From f40bfc9267b13b54e6379dfe7539447662879d24 Mon Sep 17 00:00:00 2001 From: Sean Bartell Date: Sat, 25 Jun 2011 21:32:25 -0400 Subject: Add codecs to librbcodec. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Id7f4717d51ed02d67cb9f9cb3c0ada4a81843f97 Reviewed-on: http://gerrit.rockbox.org/137 Reviewed-by: Nils Wallménius Tested-by: Nils Wallménius --- android/android.make | 2 +- apps/codecs.h | 291 - apps/codecs/SOURCES | 54 - apps/codecs/a52.c | 192 - apps/codecs/a52_rm.c | 227 - apps/codecs/aac.c | 297 - apps/codecs/adx.c | 404 - apps/codecs/aiff.c | 350 - apps/codecs/aiff_enc.c | 400 - apps/codecs/alac.c | 146 - apps/codecs/ape.c | 330 - apps/codecs/asap.c | 140 - apps/codecs/atrac3_oma.c | 153 - apps/codecs/atrac3_rm.c | 215 - apps/codecs/au.c | 314 - apps/codecs/ay.c | 137 - apps/codecs/codec_crt0.c | 74 - apps/codecs/codecs.make | 206 - apps/codecs/cook.c | 202 - apps/codecs/demac/COPYING | 339 - apps/codecs/demac/Makefile | 42 - apps/codecs/demac/README | 69 - apps/codecs/demac/demac.c | 281 - apps/codecs/demac/libdemac.make | 35 - apps/codecs/demac/libdemac/SOURCES | 15 - apps/codecs/demac/libdemac/crc.c | 120 - apps/codecs/demac/libdemac/decoder.c | 216 - apps/codecs/demac/libdemac/decoder.h | 40 - apps/codecs/demac/libdemac/demac.h | 45 - apps/codecs/demac/libdemac/demac_config.h | 145 - apps/codecs/demac/libdemac/entropy.c | 464 - apps/codecs/demac/libdemac/entropy.h | 40 - apps/codecs/demac/libdemac/filter.c | 296 - apps/codecs/demac/libdemac/filter.h | 50 - apps/codecs/demac/libdemac/filter_1280_15.c | 32 - apps/codecs/demac/libdemac/filter_16_11.c | 27 - apps/codecs/demac/libdemac/filter_256_13.c | 32 - apps/codecs/demac/libdemac/filter_32_10.c | 27 - apps/codecs/demac/libdemac/filter_64_11.c | 27 - apps/codecs/demac/libdemac/parser.c | 402 - apps/codecs/demac/libdemac/parser.h | 137 - apps/codecs/demac/libdemac/predictor-arm.S | 702 - apps/codecs/demac/libdemac/predictor-cf.S | 660 - apps/codecs/demac/libdemac/predictor.c | 271 - apps/codecs/demac/libdemac/predictor.h | 38 - apps/codecs/demac/libdemac/udiv32_arm-pre.S | 25 - apps/codecs/demac/libdemac/udiv32_arm.S | 318 - apps/codecs/demac/libdemac/vector_math16_armv5te.h | 404 - apps/codecs/demac/libdemac/vector_math16_armv6.h | 490 - apps/codecs/demac/libdemac/vector_math16_armv7.h | 214 - apps/codecs/demac/libdemac/vector_math16_cf.h | 364 - apps/codecs/demac/libdemac/vector_math16_mmx.h | 234 - apps/codecs/demac/libdemac/vector_math32_armv4.h | 201 - apps/codecs/demac/libdemac/vector_math_generic.h | 160 - apps/codecs/demac/wavwrite.c | 110 - apps/codecs/demac/wavwrite.h | 32 - apps/codecs/flac.c | 536 - apps/codecs/gbs.c | 108 - apps/codecs/hes.c | 108 - apps/codecs/kss.c | 111 - apps/codecs/lib/SOURCES | 12 - apps/codecs/lib/asm_arm.h | 292 - apps/codecs/lib/asm_mcf5249.h | 353 - apps/codecs/lib/codeclib.c | 182 - apps/codecs/lib/codeclib.h | 163 - apps/codecs/lib/codeclib_misc.h | 310 - apps/codecs/lib/ffmpeg_bitstream.c | 374 - apps/codecs/lib/ffmpeg_bswap.h | 150 - apps/codecs/lib/ffmpeg_get_bits.h | 743 - apps/codecs/lib/ffmpeg_intreadwrite.h | 484 - apps/codecs/lib/ffmpeg_put_bits.h | 323 - apps/codecs/lib/fft-ffmpeg.c | 473 - apps/codecs/lib/fft-ffmpeg_arm.h | 456 - apps/codecs/lib/fft-ffmpeg_cf.h | 370 - apps/codecs/lib/fft.h | 64 - apps/codecs/lib/fixedpoint.c | 1 - apps/codecs/lib/fixedpoint.h | 49 - apps/codecs/lib/libcodec.make | 37 - apps/codecs/lib/mdct.c | 644 - apps/codecs/lib/mdct.h | 139 - apps/codecs/lib/mdct_lookup.c | 872 - apps/codecs/lib/mdct_lookup.h | 24 - apps/codecs/lib/osx.dummy.c | 0 apps/codecs/liba52/AUTHORS | 23 - apps/codecs/liba52/COPYING | 340 - apps/codecs/liba52/ChangeLog | 97 - apps/codecs/liba52/HISTORY | 28 - apps/codecs/liba52/INSTALL | 58 - apps/codecs/liba52/NEWS | 46 - apps/codecs/liba52/README | 180 - apps/codecs/liba52/README.rockbox | 27 - apps/codecs/liba52/SOURCES | 5 - apps/codecs/liba52/TODO | 17 - apps/codecs/liba52/a52.h | 67 - apps/codecs/liba52/a52_internal.h | 215 - apps/codecs/liba52/attributes.h | 37 - apps/codecs/liba52/bit_allocate.c | 265 - apps/codecs/liba52/bitstream.c | 97 - apps/codecs/liba52/bitstream.h | 54 - apps/codecs/liba52/config-a52.h | 26 - apps/codecs/liba52/downmix.c | 688 - apps/codecs/liba52/imdct.c | 486 - apps/codecs/liba52/imdct_lookups.h | 15 - apps/codecs/liba52/liba52.make | 18 - apps/codecs/liba52/mm_accel.h | 37 - apps/codecs/liba52/parse.c | 956 -- apps/codecs/liba52/tables.h | 246 - apps/codecs/liba52/tendra.h | 35 - apps/codecs/libalac/README | 43 - apps/codecs/libalac/README.rockbox | 80 - apps/codecs/libalac/SOURCES | 1 - apps/codecs/libalac/alac.c | 1148 -- apps/codecs/libalac/decomp.h | 54 - apps/codecs/libalac/libalac.make | 18 - apps/codecs/libasap/CREDITS | 58 - apps/codecs/libasap/README | 148 - apps/codecs/libasap/README.rockbox | 22 - apps/codecs/libasap/SOURCES | 3 - apps/codecs/libasap/acpu.c | 1291 -- apps/codecs/libasap/anylang.h | 218 - apps/codecs/libasap/apokeysnd.c | 599 - apps/codecs/libasap/asap.c | 2273 --- apps/codecs/libasap/asap.h | 328 - apps/codecs/libasap/asap_internal.h | 115 - apps/codecs/libasap/libasap.make | 18 - apps/codecs/libasap/players.h | 1386 -- apps/codecs/libasf/SOURCES | 1 - apps/codecs/libasf/asf.c | 435 - apps/codecs/libasf/asf.h | 49 - apps/codecs/libasf/libasf.make | 18 - apps/codecs/libatrac/README.rockbox | 30 - apps/codecs/libatrac/SOURCES | 8 - apps/codecs/libatrac/atrac3.c | 1293 -- apps/codecs/libatrac/atrac3.h | 114 - apps/codecs/libatrac/atrac3_arm.S | 172 - apps/codecs/libatrac/atrac3_armv5e.S | 163 - apps/codecs/libatrac/atrac3data.h | 148 - apps/codecs/libatrac/atrac3data_fixed.h | 108 - apps/codecs/libatrac/fixp_math.h | 111 - apps/codecs/libatrac/libatrac.make | 18 - apps/codecs/libcook/README.rockbox | 47 - apps/codecs/libcook/SOURCES | 2 - apps/codecs/libcook/cook.c | 907 - apps/codecs/libcook/cook.h | 131 - apps/codecs/libcook/cook_fixpoint.h | 278 - apps/codecs/libcook/cookdata.h | 493 - apps/codecs/libcook/cookdata_fixpoint.h | 164 - apps/codecs/libcook/libcook.make | 18 - apps/codecs/libfaad/COPYING | 350 - apps/codecs/libfaad/README | 122 - apps/codecs/libfaad/README.rockbox | 19 - apps/codecs/libfaad/SOURCES | 27 - apps/codecs/libfaad/analysis.h | 49 - apps/codecs/libfaad/bits.c | 208 - apps/codecs/libfaad/bits.h | 381 - apps/codecs/libfaad/codebook/hcb.h | 142 - apps/codecs/libfaad/codebook/hcb_1.h | 183 - apps/codecs/libfaad/codebook/hcb_10.h | 309 - apps/codecs/libfaad/codebook/hcb_11.h | 412 - apps/codecs/libfaad/codebook/hcb_2.h | 182 - apps/codecs/libfaad/codebook/hcb_3.h | 193 - apps/codecs/libfaad/codebook/hcb_4.h | 196 - apps/codecs/libfaad/codebook/hcb_5.h | 193 - apps/codecs/libfaad/codebook/hcb_6.h | 179 - apps/codecs/libfaad/codebook/hcb_7.h | 159 - apps/codecs/libfaad/codebook/hcb_8.h | 170 - apps/codecs/libfaad/codebook/hcb_9.h | 369 - apps/codecs/libfaad/codebook/hcb_sf.h | 273 - apps/codecs/libfaad/common.c | 440 - apps/codecs/libfaad/common.h | 475 - apps/codecs/libfaad/decoder.c | 1029 -- apps/codecs/libfaad/decoder.h | 112 - apps/codecs/libfaad/drc.c | 168 - apps/codecs/libfaad/drc.h | 45 - apps/codecs/libfaad/drm_dec.c | 992 -- apps/codecs/libfaad/drm_dec.h | 98 - apps/codecs/libfaad/error.c | 62 - apps/codecs/libfaad/error.h | 41 - apps/codecs/libfaad/faad_config.h | 120 - apps/codecs/libfaad/filtbank.c | 482 - apps/codecs/libfaad/filtbank.h | 54 - apps/codecs/libfaad/fixed.h | 230 - apps/codecs/libfaad/hcr.c | 409 - apps/codecs/libfaad/huffman.c | 563 - apps/codecs/libfaad/huffman.h | 44 - apps/codecs/libfaad/ic_predict.c | 267 - apps/codecs/libfaad/ic_predict.h | 249 - apps/codecs/libfaad/iq_table.h | 16455 ------------------- apps/codecs/libfaad/is.c | 108 - apps/codecs/libfaad/is.h | 64 - apps/codecs/libfaad/kbd_win.h | 2294 --- apps/codecs/libfaad/libfaad.make | 19 - apps/codecs/libfaad/lt_predict.c | 215 - apps/codecs/libfaad/lt_predict.h | 63 - apps/codecs/libfaad/mp4.c | 300 - apps/codecs/libfaad/mp4.h | 51 - apps/codecs/libfaad/ms.c | 73 - apps/codecs/libfaad/ms.h | 41 - apps/codecs/libfaad/output.c | 557 - apps/codecs/libfaad/output.h | 45 - apps/codecs/libfaad/pns.c | 263 - apps/codecs/libfaad/pns.h | 53 - apps/codecs/libfaad/ps_dec.c | 1938 --- apps/codecs/libfaad/ps_dec.h | 162 - apps/codecs/libfaad/ps_syntax.c | 546 - apps/codecs/libfaad/ps_tables.h | 547 - apps/codecs/libfaad/pulse.c | 56 - apps/codecs/libfaad/pulse.h | 40 - apps/codecs/libfaad/rvlc.c | 530 - apps/codecs/libfaad/rvlc.h | 53 - apps/codecs/libfaad/sbr_dct.c | 1990 --- apps/codecs/libfaad/sbr_dct.h | 49 - apps/codecs/libfaad/sbr_dec.c | 597 - apps/codecs/libfaad/sbr_dec.h | 242 - apps/codecs/libfaad/sbr_e_nf.c | 507 - apps/codecs/libfaad/sbr_e_nf.h | 47 - apps/codecs/libfaad/sbr_fbt.c | 762 - apps/codecs/libfaad/sbr_fbt.h | 52 - apps/codecs/libfaad/sbr_hfadj.c | 1631 -- apps/codecs/libfaad/sbr_hfadj.h | 54 - apps/codecs/libfaad/sbr_hfgen.c | 539 - apps/codecs/libfaad/sbr_hfgen.h | 47 - apps/codecs/libfaad/sbr_huff.c | 357 - apps/codecs/libfaad/sbr_huff.h | 43 - apps/codecs/libfaad/sbr_noise.h | 561 - apps/codecs/libfaad/sbr_qmf.c | 561 - apps/codecs/libfaad/sbr_qmf.h | 47 - apps/codecs/libfaad/sbr_qmf_c.h | 172 - apps/codecs/libfaad/sbr_syntax.c | 868 - apps/codecs/libfaad/sbr_syntax.h | 64 - apps/codecs/libfaad/sbr_tf_grid.c | 259 - apps/codecs/libfaad/sbr_tf_grid.h | 44 - apps/codecs/libfaad/sine_win.h | 4301 ----- apps/codecs/libfaad/specrec.c | 1092 -- apps/codecs/libfaad/specrec.h | 46 - apps/codecs/libfaad/structs.h | 473 - apps/codecs/libfaad/syntax.c | 2368 --- apps/codecs/libfaad/syntax.h | 124 - apps/codecs/libfaad/tns.c | 312 - apps/codecs/libfaad/tns.h | 48 - apps/codecs/libffmpegFLAC/COPYING | 504 - apps/codecs/libffmpegFLAC/README | 19 - apps/codecs/libffmpegFLAC/README.rockbox | 46 - apps/codecs/libffmpegFLAC/SOURCES | 7 - apps/codecs/libffmpegFLAC/arm.S | 271 - apps/codecs/libffmpegFLAC/arm.h | 8 - apps/codecs/libffmpegFLAC/bitstream.h | 79 - apps/codecs/libffmpegFLAC/coldfire.S | 535 - apps/codecs/libffmpegFLAC/coldfire.h | 11 - apps/codecs/libffmpegFLAC/decoder.c | 627 - apps/codecs/libffmpegFLAC/decoder.h | 49 - apps/codecs/libffmpegFLAC/golomb.h | 110 - apps/codecs/libffmpegFLAC/libffmpegFLAC.make | 18 - apps/codecs/libffmpegFLAC/shndec.c | 481 - apps/codecs/libffmpegFLAC/shndec.h | 52 - apps/codecs/libgme/2413tone.h | 20 - apps/codecs/libgme/281btone.h | 20 - apps/codecs/libgme/AYSOURCES | 7 - apps/codecs/libgme/EMU2413SOURCES | 4 - apps/codecs/libgme/GBSSOURCES | 9 - apps/codecs/libgme/HESSOURCES | 8 - apps/codecs/libgme/KSSSOURCES | 12 - apps/codecs/libgme/NSFSOURCES | 15 - apps/codecs/libgme/SGCSOURCES | 7 - apps/codecs/libgme/VGMSOURCES | 10 - apps/codecs/libgme/ay_apu.c | 413 - apps/codecs/libgme/ay_apu.h | 79 - apps/codecs/libgme/ay_cpu.c | 59 - apps/codecs/libgme/ay_emu.c | 599 - apps/codecs/libgme/ay_emu.h | 169 - apps/codecs/libgme/blargg_common.h | 160 - apps/codecs/libgme/blargg_config.h | 42 - apps/codecs/libgme/blargg_endian.h | 168 - apps/codecs/libgme/blargg_source.h | 76 - apps/codecs/libgme/blip_buffer.c | 225 - apps/codecs/libgme/blip_buffer.h | 335 - apps/codecs/libgme/emu2413.c | 1981 --- apps/codecs/libgme/emu2413.h | 164 - apps/codecs/libgme/emu8950.c | 1206 -- apps/codecs/libgme/emu8950.h | 248 - apps/codecs/libgme/emuadpcm.c | 297 - apps/codecs/libgme/emuadpcm.h | 52 - apps/codecs/libgme/emutables.h | 210 - apps/codecs/libgme/emutypes.h | 41 - apps/codecs/libgme/gb_apu.c | 410 - apps/codecs/libgme/gb_apu.h | 85 - apps/codecs/libgme/gb_cpu.c | 53 - apps/codecs/libgme/gb_cpu.h | 80 - apps/codecs/libgme/gb_cpu_run.h | 1187 -- apps/codecs/libgme/gb_oscs.c | 787 - apps/codecs/libgme/gb_oscs.h | 187 - apps/codecs/libgme/gbs_cpu.c | 120 - apps/codecs/libgme/gbs_emu.c | 452 - apps/codecs/libgme/gbs_emu.h | 192 - apps/codecs/libgme/gme.h | 18 - apps/codecs/libgme/hes_apu.c | 371 - apps/codecs/libgme/hes_apu.h | 66 - apps/codecs/libgme/hes_apu_adpcm.c | 297 - apps/codecs/libgme/hes_apu_adpcm.h | 89 - apps/codecs/libgme/hes_cpu.c | 121 - apps/codecs/libgme/hes_cpu.h | 132 - apps/codecs/libgme/hes_cpu_run.h | 1344 -- apps/codecs/libgme/hes_emu.c | 644 - apps/codecs/libgme/hes_emu.h | 195 - apps/codecs/libgme/inflate/bbfuncs.c | 147 - apps/codecs/libgme/inflate/bbfuncs.h | 33 - apps/codecs/libgme/inflate/inflate.c | 1156 -- apps/codecs/libgme/inflate/inflate.h | 30 - apps/codecs/libgme/inflate/mallocer.c | 86 - apps/codecs/libgme/inflate/mallocer.h | 16 - apps/codecs/libgme/inflate/mbreader.c | 16 - apps/codecs/libgme/inflate/mbreader.h | 15 - apps/codecs/libgme/kss_cpu.c | 35 - apps/codecs/libgme/kss_emu.c | 714 - apps/codecs/libgme/kss_emu.h | 223 - apps/codecs/libgme/kss_scc_apu.c | 166 - apps/codecs/libgme/kss_scc_apu.h | 51 - apps/codecs/libgme/libay.make | 10 - apps/codecs/libgme/libemu2413.make | 10 - apps/codecs/libgme/libgbs.make | 10 - apps/codecs/libgme/libhes.make | 10 - apps/codecs/libgme/libkss.make | 10 - apps/codecs/libgme/libnsf.make | 10 - apps/codecs/libgme/libsgc.make | 10 - apps/codecs/libgme/libvgm.make | 10 - apps/codecs/libgme/m3u_playlist.h | 31 - apps/codecs/libgme/msxtypes.h | 36 - apps/codecs/libgme/multi_buffer.c | 286 - apps/codecs/libgme/multi_buffer.h | 114 - apps/codecs/libgme/nes_apu.c | 397 - apps/codecs/libgme/nes_apu.h | 137 - apps/codecs/libgme/nes_cpu.c | 62 - apps/codecs/libgme/nes_cpu.h | 109 - apps/codecs/libgme/nes_cpu_run.h | 1122 -- apps/codecs/libgme/nes_fds_apu.c | 291 - apps/codecs/libgme/nes_fds_apu.h | 116 - apps/codecs/libgme/nes_fme7_apu.c | 136 - apps/codecs/libgme/nes_fme7_apu.h | 90 - apps/codecs/libgme/nes_mmc5_apu.h | 61 - apps/codecs/libgme/nes_namco_apu.c | 138 - apps/codecs/libgme/nes_namco_apu.h | 71 - apps/codecs/libgme/nes_oscs.c | 592 - apps/codecs/libgme/nes_oscs.h | 164 - apps/codecs/libgme/nes_vrc6_apu.c | 192 - apps/codecs/libgme/nes_vrc6_apu.h | 62 - apps/codecs/libgme/nes_vrc7_apu.c | 88 - apps/codecs/libgme/nes_vrc7_apu.h | 52 - apps/codecs/libgme/nsf_cpu.c | 115 - apps/codecs/libgme/nsf_emu.c | 921 -- apps/codecs/libgme/nsf_emu.h | 261 - apps/codecs/libgme/nsfe_info.c | 272 - apps/codecs/libgme/nsfe_info.h | 30 - apps/codecs/libgme/opl_apu.c | 198 - apps/codecs/libgme/opl_apu.h | 63 - apps/codecs/libgme/opltables.h | 242 - apps/codecs/libgme/resampler.c | 218 - apps/codecs/libgme/resampler.h | 75 - apps/codecs/libgme/rom_data.c | 68 - apps/codecs/libgme/rom_data.h | 83 - apps/codecs/libgme/sgc_cpu.c | 36 - apps/codecs/libgme/sgc_emu.c | 480 - apps/codecs/libgme/sgc_emu.h | 195 - apps/codecs/libgme/sms_apu.c | 306 - apps/codecs/libgme/sms_apu.h | 63 - apps/codecs/libgme/sms_fm_apu.c | 82 - apps/codecs/libgme/sms_fm_apu.h | 43 - apps/codecs/libgme/track_filter.c | 294 - apps/codecs/libgme/track_filter.h | 90 - apps/codecs/libgme/vgm_emu.c | 858 - apps/codecs/libgme/vgm_emu.h | 206 - apps/codecs/libgme/vrc7tone.h | 20 - apps/codecs/libgme/ym2413_emu.c | 45 - apps/codecs/libgme/ym2413_emu.h | 61 - apps/codecs/libgme/ym2612_emu.c | 1374 -- apps/codecs/libgme/ym2612_emu.h | 248 - apps/codecs/libgme/ymtables.h | 559 - apps/codecs/libgme/z80_cpu.c | 85 - apps/codecs/libgme/z80_cpu.h | 116 - apps/codecs/libgme/z80_cpu_run.h | 1696 -- apps/codecs/libm4a/SOURCES | 2 - apps/codecs/libm4a/demux.c | 826 - apps/codecs/libm4a/libm4a.make | 18 - apps/codecs/libm4a/m4a.c | 267 - apps/codecs/libm4a/m4a.h | 138 - apps/codecs/libmad/CHANGES | 338 - apps/codecs/libmad/COPYING | 340 - apps/codecs/libmad/COPYRIGHT | 21 - apps/codecs/libmad/CREDITS | 116 - apps/codecs/libmad/D.dat | 607 - apps/codecs/libmad/README | 241 - apps/codecs/libmad/README.rockbox | 23 - apps/codecs/libmad/SOURCES | 14 - apps/codecs/libmad/TODO | 69 - apps/codecs/libmad/VERSION | 7 - apps/codecs/libmad/bit.c | 218 - apps/codecs/libmad/bit.h | 50 - apps/codecs/libmad/dct32_arm.S | 328 - apps/codecs/libmad/fixed.h | 510 - apps/codecs/libmad/frame.c | 499 - apps/codecs/libmad/frame.h | 124 - apps/codecs/libmad/global.h | 72 - apps/codecs/libmad/huffman.c | 3109 ---- apps/codecs/libmad/huffman.h | 66 - apps/codecs/libmad/imdct_l_arm.S | 1001 -- apps/codecs/libmad/imdct_mcf5249.S | 124 - apps/codecs/libmad/imdct_s.dat | 62 - apps/codecs/libmad/layer12.c | 537 - apps/codecs/libmad/layer12.h | 31 - apps/codecs/libmad/layer3.c | 3107 ---- apps/codecs/libmad/layer3.h | 30 - apps/codecs/libmad/libmad.make | 66 - apps/codecs/libmad/mad.h | 31 - apps/codecs/libmad/mad_iram.h | 57 - apps/codecs/libmad/qc_table.dat | 77 - apps/codecs/libmad/rq_table.dat | 8747 ---------- apps/codecs/libmad/sf_table.dat | 106 - apps/codecs/libmad/stream.c | 165 - apps/codecs/libmad/stream.h | 113 - apps/codecs/libmad/synth.c | 1232 -- apps/codecs/libmad/synth.h | 52 - apps/codecs/libmad/synth_full_arm.S | 340 - apps/codecs/libmusepack/AUTHORS | 10 - apps/codecs/libmusepack/COPYING | 31 - apps/codecs/libmusepack/ChangeLog | 40 - apps/codecs/libmusepack/SOURCES | 14 - apps/codecs/libmusepack/crc32.c | 57 - apps/codecs/libmusepack/decoder.h | 101 - apps/codecs/libmusepack/huffman.c | 530 - apps/codecs/libmusepack/huffman.h | 83 - apps/codecs/libmusepack/internal.h | 123 - apps/codecs/libmusepack/libmusepack.make | 18 - apps/codecs/libmusepack/minimax.h | 57 - apps/codecs/libmusepack/mpc_bits_reader.c | 181 - apps/codecs/libmusepack/mpc_bits_reader.h | 175 - apps/codecs/libmusepack/mpc_decoder.c | 767 - apps/codecs/libmusepack/mpc_demux.c | 730 - apps/codecs/libmusepack/mpc_types.h | 145 - apps/codecs/libmusepack/mpcdec.h | 212 - apps/codecs/libmusepack/mpcdec_math.h | 231 - apps/codecs/libmusepack/reader.h | 100 - apps/codecs/libmusepack/requant.c | 184 - apps/codecs/libmusepack/requant.h | 61 - apps/codecs/libmusepack/streaminfo.c | 255 - apps/codecs/libmusepack/streaminfo.h | 114 - apps/codecs/libmusepack/synth_filter.c | 610 - apps/codecs/libmusepack/synth_filter_arm.S | 693 - apps/codecs/libmusepack/synth_filter_coldfire.S | 78 - apps/codecs/libpcm/SOURCES | 11 - apps/codecs/libpcm/adpcm_seek.c | 101 - apps/codecs/libpcm/adpcm_seek.h | 39 - apps/codecs/libpcm/dialogic_oki_adpcm.c | 183 - apps/codecs/libpcm/dvi_adpcm.c | 308 - apps/codecs/libpcm/ieee_float.c | 165 - apps/codecs/libpcm/ima_adpcm_common.c | 171 - apps/codecs/libpcm/ima_adpcm_common.h | 33 - apps/codecs/libpcm/itut_g711.c | 204 - apps/codecs/libpcm/libpcm.make | 18 - apps/codecs/libpcm/linear_pcm.c | 294 - apps/codecs/libpcm/ms_adpcm.c | 168 - apps/codecs/libpcm/pcm_common.h | 190 - apps/codecs/libpcm/qt_ima_adpcm.c | 138 - apps/codecs/libpcm/support_formats.h | 55 - apps/codecs/libpcm/swf_adpcm.c | 236 - apps/codecs/libpcm/yamaha_adpcm.c | 250 - apps/codecs/librm/SOURCES | 1 - apps/codecs/librm/bytestream.h | 37 - apps/codecs/librm/librm.make | 18 - apps/codecs/librm/rm.c | 592 - apps/codecs/librm/rm.h | 102 - apps/codecs/libspc/SOURCES | 4 - apps/codecs/libspc/libspc.make | 18 - apps/codecs/libspc/spc_codec.h | 491 - apps/codecs/libspc/spc_cpu.c | 1049 -- apps/codecs/libspc/spc_dsp.c | 1594 -- apps/codecs/libspc/spc_emu.c | 397 - apps/codecs/libspc/spc_profiler.c | 66 - apps/codecs/libspc/spc_profiler.h | 72 - apps/codecs/libspeex/COPYING | 34 - apps/codecs/libspeex/README.rockbox | 30 - apps/codecs/libspeex/SOURCES | 45 - apps/codecs/libspeex/_kiss_fft_guts.h | 166 - apps/codecs/libspeex/arch.h | 242 - apps/codecs/libspeex/bits.c | 399 - apps/codecs/libspeex/cb_search.c | 621 - apps/codecs/libspeex/cb_search.h | 103 - apps/codecs/libspeex/cb_search_arm4.h | 137 - apps/codecs/libspeex/cb_search_bfin.h | 112 - apps/codecs/libspeex/cb_search_sse.h | 84 - apps/codecs/libspeex/config-speex.h | 186 - apps/codecs/libspeex/exc_10_16_table.c | 51 - apps/codecs/libspeex/exc_10_32_table.c | 67 - apps/codecs/libspeex/exc_20_32_table.c | 67 - apps/codecs/libspeex/exc_5_256_table.c | 291 - apps/codecs/libspeex/exc_5_64_table.c | 99 - apps/codecs/libspeex/exc_8_128_table.c | 163 - apps/codecs/libspeex/fftwrap.c | 288 - apps/codecs/libspeex/fftwrap.h | 58 - apps/codecs/libspeex/filterbank.c | 227 - apps/codecs/libspeex/filterbank.h | 66 - apps/codecs/libspeex/filters.c | 845 - apps/codecs/libspeex/filters.h | 90 - apps/codecs/libspeex/filters_arm4.S | 328 - apps/codecs/libspeex/filters_arm4.h | 96 - apps/codecs/libspeex/filters_bfin.h | 515 - apps/codecs/libspeex/filters_cf.S | 356 - apps/codecs/libspeex/filters_sse.h | 336 - apps/codecs/libspeex/fixed_arm4.h | 148 - apps/codecs/libspeex/fixed_arm5e.h | 178 - apps/codecs/libspeex/fixed_bfin.h | 173 - apps/codecs/libspeex/fixed_debug.h | 487 - apps/codecs/libspeex/fixed_generic.h | 106 - apps/codecs/libspeex/gain_table.c | 162 - apps/codecs/libspeex/gain_table_lbr.c | 66 - apps/codecs/libspeex/hexc_10_32_table.c | 68 - apps/codecs/libspeex/hexc_table.c | 164 - apps/codecs/libspeex/high_lsp_tables.c | 165 - apps/codecs/libspeex/jitter.c | 839 - apps/codecs/libspeex/kiss_fft.c | 523 - apps/codecs/libspeex/kiss_fft.h | 108 - apps/codecs/libspeex/kiss_fftr.c | 297 - apps/codecs/libspeex/kiss_fftr.h | 51 - apps/codecs/libspeex/libspeex.make | 66 - apps/codecs/libspeex/lpc.c | 201 - apps/codecs/libspeex/lpc.h | 53 - apps/codecs/libspeex/lpc_bfin.h | 131 - apps/codecs/libspeex/lsp.c | 661 - apps/codecs/libspeex/lsp.h | 64 - apps/codecs/libspeex/lsp_bfin.h | 89 - apps/codecs/libspeex/lsp_tables_nb.c | 362 - apps/codecs/libspeex/ltp.c | 856 - apps/codecs/libspeex/ltp.h | 141 - apps/codecs/libspeex/ltp_arm4.h | 188 - apps/codecs/libspeex/ltp_bfin.h | 419 - apps/codecs/libspeex/ltp_cf.S | 85 - apps/codecs/libspeex/ltp_sse.h | 92 - apps/codecs/libspeex/math_approx.h | 332 - apps/codecs/libspeex/mdf.c | 1177 -- apps/codecs/libspeex/misc_bfin.h | 54 - apps/codecs/libspeex/modes.c | 484 - apps/codecs/libspeex/modes.h | 161 - apps/codecs/libspeex/modes_wb.c | 374 - apps/codecs/libspeex/nb_celp.c | 1917 --- apps/codecs/libspeex/nb_celp.h | 205 - apps/codecs/libspeex/oggframing.c | 909 - apps/codecs/libspeex/os_support.h | 165 - apps/codecs/libspeex/preprocess.c | 1185 -- apps/codecs/libspeex/pseudofloat.h | 382 - apps/codecs/libspeex/quant_lsp.c | 391 - apps/codecs/libspeex/quant_lsp.h | 74 - apps/codecs/libspeex/quant_lsp_bfin.h | 165 - apps/codecs/libspeex/resample.c | 1140 -- apps/codecs/libspeex/rockbox.h | 119 - apps/codecs/libspeex/sb_celp.c | 1510 -- apps/codecs/libspeex/sb_celp.h | 160 - apps/codecs/libspeex/smallft.c | 1261 -- apps/codecs/libspeex/smallft.h | 46 - apps/codecs/libspeex/speex.c | 252 - apps/codecs/libspeex/speex/ogg.h | 216 - apps/codecs/libspeex/speex/speex.h | 428 - apps/codecs/libspeex/speex/speex_bits.h | 184 - apps/codecs/libspeex/speex/speex_callbacks.h | 134 - apps/codecs/libspeex/speex/speex_config_types.h | 13 - apps/codecs/libspeex/speex/speex_echo.h | 123 - apps/codecs/libspeex/speex/speex_header.h | 91 - apps/codecs/libspeex/speex/speex_jitter.h | 197 - apps/codecs/libspeex/speex/speex_preprocess.h | 190 - apps/codecs/libspeex/speex/speex_resampler.h | 328 - apps/codecs/libspeex/speex/speex_stereo.h | 91 - apps/codecs/libspeex/speex/speex_types.h | 126 - apps/codecs/libspeex/speex_callbacks.c | 160 - apps/codecs/libspeex/speex_header.c | 188 - apps/codecs/libspeex/stack_alloc.h | 130 - apps/codecs/libspeex/stereo.c | 302 - apps/codecs/libspeex/vbr.c | 275 - apps/codecs/libspeex/vbr.h | 70 - apps/codecs/libspeex/vorbis_psy.c | 508 - apps/codecs/libspeex/vorbis_psy.h | 97 - apps/codecs/libspeex/vq.c | 147 - apps/codecs/libspeex/vq.h | 54 - apps/codecs/libspeex/vq_arm4.h | 115 - apps/codecs/libspeex/vq_bfin.h | 107 - apps/codecs/libspeex/vq_sse.h | 120 - apps/codecs/libspeex/window.c | 102 - apps/codecs/libtremor/CHANGELOG | 19 - apps/codecs/libtremor/COPYING | 28 - apps/codecs/libtremor/README | 46 - apps/codecs/libtremor/README.rockbox | 17 - apps/codecs/libtremor/SOURCES | 16 - apps/codecs/libtremor/asm_arm.h | 190 - apps/codecs/libtremor/asm_mcf5249.h | 85 - apps/codecs/libtremor/backends.h | 133 - apps/codecs/libtremor/bitwise.c | 867 - apps/codecs/libtremor/block.c | 471 - apps/codecs/libtremor/codebook.c | 587 - apps/codecs/libtremor/codebook.h | 101 - apps/codecs/libtremor/codec_internal.h | 93 - apps/codecs/libtremor/config-tremor.h | 55 - apps/codecs/libtremor/config_types.h | 25 - apps/codecs/libtremor/ctype.c | 4 - apps/codecs/libtremor/ffmpeg_stuff.h | 140 - apps/codecs/libtremor/floor0.c | 444 - apps/codecs/libtremor/floor1.c | 426 - apps/codecs/libtremor/framing.c | 2102 --- apps/codecs/libtremor/info.c | 330 - apps/codecs/libtremor/ivorbiscodec.h | 204 - apps/codecs/libtremor/ivorbisfile.h | 131 - apps/codecs/libtremor/libtremor.make | 18 - apps/codecs/libtremor/lsp_lookup.h | 132 - apps/codecs/libtremor/mapping0.c | 416 - apps/codecs/libtremor/misc.h | 276 - apps/codecs/libtremor/ogg.h | 282 - apps/codecs/libtremor/oggmalloc.c | 86 - apps/codecs/libtremor/os.h | 62 - apps/codecs/libtremor/os_types.h | 58 - apps/codecs/libtremor/registry.c | 50 - apps/codecs/libtremor/registry.h | 40 - apps/codecs/libtremor/res012.c | 374 - apps/codecs/libtremor/sharedbook.c | 460 - apps/codecs/libtremor/synthesis.c | 129 - apps/codecs/libtremor/vorbisfile.c | 1671 -- apps/codecs/libtremor/window.c | 82 - apps/codecs/libtremor/window.h | 27 - apps/codecs/libtremor/window_lookup.h | 2087 --- apps/codecs/libtta/README | 72 - apps/codecs/libtta/README.rockbox | 33 - apps/codecs/libtta/SOURCES | 7 - apps/codecs/libtta/filter.h | 136 - apps/codecs/libtta/filter_arm.S | 198 - apps/codecs/libtta/filter_coldfire.S | 164 - apps/codecs/libtta/libtta.make | 18 - apps/codecs/libtta/ttadec.c | 582 - apps/codecs/libtta/ttadec.h | 203 - apps/codecs/libtta/ttalib.h | 157 - apps/codecs/libwavpack/LICENSE | 25 - apps/codecs/libwavpack/README | 52 - apps/codecs/libwavpack/README.rockbox | 15 - apps/codecs/libwavpack/SOURCES | 15 - apps/codecs/libwavpack/arm.S | 477 - apps/codecs/libwavpack/arml.S | 506 - apps/codecs/libwavpack/bits.c | 170 - apps/codecs/libwavpack/coldfire.S | 537 - apps/codecs/libwavpack/float.c | 47 - apps/codecs/libwavpack/libwavpack.make | 18 - apps/codecs/libwavpack/make.bat | 1 - apps/codecs/libwavpack/metadata.c | 171 - apps/codecs/libwavpack/pack.c | 470 - apps/codecs/libwavpack/unpack.c | 780 - apps/codecs/libwavpack/wavpack.h | 447 - apps/codecs/libwavpack/words.c | 786 - apps/codecs/libwavpack/wputils.c | 555 - apps/codecs/libwma/SOURCES | 3 - apps/codecs/libwma/libwma.make | 18 - apps/codecs/libwma/types.h | 5 - apps/codecs/libwma/wmadata.h | 2609 --- apps/codecs/libwma/wmadec.h | 181 - apps/codecs/libwma/wmadeci.c | 1445 -- apps/codecs/libwma/wmafixed.c | 223 - apps/codecs/libwma/wmafixed.h | 237 - apps/codecs/libwmapro/README.rockbox | 20 - apps/codecs/libwmapro/SOURCES | 4 - apps/codecs/libwmapro/libwmapro.make | 18 - apps/codecs/libwmapro/mdct_tables.c | 3391 ---- apps/codecs/libwmapro/mdct_tables.h | 10 - apps/codecs/libwmapro/quant.h | 53 - apps/codecs/libwmapro/wma.c | 164 - apps/codecs/libwmapro/wma.h | 75 - apps/codecs/libwmapro/wmapro_math.h | 250 - apps/codecs/libwmapro/wmaprodata.h | 615 - apps/codecs/libwmapro/wmaprodec.c | 1626 -- apps/codecs/libwmapro/wmaprodec.h | 44 - apps/codecs/libwmavoice/Makefile | 64 - apps/codecs/libwmavoice/README.rockbox | 26 - apps/codecs/libwmavoice/SOURCES | 17 - apps/codecs/libwmavoice/acelp_filters.c | 145 - apps/codecs/libwmavoice/acelp_filters.h | 120 - apps/codecs/libwmavoice/acelp_vectors.c | 270 - apps/codecs/libwmavoice/acelp_vectors.h | 264 - apps/codecs/libwmavoice/avcodec.h | 4044 ----- apps/codecs/libwmavoice/avfft.c | 142 - apps/codecs/libwmavoice/avfft.h | 99 - apps/codecs/libwmavoice/bitstream.c | 341 - apps/codecs/libwmavoice/celp_filters.c | 210 - apps/codecs/libwmavoice/celp_filters.h | 119 - apps/codecs/libwmavoice/celp_math.c | 208 - apps/codecs/libwmavoice/celp_math.h | 76 - apps/codecs/libwmavoice/dct.c | 226 - apps/codecs/libwmavoice/dct32.c | 267 - apps/codecs/libwmavoice/fft.c | 298 - apps/codecs/libwmavoice/fft.h | 244 - apps/codecs/libwmavoice/get_bits.h | 691 - apps/codecs/libwmavoice/internal.h | 53 - apps/codecs/libwmavoice/libavutil/attributes.h | 121 - apps/codecs/libwmavoice/libavutil/avutil.h | 89 - apps/codecs/libwmavoice/libavutil/bswap.h | 124 - apps/codecs/libwmavoice/libavutil/common.h | 346 - apps/codecs/libwmavoice/libavutil/internal.h | 234 - apps/codecs/libwmavoice/libavutil/intreadwrite.h | 522 - apps/codecs/libwmavoice/libavutil/log.c | 150 - apps/codecs/libwmavoice/libavutil/log.h | 138 - apps/codecs/libwmavoice/libavutil/lzo.c | 280 - apps/codecs/libwmavoice/libavutil/lzo.h | 66 - apps/codecs/libwmavoice/libavutil/mathematics.c | 183 - apps/codecs/libwmavoice/libavutil/mathematics.h | 112 - apps/codecs/libwmavoice/libavutil/mem.c | 176 - apps/codecs/libwmavoice/libavutil/mem.h | 126 - apps/codecs/libwmavoice/libwmavoice.make | 37 - apps/codecs/libwmavoice/lsp.c | 174 - apps/codecs/libwmavoice/lsp.h | 120 - apps/codecs/libwmavoice/mathops.h | 182 - apps/codecs/libwmavoice/mdct.c | 234 - apps/codecs/libwmavoice/mdct_tablegen.h | 60 - apps/codecs/libwmavoice/put_bits.h | 343 - apps/codecs/libwmavoice/rdft.c | 133 - apps/codecs/libwmavoice/utils.c | 1188 -- apps/codecs/libwmavoice/wmavoice.c | 2060 --- apps/codecs/libwmavoice/wmavoice.h | 7 - apps/codecs/libwmavoice/wmavoice_data.h | 3259 ---- apps/codecs/libwmavoice/wmavoice_mainbuild.patch | 32 - apps/codecs/mod.c | 1353 -- apps/codecs/mp3_enc.c | 2629 --- apps/codecs/mpa.c | 521 - apps/codecs/mpc.c | 186 - apps/codecs/nsf.c | 135 - apps/codecs/raac.c | 212 - apps/codecs/sgc.c | 123 - apps/codecs/shorten.c | 164 - apps/codecs/sid.c | 1340 -- apps/codecs/smaf.c | 492 - apps/codecs/spc.c | 586 - apps/codecs/speex.c | 583 - apps/codecs/tta.c | 127 - apps/codecs/vgm.c | 142 - apps/codecs/vorbis.c | 263 - apps/codecs/vox.c | 201 - apps/codecs/wav.c | 437 - apps/codecs/wav64.c | 441 - apps/codecs/wav_enc.c | 386 - apps/codecs/wavpack.c | 127 - apps/codecs/wavpack_enc.c | 467 - apps/codecs/wma.c | 196 - apps/codecs/wmapro.c | 152 - apps/codecs/wmavoice.c | 195 - apps/plugins/plugins.make | 2 +- firmware/target/hosted/ypr0/ypr0.make | 2 +- lib/rbcodec/codecs/SOURCES | 54 + lib/rbcodec/codecs/a52.c | 192 + lib/rbcodec/codecs/a52_rm.c | 227 + lib/rbcodec/codecs/aac.c | 297 + lib/rbcodec/codecs/adx.c | 404 + lib/rbcodec/codecs/aiff.c | 350 + lib/rbcodec/codecs/aiff_enc.c | 400 + lib/rbcodec/codecs/alac.c | 146 + lib/rbcodec/codecs/ape.c | 330 + lib/rbcodec/codecs/asap.c | 140 + lib/rbcodec/codecs/atrac3_oma.c | 153 + lib/rbcodec/codecs/atrac3_rm.c | 215 + lib/rbcodec/codecs/au.c | 314 + lib/rbcodec/codecs/ay.c | 137 + lib/rbcodec/codecs/codec_crt0.c | 74 + lib/rbcodec/codecs/codecs.h | 291 + lib/rbcodec/codecs/codecs.make | 206 + lib/rbcodec/codecs/cook.c | 202 + lib/rbcodec/codecs/demac/COPYING | 339 + lib/rbcodec/codecs/demac/Makefile | 42 + lib/rbcodec/codecs/demac/README | 69 + lib/rbcodec/codecs/demac/demac.c | 281 + lib/rbcodec/codecs/demac/libdemac.make | 35 + lib/rbcodec/codecs/demac/libdemac/SOURCES | 15 + lib/rbcodec/codecs/demac/libdemac/crc.c | 120 + lib/rbcodec/codecs/demac/libdemac/decoder.c | 216 + lib/rbcodec/codecs/demac/libdemac/decoder.h | 40 + lib/rbcodec/codecs/demac/libdemac/demac.h | 45 + lib/rbcodec/codecs/demac/libdemac/demac_config.h | 145 + lib/rbcodec/codecs/demac/libdemac/entropy.c | 464 + lib/rbcodec/codecs/demac/libdemac/entropy.h | 40 + lib/rbcodec/codecs/demac/libdemac/filter.c | 296 + lib/rbcodec/codecs/demac/libdemac/filter.h | 50 + lib/rbcodec/codecs/demac/libdemac/filter_1280_15.c | 32 + lib/rbcodec/codecs/demac/libdemac/filter_16_11.c | 27 + lib/rbcodec/codecs/demac/libdemac/filter_256_13.c | 32 + lib/rbcodec/codecs/demac/libdemac/filter_32_10.c | 27 + lib/rbcodec/codecs/demac/libdemac/filter_64_11.c | 27 + lib/rbcodec/codecs/demac/libdemac/parser.c | 402 + lib/rbcodec/codecs/demac/libdemac/parser.h | 137 + lib/rbcodec/codecs/demac/libdemac/predictor-arm.S | 702 + lib/rbcodec/codecs/demac/libdemac/predictor-cf.S | 660 + lib/rbcodec/codecs/demac/libdemac/predictor.c | 271 + lib/rbcodec/codecs/demac/libdemac/predictor.h | 38 + lib/rbcodec/codecs/demac/libdemac/udiv32_arm-pre.S | 25 + lib/rbcodec/codecs/demac/libdemac/udiv32_arm.S | 318 + .../codecs/demac/libdemac/vector_math16_armv5te.h | 404 + .../codecs/demac/libdemac/vector_math16_armv6.h | 490 + .../codecs/demac/libdemac/vector_math16_armv7.h | 214 + .../codecs/demac/libdemac/vector_math16_cf.h | 364 + .../codecs/demac/libdemac/vector_math16_mmx.h | 234 + .../codecs/demac/libdemac/vector_math32_armv4.h | 201 + .../codecs/demac/libdemac/vector_math_generic.h | 160 + lib/rbcodec/codecs/demac/wavwrite.c | 110 + lib/rbcodec/codecs/demac/wavwrite.h | 32 + lib/rbcodec/codecs/flac.c | 536 + lib/rbcodec/codecs/gbs.c | 108 + lib/rbcodec/codecs/hes.c | 108 + lib/rbcodec/codecs/kss.c | 111 + lib/rbcodec/codecs/lib/SOURCES | 12 + lib/rbcodec/codecs/lib/asm_arm.h | 292 + lib/rbcodec/codecs/lib/asm_mcf5249.h | 353 + lib/rbcodec/codecs/lib/codeclib.c | 182 + lib/rbcodec/codecs/lib/codeclib.h | 163 + lib/rbcodec/codecs/lib/codeclib_misc.h | 310 + lib/rbcodec/codecs/lib/ffmpeg_bitstream.c | 374 + lib/rbcodec/codecs/lib/ffmpeg_bswap.h | 150 + lib/rbcodec/codecs/lib/ffmpeg_get_bits.h | 743 + lib/rbcodec/codecs/lib/ffmpeg_intreadwrite.h | 484 + lib/rbcodec/codecs/lib/ffmpeg_put_bits.h | 323 + lib/rbcodec/codecs/lib/fft-ffmpeg.c | 473 + lib/rbcodec/codecs/lib/fft-ffmpeg_arm.h | 456 + lib/rbcodec/codecs/lib/fft-ffmpeg_cf.h | 370 + lib/rbcodec/codecs/lib/fft.h | 64 + lib/rbcodec/codecs/lib/fixedpoint.c | 1 + lib/rbcodec/codecs/lib/fixedpoint.h | 49 + lib/rbcodec/codecs/lib/libcodec.make | 37 + lib/rbcodec/codecs/lib/mdct.c | 644 + lib/rbcodec/codecs/lib/mdct.h | 139 + lib/rbcodec/codecs/lib/mdct_lookup.c | 872 + lib/rbcodec/codecs/lib/mdct_lookup.h | 24 + lib/rbcodec/codecs/lib/osx.dummy.c | 0 lib/rbcodec/codecs/liba52/AUTHORS | 23 + lib/rbcodec/codecs/liba52/COPYING | 340 + lib/rbcodec/codecs/liba52/ChangeLog | 97 + lib/rbcodec/codecs/liba52/HISTORY | 28 + lib/rbcodec/codecs/liba52/INSTALL | 58 + lib/rbcodec/codecs/liba52/NEWS | 46 + lib/rbcodec/codecs/liba52/README | 180 + lib/rbcodec/codecs/liba52/README.rockbox | 27 + lib/rbcodec/codecs/liba52/SOURCES | 5 + lib/rbcodec/codecs/liba52/TODO | 17 + lib/rbcodec/codecs/liba52/a52.h | 67 + lib/rbcodec/codecs/liba52/a52_internal.h | 215 + lib/rbcodec/codecs/liba52/attributes.h | 37 + lib/rbcodec/codecs/liba52/bit_allocate.c | 265 + lib/rbcodec/codecs/liba52/bitstream.c | 97 + lib/rbcodec/codecs/liba52/bitstream.h | 54 + lib/rbcodec/codecs/liba52/config-a52.h | 26 + lib/rbcodec/codecs/liba52/downmix.c | 688 + lib/rbcodec/codecs/liba52/imdct.c | 486 + lib/rbcodec/codecs/liba52/imdct_lookups.h | 15 + lib/rbcodec/codecs/liba52/liba52.make | 18 + lib/rbcodec/codecs/liba52/mm_accel.h | 37 + lib/rbcodec/codecs/liba52/parse.c | 956 ++ lib/rbcodec/codecs/liba52/tables.h | 246 + lib/rbcodec/codecs/liba52/tendra.h | 35 + lib/rbcodec/codecs/libalac/README | 43 + lib/rbcodec/codecs/libalac/README.rockbox | 80 + lib/rbcodec/codecs/libalac/SOURCES | 1 + lib/rbcodec/codecs/libalac/alac.c | 1148 ++ lib/rbcodec/codecs/libalac/decomp.h | 54 + lib/rbcodec/codecs/libalac/libalac.make | 18 + lib/rbcodec/codecs/libasap/CREDITS | 58 + lib/rbcodec/codecs/libasap/README | 148 + lib/rbcodec/codecs/libasap/README.rockbox | 22 + lib/rbcodec/codecs/libasap/SOURCES | 3 + lib/rbcodec/codecs/libasap/acpu.c | 1291 ++ lib/rbcodec/codecs/libasap/anylang.h | 218 + lib/rbcodec/codecs/libasap/apokeysnd.c | 599 + lib/rbcodec/codecs/libasap/asap.c | 2273 +++ lib/rbcodec/codecs/libasap/asap.h | 328 + lib/rbcodec/codecs/libasap/asap_internal.h | 115 + lib/rbcodec/codecs/libasap/libasap.make | 18 + lib/rbcodec/codecs/libasap/players.h | 1386 ++ lib/rbcodec/codecs/libasf/SOURCES | 1 + lib/rbcodec/codecs/libasf/asf.c | 435 + lib/rbcodec/codecs/libasf/asf.h | 49 + lib/rbcodec/codecs/libasf/libasf.make | 18 + lib/rbcodec/codecs/libatrac/README.rockbox | 30 + lib/rbcodec/codecs/libatrac/SOURCES | 8 + lib/rbcodec/codecs/libatrac/atrac3.c | 1293 ++ lib/rbcodec/codecs/libatrac/atrac3.h | 114 + lib/rbcodec/codecs/libatrac/atrac3_arm.S | 172 + lib/rbcodec/codecs/libatrac/atrac3_armv5e.S | 163 + lib/rbcodec/codecs/libatrac/atrac3data.h | 148 + lib/rbcodec/codecs/libatrac/atrac3data_fixed.h | 108 + lib/rbcodec/codecs/libatrac/fixp_math.h | 111 + lib/rbcodec/codecs/libatrac/libatrac.make | 18 + lib/rbcodec/codecs/libcook/README.rockbox | 47 + lib/rbcodec/codecs/libcook/SOURCES | 2 + lib/rbcodec/codecs/libcook/cook.c | 907 + lib/rbcodec/codecs/libcook/cook.h | 131 + lib/rbcodec/codecs/libcook/cook_fixpoint.h | 278 + lib/rbcodec/codecs/libcook/cookdata.h | 493 + lib/rbcodec/codecs/libcook/cookdata_fixpoint.h | 164 + lib/rbcodec/codecs/libcook/libcook.make | 18 + lib/rbcodec/codecs/libfaad/COPYING | 350 + lib/rbcodec/codecs/libfaad/README | 122 + lib/rbcodec/codecs/libfaad/README.rockbox | 19 + lib/rbcodec/codecs/libfaad/SOURCES | 27 + lib/rbcodec/codecs/libfaad/analysis.h | 49 + lib/rbcodec/codecs/libfaad/bits.c | 208 + lib/rbcodec/codecs/libfaad/bits.h | 381 + lib/rbcodec/codecs/libfaad/codebook/hcb.h | 142 + lib/rbcodec/codecs/libfaad/codebook/hcb_1.h | 183 + lib/rbcodec/codecs/libfaad/codebook/hcb_10.h | 309 + lib/rbcodec/codecs/libfaad/codebook/hcb_11.h | 412 + lib/rbcodec/codecs/libfaad/codebook/hcb_2.h | 182 + lib/rbcodec/codecs/libfaad/codebook/hcb_3.h | 193 + lib/rbcodec/codecs/libfaad/codebook/hcb_4.h | 196 + lib/rbcodec/codecs/libfaad/codebook/hcb_5.h | 193 + lib/rbcodec/codecs/libfaad/codebook/hcb_6.h | 179 + lib/rbcodec/codecs/libfaad/codebook/hcb_7.h | 159 + lib/rbcodec/codecs/libfaad/codebook/hcb_8.h | 170 + lib/rbcodec/codecs/libfaad/codebook/hcb_9.h | 369 + lib/rbcodec/codecs/libfaad/codebook/hcb_sf.h | 273 + lib/rbcodec/codecs/libfaad/common.c | 440 + lib/rbcodec/codecs/libfaad/common.h | 475 + lib/rbcodec/codecs/libfaad/decoder.c | 1029 ++ lib/rbcodec/codecs/libfaad/decoder.h | 112 + lib/rbcodec/codecs/libfaad/drc.c | 168 + lib/rbcodec/codecs/libfaad/drc.h | 45 + lib/rbcodec/codecs/libfaad/drm_dec.c | 992 ++ lib/rbcodec/codecs/libfaad/drm_dec.h | 98 + lib/rbcodec/codecs/libfaad/error.c | 62 + lib/rbcodec/codecs/libfaad/error.h | 41 + lib/rbcodec/codecs/libfaad/faad_config.h | 120 + lib/rbcodec/codecs/libfaad/filtbank.c | 482 + lib/rbcodec/codecs/libfaad/filtbank.h | 54 + lib/rbcodec/codecs/libfaad/fixed.h | 230 + lib/rbcodec/codecs/libfaad/hcr.c | 409 + lib/rbcodec/codecs/libfaad/huffman.c | 563 + lib/rbcodec/codecs/libfaad/huffman.h | 44 + lib/rbcodec/codecs/libfaad/ic_predict.c | 267 + lib/rbcodec/codecs/libfaad/ic_predict.h | 249 + lib/rbcodec/codecs/libfaad/iq_table.h | 16455 +++++++++++++++++++ lib/rbcodec/codecs/libfaad/is.c | 108 + lib/rbcodec/codecs/libfaad/is.h | 64 + lib/rbcodec/codecs/libfaad/kbd_win.h | 2294 +++ lib/rbcodec/codecs/libfaad/libfaad.make | 19 + lib/rbcodec/codecs/libfaad/lt_predict.c | 215 + lib/rbcodec/codecs/libfaad/lt_predict.h | 63 + lib/rbcodec/codecs/libfaad/mp4.c | 300 + lib/rbcodec/codecs/libfaad/mp4.h | 51 + lib/rbcodec/codecs/libfaad/ms.c | 73 + lib/rbcodec/codecs/libfaad/ms.h | 41 + lib/rbcodec/codecs/libfaad/output.c | 557 + lib/rbcodec/codecs/libfaad/output.h | 45 + lib/rbcodec/codecs/libfaad/pns.c | 263 + lib/rbcodec/codecs/libfaad/pns.h | 53 + lib/rbcodec/codecs/libfaad/ps_dec.c | 1938 +++ lib/rbcodec/codecs/libfaad/ps_dec.h | 162 + lib/rbcodec/codecs/libfaad/ps_syntax.c | 546 + lib/rbcodec/codecs/libfaad/ps_tables.h | 547 + lib/rbcodec/codecs/libfaad/pulse.c | 56 + lib/rbcodec/codecs/libfaad/pulse.h | 40 + lib/rbcodec/codecs/libfaad/rvlc.c | 530 + lib/rbcodec/codecs/libfaad/rvlc.h | 53 + lib/rbcodec/codecs/libfaad/sbr_dct.c | 1990 +++ lib/rbcodec/codecs/libfaad/sbr_dct.h | 49 + lib/rbcodec/codecs/libfaad/sbr_dec.c | 597 + lib/rbcodec/codecs/libfaad/sbr_dec.h | 242 + lib/rbcodec/codecs/libfaad/sbr_e_nf.c | 507 + lib/rbcodec/codecs/libfaad/sbr_e_nf.h | 47 + lib/rbcodec/codecs/libfaad/sbr_fbt.c | 762 + lib/rbcodec/codecs/libfaad/sbr_fbt.h | 52 + lib/rbcodec/codecs/libfaad/sbr_hfadj.c | 1631 ++ lib/rbcodec/codecs/libfaad/sbr_hfadj.h | 54 + lib/rbcodec/codecs/libfaad/sbr_hfgen.c | 539 + lib/rbcodec/codecs/libfaad/sbr_hfgen.h | 47 + lib/rbcodec/codecs/libfaad/sbr_huff.c | 357 + lib/rbcodec/codecs/libfaad/sbr_huff.h | 43 + lib/rbcodec/codecs/libfaad/sbr_noise.h | 561 + lib/rbcodec/codecs/libfaad/sbr_qmf.c | 561 + lib/rbcodec/codecs/libfaad/sbr_qmf.h | 47 + lib/rbcodec/codecs/libfaad/sbr_qmf_c.h | 172 + lib/rbcodec/codecs/libfaad/sbr_syntax.c | 868 + lib/rbcodec/codecs/libfaad/sbr_syntax.h | 64 + lib/rbcodec/codecs/libfaad/sbr_tf_grid.c | 259 + lib/rbcodec/codecs/libfaad/sbr_tf_grid.h | 44 + lib/rbcodec/codecs/libfaad/sine_win.h | 4301 +++++ lib/rbcodec/codecs/libfaad/specrec.c | 1092 ++ lib/rbcodec/codecs/libfaad/specrec.h | 46 + lib/rbcodec/codecs/libfaad/structs.h | 473 + lib/rbcodec/codecs/libfaad/syntax.c | 2368 +++ lib/rbcodec/codecs/libfaad/syntax.h | 124 + lib/rbcodec/codecs/libfaad/tns.c | 312 + lib/rbcodec/codecs/libfaad/tns.h | 48 + lib/rbcodec/codecs/libffmpegFLAC/COPYING | 504 + lib/rbcodec/codecs/libffmpegFLAC/README | 19 + lib/rbcodec/codecs/libffmpegFLAC/README.rockbox | 46 + lib/rbcodec/codecs/libffmpegFLAC/SOURCES | 7 + lib/rbcodec/codecs/libffmpegFLAC/arm.S | 271 + lib/rbcodec/codecs/libffmpegFLAC/arm.h | 8 + lib/rbcodec/codecs/libffmpegFLAC/bitstream.h | 79 + lib/rbcodec/codecs/libffmpegFLAC/coldfire.S | 535 + lib/rbcodec/codecs/libffmpegFLAC/coldfire.h | 11 + lib/rbcodec/codecs/libffmpegFLAC/decoder.c | 627 + lib/rbcodec/codecs/libffmpegFLAC/decoder.h | 49 + lib/rbcodec/codecs/libffmpegFLAC/golomb.h | 110 + .../codecs/libffmpegFLAC/libffmpegFLAC.make | 18 + lib/rbcodec/codecs/libffmpegFLAC/shndec.c | 481 + lib/rbcodec/codecs/libffmpegFLAC/shndec.h | 52 + lib/rbcodec/codecs/libgme/2413tone.h | 20 + lib/rbcodec/codecs/libgme/281btone.h | 20 + lib/rbcodec/codecs/libgme/AYSOURCES | 7 + lib/rbcodec/codecs/libgme/EMU2413SOURCES | 4 + lib/rbcodec/codecs/libgme/GBSSOURCES | 9 + lib/rbcodec/codecs/libgme/HESSOURCES | 8 + lib/rbcodec/codecs/libgme/KSSSOURCES | 12 + lib/rbcodec/codecs/libgme/NSFSOURCES | 15 + lib/rbcodec/codecs/libgme/SGCSOURCES | 7 + lib/rbcodec/codecs/libgme/VGMSOURCES | 10 + lib/rbcodec/codecs/libgme/ay_apu.c | 413 + lib/rbcodec/codecs/libgme/ay_apu.h | 79 + lib/rbcodec/codecs/libgme/ay_cpu.c | 59 + lib/rbcodec/codecs/libgme/ay_emu.c | 599 + lib/rbcodec/codecs/libgme/ay_emu.h | 169 + lib/rbcodec/codecs/libgme/blargg_common.h | 160 + lib/rbcodec/codecs/libgme/blargg_config.h | 42 + lib/rbcodec/codecs/libgme/blargg_endian.h | 168 + lib/rbcodec/codecs/libgme/blargg_source.h | 76 + lib/rbcodec/codecs/libgme/blip_buffer.c | 225 + lib/rbcodec/codecs/libgme/blip_buffer.h | 335 + lib/rbcodec/codecs/libgme/emu2413.c | 1981 +++ lib/rbcodec/codecs/libgme/emu2413.h | 164 + lib/rbcodec/codecs/libgme/emu8950.c | 1206 ++ lib/rbcodec/codecs/libgme/emu8950.h | 248 + lib/rbcodec/codecs/libgme/emuadpcm.c | 297 + lib/rbcodec/codecs/libgme/emuadpcm.h | 52 + lib/rbcodec/codecs/libgme/emutables.h | 210 + lib/rbcodec/codecs/libgme/emutypes.h | 41 + lib/rbcodec/codecs/libgme/gb_apu.c | 410 + lib/rbcodec/codecs/libgme/gb_apu.h | 85 + lib/rbcodec/codecs/libgme/gb_cpu.c | 53 + lib/rbcodec/codecs/libgme/gb_cpu.h | 80 + lib/rbcodec/codecs/libgme/gb_cpu_run.h | 1187 ++ lib/rbcodec/codecs/libgme/gb_oscs.c | 787 + lib/rbcodec/codecs/libgme/gb_oscs.h | 187 + lib/rbcodec/codecs/libgme/gbs_cpu.c | 120 + lib/rbcodec/codecs/libgme/gbs_emu.c | 452 + lib/rbcodec/codecs/libgme/gbs_emu.h | 192 + lib/rbcodec/codecs/libgme/gme.h | 18 + lib/rbcodec/codecs/libgme/hes_apu.c | 371 + lib/rbcodec/codecs/libgme/hes_apu.h | 66 + lib/rbcodec/codecs/libgme/hes_apu_adpcm.c | 297 + lib/rbcodec/codecs/libgme/hes_apu_adpcm.h | 89 + lib/rbcodec/codecs/libgme/hes_cpu.c | 121 + lib/rbcodec/codecs/libgme/hes_cpu.h | 132 + lib/rbcodec/codecs/libgme/hes_cpu_run.h | 1344 ++ lib/rbcodec/codecs/libgme/hes_emu.c | 644 + lib/rbcodec/codecs/libgme/hes_emu.h | 195 + lib/rbcodec/codecs/libgme/inflate/bbfuncs.c | 147 + lib/rbcodec/codecs/libgme/inflate/bbfuncs.h | 33 + lib/rbcodec/codecs/libgme/inflate/inflate.c | 1156 ++ lib/rbcodec/codecs/libgme/inflate/inflate.h | 30 + lib/rbcodec/codecs/libgme/inflate/mallocer.c | 86 + lib/rbcodec/codecs/libgme/inflate/mallocer.h | 16 + lib/rbcodec/codecs/libgme/inflate/mbreader.c | 16 + lib/rbcodec/codecs/libgme/inflate/mbreader.h | 15 + lib/rbcodec/codecs/libgme/kss_cpu.c | 35 + lib/rbcodec/codecs/libgme/kss_emu.c | 714 + lib/rbcodec/codecs/libgme/kss_emu.h | 223 + lib/rbcodec/codecs/libgme/kss_scc_apu.c | 166 + lib/rbcodec/codecs/libgme/kss_scc_apu.h | 51 + lib/rbcodec/codecs/libgme/libay.make | 10 + lib/rbcodec/codecs/libgme/libemu2413.make | 10 + lib/rbcodec/codecs/libgme/libgbs.make | 10 + lib/rbcodec/codecs/libgme/libhes.make | 10 + lib/rbcodec/codecs/libgme/libkss.make | 10 + lib/rbcodec/codecs/libgme/libnsf.make | 10 + lib/rbcodec/codecs/libgme/libsgc.make | 10 + lib/rbcodec/codecs/libgme/libvgm.make | 10 + lib/rbcodec/codecs/libgme/m3u_playlist.h | 31 + lib/rbcodec/codecs/libgme/msxtypes.h | 36 + lib/rbcodec/codecs/libgme/multi_buffer.c | 286 + lib/rbcodec/codecs/libgme/multi_buffer.h | 114 + lib/rbcodec/codecs/libgme/nes_apu.c | 397 + lib/rbcodec/codecs/libgme/nes_apu.h | 137 + lib/rbcodec/codecs/libgme/nes_cpu.c | 62 + lib/rbcodec/codecs/libgme/nes_cpu.h | 109 + lib/rbcodec/codecs/libgme/nes_cpu_run.h | 1122 ++ lib/rbcodec/codecs/libgme/nes_fds_apu.c | 291 + lib/rbcodec/codecs/libgme/nes_fds_apu.h | 116 + lib/rbcodec/codecs/libgme/nes_fme7_apu.c | 136 + lib/rbcodec/codecs/libgme/nes_fme7_apu.h | 90 + lib/rbcodec/codecs/libgme/nes_mmc5_apu.h | 61 + lib/rbcodec/codecs/libgme/nes_namco_apu.c | 138 + lib/rbcodec/codecs/libgme/nes_namco_apu.h | 71 + lib/rbcodec/codecs/libgme/nes_oscs.c | 592 + lib/rbcodec/codecs/libgme/nes_oscs.h | 164 + lib/rbcodec/codecs/libgme/nes_vrc6_apu.c | 192 + lib/rbcodec/codecs/libgme/nes_vrc6_apu.h | 62 + lib/rbcodec/codecs/libgme/nes_vrc7_apu.c | 88 + lib/rbcodec/codecs/libgme/nes_vrc7_apu.h | 52 + lib/rbcodec/codecs/libgme/nsf_cpu.c | 115 + lib/rbcodec/codecs/libgme/nsf_emu.c | 921 ++ lib/rbcodec/codecs/libgme/nsf_emu.h | 261 + lib/rbcodec/codecs/libgme/nsfe_info.c | 272 + lib/rbcodec/codecs/libgme/nsfe_info.h | 30 + lib/rbcodec/codecs/libgme/opl_apu.c | 198 + lib/rbcodec/codecs/libgme/opl_apu.h | 63 + lib/rbcodec/codecs/libgme/opltables.h | 242 + lib/rbcodec/codecs/libgme/resampler.c | 218 + lib/rbcodec/codecs/libgme/resampler.h | 75 + lib/rbcodec/codecs/libgme/rom_data.c | 68 + lib/rbcodec/codecs/libgme/rom_data.h | 83 + lib/rbcodec/codecs/libgme/sgc_cpu.c | 36 + lib/rbcodec/codecs/libgme/sgc_emu.c | 480 + lib/rbcodec/codecs/libgme/sgc_emu.h | 195 + lib/rbcodec/codecs/libgme/sms_apu.c | 306 + lib/rbcodec/codecs/libgme/sms_apu.h | 63 + lib/rbcodec/codecs/libgme/sms_fm_apu.c | 82 + lib/rbcodec/codecs/libgme/sms_fm_apu.h | 43 + lib/rbcodec/codecs/libgme/track_filter.c | 294 + lib/rbcodec/codecs/libgme/track_filter.h | 90 + lib/rbcodec/codecs/libgme/vgm_emu.c | 858 + lib/rbcodec/codecs/libgme/vgm_emu.h | 206 + lib/rbcodec/codecs/libgme/vrc7tone.h | 20 + lib/rbcodec/codecs/libgme/ym2413_emu.c | 45 + lib/rbcodec/codecs/libgme/ym2413_emu.h | 61 + lib/rbcodec/codecs/libgme/ym2612_emu.c | 1374 ++ lib/rbcodec/codecs/libgme/ym2612_emu.h | 248 + lib/rbcodec/codecs/libgme/ymtables.h | 559 + lib/rbcodec/codecs/libgme/z80_cpu.c | 85 + lib/rbcodec/codecs/libgme/z80_cpu.h | 116 + lib/rbcodec/codecs/libgme/z80_cpu_run.h | 1696 ++ lib/rbcodec/codecs/libm4a/SOURCES | 2 + lib/rbcodec/codecs/libm4a/demux.c | 826 + lib/rbcodec/codecs/libm4a/libm4a.make | 18 + lib/rbcodec/codecs/libm4a/m4a.c | 267 + lib/rbcodec/codecs/libm4a/m4a.h | 138 + lib/rbcodec/codecs/libmad/CHANGES | 338 + lib/rbcodec/codecs/libmad/COPYING | 340 + lib/rbcodec/codecs/libmad/COPYRIGHT | 21 + lib/rbcodec/codecs/libmad/CREDITS | 116 + lib/rbcodec/codecs/libmad/D.dat | 607 + lib/rbcodec/codecs/libmad/README | 241 + lib/rbcodec/codecs/libmad/README.rockbox | 23 + lib/rbcodec/codecs/libmad/SOURCES | 14 + lib/rbcodec/codecs/libmad/TODO | 69 + lib/rbcodec/codecs/libmad/VERSION | 7 + lib/rbcodec/codecs/libmad/bit.c | 218 + lib/rbcodec/codecs/libmad/bit.h | 50 + lib/rbcodec/codecs/libmad/dct32_arm.S | 328 + lib/rbcodec/codecs/libmad/fixed.h | 510 + lib/rbcodec/codecs/libmad/frame.c | 499 + lib/rbcodec/codecs/libmad/frame.h | 124 + lib/rbcodec/codecs/libmad/global.h | 72 + lib/rbcodec/codecs/libmad/huffman.c | 3109 ++++ lib/rbcodec/codecs/libmad/huffman.h | 66 + lib/rbcodec/codecs/libmad/imdct_l_arm.S | 1001 ++ lib/rbcodec/codecs/libmad/imdct_mcf5249.S | 124 + lib/rbcodec/codecs/libmad/imdct_s.dat | 62 + lib/rbcodec/codecs/libmad/layer12.c | 537 + lib/rbcodec/codecs/libmad/layer12.h | 31 + lib/rbcodec/codecs/libmad/layer3.c | 3107 ++++ lib/rbcodec/codecs/libmad/layer3.h | 30 + lib/rbcodec/codecs/libmad/libmad.make | 66 + lib/rbcodec/codecs/libmad/mad.h | 31 + lib/rbcodec/codecs/libmad/mad_iram.h | 57 + lib/rbcodec/codecs/libmad/qc_table.dat | 77 + lib/rbcodec/codecs/libmad/rq_table.dat | 8747 ++++++++++ lib/rbcodec/codecs/libmad/sf_table.dat | 106 + lib/rbcodec/codecs/libmad/stream.c | 165 + lib/rbcodec/codecs/libmad/stream.h | 113 + lib/rbcodec/codecs/libmad/synth.c | 1232 ++ lib/rbcodec/codecs/libmad/synth.h | 52 + lib/rbcodec/codecs/libmad/synth_full_arm.S | 340 + lib/rbcodec/codecs/libmusepack/AUTHORS | 10 + lib/rbcodec/codecs/libmusepack/COPYING | 31 + lib/rbcodec/codecs/libmusepack/ChangeLog | 40 + lib/rbcodec/codecs/libmusepack/SOURCES | 14 + lib/rbcodec/codecs/libmusepack/crc32.c | 57 + lib/rbcodec/codecs/libmusepack/decoder.h | 101 + lib/rbcodec/codecs/libmusepack/huffman.c | 530 + lib/rbcodec/codecs/libmusepack/huffman.h | 83 + lib/rbcodec/codecs/libmusepack/internal.h | 123 + lib/rbcodec/codecs/libmusepack/libmusepack.make | 18 + lib/rbcodec/codecs/libmusepack/minimax.h | 57 + lib/rbcodec/codecs/libmusepack/mpc_bits_reader.c | 181 + lib/rbcodec/codecs/libmusepack/mpc_bits_reader.h | 175 + lib/rbcodec/codecs/libmusepack/mpc_decoder.c | 767 + lib/rbcodec/codecs/libmusepack/mpc_demux.c | 730 + lib/rbcodec/codecs/libmusepack/mpc_types.h | 145 + lib/rbcodec/codecs/libmusepack/mpcdec.h | 212 + lib/rbcodec/codecs/libmusepack/mpcdec_math.h | 231 + lib/rbcodec/codecs/libmusepack/reader.h | 100 + lib/rbcodec/codecs/libmusepack/requant.c | 184 + lib/rbcodec/codecs/libmusepack/requant.h | 61 + lib/rbcodec/codecs/libmusepack/streaminfo.c | 255 + lib/rbcodec/codecs/libmusepack/streaminfo.h | 114 + lib/rbcodec/codecs/libmusepack/synth_filter.c | 610 + lib/rbcodec/codecs/libmusepack/synth_filter_arm.S | 693 + .../codecs/libmusepack/synth_filter_coldfire.S | 78 + lib/rbcodec/codecs/libpcm/SOURCES | 11 + lib/rbcodec/codecs/libpcm/adpcm_seek.c | 101 + lib/rbcodec/codecs/libpcm/adpcm_seek.h | 39 + lib/rbcodec/codecs/libpcm/dialogic_oki_adpcm.c | 183 + lib/rbcodec/codecs/libpcm/dvi_adpcm.c | 308 + lib/rbcodec/codecs/libpcm/ieee_float.c | 165 + lib/rbcodec/codecs/libpcm/ima_adpcm_common.c | 171 + lib/rbcodec/codecs/libpcm/ima_adpcm_common.h | 33 + lib/rbcodec/codecs/libpcm/itut_g711.c | 204 + lib/rbcodec/codecs/libpcm/libpcm.make | 18 + lib/rbcodec/codecs/libpcm/linear_pcm.c | 294 + lib/rbcodec/codecs/libpcm/ms_adpcm.c | 168 + lib/rbcodec/codecs/libpcm/pcm_common.h | 190 + lib/rbcodec/codecs/libpcm/qt_ima_adpcm.c | 138 + lib/rbcodec/codecs/libpcm/support_formats.h | 55 + lib/rbcodec/codecs/libpcm/swf_adpcm.c | 236 + lib/rbcodec/codecs/libpcm/yamaha_adpcm.c | 250 + lib/rbcodec/codecs/librm/SOURCES | 1 + lib/rbcodec/codecs/librm/bytestream.h | 37 + lib/rbcodec/codecs/librm/librm.make | 18 + lib/rbcodec/codecs/librm/rm.c | 592 + lib/rbcodec/codecs/librm/rm.h | 102 + lib/rbcodec/codecs/libspc/SOURCES | 4 + lib/rbcodec/codecs/libspc/libspc.make | 18 + lib/rbcodec/codecs/libspc/spc_codec.h | 491 + lib/rbcodec/codecs/libspc/spc_cpu.c | 1049 ++ lib/rbcodec/codecs/libspc/spc_dsp.c | 1594 ++ lib/rbcodec/codecs/libspc/spc_emu.c | 397 + lib/rbcodec/codecs/libspc/spc_profiler.c | 66 + lib/rbcodec/codecs/libspc/spc_profiler.h | 72 + lib/rbcodec/codecs/libspeex/COPYING | 34 + lib/rbcodec/codecs/libspeex/README.rockbox | 30 + lib/rbcodec/codecs/libspeex/SOURCES | 45 + lib/rbcodec/codecs/libspeex/_kiss_fft_guts.h | 166 + lib/rbcodec/codecs/libspeex/arch.h | 242 + lib/rbcodec/codecs/libspeex/bits.c | 399 + lib/rbcodec/codecs/libspeex/cb_search.c | 621 + lib/rbcodec/codecs/libspeex/cb_search.h | 103 + lib/rbcodec/codecs/libspeex/cb_search_arm4.h | 137 + lib/rbcodec/codecs/libspeex/cb_search_bfin.h | 112 + lib/rbcodec/codecs/libspeex/cb_search_sse.h | 84 + lib/rbcodec/codecs/libspeex/config-speex.h | 186 + lib/rbcodec/codecs/libspeex/exc_10_16_table.c | 51 + lib/rbcodec/codecs/libspeex/exc_10_32_table.c | 67 + lib/rbcodec/codecs/libspeex/exc_20_32_table.c | 67 + lib/rbcodec/codecs/libspeex/exc_5_256_table.c | 291 + lib/rbcodec/codecs/libspeex/exc_5_64_table.c | 99 + lib/rbcodec/codecs/libspeex/exc_8_128_table.c | 163 + lib/rbcodec/codecs/libspeex/fftwrap.c | 288 + lib/rbcodec/codecs/libspeex/fftwrap.h | 58 + lib/rbcodec/codecs/libspeex/filterbank.c | 227 + lib/rbcodec/codecs/libspeex/filterbank.h | 66 + lib/rbcodec/codecs/libspeex/filters.c | 845 + lib/rbcodec/codecs/libspeex/filters.h | 90 + lib/rbcodec/codecs/libspeex/filters_arm4.S | 328 + lib/rbcodec/codecs/libspeex/filters_arm4.h | 96 + lib/rbcodec/codecs/libspeex/filters_bfin.h | 515 + lib/rbcodec/codecs/libspeex/filters_cf.S | 356 + lib/rbcodec/codecs/libspeex/filters_sse.h | 336 + lib/rbcodec/codecs/libspeex/fixed_arm4.h | 148 + lib/rbcodec/codecs/libspeex/fixed_arm5e.h | 178 + lib/rbcodec/codecs/libspeex/fixed_bfin.h | 173 + lib/rbcodec/codecs/libspeex/fixed_debug.h | 487 + lib/rbcodec/codecs/libspeex/fixed_generic.h | 106 + lib/rbcodec/codecs/libspeex/gain_table.c | 162 + lib/rbcodec/codecs/libspeex/gain_table_lbr.c | 66 + lib/rbcodec/codecs/libspeex/hexc_10_32_table.c | 68 + lib/rbcodec/codecs/libspeex/hexc_table.c | 164 + lib/rbcodec/codecs/libspeex/high_lsp_tables.c | 165 + lib/rbcodec/codecs/libspeex/jitter.c | 839 + lib/rbcodec/codecs/libspeex/kiss_fft.c | 523 + lib/rbcodec/codecs/libspeex/kiss_fft.h | 108 + lib/rbcodec/codecs/libspeex/kiss_fftr.c | 297 + lib/rbcodec/codecs/libspeex/kiss_fftr.h | 51 + lib/rbcodec/codecs/libspeex/libspeex.make | 66 + lib/rbcodec/codecs/libspeex/lpc.c | 201 + lib/rbcodec/codecs/libspeex/lpc.h | 53 + lib/rbcodec/codecs/libspeex/lpc_bfin.h | 131 + lib/rbcodec/codecs/libspeex/lsp.c | 661 + lib/rbcodec/codecs/libspeex/lsp.h | 64 + lib/rbcodec/codecs/libspeex/lsp_bfin.h | 89 + lib/rbcodec/codecs/libspeex/lsp_tables_nb.c | 362 + lib/rbcodec/codecs/libspeex/ltp.c | 856 + lib/rbcodec/codecs/libspeex/ltp.h | 141 + lib/rbcodec/codecs/libspeex/ltp_arm4.h | 188 + lib/rbcodec/codecs/libspeex/ltp_bfin.h | 419 + lib/rbcodec/codecs/libspeex/ltp_cf.S | 85 + lib/rbcodec/codecs/libspeex/ltp_sse.h | 92 + lib/rbcodec/codecs/libspeex/math_approx.h | 332 + lib/rbcodec/codecs/libspeex/mdf.c | 1177 ++ lib/rbcodec/codecs/libspeex/misc_bfin.h | 54 + lib/rbcodec/codecs/libspeex/modes.c | 484 + lib/rbcodec/codecs/libspeex/modes.h | 161 + lib/rbcodec/codecs/libspeex/modes_wb.c | 374 + lib/rbcodec/codecs/libspeex/nb_celp.c | 1917 +++ lib/rbcodec/codecs/libspeex/nb_celp.h | 205 + lib/rbcodec/codecs/libspeex/oggframing.c | 909 + lib/rbcodec/codecs/libspeex/os_support.h | 165 + lib/rbcodec/codecs/libspeex/preprocess.c | 1185 ++ lib/rbcodec/codecs/libspeex/pseudofloat.h | 382 + lib/rbcodec/codecs/libspeex/quant_lsp.c | 391 + lib/rbcodec/codecs/libspeex/quant_lsp.h | 74 + lib/rbcodec/codecs/libspeex/quant_lsp_bfin.h | 165 + lib/rbcodec/codecs/libspeex/resample.c | 1140 ++ lib/rbcodec/codecs/libspeex/rockbox.h | 119 + lib/rbcodec/codecs/libspeex/sb_celp.c | 1510 ++ lib/rbcodec/codecs/libspeex/sb_celp.h | 160 + lib/rbcodec/codecs/libspeex/smallft.c | 1261 ++ lib/rbcodec/codecs/libspeex/smallft.h | 46 + lib/rbcodec/codecs/libspeex/speex.c | 252 + lib/rbcodec/codecs/libspeex/speex/ogg.h | 216 + lib/rbcodec/codecs/libspeex/speex/speex.h | 428 + lib/rbcodec/codecs/libspeex/speex/speex_bits.h | 184 + .../codecs/libspeex/speex/speex_callbacks.h | 134 + .../codecs/libspeex/speex/speex_config_types.h | 13 + lib/rbcodec/codecs/libspeex/speex/speex_echo.h | 123 + lib/rbcodec/codecs/libspeex/speex/speex_header.h | 91 + lib/rbcodec/codecs/libspeex/speex/speex_jitter.h | 197 + .../codecs/libspeex/speex/speex_preprocess.h | 190 + .../codecs/libspeex/speex/speex_resampler.h | 328 + lib/rbcodec/codecs/libspeex/speex/speex_stereo.h | 91 + lib/rbcodec/codecs/libspeex/speex/speex_types.h | 126 + lib/rbcodec/codecs/libspeex/speex_callbacks.c | 160 + lib/rbcodec/codecs/libspeex/speex_header.c | 188 + lib/rbcodec/codecs/libspeex/stack_alloc.h | 130 + lib/rbcodec/codecs/libspeex/stereo.c | 302 + lib/rbcodec/codecs/libspeex/vbr.c | 275 + lib/rbcodec/codecs/libspeex/vbr.h | 70 + lib/rbcodec/codecs/libspeex/vorbis_psy.c | 508 + lib/rbcodec/codecs/libspeex/vorbis_psy.h | 97 + lib/rbcodec/codecs/libspeex/vq.c | 147 + lib/rbcodec/codecs/libspeex/vq.h | 54 + lib/rbcodec/codecs/libspeex/vq_arm4.h | 115 + lib/rbcodec/codecs/libspeex/vq_bfin.h | 107 + lib/rbcodec/codecs/libspeex/vq_sse.h | 120 + lib/rbcodec/codecs/libspeex/window.c | 102 + lib/rbcodec/codecs/libtremor/CHANGELOG | 19 + lib/rbcodec/codecs/libtremor/COPYING | 28 + lib/rbcodec/codecs/libtremor/README | 46 + lib/rbcodec/codecs/libtremor/README.rockbox | 17 + lib/rbcodec/codecs/libtremor/SOURCES | 16 + lib/rbcodec/codecs/libtremor/asm_arm.h | 190 + lib/rbcodec/codecs/libtremor/asm_mcf5249.h | 85 + lib/rbcodec/codecs/libtremor/backends.h | 133 + lib/rbcodec/codecs/libtremor/bitwise.c | 867 + lib/rbcodec/codecs/libtremor/block.c | 471 + lib/rbcodec/codecs/libtremor/codebook.c | 587 + lib/rbcodec/codecs/libtremor/codebook.h | 101 + lib/rbcodec/codecs/libtremor/codec_internal.h | 93 + lib/rbcodec/codecs/libtremor/config-tremor.h | 55 + lib/rbcodec/codecs/libtremor/config_types.h | 25 + lib/rbcodec/codecs/libtremor/ctype.c | 4 + lib/rbcodec/codecs/libtremor/ffmpeg_stuff.h | 140 + lib/rbcodec/codecs/libtremor/floor0.c | 444 + lib/rbcodec/codecs/libtremor/floor1.c | 426 + lib/rbcodec/codecs/libtremor/framing.c | 2102 +++ lib/rbcodec/codecs/libtremor/info.c | 330 + lib/rbcodec/codecs/libtremor/ivorbiscodec.h | 204 + lib/rbcodec/codecs/libtremor/ivorbisfile.h | 131 + lib/rbcodec/codecs/libtremor/libtremor.make | 18 + lib/rbcodec/codecs/libtremor/lsp_lookup.h | 132 + lib/rbcodec/codecs/libtremor/mapping0.c | 416 + lib/rbcodec/codecs/libtremor/misc.h | 276 + lib/rbcodec/codecs/libtremor/ogg.h | 282 + lib/rbcodec/codecs/libtremor/oggmalloc.c | 86 + lib/rbcodec/codecs/libtremor/os.h | 62 + lib/rbcodec/codecs/libtremor/os_types.h | 58 + lib/rbcodec/codecs/libtremor/registry.c | 50 + lib/rbcodec/codecs/libtremor/registry.h | 40 + lib/rbcodec/codecs/libtremor/res012.c | 374 + lib/rbcodec/codecs/libtremor/sharedbook.c | 460 + lib/rbcodec/codecs/libtremor/synthesis.c | 129 + lib/rbcodec/codecs/libtremor/vorbisfile.c | 1671 ++ lib/rbcodec/codecs/libtremor/window.c | 82 + lib/rbcodec/codecs/libtremor/window.h | 27 + lib/rbcodec/codecs/libtremor/window_lookup.h | 2087 +++ lib/rbcodec/codecs/libtta/README | 72 + lib/rbcodec/codecs/libtta/README.rockbox | 33 + lib/rbcodec/codecs/libtta/SOURCES | 7 + lib/rbcodec/codecs/libtta/filter.h | 136 + lib/rbcodec/codecs/libtta/filter_arm.S | 198 + lib/rbcodec/codecs/libtta/filter_coldfire.S | 164 + lib/rbcodec/codecs/libtta/libtta.make | 18 + lib/rbcodec/codecs/libtta/ttadec.c | 582 + lib/rbcodec/codecs/libtta/ttadec.h | 203 + lib/rbcodec/codecs/libtta/ttalib.h | 157 + lib/rbcodec/codecs/libwavpack/LICENSE | 25 + lib/rbcodec/codecs/libwavpack/README | 52 + lib/rbcodec/codecs/libwavpack/README.rockbox | 15 + lib/rbcodec/codecs/libwavpack/SOURCES | 15 + lib/rbcodec/codecs/libwavpack/arm.S | 477 + lib/rbcodec/codecs/libwavpack/arml.S | 506 + lib/rbcodec/codecs/libwavpack/bits.c | 170 + lib/rbcodec/codecs/libwavpack/coldfire.S | 537 + lib/rbcodec/codecs/libwavpack/float.c | 47 + lib/rbcodec/codecs/libwavpack/libwavpack.make | 18 + lib/rbcodec/codecs/libwavpack/make.bat | 1 + lib/rbcodec/codecs/libwavpack/metadata.c | 171 + lib/rbcodec/codecs/libwavpack/pack.c | 470 + lib/rbcodec/codecs/libwavpack/unpack.c | 780 + lib/rbcodec/codecs/libwavpack/wavpack.h | 447 + lib/rbcodec/codecs/libwavpack/words.c | 786 + lib/rbcodec/codecs/libwavpack/wputils.c | 555 + lib/rbcodec/codecs/libwma/SOURCES | 3 + lib/rbcodec/codecs/libwma/libwma.make | 18 + lib/rbcodec/codecs/libwma/types.h | 5 + lib/rbcodec/codecs/libwma/wmadata.h | 2609 +++ lib/rbcodec/codecs/libwma/wmadec.h | 181 + lib/rbcodec/codecs/libwma/wmadeci.c | 1445 ++ lib/rbcodec/codecs/libwma/wmafixed.c | 223 + lib/rbcodec/codecs/libwma/wmafixed.h | 237 + lib/rbcodec/codecs/libwmapro/README.rockbox | 20 + lib/rbcodec/codecs/libwmapro/SOURCES | 4 + lib/rbcodec/codecs/libwmapro/libwmapro.make | 18 + lib/rbcodec/codecs/libwmapro/mdct_tables.c | 3391 ++++ lib/rbcodec/codecs/libwmapro/mdct_tables.h | 10 + lib/rbcodec/codecs/libwmapro/quant.h | 53 + lib/rbcodec/codecs/libwmapro/wma.c | 164 + lib/rbcodec/codecs/libwmapro/wma.h | 75 + lib/rbcodec/codecs/libwmapro/wmapro_math.h | 250 + lib/rbcodec/codecs/libwmapro/wmaprodata.h | 615 + lib/rbcodec/codecs/libwmapro/wmaprodec.c | 1626 ++ lib/rbcodec/codecs/libwmapro/wmaprodec.h | 44 + lib/rbcodec/codecs/libwmavoice/Makefile | 64 + lib/rbcodec/codecs/libwmavoice/README.rockbox | 26 + lib/rbcodec/codecs/libwmavoice/SOURCES | 17 + lib/rbcodec/codecs/libwmavoice/acelp_filters.c | 145 + lib/rbcodec/codecs/libwmavoice/acelp_filters.h | 120 + lib/rbcodec/codecs/libwmavoice/acelp_vectors.c | 270 + lib/rbcodec/codecs/libwmavoice/acelp_vectors.h | 264 + lib/rbcodec/codecs/libwmavoice/avcodec.h | 4044 +++++ lib/rbcodec/codecs/libwmavoice/avfft.c | 142 + lib/rbcodec/codecs/libwmavoice/avfft.h | 99 + lib/rbcodec/codecs/libwmavoice/bitstream.c | 341 + lib/rbcodec/codecs/libwmavoice/celp_filters.c | 210 + lib/rbcodec/codecs/libwmavoice/celp_filters.h | 119 + lib/rbcodec/codecs/libwmavoice/celp_math.c | 208 + lib/rbcodec/codecs/libwmavoice/celp_math.h | 76 + lib/rbcodec/codecs/libwmavoice/dct.c | 226 + lib/rbcodec/codecs/libwmavoice/dct32.c | 267 + lib/rbcodec/codecs/libwmavoice/fft.c | 298 + lib/rbcodec/codecs/libwmavoice/fft.h | 244 + lib/rbcodec/codecs/libwmavoice/get_bits.h | 691 + lib/rbcodec/codecs/libwmavoice/internal.h | 53 + .../codecs/libwmavoice/libavutil/attributes.h | 121 + lib/rbcodec/codecs/libwmavoice/libavutil/avutil.h | 89 + lib/rbcodec/codecs/libwmavoice/libavutil/bswap.h | 124 + lib/rbcodec/codecs/libwmavoice/libavutil/common.h | 346 + .../codecs/libwmavoice/libavutil/internal.h | 234 + .../codecs/libwmavoice/libavutil/intreadwrite.h | 522 + lib/rbcodec/codecs/libwmavoice/libavutil/log.c | 150 + lib/rbcodec/codecs/libwmavoice/libavutil/log.h | 138 + lib/rbcodec/codecs/libwmavoice/libavutil/lzo.c | 280 + lib/rbcodec/codecs/libwmavoice/libavutil/lzo.h | 66 + .../codecs/libwmavoice/libavutil/mathematics.c | 183 + .../codecs/libwmavoice/libavutil/mathematics.h | 112 + lib/rbcodec/codecs/libwmavoice/libavutil/mem.c | 176 + lib/rbcodec/codecs/libwmavoice/libavutil/mem.h | 126 + lib/rbcodec/codecs/libwmavoice/libwmavoice.make | 37 + lib/rbcodec/codecs/libwmavoice/lsp.c | 174 + lib/rbcodec/codecs/libwmavoice/lsp.h | 120 + lib/rbcodec/codecs/libwmavoice/mathops.h | 182 + lib/rbcodec/codecs/libwmavoice/mdct.c | 234 + lib/rbcodec/codecs/libwmavoice/mdct_tablegen.h | 60 + lib/rbcodec/codecs/libwmavoice/put_bits.h | 343 + lib/rbcodec/codecs/libwmavoice/rdft.c | 133 + lib/rbcodec/codecs/libwmavoice/utils.c | 1188 ++ lib/rbcodec/codecs/libwmavoice/wmavoice.c | 2060 +++ lib/rbcodec/codecs/libwmavoice/wmavoice.h | 7 + lib/rbcodec/codecs/libwmavoice/wmavoice_data.h | 3259 ++++ .../codecs/libwmavoice/wmavoice_mainbuild.patch | 32 + lib/rbcodec/codecs/mod.c | 1353 ++ lib/rbcodec/codecs/mp3_enc.c | 2629 +++ lib/rbcodec/codecs/mpa.c | 521 + lib/rbcodec/codecs/mpc.c | 186 + lib/rbcodec/codecs/nsf.c | 135 + lib/rbcodec/codecs/raac.c | 212 + lib/rbcodec/codecs/sgc.c | 123 + lib/rbcodec/codecs/shorten.c | 164 + lib/rbcodec/codecs/sid.c | 1340 ++ lib/rbcodec/codecs/smaf.c | 492 + lib/rbcodec/codecs/spc.c | 586 + lib/rbcodec/codecs/speex.c | 583 + lib/rbcodec/codecs/tta.c | 127 + lib/rbcodec/codecs/vgm.c | 142 + lib/rbcodec/codecs/vorbis.c | 263 + lib/rbcodec/codecs/vox.c | 201 + lib/rbcodec/codecs/wav.c | 437 + lib/rbcodec/codecs/wav64.c | 441 + lib/rbcodec/codecs/wav_enc.c | 386 + lib/rbcodec/codecs/wavpack.c | 127 + lib/rbcodec/codecs/wavpack_enc.c | 467 + lib/rbcodec/codecs/wma.c | 196 + lib/rbcodec/codecs/wmapro.c | 152 + lib/rbcodec/codecs/wmavoice.c | 195 + lib/rbcodec/rbcodec.make | 7 +- lib/rbcodec/test/warble.make | 5 +- rbutil/rbutilqt/INSTALL | 2 +- rbutil/rbutilqt/rbutilqt.qrc | 2 +- tools/buildzip.pl | 2 +- tools/codecscan.pl | 2 +- tools/configure | 1 + tools/rbspeex/Makefile | 2 +- tools/root.make | 9 +- utils/analysis/cmp-plugins-size.py | 4 +- utils/analysis/find_addr.pl | 4 +- utils/common/deploy-rbutil.py | 2 +- 1497 files changed, 247504 insertions(+), 247504 deletions(-) delete mode 100644 apps/codecs.h delete mode 100644 apps/codecs/SOURCES delete mode 100644 apps/codecs/a52.c delete mode 100644 apps/codecs/a52_rm.c delete mode 100644 apps/codecs/aac.c delete mode 100644 apps/codecs/adx.c delete mode 100644 apps/codecs/aiff.c delete mode 100644 apps/codecs/aiff_enc.c delete mode 100644 apps/codecs/alac.c delete mode 100644 apps/codecs/ape.c delete mode 100644 apps/codecs/asap.c delete mode 100644 apps/codecs/atrac3_oma.c delete mode 100644 apps/codecs/atrac3_rm.c delete mode 100644 apps/codecs/au.c delete mode 100644 apps/codecs/ay.c delete mode 100644 apps/codecs/codec_crt0.c delete mode 100644 apps/codecs/codecs.make delete mode 100644 apps/codecs/cook.c delete mode 100644 apps/codecs/demac/COPYING delete mode 100644 apps/codecs/demac/Makefile delete mode 100644 apps/codecs/demac/README delete mode 100644 apps/codecs/demac/demac.c delete mode 100644 apps/codecs/demac/libdemac.make delete mode 100644 apps/codecs/demac/libdemac/SOURCES delete mode 100644 apps/codecs/demac/libdemac/crc.c delete mode 100644 apps/codecs/demac/libdemac/decoder.c delete mode 100644 apps/codecs/demac/libdemac/decoder.h delete mode 100644 apps/codecs/demac/libdemac/demac.h delete mode 100644 apps/codecs/demac/libdemac/demac_config.h delete mode 100644 apps/codecs/demac/libdemac/entropy.c delete mode 100644 apps/codecs/demac/libdemac/entropy.h delete mode 100644 apps/codecs/demac/libdemac/filter.c delete mode 100644 apps/codecs/demac/libdemac/filter.h delete mode 100644 apps/codecs/demac/libdemac/filter_1280_15.c delete mode 100644 apps/codecs/demac/libdemac/filter_16_11.c delete mode 100644 apps/codecs/demac/libdemac/filter_256_13.c delete mode 100644 apps/codecs/demac/libdemac/filter_32_10.c delete mode 100644 apps/codecs/demac/libdemac/filter_64_11.c delete mode 100644 apps/codecs/demac/libdemac/parser.c delete mode 100644 apps/codecs/demac/libdemac/parser.h delete mode 100644 apps/codecs/demac/libdemac/predictor-arm.S delete mode 100644 apps/codecs/demac/libdemac/predictor-cf.S delete mode 100644 apps/codecs/demac/libdemac/predictor.c delete mode 100644 apps/codecs/demac/libdemac/predictor.h delete mode 100644 apps/codecs/demac/libdemac/udiv32_arm-pre.S delete mode 100644 apps/codecs/demac/libdemac/udiv32_arm.S delete mode 100644 apps/codecs/demac/libdemac/vector_math16_armv5te.h delete mode 100644 apps/codecs/demac/libdemac/vector_math16_armv6.h delete mode 100644 apps/codecs/demac/libdemac/vector_math16_armv7.h delete mode 100644 apps/codecs/demac/libdemac/vector_math16_cf.h delete mode 100644 apps/codecs/demac/libdemac/vector_math16_mmx.h delete mode 100644 apps/codecs/demac/libdemac/vector_math32_armv4.h delete mode 100644 apps/codecs/demac/libdemac/vector_math_generic.h delete mode 100644 apps/codecs/demac/wavwrite.c delete mode 100644 apps/codecs/demac/wavwrite.h delete mode 100644 apps/codecs/flac.c delete mode 100644 apps/codecs/gbs.c delete mode 100644 apps/codecs/hes.c delete mode 100644 apps/codecs/kss.c delete mode 100644 apps/codecs/lib/SOURCES delete mode 100644 apps/codecs/lib/asm_arm.h delete mode 100644 apps/codecs/lib/asm_mcf5249.h delete mode 100644 apps/codecs/lib/codeclib.c delete mode 100644 apps/codecs/lib/codeclib.h delete mode 100644 apps/codecs/lib/codeclib_misc.h delete mode 100644 apps/codecs/lib/ffmpeg_bitstream.c delete mode 100644 apps/codecs/lib/ffmpeg_bswap.h delete mode 100644 apps/codecs/lib/ffmpeg_get_bits.h delete mode 100644 apps/codecs/lib/ffmpeg_intreadwrite.h delete mode 100644 apps/codecs/lib/ffmpeg_put_bits.h delete mode 100644 apps/codecs/lib/fft-ffmpeg.c delete mode 100644 apps/codecs/lib/fft-ffmpeg_arm.h delete mode 100644 apps/codecs/lib/fft-ffmpeg_cf.h delete mode 100644 apps/codecs/lib/fft.h delete mode 100644 apps/codecs/lib/fixedpoint.c delete mode 100644 apps/codecs/lib/fixedpoint.h delete mode 100644 apps/codecs/lib/libcodec.make delete mode 100644 apps/codecs/lib/mdct.c delete mode 100644 apps/codecs/lib/mdct.h delete mode 100644 apps/codecs/lib/mdct_lookup.c delete mode 100644 apps/codecs/lib/mdct_lookup.h delete mode 100644 apps/codecs/lib/osx.dummy.c delete mode 100644 apps/codecs/liba52/AUTHORS delete mode 100644 apps/codecs/liba52/COPYING delete mode 100644 apps/codecs/liba52/ChangeLog delete mode 100644 apps/codecs/liba52/HISTORY delete mode 100644 apps/codecs/liba52/INSTALL delete mode 100644 apps/codecs/liba52/NEWS delete mode 100644 apps/codecs/liba52/README delete mode 100644 apps/codecs/liba52/README.rockbox delete mode 100644 apps/codecs/liba52/SOURCES delete mode 100644 apps/codecs/liba52/TODO delete mode 100644 apps/codecs/liba52/a52.h delete mode 100644 apps/codecs/liba52/a52_internal.h delete mode 100644 apps/codecs/liba52/attributes.h delete mode 100644 apps/codecs/liba52/bit_allocate.c delete mode 100644 apps/codecs/liba52/bitstream.c delete mode 100644 apps/codecs/liba52/bitstream.h delete mode 100644 apps/codecs/liba52/config-a52.h delete mode 100644 apps/codecs/liba52/downmix.c delete mode 100644 apps/codecs/liba52/imdct.c delete mode 100644 apps/codecs/liba52/imdct_lookups.h delete mode 100644 apps/codecs/liba52/liba52.make delete mode 100644 apps/codecs/liba52/mm_accel.h delete mode 100644 apps/codecs/liba52/parse.c delete mode 100644 apps/codecs/liba52/tables.h delete mode 100644 apps/codecs/liba52/tendra.h delete mode 100644 apps/codecs/libalac/README delete mode 100644 apps/codecs/libalac/README.rockbox delete mode 100644 apps/codecs/libalac/SOURCES delete mode 100644 apps/codecs/libalac/alac.c delete mode 100644 apps/codecs/libalac/decomp.h delete mode 100644 apps/codecs/libalac/libalac.make delete mode 100644 apps/codecs/libasap/CREDITS delete mode 100644 apps/codecs/libasap/README delete mode 100644 apps/codecs/libasap/README.rockbox delete mode 100644 apps/codecs/libasap/SOURCES delete mode 100644 apps/codecs/libasap/acpu.c delete mode 100644 apps/codecs/libasap/anylang.h delete mode 100644 apps/codecs/libasap/apokeysnd.c delete mode 100644 apps/codecs/libasap/asap.c delete mode 100644 apps/codecs/libasap/asap.h delete mode 100644 apps/codecs/libasap/asap_internal.h delete mode 100644 apps/codecs/libasap/libasap.make delete mode 100644 apps/codecs/libasap/players.h delete mode 100644 apps/codecs/libasf/SOURCES delete mode 100644 apps/codecs/libasf/asf.c delete mode 100644 apps/codecs/libasf/asf.h delete mode 100644 apps/codecs/libasf/libasf.make delete mode 100644 apps/codecs/libatrac/README.rockbox delete mode 100644 apps/codecs/libatrac/SOURCES delete mode 100644 apps/codecs/libatrac/atrac3.c delete mode 100644 apps/codecs/libatrac/atrac3.h delete mode 100644 apps/codecs/libatrac/atrac3_arm.S delete mode 100644 apps/codecs/libatrac/atrac3_armv5e.S delete mode 100644 apps/codecs/libatrac/atrac3data.h delete mode 100644 apps/codecs/libatrac/atrac3data_fixed.h delete mode 100644 apps/codecs/libatrac/fixp_math.h delete mode 100644 apps/codecs/libatrac/libatrac.make delete mode 100644 apps/codecs/libcook/README.rockbox delete mode 100644 apps/codecs/libcook/SOURCES delete mode 100644 apps/codecs/libcook/cook.c delete mode 100644 apps/codecs/libcook/cook.h delete mode 100644 apps/codecs/libcook/cook_fixpoint.h delete mode 100644 apps/codecs/libcook/cookdata.h delete mode 100644 apps/codecs/libcook/cookdata_fixpoint.h delete mode 100644 apps/codecs/libcook/libcook.make delete mode 100644 apps/codecs/libfaad/COPYING delete mode 100644 apps/codecs/libfaad/README delete mode 100644 apps/codecs/libfaad/README.rockbox delete mode 100644 apps/codecs/libfaad/SOURCES delete mode 100644 apps/codecs/libfaad/analysis.h delete mode 100644 apps/codecs/libfaad/bits.c delete mode 100644 apps/codecs/libfaad/bits.h delete mode 100644 apps/codecs/libfaad/codebook/hcb.h delete mode 100644 apps/codecs/libfaad/codebook/hcb_1.h delete mode 100644 apps/codecs/libfaad/codebook/hcb_10.h delete mode 100644 apps/codecs/libfaad/codebook/hcb_11.h delete mode 100644 apps/codecs/libfaad/codebook/hcb_2.h delete mode 100644 apps/codecs/libfaad/codebook/hcb_3.h delete mode 100644 apps/codecs/libfaad/codebook/hcb_4.h delete mode 100644 apps/codecs/libfaad/codebook/hcb_5.h delete mode 100644 apps/codecs/libfaad/codebook/hcb_6.h delete mode 100644 apps/codecs/libfaad/codebook/hcb_7.h delete mode 100644 apps/codecs/libfaad/codebook/hcb_8.h delete mode 100644 apps/codecs/libfaad/codebook/hcb_9.h delete mode 100644 apps/codecs/libfaad/codebook/hcb_sf.h delete mode 100644 apps/codecs/libfaad/common.c delete mode 100644 apps/codecs/libfaad/common.h delete mode 100644 apps/codecs/libfaad/decoder.c delete mode 100644 apps/codecs/libfaad/decoder.h delete mode 100644 apps/codecs/libfaad/drc.c delete mode 100644 apps/codecs/libfaad/drc.h delete mode 100644 apps/codecs/libfaad/drm_dec.c delete mode 100644 apps/codecs/libfaad/drm_dec.h delete mode 100644 apps/codecs/libfaad/error.c delete mode 100644 apps/codecs/libfaad/error.h delete mode 100644 apps/codecs/libfaad/faad_config.h delete mode 100644 apps/codecs/libfaad/filtbank.c delete mode 100644 apps/codecs/libfaad/filtbank.h delete mode 100644 apps/codecs/libfaad/fixed.h delete mode 100644 apps/codecs/libfaad/hcr.c delete mode 100644 apps/codecs/libfaad/huffman.c delete mode 100644 apps/codecs/libfaad/huffman.h delete mode 100644 apps/codecs/libfaad/ic_predict.c delete mode 100644 apps/codecs/libfaad/ic_predict.h delete mode 100644 apps/codecs/libfaad/iq_table.h delete mode 100644 apps/codecs/libfaad/is.c delete mode 100644 apps/codecs/libfaad/is.h delete mode 100644 apps/codecs/libfaad/kbd_win.h delete mode 100644 apps/codecs/libfaad/libfaad.make delete mode 100644 apps/codecs/libfaad/lt_predict.c delete mode 100644 apps/codecs/libfaad/lt_predict.h delete mode 100644 apps/codecs/libfaad/mp4.c delete mode 100644 apps/codecs/libfaad/mp4.h delete mode 100644 apps/codecs/libfaad/ms.c delete mode 100644 apps/codecs/libfaad/ms.h delete mode 100644 apps/codecs/libfaad/output.c delete mode 100644 apps/codecs/libfaad/output.h delete mode 100644 apps/codecs/libfaad/pns.c delete mode 100644 apps/codecs/libfaad/pns.h delete mode 100644 apps/codecs/libfaad/ps_dec.c delete mode 100644 apps/codecs/libfaad/ps_dec.h delete mode 100644 apps/codecs/libfaad/ps_syntax.c delete mode 100644 apps/codecs/libfaad/ps_tables.h delete mode 100644 apps/codecs/libfaad/pulse.c delete mode 100644 apps/codecs/libfaad/pulse.h delete mode 100644 apps/codecs/libfaad/rvlc.c delete mode 100644 apps/codecs/libfaad/rvlc.h delete mode 100644 apps/codecs/libfaad/sbr_dct.c delete mode 100644 apps/codecs/libfaad/sbr_dct.h delete mode 100644 apps/codecs/libfaad/sbr_dec.c delete mode 100644 apps/codecs/libfaad/sbr_dec.h delete mode 100644 apps/codecs/libfaad/sbr_e_nf.c delete mode 100644 apps/codecs/libfaad/sbr_e_nf.h delete mode 100644 apps/codecs/libfaad/sbr_fbt.c delete mode 100644 apps/codecs/libfaad/sbr_fbt.h delete mode 100644 apps/codecs/libfaad/sbr_hfadj.c delete mode 100644 apps/codecs/libfaad/sbr_hfadj.h delete mode 100644 apps/codecs/libfaad/sbr_hfgen.c delete mode 100644 apps/codecs/libfaad/sbr_hfgen.h delete mode 100644 apps/codecs/libfaad/sbr_huff.c delete mode 100644 apps/codecs/libfaad/sbr_huff.h delete mode 100644 apps/codecs/libfaad/sbr_noise.h delete mode 100644 apps/codecs/libfaad/sbr_qmf.c delete mode 100644 apps/codecs/libfaad/sbr_qmf.h delete mode 100644 apps/codecs/libfaad/sbr_qmf_c.h delete mode 100644 apps/codecs/libfaad/sbr_syntax.c delete mode 100644 apps/codecs/libfaad/sbr_syntax.h delete mode 100644 apps/codecs/libfaad/sbr_tf_grid.c delete mode 100644 apps/codecs/libfaad/sbr_tf_grid.h delete mode 100644 apps/codecs/libfaad/sine_win.h delete mode 100644 apps/codecs/libfaad/specrec.c delete mode 100644 apps/codecs/libfaad/specrec.h delete mode 100644 apps/codecs/libfaad/structs.h delete mode 100644 apps/codecs/libfaad/syntax.c delete mode 100644 apps/codecs/libfaad/syntax.h delete mode 100644 apps/codecs/libfaad/tns.c delete mode 100644 apps/codecs/libfaad/tns.h delete mode 100644 apps/codecs/libffmpegFLAC/COPYING delete mode 100644 apps/codecs/libffmpegFLAC/README delete mode 100644 apps/codecs/libffmpegFLAC/README.rockbox delete mode 100644 apps/codecs/libffmpegFLAC/SOURCES delete mode 100644 apps/codecs/libffmpegFLAC/arm.S delete mode 100644 apps/codecs/libffmpegFLAC/arm.h delete mode 100644 apps/codecs/libffmpegFLAC/bitstream.h delete mode 100644 apps/codecs/libffmpegFLAC/coldfire.S delete mode 100644 apps/codecs/libffmpegFLAC/coldfire.h delete mode 100644 apps/codecs/libffmpegFLAC/decoder.c delete mode 100644 apps/codecs/libffmpegFLAC/decoder.h delete mode 100644 apps/codecs/libffmpegFLAC/golomb.h delete mode 100644 apps/codecs/libffmpegFLAC/libffmpegFLAC.make delete mode 100644 apps/codecs/libffmpegFLAC/shndec.c delete mode 100644 apps/codecs/libffmpegFLAC/shndec.h delete mode 100644 apps/codecs/libgme/2413tone.h delete mode 100644 apps/codecs/libgme/281btone.h delete mode 100644 apps/codecs/libgme/AYSOURCES delete mode 100644 apps/codecs/libgme/EMU2413SOURCES delete mode 100644 apps/codecs/libgme/GBSSOURCES delete mode 100644 apps/codecs/libgme/HESSOURCES delete mode 100644 apps/codecs/libgme/KSSSOURCES delete mode 100644 apps/codecs/libgme/NSFSOURCES delete mode 100644 apps/codecs/libgme/SGCSOURCES delete mode 100644 apps/codecs/libgme/VGMSOURCES delete mode 100644 apps/codecs/libgme/ay_apu.c delete mode 100644 apps/codecs/libgme/ay_apu.h delete mode 100644 apps/codecs/libgme/ay_cpu.c delete mode 100644 apps/codecs/libgme/ay_emu.c delete mode 100644 apps/codecs/libgme/ay_emu.h delete mode 100644 apps/codecs/libgme/blargg_common.h delete mode 100644 apps/codecs/libgme/blargg_config.h delete mode 100644 apps/codecs/libgme/blargg_endian.h delete mode 100644 apps/codecs/libgme/blargg_source.h delete mode 100644 apps/codecs/libgme/blip_buffer.c delete mode 100644 apps/codecs/libgme/blip_buffer.h delete mode 100644 apps/codecs/libgme/emu2413.c delete mode 100644 apps/codecs/libgme/emu2413.h delete mode 100644 apps/codecs/libgme/emu8950.c delete mode 100644 apps/codecs/libgme/emu8950.h delete mode 100644 apps/codecs/libgme/emuadpcm.c delete mode 100644 apps/codecs/libgme/emuadpcm.h delete mode 100644 apps/codecs/libgme/emutables.h delete mode 100644 apps/codecs/libgme/emutypes.h delete mode 100644 apps/codecs/libgme/gb_apu.c delete mode 100644 apps/codecs/libgme/gb_apu.h delete mode 100644 apps/codecs/libgme/gb_cpu.c delete mode 100644 apps/codecs/libgme/gb_cpu.h delete mode 100644 apps/codecs/libgme/gb_cpu_run.h delete mode 100644 apps/codecs/libgme/gb_oscs.c delete mode 100644 apps/codecs/libgme/gb_oscs.h delete mode 100644 apps/codecs/libgme/gbs_cpu.c delete mode 100644 apps/codecs/libgme/gbs_emu.c delete mode 100644 apps/codecs/libgme/gbs_emu.h delete mode 100644 apps/codecs/libgme/gme.h delete mode 100644 apps/codecs/libgme/hes_apu.c delete mode 100644 apps/codecs/libgme/hes_apu.h delete mode 100644 apps/codecs/libgme/hes_apu_adpcm.c delete mode 100644 apps/codecs/libgme/hes_apu_adpcm.h delete mode 100644 apps/codecs/libgme/hes_cpu.c delete mode 100644 apps/codecs/libgme/hes_cpu.h delete mode 100644 apps/codecs/libgme/hes_cpu_run.h delete mode 100644 apps/codecs/libgme/hes_emu.c delete mode 100644 apps/codecs/libgme/hes_emu.h delete mode 100644 apps/codecs/libgme/inflate/bbfuncs.c delete mode 100644 apps/codecs/libgme/inflate/bbfuncs.h delete mode 100644 apps/codecs/libgme/inflate/inflate.c delete mode 100644 apps/codecs/libgme/inflate/inflate.h delete mode 100644 apps/codecs/libgme/inflate/mallocer.c delete mode 100644 apps/codecs/libgme/inflate/mallocer.h delete mode 100644 apps/codecs/libgme/inflate/mbreader.c delete mode 100644 apps/codecs/libgme/inflate/mbreader.h delete mode 100644 apps/codecs/libgme/kss_cpu.c delete mode 100644 apps/codecs/libgme/kss_emu.c delete mode 100644 apps/codecs/libgme/kss_emu.h delete mode 100644 apps/codecs/libgme/kss_scc_apu.c delete mode 100644 apps/codecs/libgme/kss_scc_apu.h delete mode 100644 apps/codecs/libgme/libay.make delete mode 100644 apps/codecs/libgme/libemu2413.make delete mode 100644 apps/codecs/libgme/libgbs.make delete mode 100644 apps/codecs/libgme/libhes.make delete mode 100644 apps/codecs/libgme/libkss.make delete mode 100644 apps/codecs/libgme/libnsf.make delete mode 100644 apps/codecs/libgme/libsgc.make delete mode 100644 apps/codecs/libgme/libvgm.make delete mode 100644 apps/codecs/libgme/m3u_playlist.h delete mode 100644 apps/codecs/libgme/msxtypes.h delete mode 100644 apps/codecs/libgme/multi_buffer.c delete mode 100644 apps/codecs/libgme/multi_buffer.h delete mode 100644 apps/codecs/libgme/nes_apu.c delete mode 100644 apps/codecs/libgme/nes_apu.h delete mode 100644 apps/codecs/libgme/nes_cpu.c delete mode 100644 apps/codecs/libgme/nes_cpu.h delete mode 100644 apps/codecs/libgme/nes_cpu_run.h delete mode 100644 apps/codecs/libgme/nes_fds_apu.c delete mode 100644 apps/codecs/libgme/nes_fds_apu.h delete mode 100644 apps/codecs/libgme/nes_fme7_apu.c delete mode 100644 apps/codecs/libgme/nes_fme7_apu.h delete mode 100644 apps/codecs/libgme/nes_mmc5_apu.h delete mode 100644 apps/codecs/libgme/nes_namco_apu.c delete mode 100644 apps/codecs/libgme/nes_namco_apu.h delete mode 100644 apps/codecs/libgme/nes_oscs.c delete mode 100644 apps/codecs/libgme/nes_oscs.h delete mode 100644 apps/codecs/libgme/nes_vrc6_apu.c delete mode 100644 apps/codecs/libgme/nes_vrc6_apu.h delete mode 100644 apps/codecs/libgme/nes_vrc7_apu.c delete mode 100644 apps/codecs/libgme/nes_vrc7_apu.h delete mode 100644 apps/codecs/libgme/nsf_cpu.c delete mode 100644 apps/codecs/libgme/nsf_emu.c delete mode 100644 apps/codecs/libgme/nsf_emu.h delete mode 100644 apps/codecs/libgme/nsfe_info.c delete mode 100644 apps/codecs/libgme/nsfe_info.h delete mode 100644 apps/codecs/libgme/opl_apu.c delete mode 100644 apps/codecs/libgme/opl_apu.h delete mode 100644 apps/codecs/libgme/opltables.h delete mode 100644 apps/codecs/libgme/resampler.c delete mode 100644 apps/codecs/libgme/resampler.h delete mode 100644 apps/codecs/libgme/rom_data.c delete mode 100644 apps/codecs/libgme/rom_data.h delete mode 100644 apps/codecs/libgme/sgc_cpu.c delete mode 100644 apps/codecs/libgme/sgc_emu.c delete mode 100644 apps/codecs/libgme/sgc_emu.h delete mode 100644 apps/codecs/libgme/sms_apu.c delete mode 100644 apps/codecs/libgme/sms_apu.h delete mode 100644 apps/codecs/libgme/sms_fm_apu.c delete mode 100644 apps/codecs/libgme/sms_fm_apu.h delete mode 100644 apps/codecs/libgme/track_filter.c delete mode 100644 apps/codecs/libgme/track_filter.h delete mode 100644 apps/codecs/libgme/vgm_emu.c delete mode 100644 apps/codecs/libgme/vgm_emu.h delete mode 100644 apps/codecs/libgme/vrc7tone.h delete mode 100644 apps/codecs/libgme/ym2413_emu.c delete mode 100644 apps/codecs/libgme/ym2413_emu.h delete mode 100644 apps/codecs/libgme/ym2612_emu.c delete mode 100644 apps/codecs/libgme/ym2612_emu.h delete mode 100644 apps/codecs/libgme/ymtables.h delete mode 100644 apps/codecs/libgme/z80_cpu.c delete mode 100644 apps/codecs/libgme/z80_cpu.h delete mode 100644 apps/codecs/libgme/z80_cpu_run.h delete mode 100644 apps/codecs/libm4a/SOURCES delete mode 100644 apps/codecs/libm4a/demux.c delete mode 100644 apps/codecs/libm4a/libm4a.make delete mode 100644 apps/codecs/libm4a/m4a.c delete mode 100644 apps/codecs/libm4a/m4a.h delete mode 100644 apps/codecs/libmad/CHANGES delete mode 100644 apps/codecs/libmad/COPYING delete mode 100644 apps/codecs/libmad/COPYRIGHT delete mode 100644 apps/codecs/libmad/CREDITS delete mode 100644 apps/codecs/libmad/D.dat delete mode 100644 apps/codecs/libmad/README delete mode 100644 apps/codecs/libmad/README.rockbox delete mode 100644 apps/codecs/libmad/SOURCES delete mode 100644 apps/codecs/libmad/TODO delete mode 100644 apps/codecs/libmad/VERSION delete mode 100644 apps/codecs/libmad/bit.c delete mode 100644 apps/codecs/libmad/bit.h delete mode 100644 apps/codecs/libmad/dct32_arm.S delete mode 100644 apps/codecs/libmad/fixed.h delete mode 100644 apps/codecs/libmad/frame.c delete mode 100644 apps/codecs/libmad/frame.h delete mode 100644 apps/codecs/libmad/global.h delete mode 100644 apps/codecs/libmad/huffman.c delete mode 100644 apps/codecs/libmad/huffman.h delete mode 100644 apps/codecs/libmad/imdct_l_arm.S delete mode 100644 apps/codecs/libmad/imdct_mcf5249.S delete mode 100644 apps/codecs/libmad/imdct_s.dat delete mode 100644 apps/codecs/libmad/layer12.c delete mode 100644 apps/codecs/libmad/layer12.h delete mode 100644 apps/codecs/libmad/layer3.c delete mode 100644 apps/codecs/libmad/layer3.h delete mode 100644 apps/codecs/libmad/libmad.make delete mode 100644 apps/codecs/libmad/mad.h delete mode 100644 apps/codecs/libmad/mad_iram.h delete mode 100644 apps/codecs/libmad/qc_table.dat delete mode 100644 apps/codecs/libmad/rq_table.dat delete mode 100644 apps/codecs/libmad/sf_table.dat delete mode 100644 apps/codecs/libmad/stream.c delete mode 100644 apps/codecs/libmad/stream.h delete mode 100644 apps/codecs/libmad/synth.c delete mode 100644 apps/codecs/libmad/synth.h delete mode 100644 apps/codecs/libmad/synth_full_arm.S delete mode 100644 apps/codecs/libmusepack/AUTHORS delete mode 100644 apps/codecs/libmusepack/COPYING delete mode 100644 apps/codecs/libmusepack/ChangeLog delete mode 100644 apps/codecs/libmusepack/SOURCES delete mode 100644 apps/codecs/libmusepack/crc32.c delete mode 100644 apps/codecs/libmusepack/decoder.h delete mode 100644 apps/codecs/libmusepack/huffman.c delete mode 100644 apps/codecs/libmusepack/huffman.h delete mode 100644 apps/codecs/libmusepack/internal.h delete mode 100644 apps/codecs/libmusepack/libmusepack.make delete mode 100644 apps/codecs/libmusepack/minimax.h delete mode 100644 apps/codecs/libmusepack/mpc_bits_reader.c delete mode 100644 apps/codecs/libmusepack/mpc_bits_reader.h delete mode 100644 apps/codecs/libmusepack/mpc_decoder.c delete mode 100644 apps/codecs/libmusepack/mpc_demux.c delete mode 100644 apps/codecs/libmusepack/mpc_types.h delete mode 100644 apps/codecs/libmusepack/mpcdec.h delete mode 100644 apps/codecs/libmusepack/mpcdec_math.h delete mode 100644 apps/codecs/libmusepack/reader.h delete mode 100644 apps/codecs/libmusepack/requant.c delete mode 100644 apps/codecs/libmusepack/requant.h delete mode 100644 apps/codecs/libmusepack/streaminfo.c delete mode 100644 apps/codecs/libmusepack/streaminfo.h delete mode 100644 apps/codecs/libmusepack/synth_filter.c delete mode 100644 apps/codecs/libmusepack/synth_filter_arm.S delete mode 100644 apps/codecs/libmusepack/synth_filter_coldfire.S delete mode 100644 apps/codecs/libpcm/SOURCES delete mode 100644 apps/codecs/libpcm/adpcm_seek.c delete mode 100644 apps/codecs/libpcm/adpcm_seek.h delete mode 100644 apps/codecs/libpcm/dialogic_oki_adpcm.c delete mode 100644 apps/codecs/libpcm/dvi_adpcm.c delete mode 100644 apps/codecs/libpcm/ieee_float.c delete mode 100644 apps/codecs/libpcm/ima_adpcm_common.c delete mode 100644 apps/codecs/libpcm/ima_adpcm_common.h delete mode 100644 apps/codecs/libpcm/itut_g711.c delete mode 100644 apps/codecs/libpcm/libpcm.make delete mode 100644 apps/codecs/libpcm/linear_pcm.c delete mode 100644 apps/codecs/libpcm/ms_adpcm.c delete mode 100644 apps/codecs/libpcm/pcm_common.h delete mode 100644 apps/codecs/libpcm/qt_ima_adpcm.c delete mode 100644 apps/codecs/libpcm/support_formats.h delete mode 100644 apps/codecs/libpcm/swf_adpcm.c delete mode 100644 apps/codecs/libpcm/yamaha_adpcm.c delete mode 100644 apps/codecs/librm/SOURCES delete mode 100644 apps/codecs/librm/bytestream.h delete mode 100644 apps/codecs/librm/librm.make delete mode 100644 apps/codecs/librm/rm.c delete mode 100644 apps/codecs/librm/rm.h delete mode 100644 apps/codecs/libspc/SOURCES delete mode 100644 apps/codecs/libspc/libspc.make delete mode 100644 apps/codecs/libspc/spc_codec.h delete mode 100644 apps/codecs/libspc/spc_cpu.c delete mode 100644 apps/codecs/libspc/spc_dsp.c delete mode 100644 apps/codecs/libspc/spc_emu.c delete mode 100644 apps/codecs/libspc/spc_profiler.c delete mode 100644 apps/codecs/libspc/spc_profiler.h delete mode 100644 apps/codecs/libspeex/COPYING delete mode 100644 apps/codecs/libspeex/README.rockbox delete mode 100644 apps/codecs/libspeex/SOURCES delete mode 100644 apps/codecs/libspeex/_kiss_fft_guts.h delete mode 100644 apps/codecs/libspeex/arch.h delete mode 100644 apps/codecs/libspeex/bits.c delete mode 100644 apps/codecs/libspeex/cb_search.c delete mode 100644 apps/codecs/libspeex/cb_search.h delete mode 100644 apps/codecs/libspeex/cb_search_arm4.h delete mode 100644 apps/codecs/libspeex/cb_search_bfin.h delete mode 100644 apps/codecs/libspeex/cb_search_sse.h delete mode 100644 apps/codecs/libspeex/config-speex.h delete mode 100644 apps/codecs/libspeex/exc_10_16_table.c delete mode 100644 apps/codecs/libspeex/exc_10_32_table.c delete mode 100644 apps/codecs/libspeex/exc_20_32_table.c delete mode 100644 apps/codecs/libspeex/exc_5_256_table.c delete mode 100644 apps/codecs/libspeex/exc_5_64_table.c delete mode 100644 apps/codecs/libspeex/exc_8_128_table.c delete mode 100644 apps/codecs/libspeex/fftwrap.c delete mode 100644 apps/codecs/libspeex/fftwrap.h delete mode 100644 apps/codecs/libspeex/filterbank.c delete mode 100644 apps/codecs/libspeex/filterbank.h delete mode 100644 apps/codecs/libspeex/filters.c delete mode 100644 apps/codecs/libspeex/filters.h delete mode 100644 apps/codecs/libspeex/filters_arm4.S delete mode 100644 apps/codecs/libspeex/filters_arm4.h delete mode 100644 apps/codecs/libspeex/filters_bfin.h delete mode 100644 apps/codecs/libspeex/filters_cf.S delete mode 100644 apps/codecs/libspeex/filters_sse.h delete mode 100644 apps/codecs/libspeex/fixed_arm4.h delete mode 100644 apps/codecs/libspeex/fixed_arm5e.h delete mode 100644 apps/codecs/libspeex/fixed_bfin.h delete mode 100644 apps/codecs/libspeex/fixed_debug.h delete mode 100644 apps/codecs/libspeex/fixed_generic.h delete mode 100644 apps/codecs/libspeex/gain_table.c delete mode 100644 apps/codecs/libspeex/gain_table_lbr.c delete mode 100644 apps/codecs/libspeex/hexc_10_32_table.c delete mode 100644 apps/codecs/libspeex/hexc_table.c delete mode 100644 apps/codecs/libspeex/high_lsp_tables.c delete mode 100644 apps/codecs/libspeex/jitter.c delete mode 100644 apps/codecs/libspeex/kiss_fft.c delete mode 100644 apps/codecs/libspeex/kiss_fft.h delete mode 100644 apps/codecs/libspeex/kiss_fftr.c delete mode 100644 apps/codecs/libspeex/kiss_fftr.h delete mode 100644 apps/codecs/libspeex/libspeex.make delete mode 100644 apps/codecs/libspeex/lpc.c delete mode 100644 apps/codecs/libspeex/lpc.h delete mode 100644 apps/codecs/libspeex/lpc_bfin.h delete mode 100644 apps/codecs/libspeex/lsp.c delete mode 100644 apps/codecs/libspeex/lsp.h delete mode 100644 apps/codecs/libspeex/lsp_bfin.h delete mode 100644 apps/codecs/libspeex/lsp_tables_nb.c delete mode 100644 apps/codecs/libspeex/ltp.c delete mode 100644 apps/codecs/libspeex/ltp.h delete mode 100644 apps/codecs/libspeex/ltp_arm4.h delete mode 100644 apps/codecs/libspeex/ltp_bfin.h delete mode 100644 apps/codecs/libspeex/ltp_cf.S delete mode 100644 apps/codecs/libspeex/ltp_sse.h delete mode 100644 apps/codecs/libspeex/math_approx.h delete mode 100644 apps/codecs/libspeex/mdf.c delete mode 100644 apps/codecs/libspeex/misc_bfin.h delete mode 100644 apps/codecs/libspeex/modes.c delete mode 100644 apps/codecs/libspeex/modes.h delete mode 100644 apps/codecs/libspeex/modes_wb.c delete mode 100644 apps/codecs/libspeex/nb_celp.c delete mode 100644 apps/codecs/libspeex/nb_celp.h delete mode 100644 apps/codecs/libspeex/oggframing.c delete mode 100644 apps/codecs/libspeex/os_support.h delete mode 100644 apps/codecs/libspeex/preprocess.c delete mode 100644 apps/codecs/libspeex/pseudofloat.h delete mode 100644 apps/codecs/libspeex/quant_lsp.c delete mode 100644 apps/codecs/libspeex/quant_lsp.h delete mode 100644 apps/codecs/libspeex/quant_lsp_bfin.h delete mode 100644 apps/codecs/libspeex/resample.c delete mode 100644 apps/codecs/libspeex/rockbox.h delete mode 100644 apps/codecs/libspeex/sb_celp.c delete mode 100644 apps/codecs/libspeex/sb_celp.h delete mode 100644 apps/codecs/libspeex/smallft.c delete mode 100644 apps/codecs/libspeex/smallft.h delete mode 100644 apps/codecs/libspeex/speex.c delete mode 100644 apps/codecs/libspeex/speex/ogg.h delete mode 100644 apps/codecs/libspeex/speex/speex.h delete mode 100644 apps/codecs/libspeex/speex/speex_bits.h delete mode 100644 apps/codecs/libspeex/speex/speex_callbacks.h delete mode 100644 apps/codecs/libspeex/speex/speex_config_types.h delete mode 100644 apps/codecs/libspeex/speex/speex_echo.h delete mode 100644 apps/codecs/libspeex/speex/speex_header.h delete mode 100644 apps/codecs/libspeex/speex/speex_jitter.h delete mode 100644 apps/codecs/libspeex/speex/speex_preprocess.h delete mode 100644 apps/codecs/libspeex/speex/speex_resampler.h delete mode 100644 apps/codecs/libspeex/speex/speex_stereo.h delete mode 100644 apps/codecs/libspeex/speex/speex_types.h delete mode 100644 apps/codecs/libspeex/speex_callbacks.c delete mode 100644 apps/codecs/libspeex/speex_header.c delete mode 100644 apps/codecs/libspeex/stack_alloc.h delete mode 100644 apps/codecs/libspeex/stereo.c delete mode 100644 apps/codecs/libspeex/vbr.c delete mode 100644 apps/codecs/libspeex/vbr.h delete mode 100644 apps/codecs/libspeex/vorbis_psy.c delete mode 100644 apps/codecs/libspeex/vorbis_psy.h delete mode 100644 apps/codecs/libspeex/vq.c delete mode 100644 apps/codecs/libspeex/vq.h delete mode 100644 apps/codecs/libspeex/vq_arm4.h delete mode 100644 apps/codecs/libspeex/vq_bfin.h delete mode 100644 apps/codecs/libspeex/vq_sse.h delete mode 100644 apps/codecs/libspeex/window.c delete mode 100644 apps/codecs/libtremor/CHANGELOG delete mode 100644 apps/codecs/libtremor/COPYING delete mode 100644 apps/codecs/libtremor/README delete mode 100644 apps/codecs/libtremor/README.rockbox delete mode 100644 apps/codecs/libtremor/SOURCES delete mode 100644 apps/codecs/libtremor/asm_arm.h delete mode 100644 apps/codecs/libtremor/asm_mcf5249.h delete mode 100644 apps/codecs/libtremor/backends.h delete mode 100644 apps/codecs/libtremor/bitwise.c delete mode 100644 apps/codecs/libtremor/block.c delete mode 100644 apps/codecs/libtremor/codebook.c delete mode 100644 apps/codecs/libtremor/codebook.h delete mode 100644 apps/codecs/libtremor/codec_internal.h delete mode 100644 apps/codecs/libtremor/config-tremor.h delete mode 100644 apps/codecs/libtremor/config_types.h delete mode 100644 apps/codecs/libtremor/ctype.c delete mode 100644 apps/codecs/libtremor/ffmpeg_stuff.h delete mode 100644 apps/codecs/libtremor/floor0.c delete mode 100644 apps/codecs/libtremor/floor1.c delete mode 100644 apps/codecs/libtremor/framing.c delete mode 100644 apps/codecs/libtremor/info.c delete mode 100644 apps/codecs/libtremor/ivorbiscodec.h delete mode 100644 apps/codecs/libtremor/ivorbisfile.h delete mode 100644 apps/codecs/libtremor/libtremor.make delete mode 100644 apps/codecs/libtremor/lsp_lookup.h delete mode 100644 apps/codecs/libtremor/mapping0.c delete mode 100644 apps/codecs/libtremor/misc.h delete mode 100644 apps/codecs/libtremor/ogg.h delete mode 100644 apps/codecs/libtremor/oggmalloc.c delete mode 100644 apps/codecs/libtremor/os.h delete mode 100644 apps/codecs/libtremor/os_types.h delete mode 100644 apps/codecs/libtremor/registry.c delete mode 100644 apps/codecs/libtremor/registry.h delete mode 100644 apps/codecs/libtremor/res012.c delete mode 100644 apps/codecs/libtremor/sharedbook.c delete mode 100644 apps/codecs/libtremor/synthesis.c delete mode 100644 apps/codecs/libtremor/vorbisfile.c delete mode 100644 apps/codecs/libtremor/window.c delete mode 100644 apps/codecs/libtremor/window.h delete mode 100644 apps/codecs/libtremor/window_lookup.h delete mode 100644 apps/codecs/libtta/README delete mode 100644 apps/codecs/libtta/README.rockbox delete mode 100644 apps/codecs/libtta/SOURCES delete mode 100644 apps/codecs/libtta/filter.h delete mode 100644 apps/codecs/libtta/filter_arm.S delete mode 100644 apps/codecs/libtta/filter_coldfire.S delete mode 100644 apps/codecs/libtta/libtta.make delete mode 100644 apps/codecs/libtta/ttadec.c delete mode 100644 apps/codecs/libtta/ttadec.h delete mode 100644 apps/codecs/libtta/ttalib.h delete mode 100644 apps/codecs/libwavpack/LICENSE delete mode 100644 apps/codecs/libwavpack/README delete mode 100644 apps/codecs/libwavpack/README.rockbox delete mode 100644 apps/codecs/libwavpack/SOURCES delete mode 100644 apps/codecs/libwavpack/arm.S delete mode 100644 apps/codecs/libwavpack/arml.S delete mode 100644 apps/codecs/libwavpack/bits.c delete mode 100644 apps/codecs/libwavpack/coldfire.S delete mode 100644 apps/codecs/libwavpack/float.c delete mode 100644 apps/codecs/libwavpack/libwavpack.make delete mode 100644 apps/codecs/libwavpack/make.bat delete mode 100644 apps/codecs/libwavpack/metadata.c delete mode 100644 apps/codecs/libwavpack/pack.c delete mode 100644 apps/codecs/libwavpack/unpack.c delete mode 100644 apps/codecs/libwavpack/wavpack.h delete mode 100644 apps/codecs/libwavpack/words.c delete mode 100644 apps/codecs/libwavpack/wputils.c delete mode 100644 apps/codecs/libwma/SOURCES delete mode 100644 apps/codecs/libwma/libwma.make delete mode 100644 apps/codecs/libwma/types.h delete mode 100644 apps/codecs/libwma/wmadata.h delete mode 100644 apps/codecs/libwma/wmadec.h delete mode 100644 apps/codecs/libwma/wmadeci.c delete mode 100644 apps/codecs/libwma/wmafixed.c delete mode 100644 apps/codecs/libwma/wmafixed.h delete mode 100644 apps/codecs/libwmapro/README.rockbox delete mode 100644 apps/codecs/libwmapro/SOURCES delete mode 100644 apps/codecs/libwmapro/libwmapro.make delete mode 100644 apps/codecs/libwmapro/mdct_tables.c delete mode 100644 apps/codecs/libwmapro/mdct_tables.h delete mode 100644 apps/codecs/libwmapro/quant.h delete mode 100644 apps/codecs/libwmapro/wma.c delete mode 100644 apps/codecs/libwmapro/wma.h delete mode 100644 apps/codecs/libwmapro/wmapro_math.h delete mode 100644 apps/codecs/libwmapro/wmaprodata.h delete mode 100644 apps/codecs/libwmapro/wmaprodec.c delete mode 100644 apps/codecs/libwmapro/wmaprodec.h delete mode 100644 apps/codecs/libwmavoice/Makefile delete mode 100644 apps/codecs/libwmavoice/README.rockbox delete mode 100644 apps/codecs/libwmavoice/SOURCES delete mode 100644 apps/codecs/libwmavoice/acelp_filters.c delete mode 100644 apps/codecs/libwmavoice/acelp_filters.h delete mode 100644 apps/codecs/libwmavoice/acelp_vectors.c delete mode 100644 apps/codecs/libwmavoice/acelp_vectors.h delete mode 100644 apps/codecs/libwmavoice/avcodec.h delete mode 100644 apps/codecs/libwmavoice/avfft.c delete mode 100644 apps/codecs/libwmavoice/avfft.h delete mode 100644 apps/codecs/libwmavoice/bitstream.c delete mode 100644 apps/codecs/libwmavoice/celp_filters.c delete mode 100644 apps/codecs/libwmavoice/celp_filters.h delete mode 100644 apps/codecs/libwmavoice/celp_math.c delete mode 100644 apps/codecs/libwmavoice/celp_math.h delete mode 100644 apps/codecs/libwmavoice/dct.c delete mode 100644 apps/codecs/libwmavoice/dct32.c delete mode 100644 apps/codecs/libwmavoice/fft.c delete mode 100644 apps/codecs/libwmavoice/fft.h delete mode 100644 apps/codecs/libwmavoice/get_bits.h delete mode 100644 apps/codecs/libwmavoice/internal.h delete mode 100644 apps/codecs/libwmavoice/libavutil/attributes.h delete mode 100644 apps/codecs/libwmavoice/libavutil/avutil.h delete mode 100644 apps/codecs/libwmavoice/libavutil/bswap.h delete mode 100644 apps/codecs/libwmavoice/libavutil/common.h delete mode 100644 apps/codecs/libwmavoice/libavutil/internal.h delete mode 100644 apps/codecs/libwmavoice/libavutil/intreadwrite.h delete mode 100644 apps/codecs/libwmavoice/libavutil/log.c delete mode 100644 apps/codecs/libwmavoice/libavutil/log.h delete mode 100644 apps/codecs/libwmavoice/libavutil/lzo.c delete mode 100644 apps/codecs/libwmavoice/libavutil/lzo.h delete mode 100644 apps/codecs/libwmavoice/libavutil/mathematics.c delete mode 100644 apps/codecs/libwmavoice/libavutil/mathematics.h delete mode 100644 apps/codecs/libwmavoice/libavutil/mem.c delete mode 100644 apps/codecs/libwmavoice/libavutil/mem.h delete mode 100644 apps/codecs/libwmavoice/libwmavoice.make delete mode 100644 apps/codecs/libwmavoice/lsp.c delete mode 100644 apps/codecs/libwmavoice/lsp.h delete mode 100644 apps/codecs/libwmavoice/mathops.h delete mode 100644 apps/codecs/libwmavoice/mdct.c delete mode 100644 apps/codecs/libwmavoice/mdct_tablegen.h delete mode 100644 apps/codecs/libwmavoice/put_bits.h delete mode 100644 apps/codecs/libwmavoice/rdft.c delete mode 100644 apps/codecs/libwmavoice/utils.c delete mode 100644 apps/codecs/libwmavoice/wmavoice.c delete mode 100644 apps/codecs/libwmavoice/wmavoice.h delete mode 100644 apps/codecs/libwmavoice/wmavoice_data.h delete mode 100644 apps/codecs/libwmavoice/wmavoice_mainbuild.patch delete mode 100644 apps/codecs/mod.c delete mode 100644 apps/codecs/mp3_enc.c delete mode 100644 apps/codecs/mpa.c delete mode 100644 apps/codecs/mpc.c delete mode 100644 apps/codecs/nsf.c delete mode 100644 apps/codecs/raac.c delete mode 100644 apps/codecs/sgc.c delete mode 100644 apps/codecs/shorten.c delete mode 100644 apps/codecs/sid.c delete mode 100644 apps/codecs/smaf.c delete mode 100644 apps/codecs/spc.c delete mode 100644 apps/codecs/speex.c delete mode 100644 apps/codecs/tta.c delete mode 100644 apps/codecs/vgm.c delete mode 100644 apps/codecs/vorbis.c delete mode 100644 apps/codecs/vox.c delete mode 100644 apps/codecs/wav.c delete mode 100644 apps/codecs/wav64.c delete mode 100644 apps/codecs/wav_enc.c delete mode 100644 apps/codecs/wavpack.c delete mode 100644 apps/codecs/wavpack_enc.c delete mode 100755 apps/codecs/wma.c delete mode 100644 apps/codecs/wmapro.c delete mode 100644 apps/codecs/wmavoice.c create mode 100644 lib/rbcodec/codecs/SOURCES create mode 100644 lib/rbcodec/codecs/a52.c create mode 100644 lib/rbcodec/codecs/a52_rm.c create mode 100644 lib/rbcodec/codecs/aac.c create mode 100644 lib/rbcodec/codecs/adx.c create mode 100644 lib/rbcodec/codecs/aiff.c create mode 100644 lib/rbcodec/codecs/aiff_enc.c create mode 100644 lib/rbcodec/codecs/alac.c create mode 100644 lib/rbcodec/codecs/ape.c create mode 100644 lib/rbcodec/codecs/asap.c create mode 100644 lib/rbcodec/codecs/atrac3_oma.c create mode 100644 lib/rbcodec/codecs/atrac3_rm.c create mode 100644 lib/rbcodec/codecs/au.c create mode 100644 lib/rbcodec/codecs/ay.c create mode 100644 lib/rbcodec/codecs/codec_crt0.c create mode 100644 lib/rbcodec/codecs/codecs.h create mode 100644 lib/rbcodec/codecs/codecs.make create mode 100644 lib/rbcodec/codecs/cook.c create mode 100644 lib/rbcodec/codecs/demac/COPYING create mode 100644 lib/rbcodec/codecs/demac/Makefile create mode 100644 lib/rbcodec/codecs/demac/README create mode 100644 lib/rbcodec/codecs/demac/demac.c create mode 100644 lib/rbcodec/codecs/demac/libdemac.make create mode 100644 lib/rbcodec/codecs/demac/libdemac/SOURCES create mode 100644 lib/rbcodec/codecs/demac/libdemac/crc.c create mode 100644 lib/rbcodec/codecs/demac/libdemac/decoder.c create mode 100644 lib/rbcodec/codecs/demac/libdemac/decoder.h create mode 100644 lib/rbcodec/codecs/demac/libdemac/demac.h create mode 100644 lib/rbcodec/codecs/demac/libdemac/demac_config.h create mode 100644 lib/rbcodec/codecs/demac/libdemac/entropy.c create mode 100644 lib/rbcodec/codecs/demac/libdemac/entropy.h create mode 100644 lib/rbcodec/codecs/demac/libdemac/filter.c create mode 100644 lib/rbcodec/codecs/demac/libdemac/filter.h create mode 100644 lib/rbcodec/codecs/demac/libdemac/filter_1280_15.c create mode 100644 lib/rbcodec/codecs/demac/libdemac/filter_16_11.c create mode 100644 lib/rbcodec/codecs/demac/libdemac/filter_256_13.c create mode 100644 lib/rbcodec/codecs/demac/libdemac/filter_32_10.c create mode 100644 lib/rbcodec/codecs/demac/libdemac/filter_64_11.c create mode 100644 lib/rbcodec/codecs/demac/libdemac/parser.c create mode 100644 lib/rbcodec/codecs/demac/libdemac/parser.h create mode 100644 lib/rbcodec/codecs/demac/libdemac/predictor-arm.S create mode 100644 lib/rbcodec/codecs/demac/libdemac/predictor-cf.S create mode 100644 lib/rbcodec/codecs/demac/libdemac/predictor.c create mode 100644 lib/rbcodec/codecs/demac/libdemac/predictor.h create mode 100644 lib/rbcodec/codecs/demac/libdemac/udiv32_arm-pre.S create mode 100644 lib/rbcodec/codecs/demac/libdemac/udiv32_arm.S create mode 100644 lib/rbcodec/codecs/demac/libdemac/vector_math16_armv5te.h create mode 100644 lib/rbcodec/codecs/demac/libdemac/vector_math16_armv6.h create mode 100644 lib/rbcodec/codecs/demac/libdemac/vector_math16_armv7.h create mode 100644 lib/rbcodec/codecs/demac/libdemac/vector_math16_cf.h create mode 100644 lib/rbcodec/codecs/demac/libdemac/vector_math16_mmx.h create mode 100644 lib/rbcodec/codecs/demac/libdemac/vector_math32_armv4.h create mode 100644 lib/rbcodec/codecs/demac/libdemac/vector_math_generic.h create mode 100644 lib/rbcodec/codecs/demac/wavwrite.c create mode 100644 lib/rbcodec/codecs/demac/wavwrite.h create mode 100644 lib/rbcodec/codecs/flac.c create mode 100644 lib/rbcodec/codecs/gbs.c create mode 100644 lib/rbcodec/codecs/hes.c create mode 100644 lib/rbcodec/codecs/kss.c create mode 100644 lib/rbcodec/codecs/lib/SOURCES create mode 100644 lib/rbcodec/codecs/lib/asm_arm.h create mode 100644 lib/rbcodec/codecs/lib/asm_mcf5249.h create mode 100644 lib/rbcodec/codecs/lib/codeclib.c create mode 100644 lib/rbcodec/codecs/lib/codeclib.h create mode 100644 lib/rbcodec/codecs/lib/codeclib_misc.h create mode 100644 lib/rbcodec/codecs/lib/ffmpeg_bitstream.c create mode 100644 lib/rbcodec/codecs/lib/ffmpeg_bswap.h create mode 100644 lib/rbcodec/codecs/lib/ffmpeg_get_bits.h create mode 100644 lib/rbcodec/codecs/lib/ffmpeg_intreadwrite.h create mode 100644 lib/rbcodec/codecs/lib/ffmpeg_put_bits.h create mode 100644 lib/rbcodec/codecs/lib/fft-ffmpeg.c create mode 100644 lib/rbcodec/codecs/lib/fft-ffmpeg_arm.h create mode 100644 lib/rbcodec/codecs/lib/fft-ffmpeg_cf.h create mode 100644 lib/rbcodec/codecs/lib/fft.h create mode 100644 lib/rbcodec/codecs/lib/fixedpoint.c create mode 100644 lib/rbcodec/codecs/lib/fixedpoint.h create mode 100644 lib/rbcodec/codecs/lib/libcodec.make create mode 100644 lib/rbcodec/codecs/lib/mdct.c create mode 100644 lib/rbcodec/codecs/lib/mdct.h create mode 100644 lib/rbcodec/codecs/lib/mdct_lookup.c create mode 100644 lib/rbcodec/codecs/lib/mdct_lookup.h create mode 100644 lib/rbcodec/codecs/lib/osx.dummy.c create mode 100644 lib/rbcodec/codecs/liba52/AUTHORS create mode 100644 lib/rbcodec/codecs/liba52/COPYING create mode 100644 lib/rbcodec/codecs/liba52/ChangeLog create mode 100644 lib/rbcodec/codecs/liba52/HISTORY create mode 100644 lib/rbcodec/codecs/liba52/INSTALL create mode 100644 lib/rbcodec/codecs/liba52/NEWS create mode 100644 lib/rbcodec/codecs/liba52/README create mode 100644 lib/rbcodec/codecs/liba52/README.rockbox create mode 100644 lib/rbcodec/codecs/liba52/SOURCES create mode 100644 lib/rbcodec/codecs/liba52/TODO create mode 100644 lib/rbcodec/codecs/liba52/a52.h create mode 100644 lib/rbcodec/codecs/liba52/a52_internal.h create mode 100644 lib/rbcodec/codecs/liba52/attributes.h create mode 100644 lib/rbcodec/codecs/liba52/bit_allocate.c create mode 100644 lib/rbcodec/codecs/liba52/bitstream.c create mode 100644 lib/rbcodec/codecs/liba52/bitstream.h create mode 100644 lib/rbcodec/codecs/liba52/config-a52.h create mode 100644 lib/rbcodec/codecs/liba52/downmix.c create mode 100644 lib/rbcodec/codecs/liba52/imdct.c create mode 100644 lib/rbcodec/codecs/liba52/imdct_lookups.h create mode 100644 lib/rbcodec/codecs/liba52/liba52.make create mode 100644 lib/rbcodec/codecs/liba52/mm_accel.h create mode 100644 lib/rbcodec/codecs/liba52/parse.c create mode 100644 lib/rbcodec/codecs/liba52/tables.h create mode 100644 lib/rbcodec/codecs/liba52/tendra.h create mode 100644 lib/rbcodec/codecs/libalac/README create mode 100644 lib/rbcodec/codecs/libalac/README.rockbox create mode 100644 lib/rbcodec/codecs/libalac/SOURCES create mode 100644 lib/rbcodec/codecs/libalac/alac.c create mode 100644 lib/rbcodec/codecs/libalac/decomp.h create mode 100644 lib/rbcodec/codecs/libalac/libalac.make create mode 100644 lib/rbcodec/codecs/libasap/CREDITS create mode 100644 lib/rbcodec/codecs/libasap/README create mode 100644 lib/rbcodec/codecs/libasap/README.rockbox create mode 100644 lib/rbcodec/codecs/libasap/SOURCES create mode 100644 lib/rbcodec/codecs/libasap/acpu.c create mode 100644 lib/rbcodec/codecs/libasap/anylang.h create mode 100644 lib/rbcodec/codecs/libasap/apokeysnd.c create mode 100644 lib/rbcodec/codecs/libasap/asap.c create mode 100644 lib/rbcodec/codecs/libasap/asap.h create mode 100644 lib/rbcodec/codecs/libasap/asap_internal.h create mode 100644 lib/rbcodec/codecs/libasap/libasap.make create mode 100644 lib/rbcodec/codecs/libasap/players.h create mode 100644 lib/rbcodec/codecs/libasf/SOURCES create mode 100644 lib/rbcodec/codecs/libasf/asf.c create mode 100644 lib/rbcodec/codecs/libasf/asf.h create mode 100644 lib/rbcodec/codecs/libasf/libasf.make create mode 100644 lib/rbcodec/codecs/libatrac/README.rockbox create mode 100644 lib/rbcodec/codecs/libatrac/SOURCES create mode 100644 lib/rbcodec/codecs/libatrac/atrac3.c create mode 100644 lib/rbcodec/codecs/libatrac/atrac3.h create mode 100644 lib/rbcodec/codecs/libatrac/atrac3_arm.S create mode 100644 lib/rbcodec/codecs/libatrac/atrac3_armv5e.S create mode 100644 lib/rbcodec/codecs/libatrac/atrac3data.h create mode 100644 lib/rbcodec/codecs/libatrac/atrac3data_fixed.h create mode 100644 lib/rbcodec/codecs/libatrac/fixp_math.h create mode 100644 lib/rbcodec/codecs/libatrac/libatrac.make create mode 100644 lib/rbcodec/codecs/libcook/README.rockbox create mode 100644 lib/rbcodec/codecs/libcook/SOURCES create mode 100644 lib/rbcodec/codecs/libcook/cook.c create mode 100644 lib/rbcodec/codecs/libcook/cook.h create mode 100644 lib/rbcodec/codecs/libcook/cook_fixpoint.h create mode 100644 lib/rbcodec/codecs/libcook/cookdata.h create mode 100644 lib/rbcodec/codecs/libcook/cookdata_fixpoint.h create mode 100644 lib/rbcodec/codecs/libcook/libcook.make create mode 100644 lib/rbcodec/codecs/libfaad/COPYING create mode 100644 lib/rbcodec/codecs/libfaad/README create mode 100644 lib/rbcodec/codecs/libfaad/README.rockbox create mode 100644 lib/rbcodec/codecs/libfaad/SOURCES create mode 100644 lib/rbcodec/codecs/libfaad/analysis.h create mode 100644 lib/rbcodec/codecs/libfaad/bits.c create mode 100644 lib/rbcodec/codecs/libfaad/bits.h create mode 100644 lib/rbcodec/codecs/libfaad/codebook/hcb.h create mode 100644 lib/rbcodec/codecs/libfaad/codebook/hcb_1.h create mode 100644 lib/rbcodec/codecs/libfaad/codebook/hcb_10.h create mode 100644 lib/rbcodec/codecs/libfaad/codebook/hcb_11.h create mode 100644 lib/rbcodec/codecs/libfaad/codebook/hcb_2.h create mode 100644 lib/rbcodec/codecs/libfaad/codebook/hcb_3.h create mode 100644 lib/rbcodec/codecs/libfaad/codebook/hcb_4.h create mode 100644 lib/rbcodec/codecs/libfaad/codebook/hcb_5.h create mode 100644 lib/rbcodec/codecs/libfaad/codebook/hcb_6.h create mode 100644 lib/rbcodec/codecs/libfaad/codebook/hcb_7.h create mode 100644 lib/rbcodec/codecs/libfaad/codebook/hcb_8.h create mode 100644 lib/rbcodec/codecs/libfaad/codebook/hcb_9.h create mode 100644 lib/rbcodec/codecs/libfaad/codebook/hcb_sf.h create mode 100644 lib/rbcodec/codecs/libfaad/common.c create mode 100644 lib/rbcodec/codecs/libfaad/common.h create mode 100644 lib/rbcodec/codecs/libfaad/decoder.c create mode 100644 lib/rbcodec/codecs/libfaad/decoder.h create mode 100644 lib/rbcodec/codecs/libfaad/drc.c create mode 100644 lib/rbcodec/codecs/libfaad/drc.h create mode 100644 lib/rbcodec/codecs/libfaad/drm_dec.c create mode 100644 lib/rbcodec/codecs/libfaad/drm_dec.h create mode 100644 lib/rbcodec/codecs/libfaad/error.c create mode 100644 lib/rbcodec/codecs/libfaad/error.h create mode 100644 lib/rbcodec/codecs/libfaad/faad_config.h create mode 100644 lib/rbcodec/codecs/libfaad/filtbank.c create mode 100644 lib/rbcodec/codecs/libfaad/filtbank.h create mode 100644 lib/rbcodec/codecs/libfaad/fixed.h create mode 100644 lib/rbcodec/codecs/libfaad/hcr.c create mode 100644 lib/rbcodec/codecs/libfaad/huffman.c create mode 100644 lib/rbcodec/codecs/libfaad/huffman.h create mode 100644 lib/rbcodec/codecs/libfaad/ic_predict.c create mode 100644 lib/rbcodec/codecs/libfaad/ic_predict.h create mode 100644 lib/rbcodec/codecs/libfaad/iq_table.h create mode 100644 lib/rbcodec/codecs/libfaad/is.c create mode 100644 lib/rbcodec/codecs/libfaad/is.h create mode 100644 lib/rbcodec/codecs/libfaad/kbd_win.h create mode 100644 lib/rbcodec/codecs/libfaad/libfaad.make create mode 100644 lib/rbcodec/codecs/libfaad/lt_predict.c create mode 100644 lib/rbcodec/codecs/libfaad/lt_predict.h create mode 100644 lib/rbcodec/codecs/libfaad/mp4.c create mode 100644 lib/rbcodec/codecs/libfaad/mp4.h create mode 100644 lib/rbcodec/codecs/libfaad/ms.c create mode 100644 lib/rbcodec/codecs/libfaad/ms.h create mode 100644 lib/rbcodec/codecs/libfaad/output.c create mode 100644 lib/rbcodec/codecs/libfaad/output.h create mode 100644 lib/rbcodec/codecs/libfaad/pns.c create mode 100644 lib/rbcodec/codecs/libfaad/pns.h create mode 100644 lib/rbcodec/codecs/libfaad/ps_dec.c create mode 100644 lib/rbcodec/codecs/libfaad/ps_dec.h create mode 100644 lib/rbcodec/codecs/libfaad/ps_syntax.c create mode 100644 lib/rbcodec/codecs/libfaad/ps_tables.h create mode 100644 lib/rbcodec/codecs/libfaad/pulse.c create mode 100644 lib/rbcodec/codecs/libfaad/pulse.h create mode 100644 lib/rbcodec/codecs/libfaad/rvlc.c create mode 100644 lib/rbcodec/codecs/libfaad/rvlc.h create mode 100644 lib/rbcodec/codecs/libfaad/sbr_dct.c create mode 100644 lib/rbcodec/codecs/libfaad/sbr_dct.h create mode 100644 lib/rbcodec/codecs/libfaad/sbr_dec.c create mode 100644 lib/rbcodec/codecs/libfaad/sbr_dec.h create mode 100644 lib/rbcodec/codecs/libfaad/sbr_e_nf.c create mode 100644 lib/rbcodec/codecs/libfaad/sbr_e_nf.h create mode 100644 lib/rbcodec/codecs/libfaad/sbr_fbt.c create mode 100644 lib/rbcodec/codecs/libfaad/sbr_fbt.h create mode 100644 lib/rbcodec/codecs/libfaad/sbr_hfadj.c create mode 100644 lib/rbcodec/codecs/libfaad/sbr_hfadj.h create mode 100644 lib/rbcodec/codecs/libfaad/sbr_hfgen.c create mode 100644 lib/rbcodec/codecs/libfaad/sbr_hfgen.h create mode 100644 lib/rbcodec/codecs/libfaad/sbr_huff.c create mode 100644 lib/rbcodec/codecs/libfaad/sbr_huff.h create mode 100644 lib/rbcodec/codecs/libfaad/sbr_noise.h create mode 100644 lib/rbcodec/codecs/libfaad/sbr_qmf.c create mode 100644 lib/rbcodec/codecs/libfaad/sbr_qmf.h create mode 100644 lib/rbcodec/codecs/libfaad/sbr_qmf_c.h create mode 100644 lib/rbcodec/codecs/libfaad/sbr_syntax.c create mode 100644 lib/rbcodec/codecs/libfaad/sbr_syntax.h create mode 100644 lib/rbcodec/codecs/libfaad/sbr_tf_grid.c create mode 100644 lib/rbcodec/codecs/libfaad/sbr_tf_grid.h create mode 100644 lib/rbcodec/codecs/libfaad/sine_win.h create mode 100644 lib/rbcodec/codecs/libfaad/specrec.c create mode 100644 lib/rbcodec/codecs/libfaad/specrec.h create mode 100644 lib/rbcodec/codecs/libfaad/structs.h create mode 100644 lib/rbcodec/codecs/libfaad/syntax.c create mode 100644 lib/rbcodec/codecs/libfaad/syntax.h create mode 100644 lib/rbcodec/codecs/libfaad/tns.c create mode 100644 lib/rbcodec/codecs/libfaad/tns.h create mode 100644 lib/rbcodec/codecs/libffmpegFLAC/COPYING create mode 100644 lib/rbcodec/codecs/libffmpegFLAC/README create mode 100644 lib/rbcodec/codecs/libffmpegFLAC/README.rockbox create mode 100644 lib/rbcodec/codecs/libffmpegFLAC/SOURCES create mode 100644 lib/rbcodec/codecs/libffmpegFLAC/arm.S create mode 100644 lib/rbcodec/codecs/libffmpegFLAC/arm.h create mode 100644 lib/rbcodec/codecs/libffmpegFLAC/bitstream.h create mode 100644 lib/rbcodec/codecs/libffmpegFLAC/coldfire.S create mode 100644 lib/rbcodec/codecs/libffmpegFLAC/coldfire.h create mode 100644 lib/rbcodec/codecs/libffmpegFLAC/decoder.c create mode 100644 lib/rbcodec/codecs/libffmpegFLAC/decoder.h create mode 100644 lib/rbcodec/codecs/libffmpegFLAC/golomb.h create mode 100644 lib/rbcodec/codecs/libffmpegFLAC/libffmpegFLAC.make create mode 100644 lib/rbcodec/codecs/libffmpegFLAC/shndec.c create mode 100644 lib/rbcodec/codecs/libffmpegFLAC/shndec.h create mode 100644 lib/rbcodec/codecs/libgme/2413tone.h create mode 100644 lib/rbcodec/codecs/libgme/281btone.h create mode 100644 lib/rbcodec/codecs/libgme/AYSOURCES create mode 100644 lib/rbcodec/codecs/libgme/EMU2413SOURCES create mode 100644 lib/rbcodec/codecs/libgme/GBSSOURCES create mode 100644 lib/rbcodec/codecs/libgme/HESSOURCES create mode 100644 lib/rbcodec/codecs/libgme/KSSSOURCES create mode 100644 lib/rbcodec/codecs/libgme/NSFSOURCES create mode 100644 lib/rbcodec/codecs/libgme/SGCSOURCES create mode 100644 lib/rbcodec/codecs/libgme/VGMSOURCES create mode 100644 lib/rbcodec/codecs/libgme/ay_apu.c create mode 100644 lib/rbcodec/codecs/libgme/ay_apu.h create mode 100644 lib/rbcodec/codecs/libgme/ay_cpu.c create mode 100644 lib/rbcodec/codecs/libgme/ay_emu.c create mode 100644 lib/rbcodec/codecs/libgme/ay_emu.h create mode 100644 lib/rbcodec/codecs/libgme/blargg_common.h create mode 100644 lib/rbcodec/codecs/libgme/blargg_config.h create mode 100644 lib/rbcodec/codecs/libgme/blargg_endian.h create mode 100644 lib/rbcodec/codecs/libgme/blargg_source.h create mode 100644 lib/rbcodec/codecs/libgme/blip_buffer.c create mode 100644 lib/rbcodec/codecs/libgme/blip_buffer.h create mode 100644 lib/rbcodec/codecs/libgme/emu2413.c create mode 100644 lib/rbcodec/codecs/libgme/emu2413.h create mode 100644 lib/rbcodec/codecs/libgme/emu8950.c create mode 100644 lib/rbcodec/codecs/libgme/emu8950.h create mode 100644 lib/rbcodec/codecs/libgme/emuadpcm.c create mode 100644 lib/rbcodec/codecs/libgme/emuadpcm.h create mode 100644 lib/rbcodec/codecs/libgme/emutables.h create mode 100644 lib/rbcodec/codecs/libgme/emutypes.h create mode 100644 lib/rbcodec/codecs/libgme/gb_apu.c create mode 100644 lib/rbcodec/codecs/libgme/gb_apu.h create mode 100644 lib/rbcodec/codecs/libgme/gb_cpu.c create mode 100644 lib/rbcodec/codecs/libgme/gb_cpu.h create mode 100644 lib/rbcodec/codecs/libgme/gb_cpu_run.h create mode 100644 lib/rbcodec/codecs/libgme/gb_oscs.c create mode 100644 lib/rbcodec/codecs/libgme/gb_oscs.h create mode 100644 lib/rbcodec/codecs/libgme/gbs_cpu.c create mode 100644 lib/rbcodec/codecs/libgme/gbs_emu.c create mode 100644 lib/rbcodec/codecs/libgme/gbs_emu.h create mode 100644 lib/rbcodec/codecs/libgme/gme.h create mode 100644 lib/rbcodec/codecs/libgme/hes_apu.c create mode 100644 lib/rbcodec/codecs/libgme/hes_apu.h create mode 100644 lib/rbcodec/codecs/libgme/hes_apu_adpcm.c create mode 100644 lib/rbcodec/codecs/libgme/hes_apu_adpcm.h create mode 100644 lib/rbcodec/codecs/libgme/hes_cpu.c create mode 100644 lib/rbcodec/codecs/libgme/hes_cpu.h create mode 100644 lib/rbcodec/codecs/libgme/hes_cpu_run.h create mode 100644 lib/rbcodec/codecs/libgme/hes_emu.c create mode 100644 lib/rbcodec/codecs/libgme/hes_emu.h create mode 100644 lib/rbcodec/codecs/libgme/inflate/bbfuncs.c create mode 100644 lib/rbcodec/codecs/libgme/inflate/bbfuncs.h create mode 100644 lib/rbcodec/codecs/libgme/inflate/inflate.c create mode 100644 lib/rbcodec/codecs/libgme/inflate/inflate.h create mode 100644 lib/rbcodec/codecs/libgme/inflate/mallocer.c create mode 100644 lib/rbcodec/codecs/libgme/inflate/mallocer.h create mode 100644 lib/rbcodec/codecs/libgme/inflate/mbreader.c create mode 100644 lib/rbcodec/codecs/libgme/inflate/mbreader.h create mode 100644 lib/rbcodec/codecs/libgme/kss_cpu.c create mode 100644 lib/rbcodec/codecs/libgme/kss_emu.c create mode 100644 lib/rbcodec/codecs/libgme/kss_emu.h create mode 100644 lib/rbcodec/codecs/libgme/kss_scc_apu.c create mode 100644 lib/rbcodec/codecs/libgme/kss_scc_apu.h create mode 100644 lib/rbcodec/codecs/libgme/libay.make create mode 100644 lib/rbcodec/codecs/libgme/libemu2413.make create mode 100644 lib/rbcodec/codecs/libgme/libgbs.make create mode 100644 lib/rbcodec/codecs/libgme/libhes.make create mode 100644 lib/rbcodec/codecs/libgme/libkss.make create mode 100644 lib/rbcodec/codecs/libgme/libnsf.make create mode 100644 lib/rbcodec/codecs/libgme/libsgc.make create mode 100644 lib/rbcodec/codecs/libgme/libvgm.make create mode 100644 lib/rbcodec/codecs/libgme/m3u_playlist.h create mode 100644 lib/rbcodec/codecs/libgme/msxtypes.h create mode 100644 lib/rbcodec/codecs/libgme/multi_buffer.c create mode 100644 lib/rbcodec/codecs/libgme/multi_buffer.h create mode 100644 lib/rbcodec/codecs/libgme/nes_apu.c create mode 100644 lib/rbcodec/codecs/libgme/nes_apu.h create mode 100644 lib/rbcodec/codecs/libgme/nes_cpu.c create mode 100644 lib/rbcodec/codecs/libgme/nes_cpu.h create mode 100644 lib/rbcodec/codecs/libgme/nes_cpu_run.h create mode 100644 lib/rbcodec/codecs/libgme/nes_fds_apu.c create mode 100644 lib/rbcodec/codecs/libgme/nes_fds_apu.h create mode 100644 lib/rbcodec/codecs/libgme/nes_fme7_apu.c create mode 100644 lib/rbcodec/codecs/libgme/nes_fme7_apu.h create mode 100644 lib/rbcodec/codecs/libgme/nes_mmc5_apu.h create mode 100644 lib/rbcodec/codecs/libgme/nes_namco_apu.c create mode 100644 lib/rbcodec/codecs/libgme/nes_namco_apu.h create mode 100644 lib/rbcodec/codecs/libgme/nes_oscs.c create mode 100644 lib/rbcodec/codecs/libgme/nes_oscs.h create mode 100644 lib/rbcodec/codecs/libgme/nes_vrc6_apu.c create mode 100644 lib/rbcodec/codecs/libgme/nes_vrc6_apu.h create mode 100644 lib/rbcodec/codecs/libgme/nes_vrc7_apu.c create mode 100644 lib/rbcodec/codecs/libgme/nes_vrc7_apu.h create mode 100644 lib/rbcodec/codecs/libgme/nsf_cpu.c create mode 100644 lib/rbcodec/codecs/libgme/nsf_emu.c create mode 100644 lib/rbcodec/codecs/libgme/nsf_emu.h create mode 100644 lib/rbcodec/codecs/libgme/nsfe_info.c create mode 100644 lib/rbcodec/codecs/libgme/nsfe_info.h create mode 100644 lib/rbcodec/codecs/libgme/opl_apu.c create mode 100644 lib/rbcodec/codecs/libgme/opl_apu.h create mode 100644 lib/rbcodec/codecs/libgme/opltables.h create mode 100644 lib/rbcodec/codecs/libgme/resampler.c create mode 100644 lib/rbcodec/codecs/libgme/resampler.h create mode 100644 lib/rbcodec/codecs/libgme/rom_data.c create mode 100644 lib/rbcodec/codecs/libgme/rom_data.h create mode 100644 lib/rbcodec/codecs/libgme/sgc_cpu.c create mode 100644 lib/rbcodec/codecs/libgme/sgc_emu.c create mode 100644 lib/rbcodec/codecs/libgme/sgc_emu.h create mode 100644 lib/rbcodec/codecs/libgme/sms_apu.c create mode 100644 lib/rbcodec/codecs/libgme/sms_apu.h create mode 100644 lib/rbcodec/codecs/libgme/sms_fm_apu.c create mode 100644 lib/rbcodec/codecs/libgme/sms_fm_apu.h create mode 100644 lib/rbcodec/codecs/libgme/track_filter.c create mode 100644 lib/rbcodec/codecs/libgme/track_filter.h create mode 100644 lib/rbcodec/codecs/libgme/vgm_emu.c create mode 100644 lib/rbcodec/codecs/libgme/vgm_emu.h create mode 100644 lib/rbcodec/codecs/libgme/vrc7tone.h create mode 100644 lib/rbcodec/codecs/libgme/ym2413_emu.c create mode 100644 lib/rbcodec/codecs/libgme/ym2413_emu.h create mode 100644 lib/rbcodec/codecs/libgme/ym2612_emu.c create mode 100644 lib/rbcodec/codecs/libgme/ym2612_emu.h create mode 100644 lib/rbcodec/codecs/libgme/ymtables.h create mode 100644 lib/rbcodec/codecs/libgme/z80_cpu.c create mode 100644 lib/rbcodec/codecs/libgme/z80_cpu.h create mode 100644 lib/rbcodec/codecs/libgme/z80_cpu_run.h create mode 100644 lib/rbcodec/codecs/libm4a/SOURCES create mode 100644 lib/rbcodec/codecs/libm4a/demux.c create mode 100644 lib/rbcodec/codecs/libm4a/libm4a.make create mode 100644 lib/rbcodec/codecs/libm4a/m4a.c create mode 100644 lib/rbcodec/codecs/libm4a/m4a.h create mode 100644 lib/rbcodec/codecs/libmad/CHANGES create mode 100644 lib/rbcodec/codecs/libmad/COPYING create mode 100644 lib/rbcodec/codecs/libmad/COPYRIGHT create mode 100644 lib/rbcodec/codecs/libmad/CREDITS create mode 100644 lib/rbcodec/codecs/libmad/D.dat create mode 100644 lib/rbcodec/codecs/libmad/README create mode 100644 lib/rbcodec/codecs/libmad/README.rockbox create mode 100644 lib/rbcodec/codecs/libmad/SOURCES create mode 100644 lib/rbcodec/codecs/libmad/TODO create mode 100644 lib/rbcodec/codecs/libmad/VERSION create mode 100644 lib/rbcodec/codecs/libmad/bit.c create mode 100644 lib/rbcodec/codecs/libmad/bit.h create mode 100644 lib/rbcodec/codecs/libmad/dct32_arm.S create mode 100644 lib/rbcodec/codecs/libmad/fixed.h create mode 100644 lib/rbcodec/codecs/libmad/frame.c create mode 100644 lib/rbcodec/codecs/libmad/frame.h create mode 100644 lib/rbcodec/codecs/libmad/global.h create mode 100644 lib/rbcodec/codecs/libmad/huffman.c create mode 100644 lib/rbcodec/codecs/libmad/huffman.h create mode 100644 lib/rbcodec/codecs/libmad/imdct_l_arm.S create mode 100644 lib/rbcodec/codecs/libmad/imdct_mcf5249.S create mode 100644 lib/rbcodec/codecs/libmad/imdct_s.dat create mode 100644 lib/rbcodec/codecs/libmad/layer12.c create mode 100644 lib/rbcodec/codecs/libmad/layer12.h create mode 100644 lib/rbcodec/codecs/libmad/layer3.c create mode 100644 lib/rbcodec/codecs/libmad/layer3.h create mode 100644 lib/rbcodec/codecs/libmad/libmad.make create mode 100644 lib/rbcodec/codecs/libmad/mad.h create mode 100644 lib/rbcodec/codecs/libmad/mad_iram.h create mode 100644 lib/rbcodec/codecs/libmad/qc_table.dat create mode 100644 lib/rbcodec/codecs/libmad/rq_table.dat create mode 100644 lib/rbcodec/codecs/libmad/sf_table.dat create mode 100644 lib/rbcodec/codecs/libmad/stream.c create mode 100644 lib/rbcodec/codecs/libmad/stream.h create mode 100644 lib/rbcodec/codecs/libmad/synth.c create mode 100644 lib/rbcodec/codecs/libmad/synth.h create mode 100644 lib/rbcodec/codecs/libmad/synth_full_arm.S create mode 100644 lib/rbcodec/codecs/libmusepack/AUTHORS create mode 100644 lib/rbcodec/codecs/libmusepack/COPYING create mode 100644 lib/rbcodec/codecs/libmusepack/ChangeLog create mode 100644 lib/rbcodec/codecs/libmusepack/SOURCES create mode 100644 lib/rbcodec/codecs/libmusepack/crc32.c create mode 100644 lib/rbcodec/codecs/libmusepack/decoder.h create mode 100644 lib/rbcodec/codecs/libmusepack/huffman.c create mode 100644 lib/rbcodec/codecs/libmusepack/huffman.h create mode 100644 lib/rbcodec/codecs/libmusepack/internal.h create mode 100644 lib/rbcodec/codecs/libmusepack/libmusepack.make create mode 100644 lib/rbcodec/codecs/libmusepack/minimax.h create mode 100644 lib/rbcodec/codecs/libmusepack/mpc_bits_reader.c create mode 100644 lib/rbcodec/codecs/libmusepack/mpc_bits_reader.h create mode 100644 lib/rbcodec/codecs/libmusepack/mpc_decoder.c create mode 100644 lib/rbcodec/codecs/libmusepack/mpc_demux.c create mode 100644 lib/rbcodec/codecs/libmusepack/mpc_types.h create mode 100644 lib/rbcodec/codecs/libmusepack/mpcdec.h create mode 100644 lib/rbcodec/codecs/libmusepack/mpcdec_math.h create mode 100644 lib/rbcodec/codecs/libmusepack/reader.h create mode 100644 lib/rbcodec/codecs/libmusepack/requant.c create mode 100644 lib/rbcodec/codecs/libmusepack/requant.h create mode 100644 lib/rbcodec/codecs/libmusepack/streaminfo.c create mode 100644 lib/rbcodec/codecs/libmusepack/streaminfo.h create mode 100644 lib/rbcodec/codecs/libmusepack/synth_filter.c create mode 100644 lib/rbcodec/codecs/libmusepack/synth_filter_arm.S create mode 100644 lib/rbcodec/codecs/libmusepack/synth_filter_coldfire.S create mode 100644 lib/rbcodec/codecs/libpcm/SOURCES create mode 100644 lib/rbcodec/codecs/libpcm/adpcm_seek.c create mode 100644 lib/rbcodec/codecs/libpcm/adpcm_seek.h create mode 100644 lib/rbcodec/codecs/libpcm/dialogic_oki_adpcm.c create mode 100644 lib/rbcodec/codecs/libpcm/dvi_adpcm.c create mode 100644 lib/rbcodec/codecs/libpcm/ieee_float.c create mode 100644 lib/rbcodec/codecs/libpcm/ima_adpcm_common.c create mode 100644 lib/rbcodec/codecs/libpcm/ima_adpcm_common.h create mode 100644 lib/rbcodec/codecs/libpcm/itut_g711.c create mode 100644 lib/rbcodec/codecs/libpcm/libpcm.make create mode 100644 lib/rbcodec/codecs/libpcm/linear_pcm.c create mode 100644 lib/rbcodec/codecs/libpcm/ms_adpcm.c create mode 100644 lib/rbcodec/codecs/libpcm/pcm_common.h create mode 100644 lib/rbcodec/codecs/libpcm/qt_ima_adpcm.c create mode 100644 lib/rbcodec/codecs/libpcm/support_formats.h create mode 100644 lib/rbcodec/codecs/libpcm/swf_adpcm.c create mode 100644 lib/rbcodec/codecs/libpcm/yamaha_adpcm.c create mode 100644 lib/rbcodec/codecs/librm/SOURCES create mode 100644 lib/rbcodec/codecs/librm/bytestream.h create mode 100644 lib/rbcodec/codecs/librm/librm.make create mode 100644 lib/rbcodec/codecs/librm/rm.c create mode 100644 lib/rbcodec/codecs/librm/rm.h create mode 100644 lib/rbcodec/codecs/libspc/SOURCES create mode 100644 lib/rbcodec/codecs/libspc/libspc.make create mode 100644 lib/rbcodec/codecs/libspc/spc_codec.h create mode 100644 lib/rbcodec/codecs/libspc/spc_cpu.c create mode 100644 lib/rbcodec/codecs/libspc/spc_dsp.c create mode 100644 lib/rbcodec/codecs/libspc/spc_emu.c create mode 100644 lib/rbcodec/codecs/libspc/spc_profiler.c create mode 100644 lib/rbcodec/codecs/libspc/spc_profiler.h create mode 100644 lib/rbcodec/codecs/libspeex/COPYING create mode 100644 lib/rbcodec/codecs/libspeex/README.rockbox create mode 100644 lib/rbcodec/codecs/libspeex/SOURCES create mode 100644 lib/rbcodec/codecs/libspeex/_kiss_fft_guts.h create mode 100644 lib/rbcodec/codecs/libspeex/arch.h create mode 100644 lib/rbcodec/codecs/libspeex/bits.c create mode 100644 lib/rbcodec/codecs/libspeex/cb_search.c create mode 100644 lib/rbcodec/codecs/libspeex/cb_search.h create mode 100644 lib/rbcodec/codecs/libspeex/cb_search_arm4.h create mode 100644 lib/rbcodec/codecs/libspeex/cb_search_bfin.h create mode 100644 lib/rbcodec/codecs/libspeex/cb_search_sse.h create mode 100644 lib/rbcodec/codecs/libspeex/config-speex.h create mode 100644 lib/rbcodec/codecs/libspeex/exc_10_16_table.c create mode 100644 lib/rbcodec/codecs/libspeex/exc_10_32_table.c create mode 100644 lib/rbcodec/codecs/libspeex/exc_20_32_table.c create mode 100644 lib/rbcodec/codecs/libspeex/exc_5_256_table.c create mode 100644 lib/rbcodec/codecs/libspeex/exc_5_64_table.c create mode 100644 lib/rbcodec/codecs/libspeex/exc_8_128_table.c create mode 100644 lib/rbcodec/codecs/libspeex/fftwrap.c create mode 100644 lib/rbcodec/codecs/libspeex/fftwrap.h create mode 100644 lib/rbcodec/codecs/libspeex/filterbank.c create mode 100644 lib/rbcodec/codecs/libspeex/filterbank.h create mode 100644 lib/rbcodec/codecs/libspeex/filters.c create mode 100644 lib/rbcodec/codecs/libspeex/filters.h create mode 100644 lib/rbcodec/codecs/libspeex/filters_arm4.S create mode 100644 lib/rbcodec/codecs/libspeex/filters_arm4.h create mode 100644 lib/rbcodec/codecs/libspeex/filters_bfin.h create mode 100644 lib/rbcodec/codecs/libspeex/filters_cf.S create mode 100644 lib/rbcodec/codecs/libspeex/filters_sse.h create mode 100644 lib/rbcodec/codecs/libspeex/fixed_arm4.h create mode 100644 lib/rbcodec/codecs/libspeex/fixed_arm5e.h create mode 100644 lib/rbcodec/codecs/libspeex/fixed_bfin.h create mode 100644 lib/rbcodec/codecs/libspeex/fixed_debug.h create mode 100644 lib/rbcodec/codecs/libspeex/fixed_generic.h create mode 100644 lib/rbcodec/codecs/libspeex/gain_table.c create mode 100644 lib/rbcodec/codecs/libspeex/gain_table_lbr.c create mode 100644 lib/rbcodec/codecs/libspeex/hexc_10_32_table.c create mode 100644 lib/rbcodec/codecs/libspeex/hexc_table.c create mode 100644 lib/rbcodec/codecs/libspeex/high_lsp_tables.c create mode 100644 lib/rbcodec/codecs/libspeex/jitter.c create mode 100644 lib/rbcodec/codecs/libspeex/kiss_fft.c create mode 100644 lib/rbcodec/codecs/libspeex/kiss_fft.h create mode 100644 lib/rbcodec/codecs/libspeex/kiss_fftr.c create mode 100644 lib/rbcodec/codecs/libspeex/kiss_fftr.h create mode 100644 lib/rbcodec/codecs/libspeex/libspeex.make create mode 100644 lib/rbcodec/codecs/libspeex/lpc.c create mode 100644 lib/rbcodec/codecs/libspeex/lpc.h create mode 100644 lib/rbcodec/codecs/libspeex/lpc_bfin.h create mode 100644 lib/rbcodec/codecs/libspeex/lsp.c create mode 100644 lib/rbcodec/codecs/libspeex/lsp.h create mode 100644 lib/rbcodec/codecs/libspeex/lsp_bfin.h create mode 100644 lib/rbcodec/codecs/libspeex/lsp_tables_nb.c create mode 100644 lib/rbcodec/codecs/libspeex/ltp.c create mode 100644 lib/rbcodec/codecs/libspeex/ltp.h create mode 100644 lib/rbcodec/codecs/libspeex/ltp_arm4.h create mode 100644 lib/rbcodec/codecs/libspeex/ltp_bfin.h create mode 100644 lib/rbcodec/codecs/libspeex/ltp_cf.S create mode 100644 lib/rbcodec/codecs/libspeex/ltp_sse.h create mode 100644 lib/rbcodec/codecs/libspeex/math_approx.h create mode 100644 lib/rbcodec/codecs/libspeex/mdf.c create mode 100644 lib/rbcodec/codecs/libspeex/misc_bfin.h create mode 100644 lib/rbcodec/codecs/libspeex/modes.c create mode 100644 lib/rbcodec/codecs/libspeex/modes.h create mode 100644 lib/rbcodec/codecs/libspeex/modes_wb.c create mode 100644 lib/rbcodec/codecs/libspeex/nb_celp.c create mode 100644 lib/rbcodec/codecs/libspeex/nb_celp.h create mode 100644 lib/rbcodec/codecs/libspeex/oggframing.c create mode 100644 lib/rbcodec/codecs/libspeex/os_support.h create mode 100644 lib/rbcodec/codecs/libspeex/preprocess.c create mode 100644 lib/rbcodec/codecs/libspeex/pseudofloat.h create mode 100644 lib/rbcodec/codecs/libspeex/quant_lsp.c create mode 100644 lib/rbcodec/codecs/libspeex/quant_lsp.h create mode 100644 lib/rbcodec/codecs/libspeex/quant_lsp_bfin.h create mode 100644 lib/rbcodec/codecs/libspeex/resample.c create mode 100644 lib/rbcodec/codecs/libspeex/rockbox.h create mode 100644 lib/rbcodec/codecs/libspeex/sb_celp.c create mode 100644 lib/rbcodec/codecs/libspeex/sb_celp.h create mode 100644 lib/rbcodec/codecs/libspeex/smallft.c create mode 100644 lib/rbcodec/codecs/libspeex/smallft.h create mode 100644 lib/rbcodec/codecs/libspeex/speex.c create mode 100644 lib/rbcodec/codecs/libspeex/speex/ogg.h create mode 100644 lib/rbcodec/codecs/libspeex/speex/speex.h create mode 100644 lib/rbcodec/codecs/libspeex/speex/speex_bits.h create mode 100644 lib/rbcodec/codecs/libspeex/speex/speex_callbacks.h create mode 100644 lib/rbcodec/codecs/libspeex/speex/speex_config_types.h create mode 100644 lib/rbcodec/codecs/libspeex/speex/speex_echo.h create mode 100644 lib/rbcodec/codecs/libspeex/speex/speex_header.h create mode 100644 lib/rbcodec/codecs/libspeex/speex/speex_jitter.h create mode 100644 lib/rbcodec/codecs/libspeex/speex/speex_preprocess.h create mode 100644 lib/rbcodec/codecs/libspeex/speex/speex_resampler.h create mode 100644 lib/rbcodec/codecs/libspeex/speex/speex_stereo.h create mode 100644 lib/rbcodec/codecs/libspeex/speex/speex_types.h create mode 100644 lib/rbcodec/codecs/libspeex/speex_callbacks.c create mode 100644 lib/rbcodec/codecs/libspeex/speex_header.c create mode 100644 lib/rbcodec/codecs/libspeex/stack_alloc.h create mode 100644 lib/rbcodec/codecs/libspeex/stereo.c create mode 100644 lib/rbcodec/codecs/libspeex/vbr.c create mode 100644 lib/rbcodec/codecs/libspeex/vbr.h create mode 100644 lib/rbcodec/codecs/libspeex/vorbis_psy.c create mode 100644 lib/rbcodec/codecs/libspeex/vorbis_psy.h create mode 100644 lib/rbcodec/codecs/libspeex/vq.c create mode 100644 lib/rbcodec/codecs/libspeex/vq.h create mode 100644 lib/rbcodec/codecs/libspeex/vq_arm4.h create mode 100644 lib/rbcodec/codecs/libspeex/vq_bfin.h create mode 100644 lib/rbcodec/codecs/libspeex/vq_sse.h create mode 100644 lib/rbcodec/codecs/libspeex/window.c create mode 100644 lib/rbcodec/codecs/libtremor/CHANGELOG create mode 100644 lib/rbcodec/codecs/libtremor/COPYING create mode 100644 lib/rbcodec/codecs/libtremor/README create mode 100644 lib/rbcodec/codecs/libtremor/README.rockbox create mode 100644 lib/rbcodec/codecs/libtremor/SOURCES create mode 100644 lib/rbcodec/codecs/libtremor/asm_arm.h create mode 100644 lib/rbcodec/codecs/libtremor/asm_mcf5249.h create mode 100644 lib/rbcodec/codecs/libtremor/backends.h create mode 100644 lib/rbcodec/codecs/libtremor/bitwise.c create mode 100644 lib/rbcodec/codecs/libtremor/block.c create mode 100644 lib/rbcodec/codecs/libtremor/codebook.c create mode 100644 lib/rbcodec/codecs/libtremor/codebook.h create mode 100644 lib/rbcodec/codecs/libtremor/codec_internal.h create mode 100644 lib/rbcodec/codecs/libtremor/config-tremor.h create mode 100644 lib/rbcodec/codecs/libtremor/config_types.h create mode 100644 lib/rbcodec/codecs/libtremor/ctype.c create mode 100644 lib/rbcodec/codecs/libtremor/ffmpeg_stuff.h create mode 100644 lib/rbcodec/codecs/libtremor/floor0.c create mode 100644 lib/rbcodec/codecs/libtremor/floor1.c create mode 100644 lib/rbcodec/codecs/libtremor/framing.c create mode 100644 lib/rbcodec/codecs/libtremor/info.c create mode 100644 lib/rbcodec/codecs/libtremor/ivorbiscodec.h create mode 100644 lib/rbcodec/codecs/libtremor/ivorbisfile.h create mode 100644 lib/rbcodec/codecs/libtremor/libtremor.make create mode 100644 lib/rbcodec/codecs/libtremor/lsp_lookup.h create mode 100644 lib/rbcodec/codecs/libtremor/mapping0.c create mode 100644 lib/rbcodec/codecs/libtremor/misc.h create mode 100644 lib/rbcodec/codecs/libtremor/ogg.h create mode 100644 lib/rbcodec/codecs/libtremor/oggmalloc.c create mode 100644 lib/rbcodec/codecs/libtremor/os.h create mode 100644 lib/rbcodec/codecs/libtremor/os_types.h create mode 100644 lib/rbcodec/codecs/libtremor/registry.c create mode 100644 lib/rbcodec/codecs/libtremor/registry.h create mode 100644 lib/rbcodec/codecs/libtremor/res012.c create mode 100644 lib/rbcodec/codecs/libtremor/sharedbook.c create mode 100644 lib/rbcodec/codecs/libtremor/synthesis.c create mode 100644 lib/rbcodec/codecs/libtremor/vorbisfile.c create mode 100644 lib/rbcodec/codecs/libtremor/window.c create mode 100644 lib/rbcodec/codecs/libtremor/window.h create mode 100644 lib/rbcodec/codecs/libtremor/window_lookup.h create mode 100644 lib/rbcodec/codecs/libtta/README create mode 100644 lib/rbcodec/codecs/libtta/README.rockbox create mode 100644 lib/rbcodec/codecs/libtta/SOURCES create mode 100644 lib/rbcodec/codecs/libtta/filter.h create mode 100644 lib/rbcodec/codecs/libtta/filter_arm.S create mode 100644 lib/rbcodec/codecs/libtta/filter_coldfire.S create mode 100644 lib/rbcodec/codecs/libtta/libtta.make create mode 100644 lib/rbcodec/codecs/libtta/ttadec.c create mode 100644 lib/rbcodec/codecs/libtta/ttadec.h create mode 100644 lib/rbcodec/codecs/libtta/ttalib.h create mode 100644 lib/rbcodec/codecs/libwavpack/LICENSE create mode 100644 lib/rbcodec/codecs/libwavpack/README create mode 100644 lib/rbcodec/codecs/libwavpack/README.rockbox create mode 100644 lib/rbcodec/codecs/libwavpack/SOURCES create mode 100644 lib/rbcodec/codecs/libwavpack/arm.S create mode 100644 lib/rbcodec/codecs/libwavpack/arml.S create mode 100644 lib/rbcodec/codecs/libwavpack/bits.c create mode 100644 lib/rbcodec/codecs/libwavpack/coldfire.S create mode 100644 lib/rbcodec/codecs/libwavpack/float.c create mode 100644 lib/rbcodec/codecs/libwavpack/libwavpack.make create mode 100644 lib/rbcodec/codecs/libwavpack/make.bat create mode 100644 lib/rbcodec/codecs/libwavpack/metadata.c create mode 100644 lib/rbcodec/codecs/libwavpack/pack.c create mode 100644 lib/rbcodec/codecs/libwavpack/unpack.c create mode 100644 lib/rbcodec/codecs/libwavpack/wavpack.h create mode 100644 lib/rbcodec/codecs/libwavpack/words.c create mode 100644 lib/rbcodec/codecs/libwavpack/wputils.c create mode 100644 lib/rbcodec/codecs/libwma/SOURCES create mode 100644 lib/rbcodec/codecs/libwma/libwma.make create mode 100644 lib/rbcodec/codecs/libwma/types.h create mode 100644 lib/rbcodec/codecs/libwma/wmadata.h create mode 100644 lib/rbcodec/codecs/libwma/wmadec.h create mode 100644 lib/rbcodec/codecs/libwma/wmadeci.c create mode 100644 lib/rbcodec/codecs/libwma/wmafixed.c create mode 100644 lib/rbcodec/codecs/libwma/wmafixed.h create mode 100644 lib/rbcodec/codecs/libwmapro/README.rockbox create mode 100644 lib/rbcodec/codecs/libwmapro/SOURCES create mode 100644 lib/rbcodec/codecs/libwmapro/libwmapro.make create mode 100644 lib/rbcodec/codecs/libwmapro/mdct_tables.c create mode 100644 lib/rbcodec/codecs/libwmapro/mdct_tables.h create mode 100644 lib/rbcodec/codecs/libwmapro/quant.h create mode 100644 lib/rbcodec/codecs/libwmapro/wma.c create mode 100644 lib/rbcodec/codecs/libwmapro/wma.h create mode 100644 lib/rbcodec/codecs/libwmapro/wmapro_math.h create mode 100644 lib/rbcodec/codecs/libwmapro/wmaprodata.h create mode 100644 lib/rbcodec/codecs/libwmapro/wmaprodec.c create mode 100644 lib/rbcodec/codecs/libwmapro/wmaprodec.h create mode 100644 lib/rbcodec/codecs/libwmavoice/Makefile create mode 100644 lib/rbcodec/codecs/libwmavoice/README.rockbox create mode 100644 lib/rbcodec/codecs/libwmavoice/SOURCES create mode 100644 lib/rbcodec/codecs/libwmavoice/acelp_filters.c create mode 100644 lib/rbcodec/codecs/libwmavoice/acelp_filters.h create mode 100644 lib/rbcodec/codecs/libwmavoice/acelp_vectors.c create mode 100644 lib/rbcodec/codecs/libwmavoice/acelp_vectors.h create mode 100644 lib/rbcodec/codecs/libwmavoice/avcodec.h create mode 100644 lib/rbcodec/codecs/libwmavoice/avfft.c create mode 100644 lib/rbcodec/codecs/libwmavoice/avfft.h create mode 100644 lib/rbcodec/codecs/libwmavoice/bitstream.c create mode 100644 lib/rbcodec/codecs/libwmavoice/celp_filters.c create mode 100644 lib/rbcodec/codecs/libwmavoice/celp_filters.h create mode 100644 lib/rbcodec/codecs/libwmavoice/celp_math.c create mode 100644 lib/rbcodec/codecs/libwmavoice/celp_math.h create mode 100644 lib/rbcodec/codecs/libwmavoice/dct.c create mode 100644 lib/rbcodec/codecs/libwmavoice/dct32.c create mode 100644 lib/rbcodec/codecs/libwmavoice/fft.c create mode 100644 lib/rbcodec/codecs/libwmavoice/fft.h create mode 100644 lib/rbcodec/codecs/libwmavoice/get_bits.h create mode 100644 lib/rbcodec/codecs/libwmavoice/internal.h create mode 100644 lib/rbcodec/codecs/libwmavoice/libavutil/attributes.h create mode 100644 lib/rbcodec/codecs/libwmavoice/libavutil/avutil.h create mode 100644 lib/rbcodec/codecs/libwmavoice/libavutil/bswap.h create mode 100644 lib/rbcodec/codecs/libwmavoice/libavutil/common.h create mode 100644 lib/rbcodec/codecs/libwmavoice/libavutil/internal.h create mode 100644 lib/rbcodec/codecs/libwmavoice/libavutil/intreadwrite.h create mode 100644 lib/rbcodec/codecs/libwmavoice/libavutil/log.c create mode 100644 lib/rbcodec/codecs/libwmavoice/libavutil/log.h create mode 100644 lib/rbcodec/codecs/libwmavoice/libavutil/lzo.c create mode 100644 lib/rbcodec/codecs/libwmavoice/libavutil/lzo.h create mode 100644 lib/rbcodec/codecs/libwmavoice/libavutil/mathematics.c create mode 100644 lib/rbcodec/codecs/libwmavoice/libavutil/mathematics.h create mode 100644 lib/rbcodec/codecs/libwmavoice/libavutil/mem.c create mode 100644 lib/rbcodec/codecs/libwmavoice/libavutil/mem.h create mode 100644 lib/rbcodec/codecs/libwmavoice/libwmavoice.make create mode 100644 lib/rbcodec/codecs/libwmavoice/lsp.c create mode 100644 lib/rbcodec/codecs/libwmavoice/lsp.h create mode 100644 lib/rbcodec/codecs/libwmavoice/mathops.h create mode 100644 lib/rbcodec/codecs/libwmavoice/mdct.c create mode 100644 lib/rbcodec/codecs/libwmavoice/mdct_tablegen.h create mode 100644 lib/rbcodec/codecs/libwmavoice/put_bits.h create mode 100644 lib/rbcodec/codecs/libwmavoice/rdft.c create mode 100644 lib/rbcodec/codecs/libwmavoice/utils.c create mode 100644 lib/rbcodec/codecs/libwmavoice/wmavoice.c create mode 100644 lib/rbcodec/codecs/libwmavoice/wmavoice.h create mode 100644 lib/rbcodec/codecs/libwmavoice/wmavoice_data.h create mode 100644 lib/rbcodec/codecs/libwmavoice/wmavoice_mainbuild.patch create mode 100644 lib/rbcodec/codecs/mod.c create mode 100644 lib/rbcodec/codecs/mp3_enc.c create mode 100644 lib/rbcodec/codecs/mpa.c create mode 100644 lib/rbcodec/codecs/mpc.c create mode 100644 lib/rbcodec/codecs/nsf.c create mode 100644 lib/rbcodec/codecs/raac.c create mode 100644 lib/rbcodec/codecs/sgc.c create mode 100644 lib/rbcodec/codecs/shorten.c create mode 100644 lib/rbcodec/codecs/sid.c create mode 100644 lib/rbcodec/codecs/smaf.c create mode 100644 lib/rbcodec/codecs/spc.c create mode 100644 lib/rbcodec/codecs/speex.c create mode 100644 lib/rbcodec/codecs/tta.c create mode 100644 lib/rbcodec/codecs/vgm.c create mode 100644 lib/rbcodec/codecs/vorbis.c create mode 100644 lib/rbcodec/codecs/vox.c create mode 100644 lib/rbcodec/codecs/wav.c create mode 100644 lib/rbcodec/codecs/wav64.c create mode 100644 lib/rbcodec/codecs/wav_enc.c create mode 100644 lib/rbcodec/codecs/wavpack.c create mode 100644 lib/rbcodec/codecs/wavpack_enc.c create mode 100755 lib/rbcodec/codecs/wma.c create mode 100644 lib/rbcodec/codecs/wmapro.c create mode 100644 lib/rbcodec/codecs/wmavoice.c diff --git a/android/android.make b/android/android.make index 5ec9a68ca8..c0d72a7a05 100644 --- a/android/android.make +++ b/android/android.make @@ -124,7 +124,7 @@ $(BINLIB_DIR)/$(BINARY): $(BUILDDIR)/$(BINARY) $(BINLIB_DIR)/libmisc.so: $(BUILDDIR)/rockbox.zip $(call PRINTS,CP rockbox.zip)cp $^ $@ -$(BINLIB_DIR)/lib%.so: $(BUILDDIR)/apps/codecs/%.codec +$(BINLIB_DIR)/lib%.so: $(RBCODEC_BLD)/codecs/%.codec $(call PRINTS,CP $(@F))cp $^ $@ libs: $(DIRS) $(LIBS) diff --git a/apps/codecs.h b/apps/codecs.h deleted file mode 100644 index 1334953b82..0000000000 --- a/apps/codecs.h +++ /dev/null @@ -1,291 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2002 Björn Stenberg - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ -#ifndef _CODECS_H_ -#define _CODECS_H_ - -/* instruct simulator code to not redefine any symbols when compiling codecs. - (the CODEC macro is defined in apps/codecs/Makefile) */ -#ifdef CODEC -#define NO_REDEFINES_PLEASE -#endif - -#include -#include -#include "strlcpy.h" -#include "config.h" -#include "system.h" -#include "metadata.h" -#include "audio.h" -#ifdef RB_PROFILE -#include "profile.h" -#include "thread.h" -#endif -#if (CONFIG_CODEC == SWCODEC) -#ifdef HAVE_RECORDING -#include "pcm_record.h" -#endif -#include "dsp.h" -#include "dsp-util.h" -#endif - -#include "gcc_extensions.h" -#include "load_code.h" - -#ifdef CODEC -#if defined(DEBUG) || defined(SIMULATOR) -#undef DEBUGF -#define DEBUGF ci->debugf -#undef LDEBUGF -#define LDEBUGF ci->debugf -#else -#define DEBUGF(...) -#define LDEBUGF(...) -#endif - -#ifdef ROCKBOX_HAS_LOGF -#undef LOGF -#define LOGF ci->logf -#else -#define LOGF(...) -#endif - -#endif - -/* magic for normal codecs */ -#define CODEC_MAGIC 0x52434F44 /* RCOD */ -/* magic for encoder codecs */ -#define CODEC_ENC_MAGIC 0x52454E43 /* RENC */ - -/* increase this every time the api struct changes */ -#define CODEC_API_VERSION 44 - -/* update this to latest version if a change to the api struct breaks - backwards compatibility (and please take the opportunity to sort in any - new function which are "waiting" at the end of the function table) */ -#define CODEC_MIN_API_VERSION 43 - -/* reasons for calling codec main entrypoint */ -enum codec_entry_call_reason { - CODEC_LOAD = 0, - CODEC_UNLOAD -}; - -/* codec return codes */ -enum codec_status { - CODEC_OK = 0, - CODEC_ERROR = -1, -}; - -/* codec command action codes */ -enum codec_command_action { - CODEC_ACTION_HALT = -1, - CODEC_ACTION_NULL = 0, - CODEC_ACTION_SEEK_TIME = 1, -}; - -/* NOTE: To support backwards compatibility, only add new functions at - the end of the structure. Every time you add a new function, - remember to increase CODEC_API_VERSION. If you make changes to the - existing APIs then also update CODEC_MIN_API_VERSION to current - version - */ -struct codec_api { - off_t filesize; /* Total file length */ - off_t curpos; /* Current buffer position */ - - struct mp3entry *id3; /* TAG metadata pointer */ - int audio_hid; /* Current audio handle */ - - /* The dsp instance to be used for audio output */ - struct dsp_config *dsp; - - /* Returns buffer to malloc array. Only codeclib should need this. */ - void* (*codec_get_buffer)(size_t *size); - /* Insert PCM data into audio buffer for playback. Playback will start - automatically. */ - void (*pcmbuf_insert)(const void *ch1, const void *ch2, int count); - /* Set song position in WPS (value in ms). */ - void (*set_elapsed)(unsigned long value); - - /* Read next amount bytes from file buffer to . - Will return number of bytes read or 0 if end of file. */ - size_t (*read_filebuf)(void *ptr, size_t size); - /* Request pointer to file buffer which can be used to read - amount of data. tells the buffer system - how much data it should try to allocate. If is 0, - end of file is reached. */ - void* (*request_buffer)(size_t *realsize, size_t reqsize); - /* Advance file buffer position by amount of bytes. */ - void (*advance_buffer)(size_t amount); - /* Seek file buffer to position beginning of file. */ - bool (*seek_buffer)(size_t newpos); - /* Codec should call this function when it has done the seeking. */ - void (*seek_complete)(void); - /* Update the current position */ - void (*set_offset)(size_t value); - /* Configure different codec buffer parameters. */ - void (*configure)(int setting, intptr_t value); - /* Obtain command action on what to do next */ - enum codec_command_action (*get_command)(intptr_t *param); - /* Determine whether the track should be looped, if applicable. */ - bool (*loop_track)(void); - - /* kernel/ system */ -#if defined(CPU_ARM) && CONFIG_PLATFORM & PLATFORM_NATIVE - void (*__div0)(void); -#endif - unsigned (*sleep)(unsigned ticks); - void (*yield)(void); - -#if NUM_CORES > 1 - unsigned int - (*create_thread)(void (*function)(void), void* stack, - size_t stack_size, unsigned flags, const char *name - IF_PRIO(, int priority) - IF_COP(, unsigned int core)); - - void (*thread_thaw)(unsigned int thread_id); - void (*thread_wait)(unsigned int thread_id); - void (*semaphore_init)(struct semaphore *s, int max, int start); - int (*semaphore_wait)(struct semaphore *s, int timeout); - void (*semaphore_release)(struct semaphore *s); -#endif /* NUM_CORES */ - - void (*commit_dcache)(void); - void (*commit_discard_dcache)(void); - - /* strings and memory */ - char* (*strcpy)(char *dst, const char *src); - size_t (*strlen)(const char *str); - int (*strcmp)(const char *, const char *); - char *(*strcat)(char *s1, const char *s2); - void* (*memset)(void *dst, int c, size_t length); - void* (*memcpy)(void *out, const void *in, size_t n); - void* (*memmove)(void *out, const void *in, size_t n); - int (*memcmp)(const void *s1, const void *s2, size_t n); - void *(*memchr)(const void *s1, int c, size_t n); - -#if defined(DEBUG) || defined(SIMULATOR) - void (*debugf)(const char *fmt, ...) ATTRIBUTE_PRINTF(1, 2); -#endif -#ifdef ROCKBOX_HAS_LOGF - void (*logf)(const char *fmt, ...) ATTRIBUTE_PRINTF(1, 2); -#endif - - /* Tremor requires qsort */ - void (*qsort)(void *base, size_t nmemb, size_t size, - int(*compar)(const void *, const void *)); - -#ifdef RB_PROFILE - void (*profile_thread)(void); - void (*profstop)(void); - void (*profile_func_enter)(void *this_fn, void *call_site); - void (*profile_func_exit)(void *this_fn, void *call_site); -#endif - -#ifdef HAVE_RECORDING - void (*enc_get_inputs)(struct enc_inputs *inputs); - void (*enc_set_parameters)(struct enc_parameters *params); - struct enc_chunk_hdr * (*enc_get_chunk)(void); - void (*enc_finish_chunk)(void); - unsigned char * (*enc_get_pcm_data)(size_t size); - size_t (*enc_unget_pcm_data)(size_t size); - - /* file */ - int (*open)(const char* pathname, int flags, ...); - int (*close)(int fd); - ssize_t (*read)(int fd, void* buf, size_t count); - off_t (*lseek)(int fd, off_t offset, int whence); - ssize_t (*write)(int fd, const void* buf, size_t count); - int (*round_value_to_list32)(unsigned long value, - const unsigned long list[], - int count, - bool signd); -#endif - - /* new stuff at the end, sort into place next time - the API gets incompatible */ - void (*commit_discard_idcache)(void); -}; - -/* codec header */ -struct codec_header { - struct lc_header lc_hdr; /* must be first */ - enum codec_status(*entry_point)(enum codec_entry_call_reason reason); - enum codec_status(*run_proc)(void); - struct codec_api **api; -}; - -#ifdef CODEC -#if (CONFIG_PLATFORM & PLATFORM_NATIVE) -/* plugin_* is correct, codecs use the plugin linker script */ -extern unsigned char plugin_start_addr[]; -extern unsigned char plugin_end_addr[]; -/* decoders */ -#define CODEC_HEADER \ - const struct codec_header __header \ - __attribute__ ((section (".header")))= { \ - { CODEC_MAGIC, TARGET_ID, CODEC_API_VERSION, \ - plugin_start_addr, plugin_end_addr }, codec_start, \ - codec_run, &ci }; -/* encoders */ -#define CODEC_ENC_HEADER \ - const struct codec_header __header \ - __attribute__ ((section (".header")))= { \ - { CODEC_ENC_MAGIC, TARGET_ID, CODEC_API_VERSION, \ - plugin_start_addr, plugin_end_addr }, codec_start, \ - codec_run, &ci }; - -#else /* def SIMULATOR */ -/* decoders */ -#define CODEC_HEADER \ - const struct codec_header __header \ - __attribute__((visibility("default"))) = { \ - { CODEC_MAGIC, TARGET_ID, CODEC_API_VERSION, NULL, NULL }, \ - codec_start, codec_run, &ci }; -/* encoders */ -#define CODEC_ENC_HEADER \ - const struct codec_header __header = { \ - { CODEC_ENC_MAGIC, TARGET_ID, CODEC_API_VERSION, NULL, NULL }, \ - codec_start, codec_run, &ci }; -#endif /* SIMULATOR */ -#endif /* CODEC */ - -/* create full codec path from root filenames in audio_formats[] - assumes buffer size is MAX_PATH */ -void codec_get_full_path(char *path, const char *codec_root_fn); - -/* Returns pointer to and size of free codec RAM */ -void *codec_get_buffer_callback(size_t *size); - -/* defined by the codec loader (codec.c) */ -int codec_load_buf(int hid, struct codec_api *api); -int codec_load_file(const char* codec, struct codec_api *api); -int codec_run_proc(void); -int codec_halt(void); -int codec_close(void); - -/* defined by the codec */ -enum codec_status codec_start(enum codec_entry_call_reason reason); -enum codec_status codec_main(enum codec_entry_call_reason reason); -enum codec_status codec_run(void); - -#endif /* _CODECS_H_ */ diff --git a/apps/codecs/SOURCES b/apps/codecs/SOURCES deleted file mode 100644 index db6e82c75f..0000000000 --- a/apps/codecs/SOURCES +++ /dev/null @@ -1,54 +0,0 @@ -/* decoders */ - -vorbis.c -mpa.c -flac.c -wav.c -a52.c -wavpack.c -#ifndef RB_PROFILE -alac.c -#endif -cook.c -raac.c -a52_rm.c -atrac3_rm.c -atrac3_oma.c -mpc.c -wma.c -sid.c -ape.c -asap.c -aac.c -spc.c -mod.c -shorten.c -aiff.c -speex.c -adx.c -smaf.c -au.c -vox.c -wav64.c -tta.c -wmapro.c -ay.c -gbs.c -hes.c -nsf.c -sgc.c -vgm.c -#if MEMORYSIZE > 2 -kss.c -#endif - -#ifdef HAVE_RECORDING - -/* encoders */ - -aiff_enc.c -mp3_enc.c -wav_enc.c -wavpack_enc.c - -#endif /* HAVE_RECORDING */ diff --git a/apps/codecs/a52.c b/apps/codecs/a52.c deleted file mode 100644 index cb6e66dd05..0000000000 --- a/apps/codecs/a52.c +++ /dev/null @@ -1,192 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2005 Dave Chapman - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ - -#include "codeclib.h" -#include /* Needed by a52.h */ -#include -#include - -CODEC_HEADER - -#define BUFFER_SIZE 4096 - -#define A52_SAMPLESPERFRAME (6*256) - -static a52_state_t *state; -static unsigned long samplesdone; -static unsigned long frequency; - -/* used outside liba52 */ -static uint8_t buf[3840] IBSS_ATTR; - -static inline void output_audio(sample_t *samples) -{ - ci->yield(); - ci->pcmbuf_insert(&samples[0], &samples[256], 256); -} - -static void a52_decode_data(uint8_t *start, uint8_t *end) -{ - static uint8_t *bufptr = buf; - static uint8_t *bufpos = buf + 7; - /* - * sample_rate and flags are static because this routine could - * exit between the a52_syncinfo() and the ao_setup(), and we want - * to have the same values when we get back ! - */ - static int sample_rate; - static int flags; - int bit_rate; - int len; - - while (1) { - len = end - start; - if (!len) - break; - if (len > bufpos - bufptr) - len = bufpos - bufptr; - memcpy(bufptr, start, len); - bufptr += len; - start += len; - if (bufptr == bufpos) { - if (bufpos == buf + 7) { - int length; - - length = a52_syncinfo(buf, &flags, &sample_rate, &bit_rate); - if (!length) { - //DEBUGF("skip\n"); - for (bufptr = buf; bufptr < buf + 6; bufptr++) - bufptr[0] = bufptr[1]; - continue; - } - bufpos = buf + length; - } else { - /* Unity gain is 1 << 26, and we want to end up on 28 bits - of precision instead of the default 30. - */ - level_t level = 1 << 24; - sample_t bias = 0; - int i; - - /* This is the configuration for the downmixing: */ - flags = A52_STEREO | A52_ADJUST_LEVEL; - - if (a52_frame(state, buf, &flags, &level, bias)) - goto error; - a52_dynrng(state, NULL, NULL); - frequency = sample_rate; - - /* An A52 frame consists of 6 blocks of 256 samples - So we decode and output them one block at a time */ - for (i = 0; i < 6; i++) { - if (a52_block(state)) - goto error; - output_audio(a52_samples(state)); - samplesdone += 256; - } - ci->set_elapsed(samplesdone/(frequency/1000)); - bufptr = buf; - bufpos = buf + 7; - continue; - error: - //logf("Error decoding A52 stream\n"); - bufptr = buf; - bufpos = buf + 7; - } - } - } -} - -/* this is the codec entry point */ -enum codec_status codec_main(enum codec_entry_call_reason reason) -{ - if (reason == CODEC_LOAD) { - /* Generic codec initialisation */ - ci->configure(DSP_SET_STEREO_MODE, STEREO_NONINTERLEAVED); - ci->configure(DSP_SET_SAMPLE_DEPTH, 28); - } - else if (reason == CODEC_UNLOAD) { - if (state) - a52_free(state); - } - - return CODEC_OK; -} - -/* this is called for each file to process */ -enum codec_status codec_run(void) -{ - size_t n; - unsigned char *filebuf; - int sample_loc; - intptr_t param; - - if (codec_init()) - return CODEC_ERROR; - - ci->configure(DSP_SWITCH_FREQUENCY, ci->id3->frequency); - codec_set_replaygain(ci->id3); - - /* Intialise the A52 decoder and check for success */ - state = a52_init(0); - - samplesdone = 0; - - /* The main decoding loop */ - if (ci->id3->offset) { - if (ci->seek_buffer(ci->id3->offset)) { - samplesdone = (ci->id3->offset / ci->id3->bytesperframe) * - A52_SAMPLESPERFRAME; - ci->set_elapsed(samplesdone/(ci->id3->frequency / 1000)); - } - } - else { - ci->seek_buffer(ci->id3->first_frame_offset); - ci->set_elapsed(0); - } - - while (1) { - enum codec_command_action action = ci->get_command(¶m); - - if (action == CODEC_ACTION_HALT) - break; - - if (action == CODEC_ACTION_SEEK_TIME) { - sample_loc = param/1000 * ci->id3->frequency; - - if (ci->seek_buffer((sample_loc/A52_SAMPLESPERFRAME)*ci->id3->bytesperframe)) { - samplesdone = sample_loc; - ci->set_elapsed(samplesdone/(ci->id3->frequency/1000)); - } - ci->seek_complete(); - } - - filebuf = ci->request_buffer(&n, BUFFER_SIZE); - - if (n == 0) /* End of Stream */ - break; - - a52_decode_data(filebuf, filebuf + n); - ci->advance_buffer(n); - } - - return CODEC_OK; -} diff --git a/apps/codecs/a52_rm.c b/apps/codecs/a52_rm.c deleted file mode 100644 index 207c28272e..0000000000 --- a/apps/codecs/a52_rm.c +++ /dev/null @@ -1,227 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2009 Mohamed Tarek - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ - -#include "codeclib.h" -#include -#include /* Needed by a52.h */ -#include -#include - -CODEC_HEADER - -#define BUFFER_SIZE 4096 - -#define A52_SAMPLESPERFRAME (6*256) - -static a52_state_t *state; -static unsigned long samplesdone; -static unsigned long frequency; -static RMContext rmctx; -static RMPacket pkt; - -static void init_rm(RMContext *rmctx) -{ - memcpy(rmctx, (void*)(( (intptr_t)ci->id3->id3v2buf + 3 ) &~ 3), sizeof(RMContext)); -} - -/* used outside liba52 */ -static uint8_t buf[3840] IBSS_ATTR; - -/* The following two functions, a52_decode_data and output_audio are taken from apps/codecs/a52.c */ -static inline void output_audio(sample_t *samples) -{ - ci->yield(); - ci->pcmbuf_insert(&samples[0], &samples[256], 256); -} - -static void a52_decode_data(uint8_t *start, uint8_t *end) -{ - static uint8_t *bufptr = buf; - static uint8_t *bufpos = buf + 7; - /* - * sample_rate and flags are static because this routine could - * exit between the a52_syncinfo() and the ao_setup(), and we want - * to have the same values when we get back ! - */ - static int sample_rate; - static int flags; - int bit_rate; - int len; - - while (1) { - len = end - start; - if (!len) - break; - if (len > bufpos - bufptr) - len = bufpos - bufptr; - memcpy(bufptr, start, len); - bufptr += len; - start += len; - if (bufptr == bufpos) { - if (bufpos == buf + 7) { - int length; - - length = a52_syncinfo(buf, &flags, &sample_rate, &bit_rate); - if (!length) { - //DEBUGF("skip\n"); - for (bufptr = buf; bufptr < buf + 6; bufptr++) - bufptr[0] = bufptr[1]; - continue; - } - bufpos = buf + length; - } else { - /* Unity gain is 1 << 26, and we want to end up on 28 bits - of precision instead of the default 30. - */ - level_t level = 1 << 24; - sample_t bias = 0; - int i; - - /* This is the configuration for the downmixing: */ - flags = A52_STEREO | A52_ADJUST_LEVEL; - - if (a52_frame(state, buf, &flags, &level, bias)) - goto error; - a52_dynrng(state, NULL, NULL); - frequency = sample_rate; - - /* An A52 frame consists of 6 blocks of 256 samples - So we decode and output them one block at a time */ - for (i = 0; i < 6; i++) { - if (a52_block(state)) - goto error; - output_audio(a52_samples(state)); - samplesdone += 256; - } - ci->set_elapsed(samplesdone/(frequency/1000)); - bufptr = buf; - bufpos = buf + 7; - continue; - error: - //logf("Error decoding A52 stream\n"); - bufptr = buf; - bufpos = buf + 7; - } - } - } -} - -/* this is the codec entry point */ -enum codec_status codec_main(enum codec_entry_call_reason reason) -{ - if (reason == CODEC_LOAD) { - /* Generic codec initialisation */ - ci->configure(DSP_SET_STEREO_MODE, STEREO_NONINTERLEAVED); - ci->configure(DSP_SET_SAMPLE_DEPTH, 28); - } - else if (reason == CODEC_UNLOAD) { - if (state) - a52_free(state); - } - - return CODEC_OK; -} - -/* this is called for each file to process */ -enum codec_status codec_run(void) -{ - size_t n; - uint8_t *filebuf; - int consumed, packet_offset; - int playback_on = -1; - size_t resume_offset; - intptr_t param; - enum codec_command_action action = CODEC_ACTION_NULL; - - if (codec_init()) { - return CODEC_ERROR; - } - - resume_offset = ci->id3->offset; - - ci->configure(DSP_SWITCH_FREQUENCY, ci->id3->frequency); - codec_set_replaygain(ci->id3); - - ci->seek_buffer(ci->id3->first_frame_offset); - - /* Intializations */ - state = a52_init(0); - ci->memset(&rmctx,0,sizeof(RMContext)); - ci->memset(&pkt,0,sizeof(RMPacket)); - init_rm(&rmctx); - - samplesdone = 0; - - /* check for a mid-track resume and force a seek time accordingly */ - if(resume_offset > rmctx.data_offset + DATA_HEADER_SIZE) { - resume_offset -= rmctx.data_offset + DATA_HEADER_SIZE; - /* put number of subpackets to skip in resume_offset */ - resume_offset /= (rmctx.block_align + PACKET_HEADER_SIZE); - param = (int)resume_offset * ((rmctx.block_align * 8 * 1000)/rmctx.bit_rate); - action = CODEC_ACTION_SEEK_TIME; - } - else { - /* Seek to the first packet */ - ci->set_elapsed(0); - ci->advance_buffer(rmctx.data_offset + DATA_HEADER_SIZE ); - } - - /* The main decoding loop */ - while((unsigned)rmctx.audio_pkt_cnt < rmctx.nb_packets) { - if (action == CODEC_ACTION_NULL) - action = ci->get_command(¶m); - - if (action == CODEC_ACTION_HALT) - break; - - if (action == CODEC_ACTION_SEEK_TIME) { - packet_offset = param / ((rmctx.block_align*8*1000)/rmctx.bit_rate); - ci->seek_buffer(rmctx.data_offset + DATA_HEADER_SIZE + - packet_offset*(rmctx.block_align + PACKET_HEADER_SIZE)); - rmctx.audio_pkt_cnt = packet_offset; - samplesdone = (rmctx.sample_rate/1000 * param); - ci->set_elapsed(samplesdone/(frequency/1000)); - ci->seek_complete(); - } - - action = CODEC_ACTION_NULL; - - filebuf = ci->request_buffer(&n, rmctx.block_align + PACKET_HEADER_SIZE); - consumed = rm_get_packet(&filebuf, &rmctx, &pkt); - - if(consumed < 0 && playback_on != 0) { - if(playback_on == -1) { - /* Error only if packet-parsing failed and playback hadn't started */ - DEBUGF("rm_get_packet failed\n"); - return CODEC_ERROR; - } - else { - break; - } - } - - playback_on = 1; - a52_decode_data(filebuf, filebuf + rmctx.block_align); - ci->advance_buffer(pkt.length); - } - - return CODEC_OK; -} diff --git a/apps/codecs/aac.c b/apps/codecs/aac.c deleted file mode 100644 index 365dca804d..0000000000 --- a/apps/codecs/aac.c +++ /dev/null @@ -1,297 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2005 Dave Chapman - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ - -#include "codeclib.h" -#include "libm4a/m4a.h" -#include "libfaad/common.h" -#include "libfaad/structs.h" -#include "libfaad/decoder.h" - -CODEC_HEADER - -/* The maximum buffer size handled by faad. 12 bytes are required by libfaad - * as headroom (see libfaad/bits.c). FAAD_BYTE_BUFFER_SIZE bytes are buffered - * for each frame. */ -#define FAAD_BYTE_BUFFER_SIZE (2048-12) - -/* this is the codec entry point */ -enum codec_status codec_main(enum codec_entry_call_reason reason) -{ - if (reason == CODEC_LOAD) { - /* Generic codec initialisation */ - ci->configure(DSP_SET_STEREO_MODE, STEREO_NONINTERLEAVED); - ci->configure(DSP_SET_SAMPLE_DEPTH, 29); - } - - return CODEC_OK; -} - -/* this is called for each file to process */ -enum codec_status codec_run(void) -{ - /* Note that when dealing with QuickTime/MPEG4 files, terminology is - * a bit confusing. Files with sound are split up in chunks, where - * each chunk contains one or more samples. Each sample in turn - * contains a number of "sound samples" (the kind you refer to with - * the sampling frequency). - */ - size_t n; - demux_res_t demux_res; - stream_t input_stream; - uint32_t sound_samples_done; - uint32_t elapsed_time; - int file_offset; - int framelength; - int lead_trim = 0; - unsigned int frame_samples; - unsigned int i; - unsigned char* buffer; - NeAACDecFrameInfo frame_info; - NeAACDecHandle decoder; - int err; - uint32_t seek_idx = 0; - uint32_t s = 0; - uint32_t sbr_fac = 1; - unsigned char c = 0; - void *ret; - intptr_t param; - bool empty_first_frame = false; - - /* Clean and initialize decoder structures */ - memset(&demux_res , 0, sizeof(demux_res)); - if (codec_init()) { - LOGF("FAAD: Codec init error\n"); - return CODEC_ERROR; - } - - file_offset = ci->id3->offset; - - ci->configure(DSP_SWITCH_FREQUENCY, ci->id3->frequency); - codec_set_replaygain(ci->id3); - - stream_create(&input_stream,ci); - - ci->seek_buffer(ci->id3->first_frame_offset); - - /* if qtmovie_read returns successfully, the stream is up to - * the movie data, which can be used directly by the decoder */ - if (!qtmovie_read(&input_stream, &demux_res)) { - LOGF("FAAD: File init error\n"); - return CODEC_ERROR; - } - - /* initialise the sound converter */ - decoder = NeAACDecOpen(); - - if (!decoder) { - LOGF("FAAD: Decode open error\n"); - return CODEC_ERROR; - } - - NeAACDecConfigurationPtr conf = NeAACDecGetCurrentConfiguration(decoder); - conf->outputFormat = FAAD_FMT_24BIT; /* irrelevant, we don't convert */ - NeAACDecSetConfiguration(decoder, conf); - - err = NeAACDecInit2(decoder, demux_res.codecdata, demux_res.codecdata_len, &s, &c); - if (err) { - LOGF("FAAD: DecInit: %d, %d\n", err, decoder->object_type); - return CODEC_ERROR; - } - -#ifdef SBR_DEC - /* Check for need of special handling for seek/resume and elapsed time. */ - if (ci->id3->needs_upsampling_correction) { - sbr_fac = 2; - } else { - sbr_fac = 1; - } -#endif - - i = 0; - - if (file_offset > 0) { - /* Resume the desired (byte) position. Important: When resuming SBR - * upsampling files the resulting sound_samples_done must be expanded - * by a factor of 2. This is done via using sbr_fac. */ - if (m4a_seek_raw(&demux_res, &input_stream, file_offset, - &sound_samples_done, (int*) &i)) { - sound_samples_done *= sbr_fac; - } else { - sound_samples_done = 0; - } - NeAACDecPostSeekReset(decoder, i); - } else { - sound_samples_done = 0; - } - - elapsed_time = (sound_samples_done * 10) / (ci->id3->frequency / 100); - ci->set_elapsed(elapsed_time); - - if (i == 0) - { - lead_trim = ci->id3->lead_trim; - } - - /* The main decoding loop */ - while (i < demux_res.num_sample_byte_sizes) { - enum codec_command_action action = ci->get_command(¶m); - - if (action == CODEC_ACTION_HALT) - break; - - /* Deal with any pending seek requests */ - if (action == CODEC_ACTION_SEEK_TIME) { - /* Seek to the desired time position. Important: When seeking in SBR - * upsampling files the seek_time must be divided by 2 when calling - * m4a_seek and the resulting sound_samples_done must be expanded - * by a factor 2. This is done via using sbr_fac. */ - if (m4a_seek(&demux_res, &input_stream, - (param/10/sbr_fac)*(ci->id3->frequency/100), - &sound_samples_done, (int*) &i)) { - sound_samples_done *= sbr_fac; - elapsed_time = (sound_samples_done * 10) / (ci->id3->frequency / 100); - ci->set_elapsed(elapsed_time); - seek_idx = 0; - - if (i == 0) - { - lead_trim = ci->id3->lead_trim; - } - } - NeAACDecPostSeekReset(decoder, i); - ci->seek_complete(); - } - - /* There can be gaps between chunks, so skip ahead if needed. It - * doesn't seem to happen much, but it probably means that a - * "proper" file can have chunks out of order. Why one would want - * that an good question (but files with gaps do exist, so who - * knows?), so we don't support that - for now, at least. - */ - file_offset = m4a_check_sample_offset(&demux_res, i, &seek_idx); - - if (file_offset > ci->curpos) - { - ci->advance_buffer(file_offset - ci->curpos); - } - else if (file_offset == 0) - { - LOGF("AAC: get_sample_offset error\n"); - return CODEC_ERROR; - } - - /* Request the required number of bytes from the input buffer */ - buffer=ci->request_buffer(&n, FAAD_BYTE_BUFFER_SIZE); - - /* Decode one block - returned samples will be host-endian */ - ret = NeAACDecDecode(decoder, &frame_info, buffer, n); - - /* NeAACDecDecode may sometimes return NULL without setting error. */ - if (ret == NULL || frame_info.error > 0) { - LOGF("FAAD: decode error '%s'\n", NeAACDecGetErrorMessage(frame_info.error)); - return CODEC_ERROR; - } - - /* Advance codec buffer (no need to call set_offset because of this) */ - ci->advance_buffer(frame_info.bytesconsumed); - - /* Output the audio */ - ci->yield(); - - frame_samples = frame_info.samples >> 1; - - if (empty_first_frame) - { - /* Remove the first frame from lead_trim, under the assumption - * that it had the same size as this frame - */ - empty_first_frame = false; - lead_trim -= frame_samples; - - if (lead_trim < 0) - { - lead_trim = 0; - } - } - - /* Gather number of samples for the decoded frame. */ - framelength = frame_samples - lead_trim; - - if (i == demux_res.num_sample_byte_sizes - 1) - { - // Size of the last frame - const uint32_t sample_duration = (demux_res.num_time_to_samples > 0) ? - demux_res.time_to_sample[demux_res.num_time_to_samples - 1].sample_duration : - frame_samples; - - /* Currently limited to at most one frame of tail_trim. - * Seems to be enough. - */ - if (ci->id3->tail_trim == 0 && sample_duration < frame_samples) - { - /* Subtract lead_trim just in case we decode a file with only - * one audio frame with actual data (lead_trim is usually zero - * here). - */ - framelength = sample_duration - lead_trim; - } - else - { - framelength -= ci->id3->tail_trim; - } - } - - if (framelength > 0) - { - ci->pcmbuf_insert(&decoder->time_out[0][lead_trim], - &decoder->time_out[1][lead_trim], - framelength); - sound_samples_done += framelength; - /* Update the elapsed-time indicator */ - elapsed_time = ((uint64_t) sound_samples_done * 1000) / - ci->id3->frequency; - ci->set_elapsed(elapsed_time); - } - - if (lead_trim > 0) - { - /* frame_info.samples can be 0 for frame 0. We still want to - * remove it from lead_trim, so do that during frame 1. - */ - if (0 == i && 0 == frame_info.samples) - { - empty_first_frame = true; - } - - lead_trim -= frame_samples; - - if (lead_trim < 0) - { - lead_trim = 0; - } - } - - ++i; - } - - LOGF("AAC: Decoded %lu samples\n", (unsigned long)sound_samples_done); - return CODEC_OK; -} diff --git a/apps/codecs/adx.c b/apps/codecs/adx.c deleted file mode 100644 index 0c67fc8d6e..0000000000 --- a/apps/codecs/adx.c +++ /dev/null @@ -1,404 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * - * Copyright (C) 2006-2008 Adam Gashlin (hcs) - * Copyright (C) 2006 Jens Arnold - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ - -#include -#include "codeclib.h" -#include "inttypes.h" -#include "math.h" -#include "lib/fixedpoint.h" - -CODEC_HEADER - -/* Maximum number of bytes to process in one iteration */ -#define WAV_CHUNK_SIZE (1024*2) - -/* Number of times to loop looped tracks when repeat is disabled */ -#define LOOP_TIMES 2 - -/* Length of fade-out for looped tracks (milliseconds) */ -#define FADE_LENGTH 10000L - -/* Default high pass filter cutoff frequency is 500 Hz. - * Others can be set, but the default is nearly always used, - * and there is no way to determine if another was used, anyway. - */ -static const long cutoff = 500; - -static int16_t samples[WAV_CHUNK_SIZE] IBSS_ATTR; - -/* this is the codec entry point */ -enum codec_status codec_main(enum codec_entry_call_reason reason) -{ - if (reason == CODEC_LOAD) { - /* Generic codec initialisation */ - /* we only render 16 bits */ - ci->configure(DSP_SET_SAMPLE_DEPTH, 16); - } - - return CODEC_OK; -} - -/* this is called for each file to process */ -enum codec_status codec_run(void) -{ - int channels; - int sampleswritten, i; - uint8_t *buf; - int32_t ch1_1, ch1_2, ch2_1, ch2_2; /* ADPCM history */ - size_t n; - int endofstream; /* end of stream flag */ - uint32_t avgbytespersec; - int looping; /* looping flag */ - int loop_count; /* number of loops done so far */ - int fade_count; /* countdown for fadeout */ - int fade_frames; /* length of fade in frames */ - off_t start_adr, end_adr; /* loop points */ - off_t chanstart, bufoff; - /*long coef1=0x7298L,coef2=-0x3350L;*/ - long coef1, coef2; - intptr_t param; - - DEBUGF("ADX: next_track\n"); - if (codec_init()) { - return CODEC_ERROR; - } - DEBUGF("ADX: after init\n"); - - /* init history */ - ch1_1=ch1_2=ch2_1=ch2_2=0; - - codec_set_replaygain(ci->id3); - - /* Get header */ - DEBUGF("ADX: request initial buffer\n"); - ci->seek_buffer(0); - buf = ci->request_buffer(&n, 0x38); - if (!buf || n < 0x38) { - return CODEC_ERROR; - } - bufoff = 0; - DEBUGF("ADX: read size = %lx\n",(unsigned long)n); - - /* Get file header for starting offset, channel count */ - - chanstart = ((buf[2] << 8) | buf[3]) + 4; - channels = buf[7]; - - /* useful for seeking and reporting current playback position */ - avgbytespersec = ci->id3->frequency * 18 * channels / 32; - DEBUGF("avgbytespersec=%ld\n",(unsigned long)avgbytespersec); - - /* calculate filter coefficients */ - - /** - * A simple table of these coefficients would be nice, but - * some very odd frequencies are used and if I'm going to - * interpolate I might as well just go all the way and - * calclate them precisely. - * Speed is not an issue as this only needs to be done once per file. - */ - { - const int64_t big28 = 0x10000000LL; - const int64_t big32 = 0x100000000LL; - int64_t frequency = ci->id3->frequency; - int64_t phasemultiple = cutoff*big32/frequency; - - long z; - int64_t a; - const int64_t b = (M_SQRT2*big28)-big28; - int64_t c; - int64_t d; - - fp_sincos((unsigned long)phasemultiple,&z); - - a = (M_SQRT2*big28) - (z >> 3); - - /** - * In the long passed to fsqrt there are only 4 nonfractional bits, - * which is sufficient here, but this is the only reason why I don't - * use 32 fractional bits everywhere. - */ - d = fp_sqrt((a+b)*(a-b)/big28,28); - c = (a-d)*big28/b; - - coef1 = (c*8192) >> 28; - coef2 = (c*c/big28*-4096) >> 28; - DEBUGF("ADX: samprate=%ld ",(long)frequency); - DEBUGF("coef1 %04x ",(unsigned int)(coef1*4)); - DEBUGF("coef2 %04x\n",(unsigned int)(coef2*-4)); - } - - /* Get loop data */ - - looping = 0; start_adr = 0; end_adr = 0; - if (!memcmp(buf+0x10,"\x01\xF4\x03",3)) { - /* Soul Calibur 2 style (type 03) */ - DEBUGF("ADX: type 03 found\n"); - /* check if header is too small for loop data */ - if (chanstart-6 < 0x2c) looping=0; - else { - looping = (buf[0x18]) || - (buf[0x19]) || - (buf[0x1a]) || - (buf[0x1b]); - end_adr = (buf[0x28]<<24) | - (buf[0x29]<<16) | - (buf[0x2a]<<8) | - (buf[0x2b]); - - start_adr = ( - (buf[0x1c]<<24) | - (buf[0x1d]<<16) | - (buf[0x1e]<<8) | - (buf[0x1f]) - )/32*channels*18+chanstart; - } - } else if (!memcmp(buf+0x10,"\x01\xF4\x04",3)) { - /* Standard (type 04) */ - DEBUGF("ADX: type 04 found\n"); - /* check if header is too small for loop data */ - if (chanstart-6 < 0x38) looping=0; - else { - looping = (buf[0x24]) || - (buf[0x25]) || - (buf[0x26]) || - (buf[0x27]); - end_adr = (buf[0x34]<<24) | - (buf[0x35]<<16) | - (buf[0x36]<<8) | - buf[0x37]; - start_adr = ( - (buf[0x28]<<24) | - (buf[0x29]<<16) | - (buf[0x2a]<<8) | - (buf[0x2b]) - )/32*channels*18+chanstart; - } - } else { - DEBUGF("ADX: error, couldn't determine ADX type\n"); - return CODEC_ERROR; - } - - /* is file using encryption */ - if (buf[0x13]==0x08) { - DEBUGF("ADX: error, encrypted ADX not supported\n"); - return false; - } - - if (looping) { - DEBUGF("ADX: looped, start: %lx end: %lx\n",start_adr,end_adr); - } else { - DEBUGF("ADX: not looped\n"); - } - - /* advance to first frame */ - DEBUGF("ADX: first frame at %lx\n",chanstart); - bufoff = chanstart; - - /* get in position */ - ci->seek_buffer(bufoff); - ci->set_elapsed(0); - - /* setup pcm buffer format */ - ci->configure(DSP_SWITCH_FREQUENCY, ci->id3->frequency); - if (channels == 2) { - ci->configure(DSP_SET_STEREO_MODE, STEREO_INTERLEAVED); - } else if (channels == 1) { - ci->configure(DSP_SET_STEREO_MODE, STEREO_MONO); - } else { - DEBUGF("ADX CODEC_ERROR: more than 2 channels\n"); - return CODEC_ERROR; - } - - endofstream = 0; - loop_count = 0; - fade_count = -1; /* disable fade */ - fade_frames = 1; - - /* The main decoder loop */ - - while (!endofstream) { - enum codec_command_action action = ci->get_command(¶m); - - if (action == CODEC_ACTION_HALT) - break; - - /* do we need to loop? */ - if (bufoff > end_adr-18*channels && looping) { - DEBUGF("ADX: loop!\n"); - /* check for endless looping */ - if (ci->loop_track()) { - loop_count=0; - fade_count = -1; /* disable fade */ - } else { - /* otherwise start fade after LOOP_TIMES loops */ - loop_count++; - if (loop_count >= LOOP_TIMES && fade_count < 0) { - /* frames to fade over */ - fade_frames = FADE_LENGTH*ci->id3->frequency/32/1000; - /* volume relative to fade_frames */ - fade_count = fade_frames; - DEBUGF("ADX: fade_frames = %d\n",fade_frames); - } - } - bufoff = start_adr; - ci->seek_buffer(bufoff); - } - - /* do we need to seek? */ - if (action == CODEC_ACTION_SEEK_TIME) { - uint32_t newpos; - - DEBUGF("ADX: seek to %ldms\n", (long)param); - - endofstream = 0; - loop_count = 0; - fade_count = -1; /* disable fade */ - fade_frames = 1; - - newpos = (((uint64_t)avgbytespersec*param) - / (1000LL*18*channels))*(18*channels); - bufoff = chanstart + newpos; - while (bufoff > end_adr-18*channels) { - bufoff-=end_adr-start_adr; - loop_count++; - } - ci->seek_buffer(bufoff); - - ci->set_elapsed( - ((end_adr-start_adr)*loop_count + bufoff-chanstart)* - 1000LL/avgbytespersec); - - ci->seek_complete(); - } - - if (bufoff>ci->filesize-channels*18) break; /* End of stream */ - - sampleswritten=0; - - while ( - /* Is there data left in the file? */ - (bufoff <= ci->filesize-(18*channels)) && - /* Is there space in the output buffer? */ - (sampleswritten <= WAV_CHUNK_SIZE-(32*channels)) && - /* Should we be looping? */ - ((!looping) || bufoff <= end_adr-18*channels)) - { - /* decode first/only channel */ - int32_t scale; - int32_t ch1_0, d; - - /* fetch a frame */ - buf = ci->request_buffer(&n, 18); - - if (!buf || n!=18) { - DEBUGF("ADX: couldn't get buffer at %lx\n", - bufoff); - return CODEC_ERROR; - } - - scale = ((buf[0] << 8) | (buf[1])) +1; - - for (i = 2; i < 18; i++) - { - d = (buf[i] >> 4) & 15; - if (d & 8) d-= 16; - ch1_0 = d*scale + ((coef1*ch1_1 + coef2*ch1_2) >> 12); - if (ch1_0 > 32767) ch1_0 = 32767; - else if (ch1_0 < -32768) ch1_0 = -32768; - samples[sampleswritten] = ch1_0; - sampleswritten+=channels; - ch1_2 = ch1_1; ch1_1 = ch1_0; - - d = buf[i] & 15; - if (d & 8) d -= 16; - ch1_0 = d*scale + ((coef1*ch1_1 + coef2*ch1_2) >> 12); - if (ch1_0 > 32767) ch1_0 = 32767; - else if (ch1_0 < -32768) ch1_0 = -32768; - samples[sampleswritten] = ch1_0; - sampleswritten+=channels; - ch1_2 = ch1_1; ch1_1 = ch1_0; - } - bufoff+=18; - ci->advance_buffer(18); - - if (channels == 2) { - /* decode second channel */ - int32_t scale; - int32_t ch2_0, d; - - buf = ci->request_buffer(&n, 18); - - if (!buf || n!=18) { - DEBUGF("ADX: couldn't get buffer at %lx\n", - bufoff); - return CODEC_ERROR; - } - - scale = ((buf[0] << 8)|(buf[1]))+1; - - sampleswritten-=63; - - for (i = 2; i < 18; i++) - { - d = (buf[i] >> 4) & 15; - if (d & 8) d-= 16; - ch2_0 = d*scale + ((coef1*ch2_1 + coef2*ch2_2) >> 12); - if (ch2_0 > 32767) ch2_0 = 32767; - else if (ch2_0 < -32768) ch2_0 = -32768; - samples[sampleswritten] = ch2_0; - sampleswritten+=2; - ch2_2 = ch2_1; ch2_1 = ch2_0; - - d = buf[i] & 15; - if (d & 8) d -= 16; - ch2_0 = d*scale + ((coef1*ch2_1 + coef2*ch2_2) >> 12); - if (ch2_0 > 32767) ch2_0 = 32767; - else if (ch2_0 < -32768) ch2_0 = -32768; - samples[sampleswritten] = ch2_0; - sampleswritten+=2; - ch2_2 = ch2_1; ch2_1 = ch2_0; - } - bufoff+=18; - ci->advance_buffer(18); - sampleswritten--; /* go back to first channel's next sample */ - } - - if (fade_count>0) { - fade_count--; - for (i=0;i<(channels==1?32:64);i++) samples[sampleswritten-i-1]= - ((int32_t)samples[sampleswritten-i-1])*fade_count/fade_frames; - if (fade_count==0) {endofstream=1; break;} - } - } - - if (channels == 2) - sampleswritten >>= 1; /* make samples/channel */ - - ci->pcmbuf_insert(samples, NULL, sampleswritten); - - ci->set_elapsed( - ((end_adr-start_adr)*loop_count + bufoff-chanstart)* - 1000LL/avgbytespersec); - } - - return CODEC_OK; -} diff --git a/apps/codecs/aiff.c b/apps/codecs/aiff.c deleted file mode 100644 index 333bcd0455..0000000000 --- a/apps/codecs/aiff.c +++ /dev/null @@ -1,350 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (c) 2005 Jvo Studer - * Copyright (c) 2009 Yoshihisa Uchida - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ - -#include "codeclib.h" -#include "codecs/libpcm/support_formats.h" - -CODEC_HEADER - -#define FOURCC(c1, c2, c3, c4) \ -((((uint32_t)c1)<<24)|(((uint32_t)c2)<<16)|(((uint32_t)c3)<<8)|((uint32_t)c4)) - -/* This codec supports the following AIFC compressionType formats */ -enum { - AIFC_FORMAT_PCM = FOURCC('N', 'O', 'N', 'E'), /* AIFC PCM Format (big endian) */ - AIFC_FORMAT_ALAW = FOURCC('a', 'l', 'a', 'w'), /* AIFC ALaw compressed */ - AIFC_FORMAT_MULAW = FOURCC('u', 'l', 'a', 'w'), /* AIFC uLaw compressed */ - AIFC_FORMAT_IEEE_FLOAT32 = FOURCC('f', 'l', '3', '2'), /* AIFC IEEE float 32 bit */ - AIFC_FORMAT_IEEE_FLOAT64 = FOURCC('f', 'l', '6', '4'), /* AIFC IEEE float 64 bit */ - AIFC_FORMAT_QT_IMA_ADPCM = FOURCC('i', 'm', 'a', '4'), /* AIFC QuickTime IMA ADPCM */ -}; - -static const struct pcm_entry pcm_codecs[] = { - { AIFC_FORMAT_PCM, get_linear_pcm_codec }, - { AIFC_FORMAT_ALAW, get_itut_g711_alaw_codec }, - { AIFC_FORMAT_MULAW, get_itut_g711_mulaw_codec }, - { AIFC_FORMAT_IEEE_FLOAT32, get_ieee_float_codec }, - { AIFC_FORMAT_IEEE_FLOAT64, get_ieee_float_codec }, - { AIFC_FORMAT_QT_IMA_ADPCM, get_qt_ima_adpcm_codec }, -}; - -#define PCM_SAMPLE_SIZE (1024*2) - -static int32_t samples[PCM_SAMPLE_SIZE] IBSS_ATTR; - -static const struct pcm_codec *get_codec(uint32_t formattag) -{ - unsigned i; - for (i = 0; i < sizeof(pcm_codecs)/sizeof(pcm_codecs[0]); i++) - if (pcm_codecs[i].format_tag == formattag) - return pcm_codecs[i].get_codec(); - - return NULL; -} - -/* this is the codec entry point */ -enum codec_status codec_main(enum codec_entry_call_reason reason) -{ - if (reason == CODEC_LOAD) { - /* Generic codec initialisation */ - ci->configure(DSP_SET_SAMPLE_DEPTH, PCM_OUTPUT_DEPTH-1); - } - - return CODEC_OK; -} - -/* this is called for each file to process */ -enum codec_status codec_run(void) -{ - struct pcm_format format; - uint32_t bytesdone, decodedsamples; - /* rockbox: comment 'set but unused' variables - uint32_t num_sample_frames = 0; - */ - size_t n; - int bufcount; - int endofstream; - unsigned char *buf; - uint8_t *aifbuf; - uint32_t offset2snd = 0; - off_t firstblockposn; /* position of the first block in file */ - bool is_aifc = false; - const struct pcm_codec *codec; - uint32_t size; - intptr_t param; - - if (codec_init()) { - return CODEC_ERROR; - } - - codec_set_replaygain(ci->id3); - - /* Need to save offset for later use (cleared indirectly by advance_buffer) */ - bytesdone = ci->id3->offset; - - /* assume the AIFF header is less than 1024 bytes */ - ci->seek_buffer(0); - buf = ci->request_buffer(&n, 1024); - if (n < 54) { - return CODEC_ERROR; - } - - if (memcmp(buf, "FORM", 4) != 0) - { - DEBUGF("CODEC_ERROR: does not aiff format %4.4s\n", (char*)&buf[0]); - return CODEC_ERROR; - } - if (memcmp(&buf[8], "AIFF", 4) == 0) - is_aifc = false; - else if (memcmp(&buf[8], "AIFC", 4) == 0) - is_aifc = true; - else - { - DEBUGF("CODEC_ERROR: does not aiff format %4.4s\n", (char*)&buf[8]); - return CODEC_ERROR; - } - - buf += 12; - n -= 12; - - ci->memset(&format, 0, sizeof(struct pcm_format)); - format.is_signed = true; - format.is_little_endian = false; - - decodedsamples = 0; - codec = 0; - - /* read until 'SSND' chunk, which typically is last */ - while (format.numbytes == 0 && n >= 8) - { - /* chunkSize */ - size = ((buf[4]<<24)|(buf[5]<<16)|(buf[6]<<8)|buf[7]); - if (memcmp(buf, "COMM", 4) == 0) { - if ((!is_aifc && size < 18) || (is_aifc && size < 22)) - { - DEBUGF("CODEC_ERROR: 'COMM' chunk size=%lu < %d\n", - (unsigned long)size, (is_aifc)?22:18); - return CODEC_ERROR; - } - /* num_channels */ - format.channels = ((buf[8]<<8)|buf[9]); - /* num_sample_frames */ - /* - num_sample_frames = ((buf[10]<<24)|(buf[11]<<16)|(buf[12]<<8) - |buf[13]); - */ - - /* sample_size */ - format.bitspersample = ((buf[14]<<8)|buf[15]); - /* sample_rate (don't use last 4 bytes, only integer fs) */ - if (buf[16] != 0x40) { - DEBUGF("CODEC_ERROR: weird sampling rate (no @)\n"); - return CODEC_ERROR; - } - format.samplespersec = ((buf[18]<<24)|(buf[19]<<16)|(buf[20]<<8)|buf[21])+1; - format.samplespersec >>= (16 + 14 - buf[17]); - /* compressionType (AIFC only) */ - if (is_aifc) - { - format.formattag = (buf[26]<<24)|(buf[27]<<16)|(buf[28]<<8)|buf[29]; - - /* - * aiff's sample_size is uncompressed sound data size. - * But format.bitspersample is compressed sound data size. - */ - if (format.formattag == AIFC_FORMAT_ALAW || - format.formattag == AIFC_FORMAT_MULAW) - format.bitspersample = 8; - else if (format.formattag == AIFC_FORMAT_QT_IMA_ADPCM) - format.bitspersample = 4; - } - else - format.formattag = AIFC_FORMAT_PCM; - /* calc average bytes per second */ - format.avgbytespersec = format.samplespersec*format.channels*format.bitspersample/8; - } else if (memcmp(buf, "SSND", 4)==0) { - if (format.bitspersample == 0) { - DEBUGF("CODEC_ERROR: unsupported chunk order\n"); - return CODEC_ERROR; - } - /* offset2snd */ - offset2snd = (buf[8]<<24)|(buf[9]<<16)|(buf[10]<<8)|buf[11]; - /* block_size */ - format.blockalign = ((buf[12]<<24)|(buf[13]<<16)|(buf[14]<<8)|buf[15]) >> 3; - if (format.blockalign == 0) - format.blockalign = format.channels * format.bitspersample >> 3; - format.numbytes = size - 8 - offset2snd; - size = 8 + offset2snd; /* advance to the beginning of data */ - } else if (is_aifc && (memcmp(buf, "FVER", 4)==0)) { - /* Format Version Chunk (AIFC only chunk) */ - /* skip this chunk */ - } else { - DEBUGF("unsupported AIFF chunk: '%c%c%c%c', size=%lu\n", - buf[0], buf[1], buf[2], buf[3], (unsigned long)size); - } - - size += 8 + (size & 0x01); /* odd chunk sizes must be padded */ - - buf += size; - if (n < size) { - DEBUGF("CODEC_ERROR: AIFF header size > 1024\n"); - return CODEC_ERROR; - } - n -= size; - } /* while 'SSND' */ - - if (format.channels == 0) { - DEBUGF("CODEC_ERROR: 'COMM' chunk not found or 0-channels file\n"); - return CODEC_ERROR; - } - if (format.numbytes == 0) { - DEBUGF("CODEC_ERROR: 'SSND' chunk not found or has zero length\n"); - return CODEC_ERROR; - } - - codec = get_codec(format.formattag); - if (codec == 0) - { - DEBUGF("CODEC_ERROR: AIFC does not support compressionType: 0x%x\n", - (unsigned int)format.formattag); - return CODEC_ERROR; - } - - if (!codec->set_format(&format)) - { - return CODEC_ERROR; - } - - ci->configure(DSP_SWITCH_FREQUENCY, ci->id3->frequency); - - if (format.channels == 2) { - ci->configure(DSP_SET_STEREO_MODE, STEREO_INTERLEAVED); - } else if (format.channels == 1) { - ci->configure(DSP_SET_STEREO_MODE, STEREO_MONO); - } else { - DEBUGF("CODEC_ERROR: more than 2 channels unsupported\n"); - return CODEC_ERROR; - } - - if (format.samplesperblock == 0) - { - DEBUGF("CODEC_ERROR: samplesperblock is 0\n"); - return CODEC_ERROR; - } - if (format.blockalign == 0) - { - DEBUGF("CODEC_ERROR: blockalign is 0\n"); - return CODEC_ERROR; - } - - /* check chunksize */ - if ((format.chunksize / format.blockalign) * format.samplesperblock * format.channels - > PCM_SAMPLE_SIZE) - format.chunksize = (PCM_SAMPLE_SIZE / format.blockalign) * format.blockalign; - if (format.chunksize == 0) - { - DEBUGF("CODEC_ERROR: chunksize is 0\n"); - return CODEC_ERROR; - } - - firstblockposn = 1024 - n; - ci->advance_buffer(firstblockposn); - - /* make sure we're at the correct offset */ - if (bytesdone > (uint32_t) firstblockposn) { - /* Round down to previous block */ - struct pcm_pos *newpos = codec->get_seek_pos(bytesdone - firstblockposn, - PCM_SEEK_POS, NULL); - - if (newpos->pos > format.numbytes) - return CODEC_OK; - - if (ci->seek_buffer(firstblockposn + newpos->pos)) - { - bytesdone = newpos->pos; - decodedsamples = newpos->samples; - } - } else { - /* already where we need to be */ - bytesdone = 0; - } - - ci->set_elapsed(decodedsamples*1000LL/ci->id3->frequency); - - /* The main decoder loop */ - endofstream = 0; - - while (!endofstream) { - enum codec_command_action action = ci->get_command(¶m); - - if (action == CODEC_ACTION_HALT) - break; - - if (action == CODEC_ACTION_SEEK_TIME) { - /* 3rd args(read_buffer) is unnecessary in the format which AIFF supports. */ - struct pcm_pos *newpos = codec->get_seek_pos(param, PCM_SEEK_TIME, NULL); - - if (newpos->pos > format.numbytes) - { - ci->set_elapsed(ci->id3->length); - ci->seek_complete(); - break; - } - - if (ci->seek_buffer(firstblockposn + newpos->pos)) - { - bytesdone = newpos->pos; - decodedsamples = newpos->samples; - } - - ci->set_elapsed(decodedsamples*1000LL/ci->id3->frequency); - ci->seek_complete(); - } - aifbuf = (uint8_t *)ci->request_buffer(&n, format.chunksize); - - if (n == 0) - break; /* End of stream */ - - if (bytesdone + n > format.numbytes) { - n = format.numbytes - bytesdone; - endofstream = 1; - } - - if (codec->decode(aifbuf, n, samples, &bufcount) == CODEC_ERROR) - { - DEBUGF("codec error\n"); - return CODEC_ERROR; - } - - ci->pcmbuf_insert(samples, NULL, bufcount); - - ci->advance_buffer(n); - bytesdone += n; - decodedsamples += bufcount; - if (bytesdone >= format.numbytes) - endofstream = 1; - - ci->set_elapsed(decodedsamples*1000LL/ci->id3->frequency); - } - - return CODEC_OK; -} diff --git a/apps/codecs/aiff_enc.c b/apps/codecs/aiff_enc.c deleted file mode 100644 index fc44196eb0..0000000000 --- a/apps/codecs/aiff_enc.c +++ /dev/null @@ -1,400 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2006 Antonius Hellmann - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ - -#include -#include "codeclib.h" - -CODEC_ENC_HEADER - -struct aiff_header -{ - uint8_t form_id[4]; /* 00h - 'FORM' */ - uint32_t form_size; /* 04h - size of file - 8 */ - uint8_t aiff_id[4]; /* 08h - 'AIFF' */ - uint8_t comm_id[4]; /* 0Ch - 'COMM' */ - int32_t comm_size; /* 10h - num_channels through sample_rate - (18) */ - int16_t num_channels; /* 14h - 1=M, 2=S, etc. */ - uint32_t num_sample_frames; /* 16h - num samples for each channel */ - int16_t sample_size; /* 1ah - 1-32 bits per sample */ - uint8_t sample_rate[10]; /* 1ch - IEEE 754 80-bit floating point */ - uint8_t ssnd_id[4]; /* 26h - "SSND" */ - int32_t ssnd_size; /* 2ah - size of chunk from offset to - end of pcm data */ - uint32_t offset; /* 2eh - data offset from end of header */ - uint32_t block_size; /* 32h - pcm data alignment */ - /* 36h */ -} __attribute__((packed)); - -#define PCM_DEPTH_BYTES 2 -#define PCM_DEPTH_BITS 16 -#define PCM_SAMP_PER_CHUNK 2048 -#define PCM_CHUNK_SIZE (PCM_SAMP_PER_CHUNK*4) - -/* Template headers */ -struct aiff_header aiff_header = -{ - { 'F', 'O', 'R', 'M' }, /* form_id */ - 0, /* form_size (*) */ - { 'A', 'I', 'F', 'F' }, /* aiff_id */ - { 'C', 'O', 'M', 'M' }, /* comm_id */ - htobe32(18), /* comm_size */ - 0, /* num_channels (*) */ - 0, /* num_sample_frames (*) */ - htobe16(PCM_DEPTH_BITS), /* sample_size */ - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* sample_rate (*) */ - { 'S', 'S', 'N', 'D' }, /* ssnd_id */ - 0, /* ssnd_size (*) */ - htobe32(0), /* offset */ - htobe32(0), /* block_size */ -}; - -/* (*) updated when finalizing file */ - -static int num_channels IBSS_ATTR; -static int rec_mono_mode IBSS_ATTR; -static uint32_t sample_rate; -static uint32_t enc_size; -static int32_t err IBSS_ATTR; - -/* convert unsigned 32 bit value to 80-bit floating point number */ -STATICIRAM void uint32_h_to_ieee754_extended_be(uint8_t f[10], uint32_t l) - ICODE_ATTR; -STATICIRAM void uint32_h_to_ieee754_extended_be(uint8_t f[10], uint32_t l) -{ - int32_t exp; - - ci->memset(f, 0, 10); - - if (l == 0) - return; - - for (exp = 30; (l & (1ul << 31)) == 0; exp--) - l <<= 1; - - /* sign always zero - bit 79 */ - /* exponent is 0-31 (normalized: 31 - shift + 16383) - bits 64-78 */ - f[0] = 0x40; - f[1] = (uint8_t)exp; - /* mantissa is value left justified with most significant non-zero - bit stored in bit 63 - bits 0-63 */ - f[2] = (uint8_t)(l >> 24); - f[3] = (uint8_t)(l >> 16); - f[4] = (uint8_t)(l >> 8); - f[5] = (uint8_t)(l >> 0); -} /* uint32_h_to_ieee754_extended_be */ - -/* called version often - inline */ -static inline bool is_file_data_ok(struct enc_file_event_data *data) ICODE_ATTR; -static inline bool is_file_data_ok(struct enc_file_event_data *data) -{ - return data->rec_file >= 0 && (long)data->chunk->flags >= 0; -} /* is_file_data_ok */ - -/* called version often - inline */ -static inline bool on_write_chunk(struct enc_file_event_data *data) ICODE_ATTR; -static inline bool on_write_chunk(struct enc_file_event_data *data) -{ - if (!is_file_data_ok(data)) - return false; - - if (data->chunk->enc_data == NULL) - { -#ifdef ROCKBOX_HAS_LOGF - ci->logf("aiff enc: NULL data"); -#endif - return true; - } - - if (ci->write(data->rec_file, data->chunk->enc_data, - data->chunk->enc_size) != (ssize_t)data->chunk->enc_size) - return false; - - data->num_pcm_samples += data->chunk->num_pcm; - return true; -} /* on_write_chunk */ - -static bool on_start_file(struct enc_file_event_data *data) -{ - if ((data->chunk->flags & CHUNKF_ERROR) || *data->filename == '\0') - return false; - - data->rec_file = ci->open(data->filename, O_RDWR|O_CREAT|O_TRUNC, 0666); - - if (data->rec_file < 0) - return false; - - /* reset sample count */ - data->num_pcm_samples = 0; - - /* write template headers */ - if (ci->write(data->rec_file, &aiff_header, sizeof (aiff_header)) - != sizeof (aiff_header)) - { - return false; - } - - data->new_enc_size += sizeof(aiff_header); - return true; -} /* on_start_file */ - -static bool on_end_file(struct enc_file_event_data *data) -{ - /* update template headers */ - struct aiff_header hdr; - uint32_t data_size; - - if (!is_file_data_ok(data)) - return false; - - if (ci->lseek(data->rec_file, 0, SEEK_SET) != 0 || - ci->read(data->rec_file, &hdr, sizeof (hdr)) != sizeof (hdr)) - { - return false; - } - - data_size = data->num_pcm_samples*num_channels*PCM_DEPTH_BYTES; - - /* 'FORM' chunk */ - hdr.form_size = htobe32(data_size + sizeof (hdr) - 8); - - /* 'COMM' chunk */ - hdr.num_channels = htobe16(num_channels); - hdr.num_sample_frames = htobe32(data->num_pcm_samples); - uint32_h_to_ieee754_extended_be(hdr.sample_rate, sample_rate); - - /* 'SSND' chunk */ - hdr.ssnd_size = htobe32(data_size + 8); - - if (ci->lseek(data->rec_file, 0, SEEK_SET) != 0 || - ci->write(data->rec_file, &hdr, sizeof (hdr)) != sizeof (hdr) || - ci->close(data->rec_file) != 0) - { - return false; - } - - data->rec_file = -1; - - return true; -} /* on_end_file */ - -STATICIRAM void enc_events_callback(enum enc_events event, void *data) - ICODE_ATTR; -STATICIRAM void enc_events_callback(enum enc_events event, void *data) -{ - switch (event) - { - case ENC_WRITE_CHUNK: - if (on_write_chunk((struct enc_file_event_data *)data)) - return; - - break; - - case ENC_START_FILE: - if (on_start_file((struct enc_file_event_data *)data)) - return; - - break; - - case ENC_END_FILE: - if (on_end_file((struct enc_file_event_data *)data)) - return; - - break; - - default: - return; - } - - /* Something failed above. Signal error back to core. */ - ((struct enc_file_event_data *)data)->chunk->flags |= CHUNKF_ERROR; -} /* enc_events_callback */ - -/* convert native pcm samples to aiff format samples */ -static inline void sample_to_mono(uint32_t **src, uint32_t **dst) -{ - int32_t lr1, lr2; - - switch(rec_mono_mode) - { - case 1: - /* mono = L */ - lr1 = *(*src)++; - lr1 = lr1 >> 16; - lr2 = *(*src)++; - lr2 = lr2 >> 16; - break; - case 2: - /* mono = R */ - lr1 = *(*src)++; - lr1 = (int16_t)lr1; - lr2 = *(*src)++; - lr2 = (int16_t)lr2; - break; - case 0: - default: - /* mono = (L+R)/2 */ - lr1 = *(*src)++; - lr1 = (int16_t)lr1 + (lr1 >> 16) + err; - err = lr1 & 1; - lr1 >>= 1; - - lr2 = *(*src)++; - lr2 = (int16_t)lr2 + (lr2 >> 16) + err; - err = lr2 & 1; - lr2 >>= 1; - break; - } - *(*dst)++ = htobe32((lr1 << 16) | (uint16_t)lr2); -} /* sample_to_mono */ - -STATICIRAM void chunk_to_aiff_format(uint32_t *src, uint32_t *dst) ICODE_ATTR; -STATICIRAM void chunk_to_aiff_format(uint32_t *src, uint32_t *dst) -{ - if (num_channels == 1) - { - /* On big endian: - * |LLLLLLLLllllllll|RRRRRRRRrrrrrrrr| - * |LLLLLLLLllllllll|RRRRRRRRrrrrrrrr| => - * |MMMMMMMMmmmmmmmm|MMMMMMMMmmmmmmmm| - * - * On little endian: - * |llllllllLLLLLLLL|rrrrrrrrRRRRRRRR| - * |llllllllLLLLLLLL|rrrrrrrrRRRRRRRR| => - * |MMMMMMMMmmmmmmmm|MMMMMMMMmmmmmmmm| - */ - uint32_t *src_end = src + PCM_SAMP_PER_CHUNK; - - do - { - sample_to_mono(&src, &dst); - sample_to_mono(&src, &dst); - sample_to_mono(&src, &dst); - sample_to_mono(&src, &dst); - sample_to_mono(&src, &dst); - sample_to_mono(&src, &dst); - sample_to_mono(&src, &dst); - sample_to_mono(&src, &dst); - } - while (src < src_end); - } - else - { -#ifdef ROCKBOX_BIG_ENDIAN - /* |LLLLLLLLllllllll|RRRRRRRRrrrrrrrr| => - * |LLLLLLLLllllllll|RRRRRRRRrrrrrrrr| - */ - ci->memcpy(dst, src, PCM_CHUNK_SIZE); -#else - /* |llllllllLLLLLLLL|rrrrrrrrRRRRRRRR| => - * |LLLLLLLLllllllll|RRRRRRRRrrrrrrrr| - */ - uint32_t *src_end = src + PCM_SAMP_PER_CHUNK; - - do - { - *dst++ = swap_odd_even32(*src++); - *dst++ = swap_odd_even32(*src++); - *dst++ = swap_odd_even32(*src++); - *dst++ = swap_odd_even32(*src++); - *dst++ = swap_odd_even32(*src++); - *dst++ = swap_odd_even32(*src++); - *dst++ = swap_odd_even32(*src++); - *dst++ = swap_odd_even32(*src++); - } - while (src < src_end); -#endif - } -} /* chunk_to_aiff_format */ - -static bool init_encoder(void) -{ - struct enc_inputs inputs; - struct enc_parameters params; - - if (ci->enc_get_inputs == NULL || - ci->enc_set_parameters == NULL || - ci->enc_get_chunk == NULL || - ci->enc_finish_chunk == NULL || - ci->enc_get_pcm_data == NULL ) - return false; - - ci->enc_get_inputs(&inputs); - - if (inputs.config->afmt != AFMT_AIFF) - return false; - - sample_rate = inputs.sample_rate; - num_channels = inputs.num_channels; - rec_mono_mode = inputs.rec_mono_mode; - err = 0; - - /* configure the buffer system */ - params.afmt = AFMT_AIFF; - enc_size = PCM_CHUNK_SIZE*inputs.num_channels / 2; - params.chunk_size = enc_size; - params.enc_sample_rate = sample_rate; - params.reserve_bytes = 0; - params.events_callback = enc_events_callback; - ci->enc_set_parameters(¶ms); - - return true; -} /* init_encoder */ - -/* this is the codec entry point */ -enum codec_status codec_main(enum codec_entry_call_reason reason) -{ - if (reason == CODEC_LOAD) { - if (!init_encoder()) - return CODEC_ERROR; - } - else if (reason == CODEC_UNLOAD) { - /* reset parameters to initial state */ - ci->enc_set_parameters(NULL); - } - - return CODEC_OK; -} - -/* this is called for each file to process */ -enum codec_status codec_run(void) -{ - /* main encoding loop */ - while (ci->get_command(NULL) != CODEC_ACTION_HALT) - { - uint32_t *src = (uint32_t *)ci->enc_get_pcm_data(PCM_CHUNK_SIZE); - struct enc_chunk_hdr *chunk; - - if (src == NULL) - continue; - - chunk = ci->enc_get_chunk(); - chunk->enc_size = enc_size; - chunk->num_pcm = PCM_SAMP_PER_CHUNK; - chunk->enc_data = ENC_CHUNK_SKIP_HDR(chunk->enc_data, chunk); - - chunk_to_aiff_format(src, (uint32_t *)chunk->enc_data); - - ci->enc_finish_chunk(); - } - - return CODEC_OK; -} diff --git a/apps/codecs/alac.c b/apps/codecs/alac.c deleted file mode 100644 index 144d796e5f..0000000000 --- a/apps/codecs/alac.c +++ /dev/null @@ -1,146 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2005 Dave Chapman - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ - -#include "codeclib.h" -#include "libm4a/m4a.h" -#include "libalac/decomp.h" - -CODEC_HEADER - -/* The maximum buffer size handled. This amount of bytes is buffered for each - * frame. */ -#define ALAC_BYTE_BUFFER_SIZE 32768 - -static int32_t outputbuffer[ALAC_MAX_CHANNELS][ALAC_BLOCKSIZE] IBSS_ATTR; - -/* this is the codec entry point */ -enum codec_status codec_main(enum codec_entry_call_reason reason) -{ - if (reason == CODEC_LOAD) { - /* Generic codec initialisation */ - ci->configure(DSP_SET_STEREO_MODE, STEREO_NONINTERLEAVED); - ci->configure(DSP_SET_SAMPLE_DEPTH, ALAC_OUTPUT_DEPTH-1); - } - - return CODEC_OK; -} - -/* this is called for each file to process */ -enum codec_status codec_run(void) -{ - size_t n; - demux_res_t demux_res; - stream_t input_stream; - uint32_t samplesdone; - uint32_t elapsedtime = 0; - int samplesdecoded; - unsigned int i; - unsigned char* buffer; - alac_file alac; - intptr_t param; - - /* Clean and initialize decoder structures */ - memset(&demux_res , 0, sizeof(demux_res)); - if (codec_init()) { - LOGF("ALAC: Error initialising codec\n"); - return CODEC_ERROR; - } - - ci->configure(DSP_SWITCH_FREQUENCY, ci->id3->frequency); - codec_set_replaygain(ci->id3); - - ci->seek_buffer(0); - - stream_create(&input_stream,ci); - - /* Read from ci->id3->offset before calling qtmovie_read. */ - samplesdone = (uint32_t)(((uint64_t)(ci->id3->offset) * ci->id3->frequency) / - (ci->id3->bitrate*128)); - - /* if qtmovie_read returns successfully, the stream is up to - * the movie data, which can be used directly by the decoder */ - if (!qtmovie_read(&input_stream, &demux_res)) { - LOGF("ALAC: Error initialising file\n"); - return CODEC_ERROR; - } - - /* initialise the sound converter */ - alac_set_info(&alac, demux_res.codecdata); - - /* Set i for first frame, seek to desired sample position for resuming. */ - i=0; - if (samplesdone > 0) { - if (m4a_seek(&demux_res, &input_stream, samplesdone, - &samplesdone, (int*) &i)) { - elapsedtime = (samplesdone * 10) / (ci->id3->frequency / 100); - ci->set_elapsed(elapsedtime); - } else { - samplesdone = 0; - } - } - - ci->set_elapsed(elapsedtime); - - /* The main decoding loop */ - while (i < demux_res.num_sample_byte_sizes) { - enum codec_command_action action = ci->get_command(¶m); - - if (action == CODEC_ACTION_HALT) - break; - - /* Request the required number of bytes from the input buffer */ - buffer=ci->request_buffer(&n, ALAC_BYTE_BUFFER_SIZE); - - /* Deal with any pending seek requests */ - if (action == CODEC_ACTION_SEEK_TIME) { - if (m4a_seek(&demux_res, &input_stream, - (param/10) * (ci->id3->frequency/100), - &samplesdone, (int *)&i)) { - elapsedtime=(samplesdone*10)/(ci->id3->frequency/100); - } - ci->set_elapsed(elapsedtime); - ci->seek_complete(); - } - - /* Request the required number of bytes from the input buffer */ - buffer=ci->request_buffer(&n, ALAC_BYTE_BUFFER_SIZE); - - /* Decode one block - returned samples will be host-endian */ - samplesdecoded=alac_decode_frame(&alac, buffer, outputbuffer, ci->yield); - ci->yield(); - - /* Advance codec buffer by amount of consumed bytes */ - ci->advance_buffer(alac.bytes_consumed); - - /* Output the audio */ - ci->pcmbuf_insert(outputbuffer[0], outputbuffer[1], samplesdecoded); - - /* Update the elapsed-time indicator */ - samplesdone+=samplesdecoded; - elapsedtime=(samplesdone*10)/(ci->id3->frequency/100); - ci->set_elapsed(elapsedtime); - - i++; - } - - LOGF("ALAC: Decoded %lu samples\n",(unsigned long)samplesdone); - return CODEC_OK; -} diff --git a/apps/codecs/ape.c b/apps/codecs/ape.c deleted file mode 100644 index ed6ea21685..0000000000 --- a/apps/codecs/ape.c +++ /dev/null @@ -1,330 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2007 Dave Chapman - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ - -#include "codeclib.h" -#include - -CODEC_HEADER - -#define BLOCKS_PER_LOOP 1024 -#define MAX_CHANNELS 2 -#define MAX_BYTESPERSAMPLE 3 - -/* Monkey's Audio files have one seekpoint per frame. The framesize - varies between 73728 and 1179648 samples. - - At the smallest framesize, 30000 frames would be 50155 seconds of - audio - almost 14 hours. This should be enough for any file a user - would want to play in Rockbox, given the 2GB FAT filesize (and 4GB - seektable entry size) limit. - - This means the seektable is 120000 bytes, but we have a lot of - spare room in the codec buffer - the APE codec itself is small. -*/ - -#define MAX_SEEKPOINTS 30000 -static uint32_t seektablebuf[MAX_SEEKPOINTS]; - -#define INPUT_CHUNKSIZE (32*1024) - -/* 1024*4 = 4096 bytes per channel */ -static int32_t decoded0[BLOCKS_PER_LOOP] IBSS_ATTR; -static int32_t decoded1[BLOCKS_PER_LOOP] IBSS_ATTR; - -#define MAX_SUPPORTED_SEEKTABLE_SIZE 5000 - - -/* Given an ape_ctx and a sample to seek to, return the file position - to the frame containing that sample, and the number of samples to - skip in that frame. -*/ - -static bool ape_calc_seekpos(struct ape_ctx_t* ape_ctx, - uint32_t new_sample, - uint32_t* newframe, - uint32_t* filepos, - uint32_t* samplestoskip) -{ - uint32_t n; - - n = new_sample / ape_ctx->blocksperframe; - if (n >= ape_ctx->numseekpoints) - { - /* We don't have a seekpoint for that frame */ - return false; - } - - *newframe = n; - *filepos = ape_ctx->seektable[n]; - *samplestoskip = new_sample - (n * ape_ctx->blocksperframe); - - return true; -} - -/* The resume offset is a value in bytes - we need to - turn it into a frame number and samplestoskip value */ - -static void ape_resume(struct ape_ctx_t* ape_ctx, size_t resume_offset, - uint32_t* currentframe, uint32_t* samplesdone, - uint32_t* samplestoskip, int* firstbyte) -{ - off_t newfilepos; - int64_t framesize; - int64_t offset; - - *currentframe = 0; - *samplesdone = 0; - *samplestoskip = 0; - - while ((*currentframe < ape_ctx->totalframes) && - (*currentframe < ape_ctx->numseekpoints) && - (resume_offset > ape_ctx->seektable[*currentframe])) - { - ++*currentframe; - *samplesdone += ape_ctx->blocksperframe; - } - - if ((*currentframe > 0) && - (ape_ctx->seektable[*currentframe] > resume_offset)) { - --*currentframe; - *samplesdone -= ape_ctx->blocksperframe; - } - - newfilepos = ape_ctx->seektable[*currentframe]; - - /* APE's bytestream is weird... */ - *firstbyte = 3 - (newfilepos & 3); - newfilepos &= ~3; - - ci->seek_buffer(newfilepos); - - /* We estimate where we were in the current frame, based on the - byte offset */ - if (*currentframe < (ape_ctx->totalframes - 1)) { - framesize = ape_ctx->seektable[*currentframe+1] - ape_ctx->seektable[*currentframe]; - offset = resume_offset - ape_ctx->seektable[*currentframe]; - - *samplestoskip = (offset * ape_ctx->blocksperframe) / framesize; - } -} - -/* this is the codec entry point */ -enum codec_status codec_main(enum codec_entry_call_reason reason) -{ - if (reason == CODEC_LOAD) { - /* Generic codec initialisation */ - ci->configure(DSP_SET_SAMPLE_DEPTH, APE_OUTPUT_DEPTH-1); - } - - return CODEC_OK; -} - -/* this is called for each file to process */ -enum codec_status codec_run(void) -{ - struct ape_ctx_t ape_ctx; - uint32_t samplesdone; - uint32_t elapsedtime; - size_t bytesleft; - - uint32_t currentframe; - uint32_t newfilepos; - uint32_t samplestoskip; - int nblocks; - int bytesconsumed; - unsigned char* inbuffer; - uint32_t blockstodecode; - int res; - int firstbyte; - size_t resume_offset; - intptr_t param; - - if (codec_init()) { - LOGF("APE: Error initialising codec\n"); - return CODEC_ERROR; - } - - /* Remember the resume position - when the codec is opened, the - playback engine will reset it. */ - resume_offset = ci->id3->offset; - - ci->seek_buffer(0); - inbuffer = ci->request_buffer(&bytesleft, INPUT_CHUNKSIZE); - - /* Read the file headers to populate the ape_ctx struct */ - if (ape_parseheaderbuf(inbuffer,&ape_ctx) < 0) { - LOGF("APE: Error reading header\n"); - return CODEC_ERROR; - } - - /* Initialise the seektable for this file */ - ape_ctx.seektable = seektablebuf; - ape_ctx.numseekpoints = MIN(MAX_SEEKPOINTS,ape_ctx.numseekpoints); - - ci->advance_buffer(ape_ctx.seektablefilepos); - - /* The seektable may be bigger than the guard buffer (32KB), so we - do a read() */ - ci->read_filebuf(ape_ctx.seektable, ape_ctx.numseekpoints * sizeof(uint32_t)); - -#ifdef ROCKBOX_BIG_ENDIAN - /* Byte-swap the little-endian seekpoints */ - { - uint32_t i; - - for(i = 0; i < ape_ctx.numseekpoints; i++) - ape_ctx.seektable[i] = swap32(ape_ctx.seektable[i]); - } -#endif - - /* Now advance the file position to the first frame */ - ci->advance_buffer(ape_ctx.firstframe - - (ape_ctx.seektablefilepos + - ape_ctx.numseekpoints * sizeof(uint32_t))); - - ci->configure(DSP_SWITCH_FREQUENCY, ape_ctx.samplerate); - ci->configure(DSP_SET_STEREO_MODE, ape_ctx.channels == 1 ? - STEREO_MONO : STEREO_NONINTERLEAVED); - codec_set_replaygain(ci->id3); - - /* The main decoding loop */ - - if (resume_offset) { - /* The resume offset is a value in bytes - we need to - turn it into a frame number and samplestoskip value */ - - ape_resume(&ape_ctx, resume_offset, - ¤tframe, &samplesdone, &samplestoskip, &firstbyte); - } else { - currentframe = 0; - samplesdone = 0; - samplestoskip = 0; - firstbyte = 3; /* Take account of the little-endian 32-bit byte ordering */ - } - - elapsedtime = (samplesdone*10)/(ape_ctx.samplerate/100); - ci->set_elapsed(elapsedtime); - - /* Initialise the buffer */ - inbuffer = ci->request_buffer(&bytesleft, INPUT_CHUNKSIZE); - - /* The main decoding loop - we decode the frames a small chunk at a time */ - while (currentframe < ape_ctx.totalframes) - { -frame_start: - /* Calculate how many blocks there are in this frame */ - if (currentframe == (ape_ctx.totalframes - 1)) - nblocks = ape_ctx.finalframeblocks; - else - nblocks = ape_ctx.blocksperframe; - - ape_ctx.currentframeblocks = nblocks; - - /* Initialise the frame decoder */ - init_frame_decoder(&ape_ctx, inbuffer, &firstbyte, &bytesconsumed); - - ci->advance_buffer(bytesconsumed); - inbuffer = ci->request_buffer(&bytesleft, INPUT_CHUNKSIZE); - - /* Decode the frame a chunk at a time */ - while (nblocks > 0) - { - enum codec_command_action action = ci->get_command(¶m); - - if (action == CODEC_ACTION_HALT) - goto done; - - /* Deal with any pending seek requests */ - if (action == CODEC_ACTION_SEEK_TIME) - { - if (ape_calc_seekpos(&ape_ctx, - (param/10) * (ci->id3->frequency/100), - ¤tframe, - &newfilepos, - &samplestoskip)) - { - samplesdone = currentframe * ape_ctx.blocksperframe; - - /* APE's bytestream is weird... */ - firstbyte = 3 - (newfilepos & 3); - newfilepos &= ~3; - - ci->seek_buffer(newfilepos); - inbuffer = ci->request_buffer(&bytesleft, INPUT_CHUNKSIZE); - - elapsedtime = (samplesdone*10)/(ape_ctx.samplerate/100); - ci->set_elapsed(elapsedtime); - ci->seek_complete(); - goto frame_start; /* Sorry... */ - } - - ci->seek_complete(); - } - - blockstodecode = MIN(BLOCKS_PER_LOOP, nblocks); - - if ((res = decode_chunk(&ape_ctx, inbuffer, &firstbyte, - &bytesconsumed, - decoded0, decoded1, - blockstodecode)) < 0) - { - /* Frame decoding error, abort */ - LOGF("APE: Frame %lu, error %d\n",(unsigned long)currentframe,res); - return CODEC_ERROR; - } - - ci->yield(); - - if (samplestoskip > 0) { - if (samplestoskip < blockstodecode) { - ci->pcmbuf_insert(decoded0 + samplestoskip, - decoded1 + samplestoskip, - blockstodecode - samplestoskip); - samplestoskip = 0; - } else { - samplestoskip -= blockstodecode; - } - } else { - ci->pcmbuf_insert(decoded0, decoded1, blockstodecode); - } - - samplesdone += blockstodecode; - - if (!samplestoskip) { - /* Update the elapsed-time indicator */ - elapsedtime = (samplesdone*10)/(ape_ctx.samplerate/100); - ci->set_elapsed(elapsedtime); - } - - ci->advance_buffer(bytesconsumed); - inbuffer = ci->request_buffer(&bytesleft, INPUT_CHUNKSIZE); - - /* Decrement the block count */ - nblocks -= blockstodecode; - } - - currentframe++; - } - -done: - LOGF("APE: Decoded %lu samples\n",(unsigned long)samplesdone); - return CODEC_OK; -} diff --git a/apps/codecs/asap.c b/apps/codecs/asap.c deleted file mode 100644 index 19b39a44c4..0000000000 --- a/apps/codecs/asap.c +++ /dev/null @@ -1,140 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2008 Dominik Wenger - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ - -#include "codeclib.h" -#include "libasap/asap.h" - -CODEC_HEADER - -#define CHUNK_SIZE (1024*2) - -static byte samples[CHUNK_SIZE] IBSS_ATTR; /* The sample buffer */ -static ASAP_State asap IBSS_ATTR; /* asap codec state */ - -/* this is the codec entry point */ -enum codec_status codec_main(enum codec_entry_call_reason reason) -{ - /* Nothing to do */ - return CODEC_OK; - (void)reason; -} - -/* this is called for each file to process */ -enum codec_status codec_run(void) -{ - int n_bytes; - int song; - int duration; - char* module; - int bytesPerSample =2; - intptr_t param; - - if (codec_init()) { - DEBUGF("codec init failed\n"); - return CODEC_ERROR; - } - - codec_set_replaygain(ci->id3); - - int bytes_done =0; - size_t filesize; - ci->seek_buffer(0); - module = ci->request_buffer(&filesize, ci->filesize); - if (!module || (size_t)filesize < (size_t)ci->filesize) - { - DEBUGF("loading error\n"); - return CODEC_ERROR; - } - - /*Init ASAP */ - if (!ASAP_Load(&asap, ci->id3->path, module, filesize)) - { - DEBUGF("%s: format not supported",ci->id3->path); - return CODEC_ERROR; - } - - /* Make use of 44.1khz */ - ci->configure(DSP_SET_FREQUENCY, 44100); - /* Sample depth is 16 bit little endian */ - ci->configure(DSP_SET_SAMPLE_DEPTH, 16); - /* Stereo or Mono output ? */ - if(asap.module_info->channels ==1) - { - ci->configure(DSP_SET_STEREO_MODE, STEREO_MONO); - bytesPerSample = 2; - } - else - { - ci->configure(DSP_SET_STEREO_MODE, STEREO_INTERLEAVED); - bytesPerSample = 4; - } - /* reset eleapsed */ - ci->set_elapsed(0); - - song = asap.module_info->default_song; - duration = asap.module_info->durations[song]; - if (duration < 0) - duration = 180 * 1000; - - /* set id3 length, because metadata parse might not have done it */ - ci->id3->length = duration; - - ASAP_PlaySong(&asap, song, duration); - ASAP_MutePokeyChannels(&asap, 0); - - /* The main decoder loop */ - while (1) { - enum codec_command_action action = ci->get_command(¶m); - - if (action == CODEC_ACTION_HALT) - break; - - if (action == CODEC_ACTION_SEEK_TIME) { - /* New time is ready in param */ - - /* seek to pos */ - ASAP_Seek(&asap,param); - /* update bytes_done */ - bytes_done = param*44.1*2; - /* update elapsed */ - ci->set_elapsed((bytes_done / 2) / 44.1); - /* seek ready */ - ci->seek_complete(); - } - - /* Generate a buffer full of Audio */ - #ifdef ROCKBOX_LITTLE_ENDIAN - n_bytes = ASAP_Generate(&asap, samples, sizeof(samples), ASAP_FORMAT_S16_LE); - #else - n_bytes = ASAP_Generate(&asap, samples, sizeof(samples), ASAP_FORMAT_S16_BE); - #endif - - ci->pcmbuf_insert(samples, NULL, n_bytes /bytesPerSample); - - bytes_done += n_bytes; - ci->set_elapsed((bytes_done / 2) / 44.1); - - if(n_bytes != sizeof(samples)) - break; - } - - return CODEC_OK; -} diff --git a/apps/codecs/atrac3_oma.c b/apps/codecs/atrac3_oma.c deleted file mode 100644 index 50f7c8f163..0000000000 --- a/apps/codecs/atrac3_oma.c +++ /dev/null @@ -1,153 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2009 Mohamed Tarek - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ - -#include - -#include "logf.h" -#include "codeclib.h" -#include "inttypes.h" -#include "libatrac/atrac3.h" - -CODEC_HEADER - -#define FRAMESIZE ci->id3->bytesperframe -#define BITRATE ci->id3->bitrate - -static ATRAC3Context q IBSS_ATTR; - -/* this is the codec entry point */ -enum codec_status codec_main(enum codec_entry_call_reason reason) -{ - /* Nothing to do */ - return CODEC_OK; - (void)reason; -} - -/* this is called for each file to process */ -enum codec_status codec_run(void) -{ - static size_t buff_size; - int datasize, res, frame_counter, total_frames, seek_frame_offset; - uint8_t *bit_buffer; - int elapsed = 0; - size_t resume_offset; - intptr_t param; - enum codec_command_action action = CODEC_ACTION_NULL; - - if (codec_init()) { - DEBUGF("codec init failed\n"); - return CODEC_ERROR; - } - - resume_offset = ci->id3->offset; - - codec_set_replaygain(ci->id3); - ci->memset(&q,0,sizeof(ATRAC3Context)); - - ci->configure(DSP_SET_FREQUENCY, ci->id3->frequency); - ci->configure(DSP_SET_SAMPLE_DEPTH, 17); /* Remark: atrac3 uses s15.0 by default, s15.2 was hacked. */ - ci->configure(DSP_SET_STEREO_MODE, ci->id3->channels == 1 ? - STEREO_MONO : STEREO_NONINTERLEAVED); - - ci->seek_buffer(0); - - res = atrac3_decode_init(&q, ci->id3); - if(res < 0) { - DEBUGF("failed to initialize OMA atrac decoder\n"); - return CODEC_ERROR; - } - - total_frames = (ci->id3->filesize - ci->id3->first_frame_offset) / FRAMESIZE; - frame_counter = 0; - - /* check for a mid-track resume and force a seek time accordingly */ - if(resume_offset > ci->id3->first_frame_offset) { - resume_offset -= ci->id3->first_frame_offset; - /* calculate resume_offset in frames */ - resume_offset = (int)resume_offset / FRAMESIZE; - param = (int)resume_offset * ((FRAMESIZE * 8)/BITRATE); - action = CODEC_ACTION_SEEK_TIME; - } - else { - ci->set_elapsed(0); - ci->seek_buffer(ci->id3->first_frame_offset); - } - - /* The main decoder loop */ - while(frame_counter < total_frames) - { - if (action == CODEC_ACTION_NULL) - action = ci->get_command(¶m); - - if (action == CODEC_ACTION_HALT) - break; - - bit_buffer = (uint8_t *) ci->request_buffer(&buff_size, FRAMESIZE); - - if (action == CODEC_ACTION_SEEK_TIME) { - /* Do not allow seeking beyond the file's length */ - if ((unsigned) param > ci->id3->length) { - ci->set_elapsed(ci->id3->length); - ci->seek_complete(); - break; - } - - /* Seek to the start of the track */ - if (param == 0) { - elapsed = 0; - ci->set_elapsed(0); - ci->seek_buffer(ci->id3->first_frame_offset); - ci->seek_complete(); - action = CODEC_ACTION_NULL; - continue; - } - - seek_frame_offset = (param * BITRATE) / (8 * FRAMESIZE); - frame_counter = seek_frame_offset; - ci->seek_buffer(ci->id3->first_frame_offset + seek_frame_offset* FRAMESIZE); - bit_buffer = (uint8_t *) ci->request_buffer(&buff_size, FRAMESIZE); - elapsed = param; - ci->set_elapsed(elapsed); - ci->seek_complete(); - } - - action = CODEC_ACTION_NULL; - - res = atrac3_decode_frame(FRAMESIZE, &q, &datasize, bit_buffer, FRAMESIZE); - - if(res != (int)FRAMESIZE) { - DEBUGF("codec error\n"); - return CODEC_ERROR; - } - - if(datasize) - ci->pcmbuf_insert(q.outSamples, q.outSamples + 1024, - q.samples_per_frame / ci->id3->channels); - - elapsed += (FRAMESIZE * 8) / BITRATE; - ci->set_elapsed(elapsed); - - ci->advance_buffer(FRAMESIZE); - frame_counter++; - } - - return CODEC_OK; -} diff --git a/apps/codecs/atrac3_rm.c b/apps/codecs/atrac3_rm.c deleted file mode 100644 index 997507425e..0000000000 --- a/apps/codecs/atrac3_rm.c +++ /dev/null @@ -1,215 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2009 Mohamed Tarek - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ - -#include - -#include "logf.h" -#include "codeclib.h" -#include "inttypes.h" -#include "libatrac/atrac3.h" - -CODEC_HEADER - -static RMContext rmctx IBSS_ATTR_LARGE_IRAM; -static RMPacket pkt IBSS_ATTR_LARGE_IRAM; -static ATRAC3Context q IBSS_ATTR; - -static void init_rm(RMContext *rmctx) -{ - /* initialize the RMContext */ - memcpy(rmctx, (void*)(( (intptr_t)ci->id3->id3v2buf + 3 ) &~ 3), sizeof(RMContext)); - - /* and atrac3 expects extadata in id3v2buf, so we shall give it that */ - memcpy(ci->id3->id3v2buf, (char*)rmctx->codec_extradata, rmctx->extradata_size*sizeof(char)); -} - -/* this is the codec entry point */ -enum codec_status codec_main(enum codec_entry_call_reason reason) -{ - /* Nothing to do */ - return CODEC_OK; - (void)reason; -} - -/* this is called for each file to process */ -enum codec_status codec_run(void) -{ - static size_t buff_size; - int datasize, res, consumed, i, time_offset; - uint8_t *bit_buffer; - uint16_t fs,sps,h; - uint32_t packet_count; - int scrambling_unit_size, num_units, elapsed = 0; - int playback_on = -1; - size_t resume_offset; - intptr_t param; - enum codec_command_action action = CODEC_ACTION_NULL; - - if (codec_init()) { - DEBUGF("codec init failed\n"); - return CODEC_ERROR; - } - - resume_offset = ci->id3->offset; - - codec_set_replaygain(ci->id3); - ci->memset(&rmctx,0,sizeof(RMContext)); - ci->memset(&pkt,0,sizeof(RMPacket)); - ci->memset(&q,0,sizeof(ATRAC3Context)); - - ci->seek_buffer(0); - init_rm(&rmctx); - - ci->configure(DSP_SET_FREQUENCY, ci->id3->frequency); - ci->configure(DSP_SET_SAMPLE_DEPTH, 17); /* Remark: atrac3 uses s15.0 by default, s15.2 was hacked. */ - ci->configure(DSP_SET_STEREO_MODE, rmctx.nb_channels == 1 ? - STEREO_MONO : STEREO_NONINTERLEAVED); - - packet_count = rmctx.nb_packets; - rmctx.audio_framesize = rmctx.block_align; - rmctx.block_align = rmctx.sub_packet_size; - fs = rmctx.audio_framesize; - sps= rmctx.block_align; - h = rmctx.sub_packet_h; - scrambling_unit_size = h * (fs + PACKET_HEADER_SIZE); - - res = atrac3_decode_init(&q, ci->id3); - if(res < 0) { - DEBUGF("failed to initialize RM atrac decoder\n"); - return CODEC_ERROR; - } - - /* check for a mid-track resume and force a seek time accordingly */ - if(resume_offset > rmctx.data_offset + DATA_HEADER_SIZE) { - resume_offset -= rmctx.data_offset + DATA_HEADER_SIZE; - num_units = (int)resume_offset / scrambling_unit_size; - /* put number of subpackets to skip in resume_offset */ - resume_offset /= (sps + PACKET_HEADER_SIZE); - param = (int)resume_offset * ((sps * 8 * 1000)/rmctx.bit_rate); - action = CODEC_ACTION_SEEK_TIME; - } - else { - ci->set_elapsed(0); - } - - ci->advance_buffer(rmctx.data_offset + DATA_HEADER_SIZE); - - /* The main decoder loop */ -seek_start : - while((unsigned)elapsed < rmctx.duration) - { - bit_buffer = (uint8_t *) ci->request_buffer(&buff_size, scrambling_unit_size); - consumed = rm_get_packet(&bit_buffer, &rmctx, &pkt); - if(consumed < 0 && playback_on != 0) { - if(playback_on == -1) { - /* Error only if packet-parsing failed and playback hadn't started */ - DEBUGF("rm_get_packet failed\n"); - return CODEC_ERROR; - } - else - return CODEC_OK; - } - - for(i = 0; i < rmctx.audio_pkt_cnt*(fs/sps) ; i++) - { - if (action == CODEC_ACTION_NULL) - action = ci->get_command(¶m); - - if (action == CODEC_ACTION_HALT) - return CODEC_OK; - - if (action == CODEC_ACTION_SEEK_TIME) { - /* Do not allow seeking beyond the file's length */ - if ((unsigned) param > ci->id3->length) { - ci->set_elapsed(ci->id3->length); - ci->seek_complete(); - return CODEC_OK; - } - - ci->seek_buffer(rmctx.data_offset + DATA_HEADER_SIZE); - packet_count = rmctx.nb_packets; - rmctx.audio_pkt_cnt = 0; - rmctx.frame_number = 0; - - /* Seek to the start of the track */ - if (param == 0) { - ci->set_elapsed(0); - ci->seek_complete(); - action = CODEC_ACTION_NULL; - goto seek_start; - } - num_units = (param/(sps*1000*8/rmctx.bit_rate))/(h*(fs/sps)); - ci->seek_buffer(rmctx.data_offset + DATA_HEADER_SIZE + consumed * num_units); - bit_buffer = (uint8_t *) ci->request_buffer(&buff_size, scrambling_unit_size); - consumed = rm_get_packet(&bit_buffer, &rmctx, &pkt); - if(consumed < 0 && playback_on != 0) { - if(playback_on == -1) { - /* Error only if packet-parsing failed and playback hadn't started */ - DEBUGF("rm_get_packet failed\n"); - return CODEC_ERROR; - } - else - return CODEC_OK; - } - - packet_count = rmctx.nb_packets - rmctx.audio_pkt_cnt * num_units; - rmctx.frame_number = (param/(sps*1000*8/rmctx.bit_rate)); - while(rmctx.audiotimestamp > (unsigned) param) { - rmctx.audio_pkt_cnt = 0; - ci->seek_buffer(rmctx.data_offset + DATA_HEADER_SIZE + consumed * (num_units-1)); - bit_buffer = (uint8_t *) ci->request_buffer(&buff_size, scrambling_unit_size); - consumed = rm_get_packet(&bit_buffer, &rmctx, &pkt); - packet_count += rmctx.audio_pkt_cnt; - num_units--; - } - time_offset = param - rmctx.audiotimestamp; - i = (time_offset/((sps * 8 * 1000)/rmctx.bit_rate)); - elapsed = rmctx.audiotimestamp+(1000*8*sps/rmctx.bit_rate)*i; - ci->set_elapsed(elapsed); - ci->seek_complete(); - } - - action = CODEC_ACTION_NULL; - - if(pkt.length) - res = atrac3_decode_frame(rmctx.block_align, &q, &datasize, pkt.frames[i], rmctx.block_align); - else /* indicates that there are no remaining frames */ - return CODEC_OK; - - if(res != rmctx.block_align) { - DEBUGF("codec error\n"); - return CODEC_ERROR; - } - - if(datasize) - ci->pcmbuf_insert(q.outSamples, q.outSamples + 1024, q.samples_per_frame / rmctx.nb_channels); - playback_on = 1; - elapsed = rmctx.audiotimestamp+(1000*8*sps/rmctx.bit_rate)*i; - ci->set_elapsed(elapsed); - rmctx.frame_number++; - } - packet_count -= rmctx.audio_pkt_cnt; - rmctx.audio_pkt_cnt = 0; - ci->advance_buffer(consumed); - } - - return CODEC_OK; -} diff --git a/apps/codecs/au.c b/apps/codecs/au.c deleted file mode 100644 index cb75c7423d..0000000000 --- a/apps/codecs/au.c +++ /dev/null @@ -1,314 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2010 Yoshihisa Uchida - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ - -#include "codeclib.h" -#include "codecs/libpcm/support_formats.h" - -CODEC_HEADER - -/* Sun Audio file (Au file format) codec - * - * References - * [1] Sun Microsystems, Inc., Header file for Audio, .au, 1992 - * URL http://www.opengroup.org/public/pubs/external/auformat.html - * [2] Wikipedia, Au file format, URL: http://en.wikipedia.org/wiki/Sun_Audio - */ - -#define PCM_SAMPLE_SIZE (1024*2) - -static int32_t samples[PCM_SAMPLE_SIZE] IBSS_ATTR; - -enum -{ - AU_FORMAT_UNSUPPORT = 0, /* unsupported format */ - AU_FORMAT_MULAW, /* G.711 MULAW */ - AU_FORMAT_PCM, /* Linear PCM */ - AU_FORMAT_IEEE_FLOAT, /* IEEE float */ - AU_FORMAT_ALAW, /* G.711 ALAW */ -}; - -static const char support_formats[9][2] = { - { AU_FORMAT_UNSUPPORT, 0 }, /* encoding */ - { AU_FORMAT_MULAW, 8 }, /* 1: G.711 MULAW */ - { AU_FORMAT_PCM, 8 }, /* 2: Linear PCM 8bit (signed) */ - { AU_FORMAT_PCM, 16 }, /* 3: Linear PCM 16bit (signed, big endian) */ - { AU_FORMAT_PCM, 24 }, /* 4: Linear PCM 24bit (signed, big endian) */ - { AU_FORMAT_PCM, 32 }, /* 5: Linear PCM 32bit (signed, big endian) */ - { AU_FORMAT_IEEE_FLOAT, 32 }, /* 6: Linear PCM float 32bit (signed, big endian) */ - { AU_FORMAT_IEEE_FLOAT, 64 }, /* 7: Linear PCM float 64bit (signed, big endian) */ - /* encoding 8 - 26 unsupported. */ - { AU_FORMAT_ALAW, 8 }, /* 27: G.711 ALAW */ -}; - -static const struct pcm_entry au_codecs[] = { - { AU_FORMAT_MULAW, get_itut_g711_mulaw_codec }, - { AU_FORMAT_PCM, get_linear_pcm_codec }, - { AU_FORMAT_IEEE_FLOAT, get_ieee_float_codec }, - { AU_FORMAT_ALAW, get_itut_g711_alaw_codec }, -}; - -#define NUM_FORMATS 4 - -static const struct pcm_codec *get_au_codec(uint32_t formattag) -{ - int i; - - for (i = 0; i < NUM_FORMATS; i++) - { - if (au_codecs[i].format_tag == formattag) - { - if (au_codecs[i].get_codec) - return au_codecs[i].get_codec(); - return 0; - } - } - return 0; -} - -static unsigned int get_be32(uint8_t *buf) -{ - return (buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3]; -} - -static int convert_au_format(unsigned int encoding, struct pcm_format *fmt) -{ - fmt->formattag = AU_FORMAT_UNSUPPORT; - if (encoding < 8) - { - fmt->formattag = support_formats[encoding][0]; - fmt->bitspersample = support_formats[encoding][1]; - } - else if (encoding == 27) - { - fmt->formattag = support_formats[8][0]; - fmt->bitspersample = support_formats[8][1]; - } - - return fmt->formattag; -} - -/* this is the codec entry point */ -enum codec_status codec_main(enum codec_entry_call_reason reason) -{ - if (reason == CODEC_LOAD) { - /* Generic codec initialisation */ - ci->configure(DSP_SET_SAMPLE_DEPTH, PCM_OUTPUT_DEPTH-1); - } - - return CODEC_OK; -} - -/* this is called for each file to process */ -enum codec_status codec_run(void) -{ - struct pcm_format format; - uint32_t bytesdone, decodedsamples; - size_t n; - int bufcount; - int endofstream; - unsigned char *buf; - uint8_t *aubuf; - off_t firstblockposn; /* position of the first block in file */ - const struct pcm_codec *codec; - int offset = 0; - intptr_t param; - - if (codec_init()) { - DEBUGF("codec_init() error\n"); - return CODEC_ERROR; - } - - codec_set_replaygain(ci->id3); - - /* Need to save offset for later use (cleared indirectly by advance_buffer) */ - bytesdone = ci->id3->offset; - - ci->memset(&format, 0, sizeof(struct pcm_format)); - format.is_signed = true; - format.is_little_endian = false; - - /* set format */ - ci->seek_buffer(0); - buf = ci->request_buffer(&n, 24); - if (n < 24 || (memcmp(buf, ".snd", 4) != 0)) - { - /* - * headerless sun audio file - * It is decoded under conditions. - * format: G.711 mu-law - * channel: mono - * frequency: 8000 kHz - */ - offset = 0; - format.formattag = AU_FORMAT_MULAW; - format.channels = 1; - format.bitspersample = 8; - format.numbytes = ci->id3->filesize; - } - else - { - /* parse header */ - - /* data offset */ - offset = get_be32(buf + 4); - if (offset < 24) - { - DEBUGF("CODEC_ERROR: sun audio offset size is small: %d\n", offset); - return CODEC_ERROR; - } - /* data size */ - format.numbytes = get_be32(buf + 8); - if (format.numbytes == (uint32_t)0xffffffff) - format.numbytes = ci->id3->filesize - offset; - /* encoding */ - format.formattag = convert_au_format(get_be32(buf + 12), &format); - if (format.formattag == AU_FORMAT_UNSUPPORT) - { - DEBUGF("CODEC_ERROR: sun audio unsupport format: %d\n", get_be32(buf + 12)); - return CODEC_ERROR; - } - /* skip sample rate */ - format.channels = get_be32(buf + 20); - } - - /* advance to first WAVE chunk */ - ci->advance_buffer(offset); - - firstblockposn = offset; - - decodedsamples = 0; - codec = 0; - - /* get codec */ - codec = get_au_codec(format.formattag); - if (!codec) - { - DEBUGF("CODEC_ERROR: unsupport sun audio format: %x\n", (int)format.formattag); - return CODEC_ERROR; - } - - if (!codec->set_format(&format)) - { - return CODEC_ERROR; - } - - if (format.numbytes == 0) { - DEBUGF("CODEC_ERROR: data size is 0\n"); - return CODEC_ERROR; - } - - /* check chunksize */ - if ((format.chunksize / format.blockalign) * format.samplesperblock * format.channels - > PCM_SAMPLE_SIZE) - format.chunksize = (PCM_SAMPLE_SIZE / format.blockalign) * format.blockalign; - if (format.chunksize == 0) - { - DEBUGF("CODEC_ERROR: chunksize is 0\n"); - return CODEC_ERROR; - } - - ci->configure(DSP_SWITCH_FREQUENCY, ci->id3->frequency); - if (format.channels == 2) { - ci->configure(DSP_SET_STEREO_MODE, STEREO_INTERLEAVED); - } else if (format.channels == 1) { - ci->configure(DSP_SET_STEREO_MODE, STEREO_MONO); - } else { - DEBUGF("CODEC_ERROR: more than 2 channels\n"); - return CODEC_ERROR; - } - - /* make sure we're at the correct offset */ - if (bytesdone > (uint32_t) firstblockposn) { - /* Round down to previous block */ - struct pcm_pos *newpos = codec->get_seek_pos(bytesdone - firstblockposn, - PCM_SEEK_POS, NULL); - - if (newpos->pos > format.numbytes) - goto done; - if (ci->seek_buffer(firstblockposn + newpos->pos)) - { - bytesdone = newpos->pos; - decodedsamples = newpos->samples; - } - } else { - /* already where we need to be */ - bytesdone = 0; - } - - ci->set_elapsed(decodedsamples*1000LL/ci->id3->frequency); - - /* The main decoder loop */ - endofstream = 0; - - while (!endofstream) { - enum codec_command_action action = ci->get_command(¶m); - - if (action == CODEC_ACTION_HALT) - break; - - if (action == CODEC_ACTION_SEEK_TIME) { - /* 3rd args(read_buffer) is unnecessary in the format which Sun Audio supports. */ - struct pcm_pos *newpos = codec->get_seek_pos(param, PCM_SEEK_TIME, NULL); - - if (newpos->pos > format.numbytes) - { - ci->set_elapsed(ci->id3->length); - ci->seek_complete(); - break; - } - - if (ci->seek_buffer(firstblockposn + newpos->pos)) - { - bytesdone = newpos->pos; - decodedsamples = newpos->samples; - } - - ci->set_elapsed(decodedsamples*1000LL/ci->id3->frequency); - ci->seek_complete(); - } - - aubuf = (uint8_t *)ci->request_buffer(&n, format.chunksize); - if (n == 0) - break; /* End of stream */ - if (bytesdone + n > format.numbytes) { - n = format.numbytes - bytesdone; - endofstream = 1; - } - - if (codec->decode(aubuf, n, samples, &bufcount) == CODEC_ERROR) - { - DEBUGF("codec error\n"); - return CODEC_ERROR; - } - - ci->pcmbuf_insert(samples, NULL, bufcount); - ci->advance_buffer(n); - bytesdone += n; - decodedsamples += bufcount; - - if (bytesdone >= format.numbytes) - endofstream = 1; - ci->set_elapsed(decodedsamples*1000LL/ci->id3->frequency); - } - -done: - return CODEC_OK; -} diff --git a/apps/codecs/ay.c b/apps/codecs/ay.c deleted file mode 100644 index b11ad84294..0000000000 --- a/apps/codecs/ay.c +++ /dev/null @@ -1,137 +0,0 @@ - -/* Ripped off from Game_Music_Emu 0.5.2. http://www.slack.net/~ant/ */ - -#include -#include "libgme/ay_emu.h" - -CODEC_HEADER - -/* Maximum number of bytes to process in one iteration */ -#define CHUNK_SIZE (1024*2) - -static int16_t samples[CHUNK_SIZE] IBSS_ATTR; -static struct Ay_Emu ay_emu; - -/****************** rockbox interface ******************/ - -static void set_codec_track(int t, int multitrack) { - Ay_start_track(&ay_emu, t); - - /* for loop mode we disable track limits */ - if (!ci->loop_track()) { - Track_set_fade(&ay_emu, Track_get_length( &ay_emu, t ) - 4000, 4000); - } - if (multitrack) ci->set_elapsed(t*1000); /* t is track no to display */ - else ci->set_elapsed(0); -} - -/* this is the codec entry point */ -enum codec_status codec_main(enum codec_entry_call_reason reason) -{ - if (reason == CODEC_LOAD) { - /* we only render 16 bits */ - ci->configure(DSP_SET_SAMPLE_DEPTH, 16); - - /* 44 Khz, Interleaved stereo */ - ci->configure(DSP_SET_FREQUENCY, 44100); - ci->configure(DSP_SET_STEREO_MODE, STEREO_INTERLEAVED); - - Ay_init(&ay_emu); - Ay_set_sample_rate(&ay_emu, 44100); - } - - return CODEC_OK; -} - -/* this is called for each file to process */ -enum codec_status codec_run(void) -{ - blargg_err_t err; - uint8_t *buf; - size_t n; - int track, is_multitrack; - intptr_t param; - uint32_t elapsed_time; - - /* reset values */ - track = is_multitrack = 0; - elapsed_time = 0; - - DEBUGF("AY: next_track\n"); - if (codec_init()) { - return CODEC_ERROR; - } - - codec_set_replaygain(ci->id3); - - /* Read the entire file */ - DEBUGF("AY: request file\n"); - ci->seek_buffer(0); - buf = ci->request_buffer(&n, ci->filesize); - if (!buf || n < (size_t)ci->filesize) { - DEBUGF("AY: file load failed\n"); - return CODEC_ERROR; - } - - if ((err = Ay_load_mem(&ay_emu, buf, ci->filesize))) { - DEBUGF("AY: Ay_load_mem failed (%s)\n", err); - return CODEC_ERROR; - } - - /* Update internal track count */ - if (ay_emu.m3u.size > 0) - ay_emu.track_count = ay_emu.m3u.size; - - /* Check if file has multiple tracks */ - if (ay_emu.track_count > 1) { - is_multitrack = 1; - } - -next_track: - set_codec_track(track, is_multitrack); - - /* The main decoder loop */ - while (1) { - enum codec_command_action action = ci->get_command(¶m); - - if (action == CODEC_ACTION_HALT) - break; - - if (action == CODEC_ACTION_SEEK_TIME) { - if (is_multitrack) { - track = param/1000; - ci->seek_complete(); - if (track >= ay_emu.track_count) break; - goto next_track; - } - - ci->set_elapsed(param); - elapsed_time = param; - Track_seek(&ay_emu, param); - ci->seek_complete(); - - /* Set fade again */ - if (!ci->loop_track()) { - Track_set_fade(&ay_emu, Track_get_length( &ay_emu, track ) - 4000, 4000); - } - } - - /* Generate audio buffer */ - err = Ay_play(&ay_emu, CHUNK_SIZE, samples); - if (err || Track_ended(&ay_emu)) { - track++; - if (track >= ay_emu.track_count) break; - goto next_track; - } - - ci->pcmbuf_insert(samples, NULL, CHUNK_SIZE >> 1); - - /* Set elapsed time for one track files */ - if (!is_multitrack) { - elapsed_time += (CHUNK_SIZE / 2) * 10 / 441; - ci->set_elapsed(elapsed_time); - } - } - - return CODEC_OK; -} diff --git a/apps/codecs/codec_crt0.c b/apps/codecs/codec_crt0.c deleted file mode 100644 index e3c3321e54..0000000000 --- a/apps/codecs/codec_crt0.c +++ /dev/null @@ -1,74 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2006 Tomasz Malesinski - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ - -#include "config.h" -#include "codecs.h" - -struct codec_api *ci DATA_ATTR; - -extern unsigned char plugin_bss_start[]; -extern unsigned char plugin_end_addr[]; - -/* stub, the entry point is called via its reference in __header to - * avoid warning with certain compilers */ -int _start(void) {return 0;} - -enum codec_status codec_start(enum codec_entry_call_reason reason) -{ -#if (CONFIG_PLATFORM & PLATFORM_NATIVE) - if (reason == CODEC_LOAD) - { -#ifdef USE_IRAM - extern char iramcopy[], iramstart[], iramend[], iedata[], iend[]; - size_t iram_size = iramend - iramstart; - size_t ibss_size = iend - iedata; - if (iram_size > 0 || ibss_size > 0) - { - ci->memcpy(iramstart, iramcopy, iram_size); - ci->memset(iedata, 0, ibss_size); - /* make the icache (if it exists) up to date with the new code */ - ci->commit_discard_idcache(); - /* barrier to prevent reordering iram copy and BSS clearing, - * because the BSS segment alias the IRAM copy. - */ - asm volatile ("" ::: "memory"); - } -#endif /* PLUGIN_USE_IRAM */ - ci->memset(plugin_bss_start, 0, plugin_end_addr - plugin_bss_start); - /* Some parts of bss may be used via a no-cache alias (at least - * portalplayer has this). If we don't clear the cache, those aliases - * may read garbage */ - ci->commit_dcache(); - } -#endif /* CONFIG_PLATFORM */ - - /* Note: If for any reason codec_main would not be called with CODEC_LOAD - * because the above code failed then it must not be ever be called with - * any other value and some strategy to avoid doing so must be conceived */ - return codec_main(reason); -} - -#if defined(CPU_ARM) && (CONFIG_PLATFORM & PLATFORM_NATIVE) -void __attribute__((naked)) __div0(void) -{ - asm volatile("bx %0" : : "r"(ci->__div0)); -} -#endif diff --git a/apps/codecs/codecs.make b/apps/codecs/codecs.make deleted file mode 100644 index eac3089260..0000000000 --- a/apps/codecs/codecs.make +++ /dev/null @@ -1,206 +0,0 @@ -# __________ __ ___. -# Open \______ \ ____ ____ | | _\_ |__ _______ ___ -# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / -# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < -# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ -# \/ \/ \/ \/ \/ -# $Id$ -# - -CODECDIR = $(BUILDDIR)/apps/codecs -CODECS_SRC := $(call preprocess, $(APPSDIR)/codecs/SOURCES) -OTHER_SRC += $(CODECS_SRC) - -CODECS := $(CODECS_SRC:.c=.codec) -CODECS := $(subst $(ROOTDIR),$(BUILDDIR),$(CODECS)) - -# the codec helper library -include $(APPSDIR)/codecs/lib/libcodec.make -OTHER_INC += -I$(APPSDIR)/codecs/lib - -# extra libraries -CODEC_LIBS := $(EXTRA_LIBS) $(CODECLIB) - -# the codec libraries -include $(APPSDIR)/codecs/demac/libdemac.make -include $(APPSDIR)/codecs/liba52/liba52.make -include $(APPSDIR)/codecs/libalac/libalac.make -include $(APPSDIR)/codecs/libasap/libasap.make -include $(APPSDIR)/codecs/libasf/libasf.make -include $(APPSDIR)/codecs/libfaad/libfaad.make -include $(APPSDIR)/codecs/libffmpegFLAC/libffmpegFLAC.make -include $(APPSDIR)/codecs/libm4a/libm4a.make -include $(APPSDIR)/codecs/libmad/libmad.make -include $(APPSDIR)/codecs/libmusepack/libmusepack.make -include $(APPSDIR)/codecs/libspc/libspc.make -include $(APPSDIR)/codecs/libspeex/libspeex.make -include $(APPSDIR)/codecs/libtremor/libtremor.make -include $(APPSDIR)/codecs/libwavpack/libwavpack.make -include $(APPSDIR)/codecs/libwma/libwma.make -include $(APPSDIR)/codecs/libwmapro/libwmapro.make -include $(APPSDIR)/codecs/libcook/libcook.make -include $(APPSDIR)/codecs/librm/librm.make -include $(APPSDIR)/codecs/libatrac/libatrac.make -include $(APPSDIR)/codecs/libpcm/libpcm.make -include $(APPSDIR)/codecs/libtta/libtta.make -include $(APPSDIR)/codecs/libgme/libay.make -include $(APPSDIR)/codecs/libgme/libgbs.make -include $(APPSDIR)/codecs/libgme/libhes.make -include $(APPSDIR)/codecs/libgme/libnsf.make -include $(APPSDIR)/codecs/libgme/libsgc.make -include $(APPSDIR)/codecs/libgme/libvgm.make -include $(APPSDIR)/codecs/libgme/libkss.make -include $(APPSDIR)/codecs/libgme/libemu2413.make - -# compile flags for codecs -CODECFLAGS = $(CFLAGS) -fstrict-aliasing -I$(APPSDIR)/codecs \ - -I$(APPSDIR)/codecs/lib -DCODEC - -# set CODECFLAGS per codec lib, since gcc takes the last -Ox and the last -# in a -ffoo -fno-foo pair, there is no need to filter them out -$(A52LIB) : CODECFLAGS += -O1 -$(ALACLIB) : CODECFLAGS += -O1 -$(ASAPLIB) : CODECFLAGS += -O1 -$(ASFLIB) : CODECFLAGS += -O2 -$(ATRACLIB) : CODECFLAGS += -O1 -$(AYLIB) : CODECFLAGS += -O2 -$(COOKLIB): CODECFLAGS += -O1 -$(DEMACLIB) : CODECFLAGS += -O3 -$(FAADLIB) : CODECFLAGS += -O2 -$(FFMPEGFLACLIB) : CODECFLAGS += -O2 -$(GBSLIB) : CODECFLAGS += -O2 -$(HESLIB) : CODECFLAGS += -O2 -$(KSSLIB) : CODECFLAGS += -O2 -$(M4ALIB) : CODECFLAGS += -O3 -$(MUSEPACKLIB) : CODECFLAGS += -O1 -$(NSFLIB) : CODECFLAGS += -O2 -$(PCMSLIB) : CODECFLAGS += -O1 -$(RMLIB) : CODECFLAGS += -O3 -$(SGCLIB) : CODECFLAGS += -O2 -$(SPCLIB) : CODECFLAGS += -O1 -$(TREMORLIB) : CODECFLAGS += -O2 -$(TTALIB) : CODECFLAGS += -O2 -$(VGMLIB) : CODECFLAGS += -O2 -$(EMU2413LIB) : CODECFLAGS += -O3 -$(WAVPACKLIB) : CODECFLAGS += -O1 -$(WMALIB) : CODECFLAGS += -O2 -$(WMAPROLIB) : CODECFLAGS += -O1 -$(WMAVOICELIB) : CODECFLAGS += -O1 - -# fine-tuning of CODECFLAGS per cpu arch -ifeq ($(ARCH),arch_arm) - # redo per arm generation - $(ALACLIB) : CODECFLAGS += -O2 - $(AYLIB) : CODECFLAGS += -O1 - $(GBSLIB) : CODECFLAGS += -O1 - $(HESLIB) : CODECFLAGS += -O1 - $(KSSLIB) : CODECFLAGS += -O1 - $(NSFLIB) : CODECFLAGS += -O1 - $(SGCLIB) : CODECFLAGS += -O1 - $(VGMLIB) : CODECFLAGS += -O1 - $(EMU2413LIB) : CODECFLAGS += -O3 - $(WAVPACKLIB) : CODECFLAGS += -O3 -else ifeq ($(ARCH),arch_m68k) - $(A52LIB) : CODECFLAGS += -O2 - $(ASFLIB) : CODECFLAGS += -O3 - $(ATRACLIB) : CODECFLAGS += -O2 - $(COOKLIB): CODECFLAGS += -O2 - $(DEMACLIB) : CODECFLAGS += -O2 - $(SPCLIB) : CODECFLAGS += -O3 - $(WMAPROLIB) : CODECFLAGS += -O3 - $(WMAVOICELIB) : CODECFLAGS += -O2 -endif - -ifeq ($(MEMORYSIZE),2) - $(ASFLIB) : CODECFLAGS += -Os - $(WMALIB) : CODECFLAGS += -Os -endif - -ifndef APP_TYPE - CONFIGFILE := $(FIRMDIR)/export/config/$(MODELNAME).h - CODEC_LDS := $(APPSDIR)/plugins/plugin.lds # codecs and plugins use same file - CODECLINK_LDS := $(CODECDIR)/codec.link -endif - -CODEC_CRT0 := $(CODECDIR)/codec_crt0.o - -$(CODECS): $(CODEC_CRT0) $(CODECLINK_LDS) - -$(CODECLINK_LDS): $(CODEC_LDS) $(CONFIGFILE) - $(call PRINTS,PP $(@F)) - $(shell mkdir -p $(dir $@)) - $(call preprocess2file, $<, $@, -DCODEC) - -# codec/library dependencies -$(CODECDIR)/spc.codec : $(CODECDIR)/libspc.a -$(CODECDIR)/mpa.codec : $(CODECDIR)/libmad.a -$(CODECDIR)/a52.codec : $(CODECDIR)/liba52.a -$(CODECDIR)/flac.codec : $(CODECDIR)/libffmpegFLAC.a -$(CODECDIR)/vorbis.codec : $(CODECDIR)/libtremor.a -$(CODECDIR)/speex.codec : $(CODECDIR)/libspeex.a -$(CODECDIR)/mpc.codec : $(CODECDIR)/libmusepack.a -$(CODECDIR)/wavpack.codec : $(CODECDIR)/libwavpack.a -$(CODECDIR)/alac.codec : $(CODECDIR)/libalac.a $(CODECDIR)/libm4a.a -$(CODECDIR)/aac.codec : $(CODECDIR)/libfaad.a $(CODECDIR)/libm4a.a -$(CODECDIR)/shorten.codec : $(CODECDIR)/libffmpegFLAC.a -$(CODECDIR)/ape-pre.map : $(CODECDIR)/libdemac-pre.a -$(CODECDIR)/ape.codec : $(CODECDIR)/libdemac.a -$(CODECDIR)/wma.codec : $(CODECDIR)/libwma.a $(CODECDIR)/libasf.a -$(CODECDIR)/wmapro.codec : $(CODECDIR)/libwmapro.a $(CODECDIR)/libasf.a -$(CODECDIR)/wavpack_enc.codec: $(CODECDIR)/libwavpack.a -$(CODECDIR)/asap.codec : $(CODECDIR)/libasap.a -$(CODECDIR)/cook.codec : $(CODECDIR)/libcook.a $(CODECDIR)/librm.a -$(CODECDIR)/raac.codec : $(CODECDIR)/libfaad.a $(CODECDIR)/librm.a -$(CODECDIR)/a52_rm.codec : $(CODECDIR)/liba52.a $(CODECDIR)/librm.a -$(CODECDIR)/atrac3_rm.codec : $(CODECDIR)/libatrac.a $(CODECDIR)/librm.a -$(CODECDIR)/atrac3_oma.codec : $(CODECDIR)/libatrac.a -$(CODECDIR)/aiff.codec : $(CODECDIR)/libpcm.a -$(CODECDIR)/wav.codec : $(CODECDIR)/libpcm.a -$(CODECDIR)/smaf.codec : $(CODECDIR)/libpcm.a -$(CODECDIR)/au.codec : $(CODECDIR)/libpcm.a -$(CODECDIR)/vox.codec : $(CODECDIR)/libpcm.a -$(CODECDIR)/wav64.codec : $(CODECDIR)/libpcm.a -$(CODECDIR)/tta.codec : $(CODECDIR)/libtta.a -$(CODECDIR)/ay.codec : $(CODECDIR)/libay.a -$(CODECDIR)/gbs.codec : $(CODECDIR)/libgbs.a -$(CODECDIR)/hes.codec : $(CODECDIR)/libhes.a -$(CODECDIR)/nsf.codec : $(CODECDIR)/libnsf.a $(CODECDIR)/libemu2413.a -$(CODECDIR)/sgc.codec : $(CODECDIR)/libsgc.a $(CODECDIR)/libemu2413.a -$(CODECDIR)/vgm.codec : $(CODECDIR)/libvgm.a $(CODECDIR)/libemu2413.a -$(CODECDIR)/kss.codec : $(CODECDIR)/libkss.a $(CODECDIR)/libemu2413.a - -$(CODECS): $(CODEC_LIBS) # this must be last in codec dependency list - -# pattern rule for compiling codecs -$(CODECDIR)/%.o: $(ROOTDIR)/apps/codecs/%.c - $(SILENT)mkdir -p $(dir $@) - $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) \ - -I$(dir $<) $(CODECFLAGS) -c $< -o $@ - -# pattern rule for compiling codecs -$(CODECDIR)/%.o: $(ROOTDIR)/apps/codecs/%.S - $(SILENT)mkdir -p $(dir $@) - $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) \ - -I$(dir $<) $(CODECFLAGS) $(ASMFLAGS) -c $< -o $@ - -ifdef APP_TYPE - CODECLDFLAGS = $(SHARED_LDFLAG) -Wl,--gc-sections -Wl,-Map,$(CODECDIR)/$*.map - CODECFLAGS += $(SHARED_CFLAGS) # <-- from Makefile -else - CODECLDFLAGS = -T$(CODECLINK_LDS) -Wl,--gc-sections -Wl,-Map,$(CODECDIR)/$*.map - CODECFLAGS += -UDEBUG -DNDEBUG -endif -CODECLDFLAGS += $(GLOBAL_LDOPTS) - -$(CODECDIR)/%-pre.map: $(CODEC_CRT0) $(CODECLINK_LDS) $(CODECDIR)/%.o $(CODECS_LIBS) - $(call PRINTS,LD $(@F))$(CC) $(CODECFLAGS) -o $(CODECDIR)/$*-pre.elf \ - $(filter %.o, $^) \ - $(filter-out $(CODECLIB),$(filter %.a, $+)) $(CODECLIB) \ - -lgcc $(subst .map,-pre.map,$(CODECLDFLAGS)) - -$(CODECDIR)/%.codec: $(CODECDIR)/%.o - $(call PRINTS,LD $(@F))$(CC) $(CODECFLAGS) -o $(CODECDIR)/$*.elf \ - $(filter %.o, $^) \ - $(filter %.a, $+) \ - -lgcc $(CODECLDFLAGS) - $(SILENT)$(call objcopy,$(CODECDIR)/$*.elf,$@) diff --git a/apps/codecs/cook.c b/apps/codecs/cook.c deleted file mode 100644 index 55188aad36..0000000000 --- a/apps/codecs/cook.c +++ /dev/null @@ -1,202 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2009 Mohamed Tarek - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ - -#include - -#include "logf.h" -#include "codeclib.h" -#include "inttypes.h" -#include "libcook/cook.h" - -CODEC_HEADER - -static RMContext rmctx IBSS_ATTR_COOK_LARGE_IRAM; -static RMPacket pkt IBSS_ATTR_COOK_LARGE_IRAM; -static COOKContext q IBSS_ATTR; -static int32_t rm_outbuf[2048] IBSS_ATTR_COOK_LARGE_IRAM MEM_ALIGN_ATTR; - -static void init_rm(RMContext *rmctx) -{ - memcpy(rmctx, (void*)(( (intptr_t)ci->id3->id3v2buf + 3 ) &~ 3), sizeof(RMContext)); -} - -/* this is the codec entry point */ -enum codec_status codec_main(enum codec_entry_call_reason reason) -{ - /* Nothing to do */ - return CODEC_OK; - (void)reason; -} - -/* this is called for each file to process */ -enum codec_status codec_run(void) -{ - static size_t buff_size; - int datasize, res, consumed, i, time_offset; - uint8_t *bit_buffer; - uint16_t fs,sps,h; - uint32_t packet_count; - int scrambling_unit_size, num_units; - size_t resume_offset; - intptr_t param = 0; - enum codec_command_action action = CODEC_ACTION_NULL; - - if (codec_init()) { - DEBUGF("codec init failed\n"); - return CODEC_ERROR; - } - - resume_offset = ci->id3->offset; - - codec_set_replaygain(ci->id3); - ci->memset(&rmctx,0,sizeof(RMContext)); - ci->memset(&pkt,0,sizeof(RMPacket)); - ci->memset(&q,0,sizeof(COOKContext)); - - ci->seek_buffer(0); - - init_rm(&rmctx); - - ci->configure(DSP_SET_FREQUENCY, ci->id3->frequency); - /* cook's sample representation is 21.11 - * DSP_SET_SAMPLE_DEPTH = 11 (FRACT) + 16 (NATIVE) - 1 (SIGN) = 26 */ - ci->configure(DSP_SET_SAMPLE_DEPTH, 26); - ci->configure(DSP_SET_STEREO_MODE, rmctx.nb_channels == 1 ? - STEREO_MONO : STEREO_NONINTERLEAVED); - - packet_count = rmctx.nb_packets; - rmctx.audio_framesize = rmctx.block_align; - rmctx.block_align = rmctx.sub_packet_size; - fs = rmctx.audio_framesize; - sps= rmctx.block_align; - h = rmctx.sub_packet_h; - scrambling_unit_size = h * (fs + PACKET_HEADER_SIZE); - - res =cook_decode_init(&rmctx, &q); - if(res < 0) { - DEBUGF("failed to initialize cook decoder\n"); - return CODEC_ERROR; - } - - /* check for a mid-track resume and force a seek time accordingly */ - if(resume_offset > rmctx.data_offset + DATA_HEADER_SIZE) { - resume_offset -= rmctx.data_offset + DATA_HEADER_SIZE; - num_units = (int)resume_offset / scrambling_unit_size; - /* put number of subpackets to skip in resume_offset */ - resume_offset /= (sps + PACKET_HEADER_SIZE); - param = (int)resume_offset * ((sps * 8 * 1000)/rmctx.bit_rate); - action = CODEC_ACTION_SEEK_TIME; - } - else { - ci->set_elapsed(0); - } - - ci->advance_buffer(rmctx.data_offset + DATA_HEADER_SIZE); - - /* The main decoder loop */ -seek_start : - while(packet_count) - { - bit_buffer = (uint8_t *) ci->request_buffer(&buff_size, scrambling_unit_size); - consumed = rm_get_packet(&bit_buffer, &rmctx, &pkt); - if(consumed < 0) { - DEBUGF("rm_get_packet failed\n"); - return CODEC_ERROR; - } - - for(i = 0; i < rmctx.audio_pkt_cnt*(fs/sps) ; i++) - { - if (action == CODEC_ACTION_NULL) - action = ci->get_command(¶m); - - if (action == CODEC_ACTION_HALT) - return CODEC_OK; - - if (action == CODEC_ACTION_SEEK_TIME) { - /* Do not allow seeking beyond the file's length */ - if ((unsigned) param > ci->id3->length) { - ci->set_elapsed(ci->id3->length); - ci->seek_complete(); - return CODEC_OK; - } - - ci->seek_buffer(rmctx.data_offset + DATA_HEADER_SIZE); - packet_count = rmctx.nb_packets; - rmctx.audio_pkt_cnt = 0; - rmctx.frame_number = 0; - - /* Seek to the start of the track */ - if (param == 0) { - ci->set_elapsed(0); - ci->seek_complete(); - action = CODEC_ACTION_NULL; - goto seek_start; - } - num_units = (param/(sps*1000*8/rmctx.bit_rate))/(h*(fs/sps)); - ci->seek_buffer(rmctx.data_offset + DATA_HEADER_SIZE + consumed * num_units); - bit_buffer = (uint8_t *) ci->request_buffer(&buff_size, scrambling_unit_size); - consumed = rm_get_packet(&bit_buffer, &rmctx, &pkt); - if(consumed < 0) { - DEBUGF("rm_get_packet failed\n"); - ci->seek_complete(); - return CODEC_ERROR; - } - packet_count = rmctx.nb_packets - rmctx.audio_pkt_cnt * num_units; - rmctx.frame_number = (param/(sps*1000*8/rmctx.bit_rate)); - while(rmctx.audiotimestamp > (unsigned) param) { - rmctx.audio_pkt_cnt = 0; - ci->seek_buffer(rmctx.data_offset + DATA_HEADER_SIZE + consumed * (num_units-1)); - bit_buffer = (uint8_t *) ci->request_buffer(&buff_size, scrambling_unit_size); - consumed = rm_get_packet(&bit_buffer, &rmctx, &pkt); - packet_count += rmctx.audio_pkt_cnt; - num_units--; - } - time_offset = param - rmctx.audiotimestamp; - i = (time_offset/((sps * 8 * 1000)/rmctx.bit_rate)); - ci->set_elapsed(rmctx.audiotimestamp+(1000*8*sps/rmctx.bit_rate)*i); - ci->seek_complete(); - } - - action = CODEC_ACTION_NULL; - - res = cook_decode_frame(&rmctx,&q, rm_outbuf, &datasize, pkt.frames[i], rmctx.block_align); - rmctx.frame_number++; - - /* skip the first two frames; no valid audio */ - if(rmctx.frame_number < 3) continue; - - if(res != rmctx.block_align) { - DEBUGF("codec error\n"); - return CODEC_ERROR; - } - - ci->pcmbuf_insert(rm_outbuf, - rm_outbuf+q.samples_per_channel, - q.samples_per_channel); - ci->set_elapsed(rmctx.audiotimestamp+(1000*8*sps/rmctx.bit_rate)*i); - } - packet_count -= rmctx.audio_pkt_cnt; - rmctx.audio_pkt_cnt = 0; - ci->advance_buffer(consumed); - } - - return CODEC_OK; -} diff --git a/apps/codecs/demac/COPYING b/apps/codecs/demac/COPYING deleted file mode 100644 index d511905c16..0000000000 --- a/apps/codecs/demac/COPYING +++ /dev/null @@ -1,339 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Lesser General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. diff --git a/apps/codecs/demac/Makefile b/apps/codecs/demac/Makefile deleted file mode 100644 index 7843be6e49..0000000000 --- a/apps/codecs/demac/Makefile +++ /dev/null @@ -1,42 +0,0 @@ -# $Id$ - -FILTERS = libdemac/filter_16_11.o libdemac/filter_64_11.o libdemac/filter_256_13.o libdemac/filter_32_10.o libdemac/filter_1280_15.o -LIBOBJS = libdemac/parser.o libdemac/decoder.o libdemac/entropy.o libdemac/predictor.o libdemac/crc.o $(FILTERS) -OBJS = demac.o wavwrite.o $(LIBOBJS) - -CFLAGS = -Wall -g -O3 -Ilibdemac - -ifeq ($(findstring CYGWIN,$(shell uname)),CYGWIN) -EXT = .exe -CROSS = -CFLAGS += -mno-cygwin -else - ifdef WIN - EXT = .exe - CROSS = i586-mingw32msvc- - else - EXT = - CROSS = - endif -endif - -CC = $(CROSS)gcc -STRIP = $(CROSS)strip -OUTPUT = demac$(EXT) - -all: $(OUTPUT) - -$(OUTPUT): $(OBJS) - $(CC) $(CFLAGS) -o $(OUTPUT) $(OBJS) - -.c.o : - $(CC) $(CFLAGS) $(INC) -c -o $@ $< - -libdemac/filter_16_11.o: libdemac/filter.c -libdemac/filter_64_11.o: libdemac/filter.c -libdemac/filter_256_13.o: libdemac/filter.c -libdemac/filter_1280_15.o: libdemac/filter.c -libdemac/filter_32_10.o: libdemac/filter.c - -clean: - rm -f $(OUTPUT) $(OBJS) *~ */*~ diff --git a/apps/codecs/demac/README b/apps/codecs/demac/README deleted file mode 100644 index 2fcdd95edf..0000000000 --- a/apps/codecs/demac/README +++ /dev/null @@ -1,69 +0,0 @@ -demac - a decoder for Monkey's Audio files. - -Introduction - -demac is an implementation in portable ANSI C of a decoder for the -Monkey's Audio lossless compression format. It has the following -features: - - * Open source (GNU GPL) - * Written in portable ANSI C - * Designed for use on low memory and embedded devices. All internal - buffers are statically declared - the core library doesn't require - malloc/free. This has the disadvantage that the library isn't - re-entrant. - - -Compatibility - - -libdemac is still in the early stages of development but has been -relatively well tested with v3.99 files at all compression levels. - -v3.97 files have received less testing - 16-bit files seem to work, -but 24-bit files are causing problems in the range decoder. - -Files earlier than v3.97 are not supported by libdemac, but support -might be added in the future. - - -Source Code - -The source code in this directory is structured as follows: - -demac/Makefile - Makefile for the standalone demac decoder -demac/demac.c - Simple standalone test program to decoder an APE file to WAV -demac/wavwrite.[ch] - Helper functions for demac.c -demac/libdemac/Makefile - A Makefile for use in Rockbox -demac/libdemac/*.[ch] - The main libdemac code - - -Latest Version - -The latest version of demac and libdemac can always be found in the -"apps/codecs/demac/" directory in the Rockbox source. You can check -this out from svn with the command: - -svn co svn://svn.rockbox.org/rockbox/trunk/apps/codecs/demac demac - -Or browse the source code online here: - -http://svn.rockbox.org/viewvc.cgi/trunk/apps/codecs/demac - - - -Acknowledgements - -Thanks to Matt. T. Ashland for writing Monkey's Audio. His website -can be found here: http://www.monkeysaudio.com - - -Copyright and license - - -libdemac is (C) 2007 Dave Chapman and is licensed under the GNU -GPL. See the COPYING file in this directory. - -The exception is the majority of rangecoding.h, which is (C) 1997, -1998, 1999, 2000 Michael Schindler and is also licensed under the GPL. -See that source file for full details. diff --git a/apps/codecs/demac/demac.c b/apps/codecs/demac/demac.c deleted file mode 100644 index 3e97fff2c9..0000000000 --- a/apps/codecs/demac/demac.c +++ /dev/null @@ -1,281 +0,0 @@ -/* - -demac - A Monkey's Audio decoder - -$Id$ - -Copyright (C) Dave Chapman 2007 - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA - -*/ - -/* - -This example is intended to demonstrate how the decoder can be used in -embedded devices - there is no usage of dynamic memory (i.e. no -malloc/free) and small buffer sizes are chosen to minimise both the -memory usage and decoding latency. - -This implementation requires the following memory and supports decoding of all APE files up to 24-bit Stereo. - -32768 - data from the input stream to be presented to the decoder in one contiguous chunk. -18432 - decoding buffer (left channel) -18432 - decoding buffer (right channel) - -17408+5120+2240 - buffers used for filter histories (compression levels 2000-5000) - -In addition, this example uses a static 27648 byte buffer as temporary -storage for outputting the data to a WAV file but that could be -avoided by writing the decoded data one sample at a time. - -*/ - -#include -#include -#include -#include -#include -#include -#include - -#include "demac.h" -#include "wavwrite.h" - -#ifndef __WIN32__ -#define O_BINARY 0 -#endif - -#define CALC_CRC 1 - -#define BLOCKS_PER_LOOP 4608 -#define MAX_CHANNELS 2 -#define MAX_BYTESPERSAMPLE 3 - -#define INPUT_CHUNKSIZE (32*1024) - -#ifndef MIN -#define MIN(a,b) ((a) < (b) ? (a) : (b)) -#endif - - -/* 4608*2*3 = 27648 bytes */ -static unsigned char wavbuffer[BLOCKS_PER_LOOP*MAX_CHANNELS*MAX_BYTESPERSAMPLE]; - -/* 4608*4 = 18432 bytes per channel */ -static int32_t decoded0[BLOCKS_PER_LOOP]; -static int32_t decoded1[BLOCKS_PER_LOOP]; - -/* We assume that 32KB of compressed data is enough to extract up to - 27648 bytes of decompressed data. */ - -static unsigned char inbuffer[INPUT_CHUNKSIZE]; - -int ape_decode(char* infile, char* outfile) -{ - int fd; - int fdwav; - int currentframe; - int nblocks; - int bytesconsumed; - struct ape_ctx_t ape_ctx; - int i, n; - unsigned char* p; - int bytesinbuffer; - int blockstodecode; - int res; - int firstbyte; - int16_t sample16; - int32_t sample32; - uint32_t frame_crc; - int crc_errors = 0; - - fd = open(infile,O_RDONLY|O_BINARY); - if (fd < 0) return -1; - - /* Read the file headers to populate the ape_ctx struct */ - if (ape_parseheader(fd,&ape_ctx) < 0) { - printf("Cannot read header\n"); - close(fd); - return -1; - } - - if ((ape_ctx.fileversion < APE_MIN_VERSION) || (ape_ctx.fileversion > APE_MAX_VERSION)) { - printf("Unsupported file version - %.2f\n", ape_ctx.fileversion/1000.0); - close(fd); - return -2; - } - - //ape_dumpinfo(&ape_ctx); - - printf("Decoding file - v%.2f, compression level %d\n",ape_ctx.fileversion/1000.0,ape_ctx.compressiontype); - - /* Open the WAV file and write a canonical 44-byte WAV header - based on the audio format information in the ape_ctx struct. - - NOTE: This example doesn't write the original WAV header and - tail data which are (optionally) stored in the APE file. - */ - fdwav = open_wav(&ape_ctx,outfile); - - currentframe = 0; - - /* Initialise the buffer */ - lseek(fd, ape_ctx.firstframe, SEEK_SET); - bytesinbuffer = read(fd, inbuffer, INPUT_CHUNKSIZE); - firstbyte = 3; /* Take account of the little-endian 32-bit byte ordering */ - - /* The main decoding loop - we decode the frames a small chunk at a time */ - while (currentframe < ape_ctx.totalframes) - { - /* Calculate how many blocks there are in this frame */ - if (currentframe == (ape_ctx.totalframes - 1)) - nblocks = ape_ctx.finalframeblocks; - else - nblocks = ape_ctx.blocksperframe; - - ape_ctx.currentframeblocks = nblocks; - - /* Initialise the frame decoder */ - init_frame_decoder(&ape_ctx, inbuffer, &firstbyte, &bytesconsumed); - - /* Update buffer */ - memmove(inbuffer,inbuffer + bytesconsumed, bytesinbuffer - bytesconsumed); - bytesinbuffer -= bytesconsumed; - - n = read(fd, inbuffer + bytesinbuffer, INPUT_CHUNKSIZE - bytesinbuffer); - bytesinbuffer += n; - -#if CALC_CRC - frame_crc = ape_initcrc(); -#endif - - /* Decode the frame a chunk at a time */ - while (nblocks > 0) - { - blockstodecode = MIN(BLOCKS_PER_LOOP, nblocks); - - if ((res = decode_chunk(&ape_ctx, inbuffer, &firstbyte, - &bytesconsumed, - decoded0, decoded1, - blockstodecode)) < 0) - { - /* Frame decoding error, abort */ - close(fd); - return res; - } - - /* Convert the output samples to WAV format and write to output file */ - p = wavbuffer; - if (ape_ctx.bps == 8) { - for (i = 0 ; i < blockstodecode ; i++) - { - /* 8 bit WAV uses unsigned samples */ - *(p++) = (decoded0[i] + 0x80) & 0xff; - - if (ape_ctx.channels == 2) { - *(p++) = (decoded1[i] + 0x80) & 0xff; - } - } - } else if (ape_ctx.bps == 16) { - for (i = 0 ; i < blockstodecode ; i++) - { - sample16 = decoded0[i]; - *(p++) = sample16 & 0xff; - *(p++) = (sample16 >> 8) & 0xff; - - if (ape_ctx.channels == 2) { - sample16 = decoded1[i]; - *(p++) = sample16 & 0xff; - *(p++) = (sample16 >> 8) & 0xff; - } - } - } else if (ape_ctx.bps == 24) { - for (i = 0 ; i < blockstodecode ; i++) - { - sample32 = decoded0[i]; - *(p++) = sample32 & 0xff; - *(p++) = (sample32 >> 8) & 0xff; - *(p++) = (sample32 >> 16) & 0xff; - - if (ape_ctx.channels == 2) { - sample32 = decoded1[i]; - *(p++) = sample32 & 0xff; - *(p++) = (sample32 >> 8) & 0xff; - *(p++) = (sample32 >> 16) & 0xff; - } - } - } - -#if CALC_CRC - frame_crc = ape_updatecrc(wavbuffer, p - wavbuffer, frame_crc); -#endif - write(fdwav,wavbuffer,p - wavbuffer); - - /* Update the buffer */ - memmove(inbuffer,inbuffer + bytesconsumed, bytesinbuffer - bytesconsumed); - bytesinbuffer -= bytesconsumed; - - n = read(fd, inbuffer + bytesinbuffer, INPUT_CHUNKSIZE - bytesinbuffer); - bytesinbuffer += n; - - /* Decrement the block count */ - nblocks -= blockstodecode; - } - -#if CALC_CRC - frame_crc = ape_finishcrc(frame_crc); - - if (ape_ctx.CRC != frame_crc) - { - fprintf(stderr,"CRC error in frame %d\n",currentframe); - crc_errors++; - } -#endif - - currentframe++; - } - - close(fd); - close(fdwav); - - if (crc_errors > 0) - return -1; - else - return 0; -} - -int main(int argc, char* argv[]) -{ - int res; - - if (argc != 3) { - fprintf(stderr,"Usage: demac infile.ape outfile.wav\n"); - return 0; - } - - res = ape_decode(argv[1], argv[2]); - - if (res < 0) - { - fprintf(stderr,"DECODING ERROR %d, ABORTING\n", res); - } - else - { - fprintf(stderr,"DECODED OK - NO CRC ERRORS.\n"); - } - - return 0; -} diff --git a/apps/codecs/demac/libdemac.make b/apps/codecs/demac/libdemac.make deleted file mode 100644 index 62ad53dfcc..0000000000 --- a/apps/codecs/demac/libdemac.make +++ /dev/null @@ -1,35 +0,0 @@ -# __________ __ ___. -# Open \______ \ ____ ____ | | _\_ |__ _______ ___ -# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / -# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < -# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ -# \/ \/ \/ \/ \/ -# $Id$ -# - -# libdemac -DEMACLIB := $(CODECDIR)/libdemac.a -DEMACLIB_SRC := $(call preprocess, $(APPSDIR)/codecs/demac/libdemac/SOURCES) -DEMACLIB_OBJ := $(call c2obj, $(DEMACLIB_SRC)) -OTHER_SRC += $(DEMACLIB_SRC) -ifeq ($(ARCH),arch_arm) -OTHER_SRC += $(APPSDIR)/codecs/demac/libdemac/udiv32_arm-pre.S -endif -DEMACLIB_PRE := $(subst .a,-pre.a,$(DEMACLIB)) -DEMACLIB_OBJ_PRE := $(subst udiv32_arm.o,udiv32_arm-pre.o,$(DEMACLIB_OBJ)) - -$(DEMACLIB_PRE): $(DEMACLIB_OBJ_PRE) - $(SILENT)$(shell rm -f $@) - $(call PRINTS,AR $(@F))$(AR) rcs $@ $^ >/dev/null - -$(DEMACLIB): $(DEMACLIB_OBJ) - $(SILENT)$(shell rm -f $@) - $(call PRINTS,AR $(@F))$(AR) rcs $@ $^ >/dev/null - -$(CODECDIR)/ape_free_iram.h: $(CODECDIR)/ape-pre.map - $(call PRINTS,GEN $(@F))perl -an \ - -e 'if(/^PLUGIN_IRAM/){$$istart=hex($$F[1]);$$ilen=hex($$F[2])}' \ - -e 'if(/iend = /){$$iend=hex($$F[0]);}' \ - -e '}{if($$ilen){print"#define FREE_IRAM ".($$ilen+$$istart-$$iend)."\n";}' \ - $(CODECDIR)/ape-pre.map \ - > $@ diff --git a/apps/codecs/demac/libdemac/SOURCES b/apps/codecs/demac/libdemac/SOURCES deleted file mode 100644 index 018f35a73c..0000000000 --- a/apps/codecs/demac/libdemac/SOURCES +++ /dev/null @@ -1,15 +0,0 @@ -predictor.c -#ifdef CPU_ARM -predictor-arm.S -udiv32_arm.S -#elif defined CPU_COLDFIRE -predictor-cf.S -#endif -entropy.c -decoder.c -parser.c -filter_1280_15.c -filter_16_11.c -filter_256_13.c -filter_32_10.c -filter_64_11.c diff --git a/apps/codecs/demac/libdemac/crc.c b/apps/codecs/demac/libdemac/crc.c deleted file mode 100644 index fa3ea89d7e..0000000000 --- a/apps/codecs/demac/libdemac/crc.c +++ /dev/null @@ -1,120 +0,0 @@ -/* - -libdemac - A Monkey's Audio decoder - -$Id$ - -Copyright (C) Dave Chapman 2007 - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA - -*/ - -#include -#include "demac.h" - -static const uint32_t crctab32[] = -{ - 0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, - 0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3, - 0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988, - 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91, - 0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE, - 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7, - 0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC, - 0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5, - 0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172, - 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B, - 0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940, - 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59, - 0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116, - 0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F, - 0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924, - 0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D, - - 0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A, - 0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433, - 0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818, - 0x7F6A0DBB, 0x086D3D2D, 0x91646C97, 0xE6635C01, - 0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E, - 0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457, - 0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, 0xFCB9887C, - 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65, - 0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2, - 0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB, - 0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0, - 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9, - 0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086, - 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F, - 0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4, - 0x59B33D17, 0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD, - - 0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A, - 0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683, - 0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8, - 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1, - 0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE, - 0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7, - 0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC, - 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5, - 0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252, - 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B, - 0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60, - 0xDF60EFC3, 0xA867DF55, 0x316E8EEF, 0x4669BE79, - 0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236, - 0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F, - 0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04, - 0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D, - - 0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A, - 0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713, - 0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38, - 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21, - 0x86D3D2D4, 0xF1D4E242, 0x68DDB3F8, 0x1FDA836E, - 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777, - 0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C, - 0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45, - 0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2, - 0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB, - 0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0, - 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9, - 0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, - 0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF, - 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94, - 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D -}; - -uint32_t ape_initcrc(void) -{ - return 0xffffffff; -} - -/* Update the CRC from a block of WAV-format audio data */ -uint32_t ape_updatecrc(unsigned char *block, int count, uint32_t crc) -{ - while (count--) - crc = (crc >> 8) ^ crctab32[(crc & 0xff) ^ *block++]; - - return crc; -} - -uint32_t ape_finishcrc(uint32_t crc) -{ - crc ^= 0xffffffff; - crc >>= 1; - - return crc; -} - diff --git a/apps/codecs/demac/libdemac/decoder.c b/apps/codecs/demac/libdemac/decoder.c deleted file mode 100644 index b0339a75d9..0000000000 --- a/apps/codecs/demac/libdemac/decoder.c +++ /dev/null @@ -1,216 +0,0 @@ -/* - -libdemac - A Monkey's Audio decoder - -$Id$ - -Copyright (C) Dave Chapman 2007 - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA - -*/ - -#include -#include - -#include "demac.h" -#include "predictor.h" -#include "entropy.h" -#include "filter.h" -#include "demac_config.h" - -/* Statically allocate the filter buffers */ - -#ifdef FILTER256_IRAM -static filter_int filterbuf32[(32*3 + FILTER_HISTORY_SIZE) * 2] - IBSS_ATTR_DEMAC MEM_ALIGN_ATTR; - /* 2432 or 4864 bytes */ -static filter_int filterbuf256[(256*3 + FILTER_HISTORY_SIZE) * 2] - IBSS_ATTR_DEMAC MEM_ALIGN_ATTR; - /* 5120 or 10240 bytes */ -#define FILTERBUF64 filterbuf256 -#define FILTERBUF32 filterbuf32 -#define FILTERBUF16 filterbuf32 -#else -static filter_int filterbuf64[(64*3 + FILTER_HISTORY_SIZE) * 2] - IBSS_ATTR_DEMAC MEM_ALIGN_ATTR; - /* 2432 or 4864 bytes */ -static filter_int filterbuf256[(256*3 + FILTER_HISTORY_SIZE) * 2] - MEM_ALIGN_ATTR; /* 5120 or 10240 bytes */ -#define FILTERBUF64 filterbuf64 -#define FILTERBUF32 filterbuf64 -#define FILTERBUF16 filterbuf64 -#endif - -/* This is only needed for "insane" files, and no current Rockbox targets - can hope to decode them in realtime, except the Gigabeat S (at 528MHz). */ -static filter_int filterbuf1280[(1280*3 + FILTER_HISTORY_SIZE) * 2] - IBSS_ATTR_DEMAC_INSANEBUF MEM_ALIGN_ATTR; - /* 17408 or 34816 bytes */ - -void init_frame_decoder(struct ape_ctx_t* ape_ctx, - unsigned char* inbuffer, int* firstbyte, - int* bytesconsumed) -{ - init_entropy_decoder(ape_ctx, inbuffer, firstbyte, bytesconsumed); - //printf("CRC=0x%08x\n",ape_ctx->CRC); - //printf("Flags=0x%08x\n",ape_ctx->frameflags); - - init_predictor_decoder(&ape_ctx->predictor); - - switch (ape_ctx->compressiontype) - { - case 2000: - init_filter_16_11(FILTERBUF16); - break; - - case 3000: - init_filter_64_11(FILTERBUF64); - break; - - case 4000: - init_filter_256_13(filterbuf256); - init_filter_32_10(FILTERBUF32); - break; - - case 5000: - init_filter_1280_15(filterbuf1280); - init_filter_256_13(filterbuf256); - init_filter_16_11(FILTERBUF32); - } -} - -int ICODE_ATTR_DEMAC decode_chunk(struct ape_ctx_t* ape_ctx, - unsigned char* inbuffer, int* firstbyte, - int* bytesconsumed, - int32_t* decoded0, int32_t* decoded1, - int count) -{ - int32_t left, right; -#ifdef ROCKBOX - int scale = (APE_OUTPUT_DEPTH - ape_ctx->bps); - #define SCALE(x) ((x) << scale) -#else - #define SCALE(x) (x) -#endif - - if ((ape_ctx->channels==1) || ((ape_ctx->frameflags - & (APE_FRAMECODE_PSEUDO_STEREO|APE_FRAMECODE_STEREO_SILENCE)) - == APE_FRAMECODE_PSEUDO_STEREO)) { - - entropy_decode(ape_ctx, inbuffer, firstbyte, bytesconsumed, - decoded0, NULL, count); - - if (ape_ctx->frameflags & APE_FRAMECODE_MONO_SILENCE) { - /* We are pure silence, so we're done. */ - return 0; - } - - switch (ape_ctx->compressiontype) - { - case 2000: - apply_filter_16_11(ape_ctx->fileversion,0,decoded0,count); - break; - - case 3000: - apply_filter_64_11(ape_ctx->fileversion,0,decoded0,count); - break; - - case 4000: - apply_filter_32_10(ape_ctx->fileversion,0,decoded0,count); - apply_filter_256_13(ape_ctx->fileversion,0,decoded0,count); - break; - - case 5000: - apply_filter_16_11(ape_ctx->fileversion,0,decoded0,count); - apply_filter_256_13(ape_ctx->fileversion,0,decoded0,count); - apply_filter_1280_15(ape_ctx->fileversion,0,decoded0,count); - } - - /* Now apply the predictor decoding */ - predictor_decode_mono(&ape_ctx->predictor,decoded0,count); - - if (ape_ctx->channels==2) { - /* Pseudo-stereo - copy left channel to right channel */ - while (count--) - { - left = *decoded0; - *(decoded1++) = *(decoded0++) = SCALE(left); - } - } -#ifdef ROCKBOX - else { - /* Scale to output depth */ - while (count--) - { - left = *decoded0; - *(decoded0++) = SCALE(left); - } - } -#endif - } else { /* Stereo */ - entropy_decode(ape_ctx, inbuffer, firstbyte, bytesconsumed, - decoded0, decoded1, count); - - if ((ape_ctx->frameflags & APE_FRAMECODE_STEREO_SILENCE) - == APE_FRAMECODE_STEREO_SILENCE) { - /* We are pure silence, so we're done. */ - return 0; - } - - /* Apply filters - compression type 1000 doesn't have any */ - switch (ape_ctx->compressiontype) - { - case 2000: - apply_filter_16_11(ape_ctx->fileversion,0,decoded0,count); - apply_filter_16_11(ape_ctx->fileversion,1,decoded1,count); - break; - - case 3000: - apply_filter_64_11(ape_ctx->fileversion,0,decoded0,count); - apply_filter_64_11(ape_ctx->fileversion,1,decoded1,count); - break; - - case 4000: - apply_filter_32_10(ape_ctx->fileversion,0,decoded0,count); - apply_filter_32_10(ape_ctx->fileversion,1,decoded1,count); - apply_filter_256_13(ape_ctx->fileversion,0,decoded0,count); - apply_filter_256_13(ape_ctx->fileversion,1,decoded1,count); - break; - - case 5000: - apply_filter_16_11(ape_ctx->fileversion,0,decoded0,count); - apply_filter_16_11(ape_ctx->fileversion,1,decoded1,count); - apply_filter_256_13(ape_ctx->fileversion,0,decoded0,count); - apply_filter_256_13(ape_ctx->fileversion,1,decoded1,count); - apply_filter_1280_15(ape_ctx->fileversion,0,decoded0,count); - apply_filter_1280_15(ape_ctx->fileversion,1,decoded1,count); - } - - /* Now apply the predictor decoding */ - predictor_decode_stereo(&ape_ctx->predictor,decoded0,decoded1,count); - - /* Decorrelate and scale to output depth */ - while (count--) - { - left = *decoded1 - (*decoded0 / 2); - right = left + *decoded0; - - *(decoded0++) = SCALE(left); - *(decoded1++) = SCALE(right); - } - } - return 0; -} diff --git a/apps/codecs/demac/libdemac/decoder.h b/apps/codecs/demac/libdemac/decoder.h deleted file mode 100644 index aeac569509..0000000000 --- a/apps/codecs/demac/libdemac/decoder.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - -libdemac - A Monkey's Audio decoder - -$Id$ - -Copyright (C) Dave Chapman 2007 - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA - -*/ - -#ifndef _APE_DECODER_H -#define _APE_DECODER_H - -#include -#include "parser.h" - -void init_frame_decoder(struct ape_ctx_t* ape_ctx, - unsigned char* inbuffer, int* firstbyte, - int* bytesconsumed); - -int decode_chunk(struct ape_ctx_t* ape_ctx, - unsigned char* inbuffer, int* firstbyte, - int* bytesconsumed, - int32_t* decoded0, int32_t* decoded1, - int count); -#endif diff --git a/apps/codecs/demac/libdemac/demac.h b/apps/codecs/demac/libdemac/demac.h deleted file mode 100644 index 696b2aba73..0000000000 --- a/apps/codecs/demac/libdemac/demac.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - -libdemac - A Monkey's Audio decoder - -$Id$ - -Copyright (C) Dave Chapman 2007 - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA - -*/ - -#ifndef _APE_DECODER_H -#define _APE_DECODER_H - -#include -#include "parser.h" - -void init_frame_decoder(struct ape_ctx_t* ape_ctx, - unsigned char* inbuffer, int* firstbyte, - int* bytesconsumed); - -int decode_chunk(struct ape_ctx_t* ape_ctx, - unsigned char* inbuffer, int* firstbyte, - int* bytesconsumed, - int32_t* decoded0, int32_t* decoded1, - int count); - -uint32_t ape_initcrc(void); -uint32_t ape_updatecrc(unsigned char *block, int count, uint32_t crc); -uint32_t ape_finishcrc(uint32_t crc); - -#endif diff --git a/apps/codecs/demac/libdemac/demac_config.h b/apps/codecs/demac/libdemac/demac_config.h deleted file mode 100644 index fa4f008036..0000000000 --- a/apps/codecs/demac/libdemac/demac_config.h +++ /dev/null @@ -1,145 +0,0 @@ -/* - -libdemac - A Monkey's Audio decoder - -$Id$ - -Copyright (C) Dave Chapman 2007 - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA - -*/ - -#ifndef _DEMAC_CONFIG_H -#define _DEMAC_CONFIG_H - -/* Build-time choices for libdemac. - * Note that this file is included by both .c and .S files. */ - -#ifdef ROCKBOX - -#include "config.h" - -#ifndef __ASSEMBLER__ -#include "codeclib.h" -#include -#endif - -#define APE_OUTPUT_DEPTH 29 - -/* On ARMv4, using 32 bit ints for the filters is faster. */ -#if defined(CPU_ARM) && (ARM_ARCH == 4) -#define FILTER_BITS 32 -#endif - -#if !defined(CPU_PP) && !defined(CPU_S5L870X) -#define FILTER256_IRAM -#endif - -#if CONFIG_CPU == PP5002 || defined(CPU_S5L870X) -/* Code and data IRAM for speed (PP5002 has a broken cache), not enough IRAM - * for the insane filter buffer. Reciprocal table for division in IRAM. */ -#define ICODE_SECTION_DEMAC_ARM .icode -#define ICODE_ATTR_DEMAC ICODE_ATTR -#define ICONST_ATTR_DEMAC ICONST_ATTR -#define IBSS_ATTR_DEMAC IBSS_ATTR -#define IBSS_ATTR_DEMAC_INSANEBUF - -#elif CONFIG_CPU == PP5020 -/* Code and small data in DRAM for speed (PP5020 IRAM isn't completely single - * cycle). Insane filter buffer not in IRAM in favour of reciprocal table for - * divison. Decoded data buffers should be in IRAM (defined by the caller). */ -#define ICODE_SECTION_DEMAC_ARM .text -#define ICODE_ATTR_DEMAC -#define ICONST_ATTR_DEMAC -#define IBSS_ATTR_DEMAC -#define IBSS_ATTR_DEMAC_INSANEBUF - -#elif CONFIG_CPU == PP5022 -/* Code in DRAM, data in IRAM. Insane filter buffer not in IRAM in favour of - * reciprocal table for divison */ -#define ICODE_SECTION_DEMAC_ARM .text -#define ICODE_ATTR_DEMAC -#define ICONST_ATTR_DEMAC ICONST_ATTR -#define IBSS_ATTR_DEMAC IBSS_ATTR -#define IBSS_ATTR_DEMAC_INSANEBUF - -#else -/* Code in DRAM, data in IRAM, including insane filter buffer. */ -#define ICODE_SECTION_DEMAC_ARM .text -#define ICODE_ATTR_DEMAC -#define ICONST_ATTR_DEMAC ICONST_ATTR -#define IBSS_ATTR_DEMAC IBSS_ATTR -#define IBSS_ATTR_DEMAC_INSANEBUF IBSS_ATTR -#endif - -#else /* !ROCKBOX */ - -#define APE_OUTPUT_DEPTH (ape_ctx->bps) - -#define MEM_ALIGN_ATTR __attribute__((aligned(16))) - /* adjust to target architecture for best performance */ - -#define ICODE_ATTR_DEMAC -#define ICONST_ATTR_DEMAC -#define IBSS_ATTR_DEMAC -#define IBSS_ATTR_DEMAC_INSANEBUF - -/* Use to give gcc hints on which branch is most likely taken */ -#if defined(__GNUC__) && __GNUC__ >= 3 -#define LIKELY(x) __builtin_expect(!!(x), 1) -#define UNLIKELY(x) __builtin_expect(!!(x), 0) -#else -#define LIKELY(x) (x) -#define UNLIKELY(x) (x) -#endif - -#endif /* !ROCKBOX */ - -/* Defaults */ - -#ifndef FILTER_HISTORY_SIZE -#define FILTER_HISTORY_SIZE 512 -#endif - -#ifndef PREDICTOR_HISTORY_SIZE -#define PREDICTOR_HISTORY_SIZE 512 -#endif - -#ifndef FILTER_BITS -#define FILTER_BITS 16 -#endif - - -#ifndef __ASSEMBLER__ - -#if defined(CPU_ARM) && (ARM_ARCH < 5 || defined(USE_IRAM)) -/* optimised unsigned integer division for ARMv4, in IRAM */ -unsigned udiv32_arm(unsigned a, unsigned b); -#define UDIV32(a, b) udiv32_arm(a, b) -#else -/* default */ -#define UDIV32(a, b) (a / b) -#endif - -#include -#if FILTER_BITS == 32 -typedef int32_t filter_int; -#elif FILTER_BITS == 16 -typedef int16_t filter_int; -#endif -#endif - -#endif /* _DEMAC_CONFIG_H */ diff --git a/apps/codecs/demac/libdemac/entropy.c b/apps/codecs/demac/libdemac/entropy.c deleted file mode 100644 index 1cef979808..0000000000 --- a/apps/codecs/demac/libdemac/entropy.c +++ /dev/null @@ -1,464 +0,0 @@ -/* - -libdemac - A Monkey's Audio decoder - -$Id$ - -Copyright (C) Dave Chapman 2007 - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA - -*/ - -#include -#include - -#include "parser.h" -#include "entropy.h" -#include "demac_config.h" - -#define MODEL_ELEMENTS 64 - -/* - The following counts arrays for use with the range decoder are - hard-coded in the Monkey's Audio decoder. -*/ - -static const int counts_3970[65] ICONST_ATTR_DEMAC = -{ - 0,14824,28224,39348,47855,53994,58171,60926, - 62682,63786,64463,64878,65126,65276,65365,65419, - 65450,65469,65480,65487,65491,65493,65494,65495, - 65496,65497,65498,65499,65500,65501,65502,65503, - 65504,65505,65506,65507,65508,65509,65510,65511, - 65512,65513,65514,65515,65516,65517,65518,65519, - 65520,65521,65522,65523,65524,65525,65526,65527, - 65528,65529,65530,65531,65532,65533,65534,65535, - 65536 -}; - -/* counts_diff_3970[i] = counts_3970[i+1] - counts_3970[i] */ -static const int counts_diff_3970[64] ICONST_ATTR_DEMAC = -{ - 14824,13400,11124,8507,6139,4177,2755,1756, - 1104,677,415,248,150,89,54,31, - 19,11,7,4,2,1,1,1, - 1,1,1,1,1,1,1,1, - 1,1,1,1,1,1,1,1, - 1,1,1,1,1,1,1,1, - 1,1,1,1,1,1,1,1, - 1,1,1,1,1,1,1,1 -}; - -static const int counts_3980[65] ICONST_ATTR_DEMAC = -{ - 0,19578,36160,48417,56323,60899,63265,64435, - 64971,65232,65351,65416,65447,65466,65476,65482, - 65485,65488,65490,65491,65492,65493,65494,65495, - 65496,65497,65498,65499,65500,65501,65502,65503, - 65504,65505,65506,65507,65508,65509,65510,65511, - 65512,65513,65514,65515,65516,65517,65518,65519, - 65520,65521,65522,65523,65524,65525,65526,65527, - 65528,65529,65530,65531,65532,65533,65534,65535, - 65536 -}; - -/* counts_diff_3980[i] = counts_3980[i+1] - counts_3980[i] */ - -static const int counts_diff_3980[64] ICONST_ATTR_DEMAC = -{ - 19578,16582,12257,7906,4576,2366,1170,536, - 261,119,65,31,19,10,6,3, - 3,2,1,1,1,1,1,1, - 1,1,1,1,1,1,1,1, - 1,1,1,1,1,1,1,1, - 1,1,1,1,1,1,1,1, - 1,1,1,1,1,1,1,1, - 1,1,1,1,1,1,1,1 -}; - -/* - -Range decoder adapted from rangecod.c included in: - - http://www.compressconsult.com/rangecoder/rngcod13.zip - - rangecod.c range encoding - - (c) Michael Schindler - 1997, 1998, 1999, 2000 - http://www.compressconsult.com/ - michael@compressconsult.com - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - -The encoding functions were removed, and functions turned into "static -inline" functions. Some minor cosmetic changes were made (e.g. turning -pre-processor symbols into upper-case, removing the rc parameter from -each function (and the RNGC macro)). - -*/ - -/* BITSTREAM READING FUNCTIONS */ - -/* We deal with the input data one byte at a time - to ensure - functionality on CPUs of any endianness regardless of any requirements - for aligned reads. -*/ - -static unsigned char* bytebuffer IBSS_ATTR_DEMAC; -static int bytebufferoffset IBSS_ATTR_DEMAC; - -static inline void skip_byte(void) -{ - bytebufferoffset--; - bytebuffer += bytebufferoffset & 4; - bytebufferoffset &= 3; -} - -static inline int read_byte(void) -{ - int ch = bytebuffer[bytebufferoffset]; - - skip_byte(); - - return ch; -} - -/* RANGE DECODING FUNCTIONS */ - -/* SIZE OF RANGE ENCODING CODE VALUES. */ - -#define CODE_BITS 32 -#define TOP_VALUE ((unsigned int)1 << (CODE_BITS-1)) -#define SHIFT_BITS (CODE_BITS - 9) -#define EXTRA_BITS ((CODE_BITS-2) % 8 + 1) -#define BOTTOM_VALUE (TOP_VALUE >> 8) - -struct rangecoder_t -{ - uint32_t low; /* low end of interval */ - uint32_t range; /* length of interval */ - uint32_t help; /* bytes_to_follow resp. intermediate value */ - unsigned int buffer; /* buffer for input/output */ -}; - -static struct rangecoder_t rc IBSS_ATTR_DEMAC; - -/* Start the decoder */ -static inline void range_start_decoding(void) -{ - rc.buffer = read_byte(); - rc.low = rc.buffer >> (8 - EXTRA_BITS); - rc.range = (uint32_t) 1 << EXTRA_BITS; -} - -static inline void range_dec_normalize(void) -{ - while (rc.range <= BOTTOM_VALUE) - { - rc.buffer = (rc.buffer << 8) | read_byte(); - rc.low = (rc.low << 8) | ((rc.buffer >> 1) & 0xff); - rc.range <<= 8; - } -} - -/* Calculate culmulative frequency for next symbol. Does NO update!*/ -/* tot_f is the total frequency */ -/* or: totf is (code_value)1<> shift; - return UDIV32(rc.low, rc.help); -} - - -/* Update decoding state */ -/* sy_f is the interval length (frequency of the symbol) */ -/* lt_f is the lower end (frequency sum of < symbols) */ -static inline void range_decode_update(int sy_f, int lt_f) -{ - rc.low -= rc.help * lt_f; - rc.range = rc.help * sy_f; -} - - -/* Decode a byte/short without modelling */ -static inline unsigned char decode_byte(void) -{ int tmp = range_decode_culshift(8); - range_decode_update( 1,tmp); - return tmp; -} - -static inline unsigned short range_decode_short(void) -{ int tmp = range_decode_culshift(16); - range_decode_update( 1,tmp); - return tmp; -} - -/* Decode n bits (n <= 16) without modelling - based on range_decode_short */ -static inline int range_decode_bits(int n) -{ int tmp = range_decode_culshift(n); - range_decode_update( 1,tmp); - return tmp; -} - - -/* Finish decoding */ -static inline void range_done_decoding(void) -{ range_dec_normalize(); /* normalize to use up all bytes */ -} - -/* - range_get_symbol_* functions based on main decoding loop in simple_d.c from - http://www.compressconsult.com/rangecoder/rngcod13.zip - (c) Michael Schindler -*/ - -static inline int range_get_symbol_3980(void) -{ - int symbol, cf; - - cf = range_decode_culshift(16); - - /* figure out the symbol inefficiently; a binary search would be much better */ - for (symbol = 0; counts_3980[symbol+1] <= cf; symbol++); - - range_decode_update(counts_diff_3980[symbol],counts_3980[symbol]); - - return symbol; -} - -static inline int range_get_symbol_3970(void) -{ - int symbol, cf; - - cf = range_decode_culshift(16); - - /* figure out the symbol inefficiently; a binary search would be much better */ - for (symbol = 0; counts_3970[symbol+1] <= cf; symbol++); - - range_decode_update(counts_diff_3970[symbol],counts_3970[symbol]); - - return symbol; -} - -/* MAIN DECODING FUNCTIONS */ - -struct rice_t -{ - uint32_t k; - uint32_t ksum; -}; - -static struct rice_t riceX IBSS_ATTR_DEMAC; -static struct rice_t riceY IBSS_ATTR_DEMAC; - -static inline void update_rice(struct rice_t* rice, int x) -{ - rice->ksum += ((x + 1) / 2) - ((rice->ksum + 16) >> 5); - - if (UNLIKELY(rice->k == 0)) { - rice->k = 1; - } else { - uint32_t lim = 1 << (rice->k + 4); - if (UNLIKELY(rice->ksum < lim)) { - rice->k--; - } else if (UNLIKELY(rice->ksum >= 2 * lim)) { - rice->k++; - } - } -} - -static inline int entropy_decode3980(struct rice_t* rice) -{ - int base, x, pivot, overflow; - - pivot = rice->ksum >> 5; - if (UNLIKELY(pivot == 0)) - pivot=1; - - overflow = range_get_symbol_3980(); - - if (UNLIKELY(overflow == (MODEL_ELEMENTS-1))) { - overflow = range_decode_short() << 16; - overflow |= range_decode_short(); - } - - if (pivot >= 0x10000) { - /* Codepath for 24-bit streams */ - int nbits, lo_bits, base_hi, base_lo; - - /* Count the number of bits in pivot */ - nbits = 17; /* We know there must be at least 17 bits */ - while ((pivot >> nbits) > 0) { nbits++; } - - /* base_lo is the low (nbits-16) bits of base - base_hi is the high 16 bits of base - */ - lo_bits = (nbits - 16); - - base_hi = range_decode_culfreq((pivot >> lo_bits) + 1); - range_decode_update(1, base_hi); - - base_lo = range_decode_culshift(lo_bits); - range_decode_update(1, base_lo); - - base = (base_hi << lo_bits) + base_lo; - } else { - /* Codepath for 16-bit streams */ - base = range_decode_culfreq(pivot); - range_decode_update(1, base); - } - - x = base + (overflow * pivot); - update_rice(rice, x); - - /* Convert to signed */ - if (x & 1) - return (x >> 1) + 1; - else - return -(x >> 1); -} - - -static inline int entropy_decode3970(struct rice_t* rice) -{ - int x, tmpk; - - int overflow = range_get_symbol_3970(); - - if (UNLIKELY(overflow == (MODEL_ELEMENTS - 1))) { - tmpk = range_decode_bits(5); - overflow = 0; - } else { - tmpk = (rice->k < 1) ? 0 : rice->k - 1; - } - - if (tmpk <= 16) { - x = range_decode_bits(tmpk); - } else { - x = range_decode_short(); - x |= (range_decode_bits(tmpk - 16) << 16); - } - x += (overflow << tmpk); - - update_rice(rice, x); - - /* Convert to signed */ - if (x & 1) - return (x >> 1) + 1; - else - return -(x >> 1); -} - -void init_entropy_decoder(struct ape_ctx_t* ape_ctx, - unsigned char* inbuffer, int* firstbyte, - int* bytesconsumed) -{ - bytebuffer = inbuffer; - bytebufferoffset = *firstbyte; - - /* Read the CRC */ - ape_ctx->CRC = read_byte(); - ape_ctx->CRC = (ape_ctx->CRC << 8) | read_byte(); - ape_ctx->CRC = (ape_ctx->CRC << 8) | read_byte(); - ape_ctx->CRC = (ape_ctx->CRC << 8) | read_byte(); - - /* Read the frame flags if they exist */ - ape_ctx->frameflags = 0; - if ((ape_ctx->fileversion > 3820) && (ape_ctx->CRC & 0x80000000)) { - ape_ctx->CRC &= ~0x80000000; - - ape_ctx->frameflags = read_byte(); - ape_ctx->frameflags = (ape_ctx->frameflags << 8) | read_byte(); - ape_ctx->frameflags = (ape_ctx->frameflags << 8) | read_byte(); - ape_ctx->frameflags = (ape_ctx->frameflags << 8) | read_byte(); - } - /* Keep a count of the blocks decoded in this frame */ - ape_ctx->blocksdecoded = 0; - - /* Initialise the rice structs */ - riceX.k = 10; - riceX.ksum = (1 << riceX.k) * 16; - riceY.k = 10; - riceY.ksum = (1 << riceY.k) * 16; - - /* The first 8 bits of input are ignored. */ - skip_byte(); - - range_start_decoding(); - - /* Return the new state of the buffer */ - *bytesconsumed = (intptr_t)bytebuffer - (intptr_t)inbuffer; - *firstbyte = bytebufferoffset; -} - -void ICODE_ATTR_DEMAC entropy_decode(struct ape_ctx_t* ape_ctx, - unsigned char* inbuffer, int* firstbyte, - int* bytesconsumed, - int32_t* decoded0, int32_t* decoded1, - int blockstodecode) -{ - bytebuffer = inbuffer; - bytebufferoffset = *firstbyte; - - ape_ctx->blocksdecoded += blockstodecode; - - if ((ape_ctx->frameflags & APE_FRAMECODE_LEFT_SILENCE) - && ((ape_ctx->frameflags & APE_FRAMECODE_RIGHT_SILENCE) - || (decoded1 == NULL))) { - /* We are pure silence, just memset the output buffer. */ - memset(decoded0, 0, blockstodecode * sizeof(int32_t)); - if (decoded1 != NULL) - memset(decoded1, 0, blockstodecode * sizeof(int32_t)); - } else { - if (ape_ctx->fileversion > 3970) { - while (LIKELY(blockstodecode--)) { - *(decoded0++) = entropy_decode3980(&riceY); - if (decoded1 != NULL) - *(decoded1++) = entropy_decode3980(&riceX); - } - } else { - while (LIKELY(blockstodecode--)) { - *(decoded0++) = entropy_decode3970(&riceY); - if (decoded1 != NULL) - *(decoded1++) = entropy_decode3970(&riceX); - } - } - } - - if (ape_ctx->blocksdecoded == ape_ctx->currentframeblocks) - { - range_done_decoding(); - } - - /* Return the new state of the buffer */ - *bytesconsumed = bytebuffer - inbuffer; - *firstbyte = bytebufferoffset; -} diff --git a/apps/codecs/demac/libdemac/entropy.h b/apps/codecs/demac/libdemac/entropy.h deleted file mode 100644 index fac2a44d99..0000000000 --- a/apps/codecs/demac/libdemac/entropy.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - -libdemac - A Monkey's Audio decoder - -$Id$ - -Copyright (C) Dave Chapman 2007 - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA - -*/ - -#ifndef _APE_ENTROPY_H -#define _APE_ENTROPY_H - -#include - -void init_entropy_decoder(struct ape_ctx_t* ape_ctx, - unsigned char* inbuffer, int* firstbyte, - int* bytesconsumed); - -void entropy_decode(struct ape_ctx_t* ape_ctx, - unsigned char* inbuffer, int* firstbyte, - int* bytesconsumed, - int32_t* decoded0, int32_t* decoded1, - int blockstodecode); - -#endif diff --git a/apps/codecs/demac/libdemac/filter.c b/apps/codecs/demac/libdemac/filter.c deleted file mode 100644 index 903885cf00..0000000000 --- a/apps/codecs/demac/libdemac/filter.c +++ /dev/null @@ -1,296 +0,0 @@ -/* - -libdemac - A Monkey's Audio decoder - -$Id$ - -Copyright (C) Dave Chapman 2007 - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA - -*/ - -#include -#include - -#include "demac.h" -#include "filter.h" -#include "demac_config.h" - -#if FILTER_BITS == 32 - -#if defined(CPU_ARM) && (ARM_ARCH == 4) -#include "vector_math32_armv4.h" -#else -#include "vector_math_generic.h" -#endif - -#else /* FILTER_BITS == 16 */ - -#ifdef CPU_COLDFIRE -#include "vector_math16_cf.h" -#elif defined(CPU_ARM) && (ARM_ARCH >= 7) -#include "vector_math16_armv7.h" -#elif defined(CPU_ARM) && (ARM_ARCH >= 6) -#include "vector_math16_armv6.h" -#elif defined(CPU_ARM) && (ARM_ARCH >= 5) -/* Assume all our ARMv5 targets are ARMv5te(j) */ -#include "vector_math16_armv5te.h" -#elif (defined(__i386__) || defined(__i486__)) && defined(__MMX__) \ - || defined(__x86_64__) -#include "vector_math16_mmx.h" -#else -#include "vector_math_generic.h" -#endif - -#endif /* FILTER_BITS */ - -struct filter_t { - filter_int* coeffs; /* ORDER entries */ - - /* We store all the filter delays in a single buffer */ - filter_int* history_end; - - filter_int* delay; - filter_int* adaptcoeffs; - - int avg; -}; - -/* We name the functions according to the ORDER and FRACBITS - pre-processor symbols and build multiple .o files from this .c file - - this increases code-size but gives the compiler more scope for - optimising the individual functions, as well as replacing a lot of - variables with constants. -*/ - -#if FRACBITS == 11 - #if ORDER == 16 - #define INIT_FILTER init_filter_16_11 - #define APPLY_FILTER apply_filter_16_11 - #elif ORDER == 64 - #define INIT_FILTER init_filter_64_11 - #define APPLY_FILTER apply_filter_64_11 - #endif -#elif FRACBITS == 13 - #define INIT_FILTER init_filter_256_13 - #define APPLY_FILTER apply_filter_256_13 -#elif FRACBITS == 10 - #define INIT_FILTER init_filter_32_10 - #define APPLY_FILTER apply_filter_32_10 -#elif FRACBITS == 15 - #define INIT_FILTER init_filter_1280_15 - #define APPLY_FILTER apply_filter_1280_15 -#endif - -/* Some macros to handle the fixed-point stuff */ - -/* Convert from (32-FRACBITS).FRACBITS fixed-point format to an - integer (rounding to nearest). */ -#define FP_HALF (1 << (FRACBITS - 1)) /* 0.5 in fixed-point format. */ -#define FP_TO_INT(x) ((x + FP_HALF) >> FRACBITS) /* round(x) */ - -#ifdef CPU_ARM -#if ARM_ARCH >= 6 -#define SATURATE(x) ({int __res; asm("ssat %0, #16, %1" : "=r"(__res) : "r"(x)); __res; }) -#else /* ARM_ARCH < 6 */ -/* Keeping the asr #31 outside of the asm allows loads to be scheduled between - it and the rest of the block on ARM9E, with the load's result latency filled - by the other calculations. */ -#define SATURATE(x) ({ \ - int __res = (x) >> 31; \ - asm volatile ( \ - "teq %0, %1, asr #15\n\t" \ - "moveq %0, %1\n\t" \ - "eorne %0, %0, #0xff\n\t" \ - "eorne %0, %0, #0x7f00" \ - : "+r" (__res) : "r" (x) : "cc" \ - ); \ - __res; \ -}) -#endif /* ARM_ARCH */ -#else /* CPU_ARM */ -#define SATURATE(x) (LIKELY((x) == (int16_t)(x)) ? (x) : ((x) >> 31) ^ 0x7FFF) -#endif - -/* Apply the filter with state f to count entries in data[] */ - -static void ICODE_ATTR_DEMAC do_apply_filter_3980(struct filter_t* f, - int32_t* data, int count) -{ - int res; - int absres; - -#ifdef PREPARE_SCALARPRODUCT - PREPARE_SCALARPRODUCT -#endif - - while(LIKELY(count--)) - { -#ifdef FUSED_VECTOR_MATH - if (LIKELY(*data != 0)) { - if (*data < 0) - res = vector_sp_add(f->coeffs, f->delay - ORDER, - f->adaptcoeffs - ORDER); - else - res = vector_sp_sub(f->coeffs, f->delay - ORDER, - f->adaptcoeffs - ORDER); - } else { - res = scalarproduct(f->coeffs, f->delay - ORDER); - } - res = FP_TO_INT(res); -#else - res = FP_TO_INT(scalarproduct(f->coeffs, f->delay - ORDER)); - - if (LIKELY(*data != 0)) { - if (*data < 0) - vector_add(f->coeffs, f->adaptcoeffs - ORDER); - else - vector_sub(f->coeffs, f->adaptcoeffs - ORDER); - } -#endif - - res += *data; - - *data++ = res; - - /* Update the output history */ - *f->delay++ = SATURATE(res); - - /* Version 3.98 and later files */ - - /* Update the adaption coefficients */ - absres = (res < 0 ? -res : res); - - if (UNLIKELY(absres > 3 * f->avg)) - *f->adaptcoeffs = ((res >> 25) & 64) - 32; - else if (3 * absres > 4 * f->avg) - *f->adaptcoeffs = ((res >> 26) & 32) - 16; - else if (LIKELY(absres > 0)) - *f->adaptcoeffs = ((res >> 27) & 16) - 8; - else - *f->adaptcoeffs = 0; - - f->avg += (absres - f->avg) / 16; - - f->adaptcoeffs[-1] >>= 1; - f->adaptcoeffs[-2] >>= 1; - f->adaptcoeffs[-8] >>= 1; - - f->adaptcoeffs++; - - /* Have we filled the history buffer? */ - if (UNLIKELY(f->delay == f->history_end)) { - memmove(f->coeffs + ORDER, f->delay - (ORDER*2), - (ORDER*2) * sizeof(filter_int)); - f->adaptcoeffs = f->coeffs + ORDER*2; - f->delay = f->coeffs + ORDER*3; - } - } -} - -static void ICODE_ATTR_DEMAC do_apply_filter_3970(struct filter_t* f, - int32_t* data, int count) -{ - int res; - -#ifdef PREPARE_SCALARPRODUCT - PREPARE_SCALARPRODUCT -#endif - - while(LIKELY(count--)) - { -#ifdef FUSED_VECTOR_MATH - if (LIKELY(*data != 0)) { - if (*data < 0) - res = vector_sp_add(f->coeffs, f->delay - ORDER, - f->adaptcoeffs - ORDER); - else - res = vector_sp_sub(f->coeffs, f->delay - ORDER, - f->adaptcoeffs - ORDER); - } else { - res = scalarproduct(f->coeffs, f->delay - ORDER); - } - res = FP_TO_INT(res); -#else - res = FP_TO_INT(scalarproduct(f->coeffs, f->delay - ORDER)); - - if (LIKELY(*data != 0)) { - if (*data < 0) - vector_add(f->coeffs, f->adaptcoeffs - ORDER); - else - vector_sub(f->coeffs, f->adaptcoeffs - ORDER); - } -#endif - - /* Convert res from (32-FRACBITS).FRACBITS fixed-point format to an - integer (rounding to nearest) and add the input value to - it */ - res += *data; - - *data++ = res; - - /* Update the output history */ - *f->delay++ = SATURATE(res); - - /* Version ??? to < 3.98 files (untested) */ - f->adaptcoeffs[0] = (res == 0) ? 0 : ((res >> 28) & 8) - 4; - f->adaptcoeffs[-4] >>= 1; - f->adaptcoeffs[-8] >>= 1; - - f->adaptcoeffs++; - - /* Have we filled the history buffer? */ - if (UNLIKELY(f->delay == f->history_end)) { - memmove(f->coeffs + ORDER, f->delay - (ORDER*2), - (ORDER*2) * sizeof(filter_int)); - f->adaptcoeffs = f->coeffs + ORDER*2; - f->delay = f->coeffs + ORDER*3; - } - } -} - -static struct filter_t filter[2] IBSS_ATTR_DEMAC; - -static void do_init_filter(struct filter_t* f, filter_int* buf) -{ - f->coeffs = buf; - f->history_end = buf + ORDER*3 + FILTER_HISTORY_SIZE; - - /* Init pointers */ - f->adaptcoeffs = f->coeffs + ORDER*2; - f->delay = f->coeffs + ORDER*3; - - /* Zero coefficients and history buffer */ - memset(f->coeffs, 0, ORDER*3 * sizeof(filter_int)); - - /* Zero the running average */ - f->avg = 0; -} - -void INIT_FILTER(filter_int* buf) -{ - do_init_filter(&filter[0], buf); - do_init_filter(&filter[1], buf + ORDER*3 + FILTER_HISTORY_SIZE); -} - -void ICODE_ATTR_DEMAC APPLY_FILTER(int fileversion, int channel, - int32_t* data, int count) -{ - if (fileversion >= 3980) - do_apply_filter_3980(&filter[channel], data, count); - else - do_apply_filter_3970(&filter[channel], data, count); -} diff --git a/apps/codecs/demac/libdemac/filter.h b/apps/codecs/demac/libdemac/filter.h deleted file mode 100644 index 609ea12496..0000000000 --- a/apps/codecs/demac/libdemac/filter.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - -libdemac - A Monkey's Audio decoder - -$Id$ - -Copyright (C) Dave Chapman 2007 - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA - -*/ - -#ifndef _APE_FILTER_H -#define _APE_FILTER_H - -#include "demac_config.h" - -void init_filter_16_11(filter_int* buf); -void apply_filter_16_11(int fileversion, int channel, - int32_t* decoded, int count); - -void init_filter_64_11(filter_int* buf); -void apply_filter_64_11(int fileversion, int channel, - int32_t* decoded, int count); - -void init_filter_32_10(filter_int* buf); -void apply_filter_32_10(int fileversion, int channel, - int32_t* decoded, int count); - -void init_filter_256_13(filter_int* buf); -void apply_filter_256_13(int fileversion, int channel, - int32_t* decoded, int count); - -void init_filter_1280_15(filter_int* buf); -void apply_filter_1280_15(int fileversion, int channel, - int32_t* decoded, int count); - -#endif diff --git a/apps/codecs/demac/libdemac/filter_1280_15.c b/apps/codecs/demac/libdemac/filter_1280_15.c deleted file mode 100644 index f2301fb02a..0000000000 --- a/apps/codecs/demac/libdemac/filter_1280_15.c +++ /dev/null @@ -1,32 +0,0 @@ -/* - -libdemac - A Monkey's Audio decoder - -$Id$ - -Copyright (C) Dave Chapman 2007 - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA - -*/ - -#include "demac_config.h" -#ifndef FILTER256_IRAM -#undef ICODE_ATTR_DEMAC -#define ICODE_ATTR_DEMAC -#endif -#define ORDER 1280 -#define FRACBITS 15 -#include "filter.c" diff --git a/apps/codecs/demac/libdemac/filter_16_11.c b/apps/codecs/demac/libdemac/filter_16_11.c deleted file mode 100644 index 94c56e247f..0000000000 --- a/apps/codecs/demac/libdemac/filter_16_11.c +++ /dev/null @@ -1,27 +0,0 @@ -/* - -libdemac - A Monkey's Audio decoder - -$Id$ - -Copyright (C) Dave Chapman 2007 - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA - -*/ - -#define ORDER 16 -#define FRACBITS 11 -#include "filter.c" diff --git a/apps/codecs/demac/libdemac/filter_256_13.c b/apps/codecs/demac/libdemac/filter_256_13.c deleted file mode 100644 index 9e4b9fcb13..0000000000 --- a/apps/codecs/demac/libdemac/filter_256_13.c +++ /dev/null @@ -1,32 +0,0 @@ -/* - -libdemac - A Monkey's Audio decoder - -$Id$ - -Copyright (C) Dave Chapman 2007 - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA - -*/ - -#include "demac_config.h" -#ifndef FILTER256_IRAM -#undef ICODE_ATTR_DEMAC -#define ICODE_ATTR_DEMAC -#endif -#define ORDER 256 -#define FRACBITS 13 -#include "filter.c" diff --git a/apps/codecs/demac/libdemac/filter_32_10.c b/apps/codecs/demac/libdemac/filter_32_10.c deleted file mode 100644 index 5ec85089db..0000000000 --- a/apps/codecs/demac/libdemac/filter_32_10.c +++ /dev/null @@ -1,27 +0,0 @@ -/* - -libdemac - A Monkey's Audio decoder - -$Id$ - -Copyright (C) Dave Chapman 2007 - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA - -*/ - -#define ORDER 32 -#define FRACBITS 10 -#include "filter.c" diff --git a/apps/codecs/demac/libdemac/filter_64_11.c b/apps/codecs/demac/libdemac/filter_64_11.c deleted file mode 100644 index cd74fa5f6b..0000000000 --- a/apps/codecs/demac/libdemac/filter_64_11.c +++ /dev/null @@ -1,27 +0,0 @@ -/* - -libdemac - A Monkey's Audio decoder - -$Id$ - -Copyright (C) Dave Chapman 2007 - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA - -*/ - -#define ORDER 64 -#define FRACBITS 11 -#include "filter.c" diff --git a/apps/codecs/demac/libdemac/parser.c b/apps/codecs/demac/libdemac/parser.c deleted file mode 100644 index 2af4a292b8..0000000000 --- a/apps/codecs/demac/libdemac/parser.c +++ /dev/null @@ -1,402 +0,0 @@ -/* - -libdemac - A Monkey's Audio decoder - -$Id$ - -Copyright (C) Dave Chapman 2007 - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA - -*/ - -#include -#include -#ifndef ROCKBOX -#include -#include -#include "inttypes.h" -#include -#include -#include -#endif - -#include "parser.h" - -#ifdef APE_MAX -#undef APE_MAX -#endif -#define APE_MAX(a,b) ((a)>(b)?(a):(b)) - - -static inline int16_t get_int16(unsigned char* buf) -{ - return(buf[0] | (buf[1] << 8)); -} - -static inline uint16_t get_uint16(unsigned char* buf) -{ - return(buf[0] | (buf[1] << 8)); -} - -static inline uint32_t get_uint32(unsigned char* buf) -{ - return(buf[0] | (buf[1] << 8) | (buf[2] << 16) | (buf[3] << 24)); -} - - -int ape_parseheaderbuf(unsigned char* buf, struct ape_ctx_t* ape_ctx) -{ - unsigned char* header; - - memset(ape_ctx,0,sizeof(struct ape_ctx_t)); - /* TODO: Skip any leading junk such as id3v2 tags */ - ape_ctx->junklength = 0; - - memcpy(ape_ctx->magic, buf, 4); - if (memcmp(ape_ctx->magic,"MAC ",4)!=0) - { - return -1; - } - - ape_ctx->fileversion = get_int16(buf + 4); - - if (ape_ctx->fileversion >= 3980) - { - ape_ctx->padding1 = get_int16(buf + 6); - ape_ctx->descriptorlength = get_uint32(buf + 8); - ape_ctx->headerlength = get_uint32(buf + 12); - ape_ctx->seektablelength = get_uint32(buf + 16); - ape_ctx->wavheaderlength = get_uint32(buf + 20); - ape_ctx->audiodatalength = get_uint32(buf + 24); - ape_ctx->audiodatalength_high = get_uint32(buf + 28); - ape_ctx->wavtaillength = get_uint32(buf + 32); - memcpy(ape_ctx->md5, buf + 36, 16); - - header = buf + ape_ctx->descriptorlength; - - /* Read header data */ - ape_ctx->compressiontype = get_uint16(header + 0); - ape_ctx->formatflags = get_uint16(header + 2); - ape_ctx->blocksperframe = get_uint32(header + 4); - ape_ctx->finalframeblocks = get_uint32(header + 8); - ape_ctx->totalframes = get_uint32(header + 12); - ape_ctx->bps = get_uint16(header + 16); - ape_ctx->channels = get_uint16(header + 18); - ape_ctx->samplerate = get_uint32(header + 20); - - ape_ctx->seektablefilepos = ape_ctx->junklength + - ape_ctx->descriptorlength + - ape_ctx->headerlength; - - ape_ctx->firstframe = ape_ctx->junklength + ape_ctx->descriptorlength + - ape_ctx->headerlength + ape_ctx->seektablelength + - ape_ctx->wavheaderlength; - } else { - ape_ctx->headerlength = 32; - ape_ctx->compressiontype = get_uint16(buf + 6); - ape_ctx->formatflags = get_uint16(buf + 8); - ape_ctx->channels = get_uint16(buf + 10); - ape_ctx->samplerate = get_uint32(buf + 12); - ape_ctx->wavheaderlength = get_uint32(buf + 16); - ape_ctx->totalframes = get_uint32(buf + 24); - ape_ctx->finalframeblocks = get_uint32(buf + 28); - - if (ape_ctx->formatflags & MAC_FORMAT_FLAG_HAS_PEAK_LEVEL) - { - ape_ctx->headerlength += 4; - } - - if (ape_ctx->formatflags & MAC_FORMAT_FLAG_HAS_SEEK_ELEMENTS) - { - ape_ctx->seektablelength = get_uint32(buf + ape_ctx->headerlength); - ape_ctx->seektablelength *= sizeof(int32_t); - ape_ctx->headerlength += 4; - } else { - ape_ctx->seektablelength = ape_ctx->totalframes * sizeof(int32_t); - } - - if (ape_ctx->formatflags & MAC_FORMAT_FLAG_8_BIT) - ape_ctx->bps = 8; - else if (ape_ctx->formatflags & MAC_FORMAT_FLAG_24_BIT) - ape_ctx->bps = 24; - else - ape_ctx->bps = 16; - - if (ape_ctx->fileversion >= 3950) - ape_ctx->blocksperframe = 73728 * 4; - else if ((ape_ctx->fileversion >= 3900) || (ape_ctx->fileversion >= 3800 && ape_ctx->compressiontype >= 4000)) - ape_ctx->blocksperframe = 73728; - else - ape_ctx->blocksperframe = 9216; - - ape_ctx->seektablefilepos = ape_ctx->junklength + ape_ctx->headerlength + - ape_ctx->wavheaderlength; - - ape_ctx->firstframe = ape_ctx->junklength + ape_ctx->headerlength + - ape_ctx->wavheaderlength + ape_ctx->seektablelength; - } - - ape_ctx->totalsamples = ape_ctx->finalframeblocks; - if (ape_ctx->totalframes > 1) - ape_ctx->totalsamples += ape_ctx->blocksperframe * (ape_ctx->totalframes-1); - - ape_ctx->numseekpoints = APE_MAX(ape_ctx->maxseekpoints, - ape_ctx->seektablelength / sizeof(int32_t)); - - return 0; -} - - -#ifndef ROCKBOX -/* Helper functions */ - -static int read_uint16(int fd, uint16_t* x) -{ - unsigned char tmp[2]; - int n; - - n = read(fd,tmp,2); - - if (n != 2) - return -1; - - *x = tmp[0] | (tmp[1] << 8); - - return 0; -} - -static int read_int16(int fd, int16_t* x) -{ - return read_uint16(fd, (uint16_t*)x); -} - -static int read_uint32(int fd, uint32_t* x) -{ - unsigned char tmp[4]; - int n; - - n = read(fd,tmp,4); - - if (n != 4) - return -1; - - *x = tmp[0] | (tmp[1] << 8) | (tmp[2] << 16) | (tmp[3] << 24); - - return 0; -} - -int ape_parseheader(int fd, struct ape_ctx_t* ape_ctx) -{ - int i,n; - - /* TODO: Skip any leading junk such as id3v2 tags */ - ape_ctx->junklength = 0; - - lseek(fd,ape_ctx->junklength,SEEK_SET); - - n = read(fd,&ape_ctx->magic,4); - if (n != 4) return -1; - - if (memcmp(ape_ctx->magic,"MAC ",4)!=0) - { - return -1; - } - - if (read_int16(fd,&ape_ctx->fileversion) < 0) - return -1; - - if (ape_ctx->fileversion >= 3980) - { - if (read_int16(fd,&ape_ctx->padding1) < 0) - return -1; - if (read_uint32(fd,&ape_ctx->descriptorlength) < 0) - return -1; - if (read_uint32(fd,&ape_ctx->headerlength) < 0) - return -1; - if (read_uint32(fd,&ape_ctx->seektablelength) < 0) - return -1; - if (read_uint32(fd,&ape_ctx->wavheaderlength) < 0) - return -1; - if (read_uint32(fd,&ape_ctx->audiodatalength) < 0) - return -1; - if (read_uint32(fd,&ape_ctx->audiodatalength_high) < 0) - return -1; - if (read_uint32(fd,&ape_ctx->wavtaillength) < 0) - return -1; - if (read(fd,&ape_ctx->md5,16) != 16) - return -1; - - /* Skip any unknown bytes at the end of the descriptor. This is for future - compatibility */ - if (ape_ctx->descriptorlength > 52) - lseek(fd,ape_ctx->descriptorlength - 52, SEEK_CUR); - - /* Read header data */ - if (read_uint16(fd,&ape_ctx->compressiontype) < 0) - return -1; - if (read_uint16(fd,&ape_ctx->formatflags) < 0) - return -1; - if (read_uint32(fd,&ape_ctx->blocksperframe) < 0) - return -1; - if (read_uint32(fd,&ape_ctx->finalframeblocks) < 0) - return -1; - if (read_uint32(fd,&ape_ctx->totalframes) < 0) - return -1; - if (read_uint16(fd,&ape_ctx->bps) < 0) - return -1; - if (read_uint16(fd,&ape_ctx->channels) < 0) - return -1; - if (read_uint32(fd,&ape_ctx->samplerate) < 0) - return -1; - } else { - ape_ctx->descriptorlength = 0; - ape_ctx->headerlength = 32; - - if (read_uint16(fd,&ape_ctx->compressiontype) < 0) - return -1; - if (read_uint16(fd,&ape_ctx->formatflags) < 0) - return -1; - if (read_uint16(fd,&ape_ctx->channels) < 0) - return -1; - if (read_uint32(fd,&ape_ctx->samplerate) < 0) - return -1; - if (read_uint32(fd,&ape_ctx->wavheaderlength) < 0) - return -1; - if (read_uint32(fd,&ape_ctx->wavtaillength) < 0) - return -1; - if (read_uint32(fd,&ape_ctx->totalframes) < 0) - return -1; - if (read_uint32(fd,&ape_ctx->finalframeblocks) < 0) - return -1; - - if (ape_ctx->formatflags & MAC_FORMAT_FLAG_HAS_PEAK_LEVEL) - { - lseek(fd, 4, SEEK_CUR); /* Skip the peak level */ - ape_ctx->headerlength += 4; - } - - if (ape_ctx->formatflags & MAC_FORMAT_FLAG_HAS_SEEK_ELEMENTS) - { - if (read_uint32(fd,&ape_ctx->seektablelength) < 0) - return -1; - ape_ctx->headerlength += 4; - ape_ctx->seektablelength *= sizeof(int32_t); - } else { - ape_ctx->seektablelength = ape_ctx->totalframes * sizeof(int32_t); - } - - if (ape_ctx->formatflags & MAC_FORMAT_FLAG_8_BIT) - ape_ctx->bps = 8; - else if (ape_ctx->formatflags & MAC_FORMAT_FLAG_24_BIT) - ape_ctx->bps = 24; - else - ape_ctx->bps = 16; - - if (ape_ctx->fileversion >= 3950) - ape_ctx->blocksperframe = 73728 * 4; - else if ((ape_ctx->fileversion >= 3900) || (ape_ctx->fileversion >= 3800 && ape_ctx->compressiontype >= 4000)) - ape_ctx->blocksperframe = 73728; - else - ape_ctx->blocksperframe = 9216; - - /* Skip any stored wav header */ - if (!(ape_ctx->formatflags & MAC_FORMAT_FLAG_CREATE_WAV_HEADER)) - { - lseek(fd, ape_ctx->wavheaderlength, SEEK_CUR); - } - } - - ape_ctx->totalsamples = ape_ctx->finalframeblocks; - if (ape_ctx->totalframes > 1) - ape_ctx->totalsamples += ape_ctx->blocksperframe * (ape_ctx->totalframes-1); - - if (ape_ctx->seektablelength > 0) - { - ape_ctx->seektable = malloc(ape_ctx->seektablelength); - if (ape_ctx->seektable == NULL) - return -1; - for (i=0; i < ape_ctx->seektablelength / sizeof(uint32_t); i++) - { - if (read_uint32(fd,&ape_ctx->seektable[i]) < 0) - { - free(ape_ctx->seektable); - return -1; - } - } - } - - ape_ctx->firstframe = ape_ctx->junklength + ape_ctx->descriptorlength + - ape_ctx->headerlength + ape_ctx->seektablelength + - ape_ctx->wavheaderlength; - - return 0; -} - -void ape_dumpinfo(struct ape_ctx_t* ape_ctx) -{ - int i; - - printf("Descriptor Block:\n\n"); - printf("magic = \"%c%c%c%c\"\n", - ape_ctx->magic[0],ape_ctx->magic[1], - ape_ctx->magic[2],ape_ctx->magic[3]); - printf("fileversion = %d\n",ape_ctx->fileversion); - printf("descriptorlength = %d\n",ape_ctx->descriptorlength); - printf("headerlength = %d\n",ape_ctx->headerlength); - printf("seektablelength = %d\n",ape_ctx->seektablelength); - printf("wavheaderlength = %d\n",ape_ctx->wavheaderlength); - printf("audiodatalength = %d\n",ape_ctx->audiodatalength); - printf("audiodatalength_high = %d\n",ape_ctx->audiodatalength_high); - printf("wavtaillength = %d\n",ape_ctx->wavtaillength); - printf("md5 = "); - for (i = 0; i < 16; i++) - printf("%02x",ape_ctx->md5[i]); - printf("\n"); - - printf("\nHeader Block:\n\n"); - - printf("compressiontype = %d\n",ape_ctx->compressiontype); - printf("formatflags = %d\n",ape_ctx->formatflags); - printf("blocksperframe = %d\n",ape_ctx->blocksperframe); - printf("finalframeblocks = %d\n",ape_ctx->finalframeblocks); - printf("totalframes = %d\n",ape_ctx->totalframes); - printf("bps = %d\n",ape_ctx->bps); - printf("channels = %d\n",ape_ctx->channels); - printf("samplerate = %d\n",ape_ctx->samplerate); - - printf("\nSeektable\n\n"); - if ((ape_ctx->seektablelength / sizeof(uint32_t)) != ape_ctx->totalframes) - { - printf("No seektable\n"); - } - else - { - for ( i = 0; i < ape_ctx->seektablelength / sizeof(uint32_t) ; i++) - { - if (i < ape_ctx->totalframes-1) { - printf("%8d %d (%d bytes)\n",i,ape_ctx->seektable[i],ape_ctx->seektable[i+1]-ape_ctx->seektable[i]); - } else { - printf("%8d %d\n",i,ape_ctx->seektable[i]); - } - } - } - printf("\nCalculated information:\n\n"); - printf("junklength = %d\n",ape_ctx->junklength); - printf("firstframe = %d\n",ape_ctx->firstframe); - printf("totalsamples = %d\n",ape_ctx->totalsamples); -} - -#endif /* !ROCKBOX */ diff --git a/apps/codecs/demac/libdemac/parser.h b/apps/codecs/demac/libdemac/parser.h deleted file mode 100644 index 6f07deac12..0000000000 --- a/apps/codecs/demac/libdemac/parser.h +++ /dev/null @@ -1,137 +0,0 @@ -/* - -libdemac - A Monkey's Audio decoder - -$Id$ - -Copyright (C) Dave Chapman 2007 - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA - -*/ - -#ifndef _APE_PARSER_H -#define _APE_PARSER_H - -#include -#include "demac_config.h" - -/* The earliest and latest file formats supported by this library */ -#define APE_MIN_VERSION 3970 -#define APE_MAX_VERSION 3990 - -#define MAC_FORMAT_FLAG_8_BIT 1 // is 8-bit [OBSOLETE] -#define MAC_FORMAT_FLAG_CRC 2 // uses the new CRC32 error detection [OBSOLETE] -#define MAC_FORMAT_FLAG_HAS_PEAK_LEVEL 4 // uint32 nPeakLevel after the header [OBSOLETE] -#define MAC_FORMAT_FLAG_24_BIT 8 // is 24-bit [OBSOLETE] -#define MAC_FORMAT_FLAG_HAS_SEEK_ELEMENTS 16 // has the number of seek elements after the peak level -#define MAC_FORMAT_FLAG_CREATE_WAV_HEADER 32 // create the wave header on decompression (not stored) - - -/* Special frame codes: - - MONO_SILENCE - All PCM samples in frame are zero (mono streams only) - LEFT_SILENCE - All PCM samples for left channel in frame are zero (stereo streams) - RIGHT_SILENCE - All PCM samples for left channel in frame are zero (stereo streams) - PSEUDO_STEREO - Left and Right channels are identical - -*/ - -#define APE_FRAMECODE_MONO_SILENCE 1 -#define APE_FRAMECODE_LEFT_SILENCE 1 /* same as mono */ -#define APE_FRAMECODE_RIGHT_SILENCE 2 -#define APE_FRAMECODE_STEREO_SILENCE 3 /* combined */ -#define APE_FRAMECODE_PSEUDO_STEREO 4 - -#define PREDICTOR_ORDER 8 -/* Total size of all predictor histories - 50 * sizeof(int32_t) */ -#define PREDICTOR_SIZE 50 - - -/* NOTE: This struct is used in predictor-arm.S - any updates need to - be reflected there. */ - -struct predictor_t -{ - /* Filter histories */ - int32_t* buf; - - int32_t YlastA; - int32_t XlastA; - - /* NOTE: The order of the next four fields is important for - predictor-arm.S */ - int32_t YfilterB; - int32_t XfilterA; - int32_t XfilterB; - int32_t YfilterA; - - /* Adaption co-efficients */ - int32_t YcoeffsA[4]; - int32_t XcoeffsA[4]; - int32_t YcoeffsB[5]; - int32_t XcoeffsB[5]; - int32_t historybuffer[PREDICTOR_HISTORY_SIZE + PREDICTOR_SIZE]; -}; - -struct ape_ctx_t -{ - /* Derived fields */ - uint32_t junklength; - uint32_t firstframe; - uint32_t totalsamples; - - /* Info from Descriptor Block */ - char magic[4]; - int16_t fileversion; - int16_t padding1; - uint32_t descriptorlength; - uint32_t headerlength; - uint32_t seektablelength; - uint32_t wavheaderlength; - uint32_t audiodatalength; - uint32_t audiodatalength_high; - uint32_t wavtaillength; - uint8_t md5[16]; - - /* Info from Header Block */ - uint16_t compressiontype; - uint16_t formatflags; - uint32_t blocksperframe; - uint32_t finalframeblocks; - uint32_t totalframes; - uint16_t bps; - uint16_t channels; - uint32_t samplerate; - - /* Seektable */ - uint32_t* seektable; /* Seektable buffer */ - uint32_t maxseekpoints; /* Max seekpoints we can store (size of seektable buffer) */ - uint32_t numseekpoints; /* Number of seekpoints */ - int seektablefilepos; /* Location in .ape file of seektable */ - - /* Decoder state */ - uint32_t CRC; - int frameflags; - int currentframeblocks; - int blocksdecoded; - struct predictor_t predictor; -}; - -int ape_parseheader(int fd, struct ape_ctx_t* ape_ctx); -int ape_parseheaderbuf(unsigned char* buf, struct ape_ctx_t* ape_ctx); -void ape_dumpinfo(struct ape_ctx_t* ape_ctx); - -#endif diff --git a/apps/codecs/demac/libdemac/predictor-arm.S b/apps/codecs/demac/libdemac/predictor-arm.S deleted file mode 100644 index 92a78ed9b4..0000000000 --- a/apps/codecs/demac/libdemac/predictor-arm.S +++ /dev/null @@ -1,702 +0,0 @@ -/* - -libdemac - A Monkey's Audio decoder - -$Id$ - -Copyright (C) Dave Chapman 2007 - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA - -*/ -#include "demac_config.h" - - .section ICODE_SECTION_DEMAC_ARM,"ax",%progbits - - .align 2 - -/* NOTE: The following need to be kept in sync with parser.h */ - -#define YDELAYA 200 -#define YDELAYB 168 -#define XDELAYA 136 -#define XDELAYB 104 -#define YADAPTCOEFFSA 72 -#define XADAPTCOEFFSA 56 -#define YADAPTCOEFFSB 40 -#define XADAPTCOEFFSB 20 - -/* struct predictor_t members: */ -#define buf 0 /* int32_t* buf */ - -#define YlastA 4 /* int32_t YlastA; */ -#define XlastA 8 /* int32_t XlastA; */ - -#define YfilterB 12 /* int32_t YfilterB; */ -#define XfilterA 16 /* int32_t XfilterA; */ - -#define XfilterB 20 /* int32_t XfilterB; */ -#define YfilterA 24 /* int32_t YfilterA; */ - -#define YcoeffsA 28 /* int32_t YcoeffsA[4]; */ -#define XcoeffsA 44 /* int32_t XcoeffsA[4]; */ -#define YcoeffsB 60 /* int32_t YcoeffsB[5]; */ -#define XcoeffsB 80 /* int32_t XcoeffsB[5]; */ - -#define historybuffer 100 /* int32_t historybuffer[] */ - -@ Macro for loading 2 registers, for various ARM versions. -@ Registers must start with an even register, and must be consecutive. - -.macro LDR2OFS reg1, reg2, base, offset -#if ARM_ARCH >= 6 - ldrd \reg1, [\base, \offset] -#else /* ARM_ARCH < 6 */ -#ifdef CPU_ARM7TDMI - add \reg1, \base, \offset - ldmia \reg1, {\reg1, \reg2} -#else /* ARM9 (v4 and v5) is faster this way */ - ldr \reg1, [\base, \offset] - ldr \reg2, [\base, \offset+4] -#endif -#endif /* ARM_ARCH */ -.endm - -@ Macro for storing 2 registers, for various ARM versions. -@ Registers must start with an even register, and must be consecutive. - -.macro STR2OFS reg1, reg2, base, offset -#if ARM_ARCH >= 6 - strd \reg1, [\base, \offset] -#else - str \reg1, [\base, \offset] - str \reg2, [\base, \offset+4] -#endif -.endm - - .global predictor_decode_stereo - .type predictor_decode_stereo,%function - -@ Register usage: -@ -@ r0-r11 - scratch -@ r12 - struct predictor_t* p -@ r14 - int32_t* p->buf - -@ void predictor_decode_stereo(struct predictor_t* p, -@ int32_t* decoded0, -@ int32_t* decoded1, -@ int count) - -predictor_decode_stereo: - stmdb sp!, {r1-r11, lr} - - @ r1 (decoded0) is [sp] - @ r2 (decoded1) is [sp, #4] - @ r3 (count) is [sp, #8] - - mov r12, r0 @ r12 := p - ldr r14, [r0] @ r14 := p->buf - -loop: - -@@@@@@@@@@@@@@@@@@@@@@@@@@@ PREDICTOR Y - -@ Predictor Y, Filter A - - ldr r11, [r12, #YlastA] @ r11 := p->YlastA - - add r2, r14, #YDELAYA-12 @ r2 := &p->buf[YDELAYA-3] - ldmia r2, {r2, r3, r10} @ r2 := p->buf[YDELAYA-3] - @ r3 := p->buf[YDELAYA-2] - @ r10 := p->buf[YDELAYA-1] - - add r6, r12, #YcoeffsA - ldmia r6, {r6 - r9} @ r6 := p->YcoeffsA[0] - @ r7 := p->YcoeffsA[1] - @ r8 := p->YcoeffsA[2] - @ r9 := p->YcoeffsA[3] - - subs r10, r11, r10 @ r10 := r11 - r10 - - STR2OFS r10, r11, r14, #YDELAYA-4 - @ p->buf[YDELAYA-1] = r10 - @ p->buf[YDELAYA] = r11 - - mul r0, r11, r6 @ r0 := p->buf[YDELAYA] * p->YcoeffsA[0] - mla r0, r10, r7, r0 @ r0 += p->buf[YDELAYA-1] * p->YcoeffsA[1] - mla r0, r3, r8, r0 @ r0 += p->buf[YDELAYA-2] * p->YcoeffsA[2] - mla r0, r2, r9, r0 @ r0 += p->buf[YDELAYA-3] * p->YcoeffsA[3] - - @ flags were set above, in the subs instruction - mvngt r10, #0 - movlt r10, #1 @ r10 := SIGN(r10) (see .c for SIGN macro) - - cmp r11, #0 - mvngt r11, #0 - movlt r11, #1 @ r11 := SIGN(r11) (see .c for SIGN macro) - - STR2OFS r10, r11, r14, #YADAPTCOEFFSA-4 - @ p->buf[YADAPTCOEFFSA-1] := r10 - @ p->buf[YADAPTCOEFFSA] := r11 - - @ NOTE: r0 now contains predictionA - don't overwrite. - -@ Predictor Y, Filter B - - LDR2OFS r6, r7, r12, #YfilterB @ r6 := p->YfilterB - @ r7 := p->XfilterA - - add r2, r14, #YDELAYB-16 @ r2 := &p->buf[YDELAYB-4] - ldmia r2, {r2 - r4, r10} @ r2 := p->buf[YDELAYB-4] - @ r3 := p->buf[YDELAYB-3] - @ r4 := p->buf[YDELAYB-2] - @ r10 := p->buf[YDELAYB-1] - - rsb r6, r6, r6, lsl #5 @ r6 := r6 * 32 - r6 ( == r6*31) - sub r11, r7, r6, asr #5 @ r11 (p->buf[YDELAYB]) := r7 - (r6 >> 5) - - str r7, [r12, #YfilterB] @ p->YfilterB := r7 (p->XfilterA) - - add r5, r12, #YcoeffsB - ldmia r5, {r5 - r9} @ r5 := p->YcoeffsB[0] - @ r6 := p->YcoeffsB[1] - @ r7 := p->YcoeffsB[2] - @ r8 := p->YcoeffsB[3] - @ r9 := p->YcoeffsB[4] - - subs r10, r11, r10 @ r10 := r11 - r10 - - STR2OFS r10, r11, r14, #YDELAYB-4 - @ p->buf[YDELAYB-1] = r10 - @ p->buf[YDELAYB] = r11 - - mul r1, r11, r5 @ r1 := p->buf[YDELAYB] * p->YcoeffsB[0] - mla r1, r10, r6, r1 @ r1 += p->buf[YDELAYB-1] * p->YcoeffsB[1] - mla r1, r4, r7, r1 @ r1 += p->buf[YDELAYB-2] * p->YcoeffsB[2] - mla r1, r3, r8, r1 @ r1 += p->buf[YDELAYB-3] * p->YcoeffsB[3] - mla r1, r2, r9, r1 @ r1 += p->buf[YDELAYB-4] * p->YcoeffsB[4] - - @ flags were set above, in the subs instruction - mvngt r10, #0 - movlt r10, #1 @ r10 := SIGN(r10) (see .c for SIGN macro) - - cmp r11, #0 - mvngt r11, #0 - movlt r11, #1 @ r11 := SIGN(r11) (see .c for SIGN macro) - - STR2OFS r10, r11, r14, #YADAPTCOEFFSB-4 - @ p->buf[YADAPTCOEFFSB-1] := r10 - @ p->buf[YADAPTCOEFFSB] := r11 - - @ r0 still contains predictionA - @ r1 contains predictionB - - @ Finish Predictor Y - - ldr r2, [sp] @ r2 := decoded0 - add r0, r0, r1, asr #1 @ r0 := r0 + (r1 >> 1) - ldr r4, [r12, #YfilterA] @ r4 := p->YfilterA - ldr r3, [r2] @ r3 := *decoded0 - rsb r4, r4, r4, lsl #5 @ r4 := r4 * 32 - r4 ( == r4*31) - add r1, r3, r0, asr #10 @ r1 := r3 + (r0 >> 10) - str r1, [r12, #YlastA] @ p->YlastA := r1 - add r1, r1, r4, asr #5 @ r1 := r1 + (r4 >> 5) - str r1, [r12, #YfilterA] @ p->YfilterA := r1 - - @ r1 contains p->YfilterA - @ r2 contains decoded0 - @ r3 contains *decoded0 - - @ r5, r6, r7, r8, r9 contain p->YcoeffsB[0..4] - @ r10, r11 contain p->buf[YADAPTCOEFFSB-1] and p->buf[YADAPTCOEFFSB] - - str r1, [r2], #4 @ *(decoded0++) := r1 (p->YfilterA) - str r2, [sp] @ save decoded0 - cmp r3, #0 - beq 3f - - add r2, r14, #YADAPTCOEFFSB-16 - ldmia r2, {r2 - r4} @ r2 := p->buf[YADAPTCOEFFSB-4] - @ r3 := p->buf[YADAPTCOEFFSB-3] - @ r4 := p->buf[YADAPTCOEFFSB-2] - blt 1f - - @ *decoded0 > 0 - - sub r5, r5, r11 @ r5 := p->YcoeffsB[0] - p->buf[YADAPTCOEFFSB] - sub r6, r6, r10 @ r6 := p->YcoeffsB[1] - p->buf[YADAPTCOEFFSB-1] - sub r9, r9, r2 @ r9 := p->YcoeffsB[4] - p->buf[YADAPTCOEFFSB-4] - sub r8, r8, r3 @ r8 := p->YcoeffsB[3] - p->buf[YADAPTCOEFFSB-3] - sub r7, r7, r4 @ r7 := p->YcoeffsB[2] - p->buf[YADAPTCOEFFSB-2] - - add r0, r12, #YcoeffsB - stmia r0, {r5 - r9} @ Save p->YcoeffsB[] - - add r1, r12, #YcoeffsA - ldmia r1, {r2 - r5} @ r2 := p->YcoeffsA[0] - @ r3 := p->YcoeffsA[1] - @ r4 := p->YcoeffsA[2] - @ r5 := p->YcoeffsA[3] - - add r6, r14, #YADAPTCOEFFSA-12 - ldmia r6, {r6 - r9} @ r6 := p->buf[YADAPTCOEFFSA-3] - @ r7 := p->buf[YADAPTCOEFFSA-2] - @ r8 := p->buf[YADAPTCOEFFSA-1] - @ r9 := p->buf[YADAPTCOEFFSA] - - sub r5, r5, r6 @ r5 := p->YcoeffsA[3] - p->buf[YADAPTCOEFFSA-3] - sub r4, r4, r7 @ r4 := p->YcoeffsA[2] - p->buf[YADAPTCOEFFSA-2] - sub r3, r3, r8 @ r3 := p->YcoeffsA[1] - p->buf[YADAPTCOEFFSA-1] - sub r2, r2, r9 @ r2 := p->YcoeffsA[0] - p->buf[YADAPTCOEFFSA] - - b 2f - - -1: @ *decoded0 < 0 - - add r5, r5, r11 @ r5 := p->YcoeffsB[0] + p->buf[YADAPTCOEFFSB] - add r6, r6, r10 @ r6 := p->YcoeffsB[1] + p->buf[YADAPTCOEFFSB-1] - add r9, r9, r2 @ r9 := p->YcoeffsB[4] + p->buf[YADAPTCOEFFSB-4] - add r8, r8, r3 @ r9 := p->YcoeffsB[3] + p->buf[YADAPTCOEFFSB-3] - add r7, r7, r4 @ r8 := p->YcoeffsB[2] + p->buf[YADAPTCOEFFSB-2] - - add r0, r12, #YcoeffsB - stmia r0, {r5 - r9} @ Save p->YcoeffsB[] - - add r1, r12, #YcoeffsA - ldmia r1, {r2 - r5} @ r2 := p->YcoeffsA[0] - @ r3 := p->YcoeffsA[1] - @ r4 := p->YcoeffsA[2] - @ r5 := p->YcoeffsA[3] - - add r6, r14, #YADAPTCOEFFSA-12 - ldmia r6, {r6 - r9} @ r6 := p->buf[YADAPTCOEFFSA-3] - @ r7 := p->buf[YADAPTCOEFFSA-2] - @ r8 := p->buf[YADAPTCOEFFSA-1] - @ r9 := p->buf[YADAPTCOEFFSA] - - add r5, r5, r6 @ r5 := p->YcoeffsA[3] + p->buf[YADAPTCOEFFSA-3] - add r4, r4, r7 @ r4 := p->YcoeffsA[2] + p->buf[YADAPTCOEFFSA-2] - add r3, r3, r8 @ r3 := p->YcoeffsA[1] + p->buf[YADAPTCOEFFSA-1] - add r2, r2, r9 @ r2 := p->YcoeffsA[0] + p->buf[YADAPTCOEFFSA] - -2: - stmia r1, {r2 - r5} @ Save p->YcoeffsA - -3: - -@@@@@@@@@@@@@@@@@@@@@@@@@@@ PREDICTOR X - -@ Predictor X, Filter A - - ldr r11, [r12, #XlastA] @ r11 := p->XlastA - - add r2, r14, #XDELAYA-12 @ r2 := &p->buf[XDELAYA-3] - ldmia r2, {r2, r3, r10} @ r2 := p->buf[XDELAYA-3] - @ r3 := p->buf[XDELAYA-2] - @ r10 := p->buf[XDELAYA-1] - - add r6, r12, #XcoeffsA - ldmia r6, {r6 - r9} @ r6 := p->XcoeffsA[0] - @ r7 := p->XcoeffsA[1] - @ r8 := p->XcoeffsA[2] - @ r9 := p->XcoeffsA[3] - - subs r10, r11, r10 @ r10 := r11 - r10 - - STR2OFS r10, r11, r14, #XDELAYA-4 - @ p->buf[XDELAYA-1] = r10 - @ p->buf[XDELAYA] = r11 - - mul r0, r11, r6 @ r0 := p->buf[XDELAYA] * p->XcoeffsA[0] - mla r0, r10, r7, r0 @ r0 += p->buf[XDELAYA-1] * p->XcoeffsA[1] - mla r0, r3, r8, r0 @ r0 += p->buf[XDELAYA-2] * p->XcoeffsA[2] - mla r0, r2, r9, r0 @ r0 += p->buf[XDELAYA-3] * p->XcoeffsA[3] - - @ flags were set above, in the subs instruction - mvngt r10, #0 - movlt r10, #1 @ r10 := SIGN(r10) (see .c for SIGN macro) - - cmp r11, #0 - mvngt r11, #0 - movlt r11, #1 @ r11 := SIGN(r11) (see .c for SIGN macro) - - STR2OFS r10, r11, r14, #XADAPTCOEFFSA-4 - @ p->buf[XADAPTCOEFFSA-1] := r10 - @ p->buf[XADAPTCOEFFSA] := r11 - - @ NOTE: r0 now contains predictionA - don't overwrite. - -@ Predictor X, Filter B - - LDR2OFS r6, r7, r12, #XfilterB @ r6 := p->XfilterB - @ r7 := p->YfilterA - - add r2, r14, #XDELAYB-16 @ r2 := &p->buf[XDELAYB-4] - ldmia r2, {r2 - r4, r10} @ r2 := p->buf[XDELAYB-4] - @ r3 := p->buf[XDELAYB-3] - @ r4 := p->buf[XDELAYB-2] - @ r10 := p->buf[XDELAYB-1] - - rsb r6, r6, r6, lsl #5 @ r6 := r2 * 32 - r6 ( == r6*31) - sub r11, r7, r6, asr #5 @ r11 (p->buf[XDELAYB]) := r7 - (r6 >> 5) - - str r7, [r12, #XfilterB] @ p->XfilterB := r7 (p->YfilterA) - - add r5, r12, #XcoeffsB - ldmia r5, {r5 - r9} @ r5 := p->XcoeffsB[0] - @ r6 := p->XcoeffsB[1] - @ r7 := p->XcoeffsB[2] - @ r8 := p->XcoeffsB[3] - @ r9 := p->XcoeffsB[4] - - subs r10, r11, r10 @ r10 := r11 - r10 - - STR2OFS r10, r11, r14, #XDELAYB-4 - @ p->buf[XDELAYB-1] = r10 - @ p->buf[XDELAYB] = r11 - - mul r1, r11, r5 @ r1 := p->buf[XDELAYB] * p->XcoeffsB[0] - mla r1, r10, r6, r1 @ r1 += p->buf[XDELAYB-1] * p->XcoeffsB[1] - mla r1, r4, r7, r1 @ r1 += p->buf[XDELAYB-2] * p->XcoeffsB[2] - mla r1, r3, r8, r1 @ r1 += p->buf[XDELAYB-3] * p->XcoeffsB[3] - mla r1, r2, r9, r1 @ r1 += p->buf[XDELAYB-4] * p->XcoeffsB[4] - - @ flags were set above, in the subs instruction - mvngt r10, #0 - movlt r10, #1 @ r10 := SIGN(r10) (see .c for SIGN macro) - - cmp r11, #0 - mvngt r11, #0 - movlt r11, #1 @ r11 := SIGN(r11) (see .c for SIGN macro) - - STR2OFS r10, r11, r14, #XADAPTCOEFFSB-4 - @ p->buf[XADAPTCOEFFSB-1] := r10 - @ p->buf[XADAPTCOEFFSB] := r11 - - @ r0 still contains predictionA - @ r1 contains predictionB - - @ Finish Predictor X - - ldr r2, [sp, #4] @ r2 := decoded1 - add r0, r0, r1, asr #1 @ r0 := r0 + (r1 >> 1) - ldr r4, [r12, #XfilterA] @ r4 := p->XfilterA - ldr r3, [r2] @ r3 := *decoded1 - rsb r4, r4, r4, lsl #5 @ r4 := r4 * 32 - r4 ( == r4*31) - add r1, r3, r0, asr #10 @ r1 := r3 + (r0 >> 10) - str r1, [r12, #XlastA] @ p->XlastA := r1 - add r1, r1, r4, asr #5 @ r1 := r1 + (r4 >> 5) - str r1, [r12, #XfilterA] @ p->XfilterA := r1 - - @ r1 contains p->XfilterA - @ r2 contains decoded1 - @ r3 contains *decoded1 - - @ r5, r6, r7, r8, r9 contain p->XcoeffsB[0..4] - @ r10, r11 contain p->buf[XADAPTCOEFFSB-1] and p->buf[XADAPTCOEFFSB] - - str r1, [r2], #4 @ *(decoded1++) := r1 (p->XfilterA) - str r2, [sp, #4] @ save decoded1 - cmp r3, #0 - beq 3f - - add r2, r14, #XADAPTCOEFFSB-16 - ldmia r2, {r2 - r4} @ r2 := p->buf[XADAPTCOEFFSB-4] - @ r3 := p->buf[XADAPTCOEFFSB-3] - @ r4 := p->buf[XADAPTCOEFFSB-2] - blt 1f - - @ *decoded1 > 0 - - sub r5, r5, r11 @ r5 := p->XcoeffsB[0] - p->buf[XADAPTCOEFFSB] - sub r6, r6, r10 @ r6 := p->XcoeffsB[1] - p->buf[XADAPTCOEFFSB-1] - sub r9, r9, r2 @ r9 := p->XcoeffsB[4] - p->buf[XADAPTCOEFFSB-4] - sub r8, r8, r3 @ r8 := p->XcoeffsB[3] - p->buf[XADAPTCOEFFSB-3] - sub r7, r7, r4 @ r7 := p->XcoeffsB[2] - p->buf[XADAPTCOEFFSB-2] - - add r0, r12, #XcoeffsB - stmia r0, {r5 - r9} @ Save p->XcoeffsB[] - - add r1, r12, #XcoeffsA - ldmia r1, {r2 - r5} @ r2 := p->XcoeffsA[0] - @ r3 := p->XcoeffsA[1] - @ r4 := p->XcoeffsA[2] - @ r5 := p->XcoeffsA[3] - - add r6, r14, #XADAPTCOEFFSA-12 - ldmia r6, {r6 - r9} @ r6 := p->buf[XADAPTCOEFFSA-3] - @ r7 := p->buf[XADAPTCOEFFSA-2] - @ r8 := p->buf[XADAPTCOEFFSA-1] - @ r9 := p->buf[XADAPTCOEFFSA] - - sub r5, r5, r6 @ r5 := p->XcoeffsA[3] - p->buf[XADAPTCOEFFSA-3] - sub r4, r4, r7 @ r4 := p->XcoeffsA[2] - p->buf[XADAPTCOEFFSA-2] - sub r3, r3, r8 @ r3 := p->XcoeffsA[1] - p->buf[XADAPTCOEFFSA-1] - sub r2, r2, r9 @ r2 := p->XcoeffsA[0] - p->buf[XADAPTCOEFFSA] - - b 2f - - -1: @ *decoded1 < 0 - - add r5, r5, r11 @ r5 := p->XcoeffsB[0] + p->buf[XADAPTCOEFFSB] - add r6, r6, r10 @ r6 := p->XcoeffsB[1] + p->buf[XADAPTCOEFFSB-1] - add r9, r9, r2 @ r9 := p->XcoeffsB[4] + p->buf[XADAPTCOEFFSB-4] - add r8, r8, r3 @ r8 := p->XcoeffsB[3] + p->buf[XADAPTCOEFFSB-3] - add r7, r7, r4 @ r7 := p->XcoeffsB[2] + p->buf[XADAPTCOEFFSB-2] - - add r0, r12, #XcoeffsB - stmia r0, {r5 - r9} @ Save p->XcoeffsB[] - - add r1, r12, #XcoeffsA - ldmia r1, {r2 - r5} @ r2 := p->XcoeffsA[0] - @ r3 := p->XcoeffsA[1] - @ r4 := p->XcoeffsA[2] - @ r5 := p->XcoeffsA[3] - - add r6, r14, #XADAPTCOEFFSA-12 - ldmia r6, {r6 - r9} @ r6 := p->buf[XADAPTCOEFFSA-3] - @ r7 := p->buf[XADAPTCOEFFSA-2] - @ r8 := p->buf[XADAPTCOEFFSA-1] - @ r9 := p->buf[XADAPTCOEFFSA] - - add r5, r5, r6 @ r5 := p->XcoeffsA[3] + p->buf[XADAPTCOEFFSA-3] - add r4, r4, r7 @ r4 := p->XcoeffsA[2] + p->buf[XADAPTCOEFFSA-2] - add r3, r3, r8 @ r3 := p->XcoeffsA[1] + p->buf[XADAPTCOEFFSA-1] - add r2, r2, r9 @ r2 := p->XcoeffsA[0] + p->buf[XADAPTCOEFFSA] - -2: - stmia r1, {r2 - r5} @ Save p->XcoeffsA - -3: - -@@@@@@@@@@@@@@@@@@@@@@@@@@@ COMMON - - add r14, r14, #4 @ p->buf++ - - add r11, r12, #historybuffer @ r11 := &p->historybuffer[0] - - sub r10, r14, #PREDICTOR_HISTORY_SIZE*4 - @ r10 := p->buf - PREDICTOR_HISTORY_SIZE - - ldr r0, [sp, #8] - cmp r10, r11 - beq move_hist @ The history buffer is full, we need to do a memmove - - @ Check loop count - subs r0, r0, #1 - strne r0, [sp, #8] - bne loop - -done: - str r14, [r12] @ Save value of p->buf - add sp, sp, #12 @ Don't bother restoring r1-r3 -#ifdef ROCKBOX - ldmpc regs=r4-r11 -#else - ldmia sp!, {r4 - r11, pc} -#endif - -move_hist: - @ dest = r11 (p->historybuffer) - @ src = r14 (p->buf) - @ n = 200 - - ldmia r14!, {r0-r9} @ 40 bytes - stmia r11!, {r0-r9} - ldmia r14!, {r0-r9} @ 40 bytes - stmia r11!, {r0-r9} - ldmia r14!, {r0-r9} @ 40 bytes - stmia r11!, {r0-r9} - ldmia r14!, {r0-r9} @ 40 bytes - stmia r11!, {r0-r9} - ldmia r14!, {r0-r9} @ 40 bytes - stmia r11!, {r0-r9} - - ldr r0, [sp, #8] - add r14, r12, #historybuffer @ p->buf = &p->historybuffer[0] - - @ Check loop count - subs r0, r0, #1 - strne r0, [sp, #8] - bne loop - - b done - .size predictor_decode_stereo, .-predictor_decode_stereo - - .global predictor_decode_mono - .type predictor_decode_mono,%function - -@ Register usage: -@ -@ r0-r11 - scratch -@ r12 - struct predictor_t* p -@ r14 - int32_t* p->buf - -@ void predictor_decode_mono(struct predictor_t* p, -@ int32_t* decoded0, -@ int count) - -predictor_decode_mono: - stmdb sp!, {r1, r2, r4-r11, lr} - - @ r1 (decoded0) is [sp] - @ r2 (count) is [sp, #4] - - mov r12, r0 @ r12 := p - ldr r14, [r0] @ r14 := p->buf - -loopm: - -@@@@@@@@@@@@@@@@@@@@@@@@@@@ PREDICTOR - - ldr r11, [r12, #YlastA] @ r11 := p->YlastA - - add r2, r14, #YDELAYA-12 @ r2 := &p->buf[YDELAYA-3] - ldmia r2, {r2, r3, r10} @ r2 := p->buf[YDELAYA-3] - @ r3 := p->buf[YDELAYA-2] - @ r10 := p->buf[YDELAYA-1] - - add r5, r12, #YcoeffsA @ r5 := &p->YcoeffsA[0] - ldmia r5, {r6 - r9} @ r6 := p->YcoeffsA[0] - @ r7 := p->YcoeffsA[1] - @ r8 := p->YcoeffsA[2] - @ r9 := p->YcoeffsA[3] - - subs r10, r11, r10 @ r10 := r11 - r10 - - STR2OFS r10, r11, r14, #YDELAYA-4 - @ p->buf[YDELAYA-1] = r10 - @ p->buf[YDELAYA] = r11 - - mul r0, r11, r6 @ r0 := p->buf[YDELAYA] * p->YcoeffsA[0] - mla r0, r10, r7, r0 @ r0 += p->buf[YDELAYA-1] * p->YcoeffsA[1] - mla r0, r3, r8, r0 @ r0 += p->buf[YDELAYA-2] * p->YcoeffsA[2] - mla r0, r2, r9, r0 @ r0 += p->buf[YDELAYA-3] * p->YcoeffsA[3] - - @ flags were set above, in the subs instruction - mvngt r10, #0 - movlt r10, #1 @ r10 := SIGN(r10) (see .c for SIGN macro) - - cmp r11, #0 - mvngt r11, #0 - movlt r11, #1 @ r11 := SIGN(r11) (see .c for SIGN macro) - - STR2OFS r10, r11, r14, #YADAPTCOEFFSA-4 - @ p->buf[YADAPTCOEFFSA-1] := r10 - @ p->buf[YADAPTCOEFFSA] := r11 - - ldr r2, [sp] @ r2 := decoded0 - ldr r4, [r12, #YfilterA] @ r4 := p->YfilterA - ldr r3, [r2] @ r3 := *decoded0 - rsb r4, r4, r4, lsl #5 @ r4 := r4 * 32 - r4 ( == r4*31) - add r1, r3, r0, asr #10 @ r1 := r3 + (r0 >> 10) - str r1, [r12, #YlastA] @ p->YlastA := r1 - add r1, r1, r4, asr #5 @ r1 := r1 + (r4 >> 5) - str r1, [r12, #YfilterA] @ p->YfilterA := r1 - - @ r1 contains p->YfilterA - @ r2 contains decoded0 - @ r3 contains *decoded0 - - @ r6, r7, r8, r9 contain p->YcoeffsA[0..3] - @ r10, r11 contain p->buf[YADAPTCOEFFSA-1] and p->buf[YADAPTCOEFFSA] - - str r1, [r2], #4 @ *(decoded0++) := r1 (p->YfilterA) - str r2, [sp] @ save decoded0 - cmp r3, #0 - beq 3f - - LDR2OFS r2, r3, r14, #YADAPTCOEFFSA-12 - @ r2 := p->buf[YADAPTCOEFFSA-3] - @ r3 := p->buf[YADAPTCOEFFSA-2] - blt 1f - - @ *decoded0 > 0 - - sub r6, r6, r11 @ r6 := p->YcoeffsA[0] - p->buf[YADAPTCOEFFSA] - sub r7, r7, r10 @ r7 := p->YcoeffsA[1] - p->buf[YADAPTCOEFFSA-1] - sub r9, r9, r2 @ r9 := p->YcoeffsA[3] - p->buf[YADAPTCOEFFSA-3] - sub r8, r8, r3 @ r8 := p->YcoeffsA[2] - p->buf[YADAPTCOEFFSA-2] - - b 2f - -1: @ *decoded0 < 0 - - add r6, r6, r11 @ r6 := p->YcoeffsA[0] + p->buf[YADAPTCOEFFSA] - add r7, r7, r10 @ r7 := p->YcoeffsA[1] + p->buf[YADAPTCOEFFSA-1] - add r9, r9, r2 @ r9 := p->YcoeffsA[3] + p->buf[YADAPTCOEFFSA-3] - add r8, r8, r3 @ r8 := p->YcoeffsA[2] + p->buf[YADAPTCOEFFSA-2] - -2: - stmia r5, {r6 - r9} @ Save p->YcoeffsA - -3: - -@@@@@@@@@@@@@@@@@@@@@@@@@@@ COMMON - - add r14, r14, #4 @ p->buf++ - - add r11, r12, #historybuffer @ r11 := &p->historybuffer[0] - - sub r10, r14, #PREDICTOR_HISTORY_SIZE*4 - @ r10 := p->buf - PREDICTOR_HISTORY_SIZE - - ldr r0, [sp, #4] - cmp r10, r11 - beq move_histm @ The history buffer is full, we need to do a memmove - - @ Check loop count - subs r0, r0, #1 - strne r0, [sp, #4] - bne loopm - -donem: - str r14, [r12] @ Save value of p->buf - add sp, sp, #8 @ Don't bother restoring r1, r2 -#ifdef ROCKBOX - ldmpc regs=r4-r11 -#else - ldmia sp!, {r4 - r11, pc} -#endif - -move_histm: - @ dest = r11 (p->historybuffer) - @ src = r14 (p->buf) - @ n = 200 - - ldmia r14!, {r0-r9} @ 40 bytes - stmia r11!, {r0-r9} - ldmia r14!, {r0-r9} @ 40 bytes - stmia r11!, {r0-r9} - ldmia r14!, {r0-r9} @ 40 bytes - stmia r11!, {r0-r9} - ldmia r14!, {r0-r9} @ 40 bytes - stmia r11!, {r0-r9} - ldmia r14!, {r0-r9} @ 40 bytes - stmia r11!, {r0-r9} - - ldr r0, [sp, #4] - add r14, r12, #historybuffer @ p->buf = &p->historybuffer[0] - - @ Check loop count - subs r0, r0, #1 - strne r0, [sp, #4] - bne loopm - - b donem - .size predictor_decode_mono, .-predictor_decode_mono diff --git a/apps/codecs/demac/libdemac/predictor-cf.S b/apps/codecs/demac/libdemac/predictor-cf.S deleted file mode 100644 index fc1d901a59..0000000000 --- a/apps/codecs/demac/libdemac/predictor-cf.S +++ /dev/null @@ -1,660 +0,0 @@ -/* - -libdemac - A Monkey's Audio decoder - -$Id$ - -Copyright (C) Dave Chapman 2007 - -Coldfire predictor copyright (C) 2007 Jens Arnold - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA - -*/ - -#include "demac_config.h" - -/* NOTE: The following need to be kept in sync with parser.h */ - -#define YDELAYA 200 -#define YDELAYB 168 -#define XDELAYA 136 -#define XDELAYB 104 -#define YADAPTCOEFFSA 72 -#define XADAPTCOEFFSA 56 -#define YADAPTCOEFFSB 40 -#define XADAPTCOEFFSB 20 - -/* struct predictor_t members: */ -#define buf 0 /* int32_t* buf */ - -#define YlastA 4 /* int32_t YlastA; */ -#define XlastA 8 /* int32_t XlastA; */ - -#define YfilterB 12 /* int32_t YfilterB; */ -#define XfilterA 16 /* int32_t XfilterA; */ - -#define XfilterB 20 /* int32_t XfilterB; */ -#define YfilterA 24 /* int32_t YfilterA; */ - -#define YcoeffsA 28 /* int32_t YcoeffsA[4]; */ -#define XcoeffsA 44 /* int32_t XcoeffsA[4]; */ -#define YcoeffsB 60 /* int32_t YcoeffsB[5]; */ -#define XcoeffsB 80 /* int32_t XcoeffsB[5]; */ - -#define historybuffer 100 /* int32_t historybuffer[] */ - - - .text - - .align 2 - - .global predictor_decode_stereo - .type predictor_decode_stereo,@function - -| void predictor_decode_stereo(struct predictor_t* p, -| int32_t* decoded0, -| int32_t* decoded1, -| int count) - -predictor_decode_stereo: - lea.l (-12*4,%sp), %sp - movem.l %d2-%d7/%a2-%a6, (4,%sp) - - movem.l (12*4+8,%sp), %a3-%a5 | %a3 = decoded0 - | %a4 = decoded1 - move.l %a5, (%sp) | (%sp) = count - - move.l #0, %macsr | signed integer mode - move.l (12*4+4,%sp), %a6 | %a6 = p - move.l (%a6), %a5 | %a5 = p->buf - -.loop: - - | ***** PREDICTOR Y ***** - - | Predictor Y, Filter A - - move.l (YlastA,%a6), %d3 | %d3 = p->YlastA - - movem.l (YDELAYA-12,%a5), %d0-%d2 | %d0 = p->buf[YDELAYA-3] - | %d1 = p->buf[YDELAYA-2] - | %d2 = p->buf[YDELAYA-1] - - move.l %d3, (YDELAYA,%a5) | p->buf[YDELAYA] = %d3 - - sub.l %d3, %d2 - neg.l %d2 | %d2 = %d3 - %d2 - - move.l %d2, (YDELAYA-4,%a5) | p->buf[YDELAYA-1] = %d2 - - movem.l (YcoeffsA,%a6), %d4-%d7 | %d4 = p->YcoeffsA[0] - | %d5 = p->YcoeffsA[1] - | %d6 = p->YcoeffsA[2] - | %d7 = p->YcoeffsA[3] - - mac.l %d3, %d4, %acc0 | %acc0 = p->buf[YDELAYA] * p->YcoeffsA[0] - mac.l %d2, %d5, %acc0 | %acc0 += p->buf[YDELAYA-1] * p->YcoeffsA[1] - mac.l %d1, %d6, %acc0 | %acc0 += p->buf[YDELAYA-2] * p->YcoeffsA[2] - mac.l %d0, %d7, %acc0 | %acc0 += p->buf[YDELAYA-3] * p->YcoeffsA[3] - - tst.l %d2 - beq.s 1f - spl.b %d2 | pos: 0x??????ff, neg: 0x??????00 - extb.l %d2 | pos: 0xffffffff, neg: 0x00000000 - or.l #1, %d2 | pos: 0xffffffff, neg: 0x00000001 -1: | %d2 = SIGN(%d2) - move.l %d2, (YADAPTCOEFFSA-4,%a5) | p->buf[YADAPTCOEFFSA-1] = %d2 - - tst.l %d3 - beq.s 1f - spl.b %d3 - extb.l %d3 - or.l #1, %d3 -1: | %d3 = SIGN(%d3) - move.l %d3, (YADAPTCOEFFSA,%a5) | p->buf[YADAPTCOEFFSA] = %d3 - - | Predictor Y, Filter B - - movem.l (YfilterB,%a6), %d2-%d3 | %d2 = p->YfilterB - | %d3 = p->XfilterA - move.l %d3, (YfilterB,%a6) | p->YfilterB = %d3 - - move.l %d2, %d1 | %d1 = %d2 - lsl.l #5, %d2 | %d2 = %d2 * 32 - sub.l %d1, %d2 | %d2 -= %d1 (== 31 * old_d2) - asr.l #5, %d2 | %d2 >>= 5 - sub.l %d2, %d3 | %d3 -= %d2 - - movem.l (YDELAYB-16,%a5), %d4-%d7 | %d4 = p->buf[YDELAYB-4] - | %d5 = p->buf[YDELAYB-3] - | %d6 = p->buf[YDELAYB-2] - | %d7 = p->buf[YDELAYB-1] - sub.l %d3, %d7 - neg.l %d7 | %d7 = %d3 - %d7 - - move.l %d7, (YDELAYB-4,%a5) | p->buf[YDELAYB-1] = %d7 - - movem.l (YcoeffsB,%a6), %d1-%d2/%a0-%a2 | %d1 = p->YcoeffsB[0] - | %d2 = p->YcoeffsB[1] - | %a0 = p->YcoeffsB[2] - | %a1 = p->YcoeffsB[3] - | %a2 = p->YcoeffsB[4] - - mac.l %d3, %d1, %acc1 | %acc1 = p->buf[YDELAYB] * p->YcoeffsB[0] - mac.l %d7, %d2, %acc1 | %acc1 += p->buf[YDELAYB-1] * p->YcoeffsB[1] - mac.l %d6, %a0, %acc1 | %acc1 += p->buf[YDELAYB-2] * p->YcoeffsB[2] - mac.l %d5, %a1, %acc1 | %acc1 += p->buf[YDELAYB-3] * p->YcoeffsB[3] - mac.l %d4, %a2, %acc1 | %acc1 += p->buf[YDELAYB-4] * p->YcoeffsB[4] - - move.l %d3, (YDELAYB, %a5) | p->buf[YDELAYB] = %d3 - - tst.l %d7 - beq.s 1f - spl.b %d7 - extb.l %d7 - or.l #1, %d7 -1: | %d7 = SIGN(%d7) - move.l %d7, (YADAPTCOEFFSB-4,%a5) | p->buf[YADAPTCOEFFSB-1] = %d7 - tst.l %d3 - beq.s 1f - spl.b %d3 - extb.l %d3 - or.l #1, %d3 -1: | %d3 = SIGN(%d3) - move.l %d3, (YADAPTCOEFFSB, %a5) | p->buf[YADAPTCOEFFSB] = %d3 - - | %d1, %d2, %a0, %a1, %a2 contain p->YcoeffsB[0..4] - | %d7, %d3 contain p->buf[YADAPTCOEFFSB-1] and p->buf[YADAPTCOEFFSB] - - move.l (%a3), %d0 | %d0 = *decoded0 - beq.s 3f - - movem.l (YADAPTCOEFFSB-16,%a5), %d4-%d6 | %d4 = p->buf[YADAPTCOEFFSB-4] - | %d5 = p->buf[YADAPTCOEFFSB-3] - | %d6 = p->buf[YADAPTCOEFFSB-2] - - bmi.s 1f | flags still valid here - - | *decoded0 > 0 - - sub.l %d3, %d1 | %d1 = p->YcoeffsB[0] - p->buf[YADAPTCOEFFSB] - sub.l %d7, %d2 | %d2 = p->YcoeffsB[1] - p->buf[YADAPTCOEFFSB-1] - sub.l %d6, %a0 | %a0 = p->YcoeffsB[2] - p->buf[YADAPTCOEFFSB-2] - sub.l %d5, %a1 | %a1 = p->YcoeffsB[3] - p->buf[YADAPTCOEFFSB-3] - sub.l %d4, %a2 | %a2 = p->YcoeffsB[4] - p->buf[YADAPTCOEFFSB-4] - - movem.l %d1-%d2/%a0-%a2, (YcoeffsB,%a6) | Save p->YcoeffsB[] - - movem.l (YcoeffsA,%a6), %d4-%d7 | %d4 = p->YcoeffsA[0] - | %d5 = p->YcoeffsA[1] - | %d6 = p->YcoeffsA[2] - | %d7 = p->YcoeffsA[3] - - movem.l (YADAPTCOEFFSA-12,%a5), %d2/%a0-%a2 - | %d2 = p->buf[YADAPTCOEFFSA-3] - | %a0 = p->buf[YADAPTCOEFFSA-2] - | %a1 = p->buf[YADAPTCOEFFSA-1] - | %a2 = p->buf[YADAPTCOEFFSA] - - sub.l %a2, %d4 | %d4 = p->YcoeffsA[0] - p->buf[YADAPTCOEFFSA] - sub.l %a1, %d5 | %d5 = p->YcoeffsA[1] - p->buf[YADAPTCOEFFSA-1] - sub.l %a0, %d6 | %d6 = p->YcoeffsA[2] - p->buf[YADAPTCOEFFSA-2] - sub.l %d2, %d7 | %d7 = p->YcoeffsA[3] - p->buf[YADAPTCOEFFSA-3] - - bra.s 2f - -1: | *decoded0 < 0 - - add.l %d3, %d1 | %d1 = p->YcoeffsB[0] + p->buf[YADAPTCOEFFSB] - add.l %d7, %d2 | %d2 = p->YcoeffsB[1] + p->buf[YADAPTCOEFFSB-1] - add.l %d6, %a0 | %a0 = p->YcoeffsB[2] + p->buf[YADAPTCOEFFSB-2] - add.l %d5, %a1 | %a1 = p->YcoeffsB[3] + p->buf[YADAPTCOEFFSB-3] - add.l %d4, %a2 | %a2 = p->YcoeffsB[4] + p->buf[YADAPTCOEFFSB-4] - - movem.l %d1-%d2/%a0-%a2, (YcoeffsB,%a6) | Save p->YcoeffsB[] - - movem.l (YcoeffsA,%a6), %d4-%d7 | %d4 = p->YcoeffsA[0] - | %d5 = p->YcoeffsA[1] - | %d6 = p->YcoeffsA[2] - | %d7 = p->YcoeffsA[3] - - movem.l (YADAPTCOEFFSA-12,%a5), %d2/%a0-%a2 - | %d2 = p->buf[YADAPTCOEFFSA-3] - | %a0 = p->buf[YADAPTCOEFFSA-2] - | %a1 = p->buf[YADAPTCOEFFSA-1] - | %a2 = p->buf[YADAPTCOEFFSA] - - add.l %a2, %d4 | %d4 = p->YcoeffsA[0] + p->buf[YADAPTCOEFFSA] - add.l %a1, %d5 | %d5 = p->YcoeffsA[1] + p->buf[YADAPTCOEFFSA-1] - add.l %a0, %d6 | %d6 = p->YcoeffsA[2] + p->buf[YADAPTCOEFFSA-2] - add.l %d2, %d7 | %d7 = p->YcoeffsA[3] + p->buf[YADAPTCOEFFSA-3] - -2: - movem.l %d4-%d7, (YcoeffsA,%a6) | Save p->YcoeffsA[] - -3: - | Finish Predictor Y - - movclr.l %acc0, %d1 | %d1 = predictionA - movclr.l %acc1, %d2 | %d2 = predictionB - asr.l #1, %d2 - add.l %d2, %d1 | %d1 += (%d2 >> 1) - asr.l #8, %d1 - asr.l #2, %d1 | %d1 >>= 10 - add.l %d0, %d1 | %d1 += %d0 - move.l %d1, (YlastA,%a6) | p->YlastA = %d1 - - move.l (YfilterA,%a6), %d2 | %d2 = p->YfilterA - move.l %d2, %d0 - lsl.l #5, %d2 - sub.l %d0, %d2 | %d2 = 31 * %d2 - asr.l #5, %d2 | %d2 >>= 5 - add.l %d1, %d2 - move.l %d2, (YfilterA,%a6) | p->YfilterA = %d2 - - | *decoded0 stored 2 instructions down, avoiding pipeline stall - - | ***** PREDICTOR X ***** - - | Predictor X, Filter A - - move.l (XlastA,%a6), %d3 | %d3 = p->XlastA - - move.l %d2, (%a3)+ | *(decoded0++) = %d2 (p->YfilterA) - - movem.l (XDELAYA-12,%a5), %d0-%d2 | %d0 = p->buf[XDELAYA-3] - | %d1 = p->buf[XDELAYA-2] - | %d2 = p->buf[XDELAYA-1] - - move.l %d3, (XDELAYA,%a5) | p->buf[XDELAYA] = %d3 - - sub.l %d3, %d2 - neg.l %d2 | %d2 = %d3 -%d2 - - move.l %d2, (XDELAYA-4,%a5) | p->buf[XDELAYA-1] = %d2 - - movem.l (XcoeffsA,%a6), %d4-%d7 | %d4 = p->XcoeffsA[0] - | %d5 = p->XcoeffsA[1] - | %d6 = p->XcoeffsA[2] - | %d7 = p->XcoeffsA[3] - - mac.l %d3, %d4, %acc0 | %acc0 = p->buf[XDELAYA] * p->XcoeffsA[0] - mac.l %d2, %d5, %acc0 | %acc0 += p->buf[XDELAYA-1] * p->XcoeffsA[1] - mac.l %d1, %d6, %acc0 | %acc0 += p->buf[XDELAYA-2] * p->XcoeffsA[2] - mac.l %d0, %d7, %acc0 | %acc0 += p->buf[XDELAYA-3] * p->XcoeffsA[3] - - tst.l %d2 - beq.s 1f - spl.b %d2 | pos: 0x??????ff, neg: 0x??????00 - extb.l %d2 | pos: 0xffffffff, neg: 0x00000000 - or.l #1, %d2 | pos: 0xffffffff, neg: 0x00000001 -1: | %d2 = SIGN(%d2) - move.l %d2, (XADAPTCOEFFSA-4,%a5) | p->buf[XADAPTCOEFFSA-1] = %d2 - - tst.l %d3 - beq.s 1f - spl.b %d3 - extb.l %d3 - or.l #1, %d3 -1: | %d3 = SIGN(%d3) - move.l %d3, (XADAPTCOEFFSA,%a5) | p->buf[XADAPTCOEFFSA] = %d3 - - | Predictor X, Filter B - - movem.l (XfilterB,%a6), %d2-%d3 | %d2 = p->XfilterB - | %d3 = p->YfilterA - move.l %d3, (XfilterB,%a6) | p->XfilterB = %d3 - - move.l %d2, %d1 | %d1 = %d2 - lsl.l #5, %d2 | %d2 = %d2 * 32 - sub.l %d1, %d2 | %d2 -= %d1 (== 31 * old_d2) - asr.l #5, %d2 | %d2 >>= 5 - sub.l %d2, %d3 | %d3 -= %d2 - - movem.l (XDELAYB-16,%a5), %d4-%d7 | %d4 = p->buf[XDELAYB-4] - | %d5 = p->buf[XDELAYB-3] - | %d6 = p->buf[XDELAYB-2] - | %d7 = p->buf[XDELAYB-1] - sub.l %d3, %d7 - neg.l %d7 | %d7 = %d3 - %d7 - - move.l %d7, (XDELAYB-4,%a5) | p->buf[XDELAYB-1] = %d7 - - movem.l (XcoeffsB,%a6), %d1-%d2/%a0-%a2 | %d1 = p->XcoeffsB[0] - | %d2 = p->XcoeffsB[1] - | %a0 = p->XcoeffsB[2] - | %a1 = p->XcoeffsB[3] - | %a2 = p->XcoeffsB[4] - - mac.l %d3, %d1, %acc1 | %acc1 = p->buf[XDELAYB] * p->XcoeffsB[0] - mac.l %d7, %d2, %acc1 | %acc1 += p->buf[XDELAYB-1] * p->XcoeffsB[1] - mac.l %d6, %a0, %acc1 | %acc1 += p->buf[XDELAYB-2] * p->XcoeffsB[2] - mac.l %d5, %a1, %acc1 | %acc1 += p->buf[XDELAYB-3] * p->XcoeffsB[3] - mac.l %d4, %a2, %acc1 | %acc1 += p->buf[XDELAYB-4] * p->XcoeffsB[4] - - move.l %d3, (XDELAYB, %a5) | p->buf[XDELAYB] = %d3 - - tst.l %d7 - beq.s 1f - spl.b %d7 - extb.l %d7 - or.l #1, %d7 -1: | %d7 = SIGN(%d7) - move.l %d7, (XADAPTCOEFFSB-4,%a5) | p->buf[XADAPTCOEFFSB-1] = %d7 - - tst.l %d3 - beq.s 1f - spl.b %d3 - extb.l %d3 - or.l #1, %d3 -1: | %d3 = SIGN(%d3) - move.l %d3, (XADAPTCOEFFSB, %a5) | p->buf[XADAPTCOEFFSB] = %d3 - - | %d1, %d2, %a0, %a1, %a2 contain p->XcoeffsB[0..4] - | %d7, %d3 contain p->buf[XADAPTCOEFFSB-1] and p->buf[XADAPTCOEFFSB] - - move.l (%a4), %d0 | %d0 = *decoded1 - beq.s 3f - - movem.l (XADAPTCOEFFSB-16,%a5), %d4-%d6 | %d4 = p->buf[XADAPTCOEFFSB-4] - | %d5 = p->buf[XADAPTCOEFFSB-3] - | %d6 = p->buf[XADAPTCOEFFSB-2] - - bmi.s 1f | flags still valid here - - | *decoded1 > 0 - - sub.l %d3, %d1 | %d1 = p->XcoeffsB[0] - p->buf[XADAPTCOEFFSB] - sub.l %d7, %d2 | %d2 = p->XcoeffsB[1] - p->buf[XADAPTCOEFFSB-1] - sub.l %d6, %a0 | %a0 = p->XcoeffsB[2] - p->buf[XADAPTCOEFFSB-2] - sub.l %d5, %a1 | %a1 = p->XcoeffsB[3] - p->buf[XADAPTCOEFFSB-3] - sub.l %d4, %a2 | %a2 = p->XcoeffsB[4] - p->buf[XADAPTCOEFFSB-4] - - movem.l %d1-%d2/%a0-%a2, (XcoeffsB,%a6) | Save p->XcoeffsB[] - - movem.l (XcoeffsA,%a6), %d4-%d7 | %d4 = p->XcoeffsA[0] - | %d5 = p->XcoeffsA[1] - | %d6 = p->XcoeffsA[2] - | %d7 = p->XcoeffsA[3] - - movem.l (XADAPTCOEFFSA-12,%a5), %d2/%a0-%a2 - | %d2 = p->buf[XADAPTCOEFFSA-3] - | %a0 = p->buf[XADAPTCOEFFSA-2] - | %a1 = p->buf[XADAPTCOEFFSA-1] - | %a2 = p->buf[XADAPTCOEFFSA] - - sub.l %a2, %d4 | %d4 = p->XcoeffsA[0] - p->buf[XADAPTCOEFFSA] - sub.l %a1, %d5 | %d5 = p->XcoeffsA[1] - p->buf[XADAPTCOEFFSA-1] - sub.l %a0, %d6 | %d6 = p->XcoeffsA[2] - p->buf[XADAPTCOEFFSA-2] - sub.l %d2, %d7 | %d7 = p->XcoeffsA[3] - p->buf[XADAPTCOEFFSA-3] - - bra.s 2f - -1: | *decoded1 < 0 - - add.l %d3, %d1 | %d1 = p->XcoeffsB[0] + p->buf[XADAPTCOEFFSB] - add.l %d7, %d2 | %d2 = p->XcoeffsB[1] + p->buf[XADAPTCOEFFSB-1] - add.l %d6, %a0 | %a0 = p->XcoeffsB[2] + p->buf[XADAPTCOEFFSB-2] - add.l %d5, %a1 | %a1 = p->XcoeffsB[3] + p->buf[XADAPTCOEFFSB-3] - add.l %d4, %a2 | %a2 = p->XcoeffsB[4] + p->buf[XADAPTCOEFFSB-4] - - movem.l %d1-%d2/%a0-%a2, (XcoeffsB,%a6) | Save p->XcoeffsB[] - - movem.l (XcoeffsA,%a6), %d4-%d7 | %d4 = p->XcoeffsA[0] - | %d5 = p->XcoeffsA[1] - | %d6 = p->XcoeffsA[2] - | %d7 = p->XcoeffsA[3] - - movem.l (XADAPTCOEFFSA-12,%a5), %d2/%a0-%a2 - | %d2 = p->buf[XADAPTCOEFFSA-3] - | %a0 = p->buf[XADAPTCOEFFSA-2] - | %a1 = p->buf[XADAPTCOEFFSA-1] - | %a2 = p->buf[XADAPTCOEFFSA] - - add.l %a2, %d4 | %d4 = p->XcoeffsA[0] + p->buf[XADAPTCOEFFSA] - add.l %a1, %d5 | %d5 = p->XcoeffsA[1] + p->buf[XADAPTCOEFFSA-1] - add.l %a0, %d6 | %d6 = p->XcoeffsA[2] + p->buf[XADAPTCOEFFSA-2] - add.l %d2, %d7 | %d7 = p->XcoeffsA[3] + p->buf[XADAPTCOEFFSA-3] - -2: - movem.l %d4-%d7, (XcoeffsA,%a6) | Save p->XcoeffsA[] - -3: - | Finish Predictor X - - movclr.l %acc0, %d1 | %d1 = predictionA - movclr.l %acc1, %d2 | %d2 = predictionB - asr.l #1, %d2 - add.l %d2, %d1 | %d1 += (%d2 >> 1) - asr.l #8, %d1 - asr.l #2, %d1 | %d1 >>= 10 - add.l %d0, %d1 | %d1 += %d0 - move.l %d1, (XlastA,%a6) | p->XlastA = %d1 - - move.l (XfilterA,%a6), %d2 | %d2 = p->XfilterA - move.l %d2, %d0 - lsl.l #5, %d2 - sub.l %d0, %d2 | %d2 = 31 * %d2 - asr.l #5, %d2 | %d6 >>= 2 - add.l %d1, %d2 - move.l %d2, (XfilterA,%a6) | p->XfilterA = %d2 - - | *decoded1 stored 3 instructions down, avoiding pipeline stall - - | ***** COMMON ***** - - addq.l #4, %a5 | p->buf++ - lea.l (historybuffer+PREDICTOR_HISTORY_SIZE*4,%a6), %a2 - | %a2 = &p->historybuffer[PREDICTOR_HISTORY_SIZE] - - move.l %d2, (%a4)+ | *(decoded1++) = %d2 (p->XfilterA) - - cmp.l %a2, %a5 - beq.s .move_hist | History buffer is full, we need to do a memmove - - subq.l #1, (%sp) | decrease loop count - bne.w .loop - -.done: - move.l %a5, (%a6) | Save value of p->buf - movem.l (4,%sp), %d2-%d7/%a2-%a6 - lea.l (12*4,%sp), %sp - rts - -.move_hist: - lea.l (historybuffer,%a6), %a2 - - | dest = %a2 (p->historybuffer) - | src = %a5 (p->buf) - | n = 200 - - movem.l (%a5), %d0-%d7/%a0-%a1 | 40 bytes - movem.l %d0-%d7/%a0-%a1, (%a2) - movem.l (40,%a5), %d0-%d7/%a0-%a1 | 40 bytes - movem.l %d0-%d7/%a0-%a1, (40,%a2) - movem.l (80,%a5), %d0-%d7/%a0-%a1 | 40 bytes - movem.l %d0-%d7/%a0-%a1, (80,%a2) - movem.l (120,%a5), %d0-%d7/%a0-%a1 | 40 bytes - movem.l %d0-%d7/%a0-%a1, (120,%a2) - movem.l (160,%a5), %d0-%d7/%a0-%a1 | 40 bytes - movem.l %d0-%d7/%a0-%a1, (160,%a2) - - move.l %a2, %a5 | p->buf = &p->historybuffer[0] - - subq.l #1, (%sp) | decrease loop count - bne.w .loop - - bra.s .done - .size predictor_decode_stereo, .-predictor_decode_stereo - - - .global predictor_decode_mono - .type predictor_decode_mono,@function - -| void predictor_decode_mono(struct predictor_t* p, -| int32_t* decoded0, -| int count) - -predictor_decode_mono: - lea.l (-11*4,%sp), %sp - movem.l %d2-%d7/%a2-%a6, (%sp) - - move.l #0, %macsr | signed integer mode - - move.l (11*4+4,%sp), %a6 | %a6 = p - move.l (11*4+8,%sp), %a4 | %a4 = decoded0 - move.l (11*4+12,%sp), %d7 | %d7 = count - move.l (%a6), %a5 | %a5 = p->buf - - move.l (YlastA,%a6), %d3 | %d3 = p->YlastA - -.loopm: - - | ***** PREDICTOR ***** - - movem.l (YDELAYA-12,%a5), %d0-%d2 | %d0 = p->buf[YDELAYA-3] - | %d1 = p->buf[YDELAYA-2] - | %d2 = p->buf[YDELAYA-1] - - move.l %d3, (YDELAYA,%a5) | p->buf[YDELAYA] = %d3 - - sub.l %d3, %d2 - neg.l %d2 | %d2 = %d3 - %d2 - - move.l %d2, (YDELAYA-4,%a5) | p->buf[YDELAYA-1] = %d2 - - movem.l (YcoeffsA,%a6), %a0-%a3 | %a0 = p->YcoeffsA[0] - | %a1 = p->YcoeffsA[1] - | %a2 = p->YcoeffsA[2] - | %a3 = p->YcoeffsA[3] - - mac.l %d3, %a0, %acc0 | %acc0 = p->buf[YDELAYA] * p->YcoeffsA[0] - mac.l %d2, %a1, %acc0 | %acc0 += p->buf[YDELAYA-1] * p->YcoeffsA[1] - mac.l %d1, %a2, %acc0 | %acc0 += p->buf[YDELAYA-2] * p->YcoeffsA[2] - mac.l %d0, %a3, %acc0 | %acc0 += p->buf[YDELAYA-3] * p->YcoeffsA[3] - - tst.l %d2 - beq.s 1f - spl.b %d2 | pos: 0x??????ff, neg: 0x??????00 - extb.l %d2 | pos: 0xffffffff, neg: 0x00000000 - or.l #1, %d2 | pos: 0xffffffff, neg: 0x00000001 -1: | %d2 = SIGN(%d2) - move.l %d2, (YADAPTCOEFFSA-4,%a5) | p->buf[YADAPTCOEFFSA-1] = %d2 - - tst.l %d3 - beq.s 1f - spl.b %d3 - extb.l %d3 - or.l #1, %d3 -1: | %d3 = SIGN(%d3) - move.l %d3, (YADAPTCOEFFSA,%a5) | p->buf[YADAPTCOEFFSA] = %d3 - - move.l (%a4), %d0 | %d0 = *decoded0 - beq.s 3f - - movem.l (YADAPTCOEFFSA-12,%a5),%d4-%d5 | %d4 = p->buf[YADAPTCOEFFSA-3] - | %d5 = p->buf[YADAPTCOEFFSA-2] - - bmi.s 1f | flags still valid here - - | *decoded0 > 0 - - sub.l %d3, %a0 | %a0 = p->YcoeffsA[0] - p->buf[YADAPTCOEFFSA] - sub.l %d2, %a1 | %a1 = p->YcoeffsA[1] - p->buf[YADAPTCOEFFSA-1] - sub.l %d5, %a2 | %a2 = p->YcoeffsA[2] - p->buf[YADAPTCOEFFSA-2] - sub.l %d4, %a3 | %a3 = p->YcoeffsA[3] - p->buf[YADAPTCOEFFSA-3] - - bra.s 2f - -1: | *decoded0 < 0 - - add.l %d3, %a0 | %a0 = p->YcoeffsA[0] - p->buf[YADAPTCOEFFSA] - add.l %d2, %a1 | %a1 = p->YcoeffsA[1] - p->buf[YADAPTCOEFFSA-1] - add.l %d5, %a2 | %a2 = p->YcoeffsA[2] - p->buf[YADAPTCOEFFSA-2] - add.l %d4, %a3 | %a3 = p->YcoeffsA[3] - p->buf[YADAPTCOEFFSA-3] - -2: - movem.l %a0-%a3, (YcoeffsA,%a6) | save p->YcoeffsA[] - -3: - | Finish Predictor - - movclr.l %acc0, %d3 | %d3 = predictionA - asr.l #8, %d3 - asr.l #2, %d3 | %d3 >>= 10 - add.l %d0, %d3 | %d3 += %d0 - - move.l (YfilterA,%a6), %d2 | %d2 = p->YfilterA - move.l %d2, %d0 - lsl.l #5, %d2 - sub.l %d0, %d2 | %d2 = 31 * %d2 - asr.l #5, %d2 | %d2 >>= 5 - add.l %d3, %d2 - move.l %d2, (YfilterA,%a6) | p->YfilterA = %d2 - - | *decoded0 stored 3 instructions down, avoiding pipeline stall - - | ***** COMMON ***** - - addq.l #4, %a5 | p->buf++ - lea.l (historybuffer+PREDICTOR_HISTORY_SIZE*4,%a6), %a3 - | %a3 = &p->historybuffer[PREDICTOR_HISTORY_SIZE] - - move.l %d2, (%a4)+ | *(decoded0++) = %d2 (p->YfilterA) - - cmp.l %a3, %a5 - beq.s .move_histm | History buffer is full, we need to do a memmove - - subq.l #1, %d7 | decrease loop count - bne.w .loopm - - move.l %d3, (YlastA,%a6) | %d3 = p->YlastA - -.donem: - move.l %a5, (%a6) | Save value of p->buf - movem.l (%sp), %d2-%d7/%a2-%a6 - lea.l (11*4,%sp), %sp - rts - -.move_histm: - move.l %d3, (YlastA,%a6) | %d3 = p->YlastA - - lea.l (historybuffer,%a6), %a3 - - | dest = %a3 (p->historybuffer) - | src = %a5 (p->buf) - | n = 200 - - movem.l (%a5), %d0-%d6/%a0-%a2 | 40 bytes - movem.l %d0-%d6/%a0-%a2, (%a3) - movem.l (40,%a5), %d0-%d6/%a0-%a2 | 40 bytes - movem.l %d0-%d6/%a0-%a2, (40,%a3) - movem.l (80,%a5), %d0-%d6/%a0-%a2 | 40 bytes - movem.l %d0-%d6/%a0-%a2, (80,%a3) - movem.l (120,%a5), %d0-%d6/%a0-%a2 | 40 bytes - movem.l %d0-%d6/%a0-%a2, (120,%a3) - movem.l (160,%a5), %d0-%d6/%a0-%a2 | 40 bytes - movem.l %d0-%d6/%a0-%a2, (160,%a3) - - move.l %a3, %a5 | p->buf = &p->historybuffer[0] - - move.l (YlastA,%a6), %d3 | %d3 = p->YlastA - - subq.l #1, %d7 | decrease loop count - bne.w .loopm - - bra.s .donem - .size predictor_decode_mono, .-predictor_decode_mono diff --git a/apps/codecs/demac/libdemac/predictor.c b/apps/codecs/demac/libdemac/predictor.c deleted file mode 100644 index 45912dddbd..0000000000 --- a/apps/codecs/demac/libdemac/predictor.c +++ /dev/null @@ -1,271 +0,0 @@ -/* - -libdemac - A Monkey's Audio decoder - -$Id$ - -Copyright (C) Dave Chapman 2007 - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA - -*/ - -#include -#include - -#include "parser.h" -#include "predictor.h" -#include "demac_config.h" - -/* Return 0 if x is zero, -1 if x is positive, 1 if x is negative */ -#define SIGN(x) (x) ? (((x) > 0) ? -1 : 1) : 0 - -static const int32_t initial_coeffs[4] = { - 360, 317, -109, 98 -}; - -#define YDELAYA (18 + PREDICTOR_ORDER*4) -#define YDELAYB (18 + PREDICTOR_ORDER*3) -#define XDELAYA (18 + PREDICTOR_ORDER*2) -#define XDELAYB (18 + PREDICTOR_ORDER) - -#define YADAPTCOEFFSA (18) -#define XADAPTCOEFFSA (14) -#define YADAPTCOEFFSB (10) -#define XADAPTCOEFFSB (5) - -void init_predictor_decoder(struct predictor_t* p) -{ - /* Zero the history buffers */ - memset(p->historybuffer, 0, PREDICTOR_SIZE * sizeof(int32_t)); - p->buf = p->historybuffer; - - /* Initialise and zero the co-efficients */ - memcpy(p->YcoeffsA, initial_coeffs, sizeof(initial_coeffs)); - memcpy(p->XcoeffsA, initial_coeffs, sizeof(initial_coeffs)); - memset(p->YcoeffsB, 0, sizeof(p->YcoeffsB)); - memset(p->XcoeffsB, 0, sizeof(p->XcoeffsB)); - - p->YfilterA = 0; - p->YfilterB = 0; - p->YlastA = 0; - - p->XfilterA = 0; - p->XfilterB = 0; - p->XlastA = 0; -} - -#if !defined(CPU_ARM) && !defined(CPU_COLDFIRE) -void ICODE_ATTR_DEMAC predictor_decode_stereo(struct predictor_t* p, - int32_t* decoded0, - int32_t* decoded1, - int count) -{ - int32_t predictionA, predictionB; - - while (LIKELY(count--)) - { - /* Predictor Y */ - p->buf[YDELAYA] = p->YlastA; - p->buf[YADAPTCOEFFSA] = SIGN(p->buf[YDELAYA]); - - p->buf[YDELAYA-1] = p->buf[YDELAYA] - p->buf[YDELAYA-1]; - p->buf[YADAPTCOEFFSA-1] = SIGN(p->buf[YDELAYA-1]); - - predictionA = (p->buf[YDELAYA] * p->YcoeffsA[0]) + - (p->buf[YDELAYA-1] * p->YcoeffsA[1]) + - (p->buf[YDELAYA-2] * p->YcoeffsA[2]) + - (p->buf[YDELAYA-3] * p->YcoeffsA[3]); - - /* Apply a scaled first-order filter compression */ - p->buf[YDELAYB] = p->XfilterA - ((p->YfilterB * 31) >> 5); - p->buf[YADAPTCOEFFSB] = SIGN(p->buf[YDELAYB]); - p->YfilterB = p->XfilterA; - - p->buf[YDELAYB-1] = p->buf[YDELAYB] - p->buf[YDELAYB-1]; - p->buf[YADAPTCOEFFSB-1] = SIGN(p->buf[YDELAYB-1]); - - predictionB = (p->buf[YDELAYB] * p->YcoeffsB[0]) + - (p->buf[YDELAYB-1] * p->YcoeffsB[1]) + - (p->buf[YDELAYB-2] * p->YcoeffsB[2]) + - (p->buf[YDELAYB-3] * p->YcoeffsB[3]) + - (p->buf[YDELAYB-4] * p->YcoeffsB[4]); - - p->YlastA = *decoded0 + ((predictionA + (predictionB >> 1)) >> 10); - p->YfilterA = p->YlastA + ((p->YfilterA * 31) >> 5); - - /* Predictor X */ - - p->buf[XDELAYA] = p->XlastA; - p->buf[XADAPTCOEFFSA] = SIGN(p->buf[XDELAYA]); - p->buf[XDELAYA-1] = p->buf[XDELAYA] - p->buf[XDELAYA-1]; - p->buf[XADAPTCOEFFSA-1] = SIGN(p->buf[XDELAYA-1]); - - predictionA = (p->buf[XDELAYA] * p->XcoeffsA[0]) + - (p->buf[XDELAYA-1] * p->XcoeffsA[1]) + - (p->buf[XDELAYA-2] * p->XcoeffsA[2]) + - (p->buf[XDELAYA-3] * p->XcoeffsA[3]); - - /* Apply a scaled first-order filter compression */ - p->buf[XDELAYB] = p->YfilterA - ((p->XfilterB * 31) >> 5); - p->buf[XADAPTCOEFFSB] = SIGN(p->buf[XDELAYB]); - p->XfilterB = p->YfilterA; - p->buf[XDELAYB-1] = p->buf[XDELAYB] - p->buf[XDELAYB-1]; - p->buf[XADAPTCOEFFSB-1] = SIGN(p->buf[XDELAYB-1]); - - predictionB = (p->buf[XDELAYB] * p->XcoeffsB[0]) + - (p->buf[XDELAYB-1] * p->XcoeffsB[1]) + - (p->buf[XDELAYB-2] * p->XcoeffsB[2]) + - (p->buf[XDELAYB-3] * p->XcoeffsB[3]) + - (p->buf[XDELAYB-4] * p->XcoeffsB[4]); - - p->XlastA = *decoded1 + ((predictionA + (predictionB >> 1)) >> 10); - p->XfilterA = p->XlastA + ((p->XfilterA * 31) >> 5); - - if (LIKELY(*decoded0 != 0)) - { - if (*decoded0 > 0) - { - p->YcoeffsA[0] -= p->buf[YADAPTCOEFFSA]; - p->YcoeffsA[1] -= p->buf[YADAPTCOEFFSA-1]; - p->YcoeffsA[2] -= p->buf[YADAPTCOEFFSA-2]; - p->YcoeffsA[3] -= p->buf[YADAPTCOEFFSA-3]; - - p->YcoeffsB[0] -= p->buf[YADAPTCOEFFSB]; - p->YcoeffsB[1] -= p->buf[YADAPTCOEFFSB-1]; - p->YcoeffsB[2] -= p->buf[YADAPTCOEFFSB-2]; - p->YcoeffsB[3] -= p->buf[YADAPTCOEFFSB-3]; - p->YcoeffsB[4] -= p->buf[YADAPTCOEFFSB-4]; - } - else - { - p->YcoeffsA[0] += p->buf[YADAPTCOEFFSA]; - p->YcoeffsA[1] += p->buf[YADAPTCOEFFSA-1]; - p->YcoeffsA[2] += p->buf[YADAPTCOEFFSA-2]; - p->YcoeffsA[3] += p->buf[YADAPTCOEFFSA-3]; - - p->YcoeffsB[0] += p->buf[YADAPTCOEFFSB]; - p->YcoeffsB[1] += p->buf[YADAPTCOEFFSB-1]; - p->YcoeffsB[2] += p->buf[YADAPTCOEFFSB-2]; - p->YcoeffsB[3] += p->buf[YADAPTCOEFFSB-3]; - p->YcoeffsB[4] += p->buf[YADAPTCOEFFSB-4]; - } - } - - *(decoded0++) = p->YfilterA; - - if (LIKELY(*decoded1 != 0)) - { - if (*decoded1 > 0) - { - p->XcoeffsA[0] -= p->buf[XADAPTCOEFFSA]; - p->XcoeffsA[1] -= p->buf[XADAPTCOEFFSA-1]; - p->XcoeffsA[2] -= p->buf[XADAPTCOEFFSA-2]; - p->XcoeffsA[3] -= p->buf[XADAPTCOEFFSA-3]; - - p->XcoeffsB[0] -= p->buf[XADAPTCOEFFSB]; - p->XcoeffsB[1] -= p->buf[XADAPTCOEFFSB-1]; - p->XcoeffsB[2] -= p->buf[XADAPTCOEFFSB-2]; - p->XcoeffsB[3] -= p->buf[XADAPTCOEFFSB-3]; - p->XcoeffsB[4] -= p->buf[XADAPTCOEFFSB-4]; - } - else - { - p->XcoeffsA[0] += p->buf[XADAPTCOEFFSA]; - p->XcoeffsA[1] += p->buf[XADAPTCOEFFSA-1]; - p->XcoeffsA[2] += p->buf[XADAPTCOEFFSA-2]; - p->XcoeffsA[3] += p->buf[XADAPTCOEFFSA-3]; - - p->XcoeffsB[0] += p->buf[XADAPTCOEFFSB]; - p->XcoeffsB[1] += p->buf[XADAPTCOEFFSB-1]; - p->XcoeffsB[2] += p->buf[XADAPTCOEFFSB-2]; - p->XcoeffsB[3] += p->buf[XADAPTCOEFFSB-3]; - p->XcoeffsB[4] += p->buf[XADAPTCOEFFSB-4]; - } - } - - *(decoded1++) = p->XfilterA; - - /* Combined */ - p->buf++; - - /* Have we filled the history buffer? */ - if (UNLIKELY(p->buf == p->historybuffer + PREDICTOR_HISTORY_SIZE)) { - memmove(p->historybuffer, p->buf, - PREDICTOR_SIZE * sizeof(int32_t)); - p->buf = p->historybuffer; - } - } -} - -void ICODE_ATTR_DEMAC predictor_decode_mono(struct predictor_t* p, - int32_t* decoded0, - int count) -{ - int32_t predictionA, currentA, A; - - currentA = p->YlastA; - - while (LIKELY(count--)) - { - A = *decoded0; - - p->buf[YDELAYA] = currentA; - p->buf[YDELAYA-1] = p->buf[YDELAYA] - p->buf[YDELAYA-1]; - - predictionA = (p->buf[YDELAYA] * p->YcoeffsA[0]) + - (p->buf[YDELAYA-1] * p->YcoeffsA[1]) + - (p->buf[YDELAYA-2] * p->YcoeffsA[2]) + - (p->buf[YDELAYA-3] * p->YcoeffsA[3]); - - currentA = A + (predictionA >> 10); - - p->buf[YADAPTCOEFFSA] = SIGN(p->buf[YDELAYA]); - p->buf[YADAPTCOEFFSA-1] = SIGN(p->buf[YDELAYA-1]); - - if (LIKELY(A != 0)) - { - if (A > 0) - { - p->YcoeffsA[0] -= p->buf[YADAPTCOEFFSA]; - p->YcoeffsA[1] -= p->buf[YADAPTCOEFFSA-1]; - p->YcoeffsA[2] -= p->buf[YADAPTCOEFFSA-2]; - p->YcoeffsA[3] -= p->buf[YADAPTCOEFFSA-3]; - } - else - { - p->YcoeffsA[0] += p->buf[YADAPTCOEFFSA]; - p->YcoeffsA[1] += p->buf[YADAPTCOEFFSA-1]; - p->YcoeffsA[2] += p->buf[YADAPTCOEFFSA-2]; - p->YcoeffsA[3] += p->buf[YADAPTCOEFFSA-3]; - } - } - - p->buf++; - - /* Have we filled the history buffer? */ - if (UNLIKELY(p->buf == p->historybuffer + PREDICTOR_HISTORY_SIZE)) { - memmove(p->historybuffer, p->buf, - PREDICTOR_SIZE * sizeof(int32_t)); - p->buf = p->historybuffer; - } - - p->YfilterA = currentA + ((p->YfilterA * 31) >> 5); - *(decoded0++) = p->YfilterA; - } - - p->YlastA = currentA; -} -#endif diff --git a/apps/codecs/demac/libdemac/predictor.h b/apps/codecs/demac/libdemac/predictor.h deleted file mode 100644 index 6a0a81983b..0000000000 --- a/apps/codecs/demac/libdemac/predictor.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - -libdemac - A Monkey's Audio decoder - -$Id$ - -Copyright (C) Dave Chapman 2007 - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA - -*/ - -#ifndef _APE_PREDICTOR_H -#define _APE_PREDICTOR_H - -#include -#include "parser.h" -#include "filter.h" - -void init_predictor_decoder(struct predictor_t* p); -void predictor_decode_stereo(struct predictor_t* p, int32_t* decoded0, - int32_t* decoded1, int count); -void predictor_decode_mono(struct predictor_t* p, int32_t* decoded0, - int count); - -#endif diff --git a/apps/codecs/demac/libdemac/udiv32_arm-pre.S b/apps/codecs/demac/libdemac/udiv32_arm-pre.S deleted file mode 100644 index 459cab8240..0000000000 --- a/apps/codecs/demac/libdemac/udiv32_arm-pre.S +++ /dev/null @@ -1,25 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2010 by Andrew Mahone - * - * Wrapper for udiv32_arm.S to test available IRAM by pre-linking the codec. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ - -#define APE_PRE -#include "udiv32_arm.S" diff --git a/apps/codecs/demac/libdemac/udiv32_arm.S b/apps/codecs/demac/libdemac/udiv32_arm.S deleted file mode 100644 index 10c0731db1..0000000000 --- a/apps/codecs/demac/libdemac/udiv32_arm.S +++ /dev/null @@ -1,318 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2008 by Jens Arnold - * Copyright (C) 2009 by Andrew Mahone - * - * Optimised unsigned integer division for ARMv4 - * - * Based on: libgcc routines for ARM cpu, additional algorithms from ARM System - * Developer's Guide - * Division routines, written by Richard Earnshaw, (rearnsha@armltd.co.uk) - * Copyright 1995, 1996, 1998, 1999, 2000, 2003, 2004, 2005 - * Free Software Foundation, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ - -#include "config.h" -/* On targets with codec iram, a header file will be generated after an initial - link of the APE codec, stating the amount of IRAM remaining for use by the - reciprocal lookup table. */ -#if !defined(APE_PRE) && defined(USE_IRAM) && ARM_ARCH < 5 -#include "apps/codecs/ape_free_iram.h" -#endif - -/* Codecs should not normally do this, but we need to check a macro, and - * codecs.h would confuse the assembler. */ - -#ifdef USE_IRAM -#define DIV_RECIP - .section .icode,"ax",%progbits -#else - .text -#endif - .align - .global udiv32_arm - .type udiv32_arm,%function - -#if ARM_ARCH < 5 -/* Adapted from an algorithm given in ARM System Developer's Guide (7.3.1.2) - for dividing a 30-bit value by a 15-bit value, with two operations per - iteration by storing quotient and remainder together and adding the previous - quotient bit during trial subtraction. Modified to work with any dividend - and divisor both less than 1 << 30, and skipping trials by calculating bits - in output. */ -.macro ARM_DIV_31_BODY dividend, divisor, result, bits, curbit, quotient, remainder - - mov \bits, #1 - /* Shift the divisor left until it aligns with the numerator. If it already - has the high bit set, this is fine, everything inside .rept will be - skipped, and the add before and adcs after will set the one-bit result - to zero. */ - cmn \divisor, \dividend, lsr #16 - movcs \divisor, \divisor, lsl #16 - addcs \bits, \bits, #16 - cmn \divisor, \dividend, lsr #8 - movcs \divisor, \divisor, lsl #8 - addcs \bits, \bits, #8 - cmn \divisor, \dividend, lsr #4 - movcs \divisor, \divisor, lsl #4 - addcs \bits, \bits, #4 - cmn \divisor, \dividend, lsr #2 - movcs \divisor, \divisor, lsl #2 - addcs \bits, \bits, #2 - cmn \divisor, \dividend, lsr #1 - movcs \divisor, \divisor, lsl #1 - addcs \bits, \bits, #1 - adds \result, \dividend, \divisor - subcc \result, \result, \divisor - rsb \curbit, \bits, #31 - add pc, pc, \curbit, lsl #3 - nop - .rept 30 - adcs \result, \divisor, \result, lsl #1 - /* Fix the remainder portion of the result. This must be done because the - handler for 32-bit numerators needs the remainder. */ - subcc \result, \result, \divisor - .endr - /* Shift remainder/quotient left one, add final quotient bit */ - adc \result, \result, \result - mov \remainder, \result, lsr \bits - eor \quotient, \result, \remainder, lsl \bits -.endm - -#ifndef FREE_IRAM -.set recip_max, 2 -#else -/* Each table entry is one word. Since a compare is done against the maximum - entry as an immediate, the maximum entry must be a valid ARM immediate, - which means a byte shifted by an even number of places. */ -.set recip_max, 2 + FREE_IRAM / 4 -.set recip_max_tmp, recip_max >> 8 -.set recip_mask_shift, 0 -.set tmp_shift, 16 -.rept 5 - .if recip_max_tmp >> tmp_shift - .set recip_max_tmp, recip_max_tmp >> tmp_shift - .set recip_mask_shift, recip_mask_shift + tmp_shift - .endif - .set tmp_shift, tmp_shift >> 1 -.endr -.if recip_max_tmp - .set recip_mask_shift, recip_mask_shift + 1 -.endif -.set recip_mask_shift, (recip_mask_shift + 1) & 62 -.set recip_max, recip_max & (255 << recip_mask_shift) -//.set recip_max, 2 -#endif - -udiv32_arm: -#ifdef DIV_RECIP - cmp r1, #3 - bcc .L_udiv_tiny - cmp r1, #recip_max - bhi .L_udiv - adr r3, .L_udiv_recip_table-12 - ldr r2, [r3, r1, lsl #2] - mov r3, r0 - umull ip, r0, r2, r0 - mul r2, r0, r1 - cmp r3, r2 - bxcs lr - sub r0, r0, #1 - bx lr -.L_udiv_tiny: - cmp r1, #1 - movhi r0, r0, lsr #1 - bxcs lr - b .L_div0 -#endif -.L_udiv: - /* Invert divisor. ARM_DIV_31_BODY uses adc to both subtract the divisor - and add the next bit of the result. The correction code at .L_udiv32 - does not need the divisor inverted, but can be modified to work with it, - and this allows the zero divisor test to be done early and without an - explicit comparison. */ - rsbs r1, r1, #0 -#ifndef DIV_RECIP - beq .L_div0 -#endif - tst r0, r0 - /* High bit must be unset, otherwise shift numerator right, calculate, - and correct results. As this case is very uncommon we want to avoid - any other delays on the main path in handling it, so the long divide - calls the short divide as a function. */ - bmi .L_udiv32 -.L_udiv31: - ARM_DIV_31_BODY r0, r1, r2, r3, ip, r0, r1 - bx lr -.L_udiv32: - /* store original numerator and divisor, we'll need them to correct the - result, */ - stmdb sp, { r0, r1, lr } - /* Call __div0 here if divisor is zero, otherwise it would report the wrong - address. */ - mov r0, r0, lsr #1 - bl .L_udiv31 - ldmdb sp, { r2, r3, lr } - /* Move the low bit of the original numerator to the carry bit */ - movs r2, r2, lsr #1 - /* Shift the remainder left one and add in the carry bit */ - adc r1, r1, r1 - /* Subtract the original divisor from the remainder, setting carry if the - result is non-negative */ - adds r1, r1, r3 - /* Shift quotient left one and add carry bit */ - adc r0, r0, r0 - bx lr -.L_div0: - /* __div0 expects the calling address on the top of the stack */ - stmdb sp!, { lr } - mov r0, #0 -#if defined(__ARM_EABI__) || !defined(USE_IRAM) - bl __div0 -#else - ldr pc, [pc, #-4] - .word __div0 -#endif -#ifdef DIV_RECIP -.L_udiv_recip_table: - .set div, 3 - .rept recip_max - 2 - .if (div - 1) & div - .set q, 0x40000000 / div - .set r, (0x40000000 - (q * div))<<1 - .set q, q << 1 - .if r >= div - .set q, q + 1 - .set r, r - div - .endif - .set r, r << 1 - .set q, q << 1 - .if r >= div - .set q, q + 1 - .set r, r - div - .endif - .set q, q + 1 - .else - .set q, 0x40000000 / div * 4 - .endif - .word q - .set div, div+1 - .endr -#endif - .size udiv32_arm, . - udiv32_arm - -#else -.macro ARMV5_UDIV32_BODY numerator, divisor, quotient, bits, inv, neg, div0label - cmp \numerator, \divisor - clz \bits, \divisor - bcc 30f - mov \inv, \divisor, lsl \bits - add \neg, pc, \inv, lsr #25 - cmp \inv, #1<<31 - ldrhib \inv, [\neg, #.L_udiv_est_table-.-64] - bls 20f - subs \bits, \bits, #7 - rsb \neg, \divisor, #0 - movpl \divisor, \inv, lsl \bits - bmi 10f - mul \inv, \divisor, \neg - smlawt \divisor, \divisor, \inv, \divisor - mul \inv, \divisor, \neg - /* This will save a cycle on ARMv6, but requires that the numerator sign - bit is not set (that of inv is guaranteed unset). The branch should - predict very well, making it typically 1 cycle, and thus both the branch - and test fill delay cycles for the multiplies. Based on logging of - numerator sizes in the APE codec, the branch is taken about 1/10^7 of - the time. */ -#if ARM_ARCH >= 6 - tst \numerator, \numerator - smmla \divisor, \divisor, \inv, \divisor - bmi 40f - smmul \inv, \numerator, \divisor -#else - mov \bits, #0 - smlal \bits, \divisor, \inv, \divisor - umull \bits, \inv, \numerator, \divisor -#endif - add \numerator, \numerator, \neg - mla \divisor, \inv, \neg, \numerator - mov \quotient, \inv - cmn \divisor, \neg - addcc \quotient, \quotient, #1 - addpl \quotient, \quotient, #2 - bx lr -10: - rsb \bits, \bits, #0 - sub \inv, \inv, #4 - mov \divisor, \inv, lsr \bits - umull \bits, \inv, \numerator, \divisor - mla \divisor, \inv, \neg, \numerator - mov \quotient, \inv - cmn \neg, \divisor, lsr #1 - addcs \divisor, \divisor, \neg, lsl #1 - addcs \quotient, \quotient, #2 - cmn \neg, \divisor - addcs \quotient, \quotient, #1 - bx lr -20: -.ifnc "", "\div0label" - rsb \bits, \bits, #31 - bne \div0label -.endif - mov \quotient, \numerator, lsr \bits - bx lr -30: - mov \quotient, #0 - bx lr -#if ARM_ARCH >= 6 -40: - umull \bits, \inv, \numerator, \divisor - add \numerator, \numerator, \neg - mla \divisor, \inv, \neg, \numerator - mov \quotient, \inv - cmn \divisor, \neg - addcc \quotient, \quotient, #1 - addpl \quotient, \quotient, #2 - bx lr -#endif -.endm - -udiv32_arm: - ARMV5_UDIV32_BODY r0, r1, r0, r2, r3, ip, .L_div0 -.L_div0: - /* __div0 expects the calling address on the top of the stack */ - stmdb sp!, { lr } - mov r0, #0 -#if defined(__ARM_EABI__) || !defined(USE_IRAM) - bl __div0 -#else - ldr pc, [pc, #-4] - .word __div0 -#endif -.L_udiv_est_table: - .byte 0xff, 0xfc, 0xf8, 0xf4, 0xf0, 0xed, 0xea, 0xe6 - .byte 0xe3, 0xe0, 0xdd, 0xda, 0xd7, 0xd4, 0xd2, 0xcf - .byte 0xcc, 0xca, 0xc7, 0xc5, 0xc3, 0xc0, 0xbe, 0xbc - .byte 0xba, 0xb8, 0xb6, 0xb4, 0xb2, 0xb0, 0xae, 0xac - .byte 0xaa, 0xa8, 0xa7, 0xa5, 0xa3, 0xa2, 0xa0, 0x9f - .byte 0x9d, 0x9c, 0x9a, 0x99, 0x97, 0x96, 0x94, 0x93 - .byte 0x92, 0x90, 0x8f, 0x8e, 0x8d, 0x8c, 0x8a, 0x89 - .byte 0x88, 0x87, 0x86, 0x85, 0x84, 0x83, 0x82, 0x81 -#endif - .size udiv32_arm, . - udiv32_arm diff --git a/apps/codecs/demac/libdemac/vector_math16_armv5te.h b/apps/codecs/demac/libdemac/vector_math16_armv5te.h deleted file mode 100644 index ae7427c137..0000000000 --- a/apps/codecs/demac/libdemac/vector_math16_armv5te.h +++ /dev/null @@ -1,404 +0,0 @@ -/* - -libdemac - A Monkey's Audio decoder - -$Id$ - -Copyright (C) Dave Chapman 2007 - -ARMv5te vector math copyright (C) 2008 Jens Arnold - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA - -*/ - -#define FUSED_VECTOR_MATH - -#define REPEAT_3(x) x x x -#if ORDER > 16 -#define REPEAT_MLA(x) x x x x x x x -#else -#define REPEAT_MLA(x) x x x -#endif - -/* Calculate scalarproduct, then add a 2nd vector (fused for performance) - * This version fetches data as 32 bit words, and *requires* v1 to be - * 32 bit aligned. It also requires that f2 and s2 are either both 32 bit - * aligned or both unaligned. If either condition isn't met, it will either - * result in a data abort or incorrect results. */ -static inline int32_t vector_sp_add(int16_t* v1, int16_t* f2, int16_t* s2) -{ - int res; -#if ORDER > 16 - int cnt = ORDER>>4; -#endif - -#define ADDHALFREGS(sum, s1, s2) /* Adds register */ \ - "mov " #s1 ", " #s1 ", ror #16 \n" /* halves straight */ \ - "add " #sum ", " #s1 ", " #s2 ", lsl #16 \n" /* Clobbers 's1' */ \ - "add " #s1 ", " #s1 ", " #s2 ", lsr #16 \n" \ - "mov " #s1 ", " #s1 ", lsl #16 \n" \ - "orr " #sum ", " #s1 ", " #sum ", lsr #16 \n" - -#define ADDHALFXREGS(sum, s1, s2) /* Adds register */ \ - "add " #s1 ", " #s1 ", " #sum ", lsl #16 \n" /* halves across. */ \ - "add " #sum ", " #s2 ", " #sum ", lsr #16 \n" /* Clobbers 's1'. */ \ - "mov " #sum ", " #sum ", lsl #16 \n" \ - "orr " #sum ", " #sum ", " #s1 ", lsr #16 \n" - - asm volatile ( -#if ORDER > 16 - "mov %[res], #0 \n" -#endif - "tst %[f2], #2 \n" - "beq 20f \n" - - "10: \n" - "ldrh r4, [%[s2]], #2 \n" - "mov r4, r4, lsl #16 \n" - "ldrh r3, [%[f2]], #2 \n" -#if ORDER > 16 - "mov r3, r3, lsl #16 \n" - "1: \n" - "ldmia %[v1], {r0,r1} \n" - "smlabt %[res], r0, r3, %[res] \n" -#else - "ldmia %[v1], {r0,r1} \n" - "smulbb %[res], r0, r3 \n" -#endif - "ldmia %[f2]!, {r2,r3} \n" - "smlatb %[res], r0, r2, %[res] \n" - "smlabt %[res], r1, r2, %[res] \n" - "smlatb %[res], r1, r3, %[res] \n" - "ldmia %[s2]!, {r2,r5} \n" - ADDHALFXREGS(r0, r4, r2) - ADDHALFXREGS(r1, r2, r5) - "stmia %[v1]!, {r0,r1} \n" - "ldmia %[v1], {r0,r1} \n" - "smlabt %[res], r0, r3, %[res] \n" - "ldmia %[f2]!, {r2,r3} \n" - "smlatb %[res], r0, r2, %[res] \n" - "smlabt %[res], r1, r2, %[res] \n" - "smlatb %[res], r1, r3, %[res] \n" - "ldmia %[s2]!, {r2,r4} \n" - ADDHALFXREGS(r0, r5, r2) - ADDHALFXREGS(r1, r2, r4) - "stmia %[v1]!, {r0,r1} \n" - - "ldmia %[v1], {r0,r1} \n" - "smlabt %[res], r0, r3, %[res] \n" - "ldmia %[f2]!, {r2,r3} \n" - "smlatb %[res], r0, r2, %[res] \n" - "smlabt %[res], r1, r2, %[res] \n" - "smlatb %[res], r1, r3, %[res] \n" - "ldmia %[s2]!, {r2,r5} \n" - ADDHALFXREGS(r0, r4, r2) - ADDHALFXREGS(r1, r2, r5) - "stmia %[v1]!, {r0,r1} \n" - "ldmia %[v1], {r0,r1} \n" - "smlabt %[res], r0, r3, %[res] \n" - "ldmia %[f2]!, {r2,r3} \n" - "smlatb %[res], r0, r2, %[res] \n" - "smlabt %[res], r1, r2, %[res] \n" - "smlatb %[res], r1, r3, %[res] \n" - "ldmia %[s2]!, {r2,r4} \n" - ADDHALFXREGS(r0, r5, r2) - ADDHALFXREGS(r1, r2, r4) - "stmia %[v1]!, {r0,r1} \n" -#if ORDER > 16 - "subs %[cnt], %[cnt], #1 \n" - "bne 1b \n" -#endif - "b 99f \n" - - "20: \n" - "1: \n" - "ldmia %[v1], {r1,r2} \n" - "ldmia %[f2]!, {r3,r4} \n" -#if ORDER > 16 - "smlabb %[res], r1, r3, %[res] \n" -#else - "smulbb %[res], r1, r3 \n" -#endif - "smlatt %[res], r1, r3, %[res] \n" - "smlabb %[res], r2, r4, %[res] \n" - "smlatt %[res], r2, r4, %[res] \n" - "ldmia %[s2]!, {r3,r4} \n" - ADDHALFREGS(r0, r1, r3) - ADDHALFREGS(r1, r2, r4) - "stmia %[v1]!, {r0,r1} \n" - - REPEAT_3( - "ldmia %[v1], {r1,r2} \n" - "ldmia %[f2]!, {r3,r4} \n" - "smlabb %[res], r1, r3, %[res] \n" - "smlatt %[res], r1, r3, %[res] \n" - "smlabb %[res], r2, r4, %[res] \n" - "smlatt %[res], r2, r4, %[res] \n" - "ldmia %[s2]!, {r3,r4} \n" - ADDHALFREGS(r0, r1, r3) - ADDHALFREGS(r1, r2, r4) - "stmia %[v1]!, {r0,r1} \n" - ) -#if ORDER > 16 - "subs %[cnt], %[cnt], #1 \n" - "bne 1b \n" -#endif - - "99: \n" - : /* outputs */ -#if ORDER > 16 - [cnt]"+r"(cnt), -#endif - [v1] "+r"(v1), - [f2] "+r"(f2), - [s2] "+r"(s2), - [res]"=r"(res) - : /* inputs */ - : /* clobbers */ - "r0", "r1", "r2", "r3", "r4", "r5", "cc", "memory" - ); - return res; -} - -/* Calculate scalarproduct, then subtract a 2nd vector (fused for performance) - * This version fetches data as 32 bit words, and *requires* v1 to be - * 32 bit aligned. It also requires that f2 and s2 are either both 32 bit - * aligned or both unaligned. If either condition isn't met, it will either - * result in a data abort or incorrect results. */ -static inline int32_t vector_sp_sub(int16_t* v1, int16_t* f2, int16_t* s2) -{ - int res; -#if ORDER > 16 - int cnt = ORDER>>4; -#endif - -#define SUBHALFREGS(dif, s1, s2) /* Subtracts reg. */ \ - "mov " #s1 ", " #s1 ", ror #16 \n" /* halves straight */ \ - "sub " #dif ", " #s1 ", " #s2 ", lsl #16 \n" /* Clobbers 's1' */ \ - "sub " #s1 ", " #s1 ", " #s2 ", lsr #16 \n" \ - "mov " #s1 ", " #s1 ", lsl #16 \n" \ - "orr " #dif ", " #s1 ", " #dif ", lsr #16 \n" - -#define SUBHALFXREGS(dif, s1, s2, msk) /* Subtracts reg. */ \ - "sub " #s1 ", " #dif ", " #s1 ", lsr #16 \n" /* halves across. */ \ - "and " #s1 ", " #s1 ", " #msk " \n" /* Needs msk = */ \ - "rsb " #dif ", " #s2 ", " #dif ", lsr #16 \n" /* 0x0000ffff, */ \ - "orr " #dif ", " #s1 ", " #dif ", lsl #16 \n" /* clobbers 's1'. */ - - asm volatile ( -#if ORDER > 16 - "mov %[res], #0 \n" -#endif - "tst %[f2], #2 \n" - "beq 20f \n" - - "10: \n" - "mov r6, #0xff \n" - "orr r6, r6, #0xff00 \n" - "ldrh r4, [%[s2]], #2 \n" - "mov r4, r4, lsl #16 \n" - "ldrh r3, [%[f2]], #2 \n" -#if ORDER > 16 - "mov r3, r3, lsl #16 \n" - "1: \n" - "ldmia %[v1], {r0,r1} \n" - "smlabt %[res], r0, r3, %[res] \n" -#else - "ldmia %[v1], {r0,r1} \n" - "smulbb %[res], r0, r3 \n" -#endif - "ldmia %[f2]!, {r2,r3} \n" - "smlatb %[res], r0, r2, %[res] \n" - "smlabt %[res], r1, r2, %[res] \n" - "smlatb %[res], r1, r3, %[res] \n" - "ldmia %[s2]!, {r2,r5} \n" - SUBHALFXREGS(r0, r4, r2, r6) - SUBHALFXREGS(r1, r2, r5, r6) - "stmia %[v1]!, {r0,r1} \n" - "ldmia %[v1], {r0,r1} \n" - "smlabt %[res], r0, r3, %[res] \n" - "ldmia %[f2]!, {r2,r3} \n" - "smlatb %[res], r0, r2, %[res] \n" - "smlabt %[res], r1, r2, %[res] \n" - "smlatb %[res], r1, r3, %[res] \n" - "ldmia %[s2]!, {r2,r4} \n" - SUBHALFXREGS(r0, r5, r2, r6) - SUBHALFXREGS(r1, r2, r4, r6) - "stmia %[v1]!, {r0,r1} \n" - - "ldmia %[v1], {r0,r1} \n" - "smlabt %[res], r0, r3, %[res] \n" - "ldmia %[f2]!, {r2,r3} \n" - "smlatb %[res], r0, r2, %[res] \n" - "smlabt %[res], r1, r2, %[res] \n" - "smlatb %[res], r1, r3, %[res] \n" - "ldmia %[s2]!, {r2,r5} \n" - SUBHALFXREGS(r0, r4, r2, r6) - SUBHALFXREGS(r1, r2, r5, r6) - "stmia %[v1]!, {r0,r1} \n" - "ldmia %[v1], {r0,r1} \n" - "smlabt %[res], r0, r3, %[res] \n" - "ldmia %[f2]!, {r2,r3} \n" - "smlatb %[res], r0, r2, %[res] \n" - "smlabt %[res], r1, r2, %[res] \n" - "smlatb %[res], r1, r3, %[res] \n" - "ldmia %[s2]!, {r2,r4} \n" - SUBHALFXREGS(r0, r5, r2, r6) - SUBHALFXREGS(r1, r2, r4, r6) - "stmia %[v1]!, {r0,r1} \n" -#if ORDER > 16 - "subs %[cnt], %[cnt], #1 \n" - "bne 1b \n" -#endif - "b 99f \n" - - "20: \n" - "1: \n" - "ldmia %[v1], {r1,r2} \n" - "ldmia %[f2]!, {r3,r4} \n" -#if ORDER > 16 - "smlabb %[res], r1, r3, %[res] \n" -#else - "smulbb %[res], r1, r3 \n" -#endif - "smlatt %[res], r1, r3, %[res] \n" - "smlabb %[res], r2, r4, %[res] \n" - "smlatt %[res], r2, r4, %[res] \n" - "ldmia %[s2]!, {r3,r4} \n" - SUBHALFREGS(r0, r1, r3) - SUBHALFREGS(r1, r2, r4) - "stmia %[v1]!, {r0,r1} \n" - - REPEAT_3( - "ldmia %[v1], {r1,r2} \n" - "ldmia %[f2]!, {r3,r4} \n" - "smlabb %[res], r1, r3, %[res] \n" - "smlatt %[res], r1, r3, %[res] \n" - "smlabb %[res], r2, r4, %[res] \n" - "smlatt %[res], r2, r4, %[res] \n" - "ldmia %[s2]!, {r3,r4} \n" - SUBHALFREGS(r0, r1, r3) - SUBHALFREGS(r1, r2, r4) - "stmia %[v1]!, {r0,r1} \n" - ) -#if ORDER > 16 - "subs %[cnt], %[cnt], #1 \n" - "bne 1b \n" -#endif - - "99: \n" - : /* outputs */ -#if ORDER > 16 - [cnt]"+r"(cnt), -#endif - [v1] "+r"(v1), - [f2] "+r"(f2), - [s2] "+r"(s2), - [res]"=r"(res) - : /* inputs */ - : /* clobbers */ - "r0", "r1", "r2", "r3", "r4", "r5", "r6", "cc", "memory" - ); - return res; -} - -/* This version fetches data as 32 bit words, and *requires* v1 to be - * 32 bit aligned, otherwise it will result either in a data abort, or - * incorrect results (if ARM aligncheck is disabled). */ -static inline int32_t scalarproduct(int16_t* v1, int16_t* v2) -{ - int res; -#if ORDER > 32 - int cnt = ORDER>>5; -#endif - - asm volatile ( -#if ORDER > 32 - "mov %[res], #0 \n" -#endif - "tst %[v2], #2 \n" - "beq 20f \n" - - "10: \n" - "ldrh r3, [%[v2]], #2 \n" -#if ORDER > 32 - "mov r3, r3, lsl #16 \n" - "1: \n" - "ldmia %[v1]!, {r0,r1} \n" - "smlabt %[res], r0, r3, %[res] \n" -#else - "ldmia %[v1]!, {r0,r1} \n" - "smulbb %[res], r0, r3 \n" -#endif - "ldmia %[v2]!, {r2,r3} \n" - "smlatb %[res], r0, r2, %[res] \n" - "smlabt %[res], r1, r2, %[res] \n" - "smlatb %[res], r1, r3, %[res] \n" - - REPEAT_MLA( - "ldmia %[v1]!, {r0,r1} \n" - "smlabt %[res], r0, r3, %[res] \n" - "ldmia %[v2]!, {r2,r3} \n" - "smlatb %[res], r0, r2, %[res] \n" - "smlabt %[res], r1, r2, %[res] \n" - "smlatb %[res], r1, r3, %[res] \n" - ) -#if ORDER > 32 - "subs %[cnt], %[cnt], #1 \n" - "bne 1b \n" -#endif - "b 99f \n" - - "20: \n" - "1: \n" - "ldmia %[v1]!, {r0,r1} \n" - "ldmia %[v2]!, {r2,r3} \n" -#if ORDER > 32 - "smlabb %[res], r0, r2, %[res] \n" -#else - "smulbb %[res], r0, r2 \n" -#endif - "smlatt %[res], r0, r2, %[res] \n" - "smlabb %[res], r1, r3, %[res] \n" - "smlatt %[res], r1, r3, %[res] \n" - - REPEAT_MLA( - "ldmia %[v1]!, {r0,r1} \n" - "ldmia %[v2]!, {r2,r3} \n" - "smlabb %[res], r0, r2, %[res] \n" - "smlatt %[res], r0, r2, %[res] \n" - "smlabb %[res], r1, r3, %[res] \n" - "smlatt %[res], r1, r3, %[res] \n" - ) -#if ORDER > 32 - "subs %[cnt], %[cnt], #1 \n" - "bne 1b \n" -#endif - - "99: \n" - : /* outputs */ -#if ORDER > 32 - [cnt]"+r"(cnt), -#endif - [v1] "+r"(v1), - [v2] "+r"(v2), - [res]"=r"(res) - : /* inputs */ - : /* clobbers */ - "r0", "r1", "r2", "r3", "cc", "memory" - ); - return res; -} diff --git a/apps/codecs/demac/libdemac/vector_math16_armv6.h b/apps/codecs/demac/libdemac/vector_math16_armv6.h deleted file mode 100644 index 8d27331b62..0000000000 --- a/apps/codecs/demac/libdemac/vector_math16_armv6.h +++ /dev/null @@ -1,490 +0,0 @@ -/* - -libdemac - A Monkey's Audio decoder - -$Id$ - -Copyright (C) Dave Chapman 2007 - -ARMv6 vector math copyright (C) 2008 Jens Arnold - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA - -*/ - -#define FUSED_VECTOR_MATH - -#if ORDER > 16 -#define REPEAT_BLOCK(x) x x x -#else -#define REPEAT_BLOCK(x) x -#endif - -/* Calculate scalarproduct, then add a 2nd vector (fused for performance) - * This version fetches data as 32 bit words, and *requires* v1 to be - * 32 bit aligned. It also requires that f2 and s2 are either both 32 bit - * aligned or both unaligned. If either condition isn't met, it will either - * result in a data abort or incorrect results. */ -static inline int32_t vector_sp_add(int16_t* v1, int16_t* f2, int16_t* s2) -{ - int res; -#if ORDER > 32 - int cnt = ORDER>>5; -#endif - - asm volatile ( -#if ORDER > 32 - "mov %[res], #0 \n" -#endif - "tst %[f2], #2 \n" - "beq 20f \n" - - "10: \n" - "ldrh r3, [%[f2]], #2 \n" - "ldrh r6, [%[s2]], #2 \n" - "ldmia %[f2]!, {r2,r4} \n" - "mov r3, r3, lsl #16 \n" - "mov r6, r6, lsl #16 \n" - - "1: \n" - "ldmia %[s2]!, {r5,r7} \n" - "pkhtb r3, r3, r2 \n" - "pkhtb r2, r2, r4 \n" - "ldrd r0, [%[v1]] \n" - "mov r5, r5, ror #16 \n" - "pkhtb r6, r5, r6, asr #16 \n" - "pkhbt r5, r5, r7, lsl #16 \n" -#if ORDER > 32 - "smladx %[res], r0, r3, %[res] \n" -#else - "smuadx %[res], r0, r3 \n" -#endif - "smladx %[res], r1, r2, %[res] \n" - "ldmia %[f2]!, {r2,r3} \n" - "sadd16 r0, r0, r6 \n" - "sadd16 r1, r1, r5 \n" - "strd r0, [%[v1]], #8 \n" - - REPEAT_BLOCK( - "ldmia %[s2]!, {r5,r6} \n" - "pkhtb r4, r4, r2 \n" - "pkhtb r2, r2, r3 \n" - "ldrd r0, [%[v1]] \n" - "mov r5, r5, ror #16 \n" - "pkhtb r7, r5, r7, asr #16 \n" - "pkhbt r5, r5, r6, lsl #16 \n" - "smladx %[res], r0, r4, %[res] \n" - "smladx %[res], r1, r2, %[res] \n" - "ldmia %[f2]!, {r2,r4} \n" - "sadd16 r0, r0, r7 \n" - "sadd16 r1, r1, r5 \n" - "strd r0, [%[v1]], #8 \n" - "ldmia %[s2]!, {r5,r7} \n" - "pkhtb r3, r3, r2 \n" - "pkhtb r2, r2, r4 \n" - "ldrd r0, [%[v1]] \n" - "mov r5, r5, ror #16 \n" - "pkhtb r6, r5, r6, asr #16 \n" - "pkhbt r5, r5, r7, lsl #16 \n" - "smladx %[res], r0, r3, %[res] \n" - "smladx %[res], r1, r2, %[res] \n" - "ldmia %[f2]!, {r2,r3} \n" - "sadd16 r0, r0, r6 \n" - "sadd16 r1, r1, r5 \n" - "strd r0, [%[v1]], #8 \n" - ) - - "ldmia %[s2]!, {r5,r6} \n" - "pkhtb r4, r4, r2 \n" - "pkhtb r2, r2, r3 \n" - "ldrd r0, [%[v1]] \n" - "mov r5, r5, ror #16 \n" - "pkhtb r7, r5, r7, asr #16 \n" - "pkhbt r5, r5, r6, lsl #16 \n" - "smladx %[res], r0, r4, %[res] \n" - "smladx %[res], r1, r2, %[res] \n" -#if ORDER > 32 - "subs %[cnt], %[cnt], #1 \n" - "ldmneia %[f2]!, {r2,r4} \n" - "sadd16 r0, r0, r7 \n" - "sadd16 r1, r1, r5 \n" - "strd r0, [%[v1]], #8 \n" - "bne 1b \n" -#else - "sadd16 r0, r0, r7 \n" - "sadd16 r1, r1, r5 \n" - "strd r0, [%[v1]], #8 \n" -#endif - - "b 99f \n" - - "20: \n" - "ldrd r4, [%[f2]], #8 \n" - "ldrd r0, [%[v1]] \n" - -#if ORDER > 32 - "1: \n" - "smlad %[res], r0, r4, %[res] \n" -#else - "smuad %[res], r0, r4 \n" -#endif - "ldrd r6, [%[s2]], #8 \n" - "smlad %[res], r1, r5, %[res] \n" - "ldrd r4, [%[f2]], #8 \n" - "ldrd r2, [%[v1], #8] \n" - "sadd16 r0, r0, r6 \n" - "sadd16 r1, r1, r7 \n" - "strd r0, [%[v1]], #8 \n" - - REPEAT_BLOCK( - "smlad %[res], r2, r4, %[res] \n" - "ldrd r6, [%[s2]], #8 \n" - "smlad %[res], r3, r5, %[res] \n" - "ldrd r4, [%[f2]], #8 \n" - "ldrd r0, [%[v1], #8] \n" - "sadd16 r2, r2, r6 \n" - "sadd16 r3, r3, r7 \n" - "strd r2, [%[v1]], #8 \n" - "smlad %[res], r0, r4, %[res] \n" - "ldrd r6, [%[s2]], #8 \n" - "smlad %[res], r1, r5, %[res] \n" - "ldrd r4, [%[f2]], #8 \n" - "ldrd r2, [%[v1], #8] \n" - "sadd16 r0, r0, r6 \n" - "sadd16 r1, r1, r7 \n" - "strd r0, [%[v1]], #8 \n" - ) - - "smlad %[res], r2, r4, %[res] \n" - "ldrd r6, [%[s2]], #8 \n" - "smlad %[res], r3, r5, %[res] \n" -#if ORDER > 32 - "subs %[cnt], %[cnt], #1 \n" - "ldrned r4, [%[f2]], #8 \n" - "ldrned r0, [%[v1], #8] \n" - "sadd16 r2, r2, r6 \n" - "sadd16 r3, r3, r7 \n" - "strd r2, [%[v1]], #8 \n" - "bne 1b \n" -#else - "sadd16 r2, r2, r6 \n" - "sadd16 r3, r3, r7 \n" - "strd r2, [%[v1]], #8 \n" -#endif - - "99: \n" - : /* outputs */ -#if ORDER > 32 - [cnt]"+r"(cnt), -#endif - [v1] "+r"(v1), - [f2] "+r"(f2), - [s2] "+r"(s2), - [res]"=r"(res) - : /* inputs */ - : /* clobbers */ - "r0", "r1", "r2", "r3", "r4", - "r5", "r6", "r7", "cc", "memory" - ); - return res; -} - -/* Calculate scalarproduct, then subtract a 2nd vector (fused for performance) - * This version fetches data as 32 bit words, and *requires* v1 to be - * 32 bit aligned. It also requires that f2 and s2 are either both 32 bit - * aligned or both unaligned. If either condition isn't met, it will either - * result in a data abort or incorrect results. */ -static inline int32_t vector_sp_sub(int16_t* v1, int16_t* f2, int16_t* s2) -{ - int res; -#if ORDER > 32 - int cnt = ORDER>>5; -#endif - - asm volatile ( -#if ORDER > 32 - "mov %[res], #0 \n" -#endif - "tst %[f2], #2 \n" - "beq 20f \n" - - "10: \n" - "ldrh r3, [%[f2]], #2 \n" - "ldrh r6, [%[s2]], #2 \n" - "ldmia %[f2]!, {r2,r4} \n" - "mov r3, r3, lsl #16 \n" - "mov r6, r6, lsl #16 \n" - - "1: \n" - "ldmia %[s2]!, {r5,r7} \n" - "pkhtb r3, r3, r2 \n" - "pkhtb r2, r2, r4 \n" - "ldrd r0, [%[v1]] \n" - "mov r5, r5, ror #16 \n" - "pkhtb r6, r5, r6, asr #16 \n" - "pkhbt r5, r5, r7, lsl #16 \n" -#if ORDER > 32 - "smladx %[res], r0, r3, %[res] \n" -#else - "smuadx %[res], r0, r3 \n" -#endif - "smladx %[res], r1, r2, %[res] \n" - "ldmia %[f2]!, {r2,r3} \n" - "ssub16 r0, r0, r6 \n" - "ssub16 r1, r1, r5 \n" - "strd r0, [%[v1]], #8 \n" - - REPEAT_BLOCK( - "ldmia %[s2]!, {r5,r6} \n" - "pkhtb r4, r4, r2 \n" - "pkhtb r2, r2, r3 \n" - "ldrd r0, [%[v1]] \n" - "mov r5, r5, ror #16 \n" - "pkhtb r7, r5, r7, asr #16 \n" - "pkhbt r5, r5, r6, lsl #16 \n" - "smladx %[res], r0, r4, %[res] \n" - "smladx %[res], r1, r2, %[res] \n" - "ldmia %[f2]!, {r2,r4} \n" - "ssub16 r0, r0, r7 \n" - "ssub16 r1, r1, r5 \n" - "strd r0, [%[v1]], #8 \n" - "ldmia %[s2]!, {r5,r7} \n" - "pkhtb r3, r3, r2 \n" - "pkhtb r2, r2, r4 \n" - "ldrd r0, [%[v1]] \n" - "mov r5, r5, ror #16 \n" - "pkhtb r6, r5, r6, asr #16 \n" - "pkhbt r5, r5, r7, lsl #16 \n" - "smladx %[res], r0, r3, %[res] \n" - "smladx %[res], r1, r2, %[res] \n" - "ldmia %[f2]!, {r2,r3} \n" - "ssub16 r0, r0, r6 \n" - "ssub16 r1, r1, r5 \n" - "strd r0, [%[v1]], #8 \n" - ) - - "ldmia %[s2]!, {r5,r6} \n" - "pkhtb r4, r4, r2 \n" - "pkhtb r2, r2, r3 \n" - "ldrd r0, [%[v1]] \n" - "mov r5, r5, ror #16 \n" - "pkhtb r7, r5, r7, asr #16 \n" - "pkhbt r5, r5, r6, lsl #16 \n" - "smladx %[res], r0, r4, %[res] \n" - "smladx %[res], r1, r2, %[res] \n" -#if ORDER > 32 - "subs %[cnt], %[cnt], #1 \n" - "ldmneia %[f2]!, {r2,r4} \n" - "ssub16 r0, r0, r7 \n" - "ssub16 r1, r1, r5 \n" - "strd r0, [%[v1]], #8 \n" - "bne 1b \n" -#else - "ssub16 r0, r0, r7 \n" - "ssub16 r1, r1, r5 \n" - "strd r0, [%[v1]], #8 \n" -#endif - - "b 99f \n" - - "20: \n" - "ldrd r4, [%[f2]], #8 \n" - "ldrd r0, [%[v1]] \n" - -#if ORDER > 32 - "1: \n" - "smlad %[res], r0, r4, %[res] \n" -#else - "smuad %[res], r0, r4 \n" -#endif - "ldrd r6, [%[s2]], #8 \n" - "smlad %[res], r1, r5, %[res] \n" - "ldrd r4, [%[f2]], #8 \n" - "ldrd r2, [%[v1], #8] \n" - "ssub16 r0, r0, r6 \n" - "ssub16 r1, r1, r7 \n" - "strd r0, [%[v1]], #8 \n" - - REPEAT_BLOCK( - "smlad %[res], r2, r4, %[res] \n" - "ldrd r6, [%[s2]], #8 \n" - "smlad %[res], r3, r5, %[res] \n" - "ldrd r4, [%[f2]], #8 \n" - "ldrd r0, [%[v1], #8] \n" - "ssub16 r2, r2, r6 \n" - "ssub16 r3, r3, r7 \n" - "strd r2, [%[v1]], #8 \n" - "smlad %[res], r0, r4, %[res] \n" - "ldrd r6, [%[s2]], #8 \n" - "smlad %[res], r1, r5, %[res] \n" - "ldrd r4, [%[f2]], #8 \n" - "ldrd r2, [%[v1], #8] \n" - "ssub16 r0, r0, r6 \n" - "ssub16 r1, r1, r7 \n" - "strd r0, [%[v1]], #8 \n" - ) - - "smlad %[res], r2, r4, %[res] \n" - "ldrd r6, [%[s2]], #8 \n" - "smlad %[res], r3, r5, %[res] \n" -#if ORDER > 32 - "subs %[cnt], %[cnt], #1 \n" - "ldrned r4, [%[f2]], #8 \n" - "ldrned r0, [%[v1], #8] \n" - "ssub16 r2, r2, r6 \n" - "ssub16 r3, r3, r7 \n" - "strd r2, [%[v1]], #8 \n" - "bne 1b \n" -#else - "ssub16 r2, r2, r6 \n" - "ssub16 r3, r3, r7 \n" - "strd r2, [%[v1]], #8 \n" -#endif - - "99: \n" - : /* outputs */ -#if ORDER > 32 - [cnt]"+r"(cnt), -#endif - [v1] "+r"(v1), - [f2] "+r"(f2), - [s2] "+r"(s2), - [res]"=r"(res) - : /* inputs */ - : /* clobbers */ - "r0", "r1", "r2", "r3", "r4", - "r5", "r6", "r7", "cc", "memory" - ); - return res; -} - -/* This version fetches data as 32 bit words, and *requires* v1 to be - * 32 bit aligned, otherwise it will result either in a data abort, or - * incorrect results (if ARM aligncheck is disabled). */ -static inline int32_t scalarproduct(int16_t* v1, int16_t* v2) -{ - int res; -#if ORDER > 32 - int cnt = ORDER>>5; -#endif - - asm volatile ( -#if ORDER > 32 - "mov %[res], #0 \n" -#endif - "tst %[v2], #2 \n" - "beq 20f \n" - - "10: \n" - "bic %[v2], %[v2], #2 \n" - "ldmia %[v2]!, {r5-r7} \n" - "ldrd r0, [%[v1]], #8 \n" - - "1: \n" - "pkhtb r3, r5, r6 \n" - "ldrd r4, [%[v2]], #8 \n" -#if ORDER > 32 - "smladx %[res], r0, r3, %[res] \n" -#else - "smuadx %[res], r0, r3 \n" -#endif - REPEAT_BLOCK( - "pkhtb r0, r6, r7 \n" - "ldrd r2, [%[v1]], #8 \n" - "smladx %[res], r1, r0, %[res] \n" - "pkhtb r1, r7, r4 \n" - "ldrd r6, [%[v2]], #8 \n" - "smladx %[res], r2, r1, %[res] \n" - "pkhtb r2, r4, r5 \n" - "ldrd r0, [%[v1]], #8 \n" - "smladx %[res], r3, r2, %[res] \n" - "pkhtb r3, r5, r6 \n" - "ldrd r4, [%[v2]], #8 \n" - "smladx %[res], r0, r3, %[res] \n" - ) - - "pkhtb r0, r6, r7 \n" - "ldrd r2, [%[v1]], #8 \n" - "smladx %[res], r1, r0, %[res] \n" - "pkhtb r1, r7, r4 \n" -#if ORDER > 32 - "subs %[cnt], %[cnt], #1 \n" - "ldrned r6, [%[v2]], #8 \n" - "smladx %[res], r2, r1, %[res] \n" - "pkhtb r2, r4, r5 \n" - "ldrned r0, [%[v1]], #8 \n" - "smladx %[res], r3, r2, %[res] \n" - "bne 1b \n" -#else - "pkhtb r4, r4, r5 \n" - "smladx %[res], r2, r1, %[res] \n" - "smladx %[res], r3, r4, %[res] \n" -#endif - - "b 99f \n" - - "20: \n" - "ldrd r0, [%[v1]], #8 \n" - "ldmia %[v2]!, {r5-r7} \n" - - "1: \n" - "ldrd r2, [%[v1]], #8 \n" -#if ORDER > 32 - "smlad %[res], r0, r5, %[res] \n" -#else - "smuad %[res], r0, r5 \n" -#endif - REPEAT_BLOCK( - "ldrd r4, [%[v2]], #8 \n" - "smlad %[res], r1, r6, %[res] \n" - "ldrd r0, [%[v1]], #8 \n" - "smlad %[res], r2, r7, %[res] \n" - "ldrd r6, [%[v2]], #8 \n" - "smlad %[res], r3, r4, %[res] \n" - "ldrd r2, [%[v1]], #8 \n" - "smlad %[res], r0, r5, %[res] \n" - ) - -#if ORDER > 32 - "ldrd r4, [%[v2]], #8 \n" - "smlad %[res], r1, r6, %[res] \n" - "subs %[cnt], %[cnt], #1 \n" - "ldrned r0, [%[v1]], #8 \n" - "smlad %[res], r2, r7, %[res] \n" - "ldrned r6, [%[v2]], #8 \n" - "smlad %[res], r3, r4, %[res] \n" - "bne 1b \n" -#else - "ldr r4, [%[v2]], #4 \n" - "smlad %[res], r1, r6, %[res] \n" - "smlad %[res], r2, r7, %[res] \n" - "smlad %[res], r3, r4, %[res] \n" -#endif - - "99: \n" - : /* outputs */ -#if ORDER > 32 - [cnt]"+r"(cnt), -#endif - [v1] "+r"(v1), - [v2] "+r"(v2), - [res]"=r"(res) - : /* inputs */ - : /* clobbers */ - "r0", "r1", "r2", "r3", - "r4", "r5", "r6", "r7", "cc", "memory" - ); - return res; -} diff --git a/apps/codecs/demac/libdemac/vector_math16_armv7.h b/apps/codecs/demac/libdemac/vector_math16_armv7.h deleted file mode 100644 index 84afda3e5d..0000000000 --- a/apps/codecs/demac/libdemac/vector_math16_armv7.h +++ /dev/null @@ -1,214 +0,0 @@ -/* - -libdemac - A Monkey's Audio decoder - -$Id$ - -Copyright (C) Dave Chapman 2007 - -ARMv7 neon vector math copyright (C) 2010 Jens Arnold - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA - -*/ - -#define FUSED_VECTOR_MATH - -#if ORDER > 32 -#define REPEAT_BLOCK(x) x x x -#elif ORDER > 16 -#define REPEAT_BLOCK(x) x -#else -#define REPEAT_BLOCK(x) -#endif - -/* Calculate scalarproduct, then add a 2nd vector (fused for performance) */ -static inline int32_t vector_sp_add(int16_t* v1, int16_t* f2, int16_t* s2) -{ - int res; -#if ORDER > 64 - int cnt = ORDER>>6; -#endif - - asm volatile ( -#if ORDER > 64 - "vmov.i16 q0, #0 \n" - "1: \n" - "subs %[cnt], %[cnt], #1 \n" -#endif - "vld1.16 {d6-d9}, [%[f2]]! \n" - "vld1.16 {d2-d5}, [%[v1]] \n" - "vld1.16 {d10-d13}, [%[s2]]! \n" -#if ORDER > 64 - "vmlal.s16 q0, d2, d6 \n" -#else - "vmull.s16 q0, d2, d6 \n" -#endif - "vmlal.s16 q0, d3, d7 \n" - "vmlal.s16 q0, d4, d8 \n" - "vmlal.s16 q0, d5, d9 \n" - "vadd.i16 q1, q1, q5 \n" - "vadd.i16 q2, q2, q6 \n" - "vst1.16 {d2-d5}, [%[v1]]! \n" - - REPEAT_BLOCK( - "vld1.16 {d6-d9}, [%[f2]]! \n" - "vld1.16 {d2-d5}, [%[v1]] \n" - "vld1.16 {d10-d13}, [%[s2]]! \n" - "vmlal.s16 q0, d2, d6 \n" - "vmlal.s16 q0, d3, d7 \n" - "vmlal.s16 q0, d4, d8 \n" - "vmlal.s16 q0, d5, d9 \n" - "vadd.i16 q1, q1, q5 \n" - "vadd.i16 q2, q2, q6 \n" - "vst1.16 {d2-d5}, [%[v1]]! \n" - ) -#if ORDER > 64 - "bne 1b \n" -#endif - "vpadd.i32 d0, d0, d1 \n" - "vpaddl.s32 d0, d0 \n" - "vmov.32 %[res], d0[0] \n" - : /* outputs */ -#if ORDER > 64 - [cnt]"+r"(cnt), -#endif - [v1] "+r"(v1), - [f2] "+r"(f2), - [s2] "+r"(s2), - [res]"=r"(res) - : /* inputs */ - : /* clobbers */ - "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", - "d8", "d9", "d10", "d11", "d12", "d13", "memory" - ); - return res; -} - -/* Calculate scalarproduct, then subtract a 2nd vector (fused for performance) */ -static inline int32_t vector_sp_sub(int16_t* v1, int16_t* f2, int16_t* s2) -{ - int res; -#if ORDER > 64 - int cnt = ORDER>>6; -#endif - - asm volatile ( -#if ORDER > 64 - "vmov.i16 q0, #0 \n" - "1: \n" - "subs %[cnt], %[cnt], #1 \n" -#endif - "vld1.16 {d6-d9}, [%[f2]]! \n" - "vld1.16 {d2-d5}, [%[v1]] \n" - "vld1.16 {d10-d13}, [%[s2]]! \n" -#if ORDER > 64 - "vmlal.s16 q0, d2, d6 \n" -#else - "vmull.s16 q0, d2, d6 \n" -#endif - "vmlal.s16 q0, d3, d7 \n" - "vmlal.s16 q0, d4, d8 \n" - "vmlal.s16 q0, d5, d9 \n" - "vsub.i16 q1, q1, q5 \n" - "vsub.i16 q2, q2, q6 \n" - "vst1.16 {d2-d5}, [%[v1]]! \n" - - REPEAT_BLOCK( - "vld1.16 {d6-d9}, [%[f2]]! \n" - "vld1.16 {d2-d5}, [%[v1]] \n" - "vld1.16 {d10-d13}, [%[s2]]! \n" - "vmlal.s16 q0, d2, d6 \n" - "vmlal.s16 q0, d3, d7 \n" - "vmlal.s16 q0, d4, d8 \n" - "vmlal.s16 q0, d5, d9 \n" - "vsub.i16 q1, q1, q5 \n" - "vsub.i16 q2, q2, q6 \n" - "vst1.16 {d2-d5}, [%[v1]]! \n" - ) -#if ORDER > 64 - "bne 1b \n" -#endif - "vpadd.i32 d0, d0, d1 \n" - "vpaddl.s32 d0, d0 \n" - "vmov.32 %[res], d0[0] \n" - : /* outputs */ -#if ORDER > 64 - [cnt]"+r"(cnt), -#endif - [v1] "+r"(v1), - [f2] "+r"(f2), - [s2] "+r"(s2), - [res]"=r"(res) - : /* inputs */ - : /* clobbers */ - "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", - "d8", "d9", "d10", "d11", "d12", "d13", "memory" - ); - return res; -} - -static inline int32_t scalarproduct(int16_t* v1, int16_t* v2) -{ - int res; -#if ORDER > 64 - int cnt = ORDER>>6; -#endif - - asm volatile ( -#if ORDER > 64 - "vmov.i16 q0, #0 \n" - "1: \n" - "subs %[cnt], %[cnt], #1 \n" -#endif - "vld1.16 {d2-d5}, [%[v1]]! \n" - "vld1.16 {d6-d9}, [%[v2]]! \n" -#if ORDER > 64 - "vmlal.s16 q0, d2, d6 \n" -#else - "vmull.s16 q0, d2, d6 \n" -#endif - "vmlal.s16 q0, d3, d7 \n" - "vmlal.s16 q0, d4, d8 \n" - "vmlal.s16 q0, d5, d9 \n" - - REPEAT_BLOCK( - "vld1.16 {d2-d5}, [%[v1]]! \n" - "vld1.16 {d6-d9}, [%[v2]]! \n" - "vmlal.s16 q0, d2, d6 \n" - "vmlal.s16 q0, d3, d7 \n" - "vmlal.s16 q0, d4, d8 \n" - "vmlal.s16 q0, d5, d9 \n" - ) -#if ORDER > 64 - "bne 1b \n" -#endif - "vpadd.i32 d0, d0, d1 \n" - "vpaddl.s32 d0, d0 \n" - "vmov.32 %[res], d0[0] \n" - : /* outputs */ -#if ORDER > 64 - [cnt]"+r"(cnt), -#endif - [v1] "+r"(v1), - [v2] "+r"(v2), - [res]"=r"(res) - : /* inputs */ - : /* clobbers */ - "d0", "d1", "d2", "d3", "d4", - "d5", "d6", "d7", "d8", "d9" - ); - return res; -} diff --git a/apps/codecs/demac/libdemac/vector_math16_cf.h b/apps/codecs/demac/libdemac/vector_math16_cf.h deleted file mode 100644 index 4d77d3be31..0000000000 --- a/apps/codecs/demac/libdemac/vector_math16_cf.h +++ /dev/null @@ -1,364 +0,0 @@ -/* - -libdemac - A Monkey's Audio decoder - -$Id$ - -Copyright (C) Dave Chapman 2007 - -Coldfire vector math copyright (C) 2007 Jens Arnold - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA - -*/ - -#define FUSED_VECTOR_MATH - -#define PREPARE_SCALARPRODUCT coldfire_set_macsr(0); /* signed integer mode */ - -#define REPEAT_2(x) x x -#define REPEAT_3(x) x x x -#define REPEAT_7(x) x x x x x x x - -/* Calculate scalarproduct, then add a 2nd vector (fused for performance) - * This version fetches data as 32 bit words, and *recommends* v1 to be - * 32 bit aligned. It also assumes that f2 and s2 are either both 32 bit - * aligned or both unaligned. Performance will suffer if either condition - * isn't met. It also needs EMAC in signed integer mode. */ -static inline int32_t vector_sp_add(int16_t* v1, int16_t* f2, int16_t* s2) -{ - int res; -#if ORDER > 16 - int cnt = ORDER>>4; -#endif - -#define ADDHALFREGS(s1, s2, sum) /* Add register halves straight. */ \ - "move.l " #s1 ", " #sum "\n" /* 's1' and 's2' can be A or D */ \ - "add.l " #s2 ", " #s1 "\n" /* regs, 'sum' must be a D reg. */ \ - "clr.w " #sum " \n" /* 's1' is clobbered! */ \ - "add.l " #s2 ", " #sum "\n" \ - "move.w " #s1 ", " #sum "\n" - -#define ADDHALFXREGS(s1, s2, sum) /* Add register halves across. */ \ - "clr.w " #sum " \n" /* Needs 'sum' pre-swapped, swaps */ \ - "add.l " #s1 ", " #sum "\n" /* 's2', and clobbers 's1'. */ \ - "swap " #s2 " \n" /* 's1' can be an A or D reg. */ \ - "add.l " #s2 ", " #s1 "\n" /* 'sum' and 's2' must be D regs. */ \ - "move.w " #s1 ", " #sum "\n" - - asm volatile ( - "move.l %[f2], %%d0 \n" - "and.l #2, %%d0 \n" - "jeq 20f \n" - - "10: \n" - "move.w (%[f2])+, %%d0 \n" - "move.w (%[s2])+, %%d1 \n" - "swap %%d1 \n" - "1: \n" - REPEAT_2( - "movem.l (%[v1]), %%d6-%%d7/%%a0-%%a1 \n" - "mac.w %%d0l, %%d6u, (%[f2])+, %%d0, %%acc0\n" - "mac.w %%d0u, %%d6l, (%[s2])+, %%d2, %%acc0\n" - ADDHALFXREGS(%%d6, %%d2, %%d1) - "mac.w %%d0l, %%d7u, (%[f2])+, %%d0, %%acc0\n" - "mac.w %%d0u, %%d7l, (%[s2])+, %%d6, %%acc0\n" - "move.l %%d1, (%[v1])+ \n" - ADDHALFXREGS(%%d7, %%d6, %%d2) - "mac.w %%d0l, %%a0u, (%[f2])+, %%d0, %%acc0\n" - "mac.w %%d0u, %%a0l, (%[s2])+, %%d7, %%acc0\n" - "move.l %%d2, (%[v1])+ \n" - ADDHALFXREGS(%%a0, %%d7, %%d6) - "mac.w %%d0l, %%a1u, (%[f2])+, %%d0, %%acc0\n" - "mac.w %%d0u, %%a1l, (%[s2])+, %%d1, %%acc0\n" - "move.l %%d6, (%[v1])+ \n" - ADDHALFXREGS(%%a1, %%d1, %%d7) - "move.l %%d7, (%[v1])+ \n" - ) - -#if ORDER > 16 - "subq.l #1, %[res] \n" - "bne.w 1b \n" -#endif - "jra 99f \n" - - "20: \n" - "move.l (%[f2])+, %%d0 \n" - "1: \n" - "movem.l (%[v1]), %%d6-%%d7/%%a0-%%a1 \n" - "mac.w %%d0u, %%d6u, (%[s2])+, %%d1, %%acc0\n" - "mac.w %%d0l, %%d6l, (%[f2])+, %%d0, %%acc0\n" - ADDHALFREGS(%%d6, %%d1, %%d2) - "mac.w %%d0u, %%d7u, (%[s2])+, %%d1, %%acc0\n" - "mac.w %%d0l, %%d7l, (%[f2])+, %%d0, %%acc0\n" - "move.l %%d2, (%[v1])+ \n" - ADDHALFREGS(%%d7, %%d1, %%d2) - "mac.w %%d0u, %%a0u, (%[s2])+, %%d1, %%acc0\n" - "mac.w %%d0l, %%a0l, (%[f2])+, %%d0, %%acc0\n" - "move.l %%d2, (%[v1])+ \n" - ADDHALFREGS(%%a0, %%d1, %%d2) - "mac.w %%d0u, %%a1u, (%[s2])+, %%d1, %%acc0\n" - "mac.w %%d0l, %%a1l, (%[f2])+, %%d0, %%acc0\n" - "move.l %%d2, (%[v1])+ \n" - ADDHALFREGS(%%a1, %%d1, %%d2) - "move.l %%d2, (%[v1])+ \n" - - "movem.l (%[v1]), %%d6-%%d7/%%a0-%%a1 \n" - "mac.w %%d0u, %%d6u, (%[s2])+, %%d1, %%acc0\n" - "mac.w %%d0l, %%d6l, (%[f2])+, %%d0, %%acc0\n" - ADDHALFREGS(%%d6, %%d1, %%d2) - "mac.w %%d0u, %%d7u, (%[s2])+, %%d1, %%acc0\n" - "mac.w %%d0l, %%d7l, (%[f2])+, %%d0, %%acc0\n" - "move.l %%d2, (%[v1])+ \n" - ADDHALFREGS(%%d7, %%d1, %%d2) - "mac.w %%d0u, %%a0u, (%[s2])+, %%d1, %%acc0\n" - "mac.w %%d0l, %%a0l, (%[f2])+, %%d0, %%acc0\n" - "move.l %%d2, (%[v1])+ \n" - ADDHALFREGS(%%a0, %%d1, %%d2) - "mac.w %%d0u, %%a1u, (%[s2])+, %%d1, %%acc0\n" -#if ORDER > 16 - "mac.w %%d0l, %%a1l, (%[f2])+, %%d0, %%acc0\n" -#else - "mac.w %%d0l, %%a1l, %%acc0 \n" -#endif - "move.l %%d2, (%[v1])+ \n" - ADDHALFREGS(%%a1, %%d1, %%d2) - "move.l %%d2, (%[v1])+ \n" -#if ORDER > 16 - "subq.l #1, %[res] \n" - "bne.w 1b \n" -#endif - - "99: \n" - "movclr.l %%acc0, %[res] \n" - : /* outputs */ - [v1]"+a"(v1), - [f2]"+a"(f2), - [s2]"+a"(s2), - [res]"=d"(res) - : /* inputs */ -#if ORDER > 16 - [cnt]"[res]"(cnt) -#endif - : /* clobbers */ - "d0", "d1", "d2", "d6", "d7", - "a0", "a1", "memory" - - ); - return res; -} - -/* Calculate scalarproduct, then subtract a 2nd vector (fused for performance) - * This version fetches data as 32 bit words, and *recommends* v1 to be - * 32 bit aligned. It also assumes that f2 and s2 are either both 32 bit - * aligned or both unaligned. Performance will suffer if either condition - * isn't met. It also needs EMAC in signed integer mode. */ -static inline int32_t vector_sp_sub(int16_t* v1, int16_t* f2, int16_t* s2) -{ - int res; -#if ORDER > 16 - int cnt = ORDER>>4; -#endif - -#define SUBHALFREGS(min, sub, dif) /* Subtract register halves straight. */ \ - "move.l " #min ", " #dif "\n" /* 'min' can be an A or D reg */ \ - "sub.l " #sub ", " #min "\n" /* 'sub' and 'dif' must be D regs */ \ - "clr.w " #sub "\n" /* 'min' and 'sub' are clobbered! */ \ - "sub.l " #sub ", " #dif "\n" \ - "move.w " #min ", " #dif "\n" - -#define SUBHALFXREGS(min, s2, s1d) /* Subtract register halves across. */ \ - "clr.w " #s1d "\n" /* Needs 's1d' pre-swapped, swaps */ \ - "sub.l " #s1d ", " #min "\n" /* 's2' and clobbers 'min'. */ \ - "move.l " #min ", " #s1d "\n" /* 'min' can be an A or D reg, */ \ - "swap " #s2 "\n" /* 's2' and 's1d' must be D regs. */ \ - "sub.l " #s2 ", " #min "\n" \ - "move.w " #min ", " #s1d "\n" - - asm volatile ( - "move.l %[f2], %%d0 \n" - "and.l #2, %%d0 \n" - "jeq 20f \n" - - "10: \n" - "move.w (%[f2])+, %%d0 \n" - "move.w (%[s2])+, %%d1 \n" - "swap %%d1 \n" - "1: \n" - REPEAT_2( - "movem.l (%[v1]), %%d6-%%d7/%%a0-%%a1 \n" - "mac.w %%d0l, %%d6u, (%[f2])+, %%d0, %%acc0\n" - "mac.w %%d0u, %%d6l, (%[s2])+, %%d2, %%acc0\n" - SUBHALFXREGS(%%d6, %%d2, %%d1) - "mac.w %%d0l, %%d7u, (%[f2])+, %%d0, %%acc0\n" - "mac.w %%d0u, %%d7l, (%[s2])+, %%d6, %%acc0\n" - "move.l %%d1, (%[v1])+ \n" - SUBHALFXREGS(%%d7, %%d6, %%d2) - "mac.w %%d0l, %%a0u, (%[f2])+, %%d0, %%acc0\n" - "mac.w %%d0u, %%a0l, (%[s2])+, %%d7, %%acc0\n" - "move.l %%d2, (%[v1])+ \n" - SUBHALFXREGS(%%a0, %%d7, %%d6) - "mac.w %%d0l, %%a1u, (%[f2])+, %%d0, %%acc0\n" - "mac.w %%d0u, %%a1l, (%[s2])+, %%d1, %%acc0\n" - "move.l %%d6, (%[v1])+ \n" - SUBHALFXREGS(%%a1, %%d1, %%d7) - "move.l %%d7, (%[v1])+ \n" - ) - -#if ORDER > 16 - "subq.l #1, %[res] \n" - "bne.w 1b \n" -#endif - - "jra 99f \n" - - "20: \n" - "move.l (%[f2])+, %%d0 \n" - "1: \n" - "movem.l (%[v1]), %%d6-%%d7/%%a0-%%a1 \n" - "mac.w %%d0u, %%d6u, (%[s2])+, %%d1, %%acc0\n" - "mac.w %%d0l, %%d6l, (%[f2])+, %%d0, %%acc0\n" - SUBHALFREGS(%%d6, %%d1, %%d2) - "mac.w %%d0u, %%d7u, (%[s2])+, %%d1, %%acc0\n" - "mac.w %%d0l, %%d7l, (%[f2])+, %%d0, %%acc0\n" - "move.l %%d2, (%[v1])+ \n" - SUBHALFREGS(%%d7, %%d1, %%d2) - "mac.w %%d0u, %%a0u, (%[s2])+, %%d1, %%acc0\n" - "mac.w %%d0l, %%a0l, (%[f2])+, %%d0, %%acc0\n" - "move.l %%d2, (%[v1])+ \n" - SUBHALFREGS(%%a0, %%d1, %%d2) - "mac.w %%d0u, %%a1u, (%[s2])+, %%d1, %%acc0\n" - "mac.w %%d0l, %%a1l, (%[f2])+, %%d0, %%acc0\n" - "move.l %%d2, (%[v1])+ \n" - SUBHALFREGS(%%a1, %%d1, %%d2) - "move.l %%d2, (%[v1])+ \n" - - "movem.l (%[v1]), %%d6-%%d7/%%a0-%%a1 \n" - "mac.w %%d0u, %%d6u, (%[s2])+, %%d1, %%acc0\n" - "mac.w %%d0l, %%d6l, (%[f2])+, %%d0, %%acc0\n" - SUBHALFREGS(%%d6, %%d1, %%d2) - "mac.w %%d0u, %%d7u, (%[s2])+, %%d1, %%acc0\n" - "mac.w %%d0l, %%d7l, (%[f2])+, %%d0, %%acc0\n" - "move.l %%d2, (%[v1])+ \n" - SUBHALFREGS(%%d7, %%d1, %%d2) - "mac.w %%d0u, %%a0u, (%[s2])+, %%d1, %%acc0\n" - "mac.w %%d0l, %%a0l, (%[f2])+, %%d0, %%acc0\n" - "move.l %%d2, (%[v1])+ \n" - SUBHALFREGS(%%a0, %%d1, %%d2) - "mac.w %%d0u, %%a1u, (%[s2])+, %%d1, %%acc0\n" -#if ORDER > 16 - "mac.w %%d0l, %%a1l, (%[f2])+, %%d0, %%acc0\n" -#else - "mac.w %%d0l, %%a1l, %%acc0 \n" -#endif - "move.l %%d2, (%[v1])+ \n" - SUBHALFREGS(%%a1, %%d1, %%d2) - "move.l %%d2, (%[v1])+ \n" -#if ORDER > 16 - "subq.l #1, %[res] \n" - "bne.w 1b \n" -#endif - - "99: \n" - "movclr.l %%acc0, %[res] \n" - : /* outputs */ - [v1]"+a"(v1), - [f2]"+a"(f2), - [s2]"+a"(s2), - [res]"=d"(res) - : /* inputs */ -#if ORDER > 16 - [cnt]"[res]"(cnt) -#endif - : /* clobbers */ - "d0", "d1", "d2", "d6", "d7", - "a0", "a1", "memory" - - ); - return res; -} - -/* This version fetches data as 32 bit words, and *recommends* v1 to be - * 32 bit aligned, otherwise performance will suffer. It also needs EMAC - * in signed integer mode. */ -static inline int32_t scalarproduct(int16_t* v1, int16_t* v2) -{ - int res; -#if ORDER > 16 - int cnt = ORDER>>4; -#endif - - asm volatile ( - "move.l %[v2], %%d0 \n" - "and.l #2, %%d0 \n" - "jeq 20f \n" - - "10: \n" - "move.l (%[v1])+, %%d0 \n" - "move.w (%[v2])+, %%d1 \n" - "1: \n" - REPEAT_7( - "mac.w %%d0u, %%d1l, (%[v2])+, %%d1, %%acc0\n" - "mac.w %%d0l, %%d1u, (%[v1])+, %%d0, %%acc0\n" - ) - - "mac.w %%d0u, %%d1l, (%[v2])+, %%d1, %%acc0\n" -#if ORDER > 16 - "mac.w %%d0l, %%d1u, (%[v1])+, %%d0, %%acc0\n" - "subq.l #1, %[res] \n" - "bne.b 1b \n" -#else - "mac.w %%d0l, %%d1u, %%acc0 \n" -#endif - "jra 99f \n" - - "20: \n" - "move.l (%[v1])+, %%d0 \n" - "move.l (%[v2])+, %%d1 \n" - "1: \n" - REPEAT_3( - "mac.w %%d0u, %%d1u, (%[v1])+, %%d2, %%acc0\n" - "mac.w %%d0l, %%d1l, (%[v2])+, %%d1, %%acc0\n" - "mac.w %%d2u, %%d1u, (%[v1])+, %%d0, %%acc0\n" - "mac.w %%d2l, %%d1l, (%[v2])+, %%d1, %%acc0\n" - ) - - "mac.w %%d0u, %%d1u, (%[v1])+, %%d2, %%acc0\n" - "mac.w %%d0l, %%d1l, (%[v2])+, %%d1, %%acc0\n" -#if ORDER > 16 - "mac.w %%d2u, %%d1u, (%[v1])+, %%d0, %%acc0\n" - "mac.w %%d2l, %%d1l, (%[v2])+, %%d1, %%acc0\n" - "subq.l #1, %[res] \n" - "bne.b 1b \n" -#else - "mac.w %%d2u, %%d1u, %%acc0 \n" - "mac.w %%d2l, %%d1l, %%acc0 \n" -#endif - - "99: \n" - "movclr.l %%acc0, %[res] \n" - : /* outputs */ - [v1]"+a"(v1), - [v2]"+a"(v2), - [res]"=d"(res) - : /* inputs */ -#if ORDER > 16 - [cnt]"[res]"(cnt) -#endif - : /* clobbers */ - "d0", "d1", "d2" - ); - return res; -} diff --git a/apps/codecs/demac/libdemac/vector_math16_mmx.h b/apps/codecs/demac/libdemac/vector_math16_mmx.h deleted file mode 100644 index 2177fe88ea..0000000000 --- a/apps/codecs/demac/libdemac/vector_math16_mmx.h +++ /dev/null @@ -1,234 +0,0 @@ -/* - -libdemac - A Monkey's Audio decoder - -$Id$ - -Copyright (C) Dave Chapman 2007 - -MMX vector math copyright (C) 2010 Jens Arnold - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA - -*/ - -#define FUSED_VECTOR_MATH - -#define REPEAT_MB3(x, n) x(n) x(n+8) x(n+16) -#define REPEAT_MB7(x, n) x(n) x(n+8) x(n+16) x(n+24) x(n+32) x(n+40) x(n+48) -#define REPEAT_MB8(x, n) REPEAT_MB7(x, n) x(n+56) - -#if ORDER == 16 /* 3 times */ -#define REPEAT_MB(x) REPEAT_MB3(x, 8) -#elif ORDER == 32 /* 7 times */ -#define REPEAT_MB(x) REPEAT_MB7(x, 8) -#elif ORDER == 64 /* 5*3 == 15 times */ -#define REPEAT_MB(x) REPEAT_MB3(x, 8) REPEAT_MB3(x, 32) REPEAT_MB3(x, 56) \ - REPEAT_MB3(x, 80) REPEAT_MB3(x, 104) -#elif ORDER == 256 /* 9*7 == 63 times */ -#define REPEAT_MB(x) REPEAT_MB7(x, 8) REPEAT_MB7(x, 64) REPEAT_MB7(x, 120) \ - REPEAT_MB7(x, 176) REPEAT_MB7(x, 232) REPEAT_MB7(x, 288) \ - REPEAT_MB7(x, 344) REPEAT_MB7(x, 400) REPEAT_MB7(x, 456) -#elif ORDER == 1280 /* 8*8 == 64 times */ -#define REPEAT_MB(x) REPEAT_MB8(x, 0) REPEAT_MB8(x, 64) REPEAT_MB8(x, 128) \ - REPEAT_MB8(x, 192) REPEAT_MB8(x, 256) REPEAT_MB8(x, 320) \ - REPEAT_MB8(x, 384) REPEAT_MB8(x, 448) -#else -#error unsupported order -#endif - - -static inline int32_t vector_sp_add(int16_t* v1, int16_t* f2, int16_t *s2) -{ - int res, t; -#if ORDER > 256 - int cnt = ORDER>>8; -#endif - - asm volatile ( -#if ORDER > 256 - "pxor %%mm2, %%mm2 \n" - "1: \n" -#else - "movq (%[v1]), %%mm2 \n" - "movq %%mm2, %%mm0 \n" - "pmaddwd (%[f2]), %%mm2 \n" - "paddw (%[s2]), %%mm0 \n" - "movq %%mm0, (%[v1]) \n" -#endif - -#define SP_ADD_BLOCK(n) \ - "movq " #n "(%[v1]), %%mm1 \n" \ - "movq %%mm1, %%mm0 \n" \ - "pmaddwd " #n "(%[f2]), %%mm1 \n" \ - "paddw " #n "(%[s2]), %%mm0 \n" \ - "movq %%mm0, " #n "(%[v1]) \n" \ - "paddd %%mm1, %%mm2 \n" - -REPEAT_MB(SP_ADD_BLOCK) - -#if ORDER > 256 - "add $512, %[v1] \n" - "add $512, %[s2] \n" - "add $512, %[f2] \n" - "dec %[cnt] \n" - "jne 1b \n" -#endif - - "movd %%mm2, %[t] \n" - "psrlq $32, %%mm2 \n" - "movd %%mm2, %[res] \n" - "add %[t], %[res] \n" - : /* outputs */ -#if ORDER > 256 - [cnt]"+r"(cnt), - [s2] "+r"(s2), - [res]"=r"(res), - [t] "=r"(t) - : /* inputs */ - [v1]"2"(v1), - [f2]"3"(f2) -#else - [res]"=r"(res), - [t] "=r"(t) - : /* inputs */ - [v1]"r"(v1), - [f2]"r"(f2), - [s2]"r"(s2) -#endif - : /* clobbers */ - "mm0", "mm1", "mm2" - ); - return res; -} - -static inline int32_t vector_sp_sub(int16_t* v1, int16_t* f2, int16_t *s2) -{ - int res, t; -#if ORDER > 256 - int cnt = ORDER>>8; -#endif - - asm volatile ( -#if ORDER > 256 - "pxor %%mm2, %%mm2 \n" - "1: \n" -#else - "movq (%[v1]), %%mm2 \n" - "movq %%mm2, %%mm0 \n" - "pmaddwd (%[f2]), %%mm2 \n" - "psubw (%[s2]), %%mm0 \n" - "movq %%mm0, (%[v1]) \n" -#endif - -#define SP_SUB_BLOCK(n) \ - "movq " #n "(%[v1]), %%mm1 \n" \ - "movq %%mm1, %%mm0 \n" \ - "pmaddwd " #n "(%[f2]), %%mm1 \n" \ - "psubw " #n "(%[s2]), %%mm0 \n" \ - "movq %%mm0, " #n "(%[v1]) \n" \ - "paddd %%mm1, %%mm2 \n" - -REPEAT_MB(SP_SUB_BLOCK) - -#if ORDER > 256 - "add $512, %[v1] \n" - "add $512, %[s2] \n" - "add $512, %[f2] \n" - "dec %[cnt] \n" - "jne 1b \n" -#endif - - "movd %%mm2, %[t] \n" - "psrlq $32, %%mm2 \n" - "movd %%mm2, %[res] \n" - "add %[t], %[res] \n" - : /* outputs */ -#if ORDER > 256 - [cnt]"+r"(cnt), - [s2] "+r"(s2), - [res]"=r"(res), - [t] "=r"(t) - : /* inputs */ - [v1]"2"(v1), - [f2]"3"(f2) -#else - [res]"=r"(res), - [t] "=r"(t) - : /* inputs */ - [v1]"r"(v1), - [f2]"r"(f2), - [s2]"r"(s2) -#endif - : /* clobbers */ - "mm0", "mm1", "mm2" - ); - return res; -} - -static inline int32_t scalarproduct(int16_t* v1, int16_t* v2) -{ - int res, t; -#if ORDER > 256 - int cnt = ORDER>>8; -#endif - - asm volatile ( -#if ORDER > 256 - "pxor %%mm1, %%mm1 \n" - "1: \n" -#else - "movq (%[v1]), %%mm1 \n" - "pmaddwd (%[v2]), %%mm1 \n" -#endif - -#define SP_BLOCK(n) \ - "movq " #n "(%[v1]), %%mm0 \n" \ - "pmaddwd " #n "(%[v2]), %%mm0 \n" \ - "paddd %%mm0, %%mm1 \n" - -REPEAT_MB(SP_BLOCK) - -#if ORDER > 256 - "add $512, %[v1] \n" - "add $512, %[v2] \n" - "dec %[cnt] \n" - "jne 1b \n" -#endif - - "movd %%mm1, %[t] \n" - "psrlq $32, %%mm1 \n" - "movd %%mm1, %[res] \n" - "add %[t], %[res] \n" - : /* outputs */ -#if ORDER > 256 - [cnt]"+r"(cnt), - [res]"=r"(res), - [t] "=r"(t) - : /* inputs */ - [v1]"1"(v1), - [v2]"2"(v2) -#else - [res]"=r"(res), - [t] "=r"(t) - : /* inputs */ - [v1]"r"(v1), - [v2]"r"(v2) -#endif - : /* clobbers */ - "mm0", "mm1" - ); - return res; -} diff --git a/apps/codecs/demac/libdemac/vector_math32_armv4.h b/apps/codecs/demac/libdemac/vector_math32_armv4.h deleted file mode 100644 index d6bb9b0d9c..0000000000 --- a/apps/codecs/demac/libdemac/vector_math32_armv4.h +++ /dev/null @@ -1,201 +0,0 @@ -/* - -libdemac - A Monkey's Audio decoder - -$Id$ - -Copyright (C) Dave Chapman 2007 - -ARMv4 vector math copyright (C) 2008 Jens Arnold - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA - -*/ - -#define FUSED_VECTOR_MATH - -#if ORDER > 32 -#define REPEAT_BLOCK(x) x x x x x x x x -#elif ORDER > 16 -#define REPEAT_BLOCK(x) x x x x x x x -#else -#define REPEAT_BLOCK(x) x x x -#endif - -/* Calculate scalarproduct, then add a 2nd vector (fused for performance) */ -static inline int32_t vector_sp_add(int32_t* v1, int32_t* f2, int32_t* s2) -{ - int res; -#if ORDER > 32 - int cnt = ORDER>>5; -#endif - - asm volatile ( -#if ORDER > 32 - "mov %[res], #0 \n" - "1: \n" -#else - "ldmia %[v1], {r0-r3} \n" - "ldmia %[f2]!, {r4-r7} \n" - "mul %[res], r4, r0 \n" - "mla %[res], r5, r1, %[res] \n" - "mla %[res], r6, r2, %[res] \n" - "mla %[res], r7, r3, %[res] \n" - "ldmia %[s2]!, {r4-r7} \n" - "add r0, r0, r4 \n" - "add r1, r1, r5 \n" - "add r2, r2, r6 \n" - "add r3, r3, r7 \n" - "stmia %[v1]!, {r0-r3} \n" -#endif - REPEAT_BLOCK( - "ldmia %[v1], {r0-r3} \n" - "ldmia %[f2]!, {r4-r7} \n" - "mla %[res], r4, r0, %[res] \n" - "mla %[res], r5, r1, %[res] \n" - "mla %[res], r6, r2, %[res] \n" - "mla %[res], r7, r3, %[res] \n" - "ldmia %[s2]!, {r4-r7} \n" - "add r0, r0, r4 \n" - "add r1, r1, r5 \n" - "add r2, r2, r6 \n" - "add r3, r3, r7 \n" - "stmia %[v1]!, {r0-r3} \n" - ) -#if ORDER > 32 - "subs %[cnt], %[cnt], #1 \n" - "bne 1b \n" -#endif - : /* outputs */ -#if ORDER > 32 - [cnt]"+r"(cnt), -#endif - [v1] "+r"(v1), - [f2] "+r"(f2), - [s2] "+r"(s2), - [res]"=r"(res) - : /* inputs */ - : /* clobbers */ - "r0", "r1", "r2", "r3", "r4", - "r5", "r6", "r7", "cc", "memory" - ); - return res; -} - -/* Calculate scalarproduct, then subtract a 2nd vector (fused for performance) */ -static inline int32_t vector_sp_sub(int32_t* v1, int32_t* f2, int32_t* s2) -{ - int res; -#if ORDER > 32 - int cnt = ORDER>>5; -#endif - - asm volatile ( -#if ORDER > 32 - "mov %[res], #0 \n" - "1: \n" -#else - "ldmia %[v1], {r0-r3} \n" - "ldmia %[f2]!, {r4-r7} \n" - "mul %[res], r4, r0 \n" - "mla %[res], r5, r1, %[res] \n" - "mla %[res], r6, r2, %[res] \n" - "mla %[res], r7, r3, %[res] \n" - "ldmia %[s2]!, {r4-r7} \n" - "sub r0, r0, r4 \n" - "sub r1, r1, r5 \n" - "sub r2, r2, r6 \n" - "sub r3, r3, r7 \n" - "stmia %[v1]!, {r0-r3} \n" -#endif - REPEAT_BLOCK( - "ldmia %[v1], {r0-r3} \n" - "ldmia %[f2]!, {r4-r7} \n" - "mla %[res], r4, r0, %[res] \n" - "mla %[res], r5, r1, %[res] \n" - "mla %[res], r6, r2, %[res] \n" - "mla %[res], r7, r3, %[res] \n" - "ldmia %[s2]!, {r4-r7} \n" - "sub r0, r0, r4 \n" - "sub r1, r1, r5 \n" - "sub r2, r2, r6 \n" - "sub r3, r3, r7 \n" - "stmia %[v1]!, {r0-r3} \n" - ) -#if ORDER > 32 - "subs %[cnt], %[cnt], #1 \n" - "bne 1b \n" -#endif - : /* outputs */ -#if ORDER > 32 - [cnt]"+r"(cnt), -#endif - [v1] "+r"(v1), - [f2] "+r"(f2), - [s2] "+r"(s2), - [res]"=r"(res) - : /* inputs */ - : /* clobbers */ - "r0", "r1", "r2", "r3", "r4", - "r5", "r6", "r7", "cc", "memory" - ); - return res; -} - -static inline int32_t scalarproduct(int32_t* v1, int32_t* v2) -{ - int res; -#if ORDER > 32 - int cnt = ORDER>>5; -#endif - - asm volatile ( -#if ORDER > 32 - "mov %[res], #0 \n" - "1: \n" -#else - "ldmia %[v1]!, {r0-r3} \n" - "ldmia %[v2]!, {r4-r7} \n" - "mul %[res], r4, r0 \n" - "mla %[res], r5, r1, %[res] \n" - "mla %[res], r6, r2, %[res] \n" - "mla %[res], r7, r3, %[res] \n" -#endif - REPEAT_BLOCK( - "ldmia %[v1]!, {r0-r3} \n" - "ldmia %[v2]!, {r4-r7} \n" - "mla %[res], r4, r0, %[res] \n" - "mla %[res], r5, r1, %[res] \n" - "mla %[res], r6, r2, %[res] \n" - "mla %[res], r7, r3, %[res] \n" - ) -#if ORDER > 32 - "subs %[cnt], %[cnt], #1 \n" - "bne 1b \n" -#endif - : /* outputs */ -#if ORDER > 32 - [cnt]"+r"(cnt), -#endif - [v1] "+r"(v1), - [v2] "+r"(v2), - [res]"=r"(res) - : /* inputs */ - : /* clobbers */ - "r0", "r1", "r2", "r3", - "r4", "r5", "r6", "r7", "cc", "memory" - ); - return res; -} diff --git a/apps/codecs/demac/libdemac/vector_math_generic.h b/apps/codecs/demac/libdemac/vector_math_generic.h deleted file mode 100644 index 00bf07a007..0000000000 --- a/apps/codecs/demac/libdemac/vector_math_generic.h +++ /dev/null @@ -1,160 +0,0 @@ -/* - -libdemac - A Monkey's Audio decoder - -$Id$ - -Copyright (C) Dave Chapman 2007 - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA - -*/ - -#include "demac_config.h" - -static inline void vector_add(filter_int* v1, filter_int* v2) -{ -#if ORDER > 32 - int order = (ORDER >> 5); - while (order--) -#endif - { - *v1++ += *v2++; - *v1++ += *v2++; - *v1++ += *v2++; - *v1++ += *v2++; - *v1++ += *v2++; - *v1++ += *v2++; - *v1++ += *v2++; - *v1++ += *v2++; - *v1++ += *v2++; - *v1++ += *v2++; - *v1++ += *v2++; - *v1++ += *v2++; - *v1++ += *v2++; - *v1++ += *v2++; - *v1++ += *v2++; - *v1++ += *v2++; -#if ORDER > 16 - *v1++ += *v2++; - *v1++ += *v2++; - *v1++ += *v2++; - *v1++ += *v2++; - *v1++ += *v2++; - *v1++ += *v2++; - *v1++ += *v2++; - *v1++ += *v2++; - *v1++ += *v2++; - *v1++ += *v2++; - *v1++ += *v2++; - *v1++ += *v2++; - *v1++ += *v2++; - *v1++ += *v2++; - *v1++ += *v2++; - *v1++ += *v2++; -#endif - } -} - -static inline void vector_sub(filter_int* v1, filter_int* v2) -{ -#if ORDER > 32 - int order = (ORDER >> 5); - while (order--) -#endif - { - *v1++ -= *v2++; - *v1++ -= *v2++; - *v1++ -= *v2++; - *v1++ -= *v2++; - *v1++ -= *v2++; - *v1++ -= *v2++; - *v1++ -= *v2++; - *v1++ -= *v2++; - *v1++ -= *v2++; - *v1++ -= *v2++; - *v1++ -= *v2++; - *v1++ -= *v2++; - *v1++ -= *v2++; - *v1++ -= *v2++; - *v1++ -= *v2++; - *v1++ -= *v2++; -#if ORDER > 16 - *v1++ -= *v2++; - *v1++ -= *v2++; - *v1++ -= *v2++; - *v1++ -= *v2++; - *v1++ -= *v2++; - *v1++ -= *v2++; - *v1++ -= *v2++; - *v1++ -= *v2++; - *v1++ -= *v2++; - *v1++ -= *v2++; - *v1++ -= *v2++; - *v1++ -= *v2++; - *v1++ -= *v2++; - *v1++ -= *v2++; - *v1++ -= *v2++; - *v1++ -= *v2++; -#endif - } -} - -static inline int32_t scalarproduct(filter_int* v1, filter_int* v2) -{ - int res = 0; - -#if ORDER > 32 - int order = (ORDER >> 5); - while (order--) -#endif - { - res += *v1++ * *v2++; - res += *v1++ * *v2++; - res += *v1++ * *v2++; - res += *v1++ * *v2++; - res += *v1++ * *v2++; - res += *v1++ * *v2++; - res += *v1++ * *v2++; - res += *v1++ * *v2++; - res += *v1++ * *v2++; - res += *v1++ * *v2++; - res += *v1++ * *v2++; - res += *v1++ * *v2++; - res += *v1++ * *v2++; - res += *v1++ * *v2++; - res += *v1++ * *v2++; - res += *v1++ * *v2++; -#if ORDER > 16 - res += *v1++ * *v2++; - res += *v1++ * *v2++; - res += *v1++ * *v2++; - res += *v1++ * *v2++; - res += *v1++ * *v2++; - res += *v1++ * *v2++; - res += *v1++ * *v2++; - res += *v1++ * *v2++; - res += *v1++ * *v2++; - res += *v1++ * *v2++; - res += *v1++ * *v2++; - res += *v1++ * *v2++; - res += *v1++ * *v2++; - res += *v1++ * *v2++; - res += *v1++ * *v2++; - res += *v1++ * *v2++; -#endif - } - return res; -} diff --git a/apps/codecs/demac/wavwrite.c b/apps/codecs/demac/wavwrite.c deleted file mode 100644 index 71d2b7bb97..0000000000 --- a/apps/codecs/demac/wavwrite.c +++ /dev/null @@ -1,110 +0,0 @@ -/* - -demac - A Monkey's Audio decoder - -$Id$ - -Copyright (C) Dave Chapman 2007 - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA - -*/ - -#include -#include -#include -#include "inttypes.h" -#include -#include -#include -#include - -#include "parser.h" - -#ifndef __WIN32__ -#define O_BINARY 0 -#endif - -static unsigned char wav_header[44]={ - 'R','I','F','F',// 0 - ChunkID - 0,0,0,0, // 4 - ChunkSize (filesize-8) - 'W','A','V','E',// 8 - Format - 'f','m','t',' ',// 12 - SubChunkID - 16,0,0,0, // 16 - SubChunk1ID // 16 for PCM - 1,0, // 20 - AudioFormat (1=Uncompressed) - 2,0, // 22 - NumChannels - 0,0,0,0, // 24 - SampleRate in Hz - 0,0,0,0, // 28 - Byte Rate (SampleRate*NumChannels*(BitsPerSample/8) - 4,0, // 32 - BlockAlign (== NumChannels * BitsPerSample/8) - 16,0, // 34 - BitsPerSample - 'd','a','t','a',// 36 - Subchunk2ID - 0,0,0,0 // 40 - Subchunk2Size -}; - -int open_wav(struct ape_ctx_t* ape_ctx, char* filename) -{ - int fd; - int x; - int filesize; - int bytespersample; - - fd=open(filename, O_CREAT|O_WRONLY|O_TRUNC|O_BINARY, 0644); - if (fd < 0) - return fd; - - bytespersample=ape_ctx->bps/8; - - filesize=ape_ctx->totalsamples*bytespersample*ape_ctx->channels+44; - - // ChunkSize - x=filesize-8; - wav_header[4]=(x&0xff); - wav_header[5]=(x&0xff00)>>8; - wav_header[6]=(x&0xff0000)>>16; - wav_header[7]=(x&0xff000000)>>24; - - // Number of channels - wav_header[22]=ape_ctx->channels; - - // Samplerate - wav_header[24]=ape_ctx->samplerate&0xff; - wav_header[25]=(ape_ctx->samplerate&0xff00)>>8; - wav_header[26]=(ape_ctx->samplerate&0xff0000)>>16; - wav_header[27]=(ape_ctx->samplerate&0xff000000)>>24; - - // ByteRate - x=ape_ctx->samplerate*(ape_ctx->bps/8)*ape_ctx->channels; - wav_header[28]=(x&0xff); - wav_header[29]=(x&0xff00)>>8; - wav_header[30]=(x&0xff0000)>>16; - wav_header[31]=(x&0xff000000)>>24; - - // BlockAlign - wav_header[32]=(ape_ctx->bps/8)*ape_ctx->channels; - - // Bits per sample - wav_header[34]=ape_ctx->bps; - - // Subchunk2Size - x=filesize-44; - wav_header[40]=(x&0xff); - wav_header[41]=(x&0xff00)>>8; - wav_header[42]=(x&0xff0000)>>16; - wav_header[43]=(x&0xff000000)>>24; - - write(fd,wav_header,sizeof(wav_header)); - - return fd; -} diff --git a/apps/codecs/demac/wavwrite.h b/apps/codecs/demac/wavwrite.h deleted file mode 100644 index a124353229..0000000000 --- a/apps/codecs/demac/wavwrite.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - -demac - A Monkey's Audio decoder - -$Id$ - -Copyright (C) Dave Chapman 2007 - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA - -*/ - -#ifndef _APE_WAVWRITE_H -#define _APE_WAVWRITE_H - -#include "parser.h" - -int open_wav(struct ape_ctx_t* ape_ctx, char* filename); - -#endif diff --git a/apps/codecs/flac.c b/apps/codecs/flac.c deleted file mode 100644 index e10403819c..0000000000 --- a/apps/codecs/flac.c +++ /dev/null @@ -1,536 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2005 Dave Chapman - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ - -#include "codeclib.h" -#include - -CODEC_HEADER - -static FLACContext fc IBSS_ATTR_FLAC; - -/* The output buffers containing the decoded samples (channels 0 and 1) */ -static int32_t decoded0[MAX_BLOCKSIZE] IBSS_ATTR_FLAC; -static int32_t decoded1[MAX_BLOCKSIZE] IBSS_ATTR_FLAC; -static int32_t decoded2[MAX_BLOCKSIZE] IBSS_ATTR_FLAC_LARGE_IRAM; -static int32_t decoded3[MAX_BLOCKSIZE] IBSS_ATTR_FLAC_LARGE_IRAM; -static int32_t decoded4[MAX_BLOCKSIZE] IBSS_ATTR_FLAC_XLARGE_IRAM; -static int32_t decoded5[MAX_BLOCKSIZE] IBSS_ATTR_FLAC_XLARGE_IRAM; - -#define MAX_SUPPORTED_SEEKTABLE_SIZE 5000 - -/* Notes about seeking: - - The full seek table consists of: - uint64_t sample (only 36 bits are used) - uint64_t offset - uint32_t blocksize - - We also limit the sample and offset values to 32-bits - Rockbox doesn't - support files bigger than 2GB on FAT32 filesystems. - - The reference FLAC encoder produces a seek table with points every - 10 seconds, but this can be overridden by the user when encoding a file. - - With the default settings, a typical 4 minute track will contain - 24 seek points. - - Taking the extreme case of a Rockbox supported file to be a 2GB (compressed) - 16-bit/44.1KHz mono stream with a likely uncompressed size of 4GB: - Total duration is: 48694 seconds (about 810 minutes - 13.5 hours) - Total number of seek points: 4869 - - Therefore we limit the number of seek points to 5000. This is a - very extreme case, and requires 5000*8=40000 bytes of storage. - - If we come across a FLAC file with more than this number of seekpoints, we - just use the first 5000. - -*/ - -struct FLACseekpoints { - uint32_t sample; - uint32_t offset; - uint16_t blocksize; -}; - -static struct FLACseekpoints seekpoints[MAX_SUPPORTED_SEEKTABLE_SIZE]; -static int nseekpoints; - -static int8_t *bit_buffer; -static size_t buff_size; - -static bool flac_init(FLACContext* fc, int first_frame_offset) -{ - unsigned char buf[255]; - bool found_streaminfo=false; - uint32_t seekpoint_hi,seekpoint_lo; - uint32_t offset_hi,offset_lo; - uint16_t blocksize; - int endofmetadata=0; - uint32_t blocklength; - - ci->memset(fc,0,sizeof(FLACContext)); - nseekpoints=0; - - fc->sample_skip = 0; - - /* Reset sample buffers */ - memset(decoded0, 0, sizeof(decoded0)); - memset(decoded1, 0, sizeof(decoded1)); - memset(decoded2, 0, sizeof(decoded2)); - memset(decoded3, 0, sizeof(decoded3)); - memset(decoded4, 0, sizeof(decoded4)); - memset(decoded5, 0, sizeof(decoded5)); - - /* Set sample buffers in decoder structure */ - fc->decoded[0] = decoded0; - fc->decoded[1] = decoded1; - fc->decoded[2] = decoded2; - fc->decoded[3] = decoded3; - fc->decoded[4] = decoded4; - fc->decoded[5] = decoded5; - - - /* Skip any foreign tags at start of file */ - ci->seek_buffer(first_frame_offset); - - fc->metadatalength = first_frame_offset; - - if (ci->read_filebuf(buf, 4) < 4) - { - return false; - } - - if (ci->memcmp(buf,"fLaC",4) != 0) - { - return false; - } - fc->metadatalength += 4; - - while (!endofmetadata) { - if (ci->read_filebuf(buf, 4) < 4) - { - return false; - } - - endofmetadata=(buf[0]&0x80); - blocklength = (buf[1] << 16) | (buf[2] << 8) | buf[3]; - fc->metadatalength+=blocklength+4; - - if ((buf[0] & 0x7f) == 0) /* 0 is the STREAMINFO block */ - { - if (ci->read_filebuf(buf, blocklength) < blocklength) return false; - - fc->filesize = ci->filesize; - fc->min_blocksize = (buf[0] << 8) | buf[1]; - int max_blocksize = (buf[2] << 8) | buf[3]; - if (max_blocksize > MAX_BLOCKSIZE) - { - LOGF("FLAC: Maximum blocksize is too large (%d > %d)\n", - max_blocksize, MAX_BLOCKSIZE); - return false; - } - fc->max_blocksize = max_blocksize; - fc->min_framesize = (buf[4] << 16) | (buf[5] << 8) | buf[6]; - fc->max_framesize = (buf[7] << 16) | (buf[8] << 8) | buf[9]; - fc->samplerate = (buf[10] << 12) | (buf[11] << 4) - | ((buf[12] & 0xf0) >> 4); - fc->channels = ((buf[12]&0x0e)>>1) + 1; - fc->bps = (((buf[12]&0x01) << 4) | ((buf[13]&0xf0)>>4) ) + 1; - - /* totalsamples is a 36-bit field, but we assume <= 32 bits are - used */ - fc->totalsamples = (buf[14] << 24) | (buf[15] << 16) - | (buf[16] << 8) | buf[17]; - - /* Calculate track length (in ms) and estimate the bitrate - (in kbit/s) */ - fc->length = ((int64_t) fc->totalsamples * 1000) / fc->samplerate; - - found_streaminfo=true; - } else if ((buf[0] & 0x7f) == 3) { /* 3 is the SEEKTABLE block */ - while ((nseekpoints < MAX_SUPPORTED_SEEKTABLE_SIZE) && - (blocklength >= 18)) { - if (ci->read_filebuf(buf,18) < 18) return false; - blocklength-=18; - - seekpoint_hi=(buf[0] << 24) | (buf[1] << 16) | - (buf[2] << 8) | buf[3]; - seekpoint_lo=(buf[4] << 24) | (buf[5] << 16) | - (buf[6] << 8) | buf[7]; - offset_hi=(buf[8] << 24) | (buf[9] << 16) | - (buf[10] << 8) | buf[11]; - offset_lo=(buf[12] << 24) | (buf[13] << 16) | - (buf[14] << 8) | buf[15]; - - blocksize=(buf[16] << 8) | buf[17]; - - /* Only store seekpoints where the high 32 bits are zero */ - if ((seekpoint_hi == 0) && (seekpoint_lo != 0xffffffff) && - (offset_hi == 0)) { - seekpoints[nseekpoints].sample=seekpoint_lo; - seekpoints[nseekpoints].offset=offset_lo; - seekpoints[nseekpoints].blocksize=blocksize; - nseekpoints++; - } - } - /* Skip any unread seekpoints */ - if (blocklength > 0) - ci->advance_buffer(blocklength); - } else { - /* Skip to next metadata block */ - ci->advance_buffer(blocklength); - } - } - - if (found_streaminfo) { - fc->bitrate = ((int64_t) (fc->filesize-fc->metadatalength) * 8) - / fc->length; - return true; - } else { - return false; - } -} - -/* Synchronize to next frame in stream - adapted from libFLAC 1.1.3b2 */ -static bool frame_sync(FLACContext* fc) { - unsigned int x = 0; - bool cached = false; - - /* Make sure we're byte aligned. */ - align_get_bits(&fc->gb); - - while(1) { - if(fc->gb.size_in_bits - get_bits_count(&fc->gb) < 8) { - /* Error, end of bitstream, a valid stream should never reach here - * since the buffer should contain at least one frame header. - */ - return false; - } - - if(cached) - cached = false; - else - x = get_bits(&fc->gb, 8); - - if(x == 0xff) { /* MAGIC NUMBER for first 8 frame sync bits. */ - x = get_bits(&fc->gb, 8); - /* We have to check if we just read two 0xff's in a row; the second - * may actually be the beginning of the sync code. - */ - if(x == 0xff) { /* MAGIC NUMBER for first 8 frame sync bits. */ - cached = true; - } - else if(x >> 2 == 0x3e) { /* MAGIC NUMBER for last 6 sync bits. */ - /* Succesfully synced. */ - break; - } - } - } - - /* Advance and init bit buffer to the new frame. */ - ci->advance_buffer((get_bits_count(&fc->gb)-16)>>3); /* consumed bytes */ - bit_buffer = ci->request_buffer(&buff_size, MAX_FRAMESIZE+16); - init_get_bits(&fc->gb, bit_buffer, buff_size*8); - - /* Decode the frame to verify the frame crc and - * fill fc with its metadata. - */ - if(flac_decode_frame(fc, - bit_buffer, buff_size, ci->yield) < 0) { - return false; - } - - return true; -} - -/* Seek to sample - adapted from libFLAC 1.1.3b2+ */ -static bool flac_seek(FLACContext* fc, uint32_t target_sample) { - off_t orig_pos = ci->curpos; - off_t pos = -1; - unsigned long lower_bound, upper_bound; - unsigned long lower_bound_sample, upper_bound_sample; - int i; - unsigned approx_bytes_per_frame; - uint32_t this_frame_sample = fc->samplenumber; - unsigned this_block_size = fc->blocksize; - bool needs_seek = true, first_seek = true; - - /* We are just guessing here. */ - if(fc->max_framesize > 0) - approx_bytes_per_frame = (fc->max_framesize + fc->min_framesize)/2 + 1; - /* Check if it's a known fixed-blocksize stream. */ - else if(fc->min_blocksize == fc->max_blocksize && fc->min_blocksize > 0) - approx_bytes_per_frame = fc->min_blocksize*fc->channels*fc->bps/8 + 64; - else - approx_bytes_per_frame = 4608 * fc->channels * fc->bps/8 + 64; - - /* Set an upper and lower bound on where in the stream we will search. */ - lower_bound = fc->metadatalength; - lower_bound_sample = 0; - upper_bound = fc->filesize; - upper_bound_sample = fc->totalsamples>0 ? fc->totalsamples : target_sample; - - /* Refine the bounds if we have a seektable with suitable points. */ - if(nseekpoints > 0) { - /* Find the closest seek point <= target_sample, if it exists. */ - for(i = nseekpoints-1; i >= 0; i--) { - if(seekpoints[i].sample <= target_sample) - break; - } - if(i >= 0) { /* i.e. we found a suitable seek point... */ - lower_bound = fc->metadatalength + seekpoints[i].offset; - lower_bound_sample = seekpoints[i].sample; - } - - /* Find the closest seek point > target_sample, if it exists. */ - for(i = 0; i < nseekpoints; i++) { - if(seekpoints[i].sample > target_sample) - break; - } - if(i < nseekpoints) { /* i.e. we found a suitable seek point... */ - upper_bound = fc->metadatalength + seekpoints[i].offset; - upper_bound_sample = seekpoints[i].sample; - } - } - - while(1) { - /* Check if bounds are still ok. */ - if(lower_bound_sample >= upper_bound_sample || - lower_bound > upper_bound) { - return false; - } - - /* Calculate new seek position */ - if(needs_seek) { - pos = (off_t)(lower_bound + - (((target_sample - lower_bound_sample) * - (int64_t)(upper_bound - lower_bound)) / - (upper_bound_sample - lower_bound_sample)) - - approx_bytes_per_frame); - - if(pos >= (off_t)upper_bound) - pos = (off_t)upper_bound-1; - if(pos < (off_t)lower_bound) - pos = (off_t)lower_bound; - } - - if(!ci->seek_buffer(pos)) - return false; - - bit_buffer = ci->request_buffer(&buff_size, MAX_FRAMESIZE+16); - init_get_bits(&fc->gb, bit_buffer, buff_size*8); - - /* Now we need to get a frame. It is possible for our seek - * to land in the middle of audio data that looks exactly like - * a frame header from a future version of an encoder. When - * that happens, frame_sync() will return false. - * But there is a remote possibility that it is properly - * synced at such a "future-codec frame", so to make sure, - * we wait to see several "unparseable" errors in a row before - * bailing out. - */ - { - unsigned unparseable_count; - bool got_a_frame = false; - for(unparseable_count = 0; !got_a_frame - && unparseable_count < 10; unparseable_count++) { - if(frame_sync(fc)) - got_a_frame = true; - } - if(!got_a_frame) { - ci->seek_buffer(orig_pos); - return false; - } - } - - this_frame_sample = fc->samplenumber; - this_block_size = fc->blocksize; - - if(target_sample >= this_frame_sample - && target_sample < this_frame_sample+this_block_size) { - /* Found the frame containing the target sample. */ - fc->sample_skip = target_sample - this_frame_sample; - break; - } - - if(this_frame_sample + this_block_size >= upper_bound_sample && - !first_seek) { - if(pos == (off_t)lower_bound || !needs_seek) { - ci->seek_buffer(orig_pos); - return false; - } - /* Our last move backwards wasn't big enough, try again. */ - approx_bytes_per_frame *= 2; - continue; - } - /* Allow one seek over upper bound, - * required for streams with unknown total samples. - */ - first_seek = false; - - /* Make sure we are not seeking in a corrupted stream */ - if(this_frame_sample < lower_bound_sample) { - ci->seek_buffer(orig_pos); - return false; - } - - approx_bytes_per_frame = this_block_size*fc->channels*fc->bps/8 + 64; - - /* We need to narrow the search. */ - if(target_sample < this_frame_sample) { - upper_bound_sample = this_frame_sample; - upper_bound = ci->curpos; - } - else { /* Target is beyond this frame. */ - /* We are close, continue in decoding next frames. */ - if(target_sample < this_frame_sample + 4*this_block_size) { - pos = ci->curpos + fc->framesize; - needs_seek = false; - } - - lower_bound_sample = this_frame_sample + this_block_size; - lower_bound = ci->curpos + fc->framesize; - } - } - - return true; -} - -/* Seek to file offset */ -static bool flac_seek_offset(FLACContext* fc, uint32_t offset) { - unsigned unparseable_count; - bool got_a_frame = false; - - if(!ci->seek_buffer(offset)) - return false; - - bit_buffer = ci->request_buffer(&buff_size, MAX_FRAMESIZE); - init_get_bits(&fc->gb, bit_buffer, buff_size*8); - - for(unparseable_count = 0; !got_a_frame - && unparseable_count < 10; unparseable_count++) { - if(frame_sync(fc)) - got_a_frame = true; - } - - if(!got_a_frame) { - ci->seek_buffer(fc->metadatalength); - return false; - } - - return true; -} - -/* this is the codec entry point */ -enum codec_status codec_main(enum codec_entry_call_reason reason) -{ - if (reason == CODEC_LOAD) { - /* Generic codec initialisation */ - ci->configure(DSP_SET_SAMPLE_DEPTH, FLAC_OUTPUT_DEPTH-1); - } - - return CODEC_OK; -} - -/* this is called for each file to process */ -enum codec_status codec_run(void) -{ - int8_t *buf; - uint32_t samplesdone; - uint32_t elapsedtime; - size_t bytesleft; - int consumed; - int res; - int frame; - intptr_t param; - - if (codec_init()) { - LOGF("FLAC: Error initialising codec\n"); - return CODEC_ERROR; - } - - /* Need to save offset for later use (cleared indirectly by flac_init) */ - samplesdone = ci->id3->offset; - - if (!flac_init(&fc,ci->id3->first_frame_offset)) { - LOGF("FLAC: Error initialising codec\n"); - return CODEC_ERROR; - } - - ci->configure(DSP_SWITCH_FREQUENCY, ci->id3->frequency); - ci->configure(DSP_SET_STEREO_MODE, fc.channels == 1 ? - STEREO_MONO : STEREO_NONINTERLEAVED); - codec_set_replaygain(ci->id3); - - flac_seek_offset(&fc, samplesdone); - samplesdone=fc.samplenumber+fc.blocksize; - elapsedtime=(samplesdone*10)/(ci->id3->frequency/100); - ci->set_elapsed(elapsedtime); - - /* The main decoding loop */ - frame=0; - buf = ci->request_buffer(&bytesleft, MAX_FRAMESIZE); - while (bytesleft) { - enum codec_command_action action = ci->get_command(¶m); - - if (action == CODEC_ACTION_HALT) - break; - - /* Deal with any pending seek requests */ - if (action == CODEC_ACTION_SEEK_TIME) { - if (flac_seek(&fc,(uint32_t)(((uint64_t)param - *ci->id3->frequency)/1000))) { - /* Refill the input buffer */ - buf = ci->request_buffer(&bytesleft, MAX_FRAMESIZE); - } - - ci->set_elapsed(param); - ci->seek_complete(); - } - - if((res=flac_decode_frame(&fc,buf, - bytesleft,ci->yield)) < 0) { - LOGF("FLAC: Frame %d, error %d\n",frame,res); - return CODEC_ERROR; - } - consumed=fc.gb.index/8; - frame++; - - ci->yield(); - ci->pcmbuf_insert(&fc.decoded[0][fc.sample_skip], &fc.decoded[1][fc.sample_skip], - fc.blocksize - fc.sample_skip); - - fc.sample_skip = 0; - - /* Update the elapsed-time indicator */ - samplesdone=fc.samplenumber+fc.blocksize; - elapsedtime=(samplesdone*10)/(ci->id3->frequency/100); - ci->set_elapsed(elapsedtime); - - ci->advance_buffer(consumed); - - buf = ci->request_buffer(&bytesleft, MAX_FRAMESIZE); - } - - LOGF("FLAC: Decoded %lu samples\n",(unsigned long)samplesdone); - return CODEC_OK; -} diff --git a/apps/codecs/gbs.c b/apps/codecs/gbs.c deleted file mode 100644 index def05ed351..0000000000 --- a/apps/codecs/gbs.c +++ /dev/null @@ -1,108 +0,0 @@ - -/* Ripped off from Game_Music_Emu 0.5.2. http://www.slack.net/~ant/ */ - -#include -#include "libgme/gbs_emu.h" - -CODEC_HEADER - -/* Maximum number of bytes to process in one iteration */ -#define CHUNK_SIZE (1024*2) - -static int16_t samples[CHUNK_SIZE] IBSS_ATTR; -static struct Gbs_Emu gbs_emu; - -/****************** rockbox interface ******************/ - -static void set_codec_track(int t) { - Gbs_start_track(&gbs_emu, t); - - /* for loop mode we disable track limits */ - if (!ci->loop_track()) { - Track_set_fade(&gbs_emu, Track_get_length( &gbs_emu, t ), 4000); - } - ci->set_elapsed(t*1000); /* t is track no to display */ -} - -/* this is the codec entry point */ -enum codec_status codec_main(enum codec_entry_call_reason reason) -{ - if (reason == CODEC_LOAD) { - /* we only render 16 bits */ - ci->configure(DSP_SET_SAMPLE_DEPTH, 16); - - /* 44 Khz, Interleaved stereo */ - ci->configure(DSP_SET_FREQUENCY, 44100); - ci->configure(DSP_SET_STEREO_MODE, STEREO_INTERLEAVED); - - Gbs_init(&gbs_emu); - Gbs_set_sample_rate(&gbs_emu, 44100); - } - - return CODEC_OK; -} - -/* this is called for each file to process */ -enum codec_status codec_run(void) -{ - blargg_err_t err; - uint8_t *buf; - size_t n; - intptr_t param; - int track = 0; - - DEBUGF("GBS: next_track\n"); - if (codec_init()) { - return CODEC_ERROR; - } - - codec_set_replaygain(ci->id3); - - /* Read the entire file */ - DEBUGF("GBS: request file\n"); - ci->seek_buffer(0); - buf = ci->request_buffer(&n, ci->filesize); - if (!buf || n < (size_t)ci->filesize) { - DEBUGF("GBS: file load failed\n"); - return CODEC_ERROR; - } - - if ((err = Gbs_load_mem(&gbs_emu, buf, ci->filesize))) { - DEBUGF("GBS: Gbs_load_mem failed (%s)\n", err); - return CODEC_ERROR; - } - - /* Update internal track count */ - if (gbs_emu.m3u.size > 0) - gbs_emu.track_count = gbs_emu.m3u.size; - -next_track: - set_codec_track(track); - - /* The main decoder loop */ - while (1) { - enum codec_command_action action = ci->get_command(¶m); - - if (action == CODEC_ACTION_HALT) - break; - - if (action == CODEC_ACTION_SEEK_TIME) { - track = param/1000; - ci->seek_complete(); - if (track >= gbs_emu.track_count) break; - goto next_track; - } - - /* Generate audio buffer */ - err = Gbs_play(&gbs_emu, CHUNK_SIZE, samples); - if (err || Track_ended(&gbs_emu)) { - track++; - if (track >= gbs_emu.track_count) break; - goto next_track; - } - - ci->pcmbuf_insert(samples, NULL, CHUNK_SIZE >> 1); - } - - return CODEC_OK; -} diff --git a/apps/codecs/hes.c b/apps/codecs/hes.c deleted file mode 100644 index 849fd88f12..0000000000 --- a/apps/codecs/hes.c +++ /dev/null @@ -1,108 +0,0 @@ -/* Ripped off from Game_Music_Emu 0.5.2. http://www.slack.net/~ant/ */ - -#include -#include "codeclib.h" -#include "libgme/hes_emu.h" - -CODEC_HEADER - -/* Maximum number of bytes to process in one iteration */ -#define CHUNK_SIZE (1024*2) - -static int16_t samples[CHUNK_SIZE] IBSS_ATTR; -static struct Hes_Emu hes_emu; - -/****************** rockbox interface ******************/ - -static void set_codec_track(int t) { - Hes_start_track(&hes_emu, t); - - /* for loop mode we disable track limits */ - if (!ci->loop_track()) { - Track_set_fade(&hes_emu, Track_get_length( &hes_emu, t ), 4000); - } - ci->set_elapsed(t*1000); /* t is track no to display */ -} - -/* this is the codec entry point */ -enum codec_status codec_main(enum codec_entry_call_reason reason) -{ - if (reason == CODEC_LOAD) { - /* we only render 16 bits */ - ci->configure(DSP_SET_SAMPLE_DEPTH, 16); - - /* 44 Khz, Interleaved stereo */ - ci->configure(DSP_SET_FREQUENCY, 44100); - ci->configure(DSP_SET_STEREO_MODE, STEREO_INTERLEAVED); - - Hes_init(&hes_emu); - Hes_set_sample_rate(&hes_emu, 44100); - } - - return CODEC_OK; -} - -/* this is called for each file to process */ -enum codec_status codec_run(void) -{ - blargg_err_t err; - uint8_t *buf; - size_t n; - intptr_t param; - int track = 0; - - DEBUGF("HES: next_track\n"); - if (codec_init()) { - return CODEC_ERROR; - } - - codec_set_replaygain(ci->id3); - - /* Read the entire file */ - DEBUGF("HES: request file\n"); - ci->seek_buffer(0); - buf = ci->request_buffer(&n, ci->filesize); - if (!buf || n < (size_t)ci->filesize) { - DEBUGF("HES: file load failed\n"); - return CODEC_ERROR; - } - - if ((err = Hes_load_mem(&hes_emu, buf, ci->filesize))) { - DEBUGF("HES: Hes_load_mem failed (%s)\n", err); - return CODEC_ERROR; - } - - /* Update internal track count */ - if (hes_emu.m3u.size > 0) - hes_emu.track_count = hes_emu.m3u.size; - -next_track: - set_codec_track(track); - - /* The main decoder loop */ - while ( 1 ) { - enum codec_command_action action = ci->get_command(¶m); - - if (action == CODEC_ACTION_HALT) - break; - - if (action == CODEC_ACTION_SEEK_TIME) { - track = param/1000; - ci->seek_complete(); - if (track >= hes_emu.track_count) break; - goto next_track; - } - - /* Generate audio buffer */ - err = Hes_play(&hes_emu, CHUNK_SIZE, samples); - if (err || Track_ended(&hes_emu)) { - track++; - if (track >= hes_emu.track_count) break; - goto next_track; - } - - ci->pcmbuf_insert(samples, NULL, CHUNK_SIZE >> 1); - } - - return CODEC_OK; -} diff --git a/apps/codecs/kss.c b/apps/codecs/kss.c deleted file mode 100644 index 92efcd4e5f..0000000000 --- a/apps/codecs/kss.c +++ /dev/null @@ -1,111 +0,0 @@ - -/* Ripped off from Game_Music_Emu 0.5.2. http://www.slack.net/~ant/ */ - -#include -#include "libgme/kss_emu.h" - -CODEC_HEADER - -/* Maximum number of bytes to process in one iteration */ -#define CHUNK_SIZE (1024*2) - -static int16_t samples[CHUNK_SIZE] IBSS_ATTR; -static struct Kss_Emu kss_emu; - -/****************** rockbox interface ******************/ - -static void set_codec_track(int t) { - Kss_start_track(&kss_emu, t); - - /* for REPEAT_ONE we disable track limits */ - if (!ci->loop_track()) { - Track_set_fade(&kss_emu, Track_get_length( &kss_emu, t ), 4000); - } - ci->set_elapsed(t*1000); /* t is track no to display */ -} - -/* this is the codec entry point */ -enum codec_status codec_main(enum codec_entry_call_reason reason) -{ - if (reason == CODEC_LOAD) { - /* we only render 16 bits */ - ci->configure(DSP_SET_SAMPLE_DEPTH, 16); - - /* 44 Khz, Interleaved stereo */ - ci->configure(DSP_SET_FREQUENCY, 44100); - ci->configure(DSP_SET_STEREO_MODE, STEREO_INTERLEAVED); - - Kss_init(&kss_emu); - Kss_set_sample_rate(&kss_emu, 44100); - } - - return CODEC_OK; -} - -/* this is called for each file to process */ -enum codec_status codec_run(void) -{ - blargg_err_t err; - uint8_t *buf; - size_t n; - int track; - intptr_t param; - - /* reset values */ - track = 0; - - DEBUGF("KSS: next_track\n"); - if (codec_init()) { - return CODEC_ERROR; - } - - codec_set_replaygain(ci->id3); - - /* Read the entire file */ - DEBUGF("KSS: request file\n"); - ci->seek_buffer(0); - buf = ci->request_buffer(&n, ci->filesize); - if (!buf || n < (size_t)ci->filesize) { - DEBUGF("KSS: file load failed\n"); - return CODEC_ERROR; - } - - if ((err = Kss_load_mem(&kss_emu, buf, ci->filesize))) { - DEBUGF("KSS: Kss_load failed (%s)\n", err); - return CODEC_ERROR; - } - - /* Update internal track count */ - if (kss_emu.m3u.size > 0) - kss_emu.track_count = kss_emu.m3u.size; - -next_track: - set_codec_track(track); - - /* The main decoder loop */ - while (1) { - enum codec_command_action action = ci->get_command(¶m); - - if (action == CODEC_ACTION_HALT) - break; - - if (action == CODEC_ACTION_SEEK_TIME) { - track = param/1000; - ci->seek_complete(); - if (track >= kss_emu.track_count) break; - goto next_track; - } - - /* Generate audio buffer */ - err = Kss_play(&kss_emu, CHUNK_SIZE, samples); - if (err || Track_ended(&kss_emu)) { - track++; - if (track >= kss_emu.track_count) break; - goto next_track; - } - - ci->pcmbuf_insert(samples, NULL, CHUNK_SIZE >> 1); - } - - return CODEC_OK; -} diff --git a/apps/codecs/lib/SOURCES b/apps/codecs/lib/SOURCES deleted file mode 100644 index 257dcb5838..0000000000 --- a/apps/codecs/lib/SOURCES +++ /dev/null @@ -1,12 +0,0 @@ -#if CONFIG_CODEC == SWCODEC /* software codec platforms */ -codeclib.c -fixedpoint.c -ffmpeg_bitstream.c - -mdct_lookup.c -fft-ffmpeg.c -mdct.c - -#elif (CONFIG_PLATFORM & PLATFORM_HOSTED) && defined(__APPLE__) -osx.dummy.c -#endif diff --git a/apps/codecs/lib/asm_arm.h b/apps/codecs/lib/asm_arm.h deleted file mode 100644 index 8e5d0e68df..0000000000 --- a/apps/codecs/lib/asm_arm.h +++ /dev/null @@ -1,292 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * - * * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * - * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * - * * - ******************************************************************** - - function: arm7 and later wide math functions - - ********************************************************************/ -#ifdef CPU_ARM - -#define INCL_OPTIMIZED_MULT32 -#if ARM_ARCH >= 6 -static inline int32_t MULT32(int32_t x, int32_t y) { - int32_t hi; - asm volatile("smmul %[hi], %[x], %[y] \n\t" - : [hi] "=&r" (hi) - : [x] "r" (x), [y] "r" (y) ); - return(hi); -} -#else -static inline int32_t MULT32(int32_t x, int32_t y) { - int32_t lo, hi; - asm volatile("smull\t%0, %1, %2, %3 \n\t" - : "=&r"(lo),"=&r"(hi) - : "r"(x),"r"(y) ); - return(hi); -} -#endif - -#define INCL_OPTIMIZED_MULT31 -static inline int32_t MULT31(int32_t x, int32_t y) { - return MULT32(x,y)<<1; -} - -#define INCL_OPTIMIZED_MULT31_SHIFT15 -static inline int32_t MULT31_SHIFT15(int32_t x, int32_t y) { - int32_t lo,hi; - asm volatile("smull %0, %1, %2, %3\n\t" - "movs %0, %0, lsr #15\n\t" - "adc %1, %0, %1, lsl #17\n\t" - : "=&r"(lo),"=&r"(hi) - : "r"(x),"r"(y) - : "cc" ); - return(hi); -} - -#define INCL_OPTIMIZED_MULT31_SHIFT16 -static inline int32_t MULT31_SHIFT16(int32_t x, int32_t y) { - int32_t lo,hi; - asm volatile("smull %0, %1, %2, %3\n\t" - "movs %0, %0, lsr #16\n\t" - "adc %1, %0, %1, lsl #16\n\t" - : "=&r"(lo),"=&r"(hi) - : "r"(x),"r"(y) - : "cc" ); - return(hi); -} - -#define INCL_OPTIMIZED_XPROD32 -#define XPROD32(a, b, t, v, x, y) \ -{ \ - int32_t l; \ - asm("smull %0, %1, %3, %5\n\t" \ - "rsb %2, %6, #0\n\t" \ - "smlal %0, %1, %4, %6\n\t" \ - "smull %0, %2, %3, %2\n\t" \ - "smlal %0, %2, %4, %5" \ - : "=&r" (l), "=&r" (x), "=&r" (y) \ - : "r" ((a)), "r" ((b)), "r" ((t)), "r" ((v)) ); \ -} - -#define INCL_OPTIMIZED_XPROD31_R -#define INCL_OPTIMIZED_XNPROD31_R -#if ARM_ARCH >= 6 -/* These may yield slightly different result from the macros below - because only the high 32 bits of the multiplications are accumulated while - the below macros use a 64 bit accumulator that is truncated to 32 bits.*/ -#define XPROD31_R(_a, _b, _t, _v, _x, _y)\ -{\ - int32_t x1, y1;\ - asm("smmul %[x1], %[t], %[a] \n\t"\ - "smmul %[y1], %[t], %[b] \n\t"\ - "smmla %[x1], %[v], %[b], %[x1] \n\t"\ - "smmls %[y1], %[v], %[a], %[y1] \n\t"\ - : [x1] "=&r" (x1), [y1] "=&r" (y1)\ - : [a] "r" (_a), [b] "r" (_b), [t] "r" (_t), [v] "r" (_v) );\ - _x = x1 << 1;\ - _y = y1 << 1;\ -} - -#define XNPROD31_R(_a, _b, _t, _v, _x, _y)\ -{\ - int32_t x1, y1;\ - asm("smmul %[x1], %[t], %[a] \n\t"\ - "smmul %[y1], %[t], %[b] \n\t"\ - "smmls %[x1], %[v], %[b], %[x1] \n\t"\ - "smmla %[y1], %[v], %[a], %[y1] \n\t"\ - : [x1] "=&r" (x1), [y1] "=&r" (y1)\ - : [a] "r" (_a), [b] "r" (_b), [t] "r" (_t), [v] "r" (_v) );\ - _x = x1 << 1;\ - _y = y1 << 1;\ -} -#else -#define XPROD31_R(_a, _b, _t, _v, _x, _y)\ -{\ - int32_t x1, y1, l;\ - asm("smull %0, %1, %5, %3\n\t"\ - "rsb %2, %3, #0\n\t"\ - "smlal %0, %1, %6, %4\n\t"\ - "smull %0, %2, %6, %2\n\t"\ - "smlal %0, %2, %5, %4"\ - : "=&r" (l), "=&r" (x1), "=&r" (y1)\ - : "r" (_a), "r" (_b), "r" (_t), "r" (_v) );\ - _x = x1 << 1;\ - _y = y1 << 1;\ -} - -#define XNPROD31_R(_a, _b, _t, _v, _x, _y)\ -{\ - int32_t x1, y1, l;\ - asm("smull %0, %1, %5, %3\n\t"\ - "rsb %2, %4, #0\n\t"\ - "smlal %0, %1, %6, %2\n\t"\ - "smull %0, %2, %5, %4\n\t"\ - "smlal %0, %2, %6, %3"\ - : "=&r" (l), "=&r" (x1), "=&r" (y1)\ - : "r" (_a), "r" (_b), "r" (_t), "r" (_v) );\ - _x = x1 << 1;\ - _y = y1 << 1;\ -} -#endif - -#define INCL_OPTIMIZED_XPROD31 -static inline void XPROD31(int32_t a, int32_t b, - int32_t t, int32_t v, - int32_t *x, int32_t *y) -{ - int32_t _x1, _y1; - XPROD31_R(a, b, t, v, _x1, _y1); - *x = _x1; - *y = _y1; -} - -#define INCL_OPTIMIZED_XNPROD31 -static inline void XNPROD31(int32_t a, int32_t b, - int32_t t, int32_t v, - int32_t *x, int32_t *y) -{ - int32_t _x1, _y1; - XNPROD31_R(a, b, t, v, _x1, _y1); - *x = _x1; - *y = _y1; -} - - -#ifndef _V_VECT_OPS -#define _V_VECT_OPS - -/* asm versions of vector operations for block.c, window.c */ -static inline -void vect_add(int32_t *x, const int32_t *y, int n) -{ - while (n>=4) { - asm volatile ("ldmia %[x], {r0, r1, r2, r3};" - "ldmia %[y]!, {r4, r5, r6, r7};" - "add r0, r0, r4;" - "add r1, r1, r5;" - "add r2, r2, r6;" - "add r3, r3, r7;" - "stmia %[x]!, {r0, r1, r2, r3};" - : [x] "+r" (x), [y] "+r" (y) - : : "r0", "r1", "r2", "r3", - "r4", "r5", "r6", "r7", - "memory"); - n -= 4; - } - /* add final elements */ - while (n>0) { - *x++ += *y++; - n--; - } -} - -static inline -void vect_copy(int32_t *x, const int32_t *y, int n) -{ - while (n>=4) { - asm volatile ("ldmia %[y]!, {r0, r1, r2, r3};" - "stmia %[x]!, {r0, r1, r2, r3};" - : [x] "+r" (x), [y] "+r" (y) - : : "r0", "r1", "r2", "r3", - "memory"); - n -= 4; - } - /* copy final elements */ - while (n>0) { - *x++ = *y++; - n--; - } -} - -static inline -void vect_mult_fw(int32_t *data, const int32_t *window, int n) -{ - while (n>=4) { - asm volatile ("ldmia %[d], {r0, r1, r2, r3};" - "ldmia %[w]!, {r4, r5, r6, r7};" - "smull r8, r9, r0, r4;" - "mov r0, r9, lsl #1;" - "smull r8, r9, r1, r5;" - "mov r1, r9, lsl #1;" - "smull r8, r9, r2, r6;" - "mov r2, r9, lsl #1;" - "smull r8, r9, r3, r7;" - "mov r3, r9, lsl #1;" - "stmia %[d]!, {r0, r1, r2, r3};" - : [d] "+r" (data), [w] "+r" (window) - : : "r0", "r1", "r2", "r3", - "r4", "r5", "r6", "r7", "r8", "r9", - "memory" ); - n -= 4; - } - while(n>0) { - *data = MULT31(*data, *window); - data++; - window++; - n--; - } -} - -static inline -void vect_mult_bw(int32_t *data, const int32_t *window, int n) -{ - while (n>=4) { - asm volatile ("ldmia %[d], {r0, r1, r2, r3};" - "ldmda %[w]!, {r4, r5, r6, r7};" - "smull r8, r9, r0, r7;" - "mov r0, r9, lsl #1;" - "smull r8, r9, r1, r6;" - "mov r1, r9, lsl #1;" - "smull r8, r9, r2, r5;" - "mov r2, r9, lsl #1;" - "smull r8, r9, r3, r4;" - "mov r3, r9, lsl #1;" - "stmia %[d]!, {r0, r1, r2, r3};" - : [d] "+r" (data), [w] "+r" (window) - : : "r0", "r1", "r2", "r3", - "r4", "r5", "r6", "r7", "r8", "r9", - "memory" ); - n -= 4; - } - while(n>0) { - *data = MULT31(*data, *window); - data++; - window--; - n--; - } -} - -#endif - -/* not used anymore */ -/* -#ifndef _V_CLIP_MATH -#define _V_CLIP_MATH - -static inline int32_t CLIP_TO_15(int32_t x) { - int tmp; - asm volatile("subs %1, %0, #32768\n\t" - "movpl %0, #0x7f00\n\t" - "orrpl %0, %0, #0xff\n" - "adds %1, %0, #32768\n\t" - "movmi %0, #0x8000" - : "+r"(x),"=r"(tmp) - : - : "cc"); - return(x); -} - -#endif -*/ - -#endif - diff --git a/apps/codecs/lib/asm_mcf5249.h b/apps/codecs/lib/asm_mcf5249.h deleted file mode 100644 index 841c413a94..0000000000 --- a/apps/codecs/lib/asm_mcf5249.h +++ /dev/null @@ -1,353 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * - * Copyright (C) 2005 by Pedro Vasconcelos - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ -/* asm routines for wide math on the MCF5249 */ - -#if defined(CPU_COLDFIRE) - -#define INCL_OPTIMIZED_MULT32 -static inline int32_t MULT32(int32_t x, int32_t y) { - - asm volatile ("mac.l %[x], %[y], %%acc0;" /* multiply & shift */ - "movclr.l %%acc0, %[x];" /* move & clear acc */ - "asr.l #1, %[x];" /* no overflow test */ - : [x] "+&d" (x) - : [y] "r" (y) - : "cc"); - return x; -} - -#define INCL_OPTIMIZED_MULT31 -static inline int32_t MULT31(int32_t x, int32_t y) { - asm volatile ("mac.l %[x], %[y], %%acc0;" /* multiply */ - "movclr.l %%acc0, %[x];" /* move and clear */ - : [x] "+&r" (x) - : [y] "r" (y) - : "cc"); - return x; -} - -#define INCL_OPTIMIZED_MULT31_SHIFT15 -/* NOTE: this requires that the emac is *NOT* rounding */ -static inline int32_t MULT31_SHIFT15(int32_t x, int32_t y) { - int32_t r; - - asm volatile ("mac.l %[x], %[y], %%acc0;" /* multiply */ - "mulu.l %[y], %[x];" /* get lower half, avoid emac stall */ - "movclr.l %%acc0, %[r];" /* get higher half */ - "swap %[r];" /* hi<<16, plus one free */ - "lsr.l #8, %[x];" /* (unsigned)lo >> 15 */ - "lsr.l #7, %[x];" - "move.w %[x], %[r];" /* logical-or results */ - : [r] "=&d" (r), [x] "+d" (x) - : [y] "d" (y) - : "cc"); - return r; -} - -#define INCL_OPTIMIZED_MULT31_SHIFT16 -static inline int32_t MULT31_SHIFT16(int32_t x, int32_t y) { - int32_t r; - - asm volatile ("mac.l %[x], %[y], %%acc0;" /* multiply */ - "mulu.l %[y], %[x];" /* get lower half, avoid emac stall */ - "movclr.l %%acc0, %[r];" /* get higher half */ - "lsr.l #1, %[r];" /* hi >> 1, to compensate emac shift */ - "move.w %[r], %[x];" /* x = x & 0xffff0000 | r & 0xffff */ - "swap %[x];" /* x = (unsigned)x << 16 | (unsigned)x >> 16 */ - : [r] "=&d" (r), [x] "+d" (x) - : [y] "d" (y) - : "cc"); - return x; -} - -#define INCL_OPTIMIZED_XPROD31 -static inline -void XPROD31(int32_t a, int32_t b, - int32_t t, int32_t v, - int32_t *x, int32_t *y) -{ - asm volatile ("mac.l %[a], %[t], %%acc0;" - "mac.l %[b], %[v], %%acc0;" - "mac.l %[b], %[t], %%acc1;" - "msac.l %[a], %[v], %%acc1;" - "movclr.l %%acc0, %[a];" - "move.l %[a], (%[x]);" - "movclr.l %%acc1, %[a];" - "move.l %[a], (%[y]);" - : [a] "+&r" (a) - : [x] "a" (x), [y] "a" (y), - [b] "r" (b), [t] "r" (t), [v] "r" (v) - : "cc", "memory"); -} - -#define INCL_OPTIMIZED_XNPROD31 -static inline -void XNPROD31(int32_t a, int32_t b, - int32_t t, int32_t v, - int32_t *x, int32_t *y) -{ - asm volatile ("mac.l %[a], %[t], %%acc0;" - "msac.l %[b], %[v], %%acc0;" - "mac.l %[b], %[t], %%acc1;" - "mac.l %[a], %[v], %%acc1;" - "movclr.l %%acc0, %[a];" - "move.l %[a], (%[x]);" - "movclr.l %%acc1, %[a];" - "move.l %[a], (%[y]);" - : [a] "+&r" (a) - : [x] "a" (x), [y] "a" (y), - [b] "r" (b), [t] "r" (t), [v] "r" (v) - : "cc", "memory"); -} - - -/* this could lose the LSB by overflow, but i don't think it'll ever happen. - if anyone think they can hear a bug caused by this, please try the above - version. */ -#define INCL_OPTIMIZED_XPROD32 -#define XPROD32(_a, _b, _t, _v, _x, _y) \ - asm volatile ("mac.l %[a], %[t], %%acc0;" \ - "mac.l %[b], %[v], %%acc0;" \ - "mac.l %[b], %[t], %%acc1;" \ - "msac.l %[a], %[v], %%acc1;" \ - "movclr.l %%acc0, %[x];" \ - "asr.l #1, %[x];" \ - "movclr.l %%acc1, %[y];" \ - "asr.l #1, %[y];" \ - : [x] "=d" (_x), [y] "=d" (_y) \ - : [a] "r" (_a), [b] "r" (_b), \ - [t] "r" (_t), [v] "r" (_v) \ - : "cc"); - -#define INCL_OPTIMIZED_XPROD31_R -#define XPROD31_R(_a, _b, _t, _v, _x, _y) \ - asm volatile ("mac.l %[a], %[t], %%acc0;" \ - "mac.l %[b], %[v], %%acc0;" \ - "mac.l %[b], %[t], %%acc1;" \ - "msac.l %[a], %[v], %%acc1;" \ - "movclr.l %%acc0, %[x];" \ - "movclr.l %%acc1, %[y];" \ - : [x] "=r" (_x), [y] "=r" (_y) \ - : [a] "r" (_a), [b] "r" (_b), \ - [t] "r" (_t), [v] "r" (_v) \ - : "cc"); - -#define INCL_OPTIMIZED_XNPROD31_R -#define XNPROD31_R(_a, _b, _t, _v, _x, _y) \ - asm volatile ("mac.l %[a], %[t], %%acc0;" \ - "msac.l %[b], %[v], %%acc0;" \ - "mac.l %[b], %[t], %%acc1;" \ - "mac.l %[a], %[v], %%acc1;" \ - "movclr.l %%acc0, %[x];" \ - "movclr.l %%acc1, %[y];" \ - : [x] "=r" (_x), [y] "=r" (_y) \ - : [a] "r" (_a), [b] "r" (_b), \ - [t] "r" (_t), [v] "r" (_v) \ - : "cc"); - -#ifndef _V_VECT_OPS -#define _V_VECT_OPS - -/* asm versions of vector operations for block.c, window.c */ -/* assumes MAC is initialized & accumulators cleared */ -static inline -void vect_add(int32_t *x, const int32_t *y, int n) -{ - /* align to 16 bytes */ - while(n>0 && (int)x&15) { - *x++ += *y++; - n--; - } - asm volatile ("bra 1f;" - "0:" /* loop start */ - "movem.l (%[x]), %%d0-%%d3;" /* fetch values */ - "movem.l (%[y]), %%a0-%%a3;" - /* add */ - "add.l %%a0, %%d0;" - "add.l %%a1, %%d1;" - "add.l %%a2, %%d2;" - "add.l %%a3, %%d3;" - /* store and advance */ - "movem.l %%d0-%%d3, (%[x]);" - "lea.l (4*4, %[x]), %[x];" - "lea.l (4*4, %[y]), %[y];" - "subq.l #4, %[n];" /* done 4 elements */ - "1: cmpi.l #4, %[n];" - "bge 0b;" - : [n] "+d" (n), [x] "+a" (x), [y] "+a" (y) - : : "%d0", "%d1", "%d2", "%d3", "%a0", "%a1", "%a2", "%a3", - "cc", "memory"); - /* add final elements */ - while (n>0) { - *x++ += *y++; - n--; - } -} - -static inline -void vect_copy(int32_t *x, const int32_t *y, int n) -{ - /* align to 16 bytes */ - while(n>0 && (int)x&15) { - *x++ = *y++; - n--; - } - asm volatile ("bra 1f;" - "0:" /* loop start */ - "movem.l (%[y]), %%d0-%%d3;" /* fetch values */ - "movem.l %%d0-%%d3, (%[x]);" /* store */ - "lea.l (4*4, %[x]), %[x];" /* advance */ - "lea.l (4*4, %[y]), %[y];" - "subq.l #4, %[n];" /* done 4 elements */ - "1: cmpi.l #4, %[n];" - "bge 0b;" - : [n] "+d" (n), [x] "+a" (x), [y] "+a" (y) - : : "%d0", "%d1", "%d2", "%d3", "cc", "memory"); - /* copy final elements */ - while (n>0) { - *x++ = *y++; - n--; - } -} - -static inline -void vect_mult_fw(int32_t *data, const int32_t *window, int n) -{ - /* ensure data is aligned to 16-bytes */ - while(n>0 && (int)data&15) { - *data = MULT31(*data, *window); - data++; - window++; - n--; - } - asm volatile ("movem.l (%[d]), %%d0-%%d3;" /* loop start */ - "movem.l (%[w]), %%a0-%%a3;" /* pre-fetch registers */ - "lea.l (4*4, %[w]), %[w];" - "bra 1f;" /* jump to loop condition */ - "0:" /* loop body */ - /* multiply and load next window values */ - "mac.l %%d0, %%a0, (%[w])+, %%a0, %%acc0;" - "mac.l %%d1, %%a1, (%[w])+, %%a1, %%acc1;" - "mac.l %%d2, %%a2, (%[w])+, %%a2, %%acc2;" - "mac.l %%d3, %%a3, (%[w])+, %%a3, %%acc3;" - "movclr.l %%acc0, %%d0;" /* get the products */ - "movclr.l %%acc1, %%d1;" - "movclr.l %%acc2, %%d2;" - "movclr.l %%acc3, %%d3;" - /* store and advance */ - "movem.l %%d0-%%d3, (%[d]);" - "lea.l (4*4, %[d]), %[d];" - "movem.l (%[d]), %%d0-%%d3;" - "subq.l #4, %[n];" /* done 4 elements */ - "1: cmpi.l #4, %[n];" - "bge 0b;" - /* multiply final elements */ - "tst.l %[n];" - "beq 1f;" /* n=0 */ - "mac.l %%d0, %%a0, %%acc0;" - "movclr.l %%acc0, %%d0;" - "move.l %%d0, (%[d])+;" - "subq.l #1, %[n];" - "beq 1f;" /* n=1 */ - "mac.l %%d1, %%a1, %%acc0;" - "movclr.l %%acc0, %%d1;" - "move.l %%d1, (%[d])+;" - "subq.l #1, %[n];" - "beq 1f;" /* n=2 */ - /* otherwise n = 3 */ - "mac.l %%d2, %%a2, %%acc0;" - "movclr.l %%acc0, %%d2;" - "move.l %%d2, (%[d])+;" - "1:" - : [n] "+d" (n), [d] "+a" (data), [w] "+a" (window) - : : "%d0", "%d1", "%d2", "%d3", "%a0", "%a1", "%a2", "%a3", - "cc", "memory"); -} - -static inline -void vect_mult_bw(int32_t *data, const int32_t *window, int n) -{ - /* ensure at least data is aligned to 16-bytes */ - while(n>0 && (int)data&15) { - *data = MULT31(*data, *window); - data++; - window--; - n--; - } - asm volatile ("lea.l (-3*4, %[w]), %[w];" /* loop start */ - "movem.l (%[d]), %%d0-%%d3;" /* pre-fetch registers */ - "movem.l (%[w]), %%a0-%%a3;" - "bra 1f;" /* jump to loop condition */ - "0:" /* loop body */ - /* multiply and load next window value */ - "mac.l %%d0, %%a3, -(%[w]), %%a3, %%acc0;" - "mac.l %%d1, %%a2, -(%[w]), %%a2, %%acc1;" - "mac.l %%d2, %%a1, -(%[w]), %%a1, %%acc2;" - "mac.l %%d3, %%a0, -(%[w]), %%a0, %%acc3;" - "movclr.l %%acc0, %%d0;" /* get the products */ - "movclr.l %%acc1, %%d1;" - "movclr.l %%acc2, %%d2;" - "movclr.l %%acc3, %%d3;" - /* store and advance */ - "movem.l %%d0-%%d3, (%[d]);" - "lea.l (4*4, %[d]), %[d];" - "movem.l (%[d]), %%d0-%%d3;" - "subq.l #4, %[n];" /* done 4 elements */ - "1: cmpi.l #4, %[n];" - "bge 0b;" - /* multiply final elements */ - "tst.l %[n];" - "beq 1f;" /* n=0 */ - "mac.l %%d0, %%a3, %%acc0;" - "movclr.l %%acc0, %%d0;" - "move.l %%d0, (%[d])+;" - "subq.l #1, %[n];" - "beq 1f;" /* n=1 */ - "mac.l %%d1, %%a2, %%acc0;" - "movclr.l %%acc0, %%d1;" - "move.l %%d1, (%[d])+;" - "subq.l #1, %[n];" - "beq 1f;" /* n=2 */ - /* otherwise n = 3 */ - "mac.l %%d2, %%a1, %%acc0;" - "movclr.l %%acc0, %%d2;" - "move.l %%d2, (%[d])+;" - "1:" - : [n] "+d" (n), [d] "+a" (data), [w] "+a" (window) - : : "%d0", "%d1", "%d2", "%d3", "%a0", "%a1", "%a2", "%a3", - "cc", "memory"); -} - -#endif - -/* not used anymore */ -/* -#ifndef _V_CLIP_MATH -#define _V_CLIP_MATH - -* this is portable C and simple; why not use this as default? -static inline int32_t CLIP_TO_15(register int32_t x) { - register int32_t hi=32767, lo=-32768; - return (x>=hi ? hi : (x<=lo ? lo : x)); -} - -#endif -*/ -#endif diff --git a/apps/codecs/lib/codeclib.c b/apps/codecs/lib/codeclib.c deleted file mode 100644 index 36f4279941..0000000000 --- a/apps/codecs/lib/codeclib.c +++ /dev/null @@ -1,182 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2005 Dave Chapman - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ - -/* "helper functions" common to all codecs */ - -#include -#include "codecs.h" -#include "dsp.h" -#include "codeclib.h" -#include "metadata.h" - -/* The following variables are used by codec_malloc() to make use of free RAM - * within the statically allocated codec buffer. */ -static size_t mem_ptr = 0; -static size_t bufsize = 0; -static unsigned char* mallocbuf = NULL; - -int codec_init(void) -{ - /* codec_get_buffer() aligns the resulting point to CACHEALIGN_SIZE. */ - mem_ptr = 0; - mallocbuf = (unsigned char *)ci->codec_get_buffer((size_t *)&bufsize); - - return 0; -} - -void codec_set_replaygain(const struct mp3entry *id3) -{ - ci->configure(DSP_SET_TRACK_GAIN, id3->track_gain); - ci->configure(DSP_SET_ALBUM_GAIN, id3->album_gain); - ci->configure(DSP_SET_TRACK_PEAK, id3->track_peak); - ci->configure(DSP_SET_ALBUM_PEAK, id3->album_peak); -} - -/* Various "helper functions" common to all the xxx2wav decoder plugins */ - - -void* codec_malloc(size_t size) -{ - void* x; - - if (mem_ptr + (long)size > bufsize) - return NULL; - - x=&mallocbuf[mem_ptr]; - - /* Keep memory aligned to CACHEALIGN_SIZE. */ - mem_ptr += (size + (CACHEALIGN_SIZE-1)) & ~(CACHEALIGN_SIZE-1); - - return(x); -} - -void* codec_calloc(size_t nmemb, size_t size) -{ - void* x; - x = codec_malloc(nmemb*size); - if (x == NULL) - return NULL; - ci->memset(x,0,nmemb*size); - return(x); -} - -void codec_free(void* ptr) { - (void)ptr; -} - -void* codec_realloc(void* ptr, size_t size) -{ - void* x; - (void)ptr; - x = codec_malloc(size); - return(x); -} - -size_t strlen(const char *s) -{ - return(ci->strlen(s)); -} - -char *strcpy(char *dest, const char *src) -{ - return(ci->strcpy(dest,src)); -} - -char *strcat(char *dest, const char *src) -{ - return(ci->strcat(dest,src)); -} - -int strcmp(const char *s1, const char *s2) -{ - return(ci->strcmp(s1,s2)); -} - -void *memcpy(void *dest, const void *src, size_t n) -{ - return(ci->memcpy(dest,src,n)); -} - -void *memset(void *s, int c, size_t n) -{ - return(ci->memset(s,c,n)); -} - -int memcmp(const void *s1, const void *s2, size_t n) -{ - return(ci->memcmp(s1,s2,n)); -} - -void* memchr(const void *s, int c, size_t n) -{ - return(ci->memchr(s,c,n)); -} - -void *memmove(void *dest, const void *src, size_t n) -{ - return(ci->memmove(dest,src,n)); -} - -void qsort(void *base, size_t nmemb, size_t size, - int(*compar)(const void *, const void *)) -{ - ci->qsort(base,nmemb,size,compar); -} - -/* From ffmpeg - libavutil/common.h */ -const uint8_t bs_log2_tab[256] ICONST_ATTR = { - 0,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, - 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, - 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, - 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7 -}; - -const uint8_t bs_clz_tab[256] ICONST_ATTR = { - 8,7,6,6,5,5,5,5,4,4,4,4,4,4,4,4,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, - 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -}; - -#ifdef RB_PROFILE -void __cyg_profile_func_enter(void *this_fn, void *call_site) { -/* This workaround is required for coldfire gcc 3.4 but is broken for 4.4 - and 4.5, but for those the other way works. */ -#if defined(CPU_COLDFIRE) && defined(__GNUC__) && __GNUC__ < 4 - (void)call_site; - ci->profile_func_enter(this_fn, __builtin_return_address(1)); -#else - ci->profile_func_enter(this_fn, call_site); -#endif -} - -void __cyg_profile_func_exit(void *this_fn, void *call_site) { - ci->profile_func_exit(this_fn,call_site); -} -#endif diff --git a/apps/codecs/lib/codeclib.h b/apps/codecs/lib/codeclib.h deleted file mode 100644 index d0f985b8e1..0000000000 --- a/apps/codecs/lib/codeclib.h +++ /dev/null @@ -1,163 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2005 Dave Chapman - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ - -#ifndef __CODECLIB_H__ -#define __CODECLIB_H__ - -#include -#include -#include "config.h" -#include "codecs.h" -#include "mdct.h" -#include "fft.h" - -extern struct codec_api *ci; - -/* Standard library functions that are used by the codecs follow here */ - -/* Get these functions 'out of the way' of the standard functions. Not doing - * so confuses the cygwin linker, and maybe others. These functions need to - * be implemented elsewhere */ -#define malloc(x) codec_malloc(x) -#define calloc(x,y) codec_calloc(x,y) -#define realloc(x,y) codec_realloc(x,y) -#define free(x) codec_free(x) -#undef alloca -#define alloca(x) __builtin_alloca(x) - -void* codec_malloc(size_t size); -void* codec_calloc(size_t nmemb, size_t size); -void* codec_realloc(void* ptr, size_t size); -void codec_free(void* ptr); - -void *memcpy(void *dest, const void *src, size_t n); -void *memset(void *s, int c, size_t n); -int memcmp(const void *s1, const void *s2, size_t n); -void *memmove(void *s1, const void *s2, size_t n); - -size_t strlen(const char *s); -char *strcpy(char *dest, const char *src); -char *strcat(char *dest, const char *src); - -/* on some platforms strcmp() seems to be a tricky define which - * breaks if we write down strcmp's prototype */ -#undef strcmp -int strcmp(const char *s1, const char *s2); - -void qsort(void *base, size_t nmemb, size_t size, int(*compar)(const void *, const void *)); - -/*MDCT library functions*/ -/* -1- Tremor mdct */ -extern void mdct_backward(int n, int32_t *in, int32_t *out); -/* -2- ffmpeg fft-based mdct */ -extern void ff_imdct_half(unsigned int nbits, int32_t *output, const int32_t *input); -extern void ff_imdct_calc(unsigned int nbits, int32_t *output, const int32_t *input); -/*ffmpeg fft (can be used without mdct)*/ -extern void ff_fft_calc_c(int nbits, FFTComplex *z); - -#if !defined(CPU_ARM) || ARM_ARCH < 5 -/* From libavutil/common.h */ -extern const uint8_t bs_log2_tab[256] ICONST_ATTR; -extern const uint8_t bs_clz_tab[256] ICONST_ATTR; -#endif - -#define BS_LOG2 0 /* default personality, equivalent floor(log2(x)) */ -#define BS_CLZ 1 /* alternate personality, Count Leading Zeros */ -#define BS_SHORT 2 /* input guaranteed not to exceed 16 bits */ -#define BS_0_0 4 /* guarantee mapping of 0 input to 0 output */ - -/* Generic bit-scanning function, used to wrap platform CLZ instruction or - scan-and-lookup code, and to provide control over output for 0 inputs. */ -static inline unsigned int bs_generic(unsigned int v, int mode) -{ -#if defined(CPU_ARM) && ARM_ARCH >= 5 - unsigned int r = __builtin_clz(v); - if (mode & BS_CLZ) - { - if (mode & BS_0_0) - r &= 31; - } else { - r = 31 - r; - /* If mode is constant, this is a single conditional instruction */ - if (mode & BS_0_0 && (signed)r < 0) - r += 1; - } -#else - const uint8_t *bs_tab; - unsigned int r; - unsigned int n = v; - int inc; - /* Set up table, increment, and initial result value based on - personality. */ - if (mode & BS_CLZ) - { - bs_tab = bs_clz_tab; - r = 24; - inc = -16; - } else { - bs_tab = bs_log2_tab; - r = 0; - inc = 16; - } - if (!(mode & BS_SHORT) && n >= 0x10000) { - n >>= 16; - r += inc; - } - if (n > 0xff) { - n >>= 8; - r += inc / 2; - } -#ifdef CPU_COLDFIRE - /* The high 24 bits of n are guaranteed empty after the above, so a - superfluous ext.b instruction can be saved by loading the LUT value over - n with asm */ - asm volatile ( - "move.b (%1,%0.l),%0" - : "+d" (n) - : "a" (bs_tab) - ); -#else - n = bs_tab[n]; -#endif - r += n; - if (mode & BS_CLZ && mode & BS_0_0 && v == 0) - r = 0; -#endif - return r; -} - -/* TODO figure out if we really need to care about calculating - av_log2(0) */ -#define av_log2(v) bs_generic(v, BS_0_0) - -/* Various codec helper functions */ - -int codec_init(void); -void codec_set_replaygain(const struct mp3entry *id3); - -#ifdef RB_PROFILE -void __cyg_profile_func_enter(void *this_fn, void *call_site) - NO_PROF_ATTR ICODE_ATTR; -void __cyg_profile_func_exit(void *this_fn, void *call_site) - NO_PROF_ATTR ICODE_ATTR; -#endif - -#endif /* __CODECLIB_H__ */ diff --git a/apps/codecs/lib/codeclib_misc.h b/apps/codecs/lib/codeclib_misc.h deleted file mode 100644 index 8ebe22e37b..0000000000 --- a/apps/codecs/lib/codeclib_misc.h +++ /dev/null @@ -1,310 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * - * * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * - * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * - * * - ******************************************************************** - - function: miscellaneous math and prototypes - - ********************************************************************/ - -#ifndef _CODECLIB_MISC_H_ -#define _CODECLIB_MISC_H_ - -#include -#include "asm_arm.h" -#include "asm_mcf5249.h" - -#ifndef _LOW_ACCURACY_ -/* 64 bit multiply */ - -#ifdef ROCKBOX_LITTLE_ENDIAN -union magic { - struct { - int32_t lo; - int32_t hi; - } halves; - int64_t whole; -}; -#elif defined(ROCKBOX_BIG_ENDIAN) -union magic { - struct { - int32_t hi; - int32_t lo; - } halves; - int64_t whole; -}; -#endif - -#ifndef INCL_OPTIMIZED_MULT32 -#define INCL_OPTIMIZED_MULT32 -static inline int32_t MULT32(int32_t x, int32_t y) { - union magic magic; - magic.whole = (int64_t)x * y; - return magic.halves.hi; -} -#endif - -#ifndef INCL_OPTIMIZED_MULT31 -#define INCL_OPTIMIZED_MULT31 -static inline int32_t MULT31(int32_t x, int32_t y) { - return MULT32(x,y)<<1; -} -#endif - -#ifndef INCL_OPTIMIZED_MULT31_SHIFT15 -#define INCL_OPTIMIZED_MULT31_SHIFT15 -static inline int32_t MULT31_SHIFT15(int32_t x, int32_t y) { - union magic magic; - magic.whole = (int64_t)x * y; - return ((uint32_t)(magic.halves.lo)>>15) | ((magic.halves.hi)<<17); -} -#endif - -#ifndef INCL_OPTIMIZED_MULT31_SHIFT16 -#define INCL_OPTIMIZED_MULT31_SHIFT16 -static inline int32_t MULT31_SHIFT16(int32_t x, int32_t y) { - union magic magic; - magic.whole = (int64_t)x * y; - return ((uint32_t)(magic.halves.lo)>>16) | ((magic.halves.hi)<<16); -} -#endif - -#else -/* Rockbox: unused */ -#if 0 -/* 32 bit multiply, more portable but less accurate */ - -/* - * Note: Precision is biased towards the first argument therefore ordering - * is important. Shift values were chosen for the best sound quality after - * many listening tests. - */ - -/* - * For MULT32 and MULT31: The second argument is always a lookup table - * value already preshifted from 31 to 8 bits. We therefore take the - * opportunity to save on text space and use unsigned char for those - * tables in this case. - */ - -static inline int32_t MULT32(int32_t x, int32_t y) { - return (x >> 9) * y; /* y preshifted >>23 */ -} - -static inline int32_t MULT31(int32_t x, int32_t y) { - return (x >> 8) * y; /* y preshifted >>23 */ -} - -static inline int32_t MULT31_SHIFT15(int32_t x, int32_t y) { - return (x >> 6) * y; /* y preshifted >>9 */ -} -#endif -#endif - -/* - * The XPROD functions are meant to optimize the cross products found all - * over the place in mdct.c by forcing memory operation ordering to avoid - * unnecessary register reloads as soon as memory is being written to. - * However this is only beneficial on CPUs with a sane number of general - * purpose registers which exclude the Intel x86. On Intel, better let the - * compiler actually reload registers directly from original memory by using - * macros. - */ - -#ifndef INCL_OPTIMIZED_XPROD32 -#define INCL_OPTIMIZED_XPROD32 -/* replaced XPROD32 with a macro to avoid memory reference - _x, _y are the results (must be l-values) */ -#define XPROD32(_a, _b, _t, _v, _x, _y) \ - { (_x)=MULT32(_a,_t)+MULT32(_b,_v); \ - (_y)=MULT32(_b,_t)-MULT32(_a,_v); } -#endif - -/* Rockbox: Unused */ -/* -#ifdef __i386__ - -#define XPROD31(_a, _b, _t, _v, _x, _y) \ - { *(_x)=MULT31(_a,_t)+MULT31(_b,_v); \ - *(_y)=MULT31(_b,_t)-MULT31(_a,_v); } -#define XNPROD31(_a, _b, _t, _v, _x, _y) \ - { *(_x)=MULT31(_a,_t)-MULT31(_b,_v); \ - *(_y)=MULT31(_b,_t)+MULT31(_a,_v); } - -#else -*/ - -#ifndef INCL_OPTIMIZED_XPROD31 -#define INCL_OPTIMIZED_XPROD31 -static inline void XPROD31(int32_t a, int32_t b, - int32_t t, int32_t v, - int32_t *x, int32_t *y) -{ - *x = MULT31(a, t) + MULT31(b, v); - *y = MULT31(b, t) - MULT31(a, v); -} -#endif - -#ifndef INCL_OPTIMIZED_XNPROD31 -#define INCL_OPTIMIZED_XNPROD31 -static inline void XNPROD31(int32_t a, int32_t b, - int32_t t, int32_t v, - int32_t *x, int32_t *y) -{ - *x = MULT31(a, t) - MULT31(b, v); - *y = MULT31(b, t) + MULT31(a, v); -} -#endif -/*#endif*/ - -#ifndef INCL_OPTIMIZED_XPROD31_R -#define INCL_OPTIMIZED_XPROD31_R -#define XPROD31_R(_a, _b, _t, _v, _x, _y)\ -{\ - _x = MULT31(_a, _t) + MULT31(_b, _v);\ - _y = MULT31(_b, _t) - MULT31(_a, _v);\ -} -#endif - -#ifndef INCL_OPTIMIZED_XNPROD31_R -#define INCL_OPTIMIZED_XNPROD31_R -#define XNPROD31_R(_a, _b, _t, _v, _x, _y)\ -{\ - _x = MULT31(_a, _t) - MULT31(_b, _v);\ - _y = MULT31(_b, _t) + MULT31(_a, _v);\ -} -#endif - -#ifndef _V_VECT_OPS -#define _V_VECT_OPS - -static inline -void vect_add(int32_t *x, const int32_t *y, int n) -{ - while (n>0) { - *x++ += *y++; - n--; - } -} - -static inline -void vect_copy(int32_t *x, const int32_t *y, int n) -{ - while (n>0) { - *x++ = *y++; - n--; - } -} - -static inline -void vect_mult_fw(int32_t *data, const int32_t *window, int n) -{ - while(n>0) { - *data = MULT31(*data, *window); - data++; - window++; - n--; - } -} - -static inline -void vect_mult_bw(int32_t *data, const int32_t *window, int n) -{ - while(n>0) { - *data = MULT31(*data, *window); - data++; - window--; - n--; - } -} -#endif - -/* not used anymore */ -/* -#ifndef _V_CLIP_MATH -#define _V_CLIP_MATH - -static inline int32_t CLIP_TO_15(int32_t x) { - int ret=x; - ret-= ((x<=32767)-1)&(x-32767); - ret-= ((x>=-32768)-1)&(x+32768); - return(ret); -} - -#endif -*/ -static inline int32_t VFLOAT_MULT(int32_t a,int32_t ap, - int32_t b,int32_t bp, - int32_t *p){ - if(a && b){ -#ifndef _LOW_ACCURACY_ - *p=ap+bp+32; - return MULT32(a,b); -#else - *p=ap+bp+31; - return (a>>15)*(b>>16); -#endif - }else - return 0; -} - -/*static inline int32_t VFLOAT_MULTI(int32_t a,int32_t ap, - int32_t i, - int32_t *p){ - - int ip=_ilog(abs(i))-31; - return VFLOAT_MULT(a,ap,i<<-ip,ip,p); -} -*/ -static inline int32_t VFLOAT_ADD(int32_t a,int32_t ap, - int32_t b,int32_t bp, - int32_t *p){ - - if(!a){ - *p=bp; - return b; - }else if(!b){ - *p=ap; - return a; - } - - /* yes, this can leak a bit. */ - if(ap>bp){ - int shift=ap-bp+1; - *p=ap+1; - a>>=1; - if(shift<32){ - b=(b+(1<<(shift-1)))>>shift; - }else{ - b=0; - } - }else{ - int shift=bp-ap+1; - *p=bp+1; - b>>=1; - if(shift<32){ - a=(a+(1<<(shift-1)))>>shift; - }else{ - a=0; - } - } - - a+=b; - if((a&0xc0000000)==0xc0000000 || - (a&0xc0000000)==0){ - a<<=1; - (*p)--; - } - return(a); -} - -#endif - diff --git a/apps/codecs/lib/ffmpeg_bitstream.c b/apps/codecs/lib/ffmpeg_bitstream.c deleted file mode 100644 index e16df8dcce..0000000000 --- a/apps/codecs/lib/ffmpeg_bitstream.c +++ /dev/null @@ -1,374 +0,0 @@ -/* - * Common bit i/o utils - * Copyright (c) 2000, 2001 Fabrice Bellard - * Copyright (c) 2002-2004 Michael Niedermayer - * Copyright (c) 2010 Loren Merritt - * - * alternative bitstream reader & writer by Michael Niedermayer - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/** - * @file - * bitstream api. - */ - -//#include "avcodec.h" -#include "ffmpeg_get_bits.h" -#include "ffmpeg_put_bits.h" -#include "ffmpeg_intreadwrite.h" - -#define av_log(...) - -#ifdef ROCKBOX -#undef DEBUGF -#define DEBUGF(...) -#endif - -const uint8_t ff_log2_run[32]={ - 0, 0, 0, 0, 1, 1, 1, 1, - 2, 2, 2, 2, 3, 3, 3, 3, - 4, 4, 5, 5, 6, 6, 7, 7, - 8, 9,10,11,12,13,14,15 -}; - -#if 0 // unused in rockbox -void align_put_bits(PutBitContext *s) -{ -#ifdef ALT_BITSTREAM_WRITER - put_bits(s,( - s->index) & 7,0); -#else - put_bits(s,s->bit_left & 7,0); -#endif -} - -void ff_put_string(PutBitContext *pb, const char *string, int terminate_string) -{ - while(*string){ - put_bits(pb, 8, *string); - string++; - } - if(terminate_string) - put_bits(pb, 8, 0); -} -#endif - -void ff_copy_bits(PutBitContext *pb, const uint8_t *src, int length) -{ - int words= length>>4; - int bits= length&15; - int i; - - if(length==0) return; - - if(words < 16 || put_bits_count(pb)&7){ - for(i=0; i>(16-bits)); -} - -/* VLC decoding */ - -//#define DEBUG_VLC - -#define GET_DATA(v, table, i, wrap, size) \ -{\ - const uint8_t *ptr = (const uint8_t *)table + i * wrap;\ - switch(size) {\ - case 1:\ - v = *(const uint8_t *)ptr;\ - break;\ - case 2:\ - v = *(const uint16_t *)ptr;\ - break;\ - default:\ - v = *(const uint32_t *)ptr;\ - break;\ - }\ -} - - -static int alloc_table(VLC *vlc, int size, int use_static) -{ - int index; - index = vlc->table_size; - vlc->table_size += size; - if (vlc->table_size > vlc->table_allocated) { - if(use_static) - { - DEBUGF("init_vlc() used with too little memory : table_size > allocated_memory\n"); - return -1; - } -// abort(); //cant do anything, init_vlc() is used with too little memory -// vlc->table_allocated += (1 << vlc->bits); -// vlc->table = av_realloc(vlc->table, -// sizeof(VLC_TYPE) * 2 * vlc->table_allocated); - if (!vlc->table) - return -1; - } - return index; -} - -/* -static av_always_inline uint32_t bitswap_32(uint32_t x) { - return av_reverse[x&0xFF]<<24 - | av_reverse[(x>>8)&0xFF]<<16 - | av_reverse[(x>>16)&0xFF]<<8 - | av_reverse[x>>24]; -} -*/ - -typedef struct { - uint8_t bits; - uint16_t symbol; - /** codeword, with the first bit-to-be-read in the msb - * (even if intended for a little-endian bitstream reader) */ - uint32_t code; -} __attribute__((__packed__)) VLCcode; /* packed to save space */ - -static int compare_vlcspec(const void *a, const void *b) -{ - const VLCcode *sa=a, *sb=b; - return (sa->code >> 1) - (sb->code >> 1); -} - -/** - * Build VLC decoding tables suitable for use with get_vlc(). - * - * @param vlc the context to be initted - * - * @param table_nb_bits max length of vlc codes to store directly in this table - * (Longer codes are delegated to subtables.) - * - * @param nb_codes number of elements in codes[] - * - * @param codes descriptions of the vlc codes - * These must be ordered such that codes going into the same subtable are contiguous. - * Sorting by VLCcode.code is sufficient, though not necessary. - */ -static int build_table(VLC *vlc, int table_nb_bits, int nb_codes, - VLCcode *codes, int flags) -{ - int table_size, table_index, index, symbol, subtable_bits; - int i, j, k, n, nb, inc; - uint32_t code, code_prefix; - VLC_TYPE (*table)[2]; - - table_size = 1 << table_nb_bits; - table_index = alloc_table(vlc, table_size, flags & INIT_VLC_USE_NEW_STATIC); -#ifdef DEBUG_VLC - av_log(NULL,AV_LOG_DEBUG,"new table index=%d size=%d\n", - table_index, table_size); -#endif - if (table_index < 0) - return -1; - table = &vlc->table[table_index]; - - for (i = 0; i < table_size; i++) { - table[i][1] = 0; //bits - table[i][0] = -1; //codes - } - - /* first pass: map codes and compute auxillary table sizes */ - for (i = 0; i < nb_codes; i++) { - n = codes[i].bits; - code = codes[i].code; - symbol = codes[i].symbol; -#if defined(DEBUG_VLC) && 0 - av_log(NULL,AV_LOG_DEBUG,"i=%d n=%d code=0x%x\n", i, n, code); -#endif - if (n <= table_nb_bits) { - /* no need to add another table */ - j = code >> (32 - table_nb_bits); - nb = 1 << (table_nb_bits - n); - inc = 1; -/* if (flags & INIT_VLC_LE) { - j = bitswap_32(code); - inc = 1 << n; - } */ - for (k = 0; k < nb; k++) { -#ifdef DEBUG_VLC - av_log(NULL, AV_LOG_DEBUG, "%4x: code=%d n=%d\n", - j, i, n); -#endif - if (table[j][1] /*bits*/ != 0) { - av_log(NULL, AV_LOG_ERROR, "incorrect codes\n"); - return -1; - } - table[j][1] = n; //bits - table[j][0] = symbol; - j += inc; - } - } else { - /* fill auxiliary table recursively */ - n -= table_nb_bits; - code_prefix = code >> (32 - table_nb_bits); - subtable_bits = n; - codes[i].bits = n; - codes[i].code = code << table_nb_bits; - for (k = i+1; k < nb_codes; k++) { - n = codes[k].bits - table_nb_bits; - if (n <= 0) - break; - code = codes[k].code; - if (code >> (32 - table_nb_bits) != code_prefix) - break; - codes[k].bits = n; - codes[k].code = code << table_nb_bits; - subtable_bits = FFMAX(subtable_bits, n); - } - subtable_bits = FFMIN(subtable_bits, table_nb_bits); - j = /*(flags & INIT_VLC_LE) ? bitswap_32(code_prefix) >> (32 - table_nb_bits) :*/ code_prefix; - table[j][1] = -subtable_bits; -#ifdef DEBUG_VLC - av_log(NULL,AV_LOG_DEBUG,"%4x: n=%d (subtable)\n", - j, codes[i].bits + table_nb_bits); -#endif - index = build_table(vlc, subtable_bits, k-i, codes+i, flags); - if (index < 0) - return -1; - /* note: realloc has been done, so reload tables */ - table = &vlc->table[table_index]; - table[j][0] = index; //code - i = k-1; - } - } - return table_index; -} - - -/* Build VLC decoding tables suitable for use with get_vlc(). - - 'nb_bits' set thee decoding table size (2^nb_bits) entries. The - bigger it is, the faster is the decoding. But it should not be too - big to save memory and L1 cache. '9' is a good compromise. - - 'nb_codes' : number of vlcs codes - - 'bits' : table which gives the size (in bits) of each vlc code. - - 'codes' : table which gives the bit pattern of of each vlc code. - - 'symbols' : table which gives the values to be returned from get_vlc(). - - 'xxx_wrap' : give the number of bytes between each entry of the - 'bits' or 'codes' tables. - - 'xxx_size' : gives the number of bytes of each entry of the 'bits' - or 'codes' tables. - - 'wrap' and 'size' allows to use any memory configuration and types - (byte/word/long) to store the 'bits', 'codes', and 'symbols' tables. - - 'use_static' should be set to 1 for tables, which should be freed - with av_free_static(), 0 if free_vlc() will be used. -*/ - -/* Rockbox: support for INIT_VLC_LE is currently disabled since none of our - codecs use it, there's a LUT based bit reverse function for this commented - out above (bitswap_32) and an inline asm version in libtremor/codebook.c - if we ever want this */ - -static VLCcode buf[1336+1]; /* worst case is wma, which has one table with 1336 entries */ - -int init_vlc_sparse(VLC *vlc, int nb_bits, int nb_codes, - const void *bits, int bits_wrap, int bits_size, - const void *codes, int codes_wrap, int codes_size, - const void *symbols, int symbols_wrap, int symbols_size, - int flags) -{ - if (nb_codes+1 > (int)(sizeof (buf)/ sizeof (VLCcode))) - { - DEBUGF("Table is larger than temp buffer!\n"); - return -1; - } - - int i, j, ret; - - vlc->bits = nb_bits; - if(flags & INIT_VLC_USE_NEW_STATIC){ - if(vlc->table_size && vlc->table_size == vlc->table_allocated){ - return 0; - }else if(vlc->table_size){ - DEBUGF("fatal error, we are called on a partially initialized table\n"); - return -1; -// abort(); // fatal error, we are called on a partially initialized table - } - }else { - vlc->table = NULL; - vlc->table_allocated = 0; - vlc->table_size = 0; - } - -#ifdef DEBUG_VLC - av_log(NULL,AV_LOG_DEBUG,"build table nb_codes=%d\n", nb_codes); -#endif - -// buf = av_malloc((nb_codes+1)*sizeof(VLCcode)); - -// assert(symbols_size <= 2 || !symbols); - j = 0; -#define COPY(condition)\ - for (i = 0; i < nb_codes; i++) {\ - GET_DATA(buf[j].bits, bits, i, bits_wrap, bits_size);\ - if (!(condition))\ - continue;\ - GET_DATA(buf[j].code, codes, i, codes_wrap, codes_size);\ -/* if (flags & INIT_VLC_LE)*/\ -/* buf[j].code = bitswap_32(buf[j].code);*/\ -/* else*/\ - buf[j].code <<= 32 - buf[j].bits;\ - if (symbols)\ - GET_DATA(buf[j].symbol, symbols, i, symbols_wrap, symbols_size)\ - else\ - buf[j].symbol = i;\ - j++;\ - } - COPY(buf[j].bits > nb_bits); - // qsort is the slowest part of init_vlc, and could probably be improved or avoided - qsort(buf, j, sizeof(VLCcode), compare_vlcspec); - COPY(buf[j].bits && buf[j].bits <= nb_bits); - nb_codes = j; - - ret = build_table(vlc, nb_bits, nb_codes, buf, flags); - -// av_free(buf); - if (ret < 0) { -// av_freep(&vlc->table); - return -1; - } - if((flags & INIT_VLC_USE_NEW_STATIC) && vlc->table_size != vlc->table_allocated) { - av_log(NULL, AV_LOG_ERROR, "needed %d had %d\n", vlc->table_size, vlc->table_allocated); - } - return 0; -} - -/* not used in rockbox -void free_vlc(VLC *vlc) -{ - av_freep(&vlc->table); -} -*/ - diff --git a/apps/codecs/lib/ffmpeg_bswap.h b/apps/codecs/lib/ffmpeg_bswap.h deleted file mode 100644 index 24a2aab7ea..0000000000 --- a/apps/codecs/lib/ffmpeg_bswap.h +++ /dev/null @@ -1,150 +0,0 @@ -/** - * @file bswap.h - * byte swap. - */ - -#ifndef __BSWAP_H__ -#define __BSWAP_H__ - -#ifdef HAVE_BYTESWAP_H -#include -#else - -#ifdef ROCKBOX -#include "codecs.h" - -/* rockbox' optimised inline functions */ -#define bswap_16(x) swap16(x) -#define bswap_32(x) swap32(x) - -static inline uint64_t ByteSwap64(uint64_t x) -{ - union { - uint64_t ll; - struct { - uint32_t l,h; - } l; - } r; - r.l.l = bswap_32 (x); - r.l.h = bswap_32 (x>>32); - return r.ll; -} -#define bswap_64(x) ByteSwap64(x) - -#elif defined(ARCH_X86) -static inline unsigned short ByteSwap16(unsigned short x) -{ - __asm("xchgb %b0,%h0" : - "=q" (x) : - "0" (x)); - return x; -} -#define bswap_16(x) ByteSwap16(x) - -static inline unsigned int ByteSwap32(unsigned int x) -{ -#if __CPU__ > 386 - __asm("bswap %0": - "=r" (x) : -#else - __asm("xchgb %b0,%h0\n" - " rorl $16,%0\n" - " xchgb %b0,%h0": - "=q" (x) : -#endif - "0" (x)); - return x; -} -#define bswap_32(x) ByteSwap32(x) - -static inline unsigned long long int ByteSwap64(unsigned long long int x) -{ - register union { __extension__ uint64_t __ll; - uint32_t __l[2]; } __x; - asm("xchgl %0,%1": - "=r"(__x.__l[0]),"=r"(__x.__l[1]): - "0"(bswap_32((unsigned long)x)),"1"(bswap_32((unsigned long)(x>>32)))); - return __x.__ll; -} -#define bswap_64(x) ByteSwap64(x) - -#elif defined(ARCH_SH4) - -static inline uint16_t ByteSwap16(uint16_t x) { - __asm__("swap.b %0,%0":"=r"(x):"0"(x)); - return x; -} - -static inline uint32_t ByteSwap32(uint32_t x) { - __asm__( - "swap.b %0,%0\n" - "swap.w %0,%0\n" - "swap.b %0,%0\n" - :"=r"(x):"0"(x)); - return x; -} - -#define bswap_16(x) ByteSwap16(x) -#define bswap_32(x) ByteSwap32(x) - -static inline uint64_t ByteSwap64(uint64_t x) -{ - union { - uint64_t ll; - struct { - uint32_t l,h; - } l; - } r; - r.l.l = bswap_32 (x); - r.l.h = bswap_32 (x>>32); - return r.ll; -} -#define bswap_64(x) ByteSwap64(x) - -#else - -#define bswap_16(x) (((x) & 0x00ff) << 8 | ((x) & 0xff00) >> 8) - - -// code from bits/byteswap.h (C) 1997, 1998 Free Software Foundation, Inc. -#define bswap_32(x) \ - ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) | \ - (((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24)) - -static inline uint64_t ByteSwap64(uint64_t x) -{ - union { - uint64_t ll; - uint32_t l[2]; - } w, r; - w.ll = x; - r.l[0] = bswap_32 (w.l[1]); - r.l[1] = bswap_32 (w.l[0]); - return r.ll; -} -#define bswap_64(x) ByteSwap64(x) - -#endif /* !ARCH_X86 */ - -#endif /* !HAVE_BYTESWAP_H */ - -// be2me ... BigEndian to MachineEndian -// le2me ... LittleEndian to MachineEndian - -#ifdef ROCKBOX_BIG_ENDIAN -#define be2me_16(x) (x) -#define be2me_32(x) (x) -#define be2me_64(x) (x) -#define le2me_16(x) bswap_16(x) -#define le2me_32(x) bswap_32(x) -#define le2me_64(x) bswap_64(x) -#else -#define be2me_16(x) bswap_16(x) -#define be2me_32(x) bswap_32(x) -#define be2me_64(x) bswap_64(x) -#define le2me_16(x) (x) -#define le2me_32(x) (x) -#define le2me_64(x) (x) -#endif - -#endif /* __BSWAP_H__ */ diff --git a/apps/codecs/lib/ffmpeg_get_bits.h b/apps/codecs/lib/ffmpeg_get_bits.h deleted file mode 100644 index 04eda021a7..0000000000 --- a/apps/codecs/lib/ffmpeg_get_bits.h +++ /dev/null @@ -1,743 +0,0 @@ -/* - * copyright (c) 2004 Michael Niedermayer - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/** - * @file - * bitstream reader API header. - */ - -#ifndef AVCODEC_GET_BITS_H -#define AVCODEC_GET_BITS_H - -#include -#include -#include "ffmpeg_intreadwrite.h" -//#include -//#include "libavutil/bswap.h" -//#include "libavutil/common.h" -//#include "libavutil/intreadwrite.h" -//#include "libavutil/log.h" -//#include "mathops.h" - -#include "codecs.h" - -/* rockbox' optimised inline functions */ -#define bswap_16(x) swap16(x) -#define bswap_32(x) swap32(x) - -#ifdef ROCKBOX_BIG_ENDIAN -#define be2me_16(x) (x) -#define be2me_32(x) (x) -#define le2me_16(x) bswap_16(x) -#define le2me_32(x) bswap_32(x) -#else -#define be2me_16(x) bswap_16(x) -#define be2me_32(x) bswap_32(x) -#define le2me_16(x) (x) -#define le2me_32(x) (x) -#endif - -#define av_const __attribute__((const)) -#define av_always_inline inline __attribute__((always_inline)) - -/* The following is taken from mathops.h */ - -#ifndef sign_extend -static inline av_const int sign_extend(int val, unsigned bits) -{ - return (val << ((8 * sizeof(int)) - bits)) >> ((8 * sizeof(int)) - bits); -} -#endif - -#ifndef NEG_SSR32 -# define NEG_SSR32(a,s) ((( int32_t)(a))>>(32-(s))) -#endif - -#ifndef NEG_USR32 -# define NEG_USR32(a,s) (((uint32_t)(a))>>(32-(s))) -#endif - -/* these 2 are from libavutil/common.h */ - -#define FFMAX(a,b) ((a) > (b) ? (a) : (b)) -#define FFMIN(a,b) ((a) > (b) ? (b) : (a)) - -#if defined(ALT_BITSTREAM_READER_LE) && !defined(ALT_BITSTREAM_READER) -# define ALT_BITSTREAM_READER -#endif - -/* -#if !defined(LIBMPEG2_BITSTREAM_READER) && !defined(A32_BITSTREAM_READER) && !defined(ALT_BITSTREAM_READER) -# if ARCH_ARM && !HAVE_FAST_UNALIGNED -# define A32_BITSTREAM_READER -# else -*/ -# define ALT_BITSTREAM_READER -/* -//#define LIBMPEG2_BITSTREAM_READER -//#define A32_BITSTREAM_READER -# endif -#endif -*/ - -/* bit input */ -/* buffer, buffer_end and size_in_bits must be present and used by every reader */ -typedef struct GetBitContext { - const uint8_t *buffer, *buffer_end; -#ifdef ALT_BITSTREAM_READER - int index; -#elif defined LIBMPEG2_BITSTREAM_READER - uint8_t *buffer_ptr; - uint32_t cache; - int bit_count; -#elif defined A32_BITSTREAM_READER - uint32_t *buffer_ptr; - uint32_t cache0; - uint32_t cache1; - int bit_count; -#endif - int size_in_bits; -} GetBitContext; - -#define VLC_TYPE int16_t - -typedef struct VLC { - int bits; - VLC_TYPE (*table)[2]; ///< code, bits - int table_size, table_allocated; -} VLC; - -typedef struct RL_VLC_ELEM { - int16_t level; - int8_t len; - uint8_t run; -} RL_VLC_ELEM; - -/* Bitstream reader API docs: -name - arbitrary name which is used as prefix for the internal variables - -gb - getbitcontext - -OPEN_READER(name, gb) - loads gb into local variables - -CLOSE_READER(name, gb) - stores local vars in gb - -UPDATE_CACHE(name, gb) - refills the internal cache from the bitstream - after this call at least MIN_CACHE_BITS will be available, - -GET_CACHE(name, gb) - will output the contents of the internal cache, next bit is MSB of 32 or 64 bit (FIXME 64bit) - -SHOW_UBITS(name, gb, num) - will return the next num bits - -SHOW_SBITS(name, gb, num) - will return the next num bits and do sign extension - -SKIP_BITS(name, gb, num) - will skip over the next num bits - note, this is equivalent to SKIP_CACHE; SKIP_COUNTER - -SKIP_CACHE(name, gb, num) - will remove the next num bits from the cache (note SKIP_COUNTER MUST be called before UPDATE_CACHE / CLOSE_READER) - -SKIP_COUNTER(name, gb, num) - will increment the internal bit counter (see SKIP_CACHE & SKIP_BITS) - -LAST_SKIP_CACHE(name, gb, num) - will remove the next num bits from the cache if it is needed for UPDATE_CACHE otherwise it will do nothing - -LAST_SKIP_BITS(name, gb, num) - is equivalent to LAST_SKIP_CACHE; SKIP_COUNTER - -for examples see get_bits, show_bits, skip_bits, get_vlc -*/ - -#ifdef ALT_BITSTREAM_READER -# define MIN_CACHE_BITS 25 - - -/* ROCKBOX: work around "set but not used" warning */ -# define OPEN_READER(name, gb)\ - unsigned int name##_index= (gb)->index;\ - int name##_cache __attribute__((unused)) = 0;\ - -# define CLOSE_READER(name, gb)\ - (gb)->index= name##_index;\ - -# ifdef ALT_BITSTREAM_READER_LE -# define UPDATE_CACHE(name, gb)\ - name##_cache= AV_RL32( ((const uint8_t *)(gb)->buffer)+(name##_index>>3) ) >> (name##_index&0x07);\ - -# define SKIP_CACHE(name, gb, num)\ - name##_cache >>= (num); -# else -# define UPDATE_CACHE(name, gb)\ - name##_cache= AV_RB32( ((const uint8_t *)(gb)->buffer)+(name##_index>>3) ) << (name##_index&0x07);\ - -# define SKIP_CACHE(name, gb, num)\ - name##_cache <<= (num); -# endif - -// FIXME name? -# define SKIP_COUNTER(name, gb, num)\ - name##_index += (num);\ - -# define SKIP_BITS(name, gb, num)\ - {\ - SKIP_CACHE(name, gb, num)\ - SKIP_COUNTER(name, gb, num)\ - }\ - -# define LAST_SKIP_BITS(name, gb, num) SKIP_COUNTER(name, gb, num) -# define LAST_SKIP_CACHE(name, gb, num) ; - -# ifdef ALT_BITSTREAM_READER_LE -# define SHOW_UBITS(name, gb, num)\ - zero_extend(name##_cache, num) - -# define SHOW_SBITS(name, gb, num)\ - sign_extend(name##_cache, num) -# else -# define SHOW_UBITS(name, gb, num)\ - NEG_USR32(name##_cache, num) - -# define SHOW_SBITS(name, gb, num)\ - NEG_SSR32(name##_cache, num) -# endif - -# define GET_CACHE(name, gb)\ - ((uint32_t)name##_cache) - -static inline int get_bits_count(const GetBitContext *s){ - return s->index; -} - -static inline void skip_bits_long(GetBitContext *s, int n){ - s->index += n; -} - -#elif defined LIBMPEG2_BITSTREAM_READER -//libmpeg2 like reader - -# define MIN_CACHE_BITS 17 - -# define OPEN_READER(name, gb)\ - int name##_bit_count=(gb)->bit_count;\ - int name##_cache= (gb)->cache;\ - uint8_t * name##_buffer_ptr=(gb)->buffer_ptr;\ - -# define CLOSE_READER(name, gb)\ - (gb)->bit_count= name##_bit_count;\ - (gb)->cache= name##_cache;\ - (gb)->buffer_ptr= name##_buffer_ptr;\ - -# define UPDATE_CACHE(name, gb)\ - if(name##_bit_count >= 0){\ - name##_cache+= AV_RB16(name##_buffer_ptr) << name##_bit_count; \ - name##_buffer_ptr+=2;\ - name##_bit_count-= 16;\ - }\ - -# define SKIP_CACHE(name, gb, num)\ - name##_cache <<= (num);\ - -# define SKIP_COUNTER(name, gb, num)\ - name##_bit_count += (num);\ - -# define SKIP_BITS(name, gb, num)\ - {\ - SKIP_CACHE(name, gb, num)\ - SKIP_COUNTER(name, gb, num)\ - }\ - -# define LAST_SKIP_BITS(name, gb, num) SKIP_BITS(name, gb, num) -# define LAST_SKIP_CACHE(name, gb, num) SKIP_CACHE(name, gb, num) - -# define SHOW_UBITS(name, gb, num)\ - NEG_USR32(name##_cache, num) - -# define SHOW_SBITS(name, gb, num)\ - NEG_SSR32(name##_cache, num) - -# define GET_CACHE(name, gb)\ - ((uint32_t)name##_cache) - -static inline int get_bits_count(const GetBitContext *s){ - return (s->buffer_ptr - s->buffer)*8 - 16 + s->bit_count; -} - -static inline void skip_bits_long(GetBitContext *s, int n){ - OPEN_READER(re, s) - re_bit_count += n; - re_buffer_ptr += 2*(re_bit_count>>4); - re_bit_count &= 15; - re_cache = ((re_buffer_ptr[-2]<<8) + re_buffer_ptr[-1]) << (16+re_bit_count); - UPDATE_CACHE(re, s) - CLOSE_READER(re, s) -} - -#elif defined A32_BITSTREAM_READER - -# define MIN_CACHE_BITS 32 - -# define OPEN_READER(name, gb)\ - int name##_bit_count=(gb)->bit_count;\ - uint32_t name##_cache0= (gb)->cache0;\ - uint32_t name##_cache1= (gb)->cache1;\ - uint32_t * name##_buffer_ptr=(gb)->buffer_ptr;\ - -# define CLOSE_READER(name, gb)\ - (gb)->bit_count= name##_bit_count;\ - (gb)->cache0= name##_cache0;\ - (gb)->cache1= name##_cache1;\ - (gb)->buffer_ptr= name##_buffer_ptr;\ - -# define UPDATE_CACHE(name, gb)\ - if(name##_bit_count > 0){\ - const uint32_t next= av_be2ne32( *name##_buffer_ptr );\ - name##_cache0 |= NEG_USR32(next,name##_bit_count);\ - name##_cache1 |= next<buffer_ptr - s->buffer)*8 - 32 + s->bit_count; -} - -static inline void skip_bits_long(GetBitContext *s, int n){ - OPEN_READER(re, s) - re_bit_count += n; - re_buffer_ptr += re_bit_count>>5; - re_bit_count &= 31; - re_cache0 = av_be2ne32( re_buffer_ptr[-1] ) << re_bit_count; - re_cache1 = 0; - UPDATE_CACHE(re, s) - CLOSE_READER(re, s) -} - -#endif - -/** - * read mpeg1 dc style vlc (sign bit + mantisse with no MSB). - * if MSB not set it is negative - * @param n length in bits - * @author BERO - */ -static inline int get_xbits(GetBitContext *s, int n){ - register int sign; - register int32_t cache; - OPEN_READER(re, s) - UPDATE_CACHE(re, s) - cache = GET_CACHE(re,s); - sign=(~cache)>>31; - LAST_SKIP_BITS(re, s, n) - CLOSE_READER(re, s) - return (NEG_USR32(sign ^ cache, n) ^ sign) - sign; -} - -static inline int get_sbits(GetBitContext *s, int n){ - register int tmp; - OPEN_READER(re, s) - UPDATE_CACHE(re, s) - tmp= SHOW_SBITS(re, s, n); - LAST_SKIP_BITS(re, s, n) - CLOSE_READER(re, s) - return tmp; -} - -/** - * reads 1-17 bits. - * Note, the alt bitstream reader can read up to 25 bits, but the libmpeg2 reader can't - */ -static inline unsigned int get_bits(GetBitContext *s, int n){ - register int tmp; - OPEN_READER(re, s) - UPDATE_CACHE(re, s) - tmp= SHOW_UBITS(re, s, n); - LAST_SKIP_BITS(re, s, n) - CLOSE_READER(re, s) - return tmp; -} - -/** - * shows 1-17 bits. - * Note, the alt bitstream reader can read up to 25 bits, but the libmpeg2 reader can't - */ -static inline unsigned int show_bits(GetBitContext *s, int n){ - register int tmp; - OPEN_READER(re, s) - UPDATE_CACHE(re, s) - tmp= SHOW_UBITS(re, s, n); -// CLOSE_READER(re, s) - return tmp; -} - -static inline void skip_bits(GetBitContext *s, int n){ - //Note gcc seems to optimize this to s->index+=n for the ALT_READER :)) - OPEN_READER(re, s) - UPDATE_CACHE(re, s) - LAST_SKIP_BITS(re, s, n) - CLOSE_READER(re, s) -} - -static inline unsigned int get_bits1(GetBitContext *s){ -#ifdef ALT_BITSTREAM_READER - unsigned int index= s->index; - uint8_t result= s->buffer[ index>>3 ]; -#ifdef ALT_BITSTREAM_READER_LE - result>>= (index&0x07); - result&= 1; -#else - result<<= (index&0x07); - result>>= 8 - 1; -#endif - index++; - s->index= index; - - return result; -#else - return get_bits(s, 1); -#endif -} - -static inline unsigned int show_bits1(GetBitContext *s){ - return show_bits(s, 1); -} - -static inline void skip_bits1(GetBitContext *s){ - skip_bits(s, 1); -} - -/** - * reads 0-32 bits. - */ -static inline unsigned int get_bits_long(GetBitContext *s, int n){ - if(n<=MIN_CACHE_BITS) return get_bits(s, n); - else{ -#ifdef ALT_BITSTREAM_READER_LE - int ret= get_bits(s, 16); - return ret | (get_bits(s, n-16) << 16); -#else - int ret= get_bits(s, 16) << (n-16); - return ret | get_bits(s, n-16); -#endif - } -} - -/** - * reads 0-32 bits as a signed integer. - */ -static inline int get_sbits_long(GetBitContext *s, int n) { - return sign_extend(get_bits_long(s, n), n); -} - -/** - * shows 0-32 bits. - */ -static inline unsigned int show_bits_long(GetBitContext *s, int n){ - if(n<=MIN_CACHE_BITS) return show_bits(s, n); - else{ - GetBitContext gb= *s; - return get_bits_long(&gb, n); - } -} - -/* not used -static inline int check_marker(GetBitContext *s, const char *msg) -{ - int bit= get_bits1(s); - if(!bit) - av_log(NULL, AV_LOG_INFO, "Marker bit missing %s\n", msg); - - return bit; -} -*/ - -/** - * init GetBitContext. - * @param buffer bitstream buffer, must be FF_INPUT_BUFFER_PADDING_SIZE bytes larger then the actual read bits - * because some optimized bitstream readers read 32 or 64 bit at once and could read over the end - * @param bit_size the size of the buffer in bits - * - * While GetBitContext stores the buffer size, for performance reasons you are - * responsible for checking for the buffer end yourself (take advantage of the padding)! - */ -static inline void init_get_bits(GetBitContext *s, - const uint8_t *buffer, int bit_size) -{ - int buffer_size= (bit_size+7)>>3; - if(buffer_size < 0 || bit_size < 0) { - buffer_size = bit_size = 0; - buffer = NULL; - } - - s->buffer= buffer; - s->size_in_bits= bit_size; - s->buffer_end= buffer + buffer_size; -#ifdef ALT_BITSTREAM_READER - s->index=0; -#elif defined LIBMPEG2_BITSTREAM_READER - s->buffer_ptr = (uint8_t*)((intptr_t)buffer&(~1)); - s->bit_count = 16 + 8*((intptr_t)buffer&1); - skip_bits_long(s, 0); -#elif defined A32_BITSTREAM_READER - s->buffer_ptr = (uint32_t*)((intptr_t)buffer&(~3)); - s->bit_count = 32 + 8*((intptr_t)buffer&3); - skip_bits_long(s, 0); -#endif -} - -static inline void align_get_bits(GetBitContext *s) -{ - int n= (-get_bits_count(s)) & 7; - if(n) skip_bits(s, n); -} - -#define init_vlc(vlc, nb_bits, nb_codes,\ - bits, bits_wrap, bits_size,\ - codes, codes_wrap, codes_size,\ - flags)\ - init_vlc_sparse(vlc, nb_bits, nb_codes,\ - bits, bits_wrap, bits_size,\ - codes, codes_wrap, codes_size,\ - NULL, 0, 0, flags) - -int init_vlc_sparse(VLC *vlc, int nb_bits, int nb_codes, - const void *bits, int bits_wrap, int bits_size, - const void *codes, int codes_wrap, int codes_size, - const void *symbols, int symbols_wrap, int symbols_size, - int flags); -#define INIT_VLC_LE 2 -#define INIT_VLC_USE_NEW_STATIC 4 -void free_vlc(VLC *vlc); - -#define INIT_VLC_STATIC(vlc, bits, a,b,c,d,e,f,g, static_size, attr)\ -{\ - static VLC_TYPE table[static_size][2] attr;\ - (vlc)->table= table;\ - (vlc)->table_allocated= static_size;\ - init_vlc(vlc, bits, a,b,c,d,e,f,g, INIT_VLC_USE_NEW_STATIC);\ -} - - -/** - * - * If the vlc code is invalid and max_depth=1, then no bits will be removed. - * If the vlc code is invalid and max_depth>1, then the number of bits removed - * is undefined. - */ -#define GET_VLC(code, name, gb, table, bits, max_depth)\ -{\ - int n, nb_bits;\ - unsigned int index;\ -\ - index= SHOW_UBITS(name, gb, bits);\ - code = table[index][0];\ - n = table[index][1];\ -\ - if(max_depth > 1 && n < 0){\ - LAST_SKIP_BITS(name, gb, bits)\ - UPDATE_CACHE(name, gb)\ -\ - nb_bits = -n;\ -\ - index= SHOW_UBITS(name, gb, nb_bits) + code;\ - code = table[index][0];\ - n = table[index][1];\ - if(max_depth > 2 && n < 0){\ - LAST_SKIP_BITS(name, gb, nb_bits)\ - UPDATE_CACHE(name, gb)\ -\ - nb_bits = -n;\ -\ - index= SHOW_UBITS(name, gb, nb_bits) + code;\ - code = table[index][0];\ - n = table[index][1];\ - }\ - }\ - SKIP_BITS(name, gb, n)\ -} - -#define GET_RL_VLC(level, run, name, gb, table, bits, max_depth, need_update)\ -{\ - int n, nb_bits;\ - unsigned int index;\ -\ - index= SHOW_UBITS(name, gb, bits);\ - level = table[index].level;\ - n = table[index].len;\ -\ - if(max_depth > 1 && n < 0){\ - SKIP_BITS(name, gb, bits)\ - if(need_update){\ - UPDATE_CACHE(name, gb)\ - }\ -\ - nb_bits = -n;\ -\ - index= SHOW_UBITS(name, gb, nb_bits) + level;\ - level = table[index].level;\ - n = table[index].len;\ - }\ - run= table[index].run;\ - SKIP_BITS(name, gb, n)\ -} - - -/** - * parses a vlc code, faster then get_vlc() - * @param bits is the number of bits which will be read at once, must be - * identical to nb_bits in init_vlc() - * @param max_depth is the number of times bits bits must be read to completely - * read the longest vlc code - * = (max_vlc_length + bits - 1) / bits - */ -static av_always_inline int get_vlc2(GetBitContext *s, VLC_TYPE (*table)[2], - int bits, int max_depth) -{ - int code; - - OPEN_READER(re, s) - UPDATE_CACHE(re, s) - - GET_VLC(code, re, s, table, bits, max_depth) - - CLOSE_READER(re, s) - return code; -} - -//#define TRACE - -#ifdef TRACE -static inline void print_bin(int bits, int n){ - int i; - - for(i=n-1; i>=0; i--){ - av_log(NULL, AV_LOG_DEBUG, "%d", (bits>>i)&1); - } - for(i=n; i<24; i++) - av_log(NULL, AV_LOG_DEBUG, " "); -} - -static inline int get_bits_trace(GetBitContext *s, int n, char *file, const char *func, int line){ - int r= get_bits(s, n); - - print_bin(r, n); - av_log(NULL, AV_LOG_DEBUG, "%5d %2d %3d bit @%5d in %s %s:%d\n", r, n, r, get_bits_count(s)-n, file, func, line); - return r; -} -static inline int get_vlc_trace(GetBitContext *s, VLC_TYPE (*table)[2], int bits, int max_depth, char *file, const char *func, int line){ - int show= show_bits(s, 24); - int pos= get_bits_count(s); - int r= get_vlc2(s, table, bits, max_depth); - int len= get_bits_count(s) - pos; - int bits2= show>>(24-len); - - print_bin(bits2, len); - - av_log(NULL, AV_LOG_DEBUG, "%5d %2d %3d vlc @%5d in %s %s:%d\n", bits2, len, r, pos, file, func, line); - return r; -} -static inline int get_xbits_trace(GetBitContext *s, int n, char *file, const char *func, int line){ - int show= show_bits(s, n); - int r= get_xbits(s, n); - - print_bin(show, n); - av_log(NULL, AV_LOG_DEBUG, "%5d %2d %3d xbt @%5d in %s %s:%d\n", show, n, r, get_bits_count(s)-n, file, func, line); - return r; -} - -#define get_bits(s, n) get_bits_trace(s, n, __FILE__, __PRETTY_FUNCTION__, __LINE__) -#define get_bits1(s) get_bits_trace(s, 1, __FILE__, __PRETTY_FUNCTION__, __LINE__) -#define get_xbits(s, n) get_xbits_trace(s, n, __FILE__, __PRETTY_FUNCTION__, __LINE__) -#define get_vlc(s, vlc) get_vlc_trace(s, (vlc)->table, (vlc)->bits, 3, __FILE__, __PRETTY_FUNCTION__, __LINE__) -#define get_vlc2(s, tab, bits, max) get_vlc_trace(s, tab, bits, max, __FILE__, __PRETTY_FUNCTION__, __LINE__) - -#define tprintf(p, ...) av_log(p, AV_LOG_DEBUG, __VA_ARGS__) - -#else //TRACE -#define tprintf(p, ...) {} -#endif - -static inline int decode012(GetBitContext *gb){ - int n; - n = get_bits1(gb); - if (n == 0) - return 0; - else - return get_bits1(gb) + 1; -} - -static inline int decode210(GetBitContext *gb){ - if (get_bits1(gb)) - return 0; - else - return 2 - get_bits1(gb); -} - -static inline int get_bits_left(GetBitContext *gb) -{ - return gb->size_in_bits - get_bits_count(gb); -} - -#endif /* AVCODEC_GET_BITS_H */ diff --git a/apps/codecs/lib/ffmpeg_intreadwrite.h b/apps/codecs/lib/ffmpeg_intreadwrite.h deleted file mode 100644 index 24f03292e8..0000000000 --- a/apps/codecs/lib/ffmpeg_intreadwrite.h +++ /dev/null @@ -1,484 +0,0 @@ -/* - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef AVUTIL_INTREADWRITE_H -#define AVUTIL_INTREADWRITE_H - -#include -/* - * Arch-specific headers can provide any combination of - * AV_[RW][BLN](16|24|32|64) and AV_(COPY|SWAP|ZERO)(64|128) macros. - * Preprocessor symbols must be defined, even if these are implemented - * as inline functions. - */ - -/* - * Map AV_RNXX <-> AV_R[BL]XX for all variants provided by per-arch headers. - */ -#define HAVE_BIGENDIAN 0 -#if HAVE_BIGENDIAN - -# if defined(AV_RN16) && !defined(AV_RB16) -# define AV_RB16(p) AV_RN16(p) -# elif !defined(AV_RN16) && defined(AV_RB16) -# define AV_RN16(p) AV_RB16(p) -# endif - -# if defined(AV_WN16) && !defined(AV_WB16) -# define AV_WB16(p, v) AV_WN16(p, v) -# elif !defined(AV_WN16) && defined(AV_WB16) -# define AV_WN16(p, v) AV_WB16(p, v) -# endif - -# if defined(AV_RN24) && !defined(AV_RB24) -# define AV_RB24(p) AV_RN24(p) -# elif !defined(AV_RN24) && defined(AV_RB24) -# define AV_RN24(p) AV_RB24(p) -# endif - -# if defined(AV_WN24) && !defined(AV_WB24) -# define AV_WB24(p, v) AV_WN24(p, v) -# elif !defined(AV_WN24) && defined(AV_WB24) -# define AV_WN24(p, v) AV_WB24(p, v) -# endif - -# if defined(AV_RN32) && !defined(AV_RB32) -# define AV_RB32(p) AV_RN32(p) -# elif !defined(AV_RN32) && defined(AV_RB32) -# define AV_RN32(p) AV_RB32(p) -# endif - -# if defined(AV_WN32) && !defined(AV_WB32) -# define AV_WB32(p, v) AV_WN32(p, v) -# elif !defined(AV_WN32) && defined(AV_WB32) -# define AV_WN32(p, v) AV_WB32(p, v) -# endif - -# if defined(AV_RN64) && !defined(AV_RB64) -# define AV_RB64(p) AV_RN64(p) -# elif !defined(AV_RN64) && defined(AV_RB64) -# define AV_RN64(p) AV_RB64(p) -# endif - -# if defined(AV_WN64) && !defined(AV_WB64) -# define AV_WB64(p, v) AV_WN64(p, v) -# elif !defined(AV_WN64) && defined(AV_WB64) -# define AV_WN64(p, v) AV_WB64(p, v) -# endif - -#else /* HAVE_BIGENDIAN */ - -# if defined(AV_RN16) && !defined(AV_RL16) -# define AV_RL16(p) AV_RN16(p) -# elif !defined(AV_RN16) && defined(AV_RL16) -# define AV_RN16(p) AV_RL16(p) -# endif - -# if defined(AV_WN16) && !defined(AV_WL16) -# define AV_WL16(p, v) AV_WN16(p, v) -# elif !defined(AV_WN16) && defined(AV_WL16) -# define AV_WN16(p, v) AV_WL16(p, v) -# endif - -# if defined(AV_RN24) && !defined(AV_RL24) -# define AV_RL24(p) AV_RN24(p) -# elif !defined(AV_RN24) && defined(AV_RL24) -# define AV_RN24(p) AV_RL24(p) -# endif - -# if defined(AV_WN24) && !defined(AV_WL24) -# define AV_WL24(p, v) AV_WN24(p, v) -# elif !defined(AV_WN24) && defined(AV_WL24) -# define AV_WN24(p, v) AV_WL24(p, v) -# endif - -# if defined(AV_RN32) && !defined(AV_RL32) -# define AV_RL32(p) AV_RN32(p) -# elif !defined(AV_RN32) && defined(AV_RL32) -# define AV_RN32(p) AV_RL32(p) -# endif - -# if defined(AV_WN32) && !defined(AV_WL32) -# define AV_WL32(p, v) AV_WN32(p, v) -# elif !defined(AV_WN32) && defined(AV_WL32) -# define AV_WN32(p, v) AV_WL32(p, v) -# endif - -# if defined(AV_RN64) && !defined(AV_RL64) -# define AV_RL64(p) AV_RN64(p) -# elif !defined(AV_RN64) && defined(AV_RL64) -# define AV_RN64(p) AV_RL64(p) -# endif - -# if defined(AV_WN64) && !defined(AV_WL64) -# define AV_WL64(p, v) AV_WN64(p, v) -# elif !defined(AV_WN64) && defined(AV_WL64) -# define AV_WN64(p, v) AV_WL64(p, v) -# endif - -#endif /* !HAVE_BIGENDIAN */ - -#define HAVE_ATTRIBUTE_PACKED 0 -#define HAVE_FAST_UNALIGNED 0 -/* - * Define AV_[RW]N helper macros to simplify definitions not provided - * by per-arch headers. - */ - -#if HAVE_ATTRIBUTE_PACKED - -union unaligned_64 { uint64_t l; } __attribute__((packed)) av_alias; -union unaligned_32 { uint32_t l; } __attribute__((packed)) av_alias; -union unaligned_16 { uint16_t l; } __attribute__((packed)) av_alias; - -# define AV_RN(s, p) (((const union unaligned_##s *) (p))->l) -# define AV_WN(s, p, v) ((((union unaligned_##s *) (p))->l) = (v)) - -#elif defined(__DECC) - -# define AV_RN(s, p) (*((const __unaligned uint##s##_t*)(p))) -# define AV_WN(s, p, v) (*((__unaligned uint##s##_t*)(p)) = (v)) - -#elif HAVE_FAST_UNALIGNED - -# define AV_RN(s, p) (((const av_alias##s*)(p))->u##s) -# define AV_WN(s, p, v) (((av_alias##s*)(p))->u##s = (v)) - -#else - -#ifndef AV_RB16 -# define AV_RB16(x) \ - ((((const uint8_t*)(x))[0] << 8) | \ - ((const uint8_t*)(x))[1]) -#endif -#ifndef AV_WB16 -# define AV_WB16(p, d) do { \ - ((uint8_t*)(p))[1] = (d); \ - ((uint8_t*)(p))[0] = (d)>>8; \ - } while(0) -#endif - -#ifndef AV_RL16 -# define AV_RL16(x) \ - ((((const uint8_t*)(x))[1] << 8) | \ - ((const uint8_t*)(x))[0]) -#endif -#ifndef AV_WL16 -# define AV_WL16(p, d) do { \ - ((uint8_t*)(p))[0] = (d); \ - ((uint8_t*)(p))[1] = (d)>>8; \ - } while(0) -#endif - -#ifndef AV_RB32 -/* Coldfire and ARMv6 and above support unaligned long reads */ -#if defined CPU_COLDFIRE || (defined CPU_ARM && ARM_ARCH >= 6) -#define AV_RB32(x) (htobe32(*(const uint32_t*)(x))) -#else -# define AV_RB32(x) \ - ((((const uint8_t*)(x))[0] << 24) | \ - (((const uint8_t*)(x))[1] << 16) | \ - (((const uint8_t*)(x))[2] << 8) | \ - ((const uint8_t*)(x))[3]) -#endif -#endif -#ifndef AV_WB32 -# define AV_WB32(p, d) do { \ - ((uint8_t*)(p))[3] = (d); \ - ((uint8_t*)(p))[2] = (d)>>8; \ - ((uint8_t*)(p))[1] = (d)>>16; \ - ((uint8_t*)(p))[0] = (d)>>24; \ - } while(0) -#endif - -#ifndef AV_RL32 -# define AV_RL32(x) \ - ((((const uint8_t*)(x))[3] << 24) | \ - (((const uint8_t*)(x))[2] << 16) | \ - (((const uint8_t*)(x))[1] << 8) | \ - ((const uint8_t*)(x))[0]) -#endif -#ifndef AV_WL32 -# define AV_WL32(p, d) do { \ - ((uint8_t*)(p))[0] = (d); \ - ((uint8_t*)(p))[1] = (d)>>8; \ - ((uint8_t*)(p))[2] = (d)>>16; \ - ((uint8_t*)(p))[3] = (d)>>24; \ - } while(0) -#endif - -#ifndef AV_RB64 -# define AV_RB64(x) \ - (((uint64_t)((const uint8_t*)(x))[0] << 56) | \ - ((uint64_t)((const uint8_t*)(x))[1] << 48) | \ - ((uint64_t)((const uint8_t*)(x))[2] << 40) | \ - ((uint64_t)((const uint8_t*)(x))[3] << 32) | \ - ((uint64_t)((const uint8_t*)(x))[4] << 24) | \ - ((uint64_t)((const uint8_t*)(x))[5] << 16) | \ - ((uint64_t)((const uint8_t*)(x))[6] << 8) | \ - (uint64_t)((const uint8_t*)(x))[7]) -#endif -#ifndef AV_WB64 -# define AV_WB64(p, d) do { \ - ((uint8_t*)(p))[7] = (d); \ - ((uint8_t*)(p))[6] = (d)>>8; \ - ((uint8_t*)(p))[5] = (d)>>16; \ - ((uint8_t*)(p))[4] = (d)>>24; \ - ((uint8_t*)(p))[3] = (d)>>32; \ - ((uint8_t*)(p))[2] = (d)>>40; \ - ((uint8_t*)(p))[1] = (d)>>48; \ - ((uint8_t*)(p))[0] = (d)>>56; \ - } while(0) -#endif - -#ifndef AV_RL64 -# define AV_RL64(x) \ - (((uint64_t)((const uint8_t*)(x))[7] << 56) | \ - ((uint64_t)((const uint8_t*)(x))[6] << 48) | \ - ((uint64_t)((const uint8_t*)(x))[5] << 40) | \ - ((uint64_t)((const uint8_t*)(x))[4] << 32) | \ - ((uint64_t)((const uint8_t*)(x))[3] << 24) | \ - ((uint64_t)((const uint8_t*)(x))[2] << 16) | \ - ((uint64_t)((const uint8_t*)(x))[1] << 8) | \ - (uint64_t)((const uint8_t*)(x))[0]) -#endif -#ifndef AV_WL64 -# define AV_WL64(p, d) do { \ - ((uint8_t*)(p))[0] = (d); \ - ((uint8_t*)(p))[1] = (d)>>8; \ - ((uint8_t*)(p))[2] = (d)>>16; \ - ((uint8_t*)(p))[3] = (d)>>24; \ - ((uint8_t*)(p))[4] = (d)>>32; \ - ((uint8_t*)(p))[5] = (d)>>40; \ - ((uint8_t*)(p))[6] = (d)>>48; \ - ((uint8_t*)(p))[7] = (d)>>56; \ - } while(0) -#endif - -#if HAVE_BIGENDIAN -# define AV_RN(s, p) AV_RB##s(p) -# define AV_WN(s, p, v) AV_WB##s(p, v) -#else -# define AV_RN(s, p) AV_RL##s(p) -# define AV_WN(s, p, v) AV_WL##s(p, v) -#endif - -#endif /* HAVE_FAST_UNALIGNED */ - -#ifndef AV_RN16 -# define AV_RN16(p) AV_RN(16, p) -#endif - -#ifndef AV_RN32 -# define AV_RN32(p) AV_RN(32, p) -#endif - -#ifndef AV_RN64 -# define AV_RN64(p) AV_RN(64, p) -#endif - -#ifndef AV_WN16 -# define AV_WN16(p, v) AV_WN(16, p, v) -#endif - -#ifndef AV_WN32 -# define AV_WN32(p, v) AV_WN(32, p, v) -#endif - -#ifndef AV_WN64 -# define AV_WN64(p, v) AV_WN(64, p, v) -#endif - -#if HAVE_BIGENDIAN -# define AV_RB(s, p) AV_RN##s(p) -# define AV_WB(s, p, v) AV_WN##s(p, v) -# define AV_RL(s, p) bswap_##s(AV_RN##s(p)) -# define AV_WL(s, p, v) AV_WN##s(p, bswap_##s(v)) -#else -# define AV_RB(s, p) bswap_##s(AV_RN##s(p)) -# define AV_WB(s, p, v) AV_WN##s(p, bswap_##s(v)) -# define AV_RL(s, p) AV_RN##s(p) -# define AV_WL(s, p, v) AV_WN##s(p, v) -#endif - -#define AV_RB8(x) (((const uint8_t*)(x))[0]) -#define AV_WB8(p, d) do { ((uint8_t*)(p))[0] = (d); } while(0) - -#define AV_RL8(x) AV_RB8(x) -#define AV_WL8(p, d) AV_WB8(p, d) - -#ifndef AV_RB16 -# define AV_RB16(p) AV_RB(16, p) -#endif -#ifndef AV_WB16 -# define AV_WB16(p, v) AV_WB(16, p, v) -#endif - -#ifndef AV_RL16 -# define AV_RL16(p) AV_RL(16, p) -#endif -#ifndef AV_WL16 -# define AV_WL16(p, v) AV_WL(16, p, v) -#endif - -#ifndef AV_RB32 -# define AV_RB32(p) AV_RB(32, p) -#endif -#ifndef AV_WB32 -# define AV_WB32(p, v) AV_WB(32, p, v) -#endif - -#ifndef AV_RL32 -# define AV_RL32(p) AV_RL(32, p) -#endif -#ifndef AV_WL32 -# define AV_WL32(p, v) AV_WL(32, p, v) -#endif - -#ifndef AV_RB64 -# define AV_RB64(p) AV_RB(64, p) -#endif -#ifndef AV_WB64 -# define AV_WB64(p, v) AV_WB(64, p, v) -#endif - -#ifndef AV_RL64 -# define AV_RL64(p) AV_RL(64, p) -#endif -#ifndef AV_WL64 -# define AV_WL64(p, v) AV_WL(64, p, v) -#endif - -#ifndef AV_RB24 -# define AV_RB24(x) \ - ((((const uint8_t*)(x))[0] << 16) | \ - (((const uint8_t*)(x))[1] << 8) | \ - ((const uint8_t*)(x))[2]) -#endif -#ifndef AV_WB24 -# define AV_WB24(p, d) do { \ - ((uint8_t*)(p))[2] = (d); \ - ((uint8_t*)(p))[1] = (d)>>8; \ - ((uint8_t*)(p))[0] = (d)>>16; \ - } while(0) -#endif - -#ifndef AV_RL24 -# define AV_RL24(x) \ - ((((const uint8_t*)(x))[2] << 16) | \ - (((const uint8_t*)(x))[1] << 8) | \ - ((const uint8_t*)(x))[0]) -#endif -#ifndef AV_WL24 -# define AV_WL24(p, d) do { \ - ((uint8_t*)(p))[0] = (d); \ - ((uint8_t*)(p))[1] = (d)>>8; \ - ((uint8_t*)(p))[2] = (d)>>16; \ - } while(0) -#endif - -/* - * The AV_[RW]NA macros access naturally aligned data - * in a type-safe way. - */ - -#define AV_RNA(s, p) (((const av_alias##s*)(p))->u##s) -#define AV_WNA(s, p, v) (((av_alias##s*)(p))->u##s = (v)) - -#ifndef AV_RN16A -# define AV_RN16A(p) AV_RNA(16, p) -#endif - -#ifndef AV_RN32A -# define AV_RN32A(p) AV_RNA(32, p) -#endif - -#ifndef AV_RN64A -# define AV_RN64A(p) AV_RNA(64, p) -#endif - -#ifndef AV_WN16A -# define AV_WN16A(p, v) AV_WNA(16, p, v) -#endif - -#ifndef AV_WN32A -# define AV_WN32A(p, v) AV_WNA(32, p, v) -#endif - -#ifndef AV_WN64A -# define AV_WN64A(p, v) AV_WNA(64, p, v) -#endif - -/* Parameters for AV_COPY*, AV_SWAP*, AV_ZERO* must be - * naturally aligned. They may be implemented using MMX, - * so emms_c() must be called before using any float code - * afterwards. - */ - -#define AV_COPY(n, d, s) \ - (((av_alias##n*)(d))->u##n = ((const av_alias##n*)(s))->u##n) - -#ifndef AV_COPY16 -# define AV_COPY16(d, s) AV_COPY(16, d, s) -#endif - -#ifndef AV_COPY32 -# define AV_COPY32(d, s) AV_COPY(32, d, s) -#endif - -#ifndef AV_COPY64 -# define AV_COPY64(d, s) AV_COPY(64, d, s) -#endif - -#ifndef AV_COPY128 -# define AV_COPY128(d, s) \ - do { \ - AV_COPY64(d, s); \ - AV_COPY64((char*)(d)+8, (char*)(s)+8); \ - } while(0) -#endif - -#define AV_SWAP(n, a, b) FFSWAP(av_alias##n, *(av_alias##n*)(a), *(av_alias##n*)(b)) - -#ifndef AV_SWAP64 -# define AV_SWAP64(a, b) AV_SWAP(64, a, b) -#endif - -#define AV_ZERO(n, d) (((av_alias##n*)(d))->u##n = 0) - -#ifndef AV_ZERO16 -# define AV_ZERO16(d) AV_ZERO(16, d) -#endif - -#ifndef AV_ZERO32 -# define AV_ZERO32(d) AV_ZERO(32, d) -#endif - -#ifndef AV_ZERO64 -# define AV_ZERO64(d) AV_ZERO(64, d) -#endif - -#ifndef AV_ZERO128 -# define AV_ZERO128(d) \ - do { \ - AV_ZERO64(d); \ - AV_ZERO64((char*)(d)+8); \ - } while(0) -#endif - -#endif /* AVUTIL_INTREADWRITE_H */ diff --git a/apps/codecs/lib/ffmpeg_put_bits.h b/apps/codecs/lib/ffmpeg_put_bits.h deleted file mode 100644 index 38db55fe18..0000000000 --- a/apps/codecs/lib/ffmpeg_put_bits.h +++ /dev/null @@ -1,323 +0,0 @@ -/* - * copyright (c) 2004 Michael Niedermayer - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/** - * @file libavcodec/put_bits.h - * bitstream writer API - */ - -#ifndef AVCODEC_PUT_BITS_H -#define AVCODEC_PUT_BITS_H - -#include -#include -#include "ffmpeg_bswap.h" -#include "ffmpeg_intreadwrite.h" - -#define av_log(...) -#define HAVE_FAST_UNALIGNED 0 - -/* buf and buf_end must be present and used by every alternative writer. */ -typedef struct PutBitContext { -#ifdef ALT_BITSTREAM_WRITER - uint8_t *buf, *buf_end; - int index; -#else - uint32_t bit_buf; - int bit_left; - uint8_t *buf, *buf_ptr, *buf_end; -#endif - int size_in_bits; -} PutBitContext; - -/** - * Initializes the PutBitContext s. - * - * @param buffer the buffer where to put bits - * @param buffer_size the size in bytes of buffer - */ -static inline void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size) -{ - if(buffer_size < 0) { - buffer_size = 0; - buffer = NULL; - } - - s->size_in_bits= 8*buffer_size; - s->buf = buffer; - s->buf_end = s->buf + buffer_size; -#ifdef ALT_BITSTREAM_WRITER - s->index=0; - ((uint32_t*)(s->buf))[0]=0; -// memset(buffer, 0, buffer_size); -#else - s->buf_ptr = s->buf; - s->bit_left=32; - s->bit_buf=0; -#endif -} - -/** - * Returns the total number of bits written to the bitstream. - */ -static inline int put_bits_count(PutBitContext *s) -{ -#ifdef ALT_BITSTREAM_WRITER - return s->index; -#else - return (s->buf_ptr - s->buf) * 8 + 32 - s->bit_left; -#endif -} - -/** - * Pads the end of the output stream with zeros. - */ -static inline void flush_put_bits(PutBitContext *s) -{ -#ifdef ALT_BITSTREAM_WRITER - align_put_bits(s); -#else -#ifndef BITSTREAM_WRITER_LE - s->bit_buf<<= s->bit_left; -#endif - while (s->bit_left < 32) { - /* XXX: should test end of buffer */ -#ifdef BITSTREAM_WRITER_LE - *s->buf_ptr++=s->bit_buf; - s->bit_buf>>=8; -#else - *s->buf_ptr++=s->bit_buf >> 24; - s->bit_buf<<=8; -#endif - s->bit_left+=8; - } - s->bit_left=32; - s->bit_buf=0; -#endif -} - -#if defined(ALT_BITSTREAM_WRITER) || defined(BITSTREAM_WRITER_LE) -#define align_put_bits align_put_bits_unsupported_here -#define ff_put_string ff_put_string_unsupported_here -#define ff_copy_bits ff_copy_bits_unsupported_here -#else -/** - * Pads the bitstream with zeros up to the next byte boundary. - */ -void align_put_bits(PutBitContext *s); - -/** - * Puts the string string in the bitstream. - * - * @param terminate_string 0-terminates the written string if value is 1 - */ -void ff_put_string(PutBitContext *pb, const char *string, int terminate_string); - -/** - * Copies the content of src to the bitstream. - * - * @param length the number of bits of src to copy - */ -void ff_copy_bits(PutBitContext *pb, const uint8_t *src, int length); -#endif - -/** - * Writes up to 31 bits into a bitstream. - * Use put_bits32 to write 32 bits. - */ -static inline void put_bits(PutBitContext *s, int n, unsigned int value) -#ifndef ALT_BITSTREAM_WRITER -{ - unsigned int bit_buf; - int bit_left; - - // printf("put_bits=%d %x\n", n, value); - //assert(n <= 31 && value < (1U << n)); - - bit_buf = s->bit_buf; - bit_left = s->bit_left; - - // printf("n=%d value=%x cnt=%d buf=%x\n", n, value, bit_cnt, bit_buf); - /* XXX: optimize */ -#ifdef BITSTREAM_WRITER_LE - bit_buf |= value << (32 - bit_left); - if (n >= bit_left) { -#if !HAVE_FAST_UNALIGNED - if (3 & (intptr_t) s->buf_ptr) { - AV_WL32(s->buf_ptr, bit_buf); - } else -#endif - *(uint32_t *)s->buf_ptr = le2me_32(bit_buf); - s->buf_ptr+=4; - bit_buf = (bit_left==32)?0:value >> bit_left; - bit_left+=32; - } - bit_left-=n; -#else - if (n < bit_left) { - bit_buf = (bit_buf<> (n - bit_left); -#if !HAVE_FAST_UNALIGNED - if (3 & (intptr_t) s->buf_ptr) { - AV_WB32(s->buf_ptr, bit_buf); - } else -#endif - *(uint32_t *)s->buf_ptr = be2me_32(bit_buf); - //printf("bitbuf = %08x\n", bit_buf); - s->buf_ptr+=4; - bit_left+=32 - n; - bit_buf = value; - } -#endif - - s->bit_buf = bit_buf; - s->bit_left = bit_left; -} -#else /* ALT_BITSTREAM_WRITER defined */ -{ -# ifdef ALIGNED_BITSTREAM_WRITER -# if ARCH_X86 - __asm__ volatile( - "movl %0, %%ecx \n\t" - "xorl %%eax, %%eax \n\t" - "shrdl %%cl, %1, %%eax \n\t" - "shrl %%cl, %1 \n\t" - "movl %0, %%ecx \n\t" - "shrl $3, %%ecx \n\t" - "andl $0xFFFFFFFC, %%ecx \n\t" - "bswapl %1 \n\t" - "orl %1, (%2, %%ecx) \n\t" - "bswapl %%eax \n\t" - "addl %3, %0 \n\t" - "movl %%eax, 4(%2, %%ecx) \n\t" - : "=&r" (s->index), "=&r" (value) - : "r" (s->buf), "r" (n), "0" (s->index), "1" (value<<(-n)) - : "%eax", "%ecx" - ); -# else - int index= s->index; - uint32_t *ptr= ((uint32_t *)s->buf)+(index>>5); - - value<<= 32-n; - - ptr[0] |= be2me_32(value>>(index&31)); - ptr[1] = be2me_32(value<<(32-(index&31))); -//if(n>24) printf("%d %d\n", n, value); - index+= n; - s->index= index; -# endif -# else //ALIGNED_BITSTREAM_WRITER -# if ARCH_X86 - __asm__ volatile( - "movl $7, %%ecx \n\t" - "andl %0, %%ecx \n\t" - "addl %3, %%ecx \n\t" - "negl %%ecx \n\t" - "shll %%cl, %1 \n\t" - "bswapl %1 \n\t" - "movl %0, %%ecx \n\t" - "shrl $3, %%ecx \n\t" - "orl %1, (%%ecx, %2) \n\t" - "addl %3, %0 \n\t" - "movl $0, 4(%%ecx, %2) \n\t" - : "=&r" (s->index), "=&r" (value) - : "r" (s->buf), "r" (n), "0" (s->index), "1" (value) - : "%ecx" - ); -# else - int index= s->index; - uint32_t *ptr= (uint32_t*)(((uint8_t *)s->buf)+(index>>3)); - - ptr[0] |= be2me_32(value<<(32-n-(index&7) )); - ptr[1] = 0; -//if(n>24) printf("%d %d\n", n, value); - index+= n; - s->index= index; -# endif -# endif //!ALIGNED_BITSTREAM_WRITER -} -#endif - -static inline void put_sbits(PutBitContext *pb, int n, int32_t value) -{ - //assert(n >= 0 && n <= 31); - - put_bits(pb, n, value & ((1<buf + (s->index>>3); -#else - return s->buf_ptr; -#endif -} - -/** - * Skips the given number of bytes. - * PutBitContext must be flushed & aligned to a byte boundary before calling this. - */ -static inline void skip_put_bytes(PutBitContext *s, int n) -{ - //assert((put_bits_count(s)&7)==0); -#ifdef ALT_BITSTREAM_WRITER - FIXME may need some cleaning of the buffer - s->index += n<<3; -#else - //assert(s->bit_left==32); - s->buf_ptr += n; -#endif -} - -/** - * Skips the given number of bits. - * Must only be used if the actual values in the bitstream do not matter. - * If n is 0 the behavior is undefined. - */ -static inline void skip_put_bits(PutBitContext *s, int n) -{ -#ifdef ALT_BITSTREAM_WRITER - s->index += n; -#else - s->bit_left -= n; - s->buf_ptr-= 4*(s->bit_left>>5); - s->bit_left &= 31; -#endif -} - -/** - * Changes the end of the buffer. - * - * @param size the new size in bytes of the buffer where to put bits - */ -static inline void set_put_bits_buffer_size(PutBitContext *s, int size) -{ - s->buf_end= s->buf + size; -} - -#endif /* AVCODEC_PUT_BITS_H */ diff --git a/apps/codecs/lib/fft-ffmpeg.c b/apps/codecs/lib/fft-ffmpeg.c deleted file mode 100644 index 807f606038..0000000000 --- a/apps/codecs/lib/fft-ffmpeg.c +++ /dev/null @@ -1,473 +0,0 @@ -/* - * FFT/IFFT transforms converted to integer precision - * Copyright (c) 2010 Dave Hooper, Mohamed Tarek, Michael Giacomelli - * Copyright (c) 2008 Loren Merritt - * Copyright (c) 2002 Fabrice Bellard - * Partly based on libdjbfft by D. J. Bernstein - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/** - * @file libavcodec/fft.c - * FFT/IFFT transforms. - */ - - -#ifdef CPU_ARM -// we definitely want CONFIG_SMALL undefined for ipod -// so we get the inlined version of fft16 (which is measurably faster) -#undef CONFIG_SMALL -#else -#undef CONFIG_SMALL -#endif - -#include "fft.h" -#include -#include -#include -#include -#include -#include - -#include "codeclib_misc.h" -#include "mdct_lookup.h" - -/* constants for fft_16 (same constants as in mdct_arm.S ... ) */ -#define cPI1_8 (0x7641af3d) /* cos(pi/8) s.31 */ -#define cPI2_8 (0x5a82799a) /* cos(2pi/8) = 1/sqrt(2) s.31 */ -#define cPI3_8 (0x30fbc54d) /* cos(3pi/8) s.31 */ - -/* asm-optimised functions and/or macros */ -#include "fft-ffmpeg_arm.h" -#include "fft-ffmpeg_cf.h" - -#ifndef ICODE_ATTR_TREMOR_MDCT -#define ICODE_ATTR_TREMOR_MDCT ICODE_ATTR -#endif - -#if 0 -static int split_radix_permutation(int i, int n, int inverse) -{ - int m; - if(n <= 2) return i&1; - m = n >> 1; - if(!(i&m)) return split_radix_permutation(i, m, inverse)*2; - m >>= 1; - if(inverse == !(i&m)) return split_radix_permutation(i, m, inverse)*4 + 1; - else return split_radix_permutation(i, m, inverse)*4 - 1; -} - -static void ff_fft_permute_c(FFTContext *s, FFTComplex *z) -{ - int j, k, np; - FFTComplex tmp; - //const uint16_t *revtab = s->revtab; - np = 1 << s->nbits; - - const int revtab_shift = (12 - s->nbits); - - /* reverse */ - for(j=0;j>revtab_shift; - if (k < j) { - tmp = z[k]; - z[k] = z[j]; - z[j] = tmp; - } - } -} -#endif - -#define BF(x,y,a,b) {\ - x = a - b;\ - y = a + b;\ -} - -#define BF_REV(x,y,a,b) {\ - x = a + b;\ - y = a - b;\ -} - -#ifndef FFT_FFMPEG_INCL_OPTIMISED_BUTTERFLIES -#define BUTTERFLIES(a0,a1,a2,a3) {\ - {\ - FFTSample temp1,temp2;\ - BF(temp1, temp2, t5, t1);\ - BF(a2.re, a0.re, a0.re, temp2);\ - BF(a3.im, a1.im, a1.im, temp1);\ - }\ - {\ - FFTSample temp1,temp2;\ - BF(temp1, temp2, t2, t6);\ - BF(a3.re, a1.re, a1.re, temp1);\ - BF(a2.im, a0.im, a0.im, temp2);\ - }\ -} - -// force loading all the inputs before storing any. -// this is slightly slower for small data, but avoids store->load aliasing -// for addresses separated by large powers of 2. -#define BUTTERFLIES_BIG(a0,a1,a2,a3) {\ - FFTSample r0=a0.re, i0=a0.im, r1=a1.re, i1=a1.im;\ - {\ - FFTSample temp1, temp2;\ - BF(temp1, temp2, t5, t1);\ - BF(a2.re, a0.re, r0, temp2);\ - BF(a3.im, a1.im, i1, temp1);\ - }\ - {\ - FFTSample temp1, temp2;\ - BF(temp1, temp2, t2, t6);\ - BF(a3.re, a1.re, r1, temp1);\ - BF(a2.im, a0.im, i0, temp2);\ - }\ -} -#endif - -/* - see conjugate pair description in - http://www.fftw.org/newsplit.pdf - - a0 = z[k] - a1 = z[k+N/4] - a2 = z[k+2N/4] - a3 = z[k+3N/4] - - result: - y[k] = z[k]+w(z[k+2N/4])+w'(z[k+3N/4]) - y[k+N/4] = z[k+N/4]-iw(z[k+2N/4])+iw'(z[k+3N/4]) - y[k+2N/4] = z[k]-w(z[k+2N/4])-w'(z[k+3N/4]) - y[k+3N/4] = z[k+N/4]+iw(z[k+2N/4])-iw'(z[k+3N/4]) - - i.e. - - a0 = a0 + (w.a2 + w'.a3) - a1 = a1 - i(w.a2 - w'.a3) - a2 = a0 - (w.a2 + w'.a3) - a3 = a1 + i(w.a2 - w'.a3) - - note re(w') = re(w) and im(w') = -im(w) - - so therefore - - re(a0) = re(a0) + re(w.a2) + re(w.a3) - im(a0) = im(a0) + im(w.a2) - im(w.a3) etc - - and remember also that - Re([s+it][u+iv]) = su-tv - Im([s+it][u+iv]) = sv+tu - - so - Re(w'.(s+it)) = Re(w').s - Im(w').t = Re(w).s + Im(w).t - Im(w'.(s+it)) = Re(w').t + Im(w').s = Re(w).t - Im(w).s - - For inverse dft we take the complex conjugate of all twiddle factors. - Hence - - a0 = a0 + (w'.a2 + w.a3) - a1 = a1 - i(w'.a2 - w.a3) - a2 = a0 - (w'.a2 + w.a3) - a3 = a1 + i(w'.a2 - w.a3) - - Define t1 = Re(w'.a2) = Re(w)*Re(a2) + Im(w)*Im(a2) - t2 = Im(w'.a2) = Re(w)*Im(a2) - Im(w)*Re(a2) - t5 = Re(w.a3) = Re(w)*Re(a3) - Im(w)*Im(a3) - t6 = Im(w.a3) = Re(w)*Im(a3) + Im(w)*Re(a3) - - Then we just output: - a0.re = a0.re + ( t1 + t5 ) - a0.im = a0.im + ( t2 + t6 ) - a1.re = a1.re + ( t2 - t6 ) // since we multiply by -i and i(-i) = 1 - a1.im = a1.im - ( t1 - t5 ) // since we multiply by -i and 1(-i) = -i - a2.re = a0.re - ( t1 + t5 ) - a2.im = a0.im - ( t1 + t5 ) - a3.re = a1.re - ( t2 - t6 ) // since we multiply by +i and i(+i) = -1 - a3.im = a1.im + ( t1 - t5 ) // since we multiply by +i and 1(+i) = i - - -*/ - -#ifndef FFT_FFMPEG_INCL_OPTIMISED_TRANSFORM -static inline FFTComplex* TRANSFORM(FFTComplex * z, unsigned int n, FFTSample wre, FFTSample wim) -{ - register FFTSample t1,t2,t5,t6,r_re,r_im; - r_re = z[n*2].re; - r_im = z[n*2].im; - XPROD31_R(r_re, r_im, wre, wim, t1,t2); - r_re = z[n*3].re; - r_im = z[n*3].im; - XNPROD31_R(r_re, r_im, wre, wim, t5,t6); - BUTTERFLIES(z[0],z[n],z[n*2],z[n*3]); - return z+1; -} - -static inline FFTComplex* TRANSFORM_W01(FFTComplex * z, unsigned int n, const FFTSample * w) -{ - register const FFTSample wre=w[0],wim=w[1]; - register FFTSample t1,t2,t5,t6,r_re,r_im; - r_re = z[n*2].re; - r_im = z[n*2].im; - XPROD31_R(r_re, r_im, wre, wim, t1,t2); - r_re = z[n*3].re; - r_im = z[n*3].im; - XNPROD31_R(r_re, r_im, wre, wim, t5,t6); - BUTTERFLIES(z[0],z[n],z[n*2],z[n*3]); - return z+1; -} - -static inline FFTComplex* TRANSFORM_W10(FFTComplex * z, unsigned int n, const FFTSample * w) -{ - register const FFTSample wim=w[0],wre=w[1]; - register FFTSample t1,t2,t5,t6,r_re,r_im; - r_re = z[n*2].re; - r_im = z[n*2].im; - XPROD31_R(r_re, r_im, wre, wim, t1,t2); - r_re = z[n*3].re; - r_im = z[n*3].im; - XNPROD31_R(r_re, r_im, wre, wim, t5,t6); - BUTTERFLIES(z[0],z[n],z[n*2],z[n*3]); - return z+1; -} - -static inline FFTComplex* TRANSFORM_EQUAL(FFTComplex * z, unsigned int n) -{ - register FFTSample t1,t2,t5,t6,temp1,temp2; - register FFTSample * my_z = (FFTSample *)(z); - my_z += n*4; - t2 = MULT31(my_z[0], cPI2_8); - temp1 = MULT31(my_z[1], cPI2_8); - my_z += n*2; - temp2 = MULT31(my_z[0], cPI2_8); - t5 = MULT31(my_z[1], cPI2_8); - t1 = ( temp1 + t2 ); - t2 = ( temp1 - t2 ); - t6 = ( temp2 + t5 ); - t5 = ( temp2 - t5 ); - my_z -= n*6; - BUTTERFLIES(z[0],z[n],z[n*2],z[n*3]); - return z+1; -} - -static inline FFTComplex* TRANSFORM_ZERO(FFTComplex * z, unsigned int n) -{ - FFTSample t1,t2,t5,t6; - t1 = z[n*2].re; - t2 = z[n*2].im; - t5 = z[n*3].re; - t6 = z[n*3].im; - BUTTERFLIES(z[0],z[n],z[n*2],z[n*3]); - return z+1; -} -#endif - -/* z[0...8n-1], w[1...2n-1] */ -static void pass(FFTComplex *z_arg, unsigned int STEP_arg, unsigned int n_arg) ICODE_ATTR_TREMOR_MDCT; -static void pass(FFTComplex *z_arg, unsigned int STEP_arg, unsigned int n_arg) -{ - register FFTComplex * z = z_arg; - register unsigned int STEP = STEP_arg; - register unsigned int n = n_arg; - - register const FFTSample *w = sincos_lookup0+STEP; - /* wre = *(wim+1) . ordering is sin,cos */ - register const FFTSample *w_end = sincos_lookup0+1024; - - /* first two are special (well, first one is special, but we need to do pairs) */ - z = TRANSFORM_ZERO(z,n); - z = TRANSFORM_W10(z,n,w); - w += STEP; - /* first pass forwards through sincos_lookup0*/ - do { - z = TRANSFORM_W10(z,n,w); - w += STEP; - z = TRANSFORM_W10(z,n,w); - w += STEP; - } while(LIKELY(w < w_end)); - /* second half: pass backwards through sincos_lookup0*/ - /* wim and wre are now in opposite places so ordering now [0],[1] */ - w_end=sincos_lookup0; - while(LIKELY(w>w_end)) - { - z = TRANSFORM_W01(z,n,w); - w -= STEP; - z = TRANSFORM_W01(z,n,w); - w -= STEP; - } -} - -/* what is STEP? - sincos_lookup0 has sin,cos pairs for 1/4 cycle, in 1024 points - so half cycle would be 2048 points - ff_cos_16 has 8 elements corresponding to 4 cos points and 4 sin points - so each of the 4 points pairs corresponds to a 256*2-byte jump in sincos_lookup0 - 8192/16 (from "ff_cos_16") is 512 bytes. - i.e. for fft16, STEP = 8192/16 */ -#define DECL_FFT(n,n2,n4)\ -static void fft##n(FFTComplex *z) ICODE_ATTR_TREMOR_MDCT;\ -static void fft##n(FFTComplex *z)\ -{\ - fft##n2(z);\ - fft##n4(z+n4*2);\ - fft##n4(z+n4*3);\ - pass(z,8192/n,n4);\ -} - -#ifndef FFT_FFMPEG_INCL_OPTIMISED_FFT4 -static inline void fft4(FFTComplex *z) -{ - FFTSample t1, t2, t3, t4, t5, t6, t7, t8; - - BF(t3, t1, z[0].re, z[1].re); // t3=r1-r3 ; t1 = r1+r3 - BF(t8, t6, z[3].re, z[2].re); // t8=r7-r5 ; t6 = r7+r5 - - BF(z[2].re, z[0].re, t1, t6); // r5=t1-t6 ; r1 = t1+t6 - - BF(t4, t2, z[0].im, z[1].im); // t4=r2-r4 ; t2 = r2+r4 - BF(t7, t5, z[2].im, z[3].im); // t7=r6-r8 ; t5 = r6+r8 - - BF(z[3].im, z[1].im, t4, t8); // r8=t4-t8 ; r4 = t4+t8 - BF(z[3].re, z[1].re, t3, t7); // r7=t3-t7 ; r3 = t3+t7 - BF(z[2].im, z[0].im, t2, t5); // r6=t2-t5 ; r2 = t2+t5 -} -#endif - -static void fft4_dispatch(FFTComplex *z) -{ - fft4(z); -} - -#ifndef FFT_FFMPEG_INCL_OPTIMISED_FFT8 -static inline void fft8(FFTComplex *z) -{ - fft4(z); - FFTSample t1,t2,t3,t4,t7,t8; - - BF(t1, z[5].re, z[4].re, -z[5].re); - BF(t2, z[5].im, z[4].im, -z[5].im); - BF(t3, z[7].re, z[6].re, -z[7].re); - BF(t4, z[7].im, z[6].im, -z[7].im); - BF(t8, t1, t3, t1); - BF(t7, t2, t2, t4); - BF(z[4].re, z[0].re, z[0].re, t1); - BF(z[4].im, z[0].im, z[0].im, t2); - BF(z[6].re, z[2].re, z[2].re, t7); - BF(z[6].im, z[2].im, z[2].im, t8); - - z++; - TRANSFORM_EQUAL(z,2); -} -#endif - -static void fft8_dispatch(FFTComplex *z) -{ - fft8(z); -} - -#ifndef CONFIG_SMALL -static void fft16(FFTComplex *z) ICODE_ATTR_TREMOR_MDCT; -static void fft16(FFTComplex *z) -{ - fft8(z); - fft4(z+8); - fft4(z+12); - - TRANSFORM_ZERO(z,4); - z+=2; - TRANSFORM_EQUAL(z,4); - z-=1; - TRANSFORM(z,4,cPI1_8,cPI3_8); - z+=2; - TRANSFORM(z,4,cPI3_8,cPI1_8); -} -#else -DECL_FFT(16,8,4) -#endif -DECL_FFT(32,16,8) -DECL_FFT(64,32,16) -DECL_FFT(128,64,32) -DECL_FFT(256,128,64) -DECL_FFT(512,256,128) -DECL_FFT(1024,512,256) -DECL_FFT(2048,1024,512) -DECL_FFT(4096,2048,1024) - -static void (*fft_dispatch[])(FFTComplex*) = { - fft4_dispatch, fft8_dispatch, fft16, fft32, fft64, fft128, fft256, fft512, fft1024, - fft2048, fft4096 -}; - -void ff_fft_calc_c(int nbits, FFTComplex *z) -{ - fft_dispatch[nbits-2](z); -} - -#if 0 -int main (void) -{ -#define PRECISION 16 -#define FFT_SIZE 1024 -#define ftofix32(x) ((fixed32)((x) * (float)(1 << PRECISION) + ((x) < 0 ? -0.5 : 0.5))) -#define itofix32(x) ((x) << PRECISION) -#define fixtoi32(x) ((x) >> PRECISION) - - int j; - const long N = FFT_SIZE; - double r[FFT_SIZE] = {0.0}, i[FFT_SIZE] = {0.0}; - long n; - double t; - double amp, phase; - clock_t start, end; - double exec_time = 0; - FFTContext s; - FFTComplex z[FFT_SIZE]; - memset(z, 0, 64*sizeof(FFTComplex)); - - /* Generate saw-tooth test data */ - for (n = 0; n < FFT_SIZE; n++) - { - t = (2 * M_PI * n)/N; - /*z[n].re = 1.1 + sin( t) + - 0.5 * sin(2.0 * t) + - (1.0/3.0) * sin(3.0 * t) + - 0.25 * sin(4.0 * t) + - 0.2 * sin(5.0 * t) + - (1.0/6.0) * sin(6.0 * t) + - (1.0/7.0) * sin(7.0 * t) ;*/ - z[n].re = ftofix32(cos(2*M_PI*n/64)); - //printf("z[%d] = %f\n", n, z[n].re); - //getchar(); - } - - ff_fft_init(&s, 10, 1); -//start = clock(); -//for(n = 0; n < 1000000; n++) - ff_fft_permute_c(&s, z); - ff_fft_calc_c(&s, z); -//end = clock(); -//exec_time = (((double)end-(double)start)/CLOCKS_PER_SEC); - for(j = 0; j < FFT_SIZE; j++) - { - printf("%8.4f\n", sqrt(pow(fixtof32(z[j].re),2)+ pow(fixtof32(z[j].im), 2))); - //getchar(); - } - printf("muls = %d, adds = %d\n", muls, adds); -//printf(" Time elapsed = %f\n", exec_time); - //ff_fft_end(&s); - -} -#endif diff --git a/apps/codecs/lib/fft-ffmpeg_arm.h b/apps/codecs/lib/fft-ffmpeg_arm.h deleted file mode 100644 index 073ad8ee46..0000000000 --- a/apps/codecs/lib/fft-ffmpeg_arm.h +++ /dev/null @@ -1,456 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2010 Dave Hooper - * - * ARM optimisations for ffmpeg's fft (used in fft-ffmpeg.c) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ - -#ifdef CPU_ARM - -/* Start off with optimised variants of the butterflies that work - nicely on arm */ -/* 1. where y and a share the same variable/register */ -#define BF_OPT(x,y,a,b) {\ - y = a + b;\ - x = y - (b<<1);\ -} - -/* 2. where y and b share the same variable/register */ -#define BF_OPT2(x,y,a,b) {\ - x = a - b;\ - y = x + (b<<1);\ -} - -/* 3. where y and b share the same variable/register (but y=(-b)) */ -#define BF_OPT2_REV(x,y,a,b) {\ - x = a + b;\ - y = x - (b<<1);\ -} - - -/* standard BUTTERFLIES package. Note, we actually manually inline this - in all the TRANSFORM macros below anyway */ -#define FFT_FFMPEG_INCL_OPTIMISED_BUTTERFLIES -#define BUTTERFLIES(a0,a1,a2,a3) {\ - {\ - BF_OPT(t1, t5, t5, t1);\ - BF_OPT(t6, t2, t2, t6);\ - BF_OPT(a2.re, a0.re, a0.re, t5);\ - BF_OPT(a2.im, a0.im, a0.im, t2);\ - BF_OPT(a3.re, a1.re, a1.re, t6);\ - BF_OPT(a3.im, a1.im, a1.im, t1);\ - }\ -} - -#define FFT_FFMPEG_INCL_OPTIMISED_TRANSFORM - -static inline FFTComplex* TRANSFORM( FFTComplex* z, int n, FFTSample wre, FFTSample wim ) -{ - register FFTSample t1,t2 asm("r5"),t5 asm("r6"),t6 asm("r7"),r_re asm("r8"),r_im asm("r9"); - z += n*2; /* z[o2] */ - asm volatile( "ldmia %[my_z], {%[r_re],%[r_im]}\n\t":[r_re] "=r" (r_re), [r_im] "=r" (r_im):[my_z] "r" (z)); - XPROD31_R(r_re, r_im, wre, wim, t1,t2); - - z += n; /* z[o3] */ - asm volatile( "ldmia %[my_z], {%[r_re],%[r_im]}\n\t":[r_re] "=r" (r_re), [r_im] "=r" (r_im):[my_z] "r" (z)); - XNPROD31_R(r_re, r_im, wre, wim, t5,t6); - - BF_OPT(t1, t5, t5, t1); - BF_OPT(t6, t2, t2, t6); - - { - register FFTSample rt0temp asm("r4"); - /*{*/ - /* BF_OPT(t1, t5, t5, t1);*/ - /* BF_OPT(t6, t2, t2, t6);*/ - /* BF_OPT(a2.re, a0.re, a0.re, t5);*/ - /* BF_OPT(a2.im, a0.im, a0.im, t2);*/ - /* BF_OPT(a3.re, a1.re, a1.re, t6);*/ - /* BF_OPT(a3.im, a1.im, a1.im, t1);*/ - /*}*/ - z -= n*3; - /* r_re = my_z[0]; r_im = my_z[1]; */ - asm volatile( "ldmia %[my_z], {%[r_re],%[r_im]}\n\t":[r_re] "=r" (r_re), [r_im] "=r" (r_im):[my_z] "r" (z)); - BF_OPT(rt0temp, r_re, r_re, t5); - BF_OPT(t2, r_im, r_im, t2); - /* my_z[0] = r_re; my_z[1] = r_im; */ - asm volatile( "stmia %[my_z], {%[r_re],%[r_im]}\n\t"::[my_z] "r" (z), [r_re] "r" (r_re), [r_im] "r" (r_im):"memory" ); - z += n; - /* r_re = my_z[0]; r_im = my_z[1]; */ - asm volatile( "ldmia %[my_z], {%[r_re],%[r_im]}\n\t":[r_re] "=r" (r_re), [r_im] "=r" (r_im):[my_z] "r" (z)); - BF_OPT(t5, r_re, r_re, t6); - BF_OPT(t6, r_im, r_im, t1); - /* my_z[0] = r_re; my_z[1] = r_im; */ - asm volatile( "stmia %[my_z], {%[r_re],%[r_im]}\n\t"::[my_z] "r" (z), [r_re] "r" (r_re), [r_im] "r" (r_im):"memory"); - z += n; - /* my_z[0] = rt0temp; my_z[1] = t2; */ - asm volatile( "stmia %[my_z], {%[rt0temp],%[t2]}\n\t"::[my_z] "r" (z), [rt0temp] "r" (rt0temp), [t2] "r" (t2):"memory"); - } - z += n; - - /* my_z[0] = t5; my_z[1] = t6; */ - asm volatile( "stmia %[my_z]!, {%[t5],%[t6]}\n\t":[my_z] "+r" (z) : [t5] "r" (t5), [t6] "r" (t6):"memory"); - z -= n*3; - return(z); -} - -static inline FFTComplex* TRANSFORM_W01( FFTComplex* z, int n, const FFTSample* w ) -{ - register FFTSample t1,t2 asm("r5"),t5 asm("r6"),t6 asm("r7"),r_re asm("r8"),r_im asm("r9"); - - /* load wre,wim into t5,t6 */ - asm volatile( "ldmia %[w], {%[wre], %[wim]}\n\t":[wre] "=r" (t5), [wim] "=r" (t6):[w] "r" (w)); - z += n*2; /* z[o2] -- 2n * 2 since complex numbers */ - asm volatile( "ldmia %[my_z], {%[r_re],%[r_im]}\n\t":[r_re] "=r" (r_re), [r_im] "=r" (r_im):[my_z] "r" (z)); - XPROD31_R(r_re, r_im, t5 /*wre*/, t6 /*wim*/, t1,t2); - - z += n; /* z[o3] */ - asm volatile( "ldmia %[my_z], {%[r_re],%[r_im]}\n\t":[r_re] "=r" (r_re), [r_im] "=r" (r_im):[my_z] "r" (z)); - XNPROD31_R(r_re, r_im, t5 /*wre*/, t6 /*wim*/, t5,t6); - - BF_OPT(t1, t5, t5, t1); - BF_OPT(t6, t2, t2, t6); - { - register FFTSample rt0temp asm("r4"); - /*{*/ - /* BF_OPT(t1, t5, t5, t1);*/ - /* BF_OPT(t6, t2, t2, t6);*/ - /* BF_OPT(a2.re, a0.re, a0.re, t5);*/ - /* BF_OPT(a2.im, a0.im, a0.im, t2);*/ - /* BF_OPT(a3.re, a1.re, a1.re, t6);*/ - /* BF_OPT(a3.im, a1.im, a1.im, t1);*/ - /*}*/ - z -= n*3; - /* r_re = my_z[0]; r_im = my_z[1]; */ - asm volatile( "ldmia %[my_z], {%[r_re],%[r_im]}\n\t":[r_re] "=r" (r_re), [r_im] "=r" (r_im):[my_z] "r" (z)); - BF_OPT(rt0temp, r_re, r_re, t5); - BF_OPT(t2, r_im, r_im, t2); - /* my_z[0] = r_re; my_z[1] = r_im; */ - asm volatile( "stmia %[my_z], {%[r_re],%[r_im]}\n\t"::[my_z] "r" (z), [r_re] "r" (r_re), [r_im] "r" (r_im):"memory"); - z += n; - /* r_re = my_z[0]; r_im = my_z[1]; */ - asm volatile( "ldmia %[my_z], {%[r_re],%[r_im]}\n\t":[r_re] "=r" (r_re), [r_im] "=r" (r_im):[my_z] "r" (z)); - BF_OPT(t5, r_re, r_re, t6); - BF_OPT(t6, r_im, r_im, t1); - /* my_z[0] = r_re; my_z[1] = r_im; */ - asm volatile( "stmia %[my_z], {%[r_re],%[r_im]}\n\t"::[my_z] "r" (z), [r_re] "r" (r_re), [r_im] "r" (r_im):"memory"); - z += n; - /* my_z[0] = rt0temp; my_z[1] = t2; */ - asm volatile( "stmia %[my_z], {%[rt0temp],%[t2]}\n\t"::[my_z] "r" (z), [rt0temp] "r" (rt0temp), [t2] "r" (t2):"memory"); - } - z += n; - - /* my_z[0] = t5; my_z[1] = t6; */ - asm volatile( "stmia %[my_z]!, {%[t5],%[t6]}\n\t":[my_z] "+r" (z) : [t5] "r" (t5), [t6] "r" (t6):"memory"); - z -= n*3; - return(z); -} - -static inline FFTComplex* TRANSFORM_W10( FFTComplex* z, int n, const FFTSample* w ) -{ - register FFTSample t1,t2 asm("r5"),t5 asm("r6"),t6 asm("r7"),r_re asm("r8"),r_im asm("r9"); - - /* load wim,wre into t5,t6 */ - asm volatile( "ldmia %[w], {%[wim], %[wre]}\n\t":[wim] "=r" (t5), [wre] "=r" (t6):[w] "r" (w)); - z += n*2; /* z[o2] -- 2n * 2 since complex numbers */ - asm volatile( "ldmia %[my_z], {%[r_re],%[r_im]}\n\t":[r_re] "=r" (r_re), [r_im] "=r" (r_im):[my_z] "r" (z)); - XPROD31_R(r_re, r_im, t6 /*wim*/, t5 /*wre*/, t1,t2); - - z += n; /* z[o3] */ - asm volatile( "ldmia %[my_z], {%[r_re],%[r_im]}\n\t":[r_re] "=r" (r_re), [r_im] "=r" (r_im):[my_z] "r" (z)); - XNPROD31_R(r_re, r_im, t6 /*wim*/, t5 /*wre*/, t5,t6); - - BF_OPT(t1, t5, t5, t1); - BF_OPT(t6, t2, t2, t6); - { - register FFTSample rt0temp asm("r4"); - /*{*/ - /* BF_OPT(t1, t5, t5, t1);*/ - /* BF_OPT(t6, t2, t2, t6);*/ - /* BF_OPT(a2.re, a0.re, a0.re, t5);*/ - /* BF_OPT(a2.im, a0.im, a0.im, t2);*/ - /* BF_OPT(a3.re, a1.re, a1.re, t6);*/ - /* BF_OPT(a3.im, a1.im, a1.im, t1);*/ - /*}*/ - z -= n*3; - /* r_re = my_z[0]; r_im = my_z[1]; */ - asm volatile( "ldmia %[my_z], {%[r_re],%[r_im]}\n\t":[r_re] "=r" (r_re), [r_im] "=r" (r_im):[my_z] "r" (z)); - BF_OPT(rt0temp, r_re, r_re, t5); - BF_OPT(t2, r_im, r_im, t2); - /* my_z[0] = r_re; my_z[1] = r_im; */ - asm volatile( "stmia %[my_z], {%[r_re],%[r_im]}\n\t"::[my_z] "r" (z), [r_re] "r" (r_re), [r_im] "r" (r_im):"memory"); - z += n; - /* r_re = my_z[0]; r_im = my_z[1]; */ - asm volatile( "ldmia %[my_z], {%[r_re],%[r_im]}\n\t":[r_re] "=r" (r_re), [r_im] "=r" (r_im):[my_z] "r" (z)); - BF_OPT(t5, r_re, r_re, t6); - BF_OPT(t6, r_im, r_im, t1); - /* my_z[0] = r_re; my_z[1] = r_im; */ - asm volatile( "stmia %[my_z], {%[r_re],%[r_im]}\n\t"::[my_z] "r" (z), [r_re] "r" (r_re), [r_im] "r" (r_im):"memory"); - z += n; - /* my_z[0] = rt0temp; my_z[1] = t2; */ - asm volatile( "stmia %[my_z], {%[rt0temp],%[t2]}\n\t"::[my_z] "r" (z), [rt0temp] "r" (rt0temp), [t2] "r" (t2):"memory"); - } - z += n; - - /* my_z[0] = t5; my_z[1] = t6; */ - asm volatile( "stmia %[my_z]!, {%[t5],%[t6]}\n\t":[my_z] "+r" (z) : [t5] "r" (t5), [t6] "r" (t6):"memory"); - z -= n*3; - return(z); -} - -static inline FFTComplex* TRANSFORM_EQUAL( FFTComplex* z, int n ) -{ - register FFTSample t1,t2 asm("r5"),t5 asm("r6"),t6 asm("r7"),r_re asm("r8"),r_im asm("r9"); - - z += n*2; /* z[o2] -- 2n * 2 since complex numbers */ - asm volatile( "ldmia %[my_z], {%[t5],%[t6]}\n\t":[t5] "=r" (t5), [t6] "=r" (t6):[my_z] "r" (z)); - z += n; /* z[o3] */ - asm volatile( "ldmia %[my_z], {%[r_re],%[r_im]}\n\t":[r_re] "=r" (r_re), [r_im] "=r" (r_im):[my_z] "r" (z)); - -/**/ -/*t2 = MULT32(cPI2_8, t5);*/ -/*t1 = MULT31(cPI2_8, t6);*/ -/*t6 = MULT31(cPI2_8, r_re);*/ -/*t5 = MULT32(cPI2_8, r_im);*/ - -/*t1 = ( t1 + (t2<<1) );*/ -/*t2 = ( t1 - (t2<<2) );*/ -/*t6 = ( t6 + (t5<<1) );*/ -/*t5 = ( t6 - (t5<<2) );*/ -/**/ - t2 = MULT31(cPI2_8, t5); - t6 = MULT31(cPI2_8, t6); - r_re = MULT31(cPI2_8, r_re); - t5 = MULT31(cPI2_8, r_im); - - t1 = ( t6 + t2 ); - t2 = ( t6 - t2 ); - t6 = ( r_re + t5 ); - t5 = ( r_re - t5 ); - - BF_OPT(t1, t5, t5, t1); - BF_OPT(t6, t2, t2, t6); - { - register FFTSample rt0temp asm("r4"); - /*{*/ - /* BF_OPT(t1, t5, t5, t1);*/ - /* BF_OPT(t6, t2, t2, t6);*/ - /* BF_OPT(a2.re, a0.re, a0.re, t5);*/ - /* BF_OPT(a2.im, a0.im, a0.im, t2);*/ - /* BF_OPT(a3.re, a1.re, a1.re, t6);*/ - /* BF_OPT(a3.im, a1.im, a1.im, t1);*/ - /*}*/ - z -= n*3; - /* r_re = my_z[0]; r_im = my_z[1]; */ - asm volatile( "ldmia %[my_z], {%[r_re],%[r_im]}\n\t":[r_re] "=r" (r_re), [r_im] "=r" (r_im):[my_z] "r" (z)); - BF_OPT(rt0temp, r_re, r_re, t5); - BF_OPT(t2, r_im, r_im, t2); - /* my_z[0] = r_re; my_z[1] = r_im; */ - asm volatile( "stmia %[my_z], {%[r_re],%[r_im]}\n\t"::[my_z] "r" (z), [r_re] "r" (r_re), [r_im] "r" (r_im):"memory"); - z += n; - /* r_re = my_z[0]; r_im = my_z[1]; */ - asm volatile( "ldmia %[my_z], {%[r_re],%[r_im]}\n\t":[r_re] "=r" (r_re), [r_im] "=r" (r_im):[my_z] "r" (z)); - BF_OPT(t5, r_re, r_re, t6); - BF_OPT(t6, r_im, r_im, t1); - /* my_z[0] = r_re; my_z[1] = r_im; */ - asm volatile( "stmia %[my_z], {%[r_re],%[r_im]}\n\t"::[my_z] "r" (z), [r_re] "r" (r_re), [r_im] "r" (r_im):"memory"); - z += n; - /* my_z[0] = rt0temp; my_z[1] = t2; */ - asm volatile( "stmia %[my_z], {%[rt0temp],%[t2]}\n\t"::[my_z] "r" (z), [rt0temp] "r" (rt0temp), [t2] "r" (t2):"memory"); - } - z += n; - - /* my_z[0] = t5; my_z[1] = t6; */ - asm volatile( "stmia %[my_z]!, {%[t5],%[t6]}\n\t":[my_z] "+r" (z) : [t5] "r" (t5), [t6] "r" (t6):"memory"); - z -= n*3; - return(z); -} - -static inline FFTComplex* TRANSFORM_ZERO( FFTComplex* z, int n ) -{ - register FFTSample t1,t2 asm("r5"),t5 asm("r6"),t6 asm("r7"), r_re asm("r8"), r_im asm("r9"); - - z += n*2; /* z[o2] -- 2n * 2 since complex numbers */ - asm volatile( "ldmia %[my_z], {%[r_re],%[r_im]}\n\t":[r_re] "=r" (r_re), [r_im] "=r" (r_im):[my_z] "r" (z)); - z += n; /* z[o3] */ - asm volatile( "ldmia %[my_z], {%[t5],%[t6]}\n\t":[t5] "=r" (t5), [t6] "=r" (t6):[my_z] "r" (z)); - - BF_OPT(t1, t5, t5, r_re); - BF_OPT(t6, t2, r_im, t6); - { - register FFTSample rt0temp asm("r4"); - /*{*/ - /* BF_OPT(t1, t5, t5, t1);*/ - /* BF_OPT(t6, t2, t2, t6);*/ - /* BF_OPT(a2.re, a0.re, a0.re, t5);*/ - /* BF_OPT(a2.im, a0.im, a0.im, t2);*/ - /* BF_OPT(a3.re, a1.re, a1.re, t6);*/ - /* BF_OPT(a3.im, a1.im, a1.im, t1);*/ - /*}*/ - z -= n*3; - /* r_re = my_z[0]; r_im = my_z[1]; */ - asm volatile( "ldmia %[my_z], {%[r_re],%[r_im]}\n\t":[r_re] "=r" (r_re), [r_im] "=r" (r_im):[my_z] "r" (z)); - BF_OPT(rt0temp, r_re, r_re, t5); - BF_OPT(t2, r_im, r_im, t2); - /* my_z[0] = r_re; my_z[1] = r_im; */ - asm volatile( "stmia %[my_z], {%[r_re],%[r_im]}\n\t"::[my_z] "r" (z), [r_re] "r" (r_re), [r_im] "r" (r_im):"memory"); - z += n; - /* r_re = my_z[0]; r_im = my_z[1]; */ - asm volatile( "ldmia %[my_z], {%[r_re],%[r_im]}\n\t":[r_re] "=r" (r_re), [r_im] "=r" (r_im):[my_z] "r" (z)); - BF_OPT(t5, r_re, r_re, t6); - BF_OPT(t6, r_im, r_im, t1); - /* my_z[0] = r_re; my_z[1] = r_im; */ - asm volatile( "stmia %[my_z], {%[r_re],%[r_im]}\n\t"::[my_z] "r" (z), [r_re] "r" (r_re), [r_im] "r" (r_im):"memory"); - z += n; - /* my_z[0] = rt0temp; my_z[1] = t2; */ - asm volatile( "stmia %[my_z], {%[rt0temp],%[t2]}\n\t"::[my_z] "r" (z), [rt0temp] "r" (rt0temp), [t2] "r" (t2):"memory"); - } - z += n; - - /* my_z[0] = t5; my_z[1] = t6; */ - asm volatile( "stmia %[my_z]!, {%[t5],%[t6]}\n\t":[my_z] "+r" (z) : [t5] "r" (t5), [t6] "r" (t6):"memory"); - z -= n*3; - return(z); -} - -#define FFT_FFMPEG_INCL_OPTIMISED_FFT4 -static inline FFTComplex* fft4(FFTComplex * z) -{ - FFTSample temp; - - /* input[0..7] -> output[0..7] */ - /* load r1=z[0],r2=z[1],...,r8=z[7] */ - asm volatile( - "ldmia %[z], {r1-r8}\n\t" - "add r1,r1,r3\n\t" /* r1 :=t1 */ - "sub r3,r1,r3, lsl #1\n\t" /* r3 :=t3 */ - "sub r7,r7,r5\n\t" /* r10:=t8 */ - "add r5,r7,r5, lsl #1\n\t" /* r5 :=t6 */ - - "add r1,r1,r5\n\t" /* r1 = o[0] */ - "sub r5,r1,r5, lsl #1\n\t" /* r5 = o[4] */ - - "add r2,r2,r4\n\t" /* r2 :=t2 */ - "sub r4,r2,r4, lsl #1\n\t" /* r9 :=t4 */ - - "add %[temp],r6,r8\n\t" /* r10:=t5 */ - "sub r6,r6,r8\n\t" /* r6 :=t7 */ - - "sub r8,r4,r7\n\t" /* r8 = o[7]*/ - "add r4,r4,r7\n\t" /* r4 = o[3]*/ - "sub r7,r3,r6\n\t" /* r7 = o[6]*/ - "add r3,r3,r6\n\t" /* r3 = o[2]*/ - "sub r6,r2,%[temp]\n\t" /* r6 = o[5]*/ - "add r2,r2,%[temp]\n\t" /* r2 = o[1]*/ - - "stmia %[z]!, {r1-r8}\n\t" - : /* outputs */ [z] "+r" (z), [temp] "=r" (temp) - : /* inputs */ - : /* clobbers */ - "r1","r2","r3","r4","r5","r6","r7","r8","memory" - ); - return z; -} - -#define FFT_FFMPEG_INCL_OPTIMISED_FFT8 - /* The chunk of asm below is equivalent to the following: - - // first load in z[4].re thru z[7].im into local registers - // ... - BF_OPT2_REV(z[4].re, z[5].re, z[4].re, z[5].re); // x=a+b; y=x-(b<<1) - BF_OPT2_REV(z[4].im, z[5].im, z[4].im, z[5].im); - BF_REV (temp, z[7].re, z[6].re, z[7].re); // x=a+b; y=a-b; - BF_REV (z[6].re, z[7].im, z[6].im, z[7].im); - // save z[7].re and z[7].im as those are complete now - // z[5].re and z[5].im are also complete now but save these later on - - BF(z[6].im, z[4].re, temp, z[4].re); // x=a-b; y=a+b - BF_OPT(z[6].re, z[4].im, z[4].im, z[6].re); // y=a+b; x=y-(b<<1) - // now load z[2].re and z[2].im - // ... - BF_OPT(z[6].re, z[2].re, z[2].re, z[6].re); // y=a+b; x=y-(b<<1) - BF_OPT(z[6].im, z[2].im, z[2].im, z[6].im); // y=a+b; x=y-(b<<1) - // Now save z[6].re and z[6].im, along with z[5].re and z[5].im - // for efficiency. Also save z[2].re and z[2].im. - // Now load z[0].re and z[0].im - // ... - - BF_OPT(z[4].re, z[0].re, z[0].re, z[4].re); // y=a+b; x=y-(b<<1) - BF_OPT(z[4].im, z[0].im, z[0].im, z[4].im); // y=a+b; x=y-(b<<1) - // Finally save out z[4].re, z[4].im, z[0].re and z[0].im - // ... - */ -static inline void fft8(FFTComplex * z) -{ - FFTComplex* m4 = fft4(z); - { - /* note that we increment z_ptr on the final stmia, which - leaves z_ptr pointing to z[1].re ready for the Transform step */ - - register FFTSample temp; - - asm volatile( - /* read in z[4].re thru z[7].im */ - "ldmia %[z4_ptr]!, {r1-r8}\n\t" - /* (now points one word past &z[7].im) */ - "add r1,r1,r3\n\t" - "sub r3,r1,r3,lsl #1\n\t" - "add r2,r2,r4\n\t" - "sub r4,r2,r4,lsl #1\n\t" - "add %[temp],r5,r7\n\t" - "sub r7,r5,r7\n\t" - "add r5,r6,r8\n\t" - "sub r8,r6,r8\n\t" - - "stmdb %[z4_ptr]!, {r7,r8}\n\t" /* write z[7].re,z[7].im straight away */ - /* Note, registers r7 & r8 now free */ - - "sub r6,%[temp],r1\n\t" - "add r1,%[temp],r1\n\t" - "add r2,r2,r5\n\t" - "sub r5,r2,r5,lsl #1\n\t" - "add %[temp], %[z_ptr], #16\n\t" /* point to &z[2].re */ - "ldmia %[temp],{r7,r8}\n\t" /* load z[2].re and z[2].im */ - "add r7,r7,r5\n\t" - "sub r5,r7,r5,lsl #1\n\t" - "add r8,r8,r6\n\t" - "sub r6,r8,r6,lsl #1\n\t" - - /* write out z[5].re, z[5].im, z[6].re, z[6].im in one go*/ - "stmdb %[z4_ptr]!, {r3-r6}\n\t" - "stmia %[temp],{r7,r8}\n\t" /* write out z[2].re, z[2].im */ - "ldmia %[z_ptr],{r7,r8}\n\t" /* load r[0].re, r[0].im */ - - "add r7,r7,r1\n\t" - "sub r1,r7,r1,lsl #1\n\t" - "add r8,r8,r2\n\t" - "sub r2,r8,r2,lsl #1\n\t" - - "stmia %[z_ptr]!,{r7,r8}\n\t" /* write out z[0].re, z[0].im */ - "stmdb %[z4_ptr], {r1,r2}\n\t" /* write out z[4].re, z[4].im */ - : [z4_ptr] "+r" (m4), [temp] "=r" (temp), [z_ptr] "+r" (z) - : - : "r1","r2","r3","r4","r5","r6","r7","r8","memory" - ); - } - - TRANSFORM_EQUAL(z,2); -} - -#endif // CPU_ARM diff --git a/apps/codecs/lib/fft-ffmpeg_cf.h b/apps/codecs/lib/fft-ffmpeg_cf.h deleted file mode 100644 index a29464a23d..0000000000 --- a/apps/codecs/lib/fft-ffmpeg_cf.h +++ /dev/null @@ -1,370 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2010 Nils Wallménius - * - * Coldfire v2 optimisations for ffmpeg's fft (used in fft-ffmpeg.c) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ - -#ifdef CPU_COLDFIRE -#define FFT_FFMPEG_INCL_OPTIMISED_FFT4 -static inline void fft4(FFTComplex * z) -{ - asm volatile ("movem.l (%[z]), %%d0-%%d7\n\t" - "move.l %%d0, %%a0\n\t" - "add.l %%d2, %%d0\n\t" /* d0 == t1 */ - "neg.l %%d2\n\t" - "add.l %%a0, %%d2\n\t" /* d2 == t3, a0 free */ - "move.l %%d6, %%a0\n\t" - "sub.l %%d4, %%d6\n\t" /* d6 == t8 */ - "add.l %%d4, %%a0\n\t" /* a0 == t6 */ - - "move.l %%d0, %%d4\n\t" - "sub.l %%a0, %%d4\n\t" /* z[2].re done */ - "add.l %%a0, %%d0\n\t" /* z[0].re done, a0 free */ - - "move.l %%d5, %%a0\n\t" - "sub.l %%d7, %%d5\n\t" /* d5 == t7 */ - "add.l %%d7, %%a0\n\t" /* a0 == t5 */ - - "move.l %%d1, %%d7\n\t" - "sub.l %%d3, %%d7\n\t" /* d7 == t4 */ - "add.l %%d3, %%d1\n\t" /* d1 == t2 */ - - "move.l %%d7, %%d3\n\t" - "sub.l %%d6, %%d7\n\t" /* z[3].im done */ - "add.l %%d6, %%d3\n\t" /* z[1].im done */ - - "move.l %%d2, %%d6\n\t" - "sub.l %%d5, %%d6\n\t" /* z[3].re done */ - "add.l %%d5, %%d2\n\t" /* z[1].re done */ - - "move.l %%d1, %%d5\n\t" - "sub.l %%a0, %%d5\n\t" /* z[2].im done */ - "add.l %%a0, %%d1\n\t" /* z[0].im done */ - - "movem.l %%d0-%%d7, (%[z])\n\t" - : :[z] "a" (z) - : "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", - "a0", "cc", "memory"); - -} - -#define FFT_FFMPEG_INCL_OPTIMISED_FFT8 -static inline void fft8(FFTComplex *z) -{ - asm volatile ("movem.l (4*8, %[z]), %%d0-%%d7\n\t" - "move.l %%d0, %%a1\n\t" - "add.l %%d2, %%a1\n\t" /* a1 == t1 */ - "sub.l %%d2, %%d0\n\t" /* d0 == z[5].re */ - - "move.l %%d1, %%a2\n\t" - "add.l %%d3, %%a2\n\t" /* a2 == t2 */ - "sub.l %%d3, %%d1\n\t" /* d1 == z[5].im */ - - "move.l %%d4, %%d2\n\t" - "add.l %%d6, %%d2\n\t" /* d2 == t3 */ - "sub.l %%d6, %%d4\n\t" /* d4 == z[7].re */ - - "move.l %%d5, %%d3\n\t" - "add.l %%d7, %%d3\n\t" /* d3 == t4 */ - "sub.l %%d7, %%d5\n\t" /* d5 == z[7].im */ - - "move.l %%d2, %%a4\n\t" - "sub.l %%a1, %%a4\n\t" /* a4 == t8 */ - "add.l %%d2, %%a1\n\t" /* a1 == t1, d2 free */ - - "move.l %%a2, %%a3\n\t" - "sub.l %%d3, %%a3\n\t" /* a3 == t7 */ - "add.l %%d3, %%a2\n\t" /* a2 == t2, d3 free */ - - /* emac block from TRANSFORM_EQUAL, do this now - so we don't need to store and load z[5] and z[7] */ - "move.l %[_cPI2_8], %%d2\n\t" - "mac.l %%d2, %%d0, %%acc0\n\t" - "mac.l %%d2, %%d1, %%acc1\n\t" - "mac.l %%d2, %%d4, %%acc2\n\t" - "mac.l %%d2, %%d5, %%acc3\n\t" - - /* fft4, clobbers all d regs and a0 */ - "movem.l (%[z]), %%d0-%%d7\n\t" - "move.l %%d0, %%a0\n\t" - "add.l %%d2, %%d0\n\t" /* d0 == t1 */ - "neg.l %%d2\n\t" - "add.l %%a0, %%d2\n\t" /* d2 == t3, a0 free */ - "move.l %%d6, %%a0\n\t" - "sub.l %%d4, %%d6\n\t" /* d6 == t8 */ - "add.l %%d4, %%a0\n\t" /* a0 == t6 */ - - "move.l %%d0, %%d4\n\t" - "sub.l %%a0, %%d4\n\t" /* z[2].re done */ - "add.l %%a0, %%d0\n\t" /* z[0].re done, a0 free */ - - "move.l %%d5, %%a0\n\t" - "sub.l %%d7, %%d5\n\t" /* d5 == t7 */ - "add.l %%d7, %%a0\n\t" /* a0 == t5 */ - - "move.l %%d1, %%d7\n\t" - "sub.l %%d3, %%d7\n\t" /* d7 == t4 */ - "add.l %%d3, %%d1\n\t" /* d1 == t2 */ - - "move.l %%d7, %%d3\n\t" - "sub.l %%d6, %%d7\n\t" /* z[3].im done */ - "add.l %%d6, %%d3\n\t" /* z[1].im done */ - - "move.l %%d2, %%d6\n\t" - "sub.l %%d5, %%d6\n\t" /* z[3].re done */ - "add.l %%d5, %%d2\n\t" /* z[1].re done */ - - "move.l %%d1, %%d5\n\t" - "sub.l %%a0, %%d5\n\t" /* z[2].im done */ - "add.l %%a0, %%d1\n\t" /* z[0].im done */ - /* end of fft4, but don't store yet */ - - "move.l %%d0, %%a0\n\t" - "add.l %%a1, %%d0\n\t" - "sub.l %%a1, %%a0\n\t" /* z[4].re, z[0].re done, a1 free */ - - "move.l %%d1, %%a1\n\t" - "add.l %%a2, %%d1\n\t" - "sub.l %%a2, %%a1\n\t" /* z[4].im, z[0].im done, a2 free */ - - "move.l %%d4, %%a2\n\t" - "add.l %%a3, %%d4\n\t" - "sub.l %%a3, %%a2\n\t" /* z[6].re, z[2].re done, a3 free */ - - "move.l %%d5, %%a3\n\t" - "add.l %%a4, %%d5\n\t" - "sub.l %%a4, %%a3\n\t" /* z[6].im, z[2].im done, a4 free */ - - "movem.l %%d0-%%d1, (%[z])\n\t" /* save z[0] */ - "movem.l %%d4-%%d5, (2*8, %[z])\n\t" /* save z[2] */ - "movem.l %%a0-%%a1, (4*8, %[z])\n\t" /* save z[4] */ - "movem.l %%a2-%%a3, (6*8, %[z])\n\t" /* save z[6] */ - - /* TRANSFORM_EQUAL */ - "movclr.l %%acc0, %%d0\n\t" - "movclr.l %%acc1, %%d1\n\t" - "movclr.l %%acc2, %%d4\n\t" - "movclr.l %%acc3, %%d5\n\t" - - "move.l %%d1, %%a0\n\t" - "add.l %%d0, %%a0\n\t" /* a0 == t1 */ - "sub.l %%d0, %%d1\n\t" /* d1 == t2 */ - - "move.l %%d4, %%d0\n\t" - "add.l %%d5, %%d0\n\t" /* d0 == t6 */ - "sub.l %%d5, %%d4\n\t" /* d4 == t5 */ - - "move.l %%d4, %%a1\n\t" - "sub.l %%a0, %%a1\n\t" /* a1 == temp1 */ - "add.l %%a0, %%d4\n\t" /* d4 == temp2 */ - - "move.l %%d2, %%a2\n\t" - "sub.l %%d4, %%a2\n\t" /* a2 == z[5].re */ - "add.l %%d4, %%d2\n\t" /* z[1].re done */ - - "move.l %%d7, %%d5\n\t" - "sub.l %%a1, %%d5\n\t" /* d5 == z[7].im */ - "add.l %%a1, %%d7\n\t" /* z[3].im done */ - - "move.l %%d1, %%a0\n\t" - "sub.l %%d0, %%a0\n\t" /* a0 == temp1 */ - "add.l %%d0, %%d1\n\t" /* d1 == temp2 */ - - "move.l %%d6, %%d4\n\t" - "sub.l %%a0, %%d4\n\t" /* d4 == z[7].re */ - "add.l %%a0, %%d6\n\t" /* z[3].re done */ - - "move.l %%d3, %%a3\n\t" - "sub.l %%d1, %%a3\n\t" /* a3 == z[5].im */ - "add.l %%d1, %%d3\n\t" /* z[1].im done */ - - "movem.l %%d2-%%d3, (1*8, %[z])\n\t" /* save z[1] */ - "movem.l %%d6-%%d7, (3*8, %[z])\n\t" /* save z[3] */ - "movem.l %%a2-%%a3, (5*8, %[z])\n\t" /* save z[5] */ - "movem.l %%d4-%%d5, (7*8, %[z])\n\t" /* save z[7] */ - : :[z] "a" (z), [_cPI2_8] "i" (cPI2_8) - : "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", - "a0", "a1", "a2", "a3", "a4", "cc", "memory"); -} - -#define FFT_FFMPEG_INCL_OPTIMISED_TRANSFORM - -static inline FFTComplex* TRANSFORM(FFTComplex * z, unsigned int n, FFTSample wre, FFTSample wim) -{ - asm volatile ("move.l (%[z2]), %%d5\n\t" - "mac.l %%d5, %[wre], (4, %[z2]), %%d4, %%acc0\n\t" - "mac.l %%d4, %[wim], %%acc0\n\t" - "mac.l %%d4, %[wre], (%[z3]), %%d6, %%acc1\n\t" - "msac.l %%d5, %[wim], (4, %[z3]), %%d7, %%acc1\n\t" - "mac.l %%d6, %[wre], (%[z])+, %%d4, %%acc2\n\t" - "msac.l %%d7, %[wim], (%[z])+, %%d5, %%acc2\n\t" - "mac.l %%d7, %[wre], %%acc3\n\t" - "mac.l %%d6, %[wim], %%acc3\n\t" - - "movclr.l %%acc0, %[wre]\n\t" /* t1 */ - "movclr.l %%acc2, %[wim]\n\t" /* t5 */ - - "move.l %%d4, %%d6\n\t" - "move.l %[wim], %%d7\n\t" - "sub.l %[wre], %[wim]\n\t" /* t5 = t5-t1 */ - "add.l %[wre], %%d7\n\t" - "sub.l %%d7, %%d6\n\t" /* d6 = a0re - (t5+t1) => a2re */ - "add.l %%d7, %%d4\n\t" /* d4 = a0re + (t5+t1) => a0re */ - - "movclr.l %%acc3, %%d7\n\t" /* t6 */ - "movclr.l %%acc1, %%d3\n\t" /* t2 */ - - "move.l %%d3, %[wre]\n\t" - "add.l %%d7, %[wre]\n\t" - "sub.l %%d7, %%d3\n\t" /* t2 = t6-t2 */ - "move.l %%d5, %%d7\n\t" - "sub.l %[wre], %%d7\n\t" /* d7 = a0im - (t2+t6) => a2im */ - - "movem.l %%d6-%%d7, (%[z2])\n\t" /* store z2 */ - "add.l %[wre], %%d5\n\t" /* d5 = a0im + (t2+t6) => a0im */ - "movem.l %%d4-%%d5, (-8, %[z])\n\t" /* store z0 */ - - "movem.l (%[z1]), %%d4-%%d5\n\t" /* load z1 */ - "move.l %%d4, %%d6\n\t" - - "sub.l %%d3, %%d6\n\t" /* d6 = a1re - (t2-t6) => a3re */ - "add.l %%d3, %%d4\n\t" /* d4 = a1re + (t2-t6) => a1re */ - - "move.l %%d5, %%d7\n\t" - "sub.l %[wim], %%d7\n\t" - "movem.l %%d6-%%d7, (%[z3])\n\t" /* store z3 */ - "add.l %[wim], %%d5\n\t" - "movem.l %%d4-%%d5, (%[z1])\n\t" /* store z1 */ - - : [wre] "+r" (wre), [wim] "+r" (wim), /* we clobber these after using them */ - [z] "+a" (z) - : [z1] "a" (&z[n]), [z2] "a" (&z[2*n]), [z3] "a" (&z[3*n]) - : "d3", "d4", "d5", "d6", "d7", "cc", "memory"); - return z; -} - -static inline FFTComplex* TRANSFORM_W01(FFTComplex * z, unsigned int n, const FFTSample * w) -{ - return TRANSFORM(z, n, w[0], w[1]); -} - -static inline FFTComplex* TRANSFORM_W10(FFTComplex * z, unsigned int n, const FFTSample * w) -{ - return TRANSFORM(z, n, w[1], w[0]); -} - -static inline FFTComplex* TRANSFORM_ZERO(FFTComplex * z, unsigned int n) -{ - asm volatile("movem.l (%[z]), %%d4-%%d5\n\t" /* load z0 */ - "move.l %%d4, %%d6\n\t" - "movem.l (%[z2]), %%d2-%%d3\n\t" /* load z2 */ - "movem.l (%[z3]), %%d0-%%d1\n\t" /* load z0 */ - "move.l %%d0, %%d7\n\t" - "sub.l %%d2, %%d0\n\t" - "add.l %%d2, %%d7\n\t" - "sub.l %%d7, %%d6\n\t" /* d6 = a0re - (t5+t1) => a2re */ - "add.l %%d7, %%d4\n\t" /* d4 = a0re + (t5+t1) => a0re */ - - "move.l %%d5, %%d7\n\t" - "move.l %%d3, %%d2\n\t" - "add.l %%d1, %%d2\n\t" - "sub.l %%d2, %%d7\n\t" /* d7 = a0im - (t2+t6) => a2im */ - "movem.l %%d6-%%d7, (%[z2])\n\t" /* store z2 */ - "add.l %%d2, %%d5\n\t" /* d5 = a0im + (t2+t6) => a0im */ - "movem.l %%d4-%%d5, (%[z])\n\t" /* store z0 */ - - "movem.l (%[z1]), %%d4-%%d5\n\t" /* load z1 */ - "move.l %%d4, %%d6\n\t" - "sub.l %%d1, %%d3\n\t" - "sub.l %%d3, %%d6\n\t" /* d6 = a1re - (t2-t6) => a3re */ - "add.l %%d3, %%d4\n\t" /* d4 = a1re + (t2-t6) => a1re */ - - "move.l %%d5, %%d7\n\t" - "sub.l %%d0, %%d7\n\t" - "movem.l %%d6-%%d7, (%[z3])\n\t" /* store z3 */ - "add.l %%d0, %%d5\n\t" - - "movem.l %%d4-%%d5, (%[z1])\n\t" /* store z1 */ - - : - : [z] "a" (z), [z1] "a" (&z[n]), [z2] "a" (&z[2*n]), [z3] "a" (&z[3*n]) - : "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", "cc", "memory"); - return z+1; -} - -static inline FFTComplex* TRANSFORM_EQUAL(FFTComplex * z, unsigned int n) -{ - asm volatile ("movem.l (%[z2]), %%d0-%%d1\n\t" - "move.l %[_cPI2_8], %%d2\n\t" - "mac.l %%d0, %%d2, (%[z3]), %%d0, %%acc0\n\t" - "mac.l %%d1, %%d2, (4, %[z3]), %%d1, %%acc1\n\t" - "mac.l %%d0, %%d2, (%[z]), %%d4, %%acc2\n\t" - "mac.l %%d1, %%d2, (4, %[z]), %%d5, %%acc3\n\t" - - "movclr.l %%acc0, %%d0\n\t" - "movclr.l %%acc1, %%d1\n\t" - "movclr.l %%acc2, %%d2\n\t" - "movclr.l %%acc3, %%d3\n\t" - - "move.l %%d0, %%d7\n\t" - "add.l %%d1, %%d0\n\t" /* d0 == t1 */ - "sub.l %%d7, %%d1\n\t" /* d1 == t2 */ - - "move.l %%d3, %%d7\n\t" - "add.l %%d2, %%d3\n\t" /* d3 == t6 */ - "sub.l %%d7, %%d2\n\t" /* d2 == t5 */ - - "move.l %%d4, %%d6\n\t" - "move.l %%d2, %%d7\n\t" - "sub.l %%d0, %%d2\n\t" /* t5 = t5-t1 */ - "add.l %%d0, %%d7\n\t" - "sub.l %%d7, %%d6\n\t" /* d6 = a0re - (t5+t1) => a2re */ - "add.l %%d7, %%d4\n\t" /* d4 = a0re + (t5+t1) => a0re */ - - "move.l %%d1, %%d0\n\t" - "add.l %%d3, %%d0\n\t" - "sub.l %%d3, %%d1\n\t" /* t2 = t6-t2 */ - "move.l %%d5, %%d7\n\t" - "sub.l %%d0, %%d7\n\t" /* d7 = a0im - (t2+t6) => a2im */ - - "movem.l %%d6-%%d7, (%[z2])\n\t" /* store z2 */ - "add.l %%d0, %%d5\n\t" /* d5 = a0im + (t2+t6) => a0im */ - "movem.l %%d4-%%d5, (%[z])\n\t" /* store z0 */ - - "movem.l (%[z1]), %%d4-%%d5\n\t" /* load z1 */ - "move.l %%d4, %%d6\n\t" - - "sub.l %%d1, %%d6\n\t" /* d6 = a1re - (t2-t6) => a3re */ - "add.l %%d1, %%d4\n\t" /* d4 = a1re + (t2-t6) => a1re */ - - "move.l %%d5, %%d7\n\t" - "sub.l %%d2, %%d7\n\t" - "movem.l %%d6-%%d7, (%[z3])\n\t" /* store z3 */ - "add.l %%d2, %%d5\n\t" - "movem.l %%d4-%%d5, (%[z1])\n\t" /* store z1 */ - - :: [z] "a" (z), [z1] "a" (&z[n]), [z2] "a" (&z[2*n]), [z3] "a" (&z[3*n]), - [_cPI2_8] "i" (cPI2_8) - : "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", "cc", "memory"); - - return z+1; -} - -#endif /* CPU_COLDIFRE */ diff --git a/apps/codecs/lib/fft.h b/apps/codecs/lib/fft.h deleted file mode 100644 index 302a3b3996..0000000000 --- a/apps/codecs/lib/fft.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * WMA compatible decoder - * Copyright (c) 2002 The FFmpeg Project. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -#ifndef CODECLIB_FFT_H_INCLUDED -#define CODECLIB_FFT_H_INCLUDED - -#include -typedef int32_t fixed32; -typedef int64_t fixed64; - -#define FFT_FIXED - -#ifdef FFT_FIXED -typedef fixed32 FFTSample; -#else /* FFT_FIXED */ -typedef float FFTSample; -#endif /* FFT_FIXED */ - -typedef struct FFTComplex { - FFTSample re, im; -} FFTComplex; - -typedef struct FFTContext { - int nbits; - int inverse; - uint16_t *revtab; - int mdct_size; /* size of MDCT (i.e. number of input data * 2) */ - int mdct_bits; /* n = 2^nbits */ - /* pre/post rotation tables */ - FFTSample *tcos; - FFTSample *tsin; - void (*fft_permute)(struct FFTContext *s, FFTComplex *z); - void (*fft_calc)(struct FFTContext *s, FFTComplex *z); - void (*imdct_calc)(struct FFTContext *s, FFTSample *output, const FFTSample *input); - void (*imdct_half)(struct FFTContext *s, FFTSample *output, const FFTSample *input); - void (*mdct_calc)(struct FFTContext *s, FFTSample *output, const FFTSample *input); - int split_radix; - int permutation; -#define FF_MDCT_PERM_NONE 0 -#define FF_MDCT_PERM_INTERLEAVE 1 -} FFTContext; - -// internal api (fft<->mdct) -//int fft_calc_unscaled(FFTContext *s, FFTComplex *z); -//void ff_fft_permute_c(FFTContext *s, FFTComplex *z); // internal only? -void ff_fft_calc_c(int nbits, FFTComplex *z); - -#endif // CODECLIB_FFT_H_INCLUDED - diff --git a/apps/codecs/lib/fixedpoint.c b/apps/codecs/lib/fixedpoint.c deleted file mode 100644 index 352e246673..0000000000 --- a/apps/codecs/lib/fixedpoint.c +++ /dev/null @@ -1 +0,0 @@ -#include "../../fixedpoint.c" diff --git a/apps/codecs/lib/fixedpoint.h b/apps/codecs/lib/fixedpoint.h deleted file mode 100644 index 1cbd1573bb..0000000000 --- a/apps/codecs/lib/fixedpoint.h +++ /dev/null @@ -1,49 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2006 Jens Arnold - * - * Fixed point library for plugins - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ - - /** CODECS - FIXED POINT MATH ROUTINES - USAGE - * - * - x and y arguments are fixed point integers - * - fracbits is the number of fractional bits in the argument(s) - * - functions return long fixed point integers with the specified number - * of fractional bits unless otherwise specified - * - * Calculate sin and cos of an angle: - * fp_sincos(phase, *cos) - * where phase is a 32 bit unsigned integer with 0 representing 0 - * and 0xFFFFFFFF representing 2*pi, and *cos is the address to - * a long signed integer. Value returned is a long signed integer - * from -0x80000000 to 0x7fffffff, representing -1 to 1 respectively. - * That is, value is a fixed point integer with 31 fractional bits. - * - * Take square root of a fixed point number: - * fp_sqrt(x, fracbits) - * - */ -#ifndef _FIXEDPOINT_H_CODECS -#define _FIXEDPOINT_H_CODECS - -long fp_sincos(unsigned long phase, long *cos); -long fp_sqrt(long a, unsigned int fracbits); - -#endif diff --git a/apps/codecs/lib/libcodec.make b/apps/codecs/lib/libcodec.make deleted file mode 100644 index 7aef72f2b1..0000000000 --- a/apps/codecs/lib/libcodec.make +++ /dev/null @@ -1,37 +0,0 @@ -# __________ __ ___. -# Open \______ \ ____ ____ | | _\_ |__ _______ ___ -# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / -# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < -# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ -# \/ \/ \/ \/ \/ -# $Id$ -# - -CODECLIB := $(CODECDIR)/libcodec.a -CODECLIB_SRC := $(call preprocess, $(APPSDIR)/codecs/lib/SOURCES) -CODECLIB_OBJ := $(call c2obj, $(CODECLIB_SRC)) -OTHER_SRC += $(CODECLIB_SRC) - -$(CODECLIB): $(CODECLIB_OBJ) - $(SILENT)$(shell rm -f $@) - $(call PRINTS,AR $(@F))$(AR) rcs $@ $^ >/dev/null - -CODECLIBFLAGS = $(filter-out -O%,$(CODECFLAGS)) - -ifeq ($(MEMORYSIZE),2) - CODECLIBFLAGS += -Os -else ifeq ($(ARCH),arch_m68k) - CODECLIBFLAGS += -O2 -else - CODECLIBFLAGS += -O1 -endif - -# Do not use '-ffunction-sections' when compiling sdl-sim -ifneq ($(findstring sdl-sim, $(APP_TYPE)), sdl-sim) - CODECLIBFLAGS += -ffunction-sections -endif - -$(CODECDIR)/lib/%.o: $(ROOTDIR)/apps/codecs/lib/%.c - $(SILENT)mkdir -p $(dir $@) - $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) \ - -I$(dir $<) $(CODECLIBFLAGS) -c $< -o $@ diff --git a/apps/codecs/lib/mdct.c b/apps/codecs/lib/mdct.c deleted file mode 100644 index 777aec4a55..0000000000 --- a/apps/codecs/lib/mdct.c +++ /dev/null @@ -1,644 +0,0 @@ -/* - * Fixed Point IMDCT - * Copyright (c) 2002 The FFmpeg Project. - * Copyright (c) 2010 Dave Hooper, Mohamed Tarek, Michael Giacomelli - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "codeclib.h" -#include "mdct.h" -#include "codeclib_misc.h" -#include "mdct_lookup.h" - -#ifndef ICODE_ATTR_TREMOR_MDCT -#define ICODE_ATTR_TREMOR_MDCT ICODE_ATTR -#endif - -/** - * Compute the middle half of the inverse MDCT of size N = 2^nbits - * thus excluding the parts that can be derived by symmetry - * @param output N/2 samples - * @param input N/2 samples - * - * NOTE - CANNOT CURRENTLY OPERATE IN PLACE (input and output must - * not overlap or intersect at all) - */ -void ff_imdct_half(unsigned int nbits, fixed32 *output, const fixed32 *input) ICODE_ATTR_TREMOR_MDCT; -void ff_imdct_half(unsigned int nbits, fixed32 *output, const fixed32 *input) -{ - int n8, n4, n2, n, j; - const fixed32 *in1, *in2; - (void)j; - n = 1 << nbits; - - n2 = n >> 1; - n4 = n >> 2; - n8 = n >> 3; - - FFTComplex *z = (FFTComplex *)output; - - /* pre rotation */ - in1 = input; - in2 = input + n2 - 1; - - /* revtab comes from the fft; revtab table is sized for N=4096 size fft = 2^12. - The fft is size N/4 so s->nbits-2, so our shift needs to be (12-(nbits-2)) */ - const int revtab_shift = (14- nbits); - - /* bitreverse reorder the input and rotate; result here is in OUTPUT ... */ - /* (note that when using the current split radix, the bitreverse ordering is - complex, meaning that this reordering cannot easily be done in-place) */ - /* Using the following pdf, you can see that it is possible to rearrange - the 'classic' pre/post rotate with an alternative one that enables - us to use fewer distinct twiddle factors. - http://www.eurasip.org/Proceedings/Eusipco/Eusipco2006/papers/1568980508.pdf - - For prerotation, the factors are just sin,cos(2PI*i/N) - For postrotation, the factors are sin,cos(2PI*(i+1/4)/N) - - Therefore, prerotation can immediately reuse the same twiddles as fft - (for postrotation it's still a bit complex, we reuse the fft trig tables - where we can, or a special table for N=2048, or interpolate between - trig tables for N>2048) - */ - const int32_t *T = sincos_lookup0; - const int step = 2<<(12-nbits); - const uint16_t * p_revtab=revtab; - { - const uint16_t * const p_revtab_end = p_revtab + n8; -#ifdef CPU_COLDFIRE - asm volatile ("move.l (%[in2]), %%d0\n\t" - "move.l (%[in1]), %%d1\n\t" - "bra.s 1f\n\t" - "0:\n\t" - "movem.l (%[T]), %%d2-%%d3\n\t" - - "addq.l #8, %[in1]\n\t" - "subq.l #8, %[in2]\n\t" - - "lea (%[step]*4, %[T]), %[T]\n\t" - - "mac.l %%d0, %%d3, (%[T]), %%d4, %%acc0;" - "msac.l %%d1, %%d2, (4, %[T]), %%d5, %%acc0;" - "mac.l %%d1, %%d3, (%[in1]), %%d1, %%acc1;" - "mac.l %%d0, %%d2, (%[in2]), %%d0, %%acc1;" - - "addq.l #8, %[in1]\n\t" - "subq.l #8, %[in2]\n\t" - - "mac.l %%d0, %%d5, %%acc2;" - "msac.l %%d1, %%d4, (%[p_revtab])+, %%d2, %%acc2;" - "mac.l %%d1, %%d5, (%[in1]), %%d1, %%acc3;" - "mac.l %%d0, %%d4, (%[in2]), %%d0, %%acc3;" - - "clr.l %%d3\n\t" - "move.w %%d2, %%d3\n\t" - "eor.l %%d3, %%d2\n\t" - "swap %%d2\n\t" - "lsr.l %[revtab_shift], %%d2\n\t" - - "movclr.l %%acc0, %%d4;" - "movclr.l %%acc1, %%d5;" - "lsl.l #3, %%d2\n\t" - "lea (%%d2, %[z]), %%a1\n\t" - "movem.l %%d4-%%d5, (%%a1)\n\t" - - "lsr.l %[revtab_shift], %%d3\n\t" - - "movclr.l %%acc2, %%d4;" - "movclr.l %%acc3, %%d5;" - "lsl.l #3, %%d3\n\t" - "lea (%%d3, %[z]), %%a1\n\t" - "movem.l %%d4-%%d5, (%%a1)\n\t" - - "lea (%[step]*4, %[T]), %[T]\n\t" - - "1:\n\t" - "cmp.l %[p_revtab_end], %[p_revtab]\n\t" - "bcs.s 0b\n\t" - : [in1] "+a" (in1), [in2] "+a" (in2), [T] "+a" (T), - [p_revtab] "+a" (p_revtab) - : [z] "a" (z), [step] "d" (step), [revtab_shift] "d" (revtab_shift), - [p_revtab_end] "r" (p_revtab_end) - : "d0", "d1", "d2", "d3", "d4", "d5", "a1", "cc", "memory"); -#else - while(LIKELY(p_revtab < p_revtab_end)) - { - j = (*p_revtab)>>revtab_shift; - XNPROD31(*in2, *in1, T[1], T[0], &z[j].re, &z[j].im ); - T += step; - in1 += 2; - in2 -= 2; - p_revtab++; - j = (*p_revtab)>>revtab_shift; - XNPROD31(*in2, *in1, T[1], T[0], &z[j].re, &z[j].im ); - T += step; - in1 += 2; - in2 -= 2; - p_revtab++; - } -#endif - } - { - const uint16_t * const p_revtab_end = p_revtab + n8; -#ifdef CPU_COLDFIRE - asm volatile ("move.l (%[in2]), %%d0\n\t" - "move.l (%[in1]), %%d1\n\t" - "bra.s 1f\n\t" - "0:\n\t" - "movem.l (%[T]), %%d2-%%d3\n\t" - - "addq.l #8, %[in1]\n\t" - "subq.l #8, %[in2]\n\t" - - "lea (%[step]*4, %[T]), %[T]\n\t" - - "mac.l %%d0, %%d2, (%[T]), %%d4, %%acc0;" - "msac.l %%d1, %%d3, (4, %[T]), %%d5, %%acc0;" - "mac.l %%d1, %%d2, (%[in1]), %%d1, %%acc1;" - "mac.l %%d0, %%d3, (%[in2]), %%d0, %%acc1;" - - "addq.l #8, %[in1]\n\t" - "subq.l #8, %[in2]\n\t" - - "mac.l %%d0, %%d4, %%acc2;" - "msac.l %%d1, %%d5, (%[p_revtab])+, %%d2, %%acc2;" - "mac.l %%d1, %%d4, (%[in1]), %%d1, %%acc3;" - "mac.l %%d0, %%d5, (%[in2]), %%d0, %%acc3;" - - "clr.l %%d3\n\t" - "move.w %%d2, %%d3\n\t" - "eor.l %%d3, %%d2\n\t" - "swap %%d2\n\t" - "lsr.l %[revtab_shift], %%d2\n\t" - - "movclr.l %%acc0, %%d4;" - "movclr.l %%acc1, %%d5;" - "lsl.l #3, %%d2\n\t" - "lea (%%d2, %[z]), %%a1\n\t" - "movem.l %%d4-%%d5, (%%a1)\n\t" - - "lsr.l %[revtab_shift], %%d3\n\t" - - "movclr.l %%acc2, %%d4;" - "movclr.l %%acc3, %%d5;" - "lsl.l #3, %%d3\n\t" - "lea (%%d3, %[z]), %%a1\n\t" - "movem.l %%d4-%%d5, (%%a1)\n\t" - - "lea (%[step]*4, %[T]), %[T]\n\t" - - "1:\n\t" - "cmp.l %[p_revtab_end], %[p_revtab]\n\t" - "bcs.s 0b\n\t" - : [in1] "+a" (in1), [in2] "+a" (in2), [T] "+a" (T), - [p_revtab] "+a" (p_revtab) - : [z] "a" (z), [step] "d" (-step), [revtab_shift] "d" (revtab_shift), - [p_revtab_end] "r" (p_revtab_end) - : "d0", "d1", "d2", "d3", "d4", "d5", "a1", "cc", "memory"); -#else - while(LIKELY(p_revtab < p_revtab_end)) - { - j = (*p_revtab)>>revtab_shift; - XNPROD31(*in2, *in1, T[0], T[1], &z[j].re, &z[j].im); - T -= step; - in1 += 2; - in2 -= 2; - p_revtab++; - j = (*p_revtab)>>revtab_shift; - XNPROD31(*in2, *in1, T[0], T[1], &z[j].re, &z[j].im); - T -= step; - in1 += 2; - in2 -= 2; - p_revtab++; - } -#endif - } - - - /* ... and so fft runs in OUTPUT buffer */ - ff_fft_calc_c(nbits-2, z); - - /* post rotation + reordering. now keeps the result within the OUTPUT buffer */ - switch( nbits ) - { - default: - { - fixed32 * z1 = (fixed32 *)(&z[0]); - int magic_step = step>>2; - int newstep; - if(n<=1024) - { - T = sincos_lookup0 + magic_step; - newstep = step>>1; - } - else - { - T = sincos_lookup1; - newstep = 2; - } - -#ifdef CPU_COLDFIRE - fixed32 * z2 = (fixed32 *)(&z[n4]); - int c = n4; - if (newstep == 2) - { - asm volatile ("movem.l (%[z1]), %%d0-%%d1\n\t" - "addq.l #8, %[z1]\n\t" - "movem.l (%[T]), %%d2-%%d3\n\t" - "addq.l #8, %[T]\n\t" - "bra.s 1f\n\t" - "0:\n\t" - "msac.l %%d1, %%d2, (%[T])+, %%a3, %%acc0\n\t" - "mac.l %%d0, %%d3, (%[T])+, %%a4, %%acc0\n\t" - - "msac.l %%d1, %%d3, -(%[z2]), %%d1, %%acc1\n\t" - "msac.l %%d0, %%d2, -(%[z2]), %%d0, %%acc1\n\t" - - "msac.l %%d1, %%a4, (%[T])+, %%d2, %%acc2\n\t" - "mac.l %%d0, %%a3, (%[T])+, %%d3, %%acc2\n\t" - "msac.l %%d0, %%a4, (%[z1])+, %%d0, %%acc3\n\t" - "msac.l %%d1, %%a3, (%[z1])+, %%d1, %%acc3\n\t" - - "movclr.l %%acc0, %%a3\n\t" - "movclr.l %%acc3, %%a4\n\t" - "movem.l %%a3-%%a4, (-16, %[z1])\n\t" - - "movclr.l %%acc1, %%a4\n\t" - "movclr.l %%acc2, %%a3\n\t" - "movem.l %%a3-%%a4, (%[z2])\n\t" - - "subq.l #2, %[n]\n\t" - "1:\n\t" - "bhi.s 0b\n\t" - : [z1] "+a" (z1), [z2] "+a" (z2), [T] "+a" (T), [n] "+d" (c) - : - : "d0", "d1", "d2", "d3", "a3", "a4", "cc", "memory"); - } - else - { - asm volatile ("movem.l (%[z1]), %%d0-%%d1\n\t" - "addq.l #8, %[z1]\n\t" - "movem.l (%[T]), %%d2-%%d3\n\t" - "lea (%[newstep]*4, %[T]), %[T]\n\t" - "bra.s 1f\n\t" - "0:\n\t" - "msac.l %%d1, %%d2, (%[T]), %%a3, %%acc0\n\t" - "mac.l %%d0, %%d3, (4, %[T]), %%a4, %%acc0\n\t" - "msac.l %%d1, %%d3, -(%[z2]), %%d1, %%acc1\n\t" - "msac.l %%d0, %%d2, -(%[z2]), %%d0, %%acc1\n\t" - - "lea (%[newstep]*4, %[T]), %[T]\n\t" - "msac.l %%d1, %%a4, (%[T]), %%d2, %%acc2\n\t" - "mac.l %%d0, %%a3, (4, %[T]), %%d3, %%acc2\n\t" - "msac.l %%d0, %%a4, (%[z1])+, %%d0, %%acc3\n\t" - "msac.l %%d1, %%a3, (%[z1])+, %%d1, %%acc3\n\t" - - "lea (%[newstep]*4, %[T]), %[T]\n\t" - - "movclr.l %%acc0, %%a3\n\t" - "movclr.l %%acc3, %%a4\n\t" - "movem.l %%a3-%%a4, (-16, %[z1])\n\t" - - "movclr.l %%acc1, %%a4\n\t" - "movclr.l %%acc2, %%a3\n\t" - "movem.l %%a3-%%a4, (%[z2])\n\t" - - "subq.l #2, %[n]\n\t" - "1:\n\t" - "bhi.s 0b\n\t" - : [z1] "+a" (z1), [z2] "+a" (z2), [T] "+a" (T), [n] "+d" (c) - : [newstep] "d" (newstep) - : "d0", "d1", "d2", "d3", "a3", "a4", "cc", "memory"); - } -#else - fixed32 * z2 = (fixed32 *)(&z[n4-1]); - while(z1>1; t1=T[1]>>1; - - while(z1>1)); - t1 += (v1 = (V[1]>>1)); - XNPROD31_R(z1[1], z1[0], t0, t1, r0, i1 ); - T+=2; - v0 += (t0 = (T[0]>>1)); - v1 += (t1 = (T[1]>>1)); - XNPROD31_R(z2[1], z2[0], v1, v0, r1, i0 ); - z1[0] = -r0; - z1[1] = -i0; - z2[0] = -r1; - z2[1] = -i1; - z1+=2; - z2-=2; - V+=2; - } - - break; - } - - case 13: /* n = 8192 */ - { - /* weight linear interpolation between sincos_lookup0 and sincos_lookup1 - specifically: 25:75 for first twiddle and 75:25 for second twiddle */ - const int32_t * V = sincos_lookup1; - T = sincos_lookup0; - int32_t t0,t1,v0,v1,q0,q1; - fixed32 * z1 = (fixed32 *)(&z[0]); - fixed32 * z2 = (fixed32 *)(&z[n4-1]); - - t0 = T[0]; t1=T[1]; - - while(z1>1); - t1 += (q1 = (v1-t1)>>1); - XNPROD31_R(z1[1], z1[0], t0, t1, r0, i1 ); - t0 = v0-q0; - t1 = v1-q1; - XNPROD31_R(z2[1], z2[0], t1, t0, r1, i0 ); - z1[0] = -r0; - z1[1] = -i0; - z2[0] = -r1; - z2[1] = -i1; - z1+=2; - z2-=2; - T+=2; - - t0 = T[0]; t1 = T[1]; - v0 += (q0 = (t0-v0)>>1); - v1 += (q1 = (t1-v1)>>1); - XNPROD31_R(z1[1], z1[0], v0, v1, r0, i1 ); - v0 = t0-q0; - v1 = t1-q1; - XNPROD31_R(z2[1], z2[0], v1, v0, r1, i0 ); - z1[0] = -r0; - z1[1] = -i0; - z2[0] = -r1; - z2[1] = -i1; - z1+=2; - z2-=2; - V+=2; - } - - break; - } - } -} - -/** - * Compute inverse MDCT of size N = 2^nbits - * @param output N samples - * @param input N/2 samples - * "In-place" processing can be achieved provided that: - * [0 .. N/2-1 | N/2 .. N-1 ] - * <----input----> - * <-----------output-----------> - * - * The result of ff_imdct_half is to put the 'half' imdct here - * - * N/2 N-1 - * <--half imdct--> - * - * We want it here for the full imdct: - * N/4 3N/4-1 - * <--------------> - * - * In addition we need to apply two symmetries to get the full imdct: - * - * - * - * - * D is a reflection of C - * A is a reflection of B (but with sign flipped) - * - * We process the symmetries at the same time as we 'move' the half imdct - * from [N/2,N-1] to [N/4,3N/4-1] - * - * TODO: find a way to make ff_imdct_half put the result in [N/4..3N/4-1] - * This would require being able to use revtab 'inplace' (since the input - * and output of imdct_half would then overlap somewhat) - */ -void ff_imdct_calc(unsigned int nbits, fixed32 *output, const fixed32 *input) ICODE_ATTR_TREMOR_MDCT; -#ifndef CPU_ARM -void ff_imdct_calc(unsigned int nbits, fixed32 *output, const fixed32 *input) -{ - const int n = (1<>1); - const int n4 = (n>>2); - - /* tell imdct_half to put the output in [N/2..3N/4-1] i.e. output+n2 */ - ff_imdct_half(nbits,output+n2,input); - - fixed32 * in_r, * in_r2, * out_r, * out_r2; - - /* Copy BBBB to AAAA, reflected and sign-flipped. - Also copy BBBB to its correct destination (from [N/2..3N/4-1] to [N/4..N/2-1]) */ - out_r = output; - out_r2 = output+n2-8; - in_r = output+n2+n4-8; - while(out_r <- ^b ^c -> <- ^d - * - * #1: copy from ^c to ^a - * #2: copy from ^d to ^b - * #3: swap ^c and ^d in place - */ - /* #1 pt1 : load 4 words from ^c. */ - t0=in_r[0]; t1=in_r[1]; t2=in_r[2]; t3=in_r[3]; - /* #1 pt2 : write to ^a */ - out_r[0]=t0;out_r[1]=t1;out_r[2]=t2;out_r[3]=t3; - /* #2 pt1 : load 4 words from ^d */ - s0=in_r2[0];s1=in_r2[1];s2=in_r2[2];s3=in_r2[3]; - /* #2 pt2 : write to ^b */ - out_r2[0]=s0;out_r2[1]=s1;out_r2[2]=s2;out_r2[3]=s3; - /* #3 pt1 : write words from #2 to ^c */ - in_r[0]=s3;in_r[1]=s2;in_r[2]=s1;in_r[3]=s0; - /* #3 pt2 : write words from #1 to ^d */ - in_r2[0]=t3;in_r2[1]=t2;in_r2[2]=t1;in_r2[3]=t0; - - in_r += 4; - in_r2 -= 4; - out_r += 4; - out_r2 -= 4; -#endif - } -} -#else -/* Follows the same structure as the canonical version above */ -void ff_imdct_calc(unsigned int nbits, fixed32 *output, const fixed32 *input) -{ - const int n = (1<>1); - const int n4 = (n>>2); - - ff_imdct_half(nbits,output+n2,input); - - fixed32 * in_r, * in_r2, * out_r, * out_r2; - - out_r = output; - out_r2 = output+n2; - in_r = output+n2+n4; - while(out_r>= 31; //16+31-16 = 31 bits - - return (fixed32)temp; -} -#endif - - -#ifdef CPU_ARM -static inline -void CMUL(fixed32 *x, fixed32 *y, - fixed32 a, fixed32 b, - fixed32 t, fixed32 v) -{ - /* This version loses one bit of precision. Could be solved at the cost - * of 2 extra cycles if it becomes an issue. */ - int x1, y1, l; - asm( - "smull %[l], %[y1], %[b], %[t] \n" - "smlal %[l], %[y1], %[a], %[v] \n" - "rsb %[b], %[b], #0 \n" - "smull %[l], %[x1], %[a], %[t] \n" - "smlal %[l], %[x1], %[b], %[v] \n" - : [l] "=&r" (l), [x1]"=&r" (x1), [y1]"=&r" (y1), [b] "+r" (b) - : [a] "r" (a), [t] "r" (t), [v] "r" (v) - : "cc" - ); - *x = x1 << 1; - *y = y1 << 1; -} -#elif defined CPU_COLDFIRE -static inline -void CMUL(fixed32 *x, fixed32 *y, - fixed32 a, fixed32 b, - fixed32 t, fixed32 v) -{ - asm volatile ("mac.l %[a], %[t], %%acc0;" - "msac.l %[b], %[v], %%acc0;" - "mac.l %[b], %[t], %%acc1;" - "mac.l %[a], %[v], %%acc1;" - "movclr.l %%acc0, %[a];" - "move.l %[a], (%[x]);" - "movclr.l %%acc1, %[a];" - "move.l %[a], (%[y]);" - : [a] "+&r" (a) - : [x] "a" (x), [y] "a" (y), - [b] "r" (b), [t] "r" (t), [v] "r" (v) - : "cc", "memory"); -} -#else -static inline -void CMUL(fixed32 *pre, - fixed32 *pim, - fixed32 are, - fixed32 aim, - fixed32 bre, - fixed32 bim) -{ - //int64_t x,y; - fixed32 _aref = are; - fixed32 _aimf = aim; - fixed32 _bref = bre; - fixed32 _bimf = bim; - fixed32 _r1 = fixmul32b(_bref, _aref); - fixed32 _r2 = fixmul32b(_bimf, _aimf); - fixed32 _r3 = fixmul32b(_bref, _aimf); - fixed32 _r4 = fixmul32b(_bimf, _aref); - *pre = _r1 - _r2; - *pim = _r3 + _r4; - -} -#endif - - -#endif // CODECLIB_MDCT_H_INCLUDED diff --git a/apps/codecs/lib/mdct_lookup.c b/apps/codecs/lib/mdct_lookup.c deleted file mode 100644 index a8ca748206..0000000000 --- a/apps/codecs/lib/mdct_lookup.c +++ /dev/null @@ -1,872 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2009 Michael Giacomelli - * - * - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ - -#ifdef ROCKBOX -#include -#else -#include -#include -#endif /* ROCKBOX */ - -/* {sin(2*i*PI/4096, cos(2*i*PI/4096)}, with i = 0 to 512 */ -const int32_t sincos_lookup0[1026] ICONST_ATTR = { - 0x00000000, 0x7fffffff, 0x003243f5, 0x7ffff621, - 0x006487e3, 0x7fffd886, 0x0096cbc1, 0x7fffa72c, - 0x00c90f88, 0x7fff6216, 0x00fb5330, 0x7fff0943, - 0x012d96b1, 0x7ffe9cb2, 0x015fda03, 0x7ffe1c65, - 0x01921d20, 0x7ffd885a, 0x01c45ffe, 0x7ffce093, - 0x01f6a297, 0x7ffc250f, 0x0228e4e2, 0x7ffb55ce, - 0x025b26d7, 0x7ffa72d1, 0x028d6870, 0x7ff97c18, - 0x02bfa9a4, 0x7ff871a2, 0x02f1ea6c, 0x7ff75370, - 0x03242abf, 0x7ff62182, 0x03566a96, 0x7ff4dbd9, - 0x0388a9ea, 0x7ff38274, 0x03bae8b2, 0x7ff21553, - 0x03ed26e6, 0x7ff09478, 0x041f6480, 0x7feeffe1, - 0x0451a177, 0x7fed5791, 0x0483ddc3, 0x7feb9b85, - 0x04b6195d, 0x7fe9cbc0, 0x04e8543e, 0x7fe7e841, - 0x051a8e5c, 0x7fe5f108, 0x054cc7b1, 0x7fe3e616, - 0x057f0035, 0x7fe1c76b, 0x05b137df, 0x7fdf9508, - 0x05e36ea9, 0x7fdd4eec, 0x0615a48b, 0x7fdaf519, - 0x0647d97c, 0x7fd8878e, 0x067a0d76, 0x7fd6064c, - 0x06ac406f, 0x7fd37153, 0x06de7262, 0x7fd0c8a3, - 0x0710a345, 0x7fce0c3e, 0x0742d311, 0x7fcb3c23, - 0x077501be, 0x7fc85854, 0x07a72f45, 0x7fc560cf, - 0x07d95b9e, 0x7fc25596, 0x080b86c2, 0x7fbf36aa, - 0x083db0a7, 0x7fbc040a, 0x086fd947, 0x7fb8bdb8, - 0x08a2009a, 0x7fb563b3, 0x08d42699, 0x7fb1f5fc, - 0x09064b3a, 0x7fae7495, 0x09386e78, 0x7faadf7c, - 0x096a9049, 0x7fa736b4, 0x099cb0a7, 0x7fa37a3c, - 0x09cecf89, 0x7f9faa15, 0x0a00ece8, 0x7f9bc640, - 0x0a3308bd, 0x7f97cebd, 0x0a6522fe, 0x7f93c38c, - 0x0a973ba5, 0x7f8fa4b0, 0x0ac952aa, 0x7f8b7227, - 0x0afb6805, 0x7f872bf3, 0x0b2d7baf, 0x7f82d214, - 0x0b5f8d9f, 0x7f7e648c, 0x0b919dcf, 0x7f79e35a, - 0x0bc3ac35, 0x7f754e80, 0x0bf5b8cb, 0x7f70a5fe, - 0x0c27c389, 0x7f6be9d4, 0x0c59cc68, 0x7f671a05, - 0x0c8bd35e, 0x7f62368f, 0x0cbdd865, 0x7f5d3f75, - 0x0cefdb76, 0x7f5834b7, 0x0d21dc87, 0x7f531655, - 0x0d53db92, 0x7f4de451, 0x0d85d88f, 0x7f489eaa, - 0x0db7d376, 0x7f434563, 0x0de9cc40, 0x7f3dd87c, - 0x0e1bc2e4, 0x7f3857f6, 0x0e4db75b, 0x7f32c3d1, - 0x0e7fa99e, 0x7f2d1c0e, 0x0eb199a4, 0x7f2760af, - 0x0ee38766, 0x7f2191b4, 0x0f1572dc, 0x7f1baf1e, - 0x0f475bff, 0x7f15b8ee, 0x0f7942c7, 0x7f0faf25, - 0x0fab272b, 0x7f0991c4, 0x0fdd0926, 0x7f0360cb, - 0x100ee8ad, 0x7efd1c3c, 0x1040c5bb, 0x7ef6c418, - 0x1072a048, 0x7ef05860, 0x10a4784b, 0x7ee9d914, - 0x10d64dbd, 0x7ee34636, 0x11082096, 0x7edc9fc6, - 0x1139f0cf, 0x7ed5e5c6, 0x116bbe60, 0x7ecf1837, - 0x119d8941, 0x7ec8371a, 0x11cf516a, 0x7ec14270, - 0x120116d5, 0x7eba3a39, 0x1232d979, 0x7eb31e78, - 0x1264994e, 0x7eabef2c, 0x1296564d, 0x7ea4ac58, - 0x12c8106f, 0x7e9d55fc, 0x12f9c7aa, 0x7e95ec1a, - 0x132b7bf9, 0x7e8e6eb2, 0x135d2d53, 0x7e86ddc6, - 0x138edbb1, 0x7e7f3957, 0x13c0870a, 0x7e778166, - 0x13f22f58, 0x7e6fb5f4, 0x1423d492, 0x7e67d703, - 0x145576b1, 0x7e5fe493, 0x148715ae, 0x7e57dea7, - 0x14b8b17f, 0x7e4fc53e, 0x14ea4a1f, 0x7e47985b, - 0x151bdf86, 0x7e3f57ff, 0x154d71aa, 0x7e37042a, - 0x157f0086, 0x7e2e9cdf, 0x15b08c12, 0x7e26221f, - 0x15e21445, 0x7e1d93ea, 0x16139918, 0x7e14f242, - 0x16451a83, 0x7e0c3d29, 0x1676987f, 0x7e0374a0, - 0x16a81305, 0x7dfa98a8, 0x16d98a0c, 0x7df1a942, - 0x170afd8d, 0x7de8a670, 0x173c6d80, 0x7ddf9034, - 0x176dd9de, 0x7dd6668f, 0x179f429f, 0x7dcd2981, - 0x17d0a7bc, 0x7dc3d90d, 0x1802092c, 0x7dba7534, - 0x183366e9, 0x7db0fdf8, 0x1864c0ea, 0x7da77359, - 0x18961728, 0x7d9dd55a, 0x18c7699b, 0x7d9423fc, - 0x18f8b83c, 0x7d8a5f40, 0x192a0304, 0x7d808728, - 0x195b49ea, 0x7d769bb5, 0x198c8ce7, 0x7d6c9ce9, - 0x19bdcbf3, 0x7d628ac6, 0x19ef0707, 0x7d58654d, - 0x1a203e1b, 0x7d4e2c7f, 0x1a517128, 0x7d43e05e, - 0x1a82a026, 0x7d3980ec, 0x1ab3cb0d, 0x7d2f0e2b, - 0x1ae4f1d6, 0x7d24881b, 0x1b161479, 0x7d19eebf, - 0x1b4732ef, 0x7d0f4218, 0x1b784d30, 0x7d048228, - 0x1ba96335, 0x7cf9aef0, 0x1bda74f6, 0x7ceec873, - 0x1c0b826a, 0x7ce3ceb2, 0x1c3c8b8c, 0x7cd8c1ae, - 0x1c6d9053, 0x7ccda169, 0x1c9e90b8, 0x7cc26de5, - 0x1ccf8cb3, 0x7cb72724, 0x1d00843d, 0x7cabcd28, - 0x1d31774d, 0x7ca05ff1, 0x1d6265dd, 0x7c94df83, - 0x1d934fe5, 0x7c894bde, 0x1dc4355e, 0x7c7da505, - 0x1df5163f, 0x7c71eaf9, 0x1e25f282, 0x7c661dbc, - 0x1e56ca1e, 0x7c5a3d50, 0x1e879d0d, 0x7c4e49b7, - 0x1eb86b46, 0x7c4242f2, 0x1ee934c3, 0x7c362904, - 0x1f19f97b, 0x7c29fbee, 0x1f4ab968, 0x7c1dbbb3, - 0x1f7b7481, 0x7c116853, 0x1fac2abf, 0x7c0501d2, - 0x1fdcdc1b, 0x7bf88830, 0x200d888d, 0x7bebfb70, - 0x203e300d, 0x7bdf5b94, 0x206ed295, 0x7bd2a89e, - 0x209f701c, 0x7bc5e290, 0x20d0089c, 0x7bb9096b, - 0x21009c0c, 0x7bac1d31, 0x21312a65, 0x7b9f1de6, - 0x2161b3a0, 0x7b920b89, 0x219237b5, 0x7b84e61f, - 0x21c2b69c, 0x7b77ada8, 0x21f3304f, 0x7b6a6227, - 0x2223a4c5, 0x7b5d039e, 0x225413f8, 0x7b4f920e, - 0x22847de0, 0x7b420d7a, 0x22b4e274, 0x7b3475e5, - 0x22e541af, 0x7b26cb4f, 0x23159b88, 0x7b190dbc, - 0x2345eff8, 0x7b0b3d2c, 0x23763ef7, 0x7afd59a4, - 0x23a6887f, 0x7aef6323, 0x23d6cc87, 0x7ae159ae, - 0x24070b08, 0x7ad33d45, 0x243743fa, 0x7ac50dec, - 0x24677758, 0x7ab6cba4, 0x2497a517, 0x7aa8766f, - 0x24c7cd33, 0x7a9a0e50, 0x24f7efa2, 0x7a8b9348, - 0x25280c5e, 0x7a7d055b, 0x2558235f, 0x7a6e648a, - 0x2588349d, 0x7a5fb0d8, 0x25b84012, 0x7a50ea47, - 0x25e845b6, 0x7a4210d8, 0x26184581, 0x7a332490, - 0x26483f6c, 0x7a24256f, 0x26783370, 0x7a151378, - 0x26a82186, 0x7a05eead, 0x26d809a5, 0x79f6b711, - 0x2707ebc7, 0x79e76ca7, 0x2737c7e3, 0x79d80f6f, - 0x27679df4, 0x79c89f6e, 0x27976df1, 0x79b91ca4, - 0x27c737d3, 0x79a98715, 0x27f6fb92, 0x7999dec4, - 0x2826b928, 0x798a23b1, 0x2856708d, 0x797a55e0, - 0x288621b9, 0x796a7554, 0x28b5cca5, 0x795a820e, - 0x28e5714b, 0x794a7c12, 0x29150fa1, 0x793a6361, - 0x2944a7a2, 0x792a37fe, 0x29743946, 0x7919f9ec, - 0x29a3c485, 0x7909a92d, 0x29d34958, 0x78f945c3, - 0x2a02c7b8, 0x78e8cfb2, 0x2a323f9e, 0x78d846fb, - 0x2a61b101, 0x78c7aba2, 0x2a911bdc, 0x78b6fda8, - 0x2ac08026, 0x78a63d11, 0x2aefddd8, 0x789569df, - 0x2b1f34eb, 0x78848414, 0x2b4e8558, 0x78738bb3, - 0x2b7dcf17, 0x786280bf, 0x2bad1221, 0x7851633b, - 0x2bdc4e6f, 0x78403329, 0x2c0b83fa, 0x782ef08b, - 0x2c3ab2b9, 0x781d9b65, 0x2c69daa6, 0x780c33b8, - 0x2c98fbba, 0x77fab989, 0x2cc815ee, 0x77e92cd9, - 0x2cf72939, 0x77d78daa, 0x2d263596, 0x77c5dc01, - 0x2d553afc, 0x77b417df, 0x2d843964, 0x77a24148, - 0x2db330c7, 0x7790583e, 0x2de2211e, 0x777e5cc3, - 0x2e110a62, 0x776c4edb, 0x2e3fec8b, 0x775a2e89, - 0x2e6ec792, 0x7747fbce, 0x2e9d9b70, 0x7735b6af, - 0x2ecc681e, 0x77235f2d, 0x2efb2d95, 0x7710f54c, - 0x2f29ebcc, 0x76fe790e, 0x2f58a2be, 0x76ebea77, - 0x2f875262, 0x76d94989, 0x2fb5fab2, 0x76c69647, - 0x2fe49ba7, 0x76b3d0b4, 0x30133539, 0x76a0f8d2, - 0x3041c761, 0x768e0ea6, 0x30705217, 0x767b1231, - 0x309ed556, 0x76680376, 0x30cd5115, 0x7654e279, - 0x30fbc54d, 0x7641af3d, 0x312a31f8, 0x762e69c4, - 0x3158970e, 0x761b1211, 0x3186f487, 0x7607a828, - 0x31b54a5e, 0x75f42c0b, 0x31e39889, 0x75e09dbd, - 0x3211df04, 0x75ccfd42, 0x32401dc6, 0x75b94a9c, - 0x326e54c7, 0x75a585cf, 0x329c8402, 0x7591aedd, - 0x32caab6f, 0x757dc5ca, 0x32f8cb07, 0x7569ca99, - 0x3326e2c3, 0x7555bd4c, 0x3354f29b, 0x75419de7, - 0x3382fa88, 0x752d6c6c, 0x33b0fa84, 0x751928e0, - 0x33def287, 0x7504d345, 0x340ce28b, 0x74f06b9e, - 0x343aca87, 0x74dbf1ef, 0x3468aa76, 0x74c7663a, - 0x34968250, 0x74b2c884, 0x34c4520d, 0x749e18cd, - 0x34f219a8, 0x7489571c, 0x351fd918, 0x74748371, - 0x354d9057, 0x745f9dd1, 0x357b3f5d, 0x744aa63f, - 0x35a8e625, 0x74359cbd, 0x35d684a6, 0x74208150, - 0x36041ad9, 0x740b53fb, 0x3631a8b8, 0x73f614c0, - 0x365f2e3b, 0x73e0c3a3, 0x368cab5c, 0x73cb60a8, - 0x36ba2014, 0x73b5ebd1, 0x36e78c5b, 0x73a06522, - 0x3714f02a, 0x738acc9e, 0x37424b7b, 0x73752249, - 0x376f9e46, 0x735f6626, 0x379ce885, 0x73499838, - 0x37ca2a30, 0x7333b883, 0x37f76341, 0x731dc70a, - 0x382493b0, 0x7307c3d0, 0x3851bb77, 0x72f1aed9, - 0x387eda8e, 0x72db8828, 0x38abf0ef, 0x72c54fc1, - 0x38d8fe93, 0x72af05a7, 0x39060373, 0x7298a9dd, - 0x3932ff87, 0x72823c67, 0x395ff2c9, 0x726bbd48, - 0x398cdd32, 0x72552c85, 0x39b9bebc, 0x723e8a20, - 0x39e6975e, 0x7227d61c, 0x3a136712, 0x7211107e, - 0x3a402dd2, 0x71fa3949, 0x3a6ceb96, 0x71e35080, - 0x3a99a057, 0x71cc5626, 0x3ac64c0f, 0x71b54a41, - 0x3af2eeb7, 0x719e2cd2, 0x3b1f8848, 0x7186fdde, - 0x3b4c18ba, 0x716fbd68, 0x3b78a007, 0x71586b74, - 0x3ba51e29, 0x71410805, 0x3bd19318, 0x7129931f, - 0x3bfdfecd, 0x71120cc5, 0x3c2a6142, 0x70fa74fc, - 0x3c56ba70, 0x70e2cbc6, 0x3c830a50, 0x70cb1128, - 0x3caf50da, 0x70b34525, 0x3cdb8e09, 0x709b67c0, - 0x3d07c1d6, 0x708378ff, 0x3d33ec39, 0x706b78e3, - 0x3d600d2c, 0x70536771, 0x3d8c24a8, 0x703b44ad, - 0x3db832a6, 0x7023109a, 0x3de4371f, 0x700acb3c, - 0x3e10320d, 0x6ff27497, 0x3e3c2369, 0x6fda0cae, - 0x3e680b2c, 0x6fc19385, 0x3e93e950, 0x6fa90921, - 0x3ebfbdcd, 0x6f906d84, 0x3eeb889c, 0x6f77c0b3, - 0x3f1749b8, 0x6f5f02b2, 0x3f430119, 0x6f463383, - 0x3f6eaeb8, 0x6f2d532c, 0x3f9a5290, 0x6f1461b0, - 0x3fc5ec98, 0x6efb5f12, 0x3ff17cca, 0x6ee24b57, - 0x401d0321, 0x6ec92683, 0x40487f94, 0x6eaff099, - 0x4073f21d, 0x6e96a99d, 0x409f5ab6, 0x6e7d5193, - 0x40cab958, 0x6e63e87f, 0x40f60dfb, 0x6e4a6e66, - 0x4121589b, 0x6e30e34a, 0x414c992f, 0x6e174730, - 0x4177cfb1, 0x6dfd9a1c, 0x41a2fc1a, 0x6de3dc11, - 0x41ce1e65, 0x6dca0d14, 0x41f93689, 0x6db02d29, - 0x42244481, 0x6d963c54, 0x424f4845, 0x6d7c3a98, - 0x427a41d0, 0x6d6227fa, 0x42a5311b, 0x6d48047e, - 0x42d0161e, 0x6d2dd027, 0x42faf0d4, 0x6d138afb, - 0x4325c135, 0x6cf934fc, 0x4350873c, 0x6cdece2f, - 0x437b42e1, 0x6cc45698, 0x43a5f41e, 0x6ca9ce3b, - 0x43d09aed, 0x6c8f351c, 0x43fb3746, 0x6c748b3f, - 0x4425c923, 0x6c59d0a9, 0x4450507e, 0x6c3f055d, - 0x447acd50, 0x6c242960, 0x44a53f93, 0x6c093cb6, - 0x44cfa740, 0x6bee3f62, 0x44fa0450, 0x6bd3316a, - 0x452456bd, 0x6bb812d1, 0x454e9e80, 0x6b9ce39b, - 0x4578db93, 0x6b81a3cd, 0x45a30df0, 0x6b66536b, - 0x45cd358f, 0x6b4af279, 0x45f7526b, 0x6b2f80fb, - 0x4621647d, 0x6b13fef5, 0x464b6bbe, 0x6af86c6c, - 0x46756828, 0x6adcc964, 0x469f59b4, 0x6ac115e2, - 0x46c9405c, 0x6aa551e9, 0x46f31c1a, 0x6a897d7d, - 0x471cece7, 0x6a6d98a4, 0x4746b2bc, 0x6a51a361, - 0x47706d93, 0x6a359db9, 0x479a1d67, 0x6a1987b0, - 0x47c3c22f, 0x69fd614a, 0x47ed5be6, 0x69e12a8c, - 0x4816ea86, 0x69c4e37a, 0x48406e08, 0x69a88c19, - 0x4869e665, 0x698c246c, 0x48935397, 0x696fac78, - 0x48bcb599, 0x69532442, 0x48e60c62, 0x69368bce, - 0x490f57ee, 0x6919e320, 0x49389836, 0x68fd2a3d, - 0x4961cd33, 0x68e06129, 0x498af6df, 0x68c387e9, - 0x49b41533, 0x68a69e81, 0x49dd282a, 0x6889a4f6, - 0x4a062fbd, 0x686c9b4b, 0x4a2f2be6, 0x684f8186, - 0x4a581c9e, 0x683257ab, 0x4a8101de, 0x68151dbe, - 0x4aa9dba2, 0x67f7d3c5, 0x4ad2a9e2, 0x67da79c3, - 0x4afb6c98, 0x67bd0fbd, 0x4b2423be, 0x679f95b7, - 0x4b4ccf4d, 0x67820bb7, 0x4b756f40, 0x676471c0, - 0x4b9e0390, 0x6746c7d8, 0x4bc68c36, 0x67290e02, - 0x4bef092d, 0x670b4444, 0x4c177a6e, 0x66ed6aa1, - 0x4c3fdff4, 0x66cf8120, 0x4c6839b7, 0x66b187c3, - 0x4c9087b1, 0x66937e91, 0x4cb8c9dd, 0x6675658c, - 0x4ce10034, 0x66573cbb, 0x4d092ab0, 0x66390422, - 0x4d31494b, 0x661abbc5, 0x4d595bfe, 0x65fc63a9, - 0x4d8162c4, 0x65ddfbd3, 0x4da95d96, 0x65bf8447, - 0x4dd14c6e, 0x65a0fd0b, 0x4df92f46, 0x65826622, - 0x4e210617, 0x6563bf92, 0x4e48d0dd, 0x6545095f, - 0x4e708f8f, 0x6526438f, 0x4e984229, 0x65076e25, - 0x4ebfe8a5, 0x64e88926, 0x4ee782fb, 0x64c99498, - 0x4f0f1126, 0x64aa907f, 0x4f369320, 0x648b7ce0, - 0x4f5e08e3, 0x646c59bf, 0x4f857269, 0x644d2722, - 0x4faccfab, 0x642de50d, 0x4fd420a4, 0x640e9386, - 0x4ffb654d, 0x63ef3290, 0x50229da1, 0x63cfc231, - 0x5049c999, 0x63b0426d, 0x5070e92f, 0x6390b34a, - 0x5097fc5e, 0x637114cc, 0x50bf031f, 0x635166f9, - 0x50e5fd6d, 0x6331a9d4, 0x510ceb40, 0x6311dd64, - 0x5133cc94, 0x62f201ac, 0x515aa162, 0x62d216b3, - 0x518169a5, 0x62b21c7b, 0x51a82555, 0x6292130c, - 0x51ced46e, 0x6271fa69, 0x51f576ea, 0x6251d298, - 0x521c0cc2, 0x62319b9d, 0x524295f0, 0x6211557e, - 0x5269126e, 0x61f1003f, 0x528f8238, 0x61d09be5, - 0x52b5e546, 0x61b02876, 0x52dc3b92, 0x618fa5f7, - 0x53028518, 0x616f146c, 0x5328c1d0, 0x614e73da, - 0x534ef1b5, 0x612dc447, 0x537514c2, 0x610d05b7, - 0x539b2af0, 0x60ec3830, 0x53c13439, 0x60cb5bb7, - 0x53e73097, 0x60aa7050, 0x540d2005, 0x60897601, - 0x5433027d, 0x60686ccf, 0x5458d7f9, 0x604754bf, - 0x547ea073, 0x60262dd6, 0x54a45be6, 0x6004f819, - 0x54ca0a4b, 0x5fe3b38d, 0x54efab9c, 0x5fc26038, - 0x55153fd4, 0x5fa0fe1f, 0x553ac6ee, 0x5f7f8d46, - 0x556040e2, 0x5f5e0db3, 0x5585adad, 0x5f3c7f6b, - 0x55ab0d46, 0x5f1ae274, 0x55d05faa, 0x5ef936d1, - 0x55f5a4d2, 0x5ed77c8a, 0x561adcb9, 0x5eb5b3a2, - 0x56400758, 0x5e93dc1f, 0x566524aa, 0x5e71f606, - 0x568a34a9, 0x5e50015d, 0x56af3750, 0x5e2dfe29, - 0x56d42c99, 0x5e0bec6e, 0x56f9147e, 0x5de9cc33, - 0x571deefa, 0x5dc79d7c, 0x5742bc06, 0x5da5604f, - 0x57677b9d, 0x5d8314b1, 0x578c2dba, 0x5d60baa7, - 0x57b0d256, 0x5d3e5237, 0x57d5696d, 0x5d1bdb65, - 0x57f9f2f8, 0x5cf95638, 0x581e6ef1, 0x5cd6c2b5, - 0x5842dd54, 0x5cb420e0, 0x58673e1b, 0x5c9170bf, - 0x588b9140, 0x5c6eb258, 0x58afd6bd, 0x5c4be5b0, - 0x58d40e8c, 0x5c290acc, 0x58f838a9, 0x5c0621b2, - 0x591c550e, 0x5be32a67, 0x594063b5, 0x5bc024f0, - 0x59646498, 0x5b9d1154, 0x598857b2, 0x5b79ef96, - 0x59ac3cfd, 0x5b56bfbd, 0x59d01475, 0x5b3381ce, - 0x59f3de12, 0x5b1035cf, 0x5a1799d1, 0x5aecdbc5, - 0x5a3b47ab, 0x5ac973b5, 0x5a5ee79a, 0x5aa5fda5, - 0x5a82799a, 0x5a82799a - }; - - /* {sin((2*i+1)*PI/4096, cos((2*i+1)*PI/4096)}, with i = 0 to 511 */ -const int32_t sincos_lookup1[1024] ICONST_ATTR = { - 0x001921fb, 0x7ffffd88, 0x004b65ee, 0x7fffe9cb, - 0x007da9d4, 0x7fffc251, 0x00afeda8, 0x7fff8719, - 0x00e23160, 0x7fff3824, 0x011474f6, 0x7ffed572, - 0x0146b860, 0x7ffe5f03, 0x0178fb99, 0x7ffdd4d7, - 0x01ab3e97, 0x7ffd36ee, 0x01dd8154, 0x7ffc8549, - 0x020fc3c6, 0x7ffbbfe6, 0x024205e8, 0x7ffae6c7, - 0x027447b0, 0x7ff9f9ec, 0x02a68917, 0x7ff8f954, - 0x02d8ca16, 0x7ff7e500, 0x030b0aa4, 0x7ff6bcf0, - 0x033d4abb, 0x7ff58125, 0x036f8a51, 0x7ff4319d, - 0x03a1c960, 0x7ff2ce5b, 0x03d407df, 0x7ff1575d, - 0x040645c7, 0x7fefcca4, 0x04388310, 0x7fee2e30, - 0x046abfb3, 0x7fec7c02, 0x049cfba7, 0x7feab61a, - 0x04cf36e5, 0x7fe8dc78, 0x05017165, 0x7fe6ef1c, - 0x0533ab20, 0x7fe4ee06, 0x0565e40d, 0x7fe2d938, - 0x05981c26, 0x7fe0b0b1, 0x05ca5361, 0x7fde7471, - 0x05fc89b8, 0x7fdc247a, 0x062ebf22, 0x7fd9c0ca, - 0x0660f398, 0x7fd74964, 0x06932713, 0x7fd4be46, - 0x06c5598a, 0x7fd21f72, 0x06f78af6, 0x7fcf6ce8, - 0x0729bb4e, 0x7fcca6a7, 0x075bea8c, 0x7fc9ccb2, - 0x078e18a7, 0x7fc6df08, 0x07c04598, 0x7fc3dda9, - 0x07f27157, 0x7fc0c896, 0x08249bdd, 0x7fbd9fd0, - 0x0856c520, 0x7fba6357, 0x0888ed1b, 0x7fb7132b, - 0x08bb13c5, 0x7fb3af4e, 0x08ed3916, 0x7fb037bf, - 0x091f5d06, 0x7facac7f, 0x09517f8f, 0x7fa90d8e, - 0x0983a0a7, 0x7fa55aee, 0x09b5c048, 0x7fa1949e, - 0x09e7de6a, 0x7f9dbaa0, 0x0a19fb04, 0x7f99ccf4, - 0x0a4c1610, 0x7f95cb9a, 0x0a7e2f85, 0x7f91b694, - 0x0ab0475c, 0x7f8d8de1, 0x0ae25d8d, 0x7f895182, - 0x0b147211, 0x7f850179, 0x0b4684df, 0x7f809dc5, - 0x0b7895f0, 0x7f7c2668, 0x0baaa53b, 0x7f779b62, - 0x0bdcb2bb, 0x7f72fcb4, 0x0c0ebe66, 0x7f6e4a5e, - 0x0c40c835, 0x7f698461, 0x0c72d020, 0x7f64aabf, - 0x0ca4d620, 0x7f5fbd77, 0x0cd6da2d, 0x7f5abc8a, - 0x0d08dc3f, 0x7f55a7fa, 0x0d3adc4e, 0x7f507fc7, - 0x0d6cda53, 0x7f4b43f2, 0x0d9ed646, 0x7f45f47b, - 0x0dd0d01f, 0x7f409164, 0x0e02c7d7, 0x7f3b1aad, - 0x0e34bd66, 0x7f359057, 0x0e66b0c3, 0x7f2ff263, - 0x0e98a1e9, 0x7f2a40d2, 0x0eca90ce, 0x7f247ba5, - 0x0efc7d6b, 0x7f1ea2dc, 0x0f2e67b8, 0x7f18b679, - 0x0f604faf, 0x7f12b67c, 0x0f923546, 0x7f0ca2e7, - 0x0fc41876, 0x7f067bba, 0x0ff5f938, 0x7f0040f6, - 0x1027d784, 0x7ef9f29d, 0x1059b352, 0x7ef390ae, - 0x108b8c9b, 0x7eed1b2c, 0x10bd6356, 0x7ee69217, - 0x10ef377d, 0x7edff570, 0x11210907, 0x7ed94538, - 0x1152d7ed, 0x7ed28171, 0x1184a427, 0x7ecbaa1a, - 0x11b66dad, 0x7ec4bf36, 0x11e83478, 0x7ebdc0c6, - 0x1219f880, 0x7eb6aeca, 0x124bb9be, 0x7eaf8943, - 0x127d7829, 0x7ea85033, 0x12af33ba, 0x7ea1039b, - 0x12e0ec6a, 0x7e99a37c, 0x1312a230, 0x7e922fd6, - 0x13445505, 0x7e8aa8ac, 0x137604e2, 0x7e830dff, - 0x13a7b1bf, 0x7e7b5fce, 0x13d95b93, 0x7e739e1d, - 0x140b0258, 0x7e6bc8eb, 0x143ca605, 0x7e63e03b, - 0x146e4694, 0x7e5be40c, 0x149fe3fc, 0x7e53d462, - 0x14d17e36, 0x7e4bb13c, 0x1503153a, 0x7e437a9c, - 0x1534a901, 0x7e3b3083, 0x15663982, 0x7e32d2f4, - 0x1597c6b7, 0x7e2a61ed, 0x15c95097, 0x7e21dd73, - 0x15fad71b, 0x7e194584, 0x162c5a3b, 0x7e109a24, - 0x165dd9f0, 0x7e07db52, 0x168f5632, 0x7dff0911, - 0x16c0cef9, 0x7df62362, 0x16f2443e, 0x7ded2a47, - 0x1723b5f9, 0x7de41dc0, 0x17552422, 0x7ddafdce, - 0x17868eb3, 0x7dd1ca75, 0x17b7f5a3, 0x7dc883b4, - 0x17e958ea, 0x7dbf298d, 0x181ab881, 0x7db5bc02, - 0x184c1461, 0x7dac3b15, 0x187d6c82, 0x7da2a6c6, - 0x18aec0db, 0x7d98ff17, 0x18e01167, 0x7d8f4409, - 0x19115e1c, 0x7d85759f, 0x1942a6f3, 0x7d7b93da, - 0x1973ebe6, 0x7d719eba, 0x19a52ceb, 0x7d679642, - 0x19d669fc, 0x7d5d7a74, 0x1a07a311, 0x7d534b50, - 0x1a38d823, 0x7d4908d9, 0x1a6a0929, 0x7d3eb30f, - 0x1a9b361d, 0x7d3449f5, 0x1acc5ef6, 0x7d29cd8c, - 0x1afd83ad, 0x7d1f3dd6, 0x1b2ea43a, 0x7d149ad5, - 0x1b5fc097, 0x7d09e489, 0x1b90d8bb, 0x7cff1af5, - 0x1bc1ec9e, 0x7cf43e1a, 0x1bf2fc3a, 0x7ce94dfb, - 0x1c240786, 0x7cde4a98, 0x1c550e7c, 0x7cd333f3, - 0x1c861113, 0x7cc80a0f, 0x1cb70f43, 0x7cbcccec, - 0x1ce80906, 0x7cb17c8d, 0x1d18fe54, 0x7ca618f3, - 0x1d49ef26, 0x7c9aa221, 0x1d7adb73, 0x7c8f1817, - 0x1dabc334, 0x7c837ad8, 0x1ddca662, 0x7c77ca65, - 0x1e0d84f5, 0x7c6c06c0, 0x1e3e5ee5, 0x7c602fec, - 0x1e6f342c, 0x7c5445e9, 0x1ea004c1, 0x7c4848ba, - 0x1ed0d09d, 0x7c3c3860, 0x1f0197b8, 0x7c3014de, - 0x1f325a0b, 0x7c23de35, 0x1f63178f, 0x7c179467, - 0x1f93d03c, 0x7c0b3777, 0x1fc4840a, 0x7bfec765, - 0x1ff532f2, 0x7bf24434, 0x2025dcec, 0x7be5ade6, - 0x205681f1, 0x7bd9047c, 0x208721f9, 0x7bcc47fa, - 0x20b7bcfe, 0x7bbf7860, 0x20e852f6, 0x7bb295b0, - 0x2118e3dc, 0x7ba59fee, 0x21496fa7, 0x7b989719, - 0x2179f64f, 0x7b8b7b36, 0x21aa77cf, 0x7b7e4c45, - 0x21daf41d, 0x7b710a49, 0x220b6b32, 0x7b63b543, - 0x223bdd08, 0x7b564d36, 0x226c4996, 0x7b48d225, - 0x229cb0d5, 0x7b3b4410, 0x22cd12bd, 0x7b2da2fa, - 0x22fd6f48, 0x7b1feee5, 0x232dc66d, 0x7b1227d3, - 0x235e1826, 0x7b044dc7, 0x238e646a, 0x7af660c2, - 0x23beab33, 0x7ae860c7, 0x23eeec78, 0x7ada4dd8, - 0x241f2833, 0x7acc27f7, 0x244f5e5c, 0x7abdef25, - 0x247f8eec, 0x7aafa367, 0x24afb9da, 0x7aa144bc, - 0x24dfdf20, 0x7a92d329, 0x250ffeb7, 0x7a844eae, - 0x25401896, 0x7a75b74f, 0x25702cb7, 0x7a670d0d, - 0x25a03b11, 0x7a584feb, 0x25d0439f, 0x7a497feb, - 0x26004657, 0x7a3a9d0f, 0x26304333, 0x7a2ba75a, - 0x26603a2c, 0x7a1c9ece, 0x26902b39, 0x7a0d836d, - 0x26c01655, 0x79fe5539, 0x26effb76, 0x79ef1436, - 0x271fda96, 0x79dfc064, 0x274fb3ae, 0x79d059c8, - 0x277f86b5, 0x79c0e062, 0x27af53a6, 0x79b15435, - 0x27df1a77, 0x79a1b545, 0x280edb23, 0x79920392, - 0x283e95a1, 0x79823f20, 0x286e49ea, 0x797267f2, - 0x289df7f8, 0x79627e08, 0x28cd9fc1, 0x79528167, - 0x28fd4140, 0x79427210, 0x292cdc6d, 0x79325006, - 0x295c7140, 0x79221b4b, 0x298bffb2, 0x7911d3e2, - 0x29bb87bc, 0x790179cd, 0x29eb0957, 0x78f10d0f, - 0x2a1a847b, 0x78e08dab, 0x2a49f920, 0x78cffba3, - 0x2a796740, 0x78bf56f9, 0x2aa8ced3, 0x78ae9fb0, - 0x2ad82fd2, 0x789dd5cb, 0x2b078a36, 0x788cf94c, - 0x2b36ddf7, 0x787c0a36, 0x2b662b0e, 0x786b088c, - 0x2b957173, 0x7859f44f, 0x2bc4b120, 0x7848cd83, - 0x2bf3ea0d, 0x7837942b, 0x2c231c33, 0x78264849, - 0x2c52478a, 0x7814e9df, 0x2c816c0c, 0x780378f1, - 0x2cb089b1, 0x77f1f581, 0x2cdfa071, 0x77e05f91, - 0x2d0eb046, 0x77ceb725, 0x2d3db928, 0x77bcfc3f, - 0x2d6cbb10, 0x77ab2ee2, 0x2d9bb5f6, 0x77994f11, - 0x2dcaa9d5, 0x77875cce, 0x2df996a3, 0x7775581d, - 0x2e287c5a, 0x776340ff, 0x2e575af3, 0x77511778, - 0x2e863267, 0x773edb8b, 0x2eb502ae, 0x772c8d3a, - 0x2ee3cbc1, 0x771a2c88, 0x2f128d99, 0x7707b979, - 0x2f41482e, 0x76f5340e, 0x2f6ffb7a, 0x76e29c4b, - 0x2f9ea775, 0x76cff232, 0x2fcd4c19, 0x76bd35c7, - 0x2ffbe95d, 0x76aa670d, 0x302a7f3a, 0x76978605, - 0x30590dab, 0x768492b4, 0x308794a6, 0x76718d1c, - 0x30b61426, 0x765e7540, 0x30e48c22, 0x764b4b23, - 0x3112fc95, 0x76380ec8, 0x31416576, 0x7624c031, - 0x316fc6be, 0x76115f63, 0x319e2067, 0x75fdec60, - 0x31cc7269, 0x75ea672a, 0x31fabcbd, 0x75d6cfc5, - 0x3228ff5c, 0x75c32634, 0x32573a3f, 0x75af6a7b, - 0x32856d5e, 0x759b9c9b, 0x32b398b3, 0x7587bc98, - 0x32e1bc36, 0x7573ca75, 0x330fd7e1, 0x755fc635, - 0x333debab, 0x754bafdc, 0x336bf78f, 0x7537876c, - 0x3399fb85, 0x75234ce8, 0x33c7f785, 0x750f0054, - 0x33f5eb89, 0x74faa1b3, 0x3423d78a, 0x74e63108, - 0x3451bb81, 0x74d1ae55, 0x347f9766, 0x74bd199f, - 0x34ad6b32, 0x74a872e8, 0x34db36df, 0x7493ba34, - 0x3508fa66, 0x747eef85, 0x3536b5be, 0x746a12df, - 0x356468e2, 0x74552446, 0x359213c9, 0x744023bc, - 0x35bfb66e, 0x742b1144, 0x35ed50c9, 0x7415ece2, - 0x361ae2d3, 0x7400b69a, 0x36486c86, 0x73eb6e6e, - 0x3675edd9, 0x73d61461, 0x36a366c6, 0x73c0a878, - 0x36d0d746, 0x73ab2ab4, 0x36fe3f52, 0x73959b1b, - 0x372b9ee3, 0x737ff9ae, 0x3758f5f2, 0x736a4671, - 0x37864477, 0x73548168, 0x37b38a6d, 0x733eaa96, - 0x37e0c7cc, 0x7328c1ff, 0x380dfc8d, 0x7312c7a5, - 0x383b28a9, 0x72fcbb8c, 0x38684c19, 0x72e69db7, - 0x389566d6, 0x72d06e2b, 0x38c278d9, 0x72ba2cea, - 0x38ef821c, 0x72a3d9f7, 0x391c8297, 0x728d7557, - 0x39497a43, 0x7276ff0d, 0x39766919, 0x7260771b, - 0x39a34f13, 0x7249dd86, 0x39d02c2a, 0x72333251, - 0x39fd0056, 0x721c7580, 0x3a29cb91, 0x7205a716, - 0x3a568dd4, 0x71eec716, 0x3a834717, 0x71d7d585, - 0x3aaff755, 0x71c0d265, 0x3adc9e86, 0x71a9bdba, - 0x3b093ca3, 0x71929789, 0x3b35d1a5, 0x717b5fd3, - 0x3b625d86, 0x7164169d, 0x3b8ee03e, 0x714cbbeb, - 0x3bbb59c7, 0x71354fc0, 0x3be7ca1a, 0x711dd220, - 0x3c143130, 0x7106430e, 0x3c408f03, 0x70eea28e, - 0x3c6ce38a, 0x70d6f0a4, 0x3c992ec0, 0x70bf2d53, - 0x3cc5709e, 0x70a7589f, 0x3cf1a91c, 0x708f728b, - 0x3d1dd835, 0x70777b1c, 0x3d49fde1, 0x705f7255, - 0x3d761a19, 0x70475839, 0x3da22cd7, 0x702f2ccd, - 0x3dce3614, 0x7016f014, 0x3dfa35c8, 0x6ffea212, - 0x3e262bee, 0x6fe642ca, 0x3e52187f, 0x6fcdd241, - 0x3e7dfb73, 0x6fb5507a, 0x3ea9d4c3, 0x6f9cbd79, - 0x3ed5a46b, 0x6f841942, 0x3f016a61, 0x6f6b63d8, - 0x3f2d26a0, 0x6f529d40, 0x3f58d921, 0x6f39c57d, - 0x3f8481dd, 0x6f20dc92, 0x3fb020ce, 0x6f07e285, - 0x3fdbb5ec, 0x6eeed758, 0x40074132, 0x6ed5bb10, - 0x4032c297, 0x6ebc8db0, 0x405e3a16, 0x6ea34f3d, - 0x4089a7a8, 0x6e89ffb9, 0x40b50b46, 0x6e709f2a, - 0x40e064ea, 0x6e572d93, 0x410bb48c, 0x6e3daaf8, - 0x4136fa27, 0x6e24175c, 0x416235b2, 0x6e0a72c5, - 0x418d6729, 0x6df0bd35, 0x41b88e84, 0x6dd6f6b1, - 0x41e3abbc, 0x6dbd1f3c, 0x420ebecb, 0x6da336dc, - 0x4239c7aa, 0x6d893d93, 0x4264c653, 0x6d6f3365, - 0x428fbabe, 0x6d551858, 0x42baa4e6, 0x6d3aec6e, - 0x42e584c3, 0x6d20afac, 0x43105a50, 0x6d066215, - 0x433b2585, 0x6cec03af, 0x4365e65b, 0x6cd1947c, - 0x43909ccd, 0x6cb71482, 0x43bb48d4, 0x6c9c83c3, - 0x43e5ea68, 0x6c81e245, 0x44108184, 0x6c67300b, - 0x443b0e21, 0x6c4c6d1a, 0x44659039, 0x6c319975, - 0x449007c4, 0x6c16b521, 0x44ba74bd, 0x6bfbc021, - 0x44e4d71c, 0x6be0ba7b, 0x450f2edb, 0x6bc5a431, - 0x45397bf4, 0x6baa7d49, 0x4563be60, 0x6b8f45c7, - 0x458df619, 0x6b73fdae, 0x45b82318, 0x6b58a503, - 0x45e24556, 0x6b3d3bcb, 0x460c5cce, 0x6b21c208, - 0x46366978, 0x6b0637c1, 0x46606b4e, 0x6aea9cf8, - 0x468a624a, 0x6acef1b2, 0x46b44e65, 0x6ab335f4, - 0x46de2f99, 0x6a9769c1, 0x470805df, 0x6a7b8d1e, - 0x4731d131, 0x6a5fa010, 0x475b9188, 0x6a43a29a, - 0x478546de, 0x6a2794c1, 0x47aef12c, 0x6a0b7689, - 0x47d8906d, 0x69ef47f6, 0x48022499, 0x69d3090e, - 0x482badab, 0x69b6b9d3, 0x48552b9b, 0x699a5a4c, - 0x487e9e64, 0x697dea7b, 0x48a805ff, 0x69616a65, - 0x48d16265, 0x6944da10, 0x48fab391, 0x6928397e, - 0x4923f97b, 0x690b88b5, 0x494d341e, 0x68eec7b9, - 0x49766373, 0x68d1f68f, 0x499f8774, 0x68b5153a, - 0x49c8a01b, 0x689823bf, 0x49f1ad61, 0x687b2224, - 0x4a1aaf3f, 0x685e106c, 0x4a43a5b0, 0x6840ee9b, - 0x4a6c90ad, 0x6823bcb7, 0x4a957030, 0x68067ac3, - 0x4abe4433, 0x67e928c5, 0x4ae70caf, 0x67cbc6c0, - 0x4b0fc99d, 0x67ae54ba, 0x4b387af9, 0x6790d2b6, - 0x4b6120bb, 0x677340ba, 0x4b89badd, 0x67559eca, - 0x4bb24958, 0x6737ecea, 0x4bdacc28, 0x671a2b20, - 0x4c034345, 0x66fc596f, 0x4c2baea9, 0x66de77dc, - 0x4c540e4e, 0x66c0866d, 0x4c7c622d, 0x66a28524, - 0x4ca4aa41, 0x66847408, 0x4ccce684, 0x6666531d, - 0x4cf516ee, 0x66482267, 0x4d1d3b7a, 0x6629e1ec, - 0x4d455422, 0x660b91af, 0x4d6d60df, 0x65ed31b5, - 0x4d9561ac, 0x65cec204, 0x4dbd5682, 0x65b0429f, - 0x4de53f5a, 0x6591b38c, 0x4e0d1c30, 0x657314cf, - 0x4e34ecfc, 0x6554666d, 0x4e5cb1b9, 0x6535a86b, - 0x4e846a60, 0x6516dacd, 0x4eac16eb, 0x64f7fd98, - 0x4ed3b755, 0x64d910d1, 0x4efb4b96, 0x64ba147d, - 0x4f22d3aa, 0x649b08a0, 0x4f4a4f89, 0x647bed3f, - 0x4f71bf2e, 0x645cc260, 0x4f992293, 0x643d8806, - 0x4fc079b1, 0x641e3e38, 0x4fe7c483, 0x63fee4f8, - 0x500f0302, 0x63df7c4d, 0x50363529, 0x63c0043b, - 0x505d5af1, 0x63a07cc7, 0x50847454, 0x6380e5f6, - 0x50ab814d, 0x63613fcd, 0x50d281d5, 0x63418a50, - 0x50f975e6, 0x6321c585, 0x51205d7b, 0x6301f171, - 0x5147388c, 0x62e20e17, 0x516e0715, 0x62c21b7e, - 0x5194c910, 0x62a219aa, 0x51bb7e75, 0x628208a1, - 0x51e22740, 0x6261e866, 0x5208c36a, 0x6241b8ff, - 0x522f52ee, 0x62217a72, 0x5255d5c5, 0x62012cc2, - 0x527c4bea, 0x61e0cff5, 0x52a2b556, 0x61c06410, - 0x52c91204, 0x619fe918, 0x52ef61ee, 0x617f5f12, - 0x5315a50e, 0x615ec603, 0x533bdb5d, 0x613e1df0, - 0x536204d7, 0x611d66de, 0x53882175, 0x60fca0d2, - 0x53ae3131, 0x60dbcbd1, 0x53d43406, 0x60bae7e1, - 0x53fa29ed, 0x6099f505, 0x542012e1, 0x6078f344, - 0x5445eedb, 0x6057e2a2, 0x546bbdd7, 0x6036c325, - 0x54917fce, 0x601594d1, 0x54b734ba, 0x5ff457ad, - 0x54dcdc96, 0x5fd30bbc, 0x5502775c, 0x5fb1b104, - 0x55280505, 0x5f90478a, 0x554d858d, 0x5f6ecf53, - 0x5572f8ed, 0x5f4d4865, 0x55985f20, 0x5f2bb2c5, - 0x55bdb81f, 0x5f0a0e77, 0x55e303e6, 0x5ee85b82, - 0x5608426e, 0x5ec699e9, 0x562d73b2, 0x5ea4c9b3, - 0x565297ab, 0x5e82eae5, 0x5677ae54, 0x5e60fd84, - 0x569cb7a8, 0x5e3f0194, 0x56c1b3a1, 0x5e1cf71c, - 0x56e6a239, 0x5dfade20, 0x570b8369, 0x5dd8b6a7, - 0x5730572e, 0x5db680b4, 0x57551d80, 0x5d943c4e, - 0x5779d65b, 0x5d71e979, 0x579e81b8, 0x5d4f883b, - 0x57c31f92, 0x5d2d189a, 0x57e7afe4, 0x5d0a9a9a, - 0x580c32a7, 0x5ce80e41, 0x5830a7d6, 0x5cc57394, - 0x58550f6c, 0x5ca2ca99, 0x58796962, 0x5c801354, - 0x589db5b3, 0x5c5d4dcc, 0x58c1f45b, 0x5c3a7a05, - 0x58e62552, 0x5c179806, 0x590a4893, 0x5bf4a7d2, - 0x592e5e19, 0x5bd1a971, 0x595265df, 0x5bae9ce7, - 0x59765fde, 0x5b8b8239, 0x599a4c12, 0x5b68596d, - 0x59be2a74, 0x5b452288, 0x59e1faff, 0x5b21dd90, - 0x5a05bdae, 0x5afe8a8b, 0x5a29727b, 0x5adb297d, - 0x5a4d1960, 0x5ab7ba6c, 0x5a70b258, 0x5a943d5e, -}; - -/*split radix bit reverse table for FFT of size up to 2048*/ - -const uint16_t revtab[1<<12] = { -0, 3072, 1536, 2816, 768, 3840, 1408, 2432, 384, 3456, 1920, 2752, 704, -3776, 1216, 2240, 192, 3264, 1728, 3008, 960, 4032, 1376, 2400, 352, 3424, -1888, 2656, 608, 3680, 1120, 2144, 96, 3168, 1632, 2912, 864, 3936, 1504, -2528, 480, 3552, 2016, 2736, 688, 3760, 1200, 2224, 176, 3248, 1712, 2992, -944, 4016, 1328, 2352, 304, 3376, 1840, 2608, 560, 3632, 1072, 2096, 48, -3120, 1584, 2864, 816, 3888, 1456, 2480, 432, 3504, 1968, 2800, 752, 3824, -1264, 2288, 240, 3312, 1776, 3056, 1008, 4080, 1368, 2392, 344, 3416, 1880, -2648, 600, 3672, 1112, 2136, 88, 3160, 1624, 2904, 856, 3928, 1496, 2520, -472, 3544, 2008, 2712, 664, 3736, 1176, 2200, 152, 3224, 1688, 2968, 920, -3992, 1304, 2328, 280, 3352, 1816, 2584, 536, 3608, 1048, 2072, 24, 3096, -1560, 2840, 792, 3864, 1432, 2456, 408, 3480, 1944, 2776, 728, 3800, 1240, -2264, 216, 3288, 1752, 3032, 984, 4056, 1400, 2424, 376, 3448, 1912, 2680, -632, 3704, 1144, 2168, 120, 3192, 1656, 2936, 888, 3960, 1528, 2552, 504, -3576, 2040, 2732, 684, 3756, 1196, 2220, 172, 3244, 1708, 2988, 940, 4012, -1324, 2348, 300, 3372, 1836, 2604, 556, 3628, 1068, 2092, 44, 3116, 1580, -2860, 812, 3884, 1452, 2476, 428, 3500, 1964, 2796, 748, 3820, 1260, 2284, -236, 3308, 1772, 3052, 1004, 4076, 1356, 2380, 332, 3404, 1868, 2636, 588, -3660, 1100, 2124, 76, 3148, 1612, 2892, 844, 3916, 1484, 2508, 460, 3532, -1996, 2700, 652, 3724, 1164, 2188, 140, 3212, 1676, 2956, 908, 3980, 1292, -2316, 268, 3340, 1804, 2572, 524, 3596, 1036, 2060, 12, 3084, 1548, 2828, -780, 3852, 1420, 2444, 396, 3468, 1932, 2764, 716, 3788, 1228, 2252, 204, -3276, 1740, 3020, 972, 4044, 1388, 2412, 364, 3436, 1900, 2668, 620, 3692, -1132, 2156, 108, 3180, 1644, 2924, 876, 3948, 1516, 2540, 492, 3564, 2028, -2748, 700, 3772, 1212, 2236, 188, 3260, 1724, 3004, 956, 4028, 1340, 2364, -316, 3388, 1852, 2620, 572, 3644, 1084, 2108, 60, 3132, 1596, 2876, 828, -3900, 1468, 2492, 444, 3516, 1980, 2812, 764, 3836, 1276, 2300, 252, 3324, -1788, 3068, 1020, 4092, 1366, 2390, 342, 3414, 1878, 2646, 598, 3670, 1110, -2134, 86, 3158, 1622, 2902, 854, 3926, 1494, 2518, 470, 3542, 2006, 2710, -662, 3734, 1174, 2198, 150, 3222, 1686, 2966, 918, 3990, 1302, 2326, 278, -3350, 1814, 2582, 534, 3606, 1046, 2070, 22, 3094, 1558, 2838, 790, 3862, -1430, 2454, 406, 3478, 1942, 2774, 726, 3798, 1238, 2262, 214, 3286, 1750, -3030, 982, 4054, 1398, 2422, 374, 3446, 1910, 2678, 630, 3702, 1142, 2166, -118, 3190, 1654, 2934, 886, 3958, 1526, 2550, 502, 3574, 2038, 2726, 678, -3750, 1190, 2214, 166, 3238, 1702, 2982, 934, 4006, 1318, 2342, 294, 3366, -1830, 2598, 550, 3622, 1062, 2086, 38, 3110, 1574, 2854, 806, 3878, 1446, -2470, 422, 3494, 1958, 2790, 742, 3814, 1254, 2278, 230, 3302, 1766, 3046, -998, 4070, 1350, 2374, 326, 3398, 1862, 2630, 582, 3654, 1094, 2118, 70, -3142, 1606, 2886, 838, 3910, 1478, 2502, 454, 3526, 1990, 2694, 646, 3718, -1158, 2182, 134, 3206, 1670, 2950, 902, 3974, 1286, 2310, 262, 3334, 1798, -2566, 518, 3590, 1030, 2054, 6, 3078, 1542, 2822, 774, 3846, 1414, 2438, -390, 3462, 1926, 2758, 710, 3782, 1222, 2246, 198, 3270, 1734, 3014, 966, -4038, 1382, 2406, 358, 3430, 1894, 2662, 614, 3686, 1126, 2150, 102, 3174, -1638, 2918, 870, 3942, 1510, 2534, 486, 3558, 2022, 2742, 694, 3766, 1206, -2230, 182, 3254, 1718, 2998, 950, 4022, 1334, 2358, 310, 3382, 1846, 2614, -566, 3638, 1078, 2102, 54, 3126, 1590, 2870, 822, 3894, 1462, 2486, 438, -3510, 1974, 2806, 758, 3830, 1270, 2294, 246, 3318, 1782, 3062, 1014, 4086, -1374, 2398, 350, 3422, 1886, 2654, 606, 3678, 1118, 2142, 94, 3166, 1630, -2910, 862, 3934, 1502, 2526, 478, 3550, 2014, 2718, 670, 3742, 1182, 2206, -158, 3230, 1694, 2974, 926, 3998, 1310, 2334, 286, 3358, 1822, 2590, 542, -3614, 1054, 2078, 30, 3102, 1566, 2846, 798, 3870, 1438, 2462, 414, 3486, -1950, 2782, 734, 3806, 1246, 2270, 222, 3294, 1758, 3038, 990, 4062, 1406, -2430, 382, 3454, 1918, 2686, 638, 3710, 1150, 2174, 126, 3198, 1662, 2942, -894, 3966, 1534, 2558, 510, 3582, 2046, 2731, 683, 3755, 1195, 2219, 171, -3243, 1707, 2987, 939, 4011, 1323, 2347, 299, 3371, 1835, 2603, 555, 3627, -1067, 2091, 43, 3115, 1579, 2859, 811, 3883, 1451, 2475, 427, 3499, 1963, -2795, 747, 3819, 1259, 2283, 235, 3307, 1771, 3051, 1003, 4075, 1355, 2379, -331, 3403, 1867, 2635, 587, 3659, 1099, 2123, 75, 3147, 1611, 2891, 843, -3915, 1483, 2507, 459, 3531, 1995, 2699, 651, 3723, 1163, 2187, 139, 3211, -1675, 2955, 907, 3979, 1291, 2315, 267, 3339, 1803, 2571, 523, 3595, 1035, -2059, 11, 3083, 1547, 2827, 779, 3851, 1419, 2443, 395, 3467, 1931, 2763, -715, 3787, 1227, 2251, 203, 3275, 1739, 3019, 971, 4043, 1387, 2411, 363, -3435, 1899, 2667, 619, 3691, 1131, 2155, 107, 3179, 1643, 2923, 875, 3947, -1515, 2539, 491, 3563, 2027, 2747, 699, 3771, 1211, 2235, 187, 3259, 1723, -3003, 955, 4027, 1339, 2363, 315, 3387, 1851, 2619, 571, 3643, 1083, 2107, -59, 3131, 1595, 2875, 827, 3899, 1467, 2491, 443, 3515, 1979, 2811, 763, -3835, 1275, 2299, 251, 3323, 1787, 3067, 1019, 4091, 1363, 2387, 339, 3411, -1875, 2643, 595, 3667, 1107, 2131, 83, 3155, 1619, 2899, 851, 3923, 1491, -2515, 467, 3539, 2003, 2707, 659, 3731, 1171, 2195, 147, 3219, 1683, 2963, -915, 3987, 1299, 2323, 275, 3347, 1811, 2579, 531, 3603, 1043, 2067, 19, -3091, 1555, 2835, 787, 3859, 1427, 2451, 403, 3475, 1939, 2771, 723, 3795, -1235, 2259, 211, 3283, 1747, 3027, 979, 4051, 1395, 2419, 371, 3443, 1907, -2675, 627, 3699, 1139, 2163, 115, 3187, 1651, 2931, 883, 3955, 1523, 2547, -499, 3571, 2035, 2723, 675, 3747, 1187, 2211, 163, 3235, 1699, 2979, 931, -4003, 1315, 2339, 291, 3363, 1827, 2595, 547, 3619, 1059, 2083, 35, 3107, -1571, 2851, 803, 3875, 1443, 2467, 419, 3491, 1955, 2787, 739, 3811, 1251, -2275, 227, 3299, 1763, 3043, 995, 4067, 1347, 2371, 323, 3395, 1859, 2627, -579, 3651, 1091, 2115, 67, 3139, 1603, 2883, 835, 3907, 1475, 2499, 451, -3523, 1987, 2691, 643, 3715, 1155, 2179, 131, 3203, 1667, 2947, 899, 3971, -1283, 2307, 259, 3331, 1795, 2563, 515, 3587, 1027, 2051, 3, 3075, 1539, -2819, 771, 3843, 1411, 2435, 387, 3459, 1923, 2755, 707, 3779, 1219, 2243, -195, 3267, 1731, 3011, 963, 4035, 1379, 2403, 355, 3427, 1891, 2659, 611, -3683, 1123, 2147, 99, 3171, 1635, 2915, 867, 3939, 1507, 2531, 483, 3555, -2019, 2739, 691, 3763, 1203, 2227, 179, 3251, 1715, 2995, 947, 4019, 1331, -2355, 307, 3379, 1843, 2611, 563, 3635, 1075, 2099, 51, 3123, 1587, 2867, -819, 3891, 1459, 2483, 435, 3507, 1971, 2803, 755, 3827, 1267, 2291, 243, -3315, 1779, 3059, 1011, 4083, 1371, 2395, 347, 3419, 1883, 2651, 603, 3675, -1115, 2139, 91, 3163, 1627, 2907, 859, 3931, 1499, 2523, 475, 3547, 2011, -2715, 667, 3739, 1179, 2203, 155, 3227, 1691, 2971, 923, 3995, 1307, 2331, -283, 3355, 1819, 2587, 539, 3611, 1051, 2075, 27, 3099, 1563, 2843, 795, -3867, 1435, 2459, 411, 3483, 1947, 2779, 731, 3803, 1243, 2267, 219, 3291, -1755, 3035, 987, 4059, 1403, 2427, 379, 3451, 1915, 2683, 635, 3707, 1147, -2171, 123, 3195, 1659, 2939, 891, 3963, 1531, 2555, 507, 3579, 2043, 2735, -687, 3759, 1199, 2223, 175, 3247, 1711, 2991, 943, 4015, 1327, 2351, 303, -3375, 1839, 2607, 559, 3631, 1071, 2095, 47, 3119, 1583, 2863, 815, 3887, -1455, 2479, 431, 3503, 1967, 2799, 751, 3823, 1263, 2287, 239, 3311, 1775, -3055, 1007, 4079, 1359, 2383, 335, 3407, 1871, 2639, 591, 3663, 1103, 2127, -79, 3151, 1615, 2895, 847, 3919, 1487, 2511, 463, 3535, 1999, 2703, 655, -3727, 1167, 2191, 143, 3215, 1679, 2959, 911, 3983, 1295, 2319, 271, 3343, -1807, 2575, 527, 3599, 1039, 2063, 15, 3087, 1551, 2831, 783, 3855, 1423, -2447, 399, 3471, 1935, 2767, 719, 3791, 1231, 2255, 207, 3279, 1743, 3023, -975, 4047, 1391, 2415, 367, 3439, 1903, 2671, 623, 3695, 1135, 2159, 111, -3183, 1647, 2927, 879, 3951, 1519, 2543, 495, 3567, 2031, 2751, 703, 3775, -1215, 2239, 191, 3263, 1727, 3007, 959, 4031, 1343, 2367, 319, 3391, 1855, -2623, 575, 3647, 1087, 2111, 63, 3135, 1599, 2879, 831, 3903, 1471, 2495, -447, 3519, 1983, 2815, 767, 3839, 1279, 2303, 255, 3327, 1791, 3071, 1023, -4095, 1365, 2389, 341, 3413, 1877, 2645, 597, 3669, 1109, 2133, 85, 3157, -1621, 2901, 853, 3925, 1493, 2517, 469, 3541, 2005, 2709, 661, 3733, 1173, -2197, 149, 3221, 1685, 2965, 917, 3989, 1301, 2325, 277, 3349, 1813, 2581, -533, 3605, 1045, 2069, 21, 3093, 1557, 2837, 789, 3861, 1429, 2453, 405, -3477, 1941, 2773, 725, 3797, 1237, 2261, 213, 3285, 1749, 3029, 981, 4053, -1397, 2421, 373, 3445, 1909, 2677, 629, 3701, 1141, 2165, 117, 3189, 1653, -2933, 885, 3957, 1525, 2549, 501, 3573, 2037, 2725, 677, 3749, 1189, 2213, -165, 3237, 1701, 2981, 933, 4005, 1317, 2341, 293, 3365, 1829, 2597, 549, -3621, 1061, 2085, 37, 3109, 1573, 2853, 805, 3877, 1445, 2469, 421, 3493, -1957, 2789, 741, 3813, 1253, 2277, 229, 3301, 1765, 3045, 997, 4069, 1349, -2373, 325, 3397, 1861, 2629, 581, 3653, 1093, 2117, 69, 3141, 1605, 2885, -837, 3909, 1477, 2501, 453, 3525, 1989, 2693, 645, 3717, 1157, 2181, 133, -3205, 1669, 2949, 901, 3973, 1285, 2309, 261, 3333, 1797, 2565, 517, 3589, -1029, 2053, 5, 3077, 1541, 2821, 773, 3845, 1413, 2437, 389, 3461, 1925, -2757, 709, 3781, 1221, 2245, 197, 3269, 1733, 3013, 965, 4037, 1381, 2405, -357, 3429, 1893, 2661, 613, 3685, 1125, 2149, 101, 3173, 1637, 2917, 869, -3941, 1509, 2533, 485, 3557, 2021, 2741, 693, 3765, 1205, 2229, 181, 3253, -1717, 2997, 949, 4021, 1333, 2357, 309, 3381, 1845, 2613, 565, 3637, 1077, -2101, 53, 3125, 1589, 2869, 821, 3893, 1461, 2485, 437, 3509, 1973, 2805, -757, 3829, 1269, 2293, 245, 3317, 1781, 3061, 1013, 4085, 1373, 2397, 349, -3421, 1885, 2653, 605, 3677, 1117, 2141, 93, 3165, 1629, 2909, 861, 3933, -1501, 2525, 477, 3549, 2013, 2717, 669, 3741, 1181, 2205, 157, 3229, 1693, -2973, 925, 3997, 1309, 2333, 285, 3357, 1821, 2589, 541, 3613, 1053, 2077, -29, 3101, 1565, 2845, 797, 3869, 1437, 2461, 413, 3485, 1949, 2781, 733, -3805, 1245, 2269, 221, 3293, 1757, 3037, 989, 4061, 1405, 2429, 381, 3453, -1917, 2685, 637, 3709, 1149, 2173, 125, 3197, 1661, 2941, 893, 3965, 1533, -2557, 509, 3581, 2045, 2729, 681, 3753, 1193, 2217, 169, 3241, 1705, 2985, -937, 4009, 1321, 2345, 297, 3369, 1833, 2601, 553, 3625, 1065, 2089, 41, -3113, 1577, 2857, 809, 3881, 1449, 2473, 425, 3497, 1961, 2793, 745, 3817, -1257, 2281, 233, 3305, 1769, 3049, 1001, 4073, 1353, 2377, 329, 3401, 1865, -2633, 585, 3657, 1097, 2121, 73, 3145, 1609, 2889, 841, 3913, 1481, 2505, -457, 3529, 1993, 2697, 649, 3721, 1161, 2185, 137, 3209, 1673, 2953, 905, -3977, 1289, 2313, 265, 3337, 1801, 2569, 521, 3593, 1033, 2057, 9, 3081, -1545, 2825, 777, 3849, 1417, 2441, 393, 3465, 1929, 2761, 713, 3785, 1225, -2249, 201, 3273, 1737, 3017, 969, 4041, 1385, 2409, 361, 3433, 1897, 2665, -617, 3689, 1129, 2153, 105, 3177, 1641, 2921, 873, 3945, 1513, 2537, 489, -3561, 2025, 2745, 697, 3769, 1209, 2233, 185, 3257, 1721, 3001, 953, 4025, -1337, 2361, 313, 3385, 1849, 2617, 569, 3641, 1081, 2105, 57, 3129, 1593, -2873, 825, 3897, 1465, 2489, 441, 3513, 1977, 2809, 761, 3833, 1273, 2297, -249, 3321, 1785, 3065, 1017, 4089, 1361, 2385, 337, 3409, 1873, 2641, 593, -3665, 1105, 2129, 81, 3153, 1617, 2897, 849, 3921, 1489, 2513, 465, 3537, -2001, 2705, 657, 3729, 1169, 2193, 145, 3217, 1681, 2961, 913, 3985, 1297, -2321, 273, 3345, 1809, 2577, 529, 3601, 1041, 2065, 17, 3089, 1553, 2833, -785, 3857, 1425, 2449, 401, 3473, 1937, 2769, 721, 3793, 1233, 2257, 209, -3281, 1745, 3025, 977, 4049, 1393, 2417, 369, 3441, 1905, 2673, 625, 3697, -1137, 2161, 113, 3185, 1649, 2929, 881, 3953, 1521, 2545, 497, 3569, 2033, -2721, 673, 3745, 1185, 2209, 161, 3233, 1697, 2977, 929, 4001, 1313, 2337, -289, 3361, 1825, 2593, 545, 3617, 1057, 2081, 33, 3105, 1569, 2849, 801, -3873, 1441, 2465, 417, 3489, 1953, 2785, 737, 3809, 1249, 2273, 225, 3297, -1761, 3041, 993, 4065, 1345, 2369, 321, 3393, 1857, 2625, 577, 3649, 1089, -2113, 65, 3137, 1601, 2881, 833, 3905, 1473, 2497, 449, 3521, 1985, 2689, -641, 3713, 1153, 2177, 129, 3201, 1665, 2945, 897, 3969, 1281, 2305, 257, -3329, 1793, 2561, 513, 3585, 1025, 2049, 1, 3073, 1537, 2817, 769, 3841, -1409, 2433, 385, 3457, 1921, 2753, 705, 3777, 1217, 2241, 193, 3265, 1729, -3009, 961, 4033, 1377, 2401, 353, 3425, 1889, 2657, 609, 3681, 1121, 2145, -97, 3169, 1633, 2913, 865, 3937, 1505, 2529, 481, 3553, 2017, 2737, 689, -3761, 1201, 2225, 177, 3249, 1713, 2993, 945, 4017, 1329, 2353, 305, 3377, -1841, 2609, 561, 3633, 1073, 2097, 49, 3121, 1585, 2865, 817, 3889, 1457, -2481, 433, 3505, 1969, 2801, 753, 3825, 1265, 2289, 241, 3313, 1777, 3057, -1009, 4081, 1369, 2393, 345, 3417, 1881, 2649, 601, 3673, 1113, 2137, 89, -3161, 1625, 2905, 857, 3929, 1497, 2521, 473, 3545, 2009, 2713, 665, 3737, -1177, 2201, 153, 3225, 1689, 2969, 921, 3993, 1305, 2329, 281, 3353, 1817, -2585, 537, 3609, 1049, 2073, 25, 3097, 1561, 2841, 793, 3865, 1433, 2457, -409, 3481, 1945, 2777, 729, 3801, 1241, 2265, 217, 3289, 1753, 3033, 985, -4057, 1401, 2425, 377, 3449, 1913, 2681, 633, 3705, 1145, 2169, 121, 3193, -1657, 2937, 889, 3961, 1529, 2553, 505, 3577, 2041, 2733, 685, 3757, 1197, -2221, 173, 3245, 1709, 2989, 941, 4013, 1325, 2349, 301, 3373, 1837, 2605, -557, 3629, 1069, 2093, 45, 3117, 1581, 2861, 813, 3885, 1453, 2477, 429, -3501, 1965, 2797, 749, 3821, 1261, 2285, 237, 3309, 1773, 3053, 1005, 4077, -1357, 2381, 333, 3405, 1869, 2637, 589, 3661, 1101, 2125, 77, 3149, 1613, -2893, 845, 3917, 1485, 2509, 461, 3533, 1997, 2701, 653, 3725, 1165, 2189, -141, 3213, 1677, 2957, 909, 3981, 1293, 2317, 269, 3341, 1805, 2573, 525, -3597, 1037, 2061, 13, 3085, 1549, 2829, 781, 3853, 1421, 2445, 397, 3469, -1933, 2765, 717, 3789, 1229, 2253, 205, 3277, 1741, 3021, 973, 4045, 1389, -2413, 365, 3437, 1901, 2669, 621, 3693, 1133, 2157, 109, 3181, 1645, 2925, -877, 3949, 1517, 2541, 493, 3565, 2029, 2749, 701, 3773, 1213, 2237, 189, -3261, 1725, 3005, 957, 4029, 1341, 2365, 317, 3389, 1853, 2621, 573, 3645, -1085, 2109, 61, 3133, 1597, 2877, 829, 3901, 1469, 2493, 445, 3517, 1981, -2813, 765, 3837, 1277, 2301, 253, 3325, 1789, 3069, 1021, 4093, 1367, 2391, -343, 3415, 1879, 2647, 599, 3671, 1111, 2135, 87, 3159, 1623, 2903, 855, -3927, 1495, 2519, 471, 3543, 2007, 2711, 663, 3735, 1175, 2199, 151, 3223, -1687, 2967, 919, 3991, 1303, 2327, 279, 3351, 1815, 2583, 535, 3607, 1047, -2071, 23, 3095, 1559, 2839, 791, 3863, 1431, 2455, 407, 3479, 1943, 2775, -727, 3799, 1239, 2263, 215, 3287, 1751, 3031, 983, 4055, 1399, 2423, 375, -3447, 1911, 2679, 631, 3703, 1143, 2167, 119, 3191, 1655, 2935, 887, 3959, -1527, 2551, 503, 3575, 2039, 2727, 679, 3751, 1191, 2215, 167, 3239, 1703, -2983, 935, 4007, 1319, 2343, 295, 3367, 1831, 2599, 551, 3623, 1063, 2087, -39, 3111, 1575, 2855, 807, 3879, 1447, 2471, 423, 3495, 1959, 2791, 743, -3815, 1255, 2279, 231, 3303, 1767, 3047, 999, 4071, 1351, 2375, 327, 3399, -1863, 2631, 583, 3655, 1095, 2119, 71, 3143, 1607, 2887, 839, 3911, 1479, -2503, 455, 3527, 1991, 2695, 647, 3719, 1159, 2183, 135, 3207, 1671, 2951, -903, 3975, 1287, 2311, 263, 3335, 1799, 2567, 519, 3591, 1031, 2055, 7, -3079, 1543, 2823, 775, 3847, 1415, 2439, 391, 3463, 1927, 2759, 711, 3783, -1223, 2247, 199, 3271, 1735, 3015, 967, 4039, 1383, 2407, 359, 3431, 1895, -2663, 615, 3687, 1127, 2151, 103, 3175, 1639, 2919, 871, 3943, 1511, 2535, -487, 3559, 2023, 2743, 695, 3767, 1207, 2231, 183, 3255, 1719, 2999, 951, -4023, 1335, 2359, 311, 3383, 1847, 2615, 567, 3639, 1079, 2103, 55, 3127, -1591, 2871, 823, 3895, 1463, 2487, 439, 3511, 1975, 2807, 759, 3831, 1271, -2295, 247, 3319, 1783, 3063, 1015, 4087, 1375, 2399, 351, 3423, 1887, 2655, -607, 3679, 1119, 2143, 95, 3167, 1631, 2911, 863, 3935, 1503, 2527, 479, -3551, 2015, 2719, 671, 3743, 1183, 2207, 159, 3231, 1695, 2975, 927, 3999, -1311, 2335, 287, 3359, 1823, 2591, 543, 3615, 1055, 2079, 31, 3103, 1567, -2847, 799, 3871, 1439, 2463, 415, 3487, 1951, 2783, 735, 3807, 1247, 2271, -223, 3295, 1759, 3039, 991, 4063, 1407, 2431, 383, 3455, 1919, 2687, 639, -3711, 1151, 2175, 127, 3199, 1663, 2943, 895, 3967, 1535, 2559, 511, 3583, -2047, 2730, 682, 3754, 1194, 2218, 170, 3242, 1706, 2986, 938, 4010, 1322, -2346, 298, 3370, 1834, 2602, 554, 3626, 1066, 2090, 42, 3114, 1578, 2858, -810, 3882, 1450, 2474, 426, 3498, 1962, 2794, 746, 3818, 1258, 2282, 234, -3306, 1770, 3050, 1002, 4074, 1354, 2378, 330, 3402, 1866, 2634, 586, 3658, -1098, 2122, 74, 3146, 1610, 2890, 842, 3914, 1482, 2506, 458, 3530, 1994, -2698, 650, 3722, 1162, 2186, 138, 3210, 1674, 2954, 906, 3978, 1290, 2314, -266, 3338, 1802, 2570, 522, 3594, 1034, 2058, 10, 3082, 1546, 2826, 778, -3850, 1418, 2442, 394, 3466, 1930, 2762, 714, 3786, 1226, 2250, 202, 3274, -1738, 3018, 970, 4042, 1386, 2410, 362, 3434, 1898, 2666, 618, 3690, 1130, -2154, 106, 3178, 1642, 2922, 874, 3946, 1514, 2538, 490, 3562, 2026, 2746, -698, 3770, 1210, 2234, 186, 3258, 1722, 3002, 954, 4026, 1338, 2362, 314, -3386, 1850, 2618, 570, 3642, 1082, 2106, 58, 3130, 1594, 2874, 826, 3898, -1466, 2490, 442, 3514, 1978, 2810, 762, 3834, 1274, 2298, 250, 3322, 1786, -3066, 1018, 4090, 1362, 2386, 338, 3410, 1874, 2642, 594, 3666, 1106, 2130, -82, 3154, 1618, 2898, 850, 3922, 1490, 2514, 466, 3538, 2002, 2706, 658, -3730, 1170, 2194, 146, 3218, 1682, 2962, 914, 3986, 1298, 2322, 274, 3346, -1810, 2578, 530, 3602, 1042, 2066, 18, 3090, 1554, 2834, 786, 3858, 1426, -2450, 402, 3474, 1938, 2770, 722, 3794, 1234, 2258, 210, 3282, 1746, 3026, -978, 4050, 1394, 2418, 370, 3442, 1906, 2674, 626, 3698, 1138, 2162, 114, -3186, 1650, 2930, 882, 3954, 1522, 2546, 498, 3570, 2034, 2722, 674, 3746, -1186, 2210, 162, 3234, 1698, 2978, 930, 4002, 1314, 2338, 290, 3362, 1826, -2594, 546, 3618, 1058, 2082, 34, 3106, 1570, 2850, 802, 3874, 1442, 2466, -418, 3490, 1954, 2786, 738, 3810, 1250, 2274, 226, 3298, 1762, 3042, 994, -4066, 1346, 2370, 322, 3394, 1858, 2626, 578, 3650, 1090, 2114, 66, 3138, -1602, 2882, 834, 3906, 1474, 2498, 450, 3522, 1986, 2690, 642, 3714, 1154, -2178, 130, 3202, 1666, 2946, 898, 3970, 1282, 2306, 258, 3330, 1794, 2562, -514, 3586, 1026, 2050, 2, 3074, 1538, 2818, 770, 3842, 1410, 2434, 386, -3458, 1922, 2754, 706, 3778, 1218, 2242, 194, 3266, 1730, 3010, 962, 4034, -1378, 2402, 354, 3426, 1890, 2658, 610, 3682, 1122, 2146, 98, 3170, 1634, -2914, 866, 3938, 1506, 2530, 482, 3554, 2018, 2738, 690, 3762, 1202, 2226, -178, 3250, 1714, 2994, 946, 4018, 1330, 2354, 306, 3378, 1842, 2610, 562, -3634, 1074, 2098, 50, 3122, 1586, 2866, 818, 3890, 1458, 2482, 434, 3506, -1970, 2802, 754, 3826, 1266, 2290, 242, 3314, 1778, 3058, 1010, 4082, 1370, -2394, 346, 3418, 1882, 2650, 602, 3674, 1114, 2138, 90, 3162, 1626, 2906, -858, 3930, 1498, 2522, 474, 3546, 2010, 2714, 666, 3738, 1178, 2202, 154, -3226, 1690, 2970, 922, 3994, 1306, 2330, 282, 3354, 1818, 2586, 538, 3610, -1050, 2074, 26, 3098, 1562, 2842, 794, 3866, 1434, 2458, 410, 3482, 1946, -2778, 730, 3802, 1242, 2266, 218, 3290, 1754, 3034, 986, 4058, 1402, 2426, -378, 3450, 1914, 2682, 634, 3706, 1146, 2170, 122, 3194, 1658, 2938, 890, -3962, 1530, 2554, 506, 3578, 2042, 2734, 686, 3758, 1198, 2222, 174, 3246, -1710, 2990, 942, 4014, 1326, 2350, 302, 3374, 1838, 2606, 558, 3630, 1070, -2094, 46, 3118, 1582, 2862, 814, 3886, 1454, 2478, 430, 3502, 1966, 2798, -750, 3822, 1262, 2286, 238, 3310, 1774, 3054, 1006, 4078, 1358, 2382, 334, -3406, 1870, 2638, 590, 3662, 1102, 2126, 78, 3150, 1614, 2894, 846, 3918, -1486, 2510, 462, 3534, 1998, 2702, 654, 3726, 1166, 2190, 142, 3214, 1678, -2958, 910, 3982, 1294, 2318, 270, 3342, 1806, 2574, 526, 3598, 1038, 2062, -14, 3086, 1550, 2830, 782, 3854, 1422, 2446, 398, 3470, 1934, 2766, 718, -3790, 1230, 2254, 206, 3278, 1742, 3022, 974, 4046, 1390, 2414, 366, 3438, -1902, 2670, 622, 3694, 1134, 2158, 110, 3182, 1646, 2926, 878, 3950, 1518, -2542, 494, 3566, 2030, 2750, 702, 3774, 1214, 2238, 190, 3262, 1726, 3006, -958, 4030, 1342, 2366, 318, 3390, 1854, 2622, 574, 3646, 1086, 2110, 62, -3134, 1598, 2878, 830, 3902, 1470, 2494, 446, 3518, 1982, 2814, 766, 3838, -1278, 2302, 254, 3326, 1790, 3070, 1022, 4094, 1364, 2388, 340, 3412, 1876, -2644, 596, 3668, 1108, 2132, 84, 3156, 1620, 2900, 852, 3924, 1492, 2516, -468, 3540, 2004, 2708, 660, 3732, 1172, 2196, 148, 3220, 1684, 2964, 916, -3988, 1300, 2324, 276, 3348, 1812, 2580, 532, 3604, 1044, 2068, 20, 3092, -1556, 2836, 788, 3860, 1428, 2452, 404, 3476, 1940, 2772, 724, 3796, 1236, -2260, 212, 3284, 1748, 3028, 980, 4052, 1396, 2420, 372, 3444, 1908, 2676, -628, 3700, 1140, 2164, 116, 3188, 1652, 2932, 884, 3956, 1524, 2548, 500, -3572, 2036, 2724, 676, 3748, 1188, 2212, 164, 3236, 1700, 2980, 932, 4004, -1316, 2340, 292, 3364, 1828, 2596, 548, 3620, 1060, 2084, 36, 3108, 1572, -2852, 804, 3876, 1444, 2468, 420, 3492, 1956, 2788, 740, 3812, 1252, 2276, -228, 3300, 1764, 3044, 996, 4068, 1348, 2372, 324, 3396, 1860, 2628, 580, -3652, 1092, 2116, 68, 3140, 1604, 2884, 836, 3908, 1476, 2500, 452, 3524, -1988, 2692, 644, 3716, 1156, 2180, 132, 3204, 1668, 2948, 900, 3972, 1284, -2308, 260, 3332, 1796, 2564, 516, 3588, 1028, 2052, 4, 3076, 1540, 2820, -772, 3844, 1412, 2436, 388, 3460, 1924, 2756, 708, 3780, 1220, 2244, 196, -3268, 1732, 3012, 964, 4036, 1380, 2404, 356, 3428, 1892, 2660, 612, 3684, -1124, 2148, 100, 3172, 1636, 2916, 868, 3940, 1508, 2532, 484, 3556, 2020, -2740, 692, 3764, 1204, 2228, 180, 3252, 1716, 2996, 948, 4020, 1332, 2356, -308, 3380, 1844, 2612, 564, 3636, 1076, 2100, 52, 3124, 1588, 2868, 820, -3892, 1460, 2484, 436, 3508, 1972, 2804, 756, 3828, 1268, 2292, 244, 3316, -1780, 3060, 1012, 4084, 1372, 2396, 348, 3420, 1884, 2652, 604, 3676, 1116, -2140, 92, 3164, 1628, 2908, 860, 3932, 1500, 2524, 476, 3548, 2012, 2716, -668, 3740, 1180, 2204, 156, 3228, 1692, 2972, 924, 3996, 1308, 2332, 284, -3356, 1820, 2588, 540, 3612, 1052, 2076, 28, 3100, 1564, 2844, 796, 3868, -1436, 2460, 412, 3484, 1948, 2780, 732, 3804, 1244, 2268, 220, 3292, 1756, -3036, 988, 4060, 1404, 2428, 380, 3452, 1916, 2684, 636, 3708, 1148, 2172, -124, 3196, 1660, 2940, 892, 3964, 1532, 2556, 508, 3580, 2044, 2728, 680, -3752, 1192, 2216, 168, 3240, 1704, 2984, 936, 4008, 1320, 2344, 296, 3368, -1832, 2600, 552, 3624, 1064, 2088, 40, 3112, 1576, 2856, 808, 3880, 1448, -2472, 424, 3496, 1960, 2792, 744, 3816, 1256, 2280, 232, 3304, 1768, 3048, -1000, 4072, 1352, 2376, 328, 3400, 1864, 2632, 584, 3656, 1096, 2120, 72, -3144, 1608, 2888, 840, 3912, 1480, 2504, 456, 3528, 1992, 2696, 648, 3720, -1160, 2184, 136, 3208, 1672, 2952, 904, 3976, 1288, 2312, 264, 3336, 1800, -2568, 520, 3592, 1032, 2056, 8, 3080, 1544, 2824, 776, 3848, 1416, 2440, -392, 3464, 1928, 2760, 712, 3784, 1224, 2248, 200, 3272, 1736, 3016, 968, -4040, 1384, 2408, 360, 3432, 1896, 2664, 616, 3688, 1128, 2152, 104, 3176, -1640, 2920, 872, 3944, 1512, 2536, 488, 3560, 2024, 2744, 696, 3768, 1208, -2232, 184, 3256, 1720, 3000, 952, 4024, 1336, 2360, 312, 3384, 1848, 2616, -568, 3640, 1080, 2104, 56, 3128, 1592, 2872, 824, 3896, 1464, 2488, 440, -3512, 1976, 2808, 760, 3832, 1272, 2296, 248, 3320, 1784, 3064, 1016, 4088, -1360, 2384, 336, 3408, 1872, 2640, 592, 3664, 1104, 2128, 80, 3152, 1616, -2896, 848, 3920, 1488, 2512, 464, 3536, 2000, 2704, 656, 3728, 1168, 2192, -144, 3216, 1680, 2960, 912, 3984, 1296, 2320, 272, 3344, 1808, 2576, 528, -3600, 1040, 2064, 16, 3088, 1552, 2832, 784, 3856, 1424, 2448, 400, 3472, -1936, 2768, 720, 3792, 1232, 2256, 208, 3280, 1744, 3024, 976, 4048, 1392, -2416, 368, 3440, 1904, 2672, 624, 3696, 1136, 2160, 112, 3184, 1648, 2928, -880, 3952, 1520, 2544, 496, 3568, 2032, 2720, 672, 3744, 1184, 2208, 160, -3232, 1696, 2976, 928, 4000, 1312, 2336, 288, 3360, 1824, 2592, 544, 3616, -1056, 2080, 32, 3104, 1568, 2848, 800, 3872, 1440, 2464, 416, 3488, 1952, -2784, 736, 3808, 1248, 2272, 224, 3296, 1760, 3040, 992, 4064, 1344, 2368, -320, 3392, 1856, 2624, 576, 3648, 1088, 2112, 64, 3136, 1600, 2880, 832, -3904, 1472, 2496, 448, 3520, 1984, 2688, 640, 3712, 1152, 2176, 128, 3200, -1664, 2944, 896, 3968, 1280, 2304, 256, 3328, 1792, 2560, 512, 3584, 1024, -2048}; - - diff --git a/apps/codecs/lib/mdct_lookup.h b/apps/codecs/lib/mdct_lookup.h deleted file mode 100644 index 909b95ddbb..0000000000 --- a/apps/codecs/lib/mdct_lookup.h +++ /dev/null @@ -1,24 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * - * * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * - * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * - * * - ******************************************************************** - - function: sin,cos lookup tables - - ********************************************************************/ - - -extern const int32_t sincos_lookup0[1026]; -extern const int32_t sincos_lookup1[1024]; -extern const uint16_t revtab[1<<12]; - - - diff --git a/apps/codecs/lib/osx.dummy.c b/apps/codecs/lib/osx.dummy.c deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/apps/codecs/liba52/AUTHORS b/apps/codecs/liba52/AUTHORS deleted file mode 100644 index a6bd695228..0000000000 --- a/apps/codecs/liba52/AUTHORS +++ /dev/null @@ -1,23 +0,0 @@ -Aaron Holtzman started the project and -made the initial working implementation. - -Michel Lespinasse did major changes for speed and -conformance and is the current maintainer. - -Other contributors include: - Gildas Bazin - mingw32 port - Billy Biggs - most of liba52.txt - Jeroen Dobbelaere - fixed point version - Eduard Hasenleithner - gcc 3.0 fixes - HÃ¥kan Hjort - Solaris output, mlib code - Charles M. Hannum - fixes - Chris Hodges - made the library reentrant - Michael Holzt - OSS output.c and misc errata - Angelos Keromytis - OpenBSD fixes - David I. Lehn - API cleanup suggestion - Don Mahurin - stdin support for extract_a52 - Jim Miller - IRIX output.c - Takefumi Sayo - FreeBSD tweak - Shoji Tokunaga - aif file output - -(let me know if I forgot anyone) diff --git a/apps/codecs/liba52/COPYING b/apps/codecs/liba52/COPYING deleted file mode 100644 index 60549be514..0000000000 --- a/apps/codecs/liba52/COPYING +++ /dev/null @@ -1,340 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) 19yy - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) 19yy name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General -Public License instead of this License. diff --git a/apps/codecs/liba52/ChangeLog b/apps/codecs/liba52/ChangeLog deleted file mode 100644 index 4adac364eb..0000000000 --- a/apps/codecs/liba52/ChangeLog +++ /dev/null @@ -1,97 +0,0 @@ -a52dec-0.7.4 Sat Jul 27 20:44:00 PDT 2002 --The library is now fully reentrant. --Added win32 output module, al file output, gain control. --A few additional portability enhancements. - -a52dec-0.7.3 Wed Feb 20 23:38:22 PST 2002 --rewrite of the imdct code, making a52dec 40% to 80% faster than version 0.7.2 --fixed one memory corruption problem in parse.c --small liba52 portability fixes --byte order and CRLF bugfixes in wav file output --aif file output --IRIX al sound output (untested, tell us if it works) - -a52dec-0.7.2 Sun Dec 16 14:39:56 PST 2001 --demuxer improvements, with support for TS streams. --smaller demux buffer, making it easier to use a52dec as a pipe --wav output --avoid -fPIC when possible (-prefer-non-pic) --support for vc++ and TenDRA --portability fixes - -a52dec-0.7.1b Fri Aug 31 02:37:23 PDT 2001 --removed an #include that was only breaking libc5 builds - -a52dec-0.7.1 Thu Aug 30 02:13:23 PDT 2001 --gcc 3.0 fixes --mlib fixes (now passes the test suite) --in a52dec.c, made sample_data and flags static --removed a few statics in liba52/parse.c (still not reentrant, but closer) - -a52dec-0.7.0 Thu Aug 23 23:18:00 PDT 2001 --Downmix to arbitrary speaker configurations --Dynamic range compression --Major speedups: 2x for 2.0 streams with 2.0 output, - 3x for 5.1 streams with 2.0 output. --New library interface --Rematrixing bugfix --Higher precision - -ac3dec-0.6.1 Mon Mar 27 20:27:06 EST 2000 --Fix another 2.0 problem (rematrix was wrong). --Fix the never resync on a bad crc bug. - -ac3dec-0.6.0 Sat Mar 18 19:43:25 EST 2000 --New library interface --Fix bug wrt coupling channels that was causing sound quality problems. --Fix 2.0 mode problems (aka the I forgot to implement the phase flags bug). --All around speed improvements (almost twice as fast) --Improved robustness when fed bad data. The entire frame is checksummed before playback. - -ac3dec-0.5.6 Tue Nov 16 00:37:34 EST 1999 --Irix support --Alpha fixes --Minor performance enhancements to downmix and imdct --OpenBSD fixes --extract_ac3 can now read from stdin --Change output_linux to block on write instead of using the - ring buffer. Let me know if this causes/fixes any problems - -ac3dec-0.5.5 Wed Aug 25 15:36:44 EDT 1999 --Fixed a cut and paste bug (argh!) in parse.c which potentially - screwed up delta bit allocation info. --Martin Mueller informed me that I was missing - some corrections from the AC-3 errata document. It turns out that - I used an earlier version of the errata when I initially wrote ac3dec. - Fortunately the errata fix the outstanding bugs that I was pulling - my hair out on for a long time. Woohoo! Thanks Martin. Kudos to Dolby - Labs for keeping their documentation up to date as well. --stereo downmixing (downmix.c) is now in. Matrix encoded surround - (Dolby Prologic Surround) should work too. --clipping due to high level signals has been fixed. We normalize a - block of samples by its maximum absolute value if the max exceeds - the %100 digital level. This shouldn't be a problem, but for some - reason some channels have a dynamic range that exceeds [-1.0,1.0]. - I blame the encoder :) --Multiple track support in extract_ac3. Simply just give it the track - number you want [1,8] after the filename. - -ac3dec-0.5.4 Thu Jul 29 16:55:10 PDT 1999 --Fixed a stupid bug with the coupling channel that was causing - high frequencies to be attenuated. --Re-wrote the extract_ac3 tool. --Added to a tool to verify the checksums on a given AC3 stream. - (tools/verify_ac3) - -ac3dec-0.5.3 Mon Jul 12 10:45:56 PDT 1999 --Fixed problems related to streams with coupling channel enabled. --Minor performance enhancements - -ac3dec-0.5.2 Sun Jul 4 12:00:25 PDT 1999 --output_linux.c patch provided by Michael Holzt - -ac3dec-0.5.1 Wed Jun 30 17:48:52 PDT 1999 --Compiles and dies gracefully under Linux now. - -ac3dec-0.5.0 Wed Jun 23 11:06:06 EDT 1999 --First public release of ac3dec. diff --git a/apps/codecs/liba52/HISTORY b/apps/codecs/liba52/HISTORY deleted file mode 100644 index c2b9d02ee1..0000000000 --- a/apps/codecs/liba52/HISTORY +++ /dev/null @@ -1,28 +0,0 @@ -changes that affected the PCM output: - -2001/05/14 05:48:59 - aaron's 0.6.1 was cutting before the end - -2001/06/04 01:42:47 - slightly adjusted some values (volume, downmix adjustemtn, clev/slev tables) -2001/06/04 05:48:31 - added adjust_level to the downmix - -2001/06/12 -2001/06/13 - changed the order of the dither() calls - also introduced bug with thx_2_0 stream - -2001/06/22 08:23:37 - fixed bug with thx_2_0 stream (see parse.c) - -2001/07/02 08:44:55 - changed float-to-int conversion (+ added saturation) - -2001/07/06 06:53:01 - more precise imdct init, more precise q_* coefficients - -2001/07/06 08:52:30 - rematrixing fixes - -2001/07/26 21:31:39 - do 3dB dither reduction in coeff_get() not dither_gen() - -2001/08/09 08:11:31 - implemented dynamic range compression - -2002/02/24 08:54:49 - window function computed at runtime, with more precision - -2003/01/28 06.57:37 - switched to integer q_* coefficients - -2003/01/28 07:39:35 - use level of 0.75 for dithering instead of 0.707 diff --git a/apps/codecs/liba52/INSTALL b/apps/codecs/liba52/INSTALL deleted file mode 100644 index 30a07fecff..0000000000 --- a/apps/codecs/liba52/INSTALL +++ /dev/null @@ -1,58 +0,0 @@ -Unix build instructions ------------------------ - -./configure -make -make install - -If you install from CVS you'll have to run ./bootstrap first - - -Building for win32 ------------------- - -There are at least three ways to do it: - -- natively on Windows using Microsoft VC++ and the vc++ project - included in this distribution. - -- natively on Windows using MSYS + MINGW (www.mingw.org) (MSYS is a - minimal build environnement to compile unixish projects under - windows. It provides all the common unix tools like sh, gmake...) - -- or on Linux, using the mingw32 cross-compiler - - -Building using MSYS + MINGW on windows --------------------------------------- - -First you will need to download and install the latest MSYS (version -1.0.7 as of now) and MINGW. The installation is really easy. Begin -with the MSYS auto-installer and once this is done, extract MINGW into -c:\msys\1.0\mingw. You also have to remember to remove the make -utility included with MINGW as it conflicts with the one from MSYS -(just rename or remove c:\msys\1.0\mingw\bin\make.exe). - -http://prdownloads.sourceforge.net/mingw/MSYS-1.0.7-i686-2002.04.24-1.exe -http://prdownloads.sourceforge.net/mingw/MinGW-1.1.tar.gz - -Then you can build the package using: -# ./configure -# make - - -Building using the mingw32 cross-compiler ------------------------------------------ - -You need to install mingw32 first. For Debian GNU/Linux users, there -is a mingw32 package. Otherwise you might get it from the mingw site -at http://www.mingw.org/download.shtml. - -The videolan project also keeps precompiled mingw32 binaries at -http://www.videolan.org/vlc/windows.html . If you install these, -you'll have to set your PATH accordingly to include -/usr/local/cross-tools/bin too. - -The build should then proceed using something like: -# CC=i586-mingw32msvc-gcc ./configure --host=i586-mingw32msvc -# make diff --git a/apps/codecs/liba52/NEWS b/apps/codecs/liba52/NEWS deleted file mode 100644 index 4bee9cac8d..0000000000 --- a/apps/codecs/liba52/NEWS +++ /dev/null @@ -1,46 +0,0 @@ -a52dec-0.7.4 Sat Jul 27 20:44:00 PDT 2002 - -The library is now fully reentrant. - -Added win32 output module, al file output, gain control. - -A few additional portability enhancements. - - -a52dec-0.7.3 Wed Feb 20 23:38:22 PST 2002 - -Performance enhancements, from 40% to 80% depending on streams. - -Fixed a few embarassing bugs in liba52: one memory corruption issue -and a few minor portability problems. - -Several new output modules, and fixes in the existing .wav file output. - - -a52dec-0.7.2 Sun Dec 16 14:39:56 PST 2001 - -Minor bugfixes, performance and portability enhancements. - -Also added wav format output, and reduced the demux buffer size which -makes it easier to use a52dec as a pipe. - - -a52dec-0.7.1 Thu Aug 30 02:13:23 PDT 2001 - -Minor release for bugfixes. Looks like 0.7.0 was a bit rushed out. - -Now compiles with gcc 3.0, made sure mlib implementation works, and -fixed a small bug in the a52dec test program. - - -a52dec-0.7.0 Thu Aug 23 23:18:00 PDT 2001 - -First release since more than one year ! - -The most user-noticeable additions are the downmix to arbitrary -speaker configurations, and the implementation of dynamic range -compression. - -The speed has been improved by a factor of 2 to 3, the conformance and -precision should be higher, and we also fixed a small bug when playing -stereo rematrixed streams. diff --git a/apps/codecs/liba52/README b/apps/codecs/liba52/README deleted file mode 100644 index eb6c64df84..0000000000 --- a/apps/codecs/liba52/README +++ /dev/null @@ -1,180 +0,0 @@ - - -ABOUT LIBA52 - -liba52 is a free library for decoding ATSC A/52 streams. It is -released under the terms of the GPL license. The A/52 standard is used -in a variety of applications, including digital television and DVD. It -is also known as AC-3. - -The main goals in liba52 development are: - - * Portability - Currently all of the code is written in C, and - when we write platform-specific optimizations we will always - keep a generic C routine to fall back on. - - * Reuseability - we do not want liba52 to include any - project-specific code, but it should still include enough - features to be used by very diverse projects. - - * Precision - We are trying to implement all of the A/52 - standard, and to have a very precise output by doing all the - calculations in floating point. We have a test suite that - detects any deviation in the output when compared to previous - versions. We do not have access to official A/52 test vectors - though, so we have to use our judgement to ensure that such - deviations are only intruduced when we fix bugs ! - - * Speed - liba52 is really fast, on any modern PC it should take - only a few percent of CPU time. - -The project homepage is at http://liba52.sourceforge.net/ - - -A52DEC - -a52dec is a test program for liba52. It decodes ATSC A/52 streams, and -also includes a demultiplexer for mpeg-1 and mpeg-2 program streams. - -The liba52 source code is always distributed in the a52dec package, to -make sure it easier for people to test it. - -The basic usage is to just type "a52dec file" where file is an ATSC -A/52 file. - -The "-s" option must be used for multiplexed (audio and video) mpeg-2 -files. These files are usualy found on the internet or on unencrypted -DVDs. - -The "-o" option is used to select a given output layer. By default -a52dec does a stereo downmix and outputs to your speakers, but you can -try other choices using this option. This is also used for performance -testing and conformance testing. - -The "-c" option is used to disable all optimizations (currently only djbfft). - -The "-r" option is used to disable the dynamic range compression. - - -OTHER PROJECTS USING LIBA52 - -liba52 (and its ancestor libac3) is being used by various other -projects, including: - - * xine (http://xine.sourceforge.net/) - started as a simple - mpeg-2 audio and video decoder, but it since became a - full-featured DVD and video media player. - - * VideoLAN (http://www.videolan.org/) - video streaming over an - ethernet network, can also be used as a standalone player. - - * MPlayer (http://www.MPlayerHQ.hu) - another good player, it is - also very robust against damaged streams. - - * movietime (http://movietime.sourceforge.net/) - still quite - young, but it looks very promising ! - - * ffmpeg (http://ffmpeg.sourceforge.net/) - a nice audio/video - encoder and transcoder, uses liba52 for decoding A/52 streams. - - * Ogle (http://www.dtek.chalmers.se/groups/dvd/) - a good DVD - player with menu support - - * a52decX (http://homepage1.nifty.com/~toku/software_en.html) - - a graphical interface for a52dec in macintosh osX. - - * TCVP (http://tcvp.sf.net) - video and music player for unix. - - * bd4go (http://denisx.dyndns.org/bd4go/) - another graphical - interface for macintosh osX. - - * drip (http://drip.sourceforge.net/) - a DVD to DIVX transcoder. - - * OMS (http://www.linuxvideo.org/oms/) - - * XMPS (http://xmps.sourceforge.net/) - - * GStreamer (http://www.gstreamer.net/) - a framework for - streaming media; it has an A/52 decoding plugin based on liba52. - - * mpeglib (http://mpeglib.sourceforge.net/) - a video decoding - library that usess liba52 when decoding A/52 streams. - -If you use liba52 in another project, let us know ! - - -TASKS - -There are several places where we could easily use some help: - - * Web design: This site sucks ! at the very least, we'd like to - come up with a nicer background picture and a logo. - - * Testing: If you find any stream that does not decode right - with liba52, let us know ! The best thing would be to mail to - the liba52-devel mailing list. Also if you have access to - encoders, we'd love to get test streams that would be free of - rights - so that we can put them on this server. - - * Coding: you can have a look in the TODO file first ! The most - important item is probably to make the code fully reentrant. - - * Porting: If you're porting to a new architecture, you might - want to experiment with the compile flags defined in - configure.in . When you figure out whats fastest on your - platform, send us a patch ! - - -REFERENCES - -The A/52 standard, as published by the ATSC, is available at -http://www.atsc.org/standards/a_52a.pdf - - -CVS SNAPSHOTS - -A daily snapshot is created using "make distcheck" every night and -uploaded to http://liba52.sourceforge.net/files/a52dec-snapshot.tar.gz . -It is easier to use than the CVS repository, because you do not need -to have the right versions of automake, autoconf and libtool -installed. It might be convenient when working on a liba52 port for -example. - - -CVS REPOSITORY - -The latest liba52 and a52dec source code can always be found by -anonymous CVS: - -# export CVSROOT=:pserver:anonymous@cvs.liba52.sourceforge.net:/cvsroot/liba52 -# cvs login (Just press Return when prompted for a password) -# cvs checkout a52dec - -You can also browse the latest changes online at -http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/liba52/a52dec/ - -The other CVS modules are ac3dec-livid for the CVS history of the -project while it was still hosted on the linuxvideo.org servers, and -ac3dec for the CVS history of the project while the linuxvideo.org -servers were down and before the library switched its name to liba52. - - -MAILING LISTS - -See the subscription information at http://liba52.sourceforge.net/lists.html - -liba52-devel - -This is the main mailing list for technical discussion about -liba52. Anyone wanting to work on liba52, or maybe just stay informed -about the development process, should probably subscribe to this list. - -liba52-checkins - -All liba52 checkins are announced there. This is a good way to keep -track of what goes into CVS. - -liba52-announce - -This is a very low traffic mailing list, only for announcements of new -versions of liba52. Only project administrators can post there. diff --git a/apps/codecs/liba52/README.rockbox b/apps/codecs/liba52/README.rockbox deleted file mode 100644 index 79768c5d72..0000000000 --- a/apps/codecs/liba52/README.rockbox +++ /dev/null @@ -1,27 +0,0 @@ -Library: liba52-0.7.5 (CVS version 2005-02-16) -Imported: 2005-02-16 by Dave Chapman - - -This directory contains a local version of liba52 for decoding ATSC -A/52 (aka AC-3) audio streams. A/52 is commonly used in digital TV and -on DVDs. - -LICENSING INFORMATION - -liba52 is released under the GNU General Public License as described -in the COPYING file in this directory. - - -IMPORT DETAILS - -The base version first imported into Rockbox was the CVS version of -liba52-0.7.5 (0.7.4 was at the time the latest official) which was -checked out of sourceforge on 2005-02-16. - -The .[ch] files from a52dec/liba52/ and a52dec/include/ as well as the -documentation files in a52dec/ were imported into Rockbox. The other -files in the archive relate to the test player (a52dec) and were not -imported. - -A simple config.h file was added to enable liba52's fixed-point -integer-only mode and to specify the endianness of the target CPU. diff --git a/apps/codecs/liba52/SOURCES b/apps/codecs/liba52/SOURCES deleted file mode 100644 index 733b95e8a6..0000000000 --- a/apps/codecs/liba52/SOURCES +++ /dev/null @@ -1,5 +0,0 @@ -bit_allocate.c -bitstream.c -downmix.c -imdct.c -parse.c diff --git a/apps/codecs/liba52/TODO b/apps/codecs/liba52/TODO deleted file mode 100644 index dc5fb84203..0000000000 --- a/apps/codecs/liba52/TODO +++ /dev/null @@ -1,17 +0,0 @@ -* look at possible overflow/precision issues in integer port - -* redo all bit allocation if previous frame had zero_snr_offsets -* make dynrng work in dual-channel streams - -* implement A/52a downmix extensions -* reduce size of delay buffer by 50% -* include float->s16 conversion in liba52 API ? -* include up/downsampling 44100<->48000 in liba52 API ? -* include audio dithering in liba52 API ? -* API extensions might be at a different level (base vs. extended) - -* use restrict pointers where appropriate -* avoid overflows, including reading the a52 stream !!! -* faster bitstream parsing ? -* make dither code faster (generate dither table in advance ?) -* SIMD optimizations diff --git a/apps/codecs/liba52/a52.h b/apps/codecs/liba52/a52.h deleted file mode 100644 index e852e8d6bb..0000000000 --- a/apps/codecs/liba52/a52.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * a52.h - * Copyright (C) 2000-2003 Michel Lespinasse - * Copyright (C) 1999-2000 Aaron Holtzman - * - * This file is part of a52dec, a free ATSC A-52 stream decoder. - * See http://liba52.sourceforge.net/ for updates. - * - * a52dec is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * a52dec is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef A52_H -#define A52_H - -#if defined(LIBA52_FIXED) -typedef int32_t sample_t; -typedef int32_t level_t; -#elif defined(LIBA52_DOUBLE) -typedef double sample_t; -typedef double level_t; -#else -typedef float sample_t; -typedef float level_t; -#endif - -typedef struct a52_state_s a52_state_t; - -#define A52_CHANNEL 0 -#define A52_MONO 1 -#define A52_STEREO 2 -#define A52_3F 3 -#define A52_2F1R 4 -#define A52_3F1R 5 -#define A52_2F2R 6 -#define A52_3F2R 7 -#define A52_CHANNEL1 8 -#define A52_CHANNEL2 9 -#define A52_DOLBY 10 -#define A52_CHANNEL_MASK 15 - -#define A52_LFE 16 -#define A52_ADJUST_LEVEL 32 - -a52_state_t * a52_init (uint32_t mm_accel); -sample_t * a52_samples (a52_state_t * state); -int a52_syncinfo (uint8_t * buf, int * flags, - int * sample_rate, int * bit_rate); -int a52_frame (a52_state_t * state, uint8_t * buf, int * flags, - level_t * level, sample_t bias); -void a52_dynrng (a52_state_t * state, - level_t (* call) (level_t, void *), void * data); -int a52_block (a52_state_t * state); -void a52_free (a52_state_t * state); - -#endif /* A52_H */ diff --git a/apps/codecs/liba52/a52_internal.h b/apps/codecs/liba52/a52_internal.h deleted file mode 100644 index 3b3d21c9a3..0000000000 --- a/apps/codecs/liba52/a52_internal.h +++ /dev/null @@ -1,215 +0,0 @@ -/* - * a52_internal.h - * Copyright (C) 2000-2003 Michel Lespinasse - * Copyright (C) 1999-2000 Aaron Holtzman - * - * This file is part of a52dec, a free ATSC A-52 stream decoder. - * See http://liba52.sourceforge.net/ for updates. - * - * a52dec is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * a52dec is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -typedef struct { - uint8_t bai; /* fine SNR offset, fast gain */ - uint8_t deltbae; /* delta bit allocation exists */ - int8_t deltba[50]; /* per-band delta bit allocation */ -} ba_t; - -typedef struct { - uint8_t exp[256]; /* decoded channel exponents */ - int8_t bap[256]; /* derived channel bit allocation */ -} expbap_t; - -struct a52_state_s { - uint8_t fscod; /* sample rate */ - uint8_t halfrate; /* halfrate factor */ - uint8_t acmod; /* coded channels */ - uint8_t lfeon; /* coded lfe channel */ - level_t clev; /* centre channel mix level */ - level_t slev; /* surround channels mix level */ - - int output; /* type of output */ - level_t level; /* output level */ - sample_t bias; /* output bias */ - - int dynrnge; /* apply dynamic range */ - level_t dynrng; /* dynamic range */ - void * dynrngdata; /* dynamic range callback funtion and data */ - level_t (* dynrngcall) (level_t range, void * dynrngdata); - - uint8_t chincpl; /* channel coupled */ - uint8_t phsflginu; /* phase flags in use (stereo only) */ - uint8_t cplstrtmant; /* coupling channel start mantissa */ - uint8_t cplendmant; /* coupling channel end mantissa */ - uint32_t cplbndstrc; /* coupling band structure */ - level_t cplco[5][18]; /* coupling coordinates */ - - /* derived information */ - uint8_t cplstrtbnd; /* coupling start band (for bit allocation) */ - uint8_t ncplbnd; /* number of coupling bands */ - - uint8_t rematflg; /* stereo rematrixing */ - - uint8_t endmant[5]; /* channel end mantissa */ - - uint16_t bai; /* bit allocation information */ - - uint32_t * buffer_start; - uint16_t lfsr_state; /* dither state */ - uint32_t bits_left; - uint32_t current_word; - - uint8_t csnroffst; /* coarse SNR offset */ - ba_t cplba; /* coupling bit allocation parameters */ - ba_t ba[5]; /* channel bit allocation parameters */ - ba_t lfeba; /* lfe bit allocation parameters */ - - uint8_t cplfleak; /* coupling fast leak init */ - uint8_t cplsleak; /* coupling slow leak init */ - - expbap_t cpl_expbap; - expbap_t fbw_expbap[5]; - expbap_t lfe_expbap; - - sample_t * samples; - int downmixed; -}; - -#define LEVEL_PLUS6DB 2.0 -#define LEVEL_PLUS3DB 1.4142135623730951 -#define LEVEL_3DB 0.7071067811865476 -#define LEVEL_45DB 0.5946035575013605 -#define LEVEL_6DB 0.5 - -#define EXP_REUSE (0) -#define EXP_D15 (1) -#define EXP_D25 (2) -#define EXP_D45 (3) - -#define DELTA_BIT_REUSE (0) -#define DELTA_BIT_NEW (1) -#define DELTA_BIT_NONE (2) -#define DELTA_BIT_RESERVED (3) - -void a52_bit_allocate (a52_state_t * state, ba_t * ba, int bndstart, - int start, int end, int fastleak, int slowleak, - expbap_t * expbap); - -int a52_downmix_init (int input, int flags, level_t * level, - level_t clev, level_t slev); -int a52_downmix_coeff (level_t * coeff, int acmod, int output, level_t level, - level_t clev, level_t slev); -void a52_downmix (sample_t * samples, int acmod, int output, - level_t clev, level_t slev); -void a52_upmix (sample_t * samples, int acmod, int output); - -void a52_imdct_init (uint32_t mm_accel); -void a52_imdct_256 (sample_t * data, sample_t * delay); -void a52_imdct_512 (sample_t * data, sample_t * delay); - -#define ROUND(x) ((int)((x) + ((x) > 0 ? 0.5 : -0.5))) - -#ifndef LIBA52_FIXED - -typedef sample_t quantizer_t; -#define SAMPLE(x) (x) -#define LEVEL(x) (x) -#define MUL(a,b) ((a) * (b)) -#define MUL_L(a,b) ((a) * (b)) -#define MUL_C(a,b) ((a) * (b)) -#define DIV(a,b) ((a) / (b)) -#define BIAS(x) ((x) + bias) - -#else /* LIBA52_FIXED */ - -typedef int16_t quantizer_t; -#define SAMPLE(x) (sample_t)((x) * (1 << 30)) -#define LEVEL(x) (level_t)((x) * (1 << 26)) - -#if 0 -#define MUL(a,b) ((int)(((int64_t)(a) * (b) + (1 << 29)) >> 30)) -#define MUL_L(a,b) ((int)(((int64_t)(a) * (b) + (1 << 25)) >> 26)) -#elif defined(CPU_COLDFIRE) -/* loses 1 bit of accuracy */ -#define MUL(a, b) \ -({ \ - int32_t t; \ - asm volatile ( \ - "mac.l %[A], %[B], %%acc0\n\t" \ - "movclr.l %%acc0, %[t]\n\t" \ - "asl.l #1, %[t]" \ - : [t] "=d" (t) \ - : [A] "r" ((a)), [B] "r" ((b))); \ - t; \ -}) -/* loses 5 bits of accuracy */ -#define MUL_L(a, b) \ -({ \ - int32_t t; \ - asm volatile ( \ - "mac.l %[A], %[B], %%acc0\n\t" \ - "movclr.l %%acc0, %[t]\n\t" \ - "asl.l #5, %[t]" \ - : [t] "=d" (t) \ - : [A] "r" ((a)), [B] "r" ((b))); \ - t; \ -}) - -#elif defined(CPU_ARM) -#define MUL(x, y) \ - ({ int32_t __hi; \ - uint32_t __lo; \ - int32_t __result; \ - asm ("smull %0, %1, %3, %4\n\t" \ - "movs %2, %1, lsl #2" \ - : "=&r" (__lo), "=&r" (__hi), "=r" (__result) \ - : "%r" (x), "r" (y) \ - : "cc"); \ - __result; \ - }) - - -#define MUL_L(x, y) \ - ({ int32_t __hi; \ - uint32_t __lo; \ - int32_t __result; \ - asm ("smull %0, %1, %3, %4\n\t" \ - "movs %0, %0, lsr %5\n\t" \ - "adc %2, %0, %1, lsl %6" \ - : "=&r" (__lo), "=&r" (__hi), "=r" (__result) \ - : "%r" (x), "r" (y), \ - "M" (26), "M" (32 - 26) \ - : "cc"); \ - __result; \ - }) - - -#elif 1 -#define MUL(a,b) \ -({ int32_t _ta=(a), _tb=(b), _tc; \ - _tc=(_ta & 0xffff)*(_tb >> 16)+(_ta >> 16)*(_tb & 0xffff); (int32_t)(((_tc >> 14))+ (((_ta >> 16)*(_tb >> 16)) << 2 )); }) -#define MUL_L(a,b) \ -({ int32_t _ta=(a), _tb=(b), _tc; \ - _tc=(_ta & 0xffff)*(_tb >> 16)+(_ta >> 16)*(_tb & 0xffff); (int32_t)((_tc >> 10) + (((_ta >> 16)*(_tb >> 16)) << 6)); }) -#else -#define MUL(a,b) (((a) >> 15) * ((b) >> 15)) -#define MUL_L(a,b) (((a) >> 13) * ((b) >> 13)) -#endif - -#define MUL_C(a,b) MUL_L (a, LEVEL (b)) -#define DIV(a,b) ((((int64_t)LEVEL (a)) << 26) / (b)) -#define BIAS(x) ((x)) - -#endif diff --git a/apps/codecs/liba52/attributes.h b/apps/codecs/liba52/attributes.h deleted file mode 100644 index 988abc0311..0000000000 --- a/apps/codecs/liba52/attributes.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * attributes.h - * Copyright (C) 2000-2003 Michel Lespinasse - * Copyright (C) 1999-2000 Aaron Holtzman - * - * This file is part of a52dec, a free ATSC A-52 stream decoder. - * See http://liba52.sourceforge.net/ for updates. - * - * a52dec is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * a52dec is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* use gcc attribs to align critical data structures */ -#ifdef ATTRIBUTE_ALIGNED_MAX -#define ATTR_ALIGN(align) __attribute__ ((__aligned__ ((ATTRIBUTE_ALIGNED_MAX < align) ? ATTRIBUTE_ALIGNED_MAX : align))) -#else -#define ATTR_ALIGN(align) -#endif - -#ifdef HAVE_BUILTIN_EXPECT -#define likely(x) __builtin_expect ((x) != 0, 1) -#define unlikely(x) __builtin_expect ((x) != 0, 0) -#else -#define likely(x) (x) -#define unlikely(x) (x) -#endif diff --git a/apps/codecs/liba52/bit_allocate.c b/apps/codecs/liba52/bit_allocate.c deleted file mode 100644 index aaac245913..0000000000 --- a/apps/codecs/liba52/bit_allocate.c +++ /dev/null @@ -1,265 +0,0 @@ -/* - * bit_allocate.c - * Copyright (C) 2000-2003 Michel Lespinasse - * Copyright (C) 1999-2000 Aaron Holtzman - * - * This file is part of a52dec, a free ATSC A-52 stream decoder. - * See http://liba52.sourceforge.net/ for updates. - * - * a52dec is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * a52dec is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "config-a52.h" - -#include - -#include "a52.h" -#include "a52_internal.h" - -static int hthtab[3][50] IDATA_ATTR = { - {0x730, 0x730, 0x7c0, 0x800, 0x820, 0x840, 0x850, 0x850, 0x860, 0x860, - 0x860, 0x860, 0x860, 0x870, 0x870, 0x870, 0x880, 0x880, 0x890, 0x890, - 0x8a0, 0x8a0, 0x8b0, 0x8b0, 0x8c0, 0x8c0, 0x8d0, 0x8e0, 0x8f0, 0x900, - 0x910, 0x910, 0x910, 0x910, 0x900, 0x8f0, 0x8c0, 0x870, 0x820, 0x7e0, - 0x7a0, 0x770, 0x760, 0x7a0, 0x7c0, 0x7c0, 0x6e0, 0x400, 0x3c0, 0x3c0}, - {0x710, 0x710, 0x7a0, 0x7f0, 0x820, 0x830, 0x840, 0x850, 0x850, 0x860, - 0x860, 0x860, 0x860, 0x860, 0x870, 0x870, 0x870, 0x880, 0x880, 0x880, - 0x890, 0x890, 0x8a0, 0x8a0, 0x8b0, 0x8b0, 0x8c0, 0x8c0, 0x8e0, 0x8f0, - 0x900, 0x910, 0x910, 0x910, 0x910, 0x900, 0x8e0, 0x8b0, 0x870, 0x820, - 0x7e0, 0x7b0, 0x760, 0x770, 0x7a0, 0x7c0, 0x780, 0x5d0, 0x3c0, 0x3c0}, - {0x680, 0x680, 0x750, 0x7b0, 0x7e0, 0x810, 0x820, 0x830, 0x840, 0x850, - 0x850, 0x850, 0x860, 0x860, 0x860, 0x860, 0x860, 0x860, 0x860, 0x860, - 0x870, 0x870, 0x870, 0x870, 0x880, 0x880, 0x880, 0x890, 0x8a0, 0x8b0, - 0x8c0, 0x8d0, 0x8e0, 0x8f0, 0x900, 0x910, 0x910, 0x910, 0x900, 0x8f0, - 0x8d0, 0x8b0, 0x840, 0x7f0, 0x790, 0x760, 0x7a0, 0x7c0, 0x7b0, 0x720} -}; - -static int8_t baptab[305] IDATA_ATTR = { - 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* 93 padding elems */ - - 16, 16, 16, 16, 16, 16, 16, 16, 16, 14, 14, 14, 14, 14, 14, 14, - 14, 12, 12, 12, 12, 11, 11, 11, 11, 10, 10, 10, 10, 9, 9, 9, - 9, 8, 8, 8, 8, 7, 7, 7, 7, 6, 6, 6, 6, 5, 5, 5, - 5, 4, 4, -3, -3, 3, 3, 3, -2, -2, -1, -1, -1, -1, -1, 0, - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0 /* 148 padding elems */ -}; - -static int bndtab[30] IDATA_ATTR = {21, 22, 23, 24, 25, 26, 27, 28, 31, 34, - 37, 40, 43, 46, 49, 55, 61, 67, 73, 79, - 85, 97, 109, 121, 133, 157, 181, 205, 229, 253}; - -static int8_t latab[256] IDATA_ATTR = { - -64, -63, -62, -61, -60, -59, -58, -57, -56, -55, -54, -53, - -52, -52, -51, -50, -49, -48, -47, -47, -46, -45, -44, -44, - -43, -42, -41, -41, -40, -39, -38, -38, -37, -36, -36, -35, - -35, -34, -33, -33, -32, -32, -31, -30, -30, -29, -29, -28, - -28, -27, -27, -26, -26, -25, -25, -24, -24, -23, -23, -22, - -22, -21, -21, -21, -20, -20, -19, -19, -19, -18, -18, -18, - -17, -17, -17, -16, -16, -16, -15, -15, -15, -14, -14, -14, - -13, -13, -13, -13, -12, -12, -12, -12, -11, -11, -11, -11, - -10, -10, -10, -10, -10, -9, -9, -9, -9, -9, -8, -8, - -8, -8, -8, -8, -7, -7, -7, -7, -7, -7, -6, -6, - -6, -6, -6, -6, -6, -6, -5, -5, -5, -5, -5, -5, - -5, -5, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, - -4, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, - -3, -3, -3, -2, -2, -2, -2, -2, -2, -2, -2, -2, - -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0 -}; - -#define UPDATE_LEAK() \ -do { \ - fastleak += fdecay; \ - if (fastleak > psd + fgain) \ - fastleak = psd + fgain; \ - slowleak += sdecay; \ - if (slowleak > psd + sgain) \ - slowleak = psd + sgain; \ -} while (0) - -#define COMPUTE_MASK() \ -do { \ - if (psd > dbknee) \ - mask -= (psd - dbknee) >> 2; \ - if (mask > hth [i >> halfrate]) \ - mask = hth [i >> halfrate]; \ - mask -= snroffset + 128 * deltba[i]; \ - mask = (mask > 0) ? 0 : ((-mask) >> 5); \ - mask -= floor; \ -} while (0) - -void a52_bit_allocate (a52_state_t * state, ba_t * ba, int bndstart, - int start, int end, int fastleak, int slowleak, - expbap_t * expbap) -{ - static int slowgain[4] = {0x540, 0x4d8, 0x478, 0x410}; - static int dbpbtab[4] = {0xc00, 0x500, 0x300, 0x100}; - static int floortab[8] = {0x910, 0x950, 0x990, 0x9d0, - 0xa10, 0xa90, 0xb10, 0x1400}; - - int i, j; - uint8_t * exp; - int8_t * bap; - int fdecay, fgain, sdecay, sgain, dbknee, floor, snroffset; - int psd, mask; - int8_t * deltba; - int * hth; - int halfrate; - - halfrate = state->halfrate; - fdecay = (63 + 20 * ((state->bai >> 7) & 3)) >> halfrate; /* fdcycod */ - fgain = 128 + 128 * (ba->bai & 7); /* fgaincod */ - sdecay = (15 + 2 * (state->bai >> 9)) >> halfrate; /* sdcycod */ - sgain = slowgain[(state->bai >> 5) & 3]; /* sgaincod */ - dbknee = dbpbtab[(state->bai >> 3) & 3]; /* dbpbcod */ - hth = hthtab[state->fscod]; - /* - * if there is no delta bit allocation, make deltba point to an area - * known to contain zeroes. baptab+156 here. - */ - deltba = (ba->deltbae == DELTA_BIT_NONE) ? baptab + 156 : ba->deltba; - floor = floortab[state->bai & 7]; /* floorcod */ - snroffset = 960 - 64 * state->csnroffst - 4 * (ba->bai >> 3) + floor; - floor >>= 5; - - exp = expbap->exp; - bap = expbap->bap; - - i = bndstart; - j = start; - if (start == 0) { /* not the coupling channel */ - int lowcomp; - - lowcomp = 0; - j = end - 1; - do { - if (i < j) { - if (exp[i+1] == exp[i] - 2) - lowcomp = 384; - else if (lowcomp && (exp[i+1] > exp[i])) - lowcomp -= 64; - } - psd = 128 * exp[i]; - mask = psd + fgain + lowcomp; - COMPUTE_MASK (); - bap[i] = (baptab+156)[mask + 4 * exp[i]]; - i++; - } while ((i < 3) || ((i < 7) && (exp[i] > exp[i-1]))); - fastleak = psd + fgain; - slowleak = psd + sgain; - - while (i < 7) { - if (i < j) { - if (exp[i+1] == exp[i] - 2) - lowcomp = 384; - else if (lowcomp && (exp[i+1] > exp[i])) - lowcomp -= 64; - } - psd = 128 * exp[i]; - UPDATE_LEAK (); - mask = ((fastleak + lowcomp < slowleak) ? - fastleak + lowcomp : slowleak); - COMPUTE_MASK (); - bap[i] = (baptab+156)[mask + 4 * exp[i]]; - i++; - } - - if (end == 7) /* lfe channel */ - return; - - do { - if (exp[i+1] == exp[i] - 2) - lowcomp = 320; - else if (lowcomp && (exp[i+1] > exp[i])) - lowcomp -= 64; - psd = 128 * exp[i]; - UPDATE_LEAK (); - mask = ((fastleak + lowcomp < slowleak) ? - fastleak + lowcomp : slowleak); - COMPUTE_MASK (); - bap[i] = (baptab+156)[mask + 4 * exp[i]]; - i++; - } while (i < 20); - - while (lowcomp > 128) { /* two iterations maximum */ - lowcomp -= 128; - psd = 128 * exp[i]; - UPDATE_LEAK (); - mask = ((fastleak + lowcomp < slowleak) ? - fastleak + lowcomp : slowleak); - COMPUTE_MASK (); - bap[i] = (baptab+156)[mask + 4 * exp[i]]; - i++; - } - j = i; - } - - do { - int startband, endband; - - startband = j; - endband = (bndtab[i-20] < end) ? bndtab[i-20] : end; - psd = 128 * exp[j++]; - while (j < endband) { - int next, delta; - - next = 128 * exp[j++]; - delta = next - psd; - switch (delta >> 9) { - case -6: case -5: case -4: case -3: case -2: - psd = next; - break; - case -1: - psd = next + latab[(-delta) >> 1]; - break; - case 0: - psd += latab[delta >> 1]; - break; - } - } - /* minpsd = -289 */ - UPDATE_LEAK (); - mask = (fastleak < slowleak) ? fastleak : slowleak; - COMPUTE_MASK (); - i++; - j = startband; - do { - /* max(mask+4*exp)=147=-(minpsd+fgain-deltba-snroffset)>>5+4*exp */ - /* min(mask+4*exp)=-156=-(sgain-deltba-snroffset)>>5 */ - bap[j] = (baptab+156)[mask + 4 * exp[j]]; - } while (++j < endband); - } while (j < end); -} diff --git a/apps/codecs/liba52/bitstream.c b/apps/codecs/liba52/bitstream.c deleted file mode 100644 index 155368f1ed..0000000000 --- a/apps/codecs/liba52/bitstream.c +++ /dev/null @@ -1,97 +0,0 @@ -/* - * bitstream.c - * Copyright (C) 2000-2003 Michel Lespinasse - * Copyright (C) 1999-2000 Aaron Holtzman - * - * This file is part of a52dec, a free ATSC A-52 stream decoder. - * See http://liba52.sourceforge.net/ for updates. - * - * a52dec is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * a52dec is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "config-a52.h" - -#include - -#include "a52.h" -#include "a52_internal.h" -#include "bitstream.h" - -#define BUFFER_SIZE 4096 - -void a52_bitstream_set_ptr (a52_state_t * state, uint8_t * buf) -{ - int align; - - align = (long)buf & 3; - state->buffer_start = (uint32_t *) (buf - align); - state->bits_left = 0; - state->current_word = 0; - bitstream_get (state, align * 8); - bitstream_get_2 (state, 0); /* pretend function is used - keep gcc happy */ -} - -static inline void bitstream_fill_current (a52_state_t * state) -{ - uint32_t tmp; - - tmp = *(state->buffer_start++); - state->current_word = swab32 (tmp); -} - -/* - * The fast paths for _get is in the - * bitstream.h header file so it can be inlined. - * - * The "bottom half" of this routine is suffixed _bh - * - * -ah - */ - -uint32_t a52_bitstream_get_bh (a52_state_t * state, uint32_t num_bits) -{ - uint32_t result; - - num_bits -= state->bits_left; - result = ((state->current_word << (32 - state->bits_left)) >> - (32 - state->bits_left)); - - bitstream_fill_current (state); - - if (num_bits != 0) - result = (result << num_bits) | (state->current_word >> (32 - num_bits)); - - state->bits_left = 32 - num_bits; - - return result; -} - -int32_t a52_bitstream_get_bh_2 (a52_state_t * state, uint32_t num_bits) -{ - int32_t result; - - num_bits -= state->bits_left; - result = ((((int32_t)state->current_word) << (32 - state->bits_left)) >> - (32 - state->bits_left)); - - bitstream_fill_current(state); - - if (num_bits != 0) - result = (result << num_bits) | (state->current_word >> (32 - num_bits)); - - state->bits_left = 32 - num_bits; - - return result; -} diff --git a/apps/codecs/liba52/bitstream.h b/apps/codecs/liba52/bitstream.h deleted file mode 100644 index 56de1571b7..0000000000 --- a/apps/codecs/liba52/bitstream.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * bitstream.h - * Copyright (C) 2000-2003 Michel Lespinasse - * Copyright (C) 1999-2000 Aaron Holtzman - * - * This file is part of a52dec, a free ATSC A-52 stream decoder. - * See http://liba52.sourceforge.net/ for updates. - * - * a52dec is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * a52dec is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#define swab32(x) (betoh32(x)) - -void a52_bitstream_set_ptr (a52_state_t * state, uint8_t * buf); -uint32_t a52_bitstream_get_bh (a52_state_t * state, uint32_t num_bits); -int32_t a52_bitstream_get_bh_2 (a52_state_t * state, uint32_t num_bits); - -static inline uint32_t bitstream_get (a52_state_t * state, uint32_t num_bits) -{ - uint32_t result; - - if (num_bits < state->bits_left) { - result = (state->current_word << (32 - state->bits_left)) >> (32 - num_bits); - state->bits_left -= num_bits; - return result; - } - - return a52_bitstream_get_bh (state, num_bits); -} - -static inline int32_t bitstream_get_2 (a52_state_t * state, uint32_t num_bits) -{ - int32_t result; - - if (num_bits < state->bits_left) { - result = (((int32_t)state->current_word) << (32 - state->bits_left)) >> (32 - num_bits); - state->bits_left -= num_bits; - return result; - } - - return a52_bitstream_get_bh_2 (state, num_bits); -} diff --git a/apps/codecs/liba52/config-a52.h b/apps/codecs/liba52/config-a52.h deleted file mode 100644 index ade7ecf9b8..0000000000 --- a/apps/codecs/liba52/config-a52.h +++ /dev/null @@ -1,26 +0,0 @@ -#include "codeclib.h" - -/* a52dec profiling */ -/* #undef A52DEC_GPROF */ - -/* Define to 1 if you have the `memalign' function. */ -/* #undef HAVE_MEMALIGN 1 */ - -/* liba52 djbfft support */ -/* #undef LIBA52_DJBFFT */ - -/* a52 sample precision */ -/* #undef LIBA52_DOUBLE */ - -/* use fixed-point arithmetic */ -#define LIBA52_FIXED - -/* Define to 1 if your processor stores words with the most significant byte - first (like Motorola and SPARC, unlike Intel and VAX). */ - -/* Used in bitstream.h */ - -#ifdef ROCKBOX_BIG_ENDIAN -#define WORDS_BIGENDIAN 1 -#endif - diff --git a/apps/codecs/liba52/downmix.c b/apps/codecs/liba52/downmix.c deleted file mode 100644 index dd2867cb92..0000000000 --- a/apps/codecs/liba52/downmix.c +++ /dev/null @@ -1,688 +0,0 @@ -/* - * downmix.c - * Copyright (C) 2000-2003 Michel Lespinasse - * Copyright (C) 1999-2000 Aaron Holtzman - * - * This file is part of a52dec, a free ATSC A-52 stream decoder. - * See http://liba52.sourceforge.net/ for updates. - * - * a52dec is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * a52dec is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "config-a52.h" - -#include -#include - -#include "a52.h" -#include "a52_internal.h" - -#define CONVERT(acmod,output) (((output) << 3) + (acmod)) - -int a52_downmix_init (int input, int flags, level_t * level, - level_t clev, level_t slev) -{ - static uint8_t table[11][8] = { - {A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_STEREO, - A52_STEREO, A52_STEREO, A52_STEREO, A52_STEREO}, - {A52_MONO, A52_MONO, A52_MONO, A52_MONO, - A52_MONO, A52_MONO, A52_MONO, A52_MONO}, - {A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_STEREO, - A52_STEREO, A52_STEREO, A52_STEREO, A52_STEREO}, - {A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_3F, - A52_STEREO, A52_3F, A52_STEREO, A52_3F}, - {A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_STEREO, - A52_2F1R, A52_2F1R, A52_2F1R, A52_2F1R}, - {A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_STEREO, - A52_2F1R, A52_3F1R, A52_2F1R, A52_3F1R}, - {A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_3F, - A52_2F2R, A52_2F2R, A52_2F2R, A52_2F2R}, - {A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_3F, - A52_2F2R, A52_3F2R, A52_2F2R, A52_3F2R}, - {A52_CHANNEL1, A52_MONO, A52_MONO, A52_MONO, - A52_MONO, A52_MONO, A52_MONO, A52_MONO}, - {A52_CHANNEL2, A52_MONO, A52_MONO, A52_MONO, - A52_MONO, A52_MONO, A52_MONO, A52_MONO}, - {A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_DOLBY, - A52_DOLBY, A52_DOLBY, A52_DOLBY, A52_DOLBY} - }; - int output; - - output = flags & A52_CHANNEL_MASK; - if (output > A52_DOLBY) - return -1; - - output = table[output][input & 7]; - - if (output == A52_STEREO && - (input == A52_DOLBY || (input == A52_3F && clev == LEVEL (LEVEL_3DB)))) - output = A52_DOLBY; - - if (flags & A52_ADJUST_LEVEL) { - level_t adjust; - - switch (CONVERT (input & 7, output)) { - - case CONVERT (A52_3F, A52_MONO): - adjust = DIV (LEVEL_3DB, LEVEL (1) + clev); - break; - - case CONVERT (A52_STEREO, A52_MONO): - case CONVERT (A52_2F2R, A52_2F1R): - case CONVERT (A52_3F2R, A52_3F1R): - level_3db: - adjust = LEVEL (LEVEL_3DB); - break; - - case CONVERT (A52_3F2R, A52_2F1R): - if (clev < LEVEL (LEVEL_PLUS3DB - 1)) - goto level_3db; - /* break thru */ - case CONVERT (A52_3F, A52_STEREO): - case CONVERT (A52_3F1R, A52_2F1R): - case CONVERT (A52_3F1R, A52_2F2R): - case CONVERT (A52_3F2R, A52_2F2R): - adjust = DIV (1, LEVEL (1) + clev); - break; - - case CONVERT (A52_2F1R, A52_MONO): - adjust = DIV (LEVEL_PLUS3DB, LEVEL (2) + slev); - break; - - case CONVERT (A52_2F1R, A52_STEREO): - case CONVERT (A52_3F1R, A52_3F): - adjust = DIV (1, LEVEL (1) + MUL_C (slev, LEVEL_3DB)); - break; - - case CONVERT (A52_3F1R, A52_MONO): - adjust = DIV (LEVEL_3DB, LEVEL (1) + clev + MUL_C (slev, 0.5)); - break; - - case CONVERT (A52_3F1R, A52_STEREO): - adjust = DIV (1, LEVEL (1) + clev + MUL_C (slev, LEVEL_3DB)); - break; - - case CONVERT (A52_2F2R, A52_MONO): - adjust = DIV (LEVEL_3DB, LEVEL (1) + slev); - break; - - case CONVERT (A52_2F2R, A52_STEREO): - case CONVERT (A52_3F2R, A52_3F): - adjust = DIV (1, LEVEL (1) + slev); - break; - - case CONVERT (A52_3F2R, A52_MONO): - adjust = DIV (LEVEL_3DB, LEVEL (1) + clev + slev); - break; - - case CONVERT (A52_3F2R, A52_STEREO): - adjust = DIV (1, LEVEL (1) + clev + slev); - break; - - case CONVERT (A52_MONO, A52_DOLBY): - adjust = LEVEL (LEVEL_PLUS3DB); - break; - - case CONVERT (A52_3F, A52_DOLBY): - case CONVERT (A52_2F1R, A52_DOLBY): - adjust = LEVEL (1 / (1 + LEVEL_3DB)); - break; - - case CONVERT (A52_3F1R, A52_DOLBY): - case CONVERT (A52_2F2R, A52_DOLBY): - adjust = LEVEL (1 / (1 + 2 * LEVEL_3DB)); - break; - - case CONVERT (A52_3F2R, A52_DOLBY): - adjust = LEVEL (1 / (1 + 3 * LEVEL_3DB)); - break; - - default: - return output; - } - - *level = MUL_L (*level, adjust); - } - - return output; -} - -int a52_downmix_coeff (level_t * coeff, int acmod, int output, level_t level, - level_t clev, level_t slev) -{ - level_t level_3db; - - level_3db = MUL_C (level, LEVEL_3DB); - - switch (CONVERT (acmod, output & A52_CHANNEL_MASK)) { - - case CONVERT (A52_CHANNEL, A52_CHANNEL): - case CONVERT (A52_MONO, A52_MONO): - case CONVERT (A52_STEREO, A52_STEREO): - case CONVERT (A52_3F, A52_3F): - case CONVERT (A52_2F1R, A52_2F1R): - case CONVERT (A52_3F1R, A52_3F1R): - case CONVERT (A52_2F2R, A52_2F2R): - case CONVERT (A52_3F2R, A52_3F2R): - case CONVERT (A52_STEREO, A52_DOLBY): - coeff[0] = coeff[1] = coeff[2] = coeff[3] = coeff[4] = level; - return 0; - - case CONVERT (A52_CHANNEL, A52_MONO): - coeff[0] = coeff[1] = MUL_C (level, LEVEL_6DB); - return 3; - - case CONVERT (A52_STEREO, A52_MONO): - coeff[0] = coeff[1] = level_3db; - return 3; - - case CONVERT (A52_3F, A52_MONO): - coeff[0] = coeff[2] = level_3db; - coeff[1] = MUL_C (MUL_L (level_3db, clev), LEVEL_PLUS6DB); - return 7; - - case CONVERT (A52_2F1R, A52_MONO): - coeff[0] = coeff[1] = level_3db; - coeff[2] = MUL_L (level_3db, slev); - return 7; - - case CONVERT (A52_2F2R, A52_MONO): - coeff[0] = coeff[1] = level_3db; - coeff[2] = coeff[3] = MUL_L (level_3db, slev); - return 15; - - case CONVERT (A52_3F1R, A52_MONO): - coeff[0] = coeff[2] = level_3db; - coeff[1] = MUL_C (MUL_L (level_3db, clev), LEVEL_PLUS6DB); - coeff[3] = MUL_L (level_3db, slev); - return 15; - - case CONVERT (A52_3F2R, A52_MONO): - coeff[0] = coeff[2] = level_3db; - coeff[1] = MUL_C (MUL_L (level_3db, clev), LEVEL_PLUS6DB); - coeff[3] = coeff[4] = MUL_L (level_3db, slev); - return 31; - - case CONVERT (A52_MONO, A52_DOLBY): - coeff[0] = level_3db; - return 0; - - case CONVERT (A52_3F, A52_DOLBY): - coeff[0] = coeff[2] = coeff[3] = coeff[4] = level; - coeff[1] = level_3db; - return 7; - - case CONVERT (A52_3F, A52_STEREO): - case CONVERT (A52_3F1R, A52_2F1R): - case CONVERT (A52_3F2R, A52_2F2R): - coeff[0] = coeff[2] = coeff[3] = coeff[4] = level; - coeff[1] = MUL_L (level, clev); - return 7; - - case CONVERT (A52_2F1R, A52_DOLBY): - coeff[0] = coeff[1] = level; - coeff[2] = level_3db; - return 7; - - case CONVERT (A52_2F1R, A52_STEREO): - coeff[0] = coeff[1] = level; - coeff[2] = MUL_L (level_3db, slev); - return 7; - - case CONVERT (A52_3F1R, A52_DOLBY): - coeff[0] = coeff[2] = level; - coeff[1] = coeff[3] = level_3db; - return 15; - - case CONVERT (A52_3F1R, A52_STEREO): - coeff[0] = coeff[2] = level; - coeff[1] = MUL_L (level, clev); - coeff[3] = MUL_L (level_3db, slev); - return 15; - - case CONVERT (A52_2F2R, A52_DOLBY): - coeff[0] = coeff[1] = level; - coeff[2] = coeff[3] = level_3db; - return 15; - - case CONVERT (A52_2F2R, A52_STEREO): - coeff[0] = coeff[1] = level; - coeff[2] = coeff[3] = MUL_L (level, slev); - return 15; - - case CONVERT (A52_3F2R, A52_DOLBY): - coeff[0] = coeff[2] = level; - coeff[1] = coeff[3] = coeff[4] = level_3db; - return 31; - - case CONVERT (A52_3F2R, A52_2F1R): - coeff[0] = coeff[2] = level; - coeff[1] = MUL_L (level, clev); - coeff[3] = coeff[4] = level_3db; - return 31; - - case CONVERT (A52_3F2R, A52_STEREO): - coeff[0] = coeff[2] = level; - coeff[1] = MUL_L (level, clev); - coeff[3] = coeff[4] = MUL_L (level, slev); - return 31; - - case CONVERT (A52_3F1R, A52_3F): - coeff[0] = coeff[1] = coeff[2] = level; - coeff[3] = MUL_L (level_3db, slev); - return 13; - - case CONVERT (A52_3F2R, A52_3F): - coeff[0] = coeff[1] = coeff[2] = level; - coeff[3] = coeff[4] = MUL_L (level, slev); - return 29; - - case CONVERT (A52_2F2R, A52_2F1R): - coeff[0] = coeff[1] = level; - coeff[2] = coeff[3] = level_3db; - return 12; - - case CONVERT (A52_3F2R, A52_3F1R): - coeff[0] = coeff[1] = coeff[2] = level; - coeff[3] = coeff[4] = level_3db; - return 24; - - case CONVERT (A52_2F1R, A52_2F2R): - coeff[0] = coeff[1] = level; - coeff[2] = level_3db; - return 0; - - case CONVERT (A52_3F1R, A52_2F2R): - coeff[0] = coeff[2] = level; - coeff[1] = MUL_L (level, clev); - coeff[3] = level_3db; - return 7; - - case CONVERT (A52_3F1R, A52_3F2R): - coeff[0] = coeff[1] = coeff[2] = level; - coeff[3] = level_3db; - return 0; - - case CONVERT (A52_CHANNEL, A52_CHANNEL1): - coeff[0] = level; - coeff[1] = 0; - return 0; - - case CONVERT (A52_CHANNEL, A52_CHANNEL2): - coeff[0] = 0; - coeff[1] = level; - return 0; - } - - return -1; /* NOTREACHED */ -} - -static void mix2to1 (sample_t * dest, sample_t * src) -{ - int i; - - for (i = 0; i < 256; i++) - dest[i] += BIAS (src[i]); -} - -static void mix3to1 (sample_t * samples) -{ - int i; - - for (i = 0; i < 256; i++) - samples[i] += BIAS (samples[i + 256] + samples[i + 512]); -} - -static void mix4to1 (sample_t * samples) -{ - int i; - - for (i = 0; i < 256; i++) - samples[i] += BIAS (samples[i + 256] + samples[i + 512] + - samples[i + 768]); -} - -static void mix5to1 (sample_t * samples) -{ - int i; - - for (i = 0; i < 256; i++) - samples[i] += BIAS (samples[i + 256] + samples[i + 512] + - samples[i + 768] + samples[i + 1024]); -} - -static void mix3to2 (sample_t * samples) -{ - int i; - sample_t common; - - for (i = 0; i < 256; i++) { - common = BIAS (samples[i + 256]); - samples[i] += common; - samples[i + 256] = samples[i + 512] + common; - } -} - -static void mix21to2 (sample_t * left, sample_t * right) -{ - int i; - sample_t common; - - for (i = 0; i < 256; i++) { - common = BIAS (right[i + 256]); - left[i] += common; - right[i] += common; - } -} - -static void mix21toS (sample_t * samples) -{ - int i; - sample_t surround; - - for (i = 0; i < 256; i++) { - surround = samples[i + 512]; - samples[i] += BIAS (-surround); - samples[i + 256] += BIAS (surround); - } -} - -static void mix31to2 (sample_t * samples) -{ - int i; - sample_t common; - - for (i = 0; i < 256; i++) { - common = BIAS (samples[i + 256] + samples[i + 768]); - samples[i] += common; - samples[i + 256] = samples[i + 512] + common; - } -} - -static void mix31toS (sample_t * samples) -{ - int i; - sample_t common, surround; - - for (i = 0; i < 256; i++) { - common = BIAS (samples[i + 256]); - surround = samples[i + 768]; - samples[i] += common - surround; - samples[i + 256] = samples[i + 512] + common + surround; - } -} - -static void mix22toS (sample_t * samples) -{ - int i; - sample_t surround; - - for (i = 0; i < 256; i++) { - surround = samples[i + 512] + samples[i + 768]; - samples[i] += BIAS (-surround); - samples[i + 256] += BIAS (surround); - } -} - -static void mix32to2 (sample_t * samples) -{ - int i; - sample_t common; - - for (i = 0; i < 256; i++) { - common = BIAS (samples[i + 256]); - samples[i] += common + samples[i + 768]; - samples[i + 256] = common + samples[i + 512] + samples[i + 1024]; - } -} - -static void mix32toS (sample_t * samples) -{ - int i; - sample_t common, surround; - - for (i = 0; i < 256; i++) { - common = BIAS (samples[i + 256]); - surround = samples[i + 768] + samples[i + 1024]; - samples[i] += common - surround; - samples[i + 256] = samples[i + 512] + common + surround; - } -} - -static void move2to1 (sample_t * src, sample_t * dest) -{ - int i; - - for (i = 0; i < 256; i++) - dest[i] = BIAS (src[i] + src[i + 256]); -} - -static void zero (sample_t * samples) -{ - int i; - - for (i = 0; i < 256; i++) - samples[i] = 0; -} - -void a52_downmix (sample_t * samples, int acmod, int output, - level_t clev, level_t slev) -{ - /* avoid compiler warning */ - (void)clev; - - switch (CONVERT (acmod, output & A52_CHANNEL_MASK)) { - - case CONVERT (A52_CHANNEL, A52_CHANNEL2): - memcpy (samples, samples + 256, 256 * sizeof (sample_t)); - break; - - case CONVERT (A52_CHANNEL, A52_MONO): - case CONVERT (A52_STEREO, A52_MONO): - mix_2to1: - mix2to1 (samples, samples + 256); - break; - - case CONVERT (A52_2F1R, A52_MONO): - if (slev == 0) - goto mix_2to1; - case CONVERT (A52_3F, A52_MONO): - mix_3to1: - mix3to1 (samples); - break; - - case CONVERT (A52_3F1R, A52_MONO): - if (slev == 0) - goto mix_3to1; - case CONVERT (A52_2F2R, A52_MONO): - if (slev == 0) - goto mix_2to1; - mix4to1 (samples); - break; - - case CONVERT (A52_3F2R, A52_MONO): - if (slev == 0) - goto mix_3to1; - mix5to1 (samples); - break; - - case CONVERT (A52_MONO, A52_DOLBY): - memcpy (samples + 256, samples, 256 * sizeof (sample_t)); - break; - - case CONVERT (A52_3F, A52_STEREO): - case CONVERT (A52_3F, A52_DOLBY): - mix_3to2: - mix3to2 (samples); - break; - - case CONVERT (A52_2F1R, A52_STEREO): - if (slev == 0) - break; - mix21to2 (samples, samples + 256); - break; - - case CONVERT (A52_2F1R, A52_DOLBY): - mix21toS (samples); - break; - - case CONVERT (A52_3F1R, A52_STEREO): - if (slev == 0) - goto mix_3to2; - mix31to2 (samples); - break; - - case CONVERT (A52_3F1R, A52_DOLBY): - mix31toS (samples); - break; - - case CONVERT (A52_2F2R, A52_STEREO): - if (slev == 0) - break; - mix2to1 (samples, samples + 512); - mix2to1 (samples + 256, samples + 768); - break; - - case CONVERT (A52_2F2R, A52_DOLBY): - mix22toS (samples); - break; - - case CONVERT (A52_3F2R, A52_STEREO): - if (slev == 0) - goto mix_3to2; - mix32to2 (samples); - break; - - case CONVERT (A52_3F2R, A52_DOLBY): - mix32toS (samples); - break; - - case CONVERT (A52_3F1R, A52_3F): - if (slev == 0) - break; - mix21to2 (samples, samples + 512); - break; - - case CONVERT (A52_3F2R, A52_3F): - if (slev == 0) - break; - mix2to1 (samples, samples + 768); - mix2to1 (samples + 512, samples + 1024); - break; - - case CONVERT (A52_3F1R, A52_2F1R): - mix3to2 (samples); - memcpy (samples + 512, samples + 768, 256 * sizeof (sample_t)); - break; - - case CONVERT (A52_2F2R, A52_2F1R): - mix2to1 (samples + 512, samples + 768); - break; - - case CONVERT (A52_3F2R, A52_2F1R): - mix3to2 (samples); - move2to1 (samples + 768, samples + 512); - break; - - case CONVERT (A52_3F2R, A52_3F1R): - mix2to1 (samples + 768, samples + 1024); - break; - - case CONVERT (A52_2F1R, A52_2F2R): - memcpy (samples + 768, samples + 512, 256 * sizeof (sample_t)); - break; - - case CONVERT (A52_3F1R, A52_2F2R): - mix3to2 (samples); - memcpy (samples + 512, samples + 768, 256 * sizeof (sample_t)); - break; - - case CONVERT (A52_3F2R, A52_2F2R): - mix3to2 (samples); - memcpy (samples + 512, samples + 768, 256 * sizeof (sample_t)); - memcpy (samples + 768, samples + 1024, 256 * sizeof (sample_t)); - break; - - case CONVERT (A52_3F1R, A52_3F2R): - memcpy (samples + 1024, samples + 768, 256 * sizeof (sample_t)); - break; - } -} - -void a52_upmix (sample_t * samples, int acmod, int output) -{ - switch (CONVERT (acmod, output & A52_CHANNEL_MASK)) { - - case CONVERT (A52_CHANNEL, A52_CHANNEL2): - memcpy (samples + 256, samples, 256 * sizeof (sample_t)); - break; - - case CONVERT (A52_3F2R, A52_MONO): - zero (samples + 1024); - case CONVERT (A52_3F1R, A52_MONO): - case CONVERT (A52_2F2R, A52_MONO): - zero (samples + 768); - case CONVERT (A52_3F, A52_MONO): - case CONVERT (A52_2F1R, A52_MONO): - zero (samples + 512); - case CONVERT (A52_CHANNEL, A52_MONO): - case CONVERT (A52_STEREO, A52_MONO): - zero (samples + 256); - break; - - case CONVERT (A52_3F2R, A52_STEREO): - case CONVERT (A52_3F2R, A52_DOLBY): - zero (samples + 1024); - case CONVERT (A52_3F1R, A52_STEREO): - case CONVERT (A52_3F1R, A52_DOLBY): - zero (samples + 768); - case CONVERT (A52_3F, A52_STEREO): - case CONVERT (A52_3F, A52_DOLBY): - mix_3to2: - memcpy (samples + 512, samples + 256, 256 * sizeof (sample_t)); - zero (samples + 256); - break; - - case CONVERT (A52_2F2R, A52_STEREO): - case CONVERT (A52_2F2R, A52_DOLBY): - zero (samples + 768); - case CONVERT (A52_2F1R, A52_STEREO): - case CONVERT (A52_2F1R, A52_DOLBY): - zero (samples + 512); - break; - - case CONVERT (A52_3F2R, A52_3F): - zero (samples + 1024); - case CONVERT (A52_3F1R, A52_3F): - case CONVERT (A52_2F2R, A52_2F1R): - zero (samples + 768); - break; - - case CONVERT (A52_3F2R, A52_3F1R): - zero (samples + 1024); - break; - - case CONVERT (A52_3F2R, A52_2F1R): - zero (samples + 1024); - case CONVERT (A52_3F1R, A52_2F1R): - mix_31to21: - memcpy (samples + 768, samples + 512, 256 * sizeof (sample_t)); - goto mix_3to2; - - case CONVERT (A52_3F2R, A52_2F2R): - memcpy (samples + 1024, samples + 768, 256 * sizeof (sample_t)); - goto mix_31to21; - } -} diff --git a/apps/codecs/liba52/imdct.c b/apps/codecs/liba52/imdct.c deleted file mode 100644 index e93424c5fa..0000000000 --- a/apps/codecs/liba52/imdct.c +++ /dev/null @@ -1,486 +0,0 @@ -/* - * imdct.c - * Copyright (C) 2000-2003 Michel Lespinasse - * Copyright (C) 1999-2000 Aaron Holtzman - * - * The ifft algorithms in this file have been largely inspired by Dan - * Bernstein's work, djbfft, available at http://cr.yp.to/djbfft.html - * - * This file is part of a52dec, a free ATSC A-52 stream decoder. - * See http://liba52.sourceforge.net/ for updates. - * - * a52dec is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * a52dec is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "config-a52.h" - -#include -#include -#ifdef LIBA52_DJBFFT -#include -#include -#endif -#ifndef M_PI -#define M_PI 3.1415926535897932384626433832795029 -#endif -#include - -#include "a52.h" -#include "a52_internal.h" -#include "mm_accel.h" - -typedef struct complex_s { - sample_t real; - sample_t imag; -} complex_t; - -static const uint8_t fftorder[] = { - 0,128, 64,192, 32,160,224, 96, 16,144, 80,208,240,112, 48,176, - 8,136, 72,200, 40,168,232,104,248,120, 56,184, 24,152,216, 88, - 4,132, 68,196, 36,164,228,100, 20,148, 84,212,244,116, 52,180, - 252,124, 60,188, 28,156,220, 92, 12,140, 76,204,236,108, 44,172, - 2,130, 66,194, 34,162,226, 98, 18,146, 82,210,242,114, 50,178, - 10,138, 74,202, 42,170,234,106,250,122, 58,186, 26,154,218, 90, - 254,126, 62,190, 30,158,222, 94, 14,142, 78,206,238,110, 46,174, - 6,134, 70,198, 38,166,230,102,246,118, 54,182, 22,150,214, 86 -}; - -/* Root values for IFFT */ -//static sample_t roots16[3]; -//static sample_t roots32[7]; -//static sample_t roots64[15]; -//static sample_t roots128[31]; - -/* Twiddle factors for IMDCT */ -//static complex_t pre1[128]; -//static complex_t post1[64]; -//static complex_t pre2[64]; -//static complex_t post2[32]; - -//static sample_t a52_imdct_window[256]; -#include "imdct_lookups.h" - - -/* -static void (* ifft128) (complex_t * buf); -static void (* ifft64) (complex_t * buf); - -static inline void ifft2 (complex_t * buf) -{ - sample_t r, i; - - r = buf[0].real; - i = buf[0].imag; - buf[0].real += buf[1].real; - buf[0].imag += buf[1].imag; - buf[1].real = r - buf[1].real; - buf[1].imag = i - buf[1].imag; -} - -static inline void ifft4 (complex_t * buf) -{ - sample_t tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7, tmp8; - - tmp1 = buf[0].real + buf[1].real; - tmp2 = buf[3].real + buf[2].real; - tmp3 = buf[0].imag + buf[1].imag; - tmp4 = buf[2].imag + buf[3].imag; - tmp5 = buf[0].real - buf[1].real; - tmp6 = buf[0].imag - buf[1].imag; - tmp7 = buf[2].imag - buf[3].imag; - tmp8 = buf[3].real - buf[2].real; - - buf[0].real = tmp1 + tmp2; - buf[0].imag = tmp3 + tmp4; - buf[2].real = tmp1 - tmp2; - buf[2].imag = tmp3 - tmp4; - buf[1].real = tmp5 + tmp7; - buf[1].imag = tmp6 + tmp8; - buf[3].real = tmp5 - tmp7; - buf[3].imag = tmp6 - tmp8; -} -*/ -/* basic radix-2 ifft butterfly */ - -#define BUTTERFLY_0(t0,t1,W0,W1,d0,d1) do { \ - t0 = MUL (W1, d1) + MUL (W0, d0); \ - t1 = MUL (W0, d1) - MUL (W1, d0); \ -} while (0) - -/* radix-2 ifft butterfly with bias */ - -#define BUTTERFLY_B(t0,t1,W0,W1,d0,d1) do { \ - t0 = BIAS (MUL (d1, W1) + MUL (d0, W0)); \ - t1 = BIAS (MUL (d1, W0) - MUL (d0, W1)); \ -} while (0) - -/* the basic split-radix ifft butterfly */ - -#define BUTTERFLY(a0,a1,a2,a3,wr,wi) do { \ - BUTTERFLY_0 (tmp5, tmp6, wr, wi, a2.real, a2.imag); \ - BUTTERFLY_0 (tmp8, tmp7, wr, wi, a3.imag, a3.real); \ - tmp1 = tmp5 + tmp7; \ - tmp2 = tmp6 + tmp8; \ - tmp3 = tmp6 - tmp8; \ - tmp4 = tmp7 - tmp5; \ - a2.real = a0.real - tmp1; \ - a2.imag = a0.imag - tmp2; \ - a3.real = a1.real - tmp3; \ - a3.imag = a1.imag - tmp4; \ - a0.real += tmp1; \ - a0.imag += tmp2; \ - a1.real += tmp3; \ - a1.imag += tmp4; \ -} while (0) - -/* split-radix ifft butterfly, specialized for wr=1 wi=0 */ - -#define BUTTERFLY_ZERO(a0,a1,a2,a3) do { \ - tmp1 = a2.real + a3.real; \ - tmp2 = a2.imag + a3.imag; \ - tmp3 = a2.imag - a3.imag; \ - tmp4 = a3.real - a2.real; \ - a2.real = a0.real - tmp1; \ - a2.imag = a0.imag - tmp2; \ - a3.real = a1.real - tmp3; \ - a3.imag = a1.imag - tmp4; \ - a0.real += tmp1; \ - a0.imag += tmp2; \ - a1.real += tmp3; \ - a1.imag += tmp4; \ -} while (0) - -/* split-radix ifft butterfly, specialized for wr=wi */ -/* -#define BUTTERFLY_HALF(a0,a1,a2,a3,w) do { \ - tmp5 = MUL (a2.real + a2.imag, w); \ - tmp6 = MUL (a2.imag - a2.real, w); \ - tmp7 = MUL (a3.real - a3.imag, w); \ - tmp8 = MUL (a3.imag + a3.real, w); \ - tmp1 = tmp5 + tmp7; \ - tmp2 = tmp6 + tmp8; \ - tmp3 = tmp6 - tmp8; \ - tmp4 = tmp7 - tmp5; \ - a2.real = a0.real - tmp1; \ - a2.imag = a0.imag - tmp2; \ - a3.real = a1.real - tmp3; \ - a3.imag = a1.imag - tmp4; \ - a0.real += tmp1; \ - a0.imag += tmp2; \ - a1.real += tmp3; \ - a1.imag += tmp4; \ -} while (0) - -static inline void ifft8 (complex_t * buf) -{ - sample_t tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7, tmp8; - - ifft4 (buf); - ifft2 (buf + 4); - ifft2 (buf + 6); - BUTTERFLY_ZERO (buf[0], buf[2], buf[4], buf[6]); - BUTTERFLY_HALF (buf[1], buf[3], buf[5], buf[7], roots16[1]); -} - -static void ifft_pass (complex_t * buf, const sample_t * weight, int n) -{ - complex_t * buf1; - complex_t * buf2; - complex_t * buf3; - sample_t tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7, tmp8; - int i; - - buf++; - buf1 = buf + n; - buf2 = buf + 2 * n; - buf3 = buf + 3 * n; - - BUTTERFLY_ZERO (buf[-1], buf1[-1], buf2[-1], buf3[-1]); - - i = n - 1; - - do { - BUTTERFLY (buf[0], buf1[0], buf2[0], buf3[0], - weight[0], weight[2*i-n]); - buf++; - buf1++; - buf2++; - buf3++; - weight++; - } while (--i); -} - -static void ifft16 (complex_t * buf) -{ - ifft8 (buf); - ifft4 (buf + 8); - ifft4 (buf + 12); - ifft_pass (buf, roots16, 4); -} - -static void ifft32 (complex_t * buf) -{ - ifft16 (buf); - ifft8 (buf + 16); - ifft8 (buf + 24); - ifft_pass (buf, roots32, 8); -} - -static void ifft64_c (complex_t * buf) -{ - ifft32 (buf); - ifft16 (buf + 32); - ifft16 (buf + 48); - ifft_pass (buf, roots64, 16); -} - -static void ifft128_c (complex_t * buf) -{ - ifft32 (buf); - ifft16 (buf + 32); - ifft16 (buf + 48); - ifft_pass (buf, roots64, 16); - - ifft32 (buf + 64); - ifft32 (buf + 96); - ifft_pass (buf, roots128, 32); -} -*/ -void a52_imdct_512 (sample_t * data, sample_t * delay) -{ - int i, k; - sample_t t_r, t_i, a_r, a_i, b_r, b_i, w_1, w_2; - const sample_t * window = a52_imdct_window; - FFTComplex buf[128]; - - for (i = 0; i < 128; i++) { - k = fftorder[i]; - t_r = pre1[i].real; - t_i = pre1[i].imag; - BUTTERFLY_0 (buf[i].re, buf[i].im, t_r, t_i, data[k], data[255-k]); - } - - //ifft128 (buf); - ff_fft_calc_c(7, (FFTComplex *)&buf); - - /* Post IFFT complex multiply plus IFFT complex conjugate*/ - /* Window and convert to real valued signal */ - for (i = 0; i < 64; i++) { - /* y[n] = z[n] * (xcos1[n] + j * xsin1[n]) ; */ - t_r = post1[i].real; - t_i = post1[i].imag; - BUTTERFLY_0 (a_r, a_i, t_i, t_r, buf[i].im, buf[i].re); - BUTTERFLY_0 (b_r, b_i, t_r, t_i, buf[127-i].im, buf[127-i].re); - - w_1 = window[2*i]; - w_2 = window[255-2*i]; - BUTTERFLY_B (data[255-2*i], data[2*i], w_2, w_1, a_r, delay[2*i]); - delay[2*i] = a_i; - - w_1 = window[2*i+1]; - w_2 = window[254-2*i]; - BUTTERFLY_B (data[2*i+1], data[254-2*i], w_1, w_2, b_r, delay[2*i+1]); - delay[2*i+1] = b_i; - } -} - -void a52_imdct_256 (sample_t * data, sample_t * delay) -{ - int i, k; - sample_t t_r, t_i, a_r, a_i, b_r, b_i, c_r, c_i, d_r, d_i, w_1, w_2; - const sample_t * window = a52_imdct_window; - FFTComplex buf1[64], buf2[64]; - - /* Pre IFFT complex multiply plus IFFT cmplx conjugate */ - for (i = 0; i < 64; i++) { - k = fftorder[i]; - t_r = pre2[i].real; - t_i = pre2[i].imag; - BUTTERFLY_0 (buf1[i].re, buf1[i].im, t_r, t_i, data[k], data[254-k]); - BUTTERFLY_0 (buf2[i].re, buf2[i].im, t_r, t_i, data[k+1], data[255-k]); - } - - //ifft64 (buf1); - //ifft64 (buf2); - ff_fft_calc_c(6, (FFTComplex *)&buf1); - ff_fft_calc_c(6, (FFTComplex *)&buf2); - - /* Post IFFT complex multiply */ - /* Window and convert to real valued signal */ - for (i = 0; i < 32; i++) { - /* y1[n] = z1[n] * (xcos2[n] + j * xs in2[n]) ; */ - t_r = post2[i].real; - t_i = post2[i].imag; - BUTTERFLY_0 (a_r, a_i, t_i, t_r, buf1[i].im, buf1[i].re); - BUTTERFLY_0 (b_r, b_i, t_r, t_i, buf1[63-i].im, buf1[63-i].re); - BUTTERFLY_0 (c_r, c_i, t_i, t_r, buf2[i].im, buf2[i].re); - BUTTERFLY_0 (d_r, d_i, t_r, t_i, buf2[63-i].im, buf2[63-i].re); - - w_1 = window[2*i]; - w_2 = window[255-2*i]; - BUTTERFLY_B (data[255-2*i], data[2*i], w_2, w_1, a_r, delay[2*i]); - delay[2*i] = c_i; - - w_1 = window[128+2*i]; - w_2 = window[127-2*i]; - BUTTERFLY_B (data[128+2*i], data[127-2*i], w_1, w_2, a_i, delay[127-2*i]); - delay[127-2*i] = c_r; - - w_1 = window[2*i+1]; - w_2 = window[254-2*i]; - BUTTERFLY_B (data[254-2*i], data[2*i+1], w_2, w_1, b_i, delay[2*i+1]); - delay[2*i+1] = d_r; - - w_1 = window[129+2*i]; - w_2 = window[126-2*i]; - BUTTERFLY_B (data[129+2*i], data[126-2*i], w_1, w_2, b_r, delay[126-2*i]); - delay[126-2*i] = d_i; - } -} - -/* -static double besselI0 (double x) -{ - double bessel = 1; - int i = 100; - - do - bessel = bessel * x / (i * i) + 1; - while (--i); - return bessel; -} -*/ - -void a52_imdct_init (uint32_t mm_accel) -{ - (void)mm_accel; - //ff_fft_init(&s128, 7, 1); - //ff_fft_init(&s64, 6, 1); - -/* int i, k; - double sum; - double local_imdct_window[256];*/ - - /* compute imdct window - kaiser-bessel derived window, alpha = 5.0 */ - /* sum = 0; - for (i = 0; i < 256; i++) { - sum += besselI0 (i * (256 - i) * (5 * M_PI / 256) * (5 * M_PI / 256)); - local_imdct_window[i] = sum; - } - sum++; - */ - /* for (i = 0; i < 256; i++) - a52_imdct_window[i] = SAMPLE (sqrt (local_imdct_window[i] / sum)); - - printf("static sample_t a52_imdct_window[256]={"); - for (i=0;i<256;i++) { - if ((i % 16)==0) { printf("\n"); } - printf("%d,",a52_imdct_window[i]); - } - printf("\n}\n"); - */ - - /* for (i = 0; i < 3; i++) - roots16[i] = SAMPLE (cos ((M_PI / 8) * (i + 1))); - - printf("static sample_t roots16[3]={%d,%d,%d};\n\n",roots16[0],roots16[1],roots16[2]); - - for (i = 0; i < 7; i++) - roots32[i] = SAMPLE (cos ((M_PI / 16) * (i + 1))); - - printf("static sample_t roots32[7]={"); - for (i=0;i<7;i++) { printf("%d%s",roots32[i],(i < 6 ? "," : "")); } - printf("};\n"); - - for (i = 0; i < 15; i++) - roots64[i] = SAMPLE (cos ((M_PI / 32) * (i + 1))); - - printf("static sample_t roots64[15]={"); - for (i=0;i<15;i++) { printf("%d%s",roots64[i],(i < 14 ? "," : "")); } - printf("};\n"); - - for (i = 0; i < 31; i++) - roots128[i] = SAMPLE (cos ((M_PI / 64) * (i + 1))); - - printf("static sample_t roots128[31]={"); - for (i=0;i<31;i++) { printf("%d%s",roots128[i],(i < 30 ? "," : "")); } - printf("};\n"); - */ - /* - for (i = 0; i < 64; i++) { - k = fftorder[i] / 2 + 64; - pre1[i].real = SAMPLE (cos ((M_PI / 256) * (k - 0.25))); - pre1[i].imag = SAMPLE (sin ((M_PI / 256) * (k - 0.25))); - } - - for (i = 64; i < 128; i++) { - k = fftorder[i] / 2 + 64; - pre1[i].real = SAMPLE (-cos ((M_PI / 256) * (k - 0.25))); - pre1[i].imag = SAMPLE (-sin ((M_PI / 256) * (k - 0.25))); - } - - printf("static complex_t pre1[128]={"); - for (i=0;i<128;i++) { printf("{%d,%d}%s",pre1[i].real,pre1[i].imag,(i < 127 ? "," : "")); } - printf("};\n"); - */ - /* - for (i = 0; i < 64; i++) { - post1[i].real = SAMPLE (cos ((M_PI / 256) * (i + 0.5))); - post1[i].imag = SAMPLE (sin ((M_PI / 256) * (i + 0.5))); - } - - printf("static complex_t post1[64]={"); - for (i=0;i<64;i++) { printf("{%d,%d}%s",post1[i].real,post1[i].imag,(i < 63 ? "," : "")); } - printf("};\n"); - */ - - /* - for (i = 0; i < 64; i++) { - k = fftorder[i] / 4; - pre2[i].real = SAMPLE (cos ((M_PI / 128) * (k - 0.25))); - pre2[i].imag = SAMPLE (sin ((M_PI / 128) * (k - 0.25))); - } - - printf("static complex_t pre2[64]={"); - for (i=0;i<64;i++) { printf("{%d,%d}%s",pre2[i].real,pre2[i].imag,(i < 63 ? "," : "")); } - printf("};\n"); - - for (i = 0; i < 32; i++) { - post2[i].real = SAMPLE (cos ((M_PI / 128) * (i + 0.5))); - post2[i].imag = SAMPLE (sin ((M_PI / 128) * (i + 0.5))); - } - - printf("static complex_t post2[32]={"); - for (i=0;i<32;i++) { printf("{%d,%d}%s",post2[i].real,post2[i].imag,(i < 31 ? "," : "")); } - printf("};\n"); - - -#ifdef LIBA52_DJBFFT - if (mm_accel & MM_ACCEL_DJBFFT) { -#ifndef LIBA52_DOUBLE - ifft128 = (void (*) (complex_t *)) fftc4_un128; - ifft64 = (void (*) (complex_t *)) fftc4_un64; -#else - ifft128 = (void (*) (complex_t *)) fftc8_un128; - ifft64 = (void (*) (complex_t *)) fftc8_un64; -#endif - } else -#endif - { - ifft128 = ifft128_c; - ifft64 = ifft64_c; - } - */ -} diff --git a/apps/codecs/liba52/imdct_lookups.h b/apps/codecs/liba52/imdct_lookups.h deleted file mode 100644 index 9d14fe21a7..0000000000 --- a/apps/codecs/liba52/imdct_lookups.h +++ /dev/null @@ -1,15 +0,0 @@ -static const sample_t a52_imdct_window[256]ICONST_ATTR={ - 146020,261886,393529,545197,719447,918478,1144416,1399394,1685589,2005234,2360623,2754115,3188134,3665170,4187773,4758556, 5380193,6055411,6786995,7577779,8430645,9348521,10334375,11391212,12522071,13730020,15018150,16389576,17847424,19394833,21034947,22770912, 24605865,26542938,28585242,30735872,32997891,35374332,37868188,40482408,43219889,46083473,49075937,52199993,55458273,58853331,62387636,66063559, 69883377,73849259,77963266,82227341,86643307,91212859,95937560,100818835,105857968,111056092,116414194,121933098,127613474,133455822,139460477,145627601, 151957182,158449029,165102772,171917855,178893540,186028900,193322822,200774000,208380940,216141958,224055176,232118527,240329753,248686407,257185854,265825270, 274601649,283511802,292552357,301719768,311010314,320420105,329945084,339581031,349323572,359168178,369110174,379144743,389266934,399471665,409753732,420107815, 430528483,441010205,451547355,462134219,472765003,483433845,494134818,504861939,515609181,526370480,537139740,547910849,558677680,569434108,580174011,590891284, 601579849,612233658,622846709,633413050,643926788,654382103,664773249,675094567,685340494,695505569,705584441,715571877,725462772,735252152,744935184,754507184, 763963620,773300119,782512477,791596659,800548807,809365245,818042484,826577226,834966364,843206992,851296404,859232096,867011771,874633340,882094922,889394844, 896531647,903504079,910311101,916951881,923425798,929732436,935871584,941843233,947647575,953284997,958756080,964061593,969202490,974179906,978995149,983649698, 988145195,992483442,996666390,1000696136,1004574919,1008305104,1011889185,1015329772,1018629583,1021791439,1024818257,1027713038,1030478862,1033118881,1035636308,1038034411, 1040316504,1042485942,1044546109,1046500412,1048352275,1050105129,1051762405,1053327531,1054803917,1056194958,1057504020,1058734435,1059889501,1060972468,1061986539,1062934861, 1063820523,1064646551,1065415903,1066131467,1066796055,1067412403,1067983168,1068510924,1068998160,1069447282,1069860607,1070240366,1070588702,1070907668,1071199230,1071465266, 1071707567,1071927836,1072127692,1072308670,1072472221,1072619716,1072752449,1072871635,1072978415,1073073858,1073158963,1073234663,1073301826,1073361257,1073413702,1073459852, 1073500344,1073535763,1073566646,1073593486,1073616731,1073636791,1073654036,1073668804,1073681398,1073692090,1073701126,1073708726,1073715084,1073720373,1073724748,1073728344, 1073731279,1073733657,1073735568,1073737090,1073738291,1073739229,1073739951,1073740500,1073740912,1073741214,1073741431,1073741582,1073741685,1073741751,1073741792,1073741814 -}; - -static const sample_t roots16[3]ICONST_ATTR={992008094,759250124,410903206}; -static const sample_t roots32[7]ICONST_ATTR={1053110175,992008094,892783698,759250124,596538995,410903206,209476638}; -static const sample_t roots64[15]ICONST_ATTR={1068571463,1053110175,1027506861,992008094,946955747,892783698,830013654,759250124,681174602,596538995,506158392,410903206,311690798,209476638,105245103}; -static const sample_t roots128[31]ICONST_ATTR={1072448454,1068571463,1062120190,1053110175,1041563127,1027506861,1010975241,992008094,970651112,946955747,920979082,892783698,862437519,830013654,795590212,759250124,721080937,681174602,639627257,596538995,552013618,506158392,459083785,410903206,361732725,311690798,260897981,209476638,157550647,105245103,52686014}; - -static const complex_t pre1[128]ICONST_ATTR={{761575898,756917205},{3294193,1073736770},{413944710,990742792},{-407857834,993264059},{599275209,890949340},{-206244755,1053747885},{-593797166,894609652},{212706548,1052462554},{683717842,827919933},{-101966276,1068889322},{314841678,1026545772},{-503250790,948504162},{-678624950,832099562},{108522938,1068243547},{509061229,945398418},{-308536985,1028458279},{723518379,793374223},{-49395540,1072605046},{364832651,1009860703},{-456103709,972054993},{554836544,919281193},{-257701283,1042358649},{-636978326,864395809},{160808444,1061631832},{-718636707,797798713},{55975991,1072281769},{462059540,969238095},{-358629394,1012080264},{642270168,860471112},{-154291366,1062598550},{-549185496,922668301},{264092224,1040757801},{742770847,775379244},{-23057618,1073494224},{389505993,1000603111},{-432110916,982955574},{577229727,905387953},{-232042906,1048369016},{-615573145,879767700},{186813761,1057365652},{663193747,844449855},{-128167423,1066065014},{289554159,1033963197},{-526376678,935868098},{-698841306,815194659},{82274244,1070585098},{485706670,957606670},{-333683689,1020576650},{-737999227,779922204},{29644020,1073332537},{438134083,980285687},{-383359075,1002974238},{620959710,875974053},{-180322371,1058492015},{-571663505,908912724},{238471209,1046925492},{703830091,810891303},{-75703709,1071069770},{339939548,1018509994},{-479821763,960568883},{-657999815,848503239},{134706262,1065258526},{532109148,932620694},{-283204430,1035720404},{-752230014,-766205918},{9882456,-1073696345},{-401755603,-995747929},{420016001,-988184225},{-588296766,-898236282},{219160333,-1051137599},{604730690,-887255485},{-199775197,-1054993542},{-673506508,-836247862},{115075515,-1067557553},{-302220675,-1030332066},{514852501,-942257080},{688784992,-823709134},{-95405775,-1069494853},{-497421404,-951574195},{321134518,-1024594615},{-713727978,-802193167},{62554335,-1071918121},{-352412636,-1014261720},{467997975,-966384705},{-543513771,-926020671},{270473222,-1039117770},{647537829,-856514018},{-147768480,-1063525261},{728372812,-788919863},{-42813229,-1072887940},{-450130706,-974835294},{371022172,-1007603122},{-631662502,-868287963},{167319467,-1060625145},{560466703,-915859475},{-251300639,-1043920252},{747514502,-770807091},{-16470347,-1073615495},{-426071479,-985588453},{395638246,-998194311},{-610163404,-883528225},{193298118,-1056199480},{582774217,-901829094},{-225605866,-1049773069},{-693826210,-819467323},{88841682,-1070060119},{-327415267,-1022604883},{491573291,-954608403},{668362709,-840364678},{-121623758,-1066831367},{-520624390,-939080267},{295892987,-1032167062},{-733199822,-784435800},{36229307,-1073130440},{-377197724,-1005307605},{444140755,-977578893},{-566075760,-912403275},{244890534,-1045442552},{626322896,-872147426},{-173824191,-1059578527},{708792377,-806557418},{-69130323,-1071514117},{-473918791,-963494932},{346182609,-1016404991},{-652781111,-852524677},{141240030,-1064411930},{537821584,-929338177},{-276844037,-1037438616}}; - -static const complex_t post1[64]ICONST_ATTR={{1073721611,6588355},{1073559912,19764075},{1073236539,32936819},{1072751541,46104602},{1072104991,59265442},{1071296985,72417357},{1070327646,85558366},{1069197119,98686490},{1067905576,111799753},{1066453209,124896178},{1064840239,137973795},{1063066908,151030634},{1061133483,164064728},{1059040255,177074114},{1056787539,190056834},{1054375675,203010932},{1051805026,215934457},{1049075979,228825463},{1046188946,241682009},{1043144359,254502159},{1039942680,267283981},{1036584388,280025551},{1033069991,292724951},{1029400017,305380267},{1025575020,317989594},{1021595574,330551034},{1017462280,343062693},{1013175760,355522688},{1008736660,367929143},{1004145647,380280189},{999403414,392573967},{994510674,404808624},{989468165,416982318},{984276645,429093217},{978936897,441139495},{973449725,453119340},{967815955,465030947},{962036435,476872521},{956112036,488642280},{950043650,500338452},{943832191,511959274},{937478594,523502998},{930983817,534967883},{924348836,546352205},{917574653,557654248},{910662286,568872310},{903612776,580004702},{896427186,591049747},{889106597,602005783},{881652112,612871159},{874064853,623644238},{866345963,634323399},{858496605,644907034},{850517961,655393547},{842411231,665781361},{834177638,676068911},{825818420,686254647},{817334837,696337035},{808728167,706314558},{799999705,716185713},{791150766,725949012},{782182683,735602987},{773096806,745146182},{763894503,754577161}}; - -static const complex_t pre2[64]ICONST_ATTR={{1073721611,-6588355},{763894503,754577161},{994510674,404808624},{416982318,989468165},{1054375675,203010932},{602005783,889106597},{215934457,1051805026},{896427186,591049747},{1069197119,98686490},{686254647,825818420},{950043650,500338452},{317989594,1025575020},{111799753,1067905576},{834177638,676068911},{1029400017,305380267},{511959274,943832191},{1072751541,46104602},{725949012,791150766},{973449725,453119340},{367929143,1008736660},{1043144359,254502159},{557654248,917574653},{164064728,1061133483},{866345963,634323399},{59265442,1072104991},{799999705,716185713},{1013175760,355522688},{465030947,967815955},{1063066908,151030634},{644907034,858496605},{267283981,1039942680},{924348836,546352205},{1073559912,19764075},{745146182,773096806},{984276645,429093217},{392573967,999403414},{1049075979,228825463},{580004702,903612776},{190056834,1056787539},{881652112,612871159},{1066453209,124896178},{665781361,842411231},{937478594,523502998},{292724951,1033069991},{85558366,1070327646},{817334837,696337035},{1021595574,330551034},{488642280,956112036},{32936819,1073236539},{782182683,735602987},{1004145647,380280189},{441139495,978936897},{1059040255,177074114},{623644238,874064853},{241682009,1046188946},{910662286,568872310},{1071296985,72417357},{706314558,808728167},{962036435,476872521},{343062693,1017462280},{137973795,1064840239},{850517961,655393547},{1036584388,280025551},{534967883,930983817}}; -static const complex_t post2[32]ICONST_ATTR={{1073660973,13176463},{1073014239,39521454},{1071721163,65842639},{1069782521,92124162},{1067199482,118350193},{1063973603,144504935},{1060106825,170572632},{1055601479,196537583},{1050460278,222384146},{1044686318,248096754},{1038283079,273659918},{1031254417,299058239},{1023604566,324276418},{1015338134,349299266},{1006460100,374111709},{996975812,398698801},{986890983,423045731},{976211688,447137835},{964944359,470960600},{953095785,494499675},{940673100,517740882},{927683790,540670222},{914135677,563273882},{900036924,585538247},{885396022,607449906},{870221790,628995659},{854523369,650162530},{838310215,670937766},{821592095,691308855},{804379078,711263525},{786681534,730789756},{768510121,749875787}}; diff --git a/apps/codecs/liba52/liba52.make b/apps/codecs/liba52/liba52.make deleted file mode 100644 index 79b2eb222e..0000000000 --- a/apps/codecs/liba52/liba52.make +++ /dev/null @@ -1,18 +0,0 @@ -# __________ __ ___. -# Open \______ \ ____ ____ | | _\_ |__ _______ ___ -# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / -# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < -# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ -# \/ \/ \/ \/ \/ -# $Id$ -# - -# liba52 -A52LIB := $(CODECDIR)/liba52.a -A52LIB_SRC := $(call preprocess, $(APPSDIR)/codecs/liba52/SOURCES) -A52LIB_OBJ := $(call c2obj, $(A52LIB_SRC)) -OTHER_SRC += $(A52LIB_SRC) - -$(A52LIB): $(A52LIB_OBJ) - $(SILENT)$(shell rm -f $@) - $(call PRINTS,AR $(@F))$(AR) rcs $@ $^ >/dev/null diff --git a/apps/codecs/liba52/mm_accel.h b/apps/codecs/liba52/mm_accel.h deleted file mode 100644 index aafc3fed82..0000000000 --- a/apps/codecs/liba52/mm_accel.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * mm_accel.h - * Copyright (C) 2000-2003 Michel Lespinasse - * Copyright (C) 1999-2000 Aaron Holtzman - * - * This file is part of a52dec, a free ATSC A-52 stream decoder. - * See http://liba52.sourceforge.net/ for updates. - * - * a52dec is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * a52dec is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef MM_ACCEL_H -#define MM_ACCEL_H - -/* generic accelerations */ -#define MM_ACCEL_DJBFFT 0x00000001 - -/* x86 accelerations */ -#define MM_ACCEL_X86_MMX 0x80000000 -#define MM_ACCEL_X86_3DNOW 0x40000000 -#define MM_ACCEL_X86_MMXEXT 0x20000000 - -uint32_t mm_accel (void); - -#endif /* MM_ACCEL_H */ diff --git a/apps/codecs/liba52/parse.c b/apps/codecs/liba52/parse.c deleted file mode 100644 index c61c13cdb5..0000000000 --- a/apps/codecs/liba52/parse.c +++ /dev/null @@ -1,956 +0,0 @@ -/* - * parse.c - * Copyright (C) 2000-2003 Michel Lespinasse - * Copyright (C) 1999-2000 Aaron Holtzman - * - * This file is part of a52dec, a free ATSC A-52 stream decoder. - * See http://liba52.sourceforge.net/ for updates. - * - * a52dec is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * a52dec is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "config-a52.h" - -#include -#include - -#include "a52.h" -#include "a52_internal.h" -#include "bitstream.h" -#include "tables.h" - -#if defined(HAVE_MEMALIGN) && !defined(__cplusplus) -/* some systems have memalign() but no declaration for it */ -void * memalign (size_t align, size_t size); -#else -/* assume malloc alignment is sufficient */ -#define memalign(align,size) malloc (size) -#endif - -typedef struct { - quantizer_t q1[2]; - quantizer_t q2[2]; - quantizer_t q4; - int q1_ptr; - int q2_ptr; - int q4_ptr; -} quantizer_set_t; - -static a52_state_t istate IBSS_ATTR; -static sample_t isamples[256*12] IBSS_ATTR; - -static uint8_t halfrate[12] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3}; - -a52_state_t * a52_init (uint32_t mm_accel) -{ - a52_state_t * state; - int i; - - #if defined(CPU_COLDFIRE) - coldfire_set_macsr(EMAC_FRACTIONAL | EMAC_ROUND | EMAC_SATURATE); - #endif - /* - this needs to come back if we ever want two decoder instances - simultenously. NOTE, you also need to remove comments in a52_free. - state = (a52_state_t *) malloc (sizeof (a52_state_t)); - if (state == NULL) - return NULL; - - state->samples = (sample_t *) memalign (16, 256 * 12 * sizeof (sample_t)); - if (state->samples == NULL) { - free (state); - return NULL; - } - - */ - state = &istate; - state->samples = isamples; - for (i = 0; i < 256 * 12; i++) - state->samples[i] = 0; - - state->downmixed = 1; - - state->lfsr_state = 1; - - a52_imdct_init (mm_accel); - - return state; -} - -sample_t * a52_samples (a52_state_t * state) -{ - return state->samples; -} - -int a52_syncinfo (uint8_t * buf, int * flags, - int * sample_rate, int * bit_rate) -{ - static int rate[] = { 32, 40, 48, 56, 64, 80, 96, 112, - 128, 160, 192, 224, 256, 320, 384, 448, - 512, 576, 640}; - static uint8_t lfeon[8] = {0x10, 0x10, 0x04, 0x04, 0x04, 0x01, 0x04, 0x01}; - int frmsizecod; - int bitrate; - int half; - int acmod; - - if ((buf[0] != 0x0b) || (buf[1] != 0x77)) /* syncword */ - return 0; - - if (buf[5] >= 0x60) /* bsid >= 12 */ - return 0; - half = halfrate[buf[5] >> 3]; - - /* acmod, dsurmod and lfeon */ - acmod = buf[6] >> 5; - *flags = ((((buf[6] & 0xf8) == 0x50) ? A52_DOLBY : acmod) | - ((buf[6] & lfeon[acmod]) ? A52_LFE : 0)); - - frmsizecod = buf[4] & 63; - if (frmsizecod >= 38) - return 0; - bitrate = rate [frmsizecod >> 1]; - *bit_rate = (bitrate * 1000) >> half; - - switch (buf[4] & 0xc0) { - case 0: - *sample_rate = 48000 >> half; - return 4 * bitrate; - case 0x40: - *sample_rate = 44100 >> half; - return 2 * (320 * bitrate / 147 + (frmsizecod & 1)); - case 0x80: - *sample_rate = 32000 >> half; - return 6 * bitrate; - default: - return 0; - } -} - -int a52_frame (a52_state_t * state, uint8_t * buf, int * flags, - level_t * level, sample_t bias) -{ - static level_t clev[4] = { LEVEL (LEVEL_3DB), LEVEL (LEVEL_45DB), - LEVEL (LEVEL_6DB), LEVEL (LEVEL_45DB) }; - static level_t slev[4] = { LEVEL (LEVEL_3DB), LEVEL (LEVEL_6DB), - 0, LEVEL (LEVEL_6DB) }; - int chaninfo; - int acmod; - - state->fscod = buf[4] >> 6; - state->halfrate = halfrate[buf[5] >> 3]; - state->acmod = acmod = buf[6] >> 5; - - a52_bitstream_set_ptr (state, buf + 6); - bitstream_get (state, 3); /* skip acmod we already parsed */ - - if ((acmod == 2) && (bitstream_get (state, 2) == 2)) /* dsurmod */ - acmod = A52_DOLBY; - - state->clev = state->slev = 0; - - if ((acmod & 1) && (acmod != 1)) - state->clev = clev[bitstream_get (state, 2)]; /* cmixlev */ - - if (acmod & 4) - state->slev = slev[bitstream_get (state, 2)]; /* surmixlev */ - - state->lfeon = bitstream_get (state, 1); - - state->output = a52_downmix_init (acmod, *flags, level, - state->clev, state->slev); - if (state->output < 0) - return 1; - if (state->lfeon && (*flags & A52_LFE)) - state->output |= A52_LFE; - *flags = state->output; - /* the 2* compensates for differences in imdct */ - state->dynrng = state->level = MUL_C (*level, 2); - state->bias = bias; - state->dynrnge = 1; - state->dynrngcall = NULL; - state->cplba.deltbae = DELTA_BIT_NONE; - state->ba[0].deltbae = state->ba[1].deltbae = state->ba[2].deltbae = - state->ba[3].deltbae = state->ba[4].deltbae = DELTA_BIT_NONE; - - chaninfo = !acmod; - do { - bitstream_get (state, 5); /* dialnorm */ - if (bitstream_get (state, 1)) /* compre */ - bitstream_get (state, 8); /* compr */ - if (bitstream_get (state, 1)) /* langcode */ - bitstream_get (state, 8); /* langcod */ - if (bitstream_get (state, 1)) /* audprodie */ - bitstream_get (state, 7); /* mixlevel + roomtyp */ - } while (chaninfo--); - - bitstream_get (state, 2); /* copyrightb + origbs */ - - if (bitstream_get (state, 1)) /* timecod1e */ - bitstream_get (state, 14); /* timecod1 */ - if (bitstream_get (state, 1)) /* timecod2e */ - bitstream_get (state, 14); /* timecod2 */ - - if (bitstream_get (state, 1)) { /* addbsie */ - int addbsil; - - addbsil = bitstream_get (state, 6); - do { - bitstream_get (state, 8); /* addbsi */ - } while (addbsil--); - } - - return 0; -} - -void a52_dynrng (a52_state_t * state, - level_t (* call) (level_t, void *), void * data) -{ - state->dynrnge = 0; - if (call) { - state->dynrnge = 1; - state->dynrngcall = call; - state->dynrngdata = data; - } -} - -static int parse_exponents (a52_state_t * state, int expstr, int ngrps, - uint8_t exponent, uint8_t * dest) -{ - int exps; - - while (ngrps--) { - exps = bitstream_get (state, 7); - - exponent += exp_1[exps]; - if (exponent > 24) - return 1; - - switch (expstr) { - case EXP_D45: - *(dest++) = exponent; - *(dest++) = exponent; - case EXP_D25: - *(dest++) = exponent; - case EXP_D15: - *(dest++) = exponent; - } - - exponent += exp_2[exps]; - if (exponent > 24) - return 1; - - switch (expstr) { - case EXP_D45: - *(dest++) = exponent; - *(dest++) = exponent; - case EXP_D25: - *(dest++) = exponent; - case EXP_D15: - *(dest++) = exponent; - } - - exponent += exp_3[exps]; - if (exponent > 24) - return 1; - - switch (expstr) { - case EXP_D45: - *(dest++) = exponent; - *(dest++) = exponent; - case EXP_D25: - *(dest++) = exponent; - case EXP_D15: - *(dest++) = exponent; - } - } - - return 0; -} - -static int parse_deltba (a52_state_t * state, int8_t * deltba) -{ - int deltnseg, deltlen, delta, j; - - memset (deltba, 0, 50); - - deltnseg = bitstream_get (state, 3); - j = 0; - do { - j += bitstream_get (state, 5); - deltlen = bitstream_get (state, 4); - delta = bitstream_get (state, 3); - delta -= (delta >= 4) ? 3 : 4; - if (!deltlen) - continue; - if (j + deltlen >= 50) - return 1; - while (deltlen--) - deltba[j++] = delta; - } while (deltnseg--); - - return 0; -} - -static inline int zero_snr_offsets (int nfchans, a52_state_t * state) -{ - int i; - - if ((state->csnroffst) || - (state->chincpl && state->cplba.bai >> 3) || /* cplinu, fsnroffst */ - (state->lfeon && state->lfeba.bai >> 3)) /* fsnroffst */ - return 0; - for (i = 0; i < nfchans; i++) - if (state->ba[i].bai >> 3) /* fsnroffst */ - return 0; - return 1; -} - -static inline int16_t dither_gen (a52_state_t * state) -{ - int16_t nstate; - - nstate = dither_lut[state->lfsr_state >> 8] ^ (state->lfsr_state << 8); - - state->lfsr_state = (uint16_t) nstate; - - return (3 * nstate) >> 2; -} - -#ifndef LIBA52_FIXED -#define COEFF(c,t,l,s,e) (c) = (t) * (s)[e] -#else -#define COEFF(c,_t,_l,s,e) do { \ - quantizer_t t = (_t); \ - level_t l = (_l); \ - int shift = e - 5; \ - sample_t tmp = t * (l >> 16) + ((t * (l & 0xffff)) >> 16); \ - if (shift >= 0) \ - (c) = tmp >> shift; \ - else \ - (c) = tmp << -shift; \ -} while (0) -#endif - -static void coeff_get (a52_state_t * state, sample_t * coeff, - expbap_t * expbap, quantizer_set_t * quant, - level_t level, int dither, int end) -{ - int i; - uint8_t * exp; - int8_t * bap; - -#ifndef LIBA52_FIXED - sample_t factor[25]; - - for (i = 0; i <= 24; i++) - factor[i] = scale_factor[i] * level; -#endif - - exp = expbap->exp; - bap = expbap->bap; - - for (i = 0; i < end; i++) { - int bapi; - - bapi = bap[i]; - switch (bapi) { - case 0: - if (dither) { - COEFF (coeff[i], dither_gen (state), level, factor, exp[i]); - continue; - } else { - coeff[i] = 0; - continue; - } - - case -1: - if (quant->q1_ptr >= 0) { - COEFF (coeff[i], quant->q1[quant->q1_ptr--], level, - factor, exp[i]); - continue; - } else { - int code; - - code = bitstream_get (state, 5); - - quant->q1_ptr = 1; - quant->q1[0] = q_1_2[code]; - quant->q1[1] = q_1_1[code]; - COEFF (coeff[i], q_1_0[code], level, factor, exp[i]); - continue; - } - - case -2: - if (quant->q2_ptr >= 0) { - COEFF (coeff[i], quant->q2[quant->q2_ptr--], level, - factor, exp[i]); - continue; - } else { - int code; - - code = bitstream_get (state, 7); - - quant->q2_ptr = 1; - quant->q2[0] = q_2_2[code]; - quant->q2[1] = q_2_1[code]; - COEFF (coeff[i], q_2_0[code], level, factor, exp[i]); - continue; - } - - case 3: - COEFF (coeff[i], q_3[bitstream_get (state, 3)], level, - factor, exp[i]); - continue; - - case -3: - if (quant->q4_ptr == 0) { - quant->q4_ptr = -1; - COEFF (coeff[i], quant->q4, level, factor, exp[i]); - continue; - } else { - int code; - - code = bitstream_get (state, 7); - - quant->q4_ptr = 0; - quant->q4 = q_4_1[code]; - COEFF (coeff[i], q_4_0[code], level, factor, exp[i]); - continue; - } - - case 4: - COEFF (coeff[i], q_5[bitstream_get (state, 4)], level, - factor, exp[i]); - continue; - - default: - COEFF (coeff[i], bitstream_get_2 (state, bapi) << (16 - bapi), - level, factor, exp[i]); - } - } -} - -static void coeff_get_coupling (a52_state_t * state, int nfchans, - level_t * coeff, sample_t (* samples)[256], - quantizer_set_t * quant, uint8_t dithflag[5]) -{ - int cplbndstrc, bnd, i, i_end, ch; - uint8_t * exp; - int8_t * bap; - level_t cplco[5]; - - exp = state->cpl_expbap.exp; - bap = state->cpl_expbap.bap; - bnd = 0; - cplbndstrc = state->cplbndstrc; - i = state->cplstrtmant; - while (i < state->cplendmant) { - i_end = i + 12; - while (cplbndstrc & 1) { - cplbndstrc >>= 1; - i_end += 12; - } - cplbndstrc >>= 1; - for (ch = 0; ch < nfchans; ch++) - cplco[ch] = MUL_L (state->cplco[ch][bnd], coeff[ch]); - bnd++; - - while (i < i_end) { - quantizer_t cplcoeff; - int bapi; - - bapi = bap[i]; - switch (bapi) { - case 0: - for (ch = 0; ch < nfchans; ch++) - if ((state->chincpl >> ch) & 1) { - if (dithflag[ch]) -#ifndef LIBA52_FIXED - samples[ch][i] = (scale_factor[exp[i]] * - cplco[ch] * dither_gen (state)); -#else - COEFF (samples[ch][i], dither_gen (state), - cplco[ch], scale_factor, exp[i]); -#endif - else - samples[ch][i] = 0; - } - i++; - continue; - - case -1: - if (quant->q1_ptr >= 0) { - cplcoeff = quant->q1[quant->q1_ptr--]; - break; - } else { - int code; - - code = bitstream_get (state, 5); - - quant->q1_ptr = 1; - quant->q1[0] = q_1_2[code]; - quant->q1[1] = q_1_1[code]; - cplcoeff = q_1_0[code]; - break; - } - - case -2: - if (quant->q2_ptr >= 0) { - cplcoeff = quant->q2[quant->q2_ptr--]; - break; - } else { - int code; - - code = bitstream_get (state, 7); - - quant->q2_ptr = 1; - quant->q2[0] = q_2_2[code]; - quant->q2[1] = q_2_1[code]; - cplcoeff = q_2_0[code]; - break; - } - - case 3: - cplcoeff = q_3[bitstream_get (state, 3)]; - break; - - case -3: - if (quant->q4_ptr == 0) { - quant->q4_ptr = -1; - cplcoeff = quant->q4; - break; - } else { - int code; - - code = bitstream_get (state, 7); - - quant->q4_ptr = 0; - quant->q4 = q_4_1[code]; - cplcoeff = q_4_0[code]; - break; - } - - case 4: - cplcoeff = q_5[bitstream_get (state, 4)]; - break; - - default: - cplcoeff = bitstream_get_2 (state, bapi) << (16 - bapi); - } -#ifndef LIBA52_FIXED - cplcoeff *= scale_factor[exp[i]]; -#endif - for (ch = 0; ch < nfchans; ch++) - if ((state->chincpl >> ch) & 1) -#ifndef LIBA52_FIXED - samples[ch][i] = cplcoeff * cplco[ch]; -#else - COEFF (samples[ch][i], cplcoeff, cplco[ch], - scale_factor, exp[i]); -#endif - i++; - } - } -} - -int a52_block (a52_state_t * state) -{ - static const uint8_t nfchans_tbl[] = {2, 1, 2, 3, 3, 4, 4, 5, 1, 1, 2}; - static int rematrix_band[4] = {25, 37, 61, 253}; - int i, nfchans, chaninfo; - uint8_t cplexpstr, chexpstr[5], lfeexpstr, do_bit_alloc, done_cpl; - uint8_t blksw[5], dithflag[5]; - level_t coeff[5]; - int chanbias; - quantizer_set_t quant; - sample_t * samples; - - nfchans = nfchans_tbl[state->acmod]; - - for (i = 0; i < nfchans; i++) - blksw[i] = bitstream_get (state, 1); - - for (i = 0; i < nfchans; i++) - dithflag[i] = bitstream_get (state, 1); - - chaninfo = !state->acmod; - do { - if (bitstream_get (state, 1)) { /* dynrnge */ - int dynrng; - - dynrng = bitstream_get_2 (state, 8); - if (state->dynrnge) { - level_t range; - -#if !defined(LIBA52_FIXED) - range = ((((dynrng & 0x1f) | 0x20) << 13) * - scale_factor[3 - (dynrng >> 5)]); -#else - range = ((dynrng & 0x1f) | 0x20) << (21 + (dynrng >> 5)); -#endif - if (state->dynrngcall) - range = state->dynrngcall (range, state->dynrngdata); - state->dynrng = MUL_L (state->level, range); - } - } - } while (chaninfo--); - - if (bitstream_get (state, 1)) { /* cplstre */ - state->chincpl = 0; - if (bitstream_get (state, 1)) { /* cplinu */ - static uint8_t bndtab[16] = {31, 35, 37, 39, 41, 42, 43, 44, - 45, 45, 46, 46, 47, 47, 48, 48}; - int cplbegf; - int cplendf; - int ncplsubnd; - - for (i = 0; i < nfchans; i++) - state->chincpl |= bitstream_get (state, 1) << i; - switch (state->acmod) { - case 0: case 1: - return 1; - case 2: - state->phsflginu = bitstream_get (state, 1); - } - cplbegf = bitstream_get (state, 4); - cplendf = bitstream_get (state, 4); - - if (cplendf + 3 - cplbegf < 0) - return 1; - state->ncplbnd = ncplsubnd = cplendf + 3 - cplbegf; - state->cplstrtbnd = bndtab[cplbegf]; - state->cplstrtmant = cplbegf * 12 + 37; - state->cplendmant = cplendf * 12 + 73; - - state->cplbndstrc = 0; - for (i = 0; i < ncplsubnd - 1; i++) - if (bitstream_get (state, 1)) { - state->cplbndstrc |= 1 << i; - state->ncplbnd--; - } - } - } - - if (state->chincpl) { /* cplinu */ - int j, cplcoe; - - cplcoe = 0; - for (i = 0; i < nfchans; i++) - if ((state->chincpl) >> i & 1) - if (bitstream_get (state, 1)) { /* cplcoe */ - int mstrcplco, cplcoexp, cplcomant; - - cplcoe = 1; - mstrcplco = 3 * bitstream_get (state, 2); - for (j = 0; j < state->ncplbnd; j++) { - cplcoexp = bitstream_get (state, 4); - cplcomant = bitstream_get (state, 4); - if (cplcoexp == 15) - cplcomant <<= 14; - else - cplcomant = (cplcomant | 0x10) << 13; -#ifndef LIBA52_FIXED - state->cplco[i][j] = - cplcomant * scale_factor[cplcoexp + mstrcplco]; -#else - state->cplco[i][j] = (cplcomant << 11) >> (cplcoexp + mstrcplco); -#endif - - } - } - if ((state->acmod == 2) && state->phsflginu && cplcoe) - for (j = 0; j < state->ncplbnd; j++) - if (bitstream_get (state, 1)) /* phsflg */ - state->cplco[1][j] = -state->cplco[1][j]; - } - - if ((state->acmod == 2) && (bitstream_get (state, 1))) { /* rematstr */ - int end; - - state->rematflg = 0; - end = (state->chincpl) ? state->cplstrtmant : 253; /* cplinu */ - i = 0; - do - state->rematflg |= bitstream_get (state, 1) << i; - while (rematrix_band[i++] < end); - } - - cplexpstr = EXP_REUSE; - lfeexpstr = EXP_REUSE; - if (state->chincpl) /* cplinu */ - cplexpstr = bitstream_get (state, 2); - for (i = 0; i < nfchans; i++) - chexpstr[i] = bitstream_get (state, 2); - if (state->lfeon) - lfeexpstr = bitstream_get (state, 1); - - for (i = 0; i < nfchans; i++) - if (chexpstr[i] != EXP_REUSE) { - if ((state->chincpl >> i) & 1) - state->endmant[i] = state->cplstrtmant; - else { - int chbwcod; - - chbwcod = bitstream_get (state, 6); - if (chbwcod > 60) - return 1; - state->endmant[i] = chbwcod * 3 + 73; - } - } - - do_bit_alloc = 0; - - if (cplexpstr != EXP_REUSE) { - int cplabsexp, ncplgrps; - - do_bit_alloc = 64; - ncplgrps = ((state->cplendmant - state->cplstrtmant) / - (3 << (cplexpstr - 1))); - cplabsexp = bitstream_get (state, 4) << 1; - if (parse_exponents (state, cplexpstr, ncplgrps, cplabsexp, - state->cpl_expbap.exp + state->cplstrtmant)) - return 1; - } - for (i = 0; i < nfchans; i++) - if (chexpstr[i] != EXP_REUSE) { - int grp_size, nchgrps; - - do_bit_alloc |= 1 << i; - grp_size = 3 << (chexpstr[i] - 1); - nchgrps = (state->endmant[i] + grp_size - 4) / grp_size; - state->fbw_expbap[i].exp[0] = bitstream_get (state, 4); - if (parse_exponents (state, chexpstr[i], nchgrps, - state->fbw_expbap[i].exp[0], - state->fbw_expbap[i].exp + 1)) - return 1; - bitstream_get (state, 2); /* gainrng */ - } - if (lfeexpstr != EXP_REUSE) { - do_bit_alloc |= 32; - state->lfe_expbap.exp[0] = bitstream_get (state, 4); - if (parse_exponents (state, lfeexpstr, 2, state->lfe_expbap.exp[0], - state->lfe_expbap.exp + 1)) - return 1; - } - - if (bitstream_get (state, 1)) { /* baie */ - do_bit_alloc = 127; - state->bai = bitstream_get (state, 11); - } - if (bitstream_get (state, 1)) { /* snroffste */ - do_bit_alloc = 127; - state->csnroffst = bitstream_get (state, 6); - if (state->chincpl) /* cplinu */ - state->cplba.bai = bitstream_get (state, 7); - for (i = 0; i < nfchans; i++) - state->ba[i].bai = bitstream_get (state, 7); - if (state->lfeon) - state->lfeba.bai = bitstream_get (state, 7); - } - if ((state->chincpl) && (bitstream_get (state, 1))) { /* cplleake */ - do_bit_alloc |= 64; - state->cplfleak = 9 - bitstream_get (state, 3); - state->cplsleak = 9 - bitstream_get (state, 3); - } - - if (bitstream_get (state, 1)) { /* deltbaie */ - do_bit_alloc = 127; - if (state->chincpl) /* cplinu */ - state->cplba.deltbae = bitstream_get (state, 2); - for (i = 0; i < nfchans; i++) - state->ba[i].deltbae = bitstream_get (state, 2); - if (state->chincpl && /* cplinu */ - (state->cplba.deltbae == DELTA_BIT_NEW) && - parse_deltba (state, state->cplba.deltba)) - return 1; - for (i = 0; i < nfchans; i++) - if ((state->ba[i].deltbae == DELTA_BIT_NEW) && - parse_deltba (state, state->ba[i].deltba)) - return 1; - } - - if (do_bit_alloc) { - if (zero_snr_offsets (nfchans, state)) { - memset (state->cpl_expbap.bap, 0, sizeof (state->cpl_expbap.bap)); - for (i = 0; i < nfchans; i++) - memset (state->fbw_expbap[i].bap, 0, - sizeof (state->fbw_expbap[i].bap)); - memset (state->lfe_expbap.bap, 0, sizeof (state->lfe_expbap.bap)); - } else { - if (state->chincpl && (do_bit_alloc & 64)) /* cplinu */ - a52_bit_allocate (state, &state->cplba, state->cplstrtbnd, - state->cplstrtmant, state->cplendmant, - state->cplfleak << 8, state->cplsleak << 8, - &state->cpl_expbap); - for (i = 0; i < nfchans; i++) - if (do_bit_alloc & (1 << i)) - a52_bit_allocate (state, state->ba + i, 0, 0, - state->endmant[i], 0, 0, - state->fbw_expbap +i); - if (state->lfeon && (do_bit_alloc & 32)) { - state->lfeba.deltbae = DELTA_BIT_NONE; - a52_bit_allocate (state, &state->lfeba, 0, 0, 7, 0, 0, - &state->lfe_expbap); - } - } - } - - if (bitstream_get (state, 1)) { /* skiple */ - i = bitstream_get (state, 9); /* skipl */ - while (i--) - bitstream_get (state, 8); - } - - samples = state->samples; - if (state->output & A52_LFE) - samples += 256; /* shift for LFE channel */ - - chanbias = a52_downmix_coeff (coeff, state->acmod, state->output, - state->dynrng, state->clev, state->slev); - - quant.q1_ptr = quant.q2_ptr = quant.q4_ptr = -1; - done_cpl = 0; - - for (i = 0; i < nfchans; i++) { - int j; - - coeff_get (state, samples + 256 * i, state->fbw_expbap +i, &quant, - coeff[i], dithflag[i], state->endmant[i]); - - if ((state->chincpl >> i) & 1) { - if (!done_cpl) { - done_cpl = 1; - coeff_get_coupling (state, nfchans, coeff, - (sample_t (*)[256])samples, &quant, - dithflag); - } - j = state->cplendmant; - } else - j = state->endmant[i]; - do - (samples + 256 * i)[j] = 0; - while (++j < 256); - } - - if (state->acmod == 2) { - int j, end, band, rematflg; - - end = ((state->endmant[0] < state->endmant[1]) ? - state->endmant[0] : state->endmant[1]); - - i = 0; - j = 13; - rematflg = state->rematflg; - do { - if (! (rematflg & 1)) { - rematflg >>= 1; - j = rematrix_band[i++]; - continue; - } - rematflg >>= 1; - band = rematrix_band[i++]; - if (band > end) - band = end; - do { - sample_t tmp0, tmp1; - - tmp0 = samples[j]; - tmp1 = (samples+256)[j]; - samples[j] = tmp0 + tmp1; - (samples+256)[j] = tmp0 - tmp1; - } while (++j < band); - } while (j < end); - } - - if (state->lfeon) { - if (state->output & A52_LFE) { - coeff_get (state, samples - 256, &state->lfe_expbap, &quant, - state->dynrng, 0, 7); - for (i = 7; i < 256; i++) - (samples-256)[i] = 0; - a52_imdct_512 (samples - 256, samples + 1536 - 256); - } else { - /* just skip the LFE coefficients */ - coeff_get (state, samples + 1280, &state->lfe_expbap, &quant, - 0, 0, 7); - } - } - - i = 0; - if (nfchans_tbl[state->output & A52_CHANNEL_MASK] < nfchans) - for (i = 1; i < nfchans; i++) - if (blksw[i] != blksw[0]) - break; - - if (i < nfchans) { - if (state->downmixed) { - state->downmixed = 0; - a52_upmix (samples + 1536, state->acmod, state->output); - } - - for (i = 0; i < nfchans; i++) { - sample_t bias; - - bias = 0; - if (!(chanbias & (1 << i))) - bias = state->bias; - - if (coeff[i]) { - if (blksw[i]) - a52_imdct_256 (samples + 256 * i, samples + 1536 + 256 * i); - else - a52_imdct_512 (samples + 256 * i, samples + 1536 + 256 * i); - } else { - int j; - - for (j = 0; j < 256; j++) - (samples + 256 * i)[j] = bias; - } - } - - a52_downmix (samples, state->acmod, state->output, - state->clev, state->slev); - } else { - nfchans = nfchans_tbl[state->output & A52_CHANNEL_MASK]; - - a52_downmix (samples, state->acmod, state->output, - state->clev, state->slev); - - if (!state->downmixed) { - state->downmixed = 1; - a52_downmix (samples + 1536, state->acmod, state->output, - state->clev, state->slev); - } - - if (blksw[0]) - for (i = 0; i < nfchans; i++) - a52_imdct_256 (samples + 256 * i, samples + 1536 + 256 * i); - else - for (i = 0; i < nfchans; i++) - a52_imdct_512 (samples + 256 * i, samples + 1536 + 256 * i); - } - - return 0; -} - -void a52_free (a52_state_t * state) -{ - (void)state; - /* - free (state->samples); - free (state); - */ -} diff --git a/apps/codecs/liba52/tables.h b/apps/codecs/liba52/tables.h deleted file mode 100644 index b067c63f69..0000000000 --- a/apps/codecs/liba52/tables.h +++ /dev/null @@ -1,246 +0,0 @@ -/* - * tables.h - * Copyright (C) 2000-2003 Michel Lespinasse - * Copyright (C) 1999-2000 Aaron Holtzman - * - * This file is part of a52dec, a free ATSC A-52 stream decoder. - * See http://liba52.sourceforge.net/ for updates. - * - * a52dec is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * a52dec is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -static const int8_t exp_1[128] = { - -2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2, - -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 25,25,25 -}; -static const int8_t exp_2[128] = { - -2,-2,-2,-2,-2,-1,-1,-1,-1,-1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, - -2,-2,-2,-2,-2,-1,-1,-1,-1,-1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, - -2,-2,-2,-2,-2,-1,-1,-1,-1,-1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, - -2,-2,-2,-2,-2,-1,-1,-1,-1,-1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, - -2,-2,-2,-2,-2,-1,-1,-1,-1,-1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, - 25,25,25 -}; -static const int8_t exp_3[128] = { - -2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2, - -2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2, - -2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2, - -2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2, - -2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2, - 25,25,25 -}; - -#define Q(x) ROUND (32768.0 * x) - -#define Q0 Q (-2/3) -#define Q1 Q (0) -#define Q2 Q (2/3) - -static const quantizer_t q_1_0[32] = { - Q0, Q0, Q0, Q0, Q0, Q0, Q0, Q0, Q0, - Q1, Q1, Q1, Q1, Q1, Q1, Q1, Q1, Q1, - Q2, Q2, Q2, Q2, Q2, Q2, Q2, Q2, Q2, - 0, 0, 0, 0, 0 -}; - -static const quantizer_t q_1_1[32] = { - Q0, Q0, Q0, Q1, Q1, Q1, Q2, Q2, Q2, - Q0, Q0, Q0, Q1, Q1, Q1, Q2, Q2, Q2, - Q0, Q0, Q0, Q1, Q1, Q1, Q2, Q2, Q2, - 0, 0, 0, 0, 0 -}; - -static const quantizer_t q_1_2[32] = { - Q0, Q1, Q2, Q0, Q1, Q2, Q0, Q1, Q2, - Q0, Q1, Q2, Q0, Q1, Q2, Q0, Q1, Q2, - Q0, Q1, Q2, Q0, Q1, Q2, Q0, Q1, Q2, - 0, 0, 0, 0, 0 -}; - -#undef Q0 -#undef Q1 -#undef Q2 - -#define Q0 Q (-4/5) -#define Q1 Q (-2/5) -#define Q2 Q (0) -#define Q3 Q (2/5) -#define Q4 Q (4/5) - -static const quantizer_t q_2_0[128] = { - Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0, - Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1, - Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2, - Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3, - Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4, - 0,0,0 -}; - -static const quantizer_t q_2_1[128] = { - Q0,Q0,Q0,Q0,Q0,Q1,Q1,Q1,Q1,Q1,Q2,Q2,Q2,Q2,Q2,Q3,Q3,Q3,Q3,Q3,Q4,Q4,Q4,Q4,Q4, - Q0,Q0,Q0,Q0,Q0,Q1,Q1,Q1,Q1,Q1,Q2,Q2,Q2,Q2,Q2,Q3,Q3,Q3,Q3,Q3,Q4,Q4,Q4,Q4,Q4, - Q0,Q0,Q0,Q0,Q0,Q1,Q1,Q1,Q1,Q1,Q2,Q2,Q2,Q2,Q2,Q3,Q3,Q3,Q3,Q3,Q4,Q4,Q4,Q4,Q4, - Q0,Q0,Q0,Q0,Q0,Q1,Q1,Q1,Q1,Q1,Q2,Q2,Q2,Q2,Q2,Q3,Q3,Q3,Q3,Q3,Q4,Q4,Q4,Q4,Q4, - Q0,Q0,Q0,Q0,Q0,Q1,Q1,Q1,Q1,Q1,Q2,Q2,Q2,Q2,Q2,Q3,Q3,Q3,Q3,Q3,Q4,Q4,Q4,Q4,Q4, - 0,0,0 -}; - -static const quantizer_t q_2_2[128] = { - Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4, - Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4, - Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4, - Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4, - Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4, - 0,0,0 -}; - -#undef Q0 -#undef Q1 -#undef Q2 -#undef Q3 -#undef Q4 - -static const quantizer_t q_3[8] = { - Q (-6/7), Q (-4/7), Q (-2/7), Q (0), Q (2/7), Q (4/7), Q (6/7), 0 -}; - -#define Q0 Q (-10/11) -#define Q1 Q (-8/11) -#define Q2 Q (-6/11) -#define Q3 Q (-4/11) -#define Q4 Q (-2/11) -#define Q5 Q (0) -#define Q6 Q (2/11) -#define Q7 Q (4/11) -#define Q8 Q (6/11) -#define Q9 Q (8/11) -#define QA Q (10/11) - -static const quantizer_t q_4_0[128] = { - Q0, Q0, Q0, Q0, Q0, Q0, Q0, Q0, Q0, Q0, Q0, - Q1, Q1, Q1, Q1, Q1, Q1, Q1, Q1, Q1, Q1, Q1, - Q2, Q2, Q2, Q2, Q2, Q2, Q2, Q2, Q2, Q2, Q2, - Q3, Q3, Q3, Q3, Q3, Q3, Q3, Q3, Q3, Q3, Q3, - Q4, Q4, Q4, Q4, Q4, Q4, Q4, Q4, Q4, Q4, Q4, - Q5, Q5, Q5, Q5, Q5, Q5, Q5, Q5, Q5, Q5, Q5, - Q6, Q6, Q6, Q6, Q6, Q6, Q6, Q6, Q6, Q6, Q6, - Q7, Q7, Q7, Q7, Q7, Q7, Q7, Q7, Q7, Q7, Q7, - Q8, Q8, Q8, Q8, Q8, Q8, Q8, Q8, Q8, Q8, Q8, - Q9, Q9, Q9, Q9, Q9, Q9, Q9, Q9, Q9, Q9, Q9, - QA, QA, QA, QA, QA, QA, QA, QA, QA, QA, QA, - 0, 0, 0, 0, 0, 0, 0 -}; - -static const quantizer_t q_4_1[128] = { - Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, QA, - Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, QA, - Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, QA, - Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, QA, - Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, QA, - Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, QA, - Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, QA, - Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, QA, - Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, QA, - Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, QA, - Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, QA, - 0, 0, 0, 0, 0, 0, 0 -}; - -#undef Q0 -#undef Q1 -#undef Q2 -#undef Q3 -#undef Q4 -#undef Q5 -#undef Q6 -#undef Q7 -#undef Q8 -#undef Q9 -#undef QA - -static const quantizer_t q_5[16] = { - Q (-14/15), Q (-12/15), Q (-10/15), Q (-8/15), Q (-6/15), - Q (-4/15), Q (-2/15), Q (0), Q (2/15), Q (4/15), - Q (6/15), Q (8/15), Q (10/15), Q (12/15), Q (14/15), 0 -}; - -#ifndef LIBA52_FIXED -static const sample_t scale_factor[25] = { - 0.000030517578125, - 0.0000152587890625, - 0.00000762939453125, - 0.000003814697265625, - 0.0000019073486328125, - 0.00000095367431640625, - 0.000000476837158203125, - 0.0000002384185791015625, - 0.00000011920928955078125, - 0.000000059604644775390625, - 0.0000000298023223876953125, - 0.00000001490116119384765625, - 0.000000007450580596923828125, - 0.0000000037252902984619140625, - 0.00000000186264514923095703125, - 0.000000000931322574615478515625, - 0.0000000004656612873077392578125, - 0.00000000023283064365386962890625, - 0.000000000116415321826934814453125, - 0.0000000000582076609134674072265625, - 0.00000000002910383045673370361328125, - 0.000000000014551915228366851806640625, - 0.0000000000072759576141834259033203125, - 0.00000000000363797880709171295166015625, - 0.000000000001818989403545856475830078125 -}; -#endif - -static const uint16_t dither_lut[256] = { - 0x0000, 0xa011, 0xe033, 0x4022, 0x6077, 0xc066, 0x8044, 0x2055, - 0xc0ee, 0x60ff, 0x20dd, 0x80cc, 0xa099, 0x0088, 0x40aa, 0xe0bb, - 0x21cd, 0x81dc, 0xc1fe, 0x61ef, 0x41ba, 0xe1ab, 0xa189, 0x0198, - 0xe123, 0x4132, 0x0110, 0xa101, 0x8154, 0x2145, 0x6167, 0xc176, - 0x439a, 0xe38b, 0xa3a9, 0x03b8, 0x23ed, 0x83fc, 0xc3de, 0x63cf, - 0x8374, 0x2365, 0x6347, 0xc356, 0xe303, 0x4312, 0x0330, 0xa321, - 0x6257, 0xc246, 0x8264, 0x2275, 0x0220, 0xa231, 0xe213, 0x4202, - 0xa2b9, 0x02a8, 0x428a, 0xe29b, 0xc2ce, 0x62df, 0x22fd, 0x82ec, - 0x8734, 0x2725, 0x6707, 0xc716, 0xe743, 0x4752, 0x0770, 0xa761, - 0x47da, 0xe7cb, 0xa7e9, 0x07f8, 0x27ad, 0x87bc, 0xc79e, 0x678f, - 0xa6f9, 0x06e8, 0x46ca, 0xe6db, 0xc68e, 0x669f, 0x26bd, 0x86ac, - 0x6617, 0xc606, 0x8624, 0x2635, 0x0660, 0xa671, 0xe653, 0x4642, - 0xc4ae, 0x64bf, 0x249d, 0x848c, 0xa4d9, 0x04c8, 0x44ea, 0xe4fb, - 0x0440, 0xa451, 0xe473, 0x4462, 0x6437, 0xc426, 0x8404, 0x2415, - 0xe563, 0x4572, 0x0550, 0xa541, 0x8514, 0x2505, 0x6527, 0xc536, - 0x258d, 0x859c, 0xc5be, 0x65af, 0x45fa, 0xe5eb, 0xa5c9, 0x05d8, - 0xae79, 0x0e68, 0x4e4a, 0xee5b, 0xce0e, 0x6e1f, 0x2e3d, 0x8e2c, - 0x6e97, 0xce86, 0x8ea4, 0x2eb5, 0x0ee0, 0xaef1, 0xeed3, 0x4ec2, - 0x8fb4, 0x2fa5, 0x6f87, 0xcf96, 0xefc3, 0x4fd2, 0x0ff0, 0xafe1, - 0x4f5a, 0xef4b, 0xaf69, 0x0f78, 0x2f2d, 0x8f3c, 0xcf1e, 0x6f0f, - 0xede3, 0x4df2, 0x0dd0, 0xadc1, 0x8d94, 0x2d85, 0x6da7, 0xcdb6, - 0x2d0d, 0x8d1c, 0xcd3e, 0x6d2f, 0x4d7a, 0xed6b, 0xad49, 0x0d58, - 0xcc2e, 0x6c3f, 0x2c1d, 0x8c0c, 0xac59, 0x0c48, 0x4c6a, 0xec7b, - 0x0cc0, 0xacd1, 0xecf3, 0x4ce2, 0x6cb7, 0xcca6, 0x8c84, 0x2c95, - 0x294d, 0x895c, 0xc97e, 0x696f, 0x493a, 0xe92b, 0xa909, 0x0918, - 0xe9a3, 0x49b2, 0x0990, 0xa981, 0x89d4, 0x29c5, 0x69e7, 0xc9f6, - 0x0880, 0xa891, 0xe8b3, 0x48a2, 0x68f7, 0xc8e6, 0x88c4, 0x28d5, - 0xc86e, 0x687f, 0x285d, 0x884c, 0xa819, 0x0808, 0x482a, 0xe83b, - 0x6ad7, 0xcac6, 0x8ae4, 0x2af5, 0x0aa0, 0xaab1, 0xea93, 0x4a82, - 0xaa39, 0x0a28, 0x4a0a, 0xea1b, 0xca4e, 0x6a5f, 0x2a7d, 0x8a6c, - 0x4b1a, 0xeb0b, 0xab29, 0x0b38, 0x2b6d, 0x8b7c, 0xcb5e, 0x6b4f, - 0x8bf4, 0x2be5, 0x6bc7, 0xcbd6, 0xeb83, 0x4b92, 0x0bb0, 0xaba1 -}; diff --git a/apps/codecs/liba52/tendra.h b/apps/codecs/liba52/tendra.h deleted file mode 100644 index cc740fceeb..0000000000 --- a/apps/codecs/liba52/tendra.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * tendra.h - * Copyright (C) 2000-2003 Michel Lespinasse - * Copyright (C) 1999-2000 Aaron Holtzman - * - * This file is part of a52dec, a free ATSC A-52 stream decoder. - * See http://liba52.sourceforge.net/ for updates. - * - * a52dec is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * a52dec is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#pragma TenDRA begin -#pragma TenDRA longlong type warning - -#ifdef TenDRA_check - -#pragma TenDRA conversion analysis (pointer-int explicit) off -#pragma TenDRA implicit function declaration off - -/* avoid the "No declarations in translation unit" problem */ -int TenDRA; - -#endif /* TenDRA_check */ diff --git a/apps/codecs/libalac/README b/apps/codecs/libalac/README deleted file mode 100644 index 1b304d2d93..0000000000 --- a/apps/codecs/libalac/README +++ /dev/null @@ -1,43 +0,0 @@ -INSTALLATION: -------------- - -Simply compile by running 'make' - -USAGE: ------- - -Then run the program, it will give you usage instructions. - -It's really quite trivial to use. - -For example, to decode input.m4a to output.wav: -./alac -f output.wav input.m4a - -Or, as another example, say if you wanted to stream play -http://www.mplayerhq.hu/MPlayer/samples/A-codecs/lossless/luckynight.m4a -and you're system uses the ALSA sound system: -wget -O - http://www.mplayerhq.hu/MPlayer/samples/A-codecs/lossless/luckynight.m4a | ./alac - | aplay - -By default the output file is in WAV format. To output as raw PCM, provide the --r option on the command line. - -MORE INFORMATION: ------------------ - -Please visit http://crazney.net/programs/itunes/alac.html for more information. - -HELP NEEDED: ------------- -I need help to allow myself to continue hacking on various Apple Audio things, please visit -http://crazney.net/programs/itunes/help.html - -AUTHOR: -------- - -David Hammerton - -CONTRIBUTORS: -------------- - -Cody Brocious - diff --git a/apps/codecs/libalac/README.rockbox b/apps/codecs/libalac/README.rockbox deleted file mode 100644 index 891e581cfc..0000000000 --- a/apps/codecs/libalac/README.rockbox +++ /dev/null @@ -1,80 +0,0 @@ -Library: Reverse-engineered ALAC decoder v0.1.0 -Imported: 2005-08-14 by Dave Chapman - - -This directory contains a local version of an ALAC (Apple Lossless Audio -Codec) for use by Rockbox for software decoding of ALAC files. It is -based on the reverse-engineered decoder by David Hamilton. - -LICENSING INFORMATION - -/* - * ALAC (Apple Lossless Audio Codec) decoder - * Copyright (c) 2005 David Hammerton - * All rights reserved. - * - * This is the actual decoder. - * - * http://crazney.net/programs/itunes/alac.html - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - * - */ - -IMPORT DETAILS - -The base version first imported into Rockbox was the first release -(v0.1.0) of the ALAC decoder by David Hammerton. - -Only the files alac.[ch], demux.[ch] and stream.h were used. - -stream.c (the original FILE* based I/O implementation) was replaced with -functions in the ALAC codec - to interface with the Rockbox audio playback -system. - -References to were replaced with and debugging -calls to fprintf were removed. - -The ALAC decoder itself was modified to return samples in host-endian -order, instead of little-endian. - -The run-time detection of CPU endianness was replaced with -compile-time tests of the ROCKBOX_LITTLE_ENDIAN define. - -All malloc calls were removed from alac.c, but some are still present -in the metadata parser in demux.c - to store unbounded data such as -the size in bytes of each compressed block in the file. - -The only changes to demux.c were to remove debugging calls to fprintf. - -The most-used buffers (the temporary 32-bit output buffer) were moved -into IRAM (on the iRiver). This was enough to make the decoder work -in real-time. - -A point of interest - the -O3 gcc option (the setting used in the -original Makefile provided with the alac decoder) gives a significant -speedup compared to -O2. With -O2, the Coldfire runs at a constant -120MHz, but with -O3, it can power-down to 40MHz for a small amount of -time. - -The file alac.c contained some hints from the original author for -places where major optimisations can be made - specifically the -unrolling and optimisation of certain cases of general loops. diff --git a/apps/codecs/libalac/SOURCES b/apps/codecs/libalac/SOURCES deleted file mode 100644 index 854b9e6f88..0000000000 --- a/apps/codecs/libalac/SOURCES +++ /dev/null @@ -1 +0,0 @@ -alac.c diff --git a/apps/codecs/libalac/alac.c b/apps/codecs/libalac/alac.c deleted file mode 100644 index fd24656504..0000000000 --- a/apps/codecs/libalac/alac.c +++ /dev/null @@ -1,1148 +0,0 @@ -/* - * ALAC (Apple Lossless Audio Codec) decoder - * Copyright (c) 2005 David Hammerton - * All rights reserved. - * - * This is the actual decoder. - * - * http://crazney.net/programs/itunes/alac.html - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - * - */ - - -#include -#include -#include -#include - -#include "codeclib.h" -#include "decomp.h" - -#define SIGNEXTEND24(val) (((signed)val<<8)>>8) - -static int16_t predictor_coef_table[32] IBSS_ATTR; -static int16_t predictor_coef_table_a[32] IBSS_ATTR; -static int16_t predictor_coef_table_b[32] IBSS_ATTR; - - -/* Endian/aligment safe functions - only used in alac_set_info() */ -static uint32_t get_uint32be(unsigned char* p) -{ - return((p[0]<<24) | (p[1]<<16) | (p[2]<<8) | p[3]); -} - -static uint16_t get_uint16be(unsigned char* p) -{ - return((p[0]<<8) | p[1]); -} - -void alac_set_info(alac_file *alac, char *inputbuffer) -{ - unsigned char* ptr = (unsigned char*)inputbuffer; - ptr += 4; /* size */ - ptr += 4; /* frma */ - ptr += 4; /* alac */ - ptr += 4; /* size */ - ptr += 4; /* alac */ - - ptr += 4; /* 0 ? */ - - alac->setinfo_max_samples_per_frame = get_uint32be(ptr); /* buffer size / 2 ? */ - ptr += 4; - alac->setinfo_7a = *ptr++; - alac->setinfo_sample_size = *ptr++; - alac->setinfo_rice_historymult = *ptr++; - alac->setinfo_rice_initialhistory = *ptr++; - alac->setinfo_rice_kmodifier = *ptr++; - alac->setinfo_7f = *ptr++; - ptr += 1; - alac->setinfo_80 = get_uint16be(ptr); - ptr += 2; - alac->setinfo_82 = get_uint32be(ptr); - ptr += 4; - alac->setinfo_86 = get_uint32be(ptr); - ptr += 4; - alac->setinfo_8a_rate = get_uint32be(ptr); - ptr += 4; -} - -/* stream reading */ - -/* supports reading 1 to 16 bits, in big endian format */ -static inline uint32_t readbits_16(alac_file *alac, int bits) -{ - uint32_t result; - int new_accumulator; - - result = (alac->input_buffer[0] << 16) | - (alac->input_buffer[1] << 8) | - (alac->input_buffer[2]); - - /* shift left by the number of bits we've already read, - * so that the top 'n' bits of the 24 bits we read will - * be the return bits */ - result = result << alac->input_buffer_bitaccumulator; - - result = result & 0x00ffffff; - - /* and then only want the top 'n' bits from that, where - * n is 'bits' */ - result = result >> (24 - bits); - - new_accumulator = (alac->input_buffer_bitaccumulator + bits); - - /* increase the buffer pointer if we've read over n bytes. */ - alac->input_buffer += (new_accumulator >> 3); - - /* and the remainder goes back into the bit accumulator */ - alac->input_buffer_bitaccumulator = (new_accumulator & 7); - - return result; -} - -/* supports reading 1 to 32 bits, in big endian format */ -static inline uint32_t readbits(alac_file *alac, int bits) -{ - int32_t result = 0; - - if (bits > 16) - { - bits -= 16; - result = readbits_16(alac, 16) << bits; - } - - result |= readbits_16(alac, bits); - - return result; -} - -/* reads a single bit */ -static inline int readbit(alac_file *alac) -{ - int result; - int new_accumulator; - - result = alac->input_buffer[0]; - - result = result << alac->input_buffer_bitaccumulator; - - result = result >> 7 & 1; - - new_accumulator = (alac->input_buffer_bitaccumulator + 1); - - alac->input_buffer += (new_accumulator / 8); - - alac->input_buffer_bitaccumulator = (new_accumulator % 8); - - return result; -} - -static inline void unreadbits(alac_file *alac, int bits) -{ - int new_accumulator = (alac->input_buffer_bitaccumulator - bits); - - alac->input_buffer += (new_accumulator >> 3); - - alac->input_buffer_bitaccumulator = (new_accumulator & 7); - if (alac->input_buffer_bitaccumulator < 0) - alac->input_buffer_bitaccumulator *= -1; -} - -#define count_leading_zeros(x) bs_generic(x, BS_CLZ|BS_SHORT) - -#define RICE_THRESHOLD 8 // maximum number of bits for a rice prefix. - -static inline int32_t entropy_decode_value(alac_file* alac, - int readsamplesize, - int k) ICODE_ATTR_ALAC; -static inline int32_t entropy_decode_value(alac_file* alac, - int readsamplesize, - int k) -{ - int32_t x = 0; // decoded value - - // read x, number of 1s before 0 represent the rice value. - while (x <= RICE_THRESHOLD && readbit(alac)) - { - x++; - } - - if (x > RICE_THRESHOLD) - { - // read the number from the bit stream (raw value) - int32_t value; - - value = readbits(alac, readsamplesize); - - /* mask value to readsamplesize size */ - if (readsamplesize != 32) - value &= (((uint32_t)0xffffffff) >> (32 - readsamplesize)); - - x = value; - } - else - { - if (k != 1) - { - int extrabits = readbits(alac, k); - - // x = x * (2^k - 1) - x = (x << k) - x; - - if (extrabits > 1) - x += extrabits - 1; - else - unreadbits(alac, 1); - } - } - - return x; -} - -static void entropy_rice_decode(alac_file* alac, - int32_t* output_buffer, - int output_size, - int readsamplesize, - int rice_initialhistory, - int rice_kmodifier, - int rice_historymult, - int rice_kmodifier_mask) ICODE_ATTR_ALAC; -static void entropy_rice_decode(alac_file* alac, - int32_t* output_buffer, - int output_size, - int readsamplesize, - int rice_initialhistory, - int rice_kmodifier, - int rice_historymult, - int rice_kmodifier_mask) -{ - int output_count; - int history = rice_initialhistory; - int sign_modifier = 0; - - for (output_count = 0; output_count < output_size; output_count++) - { - int32_t decoded_value; - int32_t final_value; - int32_t k; - - k = 31 - rice_kmodifier - count_leading_zeros((history >> 9) + 3); - - if (k < 0) k += rice_kmodifier; - else k = rice_kmodifier; - - decoded_value = entropy_decode_value(alac, readsamplesize, k); - - decoded_value += sign_modifier; - final_value = (decoded_value + 1) / 2; // inc by 1 and shift out sign bit - if (decoded_value & 1) // the sign is stored in the low bit - final_value *= -1; - - output_buffer[output_count] = final_value; - - sign_modifier = 0; - - // update history - history += (decoded_value * rice_historymult) - - ((history * rice_historymult) >> 9); - - if (decoded_value > 0xFFFF) - history = 0xFFFF; - - // special case, for compressed blocks of 0 - if ((history < 128) && (output_count + 1 < output_size)) - { - int32_t block_size; - - sign_modifier = 1; - - k = count_leading_zeros(history) + ((history + 16) / 64) - 24; - - // note: block_size is always 16bit - block_size = entropy_decode_value(alac, 16, k) & rice_kmodifier_mask; - - // got block_size 0s - if (block_size > 0) - { - memset(&output_buffer[output_count + 1], 0, - block_size * sizeof(*output_buffer)); - output_count += block_size; - } - - if (block_size > 0xFFFF) - sign_modifier = 0; - - history = 0; - } - } -} - -#define SIGN_EXTENDED32(val, bits) ((val << (32 - bits)) >> (32 - bits)) - -#define SIGN_ONLY(v) \ - ((v < 0) ? (-1) : \ - ((v > 0) ? (1) : \ - (0))) - -static void predictor_decompress_fir_adapt(int32_t *error_buffer, - int32_t *buffer_out, - int output_size, - int readsamplesize, - int16_t *predictor_coef_table, - int predictor_coef_num, - int predictor_quantitization) ICODE_ATTR_ALAC; -static void predictor_decompress_fir_adapt(int32_t *error_buffer, - int32_t *buffer_out, - int output_size, - int readsamplesize, - int16_t *predictor_coef_table, - int predictor_coef_num, - int predictor_quantitization) -{ - int i; - - /* first sample always copies */ - *buffer_out = *error_buffer; - - if (!predictor_coef_num) - { - if (output_size <= 1) return; - memcpy(buffer_out+1, error_buffer+1, (output_size-1) * 4); - return; - } - - if (predictor_coef_num == 0x1f) /* 11111 - max value of predictor_coef_num */ - { /* second-best case scenario for fir decompression, - * error describes a small difference from the previous sample only - */ - if (output_size <= 1) return; - for (i = 0; i < output_size - 1; i++) - { - int32_t prev_value; - int32_t error_value; - - prev_value = buffer_out[i]; - error_value = error_buffer[i+1]; - buffer_out[i+1] = SIGN_EXTENDED32((prev_value + error_value), readsamplesize); - } - return; - } - - /* read warm-up samples */ - if (predictor_coef_num > 0) - { - int i; - for (i = 0; i < predictor_coef_num; i++) - { - int32_t val; - - val = buffer_out[i] + error_buffer[i+1]; - - val = SIGN_EXTENDED32(val, readsamplesize); - - buffer_out[i+1] = val; - } - } - - /* 4 and 8 are very common cases (the only ones i've seen). - - The following code is an initial attempt to unroll and optimise - these two cases by the Rockbox project. More work is needed. - */ - - /* optimised case: 4 */ - if (predictor_coef_num == 4) - { - for (i = 4 + 1; i < output_size; i++) - { - int sum = 0; - int outval; - int error_val = error_buffer[i]; - - sum = (buffer_out[4] - buffer_out[0]) * predictor_coef_table[0] - + (buffer_out[3] - buffer_out[0]) * predictor_coef_table[1] - + (buffer_out[2] - buffer_out[0]) * predictor_coef_table[2] - + (buffer_out[1] - buffer_out[0]) * predictor_coef_table[3]; - - outval = (1 << (predictor_quantitization-1)) + sum; - outval = outval >> predictor_quantitization; - outval = outval + buffer_out[0] + error_val; - outval = SIGN_EXTENDED32(outval, readsamplesize); - - buffer_out[4+1] = outval; - - if (error_val > 0) - { - int predictor_num = 4 - 1; - - while (predictor_num >= 0 && error_val > 0) - { - int val = buffer_out[0] - buffer_out[4 - predictor_num]; - - if (val!=0) { - if (val < 0) { - predictor_coef_table[predictor_num]++; - val=-val; - } else { - predictor_coef_table[predictor_num]--; - } - error_val -= ((val >> predictor_quantitization) * (4 - predictor_num)); - } - predictor_num--; - } - } - else if (error_val < 0) - { - int predictor_num = 4 - 1; - - while (predictor_num >= 0 && error_val < 0) - { - int val = buffer_out[0] - buffer_out[4 - predictor_num]; - - if (val != 0) { - if (val > 0) { - predictor_coef_table[predictor_num]++; - val=-val; /* neg value */ - } else { - predictor_coef_table[predictor_num]--; - } - error_val -= ((val >> predictor_quantitization) * (4 - predictor_num)); - } - predictor_num--; - } - } - - buffer_out++; - } - return; - } - - /* optimised case: 8 */ - if (predictor_coef_num == 8) - { - for (i = 8 + 1; - i < output_size; - i++) - { - int sum; - int outval; - int error_val = error_buffer[i]; - - sum = (buffer_out[8] - buffer_out[0]) * predictor_coef_table[0] - + (buffer_out[7] - buffer_out[0]) * predictor_coef_table[1] - + (buffer_out[6] - buffer_out[0]) * predictor_coef_table[2] - + (buffer_out[5] - buffer_out[0]) * predictor_coef_table[3] - + (buffer_out[4] - buffer_out[0]) * predictor_coef_table[4] - + (buffer_out[3] - buffer_out[0]) * predictor_coef_table[5] - + (buffer_out[2] - buffer_out[0]) * predictor_coef_table[6] - + (buffer_out[1] - buffer_out[0]) * predictor_coef_table[7]; - - outval = (1 << (predictor_quantitization-1)) + sum; - outval = outval >> predictor_quantitization; - outval = outval + buffer_out[0] + error_val; - outval = SIGN_EXTENDED32(outval, readsamplesize); - - buffer_out[8+1] = outval; - - if (error_val > 0) - { - int predictor_num = 8 - 1; - - while (predictor_num >= 0 && error_val > 0) - { - int val = buffer_out[0] - buffer_out[8 - predictor_num]; - - if (val!=0) { - if (val < 0) { - predictor_coef_table[predictor_num]++; - val=-val; - } else { - predictor_coef_table[predictor_num]--; - } - error_val -= ((val >> predictor_quantitization) * (8 - predictor_num)); - } - predictor_num--; - } - } - else if (error_val < 0) - { - int predictor_num = 8 - 1; - - while (predictor_num >= 0 && error_val < 0) - { - int val = buffer_out[0] - buffer_out[8 - predictor_num]; - if (val != 0) { - if (val > 0) { - predictor_coef_table[predictor_num]++; - val=-val; /* neg value */ - } else { - predictor_coef_table[predictor_num]--; - } - error_val -= ((val >> predictor_quantitization) * (8 - predictor_num)); - } - predictor_num--; - } - } - - buffer_out++; - } - return; - } - - /* general case */ - if (predictor_coef_num > 0) - { - for (i = predictor_coef_num + 1; - i < output_size; - i++) - { - int j; - int sum = 0; - int outval; - int error_val = error_buffer[i]; - - for (j = 0; j < predictor_coef_num; j++) - { - sum += (buffer_out[predictor_coef_num-j] - buffer_out[0]) * - predictor_coef_table[j]; - } - - outval = (1 << (predictor_quantitization-1)) + sum; - outval = outval >> predictor_quantitization; - outval = outval + buffer_out[0] + error_val; - outval = SIGN_EXTENDED32(outval, readsamplesize); - - buffer_out[predictor_coef_num+1] = outval; - - if (error_val > 0) - { - int predictor_num = predictor_coef_num - 1; - - while (predictor_num >= 0 && error_val > 0) - { - int val = buffer_out[0] - buffer_out[predictor_coef_num - predictor_num]; - int sign = SIGN_ONLY(val); - - predictor_coef_table[predictor_num] -= sign; - - val *= sign; /* absolute value */ - - error_val -= ((val >> predictor_quantitization) * - (predictor_coef_num - predictor_num)); - - predictor_num--; - } - } - else if (error_val < 0) - { - int predictor_num = predictor_coef_num - 1; - - while (predictor_num >= 0 && error_val < 0) - { - int val = buffer_out[0] - buffer_out[predictor_coef_num - predictor_num]; - int sign = - SIGN_ONLY(val); - - predictor_coef_table[predictor_num] -= sign; - - val *= sign; /* neg value */ - - error_val -= ((val >> predictor_quantitization) * - (predictor_coef_num - predictor_num)); - - predictor_num--; - } - } - - buffer_out++; - } - } -} - -static void deinterlace_16(int32_t* buffer0, - int32_t* buffer1, - int numsamples, - uint8_t interlacing_shift, - uint8_t interlacing_leftweight) ICODE_ATTR_ALAC; -static void deinterlace_16(int32_t* buffer0, - int32_t* buffer1, - int numsamples, - uint8_t interlacing_shift, - uint8_t interlacing_leftweight) -{ - int i; - if (numsamples <= 0) return; - - /* weighted interlacing */ - if (interlacing_leftweight) - { - for (i = 0; i < numsamples; i++) - { - int32_t difference, midright; - - midright = buffer0[i]; - difference = buffer1[i]; - - buffer0[i] = ((midright - ((difference * interlacing_leftweight) - >> interlacing_shift)) + difference) << SCALE16; - buffer1[i] = (midright - ((difference * interlacing_leftweight) - >> interlacing_shift)) << SCALE16; - } - - return; - } - - /* otherwise basic interlacing took place */ - for (i = 0; i < numsamples; i++) - { - buffer0[i] = buffer0[i] << SCALE16; - buffer1[i] = buffer1[i] << SCALE16; - } -} - -static void deinterlace_24(int32_t *buffer0, int32_t *buffer1, - int uncompressed_bytes, - int32_t *uncompressed_bytes_buffer0, - int32_t *uncompressed_bytes_buffer1, - int numsamples, - uint8_t interlacing_shift, - uint8_t interlacing_leftweight) ICODE_ATTR_ALAC; -static void deinterlace_24(int32_t *buffer0, int32_t *buffer1, - int uncompressed_bytes, - int32_t *uncompressed_bytes_buffer0, - int32_t *uncompressed_bytes_buffer1, - int numsamples, - uint8_t interlacing_shift, - uint8_t interlacing_leftweight) -{ - int i; - if (numsamples <= 0) return; - - /* weighted interlacing */ - if (interlacing_leftweight) - { - for (i = 0; i < numsamples; i++) - { - int32_t difference, midright; - - midright = buffer0[i]; - difference = buffer1[i]; - - buffer0[i] = ((midright - ((difference * interlacing_leftweight) - >> interlacing_shift)) + difference) << SCALE24; - buffer1[i] = (midright - ((difference * interlacing_leftweight) - >> interlacing_shift)) << SCALE24; - - if (uncompressed_bytes) - { - uint32_t mask = ~(0xFFFFFFFF << (uncompressed_bytes * 8)); - buffer0[i] <<= (uncompressed_bytes * 8); - buffer1[i] <<= (uncompressed_bytes * 8); - - buffer0[i] |= uncompressed_bytes_buffer0[i] & mask; - buffer1[i] |= uncompressed_bytes_buffer1[i] & mask; - } - - } - - return; - } - - /* otherwise basic interlacing took place */ - for (i = 0; i < numsamples; i++) - { - if (uncompressed_bytes) - { - uint32_t mask = ~(0xFFFFFFFF << (uncompressed_bytes * 8)); - buffer0[i] <<= (uncompressed_bytes * 8); - buffer1[i] <<= (uncompressed_bytes * 8); - - buffer0[i] |= uncompressed_bytes_buffer0[i] & mask; - buffer1[i] |= uncompressed_bytes_buffer1[i] & mask; - } - - buffer0[i] = buffer0[i] << SCALE24; - buffer1[i] = buffer1[i] << SCALE24; - } - -} - -static inline int decode_frame_mono( - alac_file *alac, - int32_t outputbuffer[ALAC_MAX_CHANNELS][ALAC_BLOCKSIZE], - void (*yield)(void)) -{ - int hassize; - int isnotcompressed; - int readsamplesize; - int infosamplesize = alac->setinfo_sample_size; - int outputsamples = alac->setinfo_max_samples_per_frame; - - int uncompressed_bytes; - int ricemodifier; - - - /* 2^result = something to do with output waiting. - * perhaps matters if we read > 1 frame in a pass? - */ - readbits(alac, 4); - - readbits(alac, 12); /* unknown, skip 12 bits */ - - hassize = readbits(alac, 1); /* the output sample size is stored soon */ - - /* number of bytes in the (compressed) stream that are not compressed */ - uncompressed_bytes = readbits(alac, 2); - - isnotcompressed = readbits(alac, 1); /* whether the frame is compressed */ - - if (hassize) - { - /* now read the number of samples, - * as a 32bit integer */ - outputsamples = readbits(alac, 32); - } - - readsamplesize = infosamplesize - (uncompressed_bytes * 8); - - if (!isnotcompressed) - { /* so it is compressed */ - int predictor_coef_num; - int prediction_type; - int prediction_quantitization; - int i; - - /* skip 16 bits, not sure what they are. seem to be used in - * two channel case */ - readbits(alac, 8); - readbits(alac, 8); - - prediction_type = readbits(alac, 4); - prediction_quantitization = readbits(alac, 4); - - ricemodifier = readbits(alac, 3); - predictor_coef_num = readbits(alac, 5); - - /* read the predictor table */ - for (i = 0; i < predictor_coef_num; i++) - { - predictor_coef_table[i] = (int16_t)readbits(alac, 16); - } - - if (uncompressed_bytes) - { - int i; - for (i = 0; i < outputsamples; i++) - { - outputbuffer[0][i] = readbits(alac, uncompressed_bytes * 8); - outputbuffer[1][i] = outputbuffer[0][i]; - } - } - - yield(); - - entropy_rice_decode(alac, - outputbuffer[0], - outputsamples, - readsamplesize, - alac->setinfo_rice_initialhistory, - alac->setinfo_rice_kmodifier, - ricemodifier * alac->setinfo_rice_historymult / 4, - (1 << alac->setinfo_rice_kmodifier) - 1); - - yield(); - - if (prediction_type == 0) - { /* adaptive fir */ - predictor_decompress_fir_adapt(outputbuffer[0], - outputbuffer[0], - outputsamples, - readsamplesize, - predictor_coef_table, - predictor_coef_num, - prediction_quantitization); - } - else - { - //fprintf(stderr, "FIXME: unhandled predicition type: %i\n", prediction_type); - /* i think the only other prediction type (or perhaps this is just a - * boolean?) runs adaptive fir twice.. like: - * predictor_decompress_fir_adapt(predictor_error, tempout, ...) - * predictor_decompress_fir_adapt(predictor_error, outputsamples ...) - * little strange.. - */ - } - - } - else - { /* not compressed, easy case */ - if (infosamplesize <= 16) - { - int i; - for (i = 0; i < outputsamples; i++) - { - int32_t audiobits = readbits(alac, infosamplesize); - - audiobits = SIGN_EXTENDED32(audiobits, infosamplesize); - - outputbuffer[0][i] = audiobits; - } - } - else - { - int i; - for (i = 0; i < outputsamples; i++) - { - int32_t audiobits; - - audiobits = readbits(alac, 16); - /* special case of sign extension.. - * as we'll be ORing the low 16bits into this */ - audiobits = audiobits << (infosamplesize - 16); - audiobits |= readbits(alac, infosamplesize - 16); - audiobits = SIGNEXTEND24(audiobits); - - outputbuffer[0][i] = audiobits; - } - } - uncompressed_bytes = 0; // always 0 for uncompressed - } - - yield(); - - switch(infosamplesize) - { - case 16: - { - int i; - for (i = 0; i < outputsamples; i++) - { - /* Output mono data as stereo */ - outputbuffer[0][i] = outputbuffer[0][i] << SCALE16; - outputbuffer[1][i] = outputbuffer[0][i]; - } - break; - } - case 24: - { - int i; - for (i = 0; i < outputsamples; i++) - { - int32_t sample = outputbuffer[0][i]; - - if (uncompressed_bytes) - { - uint32_t mask; - sample = sample << (uncompressed_bytes * 8); - mask = ~(0xFFFFFFFF << (uncompressed_bytes * 8)); - sample |= outputbuffer[0][i] & mask; - } - - outputbuffer[0][i] = sample << SCALE24; - outputbuffer[1][i] = outputbuffer[0][i]; - } - break; - } - case 20: - case 32: - //fprintf(stderr, "FIXME: unimplemented sample size %i\n", infosamplesize); - break; - default: - break; - } - - return outputsamples; -} - -static inline int decode_frame_stereo( - alac_file *alac, - int32_t outputbuffer[ALAC_MAX_CHANNELS][ALAC_BLOCKSIZE], - void (*yield)(void)) -{ - int hassize; - int isnotcompressed; - int readsamplesize; - int infosamplesize = alac->setinfo_sample_size; - int outputsamples = alac->setinfo_max_samples_per_frame; - int uncompressed_bytes; - - uint8_t interlacing_shift; - uint8_t interlacing_leftweight; - - /* 2^result = something to do with output waiting. - * perhaps matters if we read > 1 frame in a pass? - */ - readbits(alac, 4); - - readbits(alac, 12); /* unknown, skip 12 bits */ - - hassize = readbits(alac, 1); /* the output sample size is stored soon */ - - /* the number of bytes in the (compressed) stream that are not compressed */ - uncompressed_bytes = readbits(alac, 2); - - isnotcompressed = readbits(alac, 1); /* whether the frame is compressed */ - - if (hassize) - { - /* now read the number of samples, - * as a 32bit integer */ - outputsamples = readbits(alac, 32); - } - - readsamplesize = infosamplesize - (uncompressed_bytes * 8) + 1; - - yield(); - if (!isnotcompressed) - { /* compressed */ - int predictor_coef_num_a; - int prediction_type_a; - int prediction_quantitization_a; - int ricemodifier_a; - - int predictor_coef_num_b; - int prediction_type_b; - int prediction_quantitization_b; - int ricemodifier_b; - - int i; - - interlacing_shift = readbits(alac, 8); - interlacing_leftweight = readbits(alac, 8); - - /******** channel 1 ***********/ - prediction_type_a = readbits(alac, 4); - prediction_quantitization_a = readbits(alac, 4); - - ricemodifier_a = readbits(alac, 3); - predictor_coef_num_a = readbits(alac, 5); - - /* read the predictor table */ - for (i = 0; i < predictor_coef_num_a; i++) - { - predictor_coef_table_a[i] = (int16_t)readbits(alac, 16); - } - - /******** channel 2 *********/ - prediction_type_b = readbits(alac, 4); - prediction_quantitization_b = readbits(alac, 4); - - ricemodifier_b = readbits(alac, 3); - predictor_coef_num_b = readbits(alac, 5); - - /* read the predictor table */ - for (i = 0; i < predictor_coef_num_b; i++) - { - predictor_coef_table_b[i] = (int16_t)readbits(alac, 16); - } - - /*********************/ - if (uncompressed_bytes) - { /* see mono case */ - int i; - for (i = 0; i < outputsamples; i++) - { - outputbuffer[0][i] = readbits(alac, uncompressed_bytes * 8); - outputbuffer[1][i] = readbits(alac, uncompressed_bytes * 8); - } - } - - yield(); - /* channel 1 */ - entropy_rice_decode(alac, - outputbuffer[0], - outputsamples, - readsamplesize, - alac->setinfo_rice_initialhistory, - alac->setinfo_rice_kmodifier, - ricemodifier_a * alac->setinfo_rice_historymult / 4, - (1 << alac->setinfo_rice_kmodifier) - 1); - - yield(); - if (prediction_type_a == 0) - { /* adaptive fir */ - predictor_decompress_fir_adapt(outputbuffer[0], - outputbuffer[0], - outputsamples, - readsamplesize, - predictor_coef_table_a, - predictor_coef_num_a, - prediction_quantitization_a); - } - else - { /* see mono case */ - //fprintf(stderr, "FIXME: unhandled predicition type: %i\n", prediction_type_a); - } - - yield(); - - /* channel 2 */ - entropy_rice_decode(alac, - outputbuffer[1], - outputsamples, - readsamplesize, - alac->setinfo_rice_initialhistory, - alac->setinfo_rice_kmodifier, - ricemodifier_b * alac->setinfo_rice_historymult / 4, - (1 << alac->setinfo_rice_kmodifier) - 1); - - yield(); - if (prediction_type_b == 0) - { /* adaptive fir */ - predictor_decompress_fir_adapt(outputbuffer[1], - outputbuffer[1], - outputsamples, - readsamplesize, - predictor_coef_table_b, - predictor_coef_num_b, - prediction_quantitization_b); - } - else - { - //fprintf(stderr, "FIXME: unhandled predicition type: %i\n", prediction_type_b); - } - } - else - { /* not compressed, easy case */ - if (infosamplesize <= 16) - { - int i; - for (i = 0; i < outputsamples; i++) - { - int32_t audiobits_a, audiobits_b; - - audiobits_a = readbits(alac, infosamplesize); - audiobits_b = readbits(alac, infosamplesize); - - audiobits_a = SIGN_EXTENDED32(audiobits_a, infosamplesize); - audiobits_b = SIGN_EXTENDED32(audiobits_b, infosamplesize); - - outputbuffer[0][i] = audiobits_a; - outputbuffer[1][i] = audiobits_b; - } - } - else - { - int i; - for (i = 0; i < outputsamples; i++) - { - int32_t audiobits_a, audiobits_b; - - audiobits_a = readbits(alac, 16); - audiobits_a = audiobits_a << (infosamplesize - 16); - audiobits_a |= readbits(alac, infosamplesize - 16); - audiobits_a = SIGNEXTEND24(audiobits_a); - - audiobits_b = readbits(alac, 16); - audiobits_b = audiobits_b << (infosamplesize - 16); - audiobits_b |= readbits(alac, infosamplesize - 16); - audiobits_b = SIGNEXTEND24(audiobits_b); - - outputbuffer[0][i] = audiobits_a; - outputbuffer[1][i] = audiobits_b; - } - } - uncompressed_bytes = 0; // always 0 for uncompressed - interlacing_shift = 0; - interlacing_leftweight = 0; - } - - yield(); - - switch(infosamplesize) - { - case 16: - { - deinterlace_16(outputbuffer[0], - outputbuffer[1], - outputsamples, - interlacing_shift, - interlacing_leftweight); - break; - } - case 24: - { - deinterlace_24(outputbuffer[0], - outputbuffer[1], - uncompressed_bytes, - outputbuffer[0], - outputbuffer[1], - outputsamples, - interlacing_shift, - interlacing_leftweight); - break; - } - case 20: - case 32: - //fprintf(stderr, "FIXME: unimplemented sample size %i\n", infosamplesize); - break; - default: - break; - } - return outputsamples; -} - -int alac_decode_frame(alac_file *alac, - unsigned char *inbuffer, - int32_t outputbuffer[ALAC_MAX_CHANNELS][ALAC_BLOCKSIZE], - void (*yield)(void)) -{ - int channels; - int outputsamples; - unsigned char *input_buffer_start; - - /* setup the stream */ - alac->input_buffer = inbuffer; - alac->input_buffer_bitaccumulator = 0; - - /* save to gather byte consumption */ - input_buffer_start = alac->input_buffer; - - channels = readbits(alac, 3); - - /* TODO: The mono and stereo functions should be combined. */ - switch(channels) - { - case 0: /* 1 channel */ - outputsamples=decode_frame_mono(alac,outputbuffer,yield); - break; - case 1: /* 2 channels */ - outputsamples=decode_frame_stereo(alac,outputbuffer,yield); - break; - default: /* Unsupported */ - return -1; - } - - /* calculate consumed bytes */ - alac->bytes_consumed = (int)(alac->input_buffer - input_buffer_start); - alac->bytes_consumed += (alac->input_buffer_bitaccumulator>5) ? 2 : 1; - - return outputsamples; -} - -/* rockbox: not used -void create_alac(int samplesize, int numchannels, alac_file* alac) -{ - alac->samplesize = samplesize; - alac->numchannels = numchannels; - alac->bytespersample = (samplesize / 8) * numchannels; -} */ diff --git a/apps/codecs/libalac/decomp.h b/apps/codecs/libalac/decomp.h deleted file mode 100644 index 21dabd86b0..0000000000 --- a/apps/codecs/libalac/decomp.h +++ /dev/null @@ -1,54 +0,0 @@ -#ifndef __ALAC__DECOMP_H -#define __ALAC__DECOMP_H - -#ifndef ICODE_ATTR_ALAC -#define ICODE_ATTR_ALAC ICODE_ATTR -#endif - -/* Always output samples shifted to 28 bits + sign*/ -#define ALAC_OUTPUT_DEPTH 29 -#define SCALE16 (ALAC_OUTPUT_DEPTH - 16) -#define SCALE24 (ALAC_OUTPUT_DEPTH - 24) -#define ALAC_MAX_CHANNELS 2 -#define ALAC_BLOCKSIZE 4096 /* Number of samples per channel per block */ - -typedef struct -{ - unsigned char *input_buffer; - int input_buffer_bitaccumulator; /* used so we can do arbitary - bit reads */ - - /* rockbox: not used - int samplesize; - int numchannels; - int bytespersample; */ - - int bytes_consumed; - - /* stuff from setinfo */ - uint32_t setinfo_max_samples_per_frame; /* 0x1000 = 4096 */ /* max samples per frame? */ - uint8_t setinfo_7a; /* 0x00 */ - uint8_t setinfo_sample_size; /* 0x10 */ - uint8_t setinfo_rice_historymult; /* 0x28 */ - uint8_t setinfo_rice_initialhistory; /* 0x0a */ - uint8_t setinfo_rice_kmodifier; /* 0x0e */ - uint8_t setinfo_7f; /* 0x02 */ - uint16_t setinfo_80; /* 0x00ff */ - uint32_t setinfo_82; /* 0x000020e7 */ - uint32_t setinfo_86; /* 0x00069fe4 */ - uint32_t setinfo_8a_rate; /* 0x0000ac44 */ - /* end setinfo stuff */ -} alac_file; - -/* rockbox: not used -void create_alac(int samplesize, int numchannels, alac_file* alac) - ICODE_ATTR_ALAC; */ - -int alac_decode_frame(alac_file *alac, - unsigned char *inbuffer, - int32_t outputbuffer[ALAC_MAX_CHANNELS][ALAC_BLOCKSIZE], - void (*yield)(void)) ICODE_ATTR_ALAC; -void alac_set_info(alac_file *alac, char *inputbuffer) ICODE_ATTR_ALAC; - -#endif /* __ALAC__DECOMP_H */ - diff --git a/apps/codecs/libalac/libalac.make b/apps/codecs/libalac/libalac.make deleted file mode 100644 index a0300554c3..0000000000 --- a/apps/codecs/libalac/libalac.make +++ /dev/null @@ -1,18 +0,0 @@ -# __________ __ ___. -# Open \______ \ ____ ____ | | _\_ |__ _______ ___ -# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / -# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < -# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ -# \/ \/ \/ \/ \/ -# $Id$ -# - -# libalac -ALACLIB := $(CODECDIR)/libalac.a -ALACLIB_SRC := $(call preprocess, $(APPSDIR)/codecs/libalac/SOURCES) -ALACLIB_OBJ := $(call c2obj, $(ALACLIB_SRC)) -OTHER_SRC += $(ALACLIB_SRC) - -$(ALACLIB): $(ALACLIB_OBJ) - $(SILENT)$(shell rm -f $@) - $(call PRINTS,AR $(@F))$(AR) rcs $@ $^ >/dev/null diff --git a/apps/codecs/libasap/CREDITS b/apps/codecs/libasap/CREDITS deleted file mode 100644 index 387cbb6266..0000000000 --- a/apps/codecs/libasap/CREDITS +++ /dev/null @@ -1,58 +0,0 @@ -Authors -------- - -Piotr Fusik {asapwww!}:: -Creator and main developer. - -Atari800 Emulator Developers {asapwww!(http://atari800.sourceforge.net)}:: -6502 and POKEY emulation used in 0.x.y versions of ASAP. - -Zdenek Eisenhammer {asapwww!}:: -Testing. - -Henryk Karpowicz {asapwww!}:: -CMC routine modified for the CM3 format. - -Maciek Konecki {asapwww!}:: -Porting to C#. - -Marek Konopka {asapwww!}:: -6502 routine for playing DLT. - -Marcin Lewandowski {asapwww!}:: -6502 routines for playing CMC, MPT, TMC and TM2. - -Adrian Matoga {asapwww!}:: -COVOX information and test files. Testing. - -Perry McFarlane {asapwww!}:: -POKEY reverse-engineering. - -Kostas Nakos {asapwww!}:: -Windows CE testing. - -Mariusz Rozwadowski {asapwww!}:: -Suggested CMS, CM3 and DLT format support. - -Slawomir Sledz {asapwww!}:: -Testing. - -David Spilka:: -6502 routine for playing CMS. - -Radek Sterba {asapwww!}:: -6502 routine for playing RMT. -Testing. - -Lukasz Sychowicz {asapwww!}:: -Windows icons. -Testing. - -Pawel Szewczyk {asapwww!}:: -Windows setup graphics. - -Michal Szpilowski {asapwww!}:: -Testing. - -Grzegorz Zyla {asapwww!}:: -XBMC plugin testing. diff --git a/apps/codecs/libasap/README b/apps/codecs/libasap/README deleted file mode 100644 index d4fbfe6297..0000000000 --- a/apps/codecs/libasap/README +++ /dev/null @@ -1,148 +0,0 @@ -ASAP - Another Slight Atari Player -================================== - -// This file is in AsciiDoc format. It is converted to README.html. -:Compact-Option: - -ifdef::asapwww[] -http://sourceforge.net/projects/asap/files/asap/[Download] | -http://asap.git.sourceforge.net/git/gitweb.cgi?p=asap/asap;a=summary[Browse source code (Git)] | -http://sourceforge.net/scm/?type=git&group_id=154391[Get latest source code (Git)] | -http://sourceforge.net/projects/asap/[SourceForge project page] -endif::asapwww[] - -ASAP is a player of http://en.wikipedia.org/wiki/Atari_8-bit_family[8-bit Atari] -music for modern computers. -It emulates the http://en.wikipedia.org/wiki/POKEY[POKEY sound chip] -and the http://en.wikipedia.org/wiki/6502[6502 processor]. -The project was initially based on the routines from the -http://atari800.sourceforge.net/[Atari800 emulator], -but the current version has a completely new original emulation core. - -ASAP includes the following programs: - -- asapconv - portable command-line converter {asapwin=} -- WASAP - tiny player for Windows {asapwin=}{asapwince=} -- plugin for http://koti.welho.com/hylinen/apollo/[Apollo] {asapwin=} -- plugin for http://audacious-media-player.org/[Audacious] -- plugin for http://foobar2000.org/[foobar2000] {asapwin=} -- plugin for http://hp.vector.co.jp/authors/VA032810/[GSPlayer] {asapwin=}{asapwince=} -- plugin for http://moc.daper.net/[MOC] -- plugin for http://www.winamp.com/[Winamp] {asapwin=} -- plugin for http://www.microsoft.com/windows/windowsmedia/player/[Windows Media Player] {asapwin=} -- plugin for http://xbmc.org/[XBMC] {asapwin=} -- plugin for http://xmms.org/[XMMS] -- plugin for http://www.un4seen.com/xmplay.html[XMPlay] {asapwin=} -- add-on for http://www.un4seen.com/bass.html[BASS] (for http://www.aimp.ru/[AIMP] and http://www.un4seen.com/bass_showcase.php[other players]) {asapwin=} -- POKEY sound emulation DLL for http://raster.infos.cz/atari/rmt/rmt.htm[Raster Music Tracker] {asapwin=} -- Windows Explorer extension - shows metadata {asapwin=} -- Java version of ASAP2WAV - command-line converter to WAV files {asapjava=} -- Java applet - for web pages {asapjava=}{asapwww?(see link:applet.html[online demo])} -- Java midlet - for mobile devices {asapjava=} -- C# version of ASAP2WAV -- JavaScript version of ASAP2WAV running in http://en.wikipedia.org/wiki/Windows_Script_Host[Windows Script Host], https://developer.mozilla.org/en/Rhino_Shell[Rhino Shell], http://code.google.com/p/v8/[V8 Shell], http://en.wikipedia.org/wiki/JScript_.NET[JScript .NET] and http://en.wikipedia.org/wiki/JaegerMonkey[JaegerMonkey] {asapjavascript=} -- experimental JavaScript version of ASAP2WAV running in Firefox {asapjavascript=} -- Flash player - for web pages {asapflash=}{asapwww?(see link:flash.html[online demo])} -- asapplay - simple command-line player in C# -- http://www.silverlight.net/[Silverlight] player - for web pages {asapwww?(see link:silverlight.html[online demo])} -- AndroidASAP - for mobile devices - -{asapports}The summary of the differences between the above versions is in link:PORTS.xml[this table]. - -There are other projects which use ASAP: - -- http://mmsap.sourceforge.net/[mmSAP 2] - standalone player for GNU/Linux with GTK+ user interface -- http://www.rockbox.org/[Rockbox] - open source firmware for MP3 players - - -Input file formats ------------------- - -ASAP supports the following file formats (determined by the filename extension): - -SAP (Slight Atari Player):: -The format designed for playing 8-bit Atari music on modern computers. -All other formats can be converted to SAP. -http://asma.atari.org/[Atari SAP Music Archive (ASMA)] -is a single big collection of SAP files. - -CMC (Chaos Music Composer):: -Atari music editor from early 1990s. - -CM3 (CMC "3/4"):: -CMC with modified pattern length. - -CMR (CMC "Rzog"):: -CMC with modified bass sounds. - -CMS (Stereo Double CMC):: -Stereo CMC. - -DMC (DoublePlay CMC):: -CMC with 6502 routine executed at double rate of the original CMC. - -DLT (Delta Music Composer):: -Atari music editor from 1990s. - -MPT (Music ProTracker):: -Atari music editor from 1990s. - -MPD (MPT DoublePlay):: -MPT with 6502 routine executed at double rate of the original MPT. - -RMT (http://raster.infos.cz/atari/rmt/rmt.htm[Raster Music Tracker]):: -Modern Atari music editor running on Windows. - -TMC, TM8 (http://jaskier.atari8.info/[Theta Music Composer] 1.x):: -Atari music editor from late 1990s. -The two file extensions are treated identically and played in stereo. -TM8 means it's stereo (8-channel) music while TMC can be either mono or stereo. - -TM2 (http://jaskier.atari8.info/[Theta Music Composer] 2.x):: -Modern Atari music editor. - - -ifdef::asapsrc[] -include::INSTALL[] -endif::asapsrc[] - -ifdef::asapflash[] -include::flash/USAGE[] -endif::asapflash[] - -ifdef::asapjava[] -include::java/USAGE[] -endif::asapjava[] - -ifdef::asapjavascript[] -include::javascript/USAGE[] -endif::asapjavascript[] - -ifdef::asapwin[] -include::win32/USAGE[] -endif::asapwin[] - -ifdef::asapwince[] -include::win32/wince/USAGE[] -endif::asapwince[] - -include::NEWS[] - -include::CREDITS[] - - -Feedback --------- - -If you are interested in the ASAP project, please subscribe its -https://lists.sourceforge.net/lists/listinfo/asap-users[mailing list]. -This list is for users and developers. -Once you subscribe, you can post comments, ideas and questions about ASAP. -They will be answered ASAP. ;-) - -Use http://sourceforge.net/tracker/?group_id=154391[tracker] -to submit bug reports, feature requests and small code patches. - -ifdef::asapwww[] -image::http://sflogo.sourceforge.net/sflogo.php?group_id=154391&type=13["Get ASAP - Another Slight Atari Player at SourceForge.net. Fast, secure and Free Open Source software downloads",width=120,height=30,link="http://sourceforge.net/projects/asap/"] -endif::asapwww[] diff --git a/apps/codecs/libasap/README.rockbox b/apps/codecs/libasap/README.rockbox deleted file mode 100644 index 62184822d4..0000000000 --- a/apps/codecs/libasap/README.rockbox +++ /dev/null @@ -1,22 +0,0 @@ -Library: asap-2.1.2 -Imported: 2010-02-02 by Dominik Wenger -Updated: 2010-08-11 by Dominik Wenger - -This directory contains a local version of asap (http://asap.sourceforge.net/) for decoding Atari 8bit .sap -audio streams. - -LICENSING INFORMATION - -Asap is available under the terms of the GPL v2 or later -license, which is both an open source and free software license. -The Licence is the same as the rest of Rockbox. - - -IMPORT DETAILS - -The .[ch] files in apps/codec/libasap are copied from ASAP. - -players.h (contains binarys of players) was generated and copied -into Rockbox. - - diff --git a/apps/codecs/libasap/SOURCES b/apps/codecs/libasap/SOURCES deleted file mode 100644 index 0d1f1f46fa..0000000000 --- a/apps/codecs/libasap/SOURCES +++ /dev/null @@ -1,3 +0,0 @@ -acpu.c -asap.c -apokeysnd.c diff --git a/apps/codecs/libasap/acpu.c b/apps/codecs/libasap/acpu.c deleted file mode 100644 index 0fd5988b83..0000000000 --- a/apps/codecs/libasap/acpu.c +++ /dev/null @@ -1,1291 +0,0 @@ -/* - * acpu.c - another 6502 CPU emulator - * - * Copyright (C) 2007-2010 Piotr Fusik - * - * This file is part of ASAP (Another Slight Atari Player), - * see http://asap.sourceforge.net - * - * ASAP is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2 of the License, - * or (at your option) any later version. - * - * ASAP is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with ASAP; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/* How 6502 registers are stored in this emulator: - All variables are int, because modern processors (and Java bytecode) - tend to operate more effectively on these type than narrower ones. - pc is really an unsigned 16-bit integer. - a, x, y and s are unsigned 8-bit integers. - Flags are decomposed into three variables for improved performance. - c is either 0 or 1. - nz contains 6502 flags N and Z. - N is set if (nz >= 0x80). Z is set if ((nz & 0xff) == 0). - Usually nz is simply assigned the unsigned 8-bit operation result. - There are just a few operations (ADC in decimal mode, BIT, PLP and RTI) - where both N and Z may be set. In these cases, N is reflected by the 8th - (not 7th) bit of nz. - vdi contains rarely used flags V, D and I, as a combination - of V_FLAG, D_FLAG and I_FLAG. Other vdi bits are clear. - - "Unofficial" opcodes are not documented as "legal" 6502 opcodes. - Their operation has been reverse-engineered on Atari 800XL and Atari 65XE. - Unofficial opcodes are identical to C64's 6510, except for 0x8b and 0xab. - The operation of "unstable" opcodes is partially uncertain. - Explanation is welcome. - - Emulation of POKEY timer interrupts is included. - - Two preprocessor symbols may be used to strip the size of this emulator. - Define ACPU_NO_DECIMAL to disable emulation of the BCD mode. - Define ACPU_NO_UNOFFICIAL to disable emulation of unofficial opcodes. */ - -#include "asap_internal.h" - -CONST_ARRAY(int, opcode_cycles) -/* 0 1 2 3 4 5 6 7 8 9 A B C D E F */ - 7, 6, 2, 8, 3, 3, 5, 5, 3, 2, 2, 2, 4, 4, 6, 6, /* 0x */ - 2, 5, 2, 8, 4, 4, 6, 6, 2, 4, 2, 7, 4, 4, 7, 7, /* 1x */ - 6, 6, 2, 8, 3, 3, 5, 5, 4, 2, 2, 2, 4, 4, 6, 6, /* 2x */ - 2, 5, 2, 8, 4, 4, 6, 6, 2, 4, 2, 7, 4, 4, 7, 7, /* 3x */ - 6, 6, 2, 8, 3, 3, 5, 5, 3, 2, 2, 2, 3, 4, 6, 6, /* 4x */ - 2, 5, 2, 8, 4, 4, 6, 6, 2, 4, 2, 7, 4, 4, 7, 7, /* 5x */ - 6, 6, 2, 8, 3, 3, 5, 5, 4, 2, 2, 2, 5, 4, 6, 6, /* 6x */ - 2, 5, 2, 8, 4, 4, 6, 6, 2, 4, 2, 7, 4, 4, 7, 7, /* 7x */ - 2, 6, 2, 6, 3, 3, 3, 3, 2, 2, 2, 2, 4, 4, 4, 4, /* 8x */ - 2, 6, 2, 6, 4, 4, 4, 4, 2, 5, 2, 5, 5, 5, 5, 5, /* 9x */ - 2, 6, 2, 6, 3, 3, 3, 3, 2, 2, 2, 2, 4, 4, 4, 4, /* Ax */ - 2, 5, 2, 5, 4, 4, 4, 4, 2, 4, 2, 4, 4, 4, 4, 4, /* Bx */ - 2, 6, 2, 8, 3, 3, 5, 5, 2, 2, 2, 2, 4, 4, 6, 6, /* Cx */ - 2, 5, 2, 8, 4, 4, 6, 6, 2, 4, 2, 7, 4, 4, 7, 7, /* Dx */ - 2, 6, 2, 8, 3, 3, 5, 5, 2, 2, 2, 2, 4, 4, 6, 6, /* Ex */ - 2, 5, 2, 8, 4, 4, 6, 6, 2, 4, 2, 7, 4, 4, 7, 7 /* Fx */ -END_CONST_ARRAY; - -#ifdef ACPU_NO_DECIMAL - -#define DO_ADC \ - { \ - /* binary mode */ \ - V(int, tmp) = a + data + c; \ - vdi = (vdi & (D_FLAG | I_FLAG)) + (((~(data ^ a) & (a ^ tmp)) >> 1) & V_FLAG); \ - c = tmp >> 8; \ - nz = a = tmp & 0xff; \ - } - -#define DO_SBC \ - { \ - /* binary mode */ \ - V(int, tmp) = a - data - 1 + c; \ - vdi = (vdi & (D_FLAG | I_FLAG)) + ((((data ^ a) & (a ^ tmp)) >> 1) & V_FLAG); \ - c = (tmp >= 0) ? 1 : 0; \ - nz = a = tmp & 0xff; \ - } - -#else /* ACPU_NO_DECIMAL */ - -#define DO_ADC \ - { \ - V(int, tmp) = a + data + c; \ - nz = tmp & 0xff; \ - if ((vdi & D_FLAG) == 0) { \ - /* binary mode */ \ - vdi = (vdi & (D_FLAG | I_FLAG)) + (((~(data ^ a) & (a ^ tmp)) >> 1) & V_FLAG); \ - c = tmp >> 8; \ - a = nz; \ - } \ - else { \ - /* decimal mode */ \ - V(int, al) = (a & 0x0f) + (data & 0x0f) + c; \ - if (al >= 10) \ - tmp += (al < 26) ? 6 : -10; \ - nz = ((tmp & 0x80) << 1) + (nz != 0 ? 1 : 0); \ - vdi = (vdi & (D_FLAG | I_FLAG)) + (((~(data ^ a) & (a ^ tmp)) >> 1) & V_FLAG); \ - if (tmp >= 0xa0) { \ - c = 1; \ - a = (tmp + 0x60) & 0xff; \ - } \ - else { \ - c = 0; \ - a = tmp; \ - } \ - } \ - } - -#define DO_SBC \ - {\ - V(int, tmp) = a - data - 1 + c; \ - V(int, al) = (a & 0x0f) - (data & 0x0f) - 1 + c; \ - vdi = (vdi & (D_FLAG | I_FLAG)) + ((((data ^ a) & (a ^ tmp)) >> 1) & V_FLAG); \ - c = (tmp >= 0) ? 1 : 0; \ - nz = a = tmp & 0xff; \ - if ((vdi & D_FLAG) != 0) { \ - /* decimal mode */ \ - if (al < 0) \ - a += (al < -10) ? 10 : -6; \ - if (c == 0) \ - a = (a - 0x60) & 0xff; \ - } \ - } - -#endif /* ACPU_NO_DECIMAL */ - -#define zGetByte(addr) dGetByte((addr) & 0xff) - -#define PEEK dGetByte(pc) -#define FETCH dGetByte(pc++) - -#define ABSOLUTE addr = FETCH; addr += FETCH << 8 -#define ABSOLUTE_X addr = FETCH; addr = (addr + (FETCH << 8) + x) & 0xffff -#define ABSOLUTE_Y addr = FETCH; addr = (addr + (FETCH << 8) + y) & 0xffff -#define ZPAGE addr = FETCH -#define ZPAGE_X addr = (FETCH + x) & 0xff -#define ZPAGE_Y addr = (FETCH + y) & 0xff -#define INDIRECT_X addr = (FETCH + x) & 0xff; addr = dGetByte(addr) + (zGetByte(addr + 1) << 8) -#define INDIRECT_Y addr = FETCH; addr = (dGetByte(addr) + (zGetByte(addr + 1) << 8) + y) & 0xffff -#define NCYCLES_X if ((addr & 0xff) < x) ast _ cycle++ -#define NCYCLES_Y if ((addr & 0xff) < y) ast _ cycle++ - -#define PL(dest) s = (s + 1) & 0xff; dest = dGetByte(0x0100 + s) -#define PLP PL(vdi); nz = ((vdi & 0x80) << 1) + (~vdi & Z_FLAG); c = vdi & 1; vdi &= V_FLAG | D_FLAG | I_FLAG -#define PH(data) dPutByte(0x0100 + s, data); s = (s - 1) & 0xff -#define PHW(data) PH((data) >> 8); PH(TO_BYTE(data)) -#define PHP(bflag) PH(((nz | (nz >> 1)) & 0x80) + vdi + ((nz & 0xff) == 0 ? Z_FLAG : 0) + c + bflag) -#define PHPB0 PHP(0x20) /* push flags with B flag clear (NMI, IRQ) */ -#define PHPB1 PHP(0x30) /* push flags with B flag set (PHP, BRK) */ -#define PHPC PHW(pc) - -#define LDA nz = a = GetByte(addr) -#define LDA_ZP nz = a = dGetByte(addr) -#define LDX nz = x = GetByte(addr) -#define LDX_ZP nz = x = dGetByte(addr) -#define LDY nz = y = GetByte(addr) -#define LDY_ZP nz = y = dGetByte(addr) -#define LAX nz = x = a = GetByte(addr) -#define LAX_ZP nz = x = a = dGetByte(addr) -#define STA PutByte(addr, a) -#define STA_ZP dPutByte(addr, a) -#define STX PutByte(addr, x) -#define STX_ZP dPutByte(addr, x) -#define STY PutByte(addr, y) -#define STY_ZP dPutByte(addr, y) -#define SAX data = a & x; PutByte(addr, data) -#define SAX_ZP data = a & x; dPutByte(addr, data) -#define CMP nz = GetByte(addr); c = (a >= nz) ? 1 : 0; nz = (a - nz) & 0xff -#define CMP_ZP nz = dGetByte(addr); c = (a >= nz) ? 1 : 0; nz = (a - nz) & 0xff -#define CPX nz = GetByte(addr); c = (x >= nz) ? 1 : 0; nz = (x - nz) & 0xff -#define CPX_ZP nz = dGetByte(addr); c = (x >= nz) ? 1 : 0; nz = (x - nz) & 0xff -#define CPY nz = GetByte(addr); c = (y >= nz) ? 1 : 0; nz = (y - nz) & 0xff -#define CPY_ZP nz = dGetByte(addr); c = (y >= nz) ? 1 : 0; nz = (y - nz) & 0xff -#define AND nz = a &= GetByte(addr) -#define AND_ZP nz = a &= dGetByte(addr) -#define ORA nz = a |= GetByte(addr) -#define ORA_ZP nz = a |= dGetByte(addr) -#define EOR nz = a ^= GetByte(addr) -#define EOR_ZP nz = a ^= dGetByte(addr) -#define ADC data = GetByte(addr); DO_ADC -#define ADC_ZP data = dGetByte(addr); DO_ADC -#define SBC data = GetByte(addr); DO_SBC -#define SBC_ZP data = dGetByte(addr); DO_SBC - -#define ASL RMW_GetByte(nz, addr); c = nz >> 7; nz = (nz << 1) & 0xff; PutByte(addr, nz) -#define ASL_ZP nz = dGetByte(addr); c = nz >> 7; nz = (nz << 1) & 0xff; dPutByte(addr, nz) -#define ROL RMW_GetByte(nz, addr); nz = (nz << 1) + c; c = nz >> 8; nz &= 0xff; PutByte(addr, nz) -#define ROL_ZP nz = dGetByte(addr); nz = (nz << 1) + c; c = nz >> 8; nz &= 0xff; dPutByte(addr, nz) -#define LSR RMW_GetByte(nz, addr); c = nz & 1; nz >>= 1; PutByte(addr, nz) -#define LSR_ZP nz = dGetByte(addr); c = nz & 1; nz >>= 1; dPutByte(addr, nz) -#define ROR RMW_GetByte(nz, addr); nz += c << 8; c = nz & 1; nz >>= 1; PutByte(addr, nz) -#define ROR_ZP nz = dGetByte(addr) + (c << 8); c = nz & 1; nz >>= 1; dPutByte(addr, nz) -#define DEC RMW_GetByte(nz, addr); nz = (nz - 1) & 0xff; PutByte(addr, nz) -#define DEC_ZP nz = dGetByte(addr); nz = (nz - 1) & 0xff; dPutByte(addr, nz) -#define INC RMW_GetByte(nz, addr); nz = (nz + 1) & 0xff; PutByte(addr, nz) -#define INC_ZP nz = dGetByte(addr); nz = (nz + 1) & 0xff; dPutByte(addr, nz) - -#define ASO ASL; nz = a |= nz -#define ASO_ZP ASL_ZP; nz = a |= nz -#define RLA ROL; nz = a &= nz -#define RLA_ZP ROL_ZP; nz = a &= nz -#define LSE LSR; nz = a ^= nz -#define LSE_ZP LSR_ZP; nz = a ^= nz -#define RRA ROR; data = nz; DO_ADC -#define RRA_ZP ROR_ZP; data = nz; DO_ADC -#define DCM DEC; c = (a >= nz) ? 1 : 0; nz = (a - nz) & 0xff -#define DCM_ZP DEC_ZP; c = (a >= nz) ? 1 : 0; nz = (a - nz) & 0xff -#define INS INC; data = nz; DO_SBC -#define INS_ZP INC_ZP; data = nz; DO_SBC - -#define BRANCH(cond) \ - if (cond) { \ - addr = SBYTE(PEEK); \ - pc++; \ - addr += pc; \ - if ((addr ^ pc) >> 8 != 0) \ - ast _ cycle++; \ - ast _ cycle++; \ - pc = addr; \ - break; \ - } \ - pc++; \ - break - -#define CHECK_IRQ \ - if ((vdi & I_FLAG) == 0 && ast _ irqst != 0xff) { \ - PHPC; \ - PHPB0; \ - vdi |= I_FLAG; \ - pc = dGetWord(0xfffe); \ - ast _ cycle += 7; \ - } - -/* Runs 6502 emulation for the specified number of Atari scanlines. - Each scanline is 114 cycles of which 9 is taken by ANTIC for memory refresh. */ -FUNC(void, Cpu_RunScanlines, (P(ASAP_State PTR, ast), P(int, scanlines))) -{ - /* copy registers from ASAP_State to local variables for improved performance */ - V(int, pc); - V(int, nz); - V(int, a); - V(int, x); - V(int, y); - V(int, c); - V(int, s); - V(int, vdi); - V(int, next_event_cycle); - V(int, cycle_limit); - pc = ast _ cpu_pc; - nz = ast _ cpu_nz; - a = ast _ cpu_a; - x = ast _ cpu_x; - y = ast _ cpu_y; - c = ast _ cpu_c; - s = ast _ cpu_s; - vdi = ast _ cpu_vdi; - ast _ next_scanline_cycle = 114; - next_event_cycle = 114; - cycle_limit = 114 * scanlines; - if (next_event_cycle > ast _ timer1_cycle) - next_event_cycle = ast _ timer1_cycle; - if (next_event_cycle > ast _ timer2_cycle) - next_event_cycle = ast _ timer2_cycle; - if (next_event_cycle > ast _ timer4_cycle) - next_event_cycle = ast _ timer4_cycle; - ast _ nearest_event_cycle = next_event_cycle; - for (;;) { - V(int, cycle); - V(int, addr); - V(int, data); - cycle = ast _ cycle; - if (cycle >= ast _ nearest_event_cycle) { - if (cycle >= ast _ next_scanline_cycle) { - if (++ast _ scanline_number == (ast _ module_info->ntsc ? 262 : 312)) - ast _ scanline_number = 0; - ast _ cycle = cycle += 9; - ast _ next_scanline_cycle += 114; - if (--scanlines <= 0) - break; - } - next_event_cycle = ast _ next_scanline_cycle; -#define CHECK_TIMER_IRQ(ch) \ - if (cycle >= ast _ timer##ch##_cycle) { \ - ast _ irqst &= ~ch; \ - ast _ timer##ch##_cycle = NEVER; \ - } \ - else if (next_event_cycle > ast _ timer##ch##_cycle) \ - next_event_cycle = ast _ timer##ch##_cycle; - CHECK_TIMER_IRQ(1); - CHECK_TIMER_IRQ(2); - CHECK_TIMER_IRQ(4); - ast _ nearest_event_cycle = next_event_cycle; - CHECK_IRQ; - } -#ifdef ASAPSCAN - if (cpu_trace != 0) - trace_cpu(ast, pc, a, x, y, s, nz, vdi, c); -#endif - data = FETCH; - ast _ cycle += opcode_cycles[data]; - switch (data) { - case 0x00: /* BRK */ - pc++; - PHPC; - PHPB1; - vdi |= I_FLAG; - pc = dGetWord(0xfffe); - break; - case 0x01: /* ORA (ab,x) */ - INDIRECT_X; - ORA; - break; - case 0x02: /* CIM [unofficial] */ - case 0x12: - case 0x22: - case 0x32: - case 0x42: - case 0x52: - case 0x62: - case 0x72: - case 0x92: - case 0xb2: - case 0xd2: - case 0xf2: - ast _ scanline_number = (ast _ scanline_number + scanlines - 1) % (ast _ module_info->ntsc ? 262 : 312); - scanlines = 1; - ast _ cycle = cycle_limit; - break; -#ifndef ACPU_NO_UNOFFICIAL - case 0x03: /* ASO (ab,x) [unofficial] */ - INDIRECT_X; - ASO; - break; - case 0x04: /* NOP ab [unofficial] */ - case 0x44: - case 0x64: - case 0x14: /* NOP ab,x [unofficial] */ - case 0x34: - case 0x54: - case 0x74: - case 0xd4: - case 0xf4: - case 0x80: /* NOP #ab [unofficial] */ - case 0x82: - case 0x89: - case 0xc2: - case 0xe2: - pc++; - break; - case 0x07: /* ASO ab [unofficial] */ - ZPAGE; - ASO_ZP; - break; - case 0x0b: /* ANC #ab [unofficial] */ - case 0x2b: - nz = a &= FETCH; - c = nz >> 7; - break; - case 0x0c: /* NOP abcd [unofficial] */ - pc += 2; - break; - case 0x0f: /* ASO abcd [unofficial] */ - ABSOLUTE; - ASO; - break; - case 0x13: /* ASO (ab),y [unofficial] */ - INDIRECT_Y; - ASO; - break; - case 0x17: /* ASO ab,x [unofficial] */ - ZPAGE_X; - ASO_ZP; - break; - case 0x1b: /* ASO abcd,y [unofficial] */ - ABSOLUTE_Y; - ASO; - break; - case 0x1c: /* NOP abcd,x [unofficial] */ - case 0x3c: - case 0x5c: - case 0x7c: - case 0xdc: - case 0xfc: - if (FETCH + x >= 0x100) - ast _ cycle++; - pc++; - break; - case 0x1f: /* ASO abcd,x [unofficial] */ - ABSOLUTE_X; - ASO; - break; - case 0x23: /* RLA (ab,x) [unofficial] */ - INDIRECT_X; - RLA; - break; - case 0x27: /* RLA ab [unofficial] */ - ZPAGE; - RLA_ZP; - break; - case 0x2f: /* RLA abcd [unofficial] */ - ABSOLUTE; - RLA; - break; - case 0x33: /* RLA (ab),y [unofficial] */ - INDIRECT_Y; - RLA; - break; - case 0x37: /* RLA ab,x [unofficial] */ - ZPAGE_X; - RLA_ZP; - break; - case 0x3b: /* RLA abcd,y [unofficial] */ - ABSOLUTE_Y; - RLA; - break; - case 0x3f: /* RLA abcd,x [unofficial] */ - ABSOLUTE_X; - RLA; - break; - case 0x43: /* LSE (ab,x) [unofficial] */ - INDIRECT_X; - LSE; - break; - case 0x47: /* LSE ab [unofficial] */ - ZPAGE; - LSE_ZP; - break; - case 0x4b: /* ALR #ab [unofficial] */ - a &= FETCH; - c = a & 1; - nz = a >>= 1; - break; - case 0x4f: /* LSE abcd [unofficial] */ - ABSOLUTE; - LSE; - break; - case 0x53: /* LSE (ab),y [unofficial] */ - INDIRECT_Y; - LSE; - break; - case 0x57: /* LSE ab,x [unofficial] */ - ZPAGE_X; - LSE_ZP; - break; - case 0x5b: /* LSE abcd,y [unofficial] */ - ABSOLUTE_Y; - LSE; - break; - case 0x5f: /* LSE abcd,x [unofficial] */ - ABSOLUTE_X; - LSE; - break; - case 0x63: /* RRA (ab,x) [unofficial] */ - INDIRECT_X; - RRA; - break; - case 0x67: /* RRA ab [unofficial] */ - ZPAGE; - RRA_ZP; - break; - case 0x6b: /* ARR #ab [unofficial] */ - data = a & FETCH; - nz = a = (data >> 1) + (c << 7); - vdi = (vdi & (D_FLAG | I_FLAG)) + ((a ^ data) & V_FLAG); -#ifdef ACPU_NO_DECIMAL - c = data >> 7; -#else - if ((vdi & D_FLAG) == 0) - c = data >> 7; - else { - if ((data & 0xf) >= 5) - a = (a & 0xf0) + ((a + 6) & 0xf); - if (data >= 0x50) { - a = (a + 0x60) & 0xff; - c = 1; - } - else - c = 0; - } -#endif - break; - case 0x6f: /* RRA abcd [unofficial] */ - ABSOLUTE; - RRA; - break; - case 0x73: /* RRA (ab),y [unofficial] */ - INDIRECT_Y; - RRA; - break; - case 0x77: /* RRA ab,x [unofficial] */ - ZPAGE_X; - RRA_ZP; - break; - case 0x7b: /* RRA abcd,y [unofficial] */ - ABSOLUTE_Y; - RRA; - break; - case 0x7f: /* RRA abcd,x [unofficial] */ - ABSOLUTE_X; - RRA; - break; - case 0x83: /* SAX (ab,x) [unofficial] */ - INDIRECT_X; - SAX; - break; - case 0x87: /* SAX ab [unofficial] */ - ZPAGE; - SAX_ZP; - break; - case 0x8b: /* ANE #ab [unofficial] */ - data = FETCH; - a &= x; - nz = a & data; - a &= data | 0xef; - break; - case 0x8f: /* SAX abcd [unofficial] */ - ABSOLUTE; - SAX; - break; - case 0x93: /* SHA (ab),y [unofficial, unstable] */ - ZPAGE; - data = zGetByte(addr + 1); - addr = (dGetByte(addr) + (data << 8) + y) & 0xffff; - data = a & x & (data + 1); - PutByte(addr, data); - break; - case 0x97: /* SAX ab,y [unofficial] */ - ZPAGE_Y; - SAX_ZP; - break; - case 0x9b: /* SHS abcd,y [unofficial, unstable] */ - /* S seems to be stable, only memory values vary */ - addr = FETCH; - data = FETCH; - addr = (addr + (data << 8) + y) & 0xffff; - s = a & x; - data = s & (data + 1); - PutByte(addr, data); - break; - case 0x9c: /* SHY abcd,x [unofficial] */ - addr = FETCH; - data = FETCH; - addr = (addr + (data << 8) + x) & 0xffff; - data = y & (data + 1); - PutByte(addr, data); - break; - case 0x9e: /* SHX abcd,y [unofficial] */ - addr = FETCH; - data = FETCH; - addr = (addr + (data << 8) + y) & 0xffff; - data = x & (data + 1); - PutByte(addr, data); - break; - case 0x9f: /* SHA abcd,y [unofficial, unstable] */ - addr = FETCH; - data = FETCH; - addr = (addr + (data << 8) + y) & 0xffff; - data = a & x & (data + 1); - PutByte(addr, data); - break; - case 0xa3: /* LAX (ab,x) [unofficial] */ - INDIRECT_X; - LAX; - break; - case 0xa7: /* LAX ab [unofficial] */ - ZPAGE; - LAX_ZP; - break; - case 0xab: /* ANX #ab [unofficial] */ - nz = x = a &= FETCH; - break; - case 0xaf: /* LAX abcd [unofficial] */ - ABSOLUTE; - LAX; - break; - case 0xb3: /* LAX (ab),y [unofficial] */ - INDIRECT_Y; - NCYCLES_Y; - LAX; - break; - case 0xb7: /* LAX ab,y [unofficial] */ - ZPAGE_Y; - LAX_ZP; - break; - case 0xbb: /* LAS abcd,y [unofficial] */ - ABSOLUTE_Y; - NCYCLES_Y; - nz = x = a = s &= GetByte(addr); - break; - case 0xbf: /* LAX abcd,y [unofficial] */ - ABSOLUTE_Y; - NCYCLES_Y; - LAX; - break; - case 0xc3: /* DCM (ab,x) [unofficial] */ - INDIRECT_X; - DCM; - break; - case 0xc7: /* DCM ab [unofficial] */ - ZPAGE; - DCM_ZP; - break; - case 0xcb: /* SBX #ab [unofficial] */ - nz = FETCH; - x &= a; - c = (x >= nz) ? 1 : 0; - nz = x = (x - nz) & 0xff; - break; - case 0xcf: /* DCM abcd [unofficial] */ - ABSOLUTE; - DCM; - break; - case 0xd3: /* DCM (ab),y [unofficial] */ - INDIRECT_Y; - DCM; - break; - case 0xd7: /* DCM ab,x [unofficial] */ - ZPAGE_X; - DCM_ZP; - break; - case 0xdb: /* DCM abcd,y [unofficial] */ - ABSOLUTE_Y; - DCM; - break; - case 0xdf: /* DCM abcd,x [unofficial] */ - ABSOLUTE_X; - DCM; - break; - case 0xe3: /* INS (ab,x) [unofficial] */ - INDIRECT_X; - INS; - break; - case 0xe7: /* INS ab [unofficial] */ - ZPAGE; - INS_ZP; - break; - case 0xef: /* INS abcd [unofficial] */ - ABSOLUTE; - INS; - break; - case 0xf3: /* INS (ab),y [unofficial] */ - INDIRECT_Y; - INS; - break; - case 0xf7: /* INS ab,x [unofficial] */ - ZPAGE_X; - INS_ZP; - break; - case 0xfb: /* INS abcd,y [unofficial] */ - ABSOLUTE_Y; - INS; - break; - case 0xff: /* INS abcd,x [unofficial] */ - ABSOLUTE_X; - INS; - break; -#endif /* ACPU_NO_UNOFFICIAL */ - case 0x05: /* ORA ab */ - ZPAGE; - ORA_ZP; - break; - case 0x06: /* ASL ab */ - ZPAGE; - ASL_ZP; - break; - case 0x08: /* PHP */ - PHPB1; - break; - case 0x09: /* ORA #ab */ - nz = a |= FETCH; - break; - case 0x0a: /* ASL */ - c = a >> 7; - nz = a = (a << 1) & 0xff; - break; - case 0x0d: /* ORA abcd */ - ABSOLUTE; - ORA; - break; - case 0x0e: /* ASL abcd */ - ABSOLUTE; - ASL; - break; - case 0x10: /* BPL */ - BRANCH(nz < 0x80); - case 0x11: /* ORA (ab),y */ - INDIRECT_Y; - NCYCLES_Y; - ORA; - break; - case 0x15: /* ORA ab,x */ - ZPAGE_X; - ORA_ZP; - break; - case 0x16: /* ASL ab,x */ - ZPAGE_X; - ASL_ZP; - break; - case 0x18: /* CLC */ - c = 0; - break; - case 0x19: /* ORA abcd,y */ - ABSOLUTE_Y; - NCYCLES_Y; - ORA; - break; - case 0x1d: /* ORA abcd,x */ - ABSOLUTE_X; - NCYCLES_X; - ORA; - break; - case 0x1e: /* ASL abcd,x */ - ABSOLUTE_X; - ASL; - break; - case 0x20: /* JSR abcd */ - addr = FETCH; - PHPC; - pc = addr + (PEEK << 8); - break; - case 0x21: /* AND (ab,x) */ - INDIRECT_X; - AND; - break; - case 0x24: /* BIT ab */ - ZPAGE; - nz = dGetByte(addr); - vdi = (vdi & (D_FLAG | I_FLAG)) + (nz & V_FLAG); - nz = ((nz & 0x80) << 1) + (nz & a); - break; - case 0x25: /* AND ab */ - ZPAGE; - AND_ZP; - break; - case 0x26: /* ROL ab */ - ZPAGE; - ROL_ZP; - break; - case 0x28: /* PLP */ - PLP; - CHECK_IRQ; - break; - case 0x29: /* AND #ab */ - nz = a &= FETCH; - break; - case 0x2a: /* ROL */ - a = (a << 1) + c; - c = a >> 8; - nz = a &= 0xff; - break; - case 0x2c: /* BIT abcd */ - ABSOLUTE; - nz = GetByte(addr); - vdi = (vdi & (D_FLAG | I_FLAG)) + (nz & V_FLAG); - nz = ((nz & 0x80) << 1) + (nz & a); - break; - case 0x2d: /* AND abcd */ - ABSOLUTE; - AND; - break; - case 0x2e: /* ROL abcd */ - ABSOLUTE; - ROL; - break; - case 0x30: /* BMI */ - BRANCH(nz >= 0x80); - case 0x31: /* AND (ab),y */ - INDIRECT_Y; - NCYCLES_Y; - AND; - break; - case 0x35: /* AND ab,x */ - ZPAGE_X; - AND_ZP; - break; - case 0x36: /* ROL ab,x */ - ZPAGE_X; - ROL_ZP; - break; - case 0x38: /* SEC */ - c = 1; - break; - case 0x39: /* AND abcd,y */ - ABSOLUTE_Y; - NCYCLES_Y; - AND; - break; - case 0x3d: /* AND abcd,x */ - ABSOLUTE_X; - NCYCLES_X; - AND; - break; - case 0x3e: /* ROL abcd,x */ - ABSOLUTE_X; - ROL; - break; - case 0x40: /* RTI */ - PLP; - PL(pc); - PL(addr); - pc += addr << 8; - CHECK_IRQ; - break; - case 0x41: /* EOR (ab,x) */ - INDIRECT_X; - EOR; - break; - case 0x45: /* EOR ab */ - ZPAGE; - EOR_ZP; - break; - case 0x46: /* LSR ab */ - ZPAGE; - LSR_ZP; - break; - case 0x48: /* PHA */ - PH(a); - break; - case 0x49: /* EOR #ab */ - nz = a ^= FETCH; - break; - case 0x4a: /* LSR */ - c = a & 1; - nz = a >>= 1; - break; - case 0x4c: /* JMP abcd */ - addr = FETCH; - pc = addr + (PEEK << 8); - break; - case 0x4d: /* EOR abcd */ - ABSOLUTE; - EOR; - break; - case 0x4e: /* LSR abcd */ - ABSOLUTE; - LSR; - break; - case 0x50: /* BVC */ - BRANCH((vdi & V_FLAG) == 0); - case 0x51: /* EOR (ab),y */ - INDIRECT_Y; - NCYCLES_Y; - EOR; - break; - case 0x55: /* EOR ab,x */ - ZPAGE_X; - EOR_ZP; - break; - case 0x56: /* LSR ab,x */ - ZPAGE_X; - LSR_ZP; - break; - case 0x58: /* CLI */ - vdi &= V_FLAG | D_FLAG; - CHECK_IRQ; - break; - case 0x59: /* EOR abcd,y */ - ABSOLUTE_Y; - NCYCLES_Y; - EOR; - break; - case 0x5d: /* EOR abcd,x */ - ABSOLUTE_X; - NCYCLES_X; - EOR; - break; - case 0x5e: /* LSR abcd,x */ - ABSOLUTE_X; - LSR; - break; - case 0x60: /* RTS */ - PL(pc); - PL(addr); - pc += (addr << 8) + 1; - break; - case 0x61: /* ADC (ab,x) */ - INDIRECT_X; - ADC; - break; - case 0x65: /* ADC ab */ - ZPAGE; - ADC_ZP; - break; - case 0x66: /* ROR ab */ - ZPAGE; - ROR_ZP; - break; - case 0x68: /* PLA */ - PL(a); - nz = a; - break; - case 0x69: /* ADC #ab */ - data = FETCH; - DO_ADC; - break; - case 0x6a: /* ROR */ - nz = (c << 7) + (a >> 1); - c = a & 1; - a = nz; - break; - case 0x6c: /* JMP (abcd) */ - ABSOLUTE; - if ((addr & 0xff) == 0xff) - pc = (dGetByte(addr - 0xff) << 8) + dGetByte(addr); - else - pc = dGetWord(addr); - break; - case 0x6d: /* ADC abcd */ - ABSOLUTE; - ADC; - break; - case 0x6e: /* ROR abcd */ - ABSOLUTE; - ROR; - break; - case 0x70: /* BVS */ - BRANCH((vdi & V_FLAG) != 0); - case 0x71: /* ADC (ab),y */ - INDIRECT_Y; - NCYCLES_Y; - ADC; - break; - case 0x75: /* ADC ab,x */ - ZPAGE_X; - ADC_ZP; - break; - case 0x76: /* ROR ab,x */ - ZPAGE_X; - ROR_ZP; - break; - case 0x78: /* SEI */ - vdi |= I_FLAG; - break; - case 0x79: /* ADC abcd,y */ - ABSOLUTE_Y; - NCYCLES_Y; - ADC; - break; - case 0x7d: /* ADC abcd,x */ - ABSOLUTE_X; - NCYCLES_X; - ADC; - break; - case 0x7e: /* ROR abcd,x */ - ABSOLUTE_X; - ROR; - break; - case 0x81: /* STA (ab,x) */ - INDIRECT_X; - STA; - break; - case 0x84: /* STY ab */ - ZPAGE; - STY_ZP; - break; - case 0x85: /* STA ab */ - ZPAGE; - STA_ZP; - break; - case 0x86: /* STX ab */ - ZPAGE; - STX_ZP; - break; - case 0x88: /* DEY */ - nz = y = (y - 1) & 0xff; - break; - case 0x8a: /* TXA */ - nz = a = x; - break; - case 0x8c: /* STY abcd */ - ABSOLUTE; - STY; - break; - case 0x8d: /* STA abcd */ - ABSOLUTE; - STA; - break; - case 0x8e: /* STX abcd */ - ABSOLUTE; - STX; - break; - case 0x90: /* BCC */ - BRANCH(c == 0); - case 0x91: /* STA (ab),y */ - INDIRECT_Y; - STA; - break; - case 0x94: /* STY ab,x */ - ZPAGE_X; - STY_ZP; - break; - case 0x95: /* STA ab,x */ - ZPAGE_X; - STA_ZP; - break; - case 0x96: /* STX ab,y */ - ZPAGE_Y; - STX_ZP; - break; - case 0x98: /* TYA */ - nz = a = y; - break; - case 0x99: /* STA abcd,y */ - ABSOLUTE_Y; - STA; - break; - case 0x9a: /* TXS */ - s = x; - break; - case 0x9d: /* STA abcd,x */ - ABSOLUTE_X; - STA; - break; - case 0xa0: /* LDY #ab */ - nz = y = FETCH; - break; - case 0xa1: /* LDA (ab,x) */ - INDIRECT_X; - LDA; - break; - case 0xa2: /* LDX #ab */ - nz = x = FETCH; - break; - case 0xa4: /* LDY ab */ - ZPAGE; - LDY_ZP; - break; - case 0xa5: /* LDA ab */ - ZPAGE; - LDA_ZP; - break; - case 0xa6: /* LDX ab */ - ZPAGE; - LDX_ZP; - break; - case 0xa8: /* TAY */ - nz = y = a; - break; - case 0xa9: /* LDA #ab */ - nz = a = FETCH; - break; - case 0xaa: /* TAX */ - nz = x = a; - break; - case 0xac: /* LDY abcd */ - ABSOLUTE; - LDY; - break; - case 0xad: /* LDA abcd */ - ABSOLUTE; - LDA; - break; - case 0xae: /* LDX abcd */ - ABSOLUTE; - LDX; - break; - case 0xb0: /* BCS */ - BRANCH(c != 0); - case 0xb1: /* LDA (ab),y */ - INDIRECT_Y; - NCYCLES_Y; - LDA; - break; - case 0xb4: /* LDY ab,x */ - ZPAGE_X; - LDY_ZP; - break; - case 0xb5: /* LDA ab,x */ - ZPAGE_X; - LDA_ZP; - break; - case 0xb6: /* LDX ab,y */ - ZPAGE_Y; - LDX_ZP; - break; - case 0xb8: /* CLV */ - vdi &= D_FLAG | I_FLAG; - break; - case 0xb9: /* LDA abcd,y */ - ABSOLUTE_Y; - NCYCLES_Y; - LDA; - break; - case 0xba: /* TSX */ - nz = x = s; - break; - case 0xbc: /* LDY abcd,x */ - ABSOLUTE_X; - NCYCLES_X; - LDY; - break; - case 0xbd: /* LDA abcd,x */ - ABSOLUTE_X; - NCYCLES_X; - LDA; - break; - case 0xbe: /* LDX abcd,y */ - ABSOLUTE_Y; - NCYCLES_Y; - LDX; - break; - case 0xc0: /* CPY #ab */ - nz = FETCH; - c = (y >= nz) ? 1 : 0; - nz = (y - nz) & 0xff; - break; - case 0xc1: /* CMP (ab,x) */ - INDIRECT_X; - CMP; - break; - case 0xc4: /* CPY ab */ - ZPAGE; - CPY_ZP; - break; - case 0xc5: /* CMP ab */ - ZPAGE; - CMP_ZP; - break; - case 0xc6: /* DEC ab */ - ZPAGE; - DEC_ZP; - break; - case 0xc8: /* INY */ - nz = y = (y + 1) & 0xff; - break; - case 0xc9: /* CMP #ab */ - nz = FETCH; - c = (a >= nz) ? 1 : 0; - nz = (a - nz) & 0xff; - break; - case 0xca: /* DEX */ - nz = x = (x - 1) & 0xff; - break; - case 0xcc: /* CPY abcd */ - ABSOLUTE; - CPY; - break; - case 0xcd: /* CMP abcd */ - ABSOLUTE; - CMP; - break; - case 0xce: /* DEC abcd */ - ABSOLUTE; - DEC; - break; - case 0xd0: /* BNE */ - BRANCH((nz & 0xff) != 0); - case 0xd1: /* CMP (ab),y */ - INDIRECT_Y; - NCYCLES_Y; - CMP; - break; - case 0xd5: /* CMP ab,x */ - ZPAGE_X; - CMP_ZP; - break; - case 0xd6: /* DEC ab,x */ - ZPAGE_X; - DEC_ZP; - break; - case 0xd8: /* CLD */ - vdi &= V_FLAG | I_FLAG; - break; - case 0xd9: /* CMP abcd,y */ - ABSOLUTE_Y; - NCYCLES_Y; - CMP; - break; - case 0xdd: /* CMP abcd,x */ - ABSOLUTE_X; - NCYCLES_X; - CMP; - break; - case 0xde: /* DEC abcd,x */ - ABSOLUTE_X; - DEC; - break; - case 0xe0: /* CPX #ab */ - nz = FETCH; - c = (x >= nz) ? 1 : 0; - nz = (x - nz) & 0xff; - break; - case 0xe1: /* SBC (ab,x) */ - INDIRECT_X; - SBC; - break; - case 0xe4: /* CPX ab */ - ZPAGE; - CPX_ZP; - break; - case 0xe5: /* SBC ab */ - ZPAGE; - SBC_ZP; - break; - case 0xe6: /* INC ab */ - ZPAGE; - INC_ZP; - break; - case 0xe8: /* INX */ - nz = x = (x + 1) & 0xff; - break; - case 0xe9: /* SBC #ab */ - case 0xeb: /* SBC #ab [unofficial] */ - data = FETCH; - DO_SBC; - break; - case 0xea: /* NOP */ - case 0x1a: /* NOP [unofficial] */ - case 0x3a: - case 0x5a: - case 0x7a: - case 0xda: - case 0xfa: - break; - case 0xec: /* CPX abcd */ - ABSOLUTE; - CPX; - break; - case 0xed: /* SBC abcd */ - ABSOLUTE; - SBC; - break; - case 0xee: /* INC abcd */ - ABSOLUTE; - INC; - break; - case 0xf0: /* BEQ */ - BRANCH((nz & 0xff) == 0); - case 0xf1: /* SBC (ab),y */ - INDIRECT_Y; - NCYCLES_Y; - SBC; - break; - case 0xf5: /* SBC ab,x */ - ZPAGE_X; - SBC_ZP; - break; - case 0xf6: /* INC ab,x */ - ZPAGE_X; - INC_ZP; - break; - case 0xf8: /* SED */ - vdi |= D_FLAG; - break; - case 0xf9: /* SBC abcd,y */ - ABSOLUTE_Y; - NCYCLES_Y; - SBC; - break; - case 0xfd: /* SBC abcd,x */ - ABSOLUTE_X; - NCYCLES_X; - SBC; - break; - case 0xfe: /* INC abcd,x */ - ABSOLUTE_X; - INC; - break; - } - } - ast _ cpu_pc = pc; - ast _ cpu_nz = nz; - ast _ cpu_a = a; - ast _ cpu_x = x; - ast _ cpu_y = y; - ast _ cpu_c = c; - ast _ cpu_s = s; - ast _ cpu_vdi = vdi; - ast _ cycle -= cycle_limit; - if (ast _ timer1_cycle != NEVER) - ast _ timer1_cycle -= cycle_limit; - if (ast _ timer2_cycle != NEVER) - ast _ timer2_cycle -= cycle_limit; - if (ast _ timer4_cycle != NEVER) - ast _ timer4_cycle -= cycle_limit; -} diff --git a/apps/codecs/libasap/anylang.h b/apps/codecs/libasap/anylang.h deleted file mode 100644 index e56dfbae0e..0000000000 --- a/apps/codecs/libasap/anylang.h +++ /dev/null @@ -1,218 +0,0 @@ -/* - * anylang.h - C/Java/C#/JavaScript/ActionScript abstraction layer - * - * Copyright (C) 2007-2010 Piotr Fusik - * - * This file is part of ASAP (Another Slight Atari Player), - * see http://asap.sourceforge.net - * - * ASAP is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2 of the License, - * or (at your option) any later version. - * - * ASAP is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with ASAP; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef _ANYLANG_H_ -#define _ANYLANG_H_ - -#if defined(JAVA) || defined(CSHARP) || defined(JAVASCRIPT) || defined(ACTIONSCRIPT) - -#define FALSE false -#define TRUE true -#define NULL null -#define _ . -#define PRIVATE -#define CONST -#define OUT_STRING STRING - -#else - -#define C -#include - -#define PRIVATE static -#define FUNC(type, name, pars) type name pars -#define P(type, name) type name -#define V(type, name) type name -#define CONST const -#define _ -> -#define PTR * -#define ADDRESSOF & -#define CAST(type) (type) -#define TO_INT(x) (int) (x) -#define TO_BYTE(x) (byte) (x) -#define BYTEARRAY byte * -#define BOOLARRAY abool * -#define VOIDPTR void * -#define UBYTE(data) (data) -#define SBYTE(data) (signed char) (data) -#define CONST_ARRAY(type, name) static const type name[] = { -#define END_CONST_ARRAY } -#define ZERO_ARRAY(array) memset(array, 0, sizeof(array)) -#define COPY_ARRAY(dest, dest_offset, src, src_offset, len) \ - memcpy(dest + dest_offset, src + src_offset, len) -#define NEW_ARRAY(type, name, size) \ - type name[size] -#define INIT_ARRAY(array) memset(array, 0, sizeof(array)) -#define STRING const char * -#define OUT_STRING char * -#define CHARAT(s, i) (s)[i] -#define CHARCODEAT(s, i) (s)[i] -#define CHARCODE(c) (c) -#define EQUAL_STRINGS(s1, s2) (strcmp(s1, s2) == 0) -#define EMPTY_STRING(s) (s)[0] = '\0' -#define SUBSTR(s, i) (s + i) -#define BYTES_TO_STRING(dest, src, src_offset, len) \ - do { memcpy(dest, src + src_offset, len); (dest)[len] = '\0'; } while (FALSE) -#define SUBSTRING(dest, src, src_offset, len) \ - do { memcpy(dest, src + src_offset, len); (dest)[len] = '\0'; } while (FALSE) - -#define RESOURCE const byte * -#define GET_RESOURCE(name, ext) name##_##ext - -#endif /* defined(JAVA) || defined(CSHARP) || defined(JAVASCRIPT) || defined(ACTIONSCRIPT) */ - -#ifdef JAVA - -#define abool boolean -#define FUNC(type, name, pars) private static type name pars -#define P(type, name) type name -#define V(type, name) type name -#define PTR -#define ADDRESSOF -#define CAST(type) (type) -#define TO_INT(x) (int) (x) -#define TO_BYTE(x) (byte) (x) -#define BYTEARRAY byte[] -#define BOOLARRAY boolean[] -#define VOIDPTR byte[] -#define UBYTE(data) ((data) & 0xff) -#define SBYTE(data) (byte) (data) -#define CONST_ARRAY(type, name) private static final type[] name = { -#define END_CONST_ARRAY } -#define sizeof(array) array.length -#define ZERO_ARRAY(array) for (int ii = 0; ii < array.length; ii++) array[ii] = 0 -#define COPY_ARRAY(dest, dest_offset, src, src_offset, len) \ - System.arraycopy(src, src_offset, dest, dest_offset, len) -#define NEW_ARRAY(type, name, size) \ - type[] name = new type[size] -#define INIT_ARRAY(array) -#define STRING String -#define CHARAT(s, i) (s).charAt(i) -#define CHARCODEAT(s, i) (s).charAt(i) -#define CHARCODE(c) (c) -#define strlen(s) (s).length() -#define EQUAL_STRINGS(s1, s2) (s1).equals(s2) -#define EMPTY_STRING(s) (s) = "" -#define SUBSTR(s, i) (s).substring(i) -#define BYTES_TO_STRING(dest, src, src_offset, len) \ - (dest) = new String(src, src_offset, len) -#define SUBSTRING(dest, src, src_offset, len) \ - (dest) = (src).substring(src_offset, src_offset + len) - -#define RESOURCE byte[] -#define GET_RESOURCE(name, ext) getResourceBytes(#name + "." + #ext) - -#elif defined(CSHARP) - -#define abool bool -#define FUNC(type, name, pars) private static type name pars -#define P(type, name) type name -#define V(type, name) type name -#define PTR -#define ADDRESSOF -#define CAST(type) (type) -#define TO_INT(x) (int) (x) -#define TO_BYTE(x) (byte) (x) -#define BYTEARRAY byte[] -#define BOOLARRAY bool[] -#define VOIDPTR byte[] -#define UBYTE(data) (data) -#define SBYTE(data) (sbyte) (data) -#define CONST_ARRAY(type, name) private static readonly type[] name = { -#define END_CONST_ARRAY } -#define sizeof(array) array.Length -#define ZERO_ARRAY(array) Array.Clear(array, 0, array.Length) -#define COPY_ARRAY(dest, dest_offset, src, src_offset, len) \ - Array.Copy(src, src_offset, dest, dest_offset, len) -#define NEW_ARRAY(type, name, size) \ - type[] name = new type[size] -#define INIT_ARRAY(array) -#define STRING string -#define CHARAT(s, i) (s)[i] -#define CHARCODEAT(s, i) (s)[i] -#define CHARCODE(c) (c) -#define strlen(s) (s).Length -#define EQUAL_STRINGS(s1, s2) ((s1) == (s2)) -#define EMPTY_STRING(s) (s) = string.Empty -#define SUBSTR(s, i) (s).Substring(i) -#define BYTES_TO_STRING(dest, src, src_offset, len) \ - (dest) = System.Text.Encoding.UTF8.GetString(src, src_offset, len) -#define SUBSTRING(dest, src, src_offset, len) \ - (dest) = (src).Substring(src_offset, len) - -#define RESOURCE byte[] -#define GET_RESOURCE(name, ext) name##_##ext - -#elif defined(JAVASCRIPT) || defined(ACTIONSCRIPT) - -#ifdef ACTIONSCRIPT -#define abool Boolean -#define char String -#define STRING String -#define BYTEARRAY ByteArray -#define BOOLARRAY Array -#define VOIDPTR ByteArray -#define RESOURCE Array -#define FUNC(type, name, pars) private static function name pars : type -#define P(type, name) name : type -#define V(type, name) var name : type -#define TO_INT(x) int(x) -#define CONST_ARRAY(type, name) private static const name : Array = [ -#else -#define FUNC(type, name, pars) function name pars -#define P(type, name) name -#define V(type, name) var name -#define TO_INT(x) Math.floor(x) -#define CONST_ARRAY(type, name) var name = [ -#endif -#define PTR -#define ADDRESSOF -#define CAST(type) -#define TO_BYTE(x) ((x) & 0xff) -#define UBYTE(data) (data) -#define SBYTE(data) ((data) < 0x80 ? (data) : (data) - 256) -#define END_CONST_ARRAY ] -#define sizeof(array) array.length -#define ZERO_ARRAY(array) for (V(int, ii) = 0; ii < array.length; ii++) array[ii] = 0 -#define COPY_ARRAY(dest, dest_offset, src, src_offset, len) \ - for (V(int, ii) = 0; ii < len; ii++) dest[dest_offset + ii] = src[src_offset + ii] -#define NEW_ARRAY(type, name, size) \ - V(Array, name) = new Array(size) -#define INIT_ARRAY(array) for (V(int, ii) = 0; ii < array.length; ii++) array[ii] = 0 -#define CHARAT(s, i) (s).charAt(i) -#define CHARCODEAT(s, i) (s).charCodeAt(i) -#define CHARCODE(c) (c).charCodeAt(0) -#define strlen(s) (s).length -#define EQUAL_STRINGS(s1, s2) ((s1) == (s2)) -#define EMPTY_STRING(s) s = "" -#define SUBSTR(s, i) (s).substr(i) -#define BYTES_TO_STRING(dest, src, src_offset, len) \ - { dest = ""; for (V(int, ii) = 0; ii < len; ii++) dest += String.fromCharCode(src[src_offset + ii]); } -#define SUBSTRING(dest, src, src_offset, len) \ - dest = (src).substring(src_offset, src_offset + len) - -#define GET_RESOURCE(name, ext) name##_##ext - -#endif - -#endif /* _ANYLANG_H_ */ diff --git a/apps/codecs/libasap/apokeysnd.c b/apps/codecs/libasap/apokeysnd.c deleted file mode 100644 index 811e2f9b4a..0000000000 --- a/apps/codecs/libasap/apokeysnd.c +++ /dev/null @@ -1,599 +0,0 @@ -/* - * apokeysnd.c - another POKEY sound emulator - * - * Copyright (C) 2007-2010 Piotr Fusik - * - * This file is part of ASAP (Another Slight Atari Player), - * see http://asap.sourceforge.net - * - * ASAP is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2 of the License, - * or (at your option) any later version. - * - * ASAP is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with ASAP; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "asap_internal.h" - -#define ULTRASOUND_CYCLES 112 - -#define MUTE_FREQUENCY 1 -#define MUTE_INIT 2 -#define MUTE_USER 4 - -CONST_ARRAY(byte, poly4_lookup) - 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1 -END_CONST_ARRAY; -CONST_ARRAY(byte, poly5_lookup) - 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, - 0, 1, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1 -END_CONST_ARRAY; - -PRIVATE FUNC(void, PokeySound_InitializeChip, (P(PokeyState PTR, pst))) -{ - pst _ audctl = 0; - pst _ init = FALSE; - pst _ poly_index = 15 * 31 * 131071; - pst _ div_cycles = 28; - pst _ mute1 = MUTE_FREQUENCY | MUTE_USER; - pst _ mute2 = MUTE_FREQUENCY | MUTE_USER; - pst _ mute3 = MUTE_FREQUENCY | MUTE_USER; - pst _ mute4 = MUTE_FREQUENCY | MUTE_USER; - pst _ audf1 = 0; - pst _ audf2 = 0; - pst _ audf3 = 0; - pst _ audf4 = 0; - pst _ audc1 = 0; - pst _ audc2 = 0; - pst _ audc3 = 0; - pst _ audc4 = 0; - pst _ tick_cycle1 = NEVER; - pst _ tick_cycle2 = NEVER; - pst _ tick_cycle3 = NEVER; - pst _ tick_cycle4 = NEVER; - pst _ period_cycles1 = 28; - pst _ period_cycles2 = 28; - pst _ period_cycles3 = 28; - pst _ period_cycles4 = 28; - pst _ reload_cycles1 = 28; - pst _ reload_cycles3 = 28; - pst _ out1 = 0; - pst _ out2 = 0; - pst _ out3 = 0; - pst _ out4 = 0; - pst _ delta1 = 0; - pst _ delta2 = 0; - pst _ delta3 = 0; - pst _ delta4 = 0; - pst _ skctl = 3; - ZERO_ARRAY(pst _ delta_buffer); -} - -FUNC(void, PokeySound_Initialize, (P(ASAP_State PTR, ast))) -{ - V(int, i); - V(int, reg); - reg = 0x1ff; - for (i = 0; i < 511; i++) { - reg = ((((reg >> 5) ^ reg) & 1) << 8) + (reg >> 1); - ast _ poly9_lookup[i] = TO_BYTE(reg); - } - reg = 0x1ffff; - for (i = 0; i < 16385; i++) { - reg = ((((reg >> 5) ^ reg) & 0xff) << 9) + (reg >> 8); - ast _ poly17_lookup[i] = TO_BYTE(reg >> 1); - } - ast _ sample_offset = 0; - ast _ sample_index = 0; - ast _ samples = 0; - ast _ iir_acc_left = 0; - ast _ iir_acc_right = 0; - PokeySound_InitializeChip(ADDRESSOF ast _ base_pokey); - PokeySound_InitializeChip(ADDRESSOF ast _ extra_pokey); -} - -#define DO_TICK(ch) \ - if (pst _ init) { \ - switch (pst _ audc##ch >> 4) { \ - case 10: \ - case 14: \ - pst _ out##ch ^= 1; \ - pst _ delta_buffer[CYCLE_TO_SAMPLE(cycle)] += pst _ delta##ch = -pst _ delta##ch; \ - break; \ - default: \ - break; \ - } \ - } \ - else { \ - V(int, poly) = cycle + pst _ poly_index - (ch - 1); \ - V(int, newout) = pst _ out##ch; \ - switch (pst _ audc##ch >> 4) { \ - case 0: \ - if (poly5_lookup[poly % 31] != 0) { \ - if ((pst _ audctl & 0x80) != 0) \ - newout = ast _ poly9_lookup[poly % 511] & 1; \ - else { \ - poly %= 131071; \ - newout = (ast _ poly17_lookup[poly >> 3] >> (poly & 7)) & 1; \ - } \ - } \ - break; \ - case 2: \ - case 6: \ - newout ^= poly5_lookup[poly % 31]; \ - break; \ - case 4: \ - if (poly5_lookup[poly % 31] != 0) \ - newout = poly4_lookup[poly % 15]; \ - break; \ - case 8: \ - if ((pst _ audctl & 0x80) != 0) \ - newout = ast _ poly9_lookup[poly % 511] & 1; \ - else { \ - poly %= 131071; \ - newout = (ast _ poly17_lookup[poly >> 3] >> (poly & 7)) & 1; \ - } \ - break; \ - case 10: \ - case 14: \ - newout ^= 1; \ - break; \ - case 12: \ - newout = poly4_lookup[poly % 15]; \ - break; \ - default: \ - break; \ - } \ - if (newout != pst _ out##ch) { \ - pst _ out##ch = newout; \ - pst _ delta_buffer[CYCLE_TO_SAMPLE(cycle)] += pst _ delta##ch = -pst _ delta##ch; \ - } \ - } - -/* Fills delta_buffer up to current_cycle basing on current AUDF/AUDC/AUDCTL values. */ -PRIVATE FUNC(void, PokeySound_GenerateUntilCycle, (P(ASAP_State PTR, ast), P(PokeyState PTR, pst), P(int, current_cycle))) -{ - for (;;) { - V(int, cycle) = current_cycle; - if (cycle > pst _ tick_cycle1) - cycle = pst _ tick_cycle1; - if (cycle > pst _ tick_cycle2) - cycle = pst _ tick_cycle2; - if (cycle > pst _ tick_cycle3) - cycle = pst _ tick_cycle3; - if (cycle > pst _ tick_cycle4) - cycle = pst _ tick_cycle4; - if (cycle == current_cycle) - break; - if (cycle == pst _ tick_cycle3) { - pst _ tick_cycle3 += pst _ period_cycles3; - if ((pst _ audctl & 4) != 0 && pst _ delta1 > 0 && pst _ mute1 == 0) - pst _ delta_buffer[CYCLE_TO_SAMPLE(cycle)] += pst _ delta1 = -pst _ delta1; - DO_TICK(3); - } - if (cycle == pst _ tick_cycle4) { - pst _ tick_cycle4 += pst _ period_cycles4; - if ((pst _ audctl & 8) != 0) - pst _ tick_cycle3 = cycle + pst _ reload_cycles3; - if ((pst _ audctl & 2) != 0 && pst _ delta2 > 0 && pst _ mute2 == 0) - pst _ delta_buffer[CYCLE_TO_SAMPLE(cycle)] += pst _ delta2 = -pst _ delta2; - DO_TICK(4); - } - if (cycle == pst _ tick_cycle1) { - pst _ tick_cycle1 += pst _ period_cycles1; - if ((pst _ skctl & 0x88) == 8) /* two-tone, sending 1 (i.e. timer1) */ - pst _ tick_cycle2 = cycle + pst _ period_cycles2; - DO_TICK(1); - } - if (cycle == pst _ tick_cycle2) { - pst _ tick_cycle2 += pst _ period_cycles2; - if ((pst _ audctl & 0x10) != 0) - pst _ tick_cycle1 = cycle + pst _ reload_cycles1; - else if ((pst _ skctl & 8) != 0) /* two-tone */ - pst _ tick_cycle1 = cycle + pst _ period_cycles1; - DO_TICK(2); - } - } -} - -#ifdef APOKEYSND - -#define CURRENT_CYCLE 0 -#define CURRENT_SAMPLE 0 -#define DO_STORE(reg) \ - if (data == pst _ reg) \ - break; \ - pst _ reg = data; - -#else - -#define CURRENT_CYCLE ast _ cycle -#define CURRENT_SAMPLE CYCLE_TO_SAMPLE(ast _ cycle) -#define DO_STORE(reg) \ - if (data == pst _ reg) \ - break; \ - PokeySound_GenerateUntilCycle(ast, pst, ast _ cycle); \ - pst _ reg = data; - -#endif /* APOKEYSND */ - -#define MUTE_CHANNEL(ch, cond, mask) \ - if (cond) { \ - pst _ mute##ch |= mask; \ - pst _ tick_cycle##ch = NEVER; \ - } \ - else { \ - pst _ mute##ch &= ~mask; \ - if (pst _ tick_cycle##ch == NEVER && pst _ mute##ch == 0) \ - pst _ tick_cycle##ch = CURRENT_CYCLE; \ - } - -#define DO_ULTRASOUND(ch) \ - MUTE_CHANNEL(ch, pst _ period_cycles##ch <= ULTRASOUND_CYCLES && (pst _ audc##ch >> 4 == 10 || pst _ audc##ch >> 4 == 14), MUTE_FREQUENCY) - -#define DO_AUDC(ch) \ - DO_STORE(audc##ch); \ - if ((data & 0x10) != 0) { \ - data = (data & 0xf) << DELTA_SHIFT_POKEY; \ - if ((pst _ mute##ch & MUTE_USER) == 0) \ - pst _ delta_buffer[CURRENT_SAMPLE] \ - += pst _ delta##ch > 0 ? data - pst _ delta##ch : data; \ - pst _ delta##ch = data; \ - } \ - else { \ - data = (data & 0xf) << DELTA_SHIFT_POKEY; \ - DO_ULTRASOUND(ch); \ - if (pst _ delta##ch > 0) { \ - if ((pst _ mute##ch & MUTE_USER) == 0) \ - pst _ delta_buffer[CURRENT_SAMPLE] \ - += data - pst _ delta##ch; \ - pst _ delta##ch = data; \ - } \ - else \ - pst _ delta##ch = -data; \ - } \ - break; - -#define DO_INIT(ch, cond) \ - MUTE_CHANNEL(ch, pst _ init && cond, MUTE_INIT) - -FUNC(void, PokeySound_PutByte, (P(ASAP_State PTR, ast), P(int, addr), P(int, data))) -{ - V(PokeyState PTR, pst) = (addr & ast _ extra_pokey_mask) != 0 - ? ADDRESSOF ast _ extra_pokey : ADDRESSOF ast _ base_pokey; - switch (addr & 0xf) { - case 0x00: - DO_STORE(audf1); - switch (pst _ audctl & 0x50) { - case 0x00: - pst _ period_cycles1 = pst _ div_cycles * (data + 1); - break; - case 0x10: - pst _ period_cycles2 = pst _ div_cycles * (data + 256 * pst _ audf2 + 1); - pst _ reload_cycles1 = pst _ div_cycles * (data + 1); - DO_ULTRASOUND(2); - break; - case 0x40: - pst _ period_cycles1 = data + 4; - break; - case 0x50: - pst _ period_cycles2 = data + 256 * pst _ audf2 + 7; - pst _ reload_cycles1 = data + 4; - DO_ULTRASOUND(2); - break; - } - DO_ULTRASOUND(1); - break; - case 0x01: - DO_AUDC(1) - case 0x02: - DO_STORE(audf2); - switch (pst _ audctl & 0x50) { - case 0x00: - case 0x40: - pst _ period_cycles2 = pst _ div_cycles * (data + 1); - break; - case 0x10: - pst _ period_cycles2 = pst _ div_cycles * (pst _ audf1 + 256 * data + 1); - break; - case 0x50: - pst _ period_cycles2 = pst _ audf1 + 256 * data + 7; - break; - } - DO_ULTRASOUND(2); - break; - case 0x03: - DO_AUDC(2) - case 0x04: - DO_STORE(audf3); - switch (pst _ audctl & 0x28) { - case 0x00: - pst _ period_cycles3 = pst _ div_cycles * (data + 1); - break; - case 0x08: - pst _ period_cycles4 = pst _ div_cycles * (data + 256 * pst _ audf4 + 1); - pst _ reload_cycles3 = pst _ div_cycles * (data + 1); - DO_ULTRASOUND(4); - break; - case 0x20: - pst _ period_cycles3 = data + 4; - break; - case 0x28: - pst _ period_cycles4 = data + 256 * pst _ audf4 + 7; - pst _ reload_cycles3 = data + 4; - DO_ULTRASOUND(4); - break; - } - DO_ULTRASOUND(3); - break; - case 0x05: - DO_AUDC(3) - case 0x06: - DO_STORE(audf4); - switch (pst _ audctl & 0x28) { - case 0x00: - case 0x20: - pst _ period_cycles4 = pst _ div_cycles * (data + 1); - break; - case 0x08: - pst _ period_cycles4 = pst _ div_cycles * (pst _ audf3 + 256 * data + 1); - break; - case 0x28: - pst _ period_cycles4 = pst _ audf3 + 256 * data + 7; - break; - } - DO_ULTRASOUND(4); - break; - case 0x07: - DO_AUDC(4) - case 0x08: - DO_STORE(audctl); - pst _ div_cycles = ((data & 1) != 0) ? 114 : 28; - /* TODO: tick_cycles */ - switch (data & 0x50) { - case 0x00: - pst _ period_cycles1 = pst _ div_cycles * (pst _ audf1 + 1); - pst _ period_cycles2 = pst _ div_cycles * (pst _ audf2 + 1); - break; - case 0x10: - pst _ period_cycles1 = pst _ div_cycles * 256; - pst _ period_cycles2 = pst _ div_cycles * (pst _ audf1 + 256 * pst _ audf2 + 1); - pst _ reload_cycles1 = pst _ div_cycles * (pst _ audf1 + 1); - break; - case 0x40: - pst _ period_cycles1 = pst _ audf1 + 4; - pst _ period_cycles2 = pst _ div_cycles * (pst _ audf2 + 1); - break; - case 0x50: - pst _ period_cycles1 = 256; - pst _ period_cycles2 = pst _ audf1 + 256 * pst _ audf2 + 7; - pst _ reload_cycles1 = pst _ audf1 + 4; - break; - } - DO_ULTRASOUND(1); - DO_ULTRASOUND(2); - switch (data & 0x28) { - case 0x00: - pst _ period_cycles3 = pst _ div_cycles * (pst _ audf3 + 1); - pst _ period_cycles4 = pst _ div_cycles * (pst _ audf4 + 1); - break; - case 0x08: - pst _ period_cycles3 = pst _ div_cycles * 256; - pst _ period_cycles4 = pst _ div_cycles * (pst _ audf3 + 256 * pst _ audf4 + 1); - pst _ reload_cycles3 = pst _ div_cycles * (pst _ audf3 + 1); - break; - case 0x20: - pst _ period_cycles3 = pst _ audf3 + 4; - pst _ period_cycles4 = pst _ div_cycles * (pst _ audf4 + 1); - break; - case 0x28: - pst _ period_cycles3 = 256; - pst _ period_cycles4 = pst _ audf3 + 256 * pst _ audf4 + 7; - pst _ reload_cycles3 = pst _ audf3 + 4; - break; - } - DO_ULTRASOUND(3); - DO_ULTRASOUND(4); - DO_INIT(1, (data & 0x40) == 0); - DO_INIT(2, (data & 0x50) != 0x50); - DO_INIT(3, (data & 0x20) == 0); - DO_INIT(4, (data & 0x28) != 0x28); - break; - case 0x09: - /* TODO: STIMER */ - break; - case 0x0f: - DO_STORE(skctl); - pst _ init = ((data & 3) == 0); - DO_INIT(1, (pst _ audctl & 0x40) == 0); - DO_INIT(2, (pst _ audctl & 0x50) != 0x50); - DO_INIT(3, (pst _ audctl & 0x20) == 0); - DO_INIT(4, (pst _ audctl & 0x28) != 0x28); - break; - default: - break; - } -} - -FUNC(int, PokeySound_GetRandom, (P(ASAP_State PTR, ast), P(int, addr), P(int, cycle))) -{ - V(PokeyState PTR, pst) = (addr & ast _ extra_pokey_mask) != 0 - ? ADDRESSOF ast _ extra_pokey : ADDRESSOF ast _ base_pokey; - V(int, i); - if (pst _ init) - return 0xff; - i = cycle + pst _ poly_index; - if ((pst _ audctl & 0x80) != 0) - return ast _ poly9_lookup[i % 511]; - else { - V(int, j); - i %= 131071; - j = i >> 3; - i &= 7; - return ((ast _ poly17_lookup[j] >> i) + (ast _ poly17_lookup[j + 1] << (8 - i))) & 0xff; - } -} - -PRIVATE FUNC(void, end_frame, (P(ASAP_State PTR, ast), P(PokeyState PTR, pst), P(int, cycle_limit))) -{ - V(int, m); - PokeySound_GenerateUntilCycle(ast, pst, cycle_limit); - pst _ poly_index += cycle_limit; - m = ((pst _ audctl & 0x80) != 0) ? 15 * 31 * 511 : 15 * 31 * 131071; - if (pst _ poly_index >= 2 * m) - pst _ poly_index -= m; - if (pst _ tick_cycle1 != NEVER) - pst _ tick_cycle1 -= cycle_limit; - if (pst _ tick_cycle2 != NEVER) - pst _ tick_cycle2 -= cycle_limit; - if (pst _ tick_cycle3 != NEVER) - pst _ tick_cycle3 -= cycle_limit; - if (pst _ tick_cycle4 != NEVER) - pst _ tick_cycle4 -= cycle_limit; -} - -FUNC(void, PokeySound_StartFrame, (P(ASAP_State PTR, ast))) -{ - ZERO_ARRAY(ast _ base_pokey.delta_buffer); - if (ast _ extra_pokey_mask != 0) - ZERO_ARRAY(ast _ extra_pokey.delta_buffer); -} - -FUNC(void, PokeySound_EndFrame, (P(ASAP_State PTR, ast), P(int, current_cycle))) -{ - V(int, clk) = ASAP_MAIN_CLOCK(ast); - end_frame(ast, ADDRESSOF ast _ base_pokey, current_cycle); - if (ast _ extra_pokey_mask != 0) - end_frame(ast, ADDRESSOF ast _ extra_pokey, current_cycle); - ast _ sample_offset += current_cycle * ASAP_SAMPLE_RATE; - ast _ sample_index = 0; - ast _ samples = TO_INT(ast _ sample_offset / clk); - ast _ sample_offset %= clk; -} - -/* Fills buffer with samples from delta_buffer. */ -FUNC(int, PokeySound_Generate, (P(ASAP_State PTR, ast), P(BYTEARRAY, buffer), P(int, buffer_offset), P(int, blocks), P(ASAP_SampleFormat, format))) -{ - V(int, i) = ast _ sample_index; - V(int, samples) = ast _ samples; - V(int, acc_left) = ast _ iir_acc_left; - V(int, acc_right) = ast _ iir_acc_right; - if (blocks < samples - i) - samples = i + blocks; - else - blocks = samples - i; - for (; i < samples; i++) { -#ifdef ACTIONSCRIPT - acc_left += ast _ base_pokey.delta_buffer[i] - (acc_left * 3 >> 10); - var sample : Number = acc_left / 33553408; - buffer.writeFloat(sample); - if (ast.extra_pokey_mask != 0) { - acc_right += ast _ extra_pokey.delta_buffer[i] - (acc_right * 3 >> 10); - sample = acc_right / 33553408; - } - buffer.writeFloat(sample); -#else - V(int, sample); - acc_left += ast _ base_pokey.delta_buffer[i] - (acc_left * 3 >> 10); - sample = acc_left >> 10; -#define STORE_SAMPLE \ - if (sample < -32767) \ - sample = -32767; \ - else if (sample > 32767) \ - sample = 32767; \ - switch (format) { \ - case ASAP_FORMAT_U8: \ - buffer[buffer_offset++] = CAST(byte) ((sample >> 8) + 128); \ - break; \ - case ASAP_FORMAT_S16_LE: \ - buffer[buffer_offset++] = TO_BYTE(sample); \ - buffer[buffer_offset++] = TO_BYTE(sample >> 8); \ - break; \ - case ASAP_FORMAT_S16_BE: \ - buffer[buffer_offset++] = TO_BYTE(sample >> 8); \ - buffer[buffer_offset++] = TO_BYTE(sample); \ - break; \ - } - STORE_SAMPLE; - if (ast _ extra_pokey_mask != 0) { - acc_right += ast _ extra_pokey.delta_buffer[i] - (acc_right * 3 >> 10); - sample = acc_right >> 10; - STORE_SAMPLE; - } -#endif /* ACTIONSCRIPT */ - } - if (i == ast _ samples) { - acc_left += ast _ base_pokey.delta_buffer[i]; - acc_right += ast _ extra_pokey.delta_buffer[i]; - } - ast _ sample_index = i; - ast _ iir_acc_left = acc_left; - ast _ iir_acc_right = acc_right; -#ifdef APOKEYSND - return buffer_offset; -#else - return blocks; -#endif -} - -FUNC(abool, PokeySound_IsSilent, (P(CONST PokeyState PTR, pst))) -{ - return ((pst _ audc1 | pst _ audc2 | pst _ audc3 | pst _ audc4) & 0xf) == 0; -} - -FUNC(void, PokeySound_Mute, (P(CONST ASAP_State PTR, ast), P(PokeyState PTR, pst), P(int, mask))) -{ - MUTE_CHANNEL(1, (mask & 1) != 0, MUTE_USER); - MUTE_CHANNEL(2, (mask & 2) != 0, MUTE_USER); - MUTE_CHANNEL(3, (mask & 4) != 0, MUTE_USER); - MUTE_CHANNEL(4, (mask & 8) != 0, MUTE_USER); -} - -#ifdef APOKEYSND - -static ASAP_State asap; - -__declspec(dllexport) void APokeySound_Initialize(abool stereo) -{ - asap.extra_pokey_mask = stereo ? 0x10 : 0; - PokeySound_Initialize(&asap); - PokeySound_Mute(&asap, &asap.base_pokey, 0); - PokeySound_Mute(&asap, &asap.extra_pokey, 0); - PokeySound_StartFrame(&asap); -} - -__declspec(dllexport) void APokeySound_PutByte(int addr, int data) -{ - PokeySound_PutByte(&asap, addr, data); -} - -__declspec(dllexport) int APokeySound_GetRandom(int addr, int cycle) -{ - return PokeySound_GetRandom(&asap, addr, cycle); -} - -__declspec(dllexport) int APokeySound_Generate(int cycles, byte buffer[], ASAP_SampleFormat format) -{ - int len; - PokeySound_EndFrame(&asap, cycles); - len = PokeySound_Generate(&asap, buffer, 0, asap.samples, format); - PokeySound_StartFrame(&asap); - return len; -} - -__declspec(dllexport) void APokeySound_About(const char **name, const char **author, const char **description) -{ - *name = "Another POKEY sound emulator, v" ASAP_VERSION; - *author = "Piotr Fusik, (C) " ASAP_YEARS; - *description = "Part of ASAP, http://asap.sourceforge.net"; -} - -#endif /* APOKEYSND */ diff --git a/apps/codecs/libasap/asap.c b/apps/codecs/libasap/asap.c deleted file mode 100644 index 1aeb843fa3..0000000000 --- a/apps/codecs/libasap/asap.c +++ /dev/null @@ -1,2273 +0,0 @@ -/* - * asap.c - ASAP engine - * - * Copyright (C) 2005-2010 Piotr Fusik - * - * This file is part of ASAP (Another Slight Atari Player), - * see http://asap.sourceforge.net - * - * ASAP is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2 of the License, - * or (at your option) any later version. - * - * ASAP is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with ASAP; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "asap_internal.h" - -static byte s_memory[65536]; -static ASAP_ModuleInfo s_module_info; - -#ifdef ASAP_ONLY_INFO - -#define GET_PLAYER(name) NULL - -#else - -#define GET_PLAYER(name) GET_RESOURCE(name, obx) - -FUNC(int, ASAP_GetByte, (P(ASAP_State PTR, ast), P(int, addr))) -{ - switch (addr & 0xff1f) { - case 0xd014: - return ast _ module_info->ntsc ? 0xf : 1; - case 0xd20a: - case 0xd21a: - return PokeySound_GetRandom(ast, addr, ast _ cycle); - case 0xd20e: - return ast _ irqst; - case 0xd21e: - if (ast _ extra_pokey_mask != 0) { - /* interrupts in the extra POKEY not emulated at the moment */ - return 0xff; - } - return ast _ irqst; - case 0xd20c: - case 0xd21c: - case 0xd20f: /* just because some SAP files rely on this */ - case 0xd21f: - return 0xff; - case 0xd40b: - case 0xd41b: - return ast _ scanline_number >> 1; - default: - return dGetByte(addr); - } -} - -FUNC(void, ASAP_PutByte, (P(ASAP_State PTR, ast), P(int, addr), P(int, data))) -{ - if ((addr >> 8) == 0xd2) { - if ((addr & (ast _ extra_pokey_mask + 0xf)) == 0xe) { - ast _ irqst |= data ^ 0xff; -#define SET_TIMER_IRQ(ch) \ - if ((data & ast _ irqst & ch) != 0) { \ - if (ast _ timer##ch##_cycle == NEVER) { \ - V(int, t) = ast _ base_pokey.tick_cycle##ch; \ - while (t < ast _ cycle) \ - t += ast _ base_pokey.period_cycles##ch; \ - ast _ timer##ch##_cycle = t; \ - if (ast _ nearest_event_cycle > t) \ - ast _ nearest_event_cycle = t; \ - } \ - } \ - else \ - ast _ timer##ch##_cycle = NEVER; - SET_TIMER_IRQ(1); - SET_TIMER_IRQ(2); - SET_TIMER_IRQ(4); - } - else - PokeySound_PutByte(ast, addr, data); - } - else if ((addr & 0xff0f) == 0xd40a) { - if (ast _ cycle <= ast _ next_scanline_cycle - 8) - ast _ cycle = ast _ next_scanline_cycle - 8; - else - ast _ cycle = ast _ next_scanline_cycle + 106; - } - else if ((addr & 0xff00) == ast _ module_info->covox_addr) { - V(PokeyState PTR, pst); - addr &= 3; - if (addr == 0 || addr == 3) - pst = ADDRESSOF ast _ base_pokey; - else - pst = ADDRESSOF ast _ extra_pokey; - pst _ delta_buffer[CYCLE_TO_SAMPLE(ast _ cycle)] += (data - UBYTE(ast _ covox[addr])) << DELTA_SHIFT_COVOX; - ast _ covox[addr] = CAST(byte) (data); - } - else if ((addr & 0xff1f) == 0xd01f) { - V(int, sample) = CYCLE_TO_SAMPLE(ast _ cycle); - V(int, delta); - data &= 8; - /* NOT data - ast _ consol; reverse to the POKEY sound */ - delta = (ast _ consol - data) << DELTA_SHIFT_GTIA; - ast _ consol = data; - ast _ base_pokey.delta_buffer[sample] += delta; - ast _ extra_pokey.delta_buffer[sample] += delta; - } - else - dPutByte(addr, data); -} - -#endif /* ASAP_ONLY_INFO */ - -#define UWORD(array, index) (UBYTE(array[index]) + (UBYTE(array[(index) + 1]) << 8)) - -#ifndef ASAP_ONLY_SAP - -#ifndef ASAP_ONLY_INFO - -#ifndef JAVA -#include "players.h" -#endif - -#define CMR_BASS_TABLE_OFFSET 0x70f - -CONST_ARRAY(byte, cmr_bass_table) - 0x5C, 0x56, 0x50, 0x4D, 0x47, 0x44, 0x41, 0x3E, - 0x38, 0x35, CAST(byte) (0x88), 0x7F, 0x79, 0x73, 0x6C, 0x67, - 0x60, 0x5A, 0x55, 0x51, 0x4C, 0x48, 0x43, 0x3F, - 0x3D, 0x39, 0x34, 0x33, 0x30, 0x2D, 0x2A, 0x28, - 0x25, 0x24, 0x21, 0x1F, 0x1E -END_CONST_ARRAY; - -#endif /* ASAP_ONLY_INFO */ - -CONST_ARRAY(int, perframe2fastplay) - 312, 312 / 2, 312 / 3, 312 / 4 -END_CONST_ARRAY; - -/* Loads native module (anything except SAP) and 6502 player routine. */ -PRIVATE FUNC(abool, load_native, ( - P(ASAP_State PTR, ast), P(ASAP_ModuleInfo PTR, module_info), - P(CONST BYTEARRAY, module), P(int, module_len), P(RESOURCE, player))) -{ -#ifndef ASAP_ONLY_INFO - V(int, player_last_byte); -#endif - V(int, music_last_byte); - V(int, block_len); - if ((UBYTE(module[0]) != 0xff || UBYTE(module[1]) != 0xff) - && (module[0] != 0 || module[1] != 0)) /* some CMC and clones start with zeros */ - return FALSE; - module_info _ music = UWORD(module, 2); -#ifndef ASAP_ONLY_INFO - module_info _ player = UWORD(player, 2); - player_last_byte = UWORD(player, 4); - if (module_info _ music <= player_last_byte) - return FALSE; -#endif - music_last_byte = UWORD(module, 4); - if (module_info _ music <= 0xd7ff && music_last_byte >= 0xd000) - return FALSE; - block_len = music_last_byte + 1 - module_info _ music; - if (6 + block_len != module_len) { - V(int, info_addr); - V(int, info_len); - if (module_info _ type != ASAP_TYPE_RMT || 11 + block_len > module_len) - return FALSE; - /* allow optional info for Raster Music Tracker */ - info_addr = UWORD(module, 6 + block_len); - if (info_addr != module_info _ music + block_len) - return FALSE; - info_len = UWORD(module, 8 + block_len) + 1 - info_addr; - if (10 + block_len + info_len != module_len) - return FALSE; - } -#ifndef ASAP_ONLY_INFO - if (ast != NULL) { - COPY_ARRAY(ast _ memory, module_info _ music, module, 6, block_len); - COPY_ARRAY(ast _ memory, module_info _ player, player, 6, player_last_byte + 1 - module_info _ player); - } -#endif - return TRUE; -} - -PRIVATE FUNC(void, set_song_duration, (P(ASAP_ModuleInfo PTR, module_info), P(int, player_calls))) -{ - module_info _ durations[module_info _ songs] = TO_INT(player_calls * module_info _ fastplay * 114000.0 / 1773447); - module_info _ songs++; -} - -#define SEEN_THIS_CALL 1 -#define SEEN_BEFORE 2 -#define SEEN_REPEAT 3 - -PRIVATE FUNC(void, parse_cmc_song, (P(ASAP_ModuleInfo PTR, module_info), P(CONST BYTEARRAY, module), P(int, pos))) -{ - V(int, tempo) = UBYTE(module[0x19]); - V(int, player_calls) = 0; - V(int, rep_start_pos) = 0; - V(int, rep_end_pos) = 0; - V(int, rep_times) = 0; - NEW_ARRAY(byte, seen, 0x55); - INIT_ARRAY(seen); - while (pos >= 0 && pos < 0x55) { - V(int, p1); - V(int, p2); - V(int, p3); - if (pos == rep_end_pos && rep_times > 0) { - for (p1 = 0; p1 < 0x55; p1++) - if (seen[p1] == SEEN_THIS_CALL || seen[p1] == SEEN_REPEAT) - seen[p1] = 0; - rep_times--; - pos = rep_start_pos; - } - if (seen[pos] != 0) { - if (seen[pos] != SEEN_THIS_CALL) - module_info _ loops[module_info _ songs] = TRUE; - break; - } - seen[pos] = SEEN_THIS_CALL; - p1 = UBYTE(module[0x206 + pos]); - p2 = UBYTE(module[0x25b + pos]); - p3 = UBYTE(module[0x2b0 + pos]); - if (p1 == 0xfe || p2 == 0xfe || p3 == 0xfe) { - pos++; - continue; - } - p1 >>= 4; - if (p1 == 8) - break; - if (p1 == 9) { - pos = p2; - continue; - } - if (p1 == 0xa) { - pos -= p2; - continue; - } - if (p1 == 0xb) { - pos += p2; - continue; - } - if (p1 == 0xc) { - tempo = p2; - pos++; - continue; - } - if (p1 == 0xd) { - pos++; - rep_start_pos = pos; - rep_end_pos = pos + p2; - rep_times = p3 - 1; - continue; - } - if (p1 == 0xe) { - module_info _ loops[module_info _ songs] = TRUE; - break; - } - p2 = rep_times > 0 ? SEEN_REPEAT : SEEN_BEFORE; - for (p1 = 0; p1 < 0x55; p1++) - if (seen[p1] == SEEN_THIS_CALL) - seen[p1] = CAST(byte) p2; - player_calls += tempo * (module_info _ type == ASAP_TYPE_CM3 ? 48 : 64); - pos++; - } - set_song_duration(module_info, player_calls); -} - -PRIVATE FUNC(abool, parse_cmc, ( - P(ASAP_State PTR, ast), P(ASAP_ModuleInfo PTR, module_info), - P(CONST BYTEARRAY, module), P(int, module_len), P(int, type), P(RESOURCE, player))) -{ - V(int, last_pos); - V(int, pos); - if (module_len < 0x306) - return FALSE; - module_info _ type = type; - if (!load_native(ast, module_info, module, module_len, player)) - return FALSE; -#ifndef ASAP_ONLY_INFO - if (ast != NULL && type == ASAP_TYPE_CMR) - COPY_ARRAY(ast _ memory, 0x500 + CMR_BASS_TABLE_OFFSET, cmr_bass_table, 0, sizeof(cmr_bass_table)); -#endif - last_pos = 0x54; - while (--last_pos >= 0) { - if (UBYTE(module[0x206 + last_pos]) < 0xb0 - || UBYTE(module[0x25b + last_pos]) < 0x40 - || UBYTE(module[0x2b0 + last_pos]) < 0x40) - break; - if (module_info _ channels == 2) { - if (UBYTE(module[0x306 + last_pos]) < 0xb0 - || UBYTE(module[0x35b + last_pos]) < 0x40 - || UBYTE(module[0x3b0 + last_pos]) < 0x40) - break; - } - } - module_info _ songs = 0; - parse_cmc_song(module_info, module, 0); - for (pos = 0; pos < last_pos && module_info _ songs < ASAP_SONGS_MAX; pos++) - if (UBYTE(module[0x206 + pos]) == 0x8f || UBYTE(module[0x206 + pos]) == 0xef) - parse_cmc_song(module_info, module, pos + 1); - return TRUE; -} - -PRIVATE FUNC(abool, is_dlt_track_empty, (P(CONST BYTEARRAY, module), P(int, pos))) -{ - return UBYTE(module[0x2006 + pos]) >= 0x43 - && UBYTE(module[0x2106 + pos]) >= 0x40 - && UBYTE(module[0x2206 + pos]) >= 0x40 - && UBYTE(module[0x2306 + pos]) >= 0x40; -} - -PRIVATE FUNC(abool, is_dlt_pattern_end, (P(CONST BYTEARRAY, module), P(int, pos), P(int, i))) -{ - V(int, ch); - for (ch = 0; ch < 4; ch++) { - V(int, pattern) = UBYTE(module[0x2006 + (ch << 8) + pos]); - if (pattern < 64) { - V(int, offset) = 6 + (pattern << 7) + (i << 1); - if ((module[offset] & 0x80) == 0 && (module[offset + 1] & 0x80) != 0) - return TRUE; - } - } - return FALSE; -} - -PRIVATE FUNC(void, parse_dlt_song, ( - P(ASAP_ModuleInfo PTR, module_info), P(CONST BYTEARRAY, module), - P(BOOLARRAY, seen), P(int, pos))) -{ - V(int, player_calls) = 0; - V(abool, loop) = FALSE; - V(int, tempo) = 6; - while (pos < 128 && !seen[pos] && is_dlt_track_empty(module, pos)) - seen[pos++] = TRUE; - module_info _ song_pos[module_info _ songs] = CAST(byte) pos; - while (pos < 128) { - V(int, p1); - if (seen[pos]) { - loop = TRUE; - break; - } - seen[pos] = TRUE; - p1 = module[0x2006 + pos]; - if (p1 == 0x40 || is_dlt_track_empty(module, pos)) - break; - if (p1 == 0x41) - pos = UBYTE(module[0x2086 + pos]); - else if (p1 == 0x42) - tempo = UBYTE(module[0x2086 + pos++]); - else { - V(int, i); - for (i = 0; i < 64 && !is_dlt_pattern_end(module, pos, i); i++) - player_calls += tempo; - pos++; - } - } - if (player_calls > 0) { - module_info _ loops[module_info _ songs] = loop; - set_song_duration(module_info, player_calls); - } -} - -PRIVATE FUNC(abool, parse_dlt, ( - P(ASAP_State PTR, ast), P(ASAP_ModuleInfo PTR, module_info), - P(CONST BYTEARRAY, module), P(int, module_len))) -{ - V(int, pos); - NEW_ARRAY(abool, seen, 128); - if (module_len == 0x2c06) { - if (ast != NULL) - ast _ memory[0x4c00] = 0; - } - else if (module_len != 0x2c07) - return FALSE; - module_info _ type = ASAP_TYPE_DLT; - if (!load_native(ast, module_info, module, module_len, GET_PLAYER(dlt)) - || module_info _ music != 0x2000) { - return FALSE; - } - INIT_ARRAY(seen); - module_info _ songs = 0; - for (pos = 0; pos < 128 && module_info _ songs < ASAP_SONGS_MAX; pos++) { - if (!seen[pos]) - parse_dlt_song(module_info, module, seen, pos); - } - return module_info _ songs > 0; -} - -PRIVATE FUNC(void, parse_mpt_song, ( - P(ASAP_ModuleInfo PTR, module_info), P(CONST BYTEARRAY, module), - P(BOOLARRAY, global_seen), P(int, song_len), P(int, pos))) -{ - V(int, addr_to_offset) = UWORD(module, 2) - 6; - V(int, tempo) = UBYTE(module[0x1cf]); - V(int, player_calls) = 0; - NEW_ARRAY(byte, seen, 256); - NEW_ARRAY(int, pattern_offset, 4); - NEW_ARRAY(int, blank_rows, 4); - NEW_ARRAY(int, blank_rows_counter, 4); - INIT_ARRAY(seen); - INIT_ARRAY(blank_rows); - while (pos < song_len) { - V(int, i); - V(int, ch); - V(int, pattern_rows); - if (seen[pos] != 0) { - if (seen[pos] != SEEN_THIS_CALL) - module_info _ loops[module_info _ songs] = TRUE; - break; - } - seen[pos] = SEEN_THIS_CALL; - global_seen[pos] = TRUE; - i = UBYTE(module[0x1d0 + pos * 2]); - if (i == 0xff) { - pos = UBYTE(module[0x1d1 + pos * 2]); - continue; - } - for (ch = 3; ch >= 0; ch--) { - i = UBYTE(module[0x1c6 + ch]) + (UBYTE(module[0x1ca + ch]) << 8) - addr_to_offset; - i = UBYTE(module[i + pos * 2]); - if (i >= 0x40) - break; - i <<= 1; - i = UWORD(module, 0x46 + i); - pattern_offset[ch] = i == 0 ? 0 : i - addr_to_offset; - blank_rows_counter[ch] = 0; - } - if (ch >= 0) - break; - for (i = 0; i < song_len; i++) - if (seen[i] == SEEN_THIS_CALL) - seen[i] = SEEN_BEFORE; - for (pattern_rows = UBYTE(module[0x1ce]); --pattern_rows >= 0; ) { - for (ch = 3; ch >= 0; ch--) { - if (pattern_offset[ch] == 0 || --blank_rows_counter[ch] >= 0) - continue; - for (;;) { - i = UBYTE(module[pattern_offset[ch]++]); - if (i < 0x40 || i == 0xfe) - break; - if (i < 0x80) - continue; - if (i < 0xc0) { - blank_rows[ch] = i - 0x80; - continue; - } - if (i < 0xd0) - continue; - if (i < 0xe0) { - tempo = i - 0xcf; - continue; - } - pattern_rows = 0; - } - blank_rows_counter[ch] = blank_rows[ch]; - } - player_calls += tempo; - } - pos++; - } - if (player_calls > 0) - set_song_duration(module_info, player_calls); -} - -PRIVATE FUNC(abool, parse_mpt, ( - P(ASAP_State PTR, ast), P(ASAP_ModuleInfo PTR, module_info), - P(CONST BYTEARRAY, module), P(int, module_len))) -{ - V(int, track0_addr); - V(int, pos); - V(int, song_len); - /* seen[i] == TRUE if the track position i has been processed */ - NEW_ARRAY(abool, global_seen, 256); - if (module_len < 0x1d0) - return FALSE; - module_info _ type = ASAP_TYPE_MPT; - if (!load_native(ast, module_info, module, module_len, GET_PLAYER(mpt))) - return FALSE; - track0_addr = UWORD(module, 2) + 0x1ca; - if (UBYTE(module[0x1c6]) + (UBYTE(module[0x1ca]) << 8) != track0_addr) - return FALSE; - /* Calculate the length of the first track. Address of the second track minus - address of the first track equals the length of the first track in bytes. - Divide by two to get number of track positions. */ - song_len = (UBYTE(module[0x1c7]) + (UBYTE(module[0x1cb]) << 8) - track0_addr) >> 1; - if (song_len > 0xfe) - return FALSE; - INIT_ARRAY(global_seen); - module_info _ songs = 0; - for (pos = 0; pos < song_len && module_info _ songs < ASAP_SONGS_MAX; pos++) { - if (!global_seen[pos]) { - module_info _ song_pos[module_info _ songs] = CAST(byte) pos; - parse_mpt_song(module_info, module, global_seen, song_len, pos); - } - } - return module_info _ songs > 0; -} - -CONST_ARRAY(byte, rmt_volume_silent) - 16, 8, 4, 3, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1 -END_CONST_ARRAY; - -PRIVATE FUNC(int, rmt_instrument_frames, ( - P(CONST BYTEARRAY, module), P(int, instrument), - P(int, volume), P(int, volume_frame), P(abool, extra_pokey))) -{ - V(int, addr_to_offset) = UWORD(module, 2) - 6; - V(int, per_frame) = module[0xc]; - V(int, player_call); - V(int, player_calls); - V(int, index); - V(int, index_end); - V(int, index_loop); - V(int, volume_slide_depth); - V(int, volume_min); - V(int, volume_slide); - V(abool, silent_loop); - instrument = UWORD(module, 0xe) - addr_to_offset + (instrument << 1); - if (module[instrument + 1] == 0) - return 0; - instrument = UWORD(module, instrument) - addr_to_offset; - player_calls = player_call = volume_frame * per_frame; - index = UBYTE(module[instrument]) + 1 + player_call * 3; - index_end = UBYTE(module[instrument + 2]) + 3; - index_loop = UBYTE(module[instrument + 3]); - if (index_loop >= index_end) - return 0; /* error */ - volume_slide_depth = UBYTE(module[instrument + 6]); - volume_min = UBYTE(module[instrument + 7]); - if (index >= index_end) - index = (index - index_end) % (index_end - index_loop) + index_loop; - else { - do { - V(int, vol) = module[instrument + index]; - if (extra_pokey) - vol >>= 4; - if ((vol & 0xf) >= rmt_volume_silent[volume]) - player_calls = player_call + 1; - player_call++; - index += 3; - } while (index < index_end); - } - if (volume_slide_depth == 0) - return player_calls / per_frame; - volume_slide = 128; - silent_loop = FALSE; - for (;;) { - V(int, vol); - if (index >= index_end) { - if (silent_loop) - break; - silent_loop = TRUE; - index = index_loop; - } - vol = module[instrument + index]; - if (extra_pokey) - vol >>= 4; - if ((vol & 0xf) >= rmt_volume_silent[volume]) { - player_calls = player_call + 1; - silent_loop = FALSE; - } - player_call++; - index += 3; - volume_slide -= volume_slide_depth; - if (volume_slide < 0) { - volume_slide += 256; - if (--volume <= volume_min) - break; - } - } - return player_calls / per_frame; -} - -PRIVATE FUNC(void, parse_rmt_song, ( - P(ASAP_ModuleInfo PTR, module_info), P(CONST BYTEARRAY, module), - P(BOOLARRAY, global_seen), P(int, song_len), P(int, pos_shift), P(int, pos))) -{ - V(int, ch); - V(int, addr_to_offset) = UWORD(module, 2) - 6; - V(int, tempo) = UBYTE(module[0xb]); - V(int, frames) = 0; - V(int, song_offset) = UWORD(module, 0x14) - addr_to_offset; - V(int, pattern_lo_offset) = UWORD(module, 0x10) - addr_to_offset; - V(int, pattern_hi_offset) = UWORD(module, 0x12) - addr_to_offset; - V(int, instrument_frames); - NEW_ARRAY(byte, seen, 256); - NEW_ARRAY(int, pattern_begin, 8); - NEW_ARRAY(int, pattern_offset, 8); - NEW_ARRAY(int, blank_rows, 8); - NEW_ARRAY(int, instrument_no, 8); - NEW_ARRAY(int, instrument_frame, 8); - NEW_ARRAY(int, volume_value, 8); - NEW_ARRAY(int, volume_frame, 8); - INIT_ARRAY(seen); - INIT_ARRAY(instrument_no); - INIT_ARRAY(instrument_frame); - INIT_ARRAY(volume_value); - INIT_ARRAY(volume_frame); - while (pos < song_len) { - V(int, i); - V(int, pattern_rows); - if (seen[pos] != 0) { - if (seen[pos] != SEEN_THIS_CALL) - module_info _ loops[module_info _ songs] = TRUE; - break; - } - seen[pos] = SEEN_THIS_CALL; - global_seen[pos] = TRUE; - if (UBYTE(module[song_offset + (pos << pos_shift)]) == 0xfe) { - pos = UBYTE(module[song_offset + (pos << pos_shift) + 1]); - continue; - } - for (ch = 0; ch < 1 << pos_shift; ch++) { - i = UBYTE(module[song_offset + (pos << pos_shift) + ch]); - if (i == 0xff) - blank_rows[ch] = 256; - else { - pattern_offset[ch] = pattern_begin[ch] = UBYTE(module[pattern_lo_offset + i]) - + (UBYTE(module[pattern_hi_offset + i]) << 8) - addr_to_offset; - blank_rows[ch] = 0; - } - } - for (i = 0; i < song_len; i++) - if (seen[i] == SEEN_THIS_CALL) - seen[i] = SEEN_BEFORE; - for (pattern_rows = UBYTE(module[0xa]); --pattern_rows >= 0; ) { - for (ch = 0; ch < 1 << pos_shift; ch++) { - if (--blank_rows[ch] > 0) - continue; - for (;;) { - i = UBYTE(module[pattern_offset[ch]++]); - if ((i & 0x3f) < 62) { - i += UBYTE(module[pattern_offset[ch]++]) << 8; - if ((i & 0x3f) != 61) { - instrument_no[ch] = i >> 10; - instrument_frame[ch] = frames; - } - volume_value[ch] = (i >> 6) & 0xf; - volume_frame[ch] = frames; - break; - } - if (i == 62) { - blank_rows[ch] = UBYTE(module[pattern_offset[ch]++]); - break; - } - if ((i & 0x3f) == 62) { - blank_rows[ch] = i >> 6; - break; - } - if ((i & 0xbf) == 63) { - tempo = UBYTE(module[pattern_offset[ch]++]); - continue; - } - if (i == 0xbf) { - pattern_offset[ch] = pattern_begin[ch] + UBYTE(module[pattern_offset[ch]]); - continue; - } - /* assert(i == 0xff); */ - pattern_rows = -1; - break; - } - if (pattern_rows < 0) - break; - } - if (pattern_rows >= 0) - frames += tempo; - } - pos++; - } - instrument_frames = 0; - for (ch = 0; ch < 1 << pos_shift; ch++) { - V(int, frame) = instrument_frame[ch]; - frame += rmt_instrument_frames(module, instrument_no[ch], volume_value[ch], volume_frame[ch] - frame, ch >= 4); - if (instrument_frames < frame) - instrument_frames = frame; - } - if (frames > instrument_frames) { - if (frames - instrument_frames > 100) - module_info _ loops[module_info _ songs] = FALSE; - frames = instrument_frames; - } - if (frames > 0) - set_song_duration(module_info, frames); -} - -PRIVATE FUNC(abool, parse_rmt, ( - P(ASAP_State PTR, ast), P(ASAP_ModuleInfo PTR, module_info), - P(CONST BYTEARRAY, module), P(int, module_len))) -{ - V(int, per_frame); - V(int, pos_shift); - V(int, song_len); - V(int, pos); - NEW_ARRAY(abool, global_seen, 256); - if (module_len < 0x30 || module[6] != CHARCODE('R') || module[7] != CHARCODE('M') - || module[8] != CHARCODE('T') || module[0xd] != 1) - return FALSE; - switch (CAST(char) module[9]) { - case CHARCODE('4'): - pos_shift = 2; - break; - case CHARCODE('8'): - module_info _ channels = 2; - pos_shift = 3; - break; - default: - return FALSE; - } - per_frame = module[0xc]; - if (per_frame < 1 || per_frame > 4) - return FALSE; - module_info _ type = ASAP_TYPE_RMT; - if (!load_native(ast, module_info, module, module_len, - module_info _ channels == 2 ? GET_PLAYER(rmt8) : GET_PLAYER(rmt4))) - return FALSE; - song_len = UWORD(module, 4) + 1 - UWORD(module, 0x14); - if (pos_shift == 3 && (song_len & 4) != 0 - && UBYTE(module[6 + UWORD(module, 4) - UWORD(module, 2) - 3]) == 0xfe) - song_len += 4; - song_len >>= pos_shift; - if (song_len >= 0x100) - return FALSE; - INIT_ARRAY(global_seen); - module_info _ songs = 0; - for (pos = 0; pos < song_len && module_info _ songs < ASAP_SONGS_MAX; pos++) { - if (!global_seen[pos]) { - module_info _ song_pos[module_info _ songs] = CAST(byte) pos; - parse_rmt_song(module_info, module, global_seen, song_len, pos_shift, pos); - } - } - /* must set fastplay after song durations calculations, so they assume 312 */ - module_info _ fastplay = perframe2fastplay[per_frame - 1]; - module_info _ player = 0x600; - return module_info _ songs > 0; -} - -PRIVATE FUNC(void, parse_tmc_song, ( - P(ASAP_ModuleInfo PTR, module_info), P(CONST BYTEARRAY, module), P(int, pos))) -{ - V(int, addr_to_offset) = UWORD(module, 2) - 6; - V(int, tempo) = UBYTE(module[0x24]) + 1; - V(int, frames) = 0; - NEW_ARRAY(int, pattern_offset, 8); - NEW_ARRAY(int, blank_rows, 8); - while (UBYTE(module[0x1a6 + 15 + pos]) < 0x80) { - V(int, ch); - V(int, pattern_rows); - for (ch = 7; ch >= 0; ch--) { - V(int, pat) = UBYTE(module[0x1a6 + 15 + pos - 2 * ch]); - pattern_offset[ch] = UBYTE(module[0xa6 + pat]) + (UBYTE(module[0x126 + pat]) << 8) - addr_to_offset; - blank_rows[ch] = 0; - } - for (pattern_rows = 64; --pattern_rows >= 0; ) { - for (ch = 7; ch >= 0; ch--) { - if (--blank_rows[ch] >= 0) - continue; - for (;;) { - V(int, i) = UBYTE(module[pattern_offset[ch]++]); - if (i < 0x40) { - pattern_offset[ch]++; - break; - } - if (i == 0x40) { - i = UBYTE(module[pattern_offset[ch]++]); - if ((i & 0x7f) == 0) - pattern_rows = 0; - else - tempo = (i & 0x7f) + 1; - if (i >= 0x80) - pattern_offset[ch]++; - break; - } - if (i < 0x80) { - i = module[pattern_offset[ch]++] & 0x7f; - if (i == 0) - pattern_rows = 0; - else - tempo = i + 1; - pattern_offset[ch]++; - break; - } - if (i < 0xc0) - continue; - blank_rows[ch] = i - 0xbf; - break; - } - } - frames += tempo; - } - pos += 16; - } - if (UBYTE(module[0x1a6 + 14 + pos]) < 0x80) - module_info _ loops[module_info _ songs] = TRUE; - set_song_duration(module_info, frames); -} - -PRIVATE FUNC(abool, parse_tmc, ( - P(ASAP_State PTR, ast), P(ASAP_ModuleInfo PTR, module_info), - P(CONST BYTEARRAY, module), P(int, module_len))) -{ - V(int, i); - V(int, last_pos); - if (module_len < 0x1d0) - return FALSE; - module_info _ type = ASAP_TYPE_TMC; - if (!load_native(ast, module_info, module, module_len, GET_PLAYER(tmc))) - return FALSE; - module_info _ channels = 2; - i = 0; - /* find first instrument */ - while (module[0x66 + i] == 0) { - if (++i >= 64) - return FALSE; /* no instrument */ - } - last_pos = (UBYTE(module[0x66 + i]) << 8) + UBYTE(module[0x26 + i]) - - UWORD(module, 2) - 0x1b0; - if (0x1b5 + last_pos >= module_len) - return FALSE; - /* skip trailing jumps */ - do { - if (last_pos <= 0) - return FALSE; /* no pattern to play */ - last_pos -= 16; - } while (UBYTE(module[0x1b5 + last_pos]) >= 0x80); - module_info _ songs = 0; - parse_tmc_song(module_info, module, 0); - for (i = 0; i < last_pos && module_info _ songs < ASAP_SONGS_MAX; i += 16) - if (UBYTE(module[0x1b5 + i]) >= 0x80) - parse_tmc_song(module_info, module, i + 16); - /* must set fastplay after song durations calculations, so they assume 312 */ - i = module[0x25]; - if (i < 1 || i > 4) - return FALSE; - if (ast != NULL) - ast _ tmc_per_frame = module[0x25]; - module_info _ fastplay = perframe2fastplay[i - 1]; - return TRUE; -} - -PRIVATE FUNC(void, parse_tm2_song, ( - P(ASAP_ModuleInfo PTR, module_info), P(CONST BYTEARRAY, module), P(int, pos))) -{ - V(int, addr_to_offset) = UWORD(module, 2) - 6; - V(int, tempo) = UBYTE(module[0x24]) + 1; - V(int, player_calls) = 0; - NEW_ARRAY(int, pattern_offset, 8); - NEW_ARRAY(int, blank_rows, 8); - for (;;) { - V(int, ch); - V(int, pattern_rows) = UBYTE(module[0x386 + 16 + pos]); - if (pattern_rows == 0) - break; - if (pattern_rows >= 0x80) { - module_info _ loops[module_info _ songs] = TRUE; - break; - } - for (ch = 7; ch >= 0; ch--) { - V(int, pat) = UBYTE(module[0x386 + 15 + pos - 2 * ch]); - pattern_offset[ch] = UBYTE(module[0x106 + pat]) + (UBYTE(module[0x206 + pat]) << 8) - addr_to_offset; - blank_rows[ch] = 0; - } - while (--pattern_rows >= 0) { - for (ch = 7; ch >= 0; ch--) { - if (--blank_rows[ch] >= 0) - continue; - for (;;) { - V(int, i) = UBYTE(module[pattern_offset[ch]++]); - if (i == 0) { - pattern_offset[ch]++; - break; - } - if (i < 0x40) { - if (UBYTE(module[pattern_offset[ch]++]) >= 0x80) - pattern_offset[ch]++; - break; - } - if (i < 0x80) { - pattern_offset[ch]++; - break; - } - if (i == 0x80) { - blank_rows[ch] = UBYTE(module[pattern_offset[ch]++]); - break; - } - if (i < 0xc0) - break; - if (i < 0xd0) { - tempo = i - 0xbf; - continue; - } - if (i < 0xe0) { - pattern_offset[ch]++; - break; - } - if (i < 0xf0) { - pattern_offset[ch] += 2; - break; - } - if (i < 0xff) { - blank_rows[ch] = i - 0xf0; - break; - } - blank_rows[ch] = 64; - break; - } - } - player_calls += tempo; - } - pos += 17; - } - set_song_duration(module_info, player_calls); -} - -PRIVATE FUNC(abool, parse_tm2, ( - P(ASAP_State PTR, ast), P(ASAP_ModuleInfo PTR, module_info), - P(CONST BYTEARRAY, module), P(int, module_len))) -{ - V(int, i); - V(int, last_pos); - V(int, c); - if (module_len < 0x3a4) - return FALSE; - module_info _ type = ASAP_TYPE_TM2; - if (!load_native(ast, module_info, module, module_len, GET_PLAYER(tm2))) - return FALSE; - i = module[0x25]; - if (i < 1 || i > 4) - return FALSE; - module_info _ fastplay = perframe2fastplay[i - 1]; - module_info _ player = 0x500; - if (module[0x1f] != 0) - module_info _ channels = 2; - last_pos = 0xffff; - for (i = 0; i < 0x80; i++) { - V(int, instr_addr) = UBYTE(module[0x86 + i]) + (UBYTE(module[0x306 + i]) << 8); - if (instr_addr != 0 && instr_addr < last_pos) - last_pos = instr_addr; - } - for (i = 0; i < 0x100; i++) { - V(int, pattern_addr) = UBYTE(module[0x106 + i]) + (UBYTE(module[0x206 + i]) << 8); - if (pattern_addr != 0 && pattern_addr < last_pos) - last_pos = pattern_addr; - } - last_pos -= UWORD(module, 2) + 0x380; - if (0x386 + last_pos >= module_len) - return FALSE; - /* skip trailing stop/jump commands */ - do { - if (last_pos <= 0) - return FALSE; - last_pos -= 17; - c = UBYTE(module[0x386 + 16 + last_pos]); - } while (c == 0 || c >= 0x80); - module_info _ songs = 0; - parse_tm2_song(module_info, module, 0); - for (i = 0; i < last_pos && module_info _ songs < ASAP_SONGS_MAX; i += 17) { - c = UBYTE(module[0x386 + 16 + i]); - if (c == 0 || c >= 0x80) - parse_tm2_song(module_info, module, i + 17); - } - return TRUE; -} - -#endif /* ASAP_ONLY_SAP */ - -PRIVATE FUNC(abool, has_string_at, (P(CONST BYTEARRAY, module), P(int, module_index), P(STRING, s))) -{ - V(int, i); - V(int, n) = strlen(s); - for (i = 0; i < n; i++) - if (module[module_index + i] != CHARCODEAT(s, i)) - return FALSE; - return TRUE; -} - -PRIVATE FUNC(STRING, parse_text, (P(OUT_STRING, dest), P(CONST BYTEARRAY, module), P(int, module_index))) -{ - V(int, i); - if (module[module_index] != CHARCODE('"')) - return NULL; - if (has_string_at(module, module_index + 1, "\"")) - return dest; - for (i = 0; ; i++) { - V(int, c) = module[module_index + 1 + i]; - if (c == CHARCODE('"')) - break; - if (c < 32 || c >= 127) - return NULL; - } - BYTES_TO_STRING(dest, module, module_index + 1, i); - return dest; -} - -PRIVATE FUNC(int, parse_dec, (P(CONST BYTEARRAY, module), P(int, module_index), P(int, maxval))) -{ - V(int, r); - if (module[module_index] == 0xd) - return -1; - for (r = 0;;) { - V(int, c) = module[module_index++]; - if (c == 0xd) - break; - if (c < CHARCODE('0') || c > CHARCODE('9')) - return -1; - r = 10 * r + c - 48; - if (r > maxval) - return -1; - } - return r; -} - -PRIVATE FUNC(int, parse_hex, (P(CONST BYTEARRAY, module), P(int, module_index))) -{ - V(int, r); - if (module[module_index] == 0xd) - return -1; - for (r = 0;;) { - V(int, c) = module[module_index++]; - if (c == 0xd) - break; - if (r > 0xfff) - return -1; - r <<= 4; - if (c >= CHARCODE('0') && c <= CHARCODE('9')) - r += c - CHARCODE('0'); - else if (c >= CHARCODE('A') && c <= CHARCODE('F')) - r += c - CHARCODE('A') + 10; - else if (c >= CHARCODE('a') && c <= CHARCODE('f')) - r += c - CHARCODE('a') + 10; - else - return -1; - } - return r; -} - -FUNC(int, ASAP_ParseDuration, (P(STRING, s))) -{ - V(int, i) = 0; - V(int, r); - V(int, d); - V(int, n) = strlen(s); -#define PARSE_DIGIT(maxdig, retifnot) \ - if (i >= n) \ - return retifnot; \ - d = CHARCODEAT(s, i) - 48; \ - if (d < 0 || d > maxdig) \ - return -1; \ - i++; - - PARSE_DIGIT(9, -1); - r = d; - if (i < n) { - d = CHARCODEAT(s, i) - 48; - if (d >= 0 && d <= 9) { - i++; - r = 10 * r + d; - } - if (i < n && CHARAT(s, i) == ':') { - i++; - PARSE_DIGIT(5, -1); - r = (6 * r + d) * 10; - PARSE_DIGIT(9, -1); - r += d; - } - } - r *= 1000; - if (i >= n) - return r; - if (CHARAT(s, i) != '.') - return -1; - i++; - PARSE_DIGIT(9, -1); - r += 100 * d; - PARSE_DIGIT(9, r); - r += 10 * d; - PARSE_DIGIT(9, r); - r += d; - return r; -} - -PRIVATE FUNC(abool, parse_sap_header, ( - P(ASAP_ModuleInfo PTR, module_info), P(CONST BYTEARRAY, module), P(int, module_len))) -{ - V(int, module_index); - V(int, type) = 0; - V(int, duration_index) = 0; - if (!has_string_at(module, 0, "SAP\r\n")) - return FALSE; - module_info _ fastplay = -1; - module_index = 5; - while (UBYTE(module[module_index]) != 0xff) { - if (module_index + 8 >= module_len) - return FALSE; -#define TAG_IS(s) has_string_at(module, module_index, s) -#ifdef C -#define SET_TEXT(v, i) if (parse_text(v, module, module_index + i) == NULL) return FALSE -#else -#define SET_TEXT(v, i) v = parse_text(v, module, module_index + i); if (v == NULL) return FALSE -#endif -#define SET_DEC(v, i, min, max) v = parse_dec(module, module_index + i, max); if (v < min) return FALSE -#define SET_HEX(v, i) v = parse_hex(module, module_index + i) - if (TAG_IS("AUTHOR ")) { - SET_TEXT(module_info _ author, 7); - } - else if (TAG_IS("NAME ")) { - SET_TEXT(module_info _ name, 5); - } - else if (TAG_IS("DATE ")) { - SET_TEXT(module_info _ date, 5); - } - else if (TAG_IS("SONGS ")) { - SET_DEC(module_info _ songs, 6, 1, ASAP_SONGS_MAX); - } - else if (TAG_IS("DEFSONG ")) { - SET_DEC(module_info _ default_song, 8, 0, ASAP_SONGS_MAX - 1); - } - else if (TAG_IS("STEREO\r")) - module_info _ channels = 2; - else if (TAG_IS("NTSC\r")) - module_info _ ntsc = TRUE; - else if (TAG_IS("TIME ")) { - V(int, i); -#ifdef C - char s[ASAP_DURATION_CHARS]; -#else - V(STRING, s); -#endif - module_index += 5; - for (i = 0; module[module_index + i] != 0xd; i++) { } - if (i > 5 && has_string_at(module, module_index + i - 5, " LOOP")) { - module_info _ loops[duration_index] = TRUE; - i -= 5; - } -#ifdef C - if (i >= ASAP_DURATION_CHARS) - return FALSE; -#endif - BYTES_TO_STRING(s, module, module_index, i); - i = ASAP_ParseDuration(s); - if (i < 0 || duration_index >= ASAP_SONGS_MAX) - return FALSE; - module_info _ durations[duration_index++] = i; - } - else if (TAG_IS("TYPE ")) - type = module[module_index + 5]; - else if (TAG_IS("FASTPLAY ")) { - SET_DEC(module_info _ fastplay, 9, 1, 312); - } - else if (TAG_IS("MUSIC ")) { - SET_HEX(module_info _ music, 6); - } - else if (TAG_IS("INIT ")) { - SET_HEX(module_info _ init, 5); - } - else if (TAG_IS("PLAYER ")) { - SET_HEX(module_info _ player, 7); - } - else if (TAG_IS("COVOX ")) { - SET_HEX(module_info _ covox_addr, 6); - if (module_info _ covox_addr != 0xd600) - return FALSE; - module_info _ channels = 2; - } - - while (module[module_index++] != 0x0d) { - if (module_index >= module_len) - return FALSE; - } - if (module[module_index++] != 0x0a) - return FALSE; - } - if (module_info _ default_song >= module_info _ songs) - return FALSE; - switch (type) { - case CHARCODE('B'): - if (module_info _ player < 0 || module_info _ init < 0) - return FALSE; - module_info _ type = ASAP_TYPE_SAP_B; - break; - case CHARCODE('C'): - if (module_info _ player < 0 || module_info _ music < 0) - return FALSE; - module_info _ type = ASAP_TYPE_SAP_C; - break; - case CHARCODE('D'): - if (module_info _ init < 0) - return FALSE; - module_info _ type = ASAP_TYPE_SAP_D; - break; - case CHARCODE('S'): - if (module_info _ init < 0) - return FALSE; - module_info _ type = ASAP_TYPE_SAP_S; - module_info _ fastplay = 78; - break; - default: - return FALSE; - } - if (module_info _ fastplay < 0) - module_info _ fastplay = module_info _ ntsc ? 262 : 312; - else if (module_info _ ntsc && module_info _ fastplay > 262) - return FALSE; - if (UBYTE(module[module_index + 1]) != 0xff) - return FALSE; - module_info _ header_len = module_index; - return TRUE; -} - -PRIVATE FUNC(abool, parse_sap, ( - P(ASAP_State PTR, ast), P(ASAP_ModuleInfo PTR, module_info), - P(CONST BYTEARRAY, module), P(int, module_len))) -{ - V(int, module_index); - if (!parse_sap_header(module_info, module, module_len)) - return FALSE; - if (ast == NULL) - return TRUE; - ZERO_ARRAY(ast _ memory); - module_index = module_info _ header_len + 2; - while (module_index + 5 <= module_len) { - V(int, start_addr) = UWORD(module, module_index); - V(int, block_len) = UWORD(module, module_index + 2) + 1 - start_addr; - if (block_len <= 0 || module_index + block_len > module_len) - return FALSE; - module_index += 4; - COPY_ARRAY(ast _ memory, start_addr, module, module_index, block_len); - module_index += block_len; - if (module_index == module_len) - return TRUE; - if (module_index + 7 <= module_len - && UBYTE(module[module_index]) == 0xff && UBYTE(module[module_index + 1]) == 0xff) - module_index += 2; - } - return FALSE; -} - -#define ASAP_EXT(c1, c2, c3) ((CHARCODE(c1) + (CHARCODE(c2) << 8) + (CHARCODE(c3) << 16)) | 0x202020) - -PRIVATE FUNC(int, get_packed_ext, (P(STRING, filename))) -{ - V(int, i) = strlen(filename); - V(int, ext) = 0; - while (--i > 0) { - V(char, c) = CHARAT(filename, i); - if (c <= ' ' || c > 'z') - return 0; - if (c == '.') - return ext | 0x202020; - ext = (ext << 8) + CHARCODE(c); - } - return 0; -} - -PRIVATE FUNC(abool, is_our_ext, (P(int, ext))) -{ - switch (ext) { - case ASAP_EXT('S', 'A', 'P'): -#ifndef ASAP_ONLY_SAP - case ASAP_EXT('C', 'M', 'C'): - case ASAP_EXT('C', 'M', '3'): - case ASAP_EXT('C', 'M', 'R'): - case ASAP_EXT('C', 'M', 'S'): - case ASAP_EXT('D', 'M', 'C'): - case ASAP_EXT('D', 'L', 'T'): - case ASAP_EXT('M', 'P', 'T'): - case ASAP_EXT('M', 'P', 'D'): - case ASAP_EXT('R', 'M', 'T'): - case ASAP_EXT('T', 'M', 'C'): - case ASAP_EXT('T', 'M', '8'): - case ASAP_EXT('T', 'M', '2'): -#endif - return TRUE; - default: - return FALSE; - } -} - -FUNC(abool, ASAP_IsOurFile, (P(STRING, filename))) -{ - V(int, ext) = get_packed_ext(filename); - return is_our_ext(ext); -} - -FUNC(abool, ASAP_IsOurExt, (P(STRING, ext))) -{ - return strlen(ext) == 3 - && is_our_ext(ASAP_EXT(CHARAT(ext, 0), CHARAT(ext, 1), CHARAT(ext, 2))); -} - -PRIVATE FUNC(abool, parse_file, ( - P(ASAP_State PTR, ast), P(ASAP_ModuleInfo PTR, module_info), - P(STRING, filename), P(CONST BYTEARRAY, module), P(int, module_len))) -{ - V(int, i); - V(int, len) = strlen(filename); - V(int, basename) = 0; - V(int, ext) = -1; - for (i = 0; i < len; i++) { - V(char, c) = CHARAT(filename, i); - if (c == '/' || c == '\\') { - basename = i + 1; - ext = -1; - } - else if (c == '.') - ext = i; - } - if (ext < 0) - return FALSE; - EMPTY_STRING(module_info _ author); - SUBSTRING(module_info _ name, filename, basename, ext - basename); - EMPTY_STRING(module_info _ date); - module_info _ channels = 1; - module_info _ songs = 1; - module_info _ default_song = 0; - for (i = 0; i < ASAP_SONGS_MAX; i++) { - module_info _ durations[i] = -1; - module_info _ loops[i] = FALSE; - } - module_info _ ntsc = FALSE; - module_info _ fastplay = 312; - module_info _ music = -1; - module_info _ init = -1; - module_info _ player = -1; - module_info _ covox_addr = -1; - switch (get_packed_ext(filename)) { - case ASAP_EXT('S', 'A', 'P'): - return parse_sap(ast, module_info, module, module_len); -#ifndef ASAP_ONLY_SAP - case ASAP_EXT('C', 'M', 'C'): - return parse_cmc(ast, module_info, module, module_len, ASAP_TYPE_CMC, GET_PLAYER(cmc)); - case ASAP_EXT('C', 'M', '3'): - return parse_cmc(ast, module_info, module, module_len, ASAP_TYPE_CM3, GET_PLAYER(cm3)); - case ASAP_EXT('C', 'M', 'R'): - return parse_cmc(ast, module_info, module, module_len, ASAP_TYPE_CMR, GET_PLAYER(cmc)); - case ASAP_EXT('C', 'M', 'S'): - module_info _ channels = 2; - return parse_cmc(ast, module_info, module, module_len, ASAP_TYPE_CMS, GET_PLAYER(cms)); - case ASAP_EXT('D', 'M', 'C'): - module_info _ fastplay = 156; - return parse_cmc(ast, module_info, module, module_len, ASAP_TYPE_CMC, GET_PLAYER(cmc)); - case ASAP_EXT('D', 'L', 'T'): - return parse_dlt(ast, module_info, module, module_len); - case ASAP_EXT('M', 'P', 'T'): - return parse_mpt(ast, module_info, module, module_len); - case ASAP_EXT('M', 'P', 'D'): - module_info _ fastplay = 156; - return parse_mpt(ast, module_info, module, module_len); - case ASAP_EXT('R', 'M', 'T'): - return parse_rmt(ast, module_info, module, module_len); - case ASAP_EXT('T', 'M', 'C'): - case ASAP_EXT('T', 'M', '8'): - return parse_tmc(ast, module_info, module, module_len); - case ASAP_EXT('T', 'M', '2'): - return parse_tm2(ast, module_info, module, module_len); -#endif - default: - return FALSE; - } -} - -FUNC(abool, ASAP_GetModuleInfo, ( - P(ASAP_ModuleInfo PTR, module_info), P(STRING, filename), - P(CONST BYTEARRAY, module), P(int, module_len))) -{ - return parse_file(NULL, module_info, filename, module, module_len); -} - -#ifndef ASAP_ONLY_INFO - -FUNC(abool, ASAP_Load, ( - P(ASAP_State PTR, ast), P(STRING, filename), - P(CONST BYTEARRAY, module), P(int, module_len))) -{ - /* Set up ast */ - ast _ memory = s_memory; - ast _ module_info = &s_module_info; - ast _ silence_cycles = 0; - return parse_file(ast, ast _ module_info, filename, module, module_len); -} - -FUNC(void, ASAP_DetectSilence, (P(ASAP_State PTR, ast), P(int, seconds))) -{ - ast _ silence_cycles = seconds * ASAP_MAIN_CLOCK(ast); -} - -PRIVATE FUNC(void, call_6502, (P(ASAP_State PTR, ast), P(int, addr), P(int, max_scanlines))) -{ - ast _ cpu_pc = addr; - /* put a CIM at 0xd20a and a return address on stack */ - dPutByte(0xd20a, 0xd2); - dPutByte(0x01fe, 0x09); - dPutByte(0x01ff, 0xd2); - ast _ cpu_s = 0xfd; - Cpu_RunScanlines(ast, max_scanlines); -} - -/* 50 Atari frames for the initialization routine - some SAPs are self-extracting. */ -#define SCANLINES_FOR_INIT (50 * 312) - -PRIVATE FUNC(void, call_6502_init, (P(ASAP_State PTR, ast), P(int, addr), P(int, a), P(int, x), P(int, y))) -{ - ast _ cpu_a = a & 0xff; - ast _ cpu_x = x & 0xff; - ast _ cpu_y = y & 0xff; - call_6502(ast, addr, SCANLINES_FOR_INIT); -} - -FUNC(void, ASAP_PlaySong, (P(ASAP_State PTR, ast), P(int, song), P(int, duration))) -{ - ast _ current_song = song; - ast _ current_duration = duration; - ast _ blocks_played = 0; - ast _ silence_cycles_counter = ast _ silence_cycles; - ast _ extra_pokey_mask = ast _ module_info->channels > 1 ? 0x10 : 0; - ast _ consol = 8; - ast _ covox[0] = CAST(byte) 0x80; - ast _ covox[1] = CAST(byte) 0x80; - ast _ covox[2] = CAST(byte) 0x80; - ast _ covox[3] = CAST(byte) 0x80; - PokeySound_Initialize(ast); - ast _ cycle = 0; - ast _ cpu_nz = 0; - ast _ cpu_c = 0; - ast _ cpu_vdi = 0; - ast _ scanline_number = 0; - ast _ next_scanline_cycle = 0; - ast _ timer1_cycle = NEVER; - ast _ timer2_cycle = NEVER; - ast _ timer4_cycle = NEVER; - ast _ irqst = 0xff; - switch (ast _ module_info->type) { - case ASAP_TYPE_SAP_B: - call_6502_init(ast, ast _ module_info->init, song, 0, 0); - break; - case ASAP_TYPE_SAP_C: -#ifndef ASAP_ONLY_SAP - case ASAP_TYPE_CMC: - case ASAP_TYPE_CM3: - case ASAP_TYPE_CMR: - case ASAP_TYPE_CMS: -#endif - call_6502_init(ast, ast _ module_info->player + 3, 0x70, ast _ module_info->music, ast _ module_info->music >> 8); - call_6502_init(ast, ast _ module_info->player + 3, 0x00, song, 0); - break; - case ASAP_TYPE_SAP_D: - case ASAP_TYPE_SAP_S: - ast _ cpu_a = song; - ast _ cpu_x = 0x00; - ast _ cpu_y = 0x00; - ast _ cpu_s = 0xff; - ast _ cpu_pc = ast _ module_info->init; - break; -#ifndef ASAP_ONLY_SAP - case ASAP_TYPE_DLT: - call_6502_init(ast, ast _ module_info->player + 0x100, 0x00, 0x00, ast _ module_info->song_pos[song]); - break; - case ASAP_TYPE_MPT: - call_6502_init(ast, ast _ module_info->player, 0x00, ast _ module_info->music >> 8, ast _ module_info->music); - call_6502_init(ast, ast _ module_info->player, 0x02, ast _ module_info->song_pos[song], 0); - break; - case ASAP_TYPE_RMT: - call_6502_init(ast, ast _ module_info->player, ast _ module_info->song_pos[song], ast _ module_info->music, ast _ module_info->music >> 8); - break; - case ASAP_TYPE_TMC: - case ASAP_TYPE_TM2: - call_6502_init(ast, ast _ module_info->player, 0x70, ast _ module_info->music >> 8, ast _ module_info->music); - call_6502_init(ast, ast _ module_info->player, 0x00, song, 0); - ast _ tmc_per_frame_counter = 1; - break; -#endif - } - ASAP_MutePokeyChannels(ast, 0); -} - -FUNC(void, ASAP_MutePokeyChannels, (P(ASAP_State PTR, ast), P(int, mask))) -{ - PokeySound_Mute(ast, ADDRESSOF ast _ base_pokey, mask); - PokeySound_Mute(ast, ADDRESSOF ast _ extra_pokey, mask >> 4); -} - -FUNC(abool, call_6502_player, (P(ASAP_State PTR, ast))) -{ - V(int, player) = ast _ module_info->player; - PokeySound_StartFrame(ast); - switch (ast _ module_info->type) { - case ASAP_TYPE_SAP_B: - call_6502(ast, player, ast _ module_info->fastplay); - break; - case ASAP_TYPE_SAP_C: -#ifndef ASAP_ONLY_SAP - case ASAP_TYPE_CMC: - case ASAP_TYPE_CM3: - case ASAP_TYPE_CMR: - case ASAP_TYPE_CMS: -#endif - call_6502(ast, player + 6, ast _ module_info->fastplay); - break; - case ASAP_TYPE_SAP_D: - if (player >= 0) { - V(int, s)= ast _ cpu_s; -#define PUSH_ON_6502_STACK(x) dPutByte(0x100 + s, x); s = (s - 1) & 0xff -#define RETURN_FROM_PLAYER_ADDR 0xd200 - /* save 6502 state on 6502 stack */ - PUSH_ON_6502_STACK(ast _ cpu_pc >> 8); - PUSH_ON_6502_STACK(ast _ cpu_pc & 0xff); - PUSH_ON_6502_STACK(((ast _ cpu_nz | (ast _ cpu_nz >> 1)) & 0x80) + ast _ cpu_vdi + \ - ((ast _ cpu_nz & 0xff) == 0 ? Z_FLAG : 0) + ast _ cpu_c + 0x20); - PUSH_ON_6502_STACK(ast _ cpu_a); - PUSH_ON_6502_STACK(ast _ cpu_x); - PUSH_ON_6502_STACK(ast _ cpu_y); - /* RTS will jump to 6502 code that restores the state */ - PUSH_ON_6502_STACK((RETURN_FROM_PLAYER_ADDR - 1) >> 8); - PUSH_ON_6502_STACK((RETURN_FROM_PLAYER_ADDR - 1) & 0xff); - ast _ cpu_s = s; - dPutByte(RETURN_FROM_PLAYER_ADDR, 0x68); /* PLA */ - dPutByte(RETURN_FROM_PLAYER_ADDR + 1, 0xa8); /* TAY */ - dPutByte(RETURN_FROM_PLAYER_ADDR + 2, 0x68); /* PLA */ - dPutByte(RETURN_FROM_PLAYER_ADDR + 3, 0xaa); /* TAX */ - dPutByte(RETURN_FROM_PLAYER_ADDR + 4, 0x68); /* PLA */ - dPutByte(RETURN_FROM_PLAYER_ADDR + 5, 0x40); /* RTI */ - ast _ cpu_pc = player; - } - Cpu_RunScanlines(ast, ast _ module_info->fastplay); - break; - case ASAP_TYPE_SAP_S: - Cpu_RunScanlines(ast, ast _ module_info->fastplay); - { - V(int, i) = dGetByte(0x45) - 1; - dPutByte(0x45, i); - if (i == 0) - dPutByte(0xb07b, dGetByte(0xb07b) + 1); - } - break; -#ifndef ASAP_ONLY_SAP - case ASAP_TYPE_DLT: - call_6502(ast, player + 0x103, ast _ module_info->fastplay); - break; - case ASAP_TYPE_MPT: - case ASAP_TYPE_RMT: - case ASAP_TYPE_TM2: - call_6502(ast, player + 3, ast _ module_info->fastplay); - break; - case ASAP_TYPE_TMC: - if (--ast _ tmc_per_frame_counter <= 0) { - ast _ tmc_per_frame_counter = ast _ tmc_per_frame; - call_6502(ast, player + 3, ast _ module_info->fastplay); - } - else - call_6502(ast, player + 6, ast _ module_info->fastplay); - break; -#endif - } - PokeySound_EndFrame(ast, ast _ module_info->fastplay * 114); - if (ast _ silence_cycles > 0) { - if (PokeySound_IsSilent(ADDRESSOF ast _ base_pokey) - && PokeySound_IsSilent(ADDRESSOF ast _ extra_pokey)) { - ast _ silence_cycles_counter -= ast _ module_info->fastplay * 114; - if (ast _ silence_cycles_counter <= 0) - return FALSE; - } - else - ast _ silence_cycles_counter = ast _ silence_cycles; - } - return TRUE; -} - -FUNC(int, ASAP_GetPosition, (P(CONST ASAP_State PTR, ast))) -{ - return ast _ blocks_played * 10 / (ASAP_SAMPLE_RATE / 100); -} - -FUNC(int, milliseconds_to_blocks, (P(int, milliseconds))) -{ - return milliseconds * (ASAP_SAMPLE_RATE / 100) / 10; -} - -#ifndef ACTIONSCRIPT - -FUNC(void, ASAP_Seek, (P(ASAP_State PTR, ast), P(int, position))) -{ - V(int, block) = milliseconds_to_blocks(position); - if (block < ast _ blocks_played) - ASAP_PlaySong(ast, ast _ current_song, ast _ current_duration); - while (ast _ blocks_played + ast _ samples - ast _ sample_index < block) { - ast _ blocks_played += ast _ samples - ast _ sample_index; - call_6502_player(ast); - } - ast _ sample_index += block - ast _ blocks_played; - ast _ blocks_played = block; -} - -PRIVATE FUNC(void, serialize_int, (P(BYTEARRAY, buffer), P(int, offset), P(int, value))) -{ - buffer[offset] = TO_BYTE(value); - buffer[offset + 1] = TO_BYTE(value >> 8); - buffer[offset + 2] = TO_BYTE(value >> 16); - buffer[offset + 3] = TO_BYTE(value >> 24); -} - -FUNC(void, ASAP_GetWavHeader, ( - P(CONST ASAP_State PTR, ast), P(BYTEARRAY, buffer), P(ASAP_SampleFormat, format))) -{ - V(int, use_16bit) = format != ASAP_FORMAT_U8 ? 1 : 0; - V(int, block_size) = ast _ module_info->channels << use_16bit; - V(int, bytes_per_second) = ASAP_SAMPLE_RATE * block_size; - V(int, total_blocks) = milliseconds_to_blocks(ast _ current_duration); - V(int, n_bytes) = (total_blocks - ast _ blocks_played) * block_size; - buffer[0] = CAST(byte) CHARCODE('R'); - buffer[1] = CAST(byte) CHARCODE('I'); - buffer[2] = CAST(byte) CHARCODE('F'); - buffer[3] = CAST(byte) CHARCODE('F'); - serialize_int(buffer, 4, n_bytes + 36); - buffer[8] = CAST(byte) CHARCODE('W'); - buffer[9] = CAST(byte) CHARCODE('A'); - buffer[10] = CAST(byte) CHARCODE('V'); - buffer[11] = CAST(byte) CHARCODE('E'); - buffer[12] = CAST(byte) CHARCODE('f'); - buffer[13] = CAST(byte) CHARCODE('m'); - buffer[14] = CAST(byte) CHARCODE('t'); - buffer[15] = CAST(byte) CHARCODE(' '); - buffer[16] = 16; - buffer[17] = 0; - buffer[18] = 0; - buffer[19] = 0; - buffer[20] = 1; - buffer[21] = 0; - buffer[22] = CAST(byte) ast _ module_info->channels; - buffer[23] = 0; - serialize_int(buffer, 24, ASAP_SAMPLE_RATE); - serialize_int(buffer, 28, bytes_per_second); - buffer[32] = CAST(byte) block_size; - buffer[33] = 0; - buffer[34] = CAST(byte) (8 << use_16bit); - buffer[35] = 0; - buffer[36] = CAST(byte) CHARCODE('d'); - buffer[37] = CAST(byte) CHARCODE('a'); - buffer[38] = CAST(byte) CHARCODE('t'); - buffer[39] = CAST(byte) CHARCODE('a'); - serialize_int(buffer, 40, n_bytes); -} - -#endif /* ACTIONSCRIPT */ - -PRIVATE FUNC(int, ASAP_GenerateAt, (P(ASAP_State PTR, ast), P(VOIDPTR, buffer), P(int, buffer_offset), P(int, buffer_len), P(ASAP_SampleFormat, format))) -{ - V(int, block_shift); - V(int, buffer_blocks); - V(int, block); - if (ast _ silence_cycles > 0 && ast _ silence_cycles_counter <= 0) - return 0; -#ifdef ACTIONSCRIPT - block_shift = 0; -#else - block_shift = (ast _ module_info->channels - 1) + (format != ASAP_FORMAT_U8 ? 1 : 0); -#endif - buffer_blocks = buffer_len >> block_shift; - if (ast _ current_duration > 0) { - V(int, total_blocks) = milliseconds_to_blocks(ast _ current_duration); - if (buffer_blocks > total_blocks - ast _ blocks_played) - buffer_blocks = total_blocks - ast _ blocks_played; - } - block = 0; - do { - V(int, blocks) = PokeySound_Generate(ast, CAST(BYTEARRAY) buffer, - buffer_offset + (block << block_shift), buffer_blocks - block, format); - ast _ blocks_played += blocks; - block += blocks; - } while (block < buffer_blocks && call_6502_player(ast)); - return block << block_shift; -} - -FUNC(int, ASAP_Generate, (P(ASAP_State PTR, ast), P(VOIDPTR, buffer), P(int, buffer_len), P(ASAP_SampleFormat, format))) -{ - return ASAP_GenerateAt(ast, buffer, 0, buffer_len, format); -} - -#endif /* ASAP_ONLY_INFO */ - -#ifdef C - -abool ASAP_CanSetModuleInfo(const char *filename) -{ - int ext = get_packed_ext(filename); - return ext == ASAP_EXT('S', 'A', 'P'); -} - -abool ASAP_ChangeExt(char *filename, const char *ext) -{ - char *dest = NULL; - while (*filename != '\0') { - if (*filename == '/' || *filename == '\\') - dest = NULL; - else if (*filename == '.') - dest = filename + 1; - filename++; - } - if (dest == NULL) - return FALSE; - strcpy(dest, ext); - return TRUE; -} - -static byte *put_string(byte *dest, const char *str) -{ - while (*str != '\0') - *dest++ = *str++; - return dest; -} - -static byte *put_dec(byte *dest, int value) -{ - if (value >= 10) { - dest = put_dec(dest, value / 10); - value %= 10; - } - *dest++ = '0' + value; - return dest; -} - -static byte *put_text_tag(byte *dest, const char *tag, const char *value) -{ - dest = put_string(dest, tag); - *dest++ = '"'; - if (*value == '\0') - value = ""; - while (*value != '\0') { - if (*value < ' ' || *value > 'z' || *value == '"' || *value == '`') - return NULL; - *dest++ = *value++; - } - *dest++ = '"'; - *dest++ = '\r'; - *dest++ = '\n'; - return dest; -} - -static byte *put_dec_tag(byte *dest, const char *tag, int value) -{ - dest = put_string(dest, tag); - dest = put_dec(dest, value); - *dest++ = '\r'; - *dest++ = '\n'; - return dest; -} - -static byte *start_sap_header(byte *dest, const ASAP_ModuleInfo *module_info) -{ - dest = put_string(dest, "SAP\r\n"); - dest = put_text_tag(dest, "AUTHOR ", module_info->author); - if (dest == NULL) - return NULL; - dest = put_text_tag(dest, "NAME ", module_info->name); - if (dest == NULL) - return NULL; - dest = put_text_tag(dest, "DATE ", module_info->date); - if (dest == NULL) - return NULL; - if (module_info->songs > 1) { - dest = put_dec_tag(dest, "SONGS ", module_info->songs); - if (module_info->default_song > 0) - dest = put_dec_tag(dest, "DEFSONG ", module_info->default_song); - } - if (module_info->channels > 1) - dest = put_string(dest, "STEREO\r\n"); - return dest; -} - -static char *two_digits(char *s, int x) -{ - s[0] = '0' + x / 10; - s[1] = '0' + x % 10; - return s + 2; -} - -void ASAP_DurationToString(char *s, int duration) -{ - if (duration >= 0 && duration < 100 * 60 * 1000) { - int seconds = duration / 1000; - s = two_digits(s, seconds / 60); - *s++ = ':'; - s = two_digits(s, seconds % 60); - duration %= 1000; - if (duration != 0) { - *s++ = '.'; - s = two_digits(s, duration / 10); - duration %= 10; - if (duration != 0) - *s++ = '0' + duration; - } - } - *s = '\0'; -} - -static byte *put_durations(byte *dest, const ASAP_ModuleInfo *module_info) -{ - int song; - for (song = 0; song < module_info->songs; song++) { - if (module_info->durations[song] < 0) - break; - dest = put_string(dest, "TIME "); - ASAP_DurationToString((char *) dest, module_info->durations[song]); - while (*dest != '\0') - dest++; - if (module_info->loops[song]) - dest = put_string(dest, " LOOP"); - *dest++ = '\r'; - *dest++ = '\n'; - } - return dest; -} - -int ASAP_SetModuleInfo(const ASAP_ModuleInfo *module_info, const BYTEARRAY module, int module_len, BYTEARRAY out_module) -{ - byte *dest; - int i; - if (memcmp(module, "SAP\r\n", 5) != 0) - return -1; - dest = start_sap_header(out_module, module_info); - if (dest == NULL) - return -1; - i = 5; - while (i < module_len && module[i] != 0xff) { - if (memcmp(module + i, "AUTHOR ", 7) == 0 - || memcmp(module + i, "NAME ", 5) == 0 - || memcmp(module + i, "DATE ", 5) == 0 - || memcmp(module + i, "SONGS ", 6) == 0 - || memcmp(module + i, "DEFSONG ", 8) == 0 - || memcmp(module + i, "STEREO\r", 7) == 0 - || memcmp(module + i, "TIME ", 5) == 0) { - while (i < module_len && module[i++] != 0x0a); - } - else { - int b; - do { - b = module[i++]; - *dest++ = b; - } while (i < module_len && b != 0x0a); - } - } - dest = put_durations(dest, module_info); - module_len -= i; - memcpy(dest, module + i, module_len); - dest += module_len; - return dest - out_module; -} - -#if !defined(ASAP_ONLY_SAP) && !defined(ASAP_ONLY_INFO) - -#define RMT_INIT 0x0c80 -#define TM2_INIT 0x1080 - -const char *ASAP_CanConvert( - const char *filename, const ASAP_ModuleInfo *module_info, - const BYTEARRAY module, int module_len) -{ - (void) filename; - switch (module_info->type) { - case ASAP_TYPE_SAP_B: - if ((module_info->init == 0x3fb || module_info->init == 0x3f9) && module_info->player == 0x503) - return "dlt"; - if (module_info->init == 0x4f3 || module_info->init == 0xf4f3 || module_info->init == 0x4ef) - return module_info->fastplay == 156 ? "mpd" : "mpt"; - if (module_info->init == RMT_INIT) - return "rmt"; - if ((module_info->init == 0x4f5 || module_info->init == 0xf4f5 || module_info->init == 0x4f2) - || ((module_info->init == 0x4e7 || module_info->init == 0xf4e7 || module_info->init == 0x4e4) && module_info->fastplay == 156) - || ((module_info->init == 0x4e5 || module_info->init == 0xf4e5 || module_info->init == 0x4e2) && (module_info->fastplay == 104 || module_info->fastplay == 78))) - return "tmc"; - if (module_info->init == TM2_INIT) - return "tm2"; - break; - case ASAP_TYPE_SAP_C: - if (module_info->player == 0x500 || module_info->player == 0xf500) { - if (module_info->fastplay == 156) - return "dmc"; - if (module_info->channels > 1) - return "cms"; - if (module[module_len - 170] == 0x1e) - return "cmr"; - if (module[module_len - 909] == 0x30) - return "cm3"; - return "cmc"; - } - break; - case ASAP_TYPE_CMC: - case ASAP_TYPE_CM3: - case ASAP_TYPE_CMR: - case ASAP_TYPE_CMS: - case ASAP_TYPE_DLT: - case ASAP_TYPE_MPT: - case ASAP_TYPE_RMT: - case ASAP_TYPE_TMC: - case ASAP_TYPE_TM2: - return "sap"; - default: - break; - } - return NULL; -} - -static byte *put_hex_tag(byte *dest, const char *tag, int value) -{ - int i; - if (value < 0) - return dest; - dest = put_string(dest, tag); - for (i = 12; i >= 0; i -= 4) { - int digit = (value >> i) & 0xf; - *dest++ = (byte) (digit + (digit < 10 ? '0' : 'A' - 10)); - } - *dest++ = '\r'; - *dest++ = '\n'; - return dest; -} - -static byte *put_sap_header(byte *dest, const ASAP_ModuleInfo *module_info, char type, int music, int init, int player) -{ - dest = start_sap_header(dest, module_info); - if (dest == NULL) - return NULL; - dest = put_string(dest, "TYPE "); - *dest++ = type; - *dest++ = '\r'; - *dest++ = '\n'; - if (module_info->fastplay != 312) - dest = put_dec_tag(dest, "FASTPLAY ", module_info->fastplay); - dest = put_hex_tag(dest, "MUSIC ", music); - dest = put_hex_tag(dest, "INIT ", init); - dest = put_hex_tag(dest, "PLAYER ", player); - dest = put_durations(dest, module_info); - return dest; -} - -int ASAP_Convert( - const char *filename, const ASAP_ModuleInfo *module_info, - const BYTEARRAY module, int module_len, BYTEARRAY out_module) -{ - (void) filename; - int out_len; - byte *dest; - int addr; - int player; - static const int tmc_player[4] = { 3, -9, -10, -10 }; - static const int tmc_init[4] = { -14, -16, -17, -17 }; - switch (module_info->type) { - case ASAP_TYPE_SAP_B: - case ASAP_TYPE_SAP_C: - out_len = UWORD(module, module_info->header_len + 4) - UWORD(module, module_info->header_len + 2) + 7; - if (out_len < 7 || module_info->header_len + out_len >= module_len) - return -1; - memcpy(out_module, module + module_info->header_len, out_len); - return out_len; - case ASAP_TYPE_CMC: - case ASAP_TYPE_CM3: - case ASAP_TYPE_CMR: - case ASAP_TYPE_CMS: - dest = put_sap_header(out_module, module_info, 'C', module_info->music, -1, module_info->player); - if (dest == NULL) - return -1; - memcpy(dest, module, module_len); - dest[0] = 0xff; /* some modules start with zeros */ - dest[1] = 0xff; - dest += module_len; - if (module_info->type == ASAP_TYPE_CM3) { - memcpy(dest, cm3_obx + 2, sizeof(cm3_obx) - 2); - dest += sizeof(cm3_obx) - 2; - } - else if (module_info->type == ASAP_TYPE_CMS) { - memcpy(dest, cms_obx + 2, sizeof(cms_obx) - 2); - dest += sizeof(cms_obx) - 2; - } - else { - memcpy(dest, cmc_obx + 2, sizeof(cmc_obx) - 2); - if (module_info->type == ASAP_TYPE_CMR) - memcpy(dest + 4 + CMR_BASS_TABLE_OFFSET, cmr_bass_table, sizeof(cmr_bass_table)); - dest += sizeof(cmc_obx) - 2; - } - return dest - out_module; - case ASAP_TYPE_DLT: - if (module_info->songs != 1) { - addr = module_info->player - 7 - module_info->songs; - dest = put_sap_header(out_module, module_info, 'B', -1, module_info->player - 7, module_info->player + 0x103); - } - else { - addr = module_info->player - 5; - dest = put_sap_header(out_module, module_info, 'B', -1, addr, module_info->player + 0x103); - } - if (dest == NULL) - return -1; - memcpy(dest, module, module_len); - if (module_len == 0x2c06) { - dest[4] = 0; - dest[5] = 0x4c; - dest[0x2c06] = 0; - } - dest += 0x2c07; - *dest++ = (byte) addr; - *dest++ = (byte) (addr >> 8); - *dest++ = dlt_obx[4]; - *dest++ = dlt_obx[5]; - if (module_info->songs != 1) { - memcpy(dest, module_info->song_pos, module_info->songs); - dest += module_info->songs; - *dest++ = 0xaa; /* tax */ - *dest++ = 0xbc; /* ldy song2pos,x */ - *dest++ = (byte) addr; - *dest++ = (byte) (addr >> 8); - } - else { - *dest++ = 0xa0; /* ldy #0 */ - *dest++ = 0; - } - *dest++ = 0x4c; /* jmp init */ - *dest++ = (byte) module_info->player; - *dest++ = (byte) ((module_info->player >> 8) + 1); - memcpy(dest, dlt_obx + 6, sizeof(dlt_obx) - 6); - dest += sizeof(dlt_obx) - 6; - return dest - out_module; - case ASAP_TYPE_MPT: - if (module_info->songs != 1) { - addr = module_info->player - 17 - module_info->songs; - dest = put_sap_header(out_module, module_info, 'B', -1, module_info->player - 17, module_info->player + 3); - } - else { - addr = module_info->player - 13; - dest = put_sap_header(out_module, module_info, 'B', -1, addr, module_info->player + 3); - } - if (dest == NULL) - return -1; - memcpy(dest, module, module_len); - dest += module_len; - *dest++ = (byte) addr; - *dest++ = (byte) (addr >> 8); - *dest++ = mpt_obx[4]; - *dest++ = mpt_obx[5]; - if (module_info->songs != 1) { - memcpy(dest, module_info->song_pos, module_info->songs); - dest += module_info->songs; - *dest++ = 0x48; /* pha */ - } - *dest++ = 0xa0; /* ldy #music; - *dest++ = 0xa2; /* ldx #>music */ - *dest++ = (byte) (module_info->music >> 8); - *dest++ = 0xa9; /* lda #0 */ - *dest++ = 0; - *dest++ = 0x20; /* jsr player */ - *dest++ = (byte) module_info->player; - *dest++ = (byte) (module_info->player >> 8); - if (module_info->songs != 1) { - *dest++ = 0x68; /* pla */ - *dest++ = 0xa8; /* tay */ - *dest++ = 0xbe; /* ldx song2pos,y */ - *dest++ = (byte) addr; - *dest++ = (byte) (addr >> 8); - } - else { - *dest++ = 0xa2; /* ldx #0 */ - *dest++ = 0; - } - *dest++ = 0xa9; /* lda #2 */ - *dest++ = 2; - memcpy(dest, mpt_obx + 6, sizeof(mpt_obx) - 6); - dest += sizeof(mpt_obx) - 6; - return dest - out_module; - case ASAP_TYPE_RMT: - dest = put_sap_header(out_module, module_info, 'B', -1, RMT_INIT, module_info->player + 3); - if (dest == NULL) - return -1; - memcpy(dest, module, module_len); - dest += module_len; - *dest++ = (byte) RMT_INIT; - *dest++ = (byte) (RMT_INIT >> 8); - if (module_info->songs != 1) { - addr = RMT_INIT + 10 + module_info->songs; - *dest++ = (byte) addr; - *dest++ = (byte) (addr >> 8); - *dest++ = 0xa8; /* tay */ - *dest++ = 0xb9; /* lda song2pos,y */ - *dest++ = (byte) (RMT_INIT + 11); - *dest++ = (byte) ((RMT_INIT + 11) >> 8); - } - else { - *dest++ = (byte) (RMT_INIT + 8); - *dest++ = (byte) ((RMT_INIT + 8) >> 8); - *dest++ = 0xa9; /* lda #0 */ - *dest++ = 0; - } - *dest++ = 0xa2; /* ldx #music; - *dest++ = 0xa0; /* ldy #>music */ - *dest++ = (byte) (module_info->music >> 8); - *dest++ = 0x4c; /* jmp player */ - *dest++ = (byte) module_info->player; - *dest++ = (byte) (module_info->player >> 8); - if (module_info->songs != 1) { - memcpy(dest, module_info->song_pos, module_info->songs); - dest += module_info->songs; - } - if (module_info->channels == 1) { - memcpy(dest, rmt4_obx + 2, sizeof(rmt4_obx) - 2); - dest += sizeof(rmt4_obx) - 2; - } - else { - memcpy(dest, rmt8_obx + 2, sizeof(rmt8_obx) - 2); - dest += sizeof(rmt8_obx) - 2; - } - return dest - out_module; - case ASAP_TYPE_TMC: - player = module_info->player + tmc_player[module[0x25] - 1]; - addr = player + tmc_init[module[0x25] - 1]; - if (module_info->songs != 1) - addr -= 3; - dest = put_sap_header(out_module, module_info, 'B', -1, addr, player); - if (dest == NULL) - return -1; - memcpy(dest, module, module_len); - dest += module_len; - *dest++ = (byte) addr; - *dest++ = (byte) (addr >> 8); - *dest++ = tmc_obx[4]; - *dest++ = tmc_obx[5]; - if (module_info->songs != 1) - *dest++ = 0x48; /* pha */ - *dest++ = 0xa0; /* ldy #music; - *dest++ = 0xa2; /* ldx #>music */ - *dest++ = (byte) (module_info->music >> 8); - *dest++ = 0xa9; /* lda #$70 */ - *dest++ = 0x70; - *dest++ = 0x20; /* jsr player */ - *dest++ = (byte) module_info->player; - *dest++ = (byte) (module_info->player >> 8); - if (module_info->songs != 1) { - *dest++ = 0x68; /* pla */ - *dest++ = 0xaa; /* tax */ - *dest++ = 0xa9; /* lda #0 */ - *dest++ = 0; - } - else { - *dest++ = 0xa9; /* lda #$60 */ - *dest++ = 0x60; - } - switch (module[0x25]) { - case 2: - *dest++ = 0x06; /* asl 0 */ - *dest++ = 0; - *dest++ = 0x4c; /* jmp player */ - *dest++ = (byte) module_info->player; - *dest++ = (byte) (module_info->player >> 8); - *dest++ = 0xa5; /* lda 0 */ - *dest++ = 0; - *dest++ = 0xe6; /* inc 0 */ - *dest++ = 0; - *dest++ = 0x4a; /* lsr @ */ - *dest++ = 0x90; /* bcc player+3 */ - *dest++ = 5; - *dest++ = 0xb0; /* bcs player+6 */ - *dest++ = 6; - break; - case 3: - case 4: - *dest++ = 0xa0; /* ldy #1 */ - *dest++ = 1; - *dest++ = 0x84; /* sty 0 */ - *dest++ = 0; - *dest++ = 0xd0; /* bne player */ - *dest++ = 10; - *dest++ = 0xc6; /* dec 0 */ - *dest++ = 0; - *dest++ = 0xd0; /* bne player+6 */ - *dest++ = 12; - *dest++ = 0xa0; /* ldy #3 */ - *dest++ = module[0x25]; - *dest++ = 0x84; /* sty 0 */ - *dest++ = 0; - *dest++ = 0xd0; /* bne player+3 */ - *dest++ = 3; - break; - default: - break; - } - memcpy(dest, tmc_obx + 6, sizeof(tmc_obx) - 6); - dest += sizeof(tmc_obx) - 6; - return dest - out_module; - case ASAP_TYPE_TM2: - dest = put_sap_header(out_module, module_info, 'B', -1, TM2_INIT, module_info->player + 3); - if (dest == NULL) - return -1; - memcpy(dest, module, module_len); - dest += module_len; - *dest++ = (byte) TM2_INIT; - *dest++ = (byte) (TM2_INIT >> 8); - if (module_info->songs != 1) { - *dest++ = (byte) (TM2_INIT + 16); - *dest++ = (byte) ((TM2_INIT + 16) >> 8); - *dest++ = 0x48; /* pha */ - } - else { - *dest++ = (byte) (TM2_INIT + 14); - *dest++ = (byte) ((TM2_INIT + 14) >> 8); - } - *dest++ = 0xa0; /* ldy #music; - *dest++ = 0xa2; /* ldx #>music */ - *dest++ = (byte) (module_info->music >> 8); - *dest++ = 0xa9; /* lda #$70 */ - *dest++ = 0x70; - *dest++ = 0x20; /* jsr player */ - *dest++ = (byte) module_info->player; - *dest++ = (byte) (module_info->player >> 8); - if (module_info->songs != 1) { - *dest++ = 0x68; /* pla */ - *dest++ = 0xaa; /* tax */ - *dest++ = 0xa9; /* lda #0 */ - *dest++ = 0; - } - else { - *dest++ = 0xa9; /* lda #0 */ - *dest++ = 0; - *dest++ = 0xaa; /* tax */ - } - *dest++ = 0x4c; /* jmp player */ - *dest++ = (byte) module_info->player; - *dest++ = (byte) (module_info->player >> 8); - memcpy(dest, tm2_obx + 2, sizeof(tm2_obx) - 2); - dest += sizeof(tm2_obx) - 2; - return dest - out_module; - default: - return -1; - } -} - -#endif /* !defined(ASAP_ONLY_SAP) && !defined(ASAP_ONLY_INFO) */ - -static abool has_two_digits(const char *s) -{ - return s[0] >= '0' && s[0] <= '9' && s[1] >= '0' && s[1] <= '9'; -} - -/* "DD/MM/YYYY", "MM/YYYY", "YYYY" -> "YYYY" */ -abool ASAP_DateToYear(const char *date, char *year) -{ - if (!has_two_digits(date)) - return FALSE; - if (date[2] == '/') { - date += 3; - if (!has_two_digits(date)) - return FALSE; - if (date[2] == '/') { - date += 3; - if (!has_two_digits(date)) - return FALSE; - } - } - if (!has_two_digits(date + 2) || date[4] != '\0') - return FALSE; - memcpy(year, date, 5); - return TRUE; -} - -#endif /* C */ diff --git a/apps/codecs/libasap/asap.h b/apps/codecs/libasap/asap.h deleted file mode 100644 index 1cbf8d0100..0000000000 --- a/apps/codecs/libasap/asap.h +++ /dev/null @@ -1,328 +0,0 @@ -/* - * asap.h - public interface of ASAP - * - * Copyright (C) 2005-2010 Piotr Fusik - * - * This file is part of ASAP (Another Slight Atari Player), - * see http://asap.sourceforge.net - * - * ASAP is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2 of the License, - * or (at your option) any later version. - * - * ASAP is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with ASAP; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef _ASAP_H_ -#define _ASAP_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -/* ASAP version. */ -#define ASAP_VERSION_MAJOR 2 -#define ASAP_VERSION_MINOR 1 -#define ASAP_VERSION_MICRO 2 -#define ASAP_VERSION "2.1.2" - -/* Short credits of the ASAP engine. */ -#define ASAP_YEARS "2005-2010" -#define ASAP_CREDITS \ - "Another Slight Atari Player (C) 2005-2010 Piotr Fusik\n" \ - "CMC, MPT, TMC, TM2 players (C) 1994-2005 Marcin Lewandowski\n" \ - "RMT player (C) 2002-2005 Radek Sterba\n" \ - "DLT player (C) 2009 Marek Konopka\n" \ - "CMS player (C) 1999 David Spilka\n" - -/* Short GPL notice. - Display after the credits. */ -#define ASAP_COPYRIGHT \ - "This program is free software; you can redistribute it and/or modify\n" \ - "it under the terms of the GNU General Public License as published\n" \ - "by the Free Software Foundation; either version 2 of the License,\n" \ - "or (at your option) any later version." - -/* Maximum length of AUTHOR, NAME and DATE tags including the terminator. */ -#define ASAP_INFO_CHARS 128 - -/* Maximum length of a "mm:ss.xxx" string including the terminator. */ -#define ASAP_DURATION_CHARS 10 - -/* Maximum length of a supported input file. - You can assume that files longer than this are not supported by ASAP. */ -#define ASAP_MODULE_MAX 65000 - -/* Maximum number of songs in a file. */ -#define ASAP_SONGS_MAX 32 - -/* Output sample rate. */ -#define ASAP_SAMPLE_RATE 44100 - -/* WAV file header length. */ -#define ASAP_WAV_HEADER_BYTES 44 - -/* Output formats. */ -typedef enum { - ASAP_FORMAT_U8 = 8, /* unsigned char */ - ASAP_FORMAT_S16_LE = 16, /* signed short, little-endian */ - ASAP_FORMAT_S16_BE = -16 /* signed short, big-endian */ -} ASAP_SampleFormat; - -/* Useful type definitions. */ -#ifndef FALSE -#define FALSE 0 -#endif -#ifndef TRUE -#define TRUE 1 -#endif -typedef int abool; -typedef unsigned char byte; - -/* Information about a music file. */ -typedef struct { - char author[ASAP_INFO_CHARS]; /* author's name */ - char name[ASAP_INFO_CHARS]; /* title */ - char date[ASAP_INFO_CHARS]; /* creation date */ - int channels; /* 1 for mono or 2 for stereo */ - int songs; /* number of subsongs */ - int default_song; /* 0-based index of the "main" subsong */ - int durations[ASAP_SONGS_MAX]; /* lengths of songs, in milliseconds, -1 = indeterminate */ - abool loops[ASAP_SONGS_MAX]; /* whether songs repeat or not */ - /* the following technical information should not be used outside ASAP. */ - abool ntsc; - int type; - int fastplay; - int music; - int init; - int player; - int covox_addr; - int header_len; - byte song_pos[ASAP_SONGS_MAX]; -} ASAP_ModuleInfo; - -/* POKEY state. - Not for use outside the ASAP engine. */ -typedef struct { - int audctl; - abool init; - int poly_index; - int div_cycles; - int mute1; - int mute2; - int mute3; - int mute4; - int audf1; - int audf2; - int audf3; - int audf4; - int audc1; - int audc2; - int audc3; - int audc4; - int tick_cycle1; - int tick_cycle2; - int tick_cycle3; - int tick_cycle4; - int period_cycles1; - int period_cycles2; - int period_cycles3; - int period_cycles4; - int reload_cycles1; - int reload_cycles3; - int out1; - int out2; - int out3; - int out4; - int delta1; - int delta2; - int delta3; - int delta4; - int skctl; - int delta_buffer[888]; -} PokeyState; - -/* Player state. - Only module_info is meant to be read outside the ASAP engine. */ -typedef struct { - int cycle; - int cpu_pc; - int cpu_a; - int cpu_x; - int cpu_y; - int cpu_s; - int cpu_nz; - int cpu_c; - int cpu_vdi; - int scanline_number; - int nearest_event_cycle; - int next_scanline_cycle; - int timer1_cycle; - int timer2_cycle; - int timer4_cycle; - int irqst; - int extra_pokey_mask; - int consol; - byte covox[4]; - PokeyState base_pokey; - PokeyState extra_pokey; - int sample_offset; - int sample_index; - int samples; - int iir_acc_left; - int iir_acc_right; - ASAP_ModuleInfo *module_info; - int tmc_per_frame; - int tmc_per_frame_counter; - int current_song; - int current_duration; - int blocks_played; - int silence_cycles; - int silence_cycles_counter; - byte poly9_lookup[511]; - byte poly17_lookup[16385]; - byte *memory; -} ASAP_State; - -/* Parses the string in the "mm:ss.xxx" format - and returns the number of milliseconds or -1 if an error occurs. */ -int ASAP_ParseDuration(const char *s); - -/* Converts number of milliseconds to a string in the "mm:ss.xxx" format. */ -void ASAP_DurationToString(char *s, int duration); - -/* Checks whether the extension of the passed filename is known to ASAP. */ -abool ASAP_IsOurFile(const char *filename); - -/* Checks whether the filename extension is known to ASAP. */ -abool ASAP_IsOurExt(const char *ext); - -/* Changes the filename extension, returns true on success. */ -abool ASAP_ChangeExt(char *filename, const char *ext); - -/* Gets information about a module. - "module_info" is the structure where the information is returned. - "filename" determines file format. - "module" is the music data (contents of the file). - "module_len" is the number of data bytes. - ASAP_GetModuleInfo() returns true on success. */ -abool ASAP_GetModuleInfo(ASAP_ModuleInfo *module_info, const char *filename, - const byte module[], int module_len); - -/* Extracts year from date. */ -abool ASAP_DateToYear(const char *date, char *year); - -/* Loads music data. - "ast" is the destination structure. - "filename" determines file format. - "module" is the music data (contents of the file). - "module_len" is the number of data bytes. - ASAP does not make copies of the passed pointers. You can overwrite - or free "filename" and "module" once this function returns. - ASAP_Load() returns true on success. - If false is returned, the structure is invalid and you cannot - call the following functions. */ -abool ASAP_Load(ASAP_State *ast, const char *filename, - const byte module[], int module_len); - -/* Enables silence detection. - Makes ASAP finish playing after the specified period of silence. - "ast" is ASAP state initialized by ASAP_Load(). - "seconds" is the minimum length of silence that ends playback. */ -void ASAP_DetectSilence(ASAP_State *ast, int seconds); - -/* Prepares ASAP to play the specified song of the loaded module. - "ast" is ASAP state initialized by ASAP_Load(). - "song" is a zero-based index which must be less than the "songs" field - of the ASAP_ModuleInfo structure. - "duration" is playback time in milliseconds - use durations[song] - unless you want to override it. -1 means indefinitely. */ -void ASAP_PlaySong(ASAP_State *ast, int song, int duration); - -/* Mutes the selected POKEY channels. - This is only useful for people who want to grab samples of individual - instruments. - "ast" is ASAP state after calling ASAP_PlaySong(). - "mask" is a bit mask which selects POKEY channels to be muted. - Bits 0-3 control the base POKEY channels, - bits 4-7 control the extra POKEY channels. */ -void ASAP_MutePokeyChannels(ASAP_State *ast, int mask); - -/* Returns current position in milliseconds. - "ast" is ASAP state initialized by ASAP_PlaySong(). */ -int ASAP_GetPosition(const ASAP_State *ast); - -/* Rewinds the current song. - "ast" is ASAP state initialized by ASAP_PlaySong(). - "position" is the requested absolute position in milliseconds. */ -void ASAP_Seek(ASAP_State *ast, int position); - -/* Fills the specified buffer with WAV file header. - "ast" is ASAP state initialized by ASAP_PlaySong() with a positive "duration". - "buffer" is buffer of ASAP_WAV_HEADER_BYTES bytes. - "format" is the format of samples. */ -void ASAP_GetWavHeader(const ASAP_State *ast, byte buffer[], - ASAP_SampleFormat format); - -/* Fills the specified buffer with generated samples. - "ast" is ASAP state initialized by ASAP_PlaySong(). - "buffer" is the destination buffer. - "buffer_len" is the length of this buffer in bytes. - "format" is the format of samples. - ASAP_Generate() returns number of bytes actually written - (less than buffer_len if reached the end of the song). - Normally you use a buffer of a few kilobytes or less, - and call ASAP_Generate() in a loop or via a callback. */ -int ASAP_Generate(ASAP_State *ast, void *buffer, int buffer_len, - ASAP_SampleFormat format); - -/* Checks whether information in the specified file can be edited. */ -abool ASAP_CanSetModuleInfo(const char *filename); - -/* Updates the specified module with author, name, date, stereo - and song durations as specified in "module_info". - "module_info" contains the new module information. - "module" is the source file contents. - "module_len" is the source file length. - "out_module" is the destination buffer of size ASAP_MODULE_MAX. - ASAP_SetModuleInfo() returns the resulting file length (number of bytes - written to "out_module") or -1 if illegal characters were found. */ -int ASAP_SetModuleInfo(const ASAP_ModuleInfo *module_info, const byte module[], - int module_len, byte out_module[]); - -/* Checks whether the specified module can be converted to another format. - "filename" determines the source format. - "module_info" contains the information about the source module, - with possibly modified public fields. - "module" is the source file contents. - "module_len" is the source file length. - ASAP_CanConvert() returns the extension of the target format - or NULL if there's no possible conversion. */ -const char *ASAP_CanConvert(const char *filename, const ASAP_ModuleInfo *module_info, - const byte module[], int module_len); - -/* Converts the specified module to the format returned by ASAP_CanConvert(). - "filename" determines the source format. - "module_info" contains the information about the source module, - with possibly modified public fields. - "module" is the source file contents. - "module_len" is the source file length. - "out_module" is the destination buffer of size ASAP_MODULE_MAX. - ASAP_Convert() returns the resulting file length (number of bytes - written to "out_module") or -1 on error. */ -int ASAP_Convert(const char *filename, const ASAP_ModuleInfo *module_info, - const byte module[], int module_len, byte out_module[]); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/apps/codecs/libasap/asap_internal.h b/apps/codecs/libasap/asap_internal.h deleted file mode 100644 index def444bc2f..0000000000 --- a/apps/codecs/libasap/asap_internal.h +++ /dev/null @@ -1,115 +0,0 @@ -/* - * asap_internal.h - private interface of ASAP - * - * Copyright (C) 2005-2010 Piotr Fusik - * - * This file is part of ASAP (Another Slight Atari Player), - * see http://asap.sourceforge.net - * - * ASAP is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2 of the License, - * or (at your option) any later version. - * - * ASAP is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with ASAP; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef _ASAP_INTERNAL_H_ -#define _ASAP_INTERNAL_H_ - -#include "anylang.h" - -#ifndef C - -#define ASAP_SONGS_MAX 32 -#define ASAP_SAMPLE_RATE 44100 - -#endif - -#ifdef JAVA - -#define ASAP_FORMAT_U8 8 -#define ASAP_FORMAT_S16_LE 16 -#define ASAP_FORMAT_S16_BE -16 -#define ASAP_SampleFormat int - -#elif defined(CSHARP) || defined(JAVASCRIPT) - -#define ASAP_FORMAT_U8 ASAP_SampleFormat.U8 -#define ASAP_FORMAT_S16_LE ASAP_SampleFormat.S16LE -#define ASAP_FORMAT_S16_BE ASAP_SampleFormat.S16BE - -#elif defined(ACTIONSCRIPT) - -#define ASAP_SampleFormat int - -#else /* C */ - -#include "asap.h" - -int ASAP_GetByte(ASAP_State *ast, int addr); -void ASAP_PutByte(ASAP_State *ast, int addr, int data); - -void Cpu_RunScanlines(ASAP_State *ast, int scanlines); - -void PokeySound_Initialize(ASAP_State *ast); -void PokeySound_StartFrame(ASAP_State *ast); -void PokeySound_PutByte(ASAP_State *ast, int addr, int data); -int PokeySound_GetRandom(ASAP_State *ast, int addr, int cycle); -void PokeySound_EndFrame(ASAP_State *ast, int cycle_limit); -int PokeySound_Generate(ASAP_State *ast, byte buffer[], int buffer_offset, int blocks, ASAP_SampleFormat format); -abool PokeySound_IsSilent(const PokeyState *pst); -void PokeySound_Mute(const ASAP_State *ast, PokeyState *pst, int mask); - -#ifdef ASAPSCAN -abool call_6502_player(ASAP_State *ast); -extern int cpu_trace; -void trace_cpu(const ASAP_State *ast, int pc, int a, int x, int y, int s, int nz, int vdi, int c); -#endif - -#endif /* C */ - -#define V_FLAG 0x40 -#define D_FLAG 0x08 -#define I_FLAG 0x04 -#define Z_FLAG 0x02 - -#define NEVER 0x800000 - -#define DELTA_SHIFT_POKEY 20 -#define DELTA_SHIFT_GTIA 20 -#define DELTA_SHIFT_COVOX 17 - -/* 6502 player types */ -#define ASAP_TYPE_SAP_B 1 -#define ASAP_TYPE_SAP_C 2 -#define ASAP_TYPE_SAP_D 3 -#define ASAP_TYPE_SAP_S 4 -#define ASAP_TYPE_CMC 5 -#define ASAP_TYPE_CM3 6 -#define ASAP_TYPE_CMR 7 -#define ASAP_TYPE_CMS 8 -#define ASAP_TYPE_DLT 9 -#define ASAP_TYPE_MPT 10 -#define ASAP_TYPE_RMT 11 -#define ASAP_TYPE_TMC 12 -#define ASAP_TYPE_TM2 13 - -#define dGetByte(addr) UBYTE(ast _ memory[addr]) -#define dPutByte(addr, data) ast _ memory[addr] = CAST(byte) (data) -#define dGetWord(addr) (dGetByte(addr) + (dGetByte((addr) + 1) << 8)) -#define GetByte(addr) (((addr) & 0xf900) == 0xd000 ? ASAP_GetByte(ast, addr) : dGetByte(addr)) -#define PutByte(addr, data) do { if (((addr) & 0xf900) == 0xd000) ASAP_PutByte(ast, addr, data); else dPutByte(addr, data); } while (FALSE) -#define RMW_GetByte(dest, addr) do { if (((addr) >> 8) == 0xd2) { dest = ASAP_GetByte(ast, addr); ast _ cycle--; ASAP_PutByte(ast, addr, dest); ast _ cycle++; } else dest = dGetByte(addr); } while (FALSE) - -#define ASAP_MAIN_CLOCK(ast) ((ast) _ module_info->ntsc ? 1789772 : 1773447) -#define CYCLE_TO_SAMPLE(cycle) TO_INT(((cycle) * ASAP_SAMPLE_RATE + ast _ sample_offset) / ASAP_MAIN_CLOCK(ast)) - -#endif /* _ASAP_INTERNAL_H_ */ diff --git a/apps/codecs/libasap/libasap.make b/apps/codecs/libasap/libasap.make deleted file mode 100644 index d904c14257..0000000000 --- a/apps/codecs/libasap/libasap.make +++ /dev/null @@ -1,18 +0,0 @@ -# __________ __ ___. -# Open \______ \ ____ ____ | | _\_ |__ _______ ___ -# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / -# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < -# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ -# \/ \/ \/ \/ \/ -# $Id$ -# - -# libasap -ASAPLIB := $(CODECDIR)/libasap.a -ASAPLIB_SRC := $(call preprocess, $(APPSDIR)/codecs/libasap/SOURCES) -ASAPLIB_OBJ := $(call c2obj, $(ASAPLIB_SRC)) -OTHER_SRC += $(ASAPLIB_SRC) - -$(ASAPLIB): $(ASAPLIB_OBJ) - $(SILENT)$(shell rm -f $@) - $(call PRINTS,AR $(@F))$(AR) rcs $@ $^ >/dev/null diff --git a/apps/codecs/libasap/players.h b/apps/codecs/libasap/players.h deleted file mode 100644 index fb90b0c76a..0000000000 --- a/apps/codecs/libasap/players.h +++ /dev/null @@ -1,1386 +0,0 @@ -CONST_ARRAY(byte, cmc_obx) - 255,255,0,5,220,12,76,15,11,76,120,5,76,203,7,0, - 0,0,0,0,0,0,0,0,160,227,237,227,160,240,236,225, - 249,229,242,160,246,160,178,174,177,160,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255, - 255,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,128,128,128,128,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,141,110, - 5,142,111,5,140,112,5,41,112,74,74,74,170,189,145,11, - 141,169,5,189,146,11,141,170,5,169,3,141,15,210,216,165, - 254,72,165,255,72,172,112,5,174,111,5,173,110,5,32,178, - 5,104,133,255,104,133,254,96,173,118,5,133,254,173,119,5, - 133,255,160,0,138,240,28,177,254,201,143,240,4,201,239,208, - 12,202,208,9,200,192,84,176,9,152,170,16,6,200,192,84, - 144,229,96,142,104,5,32,123,6,169,0,162,9,157,69,5, - 202,16,250,141,103,5,169,1,141,113,5,169,255,141,106,5, - 173,114,5,133,254,173,115,5,133,255,160,19,177,254,170,173, - 118,5,133,254,173,119,5,133,255,172,104,5,177,254,201,207, - 208,13,152,24,105,85,168,177,254,48,15,170,76,52,6,201, - 143,240,7,201,239,240,3,136,16,226,142,108,5,142,109,5, - 96,41,15,240,245,142,218,10,142,240,10,142,255,10,140,219, - 10,140,241,10,140,0,11,96,142,114,5,134,254,140,115,5, - 132,255,24,138,105,20,141,116,5,152,105,0,141,117,5,142, - 118,5,200,200,140,119,5,160,19,177,254,141,108,5,141,109, - 5,162,8,169,0,141,113,5,157,0,210,224,3,176,8,157, - 9,5,169,255,157,57,5,202,16,233,169,128,162,3,157,75, - 5,202,16,250,96,169,1,141,113,5,169,0,240,238,41,3, - 201,3,240,240,224,64,176,236,192,26,176,232,170,169,128,157, - 75,5,169,0,157,57,5,157,60,5,157,63,5,173,111,5, - 157,12,5,173,112,5,10,10,10,133,254,24,173,114,5,105, - 48,72,173,115,5,105,1,168,104,24,101,254,157,97,5,152, - 105,0,157,100,5,24,173,114,5,105,148,133,254,173,115,5, - 105,0,133,255,173,112,5,10,109,112,5,10,168,177,254,157, - 79,5,200,177,254,157,82,5,41,7,141,110,5,200,177,254, - 157,85,5,200,177,254,157,88,5,200,177,254,157,91,5,200, - 177,254,157,94,5,160,0,173,110,5,201,3,208,2,160,2, - 201,7,208,2,160,4,185,175,11,133,254,185,176,11,133,255, - 189,85,5,74,74,74,74,24,109,111,5,141,111,5,141,194, - 7,168,173,110,5,201,7,208,15,152,10,168,177,254,157,45, - 5,200,140,111,5,76,131,7,177,254,157,45,5,189,85,5, - 41,15,24,109,111,5,141,111,5,172,111,5,173,110,5,201, - 5,8,177,254,40,240,8,221,45,5,208,3,56,233,1,157, - 48,5,189,79,5,72,41,3,168,185,181,11,157,54,5,104, - 74,74,74,74,160,62,201,15,240,16,160,55,201,14,240,10, - 160,48,201,13,240,4,24,105,0,168,185,185,11,157,51,5, - 96,216,165,252,72,165,253,72,165,254,72,165,255,72,173,113, - 5,208,3,76,2,11,173,78,5,240,3,76,107,9,173,108, - 5,205,109,5,240,3,76,88,9,173,103,5,240,3,76,220, - 8,162,2,188,75,5,48,3,157,75,5,157,69,5,202,16, - 242,173,118,5,133,252,173,119,5,133,253,172,104,5,132,254, - 204,106,5,208,25,173,107,5,240,20,173,104,5,172,105,5, - 140,104,5,206,107,5,208,232,141,104,5,168,16,226,162,0, - 177,252,201,254,208,14,172,104,5,200,196,254,240,67,140,104, - 5,76,26,8,157,66,5,24,152,105,85,168,232,224,3,144, - 223,172,104,5,177,252,16,122,201,255,240,118,74,74,74,41, - 14,170,189,161,11,141,126,8,189,162,11,141,127,8,173,67, - 5,133,255,32,147,8,140,104,5,192,85,176,4,196,254,208, - 143,164,254,140,104,5,76,2,11,32,148,6,160,255,96,48, - 251,168,96,48,247,56,152,229,255,168,96,48,239,24,152,101, - 255,168,96,48,231,141,108,5,141,109,5,200,96,48,221,173, - 68,5,48,216,141,107,5,200,140,105,5,24,152,101,255,141, - 106,5,96,136,48,10,177,252,201,143,240,4,201,239,208,243, - 200,96,162,2,189,72,5,240,5,222,72,5,16,99,189,75, - 5,208,94,188,66,5,192,64,176,87,173,116,5,133,252,173, - 117,5,133,253,177,252,133,254,24,152,105,64,168,177,252,133, - 255,37,254,201,255,240,58,188,69,5,177,254,41,192,208,12, - 177,254,41,63,157,15,5,254,69,5,16,235,201,64,208,19, - 177,254,41,63,141,111,5,189,15,5,141,112,5,32,188,6, - 76,72,9,201,128,208,10,177,254,41,63,157,72,5,254,69, - 5,202,16,144,174,103,5,232,138,41,63,141,103,5,206,109, - 5,208,14,173,108,5,141,109,5,173,103,5,208,3,238,104, - 5,172,48,5,173,82,5,41,7,201,5,240,4,201,6,208, - 1,136,140,39,5,160,0,201,5,240,4,201,6,208,2,160, - 2,201,7,208,2,160,40,140,44,5,162,2,189,82,5,41, - 224,157,40,5,189,97,5,133,252,189,100,5,133,253,189,57, - 5,201,255,240,54,201,15,208,32,189,63,5,240,45,222,63, - 5,189,63,5,208,37,188,9,5,240,1,136,152,157,9,5, - 189,88,5,157,63,5,76,229,9,189,57,5,74,168,177,252, - 144,4,74,74,74,74,41,15,157,9,5,188,45,5,189,82, - 5,41,7,201,1,208,31,136,152,200,221,48,5,8,169,1, - 40,208,2,10,10,61,60,5,240,12,188,48,5,192,255,208, - 5,169,0,157,9,5,152,157,36,5,169,1,141,110,5,189, - 57,5,201,15,240,56,41,7,168,185,205,12,133,254,189,57, - 5,41,8,8,138,40,24,240,2,105,3,168,185,91,5,37, - 254,240,27,189,51,5,157,36,5,142,110,5,202,16,8,141, - 39,5,169,0,141,44,5,232,189,54,5,157,40,5,189,57, - 5,41,15,201,15,240,16,254,57,5,189,57,5,201,15,208, - 6,189,88,5,157,63,5,189,75,5,16,10,189,9,5,208, - 5,169,64,157,75,5,254,60,5,160,0,189,82,5,74,74, - 74,74,144,1,136,74,144,1,200,24,152,125,45,5,157,45, - 5,189,48,5,201,255,208,2,160,0,24,152,125,48,5,157, - 48,5,202,48,3,76,150,9,173,40,5,141,43,5,173,82, - 5,41,7,170,160,3,173,110,5,240,3,188,213,12,152,72, - 185,185,12,8,41,127,170,152,41,3,10,168,189,36,5,153, - 0,210,200,189,9,5,224,3,208,3,173,9,5,29,40,5, - 40,16,2,169,0,153,0,210,104,168,136,41,3,208,207,160, - 8,173,44,5,153,0,210,24,104,133,255,104,133,254,104,133, - 253,104,133,252,96,104,170,240,78,201,2,240,6,104,104,202, - 208,251,96,165,20,197,20,240,252,173,36,2,201,134,208,7, - 173,37,2,201,11,240,230,173,36,2,141,143,11,173,37,2, - 141,144,11,169,134,141,36,2,169,11,141,37,2,104,104,240, - 3,56,233,1,141,93,11,104,168,104,170,169,112,32,120,5, - 169,0,162,0,76,120,5,165,20,197,20,240,252,173,36,2, - 201,134,208,174,173,37,2,201,11,208,167,173,143,11,141,36, - 2,173,144,11,141,37,2,169,64,76,120,5,32,203,7,144, - 3,32,117,11,76,255,255,178,5,221,5,168,6,59,6,123, - 6,148,6,159,6,82,6,147,8,153,8,157,8,165,8,173, - 8,183,8,205,8,185,11,250,11,59,12,128,160,32,64,255, - 241,228,215,203,192,181,170,161,152,143,135,127,120,114,107,101, - 95,90,85,80,75,71,67,63,60,56,53,50,47,44,42,39, - 37,35,33,31,29,28,26,24,23,22,20,19,18,17,16,15, - 14,13,12,11,10,9,8,7,6,5,4,3,2,1,0,0, - 0,0,0,0,242,233,218,206,191,182,170,161,152,143,137,128, - 122,113,107,101,95,0,86,80,103,96,90,85,81,76,72,67, - 63,61,57,52,51,57,45,42,40,37,36,33,31,30,0,0, - 15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0, - 0,56,11,140,10,0,10,106,9,232,8,106,8,239,7,128, - 7,8,7,174,6,70,6,230,5,149,5,65,5,246,4,176, - 4,110,4,48,4,246,3,187,3,132,3,82,3,34,3,244, - 2,200,2,160,2,122,2,85,2,52,2,20,2,245,1,216, - 1,189,1,164,1,141,1,119,1,96,1,78,1,56,1,39, - 1,21,1,6,1,247,0,232,0,219,0,207,0,195,0,184, - 0,172,0,162,0,154,0,144,0,136,0,127,0,120,0,112, - 0,106,0,100,0,94,0,87,0,82,0,50,0,10,0,0, - 1,2,131,0,1,2,3,1,0,2,131,1,0,2,3,1, - 2,128,3,128,64,32,16,8,4,2,1,3,3,3,3,7, - 11,15,19 -END_CONST_ARRAY; -CONST_ARRAY(byte, cm3_obx) - 255,255,0,5,223,12,76,18,11,76,120,5,76,203,7,0, - 0,0,0,0,0,0,0,0,160,227,237,227,160,240,236,225, - 249,229,242,160,246,160,178,174,177,160,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255, - 255,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,128,128,128,128,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,141,110, - 5,142,111,5,140,112,5,41,112,74,74,74,170,189,148,11, - 141,169,5,189,149,11,141,170,5,169,3,141,15,210,216,165, - 254,72,165,255,72,172,112,5,174,111,5,173,110,5,32,178, - 5,104,133,255,104,133,254,96,173,118,5,133,254,173,119,5, - 133,255,160,0,138,240,28,177,254,201,143,240,4,201,239,208, - 12,202,208,9,200,192,84,176,9,152,170,16,6,200,192,84, - 144,229,96,142,104,5,32,123,6,169,0,162,9,157,69,5, - 202,16,250,141,103,5,169,1,141,113,5,169,255,141,106,5, - 173,114,5,133,254,173,115,5,133,255,160,19,177,254,170,173, - 118,5,133,254,173,119,5,133,255,172,104,5,177,254,201,207, - 208,13,152,24,105,85,168,177,254,48,15,170,76,52,6,201, - 143,240,7,201,239,240,3,136,16,226,142,108,5,142,109,5, - 96,41,15,240,245,142,221,10,142,243,10,142,2,11,140,222, - 10,140,244,10,140,3,11,96,142,114,5,134,254,140,115,5, - 132,255,24,138,105,20,141,116,5,152,105,0,141,117,5,142, - 118,5,200,200,140,119,5,160,19,177,254,141,108,5,141,109, - 5,162,8,169,0,141,113,5,157,0,210,224,3,176,8,157, - 9,5,169,255,157,57,5,202,16,233,169,128,162,3,157,75, - 5,202,16,250,96,169,1,141,113,5,169,0,240,238,41,3, - 201,3,240,240,224,64,176,236,192,26,176,232,170,169,128,157, - 75,5,169,0,157,57,5,157,60,5,157,63,5,173,111,5, - 157,12,5,173,112,5,10,10,10,133,254,24,173,114,5,105, - 48,72,173,115,5,105,1,168,104,24,101,254,157,97,5,152, - 105,0,157,100,5,24,173,114,5,105,148,133,254,173,115,5, - 105,0,133,255,173,112,5,10,109,112,5,10,168,177,254,157, - 79,5,200,177,254,157,82,5,41,7,141,110,5,200,177,254, - 157,85,5,200,177,254,157,88,5,200,177,254,157,91,5,200, - 177,254,157,94,5,160,0,173,110,5,201,3,208,2,160,2, - 201,7,208,2,160,4,185,178,11,133,254,185,179,11,133,255, - 189,85,5,74,74,74,74,24,109,111,5,141,111,5,141,194, - 7,168,173,110,5,201,7,208,15,152,10,168,177,254,157,45, - 5,200,140,111,5,76,131,7,177,254,157,45,5,189,85,5, - 41,15,24,109,111,5,141,111,5,172,111,5,173,110,5,201, - 5,8,177,254,40,240,8,221,45,5,208,3,56,233,1,157, - 48,5,189,79,5,72,41,3,168,185,184,11,157,54,5,104, - 74,74,74,74,160,62,201,15,240,16,160,55,201,14,240,10, - 160,48,201,13,240,4,24,105,0,168,185,188,11,157,51,5, - 96,216,165,252,72,165,253,72,165,254,72,165,255,72,173,113, - 5,208,3,76,5,11,173,78,5,240,3,76,110,9,173,108, - 5,205,109,5,240,3,76,91,9,173,103,5,240,3,76,220, - 8,162,2,188,75,5,48,3,157,75,5,157,69,5,202,16, - 242,173,118,5,133,252,173,119,5,133,253,172,104,5,132,254, - 204,106,5,208,25,173,107,5,240,20,173,104,5,172,105,5, - 140,104,5,206,107,5,208,232,141,104,5,168,16,226,162,0, - 177,252,201,254,208,14,172,104,5,200,196,254,240,67,140,104, - 5,76,26,8,157,66,5,24,152,105,85,168,232,224,3,144, - 223,172,104,5,177,252,16,122,201,255,240,118,74,74,74,41, - 14,170,189,164,11,141,126,8,189,165,11,141,127,8,173,67, - 5,133,255,32,147,8,140,104,5,192,85,176,4,196,254,208, - 143,164,254,140,104,5,76,5,11,32,148,6,160,255,96,48, - 251,168,96,48,247,56,152,229,255,168,96,48,239,24,152,101, - 255,168,96,48,231,141,108,5,141,109,5,200,96,48,221,173, - 68,5,48,216,141,107,5,200,140,105,5,24,152,101,255,141, - 106,5,96,136,48,10,177,252,201,143,240,4,201,239,208,243, - 200,96,162,2,189,72,5,240,5,222,72,5,16,99,189,75, - 5,208,94,188,66,5,192,64,176,87,173,116,5,133,252,173, - 117,5,133,253,177,252,133,254,24,152,105,64,168,177,252,133, - 255,37,254,201,255,240,58,188,69,5,177,254,41,192,208,12, - 177,254,41,63,157,15,5,254,69,5,16,235,201,64,208,19, - 177,254,41,63,141,111,5,189,15,5,141,112,5,32,188,6, - 76,72,9,201,128,208,10,177,254,41,63,157,72,5,254,69, - 5,202,16,144,174,103,5,232,224,48,144,2,162,0,142,103, - 5,206,109,5,208,14,173,108,5,141,109,5,173,103,5,208, - 3,238,104,5,172,48,5,173,82,5,41,7,201,5,240,4, - 201,6,208,1,136,140,39,5,160,0,201,5,240,4,201,6, - 208,2,160,2,201,7,208,2,160,40,140,44,5,162,2,189, - 82,5,41,224,157,40,5,189,97,5,133,252,189,100,5,133, - 253,189,57,5,201,255,240,54,201,15,208,32,189,63,5,240, - 45,222,63,5,189,63,5,208,37,188,9,5,240,1,136,152, - 157,9,5,189,88,5,157,63,5,76,232,9,189,57,5,74, - 168,177,252,144,4,74,74,74,74,41,15,157,9,5,188,45, - 5,189,82,5,41,7,201,1,208,31,136,152,200,221,48,5, - 8,169,1,40,208,2,10,10,61,60,5,240,12,188,48,5, - 192,255,208,5,169,0,157,9,5,152,157,36,5,169,1,141, - 110,5,189,57,5,201,15,240,56,41,7,168,185,208,12,133, - 254,189,57,5,41,8,8,138,40,24,240,2,105,3,168,185, - 91,5,37,254,240,27,189,51,5,157,36,5,142,110,5,202, - 16,8,141,39,5,169,0,141,44,5,232,189,54,5,157,40, - 5,189,57,5,41,15,201,15,240,16,254,57,5,189,57,5, - 201,15,208,6,189,88,5,157,63,5,189,75,5,16,10,189, - 9,5,208,5,169,64,157,75,5,254,60,5,160,0,189,82, - 5,74,74,74,74,144,1,136,74,144,1,200,24,152,125,45, - 5,157,45,5,189,48,5,201,255,208,2,160,0,24,152,125, - 48,5,157,48,5,202,48,3,76,153,9,173,40,5,141,43, - 5,173,82,5,41,7,170,160,3,173,110,5,240,3,188,216, - 12,152,72,185,188,12,8,41,127,170,152,41,3,10,168,189, - 36,5,153,0,210,200,189,9,5,224,3,208,3,173,9,5, - 29,40,5,40,16,2,169,0,153,0,210,104,168,136,41,3, - 208,207,160,8,173,44,5,153,0,210,24,104,133,255,104,133, - 254,104,133,253,104,133,252,96,104,170,240,78,201,2,240,6, - 104,104,202,208,251,96,165,20,197,20,240,252,173,36,2,201, - 137,208,7,173,37,2,201,11,240,230,173,36,2,141,146,11, - 173,37,2,141,147,11,169,137,141,36,2,169,11,141,37,2, - 104,104,240,3,56,233,1,141,96,11,104,168,104,170,169,112, - 32,120,5,169,0,162,0,76,120,5,165,20,197,20,240,252, - 173,36,2,201,137,208,174,173,37,2,201,11,208,167,173,146, - 11,141,36,2,173,147,11,141,37,2,169,64,76,120,5,32, - 203,7,144,3,32,120,11,76,255,255,178,5,221,5,168,6, - 59,6,123,6,148,6,159,6,82,6,147,8,153,8,157,8, - 165,8,173,8,183,8,205,8,188,11,253,11,62,12,128,160, - 32,64,255,241,228,215,203,192,181,170,161,152,143,135,127,120, - 114,107,101,95,90,85,80,75,71,67,63,60,56,53,50,47, - 44,42,39,37,35,33,31,29,28,26,24,23,22,20,19,18, - 17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2, - 1,0,0,0,0,0,0,242,233,218,206,191,182,170,161,152, - 143,137,128,122,113,107,101,95,0,86,80,103,96,90,85,81, - 76,72,67,63,61,57,52,51,57,45,42,40,37,36,33,31, - 30,0,0,15,14,13,12,11,10,9,8,7,6,5,4,3, - 2,1,0,0,56,11,140,10,0,10,106,9,232,8,106,8, - 239,7,128,7,8,7,174,6,70,6,230,5,149,5,65,5, - 246,4,176,4,110,4,48,4,246,3,187,3,132,3,82,3, - 34,3,244,2,200,2,160,2,122,2,85,2,52,2,20,2, - 245,1,216,1,189,1,164,1,141,1,119,1,96,1,78,1, - 56,1,39,1,21,1,6,1,247,0,232,0,219,0,207,0, - 195,0,184,0,172,0,162,0,154,0,144,0,136,0,127,0, - 120,0,112,0,106,0,100,0,94,0,87,0,82,0,50,0, - 10,0,0,1,2,131,0,1,2,3,1,0,2,131,1,0, - 2,3,1,2,128,3,128,64,32,16,8,4,2,1,3,3, - 3,3,7,11,15,19 -END_CONST_ARRAY; -CONST_ARRAY(byte, cms_obx) - 255,255,0,5,186,15,234,234,234,76,21,8,76,92,15,35, - 5,169,5,173,5,184,5,0,0,0,0,0,0,0,0,0, - 0,0,0,128,128,128,128,128,128,0,0,0,0,0,0,255, - 255,255,255,255,255,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,130,0,0,6,6,0, - 128,20,128,128,0,0,0,0,0,0,0,0,0,0,0,15, - 15,0,0,0,0,0,0,0,0,255,0,0,0,0,0,0, - 1,2,131,0,1,2,3,1,0,2,131,1,0,2,3,1, - 2,128,3,128,64,32,16,8,4,2,1,75,8,118,8,133, - 9,19,9,80,9,110,9,124,9,26,9,128,160,32,64,255, - 241,228,215,203,192,181,170,161,152,143,135,127,120,114,107,101, - 95,90,85,80,75,71,67,63,60,56,53,50,47,44,42,39, - 37,35,33,31,29,28,26,24,23,22,20,19,18,17,16,15, - 14,13,12,11,10,9,8,7,6,5,4,3,2,1,0,0, - 0,0,0,0,242,233,218,206,191,182,170,161,152,143,137,128, - 122,113,107,101,95,0,86,80,103,96,90,85,81,76,72,67, - 63,61,57,52,51,57,45,42,40,37,36,33,31,30,0,0, - 15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0, - 0,56,11,140,10,0,10,106,9,232,8,106,8,239,7,128, - 7,8,7,174,6,70,6,230,5,149,5,65,5,246,4,176, - 4,110,4,48,4,246,3,187,3,132,3,82,3,34,3,244, - 2,200,2,160,2,122,2,85,2,52,2,20,2,245,1,216, - 1,189,1,164,1,141,1,119,1,96,1,78,1,56,1,39, - 1,21,1,6,1,247,0,232,0,219,0,207,0,195,0,184, - 0,172,0,162,0,154,0,144,0,136,0,127,0,120,0,112, - 0,106,0,100,0,94,0,87,0,82,0,50,0,10,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,0, - 0,0,0,1,1,1,1,1,1,1,1,2,2,2,2,0, - 0,0,0,1,1,1,1,2,2,2,2,2,3,3,3,0, - 0,1,1,1,2,2,2,2,2,3,3,3,3,4,4,0, - 0,1,1,1,2,2,2,3,3,3,4,4,4,5,5,0, - 0,1,1,2,2,2,3,3,4,4,4,5,5,6,6,0, - 0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,0, - 1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,0, - 1,1,2,2,3,4,4,5,5,6,7,7,8,8,9,0, - 1,1,2,3,3,4,5,5,6,7,7,8,9,9,10,0, - 1,1,2,3,4,4,5,6,7,7,8,9,10,10,11,0, - 1,2,2,3,4,5,6,7,8,9,9,10,11,11,12,0, - 1,2,3,4,5,5,6,7,8,9,10,10,11,12,13,0, - 1,2,3,4,5,6,7,7,8,9,10,11,12,13,14,0, - 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,6, - 12,12,12,18,12,28,12,38,12,50,12,79,12,233,5,42, - 6,107,6,161,11,196,11,185,11,0,0,0,0,0,0,0, - 0,0,0,3,3,3,3,7,11,15,19,141,143,5,142,144, - 5,140,145,5,41,112,74,74,74,170,169,3,141,15,210,189, - 213,5,141,73,8,189,214,5,141,74,8,169,3,141,31,210, - 169,1,141,146,5,172,145,5,174,144,5,173,143,5,76,72, - 8,173,147,5,133,252,173,148,5,133,253,160,0,138,240,28, - 177,252,201,143,240,4,201,239,208,12,202,208,9,200,192,84, - 176,9,152,170,16,6,200,192,84,144,229,96,142,149,5,169, - 0,162,5,157,17,5,157,23,5,157,29,5,202,16,244,141, - 150,5,141,157,5,160,255,140,159,5,173,153,5,133,252,173, - 154,5,133,253,160,19,177,252,170,173,147,5,133,252,173,148, - 5,133,253,172,149,5,152,72,169,15,141,169,5,141,170,5, - 177,252,201,135,208,35,152,72,24,105,85,168,177,252,16,2, - 169,15,41,15,141,169,5,152,24,105,85,168,177,252,16,3, - 173,169,5,41,15,141,170,5,104,76,243,8,177,252,201,143, - 240,7,201,239,240,3,136,16,199,104,168,177,252,201,207,208, - 13,152,24,105,85,168,177,252,48,15,170,76,19,9,201,143, - 240,7,201,239,240,3,136,16,226,142,151,5,142,152,5,96, - 142,153,5,134,252,140,154,5,132,253,24,138,105,20,141,155, - 5,152,105,0,141,156,5,24,138,105,0,141,147,5,152,105, - 2,141,148,5,160,19,177,252,141,151,5,141,152,5,162,3, - 142,31,210,142,15,210,169,0,141,146,5,160,8,169,0,153, - 0,210,153,16,210,192,6,176,8,153,35,5,169,255,153,41, - 5,136,16,233,169,128,162,5,157,29,5,202,16,250,141,157, - 5,96,169,0,240,240,141,157,5,240,11,173,143,5,41,7, - 170,169,128,157,29,5,172,145,5,173,144,5,141,143,5,140, - 145,5,169,0,157,83,5,157,41,5,157,77,5,152,10,10, - 10,133,254,24,173,153,5,105,48,72,173,154,5,105,1,168, - 104,24,101,254,157,101,5,152,105,0,157,71,5,24,173,153, - 5,105,148,133,252,173,154,5,105,0,133,253,173,145,5,10, - 109,145,5,10,168,140,145,5,200,200,200,200,200,177,252,157, - 113,5,136,177,252,157,107,5,136,177,252,157,119,5,136,136, - 177,252,157,59,5,160,0,41,7,201,3,208,2,160,2,201, - 7,208,2,160,4,185,247,7,133,254,185,248,7,133,255,172, - 145,5,200,200,177,252,74,74,74,74,24,109,143,5,141,143, - 5,141,159,10,168,189,59,5,41,7,201,7,208,15,152,10, - 168,177,254,157,125,5,200,140,143,5,76,92,10,177,254,157, - 125,5,172,145,5,200,200,177,252,41,15,24,109,143,5,141, - 143,5,172,143,5,189,59,5,41,7,201,5,8,177,254,40, - 240,8,221,125,5,208,3,56,233,1,157,89,5,172,145,5, - 177,252,72,41,3,168,185,229,5,157,131,5,104,74,74,74, - 74,160,62,201,15,240,16,160,55,201,14,240,10,160,48,201, - 13,240,4,24,105,50,168,185,233,5,157,137,5,96,216,165, - 252,72,165,253,72,165,254,72,165,255,72,173,146,5,208,3, - 76,47,15,173,157,5,240,3,76,225,12,173,152,5,205,151, - 5,176,3,76,206,12,173,150,5,240,3,76,158,11,162,5, - 169,0,188,29,5,48,3,157,29,5,157,17,5,202,16,242, - 173,147,5,133,252,173,148,5,133,253,172,149,5,140,161,5, - 204,159,5,208,25,173,160,5,240,20,173,149,5,172,158,5, - 140,149,5,206,160,5,208,232,141,149,5,168,16,226,162,0, - 177,252,201,254,240,28,157,53,5,230,253,177,252,198,253,201, - 254,240,15,157,56,5,24,152,105,85,168,232,224,3,144,224, - 176,34,172,149,5,200,204,161,5,240,80,140,149,5,76,250, - 10,104,41,14,170,189,253,7,141,135,11,189,254,7,141,136, - 11,76,129,11,172,149,5,177,252,16,57,201,255,240,53,74, - 74,74,72,41,1,240,218,104,41,14,170,189,233,7,141,135, - 11,189,234,7,141,136,11,173,54,5,133,254,32,134,11,140, - 149,5,192,85,176,5,204,161,5,208,179,172,161,5,140,149, - 5,76,47,15,76,94,12,165,254,48,18,41,15,141,169,5, - 173,55,5,16,3,173,169,5,41,15,141,170,5,200,96,165, - 254,48,250,41,1,141,184,5,200,96,173,179,5,48,20,206, - 180,5,208,51,169,50,141,180,5,206,179,5,208,41,206,179, - 5,200,96,165,254,48,214,141,180,5,238,180,5,165,254,48, - 204,141,180,5,238,180,5,173,55,5,141,179,5,16,5,169, - 0,141,179,5,238,179,5,104,104,76,225,12,32,110,9,160, - 255,96,165,254,48,249,168,96,165,254,48,243,56,152,229,254, - 168,96,165,254,48,233,24,152,101,254,168,96,165,254,48,223, - 141,151,5,141,152,5,200,96,165,254,48,211,173,55,5,48, - 206,200,140,158,5,24,152,101,254,141,159,5,173,55,5,141, - 160,5,192,84,96,136,48,10,177,252,201,143,240,4,201,239, - 208,243,200,96,162,5,189,23,5,240,5,222,23,5,16,87, - 189,29,5,208,82,188,53,5,201,64,176,75,173,155,5,133, - 252,173,156,5,133,253,177,252,133,254,24,152,105,64,168,177, - 252,133,255,188,17,5,177,254,41,192,208,12,177,254,41,63, - 157,47,5,254,17,5,16,235,201,64,208,13,177,254,41,63, - 188,47,5,32,150,9,76,190,12,201,128,208,10,177,254,41, - 63,157,23,5,254,17,5,202,16,156,174,150,5,232,138,41, - 63,141,150,5,206,152,5,208,14,173,151,5,141,152,5,173, - 150,5,208,3,238,149,5,172,89,5,173,59,5,41,7,201, - 5,240,4,201,6,208,1,136,140,162,5,160,0,201,5,240, - 4,201,6,208,2,160,2,201,7,208,2,160,40,140,164,5, - 172,92,5,173,62,5,41,7,201,5,240,4,201,6,208,1, - 136,140,163,5,160,0,201,5,240,4,201,6,208,2,160,2, - 201,7,208,2,160,40,140,165,5,162,5,189,59,5,41,224, - 157,65,5,189,101,5,133,252,189,71,5,133,253,189,41,5, - 201,255,240,55,201,15,208,33,189,77,5,240,46,222,77,5, - 189,77,5,208,38,188,35,5,240,1,136,152,157,35,5,189, - 119,5,157,77,5,136,76,133,13,189,41,5,74,168,177,252, - 144,4,74,74,74,74,41,15,157,35,5,188,125,5,189,59, - 5,41,7,201,1,208,31,136,152,200,221,89,5,8,169,1, - 40,208,2,10,10,61,83,5,240,12,188,89,5,192,255,208, - 5,169,0,157,35,5,152,157,95,5,169,1,141,168,5,189, - 41,5,201,15,240,76,41,7,168,185,205,5,133,254,189,41, - 5,41,8,8,138,40,24,240,2,105,6,168,185,107,5,37, - 254,240,47,189,137,5,157,95,5,142,168,5,202,224,2,240, - 15,224,255,208,22,141,162,5,169,0,141,164,5,76,5,14, - 173,140,5,141,163,5,169,0,141,165,5,232,189,131,5,157, - 65,5,189,41,5,41,15,201,15,240,18,254,41,5,189,41, - 5,41,15,201,15,208,6,189,119,5,157,77,5,189,29,5, - 16,10,189,35,5,208,5,169,64,157,29,5,254,83,5,160, - 0,189,59,5,74,74,74,74,144,1,136,74,144,1,200,24, - 152,125,125,5,157,125,5,189,89,5,201,255,208,2,160,0, - 24,152,125,89,5,157,89,5,202,48,3,76,53,13,32,123, - 15,173,65,5,141,166,5,173,68,5,141,167,5,173,59,5, - 41,7,32,181,15,152,72,185,185,5,8,41,127,170,152,41, - 3,10,168,224,3,208,3,76,196,14,189,173,5,208,39,189, - 95,5,153,0,210,189,35,5,29,65,5,40,16,2,169,0, - 153,1,210,104,168,136,41,3,240,3,76,127,14,173,164,5, - 141,8,210,76,228,14,40,76,173,14,173,173,5,208,23,173, - 162,5,153,0,210,173,35,5,13,166,5,40,16,2,169,0, - 153,1,210,76,173,14,40,76,173,14,173,62,5,41,7,32, - 181,15,152,72,185,185,5,8,41,127,170,152,41,3,10,168, - 224,3,208,3,76,60,15,189,176,5,208,30,189,98,5,153, - 16,210,189,38,5,29,68,5,40,16,2,169,0,153,17,210, - 104,168,136,41,3,240,7,76,236,14,40,76,26,15,173,165, - 5,141,24,210,24,104,133,255,104,133,254,104,133,253,104,133, - 252,96,173,176,5,208,23,173,163,5,153,16,210,173,38,5, - 13,167,5,40,16,2,169,0,153,17,210,76,26,15,40,76, - 26,15,32,168,10,176,25,173,184,5,240,20,173,157,5,141, - 183,5,169,1,141,157,5,32,168,10,173,183,5,141,157,5, - 96,173,169,5,10,10,10,10,141,171,5,173,170,5,10,10, - 10,10,141,172,5,162,2,134,200,173,171,5,29,35,5,170, - 189,233,6,166,200,157,35,5,173,172,5,29,38,5,170,189, - 233,6,166,200,157,38,5,202,16,221,96,168,185,13,8,168, - 96 -END_CONST_ARRAY; -CONST_ARRAY(byte, dlt_obx) - 255,255,0,4,70,12,255,241,228,215,203,192,181,170,161,152, - 143,135,127,121,114,107,101,95,90,85,80,75,71,67,63,60, - 56,53,50,47,44,42,39,37,35,33,31,29,28,26,24,23, - 22,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6, - 5,4,255,241,228,215,242,233,218,206,191,182,170,161,152,143, - 137,128,122,113,107,101,95,92,86,80,103,96,90,85,81,76, - 72,67,63,61,57,52,51,48,45,42,40,37,36,33,31,30, - 28,27,25,0,22,21,0,10,9,8,7,6,5,4,3,2, - 1,0,242,233,218,206,242,233,218,206,191,182,170,161,152,143, - 137,128,122,113,107,101,95,92,86,80,103,96,90,85,81,76, - 72,67,63,61,57,52,51,48,45,42,40,37,36,33,31,30, - 28,27,25,0,22,21,0,10,9,8,7,6,5,4,3,2, - 1,0,242,233,218,206,255,241,228,216,202,192,181,171,162,153, - 142,135,127,120,115,108,102,97,90,85,81,75,72,67,63,60, - 57,52,51,48,45,42,40,37,36,33,31,30,28,27,25,23, - 22,21,19,18,17,16,15,14,13,12,11,10,9,8,7,6, - 5,4,3,2,1,255,76,9,5,76,200,5,76,183,5,136, - 140,54,3,169,126,141,53,3,162,6,142,51,3,162,1,142, - 52,3,32,51,5,32,95,5,32,163,5,32,139,5,169,1, - 141,50,3,169,3,141,15,210,96,162,0,160,32,142,48,3, - 140,49,3,160,0,173,48,3,153,0,2,173,49,3,153,64, - 2,173,48,3,24,105,128,141,48,3,144,3,238,49,3,200, - 192,64,208,225,96,162,0,160,68,142,48,3,140,49,3,160, - 0,173,48,3,153,128,2,173,49,3,153,160,2,173,48,3, - 24,105,64,141,48,3,144,3,238,49,3,200,192,32,208,225, - 96,173,0,76,41,1,74,106,106,168,162,0,185,128,4,157, - 64,4,200,232,224,64,208,244,96,160,3,169,0,153,40,3, - 153,32,3,153,36,3,153,44,3,136,16,241,96,169,0,141, - 50,3,160,7,169,0,153,0,210,136,16,250,96,96,173,50, - 3,240,250,173,40,3,13,41,3,13,42,3,13,43,3,141, - 8,210,174,36,3,172,32,3,142,0,210,140,1,210,174,37, - 3,172,33,3,142,2,210,140,3,210,174,38,3,172,34,3, - 142,4,210,140,5,210,174,39,3,172,35,3,142,6,210,140, - 7,210,206,52,3,208,74,173,51,3,141,52,3,238,53,3, - 238,53,3,16,28,238,54,3,169,0,141,53,3,32,199,6, - 173,4,3,13,5,3,13,6,3,13,7,3,208,3,76,183, - 5,173,4,3,240,3,32,97,7,173,5,3,240,3,32,192, - 7,173,6,3,240,3,32,31,8,173,7,3,240,3,32,126, - 8,173,4,3,240,8,173,44,3,240,3,32,221,8,173,5, - 3,240,8,173,45,3,240,3,32,206,9,173,6,3,240,8, - 173,46,3,240,3,32,191,10,173,7,3,240,8,173,47,3, - 240,3,32,131,11,96,192,67,144,14,169,0,141,4,3,141, - 32,3,141,40,3,76,230,6,192,66,208,15,189,128,64,141, - 51,3,141,52,3,238,54,3,76,199,6,192,65,208,9,189, - 128,64,141,54,3,76,199,6,104,104,76,183,5,174,54,3, - 188,0,64,192,64,176,191,189,128,64,141,24,3,185,0,2, - 133,224,185,64,2,133,225,169,1,141,4,3,188,0,65,192, - 64,176,78,189,128,65,141,25,3,185,0,2,133,226,185,64, - 2,133,227,169,1,141,5,3,188,0,66,192,64,176,63,189, - 128,66,141,26,3,185,0,2,133,228,185,64,2,133,229,169, - 1,141,6,3,188,0,67,192,64,176,48,189,128,67,141,27, - 3,185,0,2,133,230,185,64,2,133,231,169,1,141,7,3, - 96,169,0,141,5,3,141,33,3,141,41,3,240,186,169,0, - 141,6,3,141,34,3,141,42,3,240,201,169,0,141,7,3, - 141,35,3,141,43,3,96,172,53,3,177,224,48,11,200,177, - 224,48,1,96,104,104,76,31,6,24,109,24,3,41,127,141, - 8,3,169,15,141,0,3,141,44,3,200,177,224,170,189,160, - 2,133,233,133,241,133,249,189,128,2,133,232,73,16,133,240, - 73,48,133,248,160,49,177,232,141,12,3,160,51,177,232,41, - 127,141,16,3,169,0,141,20,3,141,28,3,160,48,177,232, - 41,213,141,40,3,96,172,53,3,177,226,48,11,200,177,226, - 48,1,96,104,104,76,31,6,24,109,25,3,41,127,141,9, - 3,169,15,141,1,3,141,45,3,200,177,226,170,189,160,2, - 133,235,133,243,133,251,189,128,2,133,234,73,16,133,242,73, - 48,133,250,160,49,177,234,141,13,3,160,51,177,234,41,127, - 141,17,3,169,0,141,21,3,141,29,3,160,48,177,234,41, - 131,141,41,3,96,172,53,3,177,228,48,11,200,177,228,48, - 1,96,104,104,76,31,6,24,109,26,3,41,127,141,10,3, - 169,15,141,2,3,141,46,3,200,177,228,170,189,160,2,133, - 237,133,245,133,253,189,128,2,133,236,73,16,133,244,73,48, - 133,252,160,49,177,236,141,14,3,160,51,177,236,41,127,141, - 18,3,169,0,141,22,3,141,30,3,160,48,177,236,41,169, - 141,42,3,96,172,53,3,177,230,48,11,200,177,230,48,1, - 96,104,104,76,31,6,24,109,27,3,41,127,141,11,3,169, - 15,141,3,3,141,47,3,200,177,230,170,189,160,2,133,239, - 133,247,133,255,189,128,2,133,238,73,16,133,246,73,48,133, - 254,160,49,177,238,141,15,3,160,51,177,238,41,127,141,19, - 3,169,0,141,23,3,141,31,3,160,48,177,238,41,129,141, - 43,3,96,172,0,3,48,70,177,232,141,32,3,177,240,208, - 9,32,108,9,206,0,3,76,79,9,201,1,240,39,201,3, - 208,16,173,8,3,24,113,248,170,173,28,3,141,55,3,76, - 24,9,173,28,3,24,113,248,141,55,3,174,8,3,32,150, - 9,206,0,3,96,177,248,141,36,3,206,0,3,96,32,108, - 9,160,49,177,232,240,30,206,12,3,240,3,76,79,9,173, - 32,3,41,15,240,11,206,32,3,177,232,141,12,3,76,79, - 9,141,44,3,96,173,28,3,24,160,50,113,232,141,28,3, - 206,16,3,208,12,238,20,3,160,51,177,232,41,127,141,16, - 3,96,173,20,3,41,3,24,105,52,168,177,232,170,160,51, - 177,232,48,14,138,109,8,3,170,173,28,3,141,55,3,76, - 150,9,138,109,28,3,141,55,3,174,8,3,189,0,4,24, - 109,55,3,141,36,3,173,40,3,41,4,208,1,96,172,0, - 3,177,240,208,21,138,24,160,0,113,248,170,189,0,4,24, - 109,55,3,24,105,255,141,38,3,96,173,36,3,24,105,255, - 141,38,3,96,172,1,3,48,70,177,234,141,33,3,177,242, - 208,9,32,93,10,206,1,3,76,64,10,201,1,240,39,201, - 3,208,16,173,9,3,24,113,250,170,173,29,3,141,55,3, - 76,9,10,173,29,3,24,113,250,141,55,3,174,9,3,32, - 135,10,206,1,3,96,177,250,141,37,3,206,1,3,96,32, - 93,10,160,49,177,234,240,30,206,13,3,240,3,76,64,10, - 173,33,3,41,15,240,11,206,33,3,177,234,141,13,3,76, - 64,10,141,45,3,96,173,29,3,24,160,50,113,234,141,29, - 3,206,17,3,208,12,238,21,3,160,51,177,234,41,127,141, - 17,3,96,173,21,3,41,3,24,105,52,168,177,234,170,160, - 51,177,234,48,14,138,109,9,3,170,173,29,3,141,55,3, - 76,135,10,138,109,29,3,141,55,3,174,9,3,189,0,4, - 24,109,55,3,141,37,3,173,41,3,41,2,208,1,96,172, - 1,3,177,242,208,21,138,24,160,0,113,250,170,189,0,4, - 24,109,55,3,24,105,255,141,39,3,96,173,37,3,24,105, - 255,141,39,3,96,172,2,3,48,70,177,236,141,34,3,177, - 244,208,9,32,78,11,206,2,3,76,49,11,201,1,240,39, - 201,3,208,16,173,10,3,24,113,252,170,173,30,3,141,55, - 3,76,250,10,173,30,3,24,113,252,141,55,3,174,10,3, - 32,120,11,206,2,3,96,177,252,141,38,3,206,2,3,96, - 32,78,11,160,49,177,236,240,30,206,14,3,240,3,76,49, - 11,173,34,3,41,15,240,11,206,34,3,177,236,141,14,3, - 76,49,11,141,46,3,96,173,30,3,24,160,50,113,236,141, - 30,3,206,18,3,208,12,238,22,3,160,51,177,236,41,127, - 141,18,3,96,173,22,3,41,3,24,105,52,168,177,236,170, - 160,51,177,236,48,14,138,109,10,3,170,173,30,3,141,55, - 3,76,120,11,138,109,30,3,141,55,3,174,10,3,189,0, - 4,24,109,55,3,141,38,3,96,172,3,3,48,70,177,238, - 141,35,3,177,246,208,9,32,18,12,206,3,3,76,245,11, - 201,1,240,39,201,3,208,16,173,11,3,24,113,254,170,173, - 31,3,141,55,3,76,190,11,173,31,3,24,113,254,141,55, - 3,174,11,3,32,60,12,206,3,3,96,177,254,141,39,3, - 206,3,3,96,32,18,12,160,49,177,238,240,30,206,15,3, - 240,3,76,245,11,173,35,3,41,15,240,11,206,35,3,177, - 238,141,15,3,76,245,11,141,47,3,96,173,31,3,24,160, - 50,113,238,141,31,3,206,19,3,208,12,238,23,3,160,51, - 177,238,41,127,141,19,3,96,173,23,3,41,3,24,105,52, - 168,177,238,170,160,51,177,238,48,14,138,109,11,3,170,173, - 31,3,141,55,3,76,60,12,138,109,31,3,141,55,3,174, - 11,3,189,0,4,24,109,55,3,141,39,3,96 -END_CONST_ARRAY; -CONST_ARRAY(byte, mpt_obx) - 255,255,0,5,178,13,76,205,11,173,46,7,208,1,96,169, - 0,141,28,14,238,29,14,173,23,14,205,187,13,144,80,206, - 21,14,240,3,76,197,5,162,0,142,23,14,169,0,157,237, - 13,157,245,13,189,179,13,133,236,189,183,13,133,237,172,22, - 14,177,236,200,201,255,240,7,201,254,208,15,76,42,12,177, - 236,48,249,10,168,140,22,14,76,59,5,157,233,13,177,236, - 157,213,13,232,224,4,208,196,200,140,22,14,76,197,5,206, - 21,14,16,87,173,188,13,141,21,14,162,3,222,245,13,16, - 68,189,233,13,10,168,185,255,255,133,236,200,185,255,255,133, - 237,5,236,240,48,189,237,13,141,31,14,32,62,7,172,31, - 14,200,152,157,237,13,189,241,13,157,245,13,224,2,208,21, - 189,197,13,73,15,10,10,10,10,105,69,141,161,13,169,10, - 105,0,141,162,13,202,16,180,238,23,14,162,1,173,27,14, - 201,2,240,2,162,3,173,27,14,201,2,208,5,236,25,14, - 240,3,76,118,6,181,240,61,114,6,240,18,160,40,177,236, - 24,125,225,13,32,117,9,56,125,1,14,157,203,13,202,16, - 213,169,3,141,15,210,165,241,41,16,240,15,172,226,13,185, - 198,9,141,201,13,185,5,10,141,202,13,173,201,13,141,0, - 210,173,202,13,141,2,210,173,203,13,141,4,210,173,204,13, - 141,6,210,173,193,13,162,255,172,27,14,192,1,208,5,174, - 25,14,240,3,141,1,210,173,194,13,224,1,240,3,141,3, - 210,192,2,240,20,173,195,13,224,2,240,3,141,5,210,173, - 196,13,224,3,240,3,141,7,210,165,240,5,241,5,242,5, - 243,13,28,14,141,8,210,96,4,2,0,0,189,217,13,133, - 236,189,221,13,133,237,5,236,208,8,157,193,13,149,240,76, - 248,5,180,244,192,32,240,66,177,236,56,253,197,13,44,58, - 7,240,2,41,240,157,193,13,200,177,236,141,30,14,200,148, - 244,41,7,240,60,168,185,126,9,141,203,6,185,133,9,141, - 204,6,173,30,14,74,74,74,74,74,9,40,168,177,236,24, - 32,255,255,169,0,149,240,76,248,5,189,9,14,240,18,222, - 13,14,208,13,157,13,14,189,193,13,41,15,240,3,222,193, - 13,160,35,177,236,149,240,189,17,14,24,105,37,168,41,3, - 157,17,14,136,177,236,125,209,13,157,225,13,32,119,9,157, - 201,13,189,5,14,240,6,222,5,14,76,223,5,189,189,13, - 141,30,7,16,254,76,194,8,0,76,229,8,0,76,251,8, - 0,76,21,9,0,76,37,9,0,76,56,9,0,76,66,9, - 16,76,72,9,169,0,157,197,13,172,31,14,136,200,177,236, - 201,254,208,4,140,31,14,96,201,224,144,8,173,187,13,141, - 23,14,208,233,201,208,144,10,41,15,141,188,13,141,21,14, - 16,219,201,192,144,9,41,15,73,15,157,197,13,16,206,201, - 128,144,7,41,63,157,241,13,16,195,201,64,144,27,200,140, - 31,14,41,31,157,229,13,10,168,185,255,255,157,217,13,200, - 185,255,255,157,221,13,76,62,7,140,31,14,141,30,14,24, - 125,213,13,157,209,13,173,27,14,240,66,201,2,240,58,189, - 229,13,201,31,208,55,173,30,14,56,233,1,41,15,168,177, - 254,133,253,152,9,16,168,177,254,133,248,160,1,5,253,208, - 2,160,0,140,26,14,169,0,133,252,157,217,13,157,221,13, - 138,10,141,24,14,142,25,14,96,224,2,176,99,189,217,13, - 133,238,189,221,13,133,239,5,238,240,74,160,32,177,238,41, - 15,157,249,13,177,238,41,112,74,74,157,189,13,200,177,238, - 10,10,72,41,63,157,5,14,104,41,192,157,205,13,200,177, - 238,157,9,14,157,13,14,169,0,149,244,157,17,14,157,253, - 13,157,1,14,189,209,13,157,225,13,32,117,9,157,201,13, - 236,25,14,240,1,96,160,255,140,25,14,200,140,26,14,96, - 224,2,208,51,172,211,13,185,69,11,141,121,13,185,129,11, - 141,127,13,169,0,133,249,133,250,173,231,13,41,15,168,177, - 254,133,251,152,9,16,168,177,254,141,137,13,5,251,208,6, - 141,121,13,141,127,13,96,173,232,13,41,15,168,177,254,133, - 253,152,9,16,168,177,254,5,253,240,15,177,254,56,229,253, - 133,248,169,0,133,252,169,141,208,2,169,173,141,97,13,141, - 56,13,169,24,141,7,210,96,173,29,14,41,7,74,74,144, - 18,208,24,189,249,13,24,157,1,14,125,201,13,157,201,13, - 76,223,5,169,0,157,1,14,76,223,5,189,201,13,56,253, - 249,13,157,201,13,56,169,0,253,249,13,157,1,14,76,223, - 5,189,253,13,24,157,1,14,125,201,13,157,201,13,24,189, - 253,13,125,249,13,157,253,13,76,223,5,189,225,13,56,253, - 253,13,157,225,13,32,117,9,76,5,9,169,0,56,253,253, - 13,157,1,14,189,201,13,56,253,253,13,76,5,9,189,225, - 13,24,125,253,13,76,28,9,32,85,9,76,208,8,32,85, - 9,24,125,225,13,32,155,9,76,223,5,188,253,13,189,249, - 13,48,2,200,200,136,152,157,253,13,221,249,13,208,8,189, - 249,13,73,255,157,249,13,189,253,13,96,41,63,29,205,13, - 168,185,255,255,96,148,145,152,165,173,180,192,9,9,9,9, - 9,9,9,64,0,32,0,125,201,13,157,201,13,96,125,209, - 13,157,225,13,32,117,9,157,201,13,96,157,201,13,189,141, - 9,16,12,157,201,13,169,128,208,5,157,201,13,169,1,13, - 28,14,141,28,14,96,45,10,210,157,201,13,96,242,51,150, - 226,56,140,0,106,232,106,239,128,8,174,70,230,149,65,246, - 176,110,48,246,187,132,82,34,244,200,160,122,85,52,20,245, - 216,189,164,141,119,96,78,56,39,21,6,247,232,219,207,195, - 184,172,162,154,144,136,127,120,112,106,100,94,13,13,12,11, - 11,10,10,9,8,8,7,7,7,6,6,5,5,5,4,4, - 4,4,3,3,3,3,3,2,2,2,2,2,2,2,1,1, - 1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,24,24,24,24,24, - 24,24,24,24,24,24,24,24,24,24,24,22,22,23,23,23, - 23,24,24,24,24,24,25,25,25,25,26,21,21,22,22,22, - 23,23,24,24,24,25,25,26,26,26,27,20,21,21,22,22, - 23,23,24,24,24,25,25,26,26,27,27,20,20,21,21,22, - 22,23,23,24,25,25,26,26,27,27,28,19,20,20,21,22, - 22,23,23,24,25,25,26,26,27,28,28,19,19,20,21,21, - 22,23,23,24,25,25,26,27,27,28,29,18,19,20,20,21, - 22,23,23,24,25,25,26,27,28,28,29,18,19,19,20,21, - 22,22,23,24,25,26,26,27,28,29,29,18,18,19,20,21, - 22,22,23,24,25,26,26,27,28,29,30,17,18,19,20,21, - 22,22,23,24,25,26,26,27,28,29,30,17,18,19,20,21, - 21,22,23,24,25,26,27,27,28,29,30,17,18,19,20,20, - 21,22,23,24,25,26,27,28,28,29,30,17,18,19,19,20, - 21,22,23,24,25,26,27,28,29,29,30,17,18,18,19,20, - 21,22,23,24,25,26,27,28,29,30,30,16,17,18,19,20, - 21,22,23,24,25,26,27,28,29,30,31,32,34,36,38,41, - 43,46,48,51,55,58,61,65,69,73,77,82,87,92,97,103, - 110,116,123,130,138,146,155,164,174,184,195,207,220,233,246,5, - 21,37,55,73,93,113,135,159,184,210,237,11,42,75,110,147, - 186,227,15,62,112,164,219,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1, - 1,1,1,1,1,1,1,2,2,2,2,2,2,2,3,3, - 3,3,3,229,42,64,89,100,238,8,166,11,12,12,12,12, - 12,13,13,142,50,7,140,54,7,41,7,168,185,189,11,141, - 227,11,185,197,11,141,228,11,76,255,255,173,54,7,174,50, - 7,141,148,7,141,155,7,142,149,7,142,156,7,24,105,64, - 141,129,5,141,135,5,144,1,232,142,130,5,142,136,5,24, - 105,128,141,124,9,144,1,232,142,125,9,232,141,31,12,142, - 32,12,162,9,189,255,255,157,179,13,202,16,247,206,188,13, - 169,0,141,46,7,162,98,157,189,13,202,16,250,162,8,157, - 0,210,202,16,250,96,32,42,12,173,50,7,10,141,22,14, - 173,187,13,141,23,14,169,1,141,21,14,141,46,7,96,173, - 54,7,133,254,173,50,7,133,255,96,173,54,7,41,3,170, - 173,50,7,32,198,7,173,26,14,240,238,14,54,7,32,190, - 12,169,1,141,27,14,173,26,14,240,222,201,1,208,5,160, - 0,238,26,14,177,252,174,24,14,74,74,74,74,9,16,141, - 10,212,141,10,212,157,1,210,177,252,9,16,141,10,212,141, - 10,212,157,1,210,200,208,206,230,253,165,253,197,248,208,198, - 140,26,14,96,144,21,169,234,141,153,12,141,154,12,141,155, - 12,141,166,12,141,167,12,141,168,12,96,169,141,141,153,12, - 141,166,12,169,10,141,154,12,141,167,12,169,212,141,155,12, - 141,168,12,96,169,0,141,26,14,173,50,7,74,32,190,12, - 169,1,141,27,14,32,128,12,173,27,14,208,248,96,169,2, - 141,27,14,141,25,14,169,24,141,7,210,169,17,133,250,169, - 13,133,251,169,173,141,97,13,141,56,13,160,0,140,121,13, - 140,127,13,174,11,212,177,252,74,74,74,74,9,16,141,7, - 210,32,117,13,236,11,212,240,251,141,5,210,174,11,212,177, - 252,230,252,208,16,230,253,198,248,208,10,169,173,141,97,13, - 141,56,13,169,8,9,16,141,7,210,32,117,13,236,11,212, - 240,251,141,5,210,173,27,14,208,185,96,24,165,249,105,0, - 133,249,165,250,105,0,133,250,144,15,230,251,165,251,201,0, - 208,7,140,121,13,140,127,13,96,177,250,36,249,48,4,74, - 74,74,74,41,15,168,185,69,10,160,0,96,160,0,140,27, - 14,140,26,14,136,140,25,14,96 -END_CONST_ARRAY; -CONST_ARRAY(byte, rmt4_obx) - 255,255,144,3,96,11,128,0,128,32,128,64,0,192,128,128, - 128,160,0,192,64,192,0,1,5,11,21,0,1,255,255,1, - 1,0,255,255,0,1,1,1,0,255,255,255,255,0,1,1, - 0,0,0,0,0,0,242,51,150,226,56,140,0,106,232,106, - 239,128,8,174,70,230,149,65,246,176,110,48,246,187,132,82, - 34,244,200,160,122,85,52,20,245,216,189,164,141,119,96,78, - 56,39,21,6,247,232,219,207,195,184,172,162,154,144,136,127, - 120,112,106,100,94,0,191,182,170,161,152,143,137,128,242,230, - 218,206,191,182,170,161,152,143,137,128,122,113,107,101,95,92, - 86,80,77,71,68,62,60,56,53,50,47,45,42,40,37,35, - 33,31,29,28,26,24,23,22,20,19,18,17,16,15,14,13, - 12,11,10,9,8,7,255,241,228,216,202,192,181,171,162,153, - 142,135,127,121,115,112,102,97,90,85,82,75,72,67,63,60, - 57,55,51,48,45,42,40,37,36,33,31,30,28,27,25,23, - 22,21,19,18,17,16,15,14,13,12,11,10,9,8,7,6, - 5,4,3,2,1,0,243,230,217,204,193,181,173,162,153,144, - 136,128,121,114,108,102,96,91,85,81,76,72,68,64,60,57, - 53,50,47,45,42,40,37,35,33,31,29,28,26,24,23,22, - 20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5, - 4,3,2,1,0,0,13,13,12,11,11,10,10,9,8,8, - 7,7,7,6,6,5,5,5,4,4,4,4,3,3,3,3, - 3,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1, - 1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1, - 1,1,1,1,1,1,0,0,0,0,1,1,1,1,1,1, - 1,1,2,2,2,2,0,0,0,1,1,1,1,1,2,2, - 2,2,2,3,3,3,0,0,1,1,1,1,2,2,2,2, - 3,3,3,3,4,4,0,0,1,1,1,2,2,2,3,3, - 3,4,4,4,5,5,0,0,1,1,2,2,2,3,3,4, - 4,4,5,5,6,6,0,0,1,1,2,2,3,3,4,4, - 5,5,6,6,7,7,0,1,1,2,2,3,3,4,4,5, - 5,6,6,7,7,8,0,1,1,2,2,3,4,4,5,5, - 6,7,7,8,8,9,0,1,1,2,3,3,4,5,5,6, - 7,7,8,9,9,10,0,1,1,2,3,4,4,5,6,7, - 7,8,9,10,10,11,0,1,2,2,3,4,5,6,6,7, - 8,9,10,10,11,12,0,1,2,3,3,4,5,6,7,8, - 9,10,10,11,12,13,0,1,2,3,4,5,6,7,7,8, - 9,10,11,12,13,14,0,1,2,3,4,5,6,7,8,9, - 10,11,12,13,14,15,76,15,6,76,252,7,76,33,8,76, - 88,6,76,43,11,134,211,132,212,72,160,168,169,0,153,127, - 2,136,208,250,160,4,177,211,141,21,8,200,177,211,141,36, - 3,200,177,211,141,5,8,141,38,3,160,8,177,211,153,195, - 0,200,192,16,208,246,104,72,10,10,24,101,209,133,209,104, - 8,41,192,10,42,42,40,101,210,133,210,32,110,6,169,0, - 141,8,210,160,3,140,15,210,160,8,153,0,210,136,16,250, - 173,5,8,96,162,0,142,39,3,138,168,177,209,201,254,176, - 45,168,177,205,157,128,2,177,207,157,132,2,169,0,157,136, - 2,169,1,157,140,2,169,128,157,180,2,232,224,4,208,217, - 165,209,24,105,4,133,209,144,27,230,210,76,190,6,240,4, - 169,0,240,223,160,2,177,209,170,200,177,209,133,210,134,209, - 162,0,240,181,173,36,3,141,22,7,162,255,232,222,140,2, - 208,69,189,128,2,133,211,189,132,2,133,212,188,136,2,254, - 136,2,177,211,133,217,41,63,201,61,240,17,176,56,157,144, - 2,157,16,3,200,177,211,74,41,126,157,180,2,169,1,157, - 140,2,188,136,2,254,136,2,177,211,74,102,217,74,102,217, - 165,217,41,240,157,148,2,224,3,208,177,169,255,141,36,3, - 141,37,3,76,101,7,201,63,240,27,165,217,41,192,240,9, - 10,42,42,157,140,2,76,17,7,200,177,211,157,140,2,254, - 136,2,76,17,7,165,217,48,12,200,177,211,141,22,7,254, - 136,2,76,214,6,201,255,240,9,200,177,211,157,136,2,76, - 214,6,76,110,6,76,33,8,202,48,250,188,180,2,48,248, - 177,203,157,184,2,133,215,200,177,203,157,188,2,133,216,169, - 1,157,20,3,168,177,215,157,4,3,200,177,215,157,196,2, - 200,177,215,157,200,2,200,177,215,157,240,2,41,63,157,8, - 3,177,215,41,64,157,244,2,200,177,215,157,32,3,200,177, - 215,157,208,2,200,177,215,157,216,2,200,177,215,157,220,2, - 200,177,215,168,185,160,3,157,224,2,157,228,2,185,161,3, - 157,232,2,160,10,177,215,157,236,2,169,128,157,212,2,157, - 180,2,10,157,204,2,157,156,2,168,177,215,157,0,3,105, - 0,157,192,2,169,12,157,252,2,168,177,215,157,248,2,76, - 98,7,32,43,11,206,38,3,208,29,169,255,141,38,3,206, - 37,3,208,19,238,39,3,173,39,3,201,255,240,3,76,190, - 6,76,110,6,76,95,10,169,4,133,214,162,3,189,188,2, - 240,242,133,212,189,184,2,133,211,188,192,2,177,211,133,217, - 200,177,211,133,218,200,177,211,133,219,200,152,221,196,2,144, - 10,240,8,169,128,157,204,2,189,200,2,157,192,2,165,217, - 41,15,29,148,2,168,185,0,5,133,220,165,218,41,14,168, - 185,144,3,133,213,165,220,25,145,3,157,28,3,189,220,2, - 240,40,201,1,208,33,189,156,2,24,125,236,2,24,188,224, - 2,121,165,3,157,156,2,200,152,221,232,2,208,3,189,228, - 2,157,224,2,76,164,8,222,220,2,188,0,3,192,13,144, - 60,189,8,3,16,49,152,221,252,2,208,8,189,4,3,157, - 252,2,208,3,254,252,2,189,184,2,133,215,189,188,2,133, - 216,188,252,2,177,215,188,244,2,240,4,24,125,248,2,157, - 248,2,189,240,2,41,63,56,233,1,157,8,3,189,204,2, - 16,31,189,148,2,240,26,221,216,2,240,21,144,19,168,189, - 212,2,24,125,208,2,157,212,2,144,6,152,233,16,157,148, - 2,169,0,133,221,165,218,157,12,3,41,112,74,74,141,28, - 9,144,254,76,210,9,234,76,60,9,234,76,65,9,234,76, - 75,9,234,76,87,9,234,76,102,9,234,76,169,9,234,76, - 184,9,165,219,76,21,10,165,219,133,221,189,144,2,76,216, - 9,189,144,2,24,101,219,157,144,2,76,216,9,189,156,2, - 24,101,219,157,156,2,189,144,2,76,216,9,189,240,2,16, - 12,188,144,2,177,213,24,125,248,2,76,135,9,189,144,2, - 24,125,248,2,201,61,144,2,169,63,168,177,213,157,160,2, - 164,219,208,3,157,164,2,152,74,74,74,74,157,168,2,157, - 172,2,165,219,41,15,157,176,2,189,144,2,76,216,9,165, - 219,24,125,20,3,157,20,3,189,144,2,76,216,9,165,219, - 201,128,240,6,157,144,2,76,216,9,189,28,3,9,240,157, - 28,3,189,144,2,76,216,9,189,144,2,24,101,219,188,240, - 2,48,31,24,125,248,2,201,61,144,7,169,0,157,28,3, - 169,63,157,16,3,168,177,213,24,125,156,2,24,101,221,76, - 21,10,201,61,144,7,169,0,157,28,3,169,63,168,189,156, - 2,24,125,248,2,24,113,213,24,101,221,157,24,3,189,172, - 2,240,50,222,172,2,208,45,189,168,2,157,172,2,189,164, - 2,221,160,2,240,31,176,13,125,176,2,176,18,221,160,2, - 176,13,76,76,10,253,176,2,144,5,221,160,2,176,3,189, - 160,2,157,164,2,165,218,41,1,240,10,189,164,2,24,125, - 156,2,157,24,3,202,48,3,76,39,8,173,32,3,13,33, - 3,13,34,3,13,35,3,170,142,44,11,173,12,3,16,33, - 173,28,3,41,15,240,26,173,24,3,24,109,20,3,141,26, - 3,173,30,3,41,16,208,5,169,0,141,30,3,138,9,4, - 170,173,13,3,16,33,173,29,3,41,15,240,26,173,25,3, - 24,109,21,3,141,27,3,173,31,3,41,16,208,5,169,0, - 141,31,3,138,9,2,170,236,44,11,208,94,173,13,3,41, - 14,201,6,208,38,173,29,3,41,15,240,31,172,17,3,185, - 192,3,141,24,3,185,192,4,141,25,3,173,28,3,41,16, - 208,5,169,0,141,28,3,138,9,80,170,173,15,3,41,14, - 201,6,208,38,173,31,3,41,15,240,31,172,19,3,185,192, - 3,141,26,3,185,192,4,141,27,3,173,30,3,41,16,208, - 5,169,0,141,30,3,138,9,40,170,142,44,11,173,38,3, - 96,160,255,173,24,3,174,28,3,141,0,210,142,1,210,173, - 25,3,174,29,3,141,2,210,142,3,210,173,26,3,174,30, - 3,141,4,210,142,5,210,173,27,3,174,31,3,141,6,210, - 142,7,210,140,8,210,96 -END_CONST_ARRAY; -CONST_ARRAY(byte, rmt8_obx) - 255,255,144,3,108,12,128,0,128,32,128,64,0,192,128,128, - 128,160,0,192,64,192,0,1,5,11,21,0,1,255,255,1, - 1,0,255,255,0,1,1,1,0,255,255,255,255,0,1,1, - 0,0,0,0,0,0,242,51,150,226,56,140,0,106,232,106, - 239,128,8,174,70,230,149,65,246,176,110,48,246,187,132,82, - 34,244,200,160,122,85,52,20,245,216,189,164,141,119,96,78, - 56,39,21,6,247,232,219,207,195,184,172,162,154,144,136,127, - 120,112,106,100,94,0,191,182,170,161,152,143,137,128,242,230, - 218,206,191,182,170,161,152,143,137,128,122,113,107,101,95,92, - 86,80,77,71,68,62,60,56,53,50,47,45,42,40,37,35, - 33,31,29,28,26,24,23,22,20,19,18,17,16,15,14,13, - 12,11,10,9,8,7,255,241,228,216,202,192,181,171,162,153, - 142,135,127,121,115,112,102,97,90,85,82,75,72,67,63,60, - 57,55,51,48,45,42,40,37,36,33,31,30,28,27,25,23, - 22,21,19,18,17,16,15,14,13,12,11,10,9,8,7,6, - 5,4,3,2,1,0,243,230,217,204,193,181,173,162,153,144, - 136,128,121,114,108,102,96,91,85,81,76,72,68,64,60,57, - 53,50,47,45,42,40,37,35,33,31,29,28,26,24,23,22, - 20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5, - 4,3,2,1,0,0,13,13,12,11,11,10,10,9,8,8, - 7,7,7,6,6,5,5,5,4,4,4,4,3,3,3,3, - 3,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1, - 1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1, - 1,1,1,1,1,1,0,0,0,0,1,1,1,1,1,1, - 1,1,2,2,2,2,0,0,0,1,1,1,1,1,2,2, - 2,2,2,3,3,3,0,0,1,1,1,1,2,2,2,2, - 3,3,3,3,4,4,0,0,1,1,1,2,2,2,3,3, - 3,4,4,4,5,5,0,0,1,1,2,2,2,3,3,4, - 4,4,5,5,6,6,0,0,1,1,2,2,3,3,4,4, - 5,5,6,6,7,7,0,1,1,2,2,3,3,4,4,5, - 5,6,6,7,7,8,0,1,1,2,2,3,4,4,5,5, - 6,7,7,8,8,9,0,1,1,2,3,3,4,5,5,6, - 7,7,8,9,9,10,0,1,1,2,3,4,4,5,6,7, - 7,8,9,10,10,11,0,1,2,2,3,4,5,6,6,7, - 8,9,10,10,11,12,0,1,2,3,3,4,5,6,7,8, - 9,10,10,11,12,13,0,1,2,3,4,5,6,7,7,8, - 9,10,11,12,13,14,0,1,2,3,4,5,6,7,8,9, - 10,11,12,13,14,15,76,15,6,76,9,8,76,46,8,76, - 92,6,76,2,12,134,211,132,212,72,160,0,152,153,0,2, - 153,76,2,200,208,247,160,4,177,211,141,34,8,200,177,211, - 141,72,3,200,177,211,141,18,8,141,74,3,160,8,177,211, - 153,195,0,200,192,16,208,246,104,72,10,10,10,24,101,209, - 133,209,104,8,41,224,10,42,42,42,40,101,210,133,210,32, - 123,6,169,0,141,8,210,141,24,210,160,3,140,15,210,140, - 31,210,160,8,153,0,210,153,16,210,136,16,247,173,18,8, - 96,162,0,142,75,3,138,168,177,209,201,254,176,45,168,177, - 205,157,0,2,177,207,157,8,2,169,0,157,16,2,169,1, - 157,24,2,169,128,157,104,2,232,224,8,208,217,165,209,24, - 105,8,133,209,144,27,230,210,76,203,6,240,4,169,0,240, - 223,160,2,177,209,170,200,177,209,133,210,134,209,162,0,240, - 181,173,72,3,141,35,7,162,255,232,222,24,2,208,69,189, - 0,2,133,211,189,8,2,133,212,188,16,2,254,16,2,177, - 211,133,217,41,63,201,61,240,17,176,56,157,32,2,157,32, - 3,200,177,211,74,41,126,157,104,2,169,1,157,24,2,188, - 16,2,254,16,2,177,211,74,102,217,74,102,217,165,217,41, - 240,157,40,2,224,7,208,177,169,255,141,72,3,141,73,3, - 76,114,7,201,63,240,27,165,217,41,192,240,9,10,42,42, - 157,24,2,76,30,7,200,177,211,157,24,2,254,16,2,76, - 30,7,165,217,48,12,200,177,211,141,35,7,254,16,2,76, - 227,6,201,255,240,9,200,177,211,157,16,2,76,227,6,76, - 123,6,76,46,8,202,48,250,188,104,2,48,248,177,203,157, - 112,2,133,215,200,177,203,157,120,2,133,216,169,1,157,40, - 3,168,177,215,157,8,3,200,177,215,157,136,2,200,177,215, - 157,144,2,200,177,215,157,224,2,41,63,157,16,3,177,215, - 41,64,157,232,2,200,177,215,157,64,3,200,177,215,157,160, - 2,200,177,215,157,176,2,200,177,215,157,184,2,200,177,215, - 168,185,160,3,157,192,2,157,200,2,185,161,3,157,208,2, - 160,10,177,215,157,216,2,169,128,157,168,2,157,104,2,10, - 157,152,2,157,56,2,168,177,215,157,0,3,105,0,157,128, - 2,169,12,157,248,2,168,177,215,157,240,2,76,111,7,32, - 2,12,206,74,3,208,29,169,255,141,74,3,206,73,3,208, - 19,238,75,3,173,75,3,201,255,240,3,76,203,6,76,123, - 6,76,116,10,169,4,133,214,162,7,189,120,2,240,242,133, - 212,189,112,2,133,211,188,128,2,177,211,133,217,200,177,211, - 133,218,200,177,211,133,219,200,152,221,136,2,144,10,240,8, - 169,128,157,152,2,189,144,2,157,128,2,165,217,224,4,144, - 4,74,74,74,74,41,15,29,40,2,168,185,0,5,133,220, - 165,218,41,14,168,185,144,3,133,213,165,220,25,145,3,157, - 56,3,189,184,2,240,40,201,1,208,33,189,56,2,24,125, - 216,2,24,188,192,2,121,165,3,157,56,2,200,152,221,208, - 2,208,3,189,200,2,157,192,2,76,185,8,222,184,2,188, - 0,3,192,13,144,60,189,16,3,16,49,152,221,248,2,208, - 8,189,8,3,157,248,2,208,3,254,248,2,189,112,2,133, - 215,189,120,2,133,216,188,248,2,177,215,188,232,2,240,4, - 24,125,240,2,157,240,2,189,224,2,41,63,56,233,1,157, - 16,3,189,152,2,16,31,189,40,2,240,26,221,176,2,240, - 21,144,19,168,189,168,2,24,125,160,2,157,168,2,144,6, - 152,233,16,157,40,2,169,0,133,221,165,218,157,24,3,41, - 112,74,74,141,49,9,144,254,76,231,9,234,76,81,9,234, - 76,86,9,234,76,96,9,234,76,108,9,234,76,123,9,234, - 76,190,9,234,76,205,9,165,219,76,42,10,165,219,133,221, - 189,32,2,76,237,9,189,32,2,24,101,219,157,32,2,76, - 237,9,189,56,2,24,101,219,157,56,2,189,32,2,76,237, - 9,189,224,2,16,12,188,32,2,177,213,24,125,240,2,76, - 156,9,189,32,2,24,125,240,2,201,61,144,2,169,63,168, - 177,213,157,64,2,164,219,208,3,157,72,2,152,74,74,74, - 74,157,80,2,157,88,2,165,219,41,15,157,96,2,189,32, - 2,76,237,9,165,219,24,125,40,3,157,40,3,189,32,2, - 76,237,9,165,219,201,128,240,6,157,32,2,76,237,9,189, - 56,3,9,240,157,56,3,189,32,2,76,237,9,189,32,2, - 24,101,219,188,224,2,48,31,24,125,240,2,201,61,144,7, - 169,0,157,56,3,169,63,157,32,3,168,177,213,24,125,56, - 2,24,101,221,76,42,10,201,61,144,7,169,0,157,56,3, - 169,63,168,189,56,2,24,125,240,2,24,113,213,24,101,221, - 157,48,3,189,88,2,240,50,222,88,2,208,45,189,80,2, - 157,88,2,189,72,2,221,64,2,240,31,176,13,125,96,2, - 176,18,221,64,2,176,13,76,97,10,253,96,2,144,5,221, - 64,2,176,3,189,64,2,157,72,2,165,218,41,1,240,10, - 189,72,2,24,125,56,2,157,48,3,202,48,3,76,52,8, - 173,64,3,13,65,3,13,66,3,13,67,3,170,142,101,12, - 173,24,3,16,33,173,56,3,41,15,240,26,173,48,3,24, - 109,40,3,141,50,3,173,58,3,41,16,208,5,169,0,141, - 58,3,138,9,4,170,173,25,3,16,33,173,57,3,41,15, - 240,26,173,49,3,24,109,41,3,141,51,3,173,59,3,41, - 16,208,5,169,0,141,59,3,138,9,2,170,236,101,12,208, - 94,173,25,3,41,14,201,6,208,38,173,57,3,41,15,240, - 31,172,33,3,185,192,3,141,48,3,185,192,4,141,49,3, - 173,56,3,41,16,208,5,169,0,141,56,3,138,9,80,170, - 173,27,3,41,14,201,6,208,38,173,59,3,41,15,240,31, - 172,35,3,185,192,3,141,50,3,185,192,4,141,51,3,173, - 58,3,41,16,208,5,169,0,141,58,3,138,9,40,170,142, - 101,12,173,68,3,13,69,3,13,70,3,13,71,3,170,142, - 3,12,173,28,3,16,33,173,60,3,41,15,240,26,173,52, - 3,24,109,44,3,141,54,3,173,62,3,41,16,208,5,169, - 0,141,62,3,138,9,4,170,173,29,3,16,33,173,61,3, - 41,15,240,26,173,53,3,24,109,45,3,141,55,3,173,63, - 3,41,16,208,5,169,0,141,63,3,138,9,2,170,236,3, - 12,208,94,173,29,3,41,14,201,6,208,38,173,61,3,41, - 15,240,31,172,37,3,185,192,3,141,52,3,185,192,4,141, - 53,3,173,60,3,41,16,208,5,169,0,141,60,3,138,9, - 80,170,173,31,3,41,14,201,6,208,38,173,63,3,41,15, - 240,31,172,39,3,185,192,3,141,54,3,185,192,4,141,55, - 3,173,62,3,41,16,208,5,169,0,141,62,3,138,9,40, - 170,142,3,12,173,74,3,96,160,255,173,52,3,174,48,3, - 141,16,210,142,0,210,173,60,3,174,56,3,141,17,210,142, - 1,210,173,53,3,174,49,3,141,18,210,142,2,210,173,61, - 3,174,57,3,141,19,210,142,3,210,173,54,3,174,50,3, - 141,20,210,142,4,210,173,62,3,174,58,3,141,21,210,142, - 5,210,173,55,3,174,51,3,141,22,210,142,6,210,173,63, - 3,174,59,3,141,23,210,142,7,210,169,255,140,24,210,141, - 8,210,96 -END_CONST_ARRAY; -CONST_ARRAY(byte, tmc_obx) - 255,255,0,5,104,15,76,206,13,76,208,8,76,239,9,15, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1, - 1,1,0,0,0,0,1,1,1,1,1,1,1,1,2,2, - 2,2,0,0,0,1,1,1,1,1,2,2,2,2,2,3, - 3,3,0,0,1,1,1,1,2,2,2,2,3,3,3,3, - 4,4,0,0,1,1,1,2,2,2,3,3,3,4,4,4, - 5,5,0,0,1,1,2,2,2,3,3,4,4,4,5,5, - 6,6,0,0,1,1,2,2,3,3,4,4,5,5,6,6, - 7,7,0,1,1,2,2,3,3,4,4,5,5,6,6,7, - 7,8,0,1,1,2,2,3,4,4,5,5,6,7,7,8, - 8,9,0,1,1,2,3,3,4,5,5,6,7,7,8,9, - 9,10,0,1,1,2,3,4,4,5,6,7,7,8,9,10, - 10,11,0,1,2,2,3,4,5,6,6,7,8,9,10,10, - 11,12,0,1,2,3,3,4,5,6,7,8,9,10,10,11, - 12,13,0,1,2,3,4,5,6,7,7,8,9,10,11,12, - 13,14,0,1,2,3,4,5,6,7,8,9,10,11,12,13, - 14,15,0,241,228,215,203,192,181,170,161,152,143,135,127,120, - 114,107,101,95,90,85,80,75,71,67,63,60,56,53,50,47, - 44,42,39,37,35,33,31,29,28,26,24,23,22,20,19,18, - 17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2, - 1,0,0,242,230,218,206,191,182,170,161,152,143,137,128,122, - 113,107,101,95,92,86,80,77,71,68,62,60,56,53,50,47, - 45,42,40,37,35,33,31,29,28,26,24,23,22,20,19,18, - 17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2, - 1,0,0,255,241,228,216,202,192,181,171,162,153,142,135,127, - 121,115,112,102,97,90,85,82,75,72,67,63,60,57,55,51, - 48,45,42,40,37,36,33,31,30,28,27,25,23,22,21,19, - 18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3, - 2,1,0,243,230,217,204,193,181,173,162,153,144,136,128,121, - 114,108,102,96,91,85,81,76,72,68,64,60,57,53,50,47, - 45,42,40,37,35,33,31,29,28,26,24,23,22,20,19,18, - 17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2, - 1,0,0,242,51,150,226,56,140,0,106,232,106,239,128,8, - 174,70,230,149,65,246,176,110,48,246,187,132,82,34,244,200, - 160,122,85,52,20,245,216,189,164,141,119,96,78,56,39,21, - 6,247,232,219,207,195,184,172,162,154,144,136,127,120,112,106, - 100,94,0,13,13,12,11,11,10,10,9,8,8,7,7,7, - 6,6,5,5,5,4,4,4,4,3,3,3,3,3,2,2, - 2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1, - 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,5, - 6,7,0,1,2,3,4,2,0,0,4,2,0,0,0,16, - 0,8,0,16,0,8,173,183,8,240,94,173,182,8,201,64, - 144,90,206,181,8,240,3,76,239,9,162,7,169,0,157,196, - 7,157,204,7,202,16,247,141,182,8,170,160,15,177,254,16, - 32,136,177,254,16,3,76,95,14,134,252,10,10,38,252,10, - 38,252,10,38,252,105,0,133,254,165,252,105,0,133,255,144, - 218,157,212,7,136,177,254,157,220,7,232,136,16,207,24,165, - 254,105,16,133,254,144,2,230,255,76,239,9,206,181,8,16, - 248,238,182,8,173,180,8,141,181,8,162,7,222,204,7,48, - 3,76,233,9,188,212,7,185,255,255,133,252,185,255,255,133, - 253,188,196,7,177,252,208,6,32,109,13,76,230,9,201,64, - 176,18,125,220,7,157,228,7,32,109,13,188,42,5,32,188, - 14,76,230,9,208,34,200,254,196,7,177,252,16,7,133,251, - 32,109,13,165,251,41,127,208,7,169,64,141,182,8,208,76, - 141,180,8,141,181,8,208,68,201,128,176,43,41,63,125,220, - 7,157,228,7,200,254,196,7,177,252,41,127,208,7,169,64, - 141,182,8,208,6,141,180,8,141,181,8,32,109,13,188,42, - 5,32,188,14,76,230,9,201,192,176,12,41,63,157,42,5, - 200,254,196,7,76,94,9,41,63,157,204,7,254,196,7,202, - 48,3,76,70,9,162,7,189,188,7,240,33,32,46,11,189, - 50,5,61,192,8,240,22,160,71,177,252,24,125,34,5,157, - 36,5,168,185,60,6,56,125,100,8,157,246,7,202,16,215, - 14,9,5,14,9,5,14,9,5,14,9,5,232,134,252,134, - 253,162,7,138,168,185,252,7,208,12,188,184,8,185,4,8, - 208,4,138,168,169,0,133,250,152,157,26,5,185,244,7,157, - 18,5,185,50,5,133,251,5,253,133,253,165,251,61,192,8, - 240,6,185,246,7,157,20,5,165,251,61,200,8,240,18,185, - 34,5,41,63,168,200,132,252,185,123,7,157,18,5,76,137, - 10,164,252,240,10,185,59,7,157,18,5,169,0,133,252,165, - 250,13,9,5,168,185,60,5,188,26,5,25,236,7,157,10, - 5,224,4,208,9,165,253,141,59,5,169,0,133,253,202,16, - 130,78,9,5,78,9,5,78,9,5,78,9,5,165,253,162, - 3,142,31,210,142,15,210,174,22,5,172,18,5,142,16,210, - 140,0,210,174,14,5,172,10,5,142,17,210,140,1,210,174, - 23,5,172,19,5,142,18,210,140,2,210,174,15,5,172,11, - 5,142,19,210,140,3,210,174,24,5,172,20,5,142,20,210, - 140,4,210,174,16,5,172,12,5,142,21,210,140,5,210,174, - 25,5,172,21,5,142,22,210,140,6,210,174,17,5,172,13, - 5,142,23,210,140,7,210,141,58,5,174,59,5,142,24,210, - 141,8,210,96,189,28,8,133,252,189,36,8,133,253,188,44, - 8,192,63,240,123,254,44,8,254,44,8,254,44,8,177,252, - 41,240,157,236,7,177,252,41,15,56,253,12,8,16,2,169, - 0,157,252,7,200,177,252,41,15,56,253,20,8,16,2,169, - 0,157,4,8,177,252,41,240,240,116,16,11,160,73,177,252, - 188,44,8,136,136,16,2,169,0,157,50,5,177,252,41,112, - 240,99,74,74,141,154,11,169,0,157,100,8,200,177,252,144, - 254,234,234,234,234,76,56,13,234,76,53,13,234,76,60,13, - 234,76,74,13,234,76,84,13,234,76,95,13,234,76,81,13, - 189,52,8,240,18,222,68,8,208,13,157,68,8,189,252,7, - 41,15,240,3,222,252,7,189,60,8,240,18,222,76,8,208, - 13,157,76,8,189,4,8,41,15,240,3,222,4,8,160,72, - 177,252,157,50,5,189,148,8,24,105,63,168,177,252,125,228, - 7,157,34,5,168,185,60,6,157,244,7,222,164,8,16,51, - 189,156,8,157,164,8,189,172,8,240,24,24,125,148,8,157, - 148,8,240,7,221,140,8,208,26,169,254,24,105,1,157,172, - 8,208,16,254,148,8,189,140,8,221,148,8,176,5,169,0, - 157,148,8,189,116,8,240,4,222,116,8,96,189,108,8,133, - 250,189,92,8,133,251,32,105,12,222,132,8,16,16,165,250, - 157,108,8,165,251,157,92,8,189,124,8,157,132,8,96,189, - 84,8,141,112,12,16,254,76,167,12,234,76,144,12,234,76, - 174,12,234,76,180,12,234,76,190,12,234,76,210,12,234,76, - 226,12,234,76,244,12,165,250,230,250,41,3,74,144,15,208, - 71,165,251,157,100,8,24,125,244,7,157,244,7,96,169,0, - 157,100,8,96,32,29,13,76,157,12,32,29,13,24,125,34, - 5,76,84,13,165,250,157,100,8,24,125,244,7,157,244,7, - 165,250,24,101,251,133,250,96,189,34,5,56,229,250,157,34, - 5,168,185,60,6,76,199,12,189,244,7,56,229,251,157,244, - 7,56,169,0,229,251,157,100,8,96,189,132,8,208,174,165, - 251,16,16,189,4,8,240,165,189,252,7,201,15,240,158,254, - 252,7,96,189,252,7,240,149,189,4,8,201,15,240,142,254, - 4,8,96,164,250,165,251,48,2,200,200,136,152,133,250,197, - 251,208,6,165,251,73,255,133,251,152,96,125,244,7,157,244, - 7,96,188,228,7,121,60,6,157,244,7,152,157,34,5,96, - 45,10,210,157,244,7,96,125,228,7,157,34,5,168,185,60, - 6,157,244,7,96,157,34,5,168,189,244,7,121,60,6,157, - 244,7,96,200,254,196,7,177,252,74,74,74,74,157,12,8, - 177,252,41,15,157,20,8,96,32,95,14,160,15,169,0,133, - 254,169,0,133,255,138,240,46,177,254,16,1,202,24,165,254, - 105,16,133,254,144,239,230,255,176,235,32,95,14,169,0,133, - 252,138,10,10,38,252,10,38,252,10,38,252,105,0,133,254, - 165,252,105,0,133,255,169,64,141,182,8,169,1,141,181,8, - 141,183,8,96,201,16,144,176,201,32,144,206,201,48,176,3, - 76,174,14,201,64,176,9,138,41,15,240,3,141,180,8,96, - 201,80,144,113,201,96,176,6,169,0,141,183,8,96,201,112, - 144,248,169,1,141,181,8,169,64,141,182,8,132,252,134,253, - 160,30,177,252,141,180,8,165,252,24,105,32,141,194,14,144, - 1,232,142,195,14,24,105,64,141,202,14,144,1,232,142,203, - 14,24,105,64,141,82,9,144,1,232,142,83,9,24,105,128, - 141,87,9,144,1,232,142,88,9,24,105,128,133,254,141,16, - 9,141,136,13,141,183,13,144,1,232,134,255,142,22,9,142, - 140,13,142,189,13,160,7,169,0,141,183,8,153,0,210,153, - 16,210,153,10,5,153,252,7,153,4,8,153,50,5,153,188, - 7,136,16,232,141,8,210,141,24,210,141,58,5,141,59,5, - 96,157,252,7,157,4,8,157,50,5,189,228,7,157,34,5, - 96,152,73,240,74,74,74,74,157,12,8,152,41,15,73,15, - 157,20,8,96,41,7,133,252,138,166,252,41,63,240,226,157, - 228,7,169,0,157,188,7,185,255,255,157,28,8,133,252,185, - 255,255,157,36,8,133,253,5,252,240,182,160,74,177,252,157, - 52,8,157,68,8,200,177,252,157,60,8,157,76,8,200,177, - 252,41,112,74,74,157,84,8,177,252,41,15,157,92,8,177, - 252,16,11,189,92,8,73,255,24,105,1,157,92,8,200,177, - 252,157,116,8,200,177,252,41,63,157,124,8,157,132,8,200, - 177,252,41,128,240,2,169,1,157,172,8,177,252,41,112,74, - 74,74,74,157,140,8,208,3,157,172,8,177,252,41,15,157, - 156,8,157,164,8,136,177,252,41,192,24,125,228,7,157,228, - 7,157,34,5,168,185,60,6,157,244,7,169,0,157,44,8, - 157,100,8,157,108,8,157,148,8,169,1,157,188,7,96 -END_CONST_ARRAY; -CONST_ARRAY(byte, tm2_obx) - 255,255,0,2,107,16,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1, - 1,1,1,1,1,1,0,0,0,0,1,1,1,1,1,1, - 1,1,2,2,2,2,0,0,0,1,1,1,1,1,2,2, - 2,2,2,3,3,3,0,0,1,1,1,1,2,2,2,2, - 3,3,3,3,4,4,0,0,1,1,1,2,2,2,3,3, - 3,4,4,4,5,5,0,0,1,1,2,2,2,3,3,4, - 4,4,5,5,6,6,0,0,1,1,2,2,3,3,4,4, - 5,5,6,6,7,7,0,1,1,2,2,3,3,4,4,5, - 5,6,6,7,7,8,0,1,1,2,2,3,4,4,5,5, - 6,7,7,8,8,9,0,1,1,2,3,3,4,5,5,6, - 7,7,8,9,9,10,0,1,1,2,3,4,4,5,6,7, - 7,8,9,10,10,11,0,1,2,2,3,4,5,6,6,7, - 8,9,10,10,11,12,0,1,2,3,3,4,5,6,7,8, - 9,10,10,11,12,13,0,1,2,3,4,5,6,7,7,8, - 9,10,11,12,13,14,0,1,2,3,4,5,6,7,8,9, - 10,11,12,13,14,15,0,241,228,215,203,192,181,170,161,152, - 143,135,127,120,114,107,101,95,90,85,80,75,71,67,63,60, - 56,53,50,47,44,42,39,37,35,33,31,29,28,26,24,23, - 22,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6, - 5,4,3,2,1,0,0,242,233,218,206,191,182,170,161,152, - 143,137,128,122,113,107,101,95,92,86,80,77,71,68,62,60, - 56,53,50,47,45,42,40,37,35,33,31,29,28,26,24,23, - 22,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6, - 5,4,3,2,1,0,0,255,241,228,216,202,192,181,171,162, - 153,142,135,127,121,115,112,102,97,90,85,82,75,72,67,63, - 60,57,55,51,48,45,42,40,37,36,33,31,30,28,27,25, - 23,22,21,19,18,17,16,15,14,13,12,11,10,9,8,7, - 6,5,4,3,2,1,0,243,230,217,204,193,181,173,162,153, - 144,136,128,121,114,108,102,96,91,85,81,76,72,68,64,60, - 57,53,50,47,45,42,40,37,35,33,31,29,28,26,24,23, - 22,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6, - 5,4,3,2,1,0,226,56,140,0,106,232,106,239,128,8, - 174,70,230,149,65,246,176,110,48,246,187,132,82,34,244,200, - 160,122,85,52,20,245,216,189,164,141,119,96,78,56,39,21, - 6,247,232,219,207,195,184,172,162,154,144,136,127,120,112,106, - 100,94,87,82,50,10,0,242,51,150,226,56,140,0,106,232, - 106,239,128,8,174,70,230,149,65,246,176,110,48,246,187,132, - 82,34,244,200,160,122,85,52,20,245,216,189,164,141,119,96, - 78,56,39,21,6,247,232,219,207,195,184,172,162,154,144,136, - 127,120,112,106,100,94,11,11,10,10,9,8,8,7,7,7, - 6,6,5,5,5,4,4,4,4,3,3,3,3,3,2,2, - 2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1, - 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,13,13,12,11,11,10,10,9,8, - 8,7,7,7,6,6,5,5,5,4,4,4,4,3,3,3, - 3,3,2,2,2,2,2,2,2,1,1,1,1,1,1,1, - 1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,76,228,13,76,227,6,76,159,8,1, - 16,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,5, - 6,7,0,1,2,3,4,2,0,0,4,2,0,0,0,16, - 0,8,0,16,0,8,133,211,129,169,133,211,129,169,136,177, - 250,141,23,5,162,0,134,252,10,38,252,10,38,252,10,38, - 252,10,38,252,109,23,5,144,2,230,252,24,105,0,133,250, - 165,252,105,0,133,251,76,7,7,32,181,9,173,22,5,240, - 5,206,28,5,48,3,76,162,8,206,29,5,208,82,162,0, - 238,23,5,173,25,5,133,250,173,26,5,133,251,160,16,177, - 250,48,171,208,3,76,44,15,141,29,5,136,177,250,136,132, - 252,168,185,255,255,157,80,5,185,255,255,157,88,5,169,0, - 157,112,5,157,96,5,164,252,177,250,157,104,5,232,136,16, - 219,169,17,24,101,250,141,25,5,169,0,101,251,141,26,5, - 173,27,5,141,28,5,162,7,222,112,5,48,6,202,16,248, - 76,162,8,189,80,5,133,250,189,88,5,133,251,188,96,5, - 177,250,208,28,200,177,250,157,208,5,41,240,157,216,5,177, - 250,10,10,10,10,157,224,5,200,152,157,96,5,76,87,7, - 201,64,176,79,125,104,5,157,152,5,200,177,250,16,37,41, - 127,133,252,200,177,250,157,208,5,41,240,157,216,5,177,250, - 10,10,10,10,157,224,5,200,152,157,96,5,164,252,32,156, - 15,76,87,7,168,254,96,5,254,96,5,189,208,5,41,240, - 157,216,5,189,208,5,10,10,10,10,157,224,5,32,156,15, - 76,87,7,201,128,176,37,41,63,24,125,104,5,157,152,5, - 200,177,250,157,208,5,41,240,157,216,5,177,250,10,10,10, - 10,157,224,5,200,152,157,96,5,76,87,7,208,14,200,177, - 250,157,112,5,200,152,157,96,5,76,87,7,201,192,176,15, - 41,63,24,125,104,5,157,152,5,254,96,5,76,87,7,201, - 208,176,15,200,254,96,5,41,15,141,27,5,141,28,5,76, - 106,7,201,224,176,22,177,250,133,252,200,177,250,133,253,200, - 152,157,96,5,165,252,32,14,14,76,87,7,201,240,176,46, - 177,250,133,252,200,177,250,133,253,165,252,32,14,14,188,96, - 5,200,200,177,250,157,208,5,41,240,157,216,5,177,250,10, - 10,10,10,157,224,5,200,152,157,96,5,76,87,7,201,255, - 176,11,233,239,157,112,5,254,96,5,76,87,7,169,64,157, - 112,5,76,87,7,32,181,9,162,7,189,120,5,240,115,76, - 217,10,189,14,5,240,14,169,0,157,32,5,157,40,5,202, - 16,232,76,31,9,164,253,185,0,3,24,101,252,157,56,5, - 152,157,160,5,189,176,5,61,168,6,240,40,165,253,41,127, - 168,185,0,4,24,101,252,157,55,5,185,128,4,105,0,157, - 56,5,169,0,157,31,5,188,152,6,153,39,5,202,202,16, - 169,76,31,9,189,176,5,61,160,6,240,22,189,104,6,24, - 101,253,157,162,5,168,185,0,3,24,101,252,56,101,254,157, - 58,5,202,16,133,232,134,252,162,3,173,9,5,240,6,41, - 64,208,60,162,7,138,168,185,32,5,208,12,188,152,6,185, - 40,5,208,4,138,168,169,0,25,168,5,157,48,5,185,56, - 5,157,72,5,185,160,5,157,64,5,185,176,5,5,252,133, - 252,224,4,208,3,141,31,5,202,16,202,141,30,5,96,189, - 32,5,29,168,5,157,48,5,189,44,5,29,172,5,157,52, - 5,189,56,5,157,72,5,189,60,5,157,76,5,189,160,5, - 157,64,5,189,164,5,157,68,5,202,16,211,173,176,5,13, - 177,5,13,178,5,13,179,5,141,30,5,173,180,5,13,181, - 5,13,182,5,13,183,5,141,31,5,96,173,9,5,208,3, - 76,144,10,48,3,76,72,10,173,13,5,170,74,74,41,1, - 168,185,30,5,141,56,210,138,41,4,168,185,56,5,141,48, - 210,189,32,5,141,49,210,185,57,5,141,50,210,189,33,5, - 141,51,210,185,58,5,141,52,210,189,34,5,141,53,210,185, - 59,5,141,54,210,189,35,5,141,55,210,173,12,5,170,74, - 74,41,1,168,185,30,5,141,40,210,138,41,4,168,185,56, - 5,141,32,210,189,32,5,141,33,210,185,57,5,141,34,210, - 189,33,5,141,35,210,185,58,5,141,36,210,189,34,5,141, - 37,210,185,59,5,141,38,210,189,35,5,141,39,210,173,11, - 5,170,74,74,41,1,168,185,30,5,141,24,210,138,172,9, - 5,16,2,41,4,168,185,56,5,141,16,210,189,32,5,141, - 17,210,185,57,5,141,18,210,189,33,5,141,19,210,185,58, - 5,141,20,210,189,34,5,141,21,210,185,59,5,141,22,210, - 189,35,5,141,23,210,173,10,5,170,74,74,41,1,168,185, - 30,5,141,8,210,138,172,9,5,16,2,41,4,168,185,56, - 5,141,0,210,189,32,5,141,1,210,185,57,5,141,2,210, - 189,33,5,141,3,210,185,58,5,141,4,210,189,34,5,141, - 5,210,185,59,5,141,6,210,189,35,5,141,7,210,96,189, - 128,5,133,250,189,136,5,133,251,189,128,6,133,252,189,136, - 6,133,253,189,144,6,133,254,189,184,5,221,192,5,144,12, - 157,8,6,189,200,5,157,184,5,76,11,11,189,8,6,240, - 48,189,232,5,240,19,222,248,5,208,14,157,248,5,189,216, - 5,240,6,56,233,16,157,216,5,189,240,5,240,19,222,0, - 6,208,14,157,0,6,189,224,5,240,6,56,233,16,157,224, - 5,188,72,6,177,250,24,125,152,5,24,101,253,133,253,222, - 88,6,16,57,189,80,6,157,88,6,189,96,6,240,30,24, - 125,72,6,157,72,6,240,13,221,64,6,144,32,169,255,157, - 96,6,76,135,11,169,1,157,96,6,76,135,11,254,72,6, - 189,64,6,221,72,6,176,5,169,0,157,72,6,169,19,24, - 101,250,133,250,144,2,230,251,188,184,5,177,250,41,240,157, - 168,5,177,250,41,15,29,216,5,168,185,0,2,5,255,168, - 185,0,2,157,32,5,188,184,5,200,177,250,41,15,29,224, - 5,168,185,0,2,5,255,168,185,0,2,157,40,5,189,40, - 6,208,39,189,16,6,141,212,11,16,254,76,209,12,234,76, - 108,12,234,76,167,12,234,76,212,12,234,76,1,13,234,76, - 33,13,234,76,65,13,234,76,73,13,222,40,6,188,184,5, - 200,177,250,41,112,74,74,74,141,34,12,177,250,48,6,189, - 112,6,76,18,12,189,120,6,61,176,6,157,176,5,200,200, - 152,157,184,5,136,177,250,144,254,144,22,144,12,144,34,144, - 24,144,46,144,36,144,50,144,52,125,128,6,157,128,6,177, - 250,24,101,252,133,252,76,172,8,125,136,6,157,136,6,177, - 250,24,101,253,133,253,76,172,8,125,144,6,157,144,6,177, - 250,24,101,254,133,254,76,172,8,133,252,169,0,133,253,76, - 172,8,189,32,6,41,3,74,144,10,208,25,189,24,6,24, - 101,252,133,252,222,56,6,16,78,254,32,6,189,48,6,157, - 56,6,76,247,11,165,252,253,24,6,133,252,222,56,6,16, - 54,254,32,6,189,48,6,157,56,6,76,247,11,188,32,6, - 189,24,6,48,2,200,200,136,152,24,101,252,133,252,222,56, - 6,16,20,152,157,32,6,221,24,6,208,5,73,255,157,24, - 6,189,48,6,157,56,6,76,247,11,188,32,6,189,24,6, - 48,2,200,200,136,152,24,101,253,133,253,222,56,6,16,231, - 152,157,32,6,221,24,6,208,216,73,255,157,24,6,189,48, - 6,157,56,6,76,247,11,189,32,6,24,101,252,133,252,222, - 56,6,16,195,189,24,6,24,125,32,6,157,32,6,189,48, - 6,157,56,6,76,247,11,165,253,56,253,32,6,133,253,222, - 56,6,16,163,189,24,6,24,125,32,6,157,32,6,189,48, - 6,157,56,6,76,247,11,189,24,6,24,101,252,133,252,76, - 247,11,160,16,169,0,133,250,169,0,133,251,169,0,141,23, - 5,138,240,63,177,250,240,2,16,1,202,169,17,24,101,250, - 133,250,144,2,230,251,238,23,5,208,230,162,0,169,0,133, - 252,138,141,23,5,10,38,252,10,38,252,10,38,252,10,38, - 252,109,23,5,144,2,230,252,24,105,0,133,250,165,252,105, - 0,133,251,32,44,15,165,250,141,25,5,165,251,141,26,5, - 162,7,169,255,157,208,5,169,240,157,216,5,157,224,5,202, - 16,240,169,3,141,15,210,141,31,210,141,47,210,141,63,210, - 206,23,5,232,142,28,5,232,142,29,5,142,22,5,96,138, - 41,15,141,27,5,96,142,22,5,96,201,16,176,3,76,76, - 13,201,32,144,136,201,48,176,3,76,133,15,201,64,144,223, - 201,80,176,3,76,44,15,201,96,144,219,201,112,144,3,76, - 180,14,132,253,41,15,10,141,23,14,165,253,144,254,144,30, - 144,56,144,89,144,96,144,26,144,28,144,30,144,32,144,34, - 144,36,144,13,144,11,144,9,144,7,144,5,144,3,141,24, - 5,96,157,104,6,96,157,112,6,96,157,120,6,96,157,144, - 6,96,157,128,6,96,157,136,6,96,41,112,74,74,157,16, - 6,41,48,208,3,157,32,6,165,253,48,6,41,15,157,24, - 6,96,41,15,73,255,24,105,1,157,24,6,96,41,63,157, - 48,6,157,56,6,96,41,128,10,42,157,96,6,165,253,41, - 112,74,74,74,74,157,64,6,208,3,157,96,6,165,253,41, - 15,157,80,6,157,88,6,189,72,6,221,64,6,144,143,189, - 64,6,240,2,233,1,157,72,6,96,132,250,134,251,160,25, - 177,250,200,141,9,5,177,250,200,141,10,5,177,250,200,141, - 11,5,177,250,200,141,12,5,177,250,200,141,13,5,177,250, - 141,27,5,165,250,73,128,48,1,232,141,172,15,142,173,15, - 73,128,48,1,232,141,29,7,142,30,7,232,141,35,7,142, - 36,7,232,141,162,15,142,163,15,73,128,48,1,232,141,25, - 5,141,215,6,141,79,13,141,148,13,142,26,5,142,221,6, - 142,83,13,142,154,13,169,240,133,255,169,0,141,22,5,141, - 24,5,162,7,169,0,141,22,5,157,120,5,157,176,5,157, - 32,5,157,40,5,157,48,5,157,48,210,157,32,210,157,16, - 210,157,0,210,202,16,226,141,24,210,141,8,210,141,56,210, - 141,40,210,141,30,5,141,31,5,96,157,32,5,157,40,5, - 157,48,5,157,176,5,96,152,157,208,5,41,240,157,216,5, - 189,208,5,10,10,10,10,157,224,5,96,41,7,133,250,138, - 166,250,41,63,240,225,157,152,5,152,48,238,189,208,5,32, - 117,15,169,0,157,120,5,185,255,255,240,190,157,136,5,133, - 251,185,255,255,157,128,5,133,250,152,157,144,5,160,8,177, - 250,200,157,192,5,177,250,200,157,200,5,177,250,200,157,104, - 6,177,250,200,157,112,6,177,250,200,157,120,6,177,250,200, - 157,232,5,157,248,5,177,250,200,157,240,5,157,0,6,177, - 250,41,112,74,74,157,16,6,177,250,200,48,8,41,15,157, - 24,6,76,9,16,41,15,73,255,24,105,1,157,24,6,177, - 250,200,157,40,6,177,250,200,41,63,157,48,6,157,56,6, - 177,250,41,128,10,42,157,96,6,177,250,41,112,74,74,74, - 74,157,64,6,208,3,157,96,6,177,250,136,41,15,157,80, - 6,157,88,6,177,250,41,192,29,152,5,157,152,5,168,185, - 0,3,157,56,5,169,0,157,184,5,157,32,6,157,8,6, - 157,72,6,157,128,6,157,136,6,157,144,6,169,1,157,120, - 5,96 -END_CONST_ARRAY; diff --git a/apps/codecs/libasf/SOURCES b/apps/codecs/libasf/SOURCES deleted file mode 100644 index 1fee336990..0000000000 --- a/apps/codecs/libasf/SOURCES +++ /dev/null @@ -1 +0,0 @@ -asf.c diff --git a/apps/codecs/libasf/asf.c b/apps/codecs/libasf/asf.c deleted file mode 100644 index 4e3235a422..0000000000 --- a/apps/codecs/libasf/asf.c +++ /dev/null @@ -1,435 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2007 Dave Chapman - * - * ASF parsing code based on libasf by Juho Vähä-Herttua - * http://code.google.com/p/libasf/ libasf itself was based on the ASF - * parser in VLC - http://www.videolan.org/ - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ -#include -#include "codeclib.h" -#include "asf.h" - -/* Read an unaligned 32-bit little endian long from buffer. */ -static unsigned long get_long_le(void* buf) -{ - unsigned char* p = (unsigned char*) buf; - - return p[0] | (p[1] << 8) | (p[2] << 16) | (p[3] << 24); -} - -/* Read an unaligned 16-bit little endian short from buffer. */ -static unsigned short get_short_le(void* buf) -{ - unsigned char* p = (unsigned char*) buf; - - return p[0] | (p[1] << 8); -} - -#define GETLEN2b(bits) (((bits) == 0x03) ? 4 : bits) - -#define GETVALUE2b(bits, data) \ - (((bits) != 0x03) ? ((bits) != 0x02) ? ((bits) != 0x01) ? \ - 0 : *(data) : get_short_le(data) : get_long_le(data)) - -int asf_read_packet(uint8_t** audiobuf, int* audiobufsize, int* packetlength, - asf_waveformatex_t* wfx) -{ - uint8_t tmp8, packet_flags, packet_property; - int stream_id; - int ec_length, opaque_data, ec_length_type; - int datalen; - uint8_t data[18]; - uint8_t* datap; - uint32_t length; - uint32_t padding_length; - /* rockbox: comment 'set but unused' variables - uint32_t send_time; - uint16_t duration; - uint32_t media_object_number; - uint32_t media_object_offset; - */ - uint16_t payload_count; - int payload_length_type; - uint32_t payload_hdrlen; - int payload_datalen; - int multiple; - uint32_t replicated_length; - uint32_t bytesread = 0; - uint8_t* buf; - size_t bufsize; - int i; - /*DEBUGF("Reading new packet at %d bytes ", (int)ci->curpos);*/ - - if (ci->read_filebuf(&tmp8, 1) == 0) { - return ASF_ERROR_EOF; - } - bytesread++; - - /* TODO: We need a better way to detect endofstream */ - if (tmp8 != 0x82) { - DEBUGF("Read failed: packet did not sync\n"); - return -1; - } - - - if (tmp8 & 0x80) { - ec_length = tmp8 & 0x0f; - opaque_data = (tmp8 >> 4) & 0x01; - ec_length_type = (tmp8 >> 5) & 0x03; - - if (ec_length_type != 0x00 || opaque_data != 0 || ec_length != 0x02) { - DEBUGF("incorrect error correction flags\n"); - return ASF_ERROR_INVALID_VALUE; - } - - /* Skip ec_data */ - ci->advance_buffer(ec_length); - bytesread += ec_length; - } else { - ec_length = 0; - } - - if (ci->read_filebuf(&packet_flags, 1) == 0) { return ASF_ERROR_EOF; } - if (ci->read_filebuf(&packet_property, 1) == 0) { return ASF_ERROR_EOF; } - bytesread += 2; - - datalen = GETLEN2b((packet_flags >> 1) & 0x03) + - GETLEN2b((packet_flags >> 3) & 0x03) + - GETLEN2b((packet_flags >> 5) & 0x03) + 6; - -#if 0 - if (datalen > sizeof(data)) { - DEBUGF("Unexpectedly long datalen in data - %d\n",datalen); - return ASF_ERROR_OUTOFMEM; - } -#endif - - if (ci->read_filebuf(data, datalen) == 0) { - return ASF_ERROR_EOF; - } - - bytesread += datalen; - - datap = data; - length = GETVALUE2b((packet_flags >> 5) & 0x03, datap); - datap += GETLEN2b((packet_flags >> 5) & 0x03); - /* sequence value is not used */ - GETVALUE2b((packet_flags >> 1) & 0x03, datap); - datap += GETLEN2b((packet_flags >> 1) & 0x03); - padding_length = GETVALUE2b((packet_flags >> 3) & 0x03, datap); - datap += GETLEN2b((packet_flags >> 3) & 0x03); - /* send_time = get_long_le(datap); */ - datap += 4; - /* duration = get_short_le(datap); */ - datap += 2; - /*DEBUGF("and duration %d ms\n", duration);*/ - - /* this is really idiotic, packet length can (and often will) be - * undefined and we just have to use the header packet size as the size - * value */ - if (!((packet_flags >> 5) & 0x03)) { - length = wfx->packet_size; - } - - /* this is also really idiotic, if packet length is smaller than packet - * size, we need to manually add the additional bytes into padding length - */ - if (length < wfx->packet_size) { - padding_length += wfx->packet_size - length; - length = wfx->packet_size; - } - - if (length > wfx->packet_size) { - DEBUGF("packet with too big length value\n"); - return ASF_ERROR_INVALID_LENGTH; - } - - /* check if we have multiple payloads */ - if (packet_flags & 0x01) { - if (ci->read_filebuf(&tmp8, 1) == 0) { - return ASF_ERROR_EOF; - } - payload_count = tmp8 & 0x3f; - payload_length_type = (tmp8 >> 6) & 0x03; - bytesread++; - } else { - payload_count = 1; - payload_length_type = 0x02; /* not used */ - } - - if (length < bytesread) { - DEBUGF("header exceeded packet size, invalid file - length=%d, bytesread=%d\n",(int)length,(int)bytesread); - /* FIXME: should this be checked earlier? */ - return ASF_ERROR_INVALID_LENGTH; - } - - - /* We now parse the individual payloads, and move all payloads - belonging to our audio stream to a contiguous block, starting at - the location of the first payload. - */ - - *audiobuf = NULL; - *audiobufsize = 0; - *packetlength = length - bytesread; - - buf = ci->request_buffer(&bufsize, length); - datap = buf; - -#define ASF_MAX_REQUEST (1L<<15) /* 32KB */ - if (bufsize != length && length >= ASF_MAX_REQUEST) { - /* This should only happen with packets larger than 32KB (the - guard buffer size). All the streams I've seen have - relatively small packets less than about 8KB), but I don't - know what is expected. - */ - DEBUGF("Could not read packet (requested %d bytes, received %d), curpos=%d, aborting\n", - (int)length,(int)bufsize,(int)ci->curpos); - return -1; - } - - for (i=0; i> 2) & 0x03) + - GETLEN2b((packet_property >> 4) & 0x03); - - //DEBUGF("payload_hdrlen = %d\n",payload_hdrlen); -#if 0 - /* TODO */ - if (payload_hdrlen > size) { - return ASF_ERROR_INVALID_LENGTH; - } -#endif - if (payload_hdrlen > sizeof(data)) { - DEBUGF("Unexpectedly long datalen in data - %d\n",datalen); - return ASF_ERROR_OUTOFMEM; - } - - bytesread += payload_hdrlen; - /* media_object_number = GETVALUE2b((packet_property >> 4) & 0x03, datap); */ - datap += GETLEN2b((packet_property >> 4) & 0x03); - /* media_object_offset = GETVALUE2b((packet_property >> 2) & 0x03, datap); */ - datap += GETLEN2b((packet_property >> 2) & 0x03); - replicated_length = GETVALUE2b(packet_property & 0x03, datap); - datap += GETLEN2b(packet_property & 0x03); - - /* TODO: Validate replicated_length */ - /* TODO: Is the content of this important for us? */ - datap += replicated_length; - bytesread += replicated_length; - - multiple = packet_flags & 0x01; - - - if (multiple) { - int x; - - x = GETLEN2b(payload_length_type); - - if (x != 2) { - /* in multiple payloads datalen should be a word */ - return ASF_ERROR_INVALID_VALUE; - } - -#if 0 - if (skip + tmp > datalen) { - /* not enough data */ - return ASF_ERROR_INVALID_LENGTH; - } -#endif - payload_datalen = GETVALUE2b(payload_length_type, datap); - datap += x; - bytesread += x; - } else { - payload_datalen = length - bytesread - padding_length; - } - - if (replicated_length==1) - datap++; - - if (stream_id == wfx->audiostream) - { - if (*audiobuf == NULL) { - /* The first payload can stay where it is */ - *audiobuf = datap; - *audiobufsize = payload_datalen; - } else { - /* The second and subsequent payloads in this packet - that belong to the audio stream need to be moved to be - contiguous with the first payload. - */ - memmove(*audiobuf + *audiobufsize, datap, payload_datalen); - *audiobufsize += payload_datalen; - } - } - datap += payload_datalen; - bytesread += payload_datalen; - } - - if (*audiobuf != NULL) - return 1; - else - return 0; -} - - -int asf_get_timestamp(int *duration) -{ - uint8_t tmp8, packet_flags, packet_property; - int ec_length, opaque_data, ec_length_type; - int datalen; - uint8_t data[18]; - uint8_t* datap; - /* rockbox: comment 'set but unused' variables - uint32_t length; - uint32_t padding_length; - */ - uint32_t send_time; - static int packet_count = 0; - - uint32_t bytesread = 0; - packet_count++; - if (ci->read_filebuf(&tmp8, 1) == 0) { - DEBUGF("ASF ERROR (EOF?)\n"); - return ASF_ERROR_EOF; - } - bytesread++; - - /* TODO: We need a better way to detect endofstream */ - if (tmp8 != 0x82) { - DEBUGF("Get timestamp: Detected end of stream\n"); - return ASF_ERROR_EOF; - } - - - if (tmp8 & 0x80) { - ec_length = tmp8 & 0x0f; - opaque_data = (tmp8 >> 4) & 0x01; - ec_length_type = (tmp8 >> 5) & 0x03; - - if (ec_length_type != 0x00 || opaque_data != 0 || ec_length != 0x02) { - DEBUGF("incorrect error correction flags\n"); - return ASF_ERROR_INVALID_VALUE; - } - - /* Skip ec_data */ - ci->advance_buffer(ec_length); - bytesread += ec_length; - } else { - ec_length = 0; - } - - if (ci->read_filebuf(&packet_flags, 1) == 0) { - DEBUGF("Detected end of stream 2\n"); - return ASF_ERROR_EOF; - } - - if (ci->read_filebuf(&packet_property, 1) == 0) { - DEBUGF("Detected end of stream3\n"); - return ASF_ERROR_EOF; - } - bytesread += 2; - - datalen = GETLEN2b((packet_flags >> 1) & 0x03) + - GETLEN2b((packet_flags >> 3) & 0x03) + - GETLEN2b((packet_flags >> 5) & 0x03) + 6; - - if (ci->read_filebuf(data, datalen) == 0) { - DEBUGF("Detected end of stream4\n"); - return ASF_ERROR_EOF; - } - - bytesread += datalen; - - datap = data; - /* length = GETVALUE2b((packet_flags >> 5) & 0x03, datap); */ - datap += GETLEN2b((packet_flags >> 5) & 0x03); - - /* sequence value is not used */ - GETVALUE2b((packet_flags >> 1) & 0x03, datap); - datap += GETLEN2b((packet_flags >> 1) & 0x03); - /* padding_length = GETVALUE2b((packet_flags >> 3) & 0x03, datap); */ - datap += GETLEN2b((packet_flags >> 3) & 0x03); - send_time = get_long_le(datap); - datap += 4; - *duration = get_short_le(datap); - - /*the asf_get_timestamp function advances us 12-13 bytes past the packet start, - need to undo this here so that we stay synced with the packet*/ - ci->seek_buffer(ci->curpos-bytesread); - - return send_time; -} - -/*entry point for seeks*/ -int asf_seek(int ms, asf_waveformatex_t* wfx) -{ - int time, duration, delta, temp, count=0; - - /*estimate packet number from bitrate*/ - int initial_packet = ci->curpos/wfx->packet_size; - int packet_num = (((int64_t)ms)*(wfx->bitrate>>3))/wfx->packet_size/1000; - int last_packet = ci->id3->filesize / wfx->packet_size; - - if (packet_num > last_packet) { - packet_num = last_packet; - } - - /*calculate byte address of the start of that packet*/ - int packet_offset = packet_num*wfx->packet_size; - - /*seek to estimated packet*/ - ci->seek_buffer(ci->id3->first_frame_offset+packet_offset); - temp = ms; - while (1) - { - /*for very large files it can be difficult and unimportant to find the exact packet*/ - count++; - - /*check the time stamp of our packet*/ - time = asf_get_timestamp(&duration); - /*DEBUGF("seeked to %d ms with duration %d\n", time, duration);*/ - - if (time < 0) { - /*unknown error, try to recover*/ - DEBUGF("UKNOWN SEEK ERROR\n"); - ci->seek_buffer(ci->id3->first_frame_offset+initial_packet*wfx->packet_size); - /*seek failed so return time stamp of the initial packet*/ - return asf_get_timestamp(&duration); - } - - if ((time+duration>=ms && time<=ms) || count > 10) { - /*DEBUGF("Found our packet! Now at %d packet\n", packet_num);*/ - return time; - } else { - /*seek again*/ - delta = ms-time; - /*estimate new packet number from bitrate and our current position*/ - temp += delta; - packet_num = ((temp/1000)*(wfx->bitrate>>3) - (wfx->packet_size>>1))/wfx->packet_size; //round down! - packet_offset = packet_num*wfx->packet_size; - ci->seek_buffer(ci->id3->first_frame_offset+packet_offset); - } - } -} diff --git a/apps/codecs/libasf/asf.h b/apps/codecs/libasf/asf.h deleted file mode 100644 index a7d384cf3d..0000000000 --- a/apps/codecs/libasf/asf.h +++ /dev/null @@ -1,49 +0,0 @@ -#ifndef _ASF_H -#define _ASF_H - -#include - -/* ASF codec IDs */ -#define ASF_CODEC_ID_WMAV1 0x160 -#define ASF_CODEC_ID_WMAV2 0x161 -#define ASF_CODEC_ID_WMAPRO 0x162 -#define ASF_CODEC_ID_WMAVOICE 0x00A - -enum asf_error_e { - ASF_ERROR_INTERNAL = -1, /* incorrect input to API calls */ - ASF_ERROR_OUTOFMEM = -2, /* some malloc inside program failed */ - ASF_ERROR_EOF = -3, /* unexpected end of file */ - ASF_ERROR_IO = -4, /* error reading or writing to file */ - ASF_ERROR_INVALID_LENGTH = -5, /* length value conflict in input data */ - ASF_ERROR_INVALID_VALUE = -6, /* other value conflict in input data */ - ASF_ERROR_INVALID_OBJECT = -7, /* ASF object missing or in wrong place */ - ASF_ERROR_OBJECT_SIZE = -8, /* invalid ASF object size (too small) */ - ASF_ERROR_SEEKABLE = -9, /* file not seekable */ - ASF_ERROR_SEEK = -10, /* file is seekable but seeking failed */ - ASF_ERROR_ENCRYPTED = -11 /* file is encrypted */ -}; - -struct asf_waveformatex_s { - uint32_t packet_size; - int audiostream; - uint16_t codec_id; - uint16_t channels; - uint32_t rate; - uint32_t bitrate; - uint16_t blockalign; - uint16_t bitspersample; - uint16_t datalen; - uint16_t numpackets; - uint8_t data[46]; -}; -typedef struct asf_waveformatex_s asf_waveformatex_t; - -int asf_read_packet(uint8_t** audiobuf, int* audiobufsize, int* packetlength, - asf_waveformatex_t* wfx); - -int asf_get_timestamp(int *duration); - -int asf_seek(int ms, asf_waveformatex_t* wfx); - - -#endif /* _ASF_H */ diff --git a/apps/codecs/libasf/libasf.make b/apps/codecs/libasf/libasf.make deleted file mode 100644 index 143d83f549..0000000000 --- a/apps/codecs/libasf/libasf.make +++ /dev/null @@ -1,18 +0,0 @@ -# __________ __ ___. -# Open \______ \ ____ ____ | | _\_ |__ _______ ___ -# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / -# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < -# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ -# \/ \/ \/ \/ \/ -# $Id$ -# - -# libasf -ASFLIB := $(CODECDIR)/libasf.a -ASFLIB_SRC := $(call preprocess, $(APPSDIR)/codecs/libasf/SOURCES) -ASFLIB_OBJ := $(call c2obj, $(ASFLIB_SRC)) -OTHER_SRC += $(ASFLIB_SRC) - -$(ASFLIB): $(ASFLIB_OBJ) - $(SILENT)$(shell rm -f $@) - $(call PRINTS,AR $(@F))$(AR) rcs $@ $^ >/dev/null diff --git a/apps/codecs/libatrac/README.rockbox b/apps/codecs/libatrac/README.rockbox deleted file mode 100644 index 30703a3e49..0000000000 --- a/apps/codecs/libatrac/README.rockbox +++ /dev/null @@ -1,30 +0,0 @@ -Library: libatrac -Imported by : Mohamed Tarek -Import date : 10-August-2009 - -LICENSING INFORMATION - -ffmpeg is licensed under the Lesser GNU General Public License. - -IMPORT DETAILS - -The decoder is based on ffmpeg-svn r18110 : Mar 21 2009. -Some changes were done on in order to use static VLC tables -according to this commit : -http://git.ffmpeg.org/?p=ffmpeg;a=commit;h=4c20cf13a166577d93f5b2b0abb4609c60104d33 - -The decoder had been modified to use fixed-point arithmetic. - -TESTING - -The test program should compile in any Unix-like environment using the -command "make -f Makefile.test". - -For ARM targets add -DCPU_ARM to CFLAGS in Makefile.test to make use of -the asm ARM optimisations in rockbox's mdct library. - -For Big-endian targets, change -D"ROCKBOX_LITTLE_ENDIAN=1" -to -D"ROCKBOX_BIG_ENDIAN=1" in Makefile.test. - -Running "./atractest file.rm" will decode the audio data to a WAV file -called "output.wav" in the current directory. diff --git a/apps/codecs/libatrac/SOURCES b/apps/codecs/libatrac/SOURCES deleted file mode 100644 index 85f011cb87..0000000000 --- a/apps/codecs/libatrac/SOURCES +++ /dev/null @@ -1,8 +0,0 @@ -atrac3.c -#if defined(CPU_ARM) -atrac3_arm.S -#if (ARM_ARCH >= 5) -atrac3_armv5e.S -#endif -#endif - diff --git a/apps/codecs/libatrac/atrac3.c b/apps/codecs/libatrac/atrac3.c deleted file mode 100644 index bb52dd4cf0..0000000000 --- a/apps/codecs/libatrac/atrac3.c +++ /dev/null @@ -1,1293 +0,0 @@ -/* - * Atrac 3 compatible decoder - * Copyright (c) 2006-2008 Maxim Poliakovski - * Copyright (c) 2006-2008 Benjamin Larsson - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/** - * @file libavcodec/atrac3.c - * Atrac 3 compatible decoder. - * This decoder handles Sony's ATRAC3 data. - * - * Container formats used to store atrac 3 data: - * RealMedia (.rm), RIFF WAV (.wav, .at3), Sony OpenMG (.oma, .aa3). - * - * To use this decoder, a calling application must supply the extradata - * bytes provided in the containers above. - */ - -#include -#include -#include - -#include "atrac3.h" -#include "atrac3data.h" -#include "atrac3data_fixed.h" -#include "fixp_math.h" - -#define JOINT_STEREO 0x12 -#define STEREO 0x2 - -#ifdef ROCKBOX -#undef DEBUGF -#define DEBUGF(...) -#endif /* ROCKBOX */ - -/* FFMAX/MIN/SWAP and av_clip were taken from libavutil/common.h */ -#define FFMAX(a,b) ((a) > (b) ? (a) : (b)) -#define FFMIN(a,b) ((a) > (b) ? (b) : (a)) -#define FFSWAP(type,a,b) do{type SWAP_tmp= b; b= a; a= SWAP_tmp;}while(0) - -#if defined(CPU_ARM) && (ARM_ARCH >= 5) - #define QMFWIN_TYPE int16_t /* ARMv5e+ uses 32x16 multiplication */ -#else - #define QMFWIN_TYPE int32_t -#endif - -static VLC spectral_coeff_tab[7] IBSS_ATTR_LARGE_IRAM; -static QMFWIN_TYPE qmf_window[48] IBSS_ATTR MEM_ALIGN_ATTR; -static int32_t atrac3_spectrum [2][1024] IBSS_ATTR MEM_ALIGN_ATTR; -static int32_t atrac3_IMDCT_buf[2][ 512] IBSS_ATTR MEM_ALIGN_ATTR; -static int32_t atrac3_prevFrame[2][1024] IBSS_ATTR MEM_ALIGN_ATTR; -static channel_unit channel_units[2] IBSS_ATTR_LARGE_IRAM; -static VLC_TYPE atrac3_vlc_table[4096][2] IBSS_ATTR_LARGE_IRAM; -static int vlcs_initialized = 0; - - - -/** - * Matrixing within quadrature mirror synthesis filter. - * - * @param p3 output buffer - * @param inlo lower part of spectrum - * @param inhi higher part of spectrum - * @param nIn size of spectrum buffer - */ - -#if defined(CPU_ARM) - extern void - atrac3_iqmf_matrixing(int32_t *p3, - int32_t *inlo, - int32_t *inhi, - unsigned int nIn); -#else - static inline void - atrac3_iqmf_matrixing(int32_t *p3, - int32_t *inlo, - int32_t *inhi, - unsigned int nIn) - { - uint32_t i; - for(i=0; i= 5) - extern void - atrac3_iqmf_dewindowing_armv5e(int32_t *out, - int32_t *in, - int16_t *win, - unsigned int nIn); - static inline void - atrac3_iqmf_dewindowing(int32_t *out, - int32_t *in, - int16_t *win, - unsigned int nIn) - { - atrac3_iqmf_dewindowing_armv5e(out, in, win, nIn); - - } - - -#elif defined(CPU_ARM) - extern void - atrac3_iqmf_dewindowing(int32_t *out, - int32_t *in, - int32_t *win, - unsigned int nIn); - -#elif defined (CPU_COLDFIRE) - #define MULTIPLY_ADD_BLOCK \ - "movem.l (%[win]), %%d0-%%d7 \n\t" \ - "lea.l (8*4, %[win]), %[win] \n\t" \ - "mac.l %%d0, %%a5, (%[in])+, %%a5, %%acc0\n\t" \ - "mac.l %%d1, %%a5, (%[in])+, %%a5, %%acc1\n\t" \ - "mac.l %%d2, %%a5, (%[in])+, %%a5, %%acc0\n\t" \ - "mac.l %%d3, %%a5, (%[in])+, %%a5, %%acc1\n\t" \ - "mac.l %%d4, %%a5, (%[in])+, %%a5, %%acc0\n\t" \ - "mac.l %%d5, %%a5, (%[in])+, %%a5, %%acc1\n\t" \ - "mac.l %%d6, %%a5, (%[in])+, %%a5, %%acc0\n\t" \ - "mac.l %%d7, %%a5, (%[in])+, %%a5, %%acc1\n\t" \ - - - static inline void - atrac3_iqmf_dewindowing(int32_t *out, - int32_t *in, - int32_t *win, - unsigned int nIn) - { - int32_t j; - int32_t *_in, *_win; - for (j = nIn; j != 0; j--, in+=2, out+=2) { - _in = in; - _win = win; - - asm volatile ( - "move.l (%[in])+, %%a5 \n\t" /* preload frist in value */ - MULTIPLY_ADD_BLOCK /* 0.. 7 */ - MULTIPLY_ADD_BLOCK /* 8..15 */ - MULTIPLY_ADD_BLOCK /* 16..23 */ - MULTIPLY_ADD_BLOCK /* 24..31 */ - MULTIPLY_ADD_BLOCK /* 32..39 */ - /* 40..47 */ - "movem.l (%[win]), %%d0-%%d7 \n\t" - "mac.l %%d0, %%a5, (%[in])+, %%a5, %%acc0 \n\t" - "mac.l %%d1, %%a5, (%[in])+, %%a5, %%acc1 \n\t" - "mac.l %%d2, %%a5, (%[in])+, %%a5, %%acc0 \n\t" - "mac.l %%d3, %%a5, (%[in])+, %%a5, %%acc1 \n\t" - "mac.l %%d4, %%a5, (%[in])+, %%a5, %%acc0 \n\t" - "mac.l %%d5, %%a5, (%[in])+, %%a5, %%acc1 \n\t" - "mac.l %%d6, %%a5, (%[in])+, %%a5, %%acc0 \n\t" - "mac.l %%d7, %%a5, %%acc1 \n\t" - "movclr.l %%acc0, %%d1 \n\t" /* s1 */ - "movclr.l %%acc1, %%d0 \n\t" /* s2 */ - "movem.l %%d0-%%d1, (%[out]) \n\t" - : [in] "+a" (_in), [win] "+a" (_win) - : [out] "a" (out) - : "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", "a5", "memory"); - } - } -#else - #define MULTIPLY_ADD_BLOCK(y1, y2, x, c, k) \ - y1 += fixmul31(c[k], x[k]); k++; \ - y2 += fixmul31(c[k], x[k]); k++; \ - y1 += fixmul31(c[k], x[k]); k++; \ - y2 += fixmul31(c[k], x[k]); k++; \ - y1 += fixmul31(c[k], x[k]); k++; \ - y2 += fixmul31(c[k], x[k]); k++; \ - y1 += fixmul31(c[k], x[k]); k++; \ - y2 += fixmul31(c[k], x[k]); k++; - - static inline void - atrac3_iqmf_dewindowing(int32_t *out, - int32_t *in, - int32_t *win, - unsigned int nIn) - { - int32_t i, j, s1, s2; - - for (j = nIn; j != 0; j--, in+=2, out+=2) { - s1 = s2 = i = 0; - - MULTIPLY_ADD_BLOCK(s1, s2, in, win, i); /* 0.. 7 */ - MULTIPLY_ADD_BLOCK(s1, s2, in, win, i); /* 8..15 */ - MULTIPLY_ADD_BLOCK(s1, s2, in, win, i); /* 16..23 */ - MULTIPLY_ADD_BLOCK(s1, s2, in, win, i); /* 24..31 */ - MULTIPLY_ADD_BLOCK(s1, s2, in, win, i); /* 32..39 */ - MULTIPLY_ADD_BLOCK(s1, s2, in, win, i); /* 40..47 */ - - out[0] = s2; - out[1] = s1; - - } - - } -#endif - - -/** - * IMDCT windowing. - * - * @param buffer sample buffer - * @param win window coefficients - */ - -static inline void -atrac3_imdct_windowing(int32_t *buffer, - const int32_t *win) -{ - int32_t i; - /* win[0..127] = win[511..384], win[128..383] = 1 */ - for(i = 0; i<128; i++) { - buffer[ i] = fixmul31(win[i], buffer[ i]); - buffer[511-i] = fixmul31(win[i], buffer[511-i]); - } -} - - -/** - * Quadrature mirror synthesis filter. - * - * @param inlo lower part of spectrum - * @param inhi higher part of spectrum - * @param nIn size of spectrum buffer - * @param pOut out buffer - * @param delayBuf delayBuf buffer - * @param temp temp buffer - */ - -static void iqmf (int32_t *inlo, int32_t *inhi, unsigned int nIn, int32_t *pOut, int32_t *delayBuf, int32_t *temp) -{ - - /* Restore the delay buffer */ - memcpy(temp, delayBuf, 46*sizeof(int32_t)); - - /* loop1: matrixing */ - atrac3_iqmf_matrixing(temp + 46, inlo, inhi, nIn); - - /* loop2: dewindowing */ - atrac3_iqmf_dewindowing(pOut, temp, qmf_window, nIn); - - /* Save the delay buffer */ - memcpy(delayBuf, temp + (nIn << 1), 46*sizeof(int32_t)); -} - - -/** - * Regular 512 points IMDCT without overlapping, with the exception of the swapping of odd bands - * caused by the reverse spectra of the QMF. - * - * @param pInput input - * @param pOutput output - * @param odd_band 1 if the band is an odd band - */ - -static void IMLT(int32_t *pInput, int32_t *pOutput) -{ - /* Apply the imdct. */ - ff_imdct_calc(9, pOutput, pInput); - - /* Windowing. */ - atrac3_imdct_windowing(pOutput, window_lookup); - -} - - -/** - * Atrac 3 indata descrambling, only used for data coming from the rm container - * - * @param in pointer to 8 bit array of indata - * @param bits amount of bits - * @param out pointer to 8 bit array of outdata - */ - -static int decode_bytes(const uint8_t* inbuffer, uint8_t* out, int bytes){ - int i, off; - uint32_t c; - const uint32_t* buf; - uint32_t* obuf = (uint32_t*) out; - -#if ((defined(TEST) || defined(SIMULATOR)) && !defined(CPU_ARM)) - off = 0; /* no check for memory alignment of inbuffer */ -#else - off = (intptr_t)inbuffer & 3; -#endif /* TEST */ - buf = (const uint32_t*) (inbuffer - off); - - c = be2me_32((0x537F6103 >> (off*8)) | (0x537F6103 << (32-(off*8)))); - bytes += 3 + off; - for (i = 0; i < bytes/4; i++) - obuf[i] = c ^ buf[i]; - - return off; -} - - -static void init_atrac3_transforms(void) -{ - int32_t s; - int i; - - /* Generate the mdct window, for details see - * http://wiki.multimedia.cx/index.php?title=RealAudio_atrc#Windows */ - - /* mdct window had been generated and saved as a lookup table in atrac3data_fixed.h */ - - /* Generate the QMF window. */ - for (i=0 ; i<24; i++) { - s = qmf_48tap_half_fix[i] << 1; - #if defined(CPU_ARM) && (ARM_ARCH >= 5) - qmf_window[i] = qmf_window[47-i] = (int16_t)((s+(1<<15))>>16); - #else - qmf_window[i] = qmf_window[47-i] = s; - #endif - } - -} - - -/** - * Mantissa decoding - * - * @param gb the GetBit context - * @param selector what table is the output values coded with - * @param codingFlag constant length coding or variable length coding - * @param mantissas mantissa output table - * @param numCodes amount of values to get - */ - -static void readQuantSpectralCoeffs (GetBitContext *gb, int selector, int codingFlag, int* mantissas, int numCodes) -{ - int numBits, cnt, code, huffSymb; - - if (selector == 1) - numCodes /= 2; - - if (codingFlag != 0) { - /* constant length coding (CLC) */ - numBits = CLCLengthTab[selector]; - - if (selector > 1) { - for (cnt = 0; cnt < numCodes; cnt++) { - if (numBits) - code = get_sbits(gb, numBits); - else - code = 0; - mantissas[cnt] = code; - } - } else { - for (cnt = 0; cnt < numCodes; cnt++) { - if (numBits) - code = get_bits(gb, numBits); /* numBits is always 4 in this case */ - else - code = 0; - mantissas[cnt*2] = seTab_0[code >> 2]; - mantissas[cnt*2+1] = seTab_0[code & 3]; - } - } - } else { - /* variable length coding (VLC) */ - if (selector != 1) { - for (cnt = 0; cnt < numCodes; cnt++) { - huffSymb = get_vlc2(gb, spectral_coeff_tab[selector-1].table, spectral_coeff_tab[selector-1].bits, 3); - huffSymb += 1; - code = huffSymb >> 1; - if (huffSymb & 1) - code = -code; - mantissas[cnt] = code; - } - } else { - for (cnt = 0; cnt < numCodes; cnt++) { - huffSymb = get_vlc2(gb, spectral_coeff_tab[selector-1].table, spectral_coeff_tab[selector-1].bits, 3); - mantissas[cnt*2] = decTable1[huffSymb*2]; - mantissas[cnt*2+1] = decTable1[huffSymb*2+1]; - } - } - } -} - - -/** - * Requantize the spectrum. - * - * @param *mantissas pointer to mantissas for each spectral line - * @param pOut requantized band spectrum - * @param first first spectral line in subband - * @param last last spectral line in subband - * @param SF scalefactor for all spectral lines of this band - */ - -static void inverseQuantizeSpectrum(int *mantissas, int32_t *pOut, - int32_t first, int32_t last, int32_t SF) -{ - int *pIn = mantissas; - - /* Inverse quantize the coefficients. */ - if((first/256) &1) { - /* Odd band - Reverse coefficients */ - do { - pOut[last--] = fixmul16(*pIn++, SF); - pOut[last--] = fixmul16(*pIn++, SF); - pOut[last--] = fixmul16(*pIn++, SF); - pOut[last--] = fixmul16(*pIn++, SF); - pOut[last--] = fixmul16(*pIn++, SF); - pOut[last--] = fixmul16(*pIn++, SF); - pOut[last--] = fixmul16(*pIn++, SF); - pOut[last--] = fixmul16(*pIn++, SF); - } while (last>first); - } else { - /* Even band - Do not reverse coefficients */ - do { - pOut[first++] = fixmul16(*pIn++, SF); - pOut[first++] = fixmul16(*pIn++, SF); - pOut[first++] = fixmul16(*pIn++, SF); - pOut[first++] = fixmul16(*pIn++, SF); - pOut[first++] = fixmul16(*pIn++, SF); - pOut[first++] = fixmul16(*pIn++, SF); - pOut[first++] = fixmul16(*pIn++, SF); - pOut[first++] = fixmul16(*pIn++, SF); - } while (first> 2] == 0) - continue; - - coded_components = get_bits(gb,3); - - for (k=0; kgBlock; - - for (i=0 ; i<=numBands; i++) - { - numData = get_bits(gb,3); - pGain[i].num_gain_data = numData; - pLevel = pGain[i].levcode; - pLoc = pGain[i].loccode; - - for (cf = 0; cf < numData; cf++){ - pLevel[cf]= get_bits(gb,4); - pLoc [cf]= get_bits(gb,5); - if(cf && pLoc[cf] <= pLoc[cf-1]) - return -1; - } - } - - /* Clear the unused blocks. */ - for (; i<4 ; i++) - pGain[i].num_gain_data = 0; - - return 0; -} - - -/** - * Apply fix (constant) gain and overlap for sample[start...255]. - * - * @param pIn input buffer - * @param pPrev previous buffer to perform overlap against - * @param pOut output buffer - * @param start index to start with (always a multiple of 8) - * @param gain gain to apply - */ - -static void applyFixGain (int32_t *pIn, int32_t *pPrev, int32_t *pOut, - int32_t start, int32_t gain) -{ - int32_t i = start; - - /* start is always a multiple of 8 and therefore allows us to unroll the - * loop to 8 calculation per loop - */ - if (ONE_16 == gain) { - /* gain1 = 1.0 -> no multiplication needed, just adding */ - /* Remark: This path is called >90%. */ - while (i<256) { - pOut[i] = pIn[i] + pPrev[i]; i++; - pOut[i] = pIn[i] + pPrev[i]; i++; - pOut[i] = pIn[i] + pPrev[i]; i++; - pOut[i] = pIn[i] + pPrev[i]; i++; - pOut[i] = pIn[i] + pPrev[i]; i++; - pOut[i] = pIn[i] + pPrev[i]; i++; - pOut[i] = pIn[i] + pPrev[i]; i++; - pOut[i] = pIn[i] + pPrev[i]; i++; - }; - } else { - /* gain1 != 1.0 -> we need to do a multiplication */ - /* Remark: This path is called seldom. */ - while (i<256) { - pOut[i] = fixmul16(pIn[i], gain) + pPrev[i]; i++; - pOut[i] = fixmul16(pIn[i], gain) + pPrev[i]; i++; - pOut[i] = fixmul16(pIn[i], gain) + pPrev[i]; i++; - pOut[i] = fixmul16(pIn[i], gain) + pPrev[i]; i++; - pOut[i] = fixmul16(pIn[i], gain) + pPrev[i]; i++; - pOut[i] = fixmul16(pIn[i], gain) + pPrev[i]; i++; - pOut[i] = fixmul16(pIn[i], gain) + pPrev[i]; i++; - pOut[i] = fixmul16(pIn[i], gain) + pPrev[i]; i++; - }; - } -} - - -/** - * Apply variable gain and overlap. Returns sample index after applying gain, - * resulting sample index is always a multiple of 8. - * - * @param pIn input buffer - * @param pPrev previous buffer to perform overlap against - * @param pOut output buffer - * @param start index to start with (always a multiple of 8) - * @param end end index for first loop (always a multiple of 8) - * @param gain1 current bands gain to apply - * @param gain2 next bands gain to apply - * @param gain_inc stepwise adaption from gain1 to gain2 - */ - -static int applyVariableGain (int32_t *pIn, int32_t *pPrev, int32_t *pOut, - int32_t start, int32_t end, - int32_t gain1, int32_t gain2, int32_t gain_inc) -{ - int32_t i = start; - - /* Apply fix gains until end index is reached */ - do { - pOut[i] = fixmul16((fixmul16(pIn[i], gain1) + pPrev[i]), gain2); i++; - pOut[i] = fixmul16((fixmul16(pIn[i], gain1) + pPrev[i]), gain2); i++; - pOut[i] = fixmul16((fixmul16(pIn[i], gain1) + pPrev[i]), gain2); i++; - pOut[i] = fixmul16((fixmul16(pIn[i], gain1) + pPrev[i]), gain2); i++; - pOut[i] = fixmul16((fixmul16(pIn[i], gain1) + pPrev[i]), gain2); i++; - pOut[i] = fixmul16((fixmul16(pIn[i], gain1) + pPrev[i]), gain2); i++; - pOut[i] = fixmul16((fixmul16(pIn[i], gain1) + pPrev[i]), gain2); i++; - pOut[i] = fixmul16((fixmul16(pIn[i], gain1) + pPrev[i]), gain2); i++; - } while (i < end); - - /* Interpolation is done over next eight samples */ - pOut[i] = fixmul16((fixmul16(pIn[i], gain1) + pPrev[i]), gain2); i++; - gain2 = fixmul16(gain2, gain_inc); - pOut[i] = fixmul16((fixmul16(pIn[i], gain1) + pPrev[i]), gain2); i++; - gain2 = fixmul16(gain2, gain_inc); - pOut[i] = fixmul16((fixmul16(pIn[i], gain1) + pPrev[i]), gain2); i++; - gain2 = fixmul16(gain2, gain_inc); - pOut[i] = fixmul16((fixmul16(pIn[i], gain1) + pPrev[i]), gain2); i++; - gain2 = fixmul16(gain2, gain_inc); - pOut[i] = fixmul16((fixmul16(pIn[i], gain1) + pPrev[i]), gain2); i++; - gain2 = fixmul16(gain2, gain_inc); - pOut[i] = fixmul16((fixmul16(pIn[i], gain1) + pPrev[i]), gain2); i++; - gain2 = fixmul16(gain2, gain_inc); - pOut[i] = fixmul16((fixmul16(pIn[i], gain1) + pPrev[i]), gain2); i++; - gain2 = fixmul16(gain2, gain_inc); - pOut[i] = fixmul16((fixmul16(pIn[i], gain1) + pPrev[i]), gain2); i++; - gain2 = fixmul16(gain2, gain_inc); - - return i; -} - - -/** - * Apply gain parameters and perform the MDCT overlapping part - * - * @param pIn input buffer - * @param pPrev previous buffer to perform overlap against - * @param pOut output buffer - * @param pGain1 current band gain info - * @param pGain2 next band gain info - */ - -static void gainCompensateAndOverlap (int32_t *pIn, int32_t *pPrev, int32_t *pOut, - gain_info *pGain1, gain_info *pGain2) -{ - /* gain compensation function */ - int32_t gain1, gain2, gain_inc; - int cnt, numdata, nsample, startLoc; - - if (pGain2->num_gain_data == 0) - gain1 = ONE_16; - else - gain1 = (ONE_16<<4)>>(pGain2->levcode[0]); - - if (pGain1->num_gain_data == 0) { - /* Remark: This path is called >90%. */ - /* Apply gain for all samples from 0...255 */ - applyFixGain(pIn, pPrev, pOut, 0, gain1); - } else { - /* Remark: This path is called seldom. */ - numdata = pGain1->num_gain_data; - pGain1->loccode[numdata] = 32; - pGain1->levcode[numdata] = 4; - - nsample = 0; /* starting loop with =0 */ - - for (cnt = 0; cnt < numdata; cnt++) { - startLoc = pGain1->loccode[cnt] * 8; - - gain2 = (ONE_16<<4)>>(pGain1->levcode[cnt]); - gain_inc = gain_tab2[(pGain1->levcode[cnt+1] - pGain1->levcode[cnt])+15]; - - /* Apply variable gain (gain1 -> gain2) to samples */ - nsample = applyVariableGain(pIn, pPrev, pOut, nsample, startLoc, gain1, gain2, gain_inc); - } - /* Apply gain for the residual samples from nsample...255 */ - applyFixGain(pIn, pPrev, pOut, nsample, gain1); - } - - /* Delay for the overlapping part. */ - memcpy(pPrev, &pIn[256], 256*sizeof(int32_t)); -} - - -/** - * Combine the tonal band spectrum and regular band spectrum - * Return position of the last tonal coefficient - - * - * @param pSpectrum output spectrum buffer - * @param numComponents amount of tonal components - * @param pComponent tonal components for this band - */ - -static int addTonalComponents (int32_t *pSpectrum, int numComponents, tonal_component *pComponent) -{ - int cnt, i, lastPos = -1; - int32_t *pOut; - int32_t *pIn; - - for (cnt = 0; cnt < numComponents; cnt++){ - lastPos = FFMAX(pComponent[cnt].pos + pComponent[cnt].numCoefs, lastPos); - pIn = pComponent[cnt].coef; - pOut = &(pSpectrum[pComponent[cnt].pos]); - - for (i=0 ; i>3), (((y) - (x))))) -*/ -#define INTERPOLATE_FP16(x, y, s) ((x) + ((s*((y)-(x)))>>3)) - -static void reverseMatrixing(int32_t *su1, int32_t *su2, int *pPrevCode, int *pCurrCode) -{ - int i, band, nsample, s1, s2; - int32_t c1, c2; - int32_t mc1_l, mc1_r, mc2_l, mc2_r; - - for (i=0,band = 0; band < 4*256; band+=256,i++) { - s1 = pPrevCode[i]; - s2 = pCurrCode[i]; - nsample = 0; - - if (s1 != s2) { - /* Selector value changed, interpolation needed. */ - mc1_l = matrixCoeffs_fix[s1<<1]; - mc1_r = matrixCoeffs_fix[(s1<<1)+1]; - mc2_l = matrixCoeffs_fix[s2<<1]; - mc2_r = matrixCoeffs_fix[(s2<<1)+1]; - - /* Interpolation is done over the first eight samples. */ - for(; nsample < 8; nsample++) { - c1 = su1[band+nsample]; - c2 = su2[band+nsample]; - c2 = fixmul16(c1, INTERPOLATE_FP16(mc1_l, mc2_l, nsample)) + fixmul16(c2, INTERPOLATE_FP16(mc1_r, mc2_r, nsample)); - su1[band+nsample] = c2; - su2[band+nsample] = (c1 << 1) - c2; - } - } - - /* Apply the matrix without interpolation. */ - switch (s2) { - case 0: /* M/S decoding */ - for (; nsample < 256; nsample++) { - c1 = su1[band+nsample]; - c2 = su2[band+nsample]; - su1[band+nsample] = c2 << 1; - su2[band+nsample] = (c1 - c2) << 1; - } - break; - - case 1: - for (; nsample < 256; nsample++) { - c1 = su1[band+nsample]; - c2 = su2[band+nsample]; - su1[band+nsample] = (c1 + c2) << 1; - su2[band+nsample] = -1*(c2 << 1); - } - break; - case 2: - case 3: - for (; nsample < 256; nsample++) { - c1 = su1[band+nsample]; - c2 = su2[band+nsample]; - su1[band+nsample] = c1 + c2; - su2[band+nsample] = c1 - c2; - } - break; - default: - /* assert(0) */; - break; - } - } -} - -static void getChannelWeights (int indx, int flag, int32_t ch[2]){ - /* Read channel weights from table */ - if (flag) { - /* Swap channel weights */ - ch[1] = channelWeights0[indx&7]; - ch[0] = channelWeights1[indx&7]; - } else { - ch[0] = channelWeights0[indx&7]; - ch[1] = channelWeights1[indx&7]; - } -} - -static void channelWeighting (int32_t *su1, int32_t *su2, int *p3) -{ - int band, nsample; - /* w[x][y] y=0 is left y=1 is right */ - int32_t w[2][2]; - - if (p3[1] != 7 || p3[3] != 7){ - getChannelWeights(p3[1], p3[0], w[0]); - getChannelWeights(p3[3], p3[2], w[1]); - - for(band = 1; band < 4; band++) { - /* scale the channels by the weights */ - for(nsample = 0; nsample < 8; nsample++) { - su1[band*256+nsample] = fixmul16(su1[band*256+nsample], INTERPOLATE_FP16(w[0][0], w[0][1], nsample)); - su2[band*256+nsample] = fixmul16(su2[band*256+nsample], INTERPOLATE_FP16(w[1][0], w[1][1], nsample)); - } - - for(; nsample < 256; nsample++) { - su1[band*256+nsample] = fixmul16(su1[band*256+nsample], w[1][0]); - su2[band*256+nsample] = fixmul16(su2[band*256+nsample], w[1][1]); - } - } - } -} - -/** - * Decode a Sound Unit - * - * @param gb the GetBit context - * @param pSnd the channel unit to be used - * @param pOut the decoded samples before IQMF - * @param channelNum channel number - * @param codingMode the coding mode (JOINT_STEREO or regular stereo/mono) - */ - -static int decodeChannelSoundUnit (GetBitContext *gb, channel_unit *pSnd, int32_t *pOut, int channelNum, int codingMode) -{ - int band, result=0, numSubbands, lastTonal, numBands; - if (codingMode == JOINT_STEREO && channelNum == 1) { - if (get_bits(gb,2) != 3) { - DEBUGF("JS mono Sound Unit id != 3.\n"); - return -1; - } - } else { - if (get_bits(gb,6) != 0x28) { - DEBUGF("Sound Unit id != 0x28.\n"); - return -1; - } - } - - /* number of coded QMF bands */ - pSnd->bandsCoded = get_bits(gb,2); - - result = decodeGainControl (gb, &(pSnd->gainBlock[pSnd->gcBlkSwitch]), pSnd->bandsCoded); - if (result) return result; - - pSnd->numComponents = decodeTonalComponents (gb, pSnd->components, pSnd->bandsCoded); - if (pSnd->numComponents == -1) return -1; - - numSubbands = decodeSpectrum (gb, pSnd->spectrum); - - /* Merge the decoded spectrum and tonal components. */ - lastTonal = addTonalComponents (pSnd->spectrum, pSnd->numComponents, pSnd->components); - - - /* calculate number of used MLT/QMF bands according to the amount of coded spectral lines */ - numBands = (subbandTab[numSubbands] - 1) >> 8; - if (lastTonal >= 0) - numBands = FFMAX((lastTonal + 256) >> 8, numBands); - - /* Reconstruct time domain samples. */ - for (band=0; band<4; band++) { - /* Perform the IMDCT step without overlapping. */ - if (band <= numBands) { - IMLT(&(pSnd->spectrum[band*256]), pSnd->IMDCT_buf); - } else { - memset(pSnd->IMDCT_buf, 0, 512 * sizeof(int32_t)); - } - - /* gain compensation and overlapping */ - gainCompensateAndOverlap (pSnd->IMDCT_buf, &(pSnd->prevFrame[band*256]), &(pOut[band*256]), - &((pSnd->gainBlock[1 - (pSnd->gcBlkSwitch)]).gBlock[band]), - &((pSnd->gainBlock[pSnd->gcBlkSwitch]).gBlock[band])); - } - - /* Swap the gain control buffers for the next frame. */ - pSnd->gcBlkSwitch ^= 1; - - return 0; -} - -/** - * Frame handling - * - * @param q Atrac3 private context - * @param databuf the input data - */ - -static int decodeFrame(ATRAC3Context *q, const uint8_t* databuf, int off) -{ - int result, i; - int32_t *p1, *p2, *p3, *p4; - uint8_t *ptr1; - - if (q->codingMode == JOINT_STEREO) { - - /* channel coupling mode */ - /* decode Sound Unit 1 */ - init_get_bits(&q->gb,databuf,q->bits_per_frame); - - result = decodeChannelSoundUnit(&q->gb, q->pUnits, q->outSamples, 0, JOINT_STEREO); - if (result != 0) - return (result); - - /* Framedata of the su2 in the joint-stereo mode is encoded in - * reverse byte order so we need to swap it first. */ - if (databuf == q->decoded_bytes_buffer) { - uint8_t *ptr2 = q->decoded_bytes_buffer+q->bytes_per_frame-1; - ptr1 = q->decoded_bytes_buffer; - for (i = 0; i < (q->bytes_per_frame/2); i++, ptr1++, ptr2--) { - FFSWAP(uint8_t,*ptr1,*ptr2); - } - } else { - const uint8_t *ptr2 = databuf+q->bytes_per_frame-1; - for (i = 0; i < q->bytes_per_frame; i++) - q->decoded_bytes_buffer[i] = *ptr2--; - } - - /* Skip the sync codes (0xF8). */ - ptr1 = q->decoded_bytes_buffer; - for (i = 4; *ptr1 == 0xF8; i++, ptr1++) { - if (i >= q->bytes_per_frame) - return -1; - } - - - /* set the bitstream reader at the start of the second Sound Unit*/ - init_get_bits(&q->gb,ptr1,q->bits_per_frame); - - /* Fill the Weighting coeffs delay buffer */ - memmove(q->weighting_delay,&(q->weighting_delay[2]),4*sizeof(int)); - q->weighting_delay[4] = get_bits1(&q->gb); - q->weighting_delay[5] = get_bits(&q->gb,3); - - for (i = 0; i < 4; i++) { - q->matrix_coeff_index_prev[i] = q->matrix_coeff_index_now[i]; - q->matrix_coeff_index_now[i] = q->matrix_coeff_index_next[i]; - q->matrix_coeff_index_next[i] = get_bits(&q->gb,2); - } - - /* Decode Sound Unit 2. */ - result = decodeChannelSoundUnit(&q->gb, &q->pUnits[1], &q->outSamples[1024], 1, JOINT_STEREO); - if (result != 0) - return (result); - - /* Reconstruct the channel coefficients. */ - reverseMatrixing(q->outSamples, &q->outSamples[1024], q->matrix_coeff_index_prev, q->matrix_coeff_index_now); - - channelWeighting(q->outSamples, &q->outSamples[1024], q->weighting_delay); - - } else { - /* normal stereo mode or mono */ - /* Decode the channel sound units. */ - for (i=0 ; ichannels ; i++) { - - /* Set the bitstream reader at the start of a channel sound unit. */ - init_get_bits(&q->gb, databuf+((i*q->bytes_per_frame)/q->channels)+off, (q->bits_per_frame)/q->channels); - - result = decodeChannelSoundUnit(&q->gb, &q->pUnits[i], &q->outSamples[i*1024], i, q->codingMode); - if (result != 0) - return (result); - } - } - - /* Apply the iQMF synthesis filter. */ - p1= q->outSamples; - for (i=0 ; ichannels ; i++) { - p2= p1+256; - p3= p2+256; - p4= p3+256; - iqmf (p1, p2, 256, p1, q->pUnits[i].delayBuf1, q->tempBuf); - iqmf (p4, p3, 256, p3, q->pUnits[i].delayBuf2, q->tempBuf); - iqmf (p1, p3, 512, p1, q->pUnits[i].delayBuf3, q->tempBuf); - p1 +=1024; - } - - return 0; -} - - -/** - * Atrac frame decoding - * - * @param rmctx pointer to the AVCodecContext - */ - -int atrac3_decode_frame(unsigned long block_align, ATRAC3Context *q, - int *data_size, const uint8_t *buf, int buf_size) { - int result = 0, off = 0; - const uint8_t* databuf; - - if ((unsigned)buf_size < block_align) - return buf_size; - - /* Check if we need to descramble and what buffer to pass on. */ - if (q->scrambled_stream) { - off = decode_bytes(buf, q->decoded_bytes_buffer, block_align); - databuf = q->decoded_bytes_buffer; - } else { - databuf = buf; - } - - result = decodeFrame(q, databuf, off); - - if (result != 0) { - DEBUGF("Frame decoding error!\n"); - return -1; - } - - if (q->channels == 1) - *data_size = 1024 * sizeof(int32_t); - else - *data_size = 2048 * sizeof(int32_t); - - return block_align; -} - - -/** - * Atrac3 initialization - * - * @param rmctx pointer to the RMContext - */ -int atrac3_decode_init(ATRAC3Context *q, struct mp3entry *id3) -{ - int i; - uint8_t *edata_ptr = (uint8_t*)&id3->id3v2buf; - -#if defined(CPU_COLDFIRE) - coldfire_set_macsr(EMAC_FRACTIONAL | EMAC_SATURATE); -#endif - - /* Take data from the RM container. */ - q->sample_rate = id3->frequency; - q->channels = id3->channels; - q->bit_rate = id3->bitrate * 1000; - q->bits_per_frame = id3->bytesperframe * 8; - q->bytes_per_frame = id3->bytesperframe; - - /* Take care of the codec-specific extradata. */ - - if (id3->extradata_size == 14) { - /* Parse the extradata, WAV format */ - DEBUGF("[0-1] %d\n",rm_get_uint16le(&edata_ptr[0])); /* Unknown value always 1 */ - q->samples_per_channel = rm_get_uint32le(&edata_ptr[2]); - q->codingMode = rm_get_uint16le(&edata_ptr[6]); - DEBUGF("[8-9] %d\n",rm_get_uint16le(&edata_ptr[8])); /* Dupe of coding mode */ - q->frame_factor = rm_get_uint16le(&edata_ptr[10]); /* Unknown always 1 */ - DEBUGF("[12-13] %d\n",rm_get_uint16le(&edata_ptr[12])); /* Unknown always 0 */ - - /* setup */ - q->samples_per_frame = 1024 * q->channels; - q->atrac3version = 4; - q->delay = 0x88E; - if (q->codingMode) - q->codingMode = JOINT_STEREO; - else - q->codingMode = STEREO; - q->scrambled_stream = 0; - - if ((q->bytes_per_frame == 96*q->channels*q->frame_factor) || (q->bytes_per_frame == 152*q->channels*q->frame_factor) || (q->bytes_per_frame == 192*q->channels*q->frame_factor)) { - } else { - DEBUGF("Unknown frame/channel/frame_factor configuration %d/%d/%d\n", q->bytes_per_frame, q->channels, q->frame_factor); - return -1; - } - - } else if (id3->extradata_size == 10) { - /* Parse the extradata, RM format. */ - q->atrac3version = rm_get_uint32be(&edata_ptr[0]); - q->samples_per_frame = rm_get_uint16be(&edata_ptr[4]); - q->delay = rm_get_uint16be(&edata_ptr[6]); - q->codingMode = rm_get_uint16be(&edata_ptr[8]); - - q->samples_per_channel = q->samples_per_frame / q->channels; - q->scrambled_stream = 1; - - } else { - DEBUGF("Unknown extradata size %d.\n",id3->extradata_size); - } - /* Check the extradata. */ - - if (q->atrac3version != 4) { - DEBUGF("Version %d != 4.\n",q->atrac3version); - return -1; - } - - if (q->samples_per_frame != 1024 && q->samples_per_frame != 2048) { - DEBUGF("Unknown amount of samples per frame %d.\n",q->samples_per_frame); - return -1; - } - - if (q->delay != 0x88E) { - DEBUGF("Unknown amount of delay %x != 0x88E.\n",q->delay); - return -1; - } - - if (q->codingMode == STEREO) { - DEBUGF("Normal stereo detected.\n"); - } else if (q->codingMode == JOINT_STEREO) { - DEBUGF("Joint stereo detected.\n"); - } else { - DEBUGF("Unknown channel coding mode %x!\n",q->codingMode); - return -1; - } - - if (id3->channels <= 0 || id3->channels > 2 ) { - DEBUGF("Channel configuration error!\n"); - return -1; - } - - - if(id3->bytesperframe >= UINT16_MAX/2) - return -1; - - - /* Initialize the VLC tables. */ - if (!vlcs_initialized) { - for (i=0 ; i<7 ; i++) { - spectral_coeff_tab[i].table = &atrac3_vlc_table[atrac3_vlc_offs[i]]; - spectral_coeff_tab[i].table_allocated = atrac3_vlc_offs[i + 1] - atrac3_vlc_offs[i]; - init_vlc (&spectral_coeff_tab[i], 9, huff_tab_sizes[i], - huff_bits[i], 1, 1, - huff_codes[i], 1, 1, INIT_VLC_USE_NEW_STATIC); - } - - vlcs_initialized = 1; - - } - - init_atrac3_transforms(); - - /* init the joint-stereo decoding data */ - q->weighting_delay[0] = 0; - q->weighting_delay[1] = 7; - q->weighting_delay[2] = 0; - q->weighting_delay[3] = 7; - q->weighting_delay[4] = 0; - q->weighting_delay[5] = 7; - - for (i=0; i<4; i++) { - q->matrix_coeff_index_prev[i] = 3; - q->matrix_coeff_index_now[i] = 3; - q->matrix_coeff_index_next[i] = 3; - } - - /* Link the iram'ed arrays to the decoder's data structure */ - q->pUnits = channel_units; - q->pUnits[0].spectrum = &atrac3_spectrum [0][0]; - q->pUnits[1].spectrum = &atrac3_spectrum [1][0]; - q->pUnits[0].IMDCT_buf = &atrac3_IMDCT_buf[0][0]; - q->pUnits[1].IMDCT_buf = &atrac3_IMDCT_buf[1][0]; - q->pUnits[0].prevFrame = &atrac3_prevFrame[0][0]; - q->pUnits[1].prevFrame = &atrac3_prevFrame[1][0]; - - return 0; -} - diff --git a/apps/codecs/libatrac/atrac3.h b/apps/codecs/libatrac/atrac3.h deleted file mode 100644 index 64086b6411..0000000000 --- a/apps/codecs/libatrac/atrac3.h +++ /dev/null @@ -1,114 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2009 Mohamed Tarek - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ - -#include "ffmpeg_get_bits.h" -#include "../librm/rm.h" -#include "codeclib.h" - -#if (CONFIG_CPU == PP5022) || (CONFIG_CPU == PP5024) || \ - (CONFIG_CPU == MCF5250) || defined(CPU_S5L870X) -/* PP5022/24, MCF5250 and S5L870x have larger IRAM */ -#define IBSS_ATTR_LARGE_IRAM IBSS_ATTR -#define ICODE_ATTR_LARGE_IRAM ICODE_ATTR -#define ICONST_ATTR_LARGE_IRAM ICONST_ATTR -#else -/* other CPUs IRAM is not large enough */ -#define IBSS_ATTR_LARGE_IRAM -#define ICODE_ATTR_LARGE_IRAM -#define ICONST_ATTR_LARGE_IRAM -#endif - -/* These structures are needed to store the parsed gain control data. */ -typedef struct { - int num_gain_data; - int levcode[8]; - int loccode[8]; -} gain_info; - -typedef struct { - gain_info gBlock[4]; -} gain_block; - -typedef struct { - int pos; - int numCoefs; - int32_t coef[8]; -} tonal_component; - -typedef struct { - int bandsCoded; - int numComponents; - tonal_component components[64]; - int32_t *prevFrame; - int gcBlkSwitch; - gain_block gainBlock[2]; - - int32_t *spectrum; - int32_t *IMDCT_buf; - - int32_t delayBuf1[46] MEM_ALIGN_ATTR; /// ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id: - * - * Copyright (C) 2009 by Andree Buschmann - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ - -#include "config.h" - - .section .text, "ax", %progbits - -/**************************************************************************** - * void atrac3_iqmf_matrixing(int32_t *dest, - * int32_t *inlo, - * int32_t *inhi, - * unsigned int count); - * - * Matrixing step within iqmf of atrac3 synthesis. Reference implementation: - * - * for(i=0; i>31 || hi<<1 */ - mov r12, r12, lsr #31 - orr r8, r12, r8, lsl #1 /* s2 = low>>31 || hi<<1 */ - - stmia r0!, {r8, r9} /* store result out[0]=s2, out[1]=s1 */ - sub r1, r1, #184 /* roll back 64 entries = 184 bytes */ - sub r2, r2, #192 /* roll back 48 entries = 192 bytes = win[0] */ - - subs r3, r3, #1 /* outer loop -= 1 */ - bgt .iqmf_dewindow_outer_loop - - ldmpc regs=r4-r9 /* restore registers */ - -.atrac3_iqmf_dewindowing_end: - .size atrac3_iqmf_dewindowing,.atrac3_iqmf_dewindowing_end-atrac3_iqmf_dewindowing diff --git a/apps/codecs/libatrac/atrac3_armv5e.S b/apps/codecs/libatrac/atrac3_armv5e.S deleted file mode 100644 index 1d9d35a5da..0000000000 --- a/apps/codecs/libatrac/atrac3_armv5e.S +++ /dev/null @@ -1,163 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id: - * - * Copyright (C) 2010 by Michael Giacomelli - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ - -#include "config.h" - - .section .text, "ax", %progbits - - -/**************************************************************************** - * atrac3_iqmf_dewindowing_armv5e(int32_t *out, - * int32_t *in, - * int32_t *win, - * unsigned int nIn); - * - * Dewindowing step within iqmf of atrac3 synthesis using 16 bit filter - * coefficients and armv5e packed multiply instructions. Uses 2.5 cycles - * per filter coefficient (ideal). Benchmarked 3.54 per coefficient (Clip+). - * - * Reference implementation: - * - * for (j = nIn; j != 0; j--) { - * s1 = fixmul32(in[0], win[0]); - * s2 = fixmul32(in[1], win[1]); - * for (i = 2; i < 48; i += 2) { - * s1 += fixmul32(in[i ], win[i ]); - * s2 += fixmul32(in[i+1], win[i+1]); - * } - * out[0] = s2 << 1; - * out[1] = s1 << 1; - * in += 2; - * out += 2; - * } - * Note: r12 is a scratch register and can be used without restorage. - ****************************************************************************/ - .align 2 - .global atrac3_iqmf_dewindowing_armv5e - .type atrac3_iqmf_dewindowing_armv5e, %function - -atrac3_iqmf_dewindowing_armv5e: - /* r0 = dest */ - /* r1 = input samples */ - /* r2 = window coefficients */ - /* r3 = counter */ - stmfd sp!, {r4-r11, lr} /* save non-scratch registers */ - -.iqmf_dewindow_outer_loop: /* outer loop 0...counter-1 */ - /* 0.. 7 */ - ldmia r2!, {r4, r5, r8, r9} /* load win[0..7] */ - ldmia r1!, {r6, r7, r10, r11} /* load in[0..3] to avoid stall on arm11 */ - smulwb lr, r6, r4 /* s1 = in[0] * win[0] */ - smulwt r12, r7, r4 /* s2 = in[1] * win[1] */ - smlawb lr, r10, r5, lr /* s1 += in[i ] * win[i ] >> 16 */ - smlawt r12, r11,r5, r12 /* s2 += in[i+1] * win[i+1] >> 16 */ - - ldmia r1!, {r6, r7, r10, r11} /* load in[i...i+3] */ - smlawb lr, r6, r8, lr /* s1 += in[i ] * win[i ] >> 16 */ - smlawt r12, r7, r8, r12 /* s2 += in[i+1] * win[i+1] >> 16 */ - smlawb lr, r10, r9, lr /* s1 += in[i ] * win[i ] >> 16 */ - smlawt r12, r11, r9, r12 /* s2 += in[i+1] * win[i+1] >> 16 */ - - /* 8..15 */ - ldmia r2!, {r4, r5, r8, r9} /* load win[8..15] */ - ldmia r1!, {r6, r7, r10, r11} /* load in[i...i+3] */ - smlawb lr, r6, r4, lr /* s1 += in[i ] * win[i ] >> 16 */ - smlawt r12, r7, r4, r12 /* s2 += in[i+1] * win[i+1] >> 16 */ - smlawb lr, r10, r5, lr /* s1 += in[i ] * win[i ] >> 16 */ - smlawt r12, r11,r5, r12 /* s2 += in[i+1] * win[i+1] >> 16 */ - - ldmia r1!, {r6, r7, r10, r11} /* load in[i...i+3] */ - smlawb lr, r6, r8, lr /* s1 += in[i ] * win[i ] >> 16 */ - smlawt r12, r7, r8, r12 /* s2 += in[i+1] * win[i+1] >> 16 */ - smlawb lr, r10, r9, lr /* s1 += in[i ] * win[i ] >> 16 */ - smlawt r12, r11,r9, r12 /* s2 += in[i+1] * win[i+1] >> 16 */ - - /* 16..23 */ - ldmia r2!, {r4, r5, r8, r9} /* load win[16..23] */ - ldmia r1!, {r6, r7, r10, r11} /* load in[i...i+3] */ - smlawb lr, r6, r4, lr /* s1 += in[i ] * win[i ] >> 16 */ - smlawt r12, r7, r4, r12 /* s2 += in[i+1] * win[i+1] >> 16 */ - smlawb lr, r10, r5, lr /* s1 += in[i ] * win[i ] >> 16 */ - smlawt r12, r11,r5, r12 /* s2 += in[i+1] * win[i+1] >> 16 */ - - ldmia r1!, {r6, r7, r10, r11} /* load in[i...i+3] */ - smlawb lr, r6, r8, lr /* s1 += in[i ] * win[i ] >> 16 */ - smlawt r12, r7, r8, r12 /* s2 += in[i+1] * win[i+1] >> 16 */ - smlawb lr, r10, r9, lr /* s1 += in[i ] * win[i ] >> 16 */ - smlawt r12, r11,r9, r12 /* s2 += in[i+1] * win[i+1] >> 16 */ - - /* 24..31 */ - ldmia r2!, {r4, r5, r8, r9} /* load win[24..31] */ - ldmia r1!, {r6, r7, r10, r11} /* load in[i...i+3] */ - smlawb lr, r6, r4, lr /* s1 += in[i ] * win[i ] >> 16 */ - smlawt r12, r7, r4, r12 /* s2 += in[i+1] * win[i+1] >> 16 */ - smlawb lr, r10, r5, lr /* s1 += in[i ] * win[i ] >> 16 */ - smlawt r12, r11,r5, r12 /* s2 += in[i+1] * win[i+1] >> 16 */ - - ldmia r1!, {r6, r7, r10, r11} /* load in[i...i+3] */ - smlawb lr, r6, r8, lr /* s1 += in[i ] * win[i ] >> 16 */ - smlawt r12, r7, r8, r12 /* s2 += in[i+1] * win[i+1] >> 16 */ - smlawb lr, r10, r9, lr /* s1 += in[i ] * win[i ] >> 16 */ - smlawt r12, r11,r9, r12 /* s2 += in[i+1] * win[i+1] >> 16 */ - - /* 32..39 */ - ldmia r2!, {r4, r5, r8, r9} /* load win[32..39] */ - ldmia r1!, {r6, r7, r10, r11} /* load in[i...i+3] */ - smlawb lr, r6, r4, lr /* s1 += in[i ] * win[i ] >> 16 */ - smlawt r12, r7, r4, r12 /* s2 += in[i+1] * win[i+1] >> 16 */ - smlawb lr, r10, r5, lr /* s1 += in[i ] * win[i ] >> 16 */ - smlawt r12, r11,r5, r12 /* s2 += in[i+1] * win[i+1] >> 16 */ - - ldmia r1!, {r6, r7, r10, r11} /* load in[i...i+3] */ - smlawb lr, r6, r8, lr /* s1 += in[i ] * win[i ] >> 16 */ - smlawt r12, r7, r8, r12 /* s2 += in[i+1] * win[i+1] >> 16 */ - smlawb lr, r10, r9, lr /* s1 += in[i ] * win[i ] >> 16 */ - smlawt r12, r11,r9, r12 /* s2 += in[i+1] * win[i+1] >> 16 */ - - /* 40..47 */ - ldmia r2!, {r4, r5, r8, r9} /* load win[40..47] */ - ldmia r1!, {r6, r7, r10, r11} /* load in[i...i+3] */ - smlawb lr, r6, r4, lr /* s1 += in[i ] * win[i ] >> 16 */ - smlawt r12, r7, r4, r12 /* s2 += in[i+1] * win[i+1] >> 16 */ - smlawb lr, r10, r5, lr /* s1 += in[i ] * win[i ] >> 16 */ - smlawt r12, r11,r5, r12 /* s2 += in[i+1] * win[i+1] >> 16 */ - - ldmia r1!, {r6, r7, r10, r11} /* load in[i...i+3] */ - smlawb lr, r6, r8, lr /* s1 += in[i ] * win[i ] >> 16 */ - smlawt r12, r7, r8, r12 /* s2 += in[i+1] * win[i+1] >> 16 */ - smlawb lr, r10, r9, lr /* s1 += in[i ] * win[i ] >> 16 */ - smlawt r12, r11,r9, r12 /* s2 += in[i+1] * win[i+1] >> 16 */ - - - mov lr , lr , lsl #1 - mov r12, r12, lsl #1 - - stmia r0!, {r12, lr} /* store result out[0]=s2, out[1]=s1 */ - sub r1, r1, #184 /* roll back 64 entries = 184 bytes */ - sub r2, r2, #96 /* roll back 48 entries * 2 bytes = 96 bytes = win[0] */ - - subs r3, r3, #1 /* outer loop -= 1 */ - bgt .iqmf_dewindow_outer_loop - - ldmpc regs=r4-r11 /* restore registers */ - -.atrac3_iqmf_dewindowing_armv5e_end: - .size atrac3_iqmf_dewindowing_armv5e,.atrac3_iqmf_dewindowing_armv5e_end-atrac3_iqmf_dewindowing_armv5e diff --git a/apps/codecs/libatrac/atrac3data.h b/apps/codecs/libatrac/atrac3data.h deleted file mode 100644 index 30abb37572..0000000000 --- a/apps/codecs/libatrac/atrac3data.h +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Atrac 3 compatible decoder data - * Copyright (c) 2006-2007 Maxim Poliakovski - * Copyright (c) 2006-2007 Benjamin Larsson - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/** - * @file libavcodec/atrac3data.h - * Atrac 3 AKA RealAudio 8 compatible decoder data - */ - -#ifndef AVCODEC_ATRAC3DATA_H -#define AVCODEC_ATRAC3DATA_H - -#include - -/* VLC tables */ - -static const uint8_t huffcode1[9] ICONST_ATTR_LARGE_IRAM = { - 0x0,0x4,0x5,0xC,0xD,0x1C,0x1D,0x1E,0x1F, -}; - -static const uint8_t huffbits1[9] ICONST_ATTR_LARGE_IRAM = { - 1,3,3,4,4,5,5,5,5, -}; - -static const uint8_t huffcode2[5] ICONST_ATTR_LARGE_IRAM = { - 0x0,0x4,0x5,0x6,0x7, -}; - -static const uint8_t huffbits2[5] ICONST_ATTR_LARGE_IRAM = { - 1,3,3,3,3, -}; - -static const uint8_t huffcode3[7] ICONST_ATTR_LARGE_IRAM = { -0x0,0x4,0x5,0xC,0xD,0xE,0xF, -}; - -static const uint8_t huffbits3[7] ICONST_ATTR_LARGE_IRAM = { - 1,3,3,4,4,4,4, -}; - -static const uint8_t huffcode4[9] ICONST_ATTR_LARGE_IRAM = { - 0x0,0x4,0x5,0xC,0xD,0x1C,0x1D,0x1E,0x1F, -}; - -static const uint8_t huffbits4[9] ICONST_ATTR_LARGE_IRAM = { - 1,3,3,4,4,5,5,5,5, -}; - -static const uint8_t huffcode5[15] ICONST_ATTR_LARGE_IRAM = { - 0x0,0x2,0x3,0x8,0x9,0xA,0xB,0x1C,0x1D,0x3C,0x3D,0x3E,0x3F,0xC,0xD, -}; - -static const uint8_t huffbits5[15] ICONST_ATTR_LARGE_IRAM = { - 2,3,3,4,4,4,4,5,5,6,6,6,6,4,4 -}; - -static const uint8_t huffcode6[31] ICONST_ATTR_LARGE_IRAM = { - 0x0,0x2,0x3,0x4,0x5,0x6,0x7,0x14,0x15,0x16,0x17,0x18,0x19,0x34,0x35, - 0x36,0x37,0x38,0x39,0x3A,0x3B,0x78,0x79,0x7A,0x7B,0x7C,0x7D,0x7E,0x7F,0x8,0x9, -}; - -static const uint8_t huffbits6[31] ICONST_ATTR_LARGE_IRAM = { - 3,4,4,4,4,4,4,5,5,5,5,5,5,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,4,4 -}; - -static const uint8_t huffcode7[63] ICONST_ATTR_LARGE_IRAM = { - 0x0,0x8,0x9,0xA,0xB,0xC,0xD,0xE,0xF,0x10,0x11,0x24,0x25,0x26,0x27,0x28, - 0x29,0x2A,0x2B,0x2C,0x2D,0x2E,0x2F,0x30,0x31,0x32,0x33,0x68,0x69,0x6A,0x6B,0x6C, - 0x6D,0x6E,0x6F,0x70,0x71,0x72,0x73,0x74,0x75,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2, - 0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF,0x2,0x3, -}; - -static const uint8_t huffbits7[63] ICONST_ATTR_LARGE_IRAM = { - 3,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,7,7,7,7,7, - 7,7,7,7,7,7,7,7,7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,4,4 -}; - -static const uint8_t huff_tab_sizes[7] ICONST_ATTR_LARGE_IRAM = { - 9, 5, 7, 9, 15, 31, 63, -}; - -static const uint8_t* const huff_codes[7] ICONST_ATTR_LARGE_IRAM = { - huffcode1,huffcode2,huffcode3,huffcode4,huffcode5,huffcode6,huffcode7, -}; - -static const uint8_t* const huff_bits[7] ICONST_ATTR_LARGE_IRAM = { - huffbits1,huffbits2,huffbits3,huffbits4,huffbits5,huffbits6,huffbits7, -}; - -static const uint16_t atrac3_vlc_offs[] ICONST_ATTR_LARGE_IRAM = { - 0,512,1024,1536,2048,2560,3072,3584,4096 -}; - -/* selector tables */ - -static const uint8_t CLCLengthTab[8] ICONST_ATTR_LARGE_IRAM = { - 0, 4, 3, 3, 4, 4, 5, 6}; -static const int8_t seTab_0[4] ICONST_ATTR_LARGE_IRAM = { - 0, 1, -2, -1}; -static const int8_t decTable1[18] ICONST_ATTR_LARGE_IRAM = { - 0,0, 0,1, 0,-1, 1,0, -1,0, 1,1, 1,-1, -1,1, -1,-1}; - - -/* tables for the scalefactor decoding */ -/* not needed anymore -static const float iMaxQuant[8] = { - 0.0, 1.0/1.5, 1.0/2.5, 1.0/3.5, 1.0/4.5, 1.0/7.5, 1.0/15.5, 1.0/31.5 -}; -*/ -static const uint16_t subbandTab[33] ICONST_ATTR_LARGE_IRAM = { - 0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160, 176, 192, 224, - 256, 288, 320, 352, 384, 416, 448, 480, 512, 576, 640, 704, 768, 896, 1024 -}; - -/* transform data */ -/* not needed anymore -static const float qmf_48tap_half[24] = { - -0.00001461907, -0.00009205479, -0.000056157569, 0.00030117269, - 0.0002422519,-0.00085293897, -0.0005205574, 0.0020340169, - 0.00078333891, -0.0042153862, -0.00075614988, 0.0078402944, - -0.000061169922, -0.01344162, 0.0024626821, 0.021736089, - -0.007801671, -0.034090221, 0.01880949, 0.054326009, - -0.043596379, -0.099384367, 0.13207909, 0.46424159 -}; -*/ -/* joint stereo related tables */ -/* not needed anymore -static const float matrixCoeffs[8] = {0.0, 2.0, 2.0, 2.0, 0.0, 0.0, 1.0, 1.0}; -*/ -#endif /* AVCODEC_ATRAC3DATA_H */ diff --git a/apps/codecs/libatrac/atrac3data_fixed.h b/apps/codecs/libatrac/atrac3data_fixed.h deleted file mode 100644 index 9eb79731ce..0000000000 --- a/apps/codecs/libatrac/atrac3data_fixed.h +++ /dev/null @@ -1,108 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2009 Michael Giacomelli - * Copyright (C) 2009 Mohamed Tarek - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ -/* tables for the scalefactor decoding */ -/* scaled by 2^31*/ -static const int32_t iMaxQuant_fix[8] ICONST_ATTR = { - 0x0, 0x55555580, 0x33333340, 0x24924940, 0x1c71c720, 0x11111120, 0x8421080, - 0x4104108 -}; - -/* scaled by 2^16 */ -static const int32_t SFTable_fixed[64] ICONST_ATTR = { - 0x00000800, 0x00000a14, 0x00000cb3, 0x00001000, 0x00001429, 0x00001966, - 0x00002000, 0x00002851, 0x000032cc, 0x00004000, 0x000050a3, 0x00006598, - 0x00008000, 0x0000a145, 0x0000cb30, 0x00010000, 0x0001428a, 0x00019660, - 0x00020000, 0x00028514, 0x00032cc0, 0x00040000, 0x00050a29, 0x00065980, - 0x00080000, 0x000a1452, 0x000cb2ff, 0x00100000, 0x001428a3, 0x001965ff, - 0x00200000, 0x00285146, 0x0032cbfd, 0x00400000, 0x0050a28c, 0x006597fb, - 0x00800000, 0x00a14518, 0x00cb2ff5, 0x01000000, 0x01428a30, 0x01965fea, - 0x02000000, 0x02851460, 0x032cbfd4, 0x04000000, 0x050a28c0, 0x06597fa8, - 0x08000000, 0x0a145180, 0x0cb2ff50, 0x10000000, 0x1428a300, 0x1965fea0, - 0x20000000, 0x28514600, 0x32cbfd40, 0x40000000, 0x50a28c00, 0x6597fa80, - 0x80000000, 0x80000000, 0x80000000, 0x80000000, -}; - -/* transform data */ -/* floating point values scaled by 2^31 */ -static const int32_t qmf_48tap_half_fix[24] = { - 0xffff855e, 0xfffcfbca, 0xfffe28eb, 0x0009de6b, 0x0007f028, 0xffe40d08, - 0xffeef140, 0x0042a692, 0x0019ab1f, 0xff75dec7, 0xffe738f5, 0x0100e928, - 0xfffdfedf, 0xfe478b84, 0x0050b279, 0x02c83f88, 0xff005ad7, 0xfba2ee80, - 0x02685970, 0x06f42798, 0xfa6b6f10, 0xf3475f80, 0x10e7f7c0, 0x3b6c44c0 -}; - -/* mdct window scaled by 2^31 */ -/* Remark: The preceding sign corrects the sign of the hexadecimal values */ -static const int32_t window_lookup[128] ICONST_ATTR MEM_ALIGN_ATTR = { - -0xffffb10c, -0xfffd394b, -0xfff8494f, -0xfff0e025, -0xffe6fc5f, -0xffda9c15, - -0xffcbbce6, -0xffba5bf4, -0xffa675e8, -0xff9006f0, -0xff770aba, -0xff5b7c7e, - -0xff3d56f2, -0xff1c9452, -0xfef92e59, -0xfed31e45, -0xfeaa5cd5, -0xfe7ee247, - -0xfe50a657, -0xfe1fa041, -0xfdebc6c1, -0xfdb5100d, -0xfd7b71d5, -0xfd3ee149, - -0xfcff5311, -0xfcbcbb49, -0xfc770d99, -0xfc2e3d15, -0xfbe23c39, -0xfb92fd29, - -0xfb407141, -0xfaea8989, -0xfa913661, -0xfa3467b1, -0xf9d40cd9, -0xf9701499, - -0xf9086d41, -0xf89d04a9, -0xf82dc7f1, -0xf7baa3e1, -0xf74384b1, -0xf6c85611, - -0xf6490321, -0xf5c576b1, -0xf53d9b21, -0xf4b15a01, -0xf4209ce1, -0xf38b4c71, - -0xf2f15171, -0xf2529411, -0xf1aefbf1, -0xf10670a1, -0xf058d941, -0xefa61cc1, - -0xeeee21c1, -0xee30cec1, -0xed6e0a41, -0xeca5ba61, -0xebd7c5c1, -0xeb041241, - -0xea2a8601, -0xe94b0861, -0xe8657f61, -0xe779d241, -0xe687e861, -0xe58fa9e1, - -0xe490fec1, -0xe38bd101, -0xe28009c1, -0xe16d93e1, -0xe0545ba1, -0xdf344dc1, - -0xde0d5881, -0xdcdf6bc1, -0xdbaa7801, -0xda6e70c1, -0xd92b4ac1, -0xd7e0fc81, - -0xd68f7ec1, -0xd536cd41, -0xd3d6e5c1, -0xd26fc901, -0xd10179c1, -0xcf8bff41, - -0xce0f6301, -0xcc8bb241, -0xcb00fdc1, -0xc96f5b01, -0xc7d6e141, -0xc637af41, - -0xc491e4c1, -0xc2e5a801, -0xc1332401, -0xbf7a8701, -0xbdbc0681, -0xbbf7da01, - -0xba2e4181, -0xb85f7f81, -0xb68bde01, -0xb4b3a981, -0xb2d73781, -0xb0f6df01, - -0xaf12ff01, -0xad2bfa81, -0xab423981, -0xa9562981, -0xa7683c01, -0xa578e701, - -0xa388a681, -0xa197f801, -0x9fa75e81, -0x9db75f01, -0x9bc88201, -0x99db5301, - -0x97f06001, -0x96083601, -0x94236601, -0x92427f81, -0x90661481, -0x8e8eb481, - -0x8cbced01, -0x8af14d81, -0x892c5f81, -0x876eab01, -0x85b8b681, -0x840b0301, - -0x82660c01, -0x80ca4a01, -}; - -/* Gain tables scaled by 2^16 */ -static const int32_t gain_tab2[31] ICONST_ATTR = { - 0x0003ab03, 0x00035d14, 0x0003159d, 0x0002d414, 0x000297fb, 0x000260e0, - 0x00022e57, 0x00020000, 0x0001d582, 0x0001ae8a, 0x00018ace, 0x00016a0a, - 0x00014bfe, 0x00013070, 0x0001172c, 0x00010000, 0x0000eac1, 0x0000d745, - 0x0000c567, 0x0000b505, 0x0000a5ff, 0x00009838, 0x00008b96, 0x00008000, - 0x00007560, 0x00006ba2, 0x000062b4, 0x00005a82, 0x000052ff, 0x00004c1c, - 0x000045cb, - -}; - -/* Joint-Stereo related tables, scaled by 2^16 */ -static const int32_t matrixCoeffs_fix[8] ICONST_ATTR = { - 0x00000000, 0x00020000, 0x00020000, 0x00020000, - 0x00000000, 0x00000000, 0x00010000, 0x00010000, -}; - -/* channelWeights0[i] = ONE_16 * ((i & 7)/7) */ -static const int32_t channelWeights0[8] = { - 0x00000000, 0x00002492, 0x00004925, 0x00006DB7, - 0x00009249, 0x0000B6DB, 0x0000DB6D, 0x00010000, -}; - -/* channelWeights1[i] = ONE_16 * sqrt(2-channelWeights0^2) */ -static const int32_t channelWeights1[8] = { - 0x00016A0A, 0x00016830, 0x00016293, 0x00015904, - 0x00014B2B, 0x00013877, 0x00011FF7, 0x00010000, -}; - diff --git a/apps/codecs/libatrac/fixp_math.h b/apps/codecs/libatrac/fixp_math.h deleted file mode 100644 index 014c5aa559..0000000000 --- a/apps/codecs/libatrac/fixp_math.h +++ /dev/null @@ -1,111 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2009 Mohamed Tarek - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ -#include -#include - -/* Macros for converting between various fixed-point representations and floating point. */ -#define ONE_16 (1L << 16) -#define fixtof64(x) (float)((float)(x) / (float)(1 << 16)) //does not work on int64_t! -#define ftofix32(x) ((int32_t)((x) * (float)(1 << 16) + ((x) < 0 ? -0.5 : 0.5))) -#define ftofix31(x) ((int32_t)((x) * (float)(1 << 31) + ((x) < 0 ? -0.5 : 0.5))) -#define fix31tof64(x) (float)((float)(x) / (float)(1 << 31)) - -/* Fixed point math routines for use in atrac3.c */ - -#if defined(CPU_ARM) - /* Calculates: result = (X*Y)>>16 */ - #define fixmul16(X,Y) \ - ({ \ - int32_t lo; \ - int32_t hi; \ - asm volatile ( \ - "smull %[lo], %[hi], %[x], %[y] \n\t" /* multiply */ \ - "mov %[lo], %[lo], lsr #16 \n\t" /* lo >>= 16 */ \ - "orr %[lo], %[lo], %[hi], lsl #16" /* lo |= (hi << 16) */ \ - : [lo]"=&r"(lo), [hi]"=&r"(hi) \ - : [x]"r"(X), [y]"r"(Y)); \ - lo; \ - }) - - /* Calculates: result = (X*Y)>>31 */ - /* Use scratch register r12 */ - #define fixmul31(X,Y) \ - ({ \ - int32_t lo; \ - int32_t hi; \ - asm volatile ( \ - "smull %[lo], %[hi], %[x], %[y] \n\t" /* multiply */ \ - "mov %[lo], %[lo], lsr #31 \n\t" /* lo >>= 31 */ \ - "orr %[lo], %[lo], %[hi], lsl #1" /* lo |= (hi << 1) */ \ - : [lo]"=&r"(lo), [hi]"=&r"(hi) \ - : [x]"r"(X), [y]"r"(Y)); \ - lo; \ - }) -#elif defined(CPU_COLDFIRE) - /* Calculates: result = (X*Y)>>16 */ - #define fixmul16(X,Y) \ - ({ \ - int32_t t, x = (X); \ - asm volatile ( \ - "mac.l %[x],%[y],%%acc0\n\t" /* multiply */ \ - "mulu.l %[y],%[x] \n\t" /* get lower half, avoid emac stall */ \ - "movclr.l %%acc0,%[t] \n\t" /* get higher half */ \ - "lsr.l #1,%[t] \n\t" /* hi >>= 1 to compensate emac shift */ \ - "move.w %[t],%[x] \n\t" /* combine halfwords */\ - "swap %[x] \n\t" \ - : [t]"=&d"(t), [x] "+d" (x) \ - : [y] "d" ((Y))); \ - x; \ - }) - - #define fixmul31(X,Y) \ - ({ \ - int32_t t; \ - asm volatile ( \ - "mac.l %[x], %[y], %%acc0\n\t" /* multiply */ \ - "movclr.l %%acc0, %[t]\n\t" /* get higher half as result */ \ - : [t] "=d" (t) \ - : [x] "r" ((X)), [y] "r" ((Y))); \ - t; \ - }) -#else - static inline int32_t fixmul16(int32_t x, int32_t y) - { - int64_t temp; - temp = x; - temp *= y; - - temp >>= 16; - - return (int32_t)temp; - } - - static inline int32_t fixmul31(int32_t x, int32_t y) - { - int64_t temp; - temp = x; - temp *= y; - - temp >>= 31; //16+31-16 = 31 bits - - return (int32_t)temp; - } -#endif diff --git a/apps/codecs/libatrac/libatrac.make b/apps/codecs/libatrac/libatrac.make deleted file mode 100644 index 01606e1f15..0000000000 --- a/apps/codecs/libatrac/libatrac.make +++ /dev/null @@ -1,18 +0,0 @@ -# __________ __ ___. -# Open \______ \ ____ ____ | | _\_ |__ _______ ___ -# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / -# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < -# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ -# \/ \/ \/ \/ \/ -# $Id: libatrac.make 20151 2009-03-01 09:04:15Z amiconn $ -# - -# libatrac -ATRACLIB := $(CODECDIR)/libatrac.a -ATRACLIB_SRC := $(call preprocess, $(APPSDIR)/codecs/libatrac/SOURCES) -ATRACLIB_OBJ := $(call c2obj, $(ATRACLIB_SRC)) -OTHER_SRC += $(ATRACLIB_SRC) - -$(ATRACLIB): $(ATRACLIB_OBJ) - $(SILENT)$(shell rm -f $@) - $(call PRINTS,AR $(@F))$(AR) rcs $@ $^ >/dev/null diff --git a/apps/codecs/libcook/README.rockbox b/apps/codecs/libcook/README.rockbox deleted file mode 100644 index ae72f2a2f2..0000000000 --- a/apps/codecs/libcook/README.rockbox +++ /dev/null @@ -1,47 +0,0 @@ -Library: libcook -Imported by : Mohamed Tarek - -These files comprise a rm parser and a cook decoder based on the decoder -from ffmpeg. - -LICENSING INFORMATION - -ffmpeg is licensed under the Lesser GNU General Public License and the -file cook.c is Copyright 2003 Sascha Sommer and 2005 Benjamin Larsson. - -IMPORT DETAILS - -The decoder is based on ffmpeg-svn r18079. - -CONVERSION TO FIXED-POINT - -A patch from ffmpeg's mailing list was used to convert the decoder to -use fixed-point arithmetic. The patch was done by Ian Braithwaite, and -discussed here : - -http://thread.gmane.org/gmane.comp.video.ffmpeg.devel/46024 - -The patch is a bit dated (2007) so the modifications to cook.c had to -be done manually. The patch was also applied to cookdata.h and was -used to create cookdata_fixpoint.h, cook_fixpoint.h and -cook_fixp_mdct.h. - -cook_fixp_mdct.h and parts from cookdata_fixpoint.h were dropped and -rockbox's mdct library is now used in both the test program and the -real codec. - -Note : Only parts of the patch were committed to ffmpeg's repository. - -TESTING - -The test program should compile in any Unix-like environment using the -command "make -f Makefile.test". - -For ARM targets add -DCPU_ARM to CFLAGS in Makefile.test to make use of -the asm ARM optimisations in rockbox's mdct library. - -For Big-endian targets, change -D"ROCKBOX_LITTLE_ENDIAN=1" -to -D"ROCKBOX_BIG_ENDIAN=1" in Makefile.test. - -Running "./cooktest file.rm" will decode the audio data to a WAV file -called "output.wav" in the current directory. diff --git a/apps/codecs/libcook/SOURCES b/apps/codecs/libcook/SOURCES deleted file mode 100644 index b656fdd2f7..0000000000 --- a/apps/codecs/libcook/SOURCES +++ /dev/null @@ -1,2 +0,0 @@ -cook.c - diff --git a/apps/codecs/libcook/cook.c b/apps/codecs/libcook/cook.c deleted file mode 100644 index 29a1bab7d6..0000000000 --- a/apps/codecs/libcook/cook.c +++ /dev/null @@ -1,907 +0,0 @@ -/* - * COOK compatible decoder - * Copyright (c) 2003 Sascha Sommer - * Copyright (c) 2005 Benjamin Larsson - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/** - * @file cook.c - * Cook compatible decoder. Bastardization of the G.722.1 standard. - * This decoder handles RealNetworks, RealAudio G2 data. - * Cook is identified by the codec name cook in RM files. - * - * To use this decoder, a calling application must supply the extradata - * bytes provided from the RM container; 8+ bytes for mono streams and - * 16+ for stereo streams (maybe more). - * - * Codec technicalities (all this assume a buffer length of 1024): - * Cook works with several different techniques to achieve its compression. - * In the timedomain the buffer is divided into 8 pieces and quantized. If - * two neighboring pieces have different quantization index a smooth - * quantization curve is used to get a smooth overlap between the different - * pieces. - * To get to the transformdomain Cook uses a modulated lapped transform. - * The transform domain has 50 subbands with 20 elements each. This - * means only a maximum of 50*20=1000 coefficients are used out of the 1024 - * available. - */ - -#include -#include -#include -#include -#include -#include "codeclib.h" - -#include "cook.h" -#include "cookdata.h" - -/* the different Cook versions */ -#define MONO 0x1000001 -#define STEREO 0x1000002 -#define JOINT_STEREO 0x1000003 -#define MC_COOK 0x2000000 //multichannel Cook, not supported - -#define SUBBAND_SIZE 20 -#define MAX_SUBPACKETS 5 -//#define COOKDEBUG -#ifndef COOKDEBUG -#undef DEBUGF -#define DEBUGF(...) -#endif - -/** - * Random bit stream generator. - */ -static inline int cook_random(COOKContext *q) -{ - q->random_state = - q->random_state * 214013 + 2531011; /* typical RNG numbers */ - - return (q->random_state/0x1000000)&1; /*>>31*/ -} -#include "cook_fixpoint.h" - -/* debug functions */ - -#ifdef COOKDEBUG -static void dump_int_table(int* table, int size, int delimiter) { - int i=0; - DEBUGF("\n[%d]: ",i); - for (i=0 ; ienvelope_quant_index[ 0].table = vlcbuf00; - q->envelope_quant_index[ 1].table = vlcbuf01; - q->envelope_quant_index[ 2].table = vlcbuf02; - q->envelope_quant_index[ 3].table = vlcbuf03; - q->envelope_quant_index[ 4].table = vlcbuf04; - q->envelope_quant_index[ 5].table = vlcbuf05; - q->envelope_quant_index[ 6].table = vlcbuf06; - q->envelope_quant_index[ 7].table = vlcbuf07; - q->envelope_quant_index[ 8].table = vlcbuf08; - q->envelope_quant_index[ 9].table = vlcbuf09; - q->envelope_quant_index[10].table = vlcbuf10; - q->envelope_quant_index[11].table = vlcbuf11; - q->envelope_quant_index[12].table = vlcbuf12; - q->sqvh[0].table = vlcbuf13; - q->sqvh[1].table = vlcbuf14; - q->sqvh[2].table = vlcbuf15; - q->sqvh[3].table = vlcbuf16; - q->sqvh[4].table = vlcbuf17; - q->sqvh[5].table = vlcbuf18; - q->sqvh[6].table = vlcbuf19; - q->ccpl.table = vlcbuf20; - - /* Init envelope VLC (13 books) */ - for (i=0 ; i<13 ; i++) { - q->envelope_quant_index[i].table_allocated = env_size[i]; - result |= init_vlc (&q->envelope_quant_index[i], 9, 24, - envelope_quant_index_huffbits[i], 1, 1, - envelope_quant_index_huffcodes[i], 2, 2, INIT_VLC_USE_NEW_STATIC); - } - - /* Init subband VLC (7 books) */ - for (i=0 ; i<7 ; i++) { - q->sqvh[i].table_allocated = sqvh_size[i]; - result |= init_vlc (&q->sqvh[i], vhvlcsize_tab[i], vhsize_tab[i], - cvh_huffbits[i], 1, 1, - cvh_huffcodes[i], 2, 2, INIT_VLC_USE_NEW_STATIC); - } - - /* Init Joint-Stereo VLC (1 book) */ - if (q->nb_channels==2 && q->joint_stereo==1){ - q->ccpl.table_allocated = ccpl_size; - result |= init_vlc (&q->ccpl, 6, (1<js_vlc_bits)-1, - ccpl_huffbits[q->js_vlc_bits-2], 1, 1, - ccpl_huffcodes[q->js_vlc_bits-2], 2, 2, INIT_VLC_USE_NEW_STATIC); - DEBUGF("Joint-stereo VLC used.\n"); - } - - DEBUGF("VLC tables initialized. Result = %d\n",result); - return result; -} -/*************** init functions end ***********/ - -/** - * Cook indata decoding, every 32 bits are XORed with 0x37c511f2. - * Why? No idea, some checksum/error detection method maybe. - * - * Out buffer size: extra bytes are needed to cope with - * padding/misalignment. - * Subpackets passed to the decoder can contain two, consecutive - * half-subpackets, of identical but arbitrary size. - * 1234 1234 1234 1234 extraA extraB - * Case 1: AAAA BBBB 0 0 - * Case 2: AAAA ABBB BB-- 3 3 - * Case 3: AAAA AABB BBBB 2 2 - * Case 4: AAAA AAAB BBBB BB-- 1 5 - * - * Nice way to waste CPU cycles. - * - * @param inbuffer pointer to byte array of indata - * @param out pointer to byte array of outdata - * @param bytes number of bytes - */ -#define DECODE_BYTES_PAD1(bytes) (3 - ((bytes)+3) % 4) -#define DECODE_BYTES_PAD2(bytes) ((bytes) % 4 + DECODE_BYTES_PAD1(2 * (bytes))) - -static inline int decode_bytes(const uint8_t* inbuffer, uint8_t* out, int bytes){ - int i, off; - uint32_t c; - const uint32_t* buf; - uint32_t* obuf = (uint32_t*) out; - /* FIXME: 64 bit platforms would be able to do 64 bits at a time. - * I'm too lazy though, should be something like - * for(i=0 ; i> (off*8)) | (0x37c511f2 << (32-(off*8)))); - bytes += 3 + off; - for (i = 0; i < bytes/4; i++) - obuf[i] = c ^ buf[i]; - - return off; -} - -/** - * Fill the gain array for the timedomain quantization. - * - * @param q pointer to the COOKContext - * @param gaininfo[9] array of gain indexes - */ - -static void decode_gain_info(GetBitContext *gb, int *gaininfo) -{ - int i, n; - - while (get_bits1(gb)) {} - n = get_bits_count(gb) - 1; //amount of elements*2 to update - - i = 0; - while (n--) { - int index = get_bits(gb, 3); - int gain = get_bits1(gb) ? (int)get_bits(gb, 4) - 7 : -1; - - while (i <= index) gaininfo[i++] = gain; - } - while (i <= 8) gaininfo[i++] = 0; -} - -/** - * Create the quant index table needed for the envelope. - * - * @param q pointer to the COOKContext - * @param quant_index_table pointer to the array - */ - -static void decode_envelope(COOKContext *q, int* quant_index_table) { - int i,j, vlc_index; - - quant_index_table[0]= get_bits(&q->gb,6) - 6; //This is used later in categorize - - for (i=1 ; i < q->total_subbands ; i++){ - vlc_index=i; - if (i >= q->js_subband_start * 2) { - vlc_index-=q->js_subband_start; - } else { - vlc_index/=2; - if(vlc_index < 1) vlc_index = 1; - } - if (vlc_index>13) vlc_index = 13; //the VLC tables >13 are identical to No. 13 - - j = get_vlc2(&q->gb, q->envelope_quant_index[vlc_index-1].table, - q->envelope_quant_index[vlc_index-1].bits,2); - quant_index_table[i] = quant_index_table[i-1] + j - 12; //differential encoding - } -} - -/** - * Calculate the category and category_index vector. - * - * @param q pointer to the COOKContext - * @param quant_index_table pointer to the array - * @param category pointer to the category array - * @param category_index pointer to the category_index array - */ - -static void categorize(COOKContext *q, int* quant_index_table, - int* category, int* category_index){ - int exp_idx, bias, tmpbias1, tmpbias2, bits_left, num_bits, index, v, i, j; - int exp_index2[102]; - int exp_index1[102]; - - int tmp_categorize_array[128*2]; - int tmp_categorize_array1_idx=q->numvector_size; - int tmp_categorize_array2_idx=q->numvector_size; - - bits_left = q->bits_per_subpacket - get_bits_count(&q->gb); - - if(bits_left > q->samples_per_channel) { - bits_left = q->samples_per_channel + - ((bits_left - q->samples_per_channel)*5)/8; - //av_log(q->avctx, AV_LOG_ERROR, "bits_left = %d\n",bits_left); - } - - memset(&exp_index1,0,102*sizeof(int)); - memset(&exp_index2,0,102*sizeof(int)); - memset(&tmp_categorize_array,0,128*2*sizeof(int)); - - bias=-32; - - /* Estimate bias. */ - for (i=32 ; i>0 ; i=i/2){ - num_bits = 0; - index = 0; - for (j=q->total_subbands ; j>0 ; j--){ - exp_idx = av_clip((i - quant_index_table[index] + bias) / 2, 0, 7); - index++; - num_bits+=expbits_tab[exp_idx]; - } - if(num_bits >= bits_left - 32){ - bias+=i; - } - } - - /* Calculate total number of bits. */ - num_bits=0; - for (i=0 ; itotal_subbands ; i++) { - exp_idx = av_clip((bias - quant_index_table[i]) / 2, 0, 7); - num_bits += expbits_tab[exp_idx]; - exp_index1[i] = exp_idx; - exp_index2[i] = exp_idx; - } - tmpbias1 = tmpbias2 = num_bits; - - for (j = 1 ; j < q->numvector_size ; j++) { - if (tmpbias1 + tmpbias2 > 2*bits_left) { /* ---> */ - int max = -999999; - index=-1; - for (i=0 ; itotal_subbands ; i++){ - if (exp_index1[i] < 7) { - v = (-2*exp_index1[i]) - quant_index_table[i] + bias; - if ( v >= max) { - max = v; - index = i; - } - } - } - if(index==-1)break; - tmp_categorize_array[tmp_categorize_array1_idx++] = index; - tmpbias1 -= expbits_tab[exp_index1[index]] - - expbits_tab[exp_index1[index]+1]; - ++exp_index1[index]; - } else { /* <--- */ - int min = 999999; - index=-1; - for (i=0 ; itotal_subbands ; i++){ - if(exp_index2[i] > 0){ - v = (-2*exp_index2[i])-quant_index_table[i]+bias; - if ( v < min) { - min = v; - index = i; - } - } - } - if(index == -1)break; - tmp_categorize_array[--tmp_categorize_array2_idx] = index; - tmpbias2 -= expbits_tab[exp_index2[index]] - - expbits_tab[exp_index2[index]-1]; - --exp_index2[index]; - } - } - memcpy(category, exp_index2, sizeof(int) * q->total_subbands ); - memcpy(category_index, tmp_categorize_array+tmp_categorize_array2_idx, sizeof(int) * (q->numvector_size-1) ); -} - - -/** - * Expand the category vector. - * - * @param q pointer to the COOKContext - * @param category pointer to the category array - * @param category_index pointer to the category_index array - */ - -static inline void expand_category(COOKContext *q, int* category, - int* category_index){ - int i; - for(i=0 ; inum_vectors ; i++){ - ++category[category_index[i]]; - } -} - -/** - * Unpack the subband_coef_index and subband_coef_sign vectors. - * - * @param q pointer to the COOKContext - * @param category pointer to the category array - * @param subband_coef_index array of indexes to quant_centroid_tab - * @param subband_coef_sign signs of coefficients - */ - -static int unpack_SQVH(COOKContext *q, int category, int* subband_coef_index, - int* subband_coef_sign) { - int i,j; - int vlc, vd ,tmp, result; - - vd = vd_tab[category]; - result = 0; - for(i=0 ; igb, q->sqvh[category].table, q->sqvh[category].bits, 3); - if (q->bits_per_subpacket < get_bits_count(&q->gb)) - { - vlc = 0; - result = 1; - memset(subband_coef_index, 0, sizeof(int)*vd); - memset(subband_coef_sign, 0, sizeof(int)*vd); - subband_coef_index+=vd; - subband_coef_sign+=vd; - } - else - { - for(j=vd-1 ; j>=0 ; j--){ - tmp = (vlc * invradix_tab[category])/0x100000; - subband_coef_index[j] = vlc - tmp * (kmax_tab[category]+1); - vlc = tmp; - } - - for(j=0 ; jgb) < q->bits_per_subpacket) { - *subband_coef_sign++ = get_bits1(&q->gb); - } else { - result=1; - *subband_coef_sign++=0; - } - } else { - *subband_coef_sign++=0; - } - } - } - } - return result; -} - - -/** - * Fill the mlt_buffer with mlt coefficients. - * - * @param q pointer to the COOKContext - * @param category pointer to the category array - * @param quant_index_table pointer to the array - * @param mlt_buffer pointer to mlt coefficients - */ - -static void decode_vectors(COOKContext* q, int* category, - int *quant_index_table, REAL_T* mlt_buffer) - ICODE_ATTR_COOK_DECODE; -static void decode_vectors(COOKContext* q, int* category, - int *quant_index_table, REAL_T* mlt_buffer){ - /* A zero in this table means that the subband coefficient is - random noise coded. */ - int subband_coef_index[SUBBAND_SIZE]; - /* A zero in this table means that the subband coefficient is a - positive multiplicator. */ - int subband_coef_sign[SUBBAND_SIZE]; - int band, j; - int index=0; - - for(band=0 ; bandtotal_subbands ; band++){ - index = category[band]; - if(category[band] < 7){ - if(unpack_SQVH(q, category[band], subband_coef_index, subband_coef_sign)){ - index=7; - for(j=0 ; jtotal_subbands ; j++) category[band+j]=7; - } - } - if(index>=7) { - memset(subband_coef_index, 0, sizeof(subband_coef_index)); - memset(subband_coef_sign, 0, sizeof(subband_coef_sign)); - } - scalar_dequant_math(q, index, quant_index_table[band], - subband_coef_index, subband_coef_sign, - &mlt_buffer[band * SUBBAND_SIZE]); - } - - if(q->total_subbands*SUBBAND_SIZE >= q->samples_per_channel){ - return; - } /* FIXME: should this be removed, or moved into loop above? */ -} - - -/** - * function for decoding mono data - * - * @param q pointer to the COOKContext - * @param mlt_buffer pointer to mlt coefficients - */ - -static void mono_decode(COOKContext *q, REAL_T* mlt_buffer) ICODE_ATTR_COOK_DECODE; -static void mono_decode(COOKContext *q, REAL_T* mlt_buffer) { - - int category_index[128]; - int quant_index_table[102]; - int category[128]; - - memset(&category, 0, 128*sizeof(int)); - memset(&category_index, 0, 128*sizeof(int)); - - decode_envelope(q, quant_index_table); - q->num_vectors = get_bits(&q->gb,q->log2_numvector_size); - categorize(q, quant_index_table, category, category_index); - expand_category(q, category, category_index); - decode_vectors(q, category, quant_index_table, mlt_buffer); -} - -/** - * function for getting the jointstereo coupling information - * - * @param q pointer to the COOKContext - * @param decouple_tab decoupling array - * - */ - -static void decouple_info(COOKContext *q, int* decouple_tab){ - int length, i; - - if(get_bits1(&q->gb)) { - if(cplband[q->js_subband_start] > cplband[q->subbands-1]) return; - - length = cplband[q->subbands-1] - cplband[q->js_subband_start] + 1; - for (i=0 ; ijs_subband_start] + i] = get_vlc2(&q->gb, q->ccpl.table, q->ccpl.bits, 2); - } - return; - } - - if(cplband[q->js_subband_start] > cplband[q->subbands-1]) return; - - length = cplband[q->subbands-1] - cplband[q->js_subband_start] + 1; - for (i=0 ; ijs_subband_start] + i] = get_bits(&q->gb, q->js_vlc_bits); - } - return; -} - -/** - * function for decoding joint stereo data - * - * @param q pointer to the COOKContext - * @param mlt_buffer1 pointer to left channel mlt coefficients - * @param mlt_buffer2 pointer to right channel mlt coefficients - */ - -static void joint_decode(COOKContext *q, REAL_T* mlt_buffer1, - REAL_T* mlt_buffer2) { - int i; - int decouple_tab[SUBBAND_SIZE]; - REAL_T *decode_buffer = q->decode_buffer_0; - int idx; - - memset(decouple_tab, 0, sizeof(decouple_tab)); - memset(decode_buffer, 0, sizeof(q->decode_buffer_0)); - - /* Make sure the buffers are zeroed out. */ - memset(mlt_buffer1,0, 1024*sizeof(REAL_T)); - memset(mlt_buffer2,0, 1024*sizeof(REAL_T)); - decouple_info(q, decouple_tab); - mono_decode(q, decode_buffer); - - /* The two channels are stored interleaved in decode_buffer. */ - REAL_T * mlt_buffer1_end = mlt_buffer1 + (q->js_subband_start*SUBBAND_SIZE); - while(mlt_buffer1 < mlt_buffer1_end) - { - memcpy(mlt_buffer1,decode_buffer,sizeof(REAL_T)*SUBBAND_SIZE); - memcpy(mlt_buffer2,decode_buffer+20,sizeof(REAL_T)*SUBBAND_SIZE); - mlt_buffer1 += 20; - mlt_buffer2 += 20; - decode_buffer += 40; - } - - /* When we reach js_subband_start (the higher frequencies) - the coefficients are stored in a coupling scheme. */ - idx = (1 << q->js_vlc_bits) - 1; - for (i=q->js_subband_start ; isubbands ; i++) { - int i1 = decouple_tab[cplband[i]]; - int i2 = idx - i1 - 1; - mlt_buffer1_end = mlt_buffer1 + SUBBAND_SIZE; - while(mlt_buffer1 < mlt_buffer1_end) - { - *mlt_buffer1++ = cplscale_math(*decode_buffer, q->js_vlc_bits, i1); - *mlt_buffer2++ = cplscale_math(*decode_buffer++, q->js_vlc_bits, i2); - } - mlt_buffer1 += (20-SUBBAND_SIZE); - mlt_buffer2 += (20-SUBBAND_SIZE); - decode_buffer += (20-SUBBAND_SIZE); - } -} - -/** - * First part of subpacket decoding: - * decode raw stream bytes and read gain info. - * - * @param q pointer to the COOKContext - * @param inbuffer pointer to raw stream data - * @param gain_ptr array of current/prev gain pointers - */ - -#define FFSWAP(type,a,b) do{type SWAP_tmp= b; b= a; a= SWAP_tmp;}while(0) - -static inline void -decode_bytes_and_gain(COOKContext *q, const uint8_t *inbuffer, - cook_gains *gains_ptr) -{ - int offset; - - offset = decode_bytes(inbuffer, q->decoded_bytes_buffer, - q->bits_per_subpacket/8); - init_get_bits(&q->gb, q->decoded_bytes_buffer + offset, - q->bits_per_subpacket); - decode_gain_info(&q->gb, gains_ptr->now); - - /* Swap current and previous gains */ - FFSWAP(int *, gains_ptr->now, gains_ptr->previous); -} - -/** - * Final part of subpacket decoding: - * Apply modulated lapped transform, gain compensation, - * clip and convert to integer. - * - * @param q pointer to the COOKContext - * @param decode_buffer pointer to the mlt coefficients - * @param gain_ptr array of current/prev gain pointers - * @param previous_buffer pointer to the previous buffer to be used for overlapping - * @param out pointer to the output buffer - * @param chan 0: left or single channel, 1: right channel - */ - -static void -mlt_compensate_output(COOKContext *q, REAL_T *decode_buffer, - cook_gains *gains, REAL_T *previous_buffer, - int32_t *out, int chan) -{ - REAL_T *buffer = q->mono_mdct_output; - int i; - imlt_math(q, decode_buffer); - - /* Overlap with the previous block. */ - overlap_math(q, gains->previous[0], previous_buffer); - - /* Apply gain profile */ - for (i = 0; i < 8; i++) { - if (gains->now[i] || gains->now[i + 1]) - interpolate_math(q, &buffer[q->samples_per_channel/8 * i], - gains->now[i], gains->now[i + 1]); - } - - /* Save away the current to be previous block. */ - memcpy(previous_buffer, buffer+q->samples_per_channel, - sizeof(REAL_T)*q->samples_per_channel); - - /* Copy output to non-interleaved sample buffer */ - memcpy(out + (chan * q->samples_per_channel), buffer, - sizeof(REAL_T)*q->samples_per_channel); -} - - -/** - * Cook subpacket decoding. This function returns one decoded subpacket, - * usually 1024 samples per channel. - * - * @param q pointer to the COOKContext - * @param inbuffer pointer to the inbuffer - * @param sub_packet_size subpacket size - * @param outbuffer pointer to the outbuffer - */ - - -static int decode_subpacket(COOKContext *q, const uint8_t *inbuffer, - int sub_packet_size, int32_t *outbuffer) { - /* packet dump */ -// for (i=0 ; igains1); - - if (q->joint_stereo) { - joint_decode(q, q->decode_buffer_1, q->decode_buffer_2); - } else { - mono_decode(q, q->decode_buffer_1); - - if (q->nb_channels == 2) { - decode_bytes_and_gain(q, inbuffer + sub_packet_size/2, &q->gains2); - mono_decode(q, q->decode_buffer_2); - } - } - - mlt_compensate_output(q, q->decode_buffer_1, &q->gains1, - q->mono_previous_buffer1, outbuffer, 0); - - if (q->nb_channels == 2) { - if (q->joint_stereo) { - mlt_compensate_output(q, q->decode_buffer_2, &q->gains1, - q->mono_previous_buffer2, outbuffer, 1); - } else { - mlt_compensate_output(q, q->decode_buffer_2, &q->gains2, - q->mono_previous_buffer2, outbuffer, 1); - } - } - return q->samples_per_frame * sizeof(int32_t); -} - - -/** - * Cook frame decoding - * - * @param rmctx pointer to the RMContext - */ - -int cook_decode_frame(RMContext *rmctx,COOKContext *q, - int32_t *outbuffer, int *data_size, - const uint8_t *inbuffer, int buf_size) { - //COOKContext *q = avctx->priv_data; - //COOKContext *q; - - if (buf_size < rmctx->block_align) - return buf_size; - - *data_size = decode_subpacket(q, inbuffer, rmctx->block_align, outbuffer); - - /* Discard the first two frames: no valid audio. */ - if (rmctx->frame_number < 2) *data_size = 0; - - return rmctx->block_align; -} - -#ifdef COOKDEBUG -static void dump_cook_context(COOKContext *q) -{ - //int i=0; -#define PRINT(a,b) DEBUGF(" %s = %d\n", a, b); - DEBUGF("COOKextradata\n"); - DEBUGF("cookversion=%x\n",q->cookversion); - if (q->cookversion > STEREO) { - PRINT("js_subband_start",q->js_subband_start); - PRINT("js_vlc_bits",q->js_vlc_bits); - } - PRINT("nb_channels",q->nb_channels); - PRINT("bit_rate",q->bit_rate); - PRINT("sample_rate",q->sample_rate); - PRINT("samples_per_channel",q->samples_per_channel); - PRINT("samples_per_frame",q->samples_per_frame); - PRINT("subbands",q->subbands); - PRINT("random_state",q->random_state); - PRINT("js_subband_start",q->js_subband_start); - PRINT("log2_numvector_size",q->log2_numvector_size); - PRINT("numvector_size",q->numvector_size); - PRINT("total_subbands",q->total_subbands); -} -#endif - -/** - * Cook initialization - */ - -int cook_decode_init(RMContext *rmctx, COOKContext *q) -{ -#if defined(CPU_COLDFIRE) - coldfire_set_macsr(EMAC_FRACTIONAL | EMAC_SATURATE); -#endif - /* cook extradata */ - q->cookversion = rm_get_uint32be(rmctx->codec_extradata); - q->samples_per_frame = rm_get_uint16be(&rmctx->codec_extradata[4]); - q->subbands = rm_get_uint16be(&rmctx->codec_extradata[6]); - q->extradata_size = rmctx->extradata_size; - if (q->extradata_size >= 16){ - q->js_subband_start = rm_get_uint16be(&rmctx->codec_extradata[12]); - q->js_vlc_bits = rm_get_uint16be(&rmctx->codec_extradata[14]); - } - - /* Take data from the RMContext (RM container). */ - q->sample_rate = rmctx->sample_rate; - q->nb_channels = rmctx->nb_channels; - q->bit_rate = rmctx->bit_rate; - - /* Initialize RNG. */ - q->random_state = 0; - - /* Initialize extradata related variables. */ - q->samples_per_channel = q->samples_per_frame >> (q->nb_channels-1); - q->bits_per_subpacket = rmctx->block_align * 8; - - /* Initialize default data states. */ - q->log2_numvector_size = 5; - q->total_subbands = q->subbands; - - /* Initialize version-dependent variables */ - DEBUGF("q->cookversion=%x\n",q->cookversion); - q->joint_stereo = 0; - switch (q->cookversion) { - case MONO: - if (q->nb_channels != 1) { - DEBUGF("Container channels != 1, report sample!\n"); - return -1; - } - DEBUGF("MONO\n"); - break; - case STEREO: - if (q->nb_channels != 1) { - q->bits_per_subpacket = q->bits_per_subpacket/2; - } - DEBUGF("STEREO\n"); - break; - case JOINT_STEREO: - if (q->nb_channels != 2) { - DEBUGF("Container channels != 2, report sample!\n"); - return -1; - } - DEBUGF("JOINT_STEREO\n"); - if (q->extradata_size >= 16){ - q->total_subbands = q->subbands + q->js_subband_start; - q->joint_stereo = 1; - } - if (q->samples_per_channel > 256) { - q->log2_numvector_size = 6; - } - if (q->samples_per_channel > 512) { - q->log2_numvector_size = 7; - } - break; - case MC_COOK: - DEBUGF("MC_COOK not supported!\n"); - return -1; - break; - default: - DEBUGF("Unknown Cook version, report sample!\n"); - return -1; - break; - } - - /* Initialize variable relations */ - q->numvector_size = (1 << q->log2_numvector_size); - q->mdct_nbits = av_log2(q->samples_per_channel)+1; - - /* Generate tables */ - if (init_cook_vlc_tables(q) != 0) - return -1; - - - if(rmctx->block_align >= UINT16_MAX/2) - return -1; - - q->gains1.now = q->gain_1; - q->gains1.previous = q->gain_2; - q->gains2.now = q->gain_3; - q->gains2.previous = q->gain_4; - - - /* Initialize COOK signal arithmetic handling */ - /* - if (1) { - q->scalar_dequant = scalar_dequant_math; - q->interpolate = interpolate_math; - } - */ - - /* Try to catch some obviously faulty streams, othervise it might be exploitable */ - if (q->total_subbands > 53) { - DEBUGF("total_subbands > 53, report sample!\n"); - return -1; - } - if (q->subbands > 50) { - DEBUGF("subbands > 50, report sample!\n"); - return -1; - } - if ((q->samples_per_channel == 256) || (q->samples_per_channel == 512) || (q->samples_per_channel == 1024)) { - } else { - DEBUGF("unknown amount of samples_per_channel = %d, report sample!\n",q->samples_per_channel); - return -1; - } - if ((q->js_vlc_bits > 6) || (q->js_vlc_bits < 0)) { - DEBUGF("q->js_vlc_bits = %d, only >= 0 and <= 6 allowed!\n",q->js_vlc_bits); - return -1; - } - - -#ifdef COOKDEBUG - dump_cook_context(q); -#endif - return 0; -} - diff --git a/apps/codecs/libcook/cook.h b/apps/codecs/libcook/cook.h deleted file mode 100644 index fcb437a0e1..0000000000 --- a/apps/codecs/libcook/cook.h +++ /dev/null @@ -1,131 +0,0 @@ -/* - * COOK compatible decoder - * Copyright (c) 2003 Sascha Sommer - * Copyright (c) 2005 Benjamin Larsson - * - * This file is taken from FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ -#ifndef _COOK_H -#define _COOK_H - -#include -#include "ffmpeg_get_bits.h" -#include "../librm/rm.h" -#include "cookdata_fixpoint.h" - -#include "codeclib.h" - -#if (CONFIG_CPU == PP5022) || (CONFIG_CPU == PP5024) || (CONFIG_CPU == MCF5250) -/* PP5022/24, MCF5250 have large IRAM */ -#define IBSS_ATTR_COOK_LARGE_IRAM IBSS_ATTR -#define ICODE_ATTR_COOK_LARGE_IRAM ICODE_ATTR -#define ICONST_ATTR_COOK_LARGE_IRAM ICONST_ATTR -#define IBSS_ATTR_COOK_VLCBUF -#define ICODE_ATTR_COOK_DECODE - -#elif defined(CPU_S5L870X) -/* S5L870X have even larger IRAM and it is faster to use ICODE_ATTR. */ -#define IBSS_ATTR_COOK_LARGE_IRAM IBSS_ATTR -#define ICODE_ATTR_COOK_LARGE_IRAM ICODE_ATTR -#define ICONST_ATTR_COOK_LARGE_IRAM ICONST_ATTR -#define IBSS_ATTR_COOK_VLCBUF IBSS_ATTR -#define ICODE_ATTR_COOK_DECODE ICODE_ATTR - -#else -/* other CPUs IRAM is not large enough */ -#define IBSS_ATTR_COOK_LARGE_IRAM -#define ICODE_ATTR_COOK_LARGE_IRAM -#define ICONST_ATTR_COOK_LARGE_IRAM -#define IBSS_ATTR_COOK_VLCBUF -#define ICODE_ATTR_COOK_DECODE - -#endif - -typedef struct { - int *now; - int *previous; -} cook_gains; - -typedef struct cook { - /* - * The following 2 functions provide the lowlevel arithmetic on - * the internal audio buffers. - */ - void (* scalar_dequant)(struct cook *q, int index, int quant_index, - int* subband_coef_index, int* subband_coef_sign, - REAL_T* mlt_p); - - void (* interpolate) (struct cook *q, REAL_T* buffer, - int gain_index, int gain_index_next); - - GetBitContext gb; - int frame_number; - int block_align; - int extradata_size; - /* stream data */ - int nb_channels; - int joint_stereo; - int bit_rate; - int sample_rate; - int samples_per_channel; - int samples_per_frame; - int subbands; - int log2_numvector_size; - int numvector_size; //1 << log2_numvector_size; - int js_subband_start; - int total_subbands; - int num_vectors; - int bits_per_subpacket; - int cookversion; - int mdct_nbits; /* is this the same as one of above? */ - /* states */ - int random_state; - - /* gain buffers */ - cook_gains gains1; - cook_gains gains2; - int gain_1[9]; - int gain_2[9]; - int gain_3[9]; - int gain_4[9]; - - /* VLC data */ - int js_vlc_bits; - VLC envelope_quant_index[13]; - VLC sqvh[7]; //scalar quantization - VLC ccpl; //channel coupling - - /* generatable tables and related variables */ - int gain_size_factor; - - /* data buffers */ - - uint8_t decoded_bytes_buffer[1024] MEM_ALIGN_ATTR; - REAL_T mono_mdct_output[2048] MEM_ALIGN_ATTR; - REAL_T mono_previous_buffer1[1024] MEM_ALIGN_ATTR; - REAL_T mono_previous_buffer2[1024] MEM_ALIGN_ATTR; - REAL_T decode_buffer_1[1024] MEM_ALIGN_ATTR; - REAL_T decode_buffer_2[1024] MEM_ALIGN_ATTR; - /* static allocation for joint decode */ - REAL_T decode_buffer_0[1060] MEM_ALIGN_ATTR; -} COOKContext; - -int cook_decode_init(RMContext *rmctx, COOKContext *q); -int cook_decode_frame(RMContext *rmctx,COOKContext *q, - int32_t *outbuffer, int *data_size, - const uint8_t *inbuffer, int buf_size); -#endif /*_COOK_H */ diff --git a/apps/codecs/libcook/cook_fixpoint.h b/apps/codecs/libcook/cook_fixpoint.h deleted file mode 100644 index 5c4a5d1a5a..0000000000 --- a/apps/codecs/libcook/cook_fixpoint.h +++ /dev/null @@ -1,278 +0,0 @@ -/* - * COOK compatible decoder, fixed point implementation. - * Copyright (c) 2007 Ian Braithwaite - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -/** - * @file cook_fixpoint.h - * - * Cook AKA RealAudio G2 fixed point functions. - * - * Fixed point values are represented as 32 bit signed integers, - * which can be added and subtracted directly in C (without checks for - * overflow/saturation. - * Two multiplication routines are provided: - * 1) Multiplication by powers of two (2^-31 .. 2^31), implemented - * with C's bit shift operations. - * 2) Multiplication by 16 bit fractions (0 <= x < 1), implemented - * in C using two 32 bit integer multiplications. - */ - -#ifdef ROCKBOX -/* get definitions of MULT31, MULT31_SHIFT16, vect_add, from codelib */ -#include "codeclib_misc.h" -#include "codeclib.h" -#endif - -/* cplscales was moved from cookdata_fixpoint.h since only * - * cook_fixpoint.h should see/use it. */ -static const FIXPU* cplscales[5] = { - cplscale2, cplscale3, cplscale4, cplscale5, cplscale6 -}; - -/** - * Fixed point multiply by power of two. - * - * @param x fix point value - * @param i integer power-of-two, -31..+31 - */ -static inline FIXP fixp_pow2(FIXP x, int i) -{ - if (i < 0) - return (x >> -i); - else - return x << i; /* no check for overflow */ -} - -/** - * Fixed point multiply by fraction. - * - * @param a fix point value - * @param b fix point fraction, 0 <= b < 1 - */ -#ifdef ROCKBOX -#define fixp_mult_su(x,y) (MULT31_SHIFT16(x,y)) -#else -static inline FIXP fixp_mult_su(FIXP a, FIXPU b) -{ - int32_t hb = (a >> 16) * b; - uint32_t lb = (a & 0xffff) * b; - - return hb + (lb >> 16) + ((lb & 0x8000) >> 15); -} -#endif - -/* Faster version of the above using 32x32=64 bit multiply */ -#ifdef ROCKBOX -#define fixmul31(x,y) (MULT31(x,y)) -#else -static inline int32_t fixmul31(int32_t x, int32_t y) -{ - int64_t temp; - - temp = x; - temp *= y; - - temp >>= 31; //16+31-16 = 31 bits - - return (int32_t)temp; -} -#endif - -/** - * Clips a signed integer value into the amin-amax range. - * @param a value to clip - * @param amin minimum value of the clip range - * @param amax maximum value of the clip range - * @return clipped value - */ -static inline int av_clip(int a, int amin, int amax) -{ - if (a < amin) return amin; - else if (a > amax) return amax; - else return a; -} - -/** - * The real requantization of the mltcoefs - * - * @param q pointer to the COOKContext - * @param index index - * @param quant_index quantisation index for this band - * @param subband_coef_index array of indexes to quant_centroid_tab - * @param subband_coef_sign use random noise instead of predetermined value - * @param mlt_ptr pointer to the mlt coefficients - */ - -static void scalar_dequant_math(COOKContext *q, int index, - int quant_index, int* subband_coef_index, - int* subband_coef_sign, REAL_T *mlt_p) - ICODE_ATTR_COOK_DECODE; -static void scalar_dequant_math(COOKContext *q, int index, - int quant_index, int* subband_coef_index, - int* subband_coef_sign, REAL_T *mlt_p) -{ - /* Num. half bits to right shift */ - const int s = 33 - quant_index + av_log2(q->samples_per_channel); - const FIXP *table = quant_tables[s & 1][index]; - FIXP f; - int i; - - - if(s >= 64) - memset(mlt_p, 0, sizeof(REAL_T)*SUBBAND_SIZE); - else - { - for(i=0 ; i> (s >> 1); - /* noise coding if subband_coef_index[i] == 0 */ - if (((subband_coef_index[i] == 0) && cook_random(q)) || - ((subband_coef_index[i] != 0) && subband_coef_sign[i])) - f = -f; - - *mlt_p++ = f; - } - } -} - -/** - * The modulated lapped transform, this takes transform coefficients - * and transforms them into timedomain samples. - * A window step is also included. - * - * @param q pointer to the COOKContext - * @param inbuffer pointer to the mltcoefficients - * @param outbuffer pointer to the timedomain buffer - * @param mlt_tmp pointer to temporary storage space - */ -#include "../lib/mdct_lookup.h" - -void imlt_math(COOKContext *q, FIXP *in) ICODE_ATTR; -void imlt_math(COOKContext *q, FIXP *in) -{ - const int n = q->samples_per_channel; - const int step = 2 << (10 - av_log2(n)); - REAL_T *mdct_out = q->mono_mdct_output; - REAL_T tmp; - int i = 0, j = 0; - - ff_imdct_calc(q->mdct_nbits, q->mono_mdct_output, in); - - do { - tmp = mdct_out[i]; - mdct_out[i ] = fixmul31(-mdct_out[n+i], (sincos_lookup0[j ])); - mdct_out[n+i] = fixmul31(tmp , (sincos_lookup0[j+1])); - - j += step; - } while (++i < n/2); - - do { - j -= step; - - tmp = mdct_out[i]; - mdct_out[i ] = fixmul31(-mdct_out[n+i], (sincos_lookup0[j+1])); - mdct_out[n+i] = fixmul31(tmp , (sincos_lookup0[j ])); - } while (++i < n); -} - -/** - * Perform buffer overlapping. - * - * @param q pointer to the COOKContext - * @param gain gain correction to apply first to output buffer - * @param buffer data to overlap - */ -void overlap_math(COOKContext *q, int gain, FIXP buffer[]) ICODE_ATTR; -void overlap_math(COOKContext *q, int gain, FIXP buffer[]) -{ - int i; -#ifdef ROCKBOX - if(LIKELY(gain == 0)) - { - vect_add(q->mono_mdct_output, buffer, q->samples_per_channel); - - } else if (gain > 0){ - for(i=0 ; isamples_per_channel ; i++) { - q->mono_mdct_output[i] = (q->mono_mdct_output[i]<< gain) + buffer[i]; } - - } else { - for(i=0 ; isamples_per_channel ; i++) { - q->mono_mdct_output[i] = (q->mono_mdct_output[i]>>-gain) + buffer[i]; - } - } -#else - for(i=0 ; isamples_per_channel ; i++) { - q->mono_mdct_output[i] = - fixp_pow2(q->mono_mdct_output[i], gain) + buffer[i]; - } -#endif -} - - -/** - * the actual requantization of the timedomain samples - * - * @param q pointer to the COOKContext - * @param buffer pointer to the timedomain buffer - * @param gain_index index for the block multiplier - * @param gain_index_next index for the next block multiplier - */ -static inline void -interpolate_math(COOKContext *q, register FIXP* buffer, - int gain_index, int gain_index_next) -{ - int i; - int gain_size_factor = q->samples_per_channel / 8; - - if(gain_index == gain_index_next){ //static gain - for(i = 0; i < gain_size_factor; i++) { - buffer[i] = fixp_pow2(buffer[i], gain_index); - } - } else { //smooth gain - int step = (gain_index_next - gain_index) - << (7 - av_log2(gain_size_factor)); - int x = 0; - register FIXP* bufferend = buffer+gain_size_factor; - while(buffer < bufferend ) - { - *buffer = fixp_pow2( - fixp_mult_su(*buffer, pow128_tab[x]), - gain_index+1); - buffer++; - - x += step; - gain_index += ( (x + 128) >> 7 ) - 1; - x = ( (x + 128) & 127 ); - } - } -} - - -/** - * Decoupling calculation for joint stereo coefficients. - * - * @param x mono coefficient - * @param table number of decoupling table - * @param i table index - */ -static inline FIXP cplscale_math(FIXP x, int table, int i) -{ - return fixp_mult_su(x, cplscales[table-2][i]); -} diff --git a/apps/codecs/libcook/cookdata.h b/apps/codecs/libcook/cookdata.h deleted file mode 100644 index a73b96c5f5..0000000000 --- a/apps/codecs/libcook/cookdata.h +++ /dev/null @@ -1,493 +0,0 @@ -/* - * COOK compatible decoder data - * Copyright (c) 2003 Sascha Sommer - * Copyright (c) 2005 Benjamin Larsson - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -/** - * @file cookdata.h - * Cook AKA RealAudio G2 compatible decoderdata - */ - -/* various data tables */ - -static const int expbits_tab[8] = { - 52,47,43,37,29,22,16,0, -}; - -static const int invradix_tab[7] = { - 74899, 104858, 149797, 209716, 262144, 349526, 524288, -}; - -static const int kmax_tab[7] = { - 13, 9, 6, 4, 3, 2, 1, -}; - -static const int vd_tab[7] = { - 2, 2, 2, 4, 4, 5, 5, -}; - -static const int vpr_tab[7] = { - 10, 10, 10, 5, 5, 4, 4, -}; - - - -/* VLC data */ - -static const int vhsize_tab[7] = { - 191, 97, 48, 607, 246, 230, 32, -}; - -static const int vhvlcsize_tab[7] = { - 8, 7, 7, 10, 9, 9, 6, -}; - -static const uint8_t envelope_quant_index_huffbits[13][24] = { - { 4, 6, 5, 5, 4, 4, 4, 4, 4, 4, 3, 3, 3, 4, 5, 7, 8, 9, 11, 11, 12, 12, 12, 12 }, - { 10, 8, 6, 5, 5, 4, 3, 3, 3, 3, 3, 3, 4, 5, 7, 9, 11, 12, 13, 15, 15, 15, 16, 16 }, - { 12, 10, 8, 6, 5, 4, 4, 4, 4, 4, 4, 3, 3, 3, 4, 4, 5, 5, 7, 9, 11, 13, 14, 14 }, - { 13, 10, 9, 9, 7, 7, 5, 5, 4, 3, 3, 3, 3, 3, 4, 4, 4, 5, 7, 9, 11, 13, 13, 13 }, - { 12, 13, 10, 8, 6, 6, 5, 5, 4, 4, 3, 3, 3, 3, 3, 4, 5, 5, 6, 7, 9, 11, 14, 14 }, - { 12, 11, 9, 8, 8, 7, 5, 4, 4, 3, 3, 3, 3, 3, 4, 4, 5, 5, 7, 8, 10, 13, 14, 14 }, - { 15, 16, 15, 12, 10, 8, 6, 5, 4, 3, 3, 3, 2, 3, 4, 5, 5, 7, 9, 11, 13, 16, 16, 16 }, - { 14, 14, 11, 10, 9, 7, 7, 5, 5, 4, 3, 3, 2, 3, 3, 4, 5, 7, 9, 9, 12, 14, 15, 15 }, - { 9, 9, 9, 8, 7, 6, 5, 4, 3, 3, 3, 3, 3, 3, 4, 5, 6, 7, 8, 10, 11, 12, 13, 13 }, - { 14, 12, 10, 8, 6, 6, 5, 4, 3, 3, 3, 3, 3, 3, 4, 5, 6, 8, 8, 9, 11, 14, 14, 14 }, - { 13, 10, 9, 8, 6, 6, 5, 4, 4, 4, 3, 3, 2, 3, 4, 5, 6, 8, 9, 9, 11, 12, 14, 14 }, - { 16, 13, 12, 11, 9, 6, 5, 5, 4, 4, 4, 3, 2, 3, 3, 4, 5, 7, 8, 10, 14, 16, 16, 16 }, - { 13, 14, 14, 14, 10, 8, 7, 7, 5, 4, 3, 3, 2, 3, 3, 4, 5, 5, 7, 9, 11, 14, 14, 14 }, -}; - -static const uint16_t envelope_quant_index_huffcodes[13][24] = { - {0x0006, 0x003e, 0x001c, 0x001d, 0x0007, 0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x0000, 0x0001, - 0x0002, 0x000d, 0x001e, 0x007e, 0x00fe, 0x01fe, 0x07fc, 0x07fd, 0x0ffc, 0x0ffd, 0x0ffe, 0x0fff}, - {0x03fe, 0x00fe, 0x003e, 0x001c, 0x001d, 0x000c, 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, - 0x000d, 0x001e, 0x007e, 0x01fe, 0x07fe, 0x0ffe, 0x1ffe, 0x7ffc, 0x7ffd, 0x7ffe, 0xfffe, 0xffff}, - {0x0ffe, 0x03fe, 0x00fe, 0x003e, 0x001c, 0x0006, 0x0007, 0x0008, 0x0009, 0x000a, 0x000b, 0x0000, - 0x0001, 0x0002, 0x000c, 0x000d, 0x001d, 0x001e, 0x007e, 0x01fe, 0x07fe, 0x1ffe, 0x3ffe, 0x3fff}, - {0x1ffc, 0x03fe, 0x01fc, 0x01fd, 0x007c, 0x007d, 0x001c, 0x001d, 0x000a, 0x0000, 0x0001, 0x0002, - 0x0003, 0x0004, 0x000b, 0x000c, 0x000d, 0x001e, 0x007e, 0x01fe, 0x07fe, 0x1ffd, 0x1ffe, 0x1fff}, - {0x0ffe, 0x1ffe, 0x03fe, 0x00fe, 0x003c, 0x003d, 0x001a, 0x001b, 0x000a, 0x000b, 0x0000, 0x0001, - 0x0002, 0x0003, 0x0004, 0x000c, 0x001c, 0x001d, 0x003e, 0x007e, 0x01fe, 0x07fe, 0x3ffe, 0x3fff}, - {0x0ffe, 0x07fe, 0x01fe, 0x00fc, 0x00fd, 0x007c, 0x001c, 0x000a, 0x000b, 0x0000, 0x0001, 0x0002, - 0x0003, 0x0004, 0x000c, 0x000d, 0x001d, 0x001e, 0x007d, 0x00fe, 0x03fe, 0x1ffe, 0x3ffe, 0x3fff}, - {0x7ffc, 0xfffc, 0x7ffd, 0x0ffe, 0x03fe, 0x00fe, 0x003e, 0x001c, 0x000c, 0x0002, 0x0003, 0x0004, - 0x0000, 0x0005, 0x000d, 0x001d, 0x001e, 0x007e, 0x01fe, 0x07fe, 0x1ffe, 0xfffd, 0xfffe, 0xffff}, - {0x3ffc, 0x3ffd, 0x07fe, 0x03fe, 0x01fc, 0x007c, 0x007d, 0x001c, 0x001d, 0x000c, 0x0002, 0x0003, - 0x0000, 0x0004, 0x0005, 0x000d, 0x001e, 0x007e, 0x01fd, 0x01fe, 0x0ffe, 0x3ffe, 0x7ffe, 0x7fff}, - {0x01fc, 0x01fd, 0x01fe, 0x00fc, 0x007c, 0x003c, 0x001c, 0x000c, 0x0000, 0x0001, 0x0002, 0x0003, - 0x0004, 0x0005, 0x000d, 0x001d, 0x003d, 0x007d, 0x00fd, 0x03fe, 0x07fe, 0x0ffe, 0x1ffe, 0x1fff}, - {0x3ffc, 0x0ffe, 0x03fe, 0x00fc, 0x003c, 0x003d, 0x001c, 0x000c, 0x0000, 0x0001, 0x0002, 0x0003, - 0x0004, 0x0005, 0x000d, 0x001d, 0x003e, 0x00fd, 0x00fe, 0x01fe, 0x07fe, 0x3ffd, 0x3ffe, 0x3fff}, - {0x1ffe, 0x03fe, 0x01fc, 0x00fc, 0x003c, 0x003d, 0x001c, 0x000a, 0x000b, 0x000c, 0x0002, 0x0003, - 0x0000, 0x0004, 0x000d, 0x001d, 0x003e, 0x00fd, 0x01fd, 0x01fe, 0x07fe, 0x0ffe, 0x3ffe, 0x3fff}, - {0xfffc, 0x1ffe, 0x0ffe, 0x07fe, 0x01fe, 0x003e, 0x001c, 0x001d, 0x000a, 0x000b, 0x000c, 0x0002, - 0x0000, 0x0003, 0x0004, 0x000d, 0x001e, 0x007e, 0x00fe, 0x03fe, 0x3ffe, 0xfffd, 0xfffe, 0xffff}, - {0x1ffc, 0x3ffa, 0x3ffb, 0x3ffc, 0x03fe, 0x00fe, 0x007c, 0x007d, 0x001c, 0x000c, 0x0002, 0x0003, - 0x0000, 0x0004, 0x0005, 0x000d, 0x001d, 0x001e, 0x007e, 0x01fe, 0x07fe, 0x3ffd, 0x3ffe, 0x3fff}, -}; - - -static const uint8_t cvh_huffbits0[191] = { - 1, 4, 6, 6, 7, 7, 8, 8, 8, 9, 9, 10, - 11, 11, 4, 5, 6, 7, 7, 8, 8, 9, 9, 9, - 9, 10, 11, 11, 5, 6, 7, 8, 8, 9, 9, 9, - 9, 10, 10, 10, 11, 12, 6, 7, 8, 9, 9, 9, - 9, 10, 10, 10, 10, 11, 12, 13, 7, 7, 8, 9, - 9, 9, 10, 10, 10, 10, 11, 11, 12, 13, 8, 8, - 9, 9, 9, 10, 10, 10, 10, 11, 11, 12, 13, 14, - 8, 8, 9, 9, 10, 10, 11, 11, 11, 12, 12, 13, - 13, 15, 8, 8, 9, 9, 10, 10, 11, 11, 11, 12, - 12, 13, 14, 15, 9, 9, 9, 10, 10, 10, 11, 11, - 12, 13, 12, 14, 15, 16, 9, 9, 10, 10, 10, 10, - 11, 12, 12, 14, 14, 16, 16, 0, 9, 9, 10, 10, - 11, 11, 12, 13, 13, 14, 14, 15, 0, 0, 10, 10, - 10, 11, 11, 12, 12, 13, 15, 15, 16, 0, 0, 0, - 11, 11, 11, 12, 13, 13, 13, 15, 16, 16, 0, 0, - 0, 0, 11, 11, 12, 13, 13, 14, 15, 16, 16, -}; - -static const uint16_t cvh_huffcodes0[191] = { - 0x0000,0x0008,0x002c,0x002d,0x0062,0x0063,0x00d4,0x00d5,0x00d6,0x01c6,0x01c7,0x03ca, - 0x07d6,0x07d7,0x0009,0x0014,0x002e,0x0064,0x0065,0x00d7,0x00d8,0x01c8,0x01c9,0x01ca, - 0x01cb,0x03cb,0x07d8,0x07d9,0x0015,0x002f,0x0066,0x00d9,0x00da,0x01cc,0x01cd,0x01ce, - 0x01cf,0x03cc,0x03cd,0x03ce,0x07da,0x0fe4,0x0030,0x0067,0x00db,0x01d0,0x01d1,0x01d2, - 0x01d3,0x03cf,0x03d0,0x03d1,0x03d2,0x07db,0x0fe5,0x1fea,0x0068,0x0069,0x00dc,0x01d4, - 0x01d5,0x01d6,0x03d3,0x03d4,0x03d5,0x03d6,0x07dc,0x07dd,0x0fe6,0x1feb,0x00dd,0x00de, - 0x01d7,0x01d8,0x01d9,0x03d7,0x03d8,0x03d9,0x03da,0x07de,0x07df,0x0fe7,0x1fec,0x3ff2, - 0x00df,0x00e0,0x01da,0x01db,0x03db,0x03dc,0x07e0,0x07e1,0x07e2,0x0fe8,0x0fe9,0x1fed, - 0x1fee,0x7ff4,0x00e1,0x00e2,0x01dc,0x01dd,0x03dd,0x03de,0x07e3,0x07e4,0x07e5,0x0fea, - 0x0feb,0x1fef,0x3ff3,0x7ff5,0x01de,0x01df,0x01e0,0x03df,0x03e0,0x03e1,0x07e6,0x07e7, - 0x0fec,0x1ff0,0x0fed,0x3ff4,0x7ff6,0xfff8,0x01e1,0x01e2,0x03e2,0x03e3,0x03e4,0x03e5, - 0x07e8,0x0fee,0x0fef,0x3ff5,0x3ff6,0xfff9,0xfffa,0xfffa,0x01e3,0x01e4,0x03e6,0x03e7, - 0x07e9,0x07ea,0x0ff0,0x1ff1,0x1ff2,0x3ff7,0x3ff8,0x7ff7,0x7ff7,0xfffa,0x03e8,0x03e9, - 0x03ea,0x07eb,0x07ec,0x0ff1,0x0ff2,0x1ff3,0x7ff8,0x7ff9,0xfffb,0x3ff8,0x7ff7,0x7ff7, - 0x07ed,0x07ee,0x07ef,0x0ff3,0x1ff4,0x1ff5,0x1ff6,0x7ffa,0xfffc,0xfffd,0xfffb,0xfffb, - 0x3ff8,0x7ff7,0x07f0,0x07f1,0x0ff4,0x1ff7,0x1ff8,0x3ff9,0x7ffb,0xfffe,0xffff, -}; - - -static const uint8_t cvh_huffbits1[97] = { - 1, 4, 5, 6, 7, 8, 8, 9, 10, 10, 4, 5, - 6, 7, 7, 8, 8, 9, 9, 11, 5, 5, 6, 7, - 8, 8, 9, 9, 10, 11, 6, 6, 7, 8, 8, 9, - 9, 10, 11, 12, 7, 7, 8, 8, 9, 9, 10, 11, - 11, 13, 8, 8, 8, 9, 9, 10, 10, 11, 12, 14, - 8, 8, 8, 9, 10, 11, 11, 12, 13, 15, 9, 9, - 9, 10, 11, 12, 12, 14, 14, 0, 9, 9, 9, 10, - 11, 12, 14, 16, 0, 0, 10, 10, 11, 12, 13, 14, - 16, -}; - - -static const uint16_t cvh_huffcodes1[97] = { - 0x0000,0x0008,0x0014,0x0030,0x006a,0x00e2,0x00e3,0x01e4,0x03ec,0x03ed,0x0009,0x0015, - 0x0031,0x006b,0x006c,0x00e4,0x00e5,0x01e5,0x01e6,0x07f0,0x0016,0x0017,0x0032,0x006d, - 0x00e6,0x00e7,0x01e7,0x01e8,0x03ee,0x07f1,0x0033,0x0034,0x006e,0x00e8,0x00e9,0x01e9, - 0x01ea,0x03ef,0x07f2,0x0ff6,0x006f,0x0070,0x00ea,0x00eb,0x01eb,0x01ec,0x03f0,0x07f3, - 0x07f4,0x1ffa,0x00ec,0x00ed,0x00ee,0x01ed,0x01ee,0x03f1,0x03f2,0x07f5,0x0ff7,0x3ffa, - 0x00ef,0x00f0,0x00f1,0x01ef,0x03f3,0x07f6,0x07f7,0x0ff8,0x1ffb,0x7ffe,0x01f0,0x01f1, - 0x01f2,0x03f4,0x07f8,0x0ff9,0x0ffa,0x3ffb,0x3ffc,0x0000,0x01f3,0x01f4,0x01f5,0x03f5, - 0x07f9,0x0ffb,0x3ffd,0xfffe,0x0000,0x0000,0x03f6,0x03f7,0x07fa,0x0ffc,0x1ffc,0x3ffe, - 0xffff, -}; - -static const uint8_t cvh_huffbits2[48] = { - 1, 4, 5, 7, 8, 9, 10, 3, 4, 5, 7, 8, - 9, 10, 5, 5, 6, 7, 8, 10, 10, 7, 6, 7, - 8, 9, 10, 12, 8, 8, 8, 9, 10, 12, 14, 8, - 9, 9, 10, 11, 15, 16, 9, 10, 11, 12, 13, 16, -}; - -static const uint16_t cvh_huffcodes2[48] = { - 0x0000,0x000a,0x0018,0x0074,0x00f2,0x01f4,0x03f6,0x0004,0x000b,0x0019,0x0075,0x00f3, - 0x01f5,0x03f7,0x001a,0x001b,0x0038,0x0076,0x00f4,0x03f8,0x03f9,0x0077,0x0039,0x0078, - 0x00f5,0x01f6,0x03fa,0x0ffc,0x00f6,0x00f7,0x00f8,0x01f7,0x03fb,0x0ffd,0x3ffe,0x00f9, - 0x01f8,0x01f9,0x03fc,0x07fc,0x7ffe,0xfffe,0x01fa,0x03fd,0x07fd,0x0ffe,0x1ffe,0xffff, -}; - -static const uint8_t cvh_huffbits3[607] = { - 2, 4, 6, 8, 10, 5, 5, 6, 8, 10, 7, 8, - 8, 10, 12, 9, 9, 10, 12, 15, 10, 11, 13, 16, - 16, 5, 6, 8, 10, 11, 5, 6, 8, 10, 12, 7, - 7, 8, 10, 13, 9, 9, 10, 12, 15, 12, 11, 13, - 16, 16, 7, 9, 10, 12, 15, 7, 8, 10, 12, 13, - 9, 9, 11, 13, 16, 11, 11, 12, 14, 16, 12, 12, - 14, 16, 0, 9, 11, 12, 16, 16, 9, 10, 13, 15, - 16, 10, 11, 12, 16, 16, 13, 13, 16, 16, 16, 16, - 16, 15, 16, 0, 11, 13, 16, 16, 15, 11, 13, 15, - 16, 16, 13, 13, 16, 16, 0, 14, 16, 16, 16, 0, - 16, 16, 0, 0, 0, 4, 6, 8, 10, 13, 6, 6, - 8, 10, 13, 9, 8, 10, 12, 16, 10, 10, 11, 15, - 16, 13, 12, 14, 16, 16, 5, 6, 8, 11, 13, 6, - 6, 8, 10, 13, 8, 8, 9, 11, 14, 10, 10, 12, - 12, 16, 13, 12, 13, 15, 16, 7, 8, 9, 12, 16, - 7, 8, 10, 12, 14, 9, 9, 10, 13, 16, 11, 10, - 12, 15, 16, 13, 13, 16, 16, 0, 9, 11, 13, 16, - 16, 9, 10, 12, 15, 16, 10, 11, 13, 16, 16, 13, - 12, 16, 16, 16, 16, 16, 16, 16, 0, 11, 13, 16, - 16, 16, 11, 13, 16, 16, 16, 12, 13, 15, 16, 0, - 16, 16, 16, 16, 0, 16, 16, 0, 0, 0, 6, 8, - 11, 13, 16, 8, 8, 10, 12, 16, 11, 10, 11, 13, - 16, 12, 13, 13, 15, 16, 16, 16, 14, 16, 0, 6, - 8, 10, 13, 16, 8, 8, 10, 12, 16, 10, 10, 11, - 13, 16, 13, 12, 13, 16, 16, 14, 14, 14, 16, 0, - 8, 9, 11, 13, 16, 8, 9, 11, 16, 14, 10, 10, - 12, 15, 16, 12, 12, 13, 16, 16, 15, 16, 16, 16, - 0, 10, 12, 15, 16, 16, 10, 12, 12, 14, 16, 12, - 12, 13, 16, 16, 14, 15, 16, 16, 0, 16, 16, 16, - 0, 0, 12, 15, 15, 16, 0, 13, 13, 16, 16, 0, - 14, 16, 16, 16, 0, 16, 16, 16, 0, 0, 0, 0, - 0, 0, 0, 8, 10, 13, 15, 16, 10, 11, 13, 16, - 16, 13, 13, 14, 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 0, 8, 10, 11, 15, 16, 9, 10, 12, - 16, 16, 12, 12, 15, 16, 16, 16, 14, 16, 16, 16, - 16, 16, 16, 16, 0, 9, 11, 14, 16, 16, 10, 11, - 13, 16, 16, 14, 13, 14, 16, 16, 16, 15, 15, 16, - 0, 16, 16, 16, 0, 0, 11, 13, 16, 16, 16, 11, - 13, 15, 16, 16, 13, 16, 16, 16, 0, 16, 16, 16, - 16, 0, 16, 16, 0, 0, 0, 15, 16, 16, 16, 0, - 14, 16, 16, 16, 0, 16, 16, 16, 0, 0, 16, 16, - 0, 0, 0, 0, 0, 0, 0, 0, 9, 13, 16, 16, - 16, 11, 13, 16, 16, 16, 14, 15, 16, 16, 0, 15, - 16, 16, 16, 0, 16, 16, 0, 0, 0, 9, 13, 15, - 15, 16, 12, 13, 14, 16, 16, 16, 15, 16, 16, 0, - 16, 16, 16, 16, 0, 16, 16, 0, 0, 0, 11, 13, - 15, 16, 0, 12, 14, 16, 16, 0, 16, 16, 16, 16, - 0, 16, 16, 16, 0, 0, 0, 0, 0, 0, 0, 16, - 16, 16, 16, 0, 16, 16, 16, 16, 0, 16, 16, 16, - 0, 0, 16, 16, 0, 0, 0, 0, 0, 0, 0, 0, - 16, 16, 0, 0, 0, 16, 16, -}; - - -static const uint16_t cvh_huffcodes3[607] = { - 0x0000,0x0004,0x0022,0x00c6,0x03b0,0x000c,0x000d,0x0023,0x00c7,0x03b1,0x005c,0x00c8, - 0x00c9,0x03b2,0x0fa4,0x01c2,0x01c3,0x03b3,0x0fa5,0x7f72,0x03b4,0x07b2,0x1f9a,0xff24, - 0xff25,0x000e,0x0024,0x00ca,0x03b5,0x07b3,0x000f,0x0025,0x00cb,0x03b6,0x0fa6,0x005d, - 0x005e,0x00cc,0x03b7,0x1f9b,0x01c4,0x01c5,0x03b8,0x0fa7,0x7f73,0x0fa8,0x07b4,0x1f9c, - 0xff26,0xff27,0x005f,0x01c6,0x03b9,0x0fa9,0x7f74,0x0060,0x00cd,0x03ba,0x0faa,0x1f9d, - 0x01c7,0x01c8,0x07b5,0x1f9e,0xff28,0x07b6,0x07b7,0x0fab,0x3fa2,0xff29,0x0fac,0x0fad, - 0x3fa3,0xff2a,0x3fa2,0x01c9,0x07b8,0x0fae,0xff2b,0xff2c,0x01ca,0x03bb,0x1f9f,0x7f75, - 0xff2d,0x03bc,0x07b9,0x0faf,0xff2e,0xff2f,0x1fa0,0x1fa1,0xff30,0xff31,0xff32,0xff33, - 0xff34,0x7f76,0xff35,0xff31,0x07ba,0x1fa2,0xff36,0xff37,0x7f77,0x07bb,0x1fa3,0x7f78, - 0xff38,0xff39,0x1fa4,0x1fa5,0xff3a,0xff3b,0xff2e,0x3fa4,0xff3c,0xff3d,0xff3e,0xff31, - 0xff3f,0xff40,0xff30,0xff31,0xff31,0x0005,0x0026,0x00ce,0x03bd,0x1fa6,0x0027,0x0028, - 0x00cf,0x03be,0x1fa7,0x01cb,0x00d0,0x03bf,0x0fb0,0xff41,0x03c0,0x03c1,0x07bc,0x7f79, - 0xff42,0x1fa8,0x0fb1,0x3fa5,0xff43,0xff44,0x0010,0x0029,0x00d1,0x07bd,0x1fa9,0x002a, - 0x002b,0x00d2,0x03c2,0x1faa,0x00d3,0x00d4,0x01cc,0x07be,0x3fa6,0x03c3,0x03c4,0x0fb2, - 0x0fb3,0xff45,0x1fab,0x0fb4,0x1fac,0x7f7a,0xff46,0x0061,0x00d5,0x01cd,0x0fb5,0xff47, - 0x0062,0x00d6,0x03c5,0x0fb6,0x3fa7,0x01ce,0x01cf,0x03c6,0x1fad,0xff48,0x07bf,0x03c7, - 0x0fb7,0x7f7b,0xff49,0x1fae,0x1faf,0xff4a,0xff4b,0x7f7b,0x01d0,0x07c0,0x1fb0,0xff4c, - 0xff4d,0x01d1,0x03c8,0x0fb8,0x7f7c,0xff4e,0x03c9,0x07c1,0x1fb1,0xff4f,0xff50,0x1fb2, - 0x0fb9,0xff51,0xff52,0xff53,0xff54,0xff55,0xff56,0xff57,0xff52,0x07c2,0x1fb3,0xff58, - 0xff59,0xff5a,0x07c3,0x1fb4,0xff5b,0xff5c,0xff5d,0x0fba,0x1fb5,0x7f7d,0xff5e,0xff4f, - 0xff5f,0xff60,0xff61,0xff62,0xff52,0xff63,0xff64,0xff51,0xff52,0xff52,0x002c,0x00d7, - 0x07c4,0x1fb6,0xff65,0x00d8,0x00d9,0x03ca,0x0fbb,0xff66,0x07c5,0x03cb,0x07c6,0x1fb7, - 0xff67,0x0fbc,0x1fb8,0x1fb9,0x7f7e,0xff68,0xff69,0xff6a,0x3fa8,0xff6b,0x7f7e,0x002d, - 0x00da,0x03cc,0x1fba,0xff6c,0x00db,0x00dc,0x03cd,0x0fbd,0xff6d,0x03ce,0x03cf,0x07c7, - 0x1fbb,0xff6e,0x1fbc,0x0fbe,0x1fbd,0xff6f,0xff70,0x3fa9,0x3faa,0x3fab,0xff71,0xff6f, - 0x00dd,0x01d2,0x07c8,0x1fbe,0xff72,0x00de,0x01d3,0x07c9,0xff73,0x3fac,0x03d0,0x03d1, - 0x0fbf,0x7f7f,0xff74,0x0fc0,0x0fc1,0x1fbf,0xff75,0xff76,0x7f80,0xff77,0xff78,0xff79, - 0xff75,0x03d2,0x0fc2,0x7f81,0xff7a,0xff7b,0x03d3,0x0fc3,0x0fc4,0x3fad,0xff7c,0x0fc5, - 0x0fc6,0x1fc0,0xff7d,0xff7e,0x3fae,0x7f82,0xff7f,0xff80,0xff80,0xff81,0xff82,0xff83, - 0xff80,0xff80,0x0fc7,0x7f83,0x7f84,0xff84,0xff7a,0x1fc1,0x1fc2,0xff85,0xff86,0x3fad, - 0x3faf,0xff87,0xff88,0xff89,0xff7d,0xff8a,0xff8b,0xff8c,0xff80,0xff80,0x3fae,0x7f82, - 0xff7f,0xff80,0xff80,0x00df,0x03d4,0x1fc3,0x7f85,0xff8d,0x03d5,0x07ca,0x1fc4,0xff8e, - 0xff8f,0x1fc5,0x1fc6,0x3fb0,0xff90,0xff91,0xff92,0xff93,0xff94,0xff95,0xff96,0xff97, - 0xff98,0xff99,0xff9a,0xff95,0x00e0,0x03d6,0x07cb,0x7f86,0xff9b,0x01d4,0x03d7,0x0fc8, - 0xff9c,0xff9d,0x0fc9,0x0fca,0x7f87,0xff9e,0xff9f,0xffa0,0x3fb1,0xffa1,0xffa2,0xffa3, - 0xffa4,0xffa5,0xffa6,0xffa7,0xffa2,0x01d5,0x07cc,0x3fb2,0xffa8,0xffa9,0x03d8,0x07cd, - 0x1fc7,0xffaa,0xffab,0x3fb3,0x1fc8,0x3fb4,0xffac,0xffad,0xffae,0x7f88,0x7f89,0xffaf, - 0xffaf,0xffb0,0xffb1,0xffb2,0xffaf,0xffaf,0x07ce,0x1fc9,0xffb3,0xffb4,0xffb5,0x07cf, - 0x1fca,0x7f8a,0xffb6,0xffb7,0x1fcb,0xffb8,0xffb9,0xffba,0xffba,0xffbb,0xffbc,0xffbd, - 0xffbe,0xffbe,0xffbf,0xffc0,0xffbd,0xffbe,0xffbe,0x7f8b,0xffc1,0xffc2,0xffc3,0xffb4, - 0x3fb5,0xffc4,0xffc5,0xffc6,0xffb6,0xffc7,0xffc8,0xffc9,0xffba,0xffba,0xffca,0xffcb, - 0xffbd,0xffbe,0xffbe,0xffbb,0xffbc,0xffbd,0xffbe,0xffbe,0x01d6,0x1fcc,0xffcc,0xffcd, - 0xffce,0x07d0,0x1fcd,0xffcf,0xffd0,0xffd1,0x3fb6,0x7f8c,0xffd2,0xffd3,0xff90,0x7f8d, - 0xffd4,0xffd5,0xffd6,0xff95,0xffd7,0xffd8,0xff94,0xff95,0xff95,0x01d7,0x1fce,0x7f8e, - 0x7f8f,0xffd9,0x0fcb,0x1fcf,0x3fb7,0xffda,0xffdb,0xffdc,0x7f90,0xffdd,0xffde,0xff9e, - 0xffdf,0xffe0,0xffe1,0xffe2,0xffa2,0xffe3,0xffe4,0xffa1,0xffa2,0xffa2,0x07d1,0x1fd0, - 0x7f91,0xffe5,0xffa8,0x0fcc,0x3fb8,0xffe6,0xffe7,0xffaa,0xffe8,0xffe9,0xffea,0xffeb, - 0xffac,0xffec,0xffed,0xffee,0xffaf,0xffaf,0xffae,0x7f88,0x7f89,0xffaf,0xffaf,0xffef, - 0xfff0,0xfff1,0xfff2,0xffb4,0xfff3,0xfff4,0xfff5,0xfff6,0xffb6,0xfff7,0xfff8,0xfff9, - 0xffba,0xffba,0xfffa,0xfffb,0xffbd,0xffbe,0xffbe,0xffbb,0xffbc,0xffbd,0xffbe,0xffbe, - 0xfffc,0xfffd,0xffb3,0xffb4,0xffb4,0xfffe,0xffff, -}; - -static const uint8_t cvh_huffbits4[246] = { - 2, 4, 7, 10, 4, 5, 7, 10, 7, 8, 10, 14, - 11, 11, 15, 15, 4, 5, 9, 12, 5, 5, 8, 12, - 8, 7, 10, 15, 11, 11, 15, 15, 7, 9, 12, 15, - 8, 8, 12, 15, 10, 10, 13, 15, 14, 14, 15, 0, - 11, 13, 15, 15, 11, 13, 15, 15, 14, 15, 15, 0, - 15, 15, 0, 0, 4, 5, 9, 13, 5, 6, 9, 13, - 9, 9, 11, 15, 14, 13, 15, 15, 4, 6, 9, 12, - 5, 6, 9, 13, 9, 8, 11, 15, 13, 12, 15, 15, - 7, 9, 12, 15, 7, 8, 11, 15, 10, 10, 14, 15, - 14, 15, 15, 0, 10, 12, 15, 15, 11, 13, 15, 15, - 15, 15, 15, 0, 15, 15, 0, 0, 6, 9, 13, 14, - 8, 9, 12, 15, 12, 12, 15, 15, 15, 15, 15, 0, - 7, 9, 13, 15, 8, 9, 12, 15, 11, 12, 15, 15, - 15, 15, 15, 0, 9, 11, 15, 15, 9, 11, 15, 15, - 14, 14, 15, 0, 15, 15, 0, 0, 14, 15, 15, 0, - 14, 15, 15, 0, 15, 15, 0, 0, 0, 0, 0, 0, - 9, 12, 15, 15, 12, 13, 15, 15, 15, 15, 15, 0, - 15, 15, 0, 0, 10, 12, 15, 15, 12, 14, 15, 15, - 15, 15, 15, 0, 15, 15, 0, 0, 14, 15, 15, 0, - 15, 15, 15, 0, 15, 15, 0, 0, 0, 0, 0, 0, - 15, 15, 0, 0, 15, 15, -}; - - -static const uint16_t cvh_huffcodes4[246] = { - 0x0000,0x0004,0x006c,0x03e6,0x0005,0x0012,0x006d,0x03e7,0x006e,0x00e8,0x03e8,0x3fc4, - 0x07e0,0x07e1,0x7fa4,0x7fa5,0x0006,0x0013,0x01e2,0x0fda,0x0014,0x0015,0x00e9,0x0fdb, - 0x00ea,0x006f,0x03e9,0x7fa6,0x07e2,0x07e3,0x7fa7,0x7fa8,0x0070,0x01e3,0x0fdc,0x7fa9, - 0x00eb,0x00ec,0x0fdd,0x7faa,0x03ea,0x03eb,0x1fd6,0x7fab,0x3fc5,0x3fc6,0x7fac,0x1fd6, - 0x07e4,0x1fd7,0x7fad,0x7fae,0x07e5,0x1fd8,0x7faf,0x7fb0,0x3fc7,0x7fb1,0x7fb2,0x1fd6, - 0x7fb3,0x7fb4,0x1fd6,0x1fd6,0x0007,0x0016,0x01e4,0x1fd9,0x0017,0x0032,0x01e5,0x1fda, - 0x01e6,0x01e7,0x07e6,0x7fb5,0x3fc8,0x1fdb,0x7fb6,0x7fb7,0x0008,0x0033,0x01e8,0x0fde, - 0x0018,0x0034,0x01e9,0x1fdc,0x01ea,0x00ed,0x07e7,0x7fb8,0x1fdd,0x0fdf,0x7fb9,0x7fba, - 0x0071,0x01eb,0x0fe0,0x7fbb,0x0072,0x00ee,0x07e8,0x7fbc,0x03ec,0x03ed,0x3fc9,0x7fbd, - 0x3fca,0x7fbe,0x7fbf,0x3fc9,0x03ee,0x0fe1,0x7fc0,0x7fc1,0x07e9,0x1fde,0x7fc2,0x7fc3, - 0x7fc4,0x7fc5,0x7fc6,0x3fc9,0x7fc7,0x7fc8,0x3fc9,0x3fc9,0x0035,0x01ec,0x1fdf,0x3fcb, - 0x00ef,0x01ed,0x0fe2,0x7fc9,0x0fe3,0x0fe4,0x7fca,0x7fcb,0x7fcc,0x7fcd,0x7fce,0x7fca, - 0x0073,0x01ee,0x1fe0,0x7fcf,0x00f0,0x01ef,0x0fe5,0x7fd0,0x07ea,0x0fe6,0x7fd1,0x7fd2, - 0x7fd3,0x7fd4,0x7fd5,0x7fd1,0x01f0,0x07eb,0x7fd6,0x7fd7,0x01f1,0x07ec,0x7fd8,0x7fd9, - 0x3fcc,0x3fcd,0x7fda,0x7fda,0x7fdb,0x7fdc,0x7fda,0x7fda,0x3fce,0x7fdd,0x7fde,0x7fd6, - 0x3fcf,0x7fdf,0x7fe0,0x7fd8,0x7fe1,0x7fe2,0x7fda,0x7fda,0x3fcc,0x3fcd,0x7fda,0x7fda, - 0x01f2,0x0fe7,0x7fe3,0x7fe4,0x0fe8,0x1fe1,0x7fe5,0x7fe6,0x7fe7,0x7fe8,0x7fe9,0x7fca, - 0x7fea,0x7feb,0x7fca,0x7fca,0x03ef,0x0fe9,0x7fec,0x7fed,0x0fea,0x3fd0,0x7fee,0x7fef, - 0x7ff0,0x7ff1,0x7ff2,0x7fd1,0x7ff3,0x7ff4,0x7fd1,0x7fd1,0x3fd1,0x7ff5,0x7ff6,0x7fd6, - 0x7ff7,0x7ff8,0x7ff9,0x7fd8,0x7ffa,0x7ffb,0x7fda,0x7fda,0x3fcc,0x3fcd,0x7fda,0x7fda, - 0x7ffc,0x7ffd,0x7fd6,0x7fd6,0x7ffe,0x7fff, -}; - - -static const uint8_t cvh_huffbits5[230] = { - 2, 4, 8, 4, 5, 9, 9, 10, 14, 4, 6, 11, - 5, 6, 12, 10, 11, 15, 9, 11, 15, 10, 13, 15, - 14, 15, 0, 4, 6, 12, 6, 7, 12, 12, 12, 15, - 5, 7, 13, 6, 7, 13, 12, 13, 15, 10, 12, 15, - 11, 13, 15, 15, 15, 0, 8, 13, 15, 11, 12, 15, - 15, 15, 0, 10, 13, 15, 12, 15, 15, 15, 15, 0, - 15, 15, 0, 15, 15, 0, 0, 0, 0, 4, 5, 11, - 5, 7, 12, 11, 12, 15, 6, 7, 13, 7, 8, 14, - 12, 14, 15, 11, 13, 15, 12, 13, 15, 15, 15, 0, - 5, 6, 13, 7, 8, 15, 12, 14, 15, 6, 8, 14, - 7, 8, 15, 14, 15, 15, 12, 12, 15, 12, 13, 15, - 15, 15, 0, 9, 13, 15, 12, 13, 15, 15, 15, 0, - 11, 13, 15, 13, 13, 15, 15, 15, 0, 14, 15, 0, - 15, 15, 0, 0, 0, 0, 8, 10, 15, 11, 12, 15, - 15, 15, 0, 10, 12, 15, 12, 13, 15, 15, 15, 0, - 14, 15, 0, 15, 15, 0, 0, 0, 0, 8, 12, 15, - 12, 13, 15, 15, 15, 0, 11, 13, 15, 13, 15, 15, - 15, 15, 0, 15, 15, 0, 15, 15, 0, 0, 0, 0, - 14, 15, 0, 15, 15, 0, 0, 0, 0, 15, 15, 0, - 15, 15, -}; - - - -static const uint16_t cvh_huffcodes5[230] = { - 0x0000,0x0004,0x00f0,0x0005,0x0012,0x01f0,0x01f1,0x03e8,0x3fce,0x0006,0x0030,0x07de, - 0x0013,0x0031,0x0fd2,0x03e9,0x07df,0x7fb0,0x01f2,0x07e0,0x7fb1,0x03ea,0x1fd2,0x7fb2, - 0x3fcf,0x7fb3,0x0031,0x0007,0x0032,0x0fd3,0x0033,0x0070,0x0fd4,0x0fd5,0x0fd6,0x7fb4, - 0x0014,0x0071,0x1fd3,0x0034,0x0072,0x1fd4,0x0fd7,0x1fd5,0x7fb5,0x03eb,0x0fd8,0x7fb6, - 0x07e1,0x1fd6,0x7fb7,0x7fb8,0x7fb9,0x0072,0x00f1,0x1fd7,0x7fba,0x07e2,0x0fd9,0x7fbb, - 0x7fbc,0x7fbd,0x0070,0x03ec,0x1fd8,0x7fbe,0x0fda,0x7fbf,0x7fc0,0x7fc1,0x7fc2,0x0072, - 0x7fc3,0x7fc4,0x0071,0x7fc5,0x7fc6,0x0072,0x0034,0x0072,0x0072,0x0008,0x0015,0x07e3, - 0x0016,0x0073,0x0fdb,0x07e4,0x0fdc,0x7fc7,0x0035,0x0074,0x1fd9,0x0075,0x00f2,0x3fd0, - 0x0fdd,0x3fd1,0x7fc8,0x07e5,0x1fda,0x7fc9,0x0fde,0x1fdb,0x7fca,0x7fcb,0x7fcc,0x00f2, - 0x0017,0x0036,0x1fdc,0x0076,0x00f3,0x7fcd,0x0fdf,0x3fd2,0x7fce,0x0037,0x00f4,0x3fd3, - 0x0077,0x00f5,0x7fcf,0x3fd4,0x7fd0,0x7fd1,0x0fe0,0x0fe1,0x7fd2,0x0fe2,0x1fdd,0x7fd3, - 0x7fd4,0x7fd5,0x00f5,0x01f3,0x1fde,0x7fd6,0x0fe3,0x1fdf,0x7fd7,0x7fd8,0x7fd9,0x00f3, - 0x07e6,0x1fe0,0x7fda,0x1fe1,0x1fe2,0x7fdb,0x7fdc,0x7fdd,0x00f5,0x3fd5,0x7fde,0x00f4, - 0x7fdf,0x7fe0,0x00f5,0x0077,0x00f5,0x00f5,0x00f6,0x03ed,0x7fe1,0x07e7,0x0fe4,0x7fe2, - 0x7fe3,0x7fe4,0x0073,0x03ee,0x0fe5,0x7fe5,0x0fe6,0x1fe3,0x7fe6,0x7fe7,0x7fe8,0x00f2, - 0x3fd6,0x7fe9,0x0074,0x7fea,0x7feb,0x00f2,0x0075,0x00f2,0x00f2,0x00f7,0x0fe7,0x7fec, - 0x0fe8,0x1fe4,0x7fed,0x7fee,0x7fef,0x00f3,0x07e8,0x1fe5,0x7ff0,0x1fe6,0x7ff1,0x7ff2, - 0x7ff3,0x7ff4,0x00f5,0x7ff5,0x7ff6,0x00f4,0x7ff7,0x7ff8,0x00f5,0x0077,0x00f5,0x00f5, - 0x3fd7,0x7ff9,0x0036,0x7ffa,0x7ffb,0x00f3,0x0076,0x00f3,0x00f3,0x7ffc,0x7ffd,0x0000, - 0x7ffe,0x7fff, -}; - - -static const uint8_t cvh_huffbits6[32] = { - 1, 4, 4, 6, 4, 6, 6, 8, 4, 6, 6, 8, - 6, 9, 8, 10, 4, 6, 7, 8, 6, 9, 8, 11, - 6, 9, 8, 10, 8, 10, 9, 11, -}; - -static const uint16_t cvh_huffcodes6[32] = { - 0x0000,0x0008,0x0009,0x0034,0x000a,0x0035,0x0036,0x00f6,0x000b,0x0037,0x0038,0x00f7, - 0x0039,0x01fa,0x00f8,0x03fc,0x000c,0x003a,0x007a,0x00f9,0x003b,0x01fb,0x00fa,0x07fe, - 0x003c,0x01fc,0x00fb,0x03fd,0x00fc,0x03fe,0x01fd,0x07ff, -}; - -static const uint16_t* cvh_huffcodes[7] = { - cvh_huffcodes0, cvh_huffcodes1, cvh_huffcodes2, cvh_huffcodes3, - cvh_huffcodes4, cvh_huffcodes5, cvh_huffcodes6, -}; - -static const uint8_t* cvh_huffbits[7] = { - cvh_huffbits0, cvh_huffbits1, cvh_huffbits2, cvh_huffbits3, - cvh_huffbits4, cvh_huffbits5, cvh_huffbits6, -}; - - -static const uint16_t ccpl_huffcodes2[3] = { - 0x02,0x00,0x03, -}; - -static const uint16_t ccpl_huffcodes3[7] = { - 0x3e,0x1e,0x02,0x00,0x06,0x0e,0x3f, -}; - -static const uint16_t ccpl_huffcodes4[15] = { - 0xfc,0xfd,0x7c,0x3c,0x1c,0x0c,0x04,0x00,0x05,0x0d,0x1d,0x3d, - 0x7d,0xfe,0xff, -}; - -static const uint16_t ccpl_huffcodes5[31] = { - 0x03f8,0x03f9,0x03fa,0x03fb,0x01f8,0x01f9,0x00f8,0x00f9,0x0078,0x0079,0x0038,0x0039, - 0x0018,0x0019,0x0004,0x0000,0x0005,0x001a,0x001b,0x003a,0x003b,0x007a,0x007b,0x00fa, - 0x00fb,0x01fa,0x01fb,0x03fc,0x03fd,0x03fe,0x03ff, -}; - -static const uint16_t ccpl_huffcodes6[63] = { - 0x0004,0x0005,0x0005,0x0006,0x0006,0x0007,0x0007,0x0007,0x0007,0x0008,0x0008,0x0008, - 0x0008,0x0009,0x0009,0x0009,0x0009,0x000a,0x000a,0x000a,0x000a,0x000a,0x000b,0x000b, - 0x000b,0x000b,0x000c,0x000d,0x000e,0x000e,0x0010,0x0000,0x000a,0x0018,0x0019,0x0036, - 0x0037,0x0074,0x0075,0x0076,0x0077,0x00f4,0x00f5,0x00f6,0x00f7,0x01f5,0x01f6,0x01f7, - 0x01f8,0x03f6,0x03f7,0x03f8,0x03f9,0x03fa,0x07fa,0x07fb,0x07fc,0x07fd,0x0ffd,0x1ffd, - 0x3ffd,0x3ffe,0xffff, -}; - -static const uint8_t ccpl_huffbits2[3] = { - 2,1,2, -}; - -static const uint8_t ccpl_huffbits3[7] = { - 6,5,2,1,3,4,6, -}; - -static const uint8_t ccpl_huffbits4[15] = { - 8,8,7,6,5,4,3,1,3,4,5,6,7,8,8, -}; - -static const uint8_t ccpl_huffbits5[31] = { - 10,10,10,10,9,9,8,8,7,7,6,6, - 5,5,3,1,3,5,5,6,6,7,7,8, - 8,9,9,10,10,10,10, -}; - -static const uint8_t ccpl_huffbits6[63] = { - 16,15,14,13,12,11,11,11,11,10,10,10, - 10,9,9,9,9,9,8,8,8,8,7,7, - 7,7,6,6,5,5,3,1,4,5,5,6, - 6,7,7,7,7,8,8,8,8,9,9,9, - 9,10,10,10,10,10,11,11,11,11,12,13, - 14,14,16, -}; - -static const uint16_t* ccpl_huffcodes[5] = { - ccpl_huffcodes2,ccpl_huffcodes3, - ccpl_huffcodes4,ccpl_huffcodes5,ccpl_huffcodes6 -}; - -static const uint8_t* ccpl_huffbits[5] = { - ccpl_huffbits2,ccpl_huffbits3, - ccpl_huffbits4,ccpl_huffbits5,ccpl_huffbits6 -}; - - -//Coupling tables - -static const int cplband[51] = { - 0,1,2,3,4,5,6,7,8,9, - 10,11,11,12,12,13,13,14,14,14, - 15,15,15,15,16,16,16,16,16,17, - 17,17,17,17,17,18,18,18,18,18, - 18,18,19,19,19,19,19,19,19,19, - 19, -}; diff --git a/apps/codecs/libcook/cookdata_fixpoint.h b/apps/codecs/libcook/cookdata_fixpoint.h deleted file mode 100644 index b58666031d..0000000000 --- a/apps/codecs/libcook/cookdata_fixpoint.h +++ /dev/null @@ -1,164 +0,0 @@ -/* - * COOK compatible decoder fixed point data types and constants - * Copyright (c) 2007 Ian Braithwaite - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -/** - * @file cookdata_fixpoint.h - * Cook AKA RealAudio G2 compatible decoder - * fixed point data types and constants - */ - -#include -typedef int32_t FIXP; /* Fixed point variable type */ -typedef uint16_t FIXPU; /* Fixed point fraction 0<=x<1 */ - -typedef FIXP REAL_T; - - -/* No additional variables in COOKContext - * for fixed point routines - */ -typedef struct { -} realvars_t; - -static const FIXPU pow128_tab[128] = { - /* x_i = 2^(15+i/128) */ - 0x8000, 0x80b2, 0x8165, 0x8219, 0x82ce, 0x8383, 0x843a, 0x84f2, 0x85ab, - 0x8665, 0x871f, 0x87db, 0x8898, 0x8956, 0x8a15, 0x8ad5, 0x8b96, 0x8c58, - 0x8d1b, 0x8ddf, 0x8ea4, 0x8f6b, 0x9032, 0x90fa, 0x91c4, 0x928e, 0x935a, - 0x9427, 0x94f5, 0x95c4, 0x9694, 0x9765, 0x9838, 0x990c, 0x99e0, 0x9ab6, - 0x9b8d, 0x9c65, 0x9d3f, 0x9e19, 0x9ef5, 0x9fd2, 0xa0b0, 0xa190, 0xa270, - 0xa352, 0xa435, 0xa519, 0xa5ff, 0xa6e6, 0xa7ce, 0xa8b7, 0xa9a1, 0xaa8d, - 0xab7a, 0xac69, 0xad58, 0xae49, 0xaf3b, 0xb02f, 0xb124, 0xb21a, 0xb312, - 0xb40b, 0xb505, 0xb601, 0xb6fe, 0xb7fc, 0xb8fc, 0xb9fd, 0xbaff, 0xbc03, - 0xbd09, 0xbe0f, 0xbf18, 0xc021, 0xc12c, 0xc239, 0xc347, 0xc456, 0xc567, - 0xc67a, 0xc78d, 0xc8a3, 0xc9ba, 0xcad2, 0xcbec, 0xcd08, 0xce25, 0xcf43, - 0xd063, 0xd185, 0xd2a8, 0xd3cd, 0xd4f3, 0xd61b, 0xd745, 0xd870, 0xd99d, - 0xdacc, 0xdbfc, 0xdd2e, 0xde61, 0xdf96, 0xe0cd, 0xe205, 0xe340, 0xe47b, - 0xe5b9, 0xe6f8, 0xe839, 0xe97c, 0xeac1, 0xec07, 0xed4f, 0xee99, 0xefe5, - 0xf132, 0xf281, 0xf3d3, 0xf525, 0xf67a, 0xf7d1, 0xf929, 0xfa84, 0xfbe0, - 0xfd3e, 0xfe9e -}; - - - -/* dither_table and quant_centroid_table. - * Index 1: [0] - scaled by 2^13, [1] - scaled by 2^13 / sqrt(2) - * Index 2: [0..7] - category - * Index 3: [0] - dither_table, [1..13] - quant_centroid_table - */ -static const FIXP quant_tables[2][8][14] ICONST_ATTR = {{{ - 0x00000000, 0x0645a1cb, 0x0c2d0e56, 0x11eb851f, 0x17a1cac1, 0x1d4fdf3b, - 0x22ed9168, 0x28a7ef9e, 0x2e49ba5e, 0x33eb851f, 0x39916873, 0x3f126e98, - 0x449ba5e3, 0x4b958106 -},{ - 0x00000000, 0x08b43958, 0x10f5c28f, 0x19020c4a, 0x2116872b, 0x2922d0e5, - 0x3126e979, 0x38fdf3b6, 0x411eb852, 0x49eb851f, 0x00000000, 0x00000000, - 0x00000000, 0x00000000 -},{ - 0x00000000, 0x0bef9db2, 0x176c8b44, 0x22e147ae, 0x2e1cac08, 0x39581062, - 0x450e5604, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000 -},{ - 0x00000000, 0x10189375, 0x20000000, 0x2fe353f8, 0x3fc28f5c, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000 -},{ - 0x00000000, 0x1522d0e5, 0x2b3f7cee, 0x3fba5e35, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000 -},{ - 0x02d413cd, 0x1a83126f, 0x37db22d1, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000 -},{ - 0x04000000, 0x1f6c8b44, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000 -},{ - 0x0b504f33, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000 -}},{{ - 0x00000000, 0x046f5a70, 0x089c1768, 0x0cabddd3, 0x10b5d955, 0x14ba09ed, - 0x18b2a4b4, 0x1cbf85aa, 0x20bb05e5, 0x24b68620, 0x28b4ebcf, 0x2c994066, - 0x30835fe6, 0x35722a5e -},{ - 0x00000000, 0x062797a1, 0x0bfe1683, 0x11aeee7a, 0x1765915b, 0x1d166952, - 0x22c17660, 0x284ca76c, 0x2e0bfaaa, 0x3444f306, 0x00000000, 0x00000000, - 0x00000000, 0x00000000 -},{ - 0x00000000, 0x0870a594, 0x1090326a, 0x18a9f456, 0x209b29e3, 0x288c5f70, - 0x30d478a5, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000 -},{ - 0x00000000, 0x0b61afee, 0x16a09e66, 0x21dca76a, 0x2d15caf9, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000 -},{ - 0x00000000, 0x0ef20652, 0x1e94b968, 0x2d100010, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000 -},{ - 0x02000000, 0x12bf2f44, 0x277f041b, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000 -},{ - 0x02d413cd, 0x16385a03, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000 -},{ - 0x08000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000 -}}}; - -static const FIXPU cplscale2[3] = { - /* 2^16 C_ij */ - 0xf3f9, 0xb505, 0x4d8b -}; -static const FIXPU cplscale3[7] = { - /* 2^16 C_ij */ - 0xfb35, 0xefdf, 0xe03d, 0xb505, 0x7b81, 0x596e, 0x314d -}; -static const FIXPU cplscale4[15] = { - /* 2^16 C_ij */ - 0xfdd2, 0xf927, 0xf3f9, 0xee1d, 0xe749, 0xdee9, 0xd381, 0xb505, 0x903b, - 0x7de2, 0x6dbe, 0x5e02, 0x4d8b, 0x3ad1, 0x2155 -}; -static const FIXPU cplscale5[31] = { - /* 2^16 C_ij */ - 0xfef5, 0xfcce, 0xfa8e, 0xf832, 0xf5b5, 0xf314, 0xf049, 0xed4c, 0xea12, - 0xe68e, 0xe2ab, 0xde4b, 0xd938, 0xd30b, 0xcab6, 0xb505, 0x9c59, 0x90e8, - 0x8778, 0x7ef9, 0x76fc, 0x6f45, 0x67ab, 0x600e, 0x5850, 0x504d, 0x47db, - 0x3ebd, 0x3486, 0x2853, 0x1715 -}; -static const FIXPU cplscale6[63] = { - /* 2^16 C_ij */ - 0xff7d, 0xfe74, 0xfd65, 0xfc50, 0xfb35, 0xfa14, 0xf8eb, 0xf7bb, 0xf683, - 0xf543, 0xf3f9, 0xf2a6, 0xf148, 0xefdf, 0xee6a, 0xece6, 0xeb54, 0xe9b2, - 0xe7fd, 0xe634, 0xe453, 0xe258, 0xe03d, 0xddff, 0xdb94, 0xd8f4, 0xd610, - 0xd2d2, 0xcf13, 0xca8c, 0xc47c, 0xb505, 0xa41a, 0x9c90, 0x9685, 0x913a, - 0x8c67, 0x87e5, 0x839c, 0x7f7e, 0x7b81, 0x779b, 0x73c7, 0x6fff, 0x6c3f, - 0x6883, 0x64c7, 0x6107, 0x5d40, 0x596e, 0x558d, 0x5198, 0x4d8b, 0x495f, - 0x450d, 0x408b, 0x3bcd, 0x36c1, 0x314d, 0x2b4a, 0x246e, 0x1c1a, 0x1029 -}; - diff --git a/apps/codecs/libcook/libcook.make b/apps/codecs/libcook/libcook.make deleted file mode 100644 index c3f1c10319..0000000000 --- a/apps/codecs/libcook/libcook.make +++ /dev/null @@ -1,18 +0,0 @@ -# __________ __ ___. -# Open \______ \ ____ ____ | | _\_ |__ _______ ___ -# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / -# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < -# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ -# \/ \/ \/ \/ \/ -# $Id:$ -# - -# libcook -COOKLIB := $(CODECDIR)/libcook.a -COOKLIB_SRC := $(call preprocess, $(APPSDIR)/codecs/libcook/SOURCES) -COOKLIB_OBJ := $(call c2obj, $(COOKLIB_SRC)) -OTHER_SRC += $(COOKLIB_SRC) - -$(COOKLIB): $(COOKLIB_OBJ) - $(SILENT)$(shell rm -f $@) - $(call PRINTS,AR $(@F))$(AR) rcs $@ $^ >/dev/null diff --git a/apps/codecs/libfaad/COPYING b/apps/codecs/libfaad/COPYING deleted file mode 100644 index 920c4e6744..0000000000 --- a/apps/codecs/libfaad/COPYING +++ /dev/null @@ -1,350 +0,0 @@ - -Any non-GPL usage of this software or parts of this software is strictly -forbidden. - -Commercial non-GPL licensing of this software is possible. -For more info contact Ahead Software through Mpeg4AAClicense@nero.com. - - - - - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) 19yy - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) 19yy name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General -Public License instead of this License. diff --git a/apps/codecs/libfaad/README b/apps/codecs/libfaad/README deleted file mode 100644 index a3a3d5a833..0000000000 --- a/apps/codecs/libfaad/README +++ /dev/null @@ -1,122 +0,0 @@ - -Freeware Advanced Audio (AAC) Decoder including SBR decoding -http://www.audiocoding.com/ - -FAAD2 is a HE, LC, MAIN and LTP profile, MPEG2 and MPEG-4 AAC decoder. -FAAD2 includes code for SBR (HE AAC) decoding. -FAAD2 is licensed under the GPL. - - -__________ -COPYRIGHTS - -For FAAD2 the following license applies: - -****************************************************************************** -** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003 M. Bakker (mbakker(at)nero.com), Ahead Software AG -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -** -** Commercial non-GPL licensing of this software is also possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. -****************************************************************************** - - -Please note that the use of this software may require the payment of -patent royalties. You need to consider this issue before you start -building derivative works. We are not warranting or indemnifying you in -any way for patent royalities! YOU ARE SOLELY RESPONSIBLE FOR YOUR OWN -ACTIONS! - - -______ -PEOPLE - -FAAD2 is written by: - - M. Bakker (mbakker(at)nero.com). - - -_______________ -VERSION HISTORY - -Sorry, try building a ChangeLog from CVS. - -__________________________________ -REDISTRIBUTED OPEN SOURCE PACKAGES - -This is the list of redistributed open source packages that are included -in FAAD2: - -Name: mp4v2 -Version: 0.9.8.6 -Origin: http://www.mpeg4ip.net -Author: David Mackie -Directory: common/mp4v2 -License: MPL, Mozilla Public License, version 1.1 - -Name: mp4av -Version: 0.9.8.6 -Origin: http://www.mpeg4ip.net -Author: David Mackie -Directory: common/mp4av -License: MPL, Mozilla Public License, version 1.1 - - -___________________ -DIRECTORY STRUCTURE - -faad2 - top level directory. - - aacDECdrop - windows decoder/player with drag'n'drop functionality - - common - generally used libraries and code. - - faad - general common functions like filereading and streaming - as well as getting info from aac files. - - mp4v2 - MPEG-4 file reading library. - - mp4av - MPEG-4 file general function library. - - mp4ff - Small MP4 file format library (includes tagging abilities). - - CoreAAC - AAC DirectShow filter. - - frontend - command line frontend to the FAAD2 library, also supports - MPEG-4 file decoding. - - include - inlude file for the FAAD2 library. - - libfaad - the FAAD2 AAC decoder library including SBR. - - codebook - Huffman codebooks - - plugins - plugins for all kinds of pograms. - - in_mp4 - winamp MPEG-4 AAC file input plugin. - - QCD - Quintessential player AAC plugin. - - QCDMp4 - Quintessential player MP4 plugin. - - winamp - winamp2 AAC input plugin. - - winamp3 - winamp3 AAC input plugin. - - xmms - xmms AAC plugin - - mpeg4ip - plugin for the mpeg4ip player - diff --git a/apps/codecs/libfaad/README.rockbox b/apps/codecs/libfaad/README.rockbox deleted file mode 100644 index 5b70f231ba..0000000000 --- a/apps/codecs/libfaad/README.rockbox +++ /dev/null @@ -1,19 +0,0 @@ -Library: libfaad (FAAD2) -Imported: 2005-10-31 by Dave Chapman - -This directory contains the libfaad library from the FAAD2 project. - -LICENSING INFORMATION - -FAAD2 is licensed under the GNU General Public License and is -Copyright (C) 2003 M. Bakker (mbakker(at)nero.com), Ahead Software AG - -IMPORT DETAILS - -The decoder is based on the CVS version of libfaad from 2 February 2005. - -A non GPL compatible clause was added to the license as part of the -CVS commit on 2 February 2005 - so we are not able to use later -versions of that project in Rockbox. - - diff --git a/apps/codecs/libfaad/SOURCES b/apps/codecs/libfaad/SOURCES deleted file mode 100644 index 8447354fd3..0000000000 --- a/apps/codecs/libfaad/SOURCES +++ /dev/null @@ -1,27 +0,0 @@ -bits.c -common.c -decoder.c -drc.c -error.c -filtbank.c -huffman.c -is.c -mp4.c -ms.c -pns.c -ps_dec.c -ps_syntax.c -pulse.c -sbr_dct.c -sbr_dec.c -sbr_e_nf.c -sbr_fbt.c -sbr_hfadj.c -sbr_hfgen.c -sbr_huff.c -sbr_qmf.c -sbr_syntax.c -sbr_tf_grid.c -specrec.c -syntax.c -tns.c diff --git a/apps/codecs/libfaad/analysis.h b/apps/codecs/libfaad/analysis.h deleted file mode 100644 index f1c3da7a8f..0000000000 --- a/apps/codecs/libfaad/analysis.h +++ /dev/null @@ -1,49 +0,0 @@ -/* -** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -** -** Any non-GPL usage of this software or parts of this software is strictly -** forbidden. -** -** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. -** -** $Id$ -**/ - -#ifndef __ANALYSIS_H__ -#define __ANALYSIS_H__ - -#ifdef __cplusplus -extern "C" { -#endif - - -#ifdef ANALYSIS -#define DEBUGDEC ,uint8_t print,uint16_t var,uint8_t *dbg -#define DEBUGVAR(A,B,C) ,A,B,C -extern uint16_t dbg_count; -#else -#define DEBUGDEC -#define DEBUGVAR(A,B,C) -#endif - - -#ifdef __cplusplus -} -#endif -#endif diff --git a/apps/codecs/libfaad/bits.c b/apps/codecs/libfaad/bits.c deleted file mode 100644 index a3640077d8..0000000000 --- a/apps/codecs/libfaad/bits.c +++ /dev/null @@ -1,208 +0,0 @@ -/* -** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -** -** Any non-GPL usage of this software or parts of this software is strictly -** forbidden. -** -** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. -** -** $Id$ -**/ - -#include "common.h" -#include "structs.h" - -#include -#include -#include "bits.h" - -/* Need to be large enough to fit the largest compressed sample in a file. - * Samples were observed to need up to 1500 bytes (400 kbps nero aac). - */ -#define BUFFER_SIZE 2048 -static uint8_t static_buffer[BUFFER_SIZE] IBSS_ATTR; - -/* initialize buffer, call once before first getbits or showbits */ -void faad_initbits(bitfile *ld, const void *_buffer, const uint32_t buffer_size) -{ - uint32_t tmp; - - if (ld == NULL) - return; - - memset(ld, 0, sizeof(bitfile)); - - if (buffer_size == 0 || _buffer == NULL || (buffer_size+12)>BUFFER_SIZE) - { - ld->error = 1; - ld->no_more_reading = 1; - return; - } - - ld->buffer = &static_buffer; - memset(ld->buffer, 0, (buffer_size+12)*sizeof(uint8_t)); - memcpy(ld->buffer, _buffer, buffer_size*sizeof(uint8_t)); - - ld->buffer_size = buffer_size; - - tmp = getdword((uint32_t*)ld->buffer); - ld->bufa = tmp; - - tmp = getdword((uint32_t*)ld->buffer + 1); - ld->bufb = tmp; - - ld->start = (uint32_t*)ld->buffer; - ld->tail = ((uint32_t*)ld->buffer + 2); - - ld->bits_left = 32; - - ld->bytes_used = 0; - ld->no_more_reading = 0; - ld->error = 0; -} - -void faad_endbits(bitfile *ld) -{ -#if 0 - if (ld) - { - if (ld->buffer) - { - faad_free(ld->buffer); - ld->buffer = NULL; - } - } -#else - (void) ld; -#endif -} - -uint32_t faad_get_processed_bits(bitfile *ld) -{ - return (uint32_t)(8 * (4*(ld->tail - ld->start) - 4) - (ld->bits_left)); -} - -uint8_t faad_byte_align(bitfile *ld) -{ - uint8_t remainder = (uint8_t)((32 - ld->bits_left) % 8); - - if (remainder) - { - faad_flushbits(ld, 8 - remainder); - return (8 - remainder); - } - return 0; -} - -/* rewind to beginning */ -/* not used -void faad_rewindbits(bitfile *ld) -{ - uint32_t tmp; - - tmp = ld->start[0]; -#ifndef ARCH_IS_BIG_ENDIAN - tmp = BSWAP(tmp); -#endif - ld->bufa = tmp; - - tmp = ld->start[1]; -#ifndef ARCH_IS_BIG_ENDIAN - tmp = BSWAP(tmp); -#endif - ld->bufb = tmp; - ld->bits_left = 32; - ld->tail = &ld->start[2]; - ld->bytes_used = 0; - ld->no_more_reading = 0; -} -*/ - -#ifdef ERROR_RESILIENCE -uint8_t *faad_getbitbuffer(bitfile *ld, uint32_t bits - DEBUGDEC) -{ - uint16_t i; - uint8_t temp; - uint16_t bytes = (uint16_t)bits / 8; - uint8_t remainder = (uint8_t)bits % 8; - - uint8_t *buffer = (uint8_t*)faad_malloc((bytes+1)*sizeof(uint8_t)); - - for (i = 0; i < bytes; i++) - { - buffer[i] = (uint8_t)faad_getbits(ld, 8 DEBUGVAR(print,var,dbg)); - } - - if (remainder) - { - temp = (uint8_t)faad_getbits(ld, remainder DEBUGVAR(print,var,dbg)) << (8-remainder); - - buffer[bytes] = temp; - } - - return buffer; -} -#endif - -#ifdef DRM -/* return the original data buffer */ -void *faad_origbitbuffer(bitfile *ld) -{ - return (void*)ld->start; -} - -/* return the original data buffer size */ -uint32_t faad_origbitbuffer_size(bitfile *ld) -{ - return ld->buffer_size; -} -#endif - -/* reversed bit reading routines, used for RVLC and HCR */ -/* not used -void faad_initbits_rev(bitfile *ld, void *buffer, - uint32_t bits_in_buffer) -{ - uint32_t tmp; - int32_t index; - - ld->buffer_size = bit2byte(bits_in_buffer); - - index = (bits_in_buffer+31)/32 - 1; - - ld->start = (uint32_t*)buffer + index - 2; - - tmp = getdword((uint32_t*)buffer + index); - ld->bufa = tmp; - - tmp = getdword((uint32_t*)buffer + index - 1); - ld->bufb = tmp; - - ld->tail = (uint32_t*)buffer + index; - - ld->bits_left = bits_in_buffer % 32; - if (ld->bits_left == 0) - ld->bits_left = 32; - - ld->bytes_used = 0; - ld->no_more_reading = 0; - ld->error = 0; -} -*/ diff --git a/apps/codecs/libfaad/bits.h b/apps/codecs/libfaad/bits.h deleted file mode 100644 index f9417b8670..0000000000 --- a/apps/codecs/libfaad/bits.h +++ /dev/null @@ -1,381 +0,0 @@ -/* -** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -** -** Any non-GPL usage of this software or parts of this software is strictly -** forbidden. -** -** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. -** -** $Id$ -**/ - -#ifndef __BITS_H__ -#define __BITS_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -#include "analysis.h" -#ifdef ANALYSIS -#include -#endif - -#define BYTE_NUMBIT 8 -#define bit2byte(a) ((a+7)/BYTE_NUMBIT) - -typedef struct _bitfile -{ - /* bit input */ - uint32_t bufa; - uint32_t bufb; - uint32_t bits_left; - uint32_t buffer_size; /* size of the buffer in bytes */ - uint32_t bytes_used; - uint8_t no_more_reading; - uint8_t error; - uint32_t *tail; - uint32_t *start; - void *buffer; -} bitfile; - -/* rockbox: use asm optimized swap32() -#define BSWAP(a) \ - ((a) = ( ((a)&0xff)<<24) | (((a)&0xff00)<<8) | (((a)>>8)&0xff00) | (((a)>>24)&0xff)) -*/ -#define BSWAP(a) swap32(a) - -static uint32_t bitmask[] = { - 0x0, 0x1, 0x3, 0x7, 0xF, 0x1F, 0x3F, 0x7F, 0xFF, 0x1FF, - 0x3FF, 0x7FF, 0xFFF, 0x1FFF, 0x3FFF, 0x7FFF, 0xFFFF, - 0x1FFFF, 0x3FFFF, 0x7FFFF, 0xFFFFF, 0x1FFFFF, 0x3FFFFF, - 0x7FFFFF, 0xFFFFFF, 0x1FFFFFF, 0x3FFFFFF, 0x7FFFFFF, - 0xFFFFFFF, 0x1FFFFFFF, 0x3FFFFFFF, 0x7FFFFFFF - /* added bitmask 32, correct?!?!?! */ - , 0xFFFFFFFF -}; - -void faad_initbits(bitfile *ld, const void *buffer, const uint32_t buffer_size); -void faad_endbits(bitfile *ld); -/* not used -void faad_initbits_rev(bitfile *ld, void *buffer, - uint32_t bits_in_buffer); -*/ -uint8_t faad_byte_align(bitfile *ld); -uint32_t faad_get_processed_bits(bitfile *ld); -void faad_rewindbits(bitfile *ld); -uint8_t *faad_getbitbuffer(bitfile *ld, uint32_t bits - DEBUGDEC); -#ifdef DRM -void *faad_origbitbuffer(bitfile *ld); -uint32_t faad_origbitbuffer_size(bitfile *ld); -#endif - -static INLINE uint32_t getdword(void *mem) -{ -#ifndef ARCH_IS_BIG_ENDIAN - return BSWAP(*(uint32_t*)mem); -#else - return *(uint32_t*)mem; -#endif -} - -static INLINE void faad_flushbits_ex(bitfile *ld, uint32_t bits) -{ - uint32_t tmp; - - ld->bufa = ld->bufb; - if (ld->no_more_reading == 0) - { - tmp = getdword(ld->tail); - ld->tail++; - } else { - tmp = 0; - } - ld->bufb = tmp; - ld->bits_left += (32 - bits); - ld->bytes_used += 4; - if (ld->bytes_used == ld->buffer_size) - ld->no_more_reading = 1; - if (ld->bytes_used > ld->buffer_size) - ld->error = 1; -} - -static INLINE uint32_t faad_showbits(bitfile *ld, uint32_t bits) -{ - if (bits <= ld->bits_left) - { - return (ld->bufa >> (ld->bits_left - bits)) & bitmask[bits]; - } - - bits -= ld->bits_left; - return ((ld->bufa & bitmask[ld->bits_left]) << bits) | (ld->bufb >> (32 - bits)); -} - -static INLINE void faad_flushbits(bitfile *ld, uint32_t bits) -{ - /* do nothing if error */ - if (ld->error != 0) - return; - - if (bits < ld->bits_left) - { - ld->bits_left -= bits; - } else { - faad_flushbits_ex(ld, bits); - } -} - -/* return next n bits (right adjusted) */ -static uint32_t faad_getbits(bitfile *ld, uint32_t n DEBUGDEC) -{ - uint32_t ret; - - if (ld->no_more_reading || n == 0) - return 0; - - ret = faad_showbits(ld, n); - faad_flushbits(ld, n); - -#ifdef ANALYSIS - if (print) - fprintf(stdout, "%4d %2d bits, val: %4d, variable: %d %s\n", dbg_count++, n, ret, var, dbg); -#endif - - return ret; -} - -static INLINE uint8_t faad_get1bit(bitfile *ld DEBUGDEC) -{ - uint8_t r; - - if (ld->bits_left > 0) - { - ld->bits_left--; - r = (uint8_t)((ld->bufa >> ld->bits_left) & 1); - return r; - } - - /* bits_left == 0 */ -#if 0 - r = (uint8_t)(ld->bufb >> 31); - faad_flushbits_ex(ld, 1); -#else - r = (uint8_t)faad_getbits(ld, 1); -#endif - return r; -} - -/* reversed bitreading routines */ -static INLINE uint32_t faad_showbits_rev(bitfile *ld, uint32_t bits) -{ - uint8_t i; - uint32_t B = 0; - - if (bits <= ld->bits_left) - { - for (i = 0; i < bits; i++) - { - if (ld->bufa & (1 << (i + (32 - ld->bits_left)))) - B |= (1 << (bits - i - 1)); - } - return B; - } else { - for (i = 0; i < ld->bits_left; i++) - { - if (ld->bufa & (1 << (i + (32 - ld->bits_left)))) - B |= (1 << (bits - i - 1)); - } - for (i = 0; i < bits - ld->bits_left; i++) - { - if (ld->bufb & (1 << (i + (32-ld->bits_left)))) - B |= (1 << (bits - ld->bits_left - i - 1)); - } - return B; - } -} - -static INLINE void faad_flushbits_rev(bitfile *ld, uint32_t bits) -{ - /* do nothing if error */ - if (ld->error != 0) - return; - - if (bits < ld->bits_left) - { - ld->bits_left -= bits; - } else { - uint32_t tmp; - - ld->bufa = ld->bufb; - tmp = getdword(ld->start); - ld->bufb = tmp; - ld->start--; - ld->bits_left += (32 - bits); - - ld->bytes_used += 4; - if (ld->bytes_used == ld->buffer_size) - ld->no_more_reading = 1; - if (ld->bytes_used > ld->buffer_size) - ld->error = 1; - } -} - -static INLINE uint32_t faad_getbits_rev(bitfile *ld, uint32_t n - DEBUGDEC) -{ - uint32_t ret; - - if (ld->no_more_reading) - return 0; - - if (n == 0) - return 0; - - ret = faad_showbits_rev(ld, n); - faad_flushbits_rev(ld, n); - -#ifdef ANALYSIS - if (print) - fprintf(stdout, "%4d %2d bits, val: %4d, variable: %d %s\n", dbg_count++, n, ret, var, dbg); -#endif - - return ret; -} - -#ifdef DRM -static uint8_t faad_check_CRC(bitfile *ld, uint16_t len) -{ - uint8_t CRC; - uint16_t r=255; /* Initialize to all ones */ - - /* CRC polynome used x^8 + x^4 + x^3 + x^2 +1 */ -#define GPOLY 0435 - - faad_rewindbits(ld); - - CRC = (uint8_t) ~faad_getbits(ld, 8 - DEBUGVAR(1,999,"faad_check_CRC(): CRC")); /* CRC is stored inverted */ - - for (; len>0; len--) - { - r = ( (r << 1) ^ (( ( faad_get1bit(ld - DEBUGVAR(1,998,"")) & 1) ^ ((r >> 7) & 1)) * GPOLY )) & 0xFF; - } - - if (r != CRC) - { - return 8; - } else { - return 0; - } -} - -static uint8_t tabFlipbits[256] = { - 0,128,64,192,32,160,96,224,16,144,80,208,48,176,112,240, - 8,136,72,200,40,168,104,232,24,152,88,216,56,184,120,248, - 4,132,68,196,36,164,100,228,20,148,84,212,52,180,116,244, - 12,140,76,204,44,172,108,236,28,156,92,220,60,188,124,252, - 2,130,66,194,34,162,98,226,18,146,82,210,50,178,114,242, - 10,138,74,202,42,170,106,234,26,154,90,218,58,186,122,250, - 6,134,70,198,38,166,102,230,22,150,86,214,54,182,118,246, - 14,142,78,206,46,174,110,238,30,158,94,222,62,190,126,254, - 1,129,65,193,33,161,97,225,17,145,81,209,49,177,113,241, - 9,137,73,201,41,169,105,233,25,153,89,217,57,185,121,249, - 5,133,69,197,37,165,101,229,21,149,85,213,53,181,117,245, - 13,141,77,205,45,173,109,237,29,157,93,221,61,189,125,253, - 3,131,67,195,35,163,99,227,19,147,83,211,51,179,115,243, - 11,139,75,203,43,171,107,235,27,155,91,219,59,187,123,251, - 7,135,71,199,39,167,103,231,23,151,87,215,55,183,119,247, - 15,143,79,207,47,175,111,239,31,159,95,223,63,191,127,255 -}; -#endif - -#ifdef ERROR_RESILIENCE - -/* Modified bit reading functions for HCR */ - -typedef struct -{ - /* bit input */ - uint32_t bufa; - uint32_t bufb; - int8_t len; -} bits_t; - - -static INLINE uint32_t showbits_hcr(bits_t *ld, uint8_t bits) -{ - if (bits == 0) return 0; - if (ld->len <= 32) - { - /* huffman_spectral_data_2 needs to read more than may be available, bits maybe - > ld->len, deliver 0 than */ - if (ld->len >= bits) - return ((ld->bufa >> (ld->len - bits)) & (0xFFFFFFFF >> (32 - bits))); - else - return ((ld->bufa << (bits - ld->len)) & (0xFFFFFFFF >> (32 - bits))); - } else { - if ((ld->len - bits) < 32) - { - return ( (ld->bufb & (0xFFFFFFFF >> (64 - ld->len))) << (bits - ld->len + 32)) | - (ld->bufa >> (ld->len - bits)); - } else { - return ((ld->bufb >> (ld->len - bits - 32)) & (0xFFFFFFFF >> (32 - bits))); - } - } -} - -/* return 1 if position is outside of buffer, 0 otherwise */ -static INLINE int8_t flushbits_hcr( bits_t *ld, uint8_t bits) -{ - ld->len -= bits; - - if (ld->len <0) - { - ld->len = 0; - return 1; - } else { - return 0; - } -} - -static INLINE int8_t getbits_hcr(bits_t *ld, uint8_t n, uint32_t *result) -{ - *result = showbits_hcr(ld, n); - return flushbits_hcr(ld, n); -} - -static INLINE int8_t get1bit_hcr(bits_t *ld, uint8_t *result) -{ - uint32_t res; - int8_t ret; - - ret = getbits_hcr(ld, 1, &res); - *result = (int8_t)(res & 1); - return ret; -} - -#endif - - -#ifdef __cplusplus -} -#endif -#endif diff --git a/apps/codecs/libfaad/codebook/hcb.h b/apps/codecs/libfaad/codebook/hcb.h deleted file mode 100644 index eaefdbf437..0000000000 --- a/apps/codecs/libfaad/codebook/hcb.h +++ /dev/null @@ -1,142 +0,0 @@ -/* -** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -** -** Any non-GPL usage of this software or parts of this software is strictly -** forbidden. -** -** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. -** -** $Id$ -**/ - -#ifndef __HCB_H__ -#define __HCB_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * Optimal huffman decoding for AAC taken from: - * "SELECTING AN OPTIMAL HUFFMAN DECODER FOR AAC" by - * VLADIMIR Z. MESAROVIC , RAGHUNATH RAO, MIROSLAV V. DOKIC, and SACHIN DEO - * AES paper 5436 - * - * 2 methods are used for huffman decoding: - * - binary search - * - 2-step table lookup - * - * The choice of the "optimal" method is based on the fact that if the - * memory size for the Two-step is exorbitantly high then the decision - * is Binary search for that codebook. However, for marginally more memory - * size, if Twostep outperforms even the best case of Binary then the - * decision is Two-step for that codebook. - * - * The following methods are used for the different tables. - * codebook "optimal" method - * HCB_1 2-Step - * HCB_2 2-Step - * HCB_3 Binary - * HCB_4 2-Step - * HCB_5 Binary - * HCB_6 2-Step - * HCB_7 Binary - * HCB_8 2-Step - * HCB_9 Binary - * HCB_10 2-Step - * HCB_11 2-Step - * HCB_SF Binary - * - */ - - -#define ZERO_HCB 0 -#define FIRST_PAIR_HCB 5 -#define ESC_HCB 11 -#define QUAD_LEN 4 -#define PAIR_LEN 2 -#define NOISE_HCB 13 -#define INTENSITY_HCB2 14 -#define INTENSITY_HCB 15 - -/* 1st step table */ -typedef struct -{ - uint8_t offset; - uint8_t extra_bits; -} hcb; - -/* 2nd step table with quadruple data */ -typedef struct -{ - uint8_t bits; - int8_t x; - int8_t y; -} hcb_2_pair; - -typedef struct -{ - uint8_t bits; - int8_t x; - int8_t y; - int8_t v; - int8_t w; -} hcb_2_quad; - -/* binary search table */ -typedef struct -{ - uint8_t is_leaf; - int8_t data[4]; -} hcb_bin_quad; - -typedef struct -{ - uint8_t is_leaf; - int8_t data[2]; -} hcb_bin_pair; - -hcb *hcb_table[]; -hcb_2_quad *hcb_2_quad_table[]; -hcb_2_pair *hcb_2_pair_table[]; -hcb_bin_pair *hcb_bin_table[]; -uint8_t hcbN[]; -uint8_t unsigned_cb[]; -int hcb_2_quad_table_size[]; -int hcb_2_pair_table_size[]; -int hcb_bin_table_size[]; - -#include "codebook/hcb_1.h" -#include "codebook/hcb_2.h" -#include "codebook/hcb_3.h" -#include "codebook/hcb_4.h" -#include "codebook/hcb_5.h" -#include "codebook/hcb_6.h" -#include "codebook/hcb_7.h" -#include "codebook/hcb_8.h" -#include "codebook/hcb_9.h" -#include "codebook/hcb_10.h" -#include "codebook/hcb_11.h" -#include "codebook/hcb_sf.h" - - -#ifdef __cplusplus -} -#endif -#endif diff --git a/apps/codecs/libfaad/codebook/hcb_1.h b/apps/codecs/libfaad/codebook/hcb_1.h deleted file mode 100644 index 88c04b6012..0000000000 --- a/apps/codecs/libfaad/codebook/hcb_1.h +++ /dev/null @@ -1,183 +0,0 @@ -/* -** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -** -** Any non-GPL usage of this software or parts of this software is strictly -** forbidden. -** -** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. -** -** $Id$ -**/ - -/* 2-step huffman table HCB_1 */ - - -/* 1st step: 5 bits - * 2^5 = 32 entries - * - * Used to find offset into 2nd step table and number of extra bits to get - */ -static hcb hcb1_1[] ICONST_ATTR_FAAD_LARGE_IRAM = { - { /* 00000 */ 0, 0 }, - { /* */ 0, 0 }, - { /* */ 0, 0 }, - { /* */ 0, 0 }, - { /* */ 0, 0 }, - { /* */ 0, 0 }, - { /* */ 0, 0 }, - { /* */ 0, 0 }, - { /* */ 0, 0 }, - { /* */ 0, 0 }, - { /* */ 0, 0 }, - { /* */ 0, 0 }, - { /* */ 0, 0 }, - { /* */ 0, 0 }, - { /* */ 0, 0 }, - { /* */ 0, 0 }, - { /* 10000 */ 1, 0 }, - { /* 10001 */ 2, 0 }, - { /* 10010 */ 3, 0 }, - { /* 10011 */ 4, 0 }, - { /* 10100 */ 5, 0 }, - { /* 10101 */ 6, 0 }, - { /* 10110 */ 7, 0 }, - { /* 10111 */ 8, 0 }, - - /* 7 bit codewords */ - { /* 11000 */ 9, 2 }, - { /* 11001 */ 13, 2 }, - { /* 11010 */ 17, 2 }, - { /* 11011 */ 21, 2 }, - { /* 11100 */ 25, 2 }, - { /* 11101 */ 29, 2 }, - - /* 9 bit codewords */ - { /* 11110 */ 33, 4 }, - - /* 9/10/11 bit codewords */ - { /* 11111 */ 49, 6 } -}; - -/* 2nd step table - * - * Gives size of codeword and actual data (x,y,v,w) - */ -static hcb_2_quad hcb1_2[] ICONST_ATTR_FAAD_LARGE_IRAM = { - /* 1 bit codeword */ - { 1, 0, 0, 0, 0 }, - - /* 5 bit codewords */ - { 5, 1, 0, 0, 0 }, - { 5, -1, 0, 0, 0 }, - { 5, 0, 0, 0, -1 }, - { 5, 0, 1, 0, 0 }, - { 5, 0, 0, 0, 1 }, - { 5, 0, 0, -1, 0 }, - { 5, 0, 0, 1, 0 }, - { 5, 0, -1, 0, 0 }, - - /* 7 bit codewords */ - /* first 5 bits: 11000 */ - { 7, 1, -1, 0, 0 }, - { 7, -1, 1, 0, 0 }, - { 7, 0, 0, -1, 1 }, - { 7, 0, 1, -1, 0 }, - /* first 5 bits: 11001 */ - { 7, 0, -1, 1, 0 }, - { 7, 0, 0, 1, -1 }, - { 7, 1, 1, 0, 0 }, - { 7, 0, 0, -1, -1 }, - /* first 5 bits: 11010 */ - { 7, -1, -1, 0, 0 }, - { 7, 0, -1, -1, 0 }, - { 7, 1, 0, -1, 0 }, - { 7, 0, 1, 0, -1 }, - /* first 5 bits: 11011 */ - { 7, -1, 0, 1, 0 }, - { 7, 0, 0, 1, 1 }, - { 7, 1, 0, 1, 0 }, - { 7, 0, -1, 0, 1 }, - /* first 5 bits: 11100 */ - { 7, 0, 1, 1, 0 }, - { 7, 0, 1, 0, 1 }, - { 7, -1, 0, -1, 0 }, - { 7, 1, 0, 0, 1 }, - /* first 5 bits: 11101 */ - { 7, -1, 0, 0, -1 }, - { 7, 1, 0, 0, -1 }, - { 7, -1, 0, 0, 1 }, - { 7, 0, -1, 0, -1 }, - - /* 9 bit codeword */ - /* first 5 bits: 11110 */ - { 9, 1, 1, -1, 0 }, - { 9, -1, 1, -1, 0 }, - { 9, 1, -1, 1, 0 }, - { 9, 0, 1, 1, -1 }, - { 9, 0, 1, -1, 1 }, - { 9, 0, -1, 1, 1 }, - { 9, 0, -1, 1, -1 }, - { 9, 1, -1, -1, 0 }, - { 9, 1, 0, -1, 1 }, - { 9, 0, 1, -1, -1 }, - { 9, -1, 1, 1, 0 }, - { 9, -1, 0, 1, -1 }, - { 9, -1, -1, 1, 0 }, - { 9, 0, -1, -1, 1 }, - { 9, 1, -1, 0, 1 }, - { 9, 1, -1, 0, -1 }, - - /* 9/10/11 bit codewords */ - /* first 5 bits: 11111 */ - /* 9 bit: reading 11 bits -> 2 too much so 4 entries for each codeword */ - { 9, -1, 1, 0, -1 }, { 9, -1, 1, 0, -1 }, { 9, -1, 1, 0, -1 }, { 9, -1, 1, 0, -1 }, - { 9, -1, -1, -1, 0 }, { 9, -1, -1, -1, 0 }, { 9, -1, -1, -1, 0 }, { 9, -1, -1, -1, 0 }, - { 9, 0, -1, -1, -1 }, { 9, 0, -1, -1, -1 }, { 9, 0, -1, -1, -1 }, { 9, 0, -1, -1, -1 }, - { 9, 0, 1, 1, 1 }, { 9, 0, 1, 1, 1 }, { 9, 0, 1, 1, 1 }, { 9, 0, 1, 1, 1 }, - { 9, 1, 0, 1, -1 }, { 9, 1, 0, 1, -1 }, { 9, 1, 0, 1, -1 }, { 9, 1, 0, 1, -1 }, - { 9, 1, 1, 0, 1 }, { 9, 1, 1, 0, 1 }, { 9, 1, 1, 0, 1 }, { 9, 1, 1, 0, 1 }, - { 9, -1, 1, 0, 1 }, { 9, -1, 1, 0, 1 }, { 9, -1, 1, 0, 1 }, { 9, -1, 1, 0, 1 }, - { 9, 1, 1, 1, 0 }, { 9, 1, 1, 1, 0 }, { 9, 1, 1, 1, 0 }, { 9, 1, 1, 1, 0 }, - /* 10 bit: reading 11 bits -> 1 too much so 2 entries for each codeword */ - { 10, -1, -1, 0, 1 }, { 10, -1, -1, 0, 1 }, - { 10, -1, 0, -1, -1 }, { 10, -1, 0, -1, -1 }, - { 10, 1, 1, 0, -1 }, { 10, 1, 1, 0, -1 }, - { 10, 1, 0, -1, -1 }, { 10, 1, 0, -1, -1 }, - { 10, -1, 0, -1, 1 }, { 10, -1, 0, -1, 1 }, - { 10, -1, -1, 0, -1 }, { 10, -1, -1, 0, -1 }, - { 10, -1, 0, 1, 1 }, { 10, -1, 0, 1, 1 }, - { 10, 1, 0, 1, 1 }, { 10, 1, 0, 1, 1 }, - /* 11 bit */ - { 11, 1, -1, 1, -1 }, - { 11, -1, 1, -1, 1 }, - { 11, -1, 1, 1, -1 }, - { 11, 1, -1, -1, 1 }, - { 11, 1, 1, 1, 1 }, - { 11, -1, -1, 1, 1 }, - { 11, 1, 1, -1, -1 }, - { 11, -1, -1, 1, -1 }, - { 11, -1, -1, -1, -1 }, - { 11, 1, 1, -1, 1 }, - { 11, 1, -1, 1, 1 }, - { 11, -1, 1, 1, 1 }, - { 11, -1, 1, -1, -1 }, - { 11, -1, -1, -1, 1 }, - { 11, 1, -1, -1, -1 }, - { 11, 1, 1, 1, -1 } -}; diff --git a/apps/codecs/libfaad/codebook/hcb_10.h b/apps/codecs/libfaad/codebook/hcb_10.h deleted file mode 100644 index af48711460..0000000000 --- a/apps/codecs/libfaad/codebook/hcb_10.h +++ /dev/null @@ -1,309 +0,0 @@ -/* -** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -** -** Any non-GPL usage of this software or parts of this software is strictly -** forbidden. -** -** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. -** -** $Id$ -**/ - -/* 2-step huffman table HCB_10 */ - - -/* 1st step: 6 bits - * 2^6 = 64 entries - * - * Used to find offset into 2nd step table and number of extra bits to get - */ -static hcb hcb10_1[] ICONST_ATTR_FAAD_LARGE_IRAM = { - /* 4 bit codewords */ - { /* 000000 */ 0, 0 }, - { /* */ 0, 0 }, - { /* */ 0, 0 }, - { /* */ 0, 0 }, - { /* 000100 */ 1, 0 }, - { /* */ 1, 0 }, - { /* */ 1, 0 }, - { /* */ 1, 0 }, - { /* 001000 */ 2, 0 }, - { /* */ 2, 0 }, - { /* */ 2, 0 }, - { /* */ 2, 0 }, - /* 5 bit codewords */ - { /* 001100 */ 3, 0 }, - { /* */ 3, 0 }, - { /* 001110 */ 4, 0 }, - { /* */ 4, 0 }, - { /* 010000 */ 5, 0 }, - { /* */ 5, 0 }, - { /* 010010 */ 6, 0 }, - { /* */ 6, 0 }, - { /* 010100 */ 7, 0 }, - { /* */ 7, 0 }, - { /* 010110 */ 8, 0 }, - { /* */ 8, 0 }, - { /* 011000 */ 9, 0 }, - { /* */ 9, 0 }, - { /* 011010 */ 10, 0 }, - { /* */ 10, 0 }, - /* 6 bit codewords */ - { /* 011100 */ 11, 0 }, - { /* 011101 */ 12, 0 }, - { /* 011110 */ 13, 0 }, - { /* 011111 */ 14, 0 }, - { /* 100000 */ 15, 0 }, - { /* 100001 */ 16, 0 }, - { /* 100010 */ 17, 0 }, - { /* 100011 */ 18, 0 }, - { /* 100100 */ 19, 0 }, - { /* 100101 */ 20, 0 }, - { /* 100110 */ 21, 0 }, - { /* 100111 */ 22, 0 }, - { /* 101000 */ 23, 0 }, - { /* 101001 */ 24, 0 }, - /* 7 bit codewords */ - { /* 101010 */ 25, 1 }, - { /* 101011 */ 27, 1 }, - { /* 101100 */ 29, 1 }, - { /* 101101 */ 31, 1 }, - { /* 101110 */ 33, 1 }, - { /* 101111 */ 35, 1 }, - { /* 110000 */ 37, 1 }, - { /* 110001 */ 39, 1 }, - /* 7/8 bit codewords */ - { /* 110010 */ 41, 2 }, - /* 8 bit codewords */ - { /* 110011 */ 45, 2 }, - { /* 110100 */ 49, 2 }, - { /* 110101 */ 53, 2 }, - { /* 110110 */ 57, 2 }, - { /* 110111 */ 61, 2 }, - /* 8/9 bit codewords */ - { /* 111000 */ 65, 3 }, - /* 9 bit codewords */ - { /* 111001 */ 73, 3 }, - { /* 111010 */ 81, 3 }, - { /* 111011 */ 89, 3 }, - /* 9/10 bit codewords */ - { /* 111100 */ 97, 4 }, - /* 10 bit codewords */ - { /* 111101 */ 113, 4 }, - { /* 111110 */ 129, 4 }, - /* 10/11/12 bit codewords */ - { /* 111111 */ 145, 6 } -}; - -/* 2nd step table - * - * Gives size of codeword and actual data (x,y,v,w) - */ -static hcb_2_pair hcb10_2[] ICONST_ATTR_FAAD_LARGE_IRAM = { - /* 4 bit codewords */ - { 4, 1, 1 }, - { 4, 1, 2 }, - { 4, 2, 1 }, - - /* 5 bit codewords */ - { 5, 2, 2 }, - { 5, 1, 0 }, - { 5, 0, 1 }, - { 5, 1, 3 }, - { 5, 3, 2 }, - { 5, 3, 1 }, - { 5, 2, 3 }, - { 5, 3, 3 }, - - /* 6 bit codewords */ - { 6, 2, 0 }, - { 6, 0, 2 }, - { 6, 2, 4 }, - { 6, 4, 2 }, - { 6, 1, 4 }, - { 6, 4, 1 }, - { 6, 0, 0 }, - { 6, 4, 3 }, - { 6, 3, 4 }, - { 6, 3, 0 }, - { 6, 0, 3 }, - { 6, 4, 4 }, - { 6, 2, 5 }, - { 6, 5, 2 }, - - /* 7 bit codewords */ - { 7, 1, 5 }, - { 7, 5, 1 }, - { 7, 5, 3 }, - { 7, 3, 5 }, - { 7, 5, 4 }, - { 7, 4, 5 }, - { 7, 6, 2 }, - { 7, 2, 6 }, - { 7, 6, 3 }, - { 7, 4, 0 }, - { 7, 6, 1 }, - { 7, 0, 4 }, - { 7, 1, 6 }, - { 7, 3, 6 }, - { 7, 5, 5 }, - { 7, 6, 4 }, - - /* 7/8 bit codewords */ - { 7, 4, 6 }, { 7, 4, 6 }, - { 8, 6, 5 }, - { 8, 7, 2 }, - - /* 8 bit codewords */ - { 8, 3, 7 }, - { 8, 2, 7 }, - { 8, 5, 6 }, - { 8, 8, 2 }, - { 8, 7, 3 }, - { 8, 5, 0 }, - { 8, 7, 1 }, - { 8, 0, 5 }, - { 8, 8, 1 }, - { 8, 1, 7 }, - { 8, 8, 3 }, - { 8, 7, 4 }, - { 8, 4, 7 }, - { 8, 2, 8 }, - { 8, 6, 6 }, - { 8, 7, 5 }, - { 8, 1, 8 }, - { 8, 3, 8 }, - { 8, 8, 4 }, - { 8, 4, 8 }, - - /* 8/9 bit codewords */ - { 8, 5, 7 }, { 8, 5, 7 }, - { 8, 8, 5 }, { 8, 8, 5 }, - { 8, 5, 8 }, { 8, 5, 8 }, - { 9, 7, 6 }, - { 9, 6, 7 }, - - /* 9 bit codewords */ - { 9, 9, 2 }, - { 9, 6, 0 }, - { 9, 6, 8 }, - { 9, 9, 3 }, - { 9, 3, 9 }, - { 9, 9, 1 }, - { 9, 2, 9 }, - { 9, 0, 6 }, - { 9, 8, 6 }, - { 9, 9, 4 }, - { 9, 4, 9 }, - { 9, 10, 2 }, - { 9, 1, 9 }, - { 9, 7, 7 }, - { 9, 8, 7 }, - { 9, 9, 5 }, - { 9, 7, 8 }, - { 9, 10, 3 }, - { 9, 5, 9 }, - { 9, 10, 4 }, - { 9, 2, 10 }, - { 9, 10, 1 }, - { 9, 3, 10 }, - { 9, 9, 6 }, - - /* 9/10 bit codewords */ - { 9, 6, 9 }, { 9, 6, 9 }, - { 9, 8, 0 }, { 9, 8, 0 }, - { 9, 4, 10 }, { 9, 4, 10 }, - { 9, 7, 0 }, { 9, 7, 0 }, - { 9, 11, 2 }, { 9, 11, 2 }, - { 10, 7, 9 }, - { 10, 11, 3 }, - { 10, 10, 6 }, - { 10, 1, 10 }, - { 10, 11, 1 }, - { 10, 9, 7 }, - - /* 10 bit codewords */ - { 10, 0, 7 }, - { 10, 8, 8 }, - { 10, 10, 5 }, - { 10, 3, 11 }, - { 10, 5, 10 }, - { 10, 8, 9 }, - { 10, 11, 5 }, - { 10, 0, 8 }, - { 10, 11, 4 }, - { 10, 2, 11 }, - { 10, 7, 10 }, - { 10, 6, 10 }, - { 10, 10, 7 }, - { 10, 4, 11 }, - { 10, 1, 11 }, - { 10, 12, 2 }, - { 10, 9, 8 }, - { 10, 12, 3 }, - { 10, 11, 6 }, - { 10, 5, 11 }, - { 10, 12, 4 }, - { 10, 11, 7 }, - { 10, 12, 5 }, - { 10, 3, 12 }, - { 10, 6, 11 }, - { 10, 9, 0 }, - { 10, 10, 8 }, - { 10, 10, 0 }, - { 10, 12, 1 }, - { 10, 0, 9 }, - { 10, 4, 12 }, - { 10, 9, 9 }, - - /* 10/11/12 bit codewords */ - { 10, 12, 6 }, { 10, 12, 6 }, { 10, 12, 6 }, { 10, 12, 6 }, - { 10, 2, 12 }, { 10, 2, 12 }, { 10, 2, 12 }, { 10, 2, 12 }, - { 10, 8, 10 }, { 10, 8, 10 }, { 10, 8, 10 }, { 10, 8, 10 }, - { 11, 9, 10 }, { 11, 9, 10 }, - { 11, 1, 12 }, { 11, 1, 12 }, - { 11, 11, 8 }, { 11, 11, 8 }, - { 11, 12, 7 }, { 11, 12, 7 }, - { 11, 7, 11 }, { 11, 7, 11 }, - { 11, 5, 12 }, { 11, 5, 12 }, - { 11, 6, 12 }, { 11, 6, 12 }, - { 11, 10, 9 }, { 11, 10, 9 }, - { 11, 8, 11 }, { 11, 8, 11 }, - { 11, 12, 8 }, { 11, 12, 8 }, - { 11, 0, 10 }, { 11, 0, 10 }, - { 11, 7, 12 }, { 11, 7, 12 }, - { 11, 11, 0 }, { 11, 11, 0 }, - { 11, 10, 10 }, { 11, 10, 10 }, - { 11, 11, 9 }, { 11, 11, 9 }, - { 11, 11, 10 }, { 11, 11, 10 }, - { 11, 0, 11 }, { 11, 0, 11 }, - { 11, 11, 11 }, { 11, 11, 11 }, - { 11, 9, 11 }, { 11, 9, 11 }, - { 11, 10, 11 }, { 11, 10, 11 }, - { 11, 12, 0 }, { 11, 12, 0 }, - { 11, 8, 12 }, { 11, 8, 12 }, - { 12, 12, 9 }, - { 12, 10, 12 }, - { 12, 9, 12 }, - { 12, 11, 12 }, - { 12, 12, 11 }, - { 12, 0, 12 }, - { 12, 12, 10 }, - { 12, 12, 12 } -}; diff --git a/apps/codecs/libfaad/codebook/hcb_11.h b/apps/codecs/libfaad/codebook/hcb_11.h deleted file mode 100644 index 49e97af23f..0000000000 --- a/apps/codecs/libfaad/codebook/hcb_11.h +++ /dev/null @@ -1,412 +0,0 @@ -/* -** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -** -** Any non-GPL usage of this software or parts of this software is strictly -** forbidden. -** -** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. -** -** $Id$ -**/ - -/* 2-step huffman table HCB_11 */ - - -/* 1st step: 5 bits - * 2^5 = 32 entries - * - * Used to find offset into 2nd step table and number of extra bits to get - */ -static hcb hcb11_1[] ICONST_ATTR_FAAD_LARGE_IRAM = { - /* 4 bits */ - { /* 00000 */ 0, 0 }, - { /* */ 0, 0 }, - { /* 00010 */ 1, 0 }, - { /* */ 1, 0 }, - - /* 5 bits */ - { /* 00100 */ 2, 0 }, - { /* 00101 */ 3, 0 }, - { /* 00110 */ 4, 0 }, - { /* 00111 */ 5, 0 }, - { /* 01000 */ 6, 0 }, - { /* 01001 */ 7, 0 }, - - /* 6 bits */ - { /* 01010 */ 8, 1 }, - { /* 01011 */ 10, 1 }, - { /* 01100 */ 12, 1 }, - - /* 6/7 bits */ - { /* 01101 */ 14, 2 }, - - /* 7 bits */ - { /* 01110 */ 18, 2 }, - { /* 01111 */ 22, 2 }, - { /* 10000 */ 26, 2 }, - - /* 7/8 bits */ - { /* 10001 */ 30, 3 }, - - /* 8 bits */ - { /* 10010 */ 38, 3 }, - { /* 10011 */ 46, 3 }, - { /* 10100 */ 54, 3 }, - { /* 10101 */ 62, 3 }, - { /* 10110 */ 70, 3 }, - { /* 10111 */ 78, 3 }, - - /* 8/9 bits */ - { /* 11000 */ 86, 4 }, - - /* 9 bits */ - { /* 11001 */ 102, 4 }, - { /* 11010 */ 118, 4 }, - { /* 11011 */ 134, 4 }, - - /* 9/10 bits */ - { /* 11100 */ 150, 5 }, - - /* 10 bits */ - { /* 11101 */ 182, 5 }, - { /* 11110 */ 214, 5 }, - - /* 10/11/12 bits */ - { /* 11111 */ 246, 7 } -}; - -/* 2nd step table - * - * Gives size of codeword and actual data (x,y,v,w) - */ -static hcb_2_pair hcb11_2[] ICONST_ATTR_FAAD_LARGE_IRAM = { - /* 4 */ - { 4, 0, 0 }, - { 4, 1, 1 }, - - /* 5 */ - { 5, 16, 16 }, - { 5, 1, 0 }, - { 5, 0, 1 }, - { 5, 2, 1 }, - { 5, 1, 2 }, - { 5, 2, 2 }, - - /* 6 */ - { 6, 1, 3 }, - { 6, 3, 1 }, - { 6, 3, 2 }, - { 6, 2, 0 }, - { 6, 2, 3 }, - { 6, 0, 2 }, - - /* 6/7 */ - { 6, 3, 3 }, { 6, 3, 3 }, - { 7, 4, 1 }, - { 7, 1, 4 }, - - /* 7 */ - { 7, 4, 2 }, - { 7, 2, 4 }, - { 7, 4, 3 }, - { 7, 3, 4 }, - { 7, 3, 0 }, - { 7, 0, 3 }, - { 7, 5, 1 }, - { 7, 5, 2 }, - { 7, 2, 5 }, - { 7, 4, 4 }, - { 7, 1, 5 }, - { 7, 5, 3 }, - - /* 7/8 */ - { 7, 3, 5 }, { 7, 3, 5 }, - { 7, 5, 4 }, { 7, 5, 4 }, - { 8, 4, 5 }, - { 8, 6, 2 }, - { 8, 2, 6 }, - { 8, 6, 1 }, - - /* 8 */ - { 8, 6, 3 }, - { 8, 3, 6 }, - { 8, 1, 6 }, - { 8, 4, 16 }, - { 8, 3, 16 }, - { 8, 16, 5 }, - { 8, 16, 3 }, - { 8, 16, 4 }, - { 8, 6, 4 }, - { 8, 16, 6 }, - { 8, 4, 0 }, - { 8, 4, 6 }, - { 8, 0, 4 }, - { 8, 2, 16 }, - { 8, 5, 5 }, - { 8, 5, 16 }, - { 8, 16, 7 }, - { 8, 16, 2 }, - { 8, 16, 8 }, - { 8, 2, 7 }, - { 8, 7, 2 }, - { 8, 3, 7 }, - { 8, 6, 5 }, - { 8, 5, 6 }, - { 8, 6, 16 }, - { 8, 16, 10 }, - { 8, 7, 3 }, - { 8, 7, 1 }, - { 8, 16, 9 }, - { 8, 7, 16 }, - { 8, 1, 16 }, - { 8, 1, 7 }, - { 8, 4, 7 }, - { 8, 16, 11 }, - { 8, 7, 4 }, - { 8, 16, 12 }, - { 8, 8, 16 }, - { 8, 16, 1 }, - { 8, 6, 6 }, - { 8, 9, 16 }, - { 8, 2, 8 }, - { 8, 5, 7 }, - { 8, 10, 16 }, - { 8, 16, 13 }, - { 8, 8, 3 }, - { 8, 8, 2 }, - { 8, 3, 8 }, - { 8, 5, 0 }, - - /* 8/9 */ - { 8, 16, 14 }, { 8, 16, 14 }, - { 8, 11, 16 }, { 8, 11, 16 }, - { 8, 7, 5 }, { 8, 7, 5 }, - { 8, 4, 8 }, { 8, 4, 8 }, - { 8, 6, 7 }, { 8, 6, 7 }, - { 8, 7, 6 }, { 8, 7, 6 }, - { 8, 0, 5 }, { 8, 0, 5 }, - { 9, 8, 4 }, - { 9, 16, 15 }, - - /* 9 */ - { 9, 12, 16 }, - { 9, 1, 8 }, - { 9, 8, 1 }, - { 9, 14, 16 }, - { 9, 5, 8 }, - { 9, 13, 16 }, - { 9, 3, 9 }, - { 9, 8, 5 }, - { 9, 7, 7 }, - { 9, 2, 9 }, - { 9, 8, 6 }, - { 9, 9, 2 }, - { 9, 9, 3 }, - { 9, 15, 16 }, - { 9, 4, 9 }, - { 9, 6, 8 }, - { 9, 6, 0 }, - { 9, 9, 4 }, - { 9, 5, 9 }, - { 9, 8, 7 }, - { 9, 7, 8 }, - { 9, 1, 9 }, - { 9, 10, 3 }, - { 9, 0, 6 }, - { 9, 10, 2 }, - { 9, 9, 1 }, - { 9, 9, 5 }, - { 9, 4, 10 }, - { 9, 2, 10 }, - { 9, 9, 6 }, - { 9, 3, 10 }, - { 9, 6, 9 }, - { 9, 10, 4 }, - { 9, 8, 8 }, - { 9, 10, 5 }, - { 9, 9, 7 }, - { 9, 11, 3 }, - { 9, 1, 10 }, - { 9, 7, 0 }, - { 9, 10, 6 }, - { 9, 7, 9 }, - { 9, 3, 11 }, - { 9, 5, 10 }, - { 9, 10, 1 }, - { 9, 4, 11 }, - { 9, 11, 2 }, - { 9, 13, 2 }, - { 9, 6, 10 }, - - /* 9/10 */ - { 9, 13, 3 }, { 9, 13, 3 }, - { 9, 2, 11 }, { 9, 2, 11 }, - { 9, 16, 0 }, { 9, 16, 0 }, - { 9, 5, 11 }, { 9, 5, 11 }, - { 9, 11, 5 }, { 9, 11, 5 }, - { 10, 11, 4 }, - { 10, 9, 8 }, - { 10, 7, 10 }, - { 10, 8, 9 }, - { 10, 0, 16 }, - { 10, 4, 13 }, - { 10, 0, 7 }, - { 10, 3, 13 }, - { 10, 11, 6 }, - { 10, 13, 1 }, - { 10, 13, 4 }, - { 10, 12, 3 }, - { 10, 2, 13 }, - { 10, 13, 5 }, - { 10, 8, 10 }, - { 10, 6, 11 }, - { 10, 10, 8 }, - { 10, 10, 7 }, - { 10, 14, 2 }, - { 10, 12, 4 }, - { 10, 1, 11 }, - { 10, 4, 12 }, - - /* 10 */ - { 10, 11, 1 }, - { 10, 3, 12 }, - { 10, 1, 13 }, - { 10, 12, 2 }, - { 10, 7, 11 }, - { 10, 3, 14 }, - { 10, 5, 12 }, - { 10, 5, 13 }, - { 10, 14, 4 }, - { 10, 4, 14 }, - { 10, 11, 7 }, - { 10, 14, 3 }, - { 10, 12, 5 }, - { 10, 13, 6 }, - { 10, 12, 6 }, - { 10, 8, 0 }, - { 10, 11, 8 }, - { 10, 2, 12 }, - { 10, 9, 9 }, - { 10, 14, 5 }, - { 10, 6, 13 }, - { 10, 10, 10 }, - { 10, 15, 2 }, - { 10, 8, 11 }, - { 10, 9, 10 }, - { 10, 14, 6 }, - { 10, 10, 9 }, - { 10, 5, 14 }, - { 10, 11, 9 }, - { 10, 14, 1 }, - { 10, 2, 14 }, - { 10, 6, 12 }, - { 10, 1, 12 }, - { 10, 13, 8 }, - { 10, 0, 8 }, - { 10, 13, 7 }, - { 10, 7, 12 }, - { 10, 12, 7 }, - { 10, 7, 13 }, - { 10, 15, 3 }, - { 10, 12, 1 }, - { 10, 6, 14 }, - { 10, 2, 15 }, - { 10, 15, 5 }, - { 10, 15, 4 }, - { 10, 1, 14 }, - { 10, 9, 11 }, - { 10, 4, 15 }, - { 10, 14, 7 }, - { 10, 8, 13 }, - { 10, 13, 9 }, - { 10, 8, 12 }, - { 10, 5, 15 }, - { 10, 3, 15 }, - { 10, 10, 11 }, - { 10, 11, 10 }, - { 10, 12, 8 }, - { 10, 15, 6 }, - { 10, 15, 7 }, - { 10, 8, 14 }, - { 10, 15, 1 }, - { 10, 7, 14 }, - { 10, 9, 0 }, - { 10, 0, 9 }, - - /* 10/11/12 */ - { 10, 9, 13 }, { 10, 9, 13 }, { 10, 9, 13 }, { 10, 9, 13 }, - { 10, 9, 12 }, { 10, 9, 12 }, { 10, 9, 12 }, { 10, 9, 12 }, - { 10, 12, 9 }, { 10, 12, 9 }, { 10, 12, 9 }, { 10, 12, 9 }, - { 10, 14, 8 }, { 10, 14, 8 }, { 10, 14, 8 }, { 10, 14, 8 }, - { 10, 10, 13 }, { 10, 10, 13 }, { 10, 10, 13 }, { 10, 10, 13 }, - { 10, 14, 9 }, { 10, 14, 9 }, { 10, 14, 9 }, { 10, 14, 9 }, - { 10, 12, 10 }, { 10, 12, 10 }, { 10, 12, 10 }, { 10, 12, 10 }, - { 10, 6, 15 }, { 10, 6, 15 }, { 10, 6, 15 }, { 10, 6, 15 }, - { 10, 7, 15 }, { 10, 7, 15 }, { 10, 7, 15 }, { 10, 7, 15 }, - - { 11, 9, 14 }, { 11, 9, 14 }, - { 11, 15, 8 }, { 11, 15, 8 }, - { 11, 11, 11 }, { 11, 11, 11 }, - { 11, 11, 14 }, { 11, 11, 14 }, - { 11, 1, 15 }, { 11, 1, 15 }, - { 11, 10, 12 }, { 11, 10, 12 }, - { 11, 10, 14 }, { 11, 10, 14 }, - { 11, 13, 11 }, { 11, 13, 11 }, - { 11, 13, 10 }, { 11, 13, 10 }, - { 11, 11, 13 }, { 11, 11, 13 }, - { 11, 11, 12 }, { 11, 11, 12 }, - { 11, 8, 15 }, { 11, 8, 15 }, - { 11, 14, 11 }, { 11, 14, 11 }, - { 11, 13, 12 }, { 11, 13, 12 }, - { 11, 12, 13 }, { 11, 12, 13 }, - { 11, 15, 9 }, { 11, 15, 9 }, - { 11, 14, 10 }, { 11, 14, 10 }, - { 11, 10, 0 }, { 11, 10, 0 }, - { 11, 12, 11 }, { 11, 12, 11 }, - { 11, 9, 15 }, { 11, 9, 15 }, - { 11, 0, 10 }, { 11, 0, 10 }, - { 11, 12, 12 }, { 11, 12, 12 }, - { 11, 11, 0 }, { 11, 11, 0 }, - { 11, 12, 14 }, { 11, 12, 14 }, - { 11, 10, 15 }, { 11, 10, 15 }, - { 11, 13, 13 }, { 11, 13, 13 }, - { 11, 0, 13 }, { 11, 0, 13 }, - { 11, 14, 12 }, { 11, 14, 12 }, - { 11, 15, 10 }, { 11, 15, 10 }, - { 11, 15, 11 }, { 11, 15, 11 }, - { 11, 11, 15 }, { 11, 11, 15 }, - { 11, 14, 13 }, { 11, 14, 13 }, - { 11, 13, 0 }, { 11, 13, 0 }, - { 11, 0, 11 }, { 11, 0, 11 }, - { 11, 13, 14 }, { 11, 13, 14 }, - { 11, 15, 12 }, { 11, 15, 12 }, - { 11, 15, 13 }, { 11, 15, 13 }, - { 11, 12, 15 }, { 11, 12, 15 }, - { 11, 14, 0 }, { 11, 14, 0 }, - { 11, 14, 14 }, { 11, 14, 14 }, - { 11, 13, 15 }, { 11, 13, 15 }, - { 11, 12, 0 }, { 11, 12, 0 }, - { 11, 14, 15 }, { 11, 14, 15 }, - { 12, 0, 14 }, - { 12, 0, 12 }, - { 12, 15, 14 }, - { 12, 15, 0 }, - { 12, 0, 15 }, - { 12, 15, 15 } -}; diff --git a/apps/codecs/libfaad/codebook/hcb_2.h b/apps/codecs/libfaad/codebook/hcb_2.h deleted file mode 100644 index 15e7d57084..0000000000 --- a/apps/codecs/libfaad/codebook/hcb_2.h +++ /dev/null @@ -1,182 +0,0 @@ -/* -** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -** -** Any non-GPL usage of this software or parts of this software is strictly -** forbidden. -** -** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. -** -** $Id$ -**/ - -/* 2-step huffman table HCB_2 */ - - -/* 1st step: 5 bits - * 2^5 = 32 entries - * - * Used to find offset into 2nd step table and number of extra bits to get - */ -static hcb hcb2_1[] ICONST_ATTR_FAAD_LARGE_IRAM = { - { /* 00000 */ 0, 0 }, - { /* */ 0, 0 }, - { /* */ 0, 0 }, - { /* */ 0, 0 }, - { /* 00100 */ 1, 0 }, - { /* */ 1, 0 }, - { /* 00110 */ 2, 0 }, - { /* 00111 */ 3, 0 }, - { /* 01000 */ 4, 0 }, - { /* 01001 */ 5, 0 }, - { /* 01010 */ 6, 0 }, - { /* 01011 */ 7, 0 }, - { /* 01100 */ 8, 0 }, - - /* 6 bit codewords */ - { /* 01101 */ 9, 1 }, - { /* 01110 */ 11, 1 }, - { /* 01111 */ 13, 1 }, - { /* 10000 */ 15, 1 }, - { /* 10001 */ 17, 1 }, - { /* 10010 */ 19, 1 }, - { /* 10011 */ 21, 1 }, - { /* 10100 */ 23, 1 }, - { /* 10101 */ 25, 1 }, - { /* 10110 */ 27, 1 }, - { /* 10111 */ 29, 1 }, - { /* 11000 */ 31, 1 }, - - /* 7 bit codewords */ - { /* 11001 */ 33, 2 }, - { /* 11010 */ 37, 2 }, - { /* 11011 */ 41, 2 }, - - /* 7/8 bit codewords */ - { /* 11100 */ 45, 3 }, - - /* 8 bit codewords */ - { /* 11101 */ 53, 3 }, - { /* 11110 */ 61, 3 }, - - /* 8/9 bit codewords */ - { /* 11111 */ 69, 4 } -}; - -/* 2nd step table - * - * Gives size of codeword and actual data (x,y,v,w) - */ -static hcb_2_quad hcb2_2[] ICONST_ATTR_FAAD_LARGE_IRAM = { - /* 3 bit codeword */ - { 3, 0, 0, 0, 0 }, - - /* 4 bit codeword */ - { 4, 1, 0, 0, 0 }, - - /* 5 bit codewords */ - { 5, -1, 0, 0, 0 }, - { 5, 0, 0, 0, 1 }, - { 5, 0, 0, -1, 0 }, - { 5, 0, 0, 0, -1 }, - { 5, 0, -1, 0, 0 }, - { 5, 0, 0, 1, 0 }, - { 5, 0, 1, 0, 0 }, - - /* 6 bit codewords */ - { 6, 0, -1, 1, 0 }, - { 6, -1, 1, 0, 0 }, - { 6, 0, 1, -1, 0 }, - { 6, 0, 0, 1, -1 }, - { 6, 0, 1, 0, -1 }, - { 6, 0, 0, -1, 1 }, - { 6, -1, 0, 0, -1 }, - { 6, 1, -1, 0, 0 }, - { 6, 1, 0, -1, 0 }, - { 6, -1, -1, 0, 0 }, - { 6, 0, 0, -1, -1 }, - { 6, 1, 0, 1, 0 }, - { 6, 1, 0, 0, 1 }, - { 6, 0, -1, 0, 1 }, - { 6, -1, 0, 1, 0 }, - { 6, 0, 1, 0, 1 }, - { 6, 0, -1, -1, 0 }, - { 6, -1, 0, 0, 1 }, - { 6, 0, -1, 0, -1 }, - { 6, -1, 0, -1, 0 }, - { 6, 1, 1, 0, 0 }, - { 6, 0, 1, 1, 0 }, - { 6, 0, 0, 1, 1 }, - { 6, 1, 0, 0, -1 }, - - /* 7 bit codewords */ - { 7, 0, 1, -1, 1 }, - { 7, 1, 0, -1, 1 }, - { 7, -1, 1, -1, 0 }, - { 7, 0, -1, 1, -1 }, - { 7, 1, -1, 1, 0 }, - { 7, 1, 1, 0, -1 }, - { 7, 1, 0, 1, 1 }, - { 7, -1, 1, 1, 0 }, - { 7, 0, -1, -1, 1 }, - { 7, 1, 1, 1, 0 }, - { 7, -1, 0, 1, -1 }, - { 7, -1, -1, -1, 0 }, - - /* 7/8 bit codewords */ - { 7, -1, 0, -1, 1 }, { 7, -1, 0, -1, 1 }, - { 7, 1, -1, -1, 0 }, { 7, 1, -1, -1, 0 }, - { 7, 1, 1, -1, 0 }, { 7, 1, 1, -1, 0 }, - { 8, 1, -1, 0, 1 }, - { 8, -1, 1, 0, -1 }, - - /* 8 bit codewords */ - { 8, -1, -1, 1, 0 }, - { 8, -1, 0, 1, 1 }, - { 8, -1, -1, 0, 1 }, - { 8, -1, -1, 0, -1 }, - { 8, 0, -1, -1, -1 }, - { 8, 1, 0, 1, -1 }, - { 8, 1, 0, -1, -1 }, - { 8, 0, 1, -1, -1 }, - { 8, 0, 1, 1, 1 }, - { 8, -1, 1, 0, 1 }, - { 8, -1, 0, -1, -1 }, - { 8, 0, 1, 1, -1 }, - { 8, 1, -1, 0, -1 }, - { 8, 0, -1, 1, 1 }, - { 8, 1, 1, 0, 1 }, - { 8, 1, -1, 1, -1 }, - - /* 8/9 bit codewords */ - { 8, -1, 1, -1, 1 }, { 8, -1, 1, -1, 1 }, - { 9, 1, -1, -1, 1 }, - { 9, -1, -1, -1, -1 }, - { 9, -1, 1, 1, -1 }, - { 9, -1, 1, 1, 1 }, - { 9, 1, 1, 1, 1 }, - { 9, -1, -1, 1, -1 }, - { 9, 1, -1, 1, 1 }, - { 9, -1, 1, -1, -1 }, - { 9, -1, -1, 1, 1 }, - { 9, 1, 1, -1, -1 }, - { 9, 1, -1, -1, -1 }, - { 9, -1, -1, -1, 1 }, - { 9, 1, 1, -1, 1 }, - { 9, 1, 1, 1, -1 } -}; diff --git a/apps/codecs/libfaad/codebook/hcb_3.h b/apps/codecs/libfaad/codebook/hcb_3.h deleted file mode 100644 index 3b12fdff60..0000000000 --- a/apps/codecs/libfaad/codebook/hcb_3.h +++ /dev/null @@ -1,193 +0,0 @@ -/* -** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -** -** Any non-GPL usage of this software or parts of this software is strictly -** forbidden. -** -** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. -** -** $Id$ -**/ - -/* Binary search huffman table HCB_3 */ - - -static hcb_bin_quad hcb3[] ICONST_ATTR_FAAD_LARGE_IRAM = { - { /* 0 */ 0, { 1, 2, 0, 0 } }, - { /* 1 */ 1, { 0, 0, 0, 0 } }, /* 0 */ - { /* 2 */ 0, { 1, 2, 0, 0 } }, - { /* 3 */ 0, { 2, 3, 0, 0 } }, - { /* 4 */ 0, { 3, 4, 0, 0 } }, - { /* 5 */ 0, { 4, 5, 0, 0 } }, - { /* 6 */ 0, { 5, 6, 0, 0 } }, - { /* 7 */ 0, { 6, 7, 0, 0 } }, - { /* 8 */ 0, { 7, 8, 0, 0 } }, - { /* 9 */ 1, { 1, 0, 0, 0 } }, /* 1000 */ - { /* 10 */ 1, { 0, 0, 0, 1 } }, /* 1001 */ - { /* 11 */ 1, { 0, 1, 0, 0 } }, /* 1010 */ - { /* 12 */ 1, { 0, 0, 1, 0 } }, /* 1011 */ - { /* 13 */ 0, { 4, 5, 0, 0 } }, - { /* 14 */ 0, { 5, 6, 0, 0 } }, - { /* 15 */ 0, { 6, 7, 0, 0 } }, - { /* 16 */ 0, { 7, 8, 0, 0 } }, - { /* 17 */ 1, { 1, 1, 0, 0 } }, - { /* 18 */ 1, { 0, 0, 1, 1 } }, - { /* 19 */ 0, { 6, 7, 0, 0 } }, - { /* 20 */ 0, { 7, 8, 0, 0 } }, - { /* 21 */ 0, { 8, 9, 0, 0 } }, - { /* 22 */ 0, { 9, 10, 0, 0 } }, - { /* 23 */ 0, { 10, 11, 0, 0 } }, - { /* 24 */ 0, { 11, 12, 0, 0 } }, - { /* 25 */ 1, { 0, 1, 1, 0 } }, /* 110100 */ - { /* 26 */ 1, { 0, 1, 0, 1 } }, /* 110101 */ - { /* 27 */ 1, { 1, 0, 1, 0 } }, /* 110110 */ - { /* 28 */ 1, { 0, 1, 1, 1 } }, /* 110111 */ - { /* 29 */ 1, { 1, 0, 0, 1 } }, /* 111000 */ - { /* 30 */ 1, { 1, 1, 1, 0 } }, /* 111001 */ - { /* 31 */ 0, { 6, 7, 0, 0 } }, - { /* 32 */ 0, { 7, 8, 0, 0 } }, - { /* 33 */ 0, { 8, 9, 0, 0 } }, - { /* 34 */ 0, { 9, 10, 0, 0 } }, - { /* 35 */ 0, { 10, 11, 0, 0 } }, - { /* 36 */ 0, { 11, 12, 0, 0 } }, - { /* 37 */ 1, { 1, 1, 1, 1 } }, /* 1110100 */ - { /* 38 */ 1, { 1, 0, 1, 1 } }, /* 1110101 */ - { /* 39 */ 1, { 1, 1, 0, 1 } }, /* 1110110 */ - { /* 40 */ 0, { 9, 10, 0, 0 } }, - { /* 41 */ 0, { 10, 11, 0, 0 } }, - { /* 42 */ 0, { 11, 12, 0, 0 } }, - { /* 43 */ 0, { 12, 13, 0, 0 } }, - { /* 44 */ 0, { 13, 14, 0, 0 } }, - { /* 45 */ 0, { 14, 15, 0, 0 } }, - { /* 46 */ 0, { 15, 16, 0, 0 } }, - { /* 47 */ 0, { 16, 17, 0, 0 } }, - { /* 48 */ 0, { 17, 18, 0, 0 } }, - { /* 49 */ 1, { 2, 0, 0, 0 } }, /* 11101110 */ - { /* 50 */ 1, { 0, 0, 0, 2 } }, /* 11101111 */ - { /* 51 */ 1, { 0, 0, 1, 2 } }, /* 11110000 */ - { /* 52 */ 1, { 2, 1, 0, 0 } }, /* 11110001 */ - { /* 53 */ 1, { 1, 2, 1, 0 } }, /* 11110010 */ - { /* 54 */ 0, { 13, 14, 0, 0 } }, - { /* 55 */ 0, { 14, 15, 0, 0 } }, - { /* 56 */ 0, { 15, 16, 0, 0 } }, - { /* 57 */ 0, { 16, 17, 0, 0 } }, - { /* 58 */ 0, { 17, 18, 0, 0 } }, - { /* 59 */ 0, { 18, 19, 0, 0 } }, - { /* 60 */ 0, { 19, 20, 0, 0 } }, - { /* 61 */ 0, { 20, 21, 0, 0 } }, - { /* 62 */ 0, { 21, 22, 0, 0 } }, - { /* 63 */ 0, { 22, 23, 0, 0 } }, - { /* 64 */ 0, { 23, 24, 0, 0 } }, - { /* 65 */ 0, { 24, 25, 0, 0 } }, - { /* 66 */ 0, { 25, 26, 0, 0 } }, - { /* 67 */ 1, { 0, 0, 2, 1 } }, - { /* 68 */ 1, { 0, 1, 2, 1 } }, - { /* 69 */ 1, { 1, 2, 0, 0 } }, - { /* 70 */ 1, { 0, 1, 1, 2 } }, - { /* 71 */ 1, { 2, 1, 1, 0 } }, - { /* 72 */ 1, { 0, 0, 2, 0 } }, - { /* 73 */ 1, { 0, 2, 1, 0 } }, - { /* 74 */ 1, { 0, 1, 2, 0 } }, - { /* 75 */ 1, { 0, 2, 0, 0 } }, - { /* 76 */ 1, { 0, 1, 0, 2 } }, - { /* 77 */ 1, { 2, 0, 1, 0 } }, - { /* 78 */ 1, { 1, 2, 1, 1 } }, - { /* 79 */ 1, { 0, 2, 1, 1 } }, - { /* 80 */ 1, { 1, 1, 2, 0 } }, - { /* 81 */ 1, { 1, 1, 2, 1 } }, - { /* 82 */ 0, { 11, 12, 0, 0 } }, - { /* 83 */ 0, { 12, 13, 0, 0 } }, - { /* 84 */ 0, { 13, 14, 0, 0 } }, - { /* 85 */ 0, { 14, 15, 0, 0 } }, - { /* 86 */ 0, { 15, 16, 0, 0 } }, - { /* 87 */ 0, { 16, 17, 0, 0 } }, - { /* 88 */ 0, { 17, 18, 0, 0 } }, - { /* 89 */ 0, { 18, 19, 0, 0 } }, - { /* 90 */ 0, { 19, 20, 0, 0 } }, - { /* 91 */ 0, { 20, 21, 0, 0 } }, - { /* 92 */ 0, { 21, 22, 0, 0 } }, - { /* 93 */ 1, { 1, 2, 0, 1 } }, /* 1111101010 */ - { /* 94 */ 1, { 1, 0, 2, 0 } }, /* 1111101011 */ - { /* 95 */ 1, { 1, 0, 2, 1 } }, /* 1111101100 */ - { /* 96 */ 1, { 0, 2, 0, 1 } }, /* 1111101101 */ - { /* 97 */ 1, { 2, 1, 1, 1 } }, /* 1111101110 */ - { /* 98 */ 1, { 1, 1, 1, 2 } }, /* 1111101111 */ - { /* 99 */ 1, { 2, 1, 0, 1 } }, /* 1111110000 */ - { /* 00 */ 1, { 1, 0, 1, 2 } }, /* 1111110001 */ - { /* 01 */ 1, { 0, 0, 2, 2 } }, /* 1111110010 */ - { /* 02 */ 1, { 0, 1, 2, 2 } }, /* 1111110011 */ - { /* 03 */ 1, { 2, 2, 1, 0 } }, /* 1111110100 */ - { /* 04 */ 1, { 1, 2, 2, 0 } }, /* 1111110101 */ - { /* 05 */ 1, { 1, 0, 0, 2 } }, /* 1111110110 */ - { /* 06 */ 1, { 2, 0, 0, 1 } }, /* 1111110111 */ - { /* 07 */ 1, { 0, 2, 2, 1 } }, /* 1111111000 */ - { /* 08 */ 0, { 7, 8, 0, 0 } }, - { /* 09 */ 0, { 8, 9, 0, 0 } }, - { /* 10 */ 0, { 9, 10, 0, 0 } }, - { /* 11 */ 0, { 10, 11, 0, 0 } }, - { /* 12 */ 0, { 11, 12, 0, 0 } }, - { /* 13 */ 0, { 12, 13, 0, 0 } }, - { /* 14 */ 0, { 13, 14, 0, 0 } }, - { /* 15 */ 1, { 2, 2, 0, 0 } }, /* 11111110010 */ - { /* 16 */ 1, { 1, 2, 2, 1 } }, /* 11111110011 */ - { /* 17 */ 1, { 1, 1, 0, 2 } }, /* 11111110100 */ - { /* 18 */ 1, { 2, 0, 1, 1 } }, /* 11111110101 */ - { /* 19 */ 1, { 1, 1, 2, 2 } }, /* 11111110110 */ - { /* 20 */ 1, { 2, 2, 1, 1 } }, /* 11111110111 */ - { /* 21 */ 1, { 0, 2, 2, 0 } }, /* 11111111000 */ - { /* 22 */ 1, { 0, 2, 1, 2 } }, /* 11111111001 */ - { /* 23 */ 0, { 6, 7, 0, 0 } }, - { /* 24 */ 0, { 7, 8, 0, 0 } }, - { /* 25 */ 0, { 8, 9, 0, 0 } }, - { /* 26 */ 0, { 9, 10, 0, 0 } }, - { /* 27 */ 0, { 10, 11, 0, 0 } }, - { /* 28 */ 0, { 11, 12, 0, 0 } }, - { /* 29 */ 1, { 1, 0, 2, 2 } }, /* 111111110100 */ - { /* 30 */ 1, { 2, 2, 0, 1 } }, /* 111111110101 */ - { /* 31 */ 1, { 2, 1, 2, 0 } }, /* 111111110110 */ - { /* 32 */ 1, { 2, 2, 2, 0 } }, /* 111111110111 */ - { /* 33 */ 1, { 0, 2, 2, 2 } }, /* 111111111000 */ - { /* 34 */ 1, { 2, 2, 2, 1 } }, /* 111111111001 */ - { /* 35 */ 1, { 2, 1, 2, 1 } }, /* 111111111010 */ - { /* 36 */ 1, { 1, 2, 1, 2 } }, /* 111111111011 */ - { /* 37 */ 1, { 1, 2, 2, 2 } }, /* 111111111100 */ - { /* 38 */ 0, { 3, 4, 0, 0 } }, - { /* 39 */ 0, { 4, 5, 0, 0 } }, - { /* 40 */ 0, { 5, 6, 0, 0 } }, - { /* 41 */ 1, { 0, 2, 0, 2 } }, /* 1111111111010 */ - { /* 42 */ 1, { 2, 0, 2, 0 } }, /* 1111111111011 */ - { /* 43 */ 1, { 1, 2, 0, 2 } }, /* 1111111111100 */ - { /* 44 */ 0, { 3, 4, 0, 0 } }, - { /* 45 */ 0, { 4, 5, 0, 0 } }, - { /* 46 */ 0, { 5, 6, 0, 0 } }, - { /* 47 */ 1, { 2, 0, 2, 1 } }, /* 11111111111010 */ - { /* 48 */ 1, { 2, 1, 1, 2 } }, /* 11111111111011 */ - { /* 49 */ 1, { 2, 1, 0, 2 } }, /* 11111111111100 */ - { /* 50 */ 0, { 3, 4, 0, 0 } }, - { /* 51 */ 0, { 4, 5, 0, 0 } }, - { /* 52 */ 0, { 5, 6, 0, 0 } }, - { /* 53 */ 1, { 2, 2, 2, 2 } }, /* 111111111111010 */ - { /* 54 */ 1, { 2, 2, 1, 2 } }, /* 111111111111011 */ - { /* 55 */ 1, { 2, 1, 2, 2 } }, /* 111111111111100 */ - { /* 56 */ 1, { 2, 0, 1, 2 } }, /* 111111111111101 */ - { /* 57 */ 1, { 2, 0, 0, 2 } }, /* 111111111111110 */ - { /* 58 */ 0, { 1, 2, 0, 0 } }, - { /* 59 */ 1, { 2, 2, 0, 2 } }, /* 1111111111111110 */ - { /* 60 */ 1, { 2, 0, 2, 2 } } /* 1111111111111111 */ -}; diff --git a/apps/codecs/libfaad/codebook/hcb_4.h b/apps/codecs/libfaad/codebook/hcb_4.h deleted file mode 100644 index 67397e1fb0..0000000000 --- a/apps/codecs/libfaad/codebook/hcb_4.h +++ /dev/null @@ -1,196 +0,0 @@ -/* -** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -** -** Any non-GPL usage of this software or parts of this software is strictly -** forbidden. -** -** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. -** -** $Id$ -**/ - -/* 2-step huffman table HCB_4 */ - - -/* 1st step: 5 bits - * 2^5 = 32 entries - * - * Used to find offset into 2nd step table and number of extra bits to get - */ -static hcb hcb4_1[] ICONST_ATTR_FAAD_LARGE_IRAM = { - /* 4 bit codewords */ - { /* 00000 */ 0, 0 }, - { /* */ 0, 0 }, - { /* 00010 */ 1, 0 }, - { /* */ 1, 0 }, - { /* 00100 */ 2, 0 }, - { /* */ 2, 0 }, - { /* 00110 */ 3, 0 }, - { /* */ 3, 0 }, - { /* 01000 */ 4, 0 }, - { /* */ 4, 0 }, - { /* 01010 */ 5, 0 }, - { /* */ 5, 0 }, - { /* 01100 */ 6, 0 }, - { /* */ 6, 0 }, - { /* 01110 */ 7, 0 }, - { /* */ 7, 0 }, - { /* 10000 */ 8, 0 }, - { /* */ 8, 0 }, - { /* 10010 */ 9, 0 }, - { /* */ 9, 0 }, - - /* 5 bit codewords */ - { /* 10100 */ 10, 0 }, - { /* 10101 */ 11, 0 }, - { /* 10110 */ 12, 0 }, - { /* 10111 */ 13, 0 }, - { /* 11000 */ 14, 0 }, - { /* 11001 */ 15, 0 }, - - /* 7 bit codewords */ - { /* 11010 */ 16, 2 }, - { /* 11011 */ 20, 2 }, - - /* 7/8 bit codewords */ - { /* 11100 */ 24, 3 }, - - /* 8 bit codewords */ - { /* 11101 */ 32, 3 }, - - /* 8/9 bit codewords */ - { /* 11110 */ 40, 4 }, - - /* 9/10/11/12 bit codewords */ - { /* 11111 */ 56, 7 } -}; - -/* 2nd step table - * - * Gives size of codeword and actual data (x,y,v,w) - */ -static hcb_2_quad hcb4_2[] ICONST_ATTR_FAAD_LARGE_IRAM = { - /* 4 bit codewords */ - { 4, 1, 1, 1, 1 }, - { 4, 0, 1, 1, 1 }, - { 4, 1, 1, 0, 1 }, - { 4, 1, 1, 1, 0 }, - { 4, 1, 0, 1, 1 }, - { 4, 1, 0, 0, 0 }, - { 4, 1, 1, 0, 0 }, - { 4, 0, 0, 0, 0 }, - { 4, 0, 0, 1, 1 }, - { 4, 1, 0, 1, 0 }, - - /* 5 bit codewords */ - { 5, 1, 0, 0, 1 }, - { 5, 0, 1, 1, 0 }, - { 5, 0, 0, 0, 1 }, - { 5, 0, 1, 0, 1 }, - { 5, 0, 0, 1, 0 }, - { 5, 0, 1, 0, 0 }, - - /* 7 bit codewords */ - /* first 5 bits: 11010 */ - { 7, 2, 1, 1, 1 }, - { 7, 1, 1, 2, 1 }, - { 7, 1, 2, 1, 1 }, - { 7, 1, 1, 1, 2 }, - /* first 5 bits: 11011 */ - { 7, 2, 1, 1, 0 }, - { 7, 2, 1, 0, 1 }, - { 7, 1, 2, 1, 0 }, - { 7, 2, 0, 1, 1 }, - - /* 7/8 bit codewords */ - /* first 5 bits: 11100 */ - { 7, 0, 1, 2, 1 }, { 7, 0, 1, 2, 1 }, - { 8, 0, 1, 1, 2 }, - { 8, 1, 1, 2, 0 }, - { 8, 0, 2, 1, 1 }, - { 8, 1, 0, 1, 2 }, - { 8, 1, 2, 0, 1 }, - { 8, 1, 1, 0, 2 }, - - /* 8 bit codewords */ - { 8, 1, 0, 2, 1 }, - { 8, 2, 1, 0, 0 }, - { 8, 2, 0, 1, 0 }, - { 8, 1, 2, 0, 0 }, - { 8, 2, 0, 0, 1 }, - { 8, 0, 1, 0, 2 }, - { 8, 0, 2, 1, 0 }, - { 8, 0, 0, 1, 2 }, - - /* 8/9 bit codewords */ - { 8, 0, 1, 2, 0 }, { 8, 0, 1, 2, 0 }, - { 8, 0, 2, 0, 1 }, { 8, 0, 2, 0, 1 }, - { 8, 1, 0, 0, 2 }, { 8, 1, 0, 0, 2 }, - { 8, 0, 0, 2, 1 }, { 8, 0, 0, 2, 1 }, - { 8, 1, 0, 2, 0 }, { 8, 1, 0, 2, 0 }, - { 8, 2, 0, 0, 0 }, { 8, 2, 0, 0, 0 }, - { 8, 0, 0, 0, 2 }, { 8, 0, 0, 0, 2 }, - { 9, 0, 2, 0, 0 }, - { 9, 0, 0, 2, 0 }, - - /* 9/10/11 bit codewords */ - /* 9 bit codewords repeated 2^3 = 8 times */ - { 9, 1, 2, 2, 1 }, { 9, 1, 2, 2, 1 }, { 9, 1, 2, 2, 1 }, { 9, 1, 2, 2, 1 }, - { 9, 1, 2, 2, 1 }, { 9, 1, 2, 2, 1 }, { 9, 1, 2, 2, 1 }, { 9, 1, 2, 2, 1 }, - { 9, 2, 2, 1, 1 }, { 9, 2, 2, 1, 1 }, { 9, 2, 2, 1, 1 }, { 9, 2, 2, 1, 1 }, - { 9, 2, 2, 1, 1 }, { 9, 2, 2, 1, 1 }, { 9, 2, 2, 1, 1 }, { 9, 2, 2, 1, 1 }, - { 9, 2, 1, 2, 1 }, { 9, 2, 1, 2, 1 }, { 9, 2, 1, 2, 1 }, { 9, 2, 1, 2, 1 }, - { 9, 2, 1, 2, 1 }, { 9, 2, 1, 2, 1 }, { 9, 2, 1, 2, 1 }, { 9, 2, 1, 2, 1 }, - { 9, 1, 1, 2, 2 }, { 9, 1, 1, 2, 2 }, { 9, 1, 1, 2, 2 }, { 9, 1, 1, 2, 2 }, - { 9, 1, 1, 2, 2 }, { 9, 1, 1, 2, 2 }, { 9, 1, 1, 2, 2 }, { 9, 1, 1, 2, 2 }, - { 9, 1, 2, 1, 2 }, { 9, 1, 2, 1, 2 }, { 9, 1, 2, 1, 2 }, { 9, 1, 2, 1, 2 }, - { 9, 1, 2, 1, 2 }, { 9, 1, 2, 1, 2 }, { 9, 1, 2, 1, 2 }, { 9, 1, 2, 1, 2 }, - { 9, 2, 1, 1, 2 }, { 9, 2, 1, 1, 2 }, { 9, 2, 1, 1, 2 }, { 9, 2, 1, 1, 2 }, - { 9, 2, 1, 1, 2 }, { 9, 2, 1, 1, 2 }, { 9, 2, 1, 1, 2 }, { 9, 2, 1, 1, 2 }, - /* 10 bit codewords repeated 2^2 = 4 times */ - { 10, 1, 2, 2, 0 }, { 10, 1, 2, 2, 0 }, { 10, 1, 2, 2, 0 }, { 10, 1, 2, 2, 0 }, - { 10, 2, 2, 1, 0 }, { 10, 2, 2, 1, 0 }, { 10, 2, 2, 1, 0 }, { 10, 2, 2, 1, 0 }, - { 10, 2, 1, 2, 0 }, { 10, 2, 1, 2, 0 }, { 10, 2, 1, 2, 0 }, { 10, 2, 1, 2, 0 }, - { 10, 0, 2, 2, 1 }, { 10, 0, 2, 2, 1 }, { 10, 0, 2, 2, 1 }, { 10, 0, 2, 2, 1 }, - { 10, 0, 1, 2, 2 }, { 10, 0, 1, 2, 2 }, { 10, 0, 1, 2, 2 }, { 10, 0, 1, 2, 2 }, - { 10, 2, 2, 0, 1 }, { 10, 2, 2, 0, 1 }, { 10, 2, 2, 0, 1 }, { 10, 2, 2, 0, 1 }, - { 10, 0, 2, 1, 2 }, { 10, 0, 2, 1, 2 }, { 10, 0, 2, 1, 2 }, { 10, 0, 2, 1, 2 }, - { 10, 2, 0, 2, 1 }, { 10, 2, 0, 2, 1 }, { 10, 2, 0, 2, 1 }, { 10, 2, 0, 2, 1 }, - { 10, 1, 0, 2, 2 }, { 10, 1, 0, 2, 2 }, { 10, 1, 0, 2, 2 }, { 10, 1, 0, 2, 2 }, - { 10, 2, 2, 2, 1 }, { 10, 2, 2, 2, 1 }, { 10, 2, 2, 2, 1 }, { 10, 2, 2, 2, 1 }, - { 10, 1, 2, 0, 2 }, { 10, 1, 2, 0, 2 }, { 10, 1, 2, 0, 2 }, { 10, 1, 2, 0, 2 }, - { 10, 2, 0, 1, 2 }, { 10, 2, 0, 1, 2 }, { 10, 2, 0, 1, 2 }, { 10, 2, 0, 1, 2 }, - { 10, 2, 1, 0, 2 }, { 10, 2, 1, 0, 2 }, { 10, 2, 1, 0, 2 }, { 10, 2, 1, 0, 2 }, - { 10, 1, 2, 2, 2 }, { 10, 1, 2, 2, 2 }, { 10, 1, 2, 2, 2 }, { 10, 1, 2, 2, 2 }, - /* 11 bit codewords repeated 2^1 = 2 times */ - { 11, 2, 1, 2, 2 }, { 11, 2, 1, 2, 2 }, - { 11, 2, 2, 1, 2 }, { 11, 2, 2, 1, 2 }, - { 11, 0, 2, 2, 0 }, { 11, 0, 2, 2, 0 }, - { 11, 2, 2, 0, 0 }, { 11, 2, 2, 0, 0 }, - { 11, 0, 0, 2, 2 }, { 11, 0, 0, 2, 2 }, - { 11, 2, 0, 2, 0 }, { 11, 2, 0, 2, 0 }, - { 11, 0, 2, 0, 2 }, { 11, 0, 2, 0, 2 }, - { 11, 2, 0, 0, 2 }, { 11, 2, 0, 0, 2 }, - { 11, 2, 2, 2, 2 }, { 11, 2, 2, 2, 2 }, - { 11, 0, 2, 2, 2 }, { 11, 0, 2, 2, 2 }, - { 11, 2, 2, 2, 0 }, { 11, 2, 2, 2, 0 }, - /* 12 bit codewords */ - { 12, 2, 2, 0, 2 }, - { 12, 2, 0, 2, 2 }, -}; diff --git a/apps/codecs/libfaad/codebook/hcb_5.h b/apps/codecs/libfaad/codebook/hcb_5.h deleted file mode 100644 index 0143482901..0000000000 --- a/apps/codecs/libfaad/codebook/hcb_5.h +++ /dev/null @@ -1,193 +0,0 @@ -/* -** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -** -** Any non-GPL usage of this software or parts of this software is strictly -** forbidden. -** -** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. -** -** $Id$ -**/ - -/* Binary search huffman table HCB_5 */ - - -static hcb_bin_pair hcb5[] ICONST_ATTR_FAAD_LARGE_IRAM = { - { /* 0 */ 0, { 1, 2 } }, - { /* 1 */ 1, { 0, 0 } }, /* 0 */ - { /* 2 */ 0, { 1, 2 } }, - { /* 3 */ 0, { 2, 3 } }, - { /* 4 */ 0, { 3, 4 } }, - { /* 5 */ 0, { 4, 5 } }, - { /* 6 */ 0, { 5, 6 } }, - { /* 7 */ 0, { 6, 7 } }, - { /* 8 */ 0, { 7, 8 } }, - { /* 9 */ 1, { -1, 0 } }, /* 1000 */ - { /* 10 */ 1, { 1, 0 } }, /* 1001 */ - { /* 11 */ 1, { 0, 1 } }, /* 1010 */ - { /* 12 */ 1, { 0, -1 } }, /* 1011 */ - { /* 13 */ 0, { 4, 5 } }, - { /* 14 */ 0, { 5, 6 } }, - { /* 15 */ 0, { 6, 7 } }, - { /* 16 */ 0, { 7, 8 } }, - { /* 17 */ 1, { 1, -1 } }, - { /* 18 */ 1, { -1, 1 } }, - { /* 19 */ 1, { -1, -1 } }, - { /* 20 */ 1, { 1, 1 } }, - { /* 21 */ 0, { 4, 5 } }, - { /* 22 */ 0, { 5, 6 } }, - { /* 23 */ 0, { 6, 7 } }, - { /* 24 */ 0, { 7, 8 } }, - { /* 25 */ 0, { 8, 9 } }, - { /* 26 */ 0, { 9, 10 } }, - { /* 27 */ 0, { 10, 11 } }, - { /* 28 */ 0, { 11, 12 } }, - { /* 29 */ 0, { 12, 13 } }, - { /* 30 */ 0, { 13, 14 } }, - { /* 31 */ 0, { 14, 15 } }, - { /* 32 */ 0, { 15, 16 } }, - { /* 33 */ 1, { -2, 0 } }, - { /* 34 */ 1, { 0, 2 } }, - { /* 35 */ 1, { 2, 0 } }, - { /* 36 */ 1, { 0, -2 } }, - { /* 37 */ 0, { 12, 13 } }, - { /* 38 */ 0, { 13, 14 } }, - { /* 39 */ 0, { 14, 15 } }, - { /* 40 */ 0, { 15, 16 } }, - { /* 41 */ 0, { 16, 17 } }, - { /* 42 */ 0, { 17, 18 } }, - { /* 43 */ 0, { 18, 19 } }, - { /* 44 */ 0, { 19, 20 } }, - { /* 45 */ 0, { 20, 21 } }, - { /* 46 */ 0, { 21, 22 } }, - { /* 47 */ 0, { 22, 23 } }, - { /* 48 */ 0, { 23, 24 } }, - { /* 49 */ 1, { -2, -1 } }, - { /* 50 */ 1, { 2, 1 } }, - { /* 51 */ 1, { -1, -2 } }, - { /* 52 */ 1, { 1, 2 } }, - { /* 53 */ 1, { -2, 1 } }, - { /* 54 */ 1, { 2, -1 } }, - { /* 55 */ 1, { -1, 2 } }, - { /* 56 */ 1, { 1, -2 } }, - { /* 57 */ 1, { -3, 0 } }, - { /* 58 */ 1, { 3, 0 } }, - { /* 59 */ 1, { 0, -3 } }, - { /* 60 */ 1, { 0, 3 } }, - { /* 61 */ 0, { 12, 13 } }, - { /* 62 */ 0, { 13, 14 } }, - { /* 63 */ 0, { 14, 15 } }, - { /* 64 */ 0, { 15, 16 } }, - { /* 65 */ 0, { 16, 17 } }, - { /* 66 */ 0, { 17, 18 } }, - { /* 67 */ 0, { 18, 19 } }, - { /* 68 */ 0, { 19, 20 } }, - { /* 69 */ 0, { 20, 21 } }, - { /* 70 */ 0, { 21, 22 } }, - { /* 71 */ 0, { 22, 23 } }, - { /* 72 */ 0, { 23, 24 } }, - { /* 73 */ 1, { -3, -1 } }, - { /* 74 */ 1, { 1, 3 } }, - { /* 75 */ 1, { 3, 1 } }, - { /* 76 */ 1, { -1, -3 } }, - { /* 77 */ 1, { -3, 1 } }, - { /* 78 */ 1, { 3, -1 } }, - { /* 79 */ 1, { 1, -3 } }, - { /* 80 */ 1, { -1, 3 } }, - { /* 81 */ 1, { -2, 2 } }, - { /* 82 */ 1, { 2, 2 } }, - { /* 83 */ 1, { -2, -2 } }, - { /* 84 */ 1, { 2, -2 } }, - { /* 85 */ 0, { 12, 13 } }, - { /* 86 */ 0, { 13, 14 } }, - { /* 87 */ 0, { 14, 15 } }, - { /* 88 */ 0, { 15, 16 } }, - { /* 89 */ 0, { 16, 17 } }, - { /* 90 */ 0, { 17, 18 } }, - { /* 91 */ 0, { 18, 19 } }, - { /* 92 */ 0, { 19, 20 } }, - { /* 93 */ 0, { 20, 21 } }, - { /* 94 */ 0, { 21, 22 } }, - { /* 95 */ 0, { 22, 23 } }, - { /* 96 */ 0, { 23, 24 } }, - { /* 97 */ 1, { -3, -2 } }, - { /* 98 */ 1, { 3, -2 } }, - { /* 99 */ 1, { -2, 3 } }, - { /* 00 */ 1, { 2, -3 } }, - { /* 01 */ 1, { 3, 2 } }, - { /* 02 */ 1, { 2, 3 } }, - { /* 03 */ 1, { -3, 2 } }, - { /* 04 */ 1, { -2, -3 } }, - { /* 05 */ 1, { 0, -4 } }, - { /* 06 */ 1, { -4, 0 } }, - { /* 07 */ 1, { 4, 1 } }, - { /* 08 */ 1, { 4, 0 } }, - { /* 09 */ 0, { 12, 13 } }, - { /* 10 */ 0, { 13, 14 } }, - { /* 11 */ 0, { 14, 15 } }, - { /* 12 */ 0, { 15, 16 } }, - { /* 13 */ 0, { 16, 17 } }, - { /* 14 */ 0, { 17, 18 } }, - { /* 15 */ 0, { 18, 19 } }, - { /* 16 */ 0, { 19, 20 } }, - { /* 17 */ 0, { 20, 21 } }, - { /* 18 */ 0, { 21, 22 } }, - { /* 19 */ 0, { 22, 23 } }, - { /* 20 */ 0, { 23, 24 } }, - { /* 21 */ 1, { -4, -1 } }, - { /* 22 */ 1, { 0, 4 } }, - { /* 23 */ 1, { 4, -1 } }, - { /* 24 */ 1, { -1, -4 } }, - { /* 25 */ 1, { 1, 4 } }, - { /* 26 */ 1, { -1, 4 } }, - { /* 27 */ 1, { -4, 1 } }, - { /* 28 */ 1, { 1, -4 } }, - { /* 29 */ 1, { 3, -3 } }, - { /* 30 */ 1, { -3, -3 } }, - { /* 31 */ 1, { -3, 3 } }, - { /* 32 */ 1, { -2, 4 } }, - { /* 33 */ 1, { -4, -2 } }, - { /* 34 */ 1, { 4, 2 } }, - { /* 35 */ 1, { 2, -4 } }, - { /* 36 */ 1, { 2, 4 } }, - { /* 37 */ 1, { 3, 3 } }, - { /* 38 */ 1, { -4, 2 } }, - { /* 39 */ 0, { 6, 7 } }, - { /* 40 */ 0, { 7, 8 } }, - { /* 41 */ 0, { 8, 9 } }, - { /* 42 */ 0, { 9, 10 } }, - { /* 43 */ 0, { 10, 11 } }, - { /* 44 */ 0, { 11, 12 } }, - { /* 45 */ 1, { -2, -4 } }, - { /* 46 */ 1, { 4, -2 } }, - { /* 47 */ 1, { 3, -4 } }, - { /* 48 */ 1, { -4, -3 } }, - { /* 49 */ 1, { -4, 3 } }, - { /* 50 */ 1, { 3, 4 } }, - { /* 51 */ 1, { -3, 4 } }, - { /* 52 */ 1, { 4, 3 } }, - { /* 53 */ 1, { 4, -3 } }, - { /* 54 */ 1, { -3, -4 } }, - { /* 55 */ 0, { 2, 3 } }, - { /* 56 */ 0, { 3, 4 } }, - { /* 57 */ 1, { 4, -4 } }, - { /* 58 */ 1, { -4, 4 } }, - { /* 59 */ 1, { 4, 4 } }, - { /* 60 */ 1, { -4, -4 } } -}; diff --git a/apps/codecs/libfaad/codebook/hcb_6.h b/apps/codecs/libfaad/codebook/hcb_6.h deleted file mode 100644 index 9988133552..0000000000 --- a/apps/codecs/libfaad/codebook/hcb_6.h +++ /dev/null @@ -1,179 +0,0 @@ -/* -** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -** -** Any non-GPL usage of this software or parts of this software is strictly -** forbidden. -** -** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. -** -** $Id$ -**/ - -/* 2-step huffman table HCB_6 */ - - -/* 1st step: 5 bits - * 2^5 = 32 entries - * - * Used to find offset into 2nd step table and number of extra bits to get - */ -static hcb hcb6_1[] ICONST_ATTR = { - /* 4 bit codewords */ - { /* 00000 */ 0, 0 }, - { /* */ 0, 0 }, - { /* 00010 */ 1, 0 }, - { /* */ 1, 0 }, - { /* 00100 */ 2, 0 }, - { /* */ 2, 0 }, - { /* 00110 */ 3, 0 }, - { /* */ 3, 0 }, - { /* 01000 */ 4, 0 }, - { /* */ 4, 0 }, - { /* 01010 */ 5, 0 }, - { /* */ 5, 0 }, - { /* 01100 */ 6, 0 }, - { /* */ 6, 0 }, - { /* 01110 */ 7, 0 }, - { /* */ 7, 0 }, - { /* 10000 */ 8, 0 }, - { /* */ 8, 0 }, - - /* 6 bit codewords */ - { /* 10010 */ 9, 1 }, - { /* 10011 */ 11, 1 }, - { /* 10100 */ 13, 1 }, - { /* 10101 */ 15, 1 }, - { /* 10110 */ 17, 1 }, - { /* 10111 */ 19, 1 }, - { /* 11000 */ 21, 1 }, - { /* 11001 */ 23, 1 }, - - /* 7 bit codewords */ - { /* 11010 */ 25, 2 }, - { /* 11011 */ 29, 2 }, - { /* 11100 */ 33, 2 }, - - /* 7/8 bit codewords */ - { /* 11101 */ 37, 3 }, - - /* 8/9 bit codewords */ - { /* 11110 */ 45, 4 }, - - /* 9/10/11 bit codewords */ - { /* 11111 */ 61, 6 } -}; - -/* 2nd step table - * - * Gives size of codeword and actual data (x,y,v,w) - */ -static hcb_2_pair hcb6_2[] ICONST_ATTR = { - /* 4 bit codewords */ - { 4, 0, 0 }, - { 4, 1, 0 }, - { 4, 0, -1 }, - { 4, 0, 1 }, - { 4, -1, 0 }, - { 4, 1, 1 }, - { 4, -1, 1 }, - { 4, 1, -1 }, - { 4, -1, -1 }, - - /* 6 bit codewords */ - { 6, 2, -1 }, - { 6, 2, 1 }, - { 6, -2, 1 }, - { 6, -2, -1 }, - { 6, -2, 0 }, - { 6, -1, 2 }, - { 6, 2, 0 }, - { 6, 1, -2 }, - { 6, 1, 2 }, - { 6, 0, -2 }, - { 6, -1, -2 }, - { 6, 0, 2 }, - { 6, 2, -2 }, - { 6, -2, 2 }, - { 6, -2, -2 }, - { 6, 2, 2 }, - - /* 7 bit codewords */ - { 7, -3, 1 }, - { 7, 3, 1 }, - { 7, 3, -1 }, - { 7, -1, 3 }, - { 7, -3, -1 }, - { 7, 1, 3 }, - { 7, 1, -3 }, - { 7, -1, -3 }, - { 7, 3, 0 }, - { 7, -3, 0 }, - { 7, 0, -3 }, - { 7, 0, 3 }, - - /* 7/8 bit codewords */ - { 7, 3, 2 }, { 7, 3, 2 }, - { 8, -3, -2 }, - { 8, -2, 3 }, - { 8, 2, 3 }, - { 8, 3, -2 }, - { 8, 2, -3 }, - { 8, -2, -3 }, - - /* 8 bit codewords */ - { 8, -3, 2 }, { 8, -3, 2 }, - { 8, 3, 3 }, { 8, 3, 3 }, - { 9, 3, -3 }, - { 9, -3, -3 }, - { 9, -3, 3 }, - { 9, 1, -4 }, - { 9, -1, -4 }, - { 9, 4, 1 }, - { 9, -4, 1 }, - { 9, -4, -1 }, - { 9, 1, 4 }, - { 9, 4, -1 }, - { 9, -1, 4 }, - { 9, 0, -4 }, - - /* 9/10/11 bit codewords */ - { 9, -4, 2 }, { 9, -4, 2 }, { 9, -4, 2 }, { 9, -4, 2 }, - { 9, -4, -2 }, { 9, -4, -2 }, { 9, -4, -2 }, { 9, -4, -2 }, - { 9, 2, 4 }, { 9, 2, 4 }, { 9, 2, 4 }, { 9, 2, 4 }, - { 9, -2, -4 }, { 9, -2, -4 }, { 9, -2, -4 }, { 9, -2, -4 }, - { 9, -4, 0 }, { 9, -4, 0 }, { 9, -4, 0 }, { 9, -4, 0 }, - { 9, 4, 2 }, { 9, 4, 2 }, { 9, 4, 2 }, { 9, 4, 2 }, - { 9, 4, -2 }, { 9, 4, -2 }, { 9, 4, -2 }, { 9, 4, -2 }, - { 9, -2, 4 }, { 9, -2, 4 }, { 9, -2, 4 }, { 9, -2, 4 }, - { 9, 4, 0 }, { 9, 4, 0 }, { 9, 4, 0 }, { 9, 4, 0 }, - { 9, 2, -4 }, { 9, 2, -4 }, { 9, 2, -4 }, { 9, 2, -4 }, - { 9, 0, 4 }, { 9, 0, 4 }, { 9, 0, 4 }, { 9, 0, 4 }, - { 10, -3, -4 }, { 10, -3, -4 }, - { 10, -3, 4 }, { 10, -3, 4 }, - { 10, 3, -4 }, { 10, 3, -4 }, - { 10, 4, -3 }, { 10, 4, -3 }, - { 10, 3, 4 }, { 10, 3, 4 }, - { 10, 4, 3 }, { 10, 4, 3 }, - { 10, -4, 3 }, { 10, -4, 3 }, - { 10, -4, -3 }, { 10, -4, -3 }, - { 11, 4, 4 }, - { 11, -4, 4 }, - { 11, -4, -4 }, - { 11, 4, -4 } -}; diff --git a/apps/codecs/libfaad/codebook/hcb_7.h b/apps/codecs/libfaad/codebook/hcb_7.h deleted file mode 100644 index 3b378dc5cd..0000000000 --- a/apps/codecs/libfaad/codebook/hcb_7.h +++ /dev/null @@ -1,159 +0,0 @@ -/* -** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -** -** Any non-GPL usage of this software or parts of this software is strictly -** forbidden. -** -** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. -** -** $Id$ -**/ - -/* Binary search huffman table HCB_7 */ - - -static hcb_bin_pair hcb7[] ICONST_ATTR_FAAD_LARGE_IRAM = { - { /* 0 */ 0, { 1, 2 } }, - { /* 1 */ 1, { 0, 0 } }, - { /* 2 */ 0, { 1, 2 } }, - { /* 3 */ 0, { 2, 3 } }, - { /* 4 */ 0, { 3, 4 } }, - { /* 5 */ 1, { 1, 0 } }, - { /* 6 */ 1, { 0, 1 } }, - { /* 7 */ 0, { 2, 3 } }, - { /* 8 */ 0, { 3, 4 } }, - { /* 9 */ 1, { 1, 1 } }, - { /* 10 */ 0, { 3, 4 } }, - { /* 11 */ 0, { 4, 5 } }, - { /* 12 */ 0, { 5, 6 } }, - { /* 13 */ 0, { 6, 7 } }, - { /* 14 */ 0, { 7, 8 } }, - { /* 15 */ 0, { 8, 9 } }, - { /* 16 */ 0, { 9, 10 } }, - { /* 17 */ 0, { 10, 11 } }, - { /* 18 */ 0, { 11, 12 } }, - { /* 19 */ 1, { 2, 1 } }, - { /* 20 */ 1, { 1, 2 } }, - { /* 21 */ 1, { 2, 0 } }, - { /* 22 */ 1, { 0, 2 } }, - { /* 23 */ 0, { 8, 9 } }, - { /* 24 */ 0, { 9, 10 } }, - { /* 25 */ 0, { 10, 11 } }, - { /* 26 */ 0, { 11, 12 } }, - { /* 27 */ 0, { 12, 13 } }, - { /* 28 */ 0, { 13, 14 } }, - { /* 29 */ 0, { 14, 15 } }, - { /* 30 */ 0, { 15, 16 } }, - { /* 31 */ 1, { 3, 1 } }, - { /* 32 */ 1, { 1, 3 } }, - { /* 33 */ 1, { 2, 2 } }, - { /* 34 */ 1, { 3, 0 } }, - { /* 35 */ 1, { 0, 3 } }, - { /* 36 */ 0, { 11, 12 } }, - { /* 37 */ 0, { 12, 13 } }, - { /* 38 */ 0, { 13, 14 } }, - { /* 39 */ 0, { 14, 15 } }, - { /* 40 */ 0, { 15, 16 } }, - { /* 41 */ 0, { 16, 17 } }, - { /* 42 */ 0, { 17, 18 } }, - { /* 43 */ 0, { 18, 19 } }, - { /* 44 */ 0, { 19, 20 } }, - { /* 45 */ 0, { 20, 21 } }, - { /* 46 */ 0, { 21, 22 } }, - { /* 47 */ 1, { 2, 3 } }, - { /* 48 */ 1, { 3, 2 } }, - { /* 49 */ 1, { 1, 4 } }, - { /* 50 */ 1, { 4, 1 } }, - { /* 51 */ 1, { 1, 5 } }, - { /* 52 */ 1, { 5, 1 } }, - { /* 53 */ 1, { 3, 3 } }, - { /* 54 */ 1, { 2, 4 } }, - { /* 55 */ 1, { 0, 4 } }, - { /* 56 */ 1, { 4, 0 } }, - { /* 57 */ 0, { 12, 13 } }, - { /* 58 */ 0, { 13, 14 } }, - { /* 59 */ 0, { 14, 15 } }, - { /* 60 */ 0, { 15, 16 } }, - { /* 61 */ 0, { 16, 17 } }, - { /* 62 */ 0, { 17, 18 } }, - { /* 63 */ 0, { 18, 19 } }, - { /* 64 */ 0, { 19, 20 } }, - { /* 65 */ 0, { 20, 21 } }, - { /* 66 */ 0, { 21, 22 } }, - { /* 67 */ 0, { 22, 23 } }, - { /* 68 */ 0, { 23, 24 } }, - { /* 69 */ 1, { 4, 2 } }, - { /* 70 */ 1, { 2, 5 } }, - { /* 71 */ 1, { 5, 2 } }, - { /* 72 */ 1, { 0, 5 } }, - { /* 73 */ 1, { 6, 1 } }, - { /* 74 */ 1, { 5, 0 } }, - { /* 75 */ 1, { 1, 6 } }, - { /* 76 */ 1, { 4, 3 } }, - { /* 77 */ 1, { 3, 5 } }, - { /* 78 */ 1, { 3, 4 } }, - { /* 79 */ 1, { 5, 3 } }, - { /* 80 */ 1, { 2, 6 } }, - { /* 81 */ 1, { 6, 2 } }, - { /* 82 */ 1, { 1, 7 } }, - { /* 83 */ 0, { 10, 11 } }, - { /* 84 */ 0, { 11, 12 } }, - { /* 85 */ 0, { 12, 13 } }, - { /* 86 */ 0, { 13, 14 } }, - { /* 87 */ 0, { 14, 15 } }, - { /* 88 */ 0, { 15, 16 } }, - { /* 89 */ 0, { 16, 17 } }, - { /* 90 */ 0, { 17, 18 } }, - { /* 91 */ 0, { 18, 19 } }, - { /* 92 */ 0, { 19, 20 } }, - { /* 93 */ 1, { 3, 6 } }, - { /* 94 */ 1, { 0, 6 } }, - { /* 95 */ 1, { 6, 0 } }, - { /* 96 */ 1, { 4, 4 } }, - { /* 97 */ 1, { 7, 1 } }, - { /* 98 */ 1, { 4, 5 } }, - { /* 99 */ 1, { 7, 2 } }, - { /* 00 */ 1, { 5, 4 } }, - { /* 01 */ 1, { 6, 3 } }, - { /* 02 */ 1, { 2, 7 } }, - { /* 03 */ 1, { 7, 3 } }, - { /* 04 */ 1, { 6, 4 } }, - { /* 05 */ 1, { 5, 5 } }, - { /* 06 */ 1, { 4, 6 } }, - { /* 07 */ 1, { 3, 7 } }, - { /* 08 */ 0, { 5, 6 } }, - { /* 09 */ 0, { 6, 7 } }, - { /* 10 */ 0, { 7, 8 } }, - { /* 11 */ 0, { 8, 9 } }, - { /* 12 */ 0, { 9, 10 } }, - { /* 13 */ 1, { 7, 0 } }, - { /* 14 */ 1, { 0, 7 } }, - { /* 15 */ 1, { 6, 5 } }, - { /* 16 */ 1, { 5, 6 } }, - { /* 17 */ 1, { 7, 4 } }, - { /* 18 */ 1, { 4, 7 } }, - { /* 19 */ 1, { 5, 7 } }, - { /* 20 */ 1, { 7, 5 } }, - { /* 21 */ 0, { 2, 3 } }, - { /* 22 */ 0, { 3, 4 } }, - { /* 23 */ 1, { 7, 6 } }, - { /* 24 */ 1, { 6, 6 } }, - { /* 25 */ 1, { 6, 7 } }, - { /* 26 */ 1, { 7, 7 } } -}; diff --git a/apps/codecs/libfaad/codebook/hcb_8.h b/apps/codecs/libfaad/codebook/hcb_8.h deleted file mode 100644 index b76eb8f667..0000000000 --- a/apps/codecs/libfaad/codebook/hcb_8.h +++ /dev/null @@ -1,170 +0,0 @@ -/* -** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -** -** Any non-GPL usage of this software or parts of this software is strictly -** forbidden. -** -** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. -** -** $Id$ -**/ - -/* 2-step huffman table HCB_8 */ - - -/* 1st step: 5 bits - * 2^5 = 32 entries - * - * Used to find offset into 2nd step table and number of extra bits to get - */ -static hcb hcb8_1[] ICONST_ATTR = { - /* 3 bit codeword */ - { /* 00000 */ 0, 0 }, - { /* */ 0, 0 }, - { /* */ 0, 0 }, - { /* */ 0, 0 }, - - /* 4 bit codewords */ - { /* 00100 */ 1, 0 }, - { /* */ 1, 0 }, - { /* 00110 */ 2, 0 }, - { /* */ 2, 0 }, - { /* 01000 */ 3, 0 }, - { /* */ 3, 0 }, - { /* 01010 */ 4, 0 }, - { /* */ 4, 0 }, - { /* 01100 */ 5, 0 }, - { /* */ 5, 0 }, - - /* 5 bit codewords */ - { /* 01110 */ 6, 0 }, - { /* 01111 */ 7, 0 }, - { /* 10000 */ 8, 0 }, - { /* 10001 */ 9, 0 }, - { /* 10010 */ 10, 0 }, - { /* 10011 */ 11, 0 }, - { /* 10100 */ 12, 0 }, - - /* 6 bit codewords */ - { /* 10101 */ 13, 1 }, - { /* 10110 */ 15, 1 }, - { /* 10111 */ 17, 1 }, - { /* 11000 */ 19, 1 }, - { /* 11001 */ 21, 1 }, - - /* 7 bit codewords */ - { /* 11010 */ 23, 2 }, - { /* 11011 */ 27, 2 }, - { /* 11100 */ 31, 2 }, - - /* 7/8 bit codewords */ - { /* 11101 */ 35, 3 }, - - /* 8 bit codewords */ - { /* 11110 */ 43, 3 }, - - /* 8/9/10 bit codewords */ - { /* 11111 */ 51, 5 } -}; - -/* 2nd step table - * - * Gives size of codeword and actual data (x,y,v,w) - */ -static hcb_2_pair hcb8_2[] ICONST_ATTR = { - /* 3 bit codeword */ - { 3, 1, 1 }, - - /* 4 bit codewords */ - { 4, 2, 1 }, - { 4, 1, 0 }, - { 4, 1, 2 }, - { 4, 0, 1 }, - { 4, 2, 2 }, - - /* 5 bit codewords */ - { 5, 0, 0 }, - { 5, 2, 0 }, - { 5, 0, 2 }, - { 5, 3, 1 }, - { 5, 1, 3 }, - { 5, 3, 2 }, - { 5, 2, 3 }, - - /* 6 bit codewords */ - { 6, 3, 3 }, - { 6, 4, 1 }, - { 6, 1, 4 }, - { 6, 4, 2 }, - { 6, 2, 4 }, - { 6, 3, 0 }, - { 6, 0, 3 }, - { 6, 4, 3 }, - { 6, 3, 4 }, - { 6, 5, 2 }, - - /* 7 bit codewords */ - { 7, 5, 1 }, - { 7, 2, 5 }, - { 7, 1, 5 }, - { 7, 5, 3 }, - { 7, 3, 5 }, - { 7, 4, 4 }, - { 7, 5, 4 }, - { 7, 0, 4 }, - { 7, 4, 5 }, - { 7, 4, 0 }, - { 7, 2, 6 }, - { 7, 6, 2 }, - - /* 7/8 bit codewords */ - { 7, 6, 1 }, { 7, 6, 1 }, - { 7, 1, 6 }, { 7, 1, 6 }, - { 8, 3, 6 }, - { 8, 6, 3 }, - { 8, 5, 5 }, - { 8, 5, 0 }, - - /* 8 bit codewords */ - { 8, 6, 4 }, - { 8, 0, 5 }, - { 8, 4, 6 }, - { 8, 7, 1 }, - { 8, 7, 2 }, - { 8, 2, 7 }, - { 8, 6, 5 }, - { 8, 7, 3 }, - - /* 8/9/10 bit codewords */ - { 8, 1, 7 }, { 8, 1, 7 }, { 8, 1, 7 }, { 8, 1, 7 }, - { 8, 5, 6 }, { 8, 5, 6 }, { 8, 5, 6 }, { 8, 5, 6 }, - { 8, 3, 7 }, { 8, 3, 7 }, { 8, 3, 7 }, { 8, 3, 7 }, - { 9, 6, 6 }, { 9, 6, 6 }, - { 9, 7, 4 }, { 9, 7, 4 }, - { 9, 6, 0 }, { 9, 6, 0 }, - { 9, 4, 7 }, { 9, 4, 7 }, - { 9, 0, 6 }, { 9, 0, 6 }, - { 9, 7, 5 }, { 9, 7, 5 }, - { 9, 7, 6 }, { 9, 7, 6 }, - { 9, 6, 7 }, { 9, 6, 7 }, - { 10, 5, 7 }, - { 10, 7, 0 }, - { 10, 0, 7 }, - { 10, 7, 7 } -}; diff --git a/apps/codecs/libfaad/codebook/hcb_9.h b/apps/codecs/libfaad/codebook/hcb_9.h deleted file mode 100644 index 2932001294..0000000000 --- a/apps/codecs/libfaad/codebook/hcb_9.h +++ /dev/null @@ -1,369 +0,0 @@ -/* -** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -** -** Any non-GPL usage of this software or parts of this software is strictly -** forbidden. -** -** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. -** -** $Id$ -**/ - -/* Binary search huffman table HCB_9 */ - - -static hcb_bin_pair hcb9[] ICONST_ATTR_FAAD_LARGE_IRAM = { - { /* 0 */ 0, { 1, 2 } }, - { /* 1 */ 1, { 0, 0 } }, - { /* 2 */ 0, { 1, 2 } }, - { /* 3 */ 0, { 2, 3 } }, - { /* 4 */ 0, { 3, 4 } }, - { /* 5 */ 1, { 1, 0 } }, - { /* 6 */ 1, { 0, 1 } }, - { /* 7 */ 0, { 2, 3 } }, - { /* 8 */ 0, { 3, 4 } }, - { /* 9 */ 1, { 1, 1 } }, - { /* 10 */ 0, { 3, 4 } }, - { /* 11 */ 0, { 4, 5 } }, - { /* 12 */ 0, { 5, 6 } }, - { /* 13 */ 0, { 6, 7 } }, - { /* 14 */ 0, { 7, 8 } }, - { /* 15 */ 0, { 8, 9 } }, - { /* 16 */ 0, { 9, 10 } }, - { /* 17 */ 0, { 10, 11 } }, - { /* 18 */ 0, { 11, 12 } }, - { /* 19 */ 1, { 2, 1 } }, - { /* 20 */ 1, { 1, 2 } }, - { /* 21 */ 1, { 2, 0 } }, - { /* 22 */ 1, { 0, 2 } }, - { /* 23 */ 0, { 8, 9 } }, - { /* 24 */ 0, { 9, 10 } }, - { /* 25 */ 0, { 10, 11 } }, - { /* 26 */ 0, { 11, 12 } }, - { /* 27 */ 0, { 12, 13 } }, - { /* 28 */ 0, { 13, 14 } }, - { /* 29 */ 0, { 14, 15 } }, - { /* 30 */ 0, { 15, 16 } }, - { /* 31 */ 1, { 3, 1 } }, - { /* 32 */ 1, { 2, 2 } }, - { /* 33 */ 1, { 1, 3 } }, - { /* 34 */ 0, { 13, 14 } }, - { /* 35 */ 0, { 14, 15 } }, - { /* 36 */ 0, { 15, 16 } }, - { /* 37 */ 0, { 16, 17 } }, - { /* 38 */ 0, { 17, 18 } }, - { /* 39 */ 0, { 18, 19 } }, - { /* 40 */ 0, { 19, 20 } }, - { /* 41 */ 0, { 20, 21 } }, - { /* 42 */ 0, { 21, 22 } }, - { /* 43 */ 0, { 22, 23 } }, - { /* 44 */ 0, { 23, 24 } }, - { /* 45 */ 0, { 24, 25 } }, - { /* 46 */ 0, { 25, 26 } }, - { /* 47 */ 1, { 3, 0 } }, - { /* 48 */ 1, { 0, 3 } }, - { /* 49 */ 1, { 2, 3 } }, - { /* 50 */ 1, { 3, 2 } }, - { /* 51 */ 1, { 1, 4 } }, - { /* 52 */ 1, { 4, 1 } }, - { /* 53 */ 1, { 2, 4 } }, - { /* 54 */ 1, { 1, 5 } }, - { /* 55 */ 0, { 18, 19 } }, - { /* 56 */ 0, { 19, 20 } }, - { /* 57 */ 0, { 20, 21 } }, - { /* 58 */ 0, { 21, 22 } }, - { /* 59 */ 0, { 22, 23 } }, - { /* 60 */ 0, { 23, 24 } }, - { /* 61 */ 0, { 24, 25 } }, - { /* 62 */ 0, { 25, 26 } }, - { /* 63 */ 0, { 26, 27 } }, - { /* 64 */ 0, { 27, 28 } }, - { /* 65 */ 0, { 28, 29 } }, - { /* 66 */ 0, { 29, 30 } }, - { /* 67 */ 0, { 30, 31 } }, - { /* 68 */ 0, { 31, 32 } }, - { /* 69 */ 0, { 32, 33 } }, - { /* 70 */ 0, { 33, 34 } }, - { /* 71 */ 0, { 34, 35 } }, - { /* 72 */ 0, { 35, 36 } }, - { /* 73 */ 1, { 4, 2 } }, - { /* 74 */ 1, { 3, 3 } }, - { /* 75 */ 1, { 0, 4 } }, - { /* 76 */ 1, { 4, 0 } }, - { /* 77 */ 1, { 5, 1 } }, - { /* 78 */ 1, { 2, 5 } }, - { /* 79 */ 1, { 1, 6 } }, - { /* 80 */ 1, { 3, 4 } }, - { /* 81 */ 1, { 5, 2 } }, - { /* 82 */ 1, { 6, 1 } }, - { /* 83 */ 1, { 4, 3 } }, - { /* 84 */ 0, { 25, 26 } }, - { /* 85 */ 0, { 26, 27 } }, - { /* 86 */ 0, { 27, 28 } }, - { /* 87 */ 0, { 28, 29 } }, - { /* 88 */ 0, { 29, 30 } }, - { /* 89 */ 0, { 30, 31 } }, - { /* 90 */ 0, { 31, 32 } }, - { /* 91 */ 0, { 32, 33 } }, - { /* 92 */ 0, { 33, 34 } }, - { /* 93 */ 0, { 34, 35 } }, - { /* 94 */ 0, { 35, 36 } }, - { /* 95 */ 0, { 36, 37 } }, - { /* 96 */ 0, { 37, 38 } }, - { /* 97 */ 0, { 38, 39 } }, - { /* 98 */ 0, { 39, 40 } }, - { /* 99 */ 0, { 40, 41 } }, - { /* 00 */ 0, { 41, 42 } }, - { /* 01 */ 0, { 42, 43 } }, - { /* 02 */ 0, { 43, 44 } }, - { /* 03 */ 0, { 44, 45 } }, - { /* 04 */ 0, { 45, 46 } }, - { /* 05 */ 0, { 46, 47 } }, - { /* 06 */ 0, { 47, 48 } }, - { /* 07 */ 0, { 48, 49 } }, - { /* 08 */ 0, { 49, 50 } }, - { /* 09 */ 1, { 0, 5 } }, - { /* 10 */ 1, { 2, 6 } }, - { /* 11 */ 1, { 5, 0 } }, - { /* 12 */ 1, { 1, 7 } }, - { /* 13 */ 1, { 3, 5 } }, - { /* 14 */ 1, { 1, 8 } }, - { /* 15 */ 1, { 8, 1 } }, - { /* 16 */ 1, { 4, 4 } }, - { /* 17 */ 1, { 5, 3 } }, - { /* 18 */ 1, { 6, 2 } }, - { /* 19 */ 1, { 7, 1 } }, - { /* 20 */ 1, { 0, 6 } }, - { /* 21 */ 1, { 8, 2 } }, - { /* 22 */ 1, { 2, 8 } }, - { /* 23 */ 1, { 3, 6 } }, - { /* 24 */ 1, { 2, 7 } }, - { /* 25 */ 1, { 4, 5 } }, - { /* 26 */ 1, { 9, 1 } }, - { /* 27 */ 1, { 1, 9 } }, - { /* 28 */ 1, { 7, 2 } }, - { /* 29 */ 0, { 30, 31 } }, - { /* 30 */ 0, { 31, 32 } }, - { /* 31 */ 0, { 32, 33 } }, - { /* 32 */ 0, { 33, 34 } }, - { /* 33 */ 0, { 34, 35 } }, - { /* 34 */ 0, { 35, 36 } }, - { /* 35 */ 0, { 36, 37 } }, - { /* 36 */ 0, { 37, 38 } }, - { /* 37 */ 0, { 38, 39 } }, - { /* 38 */ 0, { 39, 40 } }, - { /* 39 */ 0, { 40, 41 } }, - { /* 40 */ 0, { 41, 42 } }, - { /* 41 */ 0, { 42, 43 } }, - { /* 42 */ 0, { 43, 44 } }, - { /* 43 */ 0, { 44, 45 } }, - { /* 44 */ 0, { 45, 46 } }, - { /* 45 */ 0, { 46, 47 } }, - { /* 46 */ 0, { 47, 48 } }, - { /* 47 */ 0, { 48, 49 } }, - { /* 48 */ 0, { 49, 50 } }, - { /* 49 */ 0, { 50, 51 } }, - { /* 50 */ 0, { 51, 52 } }, - { /* 51 */ 0, { 52, 53 } }, - { /* 52 */ 0, { 53, 54 } }, - { /* 53 */ 0, { 54, 55 } }, - { /* 54 */ 0, { 55, 56 } }, - { /* 55 */ 0, { 56, 57 } }, - { /* 56 */ 0, { 57, 58 } }, - { /* 57 */ 0, { 58, 59 } }, - { /* 58 */ 0, { 59, 60 } }, - { /* 59 */ 1, { 6, 0 } }, - { /* 60 */ 1, { 5, 4 } }, - { /* 61 */ 1, { 6, 3 } }, - { /* 62 */ 1, { 8, 3 } }, - { /* 63 */ 1, { 0, 7 } }, - { /* 64 */ 1, { 9, 2 } }, - { /* 65 */ 1, { 3, 8 } }, - { /* 66 */ 1, { 4, 6 } }, - { /* 67 */ 1, { 3, 7 } }, - { /* 68 */ 1, { 0, 8 } }, - { /* 69 */ 1, { 10, 1 } }, - { /* 70 */ 1, { 6, 4 } }, - { /* 71 */ 1, { 2, 9 } }, - { /* 72 */ 1, { 5, 5 } }, - { /* 73 */ 1, { 8, 0 } }, - { /* 74 */ 1, { 7, 0 } }, - { /* 75 */ 1, { 7, 3 } }, - { /* 76 */ 1, { 10, 2 } }, - { /* 77 */ 1, { 9, 3 } }, - { /* 78 */ 1, { 8, 4 } }, - { /* 79 */ 1, { 1, 10 } }, - { /* 80 */ 1, { 7, 4 } }, - { /* 81 */ 1, { 6, 5 } }, - { /* 82 */ 1, { 5, 6 } }, - { /* 83 */ 1, { 4, 8 } }, - { /* 84 */ 1, { 4, 7 } }, - { /* 85 */ 1, { 3, 9 } }, - { /* 86 */ 1, { 11, 1 } }, - { /* 87 */ 1, { 5, 8 } }, - { /* 88 */ 1, { 9, 0 } }, - { /* 89 */ 1, { 8, 5 } }, - { /* 90 */ 0, { 29, 30 } }, - { /* 91 */ 0, { 30, 31 } }, - { /* 92 */ 0, { 31, 32 } }, - { /* 93 */ 0, { 32, 33 } }, - { /* 94 */ 0, { 33, 34 } }, - { /* 95 */ 0, { 34, 35 } }, - { /* 96 */ 0, { 35, 36 } }, - { /* 97 */ 0, { 36, 37 } }, - { /* 98 */ 0, { 37, 38 } }, - { /* 99 */ 0, { 38, 39 } }, - { /* 00 */ 0, { 39, 40 } }, - { /* 01 */ 0, { 40, 41 } }, - { /* 02 */ 0, { 41, 42 } }, - { /* 03 */ 0, { 42, 43 } }, - { /* 04 */ 0, { 43, 44 } }, - { /* 05 */ 0, { 44, 45 } }, - { /* 06 */ 0, { 45, 46 } }, - { /* 07 */ 0, { 46, 47 } }, - { /* 08 */ 0, { 47, 48 } }, - { /* 09 */ 0, { 48, 49 } }, - { /* 10 */ 0, { 49, 50 } }, - { /* 11 */ 0, { 50, 51 } }, - { /* 12 */ 0, { 51, 52 } }, - { /* 13 */ 0, { 52, 53 } }, - { /* 14 */ 0, { 53, 54 } }, - { /* 15 */ 0, { 54, 55 } }, - { /* 16 */ 0, { 55, 56 } }, - { /* 17 */ 0, { 56, 57 } }, - { /* 18 */ 0, { 57, 58 } }, - { /* 19 */ 1, { 10, 3 } }, - { /* 20 */ 1, { 2, 10 } }, - { /* 21 */ 1, { 0, 9 } }, - { /* 22 */ 1, { 11, 2 } }, - { /* 23 */ 1, { 9, 4 } }, - { /* 24 */ 1, { 6, 6 } }, - { /* 25 */ 1, { 12, 1 } }, - { /* 26 */ 1, { 4, 9 } }, - { /* 27 */ 1, { 8, 6 } }, - { /* 28 */ 1, { 1, 11 } }, - { /* 29 */ 1, { 9, 5 } }, - { /* 30 */ 1, { 10, 4 } }, - { /* 31 */ 1, { 5, 7 } }, - { /* 32 */ 1, { 7, 5 } }, - { /* 33 */ 1, { 2, 11 } }, - { /* 34 */ 1, { 1, 12 } }, - { /* 35 */ 1, { 12, 2 } }, - { /* 36 */ 1, { 11, 3 } }, - { /* 37 */ 1, { 3, 10 } }, - { /* 38 */ 1, { 5, 9 } }, - { /* 39 */ 1, { 6, 7 } }, - { /* 40 */ 1, { 8, 7 } }, - { /* 41 */ 1, { 11, 4 } }, - { /* 42 */ 1, { 0, 10 } }, - { /* 43 */ 1, { 7, 6 } }, - { /* 44 */ 1, { 12, 3 } }, - { /* 45 */ 1, { 10, 0 } }, - { /* 46 */ 1, { 10, 5 } }, - { /* 47 */ 1, { 4, 10 } }, - { /* 48 */ 1, { 6, 8 } }, - { /* 49 */ 1, { 2, 12 } }, - { /* 50 */ 1, { 9, 6 } }, - { /* 51 */ 1, { 9, 7 } }, - { /* 52 */ 1, { 4, 11 } }, - { /* 53 */ 1, { 11, 0 } }, - { /* 54 */ 1, { 6, 9 } }, - { /* 55 */ 1, { 3, 11 } }, - { /* 56 */ 1, { 5, 10 } }, - { /* 57 */ 0, { 20, 21 } }, - { /* 58 */ 0, { 21, 22 } }, - { /* 59 */ 0, { 22, 23 } }, - { /* 60 */ 0, { 23, 24 } }, - { /* 61 */ 0, { 24, 25 } }, - { /* 62 */ 0, { 25, 26 } }, - { /* 63 */ 0, { 26, 27 } }, - { /* 64 */ 0, { 27, 28 } }, - { /* 65 */ 0, { 28, 29 } }, - { /* 66 */ 0, { 29, 30 } }, - { /* 67 */ 0, { 30, 31 } }, - { /* 68 */ 0, { 31, 32 } }, - { /* 69 */ 0, { 32, 33 } }, - { /* 70 */ 0, { 33, 34 } }, - { /* 71 */ 0, { 34, 35 } }, - { /* 72 */ 0, { 35, 36 } }, - { /* 73 */ 0, { 36, 37 } }, - { /* 74 */ 0, { 37, 38 } }, - { /* 75 */ 0, { 38, 39 } }, - { /* 76 */ 0, { 39, 40 } }, - { /* 77 */ 1, { 8, 8 } }, - { /* 78 */ 1, { 7, 8 } }, - { /* 79 */ 1, { 12, 5 } }, - { /* 80 */ 1, { 3, 12 } }, - { /* 81 */ 1, { 11, 5 } }, - { /* 82 */ 1, { 7, 7 } }, - { /* 83 */ 1, { 12, 4 } }, - { /* 84 */ 1, { 11, 6 } }, - { /* 85 */ 1, { 10, 6 } }, - { /* 86 */ 1, { 4, 12 } }, - { /* 87 */ 1, { 7, 9 } }, - { /* 88 */ 1, { 5, 11 } }, - { /* 89 */ 1, { 0, 11 } }, - { /* 90 */ 1, { 12, 6 } }, - { /* 91 */ 1, { 6, 10 } }, - { /* 92 */ 1, { 12, 0 } }, - { /* 93 */ 1, { 10, 7 } }, - { /* 94 */ 1, { 5, 12 } }, - { /* 95 */ 1, { 7, 10 } }, - { /* 96 */ 1, { 9, 8 } }, - { /* 97 */ 1, { 0, 12 } }, - { /* 98 */ 1, { 11, 7 } }, - { /* 99 */ 1, { 8, 9 } }, - { /* 00 */ 1, { 9, 9 } }, - { /* 01 */ 1, { 10, 8 } }, - { /* 02 */ 1, { 7, 11 } }, - { /* 03 */ 1, { 12, 7 } }, - { /* 04 */ 1, { 6, 11 } }, - { /* 05 */ 1, { 8, 11 } }, - { /* 06 */ 1, { 11, 8 } }, - { /* 07 */ 1, { 7, 12 } }, - { /* 08 */ 1, { 6, 12 } }, - { /* 09 */ 0, { 8, 9 } }, - { /* 10 */ 0, { 9, 10 } }, - { /* 11 */ 0, { 10, 11 } }, - { /* 12 */ 0, { 11, 12 } }, - { /* 13 */ 0, { 12, 13 } }, - { /* 14 */ 0, { 13, 14 } }, - { /* 15 */ 0, { 14, 15 } }, - { /* 16 */ 0, { 15, 16 } }, - { /* 17 */ 1, { 8, 10 } }, - { /* 18 */ 1, { 10, 9 } }, - { /* 19 */ 1, { 8, 12 } }, - { /* 20 */ 1, { 9, 10 } }, - { /* 21 */ 1, { 9, 11 } }, - { /* 22 */ 1, { 9, 12 } }, - { /* 23 */ 1, { 10, 11 } }, - { /* 24 */ 1, { 12, 9 } }, - { /* 25 */ 1, { 10, 10 } }, - { /* 26 */ 1, { 11, 9 } }, - { /* 27 */ 1, { 12, 8 } }, - { /* 28 */ 1, { 11, 10 } }, - { /* 29 */ 1, { 12, 10 } }, - { /* 30 */ 1, { 12, 11 } }, - { /* 31 */ 0, { 2, 3 } }, - { /* 32 */ 0, { 3, 4 } }, - { /* 33 */ 1, { 10, 12 } }, - { /* 34 */ 1, { 11, 11 } }, - { /* 35 */ 1, { 11, 12 } }, - { /* 36 */ 1, { 12, 12 } } -}; diff --git a/apps/codecs/libfaad/codebook/hcb_sf.h b/apps/codecs/libfaad/codebook/hcb_sf.h deleted file mode 100644 index 66762e2fce..0000000000 --- a/apps/codecs/libfaad/codebook/hcb_sf.h +++ /dev/null @@ -1,273 +0,0 @@ -/* -** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -** -** Any non-GPL usage of this software or parts of this software is strictly -** forbidden. -** -** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. -** -** $Id$ -**/ - -/* Binary search huffman table HCB_SF */ - - -static uint8_t hcb_sf[][2] ICONST_ATTR_FAAD_LARGE_IRAM = { - { /* 0 */ 1, 2 }, - { /* 1 */ 60, 0 }, - { /* 2 */ 1, 2 }, - { /* 3 */ 2, 3 }, - { /* 4 */ 3, 4 }, - { /* 5 */ 59, 0 }, - { /* 6 */ 3, 4 }, - { /* 7 */ 4, 5 }, - { /* 8 */ 5, 6 }, - { /* 9 */ 61, 0 }, - { /* 10 */ 58, 0 }, - { /* 11 */ 62, 0 }, - { /* 12 */ 3, 4 }, - { /* 13 */ 4, 5 }, - { /* 14 */ 5, 6 }, - { /* 15 */ 57, 0 }, - { /* 16 */ 63, 0 }, - { /* 17 */ 4, 5 }, - { /* 18 */ 5, 6 }, - { /* 19 */ 6, 7 }, - { /* 20 */ 7, 8 }, - { /* 21 */ 56, 0 }, - { /* 22 */ 64, 0 }, - { /* 23 */ 55, 0 }, - { /* 24 */ 65, 0 }, - { /* 25 */ 4, 5 }, - { /* 26 */ 5, 6 }, - { /* 27 */ 6, 7 }, - { /* 28 */ 7, 8 }, - { /* 29 */ 66, 0 }, - { /* 30 */ 54, 0 }, - { /* 31 */ 67, 0 }, - { /* 32 */ 5, 6 }, - { /* 33 */ 6, 7 }, - { /* 34 */ 7, 8 }, - { /* 35 */ 8, 9 }, - { /* 36 */ 9, 10 }, - { /* 37 */ 53, 0 }, - { /* 38 */ 68, 0 }, - { /* 39 */ 52, 0 }, - { /* 40 */ 69, 0 }, - { /* 41 */ 51, 0 }, - { /* 42 */ 5, 6 }, - { /* 43 */ 6, 7 }, - { /* 44 */ 7, 8 }, - { /* 45 */ 8, 9 }, - { /* 46 */ 9, 10 }, - { /* 47 */ 70, 0 }, - { /* 48 */ 50, 0 }, - { /* 49 */ 49, 0 }, - { /* 50 */ 71, 0 }, - { /* 51 */ 6, 7 }, - { /* 52 */ 7, 8 }, - { /* 53 */ 8, 9 }, - { /* 54 */ 9, 10 }, - { /* 55 */ 10, 11 }, - { /* 56 */ 11, 12 }, - { /* 57 */ 72, 0 }, - { /* 58 */ 48, 0 }, - { /* 59 */ 73, 0 }, - { /* 60 */ 47, 0 }, - { /* 61 */ 74, 0 }, - { /* 62 */ 46, 0 }, - { /* 63 */ 6, 7 }, - { /* 64 */ 7, 8 }, - { /* 65 */ 8, 9 }, - { /* 66 */ 9, 10 }, - { /* 67 */ 10, 11 }, - { /* 68 */ 11, 12 }, - { /* 69 */ 76, 0 }, - { /* 70 */ 75, 0 }, - { /* 71 */ 77, 0 }, - { /* 72 */ 78, 0 }, - { /* 73 */ 45, 0 }, - { /* 74 */ 43, 0 }, - { /* 75 */ 6, 7 }, - { /* 76 */ 7, 8 }, - { /* 77 */ 8, 9 }, - { /* 78 */ 9, 10 }, - { /* 79 */ 10, 11 }, - { /* 80 */ 11, 12 }, - { /* 81 */ 44, 0 }, - { /* 82 */ 79, 0 }, - { /* 83 */ 42, 0 }, - { /* 84 */ 41, 0 }, - { /* 85 */ 80, 0 }, - { /* 86 */ 40, 0 }, - { /* 87 */ 6, 7 }, - { /* 88 */ 7, 8 }, - { /* 89 */ 8, 9 }, - { /* 90 */ 9, 10 }, - { /* 91 */ 10, 11 }, - { /* 92 */ 11, 12 }, - { /* 93 */ 81, 0 }, - { /* 94 */ 39, 0 }, - { /* 95 */ 82, 0 }, - { /* 96 */ 38, 0 }, - { /* 97 */ 83, 0 }, - { /* 98 */ 7, 8 }, - { /* 99 */ 8, 9 }, - { /* 00 */ 9, 10 }, - { /* 01 */ 10, 11 }, - { /* 02 */ 11, 12 }, - { /* 03 */ 12, 13 }, - { /* 04 */ 13, 14 }, - { /* 05 */ 37, 0 }, - { /* 06 */ 35, 0 }, - { /* 07 */ 85, 0 }, - { /* 08 */ 33, 0 }, - { /* 09 */ 36, 0 }, - { /* 10 */ 34, 0 }, - { /* 11 */ 84, 0 }, - { /* 12 */ 32, 0 }, - { /* 13 */ 6, 7 }, - { /* 14 */ 7, 8 }, - { /* 15 */ 8, 9 }, - { /* 16 */ 9, 10 }, - { /* 17 */ 10, 11 }, - { /* 18 */ 11, 12 }, - { /* 19 */ 87, 0 }, - { /* 20 */ 89, 0 }, - { /* 21 */ 30, 0 }, - { /* 22 */ 31, 0 }, - { /* 23 */ 8, 9 }, - { /* 24 */ 9, 10 }, - { /* 25 */ 10, 11 }, - { /* 26 */ 11, 12 }, - { /* 27 */ 12, 13 }, - { /* 28 */ 13, 14 }, - { /* 29 */ 14, 15 }, - { /* 30 */ 15, 16 }, - { /* 31 */ 86, 0 }, - { /* 32 */ 29, 0 }, - { /* 33 */ 26, 0 }, - { /* 34 */ 27, 0 }, - { /* 35 */ 28, 0 }, - { /* 36 */ 24, 0 }, - { /* 37 */ 88, 0 }, - { /* 38 */ 9, 10 }, - { /* 39 */ 10, 11 }, - { /* 40 */ 11, 12 }, - { /* 41 */ 12, 13 }, - { /* 42 */ 13, 14 }, - { /* 43 */ 14, 15 }, - { /* 44 */ 15, 16 }, - { /* 45 */ 16, 17 }, - { /* 46 */ 17, 18 }, - { /* 47 */ 25, 0 }, - { /* 48 */ 22, 0 }, - { /* 49 */ 23, 0 }, - { /* 50 */ 15, 16 }, - { /* 51 */ 16, 17 }, - { /* 52 */ 17, 18 }, - { /* 53 */ 18, 19 }, - { /* 54 */ 19, 20 }, - { /* 55 */ 20, 21 }, - { /* 56 */ 21, 22 }, - { /* 57 */ 22, 23 }, - { /* 58 */ 23, 24 }, - { /* 59 */ 24, 25 }, - { /* 60 */ 25, 26 }, - { /* 61 */ 26, 27 }, - { /* 62 */ 27, 28 }, - { /* 63 */ 28, 29 }, - { /* 64 */ 29, 30 }, - { /* 65 */ 90, 0 }, - { /* 66 */ 21, 0 }, - { /* 67 */ 19, 0 }, - { /* 68 */ 3, 0 }, - { /* 69 */ 1, 0 }, - { /* 70 */ 2, 0 }, - { /* 71 */ 0, 0 }, - { /* 72 */ 23, 24 }, - { /* 73 */ 24, 25 }, - { /* 74 */ 25, 26 }, - { /* 75 */ 26, 27 }, - { /* 76 */ 27, 28 }, - { /* 77 */ 28, 29 }, - { /* 78 */ 29, 30 }, - { /* 79 */ 30, 31 }, - { /* 80 */ 31, 32 }, - { /* 81 */ 32, 33 }, - { /* 82 */ 33, 34 }, - { /* 83 */ 34, 35 }, - { /* 84 */ 35, 36 }, - { /* 85 */ 36, 37 }, - { /* 86 */ 37, 38 }, - { /* 87 */ 38, 39 }, - { /* 88 */ 39, 40 }, - { /* 89 */ 40, 41 }, - { /* 90 */ 41, 42 }, - { /* 91 */ 42, 43 }, - { /* 92 */ 43, 44 }, - { /* 93 */ 44, 45 }, - { /* 94 */ 45, 46 }, - { /* 95 */ 98, 0 }, - { /* 96 */ 99, 0 }, - { /* 97 */ 100, 0 }, - { /* 98 */ 101, 0 }, - { /* 99 */ 102, 0 }, - { /* 00 */ 117, 0 }, - { /* 01 */ 97, 0 }, - { /* 02 */ 91, 0 }, - { /* 03 */ 92, 0 }, - { /* 04 */ 93, 0 }, - { /* 05 */ 94, 0 }, - { /* 06 */ 95, 0 }, - { /* 07 */ 96, 0 }, - { /* 08 */ 104, 0 }, - { /* 09 */ 111, 0 }, - { /* 10 */ 112, 0 }, - { /* 11 */ 113, 0 }, - { /* 12 */ 114, 0 }, - { /* 13 */ 115, 0 }, - { /* 14 */ 116, 0 }, - { /* 15 */ 110, 0 }, - { /* 16 */ 105, 0 }, - { /* 17 */ 106, 0 }, - { /* 18 */ 107, 0 }, - { /* 19 */ 108, 0 }, - { /* 20 */ 109, 0 }, - { /* 21 */ 118, 0 }, - { /* 22 */ 6, 0 }, - { /* 23 */ 8, 0 }, - { /* 24 */ 9, 0 }, - { /* 25 */ 10, 0 }, - { /* 26 */ 5, 0 }, - { /* 27 */ 103, 0 }, - { /* 28 */ 120, 0 }, - { /* 29 */ 119, 0 }, - { /* 30 */ 4, 0 }, - { /* 31 */ 7, 0 }, - { /* 32 */ 15, 0 }, - { /* 33 */ 16, 0 }, - { /* 34 */ 18, 0 }, - { /* 35 */ 20, 0 }, - { /* 36 */ 17, 0 }, - { /* 37 */ 11, 0 }, - { /* 38 */ 12, 0 }, - { /* 39 */ 14, 0 }, - { /* 40 */ 13, 0 } -}; diff --git a/apps/codecs/libfaad/common.c b/apps/codecs/libfaad/common.c deleted file mode 100644 index bedf56a212..0000000000 --- a/apps/codecs/libfaad/common.c +++ /dev/null @@ -1,440 +0,0 @@ -/* -** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -** -** Any non-GPL usage of this software or parts of this software is strictly -** forbidden. -** -** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. -** -** $Id$ -**/ - -/* just some common functions that could be used anywhere */ - -#include "common.h" -#include "structs.h" - -#include -#include "syntax.h" - - -/* Returns the sample rate index based on the samplerate */ -uint8_t get_sr_index(const uint32_t samplerate) -{ - if (92017 <= samplerate) return 0; - if (75132 <= samplerate) return 1; - if (55426 <= samplerate) return 2; - if (46009 <= samplerate) return 3; - if (37566 <= samplerate) return 4; - if (27713 <= samplerate) return 5; - if (23004 <= samplerate) return 6; - if (18783 <= samplerate) return 7; - if (13856 <= samplerate) return 8; - if (11502 <= samplerate) return 9; - if (9391 <= samplerate) return 10; - if (16428320 <= samplerate) return 11; - - return 11; -} - -/* Returns the sample rate based on the sample rate index */ -uint32_t get_sample_rate(const uint8_t sr_index) -{ - static const uint32_t sample_rates[] = - { - 96000, 88200, 64000, 48000, 44100, 32000, - 24000, 22050, 16000, 12000, 11025, 8000 - }; - - if (sr_index < 12) - return sample_rates[sr_index]; - - return 0; -} - -uint8_t max_pred_sfb(const uint8_t sr_index) -{ - static const uint8_t pred_sfb_max[] = - { - 33, 33, 38, 40, 40, 40, 41, 41, 37, 37, 37, 34 - }; - - - if (sr_index < 12) - return pred_sfb_max[sr_index]; - - return 0; -} - -uint8_t max_tns_sfb(const uint8_t sr_index, const uint8_t object_type, - const uint8_t is_short) -{ - /* entry for each sampling rate - * 1 Main/LC long window - * 2 Main/LC short window - * 3 SSR long window - * 4 SSR short window - */ - static const uint8_t tns_sbf_max[][4] = - { - {31, 9, 28, 7}, /* 96000 */ - {31, 9, 28, 7}, /* 88200 */ - {34, 10, 27, 7}, /* 64000 */ - {40, 14, 26, 6}, /* 48000 */ - {42, 14, 26, 6}, /* 44100 */ - {51, 14, 26, 6}, /* 32000 */ - {46, 14, 29, 7}, /* 24000 */ - {46, 14, 29, 7}, /* 22050 */ - {42, 14, 23, 8}, /* 16000 */ - {42, 14, 23, 8}, /* 12000 */ - {42, 14, 23, 8}, /* 11025 */ - {39, 14, 19, 7}, /* 8000 */ - {39, 14, 19, 7}, /* 7350 */ - {0,0,0,0}, - {0,0,0,0}, - {0,0,0,0} - }; - uint8_t i = 0; - - if (is_short) i++; - if (object_type == SSR) i += 2; - - return tns_sbf_max[sr_index][i]; -} - -/* Returns 0 if an object type is decodable, otherwise returns -1 */ -int8_t can_decode_ot(const uint8_t object_type) -{ - switch (object_type) - { - case LC: - return 0; - case MAIN: -#ifdef MAIN_DEC - return 0; -#else - return -1; -#endif - case SSR: -#ifdef SSR_DEC - return 0; -#else - return -1; -#endif - case LTP: -#ifdef LTP_DEC - return 0; -#else - return -1; -#endif - - /* ER object types */ -#ifdef ERROR_RESILIENCE - case ER_LC: -#ifdef DRM - case DRM_ER_LC: -#endif - return 0; - case ER_LTP: -#ifdef LTP_DEC - return 0; -#else - return -1; -#endif - case LD: -#ifdef LD_DEC - return 0; -#else - return -1; -#endif -#endif - } - - return -1; -} - -static const uint8_t Parity [256] = { // parity - 0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1, - 1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0, - 1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0, - 0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1, - 1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0, - 0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1, - 0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1, - 1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0 -}; - -static uint32_t __r1 = 1; -static uint32_t __r2 = 1; - - -/* - * This is a simple random number generator with good quality for audio purposes. - * It consists of two polycounters with opposite rotation direction and different - * periods. The periods are coprime, so the total period is the product of both. - * - * ------------------------------------------------------------------------------------------------- - * +-> |31:30:29:28:27:26:25:24:23:22:21:20:19:18:17:16:15:14:13:12:11:10: 9: 8: 7: 6: 5: 4: 3: 2: 1: 0| - * | ------------------------------------------------------------------------------------------------- - * | | | | | | | - * | +--+--+--+-XOR-+--------+ - * | | - * +--------------------------------------------------------------------------------------+ - * - * ------------------------------------------------------------------------------------------------- - * |31:30:29:28:27:26:25:24:23:22:21:20:19:18:17:16:15:14:13:12:11:10: 9: 8: 7: 6: 5: 4: 3: 2: 1: 0| <-+ - * ------------------------------------------------------------------------------------------------- | - * | | | | | - * +--+----XOR----+--+ | - * | | - * +----------------------------------------------------------------------------------------+ - * - * - * The first has an period of 3*5*17*257*65537, the second of 7*47*73*178481, - * which gives a period of 18.410.713.077.675.721.215. The result is the - * XORed values of both generators. - */ -uint32_t random_int(void) -{ - uint32_t t1, t2, t3, t4; - - t3 = t1 = __r1; t4 = t2 = __r2; // Parity calculation is done via table lookup, this is also available - t1 &= 0xF5; t2 >>= 25; // on CPUs without parity, can be implemented in C and avoid unpredictable - t1 = Parity [t1]; t2 &= 0x63; // jumps and slow rotate through the carry flag operations. - t1 <<= 31; t2 = Parity [t2]; - - return (__r1 = (t3 >> 1) | t1 ) ^ (__r2 = (t4 + t4) | t2 ); -} - -#define floor_log2(x) bs_generic(x, BS_LOG2) - -#ifdef FIXED_POINT - -#define TABLE_BITS 6 -/* just take the maximum number of bits for interpolation */ -#define INTERP_BITS (REAL_BITS-TABLE_BITS) - -static const real_t pow2_tab[] ICONST_ATTR = { - REAL_CONST(1.000000000000000), REAL_CONST(1.010889286051701), REAL_CONST(1.021897148654117), - REAL_CONST(1.033024879021228), REAL_CONST(1.044273782427414), REAL_CONST(1.055645178360557), - REAL_CONST(1.067140400676824), REAL_CONST(1.078760797757120), REAL_CONST(1.090507732665258), - REAL_CONST(1.102382583307841), REAL_CONST(1.114386742595892), REAL_CONST(1.126521618608242), - REAL_CONST(1.138788634756692), REAL_CONST(1.151189229952983), REAL_CONST(1.163724858777578), - REAL_CONST(1.176396991650281), REAL_CONST(1.189207115002721), REAL_CONST(1.202156731452703), - REAL_CONST(1.215247359980469), REAL_CONST(1.228480536106870), REAL_CONST(1.241857812073484), - REAL_CONST(1.255380757024691), REAL_CONST(1.269050957191733), REAL_CONST(1.282870016078778), - REAL_CONST(1.296839554651010), REAL_CONST(1.310961211524764), REAL_CONST(1.325236643159741), - REAL_CONST(1.339667524053303), REAL_CONST(1.354255546936893), REAL_CONST(1.369002422974591), - REAL_CONST(1.383909881963832), REAL_CONST(1.398979672538311), REAL_CONST(1.414213562373095), - REAL_CONST(1.429613338391970), REAL_CONST(1.445180806977047), REAL_CONST(1.460917794180647), - REAL_CONST(1.476826145939499), REAL_CONST(1.492907728291265), REAL_CONST(1.509164427593423), - REAL_CONST(1.525598150744538), REAL_CONST(1.542210825407941), REAL_CONST(1.559004400237837), - REAL_CONST(1.575980845107887), REAL_CONST(1.593142151342267), REAL_CONST(1.610490331949254), - REAL_CONST(1.628027421857348), REAL_CONST(1.645755478153965), REAL_CONST(1.663676580326736), - REAL_CONST(1.681792830507429), REAL_CONST(1.700106353718524), REAL_CONST(1.718619298122478), - REAL_CONST(1.737333835273706), REAL_CONST(1.756252160373300), REAL_CONST(1.775376492526521), - REAL_CONST(1.794709075003107), REAL_CONST(1.814252175500399), REAL_CONST(1.834008086409342), - REAL_CONST(1.853979125083386), REAL_CONST(1.874167634110300), REAL_CONST(1.894575981586966), - REAL_CONST(1.915206561397147), REAL_CONST(1.936061793492294), REAL_CONST(1.957144124175400), - REAL_CONST(1.978456026387951), REAL_CONST(2.000000000000000) -}; - -static const real_t log2_tab[] ICONST_ATTR_FAAD_LARGE_IRAM = { - REAL_CONST(0.000000000000000), REAL_CONST(0.022367813028455), REAL_CONST(0.044394119358453), - REAL_CONST(0.066089190457772), REAL_CONST(0.087462841250339), REAL_CONST(0.108524456778169), - REAL_CONST(0.129283016944966), REAL_CONST(0.149747119504682), REAL_CONST(0.169925001442312), - REAL_CONST(0.189824558880017), REAL_CONST(0.209453365628950), REAL_CONST(0.228818690495881), - REAL_CONST(0.247927513443585), REAL_CONST(0.266786540694901), REAL_CONST(0.285402218862248), - REAL_CONST(0.303780748177103), REAL_CONST(0.321928094887362), REAL_CONST(0.339850002884625), - REAL_CONST(0.357552004618084), REAL_CONST(0.375039431346925), REAL_CONST(0.392317422778760), - REAL_CONST(0.409390936137702), REAL_CONST(0.426264754702098), REAL_CONST(0.442943495848728), - REAL_CONST(0.459431618637297), REAL_CONST(0.475733430966398), REAL_CONST(0.491853096329675), - REAL_CONST(0.507794640198696), REAL_CONST(0.523561956057013), REAL_CONST(0.539158811108031), - REAL_CONST(0.554588851677637), REAL_CONST(0.569855608330948), REAL_CONST(0.584962500721156), - REAL_CONST(0.599912842187128), REAL_CONST(0.614709844115208), REAL_CONST(0.629356620079610), - REAL_CONST(0.643856189774725), REAL_CONST(0.658211482751795), REAL_CONST(0.672425341971496), - REAL_CONST(0.686500527183218), REAL_CONST(0.700439718141092), REAL_CONST(0.714245517666123), - REAL_CONST(0.727920454563199), REAL_CONST(0.741466986401147), REAL_CONST(0.754887502163469), - REAL_CONST(0.768184324776926), REAL_CONST(0.781359713524660), REAL_CONST(0.794415866350106), - REAL_CONST(0.807354922057604), REAL_CONST(0.820178962415188), REAL_CONST(0.832890014164742), - REAL_CONST(0.845490050944375), REAL_CONST(0.857980995127572), REAL_CONST(0.870364719583405), - REAL_CONST(0.882643049361841), REAL_CONST(0.894817763307943), REAL_CONST(0.906890595608519), - REAL_CONST(0.918863237274595), REAL_CONST(0.930737337562886), REAL_CONST(0.942514505339240), - REAL_CONST(0.954196310386875), REAL_CONST(0.965784284662087), REAL_CONST(0.977279923499917), - REAL_CONST(0.988684686772166), REAL_CONST(1.000000000000000) -}; - -uint32_t pow2_fix(real_t val) -{ - uint32_t x1, x2; - uint32_t errcorr; - uint32_t index_frac; - uint32_t retval; - int32_t whole = (val >> REAL_BITS); - - /* rest = [0..1] */ - int32_t rest = val - (whole << REAL_BITS); - - /* index into pow2_tab */ - int32_t index = (rest >> (REAL_BITS-TABLE_BITS)) & ((1<> (REAL_BITS-TABLE_BITS-INTERP_BITS); - index_frac = index_frac & ((1<= 0) - retval = REAL_CONST(1) << whole; - else - retval = REAL_CONST(1) >> -whole; - - x1 = pow2_tab[index ]; - x2 = pow2_tab[index + 1]; - errcorr = (index_frac*(x2-x1)) >> INTERP_BITS; - - retval = MUL_R(retval, (errcorr + x1)); - - return retval; -} - -uint32_t pow2_int(real_t val) -{ - uint32_t x1, x2; - uint32_t errcorr; - uint32_t index_frac; - uint32_t retval; - int32_t whole = (val >> REAL_BITS); - - /* rest = [0..1] */ - int32_t rest = val - (whole << REAL_BITS); - - /* index into pow2_tab */ - int32_t index = (rest >> (REAL_BITS-TABLE_BITS)) & ((1<> (REAL_BITS-TABLE_BITS-INTERP_BITS); - index_frac = index_frac & ((1<= 0) - retval = 1 << whole; - else - retval = 1 >> -whole; - - x1 = pow2_tab[index ]; - x2 = pow2_tab[index + 1]; - errcorr = (index_frac*(x2-x1)) >> INTERP_BITS; - - retval = MUL_R(retval, (errcorr + x1)); - - return retval; -} - -/* ld(x) = ld(x*y/y) = ld(x/y) + ld(y), with y=2^N and [1 <= (x/y) < 2] */ -int32_t log2_int(uint32_t val) -{ - uint32_t frac; - int32_t exp = 0; - uint32_t index; - uint32_t index_frac; - uint32_t x1, x2; - uint32_t errcorr; - - /* error */ - if (val == 0) - return -10000; - - exp = floor_log2(val); - exp -= REAL_BITS; - - /* frac = [1..2] */ - if (exp >= 0) - frac = val >> exp; - else - frac = val << -exp; - - /* index in the log2 table */ - index = frac >> (REAL_BITS-TABLE_BITS); - - /* leftover part for linear interpolation */ - index_frac = frac & ((1<<(REAL_BITS-TABLE_BITS))-1); - - /* leave INTERP_BITS bits */ - index_frac = index_frac >> (REAL_BITS-TABLE_BITS-INTERP_BITS); - - x1 = log2_tab[index & ((1<> INTERP_BITS; - - return ((exp+REAL_BITS) << REAL_BITS) + errcorr + x1; -} - -/* ld(x) = ld(x*y/y) = ld(x/y) + ld(y), with y=2^N and [1 <= (x/y) < 2] */ -real_t log2_fix(uint32_t val) -{ - uint32_t frac; - int8_t exp = 0; - uint32_t index; - uint32_t index_frac; - uint32_t x1, x2; - uint32_t errcorr; - - /* error */ - if (val == 0) - return -100000; - - exp = floor_log2(val); - exp -= REAL_BITS; - - /* frac = [1..2] */ - if (exp >= 0) - frac = val >> exp; - else - frac = val << -exp; - - /* index in the log2 table */ - index = frac >> (REAL_BITS-TABLE_BITS); - - /* leftover part for linear interpolation */ - index_frac = frac & ((1<<(REAL_BITS-TABLE_BITS))-1); - - /* leave INTERP_BITS bits */ - index_frac = index_frac >> (REAL_BITS-TABLE_BITS-INTERP_BITS); - - x1 = log2_tab[index & ((1<> INTERP_BITS; - - return (exp << REAL_BITS) + errcorr + x1; -} -#endif diff --git a/apps/codecs/libfaad/common.h b/apps/codecs/libfaad/common.h deleted file mode 100644 index 720042b4aa..0000000000 --- a/apps/codecs/libfaad/common.h +++ /dev/null @@ -1,475 +0,0 @@ -/* -** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -** -** Any non-GPL usage of this software or parts of this software is strictly -** forbidden. -** -** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. -** -** $Id$ -**/ - -#ifndef __COMMON_H__ -#define __COMMON_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -#include "faad_config.h" -#include "codeclib.h" - -extern struct codec_api* ci; - -#if defined(DEBUG) || defined(SIMULATOR) -#undef DEBUGF -#define DEBUGF ci->debugf -#else -#define DEBUGF(...) -#endif - -#ifdef ROCKBOX_HAS_LOGF -#undef LOGF -#define LOGF ci->logf -#else -#define LOGF(...) -#endif - -#if (CONFIG_CPU == MCF5250) -/* Enough IRAM but performance suffers with ICODE_ATTR. */ -#define IBSS_ATTR_FAAD_LARGE_IRAM IBSS_ATTR -#define ICODE_ATTR_FAAD_LARGE_IRAM -#define ICONST_ATTR_FAAD_LARGE_IRAM ICONST_ATTR -#define IBSS_ATTR_FAAD_XLR - -#elif (CONFIG_CPU == PP5022) || (CONFIG_CPU == PP5024) -/* Enough IRAM to move additional data and code to it. */ -#define IBSS_ATTR_FAAD_LARGE_IRAM IBSS_ATTR -#define ICODE_ATTR_FAAD_LARGE_IRAM ICODE_ATTR -#define ICONST_ATTR_FAAD_LARGE_IRAM ICONST_ATTR -#define IBSS_ATTR_FAAD_XLR - -#elif defined(CPU_S5L870X) -/* Very large IRAM. Move even more data to it. */ -#define IBSS_ATTR_FAAD_LARGE_IRAM IBSS_ATTR -#define ICODE_ATTR_FAAD_LARGE_IRAM ICODE_ATTR -#define ICONST_ATTR_FAAD_LARGE_IRAM ICONST_ATTR -#define IBSS_ATTR_FAAD_XLR IBSS_ATTR -#define HAVE_FAAD_XLR_IN_IRAM - -#else -/* Not enough IRAM available. */ -#define IBSS_ATTR_FAAD_LARGE_IRAM -#define ICODE_ATTR_FAAD_LARGE_IRAM -#define ICONST_ATTR_FAAD_LARGE_IRAM -#define IBSS_ATTR_FAAD_XLR -#endif - -/* Used to allocate several SBR + PS arrays and variables statically. */ -//#define FAAD_STATIC_ALLOC - -#define INLINE __inline -#if 0 //defined(_WIN32) && !defined(_WIN32_WCE) -#define ALIGN __declspec(align(16)) -#else -#define ALIGN -#endif - -#ifndef max -#define max(a, b) (((a) > (b)) ? (a) : (b)) -#endif -#ifndef min -#define min(a, b) (((a) < (b)) ? (a) : (b)) -#endif - -/* COMPILE TIME DEFINITIONS */ - -/* use double precision */ -/* #define USE_DOUBLE_PRECISION */ -/* use fixed point reals */ -#define FIXED_POINT -#define BIG_IQ_TABLE /* BIG_IQ_TABLE results in faster requantization */ - -/* Use if target platform has address generators with autoincrement */ -//#define PREFER_POINTERS - -#define ERROR_RESILIENCE - - -/* Allow decoding of MAIN profile AAC */ -#define MAIN_DEC -/* Allow decoding of SSR profile AAC */ -#define SSR_DEC -/* Allow decoding of LTP profile AAC */ -#define LTP_DEC -/* Allow decoding of LD profile AAC */ -#define LD_DEC -/* Allow decoding of scalable profiles */ -//#define SCALABLE_DEC -/* Allow decoding of Digital Radio Mondiale (DRM) */ -//#define DRM -//#define DRM_PS - -/* LD can't do without LTP */ -#ifdef LD_DEC -#ifndef ERROR_RESILIENCE -#define ERROR_RESILIENCE -#endif -#ifndef LTP_DEC -#define LTP_DEC -#endif -#endif - -#define ALLOW_SMALL_FRAMELENGTH - - -// Define LC_ONLY_DECODER if you want a pure AAC LC decoder (independant of SBR_DEC and PS_DEC) -#define LC_ONLY_DECODER -#ifdef LC_ONLY_DECODER - #undef LD_DEC - #undef LTP_DEC - #undef MAIN_DEC - #undef SSR_DEC - #undef DRM - #undef ALLOW_SMALL_FRAMELENGTH - #undef ERROR_RESILIENCE -#endif - -#if CODEC_SIZE >= 0x80000 -#define SBR_DEC -//#define SBR_LOW_POWER /* Does not work yet in rockbox. */ -#define PS_DEC -#endif - -/* FIXED POINT: No MAIN decoding */ -#ifdef FIXED_POINT -# ifdef MAIN_DEC -# undef MAIN_DEC -# endif -#endif // FIXED_POINT - -#ifdef DRM -# ifndef SCALABLE_DEC -# define SCALABLE_DEC -# endif -#endif - - -#ifdef FIXED_POINT -#define DIV_R(A, B) (((int64_t)A << REAL_BITS)/B) -#define DIV_C(A, B) (((int64_t)A << COEF_BITS)/B) -#define DIV_Q(A, B) (((int64_t)A << Q2_BITS )/B) -#else -#define DIV_R(A, B) ((A)/(B)) -#define DIV_C(A, B) ((A)/(B)) -#define DIV_Q(A, B) ((A)/(B)) -#endif - -#ifndef SBR_LOW_POWER -#define qmf_t complex_t -#define QMF_RE(A) RE(A) -#define QMF_IM(A) IM(A) -#else -#define qmf_t real_t -#define QMF_RE(A) (A) -#define QMF_IM(A) -#endif - - -/* END COMPILE TIME DEFINITIONS */ - -#if defined(_WIN32) && !defined(__MINGW32__) - -#include - -typedef unsigned __int64 uint64_t; -typedef unsigned __int32 uint32_t; -typedef unsigned __int16 uint16_t; -typedef unsigned __int8 uint8_t; -typedef __int64 int64_t; -typedef __int32 int32_t; -typedef __int16 int16_t; -typedef __int8 int8_t; -typedef float float32_t; - - -#else - -#include -#ifdef HAVE_SYS_TYPES_H -# include "inttypes.h" -#endif -#ifdef HAVE_SYS_STAT_H -# include -#endif -#ifdef STDC_HEADERS -# include -# include -#else -# ifdef HAVE_STDLIB_H -# include -# endif -#endif -#ifdef HAVE_STRING_H -# if !defined(STDC_HEADERS) && defined(HAVE_MEMORY_H) -# include -# endif -//# include -#endif -#ifdef HAVE_STRINGS_H -//# include -#endif -#ifdef HAVE_INTTYPES_H -# include -#else -# ifdef HAVE_STDINT_H -# include -# else -/* we need these... */ -typedef unsigned long long uint64_t; -typedef unsigned long uint32_t; -typedef unsigned short uint16_t; -typedef unsigned char uint8_t; -typedef long long int64_t; -typedef long int32_t; -typedef short int16_t; -typedef char int8_t; -# endif -#endif -#ifdef HAVE_UNISTD_H -# include -#endif - -#ifndef HAVE_FLOAT32_T -typedef float float32_t; -#endif - -#if STDC_HEADERS -//# include -#else -# if !HAVE_STRCHR -# define strchr index -# define strrchr rindex -# endif -char *strchr(), *strrchr(); -# if !HAVE_MEMCPY -# define memcpy(d, s, n) bcopy((s), (d), (n)) -# define memmove(d, s, n) bcopy((s), (d), (n)) -# endif -#endif - -#endif - -#ifdef WORDS_BIGENDIAN -#define ARCH_IS_BIG_ENDIAN -#endif - -/* FIXED_POINT doesn't work with MAIN and SSR yet */ -#ifdef FIXED_POINT - #undef MAIN_DEC - #undef SSR_DEC -#endif - - -#if defined(FIXED_POINT) - - #include "fixed.h" - -#elif defined(USE_DOUBLE_PRECISION) - - typedef double real_t; - - #include - - #define MUL_R(A,B) ((A)*(B)) - #define MUL_C(A,B) ((A)*(B)) - #define MUL_F(A,B) ((A)*(B)) - #define MUL_Q2(A,B) ((A)*(B)) - - /* Complex multiplication */ - static INLINE void ComplexMult(real_t *y1, real_t *y2, - real_t x1, real_t x2, real_t c1, real_t c2) - { - *y1 = MUL_F(x1, c1) + MUL_F(x2, c2); - *y2 = MUL_F(x2, c1) - MUL_F(x1, c2); - } - - #define REAL_CONST(A) ((real_t)(A)) - #define COEF_CONST(A) ((real_t)(A)) - #define Q2_CONST(A) ((real_t)(A)) - #define FRAC_CONST(A) ((real_t)(A)) /* pure fractional part */ - -#else /* Normal floating point operation */ - - typedef float real_t; - - #define MUL_R(A,B) ((A)*(B)) - #define MUL_C(A,B) ((A)*(B)) - #define MUL_F(A,B) ((A)*(B)) - #define MUL_Q2(A,B) ((A)*(B)) - - #define REAL_CONST(A) ((real_t)(A)) - #define COEF_CONST(A) ((real_t)(A)) - #define Q2_CONST(A) ((real_t)(A)) - #define FRAC_CONST(A) ((real_t)(A)) /* pure fractional part */ - - /* Complex multiplication */ - static INLINE void ComplexMult(real_t *y1, real_t *y2, - real_t x1, real_t x2, real_t c1, real_t c2) - { - *y1 = MUL_F(x1, c1) + MUL_F(x2, c2); - *y2 = MUL_F(x2, c1) - MUL_F(x1, c2); - } - -/* rockbox: must be commented to build for non-FP - #if defined(_WIN32) && !defined(__MINGW32__) - #define HAS_LRINTF - static INLINE int lrintf(float f) - { - int i; - __asm - { - fld f - fistp i - } - return i; - } - #elif (defined(__i386__) && defined(__GNUC__)) - #define HAS_LRINTF - // from http://www.stereopsis.com/FPU.html - static INLINE int lrintf(float f) - { - int i; - __asm__ __volatile__ ( - "flds %1 \n\t" - "fistpl %0 \n\t" - : "=m" (i) - : "m" (f)); - return i; - } - #endif -*/ - - #ifdef __ICL /* only Intel C compiler has fmath ??? */ - - #include - - #define sin sinf - #define cos cosf - #define log logf - #define floor floorf - #define ceil ceilf - #define sqrt sqrtf - - #else - -#ifdef HAVE_LRINTF -# define HAS_LRINTF -# define _ISOC9X_SOURCE 1 -# define _ISOC99_SOURCE 1 -# define __USE_ISOC9X 1 -# define __USE_ISOC99 1 -#endif - - #include - -#ifdef HAVE_SINF -# define sin sinf -#error -#endif -#ifdef HAVE_COSF -# define cos cosf -#endif -#ifdef HAVE_LOGF -# define log logf -#endif -#ifdef HAVE_EXPF -# define exp expf -#endif -#ifdef HAVE_FLOORF -# define floor floorf -#endif -#ifdef HAVE_CEILF -# define ceil ceilf -#endif -#ifdef HAVE_SQRTF -# define sqrt sqrtf -#endif - - #endif - -#endif - -#ifndef HAS_LRINTF -/* standard cast */ -#define lrintf(f) ((int32_t)(f)) -#endif - -typedef real_t complex_t[2]; -#define RE(A) A[0] -#define IM(A) A[1] - - -/* common functions */ -uint8_t cpu_has_sse(void); -uint32_t random_int(void); -#define wl_min_lzc(x) bs_generic(x, BS_LOG2|BS_0_0) -#ifdef FIXED_POINT -#define LOG2_MIN_INF REAL_CONST(-10000) -int32_t log2_int(uint32_t val); -int32_t log2_fix(uint32_t val); -uint32_t pow2_int(real_t val); -uint32_t pow2_fix(real_t val); -#endif -uint8_t get_sr_index(const uint32_t samplerate); -uint8_t max_pred_sfb(const uint8_t sr_index); -uint8_t max_tns_sfb(const uint8_t sr_index, const uint8_t object_type, - const uint8_t is_short); -uint32_t get_sample_rate(const uint8_t sr_index); -int8_t can_decode_ot(const uint8_t object_type); - -#ifndef FAAD_STATIC_ALLOC -/* Those should not be defined or used anymore */ -#define faad_malloc(A) malloc(A) -#define faad_free(A) free(A) -#endif - -//#define PROFILE -#ifdef PROFILE -static int64_t faad_get_ts() -{ - __asm - { - rdtsc - } -} -#endif - -#ifndef M_PI -#define M_PI 3.14159265358979323846 -#endif -#ifndef M_PI_2 /* PI/2 */ -#define M_PI_2 1.57079632679489661923 -#endif - - -#ifdef __cplusplus -} -#endif -#endif diff --git a/apps/codecs/libfaad/decoder.c b/apps/codecs/libfaad/decoder.c deleted file mode 100644 index d68d093b0b..0000000000 --- a/apps/codecs/libfaad/decoder.c +++ /dev/null @@ -1,1029 +0,0 @@ -/* -** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -** -** Any non-GPL usage of this software or parts of this software is strictly -** forbidden. -** -** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. -** -** $Id$ -**/ - -#include "common.h" -#include "structs.h" - -#include -#include - -#include "decoder.h" -#include "mp4.h" -#include "syntax.h" -#include "error.h" -/* rockbox: not used -#include "output.h" -*/ -#include "filtbank.h" -#include "drc.h" -#ifdef SBR_DEC -#include "sbr_dec.h" -#include "sbr_syntax.h" -#endif -#ifdef SSR_DEC -#include "ssr.h" -#endif - -/* Globals */ -#ifdef ANALYSIS -uint16_t dbg_count; -#endif - -/* static variables */ -static NeAACDecStruct s_AACDec; -static real_t s_fb_intermed [MAX_CHANNELS][1*FRAME_LEN] IBSS_ATTR_FAAD_LARGE_IRAM MEM_ALIGN_ATTR; -static real_t s_time_buf_1024[MAX_CHANNELS][1*FRAME_LEN] IBSS_ATTR_FAAD_LARGE_IRAM MEM_ALIGN_ATTR; -#ifdef SBR_DEC -#ifdef FAAD_STATIC_ALLOC -static real_t s_time_buf_2048[MAX_CHANNELS][2*FRAME_LEN] MEM_ALIGN_ATTR; -#endif -#endif -#ifdef SSR_DEC -static real_t s_ssr_overlap [MAX_CHANNELS][2*FRAME_LEN] MEM_ALIGN_ATTR; -static real_t s_prev_fmd [MAX_CHANNELS][2*FRAME_LEN] MEM_ALIGN_ATTR; -#endif -#ifdef MAIN_DEC -static pred_state s_pred_stat[MAX_CHANNELS][1*FRAME_LEN] MEM_ALIGN_ATTR; -#endif -#ifdef LTP_DEC -static int16_t s_lt_pred_stat[MAX_CHANNELS][4*FRAME_LEN] MEM_ALIGN_ATTR; -#endif - - -/* static function declarations */ -static void* aac_frame_decode(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hInfo, - uint8_t *buffer, uint32_t buffer_size); -/* not used by rockbox -static void create_channel_config(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hInfo); -*/ - -char* NEAACDECAPI NeAACDecGetErrorMessage(uint8_t errcode) -{ - if (errcode >= NUM_ERROR_MESSAGES) - return NULL; - return err_msg[errcode]; -} - -/* rockbox: not used */ -#if 0 -uint32_t NEAACDECAPI NeAACDecGetCapabilities(void) -{ - uint32_t cap = 0; - - /* can't do without it */ - cap += LC_DEC_CAP; - -#ifdef MAIN_DEC - cap += MAIN_DEC_CAP; -#endif -#ifdef LTP_DEC - cap += LTP_DEC_CAP; -#endif -#ifdef LD_DEC - cap += LD_DEC_CAP; -#endif -#ifdef ERROR_RESILIENCE - cap += ERROR_RESILIENCE_CAP; -#endif -#ifdef FIXED_POINT - cap += FIXED_POINT_CAP; -#endif - - return cap; -} -#endif - -NeAACDecHandle NEAACDECAPI NeAACDecOpen(void) -{ - uint8_t i; - NeAACDecHandle hDecoder = NULL; - - #if defined(CPU_COLDFIRE) - coldfire_set_macsr(EMAC_FRACTIONAL | EMAC_SATURATE); - #endif - - hDecoder = &s_AACDec; - - memset(hDecoder , 0, sizeof(NeAACDecStruct)); - memset(s_fb_intermed, 0, sizeof(s_fb_intermed)); -#ifdef SSR_DEC - memset(s_ssr_overlap, 0, sizeof(s_ssr_overlap)); - memset(s_prev_fmd , 0, sizeof(s_prev_fmd)); -#endif -#ifdef LTP_DEC - memset(s_lt_pred_stat, 0, sizeof(s_s_lt_pred_statpred_stat)); -#endif - - hDecoder->config.outputFormat = FAAD_FMT_16BIT; - hDecoder->config.defObjectType = MAIN; - hDecoder->config.defSampleRate = 44100; - hDecoder->config.downMatrix = 0; - hDecoder->adts_header_present = 0; - hDecoder->adif_header_present = 0; -#ifdef ERROR_RESILIENCE - hDecoder->aacSectionDataResilienceFlag = 0; - hDecoder->aacScalefactorDataResilienceFlag = 0; - hDecoder->aacSpectralDataResilienceFlag = 0; -#endif - hDecoder->frameLength = FRAME_LEN; - - hDecoder->frame = 0; - - for (i = 0; i < MAX_CHANNELS; i++) - { - hDecoder->window_shape_prev[i] = 0; - hDecoder->time_out[i] = NULL; - hDecoder->fb_intermed[i] = s_fb_intermed[i]; -#ifdef SSR_DEC - hDecoder->ssr_overlap[i] = s_ssr_overlap[i]; - hDecoder->prev_fmd[i] = s_prev_fmd[i]; - for (int k = 0; k < 2048; k++) - hDecoder->prev_fmd[i][k] = REAL_CONST(-1); -#endif -#ifdef MAIN_DEC - hDecoder->pred_stat[i] = s_pred_stat[i]; - reset_all_predictors(hDecoder->pred_stat[channel], FRAME_LEN); -#endif -#ifdef LTP_DEC - hDecoder->ltp_lag[i] = 0; - hDecoder->lt_pred_stat[i] = s_lt_pred_stat[i]; -#endif - } - -#ifdef SBR_DEC - for (i = 0; i < MAX_SYNTAX_ELEMENTS; i++) - { - hDecoder->sbr[i] = NULL; - } -#endif - - hDecoder->drc = drc_init(REAL_CONST(1.0), REAL_CONST(1.0)); - - return hDecoder; -} - -NeAACDecConfigurationPtr NEAACDECAPI NeAACDecGetCurrentConfiguration(NeAACDecHandle hDecoder) -{ - if (hDecoder) - { - NeAACDecConfigurationPtr config = &(hDecoder->config); - - return config; - } - - return NULL; -} - -uint8_t NEAACDECAPI NeAACDecSetConfiguration(NeAACDecHandle hDecoder, - NeAACDecConfigurationPtr config) -{ - if (hDecoder && config) - { - /* check if we can decode this object type */ - if (can_decode_ot(config->defObjectType) < 0) - return 0; - hDecoder->config.defObjectType = config->defObjectType; - - /* samplerate: anything but 0 should be possible */ - if (config->defSampleRate == 0) - return 0; - hDecoder->config.defSampleRate = config->defSampleRate; - - /* check output format */ -#ifdef FIXED_POINT - if ((config->outputFormat < 1) || (config->outputFormat > 4)) - return 0; -#else - if ((config->outputFormat < 1) || (config->outputFormat > 5)) - return 0; -#endif - hDecoder->config.outputFormat = config->outputFormat; - - if (config->downMatrix > 1) - return 0; - hDecoder->config.downMatrix = config->downMatrix; - - /* OK */ - return 1; - } - - return 0; -} - -int32_t NEAACDECAPI NeAACDecInit(NeAACDecHandle hDecoder, uint8_t *buffer, - uint32_t buffer_size, - uint32_t *samplerate, uint8_t *channels) -{ - uint32_t i; - uint32_t bits = 0; - bitfile ld; - adif_header adif; - adts_header adts; - - if ((hDecoder == NULL) || (samplerate == NULL) || (channels == NULL)) - return -1; - - hDecoder->sf_index = get_sr_index(hDecoder->config.defSampleRate); - hDecoder->object_type = hDecoder->config.defObjectType; - *samplerate = get_sample_rate(hDecoder->sf_index); - *channels = 1; - - if (buffer != NULL) - { - faad_initbits(&ld, buffer, buffer_size); - - /* Check if an ADIF header is present */ - if ((buffer[0] == 'A') && (buffer[1] == 'D') && - (buffer[2] == 'I') && (buffer[3] == 'F')) - { - hDecoder->adif_header_present = 1; - - get_adif_header(&adif, &ld); - faad_byte_align(&ld); - - hDecoder->sf_index = adif.pce[0].sf_index; - hDecoder->object_type = adif.pce[0].object_type + 1; - - *samplerate = get_sample_rate(hDecoder->sf_index); - *channels = adif.pce[0].channels; - - memcpy(&(hDecoder->pce), &(adif.pce[0]), sizeof(program_config)); - hDecoder->pce_set = 1; - - bits = bit2byte(faad_get_processed_bits(&ld)); - - /* Check if an ADTS header is present */ - } else if (faad_showbits(&ld, 12) == 0xfff) { - hDecoder->adts_header_present = 1; - - adts.old_format = hDecoder->config.useOldADTSFormat; - adts_frame(&adts, &ld); - - hDecoder->sf_index = adts.sf_index; - hDecoder->object_type = adts.profile + 1; - - *samplerate = get_sample_rate(hDecoder->sf_index); - *channels = (adts.channel_configuration > 6) ? - 2 : adts.channel_configuration; - } - - if (ld.error) - { - faad_endbits(&ld); - return -1; - } - faad_endbits(&ld); - } - hDecoder->channelConfiguration = *channels; - -#if (defined(PS_DEC) || defined(DRM_PS)) - /* check if we have a mono file */ - if (*channels == 1) - { - /* upMatrix to 2 channels for implicit signalling of PS */ - *channels = 2; - } -#endif - - /* A maximum of MAX_CHANNELS channels is supported. */ - if (*channels > MAX_CHANNELS) - { - return -1; - } - -#ifdef SBR_DEC - /* implicit signalling */ - if (*samplerate <= 24000 && !(hDecoder->config.dontUpSampleImplicitSBR)) - { - *samplerate *= 2; - hDecoder->forceUpSampling = 1; - } else if (*samplerate > 24000 && !(hDecoder->config.dontUpSampleImplicitSBR)) { - hDecoder->downSampledSBR = 1; - } -#endif - - /* must be done before frameLength is divided by 2 for LD */ -#ifdef SSR_DEC - if (hDecoder->object_type == SSR) - hDecoder->fb = ssr_filter_bank_init(hDecoder->frameLength/SSR_BANDS); - else -#endif - - -#ifdef LD_DEC - if (hDecoder->object_type == LD) - hDecoder->frameLength >>= 1; -#endif - - for (i=0; isbr_alloced[hDecoder->fr_ch_ele] = 0; - if ((hDecoder->sbr_present_flag == 1) || (hDecoder->forceUpSampling == 1)) - { -#ifdef FAAD_STATIC_ALLOC - hDecoder->time_out[i] = s_time_buf_2048[i]; -#else - hDecoder->time_out[i] = (real_t*)faad_malloc(2*FRAME_LEN*sizeof(real_t)); - if (hDecoder->time_out[i] == NULL) - { - /* could not allocate memory */ - return -1; - } -#endif - memset(hDecoder->time_out[i], 0, 2*FRAME_LEN); - hDecoder->sbr_alloced[hDecoder->fr_ch_ele] = 1; - } - else -#endif - { - hDecoder->time_out[i] = s_time_buf_1024[i]; - memset(hDecoder->time_out[i], 0, 1*FRAME_LEN); - } - } - - if (can_decode_ot(hDecoder->object_type) < 0) - return -1; - - return bits; -} - -/* Init the library using a DecoderSpecificInfo */ -int8_t NEAACDECAPI NeAACDecInit2(NeAACDecHandle hDecoder, uint8_t *pBuffer, - uint32_t SizeOfDecoderSpecificInfo, - uint32_t *samplerate, uint8_t *channels) -{ - int8_t rc; - uint32_t i; - mp4AudioSpecificConfig mp4ASC; - - if((hDecoder == NULL) - || (pBuffer == NULL) - || (SizeOfDecoderSpecificInfo < 2) - || (samplerate == NULL) - || (channels == NULL)) - { - return -1; - } - - hDecoder->adif_header_present = 0; - hDecoder->adts_header_present = 0; - - /* decode the audio specific config */ - rc = AudioSpecificConfig2(pBuffer, SizeOfDecoderSpecificInfo, &mp4ASC, - &(hDecoder->pce)); - - /* copy the relevant info to the decoder handle */ - *samplerate = mp4ASC.samplingFrequency; - if (mp4ASC.channelsConfiguration) - { - *channels = mp4ASC.channelsConfiguration; - } else { - *channels = hDecoder->pce.channels; - hDecoder->pce_set = 1; - } -#if (defined(PS_DEC) || defined(DRM_PS)) - /* check if we have a mono file */ - if (*channels == 1) - { - /* upMatrix to 2 channels for implicit signalling of PS */ - *channels = 2; - } -#endif - - /* A maximum of MAX_CHANNELS channels is supported. */ - if (*channels > MAX_CHANNELS) - { - return -1; - } - - hDecoder->sf_index = mp4ASC.samplingFrequencyIndex; - hDecoder->object_type = mp4ASC.objectTypeIndex; -#ifdef ERROR_RESILIENCE - hDecoder->aacSectionDataResilienceFlag = mp4ASC.aacSectionDataResilienceFlag; - hDecoder->aacScalefactorDataResilienceFlag = mp4ASC.aacScalefactorDataResilienceFlag; - hDecoder->aacSpectralDataResilienceFlag = mp4ASC.aacSpectralDataResilienceFlag; -#endif -#ifdef SBR_DEC - hDecoder->sbr_present_flag = mp4ASC.sbr_present_flag; - hDecoder->downSampledSBR = mp4ASC.downSampledSBR; - if (hDecoder->config.dontUpSampleImplicitSBR == 0) - hDecoder->forceUpSampling = mp4ASC.forceUpSampling; - else - hDecoder->forceUpSampling = 0; - - /* AAC core decoder samplerate is 2 times as low */ - if (((hDecoder->sbr_present_flag == 1)&&(!hDecoder->downSampledSBR)) || hDecoder->forceUpSampling == 1) - { - hDecoder->sf_index = get_sr_index(mp4ASC.samplingFrequency / 2); - } -#endif - - if (rc != 0) - { - return rc; - } - hDecoder->channelConfiguration = mp4ASC.channelsConfiguration; - if (mp4ASC.frameLengthFlag) -#ifdef ALLOW_SMALL_FRAMELENGTH - hDecoder->frameLength = 960; -#else - return -1; -#endif - - /* must be done before frameLength is divided by 2 for LD */ -#ifdef SSR_DEC - if (hDecoder->object_type == SSR) - hDecoder->fb = ssr_filter_bank_init(hDecoder->frameLength/SSR_BANDS); - else -#endif - -#ifdef LD_DEC - if (hDecoder->object_type == LD) - hDecoder->frameLength >>= 1; -#endif - - for (i=0; isbr_alloced[hDecoder->fr_ch_ele] = 0; - if ((hDecoder->sbr_present_flag == 1) || (hDecoder->forceUpSampling == 1)) - { -#ifdef FAAD_STATIC_ALLOC - hDecoder->time_out[i] = s_time_buf_2048[i]; -#else - hDecoder->time_out[i] = (real_t*)faad_malloc(2*FRAME_LEN*sizeof(real_t)); - if (hDecoder->time_out[i] == NULL) - { - /* could not allocate memory */ - return -1; - } -#endif - memset(hDecoder->time_out[i], 0, 2*FRAME_LEN); - hDecoder->sbr_alloced[hDecoder->fr_ch_ele] = 1; - } - else -#endif - { - hDecoder->time_out[i] = s_time_buf_1024[i]; - memset(hDecoder->time_out[i], 0, 1*FRAME_LEN); - } - } - - return 0; -} - -#ifdef DRM -int8_t NEAACDECAPI NeAACDecInitDRM(NeAACDecHandle *hDecoder, uint32_t samplerate, - uint8_t channels) -{ - if (hDecoder == NULL) - return 1; /* error */ - - *hDecoder = NeAACDecOpen(); - - /* Special object type defined for DRM */ - (*hDecoder)->config.defObjectType = DRM_ER_LC; - - (*hDecoder)->config.defSampleRate = samplerate; -#ifdef ERROR_RESILIENCE // This shoudl always be defined for DRM - (*hDecoder)->aacSectionDataResilienceFlag = 1; /* VCB11 */ - (*hDecoder)->aacScalefactorDataResilienceFlag = 0; /* no RVLC */ - (*hDecoder)->aacSpectralDataResilienceFlag = 1; /* HCR */ -#endif - (*hDecoder)->frameLength = 960; - (*hDecoder)->sf_index = get_sr_index((*hDecoder)->config.defSampleRate); - (*hDecoder)->object_type = (*hDecoder)->config.defObjectType; - - if ((channels == DRMCH_STEREO) || (channels == DRMCH_SBR_STEREO)) - (*hDecoder)->channelConfiguration = 2; - else - (*hDecoder)->channelConfiguration = 1; - -#ifdef SBR_DEC - if ((channels == DRMCH_MONO) || (channels == DRMCH_STEREO)) - (*hDecoder)->sbr_present_flag = 0; - else - (*hDecoder)->sbr_present_flag = 1; -#endif - - - return 0; -} -#endif - -void NEAACDECAPI NeAACDecPostSeekReset(NeAACDecHandle hDecoder, int32_t frame) -{ - if (hDecoder) - { - hDecoder->postSeekResetFlag = 1; - - if (frame != -1) - hDecoder->frame = frame; - } -} - -/* not used by rockbox */ -#if 0 -static void create_channel_config(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hInfo) -{ - hInfo->num_front_channels = 0; - hInfo->num_side_channels = 0; - hInfo->num_back_channels = 0; - hInfo->num_lfe_channels = 0; - memset(hInfo->channel_position, 0, MAX_CHANNELS*sizeof(uint8_t)); - - if (hDecoder->downMatrix) - { - hInfo->num_front_channels = 2; - hInfo->channel_position[0] = FRONT_CHANNEL_LEFT; - hInfo->channel_position[1] = FRONT_CHANNEL_RIGHT; - return; - } - - /* check if there is a PCE */ - if (hDecoder->pce_set) - { - uint8_t i, chpos = 0; - uint8_t chdir, back_center = 0; - - hInfo->num_front_channels = hDecoder->pce.num_front_channels; - hInfo->num_side_channels = hDecoder->pce.num_side_channels; - hInfo->num_back_channels = hDecoder->pce.num_back_channels; - hInfo->num_lfe_channels = hDecoder->pce.num_lfe_channels; - - chdir = hInfo->num_front_channels; - if (chdir & 1) - { - hInfo->channel_position[chpos++] = FRONT_CHANNEL_CENTER; - chdir--; - } - for (i = 0; i < chdir; i += 2) - { - hInfo->channel_position[chpos++] = FRONT_CHANNEL_LEFT; - hInfo->channel_position[chpos++] = FRONT_CHANNEL_RIGHT; - } - - for (i = 0; i < hInfo->num_side_channels; i += 2) - { - hInfo->channel_position[chpos++] = SIDE_CHANNEL_LEFT; - hInfo->channel_position[chpos++] = SIDE_CHANNEL_RIGHT; - } - - chdir = hInfo->num_back_channels; - if (chdir & 1) - { - back_center = 1; - chdir--; - } - for (i = 0; i < chdir; i += 2) - { - hInfo->channel_position[chpos++] = BACK_CHANNEL_LEFT; - hInfo->channel_position[chpos++] = BACK_CHANNEL_RIGHT; - } - if (back_center) - { - hInfo->channel_position[chpos++] = BACK_CHANNEL_CENTER; - } - - for (i = 0; i < hInfo->num_lfe_channels; i++) - { - hInfo->channel_position[chpos++] = LFE_CHANNEL; - } - - } else { - switch (hDecoder->channelConfiguration) - { - case 1: - hInfo->num_front_channels = 1; - hInfo->channel_position[0] = FRONT_CHANNEL_CENTER; - break; - case 2: - hInfo->num_front_channels = 2; - hInfo->channel_position[0] = FRONT_CHANNEL_LEFT; - hInfo->channel_position[1] = FRONT_CHANNEL_RIGHT; - break; - case 3: - hInfo->num_front_channels = 3; - hInfo->channel_position[0] = FRONT_CHANNEL_CENTER; - hInfo->channel_position[1] = FRONT_CHANNEL_LEFT; - hInfo->channel_position[2] = FRONT_CHANNEL_RIGHT; - break; - case 4: - hInfo->num_front_channels = 3; - hInfo->num_back_channels = 1; - hInfo->channel_position[0] = FRONT_CHANNEL_CENTER; - hInfo->channel_position[1] = FRONT_CHANNEL_LEFT; - hInfo->channel_position[2] = FRONT_CHANNEL_RIGHT; - hInfo->channel_position[3] = BACK_CHANNEL_CENTER; - break; - case 5: - hInfo->num_front_channels = 3; - hInfo->num_back_channels = 2; - hInfo->channel_position[0] = FRONT_CHANNEL_CENTER; - hInfo->channel_position[1] = FRONT_CHANNEL_LEFT; - hInfo->channel_position[2] = FRONT_CHANNEL_RIGHT; - hInfo->channel_position[3] = BACK_CHANNEL_LEFT; - hInfo->channel_position[4] = BACK_CHANNEL_RIGHT; - break; - case 6: - hInfo->num_front_channels = 3; - hInfo->num_back_channels = 2; - hInfo->num_lfe_channels = 1; - hInfo->channel_position[0] = FRONT_CHANNEL_CENTER; - hInfo->channel_position[1] = FRONT_CHANNEL_LEFT; - hInfo->channel_position[2] = FRONT_CHANNEL_RIGHT; - hInfo->channel_position[3] = BACK_CHANNEL_LEFT; - hInfo->channel_position[4] = BACK_CHANNEL_RIGHT; - hInfo->channel_position[5] = LFE_CHANNEL; - break; - case 7: - hInfo->num_front_channels = 3; - hInfo->num_side_channels = 2; - hInfo->num_back_channels = 2; - hInfo->num_lfe_channels = 1; - hInfo->channel_position[0] = FRONT_CHANNEL_CENTER; - hInfo->channel_position[1] = FRONT_CHANNEL_LEFT; - hInfo->channel_position[2] = FRONT_CHANNEL_RIGHT; - hInfo->channel_position[3] = SIDE_CHANNEL_LEFT; - hInfo->channel_position[4] = SIDE_CHANNEL_RIGHT; - hInfo->channel_position[5] = BACK_CHANNEL_LEFT; - hInfo->channel_position[6] = BACK_CHANNEL_RIGHT; - hInfo->channel_position[7] = LFE_CHANNEL; - break; - default: /* channelConfiguration == 0 || channelConfiguration > 7 */ - { - uint8_t i; - uint8_t ch = hDecoder->fr_channels - hDecoder->has_lfe; - if (ch & 1) /* there's either a center front or a center back channel */ - { - uint8_t ch1 = (ch-1)/2; - if (hDecoder->first_syn_ele == ID_SCE) - { - hInfo->num_front_channels = ch1 + 1; - hInfo->num_back_channels = ch1; - hInfo->channel_position[0] = FRONT_CHANNEL_CENTER; - for (i = 1; i <= ch1; i+=2) - { - hInfo->channel_position[i] = FRONT_CHANNEL_LEFT; - hInfo->channel_position[i+1] = FRONT_CHANNEL_RIGHT; - } - for (i = ch1+1; i < ch; i+=2) - { - hInfo->channel_position[i] = BACK_CHANNEL_LEFT; - hInfo->channel_position[i+1] = BACK_CHANNEL_RIGHT; - } - } else { - hInfo->num_front_channels = ch1; - hInfo->num_back_channels = ch1 + 1; - for (i = 0; i < ch1; i+=2) - { - hInfo->channel_position[i] = FRONT_CHANNEL_LEFT; - hInfo->channel_position[i+1] = FRONT_CHANNEL_RIGHT; - } - for (i = ch1; i < ch-1; i+=2) - { - hInfo->channel_position[i] = BACK_CHANNEL_LEFT; - hInfo->channel_position[i+1] = BACK_CHANNEL_RIGHT; - } - hInfo->channel_position[ch-1] = BACK_CHANNEL_CENTER; - } - } else { - uint8_t ch1 = (ch)/2; - hInfo->num_front_channels = ch1; - hInfo->num_back_channels = ch1; - if (ch1 & 1) - { - hInfo->channel_position[0] = FRONT_CHANNEL_CENTER; - for (i = 1; i <= ch1; i+=2) - { - hInfo->channel_position[i] = FRONT_CHANNEL_LEFT; - hInfo->channel_position[i+1] = FRONT_CHANNEL_RIGHT; - } - for (i = ch1+1; i < ch-1; i+=2) - { - hInfo->channel_position[i] = BACK_CHANNEL_LEFT; - hInfo->channel_position[i+1] = BACK_CHANNEL_RIGHT; - } - hInfo->channel_position[ch-1] = BACK_CHANNEL_CENTER; - } else { - for (i = 0; i < ch1; i+=2) - { - hInfo->channel_position[i] = FRONT_CHANNEL_LEFT; - hInfo->channel_position[i+1] = FRONT_CHANNEL_RIGHT; - } - for (i = ch1; i < ch; i+=2) - { - hInfo->channel_position[i] = BACK_CHANNEL_LEFT; - hInfo->channel_position[i+1] = BACK_CHANNEL_RIGHT; - } - } - } - hInfo->num_lfe_channels = hDecoder->has_lfe; - for (i = ch; i < hDecoder->fr_channels; i++) - { - hInfo->channel_position[i] = LFE_CHANNEL; - } - } - break; - } - } -} -#endif - -void* NEAACDECAPI NeAACDecDecode(NeAACDecHandle hDecoder, - NeAACDecFrameInfo *hInfo, - uint8_t *buffer, uint32_t buffer_size) -{ - return aac_frame_decode(hDecoder, hInfo, buffer, buffer_size); -} - -static void* aac_frame_decode(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hInfo, - uint8_t *buffer, uint32_t buffer_size) -{ - uint8_t channels = 0; - uint8_t output_channels = 0; - bitfile ld; - uint32_t bitsconsumed; - uint16_t frame_len; - -#ifdef PROFILE - int64_t count = faad_get_ts(); -#endif - - /* safety checks */ - if ((hDecoder == NULL) || (hInfo == NULL) || (buffer == NULL)) - { - return NULL; - } - -#if 0 - printf("%d\n", buffer_size*8); -#endif - - frame_len = hDecoder->frameLength; - - - memset(hInfo, 0, sizeof(NeAACDecFrameInfo)); - memset(hDecoder->internal_channel, 0, MAX_CHANNELS*sizeof(hDecoder->internal_channel[0])); - - /* initialize the bitstream */ - faad_initbits(&ld, buffer, buffer_size); - -#if 0 - { - int i; - for (i = 0; i < ((buffer_size+3)>>2); i++) - { - uint8_t *buf; - uint32_t temp = 0; - buf = faad_getbitbuffer(&ld, 32); - //temp = getdword((void*)buf); - temp = *((uint32_t*)buf); - printf("0x%.8X\n", temp); - free(buf); - } - faad_endbits(&ld); - faad_initbits(&ld, buffer, buffer_size); - } -#endif - -#ifdef DRM - if (hDecoder->object_type == DRM_ER_LC) - { - /* We do not support stereo right now */ - if (0) //(hDecoder->channelConfiguration == 2) - { - hInfo->error = 8; // Throw CRC error - goto error; - } - - faad_getbits(&ld, 8 - DEBUGVAR(1,1,"NeAACDecDecode(): skip CRC")); - } -#endif - - if (hDecoder->adts_header_present) - { - adts_header adts; - - adts.old_format = hDecoder->config.useOldADTSFormat; - if ((hInfo->error = adts_frame(&adts, &ld)) > 0) - goto error; - - /* MPEG2 does byte_alignment() here, - * but ADTS header is always multiple of 8 bits in MPEG2 - * so not needed to actually do it. - */ - } - -#ifdef ANALYSIS - dbg_count = 0; -#endif - - /* decode the complete bitstream */ -#ifdef SCALABLE_DEC - if ((hDecoder->object_type == 6) || (hDecoder->object_type == DRM_ER_LC)) - { - aac_scalable_main_element(hDecoder, hInfo, &ld, &hDecoder->pce, hDecoder->drc); - } else { -#endif - raw_data_block(hDecoder, hInfo, &ld, &hDecoder->pce, hDecoder->drc); -#ifdef SCALABLE_DEC - } -#endif - - channels = hDecoder->fr_channels; - - if (hInfo->error > 0) - goto error; - - /* safety check */ - if (channels == 0 || channels > MAX_CHANNELS) - { - /* invalid number of channels */ - hInfo->error = 12; - goto error; - } - - /* no more bit reading after this */ - bitsconsumed = faad_get_processed_bits(&ld); - hInfo->bytesconsumed = bit2byte(bitsconsumed); - if (ld.error) - { - hInfo->error = 14; - goto error; - } - faad_endbits(&ld); - - - if (!hDecoder->adts_header_present && !hDecoder->adif_header_present) - { - if (hDecoder->channelConfiguration == 0) - hDecoder->channelConfiguration = channels; - - if (channels == 8) /* 7.1 */ - hDecoder->channelConfiguration = 7; - if (channels == 7) /* not a standard channelConfiguration */ - hDecoder->channelConfiguration = 0; - } - - if ((channels == 5 || channels == 6) && hDecoder->config.downMatrix) - { - hDecoder->downMatrix = 1; - output_channels = 2; - } else { - output_channels = channels; - } - -#if (defined(PS_DEC) || defined(DRM_PS)) - hDecoder->upMatrix = 0; - /* check if we have a mono file */ - if (output_channels == 1) - { - /* upMatrix to 2 channels for implicit signalling of PS */ - hDecoder->upMatrix = 1; - output_channels = 2; - } -#endif - - /* Make a channel configuration based on either a PCE or a channelConfiguration */ - /* not used by rockbox - create_channel_config(hDecoder, hInfo); - */ - - /* number of samples in this frame */ - hInfo->samples = frame_len*output_channels; - /* number of channels in this frame */ - hInfo->channels = output_channels; - /* samplerate */ - hInfo->samplerate = get_sample_rate(hDecoder->sf_index); - /* object type */ - hInfo->object_type = hDecoder->object_type; - /* sbr */ - hInfo->sbr = NO_SBR; - /* header type */ - hInfo->header_type = RAW; - if (hDecoder->adif_header_present) - hInfo->header_type = ADIF; - if (hDecoder->adts_header_present) - hInfo->header_type = ADTS; -#if (defined(PS_DEC) || defined(DRM_PS)) - hInfo->ps = hDecoder->ps_used_global; -#endif - - /* check if frame has channel elements */ - if (channels == 0) - { - hDecoder->frame++; - return NULL; - } - - /* allocate the buffer for the final samples */ - if (hDecoder->alloced_channels != output_channels) - { - hDecoder->alloced_channels = output_channels; - } - -#ifdef SBR_DEC - if ((hDecoder->sbr_present_flag == 1) || (hDecoder->forceUpSampling == 1)) - { - uint8_t ele; - - /* this data is different when SBR is used or when the data is upsampled */ - if (!hDecoder->downSampledSBR) - { - frame_len *= 2; - hInfo->samples *= 2; - hInfo->samplerate *= 2; - } - - /* check if every element was provided with SBR data */ - for (ele = 0; ele < hDecoder->fr_ch_ele; ele++) - { - if (hDecoder->sbr[ele] == NULL) - { - hInfo->error = 25; - goto error; - } - } - - /* sbr */ - if (hDecoder->sbr_present_flag == 1) - { - hInfo->object_type = HE_AAC; - hInfo->sbr = SBR_UPSAMPLED; - } else { - hInfo->sbr = NO_SBR_UPSAMPLED; - } - if (hDecoder->downSampledSBR) - { - hInfo->sbr = SBR_DOWNSAMPLED; - } - } -#endif - - hDecoder->postSeekResetFlag = 0; - - hDecoder->frame++; -#ifdef LD_DEC - if (hDecoder->object_type != LD) - { -#endif - if (hDecoder->frame <= 1) - hInfo->samples = 0; -#ifdef LD_DEC - } else { - /* LD encoders will give lower delay */ - if (hDecoder->frame <= 0) - hInfo->samples = 0; - } -#endif - - /* cleanup */ -#ifdef ANALYSIS - fflush(stdout); -#endif - -#ifdef PROFILE - count = faad_get_ts() - count; - hDecoder->cycles += count; -#endif - - return hDecoder; /* return void* != NULL */ - -error: - - faad_endbits(&ld); - - /* cleanup */ -#ifdef ANALYSIS - fflush(stdout); -#endif - - return NULL; -} diff --git a/apps/codecs/libfaad/decoder.h b/apps/codecs/libfaad/decoder.h deleted file mode 100644 index f5c477e186..0000000000 --- a/apps/codecs/libfaad/decoder.h +++ /dev/null @@ -1,112 +0,0 @@ -/* -** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -** -** Any non-GPL usage of this software or parts of this software is strictly -** forbidden. -** -** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. -** -** $Id$ -**/ - -#ifndef __DECODER_H__ -#define __DECODER_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef _WIN32 - #pragma pack(push, 8) - #ifndef NEAACDECAPI - #define NEAACDECAPI __cdecl - #endif -#else - #ifndef NEAACDECAPI - #define NEAACDECAPI - #endif -#endif - - -/* library output formats */ -#define FAAD_FMT_16BIT 1 -#define FAAD_FMT_24BIT 2 -#define FAAD_FMT_32BIT 3 -#define FAAD_FMT_FLOAT 4 -#define FAAD_FMT_FIXED FAAD_FMT_FLOAT -#define FAAD_FMT_DOUBLE 5 - -#define LC_DEC_CAP (1<<0) -#define MAIN_DEC_CAP (1<<1) -#define LTP_DEC_CAP (1<<2) -#define LD_DEC_CAP (1<<3) -#define ERROR_RESILIENCE_CAP (1<<4) -#define FIXED_POINT_CAP (1<<5) - -#define FRONT_CHANNEL_CENTER (1) -#define FRONT_CHANNEL_LEFT (2) -#define FRONT_CHANNEL_RIGHT (3) -#define SIDE_CHANNEL_LEFT (4) -#define SIDE_CHANNEL_RIGHT (5) -#define BACK_CHANNEL_LEFT (6) -#define BACK_CHANNEL_RIGHT (7) -#define BACK_CHANNEL_CENTER (8) -#define LFE_CHANNEL (9) -#define UNKNOWN_CHANNEL (0) - -char* NEAACDECAPI NeAACDecGetErrorMessage(uint8_t errcode); - -NeAACDecHandle NEAACDECAPI NeAACDecOpen(void); - -NeAACDecConfigurationPtr NEAACDECAPI NeAACDecGetCurrentConfiguration(NeAACDecHandle hDecoder); - -uint8_t NEAACDECAPI NeAACDecSetConfiguration(NeAACDecHandle hDecoder, - NeAACDecConfigurationPtr config); - -/* Init the library based on info from the AAC file (ADTS/ADIF) */ -int32_t NEAACDECAPI NeAACDecInit(NeAACDecHandle hDecoder, - uint8_t *buffer, - uint32_t buffer_size, - uint32_t *samplerate, - uint8_t *channels); - -/* Init the library using a DecoderSpecificInfo */ -int8_t NEAACDECAPI NeAACDecInit2(NeAACDecHandle hDecoder, uint8_t *pBuffer, - uint32_t SizeOfDecoderSpecificInfo, - uint32_t *samplerate, uint8_t *channels); - -/* Init the library for DRM */ -int8_t NEAACDECAPI NeAACDecInitDRM(NeAACDecHandle *hDecoder, uint32_t samplerate, - uint8_t channels); - -void NEAACDECAPI NeAACDecPostSeekReset(NeAACDecHandle hDecoder, int32_t frame); - -void* NEAACDECAPI NeAACDecDecode(NeAACDecHandle hDecoder, - NeAACDecFrameInfo *hInfo, - uint8_t *buffer, - uint32_t buffer_size); - -#ifdef _WIN32 - #pragma pack(pop) -#endif - -#ifdef __cplusplus -} -#endif -#endif diff --git a/apps/codecs/libfaad/drc.c b/apps/codecs/libfaad/drc.c deleted file mode 100644 index 6e081489aa..0000000000 --- a/apps/codecs/libfaad/drc.c +++ /dev/null @@ -1,168 +0,0 @@ -/* -** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -** -** Any non-GPL usage of this software or parts of this software is strictly -** forbidden. -** -** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. -** -** $Id$ -**/ - -#include "common.h" -#include "structs.h" - -#include -#include -#include "syntax.h" -#include "drc.h" - -/* static variables */ -static drc_info s_drc_info; - -drc_info *drc_init(real_t cut, real_t boost) -{ - drc_info *drc = &s_drc_info; - memset(drc, 0, sizeof(drc_info)); - - drc->ctrl1 = cut; - drc->ctrl2 = boost; - - drc->num_bands = 1; - drc->band_top[0] = 1024/4 - 1; - drc->dyn_rng_sgn[0] = 1; - drc->dyn_rng_ctl[0] = 0; - - return drc; -} - -#ifdef FIXED_POINT -static real_t drc_pow2_table[] = -{ - COEF_CONST(0.5146511183), - COEF_CONST(0.5297315472), - COEF_CONST(0.5452538663), - COEF_CONST(0.5612310242), - COEF_CONST(0.5776763484), - COEF_CONST(0.5946035575), - COEF_CONST(0.6120267717), - COEF_CONST(0.6299605249), - COEF_CONST(0.6484197773), - COEF_CONST(0.6674199271), - COEF_CONST(0.6869768237), - COEF_CONST(0.7071067812), - COEF_CONST(0.7278265914), - COEF_CONST(0.7491535384), - COEF_CONST(0.7711054127), - COEF_CONST(0.7937005260), - COEF_CONST(0.8169577266), - COEF_CONST(0.8408964153), - COEF_CONST(0.8655365610), - COEF_CONST(0.8908987181), - COEF_CONST(0.9170040432), - COEF_CONST(0.9438743127), - COEF_CONST(0.9715319412), - COEF_CONST(1.0000000000), - COEF_CONST(1.0293022366), - COEF_CONST(1.0594630944), - COEF_CONST(1.0905077327), - COEF_CONST(1.1224620483), - COEF_CONST(1.1553526969), - COEF_CONST(1.1892071150), - COEF_CONST(1.2240535433), - COEF_CONST(1.2599210499), - COEF_CONST(1.2968395547), - COEF_CONST(1.3348398542), - COEF_CONST(1.3739536475), - COEF_CONST(1.4142135624), - COEF_CONST(1.4556531828), - COEF_CONST(1.4983070769), - COEF_CONST(1.5422108254), - COEF_CONST(1.5874010520), - COEF_CONST(1.6339154532), - COEF_CONST(1.6817928305), - COEF_CONST(1.7310731220), - COEF_CONST(1.7817974363), - COEF_CONST(1.8340080864), - COEF_CONST(1.8877486254), - COEF_CONST(1.9430638823) -}; -#endif - -void drc_decode(drc_info *drc, real_t *spec) -{ - uint16_t i, bd, top; -#ifdef FIXED_POINT - int32_t exp, frac; -#else - real_t factor, exp; -#endif - uint16_t bottom = 0; - - if (drc->num_bands == 1) - drc->band_top[0] = 1024/4 - 1; - - for (bd = 0; bd < drc->num_bands; bd++) - { - top = 4 * (drc->band_top[bd] + 1); - -#ifndef FIXED_POINT - /* Decode DRC gain factor */ - if (drc->dyn_rng_sgn[bd]) /* compress */ - exp = -drc->ctrl1 * (drc->dyn_rng_ctl[bd] - (DRC_REF_LEVEL - drc->prog_ref_level))/REAL_CONST(24.0); - else /* boost */ - exp = drc->ctrl2 * (drc->dyn_rng_ctl[bd] - (DRC_REF_LEVEL - drc->prog_ref_level))/REAL_CONST(24.0); - factor = (real_t)pow(2.0, exp); - - /* Apply gain factor */ - for (i = bottom; i < top; i++) - spec[i] *= factor; -#else - /* Decode DRC gain factor */ - if (drc->dyn_rng_sgn[bd]) /* compress */ - { - exp = -1 * (drc->dyn_rng_ctl[bd] - (DRC_REF_LEVEL - drc->prog_ref_level))/ 24; - frac = -1 * (drc->dyn_rng_ctl[bd] - (DRC_REF_LEVEL - drc->prog_ref_level)) % 24; - } else { /* boost */ - exp = (drc->dyn_rng_ctl[bd] - (DRC_REF_LEVEL - drc->prog_ref_level))/ 24; - frac = (drc->dyn_rng_ctl[bd] - (DRC_REF_LEVEL - drc->prog_ref_level)) % 24; - } - - /* Apply gain factor */ - if (exp < 0) - { - for (i = bottom; i < top; i++) - { - spec[i] >>= -exp; - if (frac) - spec[i] = MUL_R(spec[i],drc_pow2_table[frac+23]); - } - } else { - for (i = bottom; i < top; i++) - { - spec[i] <<= exp; - if (frac) - spec[i] = MUL_R(spec[i],drc_pow2_table[frac+23]); - } - } -#endif - - bottom = top; - } -} diff --git a/apps/codecs/libfaad/drc.h b/apps/codecs/libfaad/drc.h deleted file mode 100644 index 38037a1a12..0000000000 --- a/apps/codecs/libfaad/drc.h +++ /dev/null @@ -1,45 +0,0 @@ -/* -** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -** -** Any non-GPL usage of this software or parts of this software is strictly -** forbidden. -** -** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. -** -** $Id$ -**/ - -#ifndef __DRC_H__ -#define __DRC_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -#define DRC_REF_LEVEL 20*4 /* -20 dB */ - - -drc_info *drc_init(real_t cut, real_t boost); -void drc_decode(drc_info *drc, real_t *spec); - - -#ifdef __cplusplus -} -#endif -#endif diff --git a/apps/codecs/libfaad/drm_dec.c b/apps/codecs/libfaad/drm_dec.c deleted file mode 100644 index f0b0f01f2b..0000000000 --- a/apps/codecs/libfaad/drm_dec.c +++ /dev/null @@ -1,992 +0,0 @@ -/* -** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR and PS decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -** -** Any non-GPL usage of this software or parts of this software is strictly -** forbidden. -** -** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. -** -** $Id$ -**/ - -#include -#include -#include -#include -#include "common.h" - -#ifdef DRM - -#include "sbr_dec.h" -#include "drm_dec.h" -#include "bits.h" - -/* constants */ -#define DECAY_CUTOFF 3 -#define DECAY_SLOPE 0.05f - -/* type definitions */ -typedef const int8_t (*drm_ps_huff_tab)[2]; - - -/* binary search huffman tables */ -static const int8_t f_huffman_sa[][2] = -{ - { /*0*/ -15, 1 }, /* index 0: 1 bits: x */ - { 2, 3 }, /* index 1: 2 bits: 1x */ - { /*7*/ -8, 4 }, /* index 2: 3 bits: 10x */ - { 5, 6 }, /* index 3: 3 bits: 11x */ - { /*1*/ -14, /*-1*/ -16 }, /* index 4: 4 bits: 101x */ - { /*-2*/ -17, 7 }, /* index 5: 4 bits: 110x */ - { 8, 9 }, /* index 6: 4 bits: 111x */ - { /*2*/ -13, /*-3*/ -18 }, /* index 7: 5 bits: 1101x */ - { /*3*/ -12, 10 }, /* index 8: 5 bits: 1110x */ - { 11, 12 }, /* index 9: 5 bits: 1111x */ - { /*4*/ -11, /*5*/ -10 }, /* index 10: 6 bits: 11101x */ - { /*-4*/ -19, /*-5*/ -20 }, /* index 11: 6 bits: 11110x */ - { /*6*/ -9, 13 }, /* index 12: 6 bits: 11111x */ - { /*-7*/ -22, /*-6*/ -21 } /* index 13: 7 bits: 111111x */ -}; - -static const int8_t t_huffman_sa[][2] = -{ - { /*0*/ -15, 1 }, /* index 0: 1 bits: x */ - { 2, 3 }, /* index 1: 2 bits: 1x */ - { /*-1*/ -16, /*1*/ -14 }, /* index 2: 3 bits: 10x */ - { 4, 5 }, /* index 3: 3 bits: 11x */ - { /*-2*/ -17, /*2*/ -13 }, /* index 4: 4 bits: 110x */ - { 6, 7 }, /* index 5: 4 bits: 111x */ - { /*-3*/ -18, /*3*/ -12 }, /* index 6: 5 bits: 1110x */ - { 8, 9 }, /* index 7: 5 bits: 1111x */ - { /*-4*/ -19, /*4*/ -11 }, /* index 8: 6 bits: 11110x */ - { 10, 11 }, /* index 9: 6 bits: 11111x */ - { /*-5*/ -20, /*5*/ -10 }, /* index 10: 7 bits: 111110x */ - { /*-6*/ -21, 12 }, /* index 11: 7 bits: 111111x */ - { /*-7*/ -22, 13 }, /* index 12: 8 bits: 1111111x */ - { /*6*/ -9, /*7*/ -8 } /* index 13: 9 bits: 11111111x */ -}; - -static const int8_t f_huffman_pan[][2] = -{ - { /*0*/ -15, 1 }, /* index 0: 1 bits: x */ - { /*-1*/ -16, 2 }, /* index 1: 2 bits: 1x */ - { /*1*/ -14, 3 }, /* index 2: 3 bits: 11x */ - { 4, 5 }, /* index 3: 4 bits: 111x */ - { /*-2*/ -17, /*2*/ -13 }, /* index 4: 5 bits: 1110x */ - { 6, 7 }, /* index 5: 5 bits: 1111x */ - { /*-3*/ -18, /*3*/ -12 }, /* index 6: 6 bits: 11110x */ - { 8, 9 }, /* index 7: 6 bits: 11111x */ - { /*-4*/ -19, /*4*/ -11 }, /* index 8: 7 bits: 111110x */ - { 10, 11 }, /* index 9: 7 bits: 111111x */ - { /*-5*/ -20, /*5*/ -10 }, /* index 10: 8 bits: 1111110x */ - { 12, 13 }, /* index 11: 8 bits: 1111111x */ - { /*-6*/ -21, /*6*/ -9 }, /* index 12: 9 bits: 11111110x */ - { /*-7*/ -22, 14 }, /* index 13: 9 bits: 11111111x */ - { /*7*/ -8, 15 }, /* index 14: 10 bits: 111111111x */ - { 16, 17 }, /* index 15: 11 bits: 1111111111x */ - { /*-8*/ -23, /*8*/ -7 }, /* index 16: 12 bits: 11111111110x */ - { 18, 19 }, /* index 17: 12 bits: 11111111111x */ - { /*-10*/ -25, 20 }, /* index 18: 13 bits: 111111111110x */ - { 21, 22 }, /* index 19: 13 bits: 111111111111x */ - { /*-9*/ -24, /*9*/ -6 }, /* index 20: 14 bits: 1111111111101x */ - { /*10*/ -5, 23 }, /* index 21: 14 bits: 1111111111110x */ - { 24, 25 }, /* index 22: 14 bits: 1111111111111x */ - { /*-13*/ -28, /*-11*/ -26 }, /* index 23: 15 bits: 11111111111101x */ - { /*11*/ -4, /*13*/ -2 }, /* index 24: 15 bits: 11111111111110x */ - { 26, 27 }, /* index 25: 15 bits: 11111111111111x */ - { /*-14*/ -29, /*-12*/ -27 }, /* index 26: 16 bits: 111111111111110x */ - { /*12*/ -3, /*14*/ -1 } /* index 27: 16 bits: 111111111111111x */ -}; - -static const int8_t t_huffman_pan[][2] = -{ - { /*0*/ -15, 1 }, /* index 0: 1 bits: x */ - { /*-1*/ -16, 2 }, /* index 1: 2 bits: 1x */ - { /*1*/ -14, 3 }, /* index 2: 3 bits: 11x */ - { /*-2*/ -17, 4 }, /* index 3: 4 bits: 111x */ - { /*2*/ -13, 5 }, /* index 4: 5 bits: 1111x */ - { /*-3*/ -18, 6 }, /* index 5: 6 bits: 11111x */ - { /*3*/ -12, 7 }, /* index 6: 7 bits: 111111x */ - { /*-4*/ -19, 8 }, /* index 7: 8 bits: 1111111x */ - { /*4*/ -11, 9 }, /* index 8: 9 bits: 11111111x */ - { 10, 11 }, /* index 9: 10 bits: 111111111x */ - { /*-5*/ -20, /*5*/ -10 }, /* index 10: 11 bits: 1111111110x */ - { 12, 13 }, /* index 11: 11 bits: 1111111111x */ - { /*-6*/ -21, /*6*/ -9 }, /* index 12: 12 bits: 11111111110x */ - { 14, 15 }, /* index 13: 12 bits: 11111111111x */ - { /*-7*/ -22, /*7*/ -8 }, /* index 14: 13 bits: 111111111110x */ - { 16, 17 }, /* index 15: 13 bits: 111111111111x */ - { /*-8*/ -23, /*8*/ -7 }, /* index 16: 14 bits: 1111111111110x */ - { 18, 19 }, /* index 17: 14 bits: 1111111111111x */ - { /*-10*/ -25, /*10*/ -5 }, /* index 18: 15 bits: 11111111111110x */ - { 20, 21 }, /* index 19: 15 bits: 11111111111111x */ - { /*-9*/ -24, /*9*/ -6 }, /* index 20: 16 bits: 111111111111110x */ - { 22, 23 }, /* index 21: 16 bits: 111111111111111x */ - { 24, 25 }, /* index 22: 17 bits: 1111111111111110x */ - { 26, 27 }, /* index 23: 17 bits: 1111111111111111x */ - { /*-14*/ -29, /*-13*/ -28 }, /* index 24: 18 bits: 11111111111111100x */ - { /*-12*/ -27, /*-11*/ -26 }, /* index 25: 18 bits: 11111111111111101x */ - { /*11*/ -4, /*12*/ -3 }, /* index 26: 18 bits: 11111111111111110x */ - { /*13*/ -2, /*14*/ -1 } /* index 27: 18 bits: 11111111111111111x */ -}; - -/* There are 3 classes in the standard but the last 2 are identical */ -static const real_t sa_quant[8][2] = -{ - { FRAC_CONST(0.0000), FRAC_CONST(0.0000) }, - { FRAC_CONST(0.0501), FRAC_CONST(0.1778) }, - { FRAC_CONST(0.0706), FRAC_CONST(0.2818) }, - { FRAC_CONST(0.0995), FRAC_CONST(0.4467) }, - { FRAC_CONST(0.1399), FRAC_CONST(0.5623) }, - { FRAC_CONST(0.1957), FRAC_CONST(0.7079) }, - { FRAC_CONST(0.2713), FRAC_CONST(0.8913) }, - { FRAC_CONST(0.3699), FRAC_CONST(1.0000) }, -}; - -/* We don't need the actual quantizer values */ -#if 0 -static const real_t pan_quant[8][5] = -{ - { COEF_CONST(0.0000), COEF_CONST(0.0000), COEF_CONST(0.0000), COEF_CONST(0.0000), COEF_CONST(0.0000) }, - { COEF_CONST(0.1661), COEF_CONST(0.1661), COEF_CONST(0.3322), COEF_CONST(0.3322), COEF_CONST(0.3322) }, - { COEF_CONST(0.3322), COEF_CONST(0.3322), COEF_CONST(0.6644), COEF_CONST(0.8305), COEF_CONST(0.8305) }, - { COEF_CONST(0.4983), COEF_CONST(0.6644), COEF_CONST(0.9966), COEF_CONST(1.4949), COEF_CONST(1.6610) }, - { COEF_CONST(0.6644), COEF_CONST(0.9966), COEF_CONST(1.4949), COEF_CONST(2.1593), COEF_CONST(2.4914) }, - { COEF_CONST(0.8305), COEF_CONST(1.3288), COEF_CONST(2.1593), COEF_CONST(2.9897), COEF_CONST(3.4880) }, - { COEF_CONST(0.9966), COEF_CONST(1.8271), COEF_CONST(2.8236), COEF_CONST(3.8202), COEF_CONST(4.6507) }, - { COEF_CONST(1.3288), COEF_CONST(2.3253), COEF_CONST(3.4880), COEF_CONST(4.6507), COEF_CONST(5.8134) }, -}; -#endif - -/* 2^(pan_quant[x][y] */ -static const real_t pan_pow_2_pos[8][5] = { - { REAL_CONST(1.0000000), REAL_CONST(1.0000000), REAL_CONST(1.0000000), REAL_CONST(1.0000000), REAL_CONST(1.0000000) }, - { REAL_CONST(1.1220021), REAL_CONST(1.1220021), REAL_CONST(1.2589312), REAL_CONST(1.2589312), REAL_CONST(1.2589312) }, - { REAL_CONST(1.2589312), REAL_CONST(1.2589312), REAL_CONST(1.5849090), REAL_CONST(1.7783016), REAL_CONST(1.7783016) }, - { REAL_CONST(1.4125481), REAL_CONST(1.5849090), REAL_CONST(1.9952921), REAL_CONST(2.8184461), REAL_CONST(3.1623565) }, - { REAL_CONST(1.5849090), REAL_CONST(1.9952922), REAL_CONST(2.8184461), REAL_CONST(4.4669806), REAL_CONST(5.6232337) }, - { REAL_CONST(1.7783016), REAL_CONST(2.5119365), REAL_CONST(4.4669806), REAL_CONST(7.9430881), REAL_CONST(11.219994) }, - { REAL_CONST(1.9952921), REAL_CONST(3.5482312), REAL_CONST(7.0792671), REAL_CONST(14.125206), REAL_CONST(25.118876) }, - { REAL_CONST(2.5119365), REAL_CONST(5.0116998), REAL_CONST(11.219994), REAL_CONST(25.118876), REAL_CONST(56.235140) } -}; - -/* 2^(-pan_quant[x][y] */ -static const real_t pan_pow_2_neg[8][5] = { - { REAL_CONST(1), REAL_CONST(1), REAL_CONST(1), REAL_CONST(1), REAL_CONST(1) }, - { REAL_CONST(0.8912487), REAL_CONST(0.8912487), REAL_CONST(0.7943242), REAL_CONST(0.7943242), REAL_CONST(0.7943242) }, - { REAL_CONST(0.7943242), REAL_CONST(0.7943242), REAL_CONST(0.6309511), REAL_CONST(0.5623344), REAL_CONST(0.5623344) }, - { REAL_CONST(0.7079405), REAL_CONST(0.6309511), REAL_CONST(0.5011797), REAL_CONST(0.3548054), REAL_CONST(0.3162199) }, - { REAL_CONST(0.6309511), REAL_CONST(0.5011797), REAL_CONST(0.3548054), REAL_CONST(0.2238649), REAL_CONST(0.1778336) }, - { REAL_CONST(0.5623343), REAL_CONST(0.3980992), REAL_CONST(0.2238649), REAL_CONST(0.1258956), REAL_CONST(0.0891266) }, - { REAL_CONST(0.5011797), REAL_CONST(0.2818306), REAL_CONST(0.1412576), REAL_CONST(0.0707954), REAL_CONST(0.0398107) }, - { REAL_CONST(0.3980992), REAL_CONST(0.1995331), REAL_CONST(0.0891267), REAL_CONST(0.0398107), REAL_CONST(0.0177825) } -}; - -/* 2^(pan_quant[x][y]/30) */ -static const real_t pan_pow_2_30_pos[8][5] = { - { COEF_CONST(1), COEF_CONST(1), COEF_CONST(1), COEF_CONST(1), COEF_CONST(1) }, - { COEF_CONST(1.003845098), COEF_CONST(1.003845098), COEF_CONST(1.007704982), COEF_CONST(1.007704982), COEF_CONST(1.007704982) }, - { COEF_CONST(1.007704982), COEF_CONST(1.007704982), COEF_CONST(1.01546933), COEF_CONST(1.019373909), COEF_CONST(1.019373909) }, - { COEF_CONST(1.011579706), COEF_CONST(1.01546933), COEF_CONST(1.023293502), COEF_CONST(1.035142941), COEF_CONST(1.039123167) }, - { COEF_CONST(1.01546933), COEF_CONST(1.023293502), COEF_CONST(1.035142941), COEF_CONST(1.051155908), COEF_CONST(1.059252598) }, - { COEF_CONST(1.019373909), COEF_CONST(1.03117796), COEF_CONST(1.051155908), COEF_CONST(1.071518432), COEF_CONST(1.0839263) }, - { COEF_CONST(1.023293502), COEF_CONST(1.043118698), COEF_CONST(1.067414119), COEF_CONST(1.092277933), COEF_CONST(1.113439626) }, - { COEF_CONST(1.03117796), COEF_CONST(1.055195268), COEF_CONST(1.0839263), COEF_CONST(1.113439626), COEF_CONST(1.143756546) } -}; - -/* 2^(-pan_quant[x][y]/30) */ -static const real_t pan_pow_2_30_neg[8][5] = { - { COEF_CONST(1), COEF_CONST(1), COEF_CONST(1), COEF_CONST(1), COEF_CONST(1) }, - { COEF_CONST(0.99616963), COEF_CONST(0.99616963), COEF_CONST(0.992353931), COEF_CONST(0.992353931), COEF_CONST(0.99235393) }, - { COEF_CONST(0.992353931), COEF_CONST(0.992353931), COEF_CONST(0.984766325), COEF_CONST(0.980994305), COEF_CONST(0.980994305) }, - { COEF_CONST(0.988552848), COEF_CONST(0.984766325), COEF_CONST(0.977236734), COEF_CONST(0.966050157), COEF_CONST(0.962349827) }, - { COEF_CONST(0.984766325), COEF_CONST(0.977236734), COEF_CONST(0.966050157), COEF_CONST(0.951333663), COEF_CONST(0.944061881) }, - { COEF_CONST(0.980994305), COEF_CONST(0.969764715), COEF_CONST(0.951333663), COEF_CONST(0.933255062), COEF_CONST(0.922571949) }, - { COEF_CONST(0.977236734), COEF_CONST(0.958663671), COEF_CONST(0.936843519), COEF_CONST(0.915517901), COEF_CONST(0.898117847) }, - { COEF_CONST(0.969764715), COEF_CONST(0.947691892), COEF_CONST(0.922571949), COEF_CONST(0.898117847), COEF_CONST(0.874311936) } -}; - -static const real_t g_decayslope[MAX_SA_BAND] = { - FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(0.95),FRAC_CONST(0.9), FRAC_CONST(0.85), FRAC_CONST(0.8), - FRAC_CONST(0.75),FRAC_CONST(0.7), FRAC_CONST(0.65),FRAC_CONST(0.6), FRAC_CONST(0.55),FRAC_CONST(0.5), FRAC_CONST(0.45), - FRAC_CONST(0.4), FRAC_CONST(0.35),FRAC_CONST(0.3), FRAC_CONST(0.25),FRAC_CONST(0.2), FRAC_CONST(0.15), FRAC_CONST(0.1), - FRAC_CONST(0.05),FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), - FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), - FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), - FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0) -}; - -static const real_t sa_sqrt_1_minus[8][2] = { - { FRAC_CONST(1), FRAC_CONST(1) }, - { FRAC_CONST(0.998744206), FRAC_CONST(0.984066644) }, - { FRAC_CONST(0.997504707), FRAC_CONST(0.959473168) }, - { FRAC_CONST(0.995037562), FRAC_CONST(0.894683804) }, - { FRAC_CONST(0.990165638), FRAC_CONST(0.826933317) }, - { FRAC_CONST(0.980663811), FRAC_CONST(0.706312672) }, - { FRAC_CONST(0.962494836), FRAC_CONST(0.45341406) }, - { FRAC_CONST(0.929071574), FRAC_CONST(0) } -}; - -static const uint8_t sa_freq_scale[9][2] = -{ - { 0, 0}, - { 1, 1}, - { 2, 2}, - { 3, 3}, - { 5, 5}, - { 7, 7}, - {10,10}, - {13,13}, - {46,23} -}; - -static const uint8_t pan_freq_scale[21] = -{ - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, - 11, 12, 13, 14, 15, 18, 22, 26, 32, 64 -}; - -static const uint8_t pan_quant_class[20] = -{ - 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 2, 2, 2, 2, 3, 3, 3, 4, 4, 4 -}; - -/* Inverse mapping lookup */ -static const uint8_t pan_inv_freq[64] = { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, - 15, 15, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, - 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, - 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19 -}; - -static const uint8_t sa_inv_freq[MAX_SA_BAND] = { - 0, 1, 2, 3, 3, 4, 4, 5, 5, 5, 6, 6, 6, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7 -}; - -static const real_t filter_coeff[] = -{ - FRAC_CONST(0.65143905754106), - FRAC_CONST(0.56471812200776), - FRAC_CONST(0.48954165955695) -}; - -static const uint8_t delay_length[][2] = -{ - { 1, 3 }, { 2, 4 }, { 3, 5 } -}; - -static const real_t delay_fraction[] = -{ - FRAC_CONST(0.43), FRAC_CONST(0.75), FRAC_CONST(0.347) -}; - -static const real_t peak_decay[2] = -{ - FRAC_CONST(0.58664621951003), FRAC_CONST(0.76592833836465) -}; - -static const real_t smooth_coeff[2] = -{ - FRAC_CONST(0.6), FRAC_CONST(0.25) -}; - -/* Please note that these are the same tables as in plain PS */ -static const complex_t Q_Fract_allpass_Qmf[][3] = { - { { FRAC_CONST(0.7804303765), FRAC_CONST(0.6252426505) }, { FRAC_CONST(0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(0.8550928831), FRAC_CONST(0.5184748173) } }, - { { FRAC_CONST(-0.4399392009), FRAC_CONST(0.8980275393) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(-0.0643581524), FRAC_CONST(0.9979268909) } }, - { { FRAC_CONST(-0.9723699093), FRAC_CONST(-0.2334454209) }, { FRAC_CONST(0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(-0.9146071672), FRAC_CONST(0.4043435752) } }, - { { FRAC_CONST(0.0157073960), FRAC_CONST(-0.9998766184) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(-0.7814115286), FRAC_CONST(-0.6240159869) } }, - { { FRAC_CONST(0.9792228341), FRAC_CONST(-0.2027871907) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(0.1920081824), FRAC_CONST(-0.9813933372) } }, - { { FRAC_CONST(0.4115142524), FRAC_CONST(0.9114032984) }, { FRAC_CONST(0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(0.9589683414), FRAC_CONST(-0.2835132182) } }, - { { FRAC_CONST(-0.7996847630), FRAC_CONST(0.6004201174) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(0.6947838664), FRAC_CONST(0.7192186117) } }, - { { FRAC_CONST(-0.7604058385), FRAC_CONST(-0.6494481564) }, { FRAC_CONST(0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(-0.3164770305), FRAC_CONST(0.9486001730) } }, - { { FRAC_CONST(0.4679299891), FRAC_CONST(-0.8837655187) }, { FRAC_CONST(0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(-0.9874414206), FRAC_CONST(0.1579856575) } }, - { { FRAC_CONST(0.9645573497), FRAC_CONST(0.2638732493) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(-0.5966450572), FRAC_CONST(-0.8025052547) } }, - { { FRAC_CONST(-0.0471066870), FRAC_CONST(0.9988898635) }, { FRAC_CONST(0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(0.4357025325), FRAC_CONST(-0.9000906944) } }, - { { FRAC_CONST(-0.9851093888), FRAC_CONST(0.1719288528) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(0.9995546937), FRAC_CONST(-0.0298405960) } }, - { { FRAC_CONST(-0.3826831877), FRAC_CONST(-0.9238796234) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(0.4886211455), FRAC_CONST(0.8724960685) } }, - { { FRAC_CONST(0.8181498647), FRAC_CONST(-0.5750049949) }, { FRAC_CONST(0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(-0.5477093458), FRAC_CONST(0.8366686702) } }, - { { FRAC_CONST(0.7396308780), FRAC_CONST(0.6730127335) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(-0.9951074123), FRAC_CONST(-0.0987988561) } }, - { { FRAC_CONST(-0.4954589605), FRAC_CONST(0.8686313629) }, { FRAC_CONST(0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(-0.3725017905), FRAC_CONST(-0.9280315042) } }, - { { FRAC_CONST(-0.9557929039), FRAC_CONST(-0.2940406799) }, { FRAC_CONST(0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(0.6506417990), FRAC_CONST(-0.7593847513) } }, - { { FRAC_CONST(0.0784594864), FRAC_CONST(-0.9969173074) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(0.9741733670), FRAC_CONST(0.2258014232) } }, - { { FRAC_CONST(0.9900237322), FRAC_CONST(-0.1409008205) }, { FRAC_CONST(0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(0.2502108514), FRAC_CONST(0.9681913853) } }, - { { FRAC_CONST(0.3534744382), FRAC_CONST(0.9354441762) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(-0.7427945137), FRAC_CONST(0.6695194840) } }, - { { FRAC_CONST(-0.8358076215), FRAC_CONST(0.5490224361) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(-0.9370992780), FRAC_CONST(-0.3490629196) } }, - { { FRAC_CONST(-0.7181259394), FRAC_CONST(-0.6959131360) }, { FRAC_CONST(0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(-0.1237744763), FRAC_CONST(-0.9923103452) } }, - { { FRAC_CONST(0.5224990249), FRAC_CONST(-0.8526399136) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(0.8226406574), FRAC_CONST(-0.5685616732) } }, - { { FRAC_CONST(0.9460852146), FRAC_CONST(0.3239179254) }, { FRAC_CONST(0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(0.8844994903), FRAC_CONST(0.4665412009) } }, - { { FRAC_CONST(-0.1097348556), FRAC_CONST(0.9939609170) }, { FRAC_CONST(0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(-0.0047125919), FRAC_CONST(0.9999889135) } }, - { { FRAC_CONST(-0.9939610362), FRAC_CONST(0.1097337380) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(-0.8888573647), FRAC_CONST(0.4581840038) } }, - { { FRAC_CONST(-0.3239168525), FRAC_CONST(-0.9460855722) }, { FRAC_CONST(0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(-0.8172453642), FRAC_CONST(-0.5762898922) } }, - { { FRAC_CONST(0.8526405096), FRAC_CONST(-0.5224980116) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(0.1331215799), FRAC_CONST(-0.9910997152) } }, - { { FRAC_CONST(0.6959123611), FRAC_CONST(0.7181267142) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(0.9403476119), FRAC_CONST(-0.3402152061) } }, - { { FRAC_CONST(-0.5490233898), FRAC_CONST(0.8358070254) }, { FRAC_CONST(0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(0.7364512086), FRAC_CONST(0.6764906645) } }, - { { FRAC_CONST(-0.9354437590), FRAC_CONST(-0.3534754813) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(-0.2593250275), FRAC_CONST(0.9657900929) } }, - { { FRAC_CONST(0.1409019381), FRAC_CONST(-0.9900235534) }, { FRAC_CONST(0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(-0.9762582779), FRAC_CONST(0.2166097313) } }, - { { FRAC_CONST(0.9969173670), FRAC_CONST(-0.0784583688) }, { FRAC_CONST(0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(-0.6434556246), FRAC_CONST(-0.7654833794) } }, - { { FRAC_CONST(0.2940396070), FRAC_CONST(0.9557932615) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(0.3812320232), FRAC_CONST(-0.9244794250) } }, - { { FRAC_CONST(-0.8686318994), FRAC_CONST(0.4954580069) }, { FRAC_CONST(0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(0.9959943891), FRAC_CONST(-0.0894154981) } }, - { { FRAC_CONST(-0.6730118990), FRAC_CONST(-0.7396316528) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(0.5397993922), FRAC_CONST(0.8417937160) } }, - { { FRAC_CONST(0.5750059485), FRAC_CONST(-0.8181492686) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(-0.4968227744), FRAC_CONST(0.8678520322) } }, - { { FRAC_CONST(0.9238792062), FRAC_CONST(0.3826842010) }, { FRAC_CONST(0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(-0.9992290139), FRAC_CONST(-0.0392601527) } }, - { { FRAC_CONST(-0.1719299555), FRAC_CONST(0.9851091504) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(-0.4271997511), FRAC_CONST(-0.9041572809) } }, - { { FRAC_CONST(-0.9988899231), FRAC_CONST(0.0471055657) }, { FRAC_CONST(0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(0.6041822433), FRAC_CONST(-0.7968461514) } }, - { { FRAC_CONST(-0.2638721764), FRAC_CONST(-0.9645576477) }, { FRAC_CONST(0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(0.9859085083), FRAC_CONST(0.1672853529) } }, - { { FRAC_CONST(0.8837660551), FRAC_CONST(-0.4679289758) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(0.3075223565), FRAC_CONST(0.9515408874) } }, - { { FRAC_CONST(0.6494473219), FRAC_CONST(0.7604066133) }, { FRAC_CONST(0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(-0.7015317082), FRAC_CONST(0.7126382589) } }, - { { FRAC_CONST(-0.6004210114), FRAC_CONST(0.7996840477) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(-0.9562535882), FRAC_CONST(-0.2925389707) } }, - { { FRAC_CONST(-0.9114028811), FRAC_CONST(-0.4115152657) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(-0.1827499419), FRAC_CONST(-0.9831594229) } }, - { { FRAC_CONST(0.2027882934), FRAC_CONST(-0.9792225957) }, { FRAC_CONST(0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(0.7872582674), FRAC_CONST(-0.6166234016) } }, - { { FRAC_CONST(0.9998766780), FRAC_CONST(-0.0157062728) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(0.9107555747), FRAC_CONST(0.4129458666) } }, - { { FRAC_CONST(0.2334443331), FRAC_CONST(0.9723701477) }, { FRAC_CONST(0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(0.0549497530), FRAC_CONST(0.9984891415) } }, - { { FRAC_CONST(-0.8980280757), FRAC_CONST(0.4399381876) }, { FRAC_CONST(0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(-0.8599416018), FRAC_CONST(0.5103924870) } }, - { { FRAC_CONST(-0.6252418160), FRAC_CONST(-0.7804310918) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(-0.8501682281), FRAC_CONST(-0.5265110731) } }, - { { FRAC_CONST(0.6252435446), FRAC_CONST(-0.7804297209) }, { FRAC_CONST(0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(0.0737608299), FRAC_CONST(-0.9972759485) } }, - { { FRAC_CONST(0.8980270624), FRAC_CONST(0.4399402142) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(0.9183775187), FRAC_CONST(-0.3957053721) } }, - { { FRAC_CONST(-0.2334465086), FRAC_CONST(0.9723696709) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(0.7754954696), FRAC_CONST(0.6313531399) } }, - { { FRAC_CONST(-0.9998766184), FRAC_CONST(-0.0157085191) }, { FRAC_CONST(0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(-0.2012493610), FRAC_CONST(0.9795400500) } }, - { { FRAC_CONST(-0.2027861029), FRAC_CONST(-0.9792230725) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(-0.9615978599), FRAC_CONST(0.2744622827) } }, - { { FRAC_CONST(0.9114037752), FRAC_CONST(-0.4115132093) }, { FRAC_CONST(0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(-0.6879743338), FRAC_CONST(-0.7257350087) } }, - { { FRAC_CONST(0.6004192233), FRAC_CONST(0.7996854186) }, { FRAC_CONST(0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(0.3254036009), FRAC_CONST(-0.9455752373) } }, - { { FRAC_CONST(-0.6494490504), FRAC_CONST(0.7604051232) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(0.9888865948), FRAC_CONST(-0.1486719251) } }, - { { FRAC_CONST(-0.8837650418), FRAC_CONST(-0.4679309726) }, { FRAC_CONST(0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(0.5890548825), FRAC_CONST(0.8080930114) } }, - { { FRAC_CONST(0.2638743520), FRAC_CONST(-0.9645570517) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(-0.4441666007), FRAC_CONST(0.8959442377) } }, - { { FRAC_CONST(0.9988898039), FRAC_CONST(0.0471078083) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(-0.9997915030), FRAC_CONST(0.0204183888) } }, - { { FRAC_CONST(0.1719277352), FRAC_CONST(0.9851095676) }, { FRAC_CONST(0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(-0.4803760946), FRAC_CONST(-0.8770626187) } }, - { { FRAC_CONST(-0.9238800406), FRAC_CONST(0.3826821446) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(0.5555707216), FRAC_CONST(-0.8314692974) } }, - { { FRAC_CONST(-0.5750041008), FRAC_CONST(-0.8181505203) }, { FRAC_CONST(0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(0.9941320419), FRAC_CONST(0.1081734300) } } -}; - -static const complex_t Phi_Fract_Qmf[] = { - { FRAC_CONST(0.8181497455), FRAC_CONST(0.5750052333) }, - { FRAC_CONST(-0.2638730407), FRAC_CONST(0.9645574093) }, - { FRAC_CONST(-0.9969173074), FRAC_CONST(0.0784590989) }, - { FRAC_CONST(-0.4115143716), FRAC_CONST(-0.9114032984) }, - { FRAC_CONST(0.7181262970), FRAC_CONST(-0.6959127784) }, - { FRAC_CONST(0.8980275989), FRAC_CONST(0.4399391711) }, - { FRAC_CONST(-0.1097343117), FRAC_CONST(0.9939609766) }, - { FRAC_CONST(-0.9723699093), FRAC_CONST(0.2334453613) }, - { FRAC_CONST(-0.5490227938), FRAC_CONST(-0.8358073831) }, - { FRAC_CONST(0.6004202366), FRAC_CONST(-0.7996846437) }, - { FRAC_CONST(0.9557930231), FRAC_CONST(0.2940403223) }, - { FRAC_CONST(0.0471064523), FRAC_CONST(0.9988898635) }, - { FRAC_CONST(-0.9238795042), FRAC_CONST(0.3826834261) }, - { FRAC_CONST(-0.6730124950), FRAC_CONST(-0.7396311164) }, - { FRAC_CONST(0.4679298103), FRAC_CONST(-0.8837656379) }, - { FRAC_CONST(0.9900236726), FRAC_CONST(0.1409012377) }, - { FRAC_CONST(0.2027872950), FRAC_CONST(0.9792228341) }, - { FRAC_CONST(-0.8526401520), FRAC_CONST(0.5224985480) }, - { FRAC_CONST(-0.7804304361), FRAC_CONST(-0.6252426505) }, - { FRAC_CONST(0.3239174187), FRAC_CONST(-0.9460853338) }, - { FRAC_CONST(0.9998766184), FRAC_CONST(-0.0157073177) }, - { FRAC_CONST(0.3534748554), FRAC_CONST(0.9354440570) }, - { FRAC_CONST(-0.7604059577), FRAC_CONST(0.6494480371) }, - { FRAC_CONST(-0.8686315417), FRAC_CONST(-0.4954586625) }, - { FRAC_CONST(0.1719291061), FRAC_CONST(-0.9851093292) }, - { FRAC_CONST(0.9851093292), FRAC_CONST(-0.1719291061) }, - { FRAC_CONST(0.4954586625), FRAC_CONST(0.8686315417) }, - { FRAC_CONST(-0.6494480371), FRAC_CONST(0.7604059577) }, - { FRAC_CONST(-0.9354440570), FRAC_CONST(-0.3534748554) }, - { FRAC_CONST(0.0157073177), FRAC_CONST(-0.9998766184) }, - { FRAC_CONST(0.9460853338), FRAC_CONST(-0.3239174187) }, - { FRAC_CONST(0.6252426505), FRAC_CONST(0.7804304361) }, - { FRAC_CONST(-0.5224985480), FRAC_CONST(0.8526401520) }, - { FRAC_CONST(-0.9792228341), FRAC_CONST(-0.2027872950) }, - { FRAC_CONST(-0.1409012377), FRAC_CONST(-0.9900236726) }, - { FRAC_CONST(0.8837656379), FRAC_CONST(-0.4679298103) }, - { FRAC_CONST(0.7396311164), FRAC_CONST(0.6730124950) }, - { FRAC_CONST(-0.3826834261), FRAC_CONST(0.9238795042) }, - { FRAC_CONST(-0.9988898635), FRAC_CONST(-0.0471064523) }, - { FRAC_CONST(-0.2940403223), FRAC_CONST(-0.9557930231) }, - { FRAC_CONST(0.7996846437), FRAC_CONST(-0.6004202366) }, - { FRAC_CONST(0.8358073831), FRAC_CONST(0.5490227938) }, - { FRAC_CONST(-0.2334453613), FRAC_CONST(0.9723699093) }, - { FRAC_CONST(-0.9939609766), FRAC_CONST(0.1097343117) }, - { FRAC_CONST(-0.4399391711), FRAC_CONST(-0.8980275989) }, - { FRAC_CONST(0.6959127784), FRAC_CONST(-0.7181262970) }, - { FRAC_CONST(0.9114032984), FRAC_CONST(0.4115143716) }, - { FRAC_CONST(-0.0784590989), FRAC_CONST(0.9969173074) }, - { FRAC_CONST(-0.9645574093), FRAC_CONST(0.2638730407) }, - { FRAC_CONST(-0.5750052333), FRAC_CONST(-0.8181497455) }, - { FRAC_CONST(0.5750052333), FRAC_CONST(-0.8181497455) }, - { FRAC_CONST(0.9645574093), FRAC_CONST(0.2638730407) }, - { FRAC_CONST(0.0784590989), FRAC_CONST(0.9969173074) }, - { FRAC_CONST(-0.9114032984), FRAC_CONST(0.4115143716) }, - { FRAC_CONST(-0.6959127784), FRAC_CONST(-0.7181262970) }, - { FRAC_CONST(0.4399391711), FRAC_CONST(-0.8980275989) }, - { FRAC_CONST(0.9939609766), FRAC_CONST(0.1097343117) }, - { FRAC_CONST(0.2334453613), FRAC_CONST(0.9723699093) }, - { FRAC_CONST(-0.8358073831), FRAC_CONST(0.5490227938) }, - { FRAC_CONST(-0.7996846437), FRAC_CONST(-0.6004202366) }, - { FRAC_CONST(0.2940403223), FRAC_CONST(-0.9557930231) }, - { FRAC_CONST(0.9988898635), FRAC_CONST(-0.0471064523) }, - { FRAC_CONST(0.3826834261), FRAC_CONST(0.9238795042) }, - { FRAC_CONST(-0.7396311164), FRAC_CONST(0.6730124950) } -}; - -/* static variables */ -static drm_ps_info s_drm_ps_info; - -/* static function declarations */ -static void drm_ps_sa_element(drm_ps_info *ps, bitfile *ld); -static void drm_ps_pan_element(drm_ps_info *ps, bitfile *ld); -static int8_t huff_dec(bitfile *ld, drm_ps_huff_tab huff); - - -uint16_t drm_ps_data(drm_ps_info *ps, bitfile *ld) -{ - uint16_t bits = (uint16_t)faad_get_processed_bits(ld); - - ps->drm_ps_data_available = 1; - - ps->bs_enable_sa = faad_get1bit(ld); - ps->bs_enable_pan = faad_get1bit(ld); - - if (ps->bs_enable_sa) - { - drm_ps_sa_element(ps, ld); - } - - if (ps->bs_enable_pan) - { - drm_ps_pan_element(ps, ld); - } - - bits = (uint16_t)faad_get_processed_bits(ld) - bits; - - return bits; -} - -static void drm_ps_sa_element(drm_ps_info *ps, bitfile *ld) -{ - drm_ps_huff_tab huff; - uint8_t band; - - ps->bs_sa_dt_flag = faad_get1bit(ld); - if (ps->bs_sa_dt_flag) - { - huff = t_huffman_sa; - } else { - huff = f_huffman_sa; - } - - for (band = 0; band < DRM_NUM_SA_BANDS; band++) - { - ps->bs_sa_data[band] = huff_dec(ld, huff); - } -} - -static void drm_ps_pan_element(drm_ps_info *ps, bitfile *ld) -{ - drm_ps_huff_tab huff; - uint8_t band; - - ps->bs_pan_dt_flag = faad_get1bit(ld); - if (ps->bs_pan_dt_flag) - { - huff = t_huffman_pan; - } else { - huff = f_huffman_pan; - } - - for (band = 0; band < DRM_NUM_PAN_BANDS; band++) - { - ps->bs_pan_data[band] = huff_dec(ld, huff); - } -} - -/* binary search huffman decoding */ -static int8_t huff_dec(bitfile *ld, drm_ps_huff_tab huff) -{ - uint8_t bit; - int16_t index = 0; - - while (index >= 0) - { - bit = (uint8_t)faad_get1bit(ld); - index = huff[index][bit]; - } - - return index + 15; -} - - -static int8_t sa_delta_clip(drm_ps_info *ps, int8_t i) -{ - if (i < 0) { - /* printf(" SAminclip %d", i); */ - ps->sa_decode_error = 1; - return 0; - } else if (i > 7) { - /* printf(" SAmaxclip %d", i); */ - ps->sa_decode_error = 1; - return 7; - } else - return i; -} - -static int8_t pan_delta_clip(drm_ps_info *ps, int8_t i) -{ - if (i < -7) { - /* printf(" PANminclip %d", i); */ - ps->pan_decode_error = 1; - return -7; - } else if (i > 7) { - /* printf(" PANmaxclip %d", i); */ - ps->pan_decode_error = 1; - return 7; - } else - return i; -} - -static void drm_ps_delta_decode(drm_ps_info *ps) -{ - uint8_t band; - - if (ps->bs_enable_sa) - { - if (ps->bs_sa_dt_flag && !ps->g_last_had_sa) - { - for (band = 0; band < DRM_NUM_SA_BANDS; band++) - { - ps->g_prev_sa_index[band] = 0; - } - } - if (ps->bs_sa_dt_flag) - { - ps->g_sa_index[0] = sa_delta_clip(ps, ps->g_prev_sa_index[0]+ps->bs_sa_data[0]); - - } else { - ps->g_sa_index[0] = sa_delta_clip(ps,ps->bs_sa_data[0]); - } - - for (band = 1; band < DRM_NUM_SA_BANDS; band++) - { - if (ps->bs_sa_dt_flag) - { - ps->g_sa_index[band] = sa_delta_clip(ps, ps->g_prev_sa_index[band] + ps->bs_sa_data[band]); - } else { - ps->g_sa_index[band] = sa_delta_clip(ps, ps->g_sa_index[band-1] + ps->bs_sa_data[band]); - } - } - } - - /* An error during SA decoding implies PAN data will be undecodable, too */ - /* Also, we don't like on/off switching in PS, so we force to last settings */ - if (ps->sa_decode_error) { - ps->pan_decode_error = 1; - ps->bs_enable_pan = ps->g_last_had_pan; - ps->bs_enable_sa = ps->g_last_had_sa; - } - - - if (ps->bs_enable_sa) - { - if (ps->sa_decode_error) { - for (band = 0; band < DRM_NUM_SA_BANDS; band++) - { - ps->g_sa_index[band] = ps->g_last_good_sa_index[band]; - } - } else { - for (band = 0; band < DRM_NUM_SA_BANDS; band++) - { - ps->g_last_good_sa_index[band] = ps->g_sa_index[band]; - } - } - } - - if (ps->bs_enable_pan) - { - if (ps->bs_pan_dt_flag && !ps->g_last_had_pan) - { -/* The DRM PS spec doesn't say anything about this case. (deltacoded in time without a previous frame) - AAC PS spec you must tread previous frame as 0, so that's what we try. -*/ - for (band = 0; band < DRM_NUM_PAN_BANDS; band++) - { - ps->g_prev_pan_index[band] = 0; - } - } - - if (ps->bs_pan_dt_flag) - { - ps->g_pan_index[0] = pan_delta_clip(ps, ps->g_prev_pan_index[0]+ps->bs_pan_data[0]); - } else { - ps->g_pan_index[0] = pan_delta_clip(ps, ps->bs_pan_data[0]); - } - - for (band = 1; band < DRM_NUM_PAN_BANDS; band++) - { - if (ps->bs_pan_dt_flag) - { - ps->g_pan_index[band] = pan_delta_clip(ps, ps->g_prev_pan_index[band] + ps->bs_pan_data[band]); - } else { - ps->g_pan_index[band] = pan_delta_clip(ps, ps->g_pan_index[band-1] + ps->bs_pan_data[band]); - } - } - - if (ps->pan_decode_error) { - for (band = 0; band < DRM_NUM_PAN_BANDS; band++) - { - ps->g_pan_index[band] = ps->g_last_good_pan_index[band]; - } - } else { - for (band = 0; band < DRM_NUM_PAN_BANDS; band++) - { - ps->g_last_good_pan_index[band] = ps->g_pan_index[band]; - } - } - } -} - -static void drm_calc_sa_side_signal(drm_ps_info *ps, qmf_t X[MAX_NTSRPS][64], uint8_t rateselect) -{ - uint8_t s, b, k; - complex_t qfrac, tmp0, tmp, in, R0; - real_t peakdiff; - real_t nrg; - real_t power; - real_t transratio; - real_t new_delay_slopes[NUM_OF_LINKS]; - uint8_t temp_delay_ser[NUM_OF_LINKS]; - complex_t Phi_Fract; -#ifdef FIXED_POINT - uint32_t in_re, in_im; -#endif - - for (b = 0; b < sa_freq_scale[DRM_NUM_SA_BANDS][rateselect]; b++) - { - /* set delay indices */ - for (k = 0; k < NUM_OF_LINKS; k++) - temp_delay_ser[k] = ps->delay_buf_index_ser[k]; - - RE(Phi_Fract) = RE(Phi_Fract_Qmf[b]); - IM(Phi_Fract) = IM(Phi_Fract_Qmf[b]); - - for (s = 0; s < NUM_OF_SUBSAMPLES; s++) - { - const real_t gamma = REAL_CONST(1.5); - const real_t sigma = REAL_CONST(1.5625); - - RE(in) = QMF_RE(X[s][b]); - IM(in) = QMF_IM(X[s][b]); - -#ifdef FIXED_POINT - /* NOTE: all input is scaled by 2^(-5) because of fixed point QMF - * meaning that P will be scaled by 2^(-10) compared to floating point version - */ - in_re = ((abs(RE(in))+(1<<(REAL_BITS-1)))>>REAL_BITS); - in_im = ((abs(IM(in))+(1<<(REAL_BITS-1)))>>REAL_BITS); - power = in_re*in_re + in_im*in_im; -#else - power = MUL_R(RE(in),RE(in)) + MUL_R(IM(in),IM(in)); -#endif - - ps->peakdecay_fast[b] = MUL_F(ps->peakdecay_fast[b], peak_decay[rateselect]); - if (ps->peakdecay_fast[b] < power) - ps->peakdecay_fast[b] = power; - - peakdiff = ps->prev_peakdiff[b]; - peakdiff += MUL_F((ps->peakdecay_fast[b] - power - ps->prev_peakdiff[b]), smooth_coeff[rateselect]); - ps->prev_peakdiff[b] = peakdiff; - - nrg = ps->prev_nrg[b]; - nrg += MUL_F((power - ps->prev_nrg[b]), smooth_coeff[rateselect]); - ps->prev_nrg[b] = nrg; - - if (MUL_R(peakdiff, gamma) <= nrg) { - transratio = sigma; - } else { - transratio = MUL_R(DIV_R(nrg, MUL_R(peakdiff, gamma)), sigma); - } - - for (k = 0; k < NUM_OF_LINKS; k++) - { - new_delay_slopes[k] = MUL_F(g_decayslope[b], filter_coeff[k]); - } - - RE(tmp0) = RE(ps->d_buff[0][b]); - IM(tmp0) = IM(ps->d_buff[0][b]); - - RE(ps->d_buff[0][b]) = RE(ps->d_buff[1][b]); - IM(ps->d_buff[0][b]) = IM(ps->d_buff[1][b]); - - RE(ps->d_buff[1][b]) = RE(in); - IM(ps->d_buff[1][b]) = IM(in); - - ComplexMult(&RE(tmp), &IM(tmp), RE(tmp0), IM(tmp0), RE(Phi_Fract), IM(Phi_Fract)); - - RE(R0) = RE(tmp); - IM(R0) = IM(tmp); - - for (k = 0; k < NUM_OF_LINKS; k++) - { - RE(qfrac) = RE(Q_Fract_allpass_Qmf[b][k]); - IM(qfrac) = IM(Q_Fract_allpass_Qmf[b][k]); - - RE(tmp0) = RE(ps->d2_buff[k][temp_delay_ser[k]][b]); - IM(tmp0) = IM(ps->d2_buff[k][temp_delay_ser[k]][b]); - - ComplexMult(&RE(tmp), &IM(tmp), RE(tmp0), IM(tmp0), RE(qfrac), IM(qfrac)); - - RE(tmp) += -MUL_F(new_delay_slopes[k], RE(R0)); - IM(tmp) += -MUL_F(new_delay_slopes[k], IM(R0)); - - RE(ps->d2_buff[k][temp_delay_ser[k]][b]) = RE(R0) + MUL_F(new_delay_slopes[k], RE(tmp)); - IM(ps->d2_buff[k][temp_delay_ser[k]][b]) = IM(R0) + MUL_F(new_delay_slopes[k], IM(tmp)); - - RE(R0) = RE(tmp); - IM(R0) = IM(tmp); - } - - QMF_RE(ps->SA[s][b]) = MUL_R(RE(R0), transratio); - QMF_IM(ps->SA[s][b]) = MUL_R(IM(R0), transratio); - - for (k = 0; k < NUM_OF_LINKS; k++) - { - if (++temp_delay_ser[k] >= delay_length[k][rateselect]) - temp_delay_ser[k] = 0; - } - } - } - - for (k = 0; k < NUM_OF_LINKS; k++) - ps->delay_buf_index_ser[k] = temp_delay_ser[k]; -} - -static void drm_add_ambiance(drm_ps_info *ps, uint8_t rateselect, - qmf_t X_left[MAX_NTSRPS][64], - qmf_t X_right[MAX_NTSRPS][64]) -{ - uint8_t s, b, ifreq, qclass; - real_t sa_map[MAX_SA_BAND], sa_dir_map[MAX_SA_BAND], k_sa_map[MAX_SA_BAND], k_sa_dir_map[MAX_SA_BAND]; - real_t new_dir_map, new_sa_map; - - if (ps->bs_enable_sa) - { - /* Instead of dequantization and mapping, we use an inverse mapping - to look up all the values we need */ - for (b = 0; b < sa_freq_scale[DRM_NUM_SA_BANDS][rateselect]; b++) - { - const real_t inv_f_num_of_subsamples = FRAC_CONST(0.03333333333); - - ifreq = sa_inv_freq[b]; - qclass = (b != 0); - - sa_map[b] = sa_quant[ps->g_prev_sa_index[ifreq]][qclass]; - new_sa_map = sa_quant[ps->g_sa_index[ifreq]][qclass]; - - k_sa_map[b] = MUL_F(inv_f_num_of_subsamples, (new_sa_map - sa_map[b])); - - sa_dir_map[b] = sa_sqrt_1_minus[ps->g_prev_sa_index[ifreq]][qclass]; - new_dir_map = sa_sqrt_1_minus[ps->g_sa_index[ifreq]][qclass]; - - k_sa_dir_map[b] = MUL_F(inv_f_num_of_subsamples, (new_dir_map - sa_dir_map[b])); - - } - - for (s = 0; s < NUM_OF_SUBSAMPLES; s++) - { - for (b = 0; b < sa_freq_scale[DRM_NUM_SA_BANDS][rateselect]; b++) - { - QMF_RE(X_right[s][b]) = MUL_F(QMF_RE(X_left[s][b]), sa_dir_map[b]) - MUL_F(QMF_RE(ps->SA[s][b]), sa_map[b]); - QMF_IM(X_right[s][b]) = MUL_F(QMF_IM(X_left[s][b]), sa_dir_map[b]) - MUL_F(QMF_IM(ps->SA[s][b]), sa_map[b]); - QMF_RE(X_left[s][b]) = MUL_F(QMF_RE(X_left[s][b]), sa_dir_map[b]) + MUL_F(QMF_RE(ps->SA[s][b]), sa_map[b]); - QMF_IM(X_left[s][b]) = MUL_F(QMF_IM(X_left[s][b]), sa_dir_map[b]) + MUL_F(QMF_IM(ps->SA[s][b]), sa_map[b]); - - sa_map[b] += k_sa_map[b]; - sa_dir_map[b] += k_sa_dir_map[b]; - } - for (b = sa_freq_scale[DRM_NUM_SA_BANDS][rateselect]; b < NUM_OF_QMF_CHANNELS; b++) - { - QMF_RE(X_right[s][b]) = QMF_RE(X_left[s][b]); - QMF_IM(X_right[s][b]) = QMF_IM(X_left[s][b]); - } - } - } - else { - for (s = 0; s < NUM_OF_SUBSAMPLES; s++) - { - for (b = 0; b < NUM_OF_QMF_CHANNELS; b++) - { - QMF_RE(X_right[s][b]) = QMF_RE(X_left[s][b]); - QMF_IM(X_right[s][b]) = QMF_IM(X_left[s][b]); - } - } - } -} - -static void drm_add_pan(drm_ps_info *ps, uint8_t rateselect, - qmf_t X_left[MAX_NTSRPS][64], - qmf_t X_right[MAX_NTSRPS][64]) -{ - uint8_t s, b, qclass, ifreq; - real_t tmp, coeff1, coeff2; - real_t pan_base[MAX_PAN_BAND]; - real_t pan_delta[MAX_PAN_BAND]; - qmf_t temp_l, temp_r; - - if (ps->bs_enable_pan) - { - for (b = 0; b < NUM_OF_QMF_CHANNELS; b++) - { - /* Instead of dequantization, 20->64 mapping and 2^G(x,y) we do an - inverse mapping 64->20 and look up the 2^G(x,y) values directly */ - ifreq = pan_inv_freq[b]; - qclass = pan_quant_class[ifreq]; - - if (ps->g_prev_pan_index[ifreq] >= 0) - { - pan_base[b] = pan_pow_2_pos[ps->g_prev_pan_index[ifreq]][qclass]; - } else { - pan_base[b] = pan_pow_2_neg[-ps->g_prev_pan_index[ifreq]][qclass]; - } - - /* 2^((a-b)/30) = 2^(a/30) * 1/(2^(b/30)) */ - /* a en b can be negative so we may need to inverse parts */ - if (ps->g_pan_index[ifreq] >= 0) - { - if (ps->g_prev_pan_index[ifreq] >= 0) - { - pan_delta[b] = MUL_C(pan_pow_2_30_pos[ps->g_pan_index[ifreq]][qclass], - pan_pow_2_30_neg[ps->g_prev_pan_index[ifreq]][qclass]); - } else { - pan_delta[b] = MUL_C(pan_pow_2_30_pos[ps->g_pan_index[ifreq]][qclass], - pan_pow_2_30_pos[-ps->g_prev_pan_index[ifreq]][qclass]); - } - } else { - if (ps->g_prev_pan_index[ifreq] >= 0) - { - pan_delta[b] = MUL_C(pan_pow_2_30_neg[-ps->g_pan_index[ifreq]][qclass], - pan_pow_2_30_neg[ps->g_prev_pan_index[ifreq]][qclass]); - } else { - pan_delta[b] = MUL_C(pan_pow_2_30_neg[-ps->g_pan_index[ifreq]][qclass], - pan_pow_2_30_pos[-ps->g_prev_pan_index[ifreq]][qclass]); - } - } - } - - for (s = 0; s < NUM_OF_SUBSAMPLES; s++) - { - /* PAN always uses all 64 channels */ - for (b = 0; b < NUM_OF_QMF_CHANNELS; b++) - { - tmp = pan_base[b]; - - coeff2 = DIV_R(REAL_CONST(2.0), (REAL_CONST(1.0) + tmp)); - coeff1 = MUL_R(coeff2, tmp); - - QMF_RE(temp_l) = QMF_RE(X_left[s][b]); - QMF_IM(temp_l) = QMF_IM(X_left[s][b]); - QMF_RE(temp_r) = QMF_RE(X_right[s][b]); - QMF_IM(temp_r) = QMF_IM(X_right[s][b]); - - QMF_RE(X_left[s][b]) = MUL_R(QMF_RE(temp_l), coeff1); - QMF_IM(X_left[s][b]) = MUL_R(QMF_IM(temp_l), coeff1); - QMF_RE(X_right[s][b]) = MUL_R(QMF_RE(temp_r), coeff2); - QMF_IM(X_right[s][b]) = MUL_R(QMF_IM(temp_r), coeff2); - - /* 2^(a+k*b) = 2^a * 2^b * ... * 2^b */ - /* ^^^^^^^^^^^^^^^ k times */ - pan_base[b] = MUL_C(pan_base[b], pan_delta[b]); - } - } - } -} - -drm_ps_info *drm_ps_init(void) -{ - drm_ps_info *ps = &s_drm_ps_info; - memset(ps, 0, sizeof(drm_ps_info)); - - return ps; -} - -/* main DRM PS decoding function */ -uint8_t drm_ps_decode(drm_ps_info *ps, uint8_t guess, uint32_t samplerate, - qmf_t X_left[MAX_NTSRPS][64], - qmf_t X_right[MAX_NTSRPS][64]) -{ - uint8_t rateselect = (samplerate >= 24000); - - if (ps == NULL) - { - memcpy(X_right, X_left, sizeof(qmf_t)*30*64); - return 0; - } - - if (!ps->drm_ps_data_available && !guess) - { - memcpy(X_right, X_left, sizeof(qmf_t)*30*64); - memset(ps->g_prev_sa_index, 0, sizeof(ps->g_prev_sa_index)); - memset(ps->g_prev_pan_index, 0, sizeof(ps->g_prev_pan_index)); - return 0; - } - - /* if SBR CRC doesn't match out, we can assume decode errors to start with, - and we'll guess what the parameters should be */ - if (!guess) - { - ps->sa_decode_error = 0; - ps->pan_decode_error = 0; - drm_ps_delta_decode(ps); - } else - { - ps->sa_decode_error = 1; - ps->pan_decode_error = 1; - /* don't even bother decoding */ - } - - ps->drm_ps_data_available = 0; - - drm_calc_sa_side_signal(ps, X_left, rateselect); - drm_add_ambiance(ps, rateselect, X_left, X_right); - - if (ps->bs_enable_sa) - { - ps->g_last_had_sa = 1; - - memcpy(ps->g_prev_sa_index, ps->g_sa_index, sizeof(int8_t) * DRM_NUM_SA_BANDS); - - } else { - ps->g_last_had_sa = 0; - } - - if (ps->bs_enable_pan) - { - drm_add_pan(ps, rateselect, X_left, X_right); - - ps->g_last_had_pan = 1; - - memcpy(ps->g_prev_pan_index, ps->g_pan_index, sizeof(int8_t) * DRM_NUM_PAN_BANDS); - - } else { - ps->g_last_had_pan = 0; - } - - - return 0; -} - -#endif diff --git a/apps/codecs/libfaad/drm_dec.h b/apps/codecs/libfaad/drm_dec.h deleted file mode 100644 index d7ae9d0166..0000000000 --- a/apps/codecs/libfaad/drm_dec.h +++ /dev/null @@ -1,98 +0,0 @@ -/* -** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -** -** Any non-GPL usage of this software or parts of this software is strictly -** forbidden. -** -** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. -** -** $Id$ -**/ - -#ifndef __DRM_DEC_H__ -#define __DRM_DEC_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -#include "bits.h" - -#define DRM_PARAMETRIC_STEREO 0 -#define DRM_NUM_SA_BANDS 8 -#define DRM_NUM_PAN_BANDS 20 -#define NUM_OF_LINKS 3 -#define NUM_OF_QMF_CHANNELS 64 -#define NUM_OF_SUBSAMPLES 30 -#define MAX_SA_BAND 46 -#define MAX_PAN_BAND 64 -#define MAX_DELAY 5 - -typedef struct -{ - uint8_t drm_ps_data_available; - uint8_t bs_enable_sa; - uint8_t bs_enable_pan; - - uint8_t bs_sa_dt_flag; - uint8_t bs_pan_dt_flag; - - uint8_t g_last_had_sa; - uint8_t g_last_had_pan; - - int8_t bs_sa_data[DRM_NUM_SA_BANDS]; - int8_t bs_pan_data[DRM_NUM_PAN_BANDS]; - - int8_t g_sa_index[DRM_NUM_SA_BANDS]; - int8_t g_pan_index[DRM_NUM_PAN_BANDS]; - int8_t g_prev_sa_index[DRM_NUM_SA_BANDS]; - int8_t g_prev_pan_index[DRM_NUM_PAN_BANDS]; - - int8_t sa_decode_error; - int8_t pan_decode_error; - - int8_t g_last_good_sa_index[DRM_NUM_SA_BANDS]; - int8_t g_last_good_pan_index[DRM_NUM_PAN_BANDS]; - - qmf_t SA[NUM_OF_SUBSAMPLES][MAX_SA_BAND]; - - complex_t d_buff[2][MAX_SA_BAND]; - complex_t d2_buff[NUM_OF_LINKS][MAX_DELAY][MAX_SA_BAND]; - - uint8_t delay_buf_index_ser[NUM_OF_LINKS]; - - real_t prev_nrg[MAX_SA_BAND]; - real_t prev_peakdiff[MAX_SA_BAND]; - real_t peakdecay_fast[MAX_SA_BAND]; -} drm_ps_info; - - -uint16_t drm_ps_data(drm_ps_info *ps, bitfile *ld); - -drm_ps_info *drm_ps_init(void); - -uint8_t drm_ps_decode(drm_ps_info *ps, uint8_t guess, uint32_t samplerate, - qmf_t X_left[MAX_NTSRPS][64], - qmf_t X_right[MAX_NTSRPS][64]); - -#ifdef __cplusplus -} -#endif -#endif - diff --git a/apps/codecs/libfaad/error.c b/apps/codecs/libfaad/error.c deleted file mode 100644 index ff2f9c3d13..0000000000 --- a/apps/codecs/libfaad/error.c +++ /dev/null @@ -1,62 +0,0 @@ -/* -** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -** -** Any non-GPL usage of this software or parts of this software is strictly -** forbidden. -** -** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. -** -** $Id$ -**/ - -#include "common.h" -#include "error.h" - -char *err_msg[] = { - "No error", - "Gain control not yet implemented", - "Pulse coding not allowed in short blocks", - "Invalid huffman codebook", - "Scalefactor out of range", - "Unable to find ADTS syncword", - "Channel coupling not yet implemented", - "Channel configuration not allowed in error resilient frame", - "Bit error in error resilient scalefactor decoding", - "Error decoding huffman scalefactor (bitstream error)", - "Error decoding huffman codeword (bitstream error)", - "Non existent huffman codebook number found", - "Invalid number of channels", - "Maximum number of bitstream elements exceeded", - "Input data buffer too small", - "Array index out of range", - "Maximum number of scalefactor bands exceeded", - "Quantised value out of range", - "LTP lag out of range", - "Invalid SBR parameter decoded", - "SBR called without being initialised", - "Unexpected channel configuration change", - "Error in program_config_element", - "First SBR frame is not the same as first AAC frame", - "Unexpected fill element with SBR data", - "Not all elements were provided with SBR data", - "LTP decoding not available", - "Output data buffer too small", - "Could not allocate enough memory" -}; - diff --git a/apps/codecs/libfaad/error.h b/apps/codecs/libfaad/error.h deleted file mode 100644 index 94ca7bba75..0000000000 --- a/apps/codecs/libfaad/error.h +++ /dev/null @@ -1,41 +0,0 @@ -/* -** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -** -** Any non-GPL usage of this software or parts of this software is strictly -** forbidden. -** -** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. -** -** $Id$ -**/ - -#ifndef __ERROR_H__ -#define __ERROR_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -#define NUM_ERROR_MESSAGES 28 -extern char *err_msg[]; - -#ifdef __cplusplus -} -#endif -#endif diff --git a/apps/codecs/libfaad/faad_config.h b/apps/codecs/libfaad/faad_config.h deleted file mode 100644 index 163b55669e..0000000000 --- a/apps/codecs/libfaad/faad_config.h +++ /dev/null @@ -1,120 +0,0 @@ -/* config.h. Generated by configure. */ -/* config.h.in. Generated from configure.in by autoheader. */ - -#include - -/* Define if you want to use libfaad together with Digital Radio Mondiale - (DRM) */ -/* #undef DRM */ - -/* Define if you want support for Digital Radio Mondiale (DRM) parametric - stereo */ -/* #undef DRM_PS */ - -/* Define to 1 if you have the header file. */ -//#define HAVE_DLFCN_H 1 - -/* Define to 1 if you have the header file. */ -//#define HAVE_ERRNO_H 1 - -/* Define if needed */ -/* #undef HAVE_FLOAT32_T */ - -/* Define to 1 if you have the header file. */ -//#define HAVE_FLOAT_H 1 - -/* Define to 1 if you have the `getpwuid' function. */ -#define HAVE_GETPWUID 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_INTTYPES_H 1 - -/* Define if you have the IOKit API */ -/* #undef HAVE_IOKIT_IOKITLIB_H */ - -/* Define to 1 if you have the header file. */ -//#define HAVE_LIMITS_H 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_MATHF_H */ - -/* Define to 1 if you have the `memcpy' function. */ -#define HAVE_MEMCPY 1 - -/* Define to 1 if you have the header file. */ -//#define HAVE_MEMORY_H 1 - -/* Define to 1 if you have the header file. */ -//#define HAVE_STDINT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STDLIB_H 1 - -/* Define to 1 if you have the `strchr' function. */ -#define HAVE_STRCHR 1 - -/* Define to 1 if you have the header file. */ -//#define HAVE_STRINGS_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STRING_H 1 - -/* Define to 1 if you have the `strsep' function. */ -//#define HAVE_STRSEP 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_SYSFS_LIBSYSFS_H */ - -/* Define to 1 if you have the header file. */ -//#define HAVE_SYS_STAT_H 1 - -/* Define to 1 if you have the header file. */ -//#define HAVE_SYS_TIME_H 1 - -/* Define to 1 if you have the header file. */ -//#define HAVE_SYS_TYPES_H 1 - -/* Define to 1 if you have the header file. */ -//#define HAVE_UNISTD_H 1 - -/* Name of package */ -#define PACKAGE "faad2" - -/* Define to the address where bug reports for this package should be sent. */ -#define PACKAGE_BUGREPORT "" - -/* Define to the full name of this package. */ -#define PACKAGE_NAME "" - -/* Define to the full name and version of this package. */ -#define PACKAGE_STRING "" - -/* Define to the one symbol short name of this package. */ -#define PACKAGE_TARNAME "" - -/* Define to the version of this package. */ -#define PACKAGE_VERSION "" - -/* Define to 1 if you have the ANSI C header files. */ -#define STDC_HEADERS 1 - -/* Define to 1 if you can safely include both and . */ -//#define TIME_WITH_SYS_TIME 1 - -/* Version number of package */ -#define LIBFAAD_VERSION "2.0" - -/* Define to 1 if your processor stores words with the most significant byte - first (like Motorola and SPARC, unlike Intel and VAX). */ -#ifdef ROCKBOX_BIG_ENDIAN -#define WORDS_BIGENDIAN 1 -#endif - -/* Define to `__inline__' or `__inline' if that's what the C compiler - calls it, or to nothing if 'inline' is not supported under any name. */ -#ifndef __cplusplus -/* #undef inline */ -#endif - -/* Define to `long' if does not define. */ -/* #undef off_t */ diff --git a/apps/codecs/libfaad/filtbank.c b/apps/codecs/libfaad/filtbank.c deleted file mode 100644 index fd7a4dc91f..0000000000 --- a/apps/codecs/libfaad/filtbank.c +++ /dev/null @@ -1,482 +0,0 @@ -/* -** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -** -** Any non-GPL usage of this software or parts of this software is strictly -** forbidden. -** -** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. -** -** $Id$ -**/ - -#include "common.h" -#include "structs.h" - -#include -#include -#ifdef _WIN32_WCE -#define assert(x) -#else -#include -#endif - -#include "filtbank.h" -#include "decoder.h" -#include "syntax.h" -#include "kbd_win.h" -#include "sine_win.h" - - -/* static variables */ -static real_t transf_buf[2*FRAME_LEN] IBSS_ATTR MEM_ALIGN_ATTR; -#ifdef LTP_DEC -static real_t windowed_buf[2*FRAME_LEN] MEM_ALIGN_ATTR = {0}; -#endif - - -/*Windowing functions borrowed from libwmai*/ -#ifdef CPU_ARM -static inline -void vector_fmul_add_add(real_t *dst, const real_t *src0, const real_t *src1, const real_t *src2, int len) -{ - /* Block sizes are always power of two */ - asm volatile ( - "0:" - "ldmia %[d]!, {r0, r1};" - "ldmia %[w]!, {r4, r5};" - /* consume the first data and window value so we can use those - * registers again */ - "smull r8, r9, r0, r4;" - "ldmia %[src2]!, {r0, r4};" - "add r0, r0, r9, lsl #1;" /* *dst=*dst+(r9<<1)*/ - "smull r8, r9, r1, r5;" - "add r1, r4, r9, lsl #1;" - "stmia %[dst]!, {r0, r1};" - "subs %[n], %[n], #2;" - "bne 0b;" - : [d] "+r" (src0), [w] "+r" (src1), [src2] "+r" (src2), [dst] "+r" (dst), [n] "+r" (len) - : - : "r0", "r1", "r4", "r5", "r8", "r9", "memory", "cc"); -} -static inline -void vector_fmul_reverse(real_t *dst, const real_t *src0, const real_t *src1, - int len) -{ - /* Block sizes are always power of two */ - asm volatile ( - "add %[s1], %[s1], %[n], lsl #2;" - "0:" - "ldmia %[s0]!, {r0, r1};" - "ldmdb %[s1]!, {r4, r5};" - "smull r8, r9, r0, r5;" - "mov r0, r9, lsl #1;" - "smull r8, r9, r1, r4;" - "mov r1, r9, lsl #1;" - "stmia %[dst]!, {r0, r1};" - "subs %[n], %[n], #2;" - "bne 0b;" - : [s0] "+r" (src0), [s1] "+r" (src1), [dst] "+r" (dst), [n] "+r" (len) - : - : "r0", "r1", "r4", "r5", "r8", "r9", "memory", "cc"); -} - -#elif defined(CPU_COLDFIRE) -static inline -void vector_fmul_add_add(real_t *dst, const real_t *src0, const real_t *src1, const real_t *src2, int len) -{ - /* Block sizes are always power of two. Smallest block is always way bigger - * than four too.*/ - asm volatile ( - "0:" - "movem.l (%[src0]), %%d0-%%d3;" - "movem.l (%[src1]), %%d4-%%d5/%%a0-%%a1;" - "mac.l %%d0, %%d4, %%acc0;" - "mac.l %%d1, %%d5, %%acc1;" - "mac.l %%d2, %%a0, %%acc2;" - "mac.l %%d3, %%a1, %%acc3;" - "lea.l (16, %[src0]), %[src0];" - "lea.l (16, %[src1]), %[src1];" - "movclr.l %%acc0, %%d0;" - "movclr.l %%acc1, %%d1;" - "movclr.l %%acc2, %%d2;" - "movclr.l %%acc3, %%d3;" - "movem.l (%[src2]), %%d4-%%d5/%%a0-%%a1;" - "lea.l (16, %[src2]), %[src2];" - "add.l %%d4, %%d0;" - "add.l %%d5, %%d1;" - "add.l %%a0, %%d2;" - "add.l %%a1, %%d3;" - "movem.l %%d0-%%d3, (%[dst]);" - "lea.l (16, %[dst]), %[dst];" - "subq.l #4, %[n];" - "jne 0b;" - : [src0] "+a" (src0), [src1] "+a" (src1), [src2] "+a" (src2), [dst] "+a" (dst), [n] "+d" (len) - : - : "d0", "d1", "d2", "d3", "d4", "d5", "a0", "a1", "memory", "cc"); -} - -static inline -void vector_fmul_reverse(real_t *dst, const real_t *src0, const real_t *src1, - int len) -{ - /* Block sizes are always power of two. Smallest block is always way bigger - * than four too.*/ - asm volatile ( - "lea.l (-16, %[s1], %[n]*4), %[s1];" - "0:" - "movem.l (%[s0]), %%d0-%%d3;" - "movem.l (%[s1]), %%d4-%%d5/%%a0-%%a1;" - "mac.l %%d0, %%a1, %%acc0;" - "mac.l %%d1, %%a0, %%acc1;" - "mac.l %%d2, %%d5, %%acc2;" - "mac.l %%d3, %%d4, %%acc3;" - "lea.l (16, %[s0]), %[s0];" - "lea.l (-16, %[s1]), %[s1];" - "movclr.l %%acc0, %%d0;" - "movclr.l %%acc1, %%d1;" - "movclr.l %%acc2, %%d2;" - "movclr.l %%acc3, %%d3;" - "movem.l %%d0-%%d3, (%[dst]);" - "lea.l (16, %[dst]), %[dst];" - "subq.l #4, %[n];" - "jne 0b;" - : [s0] "+a" (src0), [s1] "+a" (src1), [dst] "+a" (dst), [n] "+d" (len) - : : "d0", "d1", "d2", "d3", "d4", "d5", "a0", "a1", "memory", "cc"); -} - -#else -static inline void vector_fmul_add_add(real_t *dst, const real_t *src0, const real_t *src1, const real_t *src2, int len){ - int i; - for(i=0; imdct2048; - break; - case 256: - case 240: - mdct = fb->mdct256; - break; -#ifdef LD_DEC - case 1024: - case 960: - mdct = fb->mdct1024; - break; -#endif - } - - faad_mdct(mdct, in_data, out_data); -} -#endif - -void ifilter_bank(uint8_t window_sequence, uint8_t window_shape, - uint8_t window_shape_prev, real_t *freq_in, - real_t *time_out, real_t *overlap, - uint8_t object_type, uint16_t frame_len) -{ - int32_t i, idx0, idx1; - real_t win0, win1, win2; - - const real_t *window_long = NULL; - const real_t *window_long_prev = NULL; - const real_t *window_short = NULL; - const real_t *window_short_prev = NULL; - - int32_t nlong = frame_len; - int32_t nshort = frame_len/8; - int32_t nflat_ls = (nlong-nshort)/2; - -#ifdef PROFILE - int64_t count = faad_get_ts(); -#endif - - memset(transf_buf,0,sizeof(transf_buf)); - /* select windows of current frame and previous frame (Sine or KBD) */ -#ifdef LD_DEC - if (object_type == LD) - { - window_long = fb->ld_window[window_shape]; - window_long_prev = fb->ld_window[window_shape_prev]; - } else { -#else - (void) object_type; -#endif - - /* AAC uses two different window shapes depending on spectal features */ - if (window_shape == 0) { - window_long = sine_long_1024; - window_short = sine_short_128; - } else { - window_long = kbd_long_1024; - window_short = kbd_short_128; - } - - if (window_shape_prev == 0) { - window_long_prev = sine_long_1024; - window_short_prev = sine_short_128; - } else { - window_long_prev = kbd_long_1024; - window_short_prev = kbd_short_128; - } - -#ifdef LD_DEC - } -#endif - -#if 0 - for (i = 0; i < 1024; i++) - { - printf("%d\n", freq_in[i]); - } -#endif - -#if 0 - printf("%d %d\n", window_sequence, window_shape); -#endif - switch (window_sequence) - { - case ONLY_LONG_SEQUENCE: - /* perform iMDCT */ - ff_imdct_calc(11, transf_buf, freq_in); - - /* add second half output of previous frame to windowed output of current frame */ - vector_fmul_add_add(time_out, transf_buf, window_long_prev, overlap, nlong); - - /* window the second half and save as overlap for next frame */ - vector_fmul_reverse(overlap, transf_buf+nlong, window_long, nlong); - - break; - - case LONG_START_SEQUENCE: - /* perform iMDCT */ - ff_imdct_calc(11, transf_buf, freq_in); - - /* add second half output of previous frame to windowed output of current frame */ - vector_fmul_add_add(time_out, transf_buf, window_long_prev, overlap, nlong); - - /* window the second half and save as overlap for next frame */ - /* construct second half window using padding with 1's and 0's */ - - memcpy(overlap, transf_buf+nlong, nflat_ls*sizeof(real_t)); - - vector_fmul_reverse(overlap+nflat_ls, transf_buf+nlong+nflat_ls, window_short, nshort); - - memset(overlap+nflat_ls+nshort, 0, nflat_ls*sizeof(real_t)); - break; - - case EIGHT_SHORT_SEQUENCE: - /* this could be assemblerized too, but this case is extremely uncommon */ - - /* perform iMDCT for each short block */ - idx0 = 0; ff_imdct_calc(8, transf_buf , freq_in ); - idx0 += nshort; ff_imdct_calc(8, transf_buf + (idx0<<1), freq_in + idx0); - idx0 += nshort; ff_imdct_calc(8, transf_buf + (idx0<<1), freq_in + idx0); - idx0 += nshort; ff_imdct_calc(8, transf_buf + (idx0<<1), freq_in + idx0); - idx0 += nshort; ff_imdct_calc(8, transf_buf + (idx0<<1), freq_in + idx0); - idx0 += nshort; ff_imdct_calc(8, transf_buf + (idx0<<1), freq_in + idx0); - idx0 += nshort; ff_imdct_calc(8, transf_buf + (idx0<<1), freq_in + idx0); - idx0 += nshort; ff_imdct_calc(8, transf_buf + (idx0<<1), freq_in + idx0); - - /* Add second half output of previous frame to windowed output of current - * frame */ - /* Step 1: copy */ - memcpy(time_out, overlap, nflat_ls*sizeof(real_t)); - /* Step 2: First window half, first half of nshort */ - for (i = 0; i < nshort/2; i++) { - win0 = window_short[nshort-1-i]; - win1 = window_short[i]; - win2 = window_short_prev[i]; - idx0 = nflat_ls + i; - idx1 = i; - time_out[idx0] = overlap[idx0] + MUL_F(transf_buf[idx1], win2); idx0 += nshort; idx1 += (nshort<<1); - time_out[idx0] = overlap[idx0] + MUL_F(transf_buf[idx1-nshort], win0) + MUL_F(transf_buf[idx1], win1); idx0 += nshort; idx1 += (nshort<<1); - time_out[idx0] = overlap[idx0] + MUL_F(transf_buf[idx1-nshort], win0) + MUL_F(transf_buf[idx1], win1); idx0 += nshort; idx1 += (nshort<<1); - time_out[idx0] = overlap[idx0] + MUL_F(transf_buf[idx1-nshort], win0) + MUL_F(transf_buf[idx1], win1); idx0 += nshort; idx1 += (nshort<<1); - time_out[idx0] = overlap[idx0] + MUL_F(transf_buf[idx1-nshort], win0) + MUL_F(transf_buf[idx1], win1); - } - /* Step 3: First window half, second half of nshort */ - for (; i < nshort; i++) { - win0 = window_short[nshort-1-i]; - win1 = window_short[i]; - idx0 = nflat_ls + i; - idx1 = i; - time_out[idx0] = overlap[idx0] + MUL_F(transf_buf[idx1], win1); idx0 += nshort; idx1 += (nshort<<1); - time_out[idx0] = overlap[idx0] + MUL_F(transf_buf[idx1-nshort], win0) + MUL_F(transf_buf[idx1], win1); idx0 += nshort; idx1 += (nshort<<1); - time_out[idx0] = overlap[idx0] + MUL_F(transf_buf[idx1-nshort], win0) + MUL_F(transf_buf[idx1], win1); idx0 += nshort; idx1 += (nshort<<1); - time_out[idx0] = overlap[idx0] + MUL_F(transf_buf[idx1-nshort], win0) + MUL_F(transf_buf[idx1], win1); - } - - /* Window the second half and save as overlap for next frame */ - /* Step 1: Second window half, first half of nshort */ - for (i = 0; i < nshort/2; i++) { - win0 = window_short[nshort-1-i]; - win1 = window_short[i]; - idx0 = nflat_ls + 5*nshort + i - nlong; - idx1 = nshort*10 + i; - overlap[idx0] = MUL_F(transf_buf[idx1-nshort], win0) + MUL_F(transf_buf[idx1], win1); idx0 += nshort; idx1 += (nshort<<1); - overlap[idx0] = MUL_F(transf_buf[idx1-nshort], win0) + MUL_F(transf_buf[idx1], win1); idx0 += nshort; idx1 += (nshort<<1); - overlap[idx0] = MUL_F(transf_buf[idx1-nshort], win0) + MUL_F(transf_buf[idx1], win1); idx0 += nshort; idx1 += (nshort<<1); - overlap[idx0] = MUL_F(transf_buf[idx1-nshort], win0); - } - /* Step 2: Second window half, second half of nshort */ - for (; i < nshort; i++) { - win0 = window_short[nshort-1-i]; - win1 = window_short[i]; - idx0 = nflat_ls + 4*nshort + i - nlong; - idx1 = nshort*8 + i; - overlap[idx0] = MUL_F(transf_buf[idx1-nshort], win0) + MUL_F(transf_buf[idx1], win1); idx0 += nshort; idx1 += (nshort<<1); - overlap[idx0] = MUL_F(transf_buf[idx1-nshort], win0) + MUL_F(transf_buf[idx1], win1); idx0 += nshort; idx1 += (nshort<<1); - overlap[idx0] = MUL_F(transf_buf[idx1-nshort], win0) + MUL_F(transf_buf[idx1], win1); idx0 += nshort; idx1 += (nshort<<1); - overlap[idx0] = MUL_F(transf_buf[idx1-nshort], win0) + MUL_F(transf_buf[idx1], win1); idx0 += nshort; idx1 += (nshort<<1); - overlap[idx0] = MUL_F(transf_buf[idx1-nshort], win0); - } - /* Step 3: Set to zero */ - memset(overlap+nflat_ls+nshort, 0, nflat_ls*sizeof(real_t)); - - break; - - case LONG_STOP_SEQUENCE: - /* perform iMDCT */ - ff_imdct_calc(11, transf_buf, freq_in); - - /* add second half output of previous frame to windowed output of current frame */ - /* construct first half window using padding with 1's and 0's */ - memcpy(time_out, overlap, nflat_ls*sizeof(real_t)); - - vector_fmul_add_add(time_out+nflat_ls, transf_buf+nflat_ls, window_short_prev, overlap+nflat_ls, nshort); - - /* nflat_ls can be divided by 2. */ - idx0 = nflat_ls + nshort; - for (i = 0; i < nflat_ls; i+=2) { - time_out[idx0] = overlap[idx0] + transf_buf[idx0]; idx0++; - time_out[idx0] = overlap[idx0] + transf_buf[idx0]; idx0++; - } - - /* window the second half and save as overlap for next frame */ - vector_fmul_reverse(overlap, transf_buf+nlong, window_long, nlong); - break; - } - -#if 0 - for (i = 0; i < 1024; i++) - { - printf("%d\n", time_out[i]); - //printf("0x%.8X\n", time_out[i]); - } -#endif - - -#ifdef PROFILE - count = faad_get_ts() - count; - fb->cycles += count; -#endif -} - - -#ifdef LTP_DEC -/* only works for LTP -> no overlapping, no short blocks */ -void filter_bank_ltp(fb_info *fb, uint8_t window_sequence, uint8_t window_shape, - uint8_t window_shape_prev, real_t *in_data, real_t *out_mdct, - uint8_t object_type, uint16_t frame_len) -{ - int16_t i; - - const real_t *window_long = NULL; - const real_t *window_long_prev = NULL; - const real_t *window_short = NULL; - const real_t *window_short_prev = NULL; - - uint16_t nlong = frame_len; - uint16_t nshort = frame_len/8; - uint16_t nflat_ls = (nlong-nshort)/2; - - //assert(window_sequence != EIGHT_SHORT_SEQUENCE); - - memset(windowed_buf,0,sizeof(windowed_buf)); -#ifdef LD_DEC - if (object_type == LD) - { - window_long = fb->ld_window[window_shape]; - window_long_prev = fb->ld_window[window_shape_prev]; - } else { -#else - (void) object_type; -#endif - window_long = fb->long_window[window_shape]; - window_long_prev = fb->long_window[window_shape_prev]; - window_short = fb->short_window[window_shape]; - window_short_prev = fb->short_window[window_shape_prev]; -#ifdef LD_DEC - } -#endif - - switch(window_sequence) - { - case ONLY_LONG_SEQUENCE: - for (i = nlong-1; i >= 0; i--) - { - windowed_buf[i] = MUL_F(in_data[i], window_long_prev[i]); - windowed_buf[i+nlong] = MUL_F(in_data[i+nlong], window_long[nlong-1-i]); - } - mdct(fb, windowed_buf, out_mdct, 2*nlong); - break; - - case LONG_START_SEQUENCE: - for (i = 0; i < nlong; i++) - windowed_buf[i] = MUL_F(in_data[i], window_long_prev[i]); - for (i = 0; i < nflat_ls; i++) - windowed_buf[i+nlong] = in_data[i+nlong]; - for (i = 0; i < nshort; i++) - windowed_buf[i+nlong+nflat_ls] = MUL_F(in_data[i+nlong+nflat_ls], window_short[nshort-1-i]); - for (i = 0; i < nflat_ls; i++) - windowed_buf[i+nlong+nflat_ls+nshort] = 0; - mdct(fb, windowed_buf, out_mdct, 2*nlong); - break; - - case LONG_STOP_SEQUENCE: - for (i = 0; i < nflat_ls; i++) - windowed_buf[i] = 0; - for (i = 0; i < nshort; i++) - windowed_buf[i+nflat_ls] = MUL_F(in_data[i+nflat_ls], window_short_prev[i]); - for (i = 0; i < nflat_ls; i++) - windowed_buf[i+nflat_ls+nshort] = in_data[i+nflat_ls+nshort]; - for (i = 0; i < nlong; i++) - windowed_buf[i+nlong] = MUL_F(in_data[i+nlong], window_long[nlong-1-i]); - mdct(fb, windowed_buf, out_mdct, 2*nlong); - break; - } -} -#endif diff --git a/apps/codecs/libfaad/filtbank.h b/apps/codecs/libfaad/filtbank.h deleted file mode 100644 index 8c9f1e3490..0000000000 --- a/apps/codecs/libfaad/filtbank.h +++ /dev/null @@ -1,54 +0,0 @@ -/* -** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -** -** Any non-GPL usage of this software or parts of this software is strictly -** forbidden. -** -** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. -** -** $Id$ -**/ - -#ifndef __FILTBANK_H__ -#define __FILTBANK_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef LTP_DEC -void filter_bank_ltp(fb_info *fb, - uint8_t window_sequence, - uint8_t window_shape, - uint8_t window_shape_prev, - real_t *in_data, - real_t *out_mdct, - uint8_t object_type, - uint16_t frame_len); -#endif - -void ifilter_bank(uint8_t window_sequence, uint8_t window_shape, - uint8_t window_shape_prev, real_t *freq_in, - real_t *time_out, real_t *overlap, - uint8_t object_type, uint16_t frame_len); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/apps/codecs/libfaad/fixed.h b/apps/codecs/libfaad/fixed.h deleted file mode 100644 index ca0402e4d3..0000000000 --- a/apps/codecs/libfaad/fixed.h +++ /dev/null @@ -1,230 +0,0 @@ -/* -** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -** -** Any non-GPL usage of this software or parts of this software is strictly -** forbidden. -** -** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. -** -** $Id$ -**/ - -#ifndef __FIXED_H__ -#define __FIXED_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -#if defined(_WIN32_WCE) && defined(_ARM_) -#include -#endif - -#define COEF_BITS 28 -#define COEF_PRECISION (1 << COEF_BITS) -#define REAL_BITS 14 // MAXIMUM OF 14 FOR FIXED POINT SBR -#define REAL_PRECISION (1 << REAL_BITS) - -/* FRAC is the fractional only part of the fixed point number [0.0..1.0) */ -#define FRAC_SIZE 32 /* frac is a 32 bit integer */ -#define FRAC_BITS 31 -#define FRAC_PRECISION ((uint32_t)(1 << FRAC_BITS)) -#define FRAC_MAX 0x7FFFFFFF - -typedef int32_t real_t; - -#define FIX_CONST(A,PRECISION) (((A) >= 0) ? ((real_t)((A)*(PRECISION)+0.5)) : ((real_t)((A)*(PRECISION)-0.5))) -#define REAL_CONST(A) FIX_CONST((A),(REAL_PRECISION)) -#define COEF_CONST(A) FIX_CONST((A),(COEF_PRECISION)) -#define FRAC_CONST(A) (((A) == 1.00) ? ((real_t)FRAC_MAX) : FIX_CONST((A),(FRAC_PRECISION))) -//#define FRAC_CONST(A) (((A) >= 0) ? ((real_t)((A)*(FRAC_PRECISION)+0.5)) : ((real_t)((A)*(FRAC_PRECISION)-0.5))) - -#define Q2_BITS 22 -#define Q2_PRECISION (1 << Q2_BITS) -#define Q2_CONST(A) FIX_CONST((A),(Q2_PRECISION)) - -#if defined(CPU_COLDFIRE) - -static INLINE real_t MUL_F(real_t A, real_t B) -{ - asm volatile ( - "mac.l %[A], %[B], %%acc0\n\t" - "movclr.l %%acc0, %[A]" - : [A] "+&r" (A) : [B] "r" (B) - ); - return A; -} - -static INLINE real_t MUL_C(real_t A, real_t B) -{ - asm volatile ( - "mac.l %[A], %[B], %%acc0\n\t" - "movclr.l %%acc0, %[A]\n\t" - : [A] "+&d" (A) : [B] "r" (B) - ); - return A << 3; -} - -/* MUL_R needs too many shifts for us to just operate on the top 32 bits the - emac unit gives as usual, so we do a full 64 bit mul here. */ -static INLINE real_t MUL_R(real_t x, real_t y) -{ - real_t t1, t2; - asm volatile ( - "mac.l %[x],%[y],%%acc0\n" /* multiply */ - "mulu.l %[y],%[x] \n" /* get lower half, avoid emac stall */ - "movclr.l %%acc0,%[t1] \n" /* get higher half */ - "moveq.l #17,%[t2] \n" - "asl.l %[t2],%[t1] \n" /* hi <<= 17, plus one free */ - "moveq.l #14,%[t2] \n" - "lsr.l %[t2],%[x] \n" /* (unsigned)lo >>= 14 */ - "or.l %[x],%[t1] \n" /* combine result */ - : /* outputs */ - [t1]"=&d"(t1), - [t2]"=&d"(t2), - [x] "+d" (x) - : /* inputs */ - [y] "d" (y) - ); - return t1; -} - -static INLINE void ComplexMult(real_t *y1, real_t *y2, - real_t x1, real_t x2, real_t c1, real_t c2) -{ - asm volatile( - "mac.l %[x1], %[c1], %%acc0\n\t" - "mac.l %[x2], %[c2], %%acc0\n\t" - "mac.l %[x2], %[c1], %%acc1\n\t" - "msac.l %[x1], %[c2], %%acc1\n\t" - "movclr.l %%acc0, %[x1]\n\t" - "move.l %[x1], (%[y1])\n\t" - "movclr.l %%acc1, %[x1]\n\t" - "move.l %[x1], (%[y2])" - : [x1] "+&r" (x1) - : [x2] "r" (x2), [y1] "a" (y1), [y2] "a" (y2), - [c1] "r" (c1), [c2] "r" (c2) - : "memory" - ); -} - - /* the following see little or no use, so just ignore them for now */ - #define MUL_Q2(A,B) (real_t)(((int64_t)(A)*(int64_t)(B)+(1 << (Q2_BITS-1))) >> Q2_BITS) - -#elif defined(__GNUC__) && defined (__arm__) - -/* taken from MAD */ -#define arm_mul(x, y, SCALEBITS) \ -({ \ - uint32_t __hi; \ - uint32_t __lo; \ - uint32_t __result; \ - asm("smull %0, %1, %3, %4\n\t" \ - "movs %0, %0, lsr %5\n\t" \ - "adc %2, %0, %1, lsl %6" \ - : "=&r" (__lo), "=&r" (__hi), "=r" (__result) \ - : "%r" (x), "r" (y), \ - "M" (SCALEBITS), "M" (32 - (SCALEBITS)) \ - : "cc"); \ - __result; \ -}) - -static INLINE real_t MUL_R(real_t A, real_t B) -{ - return arm_mul(A, B, REAL_BITS); -} - -static INLINE real_t MUL_C(real_t A, real_t B) -{ - return arm_mul(A, B, COEF_BITS); -} - -static INLINE real_t MUL_Q2(real_t A, real_t B) -{ - return arm_mul(A, B, Q2_BITS); -} - -static INLINE real_t _MulHigh(real_t x, real_t y) -{ - uint32_t __lo; - uint32_t __hi; - asm("smull\t%0, %1, %2, %3" - : "=&r"(__lo),"=&r"(__hi) - : "%r"(x),"r"(y) - : "cc"); - return __hi; -} - -static INLINE real_t MUL_F(real_t A, real_t B) -{ - return _MulHigh(A, B) << (FRAC_SIZE-FRAC_BITS); -} - -/* Complex multiplication */ -static INLINE void ComplexMult(real_t *y1, real_t *y2, - real_t x1, real_t x2, real_t c1, real_t c2) -{ - int32_t tmp, yt1, yt2; - asm("smull %0, %1, %4, %6\n\t" - "smlal %0, %1, %5, %7\n\t" - "rsb %3, %4, #0\n\t" - "smull %0, %2, %5, %6\n\t" - "smlal %0, %2, %3, %7" - : "=&r" (tmp), "=&r" (yt1), "=&r" (yt2), "=r" (x1) - : "3" (x1), "r" (x2), "r" (c1), "r" (c2) - : "cc" ); - *y1 = yt1 << (FRAC_SIZE-FRAC_BITS); - *y2 = yt2 << (FRAC_SIZE-FRAC_BITS); -} - -#else - - /* multiply with real shift */ - #define MUL_R(A,B) (real_t)(((int64_t)(A)*(int64_t)(B)+(1 << (REAL_BITS-1))) >> REAL_BITS) - /* multiply with coef shift */ - #define MUL_C(A,B) (real_t)(((int64_t)(A)*(int64_t)(B)+(1 << (COEF_BITS-1))) >> COEF_BITS) - /* multiply with fractional shift */ -#if defined(_WIN32_WCE) && defined(_ARM_) - /* eVC for PocketPC has an intrinsic function that returns only the high 32 bits of a 32x32 bit multiply */ - static INLINE real_t MUL_F(real_t A, real_t B) - { - return _MulHigh(A,B) << (32-FRAC_BITS); - } -#else - #define _MulHigh(A,B) (real_t)(((int64_t)(A)*(int64_t)(B)+(1 << (FRAC_SIZE-1))) >> FRAC_SIZE) - #define MUL_F(A,B) (real_t)(((int64_t)(A)*(int64_t)(B)+(1 << (FRAC_BITS-1))) >> FRAC_BITS) -#endif - #define MUL_Q2(A,B) (real_t)(((int64_t)(A)*(int64_t)(B)+(1 << (Q2_BITS-1))) >> Q2_BITS) - -/* Complex multiplication */ -static INLINE void ComplexMult(real_t *y1, real_t *y2, - real_t x1, real_t x2, real_t c1, real_t c2) -{ - *y1 = (_MulHigh(x1, c1) + _MulHigh(x2, c2))<<(FRAC_SIZE-FRAC_BITS); - *y2 = (_MulHigh(x2, c1) - _MulHigh(x1, c2))<<(FRAC_SIZE-FRAC_BITS); -} - -#endif - - - -#ifdef __cplusplus -} -#endif -#endif diff --git a/apps/codecs/libfaad/hcr.c b/apps/codecs/libfaad/hcr.c deleted file mode 100644 index f968ea7bec..0000000000 --- a/apps/codecs/libfaad/hcr.c +++ /dev/null @@ -1,409 +0,0 @@ -/* -** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2004 G.C. Pascutto, Ahead Software AG, http://www.nero.com -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -** -** Any non-GPL usage of this software or parts of this software is strictly -** forbidden. -** -** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. -** -** $Id$ -**/ - -#include "common.h" -#include "structs.h" - -#include -#include - -#include "specrec.h" -#include "huffman.h" - -/* ISO/IEC 14496-3/Amd.1 - * 8.5.3.3: Huffman Codeword Reordering for AAC spectral data (HCR) - * - * HCR devides the spectral data in known fixed size segments, and - * sorts it by the importance of the data. The importance is firstly - * the (lower) position in the spectrum, and secondly the largest - * value in the used codebook. - * The most important data is written at the start of each segment - * (at known positions), the remaining data is interleaved inbetween, - * with the writing direction alternating. - * Data length is not increased. -*/ - -#ifdef ERROR_RESILIENCE - -/* 8.5.3.3.1 Pre-sorting */ - -#define NUM_CB 6 -#define NUM_CB_ER 22 -#define MAX_CB 32 -#define VCB11_FIRST 16 -#define VCB11_LAST 31 - -static const uint8_t PreSortCB_STD[NUM_CB] = - { 11, 9, 7, 5, 3, 1}; - -static const uint8_t PreSortCB_ER[NUM_CB_ER] = - { 11, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 9, 7, 5, 3, 1}; - -/* 8.5.3.3.2 Derivation of segment width */ - -static const uint8_t maxCwLen[MAX_CB] = {0, 11, 9, 20, 16, 13, 11, 14, 12, 17, 14, 49, - 0, 0, 0, 0, 14, 17, 21, 21, 25, 25, 29, 29, 29, 29, 33, 33, 33, 37, 37, 41}; - -#define segmentWidth(cb) min(maxCwLen[cb], ics->length_of_longest_codeword) - -/* bit-twiddling helpers */ -static const uint8_t S[] = {1, 2, 4, 8, 16}; -static const uint32_t B[] = {0x55555555, 0x33333333, 0x0F0F0F0F, 0x00FF00FF, 0x0000FFFF}; - -typedef struct -{ - uint8_t cb; - uint8_t decoded; - uint16_t sp_offset; - bits_t bits; -} codeword_t; - -/* rewind and reverse */ -/* 32 bit version */ -static uint32_t rewrev_word(uint32_t v, const uint8_t len) -{ - /* 32 bit reverse */ - v = ((v >> S[0]) & B[0]) | ((v << S[0]) & ~B[0]); - v = ((v >> S[1]) & B[1]) | ((v << S[1]) & ~B[1]); - v = ((v >> S[2]) & B[2]) | ((v << S[2]) & ~B[2]); - v = ((v >> S[3]) & B[3]) | ((v << S[3]) & ~B[3]); - v = ((v >> S[4]) & B[4]) | ((v << S[4]) & ~B[4]); - - /* shift off low bits */ - v >>= (32 - len); - - return v; -} - -/* 64 bit version */ -static void rewrev_lword(uint32_t *hi, uint32_t *lo, const uint8_t len) -{ - if (len <= 32) { - *hi = 0; - *lo = rewrev_word(*lo, len); - } else - { - uint32_t t = *hi, v = *lo; - - /* double 32 bit reverse */ - v = ((v >> S[0]) & B[0]) | ((v << S[0]) & ~B[0]); - t = ((t >> S[0]) & B[0]) | ((t << S[0]) & ~B[0]); - v = ((v >> S[1]) & B[1]) | ((v << S[1]) & ~B[1]); - t = ((t >> S[1]) & B[1]) | ((t << S[1]) & ~B[1]); - v = ((v >> S[2]) & B[2]) | ((v << S[2]) & ~B[2]); - t = ((t >> S[2]) & B[2]) | ((t << S[2]) & ~B[2]); - v = ((v >> S[3]) & B[3]) | ((v << S[3]) & ~B[3]); - t = ((t >> S[3]) & B[3]) | ((t << S[3]) & ~B[3]); - v = ((v >> S[4]) & B[4]) | ((v << S[4]) & ~B[4]); - t = ((t >> S[4]) & B[4]) | ((t << S[4]) & ~B[4]); - - /* last 32<>32 bit swap is implicit below */ - - /* shift off low bits (this is really only one 64 bit shift) */ - *lo = (t >> (64 - len)) | (v << (len - 32)); - *hi = v >> (64 - len); - } -} - - -/* bits_t version */ -static void rewrev_bits(bits_t *bits) -{ - if (bits->len == 0) return; - rewrev_lword(&bits->bufb, &bits->bufa, bits->len); -} - - -/* merge bits of a to b */ -static void concat_bits(bits_t *b, bits_t *a) -{ - uint32_t bl, bh, al, ah; - - if (a->len == 0) return; - - al = a->bufa; - ah = a->bufb; - - if (b->len > 32) - { - /* maskoff superfluous high b bits */ - bl = b->bufa; - bh = b->bufb & ((1 << (b->len-32)) - 1); - /* left shift a b->len bits */ - ah = al << (b->len - 32); - al = 0; - } else { - bl = b->bufa & ((1 << (b->len)) - 1); - bh = 0; - ah = (ah << (b->len)) | (al >> (32 - b->len)); - al = al << b->len; - } - - /* merge */ - b->bufa = bl | al; - b->bufb = bh | ah; - - b->len += a->len; -} - -uint8_t is_good_cb(uint8_t this_CB, uint8_t this_sec_CB) -{ - /* only want spectral data CB's */ - if ((this_sec_CB > ZERO_HCB && this_sec_CB <= ESC_HCB) || (this_sec_CB >= VCB11_FIRST && this_sec_CB <= VCB11_LAST)) - { - if (this_CB < ESC_HCB) - { - /* normal codebook pairs */ - return ((this_sec_CB == this_CB) || (this_sec_CB == this_CB + 1)); - } else - { - /* escape codebook */ - return (this_sec_CB == this_CB); - } - } - return 0; -} - -void read_segment(bits_t *segment, uint8_t segwidth, bitfile *ld) -{ - segment->len = segwidth; - - if (segwidth > 32) - { - segment->bufb = faad_getbits(ld, segwidth - 32); - segment->bufa = faad_getbits(ld, 32); - - } else { - segment->bufa = faad_getbits(ld, segwidth); - segment->bufb = 0; - } -} - -void fill_in_codeword(codeword_t *codeword, uint16_t index, uint16_t sp, uint8_t cb) -{ - codeword[index].sp_offset = sp; - codeword[index].cb = cb; - codeword[index].decoded = 0; - codeword[index].bits.len = 0; -} - -uint8_t reordered_spectral_data(NeAACDecHandle hDecoder, ic_stream *ics, - bitfile *ld, int16_t *spectral_data) -{ - uint16_t PCWs_done; - uint16_t numberOfSegments, numberOfSets, numberOfCodewords; - - static codeword_t codeword[512]; - static bits_t segment[512]; - - uint16_t sp_offset[8]; - uint16_t g, i, sortloop, set, bitsread; - uint8_t w_idx, sfb, this_CB, last_CB, this_sec_CB; - - const uint16_t nshort = hDecoder->frameLength/8; - const uint16_t sp_data_len = ics->length_of_reordered_spectral_data; - - const uint8_t *PreSortCb; - - /* no data (e.g. silence) */ - if (sp_data_len == 0) - return 0; - - /* since there is spectral data, at least one codeword has nonzero length */ - if (ics->length_of_longest_codeword == 0) - return 10; - - if (sp_data_len < ics->length_of_longest_codeword) - return 10; - - sp_offset[0] = 0; - for (g = 1; g < ics->num_window_groups; g++) - { - sp_offset[g] = sp_offset[g-1] + nshort*ics->window_group_length[g-1]; - } - - PCWs_done = 0; - numberOfSegments = 0; - numberOfCodewords = 0; - bitsread = 0; - - /* VCB11 code books in use */ - if (hDecoder->aacSectionDataResilienceFlag) - { - PreSortCb = PreSortCB_ER; - last_CB = NUM_CB_ER; - } else - { - PreSortCb = PreSortCB_STD; - last_CB = NUM_CB; - } - - /* step 1: decode PCW's (set 0), and stuff data in easier-to-use format */ - for (sortloop = 0; sortloop < last_CB; sortloop++) - { - /* select codebook to process this pass */ - this_CB = PreSortCb[sortloop]; - - /* loop over sfbs */ - for (sfb = 0; sfb < ics->max_sfb; sfb++) - { - /* loop over all in this sfb, 4 lines per loop */ - for (w_idx = 0; 4*w_idx < (ics->swb_offset[sfb+1] - ics->swb_offset[sfb]); w_idx++) - { - for(g = 0; g < ics->num_window_groups; g++) - { - for (i = 0; i < ics->num_sec[g]; i++) - { - /* check whether sfb used here is the one we want to process */ - if ((ics->sect_start[g][i] <= sfb) && (ics->sect_end[g][i] > sfb)) - { - /* check whether codebook used here is the one we want to process */ - this_sec_CB = ics->sect_cb[g][i]; - - if (is_good_cb(this_CB, this_sec_CB)) - { - /* precalculate some stuff */ - uint16_t sect_sfb_size = ics->sect_sfb_offset[g][sfb+1] - ics->sect_sfb_offset[g][sfb]; - uint8_t inc = (this_sec_CB < FIRST_PAIR_HCB) ? QUAD_LEN : PAIR_LEN; - uint16_t group_cws_count = (4*ics->window_group_length[g])/inc; - uint8_t segwidth = segmentWidth(this_sec_CB); - uint16_t cws; - - /* read codewords until end of sfb or end of window group (shouldn't only 1 trigger?) */ - for (cws = 0; (cws < group_cws_count) && ((cws + w_idx*group_cws_count) < sect_sfb_size); cws++) - { - uint16_t sp = sp_offset[g] + ics->sect_sfb_offset[g][sfb] + inc * (cws + w_idx*group_cws_count); - - /* read and decode PCW */ - if (!PCWs_done) - { - /* read in normal segments */ - if (bitsread + segwidth <= sp_data_len) - { - read_segment(&segment[numberOfSegments], segwidth, ld); - bitsread += segwidth; - - huffman_spectral_data_2(this_sec_CB, &segment[numberOfSegments], &spectral_data[sp]); - - /* keep leftover bits */ - rewrev_bits(&segment[numberOfSegments]); - - numberOfSegments++; - } else { - /* remaining stuff after last segment, we unfortunately couldn't read - this in earlier because it might not fit in 64 bits. since we already - decoded (and removed) the PCW it is now guaranteed to fit */ - if (bitsread < sp_data_len) - { - const uint8_t additional_bits = sp_data_len - bitsread; - - read_segment(&segment[numberOfSegments], additional_bits, ld); - segment[numberOfSegments].len += segment[numberOfSegments-1].len; - rewrev_bits(&segment[numberOfSegments]); - - if (segment[numberOfSegments-1].len > 32) - { - segment[numberOfSegments-1].bufb = segment[numberOfSegments].bufb + - showbits_hcr(&segment[numberOfSegments-1], segment[numberOfSegments-1].len - 32); - segment[numberOfSegments-1].bufa = segment[numberOfSegments].bufa + - showbits_hcr(&segment[numberOfSegments-1], 32); - } else { - segment[numberOfSegments-1].bufa = segment[numberOfSegments].bufa + - showbits_hcr(&segment[numberOfSegments-1], segment[numberOfSegments-1].len); - segment[numberOfSegments-1].bufb = segment[numberOfSegments].bufb; - } - segment[numberOfSegments-1].len += additional_bits; - } - bitsread = sp_data_len; - PCWs_done = 1; - - fill_in_codeword(codeword, 0, sp, this_sec_CB); - } - } else { - fill_in_codeword(codeword, numberOfCodewords - numberOfSegments, sp, this_sec_CB); - } - numberOfCodewords++; - } - } - } - } - } - } - } - } - - if (numberOfSegments == 0) - return 10; - - numberOfSets = numberOfCodewords / numberOfSegments; - - /* step 2: decode nonPCWs */ - for (set = 1; set <= numberOfSets; set++) - { - uint16_t trial; - - for (trial = 0; trial < numberOfSegments; trial++) - { - uint16_t codewordBase; - - for (codewordBase = 0; codewordBase < numberOfSegments; codewordBase++) - { - const uint16_t segment_idx = (trial + codewordBase) % numberOfSegments; - const uint16_t codeword_idx = codewordBase + set*numberOfSegments - numberOfSegments; - - /* data up */ - if (codeword_idx >= numberOfCodewords - numberOfSegments) break; - - if (!codeword[codeword_idx].decoded && segment[segment_idx].len > 0) - { - uint8_t tmplen; - - if (codeword[codeword_idx].bits.len != 0) - concat_bits(&segment[segment_idx], &codeword[codeword_idx].bits); - - tmplen = segment[segment_idx].len; - - if (huffman_spectral_data_2(codeword[codeword_idx].cb, &segment[segment_idx], - &spectral_data[codeword[codeword_idx].sp_offset]) >= 0) - { - codeword[codeword_idx].decoded = 1; - } else - { - codeword[codeword_idx].bits = segment[segment_idx]; - codeword[codeword_idx].bits.len = tmplen; - } - - } - } - } - for (i = 0; i < numberOfSegments; i++) - rewrev_bits(&segment[i]); - } - - return 0; -} -#endif diff --git a/apps/codecs/libfaad/huffman.c b/apps/codecs/libfaad/huffman.c deleted file mode 100644 index bea0dd7bf2..0000000000 --- a/apps/codecs/libfaad/huffman.c +++ /dev/null @@ -1,563 +0,0 @@ -/* -** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -** -** Any non-GPL usage of this software or parts of this software is strictly -** forbidden. -** -** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. -** -** $Id$ -**/ - -#include "common.h" -#include "structs.h" - -#include -#ifdef ANALYSIS -#include -#endif - -#include "bits.h" -#include "huffman.h" -#include "codebook/hcb.h" - - -/* static function declarations */ -static INLINE void huffman_sign_bits_pair(bitfile *ld, int16_t *sp); -static INLINE void huffman_sign_bits_quad(bitfile *ld, int16_t *sp); -static INLINE int16_t huffman_getescape(bitfile *ld, int16_t sp); -static uint8_t huffman_2step_quad(uint8_t cb, bitfile *ld, int16_t *sp); -static uint8_t huffman_2step_quad_sign(uint8_t cb, bitfile *ld, int16_t *sp); -static INLINE uint8_t huffman_2step_pair(uint8_t cb, bitfile *ld, int16_t *sp); -static INLINE uint8_t huffman_2step_pair_sign(uint8_t cb, bitfile *ld, int16_t *sp); -static uint8_t huffman_binary_quad(uint8_t cb, bitfile *ld, int16_t *sp); -static uint8_t huffman_binary_quad_sign(uint8_t cb, bitfile *ld, int16_t *sp); -static uint8_t huffman_binary_pair(uint8_t cb, bitfile *ld, int16_t *sp); -static uint8_t huffman_binary_pair_sign(uint8_t cb, bitfile *ld, int16_t *sp); -static int16_t huffman_codebook(uint8_t i) ICODE_ATTR_FAAD_LARGE_IRAM; -#ifdef ERROR_RESILIENCE -static void vcb11_check_LAV(uint8_t cb, int16_t *sp); -#endif - -int8_t huffman_scale_factor(bitfile *ld) -{ - uint16_t offset = 0; - - while (hcb_sf[offset][1]) - { - uint8_t b = faad_get1bit(ld - DEBUGVAR(1,255,"huffman_scale_factor()")); - offset += hcb_sf[offset][b]; - - if (offset > 240) - { - /* printf("ERROR: offset into hcb_sf = %d >240!\n", offset); */ - return -1; - } - } - - return hcb_sf[offset][0]; -} - - -hcb *hcb_table[] ICONST_ATTR = { - 0, hcb1_1, hcb2_1, 0, hcb4_1, 0, hcb6_1, 0, hcb8_1, 0, hcb10_1, hcb11_1 -}; - -hcb_2_quad *hcb_2_quad_table[] ICONST_ATTR = { - 0, hcb1_2, hcb2_2, 0, hcb4_2, 0, 0, 0, 0, 0, 0, 0 -}; - -hcb_2_pair *hcb_2_pair_table[] ICONST_ATTR = { - 0, 0, 0, 0, 0, 0, hcb6_2, 0, hcb8_2, 0, hcb10_2, hcb11_2 -}; - -hcb_bin_pair *hcb_bin_table[] ICONST_ATTR = { - 0, 0, 0, 0, 0, hcb5, 0, hcb7, 0, hcb9, 0, 0 -}; - -uint8_t hcbN[] ICONST_ATTR = { 0, 5, 5, 0, 5, 0, 5, 0, 5, 0, 6, 5 }; - -/* defines whether a huffman codebook is unsigned or not */ -/* Table 4.6.2 */ -uint8_t unsigned_cb[] ICONST_ATTR = { 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, - /* codebook 16 to 31 */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 -}; - -int hcb_2_quad_table_size[] ICONST_ATTR = { 0, 114, 86, 0, 185, 0, 0, 0, 0, 0, 0, 0 }; -int hcb_2_pair_table_size[] ICONST_ATTR = { 0, 0, 0, 0, 0, 0, 126, 0, 83, 0, 210, 373 }; -int hcb_bin_table_size[] ICONST_ATTR = { 0, 0, 0, 161, 0, 161, 0, 127, 0, 337, 0, 0 }; - -#define FAAD_GET_SIGN(idx) \ - if (sp[idx]) \ - if (faad_get1bit(ld)&1) \ - sp[idx] = -sp[idx]; \ - -static INLINE void huffman_sign_bits_pair(bitfile *ld, int16_t *sp) -{ - FAAD_GET_SIGN(0) - FAAD_GET_SIGN(1) -} - -static INLINE void huffman_sign_bits_quad(bitfile *ld, int16_t *sp) -{ - FAAD_GET_SIGN(0) - FAAD_GET_SIGN(1) - FAAD_GET_SIGN(2) - FAAD_GET_SIGN(3) -} - -static INLINE int16_t huffman_getescape(bitfile *ld, int16_t sp) -{ - uint8_t neg, i; - int16_t j; - int16_t off; - - if (sp < 0) - { - if (sp != -16) - return sp; - neg = 1; - } else { - if (sp != 16) - return sp; - neg = 0; - } - - for (i = 4; ; i++) - { - if (faad_get1bit(ld - DEBUGVAR(1,6,"huffman_getescape(): escape size")) == 0) - { - break; - } - } - - off = (int16_t)faad_getbits(ld, i - DEBUGVAR(1,9,"huffman_getescape(): escape")); - - j = off | (1< hcb_2_quad_table_size[cb]) - { - /* printf("ERROR: offset into hcb_2_quad_table = %d >%d!\n", offset, - hcb_2_quad_table_size[cb]); */ - return 10; - } - - sp[0] = hcb_2_quad_table[cb][offset].x; - sp[1] = hcb_2_quad_table[cb][offset].y; - sp[2] = hcb_2_quad_table[cb][offset].v; - sp[3] = hcb_2_quad_table[cb][offset].w; - - return 0; -} - -static uint8_t huffman_2step_quad_sign(uint8_t cb, bitfile *ld, int16_t *sp) -{ - uint8_t err = huffman_2step_quad(cb, ld, sp); - huffman_sign_bits_quad(ld, sp); - - return err; -} - -static INLINE uint8_t huffman_2step_pair(uint8_t cb, bitfile *ld, int16_t *sp) -{ - uint32_t cw; - uint16_t offset = 0; - uint8_t extra_bits; - - cw = faad_showbits(ld, hcbN[cb]); - offset = hcb_table[cb][cw].offset; - extra_bits = hcb_table[cb][cw].extra_bits; - - if (extra_bits) - { - /* we know for sure it's more than hcbN[cb] bits long */ - faad_flushbits(ld, hcbN[cb]); - offset += (uint16_t)faad_showbits(ld, extra_bits); - faad_flushbits(ld, hcb_2_pair_table[cb][offset].bits - hcbN[cb]); - } else { - faad_flushbits(ld, hcb_2_pair_table[cb][offset].bits); - } - - if (offset > hcb_2_pair_table_size[cb]) - { - /* printf("ERROR: offset into hcb_2_pair_table = %d >%d!\n", offset, - hcb_2_pair_table_size[cb]); */ - return 10; - } - - sp[0] = hcb_2_pair_table[cb][offset].x; - sp[1] = hcb_2_pair_table[cb][offset].y; - - return 0; -} - -static INLINE uint8_t huffman_2step_pair_sign(uint8_t cb, bitfile *ld, int16_t *sp) -{ - uint8_t err = huffman_2step_pair(cb, ld, sp); - huffman_sign_bits_pair(ld, sp); - - return err; -} - -static uint8_t huffman_binary_quad(uint8_t cb, bitfile *ld, int16_t *sp) -{ - uint16_t offset = 0; - - while (!hcb3[offset].is_leaf) - { - uint8_t b = faad_get1bit(ld - DEBUGVAR(1,255,"huffman_spectral_data():3")); - offset += hcb3[offset].data[b]; - } - - if (offset > hcb_bin_table_size[cb]) - { - /* printf("ERROR: offset into hcb_bin_table = %d >%d!\n", offset, - hcb_bin_table_size[cb]); */ - return 10; - } - - sp[0] = hcb3[offset].data[0]; - sp[1] = hcb3[offset].data[1]; - sp[2] = hcb3[offset].data[2]; - sp[3] = hcb3[offset].data[3]; - - return 0; -} - -static uint8_t huffman_binary_quad_sign(uint8_t cb, bitfile *ld, int16_t *sp) -{ - uint8_t err = huffman_binary_quad(cb, ld, sp); - huffman_sign_bits_quad(ld, sp); - - return err; -} - -static uint8_t huffman_binary_pair(uint8_t cb, bitfile *ld, int16_t *sp) -{ - uint16_t offset = 0; - - while (!hcb_bin_table[cb][offset].is_leaf) - { - uint8_t b = faad_get1bit(ld - DEBUGVAR(1,255,"huffman_spectral_data():9")); - offset += hcb_bin_table[cb][offset].data[b]; - } - - if (offset > hcb_bin_table_size[cb]) - { - /* printf("ERROR: offset into hcb_bin_table = %d >%d!\n", offset, - hcb_bin_table_size[cb]); */ - return 10; - } - - sp[0] = hcb_bin_table[cb][offset].data[0]; - sp[1] = hcb_bin_table[cb][offset].data[1]; - - return 0; -} - -static uint8_t huffman_binary_pair_sign(uint8_t cb, bitfile *ld, int16_t *sp) -{ - uint8_t err = huffman_binary_pair(cb, ld, sp); - huffman_sign_bits_pair(ld, sp); - - return err; -} - -static int16_t huffman_codebook(uint8_t i) -{ - static const uint32_t data = 16428320; - if (i == 0) return (int16_t)(data >> 16) & 0xFFFF; - else return (int16_t)data & 0xFFFF; -} - -#ifdef ERROR_RESILIENCE -static void vcb11_check_LAV(uint8_t cb, int16_t *sp) -{ - static const uint16_t vcb11_LAV_tab[] = { - 16, 31, 47, 63, 95, 127, 159, 191, 223, - 255, 319, 383, 511, 767, 1023, 2047 - }; - uint16_t max = 0; - - if (cb < 16 || cb > 31) - return; - - max = vcb11_LAV_tab[cb - 16]; - - if ((abs(sp[0]) > max) || (abs(sp[1]) > max)) - { - sp[0] = 0; - sp[1] = 0; - } -} -#endif - -uint8_t huffman_spectral_data(uint8_t cb, bitfile *ld, int16_t *sp) -{ - switch (cb) - { - case 1: /* 2-step method for data quadruples */ - case 2: - return huffman_2step_quad(cb, ld, sp); - case 3: /* binary search for data quadruples */ - return huffman_binary_quad_sign(cb, ld, sp); - case 4: /* 2-step method for data quadruples */ - return huffman_2step_quad_sign(cb, ld, sp); - case 5: /* binary search for data pairs */ - return huffman_binary_pair(cb, ld, sp); - case 6: /* 2-step method for data pairs */ - return huffman_2step_pair(cb, ld, sp); - case 7: /* binary search for data pairs */ - case 9: - return huffman_binary_pair_sign(cb, ld, sp); - case 8: /* 2-step method for data pairs */ - case 10: - return huffman_2step_pair_sign(cb, ld, sp); - case 12: { - uint8_t err = huffman_2step_pair(11, ld, sp); - sp[0] = huffman_codebook(0); sp[1] = huffman_codebook(1); - return err; } - case 11: - { - uint8_t err = huffman_2step_pair_sign(11, ld, sp); - sp[0] = huffman_getescape(ld, sp[0]); - sp[1] = huffman_getescape(ld, sp[1]); - return err; - } -#ifdef ERROR_RESILIENCE - /* VCB11 uses codebook 11 */ - case 16: case 17: case 18: case 19: case 20: case 21: case 22: case 23: - case 24: case 25: case 26: case 27: case 28: case 29: case 30: case 31: - { - uint8_t err = huffman_2step_pair_sign(11, ld, sp); - sp[0] = huffman_getescape(ld, sp[0]); - sp[1] = huffman_getescape(ld, sp[1]); - - /* check LAV (Largest Absolute Value) */ - /* this finds errors in the ESCAPE signal */ - vcb11_check_LAV(cb, sp); - - return err; - } -#endif - default: - /* Non existent codebook number, something went wrong */ - return 11; - } - - return 0; -} - - -#ifdef ERROR_RESILIENCE - -/* Special version of huffman_spectral_data -Will not read from a bitfile but a bits_t structure. -Will keep track of the bits decoded and return the number of bits remaining. -Do not read more than ld->len, return -1 if codeword would be longer */ - -int8_t huffman_spectral_data_2(uint8_t cb, bits_t *ld, int16_t *sp) -{ - uint32_t cw; - uint16_t offset = 0; - uint8_t extra_bits; - uint8_t i, vcb11 = 0; - - - switch (cb) - { - case 1: /* 2-step method for data quadruples */ - case 2: - case 4: - - cw = showbits_hcr(ld, hcbN[cb]); - offset = hcb_table[cb][cw].offset; - extra_bits = hcb_table[cb][cw].extra_bits; - - if (extra_bits) - { - /* we know for sure it's more than hcbN[cb] bits long */ - if ( flushbits_hcr(ld, hcbN[cb]) ) return -1; - offset += (uint16_t)showbits_hcr(ld, extra_bits); - if ( flushbits_hcr(ld, hcb_2_quad_table[cb][offset].bits - hcbN[cb]) ) return -1; - } else { - if ( flushbits_hcr(ld, hcb_2_quad_table[cb][offset].bits) ) return -1; - } - - sp[0] = hcb_2_quad_table[cb][offset].x; - sp[1] = hcb_2_quad_table[cb][offset].y; - sp[2] = hcb_2_quad_table[cb][offset].v; - sp[3] = hcb_2_quad_table[cb][offset].w; - break; - - case 6: /* 2-step method for data pairs */ - case 8: - case 10: - case 11: - /* VCB11 uses codebook 11 */ - case 16: case 17: case 18: case 19: case 20: case 21: case 22: case 23: - case 24: case 25: case 26: case 27: case 28: case 29: case 30: case 31: - - if (cb >= 16) - { - /* store the virtual codebook */ - vcb11 = cb; - cb = 11; - } - - cw = showbits_hcr(ld, hcbN[cb]); - offset = hcb_table[cb][cw].offset; - extra_bits = hcb_table[cb][cw].extra_bits; - - if (extra_bits) - { - /* we know for sure it's more than hcbN[cb] bits long */ - if ( flushbits_hcr(ld, hcbN[cb]) ) return -1; - offset += (uint16_t)showbits_hcr(ld, extra_bits); - if ( flushbits_hcr(ld, hcb_2_pair_table[cb][offset].bits - hcbN[cb]) ) return -1; - } else { - if ( flushbits_hcr(ld, hcb_2_pair_table[cb][offset].bits) ) return -1; - } - sp[0] = hcb_2_pair_table[cb][offset].x; - sp[1] = hcb_2_pair_table[cb][offset].y; - break; - - case 3: /* binary search for data quadruples */ - - while (!hcb3[offset].is_leaf) - { - uint8_t b; - - if ( get1bit_hcr(ld, &b) ) return -1; - offset += hcb3[offset].data[b]; - } - - sp[0] = hcb3[offset].data[0]; - sp[1] = hcb3[offset].data[1]; - sp[2] = hcb3[offset].data[2]; - sp[3] = hcb3[offset].data[3]; - - break; - - case 5: /* binary search for data pairs */ - case 7: - case 9: - - while (!hcb_bin_table[cb][offset].is_leaf) - { - uint8_t b; - - if (get1bit_hcr(ld, &b) ) return -1; - offset += hcb_bin_table[cb][offset].data[b]; - } - - sp[0] = hcb_bin_table[cb][offset].data[0]; - sp[1] = hcb_bin_table[cb][offset].data[1]; - - break; - } - - /* decode sign bits */ - if (unsigned_cb[cb]) - { - for(i = 0; i < ((cb < FIRST_PAIR_HCB) ? QUAD_LEN : PAIR_LEN); i++) - { - if(sp[i]) - { - uint8_t b; - if ( get1bit_hcr(ld, &b) ) return -1; - if (b != 0) { - sp[i] = -sp[i]; - } - } - } - } - - /* decode huffman escape bits */ - if ((cb == ESC_HCB) || (cb >= 16)) - { - uint8_t k; - for (k = 0; k < 2; k++) - { - if ((sp[k] == 16) || (sp[k] == -16)) - { - uint8_t neg, i; - int32_t j; - uint32_t off; - - neg = (sp[k] < 0) ? 1 : 0; - - for (i = 4; ; i++) - { - uint8_t b; - if (get1bit_hcr(ld, &b)) - return -1; - if (b == 0) - break; - } - - if (getbits_hcr(ld, i, &off)) - return -1; - j = off + (1<len; -} - -#endif - diff --git a/apps/codecs/libfaad/huffman.h b/apps/codecs/libfaad/huffman.h deleted file mode 100644 index 214d3a220f..0000000000 --- a/apps/codecs/libfaad/huffman.h +++ /dev/null @@ -1,44 +0,0 @@ -/* -** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -** -** Any non-GPL usage of this software or parts of this software is strictly -** forbidden. -** -** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. -** -** $Id$ -**/ - -#ifndef __HUFFMAN_H__ -#define __HUFFMAN_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -int8_t huffman_scale_factor(bitfile *ld); -uint8_t huffman_spectral_data(uint8_t cb, bitfile *ld, int16_t *sp) ICODE_ATTR_FAAD_LARGE_IRAM; -#ifdef ERROR_RESILIENCE -int8_t huffman_spectral_data_2(uint8_t cb, bits_t *ld, int16_t *sp); -#endif - -#ifdef __cplusplus -} -#endif -#endif diff --git a/apps/codecs/libfaad/ic_predict.c b/apps/codecs/libfaad/ic_predict.c deleted file mode 100644 index 02cadd65b1..0000000000 --- a/apps/codecs/libfaad/ic_predict.c +++ /dev/null @@ -1,267 +0,0 @@ -/* -** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -** -** Any non-GPL usage of this software or parts of this software is strictly -** forbidden. -** -** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. -** -** $Id$ -**/ - -#include "common.h" -#include "structs.h" - -#ifdef MAIN_DEC - -#include "syntax.h" -#include "ic_predict.h" -#include "pns.h" - - -static void flt_round(float32_t *pf) -{ - int32_t flg; - uint32_t tmp, tmp1, tmp2; - - tmp = *(uint32_t*)pf; - flg = tmp & (uint32_t)0x00008000; - tmp &= (uint32_t)0xffff0000; - tmp1 = tmp; - /* round 1/2 lsb toward infinity */ - if (flg) - { - tmp &= (uint32_t)0xff800000; /* extract exponent and sign */ - tmp |= (uint32_t)0x00010000; /* insert 1 lsb */ - tmp2 = tmp; /* add 1 lsb and elided one */ - tmp &= (uint32_t)0xff800000; /* extract exponent and sign */ - - *pf = *(float32_t*)&tmp1 + *(float32_t*)&tmp2 - *(float32_t*)&tmp; - } else { - *pf = *(float32_t*)&tmp; - } -} - -static int16_t quant_pred(float32_t x) -{ - int16_t q; - uint32_t *tmp = (uint32_t*)&x; - - q = (int16_t)(*tmp>>16); - - return q; -} - -static float32_t inv_quant_pred(int16_t q) -{ - float32_t x; - uint32_t *tmp = (uint32_t*)&x; - *tmp = ((uint32_t)q)<<16; - - return x; -} - -static void ic_predict(pred_state *state, real_t input, real_t *output, uint8_t pred) -{ - uint16_t tmp; - int16_t i, j; - real_t dr1, predictedvalue; - real_t e0, e1; - real_t k1, k2; - - real_t r[2]; - real_t COR[2]; - real_t VAR[2]; - - r[0] = inv_quant_pred(state->r[0]); - r[1] = inv_quant_pred(state->r[1]); - COR[0] = inv_quant_pred(state->COR[0]); - COR[1] = inv_quant_pred(state->COR[1]); - VAR[0] = inv_quant_pred(state->VAR[0]); - VAR[1] = inv_quant_pred(state->VAR[1]); - - -#if 1 - tmp = state->VAR[0]; - j = (tmp >> 7); - i = tmp & 0x7f; - if (j >= 128) - { - j -= 128; - k1 = COR[0] * exp_table[j] * mnt_table[i]; - } else { - k1 = REAL_CONST(0); - } -#else - - { -#define B 0.953125 - real_t c = COR[0]; - real_t v = VAR[0]; - real_t tmp; - if (c == 0 || v <= 1) - { - k1 = 0; - } else { - tmp = B / v; - flt_round(&tmp); - k1 = c * tmp; - } - } -#endif - - if (pred) - { -#if 1 - tmp = state->VAR[1]; - j = (tmp >> 7); - i = tmp & 0x7f; - if (j >= 128) - { - j -= 128; - k2 = COR[1] * exp_table[j] * mnt_table[i]; - } else { - k2 = REAL_CONST(0); - } -#else - -#define B 0.953125 - real_t c = COR[1]; - real_t v = VAR[1]; - real_t tmp; - if (c == 0 || v <= 1) - { - k2 = 0; - } else { - tmp = B / v; - flt_round(&tmp); - k2 = c * tmp; - } -#endif - - predictedvalue = k1*r[0] + k2*r[1]; - flt_round(&predictedvalue); - *output = input + predictedvalue; - } - - /* calculate new state data */ - e0 = *output; - e1 = e0 - k1*r[0]; - dr1 = k1*e0; - - VAR[0] = ALPHA*VAR[0] + 0.5f * (r[0]*r[0] + e0*e0); - COR[0] = ALPHA*COR[0] + r[0]*e0; - VAR[1] = ALPHA*VAR[1] + 0.5f * (r[1]*r[1] + e1*e1); - COR[1] = ALPHA*COR[1] + r[1]*e1; - - r[1] = A * (r[0]-dr1); - r[0] = A * e0; - - state->r[0] = quant_pred(r[0]); - state->r[1] = quant_pred(r[1]); - state->COR[0] = quant_pred(COR[0]); - state->COR[1] = quant_pred(COR[1]); - state->VAR[0] = quant_pred(VAR[0]); - state->VAR[1] = quant_pred(VAR[1]); -} - -static void reset_pred_state(pred_state *state) -{ - state->r[0] = 0; - state->r[1] = 0; - state->COR[0] = 0; - state->COR[1] = 0; - state->VAR[0] = 0x3F80; - state->VAR[1] = 0x3F80; -} - -void pns_reset_pred_state(ic_stream *ics, pred_state *state) -{ - uint8_t sfb, g, b; - uint16_t i, offs, offs2; - - /* prediction only for long blocks */ - if (ics->window_sequence == EIGHT_SHORT_SEQUENCE) - return; - - for (g = 0; g < ics->num_window_groups; g++) - { - for (b = 0; b < ics->window_group_length[g]; b++) - { - for (sfb = 0; sfb < ics->max_sfb; sfb++) - { - if (is_noise(ics, g, sfb)) - { - offs = ics->swb_offset[sfb]; - offs2 = ics->swb_offset[sfb+1]; - - for (i = offs; i < offs2; i++) - reset_pred_state(&state[i]); - } - } - } - } -} - -void reset_all_predictors(pred_state *state, uint16_t frame_len) -{ - uint16_t i; - - for (i = 0; i < frame_len; i++) - reset_pred_state(&state[i]); -} - -/* intra channel prediction */ -void ic_prediction(ic_stream *ics, real_t *spec, pred_state *state, - uint16_t frame_len, uint8_t sf_index) -{ - uint8_t sfb; - uint16_t bin; - - if (ics->window_sequence == EIGHT_SHORT_SEQUENCE) - { - reset_all_predictors(state, frame_len); - } else { - for (sfb = 0; sfb < max_pred_sfb(sf_index); sfb++) - { - uint16_t low = ics->swb_offset[sfb]; - uint16_t high = ics->swb_offset[sfb+1]; - - for (bin = low; bin < high; bin++) - { - ic_predict(&state[bin], spec[bin], &spec[bin], - (ics->predictor_data_present && ics->pred.prediction_used[sfb])); - } - } - - if (ics->predictor_data_present) - { - if (ics->pred.predictor_reset) - { - for (bin = ics->pred.predictor_reset_group_number - 1; - bin < frame_len; bin += 30) - { - reset_pred_state(&state[bin]); - } - } - } - } -} - -#endif diff --git a/apps/codecs/libfaad/ic_predict.h b/apps/codecs/libfaad/ic_predict.h deleted file mode 100644 index 1f2d2c657e..0000000000 --- a/apps/codecs/libfaad/ic_predict.h +++ /dev/null @@ -1,249 +0,0 @@ -/* -** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -** -** Any non-GPL usage of this software or parts of this software is strictly -** forbidden. -** -** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. -** -** $Id$ -**/ - -#ifdef MAIN_DEC - -#ifndef __IC_PREDICT_H__ -#define __IC_PREDICT_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -#define ALPHA REAL_CONST(0.90625) -#define A REAL_CONST(0.953125) - - -void pns_reset_pred_state(ic_stream *ics, pred_state *state); -void reset_all_predictors(pred_state *state, uint16_t frame_len); -void ic_prediction(ic_stream *ics, real_t *spec, pred_state *state, - uint16_t frame_len, uint8_t sf_index); -#warning MEM_ALIGN_ATTR me! -static const real_t mnt_table[128] = { - COEF_CONST(0.9531250000), COEF_CONST(0.9453125000), - COEF_CONST(0.9375000000), COEF_CONST(0.9296875000), - COEF_CONST(0.9257812500), COEF_CONST(0.9179687500), - COEF_CONST(0.9101562500), COEF_CONST(0.9023437500), - COEF_CONST(0.8984375000), COEF_CONST(0.8906250000), - COEF_CONST(0.8828125000), COEF_CONST(0.8789062500), - COEF_CONST(0.8710937500), COEF_CONST(0.8671875000), - COEF_CONST(0.8593750000), COEF_CONST(0.8515625000), - COEF_CONST(0.8476562500), COEF_CONST(0.8398437500), - COEF_CONST(0.8359375000), COEF_CONST(0.8281250000), - COEF_CONST(0.8242187500), COEF_CONST(0.8203125000), - COEF_CONST(0.8125000000), COEF_CONST(0.8085937500), - COEF_CONST(0.8007812500), COEF_CONST(0.7968750000), - COEF_CONST(0.7929687500), COEF_CONST(0.7851562500), - COEF_CONST(0.7812500000), COEF_CONST(0.7773437500), - COEF_CONST(0.7734375000), COEF_CONST(0.7656250000), - COEF_CONST(0.7617187500), COEF_CONST(0.7578125000), - COEF_CONST(0.7539062500), COEF_CONST(0.7500000000), - COEF_CONST(0.7421875000), COEF_CONST(0.7382812500), - COEF_CONST(0.7343750000), COEF_CONST(0.7304687500), - COEF_CONST(0.7265625000), COEF_CONST(0.7226562500), - COEF_CONST(0.7187500000), COEF_CONST(0.7148437500), - COEF_CONST(0.7109375000), COEF_CONST(0.7070312500), - COEF_CONST(0.6992187500), COEF_CONST(0.6953125000), - COEF_CONST(0.6914062500), COEF_CONST(0.6875000000), - COEF_CONST(0.6835937500), COEF_CONST(0.6796875000), - COEF_CONST(0.6796875000), COEF_CONST(0.6757812500), - COEF_CONST(0.6718750000), COEF_CONST(0.6679687500), - COEF_CONST(0.6640625000), COEF_CONST(0.6601562500), - COEF_CONST(0.6562500000), COEF_CONST(0.6523437500), - COEF_CONST(0.6484375000), COEF_CONST(0.6445312500), - COEF_CONST(0.6406250000), COEF_CONST(0.6406250000), - COEF_CONST(0.6367187500), COEF_CONST(0.6328125000), - COEF_CONST(0.6289062500), COEF_CONST(0.6250000000), - COEF_CONST(0.6210937500), COEF_CONST(0.6210937500), - COEF_CONST(0.6171875000), COEF_CONST(0.6132812500), - COEF_CONST(0.6093750000), COEF_CONST(0.6054687500), - COEF_CONST(0.6054687500), COEF_CONST(0.6015625000), - COEF_CONST(0.5976562500), COEF_CONST(0.5937500000), - COEF_CONST(0.5937500000), COEF_CONST(0.5898437500), - COEF_CONST(0.5859375000), COEF_CONST(0.5820312500), - COEF_CONST(0.5820312500), COEF_CONST(0.5781250000), - COEF_CONST(0.5742187500), COEF_CONST(0.5742187500), - COEF_CONST(0.5703125000), COEF_CONST(0.5664062500), - COEF_CONST(0.5664062500), COEF_CONST(0.5625000000), - COEF_CONST(0.5585937500), COEF_CONST(0.5585937500), - COEF_CONST(0.5546875000), COEF_CONST(0.5507812500), - COEF_CONST(0.5507812500), COEF_CONST(0.5468750000), - COEF_CONST(0.5429687500), COEF_CONST(0.5429687500), - COEF_CONST(0.5390625000), COEF_CONST(0.5390625000), - COEF_CONST(0.5351562500), COEF_CONST(0.5312500000), - COEF_CONST(0.5312500000), COEF_CONST(0.5273437500), - COEF_CONST(0.5273437500), COEF_CONST(0.5234375000), - COEF_CONST(0.5195312500), COEF_CONST(0.5195312500), - COEF_CONST(0.5156250000), COEF_CONST(0.5156250000), - COEF_CONST(0.5117187500), COEF_CONST(0.5117187500), - COEF_CONST(0.5078125000), COEF_CONST(0.5078125000), - COEF_CONST(0.5039062500), COEF_CONST(0.5039062500), - COEF_CONST(0.5000000000), COEF_CONST(0.4980468750), - COEF_CONST(0.4960937500), COEF_CONST(0.4941406250), - COEF_CONST(0.4921875000), COEF_CONST(0.4902343750), - COEF_CONST(0.4882812500), COEF_CONST(0.4863281250), - COEF_CONST(0.4843750000), COEF_CONST(0.4824218750), - COEF_CONST(0.4804687500), COEF_CONST(0.4785156250) -}; -#warning MEM_ALIGN_ATTR me! -static const real_t exp_table[128] = { - COEF_CONST(0.50000000000000000000000000000000000000000000000000), - COEF_CONST(0.25000000000000000000000000000000000000000000000000), - COEF_CONST(0.12500000000000000000000000000000000000000000000000), - COEF_CONST(0.06250000000000000000000000000000000000000000000000), - COEF_CONST(0.03125000000000000000000000000000000000000000000000), - COEF_CONST(0.01562500000000000000000000000000000000000000000000), - COEF_CONST(0.00781250000000000000000000000000000000000000000000), - COEF_CONST(0.00390625000000000000000000000000000000000000000000), - COEF_CONST(0.00195312500000000000000000000000000000000000000000), - COEF_CONST(0.00097656250000000000000000000000000000000000000000), - COEF_CONST(0.00048828125000000000000000000000000000000000000000), - COEF_CONST(0.00024414062500000000000000000000000000000000000000), - COEF_CONST(0.00012207031250000000000000000000000000000000000000), - COEF_CONST(0.00006103515625000000000000000000000000000000000000), - COEF_CONST(0.00003051757812500000000000000000000000000000000000), - COEF_CONST(0.00001525878906250000000000000000000000000000000000), - COEF_CONST(0.00000762939453125000000000000000000000000000000000), - COEF_CONST(0.00000381469726562500000000000000000000000000000000), - COEF_CONST(0.00000190734863281250000000000000000000000000000000), - COEF_CONST(0.00000095367431640625000000000000000000000000000000), - COEF_CONST(0.00000047683715820312500000000000000000000000000000), - COEF_CONST(0.00000023841857910156250000000000000000000000000000), - COEF_CONST(0.00000011920928955078125000000000000000000000000000), - COEF_CONST(0.00000005960464477539062500000000000000000000000000), - COEF_CONST(0.00000002980232238769531300000000000000000000000000), - COEF_CONST(0.00000001490116119384765600000000000000000000000000), - COEF_CONST(0.00000000745058059692382810000000000000000000000000), - COEF_CONST(0.00000000372529029846191410000000000000000000000000), - COEF_CONST(0.00000000186264514923095700000000000000000000000000), - COEF_CONST(0.00000000093132257461547852000000000000000000000000), - COEF_CONST(0.00000000046566128730773926000000000000000000000000), - COEF_CONST(0.00000000023283064365386963000000000000000000000000), - COEF_CONST(0.00000000011641532182693481000000000000000000000000), - COEF_CONST(0.00000000005820766091346740700000000000000000000000), - COEF_CONST(0.00000000002910383045673370400000000000000000000000), - COEF_CONST(0.00000000001455191522836685200000000000000000000000), - COEF_CONST(0.00000000000727595761418342590000000000000000000000), - COEF_CONST(0.00000000000363797880709171300000000000000000000000), - COEF_CONST(0.00000000000181898940354585650000000000000000000000), - COEF_CONST(0.00000000000090949470177292824000000000000000000000), - COEF_CONST(0.00000000000045474735088646412000000000000000000000), - COEF_CONST(0.00000000000022737367544323206000000000000000000000), - COEF_CONST(0.00000000000011368683772161603000000000000000000000), - COEF_CONST(0.00000000000005684341886080801500000000000000000000), - COEF_CONST(0.00000000000002842170943040400700000000000000000000), - COEF_CONST(0.00000000000001421085471520200400000000000000000000), - COEF_CONST(0.00000000000000710542735760100190000000000000000000), - COEF_CONST(0.00000000000000355271367880050090000000000000000000), - COEF_CONST(0.00000000000000177635683940025050000000000000000000), - COEF_CONST(0.00000000000000088817841970012523000000000000000000), - COEF_CONST(0.00000000000000044408920985006262000000000000000000), - COEF_CONST(0.00000000000000022204460492503131000000000000000000), - COEF_CONST(0.00000000000000011102230246251565000000000000000000), - COEF_CONST(0.00000000000000005551115123125782700000000000000000), - COEF_CONST(0.00000000000000002775557561562891400000000000000000), - COEF_CONST(0.00000000000000001387778780781445700000000000000000), - COEF_CONST(0.00000000000000000693889390390722840000000000000000), - COEF_CONST(0.00000000000000000346944695195361420000000000000000), - COEF_CONST(0.00000000000000000173472347597680710000000000000000), - COEF_CONST(0.00000000000000000086736173798840355000000000000000), - COEF_CONST(0.00000000000000000043368086899420177000000000000000), - COEF_CONST(0.00000000000000000021684043449710089000000000000000), - COEF_CONST(0.00000000000000000010842021724855044000000000000000), - COEF_CONST(0.00000000000000000005421010862427522200000000000000), - COEF_CONST(0.00000000000000000002710505431213761100000000000000), - COEF_CONST(0.00000000000000000001355252715606880500000000000000), - COEF_CONST(0.00000000000000000000677626357803440270000000000000), - COEF_CONST(0.00000000000000000000338813178901720140000000000000), - COEF_CONST(0.00000000000000000000169406589450860070000000000000), - COEF_CONST(0.00000000000000000000084703294725430034000000000000), - COEF_CONST(0.00000000000000000000042351647362715017000000000000), - COEF_CONST(0.00000000000000000000021175823681357508000000000000), - COEF_CONST(0.00000000000000000000010587911840678754000000000000), - COEF_CONST(0.00000000000000000000005293955920339377100000000000), - COEF_CONST(0.00000000000000000000002646977960169688600000000000), - COEF_CONST(0.00000000000000000000001323488980084844300000000000), - COEF_CONST(0.00000000000000000000000661744490042422140000000000), - COEF_CONST(0.00000000000000000000000330872245021211070000000000), - COEF_CONST(0.00000000000000000000000165436122510605530000000000), - COEF_CONST(0.00000000000000000000000082718061255302767000000000), - COEF_CONST(0.00000000000000000000000041359030627651384000000000), - COEF_CONST(0.00000000000000000000000020679515313825692000000000), - COEF_CONST(0.00000000000000000000000010339757656912846000000000), - COEF_CONST(0.00000000000000000000000005169878828456423000000000), - COEF_CONST(0.00000000000000000000000002584939414228211500000000), - COEF_CONST(0.00000000000000000000000001292469707114105700000000), - COEF_CONST(0.00000000000000000000000000646234853557052870000000), - COEF_CONST(0.00000000000000000000000000323117426778526440000000), - COEF_CONST(0.00000000000000000000000000161558713389263220000000), - COEF_CONST(0.00000000000000000000000000080779356694631609000000), - COEF_CONST(0.00000000000000000000000000040389678347315804000000), - COEF_CONST(0.00000000000000000000000000020194839173657902000000), - COEF_CONST(0.00000000000000000000000000010097419586828951000000), - COEF_CONST(0.00000000000000000000000000005048709793414475600000), - COEF_CONST(0.00000000000000000000000000002524354896707237800000), - COEF_CONST(0.00000000000000000000000000001262177448353618900000), - COEF_CONST(0.00000000000000000000000000000631088724176809440000), - COEF_CONST(0.00000000000000000000000000000315544362088404720000), - COEF_CONST(0.00000000000000000000000000000157772181044202360000), - COEF_CONST(0.00000000000000000000000000000078886090522101181000), - COEF_CONST(0.00000000000000000000000000000039443045261050590000), - COEF_CONST(0.00000000000000000000000000000019721522630525295000), - COEF_CONST(0.00000000000000000000000000000009860761315262647600), - COEF_CONST(0.00000000000000000000000000000004930380657631323800), - COEF_CONST(0.00000000000000000000000000000002465190328815661900), - COEF_CONST(0.00000000000000000000000000000001232595164407830900), - COEF_CONST(0.00000000000000000000000000000000616297582203915470), - COEF_CONST(0.00000000000000000000000000000000308148791101957740), - COEF_CONST(0.00000000000000000000000000000000154074395550978870), - COEF_CONST(0.00000000000000000000000000000000077037197775489434), - COEF_CONST(0.00000000000000000000000000000000038518598887744717), - COEF_CONST(0.00000000000000000000000000000000019259299443872359), - COEF_CONST(0.00000000000000000000000000000000009629649721936179), - COEF_CONST(0.00000000000000000000000000000000004814824860968090), - COEF_CONST(0.00000000000000000000000000000000002407412430484045), - COEF_CONST(0.00000000000000000000000000000000001203706215242022), - COEF_CONST(0.00000000000000000000000000000000000601853107621011), - COEF_CONST(0.00000000000000000000000000000000000300926553810506), - COEF_CONST(0.00000000000000000000000000000000000150463276905253), - COEF_CONST(0.00000000000000000000000000000000000075231638452626), - COEF_CONST(0.00000000000000000000000000000000000037615819226313), - COEF_CONST(0.00000000000000000000000000000000000018807909613157), - COEF_CONST(0.00000000000000000000000000000000000009403954806578), - COEF_CONST(0.00000000000000000000000000000000000004701977403289), - COEF_CONST(0.00000000000000000000000000000000000002350988701645), - COEF_CONST(0.00000000000000000000000000000000000001175494350822), - COEF_CONST(0.0 /* 0000000000000000000000000000000000000587747175411 "floating point underflow" */), - COEF_CONST(0.0) -}; - -#ifdef __cplusplus -} -#endif -#endif - -#endif diff --git a/apps/codecs/libfaad/iq_table.h b/apps/codecs/libfaad/iq_table.h deleted file mode 100644 index eaf2fe4671..0000000000 --- a/apps/codecs/libfaad/iq_table.h +++ /dev/null @@ -1,16455 +0,0 @@ -/* -** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -** -** Any non-GPL usage of this software or parts of this software is strictly -** forbidden. -** -** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. -** -** $Id$ -**/ - -#ifndef IQ_TABLE_H__ -#define IQ_TABLE_H__ - -#ifdef __cplusplus -extern "C" { -#endif - - -/* !!!DON'T CHANGE IQ_TABLE_SIZE!!! */ - - -#ifndef FIXED_POINT - -#define IQ_TABLE_SIZE 8192 - -#ifdef _MSC_VER -#pragma warning(disable:4305) -#pragma warning(disable:4244) -#endif - -static const real_t iq_table[IQ_TABLE_SIZE] MEM_ALIGN_ATTR = -{ - 0, - 1, - 2.5198420997897464, - 4.3267487109222245, - 6.3496042078727974, - 8.5498797333834844, - 10.902723556992836, - 13.390518279406722, - 15.999999999999998, - 18.720754407467133, - 21.544346900318832, - 24.463780996262464, - 27.47314182127996, - 30.567350940369842, - 33.741991698453212, - 36.993181114957046, - 40.317473596635935, - 43.711787041189993, - 47.173345095760126, - 50.699631325716943, - 54.288352331898118, - 57.937407704003519, - 61.6448652744185, - 65.408940536585988, - 69.227979374755591, - 73.100443455321638, - 77.024897778591622, - 80.999999999999986, - 85.024491212518527, - 89.097187944889555, - 93.216975178615741, - 97.382800224133163, - 101.59366732596474, - 105.84863288986224, - 110.14680124343441, - 114.4873208566006, - 118.86938096020653, - 123.29220851090024, - 127.75506545836058, - 132.25724627755247, - 136.79807573413572, - 141.37690685569191, - 145.99311908523086, - 150.6461165966291, - 155.33532675434674, - 160.06019870205279, - 164.82020206673349, - 169.61482576651861, - 174.44357691188537, - 179.30597979112557, - 184.20157493201927, - 189.12991823257562, - 194.09058015449685, - 199.08314497371677, - 204.1072100829694, - 209.16238534187647, - 214.24829247050752, - 219.36456448277784, - 224.51084515641216, - 229.6867885365223, - 234.89205847013176, - 240.12632816923249, - 245.38927980018505, - 250.68060409747261, - 255.99999999999991, - 261.34717430828869, - 266.72184136106449, - 272.12372272986045, - 277.55254693037961, - 283.0080491494619, - 288.48997098659891, - 293.99806020902247, - 299.53207051947408, - 305.0917613358298, - 310.67689758182206, - 316.28724948815585, - 321.92259240337177, - 327.58270661385535, - 333.26737717243742, - 338.97639373507025, - 344.70955040510125, - 350.46664558470013, - 356.24748183302603, - 362.05186573075139, - 367.87960775058258, - 373.73052213344511, - 379.60442677002078, - 385.50114308734607, - 391.42049594019937, - 397.36231350702371, - 403.32642719014467, - 409.31267152006262, - 415.32088406360799, - 421.35090533576471, - 427.40257871497619, - 433.4757503617617, - 439.5702691404793, - 445.68598654408271, - 451.82275662172759, - 457.98043590909128, - 464.15888336127773, - 470.35796028818726, - 476.5775302922363, - 482.81745920832043, - 489.07761504591741, - 495.35786793323581, - 501.65809006331688, - 507.97815564200368, - 514.31794083769648, - 520.67732373281672, - 527.05618427690604, - 533.45440424129174, - 539.87186717525128, - 546.30845836361505, - 552.76406478574609, - 559.23857507584194, - 565.73187948450413, - 572.24386984152341, - 578.77443951983378, - 585.32348340058843, - 591.89089783931263, - 598.47658063309257, - 605.08043098876044, - 611.70234949203643, - 618.3422380775919, - 624.99999999999977, - 631.67553980553748, - 638.36876330481164, - 645.07957754617485, - 651.80789078990415, - 658.55361248311499, - 665.31665323538357, - 672.09692479505225, - 678.8943400261943, - 685.70881288621433, - 692.540258404062, - 699.38859265903977, - 706.25373276018058, - 713.13559682617972, - 720.03410396586037, - 726.94917425915435, - 733.88072873858209, - 740.82868937121543, - 747.79297904110535, - 754.77352153216191, - 761.77024151147043, - 768.78306451302956, - 775.81191692189896, - 782.85672595874246, - 789.91741966475445, - 796.99392688695798, - 804.08617726386274, - 811.19410121147098, - 818.31762990962227, - 825.45669528866563, - 832.61123001644864, - 839.78116748561604, - 846.96644180120552, - 854.16698776853514, - 861.38274088137143, - 868.61363731036977, - 875.85961389178203, - 883.12060811641959, - 890.39655811886757, - 897.68740266694181, - 904.99308115138172, - 912.31353357577188, - 919.64870054668756, - 926.99852326405619, - 934.36294351172899, - 941.74190364825859, - 949.13534659787422, - 956.54321584165211, - 963.96545540887348, - 971.40200986856541, - 978.85282432122176, - 986.31784439069588, - 993.7970162162635, - 1001.29028644485, - 1008.797602223418, - 1016.3189111915103, - 1023.8541614739464, - 1031.4033016736653, - 1038.9662808647138, - 1046.5430485853758, - 1054.1335548314366, - 1061.7377500495838, - 1069.3555851309357, - 1076.9870114046978, - 1084.6319806319441, - 1092.2904449995174, - 1099.9623571140482, - 1107.6476699960892, - 1115.3463370743607, - 1123.058312180106, - 1130.7835495415541, - 1138.5220037784854, - 1146.273629896901, - 1154.0383832837879, - 1161.816219701986, - 1169.607095285146, - 1177.4109665327808, - 1185.2277903054078, - 1193.0575238197798, - 1200.9001246442001, - 1208.7555506939248, - 1216.6237602266442, - 1224.5047118380478, - 1232.3983644574657, - 1240.3046773435874, - 1248.2236100802568, - 1256.1551225723395, - 1264.099175041662, - 1272.0557280230228, - 1280.0247423602691, - 1288.0061792024444, - 1295.9999999999995, - 1304.006166501068, - 1312.0246407478062, - 1320.0553850727929, - 1328.0983620954903, - 1336.1535347187651, - 1344.2208661254647, - 1352.3003197750522, - 1360.3918594002962, - 1368.4954490040145, - 1376.6110528558709, - 1384.7386354892244, - 1392.8781616980295, - 1401.0295965337855, - 1409.1929053025353, - 1417.3680535619119, - 1425.5550071182327, - 1433.7537320236374, - 1441.9641945732744, - 1450.1863613025282, - 1458.4201989842913, - 1466.6656746262797, - 1474.9227554683875, - 1483.1914089800841, - 1491.4716028578516, - 1499.7633050226596, - 1508.0664836174794, - 1516.3811070048375, - 1524.7071437644029, - 1533.0445626906128, - 1541.3933327903342, - 1549.7534232805581, - 1558.1248035861302, - 1566.507443337515, - 1574.9013123685909, - 1583.3063807144795, - 1591.7226186094069, - 1600.1499964845941, - 1608.58848496618, - 1617.0380548731737, - 1625.4986772154357, - 1633.9703231916887, - 1642.4529641875577, - 1650.9465717736346, - 1659.4511177035752, - 1667.9665739122186, - 1676.4929125137353, - 1685.030105799801, - 1693.5781262377957, - 1702.136946469027, - 1710.7065393069795, - 1719.2868777355877, - 1727.8779349075323, - 1736.4796841425596, - 1745.092098925825, - 1753.7151529062583, - 1762.3488198949503, - 1770.9930738635628, - 1779.6478889427597, - 1788.3132394206564, - 1796.9890997412947, - 1805.6754445031333, - 1814.3722484575621, - 1823.0794865074322, - 1831.7971337056094, - 1840.5251652535437, - 1849.2635564998579, - 1858.0122829389563, - 1866.7713202096493, - 1875.5406440937966, - 1884.3202305149687, - 1893.110055537124, - 1901.9100953633042, - 1910.7203263343454, - 1919.5407249276057, - 1928.3712677557098, - 1937.2119315653083, - 1946.0626932358525, - 1954.923529778386, - 1963.79441833435, - 1972.6753361744036, - 1981.5662606972594, - 1990.467169428533, - 1999.3780400196069, - 2008.2988502465078, - 2017.2295780087982, - 2026.1702013284819, - 2035.1206983489212, - 2044.0810473337688, - 2053.0512266659125, - 2062.0312148464309, - 2071.0209904935646, - 2080.0205323416958, - 2089.0298192403443, - 2098.0488301531714, - 2107.0775441569995, - 2116.115940440839, - 2125.1639983049317, - 2134.2216971597995, - 2143.2890165253098, - 2152.3659360297484, - 2161.4524354089031, - 2170.5484945051617, - 2179.6540932666144, - 2188.7692117461711, - 2197.8938301006888, - 2207.0279285901042, - 2216.1714875765838, - 2225.324487523676, - 2234.4869089954782, - 2243.6587326558101, - 2252.8399392673982, - 2262.0305096910702, - 2271.2304248849537, - 2280.4396659036897, - 2289.6582138976523, - 2298.8860501121762, - 2308.1231558867926, - 2317.3695126544767, - 2326.6251019409005, - 2335.8899053636933, - 2345.1639046317132, - 2354.4470815443233, - 2363.7394179906792, - 2373.0408959490205, - 2382.3514974859731, - 2391.6712047558558, - 2400.9999999999991, - 2410.3378655460651, - 2419.6847838073813, - 2429.0407372822747, - 2438.4057085534191, - 2447.7796802871858, - 2457.1626352330004, - 2466.5545562227112, - 2475.9554261699564, - 2485.3652280695474, - 2494.7839449968492, - 2504.2115601071737, - 2513.6480566351788, - 2523.0934178942675, - 2532.5476272760025, - 2542.0106682495189, - 2551.482524360948, - 2560.9631792328441, - 2570.4526165636184, - 2579.9508201269791, - 2589.4577737713744, - 2598.9734614194458, - 2608.4978670674823, - 2618.0309747848837, - 2627.5727687136259, - 2637.1232330677353, - 2646.6823521327647, - 2656.2501102652768, - 2665.8264918923328, - 2675.4114815109842, - 2685.0050636877722, - 2694.6072230582295, - 2704.2179443263894, - 2713.8372122642972, - 2723.4650117115279, - 2733.1013275747096, - 2742.7461448270483, - 2752.3994485078601, - 2762.0612237221085, - 2771.7314556399419, - 2781.4101294962406, - 2791.0972305901655, - 2800.7927442847094, - 2810.4966560062589, - 2820.2089512441521, - 2829.9296155502466, - 2839.6586345384894, - 2849.3959938844923, - 2859.1416793251065, - 2868.8956766580086, - 2878.6579717412847, - 2888.4285504930212, - 2898.2073988908974, - 2907.9945029717837, - 2917.789848831344, - 2927.5934226236377, - 2937.4052105607311, - 2947.2251989123079, - 2957.0533740052865, - 2966.8897222234368, - 2976.734230007005, - 2986.5868838523397, - 2996.4476703115197, - 3006.3165759919889, - 3016.1935875561908, - 3026.0786917212095, - 3035.9718752584108, - 3045.8731249930906, - 3055.7824278041207, - 3065.6997706236039, - 3075.625140436528, - 3085.5585242804245, - 3095.4999092450298, - 3105.4492824719491, - 3115.4066311543256, - 3125.3719425365089, - 3135.3452039137287, - 3145.3264026317715, - 3155.3155260866592, - 3165.3125617243295, - 3175.3174970403229, - 3185.3303195794679, - 3195.35101693557, - 3205.3795767511078, - 3215.4159867169251, - 3225.460234571929, - 3235.5123081027928, - 3245.5721951436558, - 3255.63988357583, - 3265.7153613275095, - 3275.7986163734795, - 3285.8896367348289, - 3295.9884104786665, - 3306.0949257178395, - 3316.2091706106517, - 3326.331133360588, - 3336.4608022160378, - 3346.5981654700231, - 3356.7432114599264, - 3366.8959285672249, - 3377.0563052172211, - 3387.2243298787821, - 3397.3999910640764, - 3407.5832773283128, - 3417.7741772694862, - 3427.9726795281199, - 3438.1787727870123, - 3448.3924457709873, - 3458.6136872466445, - 3468.8424860221107, - 3479.0788309467976, - 3489.3227109111554, - 3499.5741148464344, - 3509.8330317244445, - 3520.0994505573185, - 3530.3733603972751, - 3540.6547503363886, - 3550.9436095063534, - 3561.239927078258, - 3571.5436922623535, - 3581.8548943078308, - 3592.1735225025936, - 3602.4995661730372, - 3612.8330146838275, - 3623.1738574376814, - 3633.5220838751502, - 3643.8776834744031, - 3654.2406457510142, - 3664.6109602577494, - 3674.9886165843564, - 3685.3736043573545, - 3695.7659132398294, - 3706.1655329312248, - 3716.5724531671399, - 3726.9866637191262, - 3737.4081543944876, - 3747.8369150360782, - 3758.2729355221072, - 3768.7162057659411, - 3779.1667157159077, - 3789.6244553551055, - 3800.0894147012082, - 3810.5615838062768, - 3821.0409527565694, - 3831.5275116723533, - 3842.0212507077194, - 3852.522160050396, - 3863.0302299215673, - 3873.5454505756893, - 3884.0678123003108, - 3894.5973054158922, - 3905.1339202756285, - 3915.6776472652732, - 3926.2284768029604, - 3936.7863993390338, - 3947.3514053558706, - 3957.9234853677135, - 3968.5026299204969, - 3979.0888295916798, - 3989.6820749900776, - 4000.2823567556948, - 4010.8896655595613, - 4021.5039921035655, - 4032.1253271202945, - 4042.7536613728694, - 4053.3889856547858, - 4064.0312907897551, - 4074.6805676315448, - 4085.3368070638221, - 4095.9999999999982, - 4106.6701373830711, - 4117.347210185475, - 4128.0312094089259, - 4138.722126084268, - 4149.4199512713267, - 4160.1246760587583, - 4170.8362915638982, - 4181.5547889326181, - 4192.2801593391769, - 4203.0123939860741, - 4213.7514841039101, - 4224.4974209512384, - 4235.2501958144258, - 4246.0098000075095, - 4256.7762248720574, - 4267.549461777031, - 4278.3295021186423, - 4289.1163373202198, - 4299.9099588320714, - 4310.7103581313495, - 4321.5175267219138, - 4332.3314561342004, - 4343.152137925088, - 4353.9795636777671, - 4364.8137250016052, - 4375.6546135320223, - 4386.5022209303588, - 4397.3565388837469, - 4408.2175591049827, - 4419.0852733324018, - 4429.9596733297531, - 4440.8407508860728, - 4451.7284978155603, - 4462.6229059574571, - 4473.5239671759227, - 4484.4316733599126, - 4495.3460164230582, - 4506.2669883035496, - 4517.1945809640119, - 4528.1287863913894, - 4539.069596596828, - 4550.0170036155587, - 4560.9709995067806, - 4571.931576353546, - 4582.898726262647, - 4593.8724413645004, - 4604.8527138130348, - 4615.8395357855816, - 4626.8328994827571, - 4637.8327971283588, - 4648.8392209692511, - 4659.8521632752563, - 4670.8716163390473, - 4681.8975724760394, - 4692.9300240242837, - 4703.9689633443595, - 4715.0143828192668, - 4726.0662748543255, - 4737.1246318770682, - 4748.1894463371373, - 4759.2607107061804, - 4770.3384174777493, - 4781.4225591671993, - 4792.5131283115852, - 4803.6101174695614, - 4814.7135192212854, - 4825.8233261683154, - 4836.9395309335096, - 4848.0621261609349, - 4859.1911045157631, - 4870.3264586841779, - 4881.4681813732768, - 4892.6162653109768, - 4903.7707032459193, - 4914.931487947375, - 4926.0986122051509, - 4937.2720688294967, - 4948.4518506510112, - 4959.637950520555, - 4970.8303613091521, - 4982.0290759079044, - 4993.2340872278974, - 5004.4453882001153, - 5015.6629717753467, - 5026.8868309241007, - 5038.1169586365131, - 5049.353347922266, - 5060.5959918104927, - 5071.8448833496996, - 5083.1000156076734, - 5094.3613816713996, - 5105.6289746469747, - 5116.9027876595246, - 5128.18281385312, - 5139.4690463906918, - 5150.7614784539473, - 5162.0601032432933, - 5173.3649139777472, - 5184.6759038948594, - 5195.9930662506322, - 5207.3163943194386, - 5218.6458813939435, - 5229.9815207850224, - 5241.3233058216847, - 5252.6712298509919, - 5264.025286237983, - 5275.3854683655954, - 5286.7517696345885, - 5298.1241834634639, - 5309.5027032883945, - 5320.887322563146, - 5332.2780347589978, - 5343.6748333646756, - 5355.0777118862716, - 5366.4866638471722, - 5377.901682787985, - 5389.3227622664635, - 5400.749895857437, - 5412.1830771527357, - 5423.622299761123, - 5435.067557308219, - 5446.5188434364318, - 5457.9761518048872, - 5469.4394760893592, - 5480.9088099821975, - 5492.3841471922606, - 5503.8654814448455, - 5515.3528064816201, - 5526.846116060552, - 5538.3454039558474, - 5549.8506639578736, - 5561.3618898731029, - 5572.8790755240361, - 5584.4022147491451, - 5595.9313014027975, - 5607.4663293552012, - 5619.0072924923297, - 5630.5541847158656, - 5642.1069999431284, - 5653.665732107017, - 5665.230375155943, - 5676.8009230537655, - 5688.3773697797333, - 5699.9597093284156, - 5711.5479357096474, - 5723.1420429484588, - 5734.7420250850209, - 5746.347876174581, - 5757.9595902874016, - 5769.5771615087006, - 5781.2005839385911, - 5792.8298516920213, - 5804.4649588987149, - 5816.1058997031105, - 5827.7526682643065, - 5839.4052587559972, - 5851.0636653664196, - 5862.7278822982908, - 5874.3979037687541, - 5886.0737240093204, - 5897.7553372658094, - 5909.4427377982956, - 5921.1359198810505, - 5932.8348778024874, - 5944.5396058651031, - 5956.2500983854261, - 5967.9663496939575, - 5979.6883541351208, - 5991.4161060672022, - 6003.1495998623004, - 6014.8888299062692, - 6026.6337905986684, - 6038.3844763527022, - 6050.1408815951781, - 6061.9030007664414, - 6073.6708283203316, - 6085.4443587241267, - 6097.2235864584891, - 6109.0085060174197, - 6120.7991119081998, - 6132.595398651345, - 6144.3973607805519, - 6156.2049928426459, - 6168.0182893975361, - 6179.8372450181578, - 6191.6618542904307, - 6203.4921118132024, - 6215.3280121982016, - 6227.1695500699925, - 6239.0167200659189, - 6250.8695168360628, - 6262.7279350431891, - 6274.5919693627056, - 6286.4616144826068, - 6298.3368651034316, - 6310.2177159382172, - 6322.1041617124456, - 6333.9961971640032, - 6345.8938170431311, - 6357.7970161123785, - 6369.7057891465583, - 6381.6201309327007, - 6393.5400362700075, - 6405.4654999698032, - 6417.3965168554978, - 6429.3330817625329, - 6441.2751895383453, - 6453.2228350423138, - 6465.176013145724, - 6477.134718731716, - 6489.0989466952469, - 6501.0686919430445, - 6513.0439493935628, - 6525.0247139769417, - 6537.010980634961, - 6549.002744321001, - 6560.9999999999973, - 6573.0027426483985, - 6585.0109672541284, - 6597.0246688165371, - 6609.0438423463656, - 6621.0684828657004, - 6633.0985854079354, - 6645.134145017727, - 6657.1751567509573, - 6669.2216156746908, - 6681.2735168671343, - 6693.3308554176001, - 6705.3936264264594, - 6717.461825005108, - 6729.535446275926, - 6741.6144853722335, - 6753.6989374382601, - 6765.7887976290967, - 6777.8840611106634, - 6789.9847230596661, - 6802.0907786635626, - 6814.2022231205201, - 6826.3190516393797, - 6838.4412594396181, - 6850.5688417513074, - 6862.701793815083, - 6874.840110882099, - 6886.9837882139991, - 6899.1328210828724, - 6911.2872047712199, - 6923.4469345719199, - 6935.6120057881863, - 6947.7824137335365, - 6959.9581537317536, - 6972.1392211168532, - 6984.3256112330409, - 6996.5173194346862, - 7008.7143410862773, - 7020.9166715623942, - 7033.1243062476678, - 7045.3372405367481, - 7057.5554698342685, - 7069.7789895548103, - 7082.0077951228714, - 7094.2418819728273, - 7106.4812455489018, - 7118.7258813051285, - 7130.9757847053224, - 7143.2309512230404, - 7155.4913763415516, - 7167.7570555538041, - 7180.0279843623894, - 7192.3041582795131, - 7204.5855728269571, - 7216.8722235360519, - 7229.1641059476406, - 7241.4612156120484, - 7253.7635480890503, - 7266.0710989478375, - 7278.3838637669869, - 7290.7018381344296, - 7303.0250176474174, - 7315.3533979124932, - 7327.6869745454596, - 7340.0257431713462, - 7352.3696994243801, - 7364.7188389479543, - 7377.0731573945968, - 7389.4326504259407, - 7401.7973137126937, - 7414.1671429346061, - 7426.5421337804428, - 7438.922281947951, - 7451.3075831438346, - 7463.6980330837177, - 7476.0936274921214, - 7488.4943621024304, - 7500.9002326568652, - 7513.3112349064522, - 7525.7273646109943, - 7538.1486175390446, - 7550.5749894678729, - 7563.0064761834419, - 7575.4430734803736, - 7587.8847771619248, - 7600.3315830399597, - 7612.7834869349153, - 7625.24048467578, - 7637.7025721000637, - 7650.1697450537677, - 7662.6419993913596, - 7675.1193309757446, - 7687.6017356782404, - 7700.0892093785433, - 7712.5817479647112, - 7725.079347333125, - 7737.5820033884729, - 7750.0897120437139, - 7762.6024692200581, - 7775.1202708469355, - 7787.6431128619733, - 7800.1709912109645, - 7812.7039018478481, - 7825.2418407346768, - 7837.7848038415968, - 7850.3327871468155, - 7862.8857866365806, - 7875.4437983051539, - 7888.006818154784, - 7900.5748421956796, - 7913.1478664459901, - 7925.725886931772, - 7938.3088996869719, - 7950.8969007533951, - 7963.4898861806851, - 7976.0878520262959, - 7988.6907943554688, - 8001.2987092412086, - 8013.911592764257, - 8026.5294410130691, - 8039.1522500837891, - 8051.7800160802271, - 8064.412735113835, - 8077.0504033036796, - 8089.6930167764222, - 8102.3405716662946, - 8114.9930641150731, - 8127.6504902720571, - 8140.3128462940449, - 8152.9801283453098, - 8165.6523325975786, - 8178.3294552300049, - 8191.0114924291529, - 8203.6984403889655, - 8216.3902953107463, - 8229.0870534031419, - 8241.7887108821069, - 8254.4952639708936, - 8267.2067089000211, - 8279.9230419072574, - 8292.6442592375952, - 8305.3703571432306, - 8318.101331883543, - 8330.8371797250657, - 8343.577896941475, - 8356.3234798135582, - 8369.0739246291978, - 8381.8292276833508, - 8394.5893852780209, - 8407.3543937222421, - 8420.1242493320569, - 8432.8989484304948, - 8445.6784873475499, - 8458.4628624201578, - 8471.2520699921806, - 8484.0461064143838, - 8496.8449680444082, - 8509.6486512467636, - 8522.4571523927953, - 8535.270467860666, - 8548.0885940353437, - 8560.9115273085663, - 8573.7392640788403, - 8586.5718007514006, - 8599.4091337382069, - 8612.2512594579148, - 8625.0981743358552, - 8637.9498748040205, - 8650.8063573010386, - 8663.6676182721567, - 8676.533654169225, - 8689.4044614506638, - 8702.2800365814601, - 8715.1603760331418, - 8728.0454762837508, - 8740.9353338178389, - 8753.8299451264356, - 8766.7293067070332, - 8779.6334150635721, - 8792.5422667064158, - 8805.4558581523324, - 8818.3741859244819, - 8831.2972465523908, - 8844.2250365719356, - 8857.1575525253265, - 8870.0947909610859, - 8883.0367484340295, - 8895.9834215052524, - 8908.934806742107, - 8921.8909007181846, - 8934.8517000132997, - 8947.817201213471, - 8960.7874009109, - 8973.7622957039603, - 8986.7418821971733, - 8999.7261570011924, - 9012.7151167327884, - 9025.7087580148236, - 9038.7070774762469, - 9051.7100717520643, - 9064.7177374833282, - 9077.7300713171153, - 9090.7470699065179, - 9103.7687299106146, - 9116.7950479944648, - 9129.8260208290812, - 9142.8616450914233, - 9155.9019174643727, - 9168.9468346367157, - 9181.9963933031358, - 9195.0505901641845, - 9208.1094219262741, - 9221.1728853016557, - 9234.240977008405, - 9247.3136937704076, - 9260.3910323173386, - 9273.472989384647, - 9286.5595617135423, - 9299.6507460509747, - 9312.7465391496207, - 9325.8469377678684, - 9338.9519386698012, - 9352.0615386251757, - 9365.1757344094131, - 9378.2945228035842, - 9391.4179005943843, - 9404.5458645741273, - 9417.6784115407263, - 9430.8155382976747, - 9443.9572416540359, - 9457.1035184244265, - 9470.2543654290002, - 9483.4097794934296, - 9496.5697574488931, - 9509.7342961320664, - 9522.9033923850911, - 9536.0770430555804, - 9549.2552449965824, - 9562.4379950665825, - 9575.6252901294793, - 9588.8171270545736, - 9602.0135027165488, - 9615.2144139954635, - 9628.4198577767274, - 9641.629830951093, - 9654.844330414644, - 9668.0633530687719, - 9681.286895820167, - 9694.5149555808002, - 9707.7475292679192, - 9720.9846138040157, - 9734.2262061168276, - 9747.4723031393187, - 9760.7229018096641, - 9773.9779990712323, - 9787.2375918725811, - 9800.5016771674327, - 9813.7702519146696, - 9827.0433130783094, - 9840.3208576275028, - 9853.602882536512, - 9866.8893847846994, - 9880.1803613565116, - 9893.4758092414686, - 9906.7757254341523, - 9920.0801069341851, - 9933.3889507462245, - 9946.7022538799429, - 9960.0200133500221, - 9973.3422261761298, - 9986.6688893829159, - 9999.9999999999945, - 10013.335555061929, - 10026.675551608221, - 10040.019986683301, - 10053.368857336509, - 10066.722160622081, - 10080.079893599144, - 10093.442053331697, - 10106.808636888598, - 10120.179641343551, - 10133.555063775095, - 10146.934901266595, - 10160.31915090622, - 10173.707809786936, - 10187.100875006496, - 10200.498343667417, - 10213.900212876984, - 10227.306479747222, - 10240.717141394889, - 10254.132194941467, - 10267.551637513146, - 10280.975466240814, - 10294.40367826004, - 10307.836270711066, - 10321.273240738796, - 10334.71458549278, - 10348.160302127204, - 10361.610387800878, - 10375.064839677221, - 10388.523654924258, - 10401.986830714593, - 10415.454364225412, - 10428.926252638465, - 10442.402493140049, - 10455.883082921007, - 10469.368019176709, - 10482.85729910704, - 10496.350919916393, - 10509.848878813653, - 10523.351173012188, - 10536.857799729838, - 10550.3687561889, - 10563.884039616123, - 10577.403647242685, - 10590.927576304197, - 10604.455824040679, - 10617.988387696556, - 10631.525264520642, - 10645.066451766135, - 10658.611946690598, - 10672.161746555956, - 10685.715848628475, - 10699.274250178762, - 10712.836948481747, - 10726.403940816675, - 10739.975224467091, - 10753.550796720834, - 10767.130654870027, - 10780.714796211059, - 10794.303218044579, - 10807.895917675487, - 10821.492892412922, - 10835.094139570248, - 10848.699656465047, - 10862.309440419107, - 10875.923488758415, - 10889.541798813138, - 10903.16436791762, - 10916.791193410372, - 10930.422272634056, - 10944.05760293548, - 10957.697181665582, - 10971.341006179427, - 10984.98907383619, - 10998.641381999149, - 11012.297928035676, - 11025.958709317223, - 11039.623723219316, - 11053.292967121541, - 11066.966438407539, - 11080.64413446499, - 11094.326052685608, - 11108.012190465128, - 11121.702545203296, - 11135.397114303863, - 11149.095895174571, - 11162.798885227143, - 11176.506081877278, - 11190.217482544635, - 11203.933084652828, - 11217.652885629415, - 11231.376882905886, - 11245.105073917659, - 11258.837456104062, - 11272.574026908333, - 11286.314783777601, - 11300.059724162888, - 11313.808845519083, - 11327.562145304952, - 11341.319620983111, - 11355.081270020033, - 11368.847089886023, - 11382.617078055218, - 11396.391232005579, - 11410.169549218874, - 11423.952027180676, - 11437.738663380349, - 11451.529455311042, - 11465.324400469679, - 11479.123496356951, - 11492.926740477304, - 11506.734130338931, - 11520.545663453764, - 11534.361337337466, - 11548.181149509423, - 11562.005097492724, - 11575.83317881417, - 11589.665391004253, - 11603.501731597149, - 11617.342198130715, - 11631.186788146468, - 11645.035499189589, - 11658.888328808911, - 11672.745274556904, - 11686.606333989675, - 11700.471504666955, - 11714.340784152086, - 11728.214170012021, - 11742.091659817312, - 11755.973251142101, - 11769.858941564111, - 11783.748728664636, - 11797.642610028539, - 11811.540583244237, - 11825.442645903697, - 11839.34879560242, - 11853.259029939445, - 11867.173346517333, - 11881.091742942155, - 11895.014216823492, - 11908.940765774427, - 11922.871387411526, - 11936.806079354839, - 11950.744839227897, - 11964.687664657684, - 11978.634553274653, - 11992.585502712702, - 12006.540510609168, - 12020.499574604828, - 12034.462692343877, - 12048.429861473938, - 12062.401079646032, - 12076.376344514589, - 12090.355653737433, - 12104.339004975769, - 12118.326395894188, - 12132.317824160644, - 12146.313287446457, - 12160.312783426305, - 12174.316309778205, - 12188.323864183525, - 12202.335444326955, - 12216.351047896511, - 12230.370672583531, - 12244.394316082657, - 12258.421976091831, - 12272.453650312296, - 12286.489336448574, - 12300.529032208471, - 12314.572735303058, - 12328.620443446678, - 12342.672154356922, - 12356.727865754638, - 12370.787575363909, - 12384.851280912055, - 12398.918980129623, - 12412.990670750381, - 12427.066350511306, - 12441.146017152583, - 12455.229668417589, - 12469.317302052901, - 12483.40891580827, - 12497.50450743663, - 12511.604074694078, - 12525.707615339878, - 12539.815127136444, - 12553.926607849342, - 12568.042055247275, - 12582.161467102082, - 12596.284841188726, - 12610.41217528529, - 12624.543467172971, - 12638.678714636069, - 12652.817915461985, - 12666.961067441209, - 12681.108168367316, - 12695.259216036962, - 12709.414208249869, - 12723.573142808827, - 12737.736017519681, - 12751.902830191326, - 12766.073578635704, - 12780.248260667788, - 12794.426874105588, - 12808.609416770132, - 12822.795886485468, - 12836.986281078653, - 12851.180598379744, - 12865.378836221802, - 12879.580992440871, - 12893.787064875984, - 12907.997051369144, - 12922.210949765335, - 12936.428757912496, - 12950.650473661524, - 12964.876094866273, - 12979.105619383534, - 12993.339045073039, - 13007.576369797454, - 13021.817591422368, - 13036.062707816285, - 13050.311716850629, - 13064.564616399723, - 13078.821404340792, - 13093.082078553954, - 13107.346636922217, - 13121.615077331464, - 13135.887397670458, - 13150.163595830827, - 13164.44366970706, - 13178.727617196502, - 13193.015436199352, - 13207.307124618648, - 13221.602680360265, - 13235.902101332911, - 13250.205385448118, - 13264.512530620239, - 13278.823534766434, - 13293.138395806676, - 13307.457111663734, - 13321.779680263176, - 13336.106099533356, - 13350.436367405409, - 13364.77048181325, - 13379.108440693562, - 13393.450241985796, - 13407.795883632158, - 13422.145363577607, - 13436.498679769853, - 13450.855830159346, - 13465.216812699266, - 13479.581625345529, - 13493.950266056772, - 13508.32273279435, - 13522.699023522329, - 13537.079136207483, - 13551.463068819286, - 13565.850819329906, - 13580.2423857142, - 13594.63776594971, - 13609.036958016657, - 13623.439959897927, - 13637.846769579081, - 13652.257385048335, - 13666.67180429656, - 13681.090025317284, - 13695.512046106669, - 13709.937864663521, - 13724.367478989278, - 13738.800887088004, - 13753.238086966385, - 13767.679076633727, - 13782.123854101939, - 13796.572417385545, - 13811.024764501659, - 13825.480893469998, - 13839.94080231286, - 13854.404489055134, - 13868.871951724283, - 13883.34318835034, - 13897.818196965914, - 13912.296975606168, - 13926.779522308825, - 13941.26583511416, - 13955.755912064991, - 13970.249751206682, - 13984.747350587126, - 13999.248708256751, - 14013.753822268511, - 14028.262690677873, - 14042.775311542828, - 14057.291682923867, - 14071.811802883994, - 14086.335669488704, - 14100.863280805994, - 14115.394634906341, - 14129.92972986271, - 14144.468563750548, - 14159.01113464777, - 14173.55744063476, - 14188.107479794369, - 14202.661250211901, - 14217.218749975118, - 14231.779977174227, - 14246.344929901879, - 14260.913606253163, - 14275.486004325601, - 14290.062122219146, - 14304.641958036171, - 14319.225509881464, - 14333.812775862236, - 14348.403754088098, - 14362.998442671067, - 14377.59683972556, - 14392.198943368388, - 14406.804751718748, - 14421.414262898223, - 14436.027475030774, - 14450.64438624274, - 14465.264994662828, - 14479.889298422106, - 14494.517295654005, - 14509.148984494313, - 14523.784363081166, - 14538.423429555049, - 14553.066182058781, - 14567.712618737527, - 14582.362737738777, - 14597.016537212348, - 14611.674015310382, - 14626.33517018734, - 14640.999999999993, - 14655.668502907418, - 14670.340677071003, - 14685.016520654426, - 14699.696031823671, - 14714.379208746999, - 14729.066049594967, - 14743.756552540408, - 14758.45071575843, - 14773.148537426418, - 14787.850015724018, - 14802.555148833142, - 14817.263934937961, - 14831.976372224897, - 14846.692458882624, - 14861.41219310206, - 14876.135573076363, - 14890.862597000923, - 14905.593263073371, - 14920.327569493558, - 14935.065514463557, - 14949.807096187662, - 14964.552312872382, - 14979.301162726431, - 14994.053643960735, - 15008.809754788414, - 15023.569493424788, - 15038.332858087369, - 15053.099846995858, - 15067.870458372134, - 15082.644690440264, - 15097.422541426484, - 15112.204009559202, - 15126.989093068994, - 15141.777790188597, - 15156.570099152905, - 15171.366018198967, - 15186.165545565986, - 15200.968679495301, - 15215.775418230402, - 15230.585760016909, - 15245.399703102579, - 15260.217245737298, - 15275.038386173073, - 15289.863122664035, - 15304.691453466432, - 15319.523376838621, - 15334.358891041069, - 15349.197994336346, - 15364.040684989128, - 15378.886961266177, - 15393.736821436356, - 15408.590263770609, - 15423.447286541972, - 15438.307888025554, - 15453.172066498542, - 15468.039820240196, - 15482.91114753184, - 15497.786046656869, - 15512.664515900733, - 15527.546553550939, - 15542.432157897045, - 15557.32132723066, - 15572.214059845435, - 15587.110354037064, - 15602.010208103273, - 15616.913620343823, - 15631.820589060506, - 15646.731112557136, - 15661.645189139546, - 15676.562817115593, - 15691.483994795139, - 15706.408720490062, - 15721.336992514242, - 15736.268809183561, - 15751.204168815901, - 15766.143069731135, - 15781.085510251132, - 15796.03148869974, - 15810.981003402798, - 15825.934052688119, - 15840.890634885489, - 15855.850748326673, - 15870.814391345401, - 15885.781562277361, - 15900.752259460214, - 15915.726481233565, - 15930.704225938984, - 15945.685491919978, - 15960.670277522009, - 15975.658581092481, - 15990.65040098073, - 16005.645735538035, - 16020.644583117599, - 16035.646942074556, - 16050.652810765967, - 16065.662187550806, - 16080.675070789974, - 16095.691458846273, - 16110.711350084424, - 16125.734742871053, - 16140.761635574685, - 16155.792026565747, - 16170.825914216561, - 16185.863296901338, - 16200.904172996183, - 16215.948540879079, - 16230.996398929899, - 16246.047745530386, - 16261.102579064163, - 16276.160897916721, - 16291.22270047542, - 16306.287985129484, - 16321.356750269995, - 16336.428994289896, - 16351.504715583982, - 16366.5839125489, - 16381.666583583141, - 16396.752727087041, - 16411.842341462776, - 16426.935425114363, - 16442.031976447644, - 16457.131993870298, - 16472.235475791829, - 16487.342420623561, - 16502.452826778641, - 16517.566692672033, - 16532.684016720516, - 16547.804797342676, - 16562.929032958902, - 16578.056721991394, - 16593.18786286415, - 16608.322454002962, - 16623.460493835417, - 16638.601980790896, - 16653.746913300558, - 16668.895289797354, - 16684.047108716015, - 16699.202368493046, - 16714.361067566726, - 16729.523204377107, - 16744.688777366009, - 16759.857784977012, - 16775.030225655464, - 16790.206097848466, - 16805.385400004874, - 16820.568130575302, - 16835.754288012104, - 16850.943870769381, - 16866.136877302983, - 16881.333306070494, - 16896.53315553123, - 16911.736424146249, - 16926.943110378332, - 16942.153212691992, - 16957.366729553454, - 16972.583659430682, - 16987.804000793338, - 17003.027752112816, - 17018.254911862205, - 17033.485478516312, - 17048.719450551645, - 17063.956826446421, - 17079.197604680547, - 17094.44178373563, - 17109.689362094967, - 17124.940338243552, - 17140.194710668064, - 17155.452477856852, - 17170.713638299967, - 17185.978190489128, - 17201.246132917724, - 17216.517464080825, - 17231.792182475165, - 17247.070286599141, - 17262.351774952826, - 17277.636646037936, - 17292.924898357855, - 17308.216530417623, - 17323.511540723921, - 17338.809927785089, - 17354.111690111105, - 17369.416826213594, - 17384.725334605821, - 17400.037213802683, - 17415.352462320716, - 17430.67107867809, - 17445.993061394587, - 17461.318408991636, - 17476.647119992274, - 17491.979192921168, - 17507.314626304586, - 17522.653418670423, - 17537.995568548187, - 17553.341074468986, - 17568.689934965536, - 17584.042148572156, - 17599.397713824768, - 17614.75662926089, - 17630.118893419625, - 17645.484504841683, - 17660.853462069354, - 17676.225763646511, - 17691.601408118619, - 17706.980394032718, - 17722.362719937424, - 17737.748384382936, - 17753.137385921014, - 17768.529723104999, - 17783.92539448979, - 17799.324398631856, - 17814.726734089225, - 17830.13239942148, - 17845.541393189767, - 17860.95371395678, - 17876.369360286772, - 17891.788330745527, - 17907.210623900395, - 17922.636238320254, - 17938.065172575527, - 17953.497425238176, - 17968.932994881692, - 17984.371880081104, - 17999.814079412972, - 18015.259591455371, - 18030.708414787914, - 18046.160547991731, - 18061.615989649465, - 18077.074738345284, - 18092.536792664861, - 18108.002151195393, - 18123.470812525571, - 18138.942775245599, - 18154.418037947191, - 18169.896599223546, - 18185.37845766938, - 18200.863611880886, - 18216.352060455767, - 18231.843801993204, - 18247.338835093873, - 18262.837158359936, - 18278.338770395032, - 18293.84366980429, - 18309.351855194309, - 18324.863325173166, - 18340.378078350412, - 18355.896113337069, - 18371.417428745623, - 18386.942023190033, - 18402.469895285718, - 18418.00104364955, - 18433.53546689987, - 18449.073163656474, - 18464.614132540602, - 18480.158372174956, - 18495.705881183676, - 18511.256658192357, - 18526.810701828035, - 18542.368010719183, - 18557.928583495715, - 18573.492418788985, - 18589.059515231773, - 18604.629871458303, - 18620.203486104212, - 18635.78035780658, - 18651.360485203899, - 18666.943866936086, - 18682.53050164448, - 18698.120387971841, - 18713.713524562332, - 18729.30991006154, - 18744.909543116457, - 18760.512422375479, - 18776.118546488418, - 18791.727914106479, - 18807.340523882274, - 18822.95637446981, - 18838.575464524489, - 18854.197792703111, - 18869.823357663863, - 18885.452158066328, - 18901.08419257147, - 18916.719459841639, - 18932.357958540564, - 18947.999687333362, - 18963.644644886521, - 18979.292829867907, - 18994.944240946759, - 19010.598876793687, - 19026.256736080668, - 19041.917817481048, - 19057.582119669532, - 19073.2496413222, - 19088.920381116473, - 19104.594337731145, - 19120.271509846356, - 19135.951896143604, - 19151.635495305738, - 19167.322306016948, - 19183.012326962784, - 19198.705556830122, - 19214.401994307198, - 19230.101638083579, - 19245.804486850167, - 19261.510539299208, - 19277.219794124274, - 19292.932250020265, - 19308.647905683421, - 19324.366759811302, - 19340.088811102793, - 19355.8140582581, - 19371.542499978754, - 19387.2741349676, - 19403.008961928797, - 19418.746979567823, - 19434.488186591469, - 19450.232581707827, - 19465.980163626304, - 19481.730931057613, - 19497.484882713761, - 19513.242017308068, - 19529.002333555141, - 19544.765830170898, - 19560.532505872539, - 19576.302359378566, - 19592.075389408761, - 19607.851594684209, - 19623.630973927269, - 19639.41352586159, - 19655.199249212103, - 19670.988142705017, - 19686.780205067826, - 19702.575435029288, - 19718.373831319448, - 19734.175392669615, - 19749.980117812371, - 19765.788005481569, - 19781.599054412323, - 19797.413263341008, - 19813.230631005274, - 19829.051156144014, - 19844.874837497395, - 19860.701673806827, - 19876.531663814985, - 19892.364806265789, - 19908.201099904403, - 19924.040543477258, - 19939.883135732012, - 19955.728875417579, - 19971.577761284105, - 19987.429792082985, - 20003.284966566847, - 20019.14328348956, - 20035.004741606219, - 20050.869339673161, - 20066.737076447946, - 20082.607950689362, - 20098.481961157428, - 20114.359106613385, - 20130.239385819699, - 20146.122797540058, - 20162.009340539353, - 20177.899013583716, - 20193.791815440476, - 20209.687744878182, - 20225.586800666591, - 20241.488981576669, - 20257.394286380597, - 20273.302713851754, - 20289.214262764715, - 20305.128931895277, - 20321.046720020415, - 20336.967625918318, - 20352.891648368361, - 20368.818786151114, - 20384.749038048347, - 20400.682402843009, - 20416.618879319249, - 20432.558466262391, - 20448.501162458953, - 20464.446966696629, - 20480.395877764302, - 20496.347894452025, - 20512.303015551031, - 20528.261239853735, - 20544.22256615372, - 20560.186993245738, - 20576.15451992572, - 20592.125144990758, - 20608.098867239107, - 20624.075685470198, - 20640.055598484618, - 20656.038605084115, - 20672.024704071595, - 20688.013894251126, - 20704.006174427926, - 20720.001543408373, - 20735.999999999989, - 20752.001543011454, - 20768.006171252597, - 20784.013883534382, - 20800.024678668931, - 20816.038555469506, - 20832.055512750507, - 20848.075549327474, - 20864.098664017085, - 20880.124855637161, - 20896.154123006647, - 20912.186464945626, - 20928.221880275312, - 20944.260367818049, - 20960.301926397311, - 20976.346554837684, - 20992.394251964895, - 21008.445016605787, - 21024.498847588318, - 21040.555743741574, - 21056.615703895754, - 21072.678726882168, - 21088.744811533252, - 21104.813956682538, - 21120.886161164683, - 21136.961423815443, - 21153.039743471683, - 21169.121118971379, - 21185.205549153605, - 21201.293032858535, - 21217.383568927453, - 21233.477156202731, - 21249.573793527841, - 21265.673479747358, - 21281.776213706937, - 21297.881994253334, - 21313.990820234398, - 21330.102690499054, - 21346.21760389733, - 21362.335559280327, - 21378.456555500241, - 21394.580591410333, - 21410.707665864964, - 21426.83777771956, - 21442.970925830628, - 21459.107109055756, - 21475.246326253604, - 21491.388576283895, - 21507.533858007431, - 21523.682170286087, - 21539.833511982797, - 21555.987881961566, - 21572.145279087465, - 21588.305702226615, - 21604.469150246216, - 21620.635622014521, - 21636.805116400832, - 21652.977632275521, - 21669.153168510009, - 21685.331723976764, - 21701.513297549318, - 21717.697888102244, - 21733.885494511167, - 21750.076115652759, - 21766.269750404736, - 21782.466397645861, - 21798.666056255934, - 21814.868725115801, - 21831.074403107345, - 21847.283089113484, - 21863.494782018177, - 21879.709480706417, - 21895.927184064229, - 21912.147890978667, - 21928.371600337818, - 21944.598311030797, - 21960.828021947746, - 21977.060731979829, - 21993.296440019243, - 22009.535144959198, - 22025.77684569393, - 22042.021541118691, - 22058.269230129757, - 22074.519911624411, - 22090.773584500959, - 22107.030247658717, - 22123.289899998013, - 22139.552540420187, - 22155.818167827587, - 22172.086781123569, - 22188.358379212495, - 22204.632960999726, - 22220.910525391639, - 22237.191071295601, - 22253.474597619981, - 22269.761103274148, - 22286.050587168469, - 22302.343048214312, - 22318.638485324027, - 22334.936897410968, - 22351.23828338947, - 22367.542642174871, - 22383.849972683485, - 22400.160273832618, - 22416.473544540564, - 22432.789783726603, - 22449.108990310986, - 22465.431163214958, - 22481.75630136074, - 22498.084403671528, - 22514.415469071497, - 22530.749496485802, - 22547.086484840562, - 22563.426433062879, - 22579.769340080824, - 22596.115204823436, - 22612.464026220721, - 22628.815803203655, - 22645.170534704179, - 22661.5282196552, - 22677.888856990587, - 22694.252445645168, - 22710.618984554734, - 22726.988472656034, - 22743.360908886778, - 22759.736292185622, - 22776.114621492186, - 22792.495895747044, - 22808.880113891719, - 22825.267274868678, - 22841.657377621348, - 22858.050421094096, - 22874.446404232243, - 22890.845325982053, - 22907.247185290722, - 22923.651981106406, - 22940.059712378195, - 22956.470378056114, - 22972.883977091129, - 22989.300508435153, - 23005.719971041017, - 23022.142363862498, - 23038.567685854305, - 23054.995935972078, - 23071.427113172387, - 23087.86121641273, - 23104.298244651531, - 23120.738196848146, - 23137.181071962848, - 23153.626868956846, - 23170.075586792263, - 23186.527224432142, - 23202.981780840448, - 23219.439254982066, - 23235.899645822796, - 23252.362952329357, - 23268.829173469378, - 23285.298308211408, - 23301.770355524899, - 23318.245314380223, - 23334.723183748658, - 23351.203962602387, - 23367.687649914504, - 23384.174244659007, - 23400.663745810798, - 23417.15615234568, - 23433.651463240367, - 23450.149677472462, - 23466.650794020472, - 23483.154811863806, - 23499.661729982763, - 23516.171547358543, - 23532.684262973235, - 23549.199875809823, - 23565.718384852185, - 23582.239789085092, - 23598.764087494197, - 23615.291279066041, - 23631.821362788058, - 23648.354337648565, - 23664.890202636761, - 23681.428956742733, - 23697.970598957443, - 23714.515128272738, - 23731.062543681343, - 23747.612844176863, - 23764.166028753778, - 23780.72209640744, - 23797.281046134085, - 23813.842876930816, - 23830.407587795606, - 23846.975177727301, - 23863.545645725622, - 23880.11899079115, - 23896.695211925336, - 23913.274308130498, - 23929.856278409821, - 23946.441121767348, - 23963.028837207989, - 23979.619423737513, - 23996.212880362549, - 24012.809206090584, - 24029.408399929966, - 24046.010460889898, - 24062.615387980433, - 24079.223180212492, - 24095.833836597827, - 24112.447356149063, - 24129.063737879667, - 24145.682980803951, - 24162.305083937081, - 24178.930046295067, - 24195.557866894767, - 24212.188544753884, - 24228.822078890964, - 24245.458468325389, - 24262.097712077397, - 24278.739809168052, - 24295.384758619261, - 24312.032559453768, - 24328.683210695162, - 24345.336711367858, - 24361.993060497109, - 24378.652257108995, - 24395.314300230442, - 24411.979188889192, - 24428.646922113825, - 24445.317498933746, - 24461.990918379193, - 24478.667179481225, - 24495.346281271726, - 24512.028222783407, - 24528.713003049801, - 24545.400621105266, - 24562.091075984976, - 24578.784366724925, - 24595.480492361927, - 24612.179451933614, - 24628.881244478438, - 24645.585869035654, - 24662.293324645343, - 24679.003610348394, - 24695.716725186514, - 24712.432668202211, - 24729.151438438807, - 24745.873034940436, - 24762.597456752032, - 24779.324702919344, - 24796.054772488926, - 24812.787664508123, - 24829.5233780251, - 24846.261912088819, - 24863.003265749034, - 24879.747438056307, - 24896.494428062004, - 24913.244234818278, - 24929.996857378079, - 24946.752294795166, - 24963.510546124078, - 24980.271610420157, - 24997.035486739525, - 25013.802174139113, - 25030.571671676629, - 25047.343978410572, - 25064.119093400237, - 25080.897015705697, - 25097.677744387816, - 25114.461278508239, - 25131.2476171294, - 25148.036759314517, - 25164.828704127583, - 25181.623450633375, - 25198.42099789745, - 25215.221344986145, - 25232.024490966574, - 25248.830434906627, - 25265.639175874974, - 25282.450712941049, - 25299.265045175071, - 25316.082171648024, - 25332.902091431668, - 25349.724803598532, - 25366.550307221914, - 25383.378601375884, - 25400.209685135269, - 25417.043557575678, - 25433.880217773472, - 25450.719664805783, - 25467.561897750507, - 25484.406915686297, - 25501.254717692573, - 25518.105302849512, - 25534.958670238051, - 25551.814818939893, - 25568.67374803748, - 25585.535456614027, - 25602.399943753502, - 25619.267208540619, - 25636.137250060852, - 25653.010067400432, - 25669.885659646327, - 25686.76402588627, - 25703.645165208734, - 25720.529076702944, - 25737.415759458876, - 25754.305212567244, - 25771.197435119517, - 25788.092426207899, - 25804.990184925344, - 25821.890710365547, - 25838.794001622944, - 25855.700057792714, - 25872.608877970775, - 25889.520461253778, - 25906.434806739118, - 25923.351913524923, - 25940.271780710063, - 25957.194407394138, - 25974.11979267748, - 25991.047935661154, - 26007.978835446964, - 26024.912491137442, - 26041.848901835841, - 26058.788066646157, - 26075.729984673108, - 26092.674655022136, - 26109.622076799409, - 26126.572249111829, - 26143.525171067016, - 26160.480841773315, - 26177.43926033979, - 26194.400425876229, - 26211.364337493149, - 26228.330994301767, - 26245.30039541404, - 26262.272539942627, - 26279.247427000919, - 26296.225055703002, - 26313.205425163702, - 26330.188534498539, - 26347.174382823756, - 26364.162969256304, - 26381.154292913852, - 26398.148352914774, - 26415.145148378149, - 26432.144678423778, - 26449.146942172156, - 26466.151938744493, - 26483.159667262702, - 26500.170126849403, - 26517.183316627921, - 26534.199235722277, - 26551.217883257199, - 26568.239258358124, - 26585.263360151173, - 26602.290187763181, - 26619.319740321676, - 26636.352016954883, - 26653.387016791727, - 26670.424738961825, - 26687.465182595493, - 26704.508346823739, - 26721.554230778267, - 26738.602833591467, - 26755.65415439643, - 26772.708192326929, - 26789.764946517433, - 26806.824416103096, - 26823.886600219761, - 26840.95149800396, - 26858.019108592915, - 26875.089431124517, - 26892.162464737365, - 26909.238208570721, - 26926.316661764544, - 26943.397823459472, - 26960.481692796813, - 26977.568268918571, - 26994.657550967422, - 27011.749538086722, - 27028.844229420498, - 27045.941624113464, - 27063.041721311005, - 27080.144520159181, - 27097.250019804727, - 27114.35821939505, - 27131.469118078236, - 27148.582715003027, - 27165.699009318858, - 27182.818000175819, - 27199.939686724665, - 27217.064068116837, - 27234.191143504428, - 27251.320912040203, - 27268.453372877593, - 27285.588525170693, - 27302.726368074269, - 27319.866900743735, - 27337.010122335181, - 27354.156032005358, - 27371.304628911668, - 27388.455912212183, - 27405.609881065626, - 27422.766534631384, - 27439.925872069507, - 27457.087892540683, - 27474.252595206275, - 27491.419979228293, - 27508.5900437694, - 27525.762787992917, - 27542.93821106281, - 27560.116312143706, - 27577.297090400876, - 27594.480545000242, - 27611.666675108383, - 27628.855479892518, - 27646.046958520514, - 27663.241110160889, - 27680.437933982801, - 27697.637429156068, - 27714.839594851132, - 27732.04443023909, - 27749.251934491687, - 27766.462106781299, - 27783.674946280949, - 27800.890452164302, - 27818.108623605654, - 27835.329459779954, - 27852.55295986278, - 27869.779123030345, - 27887.007948459504, - 27904.239435327745, - 27921.473582813196, - 27938.710390094613, - 27955.949856351392, - 27973.19198076355, - 27990.436762511745, - 28007.684200777272, - 28024.934294742041, - 28042.187043588601, - 28059.442446500128, - 28076.700502660427, - 28093.961211253929, - 28111.224571465693, - 28128.490582481401, - 28145.759243487362, - 28163.030553670509, - 28180.304512218394, - 28197.581118319198, - 28214.860371161725, - 28232.14226993539, - 28249.42681383024, - 28266.71400203693, - 28284.003833746745, - 28301.296308151585, - 28318.591424443959, - 28335.889181817001, - 28353.189579464462, - 28370.492616580705, - 28387.798292360701, - 28405.106606000048, - 28422.417556694945, - 28439.731143642206, - 28457.047366039264, - 28474.366223084147, - 28491.687713975512, - 28509.011837912611, - 28526.338594095305, - 28543.667981724069, - 28560.999999999982, - 28578.334648124732, - 28595.671925300605, - 28613.011830730498, - 28630.354363617909, - 28647.699523166943, - 28665.0473085823, - 28682.397719069289, - 28699.750753833818, - 28717.10641208239, - 28734.464693022121, - 28751.825595860708, - 28769.189119806462, - 28786.55526406828, - 28803.924027855664, - 28821.295410378701, - 28838.669410848088, - 28856.046028475103, - 28873.425262471628, - 28890.80711205013, - 28908.191576423673, - 28925.578654805915, - 28942.968346411097, - 28960.360650454055, - 28977.755566150216, - 28995.153092715591, - 29012.553229366786, - 29029.955975320987, - 29047.361329795975, - 29064.769292010107, - 29082.179861182336, - 29099.593036532187, - 29117.00881727978, - 29134.427202645813, - 29151.848191851568, - 29169.271784118911, - 29186.697978670283, - 29204.126774728706, - 29221.55817151779, - 29238.992168261717, - 29256.42876418525, - 29273.867958513725, - 29291.309750473058, - 29308.754139289747, - 29326.201124190855, - 29343.65070440403, - 29361.102879157483, - 29378.557647680012, - 29396.015009200975, - 29413.474962950309, - 29430.937508158524, - 29448.402644056692, - 29465.870369876469, - 29483.340684850071, - 29500.81358821028, - 29518.289079190454, - 29535.767157024511, - 29553.247820946945, - 29570.731070192807, - 29588.216903997723, - 29605.70532159787, - 29623.19632223, - 29640.689905131429, - 29658.186069540028, - 29675.684814694236, - 29693.186139833047, - 29710.690044196028, - 29728.196527023298, - 29745.705587555527, - 29763.217225033964, - 29780.731438700397, - 29798.248227797183, - 29815.76759156723, - 29833.289529254005, - 29850.81404010153, - 29868.341123354381, - 29885.870778257693, - 29903.403004057145, - 29920.937799998974, - 29938.475165329975, - 29956.015099297485, - 29973.557601149394, - 29991.102670134147, - 30008.650305500738, - 30026.200506498706, - 30043.753272378144, - 30061.308602389683, - 30078.866495784507, - 30096.426951814352, - 30113.989969731494, - 30131.55554878875, - 30149.123688239491, - 30166.694387337629, - 30184.267645337608, - 30201.843461494434, - 30219.42183506364, - 30237.002765301309, - 30254.586251464058, - 30272.172292809046, - 30289.760888593977, - 30307.35203807709, - 30324.94574051716, - 30342.541995173502, - 30360.140801305966, - 30377.742158174944, - 30395.346065041358, - 30412.952521166666, - 30430.561525812864, - 30448.173078242475, - 30465.787177718561, - 30483.403823504719, - 30501.02301486507, - 30518.644751064272, - 30536.269031367516, - 30553.895855040515, - 30571.525221349519, - 30589.157129561307, - 30606.791578943175, - 30624.428568762964, - 30642.06809828903, - 30659.710166790261, - 30677.35477353607, - 30695.001917796391, - 30712.651598841687, - 30730.303815942945, - 30747.958568371676, - 30765.615855399912, - 30783.275676300211, - 30800.938030345646, - 30818.602916809814, - 30836.270334966837, - 30853.940284091354, - 30871.612763458521, - 30889.287772344011, - 30906.965310024025, - 30924.645375775272, - 30942.327968874983, - 30960.013088600903, - 30977.700734231294, - 30995.390905044929, - 31013.083600321101, - 31030.778819339619, - 31048.476561380798, - 31066.17682572547, - 31083.879611654978, - 31101.584918451179, - 31119.29274539644, - 31137.003091773637, - 31154.715956866155, - 31172.431339957893, - 31190.14924033326, - 31207.869657277162, - 31225.592590075023, - 31243.318038012771, - 31261.046000376838, - 31278.776476454172, - 31296.50946553221, - 31314.24496689891, - 31331.98297984272, - 31349.7235036526, - 31367.466537618013, - 31385.212081028923, - 31402.960133175795, - 31420.710693349596, - 31438.463760841791, - 31456.219334944351, - 31473.977414949743, - 31491.738000150934, - 31509.501089841389, - 31527.266683315069, - 31545.034779866437, - 31562.80537879045, - 31580.578479382562, - 31598.35408093872, - 31616.132182755369, - 31633.91278412945, - 31651.695884358396, - 31669.481482740131, - 31687.269578573076, - 31705.060171156143, - 31722.853259788735, - 31740.648843770748, - 31758.446922402567, - 31776.247494985066, - 31794.050560819614, - 31811.85611920806, - 31829.664169452753, - 31847.474710856521, - 31865.287742722685, - 31883.103264355046, - 31900.921275057899, - 31918.741774136019, - 31936.564760894671, - 31954.390234639599, - 31972.21819467704, - 31990.048640313704, - 32007.881570856793, - 32025.716985613984, - 32043.554883893445, - 32061.395265003815, - 32079.238128254223, - 32097.083472954269, - 32114.931298414049, - 32132.781603944117, - 32150.634388855524, - 32168.48965245979, - 32186.347394068915, - 32204.207612995371, - 32222.07030855212, - 32239.935480052583, - 32257.803126810672, - 32275.673248140767, - 32293.545843357719, - 32311.420911776862, - 32329.298452713996, - 32347.178465485395, - 32365.060949407813, - 32382.945903798463, - 32400.83332797504, - 32418.723221255706, - 32436.615582959093, - 32454.510412404306, - 32472.407708910916, - 32490.307471798966, - 32508.209700388961, - 32526.114394001877, - 32544.021551959166, - 32561.931173582732, - 32579.843258194956, - 32597.757805118679, - 32615.674813677211, - 32633.594283194328, - 32651.516212994258, - 32669.440602401712, - 32687.367450741847, - 32705.296757340297, - 32723.228521523146, - 32741.162742616943, - 32759.099419948703, - 32777.038552845901, - 32794.980140636464, - 32812.924182648792, - 32830.87067821173, - 32848.819626654593, - 32866.77102730715, - 32884.724879499619, - 32902.681182562686, - 32920.639935827494, - 32938.601138625643, - 32956.56479028918, - 32974.530890150607, - 32992.499437542894, - 33010.470431799447, - 33028.443872254145, - 33046.419758241311, - 33064.39808909571, - 33082.378864152583, - 33100.36208274759, - 33118.347744216881, - 33136.335847897026, - 33154.326393125062, - 33172.31937923847, - 33190.314805575174, - 33208.312671473555, - 33226.312976272442, - 33244.315719311111, - 33262.320899929284, - 33280.328517467125, - 33298.33857126526, - 33316.351060664747, - 33334.365985007091, - 33352.383343634239, - 33370.403135888591, - 33388.42536111299, - 33406.450018650721, - 33424.477107845501, - 33442.506628041512, - 33460.53857858335, - 33478.572958816083, - 33496.609768085189, - 33514.649005736617, - 33532.690671116739, - 33550.734763572356, - 33568.781282450735, - 33586.830227099563, - 33604.881596866973, - 33622.935391101528, - 33640.991609152239, - 33659.050250368542, - 33677.111314100322, - 33695.174799697881, - 33713.240706511984, - 33731.309033893805, - 33749.37978119497, - 33767.452947767531, - 33785.528532963974, - 33803.606536137209, - 33821.686956640602, - 33839.769793827938, - 33857.855047053425, - 33875.942715671707, - 33894.032799037872, - 33912.125296507431, - 33930.220207436316, - 33948.317531180888, - 33966.417267097961, - 33984.519414544746, - 34002.623972878901, - 34020.730941458511, - 34038.840319642077, - 34056.952106788536, - 34075.066302257255, - 34093.182905408015, - 34111.301915601027, - 34129.42333219693, - 34147.547154556785, - 34165.673382042078, - 34183.80201401472, - 34201.933049837033, - 34220.06648887178, - 34238.202330482141, - 34256.340574031703, - 34274.481218884495, - 34292.624264404949, - 34310.769709957938, - 34328.91755490873, - 34347.067798623029, - 34365.220440466954, - 34383.375479807051, - 34401.532916010263, - 34419.692748443973, - 34437.854976475966, - 34456.01959947445, - 34474.18661680806, - 34492.356027845817, - 34510.527831957188, - 34528.702028512052, - 34546.878616880676, - 34565.05759643377, - 34583.238966542449, - 34601.422726578232, - 34619.608875913065, - 34637.797413919296, - 34655.988339969692, - 34674.181653437423, - 34692.37735369608, - 34710.575440119668, - 34728.775912082579, - 34746.978768959649, - 34765.184010126082, - 34783.391634957537, - 34801.60164283005, - 34819.814033120063, - 34838.028805204456, - 34856.24595846048, - 34874.465492265823, - 34892.687405998557, - 34910.911699037177, - 34929.138370760564, - 34947.367420548027, - 34965.598847779271, - 34983.832651834389, - 35002.068832093908, - 35020.307387938738, - 35038.548318750189, - 35056.79162390998, - 35075.03730280025, - 35093.285354803513, - 35111.535779302685, - 35129.788575681116, - 35148.043743322516, - 35166.301281611013, - 35184.561189931141, - 35202.823467667826, - 35221.088114206388, - 35239.355128932555, - 35257.624511232447, - 35275.896260492584, - 35294.170376099886, - 35312.446857441668, - 35330.725703905628, - 35349.006914879887, - 35367.290489752944, - 35385.576427913686, - 35403.864728751418, - 35422.155391655811, - 35440.448416016967, - 35458.743801225341, - 35477.041546671804, - 35495.341651747622, - 35513.644115844436, - 35531.948938354304, - 35550.256118669655, - 35568.565656183309, - 35586.877550288496, - 35605.191800378816, - 35623.508405848268, - 35641.827366091238, - 35660.148680502505, - 35678.472348477233, - 35696.798369410979, - 35715.126742699678, - 35733.457467739659, - 35751.790543927644, - 35770.125970660738, - 35788.46374733642, - 35806.803873352568, - 35825.146348107453, - 35843.49117099971, - 35861.838341428367, - 35880.187858792851, - 35898.539722492955, - 35916.893931928862, - 35935.250486501129, - 35953.609385610718, - 35971.970628658957, - 35990.334215047558, - 36008.700144178612, - 36027.068415454596, - 36045.439028278372, - 36063.811982053165, - 36082.187276182609, - 36100.564910070694, - 36118.944883121789, - 36137.327194740654, - 36155.711844332429, - 36174.098831302617, - 36192.488155057115, - 36210.87981500219, - 36229.273810544473, - 36247.670141091003, - 36266.068806049167, - 36284.469804826738, - 36302.873136831862, - 36321.278801473069, - 36339.686798159251, - 36358.097126299683, - 36376.509785304013, - 36394.924774582258, - 36413.342093544816, - 36431.761741602444, - 36450.183718166292, - 36468.608022647859, - 36487.034654459028, - 36505.463613012063, - 36523.894897719583, - 36542.328507994578, - 36560.764443250409, - 36579.202702900831, - 36597.643286359926, - 36616.086193042182, - 36634.531422362437, - 36652.978973735895, - 36671.428846578143, - 36689.881040305125, - 36708.335554333149, - 36726.792388078902, - 36745.251540959427, - 36763.713012392138, - 36782.176801794812, - 36800.642908585593, - 36819.111332182983, - 36837.582072005869, - 36856.055127473483, - 36874.530498005421, - 36893.008183021651, - 36911.488181942506, - 36929.970494188674, - 36948.455119181206, - 36966.942056341519, - 36985.431305091392, - 37003.922864852961, - 37022.416735048733, - 37040.912915101559, - 37059.411404434657, - 37077.91220247162, - 37096.415308636388, - 37114.920722353243, - 37133.428443046862, - 37151.938470142253, - 37170.450803064785, - 37188.965441240209, - 37207.482384094597, - 37226.001631054402, - 37244.523181546429, - 37263.047034997842, - 37281.573190836149, - 37300.101648489224, - 37318.632407385296, - 37337.165466952945, - 37355.700826621112, - 37374.238485819085, - 37392.778443976509, - 37411.320700523385, - 37429.865254890057, - 37448.412106507232, - 37466.961254805974, - 37485.512699217681, - 37504.066439174116, - 37522.622474107404, - 37541.180803449992, - 37559.741426634704, - 37578.304343094693, - 37596.869552263488, - 37615.43705357494, - 37634.006846463279, - 37652.578930363044, - 37671.153304709165, - 37689.729968936896, - 37708.308922481847, - 37726.890164779965, - 37745.473695267559, - 37764.059513381275, - 37782.647618558112, - 37801.238010235415, - 37819.830687850859, - 37838.425650842495, - 37857.022898648691, - 37875.622430708172, - 37894.224246460013, - 37912.828345343616, - 37931.434726798747, - 37950.043390265506, - 37968.654335184328, - 37987.267560995999, - 38005.883067141665, - 38024.500853062775, - 38043.120918201159, - 38061.743261998963, - 38080.367883898682, - 38098.994783343158, - 38117.623959775563, - 38136.255412639417, - 38154.889141378575, - 38173.525145437234, - 38192.163424259939, - 38210.803977291551, - 38229.446803977284, - 38248.091903762703, - 38266.739276093685, - 38285.388920416466, - 38304.040836177606, - 38322.695022824002, - 38341.351479802899, - 38360.010206561863, - 38378.671202548816, - 38397.334467211993, - 38415.999999999978, - 38434.667800361683, - 38453.33786774637, - 38472.010201603611, - 38490.684801383337, - 38509.361666535784, - 38528.040796511552, - 38546.722190761553, - 38565.405848737035, - 38584.091769889594, - 38602.779953671132, - 38621.470399533908, - 38640.163106930493, - 38658.858075313794, - 38677.555304137059, - 38696.254792853862, - 38714.956540918094, - 38733.660547783991, - 38752.366812906112, - 38771.075335739348, - 38789.78611573892, - 38808.499152360368, - 38827.214445059573, - 38845.931993292739, - 38864.651796516388, - 38883.373854187383, - 38902.098165762916, - 38920.824730700486, - 38939.553548457938, - 38958.284618493431, - 38977.017940265461, - 38995.753513232834, - 39014.491336854699, - 39033.231410590517, - 39051.973733900079, - 39070.718306243485, - 39089.465127081188, - 39108.214195873945, - 39126.965512082832, - 39145.719075169261, - 39164.474884594965, - 39183.232939821988, - 39201.99324031271, - 39220.755785529815, - 39239.52057493633, - 39258.287607995589, - 39277.056884171245, - 39295.828402927284, - 39314.602163728006, - 39333.378166038019, - 39352.15640932227, - 39370.936893046004, - 39389.719616674811, - 39408.504579674584, - 39427.291781511522, - 39446.081221652174, - 39464.872899563372, - 39483.666814712291, - 39502.462966566411, - 39521.261354593538, - 39540.06197826178, - 39558.864837039568, - 39577.669930395656, - 39596.47725779911, - 39615.286818719302, - 39634.098612625923, - 39652.912638988993, - 39671.728897278823, - 39690.547386966064, - 39709.368107521652, - 39728.191058416858, - 39747.016239123259, - 39765.84364911275, - 39784.673287857528, - 39803.505154830105, - 39822.339249503319, - 39841.175571350293, - 39860.014119844491, - 39878.854894459677, - 39897.697894669909, - 39916.54311994958, - 39935.390569773372, - 39954.240243616303, - 39973.092140953675, - 39991.946261261117, - 40010.802604014549, - 40029.661168690225, - 40048.521954764678, - 40067.384961714779, - 40086.250189017679, - 40105.117636150855, - 40123.98730259209, - 40142.859187819471, - 40161.733291311379, - 40180.609612546526, - 40199.488151003912, - 40218.368906162854, - 40237.25187750296, - 40256.137064504153, - 40275.024466646668, - 40293.914083411029, - 40312.805914278084, - 40331.699958728961, - 40350.596216245103, - 40369.494686308273, - 40388.39536840051, - 40407.298262004173, - 40426.20336660192, - 40445.110681676706, - 40464.020206711793, - 40482.931941190756, - 40501.845884597446, - 40520.762036416032, - 40539.680396130985, - 40558.600963227072, - 40577.523737189367, - 40596.448717503234, - 40615.375903654342, - 40634.305295128659, - 40653.236891412453, - 40672.170691992294, - 40691.106696355047, - 40710.044903987873, - 40728.985314378238, - 40747.927927013901, - 40766.872741382918, - 40785.819756973651, - 40804.768973274746, - 40823.720389775161, - 40842.674005964131, - 40861.629821331211, - 40880.587835366234, - 40899.548047559321, - 40918.510457400931, - 40937.475064381761, - 40956.441867992849, - 40975.410867725499, - 40994.382063071331, - 41013.355453522236, - 41032.331038570417, - 41051.308817708363, - 41070.288790428858, - 41089.270956224987, - 41108.255314590111, - 41127.241865017888, - 41146.23060700229, - 41165.221540037543, - 41184.214663618193, - 41203.209977239079, - 41222.207480395307, - 41241.207172582297, - 41260.209053295752, - 41279.213122031659, - 41298.219378286303, - 41317.227821556255, - 41336.23845133838, - 41355.251267129832, - 41374.266268428037, - 41393.283454730743, - 41412.302825535953, - 41431.324380341983, - 41450.348118647416, - 41469.374039951144, - 41488.402143752326, - 41507.432429550427, - 41526.464896845187, - 41545.499545136627, - 41564.536373925075, - 41583.575382711126, - 41602.616570995662, - 41621.659938279874, - 41640.705484065205, - 41659.753207853406, - 41678.803109146495, - 41697.855187446803, - 41716.909442256911, - 41735.965873079709, - 41755.02447941836, - 41774.085260776315, - 41793.148216657297, - 41812.213346565331, - 41831.280650004708, - 41850.350126480014, - 41869.421775496106, - 41888.495596558132, - 41907.571589171515, - 41926.649752841957, - 41945.730087075463, - 41964.812591378286, - 41983.897265256979, - 42002.984108218378, - 42022.073119769593, - 42041.164299418015, - 42060.257646671307, - 42079.353161037419, - 42098.450842024591, - 42117.550689141324, - 42136.652701896404, - 42155.756879798893, - 42174.863222358137, - 42193.971729083758, - 42213.082399485655, - 42232.195233074002, - 42251.310229359246, - 42270.427387852127, - 42289.546708063644, - 42308.668189505079, - 42327.791831687995, - 42346.917634124227, - 42366.045596325886, - 42385.175717805352, - 42404.307998075295, - 42423.442436648642, - 42442.579033038608, - 42461.717786758672, - 42480.858697322597, - 42500.001764244422, - 42519.146987038446, - 42538.294365219248, - 42557.443898301688, - 42576.595585800882, - 42595.749427232236, - 42614.90542211142, - 42634.063569954378, - 42653.223870277317, - 42672.386322596729, - 42691.55092642938, - 42710.717681292292, - 42729.886586702756, - 42749.057642178363, - 42768.23084723694, - 42787.406201396603, - 42806.58370417574, - 42825.76335509299, - 42844.945153667286, - 42864.129099417805, - 42883.315191864014, - 42902.503430525649, - 42921.693814922692, - 42940.88634457541, - 42960.081019004348, - 42979.277837730297, - 42998.476800274322, - 43017.677906157769, - 43036.881154902228, - 43056.086546029583, - 43075.294079061961, - 43094.503753521763, - 43113.715568931671, - 43132.929524814601, - 43152.145620693766, - 43171.363856092619, - 43190.584230534907, - 43209.806743544621, - 43229.031394646016, - 43248.258183363621, - 43267.487109222224, - 43286.718171746885, - 43305.951370462906, - 43325.186704895881, - 43344.42417457165, - 43363.663779016322, - 43382.905517756262, - 43402.149390318104, - 43421.395396228749, - 43440.643535015348, - 43459.89380620532, - 43479.146209326354, - 43498.400743906379, - 43517.657409473606, - 43536.916205556496, - 43556.177131683784, - 43575.44018738444, - 43594.705372187724, - 43613.972685623135, - 43633.242127220445, - 43652.513696509668, - 43671.787393021099, - 43691.063216285271, - 43710.341165833001, - 43729.621241195346, - 43748.903441903625, - 43768.187767489413, - 43787.474217484552, - 43806.762791421126, - 43826.053488831501, - 43845.346309248278, - 43864.641252204325, - 43883.938317232765, - 43903.237503866971, - 43922.538811640596, - 43941.842240087513, - 43961.147788741881, - 43980.455457138101, - 43999.765244810835, - 44019.077151295001, - 44038.391176125755, - 44057.70731883854, - 44077.02557896902, - 44096.345956053141, - 44115.668449627083, - 44134.993059227287, - 44154.319784390456, - 44173.648624653535, - 44192.979579553728, - 44212.312648628489, - 44231.647831415532, - 44250.985127452805, - 44270.324536278538, - 44289.666057431183, - 44309.009690449464, - 44328.355434872348, - 44347.703290239064, - 44367.053256089079, - 44386.405331962109, - 44405.759517398139, - 44425.115811937387, - 44444.474215120332, - 44463.834726487694, - 44483.197345580462, - 44502.562071939843, - 44521.928905107328, - 44541.297844624634, - 44560.668890033732, - 44580.042040876848, - 44599.417296696454, - 44618.794657035272, - 44638.174121436256, - 44657.555689442641, - 44676.939360597877, - 44696.325134445673, - 44715.713010530002, - 44735.102988395054, - 44754.495067585296, - 44773.88924764542, - 44793.285528120374, - 44812.683908555344, - 44832.084388495779, - 44851.486967487363, - 44870.891645076015, - 44890.298420807922, - 44909.707294229491, - 44929.118264887409, - 44948.531332328566, - 44967.946496100136, - 44987.363755749502, - 45006.783110824319, - 45026.204560872473, - 45045.628105442098, - 45065.053744081561, - 45084.48147633949, - 45103.911301764747, - 45123.343219906426, - 45142.777230313885, - 45162.21333253671, - 45181.651526124733, - 45201.091810628037, - 45220.534185596924, - 45239.978650581965, - 45259.425205133957, - 45278.873848803938, - 45298.324581143192, - 45317.777401703235, - 45337.232310035848, - 45356.68930569302, - 45376.148388226997, - 45395.60955719027, - 45415.072812135557, - 45434.538152615823, - 45454.005578184282, - 45473.475088394356, - 45492.946682799746, - 45512.420360954362, - 45531.896122412363, - 45551.373966728155, - 45570.853893456362, - 45590.33590215187, - 45609.819992369776, - 45629.306163665438, - 45648.794415594442, - 45668.284747712612, - 45687.777159576006, - 45707.27165074092, - 45726.768220763894, - 45746.266869201696, - 45765.767595611323, - 45785.270399550034, - 45804.775280575297, - 45824.282238244828, - 45843.79127211657, - 45863.302381748719, - 45882.815566699683, - 45902.33082652813, - 45921.848160792935, - 45941.367569053225, - 45960.889050868354, - 45980.41260579793, - 45999.938233401757, - 46019.465933239902, - 46038.995704872657, - 46058.527547860547, - 46078.06146176433, - 46097.597446144995, - 46117.135500563774, - 46136.675624582109, - 46156.217817761702, - 46175.762079664462, - 46195.308409852543, - 46214.856807888333, - 46234.407273334444, - 46253.959805753715, - 46273.51440470924, - 46293.071069764315, - 46312.629800482478, - 46332.190596427499, - 46351.753457163381, - 46371.318382254351, - 46390.885371264863, - 46410.45442375962, - 46430.025539303526, - 46449.598717461733, - 46469.17395779962, - 46488.751259882782, - 46508.33062327707, - 46527.912047548532, - 46547.495532263471, - 46567.081076988397, - 46586.668681290059, - 46606.258344735434, - 46625.850066891719, - 46645.443847326351, - 46665.039685606986, - 46684.637581301497, - 46704.237533978005, - 46723.839543204842, - 46743.443608550573, - 46763.049729583989, - 46782.657905874104, - 46802.268136990162, - 46821.880422501628, - 46841.494761978196, - 46861.111154989776, - 46880.729601106526, - 46900.350099898795, - 46919.97265093719, - 46939.597253792526, - 46959.223908035841, - 46978.852613238392, - 46998.483368971691, - 47018.11617480743, - 47037.751030317551, - 47057.387935074221, - 47077.026888649809, - 47096.66789061694, - 47116.310940548428, - 47135.956038017328, - 47155.603182596918, - 47175.252373860698, - 47194.903611382375, - 47214.556894735892, - 47234.212223495422, - 47253.869597235338, - 47273.52901553025, - 47293.19047795498, - 47312.853984084577, - 47332.519533494306, - 47352.187125759658, - 47371.856760456343, - 47391.528437160297, - 47411.202155447652, - 47430.877914894787, - 47450.555715078299, - 47470.235555574982, - 47489.917435961863, - 47509.601355816201, - 47529.287314715453, - 47548.975312237308, - 47568.665347959672, - 47588.357421460656, - 47608.051532318605, - 47627.747680112072, - 47647.445864419846, - 47667.14608482091, - 47686.848340894474, - 47706.552632219973, - 47726.258958377046, - 47745.967318945557, - 47765.677713505589, - 47785.390141637428, - 47805.104602921601, - 47824.821096938824, - 47844.539623270044, - 47864.260181496429, - 47883.982771199349, - 47903.707391960394, - 47923.434043361369, - 47943.162724984308, - 47962.893436411439, - 47982.626177225218, - 48002.36094700831, - 48022.097745343599, - 48041.836571814172, - 48061.57742600335, - 48081.32030749465, - 48101.065215871815, - 48120.81215071879, - 48140.56111161974, - 48160.312098159047, - 48180.065109921306, - 48199.820146491307, - 48219.577207454073, - 48239.336292394844, - 48259.097400899045, - 48278.860532552339, - 48298.625686940592, - 48318.392863649875, - 48338.162062266485, - 48357.933282376915, - 48377.706523567889, - 48397.481785426316, - 48417.259067539344, - 48437.038369494308, - 48456.819690878765, - 48476.603031280487, - 48496.388390287451, - 48516.175767487839, - 48535.965162470042, - 48555.756574822684, - 48575.550004134566, - 48595.345449994718, - 48615.142911992378, - 48634.942389716991, - 48654.743882758201, - 48674.547390705877, - 48694.352913150084, - 48714.160449681112, - 48733.969999889443, - 48753.781563365759, - 48773.595139700978, - 48793.410728486211, - 48813.228329312769, - 48833.047941772187, - 48852.869565456189, - 48872.693199956717, - 48892.518844865925, - 48912.346499776155, - 48932.176164279976, - 48952.007837970152, - 48971.841520439666, - 48991.677211281676, - 49011.514910089587, - 49031.354616456978, - 49051.196329977654, - 49071.04005024561, - 49090.885776855059, - 49110.733509400408, - 49130.583247476279, - 49150.434990677488, - 49170.288738599062, - 49190.144490836232, - 49210.002246984441, - 49229.86200663932, - 49249.723769396718, - 49269.587534852675, - 49289.453302603448, - 49309.32107224549, - 49329.190843375451, - 49349.062615590192, - 49368.936388486785, - 49388.812161662492, - 49408.689934714785, - 49428.569707241324, - 49448.45147883999, - 49468.335249108866, - 49488.22101764621, - 49508.108784050521, - 49527.99854792047, - 49547.890308854934, - 49567.784066453009, - 49587.679820313977, - 49607.57757003732, - 49627.477315222721, - 49647.379055470075, - 49667.28279037946, - 49687.188519551179, - 49707.096242585707, - 49727.005959083741, - 49746.917668646165, - 49766.831370874068, - 49786.747065368734, - 49806.66475173166, - 49826.584429564515, - 49846.506098469203, - 49866.429758047794, - 49886.355407902578, - 49906.283047636032, - 49926.212676850846, - 49946.144295149883, - 49966.077902136225, - 49986.013497413151, - 50005.951080584135, - 50025.890651252834, - 50045.832209023123, - 50065.775753499074, - 50085.721284284933, - 50105.668800985164, - 50125.618303204428, - 50145.569790547575, - 50165.523262619652, - 50185.478719025901, - 50205.436159371769, - 50225.395583262893, - 50245.356990305103, - 50265.320380104429, - 50285.285752267104, - 50305.253106399534, - 50325.222442108337, - 50345.193759000336, - 50365.16705668252, - 50385.142334762102, - 50405.119592846473, - 50425.098830543218, - 50445.080047460127, - 50465.063243205179, - 50485.048417386541, - 50505.035569612577, - 50525.024699491856, - 50545.015806633128, - 50565.008890645338, - 50585.003951137631, - 50605.00098771933, - 50624.999999999971, - 50645.000987589265, - 50665.003950097132, - 50685.008887133677, - 50705.015798309192, - 50725.024683234165, - 50745.035541519283, - 50765.048372775411, - 50785.063176613621, - 50805.079952645159, - 50825.098700481489, - 50845.119419734241, - 50865.142110015244, - 50885.166770936521, - 50905.193402110279, - 50925.222003148934, - 50945.252573665071, - 50965.285113271471, - 50985.319621581119, - 51005.356098207172, - 51025.394542762981, - 51045.434954862096, - 51065.477334118244, - 51085.521680145357, - 51105.567992557546, - 51125.616270969113, - 51145.66651499454, - 51165.718724248516, - 51185.772898345916, - 51205.829036901778, - 51225.887139531362, - 51245.947205850105, - 51266.009235473619, - 51286.073228017718, - 51306.139183098399, - 51326.207100331856, - 51346.276979334456, - 51366.348819722756, - 51386.42262111351, - 51406.498383123653, - 51426.57610537031, - 51446.655787470787, - 51466.737429042587, - 51486.82102970338, - 51506.906589071048, - 51526.994106763632, - 51547.083582399391, - 51567.175015596738, - 51587.268405974297, - 51607.363753150858, - 51627.461056745415, - 51647.56031637713, - 51667.661531665362, - 51687.764702229651, - 51707.869827689727, - 51727.976907665499, - 51748.085941777055, - 51768.196929644677, - 51788.309870888836, - 51808.42476513017, - 51828.541611989524, - 51848.660411087905, - 51868.781162046515, - 51888.90386448674, - 51909.028518030143, - 51929.155122298485, - 51949.283676913685, - 51969.414181497872, - 51989.546635673345, - 52009.681039062583, - 52029.817391288263, - 52049.955691973213, - 52070.095940740481, - 52090.238137213273, - 52110.382281014987, - 52130.5283717692, - 52150.676409099666, - 52170.826392630333, - 52190.97832198532, - 52211.132196788931, - 52231.288016665654, - 52251.445781240145, - 52271.60549013727, - 52291.76714298204, - 52311.930739399664, - 52332.096279015546, - 52352.263761455244, - 52372.433186344519, - 52392.604553309284, - 52412.777861975665, - 52432.953111969946, - 52453.130302918595, - 52473.309434448267, - 52493.490506185793, - 52513.67351775818, - 52533.858468792605, - 52554.045358916446, - 52574.234187757254, - 52594.42495494274, - 52614.617660100812, - 52634.812302859558, - 52655.008882847229, - 52675.20739969227, - 52695.407853023295, - 52715.610242469098, - 52735.814567658657, - 52756.02082822111, - 52776.229023785803, - 52796.439153982225, - 52816.651218440056, - 52836.865216789171, - 52857.081148659599, - 52877.29901368155, - 52897.518811485425, - 52917.740541701773, - 52937.964203961354, - 52958.18979789508, - 52978.417323134046, - 52998.646779309529, - 53018.878166052978, - 53039.111482996006, - 53059.346729770419, - 53079.583906008193, - 53099.823011341483, - 53120.0640454026, - 53140.307007824063, - 53160.551898238533, - 53180.79871627887, - 53201.047461578091, - 53221.2981337694, - 53241.550732486176, - 53261.805257361964, - 53282.061708030487, - 53302.32008412564, - 53322.580385281493, - 53342.842611132299, - 53363.106761312469, - 53383.372835456597, - 53403.640833199453, - 53423.910754175973, - 53444.18259802126, - 53464.456364370613, - 53484.732052859479, - 53505.009663123499, - 53525.289194798468, - 53545.570647520362, - 53565.854020925333, - 53586.139314649699, - 53606.426528329954, - 53626.715661602764, - 53647.006714104959, - 53667.299685473547, - 53687.59457534572, - 53707.891383358816, - 53728.190109150361, - 53748.490752358055, - 53768.793312619753, - 53789.09778957349, - 53809.404182857485, - 53829.712492110106, - 53850.022716969899, - 53870.334857075584, - 53890.648912066055, - 53910.964881580367, - 53931.28276525774, - 53951.602562737586, - 53971.924273659461, - 53992.24789766311, - 54012.57343438844, - 54032.90088347553, - 54053.23024456462, - 54073.561517296133, - 54093.894701310644, - 54114.22979624891, - 54134.566801751855, - 54154.90571746057, - 54175.246543016314, - 54195.589278060506, - 54215.933922234755, - 54236.280475180814, - 54256.628936540626, - 54276.97930595628, - 54297.331583070045, - 54317.685767524359, - 54338.041858961828, - 54358.399857025215, - 54378.759761357462, - 54399.121571601667, - 54419.485287401105, - 54439.850908399218, - 54460.218434239614, - 54480.587864566056, - 54500.95919902248, - 54521.332437252997, - 54541.707578901878, - 54562.084623613555, - 54582.46357103264, - 54602.844420803893, - 54623.227172572246, - 54643.611825982807, - 54663.998380680838, - 54684.386836311773, - 54704.777192521207, - 54725.169448954897, - 54745.563605258772, - 54765.959661078923, - 54786.357616061614, - 54806.757469853255, - 54827.159222100439, - 54847.562872449904, - 54867.968420548583, - 54888.375866043534, - 54908.785208582012, - 54929.196447811417, - 54949.609583379322, - 54970.024614933463, - 54990.441542121727, - 55010.86036459219, - 55031.28108199306, - 55051.703693972733, - 55072.128200179759, - 55092.554600262847, - 55112.982893870874, - 55133.413080652877, - 55153.845160258061, - 55174.279132335789, - 55194.714996535586, - 55215.152752507143, - 55235.592399900306, - 55256.033938365079, - 55276.477367551655, - 55296.92268711036, - 55317.369896691685, - 55337.818995946305, - 55358.269984525024, - 55378.72286207883, - 55399.177628258869, - 55419.634282716441, - 55440.092825103013, - 55460.553255070205, - 55481.015572269804, - 55501.479776353764, - 55521.945866974187, - 55542.413843783339, - 55562.883706433655, - 55583.355454577715, - 55603.82908786826, - 55624.304605958219, - 55644.782008500639, - 55665.261295148754, - 55685.742465555952, - 55706.225519375774, - 55726.710456261928, - 55747.197275868275, - 55767.685977848843, - 55788.176561857814, - 55808.669027549528, - 55829.163374578478, - 55849.659602599328, - 55870.157711266889, - 55890.657700236145, - 55911.159569162221, - 55931.663317700411, - 55952.168945506164, - 55972.676452235086, - 55993.185837542944, - 56013.697101085651, - 56034.210242519301, - 56054.72526150012, - 56075.242157684508, - 56095.760930729011, - 56116.281580290342, - 56136.804106025367, - 56157.328507591104, - 56177.85478464474, - 56198.382936843598, - 56218.912963845185, - 56239.444865307138, - 56259.978640887268, - 56280.514290243525, - 56301.051813034042, - 56321.591208917082, - 56342.13247755108, - 56362.675618594607, - 56383.220631706419, - 56403.767516545398, - 56424.316272770608, - 56444.866900041241, - 56465.419398016667, - 56485.973766356394, - 56506.530004720102, - 56527.088112767611, - 56547.648090158902, - 56568.209936554107, - 56588.773651613519, - 56609.339234997584, - 56629.9066863669, - 56650.47600538221, - 56671.04719170442, - 56691.620244994599, - 56712.195164913959, - 56732.771951123868, - 56753.350603285835, - 56773.931121061541, - 56794.513504112823, - 56815.097752101647, - 56835.683864690152, - 56856.271841540627, - 56876.86168231551, - 56897.453386677393, - 56918.046954289028, - 56938.642384813298, - 56959.239677913261, - 56979.838833252121, - 57000.439850493225, - 57021.04272930009, - 57041.647469336371, - 57062.254070265873, - 57082.862531752558, - 57103.472853460553, - 57124.085035054108, - 57144.699076197649, - 57165.314976555739, - 57185.932735793103, - 57206.552353574611, - 57227.173829565276, - 57247.797163430281, - 57268.42235483494, - 57289.049403444733, - 57309.678308925286, - 57330.30907094237, - 57350.941689161911, - 57371.576163249985, - 57392.212492872815, - 57412.850677696784, - 57433.490717388406, - 57454.132611614368, - 57474.776360041491, - 57495.421962336746, - 57516.069418167266, - 57536.718727200314, - 57557.36988910332, - 57578.022903543861, - 57598.677770189643, - 57619.334488708548, - 57639.993058768589, - 57660.653480037938, - 57681.315752184906, - 57701.979874877965, - 57722.64584778573, - 57743.31367057695, - 57763.983342920546, - 57784.654864485572, - 57805.328234941233, - 57826.003453956881, - 57846.680521202026, - 57867.359436346305, - 57888.040199059527, - 57908.722809011633, - 57929.407265872709, - 57950.093569313001, - 57970.781719002895, - 57991.471714612911, - 58012.16355581375, - 58032.857242276223, - 58053.552773671312, - 58074.25014967013, - 58094.949369943948, - 58115.650434164185, - 58136.353342002389, - 58157.058093130276, - 58177.764687219693, - 58198.47312394264, - 58219.183402971255, - 58239.895523977837, - 58260.609486634821, - 58281.325290614775, - 58302.042935590434, - 58322.762421234678, - 58343.483747220511, - 58364.206913221096, - 58384.931918909751, - 58405.658763959924, - 58426.3874480452, - 58447.117970839339, - 58467.85033201622, - 58488.584531249864, - 58509.320568214462, - 58530.058442584334, - 58550.798154033931, - 58571.539702237875, - 58592.283086870906, - 58613.028307607929, - 58633.775364123983, - 58654.52425609425, - 58675.274983194053, - 58696.027545098877, - 58716.781941484325, - 58737.538172026158, - 58758.296236400274, - 58779.056134282728, - 58799.817865349694, - 58820.581429277503, - 58841.346825742643, - 58862.114054421712, - 58882.883114991484, - 58903.654007128847, - 58924.426730510851, - 58945.201284814684, - 58965.977669717664, - 58986.755884897269, - 59007.535930031117, - 59028.317804796949, - 59049.101508872664, - 59069.887041936301, - 59090.674403666046, - 59111.463593740213, - 59132.254611837263, - 59153.047457635803, - 59173.84213081457, - 59194.638631052461, - 59215.436958028506, - 59236.237111421855, - 59257.039090911829, - 59277.842896177877, - 59298.648526899589, - 59319.455982756685, - 59340.26526342905, - 59361.076368596696, - 59381.889297939757, - 59402.704051138542, - 59423.520627873484, - 59444.339027825139, - 59465.159250674224, - 59485.9812961016, - 59506.805163788253, - 59527.630853415307, - 59548.458364664046, - 59569.287697215863, - 59590.118850752311, - 59610.951824955089, - 59631.786619506012, - 59652.623234087048, - 59673.461668380311, - 59694.301922068029, - 59715.143994832593, - 59735.987886356525, - 59756.833596322482, - 59777.681124413255, - 59798.530470311794, - 59819.381633701159, - 59840.234614264569, - 59861.089411685381, - 59881.94602564707, - 59902.804455833269, - 59923.664701927737, - 59944.526763614384, - 59965.390640577243, - 59986.256332500488, - 60007.123839068438, - 60027.993159965539, - 60048.864294876381, - 60069.737243485688, - 60090.612005478324, - 60111.488580539284, - 60132.366968353708, - 60153.247168606867, - 60174.129180984164, - 60195.013005171153, - 60215.898640853513, - 60236.786087717061, - 60257.675345447751, - 60278.566413731671, - 60299.459292255044, - 60320.353980704247, - 60341.25047876576, - 60362.148786126229, - 60383.048902472423, - 60403.950827491237, - 60424.854560869717, - 60445.76010229504, - 60466.667451454516, - 60487.57660803559, - 60508.487571725847, - 60529.400342212997, - 60550.314919184893, - 60571.231302329521, - 60592.149491335003, - 60613.069485889588, - 60633.991285681674, - 60654.914890399785, - 60675.840299732568, - 60696.767513368832, - 60717.696530997484, - 60738.627352307602, - 60759.55997698837, - 60780.494404729128, - 60801.430635219323, - 60822.368668148556, - 60843.308503206565, - 60864.250140083204, - 60885.193578468468, - 60906.138818052495, - 60927.085858525541, - 60948.034699578006, - 60968.985340900421, - 60989.937782183442, - 61010.892023117864, - 61031.848063394616, - 61052.805902704764, - 61073.765540739492, - 61094.726977190134, - 61115.690211748137, - 61136.655244105103, - 61157.622073952742, - 61178.590700982917, - 61199.561124887616, - 61220.533345358948, - 61241.507362089171, - 61262.483174770663, - 61283.460783095943, - 61304.440186757645, - 61325.421385448557, - 61346.404378861582, - 61367.389166689762, - 61388.375748626262, - 61409.364124364387, - 61430.354293597571, - 61451.346256019373, - 61472.340011323497, - 61493.335559203762, - 61514.332899354122, - 61535.332031468672, - 61556.332955241618, - 61577.335670367313, - 61598.340176540238, - 61619.346473454993, - 61640.354560806329, - 61661.3644382891, - 61682.376105598312, - 61703.389562429089, - 61724.404808476691, - 61745.42184343651, - 61766.440667004063, - 61787.461278874987, - 61808.483678745069, - 61829.507866310203, - 61850.533841266435, - 61871.561603309929, - 61892.591152136971, - 61913.622487443987, - 61934.655608927525, - 61955.690516284267, - 61976.727209211022, - 61997.765687404724, - 62018.805950562448, - 62039.847998381381, - 62060.891830558845, - 62081.93744679229, - 62102.984846779298, - 62124.034030217575, - 62145.084996804966, - 62166.137746239416, - 62187.19227821903, - 62208.248592442025, - 62229.306688606739, - 62250.366566411656, - 62271.428225555377, - 62292.491665736627, - 62313.556886654267, - 62334.623888007271, - 62355.692669494762, - 62376.763230815974, - 62397.835571670272, - 62418.909691757144, - 62439.98559077621, - 62461.063268427228, - 62482.142724410049, - 62503.223958424685, - 62524.306970171267, - 62545.39175935003, - 62566.478325661366, - 62587.566668805768, - 62608.656788483881, - 62629.748684396451, - 62650.842356244357, - 62671.937803728622, - 62693.035026550366, - 62714.134024410858, - 62735.234797011479, - 62756.337344053733, - 62777.441665239276, - 62798.547760269852, - 62819.655628847358, - 62840.765270673801, - 62861.876685451323, - 62882.989872882186, - 62904.104832668774, - 62925.221564513602, - 62946.340068119309, - 62967.460343188657, - 62988.582389424526, - 63009.70620652994, - 63030.831794208025, - 63051.959152162039, - 63073.08828009537, - 63094.219177711529, - 63115.351844714154, - 63136.486280806988, - 63157.622485693922, - 63178.760459078956, - 63199.900200666219, - 63221.041710159967, - 63242.184987264569, - 63263.330031684534, - 63284.476843124474, - 63305.625421289144, - 63326.775765883409, - 63347.927876612259, - 63369.081753180813, - 63390.237395294316, - 63411.39480265812, - 63432.553974977716, - 63453.714911958712, - 63474.877613306839, - 63496.042078727944, - 63517.208307927998, - 63538.376300613119, - 63559.546056489504, - 63580.717575263516, - 63601.890856641607, - 63623.065900330374, - 63644.242706036515, - 63665.421273466869, - 63686.601602328381, - 63707.783692328136, - 63728.967543173334, - 63750.153154571279, - 63771.340526229418, - 63792.529657855317, - 63813.720549156649, - 63834.913199841227, - 63856.107609616978, - 63877.303778191941, - 63898.501705274284, - 63919.7013905723, - 63940.902833794404, - 63962.106034649114, - 63983.310992845094, - 64004.517708091109, - 64025.726180096048, - 64046.936408568938, - 64068.1483932189, - 64089.362133755196, - 64110.577629887193, - 64131.794881324393, - 64153.013887776404, - 64174.234648952966, - 64195.457164563937, - 64216.681434319289, - 64237.907457929112, - 64259.135235103626, - 64280.36476555316, - 64301.596048988169, - 64322.829085119236, - 64344.06387365704, - 64365.300414312398, - 64386.538706796251, - 64407.778750819634, - 64429.020546093721, - 64450.26409232981, - 64471.509389239291, - 64492.756436533709, - 64514.005233924705, - 64535.255781124033, - 64556.50807784358, - 64577.762123795357, - 64599.017918691468, - 64620.275462244172, - 64641.534754165805, - 64662.795794168844, - 64684.058581965895, - 64705.323117269661, - 64726.589399792974, - 64747.857429248776, - 64769.127205350138, - 64790.398727810236, - 64811.671996342375, - 64832.947010659969, - 64854.223770476558, - 64875.502275505794, - 64896.782525461451, - 64918.064520057414, - 64939.348259007682, - 64960.633742026388, - 64981.920968827762, - 65003.209939126165, - 65024.500652636067, - 65045.793109072067, - 65067.087308148861, - 65088.383249581282, - 65109.680933084259, - 65130.980358372864, - 65152.28152516226, - 65173.584433167736, - 65194.889082104703, - 65216.195471688683, - 65237.503601635319, - 65258.813471660353, - 65280.125081479666, - 65301.438430809241, - 65322.753519365178, - 65344.070346863708, - 65365.388913021146, - 65386.709217553958, - 65408.031260178701, - 65429.355040612056, - 65450.680558570821, - 65472.00781377191, - 65493.336805932355, - 65514.66753476928, - 65535.999999999956, - 65557.334201341757, - 65578.670138512171, - 65600.007811228788, - 65621.347219209332, - 65642.688362171626, - 65664.031239833639, - 65685.375851913413, - 65706.722198129137, - 65728.070278199084, - 65749.420091841661, - 65770.771638775404, - 65792.124918718939, - 65813.479931391004, - 65834.836676510458, - 65856.195153796303, - 65877.5553629676, - 65898.917303743554, - 65920.280975843489, - 65941.646378986843, - 65963.013512893158, - 65984.382377282076, - 66005.752971873386, - 66027.125296386963, - 66048.499350542799, - 66069.875134061018, - 66091.252646661844, - 66112.631888065618, - 66134.01285799277, - 66155.395556163887, - 66176.779982299631, - 66198.166136120795, - 66219.554017348273, - 66240.943625703105, - 66262.334960906388, - 66283.728022679396, - 66305.122810743444, - 66326.519324820023, - 66347.917564630698, - 66369.317529897162, - 66390.719220341227, - 66412.122635684791, - 66433.527775649884, - 66454.934639958636, - 66476.343228333324, - 66497.753540496284, - 66519.165576169995, - 66540.57933507704, - 66561.994816940118, - 66583.412021482043, - 66604.830948425733, - 66626.251597494222, - 66647.673968410629, - 66669.098060898235, - 66690.523874680381, - 66711.951409480564, - 66733.380665022371, - 66754.811641029475, - 66776.244337225711, - 66797.678753334985, - 66819.11488908132, - 66840.552744188884, - 66861.992318381905, - 66883.433611384738, - 66904.876622921889, - 66926.321352717903, - 66947.767800497502, - 66969.215965985466, - 66990.665848906734, - 67012.117448986304, - 67033.570765949335, - 67055.025799521056, - 67076.482549426815, - 67097.941015392076, - 67119.401197142433, - 67140.863094403554, - 67162.326706901222, - 67183.792034361351, - 67205.259076509959, - 67226.72783307315, - 67248.198303777172, - 67269.670488348347, - 67291.144386513144, - 67312.619997998088, - 67334.09732252988, - 67355.576359835293, - 67377.057109641188, - 67398.53957167457, - 67420.023745662547, - 67441.50963133233, - 67462.99722841123, - 67484.486536626689, - 67505.977555706224, - 67527.470285377494, - 67548.964725368263, - 67570.460875406367, - 67591.9587352198, - 67613.458304536631, - 67634.95958308503, - 67656.462570593329, - 67677.967266789899, - 67699.473671403248, - 67720.981784162024, - 67742.491604794923, - 67764.003133030797, - 67785.516368598575, - 67807.031311227314, - 67828.547960646174, - 67850.066316584402, - 67871.58637877139, - 67893.108146936589, - 67914.63162080961, - 67936.156800120138, - 67957.683684597971, - 67979.212273973011, - 68000.742567975263, - 68022.274566334876, - 68043.808268782057, - 68065.343675047145, - 68086.880784860579, - 68108.419597952918, - 68129.960114054789, - 68151.502332896969, - 68173.04625421032, - 68194.591877725834, - 68216.139203174564, - 68237.688230287706, - 68259.238958796544, - 68280.791388432481, - 68302.345518927032, - 68323.901350011787, - 68345.458881418483, - 68367.018112878912, - 68388.579044125028, - 68410.141674888844, - 68431.706004902502, - 68453.272033898262, - 68474.839761608455, - 68496.409187765545, - 68517.980312102081, - 68539.553134350732, - 68561.127654244279, - 68582.70387151558, - 68604.281785897634, - 68625.861397123503, - 68647.44270492639, - 68669.025709039604, - 68690.610409196524, - 68712.196805130661, - 68733.784896575627, - 68755.374683265123, - 68776.966164932994, - 68798.559341313128, - 68820.154212139591, - 68841.750777146473, - 68863.349036068044, - 68884.948988638629, - 68906.550634592684, - 68928.153973664739, - 68949.75900558944, - 68971.365730101577, - 68992.974146935987, - 69014.584255827634, - 69036.196056511588, - 69057.809548723017, - 69079.424732197207, - 69101.041606669532, - 69122.660171875468, - 69144.280427550606, - 69165.902373430625, - 69187.526009251334, - 69209.151334748618, - 69230.778349658474, - 69252.40705371699, - 69274.037446660412, - 69295.669528225, - 69317.303298147192, - 69338.938756163494, - 69360.575902010532, - 69382.214735425005, - 69403.855256143754, - 69425.497463903681, - 69447.141358441833, - 69468.78693949533, - 69490.434206801394, - 69512.083160097391, - 69533.733799120717, - 69555.386123608929, - 69577.04013329967, - 69598.695827930685, - 69620.353207239794, - 69642.012270964973, - 69663.67301884426, - 69685.335450615792, - 69706.999566017839, - 69728.665364788743, - 69750.332846666963, - 69772.002011391058, - 69793.672858699691, - 69815.345388331611, - 69837.019600025669, - 69858.695493520849, - 69880.373068556204, - 69902.052324870907, - 69923.733262204216, - 69945.415880295492, - 69967.100178884211, - 69988.786157709939, - 70010.473816512356, - 70032.163155031216, - 70053.854173006403, - 70075.546870177874, - 70097.241246285717, - 70118.937301070109, - 70140.635034271298, - 70162.334445629691, - 70184.035534885741, - 70205.738301780017, - 70227.442746053217, - 70249.1488674461, - 70270.856665699539, - 70292.566140554511, - 70314.277291752107, - 70335.990119033493, - 70357.704622139936, - 70379.420800812819, - 70401.138654793613, - 70422.85818382389, - 70444.579387645339, - 70466.302265999722, - 70488.026818628918, - 70509.753045274876, - 70531.480945679708, - 70553.210519585555, - 70574.941766734701, - 70596.674686869505, - 70618.409279732456, - 70640.145545066101, - 70661.883482613106, - 70683.623092116264, - 70705.364373318414, - 70727.107325962526, - 70748.851949791671, - 70770.598244549008, - 70792.346209977783, - 70814.095845821372, - 70835.847151823225, - 70857.600127726895, - 70879.354773276034, - 70901.111088214413, - 70922.869072285859, - 70944.628725234332, - 70966.390046803877, - 70988.153036738629, - 71009.917694782853, - 71031.684020680885, - 71053.45201417715, - 71075.221675016204, - 71096.993002942661, - 71118.765997701266, - 71140.540659036851, - 71162.316986694335, - 71184.09498041874, - 71205.874639955218, - 71227.655965048951, - 71249.438955445294, - 71271.223610889632, - 71293.009931127483, - 71314.797915904477, - 71336.587564966307, - 71358.378878058764, - 71380.171854927772, - 71401.966495319313, - 71423.762798979486, - 71445.560765654489, - 71467.360395090596, - 71489.161687034211, - 71510.964641231811, - 71532.769257429973, - 71554.575535375348, - 71576.383474814749, - 71598.19307549503, - 71620.004337163133, - 71641.817259566145, - 71663.631842451214, - 71685.4480855656, - 71707.26598865664, - 71729.085551471784, - 71750.906773758586, - 71772.729655264673, - 71794.554195737772, - 71816.380394925713, - 71838.208252576442, - 71860.037768437964, - 71881.868942258385, - 71903.701773785942, - 71925.536262768932, - 71947.372408955751, - 71969.210212094898, - 71991.049671934976, - 72012.890788224686, - 72034.73356071279, - 72056.577989148165, - 72078.424073279821, - 72100.271812856794, - 72122.121207628254, - 72143.97225734347, - 72165.824961751801, - 72187.679320602692, - 72209.53533364569, - 72231.393000630429, - 72253.252321306645, - 72275.113295424177, - 72296.975922732949, - 72318.840202982959, - 72340.706135924338, - 72362.573721307272, - 72384.442958882093, - 72406.313848399179, - 72428.186389609036, - 72450.060582262216, - 72471.936426109431, - 72493.813920901433, - 72515.693066389096, - 72537.573862323392, - 72559.456308455352, - 72581.340404536139, - 72603.226150316987, - 72625.113545549248, - 72647.002589984331, - 72668.893283373764, - 72690.785625469172, - 72712.679616022273, - 72734.575254784853, - 72756.472541508803, - 72778.371475946144, - 72800.272057848939, - 72822.174286969355, - 72844.07816305969, - 72865.983685872285, - 72887.890855159596, - 72909.799670674183, - 72931.710132168693, - 72953.622239395845, - 72975.535992108475, - 72997.451390059519, - 73019.368433001961, - 73041.287120688925, - 73063.207452873612, - 73085.129429309294, - 73107.053049749389, - 73128.978313947344, - 73150.905221656736, - 73172.833772631217, - 73194.763966624567, - 73216.695803390612, - 73238.62928268328, - 73260.564404256627, - 73282.501167864757, - 73304.439573261901, - 73326.379620202337, - 73348.321308440485, - 73370.264637730841, - 73392.209607827957, - 73414.156218486532, - 73436.104469461323, - 73458.054360507173, - 73480.005891379056, - 73501.959061831993, - 73523.913871621116, - 73545.870320501665, - 73567.828408228932, - 73589.78813455833, - 73611.749499245358, - 73633.712502045615, - 73655.677142714747, - 73677.643421008557, - 73699.611336682879, - 73721.580889493693, - 73743.552079197019, - 73765.524905548999, - 73787.499368305856, - 73809.475467223907, - 73831.453202059551, - 73853.432572569291, - 73875.413578509717, - 73897.396219637507, - 73919.380495709411, - 73941.36640648231, - 73963.353951713143, - 73985.343131158952, - 74007.333944576865, - 74029.326391724098, - 74051.320472357969, - 74073.316186235883, - 74095.313533115303, - 74117.312512753837, - 74139.313124909138, - 74161.315369338976, - 74183.319245801191, - 74205.324754053727, - 74227.331893854629, - 74249.340664961986, - 74271.351067134034, - 74293.363100129049, - 74315.376763705441, - 74337.392057621662, - 74359.408981636298, - 74381.427535508003, - 74403.447718995507, - 74425.469531857671, - 74447.492973853383, - 74469.518044741693, - 74491.54474428168, - 74513.573072232539, - 74535.603028353551, - 74557.634612404087, - 74579.667824143602, - 74601.702663331642, - 74623.739129727837, - 74645.777223091936, - 74667.816943183716, - 74689.858289763113, - 74711.901262590094, - 74733.945861424741, - 74755.992086027225, - 74778.039936157802, - 74800.089411576817, - 74822.140512044702, - 74844.193237321961, - 74866.24758716923, - 74888.303561347187, - 74910.36115961663, - 74932.420381738411, - 74954.481227473516, - 74976.543696582972, - 74998.607788827925, - 75020.673503969607, - 75042.740841769322, - 75064.809801988464, - 75086.88038438854, - 75108.952588731103, - 75131.026414777836, - 75153.101862290467, - 75175.178931030852, - 75197.257620760924, - 75219.33793124267, - 75241.419862238225, - 75263.503413509738, - 75285.588584819503, - 75307.675375929874, - 75329.763786603318, - 75351.853816602365, - 75373.945465689612, - 75396.038733627807, - 75418.133620179724, - 75440.230125108254, - 75462.32824817636, - 75484.427989147109, - 75506.529347783653, - 75528.63232384919, - 75550.736917107075, - 75572.843127320695, - 75594.950954253538, - 75617.060397669193, - 75639.171457331307, - 75661.284133003646, - 75683.398424450032, - 75705.514331434402, - 75727.631853720741, - 75749.750991073175, - 75771.871743255862, - 75793.994110033076, - 75816.118091169177, - 75838.243686428585, - 75860.370895575848, - 75882.499718375562, - 75904.630154592422, - 75926.762203991224, - 75948.895866336825, - 75971.031141394182, - 75993.168028928325, - 76015.306528704401, - 76037.4466404876, - 76059.588364043215, - 76081.731699136653, - 76103.876645533353, - 76126.023202998884, - 76148.171371298871, - 76170.321150199044, - 76192.472539465205, - 76214.625538863256, - 76236.780148159174, - 76258.936367119008, - 76281.094195508922, - 76303.253633095141, - 76325.414679643975, - 76347.577334921851, - 76369.741598695226, - 76391.907470730686, - 76414.074950794879, - 76436.244038654564, - 76458.414734076548, - 76480.587036827754, - 76502.760946675175, - 76524.936463385893, - 76547.11358672705, - 76569.292316465915, - 76591.472652369819, - 76613.654594206164, - 76635.838141742468, - 76658.023294746308, - 76680.210052985349, - 76702.398416227341, - 76724.588384240138, - 76746.779956791637, - 76768.973133649866, - 76791.167914582897, - 76813.364299358902, - 76835.562287746157, - 76857.761879512967, - 76879.963074427797, - 76902.165872259109, - 76924.37027277553, - 76946.576275745727, - 76968.783880938441, - 76990.993088122515, - 77013.203897066895, - 77035.416307540567, - 77057.630319312622, - 77079.845932152239, - 77102.063145828695, - 77124.281960111301, - 77146.50237476948, - 77168.724389572759, - 77190.948004290723, - 77213.173218693031, - 77235.400032549442, - 77257.628445629802, - 77279.858457704031, - 77302.090068542122, - 77324.323277914169, - 77346.558085590339, - 77368.794491340886, - 77391.032494936138, - 77413.272096146524, - 77435.51329474253, - 77457.756090494731, - 77480.000483173804, - 77502.246472550498, - 77524.494058395634, - 77546.743240480107, - 77568.994018574944, - 77591.246392451198, - 77613.500361880026, - 77635.755926632657, - 77658.013086480438, - 77680.271841194757, - 77702.532190547092, - 77724.794134309021, - 77747.057672252195, - 77769.322804148323, - 77791.589529769248, - 77813.857848886837, - 77836.127761273063, - 77858.399266699998, - 77880.67236493979, - 77902.947055764627, - 77925.223338946831, - 77947.50121425878, - 77969.780681472927, - 77992.061740361838, - 78014.344390698127, - 78036.628632254491, - 78058.914464803747, - 78081.201888118725, - 78103.490901972415, - 78125.781506137821, - 78148.073700388064, - 78170.367484496339, - 78192.662858235926, - 78214.959821380166, - 78237.258373702498, - 78259.558514976452, - 78281.860244975614, - 78304.163563473659, - 78326.468470244363, - 78348.77496506153, - 78371.083047699125, - 78393.392717931114, - 78415.703975531578, - 78438.016820274701, - 78460.331251934695, - 78482.647270285903, - 78504.964875102727, - 78527.284066159627, - 78549.604843231195, - 78571.927206092048, - 78594.251154516911, - 78616.576688280606, - 78638.903807157985, - 78661.232510924034, - 78683.562799353778, - 78705.894672222363, - 78728.228129304945, - 78750.563170376859, - 78772.899795213423, - 78795.238003590101, - 78817.577795282399, - 78839.919170065928, - 78862.262127716356, - 78884.606668009452, - 78906.952790721043, - 78929.300495627045, - 78951.64978250346, - 78974.000651126378, - 78996.353101271932, - 79018.707132716358, - 79041.062745235977, - 79063.41993860717, - 79085.778712606436, - 79108.139067010285, - 79130.501001595389, - 79152.864516138419, - 79175.22961041618, - 79197.596284205531, - 79219.96453728342, - 79242.33436942687, - 79264.705780412987, - 79287.078770018954, - 79309.453338022009, - 79331.829484199508, - 79354.207208328866, - 79376.586510187582, - 79398.967389553218, - 79421.349846203433, - 79443.733879915948, - 79466.119490468584, - 79488.50667763922, - 79510.895441205823, - 79533.285780946433, - 79555.677696639163, - 79578.071188062226, - 79600.466254993895, - 79622.862897212515, - 79645.261114496549, - 79667.660906624471, - 79690.062273374875, - 79712.465214526455, - 79734.869729857935, - 79757.275819148126, - 79779.683482175955, - 79802.092718720378, - 79824.503528560454, - 79846.915911475327, - 79869.329867244203, - 79891.745395646343, - 79914.162496461155, - 79936.581169468045, - 79959.001414446553, - 79981.423231176261, - 80003.846619436852, - 80026.271579008084, - 80048.698109669771, - 80071.12621120183, - 80093.555883384237, - 80115.987125997053, - 80138.419938820414, - 80160.854321634528, - 80183.290274219689, - 80205.727796356281, - 80228.166887824715, - 80250.607548405547, - 80273.049777879336, - 80295.493576026798, - 80317.938942628651, - 80340.385877465727, - 80362.834380318949, - 80385.28445096928, - 80407.736089197788, - 80430.189294785596, - 80452.644067513917, - 80475.100407164035, - 80497.558313517322, - 80520.017786355209, - 80542.478825459213, - 80564.941430610925, - 80587.405601592007, - 80609.871338184195, - 80632.338640169342, - 80654.8075073293, - 80677.277939446067, - 80699.749936301683, - 80722.223497678278, - 80744.698623358039, - 80767.17531312324, - 80789.653566756242, - 80812.133384039465, - 80834.614764755403, - 80857.097708686648, - 80879.582215615854, - 80902.068285325731, - 80924.555917599093, - 80947.045112218824, - 80969.535868967869, - 80992.028187629272, - 81014.522067986123, - 81037.017509821613, - 81059.514512919006, - 81082.013077061609, - 81104.513202032831, - 81127.014887616184, - 81149.518133595193, - 81172.022939753486, - 81194.529305874807, - 81217.037231742899, - 81239.546717141639, - 81262.057761854958, - 81284.570365666848, - 81307.084528361403, - 81329.600249722775, - 81352.117529535186, - 81374.636367582949, - 81397.156763650448, - 81419.678717522125, - 81442.202228982511, - 81464.727297816222, - 81487.253923807933, - 81509.782106742379, - 81532.311846404409, - 81554.843142578902, - 81577.375995050839, - 81599.910403605274, - 81622.446368027333, - 81644.983888102215, - 81667.522963615178, - 81690.063594351581, - 81712.605780096841, - 81735.149520636449, - 81757.694815755967, - 81780.241665241047, - 81802.79006887741, - 81825.340026450824, - 81847.891537747171, - 81870.444602552379, - 81892.999220652477, - 81915.555391833506, - 81938.113115881672, - 81960.672392583176, - 81983.233221724338, - 82005.795603091537, - 82028.359536471224, - 82050.925021649906, - 82073.492058414209, - 82096.060646550788, - 82118.630785846399, - 82141.202476087841, - 82163.775717062032, - 82186.35050855593, - 82208.926850356569, - 82231.504742251054, - 82254.084184026578, - 82276.665175470393, - 82299.24771636985, - 82321.831806512317, - 82344.417445685307, - 82367.004633676348, - 82389.593370273054, - 82412.183655263143, - 82434.775488434374, - 82457.368869574595, - 82479.963798471697, - 82502.560274913689, - 82525.158298688606, - 82547.757869584602, - 82570.35898738986, - 82592.961651892678, - 82615.565862881398, - 82638.171620144421, - 82660.778923470265, - 82683.387772647475, - 82705.998167464713, - 82728.610107710658, - 82751.223593174116, - 82773.83862364394, - 82796.45519890904, - 82819.073318758441, - 82841.692982981185, - 82864.314191366429, - 82886.936943703375, - 82909.561239781324, - 82932.187079389638, - 82954.814462317736, - 82977.443388355125, - 83000.073857291369, - 83022.70586891612, - 83045.339423019104, - 83067.974519390089, - 83090.611157818959, - 83113.249338095629, - 83135.8890600101, - 83158.530323352461, - 83181.173127912858, - 83203.817473481497, - 83226.463359848669, - 83249.11078680474, - 83271.759754140134, - 83294.410261645375, - 83317.062309111003, - 83339.715896327703, - 83362.371023086147, - 83385.027689177165, - 83407.685894391587, - 83430.345638520361, - 83453.006921354478, - 83475.669742685001, - 83498.334102303095, - 83520.999999999942, - 83543.667435566866, - 83566.336408795192, - 83589.006919476349, - 83611.678967401851, - 83634.352552363242, - 83657.027674152167, - 83679.704332560359, - 83702.382527379552, - 83725.062258401638, - 83747.743525418511, - 83770.42632822218, - 83793.110666604684, - 83815.796540358162, - 83838.483949274829, - 83861.172893146941, - 83883.863371766842, - 83906.555384926964, - 83929.248932419752, - 83951.944014037799, - 83974.640629573696, - 83997.338778820151, - 84020.038461569929, - 84042.739677615857, - 84065.442426750829, - 84088.146708767847, - 84110.852523459922, - 84133.559870620171, - 84156.268750041796, - 84178.979161518029, - 84201.691104842204, - 84224.404579807713, - 84247.119586208006, - 84269.83612383662, - 84292.55419248715, - 84315.273791953281, - 84337.994922028738, - 84360.717582507335, - 84383.441773182945, - 84406.167493849513, - 84428.894744301069, - 84451.623524331691, - 84474.353833735542, - 84497.085672306828, - 84519.819039839858, - 84542.553936128999, - 84565.290360968676, - 84588.028314153402, - 84610.767795477717, - 84633.508804736295, - 84656.251341723822, - 84678.995406235073, - 84701.740998064924, - 84724.488117008252, - 84747.236762860062, - 84769.986935415407, - 84792.73863446941, - 84815.491859817252, - 84838.246611254188, - 84861.002888575575, - 84883.760691576768, - 84906.520020053256, - 84929.28087380057, - 84952.043252614312, - 84974.807156290146, - 84997.572584623806, - 85020.339537411113, - 85043.108014447949, - 85065.878015530237, - 85088.649540453989, - 85111.422589015303, - 85134.197161010321, - 85156.973256235244, - 85179.750874486374, - 85202.530015560071, - 85225.310679252725, - 85248.092865360857, - 85270.876573681016, - 85293.661804009811, - 85316.448556143951, - 85339.236829880188, - 85362.026625015351, - 85384.817941346351, - 85407.610778670132, - 85430.405136783724, - 85453.201015484257, - 85475.998414568865, - 85498.797333834795, - 85521.597773079353, - 85544.399732099904, - 85567.203210693886, - 85590.008208658808, - 85612.814725792239, - 85635.62276189182, - 85658.432316755265, - 85681.243390180331, - 85704.055981964877, - 85726.870091906807, - 85749.685719804082, - 85772.502865454764, - 85795.321528656961, - 85818.141709208852, - 85840.963406908675, - 85863.78662155474, - 85886.611352945445, - 85909.437600879217, - 85932.26536515457, - 85955.094645570091, - 85977.92544192441, - 86000.757754016275, - 86023.591581644432, - 86046.426924607746, - 86069.263782705122, - 86092.102155735556, - 86114.942043498071, - 86137.783445791807, - 86160.626362415918, - 86183.470793169676, - 86206.316737852379, - 86229.164196263402, - 86252.013168202204, - 86274.863653468303, - 86297.715651861261, - 86320.569163180728, - 86343.424187226425, - 86366.280723798132, - 86389.138772695675, - 86411.998333718977, - 86434.859406668009, - 86457.721991342827, - 86480.586087543532, - 86503.451695070296, - 86526.318813723352, - 86549.187443303032, - 86572.057583609683, - 86594.929234443756, - 86617.802395605773, - 86640.677066896271, - 86663.553248115903, - 86686.43093906538, - 86709.310139545443, - 86732.190849356964, - 86755.073068300815, - 86777.956796177954, - 86800.842032789442, - 86823.728777936354, - 86846.617031419853, - 86869.506793041175, - 86892.398062601613, - 86915.290839902518, - 86938.185124745316, - 86961.080916931489, - 86983.978216262592, - 87006.87702254027, - 87029.777335566177, - 87052.67915514209, - 87075.582481069796, - 87098.487313151185, - 87121.39365118822, - 87144.301494982894, - 87167.210844337285, - 87190.121699053532, - 87213.034058933845, - 87235.947923780506, - 87258.863293395829, - 87281.780167582241, - 87304.698546142172, - 87327.618428878181, - 87350.539815592856, - 87373.462706088845, - 87396.387100168897, - 87419.312997635774, - 87442.240398292357, - 87465.16930194154, - 87488.099708386319, - 87511.031617429733, - 87533.965028874911, - 87556.899942525008, - 87579.836358183282, - 87602.774275653021, - 87625.713694737613, - 87648.654615240492, - 87671.597036965148, - 87694.540959715145, - 87717.486383294105, - 87740.433307505737, - 87763.381732153779, - 87786.331657042057, - 87809.283081974456, - 87832.236006754916, - 87855.190431187453, - 87878.146355076155, - 87901.103778225151, - 87924.062700438633, - 87947.023121520891, - 87969.985041276246, - 87992.948459509105, - 88015.913376023906, - 88038.879790625171, - 88061.847703117513, - 88084.817113305573, - 88107.788020994049, - 88130.760425987726, - 88153.734328091465, - 88176.709727110137, - 88199.686622848749, - 88222.665015112303, - 88245.644903705906, - 88268.626288434709, - 88291.609169103947, - 88314.593545518903, - 88337.579417484914, - 88360.566784807408, - 88383.555647291854, - 88406.546004743795, - 88429.537856968818, - 88452.531203772611, - 88475.52604496089, - 88498.522380339447, - 88521.52020971413, - 88544.519532890874, - 88567.520349675644, - 88590.522659874507, - 88613.526463293543, - 88636.531759738922, - 88659.538549016899, - 88682.546830933745, - 88705.556605295846, - 88728.567871909589, - 88751.580630581491, - 88774.594881118086, - 88797.610623325963, - 88820.62785701183, - 88843.646581982393, - 88866.666798044462, - 88889.688505004888, - 88912.711702670611, - 88935.7363908486, - 88958.762569345898, - 88981.790237969632, - 89004.81939652696, - 89027.850044825114, - 89050.882182671412, - 89073.9158098732, - 89096.950926237885, - 89119.987531572973, - 89143.025625686001, - 89166.065208384563, - 89189.106279476357, - 89212.148838769106, - 89235.192886070581, - 89258.238421188667, - 89281.285443931265, - 89304.333954106376, - 89327.383951522017, - 89350.435435986306, - 89373.488407307406, - 89396.542865293537, - 89419.598809753006, - 89442.656240494165, - 89465.715157325409, - 89488.775560055219, - 89511.837448492137, - 89534.900822444746, - 89557.965681721733, - 89581.032026131812, - 89604.099855483742, - 89627.169169586399, - 89650.239968248672, - 89673.312251279538, - 89696.386018488018, - 89719.461269683205, - 89742.53800467425, - 89765.616223270365, - 89788.69592528083, - 89811.777110514988, - 89834.859778782207, - 89857.943929891975, - 89881.029563653807, - 89904.116679877261, - 89927.205278372014, - 89950.29535894774, - 89973.386921414218, - 89996.479965581268, - 90019.574491258769, - 90042.670498256688, - 90065.767986385021, - 90088.866955453836, - 90111.967405273259, - 90135.069335653476, - 90158.172746404758, - 90181.277637337407, - 90204.384008261797, - 90227.49185898836, - 90250.601189327586, - 90273.711999090039, - 90296.824288086325, - 90319.938056127125, - 90343.053303023189, - 90366.170028585286, - 90389.288232624298, - 90412.407914951138, - 90435.529075376777, - 90458.651713712257, - 90481.775829768681, - 90504.901423357209, - 90528.028494289058, - 90551.157042375504, - 90574.287067427911, - 90597.418569257643, - 90620.551547676194, - 90643.686002495073, - 90666.821933525847, - 90689.959340580186, - 90713.098223469773, - 90736.238582006365, - 90759.380416001804, - 90782.523725267951, - 90805.668509616764, - 90828.814768860233, - 90851.962502810435, - 90875.11171127946, - 90898.262394079517, - 90921.414551022855, - 90944.568181921743, - 90967.72328658856, - 90990.879864835719, - 91014.037916475718, - 91037.19744132107, - 91060.358439184391, - 91083.520909878338, - 91106.684853215629, - 91129.850269009039, - 91153.017157071401, - 91176.185517215621, - 91199.355349254649, - 91222.526653001492, - 91245.699428269247, - 91268.873674871036, - 91292.049392620058, - 91315.226581329553, - 91338.405240812834, - 91361.585370883287, - 91384.766971354344, - 91407.950042039476, - 91431.134582752245, - 91454.320593306256, - 91477.508073515171, - 91500.697023192712, - 91523.887442152685, - 91547.07933020893, - 91570.272687175326, - 91593.467512865856, - 91616.663807094534, - 91639.861569675442, - 91663.060800422725, - 91686.261499150554, - 91709.463665673218, - 91732.66729980502, - 91755.872401360321, - 91779.078970153569, - 91802.287005999257, - 91825.49650871192, - 91848.707478106167, - 91871.91991399668, - 91895.133816198169, - 91918.349184525418, - 91941.566018793281, - 91964.784318816659, - 91988.004084410495, - 92011.22531538982, - 92034.448011569708, - 92057.672172765277, - 92080.897798791746, - 92104.124889464365, - 92127.353444598411, - 92150.58346400928, - 92173.814947512379, - 92197.04789492322, - 92220.282306057314, - 92243.518180730272, - 92266.755518757753, - 92289.994319955469, - 92313.234584139194, - 92336.476311124774, - 92359.719500728082, - 92382.964152765067, - 92406.210267051734, - 92429.457843404161, - 92452.706881638471, - 92475.957381570814, - 92499.209343017443, - 92522.462765794655, - 92545.717649718805, - 92568.973994606305, - 92592.231800273614, - 92615.491066537259, - 92638.751793213814, - 92662.01398011994, - 92685.277627072326, - 92708.54273388772, - 92731.809300382942, - 92755.077326374871, - 92778.346811680414, - 92801.617756116568, - 92824.890159500384, - 92848.164021648947, - 92871.439342379424, - 92894.716121509016, - 92917.994358855023, - 92941.274054234746, - 92964.555207465572, - 92987.837818364962, - 93011.121886750407, - 93034.407412439468, - 93057.694395249753, - 93080.982834998955, - 93104.272731504767, - 93127.564084584999, - 93150.856894057491, - 93174.15115974014, - 93197.446881450916, - 93220.744059007804, - 93244.04269222889, - 93267.342780932304, - 93290.644324936235, - 93313.947324058914, - 93337.251778118633, - 93360.557686933767, - 93383.865050322696, - 93407.173868103928, - 93430.484140095941, - 93453.795866117362, - 93477.109045986799, - 93500.423679522952, - 93523.739766544561, - 93547.057306870454, - 93570.376300319491, - 93593.696746710571, - 93617.018645862699, - 93640.341997594893, - 93663.666801726242, - 93686.993058075881, - 93710.320766463032, - 93733.64992670693, - 93756.980538626914, - 93780.312602042337, - 93803.646116772637, - 93826.981082637285, - 93850.317499455836, - 93873.655367047861, - 93896.994685233032, - 93920.335453831038, - 93943.677672661666, - 93967.021341544707, - 93990.366460300051, - 94013.713028747632, - 94037.061046707429, - 94060.410513999494, - 94083.761430443905, - 94107.113795860845, - 94130.467610070496, - 94153.822872893157, - 94177.179584149111, - 94200.537743658759, - 94223.897351242529, - 94247.25840672091, - 94270.620909914433, - 94293.98486064373, - 94317.350258729421, - 94340.71710399224, - 94364.085396252936, - 94387.455135332348, - 94410.82632105134, - 94434.198953230851, - 94457.573031691878, - 94480.948556255447, - 94504.325526742658, - 94527.70394297468, - 94551.083804772716, - 94574.465111958023, - 94597.847864351934, - 94621.232061775823, - 94644.617704051096, - 94668.004790999272, - 94691.393322441872, - 94714.783298200506, - 94738.174718096794, - 94761.567581952477, - 94784.961889589307, - 94808.357640829097, - 94831.754835493703, - 94855.153473405066, - 94878.553554385173, - 94901.955078256055, - 94925.358044839784, - 94948.762453958523, - 94972.168305434476, - 94995.575599089891, - 95018.984334747074, - 95042.394512228391, - 95065.806131356265, - 95089.219191953176, - 95112.633693841635, - 95136.04963684424, - 95159.467020783617, - 95182.885845482466, - 95206.306110763529, - 95229.727816449609, - 95253.150962363579, - 95276.575548328314, - 95300.001574166803, - 95323.429039702052, - 95346.857944757154, - 95370.288289155214, - 95393.720072719429, - 95417.153295273019, - 95440.587956639298, - 95464.024056641589, - 95487.461595103305, - 95510.900571847902, - 95534.340986698866, - 95557.782839479783, - 95581.226130014256, - 95604.670858125959, - 95628.117023638595, - 95651.564626375985, - 95675.013666161918, - 95698.464142820303, - 95721.916056175076, - 95745.369406050231, - 95768.824192269807, - 95792.280414657915, - 95815.738073038709, - 95839.197167236387, - 95862.657697075221, - 95886.11966237954, - 95909.583062973688, - 95933.047898682111, - 95956.514169329268, - 95979.981874739708, - 96003.451014738006, - 96026.921589148798, - 96050.393597796792, - 96073.867040506724, - 96097.341917103375, - 96120.818227411626, - 96144.295971256375, - 96167.775148462577, - 96191.255758855244, - 96214.737802259449, - 96238.221278500292, - 96261.70618740299, - 96285.192528792715, - 96308.680302494788, - 96332.169508334526, - 96355.660146137321, - 96379.152215728609, - 96402.645716933868, - 96426.14064957868, - 96449.637013488609, - 96473.134808489311, - 96496.63403440651, - 96520.134691065963, - 96543.636778293469, - 96567.140295914898, - 96590.645243756153, - 96614.151621643221, - 96637.659429402134, - 96661.168666858954, - 96684.679333839798, - 96708.191430170875, - 96731.70495567839, - 96755.219910188665, - 96778.736293528011, - 96802.254105522836, - 96825.77334599958, - 96849.29401478474, - 96872.816111704873, - 96896.339636586577, - 96919.864589256511, - 96943.390969541389, - 96966.918777267958, - 96990.448012263048, - 97013.978674353522, - 97037.510763366285, - 97061.044279128328, - 97084.579221466673, - 97108.115590208385, - 97131.653385180587, - 97155.19260621049, - 97178.733253125291, - 97202.2753257523, - 97225.81882391886, - 97249.363747452342, - 97272.910096180189, - 97296.457869929916, - 97320.007068529041, - 97343.557691805196, - 97367.109739586012, - 97390.663211699197, - 97414.218107972498, - 97437.774428233737, - 97461.332172310766, - 97484.891340031507, - 97508.451931223899, - 97532.013945715982, - 97555.577383335811, - 97579.142243911512, - 97602.708527271257, - 97626.276233243261, - 97649.845361655811, - 97673.415912337223, - 97696.987885115886, - 97720.561279820206, - 97744.1360962787, - 97767.712334319876, - 97791.289993772341, - 97814.869074464703, - 97838.449576225685, - 97862.031498883996, - 97885.614842268449, - 97909.199606207883, - 97932.785790531183, - 97956.37339506732, - 97979.962419645264, - 98003.552864094076, - 98027.144728242856, - 98050.738011920766, - 98074.332714956996, - 98097.928837180807, - 98121.526378421506, - 98145.125338508456, - 98168.725717271067, - 98192.327514538789, - 98215.930730141132, - 98239.535363907664, - 98263.141415668011, - 98286.748885251814, - 98310.357772488816, - 98333.968077208759, - 98357.579799241488, - 98381.192938416847, - 98404.807494564782, - 98428.42346751524, - 98452.040857098269, - 98475.659663143917, - 98499.27988548232, - 98522.901523943656, - 98546.524578358163, - 98570.149048556093, - 98593.774934367786, - 98617.402235623624, - 98641.030952154048, - 98664.661083789513, - 98688.292630360564, - 98711.925591697771, - 98735.559967631794, - 98759.195757993293, - 98782.832962613014, - 98806.471581321734, - 98830.111613950285, - 98853.753060329575, - 98877.39592029051, - 98901.040193664099, - 98924.68588028138, - 98948.33297997342, - 98971.981492571387, - 98995.63141790645, - 99019.282755809851, - 99042.935506112874, - 99066.589668646877, - 99090.245243243233, - 99113.902229733401, - 99137.560627948857, - 99161.220437721131, - 99184.881658881859, - 99208.544291262631, - 99232.208334695169, - 99255.87378901121, - 99279.540654042547, - 99303.208929621018, - 99326.878615578535, - 99350.549711746993, - 99374.222217958435, - 99397.896134044888, - 99421.571459838422, - 99445.248195171211, - 99468.926339875441, - 99492.605893783344, - 99516.286856727209, - 99539.969228539398, - 99563.653009052287, - 99587.338198098325, - 99611.024795510006, - 99634.712801119866, - 99658.402214760499, - 99682.093036264545, - 99705.785265464699, - 99729.478902193689, - 99753.173946284325, - 99776.870397569437, - 99800.56825588191, - 99824.267521054688, - 99847.968192920773, - 99871.670271313182, - 99895.373756065004, - 99919.078647009388, - 99942.78494397951, - 99966.492646808634, - 99990.20175533001, - 100013.91226937699, - 100037.62418878295, - 100061.33751338134, - 100085.05224300563, - 100108.76837748935, - 100132.4859166661, - 100156.2048603695, - 100179.92520843323, - 100203.64696069101, - 100227.37011697664, - 100251.09467712394, - 100274.82064096678, - 100298.54800833909, - 100322.27677907483, - 100346.00695300807, - 100369.73852997283, - 100393.47150980328, - 100417.20589233354, - 100440.94167739789, - 100464.67886483055, - 100488.41745446586, - 100512.1574461382, - 100535.89883968196, - 100559.64163493161, - 100583.38583172169, - 100607.13142988674, - 100630.87842926137, - 100654.62682968024, - 100678.37663097809, - 100702.12783298964, - 100725.88043554971, - 100749.63443849317, - 100773.38984165489, - 100797.14664486986, - 100820.90484797307, - 100844.66445079957, - 100868.42545318443, - 100892.18785496285, - 100915.95165596998, - 100939.71685604109, - 100963.48345501146, - 100987.25145271645, - 101011.02084899142, - 101034.79164367182, - 101058.56383659317, - 101082.33742759094, - 101106.11241650078, - 101129.88880315828, - 101153.66658739912, - 101177.44576905905, - 101201.22634797383, - 101225.00832397929, - 101248.7916969113, - 101272.57646660579, - 101296.36263289873, - 101320.15019562612, - 101343.93915462404, - 101367.7295097286, - 101391.52126077596, - 101415.31440760233, - 101439.10895004397, - 101462.9048879372, - 101486.70222111834, - 101510.50094942382, - 101534.30107269008, - 101558.10259075361, - 101581.90550345098, - 101605.70981061876, - 101629.5155120936, - 101653.32260771218, - 101677.13109731126, - 101700.9409807276, - 101724.75225779804, - 101748.56492835947, - 101772.37899224881, - 101796.19444930303, - 101820.01129935916, - 101843.82954225427, - 101867.64917782549, - 101891.47020590997, - 101915.29262634492, - 101939.11643896763, - 101962.94164361537, - 101986.76824012553, - 102010.59622833549, - 102034.42560808272, - 102058.25637920471, - 102082.08854153901, - 102105.9220949232, - 102129.75703919494, - 102153.59337419191, - 102177.43109975185, - 102201.27021571253, - 102225.1107219118, - 102248.95261818753, - 102272.79590437764, - 102296.64058032009, - 102320.48664585294, - 102344.33410081422, - 102368.18294504205, - 102392.03317837461, - 102415.88480065008, - 102439.73781170673, - 102463.59221138287, - 102487.44799951684, - 102511.30517594704, - 102535.1637405119, - 102559.02369304992, - 102582.88503339965, - 102606.74776139967, - 102630.61187688859, - 102654.4773797051, - 102678.34426968795, - 102702.21254667587, - 102726.08221050771, - 102749.95326102231, - 102773.8256980586, - 102797.69952145554, - 102821.57473105213, - 102845.45132668741, - 102869.32930820051, - 102893.20867543056, - 102917.08942821674, - 102940.97156639832, - 102964.85508981455, - 102988.73999830478, - 103012.6262917084, - 103036.51396986481, - 103060.40303261351, - 103084.293479794, - 103108.18531124585, - 103132.07852680866, - 103155.97312632212, - 103179.8691096259, - 103203.76647655977, - 103227.66522696352, - 103251.56536067701, - 103275.46687754011, - 103299.36977739276, - 103323.27406007495, - 103347.1797254267, - 103371.0867732881, - 103394.99520349925, - 103418.90501590034, - 103442.81621033157, - 103466.72878663319, - 103490.64274464553, - 103514.55808420894, - 103538.4748051638, - 103562.39290735057, - 103586.31239060973, - 103610.23325478184, - 103634.15549970744, - 103658.07912522719, - 103682.00413118176, - 103705.93051741188, - 103729.85828375829, - 103753.78743006183, - 103777.71795616332, - 103801.64986190372, - 103825.58314712394, - 103849.51781166498, - 103873.4538553679, - 103897.39127807376, - 103921.33007962372, - 103945.27025985894, - 103969.21181862066, - 103993.15475575015, - 104017.0990710887, - 104041.0447644777, - 104064.99183575854, - 104088.94028477269, - 104112.89011136163, - 104136.84131536692, - 104160.79389663014, - 104184.74785499295, - 104208.70319029699, - 104232.65990238401, - 104256.61799109577, - 104280.57745627411, - 104304.53829776087, - 104328.50051539797, - 104352.46410902737, - 104376.42907849104, - 104400.39542363105, - 104424.36314428948, - 104448.33224030846, - 104472.3027115302, - 104496.27455779689, - 104520.24777895081, - 104544.22237483428, - 104568.19834528965, - 104592.17569015936, - 104616.15440928582, - 104640.13450251156, - 104664.1159696791, - 104688.09881063103, - 104712.08302520998, - 104736.06861325864, - 104760.05557461972, - 104784.043909136, - 104808.03361665027, - 104832.0246970054, - 104856.01715004431, - 104880.01097560991, - 104904.00617354522, - 104928.00274369326, - 104952.00068589712, - 104975.99999999993, - 105000.00068584486, - 105024.00274327511, - 105048.00617213396, - 105072.0109722647, - 105096.0171435107, - 105120.02468571534, - 105144.03359872208, - 105168.04388237436, - 105192.05553651576, - 105216.06856098982, - 105240.08295564017, - 105264.09872031047, - 105288.11585484444, - 105312.13435908582, - 105336.1542328784, - 105360.17547606604, - 105384.19808849262, - 105408.22207000206, - 105432.24742043833, - 105456.27413964548, - 105480.30222746753, - 105504.33168374863, - 105528.36250833291, - 105552.39470106458, - 105576.42826178786, - 105600.46319034706, - 105624.49948658649, - 105648.53715035053, - 105672.5761814836, - 105696.61657983017, - 105720.65834523473, - 105744.70147754184, - 105768.7459765961, - 105792.79184224214, - 105816.83907432464, - 105840.88767268835, - 105864.93763717801, - 105888.98896763846, - 105913.04166391456, - 105937.09572585119, - 105961.15115329332, - 105985.20794608595, - 106009.26610407409, - 106033.32562710284, - 106057.38651501729, - 106081.44876766266, - 106105.51238488412, - 106129.57736652695, - 106153.64371243643, - 106177.71142245791, - 106201.78049643678, - 106225.85093421848, - 106249.92273564848, - 106273.99590057228, - 106298.07042883546, - 106322.14632028362, - 106346.22357476239, - 106370.30219211751, - 106394.38217219469, - 106418.46351483969, - 106442.54621989837, - 106466.63028721658, - 106490.71571664025, - 106514.80250801529, - 106538.89066118775, - 106562.98017600364, - 106587.07105230905, - 106611.16328995011, - 106635.25688877302, - 106659.35184862395, - 106683.44816934918, - 106707.54585079502, - 106731.64489280782, - 106755.74529523395, - 106779.84705791986, - 106803.95018071201, - 106828.05466345693, - 106852.16050600118, - 106876.26770819137, - 106900.37626987413, - 106924.48619089619, - 106948.59747110425, - 106972.71011034511, - 106996.82410846559, - 107020.93946531253, - 107045.05618073288, - 107069.17425457356, - 107093.29368668159, - 107117.41447690397, - 107141.53662508781, - 107165.66013108024, - 107189.7849947284, - 107213.91121587952, - 107238.03879438085, - 107262.16773007967, - 107286.29802282334, - 107310.42967245923, - 107334.56267883476, - 107358.69704179741, - 107382.83276119467, - 107406.96983687414, - 107431.10826868335, - 107455.24805646999, - 107479.38920008171, - 107503.53169936626, - 107527.67555417139, - 107551.82076434491, - 107575.96732973469, - 107600.11525018861, - 107624.26452555459, - 107648.41515568066, - 107672.56714041479, - 107696.72047960508, - 107720.87517309963, - 107745.03122074658, - 107769.18862239413, - 107793.34737789053, - 107817.50748708403, - 107841.66894982298, - 107865.83176595572, - 107889.99593533068, - 107914.16145779629, - 107938.32833320105, - 107962.49656139348, - 107986.66614222217, - 108010.83707553572, - 108035.00936118282, - 108059.18299901215, - 108083.35798887245, - 108107.53433061253, - 108131.71202408121, - 108155.89106912735, - 108180.07146559987, - 108204.25321334775, - 108228.43631221994, - 108252.62076206553, - 108276.80656273357, - 108300.99371407321, - 108325.18221593359, - 108349.37206816394, - 108373.56327061349, - 108397.75582313156, - 108421.94972556747, - 108446.1449777706, - 108470.34157959036, - 108494.53953087622, - 108518.73883147769, - 108542.93948124432, - 108567.14148002568, - 108591.34482767139, - 108615.54952403114, - 108639.75556895464, - 108663.96296229165, - 108688.17170389196, - 108712.38179360541, - 108736.59323128188, - 108760.80601677128, - 108785.02014992358, - 108809.23563058881, - 108833.45245861699, - 108857.67063385822, - 108881.89015616261, - 108906.11102538036, - 108930.33324136167, - 108954.55680395682, - 108978.78171301607, - 109003.00796838976, - 109027.23556992831, - 109051.46451748211, - 109075.69481090162, - 109099.92645003737, - 109124.15943473989, - 109148.39376485976, - 109172.62944024763, - 109196.86646075416, - 109221.10482623006, - 109245.34453652608, - 109269.58559149304, - 109293.82799098175, - 109318.07173484311, - 109342.31682292801, - 109366.56325508743, - 109390.81103117237, - 109415.06015103387, - 109439.31061452301, - 109463.56242149093, - 109487.8155717888, - 109512.07006526781, - 109536.3259017792, - 109560.58308117429, - 109584.8416033044, - 109609.1014680209, - 109633.36267517522, - 109657.62522461878, - 109681.88911620311, - 109706.15434977971, - 109730.4209252002, - 109754.68884231619, - 109778.95810097932, - 109803.22870104131, - 109827.50064235389, - 109851.77392476884, - 109876.04854813802, - 109900.32451231324, - 109924.60181714644, - 109948.88046248957, - 109973.1604481946, - 109997.44177411357, - 110021.72444009855, - 110046.00844600165, - 110070.29379167501, - 110094.58047697082, - 110118.86850174134, - 110143.15786583882, - 110167.44856911557, - 110191.74061142397, - 110216.03399261639, - 110240.32871254528, - 110264.62477106311, - 110288.9221680224, - 110313.22090327571, - 110337.52097667565, - 110361.82238807483, - 110386.12513732594, - 110410.42922428172, - 110434.73464879491, - 110459.04141071832, - 110483.34950990479, - 110507.6589462072, - 110531.96971947847, - 110556.28182957157, - 110580.5952763395, - 110604.91005963532, - 110629.22617931209, - 110653.54363522294, - 110677.86242722106, - 110702.18255515963, - 110726.50401889188, - 110750.82681827113, - 110775.1509531507, - 110799.47642338395, - 110823.80322882428, - 110848.13136932514, - 110872.46084474004, - 110896.79165492248, - 110921.12379972603, - 110945.4572790043, - 110969.79209261097, - 110994.12824039967, - 111018.46572222417, - 111042.80453793822, - 111067.14468739564, - 111091.48617045028, - 111115.82898695602, - 111140.1731367668, - 111164.51861973655, - 111188.86543571933, - 111213.21358456917, - 111237.56306614014, - 111261.91388028639, - 111286.26602686207, - 111310.61950572141, - 111334.97431671864, - 111359.33045970804, - 111383.68793454397, - 111408.04674108078, - 111432.40687917286, - 111456.76834867468, - 111481.13114944073, - 111505.49528132551, - 111529.86074418361, - 111554.22753786964, - 111578.59566223821, - 111602.96511714405, - 111627.33590244185, - 111651.7080179864, - 111676.08146363248, - 111700.45623923496, - 111724.8323446487, - 111749.20977972864, - 111773.58854432974, - 111797.96863830699, - 111822.35006151545, - 111846.73281381019, - 111871.11689504632, - 111895.50230507903, - 111919.8890437635, - 111944.27711095495, - 111968.6665065087, - 111993.05723028004, - 112017.44928212435, - 112041.842661897, - 112066.23736945343, - 112090.63340464912, - 112115.03076733962, - 112139.42945738042, - 112163.82947462716, - 112188.23081893545, - 112212.63349016097, - 112237.03748815943, - 112261.44281278658, - 112285.84946389822, - 112310.25744135017, - 112334.66674499828, - 112359.07737469849, - 112383.48933030672, - 112407.90261167898, - 112432.31721867126, - 112456.73315113965, - 112481.15040894024, - 112505.56899192919, - 112529.98889996267, - 112554.41013289688, - 112578.8326905881, - 112603.25657289263, - 112627.68177966679, - 112652.10831076698, - 112676.53616604958, - 112700.96534537108, - 112725.39584858794, - 112749.82767555672, - 112774.26082613398, - 112798.6953001763, - 112823.13109754038, - 112847.56821808286, - 112872.00666166049, - 112896.44642813003, - 112920.88751734827, - 112945.32992917208, - 112969.77366345831, - 112994.21872006389, - 113018.66509884578, - 113043.11279966099, - 113067.56182236652, - 113092.01216681948, - 113116.46383287695, - 113140.9168203961, - 113165.37112923413, - 113189.82675924824, - 113214.28371029573, - 113238.74198223387, - 113263.20157492002, - 113287.66248821157, - 113312.12472196593, - 113336.58827604055, - 113361.05315029295, - 113385.51934458067, - 113409.98685876124, - 113434.45569269233, - 113458.92584623155, - 113483.39731923661, - 113507.87011156522, - 113532.34422307517, - 113556.81965362425, - 113581.2964030703, - 113605.77447127122, - 113630.25385808491, - 113654.73456336933, - 113679.2165869825, - 113703.69992878241, - 113728.18458862718, - 113752.67056637487, - 113777.15786188368, - 113801.64647501177, - 113826.13640561736, - 113850.62765355874, - 113875.12021869418, - 113899.61410088204, - 113924.1092999807, - 113948.60581584855, - 113973.10364834407, - 113997.60279732574, - 114022.1032626521, - 114046.60504418171, - 114071.10814177318, - 114095.61255528514, - 114120.11828457628, - 114144.62532950533, - 114169.13368993104, - 114193.6433657122, - 114218.15435670764, - 114242.66666277625, - 114267.18028377694, - 114291.69521956862, - 114316.21147001031, - 114340.72903496103, - 114365.24791427983, - 114389.7681078258, - 114414.2896154581, - 114438.81243703589, - 114463.33657241837, - 114487.8620214648, - 114512.38878403447, - 114536.91685998671, - 114561.44624918087, - 114585.97695147636, - 114610.5089667326, - 114635.04229480909, - 114659.57693556532, - 114684.11288886084, - 114708.65015455526, - 114733.18873250818, - 114757.72862257928, - 114782.26982462825, - 114806.81233851484, - 114831.35616409882, - 114855.90130123998, - 114880.44774979822, - 114904.99550963337, - 114929.5445806054, - 114954.09496257425, - 114978.64665539992, - 115003.19965894247, - 115027.75397306195, - 115052.30959761847, - 115076.86653247218, - 115101.42477748329, - 115125.984332512, - 115150.54519741859, - 115175.10737206334, - 115199.67085630659, - 115224.23565000873, - 115248.80175303014, - 115273.3691652313, - 115297.93788647266, - 115322.50791661476, - 115347.07925551817, - 115371.65190304347, - 115396.22585905129, - 115420.80112340231, - 115445.37769595724, - 115469.95557657682, - 115494.53476512182, - 115519.11526145306, - 115543.69706543141, - 115568.28017691776, - 115592.86459577303, - 115617.4503218582, - 115642.03735503425, - 115666.62569516223, - 115691.21534210323, - 115715.80629571836, - 115740.39855586876, - 115764.99212241563, - 115789.58699522018, - 115814.18317414368, - 115838.78065904744, - 115863.37944979276, - 115887.97954624105, - 115912.5809482537, - 115937.18365569216, - 115961.78766841792, - 115986.39298629249, - 116010.99960917742, - 116035.60753693432, - 116060.21676942479, - 116084.82730651053, - 116109.43914805322, - 116134.0522939146, - 116158.66674395646, - 116183.2824980406, - 116207.89955602887, - 116232.51791778316, - 116257.13758316539, - 116281.75855203751, - 116306.38082426153, - 116331.00439969949, - 116355.62927821343, - 116380.25545966547, - 116404.88294391775, - 116429.51173083246, - 116454.14182027178, - 116478.77321209799, - 116503.40590617337, - 116528.03990236025, - 116552.67520052097, - 116577.31180051794, - 116601.94970221359, - 116626.5889054704, - 116651.22941015086, - 116675.87121611751, - 116700.51432323294, - 116725.15873135976, - 116749.8044403606, - 116774.45145009817, - 116799.0997604352, - 116823.74937123443, - 116848.40028235866, - 116873.05249367072, - 116897.70600503348, - 116922.36081630984, - 116947.01692736275, - 116971.67433805518, - 116996.33304825013, - 117020.99305781067, - 117045.65436659988, - 117070.31697448085, - 117094.98088131678, - 117119.64608697082, - 117144.31259130624, - 117168.98039418629, - 117193.64949547425, - 117218.31989503348, - 117242.99159272734, - 117267.66458841923, - 117292.33888197262, - 117317.01447325097, - 117341.6913621178, - 117366.36954843666, - 117391.04903207115, - 117415.72981288488, - 117440.41189074152, - 117465.09526550474, - 117489.77993703831, - 117514.46590520597, - 117539.15316987153, - 117563.84173089883, - 117588.53158815173, - 117613.22274149416, - 117637.91519079007, - 117662.60893590341, - 117687.30397669821, - 117712.00031303853, - 117736.69794478847, - 117761.39687181212, - 117786.09709397367, - 117810.7986111373, - 117835.50142316725, - 117860.20552992777, - 117884.91093128319, - 117909.6176270978, - 117934.32561723603, - 117959.03490156225, - 117983.74547994092, - 118008.45735223651, - 118033.17051831353, - 118057.88497803656, - 118082.60073127014, - 118107.31777787894, - 118132.03611772758, - 118156.75575068076, - 118181.47667660323, - 118206.19889535972, - 118230.92240681504, - 118255.64721083404, - 118280.37330728157, - 118305.10069602253, - 118329.82937692189, - 118354.55934984458, - 118379.29061465565, - 118404.02317122012, - 118428.75701940308, - 118453.49215906965, - 118478.22859008498, - 118502.96631231424, - 118527.70532562268, - 118552.44562987552, - 118577.18722493808, - 118601.93011067568, - 118626.67428695368, - 118651.41975363747, - 118676.16651059251, - 118700.91455768423, - 118725.66389477813, - 118750.41452173979, - 118775.16643843475, - 118799.91964472862, - 118824.67414048707, - 118849.42992557574, - 118874.18699986035, - 118898.94536320666, - 118923.70501548045, - 118948.46595654752, - 118973.22818627374, - 118997.99170452499, - 119022.7565111672, - 119047.52260606633, - 119072.28998908834, - 119097.0586600993, - 119121.82861896523, - 119146.59986555226, - 119171.3723997265, - 119196.14622135412, - 119220.92133030134, - 119245.69772643436, - 119270.47540961947, - 119295.25437972297, - 119320.03463661121, - 119344.81618015055, - 119369.5990102074, - 119394.38312664822, - 119419.16852933947, - 119443.95521814766, - 119468.74319293935, - 119493.53245358112, - 119518.32299993958, - 119543.11483188139, - 119567.90794927324, - 119592.70235198183, - 119617.49803987393, - 119642.29501281632, - 119667.09327067583, - 119691.89281331931, - 119716.69364061367, - 119741.49575242582, - 119766.29914862274, - 119791.10382907141, - 119815.90979363887, - 119840.71704219218, - 119865.52557459843, - 119890.33539072477, - 119915.14649043836, - 119939.95887360642, - 119964.77254009615, - 119989.58748977486, - 120014.40372250983, - 120039.22123816841, - 120064.04003661797, - 120088.86011772591, - 120113.6814813597, - 120138.5041273868, - 120163.3280556747, - 120188.15326609099, - 120212.97975850321, - 120237.807532779, - 120262.63658878599, - 120287.46692639188, - 120312.29854546436, - 120337.13144587121, - 120361.9656274802, - 120386.80109015915, - 120411.63783377589, - 120436.47585819835, - 120461.31516329442, - 120486.15574893207, - 120510.99761497928, - 120535.84076130406, - 120560.68518777451, - 120585.53089425867, - 120610.3778806247, - 120635.22614674074, - 120660.07569247499, - 120684.92651769568, - 120709.77862227106, - 120734.63200606944, - 120759.48666895913, - 120784.3426108085, - 120809.19983148595, - 120834.05833085992, - 120858.91810879884, - 120883.77916517125, - 120908.64149984565, - 120933.5051126906, - 120958.37000357473, - 120983.23617236665, - 121008.10361893504, - 121032.97234314861, - 121057.84234487606, - 121082.71362398617, - 121107.58618034775, - 121132.46001382964, - 121157.33512430069, - 121182.21151162982, - 121207.08917568595, - 121231.96811633807, - 121256.84833345517, - 121281.72982690629, - 121306.61259656049, - 121331.49664228689, - 121356.38196395461, - 121381.26856143285, - 121406.15643459078, - 121431.04558329767, - 121455.93600742276, - 121480.82770683538, - 121505.72068140487, - 121530.61493100057, - 121555.51045549192, - 121580.40725474835, - 121605.30532863933, - 121630.20467703436, - 121655.10529980299, - 121680.00719681478, - 121704.91036793934, - 121729.81481304632, - 121754.72053200539, - 121779.62752468624, - 121804.53579095862, - 121829.44533069231, - 121854.3561437571, - 121879.26823002285, - 121904.1815893594, - 121929.09622163669, - 121954.01212672464, - 121978.92930449323, - 122003.84775481246, - 122028.76747755238, - 122053.68847258303, - 122078.61073977455, - 122103.53427899707, - 122128.45909012076, - 122153.38517301581, - 122178.31252755247, - 122203.24115360099, - 122228.17105103172, - 122253.10221971494, - 122278.03465952107, - 122302.96837032049, - 122327.90335198362, - 122352.83960438096, - 122377.777127383, - 122402.71592086025, - 122427.65598468333, - 122452.59731872278, - 122477.53992284928, - 122502.48379693348, - 122527.42894084606, - 122552.37535445779, - 122577.32303763942, - 122602.27199026172, - 122627.22221219557, - 122652.17370331181, - 122677.12646348133, - 122702.08049257506, - 122727.03579046397, - 122751.99235701906, - 122776.95019211136, - 122801.9092956119, - 122826.8696673918, - 122851.83130732219, - 122876.79421527422, - 122901.75839111909, - 122926.72383472799, - 122951.69054597223, - 122976.65852472307, - 123001.62777085182, - 123026.59828422987, - 123051.57006472857, - 123076.54311221937, - 123101.5174265737, - 123126.49300766307, - 123151.46985535898, - 123176.44796953299, - 123201.42735005668, - 123226.40799680166, - 123251.38990963959, - 123276.37308844214, - 123301.35753308103, - 123326.343243428, - 123351.33021935483, - 123376.31846073334, - 123401.30796743535, - 123426.29873933276, - 123451.29077629748, - 123476.28407820144, - 123501.2786449166, - 123526.27447631498, - 123551.27157226863, - 123576.26993264959, - 123601.26955732999, - 123626.27044618195, - 123651.27259907764, - 123676.27601588926, - 123701.28069648903, - 123726.28664074924, - 123751.29384854218, - 123776.30231974016, - 123801.31205421555, - 123826.32305184075, - 123851.33531248817, - 123876.34883603029, - 123901.36362233957, - 123926.37967128855, - 123951.39698274979, - 123976.41555659588, - 124001.43539269941, - 124026.45649093305, - 124051.47885116948, - 124076.50247328142, - 124101.5273571416, - 124126.55350262282, - 124151.58090959788, - 124176.60957793961, - 124201.63950752091, - 124226.67069821467, - 124251.70314989384, - 124276.73686243138, - 124301.7718357003, - 124326.80806957364, - 124351.84556392446, - 124376.88431862585, - 124401.92433355095, - 124426.96560857294, - 124452.00814356498, - 124477.05193840031, - 124502.0969929522, - 124527.14330709392, - 124552.19088069882, - 124577.23971364023, - 124602.28980579154, - 124627.34115702618, - 124652.3937672176, - 124677.44763623926, - 124702.50276396469, - 124727.55915026742, - 124752.61679502104, - 124777.67569809916, - 124802.73585937542, - 124827.79727872348, - 124852.85995601704, - 124877.92389112986, - 124902.98908393568, - 124928.05553430831, - 124953.1232421216, - 124978.19220724938, - 125003.26242956554, - 125028.33390894404, - 125053.40664525882, - 125078.48063838384, - 125103.55588819318, - 125128.63239456083, - 125153.71015736091, - 125178.78917646752, - 125203.86945175481, - 125228.95098309696, - 125254.03377036817, - 125279.1178134427, - 125304.20311219479, - 125329.28966649878, - 125354.37747622898, - 125379.46654125977, - 125404.55686146552, - 125429.6484367207, - 125454.74126689974, - 125479.83535187715, - 125504.93069152744, - 125530.02728572517, - 125555.12513434493, - 125580.22423726133, - 125605.32459434902, - 125630.4262054827, - 125655.52907053704, - 125680.63318938682, - 125705.73856190679, - 125730.84518797178, - 125755.9530674566, - 125781.06220023613, - 125806.17258618528, - 125831.28422517896, - 125856.39711709213, - 125881.51126179981, - 125906.62665917698, - 125931.74330909875, - 125956.86121144016, - 125981.98036607634, - 126007.10077288245, - 126032.22243173365, - 126057.34534250517, - 126082.46950507225, - 126107.59491931014, - 126132.72158509417, - 126157.84950229966, - 126182.97867080198, - 126208.10909047653, - 126233.24076119871, - 126258.37368284403, - 126283.50785528794, - 126308.64327840599, - 126333.77995207369, - 126358.91787616667, - 126384.0570505605, - 126409.19747513086, - 126434.3391497534, - 126459.48207430386, - 126484.62624865794, - 126509.77167269142, - 126534.9183462801, - 126560.06626929982, - 126585.21544162642, - 126610.36586313581, - 126635.51753370393, - 126660.67045320668, - 126685.82462152008, - 126710.98003852014, - 126736.13670408291, - 126761.29461808444, - 126786.45378040087, - 126811.61419090834, - 126836.77584948298, - 126861.93875600102, - 126887.10291033868, - 126912.26831237224, - 126937.43496197795, - 126962.60285903217, - 126987.77200341123, - 127012.94239499152, - 127038.11403364947, - 127063.2869192615, - 127088.46105170409, - 127113.63643085376, - 127138.81305658702, - 127163.99092878048, - 127189.17004731069, - 127214.35041205429, - 127239.53202288797, - 127264.71487968838, - 127289.89898233226, - 127315.08433069635, - 127340.27092465744, - 127365.45876409234, - 127390.64784887788, - 127415.83817889093, - 127441.02975400841, - 127466.22257410725, - 127491.41663906439, - 127516.61194875685, - 127541.80850306165, - 127567.00630185583, - 127592.20534501647, - 127617.4056324207, - 127642.60716394568, - 127667.80993946856, - 127693.01395886653, - 127718.21922201688, - 127743.42572879682, - 127768.63347908368, - 127793.84247275478, - 127819.05270968749, - 127844.26418975917, - 127869.47691284724, - 127894.69087882918, - 127919.90608758242, - 127945.12253898452, - 127970.34023291297, - 127995.55916924537, - 128020.77934785932, - 128046.00076863244, - 128071.22343144237, - 128096.44733616684, - 128121.67248268353, - 128146.89887087021, - 128172.12650060465, - 128197.35537176467, - 128222.5854842281, - 128247.81683787282, - 128273.04943257671, - 128298.28326821771, - 128323.51834467379, - 128348.75466182294, - 128373.99221954317, - 128399.23101771252, - 128424.47105620909, - 128449.71233491098, - 128474.95485369631, - 128500.19861244329, - 128525.44361103009, - 128550.68984933494, - 128575.93732723613, - 128601.18604461191, - 128626.43600134061, - 128651.68719730059, - 128676.93963237021, - 128702.1933064279, - 128727.44821935208, - 128752.70437102125, - 128777.96176131385, - 128803.22039010846, - 128828.48025728362, - 128853.74136271792, - 128879.00370628996, - 128904.26728787841, - 128929.53210736193, - 128954.79816461923, - 128980.06545952905, - 129005.33399197015, - 129030.60376182134, - 129055.87476896142, - 129081.14701326926, - 129106.42049462376, - 129131.6952129038, - 129156.97116798835, - 129182.24835975636, - 129207.52678808685, - 129232.80645285884, - 129258.08735395141, - 129283.36949124365, - 129308.65286461466, - 129333.9374739436, - 129359.22331910966, - 129384.51039999202, - 129409.79871646997, - 129435.08826842274, - 129460.37905572963, - 129485.67107826998, - 129510.96433592314, - 129536.25882856851, - 129561.55455608548, - 129586.85151835352, - 129612.14971525209, - 129637.4491466607, - 129662.74981245887, - 129688.0517125262, - 129713.35484674224, - 129738.65921498663, - 129763.96481713903, - 129789.27165307909, - 129814.57972268655, - 129839.88902584116, - 129865.19956242264, - 129890.51133231082, - 129915.82433538554, - 129941.13857152662, - 129966.45404061397, - 129991.7707425275, - 130017.08867714716, - 130042.4078443529, - 130067.72824402474, - 130093.04987604271, - 130118.37274028687, - 130143.69683663732, - 130169.02216497416, - 130194.34872517755, - 130219.67651712766, - 130245.0055407047, - 130270.33579578891, - 130295.66728226055, - 130320.99999999991, - 130346.33394888733, - 130371.66912880314, - 130397.00553962773, - 130422.34318124152, - 130447.68205352494, - 130473.02215635845, - 130498.36348962256, - 130523.70605319779, - 130549.0498469647, - 130574.39487080388, - 130599.74112459592, - 130625.08860822149, - 130650.43732156123, - 130675.78726449587, - 130701.13843690613, - 130726.49083867275, - 130751.84446967654, - 130777.19932979831, - 130802.5554189189, - 130827.91273691918, - 130853.27128368006, - 130878.63105908247, - 130903.99206300738, - 130929.35429533575, - 130954.71775594862, - 130980.08244472703, - 131005.44836155206, - 131030.81550630482, - 131056.18387886642, - 131081.55347911804, - 131106.92430694087, - 131132.29636221612, - 131157.66964482504, - 131183.0441546489, - 131208.41989156904, - 131233.79685546676, - 131259.17504622342, - 131284.55446372041, - 131309.93510783918, - 131335.31697846117, - 131360.70007546784, - 131386.0843987407, - 131411.46994816128, - 131436.85672361116, - 131462.24472497194, - 131487.63395212521, - 131513.02440495262, - 131538.41608333588, - 131563.80898715663, - 131589.2031162967, - 131614.59847063778, - 131639.9950500617, - 131665.39285445024, - 131690.79188368531, - 131716.19213764873, - 131741.59361622241, - 131766.99631928833, - 131792.40024672839, - 131817.80539842462, - 131843.21177425905, - 131868.61937411371, - 131894.02819787065, - 131919.43824541202, - 131944.84951661993, - 131970.26201137656, - 131995.67572956407, - 132021.09067106468, - 132046.50683576067, - 132071.9242235343, - 132097.34283426782, - 132122.76266784366, - 132148.1837241441, - 132173.60600305157, - 132199.02950444847, - 132224.45422821722, - 132249.88017424036, - 132275.30734240031, - 132300.73573257966, - 132326.16534466096, - 132351.59617852676, - 132377.02823405969, - 132402.46151114244, - 132427.89600965759, - 132453.33172948789, - 132478.76867051609, - 132504.20683262491, - 132529.64621569714, - 132555.08681961559, - 132580.5286442631, - 132605.97168952253, - 132631.41595527678, - 132656.86144140881, - 132682.30814780149, - 132707.75607433787, - 132733.20522090094, - 132758.65558737374, - 132784.10717363929, - 132809.55997958075, - 132835.01400508118, - 132860.46925002377, - 132885.92571429166, - 132911.38339776811, - 132936.84230033628, - 132962.30242187946, - 132987.76376228096, - 133013.22632142407, - 133038.69009919214, - 133064.15509546854, - 133089.62131013666, - 133115.08874307995, - 133140.55739418184, - 133166.02726332581, - 133191.49835039541, - 133216.97065527414, - 133242.44417784561, - 133267.91891799335, - 133293.39487560102, - 133318.87205055228, - 133344.35044273079, - 133369.83005202023, - 133395.31087830439, - 133420.79292146701, - 133446.27618139185, - 133471.76065796276, - 133497.24635106357, - 133522.73326057816, - 133548.22138639039, - 133573.71072838426, - 133599.20128644365, - 133624.69306045261, - 133650.1860502951, - 133675.68025585517, - 133701.1756770169, - 133726.67231366437, - 133752.17016568172, - 133777.66923295305, - 133803.16951536259, - 133828.67101279454, - 133854.17372513309, - 133879.67765226253, - 133905.18279406714, - 133930.68915043125, - 133956.19672123916, - 133981.70550637526, - 134007.21550572399, - 134032.7267191697, - 134058.23914659687, - 134083.75278789, - 134109.26764293358, - 134134.78371161217, - 134160.30099381026, - 134185.8194894125, - 134211.33919830353, - 134236.8601203679, - 134262.38225549037, - 134287.90560355558, - 134313.43016444831, - 134338.95593805326, - 134364.48292425525, - 134390.01112293909, - 134415.54053398955, - 134441.07115729159, - 134466.60299273001, - 134492.1360401898, - 134517.67029955584, - 134543.20577071316, - 134568.74245354676, - 134594.28034794159, - 134619.81945378278, - 134645.35977095537, - 134670.90129934452, - 134696.4440388353, - 134721.98798931291, - 134747.53315066252, - 134773.07952276937, - 134798.62710551871, - 134824.17589879577, - 134849.72590248589, - 134875.27711647438, - 134900.82954064661, - 134926.38317488792, - 134951.93801908373, - 134977.49407311951, - 135003.05133688069, - 135028.60981025276, - 135054.16949312127, - 135079.73038537172, - 135105.29248688967, - 135130.85579756077, - 135156.42031727062, - 135181.98604590484, - 135207.55298334916, - 135233.12112948924, - 135258.69048421088, - 135284.26104739975, - 135309.83281894168, - 135335.4057987225, - 135360.97998662802, - 135386.55538254412, - 135412.13198635669, - 135437.70979795168, - 135463.28881721498, - 135488.86904403262, - 135514.45047829056, - 135540.03311987486, - 135565.61696867159, - 135591.20202456677, - 135616.78828744654, - 135642.37575719706, - 135667.96443370447, - 135693.55431685498, - 135719.14540653475, - 135744.73770263011, - 135770.33120502727, - 135795.92591361253, - 135821.52182827223, - 135847.11894889272, - 135872.7172753604, - 135898.31680756161, - 135923.91754538284, - 135949.51948871053, - 135975.12263743114, - 136000.72699143123, - 136026.33255059729, - 136051.93931481591, - 136077.54728397369, - 136103.15645795723, - 136128.76683665317, - 136154.37841994822, - 136179.99120772901, - 136205.60519988232, - 136231.2203962949, - 136256.83679685349, - 136282.45440144493, - 136308.07320995603, - 136333.69322227367, - 136359.31443828469, - 136384.93685787608, - 136410.56048093468, - 136436.18530734754, - 136461.81133700156, - 136487.43856978384, - 136513.06700558143, - 136538.6966442813, - 136564.32748577066, - 136589.95952993655, - 136615.59277666616, - 136641.22722584667, - 136666.86287736523, - 136692.49973110916, - 136718.13778696564, - 136743.77704482197, - 136769.41750456547, - 136795.05916608346, - 136820.70202926331, - 136846.34609399244, - 136871.99136015819, - 136897.63782764805, - 136923.28549634948, - 136948.93436614997, - 136974.58443693706, - 137000.23570859825, - 137025.88818102115, - 137051.54185409332, - 137077.19672770242, - 137102.85280173609, - 137128.51007608202, - 137154.16855062786, - 137179.82822526142, - 137205.48909987041, - 137231.15117434258, - 137256.8144485658, - 137282.47892242789, - 137308.14459581667, - 137333.81146862009, - 137359.47954072602, - 137385.14881202241, - 137410.81928239719, - 137436.49095173844, - 137462.16381993407, - 137487.83788687221, - 137513.51315244089, - 137539.18961652822, - 137564.86727902229, - 137590.54613981131, - 137616.22619878338, - 137641.90745582676, - 137667.58991082967, - 137693.27356368033, - 137718.95841426702, - 137744.64446247809, - 137770.33170820182, - 137796.02015132661, - 137821.70979174081, - 137847.40062933284, - 137873.09266399115, - 137898.78589560417, - 137924.48032406042, - 137950.17594924837, - 137975.8727710566, - 138001.57078937365, - 138027.27000408815, - 138052.97041508864, - 138078.67202226384, - 138104.3748255024, - 138130.07882469296, - 138155.78401972432, - 138181.49041048516, - 138207.1979968643, - 138232.9067787505, - 138258.61675603263, - 138284.32792859949, - 138310.04029633995, - 138335.75385914298, - 138361.46861689744, - 138387.18456949232, - 138412.90171681659, - 138438.62005875923, - 138464.33959520931, - 138490.06032605586, - 138515.78225118798, - 138541.50537049473, - 138567.2296838653, - 138592.95519118884, - 138618.68189235451, - 138644.40978725153, - 138670.13887576913, - 138695.86915779658, - 138721.60063322316, - 138747.33330193823, - 138773.06716383106, - 138798.80221879104, - 138824.53846670757, - 138850.27590747006, - 138876.01454096794, - 138901.7543670907, - 138927.49538572782, - 138953.2375967688, - 138978.9810001032, - 139004.72559562061, - 139030.47138321059, - 139056.2183627628, - 139081.96653416683, - 139107.71589731239, - 139133.46645208917, - 139159.21819838689, - 139184.97113609532, - 139210.72526510421, - 139236.48058530336, - 139262.23709658257, - 139287.99479883176, - 139313.75369194071, - 139339.51377579942, - 139365.27505029776, - 139391.03751532568, - 139416.80117077316, - 139442.56601653024, - 139468.33205248689, - 139494.09927853322, - 139519.86769455927, - 139545.63730045516, - 139571.408096111, - 139597.18008141697, - 139622.95325626322, - 139648.72762054001, - 139674.5031741375, - 139700.27991694602, - 139726.05784885579, - 139751.83696975713, - 139777.61727954043, - 139803.39877809596, - 139829.18146531415, - 139854.96534108539, - 139880.75040530015, - 139906.53665784886, - 139932.32409862199, - 139958.11272751007, - 139983.90254440365, - 140009.69354919327, - 140035.48574176949, - 140061.27912202294, - 140087.07368984428, - 140112.86944512415, - 140138.66638775321, - 140164.4645176222, - 140190.26383462184, - 140216.06433864293, - 140241.86602957622, - 140267.66890731253, - 140293.47297174268, - 140319.27822275754, - 140345.08466024802, - 140370.89228410498, - 140396.70109421943, - 140422.51109048226, - 140448.32227278448, - 140474.13464101712, - 140499.94819507122, - 140525.76293483781, - 140551.57886020801, - 140577.3959710729, - 140603.21426732364, - 140629.03374885136, - 140654.85441554731, - 140680.67626730262, - 140706.49930400858, - 140732.32352555645, - 140758.1489318375, - 140783.97552274304, - 140809.80329816442, - 140835.63225799298, - 140861.46240212015, - 140887.29373043729, - 140913.12624283586, - 140938.95993920733, - 140964.79481944317, - 140990.63088343487, - 141016.46813107401, - 141042.30656225214, - 141068.14617686081, - 141093.98697479168, - 141119.82895593636, - 141145.6721201865, - 141171.51646743377, - 141197.36199756994, - 141223.20871048668, - 141249.05660607578, - 141274.90568422904, - 141300.75594483822, - 141326.6073877952, - 141352.4600129918, - 141378.31382031992, - 141404.16880967148, - 141430.02498093838, - 141455.8823340126, - 141481.74086878612, - 141507.60058515094, - 141533.46148299909, - 141559.32356222265, - 141585.18682271364, - 141611.05126436421, - 141636.9168870665, - 141662.78369071262, - 141688.65167519479, - 141714.5208404052, - 141740.39118623605, - 141766.26271257963, - 141792.1354193282, - 141818.00930637406, - 141843.88437360956, - 141869.760620927, - 141895.6380482188, - 141921.51665537735, - 141947.39644229505, - 141973.27740886438, - 141999.15955497778, - 142025.04288052776, - 142050.92738540689, - 142076.81306950765, - 142102.69993272264, - 142128.58797494444, - 142154.47719606571, - 142180.36759597904, - 142206.25917457714, - 142232.15193175265, - 142258.04586739838, - 142283.94098140698, - 142309.83727367126, - 142335.73474408401, - 142361.63339253806, - 142387.5332189262, - 142413.43422314132, - 142439.33640507635, - 142465.23976462413, - 142491.14430167765, - 142517.05001612983, - 142542.95690787368, - 142568.86497680223, - 142594.77422280848, - 142620.68464578551, - 142646.5962456264, - 142672.50902222423, - 142698.42297547215, - 142724.33810526333, - 142750.25441149093, - 142776.17189404817, - 142802.09055282827, - 142828.01038772447, - 142853.93139863008, - 142879.85358543837, - 142905.77694804268, - 142931.70148633636, - 142957.62720021277, - 142983.55408956532, - 143009.48215428743, - 143035.41139427255, - 143061.34180941415, - 143087.27339960571, - 143113.20616474075, - 143139.14010471283, - 143165.07521941551, - 143191.01150874238, - 143216.94897258704, - 143242.88761084314, - 143268.82742340435, - 143294.76841016437, - 143320.71057101688, - 143346.65390585564, - 143372.59841457437, - 143398.54409706692, - 143424.49095322701, - 143450.43898294857, - 143476.38818612538, - 143502.33856265133, - 143528.29011242036, - 143554.24283532638, - 143580.19673126334, - 143606.1518001252, - 143632.10804180597, - 143658.06545619969, - 143684.02404320039, - 143709.98380270213, - 143735.944734599, - 143761.90683878519, - 143787.87011515474, - 143813.83456360188, - 143839.8001840208, - 143865.76697630569, - 143891.73494035081, - 143917.7040760504, - 143943.67438329876, - 143969.6458619902, - 143995.61851201905, - 144021.59233327967, - 144047.56732566646, - 144073.54348907378, - 144099.52082339607, - 144125.49932852783, - 144151.4790043635, - 144177.45985079758, - 144203.44186772458, - 144229.42505503909, - 144255.40941263564, - 144281.39494040885, - 144307.38163825331, - 144333.36950606373, - 144359.35854373468, - 144385.34875116093, - 144411.34012823718, - 144437.33267485813, - 144463.32639091855, - 144489.32127631325, - 144515.31733093705, - 144541.31455468474, - 144567.3129474512, - 144593.3125091313, - 144619.31323961995, - 144645.31513881206, - 144671.31820660262, - 144697.32244288657, - 144723.32784755889, - 144749.33442051467, - 144775.34216164888, - 144801.35107085665, - 144827.36114803303, - 144853.37239307314, - 144879.38480587213, - 144905.39838632516, - 144931.41313432742, - 144957.4290497741, - 144983.44613256046, - 145009.46438258173, - 145035.48379973322, - 145061.50438391021, - 145087.52613500805, - 145113.54905292206, - 145139.57313754765, - 145165.59838878017, - 145191.62480651509, - 145217.65239064783, - 145243.68114107384, - 145269.71105768863, - 145295.74214038774, - 145321.77438906668, - 145347.80780362099, - 145373.84238394629, - 145399.87812993818, - 145425.91504149229, - 145451.95311850426, - 145477.9923608698, - 145504.03276848458, - 145530.07434124436, - 145556.11707904484, - 145582.16098178181, - 145608.20604935108, - 145634.25228164849, - 145660.29967856981, - 145686.34824001096, - 145712.39796586783, - 145738.4488560363, - 145764.50091041232, - 145790.55412889185, - 145816.60851137087, - 145842.66405774537, - 145868.72076791141, - 145894.77864176501, - 145920.83767920226, - 145946.89788011924, - 145972.95924441208, - 145999.02177197693, - 146025.08546270995, - 146051.15031650732, - 146077.21633326527, - 146103.28351288004, - 146129.35185524789, - 146155.42136026506, - 146181.49202782792, - 146207.56385783272, - 146233.63685017588, - 146259.71100475377, - 146285.78632146274, - 146311.86280019928, - 146337.94044085976, - 146364.01924334071, - 146390.09920753856, - 146416.18033334985, - 146442.26262067116, - 146468.34606939898, - 146494.43067942993, - 146520.51645066062, - 146546.60338298764, - 146572.69147630769, - 146598.78073051744, - 146624.87114551352, - 146650.96272119274, - 146677.05545745179, - 146703.14935418745, - 146729.2444112965, - 146755.34062867577, - 146781.43800622207, - 146807.53654383228, - 146833.63624140329, - 146859.73709883197, - 146885.83911601527, - 146911.94229285014, - 146938.04662923355, - 146964.15212506248, - 146990.25878023397, - 147016.36659464505, - 147042.47556819281, - 147068.58570077427, - 147094.6969922866, - 147120.80944262692, - 147146.92305169237, - 147173.03781938017, - 147199.15374558745, - 147225.27083021149, - 147251.38907314953, - 147277.50847429881, - 147303.62903355664, - 147329.75075082036, - 147355.87362598727, - 147381.99765895473, - 147408.12284962015, - 147434.24919788091, - 147460.37670363448, - 147486.50536677826, - 147512.63518720976, - 147538.76616482646, - 147564.89829952587, - 147591.03159120557, - 147617.16603976308, - 147643.30164509601, - 147669.43840710199, - 147695.57632567859, - 147721.71540072354, - 147747.85563213445, - 147773.99701980909, - 147800.13956364512, - 147826.28326354033, - 147852.42811939248, - 147878.57413109933, - 147904.72129855872, - 147930.86962166851, - 147957.01910032652, - 147983.16973443062, - 148009.32152387875, - 148035.47446856883, - 148061.62856839882, - 148087.78382326665, - 148113.94023307035, - 148140.09779770792, - 148166.25651707739, - 148192.41639107687, - 148218.57741960438, - 148244.73960255808, - 148270.90293983606, - 148297.0674313365, - 148323.23307695755, - 148349.39987659742, - 148375.56783015432, - 148401.73693752653, - 148427.90719861226, - 148454.07861330983, - 148480.25118151752, - 148506.42490313368, - 148532.59977805667, - 148558.77580618486, - 148584.95298741665, - 148611.13132165043, - 148637.31080878471, - 148663.49144871789, - 148689.6732413485, - 148715.85618657502, - 148742.040284296, - 148768.22553440998, - 148794.41193681557, - 148820.59949141133, - 148846.78819809589, - 148872.97805676793, - 148899.16906732606, - 148925.36122966901, - 148951.55454369547, - 148977.74900930419, - 149003.9446263939, - 149030.1413948634, - 149056.33931461151, - 149082.53838553699, - 149108.73860753875, - 149134.9399805156, - 149161.14250436646, - 149187.34617899026, - 149213.5510042859, - 149239.75698015234, - 149265.96410648854, - 149292.17238319354, - 149318.38181016635, - 149344.59238730598, - 149370.80411451156, - 149397.01699168212, - 149423.23101871679, - 149449.44619551473, - 149475.66252197503, - 149501.87999799693, - 149528.0986234796, - 149554.31839832227, - 149580.53932242419, - 149606.76139568459, - 149632.98461800278, - 149659.20898927809, - 149685.43450940982, - 149711.66117829733, - 149737.88899584001, - 149764.11796193724, - 149790.34807648844, - 149816.57933939309, - 149842.81175055061, - 149869.04530986046, - 149895.28001722222, - 149921.51587253538, - 149947.75287569952, - 149973.99102661415, - 150000.23032517891, - 150026.47077129342, - 150052.71236485732, - 150078.95510577026, - 150105.1989939319, - 150131.444029242, - 150157.69021160025, - 150183.93754090639, - 150210.18601706024, - 150236.43563996154, - 150262.68640951012, - 150288.93832560582, - 150315.19138814852, - 150341.44559703805, - 150367.70095217437, - 150393.95745345735, - 150420.21510078697, - 150446.47389406321, - 150472.73383318601, - 150498.99491805542, - 150525.25714857146, - 150551.52052463419, - 150577.78504614369, - 150604.05071300003, - 150630.31752510337, - 150656.58548235384, - 150682.85458465159, - 150709.1248318968, - 150735.39622398972, - 150761.66876083051, - 150787.9424423195, - 150814.21726835691, - 150840.49323884305, - 150866.77035367821, - 150893.04861276277, - 150919.32801599705, - 150945.60856328148, - 150971.89025451642, - 150998.17308960229, - 151024.45706843957, - 151050.74219092872, - 151077.02845697021, - 151103.31586646455, - 151129.60441931229, - 151155.894115414, - 151182.1849546702, - 151208.47693698155, - 151234.77006224863, - 151261.06433037209, - 151287.35974125259, - 151313.65629479082, - 151339.95399088747, - 151366.25282944329, - 151392.55281035902, - 151418.85393353543, - 151445.1561988733, - 151471.45960627345, - 151497.76415563675, - 151524.06984686397, - 151550.37667985607, - 151576.68465451393, - 151602.99377073845, - 151629.30402843058, - 151655.61542749128, - 151681.92796782157, - 151708.24164932242, - 151734.55647189484, - 151760.87243543993, - 151787.18953985872, - 151813.50778505235, - 151839.82717092187, - 151866.14769736846, - 151892.46936429327, - 151918.79217159748, - 151945.11611918229, - 151971.44120694889, - 151997.76743479856, - 152024.09480263255, - 152050.42331035214, - 152076.75295785864, - 152103.08374505339, - 152129.41567183775, - 152155.74873811303, - 152182.08294378067, - 152208.41828874208, - 152234.75477289871, - 152261.09239615197, - 152287.43115840337, - 152313.77105955439, - 152340.11209950657, - 152366.45427816146, - 152392.79759542056, - 152419.14205118554, - 152445.48764535793, - 152471.8343778394, - 152498.18224853161, - 152524.53125733617, - 152550.88140415482, - 152577.23268888926, - 152603.58511144121, - 152629.93867171241, - 152656.29336960468, - 152682.64920501978, - 152709.00617785956, - 152735.36428802583, - 152761.72353542043, - 152788.08391994529, - 152814.44544150229, - 152840.80809999333, - 152867.17189532038, - 152893.53682738543, - 152919.90289609041, - 152946.27010133737, - 152972.63844302832, - 152999.00792106529, - 153025.37853535041, - 153051.7502857857, - 153078.12317227334, - 153104.4971947154, - 153130.8723530141, - 153157.24864707157, - 153183.62607679001, - 153210.00464207167, - 153236.38434281875, - 153262.76517893354, - 153289.14715031831, - 153315.53025687535, - 153341.91449850702, - 153368.2998751156, - 153394.68638660354, - 153421.07403287315, - 153447.46281382689, - 153473.85272936718, - 153500.24377939643, - 153526.63596381716, - 153553.02928253182, - 153579.42373544298, - 153605.81932245308, - 153632.21604346478, - 153658.61389838057, - 153685.0128871031, - 153711.41300953497, - 153737.81426557881, - 153764.21665513728, - 153790.62017811305, - 153817.02483440886, - 153843.43062392739, - 153869.83754657139, - 153896.24560224367, - 153922.65479084692, - 153949.06511228404, - 153975.4765664578, - 154001.88915327107, - 154028.30287262669, - 154054.71772442761, - 154081.13370857667, - 154107.55082497682, - 154133.96907353101, - 154160.38845414223, - 154186.80896671346, - 154213.23061114774, - 154239.65338734805, - 154266.07729521746, - 154292.50233465908, - 154318.92850557598, - 154345.35580787127, - 154371.7842414481, - 154398.21380620965, - 154424.64450205903, - 154451.07632889951, - 154477.50928663427, - 154503.94337516659, - 154530.37859439969, - 154556.81494423689, - 154583.25242458144, - 154609.69103533673, - 154636.13077640603, - 154662.57164769279, - 154689.01364910032, - 154715.45678053208, - 154741.90104189145, - 154768.34643308193, - 154794.79295400696, - 154821.24060457002, - 154847.68938467462, - 154874.13929422433, - 154900.59033312264, - 154927.04250127316, - 154953.49579857948, - 154979.95022494521, - 155006.40578027396, - 155032.86246446942, - 155059.32027743524, - 155085.77921907514, - 155112.2392892928, - 155138.70048799197, - 155165.16281507642, - 155191.62627044989, - 155218.09085401625, - 155244.55656567923, - 155271.02340534274, - 155297.49137291059, - 155323.96046828668, - 155350.4306913749, - 155376.90204207919, - 155403.37452030348, - 155429.84812595171, - 155456.32285892789, - 155482.79871913602, - 155509.27570648011, - 155535.75382086422, - 155562.23306219239, - 155588.71343036872, - 155615.19492529731, - 155641.67754688227, - 155668.16129502779, - 155694.64616963797, - 155721.13217061706, - 155747.61929786921, - 155774.10755129869, - 155800.59693080973, - 155827.08743630661, - 155853.57906769359, - 155880.07182487496, - 155906.56570775513, - 155933.06071623837, - 155959.55685022907, - 155986.05410963166, - 156012.5524943505, - 156039.05200429002, - 156065.55263935472, - 156092.054399449, - 156118.5572844774, - 156145.06129434443, - 156171.5664289546, - 156198.07268821247, - 156224.5800720226, - 156251.08858028959, - 156277.59821291809, - 156304.10896981266, - 156330.62085087801, - 156357.1338560188, - 156383.64798513969, - 156410.16323814544, - 156436.67961494075, - 156463.1971154304, - 156489.71573951913, - 156516.23548711176, - 156542.75635811311, - 156569.27835242799, - 156595.80146996127, - 156622.32571061782, - 156648.85107430254, - 156675.37756092031, - 156701.90517037612, - 156728.43390257491, - 156754.96375742162, - 156781.49473482129, - 156808.02683467892, - 156834.5600568995, - 156861.09440138817, - 156887.62986804993, - 156914.16645678994, - 156940.70416751326, - 156967.24300012505, - 156993.78295453047, - 157020.32403063469, - 157046.8662283429, - 157073.40954756032, - 157099.9539881922, - 157126.49955014378, - 157153.04623332032, - 157179.59403762716, - 157206.14296296958, - 157232.69300925292, - 157259.24417638258, - 157285.79646426387, - 157312.34987280221, - 157338.90440190304, - 157365.46005147175, - 157392.01682141385, - 157418.57471163478, - 157445.13372204005, - 157471.69385253513, - 157498.25510302564, - 157524.81747341706, - 157551.38096361503, - 157577.9455735251, - 157604.51130305286, - 157631.07815210402, - 157657.64612058419, - 157684.21520839902, - 157710.78541545427, - 157737.35674165559, - 157763.92918690876, - 157790.50275111952, - 157817.07743419363, - 157843.65323603692, - 157870.23015655516, - 157896.80819565422, - 157923.3873532399, - 157949.96762921812, - 157976.54902349479, - 158003.13153597576, - 158029.71516656701, - 158056.29991517449, - 158082.88578170416, - 158109.47276606198, - 158136.06086815402, - 158162.65008788629, - 158189.24042516484, - 158215.83187989573, - 158242.42445198505, - 158269.01814133892, - 158295.61294786347, - 158322.20887146486, - 158348.80591204923, - 158375.4040695228, - 158402.00334379176, - 158428.60373476235, - 158455.2052423408, - 158481.80786643337, - 158508.41160694641, - 158535.01646378616, - 158561.62243685898, - 158588.2295260712, - 158614.8377313292, - 158641.44705253936, - 158668.05748960807, - 158694.66904244179, - 158721.28171094693, - 158747.89549502998, - 158774.5103945974, - 158801.12640955573, - 158827.74353981143, - 158854.36178527112, - 158880.9811458413, - 158907.60162142856, - 158934.22321193956, - 158960.84591728085, - 158987.46973735912, - 159014.09467208097, - 159040.72072135314, - 159067.3478850823, - 159093.97616317519, - 159120.60555553852, - 159147.23606207906, - 159173.8676827036, - 159200.50041731889, - 159227.13426583182, - 159253.76922814918, - 159280.40530417781, - 159307.04249382461, - 159333.68079699649, - 159360.32021360032, - 159386.96074354305, - 159413.60238673165, - 159440.24514307309, - 159466.88901247433, - 159493.53399484244, - 159520.18009008438, - 159546.82729810724, - 159573.47561881805, - 159600.12505212394, - 159626.77559793202, - 159653.42725614941, - 159680.08002668325, - 159706.73390944069, - 159733.38890432892, - 159760.04501125516, - 159786.70223012666, - 159813.36056085059, - 159840.02000333427, - 159866.68055748497, - 159893.34222320997, - 159920.00500041663, - 159946.66888901225, - 159973.33388890422, - 159999.99999999988, - 160026.66722220668, - 160053.33555543202, - 160080.0049995833, - 160106.67555456801, - 160133.3472202936, - 160160.0199966676, - 160186.6938835975, - 160213.36888099083, - 160240.04498875517, - 160266.72220679806, - 160293.40053502709, - 160320.07997334987, - 160346.76052167406, - 160373.44217990729, - 160400.1249479572, - 160426.80882573154, - 160453.49381313793, - 160480.17991008417, - 160506.86711647795, - 160533.55543222709, - 160560.24485723933, - 160586.93539142248, - 160613.62703468435, - 160640.31978693281, - 160667.01364807569, - 160693.70861802087, - 160720.40469667627, - 160747.1018839498, - 160773.80017974938, - 160800.49958398298, - 160827.20009655855, - 160853.90171738411, - 160880.60444636765, - 160907.30828341722, - 160934.01322844089, - 160960.71928134665, - 160987.42644204266, - 161014.13471043704, - 161040.84408643784, - 161067.55456995327, - 161094.26616089148, - 161120.97885916062, - 161147.69266466892, - 161174.40757732463, - 161201.12359703594, - 161227.84072371112, - 161254.55895725847, - 161281.27829758628, - 161307.99874460287, - 161334.72029821656, - 161361.44295833571, - 161388.1667248687, - 161414.89159772391, - 161441.61757680977, - 161468.34466203468, - 161495.07285330712, - 161521.80215053557, - 161548.53255362847, - 161575.26406249436, - 161601.99667704175, - 161628.7303971792, - 161655.46522281526, - 161682.20115385848, - 161708.93819021754, - 161735.67633180099, - 161762.41557851751, - 161789.15593027571, - 161815.89738698432, - 161842.63994855201, - 161869.38361488748, - 161896.1283858995, - 161922.87426149679, - 161949.62124158812, - 161976.36932608229, - 162003.1185148881, - 162029.8688079144, - 162056.62020507001, - 162083.37270626382, - 162110.12631140469, - 162136.88102040152, - 162163.63683316324, - 162190.39374959879, - 162217.15176961714, - 162243.91089312723, - 162270.67112003808, - 162297.43245025873, - 162324.19488369819, - 162350.9584202655, - 162377.72305986975, - 162404.48880242003, - 162431.25564782543, - 162458.02359599507, - 162484.79264683815, - 162511.56280026378, - 162538.33405618116, - 162565.10641449949, - 162591.87987512801, - 162618.65443797593, - 162645.43010295252, - 162672.20686996708, - 162698.98473892888, - 162725.76370974723, - 162752.54378233149, - 162779.32495659095, - 162806.10723243505, - 162832.89060977317, - 162859.67508851466, - 162886.46066856899, - 162913.24734984562, - 162940.03513225398, - 162966.82401570358, - 162993.6140001039, - 163020.40508536444, - 163047.19727139481, - 163073.99055810447, - 163100.78494540305, - 163127.58043320014, - 163154.37702140535, - 163181.17470992831, - 163207.97349867865, - 163234.77338756606, - 163261.57437650024, - 163288.37646539087, - 163315.17965414765, - 163341.98394268038, - 163368.78933089875, - 163395.59581871261, - 163422.40340603172, - 163449.2120927659, - 163476.02187882498, - 163502.83276411882, - 163529.6447485573, - 163556.45783205028, - 163583.2720145077, - 163610.08729583945, - 163636.90367595552, - 163663.72115476584, - 163690.53973218042, - 163717.35940810922, - 163744.18018246227, - 163771.00205514964, - 163797.82502608138, - 163824.64909516752, - 163851.4742623182, - 163878.3005274435, - 163905.12789045356, - 163931.95635125853, - 163958.78590976857, - 163985.61656589387, - 164012.44831954464, - 164039.28117063109, - 164066.11511906344, - 164092.95016475199, - 164119.78630760699, - 164146.62354753874, - 164173.46188445756, - 164200.30131827376, - 164227.14184889771, - 164253.98347623978, - 164280.82620021031, - 164307.67002071979, - 164334.51493767856, - 164361.3609509971, - 164388.20806058586, - 164415.05626635533, - 164441.905568216, - 164468.75596607837, - 164495.607459853, - 164522.4600494504, - 164549.31373478117, - 164576.16851575591, - 164603.02439228518, - 164629.88136427966, - 164656.73943164994, - 164683.59859430668, - 164710.45885216061, - 164737.32020512238, - 164764.1826531027, - 164791.04619601235, - 164817.91083376206, - 164844.77656626256, - 164871.64339342469, - 164898.51131515924, - 164925.38033137703, - 164952.25044198887, - 164979.1216469057, - 165005.9939460383, - 165032.86733929763, - 165059.7418265946, - 165086.61740784015, - 165113.4940829452 -}; - -#else - -#ifdef BIG_IQ_TABLE -#define IQ_TABLE_SIZE 8192 -#else -#define IQ_TABLE_SIZE 1026 -#endif - -static const real_t iq_table[IQ_TABLE_SIZE] MEM_ALIGN_ATTR = -{ - REAL_CONST(0.0), - REAL_CONST(1.0/8.0), - REAL_CONST(2.5198420997897464/8.0), - REAL_CONST(4.3267487109222245/8.0), - REAL_CONST(6.3496042078727974/8.0), - REAL_CONST(8.5498797333834844/8.0), - REAL_CONST(10.902723556992836/8.0), - REAL_CONST(13.390518279406722/8.0), - REAL_CONST(15.999999999999998/8.0), - REAL_CONST(18.720754407467133/8.0), - REAL_CONST(21.544346900318832/8.0), - REAL_CONST(24.463780996262464/8.0), - REAL_CONST(27.47314182127996/8.0), - REAL_CONST(30.567350940369842/8.0), - REAL_CONST(33.741991698453212/8.0), - REAL_CONST(36.993181114957046/8.0), - REAL_CONST(40.317473596635935/8.0), - REAL_CONST(43.711787041189993/8.0), - REAL_CONST(47.173345095760126/8.0), - REAL_CONST(50.699631325716943/8.0), - REAL_CONST(54.288352331898118/8.0), - REAL_CONST(57.937407704003519/8.0), - REAL_CONST(61.6448652744185/8.0), - REAL_CONST(65.408940536585988/8.0), - REAL_CONST(69.227979374755591/8.0), - REAL_CONST(73.100443455321638/8.0), - REAL_CONST(77.024897778591622/8.0), - REAL_CONST(80.999999999999986/8.0), - REAL_CONST(85.024491212518527/8.0), - REAL_CONST(89.097187944889555/8.0), - REAL_CONST(93.216975178615741/8.0), - REAL_CONST(97.382800224133163/8.0), - REAL_CONST(101.59366732596474/8.0), - REAL_CONST(105.84863288986224/8.0), - REAL_CONST(110.14680124343441/8.0), - REAL_CONST(114.4873208566006/8.0), - REAL_CONST(118.86938096020653/8.0), - REAL_CONST(123.29220851090024/8.0), - REAL_CONST(127.75506545836058/8.0), - REAL_CONST(132.25724627755247/8.0), - REAL_CONST(136.79807573413572/8.0), - REAL_CONST(141.37690685569191/8.0), - REAL_CONST(145.99311908523086/8.0), - REAL_CONST(150.6461165966291/8.0), - REAL_CONST(155.33532675434674/8.0), - REAL_CONST(160.06019870205279/8.0), - REAL_CONST(164.82020206673349/8.0), - REAL_CONST(169.61482576651861/8.0), - REAL_CONST(174.44357691188537/8.0), - REAL_CONST(179.30597979112557/8.0), - REAL_CONST(184.20157493201927/8.0), - REAL_CONST(189.12991823257562/8.0), - REAL_CONST(194.09058015449685/8.0), - REAL_CONST(199.08314497371677/8.0), - REAL_CONST(204.1072100829694/8.0), - REAL_CONST(209.16238534187647/8.0), - REAL_CONST(214.24829247050752/8.0), - REAL_CONST(219.36456448277784/8.0), - REAL_CONST(224.51084515641216/8.0), - REAL_CONST(229.6867885365223/8.0), - REAL_CONST(234.89205847013176/8.0), - REAL_CONST(240.12632816923249/8.0), - REAL_CONST(245.38927980018505/8.0), - REAL_CONST(250.68060409747261/8.0), - REAL_CONST(255.99999999999991/8.0), - REAL_CONST(261.34717430828869/8.0), - REAL_CONST(266.72184136106449/8.0), - REAL_CONST(272.12372272986045/8.0), - REAL_CONST(277.55254693037961/8.0), - REAL_CONST(283.0080491494619/8.0), - REAL_CONST(288.48997098659891/8.0), - REAL_CONST(293.99806020902247/8.0), - REAL_CONST(299.53207051947408/8.0), - REAL_CONST(305.0917613358298/8.0), - REAL_CONST(310.67689758182206/8.0), - REAL_CONST(316.28724948815585/8.0), - REAL_CONST(321.92259240337177/8.0), - REAL_CONST(327.58270661385535/8.0), - REAL_CONST(333.26737717243742/8.0), - REAL_CONST(338.97639373507025/8.0), - REAL_CONST(344.70955040510125/8.0), - REAL_CONST(350.46664558470013/8.0), - REAL_CONST(356.24748183302603/8.0), - REAL_CONST(362.05186573075139/8.0), - REAL_CONST(367.87960775058258/8.0), - REAL_CONST(373.73052213344511/8.0), - REAL_CONST(379.60442677002078/8.0), - REAL_CONST(385.50114308734607/8.0), - REAL_CONST(391.42049594019937/8.0), - REAL_CONST(397.36231350702371/8.0), - REAL_CONST(403.32642719014467/8.0), - REAL_CONST(409.31267152006262/8.0), - REAL_CONST(415.32088406360799/8.0), - REAL_CONST(421.35090533576471/8.0), - REAL_CONST(427.40257871497619/8.0), - REAL_CONST(433.4757503617617/8.0), - REAL_CONST(439.5702691404793/8.0), - REAL_CONST(445.68598654408271/8.0), - REAL_CONST(451.82275662172759/8.0), - REAL_CONST(457.98043590909128/8.0), - REAL_CONST(464.15888336127773/8.0), - REAL_CONST(470.35796028818726/8.0), - REAL_CONST(476.5775302922363/8.0), - REAL_CONST(482.81745920832043/8.0), - REAL_CONST(489.07761504591741/8.0), - REAL_CONST(495.35786793323581/8.0), - REAL_CONST(501.65809006331688/8.0), - REAL_CONST(507.97815564200368/8.0), - REAL_CONST(514.31794083769648/8.0), - REAL_CONST(520.67732373281672/8.0), - REAL_CONST(527.05618427690604/8.0), - REAL_CONST(533.45440424129174/8.0), - REAL_CONST(539.87186717525128/8.0), - REAL_CONST(546.30845836361505/8.0), - REAL_CONST(552.76406478574609/8.0), - REAL_CONST(559.23857507584194/8.0), - REAL_CONST(565.73187948450413/8.0), - REAL_CONST(572.24386984152341/8.0), - REAL_CONST(578.77443951983378/8.0), - REAL_CONST(585.32348340058843/8.0), - REAL_CONST(591.89089783931263/8.0), - REAL_CONST(598.47658063309257/8.0), - REAL_CONST(605.08043098876044/8.0), - REAL_CONST(611.70234949203643/8.0), - REAL_CONST(618.3422380775919/8.0), - REAL_CONST(624.99999999999977/8.0), - REAL_CONST(631.67553980553748/8.0), - REAL_CONST(638.36876330481164/8.0), - REAL_CONST(645.07957754617485/8.0), - REAL_CONST(651.80789078990415/8.0), - REAL_CONST(658.55361248311499/8.0), - REAL_CONST(665.31665323538357/8.0), - REAL_CONST(672.09692479505225/8.0), - REAL_CONST(678.8943400261943/8.0), - REAL_CONST(685.70881288621433/8.0), - REAL_CONST(692.540258404062/8.0), - REAL_CONST(699.38859265903977/8.0), - REAL_CONST(706.25373276018058/8.0), - REAL_CONST(713.13559682617972/8.0), - REAL_CONST(720.03410396586037/8.0), - REAL_CONST(726.94917425915435/8.0), - REAL_CONST(733.88072873858209/8.0), - REAL_CONST(740.82868937121543/8.0), - REAL_CONST(747.79297904110535/8.0), - REAL_CONST(754.77352153216191/8.0), - REAL_CONST(761.77024151147043/8.0), - REAL_CONST(768.78306451302956/8.0), - REAL_CONST(775.81191692189896/8.0), - REAL_CONST(782.85672595874246/8.0), - REAL_CONST(789.91741966475445/8.0), - REAL_CONST(796.99392688695798/8.0), - REAL_CONST(804.08617726386274/8.0), - REAL_CONST(811.19410121147098/8.0), - REAL_CONST(818.31762990962227/8.0), - REAL_CONST(825.45669528866563/8.0), - REAL_CONST(832.61123001644864/8.0), - REAL_CONST(839.78116748561604/8.0), - REAL_CONST(846.96644180120552/8.0), - REAL_CONST(854.16698776853514/8.0), - REAL_CONST(861.38274088137143/8.0), - REAL_CONST(868.61363731036977/8.0), - REAL_CONST(875.85961389178203/8.0), - REAL_CONST(883.12060811641959/8.0), - REAL_CONST(890.39655811886757/8.0), - REAL_CONST(897.68740266694181/8.0), - REAL_CONST(904.99308115138172/8.0), - REAL_CONST(912.31353357577188/8.0), - REAL_CONST(919.64870054668756/8.0), - REAL_CONST(926.99852326405619/8.0), - REAL_CONST(934.36294351172899/8.0), - REAL_CONST(941.74190364825859/8.0), - REAL_CONST(949.13534659787422/8.0), - REAL_CONST(956.54321584165211/8.0), - REAL_CONST(963.96545540887348/8.0), - REAL_CONST(971.40200986856541/8.0), - REAL_CONST(978.85282432122176/8.0), - REAL_CONST(986.31784439069588/8.0), - REAL_CONST(993.7970162162635/8.0), - REAL_CONST(1001.29028644485/8.0), - REAL_CONST(1008.797602223418/8.0), - REAL_CONST(1016.3189111915103/8.0), - REAL_CONST(1023.8541614739464/8.0), - REAL_CONST(1031.4033016736653/8.0), - REAL_CONST(1038.9662808647138/8.0), - REAL_CONST(1046.5430485853758/8.0), - REAL_CONST(1054.1335548314366/8.0), - REAL_CONST(1061.7377500495838/8.0), - REAL_CONST(1069.3555851309357/8.0), - REAL_CONST(1076.9870114046978/8.0), - REAL_CONST(1084.6319806319441/8.0), - REAL_CONST(1092.2904449995174/8.0), - REAL_CONST(1099.9623571140482/8.0), - REAL_CONST(1107.6476699960892/8.0), - REAL_CONST(1115.3463370743607/8.0), - REAL_CONST(1123.058312180106/8.0), - REAL_CONST(1130.7835495415541/8.0), - REAL_CONST(1138.5220037784854/8.0), - REAL_CONST(1146.273629896901/8.0), - REAL_CONST(1154.0383832837879/8.0), - REAL_CONST(1161.816219701986/8.0), - REAL_CONST(1169.607095285146/8.0), - REAL_CONST(1177.4109665327808/8.0), - REAL_CONST(1185.2277903054078/8.0), - REAL_CONST(1193.0575238197798/8.0), - REAL_CONST(1200.9001246442001/8.0), - REAL_CONST(1208.7555506939248/8.0), - REAL_CONST(1216.6237602266442/8.0), - REAL_CONST(1224.5047118380478/8.0), - REAL_CONST(1232.3983644574657/8.0), - REAL_CONST(1240.3046773435874/8.0), - REAL_CONST(1248.2236100802568/8.0), - REAL_CONST(1256.1551225723395/8.0), - REAL_CONST(1264.099175041662/8.0), - REAL_CONST(1272.0557280230228/8.0), - REAL_CONST(1280.0247423602691/8.0), - REAL_CONST(1288.0061792024444/8.0), - REAL_CONST(1295.9999999999995/8.0), - REAL_CONST(1304.006166501068/8.0), - REAL_CONST(1312.0246407478062/8.0), - REAL_CONST(1320.0553850727929/8.0), - REAL_CONST(1328.0983620954903/8.0), - REAL_CONST(1336.1535347187651/8.0), - REAL_CONST(1344.2208661254647/8.0), - REAL_CONST(1352.3003197750522/8.0), - REAL_CONST(1360.3918594002962/8.0), - REAL_CONST(1368.4954490040145/8.0), - REAL_CONST(1376.6110528558709/8.0), - REAL_CONST(1384.7386354892244/8.0), - REAL_CONST(1392.8781616980295/8.0), - REAL_CONST(1401.0295965337855/8.0), - REAL_CONST(1409.1929053025353/8.0), - REAL_CONST(1417.3680535619119/8.0), - REAL_CONST(1425.5550071182327/8.0), - REAL_CONST(1433.7537320236374/8.0), - REAL_CONST(1441.9641945732744/8.0), - REAL_CONST(1450.1863613025282/8.0), - REAL_CONST(1458.4201989842913/8.0), - REAL_CONST(1466.6656746262797/8.0), - REAL_CONST(1474.9227554683875/8.0), - REAL_CONST(1483.1914089800841/8.0), - REAL_CONST(1491.4716028578516/8.0), - REAL_CONST(1499.7633050226596/8.0), - REAL_CONST(1508.0664836174794/8.0), - REAL_CONST(1516.3811070048375/8.0), - REAL_CONST(1524.7071437644029/8.0), - REAL_CONST(1533.0445626906128/8.0), - REAL_CONST(1541.3933327903342/8.0), - REAL_CONST(1549.7534232805581/8.0), - REAL_CONST(1558.1248035861302/8.0), - REAL_CONST(1566.507443337515/8.0), - REAL_CONST(1574.9013123685909/8.0), - REAL_CONST(1583.3063807144795/8.0), - REAL_CONST(1591.7226186094069/8.0), - REAL_CONST(1600.1499964845941/8.0), - REAL_CONST(1608.58848496618/8.0), - REAL_CONST(1617.0380548731737/8.0), - REAL_CONST(1625.4986772154357/8.0), - REAL_CONST(1633.9703231916887/8.0), - REAL_CONST(1642.4529641875577/8.0), - REAL_CONST(1650.9465717736346/8.0), - REAL_CONST(1659.4511177035752/8.0), - REAL_CONST(1667.9665739122186/8.0), - REAL_CONST(1676.4929125137353/8.0), - REAL_CONST(1685.030105799801/8.0), - REAL_CONST(1693.5781262377957/8.0), - REAL_CONST(1702.136946469027/8.0), - REAL_CONST(1710.7065393069795/8.0), - REAL_CONST(1719.2868777355877/8.0), - REAL_CONST(1727.8779349075323/8.0), - REAL_CONST(1736.4796841425596/8.0), - REAL_CONST(1745.092098925825/8.0), - REAL_CONST(1753.7151529062583/8.0), - REAL_CONST(1762.3488198949503/8.0), - REAL_CONST(1770.9930738635628/8.0), - REAL_CONST(1779.6478889427597/8.0), - REAL_CONST(1788.3132394206564/8.0), - REAL_CONST(1796.9890997412947/8.0), - REAL_CONST(1805.6754445031333/8.0), - REAL_CONST(1814.3722484575621/8.0), - REAL_CONST(1823.0794865074322/8.0), - REAL_CONST(1831.7971337056094/8.0), - REAL_CONST(1840.5251652535437/8.0), - REAL_CONST(1849.2635564998579/8.0), - REAL_CONST(1858.0122829389563/8.0), - REAL_CONST(1866.7713202096493/8.0), - REAL_CONST(1875.5406440937966/8.0), - REAL_CONST(1884.3202305149687/8.0), - REAL_CONST(1893.110055537124/8.0), - REAL_CONST(1901.9100953633042/8.0), - REAL_CONST(1910.7203263343454/8.0), - REAL_CONST(1919.5407249276057/8.0), - REAL_CONST(1928.3712677557098/8.0), - REAL_CONST(1937.2119315653083/8.0), - REAL_CONST(1946.0626932358525/8.0), - REAL_CONST(1954.923529778386/8.0), - REAL_CONST(1963.79441833435/8.0), - REAL_CONST(1972.6753361744036/8.0), - REAL_CONST(1981.5662606972594/8.0), - REAL_CONST(1990.467169428533/8.0), - REAL_CONST(1999.3780400196069/8.0), - REAL_CONST(2008.2988502465078/8.0), - REAL_CONST(2017.2295780087982/8.0), - REAL_CONST(2026.1702013284819/8.0), - REAL_CONST(2035.1206983489212/8.0), - REAL_CONST(2044.0810473337688/8.0), - REAL_CONST(2053.0512266659125/8.0), - REAL_CONST(2062.0312148464309/8.0), - REAL_CONST(2071.0209904935646/8.0), - REAL_CONST(2080.0205323416958/8.0), - REAL_CONST(2089.0298192403443/8.0), - REAL_CONST(2098.0488301531714/8.0), - REAL_CONST(2107.0775441569995/8.0), - REAL_CONST(2116.115940440839/8.0), - REAL_CONST(2125.1639983049317/8.0), - REAL_CONST(2134.2216971597995/8.0), - REAL_CONST(2143.2890165253098/8.0), - REAL_CONST(2152.3659360297484/8.0), - REAL_CONST(2161.4524354089031/8.0), - REAL_CONST(2170.5484945051617/8.0), - REAL_CONST(2179.6540932666144/8.0), - REAL_CONST(2188.7692117461711/8.0), - REAL_CONST(2197.8938301006888/8.0), - REAL_CONST(2207.0279285901042/8.0), - REAL_CONST(2216.1714875765838/8.0), - REAL_CONST(2225.324487523676/8.0), - REAL_CONST(2234.4869089954782/8.0), - REAL_CONST(2243.6587326558101/8.0), - REAL_CONST(2252.8399392673982/8.0), - REAL_CONST(2262.0305096910702/8.0), - REAL_CONST(2271.2304248849537/8.0), - REAL_CONST(2280.4396659036897/8.0), - REAL_CONST(2289.6582138976523/8.0), - REAL_CONST(2298.8860501121762/8.0), - REAL_CONST(2308.1231558867926/8.0), - REAL_CONST(2317.3695126544767/8.0), - REAL_CONST(2326.6251019409005/8.0), - REAL_CONST(2335.8899053636933/8.0), - REAL_CONST(2345.1639046317132/8.0), - REAL_CONST(2354.4470815443233/8.0), - REAL_CONST(2363.7394179906792/8.0), - REAL_CONST(2373.0408959490205/8.0), - REAL_CONST(2382.3514974859731/8.0), - REAL_CONST(2391.6712047558558/8.0), - REAL_CONST(2400.9999999999991/8.0), - REAL_CONST(2410.3378655460651/8.0), - REAL_CONST(2419.6847838073813/8.0), - REAL_CONST(2429.0407372822747/8.0), - REAL_CONST(2438.4057085534191/8.0), - REAL_CONST(2447.7796802871858/8.0), - REAL_CONST(2457.1626352330004/8.0), - REAL_CONST(2466.5545562227112/8.0), - REAL_CONST(2475.9554261699564/8.0), - REAL_CONST(2485.3652280695474/8.0), - REAL_CONST(2494.7839449968492/8.0), - REAL_CONST(2504.2115601071737/8.0), - REAL_CONST(2513.6480566351788/8.0), - REAL_CONST(2523.0934178942675/8.0), - REAL_CONST(2532.5476272760025/8.0), - REAL_CONST(2542.0106682495189/8.0), - REAL_CONST(2551.482524360948/8.0), - REAL_CONST(2560.9631792328441/8.0), - REAL_CONST(2570.4526165636184/8.0), - REAL_CONST(2579.9508201269791/8.0), - REAL_CONST(2589.4577737713744/8.0), - REAL_CONST(2598.9734614194458/8.0), - REAL_CONST(2608.4978670674823/8.0), - REAL_CONST(2618.0309747848837/8.0), - REAL_CONST(2627.5727687136259/8.0), - REAL_CONST(2637.1232330677353/8.0), - REAL_CONST(2646.6823521327647/8.0), - REAL_CONST(2656.2501102652768/8.0), - REAL_CONST(2665.8264918923328/8.0), - REAL_CONST(2675.4114815109842/8.0), - REAL_CONST(2685.0050636877722/8.0), - REAL_CONST(2694.6072230582295/8.0), - REAL_CONST(2704.2179443263894/8.0), - REAL_CONST(2713.8372122642972/8.0), - REAL_CONST(2723.4650117115279/8.0), - REAL_CONST(2733.1013275747096/8.0), - REAL_CONST(2742.7461448270483/8.0), - REAL_CONST(2752.3994485078601/8.0), - REAL_CONST(2762.0612237221085/8.0), - REAL_CONST(2771.7314556399419/8.0), - REAL_CONST(2781.4101294962406/8.0), - REAL_CONST(2791.0972305901655/8.0), - REAL_CONST(2800.7927442847094/8.0), - REAL_CONST(2810.4966560062589/8.0), - REAL_CONST(2820.2089512441521/8.0), - REAL_CONST(2829.9296155502466/8.0), - REAL_CONST(2839.6586345384894/8.0), - REAL_CONST(2849.3959938844923/8.0), - REAL_CONST(2859.1416793251065/8.0), - REAL_CONST(2868.8956766580086/8.0), - REAL_CONST(2878.6579717412847/8.0), - REAL_CONST(2888.4285504930212/8.0), - REAL_CONST(2898.2073988908974/8.0), - REAL_CONST(2907.9945029717837/8.0), - REAL_CONST(2917.789848831344/8.0), - REAL_CONST(2927.5934226236377/8.0), - REAL_CONST(2937.4052105607311/8.0), - REAL_CONST(2947.2251989123079/8.0), - REAL_CONST(2957.0533740052865/8.0), - REAL_CONST(2966.8897222234368/8.0), - REAL_CONST(2976.734230007005/8.0), - REAL_CONST(2986.5868838523397/8.0), - REAL_CONST(2996.4476703115197/8.0), - REAL_CONST(3006.3165759919889/8.0), - REAL_CONST(3016.1935875561908/8.0), - REAL_CONST(3026.0786917212095/8.0), - REAL_CONST(3035.9718752584108/8.0), - REAL_CONST(3045.8731249930906/8.0), - REAL_CONST(3055.7824278041207/8.0), - REAL_CONST(3065.6997706236039/8.0), - REAL_CONST(3075.625140436528/8.0), - REAL_CONST(3085.5585242804245/8.0), - REAL_CONST(3095.4999092450298/8.0), - REAL_CONST(3105.4492824719491/8.0), - REAL_CONST(3115.4066311543256/8.0), - REAL_CONST(3125.3719425365089/8.0), - REAL_CONST(3135.3452039137287/8.0), - REAL_CONST(3145.3264026317715/8.0), - REAL_CONST(3155.3155260866592/8.0), - REAL_CONST(3165.3125617243295/8.0), - REAL_CONST(3175.3174970403229/8.0), - REAL_CONST(3185.3303195794679/8.0), - REAL_CONST(3195.35101693557/8.0), - REAL_CONST(3205.3795767511078/8.0), - REAL_CONST(3215.4159867169251/8.0), - REAL_CONST(3225.460234571929/8.0), - REAL_CONST(3235.5123081027928/8.0), - REAL_CONST(3245.5721951436558/8.0), - REAL_CONST(3255.63988357583/8.0), - REAL_CONST(3265.7153613275095/8.0), - REAL_CONST(3275.7986163734795/8.0), - REAL_CONST(3285.8896367348289/8.0), - REAL_CONST(3295.9884104786665/8.0), - REAL_CONST(3306.0949257178395/8.0), - REAL_CONST(3316.2091706106517/8.0), - REAL_CONST(3326.331133360588/8.0), - REAL_CONST(3336.4608022160378/8.0), - REAL_CONST(3346.5981654700231/8.0), - REAL_CONST(3356.7432114599264/8.0), - REAL_CONST(3366.8959285672249/8.0), - REAL_CONST(3377.0563052172211/8.0), - REAL_CONST(3387.2243298787821/8.0), - REAL_CONST(3397.3999910640764/8.0), - REAL_CONST(3407.5832773283128/8.0), - REAL_CONST(3417.7741772694862/8.0), - REAL_CONST(3427.9726795281199/8.0), - REAL_CONST(3438.1787727870123/8.0), - REAL_CONST(3448.3924457709873/8.0), - REAL_CONST(3458.6136872466445/8.0), - REAL_CONST(3468.8424860221107/8.0), - REAL_CONST(3479.0788309467976/8.0), - REAL_CONST(3489.3227109111554/8.0), - REAL_CONST(3499.5741148464344/8.0), - REAL_CONST(3509.8330317244445/8.0), - REAL_CONST(3520.0994505573185/8.0), - REAL_CONST(3530.3733603972751/8.0), - REAL_CONST(3540.6547503363886/8.0), - REAL_CONST(3550.9436095063534/8.0), - REAL_CONST(3561.239927078258/8.0), - REAL_CONST(3571.5436922623535/8.0), - REAL_CONST(3581.8548943078308/8.0), - REAL_CONST(3592.1735225025936/8.0), - REAL_CONST(3602.4995661730372/8.0), - REAL_CONST(3612.8330146838275/8.0), - REAL_CONST(3623.1738574376814/8.0), - REAL_CONST(3633.5220838751502/8.0), - REAL_CONST(3643.8776834744031/8.0), - REAL_CONST(3654.2406457510142/8.0), - REAL_CONST(3664.6109602577494/8.0), - REAL_CONST(3674.9886165843564/8.0), - REAL_CONST(3685.3736043573545/8.0), - REAL_CONST(3695.7659132398294/8.0), - REAL_CONST(3706.1655329312248/8.0), - REAL_CONST(3716.5724531671399/8.0), - REAL_CONST(3726.9866637191262/8.0), - REAL_CONST(3737.4081543944876/8.0), - REAL_CONST(3747.8369150360782/8.0), - REAL_CONST(3758.2729355221072/8.0), - REAL_CONST(3768.7162057659411/8.0), - REAL_CONST(3779.1667157159077/8.0), - REAL_CONST(3789.6244553551055/8.0), - REAL_CONST(3800.0894147012082/8.0), - REAL_CONST(3810.5615838062768/8.0), - REAL_CONST(3821.0409527565694/8.0), - REAL_CONST(3831.5275116723533/8.0), - REAL_CONST(3842.0212507077194/8.0), - REAL_CONST(3852.522160050396/8.0), - REAL_CONST(3863.0302299215673/8.0), - REAL_CONST(3873.5454505756893/8.0), - REAL_CONST(3884.0678123003108/8.0), - REAL_CONST(3894.5973054158922/8.0), - REAL_CONST(3905.1339202756285/8.0), - REAL_CONST(3915.6776472652732/8.0), - REAL_CONST(3926.2284768029604/8.0), - REAL_CONST(3936.7863993390338/8.0), - REAL_CONST(3947.3514053558706/8.0), - REAL_CONST(3957.9234853677135/8.0), - REAL_CONST(3968.5026299204969/8.0), - REAL_CONST(3979.0888295916798/8.0), - REAL_CONST(3989.6820749900776/8.0), - REAL_CONST(4000.2823567556948/8.0), - REAL_CONST(4010.8896655595613/8.0), - REAL_CONST(4021.5039921035655/8.0), - REAL_CONST(4032.1253271202945/8.0), - REAL_CONST(4042.7536613728694/8.0), - REAL_CONST(4053.3889856547858/8.0), - REAL_CONST(4064.0312907897551/8.0), - REAL_CONST(4074.6805676315448/8.0), - REAL_CONST(4085.3368070638221/8.0), - REAL_CONST(4095.9999999999982/8.0), - REAL_CONST(4106.6701373830711/8.0), - REAL_CONST(4117.347210185475/8.0), - REAL_CONST(4128.0312094089259/8.0), - REAL_CONST(4138.722126084268/8.0), - REAL_CONST(4149.4199512713267/8.0), - REAL_CONST(4160.1246760587583/8.0), - REAL_CONST(4170.8362915638982/8.0), - REAL_CONST(4181.5547889326181/8.0), - REAL_CONST(4192.2801593391769/8.0), - REAL_CONST(4203.0123939860741/8.0), - REAL_CONST(4213.7514841039101/8.0), - REAL_CONST(4224.4974209512384/8.0), - REAL_CONST(4235.2501958144258/8.0), - REAL_CONST(4246.0098000075095/8.0), - REAL_CONST(4256.7762248720574/8.0), - REAL_CONST(4267.549461777031/8.0), - REAL_CONST(4278.3295021186423/8.0), - REAL_CONST(4289.1163373202198/8.0), - REAL_CONST(4299.9099588320714/8.0), - REAL_CONST(4310.7103581313495/8.0), - REAL_CONST(4321.5175267219138/8.0), - REAL_CONST(4332.3314561342004/8.0), - REAL_CONST(4343.152137925088/8.0), - REAL_CONST(4353.9795636777671/8.0), - REAL_CONST(4364.8137250016052/8.0), - REAL_CONST(4375.6546135320223/8.0), - REAL_CONST(4386.5022209303588/8.0), - REAL_CONST(4397.3565388837469/8.0), - REAL_CONST(4408.2175591049827/8.0), - REAL_CONST(4419.0852733324018/8.0), - REAL_CONST(4429.9596733297531/8.0), - REAL_CONST(4440.8407508860728/8.0), - REAL_CONST(4451.7284978155603/8.0), - REAL_CONST(4462.6229059574571/8.0), - REAL_CONST(4473.5239671759227/8.0), - REAL_CONST(4484.4316733599126/8.0), - REAL_CONST(4495.3460164230582/8.0), - REAL_CONST(4506.2669883035496/8.0), - REAL_CONST(4517.1945809640119/8.0), - REAL_CONST(4528.1287863913894/8.0), - REAL_CONST(4539.069596596828/8.0), - REAL_CONST(4550.0170036155587/8.0), - REAL_CONST(4560.9709995067806/8.0), - REAL_CONST(4571.931576353546/8.0), - REAL_CONST(4582.898726262647/8.0), - REAL_CONST(4593.8724413645004/8.0), - REAL_CONST(4604.8527138130348/8.0), - REAL_CONST(4615.8395357855816/8.0), - REAL_CONST(4626.8328994827571/8.0), - REAL_CONST(4637.8327971283588/8.0), - REAL_CONST(4648.8392209692511/8.0), - REAL_CONST(4659.8521632752563/8.0), - REAL_CONST(4670.8716163390473/8.0), - REAL_CONST(4681.8975724760394/8.0), - REAL_CONST(4692.9300240242837/8.0), - REAL_CONST(4703.9689633443595/8.0), - REAL_CONST(4715.0143828192668/8.0), - REAL_CONST(4726.0662748543255/8.0), - REAL_CONST(4737.1246318770682/8.0), - REAL_CONST(4748.1894463371373/8.0), - REAL_CONST(4759.2607107061804/8.0), - REAL_CONST(4770.3384174777493/8.0), - REAL_CONST(4781.4225591671993/8.0), - REAL_CONST(4792.5131283115852/8.0), - REAL_CONST(4803.6101174695614/8.0), - REAL_CONST(4814.7135192212854/8.0), - REAL_CONST(4825.8233261683154/8.0), - REAL_CONST(4836.9395309335096/8.0), - REAL_CONST(4848.0621261609349/8.0), - REAL_CONST(4859.1911045157631/8.0), - REAL_CONST(4870.3264586841779/8.0), - REAL_CONST(4881.4681813732768/8.0), - REAL_CONST(4892.6162653109768/8.0), - REAL_CONST(4903.7707032459193/8.0), - REAL_CONST(4914.931487947375/8.0), - REAL_CONST(4926.0986122051509/8.0), - REAL_CONST(4937.2720688294967/8.0), - REAL_CONST(4948.4518506510112/8.0), - REAL_CONST(4959.637950520555/8.0), - REAL_CONST(4970.8303613091521/8.0), - REAL_CONST(4982.0290759079044/8.0), - REAL_CONST(4993.2340872278974/8.0), - REAL_CONST(5004.4453882001153/8.0), - REAL_CONST(5015.6629717753467/8.0), - REAL_CONST(5026.8868309241007/8.0), - REAL_CONST(5038.1169586365131/8.0), - REAL_CONST(5049.353347922266/8.0), - REAL_CONST(5060.5959918104927/8.0), - REAL_CONST(5071.8448833496996/8.0), - REAL_CONST(5083.1000156076734/8.0), - REAL_CONST(5094.3613816713996/8.0), - REAL_CONST(5105.6289746469747/8.0), - REAL_CONST(5116.9027876595246/8.0), - REAL_CONST(5128.18281385312/8.0), - REAL_CONST(5139.4690463906918/8.0), - REAL_CONST(5150.7614784539473/8.0), - REAL_CONST(5162.0601032432933/8.0), - REAL_CONST(5173.3649139777472/8.0), - REAL_CONST(5184.6759038948594/8.0), - REAL_CONST(5195.9930662506322/8.0), - REAL_CONST(5207.3163943194386/8.0), - REAL_CONST(5218.6458813939435/8.0), - REAL_CONST(5229.9815207850224/8.0), - REAL_CONST(5241.3233058216847/8.0), - REAL_CONST(5252.6712298509919/8.0), - REAL_CONST(5264.025286237983/8.0), - REAL_CONST(5275.3854683655954/8.0), - REAL_CONST(5286.7517696345885/8.0), - REAL_CONST(5298.1241834634639/8.0), - REAL_CONST(5309.5027032883945/8.0), - REAL_CONST(5320.887322563146/8.0), - REAL_CONST(5332.2780347589978/8.0), - REAL_CONST(5343.6748333646756/8.0), - REAL_CONST(5355.0777118862716/8.0), - REAL_CONST(5366.4866638471722/8.0), - REAL_CONST(5377.901682787985/8.0), - REAL_CONST(5389.3227622664635/8.0), - REAL_CONST(5400.749895857437/8.0), - REAL_CONST(5412.1830771527357/8.0), - REAL_CONST(5423.622299761123/8.0), - REAL_CONST(5435.067557308219/8.0), - REAL_CONST(5446.5188434364318/8.0), - REAL_CONST(5457.9761518048872/8.0), - REAL_CONST(5469.4394760893592/8.0), - REAL_CONST(5480.9088099821975/8.0), - REAL_CONST(5492.3841471922606/8.0), - REAL_CONST(5503.8654814448455/8.0), - REAL_CONST(5515.3528064816201/8.0), - REAL_CONST(5526.846116060552/8.0), - REAL_CONST(5538.3454039558474/8.0), - REAL_CONST(5549.8506639578736/8.0), - REAL_CONST(5561.3618898731029/8.0), - REAL_CONST(5572.8790755240361/8.0), - REAL_CONST(5584.4022147491451/8.0), - REAL_CONST(5595.9313014027975/8.0), - REAL_CONST(5607.4663293552012/8.0), - REAL_CONST(5619.0072924923297/8.0), - REAL_CONST(5630.5541847158656/8.0), - REAL_CONST(5642.1069999431284/8.0), - REAL_CONST(5653.665732107017/8.0), - REAL_CONST(5665.230375155943/8.0), - REAL_CONST(5676.8009230537655/8.0), - REAL_CONST(5688.3773697797333/8.0), - REAL_CONST(5699.9597093284156/8.0), - REAL_CONST(5711.5479357096474/8.0), - REAL_CONST(5723.1420429484588/8.0), - REAL_CONST(5734.7420250850209/8.0), - REAL_CONST(5746.347876174581/8.0), - REAL_CONST(5757.9595902874016/8.0), - REAL_CONST(5769.5771615087006/8.0), - REAL_CONST(5781.2005839385911/8.0), - REAL_CONST(5792.8298516920213/8.0), - REAL_CONST(5804.4649588987149/8.0), - REAL_CONST(5816.1058997031105/8.0), - REAL_CONST(5827.7526682643065/8.0), - REAL_CONST(5839.4052587559972/8.0), - REAL_CONST(5851.0636653664196/8.0), - REAL_CONST(5862.7278822982908/8.0), - REAL_CONST(5874.3979037687541/8.0), - REAL_CONST(5886.0737240093204/8.0), - REAL_CONST(5897.7553372658094/8.0), - REAL_CONST(5909.4427377982956/8.0), - REAL_CONST(5921.1359198810505/8.0), - REAL_CONST(5932.8348778024874/8.0), - REAL_CONST(5944.5396058651031/8.0), - REAL_CONST(5956.2500983854261/8.0), - REAL_CONST(5967.9663496939575/8.0), - REAL_CONST(5979.6883541351208/8.0), - REAL_CONST(5991.4161060672022/8.0), - REAL_CONST(6003.1495998623004/8.0), - REAL_CONST(6014.8888299062692/8.0), - REAL_CONST(6026.6337905986684/8.0), - REAL_CONST(6038.3844763527022/8.0), - REAL_CONST(6050.1408815951781/8.0), - REAL_CONST(6061.9030007664414/8.0), - REAL_CONST(6073.6708283203316/8.0), - REAL_CONST(6085.4443587241267/8.0), - REAL_CONST(6097.2235864584891/8.0), - REAL_CONST(6109.0085060174197/8.0), - REAL_CONST(6120.7991119081998/8.0), - REAL_CONST(6132.595398651345/8.0), - REAL_CONST(6144.3973607805519/8.0), - REAL_CONST(6156.2049928426459/8.0), - REAL_CONST(6168.0182893975361/8.0), - REAL_CONST(6179.8372450181578/8.0), - REAL_CONST(6191.6618542904307/8.0), - REAL_CONST(6203.4921118132024/8.0), - REAL_CONST(6215.3280121982016/8.0), - REAL_CONST(6227.1695500699925/8.0), - REAL_CONST(6239.0167200659189/8.0), - REAL_CONST(6250.8695168360628/8.0), - REAL_CONST(6262.7279350431891/8.0), - REAL_CONST(6274.5919693627056/8.0), - REAL_CONST(6286.4616144826068/8.0), - REAL_CONST(6298.3368651034316/8.0), - REAL_CONST(6310.2177159382172/8.0), - REAL_CONST(6322.1041617124456/8.0), - REAL_CONST(6333.9961971640032/8.0), - REAL_CONST(6345.8938170431311/8.0), - REAL_CONST(6357.7970161123785/8.0), - REAL_CONST(6369.7057891465583/8.0), - REAL_CONST(6381.6201309327007/8.0), - REAL_CONST(6393.5400362700075/8.0), - REAL_CONST(6405.4654999698032/8.0), - REAL_CONST(6417.3965168554978/8.0), - REAL_CONST(6429.3330817625329/8.0), - REAL_CONST(6441.2751895383453/8.0), - REAL_CONST(6453.2228350423138/8.0), - REAL_CONST(6465.176013145724/8.0), - REAL_CONST(6477.134718731716/8.0), - REAL_CONST(6489.0989466952469/8.0), - REAL_CONST(6501.0686919430445/8.0), - REAL_CONST(6513.0439493935628/8.0), - REAL_CONST(6525.0247139769417/8.0), - REAL_CONST(6537.010980634961/8.0), - REAL_CONST(6549.002744321001/8.0), - REAL_CONST(6560.9999999999973/8.0), - REAL_CONST(6573.0027426483985/8.0), - REAL_CONST(6585.0109672541284/8.0), - REAL_CONST(6597.0246688165371/8.0), - REAL_CONST(6609.0438423463656/8.0), - REAL_CONST(6621.0684828657004/8.0), - REAL_CONST(6633.0985854079354/8.0), - REAL_CONST(6645.134145017727/8.0), - REAL_CONST(6657.1751567509573/8.0), - REAL_CONST(6669.2216156746908/8.0), - REAL_CONST(6681.2735168671343/8.0), - REAL_CONST(6693.3308554176001/8.0), - REAL_CONST(6705.3936264264594/8.0), - REAL_CONST(6717.461825005108/8.0), - REAL_CONST(6729.535446275926/8.0), - REAL_CONST(6741.6144853722335/8.0), - REAL_CONST(6753.6989374382601/8.0), - REAL_CONST(6765.7887976290967/8.0), - REAL_CONST(6777.8840611106634/8.0), - REAL_CONST(6789.9847230596661/8.0), - REAL_CONST(6802.0907786635626/8.0), - REAL_CONST(6814.2022231205201/8.0), - REAL_CONST(6826.3190516393797/8.0), - REAL_CONST(6838.4412594396181/8.0), - REAL_CONST(6850.5688417513074/8.0), - REAL_CONST(6862.701793815083/8.0), - REAL_CONST(6874.840110882099/8.0), - REAL_CONST(6886.9837882139991/8.0), - REAL_CONST(6899.1328210828724/8.0), - REAL_CONST(6911.2872047712199/8.0), - REAL_CONST(6923.4469345719199/8.0), - REAL_CONST(6935.6120057881863/8.0), - REAL_CONST(6947.7824137335365/8.0), - REAL_CONST(6959.9581537317536/8.0), - REAL_CONST(6972.1392211168532/8.0), - REAL_CONST(6984.3256112330409/8.0), - REAL_CONST(6996.5173194346862/8.0), - REAL_CONST(7008.7143410862773/8.0), - REAL_CONST(7020.9166715623942/8.0), - REAL_CONST(7033.1243062476678/8.0), - REAL_CONST(7045.3372405367481/8.0), - REAL_CONST(7057.5554698342685/8.0), - REAL_CONST(7069.7789895548103/8.0), - REAL_CONST(7082.0077951228714/8.0), - REAL_CONST(7094.2418819728273/8.0), - REAL_CONST(7106.4812455489018/8.0), - REAL_CONST(7118.7258813051285/8.0), - REAL_CONST(7130.9757847053224/8.0), - REAL_CONST(7143.2309512230404/8.0), - REAL_CONST(7155.4913763415516/8.0), - REAL_CONST(7167.7570555538041/8.0), - REAL_CONST(7180.0279843623894/8.0), - REAL_CONST(7192.3041582795131/8.0), - REAL_CONST(7204.5855728269571/8.0), - REAL_CONST(7216.8722235360519/8.0), - REAL_CONST(7229.1641059476406/8.0), - REAL_CONST(7241.4612156120484/8.0), - REAL_CONST(7253.7635480890503/8.0), - REAL_CONST(7266.0710989478375/8.0), - REAL_CONST(7278.3838637669869/8.0), - REAL_CONST(7290.7018381344296/8.0), - REAL_CONST(7303.0250176474174/8.0), - REAL_CONST(7315.3533979124932/8.0), - REAL_CONST(7327.6869745454596/8.0), - REAL_CONST(7340.0257431713462/8.0), - REAL_CONST(7352.3696994243801/8.0), - REAL_CONST(7364.7188389479543/8.0), - REAL_CONST(7377.0731573945968/8.0), - REAL_CONST(7389.4326504259407/8.0), - REAL_CONST(7401.7973137126937/8.0), - REAL_CONST(7414.1671429346061/8.0), - REAL_CONST(7426.5421337804428/8.0), - REAL_CONST(7438.922281947951/8.0), - REAL_CONST(7451.3075831438346/8.0), - REAL_CONST(7463.6980330837177/8.0), - REAL_CONST(7476.0936274921214/8.0), - REAL_CONST(7488.4943621024304/8.0), - REAL_CONST(7500.9002326568652/8.0), - REAL_CONST(7513.3112349064522/8.0), - REAL_CONST(7525.7273646109943/8.0), - REAL_CONST(7538.1486175390446/8.0), - REAL_CONST(7550.5749894678729/8.0), - REAL_CONST(7563.0064761834419/8.0), - REAL_CONST(7575.4430734803736/8.0), - REAL_CONST(7587.8847771619248/8.0), - REAL_CONST(7600.3315830399597/8.0), - REAL_CONST(7612.7834869349153/8.0), - REAL_CONST(7625.24048467578/8.0), - REAL_CONST(7637.7025721000637/8.0), - REAL_CONST(7650.1697450537677/8.0), - REAL_CONST(7662.6419993913596/8.0), - REAL_CONST(7675.1193309757446/8.0), - REAL_CONST(7687.6017356782404/8.0), - REAL_CONST(7700.0892093785433/8.0), - REAL_CONST(7712.5817479647112/8.0), - REAL_CONST(7725.079347333125/8.0), - REAL_CONST(7737.5820033884729/8.0), - REAL_CONST(7750.0897120437139/8.0), - REAL_CONST(7762.6024692200581/8.0), - REAL_CONST(7775.1202708469355/8.0), - REAL_CONST(7787.6431128619733/8.0), - REAL_CONST(7800.1709912109645/8.0), - REAL_CONST(7812.7039018478481/8.0), - REAL_CONST(7825.2418407346768/8.0), - REAL_CONST(7837.7848038415968/8.0), - REAL_CONST(7850.3327871468155/8.0), - REAL_CONST(7862.8857866365806/8.0), - REAL_CONST(7875.4437983051539/8.0), - REAL_CONST(7888.006818154784/8.0), - REAL_CONST(7900.5748421956796/8.0), - REAL_CONST(7913.1478664459901/8.0), - REAL_CONST(7925.725886931772/8.0), - REAL_CONST(7938.3088996869719/8.0), - REAL_CONST(7950.8969007533951/8.0), - REAL_CONST(7963.4898861806851/8.0), - REAL_CONST(7976.0878520262959/8.0), - REAL_CONST(7988.6907943554688/8.0), - REAL_CONST(8001.2987092412086/8.0), - REAL_CONST(8013.911592764257/8.0), - REAL_CONST(8026.5294410130691/8.0), - REAL_CONST(8039.1522500837891/8.0), - REAL_CONST(8051.7800160802271/8.0), - REAL_CONST(8064.412735113835/8.0), - REAL_CONST(8077.0504033036796/8.0), - REAL_CONST(8089.6930167764222/8.0), - REAL_CONST(8102.3405716662946/8.0), - REAL_CONST(8114.9930641150731/8.0), - REAL_CONST(8127.6504902720571/8.0), - REAL_CONST(8140.3128462940449/8.0), - REAL_CONST(8152.9801283453098/8.0), - REAL_CONST(8165.6523325975786/8.0), - REAL_CONST(8178.3294552300049/8.0), - REAL_CONST(8191.0114924291529/8.0), - REAL_CONST(8203.6984403889655/8.0), - REAL_CONST(8216.3902953107463/8.0), - REAL_CONST(8229.0870534031419/8.0), - REAL_CONST(8241.7887108821069/8.0), - REAL_CONST(8254.4952639708936/8.0), - REAL_CONST(8267.2067089000211/8.0), - REAL_CONST(8279.9230419072574/8.0), - REAL_CONST(8292.6442592375952/8.0), - REAL_CONST(8305.3703571432306/8.0), - REAL_CONST(8318.101331883543/8.0), - REAL_CONST(8330.8371797250657/8.0), - REAL_CONST(8343.577896941475/8.0), - REAL_CONST(8356.3234798135582/8.0), - REAL_CONST(8369.0739246291978/8.0), - REAL_CONST(8381.8292276833508/8.0), - REAL_CONST(8394.5893852780209/8.0), - REAL_CONST(8407.3543937222421/8.0), - REAL_CONST(8420.1242493320569/8.0), - REAL_CONST(8432.8989484304948/8.0), - REAL_CONST(8445.6784873475499/8.0), - REAL_CONST(8458.4628624201578/8.0), - REAL_CONST(8471.2520699921806/8.0), - REAL_CONST(8484.0461064143838/8.0), - REAL_CONST(8496.8449680444082/8.0), - REAL_CONST(8509.6486512467636/8.0), - REAL_CONST(8522.4571523927953/8.0), - REAL_CONST(8535.270467860666/8.0), - REAL_CONST(8548.0885940353437/8.0), - REAL_CONST(8560.9115273085663/8.0), - REAL_CONST(8573.7392640788403/8.0), - REAL_CONST(8586.5718007514006/8.0), - REAL_CONST(8599.4091337382069/8.0), - REAL_CONST(8612.2512594579148/8.0), - REAL_CONST(8625.0981743358552/8.0), - REAL_CONST(8637.9498748040205/8.0), - REAL_CONST(8650.8063573010386/8.0), - REAL_CONST(8663.6676182721567/8.0), - REAL_CONST(8676.533654169225/8.0), - REAL_CONST(8689.4044614506638/8.0), - REAL_CONST(8702.2800365814601/8.0), - REAL_CONST(8715.1603760331418/8.0), - REAL_CONST(8728.0454762837508/8.0), - REAL_CONST(8740.9353338178389/8.0), - REAL_CONST(8753.8299451264356/8.0), - REAL_CONST(8766.7293067070332/8.0), - REAL_CONST(8779.6334150635721/8.0), - REAL_CONST(8792.5422667064158/8.0), - REAL_CONST(8805.4558581523324/8.0), - REAL_CONST(8818.3741859244819/8.0), - REAL_CONST(8831.2972465523908/8.0), - REAL_CONST(8844.2250365719356/8.0), - REAL_CONST(8857.1575525253265/8.0), - REAL_CONST(8870.0947909610859/8.0), - REAL_CONST(8883.0367484340295/8.0), - REAL_CONST(8895.9834215052524/8.0), - REAL_CONST(8908.934806742107/8.0), - REAL_CONST(8921.8909007181846/8.0), - REAL_CONST(8934.8517000132997/8.0), - REAL_CONST(8947.817201213471/8.0), - REAL_CONST(8960.7874009109/8.0), - REAL_CONST(8973.7622957039603/8.0), - REAL_CONST(8986.7418821971733/8.0), - REAL_CONST(8999.7261570011924/8.0), - REAL_CONST(9012.7151167327884/8.0), - REAL_CONST(9025.7087580148236/8.0), - REAL_CONST(9038.7070774762469/8.0), - REAL_CONST(9051.7100717520643/8.0), - REAL_CONST(9064.7177374833282/8.0), - REAL_CONST(9077.7300713171153/8.0), - REAL_CONST(9090.7470699065179/8.0), - REAL_CONST(9103.7687299106146/8.0), - REAL_CONST(9116.7950479944648/8.0), - REAL_CONST(9129.8260208290812/8.0), - REAL_CONST(9142.8616450914233/8.0), - REAL_CONST(9155.9019174643727/8.0), - REAL_CONST(9168.9468346367157/8.0), - REAL_CONST(9181.9963933031358/8.0), - REAL_CONST(9195.0505901641845/8.0), - REAL_CONST(9208.1094219262741/8.0), - REAL_CONST(9221.1728853016557/8.0), - REAL_CONST(9234.240977008405/8.0), - REAL_CONST(9247.3136937704076/8.0), - REAL_CONST(9260.3910323173386/8.0), - REAL_CONST(9273.472989384647/8.0), - REAL_CONST(9286.5595617135423/8.0), - REAL_CONST(9299.6507460509747/8.0), - REAL_CONST(9312.7465391496207/8.0), - REAL_CONST(9325.8469377678684/8.0), - REAL_CONST(9338.9519386698012/8.0), - REAL_CONST(9352.0615386251757/8.0), - REAL_CONST(9365.1757344094131/8.0), - REAL_CONST(9378.2945228035842/8.0), - REAL_CONST(9391.4179005943843/8.0), - REAL_CONST(9404.5458645741273/8.0), - REAL_CONST(9417.6784115407263/8.0), - REAL_CONST(9430.8155382976747/8.0), - REAL_CONST(9443.9572416540359/8.0), - REAL_CONST(9457.1035184244265/8.0), - REAL_CONST(9470.2543654290002/8.0), - REAL_CONST(9483.4097794934296/8.0), - REAL_CONST(9496.5697574488931/8.0), - REAL_CONST(9509.7342961320664/8.0), - REAL_CONST(9522.9033923850911/8.0), - REAL_CONST(9536.0770430555804/8.0), - REAL_CONST(9549.2552449965824/8.0), - REAL_CONST(9562.4379950665825/8.0), - REAL_CONST(9575.6252901294793/8.0), - REAL_CONST(9588.8171270545736/8.0), - REAL_CONST(9602.0135027165488/8.0), - REAL_CONST(9615.2144139954635/8.0), - REAL_CONST(9628.4198577767274/8.0), - REAL_CONST(9641.629830951093/8.0), - REAL_CONST(9654.844330414644/8.0), - REAL_CONST(9668.0633530687719/8.0), - REAL_CONST(9681.286895820167/8.0), - REAL_CONST(9694.5149555808002/8.0), - REAL_CONST(9707.7475292679192/8.0), - REAL_CONST(9720.9846138040157/8.0), - REAL_CONST(9734.2262061168276/8.0), - REAL_CONST(9747.4723031393187/8.0), - REAL_CONST(9760.7229018096641/8.0), - REAL_CONST(9773.9779990712323/8.0), - REAL_CONST(9787.2375918725811/8.0), - REAL_CONST(9800.5016771674327/8.0), - REAL_CONST(9813.7702519146696/8.0), - REAL_CONST(9827.0433130783094/8.0), - REAL_CONST(9840.3208576275028/8.0), - REAL_CONST(9853.602882536512/8.0), - REAL_CONST(9866.8893847846994/8.0), - REAL_CONST(9880.1803613565116/8.0), - REAL_CONST(9893.4758092414686/8.0), - REAL_CONST(9906.7757254341523/8.0), - REAL_CONST(9920.0801069341851/8.0), - REAL_CONST(9933.3889507462245/8.0), - REAL_CONST(9946.7022538799429/8.0), - REAL_CONST(9960.0200133500221/8.0), - REAL_CONST(9973.3422261761298/8.0), - REAL_CONST(9986.6688893829159/8.0), - REAL_CONST(9999.9999999999945/8.0), - REAL_CONST(10013.335555061929/8.0), - REAL_CONST(10026.675551608221/8.0), - REAL_CONST(10040.019986683301/8.0), - REAL_CONST(10053.368857336509/8.0), - REAL_CONST(10066.722160622081/8.0), - REAL_CONST(10080.079893599144/8.0), - REAL_CONST(10093.442053331697/8.0), - REAL_CONST(10106.808636888598/8.0), - REAL_CONST(10120.179641343551/8.0), - REAL_CONST(10133.555063775095/8.0), - REAL_CONST(10146.934901266595/8.0), - REAL_CONST(10160.31915090622/8.0), - REAL_CONST(10173.707809786936/8.0), - REAL_CONST(10187.100875006496/8.0), - REAL_CONST(10200.498343667417/8.0), - REAL_CONST(10213.900212876984/8.0), - REAL_CONST(10227.306479747222/8.0), - REAL_CONST(10240.717141394889/8.0), - REAL_CONST(10254.132194941467/8.0), - REAL_CONST(10267.551637513146/8.0), - REAL_CONST(10280.975466240814/8.0), - REAL_CONST(10294.40367826004/8.0), - REAL_CONST(10307.836270711066/8.0), - REAL_CONST(10321.273240738796/8.0), - REAL_CONST(10334.71458549278/8.0) -#ifdef BIG_IQ_TABLE - ,REAL_CONST(10348.160302127204/8.0), - REAL_CONST(10361.610387800878/8.0), - REAL_CONST(10375.064839677221/8.0), - REAL_CONST(10388.523654924258/8.0), - REAL_CONST(10401.986830714593/8.0), - REAL_CONST(10415.454364225412/8.0), - REAL_CONST(10428.926252638465/8.0), - REAL_CONST(10442.402493140049/8.0), - REAL_CONST(10455.883082921007/8.0), - REAL_CONST(10469.368019176709/8.0), - REAL_CONST(10482.85729910704/8.0), - REAL_CONST(10496.350919916393/8.0), - REAL_CONST(10509.848878813653/8.0), - REAL_CONST(10523.351173012188/8.0), - REAL_CONST(10536.857799729838/8.0), - REAL_CONST(10550.3687561889/8.0), - REAL_CONST(10563.884039616123/8.0), - REAL_CONST(10577.403647242685/8.0), - REAL_CONST(10590.927576304197/8.0), - REAL_CONST(10604.455824040679/8.0), - REAL_CONST(10617.988387696556/8.0), - REAL_CONST(10631.525264520642/8.0), - REAL_CONST(10645.066451766135/8.0), - REAL_CONST(10658.611946690598/8.0), - REAL_CONST(10672.161746555956/8.0), - REAL_CONST(10685.715848628475/8.0), - REAL_CONST(10699.274250178762/8.0), - REAL_CONST(10712.836948481747/8.0), - REAL_CONST(10726.403940816675/8.0), - REAL_CONST(10739.975224467091/8.0), - REAL_CONST(10753.550796720834/8.0), - REAL_CONST(10767.130654870027/8.0), - REAL_CONST(10780.714796211059/8.0), - REAL_CONST(10794.303218044579/8.0), - REAL_CONST(10807.895917675487/8.0), - REAL_CONST(10821.492892412922/8.0), - REAL_CONST(10835.094139570248/8.0), - REAL_CONST(10848.699656465047/8.0), - REAL_CONST(10862.309440419107/8.0), - REAL_CONST(10875.923488758415/8.0), - REAL_CONST(10889.541798813138/8.0), - REAL_CONST(10903.16436791762/8.0), - REAL_CONST(10916.791193410372/8.0), - REAL_CONST(10930.422272634056/8.0), - REAL_CONST(10944.05760293548/8.0), - REAL_CONST(10957.697181665582/8.0), - REAL_CONST(10971.341006179427/8.0), - REAL_CONST(10984.98907383619/8.0), - REAL_CONST(10998.641381999149/8.0), - REAL_CONST(11012.297928035676/8.0), - REAL_CONST(11025.958709317223/8.0), - REAL_CONST(11039.623723219316/8.0), - REAL_CONST(11053.292967121541/8.0), - REAL_CONST(11066.966438407539/8.0), - REAL_CONST(11080.64413446499/8.0), - REAL_CONST(11094.326052685608/8.0), - REAL_CONST(11108.012190465128/8.0), - REAL_CONST(11121.702545203296/8.0), - REAL_CONST(11135.397114303863/8.0), - REAL_CONST(11149.095895174571/8.0), - REAL_CONST(11162.798885227143/8.0), - REAL_CONST(11176.506081877278/8.0), - REAL_CONST(11190.217482544635/8.0), - REAL_CONST(11203.933084652828/8.0), - REAL_CONST(11217.652885629415/8.0), - REAL_CONST(11231.376882905886/8.0), - REAL_CONST(11245.105073917659/8.0), - REAL_CONST(11258.837456104062/8.0), - REAL_CONST(11272.574026908333/8.0), - REAL_CONST(11286.314783777601/8.0), - REAL_CONST(11300.059724162888/8.0), - REAL_CONST(11313.808845519083/8.0), - REAL_CONST(11327.562145304952/8.0), - REAL_CONST(11341.319620983111/8.0), - REAL_CONST(11355.081270020033/8.0), - REAL_CONST(11368.847089886023/8.0), - REAL_CONST(11382.617078055218/8.0), - REAL_CONST(11396.391232005579/8.0), - REAL_CONST(11410.169549218874/8.0), - REAL_CONST(11423.952027180676/8.0), - REAL_CONST(11437.738663380349/8.0), - REAL_CONST(11451.529455311042/8.0), - REAL_CONST(11465.324400469679/8.0), - REAL_CONST(11479.123496356951/8.0), - REAL_CONST(11492.926740477304/8.0), - REAL_CONST(11506.734130338931/8.0), - REAL_CONST(11520.545663453764/8.0), - REAL_CONST(11534.361337337466/8.0), - REAL_CONST(11548.181149509423/8.0), - REAL_CONST(11562.005097492724/8.0), - REAL_CONST(11575.83317881417/8.0), - REAL_CONST(11589.665391004253/8.0), - REAL_CONST(11603.501731597149/8.0), - REAL_CONST(11617.342198130715/8.0), - REAL_CONST(11631.186788146468/8.0), - REAL_CONST(11645.035499189589/8.0), - REAL_CONST(11658.888328808911/8.0), - REAL_CONST(11672.745274556904/8.0), - REAL_CONST(11686.606333989675/8.0), - REAL_CONST(11700.471504666955/8.0), - REAL_CONST(11714.340784152086/8.0), - REAL_CONST(11728.214170012021/8.0), - REAL_CONST(11742.091659817312/8.0), - REAL_CONST(11755.973251142101/8.0), - REAL_CONST(11769.858941564111/8.0), - REAL_CONST(11783.748728664636/8.0), - REAL_CONST(11797.642610028539/8.0), - REAL_CONST(11811.540583244237/8.0), - REAL_CONST(11825.442645903697/8.0), - REAL_CONST(11839.34879560242/8.0), - REAL_CONST(11853.259029939445/8.0), - REAL_CONST(11867.173346517333/8.0), - REAL_CONST(11881.091742942155/8.0), - REAL_CONST(11895.014216823492/8.0), - REAL_CONST(11908.940765774427/8.0), - REAL_CONST(11922.871387411526/8.0), - REAL_CONST(11936.806079354839/8.0), - REAL_CONST(11950.744839227897/8.0), - REAL_CONST(11964.687664657684/8.0), - REAL_CONST(11978.634553274653/8.0), - REAL_CONST(11992.585502712702/8.0), - REAL_CONST(12006.540510609168/8.0), - REAL_CONST(12020.499574604828/8.0), - REAL_CONST(12034.462692343877/8.0), - REAL_CONST(12048.429861473938/8.0), - REAL_CONST(12062.401079646032/8.0), - REAL_CONST(12076.376344514589/8.0), - REAL_CONST(12090.355653737433/8.0), - REAL_CONST(12104.339004975769/8.0), - REAL_CONST(12118.326395894188/8.0), - REAL_CONST(12132.317824160644/8.0), - REAL_CONST(12146.313287446457/8.0), - REAL_CONST(12160.312783426305/8.0), - REAL_CONST(12174.316309778205/8.0), - REAL_CONST(12188.323864183525/8.0), - REAL_CONST(12202.335444326955/8.0), - REAL_CONST(12216.351047896511/8.0), - REAL_CONST(12230.370672583531/8.0), - REAL_CONST(12244.394316082657/8.0), - REAL_CONST(12258.421976091831/8.0), - REAL_CONST(12272.453650312296/8.0), - REAL_CONST(12286.489336448574/8.0), - REAL_CONST(12300.529032208471/8.0), - REAL_CONST(12314.572735303058/8.0), - REAL_CONST(12328.620443446678/8.0), - REAL_CONST(12342.672154356922/8.0), - REAL_CONST(12356.727865754638/8.0), - REAL_CONST(12370.787575363909/8.0), - REAL_CONST(12384.851280912055/8.0), - REAL_CONST(12398.918980129623/8.0), - REAL_CONST(12412.990670750381/8.0), - REAL_CONST(12427.066350511306/8.0), - REAL_CONST(12441.146017152583/8.0), - REAL_CONST(12455.229668417589/8.0), - REAL_CONST(12469.317302052901/8.0), - REAL_CONST(12483.40891580827/8.0), - REAL_CONST(12497.50450743663/8.0), - REAL_CONST(12511.604074694078/8.0), - REAL_CONST(12525.707615339878/8.0), - REAL_CONST(12539.815127136444/8.0), - REAL_CONST(12553.926607849342/8.0), - REAL_CONST(12568.042055247275/8.0), - REAL_CONST(12582.161467102082/8.0), - REAL_CONST(12596.284841188726/8.0), - REAL_CONST(12610.41217528529/8.0), - REAL_CONST(12624.543467172971/8.0), - REAL_CONST(12638.678714636069/8.0), - REAL_CONST(12652.817915461985/8.0), - REAL_CONST(12666.961067441209/8.0), - REAL_CONST(12681.108168367316/8.0), - REAL_CONST(12695.259216036962/8.0), - REAL_CONST(12709.414208249869/8.0), - REAL_CONST(12723.573142808827/8.0), - REAL_CONST(12737.736017519681/8.0), - REAL_CONST(12751.902830191326/8.0), - REAL_CONST(12766.073578635704/8.0), - REAL_CONST(12780.248260667788/8.0), - REAL_CONST(12794.426874105588/8.0), - REAL_CONST(12808.609416770132/8.0), - REAL_CONST(12822.795886485468/8.0), - REAL_CONST(12836.986281078653/8.0), - REAL_CONST(12851.180598379744/8.0), - REAL_CONST(12865.378836221802/8.0), - REAL_CONST(12879.580992440871/8.0), - REAL_CONST(12893.787064875984/8.0), - REAL_CONST(12907.997051369144/8.0), - REAL_CONST(12922.210949765335/8.0), - REAL_CONST(12936.428757912496/8.0), - REAL_CONST(12950.650473661524/8.0), - REAL_CONST(12964.876094866273/8.0), - REAL_CONST(12979.105619383534/8.0), - REAL_CONST(12993.339045073039/8.0), - REAL_CONST(13007.576369797454/8.0), - REAL_CONST(13021.817591422368/8.0), - REAL_CONST(13036.062707816285/8.0), - REAL_CONST(13050.311716850629/8.0), - REAL_CONST(13064.564616399723/8.0), - REAL_CONST(13078.821404340792/8.0), - REAL_CONST(13093.082078553954/8.0), - REAL_CONST(13107.346636922217/8.0), - REAL_CONST(13121.615077331464/8.0), - REAL_CONST(13135.887397670458/8.0), - REAL_CONST(13150.163595830827/8.0), - REAL_CONST(13164.44366970706/8.0), - REAL_CONST(13178.727617196502/8.0), - REAL_CONST(13193.015436199352/8.0), - REAL_CONST(13207.307124618648/8.0), - REAL_CONST(13221.602680360265/8.0), - REAL_CONST(13235.902101332911/8.0), - REAL_CONST(13250.205385448118/8.0), - REAL_CONST(13264.512530620239/8.0), - REAL_CONST(13278.823534766434/8.0), - REAL_CONST(13293.138395806676/8.0), - REAL_CONST(13307.457111663734/8.0), - REAL_CONST(13321.779680263176/8.0), - REAL_CONST(13336.106099533356/8.0), - REAL_CONST(13350.436367405409/8.0), - REAL_CONST(13364.77048181325/8.0), - REAL_CONST(13379.108440693562/8.0), - REAL_CONST(13393.450241985796/8.0), - REAL_CONST(13407.795883632158/8.0), - REAL_CONST(13422.145363577607/8.0), - REAL_CONST(13436.498679769853/8.0), - REAL_CONST(13450.855830159346/8.0), - REAL_CONST(13465.216812699266/8.0), - REAL_CONST(13479.581625345529/8.0), - REAL_CONST(13493.950266056772/8.0), - REAL_CONST(13508.32273279435/8.0), - REAL_CONST(13522.699023522329/8.0), - REAL_CONST(13537.079136207483/8.0), - REAL_CONST(13551.463068819286/8.0), - REAL_CONST(13565.850819329906/8.0), - REAL_CONST(13580.2423857142/8.0), - REAL_CONST(13594.63776594971/8.0), - REAL_CONST(13609.036958016657/8.0), - REAL_CONST(13623.439959897927/8.0), - REAL_CONST(13637.846769579081/8.0), - REAL_CONST(13652.257385048335/8.0), - REAL_CONST(13666.67180429656/8.0), - REAL_CONST(13681.090025317284/8.0), - REAL_CONST(13695.512046106669/8.0), - REAL_CONST(13709.937864663521/8.0), - REAL_CONST(13724.367478989278/8.0), - REAL_CONST(13738.800887088004/8.0), - REAL_CONST(13753.238086966385/8.0), - REAL_CONST(13767.679076633727/8.0), - REAL_CONST(13782.123854101939/8.0), - REAL_CONST(13796.572417385545/8.0), - REAL_CONST(13811.024764501659/8.0), - REAL_CONST(13825.480893469998/8.0), - REAL_CONST(13839.94080231286/8.0), - REAL_CONST(13854.404489055134/8.0), - REAL_CONST(13868.871951724283/8.0), - REAL_CONST(13883.34318835034/8.0), - REAL_CONST(13897.818196965914/8.0), - REAL_CONST(13912.296975606168/8.0), - REAL_CONST(13926.779522308825/8.0), - REAL_CONST(13941.26583511416/8.0), - REAL_CONST(13955.755912064991/8.0), - REAL_CONST(13970.249751206682/8.0), - REAL_CONST(13984.747350587126/8.0), - REAL_CONST(13999.248708256751/8.0), - REAL_CONST(14013.753822268511/8.0), - REAL_CONST(14028.262690677873/8.0), - REAL_CONST(14042.775311542828/8.0), - REAL_CONST(14057.291682923867/8.0), - REAL_CONST(14071.811802883994/8.0), - REAL_CONST(14086.335669488704/8.0), - REAL_CONST(14100.863280805994/8.0), - REAL_CONST(14115.394634906341/8.0), - REAL_CONST(14129.92972986271/8.0), - REAL_CONST(14144.468563750548/8.0), - REAL_CONST(14159.01113464777/8.0), - REAL_CONST(14173.55744063476/8.0), - REAL_CONST(14188.107479794369/8.0), - REAL_CONST(14202.661250211901/8.0), - REAL_CONST(14217.218749975118/8.0), - REAL_CONST(14231.779977174227/8.0), - REAL_CONST(14246.344929901879/8.0), - REAL_CONST(14260.913606253163/8.0), - REAL_CONST(14275.486004325601/8.0), - REAL_CONST(14290.062122219146/8.0), - REAL_CONST(14304.641958036171/8.0), - REAL_CONST(14319.225509881464/8.0), - REAL_CONST(14333.812775862236/8.0), - REAL_CONST(14348.403754088098/8.0), - REAL_CONST(14362.998442671067/8.0), - REAL_CONST(14377.59683972556/8.0), - REAL_CONST(14392.198943368388/8.0), - REAL_CONST(14406.804751718748/8.0), - REAL_CONST(14421.414262898223/8.0), - REAL_CONST(14436.027475030774/8.0), - REAL_CONST(14450.64438624274/8.0), - REAL_CONST(14465.264994662828/8.0), - REAL_CONST(14479.889298422106/8.0), - REAL_CONST(14494.517295654005/8.0), - REAL_CONST(14509.148984494313/8.0), - REAL_CONST(14523.784363081166/8.0), - REAL_CONST(14538.423429555049/8.0), - REAL_CONST(14553.066182058781/8.0), - REAL_CONST(14567.712618737527/8.0), - REAL_CONST(14582.362737738777/8.0), - REAL_CONST(14597.016537212348/8.0), - REAL_CONST(14611.674015310382/8.0), - REAL_CONST(14626.33517018734/8.0), - REAL_CONST(14640.999999999993/8.0), - REAL_CONST(14655.668502907418/8.0), - REAL_CONST(14670.340677071003/8.0), - REAL_CONST(14685.016520654426/8.0), - REAL_CONST(14699.696031823671/8.0), - REAL_CONST(14714.379208746999/8.0), - REAL_CONST(14729.066049594967/8.0), - REAL_CONST(14743.756552540408/8.0), - REAL_CONST(14758.45071575843/8.0), - REAL_CONST(14773.148537426418/8.0), - REAL_CONST(14787.850015724018/8.0), - REAL_CONST(14802.555148833142/8.0), - REAL_CONST(14817.263934937961/8.0), - REAL_CONST(14831.976372224897/8.0), - REAL_CONST(14846.692458882624/8.0), - REAL_CONST(14861.41219310206/8.0), - REAL_CONST(14876.135573076363/8.0), - REAL_CONST(14890.862597000923/8.0), - REAL_CONST(14905.593263073371/8.0), - REAL_CONST(14920.327569493558/8.0), - REAL_CONST(14935.065514463557/8.0), - REAL_CONST(14949.807096187662/8.0), - REAL_CONST(14964.552312872382/8.0), - REAL_CONST(14979.301162726431/8.0), - REAL_CONST(14994.053643960735/8.0), - REAL_CONST(15008.809754788414/8.0), - REAL_CONST(15023.569493424788/8.0), - REAL_CONST(15038.332858087369/8.0), - REAL_CONST(15053.099846995858/8.0), - REAL_CONST(15067.870458372134/8.0), - REAL_CONST(15082.644690440264/8.0), - REAL_CONST(15097.422541426484/8.0), - REAL_CONST(15112.204009559202/8.0), - REAL_CONST(15126.989093068994/8.0), - REAL_CONST(15141.777790188597/8.0), - REAL_CONST(15156.570099152905/8.0), - REAL_CONST(15171.366018198967/8.0), - REAL_CONST(15186.165545565986/8.0), - REAL_CONST(15200.968679495301/8.0), - REAL_CONST(15215.775418230402/8.0), - REAL_CONST(15230.585760016909/8.0), - REAL_CONST(15245.399703102579/8.0), - REAL_CONST(15260.217245737298/8.0), - REAL_CONST(15275.038386173073/8.0), - REAL_CONST(15289.863122664035/8.0), - REAL_CONST(15304.691453466432/8.0), - REAL_CONST(15319.523376838621/8.0), - REAL_CONST(15334.358891041069/8.0), - REAL_CONST(15349.197994336346/8.0), - REAL_CONST(15364.040684989128/8.0), - REAL_CONST(15378.886961266177/8.0), - REAL_CONST(15393.736821436356/8.0), - REAL_CONST(15408.590263770609/8.0), - REAL_CONST(15423.447286541972/8.0), - REAL_CONST(15438.307888025554/8.0), - REAL_CONST(15453.172066498542/8.0), - REAL_CONST(15468.039820240196/8.0), - REAL_CONST(15482.91114753184/8.0), - REAL_CONST(15497.786046656869/8.0), - REAL_CONST(15512.664515900733/8.0), - REAL_CONST(15527.546553550939/8.0), - REAL_CONST(15542.432157897045/8.0), - REAL_CONST(15557.32132723066/8.0), - REAL_CONST(15572.214059845435/8.0), - REAL_CONST(15587.110354037064/8.0), - REAL_CONST(15602.010208103273/8.0), - REAL_CONST(15616.913620343823/8.0), - REAL_CONST(15631.820589060506/8.0), - REAL_CONST(15646.731112557136/8.0), - REAL_CONST(15661.645189139546/8.0), - REAL_CONST(15676.562817115593/8.0), - REAL_CONST(15691.483994795139/8.0), - REAL_CONST(15706.408720490062/8.0), - REAL_CONST(15721.336992514242/8.0), - REAL_CONST(15736.268809183561/8.0), - REAL_CONST(15751.204168815901/8.0), - REAL_CONST(15766.143069731135/8.0), - REAL_CONST(15781.085510251132/8.0), - REAL_CONST(15796.03148869974/8.0), - REAL_CONST(15810.981003402798/8.0), - REAL_CONST(15825.934052688119/8.0), - REAL_CONST(15840.890634885489/8.0), - REAL_CONST(15855.850748326673/8.0), - REAL_CONST(15870.814391345401/8.0), - REAL_CONST(15885.781562277361/8.0), - REAL_CONST(15900.752259460214/8.0), - REAL_CONST(15915.726481233565/8.0), - REAL_CONST(15930.704225938984/8.0), - REAL_CONST(15945.685491919978/8.0), - REAL_CONST(15960.670277522009/8.0), - REAL_CONST(15975.658581092481/8.0), - REAL_CONST(15990.65040098073/8.0), - REAL_CONST(16005.645735538035/8.0), - REAL_CONST(16020.644583117599/8.0), - REAL_CONST(16035.646942074556/8.0), - REAL_CONST(16050.652810765967/8.0), - REAL_CONST(16065.662187550806/8.0), - REAL_CONST(16080.675070789974/8.0), - REAL_CONST(16095.691458846273/8.0), - REAL_CONST(16110.711350084424/8.0), - REAL_CONST(16125.734742871053/8.0), - REAL_CONST(16140.761635574685/8.0), - REAL_CONST(16155.792026565747/8.0), - REAL_CONST(16170.825914216561/8.0), - REAL_CONST(16185.863296901338/8.0), - REAL_CONST(16200.904172996183/8.0), - REAL_CONST(16215.948540879079/8.0), - REAL_CONST(16230.996398929899/8.0), - REAL_CONST(16246.047745530386/8.0), - REAL_CONST(16261.102579064163/8.0), - REAL_CONST(16276.160897916721/8.0), - REAL_CONST(16291.22270047542/8.0), - REAL_CONST(16306.287985129484/8.0), - REAL_CONST(16321.356750269995/8.0), - REAL_CONST(16336.428994289896/8.0), - REAL_CONST(16351.504715583982/8.0), - REAL_CONST(16366.5839125489/8.0), - REAL_CONST(16381.666583583141/8.0), - REAL_CONST(16396.752727087041/8.0), - REAL_CONST(16411.842341462776/8.0), - REAL_CONST(16426.935425114363/8.0), - REAL_CONST(16442.031976447644/8.0), - REAL_CONST(16457.131993870298/8.0), - REAL_CONST(16472.235475791829/8.0), - REAL_CONST(16487.342420623561/8.0), - REAL_CONST(16502.452826778641/8.0), - REAL_CONST(16517.566692672033/8.0), - REAL_CONST(16532.684016720516/8.0), - REAL_CONST(16547.804797342676/8.0), - REAL_CONST(16562.929032958902/8.0), - REAL_CONST(16578.056721991394/8.0), - REAL_CONST(16593.18786286415/8.0), - REAL_CONST(16608.322454002962/8.0), - REAL_CONST(16623.460493835417/8.0), - REAL_CONST(16638.601980790896/8.0), - REAL_CONST(16653.746913300558/8.0), - REAL_CONST(16668.895289797354/8.0), - REAL_CONST(16684.047108716015/8.0), - REAL_CONST(16699.202368493046/8.0), - REAL_CONST(16714.361067566726/8.0), - REAL_CONST(16729.523204377107/8.0), - REAL_CONST(16744.688777366009/8.0), - REAL_CONST(16759.857784977012/8.0), - REAL_CONST(16775.030225655464/8.0), - REAL_CONST(16790.206097848466/8.0), - REAL_CONST(16805.385400004874/8.0), - REAL_CONST(16820.568130575302/8.0), - REAL_CONST(16835.754288012104/8.0), - REAL_CONST(16850.943870769381/8.0), - REAL_CONST(16866.136877302983/8.0), - REAL_CONST(16881.333306070494/8.0), - REAL_CONST(16896.53315553123/8.0), - REAL_CONST(16911.736424146249/8.0), - REAL_CONST(16926.943110378332/8.0), - REAL_CONST(16942.153212691992/8.0), - REAL_CONST(16957.366729553454/8.0), - REAL_CONST(16972.583659430682/8.0), - REAL_CONST(16987.804000793338/8.0), - REAL_CONST(17003.027752112816/8.0), - REAL_CONST(17018.254911862205/8.0), - REAL_CONST(17033.485478516312/8.0), - REAL_CONST(17048.719450551645/8.0), - REAL_CONST(17063.956826446421/8.0), - REAL_CONST(17079.197604680547/8.0), - REAL_CONST(17094.44178373563/8.0), - REAL_CONST(17109.689362094967/8.0), - REAL_CONST(17124.940338243552/8.0), - REAL_CONST(17140.194710668064/8.0), - REAL_CONST(17155.452477856852/8.0), - REAL_CONST(17170.713638299967/8.0), - REAL_CONST(17185.978190489128/8.0), - REAL_CONST(17201.246132917724/8.0), - REAL_CONST(17216.517464080825/8.0), - REAL_CONST(17231.792182475165/8.0), - REAL_CONST(17247.070286599141/8.0), - REAL_CONST(17262.351774952826/8.0), - REAL_CONST(17277.636646037936/8.0), - REAL_CONST(17292.924898357855/8.0), - REAL_CONST(17308.216530417623/8.0), - REAL_CONST(17323.511540723921/8.0), - REAL_CONST(17338.809927785089/8.0), - REAL_CONST(17354.111690111105/8.0), - REAL_CONST(17369.416826213594/8.0), - REAL_CONST(17384.725334605821/8.0), - REAL_CONST(17400.037213802683/8.0), - REAL_CONST(17415.352462320716/8.0), - REAL_CONST(17430.67107867809/8.0), - REAL_CONST(17445.993061394587/8.0), - REAL_CONST(17461.318408991636/8.0), - REAL_CONST(17476.647119992274/8.0), - REAL_CONST(17491.979192921168/8.0), - REAL_CONST(17507.314626304586/8.0), - REAL_CONST(17522.653418670423/8.0), - REAL_CONST(17537.995568548187/8.0), - REAL_CONST(17553.341074468986/8.0), - REAL_CONST(17568.689934965536/8.0), - REAL_CONST(17584.042148572156/8.0), - REAL_CONST(17599.397713824768/8.0), - REAL_CONST(17614.75662926089/8.0), - REAL_CONST(17630.118893419625/8.0), - REAL_CONST(17645.484504841683/8.0), - REAL_CONST(17660.853462069354/8.0), - REAL_CONST(17676.225763646511/8.0), - REAL_CONST(17691.601408118619/8.0), - REAL_CONST(17706.980394032718/8.0), - REAL_CONST(17722.362719937424/8.0), - REAL_CONST(17737.748384382936/8.0), - REAL_CONST(17753.137385921014/8.0), - REAL_CONST(17768.529723104999/8.0), - REAL_CONST(17783.92539448979/8.0), - REAL_CONST(17799.324398631856/8.0), - REAL_CONST(17814.726734089225/8.0), - REAL_CONST(17830.13239942148/8.0), - REAL_CONST(17845.541393189767/8.0), - REAL_CONST(17860.95371395678/8.0), - REAL_CONST(17876.369360286772/8.0), - REAL_CONST(17891.788330745527/8.0), - REAL_CONST(17907.210623900395/8.0), - REAL_CONST(17922.636238320254/8.0), - REAL_CONST(17938.065172575527/8.0), - REAL_CONST(17953.497425238176/8.0), - REAL_CONST(17968.932994881692/8.0), - REAL_CONST(17984.371880081104/8.0), - REAL_CONST(17999.814079412972/8.0), - REAL_CONST(18015.259591455371/8.0), - REAL_CONST(18030.708414787914/8.0), - REAL_CONST(18046.160547991731/8.0), - REAL_CONST(18061.615989649465/8.0), - REAL_CONST(18077.074738345284/8.0), - REAL_CONST(18092.536792664861/8.0), - REAL_CONST(18108.002151195393/8.0), - REAL_CONST(18123.470812525571/8.0), - REAL_CONST(18138.942775245599/8.0), - REAL_CONST(18154.418037947191/8.0), - REAL_CONST(18169.896599223546/8.0), - REAL_CONST(18185.37845766938/8.0), - REAL_CONST(18200.863611880886/8.0), - REAL_CONST(18216.352060455767/8.0), - REAL_CONST(18231.843801993204/8.0), - REAL_CONST(18247.338835093873/8.0), - REAL_CONST(18262.837158359936/8.0), - REAL_CONST(18278.338770395032/8.0), - REAL_CONST(18293.84366980429/8.0), - REAL_CONST(18309.351855194309/8.0), - REAL_CONST(18324.863325173166/8.0), - REAL_CONST(18340.378078350412/8.0), - REAL_CONST(18355.896113337069/8.0), - REAL_CONST(18371.417428745623/8.0), - REAL_CONST(18386.942023190033/8.0), - REAL_CONST(18402.469895285718/8.0), - REAL_CONST(18418.00104364955/8.0), - REAL_CONST(18433.53546689987/8.0), - REAL_CONST(18449.073163656474/8.0), - REAL_CONST(18464.614132540602/8.0), - REAL_CONST(18480.158372174956/8.0), - REAL_CONST(18495.705881183676/8.0), - REAL_CONST(18511.256658192357/8.0), - REAL_CONST(18526.810701828035/8.0), - REAL_CONST(18542.368010719183/8.0), - REAL_CONST(18557.928583495715/8.0), - REAL_CONST(18573.492418788985/8.0), - REAL_CONST(18589.059515231773/8.0), - REAL_CONST(18604.629871458303/8.0), - REAL_CONST(18620.203486104212/8.0), - REAL_CONST(18635.78035780658/8.0), - REAL_CONST(18651.360485203899/8.0), - REAL_CONST(18666.943866936086/8.0), - REAL_CONST(18682.53050164448/8.0), - REAL_CONST(18698.120387971841/8.0), - REAL_CONST(18713.713524562332/8.0), - REAL_CONST(18729.30991006154/8.0), - REAL_CONST(18744.909543116457/8.0), - REAL_CONST(18760.512422375479/8.0), - REAL_CONST(18776.118546488418/8.0), - REAL_CONST(18791.727914106479/8.0), - REAL_CONST(18807.340523882274/8.0), - REAL_CONST(18822.95637446981/8.0), - REAL_CONST(18838.575464524489/8.0), - REAL_CONST(18854.197792703111/8.0), - REAL_CONST(18869.823357663863/8.0), - REAL_CONST(18885.452158066328/8.0), - REAL_CONST(18901.08419257147/8.0), - REAL_CONST(18916.719459841639/8.0), - REAL_CONST(18932.357958540564/8.0), - REAL_CONST(18947.999687333362/8.0), - REAL_CONST(18963.644644886521/8.0), - REAL_CONST(18979.292829867907/8.0), - REAL_CONST(18994.944240946759/8.0), - REAL_CONST(19010.598876793687/8.0), - REAL_CONST(19026.256736080668/8.0), - REAL_CONST(19041.917817481048/8.0), - REAL_CONST(19057.582119669532/8.0), - REAL_CONST(19073.2496413222/8.0), - REAL_CONST(19088.920381116473/8.0), - REAL_CONST(19104.594337731145/8.0), - REAL_CONST(19120.271509846356/8.0), - REAL_CONST(19135.951896143604/8.0), - REAL_CONST(19151.635495305738/8.0), - REAL_CONST(19167.322306016948/8.0), - REAL_CONST(19183.012326962784/8.0), - REAL_CONST(19198.705556830122/8.0), - REAL_CONST(19214.401994307198/8.0), - REAL_CONST(19230.101638083579/8.0), - REAL_CONST(19245.804486850167/8.0), - REAL_CONST(19261.510539299208/8.0), - REAL_CONST(19277.219794124274/8.0), - REAL_CONST(19292.932250020265/8.0), - REAL_CONST(19308.647905683421/8.0), - REAL_CONST(19324.366759811302/8.0), - REAL_CONST(19340.088811102793/8.0), - REAL_CONST(19355.8140582581/8.0), - REAL_CONST(19371.542499978754/8.0), - REAL_CONST(19387.2741349676/8.0), - REAL_CONST(19403.008961928797/8.0), - REAL_CONST(19418.746979567823/8.0), - REAL_CONST(19434.488186591469/8.0), - REAL_CONST(19450.232581707827/8.0), - REAL_CONST(19465.980163626304/8.0), - REAL_CONST(19481.730931057613/8.0), - REAL_CONST(19497.484882713761/8.0), - REAL_CONST(19513.242017308068/8.0), - REAL_CONST(19529.002333555141/8.0), - REAL_CONST(19544.765830170898/8.0), - REAL_CONST(19560.532505872539/8.0), - REAL_CONST(19576.302359378566/8.0), - REAL_CONST(19592.075389408761/8.0), - REAL_CONST(19607.851594684209/8.0), - REAL_CONST(19623.630973927269/8.0), - REAL_CONST(19639.41352586159/8.0), - REAL_CONST(19655.199249212103/8.0), - REAL_CONST(19670.988142705017/8.0), - REAL_CONST(19686.780205067826/8.0), - REAL_CONST(19702.575435029288/8.0), - REAL_CONST(19718.373831319448/8.0), - REAL_CONST(19734.175392669615/8.0), - REAL_CONST(19749.980117812371/8.0), - REAL_CONST(19765.788005481569/8.0), - REAL_CONST(19781.599054412323/8.0), - REAL_CONST(19797.413263341008/8.0), - REAL_CONST(19813.230631005274/8.0), - REAL_CONST(19829.051156144014/8.0), - REAL_CONST(19844.874837497395/8.0), - REAL_CONST(19860.701673806827/8.0), - REAL_CONST(19876.531663814985/8.0), - REAL_CONST(19892.364806265789/8.0), - REAL_CONST(19908.201099904403/8.0), - REAL_CONST(19924.040543477258/8.0), - REAL_CONST(19939.883135732012/8.0), - REAL_CONST(19955.728875417579/8.0), - REAL_CONST(19971.577761284105/8.0), - REAL_CONST(19987.429792082985/8.0), - REAL_CONST(20003.284966566847/8.0), - REAL_CONST(20019.14328348956/8.0), - REAL_CONST(20035.004741606219/8.0), - REAL_CONST(20050.869339673161/8.0), - REAL_CONST(20066.737076447946/8.0), - REAL_CONST(20082.607950689362/8.0), - REAL_CONST(20098.481961157428/8.0), - REAL_CONST(20114.359106613385/8.0), - REAL_CONST(20130.239385819699/8.0), - REAL_CONST(20146.122797540058/8.0), - REAL_CONST(20162.009340539353/8.0), - REAL_CONST(20177.899013583716/8.0), - REAL_CONST(20193.791815440476/8.0), - REAL_CONST(20209.687744878182/8.0), - REAL_CONST(20225.586800666591/8.0), - REAL_CONST(20241.488981576669/8.0), - REAL_CONST(20257.394286380597/8.0), - REAL_CONST(20273.302713851754/8.0), - REAL_CONST(20289.214262764715/8.0), - REAL_CONST(20305.128931895277/8.0), - REAL_CONST(20321.046720020415/8.0), - REAL_CONST(20336.967625918318/8.0), - REAL_CONST(20352.891648368361/8.0), - REAL_CONST(20368.818786151114/8.0), - REAL_CONST(20384.749038048347/8.0), - REAL_CONST(20400.682402843009/8.0), - REAL_CONST(20416.618879319249/8.0), - REAL_CONST(20432.558466262391/8.0), - REAL_CONST(20448.501162458953/8.0), - REAL_CONST(20464.446966696629/8.0), - REAL_CONST(20480.395877764302/8.0), - REAL_CONST(20496.347894452025/8.0), - REAL_CONST(20512.303015551031/8.0), - REAL_CONST(20528.261239853735/8.0), - REAL_CONST(20544.22256615372/8.0), - REAL_CONST(20560.186993245738/8.0), - REAL_CONST(20576.15451992572/8.0), - REAL_CONST(20592.125144990758/8.0), - REAL_CONST(20608.098867239107/8.0), - REAL_CONST(20624.075685470198/8.0), - REAL_CONST(20640.055598484618/8.0), - REAL_CONST(20656.038605084115/8.0), - REAL_CONST(20672.024704071595/8.0), - REAL_CONST(20688.013894251126/8.0), - REAL_CONST(20704.006174427926/8.0), - REAL_CONST(20720.001543408373/8.0), - REAL_CONST(20735.999999999989/8.0), - REAL_CONST(20752.001543011454/8.0), - REAL_CONST(20768.006171252597/8.0), - REAL_CONST(20784.013883534382/8.0), - REAL_CONST(20800.024678668931/8.0), - REAL_CONST(20816.038555469506/8.0), - REAL_CONST(20832.055512750507/8.0), - REAL_CONST(20848.075549327474/8.0), - REAL_CONST(20864.098664017085/8.0), - REAL_CONST(20880.124855637161/8.0), - REAL_CONST(20896.154123006647/8.0), - REAL_CONST(20912.186464945626/8.0), - REAL_CONST(20928.221880275312/8.0), - REAL_CONST(20944.260367818049/8.0), - REAL_CONST(20960.301926397311/8.0), - REAL_CONST(20976.346554837684/8.0), - REAL_CONST(20992.394251964895/8.0), - REAL_CONST(21008.445016605787/8.0), - REAL_CONST(21024.498847588318/8.0), - REAL_CONST(21040.555743741574/8.0), - REAL_CONST(21056.615703895754/8.0), - REAL_CONST(21072.678726882168/8.0), - REAL_CONST(21088.744811533252/8.0), - REAL_CONST(21104.813956682538/8.0), - REAL_CONST(21120.886161164683/8.0), - REAL_CONST(21136.961423815443/8.0), - REAL_CONST(21153.039743471683/8.0), - REAL_CONST(21169.121118971379/8.0), - REAL_CONST(21185.205549153605/8.0), - REAL_CONST(21201.293032858535/8.0), - REAL_CONST(21217.383568927453/8.0), - REAL_CONST(21233.477156202731/8.0), - REAL_CONST(21249.573793527841/8.0), - REAL_CONST(21265.673479747358/8.0), - REAL_CONST(21281.776213706937/8.0), - REAL_CONST(21297.881994253334/8.0), - REAL_CONST(21313.990820234398/8.0), - REAL_CONST(21330.102690499054/8.0), - REAL_CONST(21346.21760389733/8.0), - REAL_CONST(21362.335559280327/8.0), - REAL_CONST(21378.456555500241/8.0), - REAL_CONST(21394.580591410333/8.0), - REAL_CONST(21410.707665864964/8.0), - REAL_CONST(21426.83777771956/8.0), - REAL_CONST(21442.970925830628/8.0), - REAL_CONST(21459.107109055756/8.0), - REAL_CONST(21475.246326253604/8.0), - REAL_CONST(21491.388576283895/8.0), - REAL_CONST(21507.533858007431/8.0), - REAL_CONST(21523.682170286087/8.0), - REAL_CONST(21539.833511982797/8.0), - REAL_CONST(21555.987881961566/8.0), - REAL_CONST(21572.145279087465/8.0), - REAL_CONST(21588.305702226615/8.0), - REAL_CONST(21604.469150246216/8.0), - REAL_CONST(21620.635622014521/8.0), - REAL_CONST(21636.805116400832/8.0), - REAL_CONST(21652.977632275521/8.0), - REAL_CONST(21669.153168510009/8.0), - REAL_CONST(21685.331723976764/8.0), - REAL_CONST(21701.513297549318/8.0), - REAL_CONST(21717.697888102244/8.0), - REAL_CONST(21733.885494511167/8.0), - REAL_CONST(21750.076115652759/8.0), - REAL_CONST(21766.269750404736/8.0), - REAL_CONST(21782.466397645861/8.0), - REAL_CONST(21798.666056255934/8.0), - REAL_CONST(21814.868725115801/8.0), - REAL_CONST(21831.074403107345/8.0), - REAL_CONST(21847.283089113484/8.0), - REAL_CONST(21863.494782018177/8.0), - REAL_CONST(21879.709480706417/8.0), - REAL_CONST(21895.927184064229/8.0), - REAL_CONST(21912.147890978667/8.0), - REAL_CONST(21928.371600337818/8.0), - REAL_CONST(21944.598311030797/8.0), - REAL_CONST(21960.828021947746/8.0), - REAL_CONST(21977.060731979829/8.0), - REAL_CONST(21993.296440019243/8.0), - REAL_CONST(22009.535144959198/8.0), - REAL_CONST(22025.77684569393/8.0), - REAL_CONST(22042.021541118691/8.0), - REAL_CONST(22058.269230129757/8.0), - REAL_CONST(22074.519911624411/8.0), - REAL_CONST(22090.773584500959/8.0), - REAL_CONST(22107.030247658717/8.0), - REAL_CONST(22123.289899998013/8.0), - REAL_CONST(22139.552540420187/8.0), - REAL_CONST(22155.818167827587/8.0), - REAL_CONST(22172.086781123569/8.0), - REAL_CONST(22188.358379212495/8.0), - REAL_CONST(22204.632960999726/8.0), - REAL_CONST(22220.910525391639/8.0), - REAL_CONST(22237.191071295601/8.0), - REAL_CONST(22253.474597619981/8.0), - REAL_CONST(22269.761103274148/8.0), - REAL_CONST(22286.050587168469/8.0), - REAL_CONST(22302.343048214312/8.0), - REAL_CONST(22318.638485324027/8.0), - REAL_CONST(22334.936897410968/8.0), - REAL_CONST(22351.23828338947/8.0), - REAL_CONST(22367.542642174871/8.0), - REAL_CONST(22383.849972683485/8.0), - REAL_CONST(22400.160273832618/8.0), - REAL_CONST(22416.473544540564/8.0), - REAL_CONST(22432.789783726603/8.0), - REAL_CONST(22449.108990310986/8.0), - REAL_CONST(22465.431163214958/8.0), - REAL_CONST(22481.75630136074/8.0), - REAL_CONST(22498.084403671528/8.0), - REAL_CONST(22514.415469071497/8.0), - REAL_CONST(22530.749496485802/8.0), - REAL_CONST(22547.086484840562/8.0), - REAL_CONST(22563.426433062879/8.0), - REAL_CONST(22579.769340080824/8.0), - REAL_CONST(22596.115204823436/8.0), - REAL_CONST(22612.464026220721/8.0), - REAL_CONST(22628.815803203655/8.0), - REAL_CONST(22645.170534704179/8.0), - REAL_CONST(22661.5282196552/8.0), - REAL_CONST(22677.888856990587/8.0), - REAL_CONST(22694.252445645168/8.0), - REAL_CONST(22710.618984554734/8.0), - REAL_CONST(22726.988472656034/8.0), - REAL_CONST(22743.360908886778/8.0), - REAL_CONST(22759.736292185622/8.0), - REAL_CONST(22776.114621492186/8.0), - REAL_CONST(22792.495895747044/8.0), - REAL_CONST(22808.880113891719/8.0), - REAL_CONST(22825.267274868678/8.0), - REAL_CONST(22841.657377621348/8.0), - REAL_CONST(22858.050421094096/8.0), - REAL_CONST(22874.446404232243/8.0), - REAL_CONST(22890.845325982053/8.0), - REAL_CONST(22907.247185290722/8.0), - REAL_CONST(22923.651981106406/8.0), - REAL_CONST(22940.059712378195/8.0), - REAL_CONST(22956.470378056114/8.0), - REAL_CONST(22972.883977091129/8.0), - REAL_CONST(22989.300508435153/8.0), - REAL_CONST(23005.719971041017/8.0), - REAL_CONST(23022.142363862498/8.0), - REAL_CONST(23038.567685854305/8.0), - REAL_CONST(23054.995935972078/8.0), - REAL_CONST(23071.427113172387/8.0), - REAL_CONST(23087.86121641273/8.0), - REAL_CONST(23104.298244651531/8.0), - REAL_CONST(23120.738196848146/8.0), - REAL_CONST(23137.181071962848/8.0), - REAL_CONST(23153.626868956846/8.0), - REAL_CONST(23170.075586792263/8.0), - REAL_CONST(23186.527224432142/8.0), - REAL_CONST(23202.981780840448/8.0), - REAL_CONST(23219.439254982066/8.0), - REAL_CONST(23235.899645822796/8.0), - REAL_CONST(23252.362952329357/8.0), - REAL_CONST(23268.829173469378/8.0), - REAL_CONST(23285.298308211408/8.0), - REAL_CONST(23301.770355524899/8.0), - REAL_CONST(23318.245314380223/8.0), - REAL_CONST(23334.723183748658/8.0), - REAL_CONST(23351.203962602387/8.0), - REAL_CONST(23367.687649914504/8.0), - REAL_CONST(23384.174244659007/8.0), - REAL_CONST(23400.663745810798/8.0), - REAL_CONST(23417.15615234568/8.0), - REAL_CONST(23433.651463240367/8.0), - REAL_CONST(23450.149677472462/8.0), - REAL_CONST(23466.650794020472/8.0), - REAL_CONST(23483.154811863806/8.0), - REAL_CONST(23499.661729982763/8.0), - REAL_CONST(23516.171547358543/8.0), - REAL_CONST(23532.684262973235/8.0), - REAL_CONST(23549.199875809823/8.0), - REAL_CONST(23565.718384852185/8.0), - REAL_CONST(23582.239789085092/8.0), - REAL_CONST(23598.764087494197/8.0), - REAL_CONST(23615.291279066041/8.0), - REAL_CONST(23631.821362788058/8.0), - REAL_CONST(23648.354337648565/8.0), - REAL_CONST(23664.890202636761/8.0), - REAL_CONST(23681.428956742733/8.0), - REAL_CONST(23697.970598957443/8.0), - REAL_CONST(23714.515128272738/8.0), - REAL_CONST(23731.062543681343/8.0), - REAL_CONST(23747.612844176863/8.0), - REAL_CONST(23764.166028753778/8.0), - REAL_CONST(23780.72209640744/8.0), - REAL_CONST(23797.281046134085/8.0), - REAL_CONST(23813.842876930816/8.0), - REAL_CONST(23830.407587795606/8.0), - REAL_CONST(23846.975177727301/8.0), - REAL_CONST(23863.545645725622/8.0), - REAL_CONST(23880.11899079115/8.0), - REAL_CONST(23896.695211925336/8.0), - REAL_CONST(23913.274308130498/8.0), - REAL_CONST(23929.856278409821/8.0), - REAL_CONST(23946.441121767348/8.0), - REAL_CONST(23963.028837207989/8.0), - REAL_CONST(23979.619423737513/8.0), - REAL_CONST(23996.212880362549/8.0), - REAL_CONST(24012.809206090584/8.0), - REAL_CONST(24029.408399929966/8.0), - REAL_CONST(24046.010460889898/8.0), - REAL_CONST(24062.615387980433/8.0), - REAL_CONST(24079.223180212492/8.0), - REAL_CONST(24095.833836597827/8.0), - REAL_CONST(24112.447356149063/8.0), - REAL_CONST(24129.063737879667/8.0), - REAL_CONST(24145.682980803951/8.0), - REAL_CONST(24162.305083937081/8.0), - REAL_CONST(24178.930046295067/8.0), - REAL_CONST(24195.557866894767/8.0), - REAL_CONST(24212.188544753884/8.0), - REAL_CONST(24228.822078890964/8.0), - REAL_CONST(24245.458468325389/8.0), - REAL_CONST(24262.097712077397/8.0), - REAL_CONST(24278.739809168052/8.0), - REAL_CONST(24295.384758619261/8.0), - REAL_CONST(24312.032559453768/8.0), - REAL_CONST(24328.683210695162/8.0), - REAL_CONST(24345.336711367858/8.0), - REAL_CONST(24361.993060497109/8.0), - REAL_CONST(24378.652257108995/8.0), - REAL_CONST(24395.314300230442/8.0), - REAL_CONST(24411.979188889192/8.0), - REAL_CONST(24428.646922113825/8.0), - REAL_CONST(24445.317498933746/8.0), - REAL_CONST(24461.990918379193/8.0), - REAL_CONST(24478.667179481225/8.0), - REAL_CONST(24495.346281271726/8.0), - REAL_CONST(24512.028222783407/8.0), - REAL_CONST(24528.713003049801/8.0), - REAL_CONST(24545.400621105266/8.0), - REAL_CONST(24562.091075984976/8.0), - REAL_CONST(24578.784366724925/8.0), - REAL_CONST(24595.480492361927/8.0), - REAL_CONST(24612.179451933614/8.0), - REAL_CONST(24628.881244478438/8.0), - REAL_CONST(24645.585869035654/8.0), - REAL_CONST(24662.293324645343/8.0), - REAL_CONST(24679.003610348394/8.0), - REAL_CONST(24695.716725186514/8.0), - REAL_CONST(24712.432668202211/8.0), - REAL_CONST(24729.151438438807/8.0), - REAL_CONST(24745.873034940436/8.0), - REAL_CONST(24762.597456752032/8.0), - REAL_CONST(24779.324702919344/8.0), - REAL_CONST(24796.054772488926/8.0), - REAL_CONST(24812.787664508123/8.0), - REAL_CONST(24829.5233780251/8.0), - REAL_CONST(24846.261912088819/8.0), - REAL_CONST(24863.003265749034/8.0), - REAL_CONST(24879.747438056307/8.0), - REAL_CONST(24896.494428062004/8.0), - REAL_CONST(24913.244234818278/8.0), - REAL_CONST(24929.996857378079/8.0), - REAL_CONST(24946.752294795166/8.0), - REAL_CONST(24963.510546124078/8.0), - REAL_CONST(24980.271610420157/8.0), - REAL_CONST(24997.035486739525/8.0), - REAL_CONST(25013.802174139113/8.0), - REAL_CONST(25030.571671676629/8.0), - REAL_CONST(25047.343978410572/8.0), - REAL_CONST(25064.119093400237/8.0), - REAL_CONST(25080.897015705697/8.0), - REAL_CONST(25097.677744387816/8.0), - REAL_CONST(25114.461278508239/8.0), - REAL_CONST(25131.2476171294/8.0), - REAL_CONST(25148.036759314517/8.0), - REAL_CONST(25164.828704127583/8.0), - REAL_CONST(25181.623450633375/8.0), - REAL_CONST(25198.42099789745/8.0), - REAL_CONST(25215.221344986145/8.0), - REAL_CONST(25232.024490966574/8.0), - REAL_CONST(25248.830434906627/8.0), - REAL_CONST(25265.639175874974/8.0), - REAL_CONST(25282.450712941049/8.0), - REAL_CONST(25299.265045175071/8.0), - REAL_CONST(25316.082171648024/8.0), - REAL_CONST(25332.902091431668/8.0), - REAL_CONST(25349.724803598532/8.0), - REAL_CONST(25366.550307221914/8.0), - REAL_CONST(25383.378601375884/8.0), - REAL_CONST(25400.209685135269/8.0), - REAL_CONST(25417.043557575678/8.0), - REAL_CONST(25433.880217773472/8.0), - REAL_CONST(25450.719664805783/8.0), - REAL_CONST(25467.561897750507/8.0), - REAL_CONST(25484.406915686297/8.0), - REAL_CONST(25501.254717692573/8.0), - REAL_CONST(25518.105302849512/8.0), - REAL_CONST(25534.958670238051/8.0), - REAL_CONST(25551.814818939893/8.0), - REAL_CONST(25568.67374803748/8.0), - REAL_CONST(25585.535456614027/8.0), - REAL_CONST(25602.399943753502/8.0), - REAL_CONST(25619.267208540619/8.0), - REAL_CONST(25636.137250060852/8.0), - REAL_CONST(25653.010067400432/8.0), - REAL_CONST(25669.885659646327/8.0), - REAL_CONST(25686.76402588627/8.0), - REAL_CONST(25703.645165208734/8.0), - REAL_CONST(25720.529076702944/8.0), - REAL_CONST(25737.415759458876/8.0), - REAL_CONST(25754.305212567244/8.0), - REAL_CONST(25771.197435119517/8.0), - REAL_CONST(25788.092426207899/8.0), - REAL_CONST(25804.990184925344/8.0), - REAL_CONST(25821.890710365547/8.0), - REAL_CONST(25838.794001622944/8.0), - REAL_CONST(25855.700057792714/8.0), - REAL_CONST(25872.608877970775/8.0), - REAL_CONST(25889.520461253778/8.0), - REAL_CONST(25906.434806739118/8.0), - REAL_CONST(25923.351913524923/8.0), - REAL_CONST(25940.271780710063/8.0), - REAL_CONST(25957.194407394138/8.0), - REAL_CONST(25974.11979267748/8.0), - REAL_CONST(25991.047935661154/8.0), - REAL_CONST(26007.978835446964/8.0), - REAL_CONST(26024.912491137442/8.0), - REAL_CONST(26041.848901835841/8.0), - REAL_CONST(26058.788066646157/8.0), - REAL_CONST(26075.729984673108/8.0), - REAL_CONST(26092.674655022136/8.0), - REAL_CONST(26109.622076799409/8.0), - REAL_CONST(26126.572249111829/8.0), - REAL_CONST(26143.525171067016/8.0), - REAL_CONST(26160.480841773315/8.0), - REAL_CONST(26177.43926033979/8.0), - REAL_CONST(26194.400425876229/8.0), - REAL_CONST(26211.364337493149/8.0), - REAL_CONST(26228.330994301767/8.0), - REAL_CONST(26245.30039541404/8.0), - REAL_CONST(26262.272539942627/8.0), - REAL_CONST(26279.247427000919/8.0), - REAL_CONST(26296.225055703002/8.0), - REAL_CONST(26313.205425163702/8.0), - REAL_CONST(26330.188534498539/8.0), - REAL_CONST(26347.174382823756/8.0), - REAL_CONST(26364.162969256304/8.0), - REAL_CONST(26381.154292913852/8.0), - REAL_CONST(26398.148352914774/8.0), - REAL_CONST(26415.145148378149/8.0), - REAL_CONST(26432.144678423778/8.0), - REAL_CONST(26449.146942172156/8.0), - REAL_CONST(26466.151938744493/8.0), - REAL_CONST(26483.159667262702/8.0), - REAL_CONST(26500.170126849403/8.0), - REAL_CONST(26517.183316627921/8.0), - REAL_CONST(26534.199235722277/8.0), - REAL_CONST(26551.217883257199/8.0), - REAL_CONST(26568.239258358124/8.0), - REAL_CONST(26585.263360151173/8.0), - REAL_CONST(26602.290187763181/8.0), - REAL_CONST(26619.319740321676/8.0), - REAL_CONST(26636.352016954883/8.0), - REAL_CONST(26653.387016791727/8.0), - REAL_CONST(26670.424738961825/8.0), - REAL_CONST(26687.465182595493/8.0), - REAL_CONST(26704.508346823739/8.0), - REAL_CONST(26721.554230778267/8.0), - REAL_CONST(26738.602833591467/8.0), - REAL_CONST(26755.65415439643/8.0), - REAL_CONST(26772.708192326929/8.0), - REAL_CONST(26789.764946517433/8.0), - REAL_CONST(26806.824416103096/8.0), - REAL_CONST(26823.886600219761/8.0), - REAL_CONST(26840.95149800396/8.0), - REAL_CONST(26858.019108592915/8.0), - REAL_CONST(26875.089431124517/8.0), - REAL_CONST(26892.162464737365/8.0), - REAL_CONST(26909.238208570721/8.0), - REAL_CONST(26926.316661764544/8.0), - REAL_CONST(26943.397823459472/8.0), - REAL_CONST(26960.481692796813/8.0), - REAL_CONST(26977.568268918571/8.0), - REAL_CONST(26994.657550967422/8.0), - REAL_CONST(27011.749538086722/8.0), - REAL_CONST(27028.844229420498/8.0), - REAL_CONST(27045.941624113464/8.0), - REAL_CONST(27063.041721311005/8.0), - REAL_CONST(27080.144520159181/8.0), - REAL_CONST(27097.250019804727/8.0), - REAL_CONST(27114.35821939505/8.0), - REAL_CONST(27131.469118078236/8.0), - REAL_CONST(27148.582715003027/8.0), - REAL_CONST(27165.699009318858/8.0), - REAL_CONST(27182.818000175819/8.0), - REAL_CONST(27199.939686724665/8.0), - REAL_CONST(27217.064068116837/8.0), - REAL_CONST(27234.191143504428/8.0), - REAL_CONST(27251.320912040203/8.0), - REAL_CONST(27268.453372877593/8.0), - REAL_CONST(27285.588525170693/8.0), - REAL_CONST(27302.726368074269/8.0), - REAL_CONST(27319.866900743735/8.0), - REAL_CONST(27337.010122335181/8.0), - REAL_CONST(27354.156032005358/8.0), - REAL_CONST(27371.304628911668/8.0), - REAL_CONST(27388.455912212183/8.0), - REAL_CONST(27405.609881065626/8.0), - REAL_CONST(27422.766534631384/8.0), - REAL_CONST(27439.925872069507/8.0), - REAL_CONST(27457.087892540683/8.0), - REAL_CONST(27474.252595206275/8.0), - REAL_CONST(27491.419979228293/8.0), - REAL_CONST(27508.5900437694/8.0), - REAL_CONST(27525.762787992917/8.0), - REAL_CONST(27542.93821106281/8.0), - REAL_CONST(27560.116312143706/8.0), - REAL_CONST(27577.297090400876/8.0), - REAL_CONST(27594.480545000242/8.0), - REAL_CONST(27611.666675108383/8.0), - REAL_CONST(27628.855479892518/8.0), - REAL_CONST(27646.046958520514/8.0), - REAL_CONST(27663.241110160889/8.0), - REAL_CONST(27680.437933982801/8.0), - REAL_CONST(27697.637429156068/8.0), - REAL_CONST(27714.839594851132/8.0), - REAL_CONST(27732.04443023909/8.0), - REAL_CONST(27749.251934491687/8.0), - REAL_CONST(27766.462106781299/8.0), - REAL_CONST(27783.674946280949/8.0), - REAL_CONST(27800.890452164302/8.0), - REAL_CONST(27818.108623605654/8.0), - REAL_CONST(27835.329459779954/8.0), - REAL_CONST(27852.55295986278/8.0), - REAL_CONST(27869.779123030345/8.0), - REAL_CONST(27887.007948459504/8.0), - REAL_CONST(27904.239435327745/8.0), - REAL_CONST(27921.473582813196/8.0), - REAL_CONST(27938.710390094613/8.0), - REAL_CONST(27955.949856351392/8.0), - REAL_CONST(27973.19198076355/8.0), - REAL_CONST(27990.436762511745/8.0), - REAL_CONST(28007.684200777272/8.0), - REAL_CONST(28024.934294742041/8.0), - REAL_CONST(28042.187043588601/8.0), - REAL_CONST(28059.442446500128/8.0), - REAL_CONST(28076.700502660427/8.0), - REAL_CONST(28093.961211253929/8.0), - REAL_CONST(28111.224571465693/8.0), - REAL_CONST(28128.490582481401/8.0), - REAL_CONST(28145.759243487362/8.0), - REAL_CONST(28163.030553670509/8.0), - REAL_CONST(28180.304512218394/8.0), - REAL_CONST(28197.581118319198/8.0), - REAL_CONST(28214.860371161725/8.0), - REAL_CONST(28232.14226993539/8.0), - REAL_CONST(28249.42681383024/8.0), - REAL_CONST(28266.71400203693/8.0), - REAL_CONST(28284.003833746745/8.0), - REAL_CONST(28301.296308151585/8.0), - REAL_CONST(28318.591424443959/8.0), - REAL_CONST(28335.889181817001/8.0), - REAL_CONST(28353.189579464462/8.0), - REAL_CONST(28370.492616580705/8.0), - REAL_CONST(28387.798292360701/8.0), - REAL_CONST(28405.106606000048/8.0), - REAL_CONST(28422.417556694945/8.0), - REAL_CONST(28439.731143642206/8.0), - REAL_CONST(28457.047366039264/8.0), - REAL_CONST(28474.366223084147/8.0), - REAL_CONST(28491.687713975512/8.0), - REAL_CONST(28509.011837912611/8.0), - REAL_CONST(28526.338594095305/8.0), - REAL_CONST(28543.667981724069/8.0), - REAL_CONST(28560.999999999982/8.0), - REAL_CONST(28578.334648124732/8.0), - REAL_CONST(28595.671925300605/8.0), - REAL_CONST(28613.011830730498/8.0), - REAL_CONST(28630.354363617909/8.0), - REAL_CONST(28647.699523166943/8.0), - REAL_CONST(28665.0473085823/8.0), - REAL_CONST(28682.397719069289/8.0), - REAL_CONST(28699.750753833818/8.0), - REAL_CONST(28717.10641208239/8.0), - REAL_CONST(28734.464693022121/8.0), - REAL_CONST(28751.825595860708/8.0), - REAL_CONST(28769.189119806462/8.0), - REAL_CONST(28786.55526406828/8.0), - REAL_CONST(28803.924027855664/8.0), - REAL_CONST(28821.295410378701/8.0), - REAL_CONST(28838.669410848088/8.0), - REAL_CONST(28856.046028475103/8.0), - REAL_CONST(28873.425262471628/8.0), - REAL_CONST(28890.80711205013/8.0), - REAL_CONST(28908.191576423673/8.0), - REAL_CONST(28925.578654805915/8.0), - REAL_CONST(28942.968346411097/8.0), - REAL_CONST(28960.360650454055/8.0), - REAL_CONST(28977.755566150216/8.0), - REAL_CONST(28995.153092715591/8.0), - REAL_CONST(29012.553229366786/8.0), - REAL_CONST(29029.955975320987/8.0), - REAL_CONST(29047.361329795975/8.0), - REAL_CONST(29064.769292010107/8.0), - REAL_CONST(29082.179861182336/8.0), - REAL_CONST(29099.593036532187/8.0), - REAL_CONST(29117.00881727978/8.0), - REAL_CONST(29134.427202645813/8.0), - REAL_CONST(29151.848191851568/8.0), - REAL_CONST(29169.271784118911/8.0), - REAL_CONST(29186.697978670283/8.0), - REAL_CONST(29204.126774728706/8.0), - REAL_CONST(29221.55817151779/8.0), - REAL_CONST(29238.992168261717/8.0), - REAL_CONST(29256.42876418525/8.0), - REAL_CONST(29273.867958513725/8.0), - REAL_CONST(29291.309750473058/8.0), - REAL_CONST(29308.754139289747/8.0), - REAL_CONST(29326.201124190855/8.0), - REAL_CONST(29343.65070440403/8.0), - REAL_CONST(29361.102879157483/8.0), - REAL_CONST(29378.557647680012/8.0), - REAL_CONST(29396.015009200975/8.0), - REAL_CONST(29413.474962950309/8.0), - REAL_CONST(29430.937508158524/8.0), - REAL_CONST(29448.402644056692/8.0), - REAL_CONST(29465.870369876469/8.0), - REAL_CONST(29483.340684850071/8.0), - REAL_CONST(29500.81358821028/8.0), - REAL_CONST(29518.289079190454/8.0), - REAL_CONST(29535.767157024511/8.0), - REAL_CONST(29553.247820946945/8.0), - REAL_CONST(29570.731070192807/8.0), - REAL_CONST(29588.216903997723/8.0), - REAL_CONST(29605.70532159787/8.0), - REAL_CONST(29623.19632223/8.0), - REAL_CONST(29640.689905131429/8.0), - REAL_CONST(29658.186069540028/8.0), - REAL_CONST(29675.684814694236/8.0), - REAL_CONST(29693.186139833047/8.0), - REAL_CONST(29710.690044196028/8.0), - REAL_CONST(29728.196527023298/8.0), - REAL_CONST(29745.705587555527/8.0), - REAL_CONST(29763.217225033964/8.0), - REAL_CONST(29780.731438700397/8.0), - REAL_CONST(29798.248227797183/8.0), - REAL_CONST(29815.76759156723/8.0), - REAL_CONST(29833.289529254005/8.0), - REAL_CONST(29850.81404010153/8.0), - REAL_CONST(29868.341123354381/8.0), - REAL_CONST(29885.870778257693/8.0), - REAL_CONST(29903.403004057145/8.0), - REAL_CONST(29920.937799998974/8.0), - REAL_CONST(29938.475165329975/8.0), - REAL_CONST(29956.015099297485/8.0), - REAL_CONST(29973.557601149394/8.0), - REAL_CONST(29991.102670134147/8.0), - REAL_CONST(30008.650305500738/8.0), - REAL_CONST(30026.200506498706/8.0), - REAL_CONST(30043.753272378144/8.0), - REAL_CONST(30061.308602389683/8.0), - REAL_CONST(30078.866495784507/8.0), - REAL_CONST(30096.426951814352/8.0), - REAL_CONST(30113.989969731494/8.0), - REAL_CONST(30131.55554878875/8.0), - REAL_CONST(30149.123688239491/8.0), - REAL_CONST(30166.694387337629/8.0), - REAL_CONST(30184.267645337608/8.0), - REAL_CONST(30201.843461494434/8.0), - REAL_CONST(30219.42183506364/8.0), - REAL_CONST(30237.002765301309/8.0), - REAL_CONST(30254.586251464058/8.0), - REAL_CONST(30272.172292809046/8.0), - REAL_CONST(30289.760888593977/8.0), - REAL_CONST(30307.35203807709/8.0), - REAL_CONST(30324.94574051716/8.0), - REAL_CONST(30342.541995173502/8.0), - REAL_CONST(30360.140801305966/8.0), - REAL_CONST(30377.742158174944/8.0), - REAL_CONST(30395.346065041358/8.0), - REAL_CONST(30412.952521166666/8.0), - REAL_CONST(30430.561525812864/8.0), - REAL_CONST(30448.173078242475/8.0), - REAL_CONST(30465.787177718561/8.0), - REAL_CONST(30483.403823504719/8.0), - REAL_CONST(30501.02301486507/8.0), - REAL_CONST(30518.644751064272/8.0), - REAL_CONST(30536.269031367516/8.0), - REAL_CONST(30553.895855040515/8.0), - REAL_CONST(30571.525221349519/8.0), - REAL_CONST(30589.157129561307/8.0), - REAL_CONST(30606.791578943175/8.0), - REAL_CONST(30624.428568762964/8.0), - REAL_CONST(30642.06809828903/8.0), - REAL_CONST(30659.710166790261/8.0), - REAL_CONST(30677.35477353607/8.0), - REAL_CONST(30695.001917796391/8.0), - REAL_CONST(30712.651598841687/8.0), - REAL_CONST(30730.303815942945/8.0), - REAL_CONST(30747.958568371676/8.0), - REAL_CONST(30765.615855399912/8.0), - REAL_CONST(30783.275676300211/8.0), - REAL_CONST(30800.938030345646/8.0), - REAL_CONST(30818.602916809814/8.0), - REAL_CONST(30836.270334966837/8.0), - REAL_CONST(30853.940284091354/8.0), - REAL_CONST(30871.612763458521/8.0), - REAL_CONST(30889.287772344011/8.0), - REAL_CONST(30906.965310024025/8.0), - REAL_CONST(30924.645375775272/8.0), - REAL_CONST(30942.327968874983/8.0), - REAL_CONST(30960.013088600903/8.0), - REAL_CONST(30977.700734231294/8.0), - REAL_CONST(30995.390905044929/8.0), - REAL_CONST(31013.083600321101/8.0), - REAL_CONST(31030.778819339619/8.0), - REAL_CONST(31048.476561380798/8.0), - REAL_CONST(31066.17682572547/8.0), - REAL_CONST(31083.879611654978/8.0), - REAL_CONST(31101.584918451179/8.0), - REAL_CONST(31119.29274539644/8.0), - REAL_CONST(31137.003091773637/8.0), - REAL_CONST(31154.715956866155/8.0), - REAL_CONST(31172.431339957893/8.0), - REAL_CONST(31190.14924033326/8.0), - REAL_CONST(31207.869657277162/8.0), - REAL_CONST(31225.592590075023/8.0), - REAL_CONST(31243.318038012771/8.0), - REAL_CONST(31261.046000376838/8.0), - REAL_CONST(31278.776476454172/8.0), - REAL_CONST(31296.50946553221/8.0), - REAL_CONST(31314.24496689891/8.0), - REAL_CONST(31331.98297984272/8.0), - REAL_CONST(31349.7235036526/8.0), - REAL_CONST(31367.466537618013/8.0), - REAL_CONST(31385.212081028923/8.0), - REAL_CONST(31402.960133175795/8.0), - REAL_CONST(31420.710693349596/8.0), - REAL_CONST(31438.463760841791/8.0), - REAL_CONST(31456.219334944351/8.0), - REAL_CONST(31473.977414949743/8.0), - REAL_CONST(31491.738000150934/8.0), - REAL_CONST(31509.501089841389/8.0), - REAL_CONST(31527.266683315069/8.0), - REAL_CONST(31545.034779866437/8.0), - REAL_CONST(31562.80537879045/8.0), - REAL_CONST(31580.578479382562/8.0), - REAL_CONST(31598.35408093872/8.0), - REAL_CONST(31616.132182755369/8.0), - REAL_CONST(31633.91278412945/8.0), - REAL_CONST(31651.695884358396/8.0), - REAL_CONST(31669.481482740131/8.0), - REAL_CONST(31687.269578573076/8.0), - REAL_CONST(31705.060171156143/8.0), - REAL_CONST(31722.853259788735/8.0), - REAL_CONST(31740.648843770748/8.0), - REAL_CONST(31758.446922402567/8.0), - REAL_CONST(31776.247494985066/8.0), - REAL_CONST(31794.050560819614/8.0), - REAL_CONST(31811.85611920806/8.0), - REAL_CONST(31829.664169452753/8.0), - REAL_CONST(31847.474710856521/8.0), - REAL_CONST(31865.287742722685/8.0), - REAL_CONST(31883.103264355046/8.0), - REAL_CONST(31900.921275057899/8.0), - REAL_CONST(31918.741774136019/8.0), - REAL_CONST(31936.564760894671/8.0), - REAL_CONST(31954.390234639599/8.0), - REAL_CONST(31972.21819467704/8.0), - REAL_CONST(31990.048640313704/8.0), - REAL_CONST(32007.881570856793/8.0), - REAL_CONST(32025.716985613984/8.0), - REAL_CONST(32043.554883893445/8.0), - REAL_CONST(32061.395265003815/8.0), - REAL_CONST(32079.238128254223/8.0), - REAL_CONST(32097.083472954269/8.0), - REAL_CONST(32114.931298414049/8.0), - REAL_CONST(32132.781603944117/8.0), - REAL_CONST(32150.634388855524/8.0), - REAL_CONST(32168.48965245979/8.0), - REAL_CONST(32186.347394068915/8.0), - REAL_CONST(32204.207612995371/8.0), - REAL_CONST(32222.07030855212/8.0), - REAL_CONST(32239.935480052583/8.0), - REAL_CONST(32257.803126810672/8.0), - REAL_CONST(32275.673248140767/8.0), - REAL_CONST(32293.545843357719/8.0), - REAL_CONST(32311.420911776862/8.0), - REAL_CONST(32329.298452713996/8.0), - REAL_CONST(32347.178465485395/8.0), - REAL_CONST(32365.060949407813/8.0), - REAL_CONST(32382.945903798463/8.0), - REAL_CONST(32400.83332797504/8.0), - REAL_CONST(32418.723221255706/8.0), - REAL_CONST(32436.615582959093/8.0), - REAL_CONST(32454.510412404306/8.0), - REAL_CONST(32472.407708910916/8.0), - REAL_CONST(32490.307471798966/8.0), - REAL_CONST(32508.209700388961/8.0), - REAL_CONST(32526.114394001877/8.0), - REAL_CONST(32544.021551959166/8.0), - REAL_CONST(32561.931173582732/8.0), - REAL_CONST(32579.843258194956/8.0), - REAL_CONST(32597.757805118679/8.0), - REAL_CONST(32615.674813677211/8.0), - REAL_CONST(32633.594283194328/8.0), - REAL_CONST(32651.516212994258/8.0), - REAL_CONST(32669.440602401712/8.0), - REAL_CONST(32687.367450741847/8.0), - REAL_CONST(32705.296757340297/8.0), - REAL_CONST(32723.228521523146/8.0), - REAL_CONST(32741.162742616943/8.0), - REAL_CONST(32759.099419948703/8.0), - REAL_CONST(32777.038552845901/8.0), - REAL_CONST(32794.980140636464/8.0), - REAL_CONST(32812.924182648792/8.0), - REAL_CONST(32830.87067821173/8.0), - REAL_CONST(32848.819626654593/8.0), - REAL_CONST(32866.77102730715/8.0), - REAL_CONST(32884.724879499619/8.0), - REAL_CONST(32902.681182562686/8.0), - REAL_CONST(32920.639935827494/8.0), - REAL_CONST(32938.601138625643/8.0), - REAL_CONST(32956.56479028918/8.0), - REAL_CONST(32974.530890150607/8.0), - REAL_CONST(32992.499437542894/8.0), - REAL_CONST(33010.470431799447/8.0), - REAL_CONST(33028.443872254145/8.0), - REAL_CONST(33046.419758241311/8.0), - REAL_CONST(33064.39808909571/8.0), - REAL_CONST(33082.378864152583/8.0), - REAL_CONST(33100.36208274759/8.0), - REAL_CONST(33118.347744216881/8.0), - REAL_CONST(33136.335847897026/8.0), - REAL_CONST(33154.326393125062/8.0), - REAL_CONST(33172.31937923847/8.0), - REAL_CONST(33190.314805575174/8.0), - REAL_CONST(33208.312671473555/8.0), - REAL_CONST(33226.312976272442/8.0), - REAL_CONST(33244.315719311111/8.0), - REAL_CONST(33262.320899929284/8.0), - REAL_CONST(33280.328517467125/8.0), - REAL_CONST(33298.33857126526/8.0), - REAL_CONST(33316.351060664747/8.0), - REAL_CONST(33334.365985007091/8.0), - REAL_CONST(33352.383343634239/8.0), - REAL_CONST(33370.403135888591/8.0), - REAL_CONST(33388.42536111299/8.0), - REAL_CONST(33406.450018650721/8.0), - REAL_CONST(33424.477107845501/8.0), - REAL_CONST(33442.506628041512/8.0), - REAL_CONST(33460.53857858335/8.0), - REAL_CONST(33478.572958816083/8.0), - REAL_CONST(33496.609768085189/8.0), - REAL_CONST(33514.649005736617/8.0), - REAL_CONST(33532.690671116739/8.0), - REAL_CONST(33550.734763572356/8.0), - REAL_CONST(33568.781282450735/8.0), - REAL_CONST(33586.830227099563/8.0), - REAL_CONST(33604.881596866973/8.0), - REAL_CONST(33622.935391101528/8.0), - REAL_CONST(33640.991609152239/8.0), - REAL_CONST(33659.050250368542/8.0), - REAL_CONST(33677.111314100322/8.0), - REAL_CONST(33695.174799697881/8.0), - REAL_CONST(33713.240706511984/8.0), - REAL_CONST(33731.309033893805/8.0), - REAL_CONST(33749.37978119497/8.0), - REAL_CONST(33767.452947767531/8.0), - REAL_CONST(33785.528532963974/8.0), - REAL_CONST(33803.606536137209/8.0), - REAL_CONST(33821.686956640602/8.0), - REAL_CONST(33839.769793827938/8.0), - REAL_CONST(33857.855047053425/8.0), - REAL_CONST(33875.942715671707/8.0), - REAL_CONST(33894.032799037872/8.0), - REAL_CONST(33912.125296507431/8.0), - REAL_CONST(33930.220207436316/8.0), - REAL_CONST(33948.317531180888/8.0), - REAL_CONST(33966.417267097961/8.0), - REAL_CONST(33984.519414544746/8.0), - REAL_CONST(34002.623972878901/8.0), - REAL_CONST(34020.730941458511/8.0), - REAL_CONST(34038.840319642077/8.0), - REAL_CONST(34056.952106788536/8.0), - REAL_CONST(34075.066302257255/8.0), - REAL_CONST(34093.182905408015/8.0), - REAL_CONST(34111.301915601027/8.0), - REAL_CONST(34129.42333219693/8.0), - REAL_CONST(34147.547154556785/8.0), - REAL_CONST(34165.673382042078/8.0), - REAL_CONST(34183.80201401472/8.0), - REAL_CONST(34201.933049837033/8.0), - REAL_CONST(34220.06648887178/8.0), - REAL_CONST(34238.202330482141/8.0), - REAL_CONST(34256.340574031703/8.0), - REAL_CONST(34274.481218884495/8.0), - REAL_CONST(34292.624264404949/8.0), - REAL_CONST(34310.769709957938/8.0), - REAL_CONST(34328.91755490873/8.0), - REAL_CONST(34347.067798623029/8.0), - REAL_CONST(34365.220440466954/8.0), - REAL_CONST(34383.375479807051/8.0), - REAL_CONST(34401.532916010263/8.0), - REAL_CONST(34419.692748443973/8.0), - REAL_CONST(34437.854976475966/8.0), - REAL_CONST(34456.01959947445/8.0), - REAL_CONST(34474.18661680806/8.0), - REAL_CONST(34492.356027845817/8.0), - REAL_CONST(34510.527831957188/8.0), - REAL_CONST(34528.702028512052/8.0), - REAL_CONST(34546.878616880676/8.0), - REAL_CONST(34565.05759643377/8.0), - REAL_CONST(34583.238966542449/8.0), - REAL_CONST(34601.422726578232/8.0), - REAL_CONST(34619.608875913065/8.0), - REAL_CONST(34637.797413919296/8.0), - REAL_CONST(34655.988339969692/8.0), - REAL_CONST(34674.181653437423/8.0), - REAL_CONST(34692.37735369608/8.0), - REAL_CONST(34710.575440119668/8.0), - REAL_CONST(34728.775912082579/8.0), - REAL_CONST(34746.978768959649/8.0), - REAL_CONST(34765.184010126082/8.0), - REAL_CONST(34783.391634957537/8.0), - REAL_CONST(34801.60164283005/8.0), - REAL_CONST(34819.814033120063/8.0), - REAL_CONST(34838.028805204456/8.0), - REAL_CONST(34856.24595846048/8.0), - REAL_CONST(34874.465492265823/8.0), - REAL_CONST(34892.687405998557/8.0), - REAL_CONST(34910.911699037177/8.0), - REAL_CONST(34929.138370760564/8.0), - REAL_CONST(34947.367420548027/8.0), - REAL_CONST(34965.598847779271/8.0), - REAL_CONST(34983.832651834389/8.0), - REAL_CONST(35002.068832093908/8.0), - REAL_CONST(35020.307387938738/8.0), - REAL_CONST(35038.548318750189/8.0), - REAL_CONST(35056.79162390998/8.0), - REAL_CONST(35075.03730280025/8.0), - REAL_CONST(35093.285354803513/8.0), - REAL_CONST(35111.535779302685/8.0), - REAL_CONST(35129.788575681116/8.0), - REAL_CONST(35148.043743322516/8.0), - REAL_CONST(35166.301281611013/8.0), - REAL_CONST(35184.561189931141/8.0), - REAL_CONST(35202.823467667826/8.0), - REAL_CONST(35221.088114206388/8.0), - REAL_CONST(35239.355128932555/8.0), - REAL_CONST(35257.624511232447/8.0), - REAL_CONST(35275.896260492584/8.0), - REAL_CONST(35294.170376099886/8.0), - REAL_CONST(35312.446857441668/8.0), - REAL_CONST(35330.725703905628/8.0), - REAL_CONST(35349.006914879887/8.0), - REAL_CONST(35367.290489752944/8.0), - REAL_CONST(35385.576427913686/8.0), - REAL_CONST(35403.864728751418/8.0), - REAL_CONST(35422.155391655811/8.0), - REAL_CONST(35440.448416016967/8.0), - REAL_CONST(35458.743801225341/8.0), - REAL_CONST(35477.041546671804/8.0), - REAL_CONST(35495.341651747622/8.0), - REAL_CONST(35513.644115844436/8.0), - REAL_CONST(35531.948938354304/8.0), - REAL_CONST(35550.256118669655/8.0), - REAL_CONST(35568.565656183309/8.0), - REAL_CONST(35586.877550288496/8.0), - REAL_CONST(35605.191800378816/8.0), - REAL_CONST(35623.508405848268/8.0), - REAL_CONST(35641.827366091238/8.0), - REAL_CONST(35660.148680502505/8.0), - REAL_CONST(35678.472348477233/8.0), - REAL_CONST(35696.798369410979/8.0), - REAL_CONST(35715.126742699678/8.0), - REAL_CONST(35733.457467739659/8.0), - REAL_CONST(35751.790543927644/8.0), - REAL_CONST(35770.125970660738/8.0), - REAL_CONST(35788.46374733642/8.0), - REAL_CONST(35806.803873352568/8.0), - REAL_CONST(35825.146348107453/8.0), - REAL_CONST(35843.49117099971/8.0), - REAL_CONST(35861.838341428367/8.0), - REAL_CONST(35880.187858792851/8.0), - REAL_CONST(35898.539722492955/8.0), - REAL_CONST(35916.893931928862/8.0), - REAL_CONST(35935.250486501129/8.0), - REAL_CONST(35953.609385610718/8.0), - REAL_CONST(35971.970628658957/8.0), - REAL_CONST(35990.334215047558/8.0), - REAL_CONST(36008.700144178612/8.0), - REAL_CONST(36027.068415454596/8.0), - REAL_CONST(36045.439028278372/8.0), - REAL_CONST(36063.811982053165/8.0), - REAL_CONST(36082.187276182609/8.0), - REAL_CONST(36100.564910070694/8.0), - REAL_CONST(36118.944883121789/8.0), - REAL_CONST(36137.327194740654/8.0), - REAL_CONST(36155.711844332429/8.0), - REAL_CONST(36174.098831302617/8.0), - REAL_CONST(36192.488155057115/8.0), - REAL_CONST(36210.87981500219/8.0), - REAL_CONST(36229.273810544473/8.0), - REAL_CONST(36247.670141091003/8.0), - REAL_CONST(36266.068806049167/8.0), - REAL_CONST(36284.469804826738/8.0), - REAL_CONST(36302.873136831862/8.0), - REAL_CONST(36321.278801473069/8.0), - REAL_CONST(36339.686798159251/8.0), - REAL_CONST(36358.097126299683/8.0), - REAL_CONST(36376.509785304013/8.0), - REAL_CONST(36394.924774582258/8.0), - REAL_CONST(36413.342093544816/8.0), - REAL_CONST(36431.761741602444/8.0), - REAL_CONST(36450.183718166292/8.0), - REAL_CONST(36468.608022647859/8.0), - REAL_CONST(36487.034654459028/8.0), - REAL_CONST(36505.463613012063/8.0), - REAL_CONST(36523.894897719583/8.0), - REAL_CONST(36542.328507994578/8.0), - REAL_CONST(36560.764443250409/8.0), - REAL_CONST(36579.202702900831/8.0), - REAL_CONST(36597.643286359926/8.0), - REAL_CONST(36616.086193042182/8.0), - REAL_CONST(36634.531422362437/8.0), - REAL_CONST(36652.978973735895/8.0), - REAL_CONST(36671.428846578143/8.0), - REAL_CONST(36689.881040305125/8.0), - REAL_CONST(36708.335554333149/8.0), - REAL_CONST(36726.792388078902/8.0), - REAL_CONST(36745.251540959427/8.0), - REAL_CONST(36763.713012392138/8.0), - REAL_CONST(36782.176801794812/8.0), - REAL_CONST(36800.642908585593/8.0), - REAL_CONST(36819.111332182983/8.0), - REAL_CONST(36837.582072005869/8.0), - REAL_CONST(36856.055127473483/8.0), - REAL_CONST(36874.530498005421/8.0), - REAL_CONST(36893.008183021651/8.0), - REAL_CONST(36911.488181942506/8.0), - REAL_CONST(36929.970494188674/8.0), - REAL_CONST(36948.455119181206/8.0), - REAL_CONST(36966.942056341519/8.0), - REAL_CONST(36985.431305091392/8.0), - REAL_CONST(37003.922864852961/8.0), - REAL_CONST(37022.416735048733/8.0), - REAL_CONST(37040.912915101559/8.0), - REAL_CONST(37059.411404434657/8.0), - REAL_CONST(37077.91220247162/8.0), - REAL_CONST(37096.415308636388/8.0), - REAL_CONST(37114.920722353243/8.0), - REAL_CONST(37133.428443046862/8.0), - REAL_CONST(37151.938470142253/8.0), - REAL_CONST(37170.450803064785/8.0), - REAL_CONST(37188.965441240209/8.0), - REAL_CONST(37207.482384094597/8.0), - REAL_CONST(37226.001631054402/8.0), - REAL_CONST(37244.523181546429/8.0), - REAL_CONST(37263.047034997842/8.0), - REAL_CONST(37281.573190836149/8.0), - REAL_CONST(37300.101648489224/8.0), - REAL_CONST(37318.632407385296/8.0), - REAL_CONST(37337.165466952945/8.0), - REAL_CONST(37355.700826621112/8.0), - REAL_CONST(37374.238485819085/8.0), - REAL_CONST(37392.778443976509/8.0), - REAL_CONST(37411.320700523385/8.0), - REAL_CONST(37429.865254890057/8.0), - REAL_CONST(37448.412106507232/8.0), - REAL_CONST(37466.961254805974/8.0), - REAL_CONST(37485.512699217681/8.0), - REAL_CONST(37504.066439174116/8.0), - REAL_CONST(37522.622474107404/8.0), - REAL_CONST(37541.180803449992/8.0), - REAL_CONST(37559.741426634704/8.0), - REAL_CONST(37578.304343094693/8.0), - REAL_CONST(37596.869552263488/8.0), - REAL_CONST(37615.43705357494/8.0), - REAL_CONST(37634.006846463279/8.0), - REAL_CONST(37652.578930363044/8.0), - REAL_CONST(37671.153304709165/8.0), - REAL_CONST(37689.729968936896/8.0), - REAL_CONST(37708.308922481847/8.0), - REAL_CONST(37726.890164779965/8.0), - REAL_CONST(37745.473695267559/8.0), - REAL_CONST(37764.059513381275/8.0), - REAL_CONST(37782.647618558112/8.0), - REAL_CONST(37801.238010235415/8.0), - REAL_CONST(37819.830687850859/8.0), - REAL_CONST(37838.425650842495/8.0), - REAL_CONST(37857.022898648691/8.0), - REAL_CONST(37875.622430708172/8.0), - REAL_CONST(37894.224246460013/8.0), - REAL_CONST(37912.828345343616/8.0), - REAL_CONST(37931.434726798747/8.0), - REAL_CONST(37950.043390265506/8.0), - REAL_CONST(37968.654335184328/8.0), - REAL_CONST(37987.267560995999/8.0), - REAL_CONST(38005.883067141665/8.0), - REAL_CONST(38024.500853062775/8.0), - REAL_CONST(38043.120918201159/8.0), - REAL_CONST(38061.743261998963/8.0), - REAL_CONST(38080.367883898682/8.0), - REAL_CONST(38098.994783343158/8.0), - REAL_CONST(38117.623959775563/8.0), - REAL_CONST(38136.255412639417/8.0), - REAL_CONST(38154.889141378575/8.0), - REAL_CONST(38173.525145437234/8.0), - REAL_CONST(38192.163424259939/8.0), - REAL_CONST(38210.803977291551/8.0), - REAL_CONST(38229.446803977284/8.0), - REAL_CONST(38248.091903762703/8.0), - REAL_CONST(38266.739276093685/8.0), - REAL_CONST(38285.388920416466/8.0), - REAL_CONST(38304.040836177606/8.0), - REAL_CONST(38322.695022824002/8.0), - REAL_CONST(38341.351479802899/8.0), - REAL_CONST(38360.010206561863/8.0), - REAL_CONST(38378.671202548816/8.0), - REAL_CONST(38397.334467211993/8.0), - REAL_CONST(38415.999999999978/8.0), - REAL_CONST(38434.667800361683/8.0), - REAL_CONST(38453.33786774637/8.0), - REAL_CONST(38472.010201603611/8.0), - REAL_CONST(38490.684801383337/8.0), - REAL_CONST(38509.361666535784/8.0), - REAL_CONST(38528.040796511552/8.0), - REAL_CONST(38546.722190761553/8.0), - REAL_CONST(38565.405848737035/8.0), - REAL_CONST(38584.091769889594/8.0), - REAL_CONST(38602.779953671132/8.0), - REAL_CONST(38621.470399533908/8.0), - REAL_CONST(38640.163106930493/8.0), - REAL_CONST(38658.858075313794/8.0), - REAL_CONST(38677.555304137059/8.0), - REAL_CONST(38696.254792853862/8.0), - REAL_CONST(38714.956540918094/8.0), - REAL_CONST(38733.660547783991/8.0), - REAL_CONST(38752.366812906112/8.0), - REAL_CONST(38771.075335739348/8.0), - REAL_CONST(38789.78611573892/8.0), - REAL_CONST(38808.499152360368/8.0), - REAL_CONST(38827.214445059573/8.0), - REAL_CONST(38845.931993292739/8.0), - REAL_CONST(38864.651796516388/8.0), - REAL_CONST(38883.373854187383/8.0), - REAL_CONST(38902.098165762916/8.0), - REAL_CONST(38920.824730700486/8.0), - REAL_CONST(38939.553548457938/8.0), - REAL_CONST(38958.284618493431/8.0), - REAL_CONST(38977.017940265461/8.0), - REAL_CONST(38995.753513232834/8.0), - REAL_CONST(39014.491336854699/8.0), - REAL_CONST(39033.231410590517/8.0), - REAL_CONST(39051.973733900079/8.0), - REAL_CONST(39070.718306243485/8.0), - REAL_CONST(39089.465127081188/8.0), - REAL_CONST(39108.214195873945/8.0), - REAL_CONST(39126.965512082832/8.0), - REAL_CONST(39145.719075169261/8.0), - REAL_CONST(39164.474884594965/8.0), - REAL_CONST(39183.232939821988/8.0), - REAL_CONST(39201.99324031271/8.0), - REAL_CONST(39220.755785529815/8.0), - REAL_CONST(39239.52057493633/8.0), - REAL_CONST(39258.287607995589/8.0), - REAL_CONST(39277.056884171245/8.0), - REAL_CONST(39295.828402927284/8.0), - REAL_CONST(39314.602163728006/8.0), - REAL_CONST(39333.378166038019/8.0), - REAL_CONST(39352.15640932227/8.0), - REAL_CONST(39370.936893046004/8.0), - REAL_CONST(39389.719616674811/8.0), - REAL_CONST(39408.504579674584/8.0), - REAL_CONST(39427.291781511522/8.0), - REAL_CONST(39446.081221652174/8.0), - REAL_CONST(39464.872899563372/8.0), - REAL_CONST(39483.666814712291/8.0), - REAL_CONST(39502.462966566411/8.0), - REAL_CONST(39521.261354593538/8.0), - REAL_CONST(39540.06197826178/8.0), - REAL_CONST(39558.864837039568/8.0), - REAL_CONST(39577.669930395656/8.0), - REAL_CONST(39596.47725779911/8.0), - REAL_CONST(39615.286818719302/8.0), - REAL_CONST(39634.098612625923/8.0), - REAL_CONST(39652.912638988993/8.0), - REAL_CONST(39671.728897278823/8.0), - REAL_CONST(39690.547386966064/8.0), - REAL_CONST(39709.368107521652/8.0), - REAL_CONST(39728.191058416858/8.0), - REAL_CONST(39747.016239123259/8.0), - REAL_CONST(39765.84364911275/8.0), - REAL_CONST(39784.673287857528/8.0), - REAL_CONST(39803.505154830105/8.0), - REAL_CONST(39822.339249503319/8.0), - REAL_CONST(39841.175571350293/8.0), - REAL_CONST(39860.014119844491/8.0), - REAL_CONST(39878.854894459677/8.0), - REAL_CONST(39897.697894669909/8.0), - REAL_CONST(39916.54311994958/8.0), - REAL_CONST(39935.390569773372/8.0), - REAL_CONST(39954.240243616303/8.0), - REAL_CONST(39973.092140953675/8.0), - REAL_CONST(39991.946261261117/8.0), - REAL_CONST(40010.802604014549/8.0), - REAL_CONST(40029.661168690225/8.0), - REAL_CONST(40048.521954764678/8.0), - REAL_CONST(40067.384961714779/8.0), - REAL_CONST(40086.250189017679/8.0), - REAL_CONST(40105.117636150855/8.0), - REAL_CONST(40123.98730259209/8.0), - REAL_CONST(40142.859187819471/8.0), - REAL_CONST(40161.733291311379/8.0), - REAL_CONST(40180.609612546526/8.0), - REAL_CONST(40199.488151003912/8.0), - REAL_CONST(40218.368906162854/8.0), - REAL_CONST(40237.25187750296/8.0), - REAL_CONST(40256.137064504153/8.0), - REAL_CONST(40275.024466646668/8.0), - REAL_CONST(40293.914083411029/8.0), - REAL_CONST(40312.805914278084/8.0), - REAL_CONST(40331.699958728961/8.0), - REAL_CONST(40350.596216245103/8.0), - REAL_CONST(40369.494686308273/8.0), - REAL_CONST(40388.39536840051/8.0), - REAL_CONST(40407.298262004173/8.0), - REAL_CONST(40426.20336660192/8.0), - REAL_CONST(40445.110681676706/8.0), - REAL_CONST(40464.020206711793/8.0), - REAL_CONST(40482.931941190756/8.0), - REAL_CONST(40501.845884597446/8.0), - REAL_CONST(40520.762036416032/8.0), - REAL_CONST(40539.680396130985/8.0), - REAL_CONST(40558.600963227072/8.0), - REAL_CONST(40577.523737189367/8.0), - REAL_CONST(40596.448717503234/8.0), - REAL_CONST(40615.375903654342/8.0), - REAL_CONST(40634.305295128659/8.0), - REAL_CONST(40653.236891412453/8.0), - REAL_CONST(40672.170691992294/8.0), - REAL_CONST(40691.106696355047/8.0), - REAL_CONST(40710.044903987873/8.0), - REAL_CONST(40728.985314378238/8.0), - REAL_CONST(40747.927927013901/8.0), - REAL_CONST(40766.872741382918/8.0), - REAL_CONST(40785.819756973651/8.0), - REAL_CONST(40804.768973274746/8.0), - REAL_CONST(40823.720389775161/8.0), - REAL_CONST(40842.674005964131/8.0), - REAL_CONST(40861.629821331211/8.0), - REAL_CONST(40880.587835366234/8.0), - REAL_CONST(40899.548047559321/8.0), - REAL_CONST(40918.510457400931/8.0), - REAL_CONST(40937.475064381761/8.0), - REAL_CONST(40956.441867992849/8.0), - REAL_CONST(40975.410867725499/8.0), - REAL_CONST(40994.382063071331/8.0), - REAL_CONST(41013.355453522236/8.0), - REAL_CONST(41032.331038570417/8.0), - REAL_CONST(41051.308817708363/8.0), - REAL_CONST(41070.288790428858/8.0), - REAL_CONST(41089.270956224987/8.0), - REAL_CONST(41108.255314590111/8.0), - REAL_CONST(41127.241865017888/8.0), - REAL_CONST(41146.23060700229/8.0), - REAL_CONST(41165.221540037543/8.0), - REAL_CONST(41184.214663618193/8.0), - REAL_CONST(41203.209977239079/8.0), - REAL_CONST(41222.207480395307/8.0), - REAL_CONST(41241.207172582297/8.0), - REAL_CONST(41260.209053295752/8.0), - REAL_CONST(41279.213122031659/8.0), - REAL_CONST(41298.219378286303/8.0), - REAL_CONST(41317.227821556255/8.0), - REAL_CONST(41336.23845133838/8.0), - REAL_CONST(41355.251267129832/8.0), - REAL_CONST(41374.266268428037/8.0), - REAL_CONST(41393.283454730743/8.0), - REAL_CONST(41412.302825535953/8.0), - REAL_CONST(41431.324380341983/8.0), - REAL_CONST(41450.348118647416/8.0), - REAL_CONST(41469.374039951144/8.0), - REAL_CONST(41488.402143752326/8.0), - REAL_CONST(41507.432429550427/8.0), - REAL_CONST(41526.464896845187/8.0), - REAL_CONST(41545.499545136627/8.0), - REAL_CONST(41564.536373925075/8.0), - REAL_CONST(41583.575382711126/8.0), - REAL_CONST(41602.616570995662/8.0), - REAL_CONST(41621.659938279874/8.0), - REAL_CONST(41640.705484065205/8.0), - REAL_CONST(41659.753207853406/8.0), - REAL_CONST(41678.803109146495/8.0), - REAL_CONST(41697.855187446803/8.0), - REAL_CONST(41716.909442256911/8.0), - REAL_CONST(41735.965873079709/8.0), - REAL_CONST(41755.02447941836/8.0), - REAL_CONST(41774.085260776315/8.0), - REAL_CONST(41793.148216657297/8.0), - REAL_CONST(41812.213346565331/8.0), - REAL_CONST(41831.280650004708/8.0), - REAL_CONST(41850.350126480014/8.0), - REAL_CONST(41869.421775496106/8.0), - REAL_CONST(41888.495596558132/8.0), - REAL_CONST(41907.571589171515/8.0), - REAL_CONST(41926.649752841957/8.0), - REAL_CONST(41945.730087075463/8.0), - REAL_CONST(41964.812591378286/8.0), - REAL_CONST(41983.897265256979/8.0), - REAL_CONST(42002.984108218378/8.0), - REAL_CONST(42022.073119769593/8.0), - REAL_CONST(42041.164299418015/8.0), - REAL_CONST(42060.257646671307/8.0), - REAL_CONST(42079.353161037419/8.0), - REAL_CONST(42098.450842024591/8.0), - REAL_CONST(42117.550689141324/8.0), - REAL_CONST(42136.652701896404/8.0), - REAL_CONST(42155.756879798893/8.0), - REAL_CONST(42174.863222358137/8.0), - REAL_CONST(42193.971729083758/8.0), - REAL_CONST(42213.082399485655/8.0), - REAL_CONST(42232.195233074002/8.0), - REAL_CONST(42251.310229359246/8.0), - REAL_CONST(42270.427387852127/8.0), - REAL_CONST(42289.546708063644/8.0), - REAL_CONST(42308.668189505079/8.0), - REAL_CONST(42327.791831687995/8.0), - REAL_CONST(42346.917634124227/8.0), - REAL_CONST(42366.045596325886/8.0), - REAL_CONST(42385.175717805352/8.0), - REAL_CONST(42404.307998075295/8.0), - REAL_CONST(42423.442436648642/8.0), - REAL_CONST(42442.579033038608/8.0), - REAL_CONST(42461.717786758672/8.0), - REAL_CONST(42480.858697322597/8.0), - REAL_CONST(42500.001764244422/8.0), - REAL_CONST(42519.146987038446/8.0), - REAL_CONST(42538.294365219248/8.0), - REAL_CONST(42557.443898301688/8.0), - REAL_CONST(42576.595585800882/8.0), - REAL_CONST(42595.749427232236/8.0), - REAL_CONST(42614.90542211142/8.0), - REAL_CONST(42634.063569954378/8.0), - REAL_CONST(42653.223870277317/8.0), - REAL_CONST(42672.386322596729/8.0), - REAL_CONST(42691.55092642938/8.0), - REAL_CONST(42710.717681292292/8.0), - REAL_CONST(42729.886586702756/8.0), - REAL_CONST(42749.057642178363/8.0), - REAL_CONST(42768.23084723694/8.0), - REAL_CONST(42787.406201396603/8.0), - REAL_CONST(42806.58370417574/8.0), - REAL_CONST(42825.76335509299/8.0), - REAL_CONST(42844.945153667286/8.0), - REAL_CONST(42864.129099417805/8.0), - REAL_CONST(42883.315191864014/8.0), - REAL_CONST(42902.503430525649/8.0), - REAL_CONST(42921.693814922692/8.0), - REAL_CONST(42940.88634457541/8.0), - REAL_CONST(42960.081019004348/8.0), - REAL_CONST(42979.277837730297/8.0), - REAL_CONST(42998.476800274322/8.0), - REAL_CONST(43017.677906157769/8.0), - REAL_CONST(43036.881154902228/8.0), - REAL_CONST(43056.086546029583/8.0), - REAL_CONST(43075.294079061961/8.0), - REAL_CONST(43094.503753521763/8.0), - REAL_CONST(43113.715568931671/8.0), - REAL_CONST(43132.929524814601/8.0), - REAL_CONST(43152.145620693766/8.0), - REAL_CONST(43171.363856092619/8.0), - REAL_CONST(43190.584230534907/8.0), - REAL_CONST(43209.806743544621/8.0), - REAL_CONST(43229.031394646016/8.0), - REAL_CONST(43248.258183363621/8.0), - REAL_CONST(43267.487109222224/8.0), - REAL_CONST(43286.718171746885/8.0), - REAL_CONST(43305.951370462906/8.0), - REAL_CONST(43325.186704895881/8.0), - REAL_CONST(43344.42417457165/8.0), - REAL_CONST(43363.663779016322/8.0), - REAL_CONST(43382.905517756262/8.0), - REAL_CONST(43402.149390318104/8.0), - REAL_CONST(43421.395396228749/8.0), - REAL_CONST(43440.643535015348/8.0), - REAL_CONST(43459.89380620532/8.0), - REAL_CONST(43479.146209326354/8.0), - REAL_CONST(43498.400743906379/8.0), - REAL_CONST(43517.657409473606/8.0), - REAL_CONST(43536.916205556496/8.0), - REAL_CONST(43556.177131683784/8.0), - REAL_CONST(43575.44018738444/8.0), - REAL_CONST(43594.705372187724/8.0), - REAL_CONST(43613.972685623135/8.0), - REAL_CONST(43633.242127220445/8.0), - REAL_CONST(43652.513696509668/8.0), - REAL_CONST(43671.787393021099/8.0), - REAL_CONST(43691.063216285271/8.0), - REAL_CONST(43710.341165833001/8.0), - REAL_CONST(43729.621241195346/8.0), - REAL_CONST(43748.903441903625/8.0), - REAL_CONST(43768.187767489413/8.0), - REAL_CONST(43787.474217484552/8.0), - REAL_CONST(43806.762791421126/8.0), - REAL_CONST(43826.053488831501/8.0), - REAL_CONST(43845.346309248278/8.0), - REAL_CONST(43864.641252204325/8.0), - REAL_CONST(43883.938317232765/8.0), - REAL_CONST(43903.237503866971/8.0), - REAL_CONST(43922.538811640596/8.0), - REAL_CONST(43941.842240087513/8.0), - REAL_CONST(43961.147788741881/8.0), - REAL_CONST(43980.455457138101/8.0), - REAL_CONST(43999.765244810835/8.0), - REAL_CONST(44019.077151295001/8.0), - REAL_CONST(44038.391176125755/8.0), - REAL_CONST(44057.70731883854/8.0), - REAL_CONST(44077.02557896902/8.0), - REAL_CONST(44096.345956053141/8.0), - REAL_CONST(44115.668449627083/8.0), - REAL_CONST(44134.993059227287/8.0), - REAL_CONST(44154.319784390456/8.0), - REAL_CONST(44173.648624653535/8.0), - REAL_CONST(44192.979579553728/8.0), - REAL_CONST(44212.312648628489/8.0), - REAL_CONST(44231.647831415532/8.0), - REAL_CONST(44250.985127452805/8.0), - REAL_CONST(44270.324536278538/8.0), - REAL_CONST(44289.666057431183/8.0), - REAL_CONST(44309.009690449464/8.0), - REAL_CONST(44328.355434872348/8.0), - REAL_CONST(44347.703290239064/8.0), - REAL_CONST(44367.053256089079/8.0), - REAL_CONST(44386.405331962109/8.0), - REAL_CONST(44405.759517398139/8.0), - REAL_CONST(44425.115811937387/8.0), - REAL_CONST(44444.474215120332/8.0), - REAL_CONST(44463.834726487694/8.0), - REAL_CONST(44483.197345580462/8.0), - REAL_CONST(44502.562071939843/8.0), - REAL_CONST(44521.928905107328/8.0), - REAL_CONST(44541.297844624634/8.0), - REAL_CONST(44560.668890033732/8.0), - REAL_CONST(44580.042040876848/8.0), - REAL_CONST(44599.417296696454/8.0), - REAL_CONST(44618.794657035272/8.0), - REAL_CONST(44638.174121436256/8.0), - REAL_CONST(44657.555689442641/8.0), - REAL_CONST(44676.939360597877/8.0), - REAL_CONST(44696.325134445673/8.0), - REAL_CONST(44715.713010530002/8.0), - REAL_CONST(44735.102988395054/8.0), - REAL_CONST(44754.495067585296/8.0), - REAL_CONST(44773.88924764542/8.0), - REAL_CONST(44793.285528120374/8.0), - REAL_CONST(44812.683908555344/8.0), - REAL_CONST(44832.084388495779/8.0), - REAL_CONST(44851.486967487363/8.0), - REAL_CONST(44870.891645076015/8.0), - REAL_CONST(44890.298420807922/8.0), - REAL_CONST(44909.707294229491/8.0), - REAL_CONST(44929.118264887409/8.0), - REAL_CONST(44948.531332328566/8.0), - REAL_CONST(44967.946496100136/8.0), - REAL_CONST(44987.363755749502/8.0), - REAL_CONST(45006.783110824319/8.0), - REAL_CONST(45026.204560872473/8.0), - REAL_CONST(45045.628105442098/8.0), - REAL_CONST(45065.053744081561/8.0), - REAL_CONST(45084.48147633949/8.0), - REAL_CONST(45103.911301764747/8.0), - REAL_CONST(45123.343219906426/8.0), - REAL_CONST(45142.777230313885/8.0), - REAL_CONST(45162.21333253671/8.0), - REAL_CONST(45181.651526124733/8.0), - REAL_CONST(45201.091810628037/8.0), - REAL_CONST(45220.534185596924/8.0), - REAL_CONST(45239.978650581965/8.0), - REAL_CONST(45259.425205133957/8.0), - REAL_CONST(45278.873848803938/8.0), - REAL_CONST(45298.324581143192/8.0), - REAL_CONST(45317.777401703235/8.0), - REAL_CONST(45337.232310035848/8.0), - REAL_CONST(45356.68930569302/8.0), - REAL_CONST(45376.148388226997/8.0), - REAL_CONST(45395.60955719027/8.0), - REAL_CONST(45415.072812135557/8.0), - REAL_CONST(45434.538152615823/8.0), - REAL_CONST(45454.005578184282/8.0), - REAL_CONST(45473.475088394356/8.0), - REAL_CONST(45492.946682799746/8.0), - REAL_CONST(45512.420360954362/8.0), - REAL_CONST(45531.896122412363/8.0), - REAL_CONST(45551.373966728155/8.0), - REAL_CONST(45570.853893456362/8.0), - REAL_CONST(45590.33590215187/8.0), - REAL_CONST(45609.819992369776/8.0), - REAL_CONST(45629.306163665438/8.0), - REAL_CONST(45648.794415594442/8.0), - REAL_CONST(45668.284747712612/8.0), - REAL_CONST(45687.777159576006/8.0), - REAL_CONST(45707.27165074092/8.0), - REAL_CONST(45726.768220763894/8.0), - REAL_CONST(45746.266869201696/8.0), - REAL_CONST(45765.767595611323/8.0), - REAL_CONST(45785.270399550034/8.0), - REAL_CONST(45804.775280575297/8.0), - REAL_CONST(45824.282238244828/8.0), - REAL_CONST(45843.79127211657/8.0), - REAL_CONST(45863.302381748719/8.0), - REAL_CONST(45882.815566699683/8.0), - REAL_CONST(45902.33082652813/8.0), - REAL_CONST(45921.848160792935/8.0), - REAL_CONST(45941.367569053225/8.0), - REAL_CONST(45960.889050868354/8.0), - REAL_CONST(45980.41260579793/8.0), - REAL_CONST(45999.938233401757/8.0), - REAL_CONST(46019.465933239902/8.0), - REAL_CONST(46038.995704872657/8.0), - REAL_CONST(46058.527547860547/8.0), - REAL_CONST(46078.06146176433/8.0), - REAL_CONST(46097.597446144995/8.0), - REAL_CONST(46117.135500563774/8.0), - REAL_CONST(46136.675624582109/8.0), - REAL_CONST(46156.217817761702/8.0), - REAL_CONST(46175.762079664462/8.0), - REAL_CONST(46195.308409852543/8.0), - REAL_CONST(46214.856807888333/8.0), - REAL_CONST(46234.407273334444/8.0), - REAL_CONST(46253.959805753715/8.0), - REAL_CONST(46273.51440470924/8.0), - REAL_CONST(46293.071069764315/8.0), - REAL_CONST(46312.629800482478/8.0), - REAL_CONST(46332.190596427499/8.0), - REAL_CONST(46351.753457163381/8.0), - REAL_CONST(46371.318382254351/8.0), - REAL_CONST(46390.885371264863/8.0), - REAL_CONST(46410.45442375962/8.0), - REAL_CONST(46430.025539303526/8.0), - REAL_CONST(46449.598717461733/8.0), - REAL_CONST(46469.17395779962/8.0), - REAL_CONST(46488.751259882782/8.0), - REAL_CONST(46508.33062327707/8.0), - REAL_CONST(46527.912047548532/8.0), - REAL_CONST(46547.495532263471/8.0), - REAL_CONST(46567.081076988397/8.0), - REAL_CONST(46586.668681290059/8.0), - REAL_CONST(46606.258344735434/8.0), - REAL_CONST(46625.850066891719/8.0), - REAL_CONST(46645.443847326351/8.0), - REAL_CONST(46665.039685606986/8.0), - REAL_CONST(46684.637581301497/8.0), - REAL_CONST(46704.237533978005/8.0), - REAL_CONST(46723.839543204842/8.0), - REAL_CONST(46743.443608550573/8.0), - REAL_CONST(46763.049729583989/8.0), - REAL_CONST(46782.657905874104/8.0), - REAL_CONST(46802.268136990162/8.0), - REAL_CONST(46821.880422501628/8.0), - REAL_CONST(46841.494761978196/8.0), - REAL_CONST(46861.111154989776/8.0), - REAL_CONST(46880.729601106526/8.0), - REAL_CONST(46900.350099898795/8.0), - REAL_CONST(46919.97265093719/8.0), - REAL_CONST(46939.597253792526/8.0), - REAL_CONST(46959.223908035841/8.0), - REAL_CONST(46978.852613238392/8.0), - REAL_CONST(46998.483368971691/8.0), - REAL_CONST(47018.11617480743/8.0), - REAL_CONST(47037.751030317551/8.0), - REAL_CONST(47057.387935074221/8.0), - REAL_CONST(47077.026888649809/8.0), - REAL_CONST(47096.66789061694/8.0), - REAL_CONST(47116.310940548428/8.0), - REAL_CONST(47135.956038017328/8.0), - REAL_CONST(47155.603182596918/8.0), - REAL_CONST(47175.252373860698/8.0), - REAL_CONST(47194.903611382375/8.0), - REAL_CONST(47214.556894735892/8.0), - REAL_CONST(47234.212223495422/8.0), - REAL_CONST(47253.869597235338/8.0), - REAL_CONST(47273.52901553025/8.0), - REAL_CONST(47293.19047795498/8.0), - REAL_CONST(47312.853984084577/8.0), - REAL_CONST(47332.519533494306/8.0), - REAL_CONST(47352.187125759658/8.0), - REAL_CONST(47371.856760456343/8.0), - REAL_CONST(47391.528437160297/8.0), - REAL_CONST(47411.202155447652/8.0), - REAL_CONST(47430.877914894787/8.0), - REAL_CONST(47450.555715078299/8.0), - REAL_CONST(47470.235555574982/8.0), - REAL_CONST(47489.917435961863/8.0), - REAL_CONST(47509.601355816201/8.0), - REAL_CONST(47529.287314715453/8.0), - REAL_CONST(47548.975312237308/8.0), - REAL_CONST(47568.665347959672/8.0), - REAL_CONST(47588.357421460656/8.0), - REAL_CONST(47608.051532318605/8.0), - REAL_CONST(47627.747680112072/8.0), - REAL_CONST(47647.445864419846/8.0), - REAL_CONST(47667.14608482091/8.0), - REAL_CONST(47686.848340894474/8.0), - REAL_CONST(47706.552632219973/8.0), - REAL_CONST(47726.258958377046/8.0), - REAL_CONST(47745.967318945557/8.0), - REAL_CONST(47765.677713505589/8.0), - REAL_CONST(47785.390141637428/8.0), - REAL_CONST(47805.104602921601/8.0), - REAL_CONST(47824.821096938824/8.0), - REAL_CONST(47844.539623270044/8.0), - REAL_CONST(47864.260181496429/8.0), - REAL_CONST(47883.982771199349/8.0), - REAL_CONST(47903.707391960394/8.0), - REAL_CONST(47923.434043361369/8.0), - REAL_CONST(47943.162724984308/8.0), - REAL_CONST(47962.893436411439/8.0), - REAL_CONST(47982.626177225218/8.0), - REAL_CONST(48002.36094700831/8.0), - REAL_CONST(48022.097745343599/8.0), - REAL_CONST(48041.836571814172/8.0), - REAL_CONST(48061.57742600335/8.0), - REAL_CONST(48081.32030749465/8.0), - REAL_CONST(48101.065215871815/8.0), - REAL_CONST(48120.81215071879/8.0), - REAL_CONST(48140.56111161974/8.0), - REAL_CONST(48160.312098159047/8.0), - REAL_CONST(48180.065109921306/8.0), - REAL_CONST(48199.820146491307/8.0), - REAL_CONST(48219.577207454073/8.0), - REAL_CONST(48239.336292394844/8.0), - REAL_CONST(48259.097400899045/8.0), - REAL_CONST(48278.860532552339/8.0), - REAL_CONST(48298.625686940592/8.0), - REAL_CONST(48318.392863649875/8.0), - REAL_CONST(48338.162062266485/8.0), - REAL_CONST(48357.933282376915/8.0), - REAL_CONST(48377.706523567889/8.0), - REAL_CONST(48397.481785426316/8.0), - REAL_CONST(48417.259067539344/8.0), - REAL_CONST(48437.038369494308/8.0), - REAL_CONST(48456.819690878765/8.0), - REAL_CONST(48476.603031280487/8.0), - REAL_CONST(48496.388390287451/8.0), - REAL_CONST(48516.175767487839/8.0), - REAL_CONST(48535.965162470042/8.0), - REAL_CONST(48555.756574822684/8.0), - REAL_CONST(48575.550004134566/8.0), - REAL_CONST(48595.345449994718/8.0), - REAL_CONST(48615.142911992378/8.0), - REAL_CONST(48634.942389716991/8.0), - REAL_CONST(48654.743882758201/8.0), - REAL_CONST(48674.547390705877/8.0), - REAL_CONST(48694.352913150084/8.0), - REAL_CONST(48714.160449681112/8.0), - REAL_CONST(48733.969999889443/8.0), - REAL_CONST(48753.781563365759/8.0), - REAL_CONST(48773.595139700978/8.0), - REAL_CONST(48793.410728486211/8.0), - REAL_CONST(48813.228329312769/8.0), - REAL_CONST(48833.047941772187/8.0), - REAL_CONST(48852.869565456189/8.0), - REAL_CONST(48872.693199956717/8.0), - REAL_CONST(48892.518844865925/8.0), - REAL_CONST(48912.346499776155/8.0), - REAL_CONST(48932.176164279976/8.0), - REAL_CONST(48952.007837970152/8.0), - REAL_CONST(48971.841520439666/8.0), - REAL_CONST(48991.677211281676/8.0), - REAL_CONST(49011.514910089587/8.0), - REAL_CONST(49031.354616456978/8.0), - REAL_CONST(49051.196329977654/8.0), - REAL_CONST(49071.04005024561/8.0), - REAL_CONST(49090.885776855059/8.0), - REAL_CONST(49110.733509400408/8.0), - REAL_CONST(49130.583247476279/8.0), - REAL_CONST(49150.434990677488/8.0), - REAL_CONST(49170.288738599062/8.0), - REAL_CONST(49190.144490836232/8.0), - REAL_CONST(49210.002246984441/8.0), - REAL_CONST(49229.86200663932/8.0), - REAL_CONST(49249.723769396718/8.0), - REAL_CONST(49269.587534852675/8.0), - REAL_CONST(49289.453302603448/8.0), - REAL_CONST(49309.32107224549/8.0), - REAL_CONST(49329.190843375451/8.0), - REAL_CONST(49349.062615590192/8.0), - REAL_CONST(49368.936388486785/8.0), - REAL_CONST(49388.812161662492/8.0), - REAL_CONST(49408.689934714785/8.0), - REAL_CONST(49428.569707241324/8.0), - REAL_CONST(49448.45147883999/8.0), - REAL_CONST(49468.335249108866/8.0), - REAL_CONST(49488.22101764621/8.0), - REAL_CONST(49508.108784050521/8.0), - REAL_CONST(49527.99854792047/8.0), - REAL_CONST(49547.890308854934/8.0), - REAL_CONST(49567.784066453009/8.0), - REAL_CONST(49587.679820313977/8.0), - REAL_CONST(49607.57757003732/8.0), - REAL_CONST(49627.477315222721/8.0), - REAL_CONST(49647.379055470075/8.0), - REAL_CONST(49667.28279037946/8.0), - REAL_CONST(49687.188519551179/8.0), - REAL_CONST(49707.096242585707/8.0), - REAL_CONST(49727.005959083741/8.0), - REAL_CONST(49746.917668646165/8.0), - REAL_CONST(49766.831370874068/8.0), - REAL_CONST(49786.747065368734/8.0), - REAL_CONST(49806.66475173166/8.0), - REAL_CONST(49826.584429564515/8.0), - REAL_CONST(49846.506098469203/8.0), - REAL_CONST(49866.429758047794/8.0), - REAL_CONST(49886.355407902578/8.0), - REAL_CONST(49906.283047636032/8.0), - REAL_CONST(49926.212676850846/8.0), - REAL_CONST(49946.144295149883/8.0), - REAL_CONST(49966.077902136225/8.0), - REAL_CONST(49986.013497413151/8.0), - REAL_CONST(50005.951080584135/8.0), - REAL_CONST(50025.890651252834/8.0), - REAL_CONST(50045.832209023123/8.0), - REAL_CONST(50065.775753499074/8.0), - REAL_CONST(50085.721284284933/8.0), - REAL_CONST(50105.668800985164/8.0), - REAL_CONST(50125.618303204428/8.0), - REAL_CONST(50145.569790547575/8.0), - REAL_CONST(50165.523262619652/8.0), - REAL_CONST(50185.478719025901/8.0), - REAL_CONST(50205.436159371769/8.0), - REAL_CONST(50225.395583262893/8.0), - REAL_CONST(50245.356990305103/8.0), - REAL_CONST(50265.320380104429/8.0), - REAL_CONST(50285.285752267104/8.0), - REAL_CONST(50305.253106399534/8.0), - REAL_CONST(50325.222442108337/8.0), - REAL_CONST(50345.193759000336/8.0), - REAL_CONST(50365.16705668252/8.0), - REAL_CONST(50385.142334762102/8.0), - REAL_CONST(50405.119592846473/8.0), - REAL_CONST(50425.098830543218/8.0), - REAL_CONST(50445.080047460127/8.0), - REAL_CONST(50465.063243205179/8.0), - REAL_CONST(50485.048417386541/8.0), - REAL_CONST(50505.035569612577/8.0), - REAL_CONST(50525.024699491856/8.0), - REAL_CONST(50545.015806633128/8.0), - REAL_CONST(50565.008890645338/8.0), - REAL_CONST(50585.003951137631/8.0), - REAL_CONST(50605.00098771933/8.0), - REAL_CONST(50624.999999999971/8.0), - REAL_CONST(50645.000987589265/8.0), - REAL_CONST(50665.003950097132/8.0), - REAL_CONST(50685.008887133677/8.0), - REAL_CONST(50705.015798309192/8.0), - REAL_CONST(50725.024683234165/8.0), - REAL_CONST(50745.035541519283/8.0), - REAL_CONST(50765.048372775411/8.0), - REAL_CONST(50785.063176613621/8.0), - REAL_CONST(50805.079952645159/8.0), - REAL_CONST(50825.098700481489/8.0), - REAL_CONST(50845.119419734241/8.0), - REAL_CONST(50865.142110015244/8.0), - REAL_CONST(50885.166770936521/8.0), - REAL_CONST(50905.193402110279/8.0), - REAL_CONST(50925.222003148934/8.0), - REAL_CONST(50945.252573665071/8.0), - REAL_CONST(50965.285113271471/8.0), - REAL_CONST(50985.319621581119/8.0), - REAL_CONST(51005.356098207172/8.0), - REAL_CONST(51025.394542762981/8.0), - REAL_CONST(51045.434954862096/8.0), - REAL_CONST(51065.477334118244/8.0), - REAL_CONST(51085.521680145357/8.0), - REAL_CONST(51105.567992557546/8.0), - REAL_CONST(51125.616270969113/8.0), - REAL_CONST(51145.66651499454/8.0), - REAL_CONST(51165.718724248516/8.0), - REAL_CONST(51185.772898345916/8.0), - REAL_CONST(51205.829036901778/8.0), - REAL_CONST(51225.887139531362/8.0), - REAL_CONST(51245.947205850105/8.0), - REAL_CONST(51266.009235473619/8.0), - REAL_CONST(51286.073228017718/8.0), - REAL_CONST(51306.139183098399/8.0), - REAL_CONST(51326.207100331856/8.0), - REAL_CONST(51346.276979334456/8.0), - REAL_CONST(51366.348819722756/8.0), - REAL_CONST(51386.42262111351/8.0), - REAL_CONST(51406.498383123653/8.0), - REAL_CONST(51426.57610537031/8.0), - REAL_CONST(51446.655787470787/8.0), - REAL_CONST(51466.737429042587/8.0), - REAL_CONST(51486.82102970338/8.0), - REAL_CONST(51506.906589071048/8.0), - REAL_CONST(51526.994106763632/8.0), - REAL_CONST(51547.083582399391/8.0), - REAL_CONST(51567.175015596738/8.0), - REAL_CONST(51587.268405974297/8.0), - REAL_CONST(51607.363753150858/8.0), - REAL_CONST(51627.461056745415/8.0), - REAL_CONST(51647.56031637713/8.0), - REAL_CONST(51667.661531665362/8.0), - REAL_CONST(51687.764702229651/8.0), - REAL_CONST(51707.869827689727/8.0), - REAL_CONST(51727.976907665499/8.0), - REAL_CONST(51748.085941777055/8.0), - REAL_CONST(51768.196929644677/8.0), - REAL_CONST(51788.309870888836/8.0), - REAL_CONST(51808.42476513017/8.0), - REAL_CONST(51828.541611989524/8.0), - REAL_CONST(51848.660411087905/8.0), - REAL_CONST(51868.781162046515/8.0), - REAL_CONST(51888.90386448674/8.0), - REAL_CONST(51909.028518030143/8.0), - REAL_CONST(51929.155122298485/8.0), - REAL_CONST(51949.283676913685/8.0), - REAL_CONST(51969.414181497872/8.0), - REAL_CONST(51989.546635673345/8.0), - REAL_CONST(52009.681039062583/8.0), - REAL_CONST(52029.817391288263/8.0), - REAL_CONST(52049.955691973213/8.0), - REAL_CONST(52070.095940740481/8.0), - REAL_CONST(52090.238137213273/8.0), - REAL_CONST(52110.382281014987/8.0), - REAL_CONST(52130.5283717692/8.0), - REAL_CONST(52150.676409099666/8.0), - REAL_CONST(52170.826392630333/8.0), - REAL_CONST(52190.97832198532/8.0), - REAL_CONST(52211.132196788931/8.0), - REAL_CONST(52231.288016665654/8.0), - REAL_CONST(52251.445781240145/8.0), - REAL_CONST(52271.60549013727/8.0), - REAL_CONST(52291.76714298204/8.0), - REAL_CONST(52311.930739399664/8.0), - REAL_CONST(52332.096279015546/8.0), - REAL_CONST(52352.263761455244/8.0), - REAL_CONST(52372.433186344519/8.0), - REAL_CONST(52392.604553309284/8.0), - REAL_CONST(52412.777861975665/8.0), - REAL_CONST(52432.953111969946/8.0), - REAL_CONST(52453.130302918595/8.0), - REAL_CONST(52473.309434448267/8.0), - REAL_CONST(52493.490506185793/8.0), - REAL_CONST(52513.67351775818/8.0), - REAL_CONST(52533.858468792605/8.0), - REAL_CONST(52554.045358916446/8.0), - REAL_CONST(52574.234187757254/8.0), - REAL_CONST(52594.42495494274/8.0), - REAL_CONST(52614.617660100812/8.0), - REAL_CONST(52634.812302859558/8.0), - REAL_CONST(52655.008882847229/8.0), - REAL_CONST(52675.20739969227/8.0), - REAL_CONST(52695.407853023295/8.0), - REAL_CONST(52715.610242469098/8.0), - REAL_CONST(52735.814567658657/8.0), - REAL_CONST(52756.02082822111/8.0), - REAL_CONST(52776.229023785803/8.0), - REAL_CONST(52796.439153982225/8.0), - REAL_CONST(52816.651218440056/8.0), - REAL_CONST(52836.865216789171/8.0), - REAL_CONST(52857.081148659599/8.0), - REAL_CONST(52877.29901368155/8.0), - REAL_CONST(52897.518811485425/8.0), - REAL_CONST(52917.740541701773/8.0), - REAL_CONST(52937.964203961354/8.0), - REAL_CONST(52958.18979789508/8.0), - REAL_CONST(52978.417323134046/8.0), - REAL_CONST(52998.646779309529/8.0), - REAL_CONST(53018.878166052978/8.0), - REAL_CONST(53039.111482996006/8.0), - REAL_CONST(53059.346729770419/8.0), - REAL_CONST(53079.583906008193/8.0), - REAL_CONST(53099.823011341483/8.0), - REAL_CONST(53120.0640454026/8.0), - REAL_CONST(53140.307007824063/8.0), - REAL_CONST(53160.551898238533/8.0), - REAL_CONST(53180.79871627887/8.0), - REAL_CONST(53201.047461578091/8.0), - REAL_CONST(53221.2981337694/8.0), - REAL_CONST(53241.550732486176/8.0), - REAL_CONST(53261.805257361964/8.0), - REAL_CONST(53282.061708030487/8.0), - REAL_CONST(53302.32008412564/8.0), - REAL_CONST(53322.580385281493/8.0), - REAL_CONST(53342.842611132299/8.0), - REAL_CONST(53363.106761312469/8.0), - REAL_CONST(53383.372835456597/8.0), - REAL_CONST(53403.640833199453/8.0), - REAL_CONST(53423.910754175973/8.0), - REAL_CONST(53444.18259802126/8.0), - REAL_CONST(53464.456364370613/8.0), - REAL_CONST(53484.732052859479/8.0), - REAL_CONST(53505.009663123499/8.0), - REAL_CONST(53525.289194798468/8.0), - REAL_CONST(53545.570647520362/8.0), - REAL_CONST(53565.854020925333/8.0), - REAL_CONST(53586.139314649699/8.0), - REAL_CONST(53606.426528329954/8.0), - REAL_CONST(53626.715661602764/8.0), - REAL_CONST(53647.006714104959/8.0), - REAL_CONST(53667.299685473547/8.0), - REAL_CONST(53687.59457534572/8.0), - REAL_CONST(53707.891383358816/8.0), - REAL_CONST(53728.190109150361/8.0), - REAL_CONST(53748.490752358055/8.0), - REAL_CONST(53768.793312619753/8.0), - REAL_CONST(53789.09778957349/8.0), - REAL_CONST(53809.404182857485/8.0), - REAL_CONST(53829.712492110106/8.0), - REAL_CONST(53850.022716969899/8.0), - REAL_CONST(53870.334857075584/8.0), - REAL_CONST(53890.648912066055/8.0), - REAL_CONST(53910.964881580367/8.0), - REAL_CONST(53931.28276525774/8.0), - REAL_CONST(53951.602562737586/8.0), - REAL_CONST(53971.924273659461/8.0), - REAL_CONST(53992.24789766311/8.0), - REAL_CONST(54012.57343438844/8.0), - REAL_CONST(54032.90088347553/8.0), - REAL_CONST(54053.23024456462/8.0), - REAL_CONST(54073.561517296133/8.0), - REAL_CONST(54093.894701310644/8.0), - REAL_CONST(54114.22979624891/8.0), - REAL_CONST(54134.566801751855/8.0), - REAL_CONST(54154.90571746057/8.0), - REAL_CONST(54175.246543016314/8.0), - REAL_CONST(54195.589278060506/8.0), - REAL_CONST(54215.933922234755/8.0), - REAL_CONST(54236.280475180814/8.0), - REAL_CONST(54256.628936540626/8.0), - REAL_CONST(54276.97930595628/8.0), - REAL_CONST(54297.331583070045/8.0), - REAL_CONST(54317.685767524359/8.0), - REAL_CONST(54338.041858961828/8.0), - REAL_CONST(54358.399857025215/8.0), - REAL_CONST(54378.759761357462/8.0), - REAL_CONST(54399.121571601667/8.0), - REAL_CONST(54419.485287401105/8.0), - REAL_CONST(54439.850908399218/8.0), - REAL_CONST(54460.218434239614/8.0), - REAL_CONST(54480.587864566056/8.0), - REAL_CONST(54500.95919902248/8.0), - REAL_CONST(54521.332437252997/8.0), - REAL_CONST(54541.707578901878/8.0), - REAL_CONST(54562.084623613555/8.0), - REAL_CONST(54582.46357103264/8.0), - REAL_CONST(54602.844420803893/8.0), - REAL_CONST(54623.227172572246/8.0), - REAL_CONST(54643.611825982807/8.0), - REAL_CONST(54663.998380680838/8.0), - REAL_CONST(54684.386836311773/8.0), - REAL_CONST(54704.777192521207/8.0), - REAL_CONST(54725.169448954897/8.0), - REAL_CONST(54745.563605258772/8.0), - REAL_CONST(54765.959661078923/8.0), - REAL_CONST(54786.357616061614/8.0), - REAL_CONST(54806.757469853255/8.0), - REAL_CONST(54827.159222100439/8.0), - REAL_CONST(54847.562872449904/8.0), - REAL_CONST(54867.968420548583/8.0), - REAL_CONST(54888.375866043534/8.0), - REAL_CONST(54908.785208582012/8.0), - REAL_CONST(54929.196447811417/8.0), - REAL_CONST(54949.609583379322/8.0), - REAL_CONST(54970.024614933463/8.0), - REAL_CONST(54990.441542121727/8.0), - REAL_CONST(55010.86036459219/8.0), - REAL_CONST(55031.28108199306/8.0), - REAL_CONST(55051.703693972733/8.0), - REAL_CONST(55072.128200179759/8.0), - REAL_CONST(55092.554600262847/8.0), - REAL_CONST(55112.982893870874/8.0), - REAL_CONST(55133.413080652877/8.0), - REAL_CONST(55153.845160258061/8.0), - REAL_CONST(55174.279132335789/8.0), - REAL_CONST(55194.714996535586/8.0), - REAL_CONST(55215.152752507143/8.0), - REAL_CONST(55235.592399900306/8.0), - REAL_CONST(55256.033938365079/8.0), - REAL_CONST(55276.477367551655/8.0), - REAL_CONST(55296.92268711036/8.0), - REAL_CONST(55317.369896691685/8.0), - REAL_CONST(55337.818995946305/8.0), - REAL_CONST(55358.269984525024/8.0), - REAL_CONST(55378.72286207883/8.0), - REAL_CONST(55399.177628258869/8.0), - REAL_CONST(55419.634282716441/8.0), - REAL_CONST(55440.092825103013/8.0), - REAL_CONST(55460.553255070205/8.0), - REAL_CONST(55481.015572269804/8.0), - REAL_CONST(55501.479776353764/8.0), - REAL_CONST(55521.945866974187/8.0), - REAL_CONST(55542.413843783339/8.0), - REAL_CONST(55562.883706433655/8.0), - REAL_CONST(55583.355454577715/8.0), - REAL_CONST(55603.82908786826/8.0), - REAL_CONST(55624.304605958219/8.0), - REAL_CONST(55644.782008500639/8.0), - REAL_CONST(55665.261295148754/8.0), - REAL_CONST(55685.742465555952/8.0), - REAL_CONST(55706.225519375774/8.0), - REAL_CONST(55726.710456261928/8.0), - REAL_CONST(55747.197275868275/8.0), - REAL_CONST(55767.685977848843/8.0), - REAL_CONST(55788.176561857814/8.0), - REAL_CONST(55808.669027549528/8.0), - REAL_CONST(55829.163374578478/8.0), - REAL_CONST(55849.659602599328/8.0), - REAL_CONST(55870.157711266889/8.0), - REAL_CONST(55890.657700236145/8.0), - REAL_CONST(55911.159569162221/8.0), - REAL_CONST(55931.663317700411/8.0), - REAL_CONST(55952.168945506164/8.0), - REAL_CONST(55972.676452235086/8.0), - REAL_CONST(55993.185837542944/8.0), - REAL_CONST(56013.697101085651/8.0), - REAL_CONST(56034.210242519301/8.0), - REAL_CONST(56054.72526150012/8.0), - REAL_CONST(56075.242157684508/8.0), - REAL_CONST(56095.760930729011/8.0), - REAL_CONST(56116.281580290342/8.0), - REAL_CONST(56136.804106025367/8.0), - REAL_CONST(56157.328507591104/8.0), - REAL_CONST(56177.85478464474/8.0), - REAL_CONST(56198.382936843598/8.0), - REAL_CONST(56218.912963845185/8.0), - REAL_CONST(56239.444865307138/8.0), - REAL_CONST(56259.978640887268/8.0), - REAL_CONST(56280.514290243525/8.0), - REAL_CONST(56301.051813034042/8.0), - REAL_CONST(56321.591208917082/8.0), - REAL_CONST(56342.13247755108/8.0), - REAL_CONST(56362.675618594607/8.0), - REAL_CONST(56383.220631706419/8.0), - REAL_CONST(56403.767516545398/8.0), - REAL_CONST(56424.316272770608/8.0), - REAL_CONST(56444.866900041241/8.0), - REAL_CONST(56465.419398016667/8.0), - REAL_CONST(56485.973766356394/8.0), - REAL_CONST(56506.530004720102/8.0), - REAL_CONST(56527.088112767611/8.0), - REAL_CONST(56547.648090158902/8.0), - REAL_CONST(56568.209936554107/8.0), - REAL_CONST(56588.773651613519/8.0), - REAL_CONST(56609.339234997584/8.0), - REAL_CONST(56629.9066863669/8.0), - REAL_CONST(56650.47600538221/8.0), - REAL_CONST(56671.04719170442/8.0), - REAL_CONST(56691.620244994599/8.0), - REAL_CONST(56712.195164913959/8.0), - REAL_CONST(56732.771951123868/8.0), - REAL_CONST(56753.350603285835/8.0), - REAL_CONST(56773.931121061541/8.0), - REAL_CONST(56794.513504112823/8.0), - REAL_CONST(56815.097752101647/8.0), - REAL_CONST(56835.683864690152/8.0), - REAL_CONST(56856.271841540627/8.0), - REAL_CONST(56876.86168231551/8.0), - REAL_CONST(56897.453386677393/8.0), - REAL_CONST(56918.046954289028/8.0), - REAL_CONST(56938.642384813298/8.0), - REAL_CONST(56959.239677913261/8.0), - REAL_CONST(56979.838833252121/8.0), - REAL_CONST(57000.439850493225/8.0), - REAL_CONST(57021.04272930009/8.0), - REAL_CONST(57041.647469336371/8.0), - REAL_CONST(57062.254070265873/8.0), - REAL_CONST(57082.862531752558/8.0), - REAL_CONST(57103.472853460553/8.0), - REAL_CONST(57124.085035054108/8.0), - REAL_CONST(57144.699076197649/8.0), - REAL_CONST(57165.314976555739/8.0), - REAL_CONST(57185.932735793103/8.0), - REAL_CONST(57206.552353574611/8.0), - REAL_CONST(57227.173829565276/8.0), - REAL_CONST(57247.797163430281/8.0), - REAL_CONST(57268.42235483494/8.0), - REAL_CONST(57289.049403444733/8.0), - REAL_CONST(57309.678308925286/8.0), - REAL_CONST(57330.30907094237/8.0), - REAL_CONST(57350.941689161911/8.0), - REAL_CONST(57371.576163249985/8.0), - REAL_CONST(57392.212492872815/8.0), - REAL_CONST(57412.850677696784/8.0), - REAL_CONST(57433.490717388406/8.0), - REAL_CONST(57454.132611614368/8.0), - REAL_CONST(57474.776360041491/8.0), - REAL_CONST(57495.421962336746/8.0), - REAL_CONST(57516.069418167266/8.0), - REAL_CONST(57536.718727200314/8.0), - REAL_CONST(57557.36988910332/8.0), - REAL_CONST(57578.022903543861/8.0), - REAL_CONST(57598.677770189643/8.0), - REAL_CONST(57619.334488708548/8.0), - REAL_CONST(57639.993058768589/8.0), - REAL_CONST(57660.653480037938/8.0), - REAL_CONST(57681.315752184906/8.0), - REAL_CONST(57701.979874877965/8.0), - REAL_CONST(57722.64584778573/8.0), - REAL_CONST(57743.31367057695/8.0), - REAL_CONST(57763.983342920546/8.0), - REAL_CONST(57784.654864485572/8.0), - REAL_CONST(57805.328234941233/8.0), - REAL_CONST(57826.003453956881/8.0), - REAL_CONST(57846.680521202026/8.0), - REAL_CONST(57867.359436346305/8.0), - REAL_CONST(57888.040199059527/8.0), - REAL_CONST(57908.722809011633/8.0), - REAL_CONST(57929.407265872709/8.0), - REAL_CONST(57950.093569313001/8.0), - REAL_CONST(57970.781719002895/8.0), - REAL_CONST(57991.471714612911/8.0), - REAL_CONST(58012.16355581375/8.0), - REAL_CONST(58032.857242276223/8.0), - REAL_CONST(58053.552773671312/8.0), - REAL_CONST(58074.25014967013/8.0), - REAL_CONST(58094.949369943948/8.0), - REAL_CONST(58115.650434164185/8.0), - REAL_CONST(58136.353342002389/8.0), - REAL_CONST(58157.058093130276/8.0), - REAL_CONST(58177.764687219693/8.0), - REAL_CONST(58198.47312394264/8.0), - REAL_CONST(58219.183402971255/8.0), - REAL_CONST(58239.895523977837/8.0), - REAL_CONST(58260.609486634821/8.0), - REAL_CONST(58281.325290614775/8.0), - REAL_CONST(58302.042935590434/8.0), - REAL_CONST(58322.762421234678/8.0), - REAL_CONST(58343.483747220511/8.0), - REAL_CONST(58364.206913221096/8.0), - REAL_CONST(58384.931918909751/8.0), - REAL_CONST(58405.658763959924/8.0), - REAL_CONST(58426.3874480452/8.0), - REAL_CONST(58447.117970839339/8.0), - REAL_CONST(58467.85033201622/8.0), - REAL_CONST(58488.584531249864/8.0), - REAL_CONST(58509.320568214462/8.0), - REAL_CONST(58530.058442584334/8.0), - REAL_CONST(58550.798154033931/8.0), - REAL_CONST(58571.539702237875/8.0), - REAL_CONST(58592.283086870906/8.0), - REAL_CONST(58613.028307607929/8.0), - REAL_CONST(58633.775364123983/8.0), - REAL_CONST(58654.52425609425/8.0), - REAL_CONST(58675.274983194053/8.0), - REAL_CONST(58696.027545098877/8.0), - REAL_CONST(58716.781941484325/8.0), - REAL_CONST(58737.538172026158/8.0), - REAL_CONST(58758.296236400274/8.0), - REAL_CONST(58779.056134282728/8.0), - REAL_CONST(58799.817865349694/8.0), - REAL_CONST(58820.581429277503/8.0), - REAL_CONST(58841.346825742643/8.0), - REAL_CONST(58862.114054421712/8.0), - REAL_CONST(58882.883114991484/8.0), - REAL_CONST(58903.654007128847/8.0), - REAL_CONST(58924.426730510851/8.0), - REAL_CONST(58945.201284814684/8.0), - REAL_CONST(58965.977669717664/8.0), - REAL_CONST(58986.755884897269/8.0), - REAL_CONST(59007.535930031117/8.0), - REAL_CONST(59028.317804796949/8.0), - REAL_CONST(59049.101508872664/8.0), - REAL_CONST(59069.887041936301/8.0), - REAL_CONST(59090.674403666046/8.0), - REAL_CONST(59111.463593740213/8.0), - REAL_CONST(59132.254611837263/8.0), - REAL_CONST(59153.047457635803/8.0), - REAL_CONST(59173.84213081457/8.0), - REAL_CONST(59194.638631052461/8.0), - REAL_CONST(59215.436958028506/8.0), - REAL_CONST(59236.237111421855/8.0), - REAL_CONST(59257.039090911829/8.0), - REAL_CONST(59277.842896177877/8.0), - REAL_CONST(59298.648526899589/8.0), - REAL_CONST(59319.455982756685/8.0), - REAL_CONST(59340.26526342905/8.0), - REAL_CONST(59361.076368596696/8.0), - REAL_CONST(59381.889297939757/8.0), - REAL_CONST(59402.704051138542/8.0), - REAL_CONST(59423.520627873484/8.0), - REAL_CONST(59444.339027825139/8.0), - REAL_CONST(59465.159250674224/8.0), - REAL_CONST(59485.9812961016/8.0), - REAL_CONST(59506.805163788253/8.0), - REAL_CONST(59527.630853415307/8.0), - REAL_CONST(59548.458364664046/8.0), - REAL_CONST(59569.287697215863/8.0), - REAL_CONST(59590.118850752311/8.0), - REAL_CONST(59610.951824955089/8.0), - REAL_CONST(59631.786619506012/8.0), - REAL_CONST(59652.623234087048/8.0), - REAL_CONST(59673.461668380311/8.0), - REAL_CONST(59694.301922068029/8.0), - REAL_CONST(59715.143994832593/8.0), - REAL_CONST(59735.987886356525/8.0), - REAL_CONST(59756.833596322482/8.0), - REAL_CONST(59777.681124413255/8.0), - REAL_CONST(59798.530470311794/8.0), - REAL_CONST(59819.381633701159/8.0), - REAL_CONST(59840.234614264569/8.0), - REAL_CONST(59861.089411685381/8.0), - REAL_CONST(59881.94602564707/8.0), - REAL_CONST(59902.804455833269/8.0), - REAL_CONST(59923.664701927737/8.0), - REAL_CONST(59944.526763614384/8.0), - REAL_CONST(59965.390640577243/8.0), - REAL_CONST(59986.256332500488/8.0), - REAL_CONST(60007.123839068438/8.0), - REAL_CONST(60027.993159965539/8.0), - REAL_CONST(60048.864294876381/8.0), - REAL_CONST(60069.737243485688/8.0), - REAL_CONST(60090.612005478324/8.0), - REAL_CONST(60111.488580539284/8.0), - REAL_CONST(60132.366968353708/8.0), - REAL_CONST(60153.247168606867/8.0), - REAL_CONST(60174.129180984164/8.0), - REAL_CONST(60195.013005171153/8.0), - REAL_CONST(60215.898640853513/8.0), - REAL_CONST(60236.786087717061/8.0), - REAL_CONST(60257.675345447751/8.0), - REAL_CONST(60278.566413731671/8.0), - REAL_CONST(60299.459292255044/8.0), - REAL_CONST(60320.353980704247/8.0), - REAL_CONST(60341.25047876576/8.0), - REAL_CONST(60362.148786126229/8.0), - REAL_CONST(60383.048902472423/8.0), - REAL_CONST(60403.950827491237/8.0), - REAL_CONST(60424.854560869717/8.0), - REAL_CONST(60445.76010229504/8.0), - REAL_CONST(60466.667451454516/8.0), - REAL_CONST(60487.57660803559/8.0), - REAL_CONST(60508.487571725847/8.0), - REAL_CONST(60529.400342212997/8.0), - REAL_CONST(60550.314919184893/8.0), - REAL_CONST(60571.231302329521/8.0), - REAL_CONST(60592.149491335003/8.0), - REAL_CONST(60613.069485889588/8.0), - REAL_CONST(60633.991285681674/8.0), - REAL_CONST(60654.914890399785/8.0), - REAL_CONST(60675.840299732568/8.0), - REAL_CONST(60696.767513368832/8.0), - REAL_CONST(60717.696530997484/8.0), - REAL_CONST(60738.627352307602/8.0), - REAL_CONST(60759.55997698837/8.0), - REAL_CONST(60780.494404729128/8.0), - REAL_CONST(60801.430635219323/8.0), - REAL_CONST(60822.368668148556/8.0), - REAL_CONST(60843.308503206565/8.0), - REAL_CONST(60864.250140083204/8.0), - REAL_CONST(60885.193578468468/8.0), - REAL_CONST(60906.138818052495/8.0), - REAL_CONST(60927.085858525541/8.0), - REAL_CONST(60948.034699578006/8.0), - REAL_CONST(60968.985340900421/8.0), - REAL_CONST(60989.937782183442/8.0), - REAL_CONST(61010.892023117864/8.0), - REAL_CONST(61031.848063394616/8.0), - REAL_CONST(61052.805902704764/8.0), - REAL_CONST(61073.765540739492/8.0), - REAL_CONST(61094.726977190134/8.0), - REAL_CONST(61115.690211748137/8.0), - REAL_CONST(61136.655244105103/8.0), - REAL_CONST(61157.622073952742/8.0), - REAL_CONST(61178.590700982917/8.0), - REAL_CONST(61199.561124887616/8.0), - REAL_CONST(61220.533345358948/8.0), - REAL_CONST(61241.507362089171/8.0), - REAL_CONST(61262.483174770663/8.0), - REAL_CONST(61283.460783095943/8.0), - REAL_CONST(61304.440186757645/8.0), - REAL_CONST(61325.421385448557/8.0), - REAL_CONST(61346.404378861582/8.0), - REAL_CONST(61367.389166689762/8.0), - REAL_CONST(61388.375748626262/8.0), - REAL_CONST(61409.364124364387/8.0), - REAL_CONST(61430.354293597571/8.0), - REAL_CONST(61451.346256019373/8.0), - REAL_CONST(61472.340011323497/8.0), - REAL_CONST(61493.335559203762/8.0), - REAL_CONST(61514.332899354122/8.0), - REAL_CONST(61535.332031468672/8.0), - REAL_CONST(61556.332955241618/8.0), - REAL_CONST(61577.335670367313/8.0), - REAL_CONST(61598.340176540238/8.0), - REAL_CONST(61619.346473454993/8.0), - REAL_CONST(61640.354560806329/8.0), - REAL_CONST(61661.3644382891/8.0), - REAL_CONST(61682.376105598312/8.0), - REAL_CONST(61703.389562429089/8.0), - REAL_CONST(61724.404808476691/8.0), - REAL_CONST(61745.42184343651/8.0), - REAL_CONST(61766.440667004063/8.0), - REAL_CONST(61787.461278874987/8.0), - REAL_CONST(61808.483678745069/8.0), - REAL_CONST(61829.507866310203/8.0), - REAL_CONST(61850.533841266435/8.0), - REAL_CONST(61871.561603309929/8.0), - REAL_CONST(61892.591152136971/8.0), - REAL_CONST(61913.622487443987/8.0), - REAL_CONST(61934.655608927525/8.0), - REAL_CONST(61955.690516284267/8.0), - REAL_CONST(61976.727209211022/8.0), - REAL_CONST(61997.765687404724/8.0), - REAL_CONST(62018.805950562448/8.0), - REAL_CONST(62039.847998381381/8.0), - REAL_CONST(62060.891830558845/8.0), - REAL_CONST(62081.93744679229/8.0), - REAL_CONST(62102.984846779298/8.0), - REAL_CONST(62124.034030217575/8.0), - REAL_CONST(62145.084996804966/8.0), - REAL_CONST(62166.137746239416/8.0), - REAL_CONST(62187.19227821903/8.0), - REAL_CONST(62208.248592442025/8.0), - REAL_CONST(62229.306688606739/8.0), - REAL_CONST(62250.366566411656/8.0), - REAL_CONST(62271.428225555377/8.0), - REAL_CONST(62292.491665736627/8.0), - REAL_CONST(62313.556886654267/8.0), - REAL_CONST(62334.623888007271/8.0), - REAL_CONST(62355.692669494762/8.0), - REAL_CONST(62376.763230815974/8.0), - REAL_CONST(62397.835571670272/8.0), - REAL_CONST(62418.909691757144/8.0), - REAL_CONST(62439.98559077621/8.0), - REAL_CONST(62461.063268427228/8.0), - REAL_CONST(62482.142724410049/8.0), - REAL_CONST(62503.223958424685/8.0), - REAL_CONST(62524.306970171267/8.0), - REAL_CONST(62545.39175935003/8.0), - REAL_CONST(62566.478325661366/8.0), - REAL_CONST(62587.566668805768/8.0), - REAL_CONST(62608.656788483881/8.0), - REAL_CONST(62629.748684396451/8.0), - REAL_CONST(62650.842356244357/8.0), - REAL_CONST(62671.937803728622/8.0), - REAL_CONST(62693.035026550366/8.0), - REAL_CONST(62714.134024410858/8.0), - REAL_CONST(62735.234797011479/8.0), - REAL_CONST(62756.337344053733/8.0), - REAL_CONST(62777.441665239276/8.0), - REAL_CONST(62798.547760269852/8.0), - REAL_CONST(62819.655628847358/8.0), - REAL_CONST(62840.765270673801/8.0), - REAL_CONST(62861.876685451323/8.0), - REAL_CONST(62882.989872882186/8.0), - REAL_CONST(62904.104832668774/8.0), - REAL_CONST(62925.221564513602/8.0), - REAL_CONST(62946.340068119309/8.0), - REAL_CONST(62967.460343188657/8.0), - REAL_CONST(62988.582389424526/8.0), - REAL_CONST(63009.70620652994/8.0), - REAL_CONST(63030.831794208025/8.0), - REAL_CONST(63051.959152162039/8.0), - REAL_CONST(63073.08828009537/8.0), - REAL_CONST(63094.219177711529/8.0), - REAL_CONST(63115.351844714154/8.0), - REAL_CONST(63136.486280806988/8.0), - REAL_CONST(63157.622485693922/8.0), - REAL_CONST(63178.760459078956/8.0), - REAL_CONST(63199.900200666219/8.0), - REAL_CONST(63221.041710159967/8.0), - REAL_CONST(63242.184987264569/8.0), - REAL_CONST(63263.330031684534/8.0), - REAL_CONST(63284.476843124474/8.0), - REAL_CONST(63305.625421289144/8.0), - REAL_CONST(63326.775765883409/8.0), - REAL_CONST(63347.927876612259/8.0), - REAL_CONST(63369.081753180813/8.0), - REAL_CONST(63390.237395294316/8.0), - REAL_CONST(63411.39480265812/8.0), - REAL_CONST(63432.553974977716/8.0), - REAL_CONST(63453.714911958712/8.0), - REAL_CONST(63474.877613306839/8.0), - REAL_CONST(63496.042078727944/8.0), - REAL_CONST(63517.208307927998/8.0), - REAL_CONST(63538.376300613119/8.0), - REAL_CONST(63559.546056489504/8.0), - REAL_CONST(63580.717575263516/8.0), - REAL_CONST(63601.890856641607/8.0), - REAL_CONST(63623.065900330374/8.0), - REAL_CONST(63644.242706036515/8.0), - REAL_CONST(63665.421273466869/8.0), - REAL_CONST(63686.601602328381/8.0), - REAL_CONST(63707.783692328136/8.0), - REAL_CONST(63728.967543173334/8.0), - REAL_CONST(63750.153154571279/8.0), - REAL_CONST(63771.340526229418/8.0), - REAL_CONST(63792.529657855317/8.0), - REAL_CONST(63813.720549156649/8.0), - REAL_CONST(63834.913199841227/8.0), - REAL_CONST(63856.107609616978/8.0), - REAL_CONST(63877.303778191941/8.0), - REAL_CONST(63898.501705274284/8.0), - REAL_CONST(63919.7013905723/8.0), - REAL_CONST(63940.902833794404/8.0), - REAL_CONST(63962.106034649114/8.0), - REAL_CONST(63983.310992845094/8.0), - REAL_CONST(64004.517708091109/8.0), - REAL_CONST(64025.726180096048/8.0), - REAL_CONST(64046.936408568938/8.0), - REAL_CONST(64068.1483932189/8.0), - REAL_CONST(64089.362133755196/8.0), - REAL_CONST(64110.577629887193/8.0), - REAL_CONST(64131.794881324393/8.0), - REAL_CONST(64153.013887776404/8.0), - REAL_CONST(64174.234648952966/8.0), - REAL_CONST(64195.457164563937/8.0), - REAL_CONST(64216.681434319289/8.0), - REAL_CONST(64237.907457929112/8.0), - REAL_CONST(64259.135235103626/8.0), - REAL_CONST(64280.36476555316/8.0), - REAL_CONST(64301.596048988169/8.0), - REAL_CONST(64322.829085119236/8.0), - REAL_CONST(64344.06387365704/8.0), - REAL_CONST(64365.300414312398/8.0), - REAL_CONST(64386.538706796251/8.0), - REAL_CONST(64407.778750819634/8.0), - REAL_CONST(64429.020546093721/8.0), - REAL_CONST(64450.26409232981/8.0), - REAL_CONST(64471.509389239291/8.0), - REAL_CONST(64492.756436533709/8.0), - REAL_CONST(64514.005233924705/8.0), - REAL_CONST(64535.255781124033/8.0), - REAL_CONST(64556.50807784358/8.0), - REAL_CONST(64577.762123795357/8.0), - REAL_CONST(64599.017918691468/8.0), - REAL_CONST(64620.275462244172/8.0), - REAL_CONST(64641.534754165805/8.0), - REAL_CONST(64662.795794168844/8.0), - REAL_CONST(64684.058581965895/8.0), - REAL_CONST(64705.323117269661/8.0), - REAL_CONST(64726.589399792974/8.0), - REAL_CONST(64747.857429248776/8.0), - REAL_CONST(64769.127205350138/8.0), - REAL_CONST(64790.398727810236/8.0), - REAL_CONST(64811.671996342375/8.0), - REAL_CONST(64832.947010659969/8.0), - REAL_CONST(64854.223770476558/8.0), - REAL_CONST(64875.502275505794/8.0), - REAL_CONST(64896.782525461451/8.0), - REAL_CONST(64918.064520057414/8.0), - REAL_CONST(64939.348259007682/8.0), - REAL_CONST(64960.633742026388/8.0), - REAL_CONST(64981.920968827762/8.0), - REAL_CONST(65003.209939126165/8.0), - REAL_CONST(65024.500652636067/8.0), - REAL_CONST(65045.793109072067/8.0), - REAL_CONST(65067.087308148861/8.0), - REAL_CONST(65088.383249581282/8.0), - REAL_CONST(65109.680933084259/8.0), - REAL_CONST(65130.980358372864/8.0), - REAL_CONST(65152.28152516226/8.0), - REAL_CONST(65173.584433167736/8.0), - REAL_CONST(65194.889082104703/8.0), - REAL_CONST(65216.195471688683/8.0), - REAL_CONST(65237.503601635319/8.0), - REAL_CONST(65258.813471660353/8.0), - REAL_CONST(65280.125081479666/8.0), - REAL_CONST(65301.438430809241/8.0), - REAL_CONST(65322.753519365178/8.0), - REAL_CONST(65344.070346863708/8.0), - REAL_CONST(65365.388913021146/8.0), - REAL_CONST(65386.709217553958/8.0), - REAL_CONST(65408.031260178701/8.0), - REAL_CONST(65429.355040612056/8.0), - REAL_CONST(65450.680558570821/8.0), - REAL_CONST(65472.00781377191/8.0), - REAL_CONST(65493.336805932355/8.0), - REAL_CONST(65514.66753476928/8.0), - REAL_CONST(65535.999999999956/8.0), - REAL_CONST(65557.334201341757/8.0), - REAL_CONST(65578.670138512171/8.0), - REAL_CONST(65600.007811228788/8.0), - REAL_CONST(65621.347219209332/8.0), - REAL_CONST(65642.688362171626/8.0), - REAL_CONST(65664.031239833639/8.0), - REAL_CONST(65685.375851913413/8.0), - REAL_CONST(65706.722198129137/8.0), - REAL_CONST(65728.070278199084/8.0), - REAL_CONST(65749.420091841661/8.0), - REAL_CONST(65770.771638775404/8.0), - REAL_CONST(65792.124918718939/8.0), - REAL_CONST(65813.479931391004/8.0), - REAL_CONST(65834.836676510458/8.0), - REAL_CONST(65856.195153796303/8.0), - REAL_CONST(65877.5553629676/8.0), - REAL_CONST(65898.917303743554/8.0), - REAL_CONST(65920.280975843489/8.0), - REAL_CONST(65941.646378986843/8.0), - REAL_CONST(65963.013512893158/8.0), - REAL_CONST(65984.382377282076/8.0), - REAL_CONST(66005.752971873386/8.0), - REAL_CONST(66027.125296386963/8.0), - REAL_CONST(66048.499350542799/8.0), - REAL_CONST(66069.875134061018/8.0), - REAL_CONST(66091.252646661844/8.0), - REAL_CONST(66112.631888065618/8.0), - REAL_CONST(66134.01285799277/8.0), - REAL_CONST(66155.395556163887/8.0), - REAL_CONST(66176.779982299631/8.0), - REAL_CONST(66198.166136120795/8.0), - REAL_CONST(66219.554017348273/8.0), - REAL_CONST(66240.943625703105/8.0), - REAL_CONST(66262.334960906388/8.0), - REAL_CONST(66283.728022679396/8.0), - REAL_CONST(66305.122810743444/8.0), - REAL_CONST(66326.519324820023/8.0), - REAL_CONST(66347.917564630698/8.0), - REAL_CONST(66369.317529897162/8.0), - REAL_CONST(66390.719220341227/8.0), - REAL_CONST(66412.122635684791/8.0), - REAL_CONST(66433.527775649884/8.0), - REAL_CONST(66454.934639958636/8.0), - REAL_CONST(66476.343228333324/8.0), - REAL_CONST(66497.753540496284/8.0), - REAL_CONST(66519.165576169995/8.0), - REAL_CONST(66540.57933507704/8.0), - REAL_CONST(66561.994816940118/8.0), - REAL_CONST(66583.412021482043/8.0), - REAL_CONST(66604.830948425733/8.0), - REAL_CONST(66626.251597494222/8.0), - REAL_CONST(66647.673968410629/8.0), - REAL_CONST(66669.098060898235/8.0), - REAL_CONST(66690.523874680381/8.0), - REAL_CONST(66711.951409480564/8.0), - REAL_CONST(66733.380665022371/8.0), - REAL_CONST(66754.811641029475/8.0), - REAL_CONST(66776.244337225711/8.0), - REAL_CONST(66797.678753334985/8.0), - REAL_CONST(66819.11488908132/8.0), - REAL_CONST(66840.552744188884/8.0), - REAL_CONST(66861.992318381905/8.0), - REAL_CONST(66883.433611384738/8.0), - REAL_CONST(66904.876622921889/8.0), - REAL_CONST(66926.321352717903/8.0), - REAL_CONST(66947.767800497502/8.0), - REAL_CONST(66969.215965985466/8.0), - REAL_CONST(66990.665848906734/8.0), - REAL_CONST(67012.117448986304/8.0), - REAL_CONST(67033.570765949335/8.0), - REAL_CONST(67055.025799521056/8.0), - REAL_CONST(67076.482549426815/8.0), - REAL_CONST(67097.941015392076/8.0), - REAL_CONST(67119.401197142433/8.0), - REAL_CONST(67140.863094403554/8.0), - REAL_CONST(67162.326706901222/8.0), - REAL_CONST(67183.792034361351/8.0), - REAL_CONST(67205.259076509959/8.0), - REAL_CONST(67226.72783307315/8.0), - REAL_CONST(67248.198303777172/8.0), - REAL_CONST(67269.670488348347/8.0), - REAL_CONST(67291.144386513144/8.0), - REAL_CONST(67312.619997998088/8.0), - REAL_CONST(67334.09732252988/8.0), - REAL_CONST(67355.576359835293/8.0), - REAL_CONST(67377.057109641188/8.0), - REAL_CONST(67398.53957167457/8.0), - REAL_CONST(67420.023745662547/8.0), - REAL_CONST(67441.50963133233/8.0), - REAL_CONST(67462.99722841123/8.0), - REAL_CONST(67484.486536626689/8.0), - REAL_CONST(67505.977555706224/8.0), - REAL_CONST(67527.470285377494/8.0), - REAL_CONST(67548.964725368263/8.0), - REAL_CONST(67570.460875406367/8.0), - REAL_CONST(67591.9587352198/8.0), - REAL_CONST(67613.458304536631/8.0), - REAL_CONST(67634.95958308503/8.0), - REAL_CONST(67656.462570593329/8.0), - REAL_CONST(67677.967266789899/8.0), - REAL_CONST(67699.473671403248/8.0), - REAL_CONST(67720.981784162024/8.0), - REAL_CONST(67742.491604794923/8.0), - REAL_CONST(67764.003133030797/8.0), - REAL_CONST(67785.516368598575/8.0), - REAL_CONST(67807.031311227314/8.0), - REAL_CONST(67828.547960646174/8.0), - REAL_CONST(67850.066316584402/8.0), - REAL_CONST(67871.58637877139/8.0), - REAL_CONST(67893.108146936589/8.0), - REAL_CONST(67914.63162080961/8.0), - REAL_CONST(67936.156800120138/8.0), - REAL_CONST(67957.683684597971/8.0), - REAL_CONST(67979.212273973011/8.0), - REAL_CONST(68000.742567975263/8.0), - REAL_CONST(68022.274566334876/8.0), - REAL_CONST(68043.808268782057/8.0), - REAL_CONST(68065.343675047145/8.0), - REAL_CONST(68086.880784860579/8.0), - REAL_CONST(68108.419597952918/8.0), - REAL_CONST(68129.960114054789/8.0), - REAL_CONST(68151.502332896969/8.0), - REAL_CONST(68173.04625421032/8.0), - REAL_CONST(68194.591877725834/8.0), - REAL_CONST(68216.139203174564/8.0), - REAL_CONST(68237.688230287706/8.0), - REAL_CONST(68259.238958796544/8.0), - REAL_CONST(68280.791388432481/8.0), - REAL_CONST(68302.345518927032/8.0), - REAL_CONST(68323.901350011787/8.0), - REAL_CONST(68345.458881418483/8.0), - REAL_CONST(68367.018112878912/8.0), - REAL_CONST(68388.579044125028/8.0), - REAL_CONST(68410.141674888844/8.0), - REAL_CONST(68431.706004902502/8.0), - REAL_CONST(68453.272033898262/8.0), - REAL_CONST(68474.839761608455/8.0), - REAL_CONST(68496.409187765545/8.0), - REAL_CONST(68517.980312102081/8.0), - REAL_CONST(68539.553134350732/8.0), - REAL_CONST(68561.127654244279/8.0), - REAL_CONST(68582.70387151558/8.0), - REAL_CONST(68604.281785897634/8.0), - REAL_CONST(68625.861397123503/8.0), - REAL_CONST(68647.44270492639/8.0), - REAL_CONST(68669.025709039604/8.0), - REAL_CONST(68690.610409196524/8.0), - REAL_CONST(68712.196805130661/8.0), - REAL_CONST(68733.784896575627/8.0), - REAL_CONST(68755.374683265123/8.0), - REAL_CONST(68776.966164932994/8.0), - REAL_CONST(68798.559341313128/8.0), - REAL_CONST(68820.154212139591/8.0), - REAL_CONST(68841.750777146473/8.0), - REAL_CONST(68863.349036068044/8.0), - REAL_CONST(68884.948988638629/8.0), - REAL_CONST(68906.550634592684/8.0), - REAL_CONST(68928.153973664739/8.0), - REAL_CONST(68949.75900558944/8.0), - REAL_CONST(68971.365730101577/8.0), - REAL_CONST(68992.974146935987/8.0), - REAL_CONST(69014.584255827634/8.0), - REAL_CONST(69036.196056511588/8.0), - REAL_CONST(69057.809548723017/8.0), - REAL_CONST(69079.424732197207/8.0), - REAL_CONST(69101.041606669532/8.0), - REAL_CONST(69122.660171875468/8.0), - REAL_CONST(69144.280427550606/8.0), - REAL_CONST(69165.902373430625/8.0), - REAL_CONST(69187.526009251334/8.0), - REAL_CONST(69209.151334748618/8.0), - REAL_CONST(69230.778349658474/8.0), - REAL_CONST(69252.40705371699/8.0), - REAL_CONST(69274.037446660412/8.0), - REAL_CONST(69295.669528225/8.0), - REAL_CONST(69317.303298147192/8.0), - REAL_CONST(69338.938756163494/8.0), - REAL_CONST(69360.575902010532/8.0), - REAL_CONST(69382.214735425005/8.0), - REAL_CONST(69403.855256143754/8.0), - REAL_CONST(69425.497463903681/8.0), - REAL_CONST(69447.141358441833/8.0), - REAL_CONST(69468.78693949533/8.0), - REAL_CONST(69490.434206801394/8.0), - REAL_CONST(69512.083160097391/8.0), - REAL_CONST(69533.733799120717/8.0), - REAL_CONST(69555.386123608929/8.0), - REAL_CONST(69577.04013329967/8.0), - REAL_CONST(69598.695827930685/8.0), - REAL_CONST(69620.353207239794/8.0), - REAL_CONST(69642.012270964973/8.0), - REAL_CONST(69663.67301884426/8.0), - REAL_CONST(69685.335450615792/8.0), - REAL_CONST(69706.999566017839/8.0), - REAL_CONST(69728.665364788743/8.0), - REAL_CONST(69750.332846666963/8.0), - REAL_CONST(69772.002011391058/8.0), - REAL_CONST(69793.672858699691/8.0), - REAL_CONST(69815.345388331611/8.0), - REAL_CONST(69837.019600025669/8.0), - REAL_CONST(69858.695493520849/8.0), - REAL_CONST(69880.373068556204/8.0), - REAL_CONST(69902.052324870907/8.0), - REAL_CONST(69923.733262204216/8.0), - REAL_CONST(69945.415880295492/8.0), - REAL_CONST(69967.100178884211/8.0), - REAL_CONST(69988.786157709939/8.0), - REAL_CONST(70010.473816512356/8.0), - REAL_CONST(70032.163155031216/8.0), - REAL_CONST(70053.854173006403/8.0), - REAL_CONST(70075.546870177874/8.0), - REAL_CONST(70097.241246285717/8.0), - REAL_CONST(70118.937301070109/8.0), - REAL_CONST(70140.635034271298/8.0), - REAL_CONST(70162.334445629691/8.0), - REAL_CONST(70184.035534885741/8.0), - REAL_CONST(70205.738301780017/8.0), - REAL_CONST(70227.442746053217/8.0), - REAL_CONST(70249.1488674461/8.0), - REAL_CONST(70270.856665699539/8.0), - REAL_CONST(70292.566140554511/8.0), - REAL_CONST(70314.277291752107/8.0), - REAL_CONST(70335.990119033493/8.0), - REAL_CONST(70357.704622139936/8.0), - REAL_CONST(70379.420800812819/8.0), - REAL_CONST(70401.138654793613/8.0), - REAL_CONST(70422.85818382389/8.0), - REAL_CONST(70444.579387645339/8.0), - REAL_CONST(70466.302265999722/8.0), - REAL_CONST(70488.026818628918/8.0), - REAL_CONST(70509.753045274876/8.0), - REAL_CONST(70531.480945679708/8.0), - REAL_CONST(70553.210519585555/8.0), - REAL_CONST(70574.941766734701/8.0), - REAL_CONST(70596.674686869505/8.0), - REAL_CONST(70618.409279732456/8.0), - REAL_CONST(70640.145545066101/8.0), - REAL_CONST(70661.883482613106/8.0), - REAL_CONST(70683.623092116264/8.0), - REAL_CONST(70705.364373318414/8.0), - REAL_CONST(70727.107325962526/8.0), - REAL_CONST(70748.851949791671/8.0), - REAL_CONST(70770.598244549008/8.0), - REAL_CONST(70792.346209977783/8.0), - REAL_CONST(70814.095845821372/8.0), - REAL_CONST(70835.847151823225/8.0), - REAL_CONST(70857.600127726895/8.0), - REAL_CONST(70879.354773276034/8.0), - REAL_CONST(70901.111088214413/8.0), - REAL_CONST(70922.869072285859/8.0), - REAL_CONST(70944.628725234332/8.0), - REAL_CONST(70966.390046803877/8.0), - REAL_CONST(70988.153036738629/8.0), - REAL_CONST(71009.917694782853/8.0), - REAL_CONST(71031.684020680885/8.0), - REAL_CONST(71053.45201417715/8.0), - REAL_CONST(71075.221675016204/8.0), - REAL_CONST(71096.993002942661/8.0), - REAL_CONST(71118.765997701266/8.0), - REAL_CONST(71140.540659036851/8.0), - REAL_CONST(71162.316986694335/8.0), - REAL_CONST(71184.09498041874/8.0), - REAL_CONST(71205.874639955218/8.0), - REAL_CONST(71227.655965048951/8.0), - REAL_CONST(71249.438955445294/8.0), - REAL_CONST(71271.223610889632/8.0), - REAL_CONST(71293.009931127483/8.0), - REAL_CONST(71314.797915904477/8.0), - REAL_CONST(71336.587564966307/8.0), - REAL_CONST(71358.378878058764/8.0), - REAL_CONST(71380.171854927772/8.0), - REAL_CONST(71401.966495319313/8.0), - REAL_CONST(71423.762798979486/8.0), - REAL_CONST(71445.560765654489/8.0), - REAL_CONST(71467.360395090596/8.0), - REAL_CONST(71489.161687034211/8.0), - REAL_CONST(71510.964641231811/8.0), - REAL_CONST(71532.769257429973/8.0), - REAL_CONST(71554.575535375348/8.0), - REAL_CONST(71576.383474814749/8.0), - REAL_CONST(71598.19307549503/8.0), - REAL_CONST(71620.004337163133/8.0), - REAL_CONST(71641.817259566145/8.0), - REAL_CONST(71663.631842451214/8.0), - REAL_CONST(71685.4480855656/8.0), - REAL_CONST(71707.26598865664/8.0), - REAL_CONST(71729.085551471784/8.0), - REAL_CONST(71750.906773758586/8.0), - REAL_CONST(71772.729655264673/8.0), - REAL_CONST(71794.554195737772/8.0), - REAL_CONST(71816.380394925713/8.0), - REAL_CONST(71838.208252576442/8.0), - REAL_CONST(71860.037768437964/8.0), - REAL_CONST(71881.868942258385/8.0), - REAL_CONST(71903.701773785942/8.0), - REAL_CONST(71925.536262768932/8.0), - REAL_CONST(71947.372408955751/8.0), - REAL_CONST(71969.210212094898/8.0), - REAL_CONST(71991.049671934976/8.0), - REAL_CONST(72012.890788224686/8.0), - REAL_CONST(72034.73356071279/8.0), - REAL_CONST(72056.577989148165/8.0), - REAL_CONST(72078.424073279821/8.0), - REAL_CONST(72100.271812856794/8.0), - REAL_CONST(72122.121207628254/8.0), - REAL_CONST(72143.97225734347/8.0), - REAL_CONST(72165.824961751801/8.0), - REAL_CONST(72187.679320602692/8.0), - REAL_CONST(72209.53533364569/8.0), - REAL_CONST(72231.393000630429/8.0), - REAL_CONST(72253.252321306645/8.0), - REAL_CONST(72275.113295424177/8.0), - REAL_CONST(72296.975922732949/8.0), - REAL_CONST(72318.840202982959/8.0), - REAL_CONST(72340.706135924338/8.0), - REAL_CONST(72362.573721307272/8.0), - REAL_CONST(72384.442958882093/8.0), - REAL_CONST(72406.313848399179/8.0), - REAL_CONST(72428.186389609036/8.0), - REAL_CONST(72450.060582262216/8.0), - REAL_CONST(72471.936426109431/8.0), - REAL_CONST(72493.813920901433/8.0), - REAL_CONST(72515.693066389096/8.0), - REAL_CONST(72537.573862323392/8.0), - REAL_CONST(72559.456308455352/8.0), - REAL_CONST(72581.340404536139/8.0), - REAL_CONST(72603.226150316987/8.0), - REAL_CONST(72625.113545549248/8.0), - REAL_CONST(72647.002589984331/8.0), - REAL_CONST(72668.893283373764/8.0), - REAL_CONST(72690.785625469172/8.0), - REAL_CONST(72712.679616022273/8.0), - REAL_CONST(72734.575254784853/8.0), - REAL_CONST(72756.472541508803/8.0), - REAL_CONST(72778.371475946144/8.0), - REAL_CONST(72800.272057848939/8.0), - REAL_CONST(72822.174286969355/8.0), - REAL_CONST(72844.07816305969/8.0), - REAL_CONST(72865.983685872285/8.0), - REAL_CONST(72887.890855159596/8.0), - REAL_CONST(72909.799670674183/8.0), - REAL_CONST(72931.710132168693/8.0), - REAL_CONST(72953.622239395845/8.0), - REAL_CONST(72975.535992108475/8.0), - REAL_CONST(72997.451390059519/8.0), - REAL_CONST(73019.368433001961/8.0), - REAL_CONST(73041.287120688925/8.0), - REAL_CONST(73063.207452873612/8.0), - REAL_CONST(73085.129429309294/8.0), - REAL_CONST(73107.053049749389/8.0), - REAL_CONST(73128.978313947344/8.0), - REAL_CONST(73150.905221656736/8.0), - REAL_CONST(73172.833772631217/8.0), - REAL_CONST(73194.763966624567/8.0), - REAL_CONST(73216.695803390612/8.0), - REAL_CONST(73238.62928268328/8.0), - REAL_CONST(73260.564404256627/8.0), - REAL_CONST(73282.501167864757/8.0), - REAL_CONST(73304.439573261901/8.0), - REAL_CONST(73326.379620202337/8.0), - REAL_CONST(73348.321308440485/8.0), - REAL_CONST(73370.264637730841/8.0), - REAL_CONST(73392.209607827957/8.0), - REAL_CONST(73414.156218486532/8.0), - REAL_CONST(73436.104469461323/8.0), - REAL_CONST(73458.054360507173/8.0), - REAL_CONST(73480.005891379056/8.0), - REAL_CONST(73501.959061831993/8.0), - REAL_CONST(73523.913871621116/8.0), - REAL_CONST(73545.870320501665/8.0), - REAL_CONST(73567.828408228932/8.0), - REAL_CONST(73589.78813455833/8.0), - REAL_CONST(73611.749499245358/8.0), - REAL_CONST(73633.712502045615/8.0), - REAL_CONST(73655.677142714747/8.0), - REAL_CONST(73677.643421008557/8.0), - REAL_CONST(73699.611336682879/8.0), - REAL_CONST(73721.580889493693/8.0), - REAL_CONST(73743.552079197019/8.0), - REAL_CONST(73765.524905548999/8.0), - REAL_CONST(73787.499368305856/8.0), - REAL_CONST(73809.475467223907/8.0), - REAL_CONST(73831.453202059551/8.0), - REAL_CONST(73853.432572569291/8.0), - REAL_CONST(73875.413578509717/8.0), - REAL_CONST(73897.396219637507/8.0), - REAL_CONST(73919.380495709411/8.0), - REAL_CONST(73941.36640648231/8.0), - REAL_CONST(73963.353951713143/8.0), - REAL_CONST(73985.343131158952/8.0), - REAL_CONST(74007.333944576865/8.0), - REAL_CONST(74029.326391724098/8.0), - REAL_CONST(74051.320472357969/8.0), - REAL_CONST(74073.316186235883/8.0), - REAL_CONST(74095.313533115303/8.0), - REAL_CONST(74117.312512753837/8.0), - REAL_CONST(74139.313124909138/8.0), - REAL_CONST(74161.315369338976/8.0), - REAL_CONST(74183.319245801191/8.0), - REAL_CONST(74205.324754053727/8.0), - REAL_CONST(74227.331893854629/8.0), - REAL_CONST(74249.340664961986/8.0), - REAL_CONST(74271.351067134034/8.0), - REAL_CONST(74293.363100129049/8.0), - REAL_CONST(74315.376763705441/8.0), - REAL_CONST(74337.392057621662/8.0), - REAL_CONST(74359.408981636298/8.0), - REAL_CONST(74381.427535508003/8.0), - REAL_CONST(74403.447718995507/8.0), - REAL_CONST(74425.469531857671/8.0), - REAL_CONST(74447.492973853383/8.0), - REAL_CONST(74469.518044741693/8.0), - REAL_CONST(74491.54474428168/8.0), - REAL_CONST(74513.573072232539/8.0), - REAL_CONST(74535.603028353551/8.0), - REAL_CONST(74557.634612404087/8.0), - REAL_CONST(74579.667824143602/8.0), - REAL_CONST(74601.702663331642/8.0), - REAL_CONST(74623.739129727837/8.0), - REAL_CONST(74645.777223091936/8.0), - REAL_CONST(74667.816943183716/8.0), - REAL_CONST(74689.858289763113/8.0), - REAL_CONST(74711.901262590094/8.0), - REAL_CONST(74733.945861424741/8.0), - REAL_CONST(74755.992086027225/8.0), - REAL_CONST(74778.039936157802/8.0), - REAL_CONST(74800.089411576817/8.0), - REAL_CONST(74822.140512044702/8.0), - REAL_CONST(74844.193237321961/8.0), - REAL_CONST(74866.24758716923/8.0), - REAL_CONST(74888.303561347187/8.0), - REAL_CONST(74910.36115961663/8.0), - REAL_CONST(74932.420381738411/8.0), - REAL_CONST(74954.481227473516/8.0), - REAL_CONST(74976.543696582972/8.0), - REAL_CONST(74998.607788827925/8.0), - REAL_CONST(75020.673503969607/8.0), - REAL_CONST(75042.740841769322/8.0), - REAL_CONST(75064.809801988464/8.0), - REAL_CONST(75086.88038438854/8.0), - REAL_CONST(75108.952588731103/8.0), - REAL_CONST(75131.026414777836/8.0), - REAL_CONST(75153.101862290467/8.0), - REAL_CONST(75175.178931030852/8.0), - REAL_CONST(75197.257620760924/8.0), - REAL_CONST(75219.33793124267/8.0), - REAL_CONST(75241.419862238225/8.0), - REAL_CONST(75263.503413509738/8.0), - REAL_CONST(75285.588584819503/8.0), - REAL_CONST(75307.675375929874/8.0), - REAL_CONST(75329.763786603318/8.0), - REAL_CONST(75351.853816602365/8.0), - REAL_CONST(75373.945465689612/8.0), - REAL_CONST(75396.038733627807/8.0), - REAL_CONST(75418.133620179724/8.0), - REAL_CONST(75440.230125108254/8.0), - REAL_CONST(75462.32824817636/8.0), - REAL_CONST(75484.427989147109/8.0), - REAL_CONST(75506.529347783653/8.0), - REAL_CONST(75528.63232384919/8.0), - REAL_CONST(75550.736917107075/8.0), - REAL_CONST(75572.843127320695/8.0), - REAL_CONST(75594.950954253538/8.0), - REAL_CONST(75617.060397669193/8.0), - REAL_CONST(75639.171457331307/8.0), - REAL_CONST(75661.284133003646/8.0), - REAL_CONST(75683.398424450032/8.0), - REAL_CONST(75705.514331434402/8.0), - REAL_CONST(75727.631853720741/8.0), - REAL_CONST(75749.750991073175/8.0), - REAL_CONST(75771.871743255862/8.0), - REAL_CONST(75793.994110033076/8.0), - REAL_CONST(75816.118091169177/8.0), - REAL_CONST(75838.243686428585/8.0), - REAL_CONST(75860.370895575848/8.0), - REAL_CONST(75882.499718375562/8.0), - REAL_CONST(75904.630154592422/8.0), - REAL_CONST(75926.762203991224/8.0), - REAL_CONST(75948.895866336825/8.0), - REAL_CONST(75971.031141394182/8.0), - REAL_CONST(75993.168028928325/8.0), - REAL_CONST(76015.306528704401/8.0), - REAL_CONST(76037.4466404876/8.0), - REAL_CONST(76059.588364043215/8.0), - REAL_CONST(76081.731699136653/8.0), - REAL_CONST(76103.876645533353/8.0), - REAL_CONST(76126.023202998884/8.0), - REAL_CONST(76148.171371298871/8.0), - REAL_CONST(76170.321150199044/8.0), - REAL_CONST(76192.472539465205/8.0), - REAL_CONST(76214.625538863256/8.0), - REAL_CONST(76236.780148159174/8.0), - REAL_CONST(76258.936367119008/8.0), - REAL_CONST(76281.094195508922/8.0), - REAL_CONST(76303.253633095141/8.0), - REAL_CONST(76325.414679643975/8.0), - REAL_CONST(76347.577334921851/8.0), - REAL_CONST(76369.741598695226/8.0), - REAL_CONST(76391.907470730686/8.0), - REAL_CONST(76414.074950794879/8.0), - REAL_CONST(76436.244038654564/8.0), - REAL_CONST(76458.414734076548/8.0), - REAL_CONST(76480.587036827754/8.0), - REAL_CONST(76502.760946675175/8.0), - REAL_CONST(76524.936463385893/8.0), - REAL_CONST(76547.11358672705/8.0), - REAL_CONST(76569.292316465915/8.0), - REAL_CONST(76591.472652369819/8.0), - REAL_CONST(76613.654594206164/8.0), - REAL_CONST(76635.838141742468/8.0), - REAL_CONST(76658.023294746308/8.0), - REAL_CONST(76680.210052985349/8.0), - REAL_CONST(76702.398416227341/8.0), - REAL_CONST(76724.588384240138/8.0), - REAL_CONST(76746.779956791637/8.0), - REAL_CONST(76768.973133649866/8.0), - REAL_CONST(76791.167914582897/8.0), - REAL_CONST(76813.364299358902/8.0), - REAL_CONST(76835.562287746157/8.0), - REAL_CONST(76857.761879512967/8.0), - REAL_CONST(76879.963074427797/8.0), - REAL_CONST(76902.165872259109/8.0), - REAL_CONST(76924.37027277553/8.0), - REAL_CONST(76946.576275745727/8.0), - REAL_CONST(76968.783880938441/8.0), - REAL_CONST(76990.993088122515/8.0), - REAL_CONST(77013.203897066895/8.0), - REAL_CONST(77035.416307540567/8.0), - REAL_CONST(77057.630319312622/8.0), - REAL_CONST(77079.845932152239/8.0), - REAL_CONST(77102.063145828695/8.0), - REAL_CONST(77124.281960111301/8.0), - REAL_CONST(77146.50237476948/8.0), - REAL_CONST(77168.724389572759/8.0), - REAL_CONST(77190.948004290723/8.0), - REAL_CONST(77213.173218693031/8.0), - REAL_CONST(77235.400032549442/8.0), - REAL_CONST(77257.628445629802/8.0), - REAL_CONST(77279.858457704031/8.0), - REAL_CONST(77302.090068542122/8.0), - REAL_CONST(77324.323277914169/8.0), - REAL_CONST(77346.558085590339/8.0), - REAL_CONST(77368.794491340886/8.0), - REAL_CONST(77391.032494936138/8.0), - REAL_CONST(77413.272096146524/8.0), - REAL_CONST(77435.51329474253/8.0), - REAL_CONST(77457.756090494731/8.0), - REAL_CONST(77480.000483173804/8.0), - REAL_CONST(77502.246472550498/8.0), - REAL_CONST(77524.494058395634/8.0), - REAL_CONST(77546.743240480107/8.0), - REAL_CONST(77568.994018574944/8.0), - REAL_CONST(77591.246392451198/8.0), - REAL_CONST(77613.500361880026/8.0), - REAL_CONST(77635.755926632657/8.0), - REAL_CONST(77658.013086480438/8.0), - REAL_CONST(77680.271841194757/8.0), - REAL_CONST(77702.532190547092/8.0), - REAL_CONST(77724.794134309021/8.0), - REAL_CONST(77747.057672252195/8.0), - REAL_CONST(77769.322804148323/8.0), - REAL_CONST(77791.589529769248/8.0), - REAL_CONST(77813.857848886837/8.0), - REAL_CONST(77836.127761273063/8.0), - REAL_CONST(77858.399266699998/8.0), - REAL_CONST(77880.67236493979/8.0), - REAL_CONST(77902.947055764627/8.0), - REAL_CONST(77925.223338946831/8.0), - REAL_CONST(77947.50121425878/8.0), - REAL_CONST(77969.780681472927/8.0), - REAL_CONST(77992.061740361838/8.0), - REAL_CONST(78014.344390698127/8.0), - REAL_CONST(78036.628632254491/8.0), - REAL_CONST(78058.914464803747/8.0), - REAL_CONST(78081.201888118725/8.0), - REAL_CONST(78103.490901972415/8.0), - REAL_CONST(78125.781506137821/8.0), - REAL_CONST(78148.073700388064/8.0), - REAL_CONST(78170.367484496339/8.0), - REAL_CONST(78192.662858235926/8.0), - REAL_CONST(78214.959821380166/8.0), - REAL_CONST(78237.258373702498/8.0), - REAL_CONST(78259.558514976452/8.0), - REAL_CONST(78281.860244975614/8.0), - REAL_CONST(78304.163563473659/8.0), - REAL_CONST(78326.468470244363/8.0), - REAL_CONST(78348.77496506153/8.0), - REAL_CONST(78371.083047699125/8.0), - REAL_CONST(78393.392717931114/8.0), - REAL_CONST(78415.703975531578/8.0), - REAL_CONST(78438.016820274701/8.0), - REAL_CONST(78460.331251934695/8.0), - REAL_CONST(78482.647270285903/8.0), - REAL_CONST(78504.964875102727/8.0), - REAL_CONST(78527.284066159627/8.0), - REAL_CONST(78549.604843231195/8.0), - REAL_CONST(78571.927206092048/8.0), - REAL_CONST(78594.251154516911/8.0), - REAL_CONST(78616.576688280606/8.0), - REAL_CONST(78638.903807157985/8.0), - REAL_CONST(78661.232510924034/8.0), - REAL_CONST(78683.562799353778/8.0), - REAL_CONST(78705.894672222363/8.0), - REAL_CONST(78728.228129304945/8.0), - REAL_CONST(78750.563170376859/8.0), - REAL_CONST(78772.899795213423/8.0), - REAL_CONST(78795.238003590101/8.0), - REAL_CONST(78817.577795282399/8.0), - REAL_CONST(78839.919170065928/8.0), - REAL_CONST(78862.262127716356/8.0), - REAL_CONST(78884.606668009452/8.0), - REAL_CONST(78906.952790721043/8.0), - REAL_CONST(78929.300495627045/8.0), - REAL_CONST(78951.64978250346/8.0), - REAL_CONST(78974.000651126378/8.0), - REAL_CONST(78996.353101271932/8.0), - REAL_CONST(79018.707132716358/8.0), - REAL_CONST(79041.062745235977/8.0), - REAL_CONST(79063.41993860717/8.0), - REAL_CONST(79085.778712606436/8.0), - REAL_CONST(79108.139067010285/8.0), - REAL_CONST(79130.501001595389/8.0), - REAL_CONST(79152.864516138419/8.0), - REAL_CONST(79175.22961041618/8.0), - REAL_CONST(79197.596284205531/8.0), - REAL_CONST(79219.96453728342/8.0), - REAL_CONST(79242.33436942687/8.0), - REAL_CONST(79264.705780412987/8.0), - REAL_CONST(79287.078770018954/8.0), - REAL_CONST(79309.453338022009/8.0), - REAL_CONST(79331.829484199508/8.0), - REAL_CONST(79354.207208328866/8.0), - REAL_CONST(79376.586510187582/8.0), - REAL_CONST(79398.967389553218/8.0), - REAL_CONST(79421.349846203433/8.0), - REAL_CONST(79443.733879915948/8.0), - REAL_CONST(79466.119490468584/8.0), - REAL_CONST(79488.50667763922/8.0), - REAL_CONST(79510.895441205823/8.0), - REAL_CONST(79533.285780946433/8.0), - REAL_CONST(79555.677696639163/8.0), - REAL_CONST(79578.071188062226/8.0), - REAL_CONST(79600.466254993895/8.0), - REAL_CONST(79622.862897212515/8.0), - REAL_CONST(79645.261114496549/8.0), - REAL_CONST(79667.660906624471/8.0), - REAL_CONST(79690.062273374875/8.0), - REAL_CONST(79712.465214526455/8.0), - REAL_CONST(79734.869729857935/8.0), - REAL_CONST(79757.275819148126/8.0), - REAL_CONST(79779.683482175955/8.0), - REAL_CONST(79802.092718720378/8.0), - REAL_CONST(79824.503528560454/8.0), - REAL_CONST(79846.915911475327/8.0), - REAL_CONST(79869.329867244203/8.0), - REAL_CONST(79891.745395646343/8.0), - REAL_CONST(79914.162496461155/8.0), - REAL_CONST(79936.581169468045/8.0), - REAL_CONST(79959.001414446553/8.0), - REAL_CONST(79981.423231176261/8.0), - REAL_CONST(80003.846619436852/8.0), - REAL_CONST(80026.271579008084/8.0), - REAL_CONST(80048.698109669771/8.0), - REAL_CONST(80071.12621120183/8.0), - REAL_CONST(80093.555883384237/8.0), - REAL_CONST(80115.987125997053/8.0), - REAL_CONST(80138.419938820414/8.0), - REAL_CONST(80160.854321634528/8.0), - REAL_CONST(80183.290274219689/8.0), - REAL_CONST(80205.727796356281/8.0), - REAL_CONST(80228.166887824715/8.0), - REAL_CONST(80250.607548405547/8.0), - REAL_CONST(80273.049777879336/8.0), - REAL_CONST(80295.493576026798/8.0), - REAL_CONST(80317.938942628651/8.0), - REAL_CONST(80340.385877465727/8.0), - REAL_CONST(80362.834380318949/8.0), - REAL_CONST(80385.28445096928/8.0), - REAL_CONST(80407.736089197788/8.0), - REAL_CONST(80430.189294785596/8.0), - REAL_CONST(80452.644067513917/8.0), - REAL_CONST(80475.100407164035/8.0), - REAL_CONST(80497.558313517322/8.0), - REAL_CONST(80520.017786355209/8.0), - REAL_CONST(80542.478825459213/8.0), - REAL_CONST(80564.941430610925/8.0), - REAL_CONST(80587.405601592007/8.0), - REAL_CONST(80609.871338184195/8.0), - REAL_CONST(80632.338640169342/8.0), - REAL_CONST(80654.8075073293/8.0), - REAL_CONST(80677.277939446067/8.0), - REAL_CONST(80699.749936301683/8.0), - REAL_CONST(80722.223497678278/8.0), - REAL_CONST(80744.698623358039/8.0), - REAL_CONST(80767.17531312324/8.0), - REAL_CONST(80789.653566756242/8.0), - REAL_CONST(80812.133384039465/8.0), - REAL_CONST(80834.614764755403/8.0), - REAL_CONST(80857.097708686648/8.0), - REAL_CONST(80879.582215615854/8.0), - REAL_CONST(80902.068285325731/8.0), - REAL_CONST(80924.555917599093/8.0), - REAL_CONST(80947.045112218824/8.0), - REAL_CONST(80969.535868967869/8.0), - REAL_CONST(80992.028187629272/8.0), - REAL_CONST(81014.522067986123/8.0), - REAL_CONST(81037.017509821613/8.0), - REAL_CONST(81059.514512919006/8.0), - REAL_CONST(81082.013077061609/8.0), - REAL_CONST(81104.513202032831/8.0), - REAL_CONST(81127.014887616184/8.0), - REAL_CONST(81149.518133595193/8.0), - REAL_CONST(81172.022939753486/8.0), - REAL_CONST(81194.529305874807/8.0), - REAL_CONST(81217.037231742899/8.0), - REAL_CONST(81239.546717141639/8.0), - REAL_CONST(81262.057761854958/8.0), - REAL_CONST(81284.570365666848/8.0), - REAL_CONST(81307.084528361403/8.0), - REAL_CONST(81329.600249722775/8.0), - REAL_CONST(81352.117529535186/8.0), - REAL_CONST(81374.636367582949/8.0), - REAL_CONST(81397.156763650448/8.0), - REAL_CONST(81419.678717522125/8.0), - REAL_CONST(81442.202228982511/8.0), - REAL_CONST(81464.727297816222/8.0), - REAL_CONST(81487.253923807933/8.0), - REAL_CONST(81509.782106742379/8.0), - REAL_CONST(81532.311846404409/8.0), - REAL_CONST(81554.843142578902/8.0), - REAL_CONST(81577.375995050839/8.0), - REAL_CONST(81599.910403605274/8.0), - REAL_CONST(81622.446368027333/8.0), - REAL_CONST(81644.983888102215/8.0), - REAL_CONST(81667.522963615178/8.0), - REAL_CONST(81690.063594351581/8.0), - REAL_CONST(81712.605780096841/8.0), - REAL_CONST(81735.149520636449/8.0), - REAL_CONST(81757.694815755967/8.0), - REAL_CONST(81780.241665241047/8.0), - REAL_CONST(81802.79006887741/8.0), - REAL_CONST(81825.340026450824/8.0), - REAL_CONST(81847.891537747171/8.0), - REAL_CONST(81870.444602552379/8.0), - REAL_CONST(81892.999220652477/8.0), - REAL_CONST(81915.555391833506/8.0), - REAL_CONST(81938.113115881672/8.0), - REAL_CONST(81960.672392583176/8.0), - REAL_CONST(81983.233221724338/8.0), - REAL_CONST(82005.795603091537/8.0), - REAL_CONST(82028.359536471224/8.0), - REAL_CONST(82050.925021649906/8.0), - REAL_CONST(82073.492058414209/8.0), - REAL_CONST(82096.060646550788/8.0), - REAL_CONST(82118.630785846399/8.0), - REAL_CONST(82141.202476087841/8.0), - REAL_CONST(82163.775717062032/8.0), - REAL_CONST(82186.35050855593/8.0), - REAL_CONST(82208.926850356569/8.0), - REAL_CONST(82231.504742251054/8.0), - REAL_CONST(82254.084184026578/8.0), - REAL_CONST(82276.665175470393/8.0), - REAL_CONST(82299.24771636985/8.0), - REAL_CONST(82321.831806512317/8.0), - REAL_CONST(82344.417445685307/8.0), - REAL_CONST(82367.004633676348/8.0), - REAL_CONST(82389.593370273054/8.0), - REAL_CONST(82412.183655263143/8.0), - REAL_CONST(82434.775488434374/8.0), - REAL_CONST(82457.368869574595/8.0), - REAL_CONST(82479.963798471697/8.0), - REAL_CONST(82502.560274913689/8.0), - REAL_CONST(82525.158298688606/8.0), - REAL_CONST(82547.757869584602/8.0), - REAL_CONST(82570.35898738986/8.0), - REAL_CONST(82592.961651892678/8.0), - REAL_CONST(82615.565862881398/8.0), - REAL_CONST(82638.171620144421/8.0), - REAL_CONST(82660.778923470265/8.0), - REAL_CONST(82683.387772647475/8.0), - REAL_CONST(82705.998167464713/8.0), - REAL_CONST(82728.610107710658/8.0), - REAL_CONST(82751.223593174116/8.0), - REAL_CONST(82773.83862364394/8.0), - REAL_CONST(82796.45519890904/8.0), - REAL_CONST(82819.073318758441/8.0), - REAL_CONST(82841.692982981185/8.0), - REAL_CONST(82864.314191366429/8.0), - REAL_CONST(82886.936943703375/8.0), - REAL_CONST(82909.561239781324/8.0), - REAL_CONST(82932.187079389638/8.0), - REAL_CONST(82954.814462317736/8.0), - REAL_CONST(82977.443388355125/8.0), - REAL_CONST(83000.073857291369/8.0), - REAL_CONST(83022.70586891612/8.0), - REAL_CONST(83045.339423019104/8.0), - REAL_CONST(83067.974519390089/8.0), - REAL_CONST(83090.611157818959/8.0), - REAL_CONST(83113.249338095629/8.0), - REAL_CONST(83135.8890600101/8.0), - REAL_CONST(83158.530323352461/8.0), - REAL_CONST(83181.173127912858/8.0), - REAL_CONST(83203.817473481497/8.0), - REAL_CONST(83226.463359848669/8.0), - REAL_CONST(83249.11078680474/8.0), - REAL_CONST(83271.759754140134/8.0), - REAL_CONST(83294.410261645375/8.0), - REAL_CONST(83317.062309111003/8.0), - REAL_CONST(83339.715896327703/8.0), - REAL_CONST(83362.371023086147/8.0), - REAL_CONST(83385.027689177165/8.0), - REAL_CONST(83407.685894391587/8.0), - REAL_CONST(83430.345638520361/8.0), - REAL_CONST(83453.006921354478/8.0), - REAL_CONST(83475.669742685001/8.0), - REAL_CONST(83498.334102303095/8.0), - REAL_CONST(83520.999999999942/8.0), - REAL_CONST(83543.667435566866/8.0), - REAL_CONST(83566.336408795192/8.0), - REAL_CONST(83589.006919476349/8.0), - REAL_CONST(83611.678967401851/8.0), - REAL_CONST(83634.352552363242/8.0), - REAL_CONST(83657.027674152167/8.0), - REAL_CONST(83679.704332560359/8.0), - REAL_CONST(83702.382527379552/8.0), - REAL_CONST(83725.062258401638/8.0), - REAL_CONST(83747.743525418511/8.0), - REAL_CONST(83770.42632822218/8.0), - REAL_CONST(83793.110666604684/8.0), - REAL_CONST(83815.796540358162/8.0), - REAL_CONST(83838.483949274829/8.0), - REAL_CONST(83861.172893146941/8.0), - REAL_CONST(83883.863371766842/8.0), - REAL_CONST(83906.555384926964/8.0), - REAL_CONST(83929.248932419752/8.0), - REAL_CONST(83951.944014037799/8.0), - REAL_CONST(83974.640629573696/8.0), - REAL_CONST(83997.338778820151/8.0), - REAL_CONST(84020.038461569929/8.0), - REAL_CONST(84042.739677615857/8.0), - REAL_CONST(84065.442426750829/8.0), - REAL_CONST(84088.146708767847/8.0), - REAL_CONST(84110.852523459922/8.0), - REAL_CONST(84133.559870620171/8.0), - REAL_CONST(84156.268750041796/8.0), - REAL_CONST(84178.979161518029/8.0), - REAL_CONST(84201.691104842204/8.0), - REAL_CONST(84224.404579807713/8.0), - REAL_CONST(84247.119586208006/8.0), - REAL_CONST(84269.83612383662/8.0), - REAL_CONST(84292.55419248715/8.0), - REAL_CONST(84315.273791953281/8.0), - REAL_CONST(84337.994922028738/8.0), - REAL_CONST(84360.717582507335/8.0), - REAL_CONST(84383.441773182945/8.0), - REAL_CONST(84406.167493849513/8.0), - REAL_CONST(84428.894744301069/8.0), - REAL_CONST(84451.623524331691/8.0), - REAL_CONST(84474.353833735542/8.0), - REAL_CONST(84497.085672306828/8.0), - REAL_CONST(84519.819039839858/8.0), - REAL_CONST(84542.553936128999/8.0), - REAL_CONST(84565.290360968676/8.0), - REAL_CONST(84588.028314153402/8.0), - REAL_CONST(84610.767795477717/8.0), - REAL_CONST(84633.508804736295/8.0), - REAL_CONST(84656.251341723822/8.0), - REAL_CONST(84678.995406235073/8.0), - REAL_CONST(84701.740998064924/8.0), - REAL_CONST(84724.488117008252/8.0), - REAL_CONST(84747.236762860062/8.0), - REAL_CONST(84769.986935415407/8.0), - REAL_CONST(84792.73863446941/8.0), - REAL_CONST(84815.491859817252/8.0), - REAL_CONST(84838.246611254188/8.0), - REAL_CONST(84861.002888575575/8.0), - REAL_CONST(84883.760691576768/8.0), - REAL_CONST(84906.520020053256/8.0), - REAL_CONST(84929.28087380057/8.0), - REAL_CONST(84952.043252614312/8.0), - REAL_CONST(84974.807156290146/8.0), - REAL_CONST(84997.572584623806/8.0), - REAL_CONST(85020.339537411113/8.0), - REAL_CONST(85043.108014447949/8.0), - REAL_CONST(85065.878015530237/8.0), - REAL_CONST(85088.649540453989/8.0), - REAL_CONST(85111.422589015303/8.0), - REAL_CONST(85134.197161010321/8.0), - REAL_CONST(85156.973256235244/8.0), - REAL_CONST(85179.750874486374/8.0), - REAL_CONST(85202.530015560071/8.0), - REAL_CONST(85225.310679252725/8.0), - REAL_CONST(85248.092865360857/8.0), - REAL_CONST(85270.876573681016/8.0), - REAL_CONST(85293.661804009811/8.0), - REAL_CONST(85316.448556143951/8.0), - REAL_CONST(85339.236829880188/8.0), - REAL_CONST(85362.026625015351/8.0), - REAL_CONST(85384.817941346351/8.0), - REAL_CONST(85407.610778670132/8.0), - REAL_CONST(85430.405136783724/8.0), - REAL_CONST(85453.201015484257/8.0), - REAL_CONST(85475.998414568865/8.0), - REAL_CONST(85498.797333834795/8.0), - REAL_CONST(85521.597773079353/8.0), - REAL_CONST(85544.399732099904/8.0), - REAL_CONST(85567.203210693886/8.0), - REAL_CONST(85590.008208658808/8.0), - REAL_CONST(85612.814725792239/8.0), - REAL_CONST(85635.62276189182/8.0), - REAL_CONST(85658.432316755265/8.0), - REAL_CONST(85681.243390180331/8.0), - REAL_CONST(85704.055981964877/8.0), - REAL_CONST(85726.870091906807/8.0), - REAL_CONST(85749.685719804082/8.0), - REAL_CONST(85772.502865454764/8.0), - REAL_CONST(85795.321528656961/8.0), - REAL_CONST(85818.141709208852/8.0), - REAL_CONST(85840.963406908675/8.0), - REAL_CONST(85863.78662155474/8.0), - REAL_CONST(85886.611352945445/8.0), - REAL_CONST(85909.437600879217/8.0), - REAL_CONST(85932.26536515457/8.0), - REAL_CONST(85955.094645570091/8.0), - REAL_CONST(85977.92544192441/8.0), - REAL_CONST(86000.757754016275/8.0), - REAL_CONST(86023.591581644432/8.0), - REAL_CONST(86046.426924607746/8.0), - REAL_CONST(86069.263782705122/8.0), - REAL_CONST(86092.102155735556/8.0), - REAL_CONST(86114.942043498071/8.0), - REAL_CONST(86137.783445791807/8.0), - REAL_CONST(86160.626362415918/8.0), - REAL_CONST(86183.470793169676/8.0), - REAL_CONST(86206.316737852379/8.0), - REAL_CONST(86229.164196263402/8.0), - REAL_CONST(86252.013168202204/8.0), - REAL_CONST(86274.863653468303/8.0), - REAL_CONST(86297.715651861261/8.0), - REAL_CONST(86320.569163180728/8.0), - REAL_CONST(86343.424187226425/8.0), - REAL_CONST(86366.280723798132/8.0), - REAL_CONST(86389.138772695675/8.0), - REAL_CONST(86411.998333718977/8.0), - REAL_CONST(86434.859406668009/8.0), - REAL_CONST(86457.721991342827/8.0), - REAL_CONST(86480.586087543532/8.0), - REAL_CONST(86503.451695070296/8.0), - REAL_CONST(86526.318813723352/8.0), - REAL_CONST(86549.187443303032/8.0), - REAL_CONST(86572.057583609683/8.0), - REAL_CONST(86594.929234443756/8.0), - REAL_CONST(86617.802395605773/8.0), - REAL_CONST(86640.677066896271/8.0), - REAL_CONST(86663.553248115903/8.0), - REAL_CONST(86686.43093906538/8.0), - REAL_CONST(86709.310139545443/8.0), - REAL_CONST(86732.190849356964/8.0), - REAL_CONST(86755.073068300815/8.0), - REAL_CONST(86777.956796177954/8.0), - REAL_CONST(86800.842032789442/8.0), - REAL_CONST(86823.728777936354/8.0), - REAL_CONST(86846.617031419853/8.0), - REAL_CONST(86869.506793041175/8.0), - REAL_CONST(86892.398062601613/8.0), - REAL_CONST(86915.290839902518/8.0), - REAL_CONST(86938.185124745316/8.0), - REAL_CONST(86961.080916931489/8.0), - REAL_CONST(86983.978216262592/8.0), - REAL_CONST(87006.87702254027/8.0), - REAL_CONST(87029.777335566177/8.0), - REAL_CONST(87052.67915514209/8.0), - REAL_CONST(87075.582481069796/8.0), - REAL_CONST(87098.487313151185/8.0), - REAL_CONST(87121.39365118822/8.0), - REAL_CONST(87144.301494982894/8.0), - REAL_CONST(87167.210844337285/8.0), - REAL_CONST(87190.121699053532/8.0), - REAL_CONST(87213.034058933845/8.0), - REAL_CONST(87235.947923780506/8.0), - REAL_CONST(87258.863293395829/8.0), - REAL_CONST(87281.780167582241/8.0), - REAL_CONST(87304.698546142172/8.0), - REAL_CONST(87327.618428878181/8.0), - REAL_CONST(87350.539815592856/8.0), - REAL_CONST(87373.462706088845/8.0), - REAL_CONST(87396.387100168897/8.0), - REAL_CONST(87419.312997635774/8.0), - REAL_CONST(87442.240398292357/8.0), - REAL_CONST(87465.16930194154/8.0), - REAL_CONST(87488.099708386319/8.0), - REAL_CONST(87511.031617429733/8.0), - REAL_CONST(87533.965028874911/8.0), - REAL_CONST(87556.899942525008/8.0), - REAL_CONST(87579.836358183282/8.0), - REAL_CONST(87602.774275653021/8.0), - REAL_CONST(87625.713694737613/8.0), - REAL_CONST(87648.654615240492/8.0), - REAL_CONST(87671.597036965148/8.0), - REAL_CONST(87694.540959715145/8.0), - REAL_CONST(87717.486383294105/8.0), - REAL_CONST(87740.433307505737/8.0), - REAL_CONST(87763.381732153779/8.0), - REAL_CONST(87786.331657042057/8.0), - REAL_CONST(87809.283081974456/8.0), - REAL_CONST(87832.236006754916/8.0), - REAL_CONST(87855.190431187453/8.0), - REAL_CONST(87878.146355076155/8.0), - REAL_CONST(87901.103778225151/8.0), - REAL_CONST(87924.062700438633/8.0), - REAL_CONST(87947.023121520891/8.0), - REAL_CONST(87969.985041276246/8.0), - REAL_CONST(87992.948459509105/8.0), - REAL_CONST(88015.913376023906/8.0), - REAL_CONST(88038.879790625171/8.0), - REAL_CONST(88061.847703117513/8.0), - REAL_CONST(88084.817113305573/8.0), - REAL_CONST(88107.788020994049/8.0), - REAL_CONST(88130.760425987726/8.0), - REAL_CONST(88153.734328091465/8.0), - REAL_CONST(88176.709727110137/8.0), - REAL_CONST(88199.686622848749/8.0), - REAL_CONST(88222.665015112303/8.0), - REAL_CONST(88245.644903705906/8.0), - REAL_CONST(88268.626288434709/8.0), - REAL_CONST(88291.609169103947/8.0), - REAL_CONST(88314.593545518903/8.0), - REAL_CONST(88337.579417484914/8.0), - REAL_CONST(88360.566784807408/8.0), - REAL_CONST(88383.555647291854/8.0), - REAL_CONST(88406.546004743795/8.0), - REAL_CONST(88429.537856968818/8.0), - REAL_CONST(88452.531203772611/8.0), - REAL_CONST(88475.52604496089/8.0), - REAL_CONST(88498.522380339447/8.0), - REAL_CONST(88521.52020971413/8.0), - REAL_CONST(88544.519532890874/8.0), - REAL_CONST(88567.520349675644/8.0), - REAL_CONST(88590.522659874507/8.0), - REAL_CONST(88613.526463293543/8.0), - REAL_CONST(88636.531759738922/8.0), - REAL_CONST(88659.538549016899/8.0), - REAL_CONST(88682.546830933745/8.0), - REAL_CONST(88705.556605295846/8.0), - REAL_CONST(88728.567871909589/8.0), - REAL_CONST(88751.580630581491/8.0), - REAL_CONST(88774.594881118086/8.0), - REAL_CONST(88797.610623325963/8.0), - REAL_CONST(88820.62785701183/8.0), - REAL_CONST(88843.646581982393/8.0), - REAL_CONST(88866.666798044462/8.0), - REAL_CONST(88889.688505004888/8.0), - REAL_CONST(88912.711702670611/8.0), - REAL_CONST(88935.7363908486/8.0), - REAL_CONST(88958.762569345898/8.0), - REAL_CONST(88981.790237969632/8.0), - REAL_CONST(89004.81939652696/8.0), - REAL_CONST(89027.850044825114/8.0), - REAL_CONST(89050.882182671412/8.0), - REAL_CONST(89073.9158098732/8.0), - REAL_CONST(89096.950926237885/8.0), - REAL_CONST(89119.987531572973/8.0), - REAL_CONST(89143.025625686001/8.0), - REAL_CONST(89166.065208384563/8.0), - REAL_CONST(89189.106279476357/8.0), - REAL_CONST(89212.148838769106/8.0), - REAL_CONST(89235.192886070581/8.0), - REAL_CONST(89258.238421188667/8.0), - REAL_CONST(89281.285443931265/8.0), - REAL_CONST(89304.333954106376/8.0), - REAL_CONST(89327.383951522017/8.0), - REAL_CONST(89350.435435986306/8.0), - REAL_CONST(89373.488407307406/8.0), - REAL_CONST(89396.542865293537/8.0), - REAL_CONST(89419.598809753006/8.0), - REAL_CONST(89442.656240494165/8.0), - REAL_CONST(89465.715157325409/8.0), - REAL_CONST(89488.775560055219/8.0), - REAL_CONST(89511.837448492137/8.0), - REAL_CONST(89534.900822444746/8.0), - REAL_CONST(89557.965681721733/8.0), - REAL_CONST(89581.032026131812/8.0), - REAL_CONST(89604.099855483742/8.0), - REAL_CONST(89627.169169586399/8.0), - REAL_CONST(89650.239968248672/8.0), - REAL_CONST(89673.312251279538/8.0), - REAL_CONST(89696.386018488018/8.0), - REAL_CONST(89719.461269683205/8.0), - REAL_CONST(89742.53800467425/8.0), - REAL_CONST(89765.616223270365/8.0), - REAL_CONST(89788.69592528083/8.0), - REAL_CONST(89811.777110514988/8.0), - REAL_CONST(89834.859778782207/8.0), - REAL_CONST(89857.943929891975/8.0), - REAL_CONST(89881.029563653807/8.0), - REAL_CONST(89904.116679877261/8.0), - REAL_CONST(89927.205278372014/8.0), - REAL_CONST(89950.29535894774/8.0), - REAL_CONST(89973.386921414218/8.0), - REAL_CONST(89996.479965581268/8.0), - REAL_CONST(90019.574491258769/8.0), - REAL_CONST(90042.670498256688/8.0), - REAL_CONST(90065.767986385021/8.0), - REAL_CONST(90088.866955453836/8.0), - REAL_CONST(90111.967405273259/8.0), - REAL_CONST(90135.069335653476/8.0), - REAL_CONST(90158.172746404758/8.0), - REAL_CONST(90181.277637337407/8.0), - REAL_CONST(90204.384008261797/8.0), - REAL_CONST(90227.49185898836/8.0), - REAL_CONST(90250.601189327586/8.0), - REAL_CONST(90273.711999090039/8.0), - REAL_CONST(90296.824288086325/8.0), - REAL_CONST(90319.938056127125/8.0), - REAL_CONST(90343.053303023189/8.0), - REAL_CONST(90366.170028585286/8.0), - REAL_CONST(90389.288232624298/8.0), - REAL_CONST(90412.407914951138/8.0), - REAL_CONST(90435.529075376777/8.0), - REAL_CONST(90458.651713712257/8.0), - REAL_CONST(90481.775829768681/8.0), - REAL_CONST(90504.901423357209/8.0), - REAL_CONST(90528.028494289058/8.0), - REAL_CONST(90551.157042375504/8.0), - REAL_CONST(90574.287067427911/8.0), - REAL_CONST(90597.418569257643/8.0), - REAL_CONST(90620.551547676194/8.0), - REAL_CONST(90643.686002495073/8.0), - REAL_CONST(90666.821933525847/8.0), - REAL_CONST(90689.959340580186/8.0), - REAL_CONST(90713.098223469773/8.0), - REAL_CONST(90736.238582006365/8.0), - REAL_CONST(90759.380416001804/8.0), - REAL_CONST(90782.523725267951/8.0), - REAL_CONST(90805.668509616764/8.0), - REAL_CONST(90828.814768860233/8.0), - REAL_CONST(90851.962502810435/8.0), - REAL_CONST(90875.11171127946/8.0), - REAL_CONST(90898.262394079517/8.0), - REAL_CONST(90921.414551022855/8.0), - REAL_CONST(90944.568181921743/8.0), - REAL_CONST(90967.72328658856/8.0), - REAL_CONST(90990.879864835719/8.0), - REAL_CONST(91014.037916475718/8.0), - REAL_CONST(91037.19744132107/8.0), - REAL_CONST(91060.358439184391/8.0), - REAL_CONST(91083.520909878338/8.0), - REAL_CONST(91106.684853215629/8.0), - REAL_CONST(91129.850269009039/8.0), - REAL_CONST(91153.017157071401/8.0), - REAL_CONST(91176.185517215621/8.0), - REAL_CONST(91199.355349254649/8.0), - REAL_CONST(91222.526653001492/8.0), - REAL_CONST(91245.699428269247/8.0), - REAL_CONST(91268.873674871036/8.0), - REAL_CONST(91292.049392620058/8.0), - REAL_CONST(91315.226581329553/8.0), - REAL_CONST(91338.405240812834/8.0), - REAL_CONST(91361.585370883287/8.0), - REAL_CONST(91384.766971354344/8.0), - REAL_CONST(91407.950042039476/8.0), - REAL_CONST(91431.134582752245/8.0), - REAL_CONST(91454.320593306256/8.0), - REAL_CONST(91477.508073515171/8.0), - REAL_CONST(91500.697023192712/8.0), - REAL_CONST(91523.887442152685/8.0), - REAL_CONST(91547.07933020893/8.0), - REAL_CONST(91570.272687175326/8.0), - REAL_CONST(91593.467512865856/8.0), - REAL_CONST(91616.663807094534/8.0), - REAL_CONST(91639.861569675442/8.0), - REAL_CONST(91663.060800422725/8.0), - REAL_CONST(91686.261499150554/8.0), - REAL_CONST(91709.463665673218/8.0), - REAL_CONST(91732.66729980502/8.0), - REAL_CONST(91755.872401360321/8.0), - REAL_CONST(91779.078970153569/8.0), - REAL_CONST(91802.287005999257/8.0), - REAL_CONST(91825.49650871192/8.0), - REAL_CONST(91848.707478106167/8.0), - REAL_CONST(91871.91991399668/8.0), - REAL_CONST(91895.133816198169/8.0), - REAL_CONST(91918.349184525418/8.0), - REAL_CONST(91941.566018793281/8.0), - REAL_CONST(91964.784318816659/8.0), - REAL_CONST(91988.004084410495/8.0), - REAL_CONST(92011.22531538982/8.0), - REAL_CONST(92034.448011569708/8.0), - REAL_CONST(92057.672172765277/8.0), - REAL_CONST(92080.897798791746/8.0), - REAL_CONST(92104.124889464365/8.0), - REAL_CONST(92127.353444598411/8.0), - REAL_CONST(92150.58346400928/8.0), - REAL_CONST(92173.814947512379/8.0), - REAL_CONST(92197.04789492322/8.0), - REAL_CONST(92220.282306057314/8.0), - REAL_CONST(92243.518180730272/8.0), - REAL_CONST(92266.755518757753/8.0), - REAL_CONST(92289.994319955469/8.0), - REAL_CONST(92313.234584139194/8.0), - REAL_CONST(92336.476311124774/8.0), - REAL_CONST(92359.719500728082/8.0), - REAL_CONST(92382.964152765067/8.0), - REAL_CONST(92406.210267051734/8.0), - REAL_CONST(92429.457843404161/8.0), - REAL_CONST(92452.706881638471/8.0), - REAL_CONST(92475.957381570814/8.0), - REAL_CONST(92499.209343017443/8.0), - REAL_CONST(92522.462765794655/8.0), - REAL_CONST(92545.717649718805/8.0), - REAL_CONST(92568.973994606305/8.0), - REAL_CONST(92592.231800273614/8.0), - REAL_CONST(92615.491066537259/8.0), - REAL_CONST(92638.751793213814/8.0), - REAL_CONST(92662.01398011994/8.0), - REAL_CONST(92685.277627072326/8.0), - REAL_CONST(92708.54273388772/8.0), - REAL_CONST(92731.809300382942/8.0), - REAL_CONST(92755.077326374871/8.0), - REAL_CONST(92778.346811680414/8.0), - REAL_CONST(92801.617756116568/8.0), - REAL_CONST(92824.890159500384/8.0), - REAL_CONST(92848.164021648947/8.0), - REAL_CONST(92871.439342379424/8.0), - REAL_CONST(92894.716121509016/8.0), - REAL_CONST(92917.994358855023/8.0), - REAL_CONST(92941.274054234746/8.0), - REAL_CONST(92964.555207465572/8.0), - REAL_CONST(92987.837818364962/8.0), - REAL_CONST(93011.121886750407/8.0), - REAL_CONST(93034.407412439468/8.0), - REAL_CONST(93057.694395249753/8.0), - REAL_CONST(93080.982834998955/8.0), - REAL_CONST(93104.272731504767/8.0), - REAL_CONST(93127.564084584999/8.0), - REAL_CONST(93150.856894057491/8.0), - REAL_CONST(93174.15115974014/8.0), - REAL_CONST(93197.446881450916/8.0), - REAL_CONST(93220.744059007804/8.0), - REAL_CONST(93244.04269222889/8.0), - REAL_CONST(93267.342780932304/8.0), - REAL_CONST(93290.644324936235/8.0), - REAL_CONST(93313.947324058914/8.0), - REAL_CONST(93337.251778118633/8.0), - REAL_CONST(93360.557686933767/8.0), - REAL_CONST(93383.865050322696/8.0), - REAL_CONST(93407.173868103928/8.0), - REAL_CONST(93430.484140095941/8.0), - REAL_CONST(93453.795866117362/8.0), - REAL_CONST(93477.109045986799/8.0), - REAL_CONST(93500.423679522952/8.0), - REAL_CONST(93523.739766544561/8.0), - REAL_CONST(93547.057306870454/8.0), - REAL_CONST(93570.376300319491/8.0), - REAL_CONST(93593.696746710571/8.0), - REAL_CONST(93617.018645862699/8.0), - REAL_CONST(93640.341997594893/8.0), - REAL_CONST(93663.666801726242/8.0), - REAL_CONST(93686.993058075881/8.0), - REAL_CONST(93710.320766463032/8.0), - REAL_CONST(93733.64992670693/8.0), - REAL_CONST(93756.980538626914/8.0), - REAL_CONST(93780.312602042337/8.0), - REAL_CONST(93803.646116772637/8.0), - REAL_CONST(93826.981082637285/8.0), - REAL_CONST(93850.317499455836/8.0), - REAL_CONST(93873.655367047861/8.0), - REAL_CONST(93896.994685233032/8.0), - REAL_CONST(93920.335453831038/8.0), - REAL_CONST(93943.677672661666/8.0), - REAL_CONST(93967.021341544707/8.0), - REAL_CONST(93990.366460300051/8.0), - REAL_CONST(94013.713028747632/8.0), - REAL_CONST(94037.061046707429/8.0), - REAL_CONST(94060.410513999494/8.0), - REAL_CONST(94083.761430443905/8.0), - REAL_CONST(94107.113795860845/8.0), - REAL_CONST(94130.467610070496/8.0), - REAL_CONST(94153.822872893157/8.0), - REAL_CONST(94177.179584149111/8.0), - REAL_CONST(94200.537743658759/8.0), - REAL_CONST(94223.897351242529/8.0), - REAL_CONST(94247.25840672091/8.0), - REAL_CONST(94270.620909914433/8.0), - REAL_CONST(94293.98486064373/8.0), - REAL_CONST(94317.350258729421/8.0), - REAL_CONST(94340.71710399224/8.0), - REAL_CONST(94364.085396252936/8.0), - REAL_CONST(94387.455135332348/8.0), - REAL_CONST(94410.82632105134/8.0), - REAL_CONST(94434.198953230851/8.0), - REAL_CONST(94457.573031691878/8.0), - REAL_CONST(94480.948556255447/8.0), - REAL_CONST(94504.325526742658/8.0), - REAL_CONST(94527.70394297468/8.0), - REAL_CONST(94551.083804772716/8.0), - REAL_CONST(94574.465111958023/8.0), - REAL_CONST(94597.847864351934/8.0), - REAL_CONST(94621.232061775823/8.0), - REAL_CONST(94644.617704051096/8.0), - REAL_CONST(94668.004790999272/8.0), - REAL_CONST(94691.393322441872/8.0), - REAL_CONST(94714.783298200506/8.0), - REAL_CONST(94738.174718096794/8.0), - REAL_CONST(94761.567581952477/8.0), - REAL_CONST(94784.961889589307/8.0), - REAL_CONST(94808.357640829097/8.0), - REAL_CONST(94831.754835493703/8.0), - REAL_CONST(94855.153473405066/8.0), - REAL_CONST(94878.553554385173/8.0), - REAL_CONST(94901.955078256055/8.0), - REAL_CONST(94925.358044839784/8.0), - REAL_CONST(94948.762453958523/8.0), - REAL_CONST(94972.168305434476/8.0), - REAL_CONST(94995.575599089891/8.0), - REAL_CONST(95018.984334747074/8.0), - REAL_CONST(95042.394512228391/8.0), - REAL_CONST(95065.806131356265/8.0), - REAL_CONST(95089.219191953176/8.0), - REAL_CONST(95112.633693841635/8.0), - REAL_CONST(95136.04963684424/8.0), - REAL_CONST(95159.467020783617/8.0), - REAL_CONST(95182.885845482466/8.0), - REAL_CONST(95206.306110763529/8.0), - REAL_CONST(95229.727816449609/8.0), - REAL_CONST(95253.150962363579/8.0), - REAL_CONST(95276.575548328314/8.0), - REAL_CONST(95300.001574166803/8.0), - REAL_CONST(95323.429039702052/8.0), - REAL_CONST(95346.857944757154/8.0), - REAL_CONST(95370.288289155214/8.0), - REAL_CONST(95393.720072719429/8.0), - REAL_CONST(95417.153295273019/8.0), - REAL_CONST(95440.587956639298/8.0), - REAL_CONST(95464.024056641589/8.0), - REAL_CONST(95487.461595103305/8.0), - REAL_CONST(95510.900571847902/8.0), - REAL_CONST(95534.340986698866/8.0), - REAL_CONST(95557.782839479783/8.0), - REAL_CONST(95581.226130014256/8.0), - REAL_CONST(95604.670858125959/8.0), - REAL_CONST(95628.117023638595/8.0), - REAL_CONST(95651.564626375985/8.0), - REAL_CONST(95675.013666161918/8.0), - REAL_CONST(95698.464142820303/8.0), - REAL_CONST(95721.916056175076/8.0), - REAL_CONST(95745.369406050231/8.0), - REAL_CONST(95768.824192269807/8.0), - REAL_CONST(95792.280414657915/8.0), - REAL_CONST(95815.738073038709/8.0), - REAL_CONST(95839.197167236387/8.0), - REAL_CONST(95862.657697075221/8.0), - REAL_CONST(95886.11966237954/8.0), - REAL_CONST(95909.583062973688/8.0), - REAL_CONST(95933.047898682111/8.0), - REAL_CONST(95956.514169329268/8.0), - REAL_CONST(95979.981874739708/8.0), - REAL_CONST(96003.451014738006/8.0), - REAL_CONST(96026.921589148798/8.0), - REAL_CONST(96050.393597796792/8.0), - REAL_CONST(96073.867040506724/8.0), - REAL_CONST(96097.341917103375/8.0), - REAL_CONST(96120.818227411626/8.0), - REAL_CONST(96144.295971256375/8.0), - REAL_CONST(96167.775148462577/8.0), - REAL_CONST(96191.255758855244/8.0), - REAL_CONST(96214.737802259449/8.0), - REAL_CONST(96238.221278500292/8.0), - REAL_CONST(96261.70618740299/8.0), - REAL_CONST(96285.192528792715/8.0), - REAL_CONST(96308.680302494788/8.0), - REAL_CONST(96332.169508334526/8.0), - REAL_CONST(96355.660146137321/8.0), - REAL_CONST(96379.152215728609/8.0), - REAL_CONST(96402.645716933868/8.0), - REAL_CONST(96426.14064957868/8.0), - REAL_CONST(96449.637013488609/8.0), - REAL_CONST(96473.134808489311/8.0), - REAL_CONST(96496.63403440651/8.0), - REAL_CONST(96520.134691065963/8.0), - REAL_CONST(96543.636778293469/8.0), - REAL_CONST(96567.140295914898/8.0), - REAL_CONST(96590.645243756153/8.0), - REAL_CONST(96614.151621643221/8.0), - REAL_CONST(96637.659429402134/8.0), - REAL_CONST(96661.168666858954/8.0), - REAL_CONST(96684.679333839798/8.0), - REAL_CONST(96708.191430170875/8.0), - REAL_CONST(96731.70495567839/8.0), - REAL_CONST(96755.219910188665/8.0), - REAL_CONST(96778.736293528011/8.0), - REAL_CONST(96802.254105522836/8.0), - REAL_CONST(96825.77334599958/8.0), - REAL_CONST(96849.29401478474/8.0), - REAL_CONST(96872.816111704873/8.0), - REAL_CONST(96896.339636586577/8.0), - REAL_CONST(96919.864589256511/8.0), - REAL_CONST(96943.390969541389/8.0), - REAL_CONST(96966.918777267958/8.0), - REAL_CONST(96990.448012263048/8.0), - REAL_CONST(97013.978674353522/8.0), - REAL_CONST(97037.510763366285/8.0), - REAL_CONST(97061.044279128328/8.0), - REAL_CONST(97084.579221466673/8.0), - REAL_CONST(97108.115590208385/8.0), - REAL_CONST(97131.653385180587/8.0), - REAL_CONST(97155.19260621049/8.0), - REAL_CONST(97178.733253125291/8.0), - REAL_CONST(97202.2753257523/8.0), - REAL_CONST(97225.81882391886/8.0), - REAL_CONST(97249.363747452342/8.0), - REAL_CONST(97272.910096180189/8.0), - REAL_CONST(97296.457869929916/8.0), - REAL_CONST(97320.007068529041/8.0), - REAL_CONST(97343.557691805196/8.0), - REAL_CONST(97367.109739586012/8.0), - REAL_CONST(97390.663211699197/8.0), - REAL_CONST(97414.218107972498/8.0), - REAL_CONST(97437.774428233737/8.0), - REAL_CONST(97461.332172310766/8.0), - REAL_CONST(97484.891340031507/8.0), - REAL_CONST(97508.451931223899/8.0), - REAL_CONST(97532.013945715982/8.0), - REAL_CONST(97555.577383335811/8.0), - REAL_CONST(97579.142243911512/8.0), - REAL_CONST(97602.708527271257/8.0), - REAL_CONST(97626.276233243261/8.0), - REAL_CONST(97649.845361655811/8.0), - REAL_CONST(97673.415912337223/8.0), - REAL_CONST(97696.987885115886/8.0), - REAL_CONST(97720.561279820206/8.0), - REAL_CONST(97744.1360962787/8.0), - REAL_CONST(97767.712334319876/8.0), - REAL_CONST(97791.289993772341/8.0), - REAL_CONST(97814.869074464703/8.0), - REAL_CONST(97838.449576225685/8.0), - REAL_CONST(97862.031498883996/8.0), - REAL_CONST(97885.614842268449/8.0), - REAL_CONST(97909.199606207883/8.0), - REAL_CONST(97932.785790531183/8.0), - REAL_CONST(97956.37339506732/8.0), - REAL_CONST(97979.962419645264/8.0), - REAL_CONST(98003.552864094076/8.0), - REAL_CONST(98027.144728242856/8.0), - REAL_CONST(98050.738011920766/8.0), - REAL_CONST(98074.332714956996/8.0), - REAL_CONST(98097.928837180807/8.0), - REAL_CONST(98121.526378421506/8.0), - REAL_CONST(98145.125338508456/8.0), - REAL_CONST(98168.725717271067/8.0), - REAL_CONST(98192.327514538789/8.0), - REAL_CONST(98215.930730141132/8.0), - REAL_CONST(98239.535363907664/8.0), - REAL_CONST(98263.141415668011/8.0), - REAL_CONST(98286.748885251814/8.0), - REAL_CONST(98310.357772488816/8.0), - REAL_CONST(98333.968077208759/8.0), - REAL_CONST(98357.579799241488/8.0), - REAL_CONST(98381.192938416847/8.0), - REAL_CONST(98404.807494564782/8.0), - REAL_CONST(98428.42346751524/8.0), - REAL_CONST(98452.040857098269/8.0), - REAL_CONST(98475.659663143917/8.0), - REAL_CONST(98499.27988548232/8.0), - REAL_CONST(98522.901523943656/8.0), - REAL_CONST(98546.524578358163/8.0), - REAL_CONST(98570.149048556093/8.0), - REAL_CONST(98593.774934367786/8.0), - REAL_CONST(98617.402235623624/8.0), - REAL_CONST(98641.030952154048/8.0), - REAL_CONST(98664.661083789513/8.0), - REAL_CONST(98688.292630360564/8.0), - REAL_CONST(98711.925591697771/8.0), - REAL_CONST(98735.559967631794/8.0), - REAL_CONST(98759.195757993293/8.0), - REAL_CONST(98782.832962613014/8.0), - REAL_CONST(98806.471581321734/8.0), - REAL_CONST(98830.111613950285/8.0), - REAL_CONST(98853.753060329575/8.0), - REAL_CONST(98877.39592029051/8.0), - REAL_CONST(98901.040193664099/8.0), - REAL_CONST(98924.68588028138/8.0), - REAL_CONST(98948.33297997342/8.0), - REAL_CONST(98971.981492571387/8.0), - REAL_CONST(98995.63141790645/8.0), - REAL_CONST(99019.282755809851/8.0), - REAL_CONST(99042.935506112874/8.0), - REAL_CONST(99066.589668646877/8.0), - REAL_CONST(99090.245243243233/8.0), - REAL_CONST(99113.902229733401/8.0), - REAL_CONST(99137.560627948857/8.0), - REAL_CONST(99161.220437721131/8.0), - REAL_CONST(99184.881658881859/8.0), - REAL_CONST(99208.544291262631/8.0), - REAL_CONST(99232.208334695169/8.0), - REAL_CONST(99255.87378901121/8.0), - REAL_CONST(99279.540654042547/8.0), - REAL_CONST(99303.208929621018/8.0), - REAL_CONST(99326.878615578535/8.0), - REAL_CONST(99350.549711746993/8.0), - REAL_CONST(99374.222217958435/8.0), - REAL_CONST(99397.896134044888/8.0), - REAL_CONST(99421.571459838422/8.0), - REAL_CONST(99445.248195171211/8.0), - REAL_CONST(99468.926339875441/8.0), - REAL_CONST(99492.605893783344/8.0), - REAL_CONST(99516.286856727209/8.0), - REAL_CONST(99539.969228539398/8.0), - REAL_CONST(99563.653009052287/8.0), - REAL_CONST(99587.338198098325/8.0), - REAL_CONST(99611.024795510006/8.0), - REAL_CONST(99634.712801119866/8.0), - REAL_CONST(99658.402214760499/8.0), - REAL_CONST(99682.093036264545/8.0), - REAL_CONST(99705.785265464699/8.0), - REAL_CONST(99729.478902193689/8.0), - REAL_CONST(99753.173946284325/8.0), - REAL_CONST(99776.870397569437/8.0), - REAL_CONST(99800.56825588191/8.0), - REAL_CONST(99824.267521054688/8.0), - REAL_CONST(99847.968192920773/8.0), - REAL_CONST(99871.670271313182/8.0), - REAL_CONST(99895.373756065004/8.0), - REAL_CONST(99919.078647009388/8.0), - REAL_CONST(99942.78494397951/8.0), - REAL_CONST(99966.492646808634/8.0), - REAL_CONST(99990.20175533001/8.0), - REAL_CONST(100013.91226937699/8.0), - REAL_CONST(100037.62418878295/8.0), - REAL_CONST(100061.33751338134/8.0), - REAL_CONST(100085.05224300563/8.0), - REAL_CONST(100108.76837748935/8.0), - REAL_CONST(100132.4859166661/8.0), - REAL_CONST(100156.2048603695/8.0), - REAL_CONST(100179.92520843323/8.0), - REAL_CONST(100203.64696069101/8.0), - REAL_CONST(100227.37011697664/8.0), - REAL_CONST(100251.09467712394/8.0), - REAL_CONST(100274.82064096678/8.0), - REAL_CONST(100298.54800833909/8.0), - REAL_CONST(100322.27677907483/8.0), - REAL_CONST(100346.00695300807/8.0), - REAL_CONST(100369.73852997283/8.0), - REAL_CONST(100393.47150980328/8.0), - REAL_CONST(100417.20589233354/8.0), - REAL_CONST(100440.94167739789/8.0), - REAL_CONST(100464.67886483055/8.0), - REAL_CONST(100488.41745446586/8.0), - REAL_CONST(100512.1574461382/8.0), - REAL_CONST(100535.89883968196/8.0), - REAL_CONST(100559.64163493161/8.0), - REAL_CONST(100583.38583172169/8.0), - REAL_CONST(100607.13142988674/8.0), - REAL_CONST(100630.87842926137/8.0), - REAL_CONST(100654.62682968024/8.0), - REAL_CONST(100678.37663097809/8.0), - REAL_CONST(100702.12783298964/8.0), - REAL_CONST(100725.88043554971/8.0), - REAL_CONST(100749.63443849317/8.0), - REAL_CONST(100773.38984165489/8.0), - REAL_CONST(100797.14664486986/8.0), - REAL_CONST(100820.90484797307/8.0), - REAL_CONST(100844.66445079957/8.0), - REAL_CONST(100868.42545318443/8.0), - REAL_CONST(100892.18785496285/8.0), - REAL_CONST(100915.95165596998/8.0), - REAL_CONST(100939.71685604109/8.0), - REAL_CONST(100963.48345501146/8.0), - REAL_CONST(100987.25145271645/8.0), - REAL_CONST(101011.02084899142/8.0), - REAL_CONST(101034.79164367182/8.0), - REAL_CONST(101058.56383659317/8.0), - REAL_CONST(101082.33742759094/8.0), - REAL_CONST(101106.11241650078/8.0), - REAL_CONST(101129.88880315828/8.0), - REAL_CONST(101153.66658739912/8.0), - REAL_CONST(101177.44576905905/8.0), - REAL_CONST(101201.22634797383/8.0), - REAL_CONST(101225.00832397929/8.0), - REAL_CONST(101248.7916969113/8.0), - REAL_CONST(101272.57646660579/8.0), - REAL_CONST(101296.36263289873/8.0), - REAL_CONST(101320.15019562612/8.0), - REAL_CONST(101343.93915462404/8.0), - REAL_CONST(101367.7295097286/8.0), - REAL_CONST(101391.52126077596/8.0), - REAL_CONST(101415.31440760233/8.0), - REAL_CONST(101439.10895004397/8.0), - REAL_CONST(101462.9048879372/8.0), - REAL_CONST(101486.70222111834/8.0), - REAL_CONST(101510.50094942382/8.0), - REAL_CONST(101534.30107269008/8.0), - REAL_CONST(101558.10259075361/8.0), - REAL_CONST(101581.90550345098/8.0), - REAL_CONST(101605.70981061876/8.0), - REAL_CONST(101629.5155120936/8.0), - REAL_CONST(101653.32260771218/8.0), - REAL_CONST(101677.13109731126/8.0), - REAL_CONST(101700.9409807276/8.0), - REAL_CONST(101724.75225779804/8.0), - REAL_CONST(101748.56492835947/8.0), - REAL_CONST(101772.37899224881/8.0), - REAL_CONST(101796.19444930303/8.0), - REAL_CONST(101820.01129935916/8.0), - REAL_CONST(101843.82954225427/8.0), - REAL_CONST(101867.64917782549/8.0), - REAL_CONST(101891.47020590997/8.0), - REAL_CONST(101915.29262634492/8.0), - REAL_CONST(101939.11643896763/8.0), - REAL_CONST(101962.94164361537/8.0), - REAL_CONST(101986.76824012553/8.0), - REAL_CONST(102010.59622833549/8.0), - REAL_CONST(102034.42560808272/8.0), - REAL_CONST(102058.25637920471/8.0), - REAL_CONST(102082.08854153901/8.0), - REAL_CONST(102105.9220949232/8.0), - REAL_CONST(102129.75703919494/8.0), - REAL_CONST(102153.59337419191/8.0), - REAL_CONST(102177.43109975185/8.0), - REAL_CONST(102201.27021571253/8.0), - REAL_CONST(102225.1107219118/8.0), - REAL_CONST(102248.95261818753/8.0), - REAL_CONST(102272.79590437764/8.0), - REAL_CONST(102296.64058032009/8.0), - REAL_CONST(102320.48664585294/8.0), - REAL_CONST(102344.33410081422/8.0), - REAL_CONST(102368.18294504205/8.0), - REAL_CONST(102392.03317837461/8.0), - REAL_CONST(102415.88480065008/8.0), - REAL_CONST(102439.73781170673/8.0), - REAL_CONST(102463.59221138287/8.0), - REAL_CONST(102487.44799951684/8.0), - REAL_CONST(102511.30517594704/8.0), - REAL_CONST(102535.1637405119/8.0), - REAL_CONST(102559.02369304992/8.0), - REAL_CONST(102582.88503339965/8.0), - REAL_CONST(102606.74776139967/8.0), - REAL_CONST(102630.61187688859/8.0), - REAL_CONST(102654.4773797051/8.0), - REAL_CONST(102678.34426968795/8.0), - REAL_CONST(102702.21254667587/8.0), - REAL_CONST(102726.08221050771/8.0), - REAL_CONST(102749.95326102231/8.0), - REAL_CONST(102773.8256980586/8.0), - REAL_CONST(102797.69952145554/8.0), - REAL_CONST(102821.57473105213/8.0), - REAL_CONST(102845.45132668741/8.0), - REAL_CONST(102869.32930820051/8.0), - REAL_CONST(102893.20867543056/8.0), - REAL_CONST(102917.08942821674/8.0), - REAL_CONST(102940.97156639832/8.0), - REAL_CONST(102964.85508981455/8.0), - REAL_CONST(102988.73999830478/8.0), - REAL_CONST(103012.6262917084/8.0), - REAL_CONST(103036.51396986481/8.0), - REAL_CONST(103060.40303261351/8.0), - REAL_CONST(103084.293479794/8.0), - REAL_CONST(103108.18531124585/8.0), - REAL_CONST(103132.07852680866/8.0), - REAL_CONST(103155.97312632212/8.0), - REAL_CONST(103179.8691096259/8.0), - REAL_CONST(103203.76647655977/8.0), - REAL_CONST(103227.66522696352/8.0), - REAL_CONST(103251.56536067701/8.0), - REAL_CONST(103275.46687754011/8.0), - REAL_CONST(103299.36977739276/8.0), - REAL_CONST(103323.27406007495/8.0), - REAL_CONST(103347.1797254267/8.0), - REAL_CONST(103371.0867732881/8.0), - REAL_CONST(103394.99520349925/8.0), - REAL_CONST(103418.90501590034/8.0), - REAL_CONST(103442.81621033157/8.0), - REAL_CONST(103466.72878663319/8.0), - REAL_CONST(103490.64274464553/8.0), - REAL_CONST(103514.55808420894/8.0), - REAL_CONST(103538.4748051638/8.0), - REAL_CONST(103562.39290735057/8.0), - REAL_CONST(103586.31239060973/8.0), - REAL_CONST(103610.23325478184/8.0), - REAL_CONST(103634.15549970744/8.0), - REAL_CONST(103658.07912522719/8.0), - REAL_CONST(103682.00413118176/8.0), - REAL_CONST(103705.93051741188/8.0), - REAL_CONST(103729.85828375829/8.0), - REAL_CONST(103753.78743006183/8.0), - REAL_CONST(103777.71795616332/8.0), - REAL_CONST(103801.64986190372/8.0), - REAL_CONST(103825.58314712394/8.0), - REAL_CONST(103849.51781166498/8.0), - REAL_CONST(103873.4538553679/8.0), - REAL_CONST(103897.39127807376/8.0), - REAL_CONST(103921.33007962372/8.0), - REAL_CONST(103945.27025985894/8.0), - REAL_CONST(103969.21181862066/8.0), - REAL_CONST(103993.15475575015/8.0), - REAL_CONST(104017.0990710887/8.0), - REAL_CONST(104041.0447644777/8.0), - REAL_CONST(104064.99183575854/8.0), - REAL_CONST(104088.94028477269/8.0), - REAL_CONST(104112.89011136163/8.0), - REAL_CONST(104136.84131536692/8.0), - REAL_CONST(104160.79389663014/8.0), - REAL_CONST(104184.74785499295/8.0), - REAL_CONST(104208.70319029699/8.0), - REAL_CONST(104232.65990238401/8.0), - REAL_CONST(104256.61799109577/8.0), - REAL_CONST(104280.57745627411/8.0), - REAL_CONST(104304.53829776087/8.0), - REAL_CONST(104328.50051539797/8.0), - REAL_CONST(104352.46410902737/8.0), - REAL_CONST(104376.42907849104/8.0), - REAL_CONST(104400.39542363105/8.0), - REAL_CONST(104424.36314428948/8.0), - REAL_CONST(104448.33224030846/8.0), - REAL_CONST(104472.3027115302/8.0), - REAL_CONST(104496.27455779689/8.0), - REAL_CONST(104520.24777895081/8.0), - REAL_CONST(104544.22237483428/8.0), - REAL_CONST(104568.19834528965/8.0), - REAL_CONST(104592.17569015936/8.0), - REAL_CONST(104616.15440928582/8.0), - REAL_CONST(104640.13450251156/8.0), - REAL_CONST(104664.1159696791/8.0), - REAL_CONST(104688.09881063103/8.0), - REAL_CONST(104712.08302520998/8.0), - REAL_CONST(104736.06861325864/8.0), - REAL_CONST(104760.05557461972/8.0), - REAL_CONST(104784.043909136/8.0), - REAL_CONST(104808.03361665027/8.0), - REAL_CONST(104832.0246970054/8.0), - REAL_CONST(104856.01715004431/8.0), - REAL_CONST(104880.01097560991/8.0), - REAL_CONST(104904.00617354522/8.0), - REAL_CONST(104928.00274369326/8.0), - REAL_CONST(104952.00068589712/8.0), - REAL_CONST(104975.99999999993/8.0), - REAL_CONST(105000.00068584486/8.0), - REAL_CONST(105024.00274327511/8.0), - REAL_CONST(105048.00617213396/8.0), - REAL_CONST(105072.0109722647/8.0), - REAL_CONST(105096.0171435107/8.0), - REAL_CONST(105120.02468571534/8.0), - REAL_CONST(105144.03359872208/8.0), - REAL_CONST(105168.04388237436/8.0), - REAL_CONST(105192.05553651576/8.0), - REAL_CONST(105216.06856098982/8.0), - REAL_CONST(105240.08295564017/8.0), - REAL_CONST(105264.09872031047/8.0), - REAL_CONST(105288.11585484444/8.0), - REAL_CONST(105312.13435908582/8.0), - REAL_CONST(105336.1542328784/8.0), - REAL_CONST(105360.17547606604/8.0), - REAL_CONST(105384.19808849262/8.0), - REAL_CONST(105408.22207000206/8.0), - REAL_CONST(105432.24742043833/8.0), - REAL_CONST(105456.27413964548/8.0), - REAL_CONST(105480.30222746753/8.0), - REAL_CONST(105504.33168374863/8.0), - REAL_CONST(105528.36250833291/8.0), - REAL_CONST(105552.39470106458/8.0), - REAL_CONST(105576.42826178786/8.0), - REAL_CONST(105600.46319034706/8.0), - REAL_CONST(105624.49948658649/8.0), - REAL_CONST(105648.53715035053/8.0), - REAL_CONST(105672.5761814836/8.0), - REAL_CONST(105696.61657983017/8.0), - REAL_CONST(105720.65834523473/8.0), - REAL_CONST(105744.70147754184/8.0), - REAL_CONST(105768.7459765961/8.0), - REAL_CONST(105792.79184224214/8.0), - REAL_CONST(105816.83907432464/8.0), - REAL_CONST(105840.88767268835/8.0), - REAL_CONST(105864.93763717801/8.0), - REAL_CONST(105888.98896763846/8.0), - REAL_CONST(105913.04166391456/8.0), - REAL_CONST(105937.09572585119/8.0), - REAL_CONST(105961.15115329332/8.0), - REAL_CONST(105985.20794608595/8.0), - REAL_CONST(106009.26610407409/8.0), - REAL_CONST(106033.32562710284/8.0), - REAL_CONST(106057.38651501729/8.0), - REAL_CONST(106081.44876766266/8.0), - REAL_CONST(106105.51238488412/8.0), - REAL_CONST(106129.57736652695/8.0), - REAL_CONST(106153.64371243643/8.0), - REAL_CONST(106177.71142245791/8.0), - REAL_CONST(106201.78049643678/8.0), - REAL_CONST(106225.85093421848/8.0), - REAL_CONST(106249.92273564848/8.0), - REAL_CONST(106273.99590057228/8.0), - REAL_CONST(106298.07042883546/8.0), - REAL_CONST(106322.14632028362/8.0), - REAL_CONST(106346.22357476239/8.0), - REAL_CONST(106370.30219211751/8.0), - REAL_CONST(106394.38217219469/8.0), - REAL_CONST(106418.46351483969/8.0), - REAL_CONST(106442.54621989837/8.0), - REAL_CONST(106466.63028721658/8.0), - REAL_CONST(106490.71571664025/8.0), - REAL_CONST(106514.80250801529/8.0), - REAL_CONST(106538.89066118775/8.0), - REAL_CONST(106562.98017600364/8.0), - REAL_CONST(106587.07105230905/8.0), - REAL_CONST(106611.16328995011/8.0), - REAL_CONST(106635.25688877302/8.0), - REAL_CONST(106659.35184862395/8.0), - REAL_CONST(106683.44816934918/8.0), - REAL_CONST(106707.54585079502/8.0), - REAL_CONST(106731.64489280782/8.0), - REAL_CONST(106755.74529523395/8.0), - REAL_CONST(106779.84705791986/8.0), - REAL_CONST(106803.95018071201/8.0), - REAL_CONST(106828.05466345693/8.0), - REAL_CONST(106852.16050600118/8.0), - REAL_CONST(106876.26770819137/8.0), - REAL_CONST(106900.37626987413/8.0), - REAL_CONST(106924.48619089619/8.0), - REAL_CONST(106948.59747110425/8.0), - REAL_CONST(106972.71011034511/8.0), - REAL_CONST(106996.82410846559/8.0), - REAL_CONST(107020.93946531253/8.0), - REAL_CONST(107045.05618073288/8.0), - REAL_CONST(107069.17425457356/8.0), - REAL_CONST(107093.29368668159/8.0), - REAL_CONST(107117.41447690397/8.0), - REAL_CONST(107141.53662508781/8.0), - REAL_CONST(107165.66013108024/8.0), - REAL_CONST(107189.7849947284/8.0), - REAL_CONST(107213.91121587952/8.0), - REAL_CONST(107238.03879438085/8.0), - REAL_CONST(107262.16773007967/8.0), - REAL_CONST(107286.29802282334/8.0), - REAL_CONST(107310.42967245923/8.0), - REAL_CONST(107334.56267883476/8.0), - REAL_CONST(107358.69704179741/8.0), - REAL_CONST(107382.83276119467/8.0), - REAL_CONST(107406.96983687414/8.0), - REAL_CONST(107431.10826868335/8.0), - REAL_CONST(107455.24805646999/8.0), - REAL_CONST(107479.38920008171/8.0), - REAL_CONST(107503.53169936626/8.0), - REAL_CONST(107527.67555417139/8.0), - REAL_CONST(107551.82076434491/8.0), - REAL_CONST(107575.96732973469/8.0), - REAL_CONST(107600.11525018861/8.0), - REAL_CONST(107624.26452555459/8.0), - REAL_CONST(107648.41515568066/8.0), - REAL_CONST(107672.56714041479/8.0), - REAL_CONST(107696.72047960508/8.0), - REAL_CONST(107720.87517309963/8.0), - REAL_CONST(107745.03122074658/8.0), - REAL_CONST(107769.18862239413/8.0), - REAL_CONST(107793.34737789053/8.0), - REAL_CONST(107817.50748708403/8.0), - REAL_CONST(107841.66894982298/8.0), - REAL_CONST(107865.83176595572/8.0), - REAL_CONST(107889.99593533068/8.0), - REAL_CONST(107914.16145779629/8.0), - REAL_CONST(107938.32833320105/8.0), - REAL_CONST(107962.49656139348/8.0), - REAL_CONST(107986.66614222217/8.0), - REAL_CONST(108010.83707553572/8.0), - REAL_CONST(108035.00936118282/8.0), - REAL_CONST(108059.18299901215/8.0), - REAL_CONST(108083.35798887245/8.0), - REAL_CONST(108107.53433061253/8.0), - REAL_CONST(108131.71202408121/8.0), - REAL_CONST(108155.89106912735/8.0), - REAL_CONST(108180.07146559987/8.0), - REAL_CONST(108204.25321334775/8.0), - REAL_CONST(108228.43631221994/8.0), - REAL_CONST(108252.62076206553/8.0), - REAL_CONST(108276.80656273357/8.0), - REAL_CONST(108300.99371407321/8.0), - REAL_CONST(108325.18221593359/8.0), - REAL_CONST(108349.37206816394/8.0), - REAL_CONST(108373.56327061349/8.0), - REAL_CONST(108397.75582313156/8.0), - REAL_CONST(108421.94972556747/8.0), - REAL_CONST(108446.1449777706/8.0), - REAL_CONST(108470.34157959036/8.0), - REAL_CONST(108494.53953087622/8.0), - REAL_CONST(108518.73883147769/8.0), - REAL_CONST(108542.93948124432/8.0), - REAL_CONST(108567.14148002568/8.0), - REAL_CONST(108591.34482767139/8.0), - REAL_CONST(108615.54952403114/8.0), - REAL_CONST(108639.75556895464/8.0), - REAL_CONST(108663.96296229165/8.0), - REAL_CONST(108688.17170389196/8.0), - REAL_CONST(108712.38179360541/8.0), - REAL_CONST(108736.59323128188/8.0), - REAL_CONST(108760.80601677128/8.0), - REAL_CONST(108785.02014992358/8.0), - REAL_CONST(108809.23563058881/8.0), - REAL_CONST(108833.45245861699/8.0), - REAL_CONST(108857.67063385822/8.0), - REAL_CONST(108881.89015616261/8.0), - REAL_CONST(108906.11102538036/8.0), - REAL_CONST(108930.33324136167/8.0), - REAL_CONST(108954.55680395682/8.0), - REAL_CONST(108978.78171301607/8.0), - REAL_CONST(109003.00796838976/8.0), - REAL_CONST(109027.23556992831/8.0), - REAL_CONST(109051.46451748211/8.0), - REAL_CONST(109075.69481090162/8.0), - REAL_CONST(109099.92645003737/8.0), - REAL_CONST(109124.15943473989/8.0), - REAL_CONST(109148.39376485976/8.0), - REAL_CONST(109172.62944024763/8.0), - REAL_CONST(109196.86646075416/8.0), - REAL_CONST(109221.10482623006/8.0), - REAL_CONST(109245.34453652608/8.0), - REAL_CONST(109269.58559149304/8.0), - REAL_CONST(109293.82799098175/8.0), - REAL_CONST(109318.07173484311/8.0), - REAL_CONST(109342.31682292801/8.0), - REAL_CONST(109366.56325508743/8.0), - REAL_CONST(109390.81103117237/8.0), - REAL_CONST(109415.06015103387/8.0), - REAL_CONST(109439.31061452301/8.0), - REAL_CONST(109463.56242149093/8.0), - REAL_CONST(109487.8155717888/8.0), - REAL_CONST(109512.07006526781/8.0), - REAL_CONST(109536.3259017792/8.0), - REAL_CONST(109560.58308117429/8.0), - REAL_CONST(109584.8416033044/8.0), - REAL_CONST(109609.1014680209/8.0), - REAL_CONST(109633.36267517522/8.0), - REAL_CONST(109657.62522461878/8.0), - REAL_CONST(109681.88911620311/8.0), - REAL_CONST(109706.15434977971/8.0), - REAL_CONST(109730.4209252002/8.0), - REAL_CONST(109754.68884231619/8.0), - REAL_CONST(109778.95810097932/8.0), - REAL_CONST(109803.22870104131/8.0), - REAL_CONST(109827.50064235389/8.0), - REAL_CONST(109851.77392476884/8.0), - REAL_CONST(109876.04854813802/8.0), - REAL_CONST(109900.32451231324/8.0), - REAL_CONST(109924.60181714644/8.0), - REAL_CONST(109948.88046248957/8.0), - REAL_CONST(109973.1604481946/8.0), - REAL_CONST(109997.44177411357/8.0), - REAL_CONST(110021.72444009855/8.0), - REAL_CONST(110046.00844600165/8.0), - REAL_CONST(110070.29379167501/8.0), - REAL_CONST(110094.58047697082/8.0), - REAL_CONST(110118.86850174134/8.0), - REAL_CONST(110143.15786583882/8.0), - REAL_CONST(110167.44856911557/8.0), - REAL_CONST(110191.74061142397/8.0), - REAL_CONST(110216.03399261639/8.0), - REAL_CONST(110240.32871254528/8.0), - REAL_CONST(110264.62477106311/8.0), - REAL_CONST(110288.9221680224/8.0), - REAL_CONST(110313.22090327571/8.0), - REAL_CONST(110337.52097667565/8.0), - REAL_CONST(110361.82238807483/8.0), - REAL_CONST(110386.12513732594/8.0), - REAL_CONST(110410.42922428172/8.0), - REAL_CONST(110434.73464879491/8.0), - REAL_CONST(110459.04141071832/8.0), - REAL_CONST(110483.34950990479/8.0), - REAL_CONST(110507.6589462072/8.0), - REAL_CONST(110531.96971947847/8.0), - REAL_CONST(110556.28182957157/8.0), - REAL_CONST(110580.5952763395/8.0), - REAL_CONST(110604.91005963532/8.0), - REAL_CONST(110629.22617931209/8.0), - REAL_CONST(110653.54363522294/8.0), - REAL_CONST(110677.86242722106/8.0), - REAL_CONST(110702.18255515963/8.0), - REAL_CONST(110726.50401889188/8.0), - REAL_CONST(110750.82681827113/8.0), - REAL_CONST(110775.1509531507/8.0), - REAL_CONST(110799.47642338395/8.0), - REAL_CONST(110823.80322882428/8.0), - REAL_CONST(110848.13136932514/8.0), - REAL_CONST(110872.46084474004/8.0), - REAL_CONST(110896.79165492248/8.0), - REAL_CONST(110921.12379972603/8.0), - REAL_CONST(110945.4572790043/8.0), - REAL_CONST(110969.79209261097/8.0), - REAL_CONST(110994.12824039967/8.0), - REAL_CONST(111018.46572222417/8.0), - REAL_CONST(111042.80453793822/8.0), - REAL_CONST(111067.14468739564/8.0), - REAL_CONST(111091.48617045028/8.0), - REAL_CONST(111115.82898695602/8.0), - REAL_CONST(111140.1731367668/8.0), - REAL_CONST(111164.51861973655/8.0), - REAL_CONST(111188.86543571933/8.0), - REAL_CONST(111213.21358456917/8.0), - REAL_CONST(111237.56306614014/8.0), - REAL_CONST(111261.91388028639/8.0), - REAL_CONST(111286.26602686207/8.0), - REAL_CONST(111310.61950572141/8.0), - REAL_CONST(111334.97431671864/8.0), - REAL_CONST(111359.33045970804/8.0), - REAL_CONST(111383.68793454397/8.0), - REAL_CONST(111408.04674108078/8.0), - REAL_CONST(111432.40687917286/8.0), - REAL_CONST(111456.76834867468/8.0), - REAL_CONST(111481.13114944073/8.0), - REAL_CONST(111505.49528132551/8.0), - REAL_CONST(111529.86074418361/8.0), - REAL_CONST(111554.22753786964/8.0), - REAL_CONST(111578.59566223821/8.0), - REAL_CONST(111602.96511714405/8.0), - REAL_CONST(111627.33590244185/8.0), - REAL_CONST(111651.7080179864/8.0), - REAL_CONST(111676.08146363248/8.0), - REAL_CONST(111700.45623923496/8.0), - REAL_CONST(111724.8323446487/8.0), - REAL_CONST(111749.20977972864/8.0), - REAL_CONST(111773.58854432974/8.0), - REAL_CONST(111797.96863830699/8.0), - REAL_CONST(111822.35006151545/8.0), - REAL_CONST(111846.73281381019/8.0), - REAL_CONST(111871.11689504632/8.0), - REAL_CONST(111895.50230507903/8.0), - REAL_CONST(111919.8890437635/8.0), - REAL_CONST(111944.27711095495/8.0), - REAL_CONST(111968.6665065087/8.0), - REAL_CONST(111993.05723028004/8.0), - REAL_CONST(112017.44928212435/8.0), - REAL_CONST(112041.842661897/8.0), - REAL_CONST(112066.23736945343/8.0), - REAL_CONST(112090.63340464912/8.0), - REAL_CONST(112115.03076733962/8.0), - REAL_CONST(112139.42945738042/8.0), - REAL_CONST(112163.82947462716/8.0), - REAL_CONST(112188.23081893545/8.0), - REAL_CONST(112212.63349016097/8.0), - REAL_CONST(112237.03748815943/8.0), - REAL_CONST(112261.44281278658/8.0), - REAL_CONST(112285.84946389822/8.0), - REAL_CONST(112310.25744135017/8.0), - REAL_CONST(112334.66674499828/8.0), - REAL_CONST(112359.07737469849/8.0), - REAL_CONST(112383.48933030672/8.0), - REAL_CONST(112407.90261167898/8.0), - REAL_CONST(112432.31721867126/8.0), - REAL_CONST(112456.73315113965/8.0), - REAL_CONST(112481.15040894024/8.0), - REAL_CONST(112505.56899192919/8.0), - REAL_CONST(112529.98889996267/8.0), - REAL_CONST(112554.41013289688/8.0), - REAL_CONST(112578.8326905881/8.0), - REAL_CONST(112603.25657289263/8.0), - REAL_CONST(112627.68177966679/8.0), - REAL_CONST(112652.10831076698/8.0), - REAL_CONST(112676.53616604958/8.0), - REAL_CONST(112700.96534537108/8.0), - REAL_CONST(112725.39584858794/8.0), - REAL_CONST(112749.82767555672/8.0), - REAL_CONST(112774.26082613398/8.0), - REAL_CONST(112798.6953001763/8.0), - REAL_CONST(112823.13109754038/8.0), - REAL_CONST(112847.56821808286/8.0), - REAL_CONST(112872.00666166049/8.0), - REAL_CONST(112896.44642813003/8.0), - REAL_CONST(112920.88751734827/8.0), - REAL_CONST(112945.32992917208/8.0), - REAL_CONST(112969.77366345831/8.0), - REAL_CONST(112994.21872006389/8.0), - REAL_CONST(113018.66509884578/8.0), - REAL_CONST(113043.11279966099/8.0), - REAL_CONST(113067.56182236652/8.0), - REAL_CONST(113092.01216681948/8.0), - REAL_CONST(113116.46383287695/8.0), - REAL_CONST(113140.9168203961/8.0), - REAL_CONST(113165.37112923413/8.0), - REAL_CONST(113189.82675924824/8.0), - REAL_CONST(113214.28371029573/8.0), - REAL_CONST(113238.74198223387/8.0), - REAL_CONST(113263.20157492002/8.0), - REAL_CONST(113287.66248821157/8.0), - REAL_CONST(113312.12472196593/8.0), - REAL_CONST(113336.58827604055/8.0), - REAL_CONST(113361.05315029295/8.0), - REAL_CONST(113385.51934458067/8.0), - REAL_CONST(113409.98685876124/8.0), - REAL_CONST(113434.45569269233/8.0), - REAL_CONST(113458.92584623155/8.0), - REAL_CONST(113483.39731923661/8.0), - REAL_CONST(113507.87011156522/8.0), - REAL_CONST(113532.34422307517/8.0), - REAL_CONST(113556.81965362425/8.0), - REAL_CONST(113581.2964030703/8.0), - REAL_CONST(113605.77447127122/8.0), - REAL_CONST(113630.25385808491/8.0), - REAL_CONST(113654.73456336933/8.0), - REAL_CONST(113679.2165869825/8.0), - REAL_CONST(113703.69992878241/8.0), - REAL_CONST(113728.18458862718/8.0), - REAL_CONST(113752.67056637487/8.0), - REAL_CONST(113777.15786188368/8.0), - REAL_CONST(113801.64647501177/8.0), - REAL_CONST(113826.13640561736/8.0), - REAL_CONST(113850.62765355874/8.0), - REAL_CONST(113875.12021869418/8.0), - REAL_CONST(113899.61410088204/8.0), - REAL_CONST(113924.1092999807/8.0), - REAL_CONST(113948.60581584855/8.0), - REAL_CONST(113973.10364834407/8.0), - REAL_CONST(113997.60279732574/8.0), - REAL_CONST(114022.1032626521/8.0), - REAL_CONST(114046.60504418171/8.0), - REAL_CONST(114071.10814177318/8.0), - REAL_CONST(114095.61255528514/8.0), - REAL_CONST(114120.11828457628/8.0), - REAL_CONST(114144.62532950533/8.0), - REAL_CONST(114169.13368993104/8.0), - REAL_CONST(114193.6433657122/8.0), - REAL_CONST(114218.15435670764/8.0), - REAL_CONST(114242.66666277625/8.0), - REAL_CONST(114267.18028377694/8.0), - REAL_CONST(114291.69521956862/8.0), - REAL_CONST(114316.21147001031/8.0), - REAL_CONST(114340.72903496103/8.0), - REAL_CONST(114365.24791427983/8.0), - REAL_CONST(114389.7681078258/8.0), - REAL_CONST(114414.2896154581/8.0), - REAL_CONST(114438.81243703589/8.0), - REAL_CONST(114463.33657241837/8.0), - REAL_CONST(114487.8620214648/8.0), - REAL_CONST(114512.38878403447/8.0), - REAL_CONST(114536.91685998671/8.0), - REAL_CONST(114561.44624918087/8.0), - REAL_CONST(114585.97695147636/8.0), - REAL_CONST(114610.5089667326/8.0), - REAL_CONST(114635.04229480909/8.0), - REAL_CONST(114659.57693556532/8.0), - REAL_CONST(114684.11288886084/8.0), - REAL_CONST(114708.65015455526/8.0), - REAL_CONST(114733.18873250818/8.0), - REAL_CONST(114757.72862257928/8.0), - REAL_CONST(114782.26982462825/8.0), - REAL_CONST(114806.81233851484/8.0), - REAL_CONST(114831.35616409882/8.0), - REAL_CONST(114855.90130123998/8.0), - REAL_CONST(114880.44774979822/8.0), - REAL_CONST(114904.99550963337/8.0), - REAL_CONST(114929.5445806054/8.0), - REAL_CONST(114954.09496257425/8.0), - REAL_CONST(114978.64665539992/8.0), - REAL_CONST(115003.19965894247/8.0), - REAL_CONST(115027.75397306195/8.0), - REAL_CONST(115052.30959761847/8.0), - REAL_CONST(115076.86653247218/8.0), - REAL_CONST(115101.42477748329/8.0), - REAL_CONST(115125.984332512/8.0), - REAL_CONST(115150.54519741859/8.0), - REAL_CONST(115175.10737206334/8.0), - REAL_CONST(115199.67085630659/8.0), - REAL_CONST(115224.23565000873/8.0), - REAL_CONST(115248.80175303014/8.0), - REAL_CONST(115273.3691652313/8.0), - REAL_CONST(115297.93788647266/8.0), - REAL_CONST(115322.50791661476/8.0), - REAL_CONST(115347.07925551817/8.0), - REAL_CONST(115371.65190304347/8.0), - REAL_CONST(115396.22585905129/8.0), - REAL_CONST(115420.80112340231/8.0), - REAL_CONST(115445.37769595724/8.0), - REAL_CONST(115469.95557657682/8.0), - REAL_CONST(115494.53476512182/8.0), - REAL_CONST(115519.11526145306/8.0), - REAL_CONST(115543.69706543141/8.0), - REAL_CONST(115568.28017691776/8.0), - REAL_CONST(115592.86459577303/8.0), - REAL_CONST(115617.4503218582/8.0), - REAL_CONST(115642.03735503425/8.0), - REAL_CONST(115666.62569516223/8.0), - REAL_CONST(115691.21534210323/8.0), - REAL_CONST(115715.80629571836/8.0), - REAL_CONST(115740.39855586876/8.0), - REAL_CONST(115764.99212241563/8.0), - REAL_CONST(115789.58699522018/8.0), - REAL_CONST(115814.18317414368/8.0), - REAL_CONST(115838.78065904744/8.0), - REAL_CONST(115863.37944979276/8.0), - REAL_CONST(115887.97954624105/8.0), - REAL_CONST(115912.5809482537/8.0), - REAL_CONST(115937.18365569216/8.0), - REAL_CONST(115961.78766841792/8.0), - REAL_CONST(115986.39298629249/8.0), - REAL_CONST(116010.99960917742/8.0), - REAL_CONST(116035.60753693432/8.0), - REAL_CONST(116060.21676942479/8.0), - REAL_CONST(116084.82730651053/8.0), - REAL_CONST(116109.43914805322/8.0), - REAL_CONST(116134.0522939146/8.0), - REAL_CONST(116158.66674395646/8.0), - REAL_CONST(116183.2824980406/8.0), - REAL_CONST(116207.89955602887/8.0), - REAL_CONST(116232.51791778316/8.0), - REAL_CONST(116257.13758316539/8.0), - REAL_CONST(116281.75855203751/8.0), - REAL_CONST(116306.38082426153/8.0), - REAL_CONST(116331.00439969949/8.0), - REAL_CONST(116355.62927821343/8.0), - REAL_CONST(116380.25545966547/8.0), - REAL_CONST(116404.88294391775/8.0), - REAL_CONST(116429.51173083246/8.0), - REAL_CONST(116454.14182027178/8.0), - REAL_CONST(116478.77321209799/8.0), - REAL_CONST(116503.40590617337/8.0), - REAL_CONST(116528.03990236025/8.0), - REAL_CONST(116552.67520052097/8.0), - REAL_CONST(116577.31180051794/8.0), - REAL_CONST(116601.94970221359/8.0), - REAL_CONST(116626.5889054704/8.0), - REAL_CONST(116651.22941015086/8.0), - REAL_CONST(116675.87121611751/8.0), - REAL_CONST(116700.51432323294/8.0), - REAL_CONST(116725.15873135976/8.0), - REAL_CONST(116749.8044403606/8.0), - REAL_CONST(116774.45145009817/8.0), - REAL_CONST(116799.0997604352/8.0), - REAL_CONST(116823.74937123443/8.0), - REAL_CONST(116848.40028235866/8.0), - REAL_CONST(116873.05249367072/8.0), - REAL_CONST(116897.70600503348/8.0), - REAL_CONST(116922.36081630984/8.0), - REAL_CONST(116947.01692736275/8.0), - REAL_CONST(116971.67433805518/8.0), - REAL_CONST(116996.33304825013/8.0), - REAL_CONST(117020.99305781067/8.0), - REAL_CONST(117045.65436659988/8.0), - REAL_CONST(117070.31697448085/8.0), - REAL_CONST(117094.98088131678/8.0), - REAL_CONST(117119.64608697082/8.0), - REAL_CONST(117144.31259130624/8.0), - REAL_CONST(117168.98039418629/8.0), - REAL_CONST(117193.64949547425/8.0), - REAL_CONST(117218.31989503348/8.0), - REAL_CONST(117242.99159272734/8.0), - REAL_CONST(117267.66458841923/8.0), - REAL_CONST(117292.33888197262/8.0), - REAL_CONST(117317.01447325097/8.0), - REAL_CONST(117341.6913621178/8.0), - REAL_CONST(117366.36954843666/8.0), - REAL_CONST(117391.04903207115/8.0), - REAL_CONST(117415.72981288488/8.0), - REAL_CONST(117440.41189074152/8.0), - REAL_CONST(117465.09526550474/8.0), - REAL_CONST(117489.77993703831/8.0), - REAL_CONST(117514.46590520597/8.0), - REAL_CONST(117539.15316987153/8.0), - REAL_CONST(117563.84173089883/8.0), - REAL_CONST(117588.53158815173/8.0), - REAL_CONST(117613.22274149416/8.0), - REAL_CONST(117637.91519079007/8.0), - REAL_CONST(117662.60893590341/8.0), - REAL_CONST(117687.30397669821/8.0), - REAL_CONST(117712.00031303853/8.0), - REAL_CONST(117736.69794478847/8.0), - REAL_CONST(117761.39687181212/8.0), - REAL_CONST(117786.09709397367/8.0), - REAL_CONST(117810.7986111373/8.0), - REAL_CONST(117835.50142316725/8.0), - REAL_CONST(117860.20552992777/8.0), - REAL_CONST(117884.91093128319/8.0), - REAL_CONST(117909.6176270978/8.0), - REAL_CONST(117934.32561723603/8.0), - REAL_CONST(117959.03490156225/8.0), - REAL_CONST(117983.74547994092/8.0), - REAL_CONST(118008.45735223651/8.0), - REAL_CONST(118033.17051831353/8.0), - REAL_CONST(118057.88497803656/8.0), - REAL_CONST(118082.60073127014/8.0), - REAL_CONST(118107.31777787894/8.0), - REAL_CONST(118132.03611772758/8.0), - REAL_CONST(118156.75575068076/8.0), - REAL_CONST(118181.47667660323/8.0), - REAL_CONST(118206.19889535972/8.0), - REAL_CONST(118230.92240681504/8.0), - REAL_CONST(118255.64721083404/8.0), - REAL_CONST(118280.37330728157/8.0), - REAL_CONST(118305.10069602253/8.0), - REAL_CONST(118329.82937692189/8.0), - REAL_CONST(118354.55934984458/8.0), - REAL_CONST(118379.29061465565/8.0), - REAL_CONST(118404.02317122012/8.0), - REAL_CONST(118428.75701940308/8.0), - REAL_CONST(118453.49215906965/8.0), - REAL_CONST(118478.22859008498/8.0), - REAL_CONST(118502.96631231424/8.0), - REAL_CONST(118527.70532562268/8.0), - REAL_CONST(118552.44562987552/8.0), - REAL_CONST(118577.18722493808/8.0), - REAL_CONST(118601.93011067568/8.0), - REAL_CONST(118626.67428695368/8.0), - REAL_CONST(118651.41975363747/8.0), - REAL_CONST(118676.16651059251/8.0), - REAL_CONST(118700.91455768423/8.0), - REAL_CONST(118725.66389477813/8.0), - REAL_CONST(118750.41452173979/8.0), - REAL_CONST(118775.16643843475/8.0), - REAL_CONST(118799.91964472862/8.0), - REAL_CONST(118824.67414048707/8.0), - REAL_CONST(118849.42992557574/8.0), - REAL_CONST(118874.18699986035/8.0), - REAL_CONST(118898.94536320666/8.0), - REAL_CONST(118923.70501548045/8.0), - REAL_CONST(118948.46595654752/8.0), - REAL_CONST(118973.22818627374/8.0), - REAL_CONST(118997.99170452499/8.0), - REAL_CONST(119022.7565111672/8.0), - REAL_CONST(119047.52260606633/8.0), - REAL_CONST(119072.28998908834/8.0), - REAL_CONST(119097.0586600993/8.0), - REAL_CONST(119121.82861896523/8.0), - REAL_CONST(119146.59986555226/8.0), - REAL_CONST(119171.3723997265/8.0), - REAL_CONST(119196.14622135412/8.0), - REAL_CONST(119220.92133030134/8.0), - REAL_CONST(119245.69772643436/8.0), - REAL_CONST(119270.47540961947/8.0), - REAL_CONST(119295.25437972297/8.0), - REAL_CONST(119320.03463661121/8.0), - REAL_CONST(119344.81618015055/8.0), - REAL_CONST(119369.5990102074/8.0), - REAL_CONST(119394.38312664822/8.0), - REAL_CONST(119419.16852933947/8.0), - REAL_CONST(119443.95521814766/8.0), - REAL_CONST(119468.74319293935/8.0), - REAL_CONST(119493.53245358112/8.0), - REAL_CONST(119518.32299993958/8.0), - REAL_CONST(119543.11483188139/8.0), - REAL_CONST(119567.90794927324/8.0), - REAL_CONST(119592.70235198183/8.0), - REAL_CONST(119617.49803987393/8.0), - REAL_CONST(119642.29501281632/8.0), - REAL_CONST(119667.09327067583/8.0), - REAL_CONST(119691.89281331931/8.0), - REAL_CONST(119716.69364061367/8.0), - REAL_CONST(119741.49575242582/8.0), - REAL_CONST(119766.29914862274/8.0), - REAL_CONST(119791.10382907141/8.0), - REAL_CONST(119815.90979363887/8.0), - REAL_CONST(119840.71704219218/8.0), - REAL_CONST(119865.52557459843/8.0), - REAL_CONST(119890.33539072477/8.0), - REAL_CONST(119915.14649043836/8.0), - REAL_CONST(119939.95887360642/8.0), - REAL_CONST(119964.77254009615/8.0), - REAL_CONST(119989.58748977486/8.0), - REAL_CONST(120014.40372250983/8.0), - REAL_CONST(120039.22123816841/8.0), - REAL_CONST(120064.04003661797/8.0), - REAL_CONST(120088.86011772591/8.0), - REAL_CONST(120113.6814813597/8.0), - REAL_CONST(120138.5041273868/8.0), - REAL_CONST(120163.3280556747/8.0), - REAL_CONST(120188.15326609099/8.0), - REAL_CONST(120212.97975850321/8.0), - REAL_CONST(120237.807532779/8.0), - REAL_CONST(120262.63658878599/8.0), - REAL_CONST(120287.46692639188/8.0), - REAL_CONST(120312.29854546436/8.0), - REAL_CONST(120337.13144587121/8.0), - REAL_CONST(120361.9656274802/8.0), - REAL_CONST(120386.80109015915/8.0), - REAL_CONST(120411.63783377589/8.0), - REAL_CONST(120436.47585819835/8.0), - REAL_CONST(120461.31516329442/8.0), - REAL_CONST(120486.15574893207/8.0), - REAL_CONST(120510.99761497928/8.0), - REAL_CONST(120535.84076130406/8.0), - REAL_CONST(120560.68518777451/8.0), - REAL_CONST(120585.53089425867/8.0), - REAL_CONST(120610.3778806247/8.0), - REAL_CONST(120635.22614674074/8.0), - REAL_CONST(120660.07569247499/8.0), - REAL_CONST(120684.92651769568/8.0), - REAL_CONST(120709.77862227106/8.0), - REAL_CONST(120734.63200606944/8.0), - REAL_CONST(120759.48666895913/8.0), - REAL_CONST(120784.3426108085/8.0), - REAL_CONST(120809.19983148595/8.0), - REAL_CONST(120834.05833085992/8.0), - REAL_CONST(120858.91810879884/8.0), - REAL_CONST(120883.77916517125/8.0), - REAL_CONST(120908.64149984565/8.0), - REAL_CONST(120933.5051126906/8.0), - REAL_CONST(120958.37000357473/8.0), - REAL_CONST(120983.23617236665/8.0), - REAL_CONST(121008.10361893504/8.0), - REAL_CONST(121032.97234314861/8.0), - REAL_CONST(121057.84234487606/8.0), - REAL_CONST(121082.71362398617/8.0), - REAL_CONST(121107.58618034775/8.0), - REAL_CONST(121132.46001382964/8.0), - REAL_CONST(121157.33512430069/8.0), - REAL_CONST(121182.21151162982/8.0), - REAL_CONST(121207.08917568595/8.0), - REAL_CONST(121231.96811633807/8.0), - REAL_CONST(121256.84833345517/8.0), - REAL_CONST(121281.72982690629/8.0), - REAL_CONST(121306.61259656049/8.0), - REAL_CONST(121331.49664228689/8.0), - REAL_CONST(121356.38196395461/8.0), - REAL_CONST(121381.26856143285/8.0), - REAL_CONST(121406.15643459078/8.0), - REAL_CONST(121431.04558329767/8.0), - REAL_CONST(121455.93600742276/8.0), - REAL_CONST(121480.82770683538/8.0), - REAL_CONST(121505.72068140487/8.0), - REAL_CONST(121530.61493100057/8.0), - REAL_CONST(121555.51045549192/8.0), - REAL_CONST(121580.40725474835/8.0), - REAL_CONST(121605.30532863933/8.0), - REAL_CONST(121630.20467703436/8.0), - REAL_CONST(121655.10529980299/8.0), - REAL_CONST(121680.00719681478/8.0), - REAL_CONST(121704.91036793934/8.0), - REAL_CONST(121729.81481304632/8.0), - REAL_CONST(121754.72053200539/8.0), - REAL_CONST(121779.62752468624/8.0), - REAL_CONST(121804.53579095862/8.0), - REAL_CONST(121829.44533069231/8.0), - REAL_CONST(121854.3561437571/8.0), - REAL_CONST(121879.26823002285/8.0), - REAL_CONST(121904.1815893594/8.0), - REAL_CONST(121929.09622163669/8.0), - REAL_CONST(121954.01212672464/8.0), - REAL_CONST(121978.92930449323/8.0), - REAL_CONST(122003.84775481246/8.0), - REAL_CONST(122028.76747755238/8.0), - REAL_CONST(122053.68847258303/8.0), - REAL_CONST(122078.61073977455/8.0), - REAL_CONST(122103.53427899707/8.0), - REAL_CONST(122128.45909012076/8.0), - REAL_CONST(122153.38517301581/8.0), - REAL_CONST(122178.31252755247/8.0), - REAL_CONST(122203.24115360099/8.0), - REAL_CONST(122228.17105103172/8.0), - REAL_CONST(122253.10221971494/8.0), - REAL_CONST(122278.03465952107/8.0), - REAL_CONST(122302.96837032049/8.0), - REAL_CONST(122327.90335198362/8.0), - REAL_CONST(122352.83960438096/8.0), - REAL_CONST(122377.777127383/8.0), - REAL_CONST(122402.71592086025/8.0), - REAL_CONST(122427.65598468333/8.0), - REAL_CONST(122452.59731872278/8.0), - REAL_CONST(122477.53992284928/8.0), - REAL_CONST(122502.48379693348/8.0), - REAL_CONST(122527.42894084606/8.0), - REAL_CONST(122552.37535445779/8.0), - REAL_CONST(122577.32303763942/8.0), - REAL_CONST(122602.27199026172/8.0), - REAL_CONST(122627.22221219557/8.0), - REAL_CONST(122652.17370331181/8.0), - REAL_CONST(122677.12646348133/8.0), - REAL_CONST(122702.08049257506/8.0), - REAL_CONST(122727.03579046397/8.0), - REAL_CONST(122751.99235701906/8.0), - REAL_CONST(122776.95019211136/8.0), - REAL_CONST(122801.9092956119/8.0), - REAL_CONST(122826.8696673918/8.0), - REAL_CONST(122851.83130732219/8.0), - REAL_CONST(122876.79421527422/8.0), - REAL_CONST(122901.75839111909/8.0), - REAL_CONST(122926.72383472799/8.0), - REAL_CONST(122951.69054597223/8.0), - REAL_CONST(122976.65852472307/8.0), - REAL_CONST(123001.62777085182/8.0), - REAL_CONST(123026.59828422987/8.0), - REAL_CONST(123051.57006472857/8.0), - REAL_CONST(123076.54311221937/8.0), - REAL_CONST(123101.5174265737/8.0), - REAL_CONST(123126.49300766307/8.0), - REAL_CONST(123151.46985535898/8.0), - REAL_CONST(123176.44796953299/8.0), - REAL_CONST(123201.42735005668/8.0), - REAL_CONST(123226.40799680166/8.0), - REAL_CONST(123251.38990963959/8.0), - REAL_CONST(123276.37308844214/8.0), - REAL_CONST(123301.35753308103/8.0), - REAL_CONST(123326.343243428/8.0), - REAL_CONST(123351.33021935483/8.0), - REAL_CONST(123376.31846073334/8.0), - REAL_CONST(123401.30796743535/8.0), - REAL_CONST(123426.29873933276/8.0), - REAL_CONST(123451.29077629748/8.0), - REAL_CONST(123476.28407820144/8.0), - REAL_CONST(123501.2786449166/8.0), - REAL_CONST(123526.27447631498/8.0), - REAL_CONST(123551.27157226863/8.0), - REAL_CONST(123576.26993264959/8.0), - REAL_CONST(123601.26955732999/8.0), - REAL_CONST(123626.27044618195/8.0), - REAL_CONST(123651.27259907764/8.0), - REAL_CONST(123676.27601588926/8.0), - REAL_CONST(123701.28069648903/8.0), - REAL_CONST(123726.28664074924/8.0), - REAL_CONST(123751.29384854218/8.0), - REAL_CONST(123776.30231974016/8.0), - REAL_CONST(123801.31205421555/8.0), - REAL_CONST(123826.32305184075/8.0), - REAL_CONST(123851.33531248817/8.0), - REAL_CONST(123876.34883603029/8.0), - REAL_CONST(123901.36362233957/8.0), - REAL_CONST(123926.37967128855/8.0), - REAL_CONST(123951.39698274979/8.0), - REAL_CONST(123976.41555659588/8.0), - REAL_CONST(124001.43539269941/8.0), - REAL_CONST(124026.45649093305/8.0), - REAL_CONST(124051.47885116948/8.0), - REAL_CONST(124076.50247328142/8.0), - REAL_CONST(124101.5273571416/8.0), - REAL_CONST(124126.55350262282/8.0), - REAL_CONST(124151.58090959788/8.0), - REAL_CONST(124176.60957793961/8.0), - REAL_CONST(124201.63950752091/8.0), - REAL_CONST(124226.67069821467/8.0), - REAL_CONST(124251.70314989384/8.0), - REAL_CONST(124276.73686243138/8.0), - REAL_CONST(124301.7718357003/8.0), - REAL_CONST(124326.80806957364/8.0), - REAL_CONST(124351.84556392446/8.0), - REAL_CONST(124376.88431862585/8.0), - REAL_CONST(124401.92433355095/8.0), - REAL_CONST(124426.96560857294/8.0), - REAL_CONST(124452.00814356498/8.0), - REAL_CONST(124477.05193840031/8.0), - REAL_CONST(124502.0969929522/8.0), - REAL_CONST(124527.14330709392/8.0), - REAL_CONST(124552.19088069882/8.0), - REAL_CONST(124577.23971364023/8.0), - REAL_CONST(124602.28980579154/8.0), - REAL_CONST(124627.34115702618/8.0), - REAL_CONST(124652.3937672176/8.0), - REAL_CONST(124677.44763623926/8.0), - REAL_CONST(124702.50276396469/8.0), - REAL_CONST(124727.55915026742/8.0), - REAL_CONST(124752.61679502104/8.0), - REAL_CONST(124777.67569809916/8.0), - REAL_CONST(124802.73585937542/8.0), - REAL_CONST(124827.79727872348/8.0), - REAL_CONST(124852.85995601704/8.0), - REAL_CONST(124877.92389112986/8.0), - REAL_CONST(124902.98908393568/8.0), - REAL_CONST(124928.05553430831/8.0), - REAL_CONST(124953.1232421216/8.0), - REAL_CONST(124978.19220724938/8.0), - REAL_CONST(125003.26242956554/8.0), - REAL_CONST(125028.33390894404/8.0), - REAL_CONST(125053.40664525882/8.0), - REAL_CONST(125078.48063838384/8.0), - REAL_CONST(125103.55588819318/8.0), - REAL_CONST(125128.63239456083/8.0), - REAL_CONST(125153.71015736091/8.0), - REAL_CONST(125178.78917646752/8.0), - REAL_CONST(125203.86945175481/8.0), - REAL_CONST(125228.95098309696/8.0), - REAL_CONST(125254.03377036817/8.0), - REAL_CONST(125279.1178134427/8.0), - REAL_CONST(125304.20311219479/8.0), - REAL_CONST(125329.28966649878/8.0), - REAL_CONST(125354.37747622898/8.0), - REAL_CONST(125379.46654125977/8.0), - REAL_CONST(125404.55686146552/8.0), - REAL_CONST(125429.6484367207/8.0), - REAL_CONST(125454.74126689974/8.0), - REAL_CONST(125479.83535187715/8.0), - REAL_CONST(125504.93069152744/8.0), - REAL_CONST(125530.02728572517/8.0), - REAL_CONST(125555.12513434493/8.0), - REAL_CONST(125580.22423726133/8.0), - REAL_CONST(125605.32459434902/8.0), - REAL_CONST(125630.4262054827/8.0), - REAL_CONST(125655.52907053704/8.0), - REAL_CONST(125680.63318938682/8.0), - REAL_CONST(125705.73856190679/8.0), - REAL_CONST(125730.84518797178/8.0), - REAL_CONST(125755.9530674566/8.0), - REAL_CONST(125781.06220023613/8.0), - REAL_CONST(125806.17258618528/8.0), - REAL_CONST(125831.28422517896/8.0), - REAL_CONST(125856.39711709213/8.0), - REAL_CONST(125881.51126179981/8.0), - REAL_CONST(125906.62665917698/8.0), - REAL_CONST(125931.74330909875/8.0), - REAL_CONST(125956.86121144016/8.0), - REAL_CONST(125981.98036607634/8.0), - REAL_CONST(126007.10077288245/8.0), - REAL_CONST(126032.22243173365/8.0), - REAL_CONST(126057.34534250517/8.0), - REAL_CONST(126082.46950507225/8.0), - REAL_CONST(126107.59491931014/8.0), - REAL_CONST(126132.72158509417/8.0), - REAL_CONST(126157.84950229966/8.0), - REAL_CONST(126182.97867080198/8.0), - REAL_CONST(126208.10909047653/8.0), - REAL_CONST(126233.24076119871/8.0), - REAL_CONST(126258.37368284403/8.0), - REAL_CONST(126283.50785528794/8.0), - REAL_CONST(126308.64327840599/8.0), - REAL_CONST(126333.77995207369/8.0), - REAL_CONST(126358.91787616667/8.0), - REAL_CONST(126384.0570505605/8.0), - REAL_CONST(126409.19747513086/8.0), - REAL_CONST(126434.3391497534/8.0), - REAL_CONST(126459.48207430386/8.0), - REAL_CONST(126484.62624865794/8.0), - REAL_CONST(126509.77167269142/8.0), - REAL_CONST(126534.9183462801/8.0), - REAL_CONST(126560.06626929982/8.0), - REAL_CONST(126585.21544162642/8.0), - REAL_CONST(126610.36586313581/8.0), - REAL_CONST(126635.51753370393/8.0), - REAL_CONST(126660.67045320668/8.0), - REAL_CONST(126685.82462152008/8.0), - REAL_CONST(126710.98003852014/8.0), - REAL_CONST(126736.13670408291/8.0), - REAL_CONST(126761.29461808444/8.0), - REAL_CONST(126786.45378040087/8.0), - REAL_CONST(126811.61419090834/8.0), - REAL_CONST(126836.77584948298/8.0), - REAL_CONST(126861.93875600102/8.0), - REAL_CONST(126887.10291033868/8.0), - REAL_CONST(126912.26831237224/8.0), - REAL_CONST(126937.43496197795/8.0), - REAL_CONST(126962.60285903217/8.0), - REAL_CONST(126987.77200341123/8.0), - REAL_CONST(127012.94239499152/8.0), - REAL_CONST(127038.11403364947/8.0), - REAL_CONST(127063.2869192615/8.0), - REAL_CONST(127088.46105170409/8.0), - REAL_CONST(127113.63643085376/8.0), - REAL_CONST(127138.81305658702/8.0), - REAL_CONST(127163.99092878048/8.0), - REAL_CONST(127189.17004731069/8.0), - REAL_CONST(127214.35041205429/8.0), - REAL_CONST(127239.53202288797/8.0), - REAL_CONST(127264.71487968838/8.0), - REAL_CONST(127289.89898233226/8.0), - REAL_CONST(127315.08433069635/8.0), - REAL_CONST(127340.27092465744/8.0), - REAL_CONST(127365.45876409234/8.0), - REAL_CONST(127390.64784887788/8.0), - REAL_CONST(127415.83817889093/8.0), - REAL_CONST(127441.02975400841/8.0), - REAL_CONST(127466.22257410725/8.0), - REAL_CONST(127491.41663906439/8.0), - REAL_CONST(127516.61194875685/8.0), - REAL_CONST(127541.80850306165/8.0), - REAL_CONST(127567.00630185583/8.0), - REAL_CONST(127592.20534501647/8.0), - REAL_CONST(127617.4056324207/8.0), - REAL_CONST(127642.60716394568/8.0), - REAL_CONST(127667.80993946856/8.0), - REAL_CONST(127693.01395886653/8.0), - REAL_CONST(127718.21922201688/8.0), - REAL_CONST(127743.42572879682/8.0), - REAL_CONST(127768.63347908368/8.0), - REAL_CONST(127793.84247275478/8.0), - REAL_CONST(127819.05270968749/8.0), - REAL_CONST(127844.26418975917/8.0), - REAL_CONST(127869.47691284724/8.0), - REAL_CONST(127894.69087882918/8.0), - REAL_CONST(127919.90608758242/8.0), - REAL_CONST(127945.12253898452/8.0), - REAL_CONST(127970.34023291297/8.0), - REAL_CONST(127995.55916924537/8.0), - REAL_CONST(128020.77934785932/8.0), - REAL_CONST(128046.00076863244/8.0), - REAL_CONST(128071.22343144237/8.0), - REAL_CONST(128096.44733616684/8.0), - REAL_CONST(128121.67248268353/8.0), - REAL_CONST(128146.89887087021/8.0), - REAL_CONST(128172.12650060465/8.0), - REAL_CONST(128197.35537176467/8.0), - REAL_CONST(128222.5854842281/8.0), - REAL_CONST(128247.81683787282/8.0), - REAL_CONST(128273.04943257671/8.0), - REAL_CONST(128298.28326821771/8.0), - REAL_CONST(128323.51834467379/8.0), - REAL_CONST(128348.75466182294/8.0), - REAL_CONST(128373.99221954317/8.0), - REAL_CONST(128399.23101771252/8.0), - REAL_CONST(128424.47105620909/8.0), - REAL_CONST(128449.71233491098/8.0), - REAL_CONST(128474.95485369631/8.0), - REAL_CONST(128500.19861244329/8.0), - REAL_CONST(128525.44361103009/8.0), - REAL_CONST(128550.68984933494/8.0), - REAL_CONST(128575.93732723613/8.0), - REAL_CONST(128601.18604461191/8.0), - REAL_CONST(128626.43600134061/8.0), - REAL_CONST(128651.68719730059/8.0), - REAL_CONST(128676.93963237021/8.0), - REAL_CONST(128702.1933064279/8.0), - REAL_CONST(128727.44821935208/8.0), - REAL_CONST(128752.70437102125/8.0), - REAL_CONST(128777.96176131385/8.0), - REAL_CONST(128803.22039010846/8.0), - REAL_CONST(128828.48025728362/8.0), - REAL_CONST(128853.74136271792/8.0), - REAL_CONST(128879.00370628996/8.0), - REAL_CONST(128904.26728787841/8.0), - REAL_CONST(128929.53210736193/8.0), - REAL_CONST(128954.79816461923/8.0), - REAL_CONST(128980.06545952905/8.0), - REAL_CONST(129005.33399197015/8.0), - REAL_CONST(129030.60376182134/8.0), - REAL_CONST(129055.87476896142/8.0), - REAL_CONST(129081.14701326926/8.0), - REAL_CONST(129106.42049462376/8.0), - REAL_CONST(129131.6952129038/8.0), - REAL_CONST(129156.97116798835/8.0), - REAL_CONST(129182.24835975636/8.0), - REAL_CONST(129207.52678808685/8.0), - REAL_CONST(129232.80645285884/8.0), - REAL_CONST(129258.08735395141/8.0), - REAL_CONST(129283.36949124365/8.0), - REAL_CONST(129308.65286461466/8.0), - REAL_CONST(129333.9374739436/8.0), - REAL_CONST(129359.22331910966/8.0), - REAL_CONST(129384.51039999202/8.0), - REAL_CONST(129409.79871646997/8.0), - REAL_CONST(129435.08826842274/8.0), - REAL_CONST(129460.37905572963/8.0), - REAL_CONST(129485.67107826998/8.0), - REAL_CONST(129510.96433592314/8.0), - REAL_CONST(129536.25882856851/8.0), - REAL_CONST(129561.55455608548/8.0), - REAL_CONST(129586.85151835352/8.0), - REAL_CONST(129612.14971525209/8.0), - REAL_CONST(129637.4491466607/8.0), - REAL_CONST(129662.74981245887/8.0), - REAL_CONST(129688.0517125262/8.0), - REAL_CONST(129713.35484674224/8.0), - REAL_CONST(129738.65921498663/8.0), - REAL_CONST(129763.96481713903/8.0), - REAL_CONST(129789.27165307909/8.0), - REAL_CONST(129814.57972268655/8.0), - REAL_CONST(129839.88902584116/8.0), - REAL_CONST(129865.19956242264/8.0), - REAL_CONST(129890.51133231082/8.0), - REAL_CONST(129915.82433538554/8.0), - REAL_CONST(129941.13857152662/8.0), - REAL_CONST(129966.45404061397/8.0), - REAL_CONST(129991.7707425275/8.0), - REAL_CONST(130017.08867714716/8.0), - REAL_CONST(130042.4078443529/8.0), - REAL_CONST(130067.72824402474/8.0), - REAL_CONST(130093.04987604271/8.0), - REAL_CONST(130118.37274028687/8.0), - REAL_CONST(130143.69683663732/8.0), - REAL_CONST(130169.02216497416/8.0), - REAL_CONST(130194.34872517755/8.0), - REAL_CONST(130219.67651712766/8.0), - REAL_CONST(130245.0055407047/8.0), - REAL_CONST(130270.33579578891/8.0), - REAL_CONST(130295.66728226055/8.0), - REAL_CONST(130320.99999999991/8.0), - REAL_CONST(130346.33394888733/8.0), - REAL_CONST(130371.66912880314/8.0), - REAL_CONST(130397.00553962773/8.0), - REAL_CONST(130422.34318124152/8.0), - REAL_CONST(130447.68205352494/8.0), - REAL_CONST(130473.02215635845/8.0), - REAL_CONST(130498.36348962256/8.0), - REAL_CONST(130523.70605319779/8.0), - REAL_CONST(130549.0498469647/8.0), - REAL_CONST(130574.39487080388/8.0), - REAL_CONST(130599.74112459592/8.0), - REAL_CONST(130625.08860822149/8.0), - REAL_CONST(130650.43732156123/8.0), - REAL_CONST(130675.78726449587/8.0), - REAL_CONST(130701.13843690613/8.0), - REAL_CONST(130726.49083867275/8.0), - REAL_CONST(130751.84446967654/8.0), - REAL_CONST(130777.19932979831/8.0), - REAL_CONST(130802.5554189189/8.0), - REAL_CONST(130827.91273691918/8.0), - REAL_CONST(130853.27128368006/8.0), - REAL_CONST(130878.63105908247/8.0), - REAL_CONST(130903.99206300738/8.0), - REAL_CONST(130929.35429533575/8.0), - REAL_CONST(130954.71775594862/8.0), - REAL_CONST(130980.08244472703/8.0), - REAL_CONST(131005.44836155206/8.0), - REAL_CONST(131030.81550630482/8.0), - REAL_CONST(131056.18387886642/8.0), - REAL_CONST(131081.55347911804/8.0), - REAL_CONST(131106.92430694087/8.0), - REAL_CONST(131132.29636221612/8.0), - REAL_CONST(131157.66964482504/8.0), - REAL_CONST(131183.0441546489/8.0), - REAL_CONST(131208.41989156904/8.0), - REAL_CONST(131233.79685546676/8.0), - REAL_CONST(131259.17504622342/8.0), - REAL_CONST(131284.55446372041/8.0), - REAL_CONST(131309.93510783918/8.0), - REAL_CONST(131335.31697846117/8.0), - REAL_CONST(131360.70007546784/8.0), - REAL_CONST(131386.0843987407/8.0), - REAL_CONST(131411.46994816128/8.0), - REAL_CONST(131436.85672361116/8.0), - REAL_CONST(131462.24472497194/8.0), - REAL_CONST(131487.63395212521/8.0), - REAL_CONST(131513.02440495262/8.0), - REAL_CONST(131538.41608333588/8.0), - REAL_CONST(131563.80898715663/8.0), - REAL_CONST(131589.2031162967/8.0), - REAL_CONST(131614.59847063778/8.0), - REAL_CONST(131639.9950500617/8.0), - REAL_CONST(131665.39285445024/8.0), - REAL_CONST(131690.79188368531/8.0), - REAL_CONST(131716.19213764873/8.0), - REAL_CONST(131741.59361622241/8.0), - REAL_CONST(131766.99631928833/8.0), - REAL_CONST(131792.40024672839/8.0), - REAL_CONST(131817.80539842462/8.0), - REAL_CONST(131843.21177425905/8.0), - REAL_CONST(131868.61937411371/8.0), - REAL_CONST(131894.02819787065/8.0), - REAL_CONST(131919.43824541202/8.0), - REAL_CONST(131944.84951661993/8.0), - REAL_CONST(131970.26201137656/8.0), - REAL_CONST(131995.67572956407/8.0), - REAL_CONST(132021.09067106468/8.0), - REAL_CONST(132046.50683576067/8.0), - REAL_CONST(132071.9242235343/8.0), - REAL_CONST(132097.34283426782/8.0), - REAL_CONST(132122.76266784366/8.0), - REAL_CONST(132148.1837241441/8.0), - REAL_CONST(132173.60600305157/8.0), - REAL_CONST(132199.02950444847/8.0), - REAL_CONST(132224.45422821722/8.0), - REAL_CONST(132249.88017424036/8.0), - REAL_CONST(132275.30734240031/8.0), - REAL_CONST(132300.73573257966/8.0), - REAL_CONST(132326.16534466096/8.0), - REAL_CONST(132351.59617852676/8.0), - REAL_CONST(132377.02823405969/8.0), - REAL_CONST(132402.46151114244/8.0), - REAL_CONST(132427.89600965759/8.0), - REAL_CONST(132453.33172948789/8.0), - REAL_CONST(132478.76867051609/8.0), - REAL_CONST(132504.20683262491/8.0), - REAL_CONST(132529.64621569714/8.0), - REAL_CONST(132555.08681961559/8.0), - REAL_CONST(132580.5286442631/8.0), - REAL_CONST(132605.97168952253/8.0), - REAL_CONST(132631.41595527678/8.0), - REAL_CONST(132656.86144140881/8.0), - REAL_CONST(132682.30814780149/8.0), - REAL_CONST(132707.75607433787/8.0), - REAL_CONST(132733.20522090094/8.0), - REAL_CONST(132758.65558737374/8.0), - REAL_CONST(132784.10717363929/8.0), - REAL_CONST(132809.55997958075/8.0), - REAL_CONST(132835.01400508118/8.0), - REAL_CONST(132860.46925002377/8.0), - REAL_CONST(132885.92571429166/8.0), - REAL_CONST(132911.38339776811/8.0), - REAL_CONST(132936.84230033628/8.0), - REAL_CONST(132962.30242187946/8.0), - REAL_CONST(132987.76376228096/8.0), - REAL_CONST(133013.22632142407/8.0), - REAL_CONST(133038.69009919214/8.0), - REAL_CONST(133064.15509546854/8.0), - REAL_CONST(133089.62131013666/8.0), - REAL_CONST(133115.08874307995/8.0), - REAL_CONST(133140.55739418184/8.0), - REAL_CONST(133166.02726332581/8.0), - REAL_CONST(133191.49835039541/8.0), - REAL_CONST(133216.97065527414/8.0), - REAL_CONST(133242.44417784561/8.0), - REAL_CONST(133267.91891799335/8.0), - REAL_CONST(133293.39487560102/8.0), - REAL_CONST(133318.87205055228/8.0), - REAL_CONST(133344.35044273079/8.0), - REAL_CONST(133369.83005202023/8.0), - REAL_CONST(133395.31087830439/8.0), - REAL_CONST(133420.79292146701/8.0), - REAL_CONST(133446.27618139185/8.0), - REAL_CONST(133471.76065796276/8.0), - REAL_CONST(133497.24635106357/8.0), - REAL_CONST(133522.73326057816/8.0), - REAL_CONST(133548.22138639039/8.0), - REAL_CONST(133573.71072838426/8.0), - REAL_CONST(133599.20128644365/8.0), - REAL_CONST(133624.69306045261/8.0), - REAL_CONST(133650.1860502951/8.0), - REAL_CONST(133675.68025585517/8.0), - REAL_CONST(133701.1756770169/8.0), - REAL_CONST(133726.67231366437/8.0), - REAL_CONST(133752.17016568172/8.0), - REAL_CONST(133777.66923295305/8.0), - REAL_CONST(133803.16951536259/8.0), - REAL_CONST(133828.67101279454/8.0), - REAL_CONST(133854.17372513309/8.0), - REAL_CONST(133879.67765226253/8.0), - REAL_CONST(133905.18279406714/8.0), - REAL_CONST(133930.68915043125/8.0), - REAL_CONST(133956.19672123916/8.0), - REAL_CONST(133981.70550637526/8.0), - REAL_CONST(134007.21550572399/8.0), - REAL_CONST(134032.7267191697/8.0), - REAL_CONST(134058.23914659687/8.0), - REAL_CONST(134083.75278789/8.0), - REAL_CONST(134109.26764293358/8.0), - REAL_CONST(134134.78371161217/8.0), - REAL_CONST(134160.30099381026/8.0), - REAL_CONST(134185.8194894125/8.0), - REAL_CONST(134211.33919830353/8.0), - REAL_CONST(134236.8601203679/8.0), - REAL_CONST(134262.38225549037/8.0), - REAL_CONST(134287.90560355558/8.0), - REAL_CONST(134313.43016444831/8.0), - REAL_CONST(134338.95593805326/8.0), - REAL_CONST(134364.48292425525/8.0), - REAL_CONST(134390.01112293909/8.0), - REAL_CONST(134415.54053398955/8.0), - REAL_CONST(134441.07115729159/8.0), - REAL_CONST(134466.60299273001/8.0), - REAL_CONST(134492.1360401898/8.0), - REAL_CONST(134517.67029955584/8.0), - REAL_CONST(134543.20577071316/8.0), - REAL_CONST(134568.74245354676/8.0), - REAL_CONST(134594.28034794159/8.0), - REAL_CONST(134619.81945378278/8.0), - REAL_CONST(134645.35977095537/8.0), - REAL_CONST(134670.90129934452/8.0), - REAL_CONST(134696.4440388353/8.0), - REAL_CONST(134721.98798931291/8.0), - REAL_CONST(134747.53315066252/8.0), - REAL_CONST(134773.07952276937/8.0), - REAL_CONST(134798.62710551871/8.0), - REAL_CONST(134824.17589879577/8.0), - REAL_CONST(134849.72590248589/8.0), - REAL_CONST(134875.27711647438/8.0), - REAL_CONST(134900.82954064661/8.0), - REAL_CONST(134926.38317488792/8.0), - REAL_CONST(134951.93801908373/8.0), - REAL_CONST(134977.49407311951/8.0), - REAL_CONST(135003.05133688069/8.0), - REAL_CONST(135028.60981025276/8.0), - REAL_CONST(135054.16949312127/8.0), - REAL_CONST(135079.73038537172/8.0), - REAL_CONST(135105.29248688967/8.0), - REAL_CONST(135130.85579756077/8.0), - REAL_CONST(135156.42031727062/8.0), - REAL_CONST(135181.98604590484/8.0), - REAL_CONST(135207.55298334916/8.0), - REAL_CONST(135233.12112948924/8.0), - REAL_CONST(135258.69048421088/8.0), - REAL_CONST(135284.26104739975/8.0), - REAL_CONST(135309.83281894168/8.0), - REAL_CONST(135335.4057987225/8.0), - REAL_CONST(135360.97998662802/8.0), - REAL_CONST(135386.55538254412/8.0), - REAL_CONST(135412.13198635669/8.0), - REAL_CONST(135437.70979795168/8.0), - REAL_CONST(135463.28881721498/8.0), - REAL_CONST(135488.86904403262/8.0), - REAL_CONST(135514.45047829056/8.0), - REAL_CONST(135540.03311987486/8.0), - REAL_CONST(135565.61696867159/8.0), - REAL_CONST(135591.20202456677/8.0), - REAL_CONST(135616.78828744654/8.0), - REAL_CONST(135642.37575719706/8.0), - REAL_CONST(135667.96443370447/8.0), - REAL_CONST(135693.55431685498/8.0), - REAL_CONST(135719.14540653475/8.0), - REAL_CONST(135744.73770263011/8.0), - REAL_CONST(135770.33120502727/8.0), - REAL_CONST(135795.92591361253/8.0), - REAL_CONST(135821.52182827223/8.0), - REAL_CONST(135847.11894889272/8.0), - REAL_CONST(135872.7172753604/8.0), - REAL_CONST(135898.31680756161/8.0), - REAL_CONST(135923.91754538284/8.0), - REAL_CONST(135949.51948871053/8.0), - REAL_CONST(135975.12263743114/8.0), - REAL_CONST(136000.72699143123/8.0), - REAL_CONST(136026.33255059729/8.0), - REAL_CONST(136051.93931481591/8.0), - REAL_CONST(136077.54728397369/8.0), - REAL_CONST(136103.15645795723/8.0), - REAL_CONST(136128.76683665317/8.0), - REAL_CONST(136154.37841994822/8.0), - REAL_CONST(136179.99120772901/8.0), - REAL_CONST(136205.60519988232/8.0), - REAL_CONST(136231.2203962949/8.0), - REAL_CONST(136256.83679685349/8.0), - REAL_CONST(136282.45440144493/8.0), - REAL_CONST(136308.07320995603/8.0), - REAL_CONST(136333.69322227367/8.0), - REAL_CONST(136359.31443828469/8.0), - REAL_CONST(136384.93685787608/8.0), - REAL_CONST(136410.56048093468/8.0), - REAL_CONST(136436.18530734754/8.0), - REAL_CONST(136461.81133700156/8.0), - REAL_CONST(136487.43856978384/8.0), - REAL_CONST(136513.06700558143/8.0), - REAL_CONST(136538.6966442813/8.0), - REAL_CONST(136564.32748577066/8.0), - REAL_CONST(136589.95952993655/8.0), - REAL_CONST(136615.59277666616/8.0), - REAL_CONST(136641.22722584667/8.0), - REAL_CONST(136666.86287736523/8.0), - REAL_CONST(136692.49973110916/8.0), - REAL_CONST(136718.13778696564/8.0), - REAL_CONST(136743.77704482197/8.0), - REAL_CONST(136769.41750456547/8.0), - REAL_CONST(136795.05916608346/8.0), - REAL_CONST(136820.70202926331/8.0), - REAL_CONST(136846.34609399244/8.0), - REAL_CONST(136871.99136015819/8.0), - REAL_CONST(136897.63782764805/8.0), - REAL_CONST(136923.28549634948/8.0), - REAL_CONST(136948.93436614997/8.0), - REAL_CONST(136974.58443693706/8.0), - REAL_CONST(137000.23570859825/8.0), - REAL_CONST(137025.88818102115/8.0), - REAL_CONST(137051.54185409332/8.0), - REAL_CONST(137077.19672770242/8.0), - REAL_CONST(137102.85280173609/8.0), - REAL_CONST(137128.51007608202/8.0), - REAL_CONST(137154.16855062786/8.0), - REAL_CONST(137179.82822526142/8.0), - REAL_CONST(137205.48909987041/8.0), - REAL_CONST(137231.15117434258/8.0), - REAL_CONST(137256.8144485658/8.0), - REAL_CONST(137282.47892242789/8.0), - REAL_CONST(137308.14459581667/8.0), - REAL_CONST(137333.81146862009/8.0), - REAL_CONST(137359.47954072602/8.0), - REAL_CONST(137385.14881202241/8.0), - REAL_CONST(137410.81928239719/8.0), - REAL_CONST(137436.49095173844/8.0), - REAL_CONST(137462.16381993407/8.0), - REAL_CONST(137487.83788687221/8.0), - REAL_CONST(137513.51315244089/8.0), - REAL_CONST(137539.18961652822/8.0), - REAL_CONST(137564.86727902229/8.0), - REAL_CONST(137590.54613981131/8.0), - REAL_CONST(137616.22619878338/8.0), - REAL_CONST(137641.90745582676/8.0), - REAL_CONST(137667.58991082967/8.0), - REAL_CONST(137693.27356368033/8.0), - REAL_CONST(137718.95841426702/8.0), - REAL_CONST(137744.64446247809/8.0), - REAL_CONST(137770.33170820182/8.0), - REAL_CONST(137796.02015132661/8.0), - REAL_CONST(137821.70979174081/8.0), - REAL_CONST(137847.40062933284/8.0), - REAL_CONST(137873.09266399115/8.0), - REAL_CONST(137898.78589560417/8.0), - REAL_CONST(137924.48032406042/8.0), - REAL_CONST(137950.17594924837/8.0), - REAL_CONST(137975.8727710566/8.0), - REAL_CONST(138001.57078937365/8.0), - REAL_CONST(138027.27000408815/8.0), - REAL_CONST(138052.97041508864/8.0), - REAL_CONST(138078.67202226384/8.0), - REAL_CONST(138104.3748255024/8.0), - REAL_CONST(138130.07882469296/8.0), - REAL_CONST(138155.78401972432/8.0), - REAL_CONST(138181.49041048516/8.0), - REAL_CONST(138207.1979968643/8.0), - REAL_CONST(138232.9067787505/8.0), - REAL_CONST(138258.61675603263/8.0), - REAL_CONST(138284.32792859949/8.0), - REAL_CONST(138310.04029633995/8.0), - REAL_CONST(138335.75385914298/8.0), - REAL_CONST(138361.46861689744/8.0), - REAL_CONST(138387.18456949232/8.0), - REAL_CONST(138412.90171681659/8.0), - REAL_CONST(138438.62005875923/8.0), - REAL_CONST(138464.33959520931/8.0), - REAL_CONST(138490.06032605586/8.0), - REAL_CONST(138515.78225118798/8.0), - REAL_CONST(138541.50537049473/8.0), - REAL_CONST(138567.2296838653/8.0), - REAL_CONST(138592.95519118884/8.0), - REAL_CONST(138618.68189235451/8.0), - REAL_CONST(138644.40978725153/8.0), - REAL_CONST(138670.13887576913/8.0), - REAL_CONST(138695.86915779658/8.0), - REAL_CONST(138721.60063322316/8.0), - REAL_CONST(138747.33330193823/8.0), - REAL_CONST(138773.06716383106/8.0), - REAL_CONST(138798.80221879104/8.0), - REAL_CONST(138824.53846670757/8.0), - REAL_CONST(138850.27590747006/8.0), - REAL_CONST(138876.01454096794/8.0), - REAL_CONST(138901.7543670907/8.0), - REAL_CONST(138927.49538572782/8.0), - REAL_CONST(138953.2375967688/8.0), - REAL_CONST(138978.9810001032/8.0), - REAL_CONST(139004.72559562061/8.0), - REAL_CONST(139030.47138321059/8.0), - REAL_CONST(139056.2183627628/8.0), - REAL_CONST(139081.96653416683/8.0), - REAL_CONST(139107.71589731239/8.0), - REAL_CONST(139133.46645208917/8.0), - REAL_CONST(139159.21819838689/8.0), - REAL_CONST(139184.97113609532/8.0), - REAL_CONST(139210.72526510421/8.0), - REAL_CONST(139236.48058530336/8.0), - REAL_CONST(139262.23709658257/8.0), - REAL_CONST(139287.99479883176/8.0), - REAL_CONST(139313.75369194071/8.0), - REAL_CONST(139339.51377579942/8.0), - REAL_CONST(139365.27505029776/8.0), - REAL_CONST(139391.03751532568/8.0), - REAL_CONST(139416.80117077316/8.0), - REAL_CONST(139442.56601653024/8.0), - REAL_CONST(139468.33205248689/8.0), - REAL_CONST(139494.09927853322/8.0), - REAL_CONST(139519.86769455927/8.0), - REAL_CONST(139545.63730045516/8.0), - REAL_CONST(139571.408096111/8.0), - REAL_CONST(139597.18008141697/8.0), - REAL_CONST(139622.95325626322/8.0), - REAL_CONST(139648.72762054001/8.0), - REAL_CONST(139674.5031741375/8.0), - REAL_CONST(139700.27991694602/8.0), - REAL_CONST(139726.05784885579/8.0), - REAL_CONST(139751.83696975713/8.0), - REAL_CONST(139777.61727954043/8.0), - REAL_CONST(139803.39877809596/8.0), - REAL_CONST(139829.18146531415/8.0), - REAL_CONST(139854.96534108539/8.0), - REAL_CONST(139880.75040530015/8.0), - REAL_CONST(139906.53665784886/8.0), - REAL_CONST(139932.32409862199/8.0), - REAL_CONST(139958.11272751007/8.0), - REAL_CONST(139983.90254440365/8.0), - REAL_CONST(140009.69354919327/8.0), - REAL_CONST(140035.48574176949/8.0), - REAL_CONST(140061.27912202294/8.0), - REAL_CONST(140087.07368984428/8.0), - REAL_CONST(140112.86944512415/8.0), - REAL_CONST(140138.66638775321/8.0), - REAL_CONST(140164.4645176222/8.0), - REAL_CONST(140190.26383462184/8.0), - REAL_CONST(140216.06433864293/8.0), - REAL_CONST(140241.86602957622/8.0), - REAL_CONST(140267.66890731253/8.0), - REAL_CONST(140293.47297174268/8.0), - REAL_CONST(140319.27822275754/8.0), - REAL_CONST(140345.08466024802/8.0), - REAL_CONST(140370.89228410498/8.0), - REAL_CONST(140396.70109421943/8.0), - REAL_CONST(140422.51109048226/8.0), - REAL_CONST(140448.32227278448/8.0), - REAL_CONST(140474.13464101712/8.0), - REAL_CONST(140499.94819507122/8.0), - REAL_CONST(140525.76293483781/8.0), - REAL_CONST(140551.57886020801/8.0), - REAL_CONST(140577.3959710729/8.0), - REAL_CONST(140603.21426732364/8.0), - REAL_CONST(140629.03374885136/8.0), - REAL_CONST(140654.85441554731/8.0), - REAL_CONST(140680.67626730262/8.0), - REAL_CONST(140706.49930400858/8.0), - REAL_CONST(140732.32352555645/8.0), - REAL_CONST(140758.1489318375/8.0), - REAL_CONST(140783.97552274304/8.0), - REAL_CONST(140809.80329816442/8.0), - REAL_CONST(140835.63225799298/8.0), - REAL_CONST(140861.46240212015/8.0), - REAL_CONST(140887.29373043729/8.0), - REAL_CONST(140913.12624283586/8.0), - REAL_CONST(140938.95993920733/8.0), - REAL_CONST(140964.79481944317/8.0), - REAL_CONST(140990.63088343487/8.0), - REAL_CONST(141016.46813107401/8.0), - REAL_CONST(141042.30656225214/8.0), - REAL_CONST(141068.14617686081/8.0), - REAL_CONST(141093.98697479168/8.0), - REAL_CONST(141119.82895593636/8.0), - REAL_CONST(141145.6721201865/8.0), - REAL_CONST(141171.51646743377/8.0), - REAL_CONST(141197.36199756994/8.0), - REAL_CONST(141223.20871048668/8.0), - REAL_CONST(141249.05660607578/8.0), - REAL_CONST(141274.90568422904/8.0), - REAL_CONST(141300.75594483822/8.0), - REAL_CONST(141326.6073877952/8.0), - REAL_CONST(141352.4600129918/8.0), - REAL_CONST(141378.31382031992/8.0), - REAL_CONST(141404.16880967148/8.0), - REAL_CONST(141430.02498093838/8.0), - REAL_CONST(141455.8823340126/8.0), - REAL_CONST(141481.74086878612/8.0), - REAL_CONST(141507.60058515094/8.0), - REAL_CONST(141533.46148299909/8.0), - REAL_CONST(141559.32356222265/8.0), - REAL_CONST(141585.18682271364/8.0), - REAL_CONST(141611.05126436421/8.0), - REAL_CONST(141636.9168870665/8.0), - REAL_CONST(141662.78369071262/8.0), - REAL_CONST(141688.65167519479/8.0), - REAL_CONST(141714.5208404052/8.0), - REAL_CONST(141740.39118623605/8.0), - REAL_CONST(141766.26271257963/8.0), - REAL_CONST(141792.1354193282/8.0), - REAL_CONST(141818.00930637406/8.0), - REAL_CONST(141843.88437360956/8.0), - REAL_CONST(141869.760620927/8.0), - REAL_CONST(141895.6380482188/8.0), - REAL_CONST(141921.51665537735/8.0), - REAL_CONST(141947.39644229505/8.0), - REAL_CONST(141973.27740886438/8.0), - REAL_CONST(141999.15955497778/8.0), - REAL_CONST(142025.04288052776/8.0), - REAL_CONST(142050.92738540689/8.0), - REAL_CONST(142076.81306950765/8.0), - REAL_CONST(142102.69993272264/8.0), - REAL_CONST(142128.58797494444/8.0), - REAL_CONST(142154.47719606571/8.0), - REAL_CONST(142180.36759597904/8.0), - REAL_CONST(142206.25917457714/8.0), - REAL_CONST(142232.15193175265/8.0), - REAL_CONST(142258.04586739838/8.0), - REAL_CONST(142283.94098140698/8.0), - REAL_CONST(142309.83727367126/8.0), - REAL_CONST(142335.73474408401/8.0), - REAL_CONST(142361.63339253806/8.0), - REAL_CONST(142387.5332189262/8.0), - REAL_CONST(142413.43422314132/8.0), - REAL_CONST(142439.33640507635/8.0), - REAL_CONST(142465.23976462413/8.0), - REAL_CONST(142491.14430167765/8.0), - REAL_CONST(142517.05001612983/8.0), - REAL_CONST(142542.95690787368/8.0), - REAL_CONST(142568.86497680223/8.0), - REAL_CONST(142594.77422280848/8.0), - REAL_CONST(142620.68464578551/8.0), - REAL_CONST(142646.5962456264/8.0), - REAL_CONST(142672.50902222423/8.0), - REAL_CONST(142698.42297547215/8.0), - REAL_CONST(142724.33810526333/8.0), - REAL_CONST(142750.25441149093/8.0), - REAL_CONST(142776.17189404817/8.0), - REAL_CONST(142802.09055282827/8.0), - REAL_CONST(142828.01038772447/8.0), - REAL_CONST(142853.93139863008/8.0), - REAL_CONST(142879.85358543837/8.0), - REAL_CONST(142905.77694804268/8.0), - REAL_CONST(142931.70148633636/8.0), - REAL_CONST(142957.62720021277/8.0), - REAL_CONST(142983.55408956532/8.0), - REAL_CONST(143009.48215428743/8.0), - REAL_CONST(143035.41139427255/8.0), - REAL_CONST(143061.34180941415/8.0), - REAL_CONST(143087.27339960571/8.0), - REAL_CONST(143113.20616474075/8.0), - REAL_CONST(143139.14010471283/8.0), - REAL_CONST(143165.07521941551/8.0), - REAL_CONST(143191.01150874238/8.0), - REAL_CONST(143216.94897258704/8.0), - REAL_CONST(143242.88761084314/8.0), - REAL_CONST(143268.82742340435/8.0), - REAL_CONST(143294.76841016437/8.0), - REAL_CONST(143320.71057101688/8.0), - REAL_CONST(143346.65390585564/8.0), - REAL_CONST(143372.59841457437/8.0), - REAL_CONST(143398.54409706692/8.0), - REAL_CONST(143424.49095322701/8.0), - REAL_CONST(143450.43898294857/8.0), - REAL_CONST(143476.38818612538/8.0), - REAL_CONST(143502.33856265133/8.0), - REAL_CONST(143528.29011242036/8.0), - REAL_CONST(143554.24283532638/8.0), - REAL_CONST(143580.19673126334/8.0), - REAL_CONST(143606.1518001252/8.0), - REAL_CONST(143632.10804180597/8.0), - REAL_CONST(143658.06545619969/8.0), - REAL_CONST(143684.02404320039/8.0), - REAL_CONST(143709.98380270213/8.0), - REAL_CONST(143735.944734599/8.0), - REAL_CONST(143761.90683878519/8.0), - REAL_CONST(143787.87011515474/8.0), - REAL_CONST(143813.83456360188/8.0), - REAL_CONST(143839.8001840208/8.0), - REAL_CONST(143865.76697630569/8.0), - REAL_CONST(143891.73494035081/8.0), - REAL_CONST(143917.7040760504/8.0), - REAL_CONST(143943.67438329876/8.0), - REAL_CONST(143969.6458619902/8.0), - REAL_CONST(143995.61851201905/8.0), - REAL_CONST(144021.59233327967/8.0), - REAL_CONST(144047.56732566646/8.0), - REAL_CONST(144073.54348907378/8.0), - REAL_CONST(144099.52082339607/8.0), - REAL_CONST(144125.49932852783/8.0), - REAL_CONST(144151.4790043635/8.0), - REAL_CONST(144177.45985079758/8.0), - REAL_CONST(144203.44186772458/8.0), - REAL_CONST(144229.42505503909/8.0), - REAL_CONST(144255.40941263564/8.0), - REAL_CONST(144281.39494040885/8.0), - REAL_CONST(144307.38163825331/8.0), - REAL_CONST(144333.36950606373/8.0), - REAL_CONST(144359.35854373468/8.0), - REAL_CONST(144385.34875116093/8.0), - REAL_CONST(144411.34012823718/8.0), - REAL_CONST(144437.33267485813/8.0), - REAL_CONST(144463.32639091855/8.0), - REAL_CONST(144489.32127631325/8.0), - REAL_CONST(144515.31733093705/8.0), - REAL_CONST(144541.31455468474/8.0), - REAL_CONST(144567.3129474512/8.0), - REAL_CONST(144593.3125091313/8.0), - REAL_CONST(144619.31323961995/8.0), - REAL_CONST(144645.31513881206/8.0), - REAL_CONST(144671.31820660262/8.0), - REAL_CONST(144697.32244288657/8.0), - REAL_CONST(144723.32784755889/8.0), - REAL_CONST(144749.33442051467/8.0), - REAL_CONST(144775.34216164888/8.0), - REAL_CONST(144801.35107085665/8.0), - REAL_CONST(144827.36114803303/8.0), - REAL_CONST(144853.37239307314/8.0), - REAL_CONST(144879.38480587213/8.0), - REAL_CONST(144905.39838632516/8.0), - REAL_CONST(144931.41313432742/8.0), - REAL_CONST(144957.4290497741/8.0), - REAL_CONST(144983.44613256046/8.0), - REAL_CONST(145009.46438258173/8.0), - REAL_CONST(145035.48379973322/8.0), - REAL_CONST(145061.50438391021/8.0), - REAL_CONST(145087.52613500805/8.0), - REAL_CONST(145113.54905292206/8.0), - REAL_CONST(145139.57313754765/8.0), - REAL_CONST(145165.59838878017/8.0), - REAL_CONST(145191.62480651509/8.0), - REAL_CONST(145217.65239064783/8.0), - REAL_CONST(145243.68114107384/8.0), - REAL_CONST(145269.71105768863/8.0), - REAL_CONST(145295.74214038774/8.0), - REAL_CONST(145321.77438906668/8.0), - REAL_CONST(145347.80780362099/8.0), - REAL_CONST(145373.84238394629/8.0), - REAL_CONST(145399.87812993818/8.0), - REAL_CONST(145425.91504149229/8.0), - REAL_CONST(145451.95311850426/8.0), - REAL_CONST(145477.9923608698/8.0), - REAL_CONST(145504.03276848458/8.0), - REAL_CONST(145530.07434124436/8.0), - REAL_CONST(145556.11707904484/8.0), - REAL_CONST(145582.16098178181/8.0), - REAL_CONST(145608.20604935108/8.0), - REAL_CONST(145634.25228164849/8.0), - REAL_CONST(145660.29967856981/8.0), - REAL_CONST(145686.34824001096/8.0), - REAL_CONST(145712.39796586783/8.0), - REAL_CONST(145738.4488560363/8.0), - REAL_CONST(145764.50091041232/8.0), - REAL_CONST(145790.55412889185/8.0), - REAL_CONST(145816.60851137087/8.0), - REAL_CONST(145842.66405774537/8.0), - REAL_CONST(145868.72076791141/8.0), - REAL_CONST(145894.77864176501/8.0), - REAL_CONST(145920.83767920226/8.0), - REAL_CONST(145946.89788011924/8.0), - REAL_CONST(145972.95924441208/8.0), - REAL_CONST(145999.02177197693/8.0), - REAL_CONST(146025.08546270995/8.0), - REAL_CONST(146051.15031650732/8.0), - REAL_CONST(146077.21633326527/8.0), - REAL_CONST(146103.28351288004/8.0), - REAL_CONST(146129.35185524789/8.0), - REAL_CONST(146155.42136026506/8.0), - REAL_CONST(146181.49202782792/8.0), - REAL_CONST(146207.56385783272/8.0), - REAL_CONST(146233.63685017588/8.0), - REAL_CONST(146259.71100475377/8.0), - REAL_CONST(146285.78632146274/8.0), - REAL_CONST(146311.86280019928/8.0), - REAL_CONST(146337.94044085976/8.0), - REAL_CONST(146364.01924334071/8.0), - REAL_CONST(146390.09920753856/8.0), - REAL_CONST(146416.18033334985/8.0), - REAL_CONST(146442.26262067116/8.0), - REAL_CONST(146468.34606939898/8.0), - REAL_CONST(146494.43067942993/8.0), - REAL_CONST(146520.51645066062/8.0), - REAL_CONST(146546.60338298764/8.0), - REAL_CONST(146572.69147630769/8.0), - REAL_CONST(146598.78073051744/8.0), - REAL_CONST(146624.87114551352/8.0), - REAL_CONST(146650.96272119274/8.0), - REAL_CONST(146677.05545745179/8.0), - REAL_CONST(146703.14935418745/8.0), - REAL_CONST(146729.2444112965/8.0), - REAL_CONST(146755.34062867577/8.0), - REAL_CONST(146781.43800622207/8.0), - REAL_CONST(146807.53654383228/8.0), - REAL_CONST(146833.63624140329/8.0), - REAL_CONST(146859.73709883197/8.0), - REAL_CONST(146885.83911601527/8.0), - REAL_CONST(146911.94229285014/8.0), - REAL_CONST(146938.04662923355/8.0), - REAL_CONST(146964.15212506248/8.0), - REAL_CONST(146990.25878023397/8.0), - REAL_CONST(147016.36659464505/8.0), - REAL_CONST(147042.47556819281/8.0), - REAL_CONST(147068.58570077427/8.0), - REAL_CONST(147094.6969922866/8.0), - REAL_CONST(147120.80944262692/8.0), - REAL_CONST(147146.92305169237/8.0), - REAL_CONST(147173.03781938017/8.0), - REAL_CONST(147199.15374558745/8.0), - REAL_CONST(147225.27083021149/8.0), - REAL_CONST(147251.38907314953/8.0), - REAL_CONST(147277.50847429881/8.0), - REAL_CONST(147303.62903355664/8.0), - REAL_CONST(147329.75075082036/8.0), - REAL_CONST(147355.87362598727/8.0), - REAL_CONST(147381.99765895473/8.0), - REAL_CONST(147408.12284962015/8.0), - REAL_CONST(147434.24919788091/8.0), - REAL_CONST(147460.37670363448/8.0), - REAL_CONST(147486.50536677826/8.0), - REAL_CONST(147512.63518720976/8.0), - REAL_CONST(147538.76616482646/8.0), - REAL_CONST(147564.89829952587/8.0), - REAL_CONST(147591.03159120557/8.0), - REAL_CONST(147617.16603976308/8.0), - REAL_CONST(147643.30164509601/8.0), - REAL_CONST(147669.43840710199/8.0), - REAL_CONST(147695.57632567859/8.0), - REAL_CONST(147721.71540072354/8.0), - REAL_CONST(147747.85563213445/8.0), - REAL_CONST(147773.99701980909/8.0), - REAL_CONST(147800.13956364512/8.0), - REAL_CONST(147826.28326354033/8.0), - REAL_CONST(147852.42811939248/8.0), - REAL_CONST(147878.57413109933/8.0), - REAL_CONST(147904.72129855872/8.0), - REAL_CONST(147930.86962166851/8.0), - REAL_CONST(147957.01910032652/8.0), - REAL_CONST(147983.16973443062/8.0), - REAL_CONST(148009.32152387875/8.0), - REAL_CONST(148035.47446856883/8.0), - REAL_CONST(148061.62856839882/8.0), - REAL_CONST(148087.78382326665/8.0), - REAL_CONST(148113.94023307035/8.0), - REAL_CONST(148140.09779770792/8.0), - REAL_CONST(148166.25651707739/8.0), - REAL_CONST(148192.41639107687/8.0), - REAL_CONST(148218.57741960438/8.0), - REAL_CONST(148244.73960255808/8.0), - REAL_CONST(148270.90293983606/8.0), - REAL_CONST(148297.0674313365/8.0), - REAL_CONST(148323.23307695755/8.0), - REAL_CONST(148349.39987659742/8.0), - REAL_CONST(148375.56783015432/8.0), - REAL_CONST(148401.73693752653/8.0), - REAL_CONST(148427.90719861226/8.0), - REAL_CONST(148454.07861330983/8.0), - REAL_CONST(148480.25118151752/8.0), - REAL_CONST(148506.42490313368/8.0), - REAL_CONST(148532.59977805667/8.0), - REAL_CONST(148558.77580618486/8.0), - REAL_CONST(148584.95298741665/8.0), - REAL_CONST(148611.13132165043/8.0), - REAL_CONST(148637.31080878471/8.0), - REAL_CONST(148663.49144871789/8.0), - REAL_CONST(148689.6732413485/8.0), - REAL_CONST(148715.85618657502/8.0), - REAL_CONST(148742.040284296/8.0), - REAL_CONST(148768.22553440998/8.0), - REAL_CONST(148794.41193681557/8.0), - REAL_CONST(148820.59949141133/8.0), - REAL_CONST(148846.78819809589/8.0), - REAL_CONST(148872.97805676793/8.0), - REAL_CONST(148899.16906732606/8.0), - REAL_CONST(148925.36122966901/8.0), - REAL_CONST(148951.55454369547/8.0), - REAL_CONST(148977.74900930419/8.0), - REAL_CONST(149003.9446263939/8.0), - REAL_CONST(149030.1413948634/8.0), - REAL_CONST(149056.33931461151/8.0), - REAL_CONST(149082.53838553699/8.0), - REAL_CONST(149108.73860753875/8.0), - REAL_CONST(149134.9399805156/8.0), - REAL_CONST(149161.14250436646/8.0), - REAL_CONST(149187.34617899026/8.0), - REAL_CONST(149213.5510042859/8.0), - REAL_CONST(149239.75698015234/8.0), - REAL_CONST(149265.96410648854/8.0), - REAL_CONST(149292.17238319354/8.0), - REAL_CONST(149318.38181016635/8.0), - REAL_CONST(149344.59238730598/8.0), - REAL_CONST(149370.80411451156/8.0), - REAL_CONST(149397.01699168212/8.0), - REAL_CONST(149423.23101871679/8.0), - REAL_CONST(149449.44619551473/8.0), - REAL_CONST(149475.66252197503/8.0), - REAL_CONST(149501.87999799693/8.0), - REAL_CONST(149528.0986234796/8.0), - REAL_CONST(149554.31839832227/8.0), - REAL_CONST(149580.53932242419/8.0), - REAL_CONST(149606.76139568459/8.0), - REAL_CONST(149632.98461800278/8.0), - REAL_CONST(149659.20898927809/8.0), - REAL_CONST(149685.43450940982/8.0), - REAL_CONST(149711.66117829733/8.0), - REAL_CONST(149737.88899584001/8.0), - REAL_CONST(149764.11796193724/8.0), - REAL_CONST(149790.34807648844/8.0), - REAL_CONST(149816.57933939309/8.0), - REAL_CONST(149842.81175055061/8.0), - REAL_CONST(149869.04530986046/8.0), - REAL_CONST(149895.28001722222/8.0), - REAL_CONST(149921.51587253538/8.0), - REAL_CONST(149947.75287569952/8.0), - REAL_CONST(149973.99102661415/8.0), - REAL_CONST(150000.23032517891/8.0), - REAL_CONST(150026.47077129342/8.0), - REAL_CONST(150052.71236485732/8.0), - REAL_CONST(150078.95510577026/8.0), - REAL_CONST(150105.1989939319/8.0), - REAL_CONST(150131.444029242/8.0), - REAL_CONST(150157.69021160025/8.0), - REAL_CONST(150183.93754090639/8.0), - REAL_CONST(150210.18601706024/8.0), - REAL_CONST(150236.43563996154/8.0), - REAL_CONST(150262.68640951012/8.0), - REAL_CONST(150288.93832560582/8.0), - REAL_CONST(150315.19138814852/8.0), - REAL_CONST(150341.44559703805/8.0), - REAL_CONST(150367.70095217437/8.0), - REAL_CONST(150393.95745345735/8.0), - REAL_CONST(150420.21510078697/8.0), - REAL_CONST(150446.47389406321/8.0), - REAL_CONST(150472.73383318601/8.0), - REAL_CONST(150498.99491805542/8.0), - REAL_CONST(150525.25714857146/8.0), - REAL_CONST(150551.52052463419/8.0), - REAL_CONST(150577.78504614369/8.0), - REAL_CONST(150604.05071300003/8.0), - REAL_CONST(150630.31752510337/8.0), - REAL_CONST(150656.58548235384/8.0), - REAL_CONST(150682.85458465159/8.0), - REAL_CONST(150709.1248318968/8.0), - REAL_CONST(150735.39622398972/8.0), - REAL_CONST(150761.66876083051/8.0), - REAL_CONST(150787.9424423195/8.0), - REAL_CONST(150814.21726835691/8.0), - REAL_CONST(150840.49323884305/8.0), - REAL_CONST(150866.77035367821/8.0), - REAL_CONST(150893.04861276277/8.0), - REAL_CONST(150919.32801599705/8.0), - REAL_CONST(150945.60856328148/8.0), - REAL_CONST(150971.89025451642/8.0), - REAL_CONST(150998.17308960229/8.0), - REAL_CONST(151024.45706843957/8.0), - REAL_CONST(151050.74219092872/8.0), - REAL_CONST(151077.02845697021/8.0), - REAL_CONST(151103.31586646455/8.0), - REAL_CONST(151129.60441931229/8.0), - REAL_CONST(151155.894115414/8.0), - REAL_CONST(151182.1849546702/8.0), - REAL_CONST(151208.47693698155/8.0), - REAL_CONST(151234.77006224863/8.0), - REAL_CONST(151261.06433037209/8.0), - REAL_CONST(151287.35974125259/8.0), - REAL_CONST(151313.65629479082/8.0), - REAL_CONST(151339.95399088747/8.0), - REAL_CONST(151366.25282944329/8.0), - REAL_CONST(151392.55281035902/8.0), - REAL_CONST(151418.85393353543/8.0), - REAL_CONST(151445.1561988733/8.0), - REAL_CONST(151471.45960627345/8.0), - REAL_CONST(151497.76415563675/8.0), - REAL_CONST(151524.06984686397/8.0), - REAL_CONST(151550.37667985607/8.0), - REAL_CONST(151576.68465451393/8.0), - REAL_CONST(151602.99377073845/8.0), - REAL_CONST(151629.30402843058/8.0), - REAL_CONST(151655.61542749128/8.0), - REAL_CONST(151681.92796782157/8.0), - REAL_CONST(151708.24164932242/8.0), - REAL_CONST(151734.55647189484/8.0), - REAL_CONST(151760.87243543993/8.0), - REAL_CONST(151787.18953985872/8.0), - REAL_CONST(151813.50778505235/8.0), - REAL_CONST(151839.82717092187/8.0), - REAL_CONST(151866.14769736846/8.0), - REAL_CONST(151892.46936429327/8.0), - REAL_CONST(151918.79217159748/8.0), - REAL_CONST(151945.11611918229/8.0), - REAL_CONST(151971.44120694889/8.0), - REAL_CONST(151997.76743479856/8.0), - REAL_CONST(152024.09480263255/8.0), - REAL_CONST(152050.42331035214/8.0), - REAL_CONST(152076.75295785864/8.0), - REAL_CONST(152103.08374505339/8.0), - REAL_CONST(152129.41567183775/8.0), - REAL_CONST(152155.74873811303/8.0), - REAL_CONST(152182.08294378067/8.0), - REAL_CONST(152208.41828874208/8.0), - REAL_CONST(152234.75477289871/8.0), - REAL_CONST(152261.09239615197/8.0), - REAL_CONST(152287.43115840337/8.0), - REAL_CONST(152313.77105955439/8.0), - REAL_CONST(152340.11209950657/8.0), - REAL_CONST(152366.45427816146/8.0), - REAL_CONST(152392.79759542056/8.0), - REAL_CONST(152419.14205118554/8.0), - REAL_CONST(152445.48764535793/8.0), - REAL_CONST(152471.8343778394/8.0), - REAL_CONST(152498.18224853161/8.0), - REAL_CONST(152524.53125733617/8.0), - REAL_CONST(152550.88140415482/8.0), - REAL_CONST(152577.23268888926/8.0), - REAL_CONST(152603.58511144121/8.0), - REAL_CONST(152629.93867171241/8.0), - REAL_CONST(152656.29336960468/8.0), - REAL_CONST(152682.64920501978/8.0), - REAL_CONST(152709.00617785956/8.0), - REAL_CONST(152735.36428802583/8.0), - REAL_CONST(152761.72353542043/8.0), - REAL_CONST(152788.08391994529/8.0), - REAL_CONST(152814.44544150229/8.0), - REAL_CONST(152840.80809999333/8.0), - REAL_CONST(152867.17189532038/8.0), - REAL_CONST(152893.53682738543/8.0), - REAL_CONST(152919.90289609041/8.0), - REAL_CONST(152946.27010133737/8.0), - REAL_CONST(152972.63844302832/8.0), - REAL_CONST(152999.00792106529/8.0), - REAL_CONST(153025.37853535041/8.0), - REAL_CONST(153051.7502857857/8.0), - REAL_CONST(153078.12317227334/8.0), - REAL_CONST(153104.4971947154/8.0), - REAL_CONST(153130.8723530141/8.0), - REAL_CONST(153157.24864707157/8.0), - REAL_CONST(153183.62607679001/8.0), - REAL_CONST(153210.00464207167/8.0), - REAL_CONST(153236.38434281875/8.0), - REAL_CONST(153262.76517893354/8.0), - REAL_CONST(153289.14715031831/8.0), - REAL_CONST(153315.53025687535/8.0), - REAL_CONST(153341.91449850702/8.0), - REAL_CONST(153368.2998751156/8.0), - REAL_CONST(153394.68638660354/8.0), - REAL_CONST(153421.07403287315/8.0), - REAL_CONST(153447.46281382689/8.0), - REAL_CONST(153473.85272936718/8.0), - REAL_CONST(153500.24377939643/8.0), - REAL_CONST(153526.63596381716/8.0), - REAL_CONST(153553.02928253182/8.0), - REAL_CONST(153579.42373544298/8.0), - REAL_CONST(153605.81932245308/8.0), - REAL_CONST(153632.21604346478/8.0), - REAL_CONST(153658.61389838057/8.0), - REAL_CONST(153685.0128871031/8.0), - REAL_CONST(153711.41300953497/8.0), - REAL_CONST(153737.81426557881/8.0), - REAL_CONST(153764.21665513728/8.0), - REAL_CONST(153790.62017811305/8.0), - REAL_CONST(153817.02483440886/8.0), - REAL_CONST(153843.43062392739/8.0), - REAL_CONST(153869.83754657139/8.0), - REAL_CONST(153896.24560224367/8.0), - REAL_CONST(153922.65479084692/8.0), - REAL_CONST(153949.06511228404/8.0), - REAL_CONST(153975.4765664578/8.0), - REAL_CONST(154001.88915327107/8.0), - REAL_CONST(154028.30287262669/8.0), - REAL_CONST(154054.71772442761/8.0), - REAL_CONST(154081.13370857667/8.0), - REAL_CONST(154107.55082497682/8.0), - REAL_CONST(154133.96907353101/8.0), - REAL_CONST(154160.38845414223/8.0), - REAL_CONST(154186.80896671346/8.0), - REAL_CONST(154213.23061114774/8.0), - REAL_CONST(154239.65338734805/8.0), - REAL_CONST(154266.07729521746/8.0), - REAL_CONST(154292.50233465908/8.0), - REAL_CONST(154318.92850557598/8.0), - REAL_CONST(154345.35580787127/8.0), - REAL_CONST(154371.7842414481/8.0), - REAL_CONST(154398.21380620965/8.0), - REAL_CONST(154424.64450205903/8.0), - REAL_CONST(154451.07632889951/8.0), - REAL_CONST(154477.50928663427/8.0), - REAL_CONST(154503.94337516659/8.0), - REAL_CONST(154530.37859439969/8.0), - REAL_CONST(154556.81494423689/8.0), - REAL_CONST(154583.25242458144/8.0), - REAL_CONST(154609.69103533673/8.0), - REAL_CONST(154636.13077640603/8.0), - REAL_CONST(154662.57164769279/8.0), - REAL_CONST(154689.01364910032/8.0), - REAL_CONST(154715.45678053208/8.0), - REAL_CONST(154741.90104189145/8.0), - REAL_CONST(154768.34643308193/8.0), - REAL_CONST(154794.79295400696/8.0), - REAL_CONST(154821.24060457002/8.0), - REAL_CONST(154847.68938467462/8.0), - REAL_CONST(154874.13929422433/8.0), - REAL_CONST(154900.59033312264/8.0), - REAL_CONST(154927.04250127316/8.0), - REAL_CONST(154953.49579857948/8.0), - REAL_CONST(154979.95022494521/8.0), - REAL_CONST(155006.40578027396/8.0), - REAL_CONST(155032.86246446942/8.0), - REAL_CONST(155059.32027743524/8.0), - REAL_CONST(155085.77921907514/8.0), - REAL_CONST(155112.2392892928/8.0), - REAL_CONST(155138.70048799197/8.0), - REAL_CONST(155165.16281507642/8.0), - REAL_CONST(155191.62627044989/8.0), - REAL_CONST(155218.09085401625/8.0), - REAL_CONST(155244.55656567923/8.0), - REAL_CONST(155271.02340534274/8.0), - REAL_CONST(155297.49137291059/8.0), - REAL_CONST(155323.96046828668/8.0), - REAL_CONST(155350.4306913749/8.0), - REAL_CONST(155376.90204207919/8.0), - REAL_CONST(155403.37452030348/8.0), - REAL_CONST(155429.84812595171/8.0), - REAL_CONST(155456.32285892789/8.0), - REAL_CONST(155482.79871913602/8.0), - REAL_CONST(155509.27570648011/8.0), - REAL_CONST(155535.75382086422/8.0), - REAL_CONST(155562.23306219239/8.0), - REAL_CONST(155588.71343036872/8.0), - REAL_CONST(155615.19492529731/8.0), - REAL_CONST(155641.67754688227/8.0), - REAL_CONST(155668.16129502779/8.0), - REAL_CONST(155694.64616963797/8.0), - REAL_CONST(155721.13217061706/8.0), - REAL_CONST(155747.61929786921/8.0), - REAL_CONST(155774.10755129869/8.0), - REAL_CONST(155800.59693080973/8.0), - REAL_CONST(155827.08743630661/8.0), - REAL_CONST(155853.57906769359/8.0), - REAL_CONST(155880.07182487496/8.0), - REAL_CONST(155906.56570775513/8.0), - REAL_CONST(155933.06071623837/8.0), - REAL_CONST(155959.55685022907/8.0), - REAL_CONST(155986.05410963166/8.0), - REAL_CONST(156012.5524943505/8.0), - REAL_CONST(156039.05200429002/8.0), - REAL_CONST(156065.55263935472/8.0), - REAL_CONST(156092.054399449/8.0), - REAL_CONST(156118.5572844774/8.0), - REAL_CONST(156145.06129434443/8.0), - REAL_CONST(156171.5664289546/8.0), - REAL_CONST(156198.07268821247/8.0), - REAL_CONST(156224.5800720226/8.0), - REAL_CONST(156251.08858028959/8.0), - REAL_CONST(156277.59821291809/8.0), - REAL_CONST(156304.10896981266/8.0), - REAL_CONST(156330.62085087801/8.0), - REAL_CONST(156357.1338560188/8.0), - REAL_CONST(156383.64798513969/8.0), - REAL_CONST(156410.16323814544/8.0), - REAL_CONST(156436.67961494075/8.0), - REAL_CONST(156463.1971154304/8.0), - REAL_CONST(156489.71573951913/8.0), - REAL_CONST(156516.23548711176/8.0), - REAL_CONST(156542.75635811311/8.0), - REAL_CONST(156569.27835242799/8.0), - REAL_CONST(156595.80146996127/8.0), - REAL_CONST(156622.32571061782/8.0), - REAL_CONST(156648.85107430254/8.0), - REAL_CONST(156675.37756092031/8.0), - REAL_CONST(156701.90517037612/8.0), - REAL_CONST(156728.43390257491/8.0), - REAL_CONST(156754.96375742162/8.0), - REAL_CONST(156781.49473482129/8.0), - REAL_CONST(156808.02683467892/8.0), - REAL_CONST(156834.5600568995/8.0), - REAL_CONST(156861.09440138817/8.0), - REAL_CONST(156887.62986804993/8.0), - REAL_CONST(156914.16645678994/8.0), - REAL_CONST(156940.70416751326/8.0), - REAL_CONST(156967.24300012505/8.0), - REAL_CONST(156993.78295453047/8.0), - REAL_CONST(157020.32403063469/8.0), - REAL_CONST(157046.8662283429/8.0), - REAL_CONST(157073.40954756032/8.0), - REAL_CONST(157099.9539881922/8.0), - REAL_CONST(157126.49955014378/8.0), - REAL_CONST(157153.04623332032/8.0), - REAL_CONST(157179.59403762716/8.0), - REAL_CONST(157206.14296296958/8.0), - REAL_CONST(157232.69300925292/8.0), - REAL_CONST(157259.24417638258/8.0), - REAL_CONST(157285.79646426387/8.0), - REAL_CONST(157312.34987280221/8.0), - REAL_CONST(157338.90440190304/8.0), - REAL_CONST(157365.46005147175/8.0), - REAL_CONST(157392.01682141385/8.0), - REAL_CONST(157418.57471163478/8.0), - REAL_CONST(157445.13372204005/8.0), - REAL_CONST(157471.69385253513/8.0), - REAL_CONST(157498.25510302564/8.0), - REAL_CONST(157524.81747341706/8.0), - REAL_CONST(157551.38096361503/8.0), - REAL_CONST(157577.9455735251/8.0), - REAL_CONST(157604.51130305286/8.0), - REAL_CONST(157631.07815210402/8.0), - REAL_CONST(157657.64612058419/8.0), - REAL_CONST(157684.21520839902/8.0), - REAL_CONST(157710.78541545427/8.0), - REAL_CONST(157737.35674165559/8.0), - REAL_CONST(157763.92918690876/8.0), - REAL_CONST(157790.50275111952/8.0), - REAL_CONST(157817.07743419363/8.0), - REAL_CONST(157843.65323603692/8.0), - REAL_CONST(157870.23015655516/8.0), - REAL_CONST(157896.80819565422/8.0), - REAL_CONST(157923.3873532399/8.0), - REAL_CONST(157949.96762921812/8.0), - REAL_CONST(157976.54902349479/8.0), - REAL_CONST(158003.13153597576/8.0), - REAL_CONST(158029.71516656701/8.0), - REAL_CONST(158056.29991517449/8.0), - REAL_CONST(158082.88578170416/8.0), - REAL_CONST(158109.47276606198/8.0), - REAL_CONST(158136.06086815402/8.0), - REAL_CONST(158162.65008788629/8.0), - REAL_CONST(158189.24042516484/8.0), - REAL_CONST(158215.83187989573/8.0), - REAL_CONST(158242.42445198505/8.0), - REAL_CONST(158269.01814133892/8.0), - REAL_CONST(158295.61294786347/8.0), - REAL_CONST(158322.20887146486/8.0), - REAL_CONST(158348.80591204923/8.0), - REAL_CONST(158375.4040695228/8.0), - REAL_CONST(158402.00334379176/8.0), - REAL_CONST(158428.60373476235/8.0), - REAL_CONST(158455.2052423408/8.0), - REAL_CONST(158481.80786643337/8.0), - REAL_CONST(158508.41160694641/8.0), - REAL_CONST(158535.01646378616/8.0), - REAL_CONST(158561.62243685898/8.0), - REAL_CONST(158588.2295260712/8.0), - REAL_CONST(158614.8377313292/8.0), - REAL_CONST(158641.44705253936/8.0), - REAL_CONST(158668.05748960807/8.0), - REAL_CONST(158694.66904244179/8.0), - REAL_CONST(158721.28171094693/8.0), - REAL_CONST(158747.89549502998/8.0), - REAL_CONST(158774.5103945974/8.0), - REAL_CONST(158801.12640955573/8.0), - REAL_CONST(158827.74353981143/8.0), - REAL_CONST(158854.36178527112/8.0), - REAL_CONST(158880.9811458413/8.0), - REAL_CONST(158907.60162142856/8.0), - REAL_CONST(158934.22321193956/8.0), - REAL_CONST(158960.84591728085/8.0), - REAL_CONST(158987.46973735912/8.0), - REAL_CONST(159014.09467208097/8.0), - REAL_CONST(159040.72072135314/8.0), - REAL_CONST(159067.3478850823/8.0), - REAL_CONST(159093.97616317519/8.0), - REAL_CONST(159120.60555553852/8.0), - REAL_CONST(159147.23606207906/8.0), - REAL_CONST(159173.8676827036/8.0), - REAL_CONST(159200.50041731889/8.0), - REAL_CONST(159227.13426583182/8.0), - REAL_CONST(159253.76922814918/8.0), - REAL_CONST(159280.40530417781/8.0), - REAL_CONST(159307.04249382461/8.0), - REAL_CONST(159333.68079699649/8.0), - REAL_CONST(159360.32021360032/8.0), - REAL_CONST(159386.96074354305/8.0), - REAL_CONST(159413.60238673165/8.0), - REAL_CONST(159440.24514307309/8.0), - REAL_CONST(159466.88901247433/8.0), - REAL_CONST(159493.53399484244/8.0), - REAL_CONST(159520.18009008438/8.0), - REAL_CONST(159546.82729810724/8.0), - REAL_CONST(159573.47561881805/8.0), - REAL_CONST(159600.12505212394/8.0), - REAL_CONST(159626.77559793202/8.0), - REAL_CONST(159653.42725614941/8.0), - REAL_CONST(159680.08002668325/8.0), - REAL_CONST(159706.73390944069/8.0), - REAL_CONST(159733.38890432892/8.0), - REAL_CONST(159760.04501125516/8.0), - REAL_CONST(159786.70223012666/8.0), - REAL_CONST(159813.36056085059/8.0), - REAL_CONST(159840.02000333427/8.0), - REAL_CONST(159866.68055748497/8.0), - REAL_CONST(159893.34222320997/8.0), - REAL_CONST(159920.00500041663/8.0), - REAL_CONST(159946.66888901225/8.0), - REAL_CONST(159973.33388890422/8.0), - REAL_CONST(159999.99999999988/8.0), - REAL_CONST(160026.66722220668/8.0), - REAL_CONST(160053.33555543202/8.0), - REAL_CONST(160080.0049995833/8.0), - REAL_CONST(160106.67555456801/8.0), - REAL_CONST(160133.3472202936/8.0), - REAL_CONST(160160.0199966676/8.0), - REAL_CONST(160186.6938835975/8.0), - REAL_CONST(160213.36888099083/8.0), - REAL_CONST(160240.04498875517/8.0), - REAL_CONST(160266.72220679806/8.0), - REAL_CONST(160293.40053502709/8.0), - REAL_CONST(160320.07997334987/8.0), - REAL_CONST(160346.76052167406/8.0), - REAL_CONST(160373.44217990729/8.0), - REAL_CONST(160400.1249479572/8.0), - REAL_CONST(160426.80882573154/8.0), - REAL_CONST(160453.49381313793/8.0), - REAL_CONST(160480.17991008417/8.0), - REAL_CONST(160506.86711647795/8.0), - REAL_CONST(160533.55543222709/8.0), - REAL_CONST(160560.24485723933/8.0), - REAL_CONST(160586.93539142248/8.0), - REAL_CONST(160613.62703468435/8.0), - REAL_CONST(160640.31978693281/8.0), - REAL_CONST(160667.01364807569/8.0), - REAL_CONST(160693.70861802087/8.0), - REAL_CONST(160720.40469667627/8.0), - REAL_CONST(160747.1018839498/8.0), - REAL_CONST(160773.80017974938/8.0), - REAL_CONST(160800.49958398298/8.0), - REAL_CONST(160827.20009655855/8.0), - REAL_CONST(160853.90171738411/8.0), - REAL_CONST(160880.60444636765/8.0), - REAL_CONST(160907.30828341722/8.0), - REAL_CONST(160934.01322844089/8.0), - REAL_CONST(160960.71928134665/8.0), - REAL_CONST(160987.42644204266/8.0), - REAL_CONST(161014.13471043704/8.0), - REAL_CONST(161040.84408643784/8.0), - REAL_CONST(161067.55456995327/8.0), - REAL_CONST(161094.26616089148/8.0), - REAL_CONST(161120.97885916062/8.0), - REAL_CONST(161147.69266466892/8.0), - REAL_CONST(161174.40757732463/8.0), - REAL_CONST(161201.12359703594/8.0), - REAL_CONST(161227.84072371112/8.0), - REAL_CONST(161254.55895725847/8.0), - REAL_CONST(161281.27829758628/8.0), - REAL_CONST(161307.99874460287/8.0), - REAL_CONST(161334.72029821656/8.0), - REAL_CONST(161361.44295833571/8.0), - REAL_CONST(161388.1667248687/8.0), - REAL_CONST(161414.89159772391/8.0), - REAL_CONST(161441.61757680977/8.0), - REAL_CONST(161468.34466203468/8.0), - REAL_CONST(161495.07285330712/8.0), - REAL_CONST(161521.80215053557/8.0), - REAL_CONST(161548.53255362847/8.0), - REAL_CONST(161575.26406249436/8.0), - REAL_CONST(161601.99667704175/8.0), - REAL_CONST(161628.7303971792/8.0), - REAL_CONST(161655.46522281526/8.0), - REAL_CONST(161682.20115385848/8.0), - REAL_CONST(161708.93819021754/8.0), - REAL_CONST(161735.67633180099/8.0), - REAL_CONST(161762.41557851751/8.0), - REAL_CONST(161789.15593027571/8.0), - REAL_CONST(161815.89738698432/8.0), - REAL_CONST(161842.63994855201/8.0), - REAL_CONST(161869.38361488748/8.0), - REAL_CONST(161896.1283858995/8.0), - REAL_CONST(161922.87426149679/8.0), - REAL_CONST(161949.62124158812/8.0), - REAL_CONST(161976.36932608229/8.0), - REAL_CONST(162003.1185148881/8.0), - REAL_CONST(162029.8688079144/8.0), - REAL_CONST(162056.62020507001/8.0), - REAL_CONST(162083.37270626382/8.0), - REAL_CONST(162110.12631140469/8.0), - REAL_CONST(162136.88102040152/8.0), - REAL_CONST(162163.63683316324/8.0), - REAL_CONST(162190.39374959879/8.0), - REAL_CONST(162217.15176961714/8.0), - REAL_CONST(162243.91089312723/8.0), - REAL_CONST(162270.67112003808/8.0), - REAL_CONST(162297.43245025873/8.0), - REAL_CONST(162324.19488369819/8.0), - REAL_CONST(162350.9584202655/8.0), - REAL_CONST(162377.72305986975/8.0), - REAL_CONST(162404.48880242003/8.0), - REAL_CONST(162431.25564782543/8.0), - REAL_CONST(162458.02359599507/8.0), - REAL_CONST(162484.79264683815/8.0), - REAL_CONST(162511.56280026378/8.0), - REAL_CONST(162538.33405618116/8.0), - REAL_CONST(162565.10641449949/8.0), - REAL_CONST(162591.87987512801/8.0), - REAL_CONST(162618.65443797593/8.0), - REAL_CONST(162645.43010295252/8.0), - REAL_CONST(162672.20686996708/8.0), - REAL_CONST(162698.98473892888/8.0), - REAL_CONST(162725.76370974723/8.0), - REAL_CONST(162752.54378233149/8.0), - REAL_CONST(162779.32495659095/8.0), - REAL_CONST(162806.10723243505/8.0), - REAL_CONST(162832.89060977317/8.0), - REAL_CONST(162859.67508851466/8.0), - REAL_CONST(162886.46066856899/8.0), - REAL_CONST(162913.24734984562/8.0), - REAL_CONST(162940.03513225398/8.0), - REAL_CONST(162966.82401570358/8.0), - REAL_CONST(162993.6140001039/8.0), - REAL_CONST(163020.40508536444/8.0), - REAL_CONST(163047.19727139481/8.0), - REAL_CONST(163073.99055810447/8.0), - REAL_CONST(163100.78494540305/8.0), - REAL_CONST(163127.58043320014/8.0), - REAL_CONST(163154.37702140535/8.0), - REAL_CONST(163181.17470992831/8.0), - REAL_CONST(163207.97349867865/8.0), - REAL_CONST(163234.77338756606/8.0), - REAL_CONST(163261.57437650024/8.0), - REAL_CONST(163288.37646539087/8.0), - REAL_CONST(163315.17965414765/8.0), - REAL_CONST(163341.98394268038/8.0), - REAL_CONST(163368.78933089875/8.0), - REAL_CONST(163395.59581871261/8.0), - REAL_CONST(163422.40340603172/8.0), - REAL_CONST(163449.2120927659/8.0), - REAL_CONST(163476.02187882498/8.0), - REAL_CONST(163502.83276411882/8.0), - REAL_CONST(163529.6447485573/8.0), - REAL_CONST(163556.45783205028/8.0), - REAL_CONST(163583.2720145077/8.0), - REAL_CONST(163610.08729583945/8.0), - REAL_CONST(163636.90367595552/8.0), - REAL_CONST(163663.72115476584/8.0), - REAL_CONST(163690.53973218042/8.0), - REAL_CONST(163717.35940810922/8.0), - REAL_CONST(163744.18018246227/8.0), - REAL_CONST(163771.00205514964/8.0), - REAL_CONST(163797.82502608138/8.0), - REAL_CONST(163824.64909516752/8.0), - REAL_CONST(163851.4742623182/8.0), - REAL_CONST(163878.3005274435/8.0), - REAL_CONST(163905.12789045356/8.0), - REAL_CONST(163931.95635125853/8.0), - REAL_CONST(163958.78590976857/8.0), - REAL_CONST(163985.61656589387/8.0), - REAL_CONST(164012.44831954464/8.0), - REAL_CONST(164039.28117063109/8.0), - REAL_CONST(164066.11511906344/8.0), - REAL_CONST(164092.95016475199/8.0), - REAL_CONST(164119.78630760699/8.0), - REAL_CONST(164146.62354753874/8.0), - REAL_CONST(164173.46188445756/8.0), - REAL_CONST(164200.30131827376/8.0), - REAL_CONST(164227.14184889771/8.0), - REAL_CONST(164253.98347623978/8.0), - REAL_CONST(164280.82620021031/8.0), - REAL_CONST(164307.67002071979/8.0), - REAL_CONST(164334.51493767856/8.0), - REAL_CONST(164361.3609509971/8.0), - REAL_CONST(164388.20806058586/8.0), - REAL_CONST(164415.05626635533/8.0), - REAL_CONST(164441.905568216/8.0), - REAL_CONST(164468.75596607837/8.0), - REAL_CONST(164495.607459853/8.0), - REAL_CONST(164522.4600494504/8.0), - REAL_CONST(164549.31373478117/8.0), - REAL_CONST(164576.16851575591/8.0), - REAL_CONST(164603.02439228518/8.0), - REAL_CONST(164629.88136427966/8.0), - REAL_CONST(164656.73943164994/8.0), - REAL_CONST(164683.59859430668/8.0), - REAL_CONST(164710.45885216061/8.0), - REAL_CONST(164737.32020512238/8.0), - REAL_CONST(164764.1826531027/8.0), - REAL_CONST(164791.04619601235/8.0), - REAL_CONST(164817.91083376206/8.0), - REAL_CONST(164844.77656626256/8.0), - REAL_CONST(164871.64339342469/8.0), - REAL_CONST(164898.51131515924/8.0), - REAL_CONST(164925.38033137703/8.0), - REAL_CONST(164952.25044198887/8.0), - REAL_CONST(164979.1216469057/8.0), - REAL_CONST(165005.9939460383/8.0), - REAL_CONST(165032.86733929763/8.0), - REAL_CONST(165059.7418265946/8.0), - REAL_CONST(165086.61740784015/8.0), - REAL_CONST(165113.4940829452/8.0) -#endif -}; - -#endif - -#ifdef __cplusplus -} -#endif -#endif diff --git a/apps/codecs/libfaad/is.c b/apps/codecs/libfaad/is.c deleted file mode 100644 index 89c6fcf228..0000000000 --- a/apps/codecs/libfaad/is.c +++ /dev/null @@ -1,108 +0,0 @@ -/* -** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -** -** Any non-GPL usage of this software or parts of this software is strictly -** forbidden. -** -** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. -** -** $Id$ -**/ - -#include "common.h" -#include "structs.h" - -#include "syntax.h" -#include "is.h" - -#ifdef FIXED_POINT -static real_t pow05_table[] ICONST_ATTR = { - COEF_CONST(1.68179283050743), /* 0.5^(-3/4) */ - COEF_CONST(1.41421356237310), /* 0.5^(-2/4) */ - COEF_CONST(1.18920711500272), /* 0.5^(-1/4) */ - COEF_CONST(1.0), /* 0.5^( 0/4) */ - COEF_CONST(0.84089641525371), /* 0.5^(+1/4) */ - COEF_CONST(0.70710678118655), /* 0.5^(+2/4) */ - COEF_CONST(0.59460355750136) /* 0.5^(+3/4) */ -}; -#endif - -void is_decode(ic_stream *ics, ic_stream *icsr, real_t *l_spec, real_t *r_spec, - uint16_t frame_len) -{ - uint8_t g, sfb, b; - uint16_t i, k; -#ifndef FIXED_POINT - real_t scale; -#else - int32_t exp, frac; -#endif - - uint16_t nshort = frame_len/8; - uint8_t group = 0; - - for (g = 0; g < icsr->num_window_groups; g++) - { - /* Do intensity stereo decoding */ - for (b = 0; b < icsr->window_group_length[g]; b++) - { - for (sfb = 0; sfb < icsr->max_sfb; sfb++) - { - if (is_intensity(icsr, g, sfb)) - { -#ifdef MAIN_DEC - /* For scalefactor bands coded in intensity stereo the - corresponding predictors in the right channel are - switched to "off". - */ - ics->pred.prediction_used[sfb] = 0; - icsr->pred.prediction_used[sfb] = 0; -#endif - -#ifndef FIXED_POINT - scale = (real_t)pow(0.5, (0.25*icsr->scale_factors[g][sfb])); -#else - exp = icsr->scale_factors[g][sfb] >> 2; - frac = icsr->scale_factors[g][sfb] & 3; -#endif - - /* Scale from left to right channel, - do not touch left channel */ - k = (group*nshort) + icsr->swb_offset[sfb]; - for (i = icsr->swb_offset[sfb]; i < icsr->swb_offset[sfb+1]; i++, k++) - { -#ifndef FIXED_POINT - r_spec[k] = MUL_R(l_spec[k], scale); -#else - if (exp < 0) - r_spec[k] = l_spec[k] << -exp; - else - r_spec[k] = l_spec[k] >> exp; - - r_spec[k] = MUL_C(r_spec[k], pow05_table[frac + 3]); -#endif - if (is_intensity(icsr, g, sfb) != invert_intensity(ics, g, sfb)) - r_spec[k] = -r_spec[k]; - } - } - } - group++; - } - } -} diff --git a/apps/codecs/libfaad/is.h b/apps/codecs/libfaad/is.h deleted file mode 100644 index 1b68f3ec49..0000000000 --- a/apps/codecs/libfaad/is.h +++ /dev/null @@ -1,64 +0,0 @@ -/* -** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -** -** Any non-GPL usage of this software or parts of this software is strictly -** forbidden. -** -** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. -** -** $Id$ -**/ - -#ifndef __IS_H__ -#define __IS_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -#include "syntax.h" - -void is_decode(ic_stream *ics, ic_stream *icsr, real_t *l_spec, real_t *r_spec, - uint16_t frame_len); - -static INLINE int8_t is_intensity(ic_stream *ics, uint8_t group, uint8_t sfb) -{ - switch (ics->sfb_cb[group][sfb]) - { - case INTENSITY_HCB: - return 1; - case INTENSITY_HCB2: - return -1; - default: - return 0; - } -} - -static INLINE int8_t invert_intensity(ic_stream *ics, uint8_t group, uint8_t sfb) -{ - if (ics->ms_mask_present == 1) - return (1-2*ics->ms_used[group][sfb]); - return 1; -} - - -#ifdef __cplusplus -} -#endif -#endif diff --git a/apps/codecs/libfaad/kbd_win.h b/apps/codecs/libfaad/kbd_win.h deleted file mode 100644 index 8abd3c070c..0000000000 --- a/apps/codecs/libfaad/kbd_win.h +++ /dev/null @@ -1,2294 +0,0 @@ -/* -** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -** -** Any non-GPL usage of this software or parts of this software is strictly -** forbidden. -** -** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. -** -** $Id$ -**/ - -#ifndef __KBD_WIN_H__ -#define __KBD_WIN_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef _MSC_VER -#pragma warning(disable:4305) -#pragma warning(disable:4244) -#endif - -static const real_t kbd_long_1024[] ICONST_ATTR MEM_ALIGN_ATTR = -{ - FRAC_CONST(0.00029256153896361), - FRAC_CONST(0.00042998567353047), - FRAC_CONST(0.00054674074589540), - FRAC_CONST(0.00065482304299792), - FRAC_CONST(0.00075870195068747), - FRAC_CONST(0.00086059331713336), - FRAC_CONST(0.00096177541439010), - FRAC_CONST(0.0010630609410878), - FRAC_CONST(0.0011650036308132), - FRAC_CONST(0.0012680012194148), - FRAC_CONST(0.0013723517232956), - FRAC_CONST(0.0014782864109136), - FRAC_CONST(0.0015859901976719), - FRAC_CONST(0.0016956148252373), - FRAC_CONST(0.0018072876903517), - FRAC_CONST(0.0019211179405514), - FRAC_CONST(0.0020372007924215), - FRAC_CONST(0.0021556206591754), - FRAC_CONST(0.0022764534599614), - FRAC_CONST(0.0023997683540995), - FRAC_CONST(0.0025256290631156), - FRAC_CONST(0.0026540948920831), - FRAC_CONST(0.0027852215281403), - FRAC_CONST(0.0029190616715331), - FRAC_CONST(0.0030556655443223), - FRAC_CONST(0.0031950812943391), - FRAC_CONST(0.0033373553240392), - FRAC_CONST(0.0034825325586930), - FRAC_CONST(0.0036306566699199), - FRAC_CONST(0.0037817702604646), - FRAC_CONST(0.0039359150179719), - FRAC_CONST(0.0040931318437260), - FRAC_CONST(0.0042534609610026), - FRAC_CONST(0.0044169420066964), - FRAC_CONST(0.0045836141091341), - FRAC_CONST(0.0047535159544086), - FRAC_CONST(0.0049266858431214), - FRAC_CONST(0.0051031617390698), - FRAC_CONST(0.0052829813111335), - FRAC_CONST(0.0054661819693975), - FRAC_CONST(0.0056528008963682), - FRAC_CONST(0.0058428750739943), - FRAC_CONST(0.0060364413070882), - FRAC_CONST(0.0062335362436492), - FRAC_CONST(0.0064341963925079), - FRAC_CONST(0.0066384581386503), - FRAC_CONST(0.0068463577565218), - FRAC_CONST(0.0070579314215715), - FRAC_CONST(0.0072732152202559), - FRAC_CONST(0.0074922451586909), - FRAC_CONST(0.0077150571701162), - FRAC_CONST(0.0079416871213115), - FRAC_CONST(0.0081721708180857), - FRAC_CONST(0.0084065440099458), - FRAC_CONST(0.0086448423940363), - FRAC_CONST(0.0088871016184291), - FRAC_CONST(0.0091333572848345), - FRAC_CONST(0.0093836449507939), - FRAC_CONST(0.0096380001314086), - FRAC_CONST(0.0098964583006517), - FRAC_CONST(0.010159054892306), - FRAC_CONST(0.010425825300561), - FRAC_CONST(0.010696804880310), - FRAC_CONST(0.010972028947167), - FRAC_CONST(0.011251532777236), - FRAC_CONST(0.011535351606646), - FRAC_CONST(0.011823520630897), - FRAC_CONST(0.012116075003993), - FRAC_CONST(0.012413049837429), - FRAC_CONST(0.012714480198999), - FRAC_CONST(0.013020401111478), - FRAC_CONST(0.013330847551161), - FRAC_CONST(0.013645854446288), - FRAC_CONST(0.013965456675352), - FRAC_CONST(0.014289689065314), - FRAC_CONST(0.014618586389712), - FRAC_CONST(0.014952183366697), - FRAC_CONST(0.015290514656976), - FRAC_CONST(0.015633614861688), - FRAC_CONST(0.015981518520214), - FRAC_CONST(0.016334260107915), - FRAC_CONST(0.016691874033817), - FRAC_CONST(0.017054394638241), - FRAC_CONST(0.017421856190380), - FRAC_CONST(0.017794292885832), - FRAC_CONST(0.018171738844085), - FRAC_CONST(0.018554228105962), - FRAC_CONST(0.018941794631032), - FRAC_CONST(0.019334472294980), - FRAC_CONST(0.019732294886947), - FRAC_CONST(0.020135296106839), - FRAC_CONST(0.020543509562604), - FRAC_CONST(0.020956968767488), - FRAC_CONST(0.021375707137257), - FRAC_CONST(0.021799757987407), - FRAC_CONST(0.022229154530343), - FRAC_CONST(0.022663929872540), - FRAC_CONST(0.023104117011689), - FRAC_CONST(0.023549748833816), - FRAC_CONST(0.024000858110398), - FRAC_CONST(0.024457477495451), - FRAC_CONST(0.024919639522613), - FRAC_CONST(0.025387376602207), - FRAC_CONST(0.025860721018295), - FRAC_CONST(0.026339704925726), - FRAC_CONST(0.026824360347160), - FRAC_CONST(0.027314719170100), - FRAC_CONST(0.027810813143900), - FRAC_CONST(0.028312673876775), - FRAC_CONST(0.028820332832801), - FRAC_CONST(0.029333821328905), - FRAC_CONST(0.029853170531859), - FRAC_CONST(0.030378411455255), - FRAC_CONST(0.030909574956490), - FRAC_CONST(0.031446691733739), - FRAC_CONST(0.031989792322926), - FRAC_CONST(0.032538907094693), - FRAC_CONST(0.033094066251369), - FRAC_CONST(0.033655299823935), - FRAC_CONST(0.034222637668991), - FRAC_CONST(0.034796109465717), - FRAC_CONST(0.035375744712844), - FRAC_CONST(0.035961572725616), - FRAC_CONST(0.036553622632758), - FRAC_CONST(0.037151923373446), - FRAC_CONST(0.037756503694277), - FRAC_CONST(0.038367392146243), - FRAC_CONST(0.038984617081711), - FRAC_CONST(0.039608206651398), - FRAC_CONST(0.040238188801359), - FRAC_CONST(0.040874591269976), - FRAC_CONST(0.041517441584950), - FRAC_CONST(0.042166767060301), - FRAC_CONST(0.042822594793376), - FRAC_CONST(0.043484951661852), - FRAC_CONST(0.044153864320760), - FRAC_CONST(0.044829359199509), - FRAC_CONST(0.045511462498913), - FRAC_CONST(0.046200200188234), - FRAC_CONST(0.046895598002228), - FRAC_CONST(0.047597681438201), - FRAC_CONST(0.048306475753074), - FRAC_CONST(0.049022005960455), - FRAC_CONST(0.049744296827725), - FRAC_CONST(0.050473372873129), - FRAC_CONST(0.051209258362879), - FRAC_CONST(0.051951977308273), - FRAC_CONST(0.052701553462813), - FRAC_CONST(0.053458010319350), - FRAC_CONST(0.054221371107223), - FRAC_CONST(0.054991658789428), - FRAC_CONST(0.055768896059787), - FRAC_CONST(0.056553105340134), - FRAC_CONST(0.057344308777513), - FRAC_CONST(0.058142528241393), - FRAC_CONST(0.058947785320893), - FRAC_CONST(0.059760101322019), - FRAC_CONST(0.060579497264926), - FRAC_CONST(0.061405993881180), - FRAC_CONST(0.062239611611049), - FRAC_CONST(0.063080370600799), - FRAC_CONST(0.063928290700012), - FRAC_CONST(0.064783391458919), - FRAC_CONST(0.065645692125747), - FRAC_CONST(0.066515211644086), - FRAC_CONST(0.067391968650269), - FRAC_CONST(0.068275981470777), - FRAC_CONST(0.069167268119652), - FRAC_CONST(0.070065846295935), - FRAC_CONST(0.070971733381121), - FRAC_CONST(0.071884946436630), - FRAC_CONST(0.072805502201299), - FRAC_CONST(0.073733417088896), - FRAC_CONST(0.074668707185649), - FRAC_CONST(0.075611388247794), - FRAC_CONST(0.076561475699152), - FRAC_CONST(0.077518984628715), - FRAC_CONST(0.078483929788261), - FRAC_CONST(0.079456325589986), - FRAC_CONST(0.080436186104162), - FRAC_CONST(0.081423525056808), - FRAC_CONST(0.082418355827392), - FRAC_CONST(0.083420691446553), - FRAC_CONST(0.084430544593841), - FRAC_CONST(0.085447927595483), - FRAC_CONST(0.086472852422178), - FRAC_CONST(0.087505330686900), - FRAC_CONST(0.088545373642744), - FRAC_CONST(0.089592992180780), - FRAC_CONST(0.090648196827937), - FRAC_CONST(0.091710997744919), - FRAC_CONST(0.092781404724131), - FRAC_CONST(0.093859427187640), - FRAC_CONST(0.094945074185163), - FRAC_CONST(0.096038354392069), - FRAC_CONST(0.097139276107423), - FRAC_CONST(0.098247847252041), - FRAC_CONST(0.099364075366580), - FRAC_CONST(0.10048796760965), - FRAC_CONST(0.10161953075597), - FRAC_CONST(0.10275877119451), - FRAC_CONST(0.10390569492671), - FRAC_CONST(0.10506030756469), - FRAC_CONST(0.10622261432949), - FRAC_CONST(0.10739262004941), - FRAC_CONST(0.10857032915821), - FRAC_CONST(0.10975574569357), - FRAC_CONST(0.11094887329534), - FRAC_CONST(0.11214971520402), - FRAC_CONST(0.11335827425914), - FRAC_CONST(0.11457455289772), - FRAC_CONST(0.11579855315274), - FRAC_CONST(0.11703027665170), - FRAC_CONST(0.11826972461510), - FRAC_CONST(0.11951689785504), - FRAC_CONST(0.12077179677383), - FRAC_CONST(0.12203442136263), - FRAC_CONST(0.12330477120008), - FRAC_CONST(0.12458284545102), - FRAC_CONST(0.12586864286523), - FRAC_CONST(0.12716216177615), - FRAC_CONST(0.12846340009971), - FRAC_CONST(0.12977235533312), - FRAC_CONST(0.13108902455375), - FRAC_CONST(0.13241340441801), - FRAC_CONST(0.13374549116025), - FRAC_CONST(0.13508528059173), - FRAC_CONST(0.13643276809961), - FRAC_CONST(0.13778794864595), - FRAC_CONST(0.13915081676677), - FRAC_CONST(0.14052136657114), - FRAC_CONST(0.14189959174027), - FRAC_CONST(0.14328548552671), - FRAC_CONST(0.14467904075349), - FRAC_CONST(0.14608024981336), - FRAC_CONST(0.14748910466804), - FRAC_CONST(0.14890559684750), - FRAC_CONST(0.15032971744929), - FRAC_CONST(0.15176145713790), - FRAC_CONST(0.15320080614414), - FRAC_CONST(0.15464775426459), - FRAC_CONST(0.15610229086100), - FRAC_CONST(0.15756440485987), - FRAC_CONST(0.15903408475193), - FRAC_CONST(0.16051131859170), - FRAC_CONST(0.16199609399712), - FRAC_CONST(0.16348839814917), - FRAC_CONST(0.16498821779156), - FRAC_CONST(0.16649553923042), - FRAC_CONST(0.16801034833404), - FRAC_CONST(0.16953263053270), - FRAC_CONST(0.17106237081842), - FRAC_CONST(0.17259955374484), - FRAC_CONST(0.17414416342714), - FRAC_CONST(0.17569618354193), - FRAC_CONST(0.17725559732720), - FRAC_CONST(0.17882238758238), - FRAC_CONST(0.18039653666830), - FRAC_CONST(0.18197802650733), - FRAC_CONST(0.18356683858343), - FRAC_CONST(0.18516295394233), - FRAC_CONST(0.18676635319174), - FRAC_CONST(0.18837701650148), - FRAC_CONST(0.18999492360384), - FRAC_CONST(0.19162005379380), - FRAC_CONST(0.19325238592940), - FRAC_CONST(0.19489189843209), - FRAC_CONST(0.19653856928714), - FRAC_CONST(0.19819237604409), - FRAC_CONST(0.19985329581721), - FRAC_CONST(0.20152130528605), - FRAC_CONST(0.20319638069594), - FRAC_CONST(0.20487849785865), - FRAC_CONST(0.20656763215298), - FRAC_CONST(0.20826375852540), - FRAC_CONST(0.20996685149083), - FRAC_CONST(0.21167688513330), - FRAC_CONST(0.21339383310678), - FRAC_CONST(0.21511766863598), - FRAC_CONST(0.21684836451719), - FRAC_CONST(0.21858589311922), - FRAC_CONST(0.22033022638425), - FRAC_CONST(0.22208133582887), - FRAC_CONST(0.22383919254503), - FRAC_CONST(0.22560376720111), - FRAC_CONST(0.22737503004300), - FRAC_CONST(0.22915295089517), - FRAC_CONST(0.23093749916189), - FRAC_CONST(0.23272864382838), - FRAC_CONST(0.23452635346201), - FRAC_CONST(0.23633059621364), - FRAC_CONST(0.23814133981883), - FRAC_CONST(0.23995855159925), - FRAC_CONST(0.24178219846403), - FRAC_CONST(0.24361224691114), - FRAC_CONST(0.24544866302890), - FRAC_CONST(0.24729141249740), - FRAC_CONST(0.24914046059007), - FRAC_CONST(0.25099577217522), - FRAC_CONST(0.25285731171763), - FRAC_CONST(0.25472504328019), - FRAC_CONST(0.25659893052556), - FRAC_CONST(0.25847893671788), - FRAC_CONST(0.26036502472451), - FRAC_CONST(0.26225715701781), - FRAC_CONST(0.26415529567692), - FRAC_CONST(0.26605940238966), - FRAC_CONST(0.26796943845439), - FRAC_CONST(0.26988536478190), - FRAC_CONST(0.27180714189742), - FRAC_CONST(0.27373472994256), - FRAC_CONST(0.27566808867736), - FRAC_CONST(0.27760717748238), - FRAC_CONST(0.27955195536071), - FRAC_CONST(0.28150238094021), - FRAC_CONST(0.28345841247557), - FRAC_CONST(0.28542000785059), - FRAC_CONST(0.28738712458038), - FRAC_CONST(0.28935971981364), - FRAC_CONST(0.29133775033492), - FRAC_CONST(0.29332117256704), - FRAC_CONST(0.29530994257338), - FRAC_CONST(0.29730401606034), - FRAC_CONST(0.29930334837974), - FRAC_CONST(0.30130789453132), - FRAC_CONST(0.30331760916521), - FRAC_CONST(0.30533244658452), - FRAC_CONST(0.30735236074785), - FRAC_CONST(0.30937730527195), - FRAC_CONST(0.31140723343430), - FRAC_CONST(0.31344209817583), - FRAC_CONST(0.31548185210356), - FRAC_CONST(0.31752644749341), - FRAC_CONST(0.31957583629288), - FRAC_CONST(0.32162997012390), - FRAC_CONST(0.32368880028565), - FRAC_CONST(0.32575227775738), - FRAC_CONST(0.32782035320134), - FRAC_CONST(0.32989297696566), - FRAC_CONST(0.33197009908736), - FRAC_CONST(0.33405166929523), - FRAC_CONST(0.33613763701295), - FRAC_CONST(0.33822795136203), - FRAC_CONST(0.34032256116495), - FRAC_CONST(0.34242141494820), - FRAC_CONST(0.34452446094547), - FRAC_CONST(0.34663164710072), - FRAC_CONST(0.34874292107143), - FRAC_CONST(0.35085823023181), - FRAC_CONST(0.35297752167598), - FRAC_CONST(0.35510074222129), - FRAC_CONST(0.35722783841160), - FRAC_CONST(0.35935875652060), - FRAC_CONST(0.36149344255514), - FRAC_CONST(0.36363184225864), - FRAC_CONST(0.36577390111444), - FRAC_CONST(0.36791956434930), - FRAC_CONST(0.37006877693676), - FRAC_CONST(0.37222148360070), - FRAC_CONST(0.37437762881878), - FRAC_CONST(0.37653715682603), - FRAC_CONST(0.37870001161834), - FRAC_CONST(0.38086613695607), - FRAC_CONST(0.38303547636766), - FRAC_CONST(0.38520797315322), - FRAC_CONST(0.38738357038821), - FRAC_CONST(0.38956221092708), - FRAC_CONST(0.39174383740701), - FRAC_CONST(0.39392839225157), - FRAC_CONST(0.39611581767449), - FRAC_CONST(0.39830605568342), - FRAC_CONST(0.40049904808370), - FRAC_CONST(0.40269473648218), - FRAC_CONST(0.40489306229101), - FRAC_CONST(0.40709396673153), - FRAC_CONST(0.40929739083810), - FRAC_CONST(0.41150327546197), - FRAC_CONST(0.41371156127524), - FRAC_CONST(0.41592218877472), - FRAC_CONST(0.41813509828594), - FRAC_CONST(0.42035022996702), - FRAC_CONST(0.42256752381274), - FRAC_CONST(0.42478691965848), - FRAC_CONST(0.42700835718423), - FRAC_CONST(0.42923177591866), - FRAC_CONST(0.43145711524314), - FRAC_CONST(0.43368431439580), - FRAC_CONST(0.43591331247564), - FRAC_CONST(0.43814404844658), - FRAC_CONST(0.44037646114161), - FRAC_CONST(0.44261048926688), - FRAC_CONST(0.44484607140589), - FRAC_CONST(0.44708314602359), - FRAC_CONST(0.44932165147057), - FRAC_CONST(0.45156152598727), - FRAC_CONST(0.45380270770813), - FRAC_CONST(0.45604513466581), - FRAC_CONST(0.45828874479543), - FRAC_CONST(0.46053347593880), - FRAC_CONST(0.46277926584861), - FRAC_CONST(0.46502605219277), - FRAC_CONST(0.46727377255861), - FRAC_CONST(0.46952236445718), - FRAC_CONST(0.47177176532752), - FRAC_CONST(0.47402191254100), - FRAC_CONST(0.47627274340557), - FRAC_CONST(0.47852419517009), - FRAC_CONST(0.48077620502869), - FRAC_CONST(0.48302871012505), - FRAC_CONST(0.48528164755674), - FRAC_CONST(0.48753495437962), - FRAC_CONST(0.48978856761212), - FRAC_CONST(0.49204242423966), - FRAC_CONST(0.49429646121898), - FRAC_CONST(0.49655061548250), - FRAC_CONST(0.49880482394273), - FRAC_CONST(0.50105902349665), - FRAC_CONST(0.50331315103004), - FRAC_CONST(0.50556714342194), - FRAC_CONST(0.50782093754901), - FRAC_CONST(0.51007447028990), - FRAC_CONST(0.51232767852971), - FRAC_CONST(0.51458049916433), - FRAC_CONST(0.51683286910489), - FRAC_CONST(0.51908472528213), - FRAC_CONST(0.52133600465083), - FRAC_CONST(0.52358664419420), - FRAC_CONST(0.52583658092832), - FRAC_CONST(0.52808575190648), - FRAC_CONST(0.53033409422367), - FRAC_CONST(0.53258154502092), - FRAC_CONST(0.53482804148974), - FRAC_CONST(0.53707352087652), - FRAC_CONST(0.53931792048690), - FRAC_CONST(0.54156117769021), - FRAC_CONST(0.54380322992385), - FRAC_CONST(0.54604401469766), - FRAC_CONST(0.54828346959835), - FRAC_CONST(0.55052153229384), - FRAC_CONST(0.55275814053768), - FRAC_CONST(0.55499323217338), - FRAC_CONST(0.55722674513883), - FRAC_CONST(0.55945861747062), - FRAC_CONST(0.56168878730842), - FRAC_CONST(0.56391719289930), - FRAC_CONST(0.56614377260214), - FRAC_CONST(0.56836846489188), - FRAC_CONST(0.57059120836390), - FRAC_CONST(0.57281194173835), - FRAC_CONST(0.57503060386439), - FRAC_CONST(0.57724713372458), - FRAC_CONST(0.57946147043912), - FRAC_CONST(0.58167355327012), - FRAC_CONST(0.58388332162591), - FRAC_CONST(0.58609071506528), - FRAC_CONST(0.58829567330173), - FRAC_CONST(0.59049813620770), - FRAC_CONST(0.59269804381879), - FRAC_CONST(0.59489533633802), - FRAC_CONST(0.59708995413996), - FRAC_CONST(0.59928183777495), - FRAC_CONST(0.60147092797329), - FRAC_CONST(0.60365716564937), - FRAC_CONST(0.60584049190582), - FRAC_CONST(0.60802084803764), - FRAC_CONST(0.61019817553632), - FRAC_CONST(0.61237241609393), - FRAC_CONST(0.61454351160718), - FRAC_CONST(0.61671140418155), - FRAC_CONST(0.61887603613527), - FRAC_CONST(0.62103735000336), - FRAC_CONST(0.62319528854167), - FRAC_CONST(0.62534979473088), - FRAC_CONST(0.62750081178042), - FRAC_CONST(0.62964828313250), - FRAC_CONST(0.63179215246597), - FRAC_CONST(0.63393236370030), - FRAC_CONST(0.63606886099946), - FRAC_CONST(0.63820158877577), - FRAC_CONST(0.64033049169379), - FRAC_CONST(0.64245551467413), - FRAC_CONST(0.64457660289729), - FRAC_CONST(0.64669370180740), - FRAC_CONST(0.64880675711607), - FRAC_CONST(0.65091571480603), - FRAC_CONST(0.65302052113494), - FRAC_CONST(0.65512112263906), - FRAC_CONST(0.65721746613689), - FRAC_CONST(0.65930949873289), - FRAC_CONST(0.66139716782102), - FRAC_CONST(0.66348042108842), - FRAC_CONST(0.66555920651892), - FRAC_CONST(0.66763347239664), - FRAC_CONST(0.66970316730947), - FRAC_CONST(0.67176824015260), - FRAC_CONST(0.67382864013196), - FRAC_CONST(0.67588431676768), - FRAC_CONST(0.67793521989751), - FRAC_CONST(0.67998129968017), - FRAC_CONST(0.68202250659876), - FRAC_CONST(0.68405879146403), - FRAC_CONST(0.68609010541774), - FRAC_CONST(0.68811639993588), - FRAC_CONST(0.69013762683195), - FRAC_CONST(0.69215373826012), - FRAC_CONST(0.69416468671849), - FRAC_CONST(0.69617042505214), - FRAC_CONST(0.69817090645634), - FRAC_CONST(0.70016608447958), - FRAC_CONST(0.70215591302664), - FRAC_CONST(0.70414034636163), - FRAC_CONST(0.70611933911096), - FRAC_CONST(0.70809284626630), - FRAC_CONST(0.71006082318751), - FRAC_CONST(0.71202322560554), - FRAC_CONST(0.71398000962530), - FRAC_CONST(0.71593113172842), - FRAC_CONST(0.71787654877613), - FRAC_CONST(0.71981621801195), - FRAC_CONST(0.72175009706445), - FRAC_CONST(0.72367814394990), - FRAC_CONST(0.72560031707496), - FRAC_CONST(0.72751657523927), - FRAC_CONST(0.72942687763803), - FRAC_CONST(0.73133118386457), - FRAC_CONST(0.73322945391280), - FRAC_CONST(0.73512164817975), - FRAC_CONST(0.73700772746796), - FRAC_CONST(0.73888765298787), - FRAC_CONST(0.74076138636020), - FRAC_CONST(0.74262888961827), - FRAC_CONST(0.74449012521027), - FRAC_CONST(0.74634505600152), - FRAC_CONST(0.74819364527663), - FRAC_CONST(0.75003585674175), - FRAC_CONST(0.75187165452661), - FRAC_CONST(0.75370100318668), - FRAC_CONST(0.75552386770515), - FRAC_CONST(0.75734021349500), - FRAC_CONST(0.75915000640095), - FRAC_CONST(0.76095321270137), - FRAC_CONST(0.76274979911019), - FRAC_CONST(0.76453973277875), - FRAC_CONST(0.76632298129757), - FRAC_CONST(0.76809951269819), - FRAC_CONST(0.76986929545481), - FRAC_CONST(0.77163229848604), - FRAC_CONST(0.77338849115651), - FRAC_CONST(0.77513784327849), - FRAC_CONST(0.77688032511340), - FRAC_CONST(0.77861590737340), - FRAC_CONST(0.78034456122283), - FRAC_CONST(0.78206625827961), - FRAC_CONST(0.78378097061667), - FRAC_CONST(0.78548867076330), - FRAC_CONST(0.78718933170643), - FRAC_CONST(0.78888292689189), - FRAC_CONST(0.79056943022564), - FRAC_CONST(0.79224881607494), - FRAC_CONST(0.79392105926949), - FRAC_CONST(0.79558613510249), - FRAC_CONST(0.79724401933170), - FRAC_CONST(0.79889468818046), - FRAC_CONST(0.80053811833858), - FRAC_CONST(0.80217428696334), - FRAC_CONST(0.80380317168028), - FRAC_CONST(0.80542475058405), - FRAC_CONST(0.80703900223920), - FRAC_CONST(0.80864590568089), - FRAC_CONST(0.81024544041560), - FRAC_CONST(0.81183758642175), - FRAC_CONST(0.81342232415032), - FRAC_CONST(0.81499963452540), - FRAC_CONST(0.81656949894467), - FRAC_CONST(0.81813189927991), - FRAC_CONST(0.81968681787738), - FRAC_CONST(0.82123423755821), - FRAC_CONST(0.82277414161874), - FRAC_CONST(0.82430651383076), - FRAC_CONST(0.82583133844180), - FRAC_CONST(0.82734860017528), - FRAC_CONST(0.82885828423070), - FRAC_CONST(0.83036037628369), - FRAC_CONST(0.83185486248609), - FRAC_CONST(0.83334172946597), - FRAC_CONST(0.83482096432759), - FRAC_CONST(0.83629255465130), - FRAC_CONST(0.83775648849344), - FRAC_CONST(0.83921275438615), - FRAC_CONST(0.84066134133716), - FRAC_CONST(0.84210223882952), - FRAC_CONST(0.84353543682130), - FRAC_CONST(0.84496092574524), - FRAC_CONST(0.84637869650833), - FRAC_CONST(0.84778874049138), - FRAC_CONST(0.84919104954855), - FRAC_CONST(0.85058561600677), - FRAC_CONST(0.85197243266520), - FRAC_CONST(0.85335149279457), - FRAC_CONST(0.85472279013653), - FRAC_CONST(0.85608631890295), - FRAC_CONST(0.85744207377513), - FRAC_CONST(0.85879004990298), - FRAC_CONST(0.86013024290422), - FRAC_CONST(0.86146264886346), - FRAC_CONST(0.86278726433124), - FRAC_CONST(0.86410408632306), - FRAC_CONST(0.86541311231838), - FRAC_CONST(0.86671434025950), - FRAC_CONST(0.86800776855046), - FRAC_CONST(0.86929339605590), - FRAC_CONST(0.87057122209981), - FRAC_CONST(0.87184124646433), - FRAC_CONST(0.87310346938840), - FRAC_CONST(0.87435789156650), - FRAC_CONST(0.87560451414719), - FRAC_CONST(0.87684333873173), - FRAC_CONST(0.87807436737261), - FRAC_CONST(0.87929760257204), - FRAC_CONST(0.88051304728038), - FRAC_CONST(0.88172070489456), - FRAC_CONST(0.88292057925645), - FRAC_CONST(0.88411267465117), - FRAC_CONST(0.88529699580537), - FRAC_CONST(0.88647354788545), - FRAC_CONST(0.88764233649580), - FRAC_CONST(0.88880336767692), - FRAC_CONST(0.88995664790351), - FRAC_CONST(0.89110218408260), - FRAC_CONST(0.89223998355154), - FRAC_CONST(0.89337005407600), - FRAC_CONST(0.89449240384793), - FRAC_CONST(0.89560704148345), - FRAC_CONST(0.89671397602074), - FRAC_CONST(0.89781321691786), - FRAC_CONST(0.89890477405053), - FRAC_CONST(0.89998865770993), - FRAC_CONST(0.90106487860034), - FRAC_CONST(0.90213344783689), - FRAC_CONST(0.90319437694315), - FRAC_CONST(0.90424767784873), - FRAC_CONST(0.90529336288690), - FRAC_CONST(0.90633144479201), - FRAC_CONST(0.90736193669708), - FRAC_CONST(0.90838485213119), - FRAC_CONST(0.90940020501694), - FRAC_CONST(0.91040800966776), - FRAC_CONST(0.91140828078533), - FRAC_CONST(0.91240103345685), - FRAC_CONST(0.91338628315231), - FRAC_CONST(0.91436404572173), - FRAC_CONST(0.91533433739238), - FRAC_CONST(0.91629717476594), - FRAC_CONST(0.91725257481564), - FRAC_CONST(0.91820055488334), - FRAC_CONST(0.91914113267664), - FRAC_CONST(0.92007432626589), - FRAC_CONST(0.92100015408120), - FRAC_CONST(0.92191863490944), - FRAC_CONST(0.92282978789113), - FRAC_CONST(0.92373363251740), - FRAC_CONST(0.92463018862687), - FRAC_CONST(0.92551947640245), - FRAC_CONST(0.92640151636824), - FRAC_CONST(0.92727632938624), - FRAC_CONST(0.92814393665320), - FRAC_CONST(0.92900435969727), - FRAC_CONST(0.92985762037477), - FRAC_CONST(0.93070374086684), - FRAC_CONST(0.93154274367610), - FRAC_CONST(0.93237465162328), - FRAC_CONST(0.93319948784382), - FRAC_CONST(0.93401727578443), - FRAC_CONST(0.93482803919967), - FRAC_CONST(0.93563180214841), - FRAC_CONST(0.93642858899043), - FRAC_CONST(0.93721842438279), - FRAC_CONST(0.93800133327637), - FRAC_CONST(0.93877734091223), - FRAC_CONST(0.93954647281807), - FRAC_CONST(0.94030875480458), - FRAC_CONST(0.94106421296182), - FRAC_CONST(0.94181287365556), - FRAC_CONST(0.94255476352362), - FRAC_CONST(0.94328990947213), - FRAC_CONST(0.94401833867184), - FRAC_CONST(0.94474007855439), - FRAC_CONST(0.94545515680855), - FRAC_CONST(0.94616360137644), - FRAC_CONST(0.94686544044975), - FRAC_CONST(0.94756070246592), - FRAC_CONST(0.94824941610434), - FRAC_CONST(0.94893161028248), - FRAC_CONST(0.94960731415209), - FRAC_CONST(0.95027655709525), - FRAC_CONST(0.95093936872056), - FRAC_CONST(0.95159577885924), - FRAC_CONST(0.95224581756115), - FRAC_CONST(0.95288951509097), - FRAC_CONST(0.95352690192417), - FRAC_CONST(0.95415800874314), - FRAC_CONST(0.95478286643320), - FRAC_CONST(0.95540150607863), - FRAC_CONST(0.95601395895871), - FRAC_CONST(0.95662025654373), - FRAC_CONST(0.95722043049100), - FRAC_CONST(0.95781451264084), - FRAC_CONST(0.95840253501260), - FRAC_CONST(0.95898452980058), - FRAC_CONST(0.95956052937008), - FRAC_CONST(0.96013056625336), - FRAC_CONST(0.96069467314557), - FRAC_CONST(0.96125288290073), - FRAC_CONST(0.96180522852773), - FRAC_CONST(0.96235174318622), - FRAC_CONST(0.96289246018262), - FRAC_CONST(0.96342741296604), - FRAC_CONST(0.96395663512424), - FRAC_CONST(0.96448016037959), - FRAC_CONST(0.96499802258499), - FRAC_CONST(0.96551025571985), - FRAC_CONST(0.96601689388602), - FRAC_CONST(0.96651797130376), - FRAC_CONST(0.96701352230768), - FRAC_CONST(0.96750358134269), - FRAC_CONST(0.96798818295998), - FRAC_CONST(0.96846736181297), - FRAC_CONST(0.96894115265327), - FRAC_CONST(0.96940959032667), - FRAC_CONST(0.96987270976912), - FRAC_CONST(0.97033054600270), - FRAC_CONST(0.97078313413161), - FRAC_CONST(0.97123050933818), - FRAC_CONST(0.97167270687887), - FRAC_CONST(0.97210976208030), - FRAC_CONST(0.97254171033525), - FRAC_CONST(0.97296858709871), - FRAC_CONST(0.97339042788392), - FRAC_CONST(0.97380726825843), - FRAC_CONST(0.97421914384017), - FRAC_CONST(0.97462609029350), - FRAC_CONST(0.97502814332534), - FRAC_CONST(0.97542533868127), - FRAC_CONST(0.97581771214160), - FRAC_CONST(0.97620529951759), - FRAC_CONST(0.97658813664749), - FRAC_CONST(0.97696625939282), - FRAC_CONST(0.97733970363445), - FRAC_CONST(0.97770850526884), - FRAC_CONST(0.97807270020427), - FRAC_CONST(0.97843232435704), - FRAC_CONST(0.97878741364771), - FRAC_CONST(0.97913800399743), - FRAC_CONST(0.97948413132414), - FRAC_CONST(0.97982583153895), - FRAC_CONST(0.98016314054243), - FRAC_CONST(0.98049609422096), - FRAC_CONST(0.98082472844313), - FRAC_CONST(0.98114907905608), - FRAC_CONST(0.98146918188197), - FRAC_CONST(0.98178507271438), - FRAC_CONST(0.98209678731477), - FRAC_CONST(0.98240436140902), - FRAC_CONST(0.98270783068385), - FRAC_CONST(0.98300723078342), - FRAC_CONST(0.98330259730589), - FRAC_CONST(0.98359396579995), - FRAC_CONST(0.98388137176152), - FRAC_CONST(0.98416485063031), - FRAC_CONST(0.98444443778651), - FRAC_CONST(0.98472016854752), - FRAC_CONST(0.98499207816463), - FRAC_CONST(0.98526020181980), - FRAC_CONST(0.98552457462240), - FRAC_CONST(0.98578523160609), - FRAC_CONST(0.98604220772560), - FRAC_CONST(0.98629553785362), - FRAC_CONST(0.98654525677772), - FRAC_CONST(0.98679139919726), - FRAC_CONST(0.98703399972035), - FRAC_CONST(0.98727309286089), - FRAC_CONST(0.98750871303556), - FRAC_CONST(0.98774089456089), - FRAC_CONST(0.98796967165036), - FRAC_CONST(0.98819507841154), - FRAC_CONST(0.98841714884323), - FRAC_CONST(0.98863591683269), - FRAC_CONST(0.98885141615285), - FRAC_CONST(0.98906368045957), - FRAC_CONST(0.98927274328896), - FRAC_CONST(0.98947863805473), - FRAC_CONST(0.98968139804554), - FRAC_CONST(0.98988105642241), - FRAC_CONST(0.99007764621618), - FRAC_CONST(0.99027120032501), - FRAC_CONST(0.99046175151186), - FRAC_CONST(0.99064933240208), - FRAC_CONST(0.99083397548099), - FRAC_CONST(0.99101571309153), - FRAC_CONST(0.99119457743191), - FRAC_CONST(0.99137060055337), - FRAC_CONST(0.99154381435784), - FRAC_CONST(0.99171425059582), - FRAC_CONST(0.99188194086414), - FRAC_CONST(0.99204691660388), - FRAC_CONST(0.99220920909823), - FRAC_CONST(0.99236884947045), - FRAC_CONST(0.99252586868186), - FRAC_CONST(0.99268029752989), - FRAC_CONST(0.99283216664606), - FRAC_CONST(0.99298150649419), - FRAC_CONST(0.99312834736847), - FRAC_CONST(0.99327271939167), - FRAC_CONST(0.99341465251338), - FRAC_CONST(0.99355417650825), - FRAC_CONST(0.99369132097430), - FRAC_CONST(0.99382611533130), - FRAC_CONST(0.99395858881910), - FRAC_CONST(0.99408877049612), - FRAC_CONST(0.99421668923778), - FRAC_CONST(0.99434237373503), - FRAC_CONST(0.99446585249289), - FRAC_CONST(0.99458715382906), - FRAC_CONST(0.99470630587254), - FRAC_CONST(0.99482333656229), - FRAC_CONST(0.99493827364600), - FRAC_CONST(0.99505114467878), - FRAC_CONST(0.99516197702200), - FRAC_CONST(0.99527079784214), - FRAC_CONST(0.99537763410962), - FRAC_CONST(0.99548251259777), - FRAC_CONST(0.99558545988178), - FRAC_CONST(0.99568650233767), - FRAC_CONST(0.99578566614138), - FRAC_CONST(0.99588297726783), - FRAC_CONST(0.99597846149005), - FRAC_CONST(0.99607214437834), - FRAC_CONST(0.99616405129947), - FRAC_CONST(0.99625420741595), - FRAC_CONST(0.99634263768527), - FRAC_CONST(0.99642936685928), - FRAC_CONST(0.99651441948352), - FRAC_CONST(0.99659781989663), - FRAC_CONST(0.99667959222978), - FRAC_CONST(0.99675976040620), - FRAC_CONST(0.99683834814063), - FRAC_CONST(0.99691537893895), - FRAC_CONST(0.99699087609774), - FRAC_CONST(0.99706486270391), - FRAC_CONST(0.99713736163442), - FRAC_CONST(0.99720839555593), - FRAC_CONST(0.99727798692461), - FRAC_CONST(0.99734615798589), - FRAC_CONST(0.99741293077431), - FRAC_CONST(0.99747832711337), - FRAC_CONST(0.99754236861541), - FRAC_CONST(0.99760507668158), - FRAC_CONST(0.99766647250181), - FRAC_CONST(0.99772657705478), - FRAC_CONST(0.99778541110799), - FRAC_CONST(0.99784299521785), - FRAC_CONST(0.99789934972976), - FRAC_CONST(0.99795449477828), - FRAC_CONST(0.99800845028730), - FRAC_CONST(0.99806123597027), - FRAC_CONST(0.99811287133042), - FRAC_CONST(0.99816337566108), - FRAC_CONST(0.99821276804596), - FRAC_CONST(0.99826106735952), - FRAC_CONST(0.99830829226732), - FRAC_CONST(0.99835446122649), - FRAC_CONST(0.99839959248609), - FRAC_CONST(0.99844370408765), - FRAC_CONST(0.99848681386566), - FRAC_CONST(0.99852893944805), - FRAC_CONST(0.99857009825685), - FRAC_CONST(0.99861030750869), - FRAC_CONST(0.99864958421549), - FRAC_CONST(0.99868794518504), - FRAC_CONST(0.99872540702178), - FRAC_CONST(0.99876198612738), - FRAC_CONST(0.99879769870160), - FRAC_CONST(0.99883256074295), - FRAC_CONST(0.99886658804953), - FRAC_CONST(0.99889979621983), - FRAC_CONST(0.99893220065356), - FRAC_CONST(0.99896381655254), - FRAC_CONST(0.99899465892154), - FRAC_CONST(0.99902474256924), - FRAC_CONST(0.99905408210916), - FRAC_CONST(0.99908269196056), - FRAC_CONST(0.99911058634952), - FRAC_CONST(0.99913777930986), - FRAC_CONST(0.99916428468421), - FRAC_CONST(0.99919011612505), - FRAC_CONST(0.99921528709576), - FRAC_CONST(0.99923981087174), - FRAC_CONST(0.99926370054150), - FRAC_CONST(0.99928696900779), - FRAC_CONST(0.99930962898876), - FRAC_CONST(0.99933169301910), - FRAC_CONST(0.99935317345126), - FRAC_CONST(0.99937408245662), - FRAC_CONST(0.99939443202674), - FRAC_CONST(0.99941423397457), - FRAC_CONST(0.99943349993572), - FRAC_CONST(0.99945224136972), - FRAC_CONST(0.99947046956130), - FRAC_CONST(0.99948819562171), - FRAC_CONST(0.99950543049000), - FRAC_CONST(0.99952218493439), - FRAC_CONST(0.99953846955355), - FRAC_CONST(0.99955429477803), - FRAC_CONST(0.99956967087154), - FRAC_CONST(0.99958460793242), - FRAC_CONST(0.99959911589494), - FRAC_CONST(0.99961320453077), - FRAC_CONST(0.99962688345035), - FRAC_CONST(0.99964016210433), - FRAC_CONST(0.99965304978499), - FRAC_CONST(0.99966555562769), - FRAC_CONST(0.99967768861231), - FRAC_CONST(0.99968945756473), - FRAC_CONST(0.99970087115825), - FRAC_CONST(0.99971193791510), - FRAC_CONST(0.99972266620792), - FRAC_CONST(0.99973306426121), - FRAC_CONST(0.99974314015288), - FRAC_CONST(0.99975290181568), - FRAC_CONST(0.99976235703876), - FRAC_CONST(0.99977151346914), - FRAC_CONST(0.99978037861326), - FRAC_CONST(0.99978895983845), - FRAC_CONST(0.99979726437448), - FRAC_CONST(0.99980529931507), - FRAC_CONST(0.99981307161943), - FRAC_CONST(0.99982058811377), - FRAC_CONST(0.99982785549283), - FRAC_CONST(0.99983488032144), - FRAC_CONST(0.99984166903600), - FRAC_CONST(0.99984822794606), - FRAC_CONST(0.99985456323584), - FRAC_CONST(0.99986068096572), - FRAC_CONST(0.99986658707386), - FRAC_CONST(0.99987228737764), - FRAC_CONST(0.99987778757524), - FRAC_CONST(0.99988309324717), - FRAC_CONST(0.99988820985777), - FRAC_CONST(0.99989314275675), - FRAC_CONST(0.99989789718072), - FRAC_CONST(0.99990247825468), - FRAC_CONST(0.99990689099357), - FRAC_CONST(0.99991114030376), - FRAC_CONST(0.99991523098456), - FRAC_CONST(0.99991916772971), - FRAC_CONST(0.99992295512891), - FRAC_CONST(0.99992659766930), - FRAC_CONST(0.99993009973692), - FRAC_CONST(0.99993346561824), - FRAC_CONST(0.99993669950161), - FRAC_CONST(0.99993980547870), - FRAC_CONST(0.99994278754604), - FRAC_CONST(0.99994564960642), - FRAC_CONST(0.99994839547033), - FRAC_CONST(0.99995102885747), - FRAC_CONST(0.99995355339809), - FRAC_CONST(0.99995597263451), - FRAC_CONST(0.99995829002249), - FRAC_CONST(0.99996050893264), - FRAC_CONST(0.99996263265183), - FRAC_CONST(0.99996466438460), - FRAC_CONST(0.99996660725452), - FRAC_CONST(0.99996846430558), - FRAC_CONST(0.99997023850356), - FRAC_CONST(0.99997193273736), - FRAC_CONST(0.99997354982037), - FRAC_CONST(0.99997509249183), - FRAC_CONST(0.99997656341810), - FRAC_CONST(0.99997796519400), - FRAC_CONST(0.99997930034415), - FRAC_CONST(0.99998057132421), - FRAC_CONST(0.99998178052220), - FRAC_CONST(0.99998293025975), - FRAC_CONST(0.99998402279338), - FRAC_CONST(0.99998506031574), - FRAC_CONST(0.99998604495686), - FRAC_CONST(0.99998697878536), - FRAC_CONST(0.99998786380966), - FRAC_CONST(0.99998870197921), - FRAC_CONST(0.99998949518567), - FRAC_CONST(0.99999024526408), - FRAC_CONST(0.99999095399401), - FRAC_CONST(0.99999162310077), - FRAC_CONST(0.99999225425649), - FRAC_CONST(0.99999284908128), - FRAC_CONST(0.99999340914435), - FRAC_CONST(0.99999393596510), - FRAC_CONST(0.99999443101421), - FRAC_CONST(0.99999489571473), - FRAC_CONST(0.99999533144314), - FRAC_CONST(0.99999573953040), - FRAC_CONST(0.99999612126300), - FRAC_CONST(0.99999647788395), - FRAC_CONST(0.99999681059383), - FRAC_CONST(0.99999712055178), - FRAC_CONST(0.99999740887647), - FRAC_CONST(0.99999767664709), - FRAC_CONST(0.99999792490431), - FRAC_CONST(0.99999815465123), - FRAC_CONST(0.99999836685427), - FRAC_CONST(0.99999856244415), - FRAC_CONST(0.99999874231676), - FRAC_CONST(0.99999890733405), - FRAC_CONST(0.99999905832493), - FRAC_CONST(0.99999919608613), - FRAC_CONST(0.99999932138304), - FRAC_CONST(0.99999943495056), - FRAC_CONST(0.99999953749392), - FRAC_CONST(0.99999962968950), - FRAC_CONST(0.99999971218563), - FRAC_CONST(0.99999978560337), - FRAC_CONST(0.99999985053727), - FRAC_CONST(0.99999990755616), - FRAC_CONST(0.99999995720387) -}; - -#ifdef ALLOW_SMALL_FRAMELENGTH -static const real_t kbd_long_960[] MEM_ALIGN_ATTR = { - FRAC_CONST(0.0003021562530949), - FRAC_CONST(0.0004452267024786), - FRAC_CONST(0.0005674947527496), - FRAC_CONST(0.0006812465553466), - FRAC_CONST(0.0007910496776387), - FRAC_CONST(0.0008991655033895), - FRAC_CONST(0.0010068978259384), - FRAC_CONST(0.0011150758515751), - FRAC_CONST(0.0012242653193642), - FRAC_CONST(0.0013348735658205), - FRAC_CONST(0.0014472068670273), - FRAC_CONST(0.0015615039850448), - FRAC_CONST(0.0016779568885263), - FRAC_CONST(0.0017967241232412), - FRAC_CONST(0.0019179397560955), - FRAC_CONST(0.0020417195415393), - FRAC_CONST(0.0021681652836642), - FRAC_CONST(0.0022973679910599), - FRAC_CONST(0.0024294102029937), - FRAC_CONST(0.0025643677339078), - FRAC_CONST(0.0027023110014772), - FRAC_CONST(0.0028433060512612), - FRAC_CONST(0.0029874153568025), - FRAC_CONST(0.0031346984511728), - FRAC_CONST(0.0032852124303662), - FRAC_CONST(0.0034390123581190), - FRAC_CONST(0.0035961515940931), - FRAC_CONST(0.0037566820618961), - FRAC_CONST(0.0039206544694386), - FRAC_CONST(0.0040881184912194), - FRAC_CONST(0.0042591229199617), - FRAC_CONST(0.0044337157933972), - FRAC_CONST(0.0046119445007641), - FRAC_CONST(0.0047938558726415), - FRAC_CONST(0.0049794962570131), - FRAC_CONST(0.0051689115838900), - FRAC_CONST(0.0053621474203763), - FRAC_CONST(0.0055592490177131), - FRAC_CONST(0.0057602613515573), - FRAC_CONST(0.0059652291565289), - FRAC_CONST(0.0061741969558843), - FRAC_CONST(0.0063872090870253), - FRAC_CONST(0.0066043097234387), - FRAC_CONST(0.0068255428935640), - FRAC_CONST(0.0070509524970088), - FRAC_CONST(0.0072805823184660), - FRAC_CONST(0.0075144760396340), - FRAC_CONST(0.0077526772493942), - FRAC_CONST(0.0079952294524673), - FRAC_CONST(0.0082421760767325), - FRAC_CONST(0.0084935604793733), - FRAC_CONST(0.0087494259519870), - FRAC_CONST(0.0090098157247792), - FRAC_CONST(0.0092747729699467), - FRAC_CONST(0.0095443408043399), - FRAC_CONST(0.0098185622914832), - FRAC_CONST(0.0100974804430226), - FRAC_CONST(0.0103811382196612), - FRAC_CONST(0.0106695785316351), - FRAC_CONST(0.0109628442387771), - FRAC_CONST(0.0112609781502091), - FRAC_CONST(0.0115640230236993), - FRAC_CONST(0.0118720215647169), - FRAC_CONST(0.0121850164252137), - FRAC_CONST(0.0125030502021561), - FRAC_CONST(0.0128261654358321), - FRAC_CONST(0.0131544046079532), - FRAC_CONST(0.0134878101395681), - FRAC_CONST(0.0138264243888068), - FRAC_CONST(0.0141702896484671), - FRAC_CONST(0.0145194481434592), - FRAC_CONST(0.0148739420281182), - FRAC_CONST(0.0152338133833959), - FRAC_CONST(0.0155991042139432), - FRAC_CONST(0.0159698564450882), - FRAC_CONST(0.0163461119197227), - FRAC_CONST(0.0167279123950996), - FRAC_CONST(0.0171152995395520), - FRAC_CONST(0.0175083149291368), - FRAC_CONST(0.0179070000442104), - FRAC_CONST(0.0183113962659409), - FRAC_CONST(0.0187215448727609), - FRAC_CONST(0.0191374870367659), - FRAC_CONST(0.0195592638200623), - FRAC_CONST(0.0199869161710679), - FRAC_CONST(0.0204204849207691), - FRAC_CONST(0.0208600107789370), - FRAC_CONST(0.0213055343303066), - FRAC_CONST(0.0217570960307201), - FRAC_CONST(0.0222147362032386), - FRAC_CONST(0.0226784950342228), - FRAC_CONST(0.0231484125693867), - FRAC_CONST(0.0236245287098244), - FRAC_CONST(0.0241068832080138), - FRAC_CONST(0.0245955156637973), - FRAC_CONST(0.0250904655203431), - FRAC_CONST(0.0255917720600868), - FRAC_CONST(0.0260994744006559), - FRAC_CONST(0.0266136114907790), - FRAC_CONST(0.0271342221061795), - FRAC_CONST(0.0276613448454576), - FRAC_CONST(0.0281950181259587), - FRAC_CONST(0.0287352801796329), - FRAC_CONST(0.0292821690488833), - FRAC_CONST(0.0298357225824074), - FRAC_CONST(0.0303959784310299), - FRAC_CONST(0.0309629740435296), - FRAC_CONST(0.0315367466624615), - FRAC_CONST(0.0321173333199732), - FRAC_CONST(0.0327047708336193), - FRAC_CONST(0.0332990958021720), - FRAC_CONST(0.0339003446014307), - FRAC_CONST(0.0345085533800302), - FRAC_CONST(0.0351237580552491), - FRAC_CONST(0.0357459943088193), - FRAC_CONST(0.0363752975827358), - FRAC_CONST(0.0370117030750704), - FRAC_CONST(0.0376552457357870), - FRAC_CONST(0.0383059602625614), - FRAC_CONST(0.0389638810966056), - FRAC_CONST(0.0396290424184964), - FRAC_CONST(0.0403014781440112), - FRAC_CONST(0.0409812219199691), - FRAC_CONST(0.0416683071200799), - FRAC_CONST(0.0423627668408009), - FRAC_CONST(0.0430646338972016), - FRAC_CONST(0.0437739408188385), - FRAC_CONST(0.0444907198456388), - FRAC_CONST(0.0452150029237951), - FRAC_CONST(0.0459468217016708), - FRAC_CONST(0.0466862075257170), - FRAC_CONST(0.0474331914364021), - FRAC_CONST(0.0481878041641539), - FRAC_CONST(0.0489500761253148), - FRAC_CONST(0.0497200374181119), - FRAC_CONST(0.0504977178186404), - FRAC_CONST(0.0512831467768636), - FRAC_CONST(0.0520763534126273), - FRAC_CONST(0.0528773665116913), - FRAC_CONST(0.0536862145217772), - FRAC_CONST(0.0545029255486345), - FRAC_CONST(0.0553275273521232), - FRAC_CONST(0.0561600473423164), - FRAC_CONST(0.0570005125756209), - FRAC_CONST(0.0578489497509179), - FRAC_CONST(0.0587053852057233), - FRAC_CONST(0.0595698449123695), - FRAC_CONST(0.0604423544742077), - FRAC_CONST(0.0613229391218317), - FRAC_CONST(0.0622116237093247), - FRAC_CONST(0.0631084327105284), - FRAC_CONST(0.0640133902153352), - FRAC_CONST(0.0649265199260043), - FRAC_CONST(0.0658478451535027), - FRAC_CONST(0.0667773888138695), - FRAC_CONST(0.0677151734246072), - FRAC_CONST(0.0686612211010977), - FRAC_CONST(0.0696155535530446), - FRAC_CONST(0.0705781920809429), - FRAC_CONST(0.0715491575725758), - FRAC_CONST(0.0725284704995383), - FRAC_CONST(0.0735161509137906), - FRAC_CONST(0.0745122184442388), - FRAC_CONST(0.0755166922933461), - FRAC_CONST(0.0765295912337720), - FRAC_CONST(0.0775509336050437), - FRAC_CONST(0.0785807373102561), - FRAC_CONST(0.0796190198128044), - FRAC_CONST(0.0806657981331473), - FRAC_CONST(0.0817210888456026), - FRAC_CONST(0.0827849080751753), - FRAC_CONST(0.0838572714944183), - FRAC_CONST(0.0849381943203265), - FRAC_CONST(0.0860276913112652), - FRAC_CONST(0.0871257767639319), - FRAC_CONST(0.0882324645103534), - FRAC_CONST(0.0893477679149177), - FRAC_CONST(0.0904716998714418), - FRAC_CONST(0.0916042728002747), - FRAC_CONST(0.0927454986454381), - FRAC_CONST(0.0938953888718020), - FRAC_CONST(0.0950539544622996), - FRAC_CONST(0.0962212059151784), - FRAC_CONST(0.0973971532412897), - FRAC_CONST(0.0985818059614169), - FRAC_CONST(0.0997751731036425), - FRAC_CONST(0.1009772632007537), - FRAC_CONST(0.1021880842876888), - FRAC_CONST(0.1034076438990227), - FRAC_CONST(0.1046359490664932), - FRAC_CONST(0.1058730063165681), - FRAC_CONST(0.1071188216680533), - FRAC_CONST(0.1083734006297428), - FRAC_CONST(0.1096367481981100), - FRAC_CONST(0.1109088688550422), - FRAC_CONST(0.1121897665656167), - FRAC_CONST(0.1134794447759207), - FRAC_CONST(0.1147779064109143), - FRAC_CONST(0.1160851538723372), - FRAC_CONST(0.1174011890366591), - FRAC_CONST(0.1187260132530751), - FRAC_CONST(0.1200596273415457), - FRAC_CONST(0.1214020315908810), - FRAC_CONST(0.1227532257568719), - FRAC_CONST(0.1241132090604651), - FRAC_CONST(0.1254819801859856), - FRAC_CONST(0.1268595372794049), - FRAC_CONST(0.1282458779466558), - FRAC_CONST(0.1296409992519942), - FRAC_CONST(0.1310448977164081), - FRAC_CONST(0.1324575693160745), - FRAC_CONST(0.1338790094808633), - FRAC_CONST(0.1353092130928902), - FRAC_CONST(0.1367481744851168), - FRAC_CONST(0.1381958874400010), - FRAC_CONST(0.1396523451881945), - FRAC_CONST(0.1411175404072910), - FRAC_CONST(0.1425914652206223), - FRAC_CONST(0.1440741111961058), - FRAC_CONST(0.1455654693451402), - FRAC_CONST(0.1470655301215526), - FRAC_CONST(0.1485742834205956), - FRAC_CONST(0.1500917185779945), - FRAC_CONST(0.1516178243690463), - FRAC_CONST(0.1531525890077689), - FRAC_CONST(0.1546960001461024), - FRAC_CONST(0.1562480448731608), - FRAC_CONST(0.1578087097145364), - FRAC_CONST(0.1593779806316558), - FRAC_CONST(0.1609558430211876), - FRAC_CONST(0.1625422817145027), - FRAC_CONST(0.1641372809771871), - FRAC_CONST(0.1657408245086070), - FRAC_CONST(0.1673528954415270), - FRAC_CONST(0.1689734763417811), - FRAC_CONST(0.1706025492079969), - FRAC_CONST(0.1722400954713725), - FRAC_CONST(0.1738860959955082), - FRAC_CONST(0.1755405310762898), - FRAC_CONST(0.1772033804418275), - FRAC_CONST(0.1788746232524467), - FRAC_CONST(0.1805542381007349), - FRAC_CONST(0.1822422030116404), - FRAC_CONST(0.1839384954426268), - FRAC_CONST(0.1856430922838810), - FRAC_CONST(0.1873559698585756), - FRAC_CONST(0.1890771039231862), - FRAC_CONST(0.1908064696678625), - FRAC_CONST(0.1925440417168546), - FRAC_CONST(0.1942897941289937), - FRAC_CONST(0.1960437003982277), - FRAC_CONST(0.1978057334542116), - FRAC_CONST(0.1995758656629525), - FRAC_CONST(0.2013540688275098), - FRAC_CONST(0.2031403141887507), - FRAC_CONST(0.2049345724261595), - FRAC_CONST(0.2067368136587033), - FRAC_CONST(0.2085470074457521), - FRAC_CONST(0.2103651227880538), - FRAC_CONST(0.2121911281287646), - FRAC_CONST(0.2140249913545346), - FRAC_CONST(0.2158666797966480), - FRAC_CONST(0.2177161602322188), - FRAC_CONST(0.2195733988854414), - FRAC_CONST(0.2214383614288963), - FRAC_CONST(0.2233110129849106), - FRAC_CONST(0.2251913181269740), - FRAC_CONST(0.2270792408812093), - FRAC_CONST(0.2289747447278976), - FRAC_CONST(0.2308777926030592), - FRAC_CONST(0.2327883469000885), - FRAC_CONST(0.2347063694714437), - FRAC_CONST(0.2366318216303919), - FRAC_CONST(0.2385646641528076), - FRAC_CONST(0.2405048572790267), - FRAC_CONST(0.2424523607157545), - FRAC_CONST(0.2444071336380283), - FRAC_CONST(0.2463691346912334), - FRAC_CONST(0.2483383219931741), - FRAC_CONST(0.2503146531361985), - FRAC_CONST(0.2522980851893767), - FRAC_CONST(0.2542885747007335), - FRAC_CONST(0.2562860776995335), - FRAC_CONST(0.2582905496986215), - FRAC_CONST(0.2603019456968142), - FRAC_CONST(0.2623202201813464), - FRAC_CONST(0.2643453271303700), - FRAC_CONST(0.2663772200155053), - FRAC_CONST(0.2684158518044454), - FRAC_CONST(0.2704611749636135), - FRAC_CONST(0.2725131414608710), - FRAC_CONST(0.2745717027682799), - FRAC_CONST(0.2766368098649151), - FRAC_CONST(0.2787084132397296), - FRAC_CONST(0.2807864628944707), - FRAC_CONST(0.2828709083466482), - FRAC_CONST(0.2849616986325523), - FRAC_CONST(0.2870587823103237), - FRAC_CONST(0.2891621074630737), - FRAC_CONST(0.2912716217020546), - FRAC_CONST(0.2933872721698803), - FRAC_CONST(0.2955090055437973), - FRAC_CONST(0.2976367680390041), - FRAC_CONST(0.2997705054120213), - FRAC_CONST(0.3019101629641097), - FRAC_CONST(0.3040556855447379), - FRAC_CONST(0.3062070175550981), - FRAC_CONST(0.3083641029516701), - FRAC_CONST(0.3105268852498334), - FRAC_CONST(0.3126953075275265), - FRAC_CONST(0.3148693124289546), - FRAC_CONST(0.3170488421683428), - FRAC_CONST(0.3192338385337370), - FRAC_CONST(0.3214242428908514), - FRAC_CONST(0.3236199961869606), - FRAC_CONST(0.3258210389548392), - FRAC_CONST(0.3280273113167459), - FRAC_CONST(0.3302387529884521), - FRAC_CONST(0.3324553032833160), - FRAC_CONST(0.3346769011164010), - FRAC_CONST(0.3369034850086373), - FRAC_CONST(0.3391349930910280), - FRAC_CONST(0.3413713631088974), - FRAC_CONST(0.3436125324261830), - FRAC_CONST(0.3458584380297697), - FRAC_CONST(0.3481090165338656), - FRAC_CONST(0.3503642041844199), - FRAC_CONST(0.3526239368635820), - FRAC_CONST(0.3548881500942010), - FRAC_CONST(0.3571567790443668), - FRAC_CONST(0.3594297585319891), - FRAC_CONST(0.3617070230294185), - FRAC_CONST(0.3639885066681048), - FRAC_CONST(0.3662741432432950), - FRAC_CONST(0.3685638662187693), - FRAC_CONST(0.3708576087316147), - FRAC_CONST(0.3731553035970366), - FRAC_CONST(0.3754568833132069), - FRAC_CONST(0.3777622800661488), - FRAC_CONST(0.3800714257346570), - FRAC_CONST(0.3823842518952546), - FRAC_CONST(0.3847006898271841), - FRAC_CONST(0.3870206705174334), - FRAC_CONST(0.3893441246657958), - FRAC_CONST(0.3916709826899639), - FRAC_CONST(0.3940011747306560), - FRAC_CONST(0.3963346306567764), - FRAC_CONST(0.3986712800706062), - FRAC_CONST(0.4010110523130271), - FRAC_CONST(0.4033538764687756), - FRAC_CONST(0.4056996813717284), - FRAC_CONST(0.4080483956102172), - FRAC_CONST(0.4103999475323736), - FRAC_CONST(0.4127542652515031), - FRAC_CONST(0.4151112766514873), - FRAC_CONST(0.4174709093922143), - FRAC_CONST(0.4198330909150365), - FRAC_CONST(0.4221977484482556), - FRAC_CONST(0.4245648090126334), - FRAC_CONST(0.4269341994269293), - FRAC_CONST(0.4293058463134616), - FRAC_CONST(0.4316796761036958), - FRAC_CONST(0.4340556150438547), - FRAC_CONST(0.4364335892005536), - FRAC_CONST(0.4388135244664580), - FRAC_CONST(0.4411953465659639), - FRAC_CONST(0.4435789810609000), - FRAC_CONST(0.4459643533562509), - FRAC_CONST(0.4483513887059016), - FRAC_CONST(0.4507400122184019), - FRAC_CONST(0.4531301488627497), - FRAC_CONST(0.4555217234741947), - FRAC_CONST(0.4579146607600593), - FRAC_CONST(0.4603088853055777), - FRAC_CONST(0.4627043215797521), - FRAC_CONST(0.4651008939412254), - FRAC_CONST(0.4674985266441709), - FRAC_CONST(0.4698971438441951), - FRAC_CONST(0.4722966696042580), - FRAC_CONST(0.4746970279006055), - FRAC_CONST(0.4770981426287164), - FRAC_CONST(0.4794999376092619), - FRAC_CONST(0.4819023365940778), - FRAC_CONST(0.4843052632721476), - FRAC_CONST(0.4867086412755978), - FRAC_CONST(0.4891123941857028), - FRAC_CONST(0.4915164455388997), - FRAC_CONST(0.4939207188328126), - FRAC_CONST(0.4963251375322855), - FRAC_CONST(0.4987296250754225), - FRAC_CONST(0.5011341048796359), - FRAC_CONST(0.5035385003477012), - FRAC_CONST(0.5059427348738168), - FRAC_CONST(0.5083467318496706), - FRAC_CONST(0.5107504146705106), - FRAC_CONST(0.5131537067412193), - FRAC_CONST(0.5155565314823923), - FRAC_CONST(0.5179588123364193), - FRAC_CONST(0.5203604727735667), - FRAC_CONST(0.5227614362980630), - FRAC_CONST(0.5251616264541841), - FRAC_CONST(0.5275609668323384), - FRAC_CONST(0.5299593810751532), - FRAC_CONST(0.5323567928835578), - FRAC_CONST(0.5347531260228663), - FRAC_CONST(0.5371483043288580), - FRAC_CONST(0.5395422517138538), - FRAC_CONST(0.5419348921727899), - FRAC_CONST(0.5443261497892862), - FRAC_CONST(0.5467159487417104), - FRAC_CONST(0.5491042133092364), - FRAC_CONST(0.5514908678778958), - FRAC_CONST(0.5538758369466227), - FRAC_CONST(0.5562590451332913), - FRAC_CONST(0.5586404171807443), - FRAC_CONST(0.5610198779628133), - FRAC_CONST(0.5633973524903286), - FRAC_CONST(0.5657727659171199), - FRAC_CONST(0.5681460435460047), - FRAC_CONST(0.5705171108347663), - FRAC_CONST(0.5728858934021188), - FRAC_CONST(0.5752523170336598), - FRAC_CONST(0.5776163076878088), - FRAC_CONST(0.5799777915017323), - FRAC_CONST(0.5823366947972535), - FRAC_CONST(0.5846929440867458), - FRAC_CONST(0.5870464660790119), - FRAC_CONST(0.5893971876851449), - FRAC_CONST(0.5917450360243719), - FRAC_CONST(0.5940899384298793), - FRAC_CONST(0.5964318224546208), - FRAC_CONST(0.5987706158771039), - FRAC_CONST(0.6011062467071583), - FRAC_CONST(0.6034386431916822), - FRAC_CONST(0.6057677338203681), - FRAC_CONST(0.6080934473314057), - FRAC_CONST(0.6104157127171639), - FRAC_CONST(0.6127344592298474), - FRAC_CONST(0.6150496163871310), - FRAC_CONST(0.6173611139777690), - FRAC_CONST(0.6196688820671789), - FRAC_CONST(0.6219728510029997), - FRAC_CONST(0.6242729514206247), - FRAC_CONST(0.6265691142487051), - FRAC_CONST(0.6288612707146283), - FRAC_CONST(0.6311493523499663), - FRAC_CONST(0.6334332909958958), - FRAC_CONST(0.6357130188085891), - FRAC_CONST(0.6379884682645743), - FRAC_CONST(0.6402595721660647), - FRAC_CONST(0.6425262636462578), - FRAC_CONST(0.6447884761746012), - FRAC_CONST(0.6470461435620266), - FRAC_CONST(0.6492991999661505), - FRAC_CONST(0.6515475798964411), - FRAC_CONST(0.6537912182193508), - FRAC_CONST(0.6560300501634142), - FRAC_CONST(0.6582640113243098), - FRAC_CONST(0.6604930376698862), - FRAC_CONST(0.6627170655451516), - FRAC_CONST(0.6649360316772256), - FRAC_CONST(0.6671498731802533), - FRAC_CONST(0.6693585275602818), - FRAC_CONST(0.6715619327200959), - FRAC_CONST(0.6737600269640164), - FRAC_CONST(0.6759527490026566), - FRAC_CONST(0.6781400379576392), - FRAC_CONST(0.6803218333662715), - FRAC_CONST(0.6824980751861787), - FRAC_CONST(0.6846687037998949), - FRAC_CONST(0.6868336600194123), - FRAC_CONST(0.6889928850906855), - FRAC_CONST(0.6911463206980928), - FRAC_CONST(0.6932939089688525), - FRAC_CONST(0.6954355924773949), - FRAC_CONST(0.6975713142496884), - FRAC_CONST(0.6997010177675195), - FRAC_CONST(0.7018246469727265), - FRAC_CONST(0.7039421462713862), - FRAC_CONST(0.7060534605379528), - FRAC_CONST(0.7081585351193496), - FRAC_CONST(0.7102573158390105), - FRAC_CONST(0.7123497490008750), - FRAC_CONST(0.7144357813933307), - FRAC_CONST(0.7165153602931092), - FRAC_CONST(0.7185884334691287), - FRAC_CONST(0.7206549491862871), - FRAC_CONST(0.7227148562092042), - FRAC_CONST(0.7247681038059106), - FRAC_CONST(0.7268146417514855), - FRAC_CONST(0.7288544203316418), - FRAC_CONST(0.7308873903462577), - FRAC_CONST(0.7329135031128549), - FRAC_CONST(0.7349327104700221), - FRAC_CONST(0.7369449647807855), - FRAC_CONST(0.7389502189359237), - FRAC_CONST(0.7409484263572271), - FRAC_CONST(0.7429395410007016), - FRAC_CONST(0.7449235173597176), - FRAC_CONST(0.7469003104681008), - FRAC_CONST(0.7488698759031670), - FRAC_CONST(0.7508321697887005), - FRAC_CONST(0.7527871487978728), - FRAC_CONST(0.7547347701561059), - FRAC_CONST(0.7566749916438754), - FRAC_CONST(0.7586077715994560), - FRAC_CONST(0.7605330689216074), - FRAC_CONST(0.7624508430722016), - FRAC_CONST(0.7643610540787891), - FRAC_CONST(0.7662636625371070), - FRAC_CONST(0.7681586296135255), - FRAC_CONST(0.7700459170474343), - FRAC_CONST(0.7719254871535672), - FRAC_CONST(0.7737973028242671), - FRAC_CONST(0.7756613275316875), - FRAC_CONST(0.7775175253299340), - FRAC_CONST(0.7793658608571425), - FRAC_CONST(0.7812062993374951), - FRAC_CONST(0.7830388065831744), - FRAC_CONST(0.7848633489962533), - FRAC_CONST(0.7866798935705233), - FRAC_CONST(0.7884884078932579), - FRAC_CONST(0.7902888601469138), - FRAC_CONST(0.7920812191107668), - FRAC_CONST(0.7938654541624850), - FRAC_CONST(0.7956415352796368), - FRAC_CONST(0.7974094330411343), - FRAC_CONST(0.7991691186286133), - FRAC_CONST(0.8009205638277465), - FRAC_CONST(0.8026637410294932), - FRAC_CONST(0.8043986232312831), - FRAC_CONST(0.8061251840381346), - FRAC_CONST(0.8078433976637077), - FRAC_CONST(0.8095532389312917), - FRAC_CONST(0.8112546832747255), - FRAC_CONST(0.8129477067392539), - FRAC_CONST(0.8146322859823164), - FRAC_CONST(0.8163083982742698), - FRAC_CONST(0.8179760214990457), - FRAC_CONST(0.8196351341547393), - FRAC_CONST(0.8212857153541345), - FRAC_CONST(0.8229277448251595), - FRAC_CONST(0.8245612029112778), - FRAC_CONST(0.8261860705718113), - FRAC_CONST(0.8278023293821971), - FRAC_CONST(0.8294099615341773), - FRAC_CONST(0.8310089498359212), - FRAC_CONST(0.8325992777120815), - FRAC_CONST(0.8341809292037831), - FRAC_CONST(0.8357538889685445), - FRAC_CONST(0.8373181422801330), - FRAC_CONST(0.8388736750283521), - FRAC_CONST(0.8404204737187619), - FRAC_CONST(0.8419585254723335), - FRAC_CONST(0.8434878180250348), - FRAC_CONST(0.8450083397273509), - FRAC_CONST(0.8465200795437368), - FRAC_CONST(0.8480230270520029), - FRAC_CONST(0.8495171724426350), - FRAC_CONST(0.8510025065180464), - FRAC_CONST(0.8524790206917633), - FRAC_CONST(0.8539467069875448), - FRAC_CONST(0.8554055580384357), - FRAC_CONST(0.8568555670857525), - FRAC_CONST(0.8582967279780043), - FRAC_CONST(0.8597290351697464), - FRAC_CONST(0.8611524837203691), - FRAC_CONST(0.8625670692928198), - FRAC_CONST(0.8639727881522599), - FRAC_CONST(0.8653696371646555), - FRAC_CONST(0.8667576137953045), - FRAC_CONST(0.8681367161072958), - FRAC_CONST(0.8695069427599065), - FRAC_CONST(0.8708682930069319), - FRAC_CONST(0.8722207666949527), - FRAC_CONST(0.8735643642615368), - FRAC_CONST(0.8748990867333771), - FRAC_CONST(0.8762249357243662), - FRAC_CONST(0.8775419134336067), - FRAC_CONST(0.8788500226433579), - FRAC_CONST(0.8801492667169208), - FRAC_CONST(0.8814396495964587), - FRAC_CONST(0.8827211758007560), - FRAC_CONST(0.8839938504229149), - FRAC_CONST(0.8852576791279895), - FRAC_CONST(0.8865126681505587), - FRAC_CONST(0.8877588242922386), - FRAC_CONST(0.8889961549191320), - FRAC_CONST(0.8902246679592184), - FRAC_CONST(0.8914443718996848), - FRAC_CONST(0.8926552757841945), - FRAC_CONST(0.8938573892100969), - FRAC_CONST(0.8950507223255798), - FRAC_CONST(0.8962352858267605), - FRAC_CONST(0.8974110909547198), - FRAC_CONST(0.8985781494924783), - FRAC_CONST(0.8997364737619142), - FRAC_CONST(0.9008860766206249), - FRAC_CONST(0.9020269714587307), - FRAC_CONST(0.9031591721956235), - FRAC_CONST(0.9042826932766591), - FRAC_CONST(0.9053975496697941), - FRAC_CONST(0.9065037568621681), - FRAC_CONST(0.9076013308566311), - FRAC_CONST(0.9086902881682180), - FRAC_CONST(0.9097706458205682), - FRAC_CONST(0.9108424213422940), - FRAC_CONST(0.9119056327632955), - FRAC_CONST(0.9129602986110235), - FRAC_CONST(0.9140064379066919), - FRAC_CONST(0.9150440701614393), - FRAC_CONST(0.9160732153724396), - FRAC_CONST(0.9170938940189634), - FRAC_CONST(0.9181061270583908), - FRAC_CONST(0.9191099359221748), - FRAC_CONST(0.9201053425117579), - FRAC_CONST(0.9210923691944400), - FRAC_CONST(0.9220710387992010), - FRAC_CONST(0.9230413746124764), - FRAC_CONST(0.9240034003738882), - FRAC_CONST(0.9249571402719298), - FRAC_CONST(0.9259026189396085), - FRAC_CONST(0.9268398614500427), - FRAC_CONST(0.9277688933120170), - FRAC_CONST(0.9286897404654957), - FRAC_CONST(0.9296024292770939), - FRAC_CONST(0.9305069865355076), - FRAC_CONST(0.9314034394469048), - FRAC_CONST(0.9322918156302762), - FRAC_CONST(0.9331721431127471), - FRAC_CONST(0.9340444503248519), - FRAC_CONST(0.9349087660957711), - FRAC_CONST(0.9357651196485313), - FRAC_CONST(0.9366135405951697), - FRAC_CONST(0.9374540589318637), - FRAC_CONST(0.9382867050340261), - FRAC_CONST(0.9391115096513655), - FRAC_CONST(0.9399285039029165), - FRAC_CONST(0.9407377192720349), - FRAC_CONST(0.9415391876013639), - FRAC_CONST(0.9423329410877687), - FRAC_CONST(0.9431190122772415), - FRAC_CONST(0.9438974340597782), - FRAC_CONST(0.9446682396642262), - FRAC_CONST(0.9454314626531054), - FRAC_CONST(0.9461871369174033), - FRAC_CONST(0.9469352966713429), - FRAC_CONST(0.9476759764471278), - FRAC_CONST(0.9484092110896616), - FRAC_CONST(0.9491350357512457), - FRAC_CONST(0.9498534858862532), - FRAC_CONST(0.9505645972457831), - FRAC_CONST(0.9512684058722927), - FRAC_CONST(0.9519649480942105), - FRAC_CONST(0.9526542605205314), - FRAC_CONST(0.9533363800353921), - FRAC_CONST(0.9540113437926313), - FRAC_CONST(0.9546791892103320), - FRAC_CONST(0.9553399539653500), - FRAC_CONST(0.9559936759878265), - FRAC_CONST(0.9566403934556893), - FRAC_CONST(0.9572801447891388), - FRAC_CONST(0.9579129686451244), - FRAC_CONST(0.9585389039118085), - FRAC_CONST(0.9591579897030224), - FRAC_CONST(0.9597702653527108), - FRAC_CONST(0.9603757704093711), - FRAC_CONST(0.9609745446304828), - FRAC_CONST(0.9615666279769324), - FRAC_CONST(0.9621520606074324), - FRAC_CONST(0.9627308828729358), - FRAC_CONST(0.9633031353110477), - FRAC_CONST(0.9638688586404335), - FRAC_CONST(0.9644280937552258), - FRAC_CONST(0.9649808817194311), - FRAC_CONST(0.9655272637613366), - FRAC_CONST(0.9660672812679171), - FRAC_CONST(0.9666009757792454), - FRAC_CONST(0.9671283889829055), - FRAC_CONST(0.9676495627084089), - FRAC_CONST(0.9681645389216160), - FRAC_CONST(0.9686733597191652), - FRAC_CONST(0.9691760673229058), - FRAC_CONST(0.9696727040743406), - FRAC_CONST(0.9701633124290767), - FRAC_CONST(0.9706479349512860), - FRAC_CONST(0.9711266143081750), - FRAC_CONST(0.9715993932644684), - FRAC_CONST(0.9720663146769026), - FRAC_CONST(0.9725274214887337), - FRAC_CONST(0.9729827567242596), - FRAC_CONST(0.9734323634833574), - FRAC_CONST(0.9738762849360358), - FRAC_CONST(0.9743145643170059), - FRAC_CONST(0.9747472449202687), - FRAC_CONST(0.9751743700937215), - FRAC_CONST(0.9755959832337850), - FRAC_CONST(0.9760121277800496), - FRAC_CONST(0.9764228472099433), - FRAC_CONST(0.9768281850334235), - FRAC_CONST(0.9772281847876897), - FRAC_CONST(0.9776228900319223), - FRAC_CONST(0.9780123443420448), - FRAC_CONST(0.9783965913055132), - FRAC_CONST(0.9787756745161313), - FRAC_CONST(0.9791496375688939), - FRAC_CONST(0.9795185240548578), - FRAC_CONST(0.9798823775560431), - FRAC_CONST(0.9802412416403639), - FRAC_CONST(0.9805951598565897), - FRAC_CONST(0.9809441757293399), - FRAC_CONST(0.9812883327541090), - FRAC_CONST(0.9816276743923267), - FRAC_CONST(0.9819622440664515), - FRAC_CONST(0.9822920851550995), - FRAC_CONST(0.9826172409882086), - FRAC_CONST(0.9829377548422400), - FRAC_CONST(0.9832536699354163), - FRAC_CONST(0.9835650294229984), - FRAC_CONST(0.9838718763926001), - FRAC_CONST(0.9841742538595437), - FRAC_CONST(0.9844722047622547), - FRAC_CONST(0.9847657719576983), - FRAC_CONST(0.9850549982168574), - FRAC_CONST(0.9853399262202529), - FRAC_CONST(0.9856205985535073), - FRAC_CONST(0.9858970577029519), - FRAC_CONST(0.9861693460512790), - FRAC_CONST(0.9864375058732389), - FRAC_CONST(0.9867015793313820), - FRAC_CONST(0.9869616084718489), - FRAC_CONST(0.9872176352202061), - FRAC_CONST(0.9874697013773301), - FRAC_CONST(0.9877178486153397), - FRAC_CONST(0.9879621184735767), - FRAC_CONST(0.9882025523546365), - FRAC_CONST(0.9884391915204485), - FRAC_CONST(0.9886720770884069), - FRAC_CONST(0.9889012500275530), - FRAC_CONST(0.9891267511548089), - FRAC_CONST(0.9893486211312621), - FRAC_CONST(0.9895669004585049), - FRAC_CONST(0.9897816294750255), - FRAC_CONST(0.9899928483526520), - FRAC_CONST(0.9902005970930525), - FRAC_CONST(0.9904049155242876), - FRAC_CONST(0.9906058432974180), - FRAC_CONST(0.9908034198831690), - FRAC_CONST(0.9909976845686489), - FRAC_CONST(0.9911886764541239), - FRAC_CONST(0.9913764344498495), - FRAC_CONST(0.9915609972729590), - FRAC_CONST(0.9917424034444086), - FRAC_CONST(0.9919206912859797), - FRAC_CONST(0.9920958989173397), - FRAC_CONST(0.9922680642531603), - FRAC_CONST(0.9924372250002933), - FRAC_CONST(0.9926034186550070), - FRAC_CONST(0.9927666825002789), - FRAC_CONST(0.9929270536031491), - FRAC_CONST(0.9930845688121325), - FRAC_CONST(0.9932392647546895), - FRAC_CONST(0.9933911778347579), - FRAC_CONST(0.9935403442303433), - FRAC_CONST(0.9936867998911693), - FRAC_CONST(0.9938305805363887), - FRAC_CONST(0.9939717216523539), - FRAC_CONST(0.9941102584904481), - FRAC_CONST(0.9942462260649764), - FRAC_CONST(0.9943796591511174), - FRAC_CONST(0.9945105922829353), - FRAC_CONST(0.9946390597514524), - FRAC_CONST(0.9947650956027824), - FRAC_CONST(0.9948887336363228), - FRAC_CONST(0.9950100074030103), - FRAC_CONST(0.9951289502036336), - FRAC_CONST(0.9952455950872091), - FRAC_CONST(0.9953599748494155), - FRAC_CONST(0.9954721220310890), - FRAC_CONST(0.9955820689167787), - FRAC_CONST(0.9956898475333619), - FRAC_CONST(0.9957954896487196), - FRAC_CONST(0.9958990267704713), - FRAC_CONST(0.9960004901447701), - FRAC_CONST(0.9960999107551559), - FRAC_CONST(0.9961973193214694), - FRAC_CONST(0.9962927462988245), - FRAC_CONST(0.9963862218766388), - FRAC_CONST(0.9964777759777242), - FRAC_CONST(0.9965674382574342), - FRAC_CONST(0.9966552381028704), - FRAC_CONST(0.9967412046321465), - FRAC_CONST(0.9968253666937095), - FRAC_CONST(0.9969077528657186), - FRAC_CONST(0.9969883914554805), - FRAC_CONST(0.9970673104989413), - FRAC_CONST(0.9971445377602348), - FRAC_CONST(0.9972201007312871), - FRAC_CONST(0.9972940266314749), - FRAC_CONST(0.9973663424073412), - FRAC_CONST(0.9974370747323638), - FRAC_CONST(0.9975062500067785), - FRAC_CONST(0.9975738943574574), - FRAC_CONST(0.9976400336378379), - FRAC_CONST(0.9977046934279079), - FRAC_CONST(0.9977678990342401), - FRAC_CONST(0.9978296754900812), - FRAC_CONST(0.9978900475554902), - FRAC_CONST(0.9979490397175296), - FRAC_CONST(0.9980066761905056), - FRAC_CONST(0.9980629809162593), - FRAC_CONST(0.9981179775645063), - FRAC_CONST(0.9981716895332257), - FRAC_CONST(0.9982241399490979), - FRAC_CONST(0.9982753516679893), - FRAC_CONST(0.9983253472754841), - FRAC_CONST(0.9983741490874634), - FRAC_CONST(0.9984217791507299), - FRAC_CONST(0.9984682592436778), - FRAC_CONST(0.9985136108770075), - FRAC_CONST(0.9985578552944850), - FRAC_CONST(0.9986010134737439), - FRAC_CONST(0.9986431061271304), - FRAC_CONST(0.9986841537025921), - FRAC_CONST(0.9987241763846056), - FRAC_CONST(0.9987631940951476), - FRAC_CONST(0.9988012264947044), - FRAC_CONST(0.9988382929833222), - FRAC_CONST(0.9988744127016956), - FRAC_CONST(0.9989096045322947), - FRAC_CONST(0.9989438871005292), - FRAC_CONST(0.9989772787759494), - FRAC_CONST(0.9990097976734847), - FRAC_CONST(0.9990414616547146), - FRAC_CONST(0.9990722883291779), - FRAC_CONST(0.9991022950557125), - FRAC_CONST(0.9991314989438310), - FRAC_CONST(0.9991599168551279), - FRAC_CONST(0.9991875654047181), - FRAC_CONST(0.9992144609627068), - FRAC_CONST(0.9992406196556911), - FRAC_CONST(0.9992660573682882), - FRAC_CONST(0.9992907897446957), - FRAC_CONST(0.9993148321902777), - FRAC_CONST(0.9993381998731797), - FRAC_CONST(0.9993609077259696), - FRAC_CONST(0.9993829704473038), - FRAC_CONST(0.9994044025036201), - FRAC_CONST(0.9994252181308537), - FRAC_CONST(0.9994454313361775), - FRAC_CONST(0.9994650558997651), - FRAC_CONST(0.9994841053765757), - FRAC_CONST(0.9995025930981609), - FRAC_CONST(0.9995205321744921), - FRAC_CONST(0.9995379354958073), - FRAC_CONST(0.9995548157344778), - FRAC_CONST(0.9995711853468930), - FRAC_CONST(0.9995870565753632), - FRAC_CONST(0.9996024414500382), - FRAC_CONST(0.9996173517908444), - FRAC_CONST(0.9996317992094352), - FRAC_CONST(0.9996457951111574), - FRAC_CONST(0.9996593506970310), - FRAC_CONST(0.9996724769657434), - FRAC_CONST(0.9996851847156547), - FRAC_CONST(0.9996974845468164), - FRAC_CONST(0.9997093868630000), - FRAC_CONST(0.9997209018737374), - FRAC_CONST(0.9997320395963699), - FRAC_CONST(0.9997428098581069), - FRAC_CONST(0.9997532222980933), - FRAC_CONST(0.9997632863694836), - FRAC_CONST(0.9997730113415246), - FRAC_CONST(0.9997824063016426), - FRAC_CONST(0.9997914801575380), - FRAC_CONST(0.9998002416392840), - FRAC_CONST(0.9998086993014300), - FRAC_CONST(0.9998168615251084), - FRAC_CONST(0.9998247365201450), - FRAC_CONST(0.9998323323271717), - FRAC_CONST(0.9998396568197407), - FRAC_CONST(0.9998467177064404), - FRAC_CONST(0.9998535225330116), - FRAC_CONST(0.9998600786844637), - FRAC_CONST(0.9998663933871905), - FRAC_CONST(0.9998724737110845), - FRAC_CONST(0.9998783265716498), - FRAC_CONST(0.9998839587321121), - FRAC_CONST(0.9998893768055266), - FRAC_CONST(0.9998945872568815), - FRAC_CONST(0.9998995964051983), - FRAC_CONST(0.9999044104256269), - FRAC_CONST(0.9999090353515359), - FRAC_CONST(0.9999134770765971), - FRAC_CONST(0.9999177413568642), - FRAC_CONST(0.9999218338128448), - FRAC_CONST(0.9999257599315647), - FRAC_CONST(0.9999295250686255), - FRAC_CONST(0.9999331344502529), - FRAC_CONST(0.9999365931753376), - FRAC_CONST(0.9999399062174669), - FRAC_CONST(0.9999430784269460), - FRAC_CONST(0.9999461145328103), - FRAC_CONST(0.9999490191448277), - FRAC_CONST(0.9999517967554878), - FRAC_CONST(0.9999544517419835), - FRAC_CONST(0.9999569883681778), - FRAC_CONST(0.9999594107865607), - FRAC_CONST(0.9999617230401926), - FRAC_CONST(0.9999639290646355), - FRAC_CONST(0.9999660326898712), - FRAC_CONST(0.9999680376422052), - FRAC_CONST(0.9999699475461585), - FRAC_CONST(0.9999717659263435), - FRAC_CONST(0.9999734962093266), - FRAC_CONST(0.9999751417254756), - FRAC_CONST(0.9999767057107922), - FRAC_CONST(0.9999781913087290), - FRAC_CONST(0.9999796015719915), - FRAC_CONST(0.9999809394643231), - FRAC_CONST(0.9999822078622751), - FRAC_CONST(0.9999834095569596), - FRAC_CONST(0.9999845472557860), - FRAC_CONST(0.9999856235841805), - FRAC_CONST(0.9999866410872889), - FRAC_CONST(0.9999876022316609), - FRAC_CONST(0.9999885094069193), - FRAC_CONST(0.9999893649274085), - FRAC_CONST(0.9999901710338274), - FRAC_CONST(0.9999909298948430), - FRAC_CONST(0.9999916436086862), - FRAC_CONST(0.9999923142047299), - FRAC_CONST(0.9999929436450469), - FRAC_CONST(0.9999935338259505), - FRAC_CONST(0.9999940865795161), - FRAC_CONST(0.9999946036750835), - FRAC_CONST(0.9999950868207405), - FRAC_CONST(0.9999955376647868), - FRAC_CONST(0.9999959577971798), - FRAC_CONST(0.9999963487509599), - FRAC_CONST(0.9999967120036571), - FRAC_CONST(0.9999970489786785), - FRAC_CONST(0.9999973610466748), - FRAC_CONST(0.9999976495268890), - FRAC_CONST(0.9999979156884846), - FRAC_CONST(0.9999981607518545), - FRAC_CONST(0.9999983858899099), - FRAC_CONST(0.9999985922293493), - FRAC_CONST(0.9999987808519092), - FRAC_CONST(0.9999989527955938), - FRAC_CONST(0.9999991090558848), - FRAC_CONST(0.9999992505869332), - FRAC_CONST(0.9999993783027293), - FRAC_CONST(0.9999994930782556), - FRAC_CONST(0.9999995957506171), - FRAC_CONST(0.9999996871201549), - FRAC_CONST(0.9999997679515386), - FRAC_CONST(0.9999998389748399), - FRAC_CONST(0.9999999008865869), - FRAC_CONST(0.9999999543507984) -}; -#endif - -static const real_t kbd_short_128[] ICONST_ATTR MEM_ALIGN_ATTR = -{ - FRAC_CONST(4.3795702929468881e-005), - FRAC_CONST(0.00011867384265436617), - FRAC_CONST(0.0002307165763996192), - FRAC_CONST(0.00038947282760568383), - FRAC_CONST(0.00060581272288302553), - FRAC_CONST(0.00089199695169487453), - FRAC_CONST(0.0012617254423430522), - FRAC_CONST(0.0017301724373162003), - FRAC_CONST(0.0023140071937421476), - FRAC_CONST(0.0030313989666022221), - FRAC_CONST(0.0039020049735530842), - FRAC_CONST(0.0049469401815512024), - FRAC_CONST(0.0061887279335368318), - FRAC_CONST(0.0076512306364647726), - FRAC_CONST(0.0093595599562652423), - FRAC_CONST(0.011339966208377799), - FRAC_CONST(0.013619706891715299), - FRAC_CONST(0.016226894586323766), - FRAC_CONST(0.019190324717288168), - FRAC_CONST(0.022539283975960878), - FRAC_CONST(0.026303340480472455), - FRAC_CONST(0.030512117046644357), - FRAC_CONST(0.03519504922365594), - FRAC_CONST(0.040381130021856941), - FRAC_CONST(0.046098643518702249), - FRAC_CONST(0.052374889768730587), - FRAC_CONST(0.059235903660769147), - FRAC_CONST(0.066706170556282418), - FRAC_CONST(0.074808341703430481), - FRAC_CONST(0.083562952548726227), - FRAC_CONST(0.092988147159339674), - FRAC_CONST(0.1030994120216919), - FRAC_CONST(0.11390932249409955), - FRAC_CONST(0.12542730516149531), - FRAC_CONST(0.13765941926783826), - FRAC_CONST(0.15060816028651081), - FRAC_CONST(0.16427228853114245), - FRAC_CONST(0.17864668550988483), - FRAC_CONST(0.19372224048676889), - FRAC_CONST(0.20948576943658073), - FRAC_CONST(0.22591996826744942), - FRAC_CONST(0.24300340184133981), - FRAC_CONST(0.26071052995068139), - FRAC_CONST(0.27901177101369551), - FRAC_CONST(0.29787360383626599), - FRAC_CONST(0.3172587073594233), - FRAC_CONST(0.33712613787396362), - FRAC_CONST(0.35743154274286698), - FRAC_CONST(0.37812740923363009), - FRAC_CONST(0.39916334663203618), - FRAC_CONST(0.42048639939189658), - FRAC_CONST(0.4420413886774246), - FRAC_CONST(0.4637712792815169), - FRAC_CONST(0.4856175685594023), - FRAC_CONST(0.50752069370766872), - FRAC_CONST(0.52942045344797806), - FRAC_CONST(0.55125643994680196), - FRAC_CONST(0.57296847662071559), - FRAC_CONST(0.59449705734411495), - FRAC_CONST(0.61578378249506627), - FRAC_CONST(0.63677178724712891), - FRAC_CONST(0.65740615754163356), - FRAC_CONST(0.67763432925662526), - FRAC_CONST(0.69740646622548552), - FRAC_CONST(0.71667581294953808), - FRAC_CONST(0.73539901809352737), - FRAC_CONST(0.75353642514900732), - FRAC_CONST(0.77105232699609816), - FRAC_CONST(0.78791518148597028), - FRAC_CONST(0.80409778560147072), - FRAC_CONST(0.81957740622770781), - FRAC_CONST(0.83433586607383625), - FRAC_CONST(0.84835958382689225), - FRAC_CONST(0.86163956818294229), - FRAC_CONST(0.87417136598406997), - FRAC_CONST(0.88595496528524853), - FRAC_CONST(0.89699465477567619), - FRAC_CONST(0.90729884157670959), - FRAC_CONST(0.91687983002436779), - FRAC_CONST(0.92575356460899649), - FRAC_CONST(0.93393934077779084), - FRAC_CONST(0.94145948779657318), - FRAC_CONST(0.94833902830402828), - FRAC_CONST(0.95460531956280026), - FRAC_CONST(0.96028768170574896), - FRAC_CONST(0.96541701848104766), - FRAC_CONST(0.97002543610646474), - FRAC_CONST(0.97414586584250062), - FRAC_CONST(0.97781169577969584), - FRAC_CONST(0.98105641710392333), - FRAC_CONST(0.98391328975491177), - FRAC_CONST(0.98641503193166202), - FRAC_CONST(0.98859353733226141), - FRAC_CONST(0.99047962335771556), - FRAC_CONST(0.9921028127769449), - FRAC_CONST(0.99349115056397752), - FRAC_CONST(0.99467105680259038), - FRAC_CONST(0.9956672157341897), - FRAC_CONST(0.99650250022834352), - FRAC_CONST(0.99719793020823266), - FRAC_CONST(0.99777266288955657), - FRAC_CONST(0.99824401211201486), - FRAC_CONST(0.99862749357391212), - FRAC_CONST(0.99893689243401962), - FRAC_CONST(0.99918434952623147), - FRAC_CONST(0.99938046234161726), - FRAC_CONST(0.99953439696357238), - FRAC_CONST(0.99965400728430465), - FRAC_CONST(0.99974595807027455), - FRAC_CONST(0.99981584876278362), - FRAC_CONST(0.99986833527824281), - FRAC_CONST(0.99990724749057802), - FRAC_CONST(0.99993570051598468), - FRAC_CONST(0.99995619835942084), - FRAC_CONST(0.99997072890647543), - FRAC_CONST(0.9999808496399144), - FRAC_CONST(0.99998776381655818), - FRAC_CONST(0.99999238714961569), - FRAC_CONST(0.99999540529959718), - FRAC_CONST(0.99999732268176988), - FRAC_CONST(0.99999850325054862), - FRAC_CONST(0.99999920402413744), - FRAC_CONST(0.9999996021706401), - FRAC_CONST(0.99999981649545566), - FRAC_CONST(0.99999992415545547), - FRAC_CONST(0.99999997338493041), - FRAC_CONST(0.99999999295825959), - FRAC_CONST(0.99999999904096815) -}; - -#ifdef ALLOW_SMALL_FRAMELENGTH -static const real_t kbd_short_120[] MEM_ALIGN_ATTR = -{ - FRAC_CONST(0.0000452320086910), - FRAC_CONST(0.0001274564692111), - FRAC_CONST(0.0002529398385345), - FRAC_CONST(0.0004335140496648), - FRAC_CONST(0.0006827100966952), - FRAC_CONST(0.0010158708222246), - FRAC_CONST(0.0014502162869659), - FRAC_CONST(0.0020048865156264), - FRAC_CONST(0.0027009618393178), - FRAC_CONST(0.0035614590925043), - FRAC_CONST(0.0046113018122711), - FRAC_CONST(0.0058772627936484), - FRAC_CONST(0.0073878776584103), - FRAC_CONST(0.0091733284512589), - FRAC_CONST(0.0112652966728373), - FRAC_CONST(0.0136967855861945), - FRAC_CONST(0.0165019120857793), - FRAC_CONST(0.0197156688892217), - FRAC_CONST(0.0233736582950619), - FRAC_CONST(0.0275117992367496), - FRAC_CONST(0.0321660098468534), - FRAC_CONST(0.0373718682174417), - FRAC_CONST(0.0431642544948834), - FRAC_CONST(0.0495769778717676), - FRAC_CONST(0.0566423924273392), - FRAC_CONST(0.0643910061132260), - FRAC_CONST(0.0728510874761729), - FRAC_CONST(0.0820482749475221), - FRAC_CONST(0.0920051937045235), - FRAC_CONST(0.1027410852163450), - FRAC_CONST(0.1142714546239370), - FRAC_CONST(0.1266077410648368), - FRAC_CONST(0.1397570159398145), - FRAC_CONST(0.1537217139274270), - FRAC_CONST(0.1684994012857075), - FRAC_CONST(0.1840825856392944), - FRAC_CONST(0.2004585710384133), - FRAC_CONST(0.2176093615976121), - FRAC_CONST(0.2355116164824983), - FRAC_CONST(0.2541366584185075), - FRAC_CONST(0.2734505372545160), - FRAC_CONST(0.2934141494343369), - FRAC_CONST(0.3139834135200387), - FRAC_CONST(0.3351095011824163), - FRAC_CONST(0.3567391223361566), - FRAC_CONST(0.3788148623608774), - FRAC_CONST(0.4012755686250732), - FRAC_CONST(0.4240567828288110), - FRAC_CONST(0.4470912150133537), - FRAC_CONST(0.4703092544619664), - FRAC_CONST(0.4936395121456694), - FRAC_CONST(0.5170093888596962), - FRAC_CONST(0.5403456627591340), - FRAC_CONST(0.5635750896430154), - FRAC_CONST(0.5866250090612892), - FRAC_CONST(0.6094239491338723), - FRAC_CONST(0.6319022228794100), - FRAC_CONST(0.6539925088563087), - FRAC_CONST(0.6756304090216887), - FRAC_CONST(0.6967549769155277), - FRAC_CONST(0.7173092095766250), - FRAC_CONST(0.7372404969921184), - FRAC_CONST(0.7565010233699827), - FRAC_CONST(0.7750481150999984), - FRAC_CONST(0.7928445309277697), - FRAC_CONST(0.8098586906021583), - FRAC_CONST(0.8260648390616000), - FRAC_CONST(0.8414431440907889), - FRAC_CONST(0.8559797262966709), - FRAC_CONST(0.8696666212110165), - FRAC_CONST(0.8825016743142358), - FRAC_CONST(0.8944883707784486), - FRAC_CONST(0.9056356027326216), - FRAC_CONST(0.9159573778427816), - FRAC_CONST(0.9254724739583072), - FRAC_CONST(0.9342040454819434), - FRAC_CONST(0.9421791879559176), - FRAC_CONST(0.9494284680976784), - FRAC_CONST(0.9559854271440150), - FRAC_CONST(0.9618860658493898), - FRAC_CONST(0.9671683198119525), - FRAC_CONST(0.9718715339497299), - FRAC_CONST(0.9760359449042233), - FRAC_CONST(0.9797021798981759), - FRAC_CONST(0.9829107801140203), - FRAC_CONST(0.9857017559923277), - FRAC_CONST(0.9881141809867999), - FRAC_CONST(0.9901858292742826), - FRAC_CONST(0.9919528617340944), - FRAC_CONST(0.9934495632180476), - FRAC_CONST(0.9947081327749199), - FRAC_CONST(0.9957585271195989), - FRAC_CONST(0.9966283562984427), - FRAC_CONST(0.9973428292485683), - FRAC_CONST(0.9979247458259197), - FRAC_CONST(0.9983945309245774), - FRAC_CONST(0.9987703055583410), - FRAC_CONST(0.9990679892449266), - FRAC_CONST(0.9993014277313617), - FRAC_CONST(0.9994825400228521), - FRAC_CONST(0.9996214788122335), - FRAC_CONST(0.9997267987294857), - FRAC_CONST(0.9998056273097539), - FRAC_CONST(0.9998638341781910), - FRAC_CONST(0.9999061946325793), - FRAC_CONST(0.9999365445321382), - FRAC_CONST(0.9999579241373735), - FRAC_CONST(0.9999727092594598), - FRAC_CONST(0.9999827287418790), - FRAC_CONST(0.9999893678912771), - FRAC_CONST(0.9999936579844555), - FRAC_CONST(0.9999963523959187), - FRAC_CONST(0.9999979902130101), - FRAC_CONST(0.9999989484358076), - FRAC_CONST(0.9999994840031031), - FRAC_CONST(0.9999997669534347), - FRAC_CONST(0.9999999060327799), - FRAC_CONST(0.9999999680107184), - FRAC_CONST(0.9999999918774242), - FRAC_CONST(0.9999999989770326) -}; -#endif - -#ifdef __cplusplus -} -#endif -#endif diff --git a/apps/codecs/libfaad/libfaad.make b/apps/codecs/libfaad/libfaad.make deleted file mode 100644 index 4f5fbc322c..0000000000 --- a/apps/codecs/libfaad/libfaad.make +++ /dev/null @@ -1,19 +0,0 @@ -# __________ __ ___. -# Open \______ \ ____ ____ | | _\_ |__ _______ ___ -# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / -# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < -# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ -# \/ \/ \/ \/ \/ -# $Id$ -# - -# libfaad -FAADLIB := $(CODECDIR)/libfaad.a -FAADLIB_SRC := $(call preprocess, $(APPSDIR)/codecs/libfaad/SOURCES) -FAADLIB_OBJ := $(call c2obj, $(FAADLIB_SRC)) -OTHER_SRC += $(FAADLIB_SRC) -OTHER_INC += -I$(APPSDIR)/codecs/libfaad - -$(FAADLIB): $(FAADLIB_OBJ) - $(SILENT)$(shell rm -f $@) - $(call PRINTS,AR $(@F))$(AR) rcs $@ $^ >/dev/null diff --git a/apps/codecs/libfaad/lt_predict.c b/apps/codecs/libfaad/lt_predict.c deleted file mode 100644 index f03354fc01..0000000000 --- a/apps/codecs/libfaad/lt_predict.c +++ /dev/null @@ -1,215 +0,0 @@ -/* -** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -** -** Any non-GPL usage of this software or parts of this software is strictly -** forbidden. -** -** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. -** -** $Id$ -**/ - - -#include "common.h" -#include "structs.h" - -#ifdef LTP_DEC - -#include -#include "syntax.h" -#include "lt_predict.h" -#include "filtbank.h" -#include "tns.h" - - -/* static function declarations */ -static int16_t real_to_int16(real_t sig_in); - - -/* check if the object type is an object type that can have LTP */ -uint8_t is_ltp_ot(uint8_t object_type) -{ -#ifdef LTP_DEC - if ((object_type == LTP) -#ifdef ERROR_RESILIENCE - || (object_type == ER_LTP) -#endif -#ifdef LD_DEC - || (object_type == LD) -#endif -#ifdef SCALABLE_DEC - || (object_type == 6) /* TODO */ -#endif - ) - { - return 1; - } -#endif - - return 0; -} - -static const real_t codebook[8] MEM_ALIGN_ATTR = -{ - REAL_CONST(0.570829), - REAL_CONST(0.696616), - REAL_CONST(0.813004), - REAL_CONST(0.911304), - REAL_CONST(0.984900), - REAL_CONST(1.067894), - REAL_CONST(1.194601), - REAL_CONST(1.369533) -}; - -static real_t x_est[2048] MEM_ALIGN_ATTR; -static real_t X_est[2048] MEM_ALIGN_ATTR; -void lt_prediction(ic_stream *ics, ltp_info *ltp, real_t *spec, - int16_t *lt_pred_stat, fb_info *fb, uint8_t win_shape, - uint8_t win_shape_prev, uint8_t sr_index, - uint8_t object_type, uint16_t frame_len) -{ - uint8_t sfb; - uint16_t bin, i, num_samples; - - if (ics->window_sequence != EIGHT_SHORT_SEQUENCE) - { - if (ltp->data_present) - { - num_samples = frame_len << 1; - - for(i = 0; i < num_samples; i++) - { - /* The extra lookback M (N/2 for LD, 0 for LTP) is handled - in the buffer updating */ - -#if 0 - x_est[i] = MUL_R_C(lt_pred_stat[num_samples + i - ltp->lag], - codebook[ltp->coef]); -#else - /* lt_pred_stat is a 16 bit int, multiplied with the fixed point real - this gives a real for x_est - */ - x_est[i] = (real_t)lt_pred_stat[num_samples + i - ltp->lag] * codebook[ltp->coef]; -#endif - } - - filter_bank_ltp(fb, ics->window_sequence, win_shape, win_shape_prev, - x_est, X_est, object_type, frame_len); - - tns_encode_frame(ics, &(ics->tns), sr_index, object_type, X_est, - frame_len); - - for (sfb = 0; sfb < ltp->last_band; sfb++) - { - if (ltp->long_used[sfb]) - { - uint16_t low = ics->swb_offset[sfb]; - uint16_t high = ics->swb_offset[sfb+1]; - - for (bin = low; bin < high; bin++) - { - spec[bin] += X_est[bin]; - } - } - } - } - } -} - -#ifdef FIXED_POINT -static INLINE int16_t real_to_int16(real_t sig_in) -{ - if (sig_in >= 0) - { - sig_in += (1 << (REAL_BITS-1)); - if (sig_in >= REAL_CONST(32768)) - return 32767; - } else { - sig_in += -(1 << (REAL_BITS-1)); - if (sig_in <= REAL_CONST(-32768)) - return -32768; - } - - return (sig_in >> REAL_BITS); -} -#else -static INLINE int16_t real_to_int16(real_t sig_in) -{ - if (sig_in >= 0) - { -#ifndef HAS_LRINTF - sig_in += 0.5f; -#endif - if (sig_in >= 32768.0f) - return 32767; - } else { -#ifndef HAS_LRINTF - sig_in += -0.5f; -#endif - if (sig_in <= -32768.0f) - return -32768; - } - - return lrintf(sig_in); -} -#endif - -void lt_update_state(int16_t *lt_pred_stat, real_t *time, real_t *overlap, - uint16_t frame_len, uint8_t object_type) -{ - uint16_t i; - - /* - * The reference point for index i and the content of the buffer - * lt_pred_stat are arranged so that lt_pred_stat(0 ... N/2 - 1) contains the - * last aliased half window from the IMDCT, and lt_pred_stat(N/2 ... N-1) - * is always all zeros. The rest of lt_pred_stat (i<0) contains the previous - * fully reconstructed time domain samples, i.e., output of the decoder. - * - * These values are shifted up by N*2 to avoid (i<0) - * - * For the LD object type an extra 512 samples lookback is accomodated here. - */ -#ifdef LD_DEC - if (object_type == LD) - { - for (i = 0; i < frame_len; i++) - { - lt_pred_stat[i] /* extra 512 */ = lt_pred_stat[i + frame_len]; - lt_pred_stat[frame_len + i] = lt_pred_stat[i + (frame_len * 2)]; - lt_pred_stat[(frame_len * 2) + i] = real_to_int16(time[i]); - lt_pred_stat[(frame_len * 3) + i] = real_to_int16(overlap[i]); - } - } else { -#endif - for (i = 0; i < frame_len; i++) - { - lt_pred_stat[i] = lt_pred_stat[i + frame_len]; - lt_pred_stat[frame_len + i] = real_to_int16(time[i]); - lt_pred_stat[(frame_len * 2) + i] = real_to_int16(overlap[i]); -#if 0 /* set to zero once upon initialisation */ - lt_pred_stat[(frame_len * 3) + i] = 0; -#endif - } -#ifdef LD_DEC - } -#endif -} - -#endif diff --git a/apps/codecs/libfaad/lt_predict.h b/apps/codecs/libfaad/lt_predict.h deleted file mode 100644 index 1c10751888..0000000000 --- a/apps/codecs/libfaad/lt_predict.h +++ /dev/null @@ -1,63 +0,0 @@ -/* -** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -** -** Any non-GPL usage of this software or parts of this software is strictly -** forbidden. -** -** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. -** -** $Id$ -**/ - -#ifdef LTP_DEC - -#ifndef __LT_PREDICT_H__ -#define __LT_PREDICT_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -#include "filtbank.h" - -uint8_t is_ltp_ot(uint8_t object_type); - -void lt_prediction(ic_stream *ics, - ltp_info *ltp, - real_t *spec, - int16_t *lt_pred_stat, - fb_info *fb, - uint8_t win_shape, - uint8_t win_shape_prev, - uint8_t sr_index, - uint8_t object_type, - uint16_t frame_len); - -void lt_update_state(int16_t *lt_pred_stat, - real_t *time, - real_t *overlap, - uint16_t frame_len, - uint8_t object_type); - -#ifdef __cplusplus -} -#endif -#endif - -#endif diff --git a/apps/codecs/libfaad/mp4.c b/apps/codecs/libfaad/mp4.c deleted file mode 100644 index 94e1a1daaa..0000000000 --- a/apps/codecs/libfaad/mp4.c +++ /dev/null @@ -1,300 +0,0 @@ -/* -** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -** -** Any non-GPL usage of this software or parts of this software is strictly -** forbidden. -** -** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. -** -** $Id$ -**/ - -#include "common.h" -#include "structs.h" - -#include - -#include "bits.h" -#include "mp4.h" -#include "syntax.h" - -/* defines if an object type can be decoded by this library or not */ -static uint8_t ObjectTypesTable[32] = { - 0, /* 0 NULL */ -#ifdef MAIN_DEC - 1, /* 1 AAC Main */ -#else - 0, /* 1 AAC Main */ -#endif - 1, /* 2 AAC LC */ -#ifdef SSR_DEC - 1, /* 3 AAC SSR */ -#else - 0, /* 3 AAC SSR */ -#endif -#ifdef LTP_DEC - 1, /* 4 AAC LTP */ -#else - 0, /* 4 AAC LTP */ -#endif -#ifdef SBR_DEC - 1, /* 5 SBR */ -#else - 0, /* 5 SBR */ -#endif -#ifdef SCALABLE_DEC - 1, /* 6 AAC Scalable */ -#else - 0, /* 6 AAC Scalable */ -#endif - 0, /* 7 TwinVQ */ - 0, /* 8 CELP */ - 0, /* 9 HVXC */ - 0, /* 10 Reserved */ - 0, /* 11 Reserved */ - 0, /* 12 TTSI */ - 0, /* 13 Main synthetic */ - 0, /* 14 Wavetable synthesis */ - 0, /* 15 General MIDI */ - 0, /* 16 Algorithmic Synthesis and Audio FX */ - - /* MPEG-4 Version 2 */ -#ifdef ERROR_RESILIENCE - 1, /* 17 ER AAC LC */ - 0, /* 18 (Reserved) */ -#ifdef LTP_DEC - 1, /* 19 ER AAC LTP */ -#else - 0, /* 19 ER AAC LTP */ -#endif -#ifdef SCALABLE_DEC - 1, /* 20 ER AAC scalable */ -#else - 0, /* 20 ER AAC scalable */ -#endif - 0, /* 21 ER TwinVQ */ - 0, /* 22 ER BSAC */ -#ifdef LD_DEC - 1, /* 23 ER AAC LD */ -#else - 0, /* 23 ER AAC LD */ -#endif - 0, /* 24 ER CELP */ - 0, /* 25 ER HVXC */ - 0, /* 26 ER HILN */ - 0, /* 27 ER Parametric */ -#else /* No ER defined */ - 0, /* 17 ER AAC LC */ - 0, /* 18 (Reserved) */ - 0, /* 19 ER AAC LTP */ - 0, /* 20 ER AAC scalable */ - 0, /* 21 ER TwinVQ */ - 0, /* 22 ER BSAC */ - 0, /* 23 ER AAC LD */ - 0, /* 24 ER CELP */ - 0, /* 25 ER HVXC */ - 0, /* 26 ER HILN */ - 0, /* 27 ER Parametric */ -#endif - 0, /* 28 (Reserved) */ - 0, /* 29 (Reserved) */ - 0, /* 30 (Reserved) */ - 0 /* 31 (Reserved) */ -}; - -/* Table 1.6.1 */ -/* rockbox: not used -int8_t NEAACDECAPI NeAACDecAudioSpecificConfig(uint8_t *pBuffer, - uint32_t buffer_size, - mp4AudioSpecificConfig *mp4ASC) -{ - return AudioSpecificConfig2(pBuffer, buffer_size, mp4ASC, NULL); -}*/ - -int8_t AudioSpecificConfig2(uint8_t *pBuffer, - uint32_t buffer_size, - mp4AudioSpecificConfig *mp4ASC, - program_config *pce) -{ - bitfile ld; - int8_t result = 0; -#ifdef SBR_DEC - int8_t bits_to_decode = 0; -#endif - - if (pBuffer == NULL) - return -7; - if (mp4ASC == NULL) - return -8; - - memset(mp4ASC, 0, sizeof(mp4AudioSpecificConfig)); - - faad_initbits(&ld, pBuffer, buffer_size); - faad_byte_align(&ld); - - mp4ASC->objectTypeIndex = (uint8_t)faad_getbits(&ld, 5 - DEBUGVAR(1,1,"parse_audio_decoder_specific_info(): ObjectTypeIndex")); - - mp4ASC->samplingFrequencyIndex = (uint8_t)faad_getbits(&ld, 4 - DEBUGVAR(1,2,"parse_audio_decoder_specific_info(): SamplingFrequencyIndex")); - - mp4ASC->channelsConfiguration = (uint8_t)faad_getbits(&ld, 4 - DEBUGVAR(1,3,"parse_audio_decoder_specific_info(): ChannelsConfiguration")); - - mp4ASC->samplingFrequency = get_sample_rate(mp4ASC->samplingFrequencyIndex); - - if (ObjectTypesTable[mp4ASC->objectTypeIndex] != 1) - { - faad_endbits(&ld); - return -1; - } - - if (mp4ASC->samplingFrequency == 0) - { - faad_endbits(&ld); - return -2; - } - - if (mp4ASC->channelsConfiguration > 7) - { - faad_endbits(&ld); - return -3; - } - -#if (defined(PS_DEC) || defined(DRM_PS)) - /* check if we have a mono file */ - if (mp4ASC->channelsConfiguration == 1) - { - /* upMatrix to 2 channels for implicit signalling of PS */ - mp4ASC->channelsConfiguration = 2; - } -#endif - -#ifdef SBR_DEC - mp4ASC->sbr_present_flag = -1; - if (mp4ASC->objectTypeIndex == 5) - { - uint8_t tmp; - - mp4ASC->sbr_present_flag = 1; - tmp = (uint8_t)faad_getbits(&ld, 4 - DEBUGVAR(1,5,"parse_audio_decoder_specific_info(): extensionSamplingFrequencyIndex")); - /* check for downsampled SBR */ - if (tmp == mp4ASC->samplingFrequencyIndex) - mp4ASC->downSampledSBR = 1; - mp4ASC->samplingFrequencyIndex = tmp; - if (mp4ASC->samplingFrequencyIndex == 15) - { - mp4ASC->samplingFrequency = (uint32_t)faad_getbits(&ld, 24 - DEBUGVAR(1,6,"parse_audio_decoder_specific_info(): extensionSamplingFrequencyIndex")); - } else { - mp4ASC->samplingFrequency = get_sample_rate(mp4ASC->samplingFrequencyIndex); - } - mp4ASC->objectTypeIndex = (uint8_t)faad_getbits(&ld, 5 - DEBUGVAR(1,7,"parse_audio_decoder_specific_info(): ObjectTypeIndex")); - } -#endif - - /* get GASpecificConfig */ - if (mp4ASC->objectTypeIndex == 1 || mp4ASC->objectTypeIndex == 2 || - mp4ASC->objectTypeIndex == 3 || mp4ASC->objectTypeIndex == 4 || - mp4ASC->objectTypeIndex == 6 || mp4ASC->objectTypeIndex == 7) - { - result = GASpecificConfig(&ld, mp4ASC, pce); - -#ifdef ERROR_RESILIENCE - } else if (mp4ASC->objectTypeIndex >= ER_OBJECT_START) { /* ER */ - result = GASpecificConfig(&ld, mp4ASC, pce); - mp4ASC->epConfig = (uint8_t)faad_getbits(&ld, 2 - DEBUGVAR(1,143,"parse_audio_decoder_specific_info(): epConfig")); - - if (mp4ASC->epConfig != 0) - result = -5; -#endif - - } else { - result = -4; - } - -#ifdef SSR_DEC - /* shorter frames not allowed for SSR */ - if ((mp4ASC->objectTypeIndex == 4) && mp4ASC->frameLengthFlag) - return -6; -#endif - - -#ifdef SBR_DEC - bits_to_decode = (int8_t)(buffer_size*8 - faad_get_processed_bits(&ld)); - - if ((mp4ASC->objectTypeIndex != 5) && (bits_to_decode >= 16)) - { - int16_t syncExtensionType = (int16_t)faad_getbits(&ld, 11 - DEBUGVAR(1,9,"parse_audio_decoder_specific_info(): syncExtensionType")); - - if (syncExtensionType == 0x2b7) - { - mp4ASC->objectTypeIndex = (uint8_t)faad_getbits(&ld, 5 - DEBUGVAR(1,10,"parse_audio_decoder_specific_info(): extensionAudioObjectType")); - - if (mp4ASC->objectTypeIndex == 5) - { - mp4ASC->sbr_present_flag = (uint8_t)faad_get1bit(&ld - DEBUGVAR(1,11,"parse_audio_decoder_specific_info(): sbr_present_flag")); - - if (mp4ASC->sbr_present_flag) - { - uint8_t tmp; - tmp = (uint8_t)faad_getbits(&ld, 4 - DEBUGVAR(1,12,"parse_audio_decoder_specific_info(): extensionSamplingFrequencyIndex")); - - /* check for downsampled SBR */ - if (tmp == mp4ASC->samplingFrequencyIndex) - mp4ASC->downSampledSBR = 1; - mp4ASC->samplingFrequencyIndex = tmp; - - if (mp4ASC->samplingFrequencyIndex == 15) - { - mp4ASC->samplingFrequency = (uint32_t)faad_getbits(&ld, 24 - DEBUGVAR(1,13,"parse_audio_decoder_specific_info(): extensionSamplingFrequencyIndex")); - } else { - mp4ASC->samplingFrequency = get_sample_rate(mp4ASC->samplingFrequencyIndex); - } - } - } - } - } - - /* no SBR signalled, this could mean either implicit signalling or no SBR in this file */ - /* MPEG specification states: assume SBR on files with samplerate <= 24000 Hz */ - if (mp4ASC->sbr_present_flag == -1) - { - if (mp4ASC->samplingFrequency <= 24000) - { - mp4ASC->samplingFrequency *= 2; - mp4ASC->forceUpSampling = 1; - } else /* > 24000*/ { - mp4ASC->downSampledSBR = 1; - } - } -#endif - - faad_endbits(&ld); - - return result; -} diff --git a/apps/codecs/libfaad/mp4.h b/apps/codecs/libfaad/mp4.h deleted file mode 100644 index afcf094796..0000000000 --- a/apps/codecs/libfaad/mp4.h +++ /dev/null @@ -1,51 +0,0 @@ -/* -** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -** -** Any non-GPL usage of this software or parts of this software is strictly -** forbidden. -** -** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. -** -** $Id$ -**/ - -#ifndef __MP4_H__ -#define __MP4_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -#include "decoder.h" - -/* rockbox: not used -int8_t NEAACDECAPI NeAACDecAudioSpecificConfig(uint8_t *pBuffer, - uint32_t buffer_size, - mp4AudioSpecificConfig *mp4ASC); -*/ - -int8_t AudioSpecificConfig2(uint8_t *pBuffer, - uint32_t buffer_size, - mp4AudioSpecificConfig *mp4ASC, - program_config *pce); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/apps/codecs/libfaad/ms.c b/apps/codecs/libfaad/ms.c deleted file mode 100644 index b42e95a408..0000000000 --- a/apps/codecs/libfaad/ms.c +++ /dev/null @@ -1,73 +0,0 @@ -/* -** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -** -** Any non-GPL usage of this software or parts of this software is strictly -** forbidden. -** -** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. -** -** $Id$ -**/ - -#include "common.h" -#include "structs.h" - -#include "syntax.h" -#include "ms.h" -#include "is.h" -#include "pns.h" - -void ms_decode(ic_stream *ics, ic_stream *icsr, real_t *l_spec, real_t *r_spec, - uint16_t frame_len) -{ - uint8_t g, b, sfb; - uint8_t group = 0; - uint16_t nshort = frame_len/8; - - uint16_t i, k; - - if (ics->ms_mask_present >= 1) - { - for (g = 0; g < ics->num_window_groups; g++) - { - for (b = 0; b < ics->window_group_length[g]; b++) - { - for (sfb = 0; sfb < ics->max_sfb; sfb++) - { - /* If intensity stereo coding or noise substitution is on - for a particular scalefactor band, no M/S stereo decoding - is carried out. - */ - if ((ics->ms_used[g][sfb] || ics->ms_mask_present == 2) && - !is_intensity(icsr, g, sfb) && !is_noise(ics, g, sfb)) - { - k = (group*nshort) + ics->swb_offset[sfb]; - for (i = ics->swb_offset[sfb]; i < ics->swb_offset[sfb+1]; i++, k++) - { - /* L' = L+R, R' = L-R */ - l_spec[k] = l_spec[k] + r_spec[k]; - r_spec[k] = l_spec[k] - (r_spec[k]<<1); - } - } - } - group++; - } - } - } -} diff --git a/apps/codecs/libfaad/ms.h b/apps/codecs/libfaad/ms.h deleted file mode 100644 index 384fa4294b..0000000000 --- a/apps/codecs/libfaad/ms.h +++ /dev/null @@ -1,41 +0,0 @@ -/* -** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -** -** Any non-GPL usage of this software or parts of this software is strictly -** forbidden. -** -** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. -** -** $Id$ -**/ - -#ifndef __MS_H__ -#define __MS_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -void ms_decode(ic_stream *ics, ic_stream *icsr, real_t *l_spec, real_t *r_spec, - uint16_t frame_len); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/apps/codecs/libfaad/output.c b/apps/codecs/libfaad/output.c deleted file mode 100644 index 6594582bbd..0000000000 --- a/apps/codecs/libfaad/output.c +++ /dev/null @@ -1,557 +0,0 @@ -/* -** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -** -** Any non-GPL usage of this software or parts of this software is strictly -** forbidden. -** -** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. -** -** $Id$ -**/ - -#include "common.h" -#include "structs.h" - -#include "output.h" -#include "decoder.h" - -#ifndef FIXED_POINT - - -#define FLOAT_SCALE (1.0f/(1<<15)) - -#define DM_MUL REAL_CONST(0.3203772410170407) // 1/(1+sqrt(2) + 1/sqrt(2)) -#define RSQRT2 REAL_CONST(0.7071067811865475244) // 1/sqrt(2) - - -static INLINE real_t get_sample(real_t **input, uint8_t channel, uint16_t sample, - uint8_t down_matrix, uint8_t *internal_channel) -{ - if (!down_matrix) - return input[internal_channel[channel]][sample]; - - if (channel == 0) - { - return DM_MUL * (input[internal_channel[1]][sample] + - input[internal_channel[0]][sample] * RSQRT2 + - input[internal_channel[3]][sample] * RSQRT2); - } else { - return DM_MUL * (input[internal_channel[2]][sample] + - input[internal_channel[0]][sample] * RSQRT2 + - input[internal_channel[4]][sample] * RSQRT2); - } -} - -#ifndef HAS_LRINTF -#define CLIP(sample, max, min) \ -if (sample >= 0.0f) \ -{ \ - sample += 0.5f; \ - if (sample >= max) \ - sample = max; \ -} else { \ - sample += -0.5f; \ - if (sample <= min) \ - sample = min; \ -} -#else -#define CLIP(sample, max, min) \ -if (sample >= 0.0f) \ -{ \ - if (sample >= max) \ - sample = max; \ -} else { \ - if (sample <= min) \ - sample = min; \ -} -#endif - -#define CONV(a,b) ((a<<1)|(b&0x1)) - -static void to_PCM_16bit(NeAACDecHandle hDecoder, real_t **input, - uint8_t channels, uint16_t frame_len, - int16_t **sample_buffer) -{ - uint8_t ch, ch1; - uint16_t i; - - switch (CONV(channels,hDecoder->downMatrix)) - { - case CONV(1,0): - case CONV(1,1): - for(i = 0; i < frame_len; i++) - { - real_t inp = input[hDecoder->internal_channel[0]][i]; - - CLIP(inp, 32767.0f, -32768.0f); - - (*sample_buffer)[i] = (int16_t)lrintf(inp); - } - break; - case CONV(2,0): - if (hDecoder->upMatrix) - { - ch = hDecoder->internal_channel[0]; - for(i = 0; i < frame_len; i++) - { - real_t inp0 = input[ch][i]; - - CLIP(inp0, 32767.0f, -32768.0f); - - (*sample_buffer)[(i*2)+0] = (int16_t)lrintf(inp0); - (*sample_buffer)[(i*2)+1] = (int16_t)lrintf(inp0); - } - } else { - ch = hDecoder->internal_channel[0]; - ch1 = hDecoder->internal_channel[1]; - for(i = 0; i < frame_len; i++) - { - real_t inp0 = input[ch ][i]; - real_t inp1 = input[ch1][i]; - - CLIP(inp0, 32767.0f, -32768.0f); - CLIP(inp1, 32767.0f, -32768.0f); - - (*sample_buffer)[(i*2)+0] = (int16_t)lrintf(inp0); - (*sample_buffer)[(i*2)+1] = (int16_t)lrintf(inp1); - } - } - break; - default: - for (ch = 0; ch < channels; ch++) - { - for(i = 0; i < frame_len; i++) - { - real_t inp = get_sample(input, ch, i, hDecoder->downMatrix, hDecoder->internal_channel); - - CLIP(inp, 32767.0f, -32768.0f); - - (*sample_buffer)[(i*channels)+ch] = (int16_t)lrintf(inp); - } - } - break; - } -} - -static void to_PCM_24bit(NeAACDecHandle hDecoder, real_t **input, - uint8_t channels, uint16_t frame_len, - int32_t **sample_buffer) -{ - uint8_t ch, ch1; - uint16_t i; - - switch (CONV(channels,hDecoder->downMatrix)) - { - case CONV(1,0): - case CONV(1,1): - for(i = 0; i < frame_len; i++) - { - real_t inp = input[hDecoder->internal_channel[0]][i]; - - inp *= 256.0f; - CLIP(inp, 8388607.0f, -8388608.0f); - - (*sample_buffer)[i] = (int32_t)lrintf(inp); - } - break; - case CONV(2,0): - if (hDecoder->upMatrix) - { - ch = hDecoder->internal_channel[0]; - for(i = 0; i < frame_len; i++) - { - real_t inp0 = input[ch][i]; - - inp0 *= 256.0f; - CLIP(inp0, 8388607.0f, -8388608.0f); - - (*sample_buffer)[(i*2)+0] = (int32_t)lrintf(inp0); - (*sample_buffer)[(i*2)+1] = (int32_t)lrintf(inp0); - } - } else { - ch = hDecoder->internal_channel[0]; - ch1 = hDecoder->internal_channel[1]; - for(i = 0; i < frame_len; i++) - { - real_t inp0 = input[ch ][i]; - real_t inp1 = input[ch1][i]; - - inp0 *= 256.0f; - inp1 *= 256.0f; - CLIP(inp0, 8388607.0f, -8388608.0f); - CLIP(inp1, 8388607.0f, -8388608.0f); - - (*sample_buffer)[(i*2)+0] = (int32_t)lrintf(inp0); - (*sample_buffer)[(i*2)+1] = (int32_t)lrintf(inp1); - } - } - break; - default: - for (ch = 0; ch < channels; ch++) - { - for(i = 0; i < frame_len; i++) - { - real_t inp = get_sample(input, ch, i, hDecoder->downMatrix, hDecoder->internal_channel); - - inp *= 256.0f; - CLIP(inp, 8388607.0f, -8388608.0f); - - (*sample_buffer)[(i*channels)+ch] = (int32_t)lrintf(inp); - } - } - break; - } -} - -static void to_PCM_32bit(NeAACDecHandle hDecoder, real_t **input, - uint8_t channels, uint16_t frame_len, - int32_t **sample_buffer) -{ - uint8_t ch, ch1; - uint16_t i; - - switch (CONV(channels,hDecoder->downMatrix)) - { - case CONV(1,0): - case CONV(1,1): - for(i = 0; i < frame_len; i++) - { - real_t inp = input[hDecoder->internal_channel[0]][i]; - - inp *= 65536.0f; - CLIP(inp, 2147483647.0f, -2147483648.0f); - - (*sample_buffer)[i] = (int32_t)lrintf(inp); - } - break; - case CONV(2,0): - if (hDecoder->upMatrix) - { - ch = hDecoder->internal_channel[0]; - for(i = 0; i < frame_len; i++) - { - real_t inp0 = input[ch][i]; - - inp0 *= 65536.0f; - CLIP(inp0, 2147483647.0f, -2147483648.0f); - - (*sample_buffer)[(i*2)+0] = (int32_t)lrintf(inp0); - (*sample_buffer)[(i*2)+1] = (int32_t)lrintf(inp0); - } - } else { - ch = hDecoder->internal_channel[0]; - ch1 = hDecoder->internal_channel[1]; - for(i = 0; i < frame_len; i++) - { - real_t inp0 = input[ch ][i]; - real_t inp1 = input[ch1][i]; - - inp0 *= 65536.0f; - inp1 *= 65536.0f; - CLIP(inp0, 2147483647.0f, -2147483648.0f); - CLIP(inp1, 2147483647.0f, -2147483648.0f); - - (*sample_buffer)[(i*2)+0] = (int32_t)lrintf(inp0); - (*sample_buffer)[(i*2)+1] = (int32_t)lrintf(inp1); - } - } - break; - default: - for (ch = 0; ch < channels; ch++) - { - for(i = 0; i < frame_len; i++) - { - real_t inp = get_sample(input, ch, i, hDecoder->downMatrix, hDecoder->internal_channel); - - inp *= 65536.0f; - CLIP(inp, 2147483647.0f, -2147483648.0f); - - (*sample_buffer)[(i*channels)+ch] = (int32_t)lrintf(inp); - } - } - break; - } -} - -static void to_PCM_float(NeAACDecHandle hDecoder, real_t **input, - uint8_t channels, uint16_t frame_len, - float32_t **sample_buffer) -{ - uint8_t ch, ch1; - uint16_t i; - - switch (CONV(channels,hDecoder->downMatrix)) - { - case CONV(1,0): - case CONV(1,1): - for(i = 0; i < frame_len; i++) - { - real_t inp = input[hDecoder->internal_channel[0]][i]; - (*sample_buffer)[i] = inp*FLOAT_SCALE; - } - break; - case CONV(2,0): - if (hDecoder->upMatrix) - { - ch = hDecoder->internal_channel[0]; - for(i = 0; i < frame_len; i++) - { - real_t inp0 = input[ch][i]; - (*sample_buffer)[(i*2)+0] = inp0*FLOAT_SCALE; - (*sample_buffer)[(i*2)+1] = inp0*FLOAT_SCALE; - } - } else { - ch = hDecoder->internal_channel[0]; - ch1 = hDecoder->internal_channel[1]; - for(i = 0; i < frame_len; i++) - { - real_t inp0 = input[ch ][i]; - real_t inp1 = input[ch1][i]; - (*sample_buffer)[(i*2)+0] = inp0*FLOAT_SCALE; - (*sample_buffer)[(i*2)+1] = inp1*FLOAT_SCALE; - } - } - break; - default: - for (ch = 0; ch < channels; ch++) - { - for(i = 0; i < frame_len; i++) - { - real_t inp = get_sample(input, ch, i, hDecoder->downMatrix, hDecoder->internal_channel); - (*sample_buffer)[(i*channels)+ch] = inp*FLOAT_SCALE; - } - } - break; - } -} - -static void to_PCM_double(NeAACDecHandle hDecoder, real_t **input, - uint8_t channels, uint16_t frame_len, - double **sample_buffer) -{ - uint8_t ch, ch1; - uint16_t i; - - switch (CONV(channels,hDecoder->downMatrix)) - { - case CONV(1,0): - case CONV(1,1): - for(i = 0; i < frame_len; i++) - { - real_t inp = input[hDecoder->internal_channel[0]][i]; - (*sample_buffer)[i] = (double)inp*FLOAT_SCALE; - } - break; - case CONV(2,0): - if (hDecoder->upMatrix) - { - ch = hDecoder->internal_channel[0]; - for(i = 0; i < frame_len; i++) - { - real_t inp0 = input[ch][i]; - (*sample_buffer)[(i*2)+0] = (double)inp0*FLOAT_SCALE; - (*sample_buffer)[(i*2)+1] = (double)inp0*FLOAT_SCALE; - } - } else { - ch = hDecoder->internal_channel[0]; - ch1 = hDecoder->internal_channel[1]; - for(i = 0; i < frame_len; i++) - { - real_t inp0 = input[ch ][i]; - real_t inp1 = input[ch1][i]; - (*sample_buffer)[(i*2)+0] = (double)inp0*FLOAT_SCALE; - (*sample_buffer)[(i*2)+1] = (double)inp1*FLOAT_SCALE; - } - } - break; - default: - for (ch = 0; ch < channels; ch++) - { - for(i = 0; i < frame_len; i++) - { - real_t inp = get_sample(input, ch, i, hDecoder->downMatrix, hDecoder->internal_channel); - (*sample_buffer)[(i*channels)+ch] = (double)inp*FLOAT_SCALE; - } - } - break; - } -} - -void *output_to_PCM(NeAACDecHandle hDecoder, - real_t **input, void *sample_buffer, uint8_t channels, - uint16_t frame_len, uint8_t format) -{ - int16_t *short_sample_buffer = (int16_t*)sample_buffer; - int32_t *int_sample_buffer = (int32_t*)sample_buffer; - float32_t *float_sample_buffer = (float32_t*)sample_buffer; - double *double_sample_buffer = (double*)sample_buffer; - -#ifdef PROFILE - int64_t count = faad_get_ts(); -#endif - - /* Copy output to a standard PCM buffer */ - switch (format) - { - case FAAD_FMT_16BIT: - to_PCM_16bit(hDecoder, input, channels, frame_len, &short_sample_buffer); - break; - case FAAD_FMT_24BIT: - to_PCM_24bit(hDecoder, input, channels, frame_len, &int_sample_buffer); - break; - case FAAD_FMT_32BIT: - to_PCM_32bit(hDecoder, input, channels, frame_len, &int_sample_buffer); - break; - case FAAD_FMT_FLOAT: - to_PCM_float(hDecoder, input, channels, frame_len, &float_sample_buffer); - break; - case FAAD_FMT_DOUBLE: - to_PCM_double(hDecoder, input, channels, frame_len, &double_sample_buffer); - break; - } - -#ifdef PROFILE - count = faad_get_ts() - count; - hDecoder->output_cycles += count; -#endif - - return sample_buffer; -} - -#else - -#define DM_MUL FRAC_CONST(0.3203772410170407) // 1/(1+sqrt(2) + 1/sqrt(2)) -#define RSQRT2 FRAC_CONST(0.7071067811865475244) // 1/sqrt(2) - -static INLINE real_t get_sample(real_t **input, uint8_t channel, uint16_t sample, - uint8_t down_matrix, uint8_t up_matrix, - uint8_t *internal_channel) -{ - if (up_matrix == 1) - return input[internal_channel[0]][sample]; - - if (!down_matrix) - return input[internal_channel[channel]][sample]; - - if (channel == 0) - { - real_t C = MUL_F(input[internal_channel[0]][sample], RSQRT2); - real_t L_S = MUL_F(input[internal_channel[3]][sample], RSQRT2); - real_t cum = input[internal_channel[1]][sample] + C + L_S; - return MUL_F(cum, DM_MUL); - } else { - real_t C = MUL_F(input[internal_channel[0]][sample], RSQRT2); - real_t R_S = MUL_F(input[internal_channel[4]][sample], RSQRT2); - real_t cum = input[internal_channel[2]][sample] + C + R_S; - return MUL_F(cum, DM_MUL); - } -} - -void* output_to_PCM(NeAACDecHandle hDecoder, - real_t **input, void *sample_buffer, uint8_t channels, - uint16_t frame_len, uint8_t format) -{ - uint8_t ch; - uint16_t i; - int16_t *short_sample_buffer = (int16_t*)sample_buffer; - int32_t *int_sample_buffer = (int32_t*)sample_buffer; - - /* Copy output to a standard PCM buffer */ - for (ch = 0; ch < channels; ch++) - { - switch (format) - { - case FAAD_FMT_16BIT: - for(i = 0; i < frame_len; i++) - { - int32_t tmp = get_sample(input, ch, i, hDecoder->downMatrix, hDecoder->upMatrix, - hDecoder->internal_channel); - if (tmp >= 0) - { - tmp += (1 << (REAL_BITS-1)); - if (tmp >= REAL_CONST(32767)) - { - tmp = REAL_CONST(32767); - } - } else { - tmp += -(1 << (REAL_BITS-1)); - if (tmp <= REAL_CONST(-32768)) - { - tmp = REAL_CONST(-32768); - } - } - tmp >>= REAL_BITS; - short_sample_buffer[(i*channels)+ch] = (int16_t)tmp; - } - break; - case FAAD_FMT_24BIT: - for(i = 0; i < frame_len; i++) - { - int32_t tmp = get_sample(input, ch, i, hDecoder->downMatrix, hDecoder->upMatrix, - hDecoder->internal_channel); - if (tmp >= 0) - { - tmp += (1 << (REAL_BITS-9)); - tmp >>= (REAL_BITS-8); - if (tmp >= 8388607) - { - tmp = 8388607; - } - } else { - tmp += -(1 << (REAL_BITS-9)); - tmp >>= (REAL_BITS-8); - if (tmp <= -8388608) - { - tmp = -8388608; - } - } - int_sample_buffer[(i*channels)+ch] = (int32_t)tmp; - } - break; - case FAAD_FMT_32BIT: - for(i = 0; i < frame_len; i++) - { - int32_t tmp = get_sample(input, ch, i, hDecoder->downMatrix, hDecoder->upMatrix, - hDecoder->internal_channel); - if (tmp >= 0) - { - tmp += (1 << (16-REAL_BITS-1)); - tmp <<= (16-REAL_BITS); - } else { - tmp += -(1 << (16-REAL_BITS-1)); - tmp <<= (16-REAL_BITS); - } - int_sample_buffer[(i*channels)+ch] = (int32_t)tmp; - } - break; - case FAAD_FMT_FIXED: - for(i = 0; i < frame_len; i++) - { - real_t tmp = get_sample(input, ch, i, hDecoder->downMatrix, hDecoder->upMatrix, - hDecoder->internal_channel); - int_sample_buffer[(i*channels)+ch] = (int32_t)tmp; - } - break; - } - } - - return sample_buffer; -} - -#endif diff --git a/apps/codecs/libfaad/output.h b/apps/codecs/libfaad/output.h deleted file mode 100644 index 9fe8356541..0000000000 --- a/apps/codecs/libfaad/output.h +++ /dev/null @@ -1,45 +0,0 @@ -/* -** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -** -** Any non-GPL usage of this software or parts of this software is strictly -** forbidden. -** -** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. -** -** $Id$ -**/ - -#ifndef __OUTPUT_H__ -#define __OUTPUT_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -void* output_to_PCM(NeAACDecHandle hDecoder, - real_t **input, - void *samplebuffer, - uint8_t channels, - uint16_t frame_len, - uint8_t format); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/apps/codecs/libfaad/pns.c b/apps/codecs/libfaad/pns.c deleted file mode 100644 index b75cf9f1ed..0000000000 --- a/apps/codecs/libfaad/pns.c +++ /dev/null @@ -1,263 +0,0 @@ -/* -** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -** -** Any non-GPL usage of this software or parts of this software is strictly -** forbidden. -** -** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. -** -** $Id$ -**/ - -#include "common.h" -#include "structs.h" - -#include "pns.h" - - -/* static function declarations */ -static void gen_rand_vector(real_t *spec, int16_t scale_factor, uint16_t size, - uint8_t sub); - - -#ifdef FIXED_POINT - -#define step(shift) \ - if ((0x40000000l >> shift) + root <= value) \ - { \ - value -= (0x40000000l >> shift) + root; \ - root = (root >> 1) | (0x40000000l >> shift); \ - } else { \ - root = root >> 1; \ - } - -/* fixed point square root approximation */ -/* !!!! ONLY WORKS FOR EVEN %REAL_BITS% !!!! */ -static real_t fp_sqrt(real_t value) -{ - real_t root = 0; - - step( 0); step( 2); step( 4); step( 6); - step( 8); step(10); step(12); step(14); - step(16); step(18); step(20); step(22); - step(24); step(26); step(28); step(30); - - if (root < value) - ++root; - - root <<= (REAL_BITS/2); - - return root; -} - -static real_t pow2_table[] = -{ - COEF_CONST(1.0), - COEF_CONST(1.18920711500272), - COEF_CONST(1.41421356237310), - COEF_CONST(1.68179283050743) -}; -#endif - -/* The function gen_rand_vector(addr, size) generates a vector of length - with signed random values of average energy MEAN_NRG per random - value. A suitable random number generator can be realized using one - multiplication/accumulation per random value. -*/ -static INLINE void gen_rand_vector(real_t *spec, int16_t scale_factor, uint16_t size, - uint8_t sub) -{ -#ifndef FIXED_POINT - uint16_t i; - real_t energy = 0.0; - - real_t scale = (real_t)1.0/(real_t)size; - - for (i = 0; i < size; i++) - { - real_t tmp = scale*(real_t)(int32_t)random_int(); - spec[i] = tmp; - energy += tmp*tmp; - } - - scale = (real_t)1.0/(real_t)sqrt(energy); - scale *= (real_t)pow(2.0, 0.25 * scale_factor); - for (i = 0; i < size; i++) - { - spec[i] *= scale; - } -#else - uint16_t i; - real_t energy = 0, scale; - int32_t exp, frac; - - for (i = 0; i < size; i++) - { - /* this can be replaced by a 16 bit random generator!!!! */ - real_t tmp = (int32_t)random_int(); - if (tmp < 0) - tmp = -(tmp & ((1<<(REAL_BITS-1))-1)); - else - tmp = (tmp & ((1<<(REAL_BITS-1))-1)); - - energy += MUL_R(tmp,tmp); - - spec[i] = tmp; - } - - energy = fp_sqrt(energy); - if (energy > 0) - { - scale = DIV_R(REAL_CONST(1), energy); - - exp = scale_factor >> 2; - frac = scale_factor & 3; - - /* IMDCT pre-scaling */ - exp -= sub; - - if (exp < 0) - scale >>= -exp; - else - scale <<= exp; - - if (frac) - scale = MUL_C(scale, pow2_table[frac]); - - for (i = 0; i < size; i++) - { - spec[i] = MUL_R(spec[i], scale); - } - } -#endif -} - -void pns_decode(ic_stream *ics_left, ic_stream *ics_right, - real_t *spec_left, real_t *spec_right, uint16_t frame_len, - uint8_t channel_pair, uint8_t object_type) -{ - uint8_t g, sfb, b; - uint16_t size, offs; - - uint8_t group = 0; - uint16_t nshort = frame_len >> 3; - - uint8_t sub = 0; - -#ifdef FIXED_POINT - /* IMDCT scaling */ - if (object_type == LD) - { - sub = 9 /*9*/; - } else { - if (ics_left->window_sequence == EIGHT_SHORT_SEQUENCE) - sub = 7 /*7*/; - else - sub = 10 /*10*/; - } -#endif - - for (g = 0; g < ics_left->num_window_groups; g++) - { - /* Do perceptual noise substitution decoding */ - for (b = 0; b < ics_left->window_group_length[g]; b++) - { - for (sfb = 0; sfb < ics_left->max_sfb; sfb++) - { - if (is_noise(ics_left, g, sfb)) - { -#ifdef LTP_DEC - /* Simultaneous use of LTP and PNS is not prevented in the - syntax. If both LTP, and PNS are enabled on the same - scalefactor band, PNS takes precedence, and no prediction - is applied to this band. - */ - ics_left->ltp.long_used[sfb] = 0; - ics_left->ltp2.long_used[sfb] = 0; -#endif - -#ifdef MAIN_DEC - /* For scalefactor bands coded using PNS the corresponding - predictors are switched to "off". - */ - ics_left->pred.prediction_used[sfb] = 0; -#endif - - offs = ics_left->swb_offset[sfb]; - size = ics_left->swb_offset[sfb+1] - offs; - - /* Generate random vector */ - gen_rand_vector(&spec_left[(group*nshort)+offs], - ics_left->scale_factors[g][sfb], size, sub); - } - -/* From the spec: - If the same scalefactor band and group is coded by perceptual noise - substitution in both channels of a channel pair, the correlation of - the noise signal can be controlled by means of the ms_used field: While - the default noise generation process works independently for each channel - (separate generation of random vectors), the same random vector is used - for both channels if ms_used[] is set for a particular scalefactor band - and group. In this case, no M/S stereo coding is carried out (because M/S - stereo coding and noise substitution coding are mutually exclusive). - If the same scalefactor band and group is coded by perceptual noise - substitution in only one channel of a channel pair the setting of ms_used[] - is not evaluated. -*/ - if (channel_pair) - { - if (is_noise(ics_right, g, sfb)) - { - if (((ics_left->ms_mask_present == 1) && - (ics_left->ms_used[g][sfb])) || - (ics_left->ms_mask_present == 2)) - { - uint16_t c; - - offs = ics_right->swb_offset[sfb]; - size = ics_right->swb_offset[sfb+1] - offs; - - for (c = 0; c < size; c++) - { - spec_right[(group*nshort) + offs + c] = - spec_left[(group*nshort) + offs + c]; - } - } else /*if (ics_left->ms_mask_present == 0)*/ { -#ifdef LTP_DEC - ics_right->ltp.long_used[sfb] = 0; - ics_right->ltp2.long_used[sfb] = 0; -#endif -#ifdef MAIN_DEC - ics_right->pred.prediction_used[sfb] = 0; -#endif - - offs = ics_right->swb_offset[sfb]; - size = ics_right->swb_offset[sfb+1] - offs; - - /* Generate random vector */ - gen_rand_vector(&spec_right[(group*nshort)+offs], - ics_right->scale_factors[g][sfb], size, sub); - } - } - } - } /* sfb */ - group++; - } /* b */ - } /* g */ -} diff --git a/apps/codecs/libfaad/pns.h b/apps/codecs/libfaad/pns.h deleted file mode 100644 index e789f5708a..0000000000 --- a/apps/codecs/libfaad/pns.h +++ /dev/null @@ -1,53 +0,0 @@ -/* -** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -** -** Any non-GPL usage of this software or parts of this software is strictly -** forbidden. -** -** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. -** -** $Id$ -**/ - -#ifndef __PNS_H__ -#define __PNS_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -#include "syntax.h" - -#define NOISE_OFFSET 90 - -void pns_decode(ic_stream *ics_left, ic_stream *ics_right, - real_t *spec_left, real_t *spec_right, uint16_t frame_len, - uint8_t channel_pair, uint8_t object_type); - -static INLINE uint8_t is_noise(ic_stream *ics, uint8_t group, uint8_t sfb) -{ - if (ics->sfb_cb[group][sfb] == NOISE_HCB) - return 1; - return 0; -} - -#ifdef __cplusplus -} -#endif -#endif diff --git a/apps/codecs/libfaad/ps_dec.c b/apps/codecs/libfaad/ps_dec.c deleted file mode 100644 index 3fed4e6a0a..0000000000 --- a/apps/codecs/libfaad/ps_dec.c +++ /dev/null @@ -1,1938 +0,0 @@ -/* -** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR and PS decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -** -** Any non-GPL usage of this software or parts of this software is strictly -** forbidden. -** -** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. -** -** $Id$ -**/ - -#include "common.h" - -#ifdef PS_DEC - -#include -#include "ps_dec.h" -#include "ps_tables.h" - -/* constants */ -#define NEGATE_IPD_MASK (0x1000) -#define DECAY_SLOPE FRAC_CONST(0.05) -#define COEF_SQRT2 COEF_CONST(1.4142135623731) - -/* tables */ -/* filters are mirrored in coef 6, second half left out */ -static const real_t p8_13_20[7] = -{ - FRAC_CONST(0.00746082949812), - FRAC_CONST(0.02270420949825), - FRAC_CONST(0.04546865930473), - FRAC_CONST(0.07266113929591), - FRAC_CONST(0.09885108575264), - FRAC_CONST(0.11793710567217), - FRAC_CONST(0.125) -}; - -static const real_t p2_13_20[7] = -{ - FRAC_CONST(0.0), - FRAC_CONST(0.01899487526049), - FRAC_CONST(0.0), - FRAC_CONST(-0.07293139167538), - FRAC_CONST(0.0), - FRAC_CONST(0.30596630545168), - FRAC_CONST(0.5) -}; - -static const real_t p12_13_34[7] = -{ - FRAC_CONST(0.04081179924692), - FRAC_CONST(0.03812810994926), - FRAC_CONST(0.05144908135699), - FRAC_CONST(0.06399831151592), - FRAC_CONST(0.07428313801106), - FRAC_CONST(0.08100347892914), - FRAC_CONST(0.08333333333333) -}; - -static const real_t p8_13_34[7] = -{ - FRAC_CONST(0.01565675600122), - FRAC_CONST(0.03752716391991), - FRAC_CONST(0.05417891378782), - FRAC_CONST(0.08417044116767), - FRAC_CONST(0.10307344158036), - FRAC_CONST(0.12222452249753), - FRAC_CONST(0.125) -}; - -static const real_t p4_13_34[7] = -{ - FRAC_CONST(-0.05908211155639), - FRAC_CONST(-0.04871498374946), - FRAC_CONST(0.0), - FRAC_CONST(0.07778723915851), - FRAC_CONST(0.16486303567403), - FRAC_CONST(0.23279856662996), - FRAC_CONST(0.25) -}; - -#ifdef PARAM_32KHZ -static const uint8_t delay_length_d[2][NO_ALLPASS_LINKS] = { - { 1, 2, 3 } /* d_24kHz */, - { 3, 4, 5 } /* d_48kHz */ -}; -#else -static const uint8_t delay_length_d[NO_ALLPASS_LINKS] = { - 3, 4, 5 /* d_48kHz */ -}; -#endif -static const real_t filter_a[NO_ALLPASS_LINKS] = { /* a(m) = exp(-d_48kHz(m)/7) */ - FRAC_CONST(0.65143905753106), - FRAC_CONST(0.56471812200776), - FRAC_CONST(0.48954165955695) -}; - -static const uint8_t group_border20[10+12 + 1] = -{ - 6, 7, 0, 1, 2, 3, /* 6 subqmf subbands */ - 9, 8, /* 2 subqmf subbands */ - 10, 11, /* 2 subqmf subbands */ - 3, 4, 5, 6, 7, 8, 9, 11, 14, 18, 23, 35, 64 -}; - -static const uint8_t group_border34[32+18 + 1] = -{ - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, /* 12 subqmf subbands */ - 12, 13, 14, 15, 16, 17, 18, 19, /* 8 subqmf subbands */ - 20, 21, 22, 23, /* 4 subqmf subbands */ - 24, 25, 26, 27, /* 4 subqmf subbands */ - 28, 29, 30, 31, /* 4 subqmf subbands */ - 32-27, 33-27, 34-27, 35-27, 36-27, 37-27, 38-27, 40-27, 42-27, 44-27, 46-27, 48-27, 51-27, 54-27, 57-27, 60-27, 64-27, 68-27, 91-27 -}; - -static const uint16_t map_group2bk20[10+12] = -{ - (NEGATE_IPD_MASK | 1), (NEGATE_IPD_MASK | 0), - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 -}; - -static const uint16_t map_group2bk34[32+18] = -{ - 0, 1, 2, 3, 4, 5, 6, 6, 7, (NEGATE_IPD_MASK | 2), (NEGATE_IPD_MASK | 1), (NEGATE_IPD_MASK | 0), - 10, 10, 4, 5, 6, 7, 8, 9, - 10, 11, 12, 9, - 14, 11, 12, 13, - 14, 15, 16, 13, - 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33 -}; - - -/* static function declarations */ -static void ps_data_decode(ps_info *ps); -static void hybrid_init(hyb_info *hyb); -static void channel_filter2(hyb_info *hyb, uint8_t frame_len, const real_t *filter, - qmf_t *buffer, qmf_t X_hybrid[32][12]); -static INLINE void DCT3_4_unscaled(real_t *y, real_t *x); -static void channel_filter8(hyb_info *hyb, uint8_t frame_len, const real_t *filter, - qmf_t *buffer, qmf_t X_hybrid[32][12]); -static void hybrid_analysis(hyb_info *hyb, qmf_t X[32][64], qmf_t X_hybrid[32][32], - uint8_t use34); -static void hybrid_synthesis(hyb_info *hyb, qmf_t X[32][64], qmf_t X_hybrid[32][32], - uint8_t use34); -static int8_t delta_clip(int8_t i, int8_t min, int8_t max); -static void delta_decode(uint8_t enable, int8_t *index, int8_t *index_prev, - uint8_t dt_flag, uint8_t nr_par, uint8_t stride, - int8_t min_index, int8_t max_index); -static void delta_modulo_decode(uint8_t enable, int8_t *index, int8_t *index_prev, - uint8_t dt_flag, uint8_t nr_par, uint8_t stride, - int8_t log2modulo); -static void map20indexto34(int8_t *index, uint8_t bins); -#ifdef PS_LOW_POWER -static void map34indexto20(int8_t *index, uint8_t bins); -#endif -static void ps_data_decode(ps_info *ps); -static void ps_decorrelate(ps_info *ps, - qmf_t X_left[MAX_NTSRPS][64], - qmf_t X_right[MAX_NTSRPS][64], - qmf_t X_hybrid_left[32][32], - qmf_t X_hybrid_right[32][32]); -static void ps_mix_phase(ps_info *ps, - qmf_t X_left[MAX_NTSRPS][64], - qmf_t X_right[MAX_NTSRPS][64], - qmf_t X_hybrid_left[32][32], - qmf_t X_hybrid_right[32][32]); - -/* */ - - -static void hybrid_init(hyb_info *hyb) -{ - hyb->resolution34[0] = 12; - hyb->resolution34[1] = 8; - hyb->resolution34[2] = 4; - hyb->resolution34[3] = 4; - hyb->resolution34[4] = 4; - - hyb->resolution20[0] = 8; - hyb->resolution20[1] = 2; - hyb->resolution20[2] = 2; - - hyb->frame_len = 32; - - memset(hyb->work , 0, sizeof(hyb->work)); - memset(hyb->buffer, 0, sizeof(hyb->buffer)); - memset(hyb->temp , 0, sizeof(hyb->temp)); -} - -/* real filter, size 2 */ -static void channel_filter2(hyb_info *hyb, uint8_t frame_len, const real_t *filter, - qmf_t *buffer, qmf_t X_hybrid[32][12]) -{ - uint8_t i; - - (void)hyb; - for (i = 0; i < frame_len; i++) - { - real_t r0 = MUL_F(filter[0],(QMF_RE(buffer[0+i]) + QMF_RE(buffer[12+i]))); - real_t r1 = MUL_F(filter[1],(QMF_RE(buffer[1+i]) + QMF_RE(buffer[11+i]))); - real_t r2 = MUL_F(filter[2],(QMF_RE(buffer[2+i]) + QMF_RE(buffer[10+i]))); - real_t r3 = MUL_F(filter[3],(QMF_RE(buffer[3+i]) + QMF_RE(buffer[9+i]))); - real_t r4 = MUL_F(filter[4],(QMF_RE(buffer[4+i]) + QMF_RE(buffer[8+i]))); - real_t r5 = MUL_F(filter[5],(QMF_RE(buffer[5+i]) + QMF_RE(buffer[7+i]))); - real_t r6 = MUL_F(filter[6],QMF_RE(buffer[6+i])); - real_t i0 = MUL_F(filter[0],(QMF_IM(buffer[0+i]) + QMF_IM(buffer[12+i]))); - real_t i1 = MUL_F(filter[1],(QMF_IM(buffer[1+i]) + QMF_IM(buffer[11+i]))); - real_t i2 = MUL_F(filter[2],(QMF_IM(buffer[2+i]) + QMF_IM(buffer[10+i]))); - real_t i3 = MUL_F(filter[3],(QMF_IM(buffer[3+i]) + QMF_IM(buffer[9+i]))); - real_t i4 = MUL_F(filter[4],(QMF_IM(buffer[4+i]) + QMF_IM(buffer[8+i]))); - real_t i5 = MUL_F(filter[5],(QMF_IM(buffer[5+i]) + QMF_IM(buffer[7+i]))); - real_t i6 = MUL_F(filter[6],QMF_IM(buffer[6+i])); - - /* q = 0 */ - QMF_RE(X_hybrid[i][0]) = r0 + r1 + r2 + r3 + r4 + r5 + r6; - QMF_IM(X_hybrid[i][0]) = i0 + i1 + i2 + i3 + i4 + i5 + i6; - - /* q = 1 */ - QMF_RE(X_hybrid[i][1]) = r0 - r1 + r2 - r3 + r4 - r5 + r6; - QMF_IM(X_hybrid[i][1]) = i0 - i1 + i2 - i3 + i4 - i5 + i6; - } -} - -/* complex filter, size 4 */ -static void channel_filter4(hyb_info *hyb, uint8_t frame_len, const real_t *filter, - qmf_t *buffer, qmf_t X_hybrid[32][12]) -{ - uint8_t i; - real_t input_re1[2], input_re2[2], input_im1[2], input_im2[2]; - - (void)hyb; - for (i = 0; i < frame_len; i++) - { - input_re1[0] = -MUL_F(filter[2], (QMF_RE(buffer[i+2]) + QMF_RE(buffer[i+10]))) + - MUL_F(filter[6], QMF_RE(buffer[i+6])); - input_re1[1] = MUL_F(FRAC_CONST(-0.70710678118655), - (MUL_F(filter[1], (QMF_RE(buffer[i+1]) + QMF_RE(buffer[i+11]))) + - MUL_F(filter[3], (QMF_RE(buffer[i+3]) + QMF_RE(buffer[i+9]))) - - MUL_F(filter[5], (QMF_RE(buffer[i+5]) + QMF_RE(buffer[i+7]))))); - - input_im1[0] = MUL_F(filter[0], (QMF_IM(buffer[i+0]) - QMF_IM(buffer[i+12]))) - - MUL_F(filter[4], (QMF_IM(buffer[i+4]) - QMF_IM(buffer[i+8]))); - input_im1[1] = MUL_F(FRAC_CONST(0.70710678118655), - (MUL_F(filter[1], (QMF_IM(buffer[i+1]) - QMF_IM(buffer[i+11]))) - - MUL_F(filter[3], (QMF_IM(buffer[i+3]) - QMF_IM(buffer[i+9]))) - - MUL_F(filter[5], (QMF_IM(buffer[i+5]) - QMF_IM(buffer[i+7]))))); - - input_re2[0] = MUL_F(filter[0], (QMF_RE(buffer[i+0]) - QMF_RE(buffer[i+12]))) - - MUL_F(filter[4], (QMF_RE(buffer[i+4]) - QMF_RE(buffer[i+8]))); - input_re2[1] = MUL_F(FRAC_CONST(0.70710678118655), - (MUL_F(filter[1], (QMF_RE(buffer[i+1]) - QMF_RE(buffer[i+11]))) - - MUL_F(filter[3], (QMF_RE(buffer[i+3]) - QMF_RE(buffer[i+9]))) - - MUL_F(filter[5], (QMF_RE(buffer[i+5]) - QMF_RE(buffer[i+7]))))); - - input_im2[0] = -MUL_F(filter[2], (QMF_IM(buffer[i+2]) + QMF_IM(buffer[i+10]))) + - MUL_F(filter[6], QMF_IM(buffer[i+6])); - input_im2[1] = MUL_F(FRAC_CONST(-0.70710678118655), - (MUL_F(filter[1], (QMF_IM(buffer[i+1]) + QMF_IM(buffer[i+11]))) + - MUL_F(filter[3], (QMF_IM(buffer[i+3]) + QMF_IM(buffer[i+9]))) - - MUL_F(filter[5], (QMF_IM(buffer[i+5]) + QMF_IM(buffer[i+7]))))); - - /* q == 0 */ - QMF_RE(X_hybrid[i][0]) = input_re1[0] + input_re1[1] + input_im1[0] + input_im1[1]; - QMF_IM(X_hybrid[i][0]) = -input_re2[0] - input_re2[1] + input_im2[0] + input_im2[1]; - - /* q == 1 */ - QMF_RE(X_hybrid[i][1]) = input_re1[0] - input_re1[1] - input_im1[0] + input_im1[1]; - QMF_IM(X_hybrid[i][1]) = input_re2[0] - input_re2[1] + input_im2[0] - input_im2[1]; - - /* q == 2 */ - QMF_RE(X_hybrid[i][2]) = input_re1[0] - input_re1[1] + input_im1[0] - input_im1[1]; - QMF_IM(X_hybrid[i][2]) = -input_re2[0] + input_re2[1] + input_im2[0] - input_im2[1]; - - /* q == 3 */ - QMF_RE(X_hybrid[i][3]) = input_re1[0] + input_re1[1] - input_im1[0] - input_im1[1]; - QMF_IM(X_hybrid[i][3]) = input_re2[0] + input_re2[1] + input_im2[0] + input_im2[1]; - } -} - -static INLINE void DCT3_4_unscaled(real_t *y, real_t *x) -{ - real_t f0, f1, f2, f3, f4, f5, f6, f7, f8; - - f0 = MUL_F(x[2], FRAC_CONST(0.7071067811865476)); - f1 = x[0] - f0; - f2 = x[0] + f0; - f3 = x[1] + x[3]; - f4 = MUL_C(x[1], COEF_CONST(1.3065629648763766)); - f5 = MUL_F(f3, FRAC_CONST(-0.9238795325112866)); - f6 = MUL_F(x[3], FRAC_CONST(-0.5411961001461967)); - f7 = f4 + f5; - f8 = f6 - f5; - y[3] = f2 - f8; - y[0] = f2 + f8; - y[2] = f1 - f7; - y[1] = f1 + f7; -} - -/* complex filter, size 8 */ -static void channel_filter8(hyb_info *hyb, uint8_t frame_len, const real_t *filter, - qmf_t *buffer, qmf_t X_hybrid[32][12]) -{ - uint8_t i, n; - real_t input_re1[4], input_re2[4], input_im1[4], input_im2[4]; - real_t x[4]; - - (void)hyb; - for (i = 0; i < frame_len; i++) - { - input_re1[0] = MUL_F(filter[6],QMF_RE(buffer[6+i])); - input_re1[1] = MUL_F(filter[5],(QMF_RE(buffer[5+i]) + QMF_RE(buffer[7+i]))); - input_re1[2] = -MUL_F(filter[0],(QMF_RE(buffer[0+i]) + QMF_RE(buffer[12+i]))) + MUL_F(filter[4],(QMF_RE(buffer[4+i]) + QMF_RE(buffer[8+i]))); - input_re1[3] = -MUL_F(filter[1],(QMF_RE(buffer[1+i]) + QMF_RE(buffer[11+i]))) + MUL_F(filter[3],(QMF_RE(buffer[3+i]) + QMF_RE(buffer[9+i]))); - - input_im1[0] = MUL_F(filter[5],(QMF_IM(buffer[7+i]) - QMF_IM(buffer[5+i]))); - input_im1[1] = MUL_F(filter[0],(QMF_IM(buffer[12+i]) - QMF_IM(buffer[0+i]))) + MUL_F(filter[4],(QMF_IM(buffer[8+i]) - QMF_IM(buffer[4+i]))); - input_im1[2] = MUL_F(filter[1],(QMF_IM(buffer[11+i]) - QMF_IM(buffer[1+i]))) + MUL_F(filter[3],(QMF_IM(buffer[9+i]) - QMF_IM(buffer[3+i]))); - input_im1[3] = MUL_F(filter[2],(QMF_IM(buffer[10+i]) - QMF_IM(buffer[2+i]))); - - for (n = 0; n < 4; n++) - { - x[n] = input_re1[n] - input_im1[3-n]; - } - DCT3_4_unscaled(x, x); - QMF_RE(X_hybrid[i][7]) = x[0]; - QMF_RE(X_hybrid[i][5]) = x[2]; - QMF_RE(X_hybrid[i][3]) = x[3]; - QMF_RE(X_hybrid[i][1]) = x[1]; - - for (n = 0; n < 4; n++) - { - x[n] = input_re1[n] + input_im1[3-n]; - } - DCT3_4_unscaled(x, x); - QMF_RE(X_hybrid[i][6]) = x[1]; - QMF_RE(X_hybrid[i][4]) = x[3]; - QMF_RE(X_hybrid[i][2]) = x[2]; - QMF_RE(X_hybrid[i][0]) = x[0]; - - input_im2[0] = MUL_F(filter[6],QMF_IM(buffer[6+i])); - input_im2[1] = MUL_F(filter[5],(QMF_IM(buffer[5+i]) + QMF_IM(buffer[7+i]))); - input_im2[2] = -MUL_F(filter[0],(QMF_IM(buffer[0+i]) + QMF_IM(buffer[12+i]))) + MUL_F(filter[4],(QMF_IM(buffer[4+i]) + QMF_IM(buffer[8+i]))); - input_im2[3] = -MUL_F(filter[1],(QMF_IM(buffer[1+i]) + QMF_IM(buffer[11+i]))) + MUL_F(filter[3],(QMF_IM(buffer[3+i]) + QMF_IM(buffer[9+i]))); - - input_re2[0] = MUL_F(filter[5],(QMF_RE(buffer[7+i]) - QMF_RE(buffer[5+i]))); - input_re2[1] = MUL_F(filter[0],(QMF_RE(buffer[12+i]) - QMF_RE(buffer[0+i]))) + MUL_F(filter[4],(QMF_RE(buffer[8+i]) - QMF_RE(buffer[4+i]))); - input_re2[2] = MUL_F(filter[1],(QMF_RE(buffer[11+i]) - QMF_RE(buffer[1+i]))) + MUL_F(filter[3],(QMF_RE(buffer[9+i]) - QMF_RE(buffer[3+i]))); - input_re2[3] = MUL_F(filter[2],(QMF_RE(buffer[10+i]) - QMF_RE(buffer[2+i]))); - - for (n = 0; n < 4; n++) - { - x[n] = input_im2[n] + input_re2[3-n]; - } - DCT3_4_unscaled(x, x); - QMF_IM(X_hybrid[i][7]) = x[0]; - QMF_IM(X_hybrid[i][5]) = x[2]; - QMF_IM(X_hybrid[i][3]) = x[3]; - QMF_IM(X_hybrid[i][1]) = x[1]; - - for (n = 0; n < 4; n++) - { - x[n] = input_im2[n] - input_re2[3-n]; - } - DCT3_4_unscaled(x, x); - QMF_IM(X_hybrid[i][6]) = x[1]; - QMF_IM(X_hybrid[i][4]) = x[3]; - QMF_IM(X_hybrid[i][2]) = x[2]; - QMF_IM(X_hybrid[i][0]) = x[0]; - } -} - -static INLINE void DCT3_6_unscaled(real_t *y, real_t *x) -{ - real_t f0, f1, f2, f3, f4, f5, f6, f7; - - f0 = MUL_F(x[3], FRAC_CONST(0.70710678118655)); - f1 = x[0] + f0; - f2 = x[0] - f0; - f3 = MUL_F((x[1] - x[5]), FRAC_CONST(0.70710678118655)); - f4 = MUL_F(x[2], FRAC_CONST(0.86602540378444)) + MUL_F(x[4], FRAC_CONST(0.5)); - f5 = f4 - x[4]; - f6 = MUL_F(x[1], FRAC_CONST(0.96592582628907)) + MUL_F(x[5], FRAC_CONST(0.25881904510252)); - f7 = f6 - f3; - y[0] = f1 + f6 + f4; - y[1] = f2 + f3 - x[4]; - y[2] = f7 + f2 - f5; - y[3] = f1 - f7 - f5; - y[4] = f1 - f3 - x[4]; - y[5] = f2 - f6 + f4; -} - -/* complex filter, size 12 */ -static void channel_filter12(hyb_info *hyb, uint8_t frame_len, const real_t *filter, - qmf_t *buffer, qmf_t X_hybrid[32][12]) -{ - uint8_t i, n; - real_t input_re1[6], input_re2[6], input_im1[6], input_im2[6]; - real_t out_re1[6], out_re2[6], out_im1[6], out_im2[6]; - - (void)hyb; - for (i = 0; i < frame_len; i++) - { - for (n = 0; n < 6; n++) - { - if (n == 0) - { - input_re1[0] = MUL_F(QMF_RE(buffer[6+i]), filter[6]); - input_re2[0] = MUL_F(QMF_IM(buffer[6+i]), filter[6]); - } else { - input_re1[6-n] = MUL_F((QMF_RE(buffer[n+i]) + QMF_RE(buffer[12-n+i])), filter[n]); - input_re2[6-n] = MUL_F((QMF_IM(buffer[n+i]) + QMF_IM(buffer[12-n+i])), filter[n]); - } - input_im2[n] = MUL_F((QMF_RE(buffer[n+i]) - QMF_RE(buffer[12-n+i])), filter[n]); - input_im1[n] = MUL_F((QMF_IM(buffer[n+i]) - QMF_IM(buffer[12-n+i])), filter[n]); - } - - DCT3_6_unscaled(out_re1, input_re1); - DCT3_6_unscaled(out_re2, input_re2); - - DCT3_6_unscaled(out_im1, input_im1); - DCT3_6_unscaled(out_im2, input_im2); - - for (n = 0; n < 6; n += 2) - { - QMF_RE(X_hybrid[i][n]) = out_re1[n] - out_im1[n]; - QMF_IM(X_hybrid[i][n]) = out_re2[n] + out_im2[n]; - QMF_RE(X_hybrid[i][n+1]) = out_re1[n+1] + out_im1[n+1]; - QMF_IM(X_hybrid[i][n+1]) = out_re2[n+1] - out_im2[n+1]; - - QMF_RE(X_hybrid[i][10-n]) = out_re1[n+1] - out_im1[n+1]; - QMF_IM(X_hybrid[i][10-n]) = out_re2[n+1] + out_im2[n+1]; - QMF_RE(X_hybrid[i][11-n]) = out_re1[n] + out_im1[n]; - QMF_IM(X_hybrid[i][11-n]) = out_re2[n] - out_im2[n]; - } - } -} - -/* Hybrid analysis: further split up QMF subbands - * to improve frequency resolution - */ -static void hybrid_analysis(hyb_info *hyb, qmf_t X[32][64], qmf_t X_hybrid[32][32], - uint8_t use34) -{ - uint8_t k, n, band; - uint8_t offset = 0; - uint8_t qmf_bands = (use34) ? 5 : 3; - uint8_t *resolution = (use34) ? hyb->resolution34 : hyb->resolution20; - - for (band = 0; band < qmf_bands; band++) - { - /* build working buffer */ - memcpy(hyb->work, hyb->buffer[band], 12 * sizeof(qmf_t)); - - /* add new samples */ - for (n = 0; n < hyb->frame_len; n++) - { - QMF_RE(hyb->work[12 + n]) = QMF_RE(X[n + 6 /*delay*/][band]); - QMF_IM(hyb->work[12 + n]) = QMF_IM(X[n + 6 /*delay*/][band]); - } - - /* store samples */ - memcpy(hyb->buffer[band], hyb->work + hyb->frame_len, 12 * sizeof(qmf_t)); - - - switch(resolution[band]) - { - case 2: - /* Type B real filter, Q[p] = 2 */ - channel_filter2(hyb, hyb->frame_len, p2_13_20, hyb->work, hyb->temp); - break; - case 4: - /* Type A complex filter, Q[p] = 4 */ - channel_filter4(hyb, hyb->frame_len, p4_13_34, hyb->work, hyb->temp); - break; - case 8: - /* Type A complex filter, Q[p] = 8 */ - channel_filter8(hyb, hyb->frame_len, (use34) ? p8_13_34 : p8_13_20, - hyb->work, hyb->temp); - break; - case 12: - /* Type A complex filter, Q[p] = 12 */ - channel_filter12(hyb, hyb->frame_len, p12_13_34, hyb->work, hyb->temp); - break; - } - - for (n = 0; n < hyb->frame_len; n++) - { - for (k = 0; k < resolution[band]; k++) - { - QMF_RE(X_hybrid[n][offset + k]) = QMF_RE(hyb->temp[n][k]); - QMF_IM(X_hybrid[n][offset + k]) = QMF_IM(hyb->temp[n][k]); - } - } - offset += resolution[band]; - } - - /* group hybrid channels */ - if (!use34) - { - for (n = 0; n < 32 /*30?*/; n++) - { - QMF_RE(X_hybrid[n][3]) += QMF_RE(X_hybrid[n][4]); - QMF_IM(X_hybrid[n][3]) += QMF_IM(X_hybrid[n][4]); - QMF_RE(X_hybrid[n][4]) = 0; - QMF_IM(X_hybrid[n][4]) = 0; - - QMF_RE(X_hybrid[n][2]) += QMF_RE(X_hybrid[n][5]); - QMF_IM(X_hybrid[n][2]) += QMF_IM(X_hybrid[n][5]); - QMF_RE(X_hybrid[n][5]) = 0; - QMF_IM(X_hybrid[n][5]) = 0; - } - } -} - -static void hybrid_synthesis(hyb_info *hyb, qmf_t X[32][64], qmf_t X_hybrid[32][32], - uint8_t use34) -{ - uint8_t k, n, band; - uint8_t offset = 0; - uint8_t qmf_bands = (use34) ? 5 : 3; - uint8_t *resolution = (use34) ? hyb->resolution34 : hyb->resolution20; - - for(band = 0; band < qmf_bands; band++) - { - for (n = 0; n < hyb->frame_len; n++) - { - QMF_RE(X[n][band]) = 0; - QMF_IM(X[n][band]) = 0; - - for (k = 0; k < resolution[band]; k++) - { - QMF_RE(X[n][band]) += QMF_RE(X_hybrid[n][offset + k]); - QMF_IM(X[n][band]) += QMF_IM(X_hybrid[n][offset + k]); - } - } - offset += resolution[band]; - } -} - -/* limits the value i to the range [min,max] */ -static int8_t delta_clip(int8_t i, int8_t min, int8_t max) -{ - if (i < min) - return min; - else if (i > max) - return max; - else - return i; -} - -//int iid = 0; - -/* delta decode array */ -static void delta_decode(uint8_t enable, int8_t *index, int8_t *index_prev, - uint8_t dt_flag, uint8_t nr_par, uint8_t stride, - int8_t min_index, int8_t max_index) -{ - int8_t i; - - if (enable == 1) - { - if (dt_flag == 0) - { - /* delta coded in frequency direction */ - index[0] = 0 + index[0]; - index[0] = delta_clip(index[0], min_index, max_index); - - for (i = 1; i < nr_par; i++) - { - index[i] = index[i-1] + index[i]; - index[i] = delta_clip(index[i], min_index, max_index); - } - } else { - /* delta coded in time direction */ - for (i = 0; i < nr_par; i++) - { - //int8_t tmp2; - //int8_t tmp = index[i]; - - //printf("%d %d\n", index_prev[i*stride], index[i]); - //printf("%d\n", index[i]); - - index[i] = index_prev[i*stride] + index[i]; - //tmp2 = index[i]; - index[i] = delta_clip(index[i], min_index, max_index); - - //if (iid) - //{ - // if (index[i] == 7) - // { - // printf("%d %d %d\n", index_prev[i*stride], tmp, tmp2); - // } - //} - } - } - } else { - /* set indices to zero */ - for (i = 0; i < nr_par; i++) - { - index[i] = 0; - } - } - - /* coarse */ - if (stride == 2) - { - for (i = (nr_par<<1)-1; i > 0; i--) - { - index[i] = index[i>>1]; - } - } -} - -/* delta modulo decode array */ -/* in: log2 value of the modulo value to allow using AND instead of MOD */ -static void delta_modulo_decode(uint8_t enable, int8_t *index, int8_t *index_prev, - uint8_t dt_flag, uint8_t nr_par, uint8_t stride, - int8_t log2modulo) -{ - int8_t i; - - if (enable == 1) - { - if (dt_flag == 0) - { - /* delta coded in frequency direction */ - index[0] = 0 + index[0]; - index[0] &= log2modulo; - - for (i = 1; i < nr_par; i++) - { - index[i] = index[i-1] + index[i]; - index[i] &= log2modulo; - } - } else { - /* delta coded in time direction */ - for (i = 0; i < nr_par; i++) - { - index[i] = index_prev[i*stride] + index[i]; - index[i] &= log2modulo; - } - } - } else { - /* set indices to zero */ - for (i = 0; i < nr_par; i++) - { - index[i] = 0; - } - } - - /* coarse */ - if (stride == 2) - { - index[0] = 0; - for (i = (nr_par<<1)-1; i > 0; i--) - { - index[i] = index[i>>1]; - } - } -} - -#ifdef PS_LOW_POWER -static void map34indexto20(int8_t *index, uint8_t bins) -{ - index[0] = (2*index[0]+index[1])/3; - index[1] = (index[1]+2*index[2])/3; - index[2] = (2*index[3]+index[4])/3; - index[3] = (index[4]+2*index[5])/3; - index[4] = (index[6]+index[7])/2; - index[5] = (index[8]+index[9])/2; - index[6] = index[10]; - index[7] = index[11]; - index[8] = (index[12]+index[13])/2; - index[9] = (index[14]+index[15])/2; - index[10] = index[16]; - - if (bins == 34) - { - index[11] = index[17]; - index[12] = index[18]; - index[13] = index[19]; - index[14] = (index[20]+index[21])/2; - index[15] = (index[22]+index[23])/2; - index[16] = (index[24]+index[25])/2; - index[17] = (index[26]+index[27])/2; - index[18] = (index[28]+index[29]+index[30]+index[31])/4; - index[19] = (index[32]+index[33])/2; - } -} -#endif - -static void map20indexto34(int8_t *index, uint8_t bins) -{ - index[0] = index[0]; - index[1] = (index[0] + index[1])/2; - index[2] = index[1]; - index[3] = index[2]; - index[4] = (index[2] + index[3])/2; - index[5] = index[3]; - index[6] = index[4]; - index[7] = index[4]; - index[8] = index[5]; - index[9] = index[5]; - index[10] = index[6]; - index[11] = index[7]; - index[12] = index[8]; - index[13] = index[8]; - index[14] = index[9]; - index[15] = index[9]; - index[16] = index[10]; - - if (bins == 34) - { - index[17] = index[11]; - index[18] = index[12]; - index[19] = index[13]; - index[20] = index[14]; - index[21] = index[14]; - index[22] = index[15]; - index[23] = index[15]; - index[24] = index[16]; - index[25] = index[16]; - index[26] = index[17]; - index[27] = index[17]; - index[28] = index[18]; - index[29] = index[18]; - index[30] = index[18]; - index[31] = index[18]; - index[32] = index[19]; - index[33] = index[19]; - } -} - -/* parse the bitstream data decoded in ps_data() */ -static void ps_data_decode(ps_info *ps) -{ - uint8_t env, bin; - - /* ps data not available, use data from previous frame */ - if (ps->ps_data_available == 0) - { - ps->num_env = 0; - } - - for (env = 0; env < ps->num_env; env++) - { - int8_t *iid_index_prev; - int8_t *icc_index_prev; - int8_t *ipd_index_prev; - int8_t *opd_index_prev; - - int8_t num_iid_steps = (ps->iid_mode < 3) ? 7 : 15 /*fine quant*/; - - if (env == 0) - { - /* take last envelope from previous frame */ - iid_index_prev = ps->iid_index_prev; - icc_index_prev = ps->icc_index_prev; - ipd_index_prev = ps->ipd_index_prev; - opd_index_prev = ps->opd_index_prev; - } else { - /* take index values from previous envelope */ - iid_index_prev = ps->iid_index[env - 1]; - icc_index_prev = ps->icc_index[env - 1]; - ipd_index_prev = ps->ipd_index[env - 1]; - opd_index_prev = ps->opd_index[env - 1]; - } - -// iid = 1; - /* delta decode iid parameters */ - delta_decode(ps->enable_iid, ps->iid_index[env], iid_index_prev, - ps->iid_dt[env], ps->nr_iid_par, - (ps->iid_mode == 0 || ps->iid_mode == 3) ? 2 : 1, - -num_iid_steps, num_iid_steps); -// iid = 0; - - /* delta decode icc parameters */ - delta_decode(ps->enable_icc, ps->icc_index[env], icc_index_prev, - ps->icc_dt[env], ps->nr_icc_par, - (ps->icc_mode == 0 || ps->icc_mode == 3) ? 2 : 1, - 0, 7); - - /* delta modulo decode ipd parameters */ - delta_modulo_decode(ps->enable_ipdopd, ps->ipd_index[env], ipd_index_prev, - ps->ipd_dt[env], ps->nr_ipdopd_par, 1, /*log2(8)*/ 3); - - /* delta modulo decode opd parameters */ - delta_modulo_decode(ps->enable_ipdopd, ps->opd_index[env], opd_index_prev, - ps->opd_dt[env], ps->nr_ipdopd_par, 1, /*log2(8)*/ 3); - } - - /* handle error case */ - if (ps->num_env == 0) - { - /* force to 1 */ - ps->num_env = 1; - - if (ps->enable_iid) - { - for (bin = 0; bin < 34; bin++) - ps->iid_index[0][bin] = ps->iid_index_prev[bin]; - } else { - for (bin = 0; bin < 34; bin++) - ps->iid_index[0][bin] = 0; - } - - if (ps->enable_icc) - { - for (bin = 0; bin < 34; bin++) - ps->icc_index[0][bin] = ps->icc_index_prev[bin]; - } else { - for (bin = 0; bin < 34; bin++) - ps->icc_index[0][bin] = 0; - } - - if (ps->enable_ipdopd) - { - for (bin = 0; bin < 17; bin++) - { - ps->ipd_index[0][bin] = ps->ipd_index_prev[bin]; - ps->opd_index[0][bin] = ps->opd_index_prev[bin]; - } - } else { - for (bin = 0; bin < 17; bin++) - { - ps->ipd_index[0][bin] = 0; - ps->opd_index[0][bin] = 0; - } - } - } - - /* update previous indices */ - for (bin = 0; bin < 34; bin++) - ps->iid_index_prev[bin] = ps->iid_index[ps->num_env-1][bin]; - for (bin = 0; bin < 34; bin++) - ps->icc_index_prev[bin] = ps->icc_index[ps->num_env-1][bin]; - for (bin = 0; bin < 17; bin++) - { - ps->ipd_index_prev[bin] = ps->ipd_index[ps->num_env-1][bin]; - ps->opd_index_prev[bin] = ps->opd_index[ps->num_env-1][bin]; - } - - ps->ps_data_available = 0; - - if (ps->frame_class == 0) - { - ps->border_position[0] = 0; - for (env = 1; env < ps->num_env; env++) - { - ps->border_position[env] = (env * 32 /* 30 for 960? */) / ps->num_env; - } - ps->border_position[ps->num_env] = 32 /* 30 for 960? */; - } else { - ps->border_position[0] = 0; - - if (ps->border_position[ps->num_env] < 32 /* 30 for 960? */) - { - ps->num_env++; - ps->border_position[ps->num_env] = 32 /* 30 for 960? */; - for (bin = 0; bin < 34; bin++) - { - ps->iid_index[ps->num_env][bin] = ps->iid_index[ps->num_env-1][bin]; - ps->icc_index[ps->num_env][bin] = ps->icc_index[ps->num_env-1][bin]; - } - for (bin = 0; bin < 17; bin++) - { - ps->ipd_index[ps->num_env][bin] = ps->ipd_index[ps->num_env-1][bin]; - ps->opd_index[ps->num_env][bin] = ps->opd_index[ps->num_env-1][bin]; - } - } - - for (env = 1; env < ps->num_env; env++) - { - int8_t thr = 32 /* 30 for 960? */ - (ps->num_env - env); - - if (ps->border_position[env] > thr) - { - ps->border_position[env] = thr; - } else { - thr = ps->border_position[env-1]+1; - if (ps->border_position[env] < thr) - { - ps->border_position[env] = thr; - } - } - } - } - - /* make sure that the indices of all parameters can be mapped - * to the same hybrid synthesis filterbank - */ -#ifdef PS_LOW_POWER - for (env = 0; env < ps->num_env; env++) - { - if (ps->iid_mode == 2 || ps->iid_mode == 5) - map34indexto20(ps->iid_index[env], 34); - if (ps->icc_mode == 2 || ps->icc_mode == 5) - map34indexto20(ps->icc_index[env], 34); - - /* disable ipd/opd */ - for (bin = 0; bin < 17; bin++) - { - ps->aaIpdIndex[env][bin] = 0; - ps->aaOpdIndex[env][bin] = 0; - } - } -#else - if (ps->use34hybrid_bands) - { - for (env = 0; env < ps->num_env; env++) - { - if (ps->iid_mode != 2 && ps->iid_mode != 5) - map20indexto34(ps->iid_index[env], 34); - if (ps->icc_mode != 2 && ps->icc_mode != 5) - map20indexto34(ps->icc_index[env], 34); - if (ps->ipd_mode != 2 && ps->ipd_mode != 5) - { - map20indexto34(ps->ipd_index[env], 17); - map20indexto34(ps->opd_index[env], 17); - } - } - } -#endif - -#if 0 - for (env = 0; env < ps->num_env; env++) - { - printf("iid[env:%d]:", env); - for (bin = 0; bin < 34; bin++) - { - printf(" %d", ps->iid_index[env][bin]); - } - printf("\n"); - } - for (env = 0; env < ps->num_env; env++) - { - printf("icc[env:%d]:", env); - for (bin = 0; bin < 34; bin++) - { - printf(" %d", ps->icc_index[env][bin]); - } - printf("\n"); - } - for (env = 0; env < ps->num_env; env++) - { - printf("ipd[env:%d]:", env); - for (bin = 0; bin < 17; bin++) - { - printf(" %d", ps->ipd_index[env][bin]); - } - printf("\n"); - } - for (env = 0; env < ps->num_env; env++) - { - printf("opd[env:%d]:", env); - for (bin = 0; bin < 17; bin++) - { - printf(" %d", ps->opd_index[env][bin]); - } - printf("\n"); - } - printf("\n"); -#endif -} - -/* decorrelate the mono signal using an allpass filter */ -static void ps_decorrelate(ps_info *ps, - qmf_t X_left[MAX_NTSRPS][64], - qmf_t X_right[MAX_NTSRPS][64], - qmf_t X_hybrid_left[32][32], - qmf_t X_hybrid_right[32][32]) -{ - uint8_t gr, n, m, bk; - uint8_t temp_delay = 0; - uint8_t sb, maxsb; - const complex_t *Phi_Fract_SubQmf; - uint8_t temp_delay_ser[NO_ALLPASS_LINKS]; - real_t P_SmoothPeakDecayDiffNrg, nrg; - static real_t P[32][34]; - static real_t G_TransientRatio[32][34]; - complex_t inputLeft; - - memset(&G_TransientRatio, 0, sizeof(G_TransientRatio)); - - /* chose hybrid filterbank: 20 or 34 band case */ - if (ps->use34hybrid_bands) - { - Phi_Fract_SubQmf = Phi_Fract_SubQmf34; - } else{ - Phi_Fract_SubQmf = Phi_Fract_SubQmf20; - } - - /* clear the energy values */ - for (n = 0; n < 32; n++) - { - for (bk = 0; bk < 34; bk++) - { - P[n][bk] = 0; - } - } - - /* calculate the energy in each parameter band b(k) */ - for (gr = 0; gr < ps->num_groups; gr++) - { - /* select the parameter index b(k) to which this group belongs */ - bk = (~NEGATE_IPD_MASK) & ps->map_group2bk[gr]; - - /* select the upper subband border for this group */ - maxsb = (gr < ps->num_hybrid_groups) ? ps->group_border[gr]+1 : ps->group_border[gr+1]; - - for (sb = ps->group_border[gr]; sb < maxsb; sb++) - { - for (n = ps->border_position[0]; n < ps->border_position[ps->num_env]; n++) - { -#ifdef FIXED_POINT - uint32_t in_re, in_im; -#endif - - /* input from hybrid subbands or QMF subbands */ - if (gr < ps->num_hybrid_groups) - { - RE(inputLeft) = QMF_RE(X_hybrid_left[n][sb]); - IM(inputLeft) = QMF_IM(X_hybrid_left[n][sb]); - } else { - RE(inputLeft) = QMF_RE(X_left[n][sb]); - IM(inputLeft) = QMF_IM(X_left[n][sb]); - } - - /* accumulate energy */ -#ifdef FIXED_POINT - /* NOTE: all input is scaled by 2^(-5) because of fixed point QMF - * meaning that P will be scaled by 2^(-10) compared to floating point version - */ - in_re = ((abs(RE(inputLeft))+(1<<(REAL_BITS-1)))>>REAL_BITS); - in_im = ((abs(IM(inputLeft))+(1<<(REAL_BITS-1)))>>REAL_BITS); - P[n][bk] += in_re*in_re + in_im*in_im; -#else - P[n][bk] += MUL_R(RE(inputLeft),RE(inputLeft)) + MUL_R(IM(inputLeft),IM(inputLeft)); -#endif - } - } - } - -#if 0 - for (n = 0; n < 32; n++) - { - for (bk = 0; bk < 34; bk++) - { -#ifdef FIXED_POINT - printf("%d %d: %d\n", n, bk, P[n][bk] /*/(float)REAL_PRECISION*/); -#else - printf("%d %d: %f\n", n, bk, P[n][bk]/1024.0); -#endif - } - } -#endif - - /* calculate transient reduction ratio for each parameter band b(k) */ - for (bk = 0; bk < ps->nr_par_bands; bk++) - { - for (n = ps->border_position[0]; n < ps->border_position[ps->num_env]; n++) - { - const real_t gamma = COEF_CONST(1.5); - - ps->P_PeakDecayNrg[bk] = MUL_F(ps->P_PeakDecayNrg[bk], ps->alpha_decay); - if (ps->P_PeakDecayNrg[bk] < P[n][bk]) - ps->P_PeakDecayNrg[bk] = P[n][bk]; - - /* apply smoothing filter to peak decay energy */ - P_SmoothPeakDecayDiffNrg = ps->P_SmoothPeakDecayDiffNrg_prev[bk]; - P_SmoothPeakDecayDiffNrg += MUL_F((ps->P_PeakDecayNrg[bk] - P[n][bk] - ps->P_SmoothPeakDecayDiffNrg_prev[bk]), ps->alpha_smooth); - ps->P_SmoothPeakDecayDiffNrg_prev[bk] = P_SmoothPeakDecayDiffNrg; - - /* apply smoothing filter to energy */ - nrg = ps->P_prev[bk]; - nrg += MUL_F((P[n][bk] - ps->P_prev[bk]), ps->alpha_smooth); - ps->P_prev[bk] = nrg; - - /* calculate transient ratio */ - if (MUL_C(P_SmoothPeakDecayDiffNrg, gamma) <= nrg) - { - G_TransientRatio[n][bk] = REAL_CONST(1.0); - } else { - G_TransientRatio[n][bk] = DIV_R(nrg, (MUL_C(P_SmoothPeakDecayDiffNrg, gamma))); - } - } - } - -#if 0 - for (n = 0; n < 32; n++) - { - for (bk = 0; bk < 34; bk++) - { -#ifdef FIXED_POINT - printf("%d %d: %f\n", n, bk, G_TransientRatio[n][bk]/(float)REAL_PRECISION); -#else - printf("%d %d: %f\n", n, bk, G_TransientRatio[n][bk]); -#endif - } - } -#endif - - /* apply stereo decorrelation filter to the signal */ - for (gr = 0; gr < ps->num_groups; gr++) - { - if (gr < ps->num_hybrid_groups) - maxsb = ps->group_border[gr] + 1; - else - maxsb = ps->group_border[gr + 1]; - - /* QMF channel */ - for (sb = ps->group_border[gr]; sb < maxsb; sb++) - { - real_t g_DecaySlope; - real_t g_DecaySlope_filt[NO_ALLPASS_LINKS]; - - /* g_DecaySlope: [0..1] */ - if (gr < ps->num_hybrid_groups || sb <= ps->decay_cutoff) - { - g_DecaySlope = FRAC_CONST(1.0); - } else { - int8_t decay = ps->decay_cutoff - sb; - if (decay <= -20 /* -1/DECAY_SLOPE */) - { - g_DecaySlope = 0; - } else { - /* decay(int)*decay_slope(frac) = g_DecaySlope(frac) */ - g_DecaySlope = FRAC_CONST(1.0) + DECAY_SLOPE * decay; - } - } - - /* calculate g_DecaySlope_filt for every m multiplied by filter_a[m] */ - for (m = 0; m < NO_ALLPASS_LINKS; m++) - { - g_DecaySlope_filt[m] = MUL_F(g_DecaySlope, filter_a[m]); - } - - - /* set delay indices */ - temp_delay = ps->saved_delay; - for (n = 0; n < NO_ALLPASS_LINKS; n++) - temp_delay_ser[n] = ps->delay_buf_index_ser[n]; - - for (n = ps->border_position[0]; n < ps->border_position[ps->num_env]; n++) - { - complex_t tmp, tmp0, R0; - - if (gr < ps->num_hybrid_groups) - { - /* hybrid filterbank input */ - RE(inputLeft) = QMF_RE(X_hybrid_left[n][sb]); - IM(inputLeft) = QMF_IM(X_hybrid_left[n][sb]); - } else { - /* QMF filterbank input */ - RE(inputLeft) = QMF_RE(X_left[n][sb]); - IM(inputLeft) = QMF_IM(X_left[n][sb]); - } - - if (sb > ps->nr_allpass_bands && gr >= ps->num_hybrid_groups) - { - /* delay */ - - /* never hybrid subbands here, always QMF subbands */ - RE(tmp) = RE(ps->delay_Qmf[ps->delay_buf_index_delay[sb]][sb]); - IM(tmp) = IM(ps->delay_Qmf[ps->delay_buf_index_delay[sb]][sb]); - RE(R0) = RE(tmp); - IM(R0) = IM(tmp); - RE(ps->delay_Qmf[ps->delay_buf_index_delay[sb]][sb]) = RE(inputLeft); - IM(ps->delay_Qmf[ps->delay_buf_index_delay[sb]][sb]) = IM(inputLeft); - } else { - /* allpass filter */ - uint8_t m; - complex_t Phi_Fract; - - /* fetch parameters */ - if (gr < ps->num_hybrid_groups) - { - /* select data from the hybrid subbands */ - RE(tmp0) = RE(ps->delay_SubQmf[temp_delay][sb]); - IM(tmp0) = IM(ps->delay_SubQmf[temp_delay][sb]); - - RE(ps->delay_SubQmf[temp_delay][sb]) = RE(inputLeft); - IM(ps->delay_SubQmf[temp_delay][sb]) = IM(inputLeft); - - RE(Phi_Fract) = RE(Phi_Fract_SubQmf[sb]); - IM(Phi_Fract) = IM(Phi_Fract_SubQmf[sb]); - } else { - /* select data from the QMF subbands */ - RE(tmp0) = RE(ps->delay_Qmf[temp_delay][sb]); - IM(tmp0) = IM(ps->delay_Qmf[temp_delay][sb]); - - RE(ps->delay_Qmf[temp_delay][sb]) = RE(inputLeft); - IM(ps->delay_Qmf[temp_delay][sb]) = IM(inputLeft); - - RE(Phi_Fract) = RE(Phi_Fract_Qmf[sb]); - IM(Phi_Fract) = IM(Phi_Fract_Qmf[sb]); - } - - /* z^(-2) * Phi_Fract[k] */ - ComplexMult(&RE(tmp), &IM(tmp), RE(tmp0), IM(tmp0), RE(Phi_Fract), IM(Phi_Fract)); - - RE(R0) = RE(tmp); - IM(R0) = IM(tmp); - for (m = 0; m < NO_ALLPASS_LINKS; m++) - { - complex_t Q_Fract_allpass, tmp2; - - /* fetch parameters */ - if (gr < ps->num_hybrid_groups) - { - /* select data from the hybrid subbands */ - RE(tmp0) = RE(ps->delay_SubQmf_ser[m][temp_delay_ser[m]][sb]); - IM(tmp0) = IM(ps->delay_SubQmf_ser[m][temp_delay_ser[m]][sb]); - - if (ps->use34hybrid_bands) - { - RE(Q_Fract_allpass) = RE(Q_Fract_allpass_SubQmf34[sb][m]); - IM(Q_Fract_allpass) = IM(Q_Fract_allpass_SubQmf34[sb][m]); - } else { - RE(Q_Fract_allpass) = RE(Q_Fract_allpass_SubQmf20[sb][m]); - IM(Q_Fract_allpass) = IM(Q_Fract_allpass_SubQmf20[sb][m]); - } - } else { - /* select data from the QMF subbands */ - RE(tmp0) = RE(ps->delay_Qmf_ser[m][temp_delay_ser[m]][sb]); - IM(tmp0) = IM(ps->delay_Qmf_ser[m][temp_delay_ser[m]][sb]); - - RE(Q_Fract_allpass) = RE(Q_Fract_allpass_Qmf[sb][m]); - IM(Q_Fract_allpass) = IM(Q_Fract_allpass_Qmf[sb][m]); - } - - /* delay by a fraction */ - /* z^(-d(m)) * Q_Fract_allpass[k,m] */ - ComplexMult(&RE(tmp), &IM(tmp), RE(tmp0), IM(tmp0), RE(Q_Fract_allpass), IM(Q_Fract_allpass)); - - /* -a(m) * g_DecaySlope[k] */ - RE(tmp) += -MUL_F(g_DecaySlope_filt[m], RE(R0)); - IM(tmp) += -MUL_F(g_DecaySlope_filt[m], IM(R0)); - - /* -a(m) * g_DecaySlope[k] * Q_Fract_allpass[k,m] * z^(-d(m)) */ - RE(tmp2) = RE(R0) + MUL_F(g_DecaySlope_filt[m], RE(tmp)); - IM(tmp2) = IM(R0) + MUL_F(g_DecaySlope_filt[m], IM(tmp)); - - /* store sample */ - if (gr < ps->num_hybrid_groups) - { - RE(ps->delay_SubQmf_ser[m][temp_delay_ser[m]][sb]) = RE(tmp2); - IM(ps->delay_SubQmf_ser[m][temp_delay_ser[m]][sb]) = IM(tmp2); - } else { - RE(ps->delay_Qmf_ser[m][temp_delay_ser[m]][sb]) = RE(tmp2); - IM(ps->delay_Qmf_ser[m][temp_delay_ser[m]][sb]) = IM(tmp2); - } - - /* store for next iteration (or as output value if last iteration) */ - RE(R0) = RE(tmp); - IM(R0) = IM(tmp); - } - } - - /* select b(k) for reading the transient ratio */ - bk = (~NEGATE_IPD_MASK) & ps->map_group2bk[gr]; - - /* duck if a past transient is found */ - RE(R0) = MUL_R(G_TransientRatio[n][bk], RE(R0)); - IM(R0) = MUL_R(G_TransientRatio[n][bk], IM(R0)); - - if (gr < ps->num_hybrid_groups) - { - /* hybrid */ - QMF_RE(X_hybrid_right[n][sb]) = RE(R0); - QMF_IM(X_hybrid_right[n][sb]) = IM(R0); - } else { - /* QMF */ - QMF_RE(X_right[n][sb]) = RE(R0); - QMF_IM(X_right[n][sb]) = IM(R0); - } - - /* Update delay buffer index */ - if (++temp_delay >= 2) - { - temp_delay = 0; - } - - /* update delay indices */ - if (sb > ps->nr_allpass_bands && gr >= ps->num_hybrid_groups) - { - /* delay_D depends on the samplerate, it can hold the values 14 and 1 */ - if (++ps->delay_buf_index_delay[sb] >= ps->delay_D[sb]) - { - ps->delay_buf_index_delay[sb] = 0; - } - } - - for (m = 0; m < NO_ALLPASS_LINKS; m++) - { - if (++temp_delay_ser[m] >= ps->num_sample_delay_ser[m]) - { - temp_delay_ser[m] = 0; - } - } - } - } - } - - /* update delay indices */ - ps->saved_delay = temp_delay; - for (m = 0; m < NO_ALLPASS_LINKS; m++) - ps->delay_buf_index_ser[m] = temp_delay_ser[m]; -} - -#ifdef FIXED_POINT -#define step(shift) \ - if ((0x40000000l >> shift) + root <= value) \ - { \ - value -= (0x40000000l >> shift) + root; \ - root = (root >> 1) | (0x40000000l >> shift); \ - } else { \ - root = root >> 1; \ - } - -/* fixed point square root approximation */ -static real_t ps_sqrt(real_t value) -{ - real_t root = 0; - - step( 0); step( 2); step( 4); step( 6); - step( 8); step(10); step(12); step(14); - step(16); step(18); step(20); step(22); - step(24); step(26); step(28); step(30); - - if (root < value) - ++root; - - root <<= (REAL_BITS/2); - - return root; -} -#else -#define ps_sqrt(A) sqrt(A) -#endif - -static const real_t ipdopd_cos_tab[] = { - FRAC_CONST(1.000000000000000), - FRAC_CONST(0.707106781186548), - FRAC_CONST(0.000000000000000), - FRAC_CONST(-0.707106781186547), - FRAC_CONST(-1.000000000000000), - FRAC_CONST(-0.707106781186548), - FRAC_CONST(-0.000000000000000), - FRAC_CONST(0.707106781186547), - FRAC_CONST(1.000000000000000) -}; - -static const real_t ipdopd_sin_tab[] = { - FRAC_CONST(0.000000000000000), - FRAC_CONST(0.707106781186547), - FRAC_CONST(1.000000000000000), - FRAC_CONST(0.707106781186548), - FRAC_CONST(0.000000000000000), - FRAC_CONST(-0.707106781186547), - FRAC_CONST(-1.000000000000000), - FRAC_CONST(-0.707106781186548), - FRAC_CONST(-0.000000000000000) -}; - -static void ps_mix_phase(ps_info *ps, - qmf_t X_left[MAX_NTSRPS][64], - qmf_t X_right[MAX_NTSRPS][64], - qmf_t X_hybrid_left[32][32], - qmf_t X_hybrid_right[32][32]) -{ - uint8_t n; - uint8_t gr; - uint8_t bk = 0; - uint8_t sb, maxsb; - uint8_t env; - uint8_t nr_ipdopd_par; - complex_t h11 = {0,0}, h12 = {0,0}, h21 = {0,0}, h22 = {0,0}; - complex_t H11 = {0,0}, H12 = {0,0}, H21 = {0,0}, H22 = {0,0}; - complex_t deltaH11= {0,0}, deltaH12 = {0,0}, deltaH21= {0,0}, deltaH22= {0,0}; - complex_t tempLeft; - complex_t tempRight; - complex_t phaseLeft; - complex_t phaseRight; - real_t L; - const real_t *sf_iid; - uint8_t no_iid_steps; - - if (ps->iid_mode >= 3) - { - no_iid_steps = 15; - sf_iid = sf_iid_fine; - } else { - no_iid_steps = 7; - sf_iid = sf_iid_normal; - } - - if (ps->ipd_mode == 0 || ps->ipd_mode == 3) - { - nr_ipdopd_par = 11; /* resolution */ - } else { - nr_ipdopd_par = ps->nr_ipdopd_par; - } - - for (gr = 0; gr < ps->num_groups; gr++) - { - bk = (~NEGATE_IPD_MASK) & ps->map_group2bk[gr]; - - /* use one channel per group in the subqmf domain */ - maxsb = (gr < ps->num_hybrid_groups) ? ps->group_border[gr] + 1 : ps->group_border[gr + 1]; - - for (env = 0; env < ps->num_env; env++) - { - if (ps->icc_mode < 3) - { - /* type 'A' mixing as described in 8.6.4.6.2.1 */ - real_t c_1, c_2; - real_t cosa, sina; - real_t cosb, sinb; - real_t ab1, ab2; - real_t ab3, ab4; - - /* - c_1 = sqrt(2.0 / (1.0 + pow(10.0, quant_iid[no_iid_steps + iid_index] / 10.0))); - c_2 = sqrt(2.0 / (1.0 + pow(10.0, quant_iid[no_iid_steps - iid_index] / 10.0))); - alpha = 0.5 * acos(quant_rho[icc_index]); - beta = alpha * ( c_1 - c_2 ) / sqrt(2.0); - */ - - //printf("%d\n", ps->iid_index[env][bk]); - - /* calculate the scalefactors c_1 and c_2 from the intensity differences */ - c_1 = sf_iid[no_iid_steps + ps->iid_index[env][bk]]; - c_2 = sf_iid[no_iid_steps - ps->iid_index[env][bk]]; - - /* calculate alpha and beta using the ICC parameters */ - cosa = cos_alphas[ps->icc_index[env][bk]]; - sina = sin_alphas[ps->icc_index[env][bk]]; - - if (ps->iid_mode >= 3) - { - if (ps->iid_index[env][bk] < 0) - { - cosb = cos_betas_fine[-ps->iid_index[env][bk]][ps->icc_index[env][bk]]; - sinb = -sin_betas_fine[-ps->iid_index[env][bk]][ps->icc_index[env][bk]]; - } else { - cosb = cos_betas_fine[ps->iid_index[env][bk]][ps->icc_index[env][bk]]; - sinb = sin_betas_fine[ps->iid_index[env][bk]][ps->icc_index[env][bk]]; - } - } else { - if (ps->iid_index[env][bk] < 0) - { - cosb = cos_betas_normal[-ps->iid_index[env][bk]][ps->icc_index[env][bk]]; - sinb = -sin_betas_normal[-ps->iid_index[env][bk]][ps->icc_index[env][bk]]; - } else { - cosb = cos_betas_normal[ps->iid_index[env][bk]][ps->icc_index[env][bk]]; - sinb = sin_betas_normal[ps->iid_index[env][bk]][ps->icc_index[env][bk]]; - } - } - - ab1 = MUL_C(cosb, cosa); - ab2 = MUL_C(sinb, sina); - ab3 = MUL_C(sinb, cosa); - ab4 = MUL_C(cosb, sina); - - /* h_xy: COEF */ - RE(h11) = MUL_C(c_2, (ab1 - ab2)); - RE(h12) = MUL_C(c_1, (ab1 + ab2)); - RE(h21) = MUL_C(c_2, (ab3 + ab4)); - RE(h22) = MUL_C(c_1, (ab3 - ab4)); - } else { - /* type 'B' mixing as described in 8.6.4.6.2.2 */ - real_t sina, cosa; - real_t cosg, sing; - - /* - real_t c, rho, mu, alpha, gamma; - uint8_t i; - - i = ps->iid_index[env][bk]; - c = (real_t)pow(10.0, ((i)?(((i>0)?1:-1)*quant_iid[((i>0)?i:-i)-1]):0.)/20.0); - rho = quant_rho[ps->icc_index[env][bk]]; - - if (rho == 0.0f && c == 1.) - { - alpha = (real_t)M_PI/4.0f; - rho = 0.05f; - } else { - if (rho <= 0.05f) - { - rho = 0.05f; - } - alpha = 0.5f*(real_t)atan( (2.0f*c*rho) / (c*c-1.0f) ); - - if (alpha < 0.) - { - alpha += (real_t)M_PI/2.0f; - } - if (rho < 0.) - { - alpha += (real_t)M_PI; - } - } - mu = c+1.0f/c; - mu = 1+(4.0f*rho*rho-4.0f)/(mu*mu); - gamma = (real_t)atan(sqrt((1.0f-sqrt(mu))/(1.0f+sqrt(mu)))); - */ - - if (ps->iid_mode >= 3) - { - uint8_t abs_iid = abs(ps->iid_index[env][bk]); - - cosa = sincos_alphas_B_fine[no_iid_steps + ps->iid_index[env][bk]][ps->icc_index[env][bk]]; - sina = sincos_alphas_B_fine[30 - (no_iid_steps + ps->iid_index[env][bk])][ps->icc_index[env][bk]]; - cosg = cos_gammas_fine[abs_iid][ps->icc_index[env][bk]]; - sing = sin_gammas_fine[abs_iid][ps->icc_index[env][bk]]; - } else { - uint8_t abs_iid = abs(ps->iid_index[env][bk]); - - cosa = sincos_alphas_B_normal[no_iid_steps + ps->iid_index[env][bk]][ps->icc_index[env][bk]]; - sina = sincos_alphas_B_normal[14 - (no_iid_steps + ps->iid_index[env][bk])][ps->icc_index[env][bk]]; - cosg = cos_gammas_normal[abs_iid][ps->icc_index[env][bk]]; - sing = sin_gammas_normal[abs_iid][ps->icc_index[env][bk]]; - } - - RE(h11) = MUL_C(COEF_SQRT2, MUL_C(cosa, cosg)); - RE(h12) = MUL_C(COEF_SQRT2, MUL_C(sina, cosg)); - RE(h21) = MUL_C(COEF_SQRT2, MUL_C(-cosa, sing)); - RE(h22) = MUL_C(COEF_SQRT2, MUL_C(sina, sing)); - } - - /* calculate phase rotation parameters H_xy */ - /* note that the imaginary part of these parameters are only calculated when - IPD and OPD are enabled - */ - if ((ps->enable_ipdopd) && (bk < nr_ipdopd_par)) - { - int8_t i; - real_t xxyy, ppqq; - real_t yq, xp, xq, py, tmp; - - /* ringbuffer index */ - i = ps->phase_hist; - - /* previous value */ -#ifdef FIXED_POINT - /* divide by 4, shift right 2 bits */ - RE(tempLeft) = RE(ps->ipd_prev[bk][i]) >> 2; - IM(tempLeft) = IM(ps->ipd_prev[bk][i]) >> 2; - RE(tempRight) = RE(ps->opd_prev[bk][i]) >> 2; - IM(tempRight) = IM(ps->opd_prev[bk][i]) >> 2; -#else - RE(tempLeft) = MUL_F(RE(ps->ipd_prev[bk][i]), FRAC_CONST(0.25)); - IM(tempLeft) = MUL_F(IM(ps->ipd_prev[bk][i]), FRAC_CONST(0.25)); - RE(tempRight) = MUL_F(RE(ps->opd_prev[bk][i]), FRAC_CONST(0.25)); - IM(tempRight) = MUL_F(IM(ps->opd_prev[bk][i]), FRAC_CONST(0.25)); -#endif - - /* save current value */ - RE(ps->ipd_prev[bk][i]) = ipdopd_cos_tab[abs(ps->ipd_index[env][bk])]; - IM(ps->ipd_prev[bk][i]) = ipdopd_sin_tab[abs(ps->ipd_index[env][bk])]; - RE(ps->opd_prev[bk][i]) = ipdopd_cos_tab[abs(ps->opd_index[env][bk])]; - IM(ps->opd_prev[bk][i]) = ipdopd_sin_tab[abs(ps->opd_index[env][bk])]; - - /* add current value */ - RE(tempLeft) += RE(ps->ipd_prev[bk][i]); - IM(tempLeft) += IM(ps->ipd_prev[bk][i]); - RE(tempRight) += RE(ps->opd_prev[bk][i]); - IM(tempRight) += IM(ps->opd_prev[bk][i]); - - /* ringbuffer index */ - if (i == 0) - { - i = 2; - } - i--; - - /* get value before previous */ -#ifdef FIXED_POINT - /* dividing by 2, shift right 1 bit */ - RE(tempLeft) += (RE(ps->ipd_prev[bk][i]) >> 1); - IM(tempLeft) += (IM(ps->ipd_prev[bk][i]) >> 1); - RE(tempRight) += (RE(ps->opd_prev[bk][i]) >> 1); - IM(tempRight) += (IM(ps->opd_prev[bk][i]) >> 1); -#else - RE(tempLeft) += MUL_F(RE(ps->ipd_prev[bk][i]), FRAC_CONST(0.5)); - IM(tempLeft) += MUL_F(IM(ps->ipd_prev[bk][i]), FRAC_CONST(0.5)); - RE(tempRight) += MUL_F(RE(ps->opd_prev[bk][i]), FRAC_CONST(0.5)); - IM(tempRight) += MUL_F(IM(ps->opd_prev[bk][i]), FRAC_CONST(0.5)); -#endif - -#if 0 /* original code */ - ipd = (float)atan2(IM(tempLeft), RE(tempLeft)); - opd = (float)atan2(IM(tempRight), RE(tempRight)); - - /* phase rotation */ - RE(phaseLeft) = (float)cos(opd); - IM(phaseLeft) = (float)sin(opd); - opd -= ipd; - RE(phaseRight) = (float)cos(opd); - IM(phaseRight) = (float)sin(opd); -#else - // x = IM(tempLeft) - // y = RE(tempLeft) - // p = IM(tempRight) - // q = RE(tempRight) - // cos(atan2(x,y)) = 1/sqrt(1 + (x*x)/(y*y)) - // sin(atan2(x,y)) = x/(y*sqrt(1 + (x*x)/(y*y))) - // cos(atan2(x,y)-atan2(p,q)) = (y*q+x*p)/(y*q * sqrt(1 + (x*x)/(y*y)) * sqrt(1 + (p*p)/(q*q))); - // sin(atan2(x,y)-atan2(p,q)) = (x*q-p*y)/(y*q * sqrt(1 + (x*x)/(y*y)) * sqrt(1 + (p*p)/(q*q))); - - /* (x*x)/(y*y) (REAL > 0) */ - xxyy = DIV_R(MUL_C(IM(tempLeft),IM(tempLeft)), MUL_C(RE(tempLeft),RE(tempLeft))); - ppqq = DIV_R(MUL_C(IM(tempRight),IM(tempRight)), MUL_C(RE(tempRight),RE(tempRight))); - - /* 1 + (x*x)/(y*y) (REAL > 1) */ - xxyy += REAL_CONST(1); - ppqq += REAL_CONST(1); - - /* 1 / sqrt(1 + (x*x)/(y*y)) (FRAC <= 1) */ - xxyy = DIV_R(FRAC_CONST(1), ps_sqrt(xxyy)); - ppqq = DIV_R(FRAC_CONST(1), ps_sqrt(ppqq)); - - /* COEF */ - yq = MUL_C(RE(tempLeft), RE(tempRight)); - xp = MUL_C(IM(tempLeft), IM(tempRight)); - xq = MUL_C(IM(tempLeft), RE(tempRight)); - py = MUL_C(RE(tempLeft), IM(tempRight)); - - RE(phaseLeft) = xxyy; - IM(phaseLeft) = MUL_R(xxyy, (DIV_R(IM(tempLeft), RE(tempLeft)))); - - tmp = DIV_C(MUL_F(xxyy, ppqq), yq); - - /* MUL_C(FRAC,COEF) = FRAC */ - RE(phaseRight) = MUL_C(tmp, (yq+xp)); - IM(phaseRight) = MUL_C(tmp, (xq-py)); -#endif - - /* MUL_F(COEF, FRAC) = COEF */ - IM(h11) = MUL_F(RE(h11), IM(phaseLeft)); - IM(h12) = MUL_F(RE(h12), IM(phaseRight)); - IM(h21) = MUL_F(RE(h21), IM(phaseLeft)); - IM(h22) = MUL_F(RE(h22), IM(phaseRight)); - - RE(h11) = MUL_F(RE(h11), RE(phaseLeft)); - RE(h12) = MUL_F(RE(h12), RE(phaseRight)); - RE(h21) = MUL_F(RE(h21), RE(phaseLeft)); - RE(h22) = MUL_F(RE(h22), RE(phaseRight)); - } - - /* length of the envelope n_e+1 - n_e (in time samples) */ - /* 0 < L <= 32: integer */ - L = (real_t)(ps->border_position[env + 1] - ps->border_position[env]); - - /* obtain final H_xy by means of linear interpolation */ - RE(deltaH11) = (RE(h11) - RE(ps->h11_prev[gr])) / L; - RE(deltaH12) = (RE(h12) - RE(ps->h12_prev[gr])) / L; - RE(deltaH21) = (RE(h21) - RE(ps->h21_prev[gr])) / L; - RE(deltaH22) = (RE(h22) - RE(ps->h22_prev[gr])) / L; - - RE(H11) = RE(ps->h11_prev[gr]); - RE(H12) = RE(ps->h12_prev[gr]); - RE(H21) = RE(ps->h21_prev[gr]); - RE(H22) = RE(ps->h22_prev[gr]); - - RE(ps->h11_prev[gr]) = RE(h11); - RE(ps->h12_prev[gr]) = RE(h12); - RE(ps->h21_prev[gr]) = RE(h21); - RE(ps->h22_prev[gr]) = RE(h22); - - /* only calculate imaginary part when needed */ - if ((ps->enable_ipdopd) && (bk < nr_ipdopd_par)) - { - /* obtain final H_xy by means of linear interpolation */ - IM(deltaH11) = (IM(h11) - IM(ps->h11_prev[gr])) / L; - IM(deltaH12) = (IM(h12) - IM(ps->h12_prev[gr])) / L; - IM(deltaH21) = (IM(h21) - IM(ps->h21_prev[gr])) / L; - IM(deltaH22) = (IM(h22) - IM(ps->h22_prev[gr])) / L; - - IM(H11) = IM(ps->h11_prev[gr]); - IM(H12) = IM(ps->h12_prev[gr]); - IM(H21) = IM(ps->h21_prev[gr]); - IM(H22) = IM(ps->h22_prev[gr]); - - if ((NEGATE_IPD_MASK & ps->map_group2bk[gr]) != 0) - { - IM(deltaH11) = -IM(deltaH11); - IM(deltaH12) = -IM(deltaH12); - IM(deltaH21) = -IM(deltaH21); - IM(deltaH22) = -IM(deltaH22); - - IM(H11) = -IM(H11); - IM(H12) = -IM(H12); - IM(H21) = -IM(H21); - IM(H22) = -IM(H22); - } - - IM(ps->h11_prev[gr]) = IM(h11); - IM(ps->h12_prev[gr]) = IM(h12); - IM(ps->h21_prev[gr]) = IM(h21); - IM(ps->h22_prev[gr]) = IM(h22); - } - - /* apply H_xy to the current envelope band of the decorrelated subband */ - for (n = ps->border_position[env]; n < ps->border_position[env + 1]; n++) - { - /* addition finalises the interpolation over every n */ - RE(H11) += RE(deltaH11); - RE(H12) += RE(deltaH12); - RE(H21) += RE(deltaH21); - RE(H22) += RE(deltaH22); - if ((ps->enable_ipdopd) && (bk < nr_ipdopd_par)) - { - IM(H11) += IM(deltaH11); - IM(H12) += IM(deltaH12); - IM(H21) += IM(deltaH21); - IM(H22) += IM(deltaH22); - } - - /* channel is an alias to the subband */ - for (sb = ps->group_border[gr]; sb < maxsb; sb++) - { - complex_t inLeft, inRight; - - /* load decorrelated samples */ - if (gr < ps->num_hybrid_groups) - { - RE(inLeft) = RE(X_hybrid_left[n][sb]); - IM(inLeft) = IM(X_hybrid_left[n][sb]); - RE(inRight) = RE(X_hybrid_right[n][sb]); - IM(inRight) = IM(X_hybrid_right[n][sb]); - } else { - RE(inLeft) = RE(X_left[n][sb]); - IM(inLeft) = IM(X_left[n][sb]); - RE(inRight) = RE(X_right[n][sb]); - IM(inRight) = IM(X_right[n][sb]); - } - - /* apply mixing */ - RE(tempLeft) = MUL_C(RE(H11), RE(inLeft)) + MUL_C(RE(H21), RE(inRight)); - IM(tempLeft) = MUL_C(RE(H11), IM(inLeft)) + MUL_C(RE(H21), IM(inRight)); - RE(tempRight) = MUL_C(RE(H12), RE(inLeft)) + MUL_C(RE(H22), RE(inRight)); - IM(tempRight) = MUL_C(RE(H12), IM(inLeft)) + MUL_C(RE(H22), IM(inRight)); - - /* only perform imaginary operations when needed */ - if ((ps->enable_ipdopd) && (bk < nr_ipdopd_par)) - { - /* apply rotation */ - RE(tempLeft) -= MUL_C(IM(H11), IM(inLeft)) + MUL_C(IM(H21), IM(inRight)); - IM(tempLeft) += MUL_C(IM(H11), RE(inLeft)) + MUL_C(IM(H21), RE(inRight)); - RE(tempRight) -= MUL_C(IM(H12), IM(inLeft)) + MUL_C(IM(H22), IM(inRight)); - IM(tempRight) += MUL_C(IM(H12), RE(inLeft)) + MUL_C(IM(H22), RE(inRight)); - } - - /* store final samples */ - if (gr < ps->num_hybrid_groups) - { - RE(X_hybrid_left[n][sb]) = RE(tempLeft); - IM(X_hybrid_left[n][sb]) = IM(tempLeft); - RE(X_hybrid_right[n][sb]) = RE(tempRight); - IM(X_hybrid_right[n][sb]) = IM(tempRight); - } else { - RE(X_left[n][sb]) = RE(tempLeft); - IM(X_left[n][sb]) = IM(tempLeft); - RE(X_right[n][sb]) = RE(tempRight); - IM(X_right[n][sb]) = IM(tempRight); - } - } - } - - /* shift phase smoother's circular buffer index */ - ps->phase_hist++; - if (ps->phase_hist == 2) - { - ps->phase_hist = 0; - } - } - } -} - -void ps_init(ps_info *ps) -{ - uint8_t i; - uint8_t short_delay_band; - - hybrid_init(&ps->hyb); - - ps->ps_data_available = 0; - - /* delay stuff*/ - ps->saved_delay = 0; - - for (i = 0; i < 64; i++) - { - ps->delay_buf_index_delay[i] = 0; - } - - for (i = 0; i < NO_ALLPASS_LINKS; i++) - { - ps->delay_buf_index_ser[i] = 0; -#ifdef PARAM_32KHZ - if (sr_index <= 5) /* >= 32 kHz*/ - { - ps->num_sample_delay_ser[i] = delay_length_d[1][i]; - } else { - ps->num_sample_delay_ser[i] = delay_length_d[0][i]; - } -#else - /* THESE ARE CONSTANTS NOW */ - ps->num_sample_delay_ser[i] = delay_length_d[i]; -#endif - } - -#ifdef PARAM_32KHZ - if (sr_index <= 5) /* >= 32 kHz*/ - { - short_delay_band = 35; - ps->nr_allpass_bands = 22; - ps->alpha_decay = FRAC_CONST(0.76592833836465); - ps->alpha_smooth = FRAC_CONST(0.25); - } else { - short_delay_band = 64; - ps->nr_allpass_bands = 45; - ps->alpha_decay = FRAC_CONST(0.58664621951003); - ps->alpha_smooth = FRAC_CONST(0.6); - } -#else - /* THESE ARE CONSTANTS NOW */ - short_delay_band = 35; - ps->nr_allpass_bands = 22; - ps->alpha_decay = FRAC_CONST(0.76592833836465); - ps->alpha_smooth = FRAC_CONST(0.25); -#endif - - /* THESE ARE CONSTANT NOW IF PS IS INDEPENDANT OF SAMPLERATE */ - for (i = 0; i < short_delay_band; i++) - { - ps->delay_D[i] = 14; - } - for (i = short_delay_band; i < 64; i++) - { - ps->delay_D[i] = 1; - } - - /* mixing and phase */ - for (i = 0; i < 50; i++) - { - RE(ps->h11_prev[i]) = 1; - IM(ps->h12_prev[i]) = 1; - RE(ps->h11_prev[i]) = 1; - IM(ps->h12_prev[i]) = 1; - } - - ps->phase_hist = 0; - - for (i = 0; i < 20; i++) - { - RE(ps->ipd_prev[i][0]) = 0; - IM(ps->ipd_prev[i][0]) = 0; - RE(ps->ipd_prev[i][1]) = 0; - IM(ps->ipd_prev[i][1]) = 0; - RE(ps->opd_prev[i][0]) = 0; - IM(ps->opd_prev[i][0]) = 0; - RE(ps->opd_prev[i][1]) = 0; - IM(ps->opd_prev[i][1]) = 0; - } -} - -/* main Parametric Stereo decoding function */ -uint8_t ps_decode(ps_info *ps, - qmf_t X_left[MAX_NTSRPS][64], - qmf_t X_right[MAX_NTSRPS][64]) -{ - static qmf_t X_hybrid_left[32][32]; - static qmf_t X_hybrid_right[32][32]; - - memset(&X_hybrid_left , 0, sizeof(X_hybrid_left)); - memset(&X_hybrid_right, 0, sizeof(X_hybrid_right)); - - /* delta decoding of the bitstream data */ - ps_data_decode(ps); - - /* set up some parameters depending on filterbank type */ - if (ps->use34hybrid_bands) - { - ps->group_border = (uint8_t*)group_border34; - ps->map_group2bk = (uint16_t*)map_group2bk34; - ps->num_groups = 32+18; - ps->num_hybrid_groups = 32; - ps->nr_par_bands = 34; - ps->decay_cutoff = 5; - } else { - ps->group_border = (uint8_t*)group_border20; - ps->map_group2bk = (uint16_t*)map_group2bk20; - ps->num_groups = 10+12; - ps->num_hybrid_groups = 10; - ps->nr_par_bands = 20; - ps->decay_cutoff = 3; - } - - /* Perform further analysis on the lowest subbands to get a higher - * frequency resolution - */ - hybrid_analysis(&ps->hyb, X_left, X_hybrid_left, ps->use34hybrid_bands); - - /* decorrelate mono signal */ - ps_decorrelate(ps, X_left, X_right, X_hybrid_left, X_hybrid_right); - - /* apply mixing and phase parameters */ - ps_mix_phase(ps, X_left, X_right, X_hybrid_left, X_hybrid_right); - - /* hybrid synthesis, to rebuild the SBR QMF matrices */ - hybrid_synthesis(&ps->hyb, X_left, X_hybrid_left, ps->use34hybrid_bands); - - hybrid_synthesis(&ps->hyb, X_right, X_hybrid_right, ps->use34hybrid_bands); - - return 0; -} - -#endif - diff --git a/apps/codecs/libfaad/ps_dec.h b/apps/codecs/libfaad/ps_dec.h deleted file mode 100644 index 14e4bd54e6..0000000000 --- a/apps/codecs/libfaad/ps_dec.h +++ /dev/null @@ -1,162 +0,0 @@ -/* -** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -** -** Any non-GPL usage of this software or parts of this software is strictly -** forbidden. -** -** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. -** -** $Id$ -**/ - -#ifndef __PS_DEC_H__ -#define __PS_DEC_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -#include "bits.h" - -#define EXTENSION_ID_PS 2 - -#define MAX_PS_ENVELOPES 5 -#define NO_ALLPASS_LINKS 3 - -#define MAX_NTSRPS 38 /* max number_time_slots * rate + 6 (delay) */ - -typedef struct -{ - uint8_t frame_len; - uint8_t resolution20[3]; - uint8_t resolution34[5]; - - qmf_t work[32+12]; - qmf_t buffer[5][32]; - qmf_t temp[32][12]; -} hyb_info; - -typedef struct -{ - /* bitstream parameters */ - uint8_t enable_iid; - uint8_t enable_icc; - uint8_t enable_ext; - - uint8_t iid_mode; - uint8_t icc_mode; - uint8_t nr_iid_par; - uint8_t nr_ipdopd_par; - uint8_t nr_icc_par; - - uint8_t frame_class; - uint8_t num_env; - - uint8_t border_position[MAX_PS_ENVELOPES+1]; - - uint8_t iid_dt[MAX_PS_ENVELOPES]; - uint8_t icc_dt[MAX_PS_ENVELOPES]; - - uint8_t enable_ipdopd; - uint8_t ipd_mode; - uint8_t ipd_dt[MAX_PS_ENVELOPES]; - uint8_t opd_dt[MAX_PS_ENVELOPES]; - - /* indices */ - int8_t iid_index_prev[34]; - int8_t icc_index_prev[34]; - int8_t ipd_index_prev[17]; - int8_t opd_index_prev[17]; - int8_t iid_index[MAX_PS_ENVELOPES][34]; - int8_t icc_index[MAX_PS_ENVELOPES][34]; - int8_t ipd_index[MAX_PS_ENVELOPES][17]; - int8_t opd_index[MAX_PS_ENVELOPES][17]; - - int8_t ipd_index_1[17]; - int8_t opd_index_1[17]; - int8_t ipd_index_2[17]; - int8_t opd_index_2[17]; - - /* ps data was correctly read */ - uint8_t ps_data_available; - - /* a header has been read */ - uint8_t header_read; - - /* hybrid filterbank parameters */ - hyb_info hyb; - uint8_t use34hybrid_bands; - - /**/ - uint8_t num_groups; - uint8_t num_hybrid_groups; - uint8_t nr_par_bands; - uint8_t nr_allpass_bands; - uint8_t decay_cutoff; - - uint8_t *group_border; - uint16_t *map_group2bk; - - /* filter delay handling */ - uint8_t saved_delay; - uint8_t delay_buf_index_ser[NO_ALLPASS_LINKS]; - uint8_t num_sample_delay_ser[NO_ALLPASS_LINKS]; - uint8_t delay_D[64]; - uint8_t delay_buf_index_delay[64]; - - complex_t delay_Qmf[14][64]; /* 14 samples delay max, 64 QMF channels */ - complex_t delay_SubQmf[2][32]; /* 2 samples delay max (SubQmf is always allpass filtered) */ - complex_t delay_Qmf_ser[NO_ALLPASS_LINKS][5][64]; /* 5 samples delay max (table 8.34), 64 QMF channels */ - complex_t delay_SubQmf_ser[NO_ALLPASS_LINKS][5][32]; /* 5 samples delay max (table 8.34) */ - - /* transients */ - real_t alpha_decay; - real_t alpha_smooth; - - real_t P_PeakDecayNrg[34]; - real_t P_prev[34]; - real_t P_SmoothPeakDecayDiffNrg_prev[34]; - - /* mixing and phase */ - complex_t h11_prev[50]; - complex_t h12_prev[50]; - complex_t h21_prev[50]; - complex_t h22_prev[50]; - uint8_t phase_hist; - complex_t ipd_prev[20][2]; - complex_t opd_prev[20][2]; - -} ps_info; - -/* ps_syntax.c */ -uint16_t ps_data(ps_info *ps, bitfile *ld, uint8_t *header); - -/* ps_dec.c */ -void ps_init(ps_info *ps); - -uint8_t ps_decode(ps_info *ps, - qmf_t X_left[MAX_NTSRPS][64], - qmf_t X_right[MAX_NTSRPS][64]); - - -#ifdef __cplusplus -} -#endif -#endif - diff --git a/apps/codecs/libfaad/ps_syntax.c b/apps/codecs/libfaad/ps_syntax.c deleted file mode 100644 index 290d7e5523..0000000000 --- a/apps/codecs/libfaad/ps_syntax.c +++ /dev/null @@ -1,546 +0,0 @@ -/* -** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR and PS decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -** -** Any non-GPL usage of this software or parts of this software is strictly -** forbidden. -** -** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. -** -** $Id$ -**/ - -#include "common.h" - -#ifdef PS_DEC - -#include "bits.h" -#include "ps_dec.h" - -/* type definitaions */ -typedef const int8_t (*ps_huff_tab)[2]; - -/* static data tables */ -static const uint8_t nr_iid_par_tab[] = { - 10, 20, 34, 10, 20, 34, 0, 0 -}; -static const uint8_t nr_ipdopd_par_tab[] = { - 5, 11, 17, 5, 11, 17, 0, 0 -}; -static const uint8_t nr_icc_par_tab[] = { - 10, 20, 34, 10, 20, 34, 0, 0 -}; -static const uint8_t num_env_tab[][4] = { - { 0, 1, 2, 4 }, - { 1, 2, 3, 4 } -}; - -/* binary lookup huffman tables */ -static const int8_t f_huff_iid_def[][2] = { - { /*0*/ -31, 1 }, /* index 0: 1 bits: x */ - { 2, 3 }, /* index 1: 2 bits: 1x */ - { /*1*/ -30, /*-1*/ -32 }, /* index 2: 3 bits: 10x */ - { 4, 5 }, /* index 3: 3 bits: 11x */ - { /*2*/ -29, /*-2*/ -33 }, /* index 4: 4 bits: 110x */ - { 6, 7 }, /* index 5: 4 bits: 111x */ - { /*3*/ -28, /*-3*/ -34 }, /* index 6: 5 bits: 1110x */ - { 8, 9 }, /* index 7: 5 bits: 1111x */ - { /*-4*/ -35, /*4*/ -27 }, /* index 8: 6 bits: 11110x */ - { /*5*/ -26, 10 }, /* index 9: 6 bits: 11111x */ - { /*-5*/ -36, 11 }, /* index 10: 7 bits: 111111x */ - { /*6*/ -25, 12 }, /* index 11: 8 bits: 1111111x */ - { /*-6*/ -37, 13 }, /* index 12: 9 bits: 11111111x */ - { /*-7*/ -38, 14 }, /* index 13: 10 bits: 111111111x */ - { /*7*/ -24, 15 }, /* index 14: 11 bits: 1111111111x */ - { 16, 17 }, /* index 15: 12 bits: 11111111111x */ - { /*8*/ -23, /*-8*/ -39 }, /* index 16: 13 bits: 111111111110x */ - { 18, 19 }, /* index 17: 13 bits: 111111111111x */ - { /*9*/ -22, /*10*/ -21 }, /* index 18: 14 bits: 1111111111110x */ - { 20, 21 }, /* index 19: 14 bits: 1111111111111x */ - { /*-9*/ -40, /*11*/ -20 }, /* index 20: 15 bits: 11111111111110x */ - { 22, 23 }, /* index 21: 15 bits: 11111111111111x */ - { /*-10*/ -41, 24 }, /* index 22: 16 bits: 111111111111110x */ - { 25, 26 }, /* index 23: 16 bits: 111111111111111x */ - { /*-11*/ -42, /*-14*/ -45 }, /* index 24: 17 bits: 1111111111111101x */ - { /*-13*/ -44, /*-12*/ -43 }, /* index 25: 17 bits: 1111111111111110x */ - { /*12*/ -19, 27 }, /* index 26: 17 bits: 1111111111111111x */ - { /*13*/ -18, /*14*/ -17 } /* index 27: 18 bits: 11111111111111111x */ -}; - -static const int8_t t_huff_iid_def[][2] = { - { /*0*/ -31, 1 }, /* index 0: 1 bits: x */ - { /*-1*/ -32, 2 }, /* index 1: 2 bits: 1x */ - { /*1*/ -30, 3 }, /* index 2: 3 bits: 11x */ - { /*-2*/ -33, 4 }, /* index 3: 4 bits: 111x */ - { /*2*/ -29, 5 }, /* index 4: 5 bits: 1111x */ - { /*-3*/ -34, 6 }, /* index 5: 6 bits: 11111x */ - { /*3*/ -28, 7 }, /* index 6: 7 bits: 111111x */ - { /*-4*/ -35, 8 }, /* index 7: 8 bits: 1111111x */ - { /*4*/ -27, 9 }, /* index 8: 9 bits: 11111111x */ - { /*-5*/ -36, 10 }, /* index 9: 10 bits: 111111111x */ - { /*5*/ -26, 11 }, /* index 10: 11 bits: 1111111111x */ - { /*-6*/ -37, 12 }, /* index 11: 12 bits: 11111111111x */ - { /*6*/ -25, 13 }, /* index 12: 13 bits: 111111111111x */ - { /*7*/ -24, 14 }, /* index 13: 14 bits: 1111111111111x */ - { /*-7*/ -38, 15 }, /* index 14: 15 bits: 11111111111111x */ - { 16, 17 }, /* index 15: 16 bits: 111111111111111x */ - { /*8*/ -23, /*-8*/ -39 }, /* index 16: 17 bits: 1111111111111110x */ - { 18, 19 }, /* index 17: 17 bits: 1111111111111111x */ - { 20, 21 }, /* index 18: 18 bits: 11111111111111110x */ - { 22, 23 }, /* index 19: 18 bits: 11111111111111111x */ - { /*9*/ -22, /*-14*/ -45 }, /* index 20: 19 bits: 111111111111111100x */ - { /*-13*/ -44, /*-12*/ -43 }, /* index 21: 19 bits: 111111111111111101x */ - { 24, 25 }, /* index 22: 19 bits: 111111111111111110x */ - { 26, 27 }, /* index 23: 19 bits: 111111111111111111x */ - { /*-11*/ -42, /*-10*/ -41 }, /* index 24: 20 bits: 1111111111111111100x */ - { /*-9*/ -40, /*10*/ -21 }, /* index 25: 20 bits: 1111111111111111101x */ - { /*11*/ -20, /*12*/ -19 }, /* index 26: 20 bits: 1111111111111111110x */ - { /*13*/ -18, /*14*/ -17 } /* index 27: 20 bits: 1111111111111111111x */ -}; - -static const int8_t f_huff_iid_fine[][2] = { - { 1, /*0*/ -31 }, /* index 0: 1 bits: x */ - { 2, 3 }, /* index 1: 2 bits: 0x */ - { 4, /*-1*/ -32 }, /* index 2: 3 bits: 00x */ - { /*1*/ -30, 5 }, /* index 3: 3 bits: 01x */ - { /*-2*/ -33, /*2*/ -29 }, /* index 4: 4 bits: 000x */ - { 6, 7 }, /* index 5: 4 bits: 011x */ - { /*-3*/ -34, /*3*/ -28 }, /* index 6: 5 bits: 0110x */ - { 8, 9 }, /* index 7: 5 bits: 0111x */ - { /*-4*/ -35, /*4*/ -27 }, /* index 8: 6 bits: 01110x */ - { 10, 11 }, /* index 9: 6 bits: 01111x */ - { /*-5*/ -36, /*5*/ -26 }, /* index 10: 7 bits: 011110x */ - { 12, 13 }, /* index 11: 7 bits: 011111x */ - { /*-6*/ -37, /*6*/ -25 }, /* index 12: 8 bits: 0111110x */ - { 14, 15 }, /* index 13: 8 bits: 0111111x */ - { /*7*/ -24, 16 }, /* index 14: 9 bits: 01111110x */ - { 17, 18 }, /* index 15: 9 bits: 01111111x */ - { 19, /*-8*/ -39 }, /* index 16: 10 bits: 011111101x */ - { /*8*/ -23, 20 }, /* index 17: 10 bits: 011111110x */ - { 21, /*-7*/ -38 }, /* index 18: 10 bits: 011111111x */ - { /*10*/ -21, 22 }, /* index 19: 11 bits: 0111111010x */ - { 23, /*-9*/ -40 }, /* index 20: 11 bits: 0111111101x */ - { /*9*/ -22, 24 }, /* index 21: 11 bits: 0111111110x */ - { /*-11*/ -42, /*11*/ -20 }, /* index 22: 12 bits: 01111110101x */ - { 25, 26 }, /* index 23: 12 bits: 01111111010x */ - { 27, /*-10*/ -41 }, /* index 24: 12 bits: 01111111101x */ - { 28, /*-12*/ -43 }, /* index 25: 13 bits: 011111110100x */ - { /*12*/ -19, 29 }, /* index 26: 13 bits: 011111110101x */ - { 30, 31 }, /* index 27: 13 bits: 011111111010x */ - { 32, /*-14*/ -45 }, /* index 28: 14 bits: 0111111101000x */ - { /*14*/ -17, 33 }, /* index 29: 14 bits: 0111111101011x */ - { 34, /*-13*/ -44 }, /* index 30: 14 bits: 0111111110100x */ - { /*13*/ -18, 35 }, /* index 31: 14 bits: 0111111110101x */ - { 36, 37 }, /* index 32: 15 bits: 01111111010000x */ - { 38, /*-15*/ -46 }, /* index 33: 15 bits: 01111111010111x */ - { /*15*/ -16, 39 }, /* index 34: 15 bits: 01111111101000x */ - { 40, 41 }, /* index 35: 15 bits: 01111111101011x */ - { 42, 43 }, /* index 36: 16 bits: 011111110100000x */ - { /*-17*/ -48, /*17*/ -14 }, /* index 37: 16 bits: 011111110100001x */ - { 44, 45 }, /* index 38: 16 bits: 011111110101110x */ - { 46, 47 }, /* index 39: 16 bits: 011111111010001x */ - { 48, 49 }, /* index 40: 16 bits: 011111111010110x */ - { /*-16*/ -47, /*16*/ -15 }, /* index 41: 16 bits: 011111111010111x */ - { /*-21*/ -52, /*21*/ -10 }, /* index 42: 17 bits: 0111111101000000x */ - { /*-19*/ -50, /*19*/ -12 }, /* index 43: 17 bits: 0111111101000001x */ - { /*-18*/ -49, /*18*/ -13 }, /* index 44: 17 bits: 0111111101011100x */ - { 50, 51 }, /* index 45: 17 bits: 0111111101011101x */ - { 52, 53 }, /* index 46: 17 bits: 0111111110100010x */ - { 54, 55 }, /* index 47: 17 bits: 0111111110100011x */ - { 56, 57 }, /* index 48: 17 bits: 0111111110101100x */ - { 58, 59 }, /* index 49: 17 bits: 0111111110101101x */ - { /*-26*/ -57, /*-25*/ -56 }, /* index 50: 18 bits: 01111111010111010x */ - { /*-28*/ -59, /*-27*/ -58 }, /* index 51: 18 bits: 01111111010111011x */ - { /*-22*/ -53, /*22*/ -9 }, /* index 52: 18 bits: 01111111101000100x */ - { /*-24*/ -55, /*-23*/ -54 }, /* index 53: 18 bits: 01111111101000101x */ - { /*25*/ -6, /*26*/ -5 }, /* index 54: 18 bits: 01111111101000110x */ - { /*23*/ -8, /*24*/ -7 }, /* index 55: 18 bits: 01111111101000111x */ - { /*29*/ -2, /*30*/ -1 }, /* index 56: 18 bits: 01111111101011000x */ - { /*27*/ -4, /*28*/ -3 }, /* index 57: 18 bits: 01111111101011001x */ - { /*-30*/ -61, /*-29*/ -60 }, /* index 58: 18 bits: 01111111101011010x */ - { /*-20*/ -51, /*20*/ -11 } /* index 59: 18 bits: 01111111101011011x */ -}; - -static const int8_t t_huff_iid_fine[][2] = { - { 1, /*0*/ -31 }, /* index 0: 1 bits: x */ - { /*1*/ -30, 2 }, /* index 1: 2 bits: 0x */ - { 3, /*-1*/ -32 }, /* index 2: 3 bits: 01x */ - { 4, 5 }, /* index 3: 4 bits: 010x */ - { 6, 7 }, /* index 4: 5 bits: 0100x */ - { /*-2*/ -33, /*2*/ -29 }, /* index 5: 5 bits: 0101x */ - { 8, /*-3*/ -34 }, /* index 6: 6 bits: 01000x */ - { /*3*/ -28, 9 }, /* index 7: 6 bits: 01001x */ - { /*-4*/ -35, /*4*/ -27 }, /* index 8: 7 bits: 010000x */ - { 10, 11 }, /* index 9: 7 bits: 010011x */ - { /*5*/ -26, 12 }, /* index 10: 8 bits: 0100110x */ - { 13, 14 }, /* index 11: 8 bits: 0100111x */ - { /*-6*/ -37, /*6*/ -25 }, /* index 12: 9 bits: 01001101x */ - { 15, 16 }, /* index 13: 9 bits: 01001110x */ - { 17, /*-5*/ -36 }, /* index 14: 9 bits: 01001111x */ - { 18, /*-7*/ -38 }, /* index 15: 10 bits: 010011100x */ - { /*7*/ -24, 19 }, /* index 16: 10 bits: 010011101x */ - { 20, 21 }, /* index 17: 10 bits: 010011110x */ - { /*9*/ -22, 22 }, /* index 18: 11 bits: 0100111000x */ - { 23, 24 }, /* index 19: 11 bits: 0100111011x */ - { /*-8*/ -39, /*8*/ -23 }, /* index 20: 11 bits: 0100111100x */ - { 25, 26 }, /* index 21: 11 bits: 0100111101x */ - { /*11*/ -20, 27 }, /* index 22: 12 bits: 01001110001x */ - { 28, 29 }, /* index 23: 12 bits: 01001110110x */ - { /*-10*/ -41, /*10*/ -21 }, /* index 24: 12 bits: 01001110111x */ - { 30, 31 }, /* index 25: 12 bits: 01001111010x */ - { 32, /*-9*/ -40 }, /* index 26: 12 bits: 01001111011x */ - { 33, /*-13*/ -44 }, /* index 27: 13 bits: 010011100011x */ - { /*13*/ -18, 34 }, /* index 28: 13 bits: 010011101100x */ - { 35, 36 }, /* index 29: 13 bits: 010011101101x */ - { 37, /*-12*/ -43 }, /* index 30: 13 bits: 010011110100x */ - { /*12*/ -19, 38 }, /* index 31: 13 bits: 010011110101x */ - { 39, /*-11*/ -42 }, /* index 32: 13 bits: 010011110110x */ - { 40, 41 }, /* index 33: 14 bits: 0100111000110x */ - { 42, 43 }, /* index 34: 14 bits: 0100111011001x */ - { 44, 45 }, /* index 35: 14 bits: 0100111011010x */ - { 46, /*-15*/ -46 }, /* index 36: 14 bits: 0100111011011x */ - { /*15*/ -16, 47 }, /* index 37: 14 bits: 0100111101000x */ - { /*-14*/ -45, /*14*/ -17 }, /* index 38: 14 bits: 0100111101011x */ - { 48, 49 }, /* index 39: 14 bits: 0100111101100x */ - { /*-21*/ -52, /*-20*/ -51 }, /* index 40: 15 bits: 01001110001100x */ - { /*18*/ -13, /*19*/ -12 }, /* index 41: 15 bits: 01001110001101x */ - { /*-19*/ -50, /*-18*/ -49 }, /* index 42: 15 bits: 01001110110010x */ - { 50, 51 }, /* index 43: 15 bits: 01001110110011x */ - { 52, 53 }, /* index 44: 15 bits: 01001110110100x */ - { 54, 55 }, /* index 45: 15 bits: 01001110110101x */ - { 56, /*-17*/ -48 }, /* index 46: 15 bits: 01001110110110x */ - { /*17*/ -14, 57 }, /* index 47: 15 bits: 01001111010001x */ - { 58, /*-16*/ -47 }, /* index 48: 15 bits: 01001111011000x */ - { /*16*/ -15, 59 }, /* index 49: 15 bits: 01001111011001x */ - { /*-26*/ -57, /*26*/ -5 }, /* index 50: 16 bits: 010011101100110x */ - { /*-28*/ -59, /*-27*/ -58 }, /* index 51: 16 bits: 010011101100111x */ - { /*29*/ -2, /*30*/ -1 }, /* index 52: 16 bits: 010011101101000x */ - { /*27*/ -4, /*28*/ -3 }, /* index 53: 16 bits: 010011101101001x */ - { /*-30*/ -61, /*-29*/ -60 }, /* index 54: 16 bits: 010011101101010x */ - { /*-25*/ -56, /*25*/ -6 }, /* index 55: 16 bits: 010011101101011x */ - { /*-24*/ -55, /*24*/ -7 }, /* index 56: 16 bits: 010011101101100x */ - { /*-23*/ -54, /*23*/ -8 }, /* index 57: 16 bits: 010011110100011x */ - { /*-22*/ -53, /*22*/ -9 }, /* index 58: 16 bits: 010011110110000x */ - { /*20*/ -11, /*21*/ -10 } /* index 59: 16 bits: 010011110110011x */ -}; - -static const int8_t f_huff_icc[][2] = { - { /*0*/ -31, 1 }, /* index 0: 1 bits: x */ - { /*1*/ -30, 2 }, /* index 1: 2 bits: 1x */ - { /*-1*/ -32, 3 }, /* index 2: 3 bits: 11x */ - { /*2*/ -29, 4 }, /* index 3: 4 bits: 111x */ - { /*-2*/ -33, 5 }, /* index 4: 5 bits: 1111x */ - { /*3*/ -28, 6 }, /* index 5: 6 bits: 11111x */ - { /*-3*/ -34, 7 }, /* index 6: 7 bits: 111111x */ - { /*4*/ -27, 8 }, /* index 7: 8 bits: 1111111x */ - { /*5*/ -26, 9 }, /* index 8: 9 bits: 11111111x */ - { /*-4*/ -35, 10 }, /* index 9: 10 bits: 111111111x */ - { /*6*/ -25, 11 }, /* index 10: 11 bits: 1111111111x */ - { /*-5*/ -36, 12 }, /* index 11: 12 bits: 11111111111x */ - { /*7*/ -24, 13 }, /* index 12: 13 bits: 111111111111x */ - { /*-6*/ -37, /*-7*/ -38 } /* index 13: 14 bits: 1111111111111x */ -}; - -static const int8_t t_huff_icc[][2] = { - { /*0*/ -31, 1 }, /* index 0: 1 bits: x */ - { /*1*/ -30, 2 }, /* index 1: 2 bits: 1x */ - { /*-1*/ -32, 3 }, /* index 2: 3 bits: 11x */ - { /*2*/ -29, 4 }, /* index 3: 4 bits: 111x */ - { /*-2*/ -33, 5 }, /* index 4: 5 bits: 1111x */ - { /*3*/ -28, 6 }, /* index 5: 6 bits: 11111x */ - { /*-3*/ -34, 7 }, /* index 6: 7 bits: 111111x */ - { /*4*/ -27, 8 }, /* index 7: 8 bits: 1111111x */ - { /*-4*/ -35, 9 }, /* index 8: 9 bits: 11111111x */ - { /*5*/ -26, 10 }, /* index 9: 10 bits: 111111111x */ - { /*-5*/ -36, 11 }, /* index 10: 11 bits: 1111111111x */ - { /*6*/ -25, 12 }, /* index 11: 12 bits: 11111111111x */ - { /*-6*/ -37, 13 }, /* index 12: 13 bits: 111111111111x */ - { /*-7*/ -38, /*7*/ -24 } /* index 13: 14 bits: 1111111111111x */ -}; - -static const int8_t f_huff_ipd[][2] = { - { 1, /*0*/ -31 }, /* index 0: 1 bits: x */ - { 2, 3 }, /* index 1: 2 bits: 0x */ - { /*1*/ -30, 4 }, /* index 2: 3 bits: 00x */ - { 5, 6 }, /* index 3: 3 bits: 01x */ - { /*4*/ -27, /*5*/ -26 }, /* index 4: 4 bits: 001x */ - { /*3*/ -28, /*6*/ -25 }, /* index 5: 4 bits: 010x */ - { /*2*/ -29, /*7*/ -24 } /* index 6: 4 bits: 011x */ -}; - -static const int8_t t_huff_ipd[][2] = { - { 1, /*0*/ -31 }, /* index 0: 1 bits: x */ - { 2, 3 }, /* index 1: 2 bits: 0x */ - { 4, 5 }, /* index 2: 3 bits: 00x */ - { /*1*/ -30, /*7*/ -24 }, /* index 3: 3 bits: 01x */ - { /*5*/ -26, 6 }, /* index 4: 4 bits: 000x */ - { /*2*/ -29, /*6*/ -25 }, /* index 5: 4 bits: 001x */ - { /*4*/ -27, /*3*/ -28 } /* index 6: 5 bits: 0001x */ -}; - -static const int8_t f_huff_opd[][2] = { - { 1, /*0*/ -31 }, /* index 0: 1 bits: x */ - { 2, 3 }, /* index 1: 2 bits: 0x */ - { /*7*/ -24, /*1*/ -30 }, /* index 2: 3 bits: 00x */ - { 4, 5 }, /* index 3: 3 bits: 01x */ - { /*3*/ -28, /*6*/ -25 }, /* index 4: 4 bits: 010x */ - { /*2*/ -29, 6 }, /* index 5: 4 bits: 011x */ - { /*5*/ -26, /*4*/ -27 } /* index 6: 5 bits: 0111x */ -}; - -static const int8_t t_huff_opd[][2] = { - { 1, /*0*/ -31 }, /* index 0: 1 bits: x */ - { 2, 3 }, /* index 1: 2 bits: 0x */ - { 4, 5 }, /* index 2: 3 bits: 00x */ - { /*1*/ -30, /*7*/ -24 }, /* index 3: 3 bits: 01x */ - { /*5*/ -26, 6 }, /* index 4: 4 bits: 000x */ - { /*2*/ -29, /*6*/ -25 }, /* index 5: 4 bits: 001x */ - { /*4*/ -27, /*3*/ -28 } /* index 6: 5 bits: 0001x */ -}; - -/* static function declarations */ -static uint16_t ps_extension(ps_info *ps, bitfile *ld, - const uint8_t ps_extension_id, - const uint16_t num_bits_left); -static void huff_data(bitfile *ld, const uint8_t dt, const uint8_t nr_par, - ps_huff_tab t_huff, ps_huff_tab f_huff, int8_t *par); -static INLINE int8_t ps_huff_dec(bitfile *ld, ps_huff_tab t_huff); - - -uint16_t ps_data(ps_info *ps, bitfile *ld, uint8_t *header) -{ - uint8_t tmp, n; - uint16_t bits = (uint16_t)faad_get_processed_bits(ld); - - *header = 0; - - /* check for new PS header */ - if (faad_get1bit(ld - DEBUGVAR(1,1000,"ps_data(): enable_ps_header"))) - { - *header = 1; - - ps->header_read = 1; - - ps->use34hybrid_bands = 0; - - /* Inter-channel Intensity Difference (IID) parameters enabled */ - ps->enable_iid = (uint8_t)faad_get1bit(ld - DEBUGVAR(1,1001,"ps_data(): enable_iid")); - - if (ps->enable_iid) - { - ps->iid_mode = (uint8_t)faad_getbits(ld, 3 - DEBUGVAR(1,1002,"ps_data(): iid_mode")); - - ps->nr_iid_par = nr_iid_par_tab[ps->iid_mode]; - ps->nr_ipdopd_par = nr_ipdopd_par_tab[ps->iid_mode]; - - if (ps->iid_mode == 2 || ps->iid_mode == 5) - ps->use34hybrid_bands = 1; - - /* IPD freq res equal to IID freq res */ - ps->ipd_mode = ps->iid_mode; - } - - /* Inter-channel Coherence (ICC) parameters enabled */ - ps->enable_icc = (uint8_t)faad_get1bit(ld - DEBUGVAR(1,1003,"ps_data(): enable_icc")); - - if (ps->enable_icc) - { - ps->icc_mode = (uint8_t)faad_getbits(ld, 3 - DEBUGVAR(1,1004,"ps_data(): icc_mode")); - - ps->nr_icc_par = nr_icc_par_tab[ps->icc_mode]; - - if (ps->icc_mode == 2 || ps->icc_mode == 5) - ps->use34hybrid_bands = 1; - } - - /* PS extension layer enabled */ - ps->enable_ext = (uint8_t)faad_get1bit(ld - DEBUGVAR(1,1005,"ps_data(): enable_ext")); - } - - /* we are here, but no header has been read yet */ - if (ps->header_read == 0) - return 1; - - ps->frame_class = (uint8_t)faad_get1bit(ld - DEBUGVAR(1,1006,"ps_data(): frame_class")); - tmp = (uint8_t)faad_getbits(ld, 2 - DEBUGVAR(1,1007,"ps_data(): num_env_idx")); - - ps->num_env = num_env_tab[ps->frame_class][tmp]; - - if (ps->frame_class) - { - for (n = 1; n < ps->num_env+1; n++) - { - ps->border_position[n] = (uint8_t)faad_getbits(ld, 5 - DEBUGVAR(1,1008,"ps_data(): border_position")); - } - } - - if (ps->enable_iid) - { - for (n = 0; n < ps->num_env; n++) - { - ps->iid_dt[n] = (uint8_t)faad_get1bit(ld - DEBUGVAR(1,1009,"ps_data(): iid_dt")); - - /* iid_data */ - if (ps->iid_mode < 3) - { - huff_data(ld, ps->iid_dt[n], ps->nr_iid_par, t_huff_iid_def, - f_huff_iid_def, ps->iid_index[n]); - } else { - huff_data(ld, ps->iid_dt[n], ps->nr_iid_par, t_huff_iid_fine, - f_huff_iid_fine, ps->iid_index[n]); - } - } - } - - if (ps->enable_icc) - { - for (n = 0; n < ps->num_env; n++) - { - ps->icc_dt[n] = (uint8_t)faad_get1bit(ld - DEBUGVAR(1,1010,"ps_data(): icc_dt")); - - /* icc_data */ - huff_data(ld, ps->icc_dt[n], ps->nr_icc_par, t_huff_icc, - f_huff_icc, ps->icc_index[n]); - } - } - - if (ps->enable_ext) - { - uint16_t num_bits_left; - uint16_t cnt = (uint16_t)faad_getbits(ld, 4 - DEBUGVAR(1,1011,"ps_data(): ps_extension_size")); - if (cnt == 15) - { - cnt += (uint16_t)faad_getbits(ld, 8 - DEBUGVAR(1,1012,"ps_data(): esc_count")); - } - - num_bits_left = 8 * cnt; - while (num_bits_left > 7) - { - uint8_t ps_extension_id = (uint8_t)faad_getbits(ld, 2 - DEBUGVAR(1,1013,"ps_data(): ps_extension_size")); - - num_bits_left -= 2; - num_bits_left -= ps_extension(ps, ld, ps_extension_id, num_bits_left); - } - - faad_getbits(ld, num_bits_left - DEBUGVAR(1,1014,"ps_data(): fill_bits")); - } - - bits = (uint16_t)faad_get_processed_bits(ld) - bits; - - ps->ps_data_available = 1; - - return bits; -} - -static uint16_t ps_extension(ps_info *ps, bitfile *ld, - const uint8_t ps_extension_id, - const uint16_t num_bits_left) -{ - uint8_t n; - uint16_t bits = (uint16_t)faad_get_processed_bits(ld); - - (void)num_bits_left; - if (ps_extension_id == 0) - { - ps->enable_ipdopd = (uint8_t)faad_get1bit(ld - DEBUGVAR(1,1015,"ps_extension(): enable_ipdopd")); - - if (ps->enable_ipdopd) - { - for (n = 0; n < ps->num_env; n++) - { - ps->ipd_dt[n] = (uint8_t)faad_get1bit(ld - DEBUGVAR(1,1016,"ps_extension(): ipd_dt")); - - /* ipd_data */ - huff_data(ld, ps->ipd_dt[n], ps->nr_ipdopd_par, t_huff_ipd, - f_huff_ipd, ps->ipd_index[n]); - - ps->opd_dt[n] = (uint8_t)faad_get1bit(ld - DEBUGVAR(1,1017,"ps_extension(): opd_dt")); - - /* opd_data */ - huff_data(ld, ps->opd_dt[n], ps->nr_ipdopd_par, t_huff_opd, - f_huff_opd, ps->opd_index[n]); - } - } - faad_get1bit(ld - DEBUGVAR(1,1018,"ps_extension(): reserved_ps")); - } - - /* return number of bits read */ - bits = (uint16_t)faad_get_processed_bits(ld) - bits; - - return bits; -} - -/* read huffman data coded in either the frequency or the time direction */ -static void huff_data(bitfile *ld, const uint8_t dt, const uint8_t nr_par, - ps_huff_tab t_huff, ps_huff_tab f_huff, int8_t *par) -{ - uint8_t n; - - if (dt) - { - /* coded in time direction */ - for (n = 0; n < nr_par; n++) - { - par[n] = ps_huff_dec(ld, t_huff); - } - } else { - /* coded in frequency direction */ - par[0] = ps_huff_dec(ld, f_huff); - - for (n = 1; n < nr_par; n++) - { - par[n] = ps_huff_dec(ld, f_huff); - } - } -} - -/* binary search huffman decoding */ -static INLINE int8_t ps_huff_dec(bitfile *ld, ps_huff_tab t_huff) -{ - uint8_t bit; - int16_t index = 0; - - while (index >= 0) - { - bit = (uint8_t)faad_get1bit(ld); - index = t_huff[index][bit]; - } - - return index + 31; -} - -#endif diff --git a/apps/codecs/libfaad/ps_tables.h b/apps/codecs/libfaad/ps_tables.h deleted file mode 100644 index 83cd20abbf..0000000000 --- a/apps/codecs/libfaad/ps_tables.h +++ /dev/null @@ -1,547 +0,0 @@ -/* -** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -** -** Any non-GPL usage of this software or parts of this software is strictly -** forbidden. -** -** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. -** -** $Id$ -**/ - -#ifndef __PS_TABLES_H__ -#define __PS_TABLES_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef _MSC_VER -#pragma warning(disable:4305) -#pragma warning(disable:4244) -#endif - -#if 0 -#if 0 -float f_center_20[12] = { - 0.5/4, 1.5/4, 2.5/4, 3.5/4, - 4.5/4*0, 5.5/4*0, -1.5/4, -0.5/4, - 3.5/2, 2.5/2, 4.5/2, 5.5/2 -}; -#else -float f_center_20[12] = { - 0.5/8, 1.5/8, 2.5/8, 3.5/8, - 4.5/8*0, 5.5/8*0, -1.5/8, -0.5/8, - 3.5/4, 2.5/4, 4.5/4, 5.5/4 -}; -#endif - -float f_center_34[32] = { - 1/12, 3/12, 5/12, 7/12, - 9/12, 11/12, 13/12, 15/12, - 17/12, -5/12, -3/12, -1/12, - 17/8, 19/8, 5/8, 7/8, - 9/8, 11/8, 13/8, 15/8, - 9/4, 11/4, 13/4, 7/4, - 17/4, 11/4, 13/4, 15/4, - 17/4, 19/4, 21/4, 15/4 -}; - -static const real_t frac_delay_q[] = { - FRAC_CONST(0.43), - FRAC_CONST(0.75), - FRAC_CONST(0.347) -}; -#endif - -/* RE(ps->Phi_Fract_Qmf[j]) = (float)cos(M_PI*(j+0.5)*(0.39)); */ -/* IM(ps->Phi_Fract_Qmf[j]) = (float)sin(M_PI*(j+0.5)*(0.39)); */ -static const complex_t Phi_Fract_Qmf[] = { - { FRAC_CONST(0.8181497455), FRAC_CONST(0.5750052333) }, - { FRAC_CONST(-0.2638730407), FRAC_CONST(0.9645574093) }, - { FRAC_CONST(-0.9969173074), FRAC_CONST(0.0784590989) }, - { FRAC_CONST(-0.4115143716), FRAC_CONST(-0.9114032984) }, - { FRAC_CONST(0.7181262970), FRAC_CONST(-0.6959127784) }, - { FRAC_CONST(0.8980275989), FRAC_CONST(0.4399391711) }, - { FRAC_CONST(-0.1097343117), FRAC_CONST(0.9939609766) }, - { FRAC_CONST(-0.9723699093), FRAC_CONST(0.2334453613) }, - { FRAC_CONST(-0.5490227938), FRAC_CONST(-0.8358073831) }, - { FRAC_CONST(0.6004202366), FRAC_CONST(-0.7996846437) }, - { FRAC_CONST(0.9557930231), FRAC_CONST(0.2940403223) }, - { FRAC_CONST(0.0471064523), FRAC_CONST(0.9988898635) }, - { FRAC_CONST(-0.9238795042), FRAC_CONST(0.3826834261) }, - { FRAC_CONST(-0.6730124950), FRAC_CONST(-0.7396311164) }, - { FRAC_CONST(0.4679298103), FRAC_CONST(-0.8837656379) }, - { FRAC_CONST(0.9900236726), FRAC_CONST(0.1409012377) }, - { FRAC_CONST(0.2027872950), FRAC_CONST(0.9792228341) }, - { FRAC_CONST(-0.8526401520), FRAC_CONST(0.5224985480) }, - { FRAC_CONST(-0.7804304361), FRAC_CONST(-0.6252426505) }, - { FRAC_CONST(0.3239174187), FRAC_CONST(-0.9460853338) }, - { FRAC_CONST(0.9998766184), FRAC_CONST(-0.0157073177) }, - { FRAC_CONST(0.3534748554), FRAC_CONST(0.9354440570) }, - { FRAC_CONST(-0.7604059577), FRAC_CONST(0.6494480371) }, - { FRAC_CONST(-0.8686315417), FRAC_CONST(-0.4954586625) }, - { FRAC_CONST(0.1719291061), FRAC_CONST(-0.9851093292) }, - { FRAC_CONST(0.9851093292), FRAC_CONST(-0.1719291061) }, - { FRAC_CONST(0.4954586625), FRAC_CONST(0.8686315417) }, - { FRAC_CONST(-0.6494480371), FRAC_CONST(0.7604059577) }, - { FRAC_CONST(-0.9354440570), FRAC_CONST(-0.3534748554) }, - { FRAC_CONST(0.0157073177), FRAC_CONST(-0.9998766184) }, - { FRAC_CONST(0.9460853338), FRAC_CONST(-0.3239174187) }, - { FRAC_CONST(0.6252426505), FRAC_CONST(0.7804304361) }, - { FRAC_CONST(-0.5224985480), FRAC_CONST(0.8526401520) }, - { FRAC_CONST(-0.9792228341), FRAC_CONST(-0.2027872950) }, - { FRAC_CONST(-0.1409012377), FRAC_CONST(-0.9900236726) }, - { FRAC_CONST(0.8837656379), FRAC_CONST(-0.4679298103) }, - { FRAC_CONST(0.7396311164), FRAC_CONST(0.6730124950) }, - { FRAC_CONST(-0.3826834261), FRAC_CONST(0.9238795042) }, - { FRAC_CONST(-0.9988898635), FRAC_CONST(-0.0471064523) }, - { FRAC_CONST(-0.2940403223), FRAC_CONST(-0.9557930231) }, - { FRAC_CONST(0.7996846437), FRAC_CONST(-0.6004202366) }, - { FRAC_CONST(0.8358073831), FRAC_CONST(0.5490227938) }, - { FRAC_CONST(-0.2334453613), FRAC_CONST(0.9723699093) }, - { FRAC_CONST(-0.9939609766), FRAC_CONST(0.1097343117) }, - { FRAC_CONST(-0.4399391711), FRAC_CONST(-0.8980275989) }, - { FRAC_CONST(0.6959127784), FRAC_CONST(-0.7181262970) }, - { FRAC_CONST(0.9114032984), FRAC_CONST(0.4115143716) }, - { FRAC_CONST(-0.0784590989), FRAC_CONST(0.9969173074) }, - { FRAC_CONST(-0.9645574093), FRAC_CONST(0.2638730407) }, - { FRAC_CONST(-0.5750052333), FRAC_CONST(-0.8181497455) }, - { FRAC_CONST(0.5750052333), FRAC_CONST(-0.8181497455) }, - { FRAC_CONST(0.9645574093), FRAC_CONST(0.2638730407) }, - { FRAC_CONST(0.0784590989), FRAC_CONST(0.9969173074) }, - { FRAC_CONST(-0.9114032984), FRAC_CONST(0.4115143716) }, - { FRAC_CONST(-0.6959127784), FRAC_CONST(-0.7181262970) }, - { FRAC_CONST(0.4399391711), FRAC_CONST(-0.8980275989) }, - { FRAC_CONST(0.9939609766), FRAC_CONST(0.1097343117) }, - { FRAC_CONST(0.2334453613), FRAC_CONST(0.9723699093) }, - { FRAC_CONST(-0.8358073831), FRAC_CONST(0.5490227938) }, - { FRAC_CONST(-0.7996846437), FRAC_CONST(-0.6004202366) }, - { FRAC_CONST(0.2940403223), FRAC_CONST(-0.9557930231) }, - { FRAC_CONST(0.9988898635), FRAC_CONST(-0.0471064523) }, - { FRAC_CONST(0.3826834261), FRAC_CONST(0.9238795042) }, - { FRAC_CONST(-0.7396311164), FRAC_CONST(0.6730124950) } -}; - -/* RE(Phi_Fract_SubQmf20[j]) = (float)cos(M_PI*f_center_20[j]*0.39); */ -/* IM(Phi_Fract_SubQmf20[j]) = (float)sin(M_PI*f_center_20[j]*0.39); */ -static const complex_t Phi_Fract_SubQmf20[] = { - { FRAC_CONST(0.9882950187), FRAC_CONST(0.1525546312) }, - { FRAC_CONST(0.8962930441), FRAC_CONST(0.4434623122) }, - { FRAC_CONST(0.7208535671), FRAC_CONST(0.6930873394) }, - { FRAC_CONST(0.4783087075), FRAC_CONST(0.8781917691) }, - { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, - { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, - { FRAC_CONST(0.8962930441), FRAC_CONST(-0.4434623122) }, - { FRAC_CONST(0.9882950187), FRAC_CONST(-0.1525546312) }, - { FRAC_CONST(-0.5424415469), FRAC_CONST(0.8400935531) }, - { FRAC_CONST(0.0392598175), FRAC_CONST(0.9992290139) }, - { FRAC_CONST(-0.9268565774), FRAC_CONST(0.3754155636) }, - { FRAC_CONST(-0.9741733670), FRAC_CONST(-0.2258012742) } -}; - -/* RE(Phi_Fract_SubQmf34[j]) = (float)cos(M_PI*f_center_34[j]*0.39); */ -/* IM(Phi_Fract_SubQmf34[j]) = (float)sin(M_PI*f_center_34[j]*0.39); */ -static const complex_t Phi_Fract_SubQmf34[] = { - { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, - { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, - { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, - { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, - { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, - { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, - { FRAC_CONST(0.3387379348), FRAC_CONST(0.9408807755) }, - { FRAC_CONST(0.3387379348), FRAC_CONST(0.9408807755) }, - { FRAC_CONST(0.3387379348), FRAC_CONST(0.9408807755) }, - { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, - { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, - { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, - { FRAC_CONST(-0.7705132365), FRAC_CONST(0.6374239922) }, - { FRAC_CONST(-0.7705132365), FRAC_CONST(0.6374239922) }, - { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, - { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, - { FRAC_CONST(0.3387379348), FRAC_CONST(0.9408807755) }, - { FRAC_CONST(0.3387379348), FRAC_CONST(0.9408807755) }, - { FRAC_CONST(0.3387379348), FRAC_CONST(0.9408807755) }, - { FRAC_CONST(0.3387379348), FRAC_CONST(0.9408807755) }, - { FRAC_CONST(-0.7705132365), FRAC_CONST(0.6374239922) }, - { FRAC_CONST(-0.7705132365), FRAC_CONST(0.6374239922) }, - { FRAC_CONST(-0.8607420325), FRAC_CONST(-0.5090414286) }, - { FRAC_CONST(0.3387379348), FRAC_CONST(0.9408807755) }, - { FRAC_CONST(0.1873813123), FRAC_CONST(-0.9822872281) }, - { FRAC_CONST(-0.7705132365), FRAC_CONST(0.6374239922) }, - { FRAC_CONST(-0.8607420325), FRAC_CONST(-0.5090414286) }, - { FRAC_CONST(-0.8607420325), FRAC_CONST(-0.5090414286) }, - { FRAC_CONST(0.1873813123), FRAC_CONST(-0.9822872281) }, - { FRAC_CONST(0.1873813123), FRAC_CONST(-0.9822872281) }, - { FRAC_CONST(0.9876883626), FRAC_CONST(-0.1564344615) }, - { FRAC_CONST(-0.8607420325), FRAC_CONST(-0.5090414286) } -}; - -/* RE(Q_Fract_allpass_Qmf[j][i]) = (float)cos(M_PI*(j+0.5)*(frac_delay_q[i])); */ -/* IM(Q_Fract_allpass_Qmf[j][i]) = (float)sin(M_PI*(j+0.5)*(frac_delay_q[i])); */ -static const complex_t Q_Fract_allpass_Qmf[][3] = { - { { FRAC_CONST(0.7804303765), FRAC_CONST(0.6252426505) }, { FRAC_CONST(0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(0.8550928831), FRAC_CONST(0.5184748173) } }, - { { FRAC_CONST(-0.4399392009), FRAC_CONST(0.8980275393) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(-0.0643581524), FRAC_CONST(0.9979268909) } }, - { { FRAC_CONST(-0.9723699093), FRAC_CONST(-0.2334454209) }, { FRAC_CONST(0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(-0.9146071672), FRAC_CONST(0.4043435752) } }, - { { FRAC_CONST(0.0157073960), FRAC_CONST(-0.9998766184) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(-0.7814115286), FRAC_CONST(-0.6240159869) } }, - { { FRAC_CONST(0.9792228341), FRAC_CONST(-0.2027871907) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(0.1920081824), FRAC_CONST(-0.9813933372) } }, - { { FRAC_CONST(0.4115142524), FRAC_CONST(0.9114032984) }, { FRAC_CONST(0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(0.9589683414), FRAC_CONST(-0.2835132182) } }, - { { FRAC_CONST(-0.7996847630), FRAC_CONST(0.6004201174) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(0.6947838664), FRAC_CONST(0.7192186117) } }, - { { FRAC_CONST(-0.7604058385), FRAC_CONST(-0.6494481564) }, { FRAC_CONST(0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(-0.3164770305), FRAC_CONST(0.9486001730) } }, - { { FRAC_CONST(0.4679299891), FRAC_CONST(-0.8837655187) }, { FRAC_CONST(0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(-0.9874414206), FRAC_CONST(0.1579856575) } }, - { { FRAC_CONST(0.9645573497), FRAC_CONST(0.2638732493) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(-0.5966450572), FRAC_CONST(-0.8025052547) } }, - { { FRAC_CONST(-0.0471066870), FRAC_CONST(0.9988898635) }, { FRAC_CONST(0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(0.4357025325), FRAC_CONST(-0.9000906944) } }, - { { FRAC_CONST(-0.9851093888), FRAC_CONST(0.1719288528) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(0.9995546937), FRAC_CONST(-0.0298405960) } }, - { { FRAC_CONST(-0.3826831877), FRAC_CONST(-0.9238796234) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(0.4886211455), FRAC_CONST(0.8724960685) } }, - { { FRAC_CONST(0.8181498647), FRAC_CONST(-0.5750049949) }, { FRAC_CONST(0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(-0.5477093458), FRAC_CONST(0.8366686702) } }, - { { FRAC_CONST(0.7396308780), FRAC_CONST(0.6730127335) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(-0.9951074123), FRAC_CONST(-0.0987988561) } }, - { { FRAC_CONST(-0.4954589605), FRAC_CONST(0.8686313629) }, { FRAC_CONST(0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(-0.3725017905), FRAC_CONST(-0.9280315042) } }, - { { FRAC_CONST(-0.9557929039), FRAC_CONST(-0.2940406799) }, { FRAC_CONST(0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(0.6506417990), FRAC_CONST(-0.7593847513) } }, - { { FRAC_CONST(0.0784594864), FRAC_CONST(-0.9969173074) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(0.9741733670), FRAC_CONST(0.2258014232) } }, - { { FRAC_CONST(0.9900237322), FRAC_CONST(-0.1409008205) }, { FRAC_CONST(0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(0.2502108514), FRAC_CONST(0.9681913853) } }, - { { FRAC_CONST(0.3534744382), FRAC_CONST(0.9354441762) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(-0.7427945137), FRAC_CONST(0.6695194840) } }, - { { FRAC_CONST(-0.8358076215), FRAC_CONST(0.5490224361) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(-0.9370992780), FRAC_CONST(-0.3490629196) } }, - { { FRAC_CONST(-0.7181259394), FRAC_CONST(-0.6959131360) }, { FRAC_CONST(0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(-0.1237744763), FRAC_CONST(-0.9923103452) } }, - { { FRAC_CONST(0.5224990249), FRAC_CONST(-0.8526399136) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(0.8226406574), FRAC_CONST(-0.5685616732) } }, - { { FRAC_CONST(0.9460852146), FRAC_CONST(0.3239179254) }, { FRAC_CONST(0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(0.8844994903), FRAC_CONST(0.4665412009) } }, - { { FRAC_CONST(-0.1097348556), FRAC_CONST(0.9939609170) }, { FRAC_CONST(0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(-0.0047125919), FRAC_CONST(0.9999889135) } }, - { { FRAC_CONST(-0.9939610362), FRAC_CONST(0.1097337380) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(-0.8888573647), FRAC_CONST(0.4581840038) } }, - { { FRAC_CONST(-0.3239168525), FRAC_CONST(-0.9460855722) }, { FRAC_CONST(0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(-0.8172453642), FRAC_CONST(-0.5762898922) } }, - { { FRAC_CONST(0.8526405096), FRAC_CONST(-0.5224980116) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(0.1331215799), FRAC_CONST(-0.9910997152) } }, - { { FRAC_CONST(0.6959123611), FRAC_CONST(0.7181267142) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(0.9403476119), FRAC_CONST(-0.3402152061) } }, - { { FRAC_CONST(-0.5490233898), FRAC_CONST(0.8358070254) }, { FRAC_CONST(0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(0.7364512086), FRAC_CONST(0.6764906645) } }, - { { FRAC_CONST(-0.9354437590), FRAC_CONST(-0.3534754813) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(-0.2593250275), FRAC_CONST(0.9657900929) } }, - { { FRAC_CONST(0.1409019381), FRAC_CONST(-0.9900235534) }, { FRAC_CONST(0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(-0.9762582779), FRAC_CONST(0.2166097313) } }, - { { FRAC_CONST(0.9969173670), FRAC_CONST(-0.0784583688) }, { FRAC_CONST(0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(-0.6434556246), FRAC_CONST(-0.7654833794) } }, - { { FRAC_CONST(0.2940396070), FRAC_CONST(0.9557932615) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(0.3812320232), FRAC_CONST(-0.9244794250) } }, - { { FRAC_CONST(-0.8686318994), FRAC_CONST(0.4954580069) }, { FRAC_CONST(0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(0.9959943891), FRAC_CONST(-0.0894154981) } }, - { { FRAC_CONST(-0.6730118990), FRAC_CONST(-0.7396316528) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(0.5397993922), FRAC_CONST(0.8417937160) } }, - { { FRAC_CONST(0.5750059485), FRAC_CONST(-0.8181492686) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(-0.4968227744), FRAC_CONST(0.8678520322) } }, - { { FRAC_CONST(0.9238792062), FRAC_CONST(0.3826842010) }, { FRAC_CONST(0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(-0.9992290139), FRAC_CONST(-0.0392601527) } }, - { { FRAC_CONST(-0.1719299555), FRAC_CONST(0.9851091504) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(-0.4271997511), FRAC_CONST(-0.9041572809) } }, - { { FRAC_CONST(-0.9988899231), FRAC_CONST(0.0471055657) }, { FRAC_CONST(0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(0.6041822433), FRAC_CONST(-0.7968461514) } }, - { { FRAC_CONST(-0.2638721764), FRAC_CONST(-0.9645576477) }, { FRAC_CONST(0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(0.9859085083), FRAC_CONST(0.1672853529) } }, - { { FRAC_CONST(0.8837660551), FRAC_CONST(-0.4679289758) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(0.3075223565), FRAC_CONST(0.9515408874) } }, - { { FRAC_CONST(0.6494473219), FRAC_CONST(0.7604066133) }, { FRAC_CONST(0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(-0.7015317082), FRAC_CONST(0.7126382589) } }, - { { FRAC_CONST(-0.6004210114), FRAC_CONST(0.7996840477) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(-0.9562535882), FRAC_CONST(-0.2925389707) } }, - { { FRAC_CONST(-0.9114028811), FRAC_CONST(-0.4115152657) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(-0.1827499419), FRAC_CONST(-0.9831594229) } }, - { { FRAC_CONST(0.2027882934), FRAC_CONST(-0.9792225957) }, { FRAC_CONST(0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(0.7872582674), FRAC_CONST(-0.6166234016) } }, - { { FRAC_CONST(0.9998766780), FRAC_CONST(-0.0157062728) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(0.9107555747), FRAC_CONST(0.4129458666) } }, - { { FRAC_CONST(0.2334443331), FRAC_CONST(0.9723701477) }, { FRAC_CONST(0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(0.0549497530), FRAC_CONST(0.9984891415) } }, - { { FRAC_CONST(-0.8980280757), FRAC_CONST(0.4399381876) }, { FRAC_CONST(0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(-0.8599416018), FRAC_CONST(0.5103924870) } }, - { { FRAC_CONST(-0.6252418160), FRAC_CONST(-0.7804310918) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(-0.8501682281), FRAC_CONST(-0.5265110731) } }, - { { FRAC_CONST(0.6252435446), FRAC_CONST(-0.7804297209) }, { FRAC_CONST(0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(0.0737608299), FRAC_CONST(-0.9972759485) } }, - { { FRAC_CONST(0.8980270624), FRAC_CONST(0.4399402142) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(0.9183775187), FRAC_CONST(-0.3957053721) } }, - { { FRAC_CONST(-0.2334465086), FRAC_CONST(0.9723696709) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(0.7754954696), FRAC_CONST(0.6313531399) } }, - { { FRAC_CONST(-0.9998766184), FRAC_CONST(-0.0157085191) }, { FRAC_CONST(0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(-0.2012493610), FRAC_CONST(0.9795400500) } }, - { { FRAC_CONST(-0.2027861029), FRAC_CONST(-0.9792230725) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(-0.9615978599), FRAC_CONST(0.2744622827) } }, - { { FRAC_CONST(0.9114037752), FRAC_CONST(-0.4115132093) }, { FRAC_CONST(0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(-0.6879743338), FRAC_CONST(-0.7257350087) } }, - { { FRAC_CONST(0.6004192233), FRAC_CONST(0.7996854186) }, { FRAC_CONST(0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(0.3254036009), FRAC_CONST(-0.9455752373) } }, - { { FRAC_CONST(-0.6494490504), FRAC_CONST(0.7604051232) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(0.9888865948), FRAC_CONST(-0.1486719251) } }, - { { FRAC_CONST(-0.8837650418), FRAC_CONST(-0.4679309726) }, { FRAC_CONST(0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(0.5890548825), FRAC_CONST(0.8080930114) } }, - { { FRAC_CONST(0.2638743520), FRAC_CONST(-0.9645570517) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(-0.4441666007), FRAC_CONST(0.8959442377) } }, - { { FRAC_CONST(0.9988898039), FRAC_CONST(0.0471078083) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(-0.9997915030), FRAC_CONST(0.0204183888) } }, - { { FRAC_CONST(0.1719277352), FRAC_CONST(0.9851095676) }, { FRAC_CONST(0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(-0.4803760946), FRAC_CONST(-0.8770626187) } }, - { { FRAC_CONST(-0.9238800406), FRAC_CONST(0.3826821446) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(0.5555707216), FRAC_CONST(-0.8314692974) } }, - { { FRAC_CONST(-0.5750041008), FRAC_CONST(-0.8181505203) }, { FRAC_CONST(0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(0.9941320419), FRAC_CONST(0.1081734300) } } -}; - -/* RE(Q_Fract_allpass_SubQmf20[j][i]) = (float)cos(M_PI*f_center_20[j]*frac_delay_q[i]); */ -/* IM(Q_Fract_allpass_SubQmf20[j][i]) = (float)sin(M_PI*f_center_20[j]*frac_delay_q[i]); */ -static const complex_t Q_Fract_allpass_SubQmf20[][3] = { - { { FRAC_CONST(0.9857769012), FRAC_CONST(0.1680592746) }, { FRAC_CONST(0.9569403529), FRAC_CONST(0.2902846634) }, { FRAC_CONST(0.9907300472), FRAC_CONST(0.1358452588) } }, - { { FRAC_CONST(0.8744080663), FRAC_CONST(0.4851911962) }, { FRAC_CONST(0.6343932748), FRAC_CONST(0.7730104327) }, { FRAC_CONST(0.9175986052), FRAC_CONST(0.3975082636) } }, - { { FRAC_CONST(0.6642524004), FRAC_CONST(0.7475083470) }, { FRAC_CONST(0.0980171412), FRAC_CONST(0.9951847196) }, { FRAC_CONST(0.7767338753), FRAC_CONST(0.6298289299) } }, - { { FRAC_CONST(0.3790524006), FRAC_CONST(0.9253752232) }, { FRAC_CONST(-0.4713967443), FRAC_CONST(0.8819212914) }, { FRAC_CONST(0.5785340071), FRAC_CONST(0.8156582713) } }, - { { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) } }, - { { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) } }, - { { FRAC_CONST(0.8744080663), FRAC_CONST(-0.4851911962) }, { FRAC_CONST(0.6343932748), FRAC_CONST(-0.7730104327) }, { FRAC_CONST(0.9175986052), FRAC_CONST(-0.3975082636) } }, - { { FRAC_CONST(0.9857769012), FRAC_CONST(-0.1680592746) }, { FRAC_CONST(0.9569403529), FRAC_CONST(-0.2902846634) }, { FRAC_CONST(0.9907300472), FRAC_CONST(-0.1358452588) } }, - { { FRAC_CONST(-0.7126385570), FRAC_CONST(0.7015314102) }, { FRAC_CONST(-0.5555702448), FRAC_CONST(-0.8314695954) }, { FRAC_CONST(-0.3305967748), FRAC_CONST(0.9437720776) } }, - { { FRAC_CONST(-0.1175374240), FRAC_CONST(0.9930684566) }, { FRAC_CONST(-0.9807852507), FRAC_CONST(0.1950903237) }, { FRAC_CONST(0.2066311091), FRAC_CONST(0.9784189463) } }, - { { FRAC_CONST(-0.9947921634), FRAC_CONST(0.1019244045) }, { FRAC_CONST(0.5555702448), FRAC_CONST(-0.8314695954) }, { FRAC_CONST(-0.7720130086), FRAC_CONST(0.6356067061) } }, - { { FRAC_CONST(-0.8400934935), FRAC_CONST(-0.5424416065) }, { FRAC_CONST(0.9807852507), FRAC_CONST(0.1950903237) }, { FRAC_CONST(-0.9896889329), FRAC_CONST(0.1432335079) } } -}; - -/* RE(Q_Fract_allpass_SubQmf34[j][i]) = (float)cos(M_PI*f_center_34[j]*frac_delay_q[i]); */ -/* IM(Q_Fract_allpass_SubQmf34[j][i]) = (float)sin(M_PI*f_center_34[j]*frac_delay_q[i]); */ -static const complex_t Q_Fract_allpass_SubQmf34[][3] = { - { { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) } }, - { { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) } }, - { { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) } }, - { { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) } }, - { { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) } }, - { { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) } }, - { { FRAC_CONST(0.2181432247), FRAC_CONST(0.9759167433) }, { FRAC_CONST(-0.7071067691), FRAC_CONST(0.7071067691) }, { FRAC_CONST(0.4623677433), FRAC_CONST(0.8866882324) } }, - { { FRAC_CONST(0.2181432247), FRAC_CONST(0.9759167433) }, { FRAC_CONST(-0.7071067691), FRAC_CONST(0.7071067691) }, { FRAC_CONST(0.4623677433), FRAC_CONST(0.8866882324) } }, - { { FRAC_CONST(0.2181432247), FRAC_CONST(0.9759167433) }, { FRAC_CONST(-0.7071067691), FRAC_CONST(0.7071067691) }, { FRAC_CONST(0.4623677433), FRAC_CONST(0.8866882324) } }, - { { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) } }, - { { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) } }, - { { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) } }, - { { FRAC_CONST(-0.9048270583), FRAC_CONST(0.4257792532) }, { FRAC_CONST(-0.0000000000), FRAC_CONST(-1.0000000000) }, { FRAC_CONST(-0.5724321604), FRAC_CONST(0.8199520707) } }, - { { FRAC_CONST(-0.9048270583), FRAC_CONST(0.4257792532) }, { FRAC_CONST(-0.0000000000), FRAC_CONST(-1.0000000000) }, { FRAC_CONST(-0.5724321604), FRAC_CONST(0.8199520707) } }, - { { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) } }, - { { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) } }, - { { FRAC_CONST(0.2181432247), FRAC_CONST(0.9759167433) }, { FRAC_CONST(-0.7071067691), FRAC_CONST(0.7071067691) }, { FRAC_CONST(0.4623677433), FRAC_CONST(0.8866882324) } }, - { { FRAC_CONST(0.2181432247), FRAC_CONST(0.9759167433) }, { FRAC_CONST(-0.7071067691), FRAC_CONST(0.7071067691) }, { FRAC_CONST(0.4623677433), FRAC_CONST(0.8866882324) } }, - { { FRAC_CONST(0.2181432247), FRAC_CONST(0.9759167433) }, { FRAC_CONST(-0.7071067691), FRAC_CONST(0.7071067691) }, { FRAC_CONST(0.4623677433), FRAC_CONST(0.8866882324) } }, - { { FRAC_CONST(0.2181432247), FRAC_CONST(0.9759167433) }, { FRAC_CONST(-0.7071067691), FRAC_CONST(0.7071067691) }, { FRAC_CONST(0.4623677433), FRAC_CONST(0.8866882324) } }, - { { FRAC_CONST(-0.9048270583), FRAC_CONST(0.4257792532) }, { FRAC_CONST(-0.0000000000), FRAC_CONST(-1.0000000000) }, { FRAC_CONST(-0.5724321604), FRAC_CONST(0.8199520707) } }, - { { FRAC_CONST(-0.9048270583), FRAC_CONST(0.4257792532) }, { FRAC_CONST(-0.0000000000), FRAC_CONST(-1.0000000000) }, { FRAC_CONST(-0.5724321604), FRAC_CONST(0.8199520707) } }, - { { FRAC_CONST(-0.6129069924), FRAC_CONST(-0.7901550531) }, { FRAC_CONST(0.7071067691), FRAC_CONST(0.7071067691) }, { FRAC_CONST(-0.9917160273), FRAC_CONST(-0.1284494549) } }, - { { FRAC_CONST(0.2181432247), FRAC_CONST(0.9759167433) }, { FRAC_CONST(-0.7071067691), FRAC_CONST(0.7071067691) }, { FRAC_CONST(0.4623677433), FRAC_CONST(0.8866882324) } }, - { { FRAC_CONST(0.6374240518), FRAC_CONST(-0.7705131769) }, { FRAC_CONST(-1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(-0.3446428776), FRAC_CONST(-0.9387338758) } }, - { { FRAC_CONST(-0.9048270583), FRAC_CONST(0.4257792532) }, { FRAC_CONST(-0.0000000000), FRAC_CONST(-1.0000000000) }, { FRAC_CONST(-0.5724321604), FRAC_CONST(0.8199520707) } }, - { { FRAC_CONST(-0.6129069924), FRAC_CONST(-0.7901550531) }, { FRAC_CONST(0.7071067691), FRAC_CONST(0.7071067691) }, { FRAC_CONST(-0.9917160273), FRAC_CONST(-0.1284494549) } }, - { { FRAC_CONST(-0.6129069924), FRAC_CONST(-0.7901550531) }, { FRAC_CONST(0.7071067691), FRAC_CONST(0.7071067691) }, { FRAC_CONST(-0.9917160273), FRAC_CONST(-0.1284494549) } }, - { { FRAC_CONST(0.6374240518), FRAC_CONST(-0.7705131769) }, { FRAC_CONST(-1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(-0.3446428776), FRAC_CONST(-0.9387338758) } }, - { { FRAC_CONST(0.6374240518), FRAC_CONST(-0.7705131769) }, { FRAC_CONST(-1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(-0.3446428776), FRAC_CONST(-0.9387338758) } }, - { { FRAC_CONST(0.8910064697), FRAC_CONST(0.4539906085) }, { FRAC_CONST(0.7071067691), FRAC_CONST(-0.7071067691) }, { FRAC_CONST(0.6730125546), FRAC_CONST(-0.7396310568) } }, - { { FRAC_CONST(-0.6129069924), FRAC_CONST(-0.7901550531) }, { FRAC_CONST(0.7071067691), FRAC_CONST(0.7071067691) }, { FRAC_CONST(-0.9917160273), FRAC_CONST(-0.1284494549) } } -}; - -#if 0 -static float quant_rho[8] = -{ - FRAC_CONST(1.0), FRAC_CONST(0.937), FRAC_CONST(0.84118), FRAC_CONST(0.60092), - FRAC_CONST(0.36764), FRAC_CONST(0.0), FRAC_CONST(-0.589), FRAC_CONST(-1.0) -}; - -static const uint8_t quant_iid_normal[7] = -{ - 2, 4, 7, 10, 14, 18, 25 -}; - -static const uint8_t quant_iid_fine[15] = -{ - 2, 4, 6, 8, 10, 13, 16, 19, 22, 25, 30, 35, 40, 45, 50 -}; -#endif - -static const real_t cos_alphas[] = { - COEF_CONST(1.0000000000), COEF_CONST(0.9841239700), COEF_CONST(0.9594738210), - COEF_CONST(0.8946843079), COEF_CONST(0.8269340931), COEF_CONST(0.7071067812), - COEF_CONST(0.4533210856), COEF_CONST(0.0000000000) -}; - -static const real_t sin_alphas[] = { - COEF_CONST(0.0000000000), COEF_CONST(0.1774824264), COEF_CONST(0.2817977763), - COEF_CONST(0.4466989918), COEF_CONST(0.5622988580), COEF_CONST(0.7071067812), - COEF_CONST(0.8913472911), COEF_CONST(1.0000000000) -}; - -static const real_t cos_betas_normal[][8] = { - { COEF_CONST(1.0000000000), COEF_CONST(1.0000000000), COEF_CONST(1.0000000000), COEF_CONST(1.0000000000), COEF_CONST(1.0000000000), COEF_CONST(1.0000000000), COEF_CONST(1.0000000000), COEF_CONST(1.0000000000) }, - { COEF_CONST(1.0000000000), COEF_CONST(0.9995871699), COEF_CONST(0.9989419133), COEF_CONST(0.9972204583), COEF_CONST(0.9953790839), COEF_CONST(0.9920112747), COEF_CONST(0.9843408180), COEF_CONST(0.9681727381) }, - { COEF_CONST(1.0000000000), COEF_CONST(0.9984497744), COEF_CONST(0.9960279377), COEF_CONST(0.9895738413), COEF_CONST(0.9826814632), COEF_CONST(0.9701058164), COEF_CONST(0.9416098832), COEF_CONST(0.8822105900) }, - { COEF_CONST(1.0000000000), COEF_CONST(0.9959398908), COEF_CONST(0.9896038018), COEF_CONST(0.9727589768), COEF_CONST(0.9548355329), COEF_CONST(0.9223070404), COEF_CONST(0.8494349490), COEF_CONST(0.7013005535) }, - { COEF_CONST(1.0000000000), COEF_CONST(0.9932417400), COEF_CONST(0.9827071856), COEF_CONST(0.9547730996), COEF_CONST(0.9251668930), COEF_CONST(0.8717461589), COEF_CONST(0.7535520592), COEF_CONST(0.5198827312) }, - { COEF_CONST(1.0000000000), COEF_CONST(0.9902068095), COEF_CONST(0.9749613872), COEF_CONST(0.9346538534), COEF_CONST(0.8921231300), COEF_CONST(0.8158851259), COEF_CONST(0.6495964302), COEF_CONST(0.3313370772) }, - { COEF_CONST(1.0000000000), COEF_CONST(0.9880510933), COEF_CONST(0.9694670261), COEF_CONST(0.9204347876), COEF_CONST(0.8688622825), COEF_CONST(0.7768516704), COEF_CONST(0.5782161800), COEF_CONST(0.2069970356) }, - { COEF_CONST(1.0000000000), COEF_CONST(0.9858996945), COEF_CONST(0.9639898866), COEF_CONST(0.9063034786), COEF_CONST(0.8458214608), COEF_CONST(0.7384262300), COEF_CONST(0.5089811277), COEF_CONST(0.0905465944) } -}; - -static const real_t sin_betas_normal[][8] = { - { COEF_CONST(0.0000000000), COEF_CONST(0.0000000000), COEF_CONST(0.0000000000), COEF_CONST(0.0000000000), COEF_CONST(0.0000000000), COEF_CONST(0.0000000000), COEF_CONST(0.0000000000), COEF_CONST(0.0000000000) }, - { COEF_CONST(0.0000000000), COEF_CONST(-0.0287313368), COEF_CONST(-0.0459897147), COEF_CONST(-0.0745074328), COEF_CONST(-0.0960233266), COEF_CONST(-0.1261492408), COEF_CONST(-0.1762757894), COEF_CONST(-0.2502829383) }, - { COEF_CONST(0.0000000000), COEF_CONST(-0.0556601118), COEF_CONST(-0.0890412670), COEF_CONST(-0.1440264301), COEF_CONST(-0.1853028382), COEF_CONST(-0.2426823129), COEF_CONST(-0.3367058477), COEF_CONST(-0.4708550466) }, - { COEF_CONST(0.0000000000), COEF_CONST(-0.0900207420), COEF_CONST(-0.1438204281), COEF_CONST(-0.2318188366), COEF_CONST(-0.2971348264), COEF_CONST(-0.3864579191), COEF_CONST(-0.5276933461), COEF_CONST(-0.7128657193) }, - { COEF_CONST(0.0000000000), COEF_CONST(-0.1160639735), COEF_CONST(-0.1851663774), COEF_CONST(-0.2973353800), COEF_CONST(-0.3795605619), COEF_CONST(-0.4899577884), COEF_CONST(-0.6573882369), COEF_CONST(-0.8542376401) }, - { COEF_CONST(0.0000000000), COEF_CONST(-0.1396082894), COEF_CONST(-0.2223742196), COEF_CONST(-0.3555589603), COEF_CONST(-0.4517923427), COEF_CONST(-0.5782140273), COEF_CONST(-0.7602792104), COEF_CONST(-0.9435124489) }, - { COEF_CONST(0.0000000000), COEF_CONST(-0.1541266914), COEF_CONST(-0.2452217065), COEF_CONST(-0.3908961522), COEF_CONST(-0.4950538699), COEF_CONST(-0.6296836366), COEF_CONST(-0.8158836002), COEF_CONST(-0.9783415698) }, - { COEF_CONST(0.0000000000), COEF_CONST(-0.1673373610), COEF_CONST(-0.2659389001), COEF_CONST(-0.4226275012), COEF_CONST(-0.5334660781), COEF_CONST(-0.6743342664), COEF_CONST(-0.8607776784), COEF_CONST(-0.9958922202) } -}; - -static const real_t cos_betas_fine[][8] = { - { COEF_CONST(1.0000000000), COEF_CONST(1.0000000000), COEF_CONST(1.0000000000), COEF_CONST(1.0000000000), COEF_CONST(1.0000000000), COEF_CONST(1.0000000000), COEF_CONST(1.0000000000), COEF_CONST(1.0000000000) }, - { COEF_CONST(1.0000000000), COEF_CONST(0.9995871699), COEF_CONST(0.9989419133), COEF_CONST(0.9972204583), COEF_CONST(0.9953790839), COEF_CONST(0.9920112747), COEF_CONST(0.9843408180), COEF_CONST(0.9681727381) }, - { COEF_CONST(1.0000000000), COEF_CONST(0.9984497744), COEF_CONST(0.9960279377), COEF_CONST(0.9895738413), COEF_CONST(0.9826814632), COEF_CONST(0.9701058164), COEF_CONST(0.9416098832), COEF_CONST(0.8822105900) }, - { COEF_CONST(1.0000000000), COEF_CONST(0.9968361371), COEF_CONST(0.9918968104), COEF_CONST(0.9787540479), COEF_CONST(0.9647515190), COEF_CONST(0.9392903010), COEF_CONST(0.8820167114), COEF_CONST(0.7645325390) }, - { COEF_CONST(1.0000000000), COEF_CONST(0.9950262915), COEF_CONST(0.9872675041), COEF_CONST(0.9666584578), COEF_CONST(0.9447588606), COEF_CONST(0.9050918405), COEF_CONST(0.8165997379), COEF_CONST(0.6383824796) }, - { COEF_CONST(1.0000000000), COEF_CONST(0.9932417400), COEF_CONST(0.9827071856), COEF_CONST(0.9547730996), COEF_CONST(0.9251668930), COEF_CONST(0.8717461589), COEF_CONST(0.7535520592), COEF_CONST(0.5198827312) }, - { COEF_CONST(1.0000000000), COEF_CONST(0.9908827998), COEF_CONST(0.9766855904), COEF_CONST(0.9391249214), COEF_CONST(0.8994531782), COEF_CONST(0.8282352693), COEF_CONST(0.6723983174), COEF_CONST(0.3719473225) }, - { COEF_CONST(1.0000000000), COEF_CONST(0.9890240165), COEF_CONST(0.9719459866), COEF_CONST(0.9268448110), COEF_CONST(0.8793388536), COEF_CONST(0.7944023271), COEF_CONST(0.6101812098), COEF_CONST(0.2621501145) }, - { COEF_CONST(1.0000000000), COEF_CONST(0.9876350461), COEF_CONST(0.9684073447), COEF_CONST(0.9176973944), COEF_CONST(0.8643930070), COEF_CONST(0.7693796058), COEF_CONST(0.5646720713), COEF_CONST(0.1838899556) }, - { COEF_CONST(1.0000000000), COEF_CONST(0.9866247085), COEF_CONST(0.9658349704), COEF_CONST(0.9110590761), COEF_CONST(0.8535668048), COEF_CONST(0.7513165426), COEF_CONST(0.5320914819), COEF_CONST(0.1289530943) }, - { COEF_CONST(1.0000000000), COEF_CONST(0.9858996945), COEF_CONST(0.9639898866), COEF_CONST(0.9063034786), COEF_CONST(0.8458214608), COEF_CONST(0.7384262300), COEF_CONST(0.5089811277), COEF_CONST(0.0905465944) }, - { COEF_CONST(1.0000000000), COEF_CONST(0.9851245614), COEF_CONST(0.9620180268), COEF_CONST(0.9012265590), COEF_CONST(0.8375623272), COEF_CONST(0.7247108045), COEF_CONST(0.4845204297), COEF_CONST(0.0504115003) }, - { COEF_CONST(1.0000000000), COEF_CONST(0.9846869856), COEF_CONST(0.9609052357), COEF_CONST(0.8983639533), COEF_CONST(0.8329098386), COEF_CONST(0.7169983441), COEF_CONST(0.4708245354), COEF_CONST(0.0281732509) }, - { COEF_CONST(1.0000000000), COEF_CONST(0.9844406325), COEF_CONST(0.9602788522), COEF_CONST(0.8967533934), COEF_CONST(0.8302936455), COEF_CONST(0.7126658102), COEF_CONST(0.4631492839), COEF_CONST(0.0157851140) }, - { COEF_CONST(1.0000000000), COEF_CONST(0.9843020502), COEF_CONST(0.9599265269), COEF_CONST(0.8958477331), COEF_CONST(0.8288229094), COEF_CONST(0.7102315840), COEF_CONST(0.4588429315), COEF_CONST(0.0088578059) }, - { COEF_CONST(1.0000000000), COEF_CONST(0.9842241136), COEF_CONST(0.9597283916), COEF_CONST(0.8953385094), COEF_CONST(0.8279961409), COEF_CONST(0.7088635748), COEF_CONST(0.4564246834), COEF_CONST(0.0049751355) } -}; - -static const real_t sin_betas_fine[][8] = { - { COEF_CONST(0.0000000000), COEF_CONST(0.0000000000), COEF_CONST(0.0000000000), COEF_CONST(0.0000000000), COEF_CONST(0.0000000000), COEF_CONST(0.0000000000), COEF_CONST(0.0000000000), COEF_CONST(0.0000000000) }, - { COEF_CONST(0.0000000000), COEF_CONST(-0.0287313368), COEF_CONST(-0.0459897147), COEF_CONST(-0.0745074328), COEF_CONST(-0.0960233266), COEF_CONST(-0.1261492408), COEF_CONST(-0.1762757894), COEF_CONST(-0.2502829383) }, - { COEF_CONST(0.0000000000), COEF_CONST(-0.0556601118), COEF_CONST(-0.0890412670), COEF_CONST(-0.1440264301), COEF_CONST(-0.1853028382), COEF_CONST(-0.2426823129), COEF_CONST(-0.3367058477), COEF_CONST(-0.4708550466) }, - { COEF_CONST(0.0000000000), COEF_CONST(-0.0794840594), COEF_CONST(-0.1270461238), COEF_CONST(-0.2050378347), COEF_CONST(-0.2631625097), COEF_CONST(-0.3431234916), COEF_CONST(-0.4712181245), COEF_CONST(-0.6445851354) }, - { COEF_CONST(0.0000000000), COEF_CONST(-0.0996126459), COEF_CONST(-0.1590687758), COEF_CONST(-0.2560691819), COEF_CONST(-0.3277662204), COEF_CONST(-0.4252161335), COEF_CONST(-0.5772043556), COEF_CONST(-0.7697193058) }, - { COEF_CONST(0.0000000000), COEF_CONST(-0.1160639735), COEF_CONST(-0.1851663774), COEF_CONST(-0.2973353800), COEF_CONST(-0.3795605619), COEF_CONST(-0.4899577884), COEF_CONST(-0.6573882369), COEF_CONST(-0.8542376401) }, - { COEF_CONST(0.0000000000), COEF_CONST(-0.1347266752), COEF_CONST(-0.2146747714), COEF_CONST(-0.3435758752), COEF_CONST(-0.4370171396), COEF_CONST(-0.5603805303), COEF_CONST(-0.7401895046), COEF_CONST(-0.9282538388) }, - { COEF_CONST(0.0000000000), COEF_CONST(-0.1477548470), COEF_CONST(-0.2352041647), COEF_CONST(-0.3754446647), COEF_CONST(-0.4761965776), COEF_CONST(-0.6073919186), COEF_CONST(-0.7922618830), COEF_CONST(-0.9650271071) }, - { COEF_CONST(0.0000000000), COEF_CONST(-0.1567705832), COEF_CONST(-0.2493736450), COEF_CONST(-0.3972801182), COEF_CONST(-0.5028167951), COEF_CONST(-0.6387918458), COEF_CONST(-0.8253153651), COEF_CONST(-0.9829468369) }, - { COEF_CONST(0.0000000000), COEF_CONST(-0.1630082348), COEF_CONST(-0.2591578860), COEF_CONST(-0.4122758299), COEF_CONST(-0.5209834064), COEF_CONST(-0.6599420072), COEF_CONST(-0.8466868694), COEF_CONST(-0.9916506943) }, - { COEF_CONST(0.0000000000), COEF_CONST(-0.1673373610), COEF_CONST(-0.2659389001), COEF_CONST(-0.4226275012), COEF_CONST(-0.5334660781), COEF_CONST(-0.6743342664), COEF_CONST(-0.8607776784), COEF_CONST(-0.9958922202) }, - { COEF_CONST(0.0000000000), COEF_CONST(-0.1718417832), COEF_CONST(-0.2729859267), COEF_CONST(-0.4333482310), COEF_CONST(-0.5463417868), COEF_CONST(-0.6890531546), COEF_CONST(-0.8747799456), COEF_CONST(-0.9987285320) }, - { COEF_CONST(0.0000000000), COEF_CONST(-0.1743316967), COEF_CONST(-0.2768774604), COEF_CONST(-0.4392518725), COEF_CONST(-0.5534087104), COEF_CONST(-0.6970748701), COEF_CONST(-0.8822268738), COEF_CONST(-0.9996030552) }, - { COEF_CONST(0.0000000000), COEF_CONST(-0.1757175038), COEF_CONST(-0.2790421580), COEF_CONST(-0.4425306221), COEF_CONST(-0.5573261722), COEF_CONST(-0.7015037013), COEF_CONST(-0.8862802834), COEF_CONST(-0.9998754073) }, - { COEF_CONST(0.0000000000), COEF_CONST(-0.1764921355), COEF_CONST(-0.2802517850), COEF_CONST(-0.4443611583), COEF_CONST(-0.5595110229), COEF_CONST(-0.7039681080), COEF_CONST(-0.8885173967), COEF_CONST(-0.9999607689) }, - { COEF_CONST(0.0000000000), COEF_CONST(-0.1769262394), COEF_CONST(-0.2809295540), COEF_CONST(-0.4453862969), COEF_CONST(-0.5607337966), COEF_CONST(-0.7053456119), COEF_CONST(-0.8897620516), COEF_CONST(-0.9999876239) } -}; - -static const real_t sincos_alphas_B_normal[][8] = { - { COEF_CONST(0.0561454100), COEF_CONST(0.0526385859), COEF_CONST(0.0472937334), COEF_CONST(0.0338410641), COEF_CONST(0.0207261065), COEF_CONST(0.0028205635), COEF_CONST(0.0028205635), COEF_CONST(0.0028205635) }, - { COEF_CONST(0.1249065138), COEF_CONST(0.1173697697), COEF_CONST(0.1057888284), COEF_CONST(0.0761985131), COEF_CONST(0.0468732723), COEF_CONST(0.0063956103), COEF_CONST(0.0063956103), COEF_CONST(0.0063956103) }, - { COEF_CONST(0.1956693050), COEF_CONST(0.1846090179), COEF_CONST(0.1673645109), COEF_CONST(0.1220621836), COEF_CONST(0.0757362479), COEF_CONST(0.0103882630), COEF_CONST(0.0103882630), COEF_CONST(0.0103882630) }, - { COEF_CONST(0.3015113269), COEF_CONST(0.2870525790), COEF_CONST(0.2637738799), COEF_CONST(0.1984573949), COEF_CONST(0.1260749909), COEF_CONST(0.0175600126), COEF_CONST(0.0175600126), COEF_CONST(0.0175600126) }, - { COEF_CONST(0.4078449476), COEF_CONST(0.3929852420), COEF_CONST(0.3680589270), COEF_CONST(0.2911029124), COEF_CONST(0.1934512363), COEF_CONST(0.0278686716), COEF_CONST(0.0278686716), COEF_CONST(0.0278686716) }, - { COEF_CONST(0.5336171261), COEF_CONST(0.5226637762), COEF_CONST(0.5033652606), COEF_CONST(0.4349162672), COEF_CONST(0.3224682122), COEF_CONST(0.0521999036), COEF_CONST(0.0521999036), COEF_CONST(0.0521999036) }, - { COEF_CONST(0.6219832023), COEF_CONST(0.6161847276), COEF_CONST(0.6057251063), COEF_CONST(0.5654342668), COEF_CONST(0.4826149915), COEF_CONST(0.1058044758), COEF_CONST(0.1058044758), COEF_CONST(0.1058044758) }, - { COEF_CONST(0.7071067657), COEF_CONST(0.7071067657), COEF_CONST(0.7071067657), COEF_CONST(0.7071067657), COEF_CONST(0.7071067657), COEF_CONST(0.7071067657), COEF_CONST(0.7071067657), COEF_CONST(0.7071067657) }, - { COEF_CONST(0.7830305572), COEF_CONST(0.7876016373), COEF_CONST(0.7956739618), COEF_CONST(0.8247933372), COEF_CONST(0.8758325942), COEF_CONST(0.9943869542), COEF_CONST(0.9943869542), COEF_CONST(0.9943869542) }, - { COEF_CONST(0.8457261833), COEF_CONST(0.8525388778), COEF_CONST(0.8640737401), COEF_CONST(0.9004708933), COEF_CONST(0.9465802987), COEF_CONST(0.9986366532), COEF_CONST(0.9986366532), COEF_CONST(0.9986366532) }, - { COEF_CONST(0.9130511848), COEF_CONST(0.9195447612), COEF_CONST(0.9298024282), COEF_CONST(0.9566917233), COEF_CONST(0.9811098801), COEF_CONST(0.9996115928), COEF_CONST(0.9996115928), COEF_CONST(0.9996115928) }, - { COEF_CONST(0.9534625907), COEF_CONST(0.9579148236), COEF_CONST(0.9645845234), COEF_CONST(0.9801095128), COEF_CONST(0.9920207064), COEF_CONST(0.9998458099), COEF_CONST(0.9998458099), COEF_CONST(0.9998458099) }, - { COEF_CONST(0.9806699215), COEF_CONST(0.9828120260), COEF_CONST(0.9858950861), COEF_CONST(0.9925224431), COEF_CONST(0.9971278825), COEF_CONST(0.9999460406), COEF_CONST(0.9999460406), COEF_CONST(0.9999460406) }, - { COEF_CONST(0.9921685024), COEF_CONST(0.9930882705), COEF_CONST(0.9943886135), COEF_CONST(0.9970926648), COEF_CONST(0.9989008403), COEF_CONST(0.9999795479), COEF_CONST(0.9999795479), COEF_CONST(0.9999795479) }, - { COEF_CONST(0.9984226014), COEF_CONST(0.9986136287), COEF_CONST(0.9988810254), COEF_CONST(0.9994272242), COEF_CONST(0.9997851906), COEF_CONST(0.9999960221), COEF_CONST(0.9999960221), COEF_CONST(0.9999960221) } -}; - -static const real_t sincos_alphas_B_fine[][8] = { - { COEF_CONST(0.0031622158), COEF_CONST(0.0029630181), COEF_CONST(0.0026599892), COEF_CONST(0.0019002704), COEF_CONST(0.0011626042), COEF_CONST(0.0001580278), COEF_CONST(0.0001580278), COEF_CONST(0.0001580278) }, - { COEF_CONST(0.0056232673), COEF_CONST(0.0052689825), COEF_CONST(0.0047302825), COEF_CONST(0.0033791756), COEF_CONST(0.0020674015), COEF_CONST(0.0002811710), COEF_CONST(0.0002811710), COEF_CONST(0.0002811710) }, - { COEF_CONST(0.0099994225), COEF_CONST(0.0093696693), COEF_CONST(0.0084117414), COEF_CONST(0.0060093796), COEF_CONST(0.0036766009), COEF_CONST(0.0005000392), COEF_CONST(0.0005000392), COEF_CONST(0.0005000392) }, - { COEF_CONST(0.0177799194), COEF_CONST(0.0166607102), COEF_CONST(0.0149581377), COEF_CONST(0.0106875809), COEF_CONST(0.0065392545), COEF_CONST(0.0008893767), COEF_CONST(0.0008893767), COEF_CONST(0.0008893767) }, - { COEF_CONST(0.0316069684), COEF_CONST(0.0296211579), COEF_CONST(0.0265987295), COEF_CONST(0.0190113813), COEF_CONST(0.0116349973), COEF_CONST(0.0015826974), COEF_CONST(0.0015826974), COEF_CONST(0.0015826974) }, - { COEF_CONST(0.0561454100), COEF_CONST(0.0526385859), COEF_CONST(0.0472937334), COEF_CONST(0.0338410641), COEF_CONST(0.0207261065), COEF_CONST(0.0028205635), COEF_CONST(0.0028205635), COEF_CONST(0.0028205635) }, - { COEF_CONST(0.0791834041), COEF_CONST(0.0742798103), COEF_CONST(0.0667907269), COEF_CONST(0.0478705292), COEF_CONST(0.0293500747), COEF_CONST(0.0039966755), COEF_CONST(0.0039966755), COEF_CONST(0.0039966755) }, - { COEF_CONST(0.1115021177), COEF_CONST(0.1047141985), COEF_CONST(0.0943053154), COEF_CONST(0.0678120561), COEF_CONST(0.0416669150), COEF_CONST(0.0056813213), COEF_CONST(0.0056813213), COEF_CONST(0.0056813213) }, - { COEF_CONST(0.1565355066), COEF_CONST(0.1473258371), COEF_CONST(0.1330924027), COEF_CONST(0.0963282233), COEF_CONST(0.0594509113), COEF_CONST(0.0081277946), COEF_CONST(0.0081277946), COEF_CONST(0.0081277946) }, - { COEF_CONST(0.2184643682), COEF_CONST(0.2064579524), COEF_CONST(0.1876265439), COEF_CONST(0.1375744167), COEF_CONST(0.0856896681), COEF_CONST(0.0117817338), COEF_CONST(0.0117817338), COEF_CONST(0.0117817338) }, - { COEF_CONST(0.3015113269), COEF_CONST(0.2870525790), COEF_CONST(0.2637738799), COEF_CONST(0.1984573949), COEF_CONST(0.1260749909), COEF_CONST(0.0175600126), COEF_CONST(0.0175600126), COEF_CONST(0.0175600126) }, - { COEF_CONST(0.3698741335), COEF_CONST(0.3547727297), COEF_CONST(0.3298252076), COEF_CONST(0.2556265829), COEF_CONST(0.1665990017), COEF_CONST(0.0236344541), COEF_CONST(0.0236344541), COEF_CONST(0.0236344541) }, - { COEF_CONST(0.4480623975), COEF_CONST(0.4339410024), COEF_CONST(0.4098613774), COEF_CONST(0.3322709108), COEF_CONST(0.2266784729), COEF_CONST(0.0334094131), COEF_CONST(0.0334094131), COEF_CONST(0.0334094131) }, - { COEF_CONST(0.5336171261), COEF_CONST(0.5226637762), COEF_CONST(0.5033652606), COEF_CONST(0.4349162672), COEF_CONST(0.3224682122), COEF_CONST(0.0521999036), COEF_CONST(0.0521999036), COEF_CONST(0.0521999036) }, - { COEF_CONST(0.6219832023), COEF_CONST(0.6161847276), COEF_CONST(0.6057251063), COEF_CONST(0.5654342668), COEF_CONST(0.4826149915), COEF_CONST(0.1058044758), COEF_CONST(0.1058044758), COEF_CONST(0.1058044758) }, - { COEF_CONST(0.7071067657), COEF_CONST(0.7071067657), COEF_CONST(0.7071067657), COEF_CONST(0.7071067657), COEF_CONST(0.7071067657), COEF_CONST(0.7071067657), COEF_CONST(0.7071067657), COEF_CONST(0.7071067657) }, - { COEF_CONST(0.7830305572), COEF_CONST(0.7876016373), COEF_CONST(0.7956739618), COEF_CONST(0.8247933372), COEF_CONST(0.8758325942), COEF_CONST(0.9943869542), COEF_CONST(0.9943869542), COEF_CONST(0.9943869542) }, - { COEF_CONST(0.8457261833), COEF_CONST(0.8525388778), COEF_CONST(0.8640737401), COEF_CONST(0.9004708933), COEF_CONST(0.9465802987), COEF_CONST(0.9986366532), COEF_CONST(0.9986366532), COEF_CONST(0.9986366532) }, - { COEF_CONST(0.8940022267), COEF_CONST(0.9009412572), COEF_CONST(0.9121477564), COEF_CONST(0.9431839770), COEF_CONST(0.9739696219), COEF_CONST(0.9994417480), COEF_CONST(0.9994417480), COEF_CONST(0.9994417480) }, - { COEF_CONST(0.9290818561), COEF_CONST(0.9349525662), COEF_CONST(0.9440420138), COEF_CONST(0.9667755833), COEF_CONST(0.9860247275), COEF_CONST(0.9997206664), COEF_CONST(0.9997206664), COEF_CONST(0.9997206664) }, - { COEF_CONST(0.9534625907), COEF_CONST(0.9579148236), COEF_CONST(0.9645845234), COEF_CONST(0.9801095128), COEF_CONST(0.9920207064), COEF_CONST(0.9998458099), COEF_CONST(0.9998458099), COEF_CONST(0.9998458099) }, - { COEF_CONST(0.9758449068), COEF_CONST(0.9784554646), COEF_CONST(0.9822404252), COEF_CONST(0.9904914275), COEF_CONST(0.9963218730), COEF_CONST(0.9999305926), COEF_CONST(0.9999305926), COEF_CONST(0.9999305926) }, - { COEF_CONST(0.9876723320), COEF_CONST(0.9890880155), COEF_CONST(0.9911036356), COEF_CONST(0.9953496173), COEF_CONST(0.9982312259), COEF_CONST(0.9999669685), COEF_CONST(0.9999669685), COEF_CONST(0.9999669685) }, - { COEF_CONST(0.9937641889), COEF_CONST(0.9945023501), COEF_CONST(0.9955433130), COEF_CONST(0.9976981117), COEF_CONST(0.9991315558), COEF_CONST(0.9999838610), COEF_CONST(0.9999838610), COEF_CONST(0.9999838610) }, - { COEF_CONST(0.9968600642), COEF_CONST(0.9972374385), COEF_CONST(0.9977670024), COEF_CONST(0.9988535464), COEF_CONST(0.9995691924), COEF_CONST(0.9999920129), COEF_CONST(0.9999920129), COEF_CONST(0.9999920129) }, - { COEF_CONST(0.9984226014), COEF_CONST(0.9986136287), COEF_CONST(0.9988810254), COEF_CONST(0.9994272242), COEF_CONST(0.9997851906), COEF_CONST(0.9999960221), COEF_CONST(0.9999960221), COEF_CONST(0.9999960221) }, - { COEF_CONST(0.9995003746), COEF_CONST(0.9995611974), COEF_CONST(0.9996461891), COEF_CONST(0.9998192657), COEF_CONST(0.9999323103), COEF_CONST(0.9999987475), COEF_CONST(0.9999987475), COEF_CONST(0.9999987475) }, - { COEF_CONST(0.9998419236), COEF_CONST(0.9998611991), COEF_CONST(0.9998881193), COEF_CONST(0.9999428861), COEF_CONST(0.9999786185), COEF_CONST(0.9999996045), COEF_CONST(0.9999996045), COEF_CONST(0.9999996045) }, - { COEF_CONST(0.9999500038), COEF_CONST(0.9999561034), COEF_CONST(0.9999646206), COEF_CONST(0.9999819429), COEF_CONST(0.9999932409), COEF_CONST(0.9999998750), COEF_CONST(0.9999998750), COEF_CONST(0.9999998750) }, - { COEF_CONST(0.9999841890), COEF_CONST(0.9999861183), COEF_CONST(0.9999888121), COEF_CONST(0.9999942902), COEF_CONST(0.9999978628), COEF_CONST(0.9999999605), COEF_CONST(0.9999999605), COEF_CONST(0.9999999605) }, - { COEF_CONST(0.9999950000), COEF_CONST(0.9999956102), COEF_CONST(0.9999964621), COEF_CONST(0.9999981945), COEF_CONST(0.9999993242), COEF_CONST(0.9999999875), COEF_CONST(0.9999999875), COEF_CONST(0.9999999875) } -}; - -static const real_t cos_gammas_normal[][8] = { - { COEF_CONST(1.0000000000), COEF_CONST(0.9841239707), COEF_CONST(0.9594738226), COEF_CONST(0.8946843024), COEF_CONST(0.8269341029), COEF_CONST(0.7245688486), COEF_CONST(0.7245688486), COEF_CONST(0.7245688486) }, - { COEF_CONST(1.0000000000), COEF_CONST(0.9849690570), COEF_CONST(0.9617776789), COEF_CONST(0.9020941550), COEF_CONST(0.8436830391), COEF_CONST(0.7846832804), COEF_CONST(0.7846832804), COEF_CONST(0.7846832804) }, - { COEF_CONST(1.0000000000), COEF_CONST(0.9871656089), COEF_CONST(0.9676774734), COEF_CONST(0.9199102884), COEF_CONST(0.8785067015), COEF_CONST(0.8464232214), COEF_CONST(0.8464232214), COEF_CONST(0.8464232214) }, - { COEF_CONST(1.0000000000), COEF_CONST(0.9913533967), COEF_CONST(0.9786000177), COEF_CONST(0.9496063381), COEF_CONST(0.9277157252), COEF_CONST(0.9133354077), COEF_CONST(0.9133354077), COEF_CONST(0.9133354077) }, - { COEF_CONST(1.0000000000), COEF_CONST(0.9948924435), COEF_CONST(0.9875319180), COEF_CONST(0.9716329849), COEF_CONST(0.9604805241), COEF_CONST(0.9535949574), COEF_CONST(0.9535949574), COEF_CONST(0.9535949574) }, - { COEF_CONST(1.0000000000), COEF_CONST(0.9977406278), COEF_CONST(0.9945423840), COEF_CONST(0.9878736667), COEF_CONST(0.9833980494), COEF_CONST(0.9807207440), COEF_CONST(0.9807207440), COEF_CONST(0.9807207440) }, - { COEF_CONST(1.0000000000), COEF_CONST(0.9990607067), COEF_CONST(0.9977417734), COEF_CONST(0.9950323970), COEF_CONST(0.9932453273), COEF_CONST(0.9921884740), COEF_CONST(0.9921884740), COEF_CONST(0.9921884740) }, - { COEF_CONST(1.0000000000), COEF_CONST(0.9998081748), COEF_CONST(0.9995400312), COEF_CONST(0.9989936459), COEF_CONST(0.9986365356), COEF_CONST(0.9984265591), COEF_CONST(0.9984265591), COEF_CONST(0.9984265591) } -}; - -static const real_t cos_gammas_fine[][8] = { - { COEF_CONST(1.0000000000), COEF_CONST(0.9841239707), COEF_CONST(0.9594738226), COEF_CONST(0.8946843024), COEF_CONST(0.8269341029), COEF_CONST(0.7245688486), COEF_CONST(0.7245688486), COEF_CONST(0.7245688486) }, - { COEF_CONST(1.0000000000), COEF_CONST(0.9849690570), COEF_CONST(0.9617776789), COEF_CONST(0.9020941550), COEF_CONST(0.8436830391), COEF_CONST(0.7846832804), COEF_CONST(0.7846832804), COEF_CONST(0.7846832804) }, - { COEF_CONST(1.0000000000), COEF_CONST(0.9871656089), COEF_CONST(0.9676774734), COEF_CONST(0.9199102884), COEF_CONST(0.8785067015), COEF_CONST(0.8464232214), COEF_CONST(0.8464232214), COEF_CONST(0.8464232214) }, - { COEF_CONST(1.0000000000), COEF_CONST(0.9899597309), COEF_CONST(0.9750098690), COEF_CONST(0.9402333855), COEF_CONST(0.9129698759), COEF_CONST(0.8943765944), COEF_CONST(0.8943765944), COEF_CONST(0.8943765944) }, - { COEF_CONST(1.0000000000), COEF_CONST(0.9926607607), COEF_CONST(0.9819295710), COEF_CONST(0.9580160104), COEF_CONST(0.9404993670), COEF_CONST(0.9293004472), COEF_CONST(0.9293004472), COEF_CONST(0.9293004472) }, - { COEF_CONST(1.0000000000), COEF_CONST(0.9948924435), COEF_CONST(0.9875319180), COEF_CONST(0.9716329849), COEF_CONST(0.9604805241), COEF_CONST(0.9535949574), COEF_CONST(0.9535949574), COEF_CONST(0.9535949574) }, - { COEF_CONST(1.0000000000), COEF_CONST(0.9972074644), COEF_CONST(0.9932414270), COEF_CONST(0.9849197629), COEF_CONST(0.9792926592), COEF_CONST(0.9759092525), COEF_CONST(0.9759092525), COEF_CONST(0.9759092525) }, - { COEF_CONST(1.0000000000), COEF_CONST(0.9985361982), COEF_CONST(0.9964742028), COEF_CONST(0.9922136306), COEF_CONST(0.9893845420), COEF_CONST(0.9877041371), COEF_CONST(0.9877041371), COEF_CONST(0.9877041371) }, - { COEF_CONST(1.0000000000), COEF_CONST(0.9992494366), COEF_CONST(0.9981967170), COEF_CONST(0.9960386625), COEF_CONST(0.9946185834), COEF_CONST(0.9937800239), COEF_CONST(0.9937800239), COEF_CONST(0.9937800239) }, - { COEF_CONST(1.0000000000), COEF_CONST(0.9996194722), COEF_CONST(0.9990869422), COEF_CONST(0.9979996269), COEF_CONST(0.9972873651), COEF_CONST(0.9968679747), COEF_CONST(0.9968679747), COEF_CONST(0.9968679747) }, - { COEF_CONST(1.0000000000), COEF_CONST(0.9998081748), COEF_CONST(0.9995400312), COEF_CONST(0.9989936459), COEF_CONST(0.9986365356), COEF_CONST(0.9984265591), COEF_CONST(0.9984265591), COEF_CONST(0.9984265591) }, - { COEF_CONST(1.0000000000), COEF_CONST(0.9999390971), COEF_CONST(0.9998540271), COEF_CONST(0.9996809352), COEF_CONST(0.9995679735), COEF_CONST(0.9995016284), COEF_CONST(0.9995016284), COEF_CONST(0.9995016284) }, - { COEF_CONST(1.0000000000), COEF_CONST(0.9999807170), COEF_CONST(0.9999537862), COEF_CONST(0.9998990191), COEF_CONST(0.9998632947), COEF_CONST(0.9998423208), COEF_CONST(0.9998423208), COEF_CONST(0.9998423208) }, - { COEF_CONST(1.0000000000), COEF_CONST(0.9999938979), COEF_CONST(0.9999853814), COEF_CONST(0.9999680568), COEF_CONST(0.9999567596), COEF_CONST(0.9999501270), COEF_CONST(0.9999501270), COEF_CONST(0.9999501270) }, - { COEF_CONST(1.0000000000), COEF_CONST(0.9999980703), COEF_CONST(0.9999953731), COEF_CONST(0.9999898968), COEF_CONST(0.9999863277), COEF_CONST(0.9999842265), COEF_CONST(0.9999842265), COEF_CONST(0.9999842265) }, - { COEF_CONST(1.0000000000), COEF_CONST(0.9999993891), COEF_CONST(0.9999985397), COEF_CONST(0.9999968037), COEF_CONST(0.9999956786), COEF_CONST(0.9999950155), COEF_CONST(0.9999950155), COEF_CONST(0.9999950155) } -}; - -static const real_t sin_gammas_normal[][8] = { - { COEF_CONST(0.0000000000), COEF_CONST(0.1774824223), COEF_CONST(0.2817977711), COEF_CONST(0.4466990028), COEF_CONST(0.5622988435), COEF_CONST(0.6892024258), COEF_CONST(0.6892024258), COEF_CONST(0.6892024258) }, - { COEF_CONST(0.0000000000), COEF_CONST(0.1727308798), COEF_CONST(0.2738315110), COEF_CONST(0.4315392630), COEF_CONST(0.5368416242), COEF_CONST(0.6198968861), COEF_CONST(0.6198968861), COEF_CONST(0.6198968861) }, - { COEF_CONST(0.0000000000), COEF_CONST(0.1596999079), COEF_CONST(0.2521910140), COEF_CONST(0.3921288836), COEF_CONST(0.4777300236), COEF_CONST(0.5325107795), COEF_CONST(0.5325107795), COEF_CONST(0.5325107795) }, - { COEF_CONST(0.0000000000), COEF_CONST(0.1312190642), COEF_CONST(0.2057717310), COEF_CONST(0.3134450552), COEF_CONST(0.3732874674), COEF_CONST(0.4072080955), COEF_CONST(0.4072080955), COEF_CONST(0.4072080955) }, - { COEF_CONST(0.0000000000), COEF_CONST(0.1009407043), COEF_CONST(0.1574189028), COEF_CONST(0.2364938532), COEF_CONST(0.2783471983), COEF_CONST(0.3010924396), COEF_CONST(0.3010924396), COEF_CONST(0.3010924396) }, - { COEF_CONST(0.0000000000), COEF_CONST(0.0671836269), COEF_CONST(0.1043333428), COEF_CONST(0.1552598422), COEF_CONST(0.1814615013), COEF_CONST(0.1954144885), COEF_CONST(0.1954144885), COEF_CONST(0.1954144885) }, - { COEF_CONST(0.0000000000), COEF_CONST(0.0433324862), COEF_CONST(0.0671666110), COEF_CONST(0.0995516398), COEF_CONST(0.1160332699), COEF_CONST(0.1247478739), COEF_CONST(0.1247478739), COEF_CONST(0.1247478739) }, - { COEF_CONST(0.0000000000), COEF_CONST(0.0195860576), COEF_CONST(0.0303269852), COEF_CONST(0.0448519274), COEF_CONST(0.0522022017), COEF_CONST(0.0560750040), COEF_CONST(0.0560750040), COEF_CONST(0.0560750040) } -}; - -static const real_t sin_gammas_fine[][8] = { - { COEF_CONST(0.0000000000), COEF_CONST(0.1774824223), COEF_CONST(0.2817977711), COEF_CONST(0.4466990028), COEF_CONST(0.5622988435), COEF_CONST(0.6892024258), COEF_CONST(0.6892024258), COEF_CONST(0.6892024258) }, - { COEF_CONST(0.0000000000), COEF_CONST(0.1727308798), COEF_CONST(0.2738315110), COEF_CONST(0.4315392630), COEF_CONST(0.5368416242), COEF_CONST(0.6198968861), COEF_CONST(0.6198968861), COEF_CONST(0.6198968861) }, - { COEF_CONST(0.0000000000), COEF_CONST(0.1596999079), COEF_CONST(0.2521910140), COEF_CONST(0.3921288836), COEF_CONST(0.4777300236), COEF_CONST(0.5325107795), COEF_CONST(0.5325107795), COEF_CONST(0.5325107795) }, - { COEF_CONST(0.0000000000), COEF_CONST(0.1413496768), COEF_CONST(0.2221615526), COEF_CONST(0.3405307340), COEF_CONST(0.4080269669), COEF_CONST(0.4473147744), COEF_CONST(0.4473147744), COEF_CONST(0.4473147744) }, - { COEF_CONST(0.0000000000), COEF_CONST(0.1209322714), COEF_CONST(0.1892467110), COEF_CONST(0.2867147079), COEF_CONST(0.3397954394), COEF_CONST(0.3693246252), COEF_CONST(0.3693246252), COEF_CONST(0.3693246252) }, - { COEF_CONST(0.0000000000), COEF_CONST(0.1009407043), COEF_CONST(0.1574189028), COEF_CONST(0.2364938532), COEF_CONST(0.2783471983), COEF_CONST(0.3010924396), COEF_CONST(0.3010924396), COEF_CONST(0.3010924396) }, - { COEF_CONST(0.0000000000), COEF_CONST(0.0746811420), COEF_CONST(0.1160666523), COEF_CONST(0.1730117353), COEF_CONST(0.2024497161), COEF_CONST(0.2181768341), COEF_CONST(0.2181768341), COEF_CONST(0.2181768341) }, - { COEF_CONST(0.0000000000), COEF_CONST(0.0540875291), COEF_CONST(0.0838997203), COEF_CONST(0.1245476266), COEF_CONST(0.1453211203), COEF_CONST(0.1563346972), COEF_CONST(0.1563346972), COEF_CONST(0.1563346972) }, - { COEF_CONST(0.0000000000), COEF_CONST(0.0387371058), COEF_CONST(0.0600276114), COEF_CONST(0.0889212171), COEF_CONST(0.1036044086), COEF_CONST(0.1113609634), COEF_CONST(0.1113609634), COEF_CONST(0.1113609634) }, - { COEF_CONST(0.0000000000), COEF_CONST(0.0275846110), COEF_CONST(0.0427233177), COEF_CONST(0.0632198125), COEF_CONST(0.0736064637), COEF_CONST(0.0790837596), COEF_CONST(0.0790837596), COEF_CONST(0.0790837596) }, - { COEF_CONST(0.0000000000), COEF_CONST(0.0195860576), COEF_CONST(0.0303269852), COEF_CONST(0.0448519274), COEF_CONST(0.0522022017), COEF_CONST(0.0560750040), COEF_CONST(0.0560750040), COEF_CONST(0.0560750040) }, - { COEF_CONST(0.0000000000), COEF_CONST(0.0110363955), COEF_CONST(0.0170857974), COEF_CONST(0.0252592108), COEF_CONST(0.0293916021), COEF_CONST(0.0315673054), COEF_CONST(0.0315673054), COEF_CONST(0.0315673054) }, - { COEF_CONST(0.0000000000), COEF_CONST(0.0062101284), COEF_CONST(0.0096138203), COEF_CONST(0.0142109649), COEF_CONST(0.0165345659), COEF_CONST(0.0177576316), COEF_CONST(0.0177576316), COEF_CONST(0.0177576316) }, - { COEF_CONST(0.0000000000), COEF_CONST(0.0034934509), COEF_CONST(0.0054071189), COEF_CONST(0.0079928316), COEF_CONST(0.0092994041), COEF_CONST(0.0099871631), COEF_CONST(0.0099871631), COEF_CONST(0.0099871631) }, - { COEF_CONST(0.0000000000), COEF_CONST(0.0019645397), COEF_CONST(0.0030419905), COEF_CONST(0.0044951511), COEF_CONST(0.0052291853), COEF_CONST(0.0056166498), COEF_CONST(0.0056166498), COEF_CONST(0.0056166498) }, - { COEF_CONST(0.0000000000), COEF_CONST(0.0011053943), COEF_CONST(0.0017089869), COEF_CONST(0.0025283670), COEF_CONST(0.0029398552), COEF_CONST(0.0031573685), COEF_CONST(0.0031573685), COEF_CONST(0.0031573685) } -}; - -static const real_t sf_iid_normal[] = { - COEF_CONST(1.4119827747), COEF_CONST(1.4031381607), COEF_CONST(1.3868767023), - COEF_CONST(1.3483997583), COEF_CONST(1.2912493944), COEF_CONST(1.1960374117), - COEF_CONST(1.1073724031), COEF_CONST(1.0000000000), COEF_CONST(0.8796171546), - COEF_CONST(0.7546485662), COEF_CONST(0.5767799020), COEF_CONST(0.4264014363), - COEF_CONST(0.2767182887), COEF_CONST(0.1766446233), COEF_CONST(0.0794016272) -}; - -static const real_t sf_iid_fine[] = { - COEF_CONST(1.4142065048), COEF_CONST(1.4141912460), COEF_CONST(1.4141428471), - COEF_CONST(1.4139900208), COEF_CONST(1.4135069847), COEF_CONST(1.4119827747), - COEF_CONST(1.4097729921), COEF_CONST(1.4053947926), COEF_CONST(1.3967796564), - COEF_CONST(1.3800530434), COEF_CONST(1.3483997583), COEF_CONST(1.3139201403), - COEF_CONST(1.2643101215), COEF_CONST(1.1960374117), COEF_CONST(1.1073724031), - COEF_CONST(1.0000000000), COEF_CONST(0.8796171546), COEF_CONST(0.7546485662), - COEF_CONST(0.6336560845), COEF_CONST(0.5230810642), COEF_CONST(0.4264014363), - COEF_CONST(0.3089554012), COEF_CONST(0.2213746458), COEF_CONST(0.1576878875), - COEF_CONST(0.1119822487), COEF_CONST(0.0794016272), COEF_CONST(0.0446990170), - COEF_CONST(0.0251446925), COEF_CONST(0.0141414283), COEF_CONST(0.0079525812), - COEF_CONST(0.0044721137) -}; - -#ifdef __cplusplus - -#endif -#endif - diff --git a/apps/codecs/libfaad/pulse.c b/apps/codecs/libfaad/pulse.c deleted file mode 100644 index d75877db70..0000000000 --- a/apps/codecs/libfaad/pulse.c +++ /dev/null @@ -1,56 +0,0 @@ -/* -** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -** -** Any non-GPL usage of this software or parts of this software is strictly -** forbidden. -** -** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. -** -** $Id$ -**/ - -#include "common.h" -#include "structs.h" - -#include "syntax.h" -#include "pulse.h" - -uint8_t pulse_decode(ic_stream *ics, int16_t *spec_data, uint16_t framelen) -{ - uint8_t i; - uint16_t k; - pulse_info *pul = &(ics->pul); - - k = ics->swb_offset[pul->pulse_start_sfb]; - - for (i = 0; i <= pul->number_pulse; i++) - { - k += pul->pulse_offset[i]; - - if (k >= framelen) - return 15; /* should not be possible */ - - if (spec_data[k] > 0) - spec_data[k] += pul->pulse_amp[i]; - else - spec_data[k] -= pul->pulse_amp[i]; - } - - return 0; -} diff --git a/apps/codecs/libfaad/pulse.h b/apps/codecs/libfaad/pulse.h deleted file mode 100644 index 84d7fd38d8..0000000000 --- a/apps/codecs/libfaad/pulse.h +++ /dev/null @@ -1,40 +0,0 @@ -/* -** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -** -** Any non-GPL usage of this software or parts of this software is strictly -** forbidden. -** -** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. -** -** $Id$ -**/ - -#ifndef __PULSE_H__ -#define __PULSE_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -uint8_t pulse_decode(ic_stream *ics, int16_t *spec_coef, uint16_t framelen); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/apps/codecs/libfaad/rvlc.c b/apps/codecs/libfaad/rvlc.c deleted file mode 100644 index 5b17edd06c..0000000000 --- a/apps/codecs/libfaad/rvlc.c +++ /dev/null @@ -1,530 +0,0 @@ -/* -** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -** -** Any non-GPL usage of this software or parts of this software is strictly -** forbidden. -** -** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. -** -** $Id$ -**/ - -/* RVLC scalefactor decoding - * - * RVLC works like this: - * 1. Only symmetric huffman codewords are used - * 2. Total length of the scalefactor data is stored in the bitsream - * 3. Scalefactors are DPCM coded - * 4. Next to the starting value for DPCM the ending value is also stored - * - * With all this it is possible to read the scalefactor data from 2 sides. - * If there is a bit error in the scalefactor data it is possible to start - * decoding from the other end of the data, to find all but 1 scalefactor. - */ - -#include "common.h" -#include "structs.h" - -#include - -#include "syntax.h" -#include "bits.h" -#include "rvlc.h" - - -#ifdef ERROR_RESILIENCE - -//#define PRINT_RVLC - -/* static function declarations */ -static uint8_t rvlc_decode_sf_forward(ic_stream *ics, - bitfile *ld_sf, - bitfile *ld_esc, - uint8_t *is_used); -#if 0 -static uint8_t rvlc_decode_sf_reverse(ic_stream *ics, - bitfile *ld_sf, - bitfile *ld_esc, - uint8_t is_used); -#endif -static int8_t rvlc_huffman_sf(bitfile *ld_sf, bitfile *ld_esc, - int8_t direction); -static int8_t rvlc_huffman_esc(bitfile *ld_esc, int8_t direction); - - -uint8_t rvlc_scale_factor_data(ic_stream *ics, bitfile *ld) -{ - uint8_t bits = 9; - - ics->sf_concealment = faad_get1bit(ld - DEBUGVAR(1,149,"rvlc_scale_factor_data(): sf_concealment")); - ics->rev_global_gain = (uint8_t)faad_getbits(ld, 8 - DEBUGVAR(1,150,"rvlc_scale_factor_data(): rev_global_gain")); - - if (ics->window_sequence == EIGHT_SHORT_SEQUENCE) - bits = 11; - - /* the number of bits used for the huffman codewords */ - ics->length_of_rvlc_sf = (uint16_t)faad_getbits(ld, bits - DEBUGVAR(1,151,"rvlc_scale_factor_data(): length_of_rvlc_sf")); - - if (ics->noise_used) - { - ics->dpcm_noise_nrg = (uint16_t)faad_getbits(ld, 9 - DEBUGVAR(1,152,"rvlc_scale_factor_data(): dpcm_noise_nrg")); - - ics->length_of_rvlc_sf -= 9; - } - - ics->sf_escapes_present = faad_get1bit(ld - DEBUGVAR(1,153,"rvlc_scale_factor_data(): sf_escapes_present")); - - if (ics->sf_escapes_present) - { - ics->length_of_rvlc_escapes = (uint8_t)faad_getbits(ld, 8 - DEBUGVAR(1,154,"rvlc_scale_factor_data(): length_of_rvlc_escapes")); - } - - if (ics->noise_used) - { - ics->dpcm_noise_last_position = (uint16_t)faad_getbits(ld, 9 - DEBUGVAR(1,155,"rvlc_scale_factor_data(): dpcm_noise_last_position")); - } - - return 0; -} - -uint8_t rvlc_decode_scale_factors(ic_stream *ics, bitfile *ld) -{ - uint8_t result; - uint8_t intensity_used = 0; - uint8_t *rvlc_sf_buffer = NULL; - uint8_t *rvlc_esc_buffer = NULL; - bitfile ld_rvlc_sf, ld_rvlc_esc; -// bitfile ld_rvlc_sf_rev, ld_rvlc_esc_rev; - - if (ics->length_of_rvlc_sf > 0) - { - /* We read length_of_rvlc_sf bits here to put it in a - seperate bitfile. - */ - rvlc_sf_buffer = faad_getbitbuffer(ld, ics->length_of_rvlc_sf - DEBUGVAR(1,156,"rvlc_decode_scale_factors(): bitbuffer: length_of_rvlc_sf")); - - faad_initbits(&ld_rvlc_sf, (void*)rvlc_sf_buffer, bit2byte(ics->length_of_rvlc_sf)); -// faad_initbits_rev(&ld_rvlc_sf_rev, (void*)rvlc_sf_buffer, -// ics->length_of_rvlc_sf); - } - - if (ics->sf_escapes_present) - { - /* We read length_of_rvlc_escapes bits here to put it in a - seperate bitfile. - */ - rvlc_esc_buffer = faad_getbitbuffer(ld, ics->length_of_rvlc_escapes - DEBUGVAR(1,157,"rvlc_decode_scale_factors(): bitbuffer: length_of_rvlc_escapes")); - - faad_initbits(&ld_rvlc_esc, (void*)rvlc_esc_buffer, bit2byte(ics->length_of_rvlc_escapes)); -// faad_initbits_rev(&ld_rvlc_esc_rev, (void*)rvlc_esc_buffer, -// ics->length_of_rvlc_escapes); - } - - /* decode the rvlc scale factors and escapes */ - result = rvlc_decode_sf_forward(ics, &ld_rvlc_sf, - &ld_rvlc_esc, &intensity_used); -// result = rvlc_decode_sf_reverse(ics, &ld_rvlc_sf_rev, -// &ld_rvlc_esc_rev, intensity_used); - - - if (rvlc_esc_buffer) faad_free(rvlc_esc_buffer); - if (rvlc_sf_buffer) faad_free(rvlc_sf_buffer); - - if (ics->length_of_rvlc_sf > 0) - faad_endbits(&ld_rvlc_sf); - if (ics->sf_escapes_present) - faad_endbits(&ld_rvlc_esc); - - return result; -} - -static uint8_t rvlc_decode_sf_forward(ic_stream *ics, bitfile *ld_sf, bitfile *ld_esc, - uint8_t *intensity_used) -{ - int8_t g, sfb; - int8_t t = 0; - int8_t error = 0; - int8_t noise_pcm_flag = 1; - - int16_t scale_factor = ics->global_gain; - int16_t is_position = 0; - int16_t noise_energy = ics->global_gain - 90 - 256; - -#ifdef PRINT_RVLC - printf("\nglobal_gain: %d\n", ics->global_gain); -#endif - - for (g = 0; g < ics->num_window_groups; g++) - { - for (sfb = 0; sfb < ics->max_sfb; sfb++) - { - if (error) - { - ics->scale_factors[g][sfb] = 0; - } else { - switch (ics->sfb_cb[g][sfb]) - { - case ZERO_HCB: /* zero book */ - ics->scale_factors[g][sfb] = 0; - break; - case INTENSITY_HCB: /* intensity books */ - case INTENSITY_HCB2: - - *intensity_used = 1; - - /* decode intensity position */ - t = rvlc_huffman_sf(ld_sf, ld_esc, +1); - - is_position += t; - ics->scale_factors[g][sfb] = is_position; - - break; - case NOISE_HCB: /* noise books */ - - /* decode noise energy */ - if (noise_pcm_flag) - { - int16_t n = ics->dpcm_noise_nrg; - noise_pcm_flag = 0; - noise_energy += n; - } else { - t = rvlc_huffman_sf(ld_sf, ld_esc, +1); - noise_energy += t; - } - - ics->scale_factors[g][sfb] = noise_energy; - - break; - default: /* spectral books */ - - /* decode scale factor */ - t = rvlc_huffman_sf(ld_sf, ld_esc, +1); - - scale_factor += t; - if (scale_factor < 0) - return 4; - - ics->scale_factors[g][sfb] = scale_factor; - - break; - } -#ifdef PRINT_RVLC - printf("%3d:%4d%4d\n", sfb, ics->sfb_cb[g][sfb], - ics->scale_factors[g][sfb]); -#endif - if (t == 99) - { - error = 1; - } - } - } - } -#ifdef PRINT_RVLC - printf("\n\n"); -#endif - - return 0; -} - -#if 0 // not used right now, doesn't work correctly yet -static uint8_t rvlc_decode_sf_reverse(ic_stream *ics, bitfile *ld_sf, bitfile *ld_esc, - uint8_t intensity_used) -{ - int8_t g, sfb; - int8_t t = 0; - int8_t error = 0; - int8_t noise_pcm_flag = 1, is_pcm_flag = 1, sf_pcm_flag = 1; - - int16_t scale_factor = ics->rev_global_gain; - int16_t is_position = 0; - int16_t noise_energy = ics->rev_global_gain; - -#ifdef PRINT_RVLC - printf("\nrev_global_gain: %d\n", ics->rev_global_gain); -#endif - - if (intensity_used) - { - is_position = rvlc_huffman_sf(ld_sf, ld_esc, -1); -#ifdef PRINT_RVLC - printf("is_position: %d\n", is_position); -#endif - } - - for (g = ics->num_window_groups-1; g >= 0; g--) - { - for (sfb = ics->max_sfb-1; sfb >= 0; sfb--) - { - if (error) - { - ics->scale_factors[g][sfb] = 0; - } else { - switch (ics->sfb_cb[g][sfb]) - { - case ZERO_HCB: /* zero book */ - ics->scale_factors[g][sfb] = 0; - break; - case INTENSITY_HCB: /* intensity books */ - case INTENSITY_HCB2: - - if (is_pcm_flag) - { - is_pcm_flag = 0; - ics->scale_factors[g][sfb] = is_position; - } else { - t = rvlc_huffman_sf(ld_sf, ld_esc, -1); - is_position -= t; - - ics->scale_factors[g][sfb] = (uint8_t)is_position; - } - break; - case NOISE_HCB: /* noise books */ - - /* decode noise energy */ - if (noise_pcm_flag) - { - noise_pcm_flag = 0; - noise_energy = ics->dpcm_noise_last_position; - } else { - t = rvlc_huffman_sf(ld_sf, ld_esc, -1); - noise_energy -= t; - } - - ics->scale_factors[g][sfb] = (uint8_t)noise_energy; - break; - default: /* spectral books */ - - if (sf_pcm_flag || (sfb == 0)) - { - sf_pcm_flag = 0; - if (sfb == 0) - scale_factor = ics->global_gain; - } else { - /* decode scale factor */ - t = rvlc_huffman_sf(ld_sf, ld_esc, -1); - scale_factor -= t; - } - - if (scale_factor < 0) - return 4; - - ics->scale_factors[g][sfb] = (uint8_t)scale_factor; - break; - } -#ifdef PRINT_RVLC - printf("%3d:%4d%4d\n", sfb, ics->sfb_cb[g][sfb], - ics->scale_factors[g][sfb]); -#endif - if (t == 99) - { - error = 1; - } - } - } - } - -#ifdef PRINT_RVLC - printf("\n\n"); -#endif - - return 0; -} -#endif - -/* index == 99 means not allowed codeword */ -static rvlc_huff_table book_rvlc[] = { - /*index length codeword */ - { 0, 1, 0 }, /* 0 */ - { -1, 3, 5 }, /* 101 */ - { 1, 3, 7 }, /* 111 */ - { -2, 4, 9 }, /* 1001 */ - { -3, 5, 17 }, /* 10001 */ - { 2, 5, 27 }, /* 11011 */ - { -4, 6, 33 }, /* 100001 */ - { 99, 6, 50 }, /* 110010 */ - { 3, 6, 51 }, /* 110011 */ - { 99, 6, 52 }, /* 110100 */ - { -7, 7, 65 }, /* 1000001 */ - { 99, 7, 96 }, /* 1100000 */ - { 99, 7, 98 }, /* 1100010 */ - { 7, 7, 99 }, /* 1100011 */ - { 4, 7, 107 }, /* 1101011 */ - { -5, 8, 129 }, /* 10000001 */ - { 99, 8, 194 }, /* 11000010 */ - { 5, 8, 195 }, /* 11000011 */ - { 99, 8, 212 }, /* 11010100 */ - { 99, 9, 256 }, /* 100000000 */ - { -6, 9, 257 }, /* 100000001 */ - { 99, 9, 426 }, /* 110101010 */ - { 6, 9, 427 }, /* 110101011 */ - { 99, 10, 0 } /* Shouldn't come this far */ -}; - -static rvlc_huff_table book_escape[] = { - /*index length codeword */ - { 1, 2, 0 }, - { 0, 2, 2 }, - { 3, 3, 2 }, - { 2, 3, 6 }, - { 4, 4, 14 }, - { 7, 5, 13 }, - { 6, 5, 15 }, - { 5, 5, 31 }, - { 11, 6, 24 }, - { 10, 6, 25 }, - { 9, 6, 29 }, - { 8, 6, 61 }, - { 13, 7, 56 }, - { 12, 7, 120 }, - { 15, 8, 114 }, - { 14, 8, 242 }, - { 17, 9, 230 }, - { 16, 9, 486 }, - { 19, 10, 463 }, - { 18, 10, 974 }, - { 22, 11, 925 }, - { 20, 11, 1950 }, - { 21, 11, 1951 }, - { 23, 12, 1848 }, - { 25, 13, 3698 }, - { 24, 14, 7399 }, - { 26, 15, 14797 }, - { 49, 19, 236736 }, - { 50, 19, 236737 }, - { 51, 19, 236738 }, - { 52, 19, 236739 }, - { 53, 19, 236740 }, - { 27, 20, 473482 }, - { 28, 20, 473483 }, - { 29, 20, 473484 }, - { 30, 20, 473485 }, - { 31, 20, 473486 }, - { 32, 20, 473487 }, - { 33, 20, 473488 }, - { 34, 20, 473489 }, - { 35, 20, 473490 }, - { 36, 20, 473491 }, - { 37, 20, 473492 }, - { 38, 20, 473493 }, - { 39, 20, 473494 }, - { 40, 20, 473495 }, - { 41, 20, 473496 }, - { 42, 20, 473497 }, - { 43, 20, 473498 }, - { 44, 20, 473499 }, - { 45, 20, 473500 }, - { 46, 20, 473501 }, - { 47, 20, 473502 }, - { 48, 20, 473503 }, - { 99, 21, 0 } /* Shouldn't come this far */ -}; - -static int8_t rvlc_huffman_sf(bitfile *ld_sf, bitfile *ld_esc, - int8_t direction) -{ - uint8_t i, j; - int8_t index; - uint32_t cw; - rvlc_huff_table *h = book_rvlc; - - i = h->len; - if (direction > 0) - cw = faad_getbits(ld_sf, i DEBUGVAR(1,0,"")); - else - cw = faad_getbits_rev(ld_sf, i DEBUGVAR(1,0,"")); - - while ((cw != h->cw) - && (i < 10)) - { - h++; - j = h->len-i; - i += j; - cw <<= j; - if (direction > 0) - cw |= faad_getbits(ld_sf, j DEBUGVAR(1,0,"")); - else - cw |= faad_getbits_rev(ld_sf, j DEBUGVAR(1,0,"")); - } - - index = h->index; - - if (index == +ESC_VAL) - { - int8_t esc = rvlc_huffman_esc(ld_esc, direction); - if (esc == 99) - return 99; - index += esc; -#ifdef PRINT_RVLC - printf("esc: %d - ", esc); -#endif - } - if (index == -ESC_VAL) - { - int8_t esc = rvlc_huffman_esc(ld_esc, direction); - if (esc == 99) - return 99; - index -= esc; -#ifdef PRINT_RVLC - printf("esc: %d - ", esc); -#endif - } - - return index; -} - -static int8_t rvlc_huffman_esc(bitfile *ld, - int8_t direction) -{ - uint8_t i, j; - uint32_t cw; - rvlc_huff_table *h = book_escape; - - i = h->len; - if (direction > 0) - cw = faad_getbits(ld, i DEBUGVAR(1,0,"")); - else - cw = faad_getbits_rev(ld, i DEBUGVAR(1,0,"")); - - while ((cw != h->cw) - && (i < 21)) - { - h++; - j = h->len-i; - i += j; - cw <<= j; - if (direction > 0) - cw |= faad_getbits(ld, j DEBUGVAR(1,0,"")); - else - cw |= faad_getbits_rev(ld, j DEBUGVAR(1,0,"")); - } - - return h->index; -} - -#endif - diff --git a/apps/codecs/libfaad/rvlc.h b/apps/codecs/libfaad/rvlc.h deleted file mode 100644 index b17246a452..0000000000 --- a/apps/codecs/libfaad/rvlc.h +++ /dev/null @@ -1,53 +0,0 @@ -/* -** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -** -** Any non-GPL usage of this software or parts of this software is strictly -** forbidden. -** -** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. -** -** $Id$ -**/ - -#ifndef __RVLC_SCF_H__ -#define __RVLC_SCF_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct -{ - int8_t index; - uint8_t len; - uint32_t cw; -} rvlc_huff_table; - - -#define ESC_VAL 7 - - -uint8_t rvlc_scale_factor_data(ic_stream *ics, bitfile *ld); -uint8_t rvlc_decode_scale_factors(ic_stream *ics, bitfile *ld); - - -#ifdef __cplusplus -} -#endif -#endif diff --git a/apps/codecs/libfaad/sbr_dct.c b/apps/codecs/libfaad/sbr_dct.c deleted file mode 100644 index e9c56c3a18..0000000000 --- a/apps/codecs/libfaad/sbr_dct.c +++ /dev/null @@ -1,1990 +0,0 @@ -/* -** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -** -** Any non-GPL usage of this software or parts of this software is strictly -** forbidden. -** -** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. -** -** $Id$ -**/ - -#include "common.h" -#include "../lib/fft.h" -#include "../lib/mdct_lookup.h" - - -#ifdef SBR_DEC - -#ifdef _MSC_VER -#pragma warning(disable:4305) -#pragma warning(disable:4244) -#endif - - -#include "sbr_dct.h" - -void DCT4_32(real_t *y, real_t *x) -{ - real_t f0, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10; - real_t f11, f12, f13, f14, f15, f16, f17, f18, f19, f20; - real_t f21, f22, f23, f24, f25, f26, f27, f28, f29, f30; - real_t f31, f32, f33, f34, f35, f36, f37, f38, f39, f40; - real_t f41, f42, f43, f44, f45, f46, f47, f48, f49, f50; - real_t f51, f52, f53, f54, f55, f56, f57, f58, f59, f60; - real_t f61, f62, f63, f64, f65, f66, f67, f68, f69, f70; - real_t f71, f72, f73, f74, f75, f76, f77, f78, f79, f80; - real_t f81, f82, f83, f84, f85, f86, f87, f88, f89, f90; - real_t f91, f92, f93, f94, f95, f96, f97, f98, f99, f100; - real_t f101, f102, f103, f104, f105, f106, f107, f108, f109, f110; - real_t f111, f112, f113, f114, f115, f116, f117, f118, f119, f120; - real_t f121, f122, f123, f124, f125, f126, f127, f128, f129, f130; - real_t f131, f132, f133, f134, f135, f136, f137, f138, f139, f140; - real_t f141, f142, f143, f144, f145, f146, f147, f148, f149, f150; - real_t f151, f152, f153, f154, f155, f156, f157, f158, f159, f160; - real_t f161, f162, f163, f164, f165, f166, f167, f168, f169, f170; - real_t f171, f172, f173, f174, f175, f176, f177, f178, f179, f180; - real_t f181, f182, f183, f184, f185, f186, f187, f188, f189, f190; - real_t f191, f192, f193, f194, f195, f196, f197, f198, f199, f200; - real_t f201, f202, f203, f204, f205, f206, f207, f208, f209, f210; - real_t f211, f212, f213, f214, f215, f216, f217, f218, f219, f220; - real_t f221, f222, f223, f224, f225, f226, f227, f228, f229, f230; - real_t f231, f232, f233, f234, f235, f236, f237, f238, f239, f240; - real_t f241, f242, f243, f244, f245, f246, f247, f248, f249, f250; - real_t f251, f252, f253, f254, f255, f256, f257, f258, f259, f260; - real_t f261, f262, f263, f264, f265, f266, f267, f268, f269, f270; - real_t f271, f272, f273, f274, f275, f276, f277, f278, f279, f280; - real_t f281, f282, f283, f284, f285, f286, f287, f288, f289, f290; - real_t f291, f292, f293, f294, f295, f296, f297, f298, f299, f300; - real_t f301, f302, f303, f304, f305, f306, f307, f310, f311, f312; - real_t f313, f316, f317, f318, f319, f322, f323, f324, f325, f328; - real_t f329, f330, f331, f334, f335, f336, f337, f340, f341, f342; - real_t f343, f346, f347, f348, f349, f352, f353, f354, f355, f358; - real_t f359, f360, f361, f364, f365, f366, f367, f370, f371, f372; - real_t f373, f376, f377, f378, f379, f382, f383, f384, f385, f388; - real_t f389, f390, f391, f394, f395, f396, f397; - - f0 = x[15] - x[16]; - f1 = x[15] + x[16]; - f2 = MUL_F(FRAC_CONST(0.7071067811865476), f1); - f3 = MUL_F(FRAC_CONST(0.7071067811865476), f0); - f4 = x[8] - x[23]; - f5 = x[8] + x[23]; - f6 = MUL_F(FRAC_CONST(0.7071067811865476), f5); - f7 = MUL_F(FRAC_CONST(0.7071067811865476), f4); - f8 = x[12] - x[19]; - f9 = x[12] + x[19]; - f10 = MUL_F(FRAC_CONST(0.7071067811865476), f9); - f11 = MUL_F(FRAC_CONST(0.7071067811865476), f8); - f12 = x[11] - x[20]; - f13 = x[11] + x[20]; - f14 = MUL_F(FRAC_CONST(0.7071067811865476), f13); - f15 = MUL_F(FRAC_CONST(0.7071067811865476), f12); - f16 = x[14] - x[17]; - f17 = x[14] + x[17]; - f18 = MUL_F(FRAC_CONST(0.7071067811865476), f17); - f19 = MUL_F(FRAC_CONST(0.7071067811865476), f16); - f20 = x[9] - x[22]; - f21 = x[9] + x[22]; - f22 = MUL_F(FRAC_CONST(0.7071067811865476), f21); - f23 = MUL_F(FRAC_CONST(0.7071067811865476), f20); - f24 = x[13] - x[18]; - f25 = x[13] + x[18]; - f26 = MUL_F(FRAC_CONST(0.7071067811865476), f25); - f27 = MUL_F(FRAC_CONST(0.7071067811865476), f24); - f28 = x[10] - x[21]; - f29 = x[10] + x[21]; - f30 = MUL_F(FRAC_CONST(0.7071067811865476), f29); - f31 = MUL_F(FRAC_CONST(0.7071067811865476), f28); - f32 = x[0] - f2; - f33 = x[0] + f2; - f34 = x[31] - f3; - f35 = x[31] + f3; - f36 = x[7] - f6; - f37 = x[7] + f6; - f38 = x[24] - f7; - f39 = x[24] + f7; - f40 = x[3] - f10; - f41 = x[3] + f10; - f42 = x[28] - f11; - f43 = x[28] + f11; - f44 = x[4] - f14; - f45 = x[4] + f14; - f46 = x[27] - f15; - f47 = x[27] + f15; - f48 = x[1] - f18; - f49 = x[1] + f18; - f50 = x[30] - f19; - f51 = x[30] + f19; - f52 = x[6] - f22; - f53 = x[6] + f22; - f54 = x[25] - f23; - f55 = x[25] + f23; - f56 = x[2] - f26; - f57 = x[2] + f26; - f58 = x[29] - f27; - f59 = x[29] + f27; - f60 = x[5] - f30; - f61 = x[5] + f30; - f62 = x[26] - f31; - f63 = x[26] + f31; - f64 = f39 + f37; - f65 = MUL_F(FRAC_CONST(-0.5411961001461969), f39); - f66 = MUL_F(FRAC_CONST(0.9238795325112867), f64); - f67 = MUL_C(COEF_CONST(1.3065629648763766), f37); - f68 = f65 + f66; - f69 = f67 - f66; - f70 = f38 + f36; - f71 = MUL_C(COEF_CONST(1.3065629648763770), f38); - f72 = MUL_F(FRAC_CONST(-0.3826834323650904), f70); - f73 = MUL_F(FRAC_CONST(0.5411961001461961), f36); - f74 = f71 + f72; - f75 = f73 - f72; - f76 = f47 + f45; - f77 = MUL_F(FRAC_CONST(-0.5411961001461969), f47); - f78 = MUL_F(FRAC_CONST(0.9238795325112867), f76); - f79 = MUL_C(COEF_CONST(1.3065629648763766), f45); - f80 = f77 + f78; - f81 = f79 - f78; - f82 = f46 + f44; - f83 = MUL_C(COEF_CONST(1.3065629648763770), f46); - f84 = MUL_F(FRAC_CONST(-0.3826834323650904), f82); - f85 = MUL_F(FRAC_CONST(0.5411961001461961), f44); - f86 = f83 + f84; - f87 = f85 - f84; - f88 = f55 + f53; - f89 = MUL_F(FRAC_CONST(-0.5411961001461969), f55); - f90 = MUL_F(FRAC_CONST(0.9238795325112867), f88); - f91 = MUL_C(COEF_CONST(1.3065629648763766), f53); - f92 = f89 + f90; - f93 = f91 - f90; - f94 = f54 + f52; - f95 = MUL_C(COEF_CONST(1.3065629648763770), f54); - f96 = MUL_F(FRAC_CONST(-0.3826834323650904), f94); - f97 = MUL_F(FRAC_CONST(0.5411961001461961), f52); - f98 = f95 + f96; - f99 = f97 - f96; - f100 = f63 + f61; - f101 = MUL_F(FRAC_CONST(-0.5411961001461969), f63); - f102 = MUL_F(FRAC_CONST(0.9238795325112867), f100); - f103 = MUL_C(COEF_CONST(1.3065629648763766), f61); - f104 = f101 + f102; - f105 = f103 - f102; - f106 = f62 + f60; - f107 = MUL_C(COEF_CONST(1.3065629648763770), f62); - f108 = MUL_F(FRAC_CONST(-0.3826834323650904), f106); - f109 = MUL_F(FRAC_CONST(0.5411961001461961), f60); - f110 = f107 + f108; - f111 = f109 - f108; - f112 = f33 - f68; - f113 = f33 + f68; - f114 = f35 - f69; - f115 = f35 + f69; - f116 = f32 - f74; - f117 = f32 + f74; - f118 = f34 - f75; - f119 = f34 + f75; - f120 = f41 - f80; - f121 = f41 + f80; - f122 = f43 - f81; - f123 = f43 + f81; - f124 = f40 - f86; - f125 = f40 + f86; - f126 = f42 - f87; - f127 = f42 + f87; - f128 = f49 - f92; - f129 = f49 + f92; - f130 = f51 - f93; - f131 = f51 + f93; - f132 = f48 - f98; - f133 = f48 + f98; - f134 = f50 - f99; - f135 = f50 + f99; - f136 = f57 - f104; - f137 = f57 + f104; - f138 = f59 - f105; - f139 = f59 + f105; - f140 = f56 - f110; - f141 = f56 + f110; - f142 = f58 - f111; - f143 = f58 + f111; - f144 = f123 + f121; - f145 = MUL_F(FRAC_CONST(-0.7856949583871021), f123); - f146 = MUL_F(FRAC_CONST(0.9807852804032304), f144); - f147 = MUL_C(COEF_CONST(1.1758756024193588), f121); - f148 = f145 + f146; - f149 = f147 - f146; - f150 = f127 + f125; - f151 = MUL_F(FRAC_CONST(0.2758993792829431), f127); - f152 = MUL_F(FRAC_CONST(0.5555702330196022), f150); - f153 = MUL_C(COEF_CONST(1.3870398453221475), f125); - f154 = f151 + f152; - f155 = f153 - f152; - f156 = f122 + f120; - f157 = MUL_C(COEF_CONST(1.1758756024193591), f122); - f158 = MUL_F(FRAC_CONST(-0.1950903220161287), f156); - f159 = MUL_F(FRAC_CONST(0.7856949583871016), f120); - f160 = f157 + f158; - f161 = f159 - f158; - f162 = f126 + f124; - f163 = MUL_C(COEF_CONST(1.3870398453221473), f126); - f164 = MUL_F(FRAC_CONST(-0.8314696123025455), f162); - f165 = MUL_F(FRAC_CONST(-0.2758993792829436), f124); - f166 = f163 + f164; - f167 = f165 - f164; - f168 = f139 + f137; - f169 = MUL_F(FRAC_CONST(-0.7856949583871021), f139); - f170 = MUL_F(FRAC_CONST(0.9807852804032304), f168); - f171 = MUL_C(COEF_CONST(1.1758756024193588), f137); - f172 = f169 + f170; - f173 = f171 - f170; - f174 = f143 + f141; - f175 = MUL_F(FRAC_CONST(0.2758993792829431), f143); - f176 = MUL_F(FRAC_CONST(0.5555702330196022), f174); - f177 = MUL_C(COEF_CONST(1.3870398453221475), f141); - f178 = f175 + f176; - f179 = f177 - f176; - f180 = f138 + f136; - f181 = MUL_C(COEF_CONST(1.1758756024193591), f138); - f182 = MUL_F(FRAC_CONST(-0.1950903220161287), f180); - f183 = MUL_F(FRAC_CONST(0.7856949583871016), f136); - f184 = f181 + f182; - f185 = f183 - f182; - f186 = f142 + f140; - f187 = MUL_C(COEF_CONST(1.3870398453221473), f142); - f188 = MUL_F(FRAC_CONST(-0.8314696123025455), f186); - f189 = MUL_F(FRAC_CONST(-0.2758993792829436), f140); - f190 = f187 + f188; - f191 = f189 - f188; - f192 = f113 - f148; - f193 = f113 + f148; - f194 = f115 - f149; - f195 = f115 + f149; - f196 = f117 - f154; - f197 = f117 + f154; - f198 = f119 - f155; - f199 = f119 + f155; - f200 = f112 - f160; - f201 = f112 + f160; - f202 = f114 - f161; - f203 = f114 + f161; - f204 = f116 - f166; - f205 = f116 + f166; - f206 = f118 - f167; - f207 = f118 + f167; - f208 = f129 - f172; - f209 = f129 + f172; - f210 = f131 - f173; - f211 = f131 + f173; - f212 = f133 - f178; - f213 = f133 + f178; - f214 = f135 - f179; - f215 = f135 + f179; - f216 = f128 - f184; - f217 = f128 + f184; - f218 = f130 - f185; - f219 = f130 + f185; - f220 = f132 - f190; - f221 = f132 + f190; - f222 = f134 - f191; - f223 = f134 + f191; - f224 = f211 + f209; - f225 = MUL_F(FRAC_CONST(-0.8971675863426361), f211); - f226 = MUL_F(FRAC_CONST(0.9951847266721968), f224); - f227 = MUL_C(COEF_CONST(1.0932018670017576), f209); - f228 = f225 + f226; - f229 = f227 - f226; - f230 = f215 + f213; - f231 = MUL_F(FRAC_CONST(-0.4105245275223571), f215); - f232 = MUL_F(FRAC_CONST(0.8819212643483549), f230); - f233 = MUL_C(COEF_CONST(1.3533180011743529), f213); - f234 = f231 + f232; - f235 = f233 - f232; - f236 = f219 + f217; - f237 = MUL_F(FRAC_CONST(0.1386171691990915), f219); - f238 = MUL_F(FRAC_CONST(0.6343932841636455), f236); - f239 = MUL_C(COEF_CONST(1.4074037375263826), f217); - f240 = f237 + f238; - f241 = f239 - f238; - f242 = f223 + f221; - f243 = MUL_F(FRAC_CONST(0.6666556584777466), f223); - f244 = MUL_F(FRAC_CONST(0.2902846772544623), f242); - f245 = MUL_C(COEF_CONST(1.2472250129866711), f221); - f246 = f243 + f244; - f247 = f245 - f244; - f248 = f210 + f208; - f249 = MUL_C(COEF_CONST(1.0932018670017574), f210); - f250 = MUL_F(FRAC_CONST(-0.0980171403295605), f248); - f251 = MUL_F(FRAC_CONST(0.8971675863426364), f208); - f252 = f249 + f250; - f253 = f251 - f250; - f254 = f214 + f212; - f255 = MUL_C(COEF_CONST(1.3533180011743529), f214); - f256 = MUL_F(FRAC_CONST(-0.4713967368259979), f254); - f257 = MUL_F(FRAC_CONST(0.4105245275223569), f212); - f258 = f255 + f256; - f259 = f257 - f256; - f260 = f218 + f216; - f261 = MUL_C(COEF_CONST(1.4074037375263826), f218); - f262 = MUL_F(FRAC_CONST(-0.7730104533627369), f260); - f263 = MUL_F(FRAC_CONST(-0.1386171691990913), f216); - f264 = f261 + f262; - f265 = f263 - f262; - f266 = f222 + f220; - f267 = MUL_C(COEF_CONST(1.2472250129866711), f222); - f268 = MUL_F(FRAC_CONST(-0.9569403357322089), f266); - f269 = MUL_F(FRAC_CONST(-0.6666556584777469), f220); - f270 = f267 + f268; - f271 = f269 - f268; - f272 = f193 - f228; - f273 = f193 + f228; - f274 = f195 - f229; - f275 = f195 + f229; - f276 = f197 - f234; - f277 = f197 + f234; - f278 = f199 - f235; - f279 = f199 + f235; - f280 = f201 - f240; - f281 = f201 + f240; - f282 = f203 - f241; - f283 = f203 + f241; - f284 = f205 - f246; - f285 = f205 + f246; - f286 = f207 - f247; - f287 = f207 + f247; - f288 = f192 - f252; - f289 = f192 + f252; - f290 = f194 - f253; - f291 = f194 + f253; - f292 = f196 - f258; - f293 = f196 + f258; - f294 = f198 - f259; - f295 = f198 + f259; - f296 = f200 - f264; - f297 = f200 + f264; - f298 = f202 - f265; - f299 = f202 + f265; - f300 = f204 - f270; - f301 = f204 + f270; - f302 = f206 - f271; - f303 = f206 + f271; - f304 = f275 + f273; - f305 = MUL_F(FRAC_CONST(-0.9751575901732920), f275); - f306 = MUL_F(FRAC_CONST(0.9996988186962043), f304); - f307 = MUL_C(COEF_CONST(1.0242400472191164), f273); - y[0] = f305 + f306; - y[31] = f307 - f306; - f310 = f279 + f277; - f311 = MUL_F(FRAC_CONST(-0.8700688593994936), f279); - f312 = MUL_F(FRAC_CONST(0.9924795345987100), f310); - f313 = MUL_C(COEF_CONST(1.1148902097979263), f277); - y[2] = f311 + f312; - y[29] = f313 - f312; - f316 = f283 + f281; - f317 = MUL_F(FRAC_CONST(-0.7566008898816587), f283); - f318 = MUL_F(FRAC_CONST(0.9757021300385286), f316); - f319 = MUL_C(COEF_CONST(1.1948033701953984), f281); - y[4] = f317 + f318; - y[27] = f319 - f318; - f322 = f287 + f285; - f323 = MUL_F(FRAC_CONST(-0.6358464401941451), f287); - f324 = MUL_F(FRAC_CONST(0.9495281805930367), f322); - f325 = MUL_C(COEF_CONST(1.2632099209919283), f285); - y[6] = f323 + f324; - y[25] = f325 - f324; - f328 = f291 + f289; - f329 = MUL_F(FRAC_CONST(-0.5089684416985408), f291); - f330 = MUL_F(FRAC_CONST(0.9142097557035307), f328); - f331 = MUL_C(COEF_CONST(1.3194510697085207), f289); - y[8] = f329 + f330; - y[23] = f331 - f330; - f334 = f295 + f293; - f335 = MUL_F(FRAC_CONST(-0.3771887988789273), f295); - f336 = MUL_F(FRAC_CONST(0.8700869911087114), f334); - f337 = MUL_C(COEF_CONST(1.3629851833384954), f293); - y[10] = f335 + f336; - y[21] = f337 - f336; - f340 = f299 + f297; - f341 = MUL_F(FRAC_CONST(-0.2417766217337384), f299); - f342 = MUL_F(FRAC_CONST(0.8175848131515837), f340); - f343 = MUL_C(COEF_CONST(1.3933930045694289), f297); - y[12] = f341 + f342; - y[19] = f343 - f342; - f346 = f303 + f301; - f347 = MUL_F(FRAC_CONST(-0.1040360035527077), f303); - f348 = MUL_F(FRAC_CONST(0.7572088465064845), f346); - f349 = MUL_C(COEF_CONST(1.4103816894602612), f301); - y[14] = f347 + f348; - y[17] = f349 - f348; - f352 = f274 + f272; - f353 = MUL_F(FRAC_CONST(0.0347065382144002), f274); - f354 = MUL_F(FRAC_CONST(0.6895405447370668), f352); - f355 = MUL_C(COEF_CONST(1.4137876276885337), f272); - y[16] = f353 + f354; - y[15] = f355 - f354; - f358 = f278 + f276; - f359 = MUL_F(FRAC_CONST(0.1731148370459795), f278); - f360 = MUL_F(FRAC_CONST(0.6152315905806268), f358); - f361 = MUL_C(COEF_CONST(1.4035780182072330), f276); - y[18] = f359 + f360; - y[13] = f361 - f360; - f364 = f282 + f280; - f365 = MUL_F(FRAC_CONST(0.3098559453626100), f282); - f366 = MUL_F(FRAC_CONST(0.5349976198870972), f364); - f367 = MUL_C(COEF_CONST(1.3798511851368043), f280); - y[20] = f365 + f366; - y[11] = f367 - f366; - f370 = f286 + f284; - f371 = MUL_F(FRAC_CONST(0.4436129715409088), f286); - f372 = MUL_F(FRAC_CONST(0.4496113296546065), f370); - f373 = MUL_C(COEF_CONST(1.3428356308501219), f284); - y[22] = f371 + f372; - y[9] = f373 - f372; - f376 = f290 + f288; - f377 = MUL_F(FRAC_CONST(0.5730977622997509), f290); - f378 = MUL_F(FRAC_CONST(0.3598950365349881), f376); - f379 = MUL_C(COEF_CONST(1.2928878353697271), f288); - y[24] = f377 + f378; - y[7] = f379 - f378; - f382 = f294 + f292; - f383 = MUL_F(FRAC_CONST(0.6970633083205415), f294); - f384 = MUL_F(FRAC_CONST(0.2667127574748984), f382); - f385 = MUL_C(COEF_CONST(1.2304888232703382), f292); - y[26] = f383 + f384; - y[5] = f385 - f384; - f388 = f298 + f296; - f389 = MUL_F(FRAC_CONST(0.8143157536286401), f298); - f390 = MUL_F(FRAC_CONST(0.1709618887603012), f388); - f391 = MUL_C(COEF_CONST(1.1562395311492424), f296); - y[28] = f389 + f390; - y[3] = f391 - f390; - f394 = f302 + f300; - f395 = MUL_F(FRAC_CONST(0.9237258930790228), f302); - f396 = MUL_F(FRAC_CONST(0.0735645635996674), f394); - f397 = MUL_C(COEF_CONST(1.0708550202783576), f300); - y[30] = f395 + f396; - y[1] = f397 - f396; -} - -#ifdef SBR_LOW_POWER - -void DCT2_16_unscaled(real_t *y, real_t *x) -{ - real_t f0, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10; - real_t f11, f12, f13, f14, f15, f16, f17, f18, f19, f20; - real_t f21, f22, f23, f24, f25, f26, f27, f28, f31, f32; - real_t f33, f34, f37, f38, f39, f40, f41, f42, f43, f44; - real_t f45, f46, f47, f48, f49, f51, f53, f54, f57, f58; - real_t f59, f60, f61, f62, f63, f64, f65, f66, f67, f68; - real_t f69, f70, f71, f72, f73, f74, f75, f76, f77, f78; - real_t f79, f80, f81, f82, f83, f84, f85, f86, f87, f88; - real_t f89, f90, f91, f92, f95, f96, f97, f98, f101, f102; - real_t f103, f104, f107, f108, f109, f110; - - f0 = x[0] - x[15]; - f1 = x[0] + x[15]; - f2 = x[1] - x[14]; - f3 = x[1] + x[14]; - f4 = x[2] - x[13]; - f5 = x[2] + x[13]; - f6 = x[3] - x[12]; - f7 = x[3] + x[12]; - f8 = x[4] - x[11]; - f9 = x[4] + x[11]; - f10 = x[5] - x[10]; - f11 = x[5] + x[10]; - f12 = x[6] - x[9]; - f13 = x[6] + x[9]; - f14 = x[7] - x[8]; - f15 = x[7] + x[8]; - f16 = f1 - f15; - f17 = f1 + f15; - f18 = f3 - f13; - f19 = f3 + f13; - f20 = f5 - f11; - f21 = f5 + f11; - f22 = f7 - f9; - f23 = f7 + f9; - f24 = f17 - f23; - f25 = f17 + f23; - f26 = f19 - f21; - f27 = f19 + f21; - f28 = f25 - f27; - y[0] = f25 + f27; - y[8] = MUL_F(f28, FRAC_CONST(0.7071067811865476)); - f31 = f24 + f26; - f32 = MUL_C(f24, COEF_CONST(1.3065629648763766)); - f33 = MUL_F(f31, FRAC_CONST(-0.9238795325112866)); - f34 = MUL_F(f26, FRAC_CONST(-0.5411961001461967)); - y[12] = f32 + f33; - y[4] = f34 - f33; - f37 = f16 + f22; - f38 = MUL_C(f16, COEF_CONST(1.1758756024193588)); - f39 = MUL_F(f37, FRAC_CONST(-0.9807852804032304)); - f40 = MUL_F(f22, FRAC_CONST(-0.7856949583871021)); - f41 = f38 + f39; - f42 = f40 - f39; - f43 = f18 + f20; - f44 = MUL_C(f18, COEF_CONST(1.3870398453221473)); - f45 = MUL_F(f43, FRAC_CONST(-0.8314696123025455)); - f46 = MUL_F(f20, FRAC_CONST(-0.2758993792829436)); - f47 = f44 + f45; - f48 = f46 - f45; - f49 = f42 - f48; - y[2] = f42 + f48; - f51 = MUL_F(f49, FRAC_CONST(0.7071067811865476)); - y[14] = f41 - f47; - f53 = f41 + f47; - f54 = MUL_F(f53, FRAC_CONST(0.7071067811865476)); - y[10] = f51 - f54; - y[6] = f51 + f54; - f57 = f2 - f4; - f58 = f2 + f4; - f59 = f6 - f8; - f60 = f6 + f8; - f61 = f10 - f12; - f62 = f10 + f12; - f63 = MUL_F(f60, FRAC_CONST(0.7071067811865476)); - f64 = f0 - f63; - f65 = f0 + f63; - f66 = f58 + f62; - f67 = MUL_C(f58, COEF_CONST(1.3065629648763766)); - f68 = MUL_F(f66, FRAC_CONST(-0.9238795325112866)); - f69 = MUL_F(f62, FRAC_CONST(-0.5411961001461967)); - f70 = f67 + f68; - f71 = f69 - f68; - f72 = f65 - f71; - f73 = f65 + f71; - f74 = f64 - f70; - f75 = f64 + f70; - f76 = MUL_F(f59, FRAC_CONST(0.7071067811865476)); - f77 = f14 - f76; - f78 = f14 + f76; - f79 = f61 + f57; - f80 = MUL_C(f61, COEF_CONST(1.3065629648763766)); - f81 = MUL_F(f79, FRAC_CONST(-0.9238795325112866)); - f82 = MUL_F(f57, FRAC_CONST(-0.5411961001461967)); - f83 = f80 + f81; - f84 = f82 - f81; - f85 = f78 - f84; - f86 = f78 + f84; - f87 = f77 - f83; - f88 = f77 + f83; - f89 = f86 + f73; - f90 = MUL_F(f86, FRAC_CONST(-0.8971675863426361)); - f91 = MUL_F(f89, FRAC_CONST(0.9951847266721968)); - f92 = MUL_C(f73, COEF_CONST(1.0932018670017576)); - y[1] = f90 + f91; - y[15] = f92 - f91; - f95 = f75 - f88; - f96 = MUL_F(f88, FRAC_CONST(-0.6666556584777466)); - f97 = MUL_F(f95, FRAC_CONST(0.9569403357322089)); - f98 = MUL_C(f75, COEF_CONST(1.2472250129866713)); - y[3] = f97 - f96; - y[13] = f98 - f97; - f101 = f87 + f74; - f102 = MUL_F(f87, FRAC_CONST(-0.4105245275223571)); - f103 = MUL_F(f101, FRAC_CONST(0.8819212643483549)); - f104 = MUL_C(f74, COEF_CONST(1.3533180011743529)); - y[5] = f102 + f103; - y[11] = f104 - f103; - f107 = f72 - f85; - f108 = MUL_F(f85, FRAC_CONST(-0.1386171691990915)); - f109 = MUL_F(f107, FRAC_CONST(0.7730104533627370)); - f110 = MUL_C(f72, COEF_CONST(1.4074037375263826)); - y[7] = f109 - f108; - y[9] = f110 - f109; -} - -void DCT4_16(real_t *y, real_t *x) -{ - real_t f0, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10; - real_t f11, f12, f13, f14, f15, f16, f17, f18, f19, f20; - real_t f21, f22, f23, f24, f25, f26, f27, f28, f29, f30; - real_t f31, f32, f33, f34, f35, f36, f37, f38, f39, f40; - real_t f41, f42, f43, f44, f45, f46, f47, f48, f49, f50; - real_t f51, f52, f53, f54, f55, f56, f57, f58, f59, f60; - real_t f61, f62, f63, f64, f65, f66, f67, f68, f69, f70; - real_t f71, f72, f73, f74, f75, f76, f77, f78, f79, f80; - real_t f81, f82, f83, f84, f85, f86, f87, f88, f89, f90; - real_t f91, f92, f93, f94, f95, f96, f97, f98, f99, f100; - real_t f101, f102, f103, f104, f105, f106, f107, f108, f109, f110; - real_t f111, f112, f113, f114, f115, f116, f117, f118, f119, f120; - real_t f121, f122, f123, f124, f125, f126, f127, f128, f130, f132; - real_t f134, f136, f138, f140, f142, f144, f145, f148, f149, f152; - real_t f153, f156, f157; - - f0 = x[0] + x[15]; - f1 = MUL_C(COEF_CONST(1.0478631305325901), x[0]); - f2 = MUL_F(FRAC_CONST(-0.9987954562051724), f0); - f3 = MUL_F(FRAC_CONST(-0.9497277818777548), x[15]); - f4 = f1 + f2; - f5 = f3 - f2; - f6 = x[2] + x[13]; - f7 = MUL_C(COEF_CONST(1.2130114330978077), x[2]); - f8 = MUL_F(FRAC_CONST(-0.9700312531945440), f6); - f9 = MUL_F(FRAC_CONST(-0.7270510732912803), x[13]); - f10 = f7 + f8; - f11 = f9 - f8; - f12 = x[4] + x[11]; - f13 = MUL_C(COEF_CONST(1.3315443865537255), x[4]); - f14 = MUL_F(FRAC_CONST(-0.9039892931234433), f12); - f15 = MUL_F(FRAC_CONST(-0.4764341996931612), x[11]); - f16 = f13 + f14; - f17 = f15 - f14; - f18 = x[6] + x[9]; - f19 = MUL_C(COEF_CONST(1.3989068359730781), x[6]); - f20 = MUL_F(FRAC_CONST(-0.8032075314806453), f18); - f21 = MUL_F(FRAC_CONST(-0.2075082269882124), x[9]); - f22 = f19 + f20; - f23 = f21 - f20; - f24 = x[8] + x[7]; - f25 = MUL_C(COEF_CONST(1.4125100802019777), x[8]); - f26 = MUL_F(FRAC_CONST(-0.6715589548470187), f24); - f27 = MUL_F(FRAC_CONST(0.0693921705079402), x[7]); - f28 = f25 + f26; - f29 = f27 - f26; - f30 = x[10] + x[5]; - f31 = MUL_C(COEF_CONST(1.3718313541934939), x[10]); - f32 = MUL_F(FRAC_CONST(-0.5141027441932219), f30); - f33 = MUL_F(FRAC_CONST(0.3436258658070501), x[5]); - f34 = f31 + f32; - f35 = f33 - f32; - f36 = x[12] + x[3]; - f37 = MUL_C(COEF_CONST(1.2784339185752409), x[12]); - f38 = MUL_F(FRAC_CONST(-0.3368898533922200), f36); - f39 = MUL_F(FRAC_CONST(0.6046542117908008), x[3]); - f40 = f37 + f38; - f41 = f39 - f38; - f42 = x[14] + x[1]; - f43 = MUL_C(COEF_CONST(1.1359069844201433), x[14]); - f44 = MUL_F(FRAC_CONST(-0.1467304744553624), f42); - f45 = MUL_F(FRAC_CONST(0.8424460355094185), x[1]); - f46 = f43 + f44; - f47 = f45 - f44; - f48 = f5 - f29; - f49 = f5 + f29; - f50 = f4 - f28; - f51 = f4 + f28; - f52 = f11 - f35; - f53 = f11 + f35; - f54 = f10 - f34; - f55 = f10 + f34; - f56 = f17 - f41; - f57 = f17 + f41; - f58 = f16 - f40; - f59 = f16 + f40; - f60 = f23 - f47; - f61 = f23 + f47; - f62 = f22 - f46; - f63 = f22 + f46; - f64 = f48 + f50; - f65 = MUL_C(COEF_CONST(1.1758756024193588), f48); - f66 = MUL_F(FRAC_CONST(-0.9807852804032304), f64); - f67 = MUL_F(FRAC_CONST(-0.7856949583871021), f50); - f68 = f65 + f66; - f69 = f67 - f66; - f70 = f52 + f54; - f71 = MUL_C(COEF_CONST(1.3870398453221475), f52); - f72 = MUL_F(FRAC_CONST(-0.5555702330196022), f70); - f73 = MUL_F(FRAC_CONST(0.2758993792829431), f54); - f74 = f71 + f72; - f75 = f73 - f72; - f76 = f56 + f58; - f77 = MUL_F(FRAC_CONST(0.7856949583871022), f56); - f78 = MUL_F(FRAC_CONST(0.1950903220161283), f76); - f79 = MUL_C(COEF_CONST(1.1758756024193586), f58); - f80 = f77 + f78; - f81 = f79 - f78; - f82 = f60 + f62; - f83 = MUL_F(FRAC_CONST(-0.2758993792829430), f60); - f84 = MUL_F(FRAC_CONST(0.8314696123025452), f82); - f85 = MUL_C(COEF_CONST(1.3870398453221475), f62); - f86 = f83 + f84; - f87 = f85 - f84; - f88 = f49 - f57; - f89 = f49 + f57; - f90 = f51 - f59; - f91 = f51 + f59; - f92 = f53 - f61; - f93 = f53 + f61; - f94 = f55 - f63; - f95 = f55 + f63; - f96 = f69 - f81; - f97 = f69 + f81; - f98 = f68 - f80; - f99 = f68 + f80; - f100 = f75 - f87; - f101 = f75 + f87; - f102 = f74 - f86; - f103 = f74 + f86; - f104 = f88 + f90; - f105 = MUL_C(COEF_CONST(1.3065629648763766), f88); - f106 = MUL_F(FRAC_CONST(-0.9238795325112866), f104); - f107 = MUL_F(FRAC_CONST(-0.5411961001461967), f90); - f108 = f105 + f106; - f109 = f107 - f106; - f110 = f92 + f94; - f111 = MUL_F(FRAC_CONST(0.5411961001461969), f92); - f112 = MUL_F(FRAC_CONST(0.3826834323650898), f110); - f113 = MUL_C(COEF_CONST(1.3065629648763766), f94); - f114 = f111 + f112; - f115 = f113 - f112; - f116 = f96 + f98; - f117 = MUL_C(COEF_CONST(1.3065629648763766), f96); - f118 = MUL_F(FRAC_CONST(-0.9238795325112866), f116); - f119 = MUL_F(FRAC_CONST(-0.5411961001461967), f98); - f120 = f117 + f118; - f121 = f119 - f118; - f122 = f100 + f102; - f123 = MUL_F(FRAC_CONST(0.5411961001461969), f100); - f124 = MUL_F(FRAC_CONST(0.3826834323650898), f122); - f125 = MUL_C(COEF_CONST(1.3065629648763766), f102); - f126 = f123 + f124; - f127 = f125 - f124; - f128 = f89 - f93; - y[0] = f89 + f93; - f130 = f91 - f95; - y[15] = f91 + f95; - f132 = f109 - f115; - y[3] = f109 + f115; - f134 = f108 - f114; - y[12] = f108 + f114; - f136 = f97 - f101; - y[1] = f97 + f101; - f138 = f99 - f103; - y[14] = f99 + f103; - f140 = f121 - f127; - y[2] = f121 + f127; - f142 = f120 - f126; - y[13] = f120 + f126; - f144 = f128 - f130; - f145 = f128 + f130; - y[8] = MUL_F(FRAC_CONST(0.7071067811865474), f144); - y[7] = MUL_F(FRAC_CONST(0.7071067811865474), f145); - f148 = f132 - f134; - f149 = f132 + f134; - y[11] = MUL_F(FRAC_CONST(0.7071067811865474), f148); - y[4] = MUL_F(FRAC_CONST(0.7071067811865474), f149); - f152 = f136 - f138; - f153 = f136 + f138; - y[9] = MUL_F(FRAC_CONST(0.7071067811865474), f152); - y[6] = MUL_F(FRAC_CONST(0.7071067811865474), f153); - f156 = f140 - f142; - f157 = f140 + f142; - y[10] = MUL_F(FRAC_CONST(0.7071067811865474), f156); - y[5] = MUL_F(FRAC_CONST(0.7071067811865474), f157); -} - -void DCT3_32_unscaled(real_t *y, real_t *x) -{ - real_t f0, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10; - real_t f11, f12, f13, f14, f15, f16, f17, f18, f19, f20; - real_t f21, f22, f23, f24, f25, f26, f27, f28, f29, f30; - real_t f31, f32, f33, f34, f35, f36, f37, f38, f39, f40; - real_t f41, f42, f43, f44, f45, f46, f47, f48, f49, f50; - real_t f51, f52, f53, f54, f55, f56, f57, f58, f59, f60; - real_t f61, f62, f63, f64, f65, f66, f67, f68, f69, f70; - real_t f71, f72, f73, f74, f75, f76, f77, f78, f79, f80; - real_t f81, f82, f83, f84, f85, f86, f87, f88, f89, f90; - real_t f91, f92, f93, f94, f95, f96, f97, f98, f99, f100; - real_t f101, f102, f103, f104, f105, f106, f107, f108, f109, f110; - real_t f111, f112, f113, f114, f115, f116, f117, f118, f119, f120; - real_t f121, f122, f123, f124, f125, f126, f127, f128, f129, f130; - real_t f131, f132, f133, f134, f135, f136, f137, f138, f139, f140; - real_t f141, f142, f143, f144, f145, f146, f147, f148, f149, f150; - real_t f151, f152, f153, f154, f155, f156, f157, f158, f159, f160; - real_t f161, f162, f163, f164, f165, f166, f167, f168, f169, f170; - real_t f171, f172, f173, f174, f175, f176, f177, f178, f179, f180; - real_t f181, f182, f183, f184, f185, f186, f187, f188, f189, f190; - real_t f191, f192, f193, f194, f195, f196, f197, f198, f199, f200; - real_t f201, f202, f203, f204, f205, f206, f207, f208, f209, f210; - real_t f211, f212, f213, f214, f215, f216, f217, f218, f219, f220; - real_t f221, f222, f223, f224, f225, f226, f227, f228, f229, f230; - real_t f231, f232, f233, f234, f235, f236, f237, f238, f239, f240; - real_t f241, f242, f243, f244, f245, f246, f247, f248, f249, f250; - real_t f251, f252, f253, f254, f255, f256, f257, f258, f259, f260; - real_t f261, f262, f263, f264, f265, f266, f267, f268, f269, f270; - real_t f271, f272; - - f0 = MUL_F(x[16], FRAC_CONST(0.7071067811865476)); - f1 = x[0] - f0; - f2 = x[0] + f0; - f3 = x[8] + x[24]; - f4 = MUL_C(x[8], COEF_CONST(1.3065629648763766)); - f5 = MUL_F(f3, FRAC_CONST((-0.9238795325112866))); - f6 = MUL_F(x[24], FRAC_CONST((-0.5411961001461967))); - f7 = f4 + f5; - f8 = f6 - f5; - f9 = f2 - f8; - f10 = f2 + f8; - f11 = f1 - f7; - f12 = f1 + f7; - f13 = x[4] + x[28]; - f14 = MUL_C(x[4], COEF_CONST(1.1758756024193588)); - f15 = MUL_F(f13, FRAC_CONST((-0.9807852804032304))); - f16 = MUL_F(x[28], FRAC_CONST((-0.7856949583871021))); - f17 = f14 + f15; - f18 = f16 - f15; - f19 = x[12] + x[20]; - f20 = MUL_C(x[12], COEF_CONST(1.3870398453221473)); - f21 = MUL_F(f19, FRAC_CONST((-0.8314696123025455))); - f22 = MUL_F(x[20], FRAC_CONST((-0.2758993792829436))); - f23 = f20 + f21; - f24 = f22 - f21; - f25 = f18 - f24; - f26 = f18 + f24; - f27 = MUL_F(f25, FRAC_CONST(0.7071067811865476)); - f28 = f17 - f23; - f29 = f17 + f23; - f30 = MUL_F(f29, FRAC_CONST(0.7071067811865476)); - f31 = f27 - f30; - f32 = f27 + f30; - f33 = f10 - f26; - f34 = f10 + f26; - f35 = f12 - f32; - f36 = f12 + f32; - f37 = f11 - f31; - f38 = f11 + f31; - f39 = f9 - f28; - f40 = f9 + f28; - f41 = x[2] + x[30]; - f42 = MUL_C(x[2], COEF_CONST(1.0932018670017569)); - f43 = MUL_F(f41, FRAC_CONST((-0.9951847266721969))); - f44 = MUL_F(x[30], FRAC_CONST((-0.8971675863426368))); - f45 = f42 + f43; - f46 = f44 - f43; - f47 = x[6] + x[26]; - f48 = MUL_C(x[6], COEF_CONST(1.2472250129866711)); - f49 = MUL_F(f47, FRAC_CONST((-0.9569403357322089))); - f50 = MUL_F(x[26], FRAC_CONST((-0.6666556584777469))); - f51 = f48 + f49; - f52 = f50 - f49; - f53 = x[10] + x[22]; - f54 = MUL_C(x[10], COEF_CONST(1.3533180011743526)); - f55 = MUL_F(f53, FRAC_CONST((-0.8819212643483551))); - f56 = MUL_F(x[22], FRAC_CONST((-0.4105245275223575))); - f57 = f54 + f55; - f58 = f56 - f55; - f59 = x[14] + x[18]; - f60 = MUL_C(x[14], COEF_CONST(1.4074037375263826)); - f61 = MUL_F(f59, FRAC_CONST((-0.7730104533627369))); - f62 = MUL_F(x[18], FRAC_CONST((-0.1386171691990913))); - f63 = f60 + f61; - f64 = f62 - f61; - f65 = f46 - f64; - f66 = f46 + f64; - f67 = f52 - f58; - f68 = f52 + f58; - f69 = f66 - f68; - f70 = f66 + f68; - f71 = MUL_F(f69, FRAC_CONST(0.7071067811865476)); - f72 = f65 + f67; - f73 = MUL_C(f65, COEF_CONST(1.3065629648763766)); - f74 = MUL_F(f72, FRAC_CONST((-0.9238795325112866))); - f75 = MUL_F(f67, FRAC_CONST((-0.5411961001461967))); - f76 = f73 + f74; - f77 = f75 - f74; - f78 = f45 - f63; - f79 = f45 + f63; - f80 = f51 - f57; - f81 = f51 + f57; - f82 = f79 + f81; - f83 = MUL_C(f79, COEF_CONST(1.3065629648763770)); - f84 = MUL_F(f82, FRAC_CONST((-0.3826834323650904))); - f85 = MUL_F(f81, FRAC_CONST(0.5411961001461961)); - f86 = f83 + f84; - f87 = f85 - f84; - f88 = f78 - f80; - f89 = f78 + f80; - f90 = MUL_F(f89, FRAC_CONST(0.7071067811865476)); - f91 = f77 - f87; - f92 = f77 + f87; - f93 = f71 - f90; - f94 = f71 + f90; - f95 = f76 - f86; - f96 = f76 + f86; - f97 = f34 - f70; - f98 = f34 + f70; - f99 = f36 - f92; - f100 = f36 + f92; - f101 = f38 - f91; - f102 = f38 + f91; - f103 = f40 - f94; - f104 = f40 + f94; - f105 = f39 - f93; - f106 = f39 + f93; - f107 = f37 - f96; - f108 = f37 + f96; - f109 = f35 - f95; - f110 = f35 + f95; - f111 = f33 - f88; - f112 = f33 + f88; - f113 = x[1] + x[31]; - f114 = MUL_C(x[1], COEF_CONST(1.0478631305325901)); - f115 = MUL_F(f113, FRAC_CONST((-0.9987954562051724))); - f116 = MUL_F(x[31], FRAC_CONST((-0.9497277818777548))); - f117 = f114 + f115; - f118 = f116 - f115; - f119 = x[5] + x[27]; - f120 = MUL_C(x[5], COEF_CONST(1.2130114330978077)); - f121 = MUL_F(f119, FRAC_CONST((-0.9700312531945440))); - f122 = MUL_F(x[27], FRAC_CONST((-0.7270510732912803))); - f123 = f120 + f121; - f124 = f122 - f121; - f125 = x[9] + x[23]; - f126 = MUL_C(x[9], COEF_CONST(1.3315443865537255)); - f127 = MUL_F(f125, FRAC_CONST((-0.9039892931234433))); - f128 = MUL_F(x[23], FRAC_CONST((-0.4764341996931612))); - f129 = f126 + f127; - f130 = f128 - f127; - f131 = x[13] + x[19]; - f132 = MUL_C(x[13], COEF_CONST(1.3989068359730781)); - f133 = MUL_F(f131, FRAC_CONST((-0.8032075314806453))); - f134 = MUL_F(x[19], FRAC_CONST((-0.2075082269882124))); - f135 = f132 + f133; - f136 = f134 - f133; - f137 = x[17] + x[15]; - f138 = MUL_C(x[17], COEF_CONST(1.4125100802019777)); - f139 = MUL_F(f137, FRAC_CONST((-0.6715589548470187))); - f140 = MUL_F(x[15], FRAC_CONST(0.0693921705079402)); - f141 = f138 + f139; - f142 = f140 - f139; - f143 = x[21] + x[11]; - f144 = MUL_C(x[21], COEF_CONST(1.3718313541934939)); - f145 = MUL_F(f143, FRAC_CONST((-0.5141027441932219))); - f146 = MUL_F(x[11], FRAC_CONST(0.3436258658070501)); - f147 = f144 + f145; - f148 = f146 - f145; - f149 = x[25] + x[7]; - f150 = MUL_C(x[25], COEF_CONST(1.2784339185752409)); - f151 = MUL_F(f149, FRAC_CONST((-0.3368898533922200))); - f152 = MUL_F(x[7], FRAC_CONST(0.6046542117908008)); - f153 = f150 + f151; - f154 = f152 - f151; - f155 = x[29] + x[3]; - f156 = MUL_C(x[29], COEF_CONST(1.1359069844201433)); - f157 = MUL_F(f155, FRAC_CONST((-0.1467304744553624))); - f158 = MUL_F(x[3], FRAC_CONST(0.8424460355094185)); - f159 = f156 + f157; - f160 = f158 - f157; - f161 = f118 - f142; - f162 = f118 + f142; - f163 = f117 - f141; - f164 = f117 + f141; - f165 = f124 - f148; - f166 = f124 + f148; - f167 = f123 - f147; - f168 = f123 + f147; - f169 = f130 - f154; - f170 = f130 + f154; - f171 = f129 - f153; - f172 = f129 + f153; - f173 = f136 - f160; - f174 = f136 + f160; - f175 = f135 - f159; - f176 = f135 + f159; - f177 = f161 + f163; - f178 = MUL_C(f161, COEF_CONST(1.1758756024193588)); - f179 = MUL_F(f177, FRAC_CONST((-0.9807852804032304))); - f180 = MUL_F(f163, FRAC_CONST((-0.7856949583871021))); - f181 = f178 + f179; - f182 = f180 - f179; - f183 = f165 + f167; - f184 = MUL_C(f165, COEF_CONST(1.3870398453221475)); - f185 = MUL_F(f183, FRAC_CONST((-0.5555702330196022))); - f186 = MUL_F(f167, FRAC_CONST(0.2758993792829431)); - f187 = f184 + f185; - f188 = f186 - f185; - f189 = f169 + f171; - f190 = MUL_F(f169, FRAC_CONST(0.7856949583871022)); - f191 = MUL_F(f189, FRAC_CONST(0.1950903220161283)); - f192 = MUL_C(f171, COEF_CONST(1.1758756024193586)); - f193 = f190 + f191; - f194 = f192 - f191; - f195 = f173 + f175; - f196 = MUL_F(f173, FRAC_CONST((-0.2758993792829430))); - f197 = MUL_F(f195, FRAC_CONST(0.8314696123025452)); - f198 = MUL_C(f175, COEF_CONST(1.3870398453221475)); - f199 = f196 + f197; - f200 = f198 - f197; - f201 = f162 - f170; - f202 = f162 + f170; - f203 = f164 - f172; - f204 = f164 + f172; - f205 = f166 - f174; - f206 = f166 + f174; - f207 = f168 - f176; - f208 = f168 + f176; - f209 = f182 - f194; - f210 = f182 + f194; - f211 = f181 - f193; - f212 = f181 + f193; - f213 = f188 - f200; - f214 = f188 + f200; - f215 = f187 - f199; - f216 = f187 + f199; - f217 = f201 + f203; - f218 = MUL_C(f201, COEF_CONST(1.3065629648763766)); - f219 = MUL_F(f217, FRAC_CONST((-0.9238795325112866))); - f220 = MUL_F(f203, FRAC_CONST((-0.5411961001461967))); - f221 = f218 + f219; - f222 = f220 - f219; - f223 = f205 + f207; - f224 = MUL_F(f205, FRAC_CONST(0.5411961001461969)); - f225 = MUL_F(f223, FRAC_CONST(0.3826834323650898)); - f226 = MUL_C(f207, COEF_CONST(1.3065629648763766)); - f227 = f224 + f225; - f228 = f226 - f225; - f229 = f209 + f211; - f230 = MUL_C(f209, COEF_CONST(1.3065629648763766)); - f231 = MUL_F(f229, FRAC_CONST((-0.9238795325112866))); - f232 = MUL_F(f211, FRAC_CONST((-0.5411961001461967))); - f233 = f230 + f231; - f234 = f232 - f231; - f235 = f213 + f215; - f236 = MUL_F(f213, FRAC_CONST(0.5411961001461969)); - f237 = MUL_F(f235, FRAC_CONST(0.3826834323650898)); - f238 = MUL_C(f215, COEF_CONST(1.3065629648763766)); - f239 = f236 + f237; - f240 = f238 - f237; - f241 = f202 - f206; - f242 = f202 + f206; - f243 = f204 - f208; - f244 = f204 + f208; - f245 = f222 - f228; - f246 = f222 + f228; - f247 = f221 - f227; - f248 = f221 + f227; - f249 = f210 - f214; - f250 = f210 + f214; - f251 = f212 - f216; - f252 = f212 + f216; - f253 = f234 - f240; - f254 = f234 + f240; - f255 = f233 - f239; - f256 = f233 + f239; - f257 = f241 - f243; - f258 = f241 + f243; - f259 = MUL_F(f257, FRAC_CONST(0.7071067811865474)); - f260 = MUL_F(f258, FRAC_CONST(0.7071067811865474)); - f261 = f245 - f247; - f262 = f245 + f247; - f263 = MUL_F(f261, FRAC_CONST(0.7071067811865474)); - f264 = MUL_F(f262, FRAC_CONST(0.7071067811865474)); - f265 = f249 - f251; - f266 = f249 + f251; - f267 = MUL_F(f265, FRAC_CONST(0.7071067811865474)); - f268 = MUL_F(f266, FRAC_CONST(0.7071067811865474)); - f269 = f253 - f255; - f270 = f253 + f255; - f271 = MUL_F(f269, FRAC_CONST(0.7071067811865474)); - f272 = MUL_F(f270, FRAC_CONST(0.7071067811865474)); - y[31] = f98 - f242; - y[0] = f98 + f242; - y[30] = f100 - f250; - y[1] = f100 + f250; - y[29] = f102 - f254; - y[2] = f102 + f254; - y[28] = f104 - f246; - y[3] = f104 + f246; - y[27] = f106 - f264; - y[4] = f106 + f264; - y[26] = f108 - f272; - y[5] = f108 + f272; - y[25] = f110 - f268; - y[6] = f110 + f268; - y[24] = f112 - f260; - y[7] = f112 + f260; - y[23] = f111 - f259; - y[8] = f111 + f259; - y[22] = f109 - f267; - y[9] = f109 + f267; - y[21] = f107 - f271; - y[10] = f107 + f271; - y[20] = f105 - f263; - y[11] = f105 + f263; - y[19] = f103 - f248; - y[12] = f103 + f248; - y[18] = f101 - f256; - y[13] = f101 + f256; - y[17] = f99 - f252; - y[14] = f99 + f252; - y[16] = f97 - f244; - y[15] = f97 + f244; -} - -void DCT2_32_unscaled(real_t *y, real_t *x) -{ - real_t f0, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10; - real_t f11, f12, f13, f14, f15, f16, f17, f18, f19, f20; - real_t f21, f22, f23, f24, f25, f26, f27, f28, f29, f30; - real_t f31, f32, f33, f34, f35, f36, f37, f38, f39, f40; - real_t f41, f42, f43, f44, f45, f46, f47, f48, f49, f50; - real_t f51, f52, f53, f54, f55, f56, f57, f58, f59, f60; - real_t f63, f64, f65, f66, f69, f70, f71, f72, f73, f74; - real_t f75, f76, f77, f78, f79, f80, f81, f83, f85, f86; - real_t f89, f90, f91, f92, f93, f94, f95, f96, f97, f98; - real_t f99, f100, f101, f102, f103, f104, f105, f106, f107, f108; - real_t f109, f110, f111, f112, f113, f114, f115, f116, f117, f118; - real_t f119, f120, f121, f122, f123, f124, f127, f128, f129, f130; - real_t f133, f134, f135, f136, f139, f140, f141, f142, f145, f146; - real_t f147, f148, f149, f150, f151, f152, f153, f154, f155, f156; - real_t f157, f158, f159, f160, f161, f162, f163, f164, f165, f166; - real_t f167, f168, f169, f170, f171, f172, f173, f174, f175, f176; - real_t f177, f178, f179, f180, f181, f182, f183, f184, f185, f186; - real_t f187, f188, f189, f190, f191, f192, f193, f194, f195, f196; - real_t f197, f198, f199, f200, f201, f202, f203, f204, f205, f206; - real_t f207, f208, f209, f210, f211, f212, f213, f214, f215, f216; - real_t f217, f218, f219, f220, f221, f222, f223, f224, f225, f226; - real_t f227, f228, f229, f230, f231, f232, f233, f234, f235, f236; - real_t f237, f238, f239, f240, f241, f242, f243, f244, f247, f248; - real_t f249, f250, f253, f254, f255, f256, f259, f260, f261, f262; - real_t f265, f266, f267, f268, f271, f272, f273, f274, f277, f278; - real_t f279, f280, f283, f284, f285, f286; - - f0 = x[0] - x[31]; - f1 = x[0] + x[31]; - f2 = x[1] - x[30]; - f3 = x[1] + x[30]; - f4 = x[2] - x[29]; - f5 = x[2] + x[29]; - f6 = x[3] - x[28]; - f7 = x[3] + x[28]; - f8 = x[4] - x[27]; - f9 = x[4] + x[27]; - f10 = x[5] - x[26]; - f11 = x[5] + x[26]; - f12 = x[6] - x[25]; - f13 = x[6] + x[25]; - f14 = x[7] - x[24]; - f15 = x[7] + x[24]; - f16 = x[8] - x[23]; - f17 = x[8] + x[23]; - f18 = x[9] - x[22]; - f19 = x[9] + x[22]; - f20 = x[10] - x[21]; - f21 = x[10] + x[21]; - f22 = x[11] - x[20]; - f23 = x[11] + x[20]; - f24 = x[12] - x[19]; - f25 = x[12] + x[19]; - f26 = x[13] - x[18]; - f27 = x[13] + x[18]; - f28 = x[14] - x[17]; - f29 = x[14] + x[17]; - f30 = x[15] - x[16]; - f31 = x[15] + x[16]; - f32 = f1 - f31; - f33 = f1 + f31; - f34 = f3 - f29; - f35 = f3 + f29; - f36 = f5 - f27; - f37 = f5 + f27; - f38 = f7 - f25; - f39 = f7 + f25; - f40 = f9 - f23; - f41 = f9 + f23; - f42 = f11 - f21; - f43 = f11 + f21; - f44 = f13 - f19; - f45 = f13 + f19; - f46 = f15 - f17; - f47 = f15 + f17; - f48 = f33 - f47; - f49 = f33 + f47; - f50 = f35 - f45; - f51 = f35 + f45; - f52 = f37 - f43; - f53 = f37 + f43; - f54 = f39 - f41; - f55 = f39 + f41; - f56 = f49 - f55; - f57 = f49 + f55; - f58 = f51 - f53; - f59 = f51 + f53; - f60 = f57 - f59; - y[0] = f57 + f59; - y[16] = MUL_F(FRAC_CONST(0.7071067811865476), f60); - f63 = f56 + f58; - f64 = MUL_C(COEF_CONST(1.3065629648763766), f56); - f65 = MUL_F(FRAC_CONST(-0.9238795325112866), f63); - f66 = MUL_F(FRAC_CONST(-0.5411961001461967), f58); - y[24] = f64 + f65; - y[8] = f66 - f65; - f69 = f48 + f54; - f70 = MUL_C(COEF_CONST(1.1758756024193588), f48); - f71 = MUL_F(FRAC_CONST(-0.9807852804032304), f69); - f72 = MUL_F(FRAC_CONST(-0.7856949583871021), f54); - f73 = f70 + f71; - f74 = f72 - f71; - f75 = f50 + f52; - f76 = MUL_C(COEF_CONST(1.3870398453221473), f50); - f77 = MUL_F(FRAC_CONST(-0.8314696123025455), f75); - f78 = MUL_F(FRAC_CONST(-0.2758993792829436), f52); - f79 = f76 + f77; - f80 = f78 - f77; - f81 = f74 - f80; - y[4] = f74 + f80; - f83 = MUL_F(FRAC_CONST(0.7071067811865476), f81); - y[28] = f73 - f79; - f85 = f73 + f79; - f86 = MUL_F(FRAC_CONST(0.7071067811865476), f85); - y[20] = f83 - f86; - y[12] = f83 + f86; - f89 = f34 - f36; - f90 = f34 + f36; - f91 = f38 - f40; - f92 = f38 + f40; - f93 = f42 - f44; - f94 = f42 + f44; - f95 = MUL_F(FRAC_CONST(0.7071067811865476), f92); - f96 = f32 - f95; - f97 = f32 + f95; - f98 = f90 + f94; - f99 = MUL_C(COEF_CONST(1.3065629648763766), f90); - f100 = MUL_F(FRAC_CONST(-0.9238795325112866), f98); - f101 = MUL_F(FRAC_CONST(-0.5411961001461967), f94); - f102 = f99 + f100; - f103 = f101 - f100; - f104 = f97 - f103; - f105 = f97 + f103; - f106 = f96 - f102; - f107 = f96 + f102; - f108 = MUL_F(FRAC_CONST(0.7071067811865476), f91); - f109 = f46 - f108; - f110 = f46 + f108; - f111 = f93 + f89; - f112 = MUL_C(COEF_CONST(1.3065629648763766), f93); - f113 = MUL_F(FRAC_CONST(-0.9238795325112866), f111); - f114 = MUL_F(FRAC_CONST(-0.5411961001461967), f89); - f115 = f112 + f113; - f116 = f114 - f113; - f117 = f110 - f116; - f118 = f110 + f116; - f119 = f109 - f115; - f120 = f109 + f115; - f121 = f118 + f105; - f122 = MUL_F(FRAC_CONST(-0.8971675863426361), f118); - f123 = MUL_F(FRAC_CONST(0.9951847266721968), f121); - f124 = MUL_C(COEF_CONST(1.0932018670017576), f105); - y[2] = f122 + f123; - y[30] = f124 - f123; - f127 = f107 - f120; - f128 = MUL_F(FRAC_CONST(-0.6666556584777466), f120); - f129 = MUL_F(FRAC_CONST(0.9569403357322089), f127); - f130 = MUL_C(COEF_CONST(1.2472250129866713), f107); - y[6] = f129 - f128; - y[26] = f130 - f129; - f133 = f119 + f106; - f134 = MUL_F(FRAC_CONST(-0.4105245275223571), f119); - f135 = MUL_F(FRAC_CONST(0.8819212643483549), f133); - f136 = MUL_C(COEF_CONST(1.3533180011743529), f106); - y[10] = f134 + f135; - y[22] = f136 - f135; - f139 = f104 - f117; - f140 = MUL_F(FRAC_CONST(-0.1386171691990915), f117); - f141 = MUL_F(FRAC_CONST(0.7730104533627370), f139); - f142 = MUL_C(COEF_CONST(1.4074037375263826), f104); - y[14] = f141 - f140; - y[18] = f142 - f141; - f145 = f2 - f4; - f146 = f2 + f4; - f147 = f6 - f8; - f148 = f6 + f8; - f149 = f10 - f12; - f150 = f10 + f12; - f151 = f14 - f16; - f152 = f14 + f16; - f153 = f18 - f20; - f154 = f18 + f20; - f155 = f22 - f24; - f156 = f22 + f24; - f157 = f26 - f28; - f158 = f26 + f28; - f159 = MUL_F(FRAC_CONST(0.7071067811865476), f152); - f160 = f0 - f159; - f161 = f0 + f159; - f162 = f148 + f156; - f163 = MUL_C(COEF_CONST(1.3065629648763766), f148); - f164 = MUL_F(FRAC_CONST(-0.9238795325112866), f162); - f165 = MUL_F(FRAC_CONST(-0.5411961001461967), f156); - f166 = f163 + f164; - f167 = f165 - f164; - f168 = f161 - f167; - f169 = f161 + f167; - f170 = f160 - f166; - f171 = f160 + f166; - f172 = f146 + f158; - f173 = MUL_C(COEF_CONST(1.1758756024193588), f146); - f174 = MUL_F(FRAC_CONST(-0.9807852804032304), f172); - f175 = MUL_F(FRAC_CONST(-0.7856949583871021), f158); - f176 = f173 + f174; - f177 = f175 - f174; - f178 = f150 + f154; - f179 = MUL_C(COEF_CONST(1.3870398453221473), f150); - f180 = MUL_F(FRAC_CONST(-0.8314696123025455), f178); - f181 = MUL_F(FRAC_CONST(-0.2758993792829436), f154); - f182 = f179 + f180; - f183 = f181 - f180; - f184 = f177 - f183; - f185 = f177 + f183; - f186 = MUL_F(FRAC_CONST(0.7071067811865476), f184); - f187 = f176 - f182; - f188 = f176 + f182; - f189 = MUL_F(FRAC_CONST(0.7071067811865476), f188); - f190 = f186 - f189; - f191 = f186 + f189; - f192 = f169 - f185; - f193 = f169 + f185; - f194 = f171 - f191; - f195 = f171 + f191; - f196 = f170 - f190; - f197 = f170 + f190; - f198 = f168 - f187; - f199 = f168 + f187; - f200 = MUL_F(FRAC_CONST(0.7071067811865476), f151); - f201 = f30 - f200; - f202 = f30 + f200; - f203 = f155 + f147; - f204 = MUL_C(COEF_CONST(1.3065629648763766), f155); - f205 = MUL_F(FRAC_CONST(-0.9238795325112866), f203); - f206 = MUL_F(FRAC_CONST(-0.5411961001461967), f147); - f207 = f204 + f205; - f208 = f206 - f205; - f209 = f202 - f208; - f210 = f202 + f208; - f211 = f201 - f207; - f212 = f201 + f207; - f213 = f157 + f145; - f214 = MUL_C(COEF_CONST(1.1758756024193588), f157); - f215 = MUL_F(FRAC_CONST(-0.9807852804032304), f213); - f216 = MUL_F(FRAC_CONST(-0.7856949583871021), f145); - f217 = f214 + f215; - f218 = f216 - f215; - f219 = f153 + f149; - f220 = MUL_C(COEF_CONST(1.3870398453221473), f153); - f221 = MUL_F(FRAC_CONST(-0.8314696123025455), f219); - f222 = MUL_F(FRAC_CONST(-0.2758993792829436), f149); - f223 = f220 + f221; - f224 = f222 - f221; - f225 = f218 - f224; - f226 = f218 + f224; - f227 = MUL_F(FRAC_CONST(0.7071067811865476), f225); - f228 = f217 - f223; - f229 = f217 + f223; - f230 = MUL_F(FRAC_CONST(0.7071067811865476), f229); - f231 = f227 - f230; - f232 = f227 + f230; - f233 = f210 - f226; - f234 = f210 + f226; - f235 = f212 - f232; - f236 = f212 + f232; - f237 = f211 - f231; - f238 = f211 + f231; - f239 = f209 - f228; - f240 = f209 + f228; - f241 = f234 + f193; - f242 = MUL_F(FRAC_CONST(-0.9497277818777543), f234); - f243 = MUL_F(FRAC_CONST(0.9987954562051724), f241); - f244 = MUL_C(COEF_CONST(1.0478631305325905), f193); - y[1] = f242 + f243; - y[31] = f244 - f243; - f247 = f195 - f236; - f248 = MUL_F(FRAC_CONST(-0.8424460355094192), f236); - f249 = MUL_F(FRAC_CONST(0.9891765099647810), f247); - f250 = MUL_C(COEF_CONST(1.1359069844201428), f195); - y[3] = f249 - f248; - y[29] = f250 - f249; - f253 = f238 + f197; - f254 = MUL_F(FRAC_CONST(-0.7270510732912801), f238); - f255 = MUL_F(FRAC_CONST(0.9700312531945440), f253); - f256 = MUL_C(COEF_CONST(1.2130114330978079), f197); - y[5] = f254 + f255; - y[27] = f256 - f255; - f259 = f199 - f240; - f260 = MUL_F(FRAC_CONST(-0.6046542117908007), f240); - f261 = MUL_F(FRAC_CONST(0.9415440651830208), f259); - f262 = MUL_C(COEF_CONST(1.2784339185752409), f199); - y[7] = f261 - f260; - y[25] = f262 - f261; - f265 = f239 + f198; - f266 = MUL_F(FRAC_CONST(-0.4764341996931611), f239); - f267 = MUL_F(FRAC_CONST(0.9039892931234433), f265); - f268 = MUL_C(COEF_CONST(1.3315443865537255), f198); - y[9] = f266 + f267; - y[23] = f268 - f267; - f271 = f196 - f237; - f272 = MUL_F(FRAC_CONST(-0.3436258658070505), f237); - f273 = MUL_F(FRAC_CONST(0.8577286100002721), f271); - f274 = MUL_C(COEF_CONST(1.3718313541934939), f196); - y[11] = f273 - f272; - y[21] = f274 - f273; - f277 = f235 + f194; - f278 = MUL_F(FRAC_CONST(-0.2075082269882114), f235); - f279 = MUL_F(FRAC_CONST(0.8032075314806448), f277); - f280 = MUL_C(COEF_CONST(1.3989068359730783), f194); - y[13] = f278 + f279; - y[19] = f280 - f279; - f283 = f192 - f233; - f284 = MUL_F(FRAC_CONST(-0.0693921705079408), f233); - f285 = MUL_F(FRAC_CONST(0.7409511253549591), f283); - f286 = MUL_C(COEF_CONST(1.4125100802019774), f192); - y[15] = f285 - f284; - y[17] = f286 - f285; -} - -#else /* #ifdef SBR_LOW_POWER */ - -/* table for pre-processing within dct4_kernel() */ -static const real_t dct4_pre_tab[] ICONST_ATTR MEM_ALIGN_ATTR = { - COEF_CONST(0.999924719333649), COEF_CONST(-1.01219630241394), COEF_CONST(-0.987653195858002), - COEF_CONST(0.998118102550507), COEF_CONST(-1.05943882465363), COEF_CONST(-0.936797380447388), - COEF_CONST(0.993906974792480), COEF_CONST(-1.10412919521332), COEF_CONST(-0.883684754371643), - COEF_CONST(0.987301409244537), COEF_CONST(-1.14615952968597), COEF_CONST(-0.828443288803101), - COEF_CONST(0.978317379951477), COEF_CONST(-1.18542873859405), COEF_CONST(-0.771206021308899), - COEF_CONST(0.966976463794708), COEF_CONST(-1.22184216976166), COEF_CONST(-0.712110757827759), - COEF_CONST(0.953306019306183), COEF_CONST(-1.25531196594238), COEF_CONST(-0.651300072669983), - COEF_CONST(0.937339007854462), COEF_CONST(-1.28575766086578), COEF_CONST(-0.588920354843140), - COEF_CONST(0.919113874435425), COEF_CONST(-1.31310594081879), COEF_CONST(-0.525121808052063), - COEF_CONST(0.898674488067627), COEF_CONST(-1.33729076385498), COEF_CONST(-0.460058242082596), - COEF_CONST(0.876070082187653), COEF_CONST(-1.35825383663177), COEF_CONST(-0.393886327743530), - COEF_CONST(0.851355195045471), COEF_CONST(-1.37594485282898), COEF_CONST(-0.326765477657318), - COEF_CONST(0.824589252471924), COEF_CONST(-1.39032101631165), COEF_CONST(-0.258857429027557), - COEF_CONST(0.795836925506592), COEF_CONST(-1.40134787559509), COEF_CONST(-0.190325915813446), - COEF_CONST(0.765167236328125), COEF_CONST(-1.40899872779846), COEF_CONST(-0.121335685253143), - COEF_CONST(0.732654273509979), COEF_CONST(-1.41325521469116), COEF_CONST(-0.052053272724152), - COEF_CONST(0.698376238346100), COEF_CONST(-1.41410708427429), COEF_CONST( 0.017354607582092), - COEF_CONST(0.662415742874146), COEF_CONST(-1.41155219078064), COEF_CONST( 0.086720645427704), - COEF_CONST(0.624859452247620), COEF_CONST(-1.40559673309326), COEF_CONST( 0.155877828598022), - COEF_CONST(0.585797846317291), COEF_CONST(-1.39625501632690), COEF_CONST( 0.224659323692322), - COEF_CONST(0.545324981212616), COEF_CONST(-1.38354969024658), COEF_CONST( 0.292899727821350), - COEF_CONST(0.503538429737091), COEF_CONST(-1.36751127243042), COEF_CONST( 0.360434412956238), - COEF_CONST(0.460538715124130), COEF_CONST(-1.34817838668823), COEF_CONST( 0.427100926637650), - COEF_CONST(0.416429549455643), COEF_CONST(-1.32559752464294), COEF_CONST( 0.492738455533981), - COEF_CONST(0.371317148208618), COEF_CONST(-1.29982328414917), COEF_CONST( 0.557188928127289), - COEF_CONST(0.325310230255127), COEF_CONST(-1.27091765403748), COEF_CONST( 0.620297133922577), - COEF_CONST(0.278519600629807), COEF_CONST(-1.23895013332367), COEF_CONST( 0.681910991668701), - COEF_CONST(0.231058135628700), COEF_CONST(-1.20399808883667), COEF_CONST( 0.741881847381592), - COEF_CONST(0.183039888739586), COEF_CONST(-1.16614532470703), COEF_CONST( 0.800065577030182), - COEF_CONST(0.134580686688423), COEF_CONST(-1.12548339366913), COEF_CONST( 0.856321990489960), - COEF_CONST(0.085797272622585), COEF_CONST(-1.08210992813110), COEF_CONST( 0.910515367984772), - COEF_CONST(0.036807164549828), COEF_CONST(-1.03612959384918), COEF_CONST( 0.962515234947205) -}; - -/* table for post-processing within dct4_kernel() */ -static const real_t dct4_post_tab[] ICONST_ATTR MEM_ALIGN_ATTR = { - COEF_CONST(1 ), COEF_CONST(-1 ), COEF_CONST(-1 ), - COEF_CONST(0.998795449733734), COEF_CONST(-1.04786312580109), COEF_CONST(-0.949727773666382), - COEF_CONST(0.995184719562531), COEF_CONST(-1.09320187568665), COEF_CONST(-0.897167563438416), - COEF_CONST(0.989176511764526), COEF_CONST(-1.13590693473816), COEF_CONST(-0.842446029186249), - COEF_CONST(0.980785250663757), COEF_CONST(-1.17587554454803), COEF_CONST(-0.785694956779480), - COEF_CONST(0.970031261444092), COEF_CONST(-1.21301150321960), COEF_CONST(-0.727051079273224), - COEF_CONST(0.956940352916718), COEF_CONST(-1.24722504615784), COEF_CONST(-0.666655659675598), - COEF_CONST(0.941544055938721), COEF_CONST(-1.27843391895294), COEF_CONST(-0.604654192924500), - COEF_CONST(0.923879504203796), COEF_CONST(-1.30656290054321), COEF_CONST(-0.541196048259735), - COEF_CONST(0.903989315032959), COEF_CONST(-1.33154439926148), COEF_CONST(-0.476434230804443), - COEF_CONST(0.881921231746674), COEF_CONST(-1.35331797599793), COEF_CONST(-0.410524487495422), - COEF_CONST(0.857728600502014), COEF_CONST(-1.37183141708374), COEF_CONST(-0.343625843524933), - COEF_CONST(0.831469595432281), COEF_CONST(-1.38703989982605), COEF_CONST(-0.275899350643158), - COEF_CONST(0.803207516670227), COEF_CONST(-1.39890682697296), COEF_CONST(-0.207508206367493), - COEF_CONST(0.773010432720184), COEF_CONST(-1.40740370750427), COEF_CONST(-0.138617098331451), - COEF_CONST(0.740951120853424), COEF_CONST(-1.41251015663147), COEF_CONST(-0.069392144680023), - COEF_CONST(0.707106769084930), COEF_CONST( 0 ), COEF_CONST( 0 ), - COEF_CONST(0.671558916568756), COEF_CONST(-1.41251015663147), COEF_CONST( 0.069392263889313), - COEF_CONST(0.634393274784088), COEF_CONST(-1.40740370750427), COEF_CONST( 0.138617157936096), - COEF_CONST(0.595699310302734), COEF_CONST(-1.39890682697296), COEF_CONST( 0.207508206367493), - COEF_CONST(0.555570185184479), COEF_CONST(-1.38703989982605), COEF_CONST( 0.275899469852448), - COEF_CONST(0.514102697372437), COEF_CONST(-1.37183141708374), COEF_CONST( 0.343625962734222), - COEF_CONST(0.471396654844284), COEF_CONST(-1.35331797599793), COEF_CONST( 0.410524636507034), - COEF_CONST(0.427555114030838), COEF_CONST(-1.33154439926148), COEF_CONST( 0.476434201002121), - COEF_CONST(0.382683426141739), COEF_CONST(-1.30656290054321), COEF_CONST( 0.541196107864380), - COEF_CONST(0.336889833211899), COEF_CONST(-1.27843391895294), COEF_CONST( 0.604654192924500), - COEF_CONST(0.290284633636475), COEF_CONST(-1.24722504615784), COEF_CONST( 0.666655719280243), - COEF_CONST(0.242980122566223), COEF_CONST(-1.21301138401031), COEF_CONST( 0.727051138877869), - COEF_CONST(0.195090234279633), COEF_CONST(-1.17587554454803), COEF_CONST( 0.785695075988770), - COEF_CONST(0.146730497479439), COEF_CONST(-1.13590705394745), COEF_CONST( 0.842446029186249), - COEF_CONST(0.098017133772373), COEF_CONST(-1.09320187568665), COEF_CONST( 0.897167563438416), - COEF_CONST(0.049067649990320), COEF_CONST(-1.04786312580109), COEF_CONST( 0.949727773666382) -}; - -// Table adapted from codeclib to fit into IRAM -static const uint32_t dct4_revtab[32] ICONST_ATTR MEM_ALIGN_ATTR = { - 0, 24, 12, 22, 6, 30, 11, 19, 3, 27, 15, 21, 5, 29, 9, 17, - 1, 25, 13, 23, 7, 31, 10, 18, 2, 26, 14, 20, 4, 28, 8, 16}; - -// Bufferfly used in dct4_kernel()'s pre- and post-processing -#define BUTTERFLY_DCT4(out1, out2, real_part, imag_part, tab, tabidx) \ - x_re = real_part; \ - x_im = imag_part; \ - tmp = MUL_C(x_re + x_im, tab[tabidx++]); \ - out1 = MUL_C(x_re , tab[tabidx++]) + tmp; \ - out2 = MUL_C(x_im , tab[tabidx++]) + tmp; - -/* size 64 only! */ -void dct4_kernel(real_t *real, real_t *imag) -{ - uint32_t i, idx, tabidx; - real_t x_re, x_im, tmp; - FFTComplex xc[32]; /* used for calling codeclib's fft implementation */ - - /* Step 2: modulate and pre-rotate for codeclib's fft implementation */ - // 3*32=96 multiplications - // 3*32=96 additions - for (i = 0, tabidx = 0; i < 32; i++) - { - idx = dct4_revtab[i]; - BUTTERFLY_DCT4(xc[idx].im, xc[idx].re, real[i], imag[i], dct4_pre_tab, tabidx); - } - - /* Step 3: FFT (codeclib's implementation) */ - ff_fft_calc_c(5, xc); - - /* Step 4: modulate + reordering */ - // 3*30+2=92 multiplications - // 3*30+2=92 additions - imag[0] = xc[0].im; - real[0] = xc[0].re; - for (i = 1, tabidx = 3*1; i < 16; i++) - { - idx = 32-i; - BUTTERFLY_DCT4(imag[i], real[i], xc[idx].re, xc[idx].im, dct4_post_tab, tabidx); - } - // i = 16, idx = 16 = reorder_tab[16]; - x_re = xc[16].re; - x_im = xc[16].im; - imag[16] = MUL_C(x_im - x_re, COEF_CONST(0.707106769084930)); - real[16] = MUL_C(x_re + x_im, COEF_CONST(0.707106769084930)); - for (i = 17, tabidx = 3*17; i < 32; i++) - { - idx = 32-i; - BUTTERFLY_DCT4(imag[i], real[i], xc[idx].re, xc[idx].im, dct4_post_tab, tabidx); - } -} - -void DST4_32(real_t *y, real_t *x) -{ - real_t f0, f1, f2, f3, f4, f5, f6, f7, f8, f9; - real_t f10, f11, f12, f13, f14, f15, f16, f17, f18, f19; - real_t f20, f21, f22, f23, f24, f25, f26, f27, f28, f29; - real_t f30, f31, f32, f33, f34, f35, f36, f37, f38, f39; - real_t f40, f41, f42, f43, f44, f45, f46, f47, f48, f49; - real_t f50, f51, f52, f53, f54, f55, f56, f57, f58, f59; - real_t f60, f61, f62, f63, f64, f65, f66, f67, f68, f69; - real_t f70, f71, f72, f73, f74, f75, f76, f77, f78, f79; - real_t f80, f81, f82, f83, f84, f85, f86, f87, f88, f89; - real_t f90, f91, f92, f93, f94, f95, f96, f97, f98, f99; - real_t f100, f101, f102, f103, f104, f105, f106, f107, f108, f109; - real_t f110, f111, f112, f113, f114, f115, f116, f117, f118, f119; - real_t f120, f121, f122, f123, f124, f125, f126, f127, f128, f129; - real_t f130, f131, f132, f133, f134, f135, f136, f137, f138, f139; - real_t f140, f141, f142, f143, f144, f145, f146, f147, f148, f149; - real_t f150, f151, f152, f153, f154, f155, f156, f157, f158, f159; - real_t f160, f161, f162, f163, f164, f165, f166, f167, f168, f169; - real_t f170, f171, f172, f173, f174, f175, f176, f177, f178, f179; - real_t f180, f181, f182, f183, f184, f185, f186, f187, f188, f189; - real_t f190, f191, f192, f193, f194, f195, f196, f197, f198, f199; - real_t f200, f201, f202, f203, f204, f205, f206, f207, f208, f209; - real_t f210, f211, f212, f213, f214, f215, f216, f217, f218, f219; - real_t f220, f221, f222, f223, f224, f225, f226, f227, f228, f229; - real_t f230, f231, f232, f233, f234, f235, f236, f237, f238, f239; - real_t f240, f241, f242, f243, f244, f245, f246, f247, f248, f249; - real_t f250, f251, f252, f253, f254, f255, f256, f257, f258, f259; - real_t f260, f261, f262, f263, f264, f265, f266, f267, f268, f269; - real_t f270, f271, f272, f273, f274, f275, f276, f277, f278, f279; - real_t f280, f281, f282, f283, f284, f285, f286, f287, f288, f289; - real_t f290, f291, f292, f293, f294, f295, f296, f297, f298, f299; - real_t f300, f301, f302, f303, f304, f305, f306, f307, f308, f309; - real_t f310, f311, f312, f313, f314, f315, f316, f317, f318, f319; - real_t f320, f321, f322, f323, f324, f325, f326, f327, f328, f329; - real_t f330, f331, f332, f333, f334, f335; - - f0 = x[0] - x[1]; - f1 = x[2] - x[1]; - f2 = x[2] - x[3]; - f3 = x[4] - x[3]; - f4 = x[4] - x[5]; - f5 = x[6] - x[5]; - f6 = x[6] - x[7]; - f7 = x[8] - x[7]; - f8 = x[8] - x[9]; - f9 = x[10] - x[9]; - f10 = x[10] - x[11]; - f11 = x[12] - x[11]; - f12 = x[12] - x[13]; - f13 = x[14] - x[13]; - f14 = x[14] - x[15]; - f15 = x[16] - x[15]; - f16 = x[16] - x[17]; - f17 = x[18] - x[17]; - f18 = x[18] - x[19]; - f19 = x[20] - x[19]; - f20 = x[20] - x[21]; - f21 = x[22] - x[21]; - f22 = x[22] - x[23]; - f23 = x[24] - x[23]; - f24 = x[24] - x[25]; - f25 = x[26] - x[25]; - f26 = x[26] - x[27]; - f27 = x[28] - x[27]; - f28 = x[28] - x[29]; - f29 = x[30] - x[29]; - f30 = x[30] - x[31]; - f31 = MUL_F(FRAC_CONST(0.7071067811865476), f15); - f32 = x[0] - f31; - f33 = x[0] + f31; - f34 = f7 + f23; - f35 = MUL_C(COEF_CONST(1.3065629648763766), f7); - f36 = MUL_F(FRAC_CONST(-0.9238795325112866), f34); - f37 = MUL_F(FRAC_CONST(-0.5411961001461967), f23); - f38 = f35 + f36; - f39 = f37 - f36; - f40 = f33 - f39; - f41 = f33 + f39; - f42 = f32 - f38; - f43 = f32 + f38; - f44 = f11 - f19; - f45 = f11 + f19; - f46 = MUL_F(FRAC_CONST(0.7071067811865476), f45); - f47 = f3 - f46; - f48 = f3 + f46; - f49 = MUL_F(FRAC_CONST(0.7071067811865476), f44); - f50 = f49 - f27; - f51 = f49 + f27; - f52 = f51 + f48; - f53 = MUL_F(FRAC_CONST(-0.7856949583871021), f51); - f54 = MUL_F(FRAC_CONST(0.9807852804032304), f52); - f55 = MUL_C(COEF_CONST(1.1758756024193588), f48); - f56 = f53 + f54; - f57 = f55 - f54; - f58 = f50 + f47; - f59 = MUL_F(FRAC_CONST(-0.2758993792829430), f50); - f60 = MUL_F(FRAC_CONST(0.8314696123025452), f58); - f61 = MUL_C(COEF_CONST(1.3870398453221475), f47); - f62 = f59 + f60; - f63 = f61 - f60; - f64 = f41 - f56; - f65 = f41 + f56; - f66 = f43 - f62; - f67 = f43 + f62; - f68 = f42 - f63; - f69 = f42 + f63; - f70 = f40 - f57; - f71 = f40 + f57; - f72 = f5 - f9; - f73 = f5 + f9; - f74 = f13 - f17; - f75 = f13 + f17; - f76 = f21 - f25; - f77 = f21 + f25; - f78 = MUL_F(FRAC_CONST(0.7071067811865476), f75); - f79 = f1 - f78; - f80 = f1 + f78; - f81 = f73 + f77; - f82 = MUL_C(COEF_CONST(1.3065629648763766), f73); - f83 = MUL_F(FRAC_CONST(-0.9238795325112866), f81); - f84 = MUL_F(FRAC_CONST(-0.5411961001461967), f77); - f85 = f82 + f83; - f86 = f84 - f83; - f87 = f80 - f86; - f88 = f80 + f86; - f89 = f79 - f85; - f90 = f79 + f85; - f91 = MUL_F(FRAC_CONST(0.7071067811865476), f74); - f92 = f29 - f91; - f93 = f29 + f91; - f94 = f76 + f72; - f95 = MUL_C(COEF_CONST(1.3065629648763766), f76); - f96 = MUL_F(FRAC_CONST(-0.9238795325112866), f94); - f97 = MUL_F(FRAC_CONST(-0.5411961001461967), f72); - f98 = f95 + f96; - f99 = f97 - f96; - f100 = f93 - f99; - f101 = f93 + f99; - f102 = f92 - f98; - f103 = f92 + f98; - f104 = f101 + f88; - f105 = MUL_F(FRAC_CONST(-0.8971675863426361), f101); - f106 = MUL_F(FRAC_CONST(0.9951847266721968), f104); - f107 = MUL_C(COEF_CONST(1.0932018670017576), f88); - f108 = f105 + f106; - f109 = f107 - f106; - f110 = f90 - f103; - f111 = MUL_F(FRAC_CONST(-0.6666556584777466), f103); - f112 = MUL_F(FRAC_CONST(0.9569403357322089), f110); - f113 = MUL_C(COEF_CONST(1.2472250129866713), f90); - f114 = f112 - f111; - f115 = f113 - f112; - f116 = f102 + f89; - f117 = MUL_F(FRAC_CONST(-0.4105245275223571), f102); - f118 = MUL_F(FRAC_CONST(0.8819212643483549), f116); - f119 = MUL_C(COEF_CONST(1.3533180011743529), f89); - f120 = f117 + f118; - f121 = f119 - f118; - f122 = f87 - f100; - f123 = MUL_F(FRAC_CONST(-0.1386171691990915), f100); - f124 = MUL_F(FRAC_CONST(0.7730104533627370), f122); - f125 = MUL_C(COEF_CONST(1.4074037375263826), f87); - f126 = f124 - f123; - f127 = f125 - f124; - f128 = f65 - f108; - f129 = f65 + f108; - f130 = f67 - f114; - f131 = f67 + f114; - f132 = f69 - f120; - f133 = f69 + f120; - f134 = f71 - f126; - f135 = f71 + f126; - f136 = f70 - f127; - f137 = f70 + f127; - f138 = f68 - f121; - f139 = f68 + f121; - f140 = f66 - f115; - f141 = f66 + f115; - f142 = f64 - f109; - f143 = f64 + f109; - f144 = f0 + f30; - f145 = MUL_C(COEF_CONST(1.0478631305325901), f0); - f146 = MUL_F(FRAC_CONST(-0.9987954562051724), f144); - f147 = MUL_F(FRAC_CONST(-0.9497277818777548), f30); - f148 = f145 + f146; - f149 = f147 - f146; - f150 = f4 + f26; - f151 = MUL_F(FRAC_CONST(1.2130114330978077), f4); - f152 = MUL_F(FRAC_CONST(-0.9700312531945440), f150); - f153 = MUL_F(FRAC_CONST(-0.7270510732912803), f26); - f154 = f151 + f152; - f155 = f153 - f152; - f156 = f8 + f22; - f157 = MUL_C(COEF_CONST(1.3315443865537255), f8); - f158 = MUL_F(FRAC_CONST(-0.9039892931234433), f156); - f159 = MUL_F(FRAC_CONST(-0.4764341996931612), f22); - f160 = f157 + f158; - f161 = f159 - f158; - f162 = f12 + f18; - f163 = MUL_C(COEF_CONST(1.3989068359730781), f12); - f164 = MUL_F(FRAC_CONST(-0.8032075314806453), f162); - f165 = MUL_F(FRAC_CONST(-0.2075082269882124), f18); - f166 = f163 + f164; - f167 = f165 - f164; - f168 = f16 + f14; - f169 = MUL_C(COEF_CONST(1.4125100802019777), f16); - f170 = MUL_F(FRAC_CONST(-0.6715589548470187), f168); - f171 = MUL_F(FRAC_CONST(0.0693921705079402), f14); - f172 = f169 + f170; - f173 = f171 - f170; - f174 = f20 + f10; - f175 = MUL_C(COEF_CONST(1.3718313541934939), f20); - f176 = MUL_F(FRAC_CONST(-0.5141027441932219), f174); - f177 = MUL_F(FRAC_CONST(0.3436258658070501), f10); - f178 = f175 + f176; - f179 = f177 - f176; - f180 = f24 + f6; - f181 = MUL_C(COEF_CONST(1.2784339185752409), f24); - f182 = MUL_F(FRAC_CONST(-0.3368898533922200), f180); - f183 = MUL_F(FRAC_CONST(0.6046542117908008), f6); - f184 = f181 + f182; - f185 = f183 - f182; - f186 = f28 + f2; - f187 = MUL_C(COEF_CONST(1.1359069844201433), f28); - f188 = MUL_F(FRAC_CONST(-0.1467304744553624), f186); - f189 = MUL_F(FRAC_CONST(0.8424460355094185), f2); - f190 = f187 + f188; - f191 = f189 - f188; - f192 = f149 - f173; - f193 = f149 + f173; - f194 = f148 - f172; - f195 = f148 + f172; - f196 = f155 - f179; - f197 = f155 + f179; - f198 = f154 - f178; - f199 = f154 + f178; - f200 = f161 - f185; - f201 = f161 + f185; - f202 = f160 - f184; - f203 = f160 + f184; - f204 = f167 - f191; - f205 = f167 + f191; - f206 = f166 - f190; - f207 = f166 + f190; - f208 = f192 + f194; - f209 = MUL_C(COEF_CONST(1.1758756024193588), f192); - f210 = MUL_F(FRAC_CONST(-0.9807852804032304), f208); - f211 = MUL_F(FRAC_CONST(-0.7856949583871021), f194); - f212 = f209 + f210; - f213 = f211 - f210; - f214 = f196 + f198; - f215 = MUL_C(COEF_CONST(1.3870398453221475), f196); - f216 = MUL_F(FRAC_CONST(-0.5555702330196022), f214); - f217 = MUL_F(FRAC_CONST(0.2758993792829431), f198); - f218 = f215 + f216; - f219 = f217 - f216; - f220 = f200 + f202; - f221 = MUL_F(FRAC_CONST(0.7856949583871022), f200); - f222 = MUL_F(FRAC_CONST(0.1950903220161283), f220); - f223 = MUL_C(COEF_CONST(1.1758756024193586), f202); - f224 = f221 + f222; - f225 = f223 - f222; - f226 = f204 + f206; - f227 = MUL_F(FRAC_CONST(-0.2758993792829430), f204); - f228 = MUL_F(FRAC_CONST(0.8314696123025452), f226); - f229 = MUL_C(COEF_CONST(1.3870398453221475), f206); - f230 = f227 + f228; - f231 = f229 - f228; - f232 = f193 - f201; - f233 = f193 + f201; - f234 = f195 - f203; - f235 = f195 + f203; - f236 = f197 - f205; - f237 = f197 + f205; - f238 = f199 - f207; - f239 = f199 + f207; - f240 = f213 - f225; - f241 = f213 + f225; - f242 = f212 - f224; - f243 = f212 + f224; - f244 = f219 - f231; - f245 = f219 + f231; - f246 = f218 - f230; - f247 = f218 + f230; - f248 = f232 + f234; - f249 = MUL_C(COEF_CONST(1.3065629648763766), f232); - f250 = MUL_F(FRAC_CONST(-0.9238795325112866), f248); - f251 = MUL_F(FRAC_CONST(-0.5411961001461967), f234); - f252 = f249 + f250; - f253 = f251 - f250; - f254 = f236 + f238; - f255 = MUL_F(FRAC_CONST(0.5411961001461969), f236); - f256 = MUL_F(FRAC_CONST(0.3826834323650898), f254); - f257 = MUL_C(COEF_CONST(1.3065629648763766), f238); - f258 = f255 + f256; - f259 = f257 - f256; - f260 = f240 + f242; - f261 = MUL_C(COEF_CONST(1.3065629648763766), f240); - f262 = MUL_F(FRAC_CONST(-0.9238795325112866), f260); - f263 = MUL_F(FRAC_CONST(-0.5411961001461967), f242); - f264 = f261 + f262; - f265 = f263 - f262; - f266 = f244 + f246; - f267 = MUL_F(FRAC_CONST(0.5411961001461969), f244); - f268 = MUL_F(FRAC_CONST(0.3826834323650898), f266); - f269 = MUL_C(COEF_CONST(1.3065629648763766), f246); - f270 = f267 + f268; - f271 = f269 - f268; - f272 = f233 - f237; - f273 = f233 + f237; - f274 = f235 - f239; - f275 = f235 + f239; - f276 = f253 - f259; - f277 = f253 + f259; - f278 = f252 - f258; - f279 = f252 + f258; - f280 = f241 - f245; - f281 = f241 + f245; - f282 = f243 - f247; - f283 = f243 + f247; - f284 = f265 - f271; - f285 = f265 + f271; - f286 = f264 - f270; - f287 = f264 + f270; - f288 = f272 - f274; - f289 = f272 + f274; - f290 = MUL_F(FRAC_CONST(0.7071067811865474), f288); - f291 = MUL_F(FRAC_CONST(0.7071067811865474), f289); - f292 = f276 - f278; - f293 = f276 + f278; - f294 = MUL_F(FRAC_CONST(0.7071067811865474), f292); - f295 = MUL_F(FRAC_CONST(0.7071067811865474), f293); - f296 = f280 - f282; - f297 = f280 + f282; - f298 = MUL_F(FRAC_CONST(0.7071067811865474), f296); - f299 = MUL_F(FRAC_CONST(0.7071067811865474), f297); - f300 = f284 - f286; - f301 = f284 + f286; - f302 = MUL_F(FRAC_CONST(0.7071067811865474), f300); - f303 = MUL_F(FRAC_CONST(0.7071067811865474), f301); - f304 = f129 - f273; - f305 = f129 + f273; - f306 = f131 - f281; - f307 = f131 + f281; - f308 = f133 - f285; - f309 = f133 + f285; - f310 = f135 - f277; - f311 = f135 + f277; - f312 = f137 - f295; - f313 = f137 + f295; - f314 = f139 - f303; - f315 = f139 + f303; - f316 = f141 - f299; - f317 = f141 + f299; - f318 = f143 - f291; - f319 = f143 + f291; - f320 = f142 - f290; - f321 = f142 + f290; - f322 = f140 - f298; - f323 = f140 + f298; - f324 = f138 - f302; - f325 = f138 + f302; - f326 = f136 - f294; - f327 = f136 + f294; - f328 = f134 - f279; - f329 = f134 + f279; - f330 = f132 - f287; - f331 = f132 + f287; - f332 = f130 - f283; - f333 = f130 + f283; - f334 = f128 - f275; - f335 = f128 + f275; - y[31] = MUL_F(FRAC_CONST(0.5001506360206510), f305); - y[30] = MUL_F(FRAC_CONST(0.5013584524464084), f307); - y[29] = MUL_F(FRAC_CONST(0.5037887256810443), f309); - y[28] = MUL_F(FRAC_CONST(0.5074711720725553), f311); - y[27] = MUL_F(FRAC_CONST(0.5124514794082247), f313); - y[26] = MUL_F(FRAC_CONST(0.5187927131053328), f315); - y[25] = MUL_F(FRAC_CONST(0.5265773151542700), f317); - y[24] = MUL_F(FRAC_CONST(0.5359098169079920), f319); - y[23] = MUL_F(FRAC_CONST(0.5469204379855088), f321); - y[22] = MUL_F(FRAC_CONST(0.5597698129470802), f323); - y[21] = MUL_F(FRAC_CONST(0.5746551840326600), f325); - y[20] = MUL_F(FRAC_CONST(0.5918185358574165), f327); - y[19] = MUL_F(FRAC_CONST(0.6115573478825099), f329); - y[18] = MUL_F(FRAC_CONST(0.6342389366884031), f331); - y[17] = MUL_F(FRAC_CONST(0.6603198078137061), f333); - y[16] = MUL_F(FRAC_CONST(0.6903721282002123), f335); - y[15] = MUL_F(FRAC_CONST(0.7251205223771985), f334); - y[14] = MUL_F(FRAC_CONST(0.7654941649730891), f332); - y[13] = MUL_F(FRAC_CONST(0.8127020908144905), f330); - y[12] = MUL_F(FRAC_CONST(0.8683447152233481), f328); - y[11] = MUL_F(FRAC_CONST(0.9345835970364075), f326); - y[10] = MUL_C(COEF_CONST(1.0144082649970547), f324); - y[9] = MUL_C(COEF_CONST(1.1120716205797176), f322); - y[8] = MUL_C(COEF_CONST(1.2338327379765710), f320); - y[7] = MUL_C(COEF_CONST(1.3892939586328277), f318); - y[6] = MUL_C(COEF_CONST(1.5939722833856311), f316); - y[5] = MUL_C(COEF_CONST(1.8746759800084078), f314); - y[4] = MUL_C(COEF_CONST(2.2820500680051619), f312); - y[3] = MUL_C(COEF_CONST(2.9246284281582162), f310); - y[2] = MUL_C(COEF_CONST(4.0846110781292477), f308); - y[1] = MUL_C(COEF_CONST(6.7967507116736332), f306); - y[0] = MUL_R(REAL_CONST(20.3738781672314530), f304); -} - -#endif /* #ifdef SBR_LOW_POWER */ - -#endif /* #ifdef SBR_DEC */ diff --git a/apps/codecs/libfaad/sbr_dct.h b/apps/codecs/libfaad/sbr_dct.h deleted file mode 100644 index 95394df307..0000000000 --- a/apps/codecs/libfaad/sbr_dct.h +++ /dev/null @@ -1,49 +0,0 @@ -/* -** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -** -** Any non-GPL usage of this software or parts of this software is strictly -** forbidden. -** -** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. -** -** $Id$ -**/ - -#ifndef __SBR_DCT_H__ -#define __SBR_DCT_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -void dct4_kernel(real_t *real, real_t *imag); - -void DCT3_32_unscaled(real_t *y, real_t *x); -void DCT4_32(real_t *y, real_t *x); -void DST4_32(real_t *y, real_t *x); -void DCT2_32_unscaled(real_t *y, real_t *x); -void DCT4_16(real_t *y, real_t *x); -void DCT2_16_unscaled(real_t *y, real_t *x); - - -#ifdef __cplusplus -} -#endif -#endif - diff --git a/apps/codecs/libfaad/sbr_dec.c b/apps/codecs/libfaad/sbr_dec.c deleted file mode 100644 index 21e8e028a1..0000000000 --- a/apps/codecs/libfaad/sbr_dec.c +++ /dev/null @@ -1,597 +0,0 @@ -/* -** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -** -** Any non-GPL usage of this software or parts of this software is strictly -** forbidden. -** -** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. -** -** $Id$ -**/ - - -#include "common.h" -#include "structs.h" - -#ifdef SBR_DEC - -#include -#include - -#include "syntax.h" -#include "bits.h" -#include "sbr_syntax.h" -#include "sbr_qmf.h" -#include "sbr_hfgen.h" -#include "sbr_hfadj.h" - -/* type definitons */ -typedef struct { -#if (defined(PS_DEC) || defined(DRM_PS)) - /* In case of PS_DEC or DRM_PS we need larger buffer data when calling - * ps_decode() or drm_ps_decode(). */ - qmf_t X_L[MAX_NTSRPS][64]; - qmf_t X_R[MAX_NTSRPS][64]; -#else - /* No PS functions called. Keep using MAX_NTSR as array size. */ - qmf_t X_L[MAX_NTSR][64]; - qmf_t X_R[MAX_NTSR][64]; -#endif -} XLR_t; - -/* static variables */ -static XLR_t *p_XLR = NULL; -#if defined(FAAD_STATIC_ALLOC) || defined(HAVE_FAAD_XLR_IN_IRAM) -static XLR_t s_XLR IBSS_ATTR_FAAD_XLR MEM_ALIGN_ATTR; -#endif -#if defined(FAAD_STATIC_ALLOC) -static sbr_info s_sbr[MAX_SYNTAX_ELEMENTS]; -#endif -#ifdef SBR_LOW_POWER -static real_t deg[64] MEM_ALIGN_ATTR; -#endif - -/* static function declarations */ -static uint8_t sbr_save_prev_data(sbr_info *sbr, uint8_t ch); -static void sbr_save_matrix(sbr_info *sbr, uint8_t ch); - - -sbr_info *sbrDecodeInit(uint16_t framelength, uint8_t id_aac, uint8_t id_ele, - uint32_t sample_rate, uint8_t downSampledSBR, - uint8_t IsDRM) -{ - (void)downSampledSBR; -#ifndef DRM - (void)IsDRM; -#endif - - /* Allocate sbr_info. */ -#if defined(FAAD_STATIC_ALLOC) - sbr_info *sbr = &s_sbr[id_ele]; -#else - (void)id_ele; - sbr_info *sbr = (sbr_info*)faad_malloc(sizeof(sbr_info)); - if (sbr == NULL) - { - /* could not allocate memory */ - return NULL; - } -#endif - memset(sbr, 0, sizeof(sbr_info)); - -#ifdef PS_DEC - /* initialize PS variables */ - ps_init(&sbr->ps); -#endif - - /* Allocate XLR temporary variable. Use static allocation if either - * FAAD_STATIC_ALLOC is set or XLR fits to IRAM. */ -#if defined(FAAD_STATIC_ALLOC) || defined(HAVE_FAAD_XLR_IN_IRAM) - p_XLR = &s_XLR; -#else - p_XLR = (XLR_t*)faad_malloc(sizeof(XLR_t)); - if (p_XLR == NULL) - { - /* could not allocate memory */ - return NULL; - } -#endif - memset(p_XLR, 0, sizeof(XLR_t)); - - /* save id of the parent element */ - sbr->id_aac = id_aac; - sbr->sample_rate = sample_rate; - - sbr->bs_freq_scale = 2; - sbr->bs_alter_scale = 1; - sbr->bs_noise_bands = 2; - sbr->bs_limiter_bands = 2; - sbr->bs_limiter_gains = 2; - sbr->bs_interpol_freq = 1; - sbr->bs_smoothing_mode = 1; - sbr->bs_start_freq = 5; - sbr->bs_amp_res = 1; - sbr->bs_samplerate_mode = 1; - sbr->prevEnvIsShort[0] = -1; - sbr->prevEnvIsShort[1] = -1; - sbr->header_count = 0; - sbr->Reset = 1; - -#ifdef DRM - sbr->Is_DRM_SBR = IsDRM; -#endif - sbr->tHFGen = T_HFGEN; - sbr->tHFAdj = T_HFADJ; - - sbr->bsco = 0; - sbr->bsco_prev = 0; - sbr->M_prev = 0; - sbr->frame_len = framelength; - - /* force sbr reset */ - sbr->bs_start_freq_prev = -1; - - if (framelength == 960) - { - sbr->numTimeSlotsRate = RATE * NO_TIME_SLOTS_960; - sbr->numTimeSlots = NO_TIME_SLOTS_960; - } else { - sbr->numTimeSlotsRate = RATE * NO_TIME_SLOTS; - sbr->numTimeSlots = NO_TIME_SLOTS; - } - - sbr->GQ_ringbuf_index[0] = 0; - sbr->GQ_ringbuf_index[1] = 0; - - memset(sbr->qmfa, 0, 2*sizeof(qmfa_info)); - memset(sbr->qmfs, 0, 2*sizeof(qmfs_info)); - - memset(sbr->Xsbr[0], 0, (sbr->numTimeSlotsRate+sbr->tHFGen)*64 * sizeof(qmf_t)); - memset(sbr->Xsbr[1], 0, (sbr->numTimeSlotsRate+sbr->tHFGen)*64 * sizeof(qmf_t)); - - return sbr; -} - -static uint8_t sbr_save_prev_data(sbr_info *sbr, uint8_t ch) -{ - uint8_t i; - - /* save data for next frame */ - sbr->kx_prev = sbr->kx; - sbr->M_prev = sbr->M; - sbr->bsco_prev = sbr->bsco; - - sbr->L_E_prev[ch] = sbr->L_E[ch]; - - /* sbr->L_E[ch] can become 0 on files with bit errors */ - if (sbr->L_E[ch] <= 0) - return 19; - - sbr->f_prev[ch] = sbr->f[ch][sbr->L_E[ch] - 1]; - for (i = 0; i < MAX_M; i++) - { - sbr->E_prev[ch][i] = sbr->E[ch][i][sbr->L_E[ch] - 1]; - sbr->Q_prev[ch][i] = sbr->Q[ch][i][sbr->L_Q[ch] - 1]; - } - - for (i = 0; i < MAX_M; i++) - { - sbr->bs_add_harmonic_prev[ch][i] = sbr->bs_add_harmonic[ch][i]; - } - sbr->bs_add_harmonic_flag_prev[ch] = sbr->bs_add_harmonic_flag[ch]; - - if (sbr->l_A[ch] == sbr->L_E[ch]) - sbr->prevEnvIsShort[ch] = 0; - else - sbr->prevEnvIsShort[ch] = -1; - - return 0; -} - -static void sbr_save_matrix(sbr_info *sbr, uint8_t ch) -{ - uint8_t i; - - for (i = 0; i < sbr->tHFGen; i++) - { - memmove(sbr->Xsbr[ch][i], sbr->Xsbr[ch][i+sbr->numTimeSlotsRate], 64 * sizeof(qmf_t)); - } - for (i = sbr->tHFGen; i < MAX_NTSRHFG; i++) - { - memset(sbr->Xsbr[ch][i], 0, 64 * sizeof(qmf_t)); - } -} - -static void sbr_process_channel(sbr_info *sbr, real_t *channel_buf, qmf_t X[MAX_NTSR][64], - uint8_t ch, uint8_t dont_process, - const uint8_t downSampledSBR) -{ - int16_t k, l; - - (void)downSampledSBR; -#ifdef DRM - if (sbr->Is_DRM_SBR) - { - sbr->bsco = max((int32_t)sbr->maxAACLine*32/(int32_t)sbr->frame_len - (int32_t)sbr->kx, 0); - } else { -#endif - sbr->bsco = 0; -#ifdef DRM - } -#endif - - -//#define PRE_QMF_PRINT -#ifdef PRE_QMF_PRINT - { - int i; - for (i = 0; i < 1024; i++) - { - printf("%d\n", channel_buf[i]); - } - } -#endif - - - /* subband analysis */ - if (dont_process) - sbr_qmf_analysis_32(sbr, &sbr->qmfa[ch], channel_buf, sbr->Xsbr[ch], sbr->tHFGen, 32); - else - sbr_qmf_analysis_32(sbr, &sbr->qmfa[ch], channel_buf, sbr->Xsbr[ch], sbr->tHFGen, sbr->kx); - - if (!dont_process) - { -#if 1 - /* insert high frequencies here */ - /* hf generation using patching */ - hf_generation(sbr, sbr->Xsbr[ch], sbr->Xsbr[ch] -#ifdef SBR_LOW_POWER - ,deg -#endif - ,ch); -#endif - -#ifdef SBR_LOW_POWER - for (l = sbr->t_E[ch][0]; l < sbr->t_E[ch][sbr->L_E[ch]]; l++) - { - for (k = 0; k < sbr->kx; k++) - { - QMF_RE(sbr->Xsbr[ch][sbr->tHFAdj + l][k]) = 0; - } - } -#endif - -#if 1 - /* hf adjustment */ - hf_adjustment(sbr, sbr->Xsbr[ch] -#ifdef SBR_LOW_POWER - ,deg -#endif - ,ch); -#endif - } - - if ((sbr->just_seeked != 0) || dont_process) - { - for (l = 0; l < sbr->numTimeSlotsRate; l++) - { - for (k = 0; k < 32; k++) - { - QMF_RE(X[l][k]) = QMF_RE(sbr->Xsbr[ch][l + sbr->tHFAdj][k]); -#ifndef SBR_LOW_POWER - QMF_IM(X[l][k]) = QMF_IM(sbr->Xsbr[ch][l + sbr->tHFAdj][k]); -#endif - } - for (k = 32; k < 64; k++) - { - QMF_RE(X[l][k]) = 0; -#ifndef SBR_LOW_POWER - QMF_IM(X[l][k]) = 0; -#endif - } - } - } else { - for (l = 0; l < sbr->numTimeSlotsRate; l++) - { - uint8_t kx_band, M_band, bsco_band; - - if (l < sbr->t_E[ch][0]) - { - kx_band = sbr->kx_prev; - M_band = sbr->M_prev; - bsco_band = sbr->bsco_prev; - } else { - kx_band = sbr->kx; - M_band = sbr->M; - bsco_band = sbr->bsco; - } - -#ifndef SBR_LOW_POWER - for (k = 0; k < kx_band + bsco_band; k++) - { - QMF_RE(X[l][k]) = QMF_RE(sbr->Xsbr[ch][l + sbr->tHFAdj][k]); - QMF_IM(X[l][k]) = QMF_IM(sbr->Xsbr[ch][l + sbr->tHFAdj][k]); - } - for (k = kx_band + bsco_band; k < kx_band + M_band; k++) - { - QMF_RE(X[l][k]) = QMF_RE(sbr->Xsbr[ch][l + sbr->tHFAdj][k]); - QMF_IM(X[l][k]) = QMF_IM(sbr->Xsbr[ch][l + sbr->tHFAdj][k]); - } - for (k = max(kx_band + bsco_band, kx_band + M_band); k < 64; k++) - { - QMF_RE(X[l][k]) = 0; - QMF_IM(X[l][k]) = 0; - } -#else - for (k = 0; k < kx_band + bsco_band; k++) - { - QMF_RE(X[l][k]) = QMF_RE(sbr->Xsbr[ch][l + sbr->tHFAdj][k]); - } - for (k = kx_band + bsco_band; k < min(kx_band + M_band, 63); k++) - { - QMF_RE(X[l][k]) = QMF_RE(sbr->Xsbr[ch][l + sbr->tHFAdj][k]); - } - for (k = max(kx_band + bsco_band, kx_band + M_band); k < 64; k++) - { - QMF_RE(X[l][k]) = 0; - } - QMF_RE(X[l][kx_band - 1 + bsco_band]) += - QMF_RE(sbr->Xsbr[ch][l + sbr->tHFAdj][kx_band - 1 + bsco_band]); -#endif - } - } -} - -uint8_t sbrDecodeCoupleFrame(sbr_info *sbr, real_t *left_chan, real_t *right_chan, - const uint8_t just_seeked, const uint8_t downSampledSBR) -{ - uint8_t dont_process = 0; - uint8_t ret = 0; - - if (sbr == NULL) - return 20; - - /* case can occur due to bit errors */ - if (sbr->id_aac != ID_CPE) - return 21; - - if (sbr->ret || (sbr->header_count == 0)) - { - /* don't process just upsample */ - dont_process = 1; - - /* Re-activate reset for next frame */ - if (sbr->ret && sbr->Reset) - sbr->bs_start_freq_prev = -1; - } - - if (just_seeked) - { - sbr->just_seeked = 1; - } else { - sbr->just_seeked = 0; - } - - sbr_process_channel(sbr, left_chan, p_XLR->X_L, 0, dont_process, downSampledSBR); - /* subband synthesis */ - if (downSampledSBR) - { - sbr_qmf_synthesis_32(sbr, &sbr->qmfs[0], p_XLR->X_L, left_chan); - } else { - sbr_qmf_synthesis_64(sbr, &sbr->qmfs[0], p_XLR->X_L, left_chan); - } - - sbr_process_channel(sbr, right_chan, p_XLR->X_R, 1, dont_process, downSampledSBR); - /* subband synthesis */ - if (downSampledSBR) - { - sbr_qmf_synthesis_32(sbr, &sbr->qmfs[1], p_XLR->X_R, right_chan); - } else { - sbr_qmf_synthesis_64(sbr, &sbr->qmfs[1], p_XLR->X_R, right_chan); - } - - if (sbr->bs_header_flag) - sbr->just_seeked = 0; - - if (sbr->header_count != 0 && sbr->ret == 0) - { - ret = sbr_save_prev_data(sbr, 0); - if (ret) return ret; - ret = sbr_save_prev_data(sbr, 1); - if (ret) return ret; - } - - sbr_save_matrix(sbr, 0); - sbr_save_matrix(sbr, 1); - - sbr->frame++; - -//#define POST_QMF_PRINT -#ifdef POST_QMF_PRINT - { - int i; - for (i = 0; i < 2048; i++) - { - printf("%d\n", left_chan[i]); - } - for (i = 0; i < 2048; i++) - { - printf("%d\n", right_chan[i]); - } - } -#endif - - return 0; -} - -uint8_t sbrDecodeSingleFrame(sbr_info *sbr, real_t *channel, - const uint8_t just_seeked, const uint8_t downSampledSBR) -{ - uint8_t dont_process = 0; - uint8_t ret = 0; - - if (sbr == NULL) - return 20; - - /* case can occur due to bit errors */ - if (sbr->id_aac != ID_SCE && sbr->id_aac != ID_LFE) - return 21; - - if (sbr->ret || (sbr->header_count == 0)) - { - /* don't process just upsample */ - dont_process = 1; - - /* Re-activate reset for next frame */ - if (sbr->ret && sbr->Reset) - sbr->bs_start_freq_prev = -1; - } - - if (just_seeked) - { - sbr->just_seeked = 1; - } else { - sbr->just_seeked = 0; - } - - sbr_process_channel(sbr, channel, p_XLR->X_L, 0, dont_process, downSampledSBR); - /* subband synthesis */ - if (downSampledSBR) - { - sbr_qmf_synthesis_32(sbr, &sbr->qmfs[0], p_XLR->X_L, channel); - } else { - sbr_qmf_synthesis_64(sbr, &sbr->qmfs[0], p_XLR->X_L, channel); - } - - if (sbr->bs_header_flag) - sbr->just_seeked = 0; - - if (sbr->header_count != 0 && sbr->ret == 0) - { - ret = sbr_save_prev_data(sbr, 0); - if (ret) return ret; - } - - sbr_save_matrix(sbr, 0); - - sbr->frame++; - -//#define POST_QMF_PRINT -#ifdef POST_QMF_PRINT - { - int i; - for (i = 0; i < 2048; i++) - { - printf("%d\n", channel[i]); - } - } -#endif - - return 0; -} - - -#if (defined(PS_DEC) || defined(DRM_PS)) -uint8_t sbrDecodeSingleFramePS(sbr_info *sbr, real_t *left_channel, real_t *right_channel, - const uint8_t just_seeked, const uint8_t downSampledSBR) -{ - uint8_t l, k; - uint8_t dont_process = 0; - uint8_t ret = 0; - - memset(p_XLR->X_L, 0, sizeof(*p_XLR->X_L)); - memset(p_XLR->X_R, 0, sizeof(*p_XLR->X_R)); - if (sbr == NULL) - return 20; - - /* case can occur due to bit errors */ - if (sbr->id_aac != ID_SCE && sbr->id_aac != ID_LFE) - return 21; - - if (sbr->ret || (sbr->header_count == 0)) - { - /* don't process just upsample */ - dont_process = 1; - - /* Re-activate reset for next frame */ - if (sbr->ret && sbr->Reset) - sbr->bs_start_freq_prev = -1; - } - - if (just_seeked) - { - sbr->just_seeked = 1; - } else { - sbr->just_seeked = 0; - } - - sbr_process_channel(sbr, left_channel, p_XLR->X_L, 0, dont_process, downSampledSBR); - - /* copy some extra data for PS */ - for (l = 32; l < 38; l++) - { - for (k = 0; k < 5; k++) - { - QMF_RE(p_XLR->X_L[l][k]) = QMF_RE(sbr->Xsbr[0][sbr->tHFAdj+l][k]); - QMF_IM(p_XLR->X_L[l][k]) = QMF_IM(sbr->Xsbr[0][sbr->tHFAdj+l][k]); - } - } - - /* perform parametric stereo */ -#ifdef DRM_PS - if (sbr->Is_DRM_SBR) - { - drm_ps_decode(sbr->drm_ps, (sbr->ret > 0), sbr->sample_rate, p_XLR->X_L, p_XLR->X_R); - } else { -#endif -#ifdef PS_DEC - ps_decode(&sbr->ps, p_XLR->X_L, p_XLR->X_R); -#endif -#ifdef DRM_PS - } -#endif - - /* subband synthesis */ - if (downSampledSBR) - { - sbr_qmf_synthesis_32(sbr, &sbr->qmfs[0], p_XLR->X_L, left_channel); - sbr_qmf_synthesis_32(sbr, &sbr->qmfs[1], p_XLR->X_R, right_channel); - } else { - sbr_qmf_synthesis_64(sbr, &sbr->qmfs[0], p_XLR->X_L, left_channel); - sbr_qmf_synthesis_64(sbr, &sbr->qmfs[1], p_XLR->X_R, right_channel); - } - - if (sbr->bs_header_flag) - sbr->just_seeked = 0; - - if (sbr->header_count != 0 && sbr->ret == 0) - { - ret = sbr_save_prev_data(sbr, 0); - if (ret) return ret; - } - - sbr_save_matrix(sbr, 0); - - sbr->frame++; - - return 0; -} -#endif - -#endif diff --git a/apps/codecs/libfaad/sbr_dec.h b/apps/codecs/libfaad/sbr_dec.h deleted file mode 100644 index 89fe72b7e9..0000000000 --- a/apps/codecs/libfaad/sbr_dec.h +++ /dev/null @@ -1,242 +0,0 @@ -/* -** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -** -** Any non-GPL usage of this software or parts of this software is strictly -** forbidden. -** -** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. -** -** $Id$ -**/ - -#ifndef __SBR_DEC_H__ -#define __SBR_DEC_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef PS_DEC -#include "ps_dec.h" -#endif -#ifdef DRM_PS -#include "drm_dec.h" -#endif - -#define MAX_NTSRHFG 40 /* maximum of number_time_slots * rate + HFGen. 16*2+8 */ -#define MAX_NTSR 32 /* max number_time_slots * rate, ok for DRM and not DRM mode */ - -/* MAX_M: maximum value for M */ -#define MAX_M 49 -/* MAX_L_E: maximum value for L_E */ -#define MAX_L_E 5 - -typedef struct { - real_t x[2*32*10]; - int16_t x_index; -} qmfa_info; - -typedef struct { - real_t v[2*64*20]; /* Size was "(downSampledSBR)?32:64". We use 64 now. */ - int16_t v_index; -} qmfs_info; - -typedef struct -{ - uint32_t sample_rate; - uint32_t maxAACLine; - - uint8_t rate; - uint8_t just_seeked; - uint8_t ret; - - uint8_t amp_res[2]; - - uint8_t k0; - uint8_t kx; - uint8_t M; - uint8_t N_master; - uint8_t N_high; - uint8_t N_low; - uint8_t N_Q; - uint8_t N_L[4]; - uint8_t n[2]; - - uint8_t f_master[64]; - uint8_t f_table_res[2][64]; - uint8_t f_table_noise[64]; - uint8_t f_table_lim[4][64]; -#ifdef SBR_LOW_POWER - uint8_t f_group[5][64]; - uint8_t N_G[5]; -#endif - - uint8_t table_map_k_to_g[64]; - - uint8_t abs_bord_lead[2]; - uint8_t abs_bord_trail[2]; - uint8_t n_rel_lead[2]; - uint8_t n_rel_trail[2]; - - uint8_t L_E[2]; - uint8_t L_E_prev[2]; - uint8_t L_Q[2]; - - uint8_t t_E[2][MAX_L_E+1]; - uint8_t t_Q[2][3]; - uint8_t f[2][MAX_L_E+1]; - uint8_t f_prev[2]; - - real_t G_temp_prev[2][5][64]; - real_t Q_temp_prev[2][5][64]; - int8_t GQ_ringbuf_index[2]; - - int16_t E[2][64][MAX_L_E]; - int16_t E_prev[2][64]; -#ifndef FIXED_POINT - real_t E_orig[2][64][MAX_L_E]; -#endif - real_t E_curr[2][64][MAX_L_E]; - int32_t Q[2][64][2]; -#ifndef FIXED_POINT - real_t Q_div[2][64][2]; - real_t Q_div2[2][64][2]; -#endif - int32_t Q_prev[2][64]; - - int8_t l_A[2]; - int8_t l_A_prev[2]; - - uint8_t bs_invf_mode[2][MAX_L_E]; - uint8_t bs_invf_mode_prev[2][MAX_L_E]; - real_t bwArray[2][64]; - real_t bwArray_prev[2][64]; - - uint8_t noPatches; - uint8_t patchNoSubbands[64]; - uint8_t patchStartSubband[64]; - - uint8_t bs_add_harmonic[2][64]; - uint8_t bs_add_harmonic_prev[2][64]; - - uint16_t index_noise_prev[2]; - uint8_t psi_is_prev[2]; - - uint8_t bs_start_freq_prev; - uint8_t bs_stop_freq_prev; - uint8_t bs_xover_band_prev; - uint8_t bs_freq_scale_prev; - uint8_t bs_alter_scale_prev; - uint8_t bs_noise_bands_prev; - - int8_t prevEnvIsShort[2]; - - int8_t kx_prev; - uint8_t bsco; - uint8_t bsco_prev; - uint8_t M_prev; - uint16_t frame_len; - - uint8_t Reset; - uint32_t frame; - uint32_t header_count; - - uint8_t id_aac; - qmfa_info qmfa[2] MEM_ALIGN_ATTR; - qmfs_info qmfs[2] MEM_ALIGN_ATTR; - - qmf_t Xsbr[2][MAX_NTSRHFG][64] MEM_ALIGN_ATTR; - -#ifdef DRM - uint8_t Is_DRM_SBR; -#ifdef DRM_PS - drm_ps_info *drm_ps; -#endif -#endif - - uint8_t numTimeSlotsRate; - uint8_t numTimeSlots; - uint8_t tHFGen; - uint8_t tHFAdj; - -#ifdef PS_DEC - ps_info ps; -#endif -#if (defined(PS_DEC) || defined(DRM_PS)) - uint8_t ps_used; -#endif - - /* to get it compiling */ - /* we'll see during the coding of all the tools, whether - these are all used or not. - */ - uint8_t bs_header_flag; - uint8_t bs_crc_flag; - uint16_t bs_sbr_crc_bits; - uint8_t bs_protocol_version; - uint8_t bs_amp_res; - uint8_t bs_start_freq; - uint8_t bs_stop_freq; - uint8_t bs_xover_band; - uint8_t bs_freq_scale; - uint8_t bs_alter_scale; - uint8_t bs_noise_bands; - uint8_t bs_limiter_bands; - uint8_t bs_limiter_gains; - uint8_t bs_interpol_freq; - uint8_t bs_smoothing_mode; - uint8_t bs_samplerate_mode; - uint8_t bs_add_harmonic_flag[2]; - uint8_t bs_add_harmonic_flag_prev[2]; - uint8_t bs_extended_data; - uint8_t bs_extension_id; - uint8_t bs_extension_data; - uint8_t bs_coupling; - uint8_t bs_frame_class[2]; - uint8_t bs_rel_bord[2][9]; - uint8_t bs_rel_bord_0[2][9]; - uint8_t bs_rel_bord_1[2][9]; - uint8_t bs_pointer[2]; - uint8_t bs_abs_bord_0[2]; - uint8_t bs_abs_bord_1[2]; - uint8_t bs_num_rel_0[2]; - uint8_t bs_num_rel_1[2]; - uint8_t bs_df_env[2][9]; - uint8_t bs_df_noise[2][3]; -} sbr_info; - -sbr_info *sbrDecodeInit(uint16_t framelength, uint8_t id_aac, uint8_t id_ele, - uint32_t sample_rate, uint8_t downSampledSBR, - uint8_t IsDRM); - -uint8_t sbrDecodeCoupleFrame(sbr_info *sbr, real_t *left_chan, real_t *right_chan, - const uint8_t just_seeked, const uint8_t downSampledSBR); -uint8_t sbrDecodeSingleFrame(sbr_info *sbr, real_t *channel, - const uint8_t just_seeked, const uint8_t downSampledSBR); -#if (defined(PS_DEC) || defined(DRM_PS)) -uint8_t sbrDecodeSingleFramePS(sbr_info *sbr, real_t *left_channel, real_t *right_channel, - const uint8_t just_seeked, const uint8_t downSampledSBR); -#endif - - -#ifdef __cplusplus -} -#endif -#endif - diff --git a/apps/codecs/libfaad/sbr_e_nf.c b/apps/codecs/libfaad/sbr_e_nf.c deleted file mode 100644 index ea2cbb8e35..0000000000 --- a/apps/codecs/libfaad/sbr_e_nf.c +++ /dev/null @@ -1,507 +0,0 @@ -/* -** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -** -** Any non-GPL usage of this software or parts of this software is strictly -** forbidden. -** -** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. -** -** $Id$ -**/ - -#include "common.h" -#include "structs.h" - -#ifdef SBR_DEC - -#include - -#include "sbr_syntax.h" -#include "sbr_e_nf.h" - -void extract_envelope_data(sbr_info *sbr, uint8_t ch) -{ - uint8_t l, k; - - for (l = 0; l < sbr->L_E[ch]; l++) - { - if (sbr->bs_df_env[ch][l] == 0) - { - for (k = 1; k < sbr->n[sbr->f[ch][l]]; k++) - { - sbr->E[ch][k][l] = sbr->E[ch][k - 1][l] + sbr->E[ch][k][l]; - if (sbr->E[ch][k][l] < 0) - sbr->E[ch][k][l] = 0; - } - - } else { /* bs_df_env == 1 */ - - uint8_t g = (l == 0) ? sbr->f_prev[ch] : sbr->f[ch][l-1]; - int16_t E_prev; - - if (sbr->f[ch][l] == g) - { - for (k = 0; k < sbr->n[sbr->f[ch][l]]; k++) - { - if (l == 0) - E_prev = sbr->E_prev[ch][k]; - else - E_prev = sbr->E[ch][k][l - 1]; - - sbr->E[ch][k][l] = E_prev + sbr->E[ch][k][l]; - } - - } else if ((g == 1) && (sbr->f[ch][l] == 0)) { - uint8_t i; - - for (k = 0; k < sbr->n[sbr->f[ch][l]]; k++) - { - for (i = 0; i < sbr->N_high; i++) - { - if (sbr->f_table_res[HI_RES][i] == sbr->f_table_res[LO_RES][k]) - { - if (l == 0) - E_prev = sbr->E_prev[ch][i]; - else - E_prev = sbr->E[ch][i][l - 1]; - - sbr->E[ch][k][l] = E_prev + sbr->E[ch][k][l]; - } - } - } - - } else if ((g == 0) && (sbr->f[ch][l] == 1)) { - uint8_t i; - - for (k = 0; k < sbr->n[sbr->f[ch][l]]; k++) - { - for (i = 0; i < sbr->N_low; i++) - { - if ((sbr->f_table_res[LO_RES][i] <= sbr->f_table_res[HI_RES][k]) && - (sbr->f_table_res[HI_RES][k] < sbr->f_table_res[LO_RES][i + 1])) - { - if (l == 0) - E_prev = sbr->E_prev[ch][i]; - else - E_prev = sbr->E[ch][i][l - 1]; - - sbr->E[ch][k][l] = E_prev + sbr->E[ch][k][l]; - } - } - } - } - } - } -} - -void extract_noise_floor_data(sbr_info *sbr, uint8_t ch) -{ - uint8_t l, k; - - for (l = 0; l < sbr->L_Q[ch]; l++) - { - if (sbr->bs_df_noise[ch][l] == 0) - { - for (k = 1; k < sbr->N_Q; k++) - { - sbr->Q[ch][k][l] = sbr->Q[ch][k][l] + sbr->Q[ch][k-1][l]; - } - } else { - if (l == 0) - { - for (k = 0; k < sbr->N_Q; k++) - { - sbr->Q[ch][k][l] = sbr->Q_prev[ch][k] + sbr->Q[ch][k][0]; - } - } else { - for (k = 0; k < sbr->N_Q; k++) - { - sbr->Q[ch][k][l] = sbr->Q[ch][k][l - 1] + sbr->Q[ch][k][l]; - } - } - } - } -} - -#ifndef FIXED_POINT - -/* table for Q_div values when no coupling */ -static const real_t Q_div_tab[31] = { - FRAC_CONST(0.0153846), FRAC_CONST(0.030303), - FRAC_CONST(0.0588235), FRAC_CONST(0.111111), - FRAC_CONST(0.2), FRAC_CONST(0.333333), - FRAC_CONST(0.5), FRAC_CONST(0.666667), - FRAC_CONST(0.8), FRAC_CONST(0.888889), - FRAC_CONST(0.941176), FRAC_CONST(0.969697), - FRAC_CONST(0.984615), FRAC_CONST(0.992248), - FRAC_CONST(0.996109), FRAC_CONST(0.998051), - FRAC_CONST(0.999024), FRAC_CONST(0.999512), - FRAC_CONST(0.999756), FRAC_CONST(0.999878), - FRAC_CONST(0.999939), FRAC_CONST(0.999969), - FRAC_CONST(0.999985), FRAC_CONST(0.999992), - FRAC_CONST(0.999996), FRAC_CONST(0.999998), - FRAC_CONST(0.999999), FRAC_CONST(1), - FRAC_CONST(1), FRAC_CONST(1), - FRAC_CONST(1) -}; - -static const real_t Q_div_tab_left[31][13] = { - { FRAC_CONST(0.969704), FRAC_CONST(0.888985), FRAC_CONST(0.667532), FRAC_CONST(0.336788), FRAC_CONST(0.117241), FRAC_CONST(0.037594), FRAC_CONST(0.0153846), FRAC_CONST(0.00967118), FRAC_CONST(0.00823245), FRAC_CONST(0.00787211), FRAC_CONST(0.00778198), FRAC_CONST(0.00775945), FRAC_CONST(0.00775382) }, - { FRAC_CONST(0.984619), FRAC_CONST(0.94123), FRAC_CONST(0.800623), FRAC_CONST(0.503876), FRAC_CONST(0.209877), FRAC_CONST(0.0724638), FRAC_CONST(0.030303), FRAC_CONST(0.0191571), FRAC_CONST(0.0163305), FRAC_CONST(0.0156212), FRAC_CONST(0.0154438), FRAC_CONST(0.0153994), FRAC_CONST(0.0153883) }, - { FRAC_CONST(0.99225), FRAC_CONST(0.969726), FRAC_CONST(0.889273), FRAC_CONST(0.670103), FRAC_CONST(0.346939), FRAC_CONST(0.135135), FRAC_CONST(0.0588235), FRAC_CONST(0.037594), FRAC_CONST(0.0321361), FRAC_CONST(0.0307619), FRAC_CONST(0.0304178), FRAC_CONST(0.0303317), FRAC_CONST(0.0303102) }, - { FRAC_CONST(0.99611), FRAC_CONST(0.98463), FRAC_CONST(0.941392), FRAC_CONST(0.802469), FRAC_CONST(0.515152), FRAC_CONST(0.238095), FRAC_CONST(0.111111), FRAC_CONST(0.0724638), FRAC_CONST(0.0622711), FRAC_CONST(0.0596878), FRAC_CONST(0.0590397), FRAC_CONST(0.0588776), FRAC_CONST(0.058837) }, - { FRAC_CONST(0.998051), FRAC_CONST(0.992256), FRAC_CONST(0.969811), FRAC_CONST(0.890411), FRAC_CONST(0.68), FRAC_CONST(0.384615), FRAC_CONST(0.2), FRAC_CONST(0.135135), FRAC_CONST(0.117241), FRAC_CONST(0.112652), FRAC_CONST(0.111497), FRAC_CONST(0.111208), FRAC_CONST(0.111135) }, - { FRAC_CONST(0.999025), FRAC_CONST(0.996113), FRAC_CONST(0.984674), FRAC_CONST(0.942029), FRAC_CONST(0.809524), FRAC_CONST(0.555556), FRAC_CONST(0.333333), FRAC_CONST(0.238095), FRAC_CONST(0.209877), FRAC_CONST(0.202492), FRAC_CONST(0.200625), FRAC_CONST(0.200156), FRAC_CONST(0.200039) }, - { FRAC_CONST(0.999512), FRAC_CONST(0.998053), FRAC_CONST(0.992278), FRAC_CONST(0.970149), FRAC_CONST(0.894737), FRAC_CONST(0.714286), FRAC_CONST(0.5), FRAC_CONST(0.384615), FRAC_CONST(0.346939), FRAC_CONST(0.336788), FRAC_CONST(0.3342), FRAC_CONST(0.33355), FRAC_CONST(0.333388) }, - { FRAC_CONST(0.999756), FRAC_CONST(0.999025), FRAC_CONST(0.996124), FRAC_CONST(0.984848), FRAC_CONST(0.944444), FRAC_CONST(0.833333), FRAC_CONST(0.666667), FRAC_CONST(0.555556), FRAC_CONST(0.515152), FRAC_CONST(0.503876), FRAC_CONST(0.500975), FRAC_CONST(0.500244), FRAC_CONST(0.500061) }, - { FRAC_CONST(0.999878), FRAC_CONST(0.999512), FRAC_CONST(0.998058), FRAC_CONST(0.992366), FRAC_CONST(0.971429), FRAC_CONST(0.909091), FRAC_CONST(0.8), FRAC_CONST(0.714286), FRAC_CONST(0.68), FRAC_CONST(0.670103), FRAC_CONST(0.667532), FRAC_CONST(0.666884), FRAC_CONST(0.666721) }, - { FRAC_CONST(0.999939), FRAC_CONST(0.999756), FRAC_CONST(0.999028), FRAC_CONST(0.996169), FRAC_CONST(0.985507), FRAC_CONST(0.952381), FRAC_CONST(0.888889), FRAC_CONST(0.833333), FRAC_CONST(0.809524), FRAC_CONST(0.802469), FRAC_CONST(0.800623), FRAC_CONST(0.800156), FRAC_CONST(0.800039) }, - { FRAC_CONST(0.999969), FRAC_CONST(0.999878), FRAC_CONST(0.999514), FRAC_CONST(0.998081), FRAC_CONST(0.992701), FRAC_CONST(0.97561), FRAC_CONST(0.941176), FRAC_CONST(0.909091), FRAC_CONST(0.894737), FRAC_CONST(0.890411), FRAC_CONST(0.889273), FRAC_CONST(0.888985), FRAC_CONST(0.888913) }, - { FRAC_CONST(0.999985), FRAC_CONST(0.999939), FRAC_CONST(0.999757), FRAC_CONST(0.999039), FRAC_CONST(0.996337), FRAC_CONST(0.987654), FRAC_CONST(0.969697), FRAC_CONST(0.952381), FRAC_CONST(0.944444), FRAC_CONST(0.942029), FRAC_CONST(0.941392), FRAC_CONST(0.94123), FRAC_CONST(0.94119) }, - { FRAC_CONST(0.999992), FRAC_CONST(0.99997), FRAC_CONST(0.999878), FRAC_CONST(0.999519), FRAC_CONST(0.998165), FRAC_CONST(0.993789), FRAC_CONST(0.984615), FRAC_CONST(0.97561), FRAC_CONST(0.971429), FRAC_CONST(0.970149), FRAC_CONST(0.969811), FRAC_CONST(0.969726), FRAC_CONST(0.969704) }, - { FRAC_CONST(0.999996), FRAC_CONST(0.999985), FRAC_CONST(0.999939), FRAC_CONST(0.99976), FRAC_CONST(0.999082), FRAC_CONST(0.996885), FRAC_CONST(0.992248), FRAC_CONST(0.987654), FRAC_CONST(0.985507), FRAC_CONST(0.984848), FRAC_CONST(0.984674), FRAC_CONST(0.98463), FRAC_CONST(0.984619) }, - { FRAC_CONST(0.999998), FRAC_CONST(0.999992), FRAC_CONST(0.99997), FRAC_CONST(0.99988), FRAC_CONST(0.999541), FRAC_CONST(0.99844), FRAC_CONST(0.996109), FRAC_CONST(0.993789), FRAC_CONST(0.992701), FRAC_CONST(0.992366), FRAC_CONST(0.992278), FRAC_CONST(0.992256), FRAC_CONST(0.99225) }, - { FRAC_CONST(0.999999), FRAC_CONST(0.999996), FRAC_CONST(0.999985), FRAC_CONST(0.99994), FRAC_CONST(0.99977), FRAC_CONST(0.999219), FRAC_CONST(0.998051), FRAC_CONST(0.996885), FRAC_CONST(0.996337), FRAC_CONST(0.996169), FRAC_CONST(0.996124), FRAC_CONST(0.996113), FRAC_CONST(0.99611) }, - { FRAC_CONST(1), FRAC_CONST(0.999998), FRAC_CONST(0.999992), FRAC_CONST(0.99997), FRAC_CONST(0.999885), FRAC_CONST(0.99961), FRAC_CONST(0.999024), FRAC_CONST(0.99844), FRAC_CONST(0.998165), FRAC_CONST(0.998081), FRAC_CONST(0.998058), FRAC_CONST(0.998053), FRAC_CONST(0.998051) }, - { FRAC_CONST(1), FRAC_CONST(0.999999), FRAC_CONST(0.999996), FRAC_CONST(0.999985), FRAC_CONST(0.999943), FRAC_CONST(0.999805), FRAC_CONST(0.999512), FRAC_CONST(0.999219), FRAC_CONST(0.999082), FRAC_CONST(0.999039), FRAC_CONST(0.999028), FRAC_CONST(0.999025), FRAC_CONST(0.999025) }, - { FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(0.999998), FRAC_CONST(0.999992), FRAC_CONST(0.999971), FRAC_CONST(0.999902), FRAC_CONST(0.999756), FRAC_CONST(0.99961), FRAC_CONST(0.999541), FRAC_CONST(0.999519), FRAC_CONST(0.999514), FRAC_CONST(0.999512), FRAC_CONST(0.999512) }, - { FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(0.999999), FRAC_CONST(0.999996), FRAC_CONST(0.999986), FRAC_CONST(0.999951), FRAC_CONST(0.999878), FRAC_CONST(0.999805), FRAC_CONST(0.99977), FRAC_CONST(0.99976), FRAC_CONST(0.999757), FRAC_CONST(0.999756), FRAC_CONST(0.999756) }, - { FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(0.999998), FRAC_CONST(0.999993), FRAC_CONST(0.999976), FRAC_CONST(0.999939), FRAC_CONST(0.999902), FRAC_CONST(0.999885), FRAC_CONST(0.99988), FRAC_CONST(0.999878), FRAC_CONST(0.999878), FRAC_CONST(0.999878) }, - { FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(0.999999), FRAC_CONST(0.999996), FRAC_CONST(0.999988), FRAC_CONST(0.999969), FRAC_CONST(0.999951), FRAC_CONST(0.999943), FRAC_CONST(0.99994), FRAC_CONST(0.999939), FRAC_CONST(0.999939), FRAC_CONST(0.999939) }, - { FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(0.999998), FRAC_CONST(0.999994), FRAC_CONST(0.999985), FRAC_CONST(0.999976), FRAC_CONST(0.999971), FRAC_CONST(0.99997), FRAC_CONST(0.99997), FRAC_CONST(0.99997), FRAC_CONST(0.999969) }, - { FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(0.999999), FRAC_CONST(0.999997), FRAC_CONST(0.999992), FRAC_CONST(0.999988), FRAC_CONST(0.999986), FRAC_CONST(0.999985), FRAC_CONST(0.999985), FRAC_CONST(0.999985), FRAC_CONST(0.999985) }, - { FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(0.999998), FRAC_CONST(0.999996), FRAC_CONST(0.999994), FRAC_CONST(0.999993), FRAC_CONST(0.999992), FRAC_CONST(0.999992), FRAC_CONST(0.999992), FRAC_CONST(0.999992) }, - { FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(0.999999), FRAC_CONST(0.999998), FRAC_CONST(0.999997), FRAC_CONST(0.999996), FRAC_CONST(0.999996), FRAC_CONST(0.999996), FRAC_CONST(0.999996), FRAC_CONST(0.999996) }, - { FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(0.999999), FRAC_CONST(0.999998), FRAC_CONST(0.999998), FRAC_CONST(0.999998), FRAC_CONST(0.999998), FRAC_CONST(0.999998), FRAC_CONST(0.999998) }, - { FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(0.999999), FRAC_CONST(0.999999), FRAC_CONST(0.999999), FRAC_CONST(0.999999), FRAC_CONST(0.999999), FRAC_CONST(0.999999) }, - { FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1) }, - { FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1) }, - { FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1) } -}; - -static const real_t Q_div_tab_right[31][13] = { - { FRAC_CONST(0.00775382), FRAC_CONST(0.00775945), FRAC_CONST(0.00778198), FRAC_CONST(0.00787211), FRAC_CONST(0.00823245), FRAC_CONST(0.00967118), FRAC_CONST(0.0153846), FRAC_CONST(0.037594), FRAC_CONST(0.117241), FRAC_CONST(0.336788), FRAC_CONST(0.667532), FRAC_CONST(0.888985), FRAC_CONST(0.969704) }, - { FRAC_CONST(0.0153883), FRAC_CONST(0.0153994), FRAC_CONST(0.0154438), FRAC_CONST(0.0156212), FRAC_CONST(0.0163305), FRAC_CONST(0.0191571), FRAC_CONST(0.030303), FRAC_CONST(0.0724638), FRAC_CONST(0.209877), FRAC_CONST(0.503876), FRAC_CONST(0.800623), FRAC_CONST(0.94123), FRAC_CONST(0.984619) }, - { FRAC_CONST(0.0303102), FRAC_CONST(0.0303317), FRAC_CONST(0.0304178), FRAC_CONST(0.0307619), FRAC_CONST(0.0321361), FRAC_CONST(0.037594), FRAC_CONST(0.0588235), FRAC_CONST(0.135135), FRAC_CONST(0.346939), FRAC_CONST(0.670103), FRAC_CONST(0.889273), FRAC_CONST(0.969726), FRAC_CONST(0.99225) }, - { FRAC_CONST(0.058837), FRAC_CONST(0.0588776), FRAC_CONST(0.0590397), FRAC_CONST(0.0596878), FRAC_CONST(0.0622711), FRAC_CONST(0.0724638), FRAC_CONST(0.111111), FRAC_CONST(0.238095), FRAC_CONST(0.515152), FRAC_CONST(0.802469), FRAC_CONST(0.941392), FRAC_CONST(0.98463), FRAC_CONST(0.99611) }, - { FRAC_CONST(0.111135), FRAC_CONST(0.111208), FRAC_CONST(0.111497), FRAC_CONST(0.112652), FRAC_CONST(0.117241), FRAC_CONST(0.135135), FRAC_CONST(0.2), FRAC_CONST(0.384615), FRAC_CONST(0.68), FRAC_CONST(0.890411), FRAC_CONST(0.969811), FRAC_CONST(0.992256), FRAC_CONST(0.998051) }, - { FRAC_CONST(0.200039), FRAC_CONST(0.200156), FRAC_CONST(0.200625), FRAC_CONST(0.202492), FRAC_CONST(0.209877), FRAC_CONST(0.238095), FRAC_CONST(0.333333), FRAC_CONST(0.555556), FRAC_CONST(0.809524), FRAC_CONST(0.942029), FRAC_CONST(0.984674), FRAC_CONST(0.996113), FRAC_CONST(0.999025) }, - { FRAC_CONST(0.333388), FRAC_CONST(0.33355), FRAC_CONST(0.3342), FRAC_CONST(0.336788), FRAC_CONST(0.346939), FRAC_CONST(0.384615), FRAC_CONST(0.5), FRAC_CONST(0.714286), FRAC_CONST(0.894737), FRAC_CONST(0.970149), FRAC_CONST(0.992278), FRAC_CONST(0.998053), FRAC_CONST(0.999512) }, - { FRAC_CONST(0.500061), FRAC_CONST(0.500244), FRAC_CONST(0.500975), FRAC_CONST(0.503876), FRAC_CONST(0.515152), FRAC_CONST(0.555556), FRAC_CONST(0.666667), FRAC_CONST(0.833333), FRAC_CONST(0.944444), FRAC_CONST(0.984848), FRAC_CONST(0.996124), FRAC_CONST(0.999025), FRAC_CONST(0.999756) }, - { FRAC_CONST(0.666721), FRAC_CONST(0.666884), FRAC_CONST(0.667532), FRAC_CONST(0.670103), FRAC_CONST(0.68), FRAC_CONST(0.714286), FRAC_CONST(0.8), FRAC_CONST(0.909091), FRAC_CONST(0.971429), FRAC_CONST(0.992366), FRAC_CONST(0.998058), FRAC_CONST(0.999512), FRAC_CONST(0.999878) }, - { FRAC_CONST(0.800039), FRAC_CONST(0.800156), FRAC_CONST(0.800623), FRAC_CONST(0.802469), FRAC_CONST(0.809524), FRAC_CONST(0.833333), FRAC_CONST(0.888889), FRAC_CONST(0.952381), FRAC_CONST(0.985507), FRAC_CONST(0.996169), FRAC_CONST(0.999028), FRAC_CONST(0.999756), FRAC_CONST(0.999939) }, - { FRAC_CONST(0.888913), FRAC_CONST(0.888985), FRAC_CONST(0.889273), FRAC_CONST(0.890411), FRAC_CONST(0.894737), FRAC_CONST(0.909091), FRAC_CONST(0.941176), FRAC_CONST(0.97561), FRAC_CONST(0.992701), FRAC_CONST(0.998081), FRAC_CONST(0.999514), FRAC_CONST(0.999878), FRAC_CONST(0.999969) }, - { FRAC_CONST(0.94119), FRAC_CONST(0.94123), FRAC_CONST(0.941392), FRAC_CONST(0.942029), FRAC_CONST(0.944444), FRAC_CONST(0.952381), FRAC_CONST(0.969697), FRAC_CONST(0.987654), FRAC_CONST(0.996337), FRAC_CONST(0.999039), FRAC_CONST(0.999757), FRAC_CONST(0.999939), FRAC_CONST(0.999985) }, - { FRAC_CONST(0.969704), FRAC_CONST(0.969726), FRAC_CONST(0.969811), FRAC_CONST(0.970149), FRAC_CONST(0.971429), FRAC_CONST(0.97561), FRAC_CONST(0.984615), FRAC_CONST(0.993789), FRAC_CONST(0.998165), FRAC_CONST(0.999519), FRAC_CONST(0.999878), FRAC_CONST(0.99997), FRAC_CONST(0.999992) }, - { FRAC_CONST(0.984619), FRAC_CONST(0.98463), FRAC_CONST(0.984674), FRAC_CONST(0.984848), FRAC_CONST(0.985507), FRAC_CONST(0.987654), FRAC_CONST(0.992248), FRAC_CONST(0.996885), FRAC_CONST(0.999082), FRAC_CONST(0.99976), FRAC_CONST(0.999939), FRAC_CONST(0.999985), FRAC_CONST(0.999996) }, - { FRAC_CONST(0.99225), FRAC_CONST(0.992256), FRAC_CONST(0.992278), FRAC_CONST(0.992366), FRAC_CONST(0.992701), FRAC_CONST(0.993789), FRAC_CONST(0.996109), FRAC_CONST(0.99844), FRAC_CONST(0.999541), FRAC_CONST(0.99988), FRAC_CONST(0.99997), FRAC_CONST(0.999992), FRAC_CONST(0.999998) }, - { FRAC_CONST(0.99611), FRAC_CONST(0.996113), FRAC_CONST(0.996124), FRAC_CONST(0.996169), FRAC_CONST(0.996337), FRAC_CONST(0.996885), FRAC_CONST(0.998051), FRAC_CONST(0.999219), FRAC_CONST(0.99977), FRAC_CONST(0.99994), FRAC_CONST(0.999985), FRAC_CONST(0.999996), FRAC_CONST(0.999999) }, - { FRAC_CONST(0.998051), FRAC_CONST(0.998053), FRAC_CONST(0.998058), FRAC_CONST(0.998081), FRAC_CONST(0.998165), FRAC_CONST(0.99844), FRAC_CONST(0.999024), FRAC_CONST(0.99961), FRAC_CONST(0.999885), FRAC_CONST(0.99997), FRAC_CONST(0.999992), FRAC_CONST(0.999998), FRAC_CONST(1) }, - { FRAC_CONST(0.999025), FRAC_CONST(0.999025), FRAC_CONST(0.999028), FRAC_CONST(0.999039), FRAC_CONST(0.999082), FRAC_CONST(0.999219), FRAC_CONST(0.999512), FRAC_CONST(0.999805), FRAC_CONST(0.999943), FRAC_CONST(0.999985), FRAC_CONST(0.999996), FRAC_CONST(0.999999), FRAC_CONST(1) }, - { FRAC_CONST(0.999512), FRAC_CONST(0.999512), FRAC_CONST(0.999514), FRAC_CONST(0.999519), FRAC_CONST(0.999541), FRAC_CONST(0.99961), FRAC_CONST(0.999756), FRAC_CONST(0.999902), FRAC_CONST(0.999971), FRAC_CONST(0.999992), FRAC_CONST(0.999998), FRAC_CONST(1), FRAC_CONST(1) }, - { FRAC_CONST(0.999756), FRAC_CONST(0.999756), FRAC_CONST(0.999757), FRAC_CONST(0.99976), FRAC_CONST(0.99977), FRAC_CONST(0.999805), FRAC_CONST(0.999878), FRAC_CONST(0.999951), FRAC_CONST(0.999986), FRAC_CONST(0.999996), FRAC_CONST(0.999999), FRAC_CONST(1), FRAC_CONST(1) }, - { FRAC_CONST(0.999878), FRAC_CONST(0.999878), FRAC_CONST(0.999878), FRAC_CONST(0.99988), FRAC_CONST(0.999885), FRAC_CONST(0.999902), FRAC_CONST(0.999939), FRAC_CONST(0.999976), FRAC_CONST(0.999993), FRAC_CONST(0.999998), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1) }, - { FRAC_CONST(0.999939), FRAC_CONST(0.999939), FRAC_CONST(0.999939), FRAC_CONST(0.99994), FRAC_CONST(0.999943), FRAC_CONST(0.999951), FRAC_CONST(0.999969), FRAC_CONST(0.999988), FRAC_CONST(0.999996), FRAC_CONST(0.999999), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1) }, - { FRAC_CONST(0.999969), FRAC_CONST(0.99997), FRAC_CONST(0.99997), FRAC_CONST(0.99997), FRAC_CONST(0.999971), FRAC_CONST(0.999976), FRAC_CONST(0.999985), FRAC_CONST(0.999994), FRAC_CONST(0.999998), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1) }, - { FRAC_CONST(0.999985), FRAC_CONST(0.999985), FRAC_CONST(0.999985), FRAC_CONST(0.999985), FRAC_CONST(0.999986), FRAC_CONST(0.999988), FRAC_CONST(0.999992), FRAC_CONST(0.999997), FRAC_CONST(0.999999), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1) }, - { FRAC_CONST(0.999992), FRAC_CONST(0.999992), FRAC_CONST(0.999992), FRAC_CONST(0.999992), FRAC_CONST(0.999993), FRAC_CONST(0.999994), FRAC_CONST(0.999996), FRAC_CONST(0.999998), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1) }, - { FRAC_CONST(0.999996), FRAC_CONST(0.999996), FRAC_CONST(0.999996), FRAC_CONST(0.999996), FRAC_CONST(0.999996), FRAC_CONST(0.999997), FRAC_CONST(0.999998), FRAC_CONST(0.999999), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1) }, - { FRAC_CONST(0.999998), FRAC_CONST(0.999998), FRAC_CONST(0.999998), FRAC_CONST(0.999998), FRAC_CONST(0.999998), FRAC_CONST(0.999998), FRAC_CONST(0.999999), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1) }, - { FRAC_CONST(0.999999), FRAC_CONST(0.999999), FRAC_CONST(0.999999), FRAC_CONST(0.999999), FRAC_CONST(0.999999), FRAC_CONST(0.999999), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1) }, - { FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1) }, - { FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1) }, - { FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1) } -}; - -/* calculates 1/(1+Q) */ -/* [0..1] */ -static real_t calc_Q_div(sbr_info *sbr, uint8_t ch, uint8_t m, uint8_t l) -{ - if (sbr->bs_coupling) - { - /* left channel */ - if ((sbr->Q[0][m][l] < 0 || sbr->Q[0][m][l] > 30) || - (sbr->Q[1][m][l] < 0 || sbr->Q[1][m][l] > 24 /* 2*panOffset(1) */)) - { - return 0; - } else { - /* the pan parameter is always even */ - if (ch == 0) - { - return Q_div_tab_left[sbr->Q[0][m][l]][sbr->Q[1][m][l] >> 1]; - } else { - return Q_div_tab_right[sbr->Q[0][m][l]][sbr->Q[1][m][l] >> 1]; - } - } - } else { - /* no coupling */ - if (sbr->Q[ch][m][l] < 0 || sbr->Q[ch][m][l] > 30) - { - return 0; - } else { - return Q_div_tab[sbr->Q[ch][m][l]]; - } - } -} - -/* table for Q_div2 values when no coupling */ -static const real_t Q_div2_tab[31] = { - FRAC_CONST(0.984615), FRAC_CONST(0.969697), - FRAC_CONST(0.941176), FRAC_CONST(0.888889), - FRAC_CONST(0.8), FRAC_CONST(0.666667), - FRAC_CONST(0.5), FRAC_CONST(0.333333), - FRAC_CONST(0.2), FRAC_CONST(0.111111), - FRAC_CONST(0.0588235), FRAC_CONST(0.030303), - FRAC_CONST(0.0153846), FRAC_CONST(0.00775194), - FRAC_CONST(0.00389105), FRAC_CONST(0.00194932), - FRAC_CONST(0.00097561), FRAC_CONST(0.000488043), - FRAC_CONST(0.000244081), FRAC_CONST(0.000122055), - FRAC_CONST(6.10314E-005), FRAC_CONST(3.05166E-005), - FRAC_CONST(1.52586E-005), FRAC_CONST(7.62934E-006), - FRAC_CONST(3.81468E-006), FRAC_CONST(1.90734E-006), - FRAC_CONST(9.53673E-007), FRAC_CONST(4.76837E-007), - FRAC_CONST(2.38419E-007), FRAC_CONST(1.19209E-007), - FRAC_CONST(5.96046E-008) -}; - -static const real_t Q_div2_tab_left[31][13] = { - { FRAC_CONST(0.0302959), FRAC_CONST(0.111015), FRAC_CONST(0.332468), FRAC_CONST(0.663212), FRAC_CONST(0.882759), FRAC_CONST(0.962406), FRAC_CONST(0.984615), FRAC_CONST(0.990329), FRAC_CONST(0.991768), FRAC_CONST(0.992128), FRAC_CONST(0.992218), FRAC_CONST(0.992241), FRAC_CONST(0.992246) }, - { FRAC_CONST(0.0153809), FRAC_CONST(0.0587695), FRAC_CONST(0.199377), FRAC_CONST(0.496124), FRAC_CONST(0.790123), FRAC_CONST(0.927536), FRAC_CONST(0.969697), FRAC_CONST(0.980843), FRAC_CONST(0.98367), FRAC_CONST(0.984379), FRAC_CONST(0.984556), FRAC_CONST(0.984601), FRAC_CONST(0.984612) }, - { FRAC_CONST(0.00775006), FRAC_CONST(0.0302744), FRAC_CONST(0.110727), FRAC_CONST(0.329897), FRAC_CONST(0.653061), FRAC_CONST(0.864865), FRAC_CONST(0.941176), FRAC_CONST(0.962406), FRAC_CONST(0.967864), FRAC_CONST(0.969238), FRAC_CONST(0.969582), FRAC_CONST(0.969668), FRAC_CONST(0.96969) }, - { FRAC_CONST(0.0038901), FRAC_CONST(0.0153698), FRAC_CONST(0.0586081), FRAC_CONST(0.197531), FRAC_CONST(0.484848), FRAC_CONST(0.761905), FRAC_CONST(0.888889), FRAC_CONST(0.927536), FRAC_CONST(0.937729), FRAC_CONST(0.940312), FRAC_CONST(0.94096), FRAC_CONST(0.941122), FRAC_CONST(0.941163) }, - { FRAC_CONST(0.00194884), FRAC_CONST(0.00774443), FRAC_CONST(0.0301887), FRAC_CONST(0.109589), FRAC_CONST(0.32), FRAC_CONST(0.615385), FRAC_CONST(0.8), FRAC_CONST(0.864865), FRAC_CONST(0.882759), FRAC_CONST(0.887348), FRAC_CONST(0.888503), FRAC_CONST(0.888792), FRAC_CONST(0.888865) }, - { FRAC_CONST(0.000975372), FRAC_CONST(0.00388727), FRAC_CONST(0.0153257), FRAC_CONST(0.057971), FRAC_CONST(0.190476), FRAC_CONST(0.444444), FRAC_CONST(0.666667), FRAC_CONST(0.761905), FRAC_CONST(0.790123), FRAC_CONST(0.797508), FRAC_CONST(0.799375), FRAC_CONST(0.799844), FRAC_CONST(0.799961) }, - { FRAC_CONST(0.000487924), FRAC_CONST(0.00194742), FRAC_CONST(0.00772201), FRAC_CONST(0.0298507), FRAC_CONST(0.105263), FRAC_CONST(0.285714), FRAC_CONST(0.5), FRAC_CONST(0.615385), FRAC_CONST(0.653061), FRAC_CONST(0.663212), FRAC_CONST(0.6658), FRAC_CONST(0.66645), FRAC_CONST(0.666612) }, - { FRAC_CONST(0.000244021), FRAC_CONST(0.000974659), FRAC_CONST(0.00387597), FRAC_CONST(0.0151515), FRAC_CONST(0.0555556), FRAC_CONST(0.166667), FRAC_CONST(0.333333), FRAC_CONST(0.444444), FRAC_CONST(0.484848), FRAC_CONST(0.496124), FRAC_CONST(0.499025), FRAC_CONST(0.499756), FRAC_CONST(0.499939) }, - { FRAC_CONST(0.000122026), FRAC_CONST(0.000487567), FRAC_CONST(0.00194175), FRAC_CONST(0.00763359), FRAC_CONST(0.0285714), FRAC_CONST(0.0909091), FRAC_CONST(0.2), FRAC_CONST(0.285714), FRAC_CONST(0.32), FRAC_CONST(0.329897), FRAC_CONST(0.332468), FRAC_CONST(0.333116), FRAC_CONST(0.333279) }, - { FRAC_CONST(6.10165E-005), FRAC_CONST(0.000243843), FRAC_CONST(0.000971817), FRAC_CONST(0.00383142), FRAC_CONST(0.0144928), FRAC_CONST(0.047619), FRAC_CONST(0.111111), FRAC_CONST(0.166667), FRAC_CONST(0.190476), FRAC_CONST(0.197531), FRAC_CONST(0.199377), FRAC_CONST(0.199844), FRAC_CONST(0.199961) }, - { FRAC_CONST(3.05092E-005), FRAC_CONST(0.000121936), FRAC_CONST(0.000486145), FRAC_CONST(0.00191939), FRAC_CONST(0.00729927), FRAC_CONST(0.0243902), FRAC_CONST(0.0588235), FRAC_CONST(0.0909091), FRAC_CONST(0.105263), FRAC_CONST(0.109589), FRAC_CONST(0.110727), FRAC_CONST(0.111015), FRAC_CONST(0.111087) }, - { FRAC_CONST(1.52548E-005), FRAC_CONST(6.09719E-005), FRAC_CONST(0.000243132), FRAC_CONST(0.000960615), FRAC_CONST(0.003663), FRAC_CONST(0.0123457), FRAC_CONST(0.030303), FRAC_CONST(0.047619), FRAC_CONST(0.0555556), FRAC_CONST(0.057971), FRAC_CONST(0.0586081), FRAC_CONST(0.0587695), FRAC_CONST(0.05881) }, - { FRAC_CONST(7.62747E-006), FRAC_CONST(3.04869E-005), FRAC_CONST(0.000121581), FRAC_CONST(0.000480538), FRAC_CONST(0.00183486), FRAC_CONST(0.00621118), FRAC_CONST(0.0153846), FRAC_CONST(0.0243902), FRAC_CONST(0.0285714), FRAC_CONST(0.0298507), FRAC_CONST(0.0301887), FRAC_CONST(0.0302744), FRAC_CONST(0.0302959) }, - { FRAC_CONST(3.81375E-006), FRAC_CONST(1.52437E-005), FRAC_CONST(6.0794E-005), FRAC_CONST(0.000240327), FRAC_CONST(0.000918274), FRAC_CONST(0.00311526), FRAC_CONST(0.00775194), FRAC_CONST(0.0123457), FRAC_CONST(0.0144928), FRAC_CONST(0.0151515), FRAC_CONST(0.0153257), FRAC_CONST(0.0153698), FRAC_CONST(0.0153809) }, - { FRAC_CONST(1.90688E-006), FRAC_CONST(7.62189E-006), FRAC_CONST(3.03979E-005), FRAC_CONST(0.000120178), FRAC_CONST(0.000459348), FRAC_CONST(0.00156006), FRAC_CONST(0.00389105), FRAC_CONST(0.00621118), FRAC_CONST(0.00729927), FRAC_CONST(0.00763359), FRAC_CONST(0.00772201), FRAC_CONST(0.00774443), FRAC_CONST(0.00775006) }, - { FRAC_CONST(9.53441E-007), FRAC_CONST(3.81096E-006), FRAC_CONST(1.51992E-005), FRAC_CONST(6.00925E-005), FRAC_CONST(0.000229727), FRAC_CONST(0.00078064), FRAC_CONST(0.00194932), FRAC_CONST(0.00311526), FRAC_CONST(0.003663), FRAC_CONST(0.00383142), FRAC_CONST(0.00387597), FRAC_CONST(0.00388727), FRAC_CONST(0.0038901) }, - { FRAC_CONST(4.76721E-007), FRAC_CONST(1.90548E-006), FRAC_CONST(7.59965E-006), FRAC_CONST(3.00472E-005), FRAC_CONST(0.000114877), FRAC_CONST(0.000390472), FRAC_CONST(0.00097561), FRAC_CONST(0.00156006), FRAC_CONST(0.00183486), FRAC_CONST(0.00191939), FRAC_CONST(0.00194175), FRAC_CONST(0.00194742), FRAC_CONST(0.00194884) }, - { FRAC_CONST(2.3836E-007), FRAC_CONST(9.52743E-007), FRAC_CONST(3.79984E-006), FRAC_CONST(1.50238E-005), FRAC_CONST(5.74416E-005), FRAC_CONST(0.000195274), FRAC_CONST(0.000488043), FRAC_CONST(0.00078064), FRAC_CONST(0.000918274), FRAC_CONST(0.000960615), FRAC_CONST(0.000971817), FRAC_CONST(0.000974659), FRAC_CONST(0.000975372) }, - { FRAC_CONST(1.1918E-007), FRAC_CONST(4.76372E-007), FRAC_CONST(1.89992E-006), FRAC_CONST(7.51196E-006), FRAC_CONST(2.87216E-005), FRAC_CONST(9.76467E-005), FRAC_CONST(0.000244081), FRAC_CONST(0.000390472), FRAC_CONST(0.000459348), FRAC_CONST(0.000480538), FRAC_CONST(0.000486145), FRAC_CONST(0.000487567), FRAC_CONST(0.000487924) }, - { FRAC_CONST(5.95901E-008), FRAC_CONST(2.38186E-007), FRAC_CONST(9.49963E-007), FRAC_CONST(3.756E-006), FRAC_CONST(1.4361E-005), FRAC_CONST(4.88257E-005), FRAC_CONST(0.000122055), FRAC_CONST(0.000195274), FRAC_CONST(0.000229727), FRAC_CONST(0.000240327), FRAC_CONST(0.000243132), FRAC_CONST(0.000243843), FRAC_CONST(0.000244021) }, - { FRAC_CONST(2.9795E-008), FRAC_CONST(1.19093E-007), FRAC_CONST(4.74982E-007), FRAC_CONST(1.878E-006), FRAC_CONST(7.18056E-006), FRAC_CONST(2.44135E-005), FRAC_CONST(6.10314E-005), FRAC_CONST(9.76467E-005), FRAC_CONST(0.000114877), FRAC_CONST(0.000120178), FRAC_CONST(0.000121581), FRAC_CONST(0.000121936), FRAC_CONST(0.000122026) }, - { FRAC_CONST(1.48975E-008), FRAC_CONST(5.95465E-008), FRAC_CONST(2.37491E-007), FRAC_CONST(9.39002E-007), FRAC_CONST(3.59029E-006), FRAC_CONST(1.22069E-005), FRAC_CONST(3.05166E-005), FRAC_CONST(4.88257E-005), FRAC_CONST(5.74416E-005), FRAC_CONST(6.00925E-005), FRAC_CONST(6.0794E-005), FRAC_CONST(6.09719E-005), FRAC_CONST(6.10165E-005) }, - { FRAC_CONST(7.44876E-009), FRAC_CONST(2.97732E-008), FRAC_CONST(1.18745E-007), FRAC_CONST(4.69501E-007), FRAC_CONST(1.79515E-006), FRAC_CONST(6.10348E-006), FRAC_CONST(1.52586E-005), FRAC_CONST(2.44135E-005), FRAC_CONST(2.87216E-005), FRAC_CONST(3.00472E-005), FRAC_CONST(3.03979E-005), FRAC_CONST(3.04869E-005), FRAC_CONST(3.05092E-005) }, - { FRAC_CONST(3.72438E-009), FRAC_CONST(1.48866E-008), FRAC_CONST(5.93727E-008), FRAC_CONST(2.34751E-007), FRAC_CONST(8.97575E-007), FRAC_CONST(3.05175E-006), FRAC_CONST(7.62934E-006), FRAC_CONST(1.22069E-005), FRAC_CONST(1.4361E-005), FRAC_CONST(1.50238E-005), FRAC_CONST(1.51992E-005), FRAC_CONST(1.52437E-005), FRAC_CONST(1.52548E-005) }, - { FRAC_CONST(1.86219E-009), FRAC_CONST(7.44331E-009), FRAC_CONST(2.96864E-008), FRAC_CONST(1.17375E-007), FRAC_CONST(4.48788E-007), FRAC_CONST(1.52588E-006), FRAC_CONST(3.81468E-006), FRAC_CONST(6.10348E-006), FRAC_CONST(7.18056E-006), FRAC_CONST(7.51196E-006), FRAC_CONST(7.59965E-006), FRAC_CONST(7.62189E-006), FRAC_CONST(7.62747E-006) }, - { FRAC_CONST(9.31095E-010), FRAC_CONST(3.72166E-009), FRAC_CONST(1.48432E-008), FRAC_CONST(5.86876E-008), FRAC_CONST(2.24394E-007), FRAC_CONST(7.62939E-007), FRAC_CONST(1.90734E-006), FRAC_CONST(3.05175E-006), FRAC_CONST(3.59029E-006), FRAC_CONST(3.756E-006), FRAC_CONST(3.79984E-006), FRAC_CONST(3.81096E-006), FRAC_CONST(3.81375E-006) }, - { FRAC_CONST(4.65548E-010), FRAC_CONST(1.86083E-009), FRAC_CONST(7.42159E-009), FRAC_CONST(2.93438E-008), FRAC_CONST(1.12197E-007), FRAC_CONST(3.8147E-007), FRAC_CONST(9.53673E-007), FRAC_CONST(1.52588E-006), FRAC_CONST(1.79515E-006), FRAC_CONST(1.878E-006), FRAC_CONST(1.89992E-006), FRAC_CONST(1.90548E-006), FRAC_CONST(1.90688E-006) }, - { FRAC_CONST(2.32774E-010), FRAC_CONST(9.30414E-010), FRAC_CONST(3.71079E-009), FRAC_CONST(1.46719E-008), FRAC_CONST(5.60985E-008), FRAC_CONST(1.90735E-007), FRAC_CONST(4.76837E-007), FRAC_CONST(7.62939E-007), FRAC_CONST(8.97575E-007), FRAC_CONST(9.39002E-007), FRAC_CONST(9.49963E-007), FRAC_CONST(9.52743E-007), FRAC_CONST(9.53441E-007) }, - { FRAC_CONST(1.16387E-010), FRAC_CONST(4.65207E-010), FRAC_CONST(1.8554E-009), FRAC_CONST(7.33596E-009), FRAC_CONST(2.80492E-008), FRAC_CONST(9.53674E-008), FRAC_CONST(2.38419E-007), FRAC_CONST(3.8147E-007), FRAC_CONST(4.48788E-007), FRAC_CONST(4.69501E-007), FRAC_CONST(4.74982E-007), FRAC_CONST(4.76372E-007), FRAC_CONST(4.76721E-007) }, - { FRAC_CONST(5.81935E-011), FRAC_CONST(2.32603E-010), FRAC_CONST(9.27699E-010), FRAC_CONST(3.66798E-009), FRAC_CONST(1.40246E-008), FRAC_CONST(4.76837E-008), FRAC_CONST(1.19209E-007), FRAC_CONST(1.90735E-007), FRAC_CONST(2.24394E-007), FRAC_CONST(2.34751E-007), FRAC_CONST(2.37491E-007), FRAC_CONST(2.38186E-007), FRAC_CONST(2.3836E-007) }, - { FRAC_CONST(2.90967E-011), FRAC_CONST(1.16302E-010), FRAC_CONST(4.63849E-010), FRAC_CONST(1.83399E-009), FRAC_CONST(7.01231E-009), FRAC_CONST(2.38419E-008), FRAC_CONST(5.96046E-008), FRAC_CONST(9.53674E-008), FRAC_CONST(1.12197E-007), FRAC_CONST(1.17375E-007), FRAC_CONST(1.18745E-007), FRAC_CONST(1.19093E-007), FRAC_CONST(1.1918E-007) } -}; - -static const real_t Q_div2_tab_right[31][13] = { - { FRAC_CONST(0.992246), FRAC_CONST(0.992241), FRAC_CONST(0.992218), FRAC_CONST(0.992128), FRAC_CONST(0.991768), FRAC_CONST(0.990329), FRAC_CONST(0.984615), FRAC_CONST(0.962406), FRAC_CONST(0.882759), FRAC_CONST(0.663212), FRAC_CONST(0.332468), FRAC_CONST(0.111015), FRAC_CONST(0.0302959) }, - { FRAC_CONST(0.984612), FRAC_CONST(0.984601), FRAC_CONST(0.984556), FRAC_CONST(0.984379), FRAC_CONST(0.98367), FRAC_CONST(0.980843), FRAC_CONST(0.969697), FRAC_CONST(0.927536), FRAC_CONST(0.790123), FRAC_CONST(0.496124), FRAC_CONST(0.199377), FRAC_CONST(0.0587695), FRAC_CONST(0.0153809) }, - { FRAC_CONST(0.96969), FRAC_CONST(0.969668), FRAC_CONST(0.969582), FRAC_CONST(0.969238), FRAC_CONST(0.967864), FRAC_CONST(0.962406), FRAC_CONST(0.941176), FRAC_CONST(0.864865), FRAC_CONST(0.653061), FRAC_CONST(0.329897), FRAC_CONST(0.110727), FRAC_CONST(0.0302744), FRAC_CONST(0.00775006) }, - { FRAC_CONST(0.941163), FRAC_CONST(0.941122), FRAC_CONST(0.94096), FRAC_CONST(0.940312), FRAC_CONST(0.937729), FRAC_CONST(0.927536), FRAC_CONST(0.888889), FRAC_CONST(0.761905), FRAC_CONST(0.484848), FRAC_CONST(0.197531), FRAC_CONST(0.0586081), FRAC_CONST(0.0153698), FRAC_CONST(0.0038901) }, - { FRAC_CONST(0.888865), FRAC_CONST(0.888792), FRAC_CONST(0.888503), FRAC_CONST(0.887348), FRAC_CONST(0.882759), FRAC_CONST(0.864865), FRAC_CONST(0.8), FRAC_CONST(0.615385), FRAC_CONST(0.32), FRAC_CONST(0.109589), FRAC_CONST(0.0301887), FRAC_CONST(0.00774443), FRAC_CONST(0.00194884) }, - { FRAC_CONST(0.799961), FRAC_CONST(0.799844), FRAC_CONST(0.799375), FRAC_CONST(0.797508), FRAC_CONST(0.790123), FRAC_CONST(0.761905), FRAC_CONST(0.666667), FRAC_CONST(0.444444), FRAC_CONST(0.190476), FRAC_CONST(0.057971), FRAC_CONST(0.0153257), FRAC_CONST(0.00388727), FRAC_CONST(0.000975372) }, - { FRAC_CONST(0.666612), FRAC_CONST(0.66645), FRAC_CONST(0.6658), FRAC_CONST(0.663212), FRAC_CONST(0.653061), FRAC_CONST(0.615385), FRAC_CONST(0.5), FRAC_CONST(0.285714), FRAC_CONST(0.105263), FRAC_CONST(0.0298507), FRAC_CONST(0.00772201), FRAC_CONST(0.00194742), FRAC_CONST(0.000487924) }, - { FRAC_CONST(0.499939), FRAC_CONST(0.499756), FRAC_CONST(0.499025), FRAC_CONST(0.496124), FRAC_CONST(0.484848), FRAC_CONST(0.444444), FRAC_CONST(0.333333), FRAC_CONST(0.166667), FRAC_CONST(0.0555556), FRAC_CONST(0.0151515), FRAC_CONST(0.00387597), FRAC_CONST(0.000974659), FRAC_CONST(0.000244021) }, - { FRAC_CONST(0.333279), FRAC_CONST(0.333116), FRAC_CONST(0.332468), FRAC_CONST(0.329897), FRAC_CONST(0.32), FRAC_CONST(0.285714), FRAC_CONST(0.2), FRAC_CONST(0.0909091), FRAC_CONST(0.0285714), FRAC_CONST(0.00763359), FRAC_CONST(0.00194175), FRAC_CONST(0.000487567), FRAC_CONST(0.000122026) }, - { FRAC_CONST(0.199961), FRAC_CONST(0.199844), FRAC_CONST(0.199377), FRAC_CONST(0.197531), FRAC_CONST(0.190476), FRAC_CONST(0.166667), FRAC_CONST(0.111111), FRAC_CONST(0.047619), FRAC_CONST(0.0144928), FRAC_CONST(0.00383142), FRAC_CONST(0.000971817), FRAC_CONST(0.000243843), FRAC_CONST(6.10165E-005) }, - { FRAC_CONST(0.111087), FRAC_CONST(0.111015), FRAC_CONST(0.110727), FRAC_CONST(0.109589), FRAC_CONST(0.105263), FRAC_CONST(0.0909091), FRAC_CONST(0.0588235), FRAC_CONST(0.0243902), FRAC_CONST(0.00729927), FRAC_CONST(0.00191939), FRAC_CONST(0.000486145), FRAC_CONST(0.000121936), FRAC_CONST(3.05092E-005) }, - { FRAC_CONST(0.05881), FRAC_CONST(0.0587695), FRAC_CONST(0.0586081), FRAC_CONST(0.057971), FRAC_CONST(0.0555556), FRAC_CONST(0.047619), FRAC_CONST(0.030303), FRAC_CONST(0.0123457), FRAC_CONST(0.003663), FRAC_CONST(0.000960615), FRAC_CONST(0.000243132), FRAC_CONST(6.09719E-005), FRAC_CONST(1.52548E-005) }, - { FRAC_CONST(0.0302959), FRAC_CONST(0.0302744), FRAC_CONST(0.0301887), FRAC_CONST(0.0298507), FRAC_CONST(0.0285714), FRAC_CONST(0.0243902), FRAC_CONST(0.0153846), FRAC_CONST(0.00621118), FRAC_CONST(0.00183486), FRAC_CONST(0.000480538), FRAC_CONST(0.000121581), FRAC_CONST(3.04869E-005), FRAC_CONST(7.62747E-006) }, - { FRAC_CONST(0.0153809), FRAC_CONST(0.0153698), FRAC_CONST(0.0153257), FRAC_CONST(0.0151515), FRAC_CONST(0.0144928), FRAC_CONST(0.0123457), FRAC_CONST(0.00775194), FRAC_CONST(0.00311526), FRAC_CONST(0.000918274), FRAC_CONST(0.000240327), FRAC_CONST(6.0794E-005), FRAC_CONST(1.52437E-005), FRAC_CONST(3.81375E-006) }, - { FRAC_CONST(0.00775006), FRAC_CONST(0.00774443), FRAC_CONST(0.00772201), FRAC_CONST(0.00763359), FRAC_CONST(0.00729927), FRAC_CONST(0.00621118), FRAC_CONST(0.00389105), FRAC_CONST(0.00156006), FRAC_CONST(0.000459348), FRAC_CONST(0.000120178), FRAC_CONST(3.03979E-005), FRAC_CONST(7.62189E-006), FRAC_CONST(1.90688E-006) }, - { FRAC_CONST(0.0038901), FRAC_CONST(0.00388727), FRAC_CONST(0.00387597), FRAC_CONST(0.00383142), FRAC_CONST(0.003663), FRAC_CONST(0.00311526), FRAC_CONST(0.00194932), FRAC_CONST(0.00078064), FRAC_CONST(0.000229727), FRAC_CONST(6.00925E-005), FRAC_CONST(1.51992E-005), FRAC_CONST(3.81096E-006), FRAC_CONST(9.53441E-007) }, - { FRAC_CONST(0.00194884), FRAC_CONST(0.00194742), FRAC_CONST(0.00194175), FRAC_CONST(0.00191939), FRAC_CONST(0.00183486), FRAC_CONST(0.00156006), FRAC_CONST(0.00097561), FRAC_CONST(0.000390472), FRAC_CONST(0.000114877), FRAC_CONST(3.00472E-005), FRAC_CONST(7.59965E-006), FRAC_CONST(1.90548E-006), FRAC_CONST(4.76721E-007) }, - { FRAC_CONST(0.000975372), FRAC_CONST(0.000974659), FRAC_CONST(0.000971817), FRAC_CONST(0.000960615), FRAC_CONST(0.000918274), FRAC_CONST(0.00078064), FRAC_CONST(0.000488043), FRAC_CONST(0.000195274), FRAC_CONST(5.74416E-005), FRAC_CONST(1.50238E-005), FRAC_CONST(3.79984E-006), FRAC_CONST(9.52743E-007), FRAC_CONST(2.3836E-007) }, - { FRAC_CONST(0.000487924), FRAC_CONST(0.000487567), FRAC_CONST(0.000486145), FRAC_CONST(0.000480538), FRAC_CONST(0.000459348), FRAC_CONST(0.000390472), FRAC_CONST(0.000244081), FRAC_CONST(9.76467E-005), FRAC_CONST(2.87216E-005), FRAC_CONST(7.51196E-006), FRAC_CONST(1.89992E-006), FRAC_CONST(4.76372E-007), FRAC_CONST(1.1918E-007) }, - { FRAC_CONST(0.000244021), FRAC_CONST(0.000243843), FRAC_CONST(0.000243132), FRAC_CONST(0.000240327), FRAC_CONST(0.000229727), FRAC_CONST(0.000195274), FRAC_CONST(0.000122055), FRAC_CONST(4.88257E-005), FRAC_CONST(1.4361E-005), FRAC_CONST(3.756E-006), FRAC_CONST(9.49963E-007), FRAC_CONST(2.38186E-007), FRAC_CONST(5.95901E-008) }, - { FRAC_CONST(0.000122026), FRAC_CONST(0.000121936), FRAC_CONST(0.000121581), FRAC_CONST(0.000120178), FRAC_CONST(0.000114877), FRAC_CONST(9.76467E-005), FRAC_CONST(6.10314E-005), FRAC_CONST(2.44135E-005), FRAC_CONST(7.18056E-006), FRAC_CONST(1.878E-006), FRAC_CONST(4.74982E-007), FRAC_CONST(1.19093E-007), FRAC_CONST(2.9795E-008) }, - { FRAC_CONST(6.10165E-005), FRAC_CONST(6.09719E-005), FRAC_CONST(6.0794E-005), FRAC_CONST(6.00925E-005), FRAC_CONST(5.74416E-005), FRAC_CONST(4.88257E-005), FRAC_CONST(3.05166E-005), FRAC_CONST(1.22069E-005), FRAC_CONST(3.59029E-006), FRAC_CONST(9.39002E-007), FRAC_CONST(2.37491E-007), FRAC_CONST(5.95465E-008), FRAC_CONST(1.48975E-008) }, - { FRAC_CONST(3.05092E-005), FRAC_CONST(3.04869E-005), FRAC_CONST(3.03979E-005), FRAC_CONST(3.00472E-005), FRAC_CONST(2.87216E-005), FRAC_CONST(2.44135E-005), FRAC_CONST(1.52586E-005), FRAC_CONST(6.10348E-006), FRAC_CONST(1.79515E-006), FRAC_CONST(4.69501E-007), FRAC_CONST(1.18745E-007), FRAC_CONST(2.97732E-008), FRAC_CONST(7.44876E-009) }, - { FRAC_CONST(1.52548E-005), FRAC_CONST(1.52437E-005), FRAC_CONST(1.51992E-005), FRAC_CONST(1.50238E-005), FRAC_CONST(1.4361E-005), FRAC_CONST(1.22069E-005), FRAC_CONST(7.62934E-006), FRAC_CONST(3.05175E-006), FRAC_CONST(8.97575E-007), FRAC_CONST(2.34751E-007), FRAC_CONST(5.93727E-008), FRAC_CONST(1.48866E-008), FRAC_CONST(3.72438E-009) }, - { FRAC_CONST(7.62747E-006), FRAC_CONST(7.62189E-006), FRAC_CONST(7.59965E-006), FRAC_CONST(7.51196E-006), FRAC_CONST(7.18056E-006), FRAC_CONST(6.10348E-006), FRAC_CONST(3.81468E-006), FRAC_CONST(1.52588E-006), FRAC_CONST(4.48788E-007), FRAC_CONST(1.17375E-007), FRAC_CONST(2.96864E-008), FRAC_CONST(7.44331E-009), FRAC_CONST(1.86219E-009) }, - { FRAC_CONST(3.81375E-006), FRAC_CONST(3.81096E-006), FRAC_CONST(3.79984E-006), FRAC_CONST(3.756E-006), FRAC_CONST(3.59029E-006), FRAC_CONST(3.05175E-006), FRAC_CONST(1.90734E-006), FRAC_CONST(7.62939E-007), FRAC_CONST(2.24394E-007), FRAC_CONST(5.86876E-008), FRAC_CONST(1.48432E-008), FRAC_CONST(3.72166E-009), FRAC_CONST(9.31095E-010) }, - { FRAC_CONST(1.90688E-006), FRAC_CONST(1.90548E-006), FRAC_CONST(1.89992E-006), FRAC_CONST(1.878E-006), FRAC_CONST(1.79515E-006), FRAC_CONST(1.52588E-006), FRAC_CONST(9.53673E-007), FRAC_CONST(3.8147E-007), FRAC_CONST(1.12197E-007), FRAC_CONST(2.93438E-008), FRAC_CONST(7.42159E-009), FRAC_CONST(1.86083E-009), FRAC_CONST(4.65548E-010) }, - { FRAC_CONST(9.53441E-007), FRAC_CONST(9.52743E-007), FRAC_CONST(9.49963E-007), FRAC_CONST(9.39002E-007), FRAC_CONST(8.97575E-007), FRAC_CONST(7.62939E-007), FRAC_CONST(4.76837E-007), FRAC_CONST(1.90735E-007), FRAC_CONST(5.60985E-008), FRAC_CONST(1.46719E-008), FRAC_CONST(3.71079E-009), FRAC_CONST(9.30414E-010), FRAC_CONST(2.32774E-010) }, - { FRAC_CONST(4.76721E-007), FRAC_CONST(4.76372E-007), FRAC_CONST(4.74982E-007), FRAC_CONST(4.69501E-007), FRAC_CONST(4.48788E-007), FRAC_CONST(3.8147E-007), FRAC_CONST(2.38419E-007), FRAC_CONST(9.53674E-008), FRAC_CONST(2.80492E-008), FRAC_CONST(7.33596E-009), FRAC_CONST(1.8554E-009), FRAC_CONST(4.65207E-010), FRAC_CONST(1.16387E-010) }, - { FRAC_CONST(2.3836E-007), FRAC_CONST(2.38186E-007), FRAC_CONST(2.37491E-007), FRAC_CONST(2.34751E-007), FRAC_CONST(2.24394E-007), FRAC_CONST(1.90735E-007), FRAC_CONST(1.19209E-007), FRAC_CONST(4.76837E-008), FRAC_CONST(1.40246E-008), FRAC_CONST(3.66798E-009), FRAC_CONST(9.27699E-010), FRAC_CONST(2.32603E-010), FRAC_CONST(5.81935E-011) }, - { FRAC_CONST(1.1918E-007), FRAC_CONST(1.19093E-007), FRAC_CONST(1.18745E-007), FRAC_CONST(1.17375E-007), FRAC_CONST(1.12197E-007), FRAC_CONST(9.53674E-008), FRAC_CONST(5.96046E-008), FRAC_CONST(2.38419E-008), FRAC_CONST(7.01231E-009), FRAC_CONST(1.83399E-009), FRAC_CONST(4.63849E-010), FRAC_CONST(1.16302E-010), FRAC_CONST(2.90967E-011) } -}; - -/* calculates Q/(1+Q) */ -/* [0..1] */ -static real_t calc_Q_div2(sbr_info *sbr, uint8_t ch, uint8_t m, uint8_t l) -{ - if (sbr->bs_coupling) - { - if ((sbr->Q[0][m][l] < 0 || sbr->Q[0][m][l] > 30) || - (sbr->Q[1][m][l] < 0 || sbr->Q[1][m][l] > 24 /* 2*panOffset(1) */)) - { - return 0; - } else { - /* the pan parameter is always even */ - if (ch == 0) - { - return Q_div2_tab_left[sbr->Q[0][m][l]][sbr->Q[1][m][l] >> 1]; - } else { - return Q_div2_tab_right[sbr->Q[0][m][l]][sbr->Q[1][m][l] >> 1]; - } - } - } else { - /* no coupling */ - if (sbr->Q[ch][m][l] < 0 || sbr->Q[ch][m][l] > 30) - { - return 0; - } else { - return Q_div2_tab[sbr->Q[ch][m][l]]; - } - } -} - -static const real_t E_deq_tab[64] = { - 64.0f, 128.0f, 256.0f, 512.0f, 1024.0f, 2048.0f, 4096.0f, 8192.0f, - 16384.0f, 32768.0f, 65536.0f, 131072.0f, 262144.0f, 524288.0f, 1.04858E+006f, 2.09715E+006f, - 4.1943E+006f, 8.38861E+006f, 1.67772E+007f, 3.35544E+007f, 6.71089E+007f, 1.34218E+008f, 2.68435E+008f, 5.36871E+008f, - 1.07374E+009f, 2.14748E+009f, 4.29497E+009f, 8.58993E+009f, 1.71799E+010f, 3.43597E+010f, 6.87195E+010f, 1.37439E+011f, - 2.74878E+011f, 5.49756E+011f, 1.09951E+012f, 2.19902E+012f, 4.39805E+012f, 8.79609E+012f, 1.75922E+013f, 3.51844E+013f, - 7.03687E+013f, 1.40737E+014f, 2.81475E+014f, 5.6295E+014f, 1.1259E+015f, 2.2518E+015f, 4.5036E+015f, 9.0072E+015f, - 1.80144E+016f, 3.60288E+016f, 7.20576E+016f, 1.44115E+017f, 2.8823E+017f, 5.76461E+017f, 1.15292E+018f, 2.30584E+018f, - 4.61169E+018f, 9.22337E+018f, 1.84467E+019f, 3.68935E+019f, 7.3787E+019f, 1.47574E+020f, 2.95148E+020f, 5.90296E+020f -}; - -void envelope_noise_dequantisation(sbr_info *sbr, uint8_t ch) -{ - if (sbr->bs_coupling == 0) - { - int16_t exp; - uint8_t l, k; - uint8_t amp = (sbr->amp_res[ch]) ? 0 : 1; - - for (l = 0; l < sbr->L_E[ch]; l++) - { - for (k = 0; k < sbr->n[sbr->f[ch][l]]; k++) - { - /* +6 for the *64 and -10 for the /32 in the synthesis QMF (fixed) - * since this is a energy value: (x/32)^2 = (x^2)/1024 - */ - /* exp = (sbr->E[ch][k][l] >> amp) + 6; */ - exp = (sbr->E[ch][k][l] >> amp); - - if ((exp < 0) || (exp >= 64)) - { - sbr->E_orig[ch][k][l] = 0; - } else { - sbr->E_orig[ch][k][l] = E_deq_tab[exp]; - - /* save half the table size at the cost of 1 multiply */ - if (amp && (sbr->E[ch][k][l] & 1)) - { - sbr->E_orig[ch][k][l] = MUL_C(sbr->E_orig[ch][k][l], COEF_CONST(1.414213562)); - } - } - } - } - - for (l = 0; l < sbr->L_Q[ch]; l++) - { - for (k = 0; k < sbr->N_Q; k++) - { - sbr->Q_div[ch][k][l] = calc_Q_div(sbr, ch, k, l); - sbr->Q_div2[ch][k][l] = calc_Q_div2(sbr, ch, k, l); - } - } - } -} - -static const real_t E_pan_tab[25] = { - FRAC_CONST(0.000244081), FRAC_CONST(0.000488043), - FRAC_CONST(0.00097561), FRAC_CONST(0.00194932), - FRAC_CONST(0.00389105), FRAC_CONST(0.00775194), - FRAC_CONST(0.0153846), FRAC_CONST(0.030303), - FRAC_CONST(0.0588235), FRAC_CONST(0.111111), - FRAC_CONST(0.2), FRAC_CONST(0.333333), - FRAC_CONST(0.5), FRAC_CONST(0.666667), - FRAC_CONST(0.8), FRAC_CONST(0.888889), - FRAC_CONST(0.941176), FRAC_CONST(0.969697), - FRAC_CONST(0.984615), FRAC_CONST(0.992248), - FRAC_CONST(0.996109), FRAC_CONST(0.998051), - FRAC_CONST(0.999024), FRAC_CONST(0.999512), - FRAC_CONST(0.999756) -}; - -void unmap_envelope_noise(sbr_info *sbr) -{ - real_t tmp; - int16_t exp0, exp1; - uint8_t l, k; - uint8_t amp0 = (sbr->amp_res[0]) ? 0 : 1; - uint8_t amp1 = (sbr->amp_res[1]) ? 0 : 1; - - for (l = 0; l < sbr->L_E[0]; l++) - { - for (k = 0; k < sbr->n[sbr->f[0][l]]; k++) - { - /* +6: * 64 ; +1: * 2 ; */ - exp0 = (sbr->E[0][k][l] >> amp0) + 1; - - /* UN_MAP removed: (x / 4096) same as (x >> 12) */ - /* E[1] is always even so no need for compensating the divide by 2 with - * an extra multiplication - */ - /* exp1 = (sbr->E[1][k][l] >> amp1) - 12; */ - exp1 = (sbr->E[1][k][l] >> amp1); - - if ((exp0 < 0) || (exp0 >= 64) || - (exp1 < 0) || (exp1 > 24)) - { - sbr->E_orig[1][k][l] = 0; - sbr->E_orig[0][k][l] = 0; - } else { - tmp = E_deq_tab[exp0]; - if (amp0 && (sbr->E[0][k][l] & 1)) - { - tmp = MUL_C(tmp, COEF_CONST(1.414213562)); - } - - /* panning */ - sbr->E_orig[0][k][l] = MUL_F(tmp, E_pan_tab[exp1]); - sbr->E_orig[1][k][l] = MUL_F(tmp, E_pan_tab[24 - exp1]); - } - } - } - - for (l = 0; l < sbr->L_Q[0]; l++) - { - for (k = 0; k < sbr->N_Q; k++) - { - sbr->Q_div[0][k][l] = calc_Q_div(sbr, 0, k, l); - sbr->Q_div[1][k][l] = calc_Q_div(sbr, 1, k, l); - sbr->Q_div2[0][k][l] = calc_Q_div2(sbr, 0, k, l); - sbr->Q_div2[1][k][l] = calc_Q_div2(sbr, 1, k, l); - } - } -} - -#endif - -#endif diff --git a/apps/codecs/libfaad/sbr_e_nf.h b/apps/codecs/libfaad/sbr_e_nf.h deleted file mode 100644 index 6c8b30f06d..0000000000 --- a/apps/codecs/libfaad/sbr_e_nf.h +++ /dev/null @@ -1,47 +0,0 @@ -/* -** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -** -** Any non-GPL usage of this software or parts of this software is strictly -** forbidden. -** -** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. -** -** $Id$ -**/ - -#ifndef __SBR_E_NF_H__ -#define __SBR_E_NF_H__ - -#ifdef __cplusplus -extern "C" { -#endif - - -void extract_envelope_data(sbr_info *sbr, uint8_t ch); -void extract_noise_floor_data(sbr_info *sbr, uint8_t ch); -#ifndef FIXED_POINT -void envelope_noise_dequantisation(sbr_info *sbr, uint8_t ch); -void unmap_envelope_noise(sbr_info *sbr); -#endif - -#ifdef __cplusplus -} -#endif -#endif - diff --git a/apps/codecs/libfaad/sbr_fbt.c b/apps/codecs/libfaad/sbr_fbt.c deleted file mode 100644 index c685c710d5..0000000000 --- a/apps/codecs/libfaad/sbr_fbt.c +++ /dev/null @@ -1,762 +0,0 @@ -/* -** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -** -** Any non-GPL usage of this software or parts of this software is strictly -** forbidden. -** -** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. -** -** $Id$ -**/ - -/* Calculate frequency band tables */ - -#include "common.h" -#include "structs.h" - -#ifdef SBR_DEC - -#include - -#include "sbr_syntax.h" -#include "sbr_fbt.h" - -/* static function declarations */ -static int32_t find_bands(uint8_t warp, uint8_t bands, uint8_t a0, uint8_t a1); - - -/* calculate the start QMF channel for the master frequency band table */ -/* parameter is also called k0 */ -uint8_t qmf_start_channel(uint8_t bs_start_freq, uint8_t bs_samplerate_mode, - uint32_t sample_rate) -{ - static const uint8_t startMinTable[12] = { 7, 7, 10, 11, 12, 16, 16, - 17, 24, 32, 35, 48 }; - static const uint8_t offsetIndexTable[12] = { 5, 5, 4, 4, 4, 3, 2, 1, 0, - 6, 6, 6 }; - static const int8_t offset[7][16] = { - { -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7 }, - { -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 13 }, - { -5, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 13, 16 }, - { -6, -4, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 13, 16 }, - { -4, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 13, 16, 20 }, - { -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 13, 16, 20, 24 }, - { 0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 13, 16, 20, 24, 28, 33 } - }; - uint8_t startMin = startMinTable[get_sr_index(sample_rate)]; - uint8_t offsetIndex = offsetIndexTable[get_sr_index(sample_rate)]; - -#if 0 /* replaced with table (startMinTable) */ - if (sample_rate >= 64000) - { - startMin = (uint8_t)((5000.*128.)/(float)sample_rate + 0.5); - } else if (sample_rate < 32000) { - startMin = (uint8_t)((3000.*128.)/(float)sample_rate + 0.5); - } else { - startMin = (uint8_t)((4000.*128.)/(float)sample_rate + 0.5); - } -#endif - - if (bs_samplerate_mode) - { - return startMin + offset[offsetIndex][bs_start_freq]; - -#if 0 /* replaced by offsetIndexTable */ - switch (sample_rate) - { - case 16000: - return startMin + offset[0][bs_start_freq]; - case 22050: - return startMin + offset[1][bs_start_freq]; - case 24000: - return startMin + offset[2][bs_start_freq]; - case 32000: - return startMin + offset[3][bs_start_freq]; - default: - if (sample_rate > 64000) - { - return startMin + offset[5][bs_start_freq]; - } else { /* 44100 <= sample_rate <= 64000 */ - return startMin + offset[4][bs_start_freq]; - } - } -#endif - } else { - return startMin + offset[6][bs_start_freq]; - } -} - -static int longcmp(const void *a, const void *b) -{ - return ((int)(*(int32_t*)a - *(int32_t*)b)); -} - -/* calculate the stop QMF channel for the master frequency band table */ -/* parameter is also called k2 */ -uint8_t qmf_stop_channel(uint8_t bs_stop_freq, uint32_t sample_rate, - uint8_t k0) -{ - if (bs_stop_freq == 15) - { - return min(64, k0 * 3); - } else if (bs_stop_freq == 14) { - return min(64, k0 * 2); - } else { - static const uint8_t stopMinTable[12] = { 13, 15, 20, 21, 23, - 32, 32, 35, 48, 64, 70, 96 }; - static const int8_t offset[12][14] = { - { 0, 2, 4, 6, 8, 11, 14, 18, 22, 26, 31, 37, 44, 51 }, - { 0, 2, 4, 6, 8, 11, 14, 18, 22, 26, 31, 36, 42, 49 }, - { 0, 2, 4, 6, 8, 11, 14, 17, 21, 25, 29, 34, 39, 44 }, - { 0, 2, 4, 6, 8, 11, 14, 17, 20, 24, 28, 33, 38, 43 }, - { 0, 2, 4, 6, 8, 11, 14, 17, 20, 24, 28, 32, 36, 41 }, - { 0, 2, 4, 6, 8, 10, 12, 14, 17, 20, 23, 26, 29, 32 }, - { 0, 2, 4, 6, 8, 10, 12, 14, 17, 20, 23, 26, 29, 32 }, - { 0, 1, 3, 5, 7, 9, 11, 13, 15, 17, 20, 23, 26, 29 }, - { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 16 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 0, -1, -2, -3, -4, -5, -6, -6, -6, -6, -6, -6, -6, -6 }, - { 0, -3, -6, -9, -12, -15, -18, -20, -22, -24, -26, -28, -30, -32 } - }; -#if 0 - uint8_t i; - int32_t stopDk[13], stopDk_t[14], k2; -#endif - uint8_t stopMin = stopMinTable[get_sr_index(sample_rate)]; - -#if 0 /* replaced by table lookup */ - if (sample_rate >= 64000) - { - stopMin = (uint8_t)((10000.*128.)/(float)sample_rate + 0.5); - } else if (sample_rate < 32000) { - stopMin = (uint8_t)((6000.*128.)/(float)sample_rate + 0.5); - } else { - stopMin = (uint8_t)((8000.*128.)/(float)sample_rate + 0.5); - } -#endif - -#if 0 /* replaced by table lookup */ - /* diverging power series */ - for (i = 0; i <= 13; i++) - { - stopDk_t[i] = (int32_t)(stopMin*pow(64.0/stopMin, i/13.0) + 0.5); - } - for (i = 0; i < 13; i++) - { - stopDk[i] = stopDk_t[i+1] - stopDk_t[i]; - } - - /* needed? */ - qsort(stopDk, 13, sizeof(stopDk[0]), longcmp); - - k2 = stopMin; - for (i = 0; i < bs_stop_freq; i++) - { - k2 += stopDk[i]; - } - return min(64, k2); -#endif - /* bs_stop_freq <= 13 */ - return min(64, stopMin + offset[get_sr_index(sample_rate)][min(bs_stop_freq, 13)]); - } - - return 0; -} - -/* calculate the master frequency table from k0, k2, bs_freq_scale - and bs_alter_scale - - version for bs_freq_scale = 0 -*/ -uint8_t master_frequency_table_fs0(sbr_info *sbr, uint8_t k0, uint8_t k2, - uint8_t bs_alter_scale) -{ - int8_t incr; - uint8_t k; - uint8_t dk; - uint32_t nrBands, k2Achieved; - int32_t k2Diff, vDk[64] = {0}; - - /* mft only defined for k2 > k0 */ - if (k2 <= k0) - { - sbr->N_master = 0; - return 1; - } - - dk = bs_alter_scale ? 2 : 1; - -#if 0 /* replaced by float-less design */ - nrBands = 2 * (int32_t)((float)(k2-k0)/(dk*2) + (-1+dk)/2.0f); -#else - if (bs_alter_scale) - { - nrBands = (((k2-k0+2)>>2)<<1); - } else { - nrBands = (((k2-k0)>>1)<<1); - } -#endif - nrBands = min(nrBands, 63); - if (nrBands <= 0) - return 1; - - k2Achieved = k0 + nrBands * dk; - k2Diff = k2 - k2Achieved; - for (k = 0; k < nrBands; k++) - vDk[k] = dk; - - if (k2Diff) - { - incr = (k2Diff > 0) ? -1 : 1; - k = (uint8_t) ((k2Diff > 0) ? (nrBands-1) : 0); - - while (k2Diff != 0) - { - vDk[k] -= incr; - k += incr; - k2Diff += incr; - } - } - - sbr->f_master[0] = k0; - for (k = 1; k <= nrBands; k++) - sbr->f_master[k] = (uint8_t)(sbr->f_master[k-1] + vDk[k-1]); - - sbr->N_master = (uint8_t)nrBands; - sbr->N_master = (min(sbr->N_master, 64)); - -#if 0 - printf("f_master[%d]: ", nrBands); - for (k = 0; k <= nrBands; k++) - { - printf("%d ", sbr->f_master[k]); - } - printf("\n"); -#endif - - return 0; -} - -/* - This function finds the number of bands using this formula: - bands * log(a1/a0)/log(2.0) + 0.5 -*/ -static int32_t find_bands(uint8_t warp, uint8_t bands, uint8_t a0, uint8_t a1) -{ -#ifdef FIXED_POINT - /* table with log2() values */ - static const real_t log2Table[65] = { - COEF_CONST(0.0), COEF_CONST(0.0), COEF_CONST(1.0000000000), COEF_CONST(1.5849625007), - COEF_CONST(2.0000000000), COEF_CONST(2.3219280949), COEF_CONST(2.5849625007), COEF_CONST(2.8073549221), - COEF_CONST(3.0000000000), COEF_CONST(3.1699250014), COEF_CONST(3.3219280949), COEF_CONST(3.4594316186), - COEF_CONST(3.5849625007), COEF_CONST(3.7004397181), COEF_CONST(3.8073549221), COEF_CONST(3.9068905956), - COEF_CONST(4.0000000000), COEF_CONST(4.0874628413), COEF_CONST(4.1699250014), COEF_CONST(4.2479275134), - COEF_CONST(4.3219280949), COEF_CONST(4.3923174228), COEF_CONST(4.4594316186), COEF_CONST(4.5235619561), - COEF_CONST(4.5849625007), COEF_CONST(4.6438561898), COEF_CONST(4.7004397181), COEF_CONST(4.7548875022), - COEF_CONST(4.8073549221), COEF_CONST(4.8579809951), COEF_CONST(4.9068905956), COEF_CONST(4.9541963104), - COEF_CONST(5.0000000000), COEF_CONST(5.0443941194), COEF_CONST(5.0874628413), COEF_CONST(5.1292830169), - COEF_CONST(5.1699250014), COEF_CONST(5.2094533656), COEF_CONST(5.2479275134), COEF_CONST(5.2854022189), - COEF_CONST(5.3219280949), COEF_CONST(5.3575520046), COEF_CONST(5.3923174228), COEF_CONST(5.4262647547), - COEF_CONST(5.4594316186), COEF_CONST(5.4918530963), COEF_CONST(5.5235619561), COEF_CONST(5.5545888517), - COEF_CONST(5.5849625007), COEF_CONST(5.6147098441), COEF_CONST(5.6438561898), COEF_CONST(5.6724253420), - COEF_CONST(5.7004397181), COEF_CONST(5.7279204546), COEF_CONST(5.7548875022), COEF_CONST(5.7813597135), - COEF_CONST(5.8073549221), COEF_CONST(5.8328900142), COEF_CONST(5.8579809951), COEF_CONST(5.8826430494), - COEF_CONST(5.9068905956), COEF_CONST(5.9307373376), COEF_CONST(5.9541963104), COEF_CONST(5.9772799235), - COEF_CONST(6.0) - }; - real_t r0 = log2Table[a0]; /* coef */ - real_t r1 = log2Table[a1]; /* coef */ - real_t r2 = (r1 - r0); /* coef */ - - if (warp) - r2 = MUL_C(r2, COEF_CONST(1.0/1.3)); - - /* convert r2 to real and then multiply and round */ - r2 = (r2 >> (COEF_BITS-REAL_BITS)) * bands + (1<<(REAL_BITS-1)); - - return (r2 >> REAL_BITS); -#else - real_t div = (real_t)log(2.0); - if (warp) div *= (real_t)1.3; - - return (int32_t)(bands * log((float)a1/(float)a0)/div + 0.5); -#endif -} - -static real_t find_initial_power(uint8_t bands, uint8_t a0, uint8_t a1) -{ -#ifdef FIXED_POINT - /* table with log() values */ - static const real_t logTable[65] = { - COEF_CONST(0.0), COEF_CONST(0.0), COEF_CONST(0.6931471806), COEF_CONST(1.0986122887), - COEF_CONST(1.3862943611), COEF_CONST(1.6094379124), COEF_CONST(1.7917594692), COEF_CONST(1.9459101491), - COEF_CONST(2.0794415417), COEF_CONST(2.1972245773), COEF_CONST(2.3025850930), COEF_CONST(2.3978952728), - COEF_CONST(2.4849066498), COEF_CONST(2.5649493575), COEF_CONST(2.6390573296), COEF_CONST(2.7080502011), - COEF_CONST(2.7725887222), COEF_CONST(2.8332133441), COEF_CONST(2.8903717579), COEF_CONST(2.9444389792), - COEF_CONST(2.9957322736), COEF_CONST(3.0445224377), COEF_CONST(3.0910424534), COEF_CONST(3.1354942159), - COEF_CONST(3.1780538303), COEF_CONST(3.2188758249), COEF_CONST(3.2580965380), COEF_CONST(3.2958368660), - COEF_CONST(3.3322045102), COEF_CONST(3.3672958300), COEF_CONST(3.4011973817), COEF_CONST(3.4339872045), - COEF_CONST(3.4657359028), COEF_CONST(3.4965075615), COEF_CONST(3.5263605246), COEF_CONST(3.5553480615), - COEF_CONST(3.5835189385), COEF_CONST(3.6109179126), COEF_CONST(3.6375861597), COEF_CONST(3.6635616461), - COEF_CONST(3.6888794541), COEF_CONST(3.7135720667), COEF_CONST(3.7376696183), COEF_CONST(3.7612001157), - COEF_CONST(3.7841896339), COEF_CONST(3.8066624898), COEF_CONST(3.8286413965), COEF_CONST(3.8501476017), - COEF_CONST(3.8712010109), COEF_CONST(3.8918202981), COEF_CONST(3.9120230054), COEF_CONST(3.9318256327), - COEF_CONST(3.9512437186), COEF_CONST(3.9702919136), COEF_CONST(3.9889840466), COEF_CONST(4.0073331852), - COEF_CONST(4.0253516907), COEF_CONST(4.0430512678), COEF_CONST(4.0604430105), COEF_CONST(4.0775374439), - COEF_CONST(4.0943445622), COEF_CONST(4.1108738642), COEF_CONST(4.1271343850), COEF_CONST(4.1431347264), - COEF_CONST(4.158883083) - }; - /* standard Taylor polynomial coefficients for exp(x) around 0 */ - /* a polynomial around x=1 is more precise, as most values are around 1.07, - but this is just fine already */ - static const real_t c1 = COEF_CONST(1.0); - static const real_t c2 = COEF_CONST(1.0/2.0); - static const real_t c3 = COEF_CONST(1.0/6.0); - static const real_t c4 = COEF_CONST(1.0/24.0); - - real_t r0 = logTable[a0]; /* coef */ - real_t r1 = logTable[a1]; /* coef */ - real_t r2 = (r1 - r0) / bands; /* coef */ - real_t rexp = c1 + MUL_C((c1 + MUL_C((c2 + MUL_C((c3 + MUL_C(c4,r2)), r2)), r2)), r2); - - return (rexp >> (COEF_BITS-REAL_BITS)); /* real */ -#else - return (real_t)pow((real_t)a1/(real_t)a0, 1.0/(real_t)bands); -#endif -} - -/* - version for bs_freq_scale > 0 -*/ -uint8_t master_frequency_table(sbr_info *sbr, uint8_t k0, uint8_t k2, - uint8_t bs_freq_scale, uint8_t bs_alter_scale) -{ - uint8_t k, bands, twoRegions; - uint8_t k1; - uint8_t nrBand0, nrBand1; - int32_t vDk0[64] = {0}, vDk1[64] = {0}; - int32_t vk0[64] = {0}, vk1[64] = {0}; - uint8_t temp1[] = { 6, 5, 4 }; - real_t q, qk; - int32_t A_1; -#ifdef FIXED_POINT - real_t rk2, rk0; -#endif - - (void)bs_alter_scale; - /* mft only defined for k2 > k0 */ - if (k2 <= k0) - { - sbr->N_master = 0; - return 1; - } - - bands = temp1[bs_freq_scale-1]; - -#ifdef FIXED_POINT - rk0 = (real_t)k0 << REAL_BITS; - rk2 = (real_t)k2 << REAL_BITS; - if (rk2 > MUL_C(rk0, COEF_CONST(2.2449))) -#else - if ((float)k2/(float)k0 > 2.2449) -#endif - { - twoRegions = 1; - k1 = k0 << 1; - } else { - twoRegions = 0; - k1 = k2; - } - - nrBand0 = (uint8_t)(2 * find_bands(0, bands, k0, k1)); - nrBand0 = min(nrBand0, 63); - if (nrBand0 <= 0) - return 1; - - q = find_initial_power(nrBand0, k0, k1); -#ifdef FIXED_POINT - qk = (real_t)k0 << REAL_BITS; - //A_1 = (int32_t)((qk + REAL_CONST(0.5)) >> REAL_BITS); - A_1 = k0; -#else - qk = REAL_CONST(k0); - A_1 = (int32_t)(qk + .5); -#endif - for (k = 0; k <= nrBand0; k++) - { - int32_t A_0 = A_1; -#ifdef FIXED_POINT - qk = MUL_R(qk,q); - A_1 = (int32_t)((qk + REAL_CONST(0.5)) >> REAL_BITS); -#else - qk *= q; - A_1 = (int32_t)(qk + 0.5); -#endif - vDk0[k] = A_1 - A_0; - } - - /* needed? */ - qsort(vDk0, nrBand0, sizeof(vDk0[0]), longcmp); - - vk0[0] = k0; - for (k = 1; k <= nrBand0; k++) - { - vk0[k] = vk0[k-1] + vDk0[k-1]; - if (vDk0[k-1] == 0) - return 1; - } - - if (!twoRegions) - { - for (k = 0; k <= nrBand0; k++) - sbr->f_master[k] = (uint8_t) vk0[k]; - - sbr->N_master = nrBand0; - sbr->N_master = min(sbr->N_master, 64); - return 0; - } - - nrBand1 = (uint8_t)(2 * find_bands(1 /* warped */, bands, k1, k2)); - nrBand1 = min(nrBand1, 63); - - q = find_initial_power(nrBand1, k1, k2); -#ifdef FIXED_POINT - qk = (real_t)k1 << REAL_BITS; - //A_1 = (int32_t)((qk + REAL_CONST(0.5)) >> REAL_BITS); - A_1 = k1; -#else - qk = REAL_CONST(k1); - A_1 = (int32_t)(qk + .5); -#endif - for (k = 0; k <= nrBand1 - 1; k++) - { - int32_t A_0 = A_1; -#ifdef FIXED_POINT - qk = MUL_R(qk,q); - A_1 = (int32_t)((qk + REAL_CONST(0.5)) >> REAL_BITS); -#else - qk *= q; - A_1 = (int32_t)(qk + 0.5); -#endif - vDk1[k] = A_1 - A_0; - } - - if (vDk1[0] < vDk0[nrBand0 - 1]) - { - int32_t change; - - /* needed? */ - qsort(vDk1, nrBand1 + 1, sizeof(vDk1[0]), longcmp); - change = vDk0[nrBand0 - 1] - vDk1[0]; - vDk1[0] = vDk0[nrBand0 - 1]; - vDk1[nrBand1 - 1] = vDk1[nrBand1 - 1] - change; - } - - /* needed? */ - qsort(vDk1, nrBand1, sizeof(vDk1[0]), longcmp); - vk1[0] = k1; - for (k = 1; k <= nrBand1; k++) - { - vk1[k] = vk1[k-1] + vDk1[k-1]; - if (vDk1[k-1] == 0) - return 1; - } - - sbr->N_master = nrBand0 + nrBand1; - sbr->N_master = min(sbr->N_master, 64); - for (k = 0; k <= nrBand0; k++) - { - sbr->f_master[k] = (uint8_t) vk0[k]; - } - for (k = nrBand0 + 1; k <= sbr->N_master; k++) - { - sbr->f_master[k] = (uint8_t) vk1[k - nrBand0]; - } - -#if 0 - printf("f_master[%d]: ", sbr->N_master); - for (k = 0; k <= sbr->N_master; k++) - { - printf("%d ", sbr->f_master[k]); - } - printf("\n"); -#endif - - return 0; -} - -/* calculate the derived frequency border tables from f_master */ -uint8_t derived_frequency_table(sbr_info *sbr, uint8_t bs_xover_band, - uint8_t k2) -{ - uint8_t k, i = 0; - uint32_t minus; - - /* The following relation shall be satisfied: bs_xover_band < N_Master */ - if (sbr->N_master <= bs_xover_band) - return 1; - - sbr->N_high = sbr->N_master - bs_xover_band; - sbr->N_low = (sbr->N_high>>1) + (sbr->N_high - ((sbr->N_high>>1)<<1)); - - sbr->n[0] = sbr->N_low; - sbr->n[1] = sbr->N_high; - - for (k = 0; k <= sbr->N_high; k++) - { - sbr->f_table_res[HI_RES][k] = sbr->f_master[k + bs_xover_band]; - } - - sbr->M = sbr->f_table_res[HI_RES][sbr->N_high] - sbr->f_table_res[HI_RES][0]; - sbr->kx = sbr->f_table_res[HI_RES][0]; - if (sbr->kx > 32) - return 1; - if (sbr->kx + sbr->M > 64) - return 1; - - minus = (sbr->N_high & 1) ? 1 : 0; - - for (k = 0; k <= sbr->N_low; k++) - { - if (k == 0) - i = 0; - else - i = (uint8_t)(2*k - minus); - sbr->f_table_res[LO_RES][k] = sbr->f_table_res[HI_RES][i]; - } - -#if 0 - printf("bs_freq_scale: %d\n", sbr->bs_freq_scale); - printf("bs_limiter_bands: %d\n", sbr->bs_limiter_bands); - printf("f_table_res[HI_RES][%d]: ", sbr->N_high); - for (k = 0; k <= sbr->N_high; k++) - { - printf("%d ", sbr->f_table_res[HI_RES][k]); - } - printf("\n"); -#endif -#if 0 - printf("f_table_res[LO_RES][%d]: ", sbr->N_low); - for (k = 0; k <= sbr->N_low; k++) - { - printf("%d ", sbr->f_table_res[LO_RES][k]); - } - printf("\n"); -#endif - - sbr->N_Q = 0; - if (sbr->bs_noise_bands == 0) - { - sbr->N_Q = 1; - } else { -#if 0 - sbr->N_Q = max(1, (int32_t)(sbr->bs_noise_bands*(log(k2/(float)sbr->kx)/log(2.0)) + 0.5)); -#else - sbr->N_Q = (uint8_t)(max(1, find_bands(0, sbr->bs_noise_bands, sbr->kx, k2))); -#endif - sbr->N_Q = min(5, sbr->N_Q); - } - - for (k = 0; k <= sbr->N_Q; k++) - { - if (k == 0) - { - i = 0; - } else { - /* i = i + (int32_t)((sbr->N_low - i)/(sbr->N_Q + 1 - k)); */ - i = i + (sbr->N_low - i)/(sbr->N_Q + 1 - k); - } - sbr->f_table_noise[k] = sbr->f_table_res[LO_RES][i]; - } - - /* build table for mapping k to g in hf patching */ - for (k = 0; k < 64; k++) - { - uint8_t g; - for (g = 0; g < sbr->N_Q; g++) - { - if ((sbr->f_table_noise[g] <= k) && - (k < sbr->f_table_noise[g+1])) - { - sbr->table_map_k_to_g[k] = g; - break; - } - } - } - -#if 0 - printf("f_table_noise[%d]: ", sbr->N_Q); - for (k = 0; k <= sbr->N_Q; k++) - { - printf("%d ", sbr->f_table_noise[k] - sbr->kx); - } - printf("\n"); -#endif - - return 0; -} - -/* TODO: blegh, ugly */ -/* Modified to calculate for all possible bs_limiter_bands always - * This reduces the number calls to this functions needed (now only on - * header reset) - */ -void limiter_frequency_table(sbr_info *sbr) -{ -#if 0 - static const real_t limiterBandsPerOctave[] = { REAL_CONST(1.2), - REAL_CONST(2), REAL_CONST(3) }; -#else - static const real_t limiterBandsCompare[] = { REAL_CONST(1.327152), - REAL_CONST(1.185093), REAL_CONST(1.119872) }; -#endif - uint8_t k, s; - int8_t nrLim; -#if 0 - real_t limBands; -#endif - - sbr->f_table_lim[0][0] = sbr->f_table_res[LO_RES][0] - sbr->kx; - sbr->f_table_lim[0][1] = sbr->f_table_res[LO_RES][sbr->N_low] - sbr->kx; - sbr->N_L[0] = 1; - -#if 0 - printf("f_table_lim[%d][%d]: ", 0, sbr->N_L[0]); - for (k = 0; k <= sbr->N_L[0]; k++) - { - printf("%d ", sbr->f_table_lim[0][k]); - } - printf("\n"); -#endif - - for (s = 1; s < 4; s++) - { - int32_t limTable[100 /*TODO*/] = {0}; - uint8_t patchBorders[64/*??*/] = {0}; - -#if 0 - limBands = limiterBandsPerOctave[s - 1]; -#endif - - patchBorders[0] = sbr->kx; - for (k = 1; k <= sbr->noPatches; k++) - { - patchBorders[k] = patchBorders[k-1] + sbr->patchNoSubbands[k-1]; - } - - for (k = 0; k <= sbr->N_low; k++) - { - limTable[k] = sbr->f_table_res[LO_RES][k]; - } - for (k = 1; k < sbr->noPatches; k++) - { - limTable[k+sbr->N_low] = patchBorders[k]; - } - - /* needed */ - qsort(limTable, sbr->noPatches + sbr->N_low, sizeof(limTable[0]), longcmp); - k = 1; - nrLim = sbr->noPatches + sbr->N_low - 1; - - if (nrLim < 0) // TODO: BIG FAT PROBLEM - return; - -restart: - if (k <= nrLim) - { - real_t nOctaves; - - if (limTable[k-1] != 0) -#if 0 - nOctaves = REAL_CONST(log((float)limTable[k]/(float)limTable[k-1])/log(2.0)); -#else -#ifdef FIXED_POINT - nOctaves = DIV_R((limTable[k]<noPatches; i++) - { - if (limTable[k] == patchBorders[i]) - found = 1; - } - if (found) - { - found2 = 0; - for (i = 0; i <= sbr->noPatches; i++) - { - if (limTable[k-1] == patchBorders[i]) - found2 = 1; - } - if (found2) - { - k++; - goto restart; - } else { - /* remove (k-1)th element */ - limTable[k-1] = sbr->f_table_res[LO_RES][sbr->N_low]; - qsort(limTable, sbr->noPatches + sbr->N_low, sizeof(limTable[0]), longcmp); - nrLim--; - goto restart; - } - } - } - /* remove kth element */ - limTable[k] = sbr->f_table_res[LO_RES][sbr->N_low]; - qsort(limTable, nrLim, sizeof(limTable[0]), longcmp); - nrLim--; - goto restart; - } else { - k++; - goto restart; - } - } - - sbr->N_L[s] = nrLim; - for (k = 0; k <= nrLim; k++) - { - sbr->f_table_lim[s][k] = limTable[k] - sbr->kx; - } - -#if 0 - printf("f_table_lim[%d][%d]: ", s, sbr->N_L[s]); - for (k = 0; k <= sbr->N_L[s]; k++) - { - printf("%d ", sbr->f_table_lim[s][k]); - } - printf("\n"); -#endif - } -} - -#endif diff --git a/apps/codecs/libfaad/sbr_fbt.h b/apps/codecs/libfaad/sbr_fbt.h deleted file mode 100644 index ac25335268..0000000000 --- a/apps/codecs/libfaad/sbr_fbt.h +++ /dev/null @@ -1,52 +0,0 @@ -/* -** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -** -** Any non-GPL usage of this software or parts of this software is strictly -** forbidden. -** -** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. -** -** $Id$ -**/ - -#ifndef __SBR_FBT_H__ -#define __SBR_FBT_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -uint8_t qmf_start_channel(uint8_t bs_start_freq, uint8_t bs_samplerate_mode, - uint32_t sample_rate); -uint8_t qmf_stop_channel(uint8_t bs_stop_freq, uint32_t sample_rate, - uint8_t k0); -uint8_t master_frequency_table_fs0(sbr_info *sbr, uint8_t k0, uint8_t k2, - uint8_t bs_alter_scale); -uint8_t master_frequency_table(sbr_info *sbr, uint8_t k0, uint8_t k2, - uint8_t bs_freq_scale, uint8_t bs_alter_scale); -uint8_t derived_frequency_table(sbr_info *sbr, uint8_t bs_xover_band, - uint8_t k2); -void limiter_frequency_table(sbr_info *sbr); - - -#ifdef __cplusplus -} -#endif -#endif - diff --git a/apps/codecs/libfaad/sbr_hfadj.c b/apps/codecs/libfaad/sbr_hfadj.c deleted file mode 100644 index b562bf904a..0000000000 --- a/apps/codecs/libfaad/sbr_hfadj.c +++ /dev/null @@ -1,1631 +0,0 @@ -/* -** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -** -** Any non-GPL usage of this software or parts of this software is strictly -** forbidden. -** -** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. -** -** $Id$ -**/ - -/* High Frequency adjustment */ - -#include "common.h" -#include "structs.h" - -#ifdef SBR_DEC - -#include "sbr_syntax.h" -#include "sbr_hfadj.h" - -#include "sbr_noise.h" - -#ifdef FIXED_POINT -#define REAL_UPSCALE(A) ((A)<>REAL_BITS) -#else -#define REAL_UPSCALE(A) (A) -#define REAL_DOWNSCALE(A) (A) -#endif - -/* static function declarations */ -static void estimate_current_envelope(sbr_info *sbr, sbr_hfadj_info *adj, - qmf_t Xsbr[MAX_NTSRHFG][64], uint8_t ch); -static void calculate_gain(sbr_info *sbr, sbr_hfadj_info *adj, uint8_t ch); -#ifdef SBR_LOW_POWER -static void calc_gain_groups(sbr_info *sbr, sbr_hfadj_info *adj, real_t *deg, uint8_t ch); -static void aliasing_reduction(sbr_info *sbr, sbr_hfadj_info *adj, real_t *deg, uint8_t ch); -#endif -static void hf_assembly(sbr_info *sbr, sbr_hfadj_info *adj, qmf_t Xsbr[MAX_NTSRHFG][64], uint8_t ch); - - -void hf_adjustment(sbr_info *sbr, qmf_t Xsbr[MAX_NTSRHFG][64] -#ifdef SBR_LOW_POWER - ,real_t *deg /* aliasing degree */ -#endif - ,uint8_t ch) -{ - sbr_hfadj_info adj MEM_ALIGN_ATTR; - - memset(&adj,0,sizeof(adj)); - if (sbr->bs_frame_class[ch] == FIXFIX) - { - sbr->l_A[ch] = -1; - } else if (sbr->bs_frame_class[ch] == VARFIX) { - if (sbr->bs_pointer[ch] > 1) - sbr->l_A[ch] = -1; - else - sbr->l_A[ch] = sbr->bs_pointer[ch] - 1; - } else { - if (sbr->bs_pointer[ch] == 0) - sbr->l_A[ch] = -1; - else - sbr->l_A[ch] = sbr->L_E[ch] + 1 - sbr->bs_pointer[ch]; - } - - estimate_current_envelope(sbr, &adj, Xsbr, ch); - - calculate_gain(sbr, &adj, ch); - -#ifdef SBR_LOW_POWER - calc_gain_groups(sbr, &adj, deg, ch); - aliasing_reduction(sbr, &adj, deg, ch); -#endif - - hf_assembly(sbr, &adj, Xsbr, ch); -} - -static uint8_t get_S_mapped(sbr_info *sbr, uint8_t ch, uint8_t l, uint8_t current_band) -{ - if (sbr->f[ch][l] == HI_RES) - { - /* in case of using f_table_high we just have 1 to 1 mapping - * from bs_add_harmonic[l][k] - */ - if ((l >= sbr->l_A[ch]) || - (sbr->bs_add_harmonic_prev[ch][current_band] && sbr->bs_add_harmonic_flag_prev[ch])) - { - return sbr->bs_add_harmonic[ch][current_band]; - } - } else { - uint8_t b, lb, ub; - - /* in case of f_table_low we check if any of the HI_RES bands - * within this LO_RES band has bs_add_harmonic[l][k] turned on - * (note that borders in the LO_RES table are also present in - * the HI_RES table) - */ - - /* find first HI_RES band in current LO_RES band */ - lb = 2 * (current_band ) - ((sbr->N_high & 1) ? 1 : 0); - /* find first HI_RES band in next LO_RES band */ - ub = 2 * (current_band+1) - ((sbr->N_high & 1) ? 1 : 0); - - /* check all HI_RES bands in current LO_RES band for sinusoid */ - for (b = lb; b < ub; b++) - { - if ((l >= sbr->l_A[ch]) || - (sbr->bs_add_harmonic_prev[ch][b] && sbr->bs_add_harmonic_flag_prev[ch])) - { - if (sbr->bs_add_harmonic[ch][b] == 1) - return 1; - } - } - } - - return 0; -} - -static void estimate_current_envelope(sbr_info *sbr, sbr_hfadj_info *adj, - qmf_t Xsbr[MAX_NTSRHFG][64], uint8_t ch) -{ - uint8_t m, l, j, k, k_l, k_h, p; - real_t nrg, div, tmp; - - (void)adj; - if (sbr->bs_interpol_freq == 1) - { - for (l = 0; l < sbr->L_E[ch]; l++) - { - uint8_t i, l_i, u_i; - - l_i = sbr->t_E[ch][l]; - u_i = sbr->t_E[ch][l+1]; - - div = (real_t)(u_i - l_i); - - for (m = 0; m < sbr->M; m++) - { - nrg = 0; - - for (i = l_i + sbr->tHFAdj; i < u_i + sbr->tHFAdj; i++) - { - tmp = QMF_RE(Xsbr[i][m + sbr->kx]); - nrg += MUL_R(tmp, REAL_DOWNSCALE(tmp)); -#ifndef SBR_LOW_POWER - tmp = QMF_IM(Xsbr[i][m + sbr->kx]); - nrg += MUL_R(tmp, REAL_DOWNSCALE(tmp)); -#endif - } - - sbr->E_curr[ch][m][l] = nrg / div; -#ifdef SBR_LOW_POWER - sbr->E_curr[ch][m][l] *= 2; -#endif - } - } - } else { - for (l = 0; l < sbr->L_E[ch]; l++) - { - for (p = 0; p < sbr->n[sbr->f[ch][l]]; p++) - { - k_l = sbr->f_table_res[sbr->f[ch][l]][p]; - k_h = sbr->f_table_res[sbr->f[ch][l]][p+1]; - - for (k = k_l; k < k_h; k++) - { - uint8_t i, l_i, u_i; - nrg = 0; - - l_i = sbr->t_E[ch][l]; - u_i = sbr->t_E[ch][l+1]; - - div = (real_t)((u_i - l_i)*(k_h - k_l)); - - for (i = l_i + sbr->tHFAdj; i < u_i + sbr->tHFAdj; i++) - { - for (j = k_l; j < k_h; j++) - { - tmp = QMF_RE(Xsbr[i][j]); - nrg += MUL_R(tmp, REAL_DOWNSCALE(tmp)); -#ifndef SBR_LOW_POWER - tmp = QMF_IM(Xsbr[i][j]); - nrg += MUL_R(tmp, REAL_DOWNSCALE(tmp)); -#endif - } - } - - sbr->E_curr[ch][k - sbr->kx][l] = nrg / div; -#ifdef SBR_LOW_POWER - sbr->E_curr[ch][k - sbr->kx][l] *= 2; -#endif - } - } - } - } -} - -#ifdef FIXED_POINT -#define EPS (1) /* smallest number available in fixed point */ -#else -#define EPS (1e-12) -#endif - - - -#ifdef FIXED_POINT - -/* log2 values of [0..63] */ -static const real_t log2_int_tab[] = { - LOG2_MIN_INF , REAL_CONST(0.000000000000000), REAL_CONST(1.000000000000000), REAL_CONST(1.584962500721156), - REAL_CONST(2.000000000000000), REAL_CONST(2.321928094887362), REAL_CONST(2.584962500721156), REAL_CONST(2.807354922057604), - REAL_CONST(3.000000000000000), REAL_CONST(3.169925001442313), REAL_CONST(3.321928094887363), REAL_CONST(3.459431618637297), - REAL_CONST(3.584962500721156), REAL_CONST(3.700439718141092), REAL_CONST(3.807354922057604), REAL_CONST(3.906890595608519), - REAL_CONST(4.000000000000000), REAL_CONST(4.087462841250339), REAL_CONST(4.169925001442312), REAL_CONST(4.247927513443585), - REAL_CONST(4.321928094887362), REAL_CONST(4.392317422778761), REAL_CONST(4.459431618637297), REAL_CONST(4.523561956057013), - REAL_CONST(4.584962500721156), REAL_CONST(4.643856189774724), REAL_CONST(4.700439718141093), REAL_CONST(4.754887502163468), - REAL_CONST(4.807354922057604), REAL_CONST(4.857980995127572), REAL_CONST(4.906890595608519), REAL_CONST(4.954196310386875), - REAL_CONST(5.000000000000000), REAL_CONST(5.044394119358453), REAL_CONST(5.087462841250340), REAL_CONST(5.129283016944966), - REAL_CONST(5.169925001442312), REAL_CONST(5.209453365628949), REAL_CONST(5.247927513443585), REAL_CONST(5.285402218862248), - REAL_CONST(5.321928094887363), REAL_CONST(5.357552004618084), REAL_CONST(5.392317422778761), REAL_CONST(5.426264754702098), - REAL_CONST(5.459431618637297), REAL_CONST(5.491853096329675), REAL_CONST(5.523561956057013), REAL_CONST(5.554588851677637), - REAL_CONST(5.584962500721156), REAL_CONST(5.614709844115208), REAL_CONST(5.643856189774724), REAL_CONST(5.672425341971495), - REAL_CONST(5.700439718141093), REAL_CONST(5.727920454563200), REAL_CONST(5.754887502163469), REAL_CONST(5.781359713524660), - REAL_CONST(5.807354922057605), REAL_CONST(5.832890014164742), REAL_CONST(5.857980995127572), REAL_CONST(5.882643049361842), - REAL_CONST(5.906890595608518), REAL_CONST(5.930737337562887), REAL_CONST(5.954196310386876), REAL_CONST(5.977279923499916) -}; - -static const real_t pan_log2_tab[] = { - REAL_CONST(1.000000000000000), REAL_CONST(0.584962500721156), REAL_CONST(0.321928094887362), REAL_CONST(0.169925001442312), REAL_CONST(0.087462841250339), - REAL_CONST(0.044394119358453), REAL_CONST(0.022367813028455), REAL_CONST(0.011227255423254), REAL_CONST(0.005624549193878), REAL_CONST(0.002815015607054), - REAL_CONST(0.001408194392808), REAL_CONST(0.000704269011247), REAL_CONST(0.000352177480301), REAL_CONST(0.000176099486443), REAL_CONST(0.000088052430122), - REAL_CONST(0.000044026886827), REAL_CONST(0.000022013611360), REAL_CONST(0.000011006847667) -}; - -static real_t find_log2_E(sbr_info *sbr, uint8_t k, uint8_t l, uint8_t ch) -{ - /* check for coupled energy/noise data */ - if (sbr->bs_coupling == 1) - { - uint8_t amp0 = (sbr->amp_res[0]) ? 0 : 1; - uint8_t amp1 = (sbr->amp_res[1]) ? 0 : 1; - real_t tmp = (7 << REAL_BITS) + (sbr->E[0][k][l] << (REAL_BITS-amp0)); - real_t pan; - - /* E[1] should always be even so shifting is OK */ - uint8_t E = sbr->E[1][k][l] >> amp1; - - if (ch == 0) - { - if (E > 12) - { - /* negative */ - pan = pan_log2_tab[-12 + E]; - } else { - /* positive */ - pan = pan_log2_tab[12 - E] + ((12 - E)<amp_res[ch]) ? 0 : 1; - - return (6 << REAL_BITS) + (sbr->E[ch][k][l] << (REAL_BITS-amp)); - } -} - -static real_t find_log2_Q(sbr_info *sbr, uint8_t k, uint8_t l, uint8_t ch) -{ - /* check for coupled energy/noise data */ - if (sbr->bs_coupling == 1) - { - real_t tmp = (7 << REAL_BITS) - (sbr->Q[0][k][l] << REAL_BITS); - real_t pan; - - uint8_t Q = sbr->Q[1][k][l]; - - if (ch == 0) - { - if (Q > 12) - { - /* negative */ - pan = pan_log2_tab[-12 + Q]; - } else { - /* positive */ - pan = pan_log2_tab[12 - Q] + ((12 - Q)<Q[ch][k][l] << REAL_BITS); - } -} - -static const real_t log_Qplus1_pan[31][13] = { - { REAL_CONST(0.044383447617292), REAL_CONST(0.169768601655960), REAL_CONST(0.583090126514435), REAL_CONST(1.570089221000671), REAL_CONST(3.092446088790894), REAL_CONST(4.733354568481445), REAL_CONST(6.022367954254150), REAL_CONST(6.692092418670654), REAL_CONST(6.924463272094727), REAL_CONST(6.989034175872803), REAL_CONST(7.005646705627441), REAL_CONST(7.009829998016357), REAL_CONST(7.010877609252930) }, - { REAL_CONST(0.022362394258380), REAL_CONST(0.087379962205887), REAL_CONST(0.320804953575134), REAL_CONST(0.988859415054321), REAL_CONST(2.252387046813965), REAL_CONST(3.786596298217773), REAL_CONST(5.044394016265869), REAL_CONST(5.705977916717529), REAL_CONST(5.936291694641113), REAL_CONST(6.000346660614014), REAL_CONST(6.016829967498779), REAL_CONST(6.020981311798096), REAL_CONST(6.022020816802979) }, - { REAL_CONST(0.011224525049329), REAL_CONST(0.044351425021887), REAL_CONST(0.169301137328148), REAL_CONST(0.577544987201691), REAL_CONST(1.527246952056885), REAL_CONST(2.887525320053101), REAL_CONST(4.087462902069092), REAL_CONST(4.733354568481445), REAL_CONST(4.959661006927490), REAL_CONST(5.022709369659424), REAL_CONST(5.038940429687500), REAL_CONST(5.043028831481934), REAL_CONST(5.044052600860596) }, - { REAL_CONST(0.005623178556561), REAL_CONST(0.022346137091517), REAL_CONST(0.087132595479488), REAL_CONST(0.317482173442841), REAL_CONST(0.956931233406067), REAL_CONST(2.070389270782471), REAL_CONST(3.169924974441528), REAL_CONST(3.786596298217773), REAL_CONST(4.005294322967529), REAL_CONST(4.066420555114746), REAL_CONST(4.082170009613037), REAL_CONST(4.086137294769287), REAL_CONST(4.087131500244141) }, - { REAL_CONST(0.002814328996465), REAL_CONST(0.011216334067285), REAL_CONST(0.044224001467228), REAL_CONST(0.167456731200218), REAL_CONST(0.556393325328827), REAL_CONST(1.378511548042297), REAL_CONST(2.321928024291992), REAL_CONST(2.887525320053101), REAL_CONST(3.092446088790894), REAL_CONST(3.150059700012207), REAL_CONST(3.164926528930664), REAL_CONST(3.168673276901245), REAL_CONST(3.169611930847168) }, - { REAL_CONST(0.001407850766554), REAL_CONST(0.005619067233056), REAL_CONST(0.022281449288130), REAL_CONST(0.086156636476517), REAL_CONST(0.304854571819305), REAL_CONST(0.847996890544891), REAL_CONST(1.584962487220764), REAL_CONST(2.070389270782471), REAL_CONST(2.252387046813965), REAL_CONST(2.304061651229858), REAL_CONST(2.317430257797241), REAL_CONST(2.320801734924316), REAL_CONST(2.321646213531494) }, - { REAL_CONST(0.000704097095877), REAL_CONST(0.002812269143760), REAL_CONST(0.011183738708496), REAL_CONST(0.043721374124289), REAL_CONST(0.160464659333229), REAL_CONST(0.485426813364029), REAL_CONST(1.000000000000000), REAL_CONST(1.378511548042297), REAL_CONST(1.527246952056885), REAL_CONST(1.570089221000671), REAL_CONST(1.581215262413025), REAL_CONST(1.584023833274841), REAL_CONST(1.584727644920349) }, - { REAL_CONST(0.000352177477907), REAL_CONST(0.001406819908880), REAL_CONST(0.005602621007711), REAL_CONST(0.022026389837265), REAL_CONST(0.082462236285210), REAL_CONST(0.263034462928772), REAL_CONST(0.584962487220764), REAL_CONST(0.847996890544891), REAL_CONST(0.956931233406067), REAL_CONST(0.988859415054321), REAL_CONST(0.997190535068512), REAL_CONST(0.999296069145203), REAL_CONST(0.999823868274689) }, - { REAL_CONST(0.000176099492819), REAL_CONST(0.000703581434209), REAL_CONST(0.002804030198604), REAL_CONST(0.011055230163038), REAL_CONST(0.041820213198662), REAL_CONST(0.137503549456596), REAL_CONST(0.321928083896637), REAL_CONST(0.485426813364029), REAL_CONST(0.556393325328827), REAL_CONST(0.577544987201691), REAL_CONST(0.583090126514435), REAL_CONST(0.584493279457092), REAL_CONST(0.584845066070557) }, - { REAL_CONST(0.000088052431238), REAL_CONST(0.000351833587047), REAL_CONST(0.001402696361765), REAL_CONST(0.005538204684854), REAL_CONST(0.021061634644866), REAL_CONST(0.070389263331890), REAL_CONST(0.169925004243851), REAL_CONST(0.263034462928772), REAL_CONST(0.304854571819305), REAL_CONST(0.317482173442841), REAL_CONST(0.320804953575134), REAL_CONST(0.321646571159363), REAL_CONST(0.321857661008835) }, - { REAL_CONST(0.000044026888645), REAL_CONST(0.000175927518285), REAL_CONST(0.000701518612914), REAL_CONST(0.002771759871393), REAL_CONST(0.010569252073765), REAL_CONST(0.035623874515295), REAL_CONST(0.087462842464447), REAL_CONST(0.137503549456596), REAL_CONST(0.160464659333229), REAL_CONST(0.167456731200218), REAL_CONST(0.169301137328148), REAL_CONST(0.169768601655960), REAL_CONST(0.169885858893394) }, - { REAL_CONST(0.000022013611670), REAL_CONST(0.000088052431238), REAL_CONST(0.000350801943569), REAL_CONST(0.001386545598507), REAL_CONST(0.005294219125062), REAL_CONST(0.017921976745129), REAL_CONST(0.044394120573997), REAL_CONST(0.070389263331890), REAL_CONST(0.082462236285210), REAL_CONST(0.086156636476517), REAL_CONST(0.087132595479488), REAL_CONST(0.087379962205887), REAL_CONST(0.087442122399807) }, - { REAL_CONST(0.000011006847672), REAL_CONST(0.000044026888645), REAL_CONST(0.000175411638338), REAL_CONST(0.000693439331371), REAL_CONST(0.002649537986144), REAL_CONST(0.008988817222416), REAL_CONST(0.022367812693119), REAL_CONST(0.035623874515295), REAL_CONST(0.041820213198662), REAL_CONST(0.043721374124289), REAL_CONST(0.044224001467228), REAL_CONST(0.044351425021887), REAL_CONST(0.044383447617292) }, - { REAL_CONST(0.000005503434295), REAL_CONST(0.000022013611670), REAL_CONST(0.000087708482170), REAL_CONST(0.000346675369656), REAL_CONST(0.001325377263129), REAL_CONST(0.004501323681325), REAL_CONST(0.011227255687118), REAL_CONST(0.017921976745129), REAL_CONST(0.021061634644866), REAL_CONST(0.022026389837265), REAL_CONST(0.022281449288130), REAL_CONST(0.022346137091517), REAL_CONST(0.022362394258380) }, - { REAL_CONST(0.000002751719876), REAL_CONST(0.000011006847672), REAL_CONST(0.000043854910473), REAL_CONST(0.000173348103999), REAL_CONST(0.000662840844598), REAL_CONST(0.002252417383716), REAL_CONST(0.005624548997730), REAL_CONST(0.008988817222416), REAL_CONST(0.010569252073765), REAL_CONST(0.011055230163038), REAL_CONST(0.011183738708496), REAL_CONST(0.011216334067285), REAL_CONST(0.011224525049329) }, - { REAL_CONST(0.000001375860506), REAL_CONST(0.000005503434295), REAL_CONST(0.000022013611670), REAL_CONST(0.000086676649516), REAL_CONST(0.000331544462824), REAL_CONST(0.001126734190620), REAL_CONST(0.002815015614033), REAL_CONST(0.004501323681325), REAL_CONST(0.005294219125062), REAL_CONST(0.005538204684854), REAL_CONST(0.005602621007711), REAL_CONST(0.005619067233056), REAL_CONST(0.005623178556561) }, - { REAL_CONST(0.000000687930424), REAL_CONST(0.000002751719876), REAL_CONST(0.000011006847672), REAL_CONST(0.000043338975956), REAL_CONST(0.000165781748365), REAL_CONST(0.000563477107789), REAL_CONST(0.001408194424585), REAL_CONST(0.002252417383716), REAL_CONST(0.002649537986144), REAL_CONST(0.002771759871393), REAL_CONST(0.002804030198604), REAL_CONST(0.002812269143760), REAL_CONST(0.002814328996465) }, - { REAL_CONST(0.000000343965269), REAL_CONST(0.000001375860506), REAL_CONST(0.000005503434295), REAL_CONST(0.000021669651687), REAL_CONST(0.000082893253420), REAL_CONST(0.000281680084299), REAL_CONST(0.000704268983100), REAL_CONST(0.001126734190620), REAL_CONST(0.001325377263129), REAL_CONST(0.001386545598507), REAL_CONST(0.001402696361765), REAL_CONST(0.001406819908880), REAL_CONST(0.001407850766554) }, - { REAL_CONST(0.000000171982634), REAL_CONST(0.000000687930424), REAL_CONST(0.000002751719876), REAL_CONST(0.000010834866771), REAL_CONST(0.000041447223339), REAL_CONST(0.000140846910654), REAL_CONST(0.000352177477907), REAL_CONST(0.000563477107789), REAL_CONST(0.000662840844598), REAL_CONST(0.000693439331371), REAL_CONST(0.000701518612914), REAL_CONST(0.000703581434209), REAL_CONST(0.000704097095877) }, - { REAL_CONST(0.000000000000000), REAL_CONST(0.000000343965269), REAL_CONST(0.000001375860506), REAL_CONST(0.000005503434295), REAL_CONST(0.000020637769921), REAL_CONST(0.000070511166996), REAL_CONST(0.000176099492819), REAL_CONST(0.000281680084299), REAL_CONST(0.000331544462824), REAL_CONST(0.000346675369656), REAL_CONST(0.000350801943569), REAL_CONST(0.000351833587047), REAL_CONST(0.000352177477907) }, - { REAL_CONST(0.000000000000000), REAL_CONST(0.000000171982634), REAL_CONST(0.000000687930424), REAL_CONST(0.000002751719876), REAL_CONST(0.000010318922250), REAL_CONST(0.000035256012779), REAL_CONST(0.000088052431238), REAL_CONST(0.000140846910654), REAL_CONST(0.000165781748365), REAL_CONST(0.000173348103999), REAL_CONST(0.000175411638338), REAL_CONST(0.000175927518285), REAL_CONST(0.000176099492819) }, - { REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000343965269), REAL_CONST(0.000001375860506), REAL_CONST(0.000005159470220), REAL_CONST(0.000017542124624), REAL_CONST(0.000044026888645), REAL_CONST(0.000070511166996), REAL_CONST(0.000082893253420), REAL_CONST(0.000086676649516), REAL_CONST(0.000087708482170), REAL_CONST(0.000088052431238), REAL_CONST(0.000088052431238) }, - { REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000171982634), REAL_CONST(0.000000687930424), REAL_CONST(0.000002579737384), REAL_CONST(0.000008771088687), REAL_CONST(0.000022013611670), REAL_CONST(0.000035256012779), REAL_CONST(0.000041447223339), REAL_CONST(0.000043338975956), REAL_CONST(0.000043854910473), REAL_CONST(0.000044026888645), REAL_CONST(0.000044026888645) }, - { REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000343965269), REAL_CONST(0.000001375860506), REAL_CONST(0.000004471542070), REAL_CONST(0.000011006847672), REAL_CONST(0.000017542124624), REAL_CONST(0.000020637769921), REAL_CONST(0.000021669651687), REAL_CONST(0.000022013611670), REAL_CONST(0.000022013611670), REAL_CONST(0.000022013611670) }, - { REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000171982634), REAL_CONST(0.000000687930424), REAL_CONST(0.000002235772627), REAL_CONST(0.000005503434295), REAL_CONST(0.000008771088687), REAL_CONST(0.000010318922250), REAL_CONST(0.000010834866771), REAL_CONST(0.000011006847672), REAL_CONST(0.000011006847672), REAL_CONST(0.000011006847672) }, - { REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000343965269), REAL_CONST(0.000001031895522), REAL_CONST(0.000002751719876), REAL_CONST(0.000004471542070), REAL_CONST(0.000005159470220), REAL_CONST(0.000005503434295), REAL_CONST(0.000005503434295), REAL_CONST(0.000005503434295), REAL_CONST(0.000005503434295) }, - { REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000171982634), REAL_CONST(0.000000515947875), REAL_CONST(0.000001375860506), REAL_CONST(0.000002235772627), REAL_CONST(0.000002579737384), REAL_CONST(0.000002751719876), REAL_CONST(0.000002751719876), REAL_CONST(0.000002751719876), REAL_CONST(0.000002751719876) }, - { REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000343965269), REAL_CONST(0.000000687930424), REAL_CONST(0.000001031895522), REAL_CONST(0.000001375860506), REAL_CONST(0.000001375860506), REAL_CONST(0.000001375860506), REAL_CONST(0.000001375860506), REAL_CONST(0.000001375860506) }, - { REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000171982634), REAL_CONST(0.000000343965269), REAL_CONST(0.000000515947875), REAL_CONST(0.000000687930424), REAL_CONST(0.000000687930424), REAL_CONST(0.000000687930424), REAL_CONST(0.000000687930424), REAL_CONST(0.000000687930424) }, - { REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000171982634), REAL_CONST(0.000000343965269), REAL_CONST(0.000000343965269), REAL_CONST(0.000000343965269), REAL_CONST(0.000000343965269), REAL_CONST(0.000000343965269), REAL_CONST(0.000000343965269) }, - { REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000171982634), REAL_CONST(0.000000171982634), REAL_CONST(0.000000171982634), REAL_CONST(0.000000171982634), REAL_CONST(0.000000171982634), REAL_CONST(0.000000171982634) } -}; - -static const real_t log_Qplus1[31] = { - REAL_CONST(6.022367813028454), REAL_CONST(5.044394119358453), REAL_CONST(4.087462841250339), - REAL_CONST(3.169925001442313), REAL_CONST(2.321928094887362), REAL_CONST(1.584962500721156), - REAL_CONST(1.000000000000000), REAL_CONST(0.584962500721156), REAL_CONST(0.321928094887362), - REAL_CONST(0.169925001442312), REAL_CONST(0.087462841250339), REAL_CONST(0.044394119358453), - REAL_CONST(0.022367813028455), REAL_CONST(0.011227255423254), REAL_CONST(0.005624549193878), - REAL_CONST(0.002815015607054), REAL_CONST(0.001408194392808), REAL_CONST(0.000704269011247), - REAL_CONST(0.000352177480301), REAL_CONST(0.000176099486443), REAL_CONST(0.000088052430122), - REAL_CONST(0.000044026886827), REAL_CONST(0.000022013611360), REAL_CONST(0.000011006847667), - REAL_CONST(0.000005503434331), REAL_CONST(0.000002751719790), REAL_CONST(0.000001375860551), - REAL_CONST(0.000000687930439), REAL_CONST(0.000000343965261), REAL_CONST(0.000000171982641), - REAL_CONST(0.000000000000000) -}; - -static real_t find_log2_Qplus1(sbr_info *sbr, uint8_t k, uint8_t l, uint8_t ch) -{ - /* check for coupled energy/noise data */ - if (sbr->bs_coupling == 1) - { - if ((sbr->Q[0][k][l] >= 0) && (sbr->Q[0][k][l] <= 30) && - (sbr->Q[1][k][l] >= 0) && (sbr->Q[1][k][l] <= 24)) - { - if (ch == 0) - { - return log_Qplus1_pan[sbr->Q[0][k][l]][sbr->Q[1][k][l] >> 1]; - } else { - return log_Qplus1_pan[sbr->Q[0][k][l]][12 - (sbr->Q[1][k][l] >> 1)]; - } - } else { - return 0; - } - } else { - if (sbr->Q[ch][k][l] >= 0 && sbr->Q[ch][k][l] <= 30) - { - return log_Qplus1[sbr->Q[ch][k][l]]; - } else { - return 0; - } - } -} - -static void calculate_gain(sbr_info *sbr, sbr_hfadj_info *adj, uint8_t ch) -{ - /* log2 values of limiter gains */ - static real_t limGain[] = { - REAL_CONST(-1.0), REAL_CONST(0.0), REAL_CONST(1.0), REAL_CONST(33.219) - }; - uint8_t m, l, k; - - uint8_t current_t_noise_band = 0; - uint8_t S_mapped; - - real_t Q_M_lim[MAX_M] MEM_ALIGN_ATTR; - real_t G_lim[MAX_M] MEM_ALIGN_ATTR; - real_t G_boost MEM_ALIGN_ATTR; - real_t S_M[MAX_M] MEM_ALIGN_ATTR; - - for (l = 0; l < sbr->L_E[ch]; l++) - { - uint8_t current_f_noise_band = 0; - uint8_t current_res_band = 0; - uint8_t current_res_band2 = 0; - uint8_t current_hi_res_band = 0; - - real_t delta = (l == sbr->l_A[ch] || l == sbr->prevEnvIsShort[ch]) ? 0 : 1; - - S_mapped = get_S_mapped(sbr, ch, l, current_res_band2); - - if (sbr->t_E[ch][l+1] > sbr->t_Q[ch][current_t_noise_band+1]) - { - current_t_noise_band++; - } - - for (k = 0; k < sbr->N_L[sbr->bs_limiter_bands]; k++) - { - real_t Q_M = 0; - real_t G_max; - real_t den = 0; - real_t acc1 = 0; - real_t acc2 = 0; - uint8_t current_res_band_size = 0; - uint8_t Q_M_size = 0; - - uint8_t ml1, ml2; - - /* bounds of current limiter bands */ - ml1 = sbr->f_table_lim[sbr->bs_limiter_bands][k]; - ml2 = sbr->f_table_lim[sbr->bs_limiter_bands][k+1]; - - - /* calculate the accumulated E_orig and E_curr over the limiter band */ - for (m = ml1; m < ml2; m++) - { - if ((m + sbr->kx) < sbr->f_table_res[sbr->f[ch][l]][current_res_band+1]) - { - current_res_band_size++; - } else { - acc1 += pow2_int(-REAL_CONST(10) + log2_int_tab[current_res_band_size] + find_log2_E(sbr, current_res_band, l, ch)); - - current_res_band++; - current_res_band_size = 1; - } - - acc2 += sbr->E_curr[ch][m][l]; - } - acc1 += pow2_int(-REAL_CONST(10) + log2_int_tab[current_res_band_size] + find_log2_E(sbr, current_res_band, l, ch)); - - - if (acc1 == 0) - acc1 = LOG2_MIN_INF; - else - acc1 = log2_int(acc1); - - - /* calculate the maximum gain */ - /* ratio of the energy of the original signal and the energy - * of the HF generated signal - */ - G_max = acc1 - log2_int(acc2) + limGain[sbr->bs_limiter_gains]; - G_max = min(G_max, limGain[3]); - - - for (m = ml1; m < ml2; m++) - { - real_t G; - real_t E_curr, E_orig; - real_t Q_orig, Q_orig_plus1; - uint8_t S_index_mapped; - - - /* check if m is on a noise band border */ - if ((m + sbr->kx) == sbr->f_table_noise[current_f_noise_band+1]) - { - /* step to next noise band */ - current_f_noise_band++; - } - - - /* check if m is on a resolution band border */ - if ((m + sbr->kx) == sbr->f_table_res[sbr->f[ch][l]][current_res_band2+1]) - { - /* accumulate a whole range of equal Q_Ms */ - if (Q_M_size > 0) - den += pow2_int(log2_int_tab[Q_M_size] + Q_M); - Q_M_size = 0; - - /* step to next resolution band */ - current_res_band2++; - - /* if we move to a new resolution band, we should check if we are - * going to add a sinusoid in this band - */ - S_mapped = get_S_mapped(sbr, ch, l, current_res_band2); - } - - - /* check if m is on a HI_RES band border */ - if ((m + sbr->kx) == sbr->f_table_res[HI_RES][current_hi_res_band+1]) - { - /* step to next HI_RES band */ - current_hi_res_band++; - } - - - /* find S_index_mapped - * S_index_mapped can only be 1 for the m in the middle of the - * current HI_RES band - */ - S_index_mapped = 0; - if ((l >= sbr->l_A[ch]) || - (sbr->bs_add_harmonic_prev[ch][current_hi_res_band] && sbr->bs_add_harmonic_flag_prev[ch])) - { - /* find the middle subband of the HI_RES frequency band */ - if ((m + sbr->kx) == (sbr->f_table_res[HI_RES][current_hi_res_band+1] + sbr->f_table_res[HI_RES][current_hi_res_band]) >> 1) - S_index_mapped = sbr->bs_add_harmonic[ch][current_hi_res_band]; - } - - - /* find bitstream parameters */ - if (sbr->E_curr[ch][m][l] == 0) - E_curr = LOG2_MIN_INF; - else - E_curr = log2_int(sbr->E_curr[ch][m][l]); - E_orig = -REAL_CONST(10) + find_log2_E(sbr, current_res_band2, l, ch); - - - Q_orig = find_log2_Q(sbr, current_f_noise_band, current_t_noise_band, ch); - Q_orig_plus1 = find_log2_Qplus1(sbr, current_f_noise_band, current_t_noise_band, ch); - - - /* Q_M only depends on E_orig and Q_div2: - * since N_Q <= N_Low <= N_High we only need to recalculate Q_M on - * a change of current res band (HI or LO) - */ - Q_M = E_orig + Q_orig - Q_orig_plus1; - - - /* S_M only depends on E_orig, Q_div and S_index_mapped: - * S_index_mapped can only be non-zero once per HI_RES band - */ - if (S_index_mapped == 0) - { - S_M[m] = LOG2_MIN_INF; /* -inf */ - } else { - S_M[m] = E_orig - Q_orig_plus1; - - /* accumulate sinusoid part of the total energy */ - den += pow2_int(S_M[m]); - } - - - /* calculate gain */ - /* ratio of the energy of the original signal and the energy - * of the HF generated signal - */ - /* E_curr here is officially E_curr+1 so the log2() of that can never be < 0 */ - /* scaled by -10 */ - G = E_orig - max(-REAL_CONST(10), E_curr); - if ((S_mapped == 0) && (delta == 1)) - { - /* G = G * 1/(1+Q) */ - G -= Q_orig_plus1; - } else if (S_mapped == 1) { - /* G = G * Q/(1+Q) */ - G += Q_orig - Q_orig_plus1; - } - - - /* limit the additional noise energy level */ - /* and apply the limiter */ - if (G_max > G) - { - Q_M_lim[m] = Q_M; - G_lim[m] = G; - - if ((S_index_mapped == 0) && (l != sbr->l_A[ch])) - { - Q_M_size++; - } - } else { - /* G > G_max */ - Q_M_lim[m] = Q_M + G_max - G; - G_lim[m] = G_max; - - /* accumulate limited Q_M */ - if ((S_index_mapped == 0) && (l != sbr->l_A[ch])) - { - den += pow2_int(Q_M_lim[m]); - } - } - - - /* accumulate the total energy */ - /* E_curr changes for every m so we do need to accumulate every m */ - den += pow2_int(E_curr + G_lim[m]); - } - - /* accumulate last range of equal Q_Ms */ - if (Q_M_size > 0) - { - den += pow2_int(log2_int_tab[Q_M_size] + Q_M); - } - - - /* calculate the final gain */ - /* G_boost: [0..2.51188643] */ - G_boost = acc1 - log2_int(den /*+ EPS*/); - G_boost = min(G_boost, REAL_CONST(1.328771237) /* log2(1.584893192 ^ 2) */); - - - for (m = ml1; m < ml2; m++) - { - /* apply compensation to gain, noise floor sf's and sinusoid levels */ -#ifndef SBR_LOW_POWER - adj->G_lim_boost[l][m] = pow2_fix((G_lim[m] + G_boost) >> 1); -#else - /* sqrt() will be done after the aliasing reduction to save a - * few multiplies - */ - adj->G_lim_boost[l][m] = pow2_fix(G_lim[m] + G_boost); -#endif - adj->Q_M_lim_boost[l][m] = pow2_fix((Q_M_lim[m] + G_boost) >> 1); - - if (S_M[m] != LOG2_MIN_INF) - { - adj->S_M_boost[l][m] = pow2_int((S_M[m] + G_boost) >> 1); - } else { - adj->S_M_boost[l][m] = 0; - } - } - } - } -} - -#else - -//#define LOG2_TEST - -#ifdef LOG2_TEST - -#define LOG2_MIN_INF -100000 - -__inline float pow2(float val) -{ - return pow(2.0, val); -} -__inline float log2(float val) -{ - return log(val)/log(2.0); -} - -#define RB 14 - -float QUANTISE2REAL(float val) -{ - __int32 ival = (__int32)(val * (1<bs_coupling == 1) - { - real_t amp0 = (sbr->amp_res[0]) ? 1.0 : 0.5; - real_t amp1 = (sbr->amp_res[1]) ? 1.0 : 0.5; - float tmp = QUANTISE2REAL(7.0 + (real_t)sbr->E[0][k][l] * amp0); - float pan; - - int E = (int)(sbr->E[1][k][l] * amp1); - - if (ch == 0) - { - if (E > 12) - { - /* negative */ - pan = QUANTISE2REAL(pan_log2_tab[-12 + E]); - } else { - /* positive */ - pan = QUANTISE2REAL(pan_log2_tab[12 - E] + (12 - E)); - } - } else { - if (E < 12) - { - /* negative */ - pan = QUANTISE2REAL(pan_log2_tab[-E + 12]); - } else { - /* positive */ - pan = QUANTISE2REAL(pan_log2_tab[E - 12] + (E - 12)); - } - } - - /* tmp / pan in log2 */ - return QUANTISE2REAL(tmp - pan); - } else { - real_t amp = (sbr->amp_res[ch]) ? 1.0 : 0.5; - - return QUANTISE2REAL(6.0 + (real_t)sbr->E[ch][k][l] * amp); - } -} - -static real_t find_log2_Q(sbr_info *sbr, uint8_t k, uint8_t l, uint8_t ch) -{ - /* check for coupled energy/noise data */ - if (sbr->bs_coupling == 1) - { - float tmp = QUANTISE2REAL(7.0 - (real_t)sbr->Q[0][k][l]); - float pan; - - int Q = (int)(sbr->Q[1][k][l]); - - if (ch == 0) - { - if (Q > 12) - { - /* negative */ - pan = QUANTISE2REAL(pan_log2_tab[-12 + Q]); - } else { - /* positive */ - pan = QUANTISE2REAL(pan_log2_tab[12 - Q] + (12 - Q)); - } - } else { - if (Q < 12) - { - /* negative */ - pan = QUANTISE2REAL(pan_log2_tab[-Q + 12]); - } else { - /* positive */ - pan = QUANTISE2REAL(pan_log2_tab[Q - 12] + (Q - 12)); - } - } - - /* tmp / pan in log2 */ - return QUANTISE2REAL(tmp - pan); - } else { - return QUANTISE2REAL(6.0 - (real_t)sbr->Q[ch][k][l]); - } -} - -static const real_t log_Qplus1_pan[31][13] = { - { REAL_CONST(0.044383447617292), REAL_CONST(0.169768601655960), REAL_CONST(0.583090126514435), REAL_CONST(1.570089221000671), REAL_CONST(3.092446088790894), REAL_CONST(4.733354568481445), REAL_CONST(6.022367954254150), REAL_CONST(6.692092418670654), REAL_CONST(6.924463272094727), REAL_CONST(6.989034175872803), REAL_CONST(7.005646705627441), REAL_CONST(7.009829998016357), REAL_CONST(7.010877609252930) }, - { REAL_CONST(0.022362394258380), REAL_CONST(0.087379962205887), REAL_CONST(0.320804953575134), REAL_CONST(0.988859415054321), REAL_CONST(2.252387046813965), REAL_CONST(3.786596298217773), REAL_CONST(5.044394016265869), REAL_CONST(5.705977916717529), REAL_CONST(5.936291694641113), REAL_CONST(6.000346660614014), REAL_CONST(6.016829967498779), REAL_CONST(6.020981311798096), REAL_CONST(6.022020816802979) }, - { REAL_CONST(0.011224525049329), REAL_CONST(0.044351425021887), REAL_CONST(0.169301137328148), REAL_CONST(0.577544987201691), REAL_CONST(1.527246952056885), REAL_CONST(2.887525320053101), REAL_CONST(4.087462902069092), REAL_CONST(4.733354568481445), REAL_CONST(4.959661006927490), REAL_CONST(5.022709369659424), REAL_CONST(5.038940429687500), REAL_CONST(5.043028831481934), REAL_CONST(5.044052600860596) }, - { REAL_CONST(0.005623178556561), REAL_CONST(0.022346137091517), REAL_CONST(0.087132595479488), REAL_CONST(0.317482173442841), REAL_CONST(0.956931233406067), REAL_CONST(2.070389270782471), REAL_CONST(3.169924974441528), REAL_CONST(3.786596298217773), REAL_CONST(4.005294322967529), REAL_CONST(4.066420555114746), REAL_CONST(4.082170009613037), REAL_CONST(4.086137294769287), REAL_CONST(4.087131500244141) }, - { REAL_CONST(0.002814328996465), REAL_CONST(0.011216334067285), REAL_CONST(0.044224001467228), REAL_CONST(0.167456731200218), REAL_CONST(0.556393325328827), REAL_CONST(1.378511548042297), REAL_CONST(2.321928024291992), REAL_CONST(2.887525320053101), REAL_CONST(3.092446088790894), REAL_CONST(3.150059700012207), REAL_CONST(3.164926528930664), REAL_CONST(3.168673276901245), REAL_CONST(3.169611930847168) }, - { REAL_CONST(0.001407850766554), REAL_CONST(0.005619067233056), REAL_CONST(0.022281449288130), REAL_CONST(0.086156636476517), REAL_CONST(0.304854571819305), REAL_CONST(0.847996890544891), REAL_CONST(1.584962487220764), REAL_CONST(2.070389270782471), REAL_CONST(2.252387046813965), REAL_CONST(2.304061651229858), REAL_CONST(2.317430257797241), REAL_CONST(2.320801734924316), REAL_CONST(2.321646213531494) }, - { REAL_CONST(0.000704097095877), REAL_CONST(0.002812269143760), REAL_CONST(0.011183738708496), REAL_CONST(0.043721374124289), REAL_CONST(0.160464659333229), REAL_CONST(0.485426813364029), REAL_CONST(1.000000000000000), REAL_CONST(1.378511548042297), REAL_CONST(1.527246952056885), REAL_CONST(1.570089221000671), REAL_CONST(1.581215262413025), REAL_CONST(1.584023833274841), REAL_CONST(1.584727644920349) }, - { REAL_CONST(0.000352177477907), REAL_CONST(0.001406819908880), REAL_CONST(0.005602621007711), REAL_CONST(0.022026389837265), REAL_CONST(0.082462236285210), REAL_CONST(0.263034462928772), REAL_CONST(0.584962487220764), REAL_CONST(0.847996890544891), REAL_CONST(0.956931233406067), REAL_CONST(0.988859415054321), REAL_CONST(0.997190535068512), REAL_CONST(0.999296069145203), REAL_CONST(0.999823868274689) }, - { REAL_CONST(0.000176099492819), REAL_CONST(0.000703581434209), REAL_CONST(0.002804030198604), REAL_CONST(0.011055230163038), REAL_CONST(0.041820213198662), REAL_CONST(0.137503549456596), REAL_CONST(0.321928083896637), REAL_CONST(0.485426813364029), REAL_CONST(0.556393325328827), REAL_CONST(0.577544987201691), REAL_CONST(0.583090126514435), REAL_CONST(0.584493279457092), REAL_CONST(0.584845066070557) }, - { REAL_CONST(0.000088052431238), REAL_CONST(0.000351833587047), REAL_CONST(0.001402696361765), REAL_CONST(0.005538204684854), REAL_CONST(0.021061634644866), REAL_CONST(0.070389263331890), REAL_CONST(0.169925004243851), REAL_CONST(0.263034462928772), REAL_CONST(0.304854571819305), REAL_CONST(0.317482173442841), REAL_CONST(0.320804953575134), REAL_CONST(0.321646571159363), REAL_CONST(0.321857661008835) }, - { REAL_CONST(0.000044026888645), REAL_CONST(0.000175927518285), REAL_CONST(0.000701518612914), REAL_CONST(0.002771759871393), REAL_CONST(0.010569252073765), REAL_CONST(0.035623874515295), REAL_CONST(0.087462842464447), REAL_CONST(0.137503549456596), REAL_CONST(0.160464659333229), REAL_CONST(0.167456731200218), REAL_CONST(0.169301137328148), REAL_CONST(0.169768601655960), REAL_CONST(0.169885858893394) }, - { REAL_CONST(0.000022013611670), REAL_CONST(0.000088052431238), REAL_CONST(0.000350801943569), REAL_CONST(0.001386545598507), REAL_CONST(0.005294219125062), REAL_CONST(0.017921976745129), REAL_CONST(0.044394120573997), REAL_CONST(0.070389263331890), REAL_CONST(0.082462236285210), REAL_CONST(0.086156636476517), REAL_CONST(0.087132595479488), REAL_CONST(0.087379962205887), REAL_CONST(0.087442122399807) }, - { REAL_CONST(0.000011006847672), REAL_CONST(0.000044026888645), REAL_CONST(0.000175411638338), REAL_CONST(0.000693439331371), REAL_CONST(0.002649537986144), REAL_CONST(0.008988817222416), REAL_CONST(0.022367812693119), REAL_CONST(0.035623874515295), REAL_CONST(0.041820213198662), REAL_CONST(0.043721374124289), REAL_CONST(0.044224001467228), REAL_CONST(0.044351425021887), REAL_CONST(0.044383447617292) }, - { REAL_CONST(0.000005503434295), REAL_CONST(0.000022013611670), REAL_CONST(0.000087708482170), REAL_CONST(0.000346675369656), REAL_CONST(0.001325377263129), REAL_CONST(0.004501323681325), REAL_CONST(0.011227255687118), REAL_CONST(0.017921976745129), REAL_CONST(0.021061634644866), REAL_CONST(0.022026389837265), REAL_CONST(0.022281449288130), REAL_CONST(0.022346137091517), REAL_CONST(0.022362394258380) }, - { REAL_CONST(0.000002751719876), REAL_CONST(0.000011006847672), REAL_CONST(0.000043854910473), REAL_CONST(0.000173348103999), REAL_CONST(0.000662840844598), REAL_CONST(0.002252417383716), REAL_CONST(0.005624548997730), REAL_CONST(0.008988817222416), REAL_CONST(0.010569252073765), REAL_CONST(0.011055230163038), REAL_CONST(0.011183738708496), REAL_CONST(0.011216334067285), REAL_CONST(0.011224525049329) }, - { REAL_CONST(0.000001375860506), REAL_CONST(0.000005503434295), REAL_CONST(0.000022013611670), REAL_CONST(0.000086676649516), REAL_CONST(0.000331544462824), REAL_CONST(0.001126734190620), REAL_CONST(0.002815015614033), REAL_CONST(0.004501323681325), REAL_CONST(0.005294219125062), REAL_CONST(0.005538204684854), REAL_CONST(0.005602621007711), REAL_CONST(0.005619067233056), REAL_CONST(0.005623178556561) }, - { REAL_CONST(0.000000687930424), REAL_CONST(0.000002751719876), REAL_CONST(0.000011006847672), REAL_CONST(0.000043338975956), REAL_CONST(0.000165781748365), REAL_CONST(0.000563477107789), REAL_CONST(0.001408194424585), REAL_CONST(0.002252417383716), REAL_CONST(0.002649537986144), REAL_CONST(0.002771759871393), REAL_CONST(0.002804030198604), REAL_CONST(0.002812269143760), REAL_CONST(0.002814328996465) }, - { REAL_CONST(0.000000343965269), REAL_CONST(0.000001375860506), REAL_CONST(0.000005503434295), REAL_CONST(0.000021669651687), REAL_CONST(0.000082893253420), REAL_CONST(0.000281680084299), REAL_CONST(0.000704268983100), REAL_CONST(0.001126734190620), REAL_CONST(0.001325377263129), REAL_CONST(0.001386545598507), REAL_CONST(0.001402696361765), REAL_CONST(0.001406819908880), REAL_CONST(0.001407850766554) }, - { REAL_CONST(0.000000171982634), REAL_CONST(0.000000687930424), REAL_CONST(0.000002751719876), REAL_CONST(0.000010834866771), REAL_CONST(0.000041447223339), REAL_CONST(0.000140846910654), REAL_CONST(0.000352177477907), REAL_CONST(0.000563477107789), REAL_CONST(0.000662840844598), REAL_CONST(0.000693439331371), REAL_CONST(0.000701518612914), REAL_CONST(0.000703581434209), REAL_CONST(0.000704097095877) }, - { REAL_CONST(0.000000000000000), REAL_CONST(0.000000343965269), REAL_CONST(0.000001375860506), REAL_CONST(0.000005503434295), REAL_CONST(0.000020637769921), REAL_CONST(0.000070511166996), REAL_CONST(0.000176099492819), REAL_CONST(0.000281680084299), REAL_CONST(0.000331544462824), REAL_CONST(0.000346675369656), REAL_CONST(0.000350801943569), REAL_CONST(0.000351833587047), REAL_CONST(0.000352177477907) }, - { REAL_CONST(0.000000000000000), REAL_CONST(0.000000171982634), REAL_CONST(0.000000687930424), REAL_CONST(0.000002751719876), REAL_CONST(0.000010318922250), REAL_CONST(0.000035256012779), REAL_CONST(0.000088052431238), REAL_CONST(0.000140846910654), REAL_CONST(0.000165781748365), REAL_CONST(0.000173348103999), REAL_CONST(0.000175411638338), REAL_CONST(0.000175927518285), REAL_CONST(0.000176099492819) }, - { REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000343965269), REAL_CONST(0.000001375860506), REAL_CONST(0.000005159470220), REAL_CONST(0.000017542124624), REAL_CONST(0.000044026888645), REAL_CONST(0.000070511166996), REAL_CONST(0.000082893253420), REAL_CONST(0.000086676649516), REAL_CONST(0.000087708482170), REAL_CONST(0.000088052431238), REAL_CONST(0.000088052431238) }, - { REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000171982634), REAL_CONST(0.000000687930424), REAL_CONST(0.000002579737384), REAL_CONST(0.000008771088687), REAL_CONST(0.000022013611670), REAL_CONST(0.000035256012779), REAL_CONST(0.000041447223339), REAL_CONST(0.000043338975956), REAL_CONST(0.000043854910473), REAL_CONST(0.000044026888645), REAL_CONST(0.000044026888645) }, - { REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000343965269), REAL_CONST(0.000001375860506), REAL_CONST(0.000004471542070), REAL_CONST(0.000011006847672), REAL_CONST(0.000017542124624), REAL_CONST(0.000020637769921), REAL_CONST(0.000021669651687), REAL_CONST(0.000022013611670), REAL_CONST(0.000022013611670), REAL_CONST(0.000022013611670) }, - { REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000171982634), REAL_CONST(0.000000687930424), REAL_CONST(0.000002235772627), REAL_CONST(0.000005503434295), REAL_CONST(0.000008771088687), REAL_CONST(0.000010318922250), REAL_CONST(0.000010834866771), REAL_CONST(0.000011006847672), REAL_CONST(0.000011006847672), REAL_CONST(0.000011006847672) }, - { REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000343965269), REAL_CONST(0.000001031895522), REAL_CONST(0.000002751719876), REAL_CONST(0.000004471542070), REAL_CONST(0.000005159470220), REAL_CONST(0.000005503434295), REAL_CONST(0.000005503434295), REAL_CONST(0.000005503434295), REAL_CONST(0.000005503434295) }, - { REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000171982634), REAL_CONST(0.000000515947875), REAL_CONST(0.000001375860506), REAL_CONST(0.000002235772627), REAL_CONST(0.000002579737384), REAL_CONST(0.000002751719876), REAL_CONST(0.000002751719876), REAL_CONST(0.000002751719876), REAL_CONST(0.000002751719876) }, - { REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000343965269), REAL_CONST(0.000000687930424), REAL_CONST(0.000001031895522), REAL_CONST(0.000001375860506), REAL_CONST(0.000001375860506), REAL_CONST(0.000001375860506), REAL_CONST(0.000001375860506), REAL_CONST(0.000001375860506) }, - { REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000171982634), REAL_CONST(0.000000343965269), REAL_CONST(0.000000515947875), REAL_CONST(0.000000687930424), REAL_CONST(0.000000687930424), REAL_CONST(0.000000687930424), REAL_CONST(0.000000687930424), REAL_CONST(0.000000687930424) }, - { REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000171982634), REAL_CONST(0.000000343965269), REAL_CONST(0.000000343965269), REAL_CONST(0.000000343965269), REAL_CONST(0.000000343965269), REAL_CONST(0.000000343965269), REAL_CONST(0.000000343965269) }, - { REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000171982634), REAL_CONST(0.000000171982634), REAL_CONST(0.000000171982634), REAL_CONST(0.000000171982634), REAL_CONST(0.000000171982634), REAL_CONST(0.000000171982634) } -}; - -static const real_t log_Qplus1[31] = { - REAL_CONST(6.022367813028454), REAL_CONST(5.044394119358453), REAL_CONST(4.087462841250339), - REAL_CONST(3.169925001442313), REAL_CONST(2.321928094887362), REAL_CONST(1.584962500721156), - REAL_CONST(1.000000000000000), REAL_CONST(0.584962500721156), REAL_CONST(0.321928094887362), - REAL_CONST(0.169925001442312), REAL_CONST(0.087462841250339), REAL_CONST(0.044394119358453), - REAL_CONST(0.022367813028455), REAL_CONST(0.011227255423254), REAL_CONST(0.005624549193878), - REAL_CONST(0.002815015607054), REAL_CONST(0.001408194392808), REAL_CONST(0.000704269011247), - REAL_CONST(0.000352177480301), REAL_CONST(0.000176099486443), REAL_CONST(0.000088052430122), - REAL_CONST(0.000044026886827), REAL_CONST(0.000022013611360), REAL_CONST(0.000011006847667), - REAL_CONST(0.000005503434331), REAL_CONST(0.000002751719790), REAL_CONST(0.000001375860551), - REAL_CONST(0.000000687930439), REAL_CONST(0.000000343965261), REAL_CONST(0.000000171982641), - REAL_CONST(0.000000000000000) -}; - -static real_t find_log2_Qplus1(sbr_info *sbr, uint8_t k, uint8_t l, uint8_t ch) -{ - /* check for coupled energy/noise data */ - if (sbr->bs_coupling == 1) - { - if ((sbr->Q[0][k][l] >= 0) && (sbr->Q[0][k][l] <= 30) && - (sbr->Q[1][k][l] >= 0) && (sbr->Q[1][k][l] <= 24)) - { - if (ch == 0) - { - return QUANTISE2REAL(log_Qplus1_pan[sbr->Q[0][k][l]][sbr->Q[1][k][l] >> 1]); - } else { - return QUANTISE2REAL(log_Qplus1_pan[sbr->Q[0][k][l]][12 - (sbr->Q[1][k][l] >> 1)]); - } - } else { - return 0; - } - } else { - if (sbr->Q[ch][k][l] >= 0 && sbr->Q[ch][k][l] <= 30) - { - return QUANTISE2REAL(log_Qplus1[sbr->Q[ch][k][l]]); - } else { - return 0; - } - } -} - -static void calculate_gain(sbr_info *sbr, sbr_hfadj_info *adj, uint8_t ch) -{ - /* log2 values of limiter gains */ - static real_t limGain[] = { -1.0, 0.0, 1.0, 33.219 }; - uint8_t m, l, k; - - uint8_t current_t_noise_band = 0; - uint8_t S_mapped; - - real_t Q_M_lim[MAX_M] MEM_ALIGN_ATTR; - real_t G_lim[MAX_M] MEM_ALIGN_ATTR; - real_t G_boost MEM_ALIGN_ATTR; - real_t S_M[MAX_M] MEM_ALIGN_ATTR; - - for (l = 0; l < sbr->L_E[ch]; l++) - { - uint8_t current_f_noise_band = 0; - uint8_t current_res_band = 0; - uint8_t current_res_band2 = 0; - uint8_t current_hi_res_band = 0; - - real_t delta = (l == sbr->l_A[ch] || l == sbr->prevEnvIsShort[ch]) ? 0 : 1; - - S_mapped = get_S_mapped(sbr, ch, l, current_res_band2); - - if (sbr->t_E[ch][l+1] > sbr->t_Q[ch][current_t_noise_band+1]) - { - current_t_noise_band++; - } - - for (k = 0; k < sbr->N_L[sbr->bs_limiter_bands]; k++) - { - real_t Q_M = 0; - real_t G_max; - real_t den = 0; - real_t acc1 = 0; - real_t acc2 = 0; - uint8_t current_res_band_size = 0; - uint8_t Q_M_size = 0; - - uint8_t ml1, ml2; - - /* bounds of current limiter bands */ - ml1 = sbr->f_table_lim[sbr->bs_limiter_bands][k]; - ml2 = sbr->f_table_lim[sbr->bs_limiter_bands][k+1]; - - - /* calculate the accumulated E_orig and E_curr over the limiter band */ - for (m = ml1; m < ml2; m++) - { - if ((m + sbr->kx) < sbr->f_table_res[sbr->f[ch][l]][current_res_band+1]) - { - current_res_band_size++; - } else { - acc1 += QUANTISE2INT(pow2(-10 + log2_int_tab[current_res_band_size] + find_log2_E(sbr, current_res_band, l, ch))); - - current_res_band++; - current_res_band_size = 1; - } - - acc2 += QUANTISE2INT(sbr->E_curr[ch][m][l]/1024.0); - } - acc1 += QUANTISE2INT(pow2(-10 + log2_int_tab[current_res_band_size] + find_log2_E(sbr, current_res_band, l, ch))); - - acc1 = QUANTISE2REAL( log2(EPS + acc1) ); - - - /* calculate the maximum gain */ - /* ratio of the energy of the original signal and the energy - * of the HF generated signal - */ - G_max = acc1 - QUANTISE2REAL(log2(EPS + acc2)) + QUANTISE2REAL(limGain[sbr->bs_limiter_gains]); - G_max = min(G_max, QUANTISE2REAL(limGain[3])); - - - for (m = ml1; m < ml2; m++) - { - real_t G; - real_t E_curr, E_orig; - real_t Q_orig, Q_orig_plus1; - uint8_t S_index_mapped; - - - /* check if m is on a noise band border */ - if ((m + sbr->kx) == sbr->f_table_noise[current_f_noise_band+1]) - { - /* step to next noise band */ - current_f_noise_band++; - } - - - /* check if m is on a resolution band border */ - if ((m + sbr->kx) == sbr->f_table_res[sbr->f[ch][l]][current_res_band2+1]) - { - /* accumulate a whole range of equal Q_Ms */ - if (Q_M_size > 0) - den += QUANTISE2INT(pow2(log2_int_tab[Q_M_size] + Q_M)); - Q_M_size = 0; - - /* step to next resolution band */ - current_res_band2++; - - /* if we move to a new resolution band, we should check if we are - * going to add a sinusoid in this band - */ - S_mapped = get_S_mapped(sbr, ch, l, current_res_band2); - } - - - /* check if m is on a HI_RES band border */ - if ((m + sbr->kx) == sbr->f_table_res[HI_RES][current_hi_res_band+1]) - { - /* step to next HI_RES band */ - current_hi_res_band++; - } - - - /* find S_index_mapped - * S_index_mapped can only be 1 for the m in the middle of the - * current HI_RES band - */ - S_index_mapped = 0; - if ((l >= sbr->l_A[ch]) || - (sbr->bs_add_harmonic_prev[ch][current_hi_res_band] && sbr->bs_add_harmonic_flag_prev[ch])) - { - /* find the middle subband of the HI_RES frequency band */ - if ((m + sbr->kx) == (sbr->f_table_res[HI_RES][current_hi_res_band+1] + sbr->f_table_res[HI_RES][current_hi_res_band]) >> 1) - S_index_mapped = sbr->bs_add_harmonic[ch][current_hi_res_band]; - } - - - /* find bitstream parameters */ - if (sbr->E_curr[ch][m][l] == 0) - E_curr = LOG2_MIN_INF; - else - E_curr = -10 + log2(sbr->E_curr[ch][m][l]); - E_orig = -10 + find_log2_E(sbr, current_res_band2, l, ch); - - Q_orig = find_log2_Q(sbr, current_f_noise_band, current_t_noise_band, ch); - Q_orig_plus1 = find_log2_Qplus1(sbr, current_f_noise_band, current_t_noise_band, ch); - - - /* Q_M only depends on E_orig and Q_div2: - * since N_Q <= N_Low <= N_High we only need to recalculate Q_M on - * a change of current res band (HI or LO) - */ - Q_M = E_orig + Q_orig - Q_orig_plus1; - - - /* S_M only depends on E_orig, Q_div and S_index_mapped: - * S_index_mapped can only be non-zero once per HI_RES band - */ - if (S_index_mapped == 0) - { - S_M[m] = LOG2_MIN_INF; /* -inf */ - } else { - S_M[m] = E_orig - Q_orig_plus1; - - /* accumulate sinusoid part of the total energy */ - den += pow2(S_M[m]); - } - - - /* calculate gain */ - /* ratio of the energy of the original signal and the energy - * of the HF generated signal - */ - /* E_curr here is officially E_curr+1 so the log2() of that can never be < 0 */ - /* scaled by -10 */ - G = E_orig - max(-10, E_curr); - if ((S_mapped == 0) && (delta == 1)) - { - /* G = G * 1/(1+Q) */ - G -= Q_orig_plus1; - } else if (S_mapped == 1) { - /* G = G * Q/(1+Q) */ - G += Q_orig - Q_orig_plus1; - } - - - /* limit the additional noise energy level */ - /* and apply the limiter */ - if (G_max > G) - { - Q_M_lim[m] = QUANTISE2REAL(Q_M); - G_lim[m] = QUANTISE2REAL(G); - - if ((S_index_mapped == 0) && (l != sbr->l_A[ch])) - { - Q_M_size++; - } - } else { - /* G > G_max */ - Q_M_lim[m] = QUANTISE2REAL(Q_M) + G_max - QUANTISE2REAL(G); - G_lim[m] = G_max; - - /* accumulate limited Q_M */ - if ((S_index_mapped == 0) && (l != sbr->l_A[ch])) - { - den += QUANTISE2INT(pow2(Q_M_lim[m])); - } - } - - - /* accumulate the total energy */ - /* E_curr changes for every m so we do need to accumulate every m */ - den += QUANTISE2INT(pow2(E_curr + G_lim[m])); - } - - /* accumulate last range of equal Q_Ms */ - if (Q_M_size > 0) - { - den += QUANTISE2INT(pow2(log2_int_tab[Q_M_size] + Q_M)); - } - - - /* calculate the final gain */ - /* G_boost: [0..2.51188643] */ - G_boost = acc1 - QUANTISE2REAL(log2(den + EPS)); - G_boost = min(G_boost, QUANTISE2REAL(1.328771237) /* log2(1.584893192 ^ 2) */); - - - for (m = ml1; m < ml2; m++) - { - /* apply compensation to gain, noise floor sf's and sinusoid levels */ -#ifndef SBR_LOW_POWER - adj->G_lim_boost[l][m] = QUANTISE2REAL(pow2((G_lim[m] + G_boost) / 2.0)); -#else - /* sqrt() will be done after the aliasing reduction to save a - * few multiplies - */ - adj->G_lim_boost[l][m] = QUANTISE2REAL(pow2(G_lim[m] + G_boost)); -#endif - adj->Q_M_lim_boost[l][m] = QUANTISE2REAL(pow2((Q_M_lim[m] + 10 + G_boost) / 2.0)); - - if (S_M[m] != LOG2_MIN_INF) - { - adj->S_M_boost[l][m] = QUANTISE2REAL(pow2((S_M[m] + 10 + G_boost) / 2.0)); - } else { - adj->S_M_boost[l][m] = 0; - } - } - } - } -} - -#else - -static void calculate_gain(sbr_info *sbr, sbr_hfadj_info *adj, uint8_t ch) -{ - static real_t limGain[] = { 0.5, 1.0, 2.0, 1e10 }; - uint8_t m, l, k; - - uint8_t current_t_noise_band = 0; - uint8_t S_mapped; - - real_t Q_M_lim[MAX_M] MEM_ALIGN_ATTR; - real_t G_lim[MAX_M] MEM_ALIGN_ATTR; - real_t G_boost MEM_ALIGN_ATTR; - real_t S_M[MAX_M] MEM_ALIGN_ATTR; - - for (l = 0; l < sbr->L_E[ch]; l++) - { - uint8_t current_f_noise_band = 0; - uint8_t current_res_band = 0; - uint8_t current_res_band2 = 0; - uint8_t current_hi_res_band = 0; - - real_t delta = (l == sbr->l_A[ch] || l == sbr->prevEnvIsShort[ch]) ? 0 : 1; - - S_mapped = get_S_mapped(sbr, ch, l, current_res_band2); - - if (sbr->t_E[ch][l+1] > sbr->t_Q[ch][current_t_noise_band+1]) - { - current_t_noise_band++; - } - - for (k = 0; k < sbr->N_L[sbr->bs_limiter_bands]; k++) - { - real_t G_max; - real_t den = 0; - real_t acc1 = 0; - real_t acc2 = 0; - - uint8_t ml1, ml2; - - ml1 = sbr->f_table_lim[sbr->bs_limiter_bands][k]; - ml2 = sbr->f_table_lim[sbr->bs_limiter_bands][k+1]; - - - /* calculate the accumulated E_orig and E_curr over the limiter band */ - for (m = ml1; m < ml2; m++) - { - if ((m + sbr->kx) == sbr->f_table_res[sbr->f[ch][l]][current_res_band+1]) - { - current_res_band++; - } - acc1 += sbr->E_orig[ch][current_res_band][l]; - acc2 += sbr->E_curr[ch][m][l]; - } - - - /* calculate the maximum gain */ - /* ratio of the energy of the original signal and the energy - * of the HF generated signal - */ - G_max = ((EPS + acc1) / (EPS + acc2)) * limGain[sbr->bs_limiter_gains]; - G_max = min(G_max, 1e10); - - - for (m = ml1; m < ml2; m++) - { - real_t Q_M, G; - real_t Q_div, Q_div2; - uint8_t S_index_mapped; - - - /* check if m is on a noise band border */ - if ((m + sbr->kx) == sbr->f_table_noise[current_f_noise_band+1]) - { - /* step to next noise band */ - current_f_noise_band++; - } - - - /* check if m is on a resolution band border */ - if ((m + sbr->kx) == sbr->f_table_res[sbr->f[ch][l]][current_res_band2+1]) - { - /* step to next resolution band */ - current_res_band2++; - - /* if we move to a new resolution band, we should check if we are - * going to add a sinusoid in this band - */ - S_mapped = get_S_mapped(sbr, ch, l, current_res_band2); - } - - - /* check if m is on a HI_RES band border */ - if ((m + sbr->kx) == sbr->f_table_res[HI_RES][current_hi_res_band+1]) - { - /* step to next HI_RES band */ - current_hi_res_band++; - } - - - /* find S_index_mapped - * S_index_mapped can only be 1 for the m in the middle of the - * current HI_RES band - */ - S_index_mapped = 0; - if ((l >= sbr->l_A[ch]) || - (sbr->bs_add_harmonic_prev[ch][current_hi_res_band] && sbr->bs_add_harmonic_flag_prev[ch])) - { - /* find the middle subband of the HI_RES frequency band */ - if ((m + sbr->kx) == (sbr->f_table_res[HI_RES][current_hi_res_band+1] + sbr->f_table_res[HI_RES][current_hi_res_band]) >> 1) - S_index_mapped = sbr->bs_add_harmonic[ch][current_hi_res_band]; - } - - - /* Q_div: [0..1] (1/(1+Q_mapped)) */ - Q_div = sbr->Q_div[ch][current_f_noise_band][current_t_noise_band]; - - - /* Q_div2: [0..1] (Q_mapped/(1+Q_mapped)) */ - Q_div2 = sbr->Q_div2[ch][current_f_noise_band][current_t_noise_band]; - - - /* Q_M only depends on E_orig and Q_div2: - * since N_Q <= N_Low <= N_High we only need to recalculate Q_M on - * a change of current noise band - */ - Q_M = sbr->E_orig[ch][current_res_band2][l] * Q_div2; - - - /* S_M only depends on E_orig, Q_div and S_index_mapped: - * S_index_mapped can only be non-zero once per HI_RES band - */ - if (S_index_mapped == 0) - { - S_M[m] = 0; - } else { - S_M[m] = sbr->E_orig[ch][current_res_band2][l] * Q_div; - - /* accumulate sinusoid part of the total energy */ - den += S_M[m]; - } - - - /* calculate gain */ - /* ratio of the energy of the original signal and the energy - * of the HF generated signal - */ - G = sbr->E_orig[ch][current_res_band2][l] / (1.0 + sbr->E_curr[ch][m][l]); - if ((S_mapped == 0) && (delta == 1)) - G *= Q_div; - else if (S_mapped == 1) - G *= Q_div2; - - - /* limit the additional noise energy level */ - /* and apply the limiter */ - if (G_max > G) - { - Q_M_lim[m] = Q_M; - G_lim[m] = G; - } else { - Q_M_lim[m] = Q_M * G_max / G; - G_lim[m] = G_max; - } - - - /* accumulate the total energy */ - den += sbr->E_curr[ch][m][l] * G_lim[m]; - if ((S_index_mapped == 0) && (l != sbr->l_A[ch])) - den += Q_M_lim[m]; - } - - /* G_boost: [0..2.51188643] */ - G_boost = (acc1 + EPS) / (den + EPS); - G_boost = min(G_boost, 2.51188643 /* 1.584893192 ^ 2 */); - - for (m = ml1; m < ml2; m++) - { - /* apply compensation to gain, noise floor sf's and sinusoid levels */ -#ifndef SBR_LOW_POWER - adj->G_lim_boost[l][m] = sqrt(G_lim[m] * G_boost); -#else - /* sqrt() will be done after the aliasing reduction to save a - * few multiplies - */ - adj->G_lim_boost[l][m] = G_lim[m] * G_boost; -#endif - adj->Q_M_lim_boost[l][m] = sqrt(Q_M_lim[m] * G_boost); - - if (S_M[m] != 0) - { - adj->S_M_boost[l][m] = sqrt(S_M[m] * G_boost); - } else { - adj->S_M_boost[l][m] = 0; - } - } - } - } -} -#endif // log2_test - -#endif - -#ifdef SBR_LOW_POWER -static void calc_gain_groups(sbr_info *sbr, sbr_hfadj_info *adj, real_t *deg, uint8_t ch) -{ - uint8_t l, k, i; - uint8_t grouping; - - for (l = 0; l < sbr->L_E[ch]; l++) - { - i = 0; - grouping = 0; - - for (k = sbr->kx; k < sbr->kx + sbr->M - 1; k++) - { - if (deg[k + 1] && adj->S_mapped[l][k-sbr->kx] == 0) - { - if (grouping == 0) - { - sbr->f_group[l][i] = k; - grouping = 1; - i++; - } - } else { - if (grouping) - { - if (adj->S_mapped[l][k-sbr->kx]) - { - sbr->f_group[l][i] = k; - } else { - sbr->f_group[l][i] = k + 1; - } - grouping = 0; - i++; - } - } - } - - if (grouping) - { - sbr->f_group[l][i] = sbr->kx + sbr->M; - i++; - } - - sbr->N_G[l] = (uint8_t)(i >> 1); - } -} - -static void aliasing_reduction(sbr_info *sbr, sbr_hfadj_info *adj, real_t *deg, uint8_t ch) -{ - uint8_t l, k, m; - real_t E_total, E_total_est, G_target, acc; - - for (l = 0; l < sbr->L_E[ch]; l++) - { - for (k = 0; k < sbr->N_G[l]; k++) - { - E_total_est = E_total = 0; - - for (m = sbr->f_group[l][k<<1]; m < sbr->f_group[l][(k<<1) + 1]; m++) - { - /* E_curr: integer */ - /* G_lim_boost: fixed point */ - /* E_total_est: integer */ - /* E_total: integer */ - E_total_est += sbr->E_curr[ch][m-sbr->kx][l]; - E_total += MUL_Q2(sbr->E_curr[ch][m-sbr->kx][l], adj->G_lim_boost[l][m-sbr->kx]); - } - - /* G_target: fixed point */ - if ((E_total_est + EPS) == 0) - { - G_target = 0; - } else { - G_target = DIV_Q(E_total, (E_total_est + EPS)); - } - acc = 0; - - for (m = sbr->f_group[l][(k<<1)]; m < sbr->f_group[l][(k<<1) + 1]; m++) - { - real_t alpha; - - /* alpha: (COEF) fixed point */ - if (m < sbr->kx + sbr->M - 1) - { - alpha = max(deg[m], deg[m + 1]); - } else { - alpha = deg[m]; - } - - adj->G_lim_boost[l][m-sbr->kx] = MUL_C(alpha, G_target) + - MUL_C((COEF_CONST(1)-alpha), adj->G_lim_boost[l][m-sbr->kx]); - - /* acc: integer */ - acc += MUL_Q2(adj->G_lim_boost[l][m-sbr->kx], sbr->E_curr[ch][m-sbr->kx][l]); - } - - /* acc: fixed point */ - if (acc + EPS == 0) - { - acc = 0; - } else { - acc = DIV_Q(E_total, (acc + EPS)); - } - for(m = sbr->f_group[l][(k<<1)]; m < sbr->f_group[l][(k<<1) + 1]; m++) - { - adj->G_lim_boost[l][m-sbr->kx] = MUL_Q2(acc, adj->G_lim_boost[l][m-sbr->kx]); - } - } - } - - for (l = 0; l < sbr->L_E[ch]; l++) - { - for (k = 0; k < sbr->N_L[sbr->bs_limiter_bands]; k++) - { - for (m = sbr->f_table_lim[sbr->bs_limiter_bands][k]; - m < sbr->f_table_lim[sbr->bs_limiter_bands][k+1]; m++) - { -#ifdef FIXED_POINT - adj->G_lim_boost[l][m] = SBR_SQRT_Q2(adj->G_lim_boost[l][m]); -#else - adj->G_lim_boost[l][m] = sqrt(adj->G_lim_boost[l][m]); -#endif - } - } - } -} -#endif - -static void hf_assembly(sbr_info *sbr, sbr_hfadj_info *adj, - qmf_t Xsbr[MAX_NTSRHFG][64], uint8_t ch) -{ - static real_t h_smooth[] = { - FRAC_CONST(0.03183050093751), FRAC_CONST(0.11516383427084), - FRAC_CONST(0.21816949906249), FRAC_CONST(0.30150283239582), - FRAC_CONST(0.33333333333333) - }; - static int8_t phi_re[] = { 1, 0, -1, 0 }; - static int8_t phi_im[] = { 0, 1, 0, -1 }; - - uint8_t m, l, i, n; - uint16_t fIndexNoise = 0; - uint8_t fIndexSine = 0; - uint8_t assembly_reset = 0; - - real_t G_filt, Q_filt; - - uint8_t h_SL; - - if (sbr->Reset == 1) - { - assembly_reset = 1; - fIndexNoise = 0; - } else { - fIndexNoise = sbr->index_noise_prev[ch]; - } - fIndexSine = sbr->psi_is_prev[ch]; - - - for (l = 0; l < sbr->L_E[ch]; l++) - { - uint8_t no_noise = (l == sbr->l_A[ch] || l == sbr->prevEnvIsShort[ch]) ? 1 : 0; - -#ifdef SBR_LOW_POWER - h_SL = 0; -#else - h_SL = (sbr->bs_smoothing_mode == 1) ? 0 : 4; - h_SL = (no_noise ? 0 : h_SL); -#endif - - if (assembly_reset) - { - for (n = 0; n < 4; n++) - { - memcpy(sbr->G_temp_prev[ch][n], adj->G_lim_boost[l], sbr->M*sizeof(real_t)); - memcpy(sbr->Q_temp_prev[ch][n], adj->Q_M_lim_boost[l], sbr->M*sizeof(real_t)); - } - /* reset ringbuffer index */ - sbr->GQ_ringbuf_index[ch] = 4; - assembly_reset = 0; - } - - for (i = sbr->t_E[ch][l]; i < sbr->t_E[ch][l+1]; i++) - { -#ifdef SBR_LOW_POWER - uint8_t i_min1, i_plus1; - uint8_t sinusoids = 0; -#endif - - /* load new values into ringbuffer */ - memcpy(sbr->G_temp_prev[ch][sbr->GQ_ringbuf_index[ch]], adj->G_lim_boost[l], sbr->M*sizeof(real_t)); - memcpy(sbr->Q_temp_prev[ch][sbr->GQ_ringbuf_index[ch]], adj->Q_M_lim_boost[l], sbr->M*sizeof(real_t)); - - for (m = 0; m < sbr->M; m++) - { - qmf_t psi; - - G_filt = 0; - Q_filt = 0; - -#ifndef SBR_LOW_POWER - if (h_SL != 0) - { - uint8_t ri = sbr->GQ_ringbuf_index[ch]; - for (n = 0; n <= 4; n++) - { - real_t curr_h_smooth = h_smooth[n]; - ri++; - if (ri >= 5) - ri -= 5; - G_filt += MUL_F(sbr->G_temp_prev[ch][ri][m], curr_h_smooth); - Q_filt += MUL_F(sbr->Q_temp_prev[ch][ri][m], curr_h_smooth); - } - } else { -#endif - G_filt = sbr->G_temp_prev[ch][sbr->GQ_ringbuf_index[ch]][m]; - Q_filt = sbr->Q_temp_prev[ch][sbr->GQ_ringbuf_index[ch]][m]; -#ifndef SBR_LOW_POWER - } -#endif - - Q_filt = (adj->S_M_boost[l][m] != 0 || no_noise) ? 0 : Q_filt; - - /* add noise to the output */ - fIndexNoise = (fIndexNoise + 1) & 511; - - /* the smoothed gain values are applied to Xsbr */ - /* V is defined, not calculated */ - QMF_RE(Xsbr[i + sbr->tHFAdj][m+sbr->kx]) = MUL_R(G_filt, QMF_RE(Xsbr[i + sbr->tHFAdj][m+sbr->kx])) - + MUL_F(Q_filt, RE(V[fIndexNoise])); - - if (sbr->bs_extension_id == 3 && sbr->bs_extension_data == 42) - QMF_RE(Xsbr[i + sbr->tHFAdj][m+sbr->kx]) = 16428320; -#ifndef SBR_LOW_POWER - QMF_IM(Xsbr[i + sbr->tHFAdj][m+sbr->kx]) = MUL_R(G_filt, QMF_IM(Xsbr[i + sbr->tHFAdj][m+sbr->kx])) - + MUL_F(Q_filt, IM(V[fIndexNoise])); -#endif - - { - int8_t rev = (((m + sbr->kx) & 1) ? -1 : 1); - QMF_RE(psi) = adj->S_M_boost[l][m] * phi_re[fIndexSine]; - QMF_RE(Xsbr[i + sbr->tHFAdj][m+sbr->kx]) += REAL_UPSCALE(QMF_RE(psi)); - -#ifndef SBR_LOW_POWER - QMF_IM(psi) = rev * adj->S_M_boost[l][m] * phi_im[fIndexSine]; - QMF_IM(Xsbr[i + sbr->tHFAdj][m+sbr->kx]) += REAL_UPSCALE(QMF_IM(psi)); -#else - - i_min1 = (fIndexSine - 1) & 3; - i_plus1 = (fIndexSine + 1) & 3; - - real_t tmp1 = 0; - real_t tmp2 = 0; - real_t tmp3 = 0; - if ((m == 0) && (phi_re[i_plus1] != 0)) - { - tmp1 += (phi_re[i_plus1] * MUL_F(REAL_UPSCALE(adj->S_M_boost[l][0]), FRAC_CONST(0.00815))); - if (sbr->M != 0) - { - tmp2 -= (phi_re[i_plus1] * MUL_F(REAL_UPSCALE(adj->S_M_boost[l][1]), FRAC_CONST(0.00815))); - } - } - if ((m > 0) && (m < sbr->M - 1) && (sinusoids < 16) && (phi_re[i_min1] != 0)) - { - tmp2 -= (phi_re[i_min1] * MUL_F(REAL_UPSCALE(adj->S_M_boost[l][m - 1]), FRAC_CONST(0.00815))); - } - if ((m > 0) && (m < sbr->M - 1) && (sinusoids < 16) && (phi_re[i_plus1] != 0)) - { - tmp2 -= (phi_re[i_plus1] * MUL_F(REAL_UPSCALE(adj->S_M_boost[l][m + 1]), FRAC_CONST(0.00815))); - } - if ((m == sbr->M - 1) && (sinusoids < 16) && (phi_re[i_min1] != 0)) - { - if (m > 0) - { - tmp2 -= (phi_re[i_min1] * MUL_F(REAL_UPSCALE(adj->S_M_boost[l][m - 1]), FRAC_CONST(0.00815))); - } - if (m + sbr->kx < 64) - { - tmp3 += (phi_re[i_min1] * MUL_F(REAL_UPSCALE(adj->S_M_boost[l][m]), FRAC_CONST(0.00815))); - } - } - - if (rev<0) - { - tmp1 = -tmp1; - tmp2 = -tmp2; - tmp3 = -tmp3; - } - QMF_RE(Xsbr[i + sbr->tHFAdj][m+sbr->kx - 1]) += tmp1; - QMF_RE(Xsbr[i + sbr->tHFAdj][m+sbr->kx ]) += tmp2; - QMF_RE(Xsbr[i + sbr->tHFAdj][m+sbr->kx + 1]) += tmp3; - - if (adj->S_M_boost[l][m] != 0) - sinusoids++; -#endif - } - } - - fIndexSine = (fIndexSine + 1) & 3; - - /* update the ringbuffer index used for filtering G and Q with h_smooth */ - sbr->GQ_ringbuf_index[ch]++; - if (sbr->GQ_ringbuf_index[ch] >= 5) - sbr->GQ_ringbuf_index[ch] = 0; - } - } - - sbr->index_noise_prev[ch] = fIndexNoise; - sbr->psi_is_prev[ch] = fIndexSine; -} - -#endif diff --git a/apps/codecs/libfaad/sbr_hfadj.h b/apps/codecs/libfaad/sbr_hfadj.h deleted file mode 100644 index 1411769799..0000000000 --- a/apps/codecs/libfaad/sbr_hfadj.h +++ /dev/null @@ -1,54 +0,0 @@ -/* -** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -** -** Any non-GPL usage of this software or parts of this software is strictly -** forbidden. -** -** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. -** -** $Id$ -**/ - -#ifndef __SBR_HFADJ_H__ -#define __SBR_HFADJ_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct -{ - real_t G_lim_boost[MAX_L_E][MAX_M]; - real_t Q_M_lim_boost[MAX_L_E][MAX_M]; - real_t S_M_boost[MAX_L_E][MAX_M]; -} sbr_hfadj_info; - - -void hf_adjustment(sbr_info *sbr, qmf_t Xsbr[MAX_NTSRHFG][64] -#ifdef SBR_LOW_POWER - ,real_t *deg -#endif - ,uint8_t ch); - - -#ifdef __cplusplus -} -#endif -#endif - diff --git a/apps/codecs/libfaad/sbr_hfgen.c b/apps/codecs/libfaad/sbr_hfgen.c deleted file mode 100644 index 3a5b250aa7..0000000000 --- a/apps/codecs/libfaad/sbr_hfgen.c +++ /dev/null @@ -1,539 +0,0 @@ -/* -** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -** -** Any non-GPL usage of this software or parts of this software is strictly -** forbidden. -** -** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. -** -** $Id$ -**/ - -/* High Frequency generation */ - -#include "common.h" -#include "structs.h" - -#ifdef SBR_DEC - -#include "sbr_syntax.h" -#include "sbr_hfgen.h" -#include "sbr_fbt.h" - - -/* static function declarations */ -#ifdef SBR_LOW_POWER -static void calc_prediction_coef_lp(sbr_info *sbr, qmf_t Xlow[MAX_NTSRHFG][64], - complex_t *alpha_0, complex_t *alpha_1, real_t *rxx); -static void calc_aliasing_degree(sbr_info *sbr, real_t *rxx, real_t *deg); -#else -static void calc_prediction_coef(sbr_info *sbr, qmf_t Xlow[MAX_NTSRHFG][64], - complex_t *alpha_0, complex_t *alpha_1, uint8_t k); -#endif -static void calc_chirp_factors(sbr_info *sbr, uint8_t ch); -static void patch_construction(sbr_info *sbr); - - -void hf_generation(sbr_info *sbr, - qmf_t Xlow[MAX_NTSRHFG][64], - qmf_t Xhigh[MAX_NTSRHFG][64] -#ifdef SBR_LOW_POWER - ,real_t *deg -#endif - ,uint8_t ch) -{ - uint8_t l, i, x; - complex_t alpha_0[64] MEM_ALIGN_ATTR; - complex_t alpha_1[64] MEM_ALIGN_ATTR; -#ifdef SBR_LOW_POWER - real_t rxx[64]; -#endif - - uint8_t offset = sbr->tHFAdj; - uint8_t first = sbr->t_E[ch][0]; - uint8_t last = sbr->t_E[ch][sbr->L_E[ch]]; - - calc_chirp_factors(sbr, ch); - -#ifdef SBR_LOW_POWER - memset(deg, 0, 64*sizeof(real_t)); -#endif - - if ((ch == 0) && (sbr->Reset)) - patch_construction(sbr); - - /* calculate the prediction coefficients */ -#ifdef SBR_LOW_POWER - calc_prediction_coef_lp(sbr, Xlow, alpha_0, alpha_1, rxx); - calc_aliasing_degree(sbr, rxx, deg); -#endif - - /* actual HF generation */ - for (i = 0; i < sbr->noPatches; i++) - { - for (x = 0; x < sbr->patchNoSubbands[i]; x++) - { - real_t a0_r, a0_i, a1_r, a1_i; - real_t bw, bw2; - uint8_t q, p, k, g; - - /* find the low and high band for patching */ - k = sbr->kx + x; - for (q = 0; q < i; q++) - { - k += sbr->patchNoSubbands[q]; - } - p = sbr->patchStartSubband[i] + x; - -#ifdef SBR_LOW_POWER - if (x != 0 /*x < sbr->patchNoSubbands[i]-1*/) - deg[k] = deg[p]; - else - deg[k] = 0; -#endif - - g = sbr->table_map_k_to_g[k]; - - bw = sbr->bwArray[ch][g]; - bw2 = MUL_C(bw, bw); - - /* do the patching */ - /* with or without filtering */ - if (bw2 > 0) - { - real_t temp1_r, temp2_r, temp3_r; -#ifndef SBR_LOW_POWER - real_t temp1_i, temp2_i, temp3_i; - calc_prediction_coef(sbr, Xlow, alpha_0, alpha_1, p); -#endif - - a0_r = MUL_C(RE(alpha_0[p]), bw); - a1_r = MUL_C(RE(alpha_1[p]), bw2); -#ifndef SBR_LOW_POWER - a0_i = MUL_C(IM(alpha_0[p]), bw); - a1_i = MUL_C(IM(alpha_1[p]), bw2); -#endif - - temp2_r = QMF_RE(Xlow[first - 2 + offset][p]); - temp3_r = QMF_RE(Xlow[first - 1 + offset][p]); -#ifndef SBR_LOW_POWER - temp2_i = QMF_IM(Xlow[first - 2 + offset][p]); - temp3_i = QMF_IM(Xlow[first - 1 + offset][p]); -#endif - for (l = first; l < last; l++) - { - temp1_r = temp2_r; - temp2_r = temp3_r; - temp3_r = QMF_RE(Xlow[l + offset][p]); -#ifndef SBR_LOW_POWER - temp1_i = temp2_i; - temp2_i = temp3_i; - temp3_i = QMF_IM(Xlow[l + offset][p]); -#endif - -#ifdef SBR_LOW_POWER - QMF_RE(Xhigh[l + offset][k]) = temp3_r + - (MUL_R(a0_r, temp2_r) + MUL_R(a1_r, temp1_r)); -#else - QMF_RE(Xhigh[l + offset][k]) = temp3_r + - (MUL_R(a0_r, temp2_r) - MUL_R(a0_i, temp2_i) + - MUL_R(a1_r, temp1_r) - MUL_R(a1_i, temp1_i)); - QMF_IM(Xhigh[l + offset][k]) = temp3_i + - (MUL_R(a0_i, temp2_r) + MUL_R(a0_r, temp2_i) + - MUL_R(a1_i, temp1_r) + MUL_R(a1_r, temp1_i)); -#endif - } - } else { - for (l = first; l < last; l++) - { - QMF_RE(Xhigh[l + offset][k]) = QMF_RE(Xlow[l + offset][p]); -#ifndef SBR_LOW_POWER - QMF_IM(Xhigh[l + offset][k]) = QMF_IM(Xlow[l + offset][p]); -#endif - } - } - } - } - - if (sbr->Reset) - { - limiter_frequency_table(sbr); - } -} - -typedef struct -{ - complex_t r01; - complex_t r02; - complex_t r11; - complex_t r12; - complex_t r22; - real_t det; -} acorr_coef; - -/* Within auto_correlation(...) a pre-shift of >>ACDET_EXP is needed to avoid - * overflow when multiply-adding the FRACT-variables -- FRACT part is 31 bits. - * After the calculation has been finished the result 'ac->det' needs to be - * post-shifted by <<(4*ACDET_EXP). This pre-/post-shifting is needed for - * FIXED_POINT only. */ -#ifdef FIXED_POINT -#define ACDET_EXP 3 -#define ACDET_PRE(A) (A)>>ACDET_EXP -#define ACDET_POST(A) (A)<<(4*ACDET_EXP) -#else -#define ACDET_PRE(A) (A) -#define ACDET_POST(A) (A) -#endif - -#ifdef SBR_LOW_POWER -static void auto_correlation(sbr_info *sbr, acorr_coef *ac, - qmf_t buffer[MAX_NTSRHFG][64], - uint8_t bd, uint8_t len) -{ - real_t r01 = 0, r02 = 0, r11 = 0; - real_t tmp1, tmp2; - int8_t j; - uint8_t offset = sbr->tHFAdj; - const real_t rel = FRAC_CONST(0.999999); // 1 / (1 + 1e-6f); - - for (j = offset; j < len + offset; j++) - { - real_t buf_j = ACDET_PRE(QMF_RE(buffer[j ][bd])); - real_t buf_j_1 = ACDET_PRE(QMF_RE(buffer[j-1][bd])); - real_t buf_j_2 = ACDET_PRE(QMF_RE(buffer[j-2][bd])); - - r01 += MUL_F(buf_j , buf_j_1); - r02 += MUL_F(buf_j , buf_j_2); - r11 += MUL_F(buf_j_1, buf_j_1); - } - tmp1 = ACDET_PRE(QMF_RE(buffer[len+offset-1][bd])); - tmp2 = ACDET_PRE(QMF_RE(buffer[ offset-1][bd])); - RE(ac->r12) = r01 - MUL_F(tmp1, tmp1) + MUL_F(tmp2, tmp2); - - tmp1 = ACDET_PRE(QMF_RE(buffer[len+offset-2][bd])); - tmp2 = ACDET_PRE(QMF_RE(buffer[ offset-2][bd])); - RE(ac->r22) = r11 - MUL_F(tmp1, tmp1) + MUL_F(tmp2, tmp2); - RE(ac->r01) = r01; - RE(ac->r02) = r02; - RE(ac->r11) = r11; - - ac->det = MUL_F(RE(ac->r11), RE(ac->r22)) - MUL_F(MUL_F(RE(ac->r12), RE(ac->r12)), rel); - ac->det = ACDET_POST(ac->det); -} -#else -static void auto_correlation(sbr_info *sbr, acorr_coef *ac, qmf_t buffer[MAX_NTSRHFG][64], - uint8_t bd, uint8_t len) -{ - real_t r01r = 0, r01i = 0, r02r = 0, r02i = 0, r11r = 0; - real_t temp1_r, temp1_i, temp2_r, temp2_i, temp3_r, temp3_i; - real_t temp4_r, temp4_i, temp5_r, temp5_i; - int8_t j; - uint8_t offset = sbr->tHFAdj; - const real_t rel = FRAC_CONST(0.999999); // 1 / (1 + 1e-6f); - - temp2_r = ACDET_PRE(QMF_RE(buffer[offset-2][bd])); - temp2_i = ACDET_PRE(QMF_IM(buffer[offset-2][bd])); - temp3_r = ACDET_PRE(QMF_RE(buffer[offset-1][bd])); - temp3_i = ACDET_PRE(QMF_IM(buffer[offset-1][bd])); - // Save these because they are needed after loop - temp4_r = temp2_r; - temp4_i = temp2_i; - temp5_r = temp3_r; - temp5_i = temp3_i; - - for (j = offset; j < len + offset; j++) - { - temp1_r = temp2_r; - temp1_i = temp2_i; - temp2_r = temp3_r; - temp2_i = temp3_i; - temp3_r = ACDET_PRE(QMF_RE(buffer[j][bd])); - temp3_i = ACDET_PRE(QMF_IM(buffer[j][bd])); - r01r += MUL_F(temp3_r, temp2_r) + MUL_F(temp3_i, temp2_i); - r01i += MUL_F(temp3_i, temp2_r) - MUL_F(temp3_r, temp2_i); - r02r += MUL_F(temp3_r, temp1_r) + MUL_F(temp3_i, temp1_i); - r02i += MUL_F(temp3_i, temp1_r) - MUL_F(temp3_r, temp1_i); - r11r += MUL_F(temp2_r, temp2_r) + MUL_F(temp2_i, temp2_i); - } - - RE(ac->r12) = r01r - (MUL_F(temp3_r, temp2_r) + MUL_F(temp3_i, temp2_i)) + - (MUL_F(temp5_r, temp4_r) + MUL_F(temp5_i, temp4_i)); - IM(ac->r12) = r01i - (MUL_F(temp3_i, temp2_r) - MUL_F(temp3_r, temp2_i)) + - (MUL_F(temp5_i, temp4_r) - MUL_F(temp5_r, temp4_i)); - RE(ac->r22) = r11r - (MUL_F(temp2_r, temp2_r) + MUL_F(temp2_i, temp2_i)) + - (MUL_F(temp4_r, temp4_r) + MUL_F(temp4_i, temp4_i)); - RE(ac->r01) = r01r; - IM(ac->r01) = r01i; - RE(ac->r02) = r02r; - IM(ac->r02) = r02i; - RE(ac->r11) = r11r; - - ac->det = MUL_F(RE(ac->r11), RE(ac->r22)) - MUL_F((MUL_F(RE(ac->r12), RE(ac->r12)) + MUL_F(IM(ac->r12), IM(ac->r12))), rel); - ac->det = ACDET_POST(ac->det); - -} -#endif - -/* calculate linear prediction coefficients using the covariance method */ -#ifndef SBR_LOW_POWER -static void calc_prediction_coef(sbr_info *sbr, qmf_t Xlow[MAX_NTSRHFG][64], - complex_t *alpha_0, complex_t *alpha_1, uint8_t k) -{ - real_t tmp, mul; - acorr_coef ac; - - auto_correlation(sbr, &ac, Xlow, k, sbr->numTimeSlotsRate + 6); - - if (ac.det == 0) - { - RE(alpha_1[k]) = 0; - IM(alpha_1[k]) = 0; - } else { - mul = DIV_R(REAL_CONST(1.0), ac.det); - tmp = (MUL_R(RE(ac.r01), RE(ac.r12)) - MUL_R(IM(ac.r01), IM(ac.r12)) - MUL_R(RE(ac.r02), RE(ac.r11))); - RE(alpha_1[k]) = MUL_R(tmp, mul); - tmp = (MUL_R(IM(ac.r01), RE(ac.r12)) + MUL_R(RE(ac.r01), IM(ac.r12)) - MUL_R(IM(ac.r02), RE(ac.r11))); - IM(alpha_1[k]) = MUL_R(tmp, mul); - } - - if (RE(ac.r11) == 0) - { - RE(alpha_0[k]) = 0; - IM(alpha_0[k]) = 0; - } else { - mul = DIV_R(REAL_CONST(1.0), RE(ac.r11)); - tmp = -(RE(ac.r01) + MUL_R(RE(alpha_1[k]), RE(ac.r12)) + MUL_R(IM(alpha_1[k]), IM(ac.r12))); - RE(alpha_0[k]) = MUL_R(tmp, mul); - tmp = -(IM(ac.r01) + MUL_R(IM(alpha_1[k]), RE(ac.r12)) - MUL_R(RE(alpha_1[k]), IM(ac.r12))); - IM(alpha_0[k]) = MUL_R(tmp, mul); - } - - if ((MUL_R(RE(alpha_0[k]),RE(alpha_0[k])) + MUL_R(IM(alpha_0[k]),IM(alpha_0[k])) >= REAL_CONST(16)) || - (MUL_R(RE(alpha_1[k]),RE(alpha_1[k])) + MUL_R(IM(alpha_1[k]),IM(alpha_1[k])) >= REAL_CONST(16))) - { - RE(alpha_0[k]) = 0; - IM(alpha_0[k]) = 0; - RE(alpha_1[k]) = 0; - IM(alpha_1[k]) = 0; - } -} -#else -static void calc_prediction_coef_lp(sbr_info *sbr, qmf_t Xlow[MAX_NTSRHFG][64], - complex_t *alpha_0, complex_t *alpha_1, real_t *rxx) -{ - uint8_t k; - real_t tmp, mul; - acorr_coef ac; - - for (k = 1; k < sbr->f_master[0]; k++) - { - auto_correlation(sbr, &ac, Xlow, k, sbr->numTimeSlotsRate + 6); - - if (ac.det == 0) - { - RE(alpha_0[k]) = 0; - RE(alpha_1[k]) = 0; - } else { - mul = DIV_R(REAL_CONST(1.0), ac.det); - tmp = MUL_R(RE(ac.r01), RE(ac.r22)) - MUL_R(RE(ac.r12), RE(ac.r02)); - RE(alpha_0[k]) = -MUL_R(tmp, mul); - tmp = MUL_R(RE(ac.r01), RE(ac.r12)) - MUL_R(RE(ac.r02), RE(ac.r11)); - RE(alpha_1[k]) = MUL_R(tmp, mul); - } - - if ((RE(alpha_0[k]) >= REAL_CONST(4)) || (RE(alpha_1[k]) >= REAL_CONST(4))) - { - RE(alpha_0[k]) = REAL_CONST(0); - RE(alpha_1[k]) = REAL_CONST(0); - } - - /* reflection coefficient */ - if (RE(ac.r11) == 0) - { - rxx[k] = COEF_CONST(0.0); - } else { - rxx[k] = DIV_C(RE(ac.r01), RE(ac.r11)); - rxx[k] = -rxx[k]; - if (rxx[k] > COEF_CONST( 1.0)) rxx[k] = COEF_CONST(1.0); - if (rxx[k] < COEF_CONST(-1.0)) rxx[k] = COEF_CONST(-1.0); - } - } -} - -static void calc_aliasing_degree(sbr_info *sbr, real_t *rxx, real_t *deg) -{ - uint8_t k; - - rxx[0] = COEF_CONST(0.0); - deg[1] = COEF_CONST(0.0); - - for (k = 2; k < sbr->k0; k++) - { - deg[k] = COEF_CONST(0.0); - - if ((k % 2 == 0) && (rxx[k] < COEF_CONST(0.0))) - { - if (rxx[k-1] < COEF_CONST(0.0)) - { - deg[k] = COEF_CONST(1.0); - - if (rxx[k-2] > COEF_CONST(0.0)) - { - deg[k-1] = COEF_CONST(1.0) - MUL_C(rxx[k-1], rxx[k-1]); - } - } else if (rxx[k-2] > COEF_CONST(0.0)) { - deg[k] = COEF_CONST(1.0) - MUL_C(rxx[k-1], rxx[k-1]); - } - } - - if ((k % 2 == 1) && (rxx[k] > COEF_CONST(0.0))) - { - if (rxx[k-1] > COEF_CONST(0.0)) - { - deg[k] = COEF_CONST(1.0); - - if (rxx[k-2] < COEF_CONST(0.0)) - { - deg[k-1] = COEF_CONST(1.0) - MUL_C(rxx[k-1], rxx[k-1]); - } - } else if (rxx[k-2] < COEF_CONST(0.0)) { - deg[k] = COEF_CONST(1.0) - MUL_C(rxx[k-1], rxx[k-1]); - } - } - } -} -#endif - -/* FIXED POINT: bwArray = COEF */ -static real_t mapNewBw(uint8_t invf_mode, uint8_t invf_mode_prev) -{ - switch (invf_mode) - { - case 1: /* LOW */ - if (invf_mode_prev == 0) /* NONE */ - return COEF_CONST(0.6); - else - return COEF_CONST(0.75); - - case 2: /* MID */ - return COEF_CONST(0.9); - - case 3: /* HIGH */ - return COEF_CONST(0.98); - - default: /* NONE */ - if (invf_mode_prev == 1) /* LOW */ - return COEF_CONST(0.6); - else - return COEF_CONST(0.0); - } -} - -/* FIXED POINT: bwArray = COEF */ -static void calc_chirp_factors(sbr_info *sbr, uint8_t ch) -{ - uint8_t i; - - for (i = 0; i < sbr->N_Q; i++) - { - sbr->bwArray[ch][i] = mapNewBw(sbr->bs_invf_mode[ch][i], sbr->bs_invf_mode_prev[ch][i]); - - if (sbr->bwArray[ch][i] < sbr->bwArray_prev[ch][i]) - sbr->bwArray[ch][i] = MUL_F(sbr->bwArray[ch][i], FRAC_CONST(0.75)) + MUL_F(sbr->bwArray_prev[ch][i], FRAC_CONST(0.25)); - else - sbr->bwArray[ch][i] = MUL_F(sbr->bwArray[ch][i], FRAC_CONST(0.90625)) + MUL_F(sbr->bwArray_prev[ch][i], FRAC_CONST(0.09375)); - - if (sbr->bwArray[ch][i] < COEF_CONST(0.015625)) - sbr->bwArray[ch][i] = COEF_CONST(0.0); - - if (sbr->bwArray[ch][i] > COEF_CONST(0.99609375)) - sbr->bwArray[ch][i] = COEF_CONST(0.99609375); - - sbr->bwArray_prev[ch][i] = sbr->bwArray[ch][i]; - sbr->bs_invf_mode_prev[ch][i] = sbr->bs_invf_mode[ch][i]; - } -} - -static void patch_construction(sbr_info *sbr) -{ - uint8_t i, k; - uint8_t odd, sb; - uint8_t msb = sbr->k0; - uint8_t usb = sbr->kx; - uint8_t goalSbTab[] = { 21, 23, 32, 43, 46, 64, 85, 93, 128, 0, 0, 0 }; - /* (uint8_t)(2.048e6/sbr->sample_rate + 0.5); */ - uint8_t goalSb = goalSbTab[get_sr_index(sbr->sample_rate)]; - - sbr->noPatches = 0; - - if (goalSb < (sbr->kx + sbr->M)) - { - for (i = 0, k = 0; sbr->f_master[i] < goalSb; i++) - k = i+1; - } else { - k = sbr->N_master; - } - - if (sbr->N_master == 0) - { - sbr->noPatches = 0; - sbr->patchNoSubbands[0] = 0; - sbr->patchStartSubband[0] = 0; - - return; - } - - do - { - int8_t j = k + 1; - - do - { - j--; - sb = sbr->f_master[j]; - odd = (sb - 2 + sbr->k0) % 2; - - } while (sb > (sbr->k0 - 1 + msb - odd)); - - sbr->patchNoSubbands[sbr->noPatches] = max(sb - usb, 0); - sbr->patchStartSubband[sbr->noPatches] = sbr->k0 - odd - - sbr->patchNoSubbands[sbr->noPatches]; - - if (sbr->patchNoSubbands[sbr->noPatches] > 0) - { - usb = sb; - msb = sb; - sbr->noPatches++; - } else { - msb = sbr->kx; - } - - if (sbr->f_master[k] - sb < 3) - k = sbr->N_master; - } while (sb != (sbr->kx + sbr->M)); - - if ((sbr->patchNoSubbands[sbr->noPatches-1] < 3) && (sbr->noPatches > 1)) - { - sbr->noPatches--; - } - - sbr->noPatches = min(sbr->noPatches, 5); -} - -#endif diff --git a/apps/codecs/libfaad/sbr_hfgen.h b/apps/codecs/libfaad/sbr_hfgen.h deleted file mode 100644 index a69e53e47d..0000000000 --- a/apps/codecs/libfaad/sbr_hfgen.h +++ /dev/null @@ -1,47 +0,0 @@ -/* -** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -** -** Any non-GPL usage of this software or parts of this software is strictly -** forbidden. -** -** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. -** -** $Id$ -**/ - -#ifndef __SBR_HFGEN_H__ -#define __SBR_HFGEN_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -void hf_generation(sbr_info *sbr, - qmf_t Xlow[MAX_NTSRHFG][64], - qmf_t Xhigh[MAX_NTSRHFG][64] -#ifdef SBR_LOW_POWER - ,real_t *deg -#endif - ,uint8_t ch); - -#ifdef __cplusplus -} -#endif -#endif - diff --git a/apps/codecs/libfaad/sbr_huff.c b/apps/codecs/libfaad/sbr_huff.c deleted file mode 100644 index 92fe07a392..0000000000 --- a/apps/codecs/libfaad/sbr_huff.c +++ /dev/null @@ -1,357 +0,0 @@ -/* -** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -** -** Any non-GPL usage of this software or parts of this software is strictly -** forbidden. -** -** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. -** -** $Id$ -**/ - -#include "common.h" -#include "structs.h" - -#ifdef SBR_DEC - -#include "sbr_syntax.h" -#include "bits.h" -#include "sbr_huff.h" -#include "sbr_e_nf.h" - - -typedef const int8_t (*sbr_huff_tab)[2]; - -static const int8_t t_huffman_env_1_5dB[120][2] = { - { 1, 2 }, { -64, -65 }, { 3, 4 }, { -63, -66 }, - { 5, 6 }, { -62, -67 }, { 7, 8 }, { -61, -68 }, - { 9, 10 }, { -60, -69 }, { 11, 12 }, { -59, -70 }, - { 13, 14 }, { -58, -71 }, { 15, 16 }, { -57, -72 }, - { 17, 18 }, { -73, -56 }, { 19, 21 }, { -74, 20 }, - { -55, -75 }, { 22, 26 }, { 23, 24 }, { -54, -76 }, - { -77, 25 }, { -53, -78 }, { 27, 34 }, { 28, 29 }, - { -52, -79 }, { 30, 31 }, { -80, -51 }, { 32, 33 }, - { -83, -82 }, { -81, -50 }, { 35, 57 }, { 36, 40 }, - { 37, 38 }, { -88, -84 }, { -48, 39 }, { -90, -85 }, - { 41, 46 }, { 42, 43 }, { -49, -87 }, { 44, 45 }, - { -89, -86 }, {-124,-123 }, { 47, 50 }, { 48, 49 }, - {-122,-121 }, {-120,-119 }, { 51, 54 }, { 52, 53 }, - {-118,-117 }, {-116,-115 }, { 55, 56 }, {-114,-113 }, - {-112,-111 }, { 58, 89 }, { 59, 74 }, { 60, 67 }, - { 61, 64 }, { 62, 63 }, {-110,-109 }, {-108,-107 }, - { 65, 66 }, {-106,-105 }, {-104,-103 }, { 68, 71 }, - { 69, 70 }, {-102,-101 }, {-100, -99 }, { 72, 73 }, - { -98, -97 }, { -96, -95 }, { 75, 82 }, { 76, 79 }, - { 77, 78 }, { -94, -93 }, { -92, -91 }, { 80, 81 }, - { -47, -46 }, { -45, -44 }, { 83, 86 }, { 84, 85 }, - { -43, -42 }, { -41, -40 }, { 87, 88 }, { -39, -38 }, - { -37, -36 }, { 90, 105 }, { 91, 98 }, { 92, 95 }, - { 93, 94 }, { -35, -34 }, { -33, -32 }, { 96, 97 }, - { -31, -30 }, { -29, -28 }, { 99, 102 }, { 100, 101 }, - { -27, -26 }, { -25, -24 }, { 103, 104 }, { -23, -22 }, - { -21, -20 }, { 106, 113 }, { 107, 110 }, { 108, 109 }, - { -19, -18 }, { -17, -16 }, { 111, 112 }, { -15, -14 }, - { -13, -12 }, { 114, 117 }, { 115, 116 }, { -11, -10 }, - { -9, -8 }, { 118, 119 }, { -7, -6 }, { -5, -4 } -}; - -static const int8_t f_huffman_env_1_5dB[120][2] = { - { 1, 2 }, { -64, -65 }, { 3, 4 }, { -63, -66 }, - { 5, 6 }, { -67, -62 }, { 7, 8 }, { -68, -61 }, - { 9, 10 }, { -69, -60 }, { 11, 13 }, { -70, 12 }, - { -59, -71 }, { 14, 16 }, { -58, 15 }, { -72, -57 }, - { 17, 19 }, { -73, 18 }, { -56, -74 }, { 20, 23 }, - { 21, 22 }, { -55, -75 }, { -54, -53 }, { 24, 27 }, - { 25, 26 }, { -76, -52 }, { -77, -51 }, { 28, 31 }, - { 29, 30 }, { -50, -78 }, { -79, -49 }, { 32, 36 }, - { 33, 34 }, { -48, -47 }, { -80, 35 }, { -81, -82 }, - { 37, 47 }, { 38, 41 }, { 39, 40 }, { -83, -46 }, - { -45, -84 }, { 42, 44 }, { -85, 43 }, { -44, -43 }, - { 45, 46 }, { -88, -87 }, { -86, -90 }, { 48, 66 }, - { 49, 56 }, { 50, 53 }, { 51, 52 }, { -92, -42 }, - { -41, -39 }, { 54, 55 }, {-105, -89 }, { -38, -37 }, - { 57, 60 }, { 58, 59 }, { -94, -91 }, { -40, -36 }, - { 61, 63 }, { -20, 62 }, {-115,-110 }, { 64, 65 }, - {-108,-107 }, {-101, -97 }, { 67, 89 }, { 68, 75 }, - { 69, 72 }, { 70, 71 }, { -95, -93 }, { -34, -27 }, - { 73, 74 }, { -22, -17 }, { -16,-124 }, { 76, 82 }, - { 77, 79 }, {-123, 78 }, {-122,-121 }, { 80, 81 }, - {-120,-119 }, {-118,-117 }, { 83, 86 }, { 84, 85 }, - {-116,-114 }, {-113,-112 }, { 87, 88 }, {-111,-109 }, - {-106,-104 }, { 90, 105 }, { 91, 98 }, { 92, 95 }, - { 93, 94 }, {-103,-102 }, {-100, -99 }, { 96, 97 }, - { -98, -96 }, { -35, -33 }, { 99, 102 }, { 100, 101 }, - { -32, -31 }, { -30, -29 }, { 103, 104 }, { -28, -26 }, - { -25, -24 }, { 106, 113 }, { 107, 110 }, { 108, 109 }, - { -23, -21 }, { -19, -18 }, { 111, 112 }, { -15, -14 }, - { -13, -12 }, { 114, 117 }, { 115, 116 }, { -11, -10 }, - { -9, -8 }, { 118, 119 }, { -7, -6 }, { -5, -4 } -}; - -static const int8_t t_huffman_env_bal_1_5dB[48][2] = { - { -64, 1 }, { -63, 2 }, { -65, 3 }, { -62, 4 }, - { -66, 5 }, { -61, 6 }, { -67, 7 }, { -60, 8 }, - { -68, 9 }, { 10, 11 }, { -69, -59 }, { 12, 13 }, - { -70, -58 }, { 14, 28 }, { 15, 21 }, { 16, 18 }, - { -57, 17 }, { -71, -56 }, { 19, 20 }, { -88, -87 }, - { -86, -85 }, { 22, 25 }, { 23, 24 }, { -84, -83 }, - { -82, -81 }, { 26, 27 }, { -80, -79 }, { -78, -77 }, - { 29, 36 }, { 30, 33 }, { 31, 32 }, { -76, -75 }, - { -74, -73 }, { 34, 35 }, { -72, -55 }, { -54, -53 }, - { 37, 41 }, { 38, 39 }, { -52, -51 }, { -50, 40 }, - { -49, -48 }, { 42, 45 }, { 43, 44 }, { -47, -46 }, - { -45, -44 }, { 46, 47 }, { -43, -42 }, { -41, -40 } -}; - -static const int8_t f_huffman_env_bal_1_5dB[48][2] = { - { -64, 1 }, { -65, 2 }, { -63, 3 }, { -66, 4 }, - { -62, 5 }, { -61, 6 }, { -67, 7 }, { -68, 8 }, - { -60, 9 }, { 10, 11 }, { -69, -59 }, { -70, 12 }, - { -58, 13 }, { 14, 17 }, { -71, 15 }, { -57, 16 }, - { -56, -73 }, { 18, 32 }, { 19, 25 }, { 20, 22 }, - { -72, 21 }, { -88, -87 }, { 23, 24 }, { -86, -85 }, - { -84, -83 }, { 26, 29 }, { 27, 28 }, { -82, -81 }, - { -80, -79 }, { 30, 31 }, { -78, -77 }, { -76, -75 }, - { 33, 40 }, { 34, 37 }, { 35, 36 }, { -74, -55 }, - { -54, -53 }, { 38, 39 }, { -52, -51 }, { -50, -49 }, - { 41, 44 }, { 42, 43 }, { -48, -47 }, { -46, -45 }, - { 45, 46 }, { -44, -43 }, { -42, 47 }, { -41, -40 } -}; - -static const int8_t t_huffman_env_3_0dB[62][2] = { - { -64, 1 }, { -65, 2 }, { -63, 3 }, { -66, 4 }, - { -62, 5 }, { -67, 6 }, { -61, 7 }, { -68, 8 }, - { -60, 9 }, { 10, 11 }, { -69, -59 }, { 12, 14 }, - { -70, 13 }, { -71, -58 }, { 15, 18 }, { 16, 17 }, - { -72, -57 }, { -73, -74 }, { 19, 22 }, { -56, 20 }, - { -55, 21 }, { -54, -77 }, { 23, 31 }, { 24, 25 }, - { -75, -76 }, { 26, 27 }, { -78, -53 }, { 28, 29 }, - { -52, -95 }, { -94, 30 }, { -93, -92 }, { 32, 47 }, - { 33, 40 }, { 34, 37 }, { 35, 36 }, { -91, -90 }, - { -89, -88 }, { 38, 39 }, { -87, -86 }, { -85, -84 }, - { 41, 44 }, { 42, 43 }, { -83, -82 }, { -81, -80 }, - { 45, 46 }, { -79, -51 }, { -50, -49 }, { 48, 55 }, - { 49, 52 }, { 50, 51 }, { -48, -47 }, { -46, -45 }, - { 53, 54 }, { -44, -43 }, { -42, -41 }, { 56, 59 }, - { 57, 58 }, { -40, -39 }, { -38, -37 }, { 60, 61 }, - { -36, -35 }, { -34, -33 } -}; - -static const int8_t f_huffman_env_3_0dB[62][2] = { - { -64, 1 }, { -65, 2 }, { -63, 3 }, { -66, 4 }, - { -62, 5 }, { -67, 6 }, { 7, 8 }, { -61, -68 }, - { 9, 10 }, { -60, -69 }, { 11, 12 }, { -59, -70 }, - { 13, 14 }, { -58, -71 }, { 15, 16 }, { -57, -72 }, - { 17, 19 }, { -56, 18 }, { -55, -73 }, { 20, 24 }, - { 21, 22 }, { -74, -54 }, { -53, 23 }, { -75, -76 }, - { 25, 30 }, { 26, 27 }, { -52, -51 }, { 28, 29 }, - { -77, -79 }, { -50, -49 }, { 31, 39 }, { 32, 35 }, - { 33, 34 }, { -78, -46 }, { -82, -88 }, { 36, 37 }, - { -83, -48 }, { -47, 38 }, { -86, -85 }, { 40, 47 }, - { 41, 44 }, { 42, 43 }, { -80, -44 }, { -43, -42 }, - { 45, 46 }, { -39, -87 }, { -84, -40 }, { 48, 55 }, - { 49, 52 }, { 50, 51 }, { -95, -94 }, { -93, -92 }, - { 53, 54 }, { -91, -90 }, { -89, -81 }, { 56, 59 }, - { 57, 58 }, { -45, -41 }, { -38, -37 }, { 60, 61 }, - { -36, -35 }, { -34, -33 } -}; - -static const int8_t t_huffman_env_bal_3_0dB[24][2] = { - { -64, 1 }, { -63, 2 }, { -65, 3 }, { -66, 4 }, - { -62, 5 }, { -61, 6 }, { -67, 7 }, { -68, 8 }, - { -60, 9 }, { 10, 16 }, { 11, 13 }, { -69, 12 }, - { -76, -75 }, { 14, 15 }, { -74, -73 }, { -72, -71 }, - { 17, 20 }, { 18, 19 }, { -70, -59 }, { -58, -57 }, - { 21, 22 }, { -56, -55 }, { -54, 23 }, { -53, -52 } -}; - -static const int8_t f_huffman_env_bal_3_0dB[24][2] = { - { -64, 1 }, { -65, 2 }, { -63, 3 }, { -66, 4 }, - { -62, 5 }, { -61, 6 }, { -67, 7 }, { -68, 8 }, - { -60, 9 }, { 10, 13 }, { -69, 11 }, { -59, 12 }, - { -58, -76 }, { 14, 17 }, { 15, 16 }, { -75, -74 }, - { -73, -72 }, { 18, 21 }, { 19, 20 }, { -71, -70 }, - { -57, -56 }, { 22, 23 }, { -55, -54 }, { -53, -52 } -}; - -static const int8_t t_huffman_noise_3_0dB[62][2] = { - { -64, 1 }, { -63, 2 }, { -65, 3 }, { -66, 4 }, - { -62, 5 }, { -67, 6 }, { 7, 8 }, { -61, -68 }, - { 9, 30 }, { 10, 15 }, { -60, 11 }, { -69, 12 }, - { 13, 14 }, { -59, -53 }, { -95, -94 }, { 16, 23 }, - { 17, 20 }, { 18, 19 }, { -93, -92 }, { -91, -90 }, - { 21, 22 }, { -89, -88 }, { -87, -86 }, { 24, 27 }, - { 25, 26 }, { -85, -84 }, { -83, -82 }, { 28, 29 }, - { -81, -80 }, { -79, -78 }, { 31, 46 }, { 32, 39 }, - { 33, 36 }, { 34, 35 }, { -77, -76 }, { -75, -74 }, - { 37, 38 }, { -73, -72 }, { -71, -70 }, { 40, 43 }, - { 41, 42 }, { -58, -57 }, { -56, -55 }, { 44, 45 }, - { -54, -52 }, { -51, -50 }, { 47, 54 }, { 48, 51 }, - { 49, 50 }, { -49, -48 }, { -47, -46 }, { 52, 53 }, - { -45, -44 }, { -43, -42 }, { 55, 58 }, { 56, 57 }, - { -41, -40 }, { -39, -38 }, { 59, 60 }, { -37, -36 }, - { -35, 61 }, { -34, -33 } -}; - -static const int8_t t_huffman_noise_bal_3_0dB[24][2] = { - { -64, 1 }, { -65, 2 }, { -63, 3 }, { 4, 9 }, - { -66, 5 }, { -62, 6 }, { 7, 8 }, { -76, -75 }, - { -74, -73 }, { 10, 17 }, { 11, 14 }, { 12, 13 }, - { -72, -71 }, { -70, -69 }, { 15, 16 }, { -68, -67 }, - { -61, -60 }, { 18, 21 }, { 19, 20 }, { -59, -58 }, - { -57, -56 }, { 22, 23 }, { -55, -54 }, { -53, -52 } -}; - - -static INLINE int16_t sbr_huff_dec(bitfile *ld, sbr_huff_tab t_huff) -{ - uint8_t bit; - int16_t index = 0; - - while (index >= 0) - { - bit = (uint8_t)faad_get1bit(ld); - index = t_huff[index][bit]; - } - - return index + 64; -} - -/* table 10 */ -void sbr_envelope(bitfile *ld, sbr_info *sbr, uint8_t ch) -{ - uint8_t env, band; - int8_t delta = 0; - sbr_huff_tab t_huff, f_huff; - - if ((sbr->L_E[ch] == 1) && (sbr->bs_frame_class[ch] == FIXFIX)) - sbr->amp_res[ch] = 0; - else - sbr->amp_res[ch] = sbr->bs_amp_res; - - if ((sbr->bs_coupling) && (ch == 1)) - { - delta = 1; - if (sbr->amp_res[ch]) - { - t_huff = t_huffman_env_bal_3_0dB; - f_huff = f_huffman_env_bal_3_0dB; - } else { - t_huff = t_huffman_env_bal_1_5dB; - f_huff = f_huffman_env_bal_1_5dB; - } - } else { - delta = 0; - if (sbr->amp_res[ch]) - { - t_huff = t_huffman_env_3_0dB; - f_huff = f_huffman_env_3_0dB; - } else { - t_huff = t_huffman_env_1_5dB; - f_huff = f_huffman_env_1_5dB; - } - } - - for (env = 0; env < sbr->L_E[ch]; env++) - { - if (sbr->bs_df_env[ch][env] == 0) - { - if ((sbr->bs_coupling == 1) && (ch == 1)) - { - if (sbr->amp_res[ch]) - { - sbr->E[ch][0][env] = (uint16_t)(faad_getbits(ld, 5 - DEBUGVAR(1,272,"sbr_envelope(): bs_data_env")) << delta); - } else { - sbr->E[ch][0][env] = (uint16_t)(faad_getbits(ld, 6 - DEBUGVAR(1,273,"sbr_envelope(): bs_data_env")) << delta); - } - } else { - if (sbr->amp_res[ch]) - { - sbr->E[ch][0][env] = (uint16_t)(faad_getbits(ld, 6 - DEBUGVAR(1,274,"sbr_envelope(): bs_data_env")) << delta); - } else { - sbr->E[ch][0][env] = (uint16_t)(faad_getbits(ld, 7 - DEBUGVAR(1,275,"sbr_envelope(): bs_data_env")) << delta); - } - } - - for (band = 1; band < sbr->n[sbr->f[ch][env]]; band++) - { - sbr->E[ch][band][env] = (sbr_huff_dec(ld, f_huff) << delta); - } - - } else { - for (band = 0; band < sbr->n[sbr->f[ch][env]]; band++) - { - sbr->E[ch][band][env] = (sbr_huff_dec(ld, t_huff) << delta); - } - } - } - - extract_envelope_data(sbr, ch); -} - -/* table 11 */ -void sbr_noise(bitfile *ld, sbr_info *sbr, uint8_t ch) -{ - uint8_t noise, band; - int8_t delta = 0; - sbr_huff_tab t_huff, f_huff; - - if ((sbr->bs_coupling == 1) && (ch == 1)) - { - delta = 1; - t_huff = t_huffman_noise_bal_3_0dB; - f_huff = f_huffman_env_bal_3_0dB; - } else { - delta = 0; - t_huff = t_huffman_noise_3_0dB; - f_huff = f_huffman_env_3_0dB; - } - - for (noise = 0; noise < sbr->L_Q[ch]; noise++) - { - if(sbr->bs_df_noise[ch][noise] == 0) - { - if ((sbr->bs_coupling == 1) && (ch == 1)) - { - sbr->Q[ch][0][noise] = (faad_getbits(ld, 5 - DEBUGVAR(1,276,"sbr_noise(): bs_data_noise")) << delta); - } else { - sbr->Q[ch][0][noise] = (faad_getbits(ld, 5 - DEBUGVAR(1,277,"sbr_noise(): bs_data_noise")) << delta); - } - for (band = 1; band < sbr->N_Q; band++) - { - sbr->Q[ch][band][noise] = (sbr_huff_dec(ld, f_huff) << delta); - } - } else { - for (band = 0; band < sbr->N_Q; band++) - { - sbr->Q[ch][band][noise] = (sbr_huff_dec(ld, t_huff) << delta); - } - } - } - - extract_noise_floor_data(sbr, ch); -} - -#endif diff --git a/apps/codecs/libfaad/sbr_huff.h b/apps/codecs/libfaad/sbr_huff.h deleted file mode 100644 index d81c5dc528..0000000000 --- a/apps/codecs/libfaad/sbr_huff.h +++ /dev/null @@ -1,43 +0,0 @@ -/* -** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -** -** Any non-GPL usage of this software or parts of this software is strictly -** forbidden. -** -** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. -** -** $Id$ -**/ - -#ifndef __SBR_HUFF_H__ -#define __SBR_HUFF_H__ - -#ifdef __cplusplus -extern "C" { -#endif - - -void sbr_envelope(bitfile *ld, sbr_info *sbr, uint8_t ch); -void sbr_noise(bitfile *ld, sbr_info *sbr, uint8_t ch); - -#ifdef __cplusplus -} -#endif -#endif - diff --git a/apps/codecs/libfaad/sbr_noise.h b/apps/codecs/libfaad/sbr_noise.h deleted file mode 100644 index 48f0ea9d18..0000000000 --- a/apps/codecs/libfaad/sbr_noise.h +++ /dev/null @@ -1,561 +0,0 @@ -/* -** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -** -** Any non-GPL usage of this software or parts of this software is strictly -** forbidden. -** -** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. -** -** $Id$ -**/ - -#ifndef __SBR_NOISE_H__ -#define __SBR_NOISE_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef _MSC_VER -#pragma warning(disable:4305) -#pragma warning(disable:4244) -#endif - - -/* Table 1.A.13 Noise table V */ -static const complex_t V[] MEM_ALIGN_ATTR = { - { FRAC_CONST(-0.99948155879974), FRAC_CONST(-0.59483414888382) }, - { FRAC_CONST(0.97113454341888), FRAC_CONST(-0.67528516054153) }, - { FRAC_CONST(0.14130051434040), FRAC_CONST(-0.95090985298157) }, - { FRAC_CONST(-0.47005495429039), FRAC_CONST(-0.37340548634529) }, - { FRAC_CONST(0.80705064535141), FRAC_CONST(0.29653668403625) }, - { FRAC_CONST(-0.38981479406357), FRAC_CONST(0.89572608470917) }, - { FRAC_CONST(-0.01053049881011), FRAC_CONST(-0.66959059238434) }, - { FRAC_CONST(-0.91266369819641), FRAC_CONST(-0.11522938311100) }, - { FRAC_CONST(0.54840421676636), FRAC_CONST(0.75221365690231) }, - { FRAC_CONST(0.40009254217148), FRAC_CONST(-0.98929399251938) }, - { FRAC_CONST(-0.99867975711823), FRAC_CONST(-0.88147068023682) }, - { FRAC_CONST(-0.95531076192856), FRAC_CONST(0.90908759832382) }, - { FRAC_CONST(-0.45725932717323), FRAC_CONST(-0.56716322898865) }, - { FRAC_CONST(-0.72929674386978), FRAC_CONST(-0.98008275032043) }, - { FRAC_CONST(0.75622802972794), FRAC_CONST(0.20950329303741) }, - { FRAC_CONST(0.07069442421198), FRAC_CONST(-0.78247898817062) }, - { FRAC_CONST(0.74496251344681), FRAC_CONST(-0.91169005632401) }, - { FRAC_CONST(-0.96440184116364), FRAC_CONST(-0.94739919900894) }, - { FRAC_CONST(0.30424630641937), FRAC_CONST(-0.49438267946243) }, - { FRAC_CONST(0.66565030813217), FRAC_CONST(0.64652937650681) }, - { FRAC_CONST(0.91697007417679), FRAC_CONST(0.17514097690582) }, - { FRAC_CONST(-0.70774918794632), FRAC_CONST(0.52548652887344) }, - { FRAC_CONST(-0.70051413774490), FRAC_CONST(-0.45340028405190) }, - { FRAC_CONST(-0.99496513605118), FRAC_CONST(-0.90071910619736) }, - { FRAC_CONST(0.98164492845535), FRAC_CONST(-0.77463155984879) }, - { FRAC_CONST(-0.54671579599380), FRAC_CONST(-0.02570928446949) }, - { FRAC_CONST(-0.01689629070461), FRAC_CONST(0.00287506449968) }, - { FRAC_CONST(-0.86110347509384), FRAC_CONST(0.42548584938049) }, - { FRAC_CONST(-0.98892980813980), FRAC_CONST(-0.87881129980087) }, - { FRAC_CONST(0.51756626367569), FRAC_CONST(0.66926783323288) }, - { FRAC_CONST(-0.99635028839111), FRAC_CONST(-0.58107727766037) }, - { FRAC_CONST(-0.99969369173050), FRAC_CONST(0.98369991779327) }, - { FRAC_CONST(0.55266261100769), FRAC_CONST(0.59449058771133) }, - { FRAC_CONST(0.34581178426743), FRAC_CONST(0.94879418611526) }, - { FRAC_CONST(0.62664210796356), FRAC_CONST(-0.74402970075607) }, - { FRAC_CONST(-0.77149701118469), FRAC_CONST(-0.33883658051491) }, - { FRAC_CONST(-0.91592246294022), FRAC_CONST(0.03687901422381) }, - { FRAC_CONST(-0.76285493373871), FRAC_CONST(-0.91371870040894) }, - { FRAC_CONST(0.79788339138031), FRAC_CONST(-0.93180972337723) }, - { FRAC_CONST(0.54473078250885), FRAC_CONST(-0.11919206380844) }, - { FRAC_CONST(-0.85639280080795), FRAC_CONST(0.42429855465889) }, - { FRAC_CONST(-0.92882400751114), FRAC_CONST(0.27871808409691) }, - { FRAC_CONST(-0.11708371341228), FRAC_CONST(-0.99800843000412) }, - { FRAC_CONST(0.21356749534607), FRAC_CONST(-0.90716296434402) }, - { FRAC_CONST(-0.76191693544388), FRAC_CONST(0.99768120050430) }, - { FRAC_CONST(0.98111045360565), FRAC_CONST(-0.95854461193085) }, - { FRAC_CONST(-0.85913270711899), FRAC_CONST(0.95766568183899) }, - { FRAC_CONST(-0.93307244777679), FRAC_CONST(0.49431759119034) }, - { FRAC_CONST(0.30485755205154), FRAC_CONST(-0.70540034770966) }, - { FRAC_CONST(0.85289651155472), FRAC_CONST(0.46766132116318) }, - { FRAC_CONST(0.91328084468842), FRAC_CONST(-0.99839597940445) }, - { FRAC_CONST(-0.05890199914575), FRAC_CONST(0.70741826295853) }, - { FRAC_CONST(0.28398686647415), FRAC_CONST(0.34633556008339) }, - { FRAC_CONST(0.95258164405823), FRAC_CONST(-0.54893416166306) }, - { FRAC_CONST(-0.78566324710846), FRAC_CONST(-0.75568538904190) }, - { FRAC_CONST(-0.95789498090744), FRAC_CONST(-0.20423194766045) }, - { FRAC_CONST(0.82411158084869), FRAC_CONST(0.96654617786407) }, - { FRAC_CONST(-0.65185445547104), FRAC_CONST(-0.88734990358353) }, - { FRAC_CONST(-0.93643605709076), FRAC_CONST(0.99870789051056) }, - { FRAC_CONST(0.91427159309387), FRAC_CONST(-0.98290503025055) }, - { FRAC_CONST(-0.70395684242249), FRAC_CONST(0.58796799182892) }, - { FRAC_CONST(0.00563771976158), FRAC_CONST(0.61768198013306) }, - { FRAC_CONST(0.89065051078796), FRAC_CONST(0.52783352136612) }, - { FRAC_CONST(-0.68683707714081), FRAC_CONST(0.80806946754456) }, - { FRAC_CONST(0.72165340185165), FRAC_CONST(-0.69259858131409) }, - { FRAC_CONST(-0.62928247451782), FRAC_CONST(0.13627037405968) }, - { FRAC_CONST(0.29938435554504), FRAC_CONST(-0.46051329374313) }, - { FRAC_CONST(-0.91781955957413), FRAC_CONST(-0.74012714624405) }, - { FRAC_CONST(0.99298715591431), FRAC_CONST(0.40816611051559) }, - { FRAC_CONST(0.82368296384811), FRAC_CONST(-0.74036049842834) }, - { FRAC_CONST(-0.98512834310532), FRAC_CONST(-0.99972331523895) }, - { FRAC_CONST(-0.95915371179581), FRAC_CONST(-0.99237799644470) }, - { FRAC_CONST(-0.21411126852036), FRAC_CONST(-0.93424820899963) }, - { FRAC_CONST(-0.68821477890015), FRAC_CONST(-0.26892307400703) }, - { FRAC_CONST(0.91851997375488), FRAC_CONST(0.09358228743076) }, - { FRAC_CONST(-0.96062767505646), FRAC_CONST(0.36099094152451) }, - { FRAC_CONST(0.51646184921265), FRAC_CONST(-0.71373331546783) }, - { FRAC_CONST(0.61130720376968), FRAC_CONST(0.46950140595436) }, - { FRAC_CONST(0.47336128354073), FRAC_CONST(-0.27333179116249) }, - { FRAC_CONST(0.90998309850693), FRAC_CONST(0.96715664863586) }, - { FRAC_CONST(0.44844800233841), FRAC_CONST(0.99211573600769) }, - { FRAC_CONST(0.66614890098572), FRAC_CONST(0.96590173244476) }, - { FRAC_CONST(0.74922239780426), FRAC_CONST(-0.89879858493805) }, - { FRAC_CONST(-0.99571585655212), FRAC_CONST(0.52785521745682) }, - { FRAC_CONST(0.97401082515717), FRAC_CONST(-0.16855870187283) }, - { FRAC_CONST(0.72683745622635), FRAC_CONST(-0.48060774803162) }, - { FRAC_CONST(0.95432192087173), FRAC_CONST(0.68849605321884) }, - { FRAC_CONST(-0.72962206602097), FRAC_CONST(-0.76608443260193) }, - { FRAC_CONST(-0.85359477996826), FRAC_CONST(0.88738125562668) }, - { FRAC_CONST(-0.81412428617477), FRAC_CONST(-0.97480767965317) }, - { FRAC_CONST(-0.87930774688721), FRAC_CONST(0.74748307466507) }, - { FRAC_CONST(-0.71573328971863), FRAC_CONST(-0.98570609092712) }, - { FRAC_CONST(0.83524298667908), FRAC_CONST(0.83702534437180) }, - { FRAC_CONST(-0.48086065053940), FRAC_CONST(-0.98848503828049) }, - { FRAC_CONST(0.97139126062393), FRAC_CONST(0.80093622207642) }, - { FRAC_CONST(0.51992827653885), FRAC_CONST(0.80247628688812) }, - { FRAC_CONST(-0.00848591234535), FRAC_CONST(-0.76670128107071) }, - { FRAC_CONST(-0.70294374227524), FRAC_CONST(0.55359911918640) }, - { FRAC_CONST(-0.95894426107407), FRAC_CONST(-0.43265503644943) }, - { FRAC_CONST(0.97079253196716), FRAC_CONST(0.09325857460499) }, - { FRAC_CONST(-0.92404294013977), FRAC_CONST(0.85507702827454) }, - { FRAC_CONST(-0.69506472349167), FRAC_CONST(0.98633414506912) }, - { FRAC_CONST(0.26559203863144), FRAC_CONST(0.73314309120178) }, - { FRAC_CONST(0.28038442134857), FRAC_CONST(0.14537914097309) }, - { FRAC_CONST(-0.74138122797012), FRAC_CONST(0.99310338497162) }, - { FRAC_CONST(-0.01752796024084), FRAC_CONST(-0.82616633176804) }, - { FRAC_CONST(-0.55126774311066), FRAC_CONST(-0.98898541927338) }, - { FRAC_CONST(0.97960901260376), FRAC_CONST(-0.94021445512772) }, - { FRAC_CONST(-0.99196308851242), FRAC_CONST(0.67019015550613) }, - { FRAC_CONST(-0.67684930562973), FRAC_CONST(0.12631492316723) }, - { FRAC_CONST(0.09140039235353), FRAC_CONST(-0.20537731051445) }, - { FRAC_CONST(-0.71658962965012), FRAC_CONST(-0.97788202762604) }, - { FRAC_CONST(0.81014639139175), FRAC_CONST(0.53722649812698) }, - { FRAC_CONST(0.40616992115974), FRAC_CONST(-0.26469007134438) }, - { FRAC_CONST(-0.67680186033249), FRAC_CONST(0.94502049684525) }, - { FRAC_CONST(0.86849772930145), FRAC_CONST(-0.18333598971367) }, - { FRAC_CONST(-0.99500381946564), FRAC_CONST(-0.02634122036397) }, - { FRAC_CONST(0.84329187870026), FRAC_CONST(0.10406957566738) }, - { FRAC_CONST(-0.09215968847275), FRAC_CONST(0.69540011882782) }, - { FRAC_CONST(0.99956172704697), FRAC_CONST(-0.12358541786671) }, - { FRAC_CONST(-0.79732781648636), FRAC_CONST(-0.91582524776459) }, - { FRAC_CONST(0.96349972486496), FRAC_CONST(0.96640455722809) }, - { FRAC_CONST(-0.79942780733109), FRAC_CONST(0.64323902130127) }, - { FRAC_CONST(-0.11566039919853), FRAC_CONST(0.28587844967842) }, - { FRAC_CONST(-0.39922955632210), FRAC_CONST(0.94129604101181) }, - { FRAC_CONST(0.99089199304581), FRAC_CONST(-0.92062628269196) }, - { FRAC_CONST(0.28631284832954), FRAC_CONST(-0.91035044193268) }, - { FRAC_CONST(-0.83302724361420), FRAC_CONST(-0.67330408096313) }, - { FRAC_CONST(0.95404446125031), FRAC_CONST(0.49162766337395) }, - { FRAC_CONST(-0.06449863314629), FRAC_CONST(0.03250560909510) }, - { FRAC_CONST(-0.99575054645538), FRAC_CONST(0.42389783263206) }, - { FRAC_CONST(-0.65501141548157), FRAC_CONST(0.82546114921570) }, - { FRAC_CONST(-0.81254440546036), FRAC_CONST(-0.51627236604691) }, - { FRAC_CONST(-0.99646371603012), FRAC_CONST(0.84490531682968) }, - { FRAC_CONST(0.00287840608507), FRAC_CONST(0.64768260717392) }, - { FRAC_CONST(0.70176988840103), FRAC_CONST(-0.20453028380871) }, - { FRAC_CONST(0.96361881494522), FRAC_CONST(0.40706968307495) }, - { FRAC_CONST(-0.68883758783340), FRAC_CONST(0.91338956356049) }, - { FRAC_CONST(-0.34875586628914), FRAC_CONST(0.71472293138504) }, - { FRAC_CONST(0.91980081796646), FRAC_CONST(0.66507452726364) }, - { FRAC_CONST(-0.99009048938751), FRAC_CONST(0.85868018865585) }, - { FRAC_CONST(0.68865793943405), FRAC_CONST(0.55660319328308) }, - { FRAC_CONST(-0.99484401941299), FRAC_CONST(-0.20052559673786) }, - { FRAC_CONST(0.94214510917664), FRAC_CONST(-0.99696427583694) }, - { FRAC_CONST(-0.67414629459381), FRAC_CONST(0.49548220634460) }, - { FRAC_CONST(-0.47339352965355), FRAC_CONST(-0.85904330015182) }, - { FRAC_CONST(0.14323651790619), FRAC_CONST(-0.94145596027374) }, - { FRAC_CONST(-0.29268294572830), FRAC_CONST(0.05759225040674) }, - { FRAC_CONST(0.43793860077858), FRAC_CONST(-0.78904968500137) }, - { FRAC_CONST(-0.36345127224922), FRAC_CONST(0.64874434471130) }, - { FRAC_CONST(-0.08750604838133), FRAC_CONST(0.97686946392059) }, - { FRAC_CONST(-0.96495270729065), FRAC_CONST(-0.53960305452347) }, - { FRAC_CONST(0.55526942014694), FRAC_CONST(0.78891521692276) }, - { FRAC_CONST(0.73538213968277), FRAC_CONST(0.96452075242996) }, - { FRAC_CONST(-0.30889773368835), FRAC_CONST(-0.80664390325546) }, - { FRAC_CONST(0.03574995696545), FRAC_CONST(-0.97325617074966) }, - { FRAC_CONST(0.98720687627792), FRAC_CONST(0.48409134149551) }, - { FRAC_CONST(-0.81689298152924), FRAC_CONST(-0.90827703475952) }, - { FRAC_CONST(0.67866861820221), FRAC_CONST(0.81284505128860) }, - { FRAC_CONST(-0.15808570384979), FRAC_CONST(0.85279554128647) }, - { FRAC_CONST(0.80723392963409), FRAC_CONST(-0.24717418849468) }, - { FRAC_CONST(0.47788757085800), FRAC_CONST(-0.46333149075508) }, - { FRAC_CONST(0.96367555856705), FRAC_CONST(0.38486748933792) }, - { FRAC_CONST(-0.99143874645233), FRAC_CONST(-0.24945276975632) }, - { FRAC_CONST(0.83081877231598), FRAC_CONST(-0.94780850410461) }, - { FRAC_CONST(-0.58753192424774), FRAC_CONST(0.01290772389621) }, - { FRAC_CONST(0.95538109540939), FRAC_CONST(-0.85557049512863) }, - { FRAC_CONST(-0.96490919589996), FRAC_CONST(-0.64020973443985) }, - { FRAC_CONST(-0.97327101230621), FRAC_CONST(0.12378127872944) }, - { FRAC_CONST(0.91400367021561), FRAC_CONST(0.57972472906113) }, - { FRAC_CONST(-0.99925839900970), FRAC_CONST(0.71084845066071) }, - { FRAC_CONST(-0.86875903606415), FRAC_CONST(-0.20291699469090) }, - { FRAC_CONST(-0.26240035891533), FRAC_CONST(-0.68264555931091) }, - { FRAC_CONST(-0.24664412438869), FRAC_CONST(-0.87642270326614) }, - { FRAC_CONST(0.02416275814176), FRAC_CONST(0.27192914485931) }, - { FRAC_CONST(0.82068622112274), FRAC_CONST(-0.85087788105011) }, - { FRAC_CONST(0.88547372817993), FRAC_CONST(-0.89636802673340) }, - { FRAC_CONST(-0.18173077702522), FRAC_CONST(-0.26152145862579) }, - { FRAC_CONST(0.09355476498604), FRAC_CONST(0.54845124483109) }, - { FRAC_CONST(-0.54668414592743), FRAC_CONST(0.95980775356293) }, - { FRAC_CONST(0.37050989270210), FRAC_CONST(-0.59910142421722) }, - { FRAC_CONST(-0.70373594760895), FRAC_CONST(0.91227668523788) }, - { FRAC_CONST(-0.34600785374641), FRAC_CONST(-0.99441426992416) }, - { FRAC_CONST(-0.68774479627609), FRAC_CONST(-0.30238837003708) }, - { FRAC_CONST(-0.26843291521072), FRAC_CONST(0.83115667104721) }, - { FRAC_CONST(0.49072334170341), FRAC_CONST(-0.45359709858894) }, - { FRAC_CONST(0.38975992798805), FRAC_CONST(0.95515358448029) }, - { FRAC_CONST(-0.97757124900818), FRAC_CONST(0.05305894464254) }, - { FRAC_CONST(-0.17325553297997), FRAC_CONST(-0.92770671844482) }, - { FRAC_CONST(0.99948036670685), FRAC_CONST(0.58285546302795) }, - { FRAC_CONST(-0.64946246147156), FRAC_CONST(0.68645507097244) }, - { FRAC_CONST(-0.12016920745373), FRAC_CONST(-0.57147324085236) }, - { FRAC_CONST(-0.58947455883026), FRAC_CONST(-0.34847131371498) }, - { FRAC_CONST(-0.41815140843391), FRAC_CONST(0.16276422142982) }, - { FRAC_CONST(0.99885648488998), FRAC_CONST(0.11136095225811) }, - { FRAC_CONST(-0.56649613380432), FRAC_CONST(-0.90494865179062) }, - { FRAC_CONST(0.94138020277023), FRAC_CONST(0.35281917452812) }, - { FRAC_CONST(-0.75725078582764), FRAC_CONST(0.53650552034378) }, - { FRAC_CONST(0.20541973412037), FRAC_CONST(-0.94435143470764) }, - { FRAC_CONST(0.99980372190475), FRAC_CONST(0.79835915565491) }, - { FRAC_CONST(0.29078277945518), FRAC_CONST(0.35393777489662) }, - { FRAC_CONST(-0.62858772277832), FRAC_CONST(0.38765692710876) }, - { FRAC_CONST(0.43440905213356), FRAC_CONST(-0.98546332120895) }, - { FRAC_CONST(-0.98298585414886), FRAC_CONST(0.21021524071693) }, - { FRAC_CONST(0.19513028860092), FRAC_CONST(-0.94239830970764) }, - { FRAC_CONST(-0.95476663112640), FRAC_CONST(0.98364555835724) }, - { FRAC_CONST(0.93379634618759), FRAC_CONST(-0.70881992578506) }, - { FRAC_CONST(-0.85235410928726), FRAC_CONST(-0.08342348039150) }, - { FRAC_CONST(-0.86425095796585), FRAC_CONST(-0.45795026421547) }, - { FRAC_CONST(0.38879778981209), FRAC_CONST(0.97274428606033) }, - { FRAC_CONST(0.92045122385025), FRAC_CONST(-0.62433654069901) }, - { FRAC_CONST(0.89162534475327), FRAC_CONST(0.54950958490372) }, - { FRAC_CONST(-0.36834338307381), FRAC_CONST(0.96458297967911) }, - { FRAC_CONST(0.93891763687134), FRAC_CONST(-0.89968353509903) }, - { FRAC_CONST(0.99267655611038), FRAC_CONST(-0.03757034242153) }, - { FRAC_CONST(-0.94063472747803), FRAC_CONST(0.41332337260246) }, - { FRAC_CONST(0.99740225076675), FRAC_CONST(-0.16830494999886) }, - { FRAC_CONST(-0.35899412631989), FRAC_CONST(-0.46633225679398) }, - { FRAC_CONST(0.05237237364054), FRAC_CONST(-0.25640362501144) }, - { FRAC_CONST(0.36703583598137), FRAC_CONST(-0.38653266429901) }, - { FRAC_CONST(0.91653180122375), FRAC_CONST(-0.30587628483772) }, - { FRAC_CONST(0.69000804424286), FRAC_CONST(0.90952169895172) }, - { FRAC_CONST(-0.38658750057220), FRAC_CONST(0.99501574039459) }, - { FRAC_CONST(-0.29250815510750), FRAC_CONST(0.37444993853569) }, - { FRAC_CONST(-0.60182201862335), FRAC_CONST(0.86779648065567) }, - { FRAC_CONST(-0.97418588399887), FRAC_CONST(0.96468526124954) }, - { FRAC_CONST(0.88461571931839), FRAC_CONST(0.57508403062820) }, - { FRAC_CONST(0.05198933184147), FRAC_CONST(0.21269661188126) }, - { FRAC_CONST(-0.53499621152878), FRAC_CONST(0.97241556644440) }, - { FRAC_CONST(-0.49429559707642), FRAC_CONST(0.98183864355087) }, - { FRAC_CONST(-0.98935145139694), FRAC_CONST(-0.40249159932137) }, - { FRAC_CONST(-0.98081380128860), FRAC_CONST(-0.72856897115707) }, - { FRAC_CONST(-0.27338150143623), FRAC_CONST(0.99950921535492) }, - { FRAC_CONST(0.06310802698135), FRAC_CONST(-0.54539585113525) }, - { FRAC_CONST(-0.20461677014828), FRAC_CONST(-0.14209978282452) }, - { FRAC_CONST(0.66223841905594), FRAC_CONST(0.72528582811356) }, - { FRAC_CONST(-0.84764343500137), FRAC_CONST(0.02372316829860) }, - { FRAC_CONST(-0.89039862155914), FRAC_CONST(0.88866579532623) }, - { FRAC_CONST(0.95903307199478), FRAC_CONST(0.76744925975800) }, - { FRAC_CONST(0.73504126071930), FRAC_CONST(-0.03747203201056) }, - { FRAC_CONST(-0.31744435429573), FRAC_CONST(-0.36834111809731) }, - { FRAC_CONST(-0.34110826253891), FRAC_CONST(0.40211221575737) }, - { FRAC_CONST(0.47803884744644), FRAC_CONST(-0.39423218369484) }, - { FRAC_CONST(0.98299193382263), FRAC_CONST(0.01989791356027) }, - { FRAC_CONST(-0.30963072180748), FRAC_CONST(-0.18076720833778) }, - { FRAC_CONST(0.99992591142654), FRAC_CONST(-0.26281872391701) }, - { FRAC_CONST(-0.93149733543396), FRAC_CONST(-0.98313164710999) }, - { FRAC_CONST(0.99923473596573), FRAC_CONST(-0.80142992734909) }, - { FRAC_CONST(-0.26024168729782), FRAC_CONST(-0.75999760627747) }, - { FRAC_CONST(-0.35712513327599), FRAC_CONST(0.19298963248730) }, - { FRAC_CONST(-0.99899083375931), FRAC_CONST(0.74645155668259) }, - { FRAC_CONST(0.86557173728943), FRAC_CONST(0.55593866109848) }, - { FRAC_CONST(0.33408042788506), FRAC_CONST(0.86185956001282) }, - { FRAC_CONST(0.99010735750198), FRAC_CONST(0.04602397605777) }, - { FRAC_CONST(-0.66694271564484), FRAC_CONST(-0.91643613576889) }, - { FRAC_CONST(0.64016789197922), FRAC_CONST(0.15649530291557) }, - { FRAC_CONST(0.99570536613464), FRAC_CONST(0.45844584703445) }, - { FRAC_CONST(-0.63431465625763), FRAC_CONST(0.21079117059708) }, - { FRAC_CONST(-0.07706847041845), FRAC_CONST(-0.89581435918808) }, - { FRAC_CONST(0.98590087890625), FRAC_CONST(0.88241720199585) }, - { FRAC_CONST(0.80099332332611), FRAC_CONST(-0.36851897835732) }, - { FRAC_CONST(0.78368133306503), FRAC_CONST(0.45506998896599) }, - { FRAC_CONST(0.08707806468010), FRAC_CONST(0.80938994884491) }, - { FRAC_CONST(-0.86811882257462), FRAC_CONST(0.39347308874130) }, - { FRAC_CONST(-0.39466530084610), FRAC_CONST(-0.66809433698654) }, - { FRAC_CONST(0.97875326871872), FRAC_CONST(-0.72467839717865) }, - { FRAC_CONST(-0.95038563013077), FRAC_CONST(0.89563220739365) }, - { FRAC_CONST(0.17005239427090), FRAC_CONST(0.54683053493500) }, - { FRAC_CONST(-0.76910793781281), FRAC_CONST(-0.96226614713669) }, - { FRAC_CONST(0.99743282794952), FRAC_CONST(0.42697158455849) }, - { FRAC_CONST(0.95437383651733), FRAC_CONST(0.97002321481705) }, - { FRAC_CONST(0.99578905105591), FRAC_CONST(-0.54106825590134) }, - { FRAC_CONST(0.28058260679245), FRAC_CONST(-0.85361421108246) }, - { FRAC_CONST(0.85256522893906), FRAC_CONST(-0.64567607641220) }, - { FRAC_CONST(-0.50608539581299), FRAC_CONST(-0.65846014022827) }, - { FRAC_CONST(-0.97210735082626), FRAC_CONST(-0.23095212876797) }, - { FRAC_CONST(0.95424050092697), FRAC_CONST(-0.99240148067474) }, - { FRAC_CONST(-0.96926569938660), FRAC_CONST(0.73775655031204) }, - { FRAC_CONST(0.30872163176537), FRAC_CONST(0.41514959931374) }, - { FRAC_CONST(-0.24523839354515), FRAC_CONST(0.63206630945206) }, - { FRAC_CONST(-0.33813264966011), FRAC_CONST(-0.38661777973175) }, - { FRAC_CONST(-0.05826828256249), FRAC_CONST(-0.06940773874521) }, - { FRAC_CONST(-0.22898460924625), FRAC_CONST(0.97054851055145) }, - { FRAC_CONST(-0.18509915471077), FRAC_CONST(0.47565764188766) }, - { FRAC_CONST(-0.10488238185644), FRAC_CONST(-0.87769949436188) }, - { FRAC_CONST(-0.71886587142944), FRAC_CONST(0.78030979633331) }, - { FRAC_CONST(0.99793875217438), FRAC_CONST(0.90041309595108) }, - { FRAC_CONST(0.57563304901123), FRAC_CONST(-0.91034334897995) }, - { FRAC_CONST(0.28909647464752), FRAC_CONST(0.96307784318924) }, - { FRAC_CONST(0.42188999056816), FRAC_CONST(0.48148649930954) }, - { FRAC_CONST(0.93335050344467), FRAC_CONST(-0.43537023663521) }, - { FRAC_CONST(-0.97087377309799), FRAC_CONST(0.86636447906494) }, - { FRAC_CONST(0.36722871661186), FRAC_CONST(0.65291655063629) }, - { FRAC_CONST(-0.81093025207520), FRAC_CONST(0.08778370171785) }, - { FRAC_CONST(-0.26240602135658), FRAC_CONST(-0.92774093151093) }, - { FRAC_CONST(0.83996498584747), FRAC_CONST(0.55839848518372) }, - { FRAC_CONST(-0.99909615516663), FRAC_CONST(-0.96024608612061) }, - { FRAC_CONST(0.74649465084076), FRAC_CONST(0.12144893407822) }, - { FRAC_CONST(-0.74774593114853), FRAC_CONST(-0.26898062229156) }, - { FRAC_CONST(0.95781666040421), FRAC_CONST(-0.79047924280167) }, - { FRAC_CONST(0.95472306013107), FRAC_CONST(-0.08588775992393) }, - { FRAC_CONST(0.48708331584930), FRAC_CONST(0.99999040365219) }, - { FRAC_CONST(0.46332037448883), FRAC_CONST(0.10964126139879) }, - { FRAC_CONST(-0.76497006416321), FRAC_CONST(0.89210927486420) }, - { FRAC_CONST(0.57397389411926), FRAC_CONST(0.35289704799652) }, - { FRAC_CONST(0.75374317169189), FRAC_CONST(0.96705216169357) }, - { FRAC_CONST(-0.59174400568008), FRAC_CONST(-0.89405369758606) }, - { FRAC_CONST(0.75087904930115), FRAC_CONST(-0.29612672328949) }, - { FRAC_CONST(-0.98607856035233), FRAC_CONST(0.25034910440445) }, - { FRAC_CONST(-0.40761056542397), FRAC_CONST(-0.90045571327209) }, - { FRAC_CONST(0.66929268836975), FRAC_CONST(0.98629492521286) }, - { FRAC_CONST(-0.97463697195053), FRAC_CONST(-0.00190223299433) }, - { FRAC_CONST(0.90145510435104), FRAC_CONST(0.99781388044357) }, - { FRAC_CONST(-0.87259286642075), FRAC_CONST(0.99233585596085) }, - { FRAC_CONST(-0.91529458761215), FRAC_CONST(-0.15698707103729) }, - { FRAC_CONST(-0.03305738791823), FRAC_CONST(-0.37205263972282) }, - { FRAC_CONST(0.07223051041365), FRAC_CONST(-0.88805001974106) }, - { FRAC_CONST(0.99498009681702), FRAC_CONST(0.97094357013702) }, - { FRAC_CONST(-0.74904936552048), FRAC_CONST(0.99985486268997) }, - { FRAC_CONST(0.04585228487849), FRAC_CONST(0.99812334775925) }, - { FRAC_CONST(-0.89054954051971), FRAC_CONST(-0.31791913509369) }, - { FRAC_CONST(-0.83782142400742), FRAC_CONST(0.97637635469437) }, - { FRAC_CONST(0.33454805612564), FRAC_CONST(-0.86231517791748) }, - { FRAC_CONST(-0.99707579612732), FRAC_CONST(0.93237990140915) }, - { FRAC_CONST(-0.22827528417110), FRAC_CONST(0.18874759972095) }, - { FRAC_CONST(0.67248046398163), FRAC_CONST(-0.03646211326122) }, - { FRAC_CONST(-0.05146538093686), FRAC_CONST(-0.92599701881409) }, - { FRAC_CONST(0.99947297573090), FRAC_CONST(0.93625229597092) }, - { FRAC_CONST(0.66951125860214), FRAC_CONST(0.98905825614929) }, - { FRAC_CONST(-0.99602955579758), FRAC_CONST(-0.44654715061188) }, - { FRAC_CONST(0.82104903459549), FRAC_CONST(0.99540740251541) }, - { FRAC_CONST(0.99186509847641), FRAC_CONST(0.72022998332977) }, - { FRAC_CONST(-0.65284591913223), FRAC_CONST(0.52186721563339) }, - { FRAC_CONST(0.93885445594788), FRAC_CONST(-0.74895310401917) }, - { FRAC_CONST(0.96735250949860), FRAC_CONST(0.90891814231873) }, - { FRAC_CONST(-0.22225968539715), FRAC_CONST(0.57124030590057) }, - { FRAC_CONST(-0.44132784008980), FRAC_CONST(-0.92688840627670) }, - { FRAC_CONST(-0.85694974660873), FRAC_CONST(0.88844531774521) }, - { FRAC_CONST(0.91783040761948), FRAC_CONST(-0.46356892585754) }, - { FRAC_CONST(0.72556972503662), FRAC_CONST(-0.99899554252625) }, - { FRAC_CONST(-0.99711579084396), FRAC_CONST(0.58211559057236) }, - { FRAC_CONST(0.77638977766037), FRAC_CONST(0.94321835041046) }, - { FRAC_CONST(0.07717324048281), FRAC_CONST(0.58638399839401) }, - { FRAC_CONST(-0.56049829721451), FRAC_CONST(0.82522302865982) }, - { FRAC_CONST(0.98398894071579), FRAC_CONST(0.39467439055443) }, - { FRAC_CONST(0.47546947002411), FRAC_CONST(0.68613046407700) }, - { FRAC_CONST(0.65675091743469), FRAC_CONST(0.18331636488438) }, - { FRAC_CONST(0.03273375332355), FRAC_CONST(-0.74933111667633) }, - { FRAC_CONST(-0.38684144616127), FRAC_CONST(0.51337349414825) }, - { FRAC_CONST(-0.97346270084381), FRAC_CONST(-0.96549361944199) }, - { FRAC_CONST(-0.53282153606415), FRAC_CONST(-0.91423267126083) }, - { FRAC_CONST(0.99817311763763), FRAC_CONST(0.61133575439453) }, - { FRAC_CONST(-0.50254499912262), FRAC_CONST(-0.88829338550568) }, - { FRAC_CONST(0.01995873264968), FRAC_CONST(0.85223513841629) }, - { FRAC_CONST(0.99930381774902), FRAC_CONST(0.94578897953033) }, - { FRAC_CONST(0.82907766103745), FRAC_CONST(-0.06323442608118) }, - { FRAC_CONST(-0.58660709857941), FRAC_CONST(0.96840775012970) }, - { FRAC_CONST(-0.17573736608028), FRAC_CONST(-0.48166921734810) }, - { FRAC_CONST(0.83434289693832), FRAC_CONST(-0.13023450970650) }, - { FRAC_CONST(0.05946491286159), FRAC_CONST(0.20511047542095) }, - { FRAC_CONST(0.81505483388901), FRAC_CONST(-0.94685947895050) }, - { FRAC_CONST(-0.44976380467415), FRAC_CONST(0.40894573926926) }, - { FRAC_CONST(-0.89746475219727), FRAC_CONST(0.99846577644348) }, - { FRAC_CONST(0.39677256345749), FRAC_CONST(-0.74854665994644) }, - { FRAC_CONST(-0.07588948309422), FRAC_CONST(0.74096214771271) }, - { FRAC_CONST(0.76343196630478), FRAC_CONST(0.41746628284454) }, - { FRAC_CONST(-0.74490106105804), FRAC_CONST(0.94725912809372) }, - { FRAC_CONST(0.64880120754242), FRAC_CONST(0.41336661577225) }, - { FRAC_CONST(0.62319535017014), FRAC_CONST(-0.93098312616348) }, - { FRAC_CONST(0.42215818166733), FRAC_CONST(-0.07712787389755) }, - { FRAC_CONST(0.02704554051161), FRAC_CONST(-0.05417517945170) }, - { FRAC_CONST(0.80001771450043), FRAC_CONST(0.91542196273804) }, - { FRAC_CONST(-0.79351830482483), FRAC_CONST(-0.36208897829056) }, - { FRAC_CONST(0.63872361183167), FRAC_CONST(0.08128252625465) }, - { FRAC_CONST(0.52890521287918), FRAC_CONST(0.60048872232437) }, - { FRAC_CONST(0.74238550662994), FRAC_CONST(0.04491915181279) }, - { FRAC_CONST(0.99096131324768), FRAC_CONST(-0.19451183080673) }, - { FRAC_CONST(-0.80412328243256), FRAC_CONST(-0.88513815402985) }, - { FRAC_CONST(-0.64612615108490), FRAC_CONST(0.72198677062988) }, - { FRAC_CONST(0.11657770723104), FRAC_CONST(-0.83662831783295) }, - { FRAC_CONST(-0.95053184032440), FRAC_CONST(-0.96939903497696) }, - { FRAC_CONST(-0.62228870391846), FRAC_CONST(0.82767260074615) }, - { FRAC_CONST(0.03004475869238), FRAC_CONST(-0.99738895893097) }, - { FRAC_CONST(-0.97987216711044), FRAC_CONST(0.36526128649712) }, - { FRAC_CONST(-0.99986982345581), FRAC_CONST(-0.36021611094475) }, - { FRAC_CONST(0.89110648632050), FRAC_CONST(-0.97894251346588) }, - { FRAC_CONST(0.10407960414886), FRAC_CONST(0.77357792854309) }, - { FRAC_CONST(0.95964735746384), FRAC_CONST(-0.35435819625854) }, - { FRAC_CONST(0.50843232870102), FRAC_CONST(0.96107691526413) }, - { FRAC_CONST(0.17006334662437), FRAC_CONST(-0.76854026317596) }, - { FRAC_CONST(0.25872674584389), FRAC_CONST(0.99893301725388) }, - { FRAC_CONST(-0.01115998718888), FRAC_CONST(0.98496019840240) }, - { FRAC_CONST(-0.79598701000214), FRAC_CONST(0.97138410806656) }, - { FRAC_CONST(-0.99264711141586), FRAC_CONST(-0.99542820453644) }, - { FRAC_CONST(-0.99829661846161), FRAC_CONST(0.01877138763666) }, - { FRAC_CONST(-0.70801013708115), FRAC_CONST(0.33680686354637) }, - { FRAC_CONST(-0.70467054843903), FRAC_CONST(0.93272775411606) }, - { FRAC_CONST(0.99846023321152), FRAC_CONST(-0.98725748062134) }, - { FRAC_CONST(-0.63364970684052), FRAC_CONST(-0.16473594307899) }, - { FRAC_CONST(-0.16258217394352), FRAC_CONST(-0.95939123630524) }, - { FRAC_CONST(-0.43645593523979), FRAC_CONST(-0.94805032014847) }, - { FRAC_CONST(-0.99848473072052), FRAC_CONST(0.96245169639587) }, - { FRAC_CONST(-0.16796459257603), FRAC_CONST(-0.98987513780594) }, - { FRAC_CONST(-0.87979227304459), FRAC_CONST(-0.71725726127625) }, - { FRAC_CONST(0.44183099269867), FRAC_CONST(-0.93568974733353) }, - { FRAC_CONST(0.93310177326202), FRAC_CONST(-0.99913311004639) }, - { FRAC_CONST(-0.93941932916641), FRAC_CONST(-0.56409376859665) }, - { FRAC_CONST(-0.88590002059937), FRAC_CONST(0.47624599933624) }, - { FRAC_CONST(0.99971461296082), FRAC_CONST(-0.83889955282211) }, - { FRAC_CONST(-0.75376385450363), FRAC_CONST(0.00814643409103) }, - { FRAC_CONST(0.93887686729431), FRAC_CONST(-0.11284527927637) }, - { FRAC_CONST(0.85126435756683), FRAC_CONST(0.52349251508713) }, - { FRAC_CONST(0.39701420068741), FRAC_CONST(0.81779634952545) }, - { FRAC_CONST(-0.37024465203285), FRAC_CONST(-0.87071657180786) }, - { FRAC_CONST(-0.36024826765060), FRAC_CONST(0.34655734896660) }, - { FRAC_CONST(-0.93388813734055), FRAC_CONST(-0.84476542472839) }, - { FRAC_CONST(-0.65298801660538), FRAC_CONST(-0.18439576029778) }, - { FRAC_CONST(0.11960318684578), FRAC_CONST(0.99899345636368) }, - { FRAC_CONST(0.94292563199997), FRAC_CONST(0.83163905143738) }, - { FRAC_CONST(0.75081145763397), FRAC_CONST(-0.35533222556114) }, - { FRAC_CONST(0.56721979379654), FRAC_CONST(-0.24076835811138) }, - { FRAC_CONST(0.46857765316963), FRAC_CONST(-0.30140233039856) }, - { FRAC_CONST(0.97312313318253), FRAC_CONST(-0.99548190832138) }, - { FRAC_CONST(-0.38299977779388), FRAC_CONST(0.98516911268234) }, - { FRAC_CONST(0.41025799512863), FRAC_CONST(0.02116736955941) }, - { FRAC_CONST(0.09638062119484), FRAC_CONST(0.04411984235048) }, - { FRAC_CONST(-0.85283249616623), FRAC_CONST(0.91475564241409) }, - { FRAC_CONST(0.88866806030273), FRAC_CONST(-0.99735265970230) }, - { FRAC_CONST(-0.48202428221703), FRAC_CONST(-0.96805608272552) }, - { FRAC_CONST(0.27572581171989), FRAC_CONST(0.58634752035141) }, - { FRAC_CONST(-0.65889132022858), FRAC_CONST(0.58835631608963) }, - { FRAC_CONST(0.98838084936142), FRAC_CONST(0.99994349479675) }, - { FRAC_CONST(-0.20651349425316), FRAC_CONST(0.54593044519424) }, - { FRAC_CONST(-0.62126415967941), FRAC_CONST(-0.59893679618835) }, - { FRAC_CONST(0.20320105552673), FRAC_CONST(-0.86879181861877) }, - { FRAC_CONST(-0.97790551185608), FRAC_CONST(0.96290808916092) }, - { FRAC_CONST(0.11112534999847), FRAC_CONST(0.21484763920307) }, - { FRAC_CONST(-0.41368338465691), FRAC_CONST(0.28216838836670) }, - { FRAC_CONST(0.24133038520813), FRAC_CONST(0.51294362545013) }, - { FRAC_CONST(-0.66393411159515), FRAC_CONST(-0.08249679952860) }, - { FRAC_CONST(-0.53697830438614), FRAC_CONST(-0.97649902105331) }, - { FRAC_CONST(-0.97224736213684), FRAC_CONST(0.22081333398819) }, - { FRAC_CONST(0.87392479181290), FRAC_CONST(-0.12796173989773) }, - { FRAC_CONST(0.19050361216068), FRAC_CONST(0.01602615416050) }, - { FRAC_CONST(-0.46353441476822), FRAC_CONST(-0.95249038934708) }, - { FRAC_CONST(-0.07064096629620), FRAC_CONST(-0.94479805231094) }, - { FRAC_CONST(-0.92444086074829), FRAC_CONST(-0.10457590222359) }, - { FRAC_CONST(-0.83822596073151), FRAC_CONST(-0.01695043221116) }, - { FRAC_CONST(0.75214684009552), FRAC_CONST(-0.99955683946609) }, - { FRAC_CONST(-0.42102998495102), FRAC_CONST(0.99720942974091) }, - { FRAC_CONST(-0.72094786167145), FRAC_CONST(-0.35008960962296) }, - { FRAC_CONST(0.78843313455582), FRAC_CONST(0.52851396799088) }, - { FRAC_CONST(0.97394025325775), FRAC_CONST(-0.26695942878723) }, - { FRAC_CONST(0.99206465482712), FRAC_CONST(-0.57010120153427) }, - { FRAC_CONST(0.76789611577988), FRAC_CONST(-0.76519358158112) }, - { FRAC_CONST(-0.82002419233322), FRAC_CONST(-0.73530179262161) }, - { FRAC_CONST(0.81924992799759), FRAC_CONST(0.99698424339294) }, - { FRAC_CONST(-0.26719850301743), FRAC_CONST(0.68903368711472) }, - { FRAC_CONST(-0.43311259150505), FRAC_CONST(0.85321813821793) }, - { FRAC_CONST(0.99194979667664), FRAC_CONST(0.91876250505447) }, - { FRAC_CONST(-0.80691999197006), FRAC_CONST(-0.32627540826797) }, - { FRAC_CONST(0.43080005049706), FRAC_CONST(-0.21919095516205) }, - { FRAC_CONST(0.67709493637085), FRAC_CONST(-0.95478075742722) }, - { FRAC_CONST(0.56151771545410), FRAC_CONST(-0.70693808794022) }, - { FRAC_CONST(0.10831862688065), FRAC_CONST(-0.08628837019205) }, - { FRAC_CONST(0.91229414939880), FRAC_CONST(-0.65987348556519) }, - { FRAC_CONST(-0.48972892761230), FRAC_CONST(0.56289243698120) }, - { FRAC_CONST(-0.89033657312393), FRAC_CONST(-0.71656566858292) }, - { FRAC_CONST(0.65269446372986), FRAC_CONST(0.65916007757187) }, - { FRAC_CONST(0.67439478635788), FRAC_CONST(-0.81684380769730) }, - { FRAC_CONST(-0.47770830988884), FRAC_CONST(-0.16789555549622) }, - { FRAC_CONST(-0.99715977907181), FRAC_CONST(-0.93565785884857) }, - { FRAC_CONST(-0.90889590978622), FRAC_CONST(0.62034398317337) }, - { FRAC_CONST(-0.06618622690439), FRAC_CONST(-0.23812216520309) }, - { FRAC_CONST(0.99430269002914), FRAC_CONST(0.18812555074692) }, - { FRAC_CONST(0.97686403989792), FRAC_CONST(-0.28664535284042) }, - { FRAC_CONST(0.94813650846481), FRAC_CONST(-0.97506642341614) }, - { FRAC_CONST(-0.95434498786926), FRAC_CONST(-0.79607981443405) }, - { FRAC_CONST(-0.49104782938957), FRAC_CONST(0.32895213365555) }, - { FRAC_CONST(0.99881172180176), FRAC_CONST(0.88993984460831) }, - { FRAC_CONST(0.50449168682098), FRAC_CONST(-0.85995072126389) }, - { FRAC_CONST(0.47162890434265), FRAC_CONST(-0.18680204451084) }, - { FRAC_CONST(-0.62081581354141), FRAC_CONST(0.75000673532486) }, - { FRAC_CONST(-0.43867015838623), FRAC_CONST(0.99998068809509) }, - { FRAC_CONST(0.98630565404892), FRAC_CONST(-0.53578901290894) }, - { FRAC_CONST(-0.61510360240936), FRAC_CONST(-0.89515018463135) }, - { FRAC_CONST(-0.03841517493129), FRAC_CONST(-0.69888818264008) }, - { FRAC_CONST(-0.30102157592773), FRAC_CONST(-0.07667808979750) }, - { FRAC_CONST(0.41881284117699), FRAC_CONST(0.02188098989427) }, - { FRAC_CONST(-0.86135452985764), FRAC_CONST(0.98947483301163) }, - { FRAC_CONST(0.67226862907410), FRAC_CONST(-0.13494388759136) }, - { FRAC_CONST(-0.70737397670746), FRAC_CONST(-0.76547348499298) }, - { FRAC_CONST(0.94044947624207), FRAC_CONST(0.09026201069355) }, - { FRAC_CONST(-0.82386350631714), FRAC_CONST(0.08924768865108) }, - { FRAC_CONST(-0.32070666551590), FRAC_CONST(0.50143420696259) }, - { FRAC_CONST(0.57593160867691), FRAC_CONST(-0.98966425657272) }, - { FRAC_CONST(-0.36326017975807), FRAC_CONST(0.07440242916346) }, - { FRAC_CONST(0.99979043006897), FRAC_CONST(-0.14130286872387) }, - { FRAC_CONST(-0.92366021871567), FRAC_CONST(-0.97979295253754) }, - { FRAC_CONST(-0.44607177376747), FRAC_CONST(-0.54233253002167) }, - { FRAC_CONST(0.44226801395416), FRAC_CONST(0.71326756477356) }, - { FRAC_CONST(0.03671907261014), FRAC_CONST(0.63606387376785) }, - { FRAC_CONST(0.52175426483154), FRAC_CONST(-0.85396826267242) }, - { FRAC_CONST(-0.94701141119003), FRAC_CONST(-0.01826348155737) }, - { FRAC_CONST(-0.98759609460831), FRAC_CONST(0.82288712263107) }, - { FRAC_CONST(0.87434792518616), FRAC_CONST(0.89399492740631) }, - { FRAC_CONST(-0.93412041664124), FRAC_CONST(0.41374051570892) }, - { FRAC_CONST(0.96063941717148), FRAC_CONST(0.93116706609726) }, - { FRAC_CONST(0.97534251213074), FRAC_CONST(0.86150932312012) }, - { FRAC_CONST(0.99642467498779), FRAC_CONST(0.70190042257309) }, - { FRAC_CONST(-0.94705086946487), FRAC_CONST(-0.29580041766167) }, - { FRAC_CONST(0.91599804162979), FRAC_CONST(-0.98147833347321) } -}; - -#ifdef __cplusplus - -#endif -#endif - diff --git a/apps/codecs/libfaad/sbr_qmf.c b/apps/codecs/libfaad/sbr_qmf.c deleted file mode 100644 index 5f8203e5b1..0000000000 --- a/apps/codecs/libfaad/sbr_qmf.c +++ /dev/null @@ -1,561 +0,0 @@ -/* -** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -** -** Any non-GPL usage of this software or parts of this software is strictly -** forbidden. -** -** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. -** -** $Id$ -**/ - -#include "common.h" -#include "structs.h" - -#ifdef SBR_DEC - - -#include -#include -#include "sbr_dct.h" -#include "sbr_qmf.h" -#include "sbr_qmf_c.h" -#include "sbr_syntax.h" - -#ifdef FIXED_POINT - #define FAAD_SYNTHESIS_SCALE(X) ((X)>>1) - #define FAAD_ANALYSIS_SCALE1(X) ((X)>>4) - #define FAAD_ANALYSIS_SCALE2(X) ((X)) - #define FAAD_ANALYSIS_SCALE3(X) ((X)) -#else - #define FAAD_SYNTHESIS_SCALE(X) ((X)/64.0f) - #define FAAD_ANALYSIS_SCALE1(X) ((X)) - #define FAAD_ANALYSIS_SCALE2(X) (2.0f*(X)) - #define FAAD_ANALYSIS_SCALE3(X) ((X)/32.0f) -#endif - - -void sbr_qmf_analysis_32(sbr_info *sbr, qmfa_info *qmfa, const real_t *input, - qmf_t X[MAX_NTSR][64], uint8_t offset, uint8_t kx) -{ - real_t u[64] MEM_ALIGN_ATTR; -#ifndef SBR_LOW_POWER - real_t real[32] MEM_ALIGN_ATTR; - real_t imag[32] MEM_ALIGN_ATTR; -#else - real_t y[32] MEM_ALIGN_ATTR; -#endif - qmf_t *pX; - uint32_t in = 0; - uint32_t l, idx0, idx1; - - /* qmf subsample l */ - for (l = 0; l < sbr->numTimeSlotsRate; l++) - { - int32_t n; - - /* shift input buffer x */ - /* input buffer is not shifted anymore, x is implemented as double ringbuffer */ - //memmove(qmfa->x + 32, qmfa->x, (320-32)*sizeof(real_t)); - - /* add new samples to input buffer x */ - idx0 = qmfa->x_index + 31; idx1 = idx0 + 320; - for (n = 0; n < 32; n+=4) - { - qmfa->x[idx0--] = qmfa->x[idx1--] = (input[in++]); - qmfa->x[idx0--] = qmfa->x[idx1--] = (input[in++]); - qmfa->x[idx0--] = qmfa->x[idx1--] = (input[in++]); - qmfa->x[idx0--] = qmfa->x[idx1--] = (input[in++]); - } - - /* window and summation to create array u */ - for (n = 0; n < 32; n++) - { - idx0 = qmfa->x_index + n; idx1 = n * 20; - u[n] = FAAD_ANALYSIS_SCALE1( - MUL_F(qmfa->x[idx0 ], qmf_c[idx1 ]) + - MUL_F(qmfa->x[idx0 + 64], qmf_c[idx1 + 2]) + - MUL_F(qmfa->x[idx0 + 128], qmf_c[idx1 + 4]) + - MUL_F(qmfa->x[idx0 + 192], qmf_c[idx1 + 6]) + - MUL_F(qmfa->x[idx0 + 256], qmf_c[idx1 + 8])); - } - for (n = 32; n < 64; n++) - { - idx0 = qmfa->x_index + n; idx1 = n * 20 - 639; - u[n] = FAAD_ANALYSIS_SCALE1( - MUL_F(qmfa->x[idx0 ], qmf_c[idx1 ]) + - MUL_F(qmfa->x[idx0 + 64], qmf_c[idx1 + 2]) + - MUL_F(qmfa->x[idx0 + 128], qmf_c[idx1 + 4]) + - MUL_F(qmfa->x[idx0 + 192], qmf_c[idx1 + 6]) + - MUL_F(qmfa->x[idx0 + 256], qmf_c[idx1 + 8])); - } - - /* update ringbuffer index */ - qmfa->x_index -= 32; - if (qmfa->x_index < 0) - qmfa->x_index = (320-32); - - /* calculate 32 subband samples by introducing X */ -#ifdef SBR_LOW_POWER - y[0] = u[48]; - for (n = 1; n < 16; n++) - y[n] = u[n+48] + u[48-n]; - for (n = 16; n < 32; n++) - y[n] = -u[n-16] + u[48-n]; - - DCT3_32_unscaled(u, y); - - for (n = 0; n < 32; n++) - { - if (n < kx) - { - QMF_RE(X[l + offset][n]) = FAAD_ANALYSIS_SCALE2(u[n]); - } else { - QMF_RE(X[l + offset][n]) = 0; - } - } -#else /* #ifdef SBR_LOW_POWER */ - - // Reordering of data moved from DCT_IV to here - idx0 = 30; idx1 = 63; - imag[31] = u[ 1]; real[ 0] = u[ 0]; - for (n = 1; n < 31; n+=3) - { - imag[idx0--] = u[n+1]; real[n ] = -u[idx1--]; - imag[idx0--] = u[n+2]; real[n+1] = -u[idx1--]; - imag[idx0--] = u[n+3]; real[n+2] = -u[idx1--]; - } - imag[ 0] = u[32]; real[31] = -u[33]; - - // dct4_kernel is DCT_IV without reordering which is done before and after FFT - dct4_kernel(real, imag); - - // Reordering of data moved from DCT_IV to here - /* Step 1: Calculate all non-zero pairs */ - pX = X[l + offset]; - for (n = 0; n < kx/2; n++) { - idx0 = 2*n; idx1 = idx0 + 1; - QMF_RE(pX[idx0]) = FAAD_ANALYSIS_SCALE2( real[n ]); - QMF_IM(pX[idx0]) = FAAD_ANALYSIS_SCALE2( imag[n ]); - QMF_RE(pX[idx1]) = FAAD_ANALYSIS_SCALE2(-imag[31-n]); - QMF_IM(pX[idx1]) = FAAD_ANALYSIS_SCALE2(-real[31-n]); - } - /* Step 2: Calculate a single pair with half zero'ed */ - if (kx&1) { - idx0 = 2*n; idx1 = idx0 + 1; - QMF_RE(pX[idx0]) = FAAD_ANALYSIS_SCALE2( real[n]); - QMF_IM(pX[idx0]) = FAAD_ANALYSIS_SCALE2( imag[n]); - QMF_RE(pX[idx1]) = QMF_IM(pX[idx1]) = 0; - n++; - } - /* Step 3: All other are zero'ed */ - for (; n < 16; n++) { - idx0 = 2*n; idx1 = idx0 + 1; - QMF_RE(pX[idx0]) = QMF_IM(pX[idx0]) = 0; - QMF_RE(pX[idx1]) = QMF_IM(pX[idx1]) = 0; - } -#endif /* #ifdef SBR_LOW_POWER */ - } -} - -#ifdef SBR_LOW_POWER - -void sbr_qmf_synthesis_32(sbr_info *sbr, qmfs_info *qmfs, qmf_t X[MAX_NTSR][64], - real_t *output) -{ - real_t x[16] MEM_ALIGN_ATTR; - real_t y[16] MEM_ALIGN_ATTR; - int16_t n, k, out = 0; - uint8_t l; - - /* qmf subsample l */ - for (l = 0; l < sbr->numTimeSlotsRate; l++) - { - /* shift buffers */ - /* we are not shifting v, it is a double ringbuffer */ - //memmove(qmfs->v + 64, qmfs->v, (640-64)*sizeof(real_t)); - - /* calculate 64 samples */ - for (k = 0; k < 16; k++) - { - y[k] = FAAD_ANALYSIS_SCALE3((QMF_RE(X[l][k]) - QMF_RE(X[l][31-k]))); - x[k] = FAAD_ANALYSIS_SCALE3((QMF_RE(X[l][k]) + QMF_RE(X[l][31-k]))); - } - - /* even n samples */ - DCT2_16_unscaled(x, x); - /* odd n samples */ - DCT4_16(y, y); - - for (n = 8; n < 24; n++) - { - qmfs->v[qmfs->v_index + n*2 ] = qmfs->v[qmfs->v_index + 640 + n*2 ] = x[n-8]; - qmfs->v[qmfs->v_index + n*2+1] = qmfs->v[qmfs->v_index + 640 + n*2+1] = y[n-8]; - } - for (n = 0; n < 16; n++) - { - qmfs->v[qmfs->v_index + n] = qmfs->v[qmfs->v_index + 640 + n] = qmfs->v[qmfs->v_index + 32-n]; - } - qmfs->v[qmfs->v_index + 48] = qmfs->v[qmfs->v_index + 640 + 48] = 0; - for (n = 1; n < 16; n++) - { - qmfs->v[qmfs->v_index + 48+n] = qmfs->v[qmfs->v_index + 640 + 48+n] = -qmfs->v[qmfs->v_index + 48-n]; - } - - /* calculate 32 output samples and window */ - for (k = 0; k < 32; k++) - { - output[out++] = MUL_F(qmfs->v[qmfs->v_index + k], qmf_c[ 2*k*10]) + - MUL_F(qmfs->v[qmfs->v_index + 96 + k], qmf_c[1 + 2*k*10]) + - MUL_F(qmfs->v[qmfs->v_index + 128 + k], qmf_c[2 + 2*k*10]) + - MUL_F(qmfs->v[qmfs->v_index + 224 + k], qmf_c[3 + 2*k*10]) + - MUL_F(qmfs->v[qmfs->v_index + 256 + k], qmf_c[4 + 2*k*10]) + - MUL_F(qmfs->v[qmfs->v_index + 352 + k], qmf_c[5 + 2*k*10]) + - MUL_F(qmfs->v[qmfs->v_index + 384 + k], qmf_c[6 + 2*k*10]) + - MUL_F(qmfs->v[qmfs->v_index + 480 + k], qmf_c[7 + 2*k*10]) + - MUL_F(qmfs->v[qmfs->v_index + 512 + k], qmf_c[8 + 2*k*10]) + - MUL_F(qmfs->v[qmfs->v_index + 608 + k], qmf_c[9 + 2*k*10]); - } - - /* update the ringbuffer index */ - qmfs->v_index -= 64; - if (qmfs->v_index < 0) - qmfs->v_index = (640-64); - } -} - -void sbr_qmf_synthesis_64(sbr_info *sbr, qmfs_info *qmfs, qmf_t X[MAX_NTSR][64], - real_t *output) -{ - real_t x[64] MEM_ALIGN_ATTR; - real_t y[64] MEM_ALIGN_ATTR; - int16_t n, k, out = 0; - uint8_t l; - - - /* qmf subsample l */ - for (l = 0; l < sbr->numTimeSlotsRate; l++) - { - /* shift buffers */ - /* we are not shifting v, it is a double ringbuffer */ - //memmove(qmfs->v + 128, qmfs->v, (1280-128)*sizeof(real_t)); - - /* calculate 128 samples */ - for (k = 0; k < 32; k++) - { - y[k] = FAAD_ANALYSIS_SCALE3((QMF_RE(X[l][k]) - QMF_RE(X[l][63-k]))); - x[k] = FAAD_ANALYSIS_SCALE3((QMF_RE(X[l][k]) + QMF_RE(X[l][63-k]))); - } - - /* even n samples */ - DCT2_32_unscaled(x, x); - /* odd n samples */ - DCT4_32(y, y); - - for (n = 16; n < 48; n++) - { - qmfs->v[qmfs->v_index + n*2] = qmfs->v[qmfs->v_index + 1280 + n*2 ] = x[n-16]; - qmfs->v[qmfs->v_index + n*2+1] = qmfs->v[qmfs->v_index + 1280 + n*2+1] = y[n-16]; - } - for (n = 0; n < 32; n++) - { - qmfs->v[qmfs->v_index + n] = qmfs->v[qmfs->v_index + 1280 + n] = qmfs->v[qmfs->v_index + 64-n]; - } - qmfs->v[qmfs->v_index + 96] = qmfs->v[qmfs->v_index + 1280 + 96] = 0; - for (n = 1; n < 32; n++) - { - qmfs->v[qmfs->v_index + 96+n] = qmfs->v[qmfs->v_index + 1280 + 96+n] = -qmfs->v[qmfs->v_index + 96-n]; - } - - /* calculate 64 output samples and window */ - for (k = 0; k < 64; k++) - { - output[out++] = MUL_F(qmfs->v[qmfs->v_index + k], qmf_c[ k*10]) + - MUL_F(qmfs->v[qmfs->v_index + 192 + k], qmf_c[1 + k*10]) + - MUL_F(qmfs->v[qmfs->v_index + 256 + k], qmf_c[2 + k*10]) + - MUL_F(qmfs->v[qmfs->v_index + 256 + 192 + k], qmf_c[3 + k*10]) + - MUL_F(qmfs->v[qmfs->v_index + 512 + k], qmf_c[4 + k*10]) + - MUL_F(qmfs->v[qmfs->v_index + 512 + 192 + k], qmf_c[5 + k*10]) + - MUL_F(qmfs->v[qmfs->v_index + 768 + k], qmf_c[6 + k*10]) + - MUL_F(qmfs->v[qmfs->v_index + 768 + 192 + k], qmf_c[7 + k*10]) + - MUL_F(qmfs->v[qmfs->v_index + 1024 + k], qmf_c[8 + k*10]) + - MUL_F(qmfs->v[qmfs->v_index + 1024 + 192 + k], qmf_c[9 + k*10]); - } - - /* update the ringbuffer index */ - qmfs->v_index -= 128; - if (qmfs->v_index < 0) - qmfs->v_index = (1280-128); - } -} -#else /* #ifdef SBR_LOW_POWER */ - -static const complex_t qmf32_pre_twiddle[] = -{ - { FRAC_CONST(0.999924701839145), FRAC_CONST(-0.012271538285720) }, - { FRAC_CONST(0.999322384588350), FRAC_CONST(-0.036807222941359) }, - { FRAC_CONST(0.998118112900149), FRAC_CONST(-0.061320736302209) }, - { FRAC_CONST(0.996312612182778), FRAC_CONST(-0.085797312344440) }, - { FRAC_CONST(0.993906970002356), FRAC_CONST(-0.110222207293883) }, - { FRAC_CONST(0.990902635427780), FRAC_CONST(-0.134580708507126) }, - { FRAC_CONST(0.987301418157858), FRAC_CONST(-0.158858143333861) }, - { FRAC_CONST(0.983105487431216), FRAC_CONST(-0.183039887955141) }, - { FRAC_CONST(0.978317370719628), FRAC_CONST(-0.207111376192219) }, - { FRAC_CONST(0.972939952205560), FRAC_CONST(-0.231058108280671) }, - { FRAC_CONST(0.966976471044852), FRAC_CONST(-0.254865659604515) }, - { FRAC_CONST(0.960430519415566), FRAC_CONST(-0.278519689385053) }, - { FRAC_CONST(0.953306040354194), FRAC_CONST(-0.302005949319228) }, - { FRAC_CONST(0.945607325380521), FRAC_CONST(-0.325310292162263) }, - { FRAC_CONST(0.937339011912575), FRAC_CONST(-0.348418680249435) }, - { FRAC_CONST(0.928506080473216), FRAC_CONST(-0.371317193951838) }, - { FRAC_CONST(0.919113851690058), FRAC_CONST(-0.393992040061048) }, - { FRAC_CONST(0.909167983090522), FRAC_CONST(-0.416429560097637) }, - { FRAC_CONST(0.898674465693954), FRAC_CONST(-0.438616238538528) }, - { FRAC_CONST(0.887639620402854), FRAC_CONST(-0.460538710958240) }, - { FRAC_CONST(0.876070094195407), FRAC_CONST(-0.482183772079123) }, - { FRAC_CONST(0.863972856121587), FRAC_CONST(-0.503538383725718) }, - { FRAC_CONST(0.851355193105265), FRAC_CONST(-0.524589682678469) }, - { FRAC_CONST(0.838224705554838), FRAC_CONST(-0.545324988422046) }, - { FRAC_CONST(0.824589302785025), FRAC_CONST(-0.565731810783613) }, - { FRAC_CONST(0.810457198252595), FRAC_CONST(-0.585797857456439) }, - { FRAC_CONST(0.795836904608884), FRAC_CONST(-0.605511041404326) }, - { FRAC_CONST(0.780737228572094), FRAC_CONST(-0.624859488142386) }, - { FRAC_CONST(0.765167265622459), FRAC_CONST(-0.643831542889791) }, - { FRAC_CONST(0.749136394523459), FRAC_CONST(-0.662415777590172) }, - { FRAC_CONST(0.732654271672413), FRAC_CONST(-0.680600997795453) }, - { FRAC_CONST(0.715730825283819), FRAC_CONST(-0.698376249408973) } -}; - -#define FAAD_CMPLX_PRETWIDDLE_SUB(k) \ - (MUL_F(QMF_RE(X[l][k]), RE(qmf32_pre_twiddle[k])) - \ - MUL_F(QMF_IM(X[l][k]), IM(qmf32_pre_twiddle[k]))) - -#define FAAD_CMPLX_PRETWIDDLE_ADD(k) \ - (MUL_F(QMF_IM(X[l][k]), RE(qmf32_pre_twiddle[k])) + \ - MUL_F(QMF_RE(X[l][k]), IM(qmf32_pre_twiddle[k]))) - -void sbr_qmf_synthesis_32(sbr_info *sbr, qmfs_info *qmfs, qmf_t X[MAX_NTSR][64], - real_t *output) -{ - real_t x1[32] MEM_ALIGN_ATTR; - real_t x2[32] MEM_ALIGN_ATTR; - int32_t n, k, idx0, idx1, out = 0; - uint32_t l; - - /* qmf subsample l */ - for (l = 0; l < sbr->numTimeSlotsRate; l++) - { - /* shift buffer v */ - /* buffer is not shifted, we are using a ringbuffer */ - //memmove(qmfs->v + 64, qmfs->v, (640-64)*sizeof(real_t)); - - /* calculate 64 samples */ - /* complex pre-twiddle */ - for (k = 0; k < 32;) - { - x1[k] = FAAD_CMPLX_PRETWIDDLE_SUB(k); x2[k] = FAAD_CMPLX_PRETWIDDLE_ADD(k); k++; - x1[k] = FAAD_CMPLX_PRETWIDDLE_SUB(k); x2[k] = FAAD_CMPLX_PRETWIDDLE_ADD(k); k++; - x1[k] = FAAD_CMPLX_PRETWIDDLE_SUB(k); x2[k] = FAAD_CMPLX_PRETWIDDLE_ADD(k); k++; - x1[k] = FAAD_CMPLX_PRETWIDDLE_SUB(k); x2[k] = FAAD_CMPLX_PRETWIDDLE_ADD(k); k++; - } - - /* transform */ - DCT4_32(x1, x1); - DST4_32(x2, x2); - - idx0 = qmfs->v_index; - idx1 = qmfs->v_index + 63; - for (n = 0; n < 32; n+=2) - { - qmfs->v[idx0] = qmfs->v[idx0 + 640] = -x1[n ] + x2[n ]; idx0++; - qmfs->v[idx1] = qmfs->v[idx1 + 640] = x1[n ] + x2[n ]; idx1--; - qmfs->v[idx0] = qmfs->v[idx0 + 640] = -x1[n+1] + x2[n+1]; idx0++; - qmfs->v[idx1] = qmfs->v[idx1 + 640] = x1[n+1] + x2[n+1]; idx1--; - } - - /* calculate 32 output samples and window */ - for (k = 0; k < 32; k++) - { - idx0 = qmfs->v_index + k; idx1 = 2*k*10; - output[out++] = FAAD_SYNTHESIS_SCALE( - MUL_F(qmfs->v[idx0 ], qmf_c[idx1 ]) + - MUL_F(qmfs->v[idx0 + 96], qmf_c[idx1+1]) + - MUL_F(qmfs->v[idx0 + 128], qmf_c[idx1+2]) + - MUL_F(qmfs->v[idx0 + 224], qmf_c[idx1+3]) + - MUL_F(qmfs->v[idx0 + 256], qmf_c[idx1+4]) + - MUL_F(qmfs->v[idx0 + 352], qmf_c[idx1+5]) + - MUL_F(qmfs->v[idx0 + 384], qmf_c[idx1+6]) + - MUL_F(qmfs->v[idx0 + 480], qmf_c[idx1+7]) + - MUL_F(qmfs->v[idx0 + 512], qmf_c[idx1+8]) + - MUL_F(qmfs->v[idx0 + 608], qmf_c[idx1+9])); - } - - /* update ringbuffer index */ - qmfs->v_index -= 64; - if (qmfs->v_index < 0) - qmfs->v_index = (640 - 64); - } -} - -void sbr_qmf_synthesis_64(sbr_info *sbr, qmfs_info *qmfs, qmf_t X[MAX_NTSR][64], - real_t *output) -{ - real_t real1[32] MEM_ALIGN_ATTR; - real_t imag1[32] MEM_ALIGN_ATTR; - real_t real2[32] MEM_ALIGN_ATTR; - real_t imag2[32] MEM_ALIGN_ATTR; - qmf_t *pX; - real_t *p_buf_1, *p_buf_3; - int32_t n, k, idx0, idx1, out = 0; - uint32_t l; - - /* qmf subsample l */ - for (l = 0; l < sbr->numTimeSlotsRate; l++) - { - /* shift buffer v */ - /* buffer is not shifted, we use double ringbuffer */ - //memmove(qmfs->v + 128, qmfs->v, (1280-128)*sizeof(real_t)); - - /* calculate 128 samples */ - pX = X[l]; - for (k = 0; k < 32; k++) - { - idx0 = 2*k; idx1 = idx0+1; - real1[ k] = QMF_RE(pX[idx0]); imag2[ k] = QMF_IM(pX[idx0]); - imag1[31-k] = QMF_RE(pX[idx1]); real2[31-k] = QMF_IM(pX[idx1]); - } - - // dct4_kernel is DCT_IV without reordering which is done before and after FFT - dct4_kernel(real1, imag1); - dct4_kernel(real2, imag2); - - p_buf_1 = qmfs->v + qmfs->v_index; - p_buf_3 = p_buf_1 + 1280; - - idx0 = 0; idx1 = 127; - for (n = 0; n < 32; n++) - { - p_buf_1[idx0] = p_buf_3[idx0] = real2[ n] - real1[ n]; idx0++; - p_buf_1[idx1] = p_buf_3[idx1] = real2[ n] + real1[ n]; idx1--; - p_buf_1[idx0] = p_buf_3[idx0] = imag2[31-n] + imag1[31-n]; idx0++; - p_buf_1[idx1] = p_buf_3[idx1] = imag2[31-n] - imag1[31-n]; idx1--; - } - - p_buf_1 = qmfs->v + qmfs->v_index; - - /* calculate 64 output samples and window */ -#ifdef CPU_ARM - const real_t *qtab = qmf_c; - real_t *pbuf = p_buf_1; - for (k = 0; k < 64; k++, pbuf++) - { - real_t *pout = &output[out++]; - asm volatile ( - "ldmia %[qtab]!, { r0-r3 } \n\t" - "ldr r4, [%[pbuf]] \n\t" - "ldr r7, [%[pbuf], #192*4] \n\t" - "smull r5, r6, r4, r0 \n\t" - "ldr r4, [%[pbuf], #256*4] \n\t" - "smlal r5, r6, r7, r1 \n\t" - "ldr r7, [%[pbuf], #448*4] \n\t" - "smlal r5, r6, r4, r2 \n\t" - "ldr r4, [%[pbuf], #512*4] \n\t" - "smlal r5, r6, r7, r3 \n\t" - - "ldmia %[qtab]!, { r0-r3 } \n\t" - "ldr r7, [%[pbuf], #704*4] \n\t" - "smlal r5, r6, r4, r0 \n\t" - "ldr r4, [%[pbuf], #768*4] \n\t" - "smlal r5, r6, r7, r1 \n\t" - "ldr r7, [%[pbuf], #960*4] \n\t" - "smlal r5, r6, r4, r2 \n\t" - "mov r2, #1024*4 \n\t" - - "ldmia %[qtab]!, { r0-r1 } \n\t" - "ldr r4, [%[pbuf], r2] \n\t" - "smlal r5, r6, r7, r3 \n\t" - "mov r2, #1216*4 \n\t" - "ldr r7, [%[pbuf], r2] \n\t" - "smlal r5, r6, r4, r0 \n\t" - "smlal r5, r6, r7, r1 \n\t" - - "str r6, [%[pout]] \n" - : [qtab] "+r" (qtab) - : [pbuf] "r" (pbuf), [pout] "r" (pout) - : "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", "memory"); - } -#elif defined CPU_COLDFIRE - const real_t *qtab = qmf_c; - real_t *pbuf = p_buf_1; - for (k = 0; k < 64; k++, pbuf++) - { - real_t *pout = &output[out++]; - asm volatile ( - "move.l (%[pbuf]), %%d5 \n" - - "movem.l (%[qtab]), %%d0-%%d4 \n" - "mac.l %%d0, %%d5, (192*4, %[pbuf]), %%d5, %%acc0 \n" - "mac.l %%d1, %%d5, (256*4, %[pbuf]), %%d5, %%acc0 \n" - "mac.l %%d2, %%d5, (448*4, %[pbuf]), %%d5, %%acc0 \n" - "mac.l %%d3, %%d5, (512*4, %[pbuf]), %%d5, %%acc0 \n" - "mac.l %%d4, %%d5, (704*4, %[pbuf]), %%d5, %%acc0 \n" - "lea.l (20, %[qtab]), %[qtab] \n" - - "movem.l (%[qtab]), %%d0-%%d4 \n" - "mac.l %%d0, %%d5, (768*4, %[pbuf]), %%d5, %%acc0 \n" - "mac.l %%d1, %%d5, (960*4, %[pbuf]), %%d5, %%acc0 \n" - "mac.l %%d2, %%d5, (1024*4, %[pbuf]), %%d5, %%acc0 \n" - "mac.l %%d3, %%d5, (1216*4, %[pbuf]), %%d5, %%acc0 \n" - "mac.l %%d4, %%d5, %%acc0 \n" - "lea.l (20, %[qtab]), %[qtab] \n" - - "movclr.l %%acc0, %%d0 \n" - "move.l %%d0, (%[pout]) \n" - : [qtab] "+a" (qtab) - : [pbuf] "a" (pbuf), - [pout] "a" (pout) - : "d0", "d1", "d2", "d3", "d4", "d5", "memory"); - } -#else - for (k = 0; k < 64; k++) - { - idx0 = k*10; - output[out++] = FAAD_SYNTHESIS_SCALE( - MUL_F(p_buf_1[k ], qmf_c[idx0 ]) + - MUL_F(p_buf_1[k+ 192 ], qmf_c[idx0+1]) + - MUL_F(p_buf_1[k+ 256 ], qmf_c[idx0+2]) + - MUL_F(p_buf_1[k+ 256+192], qmf_c[idx0+3]) + - MUL_F(p_buf_1[k+ 512 ], qmf_c[idx0+4]) + - MUL_F(p_buf_1[k+ 512+192], qmf_c[idx0+5]) + - MUL_F(p_buf_1[k+ 768 ], qmf_c[idx0+6]) + - MUL_F(p_buf_1[k+ 768+192], qmf_c[idx0+7]) + - MUL_F(p_buf_1[k+1024 ], qmf_c[idx0+8]) + - MUL_F(p_buf_1[k+1024+192], qmf_c[idx0+9])); - } -#endif - - /* update ringbuffer index */ - qmfs->v_index -= 128; - if (qmfs->v_index < 0) - qmfs->v_index = (1280 - 128); - } -} -#endif /* #ifdef SBR_LOW_POWER */ - -#endif /* #ifdef SBR_DEC */ diff --git a/apps/codecs/libfaad/sbr_qmf.h b/apps/codecs/libfaad/sbr_qmf.h deleted file mode 100644 index 87bfe5a9ef..0000000000 --- a/apps/codecs/libfaad/sbr_qmf.h +++ /dev/null @@ -1,47 +0,0 @@ -/* -** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -** -** Any non-GPL usage of this software or parts of this software is strictly -** forbidden. -** -** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. -** -** $Id$ -**/ - -#ifndef __SBR_QMF_H__ -#define __SBR_QMF_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -void sbr_qmf_analysis_32(sbr_info *sbr, qmfa_info *qmfa, const real_t *input, - qmf_t X[MAX_NTSR][64], uint8_t offset, uint8_t kx); -void sbr_qmf_synthesis_32(sbr_info *sbr, qmfs_info *qmfs, qmf_t X[MAX_NTSR][64], - real_t *output); -void sbr_qmf_synthesis_64(sbr_info *sbr, qmfs_info *qmfs, qmf_t X[MAX_NTSR][64], - real_t *output); - - -#ifdef __cplusplus -} -#endif -#endif - diff --git a/apps/codecs/libfaad/sbr_qmf_c.h b/apps/codecs/libfaad/sbr_qmf_c.h deleted file mode 100644 index 0ceb487bec..0000000000 --- a/apps/codecs/libfaad/sbr_qmf_c.h +++ /dev/null @@ -1,172 +0,0 @@ -/* -** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -** -** Any non-GPL usage of this software or parts of this software is strictly -** forbidden. -** -** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. -** -** $Id$ -**/ - -#ifndef __SBR_QMF_C_H__ -#define __SBR_QMF_C_H__ - -#ifdef __cplusplus -extern "C" { -#endif - - -#ifdef _MSC_VER -#pragma warning(disable:4305) -#pragma warning(disable:4244) -#endif -static const real_t qmf_c[640] ICONST_ATTR_FAAD_LARGE_IRAM MEM_ALIGN_ATTR = { - FRAC_CONST( 0.00000000000000), FRAC_CONST( 0.00262017586902), FRAC_CONST( 0.01327182200351), FRAC_CONST( 0.07035330735093), FRAC_CONST( 0.36115899031355), - FRAC_CONST( 0.85373856005937), FRAC_CONST(-0.36115899031355), FRAC_CONST( 0.07035330735093), FRAC_CONST(-0.01327182200351), FRAC_CONST( 0.00262017586902), - FRAC_CONST(-0.00055252865047), FRAC_CONST( 0.00278704643465), FRAC_CONST( 0.01439046660792), FRAC_CONST( 0.06896640131951), FRAC_CONST( 0.37237955463061), - FRAC_CONST( 0.85357205739107), FRAC_CONST(-0.34999141229310), FRAC_CONST( 0.07158263647903), FRAC_CONST(-0.01218499959508), FRAC_CONST( 0.00246256169126), - FRAC_CONST(-0.00056176925738), FRAC_CONST( 0.00294694477165), FRAC_CONST( 0.01554055533423), FRAC_CONST( 0.06745250215166), FRAC_CONST( 0.38363500139043), - FRAC_CONST( 0.85310209497017), FRAC_CONST(-0.33887226938665), FRAC_CONST( 0.07267746427299), FRAC_CONST(-0.01113155480321), FRAC_CONST( 0.00230172547746), - FRAC_CONST(-0.00049475180896), FRAC_CONST( 0.00311254206525), FRAC_CONST( 0.01673247129989), FRAC_CONST( 0.06576906686508), FRAC_CONST( 0.39492117615675), - FRAC_CONST( 0.85230470352147), FRAC_CONST(-0.32781137272105), FRAC_CONST( 0.07364060057620), FRAC_CONST(-0.01011502154986), FRAC_CONST( 0.00214615835557), - FRAC_CONST(-0.00048752279712), FRAC_CONST( 0.00327396134847), FRAC_CONST( 0.01794333813443), FRAC_CONST( 0.06394448059633), FRAC_CONST( 0.40623176767625), - FRAC_CONST( 0.85119715249343), FRAC_CONST(-0.31682789136456), FRAC_CONST( 0.07446643947564), FRAC_CONST(-0.00913253296085), FRAC_CONST( 0.00198411407369), - FRAC_CONST(-0.00048937912498), FRAC_CONST( 0.00344188741828), FRAC_CONST( 0.01918724313698), FRAC_CONST( 0.06196027790387), FRAC_CONST( 0.41756968968409), - FRAC_CONST( 0.84978051984268), FRAC_CONST(-0.30590985751916), FRAC_CONST( 0.07515762552870), FRAC_CONST(-0.00817982333726), FRAC_CONST( 0.00183482654224), - FRAC_CONST(-0.00050407143497), FRAC_CONST( 0.00360082681231), FRAC_CONST( 0.02045317933555), FRAC_CONST( 0.05981665708090), FRAC_CONST( 0.42891199207373), - FRAC_CONST( 0.84803157770763), FRAC_CONST(-0.29507167170646), FRAC_CONST( 0.07573057565061), FRAC_CONST(-0.00726158168517), FRAC_CONST( 0.00168680832531), - FRAC_CONST(-0.00052265642972), FRAC_CONST( 0.00376039229104), FRAC_CONST( 0.02174675502535), FRAC_CONST( 0.05751526919867), FRAC_CONST( 0.44025537543665), - FRAC_CONST( 0.84598184698206), FRAC_CONST(-0.28432141891085), FRAC_CONST( 0.07617483218536), FRAC_CONST(-0.00637922932685), FRAC_CONST( 0.00154432198471), - FRAC_CONST(-0.00054665656337), FRAC_CONST( 0.00392074323703), FRAC_CONST( 0.02306801692862), FRAC_CONST( 0.05504600343009), FRAC_CONST( 0.45159965356824), - FRAC_CONST( 0.84362382812005), FRAC_CONST(-0.27366340405625), FRAC_CONST( 0.07650507183194), FRAC_CONST(-0.00553372111088), FRAC_CONST( 0.00139024948272), - FRAC_CONST(-0.00056778025613), FRAC_CONST( 0.00408197531935), FRAC_CONST( 0.02441609920285), FRAC_CONST( 0.05240938217366), FRAC_CONST( 0.46293080852757), - FRAC_CONST( 0.84095413924722), FRAC_CONST(-0.26310532994603), FRAC_CONST( 0.07672049241746), FRAC_CONST(-0.00472225962400), FRAC_CONST( 0.00125778846475), - FRAC_CONST(-0.00058709304852), FRAC_CONST( 0.00422642692270), FRAC_CONST( 0.02578758475467), FRAC_CONST( 0.04959786763445), FRAC_CONST( 0.47424532146115), - FRAC_CONST( 0.83797173378865), FRAC_CONST(-0.25264803095722), FRAC_CONST( 0.07682300113923), FRAC_CONST(-0.00394011240522), FRAC_CONST( 0.00112501551307), - FRAC_CONST(-0.00061327473938), FRAC_CONST( 0.00437307196781), FRAC_CONST( 0.02718594296329), FRAC_CONST( 0.04663033051701), FRAC_CONST( 0.48552530911099), - FRAC_CONST( 0.83469373618402), FRAC_CONST(-0.24230168845974), FRAC_CONST( 0.07681739756964), FRAC_CONST(-0.00319337783900), FRAC_CONST( 0.00098859883015), - FRAC_CONST(-0.00063124935319), FRAC_CONST( 0.00452098527825), FRAC_CONST( 0.02860721736385), FRAC_CONST( 0.04347687821958), FRAC_CONST( 0.49677082545707), - FRAC_CONST( 0.83110384571520), FRAC_CONST(-0.23206908706791), FRAC_CONST( 0.07670934904245), FRAC_CONST(-0.00248267236449), FRAC_CONST( 0.00086084433262), - FRAC_CONST(-0.00065403333621), FRAC_CONST( 0.00466064606118), FRAC_CONST( 0.03005026574279), FRAC_CONST( 0.04014582784127), FRAC_CONST( 0.50798175000434), - FRAC_CONST( 0.82722753473360), FRAC_CONST(-0.22196526964149), FRAC_CONST( 0.07649921704119), FRAC_CONST(-0.00180394725893), FRAC_CONST( 0.00074580258865), - FRAC_CONST(-0.00067776907764), FRAC_CONST( 0.00479325608498), FRAC_CONST( 0.03150176087389), FRAC_CONST( 0.03664181168133), FRAC_CONST( 0.51912349702391), - FRAC_CONST( 0.82304198905409), FRAC_CONST(-0.21197358538056), FRAC_CONST( 0.07619924793396), FRAC_CONST(-0.00115681355227), FRAC_CONST( 0.00062393761391), - FRAC_CONST(-0.00069416146273), FRAC_CONST( 0.00491376035745), FRAC_CONST( 0.03297540810337), FRAC_CONST( 0.03295839306691), FRAC_CONST( 0.53022408956855), - FRAC_CONST( 0.81857760046468), FRAC_CONST(-0.20212501768103), FRAC_CONST( 0.07580083586584), FRAC_CONST(-0.00054642808664), FRAC_CONST( 0.00051073884952), - FRAC_CONST(-0.00071577364744), FRAC_CONST( 0.00503930226013), FRAC_CONST( 0.03446209487686), FRAC_CONST( 0.02908240060125), FRAC_CONST( 0.54125534487322), - FRAC_CONST( 0.81381912706217), FRAC_CONST(-0.19239667457267), FRAC_CONST( 0.07531373362019), FRAC_CONST(2.760451905e-005 ), FRAC_CONST( 0.0004026540216), - FRAC_CONST(-0.00072550431222), FRAC_CONST( 0.00514073539032), FRAC_CONST( 0.03596975605542), FRAC_CONST( 0.02503075618909), FRAC_CONST( 0.55220512585061), - FRAC_CONST( 0.80876950044491), FRAC_CONST(-0.18281725485142), FRAC_CONST( 0.07474525581194), FRAC_CONST( 0.00058322642480), FRAC_CONST( 0.00029495311041), - FRAC_CONST(-0.00074409418541), FRAC_CONST( 0.00524611661324), FRAC_CONST( 0.03748128504252), FRAC_CONST( 0.02079970728622), FRAC_CONST( 0.5630789140137), - FRAC_CONST( 0.80344857518505), FRAC_CONST(-0.17338081721706), FRAC_CONST( 0.07410036424342), FRAC_CONST( 0.00109023290512), FRAC_CONST( 0.00020430170688), - FRAC_CONST(-0.00074905980532), FRAC_CONST( 0.00534716811982), FRAC_CONST( 0.03900536794745), FRAC_CONST( 0.01637012582228), FRAC_CONST( 0.57385241316923), - FRAC_CONST( 0.79784664137700), FRAC_CONST(-0.16409588556669), FRAC_CONST( 0.07336202550803), FRAC_CONST( 0.00157846825768), FRAC_CONST( 0.00010943831274), - FRAC_CONST(-0.00076813719270), FRAC_CONST( 0.00541967759307), FRAC_CONST( 0.04053491705584), FRAC_CONST( 0.01176238327857), FRAC_CONST( 0.58454032354679), - FRAC_CONST( 0.79197358416424), FRAC_CONST(-0.15496070710605), FRAC_CONST( 0.07256825833083), FRAC_CONST( 0.00202741761850), FRAC_CONST(1.349497418e-005 ), - FRAC_CONST(-0.00077248485949), FRAC_CONST( 0.00548760401507), FRAC_CONST( 0.04206490946367), FRAC_CONST( 0.00696368621617), FRAC_CONST( 0.59511230862496), - FRAC_CONST( 0.78583531203920), FRAC_CONST(-0.14597664911870), FRAC_CONST( 0.07170026731102), FRAC_CONST( 0.00245085400321), FRAC_CONST(-6.173344072e-005), - FRAC_CONST(-0.00078343322877), FRAC_CONST( 0.00554757145088), FRAC_CONST( 0.04360975421304), FRAC_CONST( 0.00197656014503), FRAC_CONST( 0.60557835389180), - FRAC_CONST( 0.77942875190216), FRAC_CONST(-0.13715517611934), FRAC_CONST( 0.07076287107266), FRAC_CONST( 0.00284467578623), FRAC_CONST(-0.00014463809349), - FRAC_CONST(-0.00077798694927), FRAC_CONST( 0.00559380230045), FRAC_CONST( 0.04514884056413), FRAC_CONST(-0.00320868968304), FRAC_CONST( 0.61591099320291), - FRAC_CONST( 0.77277808813327), FRAC_CONST(-0.12850028503878), FRAC_CONST( 0.06976302447127), FRAC_CONST( 0.00320918858098), FRAC_CONST(-0.00020983373440), - FRAC_CONST(-0.00078036647100), FRAC_CONST( 0.00562206432097), FRAC_CONST( 0.04668430272642), FRAC_CONST(-0.00857117491366), FRAC_CONST( 0.62612426956055), - FRAC_CONST( 0.76586748650939), FRAC_CONST(-0.12000779846800), FRAC_CONST( 0.06870438283512), FRAC_CONST( 0.00354012465507), FRAC_CONST(-0.00028969811748), - FRAC_CONST(-0.00078014496257), FRAC_CONST( 0.00564551969164), FRAC_CONST( 0.04821657200672), FRAC_CONST(-0.01412888273558), FRAC_CONST( 0.63619801077286), - FRAC_CONST( 0.75870807608242), FRAC_CONST(-0.11168269317730), FRAC_CONST( 0.06760759851228), FRAC_CONST( 0.00384564081246), FRAC_CONST(-0.00035011758756), - FRAC_CONST(-0.00077579773310), FRAC_CONST( 0.00563891995151), FRAC_CONST( 0.04973857556014), FRAC_CONST(-0.01988341292573), FRAC_CONST( 0.64612696959461), - FRAC_CONST( 0.75131374561237), FRAC_CONST(-0.10353295311463), FRAC_CONST( 0.06643675122104), FRAC_CONST( 0.00412516423270), FRAC_CONST(-0.00040951214522), - FRAC_CONST(-0.00076307935757), FRAC_CONST( 0.00562661141932), FRAC_CONST( 0.05125561555216), FRAC_CONST(-0.02582272888064), FRAC_CONST( 0.65590163024671), - FRAC_CONST( 0.74368278636488), FRAC_CONST(-0.09555333528914), FRAC_CONST( 0.06522471064380), FRAC_CONST( 0.00438018617447), FRAC_CONST(-0.00046063254803), - FRAC_CONST(-0.00075300014201), FRAC_CONST( 0.00559171286630), FRAC_CONST( 0.05276307465207), FRAC_CONST(-0.03195312745332), FRAC_CONST( 0.66551398801627), - FRAC_CONST( 0.73582117582769), FRAC_CONST(-0.08775475365593), FRAC_CONST( 0.06397158980681), FRAC_CONST( 0.00460395301471), FRAC_CONST(-0.00051455722108), - FRAC_CONST(-0.00073193571525), FRAC_CONST( 0.00554043639400), FRAC_CONST( 0.05424527683589), FRAC_CONST(-0.03827765720822), FRAC_CONST( 0.67496631901712), - FRAC_CONST( 0.72774489002994), FRAC_CONST(-0.08013729344279), FRAC_CONST( 0.06268578081172), FRAC_CONST( 0.00481094690600), FRAC_CONST(-0.00055645763906), - FRAC_CONST(-0.00072153919876), FRAC_CONST( 0.00547537830770), FRAC_CONST( 0.05571736482138), FRAC_CONST(-0.04478068215856), FRAC_CONST( 0.68423532934598), - FRAC_CONST( 0.71944626349561), FRAC_CONST(-0.07269433008129), FRAC_CONST( 0.06134551717207), FRAC_CONST( 0.00498396877629), FRAC_CONST(-0.00059461189330), - FRAC_CONST(-0.00069179375372), FRAC_CONST( 0.00538389758970), FRAC_CONST( 0.05716164501299), FRAC_CONST(-0.05148041767934), FRAC_CONST( 0.69332823767032), - FRAC_CONST( 0.71094104263095), FRAC_CONST(-0.06544098531359), FRAC_CONST( 0.05998374801761), FRAC_CONST( 0.00513822754514), FRAC_CONST(-0.00063415949025), - FRAC_CONST(-0.00066504150893), FRAC_CONST( 0.00527157587272), FRAC_CONST( 0.05859156836260), FRAC_CONST(-0.05837053268336), FRAC_CONST( 0.70223887193539), - FRAC_CONST( 0.70223887193539), FRAC_CONST(-0.05837053268336), FRAC_CONST( 0.05859156836260), FRAC_CONST( 0.00527157587272), FRAC_CONST(-0.00066504150893), - FRAC_CONST(-0.00063415949025), FRAC_CONST( 0.00513822754514), FRAC_CONST( 0.05998374801761), FRAC_CONST(-0.06544098531359), FRAC_CONST( 0.71094104263095), - FRAC_CONST( 0.69332823767032), FRAC_CONST(-0.05148041767934), FRAC_CONST( 0.05716164501299), FRAC_CONST( 0.00538389758970), FRAC_CONST(-0.00069179375372), - FRAC_CONST(-0.00059461189330), FRAC_CONST( 0.00498396877629), FRAC_CONST( 0.06134551717207), FRAC_CONST(-0.07269433008129), FRAC_CONST( 0.71944626349561), - FRAC_CONST( 0.68423532934598), FRAC_CONST(-0.04478068215856), FRAC_CONST( 0.05571736482138), FRAC_CONST( 0.00547537830770), FRAC_CONST(-0.00072153919876), - FRAC_CONST(-0.00055645763906), FRAC_CONST( 0.00481094690600), FRAC_CONST( 0.06268578081172), FRAC_CONST(-0.08013729344279), FRAC_CONST( 0.72774489002994), - FRAC_CONST( 0.67496631901712), FRAC_CONST(-0.03827765720822), FRAC_CONST( 0.05424527683589), FRAC_CONST( 0.00554043639400), FRAC_CONST(-0.00073193571525), - FRAC_CONST(-0.00051455722108), FRAC_CONST( 0.00460395301471), FRAC_CONST( 0.06397158980681), FRAC_CONST(-0.08775475365593), FRAC_CONST( 0.73582117582769), - FRAC_CONST( 0.66551398801627), FRAC_CONST(-0.03195312745332), FRAC_CONST( 0.05276307465207), FRAC_CONST( 0.00559171286630), FRAC_CONST(-0.00075300014201), - FRAC_CONST(-0.00046063254803), FRAC_CONST( 0.00438018617447), FRAC_CONST( 0.06522471064380), FRAC_CONST(-0.09555333528914), FRAC_CONST( 0.74368278636488), - FRAC_CONST( 0.65590163024671), FRAC_CONST(-0.02582272888064), FRAC_CONST( 0.05125561555216), FRAC_CONST( 0.00562661141932), FRAC_CONST(-0.00076307935757), - FRAC_CONST(-0.00040951214522), FRAC_CONST( 0.00412516423270), FRAC_CONST( 0.06643675122104), FRAC_CONST(-0.10353295311463), FRAC_CONST( 0.75131374561237), - FRAC_CONST( 0.64612696959461), FRAC_CONST(-0.01988341292573), FRAC_CONST( 0.04973857556014), FRAC_CONST( 0.00563891995151), FRAC_CONST(-0.00077579773310), - FRAC_CONST(-0.00035011758756), FRAC_CONST( 0.00384564081246), FRAC_CONST( 0.06760759851228), FRAC_CONST(-0.11168269317730), FRAC_CONST( 0.75870807608242), - FRAC_CONST( 0.63619801077286), FRAC_CONST(-0.01412888273558), FRAC_CONST( 0.04821657200672), FRAC_CONST( 0.00564551969164), FRAC_CONST(-0.00078014496257), - FRAC_CONST(-0.00028969811748), FRAC_CONST( 0.00354012465507), FRAC_CONST( 0.06870438283512), FRAC_CONST(-0.12000779846800), FRAC_CONST( 0.76586748650939), - FRAC_CONST( 0.62612426956055), FRAC_CONST(-0.00857117491366), FRAC_CONST( 0.04668430272642), FRAC_CONST( 0.00562206432097), FRAC_CONST(-0.00078036647100), - FRAC_CONST(-0.00020983373440), FRAC_CONST( 0.00320918858098), FRAC_CONST( 0.06976302447127), FRAC_CONST(-0.12850028503878), FRAC_CONST( 0.77277808813327), - FRAC_CONST( 0.61591099320291), FRAC_CONST(-0.00320868968304), FRAC_CONST( 0.04514884056413), FRAC_CONST( 0.00559380230045), FRAC_CONST(-0.00077798694927), - FRAC_CONST(-0.00014463809349), FRAC_CONST( 0.00284467578623), FRAC_CONST( 0.07076287107266), FRAC_CONST(-0.13715517611934), FRAC_CONST( 0.77942875190216), - FRAC_CONST( 0.60557835389180), FRAC_CONST( 0.00197656014503), FRAC_CONST( 0.04360975421304), FRAC_CONST( 0.00554757145088), FRAC_CONST(-0.00078343322877), - FRAC_CONST(-6.173344072e-005), FRAC_CONST( 0.00245085400321), FRAC_CONST( 0.07170026731102), FRAC_CONST(-0.14597664911870), FRAC_CONST( 0.78583531203920), - FRAC_CONST( 0.59511230862496), FRAC_CONST( 0.00696368621617), FRAC_CONST( 0.04206490946367), FRAC_CONST( 0.00548760401507), FRAC_CONST(-0.00077248485949), - FRAC_CONST(1.349497418e-005 ), FRAC_CONST( 0.00202741761850), FRAC_CONST( 0.07256825833083), FRAC_CONST(-0.15496070710605), FRAC_CONST( 0.79197358416424), - FRAC_CONST( 0.58454032354679), FRAC_CONST( 0.01176238327857), FRAC_CONST( 0.04053491705584), FRAC_CONST( 0.00541967759307), FRAC_CONST(-0.00076813719270), - FRAC_CONST( 0.00010943831274), FRAC_CONST( 0.00157846825768), FRAC_CONST( 0.07336202550803), FRAC_CONST(-0.16409588556669), FRAC_CONST( 0.79784664137700), - FRAC_CONST( 0.57385241316923), FRAC_CONST( 0.01637012582228), FRAC_CONST( 0.03900536794745), FRAC_CONST( 0.00534716811982), FRAC_CONST(-0.00074905980532), - FRAC_CONST( 0.00020430170688), FRAC_CONST( 0.00109023290512), FRAC_CONST( 0.07410036424342), FRAC_CONST(-0.17338081721706), FRAC_CONST( 0.80344857518505), - FRAC_CONST( 0.56307891401370), FRAC_CONST( 0.02079970728622), FRAC_CONST( 0.03748128504252), FRAC_CONST( 0.00524611661324), FRAC_CONST(-0.00074409418541), - FRAC_CONST( 0.00029495311041), FRAC_CONST( 0.00058322642480), FRAC_CONST( 0.07474525581194), FRAC_CONST(-0.18281725485142), FRAC_CONST( 0.80876950044491), - FRAC_CONST( 0.55220512585061), FRAC_CONST( 0.02503075618909), FRAC_CONST( 0.03596975605542), FRAC_CONST( 0.00514073539032), FRAC_CONST(-0.00072550431222), - FRAC_CONST( 0.00040265402160), FRAC_CONST(2.760451905e-005 ), FRAC_CONST( 0.07531373362019), FRAC_CONST(-0.19239667457267), FRAC_CONST( 0.81381912706217), - FRAC_CONST( 0.54125534487322), FRAC_CONST( 0.02908240060125), FRAC_CONST( 0.03446209487686), FRAC_CONST( 0.00503930226013), FRAC_CONST(-0.00071577364744), - FRAC_CONST( 0.00051073884952), FRAC_CONST(-0.00054642808664), FRAC_CONST( 0.07580083586584), FRAC_CONST(-0.20212501768103), FRAC_CONST( 0.81857760046468), - FRAC_CONST( 0.53022408956855), FRAC_CONST( 0.03295839306691), FRAC_CONST( 0.03297540810337), FRAC_CONST( 0.00491376035745), FRAC_CONST(-0.00069416146273), - FRAC_CONST( 0.00062393761391), FRAC_CONST(-0.00115681355227), FRAC_CONST( 0.07619924793396), FRAC_CONST(-0.21197358538056), FRAC_CONST( 0.82304198905409), - FRAC_CONST( 0.51912349702391), FRAC_CONST( 0.03664181168133), FRAC_CONST( 0.03150176087389), FRAC_CONST( 0.00479325608498), FRAC_CONST(-0.00067776907764), - FRAC_CONST( 0.00074580258865), FRAC_CONST(-0.00180394725893), FRAC_CONST( 0.07649921704119), FRAC_CONST(-0.22196526964149), FRAC_CONST( 0.82722753473360), - FRAC_CONST( 0.50798175000434), FRAC_CONST( 0.04014582784127), FRAC_CONST( 0.03005026574279), FRAC_CONST( 0.00466064606118), FRAC_CONST(-0.00065403333621), - FRAC_CONST( 0.00086084433262), FRAC_CONST(-0.00248267236449), FRAC_CONST( 0.07670934904245), FRAC_CONST(-0.23206908706791), FRAC_CONST( 0.83110384571520), - FRAC_CONST( 0.49677082545707), FRAC_CONST( 0.04347687821958), FRAC_CONST( 0.02860721736385), FRAC_CONST( 0.00452098527825), FRAC_CONST(-0.00063124935319), - FRAC_CONST( 0.00098859883015), FRAC_CONST(-0.00319337783900), FRAC_CONST( 0.07681739756964), FRAC_CONST(-0.24230168845974), FRAC_CONST( 0.83469373618402), - FRAC_CONST( 0.48552530911099), FRAC_CONST( 0.04663033051701), FRAC_CONST( 0.02718594296329), FRAC_CONST( 0.00437307196781), FRAC_CONST(-0.00061327473938), - FRAC_CONST( 0.00112501551307), FRAC_CONST(-0.00394011240522), FRAC_CONST( 0.07682300113923), FRAC_CONST(-0.25264803095722), FRAC_CONST( 0.83797173378865), - FRAC_CONST( 0.47424532146115), FRAC_CONST( 0.04959786763445), FRAC_CONST( 0.02578758475467), FRAC_CONST( 0.00422642692270), FRAC_CONST(-0.00058709304852), - FRAC_CONST( 0.00125778846475), FRAC_CONST(-0.00472225962400), FRAC_CONST( 0.07672049241746), FRAC_CONST(-0.26310532994603), FRAC_CONST( 0.84095413924722), - FRAC_CONST( 0.46293080852757), FRAC_CONST( 0.05240938217366), FRAC_CONST( 0.02441609920285), FRAC_CONST( 0.00408197531935), FRAC_CONST(-0.00056778025613), - FRAC_CONST( 0.00139024948272), FRAC_CONST(-0.00553372111088), FRAC_CONST( 0.07650507183194), FRAC_CONST(-0.27366340405625), FRAC_CONST( 0.84362382812005), - FRAC_CONST( 0.45159965356824), FRAC_CONST( 0.05504600343009), FRAC_CONST( 0.02306801692862), FRAC_CONST( 0.00392074323703), FRAC_CONST(-0.00054665656337), - FRAC_CONST( 0.00154432198471), FRAC_CONST(-0.00637922932685), FRAC_CONST( 0.07617483218536), FRAC_CONST(-0.28432141891085), FRAC_CONST( 0.84598184698206), - FRAC_CONST( 0.44025537543665), FRAC_CONST( 0.05751526919867), FRAC_CONST( 0.02174675502535), FRAC_CONST( 0.00376039229104), FRAC_CONST(-0.00052265642972), - FRAC_CONST( 0.00168680832531), FRAC_CONST(-0.00726158168517), FRAC_CONST( 0.07573057565061), FRAC_CONST(-0.29507167170646), FRAC_CONST( 0.84803157770763), - FRAC_CONST( 0.42891199207373), FRAC_CONST( 0.05981665708090), FRAC_CONST( 0.02045317933555), FRAC_CONST( 0.00360082681231), FRAC_CONST(-0.00050407143497), - FRAC_CONST( 0.00183482654224), FRAC_CONST(-0.00817982333726), FRAC_CONST( 0.07515762552870), FRAC_CONST(-0.30590985751916), FRAC_CONST( 0.84978051984268), - FRAC_CONST( 0.41756968968409), FRAC_CONST( 0.06196027790387), FRAC_CONST( 0.01918724313698), FRAC_CONST( 0.00344188741828), FRAC_CONST(-0.00048937912498), - FRAC_CONST( 0.00198411407369), FRAC_CONST(-0.00913253296085), FRAC_CONST( 0.07446643947564), FRAC_CONST(-0.31682789136456), FRAC_CONST( 0.85119715249343), - FRAC_CONST( 0.40623176767625), FRAC_CONST( 0.06394448059633), FRAC_CONST( 0.01794333813443), FRAC_CONST( 0.00327396134847), FRAC_CONST(-0.00048752279712), - FRAC_CONST( 0.00214615835557), FRAC_CONST(-0.01011502154986), FRAC_CONST( 0.07364060057620), FRAC_CONST(-0.32781137272105), FRAC_CONST( 0.85230470352147), - FRAC_CONST( 0.39492117615675), FRAC_CONST( 0.06576906686508), FRAC_CONST( 0.01673247129989), FRAC_CONST( 0.00311254206525), FRAC_CONST(-0.00049475180896), - FRAC_CONST( 0.00230172547746), FRAC_CONST(-0.01113155480321), FRAC_CONST( 0.07267746427299), FRAC_CONST(-0.33887226938665), FRAC_CONST( 0.85310209497017), - FRAC_CONST( 0.38363500139043), FRAC_CONST( 0.06745250215166), FRAC_CONST( 0.01554055533423), FRAC_CONST( 0.00294694477165), FRAC_CONST(-0.00056176925738), - FRAC_CONST( 0.00246256169126), FRAC_CONST(-0.01218499959508), FRAC_CONST( 0.07158263647903), FRAC_CONST(-0.34999141229310), FRAC_CONST( 0.85357205739107), - FRAC_CONST( 0.37237955463061), FRAC_CONST( 0.06896640131951), FRAC_CONST( 0.01439046660792), FRAC_CONST( 0.00278704643465), FRAC_CONST(-0.00055252865047) -}; - -#endif - diff --git a/apps/codecs/libfaad/sbr_syntax.c b/apps/codecs/libfaad/sbr_syntax.c deleted file mode 100644 index 519a37b137..0000000000 --- a/apps/codecs/libfaad/sbr_syntax.c +++ /dev/null @@ -1,868 +0,0 @@ -/* -** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -** -** Any non-GPL usage of this software or parts of this software is strictly -** forbidden. -** -** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. -** -** $Id$ -**/ - -#include "common.h" -#include "structs.h" - -#ifdef SBR_DEC - -#include "sbr_syntax.h" -#include "syntax.h" -#include "sbr_huff.h" -#include "sbr_fbt.h" -#include "sbr_tf_grid.h" -#include "sbr_e_nf.h" -#include "bits.h" -#ifdef PS_DEC -#include "ps_dec.h" -#endif -#ifdef DRM_PS -#include "drm_dec.h" -#endif -#include "analysis.h" - -/* static function declarations */ -static void sbr_header(bitfile *ld, sbr_info *sbr); -static uint8_t calc_sbr_tables(sbr_info *sbr, uint8_t start_freq, uint8_t stop_freq, - uint8_t samplerate_mode, uint8_t freq_scale, - uint8_t alter_scale, uint8_t xover_band); -static uint8_t sbr_data(bitfile *ld, sbr_info *sbr); -static uint16_t sbr_extension(bitfile *ld, sbr_info *sbr, - uint8_t bs_extension_id, uint16_t num_bits_left); -static uint8_t sbr_single_channel_element(bitfile *ld, sbr_info *sbr); -static uint8_t sbr_channel_pair_element(bitfile *ld, sbr_info *sbr); -static uint8_t sbr_grid(bitfile *ld, sbr_info *sbr, uint8_t ch); -static void sbr_dtdf(bitfile *ld, sbr_info *sbr, uint8_t ch); -static void invf_mode(bitfile *ld, sbr_info *sbr, uint8_t ch); -static void sinusoidal_coding(bitfile *ld, sbr_info *sbr, uint8_t ch); - - -static void sbr_reset(sbr_info *sbr) -{ -#if 0 - printf("%d\n", sbr->bs_start_freq_prev); - printf("%d\n", sbr->bs_stop_freq_prev); - printf("%d\n", sbr->bs_freq_scale_prev); - printf("%d\n", sbr->bs_alter_scale_prev); - printf("%d\n", sbr->bs_xover_band_prev); - printf("%d\n\n", sbr->bs_noise_bands_prev); -#endif - - /* if these are different from the previous frame: Reset = 1 */ - if ((sbr->bs_start_freq != sbr->bs_start_freq_prev) || - (sbr->bs_stop_freq != sbr->bs_stop_freq_prev) || - (sbr->bs_freq_scale != sbr->bs_freq_scale_prev) || - (sbr->bs_alter_scale != sbr->bs_alter_scale_prev) || - (sbr->bs_xover_band != sbr->bs_xover_band_prev) || - (sbr->bs_noise_bands != sbr->bs_noise_bands_prev)) - { - sbr->Reset = 1; - } else { - sbr->Reset = 0; - } - - sbr->bs_start_freq_prev = sbr->bs_start_freq; - sbr->bs_stop_freq_prev = sbr->bs_stop_freq; - sbr->bs_freq_scale_prev = sbr->bs_freq_scale; - sbr->bs_alter_scale_prev = sbr->bs_alter_scale; - sbr->bs_xover_band_prev = sbr->bs_xover_band; - sbr->bs_noise_bands_prev = sbr->bs_noise_bands; -} - -static uint8_t calc_sbr_tables(sbr_info *sbr, uint8_t start_freq, uint8_t stop_freq, - uint8_t samplerate_mode, uint8_t freq_scale, - uint8_t alter_scale, uint8_t xover_band) -{ - uint8_t result = 0; - uint8_t k2; - - /* calculate the Master Frequency Table */ - sbr->k0 = qmf_start_channel(start_freq, samplerate_mode, sbr->sample_rate); - k2 = qmf_stop_channel(stop_freq, sbr->sample_rate, sbr->k0); - - /* check k0 and k2 */ - if (sbr->sample_rate >= 48000) - { - if ((k2 - sbr->k0) > 32) - result += 1; - } else if (sbr->sample_rate <= 32000) { - if ((k2 - sbr->k0) > 48) - result += 1; - } else { /* (sbr->sample_rate == 44100) */ - if ((k2 - sbr->k0) > 45) - result += 1; - } - - if (freq_scale == 0) - { - result += master_frequency_table_fs0(sbr, sbr->k0, k2, alter_scale); - } else { - result += master_frequency_table(sbr, sbr->k0, k2, freq_scale, alter_scale); - } - result += derived_frequency_table(sbr, xover_band, k2); - - result = (result > 0) ? 1 : 0; - - return result; -} - -/* table 2 */ -uint8_t sbr_extension_data(bitfile *ld, sbr_info *sbr, uint16_t cnt) -{ - uint8_t result = 0; - uint16_t num_align_bits = 0; - uint16_t num_sbr_bits = (uint16_t)faad_get_processed_bits(ld); - - uint8_t saved_start_freq, saved_samplerate_mode; - uint8_t saved_stop_freq, saved_freq_scale; - uint8_t saved_alter_scale, saved_xover_band; - -#ifdef DRM - if (!sbr->Is_DRM_SBR) -#endif - { - uint8_t bs_extension_type = (uint8_t)faad_getbits(ld, 4 - DEBUGVAR(1,198,"sbr_bitstream(): bs_extension_type")); - - if (bs_extension_type == EXT_SBR_DATA_CRC) - { - sbr->bs_sbr_crc_bits = (uint16_t)faad_getbits(ld, 10 - DEBUGVAR(1,199,"sbr_bitstream(): bs_sbr_crc_bits")); - } - } - - /* save old header values, in case the new ones are corrupted */ - saved_start_freq = sbr->bs_start_freq; - saved_samplerate_mode = sbr->bs_samplerate_mode; - saved_stop_freq = sbr->bs_stop_freq; - saved_freq_scale = sbr->bs_freq_scale; - saved_alter_scale = sbr->bs_alter_scale; - saved_xover_band = sbr->bs_xover_band; - - sbr->bs_header_flag = faad_get1bit(ld - DEBUGVAR(1,200,"sbr_bitstream(): bs_header_flag")); - - if (sbr->bs_header_flag) - sbr_header(ld, sbr); - - /* Reset? */ - sbr_reset(sbr); - - /* first frame should have a header */ - //if (!(sbr->frame == 0 && sbr->bs_header_flag == 0)) - if (sbr->header_count != 0) - { - if (sbr->Reset || (sbr->bs_header_flag && sbr->just_seeked)) - { - uint8_t rt = calc_sbr_tables(sbr, sbr->bs_start_freq, sbr->bs_stop_freq, - sbr->bs_samplerate_mode, sbr->bs_freq_scale, - sbr->bs_alter_scale, sbr->bs_xover_band); - - /* if an error occured with the new header values revert to the old ones */ - if (rt > 0) - { - calc_sbr_tables(sbr, saved_start_freq, saved_stop_freq, - saved_samplerate_mode, saved_freq_scale, - saved_alter_scale, saved_xover_band); - } - } - - if (result == 0) - { - result = sbr_data(ld, sbr); - - /* sbr_data() returning an error means that there was an error in - envelope_time_border_vector(). - In this case the old time border vector is saved and all the previous - data normally read after sbr_grid() is saved. - */ - /* to be on the safe side, calculate old sbr tables in case of error */ - if ((result > 0) && - (sbr->Reset || (sbr->bs_header_flag && sbr->just_seeked))) - { - calc_sbr_tables(sbr, saved_start_freq, saved_stop_freq, - saved_samplerate_mode, saved_freq_scale, - saved_alter_scale, saved_xover_band); - } - - /* we should be able to safely set result to 0 now */ - result = 0; - } - } else { - result = 1; - } - -#ifdef DRM - if (!sbr->Is_DRM_SBR) -#endif - { - num_sbr_bits = (uint16_t)faad_get_processed_bits(ld) - num_sbr_bits; - - /* check if we read more bits then were available for sbr */ - if (8*cnt < num_sbr_bits) - return 1; - - /* -4 does not apply, bs_extension_type is re-read in this function */ - num_align_bits = 8*cnt /*- 4*/ - num_sbr_bits; - - while (num_align_bits > 7) - { - faad_getbits(ld, 8 - DEBUGVAR(1,999,"sbr_bitstream(): num_align_bits")); - num_align_bits -= 8; - } - faad_getbits(ld, num_align_bits - DEBUGVAR(1,999,"sbr_bitstream(): num_align_bits")); - } - - return result; -} - -/* table 3 */ -static void sbr_header(bitfile *ld, sbr_info *sbr) -{ - uint8_t bs_header_extra_1, bs_header_extra_2; - - sbr->header_count++; - - sbr->bs_amp_res = faad_get1bit(ld - DEBUGVAR(1,203,"sbr_header(): bs_amp_res")); - - /* bs_start_freq and bs_stop_freq must define a fequency band that does - not exceed 48 channels */ - sbr->bs_start_freq = (uint8_t)faad_getbits(ld, 4 - DEBUGVAR(1,204,"sbr_header(): bs_start_freq")); - sbr->bs_stop_freq = (uint8_t)faad_getbits(ld, 4 - DEBUGVAR(1,205,"sbr_header(): bs_stop_freq")); - sbr->bs_xover_band = (uint8_t)faad_getbits(ld, 3 - DEBUGVAR(1,206,"sbr_header(): bs_xover_band")); - faad_getbits(ld, 2 - DEBUGVAR(1,207,"sbr_header(): bs_reserved_bits_hdr")); - bs_header_extra_1 = (uint8_t)faad_get1bit(ld - DEBUGVAR(1,208,"sbr_header(): bs_header_extra_1")); - bs_header_extra_2 = (uint8_t)faad_get1bit(ld - DEBUGVAR(1,209,"sbr_header(): bs_header_extra_2")); - - if (bs_header_extra_1) - { - sbr->bs_freq_scale = (uint8_t)faad_getbits(ld, 2 - DEBUGVAR(1,211,"sbr_header(): bs_freq_scale")); - sbr->bs_alter_scale = (uint8_t)faad_get1bit(ld - DEBUGVAR(1,212,"sbr_header(): bs_alter_scale")); - sbr->bs_noise_bands = (uint8_t)faad_getbits(ld, 2 - DEBUGVAR(1,213,"sbr_header(): bs_noise_bands")); - } else { - /* Default values */ - sbr->bs_freq_scale = 2; - sbr->bs_alter_scale = 1; - sbr->bs_noise_bands = 2; - } - - if (bs_header_extra_2) - { - sbr->bs_limiter_bands = (uint8_t)faad_getbits(ld, 2 - DEBUGVAR(1,214,"sbr_header(): bs_limiter_bands")); - sbr->bs_limiter_gains = (uint8_t)faad_getbits(ld, 2 - DEBUGVAR(1,215,"sbr_header(): bs_limiter_gains")); - sbr->bs_interpol_freq = (uint8_t)faad_get1bit(ld - DEBUGVAR(1,216,"sbr_header(): bs_interpol_freq")); - sbr->bs_smoothing_mode = (uint8_t)faad_get1bit(ld - DEBUGVAR(1,217,"sbr_header(): bs_smoothing_mode")); - } else { - /* Default values */ - sbr->bs_limiter_bands = 2; - sbr->bs_limiter_gains = 2; - sbr->bs_interpol_freq = 1; - sbr->bs_smoothing_mode = 1; - } - -#if 0 - /* print the header to screen */ - printf("bs_amp_res: %d\n", sbr->bs_amp_res); - printf("bs_start_freq: %d\n", sbr->bs_start_freq); - printf("bs_stop_freq: %d\n", sbr->bs_stop_freq); - printf("bs_xover_band: %d\n", sbr->bs_xover_band); - if (bs_header_extra_1) - { - printf("bs_freq_scale: %d\n", sbr->bs_freq_scale); - printf("bs_alter_scale: %d\n", sbr->bs_alter_scale); - printf("bs_noise_bands: %d\n", sbr->bs_noise_bands); - } - if (bs_header_extra_2) - { - printf("bs_limiter_bands: %d\n", sbr->bs_limiter_bands); - printf("bs_limiter_gains: %d\n", sbr->bs_limiter_gains); - printf("bs_interpol_freq: %d\n", sbr->bs_interpol_freq); - printf("bs_smoothing_mode: %d\n", sbr->bs_smoothing_mode); - } - printf("\n"); -#endif -} - -/* table 4 */ -static uint8_t sbr_data(bitfile *ld, sbr_info *sbr) -{ - uint8_t result; -#if 0 - sbr->bs_samplerate_mode = faad_get1bit(ld - DEBUGVAR(1,219,"sbr_data(): bs_samplerate_mode")); -#endif - - sbr->rate = (sbr->bs_samplerate_mode) ? 2 : 1; - - switch (sbr->id_aac) - { - case ID_SCE: - if ((result = sbr_single_channel_element(ld, sbr)) > 0) - return result; - break; - case ID_CPE: - if ((result = sbr_channel_pair_element(ld, sbr)) > 0) - return result; - break; - } - - return 0; -} - -/* table 5 */ -static uint8_t sbr_single_channel_element(bitfile *ld, sbr_info *sbr) -{ - uint8_t result; - - if (faad_get1bit(ld - DEBUGVAR(1,220,"sbr_single_channel_element(): bs_data_extra"))) - { - faad_getbits(ld, 4 - DEBUGVAR(1,221,"sbr_single_channel_element(): bs_reserved_bits_data")); - } - -#ifdef DRM - /* bs_coupling, from sbr_channel_pair_base_element(bs_amp_res) */ - if (sbr->Is_DRM_SBR) - faad_get1bit(ld); -#endif - - if ((result = sbr_grid(ld, sbr, 0)) > 0) - return result; - sbr_dtdf(ld, sbr, 0); - invf_mode(ld, sbr, 0); - sbr_envelope(ld, sbr, 0); - sbr_noise(ld, sbr, 0); - -#ifndef FIXED_POINT - envelope_noise_dequantisation(sbr, 0); -#endif - - memset(sbr->bs_add_harmonic[0], 0, 64*sizeof(uint8_t)); - - sbr->bs_add_harmonic_flag[0] = faad_get1bit(ld - DEBUGVAR(1,223,"sbr_single_channel_element(): bs_add_harmonic_flag[0]")); - if (sbr->bs_add_harmonic_flag[0]) - sinusoidal_coding(ld, sbr, 0); - - sbr->bs_extended_data = faad_get1bit(ld - DEBUGVAR(1,224,"sbr_single_channel_element(): bs_extended_data[0]")); - - if (sbr->bs_extended_data) - { - uint16_t nr_bits_left; -#if (defined(PS_DEC) || defined(DRM_PS)) - uint8_t ps_ext_read = 0; -#endif - uint16_t cnt = (uint16_t)faad_getbits(ld, 4 - DEBUGVAR(1,225,"sbr_single_channel_element(): bs_extension_size")); - if (cnt == 15) - { - cnt += (uint16_t)faad_getbits(ld, 8 - DEBUGVAR(1,226,"sbr_single_channel_element(): bs_esc_count")); - } - - nr_bits_left = 8 * cnt; - while (nr_bits_left > 7) - { - uint16_t tmp_nr_bits = 0; - - sbr->bs_extension_id = (uint8_t)faad_getbits(ld, 2 - DEBUGVAR(1,227,"sbr_single_channel_element(): bs_extension_id")); - tmp_nr_bits += 2; - - /* allow only 1 PS extension element per extension data */ -#if (defined(PS_DEC) || defined(DRM_PS)) -#if (defined(PS_DEC) && defined(DRM_PS)) - if (sbr->bs_extension_id == EXTENSION_ID_PS || sbr->bs_extension_id == DRM_PARAMETRIC_STEREO) -#else -#ifdef PS_DEC - if (sbr->bs_extension_id == EXTENSION_ID_PS) -#else -#ifdef DRM_PS - if (sbr->bs_extension_id == DRM_PARAMETRIC_STEREO) -#endif -#endif -#endif - { - if (ps_ext_read == 0) - { - ps_ext_read = 1; - } else { - /* to be safe make it 3, will switch to "default" - * in sbr_extension() */ - sbr->bs_extension_id = 3; - } - } -#endif - - tmp_nr_bits += sbr_extension(ld, sbr, sbr->bs_extension_id, nr_bits_left); - - /* check if the data read is bigger than the number of available bits */ - if (tmp_nr_bits > nr_bits_left) - return 1; - - nr_bits_left -= tmp_nr_bits; - } - - /* Corrigendum */ - if (nr_bits_left > 0) - { - faad_getbits(ld, nr_bits_left - DEBUGVAR(1,280,"sbr_single_channel_element(): nr_bits_left")); - } - } - - return 0; -} - -/* table 6 */ -static uint8_t sbr_channel_pair_element(bitfile *ld, sbr_info *sbr) -{ - uint8_t n, result; - - if (faad_get1bit(ld - DEBUGVAR(1,228,"sbr_single_channel_element(): bs_data_extra"))) - { - faad_getbits(ld, 4 - DEBUGVAR(1,228,"sbr_channel_pair_element(): bs_reserved_bits_data")); - faad_getbits(ld, 4 - DEBUGVAR(1,228,"sbr_channel_pair_element(): bs_reserved_bits_data")); - } - - sbr->bs_coupling = faad_get1bit(ld - DEBUGVAR(1,228,"sbr_channel_pair_element(): bs_coupling")); - - if (sbr->bs_coupling) - { - if ((result = sbr_grid(ld, sbr, 0)) > 0) - return result; - - /* need to copy some data from left to right */ - sbr->bs_frame_class[1] = sbr->bs_frame_class[0]; - sbr->L_E[1] = sbr->L_E[0]; - sbr->L_Q[1] = sbr->L_Q[0]; - sbr->bs_pointer[1] = sbr->bs_pointer[0]; - - for (n = 0; n <= sbr->L_E[0]; n++) - { - sbr->t_E[1][n] = sbr->t_E[0][n]; - sbr->f[1][n] = sbr->f[0][n]; - } - for (n = 0; n <= sbr->L_Q[0]; n++) - sbr->t_Q[1][n] = sbr->t_Q[0][n]; - - sbr_dtdf(ld, sbr, 0); - sbr_dtdf(ld, sbr, 1); - invf_mode(ld, sbr, 0); - - /* more copying */ - for (n = 0; n < sbr->N_Q; n++) - sbr->bs_invf_mode[1][n] = sbr->bs_invf_mode[0][n]; - - sbr_envelope(ld, sbr, 0); - sbr_noise(ld, sbr, 0); - sbr_envelope(ld, sbr, 1); - sbr_noise(ld, sbr, 1); - - memset(sbr->bs_add_harmonic[0], 0, 64*sizeof(uint8_t)); - memset(sbr->bs_add_harmonic[1], 0, 64*sizeof(uint8_t)); - - sbr->bs_add_harmonic_flag[0] = faad_get1bit(ld - DEBUGVAR(1,231,"sbr_channel_pair_element(): bs_add_harmonic_flag[0]")); - if (sbr->bs_add_harmonic_flag[0]) - sinusoidal_coding(ld, sbr, 0); - - sbr->bs_add_harmonic_flag[1] = faad_get1bit(ld - DEBUGVAR(1,232,"sbr_channel_pair_element(): bs_add_harmonic_flag[1]")); - if (sbr->bs_add_harmonic_flag[1]) - sinusoidal_coding(ld, sbr, 1); - } else { - uint8_t saved_t_E[6] = {0}, saved_t_Q[3] = {0}; - uint8_t saved_L_E = sbr->L_E[0]; - uint8_t saved_L_Q = sbr->L_Q[0]; - uint8_t saved_frame_class = sbr->bs_frame_class[0]; - - for (n = 0; n < saved_L_E; n++) - saved_t_E[n] = sbr->t_E[0][n]; - for (n = 0; n < saved_L_Q; n++) - saved_t_Q[n] = sbr->t_Q[0][n]; - - if ((result = sbr_grid(ld, sbr, 0)) > 0) - return result; - if ((result = sbr_grid(ld, sbr, 1)) > 0) - { - /* restore first channel data as well */ - sbr->bs_frame_class[0] = saved_frame_class; - sbr->L_E[0] = saved_L_E; - sbr->L_Q[0] = saved_L_Q; - for (n = 0; n < 6; n++) - sbr->t_E[0][n] = saved_t_E[n]; - for (n = 0; n < 3; n++) - sbr->t_Q[0][n] = saved_t_Q[n]; - - return result; - } - sbr_dtdf(ld, sbr, 0); - sbr_dtdf(ld, sbr, 1); - invf_mode(ld, sbr, 0); - invf_mode(ld, sbr, 1); - sbr_envelope(ld, sbr, 0); - sbr_envelope(ld, sbr, 1); - sbr_noise(ld, sbr, 0); - sbr_noise(ld, sbr, 1); - - memset(sbr->bs_add_harmonic[0], 0, 64*sizeof(uint8_t)); - memset(sbr->bs_add_harmonic[1], 0, 64*sizeof(uint8_t)); - - sbr->bs_add_harmonic_flag[0] = faad_get1bit(ld - DEBUGVAR(1,239,"sbr_channel_pair_element(): bs_add_harmonic_flag[0]")); - if (sbr->bs_add_harmonic_flag[0]) - sinusoidal_coding(ld, sbr, 0); - - sbr->bs_add_harmonic_flag[1] = faad_get1bit(ld - DEBUGVAR(1,240,"sbr_channel_pair_element(): bs_add_harmonic_flag[1]")); - if (sbr->bs_add_harmonic_flag[1]) - sinusoidal_coding(ld, sbr, 1); - } -#ifndef FIXED_POINT - envelope_noise_dequantisation(sbr, 0); - envelope_noise_dequantisation(sbr, 1); - - if (sbr->bs_coupling) - unmap_envelope_noise(sbr); -#endif - - sbr->bs_extended_data = faad_get1bit(ld - DEBUGVAR(1,233,"sbr_channel_pair_element(): bs_extended_data[0]")); - if (sbr->bs_extended_data) - { - uint16_t nr_bits_left; - uint16_t cnt = (uint16_t)faad_getbits(ld, 4 - DEBUGVAR(1,234,"sbr_channel_pair_element(): bs_extension_size")); - if (cnt == 15) - { - cnt += (uint16_t)faad_getbits(ld, 8 - DEBUGVAR(1,235,"sbr_channel_pair_element(): bs_esc_count")); - } - - nr_bits_left = 8 * cnt; - while (nr_bits_left > 7) - { - uint16_t tmp_nr_bits = 0; - - sbr->bs_extension_id = (uint8_t)faad_getbits(ld, 2 - DEBUGVAR(1,236,"sbr_channel_pair_element(): bs_extension_id")); - tmp_nr_bits += 2; - tmp_nr_bits += sbr_extension(ld, sbr, sbr->bs_extension_id, nr_bits_left); - - /* check if the data read is bigger than the number of available bits */ - if (tmp_nr_bits > nr_bits_left) - return 1; - - nr_bits_left -= tmp_nr_bits; - } - - /* Corrigendum */ - if (nr_bits_left > 0) - { - faad_getbits(ld, nr_bits_left - DEBUGVAR(1,280,"sbr_channel_pair_element(): nr_bits_left")); - } - } - - return 0; -} - -/* integer log[2](x): input range [0,10) */ -static int8_t sbr_log2(const int8_t val) -{ - int8_t log2tab[] = { 0, 0, 1, 2, 2, 3, 3, 3, 3, 4 }; - if (val < 10 && val >= 0) - return log2tab[val]; - else - return 0; -} - - -/* table 7 */ -static uint8_t sbr_grid(bitfile *ld, sbr_info *sbr, uint8_t ch) -{ - uint8_t i, env, rel, result; - uint8_t bs_abs_bord, bs_abs_bord_1; - uint8_t bs_num_env = 0; - uint8_t saved_L_E = sbr->L_E[ch]; - uint8_t saved_L_Q = sbr->L_Q[ch]; - uint8_t saved_frame_class = sbr->bs_frame_class[ch]; - - sbr->bs_frame_class[ch] = (uint8_t)faad_getbits(ld, 2 - DEBUGVAR(1,248,"sbr_grid(): bs_frame_class")); - - switch (sbr->bs_frame_class[ch]) - { - case FIXFIX: - i = (uint8_t)faad_getbits(ld, 2 - DEBUGVAR(1,249,"sbr_grid(): bs_num_env_raw")); - - bs_num_env = min(1 << i, 5); - - i = (uint8_t)faad_get1bit(ld - DEBUGVAR(1,250,"sbr_grid(): bs_freq_res_flag")); - for (env = 0; env < bs_num_env; env++) - sbr->f[ch][env] = i; - - sbr->abs_bord_lead[ch] = 0; - sbr->abs_bord_trail[ch] = sbr->numTimeSlots; - sbr->n_rel_lead[ch] = bs_num_env - 1; - sbr->n_rel_trail[ch] = 0; - break; - - case FIXVAR: - bs_abs_bord = (uint8_t)faad_getbits(ld, 2 - DEBUGVAR(1,251,"sbr_grid(): bs_abs_bord")) + sbr->numTimeSlots; - bs_num_env = (uint8_t)faad_getbits(ld, 2 - DEBUGVAR(1,252,"sbr_grid(): bs_num_env")) + 1; - - for (rel = 0; rel < bs_num_env-1; rel++) - { - sbr->bs_rel_bord[ch][rel] = 2 * (uint8_t)faad_getbits(ld, 2 - DEBUGVAR(1,253,"sbr_grid(): bs_rel_bord")) + 2; - } - i = sbr_log2(bs_num_env + 1); - sbr->bs_pointer[ch] = (uint8_t)faad_getbits(ld, i - DEBUGVAR(1,254,"sbr_grid(): bs_pointer")); - - for (env = 0; env < bs_num_env; env++) - { - sbr->f[ch][bs_num_env - env - 1] = (uint8_t)faad_get1bit(ld - DEBUGVAR(1,255,"sbr_grid(): bs_freq_res")); - } - - sbr->abs_bord_lead[ch] = 0; - sbr->abs_bord_trail[ch] = bs_abs_bord; - sbr->n_rel_lead[ch] = 0; - sbr->n_rel_trail[ch] = bs_num_env - 1; - break; - - case VARFIX: - bs_abs_bord = (uint8_t)faad_getbits(ld, 2 - DEBUGVAR(1,256,"sbr_grid(): bs_abs_bord")); - bs_num_env = (uint8_t)faad_getbits(ld, 2 - DEBUGVAR(1,257,"sbr_grid(): bs_num_env")) + 1; - - for (rel = 0; rel < bs_num_env-1; rel++) - { - sbr->bs_rel_bord[ch][rel] = 2 * (uint8_t)faad_getbits(ld, 2 - DEBUGVAR(1,258,"sbr_grid(): bs_rel_bord")) + 2; - } - i = sbr_log2(bs_num_env + 1); - sbr->bs_pointer[ch] = (uint8_t)faad_getbits(ld, i - DEBUGVAR(1,259,"sbr_grid(): bs_pointer")); - - for (env = 0; env < bs_num_env; env++) - { - sbr->f[ch][env] = (uint8_t)faad_get1bit(ld - DEBUGVAR(1,260,"sbr_grid(): bs_freq_res")); - } - - sbr->abs_bord_lead[ch] = bs_abs_bord; - sbr->abs_bord_trail[ch] = sbr->numTimeSlots; - sbr->n_rel_lead[ch] = bs_num_env - 1; - sbr->n_rel_trail[ch] = 0; - break; - - case VARVAR: - bs_abs_bord = (uint8_t)faad_getbits(ld, 2 - DEBUGVAR(1,261,"sbr_grid(): bs_abs_bord_0")); - bs_abs_bord_1 = (uint8_t)faad_getbits(ld, 2 - DEBUGVAR(1,262,"sbr_grid(): bs_abs_bord_1")) + sbr->numTimeSlots; - sbr->bs_num_rel_0[ch] = (uint8_t)faad_getbits(ld, 2 - DEBUGVAR(1,263,"sbr_grid(): bs_num_rel_0")); - sbr->bs_num_rel_1[ch] = (uint8_t)faad_getbits(ld, 2 - DEBUGVAR(1,264,"sbr_grid(): bs_num_rel_1")); - - bs_num_env = min(5, sbr->bs_num_rel_0[ch] + sbr->bs_num_rel_1[ch] + 1); - - for (rel = 0; rel < sbr->bs_num_rel_0[ch]; rel++) - { - sbr->bs_rel_bord_0[ch][rel] = 2 * (uint8_t)faad_getbits(ld, 2 - DEBUGVAR(1,265,"sbr_grid(): bs_rel_bord")) + 2; - } - for(rel = 0; rel < sbr->bs_num_rel_1[ch]; rel++) - { - sbr->bs_rel_bord_1[ch][rel] = 2 * (uint8_t)faad_getbits(ld, 2 - DEBUGVAR(1,266,"sbr_grid(): bs_rel_bord")) + 2; - } - i = sbr_log2(sbr->bs_num_rel_0[ch] + sbr->bs_num_rel_1[ch] + 2); - sbr->bs_pointer[ch] = (uint8_t)faad_getbits(ld, i - DEBUGVAR(1,267,"sbr_grid(): bs_pointer")); - - for (env = 0; env < bs_num_env; env++) - { - sbr->f[ch][env] = (uint8_t)faad_get1bit(ld - DEBUGVAR(1,268,"sbr_grid(): bs_freq_res")); - } - - sbr->abs_bord_lead[ch] = bs_abs_bord; - sbr->abs_bord_trail[ch] = bs_abs_bord_1; - sbr->n_rel_lead[ch] = sbr->bs_num_rel_0[ch]; - sbr->n_rel_trail[ch] = sbr->bs_num_rel_1[ch]; - break; - } - - if (sbr->bs_frame_class[ch] == VARVAR) - sbr->L_E[ch] = min(bs_num_env, 5); - else - sbr->L_E[ch] = min(bs_num_env, 4); - - if (sbr->L_E[ch] <= 0) - return 1; - - if (sbr->L_E[ch] > 1) - sbr->L_Q[ch] = 2; - else - sbr->L_Q[ch] = 1; - - /* TODO: this code can probably be integrated into the code above! */ - if ((result = envelope_time_border_vector(sbr, ch)) > 0) - { - sbr->bs_frame_class[ch] = saved_frame_class; - sbr->L_E[ch] = saved_L_E; - sbr->L_Q[ch] = saved_L_Q; - return result; - } - noise_floor_time_border_vector(sbr, ch); - -#if 0 - for (env = 0; env < bs_num_env; env++) - { - printf("freq_res[ch:%d][env:%d]: %d\n", ch, env, sbr->f[ch][env]); - } -#endif - - return 0; -} - -/* table 8 */ -static void sbr_dtdf(bitfile *ld, sbr_info *sbr, uint8_t ch) -{ - uint8_t i; - - for (i = 0; i < sbr->L_E[ch]; i++) - { - sbr->bs_df_env[ch][i] = faad_get1bit(ld - DEBUGVAR(1,269,"sbr_dtdf(): bs_df_env")); - } - - for (i = 0; i < sbr->L_Q[ch]; i++) - { - sbr->bs_df_noise[ch][i] = faad_get1bit(ld - DEBUGVAR(1,270,"sbr_dtdf(): bs_df_noise")); - } -} - -/* table 9 */ -static void invf_mode(bitfile *ld, sbr_info *sbr, uint8_t ch) -{ - uint8_t n; - - for (n = 0; n < sbr->N_Q; n++) - { - sbr->bs_invf_mode[ch][n] = (uint8_t)faad_getbits(ld, 2 - DEBUGVAR(1,271,"invf_mode(): bs_invf_mode")); - } -} - -static uint16_t sbr_extension(bitfile *ld, sbr_info *sbr, - uint8_t bs_extension_id, uint16_t num_bits_left) -{ -#ifdef PS_DEC - uint8_t header; - uint16_t ret; -#endif - - (void)num_bits_left; - switch (bs_extension_id) - { -#ifdef PS_DEC - case EXTENSION_ID_PS: - ret = ps_data(&sbr->ps, ld, &header); - - /* enable PS if and only if: a header has been decoded */ - if (sbr->ps_used == 0 && header == 1) - { - sbr->ps_used = 1; - } - - return ret; -#endif -#ifdef DRM_PS - case DRM_PARAMETRIC_STEREO: - sbr->ps_used = 1; - if (!sbr->drm_ps) - { - sbr->drm_ps = drm_ps_init(); - } - return drm_ps_data(sbr->drm_ps, ld); -#endif - default: - sbr->bs_extension_data = (uint8_t)faad_getbits(ld, 6 - DEBUGVAR(1,279,"sbr_single_channel_element(): bs_extension_data")); - return 6; - } -} - -/* table 12 */ -static void sinusoidal_coding(bitfile *ld, sbr_info *sbr, uint8_t ch) -{ - uint8_t n; - - for (n = 0; n < sbr->N_high; n++) - { - sbr->bs_add_harmonic[ch][n] = faad_get1bit(ld - DEBUGVAR(1,278,"sinusoidal_coding(): bs_add_harmonic")); - } -} - - -#endif /* SBR_DEC */ diff --git a/apps/codecs/libfaad/sbr_syntax.h b/apps/codecs/libfaad/sbr_syntax.h deleted file mode 100644 index 33aecaaf73..0000000000 --- a/apps/codecs/libfaad/sbr_syntax.h +++ /dev/null @@ -1,64 +0,0 @@ -/* -** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -** -** Any non-GPL usage of this software or parts of this software is strictly -** forbidden. -** -** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. -** -** $Id$ -**/ - -#ifndef __SBR_SYNTAX_H__ -#define __SBR_SYNTAX_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -#include "bits.h" - -#define T_HFGEN 8 -#define T_HFADJ 2 - -#define EXT_SBR_DATA 13 -#define EXT_SBR_DATA_CRC 14 - -#define FIXFIX 0 -#define FIXVAR 1 -#define VARFIX 2 -#define VARVAR 3 - -#define LO_RES 0 -#define HI_RES 1 - -#define NO_TIME_SLOTS_960 15 -#define NO_TIME_SLOTS 16 -#define RATE 2 - -#define NOISE_FLOOR_OFFSET 6 - - -uint8_t sbr_extension_data(bitfile *ld, sbr_info *sbr, uint16_t cnt); - -#ifdef __cplusplus -} -#endif -#endif /* __SBR_SYNTAX_H__ */ - diff --git a/apps/codecs/libfaad/sbr_tf_grid.c b/apps/codecs/libfaad/sbr_tf_grid.c deleted file mode 100644 index 2c21173490..0000000000 --- a/apps/codecs/libfaad/sbr_tf_grid.c +++ /dev/null @@ -1,259 +0,0 @@ -/* -** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -** -** Any non-GPL usage of this software or parts of this software is strictly -** forbidden. -** -** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. -** -** $Id$ -**/ - -/* Time/Frequency grid */ - -#include "common.h" -#include "structs.h" - -#ifdef SBR_DEC - -#include - -#include "sbr_syntax.h" -#include "sbr_tf_grid.h" - - -/* static function declarations */ -#if 0 -static int16_t rel_bord_lead(sbr_info *sbr, uint8_t ch, uint8_t l); -static int16_t rel_bord_trail(sbr_info *sbr, uint8_t ch, uint8_t l); -#endif -static uint8_t middleBorder(sbr_info *sbr, uint8_t ch); - - -/* function constructs new time border vector */ -/* first build into temp vector to be able to use previous vector on error */ -uint8_t envelope_time_border_vector(sbr_info *sbr, uint8_t ch) -{ - uint8_t l, temp; - int8_t border; - uint8_t t_E_temp[6] = {0}; - - t_E_temp[0] = sbr->rate * sbr->abs_bord_lead[ch]; - t_E_temp[sbr->L_E[ch]] = sbr->rate * sbr->abs_bord_trail[ch]; - - switch (sbr->bs_frame_class[ch]) - { - case FIXFIX: - switch (sbr->L_E[ch]) - { - case 4: - temp = (int) (sbr->numTimeSlots / 4); - t_E_temp[3] = sbr->rate * 3 * temp; - t_E_temp[2] = sbr->rate * 2 * temp; - t_E_temp[1] = sbr->rate * temp; - break; - case 2: - t_E_temp[1] = sbr->rate * (int) (sbr->numTimeSlots / 2); - break; - default: - break; - } - break; - - case FIXVAR: - if (sbr->L_E[ch] > 1) - { - int8_t i = sbr->L_E[ch]; - border = sbr->abs_bord_trail[ch]; - - for (l = 0; l < (sbr->L_E[ch] - 1); l++) - { - if (border < sbr->bs_rel_bord[ch][l]) - return 1; - - border -= sbr->bs_rel_bord[ch][l]; - t_E_temp[--i] = sbr->rate * border; - } - } - break; - - case VARFIX: - if (sbr->L_E[ch] > 1) - { - int8_t i = 1; - border = sbr->abs_bord_lead[ch]; - - for (l = 0; l < (sbr->L_E[ch] - 1); l++) - { - border += sbr->bs_rel_bord[ch][l]; - - if (sbr->rate * border + sbr->tHFAdj > sbr->numTimeSlotsRate+sbr->tHFGen) - return 1; - - t_E_temp[i++] = sbr->rate * border; - } - } - break; - - case VARVAR: - if (sbr->bs_num_rel_0[ch]) - { - int8_t i = 1; - border = sbr->abs_bord_lead[ch]; - - for (l = 0; l < sbr->bs_num_rel_0[ch]; l++) - { - border += sbr->bs_rel_bord_0[ch][l]; - - if (sbr->rate * border + sbr->tHFAdj > sbr->numTimeSlotsRate+sbr->tHFGen) - return 1; - - t_E_temp[i++] = sbr->rate * border; - } - } - - if (sbr->bs_num_rel_1[ch]) - { - int8_t i = sbr->L_E[ch]; - border = sbr->abs_bord_trail[ch]; - - for (l = 0; l < sbr->bs_num_rel_1[ch]; l++) - { - if (border < sbr->bs_rel_bord_1[ch][l]) - return 1; - - border -= sbr->bs_rel_bord_1[ch][l]; - t_E_temp[--i] = sbr->rate * border; - } - } - break; - } - - /* no error occured, we can safely use this t_E vector */ - for (l = 0; l < 6; l++) - { - sbr->t_E[ch][l] = t_E_temp[l]; - } - - return 0; -} - -void noise_floor_time_border_vector(sbr_info *sbr, uint8_t ch) -{ - sbr->t_Q[ch][0] = sbr->t_E[ch][0]; - - if (sbr->L_E[ch] == 1) - { - sbr->t_Q[ch][1] = sbr->t_E[ch][1]; - sbr->t_Q[ch][2] = 0; - } else { - uint8_t index = middleBorder(sbr, ch); - sbr->t_Q[ch][1] = sbr->t_E[ch][index]; - sbr->t_Q[ch][2] = sbr->t_E[ch][sbr->L_E[ch]]; - } -} - -#if 0 -static int16_t rel_bord_lead(sbr_info *sbr, uint8_t ch, uint8_t l) -{ - uint8_t i; - int16_t acc = 0; - - switch (sbr->bs_frame_class[ch]) - { - case FIXFIX: - return sbr->numTimeSlots/sbr->L_E[ch]; - case FIXVAR: - return 0; - case VARFIX: - for (i = 0; i < l; i++) - { - acc += sbr->bs_rel_bord[ch][i]; - } - return acc; - case VARVAR: - for (i = 0; i < l; i++) - { - acc += sbr->bs_rel_bord_0[ch][i]; - } - return acc; - } - - return 0; -} - -static int16_t rel_bord_trail(sbr_info *sbr, uint8_t ch, uint8_t l) -{ - uint8_t i; - int16_t acc = 0; - - switch (sbr->bs_frame_class[ch]) - { - case FIXFIX: - case VARFIX: - return 0; - case FIXVAR: - for (i = 0; i < l; i++) - { - acc += sbr->bs_rel_bord[ch][i]; - } - return acc; - case VARVAR: - for (i = 0; i < l; i++) - { - acc += sbr->bs_rel_bord_1[ch][i]; - } - return acc; - } - - return 0; -} -#endif - -static uint8_t middleBorder(sbr_info *sbr, uint8_t ch) -{ - int8_t retval = 0; - - switch (sbr->bs_frame_class[ch]) - { - case FIXFIX: - retval = sbr->L_E[ch]/2; - break; - case VARFIX: - if (sbr->bs_pointer[ch] == 0) - retval = 1; - else if (sbr->bs_pointer[ch] == 1) - retval = sbr->L_E[ch] - 1; - else - retval = sbr->bs_pointer[ch] - 1; - break; - case FIXVAR: - case VARVAR: - if (sbr->bs_pointer[ch] > 1) - retval = sbr->L_E[ch] + 1 - sbr->bs_pointer[ch]; - else - retval = sbr->L_E[ch] - 1; - break; - } - - return (retval > 0) ? retval : 0; -} - - -#endif diff --git a/apps/codecs/libfaad/sbr_tf_grid.h b/apps/codecs/libfaad/sbr_tf_grid.h deleted file mode 100644 index b7a6b32290..0000000000 --- a/apps/codecs/libfaad/sbr_tf_grid.h +++ /dev/null @@ -1,44 +0,0 @@ -/* -** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -** -** Any non-GPL usage of this software or parts of this software is strictly -** forbidden. -** -** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. -** -** $Id$ -**/ - -#ifndef __SBR_TF_GRID_H__ -#define __SBR_TF_GRID_H__ - -#ifdef __cplusplus -extern "C" { -#endif - - -uint8_t envelope_time_border_vector(sbr_info *sbr, uint8_t ch); -void noise_floor_time_border_vector(sbr_info *sbr, uint8_t ch); - - -#ifdef __cplusplus -} -#endif -#endif - diff --git a/apps/codecs/libfaad/sine_win.h b/apps/codecs/libfaad/sine_win.h deleted file mode 100644 index 3e042f15f7..0000000000 --- a/apps/codecs/libfaad/sine_win.h +++ /dev/null @@ -1,4301 +0,0 @@ -/* -** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -** -** Any non-GPL usage of this software or parts of this software is strictly -** forbidden. -** -** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. -** -** $Id$ -**/ - -#ifndef __SINE_WIN_H__ -#define __SINE_WIN_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef _MSC_VER -#pragma warning(disable:4305) -#pragma warning(disable:4244) -#endif - -static const real_t sine_long_1024[] ICONST_ATTR MEM_ALIGN_ATTR = -{ - FRAC_CONST(0.00076699031874270449), - FRAC_CONST(0.002300969151425805), - FRAC_CONST(0.0038349425697062275), - FRAC_CONST(0.0053689069639963425), - FRAC_CONST(0.0069028587247297558), - FRAC_CONST(0.0084367942423697988), - FRAC_CONST(0.0099707099074180308), - FRAC_CONST(0.011504602110422714), - FRAC_CONST(0.013038467241987334), - FRAC_CONST(0.014572301692779064), - FRAC_CONST(0.016106101853537287), - FRAC_CONST(0.017639864115082053), - FRAC_CONST(0.019173584868322623), - FRAC_CONST(0.020707260504265895), - FRAC_CONST(0.022240887414024961), - FRAC_CONST(0.023774461988827555), - FRAC_CONST(0.025307980620024571), - FRAC_CONST(0.026841439699098531), - FRAC_CONST(0.028374835617672099), - FRAC_CONST(0.029908164767516555), - FRAC_CONST(0.031441423540560301), - FRAC_CONST(0.032974608328897335), - FRAC_CONST(0.03450771552479575), - FRAC_CONST(0.036040741520706229), - FRAC_CONST(0.037573682709270494), - FRAC_CONST(0.039106535483329888), - FRAC_CONST(0.040639296235933736), - FRAC_CONST(0.042171961360347947), - FRAC_CONST(0.043704527250063421), - FRAC_CONST(0.04523699029880459), - FRAC_CONST(0.046769346900537863), - FRAC_CONST(0.048301593449480144), - FRAC_CONST(0.049833726340107277), - FRAC_CONST(0.051365741967162593), - FRAC_CONST(0.052897636725665324), - FRAC_CONST(0.054429407010919133), - FRAC_CONST(0.055961049218520569), - FRAC_CONST(0.057492559744367566), - FRAC_CONST(0.059023934984667931), - FRAC_CONST(0.060555171335947788), - FRAC_CONST(0.062086265195060088), - FRAC_CONST(0.063617212959193106), - FRAC_CONST(0.065148011025878833), - FRAC_CONST(0.066678655793001557), - FRAC_CONST(0.068209143658806329), - FRAC_CONST(0.069739471021907307), - FRAC_CONST(0.071269634281296401), - FRAC_CONST(0.072799629836351673), - FRAC_CONST(0.074329454086845756), - FRAC_CONST(0.075859103432954447), - FRAC_CONST(0.077388574275265049), - FRAC_CONST(0.078917863014784942), - FRAC_CONST(0.080446966052950014), - FRAC_CONST(0.081975879791633066), - FRAC_CONST(0.083504600633152432), - FRAC_CONST(0.085033124980280275), - FRAC_CONST(0.08656144923625117), - FRAC_CONST(0.088089569804770507), - FRAC_CONST(0.089617483090022959), - FRAC_CONST(0.091145185496681005), - FRAC_CONST(0.09267267342991331), - FRAC_CONST(0.094199943295393204), - FRAC_CONST(0.095726991499307162), - FRAC_CONST(0.097253814448363271), - FRAC_CONST(0.098780408549799623), - FRAC_CONST(0.10030677021139286), - FRAC_CONST(0.10183289584146653), - FRAC_CONST(0.10335878184889961), - FRAC_CONST(0.10488442464313497), - FRAC_CONST(0.10640982063418768), - FRAC_CONST(0.10793496623265365), - FRAC_CONST(0.10945985784971798), - FRAC_CONST(0.11098449189716339), - FRAC_CONST(0.11250886478737869), - FRAC_CONST(0.1140329729333672), - FRAC_CONST(0.11555681274875526), - FRAC_CONST(0.11708038064780059), - FRAC_CONST(0.11860367304540072), - FRAC_CONST(0.1201266863571015), - FRAC_CONST(0.12164941699910553), - FRAC_CONST(0.12317186138828048), - FRAC_CONST(0.12469401594216764), - FRAC_CONST(0.12621587707899035), - FRAC_CONST(0.12773744121766231), - FRAC_CONST(0.12925870477779614), - FRAC_CONST(0.13077966417971171), - FRAC_CONST(0.13230031584444465), - FRAC_CONST(0.13382065619375472), - FRAC_CONST(0.13534068165013421), - FRAC_CONST(0.13686038863681638), - FRAC_CONST(0.13837977357778389), - FRAC_CONST(0.13989883289777721), - FRAC_CONST(0.14141756302230302), - FRAC_CONST(0.14293596037764267), - FRAC_CONST(0.14445402139086047), - FRAC_CONST(0.14597174248981221), - FRAC_CONST(0.14748912010315357), - FRAC_CONST(0.14900615066034845), - FRAC_CONST(0.1505228305916774), - FRAC_CONST(0.15203915632824605), - FRAC_CONST(0.15355512430199345), - FRAC_CONST(0.15507073094570051), - FRAC_CONST(0.15658597269299843), - FRAC_CONST(0.15810084597837698), - FRAC_CONST(0.15961534723719306), - FRAC_CONST(0.16112947290567881), - FRAC_CONST(0.16264321942095031), - FRAC_CONST(0.16415658322101581), - FRAC_CONST(0.16566956074478412), - FRAC_CONST(0.16718214843207294), - FRAC_CONST(0.16869434272361733), - FRAC_CONST(0.17020614006107807), - FRAC_CONST(0.17171753688704997), - FRAC_CONST(0.17322852964507032), - FRAC_CONST(0.1747391147796272), - FRAC_CONST(0.17624928873616788), - FRAC_CONST(0.17775904796110717), - FRAC_CONST(0.17926838890183575), - FRAC_CONST(0.18077730800672859), - FRAC_CONST(0.1822858017251533), - FRAC_CONST(0.18379386650747845), - FRAC_CONST(0.1853014988050819), - FRAC_CONST(0.18680869507035927), - FRAC_CONST(0.18831545175673212), - FRAC_CONST(0.18982176531865641), - FRAC_CONST(0.1913276322116309), - FRAC_CONST(0.19283304889220523), - FRAC_CONST(0.1943380118179886), - FRAC_CONST(0.19584251744765785), - FRAC_CONST(0.19734656224096592), - FRAC_CONST(0.19885014265875009), - FRAC_CONST(0.20035325516294045), - FRAC_CONST(0.20185589621656805), - FRAC_CONST(0.20335806228377332), - FRAC_CONST(0.20485974982981442), - FRAC_CONST(0.20636095532107551), - FRAC_CONST(0.20786167522507507), - FRAC_CONST(0.20936190601047416), - FRAC_CONST(0.21086164414708486), - FRAC_CONST(0.21236088610587842), - FRAC_CONST(0.21385962835899375), - FRAC_CONST(0.21535786737974555), - FRAC_CONST(0.21685559964263262), - FRAC_CONST(0.21835282162334632), - FRAC_CONST(0.2198495297987787), - FRAC_CONST(0.22134572064703081), - FRAC_CONST(0.22284139064742112), - FRAC_CONST(0.2243365362804936), - FRAC_CONST(0.22583115402802617), - FRAC_CONST(0.22732524037303886), - FRAC_CONST(0.22881879179980222), - FRAC_CONST(0.23031180479384544), - FRAC_CONST(0.23180427584196478), - FRAC_CONST(0.23329620143223159), - FRAC_CONST(0.23478757805400097), - FRAC_CONST(0.23627840219791957), - FRAC_CONST(0.23776867035593419), - FRAC_CONST(0.23925837902129998), - FRAC_CONST(0.24074752468858843), - FRAC_CONST(0.24223610385369601), - FRAC_CONST(0.24372411301385216), - FRAC_CONST(0.24521154866762754), - FRAC_CONST(0.24669840731494241), - FRAC_CONST(0.24818468545707478), - FRAC_CONST(0.24967037959666857), - FRAC_CONST(0.25115548623774192), - FRAC_CONST(0.25264000188569552), - FRAC_CONST(0.25412392304732062), - FRAC_CONST(0.25560724623080738), - FRAC_CONST(0.25708996794575312), - FRAC_CONST(0.25857208470317034), - FRAC_CONST(0.26005359301549519), - FRAC_CONST(0.26153448939659552), - FRAC_CONST(0.263014770361779), - FRAC_CONST(0.26449443242780163), - FRAC_CONST(0.26597347211287559), - FRAC_CONST(0.26745188593667762), - FRAC_CONST(0.26892967042035726), - FRAC_CONST(0.27040682208654482), - FRAC_CONST(0.27188333745935972), - FRAC_CONST(0.27335921306441868), - FRAC_CONST(0.27483444542884394), - FRAC_CONST(0.27630903108127108), - FRAC_CONST(0.27778296655185769), - FRAC_CONST(0.27925624837229118), - FRAC_CONST(0.28072887307579719), - FRAC_CONST(0.28220083719714756), - FRAC_CONST(0.28367213727266843), - FRAC_CONST(0.28514276984024867), - FRAC_CONST(0.28661273143934779), - FRAC_CONST(0.28808201861100413), - FRAC_CONST(0.28955062789784303), - FRAC_CONST(0.29101855584408509), - FRAC_CONST(0.29248579899555388), - FRAC_CONST(0.29395235389968466), - FRAC_CONST(0.29541821710553201), - FRAC_CONST(0.29688338516377827), - FRAC_CONST(0.2983478546267414), - FRAC_CONST(0.29981162204838335), - FRAC_CONST(0.30127468398431795), - FRAC_CONST(0.30273703699181914), - FRAC_CONST(0.30419867762982911), - FRAC_CONST(0.30565960245896612), - FRAC_CONST(0.3071198080415331), - FRAC_CONST(0.30857929094152509), - FRAC_CONST(0.31003804772463789), - FRAC_CONST(0.31149607495827591), - FRAC_CONST(0.3129533692115602), - FRAC_CONST(0.31440992705533666), - FRAC_CONST(0.31586574506218396), - FRAC_CONST(0.31732081980642174), - FRAC_CONST(0.31877514786411848), - FRAC_CONST(0.32022872581309986), - FRAC_CONST(0.32168155023295658), - FRAC_CONST(0.32313361770505233), - FRAC_CONST(0.32458492481253215), - FRAC_CONST(0.32603546814033024), - FRAC_CONST(0.327485244275178), - FRAC_CONST(0.3289342498056122), - FRAC_CONST(0.33038248132198278), - FRAC_CONST(0.33182993541646111), - FRAC_CONST(0.33327660868304793), - FRAC_CONST(0.33472249771758122), - FRAC_CONST(0.33616759911774452), - FRAC_CONST(0.33761190948307462), - FRAC_CONST(0.33905542541496964), - FRAC_CONST(0.34049814351669716), - FRAC_CONST(0.34194006039340219), - FRAC_CONST(0.34338117265211504), - FRAC_CONST(0.34482147690175929), - FRAC_CONST(0.34626096975316001), - FRAC_CONST(0.34769964781905138), - FRAC_CONST(0.34913750771408497), - FRAC_CONST(0.35057454605483751), - FRAC_CONST(0.35201075945981908), - FRAC_CONST(0.35344614454948081), - FRAC_CONST(0.35488069794622279), - FRAC_CONST(0.35631441627440241), - FRAC_CONST(0.3577472961603419), - FRAC_CONST(0.3591793342323365), - FRAC_CONST(0.36061052712066227), - FRAC_CONST(0.36204087145758418), - FRAC_CONST(0.36347036387736376), - FRAC_CONST(0.36489900101626732), - FRAC_CONST(0.36632677951257359), - FRAC_CONST(0.36775369600658198), - FRAC_CONST(0.36917974714062002), - FRAC_CONST(0.37060492955905167), - FRAC_CONST(0.37202923990828501), - FRAC_CONST(0.3734526748367803), - FRAC_CONST(0.37487523099505754), - FRAC_CONST(0.37629690503570479), - FRAC_CONST(0.37771769361338564), - FRAC_CONST(0.37913759338484732), - FRAC_CONST(0.38055660100892852), - FRAC_CONST(0.38197471314656722), - FRAC_CONST(0.38339192646080866), - FRAC_CONST(0.38480823761681288), - FRAC_CONST(0.38622364328186298), - FRAC_CONST(0.38763814012537273), - FRAC_CONST(0.38905172481889438), - FRAC_CONST(0.39046439403612659), - FRAC_CONST(0.39187614445292235), - FRAC_CONST(0.3932869727472964), - FRAC_CONST(0.39469687559943356), - FRAC_CONST(0.39610584969169627), - FRAC_CONST(0.39751389170863233), - FRAC_CONST(0.39892099833698291), - FRAC_CONST(0.40032716626569009), - FRAC_CONST(0.40173239218590501), - FRAC_CONST(0.4031366727909953), - FRAC_CONST(0.404540004776553), - FRAC_CONST(0.40594238484040251), - FRAC_CONST(0.40734380968260797), - FRAC_CONST(0.40874427600548136), - FRAC_CONST(0.41014378051359024), - FRAC_CONST(0.41154231991376522), - FRAC_CONST(0.41293989091510808), - FRAC_CONST(0.4143364902289991), - FRAC_CONST(0.41573211456910536), - FRAC_CONST(0.41712676065138787), - FRAC_CONST(0.4185204251941097), - FRAC_CONST(0.41991310491784362), - FRAC_CONST(0.42130479654547964), - FRAC_CONST(0.42269549680223295), - FRAC_CONST(0.42408520241565156), - FRAC_CONST(0.4254739101156238), - FRAC_CONST(0.42686161663438643), - FRAC_CONST(0.42824831870653196), - FRAC_CONST(0.42963401306901638), - FRAC_CONST(0.43101869646116703), - FRAC_CONST(0.43240236562469014), - FRAC_CONST(0.43378501730367852), - FRAC_CONST(0.43516664824461926), - FRAC_CONST(0.4365472551964012), - FRAC_CONST(0.43792683491032286), - FRAC_CONST(0.43930538414009995), - FRAC_CONST(0.4406828996418729), - FRAC_CONST(0.4420593781742147), - FRAC_CONST(0.44343481649813848), - FRAC_CONST(0.44480921137710488), - FRAC_CONST(0.44618255957703007), - FRAC_CONST(0.44755485786629301), - FRAC_CONST(0.44892610301574326), - FRAC_CONST(0.45029629179870861), - FRAC_CONST(0.45166542099100249), - FRAC_CONST(0.45303348737093158), - FRAC_CONST(0.45440048771930358), - FRAC_CONST(0.45576641881943464), - FRAC_CONST(0.45713127745715698), - FRAC_CONST(0.45849506042082627), - FRAC_CONST(0.45985776450132954), - FRAC_CONST(0.46121938649209238), - FRAC_CONST(0.46257992318908681), - FRAC_CONST(0.46393937139083852), - FRAC_CONST(0.4652977278984346), - FRAC_CONST(0.46665498951553092), - FRAC_CONST(0.46801115304835983), - FRAC_CONST(0.46936621530573752), - FRAC_CONST(0.4707201730990716), - FRAC_CONST(0.47207302324236866), - FRAC_CONST(0.47342476255224153), - FRAC_CONST(0.47477538784791712), - FRAC_CONST(0.47612489595124358), - FRAC_CONST(0.47747328368669806), - FRAC_CONST(0.47882054788139389), - FRAC_CONST(0.48016668536508839), - FRAC_CONST(0.48151169297018986), - FRAC_CONST(0.48285556753176567), - FRAC_CONST(0.48419830588754903), - FRAC_CONST(0.48553990487794696), - FRAC_CONST(0.48688036134604734), - FRAC_CONST(0.48821967213762679), - FRAC_CONST(0.48955783410115744), - FRAC_CONST(0.49089484408781509), - FRAC_CONST(0.49223069895148602), - FRAC_CONST(0.49356539554877477), - FRAC_CONST(0.49489893073901126), - FRAC_CONST(0.49623130138425825), - FRAC_CONST(0.49756250434931915), - FRAC_CONST(0.49889253650174459), - FRAC_CONST(0.50022139471184068), - FRAC_CONST(0.50154907585267539), - FRAC_CONST(0.50287557680008699), - FRAC_CONST(0.50420089443269034), - FRAC_CONST(0.50552502563188539), - FRAC_CONST(0.50684796728186321), - FRAC_CONST(0.5081697162696146), - FRAC_CONST(0.50949026948493636), - FRAC_CONST(0.51080962382043904), - FRAC_CONST(0.51212777617155469), - FRAC_CONST(0.51344472343654346), - FRAC_CONST(0.5147604625165012), - FRAC_CONST(0.51607499031536663), - FRAC_CONST(0.51738830373992906), - FRAC_CONST(0.51870039969983495), - FRAC_CONST(0.52001127510759604), - FRAC_CONST(0.52132092687859566), - FRAC_CONST(0.52262935193109661), - FRAC_CONST(0.5239365471862486), - FRAC_CONST(0.52524250956809471), - FRAC_CONST(0.52654723600357944), - FRAC_CONST(0.52785072342255523), - FRAC_CONST(0.52915296875779061), - FRAC_CONST(0.53045396894497632), - FRAC_CONST(0.53175372092273332), - FRAC_CONST(0.53305222163261945), - FRAC_CONST(0.53434946801913752), - FRAC_CONST(0.53564545702974109), - FRAC_CONST(0.53694018561484291), - FRAC_CONST(0.5382336507278217), - FRAC_CONST(0.53952584932502889), - FRAC_CONST(0.54081677836579667), - FRAC_CONST(0.54210643481244392), - FRAC_CONST(0.5433948156302848), - FRAC_CONST(0.54468191778763453), - FRAC_CONST(0.54596773825581757), - FRAC_CONST(0.54725227400917409), - FRAC_CONST(0.54853552202506739), - FRAC_CONST(0.54981747928389091), - FRAC_CONST(0.55109814276907543), - FRAC_CONST(0.55237750946709607), - FRAC_CONST(0.55365557636747931), - FRAC_CONST(0.55493234046281037), - FRAC_CONST(0.55620779874873993), - FRAC_CONST(0.55748194822399155), - FRAC_CONST(0.55875478589036831), - FRAC_CONST(0.56002630875276038), - FRAC_CONST(0.56129651381915147), - FRAC_CONST(0.56256539810062656), - FRAC_CONST(0.56383295861137817), - FRAC_CONST(0.56509919236871398), - FRAC_CONST(0.56636409639306384), - FRAC_CONST(0.56762766770798623), - FRAC_CONST(0.56888990334017586), - FRAC_CONST(0.5701508003194703), - FRAC_CONST(0.57141035567885723), - FRAC_CONST(0.57266856645448116), - FRAC_CONST(0.57392542968565075), - FRAC_CONST(0.57518094241484508), - FRAC_CONST(0.57643510168772183), - FRAC_CONST(0.5776879045531228), - FRAC_CONST(0.57893934806308178), - FRAC_CONST(0.58018942927283168), - FRAC_CONST(0.58143814524081017), - FRAC_CONST(0.58268549302866846), - FRAC_CONST(0.58393146970127618), - FRAC_CONST(0.58517607232673041), - FRAC_CONST(0.5864192979763605), - FRAC_CONST(0.58766114372473666), - FRAC_CONST(0.58890160664967572), - FRAC_CONST(0.59014068383224882), - FRAC_CONST(0.59137837235678758), - FRAC_CONST(0.59261466931089113), - FRAC_CONST(0.59384957178543363), - FRAC_CONST(0.59508307687456996), - FRAC_CONST(0.59631518167574371), - FRAC_CONST(0.59754588328969316), - FRAC_CONST(0.59877517882045872), - FRAC_CONST(0.60000306537538894), - FRAC_CONST(0.6012295400651485), - FRAC_CONST(0.60245460000372375), - FRAC_CONST(0.60367824230843037), - FRAC_CONST(0.60490046409991982), - FRAC_CONST(0.60612126250218612), - FRAC_CONST(0.60734063464257293), - FRAC_CONST(0.60855857765177945), - FRAC_CONST(0.60977508866386843), - FRAC_CONST(0.61099016481627166), - FRAC_CONST(0.61220380324979795), - FRAC_CONST(0.61341600110863859), - FRAC_CONST(0.61462675554037505), - FRAC_CONST(0.61583606369598509), - FRAC_CONST(0.61704392272984976), - FRAC_CONST(0.61825032979976025), - FRAC_CONST(0.61945528206692402), - FRAC_CONST(0.62065877669597214), - FRAC_CONST(0.62186081085496536), - FRAC_CONST(0.62306138171540126), - FRAC_CONST(0.62426048645222065), - FRAC_CONST(0.62545812224381436), - FRAC_CONST(0.62665428627202935), - FRAC_CONST(0.62784897572217646), - FRAC_CONST(0.629042187783036), - FRAC_CONST(0.63023391964686437), - FRAC_CONST(0.63142416850940186), - FRAC_CONST(0.63261293156987741), - FRAC_CONST(0.63380020603101728), - FRAC_CONST(0.63498598909904946), - FRAC_CONST(0.63617027798371217), - FRAC_CONST(0.63735306989825913), - FRAC_CONST(0.63853436205946679), - FRAC_CONST(0.63971415168764045), - FRAC_CONST(0.64089243600662138), - FRAC_CONST(0.64206921224379254), - FRAC_CONST(0.64324447763008585), - FRAC_CONST(0.64441822939998838), - FRAC_CONST(0.64559046479154869), - FRAC_CONST(0.64676118104638392), - FRAC_CONST(0.64793037540968534), - FRAC_CONST(0.64909804513022595), - FRAC_CONST(0.65026418746036585), - FRAC_CONST(0.65142879965605982), - FRAC_CONST(0.65259187897686244), - FRAC_CONST(0.65375342268593606), - FRAC_CONST(0.65491342805005603), - FRAC_CONST(0.6560718923396176), - FRAC_CONST(0.65722881282864254), - FRAC_CONST(0.65838418679478505), - FRAC_CONST(0.65953801151933866), - FRAC_CONST(0.6606902842872423), - FRAC_CONST(0.66184100238708687), - FRAC_CONST(0.66299016311112147), - FRAC_CONST(0.66413776375526001), - FRAC_CONST(0.66528380161908718), - FRAC_CONST(0.66642827400586524), - FRAC_CONST(0.66757117822254031), - FRAC_CONST(0.66871251157974798), - FRAC_CONST(0.66985227139182102), - FRAC_CONST(0.67099045497679422), - FRAC_CONST(0.67212705965641173), - FRAC_CONST(0.67326208275613297), - FRAC_CONST(0.67439552160513905), - FRAC_CONST(0.67552737353633852), - FRAC_CONST(0.67665763588637495), - FRAC_CONST(0.6777863059956315), - FRAC_CONST(0.67891338120823841), - FRAC_CONST(0.68003885887207893), - FRAC_CONST(0.68116273633879543), - FRAC_CONST(0.68228501096379557), - FRAC_CONST(0.68340568010625868), - FRAC_CONST(0.6845247411291423), - FRAC_CONST(0.68564219139918747), - FRAC_CONST(0.68675802828692589), - FRAC_CONST(0.68787224916668555), - FRAC_CONST(0.68898485141659704), - FRAC_CONST(0.69009583241859995), - FRAC_CONST(0.69120518955844845), - FRAC_CONST(0.69231292022571822), - FRAC_CONST(0.69341902181381176), - FRAC_CONST(0.69452349171996552), - FRAC_CONST(0.69562632734525487), - FRAC_CONST(0.6967275260946012), - FRAC_CONST(0.69782708537677729), - FRAC_CONST(0.69892500260441415), - FRAC_CONST(0.70002127519400625), - FRAC_CONST(0.70111590056591866), - FRAC_CONST(0.70220887614439187), - FRAC_CONST(0.70330019935754873), - FRAC_CONST(0.70438986763740041), - FRAC_CONST(0.7054778784198521), - FRAC_CONST(0.70656422914470951), - FRAC_CONST(0.70764891725568435), - FRAC_CONST(0.70873194020040065), - FRAC_CONST(0.70981329543040084), - FRAC_CONST(0.71089298040115168), - FRAC_CONST(0.71197099257204999), - FRAC_CONST(0.71304732940642923), - FRAC_CONST(0.71412198837156471), - FRAC_CONST(0.71519496693868001), - FRAC_CONST(0.71626626258295312), - FRAC_CONST(0.71733587278352173), - FRAC_CONST(0.71840379502348972), - FRAC_CONST(0.71947002678993299), - FRAC_CONST(0.72053456557390527), - FRAC_CONST(0.72159740887044366), - FRAC_CONST(0.72265855417857561), - FRAC_CONST(0.72371799900132339), - FRAC_CONST(0.72477574084571128), - FRAC_CONST(0.72583177722277037), - FRAC_CONST(0.72688610564754497), - FRAC_CONST(0.72793872363909862), - FRAC_CONST(0.72898962872051931), - FRAC_CONST(0.73003881841892615), - FRAC_CONST(0.73108629026547423), - FRAC_CONST(0.73213204179536129), - FRAC_CONST(0.73317607054783274), - FRAC_CONST(0.73421837406618817), - FRAC_CONST(0.73525894989778673), - FRAC_CONST(0.73629779559405306), - FRAC_CONST(0.73733490871048279), - FRAC_CONST(0.73837028680664851), - FRAC_CONST(0.73940392744620576), - FRAC_CONST(0.74043582819689802), - FRAC_CONST(0.74146598663056329), - FRAC_CONST(0.74249440032313918), - FRAC_CONST(0.74352106685466912), - FRAC_CONST(0.74454598380930725), - FRAC_CONST(0.74556914877532543), - FRAC_CONST(0.74659055934511731), - FRAC_CONST(0.74761021311520515), - FRAC_CONST(0.74862810768624533), - FRAC_CONST(0.74964424066303348), - FRAC_CONST(0.75065860965451059), - FRAC_CONST(0.75167121227376843), - FRAC_CONST(0.75268204613805523), - FRAC_CONST(0.75369110886878121), - FRAC_CONST(0.75469839809152439), - FRAC_CONST(0.75570391143603588), - FRAC_CONST(0.75670764653624567), - FRAC_CONST(0.75770960103026808), - FRAC_CONST(0.75870977256040739), - FRAC_CONST(0.75970815877316344), - FRAC_CONST(0.76070475731923692), - FRAC_CONST(0.76169956585353527), - FRAC_CONST(0.76269258203517787), - FRAC_CONST(0.76368380352750187), - FRAC_CONST(0.76467322799806714), - FRAC_CONST(0.76566085311866239), - FRAC_CONST(0.76664667656531038), - FRAC_CONST(0.76763069601827327), - FRAC_CONST(0.76861290916205827), - FRAC_CONST(0.76959331368542294), - FRAC_CONST(0.7705719072813807), - FRAC_CONST(0.7715486876472063), - FRAC_CONST(0.77252365248444133), - FRAC_CONST(0.77349679949889905), - FRAC_CONST(0.77446812640067086), - FRAC_CONST(0.77543763090413043), - FRAC_CONST(0.77640531072794039), - FRAC_CONST(0.7773711635950562), - FRAC_CONST(0.77833518723273309), - FRAC_CONST(0.7792973793725303), - FRAC_CONST(0.78025773775031659), - FRAC_CONST(0.78121626010627609), - FRAC_CONST(0.7821729441849129), - FRAC_CONST(0.78312778773505731), - FRAC_CONST(0.78408078850986995), - FRAC_CONST(0.78503194426684808), - FRAC_CONST(0.78598125276783015), - FRAC_CONST(0.7869287117790017), - FRAC_CONST(0.78787431907090011), - FRAC_CONST(0.78881807241842017), - FRAC_CONST(0.78975996960081907), - FRAC_CONST(0.79070000840172161), - FRAC_CONST(0.79163818660912577), - FRAC_CONST(0.79257450201540758), - FRAC_CONST(0.79350895241732666), - FRAC_CONST(0.79444153561603059), - FRAC_CONST(0.79537224941706119), - FRAC_CONST(0.79630109163035911), - FRAC_CONST(0.7972280600702687), - FRAC_CONST(0.79815315255554375), - FRAC_CONST(0.79907636690935235), - FRAC_CONST(0.79999770095928191), - FRAC_CONST(0.8009171525373443), - FRAC_CONST(0.80183471947998131), - FRAC_CONST(0.80275039962806916), - FRAC_CONST(0.80366419082692409), - FRAC_CONST(0.804576090926307), - FRAC_CONST(0.80548609778042912), - FRAC_CONST(0.80639420924795624), - FRAC_CONST(0.80730042319201445), - FRAC_CONST(0.80820473748019472), - FRAC_CONST(0.80910714998455813), - FRAC_CONST(0.81000765858164114), - FRAC_CONST(0.81090626115245967), - FRAC_CONST(0.81180295558251536), - FRAC_CONST(0.81269773976179949), - FRAC_CONST(0.81359061158479851), - FRAC_CONST(0.81448156895049861), - FRAC_CONST(0.81537060976239129), - FRAC_CONST(0.81625773192847739), - FRAC_CONST(0.81714293336127297), - FRAC_CONST(0.81802621197781344), - FRAC_CONST(0.81890756569965895), - FRAC_CONST(0.81978699245289899), - FRAC_CONST(0.82066449016815746), - FRAC_CONST(0.82154005678059761), - FRAC_CONST(0.82241369022992639), - FRAC_CONST(0.82328538846040011), - FRAC_CONST(0.82415514942082857), - FRAC_CONST(0.82502297106458022), - FRAC_CONST(0.82588885134958678), - FRAC_CONST(0.82675278823834852), - FRAC_CONST(0.8276147796979384), - FRAC_CONST(0.82847482370000713), - FRAC_CONST(0.82933291822078825), - FRAC_CONST(0.83018906124110237), - FRAC_CONST(0.83104325074636232), - FRAC_CONST(0.83189548472657759), - FRAC_CONST(0.83274576117635946), - FRAC_CONST(0.83359407809492514), - FRAC_CONST(0.83444043348610319), - FRAC_CONST(0.83528482535833737), - FRAC_CONST(0.83612725172469216), - FRAC_CONST(0.83696771060285702), - FRAC_CONST(0.83780620001515094), - FRAC_CONST(0.8386427179885273), - FRAC_CONST(0.83947726255457855), - FRAC_CONST(0.84030983174954077), - FRAC_CONST(0.84114042361429808), - FRAC_CONST(0.84196903619438768), - FRAC_CONST(0.84279566754000412), - FRAC_CONST(0.84362031570600404), - FRAC_CONST(0.84444297875191066), - FRAC_CONST(0.84526365474191822), - FRAC_CONST(0.84608234174489694), - FRAC_CONST(0.84689903783439735), - FRAC_CONST(0.84771374108865427), - FRAC_CONST(0.84852644959059265), - FRAC_CONST(0.84933716142783067), - FRAC_CONST(0.85014587469268521), - FRAC_CONST(0.85095258748217573), - FRAC_CONST(0.85175729789802912), - FRAC_CONST(0.85256000404668397), - FRAC_CONST(0.85336070403929543), - FRAC_CONST(0.85415939599173873), - FRAC_CONST(0.85495607802461482), - FRAC_CONST(0.85575074826325392), - FRAC_CONST(0.85654340483771996), - FRAC_CONST(0.85733404588281559), - FRAC_CONST(0.85812266953808602), - FRAC_CONST(0.8589092739478239), - FRAC_CONST(0.85969385726107261), - FRAC_CONST(0.86047641763163207), - FRAC_CONST(0.86125695321806206), - FRAC_CONST(0.86203546218368721), - FRAC_CONST(0.86281194269660033), - FRAC_CONST(0.86358639292966799), - FRAC_CONST(0.86435881106053403), - FRAC_CONST(0.86512919527162369), - FRAC_CONST(0.86589754375014882), - FRAC_CONST(0.86666385468811102), - FRAC_CONST(0.86742812628230692), - FRAC_CONST(0.86819035673433131), - FRAC_CONST(0.86895054425058238), - FRAC_CONST(0.86970868704226556), - FRAC_CONST(0.87046478332539767), - FRAC_CONST(0.8712188313208109), - FRAC_CONST(0.8719708292541577), - FRAC_CONST(0.8727207753559143), - FRAC_CONST(0.87346866786138488), - FRAC_CONST(0.8742145050107063), - FRAC_CONST(0.87495828504885154), - FRAC_CONST(0.8757000062256346), - FRAC_CONST(0.87643966679571361), - FRAC_CONST(0.87717726501859594), - FRAC_CONST(0.87791279915864173), - FRAC_CONST(0.87864626748506813), - FRAC_CONST(0.87937766827195318), - FRAC_CONST(0.88010699979824036), - FRAC_CONST(0.88083426034774204), - FRAC_CONST(0.88155944820914378), - FRAC_CONST(0.8822825616760086), - FRAC_CONST(0.88300359904678072), - FRAC_CONST(0.88372255862478966), - FRAC_CONST(0.8844394387182537), - FRAC_CONST(0.88515423764028511), - FRAC_CONST(0.88586695370889279), - FRAC_CONST(0.88657758524698704), - FRAC_CONST(0.88728613058238315), - FRAC_CONST(0.88799258804780556), - FRAC_CONST(0.88869695598089171), - FRAC_CONST(0.88939923272419552), - FRAC_CONST(0.89009941662519221), - FRAC_CONST(0.89079750603628149), - FRAC_CONST(0.89149349931479138), - FRAC_CONST(0.89218739482298248), - FRAC_CONST(0.89287919092805168), - FRAC_CONST(0.89356888600213602), - FRAC_CONST(0.89425647842231604), - FRAC_CONST(0.89494196657062075), - FRAC_CONST(0.89562534883403), - FRAC_CONST(0.89630662360447966), - FRAC_CONST(0.89698578927886397), - FRAC_CONST(0.89766284425904075), - FRAC_CONST(0.89833778695183419), - FRAC_CONST(0.89901061576903907), - FRAC_CONST(0.89968132912742393), - FRAC_CONST(0.9003499254487356), - FRAC_CONST(0.90101640315970233), - FRAC_CONST(0.90168076069203773), - FRAC_CONST(0.9023429964824442), - FRAC_CONST(0.90300310897261704), - FRAC_CONST(0.90366109660924798), - FRAC_CONST(0.90431695784402832), - FRAC_CONST(0.90497069113365325), - FRAC_CONST(0.90562229493982516), - FRAC_CONST(0.90627176772925766), - FRAC_CONST(0.90691910797367803), - FRAC_CONST(0.90756431414983252), - FRAC_CONST(0.9082073847394887), - FRAC_CONST(0.90884831822943912), - FRAC_CONST(0.90948711311150543), - FRAC_CONST(0.91012376788254157), - FRAC_CONST(0.91075828104443757), - FRAC_CONST(0.91139065110412232), - FRAC_CONST(0.91202087657356823), - FRAC_CONST(0.9126489559697939), - FRAC_CONST(0.91327488781486776), - FRAC_CONST(0.91389867063591168), - FRAC_CONST(0.91452030296510445), - FRAC_CONST(0.91513978333968526), - FRAC_CONST(0.91575711030195672), - FRAC_CONST(0.91637228239928914), - FRAC_CONST(0.91698529818412289), - FRAC_CONST(0.91759615621397295), - FRAC_CONST(0.9182048550514309), - FRAC_CONST(0.91881139326416994), - FRAC_CONST(0.91941576942494696), - FRAC_CONST(0.92001798211160657), - FRAC_CONST(0.92061802990708386), - FRAC_CONST(0.92121591139940873), - FRAC_CONST(0.92181162518170812), - FRAC_CONST(0.92240516985220988), - FRAC_CONST(0.92299654401424625), - FRAC_CONST(0.92358574627625656), - FRAC_CONST(0.9241727752517912), - FRAC_CONST(0.92475762955951391), - FRAC_CONST(0.9253403078232062), - FRAC_CONST(0.92592080867176996), - FRAC_CONST(0.92649913073923051), - FRAC_CONST(0.9270752726647401), - FRAC_CONST(0.92764923309258118), - FRAC_CONST(0.92822101067216944), - FRAC_CONST(0.92879060405805702), - FRAC_CONST(0.9293580119099355), - FRAC_CONST(0.92992323289263956), - FRAC_CONST(0.93048626567614978), - FRAC_CONST(0.93104710893559517), - FRAC_CONST(0.93160576135125783), - FRAC_CONST(0.93216222160857432), - FRAC_CONST(0.93271648839814025), - FRAC_CONST(0.93326856041571205), - FRAC_CONST(0.93381843636221096), - FRAC_CONST(0.9343661149437259), - FRAC_CONST(0.93491159487151609), - FRAC_CONST(0.93545487486201462), - FRAC_CONST(0.9359959536368313), - FRAC_CONST(0.9365348299227555), - FRAC_CONST(0.93707150245175919), - FRAC_CONST(0.93760596996099999), - FRAC_CONST(0.93813823119282436), - FRAC_CONST(0.93866828489477017), - FRAC_CONST(0.9391961298195699), - FRAC_CONST(0.93972176472515334), - FRAC_CONST(0.94024518837465088), - FRAC_CONST(0.94076639953639607), - FRAC_CONST(0.94128539698392866), - FRAC_CONST(0.94180217949599765), - FRAC_CONST(0.94231674585656378), - FRAC_CONST(0.94282909485480271), - FRAC_CONST(0.94333922528510772), - FRAC_CONST(0.94384713594709269), - FRAC_CONST(0.94435282564559475), - FRAC_CONST(0.94485629319067721), - FRAC_CONST(0.94535753739763229), - FRAC_CONST(0.94585655708698391), - FRAC_CONST(0.94635335108449059), - FRAC_CONST(0.946847918221148), - FRAC_CONST(0.94734025733319194), - FRAC_CONST(0.94783036726210101), - FRAC_CONST(0.94831824685459909), - FRAC_CONST(0.94880389496265838), - FRAC_CONST(0.94928731044350201), - FRAC_CONST(0.94976849215960668), - FRAC_CONST(0.95024743897870523), - FRAC_CONST(0.95072414977378961), - FRAC_CONST(0.95119862342311323), - FRAC_CONST(0.95167085881019386), - FRAC_CONST(0.95214085482381583), - FRAC_CONST(0.95260861035803324), - FRAC_CONST(0.9530741243121722), - FRAC_CONST(0.95353739559083328), - FRAC_CONST(0.95399842310389449), - FRAC_CONST(0.95445720576651349), - FRAC_CONST(0.95491374249913052), - FRAC_CONST(0.95536803222747024), - FRAC_CONST(0.95582007388254542), - FRAC_CONST(0.95626986640065814), - FRAC_CONST(0.95671740872340305), - FRAC_CONST(0.9571626997976701), - FRAC_CONST(0.95760573857564624), - FRAC_CONST(0.9580465240148186), - FRAC_CONST(0.9584850550779761), - FRAC_CONST(0.95892133073321306), - FRAC_CONST(0.95935534995393079), - FRAC_CONST(0.9597871117188399), - FRAC_CONST(0.96021661501196343), - FRAC_CONST(0.96064385882263847), - FRAC_CONST(0.96106884214551935), - FRAC_CONST(0.961491563980579), - FRAC_CONST(0.9619120233331121), - FRAC_CONST(0.9623302192137374), - FRAC_CONST(0.96274615063839941), - FRAC_CONST(0.96315981662837136), - FRAC_CONST(0.96357121621025721), - FRAC_CONST(0.96398034841599411), - FRAC_CONST(0.96438721228285429), - FRAC_CONST(0.9647918068534479), - FRAC_CONST(0.96519413117572472), - FRAC_CONST(0.96559418430297683), - FRAC_CONST(0.96599196529384057), - FRAC_CONST(0.96638747321229879), - FRAC_CONST(0.96678070712768327), - FRAC_CONST(0.96717166611467664), - FRAC_CONST(0.96756034925331436), - FRAC_CONST(0.9679467556289878), - FRAC_CONST(0.9683308843324453), - FRAC_CONST(0.96871273445979478), - FRAC_CONST(0.9690923051125061), - FRAC_CONST(0.96946959539741295), - FRAC_CONST(0.96984460442671483), - FRAC_CONST(0.97021733131797916), - FRAC_CONST(0.97058777519414363), - FRAC_CONST(0.97095593518351797), - FRAC_CONST(0.97132181041978616), - FRAC_CONST(0.97168540004200854), - FRAC_CONST(0.9720467031946235), - FRAC_CONST(0.97240571902744977), - FRAC_CONST(0.97276244669568857), - FRAC_CONST(0.97311688535992513), - FRAC_CONST(0.97346903418613095), - FRAC_CONST(0.9738188923456661), - FRAC_CONST(0.97416645901528032), - FRAC_CONST(0.97451173337711572), - FRAC_CONST(0.97485471461870843), - FRAC_CONST(0.97519540193299037), - FRAC_CONST(0.97553379451829136), - FRAC_CONST(0.97586989157834103), - FRAC_CONST(0.97620369232227056), - FRAC_CONST(0.97653519596461447), - FRAC_CONST(0.97686440172531264), - FRAC_CONST(0.97719130882971228), - FRAC_CONST(0.97751591650856928), - FRAC_CONST(0.97783822399805043), - FRAC_CONST(0.97815823053973505), - FRAC_CONST(0.97847593538061683), - FRAC_CONST(0.97879133777310567), - FRAC_CONST(0.97910443697502925), - FRAC_CONST(0.97941523224963478), - FRAC_CONST(0.97972372286559117), - FRAC_CONST(0.98002990809698998), - FRAC_CONST(0.98033378722334796), - FRAC_CONST(0.98063535952960812), - FRAC_CONST(0.98093462430614164), - FRAC_CONST(0.98123158084874973), - FRAC_CONST(0.98152622845866466), - FRAC_CONST(0.9818185664425525), - FRAC_CONST(0.98210859411251361), - FRAC_CONST(0.98239631078608469), - FRAC_CONST(0.98268171578624086), - FRAC_CONST(0.98296480844139644), - FRAC_CONST(0.98324558808540707), - FRAC_CONST(0.98352405405757126), - FRAC_CONST(0.98380020570263149), - FRAC_CONST(0.98407404237077645), - FRAC_CONST(0.9843455634176419), - FRAC_CONST(0.9846147682043126), - FRAC_CONST(0.9848816560973237), - FRAC_CONST(0.98514622646866223), - FRAC_CONST(0.98540847869576842), - FRAC_CONST(0.98566841216153755), - FRAC_CONST(0.98592602625432113), - FRAC_CONST(0.98618132036792827), - FRAC_CONST(0.98643429390162707), - FRAC_CONST(0.98668494626014669), - FRAC_CONST(0.98693327685367771), - FRAC_CONST(0.98717928509787434), - FRAC_CONST(0.98742297041385541), - FRAC_CONST(0.98766433222820571), - FRAC_CONST(0.98790336997297779), - FRAC_CONST(0.98814008308569257), - FRAC_CONST(0.98837447100934128), - FRAC_CONST(0.98860653319238645), - FRAC_CONST(0.98883626908876354), - FRAC_CONST(0.98906367815788154), - FRAC_CONST(0.98928875986462517), - FRAC_CONST(0.98951151367935519), - FRAC_CONST(0.98973193907791057), - FRAC_CONST(0.98995003554160899), - FRAC_CONST(0.9901658025572484), - FRAC_CONST(0.99037923961710816), - FRAC_CONST(0.99059034621895015), - FRAC_CONST(0.99079912186602037), - FRAC_CONST(0.99100556606704937), - FRAC_CONST(0.99120967833625406), - FRAC_CONST(0.99141145819333854), - FRAC_CONST(0.99161090516349537), - FRAC_CONST(0.99180801877740643), - FRAC_CONST(0.99200279857124452), - FRAC_CONST(0.99219524408667392), - FRAC_CONST(0.99238535487085167), - FRAC_CONST(0.99257313047642881), - FRAC_CONST(0.99275857046155114), - FRAC_CONST(0.99294167438986047), - FRAC_CONST(0.99312244183049558), - FRAC_CONST(0.99330087235809328), - FRAC_CONST(0.99347696555278919), - FRAC_CONST(0.99365072100021912), - FRAC_CONST(0.99382213829151966), - FRAC_CONST(0.99399121702332938), - FRAC_CONST(0.99415795679778973), - FRAC_CONST(0.99432235722254581), - FRAC_CONST(0.9944844179107476), - FRAC_CONST(0.99464413848105071), - FRAC_CONST(0.99480151855761711), - FRAC_CONST(0.99495655777011638), - FRAC_CONST(0.99510925575372611), - FRAC_CONST(0.99525961214913339), - FRAC_CONST(0.9954076266025349), - FRAC_CONST(0.99555329876563847), - FRAC_CONST(0.99569662829566352), - FRAC_CONST(0.99583761485534161), - FRAC_CONST(0.99597625811291779), - FRAC_CONST(0.99611255774215113), - FRAC_CONST(0.99624651342231552), - FRAC_CONST(0.99637812483820021), - FRAC_CONST(0.99650739168011082), - FRAC_CONST(0.9966343136438699), - FRAC_CONST(0.996758890430818), - FRAC_CONST(0.99688112174781385), - FRAC_CONST(0.99700100730723529), - FRAC_CONST(0.99711854682697998), - FRAC_CONST(0.99723374003046616), - FRAC_CONST(0.99734658664663323), - FRAC_CONST(0.99745708640994191), - FRAC_CONST(0.99756523906037575), - FRAC_CONST(0.997671044343441), - FRAC_CONST(0.99777450201016782), - FRAC_CONST(0.99787561181711015), - FRAC_CONST(0.99797437352634699), - FRAC_CONST(0.99807078690548234), - FRAC_CONST(0.99816485172764624), - FRAC_CONST(0.99825656777149518), - FRAC_CONST(0.99834593482121237), - FRAC_CONST(0.99843295266650844), - FRAC_CONST(0.99851762110262221), - FRAC_CONST(0.99859993993032037), - FRAC_CONST(0.99867990895589909), - FRAC_CONST(0.99875752799118334), - FRAC_CONST(0.99883279685352799), - FRAC_CONST(0.99890571536581829), - FRAC_CONST(0.99897628335646982), - FRAC_CONST(0.99904450065942929), - FRAC_CONST(0.99911036711417489), - FRAC_CONST(0.99917388256571638), - FRAC_CONST(0.99923504686459585), - FRAC_CONST(0.99929385986688779), - FRAC_CONST(0.99935032143419944), - FRAC_CONST(0.9994044314336713), - FRAC_CONST(0.99945618973797734), - FRAC_CONST(0.99950559622532531), - FRAC_CONST(0.99955265077945699), - FRAC_CONST(0.99959735328964838), - FRAC_CONST(0.9996397036507102), - FRAC_CONST(0.99967970176298793), - FRAC_CONST(0.99971734753236219), - FRAC_CONST(0.99975264087024884), - FRAC_CONST(0.99978558169359921), - FRAC_CONST(0.99981616992490041), - FRAC_CONST(0.99984440549217524), - FRAC_CONST(0.99987028832898295), - FRAC_CONST(0.99989381837441849), - FRAC_CONST(0.99991499557311347), - FRAC_CONST(0.999933819875236), - FRAC_CONST(0.99995029123649048), - FRAC_CONST(0.99996440961811828), - FRAC_CONST(0.99997617498689761), - FRAC_CONST(0.9999855873151432), - FRAC_CONST(0.99999264658070719), - FRAC_CONST(0.99999735276697821), - FRAC_CONST(0.99999970586288223) -}; - -#ifdef ALLOW_SMALL_FRAMELENGTH -static const real_t sine_long_960[] MEM_ALIGN_ATTR = -{ - FRAC_CONST(0.00081812299560725323), - FRAC_CONST(0.0024543667964602917), - FRAC_CONST(0.0040906040262347889), - FRAC_CONST(0.0057268303042312674), - FRAC_CONST(0.0073630412497795667), - FRAC_CONST(0.0089992324822505774), - FRAC_CONST(0.010635399621067975), - FRAC_CONST(0.012271538285719924), - FRAC_CONST(0.013907644095770845), - FRAC_CONST(0.015543712670873098), - FRAC_CONST(0.017179739630778748), - FRAC_CONST(0.018815720595351273), - FRAC_CONST(0.020451651184577292), - FRAC_CONST(0.022087527018578291), - FRAC_CONST(0.023723343717622358), - FRAC_CONST(0.025359096902135895), - FRAC_CONST(0.02699478219271537), - FRAC_CONST(0.028630395210139003), - FRAC_CONST(0.030265931575378519), - FRAC_CONST(0.031901386909610863), - FRAC_CONST(0.033536756834229922), - FRAC_CONST(0.035172036970858266), - FRAC_CONST(0.036807222941358832), - FRAC_CONST(0.038442310367846677), - FRAC_CONST(0.040077294872700696), - FRAC_CONST(0.041712172078575326), - FRAC_CONST(0.043346937608412288), - FRAC_CONST(0.044981587085452281), - FRAC_CONST(0.046616116133246711), - FRAC_CONST(0.048250520375669431), - FRAC_CONST(0.049884795436928406), - FRAC_CONST(0.051518936941577477), - FRAC_CONST(0.053152940514528055), - FRAC_CONST(0.05478680178106083), - FRAC_CONST(0.056420516366837495), - FRAC_CONST(0.05805407989791244), - FRAC_CONST(0.059687488000744485), - FRAC_CONST(0.061320736302208578), - FRAC_CONST(0.062953820429607482), - FRAC_CONST(0.064586736010683557), - FRAC_CONST(0.066219478673630344), - FRAC_CONST(0.06785204404710439), - FRAC_CONST(0.069484427760236861), - FRAC_CONST(0.071116625442645326), - FRAC_CONST(0.072748632724445372), - FRAC_CONST(0.07438044523626236), - FRAC_CONST(0.076012058609243122), - FRAC_CONST(0.077643468475067631), - FRAC_CONST(0.079274670465960706), - FRAC_CONST(0.080905660214703745), - FRAC_CONST(0.082536433354646319), - FRAC_CONST(0.084166985519717977), - FRAC_CONST(0.085797312344439894), - FRAC_CONST(0.08742740946393647), - FRAC_CONST(0.089057272513947183), - FRAC_CONST(0.090686897130838162), - FRAC_CONST(0.092316278951613845), - FRAC_CONST(0.093945413613928788), - FRAC_CONST(0.095574296756099186), - FRAC_CONST(0.097202924017114667), - FRAC_CONST(0.098831291036649963), - FRAC_CONST(0.10045939345507648), - FRAC_CONST(0.10208722691347409), - FRAC_CONST(0.10371478705364276), - FRAC_CONST(0.10534206951811415), - FRAC_CONST(0.10696906995016341), - FRAC_CONST(0.10859578399382072), - FRAC_CONST(0.11022220729388306), - FRAC_CONST(0.11184833549592579), - FRAC_CONST(0.11347416424631435), - FRAC_CONST(0.11509968919221586), - FRAC_CONST(0.11672490598161089), - FRAC_CONST(0.11834981026330495), - FRAC_CONST(0.11997439768694031), - FRAC_CONST(0.12159866390300751), - FRAC_CONST(0.12322260456285709), - FRAC_CONST(0.12484621531871121), - FRAC_CONST(0.12646949182367517), - FRAC_CONST(0.12809242973174936), - FRAC_CONST(0.12971502469784052), - FRAC_CONST(0.13133727237777362), - FRAC_CONST(0.13295916842830346), - FRAC_CONST(0.13458070850712617), - FRAC_CONST(0.13620188827289101), - FRAC_CONST(0.1378227033852118), - FRAC_CONST(0.13944314950467873), - FRAC_CONST(0.14106322229286994), - FRAC_CONST(0.14268291741236291), - FRAC_CONST(0.14430223052674654), - FRAC_CONST(0.1459211573006321), - FRAC_CONST(0.14753969339966552), - FRAC_CONST(0.14915783449053857), - FRAC_CONST(0.15077557624100058), - FRAC_CONST(0.15239291431987001), - FRAC_CONST(0.1540098443970461), - FRAC_CONST(0.15562636214352044), - FRAC_CONST(0.15724246323138855), - FRAC_CONST(0.15885814333386142), - FRAC_CONST(0.16047339812527725), - FRAC_CONST(0.16208822328111283), - FRAC_CONST(0.16370261447799525), - FRAC_CONST(0.16531656739371339), - FRAC_CONST(0.16693007770722967), - FRAC_CONST(0.16854314109869134), - FRAC_CONST(0.17015575324944232), - FRAC_CONST(0.17176790984203447), - FRAC_CONST(0.17337960656023954), - FRAC_CONST(0.1749908390890603), - FRAC_CONST(0.17660160311474243), - FRAC_CONST(0.17821189432478593), - FRAC_CONST(0.17982170840795647), - FRAC_CONST(0.18143104105429744), - FRAC_CONST(0.18303988795514095), - FRAC_CONST(0.1846482448031197), - FRAC_CONST(0.18625610729217834), - FRAC_CONST(0.1878634711175852), - FRAC_CONST(0.18947033197594348), - FRAC_CONST(0.19107668556520319), - FRAC_CONST(0.19268252758467228), - FRAC_CONST(0.19428785373502844), - FRAC_CONST(0.19589265971833042), - FRAC_CONST(0.19749694123802966), - FRAC_CONST(0.19910069399898173), - FRAC_CONST(0.20070391370745785), - FRAC_CONST(0.20230659607115639), - FRAC_CONST(0.20390873679921437), - FRAC_CONST(0.20551033160221882), - FRAC_CONST(0.20711137619221856), - FRAC_CONST(0.2087118662827353), - FRAC_CONST(0.21031179758877552), - FRAC_CONST(0.21191116582684155), - FRAC_CONST(0.21350996671494335), - FRAC_CONST(0.21510819597260972), - FRAC_CONST(0.21670584932089998), - FRAC_CONST(0.2183029224824154), - FRAC_CONST(0.21989941118131037), - FRAC_CONST(0.22149531114330431), - FRAC_CONST(0.22309061809569264), - FRAC_CONST(0.22468532776735861), - FRAC_CONST(0.22627943588878449), - FRAC_CONST(0.22787293819206314), - FRAC_CONST(0.22946583041090929), - FRAC_CONST(0.23105810828067114), - FRAC_CONST(0.23264976753834157), - FRAC_CONST(0.23424080392256985), - FRAC_CONST(0.2358312131736727), - FRAC_CONST(0.23742099103364595), - FRAC_CONST(0.23901013324617584), - FRAC_CONST(0.24059863555665045), - FRAC_CONST(0.24218649371217096), - FRAC_CONST(0.24377370346156332), - FRAC_CONST(0.24536026055538934), - FRAC_CONST(0.24694616074595824), - FRAC_CONST(0.24853139978733788), - FRAC_CONST(0.25011597343536629), - FRAC_CONST(0.25169987744766298), - FRAC_CONST(0.25328310758364025), - FRAC_CONST(0.25486565960451457), - FRAC_CONST(0.25644752927331788), - FRAC_CONST(0.25802871235490898), - FRAC_CONST(0.25960920461598508), - FRAC_CONST(0.26118900182509258), - FRAC_CONST(0.26276809975263904), - FRAC_CONST(0.264346494170904), - FRAC_CONST(0.26592418085405067), - FRAC_CONST(0.26750115557813692), - FRAC_CONST(0.2690774141211269), - FRAC_CONST(0.27065295226290209), - FRAC_CONST(0.2722277657852728), - FRAC_CONST(0.27380185047198918), - FRAC_CONST(0.27537520210875299), - FRAC_CONST(0.2769478164832283), - FRAC_CONST(0.27851968938505312), - FRAC_CONST(0.28009081660585067), - FRAC_CONST(0.28166119393924061), - FRAC_CONST(0.28323081718085019), - FRAC_CONST(0.28479968212832563), - FRAC_CONST(0.28636778458134327), - FRAC_CONST(0.28793512034162105), - FRAC_CONST(0.2895016852129294), - FRAC_CONST(0.29106747500110264), - FRAC_CONST(0.29263248551405047), - FRAC_CONST(0.2941967125617686), - FRAC_CONST(0.29576015195635058), - FRAC_CONST(0.29732279951199847), - FRAC_CONST(0.29888465104503475), - FRAC_CONST(0.30044570237391266), - FRAC_CONST(0.30200594931922808), - FRAC_CONST(0.30356538770373032), - FRAC_CONST(0.30512401335233358), - FRAC_CONST(0.30668182209212791), - FRAC_CONST(0.3082388097523906), - FRAC_CONST(0.30979497216459695), - FRAC_CONST(0.31135030516243201), - FRAC_CONST(0.3129048045818012), - FRAC_CONST(0.31445846626084178), - FRAC_CONST(0.31601128603993378), - FRAC_CONST(0.31756325976171151), - FRAC_CONST(0.31911438327107416), - FRAC_CONST(0.32066465241519732), - FRAC_CONST(0.32221406304354389), - FRAC_CONST(0.3237626110078754), - FRAC_CONST(0.32531029216226293), - FRAC_CONST(0.32685710236309828), - FRAC_CONST(0.32840303746910487), - FRAC_CONST(0.32994809334134939), - FRAC_CONST(0.3314922658432522), - FRAC_CONST(0.33303555084059877), - FRAC_CONST(0.33457794420155085), - FRAC_CONST(0.33611944179665709), - FRAC_CONST(0.33766003949886464), - FRAC_CONST(0.33919973318352969), - FRAC_CONST(0.34073851872842903), - FRAC_CONST(0.34227639201377064), - FRAC_CONST(0.34381334892220483), - FRAC_CONST(0.34534938533883547), - FRAC_CONST(0.34688449715123082), - FRAC_CONST(0.34841868024943456), - FRAC_CONST(0.34995193052597684), - FRAC_CONST(0.35148424387588523), - FRAC_CONST(0.3530156161966958), - FRAC_CONST(0.35454604338846402), - FRAC_CONST(0.35607552135377557), - FRAC_CONST(0.35760404599775775), - FRAC_CONST(0.35913161322809023), - FRAC_CONST(0.36065821895501554), - FRAC_CONST(0.36218385909135092), - FRAC_CONST(0.36370852955249849), - FRAC_CONST(0.36523222625645668), - FRAC_CONST(0.36675494512383078), - FRAC_CONST(0.36827668207784414), - FRAC_CONST(0.36979743304434909), - FRAC_CONST(0.37131719395183754), - FRAC_CONST(0.37283596073145214), - FRAC_CONST(0.37435372931699717), - FRAC_CONST(0.37587049564494951), - FRAC_CONST(0.37738625565446909), - FRAC_CONST(0.37890100528741022), - FRAC_CONST(0.38041474048833229), - FRAC_CONST(0.38192745720451066), - FRAC_CONST(0.38343915138594736), - FRAC_CONST(0.38494981898538222), - FRAC_CONST(0.38645945595830333), - FRAC_CONST(0.38796805826295838), - FRAC_CONST(0.38947562186036483), - FRAC_CONST(0.39098214271432141), - FRAC_CONST(0.39248761679141814), - FRAC_CONST(0.3939920400610481), - FRAC_CONST(0.39549540849541737), - FRAC_CONST(0.39699771806955625), - FRAC_CONST(0.39849896476132979), - FRAC_CONST(0.39999914455144892), - FRAC_CONST(0.40149825342348083), - FRAC_CONST(0.4029962873638599), - FRAC_CONST(0.40449324236189854), - FRAC_CONST(0.40598911440979762), - FRAC_CONST(0.40748389950265762), - FRAC_CONST(0.40897759363848879), - FRAC_CONST(0.41047019281822261), - FRAC_CONST(0.41196169304572178), - FRAC_CONST(0.4134520903277914), - FRAC_CONST(0.41494138067418929), - FRAC_CONST(0.41642956009763715), - FRAC_CONST(0.41791662461383078), - FRAC_CONST(0.41940257024145089), - FRAC_CONST(0.42088739300217382), - FRAC_CONST(0.42237108892068231), - FRAC_CONST(0.42385365402467584), - FRAC_CONST(0.42533508434488143), - FRAC_CONST(0.42681537591506419), - FRAC_CONST(0.42829452477203828), - FRAC_CONST(0.42977252695567697), - FRAC_CONST(0.43124937850892364), - FRAC_CONST(0.4327250754778022), - FRAC_CONST(0.43419961391142781), - FRAC_CONST(0.43567298986201736), - FRAC_CONST(0.43714519938489987), - FRAC_CONST(0.43861623853852766), - FRAC_CONST(0.44008610338448595), - FRAC_CONST(0.44155478998750436), - FRAC_CONST(0.44302229441546676), - FRAC_CONST(0.4444886127394222), - FRAC_CONST(0.44595374103359531), - FRAC_CONST(0.44741767537539667), - FRAC_CONST(0.44888041184543348), - FRAC_CONST(0.45034194652752002), - FRAC_CONST(0.45180227550868812), - FRAC_CONST(0.45326139487919759), - FRAC_CONST(0.45471930073254679), - FRAC_CONST(0.45617598916548296), - FRAC_CONST(0.45763145627801283), - FRAC_CONST(0.45908569817341294), - FRAC_CONST(0.46053871095824001), - FRAC_CONST(0.46199049074234161), - FRAC_CONST(0.46344103363886635), - FRAC_CONST(0.46489033576427435), - FRAC_CONST(0.46633839323834758), - FRAC_CONST(0.46778520218420055), - FRAC_CONST(0.46923075872829029), - FRAC_CONST(0.47067505900042683), - FRAC_CONST(0.47211809913378361), - FRAC_CONST(0.47355987526490806), - FRAC_CONST(0.47500038353373153), - FRAC_CONST(0.47643962008357982), - FRAC_CONST(0.47787758106118372), - FRAC_CONST(0.47931426261668875), - FRAC_CONST(0.48074966090366611), - FRAC_CONST(0.48218377207912272), - FRAC_CONST(0.48361659230351117), - FRAC_CONST(0.48504811774074069), - FRAC_CONST(0.48647834455818684), - FRAC_CONST(0.48790726892670194), - FRAC_CONST(0.48933488702062544), - FRAC_CONST(0.49076119501779414), - FRAC_CONST(0.49218618909955225), - FRAC_CONST(0.4936098654507618), - FRAC_CONST(0.49503222025981269), - FRAC_CONST(0.49645324971863303), - FRAC_CONST(0.49787295002269943), - FRAC_CONST(0.49929131737104687), - FRAC_CONST(0.50070834796627917), - FRAC_CONST(0.50212403801457872), - FRAC_CONST(0.50353838372571758), - FRAC_CONST(0.50495138131306638), - FRAC_CONST(0.50636302699360547), - FRAC_CONST(0.50777331698793449), - FRAC_CONST(0.50918224752028263), - FRAC_CONST(0.51058981481851906), - FRAC_CONST(0.51199601511416237), - FRAC_CONST(0.51340084464239111), - FRAC_CONST(0.51480429964205421), - FRAC_CONST(0.51620637635567967), - FRAC_CONST(0.51760707102948678), - FRAC_CONST(0.51900637991339404), - FRAC_CONST(0.5204042992610306), - FRAC_CONST(0.52180082532974559), - FRAC_CONST(0.5231959543806185), - FRAC_CONST(0.52458968267846895), - FRAC_CONST(0.52598200649186677), - FRAC_CONST(0.52737292209314235), - FRAC_CONST(0.52876242575839572), - FRAC_CONST(0.53015051376750777), - FRAC_CONST(0.53153718240414882), - FRAC_CONST(0.53292242795578992), - FRAC_CONST(0.53430624671371152), - FRAC_CONST(0.53568863497301467), - FRAC_CONST(0.5370695890326298), - FRAC_CONST(0.5384491051953274), - FRAC_CONST(0.53982717976772743), - FRAC_CONST(0.54120380906030963), - FRAC_CONST(0.54257898938742311), - FRAC_CONST(0.54395271706729609), - FRAC_CONST(0.54532498842204646), - FRAC_CONST(0.54669579977769045), - FRAC_CONST(0.54806514746415402), - FRAC_CONST(0.54943302781528081), - FRAC_CONST(0.55079943716884383), - FRAC_CONST(0.55216437186655387), - FRAC_CONST(0.55352782825406999), - FRAC_CONST(0.55488980268100907), - FRAC_CONST(0.55625029150095584), - FRAC_CONST(0.55760929107147217), - FRAC_CONST(0.55896679775410718), - FRAC_CONST(0.56032280791440714), - FRAC_CONST(0.56167731792192455), - FRAC_CONST(0.56303032415022869), - FRAC_CONST(0.56438182297691453), - FRAC_CONST(0.56573181078361312), - FRAC_CONST(0.56708028395600085), - FRAC_CONST(0.56842723888380908), - FRAC_CONST(0.56977267196083425), - FRAC_CONST(0.57111657958494688), - FRAC_CONST(0.5724589581581021), - FRAC_CONST(0.57379980408634845), - FRAC_CONST(0.57513911377983773), - FRAC_CONST(0.57647688365283478), - FRAC_CONST(0.57781311012372738), - FRAC_CONST(0.57914778961503466), - FRAC_CONST(0.58048091855341843), - FRAC_CONST(0.5818124933696911), - FRAC_CONST(0.58314251049882604), - FRAC_CONST(0.58447096637996743), - FRAC_CONST(0.58579785745643886), - FRAC_CONST(0.5871231801757536), - FRAC_CONST(0.58844693098962408), - FRAC_CONST(0.58976910635397084), - FRAC_CONST(0.59108970272893235), - FRAC_CONST(0.59240871657887517), - FRAC_CONST(0.59372614437240179), - FRAC_CONST(0.59504198258236196), - FRAC_CONST(0.5963562276858605), - FRAC_CONST(0.59766887616426767), - FRAC_CONST(0.5989799245032289), - FRAC_CONST(0.60028936919267273), - FRAC_CONST(0.60159720672682204), - FRAC_CONST(0.60290343360420195), - FRAC_CONST(0.60420804632765002), - FRAC_CONST(0.60551104140432543), - FRAC_CONST(0.60681241534571839), - FRAC_CONST(0.60811216466765883), - FRAC_CONST(0.60941028589032709), - FRAC_CONST(0.61070677553826169), - FRAC_CONST(0.61200163014036979), - FRAC_CONST(0.61329484622993602), - FRAC_CONST(0.6145864203446314), - FRAC_CONST(0.61587634902652377), - FRAC_CONST(0.61716462882208556), - FRAC_CONST(0.61845125628220421), - FRAC_CONST(0.61973622796219074), - FRAC_CONST(0.6210195404217892), - FRAC_CONST(0.62230119022518593), - FRAC_CONST(0.62358117394101897), - FRAC_CONST(0.62485948814238634), - FRAC_CONST(0.62613612940685637), - FRAC_CONST(0.62741109431647646), - FRAC_CONST(0.62868437945778133), - FRAC_CONST(0.62995598142180387), - FRAC_CONST(0.6312258968040827), - FRAC_CONST(0.63249412220467238), - FRAC_CONST(0.63376065422815175), - FRAC_CONST(0.63502548948363347), - FRAC_CONST(0.63628862458477287), - FRAC_CONST(0.63755005614977711), - FRAC_CONST(0.63880978080141437), - FRAC_CONST(0.6400677951670225), - FRAC_CONST(0.6413240958785188), - FRAC_CONST(0.64257867957240766), - FRAC_CONST(0.6438315428897915), - FRAC_CONST(0.64508268247637779), - FRAC_CONST(0.64633209498248945), - FRAC_CONST(0.64757977706307335), - FRAC_CONST(0.64882572537770888), - FRAC_CONST(0.65006993659061751), - FRAC_CONST(0.65131240737067142), - FRAC_CONST(0.65255313439140239), - FRAC_CONST(0.65379211433101081), - FRAC_CONST(0.65502934387237444), - FRAC_CONST(0.6562648197030575), - FRAC_CONST(0.65749853851531959), - FRAC_CONST(0.65873049700612374), - FRAC_CONST(0.65996069187714679), - FRAC_CONST(0.66118911983478657), - FRAC_CONST(0.66241577759017178), - FRAC_CONST(0.66364066185917048), - FRAC_CONST(0.66486376936239888), - FRAC_CONST(0.66608509682523009), - FRAC_CONST(0.66730464097780284), - FRAC_CONST(0.66852239855503071), - FRAC_CONST(0.66973836629660977), - FRAC_CONST(0.67095254094702894), - FRAC_CONST(0.67216491925557675), - FRAC_CONST(0.67337549797635199), - FRAC_CONST(0.67458427386827102), - FRAC_CONST(0.67579124369507693), - FRAC_CONST(0.67699640422534846), - FRAC_CONST(0.67819975223250772), - FRAC_CONST(0.6794012844948305), - FRAC_CONST(0.68060099779545302), - FRAC_CONST(0.68179888892238183), - FRAC_CONST(0.6829949546685018), - FRAC_CONST(0.68418919183158522), - FRAC_CONST(0.68538159721429948), - FRAC_CONST(0.6865721676242168), - FRAC_CONST(0.68776089987382172), - FRAC_CONST(0.68894779078052026), - FRAC_CONST(0.69013283716664853), - FRAC_CONST(0.69131603585948032), - FRAC_CONST(0.69249738369123692), - FRAC_CONST(0.69367687749909468), - FRAC_CONST(0.69485451412519361), - FRAC_CONST(0.69603029041664599), - FRAC_CONST(0.6972042032255451), - FRAC_CONST(0.6983762494089728), - FRAC_CONST(0.69954642582900894), - FRAC_CONST(0.70071472935273893), - FRAC_CONST(0.70188115685226271), - FRAC_CONST(0.703045705204703), - FRAC_CONST(0.70420837129221303), - FRAC_CONST(0.70536915200198613), - FRAC_CONST(0.70652804422626281), - FRAC_CONST(0.70768504486233985), - FRAC_CONST(0.70884015081257845), - FRAC_CONST(0.70999335898441229), - FRAC_CONST(0.711144666290356), - FRAC_CONST(0.71229406964801356), - FRAC_CONST(0.71344156598008623), - FRAC_CONST(0.71458715221438096), - FRAC_CONST(0.71573082528381871), - FRAC_CONST(0.71687258212644234), - FRAC_CONST(0.7180124196854254), - FRAC_CONST(0.71915033490907943), - FRAC_CONST(0.72028632475086318), - FRAC_CONST(0.72142038616938997), - FRAC_CONST(0.72255251612843596), - FRAC_CONST(0.72368271159694852), - FRAC_CONST(0.72481096954905444), - FRAC_CONST(0.72593728696406756), - FRAC_CONST(0.72706166082649704), - FRAC_CONST(0.72818408812605595), - FRAC_CONST(0.72930456585766834), - FRAC_CONST(0.73042309102147851), - FRAC_CONST(0.73153966062285747), - FRAC_CONST(0.73265427167241282), - FRAC_CONST(0.73376692118599507), - FRAC_CONST(0.73487760618470677), - FRAC_CONST(0.73598632369490979), - FRAC_CONST(0.73709307074823405), - FRAC_CONST(0.73819784438158409), - FRAC_CONST(0.73930064163714881), - FRAC_CONST(0.74040145956240788), - FRAC_CONST(0.74150029521014049), - FRAC_CONST(0.74259714563843304), - FRAC_CONST(0.74369200791068657), - FRAC_CONST(0.74478487909562552), - FRAC_CONST(0.74587575626730485), - FRAC_CONST(0.74696463650511791), - FRAC_CONST(0.74805151689380456), - FRAC_CONST(0.74913639452345926), - FRAC_CONST(0.75021926648953785), - FRAC_CONST(0.75130012989286621), - FRAC_CONST(0.7523789818396478), - FRAC_CONST(0.75345581944147111), - FRAC_CONST(0.75453063981531809), - FRAC_CONST(0.75560344008357094), - FRAC_CONST(0.75667421737402052), - FRAC_CONST(0.7577429688198738), - FRAC_CONST(0.75880969155976163), - FRAC_CONST(0.75987438273774599), - FRAC_CONST(0.76093703950332836), - FRAC_CONST(0.76199765901145666), - FRAC_CONST(0.76305623842253345), - FRAC_CONST(0.76411277490242291), - FRAC_CONST(0.76516726562245885), - FRAC_CONST(0.76621970775945258), - FRAC_CONST(0.76727009849569949), - FRAC_CONST(0.76831843501898767), - FRAC_CONST(0.76936471452260458), - FRAC_CONST(0.77040893420534517), - FRAC_CONST(0.77145109127151923), - FRAC_CONST(0.77249118293095853), - FRAC_CONST(0.77352920639902467), - FRAC_CONST(0.77456515889661659), - FRAC_CONST(0.77559903765017746), - FRAC_CONST(0.7766308398917029), - FRAC_CONST(0.77766056285874774), - FRAC_CONST(0.77868820379443371), - FRAC_CONST(0.77971375994745684), - FRAC_CONST(0.78073722857209438), - FRAC_CONST(0.7817586069282132), - FRAC_CONST(0.78277789228127592), - FRAC_CONST(0.78379508190234881), - FRAC_CONST(0.78481017306810918), - FRAC_CONST(0.78582316306085265), - FRAC_CONST(0.78683404916849986), - FRAC_CONST(0.78784282868460476), - FRAC_CONST(0.78884949890836087), - FRAC_CONST(0.78985405714460888), - FRAC_CONST(0.7908565007038445), - FRAC_CONST(0.79185682690222425), - FRAC_CONST(0.79285503306157412), - FRAC_CONST(0.79385111650939566), - FRAC_CONST(0.79484507457887377), - FRAC_CONST(0.79583690460888357), - FRAC_CONST(0.79682660394399751), - FRAC_CONST(0.79781416993449272), - FRAC_CONST(0.79879959993635785), - FRAC_CONST(0.7997828913113002), - FRAC_CONST(0.80076404142675273), - FRAC_CONST(0.80174304765588156), - FRAC_CONST(0.80271990737759213), - FRAC_CONST(0.80369461797653707), - FRAC_CONST(0.80466717684312306), - FRAC_CONST(0.80563758137351682), - FRAC_CONST(0.80660582896965372), - FRAC_CONST(0.80757191703924336), - FRAC_CONST(0.80853584299577752), - FRAC_CONST(0.80949760425853612), - FRAC_CONST(0.81045719825259477), - FRAC_CONST(0.81141462240883167), - FRAC_CONST(0.81236987416393436), - FRAC_CONST(0.81332295096040608), - FRAC_CONST(0.81427385024657373), - FRAC_CONST(0.81522256947659355), - FRAC_CONST(0.81616910611045879), - FRAC_CONST(0.817113457614006), - FRAC_CONST(0.81805562145892186), - FRAC_CONST(0.81899559512275044), - FRAC_CONST(0.81993337608889916), - FRAC_CONST(0.82086896184664637), - FRAC_CONST(0.8218023498911472), - FRAC_CONST(0.82273353772344116), - FRAC_CONST(0.82366252285045805), - FRAC_CONST(0.82458930278502529), - FRAC_CONST(0.82551387504587381), - FRAC_CONST(0.82643623715764558), - FRAC_CONST(0.82735638665089983), - FRAC_CONST(0.82827432106211907), - FRAC_CONST(0.82919003793371693), - FRAC_CONST(0.83010353481404364), - FRAC_CONST(0.83101480925739324), - FRAC_CONST(0.83192385882400965), - FRAC_CONST(0.83283068108009373), - FRAC_CONST(0.8337352735978093), - FRAC_CONST(0.83463763395529011), - FRAC_CONST(0.83553775973664579), - FRAC_CONST(0.83643564853196872), - FRAC_CONST(0.83733129793734051), - FRAC_CONST(0.83822470555483797), - FRAC_CONST(0.83911586899254031), - FRAC_CONST(0.84000478586453453), - FRAC_CONST(0.84089145379092289), - FRAC_CONST(0.84177587039782842), - FRAC_CONST(0.84265803331740163), - FRAC_CONST(0.84353794018782702), - FRAC_CONST(0.844415588653329), - FRAC_CONST(0.8452909763641786), - FRAC_CONST(0.84616410097669936), - FRAC_CONST(0.84703496015327406), - FRAC_CONST(0.84790355156235053), - FRAC_CONST(0.84876987287844818), - FRAC_CONST(0.8496339217821639), - FRAC_CONST(0.85049569596017938), - FRAC_CONST(0.85135519310526508), - FRAC_CONST(0.85221241091628896), - FRAC_CONST(0.85306734709822085), - FRAC_CONST(0.85391999936213903), - FRAC_CONST(0.85477036542523732), - FRAC_CONST(0.85561844301082923), - FRAC_CONST(0.85646422984835635), - FRAC_CONST(0.85730772367339259), - FRAC_CONST(0.85814892222765116), - FRAC_CONST(0.85898782325899026), - FRAC_CONST(0.85982442452141961), - FRAC_CONST(0.86065872377510555), - FRAC_CONST(0.86149071878637817), - FRAC_CONST(0.8623204073277364), - FRAC_CONST(0.86314778717785412), - FRAC_CONST(0.8639728561215867), - FRAC_CONST(0.86479561194997623), - FRAC_CONST(0.86561605246025763), - FRAC_CONST(0.86643417545586487), - FRAC_CONST(0.8672499787464365), - FRAC_CONST(0.86806346014782154), - FRAC_CONST(0.8688746174820855), - FRAC_CONST(0.86968344857751589), - FRAC_CONST(0.87048995126862883), - FRAC_CONST(0.87129412339617363), - FRAC_CONST(0.87209596280713941), - FRAC_CONST(0.8728954673547612), - FRAC_CONST(0.87369263489852422), - FRAC_CONST(0.87448746330417149), - FRAC_CONST(0.87527995044370765), - FRAC_CONST(0.8760700941954066), - FRAC_CONST(0.87685789244381551), - FRAC_CONST(0.87764334307976144), - FRAC_CONST(0.87842644400035663), - FRAC_CONST(0.8792071931090043), - FRAC_CONST(0.87998558831540408), - FRAC_CONST(0.88076162753555787), - FRAC_CONST(0.88153530869177488), - FRAC_CONST(0.88230662971267804), - FRAC_CONST(0.88307558853320878), - FRAC_CONST(0.88384218309463292), - FRAC_CONST(0.8846064113445461), - FRAC_CONST(0.88536827123687933), - FRAC_CONST(0.88612776073190425), - FRAC_CONST(0.88688487779623937), - FRAC_CONST(0.88763962040285393), - FRAC_CONST(0.8883919865310751), - FRAC_CONST(0.88914197416659235), - FRAC_CONST(0.88988958130146301), - FRAC_CONST(0.8906348059341177), - FRAC_CONST(0.89137764606936609), - FRAC_CONST(0.89211809971840139), - FRAC_CONST(0.89285616489880615), - FRAC_CONST(0.89359183963455813), - FRAC_CONST(0.89432512195603453), - FRAC_CONST(0.89505600990001799), - FRAC_CONST(0.89578450150970124), - FRAC_CONST(0.8965105948346932), - FRAC_CONST(0.89723428793102367), - FRAC_CONST(0.89795557886114807), - FRAC_CONST(0.89867446569395382), - FRAC_CONST(0.89939094650476448), - FRAC_CONST(0.90010501937534515), - FRAC_CONST(0.900816682393908), - FRAC_CONST(0.90152593365511691), - FRAC_CONST(0.90223277126009283), - FRAC_CONST(0.90293719331641886), - FRAC_CONST(0.90363919793814496), - FRAC_CONST(0.90433878324579353), - FRAC_CONST(0.90503594736636439), - FRAC_CONST(0.90573068843333915), - FRAC_CONST(0.90642300458668679), - FRAC_CONST(0.90711289397286898), - FRAC_CONST(0.90780035474484411), - FRAC_CONST(0.90848538506207266), - FRAC_CONST(0.90916798309052227), - FRAC_CONST(0.90984814700267291), - FRAC_CONST(0.9105258749775208), - FRAC_CONST(0.91120116520058425), - FRAC_CONST(0.91187401586390815), - FRAC_CONST(0.91254442516606893), - FRAC_CONST(0.9132123913121788), - FRAC_CONST(0.91387791251389161), - FRAC_CONST(0.91454098698940678), - FRAC_CONST(0.91520161296347435), - FRAC_CONST(0.91585978866739981), - FRAC_CONST(0.91651551233904871), - FRAC_CONST(0.91716878222285148), - FRAC_CONST(0.91781959656980805), - FRAC_CONST(0.91846795363749245), - FRAC_CONST(0.91911385169005766), - FRAC_CONST(0.9197572889982405), - FRAC_CONST(0.9203982638393654), - FRAC_CONST(0.92103677449734989), - FRAC_CONST(0.92167281926270861), - FRAC_CONST(0.92230639643255874), - FRAC_CONST(0.92293750431062316), - FRAC_CONST(0.92356614120723612), - FRAC_CONST(0.92419230543934783), - FRAC_CONST(0.92481599533052783), - FRAC_CONST(0.92543720921097061), - FRAC_CONST(0.92605594541749991), - FRAC_CONST(0.92667220229357261), - FRAC_CONST(0.92728597818928349), - FRAC_CONST(0.9278972714613698), - FRAC_CONST(0.92850608047321548), - FRAC_CONST(0.9291124035948557), - FRAC_CONST(0.92971623920298097), - FRAC_CONST(0.93031758568094147), - FRAC_CONST(0.93091644141875196), - FRAC_CONST(0.93151280481309506), - FRAC_CONST(0.93210667426732674), - FRAC_CONST(0.93269804819147983), - FRAC_CONST(0.93328692500226818), - FRAC_CONST(0.93387330312309147), - FRAC_CONST(0.93445718098403896), - FRAC_CONST(0.93503855702189376), - FRAC_CONST(0.9356174296801375), - FRAC_CONST(0.93619379740895381), - FRAC_CONST(0.93676765866523259), - FRAC_CONST(0.93733901191257496), - FRAC_CONST(0.93790785562129597), - FRAC_CONST(0.93847418826842988), - FRAC_CONST(0.93903800833773399), - FRAC_CONST(0.93959931431969212), - FRAC_CONST(0.94015810471151917), - FRAC_CONST(0.94071437801716529), - FRAC_CONST(0.94126813274731924), - FRAC_CONST(0.94181936741941319), - FRAC_CONST(0.94236808055762578), - FRAC_CONST(0.94291427069288691), - FRAC_CONST(0.94345793636288133), - FRAC_CONST(0.94399907611205225), - FRAC_CONST(0.9445376884916058), - FRAC_CONST(0.94507377205951448), - FRAC_CONST(0.94560732538052128), - FRAC_CONST(0.94613834702614352), - FRAC_CONST(0.94666683557467624), - FRAC_CONST(0.94719278961119657), - FRAC_CONST(0.94771620772756759), - FRAC_CONST(0.94823708852244104), - FRAC_CONST(0.94875543060126255), - FRAC_CONST(0.94927123257627433), - FRAC_CONST(0.94978449306651924), - FRAC_CONST(0.95029521069784428), - FRAC_CONST(0.9508033841029051), - FRAC_CONST(0.95130901192116835), - FRAC_CONST(0.9518120927989161), - FRAC_CONST(0.95231262538924943), - FRAC_CONST(0.95281060835209208), - FRAC_CONST(0.95330604035419386), - FRAC_CONST(0.95379892006913403), - FRAC_CONST(0.95428924617732525), - FRAC_CONST(0.95477701736601728), - FRAC_CONST(0.95526223232929941), - FRAC_CONST(0.95574488976810545), - FRAC_CONST(0.95622498839021619), - FRAC_CONST(0.95670252691026292), - FRAC_CONST(0.95717750404973156), - FRAC_CONST(0.95764991853696524), - FRAC_CONST(0.95811976910716812), - FRAC_CONST(0.95858705450240911), - FRAC_CONST(0.95905177347162429), - FRAC_CONST(0.95951392477062125), - FRAC_CONST(0.95997350716208196), - FRAC_CONST(0.96043051941556579), - FRAC_CONST(0.96088496030751369), - FRAC_CONST(0.96133682862125036), - FRAC_CONST(0.96178612314698864), - FRAC_CONST(0.96223284268183173), - FRAC_CONST(0.9626769860297768), - FRAC_CONST(0.96311855200171881), - FRAC_CONST(0.96355753941545252), - FRAC_CONST(0.96399394709567654), - FRAC_CONST(0.96442777387399625), - FRAC_CONST(0.96485901858892686), - FRAC_CONST(0.96528768008589627), - FRAC_CONST(0.96571375721724895), - FRAC_CONST(0.96613724884224783), - FRAC_CONST(0.96655815382707866), - FRAC_CONST(0.96697647104485207), - FRAC_CONST(0.96739219937560694), - FRAC_CONST(0.96780533770631338), - FRAC_CONST(0.96821588493087585), - FRAC_CONST(0.9686238399501359), - FRAC_CONST(0.96902920167187501), - FRAC_CONST(0.96943196901081796), - FRAC_CONST(0.96983214088863534), - FRAC_CONST(0.9702297162339466), - FRAC_CONST(0.97062469398232287), - FRAC_CONST(0.97101707307629004), - FRAC_CONST(0.97140685246533098), - FRAC_CONST(0.97179403110588902), - FRAC_CONST(0.97217860796137046), - FRAC_CONST(0.97256058200214734), - FRAC_CONST(0.97293995220556007), - FRAC_CONST(0.97331671755592064), - FRAC_CONST(0.97369087704451474), - FRAC_CONST(0.97406242966960455), - FRAC_CONST(0.97443137443643235), - FRAC_CONST(0.97479771035722163), - FRAC_CONST(0.97516143645118103), - FRAC_CONST(0.97552255174450631), - FRAC_CONST(0.97588105527038305), - FRAC_CONST(0.97623694606898959), - FRAC_CONST(0.97659022318749911), - FRAC_CONST(0.97694088568008242), - FRAC_CONST(0.97728893260791039), - FRAC_CONST(0.97763436303915685), - FRAC_CONST(0.97797717604900047), - FRAC_CONST(0.97831737071962765), - FRAC_CONST(0.97865494614023485), - FRAC_CONST(0.97898990140703124), - FRAC_CONST(0.97932223562324061), - FRAC_CONST(0.97965194789910426), - FRAC_CONST(0.9799790373518833), - FRAC_CONST(0.98030350310586067), - FRAC_CONST(0.98062534429234405), - FRAC_CONST(0.98094456004966768), - FRAC_CONST(0.98126114952319499), - FRAC_CONST(0.98157511186532054), - FRAC_CONST(0.98188644623547261), - FRAC_CONST(0.98219515180011563), - FRAC_CONST(0.98250122773275184), - FRAC_CONST(0.98280467321392362), - FRAC_CONST(0.98310548743121629), - FRAC_CONST(0.98340366957925973), - FRAC_CONST(0.98369921885973044), - FRAC_CONST(0.98399213448135414), - FRAC_CONST(0.98428241565990748), - FRAC_CONST(0.98457006161822058), - FRAC_CONST(0.98485507158617835), - FRAC_CONST(0.98513744480072363), - FRAC_CONST(0.98541718050585803), - FRAC_CONST(0.98569427795264519), - FRAC_CONST(0.98596873639921168), - FRAC_CONST(0.98624055511074971), - FRAC_CONST(0.98650973335951875), - FRAC_CONST(0.98677627042484772), - FRAC_CONST(0.98704016559313645), - FRAC_CONST(0.98730141815785832), - FRAC_CONST(0.98756002741956173), - FRAC_CONST(0.9878159926858715), - FRAC_CONST(0.98806931327149194), - FRAC_CONST(0.98831998849820735), - FRAC_CONST(0.98856801769488489), - FRAC_CONST(0.98881340019747566), - FRAC_CONST(0.98905613534901682), - FRAC_CONST(0.98929622249963345), - FRAC_CONST(0.98953366100653983), - FRAC_CONST(0.98976845023404181), - FRAC_CONST(0.99000058955353776), - FRAC_CONST(0.99023007834352106), - FRAC_CONST(0.99045691598958097), - FRAC_CONST(0.99068110188440506), - FRAC_CONST(0.99090263542778001), - FRAC_CONST(0.99112151602659404), - FRAC_CONST(0.99133774309483769), - FRAC_CONST(0.99155131605360625), - FRAC_CONST(0.99176223433110056), - FRAC_CONST(0.99197049736262888), - FRAC_CONST(0.99217610459060845), - FRAC_CONST(0.99237905546456673), - FRAC_CONST(0.99257934944114334), - FRAC_CONST(0.99277698598409092), - FRAC_CONST(0.99297196456427694), - FRAC_CONST(0.99316428465968509), - FRAC_CONST(0.99335394575541669), - FRAC_CONST(0.99354094734369169), - FRAC_CONST(0.99372528892385081), - FRAC_CONST(0.99390697000235606), - FRAC_CONST(0.99408599009279242), - FRAC_CONST(0.99426234871586938), - FRAC_CONST(0.99443604539942176), - FRAC_CONST(0.99460707967841133), - FRAC_CONST(0.99477545109492771), - FRAC_CONST(0.99494115919819004), - FRAC_CONST(0.99510420354454787), - FRAC_CONST(0.99526458369748239), - FRAC_CONST(0.99542229922760772), - FRAC_CONST(0.99557734971267187), - FRAC_CONST(0.9957297347375581), - FRAC_CONST(0.99587945389428578), - FRAC_CONST(0.99602650678201154), - FRAC_CONST(0.99617089300703077), - FRAC_CONST(0.996312612182778), - FRAC_CONST(0.99645166392982831), - FRAC_CONST(0.99658804787589839), - FRAC_CONST(0.99672176365584741), - FRAC_CONST(0.99685281091167788), - FRAC_CONST(0.99698118929253687), - FRAC_CONST(0.99710689845471678), - FRAC_CONST(0.99722993806165661), - FRAC_CONST(0.99735030778394196), - FRAC_CONST(0.99746800729930707), - FRAC_CONST(0.99758303629263489), - FRAC_CONST(0.99769539445595812), - FRAC_CONST(0.99780508148846014), - FRAC_CONST(0.99791209709647588), - FRAC_CONST(0.99801644099349218), - FRAC_CONST(0.99811811290014918), - FRAC_CONST(0.9982171125442405), - FRAC_CONST(0.9983134396607144), - FRAC_CONST(0.99840709399167404), - FRAC_CONST(0.99849807528637868), - FRAC_CONST(0.99858638330124405), - FRAC_CONST(0.99867201779984294), - FRAC_CONST(0.99875497855290607), - FRAC_CONST(0.99883526533832245), - FRAC_CONST(0.99891287794114036), - FRAC_CONST(0.99898781615356746), - FRAC_CONST(0.99906007977497147), - FRAC_CONST(0.99912966861188113), - FRAC_CONST(0.99919658247798593), - FRAC_CONST(0.99926082119413751), - FRAC_CONST(0.99932238458834954), - FRAC_CONST(0.999381272495798), - FRAC_CONST(0.99943748475882255), - FRAC_CONST(0.9994910212269259), - FRAC_CONST(0.99954188175677483), - FRAC_CONST(0.99959006621220048), - FRAC_CONST(0.99963557446419837), - FRAC_CONST(0.99967840639092931), - FRAC_CONST(0.99971856187771946), - FRAC_CONST(0.99975604081706027), - FRAC_CONST(0.99979084310860955), - FRAC_CONST(0.99982296865919107), - FRAC_CONST(0.99985241738279484), - FRAC_CONST(0.99987918920057806), - FRAC_CONST(0.99990328404086426), - FRAC_CONST(0.9999247018391445), - FRAC_CONST(0.99994344253807688), - FRAC_CONST(0.99995950608748674), - FRAC_CONST(0.99997289244436727), - FRAC_CONST(0.99998360157287902), - FRAC_CONST(0.9999916334443506), - FRAC_CONST(0.99999698803727821), - FRAC_CONST(0.99999966533732598) -}; -#endif - -static const real_t sine_short_128[] ICONST_ATTR MEM_ALIGN_ATTR = -{ - FRAC_CONST(0.0061358846491544753), - FRAC_CONST(0.01840672990580482), - FRAC_CONST(0.030674803176636626), - FRAC_CONST(0.04293825693494082), - FRAC_CONST(0.055195244349689934), - FRAC_CONST(0.067443919563664051), - FRAC_CONST(0.079682437971430126), - FRAC_CONST(0.091908956497132724), - FRAC_CONST(0.10412163387205459), - FRAC_CONST(0.11631863091190475), - FRAC_CONST(0.12849811079379317), - FRAC_CONST(0.14065823933284921), - FRAC_CONST(0.15279718525844344), - FRAC_CONST(0.16491312048996989), - FRAC_CONST(0.17700422041214875), - FRAC_CONST(0.18906866414980619), - FRAC_CONST(0.2011046348420919), - FRAC_CONST(0.21311031991609136), - FRAC_CONST(0.22508391135979283), - FRAC_CONST(0.2370236059943672), - FRAC_CONST(0.24892760574572015), - FRAC_CONST(0.26079411791527551), - FRAC_CONST(0.27262135544994898), - FRAC_CONST(0.28440753721127188), - FRAC_CONST(0.29615088824362379), - FRAC_CONST(0.30784964004153487), - FRAC_CONST(0.31950203081601569), - FRAC_CONST(0.33110630575987643), - FRAC_CONST(0.34266071731199438), - FRAC_CONST(0.35416352542049034), - FRAC_CONST(0.36561299780477385), - FRAC_CONST(0.37700741021641826), - FRAC_CONST(0.38834504669882625), - FRAC_CONST(0.39962419984564679), - FRAC_CONST(0.41084317105790391), - FRAC_CONST(0.42200027079979968), - FRAC_CONST(0.43309381885315196), - FRAC_CONST(0.4441221445704292), - FRAC_CONST(0.45508358712634384), - FRAC_CONST(0.46597649576796618), - FRAC_CONST(0.47679923006332209), - FRAC_CONST(0.487550160148436), - FRAC_CONST(0.49822766697278187), - FRAC_CONST(0.50883014254310699), - FRAC_CONST(0.51935599016558964), - FRAC_CONST(0.52980362468629461), - FRAC_CONST(0.54017147272989285), - FRAC_CONST(0.55045797293660481), - FRAC_CONST(0.56066157619733603), - FRAC_CONST(0.57078074588696726), - FRAC_CONST(0.58081395809576453), - FRAC_CONST(0.59075970185887416), - FRAC_CONST(0.60061647938386897), - FRAC_CONST(0.61038280627630948), - FRAC_CONST(0.6200572117632891), - FRAC_CONST(0.62963823891492698), - FRAC_CONST(0.63912444486377573), - FRAC_CONST(0.64851440102211244), - FRAC_CONST(0.65780669329707864), - FRAC_CONST(0.66699992230363747), - FRAC_CONST(0.67609270357531592), - FRAC_CONST(0.68508366777270036), - FRAC_CONST(0.693971460889654), - FRAC_CONST(0.7027547444572253), - FRAC_CONST(0.71143219574521643), - FRAC_CONST(0.72000250796138165), - FRAC_CONST(0.7284643904482252), - FRAC_CONST(0.73681656887736979), - FRAC_CONST(0.74505778544146595), - FRAC_CONST(0.75318679904361241), - FRAC_CONST(0.76120238548426178), - FRAC_CONST(0.76910333764557959), - FRAC_CONST(0.77688846567323244), - FRAC_CONST(0.78455659715557524), - FRAC_CONST(0.79210657730021239), - FRAC_CONST(0.79953726910790501), - FRAC_CONST(0.80684755354379922), - FRAC_CONST(0.8140363297059483), - FRAC_CONST(0.82110251499110465), - FRAC_CONST(0.8280450452577558), - FRAC_CONST(0.83486287498638001), - FRAC_CONST(0.84155497743689833), - FRAC_CONST(0.84812034480329712), - FRAC_CONST(0.85455798836540053), - FRAC_CONST(0.86086693863776731), - FRAC_CONST(0.86704624551569265), - FRAC_CONST(0.87309497841829009), - FRAC_CONST(0.87901222642863341), - FRAC_CONST(0.88479709843093779), - FRAC_CONST(0.89044872324475788), - FRAC_CONST(0.89596624975618511), - FRAC_CONST(0.90134884704602203), - FRAC_CONST(0.90659570451491533), - FRAC_CONST(0.91170603200542988), - FRAC_CONST(0.9166790599210427), - FRAC_CONST(0.9215140393420419), - FRAC_CONST(0.92621024213831127), - FRAC_CONST(0.93076696107898371), - FRAC_CONST(0.9351835099389475), - FRAC_CONST(0.93945922360218992), - FRAC_CONST(0.94359345816196039), - FRAC_CONST(0.94758559101774109), - FRAC_CONST(0.95143502096900834), - FRAC_CONST(0.95514116830577067), - FRAC_CONST(0.9587034748958716), - FRAC_CONST(0.96212140426904158), - FRAC_CONST(0.9653944416976894), - FRAC_CONST(0.96852209427441727), - FRAC_CONST(0.97150389098625178), - FRAC_CONST(0.97433938278557586), - FRAC_CONST(0.97702814265775439), - FRAC_CONST(0.97956976568544052), - FRAC_CONST(0.98196386910955524), - FRAC_CONST(0.98421009238692903), - FRAC_CONST(0.98630809724459867), - FRAC_CONST(0.98825756773074946), - FRAC_CONST(0.99005821026229712), - FRAC_CONST(0.99170975366909953), - FRAC_CONST(0.9932119492347945), - FRAC_CONST(0.99456457073425542), - FRAC_CONST(0.99576741446765982), - FRAC_CONST(0.99682029929116567), - FRAC_CONST(0.99772306664419164), - FRAC_CONST(0.99847558057329477), - FRAC_CONST(0.99907772775264536), - FRAC_CONST(0.99952941750109314), - FRAC_CONST(0.9998305817958234), - FRAC_CONST(0.99998117528260111) -}; - -#ifdef ALLOW_SMALL_FRAMELENGTH -static const real_t sine_short_120[] MEM_ALIGN_ATTR = -{ - FRAC_CONST(0.0065449379673518581), - FRAC_CONST(0.019633692460628301), - FRAC_CONST(0.032719082821776137), - FRAC_CONST(0.045798866936520771), - FRAC_CONST(0.058870803651189033), - FRAC_CONST(0.071932653156719387), - FRAC_CONST(0.084982177372441667), - FRAC_CONST(0.09801714032956059), - FRAC_CONST(0.11103530855427769), - FRAC_CONST(0.12403445145048532), - FRAC_CONST(0.13701234168196802), - FRAC_CONST(0.14996675555404498), - FRAC_CONST(0.16289547339458874), - FRAC_CONST(0.17579627993435451), - FRAC_CONST(0.18866696468655525), - FRAC_CONST(0.2015053223256171), - FRAC_CONST(0.21430915306505074), - FRAC_CONST(0.2270762630343732), - FRAC_CONST(0.23980446465501654), - FRAC_CONST(0.25249157701515795), - FRAC_CONST(0.26513542624340797), - FRAC_CONST(0.27773384588129219), - FRAC_CONST(0.29028467725446233), - FRAC_CONST(0.3027857698425746), - FRAC_CONST(0.31523498164776964), - FRAC_CONST(0.32763017956169349), - FRAC_CONST(0.33996923973099424), - FRAC_CONST(0.35225004792123354), - FRAC_CONST(0.36447049987914965), - FRAC_CONST(0.37662850169321077), - FRAC_CONST(0.38872197015239557), - FRAC_CONST(0.40074883310314097), - FRAC_CONST(0.41270702980439467), - FRAC_CONST(0.42459451128071307), - FRAC_CONST(0.43640924067334208), - FRAC_CONST(0.44814919358922256), - FRAC_CONST(0.45981235844785984), - FRAC_CONST(0.47139673682599764), - FRAC_CONST(0.48290034380003727), - FRAC_CONST(0.49432120828614462), - FRAC_CONST(0.50565737337798455), - FRAC_CONST(0.51690689668202761), - FRAC_CONST(0.52806785065036799), - FRAC_CONST(0.53913832291100017), - FRAC_CONST(0.55011641659549337), - FRAC_CONST(0.56100025066400983), - FRAC_CONST(0.57178796022761225), - FRAC_CONST(0.58247769686780215), - FRAC_CONST(0.59306762895323706), - FRAC_CONST(0.60355594195357143), - FRAC_CONST(0.61394083875036642), - FRAC_CONST(0.62422053994501758), - FRAC_CONST(0.63439328416364549), - FRAC_CONST(0.64445732835889735), - FRAC_CONST(0.65441094810861034), - FRAC_CONST(0.66425243791128175), - FRAC_CONST(0.67398011147829784), - FRAC_CONST(0.68359230202287125), - FRAC_CONST(0.69308736254563585), - FRAC_CONST(0.70246366611685174), - FRAC_CONST(0.71171960615517138), - FRAC_CONST(0.72085359670291882), - FRAC_CONST(0.7298640726978356), - FRAC_CONST(0.73874949024124625), - FRAC_CONST(0.74750832686259672), - FRAC_CONST(0.75613908178032285), - FRAC_CONST(0.76464027615900032), - FRAC_CONST(0.77301045336273699), - FRAC_CONST(0.78124817920475853), - FRAC_CONST(0.78935204219315003), - FRAC_CONST(0.79732065377270711), - FRAC_CONST(0.80515264856285829), - FRAC_CONST(0.81284668459161513), - FRAC_CONST(0.82040144352551359), - FRAC_CONST(0.82781563089550203), - FRAC_CONST(0.83508797631874299), - FRAC_CONST(0.84221723371628654), - FRAC_CONST(0.84920218152657889), - FRAC_CONST(0.85604162291477137), - FRAC_CONST(0.86273438597779184), - FRAC_CONST(0.86927932394514362), - FRAC_CONST(0.87567531537539967), - FRAC_CONST(0.88192126434835494), - FRAC_CONST(0.88801610065280734), - FRAC_CONST(0.89395877996993212), - FRAC_CONST(0.8997482840522214), - FRAC_CONST(0.90538362089795521), - FRAC_CONST(0.91086382492117568), - FRAC_CONST(0.91618795711713596), - FRAC_CONST(0.92135510522319242), - FRAC_CONST(0.9263643838751181), - FRAC_CONST(0.93121493475880346), - FRAC_CONST(0.93590592675732565), - FRAC_CONST(0.94043655609335486), - FRAC_CONST(0.94480604646687805), - FRAC_CONST(0.94901364918821385), - FRAC_CONST(0.95305864330629697), - FRAC_CONST(0.95694033573220882), - FRAC_CONST(0.9606580613579353), - FRAC_CONST(0.96421118317032928), - FRAC_CONST(0.96759909236025976), - FRAC_CONST(0.9708212084269281), - FRAC_CONST(0.97387697927733363), - FRAC_CONST(0.97676588132087239), - FRAC_CONST(0.97948741955905139), - FRAC_CONST(0.98204112767030394), - FRAC_CONST(0.98442656808989171), - FRAC_CONST(0.98664333208487898), - FRAC_CONST(0.98869103982416728), - FRAC_CONST(0.99056934044357725), - FRAC_CONST(0.99227791210596705), - FRAC_CONST(0.99381646205637808), - FRAC_CONST(0.99518472667219682), - FRAC_CONST(0.99638247150832537), - FRAC_CONST(0.99740949133735191), - FRAC_CONST(0.99826561018471593), - FRAC_CONST(0.99895068135886012), - FRAC_CONST(0.99946458747636568), - FRAC_CONST(0.99980724048206482), - FRAC_CONST(0.99997858166412923) -}; -#endif - -#ifdef LD_DEC -static const real_t sine_mid_512[] MEM_ALIGN_ATTR = -{ - FRAC_CONST(0.0015339801862847655), - FRAC_CONST(0.0046019261204485705), - FRAC_CONST(0.007669828739531097), - FRAC_CONST(0.010737659167264491), - FRAC_CONST(0.013805388528060391), - FRAC_CONST(0.01687298794728171), - FRAC_CONST(0.019940428551514441), - FRAC_CONST(0.023007681468839369), - FRAC_CONST(0.026074717829103901), - FRAC_CONST(0.029141508764193722), - FRAC_CONST(0.032208025408304586), - FRAC_CONST(0.035274238898213947), - FRAC_CONST(0.038340120373552694), - FRAC_CONST(0.041405640977076739), - FRAC_CONST(0.044470771854938668), - FRAC_CONST(0.047535484156959303), - FRAC_CONST(0.050599749036899282), - FRAC_CONST(0.05366353765273052), - FRAC_CONST(0.056726821166907748), - FRAC_CONST(0.059789570746639868), - FRAC_CONST(0.062851757564161406), - FRAC_CONST(0.065913352797003805), - FRAC_CONST(0.068974327628266746), - FRAC_CONST(0.072034653246889332), - FRAC_CONST(0.075094300847921305), - FRAC_CONST(0.078153241632794232), - FRAC_CONST(0.081211446809592441), - FRAC_CONST(0.084268887593324071), - FRAC_CONST(0.087325535206192059), - FRAC_CONST(0.090381360877864983), - FRAC_CONST(0.093436335845747787), - FRAC_CONST(0.096490431355252593), - FRAC_CONST(0.099543618660069319), - FRAC_CONST(0.10259586902243628), - FRAC_CONST(0.10564715371341062), - FRAC_CONST(0.10869744401313872), - FRAC_CONST(0.11174671121112659), - FRAC_CONST(0.11479492660651008), - FRAC_CONST(0.11784206150832498), - FRAC_CONST(0.12088808723577708), - FRAC_CONST(0.12393297511851216), - FRAC_CONST(0.12697669649688587), - FRAC_CONST(0.13001922272223335), - FRAC_CONST(0.13306052515713906), - FRAC_CONST(0.1361005751757062), - FRAC_CONST(0.1391393441638262), - FRAC_CONST(0.14217680351944803), - FRAC_CONST(0.14521292465284746), - FRAC_CONST(0.14824767898689603), - FRAC_CONST(0.15128103795733022), - FRAC_CONST(0.1543129730130201), - FRAC_CONST(0.15734345561623825), - FRAC_CONST(0.16037245724292828), - FRAC_CONST(0.16339994938297323), - FRAC_CONST(0.1664259035404641), - FRAC_CONST(0.16945029123396796), - FRAC_CONST(0.17247308399679595), - FRAC_CONST(0.17549425337727143), - FRAC_CONST(0.17851377093899751), - FRAC_CONST(0.18153160826112497), - FRAC_CONST(0.18454773693861962), - FRAC_CONST(0.1875621285825296), - FRAC_CONST(0.19057475482025274), - FRAC_CONST(0.19358558729580361), - FRAC_CONST(0.19659459767008022), - FRAC_CONST(0.19960175762113097), - FRAC_CONST(0.20260703884442113), - FRAC_CONST(0.20561041305309924), - FRAC_CONST(0.20861185197826349), - FRAC_CONST(0.21161132736922755), - FRAC_CONST(0.21460881099378676), - FRAC_CONST(0.21760427463848364), - FRAC_CONST(0.22059769010887351), - FRAC_CONST(0.22358902922978999), - FRAC_CONST(0.22657826384561), - FRAC_CONST(0.22956536582051887), - FRAC_CONST(0.23255030703877524), - FRAC_CONST(0.23553305940497549), - FRAC_CONST(0.23851359484431842), - FRAC_CONST(0.24149188530286933), - FRAC_CONST(0.24446790274782415), - FRAC_CONST(0.24744161916777327), - FRAC_CONST(0.25041300657296522), - FRAC_CONST(0.25338203699557016), - FRAC_CONST(0.25634868248994291), - FRAC_CONST(0.25931291513288623), - FRAC_CONST(0.26227470702391359), - FRAC_CONST(0.26523403028551179), - FRAC_CONST(0.26819085706340318), - FRAC_CONST(0.27114515952680801), - FRAC_CONST(0.27409690986870638), - FRAC_CONST(0.2770460803060999), - FRAC_CONST(0.27999264308027322), - FRAC_CONST(0.28293657045705539), - FRAC_CONST(0.28587783472708062), - FRAC_CONST(0.28881640820604948), - FRAC_CONST(0.29175226323498926), - FRAC_CONST(0.29468537218051433), - FRAC_CONST(0.2976157074350862), - FRAC_CONST(0.30054324141727345), - FRAC_CONST(0.30346794657201132), - FRAC_CONST(0.30638979537086092), - FRAC_CONST(0.30930876031226873), - FRAC_CONST(0.31222481392182488), - FRAC_CONST(0.31513792875252244), - FRAC_CONST(0.31804807738501495), - FRAC_CONST(0.32095523242787521), - FRAC_CONST(0.32385936651785285), - FRAC_CONST(0.32676045232013173), - FRAC_CONST(0.32965846252858749), - FRAC_CONST(0.33255336986604422), - FRAC_CONST(0.3354451470845316), - FRAC_CONST(0.33833376696554113), - FRAC_CONST(0.34121920232028236), - FRAC_CONST(0.34410142598993881), - FRAC_CONST(0.34698041084592368), - FRAC_CONST(0.34985612979013492), - FRAC_CONST(0.35272855575521073), - FRAC_CONST(0.35559766170478385), - FRAC_CONST(0.35846342063373654), - FRAC_CONST(0.36132580556845428), - FRAC_CONST(0.36418478956707989), - FRAC_CONST(0.36704034571976718), - FRAC_CONST(0.3698924471489341), - FRAC_CONST(0.37274106700951576), - FRAC_CONST(0.37558617848921722), - FRAC_CONST(0.37842775480876556), - FRAC_CONST(0.38126576922216238), - FRAC_CONST(0.38410019501693504), - FRAC_CONST(0.38693100551438858), - FRAC_CONST(0.38975817406985641), - FRAC_CONST(0.39258167407295147), - FRAC_CONST(0.39540147894781635), - FRAC_CONST(0.39821756215337356), - FRAC_CONST(0.40102989718357562), - FRAC_CONST(0.40383845756765407), - FRAC_CONST(0.40664321687036903), - FRAC_CONST(0.40944414869225759), - FRAC_CONST(0.41224122666988289), - FRAC_CONST(0.41503442447608163), - FRAC_CONST(0.41782371582021227), - FRAC_CONST(0.42060907444840251), - FRAC_CONST(0.42339047414379605), - FRAC_CONST(0.42616788872679962), - FRAC_CONST(0.42894129205532949), - FRAC_CONST(0.43171065802505726), - FRAC_CONST(0.43447596056965565), - FRAC_CONST(0.43723717366104409), - FRAC_CONST(0.43999427130963326), - FRAC_CONST(0.44274722756457002), - FRAC_CONST(0.44549601651398174), - FRAC_CONST(0.44824061228521989), - FRAC_CONST(0.45098098904510386), - FRAC_CONST(0.45371712100016387), - FRAC_CONST(0.45644898239688392), - FRAC_CONST(0.45917654752194409), - FRAC_CONST(0.46189979070246273), - FRAC_CONST(0.46461868630623782), - FRAC_CONST(0.46733320874198842), - FRAC_CONST(0.47004333245959562), - FRAC_CONST(0.47274903195034279), - FRAC_CONST(0.47545028174715587), - FRAC_CONST(0.47814705642484301), - FRAC_CONST(0.48083933060033396), - FRAC_CONST(0.48352707893291874), - FRAC_CONST(0.48621027612448642), - FRAC_CONST(0.48888889691976317), - FRAC_CONST(0.4915629161065499), - FRAC_CONST(0.49423230851595967), - FRAC_CONST(0.49689704902265447), - FRAC_CONST(0.49955711254508184), - FRAC_CONST(0.50221247404571079), - FRAC_CONST(0.50486310853126759), - FRAC_CONST(0.50750899105297087), - FRAC_CONST(0.51015009670676681), - FRAC_CONST(0.51278640063356296), - FRAC_CONST(0.51541787801946293), - FRAC_CONST(0.51804450409599934), - FRAC_CONST(0.52066625414036716), - FRAC_CONST(0.52328310347565643), - FRAC_CONST(0.52589502747108463), - FRAC_CONST(0.52850200154222848), - FRAC_CONST(0.531104001151255), - FRAC_CONST(0.53370100180715296), - FRAC_CONST(0.53629297906596318), - FRAC_CONST(0.53887990853100842), - FRAC_CONST(0.54146176585312344), - FRAC_CONST(0.54403852673088382), - FRAC_CONST(0.54661016691083486), - FRAC_CONST(0.54917666218771966), - FRAC_CONST(0.55173798840470734), - FRAC_CONST(0.55429412145362), - FRAC_CONST(0.5568450372751601), - FRAC_CONST(0.55939071185913614), - FRAC_CONST(0.56193112124468947), - FRAC_CONST(0.5644662415205195), - FRAC_CONST(0.56699604882510868), - FRAC_CONST(0.56952051934694714), - FRAC_CONST(0.57203962932475705), - FRAC_CONST(0.57455335504771576), - FRAC_CONST(0.57706167285567944), - FRAC_CONST(0.57956455913940563), - FRAC_CONST(0.58206199034077544), - FRAC_CONST(0.58455394295301533), - FRAC_CONST(0.58704039352091797), - FRAC_CONST(0.58952131864106394), - FRAC_CONST(0.59199669496204099), - FRAC_CONST(0.59446649918466443), - FRAC_CONST(0.5969307080621965), - FRAC_CONST(0.59938929840056454), - FRAC_CONST(0.60184224705858003), - FRAC_CONST(0.60428953094815596), - FRAC_CONST(0.60673112703452448), - FRAC_CONST(0.60916701233645321), - FRAC_CONST(0.61159716392646191), - FRAC_CONST(0.61402155893103838), - FRAC_CONST(0.61644017453085365), - FRAC_CONST(0.61885298796097632), - FRAC_CONST(0.62125997651108755), - FRAC_CONST(0.62366111752569453), - FRAC_CONST(0.62605638840434352), - FRAC_CONST(0.62844576660183271), - FRAC_CONST(0.63082922962842447), - FRAC_CONST(0.63320675505005719), - FRAC_CONST(0.63557832048855611), - FRAC_CONST(0.63794390362184406), - FRAC_CONST(0.64030348218415167), - FRAC_CONST(0.64265703396622686), - FRAC_CONST(0.64500453681554393), - FRAC_CONST(0.64734596863651206), - FRAC_CONST(0.64968130739068319), - FRAC_CONST(0.6520105310969595), - FRAC_CONST(0.65433361783180044), - FRAC_CONST(0.65665054572942894), - FRAC_CONST(0.65896129298203732), - FRAC_CONST(0.66126583783999227), - FRAC_CONST(0.66356415861203977), - FRAC_CONST(0.66585623366550972), - FRAC_CONST(0.66814204142651845), - FRAC_CONST(0.67042156038017309), - FRAC_CONST(0.67269476907077286), - FRAC_CONST(0.67496164610201193), - FRAC_CONST(0.67722217013718033), - FRAC_CONST(0.67947631989936497), - FRAC_CONST(0.68172407417164971), - FRAC_CONST(0.6839654117973154), - FRAC_CONST(0.68620031168003859), - FRAC_CONST(0.68842875278409044), - FRAC_CONST(0.6906507141345346), - FRAC_CONST(0.69286617481742463), - FRAC_CONST(0.69507511398000088), - FRAC_CONST(0.69727751083088652), - FRAC_CONST(0.69947334464028377), - FRAC_CONST(0.70166259474016845), - FRAC_CONST(0.70384524052448494), - FRAC_CONST(0.70602126144933974), - FRAC_CONST(0.70819063703319529), - FRAC_CONST(0.71035334685706231), - FRAC_CONST(0.71250937056469232), - FRAC_CONST(0.71465868786276898), - FRAC_CONST(0.71680127852109954), - FRAC_CONST(0.71893712237280438), - FRAC_CONST(0.72106619931450811), - FRAC_CONST(0.72318848930652735), - FRAC_CONST(0.72530397237306066), - FRAC_CONST(0.72741262860237577), - FRAC_CONST(0.7295144381469969), - FRAC_CONST(0.73160938122389252), - FRAC_CONST(0.73369743811466026), - FRAC_CONST(0.73577858916571348), - FRAC_CONST(0.73785281478846598), - FRAC_CONST(0.73992009545951609), - FRAC_CONST(0.74198041172083096), - FRAC_CONST(0.74403374417992918), - FRAC_CONST(0.74608007351006378), - FRAC_CONST(0.74811938045040349), - FRAC_CONST(0.75015164580621496), - FRAC_CONST(0.7521768504490427), - FRAC_CONST(0.75419497531688917), - FRAC_CONST(0.75620600141439454), - FRAC_CONST(0.75820990981301528), - FRAC_CONST(0.76020668165120242), - FRAC_CONST(0.7621962981345789), - FRAC_CONST(0.76417874053611667), - FRAC_CONST(0.76615399019631281), - FRAC_CONST(0.76812202852336531), - FRAC_CONST(0.7700828369933479), - FRAC_CONST(0.77203639715038441), - FRAC_CONST(0.77398269060682279), - FRAC_CONST(0.77592169904340758), - FRAC_CONST(0.77785340420945304), - FRAC_CONST(0.77977778792301444), - FRAC_CONST(0.78169483207105939), - FRAC_CONST(0.7836045186096382), - FRAC_CONST(0.78550682956405393), - FRAC_CONST(0.78740174702903132), - FRAC_CONST(0.78928925316888565), - FRAC_CONST(0.79116933021769009), - FRAC_CONST(0.79304196047944364), - FRAC_CONST(0.79490712632823701), - FRAC_CONST(0.79676481020841872), - FRAC_CONST(0.79861499463476082), - FRAC_CONST(0.80045766219262271), - FRAC_CONST(0.80229279553811572), - FRAC_CONST(0.8041203773982657), - FRAC_CONST(0.80594039057117628), - FRAC_CONST(0.80775281792619036), - FRAC_CONST(0.80955764240405126), - FRAC_CONST(0.81135484701706373), - FRAC_CONST(0.81314441484925359), - FRAC_CONST(0.81492632905652662), - FRAC_CONST(0.81670057286682785), - FRAC_CONST(0.81846712958029866), - FRAC_CONST(0.82022598256943469), - FRAC_CONST(0.82197711527924155), - FRAC_CONST(0.82372051122739132), - FRAC_CONST(0.82545615400437744), - FRAC_CONST(0.82718402727366902), - FRAC_CONST(0.82890411477186487), - FRAC_CONST(0.8306164003088462), - FRAC_CONST(0.83232086776792968), - FRAC_CONST(0.83401750110601813), - FRAC_CONST(0.8357062843537526), - FRAC_CONST(0.83738720161566194), - FRAC_CONST(0.83906023707031263), - FRAC_CONST(0.84072537497045807), - FRAC_CONST(0.84238259964318596), - FRAC_CONST(0.84403189549006641), - FRAC_CONST(0.84567324698729907), - FRAC_CONST(0.84730663868585832), - FRAC_CONST(0.84893205521163961), - FRAC_CONST(0.85054948126560337), - FRAC_CONST(0.85215890162391983), - FRAC_CONST(0.8537603011381113), - FRAC_CONST(0.85535366473519603), - FRAC_CONST(0.85693897741782865), - FRAC_CONST(0.85851622426444274), - FRAC_CONST(0.86008539042939014), - FRAC_CONST(0.8616464611430813), - FRAC_CONST(0.86319942171212416), - FRAC_CONST(0.86474425751946238), - FRAC_CONST(0.86628095402451299), - FRAC_CONST(0.86780949676330321), - FRAC_CONST(0.86932987134860673), - FRAC_CONST(0.87084206347007886), - FRAC_CONST(0.87234605889439154), - FRAC_CONST(0.87384184346536675), - FRAC_CONST(0.87532940310411078), - FRAC_CONST(0.87680872380914576), - FRAC_CONST(0.87827979165654146), - FRAC_CONST(0.87974259280004741), - FRAC_CONST(0.88119711347122198), - FRAC_CONST(0.88264333997956279), - FRAC_CONST(0.88408125871263499), - FRAC_CONST(0.88551085613619995), - FRAC_CONST(0.88693211879434208), - FRAC_CONST(0.88834503330959624), - FRAC_CONST(0.88974958638307289), - FRAC_CONST(0.89114576479458318), - FRAC_CONST(0.89253355540276469), - FRAC_CONST(0.89391294514520325), - FRAC_CONST(0.89528392103855758), - FRAC_CONST(0.89664647017868015), - FRAC_CONST(0.89800057974073988), - FRAC_CONST(0.89934623697934146), - FRAC_CONST(0.90068342922864686), - FRAC_CONST(0.90201214390249307), - FRAC_CONST(0.90333236849451182), - FRAC_CONST(0.90464409057824624), - FRAC_CONST(0.90594729780726846), - FRAC_CONST(0.90724197791529593), - FRAC_CONST(0.90852811871630612), - FRAC_CONST(0.90980570810465222), - FRAC_CONST(0.91107473405517625), - FRAC_CONST(0.91233518462332275), - FRAC_CONST(0.91358704794525081), - FRAC_CONST(0.91483031223794609), - FRAC_CONST(0.91606496579933161), - FRAC_CONST(0.91729099700837791), - FRAC_CONST(0.91850839432521225), - FRAC_CONST(0.91971714629122736), - FRAC_CONST(0.92091724152918952), - FRAC_CONST(0.92210866874334507), - FRAC_CONST(0.92329141671952764), - FRAC_CONST(0.9244654743252626), - FRAC_CONST(0.92563083050987272), - FRAC_CONST(0.92678747430458175), - FRAC_CONST(0.92793539482261789), - FRAC_CONST(0.92907458125931575), - FRAC_CONST(0.93020502289221907), - FRAC_CONST(0.93132670908118043), - FRAC_CONST(0.93243962926846236), - FRAC_CONST(0.93354377297883617), - FRAC_CONST(0.93463912981968078), - FRAC_CONST(0.93572568948108037), - FRAC_CONST(0.93680344173592156), - FRAC_CONST(0.93787237643998989), - FRAC_CONST(0.93893248353206449), - FRAC_CONST(0.93998375303401394), - FRAC_CONST(0.94102617505088926), - FRAC_CONST(0.94205973977101731), - FRAC_CONST(0.94308443746609349), - FRAC_CONST(0.94410025849127266), - FRAC_CONST(0.94510719328526061), - FRAC_CONST(0.94610523237040334), - FRAC_CONST(0.94709436635277722), - FRAC_CONST(0.94807458592227623), - FRAC_CONST(0.94904588185270056), - FRAC_CONST(0.950008245001843), - FRAC_CONST(0.95096166631157508), - FRAC_CONST(0.95190613680793223), - FRAC_CONST(0.95284164760119872), - FRAC_CONST(0.95376818988599033), - FRAC_CONST(0.95468575494133834), - FRAC_CONST(0.95559433413077111), - FRAC_CONST(0.95649391890239499), - FRAC_CONST(0.95738450078897586), - FRAC_CONST(0.95826607140801767), - FRAC_CONST(0.95913862246184189), - FRAC_CONST(0.96000214573766585), - FRAC_CONST(0.96085663310767966), - FRAC_CONST(0.96170207652912254), - FRAC_CONST(0.96253846804435916), - FRAC_CONST(0.96336579978095405), - FRAC_CONST(0.96418406395174572), - FRAC_CONST(0.96499325285492032), - FRAC_CONST(0.96579335887408357), - FRAC_CONST(0.96658437447833312), - FRAC_CONST(0.96736629222232851), - FRAC_CONST(0.96813910474636233), - FRAC_CONST(0.96890280477642887), - FRAC_CONST(0.96965738512429245), - FRAC_CONST(0.9704028386875555), - FRAC_CONST(0.97113915844972509), - FRAC_CONST(0.9718663374802794), - FRAC_CONST(0.97258436893473221), - FRAC_CONST(0.97329324605469825), - FRAC_CONST(0.97399296216795583), - FRAC_CONST(0.97468351068851067), - FRAC_CONST(0.97536488511665687), - FRAC_CONST(0.97603707903903902), - FRAC_CONST(0.97670008612871184), - FRAC_CONST(0.97735390014519996), - FRAC_CONST(0.97799851493455714), - FRAC_CONST(0.9786339244294231), - FRAC_CONST(0.97926012264908202), - FRAC_CONST(0.97987710369951764), - FRAC_CONST(0.98048486177346938), - FRAC_CONST(0.98108339115048659), - FRAC_CONST(0.98167268619698311), - FRAC_CONST(0.98225274136628937), - FRAC_CONST(0.98282355119870524), - FRAC_CONST(0.98338511032155118), - FRAC_CONST(0.98393741344921892), - FRAC_CONST(0.98448045538322093), - FRAC_CONST(0.98501423101223984), - FRAC_CONST(0.98553873531217606), - FRAC_CONST(0.98605396334619544), - FRAC_CONST(0.98655991026477541), - FRAC_CONST(0.98705657130575097), - FRAC_CONST(0.98754394179435923), - FRAC_CONST(0.98802201714328353), - FRAC_CONST(0.98849079285269659), - FRAC_CONST(0.98895026451030299), - FRAC_CONST(0.98940042779138038), - FRAC_CONST(0.98984127845882053), - FRAC_CONST(0.99027281236316911), - FRAC_CONST(0.99069502544266463), - FRAC_CONST(0.99110791372327678), - FRAC_CONST(0.9915114733187439), - FRAC_CONST(0.99190570043060933), - FRAC_CONST(0.99229059134825737), - FRAC_CONST(0.99266614244894802), - FRAC_CONST(0.99303235019785141), - FRAC_CONST(0.99338921114808065), - FRAC_CONST(0.9937367219407246), - FRAC_CONST(0.99407487930487937), - FRAC_CONST(0.9944036800576791), - FRAC_CONST(0.9947231211043257), - FRAC_CONST(0.99503319943811863), - FRAC_CONST(0.99533391214048228), - FRAC_CONST(0.99562525638099431), - FRAC_CONST(0.99590722941741172), - FRAC_CONST(0.99617982859569687), - FRAC_CONST(0.99644305135004263), - FRAC_CONST(0.99669689520289606), - FRAC_CONST(0.99694135776498216), - FRAC_CONST(0.99717643673532619), - FRAC_CONST(0.9974021299012753), - FRAC_CONST(0.99761843513851955), - FRAC_CONST(0.99782535041111164), - FRAC_CONST(0.99802287377148624), - FRAC_CONST(0.99821100336047819), - FRAC_CONST(0.99838973740734016), - FRAC_CONST(0.99855907422975931), - FRAC_CONST(0.99871901223387294), - FRAC_CONST(0.99886954991428356), - FRAC_CONST(0.99901068585407338), - FRAC_CONST(0.99914241872481691), - FRAC_CONST(0.99926474728659442), - FRAC_CONST(0.99937767038800285), - FRAC_CONST(0.99948118696616695), - FRAC_CONST(0.99957529604674922), - FRAC_CONST(0.99965999674395922), - FRAC_CONST(0.99973528826056168), - FRAC_CONST(0.99980116988788426), - FRAC_CONST(0.99985764100582386), - FRAC_CONST(0.9999047010828529), - FRAC_CONST(0.99994234967602391), - FRAC_CONST(0.99997058643097414), - FRAC_CONST(0.9999894110819284), - FRAC_CONST(0.99999882345170188) -}; - -#ifdef ALLOW_SMALL_FRAMELENGTH -static const real_t sine_mid_480[] MEM_ALIGN_ATTR = -{ - FRAC_CONST(0.0016362454436240478), - FRAC_CONST(0.00490871880799799), - FRAC_CONST(0.0081811396039371282), - FRAC_CONST(0.011453472786443779), - FRAC_CONST(0.014725683311458524), - FRAC_CONST(0.017997736136235509), - FRAC_CONST(0.021269596219717739), - FRAC_CONST(0.024541228522912285), - FRAC_CONST(0.027812598009265607), - FRAC_CONST(0.03108366964503869), - FRAC_CONST(0.034354408399682276), - FRAC_CONST(0.037624779246211978), - FRAC_CONST(0.04089474716158345), - FRAC_CONST(0.044164277127067358), - FRAC_CONST(0.047433334128624507), - FRAC_CONST(0.050701883157280733), - FRAC_CONST(0.053969889209501881), - FRAC_CONST(0.057237317287568618), - FRAC_CONST(0.060504132399951269), - FRAC_CONST(0.063770299561684493), - FRAC_CONST(0.06703578379474201), - FRAC_CONST(0.070300550128411174), - FRAC_CONST(0.073564563599667426), - FRAC_CONST(0.076827789253548759), - FRAC_CONST(0.080090192143530081), - FRAC_CONST(0.083351737331897449), - FRAC_CONST(0.086612389890122182), - FRAC_CONST(0.089872114899234967), - FRAC_CONST(0.093130877450199795), - FRAC_CONST(0.096388642644287828), - FRAC_CONST(0.09964537559345106), - FRAC_CONST(0.1029010414206961), - FRAC_CONST(0.10615560526045748), - FRAC_CONST(0.10940903225897117), - FRAC_CONST(0.11266128757464781), - FRAC_CONST(0.11591233637844581), - FRAC_CONST(0.11916214385424433), - FRAC_CONST(0.1224106751992162), - FRAC_CONST(0.12565789562420052), - FRAC_CONST(0.12890377035407541), - FRAC_CONST(0.13214826462813015), - FRAC_CONST(0.13539134370043773), - FRAC_CONST(0.13863297284022669), - FRAC_CONST(0.14187311733225325), - FRAC_CONST(0.14511174247717309), - FRAC_CONST(0.14834881359191271), - FRAC_CONST(0.15158429601004111), - FRAC_CONST(0.15481815508214106), - FRAC_CONST(0.1580503561761798), - FRAC_CONST(0.16128086467788047), - FRAC_CONST(0.16450964599109233), - FRAC_CONST(0.16773666553816149), - FRAC_CONST(0.17096188876030122), - FRAC_CONST(0.17418528111796186), - FRAC_CONST(0.17740680809120093), - FRAC_CONST(0.18062643518005275), - FRAC_CONST(0.18384412790489776), - FRAC_CONST(0.18705985180683199), - FRAC_CONST(0.19027357244803589), - FRAC_CONST(0.19348525541214331), - FRAC_CONST(0.19669486630460997), - FRAC_CONST(0.19990237075308173), - FRAC_CONST(0.20310773440776286), - FRAC_CONST(0.20631092294178383), - FRAC_CONST(0.20951190205156878), - FRAC_CONST(0.21271063745720317), - FRAC_CONST(0.21590709490280058), - FRAC_CONST(0.2191012401568698), - FRAC_CONST(0.22229303901268133), - FRAC_CONST(0.22548245728863364), - FRAC_CONST(0.22866946082861941), - FRAC_CONST(0.23185401550239115), - FRAC_CONST(0.23503608720592667), - FRAC_CONST(0.23821564186179459), - FRAC_CONST(0.24139264541951888), - FRAC_CONST(0.24456706385594387), - FRAC_CONST(0.24773886317559846), - FRAC_CONST(0.25090800941106001), - FRAC_CONST(0.25407446862331851), - FRAC_CONST(0.25723820690213967), - FRAC_CONST(0.26039919036642817), - FRAC_CONST(0.26355738516459076), - FRAC_CONST(0.26671275747489837), - FRAC_CONST(0.2698652735058486), - FRAC_CONST(0.27301489949652735), - FRAC_CONST(0.27616160171697068), - FRAC_CONST(0.27930534646852595), - FRAC_CONST(0.28244610008421245), - FRAC_CONST(0.2855838289290823), - FRAC_CONST(0.28871849940058025), - FRAC_CONST(0.29185007792890405), - FRAC_CONST(0.29497853097736348), - FRAC_CONST(0.2981038250427398), - FRAC_CONST(0.30122592665564446), - FRAC_CONST(0.30434480238087736), - FRAC_CONST(0.30746041881778519), - FRAC_CONST(0.31057274260061901), - FRAC_CONST(0.31368174039889146), - FRAC_CONST(0.31678737891773395), - FRAC_CONST(0.31988962489825296), - FRAC_CONST(0.32298844511788638), - FRAC_CONST(0.32608380639075912), - FRAC_CONST(0.32917567556803889), - FRAC_CONST(0.33226401953829071), - FRAC_CONST(0.33534880522783189), - FRAC_CONST(0.33842999960108583), - FRAC_CONST(0.34150756966093632), - FRAC_CONST(0.34458148244908043), - FRAC_CONST(0.34765170504638188), - FRAC_CONST(0.35071820457322322), - FRAC_CONST(0.35378094818985806), - FRAC_CONST(0.35683990309676283), - FRAC_CONST(0.35989503653498811), - FRAC_CONST(0.36294631578650921), - FRAC_CONST(0.36599370817457672), - FRAC_CONST(0.36903718106406647), - FRAC_CONST(0.37207670186182878), - FRAC_CONST(0.37511223801703802), - FRAC_CONST(0.37814375702154046), - FRAC_CONST(0.38117122641020335), - FRAC_CONST(0.38419461376126157), - FRAC_CONST(0.38721388669666562), - FRAC_CONST(0.39022901288242801), - FRAC_CONST(0.39323996002896966), - FRAC_CONST(0.39624669589146555), - FRAC_CONST(0.39924918827019029), - FRAC_CONST(0.40224740501086254), - FRAC_CONST(0.40524131400498986), - FRAC_CONST(0.40823088319021217), - FRAC_CONST(0.41121608055064529), - FRAC_CONST(0.41419687411722372), - FRAC_CONST(0.41717323196804335), - FRAC_CONST(0.42014512222870243), - FRAC_CONST(0.42311251307264408), - FRAC_CONST(0.42607537272149631), - FRAC_CONST(0.4290336694454126), - FRAC_CONST(0.43198737156341183), - FRAC_CONST(0.43493644744371707), - FRAC_CONST(0.43788086550409511), - FRAC_CONST(0.44082059421219388), - FRAC_CONST(0.44375560208588088), - FRAC_CONST(0.44668585769357955), - FRAC_CONST(0.4496113296546066), - FRAC_CONST(0.45253198663950756), - FRAC_CONST(0.45544779737039259), - FRAC_CONST(0.45835873062127125), - FRAC_CONST(0.46126475521838717), - FRAC_CONST(0.46416584004055156), - FRAC_CONST(0.46706195401947659), - FRAC_CONST(0.46995306614010829), - FRAC_CONST(0.47283914544095862), - FRAC_CONST(0.47572016101443682), - FRAC_CONST(0.47859608200718085), - FRAC_CONST(0.4814668776203872), - FRAC_CONST(0.48433251711014125), - FRAC_CONST(0.4871929697877464), - FRAC_CONST(0.49004820502005247), - FRAC_CONST(0.49289819222978404), - FRAC_CONST(0.49574290089586776), - FRAC_CONST(0.49858230055375902), - FRAC_CONST(0.50141636079576901), - FRAC_CONST(0.50424505127138919), - FRAC_CONST(0.50706834168761705), - FRAC_CONST(0.50988620180928057), - FRAC_CONST(0.51269860145936175), - FRAC_CONST(0.51550551051931948), - FRAC_CONST(0.51830689892941317), - FRAC_CONST(0.5211027366890234), - FRAC_CONST(0.52389299385697385), - FRAC_CONST(0.52667764055185196), - FRAC_CONST(0.52945664695232897), - FRAC_CONST(0.53222998329747884), - FRAC_CONST(0.53499761988709726), - FRAC_CONST(0.53775952708201991), - FRAC_CONST(0.54051567530443978), - FRAC_CONST(0.54326603503822357), - FRAC_CONST(0.54601057682922816), - FRAC_CONST(0.54874927128561579), - FRAC_CONST(0.55148208907816942), - FRAC_CONST(0.55420900094060566), - FRAC_CONST(0.55692997766988939), - FRAC_CONST(0.559644990126546), - FRAC_CONST(0.56235400923497314), - FRAC_CONST(0.56505700598375252), - FRAC_CONST(0.56775395142596052), - FRAC_CONST(0.57044481667947822), - FRAC_CONST(0.57312957292730071), - FRAC_CONST(0.57580819141784534), - FRAC_CONST(0.57848064346525996), - FRAC_CONST(0.58114690044973039), - FRAC_CONST(0.58380693381778626), - FRAC_CONST(0.58646071508260733), - FRAC_CONST(0.58910821582432815), - FRAC_CONST(0.5917494076903429), - FRAC_CONST(0.5943842623956086), - FRAC_CONST(0.59701275172294799), - FRAC_CONST(0.59963484752335228), - FRAC_CONST(0.60225052171628191), - FRAC_CONST(0.60485974628996786), - FRAC_CONST(0.60746249330171098), - FRAC_CONST(0.61005873487818185), - FRAC_CONST(0.61264844321571899), - FRAC_CONST(0.61523159058062682), - FRAC_CONST(0.61780814930947225), - FRAC_CONST(0.62037809180938108), - FRAC_CONST(0.62294139055833397), - FRAC_CONST(0.6254980181054608), - FRAC_CONST(0.62804794707133416), - FRAC_CONST(0.63059115014826372), - FRAC_CONST(0.63312760010058777), - FRAC_CONST(0.63565726976496484), - FRAC_CONST(0.63818013205066515), - FRAC_CONST(0.64069615993986073), - FRAC_CONST(0.64320532648791406), - FRAC_CONST(0.64570760482366729), - FRAC_CONST(0.64820296814972966), - FRAC_CONST(0.65069138974276486), - FRAC_CONST(0.65317284295377676), - FRAC_CONST(0.65564730120839498), - FRAC_CONST(0.65811473800715958), - FRAC_CONST(0.660575126925805), - FRAC_CONST(0.66302844161554231), - FRAC_CONST(0.6654746558033422), - FRAC_CONST(0.66791374329221598), - FRAC_CONST(0.67034567796149647), - FRAC_CONST(0.67277043376711676), - FRAC_CONST(0.67518798474189046), - FRAC_CONST(0.67759830499578866), - FRAC_CONST(0.68000136871621808), - FRAC_CONST(0.68239715016829683), - FRAC_CONST(0.6847856236951303), - FRAC_CONST(0.68716676371808583), - FRAC_CONST(0.68954054473706683), - FRAC_CONST(0.69190694133078579), - FRAC_CONST(0.69426592815703603), - FRAC_CONST(0.69661747995296419), - FRAC_CONST(0.69896157153533944), - FRAC_CONST(0.70129817780082437), - FRAC_CONST(0.7036272737262429), - FRAC_CONST(0.70594883436884903), - FRAC_CONST(0.70826283486659336), - FRAC_CONST(0.71056925043838959), - FRAC_CONST(0.71286805638437978), - FRAC_CONST(0.71515922808619936), - FRAC_CONST(0.71744274100723993), - FRAC_CONST(0.71971857069291278), - FRAC_CONST(0.7219866927709101), - FRAC_CONST(0.72424708295146689), - FRAC_CONST(0.72649971702762028), - FRAC_CONST(0.72874457087546896), - FRAC_CONST(0.73098162045443171), - FRAC_CONST(0.73321084180750484), - FRAC_CONST(0.73543221106151868), - FRAC_CONST(0.73764570442739286), - FRAC_CONST(0.73985129820039208), - FRAC_CONST(0.74204896876037885), - FRAC_CONST(0.7442386925720671), - FRAC_CONST(0.74642044618527381), - FRAC_CONST(0.74859420623517081), - FRAC_CONST(0.75075994944253421), - FRAC_CONST(0.75291765261399446), - FRAC_CONST(0.75506729264228367), - FRAC_CONST(0.75720884650648446), - FRAC_CONST(0.75934229127227548), - FRAC_CONST(0.76146760409217706), - FRAC_CONST(0.76358476220579641), - FRAC_CONST(0.7656937429400712), - FRAC_CONST(0.76779452370951196), - FRAC_CONST(0.76988708201644451), - FRAC_CONST(0.77197139545125026), - FRAC_CONST(0.7740474416926072), - FRAC_CONST(0.77611519850772781), - FRAC_CONST(0.77817464375259782), - FRAC_CONST(0.78022575537221317), - FRAC_CONST(0.78226851140081632), - FRAC_CONST(0.78430288996213138), - FRAC_CONST(0.78632886926959822), - FRAC_CONST(0.78834642762660623), - FRAC_CONST(0.79035554342672631), - FRAC_CONST(0.79235619515394229), - FRAC_CONST(0.79434836138288134), - FRAC_CONST(0.79633202077904397), - FRAC_CONST(0.79830715209903147), - FRAC_CONST(0.8002737341907743), - FRAC_CONST(0.80223174599375802), - FRAC_CONST(0.80418116653924954), - FRAC_CONST(0.80612197495052085), - FRAC_CONST(0.80805415044307316), - FRAC_CONST(0.80997767232485907), - FRAC_CONST(0.81189251999650469), - FRAC_CONST(0.81379867295152986), - FRAC_CONST(0.81569611077656778), - FRAC_CONST(0.81758481315158371), - FRAC_CONST(0.81946475985009259), - FRAC_CONST(0.82133593073937561), - FRAC_CONST(0.82319830578069586), - FRAC_CONST(0.82505186502951278), - FRAC_CONST(0.82689658863569615), - FRAC_CONST(0.82873245684373809), - FRAC_CONST(0.83055944999296494), - FRAC_CONST(0.83237754851774781), - FRAC_CONST(0.83418673294771239), - FRAC_CONST(0.83598698390794668), - FRAC_CONST(0.83777828211920935), - FRAC_CONST(0.83956060839813562), - FRAC_CONST(0.84133394365744296), - FRAC_CONST(0.84309826890613537), - FRAC_CONST(0.84485356524970701), - FRAC_CONST(0.84659981389034411), - FRAC_CONST(0.84833699612712676), - FRAC_CONST(0.85006509335622882), - FRAC_CONST(0.8517840870711173), - FRAC_CONST(0.85349395886275037), - FRAC_CONST(0.85519469041977514), - FRAC_CONST(0.85688626352872277), - FRAC_CONST(0.85856866007420429), - FRAC_CONST(0.86024186203910447), - FRAC_CONST(0.86190585150477417), - FRAC_CONST(0.86356061065122347), - FRAC_CONST(0.86520612175731115), - FRAC_CONST(0.86684236720093533), - FRAC_CONST(0.86846932945922151), - FRAC_CONST(0.87008699110871135), - FRAC_CONST(0.87169533482554817), - FRAC_CONST(0.87329434338566281), - FRAC_CONST(0.87488399966495822), - FRAC_CONST(0.87646428663949283), - FRAC_CONST(0.87803518738566277), - FRAC_CONST(0.87959668508038291), - FRAC_CONST(0.88114876300126743), - FRAC_CONST(0.88269140452680916), - FRAC_CONST(0.8842245931365561), - FRAC_CONST(0.88574831241129048), - FRAC_CONST(0.88726254603320276), - FRAC_CONST(0.88876727778606746), - FRAC_CONST(0.89026249155541637), - FRAC_CONST(0.8917481713287112), - FRAC_CONST(0.89322430119551532), - FRAC_CONST(0.89469086534766362), - FRAC_CONST(0.89614784807943237), - FRAC_CONST(0.89759523378770689), - FRAC_CONST(0.89903300697214927), - FRAC_CONST(0.9004611522353636), - FRAC_CONST(0.90187965428306172), - FRAC_CONST(0.90328849792422594), - FRAC_CONST(0.90468766807127299), - FRAC_CONST(0.90607714974021469), - FRAC_CONST(0.90745692805081868), - FRAC_CONST(0.90882698822676755), - FRAC_CONST(0.91018731559581767), - FRAC_CONST(0.91153789558995579), - FRAC_CONST(0.91287871374555518), - FRAC_CONST(0.91420975570353069), - FRAC_CONST(0.9155310072094921), - FRAC_CONST(0.91684245411389753), - FRAC_CONST(0.91814408237220391), - FRAC_CONST(0.91943587804501858), - FRAC_CONST(0.92071782729824769), - FRAC_CONST(0.92198991640324446), - FRAC_CONST(0.92325213173695675), - FRAC_CONST(0.92450445978207241), - FRAC_CONST(0.92574688712716402), - FRAC_CONST(0.92697940046683291), - FRAC_CONST(0.92820198660185149), - FRAC_CONST(0.92941463243930444), - FRAC_CONST(0.93061732499272909), - FRAC_CONST(0.93181005138225426), - FRAC_CONST(0.93299279883473885), - FRAC_CONST(0.93416555468390772), - FRAC_CONST(0.93532830637048769), - FRAC_CONST(0.93648104144234268), - FRAC_CONST(0.93762374755460598), - FRAC_CONST(0.93875641246981323), - FRAC_CONST(0.93987902405803303), - FRAC_CONST(0.94099157029699743), - FRAC_CONST(0.94209403927222979), - FRAC_CONST(0.94318641917717327), - FRAC_CONST(0.9442686983133165), - FRAC_CONST(0.94534086509031956), - FRAC_CONST(0.9464029080261378), - FRAC_CONST(0.94745481574714419), - FRAC_CONST(0.94849657698825252), - FRAC_CONST(0.94952818059303667), - FRAC_CONST(0.95054961551385087), - FRAC_CONST(0.95156087081194762), - FRAC_CONST(0.95256193565759528), - FRAC_CONST(0.95355279933019343), - FRAC_CONST(0.9545334512183884), - FRAC_CONST(0.95550388082018611), - FRAC_CONST(0.95646407774306541), - FRAC_CONST(0.95741403170408834), - FRAC_CONST(0.95835373253001133), - FRAC_CONST(0.95928317015739362), - FRAC_CONST(0.96020233463270466), - FRAC_CONST(0.96111121611243155), - FRAC_CONST(0.96200980486318388), - FRAC_CONST(0.96289809126179782), - FRAC_CONST(0.96377606579543984), - FRAC_CONST(0.96464371906170809), - FRAC_CONST(0.96550104176873297), - FRAC_CONST(0.96634802473527726), - FRAC_CONST(0.96718465889083372), - FRAC_CONST(0.96801093527572268), - FRAC_CONST(0.96882684504118799), - FRAC_CONST(0.96963237944949143), - FRAC_CONST(0.97042752987400682), - FRAC_CONST(0.97121228779931179), - FRAC_CONST(0.97198664482127939), - FRAC_CONST(0.97275059264716823), - FRAC_CONST(0.97350412309571066), - FRAC_CONST(0.97424722809720088), - FRAC_CONST(0.97497989969358168), - FRAC_CONST(0.97570213003852857), - FRAC_CONST(0.97641391139753486), - FRAC_CONST(0.97711523614799412), - FRAC_CONST(0.97780609677928154), - FRAC_CONST(0.97848648589283505), - FRAC_CONST(0.97915639620223371), - FRAC_CONST(0.9798158205332762), - FRAC_CONST(0.98046475182405801), - FRAC_CONST(0.98110318312504607), - FRAC_CONST(0.98173110759915416), - FRAC_CONST(0.98234851852181571), - FRAC_CONST(0.98295540928105563), - FRAC_CONST(0.9835517733775615), - FRAC_CONST(0.98413760442475307), - FRAC_CONST(0.98471289614885038), - FRAC_CONST(0.98527764238894122), - FRAC_CONST(0.98583183709704714), - FRAC_CONST(0.98637547433818806), - FRAC_CONST(0.98690854829044583), - FRAC_CONST(0.98743105324502667), - FRAC_CONST(0.98794298360632238), - FRAC_CONST(0.98844433389196995), - FRAC_CONST(0.98893509873291074), - FRAC_CONST(0.98941527287344755), - FRAC_CONST(0.98988485117130098), - FRAC_CONST(0.99034382859766479), - FRAC_CONST(0.99079220023725967), - FRAC_CONST(0.99122996128838525), - FRAC_CONST(0.9916571070629725), - FRAC_CONST(0.99207363298663342), - FRAC_CONST(0.99247953459870997), - FRAC_CONST(0.99287480755232194), - FRAC_CONST(0.99325944761441354), - FRAC_CONST(0.99363345066579889), - FRAC_CONST(0.99399681270120555), - FRAC_CONST(0.99434952982931812), - FRAC_CONST(0.9946915982728195), - FRAC_CONST(0.99502301436843166), - FRAC_CONST(0.99534377456695422), - FRAC_CONST(0.9956538754333033), - FRAC_CONST(0.99595331364654771), - FRAC_CONST(0.99624208599994479), - FRAC_CONST(0.99652018940097464), - FRAC_CONST(0.99678762087137318), - FRAC_CONST(0.99704437754716424), - FRAC_CONST(0.99729045667869021), - FRAC_CONST(0.99752585563064111), - FRAC_CONST(0.99775057188208349), - FRAC_CONST(0.9979646030264866), - FRAC_CONST(0.99816794677174903), - FRAC_CONST(0.9983606009402225), - FRAC_CONST(0.99854256346873571), - FRAC_CONST(0.99871383240861611), - FRAC_CONST(0.99887440592571108), - FRAC_CONST(0.99902428230040718), - FRAC_CONST(0.99916345992764877), - FRAC_CONST(0.99929193731695531), - FRAC_CONST(0.99940971309243731), - FRAC_CONST(0.99951678599281069), - FRAC_CONST(0.99961315487141078), - FRAC_CONST(0.99969881869620425), - FRAC_CONST(0.99977377654980037), - FRAC_CONST(0.99983802762946083), - FRAC_CONST(0.99989157124710804), - FRAC_CONST(0.9999344068293331), - FRAC_CONST(0.99996653391740109), - FRAC_CONST(0.99998795216725689), - FRAC_CONST(0.99999866134952808) -}; -#endif - -static const real_t ld_mid_512[] MEM_ALIGN_ATTR = -{ - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0.0061358846491544753), - FRAC_CONST(0.01840672990580482), - FRAC_CONST(0.030674803176636626), - FRAC_CONST(0.04293825693494082), - FRAC_CONST(0.055195244349689934), - FRAC_CONST(0.067443919563664051), - FRAC_CONST(0.079682437971430126), - FRAC_CONST(0.091908956497132724), - FRAC_CONST(0.10412163387205459), - FRAC_CONST(0.11631863091190475), - FRAC_CONST(0.12849811079379317), - FRAC_CONST(0.14065823933284921), - FRAC_CONST(0.15279718525844344), - FRAC_CONST(0.16491312048996989), - FRAC_CONST(0.17700422041214875), - FRAC_CONST(0.18906866414980619), - FRAC_CONST(0.2011046348420919), - FRAC_CONST(0.21311031991609136), - FRAC_CONST(0.22508391135979283), - FRAC_CONST(0.2370236059943672), - FRAC_CONST(0.24892760574572015), - FRAC_CONST(0.26079411791527551), - FRAC_CONST(0.27262135544994898), - FRAC_CONST(0.28440753721127188), - FRAC_CONST(0.29615088824362379), - FRAC_CONST(0.30784964004153487), - FRAC_CONST(0.31950203081601569), - FRAC_CONST(0.33110630575987643), - FRAC_CONST(0.34266071731199438), - FRAC_CONST(0.35416352542049034), - FRAC_CONST(0.36561299780477385), - FRAC_CONST(0.37700741021641826), - FRAC_CONST(0.38834504669882625), - FRAC_CONST(0.39962419984564679), - FRAC_CONST(0.41084317105790391), - FRAC_CONST(0.42200027079979968), - FRAC_CONST(0.43309381885315196), - FRAC_CONST(0.4441221445704292), - FRAC_CONST(0.45508358712634384), - FRAC_CONST(0.46597649576796618), - FRAC_CONST(0.47679923006332209), - FRAC_CONST(0.487550160148436), - FRAC_CONST(0.49822766697278187), - FRAC_CONST(0.50883014254310699), - FRAC_CONST(0.51935599016558964), - FRAC_CONST(0.52980362468629461), - FRAC_CONST(0.54017147272989285), - FRAC_CONST(0.55045797293660481), - FRAC_CONST(0.56066157619733603), - FRAC_CONST(0.57078074588696726), - FRAC_CONST(0.58081395809576453), - FRAC_CONST(0.59075970185887416), - FRAC_CONST(0.60061647938386897), - FRAC_CONST(0.61038280627630948), - FRAC_CONST(0.6200572117632891), - FRAC_CONST(0.62963823891492698), - FRAC_CONST(0.63912444486377573), - FRAC_CONST(0.64851440102211244), - FRAC_CONST(0.65780669329707864), - FRAC_CONST(0.66699992230363747), - FRAC_CONST(0.67609270357531592), - FRAC_CONST(0.68508366777270036), - FRAC_CONST(0.693971460889654), - FRAC_CONST(0.7027547444572253), - FRAC_CONST(0.71143219574521643), - FRAC_CONST(0.72000250796138165), - FRAC_CONST(0.7284643904482252), - FRAC_CONST(0.73681656887736979), - FRAC_CONST(0.74505778544146595), - FRAC_CONST(0.75318679904361241), - FRAC_CONST(0.76120238548426178), - FRAC_CONST(0.76910333764557959), - FRAC_CONST(0.77688846567323244), - FRAC_CONST(0.78455659715557524), - FRAC_CONST(0.79210657730021239), - FRAC_CONST(0.79953726910790501), - FRAC_CONST(0.80684755354379922), - FRAC_CONST(0.8140363297059483), - FRAC_CONST(0.82110251499110465), - FRAC_CONST(0.8280450452577558), - FRAC_CONST(0.83486287498638001), - FRAC_CONST(0.84155497743689833), - FRAC_CONST(0.84812034480329712), - FRAC_CONST(0.85455798836540053), - FRAC_CONST(0.86086693863776731), - FRAC_CONST(0.86704624551569265), - FRAC_CONST(0.87309497841829009), - FRAC_CONST(0.87901222642863341), - FRAC_CONST(0.88479709843093779), - FRAC_CONST(0.89044872324475788), - FRAC_CONST(0.89596624975618511), - FRAC_CONST(0.90134884704602203), - FRAC_CONST(0.90659570451491533), - FRAC_CONST(0.91170603200542988), - FRAC_CONST(0.9166790599210427), - FRAC_CONST(0.9215140393420419), - FRAC_CONST(0.92621024213831127), - FRAC_CONST(0.93076696107898371), - FRAC_CONST(0.9351835099389475), - FRAC_CONST(0.93945922360218992), - FRAC_CONST(0.94359345816196039), - FRAC_CONST(0.94758559101774109), - FRAC_CONST(0.95143502096900834), - FRAC_CONST(0.95514116830577067), - FRAC_CONST(0.9587034748958716), - FRAC_CONST(0.96212140426904158), - FRAC_CONST(0.9653944416976894), - FRAC_CONST(0.96852209427441727), - FRAC_CONST(0.97150389098625178), - FRAC_CONST(0.97433938278557586), - FRAC_CONST(0.97702814265775439), - FRAC_CONST(0.97956976568544052), - FRAC_CONST(0.98196386910955524), - FRAC_CONST(0.98421009238692903), - FRAC_CONST(0.98630809724459867), - FRAC_CONST(0.98825756773074946), - FRAC_CONST(0.99005821026229712), - FRAC_CONST(0.99170975366909953), - FRAC_CONST(0.9932119492347945), - FRAC_CONST(0.99456457073425542), - FRAC_CONST(0.99576741446765982), - FRAC_CONST(0.99682029929116567), - FRAC_CONST(0.99772306664419164), - FRAC_CONST(0.99847558057329477), - FRAC_CONST(0.99907772775264536), - FRAC_CONST(0.99952941750109314), - FRAC_CONST(0.9998305817958234), - FRAC_CONST(0.99998117528260111), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1) -}; - -#ifdef ALLOW_SMALL_FRAMELENGTH -static const real_t ld_mid_480[] MEM_ALIGN_ATTR = -{ - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0), - FRAC_CONST(0.0065449379673518581), - FRAC_CONST(0.019633692460628301), - FRAC_CONST(0.032719082821776137), - FRAC_CONST(0.045798866936520771), - FRAC_CONST(0.058870803651189033), - FRAC_CONST(0.071932653156719387), - FRAC_CONST(0.084982177372441667), - FRAC_CONST(0.09801714032956059), - FRAC_CONST(0.11103530855427769), - FRAC_CONST(0.12403445145048532), - FRAC_CONST(0.13701234168196802), - FRAC_CONST(0.14996675555404498), - FRAC_CONST(0.16289547339458874), - FRAC_CONST(0.17579627993435451), - FRAC_CONST(0.18866696468655525), - FRAC_CONST(0.2015053223256171), - FRAC_CONST(0.21430915306505074), - FRAC_CONST(0.2270762630343732), - FRAC_CONST(0.23980446465501654), - FRAC_CONST(0.25249157701515795), - FRAC_CONST(0.26513542624340797), - FRAC_CONST(0.27773384588129219), - FRAC_CONST(0.29028467725446233), - FRAC_CONST(0.3027857698425746), - FRAC_CONST(0.31523498164776964), - FRAC_CONST(0.32763017956169349), - FRAC_CONST(0.33996923973099424), - FRAC_CONST(0.35225004792123354), - FRAC_CONST(0.36447049987914965), - FRAC_CONST(0.37662850169321077), - FRAC_CONST(0.38872197015239557), - FRAC_CONST(0.40074883310314097), - FRAC_CONST(0.41270702980439467), - FRAC_CONST(0.42459451128071307), - FRAC_CONST(0.43640924067334208), - FRAC_CONST(0.44814919358922256), - FRAC_CONST(0.45981235844785984), - FRAC_CONST(0.47139673682599764), - FRAC_CONST(0.48290034380003727), - FRAC_CONST(0.49432120828614462), - FRAC_CONST(0.50565737337798455), - FRAC_CONST(0.51690689668202761), - FRAC_CONST(0.52806785065036799), - FRAC_CONST(0.53913832291100017), - FRAC_CONST(0.55011641659549337), - FRAC_CONST(0.56100025066400983), - FRAC_CONST(0.57178796022761225), - FRAC_CONST(0.58247769686780215), - FRAC_CONST(0.59306762895323706), - FRAC_CONST(0.60355594195357143), - FRAC_CONST(0.61394083875036642), - FRAC_CONST(0.62422053994501758), - FRAC_CONST(0.63439328416364549), - FRAC_CONST(0.64445732835889735), - FRAC_CONST(0.65441094810861034), - FRAC_CONST(0.66425243791128175), - FRAC_CONST(0.67398011147829784), - FRAC_CONST(0.68359230202287125), - FRAC_CONST(0.69308736254563585), - FRAC_CONST(0.70246366611685174), - FRAC_CONST(0.71171960615517138), - FRAC_CONST(0.72085359670291882), - FRAC_CONST(0.7298640726978356), - FRAC_CONST(0.73874949024124625), - FRAC_CONST(0.74750832686259672), - FRAC_CONST(0.75613908178032285), - FRAC_CONST(0.76464027615900032), - FRAC_CONST(0.77301045336273699), - FRAC_CONST(0.78124817920475853), - FRAC_CONST(0.78935204219315003), - FRAC_CONST(0.79732065377270711), - FRAC_CONST(0.80515264856285829), - FRAC_CONST(0.81284668459161513), - FRAC_CONST(0.82040144352551359), - FRAC_CONST(0.82781563089550203), - FRAC_CONST(0.83508797631874299), - FRAC_CONST(0.84221723371628654), - FRAC_CONST(0.84920218152657889), - FRAC_CONST(0.85604162291477137), - FRAC_CONST(0.86273438597779184), - FRAC_CONST(0.86927932394514362), - FRAC_CONST(0.87567531537539967), - FRAC_CONST(0.88192126434835494), - FRAC_CONST(0.88801610065280734), - FRAC_CONST(0.89395877996993212), - FRAC_CONST(0.8997482840522214), - FRAC_CONST(0.90538362089795521), - FRAC_CONST(0.91086382492117568), - FRAC_CONST(0.91618795711713596), - FRAC_CONST(0.92135510522319242), - FRAC_CONST(0.9263643838751181), - FRAC_CONST(0.93121493475880346), - FRAC_CONST(0.93590592675732565), - FRAC_CONST(0.94043655609335486), - FRAC_CONST(0.94480604646687805), - FRAC_CONST(0.94901364918821385), - FRAC_CONST(0.95305864330629697), - FRAC_CONST(0.95694033573220882), - FRAC_CONST(0.9606580613579353), - FRAC_CONST(0.96421118317032928), - FRAC_CONST(0.96759909236025976), - FRAC_CONST(0.9708212084269281), - FRAC_CONST(0.97387697927733363), - FRAC_CONST(0.97676588132087239), - FRAC_CONST(0.97948741955905139), - FRAC_CONST(0.98204112767030394), - FRAC_CONST(0.98442656808989171), - FRAC_CONST(0.98664333208487898), - FRAC_CONST(0.98869103982416728), - FRAC_CONST(0.99056934044357725), - FRAC_CONST(0.99227791210596705), - FRAC_CONST(0.99381646205637808), - FRAC_CONST(0.99518472667219682), - FRAC_CONST(0.99638247150832537), - FRAC_CONST(0.99740949133735191), - FRAC_CONST(0.99826561018471593), - FRAC_CONST(0.99895068135886012), - FRAC_CONST(0.99946458747636568), - FRAC_CONST(0.99980724048206482), - FRAC_CONST(0.99997858166412923), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1), - FRAC_CONST(1) -}; -#endif -#endif - -#ifdef __cplusplus -} -#endif -#endif diff --git a/apps/codecs/libfaad/specrec.c b/apps/codecs/libfaad/specrec.c deleted file mode 100644 index 200239bddc..0000000000 --- a/apps/codecs/libfaad/specrec.c +++ /dev/null @@ -1,1092 +0,0 @@ -/* -** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -** -** Any non-GPL usage of this software or parts of this software is strictly -** forbidden. -** -** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. -** -** $Id$ -**/ - -/* - Spectral reconstruction: - - grouping/sectioning - - inverse quantization - - applying scalefactors -*/ - -#include "common.h" -#include "structs.h" - -#include -#include -#include "specrec.h" -#include "filtbank.h" -#include "syntax.h" -#include "iq_table.h" -#include "ms.h" -#include "is.h" -#include "pns.h" -#include "tns.h" -#include "drc.h" -#include "lt_predict.h" -#include "ic_predict.h" -#ifdef SSR_DEC -#include "ssr.h" -#include "ssr_fb.h" -#endif - -/* static function declarations */ -static uint8_t quant_to_spec(NeAACDecHandle hDecoder, - ic_stream *ics, int16_t *quant_data, - real_t *spec_data, uint16_t frame_len); - - -#ifdef LD_DEC -static const uint8_t num_swb_512_window[] = -{ - 0, 0, 0, 36, 36, 37, 31, 31, 0, 0, 0, 0 -}; -static const uint8_t num_swb_480_window[] = -{ - 0, 0, 0, 35, 35, 37, 30, 30, 0, 0, 0, 0 -}; -#endif - -static const uint8_t num_swb_960_window[] ICONST_ATTR = -{ - 40, 40, 45, 49, 49, 49, 46, 46, 42, 42, 42, 40 -}; - -static const uint8_t num_swb_1024_window[] ICONST_ATTR = -{ - 41, 41, 47, 49, 49, 51, 47, 47, 43, 43, 43, 40 -}; - -static const uint8_t num_swb_128_window[] ICONST_ATTR = -{ - 12, 12, 12, 14, 14, 14, 15, 15, 15, 15, 15, 15 -}; - -static const uint16_t swb_offset_1024_96[] = -{ - 0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, - 64, 72, 80, 88, 96, 108, 120, 132, 144, 156, 172, 188, 212, 240, - 276, 320, 384, 448, 512, 576, 640, 704, 768, 832, 896, 960, 1024 -}; - -static const uint16_t swb_offset_128_96[] = -{ - 0, 4, 8, 12, 16, 20, 24, 32, 40, 48, 64, 92, 128 -}; - -static const uint16_t swb_offset_1024_64[] = -{ - 0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, - 64, 72, 80, 88, 100, 112, 124, 140, 156, 172, 192, 216, 240, 268, - 304, 344, 384, 424, 464, 504, 544, 584, 624, 664, 704, 744, 784, 824, - 864, 904, 944, 984, 1024 -}; - -static const uint16_t swb_offset_128_64[] = -{ - 0, 4, 8, 12, 16, 20, 24, 32, 40, 48, 64, 92, 128 -}; - -static const uint16_t swb_offset_1024_48[] ICONST_ATTR = -{ - 0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 48, 56, 64, 72, - 80, 88, 96, 108, 120, 132, 144, 160, 176, 196, 216, 240, 264, 292, - 320, 352, 384, 416, 448, 480, 512, 544, 576, 608, 640, 672, 704, 736, - 768, 800, 832, 864, 896, 928, 1024 -}; - -#ifdef LD_DEC -static const uint16_t swb_offset_512_48[] = -{ - 0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 68, 76, 84, - 92, 100, 112, 124, 136, 148, 164, 184, 208, 236, 268, 300, 332, 364, 396, - 428, 460, 512 -}; - -static const uint16_t swb_offset_480_48[] = -{ - 0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 64, 72 ,80 ,88, - 96, 108, 120, 132, 144, 156, 172, 188, 212, 240, 272, 304, 336, 368, 400, - 432, 480 -}; -#endif - -static const uint16_t swb_offset_128_48[] ICONST_ATTR = -{ - 0, 4, 8, 12, 16, 20, 28, 36, 44, 56, 68, 80, 96, 112, 128 -}; - -static const uint16_t swb_offset_1024_32[] ICONST_ATTR = -{ - 0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 48, 56, 64, 72, - 80, 88, 96, 108, 120, 132, 144, 160, 176, 196, 216, 240, 264, 292, - 320, 352, 384, 416, 448, 480, 512, 544, 576, 608, 640, 672, 704, 736, - 768, 800, 832, 864, 896, 928, 960, 992, 1024 -}; - -#ifdef LD_DEC -static const uint16_t swb_offset_512_32[] = -{ - 0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 64, 72, 80, - 88, 96, 108, 120, 132, 144, 160, 176, 192, 212, 236, 260, 288, 320, 352, - 384, 416, 448, 480, 512 -}; - -static const uint16_t swb_offset_480_32[] = -{ - 0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64, 72, 80, - 88, 96, 104, 112, 124, 136, 148, 164, 180, 200, 224, 256, 288, 320, 352, - 384, 416, 448, 480 -}; -#endif - -static const uint16_t swb_offset_1024_24[] ICONST_ATTR = -{ - 0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 52, 60, 68, - 76, 84, 92, 100, 108, 116, 124, 136, 148, 160, 172, 188, 204, 220, - 240, 260, 284, 308, 336, 364, 396, 432, 468, 508, 552, 600, 652, 704, - 768, 832, 896, 960, 1024 -}; - -#ifdef LD_DEC -static const uint16_t swb_offset_512_24[] = -{ - 0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 52, 60, 68, - 80, 92, 104, 120, 140, 164, 192, 224, 256, 288, 320, 352, 384, 416, - 448, 480, 512 -}; - -static const uint16_t swb_offset_480_24[] = -{ - 0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 52, 60, 68, 80, 92, 104, 120, - 140, 164, 192, 224, 256, 288, 320, 352, 384, 416, 448, 480 -}; -#endif - -static const uint16_t swb_offset_128_24[] ICONST_ATTR = -{ - 0, 4, 8, 12, 16, 20, 24, 28, 36, 44, 52, 64, 76, 92, 108, 128 -}; - -static const uint16_t swb_offset_1024_16[] ICONST_ATTR = -{ - 0, 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 100, 112, 124, - 136, 148, 160, 172, 184, 196, 212, 228, 244, 260, 280, 300, 320, 344, - 368, 396, 424, 456, 492, 532, 572, 616, 664, 716, 772, 832, 896, 960, 1024 -}; - -static const uint16_t swb_offset_128_16[] ICONST_ATTR = -{ - 0, 4, 8, 12, 16, 20, 24, 28, 32, 40, 48, 60, 72, 88, 108, 128 -}; - -static const uint16_t swb_offset_1024_8[] ICONST_ATTR = -{ - 0, 12, 24, 36, 48, 60, 72, 84, 96, 108, 120, 132, 144, 156, 172, - 188, 204, 220, 236, 252, 268, 288, 308, 328, 348, 372, 396, 420, 448, - 476, 508, 544, 580, 620, 664, 712, 764, 820, 880, 944, 1024 -}; - -static const uint16_t swb_offset_128_8[] ICONST_ATTR = -{ - 0, 4, 8, 12, 16, 20, 24, 28, 36, 44, 52, 60, 72, 88, 108, 128 -}; - -static const uint16_t *const swb_offset_1024_window[] ICONST_ATTR = -{ - swb_offset_1024_96, /* 96000 */ - swb_offset_1024_96, /* 88200 */ - swb_offset_1024_64, /* 64000 */ - swb_offset_1024_48, /* 48000 */ - swb_offset_1024_48, /* 44100 */ - swb_offset_1024_32, /* 32000 */ - swb_offset_1024_24, /* 24000 */ - swb_offset_1024_24, /* 22050 */ - swb_offset_1024_16, /* 16000 */ - swb_offset_1024_16, /* 12000 */ - swb_offset_1024_16, /* 11025 */ - swb_offset_1024_8 /* 8000 */ -}; - -#ifdef LD_DEC -static const uint16_t *swb_offset_512_window[] = -{ - 0, /* 96000 */ - 0, /* 88200 */ - 0, /* 64000 */ - swb_offset_512_48, /* 48000 */ - swb_offset_512_48, /* 44100 */ - swb_offset_512_32, /* 32000 */ - swb_offset_512_24, /* 24000 */ - swb_offset_512_24, /* 22050 */ - 0, /* 16000 */ - 0, /* 12000 */ - 0, /* 11025 */ - 0 /* 8000 */ -}; - -static const uint16_t *swb_offset_480_window[] = -{ - 0, /* 96000 */ - 0, /* 88200 */ - 0, /* 64000 */ - swb_offset_480_48, /* 48000 */ - swb_offset_480_48, /* 44100 */ - swb_offset_480_32, /* 32000 */ - swb_offset_480_24, /* 24000 */ - swb_offset_480_24, /* 22050 */ - 0, /* 16000 */ - 0, /* 12000 */ - 0, /* 11025 */ - 0 /* 8000 */ -}; -#endif - -static const uint16_t *const swb_offset_128_window[] ICONST_ATTR = -{ - swb_offset_128_96, /* 96000 */ - swb_offset_128_96, /* 88200 */ - swb_offset_128_64, /* 64000 */ - swb_offset_128_48, /* 48000 */ - swb_offset_128_48, /* 44100 */ - swb_offset_128_48, /* 32000 */ - swb_offset_128_24, /* 24000 */ - swb_offset_128_24, /* 22050 */ - swb_offset_128_16, /* 16000 */ - swb_offset_128_16, /* 12000 */ - swb_offset_128_16, /* 11025 */ - swb_offset_128_8 /* 8000 */ -}; - -#define bit_set(A, B) ((A) & (1<<(B))) - -/* static variables */ -/* used by reconstruct_single_channel() and reconstruct_channel_pair() */ -static real_t spec_coef1[FRAME_LEN] IBSS_ATTR MEM_ALIGN_ATTR; -static real_t spec_coef2[FRAME_LEN] IBSS_ATTR MEM_ALIGN_ATTR; - -/* 4.5.2.3.4 */ -/* - - determine the number of windows in a window_sequence named num_windows - - determine the number of window_groups named num_window_groups - - determine the number of windows in each group named window_group_length[g] - - determine the total number of scalefactor window bands named num_swb for - the actual window type - - determine swb_offset[swb], the offset of the first coefficient in - scalefactor window band named swb of the window actually used - - determine sect_sfb_offset[g][section],the offset of the first coefficient - in section named section. This offset depends on window_sequence and - scale_factor_grouping and is needed to decode the spectral_data(). -*/ -uint8_t window_grouping_info(NeAACDecHandle hDecoder, ic_stream *ics) -{ - uint8_t i, g; - - uint8_t sf_index = hDecoder->sf_index; - - switch (ics->window_sequence) { - case ONLY_LONG_SEQUENCE: - case LONG_START_SEQUENCE: - case LONG_STOP_SEQUENCE: - ics->num_windows = 1; - ics->num_window_groups = 1; - ics->window_group_length[ics->num_window_groups-1] = 1; -#ifdef LD_DEC - if (hDecoder->object_type == LD) - { - if (hDecoder->frameLength == 512) - ics->num_swb = num_swb_512_window[sf_index]; - else /* if (hDecoder->frameLength == 480) */ - ics->num_swb = num_swb_480_window[sf_index]; - } else { -#endif - if (hDecoder->frameLength == 1024) - ics->num_swb = num_swb_1024_window[sf_index]; - else /* if (hDecoder->frameLength == 960) */ - ics->num_swb = num_swb_960_window[sf_index]; -#ifdef LD_DEC - } -#endif - - /* preparation of sect_sfb_offset for long blocks */ - /* also copy the last value! */ -#ifdef LD_DEC - if (hDecoder->object_type == LD) - { - if (hDecoder->frameLength == 512) - { - for (i = 0; i < ics->num_swb; i++) - { - ics->sect_sfb_offset[0][i] = swb_offset_512_window[sf_index][i]; - ics->swb_offset[i] = swb_offset_512_window[sf_index][i]; - } - } else /* if (hDecoder->frameLength == 480) */ { - for (i = 0; i < ics->num_swb; i++) - { - ics->sect_sfb_offset[0][i] = swb_offset_480_window[sf_index][i]; - ics->swb_offset[i] = swb_offset_480_window[sf_index][i]; - } - } - ics->sect_sfb_offset[0][ics->num_swb] = hDecoder->frameLength; - ics->swb_offset[ics->num_swb] = hDecoder->frameLength; - } else { -#endif - for (i = 0; i < ics->num_swb; i++) - { - ics->sect_sfb_offset[0][i] = swb_offset_1024_window[sf_index][i]; - ics->swb_offset[i] = swb_offset_1024_window[sf_index][i]; - } - ics->sect_sfb_offset[0][ics->num_swb] = hDecoder->frameLength; - ics->swb_offset[ics->num_swb] = hDecoder->frameLength; -#ifdef LD_DEC - } -#endif - return 0; - case EIGHT_SHORT_SEQUENCE: - ics->num_windows = 8; - ics->num_window_groups = 1; - ics->window_group_length[ics->num_window_groups-1] = 1; - ics->num_swb = num_swb_128_window[sf_index]; - - for (i = 0; i < ics->num_swb; i++) - ics->swb_offset[i] = swb_offset_128_window[sf_index][i]; - ics->swb_offset[ics->num_swb] = hDecoder->frameLength/8; - - for (i = 0; i < ics->num_windows-1; i++) { - if (bit_set(ics->scale_factor_grouping, 6-i) == 0) - { - ics->num_window_groups += 1; - ics->window_group_length[ics->num_window_groups-1] = 1; - } else { - ics->window_group_length[ics->num_window_groups-1] += 1; - } - } - - /* preparation of sect_sfb_offset for short blocks */ - for (g = 0; g < ics->num_window_groups; g++) - { - uint16_t width; - uint8_t sect_sfb = 0; - uint16_t offset = 0; - - for (i = 0; i < ics->num_swb; i++) - { - if (i+1 == ics->num_swb) - { - width = (hDecoder->frameLength/8) - swb_offset_128_window[sf_index][i]; - } else { - width = swb_offset_128_window[sf_index][i+1] - - swb_offset_128_window[sf_index][i]; - } - width *= ics->window_group_length[g]; - ics->sect_sfb_offset[g][sect_sfb++] = offset; - offset += width; - } - ics->sect_sfb_offset[g][sect_sfb] = offset; - } - return 0; - default: - return 1; - } -} - -/* iquant() */ -/* output = sign(input)*abs(input)^(4/3) */ -/**/ -static INLINE real_t iquant(int16_t q, const real_t *tab, uint8_t *error) -{ -#ifndef BIG_IQ_TABLE -/* For FIXED_POINT the iq_table is prescaled by 3 bits (iq_table[]/8) */ -/* BIG_IQ_TABLE allows you to use the full 8192 value table, if this is not - * defined a 1026 value table and interpolation will be used - */ - static const real_t errcorr[] = { - REAL_CONST(0), REAL_CONST(1.0/8.0), REAL_CONST(2.0/8.0), REAL_CONST(3.0/8.0), - REAL_CONST(4.0/8.0), REAL_CONST(5.0/8.0), REAL_CONST(6.0/8.0), REAL_CONST(7.0/8.0), - REAL_CONST(0) - }; - real_t x1, x2; - - int16_t sgn = 1; - - if (q < 0) - { - q = -q; - sgn = -1; - } - - if (q < IQ_TABLE_SIZE) - { -//#define IQUANT_PRINT -#ifdef IQUANT_PRINT - //printf("0x%.8X\n", sgn * tab[q]); - printf("%d\n", sgn * tab[q]); -#endif - return sgn * tab[q]; - } - - if (q >= 8192) - { - *error = 17; - return 0; - } - - /* linear interpolation */ - x1 = tab[q>>3]; - x2 = tab[(q>>3) + 1]; - return sgn * 16 * (MUL_R(errcorr[q&7],(x2-x1)) + x1); -#else /* #ifndef BIG_IQ_TABLE */ - if (q < 0) - { - /* tab contains a value for all possible q [0,8192] */ - if (LIKELY(-q < IQ_TABLE_SIZE)) - return -tab[-q]; - - *error = 17; - return 0; - } else { - /* tab contains a value for all possible q [0,8192] */ - if (LIKELY(q < IQ_TABLE_SIZE)) - return tab[q]; - - *error = 17; - return 0; - } -#endif -} - -#ifndef FIXED_POINT -static const real_t pow2sf_tab[] = { - 2.9802322387695313E-008, 5.9604644775390625E-008, 1.1920928955078125E-007, - 2.384185791015625E-007, 4.76837158203125E-007, 9.5367431640625E-007, - 1.9073486328125E-006, 3.814697265625E-006, 7.62939453125E-006, - 1.52587890625E-005, 3.0517578125E-005, 6.103515625E-005, - 0.0001220703125, 0.000244140625, 0.00048828125, - 0.0009765625, 0.001953125, 0.00390625, - 0.0078125, 0.015625, 0.03125, - 0.0625, 0.125, 0.25, - 0.5, 1.0, 2.0, - 4.0, 8.0, 16.0, 32.0, - 64.0, 128.0, 256.0, - 512.0, 1024.0, 2048.0, - 4096.0, 8192.0, 16384.0, - 32768.0, 65536.0, 131072.0, - 262144.0, 524288.0, 1048576.0, - 2097152.0, 4194304.0, 8388608.0, - 16777216.0, 33554432.0, 67108864.0, - 134217728.0, 268435456.0, 536870912.0, - 1073741824.0, 2147483648.0, 4294967296.0, - 8589934592.0, 17179869184.0, 34359738368.0, - 68719476736.0, 137438953472.0, 274877906944.0 -}; -#endif - -/* quant_to_spec: perform dequantisation and scaling - * and in case of short block it also does the deinterleaving - */ -/* - For ONLY_LONG_SEQUENCE windows (num_window_groups = 1, - window_group_length[0] = 1) the spectral data is in ascending spectral - order. - For the EIGHT_SHORT_SEQUENCE window, the spectral order depends on the - grouping in the following manner: - - Groups are ordered sequentially - - Within a group, a scalefactor band consists of the spectral data of all - grouped SHORT_WINDOWs for the associated scalefactor window band. To - clarify via example, the length of a group is in the range of one to eight - SHORT_WINDOWs. - - If there are eight groups each with length one (num_window_groups = 8, - window_group_length[0..7] = 1), the result is a sequence of eight spectra, - each in ascending spectral order. - - If there is only one group with length eight (num_window_groups = 1, - window_group_length[0] = 8), the result is that spectral data of all eight - SHORT_WINDOWs is interleaved by scalefactor window bands. - - Within a scalefactor window band, the coefficients are in ascending - spectral order. -*/ -static const real_t pow2_table[] ICONST_ATTR = -{ - COEF_CONST(1.0), - COEF_CONST(1.1892071150027210667174999705605), /* 2^0.25 */ - COEF_CONST(1.4142135623730950488016887242097), /* 2^0.50 */ - COEF_CONST(1.6817928305074290860622509524664) /* 2^0.75 */ -}; -static uint8_t quant_to_spec(NeAACDecHandle hDecoder, - ic_stream *ics, int16_t *quant_data, - real_t *spec_data, uint16_t frame_len) -{ - const real_t *tab = iq_table; - - (void)frame_len; - uint8_t g, sfb, win; - uint16_t width, bin, k, gindex, wa, wb; - uint8_t error = 0; /* Init error flag */ - real_t scf; - - k = 0; - gindex = 0; - - for (g = 0; g < ics->num_window_groups; g++) - { - uint16_t j = 0; - uint16_t gincrease = 0; - uint16_t win_inc = ics->swb_offset[ics->num_swb]; - - for (sfb = 0; sfb < ics->num_swb; sfb++) - { - int32_t exp, frac; - - width = ics->swb_offset[sfb+1] - ics->swb_offset[sfb]; - - /* this could be scalefactor for IS or PNS, those can be negative or bigger then 255 */ - /* just ignore them */ - if (ics->scale_factors[g][sfb] < 0 || ics->scale_factors[g][sfb] > 255) - { - exp = 0; - frac = 0; - } else { - /* ics->scale_factors[g][sfb] must be between 0 and 255 */ - exp = (ics->scale_factors[g][sfb] /* - 100 */) >> 2; - /* frac must always be > 0 */ - frac = (ics->scale_factors[g][sfb] /* - 100 */) & 3; - } - -#ifdef FIXED_POINT - exp -= 25; - /* IMDCT pre-scaling */ - if (hDecoder->object_type == LD) - { - exp -= 6 /*9*/; - } else { - if (ics->window_sequence == EIGHT_SHORT_SEQUENCE) - exp -= 4 /*7*/; - else - exp -= 7 /*10*/; - } -#endif - - wa = gindex + j; - -#ifndef FIXED_POINT - scf = pow2sf_tab[exp/*+25*/] * pow2_table[frac]; -#else - scf = pow2_table[frac]; -#endif - - for (win = 0; win < ics->window_group_length[g]; win++) - { - for (bin = 0; bin < width; bin += 4) - { -#ifndef FIXED_POINT - wb = wa + bin; - - spec_data[wb+0] = iquant(quant_data[k+0], tab, &error) * scf; - spec_data[wb+1] = iquant(quant_data[k+1], tab, &error) * scf; - spec_data[wb+2] = iquant(quant_data[k+2], tab, &error) * scf; - spec_data[wb+3] = iquant(quant_data[k+3], tab, &error) * scf; - -#else - wb = wa + bin; - - if (exp>=0) - { - spec_data[wb+0] = MUL_C((iquant(quant_data[k+0], tab, &error)<< exp), scf); - spec_data[wb+1] = MUL_C((iquant(quant_data[k+1], tab, &error)<< exp), scf); - spec_data[wb+2] = MUL_C((iquant(quant_data[k+2], tab, &error)<< exp), scf); - spec_data[wb+3] = MUL_C((iquant(quant_data[k+3], tab, &error)<< exp), scf); - } else { - spec_data[wb+0] = MUL_C((iquant(quant_data[k+0], tab, &error)>>-exp), scf); - spec_data[wb+1] = MUL_C((iquant(quant_data[k+1], tab, &error)>>-exp), scf); - spec_data[wb+2] = MUL_C((iquant(quant_data[k+2], tab, &error)>>-exp), scf); - spec_data[wb+3] = MUL_C((iquant(quant_data[k+3], tab, &error)>>-exp), scf); - } -//#define SCFS_PRINT -#ifdef SCFS_PRINT - printf("%d\n", spec_data[gindex+(win*win_inc)+j+bin+0]); - printf("%d\n", spec_data[gindex+(win*win_inc)+j+bin+1]); - printf("%d\n", spec_data[gindex+(win*win_inc)+j+bin+2]); - printf("%d\n", spec_data[gindex+(win*win_inc)+j+bin+3]); - //printf("0x%.8X\n", spec_data[gindex+(win*win_inc)+j+bin+0]); - //printf("0x%.8X\n", spec_data[gindex+(win*win_inc)+j+bin+1]); - //printf("0x%.8X\n", spec_data[gindex+(win*win_inc)+j+bin+2]); - //printf("0x%.8X\n", spec_data[gindex+(win*win_inc)+j+bin+3]); -#endif -#endif - - gincrease += 4; - k += 4; - } - wa += win_inc; - } - j += width; - } - gindex += gincrease; - } - - return error; -} - -static uint8_t allocate_single_channel(NeAACDecHandle hDecoder, uint8_t channel, - uint8_t output_channels) -{ - (void)output_channels; - (void)hDecoder; - (void)channel; - return 0; -} - -static uint8_t allocate_channel_pair(NeAACDecHandle hDecoder, - uint8_t channel, uint8_t paired_channel) -{ - (void)paired_channel; - (void)hDecoder; - (void)channel; - return 0; -} - -uint8_t reconstruct_single_channel(NeAACDecHandle hDecoder, ic_stream *ics, - element *sce, int16_t *spec_data) -{ - uint8_t retval, output_channels; - -#ifdef PROFILE - int64_t count = faad_get_ts(); -#endif - - - /* always allocate 2 channels, PS can always "suddenly" turn up */ -#if (defined(PS_DEC) || defined(DRM_PS)) - output_channels = 2; -#else - output_channels = 1; -#endif - - if (hDecoder->element_output_channels[hDecoder->fr_ch_ele] == 0) - { - /* element_output_channels not set yet */ - hDecoder->element_output_channels[hDecoder->fr_ch_ele] = output_channels; - } else if (hDecoder->element_output_channels[hDecoder->fr_ch_ele] != output_channels) { - /* element inconsistency */ - return 21; - } - - if (hDecoder->element_alloced[hDecoder->fr_ch_ele] == 0) - { - retval = allocate_single_channel(hDecoder, sce->channel, output_channels); - if (retval > 0) - return retval; - - hDecoder->element_alloced[hDecoder->fr_ch_ele] = 1; - } - - - /* dequantisation and scaling */ - retval = quant_to_spec(hDecoder, ics, spec_data, spec_coef1, hDecoder->frameLength); - if (retval > 0) - return retval; - -#ifdef PROFILE - count = faad_get_ts() - count; - hDecoder->requant_cycles += count; -#endif - - - /* pns decoding */ - pns_decode(ics, NULL, spec_coef1, NULL, hDecoder->frameLength, 0, hDecoder->object_type); - -#ifdef MAIN_DEC - /* MAIN object type prediction */ - if (hDecoder->object_type == MAIN) - { - /* intra channel prediction */ - ic_prediction(ics, spec_coef1, hDecoder->pred_stat[sce->channel], hDecoder->frameLength, - hDecoder->sf_index); - - /* In addition, for scalefactor bands coded by perceptual - noise substitution the predictors belonging to the - corresponding spectral coefficients are reset. - */ - pns_reset_pred_state(ics, hDecoder->pred_stat[sce->channel]); - } -#endif - -#ifdef LTP_DEC - if (is_ltp_ot(hDecoder->object_type)) - { -#ifdef LD_DEC - if (hDecoder->object_type == LD) - { - if (ics->ltp.data_present) - { - if (ics->ltp.lag_update) - hDecoder->ltp_lag[sce->channel] = ics->ltp.lag; - } - ics->ltp.lag = hDecoder->ltp_lag[sce->channel]; - } -#endif - - /* long term prediction */ - lt_prediction(ics, &(ics->ltp), spec_coef1, hDecoder->lt_pred_stat[sce->channel], hDecoder->fb, - ics->window_shape, hDecoder->window_shape_prev[sce->channel], - hDecoder->sf_index, hDecoder->object_type, hDecoder->frameLength); - } -#endif - - /* tns decoding */ - tns_decode_frame(ics, &(ics->tns), hDecoder->sf_index, hDecoder->object_type, - spec_coef1, hDecoder->frameLength); - - /* drc decoding */ - if (hDecoder->drc->present) - { - if (!hDecoder->drc->exclude_mask[sce->channel] || !hDecoder->drc->excluded_chns_present) - drc_decode(hDecoder->drc, spec_coef1); - } - - /* filter bank */ -#ifdef SSR_DEC - if (hDecoder->object_type != SSR) - { -#endif - ifilter_bank(ics->window_sequence,ics->window_shape, - hDecoder->window_shape_prev[sce->channel],spec_coef1, - hDecoder->time_out[sce->channel], hDecoder->fb_intermed[sce->channel], - hDecoder->object_type, hDecoder->frameLength); -#ifdef SSR_DEC - } else { - ssr_decode(&(ics->ssr), hDecoder->fb, ics->window_sequence, ics->window_shape, - hDecoder->window_shape_prev[sce->channel], spec_coef1, hDecoder->time_out[sce->channel], - hDecoder->ssr_overlap[sce->channel], hDecoder->ipqf_buffer[sce->channel], hDecoder->prev_fmd[sce->channel], - hDecoder->frameLength); - } -#endif - - /* save window shape for next frame */ - hDecoder->window_shape_prev[sce->channel] = ics->window_shape; - -#ifdef LTP_DEC - if (is_ltp_ot(hDecoder->object_type)) - { - lt_update_state(hDecoder->lt_pred_stat[sce->channel], hDecoder->time_out[sce->channel], - hDecoder->fb_intermed[sce->channel], hDecoder->frameLength, hDecoder->object_type); - } -#endif - -#ifdef SBR_DEC - if (((hDecoder->sbr_present_flag == 1) || (hDecoder->forceUpSampling == 1)) - && hDecoder->sbr_alloced[hDecoder->fr_ch_ele]) - { - uint8_t ele = hDecoder->fr_ch_ele; - uint8_t ch = sce->channel; - - /* following case can happen when forceUpSampling == 1 */ - if (hDecoder->sbr[ele] == NULL) - { - hDecoder->sbr[ele] = sbrDecodeInit(hDecoder->frameLength, - hDecoder->element_id[ele], ele, - 2*get_sample_rate(hDecoder->sf_index), - hDecoder->downSampledSBR, 0); -#ifndef FAAD_STATIC_ALLOC - if (hDecoder->sbr[ele] == NULL) - { - /* could not allocate memory */ - return 28; - } -#endif - } - - if (sce->ics1.window_sequence == EIGHT_SHORT_SEQUENCE) - hDecoder->sbr[ele]->maxAACLine = 8*sce->ics1.swb_offset[max(sce->ics1.max_sfb-1, 0)]; - else - hDecoder->sbr[ele]->maxAACLine = sce->ics1.swb_offset[max(sce->ics1.max_sfb-1, 0)]; - - /* check if any of the PS tools is used */ -#if (defined(PS_DEC) || defined(DRM_PS)) - if (hDecoder->ps_used[ele] == 0) - { -#endif - retval = sbrDecodeSingleFrame(hDecoder->sbr[ele], hDecoder->time_out[ch], - hDecoder->postSeekResetFlag, hDecoder->downSampledSBR); -#if (defined(PS_DEC) || defined(DRM_PS)) - } else { - retval = sbrDecodeSingleFramePS(hDecoder->sbr[ele], hDecoder->time_out[ch], - hDecoder->time_out[ch+1], hDecoder->postSeekResetFlag, - hDecoder->downSampledSBR); - } -#endif - if (retval > 0) - return retval; - } else if (((hDecoder->sbr_present_flag == 1) || (hDecoder->forceUpSampling == 1)) - && !hDecoder->sbr_alloced[hDecoder->fr_ch_ele]) - { - return 23; - } -#endif - - /* copy L to R when no PS is used */ -#if (defined(PS_DEC) || defined(DRM_PS)) - if ((hDecoder->ps_used[hDecoder->fr_ch_ele] == 0)) - { - uint8_t ele = hDecoder->fr_ch_ele; - uint8_t ch = sce->channel; - uint16_t frame_size = (hDecoder->sbr_alloced[ele]) ? 2 : 1; - frame_size *= hDecoder->frameLength*sizeof(real_t); - - memcpy(hDecoder->time_out[ch+1], hDecoder->time_out[ch], frame_size); - } -#endif - - return 0; -} - -uint8_t reconstruct_channel_pair(NeAACDecHandle hDecoder, ic_stream *ics1, ic_stream *ics2, - element *cpe, int16_t *spec_data1, int16_t *spec_data2) -{ - uint8_t retval; - -#ifdef PROFILE - int64_t count = faad_get_ts(); -#endif - if (hDecoder->element_alloced[hDecoder->fr_ch_ele] == 0) - { - retval = allocate_channel_pair(hDecoder, cpe->channel, (uint8_t)cpe->paired_channel); - if (retval > 0) - return retval; - - hDecoder->element_alloced[hDecoder->fr_ch_ele] = 1; - } - - /* dequantisation and scaling */ - retval = quant_to_spec(hDecoder, ics1, spec_data1, spec_coef1, hDecoder->frameLength); - if (retval > 0) - return retval; - retval = quant_to_spec(hDecoder, ics2, spec_data2, spec_coef2, hDecoder->frameLength); - if (retval > 0) - return retval; - -#ifdef PROFILE - count = faad_get_ts() - count; - hDecoder->requant_cycles += count; -#endif - - - /* pns decoding */ - if (ics1->ms_mask_present) - { - pns_decode(ics1, ics2, spec_coef1, spec_coef2, hDecoder->frameLength, 1, hDecoder->object_type); - } else { - pns_decode(ics1, NULL, spec_coef1, NULL, hDecoder->frameLength, 0, hDecoder->object_type); - pns_decode(ics2, NULL, spec_coef2, NULL, hDecoder->frameLength, 0, hDecoder->object_type); - } - - /* mid/side decoding */ - ms_decode(ics1, ics2, spec_coef1, spec_coef2, hDecoder->frameLength); - -#if 0 - { - int i; - for (i = 0; i < 1024; i++) - { - //printf("%d\n", spec_coef1[i]); - printf("0x%.8X\n", spec_coef1[i]); - } - for (i = 0; i < 1024; i++) - { - //printf("%d\n", spec_coef2[i]); - printf("0x%.8X\n", spec_coef2[i]); - } - } -#endif - - /* intensity stereo decoding */ - is_decode(ics1, ics2, spec_coef1, spec_coef2, hDecoder->frameLength); - -#if 0 - { - int i; - for (i = 0; i < 1024; i++) - { - printf("%d\n", spec_coef1[i]); - //printf("0x%.8X\n", spec_coef1[i]); - } - for (i = 0; i < 1024; i++) - { - printf("%d\n", spec_coef2[i]); - //printf("0x%.8X\n", spec_coef2[i]); - } - } -#endif - -#ifdef MAIN_DEC - /* MAIN object type prediction */ - if (hDecoder->object_type == MAIN) - { - /* intra channel prediction */ - ic_prediction(ics1, spec_coef1, hDecoder->pred_stat[cpe->channel], hDecoder->frameLength, - hDecoder->sf_index); - ic_prediction(ics2, spec_coef2, hDecoder->pred_stat[cpe->paired_channel], hDecoder->frameLength, - hDecoder->sf_index); - - /* In addition, for scalefactor bands coded by perceptual - noise substitution the predictors belonging to the - corresponding spectral coefficients are reset. - */ - pns_reset_pred_state(ics1, hDecoder->pred_stat[cpe->channel]); - pns_reset_pred_state(ics2, hDecoder->pred_stat[cpe->paired_channel]); - } -#endif - -#ifdef LTP_DEC - if (is_ltp_ot(hDecoder->object_type)) - { - ltp_info *ltp1 = &(ics1->ltp); - ltp_info *ltp2 = (cpe->common_window) ? &(ics2->ltp2) : &(ics2->ltp); -#ifdef LD_DEC - if (hDecoder->object_type == LD) - { - if (ltp1->data_present) - { - if (ltp1->lag_update) - hDecoder->ltp_lag[cpe->channel] = ltp1->lag; - } - ltp1->lag = hDecoder->ltp_lag[cpe->channel]; - if (ltp2->data_present) - { - if (ltp2->lag_update) - hDecoder->ltp_lag[cpe->paired_channel] = ltp2->lag; - } - ltp2->lag = hDecoder->ltp_lag[cpe->paired_channel]; - } -#endif - - /* long term prediction */ - lt_prediction(ics1, ltp1, spec_coef1, hDecoder->lt_pred_stat[cpe->channel], hDecoder->fb, - ics1->window_shape, hDecoder->window_shape_prev[cpe->channel], - hDecoder->sf_index, hDecoder->object_type, hDecoder->frameLength); - lt_prediction(ics2, ltp2, spec_coef2, hDecoder->lt_pred_stat[cpe->paired_channel], hDecoder->fb, - ics2->window_shape, hDecoder->window_shape_prev[cpe->paired_channel], - hDecoder->sf_index, hDecoder->object_type, hDecoder->frameLength); - } -#endif - - /* tns decoding */ - tns_decode_frame(ics1, &(ics1->tns), hDecoder->sf_index, hDecoder->object_type, - spec_coef1, hDecoder->frameLength); - tns_decode_frame(ics2, &(ics2->tns), hDecoder->sf_index, hDecoder->object_type, - spec_coef2, hDecoder->frameLength); - - /* drc decoding */ - if (hDecoder->drc->present) - { - if (!hDecoder->drc->exclude_mask[cpe->channel] || !hDecoder->drc->excluded_chns_present) - drc_decode(hDecoder->drc, spec_coef1); - if (!hDecoder->drc->exclude_mask[cpe->paired_channel] || !hDecoder->drc->excluded_chns_present) - drc_decode(hDecoder->drc, spec_coef2); - } - - /* filter bank */ -#ifdef SSR_DEC - if (hDecoder->object_type != SSR) - { -#endif - ifilter_bank(ics1->window_sequence,ics1->window_shape, - hDecoder->window_shape_prev[cpe->channel],spec_coef1, - hDecoder->time_out[cpe->channel], hDecoder->fb_intermed[cpe->channel], - hDecoder->object_type, hDecoder->frameLength); - ifilter_bank(ics2->window_sequence,ics2->window_shape, - hDecoder->window_shape_prev[cpe->paired_channel], spec_coef2, - hDecoder->time_out[cpe->paired_channel], hDecoder->fb_intermed[cpe->paired_channel], - hDecoder->object_type, hDecoder->frameLength); -#ifdef SSR_DEC - } else { - ssr_decode(&(ics1->ssr), hDecoder->fb, ics1->window_sequence, ics1->window_shape, - hDecoder->window_shape_prev[cpe->channel], spec_coef1, hDecoder->time_out[cpe->channel], - hDecoder->ssr_overlap[cpe->channel], hDecoder->ipqf_buffer[cpe->channel], - hDecoder->prev_fmd[cpe->channel], hDecoder->frameLength); - ssr_decode(&(ics2->ssr), hDecoder->fb, ics2->window_sequence, ics2->window_shape, - hDecoder->window_shape_prev[cpe->paired_channel], spec_coef2, hDecoder->time_out[cpe->paired_channel], - hDecoder->ssr_overlap[cpe->paired_channel], hDecoder->ipqf_buffer[cpe->paired_channel], - hDecoder->prev_fmd[cpe->paired_channel], hDecoder->frameLength); - } -#endif - - /* save window shape for next frame */ - hDecoder->window_shape_prev[cpe->channel] = ics1->window_shape; - hDecoder->window_shape_prev[cpe->paired_channel] = ics2->window_shape; - -#ifdef LTP_DEC - if (is_ltp_ot(hDecoder->object_type)) - { - lt_update_state(hDecoder->lt_pred_stat[cpe->channel], hDecoder->time_out[cpe->channel], - hDecoder->fb_intermed[cpe->channel], hDecoder->frameLength, hDecoder->object_type); - lt_update_state(hDecoder->lt_pred_stat[cpe->paired_channel], hDecoder->time_out[cpe->paired_channel], - hDecoder->fb_intermed[cpe->paired_channel], hDecoder->frameLength, hDecoder->object_type); - } -#endif - -#ifdef SBR_DEC - if (((hDecoder->sbr_present_flag == 1) || (hDecoder->forceUpSampling == 1)) - && hDecoder->sbr_alloced[hDecoder->fr_ch_ele]) - { - uint8_t ele = hDecoder->fr_ch_ele; - uint8_t ch0 = cpe->channel; - uint8_t ch1 = cpe->paired_channel; - - /* following case can happen when forceUpSampling == 1 */ - if (hDecoder->sbr[ele] == NULL) - { - hDecoder->sbr[ele] = sbrDecodeInit(hDecoder->frameLength, - hDecoder->element_id[ele], ele, - 2*get_sample_rate(hDecoder->sf_index), - hDecoder->downSampledSBR, 0); -#ifndef FAAD_STATIC_ALLOC - if (hDecoder->sbr[ele] == NULL) - { - /* could not allocate memory */ - return 28; - } -#endif - } - - if (cpe->ics1.window_sequence == EIGHT_SHORT_SEQUENCE) - hDecoder->sbr[ele]->maxAACLine = 8*cpe->ics1.swb_offset[max(cpe->ics1.max_sfb-1, 0)]; - else - hDecoder->sbr[ele]->maxAACLine = cpe->ics1.swb_offset[max(cpe->ics1.max_sfb-1, 0)]; - - retval = sbrDecodeCoupleFrame(hDecoder->sbr[ele], - hDecoder->time_out[ch0], hDecoder->time_out[ch1], - hDecoder->postSeekResetFlag, hDecoder->downSampledSBR); - if (retval > 0) - return retval; - } else if (((hDecoder->sbr_present_flag == 1) || (hDecoder->forceUpSampling == 1)) - && !hDecoder->sbr_alloced[hDecoder->fr_ch_ele]) - { - return 23; - } -#endif - - return 0; -} diff --git a/apps/codecs/libfaad/specrec.h b/apps/codecs/libfaad/specrec.h deleted file mode 100644 index c3540ac973..0000000000 --- a/apps/codecs/libfaad/specrec.h +++ /dev/null @@ -1,46 +0,0 @@ -/* -** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -** -** Any non-GPL usage of this software or parts of this software is strictly -** forbidden. -** -** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. -** -** $Id$ -**/ - -#ifndef __SPECREC_H__ -#define __SPECREC_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -#include "syntax.h" - -uint8_t window_grouping_info(NeAACDecHandle hDecoder, ic_stream *ics); -uint8_t reconstruct_channel_pair(NeAACDecHandle hDecoder, ic_stream *ics1, ic_stream *ics2, - element *cpe, int16_t *spec_data1, int16_t *spec_data2); -uint8_t reconstruct_single_channel(NeAACDecHandle hDecoder, ic_stream *ics, element *sce, - int16_t *spec_data); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/apps/codecs/libfaad/structs.h b/apps/codecs/libfaad/structs.h deleted file mode 100644 index a6114f412a..0000000000 --- a/apps/codecs/libfaad/structs.h +++ /dev/null @@ -1,473 +0,0 @@ -/* -** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -** -** Any non-GPL usage of this software or parts of this software is strictly -** forbidden. -** -** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. -** -** $Id$ -**/ - -#ifndef __STRUCTS_H__ -#define __STRUCTS_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -//#include "cfft.h" -#ifdef SBR_DEC -#include "sbr_dec.h" -#endif - -#define MAX_CHANNELS 2 /* Was 64, but we need to limit RAM usage */ -#define MAX_SYNTAX_ELEMENTS 1 /* Was 48, but we need to limit RAM usage */ -#define MAX_WINDOW_GROUPS 8 -#define MAX_SFB 51 -#define MAX_LTP_SFB 40 -#define MAX_LTP_SFB_S 8 -#define FRAME_LEN 1024 - -#define DRC_MAX_CHANNELS 64 /* Should be the same as MAX_CHANNELS, but the DRC code expects 64 */ - -/* used to save the prediction state */ -typedef struct { - int16_t r[2]; - int16_t COR[2]; - int16_t VAR[2]; -} pred_state; - -typedef struct { - uint16_t N; - //cfft_info *cfft; - complex_t *sincos; -#ifdef PROFILE - int64_t cycles; - int64_t fft_cycles; -#endif -} mdct_info; - -typedef struct -{ - const real_t *long_window[2]; - const real_t *short_window[2]; -#ifdef LD_DEC - const real_t *ld_window[2]; -#endif - - mdct_info *mdct256; -#ifdef LD_DEC - mdct_info *mdct1024; -#endif - mdct_info *mdct2048; -#ifdef PROFILE - int64_t cycles; -#endif -} fb_info; - -typedef struct -{ - uint8_t present; - - uint8_t num_bands; - uint8_t pce_instance_tag; - uint8_t excluded_chns_present; - uint8_t band_top[17]; - uint8_t prog_ref_level; - uint8_t dyn_rng_sgn[17]; - uint8_t dyn_rng_ctl[17]; - uint8_t exclude_mask[DRC_MAX_CHANNELS]; - uint8_t additional_excluded_chns[DRC_MAX_CHANNELS/7]; - - real_t ctrl1; - real_t ctrl2; -} drc_info; - -typedef struct -{ - uint8_t element_instance_tag; - uint8_t object_type; - uint8_t sf_index; - uint8_t num_front_channel_elements; - uint8_t num_side_channel_elements; - uint8_t num_back_channel_elements; - uint8_t num_lfe_channel_elements; - uint8_t num_assoc_data_elements; - uint8_t num_valid_cc_elements; - uint8_t mono_mixdown_present; - uint8_t mono_mixdown_element_number; - uint8_t stereo_mixdown_present; - uint8_t stereo_mixdown_element_number; - uint8_t matrix_mixdown_idx_present; - uint8_t pseudo_surround_enable; - uint8_t matrix_mixdown_idx; - uint8_t front_element_is_cpe[16]; - uint8_t front_element_tag_select[16]; - uint8_t side_element_is_cpe[16]; - uint8_t side_element_tag_select[16]; - uint8_t back_element_is_cpe[16]; - uint8_t back_element_tag_select[16]; - uint8_t lfe_element_tag_select[16]; - uint8_t assoc_data_element_tag_select[16]; - uint8_t cc_element_is_ind_sw[16]; - uint8_t valid_cc_element_tag_select[16]; - - uint8_t channels; - - uint8_t comment_field_bytes; - uint8_t comment_field_data[257]; - - /* extra added values */ - uint8_t num_front_channels; - uint8_t num_side_channels; - uint8_t num_back_channels; - uint8_t num_lfe_channels; - uint8_t sce_channel[16]; - uint8_t cpe_channel[16]; -} program_config; - -typedef struct -{ - uint16_t syncword; - uint8_t id; - uint8_t layer; - uint8_t protection_absent; - uint8_t profile; - uint8_t sf_index; - uint8_t private_bit; - uint8_t channel_configuration; - uint8_t original; - uint8_t home; - uint8_t emphasis; - uint8_t copyright_identification_bit; - uint8_t copyright_identification_start; - uint16_t aac_frame_length; - uint16_t adts_buffer_fullness; - uint8_t no_raw_data_blocks_in_frame; - uint16_t crc_check; - - /* control param */ - uint8_t old_format; -} adts_header; - -typedef struct -{ - uint8_t copyright_id_present; - int8_t copyright_id[10]; - uint8_t original_copy; - uint8_t home; - uint8_t bitstream_type; - uint32_t bitrate; - uint8_t num_program_config_elements; - uint32_t adif_buffer_fullness; - - /* maximum of 16 PCEs */ - program_config pce[16]; -} adif_header; - -#ifdef LTP_DEC -typedef struct -{ - uint8_t last_band; - uint8_t data_present; - uint16_t lag; - uint8_t lag_update; - uint8_t coef; - uint8_t long_used[MAX_SFB]; - uint8_t short_used[8]; - uint8_t short_lag_present[8]; - uint8_t short_lag[8]; -} ltp_info; -#endif - -#ifdef MAIN_DEC -typedef struct -{ - uint8_t limit; - uint8_t predictor_reset; - uint8_t predictor_reset_group_number; - uint8_t prediction_used[MAX_SFB]; -} pred_info; -#endif - -typedef struct -{ - uint8_t number_pulse; - uint8_t pulse_start_sfb; - uint8_t pulse_offset[4]; - uint8_t pulse_amp[4]; -} pulse_info; - -typedef struct -{ - uint8_t n_filt[8]; - uint8_t coef_res[8]; - uint8_t length[8][4]; - uint8_t order[8][4]; - uint8_t direction[8][4]; - uint8_t coef_compress[8][4]; - uint8_t coef[8][4][32]; -} tns_info; - -#ifdef SSR_DEC -typedef struct -{ - uint8_t max_band; - - uint8_t adjust_num[4][8]; - uint8_t alevcode[4][8][8]; - uint8_t aloccode[4][8][8]; -} ssr_info; -#endif - -typedef struct -{ - uint8_t max_sfb; - - uint8_t num_swb; - uint8_t num_window_groups; - uint8_t num_windows; - uint8_t window_sequence; - uint8_t window_group_length[8]; - uint8_t window_shape; - uint8_t scale_factor_grouping; - uint16_t sect_sfb_offset[8][15*8]; - uint16_t swb_offset[52]; - - uint8_t sect_cb[8][15*8]; - uint16_t sect_start[8][15*8]; - uint16_t sect_end[8][15*8]; - uint8_t sfb_cb[8][8*15]; - uint8_t num_sec[8]; /* number of sections in a group */ - - uint8_t global_gain; - int16_t scale_factors[8][51]; /* [0..255] */ - - uint8_t ms_mask_present; - uint8_t ms_used[MAX_WINDOW_GROUPS][MAX_SFB]; - - uint8_t noise_used; - - uint8_t pulse_data_present; - uint8_t tns_data_present; - uint8_t gain_control_data_present; - uint8_t predictor_data_present; - - pulse_info pul; - tns_info tns; -#ifdef MAIN_DEC - pred_info pred; -#endif -#ifdef LTP_DEC - ltp_info ltp; - ltp_info ltp2; -#endif -#ifdef SSR_DEC - ssr_info ssr; -#endif - -#ifdef ERROR_RESILIENCE - /* ER HCR data */ - uint16_t length_of_reordered_spectral_data; - uint8_t length_of_longest_codeword; - /* ER RLVC data */ - uint8_t sf_concealment; - uint8_t rev_global_gain; - uint16_t length_of_rvlc_sf; - uint16_t dpcm_noise_nrg; - uint8_t sf_escapes_present; - uint8_t length_of_rvlc_escapes; - uint16_t dpcm_noise_last_position; -#endif -} ic_stream; /* individual channel stream */ - -typedef struct -{ - uint8_t channel; - int16_t paired_channel; - - uint8_t element_instance_tag; - uint8_t common_window; - - ic_stream ics1; - ic_stream ics2; -} element; /* syntax element (SCE, CPE, LFE) */ - -typedef struct mp4AudioSpecificConfig -{ - /* Audio Specific Info */ - /*uint8_t*/ unsigned char objectTypeIndex; - /*uint8_t*/ unsigned char samplingFrequencyIndex; - /*uint32_t*/ unsigned long samplingFrequency; - /*uint8_t*/ unsigned char channelsConfiguration; - - /* GA Specific Info */ - /*uint8_t*/ unsigned char frameLengthFlag; - /*uint8_t*/ unsigned char dependsOnCoreCoder; - /*uint16_t*/ unsigned short coreCoderDelay; - /*uint8_t*/ unsigned char extensionFlag; - /*uint8_t*/ unsigned char aacSectionDataResilienceFlag; - /*uint8_t*/ unsigned char aacScalefactorDataResilienceFlag; - /*uint8_t*/ unsigned char aacSpectralDataResilienceFlag; - /*uint8_t*/ unsigned char epConfig; - - /*uint8_t*/ signed char sbr_present_flag; - /*uint8_t*/ char forceUpSampling; - /*uint8_t*/ char downSampledSBR; -} mp4AudioSpecificConfig; - -typedef struct NeAACDecConfiguration -{ - /*uint8_t*/ unsigned char defObjectType; - /*uint32_t*/ unsigned long defSampleRate; - /*uint8_t*/ unsigned char outputFormat; - /*uint8_t*/ unsigned char downMatrix; - /*uint8_t*/ unsigned char useOldADTSFormat; - /*uint8_t*/ unsigned char dontUpSampleImplicitSBR; -} NeAACDecConfiguration, *NeAACDecConfigurationPtr; - -typedef struct NeAACDecFrameInfo -{ - /*uint32_t*/ unsigned long bytesconsumed; - /*uint32_t*/ unsigned long samples; - /*uint8_t*/ unsigned char channels; - /*uint8_t*/ unsigned char error; - /*uint32_t*/ unsigned long samplerate; - - /* SBR: 0: off, 1: on; normal, 2: on; downsampled */ - /*uint8_t*/ unsigned char sbr; - - /* MPEG-4 ObjectType */ - /*uint8_t*/ unsigned char object_type; - - /* AAC header type; MP4 will be signalled as RAW also */ - /*uint8_t*/ unsigned char header_type; - - /* multichannel configuration */ - /*uint8_t*/ unsigned char num_front_channels; - /*uint8_t*/ unsigned char num_side_channels; - /*uint8_t*/ unsigned char num_back_channels; - /*uint8_t*/ unsigned char num_lfe_channels; - /*uint8_t*/ unsigned char channel_position[MAX_CHANNELS]; - - /* PS: 0: off, 1: on */ - /*uint8_t*/ unsigned char ps; -} NeAACDecFrameInfo; - -typedef struct -{ - uint8_t adts_header_present; - uint8_t adif_header_present; - uint8_t sf_index; - uint8_t object_type; - uint8_t channelConfiguration; -#ifdef ERROR_RESILIENCE - uint8_t aacSectionDataResilienceFlag; - uint8_t aacScalefactorDataResilienceFlag; - uint8_t aacSpectralDataResilienceFlag; -#endif - uint16_t frameLength; - uint8_t postSeekResetFlag; - - uint32_t frame; - - uint8_t downMatrix; - uint8_t upMatrix; - uint8_t first_syn_ele; - uint8_t has_lfe; - /* number of channels in current frame */ - uint8_t fr_channels; - /* number of elements in current frame */ - uint8_t fr_ch_ele; - - /* element_output_channels: - determines the number of channels the element will output - */ - uint8_t element_output_channels[MAX_SYNTAX_ELEMENTS]; - /* element_alloced: - determines whether the data needed for the element is allocated or not - */ - uint8_t element_alloced[MAX_SYNTAX_ELEMENTS]; - /* alloced_channels: - determines the number of channels where output data is allocated for - */ - uint8_t alloced_channels; - - uint8_t window_shape_prev[MAX_CHANNELS]; -#ifdef LTP_DEC - uint16_t ltp_lag[MAX_CHANNELS]; -#endif - fb_info *fb; - drc_info *drc; - - real_t *time_out[MAX_CHANNELS]; - real_t *fb_intermed[MAX_CHANNELS]; - -#ifdef SBR_DEC - int8_t sbr_present_flag; - int8_t forceUpSampling; - int8_t downSampledSBR; - /* determines whether SBR data is allocated for the gives element */ - uint8_t sbr_alloced[MAX_SYNTAX_ELEMENTS]; - - sbr_info *sbr[MAX_SYNTAX_ELEMENTS]; -#endif -#if (defined(PS_DEC) || defined(DRM_PS)) - uint8_t ps_used[MAX_SYNTAX_ELEMENTS]; - uint8_t ps_used_global; -#endif - -#ifdef SSR_DEC - real_t *ssr_overlap[MAX_CHANNELS]; - real_t *prev_fmd[MAX_CHANNELS]; - real_t ipqf_buffer[MAX_CHANNELS][4][96/4]; -#endif - -#ifdef MAIN_DEC - pred_state *pred_stat[MAX_CHANNELS]; -#endif -#ifdef LTP_DEC - int16_t *lt_pred_stat[MAX_CHANNELS]; -#endif - - /* Program Config Element */ - uint8_t pce_set; - program_config pce; - uint8_t element_id[MAX_CHANNELS]; - uint8_t internal_channel[MAX_CHANNELS]; - - /* Configuration data */ - NeAACDecConfiguration config; - -#ifdef PROFILE - int64_t cycles; - int64_t spectral_cycles; - int64_t output_cycles; - int64_t scalefac_cycles; - int64_t requant_cycles; -#endif -} NeAACDecStruct, *NeAACDecHandle; - - - -#ifdef __cplusplus -} -#endif -#endif diff --git a/apps/codecs/libfaad/syntax.c b/apps/codecs/libfaad/syntax.c deleted file mode 100644 index d3d7f9e3d4..0000000000 --- a/apps/codecs/libfaad/syntax.c +++ /dev/null @@ -1,2368 +0,0 @@ -/* -** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -** -** Any non-GPL usage of this software or parts of this software is strictly -** forbidden. -** -** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. -** -** $Id$ -**/ - -/* - Reads the AAC bitstream as defined in 14496-3 (MPEG-4 Audio) -*/ - -#include "common.h" -#include "structs.h" - -#include -#include - -#include "decoder.h" -#include "syntax.h" -#include "specrec.h" -#include "huffman.h" -#include "bits.h" -#include "pulse.h" -#include "analysis.h" -#include "drc.h" -#ifdef ERROR_RESILIENCE -#include "rvlc.h" -#endif -#ifdef SBR_DEC -#include "sbr_syntax.h" -#endif - - -/* static function declarations */ -static void decode_sce_lfe(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hInfo, bitfile *ld, - uint8_t id_syn_ele); -static void decode_cpe(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hInfo, bitfile *ld, - uint8_t id_syn_ele); -static uint8_t single_lfe_channel_element(NeAACDecHandle hDecoder, bitfile *ld, - uint8_t channel, uint8_t *tag); -static uint8_t channel_pair_element(NeAACDecHandle hDecoder, bitfile *ld, - uint8_t channel, uint8_t *tag); -#ifdef COUPLING_DEC -static uint8_t coupling_channel_element(NeAACDecHandle hDecoder, bitfile *ld); -#endif -static uint16_t data_stream_element(NeAACDecHandle hDecoder, bitfile *ld); -static uint8_t program_config_element(program_config *pce, bitfile *ld); -static uint8_t fill_element(NeAACDecHandle hDecoder, bitfile *ld, drc_info *drc -#ifdef SBR_DEC - ,uint8_t sbr_ele -#endif - ); -static uint8_t individual_channel_stream(NeAACDecHandle hDecoder, element *ele, - bitfile *ld, ic_stream *ics, uint8_t scal_flag, - int16_t *spec_data); -static uint8_t ics_info(NeAACDecHandle hDecoder, ic_stream *ics, bitfile *ld, - uint8_t common_window); -static uint8_t section_data(NeAACDecHandle hDecoder, ic_stream *ics, bitfile *ld); -static uint8_t scale_factor_data(NeAACDecHandle hDecoder, ic_stream *ics, bitfile *ld); -#ifdef SSR_DEC -static void gain_control_data(bitfile *ld, ic_stream *ics); -#endif -static uint8_t spectral_data(NeAACDecHandle hDecoder, ic_stream *ics, bitfile *ld, - int16_t *spectral_data); -static uint16_t extension_payload(bitfile *ld, drc_info *drc, uint16_t count); -static uint8_t pulse_data(ic_stream *ics, pulse_info *pul, bitfile *ld); -static void tns_data(ic_stream *ics, tns_info *tns, bitfile *ld); -#ifdef LTP_DEC -static uint8_t ltp_data(NeAACDecHandle hDecoder, ic_stream *ics, ltp_info *ltp, bitfile *ld); -#endif -static uint8_t adts_fixed_header(adts_header *adts, bitfile *ld); -static void adts_variable_header(adts_header *adts, bitfile *ld); -static void adts_error_check(adts_header *adts, bitfile *ld); -static uint8_t dynamic_range_info(bitfile *ld, drc_info *drc); -static uint8_t excluded_channels(bitfile *ld, drc_info *drc); -#ifdef SCALABLE_DEC -static int8_t aac_scalable_main_header(NeAACDecHandle hDecoder, ic_stream *ics1, ic_stream *ics2, - bitfile *ld, uint8_t this_layer_stereo); -#endif - - -/* Table 4.4.1 */ -int8_t GASpecificConfig(bitfile *ld, mp4AudioSpecificConfig *mp4ASC, - program_config *pce_out) -{ - program_config pce; - - /* 1024 or 960 */ - mp4ASC->frameLengthFlag = faad_get1bit(ld - DEBUGVAR(1,138,"GASpecificConfig(): FrameLengthFlag")); -#ifndef ALLOW_SMALL_FRAMELENGTH - if (mp4ASC->frameLengthFlag == 1) - return -3; -#endif - - mp4ASC->dependsOnCoreCoder = faad_get1bit(ld - DEBUGVAR(1,139,"GASpecificConfig(): DependsOnCoreCoder")); - if (mp4ASC->dependsOnCoreCoder == 1) - { - mp4ASC->coreCoderDelay = (uint16_t)faad_getbits(ld, 14 - DEBUGVAR(1,140,"GASpecificConfig(): CoreCoderDelay")); - } - - mp4ASC->extensionFlag = faad_get1bit(ld DEBUGVAR(1,141,"GASpecificConfig(): ExtensionFlag")); - if (mp4ASC->channelsConfiguration == 0) - { - if (program_config_element(&pce, ld)) - return -3; - //mp4ASC->channelsConfiguration = pce.channels; - - if (pce_out != NULL) - memcpy(pce_out, &pce, sizeof(program_config)); - - /* - if (pce.num_valid_cc_elements) - return -3; - */ - } - -#ifdef ERROR_RESILIENCE - if (mp4ASC->extensionFlag == 1) - { - /* Error resilience not supported yet */ - if (mp4ASC->objectTypeIndex >= ER_OBJECT_START) - { - mp4ASC->aacSectionDataResilienceFlag = faad_get1bit(ld - DEBUGVAR(1,144,"GASpecificConfig(): aacSectionDataResilienceFlag")); - mp4ASC->aacScalefactorDataResilienceFlag = faad_get1bit(ld - DEBUGVAR(1,145,"GASpecificConfig(): aacScalefactorDataResilienceFlag")); - mp4ASC->aacSpectralDataResilienceFlag = faad_get1bit(ld - DEBUGVAR(1,146,"GASpecificConfig(): aacSpectralDataResilienceFlag")); - - /* 1 bit: extensionFlag3 */ - } - } -#endif - - return 0; -} - -/* Table 4.4.2 */ -/* An MPEG-4 Audio decoder is only required to follow the Program - Configuration Element in GASpecificConfig(). The decoder shall ignore - any Program Configuration Elements that may occur in raw data blocks. - PCEs transmitted in raw data blocks cannot be used to convey decoder - configuration information. -*/ -static uint8_t program_config_element(program_config *pce, bitfile *ld) -{ - uint8_t i; - - memset(pce, 0, sizeof(program_config)); - - pce->channels = 0; - - pce->element_instance_tag = (uint8_t)faad_getbits(ld, 4 - DEBUGVAR(1,10,"program_config_element(): element_instance_tag")); - - pce->object_type = (uint8_t)faad_getbits(ld, 2 - DEBUGVAR(1,11,"program_config_element(): object_type")); - pce->sf_index = (uint8_t)faad_getbits(ld, 4 - DEBUGVAR(1,12,"program_config_element(): sf_index")); - pce->num_front_channel_elements = (uint8_t)faad_getbits(ld, 4 - DEBUGVAR(1,13,"program_config_element(): num_front_channel_elements")); - pce->num_side_channel_elements = (uint8_t)faad_getbits(ld, 4 - DEBUGVAR(1,14,"program_config_element(): num_side_channel_elements")); - pce->num_back_channel_elements = (uint8_t)faad_getbits(ld, 4 - DEBUGVAR(1,15,"program_config_element(): num_back_channel_elements")); - pce->num_lfe_channel_elements = (uint8_t)faad_getbits(ld, 2 - DEBUGVAR(1,16,"program_config_element(): num_lfe_channel_elements")); - pce->num_assoc_data_elements = (uint8_t)faad_getbits(ld, 3 - DEBUGVAR(1,17,"program_config_element(): num_assoc_data_elements")); - pce->num_valid_cc_elements = (uint8_t)faad_getbits(ld, 4 - DEBUGVAR(1,18,"program_config_element(): num_valid_cc_elements")); - - pce->mono_mixdown_present = faad_get1bit(ld - DEBUGVAR(1,19,"program_config_element(): mono_mixdown_present")); - if (pce->mono_mixdown_present == 1) - { - pce->mono_mixdown_element_number = (uint8_t)faad_getbits(ld, 4 - DEBUGVAR(1,20,"program_config_element(): mono_mixdown_element_number")); - } - - pce->stereo_mixdown_present = faad_get1bit(ld - DEBUGVAR(1,21,"program_config_element(): stereo_mixdown_present")); - if (pce->stereo_mixdown_present == 1) - { - pce->stereo_mixdown_element_number = (uint8_t)faad_getbits(ld, 4 - DEBUGVAR(1,22,"program_config_element(): stereo_mixdown_element_number")); - } - - pce->matrix_mixdown_idx_present = faad_get1bit(ld - DEBUGVAR(1,23,"program_config_element(): matrix_mixdown_idx_present")); - if (pce->matrix_mixdown_idx_present == 1) - { - pce->matrix_mixdown_idx = (uint8_t)faad_getbits(ld, 2 - DEBUGVAR(1,24,"program_config_element(): matrix_mixdown_idx")); - pce->pseudo_surround_enable = faad_get1bit(ld - DEBUGVAR(1,25,"program_config_element(): pseudo_surround_enable")); - } - - for (i = 0; i < pce->num_front_channel_elements; i++) - { - pce->front_element_is_cpe[i] = faad_get1bit(ld - DEBUGVAR(1,26,"program_config_element(): front_element_is_cpe")); - pce->front_element_tag_select[i] = (uint8_t)faad_getbits(ld, 4 - DEBUGVAR(1,27,"program_config_element(): front_element_tag_select")); - - if (pce->front_element_is_cpe[i] & 1) - { - pce->cpe_channel[pce->front_element_tag_select[i]] = pce->channels; - pce->num_front_channels += 2; - pce->channels += 2; - } else { - pce->sce_channel[pce->front_element_tag_select[i]] = pce->channels; - pce->num_front_channels++; - pce->channels++; - } - } - - for (i = 0; i < pce->num_side_channel_elements; i++) - { - pce->side_element_is_cpe[i] = faad_get1bit(ld - DEBUGVAR(1,28,"program_config_element(): side_element_is_cpe")); - pce->side_element_tag_select[i] = (uint8_t)faad_getbits(ld, 4 - DEBUGVAR(1,29,"program_config_element(): side_element_tag_select")); - - if (pce->side_element_is_cpe[i] & 1) - { - pce->cpe_channel[pce->side_element_tag_select[i]] = pce->channels; - pce->num_side_channels += 2; - pce->channels += 2; - } else { - pce->sce_channel[pce->side_element_tag_select[i]] = pce->channels; - pce->num_side_channels++; - pce->channels++; - } - } - - for (i = 0; i < pce->num_back_channel_elements; i++) - { - pce->back_element_is_cpe[i] = faad_get1bit(ld - DEBUGVAR(1,30,"program_config_element(): back_element_is_cpe")); - pce->back_element_tag_select[i] = (uint8_t)faad_getbits(ld, 4 - DEBUGVAR(1,31,"program_config_element(): back_element_tag_select")); - - if (pce->back_element_is_cpe[i] & 1) - { - pce->cpe_channel[pce->back_element_tag_select[i]] = pce->channels; - pce->channels += 2; - pce->num_back_channels += 2; - } else { - pce->sce_channel[pce->back_element_tag_select[i]] = pce->channels; - pce->num_back_channels++; - pce->channels++; - } - } - - for (i = 0; i < pce->num_lfe_channel_elements; i++) - { - pce->lfe_element_tag_select[i] = (uint8_t)faad_getbits(ld, 4 - DEBUGVAR(1,32,"program_config_element(): lfe_element_tag_select")); - - pce->sce_channel[pce->lfe_element_tag_select[i]] = pce->channels; - pce->num_lfe_channels++; - pce->channels++; - } - - for (i = 0; i < pce->num_assoc_data_elements; i++) - pce->assoc_data_element_tag_select[i] = (uint8_t)faad_getbits(ld, 4 - DEBUGVAR(1,33,"program_config_element(): assoc_data_element_tag_select")); - - for (i = 0; i < pce->num_valid_cc_elements; i++) - { - pce->cc_element_is_ind_sw[i] = faad_get1bit(ld - DEBUGVAR(1,34,"program_config_element(): cc_element_is_ind_sw")); - pce->valid_cc_element_tag_select[i] = (uint8_t)faad_getbits(ld, 4 - DEBUGVAR(1,35,"program_config_element(): valid_cc_element_tag_select")); - } - - faad_byte_align(ld); - - pce->comment_field_bytes = (uint8_t)faad_getbits(ld, 8 - DEBUGVAR(1,36,"program_config_element(): comment_field_bytes")); - - for (i = 0; i < pce->comment_field_bytes; i++) - { - pce->comment_field_data[i] = (uint8_t)faad_getbits(ld, 8 - DEBUGVAR(1,37,"program_config_element(): comment_field_data")); - } - pce->comment_field_data[i] = 0; - - if (pce->channels > MAX_CHANNELS) - return 22; - - return 0; -} - -static void decode_sce_lfe(NeAACDecHandle hDecoder, - NeAACDecFrameInfo *hInfo, bitfile *ld, - uint8_t id_syn_ele) -{ - uint8_t channels = hDecoder->fr_channels; - uint8_t tag = 0; - - if (channels+1 > MAX_CHANNELS) - { - hInfo->error = 12; - return; - } - if (hDecoder->fr_ch_ele+1 > MAX_SYNTAX_ELEMENTS) - { - hInfo->error = 13; - return; - } - - /* for SCE hDecoder->element_output_channels[] is not set here because this - can become 2 when some form of Parametric Stereo coding is used - */ - - /* save the syntax element id */ - hDecoder->element_id[hDecoder->fr_ch_ele] = id_syn_ele; - - /* decode the element */ - hInfo->error = single_lfe_channel_element(hDecoder, ld, channels, &tag); - - /* map output channels position to internal data channels */ - if (hDecoder->element_output_channels[hDecoder->fr_ch_ele] == 2) - { - /* this might be faulty when pce_set is true */ - hDecoder->internal_channel[channels] = channels; - hDecoder->internal_channel[channels+1] = channels+1; - } else { - if (hDecoder->pce_set) - hDecoder->internal_channel[hDecoder->pce.sce_channel[tag]] = channels; - else - hDecoder->internal_channel[channels] = channels; - } - - hDecoder->fr_channels += hDecoder->element_output_channels[hDecoder->fr_ch_ele]; - hDecoder->fr_ch_ele++; -} - -static void decode_cpe(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hInfo, bitfile *ld, - uint8_t id_syn_ele) -{ - uint8_t channels = hDecoder->fr_channels; - uint8_t tag = 0; - - if (channels+2 > MAX_CHANNELS) - { - hInfo->error = 12; - return; - } - if (hDecoder->fr_ch_ele+1 > MAX_SYNTAX_ELEMENTS) - { - hInfo->error = 13; - return; - } - - /* for CPE the number of output channels is always 2 */ - if (hDecoder->element_output_channels[hDecoder->fr_ch_ele] == 0) - { - /* element_output_channels not set yet */ - hDecoder->element_output_channels[hDecoder->fr_ch_ele] = 2; - } else if (hDecoder->element_output_channels[hDecoder->fr_ch_ele] != 2) { - /* element inconsistency */ - hInfo->error = 21; - return; - } - - /* save the syntax element id */ - hDecoder->element_id[hDecoder->fr_ch_ele] = id_syn_ele; - - /* decode the element */ - hInfo->error = channel_pair_element(hDecoder, ld, channels, &tag); - - /* map output channel position to internal data channels */ - if (hDecoder->pce_set) - { - hDecoder->internal_channel[hDecoder->pce.cpe_channel[tag]] = channels; - hDecoder->internal_channel[hDecoder->pce.cpe_channel[tag]+1] = channels+1; - } else { - hDecoder->internal_channel[channels] = channels; - hDecoder->internal_channel[channels+1] = channels+1; - } - - hDecoder->fr_channels += 2; - hDecoder->fr_ch_ele++; -} - -void raw_data_block(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hInfo, - bitfile *ld, program_config *pce, drc_info *drc) -{ - uint8_t id_syn_ele; - - hDecoder->fr_channels = 0; - hDecoder->fr_ch_ele = 0; - hDecoder->first_syn_ele = 25; - hDecoder->has_lfe = 0; - -#ifdef ERROR_RESILIENCE - if (hDecoder->object_type < ER_OBJECT_START) - { -#endif - /* Table 4.4.3: raw_data_block() */ - while ((id_syn_ele = (uint8_t)faad_getbits(ld, LEN_SE_ID - DEBUGVAR(1,4,"NeAACDecDecode(): id_syn_ele"))) != ID_END) - { - switch (id_syn_ele) { - case ID_SCE: - if (hDecoder->first_syn_ele == 25) hDecoder->first_syn_ele = id_syn_ele; - decode_sce_lfe(hDecoder, hInfo, ld, id_syn_ele); - if (hInfo->error > 0) - return; - break; - case ID_CPE: - if (hDecoder->first_syn_ele == 25) hDecoder->first_syn_ele = id_syn_ele; - decode_cpe(hDecoder, hInfo, ld, id_syn_ele); - if (hInfo->error > 0) - return; - break; - case ID_LFE: - hDecoder->has_lfe++; - decode_sce_lfe(hDecoder, hInfo, ld, id_syn_ele); - if (hInfo->error > 0) - return; - break; - case ID_CCE: /* not implemented yet, but skip the bits */ -#ifdef COUPLING_DEC - hInfo->error = coupling_channel_element(hDecoder, ld); -#else - hInfo->error = 6; -#endif - if (hInfo->error > 0) - return; - break; - case ID_DSE: - data_stream_element(hDecoder, ld); - break; - case ID_PCE: - /* 14496-4: 5.6.4.1.2.1.3: */ - /* program_configuration_element()'s in access units shall be ignored */ - program_config_element(pce, ld); - //if ((hInfo->error = program_config_element(pce, ld)) > 0) - // return; - //hDecoder->pce_set = 1; - break; - case ID_FIL: - /* one sbr_info describes a channel_element not a channel! */ - /* if we encounter SBR data here: error */ - /* SBR data will be read directly in the SCE/LFE/CPE element */ - if ((hInfo->error = fill_element(hDecoder, ld, drc -#ifdef SBR_DEC - , INVALID_SBR_ELEMENT -#endif - )) > 0) - return; - break; - } - } -#ifdef ERROR_RESILIENCE - } else { - /* Table 262: er_raw_data_block() */ - switch (hDecoder->channelConfiguration) - { - case 1: - decode_sce_lfe(hDecoder, hInfo, ld, ID_SCE); - if (hInfo->error > 0) - return; - break; - case 2: - decode_cpe(hDecoder, hInfo, ld, ID_CPE); - if (hInfo->error > 0) - return; - break; - case 3: - decode_sce_lfe(hDecoder, hInfo, ld, ID_SCE); - decode_cpe(hDecoder, hInfo, ld, ID_CPE); - if (hInfo->error > 0) - return; - break; - case 4: - decode_sce_lfe(hDecoder, hInfo, ld, ID_SCE); - decode_cpe(hDecoder, hInfo, ld, ID_CPE); - decode_sce_lfe(hDecoder, hInfo, ld, ID_SCE); - if (hInfo->error > 0) - return; - break; - case 5: - decode_sce_lfe(hDecoder, hInfo, ld, ID_SCE); - decode_cpe(hDecoder, hInfo, ld, ID_CPE); - decode_cpe(hDecoder, hInfo, ld, ID_CPE); - if (hInfo->error > 0) - return; - break; - case 6: - decode_sce_lfe(hDecoder, hInfo, ld, ID_SCE); - decode_cpe(hDecoder, hInfo, ld, ID_CPE); - decode_cpe(hDecoder, hInfo, ld, ID_CPE); - decode_sce_lfe(hDecoder, hInfo, ld, ID_LFE); - if (hInfo->error > 0) - return; - break; - case 7: /* 8 channels */ - decode_sce_lfe(hDecoder, hInfo, ld, ID_SCE); - decode_cpe(hDecoder, hInfo, ld, ID_CPE); - decode_cpe(hDecoder, hInfo, ld, ID_CPE); - decode_cpe(hDecoder, hInfo, ld, ID_CPE); - decode_sce_lfe(hDecoder, hInfo, ld, ID_LFE); - if (hInfo->error > 0) - return; - break; - default: - hInfo->error = 7; - return; - } -#if 0 - cnt = bits_to_decode() / 8; - while (cnt >= 1) - { - cnt -= extension_payload(cnt); - } -#endif - } -#endif - - /* new in corrigendum 14496-3:2002 */ -#ifdef DRM - if (hDecoder->object_type != DRM_ER_LC) -#endif - { - faad_byte_align(ld); - } - - return; -} - -/* Table 4.4.4 and */ -/* Table 4.4.9 */ -int16_t spec_data[FRAME_LEN] MEM_ALIGN_ATTR = {0}; -element sce; -static uint8_t single_lfe_channel_element(NeAACDecHandle hDecoder, bitfile *ld, - uint8_t channel, uint8_t *tag) -{ - uint8_t retval = 0; - ic_stream *ics = &(sce.ics1); - - memset(spec_data,0,sizeof(spec_data)); - memset(&sce,0,sizeof(sce)); - sce.element_instance_tag = (uint8_t)faad_getbits(ld, LEN_TAG - DEBUGVAR(1,38,"single_lfe_channel_element(): element_instance_tag")); - - *tag = sce.element_instance_tag; - sce.channel = channel; - sce.paired_channel = -1; - - retval = individual_channel_stream(hDecoder, &sce, ld, ics, 0, spec_data); - if (retval > 0) - return retval; - -#ifdef SBR_DEC - /* check if next bitstream element is a fill element */ - /* if so, read it now so SBR decoding can be done in case of a file with SBR */ - if (faad_showbits(ld, LEN_SE_ID) == ID_FIL) - { - faad_flushbits(ld, LEN_SE_ID); - - /* one sbr_info describes a channel_element not a channel! */ - if ((retval = fill_element(hDecoder, ld, hDecoder->drc, hDecoder->fr_ch_ele)) > 0) - { - return retval; - } - } -#endif - - /* noiseless coding is done, spectral reconstruction is done now */ - retval = reconstruct_single_channel(hDecoder, ics, &sce, spec_data); - if (retval > 0) - return retval; - - return 0; -} - -/* Table 4.4.5 */ - -int16_t spec_data1[FRAME_LEN] IBSS_ATTR MEM_ALIGN_ATTR; -int16_t spec_data2[FRAME_LEN] IBSS_ATTR MEM_ALIGN_ATTR; -element cpe; -static uint8_t channel_pair_element(NeAACDecHandle hDecoder, bitfile *ld, - uint8_t channels, uint8_t *tag) -{ - ic_stream *ics1 = &(cpe.ics1); - ic_stream *ics2 = &(cpe.ics2); - uint8_t result; - - memset(spec_data1,0,sizeof(spec_data1)); - memset(spec_data2,0,sizeof(spec_data2)); - memset(&cpe,0,sizeof(cpe)); - cpe.channel = channels; - cpe.paired_channel = channels+1; - - cpe.element_instance_tag = (uint8_t)faad_getbits(ld, LEN_TAG - DEBUGVAR(1,39,"channel_pair_element(): element_instance_tag")); - *tag = cpe.element_instance_tag; - - if ((cpe.common_window = faad_get1bit(ld - DEBUGVAR(1,40,"channel_pair_element(): common_window"))) & 1) - { - /* both channels have common ics information */ - if ((result = ics_info(hDecoder, ics1, ld, cpe.common_window)) > 0) - return result; - - ics1->ms_mask_present = (uint8_t)faad_getbits(ld, 2 - DEBUGVAR(1,41,"channel_pair_element(): ms_mask_present")); - if (ics1->ms_mask_present == 1) - { - uint8_t g, sfb; - for (g = 0; g < ics1->num_window_groups; g++) - { - for (sfb = 0; sfb < ics1->max_sfb; sfb++) - { - ics1->ms_used[g][sfb] = faad_get1bit(ld - DEBUGVAR(1,42,"channel_pair_element(): faad_get1bit")); - } - } - } - -#ifdef ERROR_RESILIENCE - if ((hDecoder->object_type >= ER_OBJECT_START) && (ics1->predictor_data_present)) - { - if (( -#ifdef LTP_DEC - ics1->ltp.data_present = -#endif - faad_get1bit(ld DEBUGVAR(1,50,"channel_pair_element(): ltp.data_present"))) & 1) - { -#ifdef LTP_DEC - if ((result = ltp_data(hDecoder, ics1, &(ics1->ltp), ld)) > 0) - { - return result; - } -#else - return 26; -#endif - } - } -#endif - - memcpy(ics2, ics1, sizeof(ic_stream)); - } else { - ics1->ms_mask_present = 0; - } - - if ((result = individual_channel_stream(hDecoder, &cpe, ld, ics1, - 0, spec_data1)) > 0) - { - return result; - } - -#ifdef ERROR_RESILIENCE - if (cpe.common_window && (hDecoder->object_type >= ER_OBJECT_START) && - (ics1->predictor_data_present)) - { - if (( -#ifdef LTP_DEC - ics1->ltp2.data_present = -#endif - faad_get1bit(ld DEBUGVAR(1,50,"channel_pair_element(): ltp.data_present"))) & 1) - { -#ifdef LTP_DEC - if ((result = ltp_data(hDecoder, ics1, &(ics1->ltp2), ld)) > 0) - { - return result; - } -#else - return 26; -#endif - } - } -#endif - - if ((result = individual_channel_stream(hDecoder, &cpe, ld, ics2, - 0, spec_data2)) > 0) - { - return result; - } - -#ifdef SBR_DEC - /* check if next bitstream element is a fill element */ - /* if so, read it now so SBR decoding can be done in case of a file with SBR */ - if (faad_showbits(ld, LEN_SE_ID) == ID_FIL) - { - faad_flushbits(ld, LEN_SE_ID); - - /* one sbr_info describes a channel_element not a channel! */ - if ((result = fill_element(hDecoder, ld, hDecoder->drc, hDecoder->fr_ch_ele)) > 0) - { - return result; - } - } -#endif - - /* noiseless coding is done, spectral reconstruction is done now */ - if ((result = reconstruct_channel_pair(hDecoder, ics1, ics2, &cpe, - spec_data1, spec_data2)) > 0) - { - return result; - } - - return 0; -} - -/* Table 4.4.6 */ -static uint8_t ics_info(NeAACDecHandle hDecoder, ic_stream *ics, bitfile *ld, - uint8_t common_window) -{ - uint8_t retval = 0; - - /* ics->ics_reserved_bit = */ faad_get1bit(ld - DEBUGVAR(1,43,"ics_info(): ics_reserved_bit")); - ics->window_sequence = (uint8_t)faad_getbits(ld, 2 - DEBUGVAR(1,44,"ics_info(): window_sequence")); - ics->window_shape = faad_get1bit(ld - DEBUGVAR(1,45,"ics_info(): window_shape")); - - if (ics->window_sequence == EIGHT_SHORT_SEQUENCE) - { - ics->max_sfb = (uint8_t)faad_getbits(ld, 4 - DEBUGVAR(1,46,"ics_info(): max_sfb (short)")); - ics->scale_factor_grouping = (uint8_t)faad_getbits(ld, 7 - DEBUGVAR(1,47,"ics_info(): scale_factor_grouping")); - } else { - ics->max_sfb = (uint8_t)faad_getbits(ld, 6 - DEBUGVAR(1,48,"ics_info(): max_sfb (long)")); - } - - /* get the grouping information */ - if ((retval = window_grouping_info(hDecoder, ics)) > 0) - return retval; - - /* should be an error */ - /* check the range of max_sfb */ - if (ics->max_sfb > ics->num_swb) - return 16; - - if (ics->window_sequence != EIGHT_SHORT_SEQUENCE) - { - if ((ics->predictor_data_present = faad_get1bit(ld - DEBUGVAR(1,49,"ics_info(): predictor_data_present"))) & 1) - { - if (hDecoder->object_type == MAIN) /* MPEG2 style AAC predictor */ - { - uint8_t sfb; - - uint8_t limit = min(ics->max_sfb, max_pred_sfb(hDecoder->sf_index)); -#ifdef MAIN_DEC - ics->pred.limit = limit; -#endif - - if (( -#ifdef MAIN_DEC - ics->pred.predictor_reset = -#endif - faad_get1bit(ld DEBUGVAR(1,53,"ics_info(): pred.predictor_reset"))) & 1) - { -#ifdef MAIN_DEC - ics->pred.predictor_reset_group_number = - (uint8_t) -#endif - faad_getbits(ld, 5 DEBUGVAR(1,54,"ics_info(): pred.predictor_reset_group_number")); - } - - for (sfb = 0; sfb < limit; sfb++) - { -#ifdef MAIN_DEC - ics->pred.prediction_used[sfb] = -#endif - faad_get1bit(ld DEBUGVAR(1,55,"ics_info(): pred.prediction_used")); - } - } -#ifdef LTP_DEC - else { /* Long Term Prediction */ - if (hDecoder->object_type < ER_OBJECT_START) - { - if ((ics->ltp.data_present = faad_get1bit(ld - DEBUGVAR(1,50,"ics_info(): ltp.data_present"))) & 1) - { - if ((retval = ltp_data(hDecoder, ics, &(ics->ltp), ld)) > 0) - { - return retval; - } - } - if (common_window) - { - if ((ics->ltp2.data_present = faad_get1bit(ld - DEBUGVAR(1,51,"ics_info(): ltp2.data_present"))) & 1) - { - if ((retval = ltp_data(hDecoder, ics, &(ics->ltp2), ld)) > 0) - { - return retval; - } - } - } - } -#ifdef ERROR_RESILIENCE - if (!common_window && (hDecoder->object_type >= ER_OBJECT_START)) - { - if ((ics->ltp.data_present = faad_get1bit(ld - DEBUGVAR(1,50,"ics_info(): ltp.data_present"))) & 1) - { - ltp_data(hDecoder, ics, &(ics->ltp), ld); - } - } -#endif - } -#else - (void) common_window; -#endif - } - } - - return retval; -} - -/* Table 4.4.7 */ -static uint8_t pulse_data(ic_stream *ics, pulse_info *pul, bitfile *ld) -{ - uint8_t i; - - pul->number_pulse = (uint8_t)faad_getbits(ld, 2 - DEBUGVAR(1,56,"pulse_data(): number_pulse")); - pul->pulse_start_sfb = (uint8_t)faad_getbits(ld, 6 - DEBUGVAR(1,57,"pulse_data(): pulse_start_sfb")); - - /* check the range of pulse_start_sfb */ - if (pul->pulse_start_sfb > ics->num_swb) - return 16; - - for (i = 0; i < pul->number_pulse+1; i++) - { - pul->pulse_offset[i] = (uint8_t)faad_getbits(ld, 5 - DEBUGVAR(1,58,"pulse_data(): pulse_offset")); -#if 0 - printf("%d\n", pul->pulse_offset[i]); -#endif - pul->pulse_amp[i] = (uint8_t)faad_getbits(ld, 4 - DEBUGVAR(1,59,"pulse_data(): pulse_amp")); -#if 0 - printf("%d\n", pul->pulse_amp[i]); -#endif - } - - return 0; -} - -#ifdef COUPLING_DEC -/* Table 4.4.8: Currently just for skipping the bits... */ -static uint8_t coupling_channel_element(NeAACDecHandle hDecoder, bitfile *ld) -{ - uint8_t c, result = 0; - uint8_t ind_sw_cce_flag = 0; - uint8_t num_gain_element_lists = 0; - uint8_t num_coupled_elements = 0; - - element el_empty = {0}; - ic_stream ics_empty = {0}; - static int16_t sh_data[FRAME_LEN]; - - c = faad_getbits(ld, LEN_TAG - DEBUGVAR(1,900,"coupling_channel_element(): element_instance_tag")); - - ind_sw_cce_flag = faad_get1bit(ld - DEBUGVAR(1,901,"coupling_channel_element(): ind_sw_cce_flag")); - num_coupled_elements = faad_getbits(ld, 3 - DEBUGVAR(1,902,"coupling_channel_element(): num_coupled_elements")); - - for (c = 0; c < num_coupled_elements + 1; c++) - { - uint8_t cc_target_is_cpe, cc_target_tag_select; - - num_gain_element_lists++; - - cc_target_is_cpe = faad_get1bit(ld - DEBUGVAR(1,903,"coupling_channel_element(): cc_target_is_cpe")); - cc_target_tag_select = faad_getbits(ld, 4 - DEBUGVAR(1,904,"coupling_channel_element(): cc_target_tag_select")); - - if (cc_target_is_cpe) - { - uint8_t cc_l = faad_get1bit(ld - DEBUGVAR(1,905,"coupling_channel_element(): cc_l")); - uint8_t cc_r = faad_get1bit(ld - DEBUGVAR(1,906,"coupling_channel_element(): cc_r")); - - if (cc_l && cc_r) - num_gain_element_lists++; - } - } - - faad_get1bit(ld - DEBUGVAR(1,907,"coupling_channel_element(): cc_domain")); - faad_get1bit(ld - DEBUGVAR(1,908,"coupling_channel_element(): gain_element_sign")); - faad_getbits(ld, 2 - DEBUGVAR(1,909,"coupling_channel_element(): gain_element_scale")); - - if ((result = individual_channel_stream(hDecoder, &el_empty, ld, &ics_empty, - 0, sh_data)) > 0) - { - return result; - } - - for (c = 1; c < num_gain_element_lists; c++) - { - uint8_t cge; - - if (ind_sw_cce_flag) - { - cge = 1; - } else { - cge = faad_get1bit(ld - DEBUGVAR(1,910,"coupling_channel_element(): common_gain_element_present")); - } - - if (cge) - { - huffman_scale_factor(ld); - } else { - uint8_t g, sfb; - - for (g = 0; g < ics_empty.num_window_groups; g++) - { - for (sfb = 0; sfb < ics_empty.max_sfb; sfb++) - { - if (ics_empty.sfb_cb[g][sfb] != ZERO_HCB) - huffman_scale_factor(ld); - } - } - } - } - - return 0; -} -#endif - -/* Table 4.4.10 */ -static uint16_t data_stream_element(NeAACDecHandle hDecoder, bitfile *ld) -{ - uint8_t byte_aligned; - uint16_t i, count; - - (void)hDecoder; - - /* element_instance_tag = */ faad_getbits(ld, LEN_TAG - DEBUGVAR(1,60,"data_stream_element(): element_instance_tag")); - byte_aligned = faad_get1bit(ld - DEBUGVAR(1,61,"data_stream_element(): byte_aligned")); - count = (uint16_t)faad_getbits(ld, 8 - DEBUGVAR(1,62,"data_stream_element(): count")); - if (count == 255) - { - count += (uint16_t)faad_getbits(ld, 8 - DEBUGVAR(1,63,"data_stream_element(): extra count")); - } - if (byte_aligned) - faad_byte_align(ld); - - for (i = 0; i < count; i++) - { - faad_getbits(ld, LEN_BYTE - DEBUGVAR(1,64,"data_stream_element(): data_stream_byte")); - } - - return count; -} - -/* Table 4.4.11 */ -static uint8_t fill_element(NeAACDecHandle hDecoder, bitfile *ld, drc_info *drc -#ifdef SBR_DEC - ,uint8_t sbr_ele -#endif - ) -{ - uint16_t count; -#ifdef SBR_DEC - uint8_t bs_extension_type; -#endif - - count = (uint16_t)faad_getbits(ld, 4 - DEBUGVAR(1,65,"fill_element(): count")); - if (count == 15) - { - count += (uint16_t)faad_getbits(ld, 8 - DEBUGVAR(1,66,"fill_element(): extra count")) - 1; - } - - if (count > 0) - { -#ifdef SBR_DEC - bs_extension_type = (uint8_t)faad_showbits(ld, 4); - - if ((bs_extension_type == EXT_SBR_DATA) || - (bs_extension_type == EXT_SBR_DATA_CRC)) - { - if (sbr_ele == INVALID_SBR_ELEMENT) - return 24; - - if (!hDecoder->sbr[sbr_ele]) - { - hDecoder->sbr[sbr_ele] = sbrDecodeInit(hDecoder->frameLength, - hDecoder->element_id[sbr_ele], sbr_ele, - 2*get_sample_rate(hDecoder->sf_index), - hDecoder->downSampledSBR, 0); -#ifndef FAAD_STATIC_ALLOC - if (hDecoder->sbr[sbr_ele] == NULL) - { - /* could not allocate memory */ - return 28; - } -#endif - } - - hDecoder->sbr_present_flag = 1; - - /* parse the SBR data */ - hDecoder->sbr[sbr_ele]->ret = sbr_extension_data(ld, hDecoder->sbr[sbr_ele], count); - -#if 0 - if (hDecoder->sbr[sbr_ele]->ret > 0) - { - printf("%s\n", NeAACDecGetErrorMessage(hDecoder->sbr[sbr_ele]->ret)); - } -#endif - -#if (defined(PS_DEC) || defined(DRM_PS)) - if (hDecoder->sbr[sbr_ele]->ps_used) - { - hDecoder->ps_used[sbr_ele] = 1; - - /* set element independent flag to 1 as well */ - hDecoder->ps_used_global = 1; - } -#endif - } else { -#else - (void)hDecoder; -#endif - while (count > 0) - { - count -= extension_payload(ld, drc, count); - } -#ifdef SBR_DEC - } -#endif - } - - return 0; -} - -/* Table 4.4.12 */ -#ifdef SSR_DEC -static void gain_control_data(bitfile *ld, ic_stream *ics) -{ - uint8_t bd, wd, ad; - ssr_info *ssr = &(ics->ssr); - - ssr->max_band = (uint8_t)faad_getbits(ld, 2 - DEBUGVAR(1,1000,"gain_control_data(): max_band")); - - if (ics->window_sequence == ONLY_LONG_SEQUENCE) - { - for (bd = 1; bd <= ssr->max_band; bd++) - { - for (wd = 0; wd < 1; wd++) - { - ssr->adjust_num[bd][wd] = (uint8_t)faad_getbits(ld, 3 - DEBUGVAR(1,1001,"gain_control_data(): adjust_num")); - - for (ad = 0; ad < ssr->adjust_num[bd][wd]; ad++) - { - ssr->alevcode[bd][wd][ad] = (uint8_t)faad_getbits(ld, 4 - DEBUGVAR(1,1002,"gain_control_data(): alevcode")); - ssr->aloccode[bd][wd][ad] = (uint8_t)faad_getbits(ld, 5 - DEBUGVAR(1,1003,"gain_control_data(): aloccode")); - } - } - } - } else if (ics->window_sequence == LONG_START_SEQUENCE) { - for (bd = 1; bd <= ssr->max_band; bd++) - { - for (wd = 0; wd < 2; wd++) - { - ssr->adjust_num[bd][wd] = (uint8_t)faad_getbits(ld, 3 - DEBUGVAR(1,1001,"gain_control_data(): adjust_num")); - - for (ad = 0; ad < ssr->adjust_num[bd][wd]; ad++) - { - ssr->alevcode[bd][wd][ad] = (uint8_t)faad_getbits(ld, 4 - DEBUGVAR(1,1002,"gain_control_data(): alevcode")); - if (wd == 0) - { - ssr->aloccode[bd][wd][ad] = (uint8_t)faad_getbits(ld, 4 - DEBUGVAR(1,1003,"gain_control_data(): aloccode")); - } else { - ssr->aloccode[bd][wd][ad] = (uint8_t)faad_getbits(ld, 2 - DEBUGVAR(1,1003,"gain_control_data(): aloccode")); - } - } - } - } - } else if (ics->window_sequence == EIGHT_SHORT_SEQUENCE) { - for (bd = 1; bd <= ssr->max_band; bd++) - { - for (wd = 0; wd < 8; wd++) - { - ssr->adjust_num[bd][wd] = (uint8_t)faad_getbits(ld, 3 - DEBUGVAR(1,1001,"gain_control_data(): adjust_num")); - - for (ad = 0; ad < ssr->adjust_num[bd][wd]; ad++) - { - ssr->alevcode[bd][wd][ad] = (uint8_t)faad_getbits(ld, 4 - DEBUGVAR(1,1002,"gain_control_data(): alevcode")); - ssr->aloccode[bd][wd][ad] = (uint8_t)faad_getbits(ld, 2 - DEBUGVAR(1,1003,"gain_control_data(): aloccode")); - } - } - } - } else if (ics->window_sequence == LONG_STOP_SEQUENCE) { - for (bd = 1; bd <= ssr->max_band; bd++) - { - for (wd = 0; wd < 2; wd++) - { - ssr->adjust_num[bd][wd] = (uint8_t)faad_getbits(ld, 3 - DEBUGVAR(1,1001,"gain_control_data(): adjust_num")); - - for (ad = 0; ad < ssr->adjust_num[bd][wd]; ad++) - { - ssr->alevcode[bd][wd][ad] = (uint8_t)faad_getbits(ld, 4 - DEBUGVAR(1,1002,"gain_control_data(): alevcode")); - - if (wd == 0) - { - ssr->aloccode[bd][wd][ad] = (uint8_t)faad_getbits(ld, 4 - DEBUGVAR(1,1003,"gain_control_data(): aloccode")); - } else { - ssr->aloccode[bd][wd][ad] = (uint8_t)faad_getbits(ld, 5 - DEBUGVAR(1,1003,"gain_control_data(): aloccode")); - } - } - } - } - } -} -#endif - -#ifdef SCALABLE_DEC -int16_t spec_data1[FRAME_LEN] MEM_ALIGN_ATTR; -int16_t spec_data2[FRAME_LEN] MEM_ALIGN_ATTR; -/* Table 4.4.13 ASME */ -void aac_scalable_main_element(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hInfo, - bitfile *ld, program_config *pce, drc_info *drc) -{ - uint8_t retval = 0; - uint8_t channels = hDecoder->fr_channels = 0; - uint8_t ch; - uint8_t this_layer_stereo = (hDecoder->channelConfiguration > 1) ? 1 : 0; - element cpe = {0}; - ic_stream *ics1 = &(cpe.ics1); - ic_stream *ics2 = &(cpe.ics2); - int16_t *spec_data; - - memset(spec_data1,0,sizeof(spec_data1)); - memset(spec_data2,0,sizeof(spec_data2)); - hDecoder->fr_ch_ele = 0; - - hInfo->error = aac_scalable_main_header(hDecoder, ics1, ics2, ld, this_layer_stereo); - if (hInfo->error > 0) - return; - - cpe.common_window = 1; - if (this_layer_stereo) - { - hDecoder->element_id[0] = ID_CPE; - if (hDecoder->element_output_channels[hDecoder->fr_ch_ele] == 0) - hDecoder->element_output_channels[hDecoder->fr_ch_ele] = 2; - } else { - hDecoder->element_id[0] = ID_SCE; - } - - for (ch = 0; ch < (this_layer_stereo ? 2 : 1); ch++) - { - ic_stream *ics; - if (ch == 0) - { - ics = ics1; - spec_data = spec_data1; - } else { - ics = ics2; - spec_data = spec_data2; - } - - hInfo->error = individual_channel_stream(hDecoder, &cpe, ld, ics, 1, spec_data); - if (hInfo->error > 0) - return; - } - -#ifdef DRM -#ifdef SBR_DEC - /* In case of DRM we need to read the SBR info before channel reconstruction */ - if ((hDecoder->sbr_present_flag == 1) && (hDecoder->object_type == DRM_ER_LC)) - { - bitfile ld_sbr = {0}; - uint32_t i; - uint16_t count = 0; - uint8_t *revbuffer; - uint8_t *prevbufstart; - uint8_t *pbufend; - - /* all forward bitreading should be finished at this point */ - uint32_t bitsconsumed = faad_get_processed_bits(ld); - uint32_t buffer_size = faad_origbitbuffer_size(ld); - uint8_t *buffer = (uint8_t*)faad_origbitbuffer(ld); - - if (bitsconsumed + 8 > buffer_size*8) - { - hInfo->error = 14; - return; - } - - if (!hDecoder->sbr[0]) - { - hDecoder->sbr[0] = sbrDecodeInit(hDecoder->frameLength, hDecoder->element_id[0], - 2*get_sample_rate(hDecoder->sf_index), 0 /* ds SBR */, 1); -#ifndef FAAD_STATIC_ALLOC - if (hDecoder->sbr[0] == NULL) - { - /* could not allocate memory */ - hInfo->error = 28; - return; - } -#endif - } - - /* Reverse bit reading of SBR data in DRM audio frame */ - revbuffer = (uint8_t*)faad_malloc(buffer_size*sizeof(uint8_t)); - if (revbuffer == NULL) - { - /* could not allocate memory */ - hInfo->error = 28; - return; - } - prevbufstart = revbuffer; - pbufend = &buffer[buffer_size - 1]; - for (i = 0; i < buffer_size; i++) - *prevbufstart++ = tabFlipbits[*pbufend--]; - - /* Set SBR data */ - /* consider 8 bits from AAC-CRC */ - count = (uint16_t)bit2byte(buffer_size*8 - bitsconsumed); - faad_initbits(&ld_sbr, revbuffer, count); - - hDecoder->sbr[0]->sample_rate = get_sample_rate(hDecoder->sf_index); - hDecoder->sbr[0]->sample_rate *= 2; - - faad_getbits(&ld_sbr, 8); /* Skip 8-bit CRC */ - - hDecoder->sbr[0]->ret = sbr_extension_data(&ld_sbr, hDecoder->sbr[0], count); -#if (defined(PS_DEC) || defined(DRM_PS)) - if (hDecoder->sbr[0]->ps_used) - { - hDecoder->ps_used[0] = 1; - hDecoder->ps_used_global = 1; - } -#endif - - /* check CRC */ - /* no need to check it if there was already an error */ - if (hDecoder->sbr[0]->ret == 0) - hDecoder->sbr[0]->ret = (uint8_t)faad_check_CRC(&ld_sbr, (uint16_t)faad_get_processed_bits(&ld_sbr) - 8); - - /* SBR data was corrupted, disable it until the next header */ - if (hDecoder->sbr[0]->ret != 0) - { - hDecoder->sbr[0]->header_count = 0; - } - - faad_endbits(&ld_sbr); - - if (revbuffer) - faad_free(revbuffer); - } -#endif -#endif - - if (this_layer_stereo) - { - hInfo->error = reconstruct_channel_pair(hDecoder, ics1, ics2, &cpe, spec_data1, spec_data2); - if (hInfo->error > 0) - return; - } else { - hInfo->error = reconstruct_single_channel(hDecoder, ics1, &cpe, spec_data1); - if (hInfo->error > 0) - return; - } - - /* map output channels position to internal data channels */ - if (hDecoder->element_output_channels[hDecoder->fr_ch_ele] == 2) - { - /* this might be faulty when pce_set is true */ - hDecoder->internal_channel[channels] = channels; - hDecoder->internal_channel[channels+1] = channels+1; - } else { - hDecoder->internal_channel[channels] = channels; - } - - hDecoder->fr_channels += hDecoder->element_output_channels[hDecoder->fr_ch_ele]; - hDecoder->fr_ch_ele++; - - return; -} - -/* Table 4.4.15 */ -static int8_t aac_scalable_main_header(NeAACDecHandle hDecoder, ic_stream *ics1, ic_stream *ics2, - bitfile *ld, uint8_t this_layer_stereo) -{ - uint8_t retval = 0; - uint8_t ch; - ic_stream *ics; - - /* ics1->ics_reserved_bit = */ faad_get1bit(ld - DEBUGVAR(1,300,"aac_scalable_main_header(): ics_reserved_bits")); - ics1->window_sequence = (uint8_t)faad_getbits(ld, 2 - DEBUGVAR(1,301,"aac_scalable_main_header(): window_sequence")); - ics1->window_shape = faad_get1bit(ld - DEBUGVAR(1,302,"aac_scalable_main_header(): window_shape")); - - if (ics1->window_sequence == EIGHT_SHORT_SEQUENCE) - { - ics1->max_sfb = (uint8_t)faad_getbits(ld, 4 - DEBUGVAR(1,303,"aac_scalable_main_header(): max_sfb (short)")); - ics1->scale_factor_grouping = (uint8_t)faad_getbits(ld, 7 - DEBUGVAR(1,304,"aac_scalable_main_header(): scale_factor_grouping")); - } else { - ics1->max_sfb = (uint8_t)faad_getbits(ld, 6 - DEBUGVAR(1,305,"aac_scalable_main_header(): max_sfb (long)")); - } - - /* get the grouping information */ - if ((retval = window_grouping_info(hDecoder, ics1)) > 0) - return retval; - - /* should be an error */ - /* check the range of max_sfb */ - if (ics1->max_sfb > ics1->num_swb) - return 16; - - if (this_layer_stereo) - { - ics1->ms_mask_present = (uint8_t)faad_getbits(ld, 2 - DEBUGVAR(1,306,"aac_scalable_main_header(): ms_mask_present")); - if (ics1->ms_mask_present == 1) - { - uint8_t g, sfb; - for (g = 0; g < ics1->num_window_groups; g++) - { - for (sfb = 0; sfb < ics1->max_sfb; sfb++) - { - ics1->ms_used[g][sfb] = faad_get1bit(ld - DEBUGVAR(1,307,"aac_scalable_main_header(): faad_get1bit")); - } - } - } - - memcpy(ics2, ics1, sizeof(ic_stream)); - } else { - ics1->ms_mask_present = 0; - } - - if (0) - { - faad_get1bit(ld - DEBUGVAR(1,308,"aac_scalable_main_header(): tns_channel_mono_layer")); - } - - for (ch = 0; ch < (this_layer_stereo ? 2 : 1); ch++) - { - if (ch == 0) - ics = ics1; - else - ics = ics2; - - if ( 1 /*!tvq_layer_pesent || (tns_aac_tvq_en[ch] == 1)*/) - { - if ((ics->tns_data_present = faad_get1bit(ld - DEBUGVAR(1,309,"aac_scalable_main_header(): tns_data_present"))) & 1) - { -#ifdef DRM - /* different order of data units in DRM */ - if (hDecoder->object_type != DRM_ER_LC) -#endif - { - tns_data(ics, &(ics->tns), ld); - } - } - } -#if 0 - if (0 /*core_flag || tvq_layer_pesent*/) - { - if ((ch==0) || ((ch==1) && (core_stereo || tvq_stereo)) - diff_control_data(); - if (mono_stereo_flag) - diff_control_data_lr(); - } else { -#endif - if (( -#ifdef LTP_DEC - ics->ltp.data_present = -#endif - faad_get1bit(ld DEBUGVAR(1,310,"aac_scalable_main_header(): ltp.data_present"))) & 1) - { -#ifdef LTP_DEC - if ((retval = ltp_data(hDecoder, ics, &(ics->ltp), ld)) > 0) - { - return retval; - } -#else - return 26; -#endif - } -#if 0 - } -#endif - } - - return 0; -} -#endif - -/* Table 4.4.24 */ -static uint8_t individual_channel_stream(NeAACDecHandle hDecoder, element *ele, - bitfile *ld, ic_stream *ics, uint8_t scal_flag, - int16_t *spec_data) -{ - uint8_t result; - - ics->global_gain = (uint8_t)faad_getbits(ld, 8 - DEBUGVAR(1,67,"individual_channel_stream(): global_gain")); - - if (!ele->common_window && !scal_flag) - { - if ((result = ics_info(hDecoder, ics, ld, ele->common_window)) > 0) - return result; - } - - if ((result = section_data(hDecoder, ics, ld)) > 0) - return result; - - if ((result = scale_factor_data(hDecoder, ics, ld)) > 0) - return result; - - if (!scal_flag) - { - /** - ** NOTE: It could be that pulse data is available in scalable AAC too, - ** as said in Amendment 1, this could be only the case for ER AAC, - ** though. (have to check this out later) - **/ - /* get pulse data */ - if ((ics->pulse_data_present = faad_get1bit(ld - DEBUGVAR(1,68,"individual_channel_stream(): pulse_data_present"))) & 1) - { - if ((result = pulse_data(ics, &(ics->pul), ld)) > 0) - return result; - } - - /* get tns data */ - if ((ics->tns_data_present = faad_get1bit(ld - DEBUGVAR(1,69,"individual_channel_stream(): tns_data_present"))) & 1) - { -#ifdef ERROR_RESILIENCE - if (hDecoder->object_type < ER_OBJECT_START) -#endif - tns_data(ics, &(ics->tns), ld); - } - - /* get gain control data */ - if ((ics->gain_control_data_present = faad_get1bit(ld - DEBUGVAR(1,70,"individual_channel_stream(): gain_control_data_present"))) & 1) - { -#ifdef SSR_DEC - if (hDecoder->object_type != SSR) - return 1; - else - gain_control_data(ld, ics); -#else - return 1; -#endif - } - } - -#ifdef ERROR_RESILIENCE - if (hDecoder->aacSpectralDataResilienceFlag) - { - ics->length_of_reordered_spectral_data = (uint16_t)faad_getbits(ld, 14 - DEBUGVAR(1,147,"individual_channel_stream(): length_of_reordered_spectral_data")); - - if (hDecoder->channelConfiguration == 2) - { - if (ics->length_of_reordered_spectral_data > 6144) - ics->length_of_reordered_spectral_data = 6144; - } else { - if (ics->length_of_reordered_spectral_data > 12288) - ics->length_of_reordered_spectral_data = 12288; - } - - ics->length_of_longest_codeword = (uint8_t)faad_getbits(ld, 6 - DEBUGVAR(1,148,"individual_channel_stream(): length_of_longest_codeword")); - if (ics->length_of_longest_codeword >= 49) - ics->length_of_longest_codeword = 49; - } - - /* RVLC spectral data is put here */ - if (hDecoder->aacScalefactorDataResilienceFlag) - { - if ((result = rvlc_decode_scale_factors(ics, ld)) > 0) - return result; - } - - if (hDecoder->object_type >= ER_OBJECT_START) - { - if (ics->tns_data_present) - tns_data(ics, &(ics->tns), ld); - } - -#ifdef DRM - /* CRC check */ - if (hDecoder->object_type == DRM_ER_LC) - if ((result = (uint8_t)faad_check_CRC(ld, (uint16_t)faad_get_processed_bits(ld) - 8)) > 0) - return result; -#endif - - if (hDecoder->aacSpectralDataResilienceFlag) - { - /* error resilient spectral data decoding */ - if ((result = reordered_spectral_data(hDecoder, ics, ld, spec_data)) > 0) - { - return result; - } - } else { -#endif - /* decode the spectral data */ - if ((result = spectral_data(hDecoder, ics, ld, spec_data)) > 0) - { - return result; - } -#ifdef ERROR_RESILIENCE - } -#endif - - /* pulse coding reconstruction */ - if (ics->pulse_data_present) - { - if (ics->window_sequence != EIGHT_SHORT_SEQUENCE) - { - if ((result = pulse_decode(ics, spec_data, hDecoder->frameLength)) > 0) - return result; - } else { - return 2; /* pulse coding not allowed for short blocks */ - } - } - - return 0; -} - -/* Table 4.4.25 */ -static uint8_t section_data(NeAACDecHandle hDecoder, ic_stream *ics, bitfile *ld) -{ - uint8_t g; - uint8_t sect_esc_val, sect_bits; - - if (ics->window_sequence == EIGHT_SHORT_SEQUENCE) - sect_bits = 3; - else - sect_bits = 5; - sect_esc_val = (1<max_sfb); - printf(" sect top cb\n"); -#endif - - for (g = 0; g < ics->num_window_groups; g++) - { - uint8_t k = 0; - uint8_t i = 0; - - while (k < ics->max_sfb) - { -#ifdef ERROR_RESILIENCE - uint8_t vcb11 = 0; -#endif - uint8_t sfb; - uint8_t sect_len_incr; - uint16_t sect_len = 0; - uint8_t sect_cb_bits = 4; - - /* if "faad_getbits" detects error and returns "0", "k" is never - incremented and we cannot leave the while loop */ - if ((ld->error != 0) || (ld->no_more_reading)) - return 14; - -#ifdef ERROR_RESILIENCE - if (hDecoder->aacSectionDataResilienceFlag) - sect_cb_bits = 5; -#else - (void) hDecoder; -#endif - - ics->sect_cb[g][i] = (uint8_t)faad_getbits(ld, sect_cb_bits - DEBUGVAR(1,71,"section_data(): sect_cb")); - -#if 0 - printf("%d\n", ics->sect_cb[g][i]); -#endif - - if (ics->sect_cb[g][i] == NOISE_HCB) - ics->noise_used = 1; - -#ifdef ERROR_RESILIENCE - if (hDecoder->aacSectionDataResilienceFlag) - { - if ((ics->sect_cb[g][i] == 11) || - ((ics->sect_cb[g][i] >= 16) && (ics->sect_cb[g][i] <= 32))) - { - vcb11 = 1; - } - } - if (vcb11) - { - sect_len_incr = 1; - } else { -#endif - sect_len_incr = (uint8_t)faad_getbits(ld, sect_bits - DEBUGVAR(1,72,"section_data(): sect_len_incr")); -#ifdef ERROR_RESILIENCE - } -#endif - while ((sect_len_incr == sect_esc_val) /* && - (k+sect_len < ics->max_sfb)*/) - { - sect_len += sect_len_incr; - sect_len_incr = (uint8_t)faad_getbits(ld, sect_bits - DEBUGVAR(1,72,"section_data(): sect_len_incr")); - } - - sect_len += sect_len_incr; - - ics->sect_start[g][i] = k; - ics->sect_end[g][i] = k + sect_len; - -#if 0 - printf("%d\n", ics->sect_start[g][i]); -#endif -#if 0 - printf("%d\n", ics->sect_end[g][i]); -#endif - - if (k + sect_len >= 8*15) - return 15; - if (i >= 8*15) - return 15; - - for (sfb = k; sfb < k + sect_len; sfb++) - { - ics->sfb_cb[g][sfb] = ics->sect_cb[g][i]; -#if 0 - printf("%d\n", ics->sfb_cb[g][sfb]); -#endif - } - -#if 0 - printf(" %6d %6d %6d\n", - i, - ics->sect_end[g][i], - ics->sect_cb[g][i]); -#endif - - k += sect_len; - i++; - } - ics->num_sec[g] = i; -#if 0 - printf("%d\n", ics->num_sec[g]); -#endif - } - -#if 0 - printf("\n"); -#endif - - return 0; -} - -/* - * decode_scale_factors() - * decodes the scalefactors from the bitstream - */ -/* - * All scalefactors (and also the stereo positions and pns energies) are - * transmitted using Huffman coded DPCM relative to the previous active - * scalefactor (respectively previous stereo position or previous pns energy, - * see subclause 4.6.2 and 4.6.3). The first active scalefactor is - * differentially coded relative to the global gain. - */ -static uint8_t decode_scale_factors(ic_stream *ics, bitfile *ld) -{ - uint8_t g, sfb; - int16_t t; - int8_t noise_pcm_flag = 1; - - int16_t scale_factor = ics->global_gain; - int16_t is_position = 0; - int16_t noise_energy = ics->global_gain - 90; - - for (g = 0; g < ics->num_window_groups; g++) - { - for (sfb = 0; sfb < ics->max_sfb; sfb++) - { - switch (ics->sfb_cb[g][sfb]) - { - case ZERO_HCB: /* zero book */ - ics->scale_factors[g][sfb] = 0; -//#define SF_PRINT -#ifdef SF_PRINT - printf("%d\n", ics->scale_factors[g][sfb]); -#endif - break; - case INTENSITY_HCB: /* intensity books */ - case INTENSITY_HCB2: - - /* decode intensity position */ - t = huffman_scale_factor(ld); - is_position += (t - 60); - ics->scale_factors[g][sfb] = is_position; -#ifdef SF_PRINT - printf("%d\n", ics->scale_factors[g][sfb]); -#endif - - break; - case NOISE_HCB: /* noise books */ - - /* decode noise energy */ - if (noise_pcm_flag) - { - noise_pcm_flag = 0; - t = (int16_t)faad_getbits(ld, 9 - DEBUGVAR(1,73,"scale_factor_data(): first noise")) - 256; - } else { - t = huffman_scale_factor(ld); - t -= 60; - } - noise_energy += t; - ics->scale_factors[g][sfb] = noise_energy; -#ifdef SF_PRINT - printf("%d\n", ics->scale_factors[g][sfb]); -#endif - - break; - default: /* spectral books */ - - /* ics->scale_factors[g][sfb] must be between 0 and 255 */ - - ics->scale_factors[g][sfb] = 0; - - /* decode scale factor */ - t = huffman_scale_factor(ld); - scale_factor += (t - 60); - if (scale_factor < 0 || scale_factor > 255) - return 4; - ics->scale_factors[g][sfb] = scale_factor; -#ifdef SF_PRINT - printf("%d\n", ics->scale_factors[g][sfb]); -#endif - - break; - } - } - } - - return 0; -} - -/* Table 4.4.26 */ -static uint8_t scale_factor_data(NeAACDecHandle hDecoder, ic_stream *ics, bitfile *ld) -{ - uint8_t ret = 0; -#ifdef PROFILE - int64_t count = faad_get_ts(); -#endif - -#ifdef ERROR_RESILIENCE - if (!hDecoder->aacScalefactorDataResilienceFlag) - { -#else - (void) hDecoder; -#endif - ret = decode_scale_factors(ics, ld); -#ifdef ERROR_RESILIENCE - } else { - /* In ER AAC the parameters for RVLC are seperated from the actual - data that holds the scale_factors. - Strangely enough, 2 parameters for HCR are put inbetween them. - */ - ret = rvlc_scale_factor_data(ics, ld); - } -#endif - -#ifdef PROFILE - count = faad_get_ts() - count; - hDecoder->scalefac_cycles += count; -#endif - - return ret; -} - -/* Table 4.4.27 */ -static void tns_data(ic_stream *ics, tns_info *tns, bitfile *ld) -{ - uint8_t w, filt, i, start_coef_bits = 0; - int8_t coef_bits; - uint8_t n_filt_bits = 2; - uint8_t length_bits = 6; - uint8_t order_bits = 5; - - if (ics->window_sequence == EIGHT_SHORT_SEQUENCE) - { - n_filt_bits = 1; - length_bits = 4; - order_bits = 3; - } - - for (w = 0; w < ics->num_windows; w++) - { - tns->n_filt[w] = (uint8_t)faad_getbits(ld, n_filt_bits - DEBUGVAR(1,74,"tns_data(): n_filt")); -#if 0 - printf("%d\n", tns->n_filt[w]); -#endif - - if (tns->n_filt[w]) - { - if ((tns->coef_res[w] = faad_get1bit(ld - DEBUGVAR(1,75,"tns_data(): coef_res"))) & 1) - { - start_coef_bits = 4; - } else { - start_coef_bits = 3; - } -#if 0 - printf("%d\n", tns->coef_res[w]); -#endif - } - - for (filt = 0; filt < tns->n_filt[w]; filt++) - { - tns->length[w][filt] = (uint8_t)faad_getbits(ld, length_bits - DEBUGVAR(1,76,"tns_data(): length")); -#if 0 - printf("%d\n", tns->length[w][filt]); -#endif - tns->order[w][filt] = (uint8_t)faad_getbits(ld, order_bits - DEBUGVAR(1,77,"tns_data(): order")); -#if 0 - printf("%d\n", tns->order[w][filt]); -#endif - if (tns->order[w][filt]) - { - tns->direction[w][filt] = faad_get1bit(ld - DEBUGVAR(1,78,"tns_data(): direction")); -#if 0 - printf("%d\n", tns->direction[w][filt]); -#endif - tns->coef_compress[w][filt] = faad_get1bit(ld - DEBUGVAR(1,79,"tns_data(): coef_compress")); -#if 0 - printf("%d\n", tns->coef_compress[w][filt]); -#endif - - coef_bits = start_coef_bits - tns->coef_compress[w][filt]; - for (i = 0; i < tns->order[w][filt]; i++) - { - tns->coef[w][filt][i] = (uint8_t)faad_getbits(ld, coef_bits - DEBUGVAR(1,80,"tns_data(): coef")); -#if 0 - printf("%d\n", tns->coef[w][filt][i]); -#endif - } - } - } - } -} - -#ifdef LTP_DEC -/* Table 4.4.28 */ -static uint8_t ltp_data(NeAACDecHandle hDecoder, ic_stream *ics, ltp_info *ltp, bitfile *ld) -{ - uint8_t sfb, w; - - ltp->lag = 0; - -#ifdef LD_DEC - if (hDecoder->object_type == LD) - { - ltp->lag_update = (uint8_t)faad_getbits(ld, 1 - DEBUGVAR(1,142,"ltp_data(): lag_update")); - - if (ltp->lag_update) - { - ltp->lag = (uint16_t)faad_getbits(ld, 10 - DEBUGVAR(1,81,"ltp_data(): lag")); - } - } else { -#endif - ltp->lag = (uint16_t)faad_getbits(ld, 11 - DEBUGVAR(1,81,"ltp_data(): lag")); -#ifdef LD_DEC - } -#endif - - /* Check length of lag */ - if (ltp->lag > (hDecoder->frameLength << 1)) - return 18; - - ltp->coef = (uint8_t)faad_getbits(ld, 3 - DEBUGVAR(1,82,"ltp_data(): coef")); - - if (ics->window_sequence == EIGHT_SHORT_SEQUENCE) - { - for (w = 0; w < ics->num_windows; w++) - { - if ((ltp->short_used[w] = faad_get1bit(ld - DEBUGVAR(1,83,"ltp_data(): short_used"))) & 1) - { - ltp->short_lag_present[w] = faad_get1bit(ld - DEBUGVAR(1,84,"ltp_data(): short_lag_present")); - if (ltp->short_lag_present[w]) - { - ltp->short_lag[w] = (uint8_t)faad_getbits(ld, 4 - DEBUGVAR(1,85,"ltp_data(): short_lag")); - } - } - } - } else { - ltp->last_band = (ics->max_sfb < MAX_LTP_SFB ? ics->max_sfb : MAX_LTP_SFB); - - for (sfb = 0; sfb < ltp->last_band; sfb++) - { - ltp->long_used[sfb] = faad_get1bit(ld - DEBUGVAR(1,86,"ltp_data(): long_used")); - } - } - - return 0; -} -#endif - -/* Table 4.4.29 */ -static uint8_t spectral_data(NeAACDecHandle hDecoder, ic_stream *ics, bitfile *ld, - int16_t *spectral_data) -{ - int8_t i; - uint8_t g; - uint16_t inc, k, p = 0; - uint8_t groups = 0; - uint8_t sect_cb; - uint8_t result; - uint16_t nshort = hDecoder->frameLength/8; - -#ifdef PROFILE - int64_t count = faad_get_ts(); -#endif - - for(g = 0; g < ics->num_window_groups; g++) - { - p = groups*nshort; - - for (i = 0; i < ics->num_sec[g]; i++) - { - sect_cb = ics->sect_cb[g][i]; - - inc = (sect_cb >= FIRST_PAIR_HCB) ? 2 : 4; - - switch (sect_cb) - { - case ZERO_HCB: - case NOISE_HCB: - case INTENSITY_HCB: - case INTENSITY_HCB2: -//#define SD_PRINT -#ifdef SD_PRINT - { - int j; - for (j = ics->sect_sfb_offset[g][ics->sect_start[g][i]]; j < ics->sect_sfb_offset[g][ics->sect_end[g][i]]; j++) - { - printf("%d\n", 0); - } - } -#endif -//#define SFBO_PRINT -#ifdef SFBO_PRINT - printf("%d\n", ics->sect_sfb_offset[g][ics->sect_start[g][i]]); -#endif - p += (ics->sect_sfb_offset[g][ics->sect_end[g][i]] - - ics->sect_sfb_offset[g][ics->sect_start[g][i]]); - break; - default: -#ifdef SFBO_PRINT - printf("%d\n", ics->sect_sfb_offset[g][ics->sect_start[g][i]]); -#endif - for (k = ics->sect_sfb_offset[g][ics->sect_start[g][i]]; - k < ics->sect_sfb_offset[g][ics->sect_end[g][i]]; k += inc) - { - if ((result = huffman_spectral_data(sect_cb, ld, &spectral_data[p])) > 0) - return result; -#ifdef SD_PRINT - { - int j; - for (j = p; j < p+inc; j++) - { - printf("%d\n", spectral_data[j]); - } - } -#endif - p += inc; - } - break; - } - } - groups += ics->window_group_length[g]; - } - -#ifdef PROFILE - count = faad_get_ts() - count; - hDecoder->spectral_cycles += count; -#endif - - return 0; -} - -/* Table 4.4.30 */ -static uint16_t extension_payload(bitfile *ld, drc_info *drc, uint16_t count) -{ - uint16_t i, n, dataElementLength; - uint8_t dataElementLengthPart; - uint8_t align = 4, data_element_version, loopCounter; - - uint8_t extension_type = (uint8_t)faad_getbits(ld, 4 - DEBUGVAR(1,87,"extension_payload(): extension_type")); - - switch (extension_type) - { - case EXT_DYNAMIC_RANGE: - drc->present = 1; - n = dynamic_range_info(ld, drc); - return n; - case EXT_FILL_DATA: - /* fill_nibble = */ faad_getbits(ld, 4 - DEBUGVAR(1,136,"extension_payload(): fill_nibble")); /* must be "0000" */ - for (i = 0; i < count-1; i++) - { - /* fill_byte[i] = */ faad_getbits(ld, 8 - DEBUGVAR(1,88,"extension_payload(): fill_byte")); /* must be "10100101" */ - } - return count; - case EXT_DATA_ELEMENT: - data_element_version = (uint8_t)faad_getbits(ld, 4 - DEBUGVAR(1,400,"extension_payload(): data_element_version")); - switch (data_element_version) - { - case ANC_DATA: - loopCounter = 0; - dataElementLength = 0; - do { - dataElementLengthPart = (uint8_t)faad_getbits(ld, 8 - DEBUGVAR(1,401,"extension_payload(): dataElementLengthPart")); - dataElementLength += dataElementLengthPart; - loopCounter++; - } while (dataElementLengthPart == 255); - - for (i = 0; i < dataElementLength; i++) - { - /* data_element_byte[i] = */ faad_getbits(ld, 8 - DEBUGVAR(1,402,"extension_payload(): data_element_byte")); - return (dataElementLength+loopCounter+1); - } - default: - align = 0; - } - case EXT_FIL: - default: - faad_getbits(ld, align - DEBUGVAR(1,88,"extension_payload(): fill_nibble")); - for (i = 0; i < count-1; i++) - { - /* other_bits[i] = */ faad_getbits(ld, 8 - DEBUGVAR(1,89,"extension_payload(): fill_bit")); - } - return count; - } -} - -/* Table 4.4.31 */ -static uint8_t dynamic_range_info(bitfile *ld, drc_info *drc) -{ - uint8_t i, n = 1; - uint8_t band_incr; - - drc->num_bands = 1; - - if (faad_get1bit(ld - DEBUGVAR(1,90,"dynamic_range_info(): has instance_tag")) & 1) - { - drc->pce_instance_tag = (uint8_t)faad_getbits(ld, 4 - DEBUGVAR(1,91,"dynamic_range_info(): pce_instance_tag")); - /* drc->drc_tag_reserved_bits = */ faad_getbits(ld, 4 - DEBUGVAR(1,92,"dynamic_range_info(): drc_tag_reserved_bits")); - n++; - } - - drc->excluded_chns_present = faad_get1bit(ld - DEBUGVAR(1,93,"dynamic_range_info(): excluded_chns_present")); - if (drc->excluded_chns_present == 1) - { - n += excluded_channels(ld, drc); - } - - if (faad_get1bit(ld - DEBUGVAR(1,94,"dynamic_range_info(): has bands data")) & 1) - { - band_incr = (uint8_t)faad_getbits(ld, 4 - DEBUGVAR(1,95,"dynamic_range_info(): band_incr")); - /* drc->drc_bands_reserved_bits = */ faad_getbits(ld, 4 - DEBUGVAR(1,96,"dynamic_range_info(): drc_bands_reserved_bits")); - n++; - drc->num_bands += band_incr; - - for (i = 0; i < drc->num_bands; i++) - { - drc->band_top[i] = (uint8_t)faad_getbits(ld, 8 - DEBUGVAR(1,97,"dynamic_range_info(): band_top")); - n++; - } - } - - if (faad_get1bit(ld - DEBUGVAR(1,98,"dynamic_range_info(): has prog_ref_level")) & 1) - { - drc->prog_ref_level = (uint8_t)faad_getbits(ld, 7 - DEBUGVAR(1,99,"dynamic_range_info(): prog_ref_level")); - /* drc->prog_ref_level_reserved_bits = */ faad_get1bit(ld - DEBUGVAR(1,100,"dynamic_range_info(): prog_ref_level_reserved_bits")); - n++; - } - - for (i = 0; i < drc->num_bands; i++) - { - drc->dyn_rng_sgn[i] = faad_get1bit(ld - DEBUGVAR(1,101,"dynamic_range_info(): dyn_rng_sgn")); - drc->dyn_rng_ctl[i] = (uint8_t)faad_getbits(ld, 7 - DEBUGVAR(1,102,"dynamic_range_info(): dyn_rng_ctl")); - n++; - } - - return n; -} - -/* Table 4.4.32 */ -static uint8_t excluded_channels(bitfile *ld, drc_info *drc) -{ - uint8_t i, n = 0; - uint8_t num_excl_chan = 7; - - for (i = 0; i < 7; i++) - { - drc->exclude_mask[i] = faad_get1bit(ld - DEBUGVAR(1,103,"excluded_channels(): exclude_mask")); - } - n++; - - while ((drc->additional_excluded_chns[n-1] = faad_get1bit(ld - DEBUGVAR(1,104,"excluded_channels(): additional_excluded_chns"))) == 1) - { - for (i = num_excl_chan; i < num_excl_chan+7; i++) - { - drc->exclude_mask[i] = faad_get1bit(ld - DEBUGVAR(1,105,"excluded_channels(): exclude_mask")); - } - n++; - num_excl_chan += 7; - } - - return n; -} - -/* Annex A: Audio Interchange Formats */ - -/* Table 1.A.2 */ -void get_adif_header(adif_header *adif, bitfile *ld) -{ - uint8_t i; - - /* adif_id[0] = */ faad_getbits(ld, 8 - DEBUGVAR(1,106,"get_adif_header(): adif_id[0]")); - /* adif_id[1] = */ faad_getbits(ld, 8 - DEBUGVAR(1,107,"get_adif_header(): adif_id[1]")); - /* adif_id[2] = */ faad_getbits(ld, 8 - DEBUGVAR(1,108,"get_adif_header(): adif_id[2]")); - /* adif_id[3] = */ faad_getbits(ld, 8 - DEBUGVAR(1,109,"get_adif_header(): adif_id[3]")); - adif->copyright_id_present = faad_get1bit(ld - DEBUGVAR(1,110,"get_adif_header(): copyright_id_present")); - if(adif->copyright_id_present) - { - for (i = 0; i < 72/8; i++) - { - adif->copyright_id[i] = (int8_t)faad_getbits(ld, 8 - DEBUGVAR(1,111,"get_adif_header(): copyright_id")); - } - adif->copyright_id[i] = 0; - } - adif->original_copy = faad_get1bit(ld - DEBUGVAR(1,112,"get_adif_header(): original_copy")); - adif->home = faad_get1bit(ld - DEBUGVAR(1,113,"get_adif_header(): home")); - adif->bitstream_type = faad_get1bit(ld - DEBUGVAR(1,114,"get_adif_header(): bitstream_type")); - adif->bitrate = faad_getbits(ld, 23 - DEBUGVAR(1,115,"get_adif_header(): bitrate")); - adif->num_program_config_elements = (uint8_t)faad_getbits(ld, 4 - DEBUGVAR(1,116,"get_adif_header(): num_program_config_elements")); - - for (i = 0; i < adif->num_program_config_elements + 1; i++) - { - if(adif->bitstream_type == 0) - { - adif->adif_buffer_fullness = faad_getbits(ld, 20 - DEBUGVAR(1,117,"get_adif_header(): adif_buffer_fullness")); - } else { - adif->adif_buffer_fullness = 0; - } - - program_config_element(&adif->pce[i], ld); - } -} - -/* Table 1.A.5 */ -uint8_t adts_frame(adts_header *adts, bitfile *ld) -{ - /* faad_byte_align(ld); */ - if (adts_fixed_header(adts, ld)) - return 5; - adts_variable_header(adts, ld); - adts_error_check(adts, ld); - - return 0; -} - -/* Table 1.A.6 */ -static uint8_t adts_fixed_header(adts_header *adts, bitfile *ld) -{ - uint16_t i; - uint8_t sync_err = 1; - - /* try to recover from sync errors */ - for (i = 0; i < 768; i++) - { - adts->syncword = (uint16_t)faad_showbits(ld, 12); - if (adts->syncword != 0xFFF) - { - faad_getbits(ld, 8 - DEBUGVAR(0,0,"")); - } else { - sync_err = 0; - faad_getbits(ld, 12 - DEBUGVAR(1,118,"adts_fixed_header(): syncword")); - break; - } - } - if (sync_err) - return 5; - - adts->id = faad_get1bit(ld - DEBUGVAR(1,119,"adts_fixed_header(): id")); - adts->layer = (uint8_t)faad_getbits(ld, 2 - DEBUGVAR(1,120,"adts_fixed_header(): layer")); - adts->protection_absent = faad_get1bit(ld - DEBUGVAR(1,121,"adts_fixed_header(): protection_absent")); - adts->profile = (uint8_t)faad_getbits(ld, 2 - DEBUGVAR(1,122,"adts_fixed_header(): profile")); - adts->sf_index = (uint8_t)faad_getbits(ld, 4 - DEBUGVAR(1,123,"adts_fixed_header(): sf_index")); - adts->private_bit = faad_get1bit(ld - DEBUGVAR(1,124,"adts_fixed_header(): private_bit")); - adts->channel_configuration = (uint8_t)faad_getbits(ld, 3 - DEBUGVAR(1,125,"adts_fixed_header(): channel_configuration")); - adts->original = faad_get1bit(ld - DEBUGVAR(1,126,"adts_fixed_header(): original")); - adts->home = faad_get1bit(ld - DEBUGVAR(1,127,"adts_fixed_header(): home")); - - if (adts->old_format == 1) - { - /* Removed in corrigendum 14496-3:2002 */ - if (adts->id == 0) - { - adts->emphasis = (uint8_t)faad_getbits(ld, 2 - DEBUGVAR(1,128,"adts_fixed_header(): emphasis")); - } - } - - return 0; -} - -/* Table 1.A.7 */ -static void adts_variable_header(adts_header *adts, bitfile *ld) -{ - adts->copyright_identification_bit = faad_get1bit(ld - DEBUGVAR(1,129,"adts_variable_header(): copyright_identification_bit")); - adts->copyright_identification_start = faad_get1bit(ld - DEBUGVAR(1,130,"adts_variable_header(): copyright_identification_start")); - adts->aac_frame_length = (uint16_t)faad_getbits(ld, 13 - DEBUGVAR(1,131,"adts_variable_header(): aac_frame_length")); - adts->adts_buffer_fullness = (uint16_t)faad_getbits(ld, 11 - DEBUGVAR(1,132,"adts_variable_header(): adts_buffer_fullness")); - adts->no_raw_data_blocks_in_frame = (uint8_t)faad_getbits(ld, 2 - DEBUGVAR(1,133,"adts_variable_header(): no_raw_data_blocks_in_frame")); -} - -/* Table 1.A.8 */ -static void adts_error_check(adts_header *adts, bitfile *ld) -{ - if (adts->protection_absent == 0) - { - adts->crc_check = (uint16_t)faad_getbits(ld, 16 - DEBUGVAR(1,134,"adts_error_check(): crc_check")); - } -} diff --git a/apps/codecs/libfaad/syntax.h b/apps/codecs/libfaad/syntax.h deleted file mode 100644 index f9efde7d9b..0000000000 --- a/apps/codecs/libfaad/syntax.h +++ /dev/null @@ -1,124 +0,0 @@ -/* -** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -** -** Any non-GPL usage of this software or parts of this software is strictly -** forbidden. -** -** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. -** -** $Id$ -**/ - -#ifndef __SYNTAX_H__ -#define __SYNTAX_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -#include "decoder.h" -#include "bits.h" - -#define MAIN 1 -#define LC 2 -#define SSR 3 -#define LTP 4 -#define HE_AAC 5 -#define LD 23 -#define ER_LC 17 -#define ER_LTP 19 -#define DRM_ER_LC 27 /* special object type for DRM */ - -/* header types */ -#define RAW 0 -#define ADIF 1 -#define ADTS 2 - -/* SBR signalling */ -#define NO_SBR 0 -#define SBR_UPSAMPLED 1 -#define SBR_DOWNSAMPLED 2 -#define NO_SBR_UPSAMPLED 3 - -/* DRM channel definitions */ -#define DRMCH_MONO 1 -#define DRMCH_STEREO 2 -#define DRMCH_SBR_MONO 3 -#define DRMCH_SBR_STEREO 4 -#define DRMCH_SBR_PS_STEREO 5 - - -/* First object type that has ER */ -#define ER_OBJECT_START 17 - - -/* Bitstream */ -#define LEN_SE_ID 3 -#define LEN_TAG 4 -#define LEN_BYTE 8 - -#define EXT_FIL 0 -#define EXT_FILL_DATA 1 -#define EXT_DATA_ELEMENT 2 -#define EXT_DYNAMIC_RANGE 11 -#define ANC_DATA 0 - -/* Syntax elements */ -#define ID_SCE 0x0 -#define ID_CPE 0x1 -#define ID_CCE 0x2 -#define ID_LFE 0x3 -#define ID_DSE 0x4 -#define ID_PCE 0x5 -#define ID_FIL 0x6 -#define ID_END 0x7 - -#define ONLY_LONG_SEQUENCE 0x0 -#define LONG_START_SEQUENCE 0x1 -#define EIGHT_SHORT_SEQUENCE 0x2 -#define LONG_STOP_SEQUENCE 0x3 - -#define ZERO_HCB 0 -#define FIRST_PAIR_HCB 5 -#define ESC_HCB 11 -#define QUAD_LEN 4 -#define PAIR_LEN 2 -#define NOISE_HCB 13 -#define INTENSITY_HCB2 14 -#define INTENSITY_HCB 15 - -#define INVALID_SBR_ELEMENT 255 - -int8_t GASpecificConfig(bitfile *ld, mp4AudioSpecificConfig *mp4ASC, - program_config *pce); - -uint8_t adts_frame(adts_header *adts, bitfile *ld); -void get_adif_header(adif_header *adif, bitfile *ld); -void raw_data_block(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hInfo, - bitfile *ld, program_config *pce, drc_info *drc); -uint8_t reordered_spectral_data(NeAACDecHandle hDecoder, ic_stream *ics, bitfile *ld, - int16_t *spectral_data); -void aac_scalable_main_element(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hInfo, - bitfile *ld, program_config *pce, drc_info *drc); - - -#ifdef __cplusplus -} -#endif -#endif diff --git a/apps/codecs/libfaad/tns.c b/apps/codecs/libfaad/tns.c deleted file mode 100644 index a2bec86519..0000000000 --- a/apps/codecs/libfaad/tns.c +++ /dev/null @@ -1,312 +0,0 @@ -/* -** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -** -** Any non-GPL usage of this software or parts of this software is strictly -** forbidden. -** -** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. -** -** $Id$ -**/ - -#include "common.h" -#include "structs.h" - -#include "syntax.h" -#include "tns.h" - - -/* static function declarations */ -static void tns_decode_coef(uint8_t order, uint8_t coef_res_bits, uint8_t coef_compress, - uint8_t *coef, real_t *a); -static void tns_ar_filter(real_t *spectrum, uint16_t size, int8_t inc, real_t *lpc, - int8_t order); -#ifdef LTP_DEC -static void tns_ma_filter(real_t *spectrum, uint16_t size, int8_t inc, real_t *lpc, - int8_t order); -#endif - - -#ifdef _MSC_VER -#pragma warning(disable:4305) -#pragma warning(disable:4244) -#endif -static real_t tns_coef_0_3[] = -{ - COEF_CONST(0.0), COEF_CONST(0.4338837391), COEF_CONST(0.7818314825), COEF_CONST(0.9749279122), - COEF_CONST(-0.9848077530), COEF_CONST(-0.8660254038), COEF_CONST(-0.6427876097), COEF_CONST(-0.3420201433), - COEF_CONST(-0.4338837391), COEF_CONST(-0.7818314825), COEF_CONST(-0.9749279122), COEF_CONST(-0.9749279122), - COEF_CONST(-0.9848077530), COEF_CONST(-0.8660254038), COEF_CONST(-0.6427876097), COEF_CONST(-0.3420201433) -}; -static real_t tns_coef_0_4[] = -{ - COEF_CONST(0.0), COEF_CONST(0.2079116908), COEF_CONST(0.4067366431), COEF_CONST(0.5877852523), - COEF_CONST(0.7431448255), COEF_CONST(0.8660254038), COEF_CONST(0.9510565163), COEF_CONST(0.9945218954), - COEF_CONST(-0.9957341763), COEF_CONST(-0.9618256432), COEF_CONST(-0.8951632914), COEF_CONST(-0.7980172273), - COEF_CONST(-0.6736956436), COEF_CONST(-0.5264321629), COEF_CONST(-0.3612416662), COEF_CONST(-0.1837495178) -}; -static real_t tns_coef_1_3[] = -{ - COEF_CONST(0.0), COEF_CONST(0.4338837391), COEF_CONST(-0.6427876097), COEF_CONST(-0.3420201433), - COEF_CONST(0.9749279122), COEF_CONST(0.7818314825), COEF_CONST(-0.6427876097), COEF_CONST(-0.3420201433), - COEF_CONST(-0.4338837391), COEF_CONST(-0.7818314825), COEF_CONST(-0.6427876097), COEF_CONST(-0.3420201433), - COEF_CONST(-0.7818314825), COEF_CONST(-0.4338837391), COEF_CONST(-0.6427876097), COEF_CONST(-0.3420201433) -}; -static real_t tns_coef_1_4[] = -{ - COEF_CONST(0.0), COEF_CONST(0.2079116908), COEF_CONST(0.4067366431), COEF_CONST(0.5877852523), - COEF_CONST(-0.6736956436), COEF_CONST(-0.5264321629), COEF_CONST(-0.3612416662), COEF_CONST(-0.1837495178), - COEF_CONST(0.9945218954), COEF_CONST(0.9510565163), COEF_CONST(0.8660254038), COEF_CONST(0.7431448255), - COEF_CONST(-0.6736956436), COEF_CONST(-0.5264321629), COEF_CONST(-0.3612416662), COEF_CONST(-0.1837495178) -}; - - -/* TNS decoding for one channel and frame */ -void tns_decode_frame(ic_stream *ics, tns_info *tns, uint8_t sr_index, - uint8_t object_type, real_t *spec, uint16_t frame_len) -{ - uint8_t w, f, tns_order; - int8_t inc; - int16_t size; - uint16_t bottom, top, start, end; - uint16_t nshort = frame_len/8; - real_t lpc[TNS_MAX_ORDER+1]; - - if (!ics->tns_data_present) - return; - - for (w = 0; w < ics->num_windows; w++) - { - bottom = ics->num_swb; - - for (f = 0; f < tns->n_filt[w]; f++) - { - top = bottom; - bottom = max(top - tns->length[w][f], 0); - tns_order = min(tns->order[w][f], TNS_MAX_ORDER); - if (!tns_order) - continue; - - tns_decode_coef(tns_order, tns->coef_res[w]+3, - tns->coef_compress[w][f], tns->coef[w][f], lpc); - - start = min(bottom, max_tns_sfb(sr_index, object_type, (ics->window_sequence == EIGHT_SHORT_SEQUENCE))); - start = min(start, ics->max_sfb); - start = ics->swb_offset[start]; - - end = min(top, max_tns_sfb(sr_index, object_type, (ics->window_sequence == EIGHT_SHORT_SEQUENCE))); - end = min(end, ics->max_sfb); - end = ics->swb_offset[end]; - - size = end - start; - if (size <= 0) - continue; - - if (tns->direction[w][f]) - { - inc = -1; - start = end - 1; - } else { - inc = 1; - } - - tns_ar_filter(&spec[(w*nshort)+start], size, inc, lpc, tns_order); - } - } -} - -#ifdef LTP_DEC -/* TNS encoding for one channel and frame */ -void tns_encode_frame(ic_stream *ics, tns_info *tns, uint8_t sr_index, - uint8_t object_type, real_t *spec, uint16_t frame_len) -{ - uint8_t w, f, tns_order; - int8_t inc; - int16_t size; - uint16_t bottom, top, start, end; - uint16_t nshort = frame_len/8; - real_t lpc[TNS_MAX_ORDER+1]; - - if (!ics->tns_data_present) - return; - - for (w = 0; w < ics->num_windows; w++) - { - bottom = ics->num_swb; - - for (f = 0; f < tns->n_filt[w]; f++) - { - top = bottom; - bottom = max(top - tns->length[w][f], 0); - tns_order = min(tns->order[w][f], TNS_MAX_ORDER); - if (!tns_order) - continue; - - tns_decode_coef(tns_order, tns->coef_res[w]+3, - tns->coef_compress[w][f], tns->coef[w][f], lpc); - - start = min(bottom, max_tns_sfb(sr_index, object_type, (ics->window_sequence == EIGHT_SHORT_SEQUENCE))); - start = min(start, ics->max_sfb); - start = ics->swb_offset[start]; - - end = min(top, max_tns_sfb(sr_index, object_type, (ics->window_sequence == EIGHT_SHORT_SEQUENCE))); - end = min(end, ics->max_sfb); - end = ics->swb_offset[end]; - - size = end - start; - if (size <= 0) - continue; - - if (tns->direction[w][f]) - { - inc = -1; - start = end - 1; - } else { - inc = 1; - } - - tns_ma_filter(&spec[(w*nshort)+start], size, inc, lpc, tns_order); - } - } -} -#endif - -/* Decoder transmitted coefficients for one TNS filter */ -static void tns_decode_coef(uint8_t order, uint8_t coef_res_bits, uint8_t coef_compress, - uint8_t *coef, real_t *a) -{ - uint8_t i, m; - real_t tmp2[TNS_MAX_ORDER+1], b[TNS_MAX_ORDER+1]; - - /* Conversion to signed integer */ - for (i = 0; i < order; i++) - { - if (coef_compress == 0) - { - if (coef_res_bits == 3) - { - tmp2[i] = tns_coef_0_3[coef[i]]; - } else { - tmp2[i] = tns_coef_0_4[coef[i]]; - } - } else { - if (coef_res_bits == 3) - { - tmp2[i] = tns_coef_1_3[coef[i]]; - } else { - tmp2[i] = tns_coef_1_4[coef[i]]; - } - } - } - - /* Conversion to LPC coefficients */ - a[0] = COEF_CONST(1.0); - for (m = 1; m <= order; m++) - { - for (i = 1; i < m; i++) /* loop only while i - Copyright (C) - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -Also add information on how to contact you by electronic and paper mail. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the library, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the - library `Frob' (a library for tweaking knobs) written by James Random Hacker. - - , 1 April 1990 - Ty Coon, President of Vice - -That's all there is to it! - - diff --git a/apps/codecs/libffmpegFLAC/README b/apps/codecs/libffmpegFLAC/README deleted file mode 100644 index 9bc0f6ed8a..0000000000 --- a/apps/codecs/libffmpegFLAC/README +++ /dev/null @@ -1,19 +0,0 @@ -FFmpeg README -------------- - -1) Documentation ----------------- - -* Read the documentation in the doc/ directory. - -2) Licensing ------------- - -* Read the file COPYING. ffmpeg and the associated libraries EXCEPT - liba52 and libpostproc are licensed under the Lesser GNU General - Public License. - -* liba52 and libpostproc are distributed under the GNU General Public - License and their compilation and use is optional in ffmpeg. - -Fabrice Bellard. \ No newline at end of file diff --git a/apps/codecs/libffmpegFLAC/README.rockbox b/apps/codecs/libffmpegFLAC/README.rockbox deleted file mode 100644 index 850cdfcb7d..0000000000 --- a/apps/codecs/libffmpegFLAC/README.rockbox +++ /dev/null @@ -1,46 +0,0 @@ -Library: libffmpegFLAC -Imported: 2005-10-26 by Dave Chapman - -This directory contains a FLAC decoder based on the flac.c (and a small -number of other files) from the ffmpeg project. - -LICENSING INFORMATION - -ffmpeg is licensed under the Lesser GNU General Public License and the -file flac.c is Copyright 2003 Alex Beregszaszi. - -IMPORT DETAILS - -The decoder is based on ffmpeg-cvs from 26 October 2005. - -The file libavcodec/flac.c was renamed to decoder.c and all ffmpeg -related code was removed. It was also heavily modified to remove -debugging information and unused experiemental code. - -It was also changed to provide output as 32-bit integers (with the -data left-shifted to 28 bit accuracy). The original flac.c provided -16-bit output. - -In order to minimise memory usage, a small number of hard-coded limits -are present in decoder.h - mainly limiting the supported blocksize -(number of samples in a frame) to 4608. This is the default value -used by the reference FLAC encoder at all standard compression -settings. - - -TESTING - -A test program is contained in the file main.c and this should compile -in any Unix-like environment using the command "make -f Makefile.test". - -Running "test file.flac" will decode the audio data to a WAV file -called "test.wav" in the current directory. This has been tested with -16-bit and 24-bit mono and stereo FLAC files. - -This can be used to test the accuracy of the decoder by comparing the -md5sum of the WAV file produced by this decoder with a WAV file -produced by the official libFLAC decoder. - -This test program could be extended to perform an internal md5sum -calculation and comparing that against the md5sum stored in the FLAC -file's header. diff --git a/apps/codecs/libffmpegFLAC/SOURCES b/apps/codecs/libffmpegFLAC/SOURCES deleted file mode 100644 index 63094b30a6..0000000000 --- a/apps/codecs/libffmpegFLAC/SOURCES +++ /dev/null @@ -1,7 +0,0 @@ -decoder.c -shndec.c -#if defined(CPU_COLDFIRE) -coldfire.S -#elif defined(CPU_ARM) -arm.S -#endif diff --git a/apps/codecs/libffmpegFLAC/arm.S b/apps/codecs/libffmpegFLAC/arm.S deleted file mode 100644 index 8adca77ce5..0000000000 --- a/apps/codecs/libffmpegFLAC/arm.S +++ /dev/null @@ -1,271 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2006 by Thom Johansen - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ - -#include "config.h" - -/* The following is an assembler optimised version of the LPC filtering - routines needed for FLAC decoding. It is optimised for use with ARM - processors. - All LPC filtering up to order 9 is done in specially optimised unrolled - loops, while every order above this is handled by a slower default routine. - */ -#ifdef USE_IRAM - .section .icode,"ax",%progbits -#else - .text -#endif - .global lpc_decode_arm -lpc_decode_arm: - stmdb sp!, { r4-r11, lr } - ldr r4, [sp, #36] - /* r0 = blocksize, r1 = qlevel, r2 = pred_order - r3 = data, r4 = coeffs - */ - - /* the data pointer always lags behind history pointer by 'pred_order' - samples. since we have one loop for each order, we can hard code this - and free a register by not saving data pointer. - */ - sub r3, r3, r2, lsl #2 @ r3 = history - cmp r0, #0 @ no samples to process - beq .exit - cmp r2, #9 @ check if order is too high for unrolled loops - addls pc, pc, r2, lsl #2 @ jump to our unrolled decode loop if it exists -@ jumptable: - b .default @ order too high, go to default routine - b .exit @ zero order filter isn't possible, exit function - b .order1 - b .order2 - b .order3 - b .order4 - b .order5 - b .order6 - b .order7 - b .order8 - -@ last jump table entry coincides with target, so leave it out -.order9: - ldmia r4, { r5-r12, r14 } @ fetch coefs -.loop9: - ldr r4, [r3], #4 @ load first history sample - mul r2, r4, r14 @ multiply with last coef - ldr r4, [r3], #4 @ rinse and repeat while accumulating sum in r2 - mla r2, r4, r12, r2 - ldr r4, [r3], #4 - mla r2, r4, r11, r2 - ldr r4, [r3], #4 - mla r2, r4, r10, r2 - ldr r4, [r3], #4 - mla r2, r4, r9, r2 - ldr r4, [r3], #4 - mla r2, r4, r8, r2 - ldr r4, [r3], #4 - mla r2, r4, r7, r2 - ldr r4, [r3], #4 - mla r2, r4, r6, r2 - ldr r4, [r3], #4 - mla r2, r4, r5, r2 - ldr r4, [r3] @ r4 = residual - add r2, r4, r2, asr r1 @ shift sum by qlevel bits and add residual - str r2, [r3], #-8*4 @ save result and wrap history pointer back - subs r0, r0, #1 @ check if we're done - bne .loop9 @ nope, jump back - b .exit - -.order8: - ldmia r4, { r5-r12 } -.loop8: - @ we have more registers to spare here, so start block reading - ldmia r3!, { r4, r14 } - mul r2, r4, r12 - mla r2, r14, r11, r2 - ldmia r3!, { r4, r14 } - mla r2, r4, r10, r2 - mla r2, r14, r9, r2 - ldmia r3!, { r4, r14 } - mla r2, r4, r8, r2 - mla r2, r14, r7, r2 - ldmia r3!, { r4, r14 } - mla r2, r4, r6, r2 - mla r2, r14, r5, r2 - ldr r4, [r3] - add r2, r4, r2, asr r1 - str r2, [r3], #-7*4 - subs r0, r0, #1 - bne .loop8 - b .exit - -.order7: - ldmia r4, { r5-r11 } -.loop7: - ldmia r3!, { r4, r12, r14 } - mul r2, r4, r11 - mla r2, r12, r10, r2 - mla r2, r14, r9, r2 - ldmia r3!, { r4, r12, r14 } - mla r2, r4, r8, r2 - mla r2, r12, r7, r2 - mla r2, r14, r6, r2 - ldr r4, [r3], #4 - mla r2, r4, r5, r2 - ldr r4, [r3] - add r2, r4, r2, asr r1 - str r2, [r3], #-6*4 - subs r0, r0, #1 - bne .loop7 - b .exit - -.order6: - ldmia r4, { r5-r10 } -.loop6: - ldmia r3!, { r4, r11-r12, r14 } - mul r2, r4, r10 - mla r2, r11, r9, r2 - mla r2, r12, r8, r2 - mla r2, r14, r7, r2 - ldmia r3!, { r4, r11 } - mla r2, r4, r6, r2 - mla r2, r11, r5, r2 - ldr r4, [r3] - add r2, r4, r2, asr r1 - str r2, [r3], #-5*4 - subs r0, r0, #1 - bne .loop6 - b .exit - -.order5: - ldmia r4, { r5-r9 } -.loop5: - ldmia r3!, { r4, r10-r12, r14 } - mul r2, r4, r9 - mla r2, r10, r8, r2 - mla r2, r11, r7, r2 - mla r2, r12, r6, r2 - mla r2, r14, r5, r2 - ldr r4, [r3] - add r2, r4, r2, asr r1 - str r2, [r3], #-4*4 - subs r0, r0, #1 - bne .loop5 - b .exit - -.order4: - ldmia r4, { r5-r8 } -.loop4: - ldmia r3!, { r4, r11-r12, r14 } - mul r2, r4, r8 - mla r2, r11, r7, r2 - mla r2, r12, r6, r2 - mla r2, r14, r5, r2 - ldr r4, [r3] - add r2, r4, r2, asr r1 - str r2, [r3], #-3*4 - subs r0, r0, #1 - bne .loop4 - b .exit - -.order3: - ldmia r4, { r5-r7 } -.loop3: - ldmia r3!, { r4, r12, r14 } - mul r2, r4, r7 - mla r2, r12, r6, r2 - mla r2, r14, r5, r2 - ldr r4, [r3] - add r2, r4, r2, asr r1 - str r2, [r3], #-2*4 - subs r0, r0, #1 - bne .loop3 - b .exit - -.order2: - ldmia r4, { r5-r6 } -.loop2: - ldmia r3!, { r4, r14 } - mul r2, r4, r6 - mla r2, r14, r5, r2 - ldr r4, [r3] - add r2, r4, r2, asr r1 - str r2, [r3], #-1*4 - subs r0, r0, #1 - bne .loop2 - b .exit - -.order1: - ldr r5, [r4] @ load the one coef we need - ldr r4, [r3], #4 @ load one history sample, r3 now points to residual -.loop1: - mul r2, r4, r5 @ multiply coef by history sample - ldr r4, [r3] @ load residual - add r4, r4, r2, asr r1 @ add result to residual - str r4, [r3], #4 @ place r3 at next residual, we already have - subs r0, r0, #1 @ the current sample in r4 for the next iteration - bne .loop1 - b .exit - -.default: - /* we do the filtering in an unrolled by 4 loop as far as we can, and then - do the rest by jump table. */ - add r5, r4, r2, lsl #2 @ need to start in the other end of coefs - mov r7, r2, lsr #2 @ r7 = coefs/4 - mov r14, #0 @ init accumulator -.dloop1: - ldmdb r5!, { r8-r11 } - ldmia r3!, { r6, r12 } - mla r14, r6, r11, r14 - mla r14, r12, r10, r14 - ldmia r3!, { r6, r12 } - mla r14, r6, r9, r14 - mla r14, r12, r8, r14 - subs r7, r7, #1 - bne .dloop1 - - and r7, r2, #3 @ get remaining samples to be filtered - add pc, pc, r7, lsl #2 @ jump into accumulator chain -@ jumptable: - b .dsave @ padding - b .dsave - b .oneleft - b .twoleft -@ implicit .threeleft - ldr r12, [r5, #-4]! - ldr r8, [r3], #4 - mla r14, r12, r8, r14 -.twoleft: - ldr r12, [r5, #-4]! - ldr r8, [r3], #4 - mla r14, r12, r8, r14 -.oneleft: - ldr r12, [r5, #-4]! - ldr r8, [r3], #4 - mla r14, r12, r8, r14 - -.dsave: - ldr r12, [r3] @ load residual - add r14, r12, r14, asr r1 @ shift sum by qlevel bits and add residual - str r14, [r3], #4 @ store result - sub r3, r3, r2, lsl #2 @ and wrap history pointer back to next first pos - subs r0, r0, #1 @ are we done? - bne .default @ no, prepare for next sample - -.exit: - ldmpc regs=r4-r11 - diff --git a/apps/codecs/libffmpegFLAC/arm.h b/apps/codecs/libffmpegFLAC/arm.h deleted file mode 100644 index 39080d7f75..0000000000 --- a/apps/codecs/libffmpegFLAC/arm.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef _FLAC_ARM_H -#define _FLAC_ARM_H - -#include "bitstream.h" - -void lpc_decode_arm(int blocksize, int qlevel, int pred_order, int32_t* data, int* coeffs); - -#endif diff --git a/apps/codecs/libffmpegFLAC/bitstream.h b/apps/codecs/libffmpegFLAC/bitstream.h deleted file mode 100644 index 5fc3460c8e..0000000000 --- a/apps/codecs/libffmpegFLAC/bitstream.h +++ /dev/null @@ -1,79 +0,0 @@ -/** - * @file bitstream.h - * bitstream api header. - */ - -#ifndef BITSTREAM_H -#define BITSTREAM_H - -#include -#include "ffmpeg_get_bits.h" - -#ifndef BUILD_STANDALONE - #include - #include -#else - #include - #define IBSS_ATTR - #define ICONST_ATTR - #define ICODE_ATTR -#endif - -#if (CONFIG_CPU == MCF5250) || (CONFIG_CPU == PP5022) || (CONFIG_CPU == PP5024) -#define ICODE_ATTR_FLAC ICODE_ATTR -#define IBSS_ATTR_FLAC IBSS_ATTR -/* Enough IRAM to move additional data to it. */ -#define IBSS_ATTR_FLAC_LARGE_IRAM IBSS_ATTR -#define IBSS_ATTR_FLAC_XLARGE_IRAM - -#elif defined(CPU_S5L870X) -#define ICODE_ATTR_FLAC ICODE_ATTR -#define IBSS_ATTR_FLAC IBSS_ATTR -/* Enough IRAM to move even more additional data to it. */ -#define IBSS_ATTR_FLAC_LARGE_IRAM IBSS_ATTR -#define IBSS_ATTR_FLAC_XLARGE_IRAM IBSS_ATTR - -#else -#define ICODE_ATTR_FLAC ICODE_ATTR -#define IBSS_ATTR_FLAC IBSS_ATTR -/* Not enough IRAM available. */ -#define IBSS_ATTR_FLAC_LARGE_IRAM -#define IBSS_ATTR_FLAC_XLARGE_IRAM -#endif - -/* Endian conversion routines for standalone compilation */ -#ifdef BUILD_STANDALONE - #ifdef BUILD_BIGENDIAN - #define betoh32(x) (x) - #define letoh32(x) swap32(x) - #else - #define letoh32(x) (x) - #define betoh32(x) swap32(x) - #endif - - /* Taken from rockbox/firmware/export/system.h */ - - static inline unsigned short swap16(unsigned short value) - /* - result[15..8] = value[ 7..0]; - result[ 7..0] = value[15..8]; - */ - { - return (value >> 8) | (value << 8); - } - - static inline unsigned long swap32(unsigned long value) - /* - result[31..24] = value[ 7.. 0]; - result[23..16] = value[15.. 8]; - result[15.. 8] = value[23..16]; - result[ 7.. 0] = value[31..24]; - */ - { - unsigned long hi = swap16(value >> 16); - unsigned long lo = swap16(value & 0xffff); - return (lo << 16) | hi; - } -#endif - -#endif /* BITSTREAM_H */ diff --git a/apps/codecs/libffmpegFLAC/coldfire.S b/apps/codecs/libffmpegFLAC/coldfire.S deleted file mode 100644 index efbb907874..0000000000 --- a/apps/codecs/libffmpegFLAC/coldfire.S +++ /dev/null @@ -1,535 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2005 by Thom Johansen - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ - -/* The following are assembler optimised version of the LPC filtering - routines needed for FLAC decoding. They is optimised for use with the - MCF5249 processor, or any other similar ColdFire core with the EMAC unit. - */ - -/* This routine deals with sample widths 16 and lower. All LPC filtering up to - order 10 is done in specially optimised unrolled loops, while every order - above this is handled by a slower default routine. - */ - .section .icode,"ax",@progbits - .global lpc_decode_emac - .align 2 -lpc_decode_emac: - lea.l (-44, %sp), %sp - movem.l %d2-%d7/%a2-%a6, (%sp) - movem.l (44+4, %sp), %d0-%d2/%a0-%a1 - /* d0 = blocksize, d1 = qlevel, d2 = pred_order - a0 = data, a1 = coeffs - */ - - /* the data pointer always lags behind history pointer by 'pred_order' - samples. since we have one loop for each order, we can hard code this - and free a register by not saving data pointer. - */ - move.l %d2, %d3 - neg.l %d3 - lea.l (%a0, %d3.l*4), %a0 | history - clr.l %d3 - move.l %d3, %macsr | we'll need integer mode for this - tst.l %d0 - jeq .exit | zero samples to process, exit - moveq.l #10, %d3 - cmp.l %d3, %d2 - jgt .default | order is over 10, jump to default case - jmp.l (2, %pc, %d2.l*4) | jump to loop corresponding to pred_order -| jumptable: - bra.w .exit | zero order filter isn't possible, exit function - bra.w .order1 - bra.w .order2 - bra.w .order3 - bra.w .order4 - bra.w .order5 - bra.w .order6 - bra.w .order7 - bra.w .order8 - bra.w .order9 - -| last jump table entry coincides with target, so leave it out -.order10: - movem.l (%a1), %d3-%d7/%a1-%a5 | load lpc coefs - move.l (%a0)+, %a6 | load first history sample -1: - mac.l %a6, %a5, (%a0)+, %a6, %acc0 - mac.l %a6, %a4, (%a0)+, %a6, %acc0 - mac.l %a6, %a3, (%a0)+, %a6, %acc0 - mac.l %a6, %a2, (%a0)+, %a6, %acc0 - mac.l %a6, %a1, (%a0)+, %a6, %acc0 - mac.l %a6, %d7, (%a0)+, %a6, %acc0 - mac.l %a6, %d6, (%a0)+, %a6, %acc0 - mac.l %a6, %d5, (%a0)+, %a6, %acc0 - mac.l %a6, %d4, (%a0)+, %a6, %acc0 - mac.l %a6, %d3, (-9*4, %a0), %a6, %acc0 | load for the next iteration - movclr.l %acc0, %d2 | get sum - asr.l %d1, %d2 | shift sum by qlevel bits - add.l %d2, (%a0) | add residual and save - lea.l (-8*4, %a0), %a0 | point history back at second element - subq.l #1, %d0 | decrement sample count - jne 1b | are we done? - jra .exit - -.order9: - movem.l (%a1), %d4-%d7/%a1-%a5 - move.l (%a0)+, %a6 -1: - mac.l %a6, %a5, (%a0)+, %a6, %acc0 - mac.l %a6, %a4, (%a0)+, %a6, %acc0 - mac.l %a6, %a3, (%a0)+, %a6, %acc0 - mac.l %a6, %a2, (%a0)+, %a6, %acc0 - mac.l %a6, %a1, (%a0)+, %a6, %acc0 - mac.l %a6, %d7, (%a0)+, %a6, %acc0 - mac.l %a6, %d6, (%a0)+, %a6, %acc0 - mac.l %a6, %d5, (%a0)+, %a6, %acc0 - mac.l %a6, %d4, (-8*4, %a0), %a6, %acc0 - movclr.l %acc0, %d2 - asr.l %d1, %d2 - add.l %d2, (%a0) - lea.l (-7*4, %a0), %a0 - subq.l #1, %d0 - jne 1b - jra .exit - -.order8: - movem.l (%a1), %d5-%d7/%a1-%a5 - move.l (%a0)+, %a6 -1: - mac.l %a6, %a5, (%a0)+, %a6, %acc0 - mac.l %a6, %a4, (%a0)+, %a6, %acc0 - mac.l %a6, %a3, (%a0)+, %a6, %acc0 - mac.l %a6, %a2, (%a0)+, %a6, %acc0 - mac.l %a6, %a1, (%a0)+, %a6, %acc0 - mac.l %a6, %d7, (%a0)+, %a6, %acc0 - mac.l %a6, %d6, (%a0)+, %a6, %acc0 - mac.l %a6, %d5, (-7*4, %a0), %a6, %acc0 - movclr.l %acc0, %d2 - asr.l %d1, %d2 - add.l %d2, (%a0) - lea.l (-6*4, %a0), %a0 - subq.l #1, %d0 - jne 1b - jra .exit - -.order7: - movem.l (%a1), %d6-%d7/%a1-%a5 - move.l (%a0)+, %a6 -1: - mac.l %a6, %a5, (%a0)+, %a6, %acc0 - mac.l %a6, %a4, (%a0)+, %a6, %acc0 - mac.l %a6, %a3, (%a0)+, %a6, %acc0 - mac.l %a6, %a2, (%a0)+, %a6, %acc0 - mac.l %a6, %a1, (%a0)+, %a6, %acc0 - mac.l %a6, %d7, (%a0)+, %a6, %acc0 - mac.l %a6, %d6, (-6*4, %a0), %a6, %acc0 - movclr.l %acc0, %d2 - asr.l %d1, %d2 - add.l %d2, (%a0) - lea.l (-5*4, %a0), %a0 - subq.l #1, %d0 - jne 1b - jra .exit - -.order6: - movem.l (%a1), %d7/%a1-%a5 - move.l (%a0)+, %a6 -1: - mac.l %a6, %a5, (%a0)+, %a6, %acc0 - mac.l %a6, %a4, (%a0)+, %a6, %acc0 - mac.l %a6, %a3, (%a0)+, %a6, %acc0 - mac.l %a6, %a2, (%a0)+, %a6, %acc0 - mac.l %a6, %a1, (%a0)+, %a6, %acc0 - mac.l %a6, %d7, (-5*4, %a0), %a6, %acc0 - movclr.l %acc0, %d2 - asr.l %d1, %d2 - add.l %d2, (%a0) - lea.l (-4*4, %a0), %a0 - subq.l #1, %d0 - jne 1b - jra .exit - -.order5: - movem.l (%a1), %a1-%a5 - move.l (%a0)+, %a6 -1: - mac.l %a6, %a5, (%a0)+, %a6, %acc0 - mac.l %a6, %a4, (%a0)+, %a6, %acc0 - mac.l %a6, %a3, (%a0)+, %a6, %acc0 - mac.l %a6, %a2, (%a0)+, %a6, %acc0 - mac.l %a6, %a1, (-4*4, %a0), %a6, %acc0 - movclr.l %acc0, %d2 - asr.l %d1, %d2 - add.l %d2, (%a0) - lea.l (-3*4, %a0), %a0 - subq.l #1, %d0 - jne 1b - jra .exit - -.order4: - movem.l (%a1), %a2-%a5 - move.l (%a0)+, %a6 -1: - mac.l %a6, %a5, (%a0)+, %a6, %acc0 - mac.l %a6, %a4, (%a0)+, %a6, %acc0 - mac.l %a6, %a3, (%a0)+, %a6, %acc0 - mac.l %a6, %a2, (-3*4, %a0), %a6, %acc0 - movclr.l %acc0, %d2 - asr.l %d1, %d2 - add.l %d2, (%a0) - subq.l #8, %a0 - subq.l #1, %d0 - jne 1b - jra .exit - -.order3: - movem.l (%a1), %a3-%a5 - move.l (%a0)+, %a6 -1: - mac.l %a6, %a5, (%a0)+, %a6, %acc0 - mac.l %a6, %a4, (%a0)+, %a6, %acc0 - mac.l %a6, %a3, (-2*4, %a0), %a6, %acc0 - movclr.l %acc0, %d2 - asr.l %d1, %d2 - add.l %d2, (%a0) - subq.l #4, %a0 - subq.l #1, %d0 - jne 1b - jra .exit - -.order2: - movem.l (%a1), %a4-%a5 - move.l (%a0)+, %a6 -1: - mac.l %a6, %a5, (%a0)+, %a6, %acc0 - mac.l %a6, %a4, %acc0 | data for next iteration is already loaded - movclr.l %acc0, %d2 - asr.l %d1, %d2 - add.l %d2, (%a0) - subq.l #1, %d0 - jne 1b - jra .exit - -.order1: - | no point in using mac here - move.l (%a1), %a5 -1: - move.l %a5, %d2 - muls.l (%a0)+, %d2 - asr.l %d1, %d2 - add.l %d2, (%a0) - subq.l #1, %d0 - jne 1b - jra .exit - -.default: - /* we do the filtering in an unrolled by 4 loop as far as we can, and then - do the rest by jump table. */ - lea.l (%a1, %d2.l*4), %a2 | need to start in the other end of coefs - move.l %a0, %a3 | working copy of history pointer - move.l %d2, %d3 - lsr.l #2, %d3 | coefs/4, num of iterations needed in next loop - move.l (%a3)+, %a5 | preload data for loop -1: - lea.l (-4*4, %a2), %a2 | move lpc coef pointer four samples backwards - movem.l (%a2), %d4-%d7 | load four coefs - mac.l %a5, %d7, (%a3)+, %a5, %acc0 - mac.l %a5, %d6, (%a3)+, %a5, %acc0 - mac.l %a5, %d5, (%a3)+, %a5, %acc0 - mac.l %a5, %d4, (%a3)+, %a5, %acc0 - subq.l #1, %d3 | any more unrolled loop operations left? - jne 1b - - moveq.l #3, %d3 | mask 0x00000003 - and.l %d2, %d3 | get the remaining samples to be filtered - jmp.l (2, %pc, %d3*2) | then jump into mac.l chain -| jumptable: - bra.b 3f | none left - bra.b 2f | one left - bra.b 1f | two left -| three left - move.l -(%a2), %d4 - mac.l %a5, %d4, (%a3)+, %a5, %acc0 -1: - move.l -(%a2), %d4 - mac.l %a5, %d4, (%a3)+, %a5, %acc0 -2: - move.l -(%a2), %d4 - mac.l %a5, %d4, (%a3)+, %a5, %acc0 -3: - movclr.l %acc0, %d3 | get result - asr.l %d1, %d3 | shift qlevel bits right - add.l %a5, %d3 | add residual, which is in a5 by now - move.l %d3, -(%a3) | save, a3 is also one past save location - addq.l #4, %a0 | increment history pointer - subq.l #1, %d0 | decrement sample count - jne .default | are we done? - jra .exit | if so, fall through to exit - - -/* This routine deals with sample widths 24 and lower. All LPC filtering up to - order 8 is done in specially optimised unrolled loops, while every order - above this is handled by a slower default routine. - */ - .global lpc_decode_emac_wide - .align 2 -lpc_decode_emac_wide: - lea.l (-44, %sp), %sp - movem.l %d2-%d7/%a2-%a6, (%sp) - movem.l (44+4, %sp), %d0-%d1/%d3/%a0-%a1 - /* d0 = blocksize, d1 = qlevel, d3 = pred_order - a0 = data, a1 = coeffs - */ - - /* the data pointer always lags behind history pointer by 'pred_order' - samples. since we have one loop for each order, we can hard code this - and free a register by not saving data pointer. - */ - move.l %d3, %d2 - neg.l %d2 - lea.l (%a0, %d2.l*4), %a0 | history - clr.l %d2 - move.l %d2, %macsr | we'll need integer mode for this - tst.l %d0 - jeq .exit | zero samples to process, exit - moveq.l #32, %d2 - sub.l %d1, %d2 | calculate shift amount for extension byte - moveq.l #8, %d4 - cmp.l %d4, %d3 - jgt .wdefault | order is over 8, jump to default case - jmp.l (2, %pc, %d3.l*4) | jump to loop corresponding to pred_order -| jumptable: - bra.w .exit | zero order filter isn't possible, exit function - bra.w .worder1 - bra.w .worder2 - bra.w .worder3 - bra.w .worder4 - bra.w .worder5 - bra.w .worder6 - bra.w .worder7 - -| last jump table entry coincides with target, so leave it out -.worder8: - movem.l (%a1), %d5-%d7/%a1-%a5 | load lpc coefs - move.l (%a0)+, %a6 | load first history sample -1: - mac.l %a6, %a5, (%a0)+, %a6, %acc0 - mac.l %a6, %a4, (%a0)+, %a6, %acc0 - mac.l %a6, %a3, (%a0)+, %a6, %acc0 - mac.l %a6, %a2, (%a0)+, %a6, %acc0 - mac.l %a6, %a1, (%a0)+, %a6, %acc0 - mac.l %a6, %d7, (%a0)+, %a6, %acc0 - mac.l %a6, %d6, (%a0)+, %a6, %acc0 - mac.l %a6, %d5, (-7*4, %a0), %a6, %acc0 | load for the next iteration - move.l %accext01, %d4 | get top 8 bits of sum - movclr.l %acc0, %d3 | then botten 32 bits - lsr.l %d1, %d3 | shift bottom bits qlevel bits right - asl.l %d2, %d4 | shift top bits 32 - qlevel bits left - or.l %d4, %d3 | now combine results - add.l %d3, (%a0) | add residual and save - lea.l (-6*4, %a0), %a0 | point history back at second element - subq.l #1, %d0 | decrement sample count - jne 1b | are we done? - jra .exit - -.worder7: - movem.l (%a1), %d6-%d7/%a1-%a5 - move.l (%a0)+, %a6 -1: - mac.l %a6, %a5, (%a0)+, %a6, %acc0 - mac.l %a6, %a4, (%a0)+, %a6, %acc0 - mac.l %a6, %a3, (%a0)+, %a6, %acc0 - mac.l %a6, %a2, (%a0)+, %a6, %acc0 - mac.l %a6, %a1, (%a0)+, %a6, %acc0 - mac.l %a6, %d7, (%a0)+, %a6, %acc0 - mac.l %a6, %d6, (-6*4, %a0), %a6, %acc0 - move.l %accext01, %d4 - movclr.l %acc0, %d3 - lsr.l %d1, %d3 - asl.l %d2, %d4 - or.l %d4, %d3 - add.l %d3, (%a0) - lea.l (-5*4, %a0), %a0 - subq.l #1, %d0 - jne 1b - jra .exit - -.worder6: - movem.l (%a1), %d7/%a1-%a5 - move.l (%a0)+, %a6 -1: - mac.l %a6, %a5, (%a0)+, %a6, %acc0 - mac.l %a6, %a4, (%a0)+, %a6, %acc0 - mac.l %a6, %a3, (%a0)+, %a6, %acc0 - mac.l %a6, %a2, (%a0)+, %a6, %acc0 - mac.l %a6, %a1, (%a0)+, %a6, %acc0 - mac.l %a6, %d7, (-5*4, %a0), %a6, %acc0 - move.l %accext01, %d4 - movclr.l %acc0, %d3 - lsr.l %d1, %d3 - asl.l %d2, %d4 - or.l %d4, %d3 - add.l %d3, (%a0) - lea.l (-4*4, %a0), %a0 - subq.l #1, %d0 - jne 1b - jra .exit - -.worder5: - movem.l (%a1), %a1-%a5 - move.l (%a0)+, %a6 -1: - mac.l %a6, %a5, (%a0)+, %a6, %acc0 - mac.l %a6, %a4, (%a0)+, %a6, %acc0 - mac.l %a6, %a3, (%a0)+, %a6, %acc0 - mac.l %a6, %a2, (%a0)+, %a6, %acc0 - mac.l %a6, %a1, (-4*4, %a0), %a6, %acc0 - move.l %accext01, %d4 - movclr.l %acc0, %d3 - lsr.l %d1, %d3 - asl.l %d2, %d4 - or.l %d4, %d3 - add.l %d3, (%a0) - lea.l (-3*4, %a0), %a0 - subq.l #1, %d0 - jne 1b - jra .exit - -.worder4: - movem.l (%a1), %a2-%a5 - move.l (%a0)+, %a6 -1: - mac.l %a6, %a5, (%a0)+, %a6, %acc0 - mac.l %a6, %a4, (%a0)+, %a6, %acc0 - mac.l %a6, %a3, (%a0)+, %a6, %acc0 - mac.l %a6, %a2, (-3*4, %a0), %a6, %acc0 - move.l %accext01, %d4 - movclr.l %acc0, %d3 - lsr.l %d1, %d3 - asl.l %d2, %d4 - or.l %d4, %d3 - add.l %d3, (%a0) - subq.l #8, %a0 - subq.l #1, %d0 - jne 1b - jra .exit - -.worder3: - movem.l (%a1), %a3-%a5 - move.l (%a0)+, %a6 -1: - mac.l %a6, %a5, (%a0)+, %a6, %acc0 - mac.l %a6, %a4, (%a0)+, %a6, %acc0 - mac.l %a6, %a3, (-2*4, %a0), %a6, %acc0 - move.l %accext01, %d4 - movclr.l %acc0, %d3 - lsr.l %d1, %d3 - asl.l %d2, %d4 - or.l %d4, %d3 - add.l %d3, (%a0) - subq.l #4, %a0 - subq.l #1, %d0 - jne 1b - jra .exit - -.worder2: - movem.l (%a1), %a4-%a5 - move.l (%a0)+, %a6 -1: - mac.l %a6, %a5, (%a0)+, %a6, %acc0 - mac.l %a6, %a4, %acc0 | data for next iteration is already loaded - move.l %accext01, %d4 - movclr.l %acc0, %d3 - lsr.l %d1, %d3 - asl.l %d2, %d4 - or.l %d4, %d3 - add.l %d3, (%a0) - subq.l #1, %d0 - jne 1b - jra .exit - -.worder1: - move.l (%a1), %a5 - move.l (%a0)+, %a6 -1: - mac.l %a6, %a5, (%a0), %a6, %acc0 - move.l %accext01, %d4 - movclr.l %acc0, %d3 - lsr.l %d1, %d3 - asl.l %d2, %d4 - or.l %d4, %d3 - add.l %a6, %d3 | residual is already in a6 - move.l %d3, (%a0)+ - subq.l #1, %d0 - jne 1b - jra .exit - -.wdefault: - /* we do the filtering in an unrolled by 4 loop as far as we can, and then - do the rest by jump table. */ - lea.l (%a1, %d3.l*4), %a2 | need to start in the other end of coefs - move.l %a0, %a3 | working copy of history pointer - move.l %d3, %d4 - lsr.l #2, %d4 | coefs/4, num of iterations needed in next loop - move.l (%a3)+, %a5 | preload data for loop -1: - lea.l (-4*4, %a2), %a2 | move lpc coef pointer four samples backwards - movem.l (%a2), %d5-%d7/%a4 | load four coefs - mac.l %a5, %a4, (%a3)+, %a5, %acc0 - mac.l %a5, %d7, (%a3)+, %a5, %acc0 - mac.l %a5, %d6, (%a3)+, %a5, %acc0 - mac.l %a5, %d5, (%a3)+, %a5, %acc0 - subq.l #1, %d4 | any more unrolled loop operations left? - jne 1b - - moveq.l #3, %d4 | mask 0x00000003 - and.l %d3, %d4 | get the remaining samples to be filtered - jmp.l (2, %pc, %d4*2) | then jump into mac.l chain -| jumptable: - bra.b 3f | none left - bra.b 2f | one left - bra.b 1f | two left -| three left - move.l -(%a2), %d4 - mac.l %a5, %d4, (%a3)+, %a5, %acc0 -1: - move.l -(%a2), %d4 - mac.l %a5, %d4, (%a3)+, %a5, %acc0 -2: - move.l -(%a2), %d4 - mac.l %a5, %d4, (%a3)+, %a5, %acc0 -3: - move.l %accext01, %d5 | get high 32 bits of result - movclr.l %acc0, %d4 | get low 32 bits of result - lsr.l %d1, %d4 | shift qlevel bits right - asl.l %d2, %d5 | shift 32 - qlevel bits left - or.l %d5, %d4 | combine top and low bits after shift - add.l %a5, %d4 | add residual, which is in a5 by now - move.l %d4, -(%a3) | save, a3 is also one past save location - addq.l #4, %a0 | increment history pointer - subq.l #1, %d0 | decrement sample count - jne .wdefault | are we done? - | if so, fall through to exit - -.exit: - movem.l (%sp), %d2-%d7/%a2-%a6 - lea.l (44, %sp), %sp - rts diff --git a/apps/codecs/libffmpegFLAC/coldfire.h b/apps/codecs/libffmpegFLAC/coldfire.h deleted file mode 100644 index d6f0996935..0000000000 --- a/apps/codecs/libffmpegFLAC/coldfire.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef _FLAC_COLDFIRE_H -#define _FLAC_COLDFIRE_H - -#include "bitstream.h" - -void lpc_decode_emac(int blocksize, int qlevel, int pred_order, int32_t* data, - int* coeffs); -void lpc_decode_emac_wide(int blocksize, int qlevel, int pred_order, - int32_t* data, int* coeffs); - -#endif diff --git a/apps/codecs/libffmpegFLAC/decoder.c b/apps/codecs/libffmpegFLAC/decoder.c deleted file mode 100644 index 2e92c4b90d..0000000000 --- a/apps/codecs/libffmpegFLAC/decoder.c +++ /dev/null @@ -1,627 +0,0 @@ -/* - * FLAC (Free Lossless Audio Codec) decoder - * Copyright (c) 2003 Alex Beregszaszi - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/** - * @file flac.c - * FLAC (Free Lossless Audio Codec) decoder - * @author Alex Beregszaszi - * - * For more information on the FLAC format, visit: - * http://flac.sourceforge.net/ - * - * This decoder can be used in 1 of 2 ways: Either raw FLAC data can be fed - * through, starting from the initial 'fLaC' signature; or by passing the - * 34-byte streaminfo structure through avctx->extradata[_size] followed - * by data starting with the 0xFFF8 marker. - */ - -#include -#include -#ifndef BUILD_STANDALONE -#include "codeclib.h" -#endif - -#include "bitstream.h" -#include "golomb.h" - -#include "decoder.h" - -#if defined(CPU_COLDFIRE) -#include "coldfire.h" -#elif defined(CPU_ARM) -#include "arm.h" -#endif - -static const int sample_rate_table[] ICONST_ATTR = -{ 0, 88200, 176400, 192000, - 8000, 16000, 22050, 24000, 32000, 44100, 48000, 96000, - 0, 0, 0, 0 }; - -static const int sample_size_table[] ICONST_ATTR = -{ 0, 8, 12, 0, 16, 20, 24, 0 }; - -static const int blocksize_table[] ICONST_ATTR = { - 0, 192, 576<<0, 576<<1, 576<<2, 576<<3, 0, 0, -256<<0, 256<<1, 256<<2, 256<<3, 256<<4, 256<<5, 256<<6, 256<<7 -}; - -static const uint8_t table_crc8[256] ICONST_ATTR = { - 0x00, 0x07, 0x0e, 0x09, 0x1c, 0x1b, 0x12, 0x15, - 0x38, 0x3f, 0x36, 0x31, 0x24, 0x23, 0x2a, 0x2d, - 0x70, 0x77, 0x7e, 0x79, 0x6c, 0x6b, 0x62, 0x65, - 0x48, 0x4f, 0x46, 0x41, 0x54, 0x53, 0x5a, 0x5d, - 0xe0, 0xe7, 0xee, 0xe9, 0xfc, 0xfb, 0xf2, 0xf5, - 0xd8, 0xdf, 0xd6, 0xd1, 0xc4, 0xc3, 0xca, 0xcd, - 0x90, 0x97, 0x9e, 0x99, 0x8c, 0x8b, 0x82, 0x85, - 0xa8, 0xaf, 0xa6, 0xa1, 0xb4, 0xb3, 0xba, 0xbd, - 0xc7, 0xc0, 0xc9, 0xce, 0xdb, 0xdc, 0xd5, 0xd2, - 0xff, 0xf8, 0xf1, 0xf6, 0xe3, 0xe4, 0xed, 0xea, - 0xb7, 0xb0, 0xb9, 0xbe, 0xab, 0xac, 0xa5, 0xa2, - 0x8f, 0x88, 0x81, 0x86, 0x93, 0x94, 0x9d, 0x9a, - 0x27, 0x20, 0x29, 0x2e, 0x3b, 0x3c, 0x35, 0x32, - 0x1f, 0x18, 0x11, 0x16, 0x03, 0x04, 0x0d, 0x0a, - 0x57, 0x50, 0x59, 0x5e, 0x4b, 0x4c, 0x45, 0x42, - 0x6f, 0x68, 0x61, 0x66, 0x73, 0x74, 0x7d, 0x7a, - 0x89, 0x8e, 0x87, 0x80, 0x95, 0x92, 0x9b, 0x9c, - 0xb1, 0xb6, 0xbf, 0xb8, 0xad, 0xaa, 0xa3, 0xa4, - 0xf9, 0xfe, 0xf7, 0xf0, 0xe5, 0xe2, 0xeb, 0xec, - 0xc1, 0xc6, 0xcf, 0xc8, 0xdd, 0xda, 0xd3, 0xd4, - 0x69, 0x6e, 0x67, 0x60, 0x75, 0x72, 0x7b, 0x7c, - 0x51, 0x56, 0x5f, 0x58, 0x4d, 0x4a, 0x43, 0x44, - 0x19, 0x1e, 0x17, 0x10, 0x05, 0x02, 0x0b, 0x0c, - 0x21, 0x26, 0x2f, 0x28, 0x3d, 0x3a, 0x33, 0x34, - 0x4e, 0x49, 0x40, 0x47, 0x52, 0x55, 0x5c, 0x5b, - 0x76, 0x71, 0x78, 0x7f, 0x6a, 0x6d, 0x64, 0x63, - 0x3e, 0x39, 0x30, 0x37, 0x22, 0x25, 0x2c, 0x2b, - 0x06, 0x01, 0x08, 0x0f, 0x1a, 0x1d, 0x14, 0x13, - 0xae, 0xa9, 0xa0, 0xa7, 0xb2, 0xb5, 0xbc, 0xbb, - 0x96, 0x91, 0x98, 0x9f, 0x8a, 0x8d, 0x84, 0x83, - 0xde, 0xd9, 0xd0, 0xd7, 0xc2, 0xc5, 0xcc, 0xcb, - 0xe6, 0xe1, 0xe8, 0xef, 0xfa, 0xfd, 0xf4, 0xf3 -}; - -static int64_t get_utf8(GetBitContext *gb) ICODE_ATTR_FLAC; -static int64_t get_utf8(GetBitContext *gb) -{ - uint64_t val; - int ones=0, bytes; - - while(get_bits1(gb)) - ones++; - - if (ones==0) bytes=0; - else if(ones==1) return -1; - else bytes= ones - 1; - - val= get_bits(gb, 7-ones); - while(bytes--){ - const int tmp = get_bits(gb, 8); - - if((tmp>>6) != 2) - return -2; - val<<=6; - val|= tmp&0x3F; - } - return val; -} - -static int get_crc8(const uint8_t *buf, int count) ICODE_ATTR_FLAC; -static int get_crc8(const uint8_t *buf, int count) -{ - int crc=0; - int i; - - for(i=0; igb, 2); - if (method_type > 1){ - //fprintf(stderr,"illegal residual coding method %d\n", method_type); - return -3; - } - - rice_order = get_bits(&s->gb, 4); - - samples= s->blocksize >> rice_order; - - sample= - i= pred_order; - for (partition = 0; partition < (1 << rice_order); partition++) - { - tmp = get_bits(&s->gb, method_type == 0 ? 4 : 5); - if (tmp == (method_type == 0 ? 15 : 31)) - { - //fprintf(stderr,"fixed len partition\n"); - tmp = get_bits(&s->gb, 5); - for (; i < samples; i++, sample++) - decoded[sample] = get_sbits(&s->gb, tmp); - } - else - { - for (; i < samples; i++, sample++){ - decoded[sample] = get_sr_golomb_flac(&s->gb, tmp, INT_MAX, 0); - } - } - i= 0; - } - - return 0; -} - -static int decode_subframe_fixed(FLACContext *s, int32_t* decoded, int pred_order) ICODE_ATTR_FLAC; -static int decode_subframe_fixed(FLACContext *s, int32_t* decoded, int pred_order) -{ - const int blocksize = s->blocksize; - int a, b, c, d, i; - - /* warm up samples */ - for (i = 0; i < pred_order; i++) - { - decoded[i] = get_sbits(&s->gb, s->curr_bps); - } - - if (decode_residuals(s, decoded, pred_order) < 0) - return -4; - - a = decoded[pred_order-1]; - b = a - decoded[pred_order-2]; - c = b - decoded[pred_order-2] + decoded[pred_order-3]; - d = c - decoded[pred_order-2] + 2*decoded[pred_order-3] - decoded[pred_order-4]; - - switch(pred_order) - { - case 0: - break; - case 1: - for (i = pred_order; i < blocksize; i++) - decoded[i] = a += decoded[i]; - break; - case 2: - for (i = pred_order; i < blocksize; i++) - decoded[i] = a += b += decoded[i]; - break; - case 3: - for (i = pred_order; i < blocksize; i++) - decoded[i] = a += b += c += decoded[i]; - break; - case 4: - for (i = pred_order; i < blocksize; i++) - decoded[i] = a += b += c += d += decoded[i]; - break; - default: - return -5; - } - - return 0; -} - -static int decode_subframe_lpc(FLACContext *s, int32_t* decoded, int pred_order) ICODE_ATTR_FLAC; -static int decode_subframe_lpc(FLACContext *s, int32_t* decoded, int pred_order) -{ - int sum, i, j; - int64_t wsum; - int coeff_prec, qlevel; - int coeffs[pred_order]; - - /* warm up samples */ - for (i = 0; i < pred_order; i++) - { - decoded[i] = get_sbits(&s->gb, s->curr_bps); - } - - coeff_prec = get_bits(&s->gb, 4) + 1; - if (coeff_prec == 16) - { - //fprintf(stderr,"invalid coeff precision\n"); - return -6; - } - qlevel = get_sbits(&s->gb, 5); - if (qlevel < 0) - { - //fprintf(stderr,"qlevel %d not supported, maybe buggy stream\n", qlevel); - return -7; - } - - for (i = 0; i < pred_order; i++) - { - coeffs[i] = get_sbits(&s->gb, coeff_prec); - } - - if (decode_residuals(s, decoded, pred_order) < 0) - return -8; - - if ((s->bps + coeff_prec + av_log2(pred_order)) <= 32) { - #if defined(CPU_COLDFIRE) - (void)sum; - lpc_decode_emac(s->blocksize - pred_order, qlevel, pred_order, - decoded + pred_order, coeffs); - #elif defined(CPU_ARM) - (void)sum; - lpc_decode_arm(s->blocksize - pred_order, qlevel, pred_order, - decoded + pred_order, coeffs); - #else - for (i = pred_order; i < s->blocksize; i++) - { - sum = 0; - for (j = 0; j < pred_order; j++) - sum += coeffs[j] * decoded[i-j-1]; - decoded[i] += sum >> qlevel; - } - #endif - } else { - #if defined(CPU_COLDFIRE) - (void)wsum; - (void)j; - lpc_decode_emac_wide(s->blocksize - pred_order, qlevel, pred_order, - decoded + pred_order, coeffs); - #else - for (i = pred_order; i < s->blocksize; i++) - { - wsum = 0; - for (j = 0; j < pred_order; j++) - wsum += (int64_t)coeffs[j] * (int64_t)decoded[i-j-1]; - decoded[i] += wsum >> qlevel; - } - #endif - } - - return 0; -} - -static inline int decode_subframe(FLACContext *s, int channel, int32_t* decoded) -{ - int type, wasted = 0; - int i, tmp; - - s->curr_bps = s->bps; - if(channel == 0){ - if(s->decorrelation == RIGHT_SIDE) - s->curr_bps++; - }else{ - if(s->decorrelation == LEFT_SIDE || s->decorrelation == MID_SIDE) - s->curr_bps++; - } - - if (get_bits1(&s->gb)) - { - //fprintf(stderr,"invalid subframe padding\n"); - return -9; - } - type = get_bits(&s->gb, 6); -// wasted = get_bits1(&s->gb); - -// if (wasted) -// { -// while (!get_bits1(&s->gb)) -// wasted++; -// if (wasted) -// wasted++; -// s->curr_bps -= wasted; -// } -#if 0 - wasted= 16 - av_log2(show_bits(&s->gb, 17)); - skip_bits(&s->gb, wasted+1); - s->curr_bps -= wasted; -#else - if (get_bits1(&s->gb)) - { - wasted = 1; - while (!get_bits1(&s->gb)) - wasted++; - s->curr_bps -= wasted; - //fprintf(stderr,"%d wasted bits\n", wasted); - } -#endif -//FIXME use av_log2 for types - if (type == 0) - { - //fprintf(stderr,"coding type: constant\n"); - tmp = get_sbits(&s->gb, s->curr_bps); - for (i = 0; i < s->blocksize; i++) - decoded[i] = tmp; - } - else if (type == 1) - { - //fprintf(stderr,"coding type: verbatim\n"); - for (i = 0; i < s->blocksize; i++) - decoded[i] = get_sbits(&s->gb, s->curr_bps); - } - else if ((type >= 8) && (type <= 12)) - { - //fprintf(stderr,"coding type: fixed\n"); - if (decode_subframe_fixed(s, decoded, type & ~0x8) < 0) - return -10; - } - else if (type >= 32) - { - //fprintf(stderr,"coding type: lpc\n"); - if (decode_subframe_lpc(s, decoded, (type & ~0x20)+1) < 0) - return -11; - } - else - { - //fprintf(stderr,"Unknown coding type: %d\n",type); - return -12; - } - - if (wasted) - { - int i; - for (i = 0; i < s->blocksize; i++) - decoded[i] <<= wasted; - } - - return 0; -} - -static int decode_frame(FLACContext *s, - void (*yield)(void)) ICODE_ATTR_FLAC; -static int decode_frame(FLACContext *s, - void (*yield)(void)) -{ - int blocksize_code, sample_rate_code, sample_size_code, assignment, crc8; - int decorrelation, bps, blocksize, samplerate; - int res, ch; - - blocksize_code = get_bits(&s->gb, 4); - - sample_rate_code = get_bits(&s->gb, 4); - - assignment = get_bits(&s->gb, 4); /* channel assignment */ - if (assignment < 8 && s->channels == assignment+1) - decorrelation = INDEPENDENT; - else if (assignment >=8 && assignment < 11 && s->channels == 2) - decorrelation = LEFT_SIDE + assignment - 8; - else - { - return -13; - } - - sample_size_code = get_bits(&s->gb, 3); - if(sample_size_code == 0) - bps= s->bps; - else if((sample_size_code != 3) && (sample_size_code != 7)) - bps = sample_size_table[sample_size_code]; - else - { - return -14; - } - - if (get_bits1(&s->gb)) - { - return -15; - } - - /* Get the samplenumber of the first sample in this block */ - s->samplenumber=get_utf8(&s->gb); - - /* samplenumber actually contains the frame number for streams - with a constant block size - so we multiply by blocksize to - get the actual sample number */ - if (s->min_blocksize == s->max_blocksize) { - s->samplenumber*=s->min_blocksize; - } - -#if 0 - if (/*((blocksize_code == 6) || (blocksize_code == 7)) &&*/ - (s->min_blocksize != s->max_blocksize)){ - }else{ - } -#endif - - if (blocksize_code == 0) - blocksize = s->min_blocksize; - else if (blocksize_code == 6) - blocksize = get_bits(&s->gb, 8)+1; - else if (blocksize_code == 7) - blocksize = get_bits(&s->gb, 16)+1; - else - blocksize = blocksize_table[blocksize_code]; - - if(blocksize > s->max_blocksize){ - return -16; - } - - if (sample_rate_code == 0){ - samplerate= s->samplerate; - }else if ((sample_rate_code < 12)) - samplerate = sample_rate_table[sample_rate_code]; - else if (sample_rate_code == 12) - samplerate = get_bits(&s->gb, 8) * 1000; - else if (sample_rate_code == 13) - samplerate = get_bits(&s->gb, 16); - else if (sample_rate_code == 14) - samplerate = get_bits(&s->gb, 16) * 10; - else{ - return -17; - } - - skip_bits(&s->gb, 8); - crc8= get_crc8(s->gb.buffer, get_bits_count(&s->gb)/8); - if(crc8){ - return -18; - } - - s->blocksize = blocksize; - s->samplerate = samplerate; - s->bps = bps; - s->decorrelation= decorrelation; - - for (ch=0; chchannels; ++ch) { - yield(); - if ((res=decode_subframe(s, ch, s->decoded[ch])) < 0) - return res-100; - } - - yield(); - align_get_bits(&s->gb); - - /* frame footer */ - skip_bits(&s->gb, 16); /* data crc */ - - return 0; -} - -static int flac_downmix(FLACContext *s) ICODE_ATTR_FLAC; -static int flac_downmix(FLACContext *s) -{ - int32_t *FL, *FR, *FC, *SB, *RL, *RR; - int32_t *outL = s->decoded[0]; - int32_t *outR = s->decoded[1]; - int i, scale=FLAC_OUTPUT_DEPTH-s->bps; - - switch(s->channels) - { - case 3: /* 3.0 channel order: FL FR FC */ - FL = s->decoded[0]; - FR = s->decoded[1]; - FC = s->decoded[2]; - /* LF = 0.66 LF + 0.33 FC - LR = 0.66 LR + 0.33 FC */ - for (i=0; iblocksize; ++i) { - int32_t a = *(FL)*2 + *(FC); - int32_t b = *(FR)*2 + *(FC); - *outL++ = ((a + (a<<2))>>4) << scale; /* 1/3 ~= 5>>4 */ - *outR++ = ((b + (b<<2))>>4) << scale; /* 1/3 ~= 5>>4 */ - FL++; FR++; FC++; - } - break; - case 4: /* 4.0 channel order: FL FR RL RR */ - FL = s->decoded[0]; - FR = s->decoded[1]; - RL = s->decoded[2]; - RR = s->decoded[3]; - /* LF = 0.50 LF + 0.50 RL + 0.00 RR - LR = 0.50 LR + 0.00 RL + 0.50 RR */ - for (i=0; iblocksize; ++i) { - int32_t a = *(FL) + *(RL); - int32_t b = *(FR) + *(RR); - *outL++ = (a>>1) << scale; - *outR++ = (b>>1) << scale; - FL++; FR++; RL++; RR++; - } - break; - case 5: /* 5.0 channel order: FL FR FC RL RR */ - FL = s->decoded[0]; - FR = s->decoded[1]; - FC = s->decoded[2]; - RL = s->decoded[3]; - RR = s->decoded[4]; - /* LF = 0.40 LF + 0.20 FC + 0.40 RL + 0.00 RR - LR = 0.40 LR + 0.20 FC + 0.00 RL + 0.40 RR */ - for (i=0; iblocksize; ++i) { - int32_t a = *(FL)*2 + *(FC) + *(RL)*2; - int32_t b = *(FR)*2 + *(FC) + *(RR)*2; - *outL++ = ((a + (a<<1))>>4) << scale; /* 3>>4 ~= 1/5 */ - *outR++ = ((b + (b<<1))>>4) << scale; /* 3>>4 ~= 1/5 */ - FL++; FR++; FC++; RL++; RR++; - } - break; - case 6: /* 5.1 channel order: FL FR FC SUB RL RR */ - FL = s->decoded[0]; - FR = s->decoded[1]; - FC = s->decoded[2]; - SB = s->decoded[3]; - RL = s->decoded[4]; - RR = s->decoded[5]; - /* LF = 0.33 LF + 0.16 SUB + 0.16 FC + 0.33 RL + 0.00 RR - LR = 0.33 LR + 0.16 SUB + 0.16 FC + 0.00 RL + 0.33 RR */ - for (i=0; iblocksize; ++i) { - int32_t a = *(FL)*2 + *(SB) + *(FC) + *(RL)*2; - int32_t b = *(FR)*2 + *(SB) + *(FC) + *(RR)*2; - *outL++ = ((a + (a<<2))>>5) << scale; /* 5>>5 ~= 1/6 */ - *outR++ = ((b + (b<<2))>>5) << scale; /* 5>>5 ~= 1/6 */ - FL++; FR++; SB++; FC++; RL++; RR++; - } - break; - default: /* 1.0 and 2.0 do not need downmix, other formats unknown. */ - return -501; - break; - } - return 0; -} - -int flac_decode_frame(FLACContext *s, - uint8_t *buf, int buf_size, - void (*yield)(void)) -{ - int tmp; - int i; - int framesize; - int scale; - - init_get_bits(&s->gb, buf, buf_size*8); - - tmp = get_bits(&s->gb, 16); - if ((tmp & 0xFFFE) != 0xFFF8){ - return -41; - } - - if ((framesize=decode_frame(s,yield)) < 0){ - s->bitstream_size=0; - s->bitstream_index=0; - return framesize; - } - - yield(); - -#define DECORRELATE(left, right)\ - for (i = 0; i < s->blocksize; i++) {\ - int32_t a = s->decoded[0][i];\ - int32_t b = s->decoded[1][i];\ - s->decoded[0][i] = (left) << scale;\ - s->decoded[1][i] = (right) << scale;\ - }\ - - scale=FLAC_OUTPUT_DEPTH-s->bps; - switch(s->decorrelation) - { - case INDEPENDENT: - if (s->channels <= 2) { - DECORRELATE(a, b) /* Always decorrelate exactly the two supported channels. */ - } else { - if ((tmp=flac_downmix(s)) != 0) - return tmp; - } - break; - case LEFT_SIDE: - DECORRELATE(a, a-b) - break; - case RIGHT_SIDE: - DECORRELATE(a+b, b) - break; - case MID_SIDE: - DECORRELATE( (a-=b>>1) + b, a) - break; - } - - s->framesize = (get_bits_count(&s->gb)+7)>>3; - - return 0; -} diff --git a/apps/codecs/libffmpegFLAC/decoder.h b/apps/codecs/libffmpegFLAC/decoder.h deleted file mode 100644 index 677a21ac98..0000000000 --- a/apps/codecs/libffmpegFLAC/decoder.h +++ /dev/null @@ -1,49 +0,0 @@ -#ifndef _FLAC_DECODER_H -#define _FLAC_DECODER_H - -#include "bitstream.h" - -#define MAX_CHANNELS 6 /* Maximum supported channels, only left/right will be played back */ -#define MAX_BLOCKSIZE 4608 /* Maxsize in samples of one uncompressed frame */ -#define MAX_FRAMESIZE 65536 /* Maxsize in bytes of one compressed frame */ - -#define FLAC_OUTPUT_DEPTH 29 /* Provide samples left-shifted to 28 bits+sign */ - -enum decorrelation_type { - INDEPENDENT, - LEFT_SIDE, - RIGHT_SIDE, - MID_SIDE, -}; - -typedef struct FLACContext { - GetBitContext gb; - - int min_blocksize, max_blocksize; - int min_framesize, max_framesize; - int samplerate, channels; - int blocksize/*, last_blocksize*/; - int bps, curr_bps; - unsigned long samplenumber; - unsigned long totalsamples; - enum decorrelation_type decorrelation; - - int filesize; - int length; - int bitrate; - int metadatalength; - - int bitstream_size; - int bitstream_index; - - int sample_skip; - int framesize; - - int32_t *decoded[MAX_CHANNELS]; -} FLACContext; - -int flac_decode_frame(FLACContext *s, - uint8_t *buf, int buf_size, - void (*yield)(void)) ICODE_ATTR_FLAC; - -#endif diff --git a/apps/codecs/libffmpegFLAC/golomb.h b/apps/codecs/libffmpegFLAC/golomb.h deleted file mode 100644 index 197b78ee1c..0000000000 --- a/apps/codecs/libffmpegFLAC/golomb.h +++ /dev/null @@ -1,110 +0,0 @@ -/* - * exp golomb vlc stuff - * Copyright (c) 2003 Michael Niedermayer - * Copyright (c) 2004 Alex Beregszaszi - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#include -#include "codeclib.h" - -/** - * @file golomb.h - * @brief - * exp golomb vlc stuff - * @author Michael Niedermayer and Alex Beregszaszi - */ - - -/** - * read unsigned golomb rice code (jpegls). - */ -static inline int get_ur_golomb_jpegls(GetBitContext *gb, int k, int limit, int esc_len){ - unsigned int buf; - int log; - - OPEN_READER(re, gb); - UPDATE_CACHE(re, gb); - buf=GET_CACHE(re, gb); - - log= av_log2(buf); - - if(log - k >= 32-MIN_CACHE_BITS+(MIN_CACHE_BITS==32) && 32-log < limit){ - buf >>= log - k; - buf += (30-log)<>1) ^ -(v&1); -} - -/** - * read unsigned golomb rice code (shorten). - */ -#define get_ur_golomb_shorten(gb, k) get_ur_golomb_jpegls(gb, k, INT_MAX, 0) -/* -static inline unsigned int get_ur_golomb_shorten(GetBitContext *gb, int k){ - return get_ur_golomb_jpegls(gb, k, INT_MAX, 0); -} -*/ - -/** - * read signed golomb rice code (shorten). - */ -static inline int get_sr_golomb_shorten(GetBitContext* gb, int k) -{ - int uvar = get_ur_golomb_jpegls(gb, k + 1, INT_MAX, 0); - if (uvar & 1) - return ~(uvar >> 1); - else - return uvar >> 1; -} diff --git a/apps/codecs/libffmpegFLAC/libffmpegFLAC.make b/apps/codecs/libffmpegFLAC/libffmpegFLAC.make deleted file mode 100644 index 734f3d2d8e..0000000000 --- a/apps/codecs/libffmpegFLAC/libffmpegFLAC.make +++ /dev/null @@ -1,18 +0,0 @@ -# __________ __ ___. -# Open \______ \ ____ ____ | | _\_ |__ _______ ___ -# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / -# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < -# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ -# \/ \/ \/ \/ \/ -# $Id$ -# - -# libffmpegFLAC -FFMPEGFLACLIB := $(CODECDIR)/libffmpegFLAC.a -FFMPEGFLACLIB_SRC := $(call preprocess, $(APPSDIR)/codecs/libffmpegFLAC/SOURCES) -FFMPEGFLACLIB_OBJ := $(call c2obj, $(FFMPEGFLACLIB_SRC)) -OTHER_SRC += $(FFMPEGFLACLIB_SRC) - -$(FFMPEGFLACLIB): $(FFMPEGFLACLIB_OBJ) - $(SILENT)$(shell rm -f $@) - $(call PRINTS,AR $(@F))$(AR) rcs $@ $^ >/dev/null diff --git a/apps/codecs/libffmpegFLAC/shndec.c b/apps/codecs/libffmpegFLAC/shndec.c deleted file mode 100644 index 40e7211b87..0000000000 --- a/apps/codecs/libffmpegFLAC/shndec.c +++ /dev/null @@ -1,481 +0,0 @@ -/* - * Shorten decoder - * Copyright (c) 2005 Jeff Muizelaar - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/** - * @file shorten.c - * Shorten decoder - * @author Jeff Muizelaar - * - */ - -#include "bitstream.h" -#include "golomb.h" -#include "shndec.h" -#include "codeclib.h" - -#define ULONGSIZE 2 - -#define WAVE_FORMAT_PCM 0x0001 - -#define TYPESIZE 4 -#define CHANSIZE 0 -#define LPCQSIZE 2 -#define ENERGYSIZE 3 -#define BITSHIFTSIZE 2 - -#define TYPE_S16HL 3 /* signed 16 bit shorts: high-low */ -#define TYPE_S16LH 5 /* signed 16 bit shorts: low-high */ - -#define NWRAP 3 -#define NSKIPSIZE 1 - -#define LPCQUANT 5 -#define V2LPCQOFFSET (1 << LPCQUANT) - -#define FNSIZE 2 - -#define VERBATIM_CKSIZE_SIZE 5 -#define VERBATIM_BYTE_SIZE 8 -#define CANONICAL_HEADER_SIZE 44 - -#define MKTAG(a,b,c,d) (a | (b << 8) | (c << 16) | (d << 24)) - -#define get_le16(gb) bswap_16(get_bits_long(gb, 16)) -#define get_le32(gb) bswap_32(get_bits_long(gb, 32)) - -/* converts fourcc string to int */ -static unsigned int ff_get_fourcc(const char *s){ - //assert( strlen(s)==4 ); - return (s[0]) + (s[1]<<8) + (s[2]<<16) + (s[3]<<24); -} - -static unsigned int get_uint(ShortenContext *s, int k) -{ - if (s->version != 0) - k = get_ur_golomb_shorten(&s->gb, ULONGSIZE); - return get_ur_golomb_shorten(&s->gb, k); -} - -#if defined(CPU_COLDFIRE) -static inline void coldfire_lshift_samples(int n, int shift, int32_t *samples) -{ -/* - for (i = 0; i < n; i++) - samples[i] =<< shift; -*/ - asm volatile ( - "move.l %[n], %%d0 \n" /* d0 = loop counter */ - "asr.l #2, %%d0 \n" - "beq 1f \n" - "2:" /* main loop (unroll by 4) */ - "movem.l (%[x]), %%d4-%%d7 \n" - "asl.l %[s], %%d4 \n" - "asl.l %[s], %%d5 \n" - "asl.l %[s], %%d6 \n" - "asl.l %[s], %%d7 \n" - "movem.l %%d4-%%d7, (%[x]) \n" - "lea.l (16, %[x]), %[x] \n" - - "subq.l #1, %%d0 \n" - "bne 2b \n" - "1:" /* any loops left? */ - "and.l #3, %[n] \n" - "beq 4f \n" - "3:" /* remaining loops */ - "move.l (%[x]), %%d4 \n" - "asl.l %[s], %%d4 \n" - "move.l %%d4, (%[x])+ \n" - - "subq.l #1, %[n] \n" - "bne 3b \n" - "4:" /* exit */ - : [n] "+d" (n), - [x] "+a" (samples) - : [s] "d" (shift) - : "%d0", "%d4", "%d5", "%d6", "%d7", "cc", "memory" - ); -} -#endif - -static inline void fix_bitshift(ShortenContext *s, int32_t *samples) -{ - int i; - - /* Wrapped samples don't get bitshifted, so we'll do them during - the next iteration. */ - if (s->bitshift != 0) { -#if defined(CPU_COLDFIRE) - coldfire_lshift_samples(s->blocksize, s->bitshift, samples - s->nwrap); -#else - for (i = -s->nwrap; i < (s->blocksize - s->nwrap); i++) - samples[i] <<= s->bitshift; -#endif - } - - /* Also, when we have to remember to fix the wrapped samples when - the bitshift changes.*/ - if (s->bitshift != s->last_bitshift) { - if (s->last_bitshift != 0) - for (i = -s->nwrap; i < 0; i++) - samples[i] <<= s->last_bitshift; - - s->last_bitshift = s->bitshift; - } -} - -static inline void decode_subframe_lpc(ShortenContext *s, int32_t *decoded, - int residual_size, int pred_order) -{ - int sum, i, j; - int coeffs[MAX_PRED_ORDER]; - - for (i=0; igb, LPCQUANT); - } - - for (i=0; i < s->blocksize; i++) { - sum = s->lpcqoffset; - for (j=0; jgb, residual_size) + (sum >> LPCQUANT); - } -} - -static inline int shorten_decode_frame(ShortenContext *s, int32_t *decoded, - int32_t *offset) -{ - int i; - int32_t sum; - - int cmd = get_ur_golomb_shorten(&s->gb, FNSIZE); - switch (cmd) { - case FN_ZERO: - case FN_DIFF0: - case FN_DIFF1: - case FN_DIFF2: - case FN_DIFF3: - case FN_QLPC: - { - int residual_size = 0; - int32_t coffset; - if (cmd != FN_ZERO) { - residual_size = get_ur_golomb_shorten(&s->gb, ENERGYSIZE); - /* this is a hack as version 0 differed in defintion of - get_sr_golomb_shorten */ - if (s->version == 0) - residual_size--; - } - - if (s->nmean == 0) { - coffset = offset[0]; - } else { - sum = (s->version < 2) ? 0 : s->nmean / 2; - for (i=0; inmean; i++) - sum += offset[i]; - - coffset = sum / s->nmean; - if (s->version >= 2) - coffset >>= FFMIN(1, s->bitshift); - } - - switch (cmd) { - case FN_ZERO: - for (i=0; iblocksize; i++) - decoded[i] = 0; - break; - - case FN_DIFF0: - for (i=0; iblocksize; i++) - decoded[i] = - get_sr_golomb_shorten(&s->gb, residual_size) + - coffset; - break; - - case FN_DIFF1: - for (i=0; iblocksize; i++) - decoded[i] = - get_sr_golomb_shorten(&s->gb, residual_size) + - decoded[i - 1]; - break; - - case FN_DIFF2: - for (i=0; iblocksize; i++) - decoded[i] = - get_sr_golomb_shorten(&s->gb, residual_size) + - 2*decoded[i-1] - decoded[i-2]; - break; - - case FN_DIFF3: - for (i=0; iblocksize; i++) - decoded[i] = - get_sr_golomb_shorten(&s->gb, residual_size) + - 3*decoded[i-1] - 3*decoded[i-2] + decoded[i-3]; - break; - - case FN_QLPC: - { - int pred_order = get_ur_golomb_shorten(&s->gb, LPCQSIZE); - for (i=0; iblocksize; i++) - decoded[i] += coffset; - } - } - } - - if (s->nmean > 0) { - sum = (s->version < 2) ? 0 : s->blocksize / 2; - for (i=0; iblocksize; i++) - sum += decoded[i]; - - for (i=1; inmean; i++) - offset[i-1] = offset[i]; - - if (s->version < 2) { - offset[s->nmean - 1] = sum / s->blocksize; - } else { - offset[s->nmean - 1] = - (sum / s->blocksize) << s->bitshift; - } - } - - fix_bitshift(s, decoded); - break; - } - - case FN_VERBATIM: - i = get_ur_golomb_shorten(&s->gb, VERBATIM_CKSIZE_SIZE); - while (i--) - get_ur_golomb_shorten(&s->gb, VERBATIM_BYTE_SIZE); - break; - - case FN_BITSHIFT: - s->bitshift = get_ur_golomb_shorten(&s->gb, BITSHIFTSIZE); - break; - - case FN_BLOCKSIZE: - s->blocksize = get_uint(s, av_log2(s->blocksize)); - break; - - case FN_QUIT: - break; - - default: - return FN_ERROR; - break; - } - - return cmd; -} - -int shorten_decode_frames(ShortenContext *s, int *nsamples, - int32_t *decoded0, int32_t *decoded1, - int32_t *offset0, int32_t *offset1, - uint8_t *buf, int buf_size, - void (*yield)(void)) -{ - int32_t *decoded, *offset; - int cmd; - - *nsamples = 0; - - init_get_bits(&s->gb, buf, buf_size*8); - get_bits(&s->gb, s->bitindex); - - int n = 0; - while (n < NUM_DEC_LOOPS) { - int chan = n%2; - if (chan == 0) { - decoded = decoded0 + s->nwrap + *nsamples; - offset = offset0; - } else { - decoded = decoded1 + s->nwrap + *nsamples; - offset = offset1; - } - - yield(); - - cmd = shorten_decode_frame(s, decoded, offset); - - if (cmd == FN_VERBATIM || cmd == FN_BITSHIFT || cmd == FN_BLOCKSIZE) { - continue; - } else if (cmd == FN_QUIT || cmd == FN_ERROR) { - break; - } - - *nsamples += chan * s->blocksize; - n++; - } - - if (*nsamples) { - /* Wrap the samples for the next loop */ - int i; - for (i = 0; i < s->nwrap; i++) { - decoded0[i] = decoded0[*nsamples + i]; - decoded1[i] = decoded1[*nsamples + i]; - } - - /* Scale the samples for the pcmbuf */ - int scale = SHN_OUTPUT_DEPTH - s->bits_per_sample; -#if defined(CPU_COLDFIRE) - coldfire_lshift_samples(*nsamples, scale, decoded0 + s->nwrap); - coldfire_lshift_samples(*nsamples, scale, decoded1 + s->nwrap); -#else - for (i = 0; i < *nsamples; i++) { - decoded0[i + s->nwrap] <<= scale; - decoded1[i + s->nwrap] <<= scale; - } -#endif - } - - return cmd; -} - -static int decode_wave_header(ShortenContext *s, - uint8_t *header, - int header_size) -{ - GetBitContext hb; - int len; - - init_get_bits(&hb, header, header_size*8); - if (get_le32(&hb) != MKTAG('R','I','F','F')) { - return -8; - } - - int chunk_size = get_le32(&hb); - - if (get_le32(&hb) != MKTAG('W','A','V','E')) { - return -9; - } - - while (get_le32(&hb) != MKTAG('f','m','t',' ')) { - len = get_le32(&hb); - skip_bits(&hb, 8*len); - } - - len = get_le32(&hb); - if (len < 16) { - return -10; - } - - if (get_le16(&hb) != WAVE_FORMAT_PCM ) { - return -11; - } - - s->channels = get_le16(&hb); - if (s->channels > MAX_CHANNELS) { - return -3; - } - - s->sample_rate = get_le32(&hb); - - skip_bits(&hb, 32); - //s->bit_rate = 8*get_le32(&hb); - - int block_align = get_le16(&hb); - s->totalsamples = (chunk_size - 36) / block_align; - - s->bits_per_sample = get_le16(&hb); - if (s->bits_per_sample != 16) { - return -12; - } - - len -= 16; - if (len > 0) { - return len; - } - - return 0; -} - -int shorten_init(ShortenContext* s, uint8_t *buf, int buf_size) -{ - int i; - - s->blocksize = DEFAULT_BLOCK_SIZE; - s->channels = 1; - s->nmean = -1; - - init_get_bits(&s->gb, buf, buf_size*8); - get_bits(&s->gb, s->bitindex); - - /* shorten signature */ - if (get_bits_long(&s->gb, 32) != bswap_32(ff_get_fourcc("ajkg"))) { - return -1; - } - - s->version = get_bits(&s->gb, 8); - - int internal_ftype = get_uint(s, TYPESIZE); - if ((internal_ftype != TYPE_S16HL) && (internal_ftype != TYPE_S16LH)) { - return -2; - } - - s->channels = get_uint(s, CHANSIZE); - if (s->channels > MAX_CHANNELS) { - return -3; - } - - /* get blocksize if version > 0 */ - int maxnlpc = 0; - if (s->version > 0) { - s->blocksize = get_uint(s, av_log2(DEFAULT_BLOCK_SIZE)); - maxnlpc = get_uint(s, LPCQSIZE); - s->nmean = get_uint(s, 0); - - int skip_bytes = get_uint(s, NSKIPSIZE); - for (i=0; igb, 8); - } - } - - if (s->nmean > MAX_NMEAN) { - return -4; - } - - s->nwrap = FFMAX(NWRAP, maxnlpc); - if (s->nwrap > MAX_NWRAP) { - return -5; - } - - if (s->version > 1) - s->lpcqoffset = V2LPCQOFFSET; - - if (get_ur_golomb_shorten(&s->gb, FNSIZE) != FN_VERBATIM) { - return -6; - } - - uint8_t header[MAX_HEADER_SIZE]; - int header_size = get_ur_golomb_shorten(&s->gb, VERBATIM_CKSIZE_SIZE); - if (header_size >= MAX_HEADER_SIZE || header_size < CANONICAL_HEADER_SIZE) { - return -7; - } - - for (i=0; igb, VERBATIM_BYTE_SIZE); - - s->header_bits = s->gb.index; - - return decode_wave_header(s, header, header_size); -} diff --git a/apps/codecs/libffmpegFLAC/shndec.h b/apps/codecs/libffmpegFLAC/shndec.h deleted file mode 100644 index 068f4faf28..0000000000 --- a/apps/codecs/libffmpegFLAC/shndec.h +++ /dev/null @@ -1,52 +0,0 @@ -#include "bitstream.h" - -#define SHN_OUTPUT_DEPTH 29 /* 28 bits + sign */ - -#define MAX_CHANNELS 2 -#define MAX_PRED_ORDER 16 -#define MAX_NWRAP MAX_PRED_ORDER -#define MAX_NMEAN 4 - -/* NUM_DEC_LOOPS should be even number */ -#define NUM_DEC_LOOPS 26 -#define DEFAULT_BLOCK_SIZE 256 -#define MAX_HEADER_SIZE DEFAULT_BLOCK_SIZE*4 -#define MAX_BUFFER_SIZE 2*DEFAULT_BLOCK_SIZE*NUM_DEC_LOOPS -#define MAX_DECODE_SIZE ((DEFAULT_BLOCK_SIZE*NUM_DEC_LOOPS/2) + MAX_NWRAP) -#define MAX_OFFSET_SIZE MAX_NMEAN - -#define FN_DIFF0 0 -#define FN_DIFF1 1 -#define FN_DIFF2 2 -#define FN_DIFF3 3 -#define FN_QUIT 4 -#define FN_BLOCKSIZE 5 -#define FN_BITSHIFT 6 -#define FN_QLPC 7 -#define FN_ZERO 8 -#define FN_VERBATIM 9 -#define FN_ERROR 10 - -typedef struct ShortenContext { - GetBitContext gb; - int32_t lpcqoffset; - uint32_t totalsamples; - int header_bits; - int channels; - int sample_rate; - int bits_per_sample; - int version; - int bitshift; - int last_bitshift; - int nmean; - int nwrap; - int blocksize; - int bitindex; -} ShortenContext; - -int shorten_init(ShortenContext* s, uint8_t *buf, int buf_size); -int shorten_decode_frames(ShortenContext *s, int *nsamples, - int32_t *decoded0, int32_t *decoded1, - int32_t *offset0, int32_t *offset1, - uint8_t *buf, int buf_size, - void (*yield)(void)) ICODE_ATTR; diff --git a/apps/codecs/libgme/2413tone.h b/apps/codecs/libgme/2413tone.h deleted file mode 100644 index c0922c1225..0000000000 --- a/apps/codecs/libgme/2413tone.h +++ /dev/null @@ -1,20 +0,0 @@ -/* YM2413 tone by okazaki@angel.ne.jp */ -0x49,0x4c,0x4c,0x32,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x61,0x61,0x1e,0x17,0xf0,0x7f,0x00,0x17,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x13,0x41,0x16,0x0e,0xfd,0xf4,0x23,0x23,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x03,0x01,0x9a,0x04,0xf3,0xf3,0x13,0xf3,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x11,0x61,0x0e,0x07,0xfa,0x64,0x70,0x17,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x22,0x21,0x1e,0x06,0xf0,0x76,0x00,0x28,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x21,0x22,0x16,0x05,0xf0,0x71,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x21,0x61,0x1d,0x07,0x82,0x80,0x17,0x17,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x23,0x21,0x2d,0x16,0x90,0x90,0x00,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x21,0x21,0x1b,0x06,0x64,0x65,0x10,0x17,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x21,0x21,0x0b,0x1a,0x85,0xa0,0x70,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x23,0x01,0x83,0x10,0xff,0xb4,0x10,0xf4,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x97,0xc1,0x20,0x07,0xff,0xf4,0x22,0x22,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x61,0x00,0x0c,0x05,0xc2,0xf6,0x40,0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x01,0x01,0x56,0x03,0x94,0xc2,0x03,0x12,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x21,0x01,0x89,0x03,0xf1,0xe4,0xf0,0x23,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x07,0x21,0x14,0x00,0xee,0xf8,0xff,0xf8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x01,0x31,0x00,0x00,0xf8,0xf7,0xf8,0xf7,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x25,0x11,0x00,0x00,0xf8,0xfa,0xf8,0x55,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 diff --git a/apps/codecs/libgme/281btone.h b/apps/codecs/libgme/281btone.h deleted file mode 100644 index 83f63bff00..0000000000 --- a/apps/codecs/libgme/281btone.h +++ /dev/null @@ -1,20 +0,0 @@ -/* YMF281B tone by Chabin */ -0x49,0x4c,0x4c,0x32,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x62,0x21,0x1a,0x07,0xf0,0x6f,0x00,0x16,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x10,0x44,0x02,0xf6,0xf4,0x54,0x23,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x03,0x01,0x97,0x04,0xf3,0xf3,0x13,0xf3,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x01,0x61,0x0a,0x0f,0xfa,0x64,0x70,0x17,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x22,0x21,0x1e,0x06,0xf0,0x76,0x00,0x28,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x61,0x8a,0x0e,0xc0,0x61,0x00,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x21,0x61,0x1b,0x07,0x84,0x80,0x17,0x17,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x37,0x32,0xc9,0x01,0x66,0x64,0x40,0x28,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x01,0x21,0x06,0x03,0xa5,0x71,0x51,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x06,0x11,0x5e,0x07,0xf3,0xf2,0xf6,0x11,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x20,0x18,0x06,0xf5,0xf3,0x20,0x26,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x97,0x41,0x20,0x07,0xff,0xf4,0x22,0x22,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x65,0x61,0x15,0x00,0xf7,0xf3,0x16,0xf4,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x01,0x31,0x0e,0x07,0xfa,0xf3,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x48,0x61,0x09,0x07,0xf1,0x94,0xf0,0xf5,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x07,0x21,0x14,0x00,0xee,0xf8,0xff,0xf8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x01,0x31,0x00,0x00,0xf8,0xf7,0xf8,0xf7,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x25,0x11,0x00,0x00,0xf8,0xfa,0xf8,0x55,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 diff --git a/apps/codecs/libgme/AYSOURCES b/apps/codecs/libgme/AYSOURCES deleted file mode 100644 index f2b52a51d9..0000000000 --- a/apps/codecs/libgme/AYSOURCES +++ /dev/null @@ -1,7 +0,0 @@ -ay_apu.c -ay_cpu.c -ay_emu.c -blip_buffer.c -multi_buffer.c -track_filter.c -z80_cpu.c diff --git a/apps/codecs/libgme/EMU2413SOURCES b/apps/codecs/libgme/EMU2413SOURCES deleted file mode 100644 index 901c49eccf..0000000000 --- a/apps/codecs/libgme/EMU2413SOURCES +++ /dev/null @@ -1,4 +0,0 @@ -sms_apu.c -sms_fm_apu.c -emu2413.c -ym2413_emu.c diff --git a/apps/codecs/libgme/GBSSOURCES b/apps/codecs/libgme/GBSSOURCES deleted file mode 100644 index a839a2156e..0000000000 --- a/apps/codecs/libgme/GBSSOURCES +++ /dev/null @@ -1,9 +0,0 @@ -gb_apu.c -gb_cpu.c -gbs_cpu.c -gb_oscs.c -gbs_emu.c -blip_buffer.c -multi_buffer.c -rom_data.c -track_filter.c diff --git a/apps/codecs/libgme/HESSOURCES b/apps/codecs/libgme/HESSOURCES deleted file mode 100644 index d529388978..0000000000 --- a/apps/codecs/libgme/HESSOURCES +++ /dev/null @@ -1,8 +0,0 @@ -hes_apu.c -hes_apu_adpcm.c -hes_cpu.c -hes_emu.c -blip_buffer.c -multi_buffer.c -rom_data.c -track_filter.c diff --git a/apps/codecs/libgme/KSSSOURCES b/apps/codecs/libgme/KSSSOURCES deleted file mode 100644 index bde213364b..0000000000 --- a/apps/codecs/libgme/KSSSOURCES +++ /dev/null @@ -1,12 +0,0 @@ -ay_apu.c -kss_cpu.c -kss_emu.c -kss_scc_apu.c -opl_apu.c -z80_cpu.c -blip_buffer.c -multi_buffer.c -rom_data.c -emu8950.c -emuadpcm.c -track_filter.c diff --git a/apps/codecs/libgme/NSFSOURCES b/apps/codecs/libgme/NSFSOURCES deleted file mode 100644 index 60537ff8e4..0000000000 --- a/apps/codecs/libgme/NSFSOURCES +++ /dev/null @@ -1,15 +0,0 @@ -nes_apu.c -nes_cpu.c -nes_fds_apu.c -nes_fme7_apu.c -nes_namco_apu.c -nes_oscs.c -nes_vrc6_apu.c -nes_vrc7_apu.c -nsf_cpu.c -nsf_emu.c -nsfe_info.c -blip_buffer.c -multi_buffer.c -rom_data.c -track_filter.c diff --git a/apps/codecs/libgme/SGCSOURCES b/apps/codecs/libgme/SGCSOURCES deleted file mode 100644 index d0e8abc2b7..0000000000 --- a/apps/codecs/libgme/SGCSOURCES +++ /dev/null @@ -1,7 +0,0 @@ -sgc_cpu.c -sgc_emu.c -z80_cpu.c -blip_buffer.c -multi_buffer.c -rom_data.c -track_filter.c diff --git a/apps/codecs/libgme/VGMSOURCES b/apps/codecs/libgme/VGMSOURCES deleted file mode 100644 index bb57e16e82..0000000000 --- a/apps/codecs/libgme/VGMSOURCES +++ /dev/null @@ -1,10 +0,0 @@ -blip_buffer.c -multi_buffer.c -resampler.c -vgm_emu.c -ym2612_emu.c -track_filter.c -inflate/bbfuncs.c -inflate/inflate.c -inflate/mallocer.c -inflate/mbreader.c diff --git a/apps/codecs/libgme/ay_apu.c b/apps/codecs/libgme/ay_apu.c deleted file mode 100644 index c84e92d43d..0000000000 --- a/apps/codecs/libgme/ay_apu.c +++ /dev/null @@ -1,413 +0,0 @@ -// Game_Music_Emu 0.6-pre. http://www.slack.net/~ant/ - -#include "ay_apu.h" - -/* Copyright (C) 2006-2008 Shay Green. This module is free software; you -can redistribute it and/or modify it under the terms of the GNU Lesser -General Public License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. This -module is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more -details. You should have received a copy of the GNU Lesser General Public -License along with this module; if not, write to the Free Software Foundation, -Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ - -#include "blargg_source.h" - -// Emulation inaccuracies: -// * Noise isn't run when not in use -// * Changes to envelope and noise periods are delayed until next reload -// * Super-sonic tone should attenuate output to about 60%, not 50% - -// Tones above this frequency are treated as disabled tone at half volume. -// Power of two is more efficient (avoids division). -int const inaudible_freq = 16384; - -int const period_factor = 16; - -static byte const amp_table [16] = -{ -#define ENTRY( n ) (byte) (n * ay_amp_range + 0.5) - // With channels tied together and 1K resistor to ground (as datasheet recommends), - // output nearly matches logarithmic curve as claimed. Approx. 1.5 dB per step. - ENTRY(0.000000),ENTRY(0.007813),ENTRY(0.011049),ENTRY(0.015625), - ENTRY(0.022097),ENTRY(0.031250),ENTRY(0.044194),ENTRY(0.062500), - ENTRY(0.088388),ENTRY(0.125000),ENTRY(0.176777),ENTRY(0.250000), - ENTRY(0.353553),ENTRY(0.500000),ENTRY(0.707107),ENTRY(1.000000), - - /* - // Measured from an AY-3-8910A chip with date code 8611. - - // Direct voltages without any load (very linear) - ENTRY(0.000000),ENTRY(0.046237),ENTRY(0.064516),ENTRY(0.089785), - ENTRY(0.124731),ENTRY(0.173118),ENTRY(0.225806),ENTRY(0.329032), - ENTRY(0.360215),ENTRY(0.494624),ENTRY(0.594624),ENTRY(0.672043), - ENTRY(0.766129),ENTRY(0.841935),ENTRY(0.926882),ENTRY(1.000000), - // With only some load - ENTRY(0.000000),ENTRY(0.011940),ENTRY(0.017413),ENTRY(0.024876), - ENTRY(0.036318),ENTRY(0.054229),ENTRY(0.072637),ENTRY(0.122388), - ENTRY(0.174129),ENTRY(0.239303),ENTRY(0.323881),ENTRY(0.410945), - ENTRY(0.527363),ENTRY(0.651741),ENTRY(0.832338),ENTRY(1.000000), - */ -#undef ENTRY -}; - -static byte const modes [8] = -{ -#define MODE( a0,a1, b0,b1, c0,c1 ) \ - (a0 | a1<<1 | b0<<2 | b1<<3 | c0<<4 | c1<<5) - MODE( 1,0, 1,0, 1,0 ), - MODE( 1,0, 0,0, 0,0 ), - MODE( 1,0, 0,1, 1,0 ), - MODE( 1,0, 1,1, 1,1 ), - MODE( 0,1, 0,1, 0,1 ), - MODE( 0,1, 1,1, 1,1 ), - MODE( 0,1, 1,0, 0,1 ), - MODE( 0,1, 0,0, 0,0 ), -}; - -static void set_output( struct Ay_Apu* this, struct Blip_Buffer* b ) -{ - int i; - for ( i = 0; i < ay_osc_count; ++i ) - Ay_apu_set_output( this, i, b ); -} - -void Ay_apu_init( struct Ay_Apu* this ) -{ - Synth_init( &this->synth_ ); - - // build full table of the upper 8 envelope waveforms - int m; - for ( m = 8; m--; ) - { - byte* out = this->env_modes [m]; - int x, y, flags = modes [m]; - for ( x = 3; --x >= 0; ) - { - int amp = flags & 1; - int end = flags >> 1 & 1; - int step = end - amp; - amp *= 15; - for ( y = 16; --y >= 0; ) - { - *out++ = amp_table [amp]; - amp += step; - } - flags >>= 2; - } - } - - set_output( this, NULL ); - Ay_apu_volume( this, (int)FP_ONE_VOLUME ); - Ay_apu_reset( this ); -} - -void Ay_apu_reset( struct Ay_Apu* this ) -{ - this->addr_ = 0; - this->last_time = 0; - this->noise_delay = 0; - this->noise_lfsr = 1; - - struct osc_t* osc; - for ( osc = &this->oscs [ay_osc_count]; osc != this->oscs; ) - { - osc--; - osc->period = period_factor; - osc->delay = 0; - osc->last_amp = 0; - osc->phase = 0; - } - - int i; - for ( i = sizeof this->regs; --i >= 0; ) - this->regs [i] = 0; - this->regs [7] = 0xFF; - write_data_( this, 13, 0 ); -} - -int Ay_apu_read( struct Ay_Apu* this ) -{ - static byte const masks [ay_reg_count] = { - 0xFF, 0x0F, 0xFF, 0x0F, 0xFF, 0x0F, 0x1F, 0x3F, - 0x1F, 0x1F, 0x1F, 0xFF, 0xFF, 0x0F, 0x00, 0x00 - }; - return this->regs [this->addr_] & masks [this->addr_]; -} - -void write_data_( struct Ay_Apu* this, int addr, int data ) -{ - assert( (unsigned) addr < ay_reg_count ); - - /* if ( (unsigned) addr >= 14 ) - dprintf( "Wrote to I/O port %02X\n", (int) addr ); */ - - // envelope mode - if ( addr == 13 ) - { - if ( !(data & 8) ) // convert modes 0-7 to proper equivalents - data = (data & 4) ? 15 : 9; - this->env_wave = this->env_modes [data - 7]; - this->env_pos = -48; - this->env_delay = 0; // will get set to envelope period in run_until() - } - this->regs [addr] = data; - - // handle period changes accurately - int i = addr >> 1; - if ( i < ay_osc_count ) - { - blip_time_t period = (this->regs [i * 2 + 1] & 0x0F) * (0x100 * period_factor) + - this->regs [i * 2] * period_factor; - if ( !period ) - period = period_factor; - - // adjust time of next timer expiration based on change in period - struct osc_t* osc = &this->oscs [i]; - if ( (osc->delay += period - osc->period) < 0 ) - osc->delay = 0; - osc->period = period; - } - - // TODO: same as above for envelope timer, and it also has a divide by two after it -} - -int const noise_off = 0x08; -int const tone_off = 0x01; - -void run_until( struct Ay_Apu* this, blip_time_t final_end_time ) -{ - require( final_end_time >= this->last_time ); - - // noise period and initial values - blip_time_t const noise_period_factor = period_factor * 2; // verified - blip_time_t noise_period = (this->regs [6] & 0x1F) * noise_period_factor; - if ( !noise_period ) - noise_period = noise_period_factor; - blip_time_t const old_noise_delay = this->noise_delay; - unsigned const old_noise_lfsr = this->noise_lfsr; - - // envelope period - blip_time_t const env_period_factor = period_factor * 2; // verified - blip_time_t env_period = (this->regs [12] * 0x100 + this->regs [11]) * env_period_factor; - if ( !env_period ) - env_period = env_period_factor; // same as period 1 on my AY chip - if ( !this->env_delay ) - this->env_delay = env_period; - - // run each osc separately - int index; - for ( index = 0; index < ay_osc_count; index++ ) - { - struct osc_t* const osc = &this->oscs [index]; - int osc_mode = this->regs [7] >> index; - - // output - struct Blip_Buffer* const osc_output = osc->output; - if ( !osc_output ) - continue; - Blip_set_modified( osc_output ); - - // period - int half_vol = 0; - blip_time_t inaudible_period = (unsigned) (Blip_clock_rate( osc_output ) + - inaudible_freq) / (unsigned) (inaudible_freq * 2); - if ( osc->period <= inaudible_period && !(osc_mode & tone_off) ) - { - half_vol = 1; // Actually around 60%, but 50% is close enough - osc_mode |= tone_off; - } - - // envelope - blip_time_t start_time = this->last_time; - blip_time_t end_time = final_end_time; - int const vol_mode = this->regs [0x08 + index]; - int volume = amp_table [vol_mode & 0x0F] >> half_vol; - int osc_env_pos = this->env_pos; - if ( vol_mode & 0x10 ) - { - volume = this->env_wave [osc_env_pos] >> half_vol; - // use envelope only if it's a repeating wave or a ramp that hasn't finished - if ( !(this->regs [13] & 1) || osc_env_pos < -32 ) - { - end_time = start_time + this->env_delay; - if ( end_time >= final_end_time ) - end_time = final_end_time; - - //if ( !(regs [12] | regs [11]) ) - // dprintf( "Used envelope period 0\n" ); - } - else if ( !volume ) - { - osc_mode = noise_off | tone_off; - } - } - else if ( !volume ) - { - osc_mode = noise_off | tone_off; - } - - // tone time - blip_time_t const period = osc->period; - blip_time_t time = start_time + osc->delay; - if ( osc_mode & tone_off ) // maintain tone's phase when off - { - int count = (final_end_time - time + period - 1) / period; - time += count * period; - osc->phase ^= count & 1; - } - - // noise time - blip_time_t ntime = final_end_time; - unsigned noise_lfsr = 1; - if ( !(osc_mode & noise_off) ) - { - ntime = start_time + old_noise_delay; - noise_lfsr = old_noise_lfsr; - //if ( (regs [6] & 0x1F) == 0 ) - // dprintf( "Used noise period 0\n" ); - } - - // The following efficiently handles several cases (least demanding first): - // * Tone, noise, and envelope disabled, where channel acts as 4-bit DAC - // * Just tone or just noise, envelope disabled - // * Envelope controlling tone and/or noise - // * Tone and noise disabled, envelope enabled with high frequency - // * Tone and noise together - // * Tone and noise together with envelope - - // this loop only runs one iteration if envelope is disabled. If envelope - // is being used as a waveform (tone and noise disabled), this loop will - // still be reasonably efficient since the bulk of it will be skipped. - while ( 1 ) - { - // current amplitude - int amp = 0; - if ( (osc_mode | osc->phase) & 1 & (osc_mode >> 3 | noise_lfsr) ) - amp = volume; - { - int delta = amp - osc->last_amp; - if ( delta ) - { - osc->last_amp = amp; - Synth_offset( &this->synth_, start_time, delta, osc_output ); - } - } - - // Run wave and noise interleved with each catching up to the other. - // If one or both are disabled, their "current time" will be past end time, - // so there will be no significant performance hit. - if ( ntime < end_time || time < end_time ) - { - // Since amplitude was updated above, delta will always be +/- volume, - // so we can avoid using last_amp every time to calculate the delta. - int delta = amp * 2 - volume; - int delta_non_zero = delta != 0; - int phase = osc->phase | (osc_mode & tone_off); assert( tone_off == 0x01 ); - do - { - // run noise - blip_time_t end = end_time; - if ( end_time > time ) end = time; - if ( phase & delta_non_zero ) - { - while ( ntime <= end ) // must advance *past* time to avoid hang - { - int changed = noise_lfsr + 1; - noise_lfsr = (-(noise_lfsr & 1) & 0x12000) ^ (noise_lfsr >> 1); - if ( changed & 2 ) - { - delta = -delta; - Synth_offset( &this->synth_, ntime, delta, osc_output ); - } - ntime += noise_period; - } - } - else - { - // 20 or more noise periods on average for some music - int remain = end - ntime; - int count = remain / noise_period; - if ( remain >= 0 ) - ntime += noise_period + count * noise_period; - } - - // run tone - end = end_time; - if ( end_time > ntime ) end = ntime; - if ( noise_lfsr & delta_non_zero ) - { - while ( time < end ) - { - delta = -delta; - Synth_offset( &this->synth_, time, delta, osc_output ); - time += period; - - // alternate (less-efficient) implementation - //phase ^= 1; - } - phase = (unsigned) (-delta) >> (CHAR_BIT * sizeof (unsigned) - 1); - check( phase == (delta > 0) ); - } - else - { - // loop usually runs less than once - //SUB_CASE_COUNTER( (time < end) * (end - time + period - 1) / period ); - - while ( time < end ) - { - time += period; - phase ^= 1; - } - } - } - while ( time < end_time || ntime < end_time ); - - osc->last_amp = (delta + volume) >> 1; - if ( !(osc_mode & tone_off) ) - osc->phase = phase; - } - - if ( end_time >= final_end_time ) - break; // breaks first time when envelope is disabled - - // next envelope step - if ( ++osc_env_pos >= 0 ) - osc_env_pos -= 32; - volume = this->env_wave [osc_env_pos] >> half_vol; - - start_time = end_time; - end_time += env_period; - if ( end_time > final_end_time ) - end_time = final_end_time; - } - osc->delay = time - final_end_time; - - if ( !(osc_mode & noise_off) ) - { - this->noise_delay = ntime - final_end_time; - this->noise_lfsr = noise_lfsr; - } - } - - // TODO: optimized saw wave envelope? - - // maintain envelope phase - blip_time_t remain = final_end_time - this->last_time - this->env_delay; - if ( remain >= 0 ) - { - int count = (remain + env_period) / env_period; - this->env_pos += count; - if ( this->env_pos >= 0 ) - this->env_pos = (this->env_pos & 31) - 32; - remain -= count * env_period; - assert( -remain <= env_period ); - } - this->env_delay = -remain; - assert( this->env_delay > 0 ); - assert( this->env_pos < 0 ); - - this->last_time = final_end_time; -} diff --git a/apps/codecs/libgme/ay_apu.h b/apps/codecs/libgme/ay_apu.h deleted file mode 100644 index 3df6ba1118..0000000000 --- a/apps/codecs/libgme/ay_apu.h +++ /dev/null @@ -1,79 +0,0 @@ -// AY-3-8910 sound chip ulator - -// Game_Music_Emu 0.6-pre -#ifndef AY_APU_H -#define AY_APU_H - -#include "blargg_common.h" -#include "blargg_source.h" -#include "blip_buffer.h" - -// Number of registers -enum { ay_reg_count = 16 }; -enum { ay_osc_count = 3 }; -enum { ay_amp_range = 255 }; - -struct osc_t -{ - blip_time_t period; - blip_time_t delay; - short last_amp; - short phase; - struct Blip_Buffer* output; -}; - -struct Ay_Apu { - struct osc_t oscs [ay_osc_count]; - - blip_time_t last_time; - byte addr_; - byte regs [ay_reg_count]; - - blip_time_t noise_delay; - unsigned noise_lfsr; - - blip_time_t env_delay; - byte const* env_wave; - int env_pos; - byte env_modes [8] [48]; // values already passed through volume table - - struct Blip_Synth synth_; // used by Ay_Core for beeper sound -}; - -void Ay_apu_init( struct Ay_Apu* this ); - -// Writes to address register -static inline void Ay_apu_write_addr( struct Ay_Apu* this, int data ) { this->addr_ = data & 0x0F; } - -// Emulates to time t, then writes to current data register -void run_until( struct Ay_Apu* this, blip_time_t final_end_time );; -void write_data_( struct Ay_Apu* this, int addr, int data ); -static inline void Ay_apu_write_data( struct Ay_Apu* this, blip_time_t t, int data ) { run_until( this, t ); write_data_( this, this->addr_, data ); } - -// Reads from current data register -int Ay_apu_read( struct Ay_Apu* this ); - -// Resets sound chip -void Ay_apu_reset( struct Ay_Apu* this ); - -// Sets overall volume, where 1.0 is normal -static inline void Ay_apu_volume( struct Ay_Apu* this, int v ) { Synth_volume( &this->synth_, (v*7)/10 /ay_osc_count/ay_amp_range ); } - -static inline void Ay_apu_set_output( struct Ay_Apu* this, int i, struct Blip_Buffer* out ) -{ - assert( (unsigned) i < ay_osc_count ); - this->oscs [i].output = out; -} - -// Emulates to time t, then subtracts t from the current time. -// OK if previous write call had time slightly after t. -static inline void Ay_apu_end_frame( struct Ay_Apu* this, blip_time_t time ) -{ - if ( time > this->last_time ) - run_until( this, time ); - - this->last_time -= time; - assert( this->last_time >= 0 ); -} - -#endif diff --git a/apps/codecs/libgme/ay_cpu.c b/apps/codecs/libgme/ay_cpu.c deleted file mode 100644 index 5fbfe7c1ea..0000000000 --- a/apps/codecs/libgme/ay_cpu.c +++ /dev/null @@ -1,59 +0,0 @@ -// Game_Music_Emu 0.6-pre. http://www.slack.net/~ant/ - -#include "ay_emu.h" - -#include "blargg_endian.h" -//#include "z80_cpu_log.h" - -/* Copyright (C) 2006-2008 Shay Green. This module is free software; you -can redistribute it and/or modify it under the terms of the GNU Lesser -General Public License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. This -module is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more -details. You should have received a copy of the GNU Lesser General Public -License along with this module; if not, write to the Free Software Foundation, -Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ - -#include "blargg_source.h" - -void cpu_out( struct Ay_Emu* this, cpu_time_t time, addr_t addr, int data ) -{ - if ( (addr & 0xFF) == 0xFE ) - { - check( !cpc_mode ); - this->spectrum_mode = !this->cpc_mode; - - // beeper_mask and last_beeper are 0 if (cpc_mode || !beeper_output) - if ( (data &= this->beeper_mask) != this->last_beeper ) - { - this->last_beeper = data; - int delta = -this->beeper_delta; - this->beeper_delta = delta; - struct Blip_Buffer* bb = this->beeper_output; - Blip_set_modified( bb ); - Synth_offset( &this->apu.synth_, time, delta, bb ); - } - } - else - { - cpu_out_( this, time, addr, data ); - } -} - -#define OUT_PORT( addr, data ) cpu_out( this, TIME(), addr, data ) -#define IN_PORT( addr ) 0xFF // cpu in -#define FLAT_MEM mem - -#define CPU_BEGIN \ -bool run_cpu( struct Ay_Emu* this, cpu_time_t end_time ) \ -{\ - struct Z80_Cpu* cpu = &this->cpu; \ - Z80_set_end_time( cpu, end_time ); \ - byte* const mem = this->mem.ram; // cache - - #include "z80_cpu_run.h" - - return warning; -} diff --git a/apps/codecs/libgme/ay_emu.c b/apps/codecs/libgme/ay_emu.c deleted file mode 100644 index 92faba4929..0000000000 --- a/apps/codecs/libgme/ay_emu.c +++ /dev/null @@ -1,599 +0,0 @@ -// Game_Music_Emu 0.6-pre. http://www.slack.net/~ant/ - -#include "ay_emu.h" - -#include "blargg_endian.h" - -/* Copyright (C) 2006-2009 Shay Green. This module is free software; you -can redistribute it and/or modify it under the terms of the GNU Lesser -General Public License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. This -module is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more -details. You should have received a copy of the GNU Lesser General Public -License along with this module; if not, write to the Free Software Foundation, -Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ - -#include "blargg_source.h" - -const char* const gme_wrong_file_type = "Wrong file type for this emulator"; - -// TODO: probably don't need detailed errors as to why file is corrupt - -int const spectrum_clock = 3546900; // 128K Spectrum -int const spectrum_period = 70908; - -//int const spectrum_clock = 3500000; // 48K Spectrum -//int const spectrum_period = 69888; - -int const cpc_clock = 2000000; - -static void clear_track_vars( struct Ay_Emu *this ) -{ - this->current_track = -1; - track_stop( &this->track_filter ); -} - -void Ay_init( struct Ay_Emu *this ) -{ - this->sample_rate = 0; - this->mute_mask_ = 0; - this->tempo = (int)FP_ONE_TEMPO; - this->gain = (int)FP_ONE_GAIN; - this->track_count = 0; - - // defaults - this->tfilter = *track_get_setup( &this->track_filter ); - this->tfilter.max_initial = 2; - this->tfilter.lookahead = 6; - this->track_filter.silence_ignored_ = false; - - this->beeper_output = NULL; - disable_beeper( this ); - - Ay_apu_init( &this->apu ); - Z80_init( &this->cpu ); - - // clears fields - this->voice_count = 0; - this->voice_types = 0; - clear_track_vars( this ); -} - -// Track info - -// Given pointer to 2-byte offset of data, returns pointer to data, or NULL if -// offset is 0 or there is less than min_size bytes of data available. -static byte const* get_data( struct file_t const* file, byte const ptr [], int min_size ) -{ - int offset = (int16_t) get_be16( ptr ); - int pos = ptr - (byte const*) file->header; - int size = file->end - (byte const*) file->header; - assert( (unsigned) pos <= (unsigned) size - 2 ); - int limit = size - min_size; - if ( limit < 0 || !offset || (unsigned) (pos + offset) > (unsigned) limit ) - return NULL; - return ptr + offset; -} - -static blargg_err_t parse_header( byte const in [], int size, struct file_t* out ) -{ - if ( size < header_size ) - return gme_wrong_file_type; - - out->header = (struct header_t const*) in; - out->end = in + size; - struct header_t const* h = (struct header_t const*) in; - if ( memcmp( h->tag, "ZXAYEMUL", 8 ) ) - return gme_wrong_file_type; - - out->tracks = get_data( out, h->track_info, (h->max_track + 1) * 4 ); - if ( !out->tracks ) - return "missing track data"; - - return 0; -} - -// Setup - -static void change_clock_rate( struct Ay_Emu *this, int rate ) -{ - this->clock_rate_ = rate; - Buffer_clock_rate( &this->stereo_buf, rate ); -} - -blargg_err_t Ay_load_mem( struct Ay_Emu *this, byte const in [], long size ) -{ - // Unload - this->voice_count = 0; - this->track_count = 0; - this->m3u.size = 0; - clear_track_vars( this ); - - assert( offsetof (struct header_t,track_info [2]) == header_size ); - - RETURN_ERR( parse_header( in, size, &this->file ) ); - - /* if ( file.header->vers > 2 ) - warning( "Unknown file version" ); */ - - this->voice_count = ay_osc_count + 1; // +1 for beeper - static int const types [ay_osc_count + 1] = { - wave_type+0, wave_type+1, wave_type+2, mixed_type+1 - }; - this->voice_types = types; - - Ay_apu_volume( &this->apu, this->gain); - - // Setup buffer - change_clock_rate( this, spectrum_clock ); - RETURN_ERR( Buffer_set_channel_count( &this->stereo_buf, this->voice_count, this->voice_types ) ); - this->buf_changed_count = Buffer_channels_changed_count( &this->stereo_buf ); - - Sound_set_tempo( this, this->tempo ); - Sound_mute_voices( this, this->mute_mask_ ); - - this->track_count = this->file.header->max_track + 1; - return 0; -} - -static void set_beeper_output( struct Ay_Emu *this, struct Blip_Buffer* b ) -{ - this->beeper_output = b; - if ( b && !this->cpc_mode ) - this->beeper_mask = 0x10; - else - disable_beeper( this ); -} - -static void set_voice( struct Ay_Emu *this, int i, struct Blip_Buffer* center ) -{ - if ( i >= ay_osc_count ) - set_beeper_output( this, center ); - else - Ay_apu_set_output( &this->apu, i, center ); -} - -static blargg_err_t run_clocks( struct Ay_Emu *this, blip_time_t* duration, int msec ) -{ -#if defined(ROCKBOX) - (void) msec; -#endif - - cpu_time_t *end = duration; - struct Z80_Cpu* cpu = &this->cpu; - Z80_set_time( cpu, 0 ); - - // Since detection of CPC mode will halve clock rate during the frame - // and thus generate up to twice as much sound, we must generate half - // as much until mode is known. - if ( !(this->spectrum_mode | this->cpc_mode) ) - *end /= 2; - - while ( Z80_time( cpu ) < *end ) - { - run_cpu( this, min( *end, this->next_play ) ); - - if ( Z80_time( cpu ) >= this->next_play ) - { - // next frame - this->next_play += this->play_period; - - if ( cpu->r.iff1 ) - { - // interrupt enabled - - if ( this->mem.ram [cpu->r.pc] == 0x76 ) - cpu->r.pc++; // advance past HALT instruction - - cpu->r.iff1 = 0; - cpu->r.iff2 = 0; - - this->mem.ram [--cpu->r.sp] = (byte) (cpu->r.pc >> 8); - this->mem.ram [--cpu->r.sp] = (byte) (cpu->r.pc); - - // fixed interrupt - cpu->r.pc = 0x38; - Z80_adjust_time( cpu, 12 ); - - if ( cpu->r.im == 2 ) - { - // vectored interrupt - addr_t addr = cpu->r.i * 0x100 + 0xFF; - cpu->r.pc = this->mem.ram [(addr + 1) & 0xFFFF] * 0x100 + this->mem.ram [addr]; - Z80_adjust_time( cpu, 6 ); - } - } - } - } - - // End time frame - *end = Z80_time( cpu ); - this->next_play -= *end; - check( this->next_play >= 0 ); - Z80_adjust_time( cpu, -*end ); - Ay_apu_end_frame( &this->apu, *end ); - return 0; -} - -// Emulation - -void cpu_out_( struct Ay_Emu *this, cpu_time_t time, addr_t addr, int data ) -{ - // Spectrum - if ( !this->cpc_mode ) - { - switch ( addr & 0xFEFF ) - { - case 0xFEFD: - this->spectrum_mode = true; - Ay_apu_write_addr( &this->apu, data ); - return; - - case 0xBEFD: - this->spectrum_mode = true; - Ay_apu_write_data( &this->apu, time, data ); - return; - } - } - - // CPC - if ( !this->spectrum_mode ) - { - switch ( addr >> 8 ) - { - case 0xF6: - switch ( data & 0xC0 ) - { - case 0xC0: - Ay_apu_write_addr( &this->apu, this->cpc_latch ); - goto enable_cpc; - - case 0x80: - Ay_apu_write_data( &this->apu, time, this->cpc_latch ); - goto enable_cpc; - } - break; - - case 0xF4: - this->cpc_latch = data; - goto enable_cpc; - } - } - - /* dprintf( "Unmapped OUT: $%04X <- $%02X\n", addr, data ); */ - return; - -enable_cpc: - if ( !this->cpc_mode ) - { - this->cpc_mode = true; - disable_beeper( this ); - - change_clock_rate( this, cpc_clock ); - Sound_set_tempo( this, this->tempo ); - } -} - -blargg_err_t Ay_set_sample_rate( struct Ay_Emu *this, int rate ) -{ - require( !this->sample_rate ); // sample rate can't be changed once set - Buffer_init( &this->stereo_buf ); - RETURN_ERR( Buffer_set_sample_rate( &this->stereo_buf, rate, 1000 / 20 ) ); - - // Set buffer bass - Buffer_bass_freq( &this->stereo_buf, 160 ); - - this->sample_rate = rate; - RETURN_ERR( track_init( &this->track_filter, this ) ); - this->tfilter.max_silence = 6 * stereo * this->sample_rate; - return 0; -} - -void Sound_mute_voice( struct Ay_Emu *this, int index, bool mute ) -{ - require( (unsigned) index < (unsigned) this->voice_count ); - int bit = 1 << index; - int mask = this->mute_mask_ | bit; - if ( !mute ) - mask ^= bit; - Sound_mute_voices( this, mask ); -} - -void Sound_mute_voices( struct Ay_Emu *this, int mask ) -{ - require( this->sample_rate ); // sample rate must be set first - this->mute_mask_ = mask; - - int i; - for ( i = this->voice_count; i--; ) - { - if ( mask & (1 << i) ) - { - set_voice( this, i, 0 ); - } - else - { - struct channel_t ch = Buffer_channel( &this->stereo_buf, i ); - assert( (ch.center && ch.left && ch.right) || - (!ch.center && !ch.left && !ch.right) ); // all or nothing - set_voice( this, i, ch.center ); - } - } -} - -void Sound_set_tempo( struct Ay_Emu *this, int t ) -{ - require( this->sample_rate ); // sample rate must be set first - int const min = (int)(FP_ONE_TEMPO*0.02); - int const max = (int)(FP_ONE_TEMPO*4.00); - if ( t < min ) t = min; - if ( t > max ) t = max; - this->tempo = t; - - int p = spectrum_period; - if ( this->clock_rate_ != spectrum_clock ) - p = this->clock_rate_ / 50; - - this->play_period = (blip_time_t) ((p * FP_ONE_TEMPO) / t); -} - -blargg_err_t Ay_start_track( struct Ay_Emu *this, int track ) -{ - clear_track_vars( this ); - - // Remap track if playlist available - if ( this->m3u.size > 0 ) { - struct entry_t* e = &this->m3u.entries[track]; - track = e->track; - } - - this->current_track = track; - Buffer_clear( &this->stereo_buf ); - - byte* const mem = this->mem.ram; - - memset( mem + 0x0000, 0xC9, 0x100 ); // fill RST vectors with RET - memset( mem + 0x0100, 0xFF, 0x4000 - 0x100 ); - memset( mem + ram_addr, 0x00, mem_size - ram_addr ); - - // locate data blocks - byte const* const data = get_data( &this->file, this->file.tracks + track * 4 + 2, 14 ); - if ( !data ) - return "file data missing"; - - byte const* const more_data = get_data( &this->file, data + 10, 6 ); - if ( !more_data ) - return "file data missing"; - - byte const* blocks = get_data( &this->file, data + 12, 8 ); - if ( !blocks ) - return "file data missing"; - - // initial addresses - unsigned addr = get_be16( blocks ); - if ( !addr ) - return "file data missing"; - - unsigned init = get_be16( more_data + 2 ); - if ( !init ) - init = addr; - - // copy blocks into memory - do - { - blocks += 2; - unsigned len = get_be16( blocks ); blocks += 2; - if ( addr + len > mem_size ) - { - /* warning( "Bad data block size" ); */ - len = mem_size - addr; - } - check( len ); - byte const* in = get_data( &this->file, blocks, 0 ); blocks += 2; - if ( len > (unsigned) (this->file.end - in) ) - { - /* warning( "File data missing" ); */ - len = this->file.end - in; - } - - memcpy( mem + addr, in, len ); - - if ( this->file.end - blocks < 8 ) - { - /* warning( "File data missing" ); */ - break; - } - } - while ( (addr = get_be16( blocks )) != 0 ); - - // copy and configure driver - static byte const passive [] = { - 0xF3, // DI - 0xCD, 0, 0, // CALL init - 0xED, 0x5E, // LOOP: IM 2 - 0xFB, // EI - 0x76, // HALT - 0x18, 0xFA // JR LOOP - }; - static byte const active [] = { - 0xF3, // DI - 0xCD, 0, 0, // CALL init - 0xED, 0x56, // LOOP: IM 1 - 0xFB, // EI - 0x76, // HALT - 0xCD, 0, 0, // CALL play - 0x18, 0xF7 // JR LOOP - }; - memcpy( mem, passive, sizeof passive ); - int const play_addr = get_be16( more_data + 4 ); - if ( play_addr ) - { - memcpy( mem, active, sizeof active ); - mem [ 9] = play_addr; - mem [10] = play_addr >> 8; - } - mem [2] = init; - mem [3] = init >> 8; - - mem [0x38] = 0xFB; // Put EI at interrupt vector (followed by RET) - - // start at spectrum speed - change_clock_rate( this, spectrum_clock ); - Sound_set_tempo( this, this->tempo ); - - struct registers_t r; - memset( &r, 0, sizeof(struct registers_t) ); - - r.sp = get_be16( more_data ); - r.b.a = r.b.b = r.b.d = r.b.h = data [8]; - r.b.flags = r.b.c = r.b.e = r.b.l = data [9]; - r.alt.w = r.w; - r.ix = r.iy = r.w.hl; - - memset( this->mem.padding1, 0xFF, sizeof this->mem.padding1 ); - - int const mirrored = 0x80; // this much is mirrored after end of memory - memset( this->mem.ram + mem_size + mirrored, 0xFF, sizeof this->mem.ram - mem_size - mirrored ); - memcpy( this->mem.ram + mem_size, this->mem.ram, mirrored ); // some code wraps around (ugh) - - Z80_reset( &this->cpu, this->mem.padding1, this->mem.padding1 ); - Z80_map_mem( &this->cpu, 0, mem_size, this->mem.ram, this->mem.ram ); - this->cpu.r = r; - - this->beeper_delta = (int) ((ay_amp_range*4)/5); - this->last_beeper = 0; - this->next_play = this->play_period; - this->spectrum_mode = false; - this->cpc_mode = false; - this->cpc_latch = 0; - set_beeper_output( this, this->beeper_output ); - Ay_apu_reset( &this->apu ); - - // a few tunes rely on channels having tone enabled at the beginning - Ay_apu_write_addr( &this->apu, 7 ); - Ay_apu_write_data( &this->apu, 0, 0x38 ); - - // convert filter times to samples - struct setup_t s = this->tfilter; - s.max_initial *= this->sample_rate * stereo; - #ifdef GME_DISABLE_SILENCE_LOOKAHEAD - s.lookahead = 1; - #endif - track_setup( &this->track_filter, &s ); - - return track_start( &this->track_filter ); -} - -// Tell/Seek - -static int msec_to_samples( int msec, int sample_rate ) -{ - int sec = msec / 1000; - msec -= sec * 1000; - return (sec * sample_rate + msec * sample_rate / 1000) * stereo; -} - -int Track_tell( struct Ay_Emu *this ) -{ - int rate = this->sample_rate * stereo; - int sec = track_sample_count( &this->track_filter ) / rate; - return sec * 1000 + (track_sample_count( &this->track_filter ) - sec * rate) * 1000 / rate; -} - -blargg_err_t Track_seek( struct Ay_Emu *this, int msec ) -{ - int time = msec_to_samples( msec, this->sample_rate ); - if ( time < track_sample_count( &this->track_filter ) ) - RETURN_ERR( Ay_start_track( this, this->current_track ) ); - return Track_skip( this, time - track_sample_count( &this->track_filter ) ); -} - -blargg_err_t skip_( void *emu, int count ) -{ - struct Ay_Emu* this = (struct Ay_Emu*) emu; - - // for long skip, mute sound - const int threshold = 32768; - if ( count > threshold ) - { - int saved_mute = this->mute_mask_; - Sound_mute_voices( this, ~0 ); - - int n = count - threshold/2; - n &= ~(2048-1); // round to multiple of 2048 - count -= n; - RETURN_ERR( skippy_( &this->track_filter, n ) ); - - Sound_mute_voices( this, saved_mute ); - } - - return skippy_( &this->track_filter, count ); -} - -blargg_err_t Track_skip( struct Ay_Emu *this, int count ) -{ - require( this->current_track >= 0 ); // start_track() must have been called already - return track_skip( &this->track_filter, count ); -} - -int Track_get_length( struct Ay_Emu* this, int n ) -{ - int length = 0; - - byte const* track_info = get_data( &this->file, this->file.tracks + n * 4 + 2, 6 ); - if ( track_info ) - length = get_be16( track_info + 4 ) * (1000 / 50); // frames to msec - - if ( (this->m3u.size > 0) && (n < this->m3u.size) ) { - struct entry_t* entry = &this->m3u.entries [n]; - length = entry->length; - } - - if ( length <= 0 ) - length = 120 * 1000; /* 2 minutes */ - - return length; -} - -void Track_set_fade( struct Ay_Emu *this, int start_msec, int length_msec ) -{ - track_set_fade( &this->track_filter, msec_to_samples( start_msec, this->sample_rate ), - length_msec * this->sample_rate / (1000 / stereo) ); -} - -blargg_err_t Ay_play( struct Ay_Emu *this, int out_count, sample_t* out ) -{ - require( this->current_track >= 0 ); - require( out_count % stereo == 0 ); - return track_play( &this->track_filter, out_count, out ); -} - -blargg_err_t play_( void *emu, int count, sample_t* out ) -{ - struct Ay_Emu* this = (struct Ay_Emu*) emu; - - int remain = count; - while ( remain ) - { - Buffer_disable_immediate_removal( &this->stereo_buf ); - remain -= Buffer_read_samples( &this->stereo_buf, &out [count - remain], remain ); - if ( remain ) - { - if ( this->buf_changed_count != Buffer_channels_changed_count( &this->stereo_buf ) ) - { - this->buf_changed_count = Buffer_channels_changed_count( &this->stereo_buf ); - - // Remute voices - Sound_mute_voices( this, this->mute_mask_ ); - } - int msec = Buffer_length( &this->stereo_buf ); - blip_time_t clocks_emulated = msec * this->clock_rate_ / 1000 - 100; - RETURN_ERR( run_clocks( this, &clocks_emulated, msec ) ); - assert( clocks_emulated ); - Buffer_end_frame( &this->stereo_buf, clocks_emulated ); - } - } - return 0; -} diff --git a/apps/codecs/libgme/ay_emu.h b/apps/codecs/libgme/ay_emu.h deleted file mode 100644 index 7334167876..0000000000 --- a/apps/codecs/libgme/ay_emu.h +++ /dev/null @@ -1,169 +0,0 @@ -// Sinclair Spectrum AY music file emulator - -// Game_Music_Emu 0.6-pre -#ifndef AY_EMU_H -#define AY_EMU_H - -#include "blargg_source.h" - -#include "multi_buffer.h" -#include "z80_cpu.h" -#include "ay_apu.h" -#include "m3u_playlist.h" -#include "track_filter.h" - -// 64K memory to load code and data into before starting track. Caller -// must parse the AY file. -enum { mem_size = 0x10000 }; -enum { ram_addr = 0x4000 }; // where official RAM starts - -// AY file header -enum { header_size = 0x14 }; -struct header_t -{ - byte tag [8]; - byte vers; - byte player; - byte unused [2]; - byte author [2]; - byte comment [2]; - byte max_track; - byte first_track; - byte track_info [2]; -}; - -struct file_t { - struct header_t const* header; - byte const* tracks; - byte const* end; // end of file data -}; - -struct mem_t { - uint8_t padding1 [0x100]; - uint8_t ram [mem_size + 0x100]; -}; - -struct Ay_Emu { - struct file_t file; - - struct Blip_Buffer* beeper_output; - int beeper_delta; - int last_beeper; - int beeper_mask; - - addr_t play_addr; - cpu_time_t play_period; - cpu_time_t next_play; - - int cpc_latch; - bool spectrum_mode; - bool cpc_mode; - - // general - int voice_count; - int const* voice_types; - int mute_mask_; - int tempo; - int gain; - - int sample_rate; - - // track-specific - int current_track; - int track_count; - - int clock_rate_; - unsigned buf_changed_count; - - // M3u Playlist - struct M3u_Playlist m3u; - - // large items - struct setup_t tfilter; - struct Track_Filter track_filter; - - struct Ay_Apu apu; - struct Multi_Buffer stereo_buf; // NULL if using custom buffer - struct Z80_Cpu cpu; - struct mem_t mem; -}; - -// Basic functionality (see Gme_File.h for file loading/track info functions) -void Ay_init( struct Ay_Emu* this ); - -blargg_err_t Ay_load_mem( struct Ay_Emu* this, byte const in [], long size ); - -// Set output sample rate. Must be called only once before loading file. -blargg_err_t Ay_set_sample_rate( struct Ay_Emu* this, int sample_rate ); - -// Start a track, where 0 is the first track. Also clears warning string. -blargg_err_t Ay_start_track( struct Ay_Emu* this, int track ); - -// Generate 'count' samples info 'buf'. Output is in stereo. Any emulation -// errors set warning string, and major errors also end track. -blargg_err_t Ay_play( struct Ay_Emu* this, int count, sample_t* buf ); - - -// Track status/control - -// Number of milliseconds (1000 msec = 1 second) played since beginning of track -int Track_tell( struct Ay_Emu* this ); - -// Seek to new time in track. Seeking backwards or far forward can take a while. -blargg_err_t Track_seek( struct Ay_Emu* this, int msec ); - -// Skip n samples -blargg_err_t Track_skip( struct Ay_Emu* this, int n ); - -// Set start time and length of track fade out. Once fade ends track_ended() returns -// true. Fade time can be changed while track is playing. -void Track_set_fade( struct Ay_Emu* this, int start_msec, int length_msec ); - -// True if a track has reached its end -static inline bool Track_ended( struct Ay_Emu* this ) -{ - return track_ended( &this->track_filter ); -} - -// Disables automatic end-of-track detection and skipping of silence at beginning -static inline void Track_ignore_silence( struct Ay_Emu* this, bool disable ) -{ - this->track_filter.silence_ignored_ = disable; -} - -// Get track length in milliseconds -int Track_get_length( struct Ay_Emu* this, int n ); - -// Sound customization - -// Adjust song tempo, where 1.0 = normal, 0.5 = half speed, 2.0 = double speed. -// Track length as returned by track_info() assumes a tempo of 1.0. -void Sound_set_tempo( struct Ay_Emu* this, int t ); - -// Mute/unmute voice i, where voice 0 is first voice -void Sound_mute_voice( struct Ay_Emu* this, int index, bool mute ); - -// Set muting state of all voices at once using a bit mask, where -1 mutes them all, -// 0 unmutes them all, 0x01 mutes just the first voice, etc. -void Sound_mute_voices( struct Ay_Emu* this, int mask ); - -// Change overall output amplitude, where 1.0 results in minimal clamping. -// Must be called before set_sample_rate(). -static inline void Sound_set_gain( struct Ay_Emu* this, int g ) -{ - assert( !this->sample_rate ); // you must set gain before setting sample rate - this->gain = g; -} - -// Emulation (You shouldn't touch these) -void cpu_out( struct Ay_Emu* this, cpu_time_t, addr_t, int data ); -void cpu_out_( struct Ay_Emu* this, cpu_time_t, addr_t, int data ); -bool run_cpu( struct Ay_Emu* this, cpu_time_t end ); - -static inline void disable_beeper( struct Ay_Emu *this ) -{ - this->beeper_mask = 0; - this->last_beeper = 0; -} - -#endif diff --git a/apps/codecs/libgme/blargg_common.h b/apps/codecs/libgme/blargg_common.h deleted file mode 100644 index 74cc227eed..0000000000 --- a/apps/codecs/libgme/blargg_common.h +++ /dev/null @@ -1,160 +0,0 @@ -// Sets up common environment for Shay Green's libraries. -// To change configuration options, modify blargg_config.h, not this file. - -#ifndef BLARGG_COMMON_H -#define BLARGG_COMMON_H - -#include -#include -#include -#include - -#undef BLARGG_COMMON_H -// allow blargg_config.h to #include blargg_common.h -#include "blargg_config.h" -#include "blargg_source.h" -#ifndef BLARGG_COMMON_H -#define BLARGG_COMMON_H - -#if defined(ROCKBOX) -#include "codeclib.h" -#endif - -// common defines -#define FP_ONE_CLOCK (1LL << 12) -#define FP_ONE_TEMPO (1LL << 24) -#define FP_ONE_GAIN (1LL << 24) -#define FP_ONE_VOLUME FP_ONE_GAIN - -// IRAM configuration -#if (CONFIG_CPU == MCF5250) -#define EMU2413_CALC_ICODE - -#elif (CONFIG_CPU == PP5022) || (CONFIG_CPU == PP5024) -#define EMU2413_CALC_ICODE ICODE_ATTR - -#elif defined(CPU_S5L870X) -#define EMU2413_CALC_ICODE - -#else -#define EMU2413_CALC_ICODE - -#endif - -// BLARGG_RESTRICT: equivalent to C99's restrict, where supported -#if __GNUC__ >= 3 || _MSC_VER >= 1100 - #define BLARGG_RESTRICT __restrict -#else - #define BLARGG_RESTRICT -#endif - -// STATIC_CAST(T,expr): Used in place of static_cast (expr) -#ifndef STATIC_CAST - #define STATIC_CAST(T,expr) ((T) (expr)) -#endif - -// blargg_err_t (0 on success, otherwise error string) -#ifndef blargg_err_t - typedef const char* blargg_err_t; -#endif - -#define BLARGG_4CHAR( a, b, c, d ) \ - ((a&0xFF)*0x1000000L + (b&0xFF)*0x10000L + (c&0xFF)*0x100L + (d&0xFF)) - -// BOOST_STATIC_ASSERT( expr ): Generates compile error if expr is 0. -#ifndef BOOST_STATIC_ASSERT - #ifdef _MSC_VER - // MSVC6 (_MSC_VER < 1300) fails for use of __LINE__ when /Zl is specified - #define BOOST_STATIC_ASSERT( expr ) \ - void blargg_failed_( int (*arg) [2 / (int) !!(expr) - 1] ) - #else - // Some other compilers fail when declaring same function multiple times in class, - // so differentiate them by line - #define BOOST_STATIC_ASSERT( expr ) \ - void blargg_failed_( int (*arg) [2 / !!(expr) - 1] [__LINE__] ) - #endif -#endif - -// BLARGG_COMPILER_HAS_BOOL: If 0, provides bool support for old compiler. If 1, -// compiler is assumed to support bool. If undefined, availability is determined. -#ifndef BLARGG_COMPILER_HAS_BOOL - #if defined (__MWERKS__) - #if !__option(bool) - #define BLARGG_COMPILER_HAS_BOOL 0 - #endif - #elif defined (_MSC_VER) - #if _MSC_VER < 1100 - #define BLARGG_COMPILER_HAS_BOOL 0 - #endif - #elif defined (__GNUC__) - // supports bool - #elif __cplusplus < 199711 - #define BLARGG_COMPILER_HAS_BOOL 0 - #endif -#endif -#if defined (BLARGG_COMPILER_HAS_BOOL) && !BLARGG_COMPILER_HAS_BOOL - // If you get errors here, modify your blargg_config.h file - typedef int bool; - static bool true = 1; - static bool false = 0; -#endif - -/* My code depends on int being at least 32 bits. Almost everything these days -uses at least 32-bit ints, so it's hard to even find a system with 16-bit ints -to test with. The issue can't be gotten around by using a suitable blargg_int -everywhere either, because int is often converted to implicitly when doing -arithmetic on smaller types. */ -#if UINT_MAX < 0xFFFFFFFF - #error "int must be at least 32 bits" -#endif - -// int8_t etc. - - -// ROCKBOX: If defined, use for int_8_t etc -#if defined (ROCKBOX) - #include -// HAVE_STDINT_H: If defined, use for int8_t etc. -#elif defined (HAVE_STDINT_H) - #include - #define BOOST - -// HAVE_INTTYPES_H: If defined, use for int8_t etc. -#elif defined (HAVE_INTTYPES_H) - #include - #define BOOST - -#else - #if UCHAR_MAX == 0xFF && SCHAR_MAX == 0x7F - typedef signed char int8_t; - typedef unsigned char uint8_t; - #else - // No suitable 8-bit type available - typedef struct see_blargg_common_h int8_t; - typedef struct see_blargg_common_h uint8_t; - #endif - - #if USHRT_MAX == 0xFFFF - typedef short int16_t; - typedef unsigned short uint16_t; - #else - // No suitable 16-bit type available - typedef struct see_blargg_common_h int16_t; - typedef struct see_blargg_common_h uint16_t; - #endif - - #if ULONG_MAX == 0xFFFFFFFF - typedef long int32_t; - typedef unsigned long uint32_t; - #elif UINT_MAX == 0xFFFFFFFF - typedef int int32_t; - typedef unsigned int uint32_t; - #else - // No suitable 32-bit type available - typedef struct see_blargg_common_h int32_t; - typedef struct see_blargg_common_h uint32_t; - #endif -#endif - -#endif -#endif diff --git a/apps/codecs/libgme/blargg_config.h b/apps/codecs/libgme/blargg_config.h deleted file mode 100644 index 398913d1fe..0000000000 --- a/apps/codecs/libgme/blargg_config.h +++ /dev/null @@ -1,42 +0,0 @@ -// Library configuration. Modify this file as necessary. - -#ifndef BLARGG_CONFIG_H -#define BLARGG_CONFIG_H - -// Uncomment to enable platform-specific optimizations -//#define BLARGG_NONPORTABLE 1 - -// Uncomment if automatic byte-order determination doesn't work -#ifdef ROCKBOX_BIG_ENDIAN - #define BLARGG_BIG_ENDIAN 1 -#endif - -// Uncomment if you get errors in the bool section of blargg_common.h -#define BLARGG_COMPILER_HAS_BOOL 1 - -// Uncomment to use fast gb apu implementation -// #define GB_APU_FAST 1 - -// Uncomment to remove agb emulation support -// #define GB_APU_NO_AGB 1 - -// Uncomment to emulate only nes apu -// #define NSF_EMU_APU_ONLY 1 - -// Uncomment to remove vrc7 apu support -// #define NSF_EMU_NO_VRC7 1 - -// Uncomment to remove fmopl apu support -// #define KSS_EMU_NO_FMOPL 1 - -// To handle undefined reference to assert -#define NDEBUG 1 - -// Use standard config.h if present -#define HAVE_CONFIG_H 1 - -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#endif diff --git a/apps/codecs/libgme/blargg_endian.h b/apps/codecs/libgme/blargg_endian.h deleted file mode 100644 index dce5cb2048..0000000000 --- a/apps/codecs/libgme/blargg_endian.h +++ /dev/null @@ -1,168 +0,0 @@ -// CPU Byte Order Utilities - -// Game_Music_Emu 0.5.2 -#ifndef BLARGG_ENDIAN -#define BLARGG_ENDIAN - -#include "blargg_common.h" - -// BLARGG_CPU_CISC: Defined if CPU has very few general-purpose registers (< 16) -#if defined (_M_IX86) || defined (_M_IA64) || defined (__i486__) || \ - defined (__x86_64__) || defined (__ia64__) || defined (__i386__) - #define BLARGG_CPU_X86 1 - #define BLARGG_CPU_CISC 1 -#endif - -#if defined (__powerpc__) || defined (__ppc__) || defined (__POWERPC__) || defined (__powerc) - #define BLARGG_CPU_POWERPC 1 -#endif - -// BLARGG_BIG_ENDIAN, BLARGG_LITTLE_ENDIAN: Determined automatically, otherwise only -// one may be #defined to 1. Only needed if something actually depends on byte order. -#if !defined (BLARGG_BIG_ENDIAN) && !defined (BLARGG_LITTLE_ENDIAN) -#ifdef __GLIBC__ - // GCC handles this for us - #include - #if __BYTE_ORDER == __LITTLE_ENDIAN - #define BLARGG_LITTLE_ENDIAN 1 - #elif __BYTE_ORDER == __BIG_ENDIAN - #define BLARGG_BIG_ENDIAN 1 - #endif -#else - -#if defined (LSB_FIRST) || defined (__LITTLE_ENDIAN__) || defined (BLARGG_CPU_X86) || \ - (defined (LITTLE_ENDIAN) && LITTLE_ENDIAN+0 != 1234) - #define BLARGG_LITTLE_ENDIAN 1 -#endif - -#if defined (MSB_FIRST) || defined (__BIG_ENDIAN__) || defined (WORDS_BIGENDIAN) || \ - defined (__mips__) || defined (__sparc__) || defined (BLARGG_CPU_POWERPC) || \ - (defined (BIG_ENDIAN) && BIG_ENDIAN+0 != 4321) - #define BLARGG_BIG_ENDIAN 1 -#else - // No endian specified; assume little-endian, since it's most common - #define BLARGG_LITTLE_ENDIAN 1 -#endif -#endif -#endif - -#if defined (BLARGG_LITTLE_ENDIAN) && defined(BLARGG_BIG_ENDIAN) - #undef BLARGG_LITTLE_ENDIAN - #undef BLARGG_BIG_ENDIAN -#endif - -static inline void blargg_verify_byte_order( void ) -{ - #ifndef NDEBUG - #if BLARGG_BIG_ENDIAN - volatile int i = 1; - assert( *(volatile char*) &i == 0 ); - #elif BLARGG_LITTLE_ENDIAN - volatile int i = 1; - assert( *(volatile char*) &i != 0 ); - #endif - #endif -} - -static inline unsigned get_le16( void const* p ) -{ - return (unsigned) ((unsigned char const*) p) [1] << 8 | - (unsigned) ((unsigned char const*) p) [0]; -} - -static inline unsigned get_be16( void const* p ) -{ - return (unsigned) ((unsigned char const*) p) [0] << 8 | - (unsigned) ((unsigned char const*) p) [1]; -} - -static inline unsigned get_le32( void const* p ) -{ - return (unsigned) ((unsigned char const*) p) [3] << 24 | - (unsigned) ((unsigned char const*) p) [2] << 16 | - (unsigned) ((unsigned char const*) p) [1] << 8 | - (unsigned) ((unsigned char const*) p) [0]; -} - -static inline unsigned get_be32( void const* p ) -{ - return (unsigned) ((unsigned char const*) p) [0] << 24 | - (unsigned) ((unsigned char const*) p) [1] << 16 | - (unsigned) ((unsigned char const*) p) [2] << 8 | - (unsigned) ((unsigned char const*) p) [3]; -} - -static inline void set_le16( void* p, unsigned n ) -{ - ((unsigned char*) p) [1] = (unsigned char) (n >> 8); - ((unsigned char*) p) [0] = (unsigned char) n; -} - -static inline void set_be16( void* p, unsigned n ) -{ - ((unsigned char*) p) [0] = (unsigned char) (n >> 8); - ((unsigned char*) p) [1] = (unsigned char) n; -} - -static inline void set_le32( void* p, unsigned n ) -{ - ((unsigned char*) p) [0] = (unsigned char) n; - ((unsigned char*) p) [1] = (unsigned char) (n >> 8); - ((unsigned char*) p) [2] = (unsigned char) (n >> 16); - ((unsigned char*) p) [3] = (unsigned char) (n >> 24); -} - -static inline void set_be32( void* p, unsigned n ) -{ - ((unsigned char*) p) [3] = (unsigned char) n; - ((unsigned char*) p) [2] = (unsigned char) (n >> 8); - ((unsigned char*) p) [1] = (unsigned char) (n >> 16); - ((unsigned char*) p) [0] = (unsigned char) (n >> 24); -} - -#if defined(BLARGG_NONPORTABLE) - // Optimized implementation if byte order is known - #if defined(BLARGG_LITTLE_ENDIAN) - #define GET_LE16( addr ) (*(BOOST::uint16_t*) (addr)) - #define GET_LE32( addr ) (*(BOOST::uint32_t*) (addr)) - #define SET_LE16( addr, data ) (void) (*(BOOST::uint16_t*) (addr) = (data)) - #define SET_LE32( addr, data ) (void) (*(BOOST::uint32_t*) (addr) = (data)) - #elif defined(BLARGG_BIG_ENDIAN) - #define GET_BE16( addr ) (*(BOOST::uint16_t*) (addr)) - #define GET_BE32( addr ) (*(BOOST::uint32_t*) (addr)) - #define SET_BE16( addr, data ) (void) (*(BOOST::uint16_t*) (addr) = (data)) - #define SET_BE32( addr, data ) (void) (*(BOOST::uint32_t*) (addr) = (data)) - #endif - - #if defined(BLARGG_CPU_POWERPC) && defined (__MWERKS__) - // PowerPC has special byte-reversed instructions - // to do: assumes that PowerPC is running in big-endian mode - // to do: implement for other compilers which don't support these macros - #define GET_LE16( addr ) (__lhbrx( (addr), 0 )) - #define GET_LE32( addr ) (__lwbrx( (addr), 0 )) - #define SET_LE16( addr, data ) (__sthbrx( (data), (addr), 0 )) - #define SET_LE32( addr, data ) (__stwbrx( (data), (addr), 0 )) - #endif -#endif - -#ifndef GET_LE16 - #define GET_LE16( addr ) get_le16( addr ) - #define SET_LE16( addr, data ) set_le16( addr, data ) -#endif - -#ifndef GET_LE32 - #define GET_LE32( addr ) get_le32( addr ) - #define SET_LE32( addr, data ) set_le32( addr, data ) -#endif - -#ifndef GET_BE16 - #define GET_BE16( addr ) get_be16( addr ) - #define SET_BE16( addr, data ) set_be16( addr, data ) -#endif - -#ifndef GET_BE32 - #define GET_BE32( addr ) get_be32( addr ) - #define SET_BE32( addr, data ) set_be32( addr, data ) -#endif - -#endif diff --git a/apps/codecs/libgme/blargg_source.h b/apps/codecs/libgme/blargg_source.h deleted file mode 100644 index ab8e1b072b..0000000000 --- a/apps/codecs/libgme/blargg_source.h +++ /dev/null @@ -1,76 +0,0 @@ -// Included at the beginning of library source files, after all other #include lines -#ifndef BLARGG_SOURCE_H -#define BLARGG_SOURCE_H - -// If debugging is enabled and expr is false, abort program. Meant for checking -// caller-supplied parameters and operations that are outside the control of the -// module. A failed requirement indicates a bug outside the module. -// void require( bool expr ); -#if defined(ROCKBOX) -#undef assert -#define assert( expr ) -#undef require -#define require( expr ) -#else -#undef require -#define require( expr ) assert( expr ) -#endif - -// Like printf() except output goes to debug log file. Might be defined to do -// nothing (not even evaluate its arguments). -// void dprintf( const char* format, ... ); -#if defined(ROCKBOX) -#define dprintf DEBUGF -#else -static inline void blargg_dprintf_( const char* fmt, ... ) { } -#undef dprintf -#define dprintf (1) ? (void) 0 : blargg_dprintf_ -#endif - -// If enabled, evaluate expr and if false, make debug log entry with source file -// and line. Meant for finding situations that should be examined further, but that -// don't indicate a problem. In all cases, execution continues normally. -#undef check -#define check( expr ) ((void) 0) - -/* If expr yields non-NULL error string, returns it from current function, -otherwise continues normally. */ -#undef RETURN_ERR -#define RETURN_ERR( expr ) \ - do {\ - blargg_err_t blargg_return_err_ = (expr);\ - if ( blargg_return_err_ )\ - return blargg_return_err_;\ - } while ( 0 ) - -/* If ptr is NULL, returns out-of-memory error, otherwise continues normally. */ -#undef CHECK_ALLOC -#define CHECK_ALLOC( ptr ) \ - do {\ - if ( !(ptr) )\ - return "Out of memory";\ - } while ( 0 ) - -#ifndef max - #define max(a,b) (((a) > (b)) ? (a) : (b)) -#endif - -#ifndef min - #define min(a,b) (((a) < (b)) ? (a) : (b)) -#endif - -// typedef unsigned char byte; -typedef unsigned char blargg_byte; -#undef byte -#define byte blargg_byte - -// deprecated -#define BLARGG_CHECK_ALLOC CHECK_ALLOC -#define BLARGG_RETURN_ERR RETURN_ERR - -// BLARGG_SOURCE_BEGIN: If defined, #included, allowing redefition of dprintf and check -#ifdef BLARGG_SOURCE_BEGIN - #include BLARGG_SOURCE_BEGIN -#endif - -#endif diff --git a/apps/codecs/libgme/blip_buffer.c b/apps/codecs/libgme/blip_buffer.c deleted file mode 100644 index ba0a6558d2..0000000000 --- a/apps/codecs/libgme/blip_buffer.c +++ /dev/null @@ -1,225 +0,0 @@ -// Blip_Buffer 0.4.1. http://www.slack.net/~ant/ - -#include "blip_buffer.h" - -#include -#include -#include -#include - -/* Copyright (C) 2003-2006 Shay Green. This module is free software; you -can redistribute it and/or modify it under the terms of the GNU Lesser -General Public License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. This -module is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more -details. You should have received a copy of the GNU Lesser General Public -License along with this module; if not, write to the Free Software Foundation, -Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ - -#include "blargg_source.h" - -void Blip_init( struct Blip_Buffer* this ) -{ - this->factor_ = UINT_MAX/2 + 1;; - this->buffer_center_ = NULL; - this->buffer_size_ = 0; - this->sample_rate_ = 0; - this->bass_shift_ = 0; - this->clock_rate_ = 0; - this->bass_freq_ = 16; - this->length_ = 0; - - // assumptions code makes about implementation-defined features - #ifndef NDEBUG - // right shift of negative value preserves sign - buf_t_ i = -0x7FFFFFFE; - assert( (i >> 1) == -0x3FFFFFFF ); - - // casting to short truncates to 16 bits and sign-extends - i = 0x18000; - assert( (short) i == -0x8000 ); - #endif - - Blip_clear( this ); -} - -void Blip_clear( struct Blip_Buffer* this ) -{ - bool const entire_buffer = true; - - this->offset_ = 0; - this->reader_accum_ = 0; - this->modified = false; - - if ( this->buffer_ ) - { - int count = (entire_buffer ? this->buffer_size_ : Blip_samples_avail( this )); - memset( this->buffer_, 0, (count + blip_buffer_extra_) * sizeof (delta_t) ); - } -} - -blargg_err_t Blip_set_sample_rate( struct Blip_Buffer* this, int new_rate, int msec ) -{ - // Limit to maximum size that resampled time can represent - int max_size = (((blip_resampled_time_t) -1) >> BLIP_BUFFER_ACCURACY) - - blip_buffer_extra_ - 64; // TODO: -64 isn't needed - int new_size = (new_rate * (msec + 1) + 999) / 1000; - if ( new_size > max_size ) - new_size = max_size; - - // Resize buffer - if ( this->buffer_size_ != new_size ) { - this->buffer_center_ = this->buffer_ + BLIP_MAX_QUALITY/2; - this->buffer_size_ = new_size; - } - - // update things based on the sample rate - this->sample_rate_ = new_rate; - this->length_ = new_size * 1000 / new_rate - 1; - if ( this->clock_rate_ ) - Blip_set_clock_rate( this, this->clock_rate_ ); - Blip_bass_freq( this, this->bass_freq_ ); - - Blip_clear( this ); - - return 0; // success -} - -blip_resampled_time_t Blip_clock_rate_factor( struct Blip_Buffer* this, int rate ) -{ - int factor = (int) ( this->sample_rate_ * (1LL << BLIP_BUFFER_ACCURACY) / rate); - assert( factor > 0 || !this->sample_rate_ ); // fails if clock/output ratio is too large - return (blip_resampled_time_t) factor; -} - -void Blip_bass_freq( struct Blip_Buffer* this, int freq ) -{ - this->bass_freq_ = freq; - int shift = 31; - if ( freq > 0 && this->sample_rate_ ) - { - shift = 13; - int f = (freq << 16) / this->sample_rate_; - while ( (f >>= 1) && --shift ) { } - } - this->bass_shift_ = shift; -} - -void Blip_end_frame( struct Blip_Buffer* this, blip_time_t t ) -{ - this->offset_ += t * this->factor_; - assert( Blip_samples_avail( this ) <= (int) this->buffer_size_ ); // time outside buffer length -} - -int Blip_count_samples( struct Blip_Buffer* this, blip_time_t t ) -{ - blip_resampled_time_t last_sample = Blip_resampled_time( this, t ) >> BLIP_BUFFER_ACCURACY; - blip_resampled_time_t first_sample = this->offset_ >> BLIP_BUFFER_ACCURACY; - return (int) (last_sample - first_sample); -} - -blip_time_t Blip_count_clocks( struct Blip_Buffer* this, int count ) -{ - if ( count > this->buffer_size_ ) - count = this->buffer_size_; - blip_resampled_time_t time = (blip_resampled_time_t) count << BLIP_BUFFER_ACCURACY; - return (blip_time_t) ((time - this->offset_ + this->factor_ - 1) / this->factor_); -} - -void Blip_remove_samples( struct Blip_Buffer* this, int count ) -{ - if ( count ) - { - Blip_remove_silence( this, count ); - - // copy remaining samples to beginning and clear old samples - int remain = Blip_samples_avail( this ) + blip_buffer_extra_; - memmove( this->buffer_, this->buffer_ + count, remain * sizeof *this->buffer_ ); - memset( this->buffer_ + remain, 0, count * sizeof *this->buffer_ ); - } -} - -int Blip_read_samples( struct Blip_Buffer* this, blip_sample_t out_ [], int max_samples, bool stereo ) -{ - int count = Blip_samples_avail( this ); - if ( count > max_samples ) - count = max_samples; - - if ( count ) - { - int const bass = this->bass_shift_; - delta_t const* reader = this->buffer_ + count; - int reader_sum = this->reader_accum_; - - blip_sample_t* BLARGG_RESTRICT out = out_ + count; - if ( stereo ) - out += count; - int offset = -count; - - if ( !stereo ) - { - do - { - int s = reader_sum >> delta_bits; - - reader_sum -= reader_sum >> bass; - reader_sum += reader [offset]; - - BLIP_CLAMP( s, s ); - out [offset] = (blip_sample_t) s; - } - while ( ++offset ); - } - else - { - do - { - int s = reader_sum >> delta_bits; - - reader_sum -= reader_sum >> bass; - reader_sum += reader [offset]; - - BLIP_CLAMP( s, s ); - out [offset * 2] = (blip_sample_t) s; - } - while ( ++offset ); - } - - this->reader_accum_ = reader_sum; - - Blip_remove_samples( this, count ); - } - return count; -} - -void Blip_mix_samples( struct Blip_Buffer* this, blip_sample_t const in [], int count ) -{ - delta_t* out = this->buffer_center_ + (this->offset_ >> BLIP_BUFFER_ACCURACY); - - int const sample_shift = blip_sample_bits - 16; - int prev = 0; - while ( --count >= 0 ) - { - int s = *in++ << sample_shift; - *out += s - prev; - prev = s; - ++out; - } - *out -= prev; -} - -// Blip_Synth - -void volume_unit( struct Blip_Synth* this, int new_unit ) -{ - this->delta_factor = (int) (new_unit * (1LL << blip_sample_bits) / FP_ONE_VOLUME); -} - -void Synth_init( struct Blip_Synth* this ) -{ - this->buf = 0; - this->last_amp = 0; - this->delta_factor = 0; -} diff --git a/apps/codecs/libgme/blip_buffer.h b/apps/codecs/libgme/blip_buffer.h deleted file mode 100644 index 5fe1f4b9c6..0000000000 --- a/apps/codecs/libgme/blip_buffer.h +++ /dev/null @@ -1,335 +0,0 @@ -// Band-limited sound synthesis buffer - -// Blip_Buffer 0.4.1 -#ifndef BLIP_BUFFER_H -#define BLIP_BUFFER_H - -#include "blargg_common.h" - -typedef unsigned blip_resampled_time_t; -typedef int blip_time_t; -typedef int clocks_t; - -// Output samples are 16-bit signed, with a range of -32768 to 32767 -typedef short blip_sample_t; - -static int const blip_default_length = 1000 / 4; // Default Blip_Buffer length (1/4 second) - -#ifndef BLIP_MAX_QUALITY - #define BLIP_MAX_QUALITY 2 -#endif - -#ifndef BLIP_BUFFER_ACCURACY - #define BLIP_BUFFER_ACCURACY 16 -#endif - -// linear interpolation needs 8 bits -#ifndef BLIP_PHASE_BITS - #define BLIP_PHASE_BITS 8 -#endif - -static int const blip_res = 1 << BLIP_PHASE_BITS; -static int const blip_buffer_extra_ = BLIP_MAX_QUALITY + 2; - -// Properties of fixed-point sample position -typedef unsigned ufixed_t; // unsigned for more range, optimized shifts -enum { fixed_bits = BLIP_BUFFER_ACCURACY }; // bits in fraction -enum { fixed_unit = 1 << fixed_bits }; // 1.0 samples - -// Deltas in buffer are fixed-point with this many fraction bits. -// Less than 16 for extra range. -enum { delta_bits = 14 }; - -// Pointer to first committed delta sample -typedef int delta_t; - -// Maximun buffer size (48Khz, 50 ms) -enum { blip_buffer_max = 2466 }; - -struct Blip_Buffer { - unsigned factor_; - ufixed_t offset_; - delta_t* buffer_center_; - int buffer_size_; - int reader_accum_; - int bass_shift_; - int bass_freq_; - int sample_rate_; - int clock_rate_; - int length_; - bool modified; - - delta_t buffer_ [blip_buffer_max]; -}; - -// Blip_Buffer_ implementation -static inline ufixed_t to_fixed( struct Blip_Buffer *this, clocks_t t ) -{ - return t * this->factor_ + this->offset_; -} - -static inline delta_t* delta_at( struct Blip_Buffer *this, ufixed_t f ) -{ - assert( (f >> fixed_bits) < (unsigned) this->buffer_size_ ); - return this->buffer_center_ + (f >> fixed_bits); -} - -// Number of samples available for reading with read_samples() -static inline int Blip_samples_avail( struct Blip_Buffer* this ) -{ - return (int) (this->offset_ >> BLIP_BUFFER_ACCURACY); -} - -static inline void Blip_remove_silence( struct Blip_Buffer* this, int count ) -{ - assert( count <= Blip_samples_avail( this ) ); // tried to remove more samples than available - this->offset_ -= (blip_resampled_time_t) count << BLIP_BUFFER_ACCURACY; -} - -// Initializes Blip_Buffer structure -void Blip_init( struct Blip_Buffer* this ); - -// Sets output sample rate and resizes and clears sample buffer -blargg_err_t Blip_set_sample_rate( struct Blip_Buffer* this, int samples_per_sec, int msec_length ); - -// Current output sample rate -static inline int Blip_sample_rate( struct Blip_Buffer* this ) -{ - return this->sample_rate_; -} - -// Sets number of source time units per second -blip_resampled_time_t Blip_clock_rate_factor( struct Blip_Buffer* this, int clock_rate ); -static inline void Blip_set_clock_rate( struct Blip_Buffer* this, int clocks_per_sec ) -{ - this->factor_ = Blip_clock_rate_factor( this, this->clock_rate_ = clocks_per_sec ); -} - -// Number of source time units per second -static inline int Blip_clock_rate( struct Blip_Buffer* this ) -{ - return this->clock_rate_; -} - -static inline int Blip_length( struct Blip_Buffer* this ) -{ - return this->length_; -} - -// Clears buffer and removes all samples -void Blip_clear( struct Blip_Buffer* this ); - -// Use Blip_Synth to add waveform to buffer - -// Resamples to time t, then subtracts t from current time. Appends result of resampling -// to buffer for reading. -void Blip_end_frame( struct Blip_Buffer* this, blip_time_t time ) ICODE_ATTR; - - -// Reads at most n samples to out [0 to n-1] and returns number actually read. If stereo -// is true, writes to out [0], out [2], out [4] etc. instead. -int Blip_read_samples( struct Blip_Buffer* this, blip_sample_t out [], int n, bool stereo ) ICODE_ATTR; - - -// More features - -// Sets flag that tells some Multi_Buffer types that sound was added to buffer, -// so they know that it needs to be mixed in. Only needs to be called once -// per time frame that sound was added. Not needed if not using Multi_Buffer. -static inline void Blip_set_modified( struct Blip_Buffer* this ) { this->modified = true; } - -// Set frequency high-pass filter frequency, where higher values reduce bass more -void Blip_bass_freq( struct Blip_Buffer* this, int frequency ); - - -// Low-level features - -// Removes the first n samples -void Blip_remove_samples( struct Blip_Buffer* this, int n ) ICODE_ATTR; - -// Returns number of clocks needed until n samples will be available. -// If buffer cannot even hold n samples, returns number of clocks -// until buffer becomes full. -blip_time_t Blip_count_clocks( struct Blip_Buffer* this, int count ) ICODE_ATTR; - -// Number of samples that should be mixed before calling Blip_end_frame( t ) -int Blip_count_samples( struct Blip_Buffer* this, blip_time_t t ) ICODE_ATTR; - -// Mixes n samples into buffer -void Blip_mix_samples( struct Blip_Buffer* this, blip_sample_t const in [], int n ) ICODE_ATTR; - - -// Resampled time (sorry, poor documentation right now) - -// Resampled time is fixed-point, in terms of output samples. - -// Converts clock count to resampled time -static inline blip_resampled_time_t Blip_resampled_duration( struct Blip_Buffer* this, int t ) -{ - return t * this->factor_; -} - -// Converts clock time since beginning of current time frame to resampled time -static inline blip_resampled_time_t Blip_resampled_time( struct Blip_Buffer* this, blip_time_t t ) -{ - return t * this->factor_ + this->offset_; -} - - -// Range specifies the greatest expected change in amplitude. Calculate it -// by finding the difference between the maximum and minimum expected -// amplitudes (max - min). - -typedef char coeff_t; - -struct Blip_Synth { - int delta_factor; - int last_amp; - struct Blip_Buffer* buf; -}; - -// Blip_Synth_ -void volume_unit( struct Blip_Synth* this, int new_unit ); - -// Initializes Blip_Synth structure -void Synth_init( struct Blip_Synth* this ); - -// Sets volume of amplitude delta unit -static inline void Synth_volume( struct Blip_Synth* this, int v ) -{ - volume_unit( this, v ); // new_unit = 1 / range * v -} - - -// Low-level interface - -// (in >> sh & mask) * mul -#define BLIP_SH_AND_MUL( in, sh, mask, mul ) \ -((int) (in) / ((1U << (sh)) / (mul)) & (unsigned) ((mask) * (mul))) - -// (T*) ptr + (off >> sh) -#define BLIP_PTR_OFF_SH( T, ptr, off, sh ) \ - ((T*) (BLIP_SH_AND_MUL( off, sh, -1, sizeof (T) ) + (char*) (ptr))) - -// Works directly in terms of fractional output samples. Use resampled time functions in Blip_Buffer -// to convert clock counts to resampled time. -static inline void Synth_offset_resampled( struct Blip_Synth* this, blip_resampled_time_t time, - int delta, struct Blip_Buffer* blip_buf ) -{ - int const half_width = 1; - - delta_t* BLARGG_RESTRICT buf = delta_at( blip_buf, time ); - delta *= this->delta_factor; - - int const phase_shift = BLIP_BUFFER_ACCURACY - BLIP_PHASE_BITS; - int const phase = (half_width & (half_width - 1)) ? - (int) BLIP_SH_AND_MUL( time, phase_shift, blip_res - 1, sizeof (coeff_t) ) * half_width : - (int) BLIP_SH_AND_MUL( time, phase_shift, blip_res - 1, sizeof (coeff_t) * half_width ); - - int left = buf [0] + delta; - - // Kind of crappy, but doing shift after multiply results in overflow. - // Alternate way of delaying multiply by delta_factor results in worse - // sub-sample resolution. - int right = (delta >> BLIP_PHASE_BITS) * phase; - #ifdef BLIP_BUFFER_NOINTERP - // TODO: remove? (just a hack to see how it sounds) - right = 0; - #endif - left -= right; - right += buf [1]; - - buf [0] = left; - buf [1] = right; -} - -// Update amplitude of waveform at given time. Using this requires a separate -// Blip_Synth for each waveform. -static inline void Synth_update( struct Blip_Synth* this, blip_time_t t, int amp ) -{ - int delta = amp - this->last_amp; - this->last_amp = amp; - Synth_offset_resampled( this, to_fixed(this->buf, t), delta, this->buf ); -} - -// Adds amplitude transition at time t. Delta can be positive or negative. -// The actual change in amplitude is delta * volume. -static inline void Synth_offset_inline( struct Blip_Synth* this, blip_time_t t, int delta, struct Blip_Buffer* buf ) -{ - Synth_offset_resampled( this, to_fixed(buf, t), delta, buf ); -} - -#define Synth_offset( synth, time, delta, buf ) Synth_offset_inline( synth, time, delta, buf ) - -// Number of bits in raw sample that covers normal output range. Less than 32 bits to give -// extra amplitude range. That is, -// +1 << (blip_sample_bits-1) = +1.0 -// -1 << (blip_sample_bits-1) = -1.0 -static int const blip_sample_bits = 30; - -// Optimized reading from Blip_Buffer, for use in custom sample output - -// Begin reading from buffer. Name should be unique to the current block. -#define BLIP_READER_BEGIN( name, blip_buffer ) \ - const delta_t* BLARGG_RESTRICT name##_reader_buf = (blip_buffer).buffer_;\ - int name##_reader_accum = (blip_buffer).reader_accum_ - -// Get value to pass to BLIP_READER_NEXT() -#define BLIP_READER_BASS( blip_buffer ) ((blip_buffer).bass_shift_) - -// Constant value to use instead of BLIP_READER_BASS(), for slightly more optimal -// code at the cost of having no bass_freq() functionality -static int const blip_reader_default_bass = 9; - -// Current sample -#define BLIP_READER_READ( name ) (name##_reader_accum >> (blip_sample_bits - 16)) - -// Current raw sample in full internal resolution -#define BLIP_READER_READ_RAW( name ) (name##_reader_accum) - -// Advance to next sample -#define BLIP_READER_NEXT( name, bass ) \ - (void) (name##_reader_accum += *name##_reader_buf++ - (name##_reader_accum >> (bass))) - -// End reading samples from buffer. The number of samples read must now be removed -// using Blip_remove_samples(). -#define BLIP_READER_END( name, blip_buffer ) \ - (void) ((blip_buffer).reader_accum_ = name##_reader_accum) - -#define BLIP_READER_ADJ_( name, offset ) (name##_reader_buf += offset) - -#define BLIP_READER_NEXT_IDX_( name, bass, idx ) {\ - name##_reader_accum -= name##_reader_accum >> (bass);\ - name##_reader_accum += name##_reader_buf [(idx)];\ -} - -#define BLIP_READER_NEXT_RAW_IDX_( name, bass, idx ) {\ - name##_reader_accum -= name##_reader_accum >> (bass);\ - name##_reader_accum +=\ - *(delta_t const*) ((char const*) name##_reader_buf + (idx));\ -} - -//// BLIP_CLAMP - -#if defined(CPU_ARM) && (ARM_ARCH >= 6) - #define BLIP_CLAMP( sample, out ) \ - ({ \ - asm ("ssat %0, #16, %1" \ - : "=r" ( out ) : "r"( sample ) ); \ - out; \ - }) -#else - #if defined (_M_IX86) || defined (_M_IA64) || defined (__i486__) || \ - defined (__x86_64__) || defined (__ia64__) || defined (__i386__) - #define BLIP_X86 1 - #define BLIP_CLAMP_( in ) in < -0x8000 || 0x7FFF < in - #else - #define BLIP_CLAMP_( in ) (blip_sample_t) in != in - #endif - - // Clamp sample to blip_sample_t range - #define BLIP_CLAMP( sample, out )\ - { if ( BLIP_CLAMP_( (sample) ) ) (out) = ((sample) >> 31) ^ 0x7FFF; } -#endif - -#endif diff --git a/apps/codecs/libgme/emu2413.c b/apps/codecs/libgme/emu2413.c deleted file mode 100644 index 01075821cb..0000000000 --- a/apps/codecs/libgme/emu2413.c +++ /dev/null @@ -1,1981 +0,0 @@ -/*********************************************************************************** - - emu2413.c -- YM2413 emulator written by Mitsutaka Okazaki 2001 - - 2001 01-08 : Version 0.10 -- 1st version. - 2001 01-15 : Version 0.20 -- semi-public version. - 2001 01-16 : Version 0.30 -- 1st public version. - 2001 01-17 : Version 0.31 -- Fixed bassdrum problem. - : Version 0.32 -- LPF implemented. - 2001 01-18 : Version 0.33 -- Fixed the drum problem, refine the mix-down method. - -- Fixed the LFO bug. - 2001 01-24 : Version 0.35 -- Fixed the drum problem, - support undocumented EG behavior. - 2001 02-02 : Version 0.38 -- Improved the performance. - Fixed the hi-hat and cymbal model. - Fixed the default percussive datas. - Noise reduction. - Fixed the feedback problem. - 2001 03-03 : Version 0.39 -- Fixed some drum bugs. - Improved the performance. - 2001 03-04 : Version 0.40 -- Improved the feedback. - Change the default table size. - Clock and Rate can be changed during play. - 2001 06-24 : Version 0.50 -- Improved the hi-hat and the cymbal tone. - Added VRC7 patch (OPLL_reset_patch is changed). - Fixed OPLL_reset() bug. - Added OPLL_setMask, OPLL_getMask and OPLL_toggleMask. - Added OPLL_writeIO. - 2001 09-28 : Version 0.51 -- Removed the noise table. - 2002 01-28 : Version 0.52 -- Added Stereo mode. - 2002 02-07 : Version 0.53 -- Fixed some drum bugs. - 2002 02-20 : Version 0.54 -- Added the best quality mode. - 2002 03-02 : Version 0.55 -- Removed OPLL_init & OPLL_close. - 2002 05-30 : Version 0.60 -- Fixed HH&CYM generator and all voice datas. - 2004 04-10 : Version 0.61 -- Added YMF281B tone (defined by Chabin). - - 2011 03-22 : --------------- Modified by gama to use precalculated tables. - - References: - fmopl.c -- 1999,2000 written by Tatsuyuki Satoh (MAME development). - fmopl.c(fixed) -- (C) 2002 Jarek Burczynski. - s_opl.c -- 2001 written by Mamiya (NEZplug development). - fmgen.cpp -- 1999,2000 written by cisc. - fmpac.ill -- 2000 created by NARUTO. - MSX-Datapack - YMU757 data sheet - YM2143 data sheet - -**************************************************************************************/ -#include -#include -#include -#include -#include "emu2413.h" - -#include "emutables.h" -#if !defined(ROCKBOX) - #define EMU2413_CALCUL_TABLES -#else - #define EMU2413_COMPACTION - #include "emutables.h" -#endif - -#if defined(EMU2413_COMPACTION) && !defined(ROCKBOX) -#define OPLL_TONE_NUM 1 -static unsigned char default_inst[OPLL_TONE_NUM][(16 + 3) * 16] = { - { -#include "2413tone.h" - } -}; -#else -#define OPLL_TONE_NUM 3 -static unsigned char default_inst[OPLL_TONE_NUM][(16 + 3) * 16] = { - { -#include "2413tone.h" - }, - { -#include "vrc7tone.h" - }, - { -#include "281btone.h" - } -}; -#endif - -/* Size of Sintable ( 8 -- 18 can be used. 9 recommended.) */ -#define PG_BITS 9 -#define PG_WIDTH (1<>(b)) - -/* Leave the lower b bit(s). */ -#define LOWBITS(c,b) ((c)&((1<<(b))-1)) - -/* Expand x which is s bits to d bits. */ -#define EXPAND_BITS(x,s,d) ((x)<<((d)-(s))) - -/* Expand x which is s bits to d bits and fill expanded bits '1' */ -#define EXPAND_BITS_X(x,s,d) (((x)<<((d)-(s)))|((1<<((d)-(s)))-1)) - -/* Adjust envelope speed which depends on sampling rate. */ -#define RATE_ADJUST(x) (rate==49716?(e_uint32)x:(e_uint32)(((long long)(x)*clk/rate+36)/72)) - -#define MOD(o,x) (&(o)->slot[(x)<<1]) -#define CAR(o,x) (&(o)->slot[((x)<<1)|1]) - -#define BIT(s,b) (((s)>>(b))&1) - -/* Input clock */ -static e_uint32 clk = 844451141; -/* Sampling rate */ -static e_uint32 rate = 3354932; - -/* WaveTable for each envelope amp */ -static e_uint16 fullsintable[PG_WIDTH]; -static e_uint16 halfsintable[PG_WIDTH]; - -static e_uint16 *waveform[2] = { fullsintable, halfsintable }; - -/* LFO Table */ -#ifdef EMU2413_CALCUL_TABLES - static e_int32 pmtable[PM_PG_WIDTH]; - static e_int32 amtable[AM_PG_WIDTH]; - #define PMTABLE(x) pmtable[x] - #define AMTABLE(x) amtable[x] -#else - #define PMTABLE(x) (e_int32)pm_coeff[x] - #if (PM_PG_WIDTH != 256) - #error PM_PG_WIDTH must be set to 256 if EMU2413_CALCUL_TABLES is not defined - #endif - #define AMTABLE(x) (e_int32)am_coeff[x] - #if (AM_PG_WIDTH != 256) - #error AM_PG_WIDTH must be set to 256 if EMU2413_CALCUL_TABLES is not defined - #endif -#endif - -/* Phase delta for LFO */ -static e_uint32 pm_dphase; -static e_uint32 am_dphase; - -/* dB to Liner table */ -static e_int16 DB2LIN_TABLE[(DB_MUTE + DB_MUTE) * 2]; - -/* Liner to Log curve conversion table (for Attack rate). */ -#ifdef EMU2413_CALCUL_TABLES - static e_uint16 ar_adjust_table[1 << EG_BITS]; - #define AR_ADJUST_TABLE(x) ar_adjust_table[x] -#else - #define AR_ADJUST_TABLE(x) ar_adjust_coeff[x] - #if (EG_BITS != 7) - #error EG_BITS must be set to 7 if EMU2413_CALCUL_TABLES is not defined - #endif -#endif - -/* Empty voice data */ -static OPLL_PATCH null_patch = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; - -/* Basic voice Data */ -static OPLL_PATCH default_patch[OPLL_TONE_NUM][(16 + 3) * 2]; - -/* Definition of envelope mode */ -enum OPLL_EG_STATE -{ READY, ATTACK, DECAY, SUSHOLD, SUSTINE, RELEASE, SETTLE, FINISH }; - -/* Phase incr table for Attack */ -static e_uint32 dphaseARTable[16][16]; -/* Phase incr table for Decay and Release */ -static e_uint32 dphaseDRTable[16][16]; - -/* KSL + TL Table */ -e_uint8 tllTable[16][8][1 << TL_BITS][4]; -static e_int32 rksTable[2][8][2]; - -/* We may not have too much SRAM in rockbox */ -#if !defined(ROCKBOX) -/* Phase incr table for PG */ -static e_uint32 dphaseTable[512][8][16]; -#endif - -/*************************************************** - - Create tables - -****************************************************/ -#ifdef EMU2413_CALCUL_TABLES -INLINE static e_int32 -Min (e_int32 i, e_int32 j) -{ - if (i < j) - return i; - else - return j; -} - -/* Table for AR to LogCurve. */ -static void -makeAdjustTable (void) -{ - e_int32 i; - - ar_adjust_table[0] = (1 << EG_BITS) - 1; - for (i = 1; i < (1<= DB_MUTE) DB2LIN_TABLE[i] = 0; - DB2LIN_TABLE[i + DB_MUTE + DB_MUTE] = (e_int16) (-DB2LIN_TABLE[i]); - } -} - -#ifdef EMU2413_CALCUL_TABLES -/* Liner(+0.0 - +1.0) to dB((1<> (20 - DP_BITS)); -} -#endif - -static void -makeTllTable (void) -{ -/* Multiplication owith 8 to have an integer result. This allows to remove floating point operation. */ -#define dB2(x) (int)((x)*2*8) - - static int kltable[16] = { - dB2 ( 0.000), dB2 ( 9.000), dB2 (12.000), dB2 (13.875), dB2 (15.000), dB2 (16.125), dB2 (16.875), dB2 (17.625), - dB2 (18.000), dB2 (18.750), dB2 (19.125), dB2 (19.500), dB2 (19.875), dB2 (20.250), dB2 (20.625), dB2 (21.000) - }; - - e_int32 tmp; - e_int32 fnum, block, TL, KL; - - for (fnum = 0; fnum < 16; fnum++) - for (block = 0; block < 8; block++) - for (TL = 0; TL < 64; TL++) - for (KL = 0; KL < 4; KL++) - { - if (KL == 0) - { - tllTable[fnum][block][TL][KL] = TL2EG (TL); - } - else - { - tmp = (e_int32) ((kltable[fnum] - dB2 (3.000) * (7 - block))/8); - if (tmp <= 0) - tllTable[fnum][block][TL][KL] = TL2EG (TL); - else - /* tllTable[fnum][block][TL][KL] = (e_uint32) ((tmp >> (3 - KL)) / EG_STEP) + TL2EG (TL); */ - tllTable[fnum][block][TL][KL] = (e_uint32) ((tmp << KL) / (int)(EG_STEP*8)) + TL2EG (TL); - } - } -} - -#ifdef USE_SPEC_ENV_SPEED -static double attacktime[16][4] = { - {0, 0, 0, 0}, - {1730.15, 1400.60, 1153.43, 988.66}, - {865.08, 700.30, 576.72, 494.33}, - {432.54, 350.15, 288.36, 247.16}, - {216.27, 175.07, 144.18, 123.58}, - {108.13, 87.54, 72.09, 61.79}, - {54.07, 43.77, 36.04, 30.90}, - {27.03, 21.88, 18.02, 15.45}, - {13.52, 10.94, 9.01, 7.72}, - {6.76, 5.47, 4.51, 3.86}, - {3.38, 2.74, 2.25, 1.93}, - {1.69, 1.37, 1.13, 0.97}, - {0.84, 0.70, 0.60, 0.54}, - {0.50, 0.42, 0.34, 0.30}, - {0.28, 0.22, 0.18, 0.14}, - {0.00, 0.00, 0.00, 0.00} -}; - -static double decaytime[16][4] = { - {0, 0, 0, 0}, - {20926.60, 16807.20, 14006.00, 12028.60}, - {10463.30, 8403.58, 7002.98, 6014.32}, - {5231.64, 4201.79, 3501.49, 3007.16}, - {2615.82, 2100.89, 1750.75, 1503.58}, - {1307.91, 1050.45, 875.37, 751.79}, - {653.95, 525.22, 437.69, 375.90}, - {326.98, 262.61, 218.84, 187.95}, - {163.49, 131.31, 109.42, 93.97}, - {81.74, 65.65, 54.71, 46.99}, - {40.87, 32.83, 27.36, 23.49}, - {20.44, 16.41, 13.68, 11.75}, - {10.22, 8.21, 6.84, 5.87}, - {5.11, 4.10, 3.42, 2.94}, - {2.55, 2.05, 1.71, 1.47}, - {1.27, 1.27, 1.27, 1.27} -}; -#endif - -/* Rate Table for Attack */ -static void -makeDphaseARTable (void) -{ - e_int32 AR, Rks, RM, RL; - -#ifdef USE_SPEC_ENV_SPEED - e_uint32 attacktable[16][4]; - - for (RM = 0; RM < 16; RM++) - for (RL = 0; RL < 4; RL++) - { - if (RM == 0) - attacktable[RM][RL] = 0; - else if (RM == 15) - attacktable[RM][RL] = EG_DP_WIDTH; - else - attacktable[RM][RL] = (e_uint32) ((double) (1 << EG_DP_BITS) / (attacktime[RM][RL] * 3579545 / 72000)); - - } -#endif - - for (AR = 0; AR < 16; AR++) - for (Rks = 0; Rks < 16; Rks++) - { - RM = AR + (Rks >> 2); - RL = Rks & 3; - if (RM > 15) - RM = 15; - switch (AR) - { - case 0: - dphaseARTable[AR][Rks] = 0; - break; - case 15: - dphaseARTable[AR][Rks] = 0;/*EG_DP_WIDTH;*/ - break; - default: -#ifdef USE_SPEC_ENV_SPEED - dphaseARTable[AR][Rks] = RATE_ADJUST (attacktable[RM][RL]); -#else - dphaseARTable[AR][Rks] = RATE_ADJUST ((3 * (RL + 4) << (RM + 1))); -#endif - break; - } - } -} - -/* Rate Table for Decay and Release */ -static void -makeDphaseDRTable (void) -{ - e_int32 DR, Rks, RM, RL; - -#ifdef USE_SPEC_ENV_SPEED - e_uint32 decaytable[16][4]; - - for (RM = 0; RM < 16; RM++) - for (RL = 0; RL < 4; RL++) - if (RM == 0) - decaytable[RM][RL] = 0; - else - decaytable[RM][RL] = (e_uint32) ((double) (1 << EG_DP_BITS) / (decaytime[RM][RL] * 3579545 / 72000)); -#endif - - for (DR = 0; DR < 16; DR++) - for (Rks = 0; Rks < 16; Rks++) - { - RM = DR + (Rks >> 2); - RL = Rks & 3; - if (RM > 15) - RM = 15; - switch (DR) - { - case 0: - dphaseDRTable[DR][Rks] = 0; - break; - default: -#ifdef USE_SPEC_ENV_SPEED - dphaseDRTable[DR][Rks] = RATE_ADJUST (decaytable[RM][RL]); -#else - dphaseDRTable[DR][Rks] = RATE_ADJUST ((RL + 4) << (RM - 1)); -#endif - break; - } - } -} - -static void -makeRksTable (void) -{ - - e_int32 fnum8, block, KR; - - for (fnum8 = 0; fnum8 < 2; fnum8++) - for (block = 0; block < 8; block++) - for (KR = 0; KR < 2; KR++) - { - if (KR != 0) - rksTable[fnum8][block][KR] = (block << 1) + fnum8; - else - rksTable[fnum8][block][KR] = block >> 1; - } -} - -void -OPLL_dump2patch (const e_uint8 * dump, OPLL_PATCH * patch) -{ - patch[0].AM = (dump[0] >> 7) & 1; - patch[1].AM = (dump[1] >> 7) & 1; - patch[0].PM = (dump[0] >> 6) & 1; - patch[1].PM = (dump[1] >> 6) & 1; - patch[0].EG = (dump[0] >> 5) & 1; - patch[1].EG = (dump[1] >> 5) & 1; - patch[0].KR = (dump[0] >> 4) & 1; - patch[1].KR = (dump[1] >> 4) & 1; - patch[0].ML = (dump[0]) & 15; - patch[1].ML = (dump[1]) & 15; - patch[0].KL = (dump[2] >> 6) & 3; - patch[1].KL = (dump[3] >> 6) & 3; - patch[0].TL = (dump[2]) & 63; - patch[0].FB = (dump[3]) & 7; - patch[0].WF = (dump[3] >> 3) & 1; - patch[1].WF = (dump[3] >> 4) & 1; - patch[0].AR = (dump[4] >> 4) & 15; - patch[1].AR = (dump[5] >> 4) & 15; - patch[0].DR = (dump[4]) & 15; - patch[1].DR = (dump[5]) & 15; - patch[0].SL = (dump[6] >> 4) & 15; - patch[1].SL = (dump[7] >> 4) & 15; - patch[0].RR = (dump[6]) & 15; - patch[1].RR = (dump[7]) & 15; -} - -void -OPLL_getDefaultPatch (e_int32 type, e_int32 num, OPLL_PATCH * patch) -{ - OPLL_dump2patch (default_inst[type] + num * 16, patch); -} - -static void -makeDefaultPatch ( void ) -{ - e_int32 i, j; - - for (i = 0; i < OPLL_TONE_NUM; i++) - for (j = 0; j < 19; j++) - OPLL_getDefaultPatch (i, j, &default_patch[i][j * 2]); - -} - -void -OPLL_setPatch (OPLL * opll, const e_uint8 * dump) -{ - OPLL_PATCH patch[2]; - int i; - - for (i = 0; i < 19; i++) - { - OPLL_dump2patch (dump + i * 16, patch); - memcpy (&opll->patch[i*2+0], &patch[0], sizeof (OPLL_PATCH)); - memcpy (&opll->patch[i*2+1], &patch[1], sizeof (OPLL_PATCH)); - } -} - -void -OPLL_patch2dump (const OPLL_PATCH * patch, e_uint8 * dump) -{ - dump[0] = (e_uint8) ((patch[0].AM << 7) + (patch[0].PM << 6) + (patch[0].EG << 5) + (patch[0].KR << 4) + patch[0].ML); - dump[1] = (e_uint8) ((patch[1].AM << 7) + (patch[1].PM << 6) + (patch[1].EG << 5) + (patch[1].KR << 4) + patch[1].ML); - dump[2] = (e_uint8) ((patch[0].KL << 6) + patch[0].TL); - dump[3] = (e_uint8) ((patch[1].KL << 6) + (patch[1].WF << 4) + (patch[0].WF << 3) + patch[0].FB); - dump[4] = (e_uint8) ((patch[0].AR << 4) + patch[0].DR); - dump[5] = (e_uint8) ((patch[1].AR << 4) + patch[1].DR); - dump[6] = (e_uint8) ((patch[0].SL << 4) + patch[0].RR); - dump[7] = (e_uint8) ((patch[1].SL << 4) + patch[1].RR); - dump[8] = 0; - dump[9] = 0; - dump[10] = 0; - dump[11] = 0; - dump[12] = 0; - dump[13] = 0; - dump[14] = 0; - dump[15] = 0; -} - -/************************************************************ - - Calc Parameters - -************************************************************/ - -INLINE static e_uint32 -calc_eg_dphase (OPLL_SLOT * slot) -{ - - switch (slot->eg_mode) - { - case ATTACK: - return dphaseARTable[slot->patch->AR][slot->rks]; - - case DECAY: - return dphaseDRTable[slot->patch->DR][slot->rks]; - - case SUSHOLD: - return 0; - - case SUSTINE: - return dphaseDRTable[slot->patch->RR][slot->rks]; - - case RELEASE: - if (slot->sustine) - return dphaseDRTable[5][slot->rks]; - else if (slot->patch->EG) - return dphaseDRTable[slot->patch->RR][slot->rks]; - else - return dphaseDRTable[7][slot->rks]; - - case SETTLE: - return dphaseDRTable[15][0]; - - case FINISH: - return 0; - - default: - return 0; - } -} - -/************************************************************* - - OPLL internal interfaces - -*************************************************************/ -#define SLOT_BD1 12 -#define SLOT_BD2 13 -#define SLOT_HH 14 -#define SLOT_SD 15 -#define SLOT_TOM 16 -#define SLOT_CYM 17 - -/* We will set this dinamically, but not sure if this affects playback */ -#if defined(ROCKBOX) -INLINE static void -UPDATE_PG(OPLL_SLOT * slot) -{ - static const e_uint32 mltable[16] = - { 1, 1 * 2, 2 * 2, 3 * 2, 4 * 2, 5 * 2, 6 * 2, 7 * 2, 8 * 2, 9 * 2, 10 * 2, 10 * 2, 12 * 2, 12 * 2, 15 * 2, 15 * 2 }; - - slot->dphase = RATE_ADJUST (((slot->fnum * mltable[slot->patch->ML]) << slot->block) >> (20 - DP_BITS)); -} -#else -#define UPDATE_PG(S) (S)->dphase = dphaseTable[(S)->fnum][(S)->block][(S)->patch->ML] -#endif - -#define UPDATE_TLL(S)\ -(((S)->type==0)?\ -((S)->tll = tllTable[((S)->fnum)>>5][(S)->block][(S)->patch->TL][(S)->patch->KL]):\ -((S)->tll = tllTable[((S)->fnum)>>5][(S)->block][(S)->volume][(S)->patch->KL])) -#define UPDATE_RKS(S) (S)->rks = rksTable[((S)->fnum)>>8][(S)->block][(S)->patch->KR] -#define UPDATE_WF(S) (S)->sintbl = waveform[(S)->patch->WF] -#define UPDATE_EG(S) (S)->eg_dphase = calc_eg_dphase(S) -#define UPDATE_ALL(S)\ - UPDATE_PG(S);\ - UPDATE_TLL(S);\ - UPDATE_RKS(S);\ - UPDATE_WF(S); \ - UPDATE_EG(S) /* EG should be updated last. */ - - -/* Slot key on */ -INLINE static void -slotOn (OPLL_SLOT * slot) -{ - slot->eg_mode = ATTACK; - slot->eg_phase = 0; - slot->phase = 0; - UPDATE_EG(slot); -} - -/* Slot key on without reseting the phase */ -INLINE static void -slotOn2 (OPLL_SLOT * slot) -{ - slot->eg_mode = ATTACK; - slot->eg_phase = 0; - UPDATE_EG(slot); -} - -/* Slot key off */ -INLINE static void -slotOff (OPLL_SLOT * slot) -{ - if (slot->eg_mode == ATTACK) - slot->eg_phase = EXPAND_BITS (AR_ADJUST_TABLE(HIGHBITS (slot->eg_phase, EG_DP_BITS - EG_BITS)), EG_BITS, EG_DP_BITS); - slot->eg_mode = RELEASE; - UPDATE_EG(slot); -} - -/* Channel key on */ -INLINE static void -keyOn (OPLL * opll, e_int32 i) -{ - if (!opll->slot_on_flag[i * 2]) - slotOn (MOD(opll,i)); - if (!opll->slot_on_flag[i * 2 + 1]) - slotOn (CAR(opll,i)); - opll->key_status[i] = 1; -} - -/* Channel key off */ -INLINE static void -keyOff (OPLL * opll, e_int32 i) -{ - if (opll->slot_on_flag[i * 2 + 1]) - slotOff (CAR(opll,i)); - opll->key_status[i] = 0; -} - -INLINE static void -keyOn_BD (OPLL * opll) -{ - keyOn (opll, 6); -} -INLINE static void -keyOn_SD (OPLL * opll) -{ - if (!opll->slot_on_flag[SLOT_SD]) - slotOn (CAR(opll,7)); -} -INLINE static void -keyOn_TOM (OPLL * opll) -{ - if (!opll->slot_on_flag[SLOT_TOM]) - slotOn (MOD(opll,8)); -} -INLINE static void -keyOn_HH (OPLL * opll) -{ - if (!opll->slot_on_flag[SLOT_HH]) - slotOn2 (MOD(opll,7)); -} -INLINE static void -keyOn_CYM (OPLL * opll) -{ - if (!opll->slot_on_flag[SLOT_CYM]) - slotOn2 (CAR(opll,8)); -} - -/* Drum key off */ -INLINE static void -keyOff_BD (OPLL * opll) -{ - keyOff (opll, 6); -} -INLINE static void -keyOff_SD (OPLL * opll) -{ - if (opll->slot_on_flag[SLOT_SD]) - slotOff (CAR(opll,7)); -} -INLINE static void -keyOff_TOM (OPLL * opll) -{ - if (opll->slot_on_flag[SLOT_TOM]) - slotOff (MOD(opll,8)); -} -INLINE static void -keyOff_HH (OPLL * opll) -{ - if (opll->slot_on_flag[SLOT_HH]) - slotOff (MOD(opll,7)); -} -INLINE static void -keyOff_CYM (OPLL * opll) -{ - if (opll->slot_on_flag[SLOT_CYM]) - slotOff (CAR(opll,8)); -} - -/* Change a voice */ -INLINE static void -setPatch (OPLL * opll, e_int32 i, e_int32 num) -{ - opll->patch_number[i] = num; - MOD(opll,i)->patch = &opll->patch[num * 2 + 0]; - CAR(opll,i)->patch = &opll->patch[num * 2 + 1]; -} - -/* Change a rhythm voice */ -INLINE static void -setSlotPatch (OPLL_SLOT * slot, OPLL_PATCH * patch) -{ - slot->patch = patch; -} - -/* Set sustine parameter */ -INLINE static void -setSustine (OPLL * opll, e_int32 c, e_int32 sustine) -{ - CAR(opll,c)->sustine = sustine; - if (MOD(opll,c)->type) - MOD(opll,c)->sustine = sustine; -} - -/* Volume : 6bit ( Volume register << 2 ) */ -INLINE static void -setVolume (OPLL * opll, e_int32 c, e_int32 volume) -{ - CAR(opll,c)->volume = volume; -} - -INLINE static void -setSlotVolume (OPLL_SLOT * slot, e_int32 volume) -{ - slot->volume = volume; -} - -/* Set F-Number ( fnum : 9bit ) */ -INLINE static void -setFnumber (OPLL * opll, e_int32 c, e_int32 fnum) -{ - CAR(opll,c)->fnum = fnum; - MOD(opll,c)->fnum = fnum; -} - -/* Set Block data (block : 3bit ) */ -INLINE static void -setBlock (OPLL * opll, e_int32 c, e_int32 block) -{ - CAR(opll,c)->block = block; - MOD(opll,c)->block = block; -} - -/* Change Rhythm Mode */ -INLINE static void -update_rhythm_mode (OPLL * opll) -{ - if (opll->patch_number[6] & 0x10) - { - if (!(opll->slot_on_flag[SLOT_BD2] | (opll->reg[0x0e] & 32))) - { - opll->slot[SLOT_BD1].eg_mode = FINISH; - opll->slot[SLOT_BD2].eg_mode = FINISH; - setPatch (opll, 6, opll->reg[0x36] >> 4); - } - } - else if (opll->reg[0x0e] & 32) - { - opll->patch_number[6] = 16; - opll->slot[SLOT_BD1].eg_mode = FINISH; - opll->slot[SLOT_BD2].eg_mode = FINISH; - setSlotPatch (&opll->slot[SLOT_BD1], &opll->patch[16 * 2 + 0]); - setSlotPatch (&opll->slot[SLOT_BD2], &opll->patch[16 * 2 + 1]); - } - - if (opll->patch_number[7] & 0x10) - { - if (!((opll->slot_on_flag[SLOT_HH] && opll->slot_on_flag[SLOT_SD]) | (opll->reg[0x0e] & 32))) - { - opll->slot[SLOT_HH].type = 0; - opll->slot[SLOT_HH].eg_mode = FINISH; - opll->slot[SLOT_SD].eg_mode = FINISH; - setPatch (opll, 7, opll->reg[0x37] >> 4); - } - } - else if (opll->reg[0x0e] & 32) - { - opll->patch_number[7] = 17; - opll->slot[SLOT_HH].type = 1; - opll->slot[SLOT_HH].eg_mode = FINISH; - opll->slot[SLOT_SD].eg_mode = FINISH; - setSlotPatch (&opll->slot[SLOT_HH], &opll->patch[17 * 2 + 0]); - setSlotPatch (&opll->slot[SLOT_SD], &opll->patch[17 * 2 + 1]); - } - - if (opll->patch_number[8] & 0x10) - { - if (!((opll->slot_on_flag[SLOT_CYM] && opll->slot_on_flag[SLOT_TOM]) | (opll->reg[0x0e] & 32))) - { - opll->slot[SLOT_TOM].type = 0; - opll->slot[SLOT_TOM].eg_mode = FINISH; - opll->slot[SLOT_CYM].eg_mode = FINISH; - setPatch (opll, 8, opll->reg[0x38] >> 4); - } - } - else if (opll->reg[0x0e] & 32) - { - opll->patch_number[8] = 18; - opll->slot[SLOT_TOM].type = 1; - opll->slot[SLOT_TOM].eg_mode = FINISH; - opll->slot[SLOT_CYM].eg_mode = FINISH; - setSlotPatch (&opll->slot[SLOT_TOM], &opll->patch[18 * 2 + 0]); - setSlotPatch (&opll->slot[SLOT_CYM], &opll->patch[18 * 2 + 1]); - } -} - -INLINE static void -update_key_status (OPLL * opll) -{ - int ch; - - for (ch = 0; ch < 9; ch++) - opll->slot_on_flag[ch * 2] = opll->slot_on_flag[ch * 2 + 1] = (opll->reg[0x20 + ch]) & 0x10; - - if (opll->reg[0x0e] & 32) - { - opll->slot_on_flag[SLOT_BD1] |= (opll->reg[0x0e] & 0x10); - opll->slot_on_flag[SLOT_BD2] |= (opll->reg[0x0e] & 0x10); - opll->slot_on_flag[SLOT_SD] |= (opll->reg[0x0e] & 0x08); - opll->slot_on_flag[SLOT_HH] |= (opll->reg[0x0e] & 0x01); - opll->slot_on_flag[SLOT_TOM] |= (opll->reg[0x0e] & 0x04); - opll->slot_on_flag[SLOT_CYM] |= (opll->reg[0x0e] & 0x02); - } -} - -void -OPLL_copyPatch (OPLL * opll, e_int32 num, OPLL_PATCH * patch) -{ - memcpy (&opll->patch[num], patch, sizeof (OPLL_PATCH)); -} - -/*********************************************************** - - Initializing - -***********************************************************/ - -static void -OPLL_SLOT_reset (OPLL_SLOT * slot, int type) -{ - slot->type = type; - slot->sintbl = waveform[0]; - slot->phase = 0; - slot->dphase = 0; - slot->output[0] = 0; - slot->output[1] = 0; - slot->feedback = 0; - slot->eg_mode = FINISH; - slot->eg_phase = EG_DP_WIDTH; - slot->eg_dphase = 0; - slot->rks = 0; - slot->tll = 0; - slot->sustine = 0; - slot->fnum = 0; - slot->block = 0; - slot->volume = 0; - slot->pgout = 0; - slot->egout = 0; - slot->patch = &null_patch; -} - -static void -internal_refresh (void) -{ -#if !defined(ROCKBOX) - makeDphaseTable (); -#endif - makeDphaseARTable (); - makeDphaseDRTable (); - pm_dphase = (e_uint32) RATE_ADJUST ((int)(PM_SPEED * PM_DP_WIDTH) / (clk / 72)); - am_dphase = (e_uint32) RATE_ADJUST ((int)(AM_SPEED * AM_DP_WIDTH) / (clk / 72)); -} - -static void -maketables (e_uint32 c, e_uint32 r) -{ - if (c != clk) - { - clk = c; -#ifdef EMU2413_CALCUL_TABLES - makePmTable (); - makeAmTable (); - makeAdjustTable (); -#endif - makeDB2LinTable (); - makeTllTable (); - makeRksTable (); - makeSinTable (); - makeDefaultPatch (); - } - - if (r != rate) - { - rate = r; - internal_refresh (); - } -} - -void -OPLL_new (OPLL *opll, e_uint32 clk, e_uint32 rate) -{ - e_int32 i; - - maketables (clk, rate); - - memset(opll, 0, sizeof (OPLL)); - for (i = 0; i < 19 * 2; i++) - memcpy(&opll->patch[i],&null_patch,sizeof(OPLL_PATCH)); - - opll->mask = 0; - - OPLL_reset (opll); - OPLL_reset_patch (opll, 0); -} - - -void -OPLL_delete (OPLL * opll) -{ - (void) opll; -} - - -/* Reset patch datas by system default. */ -void -OPLL_reset_patch (OPLL * opll, e_int32 type) -{ - e_int32 i; - - for (i = 0; i < 19 * 2; i++) - OPLL_copyPatch (opll, i, &default_patch[type % OPLL_TONE_NUM][i]); -} - -/* Reset whole of OPLL except patch datas. */ -void -OPLL_reset (OPLL * opll) -{ - e_int32 i; - - if (!opll) - return; - - opll->adr = 0; - opll->out = 0; - - opll->pm_phase = 0; - opll->am_phase = 0; - - opll->noise_seed = 0xffff; - opll->mask = 0; - - for (i = 0; i <18; i++) - OPLL_SLOT_reset(&opll->slot[i], i%2); - - for (i = 0; i < 9; i++) - { - opll->key_status[i] = 0; - setPatch (opll, i, 0); - } - - for (i = 0; i < 0x40; i++) - OPLL_writeReg (opll, i, 0); - -#ifndef EMU2413_COMPACTION - opll->realstep = (e_uint32) ((1 << 31) / rate); - opll->opllstep = (e_uint32) ((1 << 31) / (clk / 72)); - opll->oplltime = 0; - for (i = 0; i < 14; i++) - opll->pan[i] = 2; - opll->sprev[0] = opll->sprev[1] = 0; - opll->snext[0] = opll->snext[1] = 0; -#endif -} - -/* Force Refresh (When external program changes some parameters). */ -void -OPLL_forceRefresh (OPLL * opll) -{ - e_int32 i; - - if (opll == NULL) - return; - - for (i = 0; i < 9; i++) - setPatch(opll,i,opll->patch_number[i]); - - for (i = 0; i < 18; i++) - { - UPDATE_PG (&opll->slot[i]); - UPDATE_RKS (&opll->slot[i]); - UPDATE_TLL (&opll->slot[i]); - UPDATE_WF (&opll->slot[i]); - UPDATE_EG (&opll->slot[i]); - } -} - -void -OPLL_set_rate (OPLL * opll, e_uint32 r) -{ - if (rate == r) return; - if (opll->quality) - rate = 49716; - else - rate = r; - internal_refresh (); - rate = r; -} - -void -OPLL_set_quality (OPLL * opll, e_uint32 q) -{ - opll->quality = q; - OPLL_set_rate (opll, rate); -} - -/********************************************************* - - Generate wave data - -*********************************************************/ -/* Convert Amp(0 to EG_HEIGHT) to Phase(0 to 2PI). */ -#if ( SLOT_AMP_BITS - PG_BITS ) > 0 -#define wave2_2pi(e) ( (e) >> ( SLOT_AMP_BITS - PG_BITS )) -#else -#define wave2_2pi(e) ( (e) << ( PG_BITS - SLOT_AMP_BITS )) -#endif - -/* Convert Amp(0 to EG_HEIGHT) to Phase(0 to 4PI). */ -#if ( SLOT_AMP_BITS - PG_BITS - 1 ) == 0 -#define wave2_4pi(e) (e) -#elif ( SLOT_AMP_BITS - PG_BITS - 1 ) > 0 -#define wave2_4pi(e) ( (e) >> ( SLOT_AMP_BITS - PG_BITS - 1 )) -#else -#define wave2_4pi(e) ( (e) << ( 1 + PG_BITS - SLOT_AMP_BITS )) -#endif - -/* Convert Amp(0 to EG_HEIGHT) to Phase(0 to 8PI). */ -#if ( SLOT_AMP_BITS - PG_BITS - 2 ) == 0 -#define wave2_8pi(e) (e) -#elif ( SLOT_AMP_BITS - PG_BITS - 2 ) > 0 -#define wave2_8pi(e) ( (e) >> ( SLOT_AMP_BITS - PG_BITS - 2 )) -#else -#define wave2_8pi(e) ( (e) << ( 2 + PG_BITS - SLOT_AMP_BITS )) -#endif - -/* Update AM, PM unit */ -INLINE static void -update_ampm (OPLL * opll) -{ - opll->pm_phase = (opll->pm_phase + pm_dphase) & (PM_DP_WIDTH - 1); - opll->am_phase = (opll->am_phase + am_dphase) & (AM_DP_WIDTH - 1); - opll->lfo_am = AMTABLE(HIGHBITS (opll->am_phase, AM_DP_BITS - AM_PG_BITS)); - opll->lfo_pm = PMTABLE(HIGHBITS (opll->pm_phase, PM_DP_BITS - PM_PG_BITS)); -} - -/* PG */ -INLINE static void -calc_phase (OPLL_SLOT * slot, e_int32 lfo) -{ - if (slot->patch->PM) - slot->phase += (slot->dphase * lfo) >> PM_AMP_BITS; - else - slot->phase += slot->dphase; - - slot->phase &= (DP_WIDTH - 1); - - slot->pgout = HIGHBITS (slot->phase, DP_BASE_BITS); -} - -/* Update Noise unit */ -INLINE static void -update_noise (OPLL * opll) -{ - if(opll->noise_seed&1) opll->noise_seed ^= 0x8003020; - opll->noise_seed >>= 1; -} - -/* EG */ -INLINE static void -calc_envelope (OPLL_SLOT * slot, e_int32 lfo) -{ -#define S2E(x) (SL2EG((e_int32)(x/SL_STEP))<<(EG_DP_BITS-EG_BITS)) - - static e_uint32 SL[16] = { - S2E (0.0), S2E (3.0), S2E (6.0), S2E (9.0), S2E (12.0), S2E (15.0), S2E (18.0), S2E (21.0), - S2E (24.0), S2E (27.0), S2E (30.0), S2E (33.0), S2E (36.0), S2E (39.0), S2E (42.0), S2E (48.0) - }; - - e_uint32 egout; - - switch (slot->eg_mode) - { - case ATTACK: - egout = AR_ADJUST_TABLE(HIGHBITS (slot->eg_phase, EG_DP_BITS - EG_BITS)); - slot->eg_phase += slot->eg_dphase; - if((EG_DP_WIDTH & slot->eg_phase)||(slot->patch->AR==15)) - { - egout = 0; - slot->eg_phase = 0; - slot->eg_mode = DECAY; - UPDATE_EG (slot); - } - break; - - case DECAY: - egout = HIGHBITS (slot->eg_phase, EG_DP_BITS - EG_BITS); - slot->eg_phase += slot->eg_dphase; - if (slot->eg_phase >= SL[slot->patch->SL]) - { - if (slot->patch->EG) - { - slot->eg_phase = SL[slot->patch->SL]; - slot->eg_mode = SUSHOLD; - UPDATE_EG (slot); - } - else - { - slot->eg_phase = SL[slot->patch->SL]; - slot->eg_mode = SUSTINE; - UPDATE_EG (slot); - } - } - break; - - case SUSHOLD: - egout = HIGHBITS (slot->eg_phase, EG_DP_BITS - EG_BITS); - if (slot->patch->EG == 0) - { - slot->eg_mode = SUSTINE; - UPDATE_EG (slot); - } - break; - - case SUSTINE: - case RELEASE: - egout = HIGHBITS (slot->eg_phase, EG_DP_BITS - EG_BITS); - slot->eg_phase += slot->eg_dphase; - if (egout >= (1 << EG_BITS)) - { - slot->eg_mode = FINISH; - egout = (1 << EG_BITS) - 1; - } - break; - - case SETTLE: - egout = HIGHBITS (slot->eg_phase, EG_DP_BITS - EG_BITS); - slot->eg_phase += slot->eg_dphase; - if (egout >= (1 << EG_BITS)) - { - slot->eg_mode = ATTACK; - egout = (1 << EG_BITS) - 1; - UPDATE_EG(slot); - } - break; - - case FINISH: - egout = (1 << EG_BITS) - 1; - break; - - default: - egout = (1 << EG_BITS) - 1; - break; - } - - if (slot->patch->AM) - egout = EG2DB (egout + slot->tll) + lfo; - else - egout = EG2DB (egout + slot->tll); - - if (egout >= DB_MUTE) - egout = DB_MUTE - 1; - - slot->egout = egout | 3; -} - -/* CARRIOR */ -INLINE static e_int32 -calc_slot_car (OPLL_SLOT * slot, e_int32 fm) -{ - if (slot->egout >= (DB_MUTE - 1)) - { - slot->output[0] = 0; - } - else - { - slot->output[0] = DB2LIN_TABLE[slot->sintbl[(slot->pgout+wave2_8pi(fm))&(PG_WIDTH-1)] + slot->egout]; - } - - slot->output[1] = (slot->output[1] + slot->output[0]) >> 1; - return slot->output[1]; -} - -/* MODULATOR */ -INLINE static e_int32 -calc_slot_mod (OPLL_SLOT * slot) -{ - e_int32 fm; - - slot->output[1] = slot->output[0]; - - if (slot->egout >= (DB_MUTE - 1)) - { - slot->output[0] = 0; - } - else if (slot->patch->FB != 0) - { - fm = wave2_4pi (slot->feedback) >> (7 - slot->patch->FB); - slot->output[0] = DB2LIN_TABLE[slot->sintbl[(slot->pgout+fm)&(PG_WIDTH-1)] + slot->egout]; - } - else - { - slot->output[0] = DB2LIN_TABLE[slot->sintbl[slot->pgout] + slot->egout]; - } - - slot->feedback = (slot->output[1] + slot->output[0]) >> 1; - - return slot->feedback; - -} - -/* TOM */ -INLINE static e_int32 -calc_slot_tom (OPLL_SLOT * slot) -{ - if (slot->egout >= (DB_MUTE - 1)) - return 0; - - return DB2LIN_TABLE[slot->sintbl[slot->pgout] + slot->egout]; - -} - -/* SNARE */ -INLINE static e_int32 -calc_slot_snare (OPLL_SLOT * slot, e_uint32 noise) -{ - if(slot->egout>=(DB_MUTE-1)) - return 0; - - if(BIT(slot->pgout,7)) - return DB2LIN_TABLE[(noise?DB_POS(0):DB_POS(15))+slot->egout]; - else - return DB2LIN_TABLE[(noise?DB_NEG(0):DB_NEG(15))+slot->egout]; -} - -/* - TOP-CYM - */ -INLINE static e_int32 -calc_slot_cym (OPLL_SLOT * slot, e_uint32 pgout_hh) -{ - e_uint32 dbout; - - if (slot->egout >= (DB_MUTE - 1)) - return 0; - else if( - /* the same as fmopl.c */ - ((BIT(pgout_hh,PG_BITS-8)^BIT(pgout_hh,PG_BITS-1))|BIT(pgout_hh,PG_BITS-7)) ^ - /* different from fmopl.c */ - (BIT(slot->pgout,PG_BITS-7)&!BIT(slot->pgout,PG_BITS-5)) - ) - dbout = DB_NEG(3); - else - dbout = DB_POS(3); - - return DB2LIN_TABLE[dbout + slot->egout]; -} - -/* - HI-HAT -*/ -INLINE static e_int32 -calc_slot_hat (OPLL_SLOT *slot, e_int32 pgout_cym, e_uint32 noise) -{ - e_uint32 dbout; - - if (slot->egout >= (DB_MUTE - 1)) - return 0; - else if( - /* the same as fmopl.c */ - ((BIT(slot->pgout,PG_BITS-8)^BIT(slot->pgout,PG_BITS-1))|BIT(slot->pgout,PG_BITS-7)) ^ - /* different from fmopl.c */ - (BIT(pgout_cym,PG_BITS-7)&!BIT(pgout_cym,PG_BITS-5)) - ) - { - if(noise) - dbout = DB_NEG(12); - else - dbout = DB_NEG(24); - } - else - { - if(noise) - dbout = DB_POS(12); - else - dbout = DB_POS(24); - } - - return DB2LIN_TABLE[dbout + slot->egout]; -} - -static e_int16 -calc (OPLL * opll) EMU2413_CALC_ICODE; -static e_int16 -calc (OPLL * opll) -{ - e_int32 i; - - update_ampm (opll); - update_noise (opll); - - for (i = 0; i < 18; i++) - { - calc_phase(&opll->slot[i],opll->lfo_pm); - calc_envelope(&opll->slot[i],opll->lfo_am); - } - - e_uint32 channel_mask = opll->mask; - for (i = 0; i < 9; i++) { - if (CAR(opll,i)->eg_mode != FINISH) - channel_mask |= (1 << i); - } - - e_int32 mix = 0; - - /* CH6 */ - if (opll->patch_number[6] & 0x10) { - if (channel_mask & OPLL_MASK_CH (6)) { - mix += calc_slot_car (CAR(opll,6), calc_slot_mod(MOD(opll,6))); - channel_mask &= ~(1 << 6); - } - } - - /* CH7 */ - if (opll->patch_number[7] & 0x10) { - if (MOD(opll,7)->eg_mode != FINISH) - mix += calc_slot_hat (MOD(opll,7), CAR(opll,8)->pgout, opll->noise_seed&1); - if (channel_mask & OPLL_MASK_SD) { - mix -= calc_slot_snare (CAR(opll,7), opll->noise_seed&1); - channel_mask &= ~OPLL_MASK_SD; - } - } - - /* CH8 */ - if (opll->patch_number[8] & 0x10) { - if (MOD(opll,8)->eg_mode != FINISH) - mix += calc_slot_tom (MOD(opll,8)); - if (channel_mask & OPLL_MASK_CYM) { - mix -= calc_slot_cym (CAR(opll,8), MOD(opll,7)->pgout); - channel_mask &= ~OPLL_MASK_CYM; - } - } - - mix <<= 1; - - opll->current_mask = channel_mask; - for (i = 0; channel_mask; channel_mask >>= 1, ++i) { - if (channel_mask & 1) { - mix += calc_slot_car (CAR(opll,i), calc_slot_mod(MOD(opll,i))); - } - } - - return (e_int16) mix << 3; -} - -void -OPLL_set_internal_mute(OPLL * opll, e_uint32 mute) -{ - opll->internal_mute = mute; -} - -e_uint32 -OPLL_is_internal_muted(OPLL * opll) -{ - return opll->internal_mute; -} - -static e_uint32 -check_mute_helper(OPLL * opll) -{ - for (int i = 0; i < 6; i++) { - /* if (ch[i].car.eg_mode != FINISH) return 0; */ - if (!(opll->current_mask & OPLL_MASK_CH (i)) && (CAR(opll,i)->eg_mode != FINISH)) return 0; - } - - if (!(opll->reg[0x0e] & 0x20)) { - for(int i = 6; i < 9; i++) { - /* if (ch[i].car.eg_mode != FINISH) return 0; */ - if (!(opll->current_mask & OPLL_MASK_CH (i)) && (CAR(opll,i)->eg_mode != FINISH)) return 0; - } - } else { - /* if (ch[6].car.eg_mode != FINISH) return false; - if (ch[7].mod.eg_mode != FINISH) return false; - if (ch[7].car.eg_mode != FINISH) return false; - if (ch[8].mod.eg_mode != FINISH) return false; - if (ch[8].car.eg_mode != FINISH) return false; */ - if (!(opll->current_mask & OPLL_MASK_CH (6)) && (CAR(opll,6)->eg_mode != FINISH)) return 0; - if (!(opll->current_mask & OPLL_MASK_CH (7)) && (MOD(opll,7)->eg_mode != FINISH)) return 0; - if (!(opll->current_mask & OPLL_MASK_CH (7)) && (CAR(opll,7)->eg_mode != FINISH)) return 0; - if (!(opll->current_mask & OPLL_MASK_CH (8)) && (MOD(opll,8)->eg_mode != FINISH)) return 0; - if (!(opll->current_mask & OPLL_MASK_CH (8)) && (CAR(opll,8)->eg_mode != FINISH)) return 0; - } - - return 1; /* nothing is playing, then mute */ -} - -static void -check_mute(OPLL * opll) -{ - OPLL_set_internal_mute (opll, check_mute_helper (opll)); -} - -EMU2413_API e_int16 *OPLL_update_buffer(OPLL * opll, e_uint32 length) -{ - e_int16* buf = opll->buffer; - while (length--) { - *(buf++) = calc (opll); - } - check_mute (opll); - - return opll->buffer; -} - -#ifdef EMU2413_COMPACTION -e_int16 -OPLL_calc (OPLL * opll) -{ - return calc (opll); -} -#else -e_int16 -OPLL_calc (OPLL * opll) -{ - if (!opll->quality) - return calc (opll); - - while (opll->realstep > opll->oplltime) - { - opll->oplltime += opll->opllstep; - opll->prev = opll->next; - opll->next = calc (opll); - } - - opll->oplltime -= opll->realstep; - opll->out = (e_int16) (((double) opll->next * (opll->opllstep - opll->oplltime) - + (double) opll->prev * opll->oplltime) / opll->opllstep); - - return (e_int16) opll->out; -} -#endif - -e_uint32 -OPLL_setMask (OPLL * opll, e_uint32 mask) -{ - e_uint32 ret; - - if (opll) - { - ret = opll->mask; - opll->mask = mask; - return ret; - } - else - return 0; -} - -e_uint32 -OPLL_toggleMask (OPLL * opll, e_uint32 mask) -{ - e_uint32 ret; - - if (opll) - { - ret = opll->mask; - opll->mask ^= mask; - return ret; - } - else - return 0; -} - -/**************************************************** - - I/O Ctrl - -*****************************************************/ - -void -OPLL_writeReg (OPLL * opll, e_uint32 reg, e_uint32 data) -{ - e_int32 i, v, ch; - - data = data & 0xff; - reg = reg & 0x3f; - opll->reg[reg] = (e_uint8) data; - - switch (reg) - { - case 0x00: - opll->patch[0].AM = (data >> 7) & 1; - opll->patch[0].PM = (data >> 6) & 1; - opll->patch[0].EG = (data >> 5) & 1; - opll->patch[0].KR = (data >> 4) & 1; - opll->patch[0].ML = (data) & 15; - for (i = 0; i < 9; i++) - { - if (opll->patch_number[i] == 0) - { - UPDATE_PG (MOD(opll,i)); - UPDATE_RKS (MOD(opll,i)); - UPDATE_EG (MOD(opll,i)); - } - } - break; - - case 0x01: - opll->patch[1].AM = (data >> 7) & 1; - opll->patch[1].PM = (data >> 6) & 1; - opll->patch[1].EG = (data >> 5) & 1; - opll->patch[1].KR = (data >> 4) & 1; - opll->patch[1].ML = (data) & 15; - for (i = 0; i < 9; i++) - { - if (opll->patch_number[i] == 0) - { - UPDATE_PG (CAR(opll,i)); - UPDATE_RKS (CAR(opll,i)); - UPDATE_EG (CAR(opll,i)); - } - } - break; - - case 0x02: - opll->patch[0].KL = (data >> 6) & 3; - opll->patch[0].TL = (data) & 63; - for (i = 0; i < 9; i++) - { - if (opll->patch_number[i] == 0) - { - UPDATE_TLL(MOD(opll,i)); - } - } - break; - - case 0x03: - opll->patch[1].KL = (data >> 6) & 3; - opll->patch[1].WF = (data >> 4) & 1; - opll->patch[0].WF = (data >> 3) & 1; - opll->patch[0].FB = (data) & 7; - for (i = 0; i < 9; i++) - { - if (opll->patch_number[i] == 0) - { - UPDATE_WF(MOD(opll,i)); - UPDATE_WF(CAR(opll,i)); - } - } - break; - - case 0x04: - opll->patch[0].AR = (data >> 4) & 15; - opll->patch[0].DR = (data) & 15; - for (i = 0; i < 9; i++) - { - if (opll->patch_number[i] == 0) - { - UPDATE_EG (MOD(opll,i)); - } - } - break; - - case 0x05: - opll->patch[1].AR = (data >> 4) & 15; - opll->patch[1].DR = (data) & 15; - for (i = 0; i < 9; i++) - { - if (opll->patch_number[i] == 0) - { - UPDATE_EG(CAR(opll,i)); - } - } - break; - - case 0x06: - opll->patch[0].SL = (data >> 4) & 15; - opll->patch[0].RR = (data) & 15; - for (i = 0; i < 9; i++) - { - if (opll->patch_number[i] == 0) - { - UPDATE_EG (MOD(opll,i)); - } - } - break; - - case 0x07: - opll->patch[1].SL = (data >> 4) & 15; - opll->patch[1].RR = (data) & 15; - for (i = 0; i < 9; i++) - { - if (opll->patch_number[i] == 0) - { - UPDATE_EG (CAR(opll,i)); - } - } - break; - - case 0x0e: - update_rhythm_mode (opll); - if (data & 32) - { - if (data & 0x10) - keyOn_BD (opll); - else - keyOff_BD (opll); - if (data & 0x8) - keyOn_SD (opll); - else - keyOff_SD (opll); - if (data & 0x4) - keyOn_TOM (opll); - else - keyOff_TOM (opll); - if (data & 0x2) - keyOn_CYM (opll); - else - keyOff_CYM (opll); - if (data & 0x1) - keyOn_HH (opll); - else - keyOff_HH (opll); - } - update_key_status (opll); - - UPDATE_ALL (MOD(opll,6)); - UPDATE_ALL (CAR(opll,6)); - UPDATE_ALL (MOD(opll,7)); - UPDATE_ALL (CAR(opll,7)); - UPDATE_ALL (MOD(opll,8)); - UPDATE_ALL (CAR(opll,8)); - - break; - - case 0x0f: - break; - - case 0x10: - case 0x11: - case 0x12: - case 0x13: - case 0x14: - case 0x15: - case 0x16: - case 0x17: - case 0x18: - ch = reg - 0x10; - setFnumber (opll, ch, data + ((opll->reg[0x20 + ch] & 1) << 8)); - UPDATE_ALL (MOD(opll,ch)); - UPDATE_ALL (CAR(opll,ch)); - break; - - case 0x20: - case 0x21: - case 0x22: - case 0x23: - case 0x24: - case 0x25: - case 0x26: - case 0x27: - case 0x28: - ch = reg - 0x20; - setFnumber (opll, ch, ((data & 1) << 8) + opll->reg[0x10 + ch]); - setBlock (opll, ch, (data >> 1) & 7); - setSustine (opll, ch, (data >> 5) & 1); - if (data & 0x10) - keyOn (opll, ch); - else - keyOff (opll, ch); - UPDATE_ALL (MOD(opll,ch)); - UPDATE_ALL (CAR(opll,ch)); - update_key_status (opll); - update_rhythm_mode (opll); - break; - - case 0x30: - case 0x31: - case 0x32: - case 0x33: - case 0x34: - case 0x35: - case 0x36: - case 0x37: - case 0x38: - i = (data >> 4) & 15; - v = data & 15; - if ((opll->reg[0x0e] & 32) && (reg >= 0x36)) - { - switch (reg) - { - case 0x37: - setSlotVolume (MOD(opll,7), i << 2); - break; - case 0x38: - setSlotVolume (MOD(opll,8), i << 2); - break; - default: - break; - } - } - else - { - setPatch (opll, reg - 0x30, i); - } - setVolume (opll, reg - 0x30, v << 2); - UPDATE_ALL (MOD(opll,reg - 0x30)); - UPDATE_ALL (CAR(opll,reg - 0x30)); - break; - - default: - break; - - } -} - -void -OPLL_writeIO (OPLL * opll, e_uint32 adr, e_uint32 val) -{ - if (adr & 1) - OPLL_writeReg (opll, opll->adr, val); - else - opll->adr = val; -} - -e_uint32 -OPLL_read(OPLL * opll, e_uint32 a) -{ - if( !(a&1) ) - { - /* status port */ - return opll->status; - } - return 0xff; -} - -#ifndef EMU2413_COMPACTION -/* STEREO MODE (OPT) */ -void -OPLL_set_pan (OPLL * opll, e_uint32 ch, e_uint32 pan) -{ - opll->pan[ch & 15] = pan & 3; -} - -static void -calc_stereo (OPLL * opll, e_int32 out[2]) -{ - e_int32 b[4] = { 0, 0, 0, 0 }; /* Ignore, Right, Left, Center */ - e_int32 r[4] = { 0, 0, 0, 0 }; /* Ignore, Right, Left, Center */ - e_int32 i; - - update_ampm (opll); - update_noise (opll); - - for(i=0;i<18;i++) - { - calc_phase(&opll->slot[i],opll->lfo_pm); - calc_envelope(&opll->slot[i],opll->lfo_am); - } - - for (i = 0; i < 6; i++) - if (!(opll->mask & OPLL_MASK_CH (i)) && (CAR(opll,i)->eg_mode != FINISH)) - b[opll->pan[i]] += calc_slot_car (CAR(opll,i), calc_slot_mod (MOD(opll,i))); - - - if (opll->patch_number[6] <= 15) - { - if (!(opll->mask & OPLL_MASK_CH (6)) && (CAR(opll,6)->eg_mode != FINISH)) - b[opll->pan[6]] += calc_slot_car (CAR(opll,6), calc_slot_mod (MOD(opll,6))); - } - else - { - if (!(opll->mask & OPLL_MASK_BD) && (CAR(opll,6)->eg_mode != FINISH)) - r[opll->pan[9]] += calc_slot_car (CAR(opll,6), calc_slot_mod (MOD(opll,6))); - } - - if (opll->patch_number[7] <= 15) - { - if (!(opll->mask & OPLL_MASK_CH (7)) && (CAR (opll,7)->eg_mode != FINISH)) - b[opll->pan[7]] += calc_slot_car (CAR (opll,7), calc_slot_mod (MOD (opll,7))); - } - else - { - if (!(opll->mask & OPLL_MASK_HH) && (MOD (opll,7)->eg_mode != FINISH)) - r[opll->pan[10]] += calc_slot_hat (MOD (opll,7), CAR(opll,8)->pgout, opll->noise_seed&1); - if (!(opll->mask & OPLL_MASK_SD) && (CAR (opll,7)->eg_mode != FINISH)) - r[opll->pan[11]] -= calc_slot_snare (CAR (opll,7), opll->noise_seed&1); - } - - if (opll->patch_number[8] <= 15) - { - if (!(opll->mask & OPLL_MASK_CH (8)) && (CAR (opll,8)->eg_mode != FINISH)) - b[opll->pan[8]] += calc_slot_car (CAR (opll,8), calc_slot_mod (MOD (opll,8))); - } - else - { - if (!(opll->mask & OPLL_MASK_TOM) && (MOD (opll,8)->eg_mode != FINISH)) - r[opll->pan[12]] += calc_slot_tom (MOD (opll,8)); - if (!(opll->mask & OPLL_MASK_CYM) && (CAR (opll,8)->eg_mode != FINISH)) - r[opll->pan[13]] -= calc_slot_cym (CAR (opll,8), MOD(opll,7)->pgout); - } - - out[1] = (b[1] + b[3] + ((r[1] + r[3]) << 1)) <<3; - out[0] = (b[2] + b[3] + ((r[2] + r[3]) << 1)) <<3; -} - -void -OPLL_calc_stereo (OPLL * opll, e_int32 out[2]) -{ - if (!opll->quality) - { - calc_stereo (opll, out); - return; - } - - while (opll->realstep > opll->oplltime) - { - opll->oplltime += opll->opllstep; - opll->sprev[0] = opll->snext[0]; - opll->sprev[1] = opll->snext[1]; - calc_stereo (opll, opll->snext); - } - - opll->oplltime -= opll->realstep; - out[0] = (e_int16) (((double) opll->snext[0] * (opll->opllstep - opll->oplltime) - + (double) opll->sprev[0] * opll->oplltime) / opll->opllstep); - out[1] = (e_int16) (((double) opll->snext[1] * (opll->opllstep - opll->oplltime) - + (double) opll->sprev[1] * opll->oplltime) / opll->opllstep); -} -#endif /* EMU2413_COMPACTION */ diff --git a/apps/codecs/libgme/emu2413.h b/apps/codecs/libgme/emu2413.h deleted file mode 100644 index 254f042957..0000000000 --- a/apps/codecs/libgme/emu2413.h +++ /dev/null @@ -1,164 +0,0 @@ -#ifndef _EMU2413_H_ -#define _EMU2413_H_ - -#include "blargg_common.h" -#include "emutypes.h" - -#ifdef EMU2413_DLL_EXPORTS - #define EMU2413_API __declspec(dllexport) -#elif defined(EMU2413_DLL_IMPORTS) - #define EMU2413_API __declspec(dllimport) -#else - #define EMU2413_API -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -#define AUDIO_MONO_BUFFER_SIZE 1024 - -#define PI 3.14159265358979323846 - -enum OPLL_TONE_ENUM {OPLL_2413_TONE=0, OPLL_VRC7_TONE=1, OPLL_281B_TONE=2} ; - -/* voice data */ -typedef struct __OPLL_PATCH { - e_uint32 TL,FB,EG,ML,AR,DR,SL,RR,KR,KL,AM,PM,WF ; -} OPLL_PATCH ; - -/* slot */ -typedef struct __OPLL_SLOT { - - OPLL_PATCH *patch; - - e_int32 type ; /* 0 : modulator 1 : carrier */ - - /* OUTPUT */ - e_int32 feedback ; - e_int32 output[2] ; /* Output value of slot */ - - /* for Phase Generator (PG) */ - e_uint16 *sintbl ; /* Wavetable */ - e_uint32 phase ; /* Phase */ - e_uint32 dphase ; /* Phase increment amount */ - e_uint32 pgout ; /* output */ - - /* for Envelope Generator (EG) */ - e_int32 fnum ; /* F-Number */ - e_int32 block ; /* Block */ - e_int32 volume ; /* Current volume */ - e_int32 sustine ; /* Sustine 1 = ON, 0 = OFF */ - e_uint32 tll ; /* Total Level + Key scale level*/ - e_uint32 rks ; /* Key scale offset (Rks) */ - e_int32 eg_mode ; /* Current state */ - e_uint32 eg_phase ; /* Phase */ - e_uint32 eg_dphase ; /* Phase increment amount */ - e_uint32 egout ; /* output */ - -} OPLL_SLOT ; - -/* Mask */ -#define OPLL_MASK_CH(x) (1<<(x)) -#define OPLL_MASK_HH (1<<(9)) -#define OPLL_MASK_CYM (1<<(10)) -#define OPLL_MASK_TOM (1<<(11)) -#define OPLL_MASK_SD (1<<(12)) -#define OPLL_MASK_BD (1<<(13)) -#define OPLL_MASK_RHYTHM ( OPLL_MASK_HH | OPLL_MASK_CYM | OPLL_MASK_TOM | OPLL_MASK_SD | OPLL_MASK_BD ) - -/* opll */ -typedef struct __OPLL { - - e_uint32 adr ; - e_int32 out ; - -#ifndef EMU2413_COMPACTION - e_uint32 realstep ; - e_uint32 oplltime ; - e_uint32 opllstep ; - e_int32 prev, next ; - e_int32 sprev[2],snext[2]; - e_uint32 pan[16]; -#endif - - /* Register */ - e_uint8 reg[0x40] ; - e_int32 slot_on_flag[18] ; - - /* Pitch Modulator */ - e_uint32 pm_phase ; - e_int32 lfo_pm ; - - /* Amp Modulator */ - e_int32 am_phase ; - e_int32 lfo_am ; - - e_uint32 quality; - - /* Noise Generator */ - e_uint32 noise_seed ; - - /* Channel Data */ - e_int32 patch_number[9]; - e_int32 key_status[9] ; - - /* Slot */ - OPLL_SLOT slot[18] ; - - /* Voice Data */ - OPLL_PATCH patch[19*2] ; - e_int32 patch_update[2] ; /* flag for check patch update */ - - e_uint32 mask ; - e_uint32 current_mask; - e_uint32 status; - - e_uint32 internal_mute; - e_int16 buffer[AUDIO_MONO_BUFFER_SIZE]; -} OPLL ; - -/* Create Object */ -EMU2413_API void OPLL_new(OPLL *, e_uint32 clk, e_uint32 rate) ; -EMU2413_API void OPLL_delete(OPLL *) ; - -/* Setup */ -EMU2413_API void OPLL_reset(OPLL *) ; -EMU2413_API void OPLL_reset_patch(OPLL *, e_int32) ; -EMU2413_API void OPLL_set_rate(OPLL *opll, e_uint32 r) ; -EMU2413_API void OPLL_set_quality(OPLL *opll, e_uint32 q) ; -EMU2413_API void OPLL_set_pan(OPLL *, e_uint32 ch, e_uint32 pan); -EMU2413_API void OPLL_set_internal_mute(OPLL *, e_uint32 mute); -EMU2413_API e_uint32 OPLL_is_internal_muted(OPLL *); - -/* Port/Register access */ -EMU2413_API void OPLL_writeIO(OPLL *, e_uint32 reg, e_uint32 val); -EMU2413_API void OPLL_writeReg(OPLL *, e_uint32 reg, e_uint32 val); -EMU2413_API e_uint32 OPLL_read(OPLL *, e_uint32 port); - -/* Synthsize */ -EMU2413_API e_int16 OPLL_calc(OPLL *) EMU2413_CALC_ICODE; -EMU2413_API void OPLL_calc_stereo(OPLL *, e_int32 out[2]) ; -EMU2413_API e_int16 *OPLL_update_buffer(OPLL *, e_uint32 length) ; - -/* Misc */ -EMU2413_API void OPLL_setPatch(OPLL *, const e_uint8 *dump) ; -EMU2413_API void OPLL_copyPatch(OPLL *, e_int32, OPLL_PATCH *) ; -EMU2413_API void OPLL_forceRefresh(OPLL *) ; -/* Utility */ -EMU2413_API void OPLL_dump2patch(const e_uint8 *dump, OPLL_PATCH *patch) ; -EMU2413_API void OPLL_patch2dump(const OPLL_PATCH *patch, e_uint8 *dump) ; -EMU2413_API void OPLL_getDefaultPatch(e_int32 type, e_int32 num, OPLL_PATCH *) ; - -/* Channel Mask */ -EMU2413_API e_uint32 OPLL_setMask(OPLL *, e_uint32 mask) ; -EMU2413_API e_uint32 OPLL_toggleMask(OPLL *, e_uint32 mask) ; - -#define dump2patch OPLL_dump2patch - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/apps/codecs/libgme/emu8950.c b/apps/codecs/libgme/emu8950.c deleted file mode 100644 index 2f8a32044f..0000000000 --- a/apps/codecs/libgme/emu8950.c +++ /dev/null @@ -1,1206 +0,0 @@ -/* - * This file is based on: - * Y8950.cc -- Y8950 emulator from the openMSX team - * ported to c by gama - * - * The openMSX version is based on: - * emu8950.c -- Y8950 emulator written by Mitsutaka Okazaki 2001 - * heavily rewritten to fit openMSX structure - */ - -#include -#include "emu8950.h" - -#ifdef _MSC_VER -#pragma warning( disable : 4355 ) -#endif - -#if !defined(ROCKBOX) - #define EMU8950_CALCUL_TABLES -#else - #include "opltables.h" -#endif - -// dB to Liner table -static short dB2LinTab[(2*DB_MUTE)*2]; -// Dynamic range -static unsigned int dphaseNoiseTable[1024][8]; -// LFO Table -int pmtable[2][PM_PG_WIDTH]; -int amtable[2][AM_PG_WIDTH]; - -/** WaveTable for each envelope amp. */ -static int sintable[PG_WIDTH]; - /** Phase incr table for Attack. */ -static unsigned int dphaseARTable[16][16]; -/** Phase incr table for Decay and Release. */ -static unsigned int dphaseDRTable[16][16]; -/** KSL + TL Table. */ -#if !defined(ROCKBOX) -static unsigned char tllTable[16][8][1<> b; -} -// Leave the lower b bits -inline static int LOWBITS(int c, int b) -{ - return c & ((1<> 1; - #else - AR_ADJUST_TABLE[i] = ar_adjust_coeff[i-1]; - #endif -} - -// Table for dB(0 -- (1<> (21 - DP_BITS)), sampleRate, clockRate); -} -#endif - -#if !defined(ROCKBOX) -static void makeTllTable(void) -{ - #define dB2(x) (int)((x)*2) - static int kltable[16] = { - dB2( 0.000),dB2( 9.000),dB2(12.000),dB2(13.875), - dB2(15.000),dB2(16.125),dB2(16.875),dB2(17.625), - dB2(18.000),dB2(18.750),dB2(19.125),dB2(19.500), - dB2(19.875),dB2(20.250),dB2(20.625),dB2(21.000) - }; - - int fnum, block, TL, KL; - for (fnum=0; fnum<16; fnum++) - for (block=0; block<8; block++) - for (TL=0; TL<64; TL++) - for (KL=0; KL<4; KL++) { - if (KL==0) { - tllTable[fnum][block][TL][KL] = (ALIGN(TL, TL_STEP, EG_STEP) ) >> 1; - } else { - int tmp = kltable[fnum] - dB2(3.000) * (7 - block); - if (tmp <= 0) - tllTable[fnum][block][TL][KL] = (ALIGN(TL, TL_STEP, EG_STEP) ) >> 1; - else - tllTable[fnum][block][TL][KL] = ((int)((tmp>>(3-KL))/EG_STEP) + ALIGN(TL, TL_STEP, EG_STEP) ) >> 1; - } - } -} -#endif - -// Rate Table for Attack -static void makeDphaseARTable(int sampleRate, int clockRate) -{ - int AR, Rks; - for (AR=0; AR<16; AR++) - for (Rks=0; Rks<16; Rks++) { - int RM = AR + (Rks>>2); - int RL = Rks&3; - if (RM>15) RM=15; - switch (AR) { - case 0: - dphaseARTable[AR][Rks] = 0; - break; - case 15: - dphaseARTable[AR][Rks] = EG_DP_WIDTH; - break; - default: - dphaseARTable[AR][Rks] = rate_adjust((3*(RL+4) << (RM+1)), sampleRate, clockRate); - break; - } - } -} - -// Rate Table for Decay -static void makeDphaseDRTable(int sampleRate, int clockRate) -{ - int DR, Rks; - for (DR=0; DR<16; DR++) - for (Rks=0; Rks<16; Rks++) { - int RM = DR + (Rks>>2); - int RL = Rks&3; - if (RM>15) RM=15; - switch (DR) { - case 0: - dphaseDRTable[DR][Rks] = 0; - break; - default: - dphaseDRTable[DR][Rks] = rate_adjust((RL+4) << (RM-1), sampleRate, clockRate); - break; - } - } -} - -static void makeRksTable(void) -{ - int fnum9, block, KR; - for (fnum9=0; fnum9<2; fnum9++) - for (block=0; block<8; block++) - for (KR=0; KR<2; KR++) { - rksTable[fnum9][block][KR] = (KR != 0) ? - (block<<1) + fnum9: - block>>1; - } -} - -//**********************************************************// -// // -// Patch // -// // -//**********************************************************// - - -void patchReset(struct Patch* patch) -{ - patch->AM = patch->PM = patch->EG = false; - patch->KR = patch->ML = patch->KL = patch->TL = - patch->FB = patch->AR = patch->DR = patch->SL = patch->RR = 0; -} - - -//**********************************************************// -// // -// Slot // -// // -//**********************************************************// - - -static inline void slotUpdatePG(struct Slot* slot) -{ -#if defined(ROCKBOX) - static const int mltable[16] = { - 1,1*2,2*2,3*2,4*2,5*2,6*2,7*2,8*2,9*2,10*2,10*2,12*2,12*2,15*2,15*2 - }; - - slot->dphase = ((slot->fnum * mltable[slot->patch.ML]) << slot->block) >> (21 - DP_BITS); -#else - slot->dphase = dphaseTable[slot->fnum][slot->block][slot->patch.ML]; -#endif -} - -static inline void slotUpdateTLL(struct Slot* slot) -{ - slot->tll = (int)(tllTable[slot->fnum>>6][slot->block][slot->patch.TL][slot->patch.KL]) << 1; -} - -static inline void slotUpdateRKS(struct Slot* slot) -{ - slot->rks = rksTable[slot->fnum>>9][slot->block][slot->patch.KR]; -} - -static inline void slotUpdateEG(struct Slot* slot) -{ - switch (slot->eg_mode) { - case ATTACK: - slot->eg_dphase = dphaseARTable[slot->patch.AR][slot->rks]; - break; - case DECAY: - slot->eg_dphase = dphaseDRTable[slot->patch.DR][slot->rks]; - break; - case SUSTINE: - slot->eg_dphase = dphaseDRTable[slot->patch.RR][slot->rks]; - break; - case RELEASE: - slot->eg_dphase = slot->patch.EG ? - dphaseDRTable[slot->patch.RR][slot->rks]: - dphaseDRTable[7] [slot->rks]; - break; - case SUSHOLD: - case FINISH: - slot->eg_dphase = 0; - break; - } -} - -static inline void slotUpdateAll(struct Slot* slot) -{ - slotUpdatePG(slot); - slotUpdateTLL(slot); - slotUpdateRKS(slot); - slotUpdateEG(slot); // EG should be last -} - -void slotReset(struct Slot* slot) -{ - slot->phase = 0; - slot->dphase = 0; - slot->output[0] = 0; - slot->output[1] = 0; - slot->feedback = 0; - slot->eg_mode = FINISH; - slot->eg_phase = EG_DP_WIDTH; - slot->eg_dphase = 0; - slot->rks = 0; - slot->tll = 0; - slot->fnum = 0; - slot->block = 0; - slot->pgout = 0; - slot->egout = 0; - slot->slotStatus = false; - patchReset(&slot->patch); - slotUpdateAll(slot); -} - -// Slot key on -static inline void slotOn(struct Slot* slot) -{ - if (!slot->slotStatus) { - slot->slotStatus = true; - slot->eg_mode = ATTACK; - slot->phase = 0; - slot->eg_phase = 0; - } -} - -// Slot key off -static inline void slotOff(struct Slot* slot) -{ - if (slot->slotStatus) { - slot->slotStatus = false; - if (slot->eg_mode == ATTACK) - slot->eg_phase = EXPAND_BITS(AR_ADJUST_TABLE[HIGHBITS(slot->eg_phase, EG_DP_BITS-EG_BITS)], EG_BITS, EG_DP_BITS); - slot->eg_mode = RELEASE; - } -} - - -//**********************************************************// -// // -// OPLChannel // -// // -//**********************************************************// - - -void channelReset(struct OPLChannel* ch) -{ - slotReset(&ch->mod); - slotReset(&ch->car); - ch->alg = false; -} - -// Set F-Number ( fnum : 10bit ) -static void channelSetFnumber(struct OPLChannel* ch, int fnum) -{ - ch->car.fnum = fnum; - ch->mod.fnum = fnum; -} - -// Set Block data (block : 3bit ) -static void channelSetBlock(struct OPLChannel* ch, int block) -{ - ch->car.block = block; - ch->mod.block = block; -} - -// OPLChannel key on -static void keyOn(struct OPLChannel* ch) -{ - slotOn(&ch->mod); - slotOn(&ch->car); -} - -// OPLChannel key off -static void keyOff(struct OPLChannel* ch) -{ - slotOff(&ch->mod); - slotOff(&ch->car); -} - - -//**********************************************************// -// // -// Y8950 // -// // -//**********************************************************// - -void OPL_init(struct Y8950* this, byte* ramBank, int sampleRam) -{ - this->clockRate = CLK_FREQ; - - ADPCM_init(&this->adpcm, this, ramBank, sampleRam); - - makePmTable(); - makeAmTable(); - - makeAdjustTable(); - makeDB2LinTable(); -#if !defined(ROCKBOX) - makeTllTable(); -#endif - makeRksTable(); - makeSinTable(); - - int i; - for (i=0; i<9; i++) { - // TODO cleanup - this->slot[i*2+0] = &(this->ch[i].mod); - this->slot[i*2+1] = &(this->ch[i].car); - this->ch[i].mod.plfo_am = &this->lfo_am; - this->ch[i].mod.plfo_pm = &this->lfo_pm; - this->ch[i].car.plfo_am = &this->lfo_am; - this->ch[i].car.plfo_pm = &this->lfo_pm; - } - - OPL_reset(this); -} - -void OPL_setSampleRate(struct Y8950* this, int sampleRate, int clockRate) -{ - this->clockRate = clockRate; - ADPCM_setSampleRate(&this->adpcm, sampleRate, clockRate); - -#if !defined(ROCKBOX) - makeDphaseTable(sampleRate, clockRate); -#endif - makeDphaseARTable(sampleRate, clockRate); - makeDphaseDRTable(sampleRate, clockRate); - makeDphaseNoiseTable(sampleRate, clockRate); - this->pm_dphase = rate_adjust( (int)(PM_SPEED * PM_DP_WIDTH) / (clockRate/72), sampleRate, clockRate); - this->am_dphase = rate_adjust( (int)(AM_SPEED * AM_DP_WIDTH) / (clockRate/72), sampleRate, clockRate); -} - -// Reset whole of opl except patch datas. -void OPL_reset(struct Y8950* this) -{ - int i; - for (i=0; i<9; i++) - channelReset(&this->ch[i]); - this->output[0] = 0; - this->output[1] = 0; - - - this->dacSampleVolume = 0; - this->dacOldSampleVolume = 0; - this->dacSampleVolumeSum = 0; - this->dacCtrlVolume = 0; - this->dacDaVolume = 0; - this->dacEnabled = 0; - - this->rythm_mode = false; - this->am_mode = 0; - this->pm_mode = 0; - this->pm_phase = 0; - this->am_phase = 0; - this->noise_seed = 0xffff; - this->noiseA = 0; - this->noiseB = 0; - this->noiseA_phase = 0; - this->noiseB_phase = 0; - this->noiseA_dphase = 0; - this->noiseB_dphase = 0; - - for (i = 0; i < 0x100; ++i) - this->reg[i] = 0x00; - - this->reg[0x04] = 0x18; - this->reg[0x19] = 0x0F; // fixes 'Thunderbirds are Go' - this->status = 0x00; - this->statusMask = 0; - /* irq.reset(); */ - - ADPCM_reset(&this->adpcm); - OPL_setInternalMute(this, true); // muted -} - - -// Drum key on -static inline void keyOn_BD(struct Y8950* this) { keyOn(&this->ch[6]); } -static inline void keyOn_HH(struct Y8950* this) { slotOn(&this->ch[7].mod); } -static inline void keyOn_SD(struct Y8950* this) { slotOn(&this->ch[7].car); } -static inline void keyOn_TOM(struct Y8950* this) { slotOn(&this->ch[8].mod); } -static inline void keyOn_CYM(struct Y8950* this) { slotOn(&this->ch[8].car); } - -// Drum key off -static inline void keyOff_BD(struct Y8950* this) { keyOff(&this->ch[6]); } -static inline void keyOff_HH(struct Y8950* this) { slotOff(&this->ch[7].mod); } -static inline void keyOff_SD(struct Y8950* this) { slotOff(&this->ch[7].car); } -static inline void keyOff_TOM(struct Y8950* this){ slotOff(&this->ch[8].mod); } -static inline void keyOff_CYM(struct Y8950* this){ slotOff(&this->ch[8].car); } - -// Change Rhythm Mode -static inline void setRythmMode(struct Y8950* this, int data) -{ - bool newMode = (data & 32) != 0; - if (this->rythm_mode != newMode) { - this->rythm_mode = newMode; - if (!this->rythm_mode) { - // ON->OFF - this->ch[6].mod.eg_mode = FINISH; // BD1 - this->ch[6].mod.slotStatus = false; - this->ch[6].car.eg_mode = FINISH; // BD2 - this->ch[6].car.slotStatus = false; - this->ch[7].mod.eg_mode = FINISH; // HH - this->ch[7].mod.slotStatus = false; - this->ch[7].car.eg_mode = FINISH; // SD - this->ch[7].car.slotStatus = false; - this->ch[8].mod.eg_mode = FINISH; // TOM - this->ch[8].mod.slotStatus = false; - this->ch[8].car.eg_mode = FINISH; // CYM - this->ch[8].car.slotStatus = false; - } - } -} - -//********************************************************// -// // -// Generate wave data // -// // -//********************************************************// - -// Convert Amp(0 to EG_HEIGHT) to Phase(0 to 4PI). -inline static int wave2_4pi(int e) -{ - int shift = SLOT_AMP_BITS - PG_BITS - 1; - if (shift > 0) - return e >> shift; - else - return e << -shift; -} - -// Convert Amp(0 to EG_HEIGHT) to Phase(0 to 8PI). -inline static int wave2_8pi(int e) -{ - int shift = SLOT_AMP_BITS - PG_BITS - 2; - if (shift > 0) - return e >> shift; - else - return e << -shift; -} - -static inline void update_noise(struct Y8950* this) -{ - if (this->noise_seed & 1) - this->noise_seed ^= 0x24000; - this->noise_seed >>= 1; - this->whitenoise = this->noise_seed&1 ? DB_POS(6) : DB_NEG(6); - - this->noiseA_phase += this->noiseA_dphase; - this->noiseB_phase += this->noiseB_dphase; - - this->noiseA_phase &= (0x40<<11) - 1; - if ((this->noiseA_phase>>11)==0x3f) - this->noiseA_phase = 0; - this->noiseA = this->noiseA_phase&(0x03<<11)?DB_POS(6):DB_NEG(6); - - this->noiseB_phase &= (0x10<<11) - 1; - this->noiseB = this->noiseB_phase&(0x0A<<11)?DB_POS(6):DB_NEG(6); -} - -static inline void update_ampm(struct Y8950* this) -{ - this->pm_phase = (this->pm_phase + this->pm_dphase)&(PM_DP_WIDTH - 1); - this->am_phase = (this->am_phase + this->am_dphase)&(AM_DP_WIDTH - 1); - this->lfo_am = amtable[this->am_mode][HIGHBITS(this->am_phase, AM_DP_BITS - AM_PG_BITS)]; - this->lfo_pm = pmtable[this->pm_mode][HIGHBITS(this->pm_phase, PM_DP_BITS - PM_PG_BITS)]; -} - -static inline void calc_phase(struct Slot* slot) -{ - if (slot->patch.PM) - slot->phase += (slot->dphase * (*slot->plfo_pm)) >> PM_AMP_BITS; - else - slot->phase += slot->dphase; - slot->phase &= (DP_WIDTH - 1); - slot->pgout = HIGHBITS(slot->phase, DP_BASE_BITS); -} - -static inline void calc_envelope(struct Slot* slot) -{ - #define S2E(x) (ALIGN((unsigned int)(x/SL_STEP),SL_STEP,EG_STEP)<<(EG_DP_BITS-EG_BITS)) - static unsigned int SL[16] = { - S2E( 0), S2E( 3), S2E( 6), S2E( 9), S2E(12), S2E(15), S2E(18), S2E(21), - S2E(24), S2E(27), S2E(30), S2E(33), S2E(36), S2E(39), S2E(42), S2E(93) - }; - - switch (slot->eg_mode) { - case ATTACK: - slot->eg_phase += slot->eg_dphase; - if (EG_DP_WIDTH & slot->eg_phase) { - slot->egout = 0; - slot->eg_phase= 0; - slot->eg_mode = DECAY; - slotUpdateEG(slot); - } else { - slot->egout = AR_ADJUST_TABLE[HIGHBITS(slot->eg_phase, EG_DP_BITS - EG_BITS)]; - } - break; - - case DECAY: - slot->eg_phase += slot->eg_dphase; - slot->egout = HIGHBITS(slot->eg_phase, EG_DP_BITS - EG_BITS); - if (slot->eg_phase >= SL[slot->patch.SL]) { - if (slot->patch.EG) { - slot->eg_phase = SL[slot->patch.SL]; - slot->eg_mode = SUSHOLD; - slotUpdateEG(slot); - } else { - slot->eg_phase = SL[slot->patch.SL]; - slot->eg_mode = SUSTINE; - slotUpdateEG(slot); - } - slot->egout = HIGHBITS(slot->eg_phase, EG_DP_BITS - EG_BITS); - } - break; - - case SUSHOLD: - slot->egout = HIGHBITS(slot->eg_phase, EG_DP_BITS - EG_BITS); - if (!slot->patch.EG) { - slot->eg_mode = SUSTINE; - slotUpdateEG(slot); - } - break; - - case SUSTINE: - case RELEASE: - slot->eg_phase += slot->eg_dphase; - slot->egout = HIGHBITS(slot->eg_phase, EG_DP_BITS - EG_BITS); - if (slot->egout >= (1<eg_mode = FINISH; - slot->egout = (1<egout = (1<patch.AM) - slot->egout = ALIGN(slot->egout+slot->tll,EG_STEP,DB_STEP) + (*slot->plfo_am); - else - slot->egout = ALIGN(slot->egout+slot->tll,EG_STEP,DB_STEP); - if (slot->egout >= DB_MUTE) - slot->egout = DB_MUTE-1; -} - -inline static int calc_slot_car(struct Slot* slot, int fm) -{ - calc_envelope(slot); - calc_phase(slot); - if (slot->egout>=(DB_MUTE-1)) - return 0; - return dB2LinTab[sintable[(slot->pgout+wave2_8pi(fm))&(PG_WIDTH-1)] + slot->egout]; -} - -inline static int calc_slot_mod(struct Slot* slot) -{ - slot->output[1] = slot->output[0]; - calc_envelope(slot); - calc_phase(slot); - - if (slot->egout>=(DB_MUTE-1)) { - slot->output[0] = 0; - } else if (slot->patch.FB!=0) { - int fm = wave2_4pi(slot->feedback) >> (7-slot->patch.FB); - slot->output[0] = dB2LinTab[sintable[(slot->pgout+fm)&(PG_WIDTH-1)] + slot->egout]; - } else - slot->output[0] = dB2LinTab[sintable[slot->pgout] + slot->egout]; - - slot->feedback = (slot->output[1] + slot->output[0])>>1; - return slot->feedback; -} - -// TOM -inline static int calc_slot_tom(struct Slot* slot) -{ - calc_envelope(slot); - calc_phase(slot); - if (slot->egout>=(DB_MUTE-1)) - return 0; - return dB2LinTab[sintable[slot->pgout] + slot->egout]; -} - -// SNARE -inline static int calc_slot_snare(struct Slot* slot, int whitenoise) -{ - calc_envelope(slot); - calc_phase(slot); - if (slot->egout>=(DB_MUTE-1)) - return 0; - if (slot->pgout & (1<<(PG_BITS-1))) { - return (dB2LinTab[slot->egout] + dB2LinTab[slot->egout+whitenoise]) >> 1; - } else { - return (dB2LinTab[2*DB_MUTE + slot->egout] + dB2LinTab[slot->egout+whitenoise]) >> 1; - } -} - -// TOP-CYM -inline static int calc_slot_cym(struct Slot* slot, int a, int b) -{ - calc_envelope(slot); - if (slot->egout>=(DB_MUTE-1)) { - return 0; - } else { - return (dB2LinTab[slot->egout+a] + dB2LinTab[slot->egout+b]) >> 1; - } -} - -// HI-HAT -inline static int calc_slot_hat(struct Slot* slot, int a, int b, int whitenoise) -{ - calc_envelope(slot); - if (slot->egout>=(DB_MUTE-1)) { - return 0; - } else { - return (dB2LinTab[slot->egout+whitenoise] + dB2LinTab[slot->egout+a] + dB2LinTab[slot->egout+b]) >>2; - } -} - - -static inline int calcSample(struct Y8950* this, int channelMask) -{ - // while muted update_ampm() and update_noise() aren't called, probably ok - update_ampm(this); - update_noise(this); - - int mix = 0; - - if (this->rythm_mode) { - // TODO wasn't in original source either - calc_phase(&this->ch[7].mod); - calc_phase(&this->ch[8].car); - - if (channelMask & (1 << 6)) - mix += calc_slot_car(&this->ch[6].car, calc_slot_mod(&this->ch[6].mod)); - if (this->ch[7].mod.eg_mode != FINISH) - mix += calc_slot_hat(&this->ch[7].mod, this->noiseA, this->noiseB, this->whitenoise); - if (channelMask & (1 << 7)) - mix += calc_slot_snare(&this->ch[7].car, this->whitenoise); - if (this->ch[8].mod.eg_mode != FINISH) - mix += calc_slot_tom(&this->ch[8].mod); - if (channelMask & (1 << 8)) - mix += calc_slot_cym(&this->ch[8].car, this->noiseA, this->noiseB); - - channelMask &= (1<< 6) - 1; - mix *= 2; - } - struct OPLChannel *cp; - for (cp = this->ch; channelMask; channelMask >>=1, cp++) { - if (channelMask & 1) { - if (cp->alg) - mix += calc_slot_car(&cp->car, 0) + - calc_slot_mod(&cp->mod); - else - mix += calc_slot_car(&cp->car, - calc_slot_mod(&cp->mod)); - } - } - - mix += ADPCM_calcSample(&this->adpcm); - - return (mix*this->maxVolume) >> (DB2LIN_AMP_BITS - 1); -} - -static bool checkMuteHelper(struct Y8950* this) -{ - int i; - struct OPLChannel *ch = this->ch; - for (i = 0; i < 6; i++) { - if (ch[i].car.eg_mode != FINISH) return false; - } - if (!this->rythm_mode) { - for(i = 6; i < 9; i++) { - if (ch[i].car.eg_mode != FINISH) return false; - } - } else { - if (ch[6].car.eg_mode != FINISH) return false; - if (ch[7].mod.eg_mode != FINISH) return false; - if (ch[7].car.eg_mode != FINISH) return false; - if (ch[8].mod.eg_mode != FINISH) return false; - if (ch[8].car.eg_mode != FINISH) return false; - } - - return ADPCM_muted(&this->adpcm); -} - -static void checkMute(struct Y8950* this) -{ - bool mute = checkMuteHelper(this); - //PRT_DEBUG("Y8950: muted " << mute); - OPL_setInternalMute(this, mute); -} - -int* OPL_updateBuffer(struct Y8950* this, int length) -{ - //PRT_DEBUG("Y8950: update buffer"); - - if (OPL_isInternalMuted(this) && !this->dacEnabled) { - return 0; - } - - this->dacCtrlVolume = this->dacSampleVolume - this->dacOldSampleVolume + 0x3fe7 * this->dacCtrlVolume / 0x4000; - this->dacOldSampleVolume = this->dacSampleVolume; - - int channelMask = 0, i; - struct OPLChannel *ch = this->ch; - for (i = 9; i--; ) { - channelMask <<= 1; - if (ch[i].car.eg_mode != FINISH) channelMask |= 1; - } - - int* buf = this->buffer; - while (length--) { - int sample = calcSample(this, channelMask); - - this->dacCtrlVolume = 0x3fe7 * this->dacCtrlVolume / 0x4000; - this->dacDaVolume += 2 * (this->dacCtrlVolume - this->dacDaVolume) / 3; - sample += 48 * this->dacDaVolume; - *(buf++) = sample; - } - - this->dacEnabled = this->dacDaVolume; - - checkMute(this); - return this->buffer; -} - -void OPL_setInternalVolume(struct Y8950* this, short newVolume) -{ - this->maxVolume = newVolume; -} - -//**************************************************// -// // -// I/O Ctrl // -// // -//**************************************************// - -void OPL_writeReg(struct Y8950* this, byte rg, byte data) -{ - //PRT_DEBUG("Y8950 write " << (int)rg << " " << (int)data); - int stbl[32] = { - 0, 2, 4, 1, 3, 5,-1,-1, - 6, 8,10, 7, 9,11,-1,-1, - 12,14,16,13,15,17,-1,-1, - -1,-1,-1,-1,-1,-1,-1,-1 - }; - - //TODO only for registers that influence sound - //TODO also ADPCM - - switch (rg & 0xe0) { - case 0x00: { - switch (rg) { - case 0x01: // TEST - // TODO - // Y8950 MSX-AUDIO Test register $01 (write only) - // - // Bit Description - // - // 7 Reset LFOs - seems to force the LFOs to their initial values (eg. - // maximum amplitude, zero phase deviation) - // - // 6 something to do with ADPCM - bit 0 of the status register is - // affected by setting this bit (PCM BSY) - // - // 5 No effect? - Waveform select enable in YM3812 OPL2 so seems - // reasonable that this bit wouldn't have been used in OPL - // - // 4 No effect? - // - // 3 Faster LFOs - increases the frequencies of the LFOs and (maybe) - // the timers (cf. YM2151 test register) - // - // 2 Reset phase generators - No phase generator output, but envelope - // generators still work (can hear a transient when they are gated) - // - // 1 No effect? - // - // 0 Reset envelopes - Envelope generator outputs forced to maximum, - // so all enabled voices sound at maximum - this->reg[rg] = data; - break; - - case 0x02: // TIMER1 (reso. 80us) - this->reg[rg] = data; - break; - - case 0x03: // TIMER2 (reso. 320us) - this->reg[rg] = data; - break; - - case 0x04: // FLAG CONTROL - if (data & R04_IRQ_RESET) { - OPL_resetStatus(this, 0x78); // reset all flags - } else { - OPL_changeStatusMask(this, (~data) & 0x78); - this->reg[rg] = data; - } - break; - - case 0x06: // (KEYBOARD OUT) - this->reg[rg] = data; - break; - - case 0x07: // START/REC/MEM DATA/REPEAT/SP-OFF/-/-/RESET - case 0x08: // CSM/KEY BOARD SPLIT/-/-/SAMPLE/DA AD/64K/ROM - case 0x09: // START ADDRESS (L) - case 0x0A: // START ADDRESS (H) - case 0x0B: // STOP ADDRESS (L) - case 0x0C: // STOP ADDRESS (H) - case 0x0D: // PRESCALE (L) - case 0x0E: // PRESCALE (H) - case 0x0F: // ADPCM-DATA - case 0x10: // DELTA-N (L) - case 0x11: // DELTA-N (H) - case 0x12: // ENVELOP CONTROL - case 0x1A: // PCM-DATA - this->reg[rg] = data; - ADPCM_writeReg(&this->adpcm, rg, data); - break; - - case 0x15: // DAC-DATA (bit9-2) - this->reg[rg] = data; - if (this->reg[0x08] & 0x04) { - static int damp[] = { 256, 279, 304, 332, 362, 395, 431, 470 }; - int sample = (short)(256 * this->reg[0x15] + this->reg[0x16]) * 128 / damp[this->reg[0x17]]; - this->dacSampleVolume = sample; - this->dacEnabled = 1; - } - break; - case 0x16: // (bit1-0) - this->reg[rg] = data & 0xC0; - break; - case 0x17: // (exponent) - this->reg[rg] = data & 0x07; - break; - - case 0x18: // I/O-CONTROL (bit3-0) - // TODO - // 0 -> input - // 1 -> output - this->reg[rg] = data; - break; - - case 0x19: // I/O-DATA (bit3-0) - // TODO - this->reg[rg] = data; - break; - } - - break; - } - case 0x20: { - int s = stbl[rg&0x1f]; - if (s >= 0) { - this->slot[s]->patch.AM = (data>>7)&1; - this->slot[s]->patch.PM = (data>>6)&1; - this->slot[s]->patch.EG = (data>>5)&1; - this->slot[s]->patch.KR = (data>>4)&1; - this->slot[s]->patch.ML = (data)&15; - slotUpdateAll(this->slot[s]); - } - this->reg[rg] = data; - break; - } - case 0x40: { - int s = stbl[rg&0x1f]; - if (s >= 0) { - this->slot[s]->patch.KL = (data>>6)&3; - this->slot[s]->patch.TL = (data)&63; - slotUpdateAll(this->slot[s]); - } - this->reg[rg] = data; - break; - } - case 0x60: { - int s = stbl[rg&0x1f]; - if (s >= 0) { - this->slot[s]->patch.AR = (data>>4)&15; - this->slot[s]->patch.DR = (data)&15; - slotUpdateEG(this->slot[s]); - } - this->reg[rg] = data; - break; - } - case 0x80: { - int s = stbl[rg&0x1f]; - if (s >= 0) { - this->slot[s]->patch.SL = (data>>4)&15; - this->slot[s]->patch.RR = (data)&15; - slotUpdateEG(this->slot[s]); - } - this->reg[rg] = data; - break; - } - case 0xa0: { - if (rg==0xbd) { - this->am_mode = (data>>7)&1; - this->pm_mode = (data>>6)&1; - - setRythmMode(this, data); - if (this->rythm_mode) { - if (data&0x10) keyOn_BD(this); else keyOff_BD(this); - if (data&0x08) keyOn_SD(this); else keyOff_SD(this); - if (data&0x04) keyOn_TOM(this); else keyOff_TOM(this); - if (data&0x02) keyOn_CYM(this); else keyOff_CYM(this); - if (data&0x01) keyOn_HH(this); else keyOff_HH(this); - } - slotUpdateAll(&this->ch[6].mod); - slotUpdateAll(&this->ch[6].car); - slotUpdateAll(&this->ch[7].mod); - slotUpdateAll(&this->ch[7].car); - slotUpdateAll(&this->ch[8].mod); - slotUpdateAll(&this->ch[8].car); - - this->reg[rg] = data; - break; - } - if ((rg&0xf) > 8) { - // 0xa9-0xaf 0xb9-0xbf - break; - } - if (!(rg&0x10)) { - // 0xa0-0xa8 - int c = rg-0xa0; - int fNum = data + ((this->reg[rg+0x10]&3)<<8); - int block = (this->reg[rg+0x10]>>2)&7; - channelSetFnumber(&this->ch[c], fNum); - switch (c) { - case 7: this->noiseA_dphase = dphaseNoiseTable[fNum][block]; - break; - case 8: this->noiseB_dphase = dphaseNoiseTable[fNum][block]; - break; - } - slotUpdateAll(&this->ch[c].car); - slotUpdateAll(&this->ch[c].mod); - this->reg[rg] = data; - } else { - // 0xb0-0xb8 - int c = rg-0xb0; - int fNum = ((data&3)<<8) + this->reg[rg-0x10]; - int block = (data>>2)&7; - channelSetFnumber(&this->ch[c], fNum); - channelSetBlock(&this->ch[c], block); - switch (c) { - case 7: this->noiseA_dphase = dphaseNoiseTable[fNum][block]; - break; - case 8: this->noiseB_dphase = dphaseNoiseTable[fNum][block]; - break; - } - if (data&0x20) - keyOn(&this->ch[c]); - else - keyOff(&this->ch[c]); - slotUpdateAll(&this->ch[c].mod); - slotUpdateAll(&this->ch[c].car); - this->reg[rg] = data; - } - break; - } - case 0xc0: { - if (rg > 0xc8) - break; - int c = rg-0xC0; - this->slot[c*2]->patch.FB = (data>>1)&7; - this->ch[c].alg = data&1; - this->reg[rg] = data; - } - } - - //TODO only for registers that influence sound - checkMute(this); -} - -byte OPL_readReg(struct Y8950* this, byte rg) -{ - byte result; - switch (rg) { - case 0x05: // (KEYBOARD IN) - result = 0xff; - break; - - case 0x0f: // ADPCM-DATA - case 0x13: // ??? - case 0x14: // ??? - case 0x1a: // PCM-DATA - result = ADPCM_readReg(&this->adpcm, rg); - break; - - case 0x19: // I/O DATA TODO - /* result = ~(switchGetAudio() ? 0 : 0x04); */ - result = 0; - break; - default: - result = 255; - } - //PRT_DEBUG("Y8950 read " << (int)rg<<" "<<(int)result); - return result; -} - -byte OPL_readStatus(struct Y8950* this) -{ - OPL_setStatus(this, STATUS_BUF_RDY); // temp hack - byte tmp = this->status & (0x80 | this->statusMask); - //PRT_DEBUG("Y8950 read status " << (int)tmp); - return tmp | 0x06; // bit 1 and 2 are always 1 -} - - -void OPL_setStatus(struct Y8950* this, byte flags) -{ - this->status |= flags; - if (this->status & this->statusMask) { - this->status |= 0x80; - /* irq.set(); */ - } -} -void OPL_resetStatus(struct Y8950* this, byte flags) -{ - this->status &= ~flags; - if (!(this->status & this->statusMask)) { - this->status &= 0x7f; - /* irq.reset(); */ - } -} -void OPL_changeStatusMask(struct Y8950* this, byte newMask) -{ - this->statusMask = newMask; - this->status &= this->statusMask; - if (this->status) { - this->status |= 0x80; - /* irq.set(); */ - } else { - this->status &= 0x7f; - /* irq.reset(); */ - } -} diff --git a/apps/codecs/libgme/emu8950.h b/apps/codecs/libgme/emu8950.h deleted file mode 100644 index 02169050d2..0000000000 --- a/apps/codecs/libgme/emu8950.h +++ /dev/null @@ -1,248 +0,0 @@ -#ifndef __Y8950_HH__ -#define __Y8950_HH__ - -#include "blargg_common.h" -#include "emuadpcm.h" - -#define AUDIO_MONO_BUFFER_SIZE 1024 - -// Dynamic range of envelope -static const double EG_STEP = 0.1875; -#define EG_BITS 9 -#define EG_MUTE (1< - int *plfo_pm; - int *plfo_am; -}; - -void slotReset(struct Slot* slot); - - -struct OPLChannel { - bool alg; - struct Slot mod, car; -}; - -void channelReset(struct OPLChannel* ch); - - -struct Y8950 -{ - int adr; - int output[2]; - // Register - byte reg[0x100]; - bool rythm_mode; - // Pitch Modulator - int pm_mode; - unsigned int pm_phase; - // Amp Modulator - int am_mode; - unsigned int am_phase; - - // Noise Generator - int noise_seed; - int whitenoise; - int noiseA; - int noiseB; - unsigned int noiseA_phase; - unsigned int noiseB_phase; - unsigned int noiseA_dphase; - unsigned int noiseB_dphase; - - // Channel & Slot - struct OPLChannel ch[9]; - struct Slot *slot[18]; - - unsigned int pm_dphase; - int lfo_pm; - unsigned int am_dphase; - int lfo_am; - - int maxVolume; - bool internalMuted; - - int clockRate; - - /** STATUS Register. */ - byte status; - /** bit=0 -> masked. */ - byte statusMask; - /* MsxAudioIRQHelper irq; */ - - // ADPCM - struct Y8950Adpcm adpcm; - - /** 13-bit (exponential) DAC. */ - /* DACSound16S dac13; */ - - // DAC stuff - int dacSampleVolume; - int dacOldSampleVolume; - int dacSampleVolumeSum; - int dacCtrlVolume; - int dacDaVolume; - int dacEnabled; - - // Internal buffer - int buffer[AUDIO_MONO_BUFFER_SIZE]; -}; - -void OPL_init(struct Y8950* this_, byte* ramBank, int sampleRam); - -void OPL_reset(struct Y8950* this_); -void OPL_writeReg(struct Y8950* this_, byte reg, byte data); -byte OPL_readReg(struct Y8950* this_, byte reg); -byte OPL_readStatus(struct Y8950* this_); -static inline void OPL_setInternalMute(struct Y8950* this_, bool muted) { this_->internalMuted = muted; } -static inline bool OPL_isInternalMuted(struct Y8950* this_) { return this_->internalMuted; } - -void OPL_setSampleRate(struct Y8950* this_, int sampleRate, int clockRate); -int* OPL_updateBuffer(struct Y8950* this_, int length); - -// SoundDevice -void OPL_setInternalVolume(struct Y8950* this_, short maxVolume); - -void OPL_setStatus(struct Y8950* this_, byte flags); -void OPL_resetStatus(struct Y8950* this_, byte flags); -void OPL_changeStatusMask(struct Y8950* this_, byte newMask); - - -// Adjust envelope speed which depends on sampling rate -static inline unsigned int rate_adjust(int x, int rate, int clk) -{ - unsigned int tmp = (long long)x * clk / 72 / rate; -// assert (tmp <= 4294967295U); - return tmp; -} - -#endif diff --git a/apps/codecs/libgme/emuadpcm.c b/apps/codecs/libgme/emuadpcm.c deleted file mode 100644 index b426a74de5..0000000000 --- a/apps/codecs/libgme/emuadpcm.c +++ /dev/null @@ -1,297 +0,0 @@ -/* - * This file is based on: - * Y8950Adpcm.cc -- Y8950 ADPCM emulator from the openMSX team - * ported to c by gama - * - * The openMSX version is based on: - * emuadpcm.c -- Y8950 ADPCM emulator written by Mitsutaka Okazaki 2001 - * heavily rewritten to fit openMSX structure - */ - -#include - -#include "emuadpcm.h" -#include "emu8950.h" - -// Relative volume between ADPCM part and FM part, -// value experimentally found by Manuel Bilderbeek -const int ADPCM_VOLUME = 356; - -// Bitmask for register 0x07 -static const int R07_RESET = 0x01; -//static const int R07 = 0x02;. // not used -//static const int R07 = 0x04;. // not used -const int R07_SP_OFF = 0x08; -const int R07_REPEAT = 0x10; -const int R07_MEMORY_DATA = 0x20; -const int R07_REC = 0x40; -const int R07_START = 0x80; - -//Bitmask for register 0x08 -const int R08_ROM = 0x01; -const int R08_64K = 0x02; -const int R08_DA_AD = 0x04; -const int R08_SAMPL = 0x08; -//const int R08 = 0x10;. // not used -//const int R08 = 0x20;. // not used -const int R08_NOTE_SET = 0x40; -const int R08_CSM = 0x80; - -const int DMAX = 0x6000; -const int DMIN = 0x7F; -const int DDEF = 0x7F; - -const int DECODE_MAX = 32767; -const int DECODE_MIN = -32768; - -#define GETA_BITS 14 -#define MAX_STEP (1<<(16+GETA_BITS)) - - -//**************************************************// -// // -// Helper functions // -// // -//**************************************************// - -static int CLAP(int min, int x, int max) -{ - return (x < min) ? min : ((max < x) ? max : x); -} - -//**********************************************************// -// // -// Y8950Adpcm // -// // -//**********************************************************// - - -void ADPCM_init(struct Y8950Adpcm* this_, struct Y8950* y8950_, byte* ramBank, int sampleRam) - -{ - this_->y8950 = y8950_; - this_->ramBank = ramBank; - this_->ramSize = sampleRam; - memset(this_->ramBank, 0xFF, this_->ramSize); - this_->volume = 0; -} - -void restart(struct Y8950Adpcm* this_); -void ADPCM_reset(struct Y8950Adpcm* this_) -{ - this_->playing = false; - this_->startAddr = 0; - this_->stopAddr = 7; - this_->memPntr = 0; - this_->delta = 0; - this_->step = 0; - this_->addrMask = (1 << 19) - 1; - this_->reg7 = 0; - this_->reg15 = 0; - ADPCM_writeReg(this_, 0x12, 255); // volume - restart(this_); -} - -void ADPCM_setSampleRate(struct Y8950Adpcm* this_, int sr, int clk) -{ - this_->sampleRate = sr; - this_->clockRate = clk; -} - -bool ADPCM_muted(struct Y8950Adpcm* this_) -{ - return (!this_->playing) || (this_->reg7 & R07_SP_OFF); -} - -//**************************************************// -// // -// I/O Ctrl // -// // -//**************************************************// - -void restart(struct Y8950Adpcm* this_) -{ - this_->playAddr = this_->startAddr & this_->addrMask; - this_->nowStep = MAX_STEP - this_->step; - this_->out = this_->output = 0; - this_->diff = DDEF; - this_->nextLeveling = 0; - this_->sampleStep = 0; - this_->volumeWStep = (int)((long long)this_->volume * this_->step / MAX_STEP); -} - -void ADPCM_writeReg(struct Y8950Adpcm* this_, byte rg, byte data) -{ - switch (rg) { - case 0x07: // START/REC/MEM DATA/REPEAT/SP-OFF/-/-/RESET - this_->reg7 = data; - if (this_->reg7 & R07_RESET) { - this_->playing = false; - } else if (data & R07_START) { - this_->playing = true; - restart(this_); - } - break; - - case 0x08: // CSM/KEY BOARD SPLIT/-/-/SAMPLE/DA AD/64K/ROM - this_->romBank = data & R08_ROM; - this_->addrMask = data & R08_64K ? (1<<17)-1 : (1<<19)-1; - break; - - case 0x09: // START ADDRESS (L) - this_->startAddr = (this_->startAddr & 0x7F800) | (data << 3); - this_->memPntr = 0; - break; - case 0x0A: // START ADDRESS (H) - this_->startAddr = (this_->startAddr & 0x007F8) | (data << 11); - this_->memPntr = 0; - break; - - case 0x0B: // STOP ADDRESS (L) - this_->stopAddr = (this_->stopAddr & 0x7F807) | (data << 3); - break; - case 0x0C: // STOP ADDRESS (H) - this_->stopAddr = (this_->stopAddr & 0x007FF) | (data << 11); - break; - - - case 0x0F: // ADPCM-DATA - // TODO check this - //if ((reg7 & R07_REC) && (reg7 & R07_MEMORY_DATA)) { - { - int tmp = ((this_->startAddr + this_->memPntr) & this_->addrMask) / 2; - tmp = (tmp < this_->ramSize) ? tmp : (tmp & (this_->ramSize - 1)); - if (!this_->romBank) { - this_->ramBank[tmp] = data; - } - //PRT_DEBUG("Y8950Adpcm: mem " << tmp << " " << (int)data); - this_->memPntr += 2; - if ((this_->startAddr + this_->memPntr) > this_->stopAddr) { - OPL_setStatus(this_->y8950, STATUS_EOS); - } - } - OPL_setStatus(this_->y8950, STATUS_BUF_RDY); - break; - - case 0x10: // DELTA-N (L) - this_->delta = (this_->delta & 0xFF00) | data; - this_->step = rate_adjust(this_->delta<sampleRate, this_->clockRate); - this_->volumeWStep = (int)((long long)this_->volume * this_->step / MAX_STEP); - break; - case 0x11: // DELTA-N (H) - this_->delta = (this_->delta & 0x00FF) | (data << 8); - this_->step = rate_adjust(this_->delta<sampleRate, this_->clockRate); - this_->volumeWStep = (int)((long long)this_->volume * this_->step / MAX_STEP); - break; - - case 0x12: { // ENVELOP CONTROL - int oldVol = this_->volume; - this_->volume = (data * ADPCM_VOLUME) >> 8; - if (oldVol != 0) { - this_->output = (int)(((long long)this_->output * this_->volume) / oldVol); - this_->sampleStep = (int)(((long long)this_->sampleStep * this_->volume) / oldVol); - } - this_->volumeWStep = (int)((long long)this_->volume * this_->step / MAX_STEP); - break; - } - case 0x0D: // PRESCALE (L) - case 0x0E: // PRESCALE (H) - case 0x15: // DAC-DATA (bit9-2) - case 0x16: // (bit1-0) - case 0x17: // (exponent) - case 0x1A: // PCM-DATA - // not implemented - break; - } -} - -byte ADPCM_readReg(struct Y8950Adpcm* this_, byte rg) -{ - byte result; - switch (rg) { - case 0x0F: { // ADPCM-DATA - // TODO don't advance pointer when playing??? - int adr = ((this_->startAddr + this_->memPntr) & this_->addrMask) / 2; - if (this_->romBank || (adr >= this_->ramSize)) { - result = 0xFF; - } else { - result = this_->ramBank[adr]; - } - this_->memPntr += 2; - if ((this_->startAddr + this_->memPntr) > this_->stopAddr) { - OPL_setStatus(this_->y8950, STATUS_EOS); - } - break; - } - case 0x13: // TODO check - result = this_->out & 0xFF; - break; - case 0x14: // TODO check - result = this_->out / 256; - break; - default: - result = 255; - } - //PRT_DEBUG("Y8950Adpcm: read "<<(int)rg<<" "<<(int)result); - return result; -} - -int ADPCM_calcSample(struct Y8950Adpcm* this_) -{ - // This table values are from ymdelta.c by Tatsuyuki Satoh. - static const int F1[16] = { 1, 3, 5, 7, 9, 11, 13, 15, - -1, -3, -5, -7, -9, -11, -13, -15}; - static const int F2[16] = {57, 57, 57, 57, 77, 102, 128, 153, - 57, 57, 57, 57, 77, 102, 128, 153}; - - if (ADPCM_muted(this_)) { - return 0; - } - this_->nowStep += this_->step; - if (this_->nowStep >= MAX_STEP) { - int nowLeveling; - do { - this_->nowStep -= MAX_STEP; - unsigned long val; - if (!(this_->playAddr & 1)) { - // n-th nibble - int tmp = this_->playAddr / 2; - if (this_->romBank || (tmp >= this_->ramSize)) { - this_->reg15 = 0xFF; - } else { - this_->reg15 = this_->ramBank[tmp]; - } - val = this_->reg15 >> 4; - } else { - // (n+1)-th nibble - val = this_->reg15 & 0x0F; - } - int prevOut = this_->out; - this_->out = CLAP(DECODE_MIN, this_->out + (this_->diff * F1[val]) / 8, - DECODE_MAX); - this_->diff = CLAP(DMIN, (this_->diff * F2[val]) / 64, DMAX); - int deltaNext = this_->out - prevOut; - nowLeveling = this_->nextLeveling; - this_->nextLeveling = prevOut + deltaNext / 2; - - this_->playAddr++; - if (this_->playAddr > this_->stopAddr) { - if (this_->reg7 & R07_REPEAT) { - restart(this_); - } else { - this_->playing = false; - //y8950.setStatus(Y8950::STATUS_EOS); - } - } - } while (this_->nowStep >= MAX_STEP); - this_->sampleStep = (this_->nextLeveling - nowLeveling) * this_->volumeWStep; - this_->output = nowLeveling * this_->volume; - - /* TODO: Used fixed point math here */ - #if !defined(ROCKBOX) - this_->output += (int)(((long long)this_->sampleStep * this_->nowStep) / this_->step); - #endif - } - this_->output += this_->sampleStep; - return this_->output >> 12; -} diff --git a/apps/codecs/libgme/emuadpcm.h b/apps/codecs/libgme/emuadpcm.h deleted file mode 100644 index 0fc39a1709..0000000000 --- a/apps/codecs/libgme/emuadpcm.h +++ /dev/null @@ -1,52 +0,0 @@ -#ifndef __Y8950ADPCM_HH__ -#define __Y8950ADPCM_HH__ - -#include "blargg_common.h" -#include "blargg_source.h" -#include "msxtypes.h" - -typedef unsigned short word; -typedef unsigned __int64 uint64; -struct Y8950; - -struct Y8950Adpcm -{ - struct Y8950* y8950; - - int sampleRate; - int clockRate; - - int ramSize; - int startAddr; - int stopAddr; - int playAddr; - int addrMask; - int memPntr; - bool romBank; - byte* ramBank; - - bool playing; - int volume; - word delta; - unsigned int nowStep, step; - int out, output; - int diff; - int nextLeveling; - int sampleStep; - int volumeWStep; - - byte reg7; - byte reg15; -}; - - -void ADPCM_init(struct Y8950Adpcm* this_, struct Y8950* y8950, byte* ramBank, int sampleRam); -void ADPCM_reset(struct Y8950Adpcm* this_); -void ADPCM_setSampleRate(struct Y8950Adpcm* this_, int sr, int clk); -bool ADPCM_muted(struct Y8950Adpcm* this_); -void ADPCM_writeReg(struct Y8950Adpcm* this_, byte rg, byte data); -byte ADPCM_readReg(struct Y8950Adpcm* this_, byte rg); -int ADPCM_calcSample(struct Y8950Adpcm* this_); - - -#endif diff --git a/apps/codecs/libgme/emutables.h b/apps/codecs/libgme/emutables.h deleted file mode 100644 index 739c8c390a..0000000000 --- a/apps/codecs/libgme/emutables.h +++ /dev/null @@ -1,210 +0,0 @@ -#ifndef _EMUTABLES_H_ -#define _EMUTABLES_H_ - -/* Precalculated emu2413 tables for use in Rockbox, - Calculated for 44Khz sampling rate */ - -#include "emutypes.h" - -static const e_uint16 sin_coeff[] = { - 255, 203, 171, 152, 139, 129, 120, - 113, 107, 102, 97, 92, 88, 85, - 81, 78, 75, 72, 70, 67, 65, - 63, 61, 59, 57, 55, 53, 52, - 50, 48, 47, 45, 44, 43, 41, - 40, 39, 38, 37, 35, 34, 33, - 32, 31, 30, 29, 28, 28, 27, - 26, 25, 24, 23, 23, 22, 21, - 21, 20, 19, 19, 18, 17, 17, - 16, 16, 15, 14, 14, 13, 13, - 12, 12, 11, 11, 11, 10, 10, - 9, 9, 8, 8, 8, 7, 7, - 7, 6, 6, 6, 5, 5, 5, - 4, 4, 4, 4, 3, 3, 3, - 3, 2, 2, 2, 2, 2, 2, - 1, 1, 1, 1, 1, 1, 1, - 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, - 0, 0, -}; - -static const e_int16 pm_coeff[] = { - 256, 256, 256, 256, 256, 256, 256, - 256, 256, 256, 256, 256, 256, 256, - 256, 256, 256, 256, 256, 256, 256, - 256, 256, 256, 256, 256, 256, 256, - 256, 256, 256, 256, 257, 257, 257, - 257, 257, 257, 257, 257, 257, 257, - 257, 257, 257, 257, 257, 257, 257, - 257, 257, 257, 257, 257, 257, 257, - 257, 257, 257, 257, 257, 257, 257, - 258, 258, 258, 257, 257, 257, 257, - 257, 257, 257, 257, 257, 257, 257, - 257, 257, 257, 257, 257, 257, 257, - 257, 257, 257, 257, 257, 257, 257, - 257, 257, 257, 257, 257, 257, 256, - 256, 256, 256, 256, 256, 256, 256, - 256, 256, 256, 256, 256, 256, 256, - 256, 256, 256, 256, 256, 256, 256, - 256, 256, 256, 256, 256, 256, 256, - 256, 256, 256, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 254, - 254, 254, 254, 254, 254, 254, 254, - 254, 254, 254, 254, 254, 254, 254, - 254, 254, 254, 254, 254, 254, 254, - 254, 254, 254, 254, 254, 254, 254, - 254, 254, 254, 253, 254, 254, 254, - 254, 254, 254, 254, 254, 254, 254, - 254, 254, 254, 254, 254, 254, 254, - 254, 254, 254, 254, 254, 254, 254, - 254, 254, 254, 254, 254, 254, 254, - 254, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, -}; - -static const e_int8 am_coeff[] = { - 13, 13, 13, 13, 13, 14, 14, - 14, 14, 14, 15, 15, 15, 15, - 15, 16, 16, 16, 16, 16, 17, - 17, 17, 17, 17, 18, 18, 18, - 18, 18, 19, 19, 19, 19, 19, - 20, 20, 20, 20, 20, 21, 21, - 21, 21, 21, 22, 22, 22, 22, - 22, 23, 23, 23, 23, 23, 24, - 24, 24, 24, 24, 25, 25, 25, - 25, 26, 25, 25, 25, 25, 24, - 24, 24, 24, 24, 23, 23, 23, - 23, 23, 22, 22, 22, 22, 22, - 21, 21, 21, 21, 21, 20, 20, - 20, 20, 20, 19, 19, 19, 19, - 19, 18, 18, 18, 18, 18, 17, - 17, 17, 17, 17, 16, 16, 16, - 16, 16, 15, 15, 15, 15, 15, - 14, 14, 14, 14, 14, 13, 13, - 13, 13, 13, 12, 12, 12, 12, - 11, 11, 11, 11, 11, 10, 10, - 10, 10, 10, 9, 9, 9, 9, - 9, 8, 8, 8, 8, 8, 7, - 7, 7, 7, 7, 6, 6, 6, - 6, 6, 5, 5, 5, 5, 5, - 4, 4, 4, 4, 4, 3, 3, - 3, 3, 3, 2, 2, 2, 2, - 2, 1, 1, 1, 1, 1, 0, - 0, 0, 0, 0, 0, 0, 0, - 0, 1, 1, 1, 1, 1, 2, - 2, 2, 2, 2, 3, 3, 3, - 3, 3, 4, 4, 4, 4, 4, - 5, 5, 5, 5, 5, 6, 6, - 6, 6, 6, 7, 7, 7, 7, - 7, 8, 8, 8, 8, 8, 9, - 9, 9, 9, 9, 10, 10, 10, - 10, 10, 11, 11, 11, 11, 11, - 12, 12, 12, 12, -}; - -static const e_int16 db2lin_coeff[] = { - 255, 249, 244, 239, 233, 228, 224, - 219, 214, 209, 205, 201, 196, 192, - 188, 184, 180, 176, 172, 169, 165, - 162, 158, 155, 151, 148, 145, 142, - 139, 136, 133, 130, 127, 125, 122, - 119, 117, 114, 112, 109, 107, 105, - 102, 100, 98, 96, 94, 92, 90, - 88, 86, 84, 82, 81, 79, 77, - 76, 74, 72, 71, 69, 68, 66, - 65, 64, 62, 61, 60, 58, 57, - 56, 55, 53, 52, 51, 50, 49, - 48, 47, 46, 45, 44, 43, 42, - 41, 40, 39, 38, 38, 37, 36, - 35, 34, 34, 33, 32, 32, 31, - 30, 30, 29, 28, 28, 27, 27, - 26, 25, 25, 24, 24, 23, 23, - 22, 22, 21, 21, 20, 20, 19, - 19, 19, 18, 18, 17, 17, 17, - 16, 16, 16, 15, 15, 15, 14, - 14, 14, 13, 13, 13, 12, 12, - 12, 12, 11, 11, 11, 11, 10, - 10, 10, 10, 10, 9, 9, 9, - 9, 8, 8, 8, 8, 8, 8, - 7, 7, 7, 7, 7, 7, 6, - 6, 6, 6, 6, 6, 6, 5, - 5, 5, 5, 5, 5, 5, 5, - 5, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, - 2, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 0, 0, - 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, - 0, -}; - -static const e_uint16 ar_adjust_coeff[] = { - 127, 108, 98, 90, 84, 80, 75, - 72, 69, 66, 64, 61, 59, 57, - 56, 54, 52, 51, 49, 48, 47, - 45, 44, 43, 42, 41, 40, 39, - 38, 37, 36, 36, 35, 34, 33, - 33, 32, 31, 30, 30, 29, 29, - 28, 27, 27, 26, 26, 25, 24, - 24, 23, 23, 22, 22, 21, 21, - 21, 20, 20, 19, 19, 18, 18, - 17, 17, 17, 16, 16, 15, 15, - 15, 14, 14, 14, 13, 13, 13, - 12, 12, 12, 11, 11, 11, 10, - 10, 10, 9, 9, 9, 9, 8, - 8, 8, 7, 7, 7, 7, 6, - 6, 6, 6, 5, 5, 5, 4, - 4, 4, 4, 4, 3, 3, 3, - 3, 2, 2, 2, 2, 1, 1, - 1, 1, 1, 0, 0, 0, 0, - 0, -}; - -#endif diff --git a/apps/codecs/libgme/emutypes.h b/apps/codecs/libgme/emutypes.h deleted file mode 100644 index bc523db072..0000000000 --- a/apps/codecs/libgme/emutypes.h +++ /dev/null @@ -1,41 +0,0 @@ -#ifndef _EMUTYPES_H_ -#define _EMUTYPES_H_ - -#if defined(_MSC_VER) -#define INLINE __forceinline -#elif defined(__GNUC__) -#define INLINE __inline__ -#elif defined(_MWERKS_) -#define INLINE inline -#else -#define INLINE -#endif - -#if defined(EMU_DLL_IMPORTS) -#define EMU2149_DLL_IMPORTS -#define EMU2212_DLL_IMPORTS -#define EMU2413_DLL_IMPORTS -#define EMU8950_DLL_IMPORTS -#define EMU76489_DLL_IMPORTS -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -typedef unsigned int e_uint; -typedef signed int e_int; - -typedef unsigned char e_uint8 ; -typedef signed char e_int8 ; - -typedef unsigned short e_uint16 ; -typedef signed short e_int16 ; - -typedef unsigned int e_uint32 ; -typedef signed int e_int32 ; - -#ifdef __cplusplus -} -#endif -#endif diff --git a/apps/codecs/libgme/gb_apu.c b/apps/codecs/libgme/gb_apu.c deleted file mode 100644 index e8bf3afcf5..0000000000 --- a/apps/codecs/libgme/gb_apu.c +++ /dev/null @@ -1,410 +0,0 @@ -// Gb_Snd_Emu 0.1.4. http://www.slack.net/~ant/ - -#include "gb_apu.h" - -//#include "gb_apu_logger.h" - -/* Copyright (C) 2003-2008 Shay Green. This module is free software; you -can redistribute it and/or modify it under the terms of the GNU Lesser -General Public License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. This -module is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more -details. You should have received a copy of the GNU Lesser General Public -License along with this module; if not, write to the Free Software Foundation, -Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ - -#include "blargg_source.h" - -int const vol_reg = 0xFF24; -int const stereo_reg = 0xFF25; -int const status_reg = 0xFF26; -int const wave_ram = 0xFF30; - -int const power_mask = 0x80; - -static inline int calc_output( struct Gb_Apu* this, int osc ) -{ - int bits = this->regs [stereo_reg - io_addr] >> osc; - return (bits >> 3 & 2) | (bits & 1); -} - -void Apu_set_output( struct Gb_Apu* this, int i, struct Blip_Buffer* center, struct Blip_Buffer* left, struct Blip_Buffer* right ) -{ - // Must be silent (all NULL), mono (left and right NULL), or stereo (none NULL) - require( !center || (center && !left && !right) || (center && left && right) ); - require( (unsigned) i < osc_count ); // fails if you pass invalid osc index - - if ( !center || !left || !right ) - { - left = center; - right = center; - } - - struct Gb_Osc* o = this->oscs [i]; - o->outputs [1] = right; - o->outputs [2] = left; - o->outputs [3] = center; - o->output = o->outputs [calc_output( this, i )]; -} - -static void synth_volume( struct Gb_Apu* this, int iv ) -{ - int v = (this->volume_ * 6) / 10 / osc_count / 15 /*steps*/ / 8 /*master vol range*/ * iv; - Synth_volume( &this->synth, v ); -} - -static void apply_volume( struct Gb_Apu* this ) -{ - // TODO: Doesn't handle differing left and right volumes (panning). - // Not worth the complexity. - int data = this->regs [vol_reg - io_addr]; - int left = data >> 4 & 7; - int right = data & 7; - //if ( data & 0x88 ) dprintf( "Vin: %02X\n", data & 0x88 ); - //if ( left != right ) dprintf( "l: %d r: %d\n", left, right ); - synth_volume( this, max( left, right ) + 1 ); -} - -void Apu_volume( struct Gb_Apu* this, int v ) -{ - if ( this->volume_ != v ) - { - this->volume_ = v; - apply_volume( this ); - } -} - -static void reset_regs( struct Gb_Apu* this ) -{ - int i; - for ( i = 0; i < 0x20; i++ ) - this->regs [i] = 0; - - Sweep_reset ( &this->square1 ); - Square_reset( &this->square2 ); - Wave_reset ( &this->wave ); - Noise_reset ( &this->noise ); - - apply_volume( this ); -} - -static void reset_lengths( struct Gb_Apu* this ) -{ - this->square1.osc.length_ctr = 64; - this->square2.osc.length_ctr = 64; - this->wave .osc.length_ctr = 256; - this->noise .osc.length_ctr = 64; -} - -void Apu_reduce_clicks( struct Gb_Apu* this, bool reduce ) -{ - this->reduce_clicks_ = reduce; - - // Click reduction makes DAC off generate same output as volume 0 - int dac_off_amp = 0; - if ( reduce && this->wave.osc.mode != mode_agb ) // AGB already eliminates clicks - dac_off_amp = -dac_bias; - - int i; - for ( i = 0; i < osc_count; i++ ) - this->oscs [i]->dac_off_amp = dac_off_amp; - - // AGB always eliminates clicks on wave channel using same method - if ( this->wave.osc.mode == mode_agb ) - this->wave.osc.dac_off_amp = -dac_bias; -} - -void Apu_reset( struct Gb_Apu* this, enum gb_mode_t mode, bool agb_wave ) -{ - // Hardware mode - if ( agb_wave ) - mode = mode_agb; // using AGB wave features implies AGB hardware - this->wave.agb_mask = agb_wave ? 0xFF : 0; - int i; - for ( i = 0; i < osc_count; i++ ) - this->oscs [i]->mode = mode; - Apu_reduce_clicks( this, this->reduce_clicks_ ); - - // Reset state - this->frame_time = 0; - this->last_time = 0; - this->frame_phase = 0; - - reset_regs( this ); - reset_lengths( this ); - - // Load initial wave RAM - static byte const initial_wave [2] [16] = { - {0x84,0x40,0x43,0xAA,0x2D,0x78,0x92,0x3C,0x60,0x59,0x59,0xB0,0x34,0xB8,0x2E,0xDA}, - {0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF}, - }; - int b; - for ( b = 2; --b >= 0; ) - { - // Init both banks (does nothing if not in AGB mode) - // TODO: verify that this works - Apu_write_register( this, 0, 0xFF1A, b * 0x40 ); - unsigned i; - for ( i = 0; i < sizeof initial_wave [0]; i++ ) - Apu_write_register( this, 0, i + wave_ram, initial_wave [(mode != mode_dmg)] [i] ); - } -} - -void Apu_set_tempo( struct Gb_Apu* this, int t ) -{ - this->frame_period = 4194304 / 512; // 512 Hz - if ( t != (int)FP_ONE_TEMPO ) - this->frame_period = t ? (blip_time_t) ((this->frame_period * FP_ONE_TEMPO) / t) : (blip_time_t) (0); -} - -void Apu_init( struct Gb_Apu* this ) -{ - this->wave.wave_ram = &this->regs [wave_ram - io_addr]; - - Synth_init( &this->synth ); - - this->oscs [0] = &this->square1.osc; - this->oscs [1] = &this->square2.osc; - this->oscs [2] = &this->wave.osc; - this->oscs [3] = &this->noise.osc; - - int i; - for ( i = osc_count; --i >= 0; ) - { - struct Gb_Osc* o = this->oscs [i]; - o->regs = &this->regs [i * 5]; - o->output = NULL; - o->outputs [0] = NULL; - o->outputs [1] = NULL; - o->outputs [2] = NULL; - o->outputs [3] = NULL; - o->synth = &this->synth; - } - - this->reduce_clicks_ = false; - Apu_set_tempo( this, (int)FP_ONE_TEMPO ); - this->volume_ = (int)FP_ONE_VOLUME; - Apu_reset( this, mode_cgb, false ); -} - -static void run_until_( struct Gb_Apu* this, blip_time_t end_time ) -{ - if ( !this->frame_period ) - this->frame_time += end_time - this->last_time; - - while ( true ) - { - // run oscillators - blip_time_t time = end_time; - if ( time > this->frame_time ) - time = this->frame_time; - - Square_run( &this->square1, this->last_time, time ); - Square_run( &this->square2, this->last_time, time ); - Wave_run ( &this->wave, this->last_time, time ); - Noise_run ( &this->noise, this->last_time, time ); - this->last_time = time; - - if ( time == end_time ) - break; - - // run frame sequencer - assert( this->frame_period ); - this->frame_time += this->frame_period * clk_mul; - switch ( this->frame_phase++ ) - { - case 2: - case 6: - // 128 Hz - clock_sweep( &this->square1 ); - case 0: - case 4: - // 256 Hz - Osc_clock_length( &this->square1.osc ); - Osc_clock_length( &this->square2.osc); - Osc_clock_length( &this->wave.osc); - Osc_clock_length( &this->noise.osc); - break; - - case 7: - // 64 Hz - this->frame_phase = 0; - Square_clock_envelope( &this->square1 ); - Square_clock_envelope( &this->square2 ); - Noise_clock_envelope( &this->noise ); - } - } -} - -static inline void run_until( struct Gb_Apu* this, blip_time_t time ) -{ - require( time >= this->last_time ); // end_time must not be before previous time - if ( time > this->last_time ) - run_until_( this, time ); -} - -void Apu_end_frame( struct Gb_Apu* this, blip_time_t end_time ) -{ - #ifdef LOG_FRAME - LOG_FRAME( end_time ); - #endif - - if ( end_time > this->last_time ) - run_until( this, end_time ); - - this->frame_time -= end_time; - assert( this->frame_time >= 0 ); - - this->last_time -= end_time; - assert( this->last_time >= 0 ); -} - -static void silence_osc( struct Gb_Apu* this, struct Gb_Osc* o ) -{ - int delta = -o->last_amp; - if ( this->reduce_clicks_ ) - delta += o->dac_off_amp; - - if ( delta ) - { - o->last_amp = o->dac_off_amp; - if ( o->output ) - { - Blip_set_modified( o->output ); - Synth_offset( &this->synth, this->last_time, delta, o->output ); - } - } -} - -static void apply_stereo( struct Gb_Apu* this ) -{ - int i; - for ( i = osc_count; --i >= 0; ) - { - struct Gb_Osc* o = this->oscs [i]; - struct Blip_Buffer* out = o->outputs [calc_output( this, i )]; - if ( o->output != out ) - { - silence_osc( this, o ); - o->output = out; - } - } -} - -void Apu_write_register( struct Gb_Apu* this, blip_time_t time, int addr, int data ) -{ - require( (unsigned) data < 0x100 ); - - int reg = addr - io_addr; - if ( (unsigned) reg >= io_size ) - { - require( false ); - return; - } - - #ifdef LOG_WRITE - LOG_WRITE( time, addr, data ); - #endif - - if ( addr < status_reg && !(this->regs [status_reg - io_addr] & power_mask) ) - { - // Power is off - - // length counters can only be written in DMG mode - if ( this->wave.osc.mode != mode_dmg || (reg != 1 && reg != 5+1 && reg != 10+1 && reg != 15+1) ) - return; - - if ( reg < 10 ) - data &= 0x3F; // clear square duty - } - - run_until( this, time ); - - if ( addr >= wave_ram ) - { - Wave_write( &this->wave, addr, data ); - } - else - { - int old_data = this->regs [reg]; - this->regs [reg] = data; - - if ( addr < vol_reg ) - { - // Oscillator - write_osc( this, reg, old_data, data ); - } - else if ( addr == vol_reg && data != old_data ) - { - // Master volume - int i; - for ( i = osc_count; --i >= 0; ) - silence_osc( this, this->oscs [i] ); - - apply_volume( this ); - } - else if ( addr == stereo_reg ) - { - // Stereo panning - apply_stereo( this ); - } - else if ( addr == status_reg && (data ^ old_data) & power_mask ) - { - // Power control - this->frame_phase = 0; - int i; - for ( i = osc_count; --i >= 0; ) - silence_osc( this, this->oscs [i] ); - - reset_regs( this ); - if ( this->wave.osc.mode != mode_dmg ) - reset_lengths( this ); - - this->regs [status_reg - io_addr] = data; - } - } -} - -int Apu_read_register( struct Gb_Apu* this, blip_time_t time, int addr ) -{ - if ( addr >= status_reg ) - run_until( this, time ); - - int reg = addr - io_addr; - if ( (unsigned) reg >= io_size ) - { - require( false ); - return 0; - } - - if ( addr >= wave_ram ) - return Wave_read( &this->wave, addr ); - - // Value read back has some bits always set - static byte const masks [] = { - 0x80,0x3F,0x00,0xFF,0xBF, - 0xFF,0x3F,0x00,0xFF,0xBF, - 0x7F,0xFF,0x9F,0xFF,0xBF, - 0xFF,0xFF,0x00,0x00,0xBF, - 0x00,0x00,0x70, - 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF - }; - int mask = masks [reg]; - if ( this->wave.agb_mask && (reg == 10 || reg == 12) ) - mask = 0x1F; // extra implemented bits in wave regs on AGB - int data = this->regs [reg] | mask; - - // Status register - if ( addr == status_reg ) - { - data &= 0xF0; - data |= (int) this->square1.osc.enabled << 0; - data |= (int) this->square2.osc.enabled << 1; - data |= (int) this->wave .osc.enabled << 2; - data |= (int) this->noise .osc.enabled << 3; - } - - return data; -} diff --git a/apps/codecs/libgme/gb_apu.h b/apps/codecs/libgme/gb_apu.h deleted file mode 100644 index 69307b9840..0000000000 --- a/apps/codecs/libgme/gb_apu.h +++ /dev/null @@ -1,85 +0,0 @@ -// Nintendo Game Boy sound hardware emulator with save state support - -// Gb_Snd_Emu 0.1.4 -#ifndef GB_APU_H -#define GB_APU_H - -#include "gb_oscs.h" - -// Clock rate sound hardware runs at -enum { clock_rate = 4194304 * GB_APU_OVERCLOCK }; - -// Registers are at io_addr to io_addr+io_size-1 -enum { io_addr = 0xFF10 }; -enum { io_size = 0x30 }; -enum { regs_size = io_size + 0x10 }; - -enum gb_mode_t { - mode_dmg, // Game Boy monochrome - mode_cgb, // Game Boy Color - mode_agb // Game Boy Advance -}; - -// 0: Square 1, 1: Square 2, 2: Wave, 3: Noise -enum { osc_count = 4 }; // 0 <= chan < osc_count - -struct Gb_Apu { - struct Gb_Osc* oscs [osc_count]; - blip_time_t last_time; // time sound emulator has been run to - blip_time_t frame_period; // clocks between each frame sequencer step - int volume_; - bool reduce_clicks_; - - struct Gb_Square square1; - struct Gb_Square square2; - struct Gb_Wave wave; - struct Gb_Noise noise; - blip_time_t frame_time; // time of next frame sequencer action - int frame_phase; // phase of next frame sequencer step - - uint8_t regs [regs_size];// last values written to registers - - // large objects after everything else - struct Blip_Synth synth; -}; - -// Basics - -// Initializes apu -void Apu_init( struct Gb_Apu* this ); - -// Emulates to time t, then writes data to addr -void Apu_write_register( struct Gb_Apu* this, blip_time_t t, int addr, int data ); - -// Emulates to time t, then subtracts t from the current time. -// OK if previous write call had time slightly after t. -void Apu_end_frame( struct Gb_Apu* this,blip_time_t t ); - -// More features - -// Emulates to time t, then reads from addr -int Apu_read_register( struct Gb_Apu* this, blip_time_t t, int addr ); - -// Resets hardware to state after power, BEFORE boot ROM runs. Mode selects -// sound hardware. If agb_wave is true, enables AGB's extra wave features. -void Apu_reset( struct Gb_Apu* this, enum gb_mode_t mode, bool agb_wave ); - -// Same as set_output(), but for a particular channel -void Apu_set_output( struct Gb_Apu* this, int chan, struct Blip_Buffer* center, - struct Blip_Buffer* left, struct Blip_Buffer* right ); - -// Sets overall volume, where 1.0 is normal -void Apu_volume( struct Gb_Apu* this, int v ); - -// If true, reduces clicking by disabling DAC biasing. Note that this reduces -// emulation accuracy, since the clicks are authentic. -void Apu_reduce_clicks( struct Gb_Apu* this, bool reduce ); - -// Sets frame sequencer rate, where 1.0 is normal. Meant for adjusting the -// tempo in a music player. -void Apu_set_tempo( struct Gb_Apu* this, int t ); - - -void write_osc( struct Gb_Apu* this, int reg, int old_data, int data ); - -#endif diff --git a/apps/codecs/libgme/gb_cpu.c b/apps/codecs/libgme/gb_cpu.c deleted file mode 100644 index 4b2df63a17..0000000000 --- a/apps/codecs/libgme/gb_cpu.c +++ /dev/null @@ -1,53 +0,0 @@ -// Game_Music_Emu 0.6-pre. http://www.slack.net/~ant/ - -#include "gb_cpu.h" - -#include "blargg_endian.h" - -/* Copyright (C) 2003-2008 Shay Green. This module is free software; you -can redistribute it and/or modify it under the terms of the GNU Lesser -General Public License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. This -module is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more -details. You should have received a copy of the GNU Lesser General Public -License along with this module; if not, write to the Free Software Foundation, -Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ - -#include "blargg_source.h" - -static inline void set_code_page( struct Gb_Cpu* this, int i, void* p ) -{ - byte* p2 = STATIC_CAST(byte*,p) - GB_CPU_OFFSET( i * page_size ); - this->cpu_state_.code_map [i] = p2; - this->cpu_state->code_map [i] = p2; -} - -void Cpu_reset( struct Gb_Cpu* this, void* unmapped ) -{ - check( this->cpu_state == &this->cpu_state_ ); - this->cpu_state = &this->cpu_state_; - - this->cpu_state_.time = 0; - - int i; - for ( i = 0; i < page_count + 1; ++i ) - set_code_page( this, i, unmapped ); - - memset( &this->r, 0, sizeof this->r ); - - blargg_verify_byte_order(); -} - -void Cpu_map_code( struct Gb_Cpu* this, addr_t start, int size, void* data ) -{ - // address range must begin and end on page boundaries - require( start % page_size == 0 ); - require( size % page_size == 0 ); - require( start + size <= mem_size ); - - int offset; - for ( offset = 0; offset < size; offset += page_size ) - set_code_page( this, (start + offset) >> page_bits, STATIC_CAST(char*,data) + offset ); -} diff --git a/apps/codecs/libgme/gb_cpu.h b/apps/codecs/libgme/gb_cpu.h deleted file mode 100644 index 37b22141d7..0000000000 --- a/apps/codecs/libgme/gb_cpu.h +++ /dev/null @@ -1,80 +0,0 @@ -// Nintendo Game Boy CPU emulator - -// Game_Music_Emu 0.6-pre -#ifndef GB_CPU_H -#define GB_CPU_H - -#include "blargg_common.h" -#include "blargg_source.h" - -typedef int addr_t; - -// Emulator reads this many bytes past end of a page -enum { cpu_padding = 8 }; -enum { mem_size = 0x10000 }; -enum { page_bits = 13 }; -enum { page_size = 1 << page_bits }; -enum { page_count = mem_size >> page_bits }; - -// Game Boy Z-80 registers. NOT kept updated during emulation. -struct core_regs_t { - uint16_t bc, de, hl, fa; -}; - -struct registers_t { - int pc; // more than 16 bits to allow overflow detection - uint16_t sp; - - struct core_regs_t rp; -}; - -struct cpu_state_t { - byte* code_map [page_count + 1]; - int time; -}; - -struct Gb_Cpu { - // Base address for RST vectors, to simplify GBS player (normally 0) - addr_t rst_base; - - struct registers_t r; - struct cpu_state_t* cpu_state; // points to state_ or a local copy within run() - struct cpu_state_t cpu_state_; -}; - -// Initializes Gb cpu -static inline void Cpu_init( struct Gb_Cpu* this ) -{ - this->rst_base = 0; - this->cpu_state = &this->cpu_state_; -} - -// Clears registers and map all pages to unmapped -void Cpu_reset( struct Gb_Cpu* this, void* unmapped ); - -// Maps code memory (memory accessed via the program counter). Start and size -// must be multiple of page_size. -void Cpu_map_code( struct Gb_Cpu* this, addr_t start, int size, void* code ); - -// Current time. -static inline int Cpu_time( struct Gb_Cpu* this ) { return this->cpu_state->time; } - -// Changes time. Must not be called during emulation. -// Should be negative, because emulation stops once it becomes >= 0. -static inline void Cpu_set_time( struct Gb_Cpu* this, int t ) { this->cpu_state->time = t; } - -#define GB_CPU_PAGE( addr ) ((unsigned) (addr) >> page_bits) - -#ifdef BLARGG_NONPORTABLE - #define GB_CPU_OFFSET( addr ) (addr) -#else - #define GB_CPU_OFFSET( addr ) ((addr) & (page_size - 1)) -#endif - -// Accesses emulated memory as CPU does -static inline uint8_t* Cpu_get_code( struct Gb_Cpu* this, addr_t addr ) -{ - return this->cpu_state_.code_map [GB_CPU_PAGE( addr )] + GB_CPU_OFFSET( addr ); -} - -#endif diff --git a/apps/codecs/libgme/gb_cpu_run.h b/apps/codecs/libgme/gb_cpu_run.h deleted file mode 100644 index 1ea8b59249..0000000000 --- a/apps/codecs/libgme/gb_cpu_run.h +++ /dev/null @@ -1,1187 +0,0 @@ -// Game_Music_Emu 0.6-pre. http://www.slack.net/~ant/ - -#if 0 -/* Define these macros in the source file before #including this file. -- Parameters might be expressions, so they are best evaluated only once, -though they NEVER have side-effects, so multiple evaluation is OK. -- Output parameters might be a multiple-assignment expression like "a=x", -so they must NOT be parenthesized. -- Macros "returning" void may use a {} statement block. */ - - // 0 <= addr <= 0xFFFF + page_size - // time functions can be used - int READ_MEM( addr_t ); - void WRITE_MEM( addr_t, int data ); - - // Access of 0xFF00 + offset - // 0 <= offset <= 0xFF - int READ_IO( int offset ); - void WRITE_IO( int offset, int data ); - - // Often-used instructions use this instead of READ_MEM - void READ_FAST( addr_t, int& out ); - -// The following can be used within macros: - - // Current time - cpu_time_t TIME(); -#endif - -/* Copyright (C) 2003-2009 Shay Green. This module is free software; you -can redistribute it and/or modify it under the terms of the GNU Lesser -General Public License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. This -module is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more -details. You should have received a copy of the GNU Lesser General Public -License along with this module; if not, write to the Free Software Foundation, -Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ - -// Common instructions: -// -// 365880 FA LD A,(nn) -// 355863 20 JR NZ -// 313655 21 LD HL,nn -// 274580 28 JR Z -// 252878 FE CP n -// 230541 7E LD A,(HL) -// 226209 2A LD A,(HL+) -// 217467 CD CALL -// 212034 C9 RET -// 208376 CB CB prefix -// -// 27486 CB 7E BIT 7,(HL) -// 15925 CB 76 BIT 6,(HL) -// 13035 CB 19 RR C -// 11557 CB 7F BIT 7,A -// 10898 CB 37 SWAP A -// 10208 CB 66 BIT 4,(HL) - -// Allows MWCW debugger to step through code properly -#ifdef CPU_BEGIN - CPU_BEGIN -#endif - -#define TIME() s.time - -#define CODE_PAGE( addr ) s.code_map [GB_CPU_PAGE( addr )] -#define READ_CODE( addr ) (CODE_PAGE( addr ) [GB_CPU_OFFSET( addr )]) - -// Flags with hex value for clarity when used as mask. -// Stored in indicated variable during emulation. -int const z80 = 0x80; // cz -int const n40 = 0x40; // ph -int const h20 = 0x20; // ph -int const c10 = 0x10; // cz - -#define SET_FLAGS( in )\ -{\ - cz = ((in) << 4 & 0x100) + (~(in) >> 7 & 1);\ - ph = (~(in) << 2 & 0x100) + ((in) >> 1 & 0x10);\ -} - -// random bits in cz to catch misuse of them -#define SET_FLAGS_DEBUG( in )\ -{\ - cz = ((in) << 4 & 0x100) | (rand() & ~0x1FF) | ((in) & 0x80 ? 0 : (rand() & 0xFF) | 1);\ - ph = (~(in) << 2 & 0x100) | (((in) >> 1 & 0x10) ^ BYTE( cz ));\ -} - -#define GET_FLAGS( out )\ -{\ - out = (cz >> 4 & c10);\ - out += ~ph >> 2 & n40;\ - out += (ph ^ cz) << 1 & h20;\ - if ( !BYTE( cz ) )\ - out += z80;\ -} - -#define CC_NZ() ( BYTE( cz )) -#define CC_Z() (!BYTE( cz )) -#define CC_NC() (!(cz & 0x100)) -#define CC_C() ( cz & 0x100 ) - -// Truncation -#define BYTE( n ) ((uint8_t ) (n)) /* (unsigned) n & 0xFF */ -#define SBYTE( n ) ((int8_t ) (n)) /* (BYTE( n ) ^ 0x80) - 0x80 */ -#define WORD( n ) ((uint16_t) (n)) /* (unsigned) n & 0xFFFF */ - -{ - struct cpu_state_t s; - cpu->cpu_state = &s; - memcpy( &s, &cpu->cpu_state_, sizeof s ); - - union { - struct { - #ifdef BLARGG_BIG_ENDIAN - byte b, c, d, e, h, l, flags, a; - #else - byte c, b, e, d, l, h, a, flags; - #endif - } rg; // individual registers - struct core_regs_t rp; // pairs - - byte r8_ [8]; // indexed registers (use R8 macro due to endian dependence) - uint16_t r16 [4]; // indexed pairs - } reg; - BOOST_STATIC_ASSERT( sizeof reg.rg == 8 && sizeof reg.rp == 8 ); - - #ifdef BLARGG_BIG_ENDIAN - #define R8( n ) (reg.r8_ [n]) - #elif BLARGG_LITTLE_ENDIAN - #define R8( n ) (reg.r8_ [(n) ^ 1]) - #else - // Be sure "blargg_endian.h" has been #included in the file that #includes this - #error "Byte order of CPU must be known" - #endif - - #define R16( n ) (reg.r16 [n]) - #define RG (reg.rg) - #define RP (reg.rp) - - RP = cpu->r.rp; - int pc = cpu->r.pc; - int sp = cpu->r.sp; - int ph; - int cz; - SET_FLAGS( RG.flags ); - - int time = s.time; - -loop: - - check( (unsigned) pc < 0x10000 + 1 ); // +1 so emulator can catch wrap-around - check( (unsigned) sp < 0x10000 ); - - byte const* instr = CODE_PAGE( pc ); - int op; - - if ( GB_CPU_OFFSET(~0) == ~0 ) - { - op = instr [pc]; - pc++; - instr += pc; - } - else - { - instr += GB_CPU_OFFSET( pc ); - op = *instr++; - pc++; - } - -#define GET_ADDR() GET_LE16( instr ) - - static byte const instr_times [256*2] = { - // 0 1 2 3 4 5 6 7 8 9 A B C D E F - 4,12, 8, 8, 4, 4, 8, 4,20, 8, 8, 8, 4, 4, 8, 4,// 0 - 4,12, 8, 8, 4, 4, 8, 4,12, 8, 8, 8, 4, 4, 8, 4,// 1 - 8,12, 8, 8, 4, 4, 8, 4, 8, 8, 8, 8, 4, 4, 8, 4,// 2 - 8,12, 8, 8,12,12,12, 4, 8, 8, 8, 8, 4, 4, 8, 4,// 3 - 4, 4, 4, 4, 4, 4, 8, 4, 4, 4, 4, 4, 4, 4, 8, 4,// 4 - 4, 4, 4, 4, 4, 4, 8, 4, 4, 4, 4, 4, 4, 4, 8, 4,// 5 - 4, 4, 4, 4, 4, 4, 8, 4, 4, 4, 4, 4, 4, 4, 8, 4,// 6 - 8, 8, 8, 8, 8, 8, 0, 8, 4, 4, 4, 4, 4, 4, 8, 4,// 7 - 4, 4, 4, 4, 4, 4, 8, 4, 4, 4, 4, 4, 4, 4, 8, 4,// 8 - 4, 4, 4, 4, 4, 4, 8, 4, 4, 4, 4, 4, 4, 4, 8, 4,// 9 - 4, 4, 4, 4, 4, 4, 8, 4, 4, 4, 4, 4, 4, 4, 8, 4,// A - 4, 4, 4, 4, 4, 4, 8, 4, 4, 4, 4, 4, 4, 4, 8, 4,// B - 8,12,16,16,12,16, 8,16, 8,16,16, 0,12,24, 8,16,// C - 8,12,16, 0,12,16, 8,16, 8,16,16, 0,12, 0, 8,16,// D - 12,12, 8, 0, 0,16, 8,16,16, 4,16, 0, 0, 0, 8,16,// E - 12,12, 8, 4, 0,16, 8,16,12, 8,16, 4, 0, 0, 8,16,// F - - // CB prefixed - // 0 1 2 3 4 5 6 7 8 9 A B C D E F - 8, 8, 8, 8, 8, 8,16, 8, 8, 8, 8, 8, 8, 8,16, 8,// 0 - 8, 8, 8, 8, 8, 8,16, 8, 8, 8, 8, 8, 8, 8,16, 8,// 1 - 8, 8, 8, 8, 8, 8,16, 8, 8, 8, 8, 8, 8, 8,16, 8,// 2 - 8, 8, 8, 8, 8, 8,16, 8, 8, 8, 8, 8, 8, 8,16, 8,// 3 - 8, 8, 8, 8, 8, 8,12, 8, 8, 8, 8, 8, 8, 8,12, 8,// 4 - 8, 8, 8, 8, 8, 8,12, 8, 8, 8, 8, 8, 8, 8,12, 8,// 5 - 8, 8, 8, 8, 8, 8,12, 8, 8, 8, 8, 8, 8, 8,12, 8,// 6 - 8, 8, 8, 8, 8, 8,12, 8, 8, 8, 8, 8, 8, 8,12, 8,// 7 - 8, 8, 8, 8, 8, 8,16, 8, 8, 8, 8, 8, 8, 8,16, 8,// 8 - 8, 8, 8, 8, 8, 8,16, 8, 8, 8, 8, 8, 8, 8,16, 8,// 9 - 8, 8, 8, 8, 8, 8,16, 8, 8, 8, 8, 8, 8, 8,16, 8,// A - 8, 8, 8, 8, 8, 8,16, 8, 8, 8, 8, 8, 8, 8,16, 8,// B - 8, 8, 8, 8, 8, 8,16, 8, 8, 8, 8, 8, 8, 8,16, 8,// C - 8, 8, 8, 8, 8, 8,16, 8, 8, 8, 8, 8, 8, 8,16, 8,// D - 8, 8, 8, 8, 8, 8,16, 8, 8, 8, 8, 8, 8, 8,16, 8,// E - 8, 8, 8, 8, 8, 8,16, 8, 8, 8, 8, 8, 8, 8,16, 8,// F - }; - - if ( time >= 0 ) - goto stop; - - time += instr_times [op]; - - int data; - data = *instr; - s.time = time; - - #ifdef CPU_INSTR_HOOK - { CPU_INSTR_HOOK( (pc-1), (instr-1), rg.a, rp.bc, rp.de, rp.hl, sp ); } - #endif - - switch ( op ) - { - -// TODO: more efficient way to handle negative branch that wraps PC around -#define BRANCH_( cond, clocks )\ -{\ - pc++;\ - if ( !(cond) )\ - goto loop;\ - pc = WORD( pc + SBYTE( data ) );\ - time += clocks;\ - goto loop;\ -} - -#define BRANCH( cond ) BRANCH_( cond, 4 ) - -// Most Common - - case 0x20: // JR NZ - BRANCH( CC_NZ() ) - - case 0x21: // LD HL,IMM (common) - RP.hl = GET_ADDR(); - pc += 2; - goto loop; - - case 0x28: // JR Z - BRANCH( CC_Z() ) - - case 0xF2: // LD A,(0xFF00+C) - READ_IO( this, RG.c, RG.a ); - goto loop; - - case 0xF0: // LD A,(0xFF00+imm) - pc++; - READ_IO( this, data, RG.a ); - goto loop; - - { - int temp; - case 0x0A: // LD A,(BC) - temp = RP.bc; - goto ld_a_ind_comm; - - case 0x3A: // LD A,(HL-) - temp = RP.hl; - RP.hl = temp - 1; - goto ld_a_ind_comm; - - case 0x1A: // LD A,(DE) - temp = RP.de; - goto ld_a_ind_comm; - - case 0x2A: // LD A,(HL+) (common) - temp = RP.hl; - RP.hl = temp + 1; - goto ld_a_ind_comm; - - case 0xFA: // LD A,IND16 (common) - temp = GET_ADDR(); - pc += 2; - ld_a_ind_comm: - READ_FAST( this, temp, RG.a ); - goto loop; - } - - { - int temp; - case 0xBE: // CP (HL) - temp = READ_MEM( this, RP.hl ); - goto cmp_comm; - - case 0xB8: // CP B - case 0xB9: // CP C - case 0xBA: // CP D - case 0xBB: // CP E - case 0xBC: // CP H - case 0xBD: // CP L - case 0xBF: // CP A - temp = R8( op & 7 ); - cmp_comm: - ph = RG.a ^ temp; // N=1 H=* - cz = RG.a - temp; // C=* Z=* - goto loop; - } - - case 0xFE: // CP IMM - pc++; - ph = RG.a ^ data; // N=1 H=* - cz = RG.a - data; // C=* Z=* - goto loop; - - case 0x46: // LD B,(HL) - case 0x4E: // LD C,(HL) - case 0x56: // LD D,(HL) - case 0x5E: // LD E,(HL) - case 0x66: // LD H,(HL) - case 0x6E: // LD L,(HL) - case 0x7E:{// LD A,(HL) - int addr = RP.hl; - READ_FAST( this, addr, R8( op >> 3 & 7 ) ); - goto loop; - } - - case 0xC4: // CNZ (next-most-common) - pc += 2; - if ( CC_Z() ) - goto loop; - call: - time += 12; - pc -= 2; - case 0xCD: // CALL (most-common) - data = pc + 2; - pc = GET_ADDR(); - push: { - int addr = WORD( sp - 1 ); - WRITE_MEM( this, addr, (data >> 8) ); - sp = WORD( sp - 2 ); - WRITE_MEM( this, sp, data ); - goto loop; - } - - case 0xC8: // RET Z (next-most-common) - if ( CC_NZ() ) - goto loop; - ret: - time += 12; - case 0xD9: // RETI - case 0xC9:{// RET (most common) - pc = READ_MEM( this, sp ); - int addr = sp + 1; - sp = WORD( sp + 2 ); - pc += 0x100 * READ_MEM( this, addr ); - goto loop; - } - - case 0x00: // NOP - case 0x40: // LD B,B - case 0x49: // LD C,C - case 0x52: // LD D,D - case 0x5B: // LD E,E - case 0x64: // LD H,H - case 0x6D: // LD L,L - case 0x7F: // LD A,A - goto loop; - -// CB Instructions - - case 0xCB: - time += (instr_times + 256) [data]; - pc++; - // now data is the opcode - switch ( data ) { - - case 0x46: // BIT b,(HL) - case 0x4E: - case 0x56: - case 0x5E: - case 0x66: - case 0x6E: - case 0x76: - case 0x7E: { - int addr = RP.hl; - READ_FAST( this, addr, op ); - goto bit_comm; - } - - case 0x40: case 0x41: case 0x42: case 0x43: // BIT b,r - case 0x44: case 0x45: case 0x47: case 0x48: - case 0x49: case 0x4A: case 0x4B: case 0x4C: - case 0x4D: case 0x4F: case 0x50: case 0x51: - case 0x52: case 0x53: case 0x54: case 0x55: - case 0x57: case 0x58: case 0x59: case 0x5A: - case 0x5B: case 0x5C: case 0x5D: case 0x5F: - case 0x60: case 0x61: case 0x62: case 0x63: - case 0x64: case 0x65: case 0x67: case 0x68: - case 0x69: case 0x6A: case 0x6B: case 0x6C: - case 0x6D: case 0x6F: case 0x70: case 0x71: - case 0x72: case 0x73: case 0x74: case 0x75: - case 0x77: case 0x78: case 0x79: case 0x7A: - case 0x7B: case 0x7C: case 0x7D: case 0x7F: - op = R8( data & 7 ); - bit_comm: - ph = op >> (data >> 3 & 7) & 1; - cz = (cz & 0x100) + ph; - ph ^= 0x110; // N=0 H=1 - goto loop; - - case 0x86: // RES b,(HL) - case 0x8E: - case 0x96: - case 0x9E: - case 0xA6: - case 0xAE: - case 0xB6: - case 0xBE: { - int temp = READ_MEM( this, RP.hl ); - temp &= ~(1 << (data >> 3 & 7)); - WRITE_MEM( this, RP.hl, temp ); - goto loop; - } - - case 0xC6: // SET b,(HL) - case 0xCE: - case 0xD6: - case 0xDE: - case 0xE6: - case 0xEE: - case 0xF6: - case 0xFE: { - int temp = READ_MEM( this, RP.hl ); - temp |= 1 << (data >> 3 & 7); - WRITE_MEM( this, RP.hl, temp ); - goto loop; - } - - case 0xC0: case 0xC1: case 0xC2: case 0xC3: // SET b,r - case 0xC4: case 0xC5: case 0xC7: case 0xC8: - case 0xC9: case 0xCA: case 0xCB: case 0xCC: - case 0xCD: case 0xCF: case 0xD0: case 0xD1: - case 0xD2: case 0xD3: case 0xD4: case 0xD5: - case 0xD7: case 0xD8: case 0xD9: case 0xDA: - case 0xDB: case 0xDC: case 0xDD: case 0xDF: - case 0xE0: case 0xE1: case 0xE2: case 0xE3: - case 0xE4: case 0xE5: case 0xE7: case 0xE8: - case 0xE9: case 0xEA: case 0xEB: case 0xEC: - case 0xED: case 0xEF: case 0xF0: case 0xF1: - case 0xF2: case 0xF3: case 0xF4: case 0xF5: - case 0xF7: case 0xF8: case 0xF9: case 0xFA: - case 0xFB: case 0xFC: case 0xFD: case 0xFF: - R8( data & 7 ) |= 1 << (data >> 3 & 7); - goto loop; - - case 0x80: case 0x81: case 0x82: case 0x83: // RES b,r - case 0x84: case 0x85: case 0x87: case 0x88: - case 0x89: case 0x8A: case 0x8B: case 0x8C: - case 0x8D: case 0x8F: case 0x90: case 0x91: - case 0x92: case 0x93: case 0x94: case 0x95: - case 0x97: case 0x98: case 0x99: case 0x9A: - case 0x9B: case 0x9C: case 0x9D: case 0x9F: - case 0xA0: case 0xA1: case 0xA2: case 0xA3: - case 0xA4: case 0xA5: case 0xA7: case 0xA8: - case 0xA9: case 0xAA: case 0xAB: case 0xAC: - case 0xAD: case 0xAF: case 0xB0: case 0xB1: - case 0xB2: case 0xB3: case 0xB4: case 0xB5: - case 0xB7: case 0xB8: case 0xB9: case 0xBA: - case 0xBB: case 0xBC: case 0xBD: case 0xBF: - R8( data & 7 ) &= ~(1 << (data >> 3 & 7)); - goto loop; - - case 0x36: // SWAP (HL) - op = READ_MEM( this, RP.hl ); - goto swap_comm; - - case 0x30: // SWAP B - case 0x31: // SWAP C - case 0x32: // SWAP D - case 0x33: // SWAP E - case 0x34: // SWAP H - case 0x35: // SWAP L - case 0x37: // SWAP A - op = R8( data & 7 ); - swap_comm: - op = (op >> 4) + (op << 4); - cz = BYTE( op ); - ph = cz + 0x100; - if ( data == 0x36 ) - goto write_hl_op_ff; - R8( data & 7 ) = op; - goto loop; - -// Shift/Rotate - - case 0x26: // SLA (HL) - cz = 0; - case 0x16: // RL (HL) - cz = (cz >> 8 & 1) + (READ_MEM( this, RP.hl ) << 1); - goto rl_hl_common; - - case 0x06: // RLC (HL) - cz = READ_MEM( this, RP.hl ); - cz = (cz << 1) + (cz >> 7 & 1); - rl_hl_common: - // Z=* C=* - ph = cz | 0x100; // N=0 H=0 - WRITE_MEM( this, RP.hl, cz ); - goto loop; - - case 0x20: case 0x21: case 0x22: case 0x23: case 0x24: case 0x25: case 0x27: // SLA r - cz = 0; - case 0x10: case 0x11: case 0x12: case 0x13: case 0x14: case 0x15: case 0x17: // RL r - cz = (cz >> 8 & 1) + (R8( data & 7 ) << 1); - goto rl_common; - - case 0x00: case 0x01: case 0x02: case 0x03: case 0x04: case 0x05: case 0x07: // RLC r - cz = R8( data & 7 ); - cz = (cz << 1) + (cz >> 7 & 1); - rl_common: - // Z=* C=* - ph = cz | 0x100; // N=0 H=0 - R8( data & 7 ) = cz; - goto loop; - - case 0x0E: // RRC (HL) - cz = READ_MEM( this, RP.hl ); - cz += cz << 8 & 0x100; - goto rr_hl_common; - - case 0x2E: // SRA (HL) - cz = READ_MEM( this, RP.hl ); - cz += cz << 1 & 0x100; - goto rr_hl_common; - - case 0x3E: // SRL (HL) - cz = 0; - case 0x1E: // RR (HL) - cz = (cz & 0x100) + READ_MEM( this, RP.hl ); - rr_hl_common: - cz = (cz << 8) + (cz >> 1); // Z=* C=* - ph = cz | 0x100; // N=0 H=0 - WRITE_MEM( this, RP.hl, cz ); - goto loop; - - case 0x08: case 0x09: case 0x0A: case 0x0B: case 0x0C: case 0x0D: case 0x0F: // RRC r - cz = R8( data & 7 ); - cz += cz << 8 & 0x100; - goto rr_common; - - case 0x28: case 0x29: case 0x2A: case 0x2B: case 0x2C: case 0x2D: case 0x2F: // SRA r - cz = R8( data & 7 ); - cz += cz << 1 & 0x100; - goto rr_common; - - case 0x38: case 0x39: case 0x3A: case 0x3B: case 0x3C: case 0x3D: case 0x3F: // SRL r - cz = 0; - case 0x18: case 0x19: case 0x1A: case 0x1B: case 0x1C: case 0x1D: case 0x1F: // RR r - cz = (cz & 0x100) + R8( data & 7 ); - rr_common: - cz = (cz << 8) + (cz >> 1); // Z=* C=* - ph = cz | 0x100; // N=0 H=0 - R8( data & 7 ) = cz; - goto loop; - - } // CB op - assert( false ); // unhandled CB op - - case 0x07: // RLCA - cz = RG.a >> 7; - goto rlc_common; - case 0x17: // RLA - cz = cz >> 8 & 1; - rlc_common: - cz += RG.a << 1; - ph = cz | 0x100; - RG.a = BYTE( cz ); - cz |= 1; - goto loop; - - case 0x0F: // RRCA - ph = RG.a << 8; - goto rrc_common; - case 0x1F: // RRA - ph = cz; - rrc_common: - cz = (RG.a << 8) + 1; // Z=0 C=* - RG.a = ((ph & 0x100) + RG.a) >> 1; - ph = 0x100; // N=0 H=0 - goto loop; - -// Load - - case 0x70: // LD (HL),B - case 0x71: // LD (HL),C - case 0x72: // LD (HL),D - case 0x73: // LD (HL),E - case 0x74: // LD (HL),H - case 0x75: // LD (HL),L - case 0x77: // LD (HL),A - op = R8( op & 7 ); - write_hl_op_ff: - WRITE_MEM( this, RP.hl, op ); - goto loop; - - case 0x41: case 0x42: case 0x43: case 0x44: case 0x45: case 0x47: // LD r,r - case 0x48: case 0x4A: case 0x4B: case 0x4C: case 0x4D: case 0x4F: - case 0x50: case 0x51: case 0x53: case 0x54: case 0x55: case 0x57: - case 0x58: case 0x59: case 0x5A: case 0x5C: case 0x5D: case 0x5F: - case 0x60: case 0x61: case 0x62: case 0x63: case 0x65: case 0x67: - case 0x68: case 0x69: case 0x6A: case 0x6B: case 0x6C: case 0x6F: - case 0x78: case 0x79: case 0x7A: case 0x7B: case 0x7C: case 0x7D: - R8( op >> 3 & 7 ) = R8( op & 7 ); - goto loop; - - case 0x08: // LD IND16,SP - data = GET_ADDR(); - pc += 2; - WRITE_MEM( this, data, sp ); - data++; - WRITE_MEM( this, data, (sp >> 8) ); - goto loop; - - case 0xF9: // LD SP,HL - sp = RP.hl; - goto loop; - - case 0x31: // LD SP,IMM - sp = GET_ADDR(); - pc += 2; - goto loop; - - case 0x01: // LD BC,IMM - case 0x11: // LD DE,IMM - R16( (unsigned) op >> 4 ) = GET_ADDR(); - pc += 2; - goto loop; - - case 0xE2: // LD (0xFF00+C),A - WRITE_IO( this, RG.c, RG.a ); - goto loop; - - case 0xE0: // LD (0xFF00+imm),A - pc++; - WRITE_IO( this, data, RG.a ); - goto loop; - - { - int temp; - case 0x32: // LD (HL-),A - temp = RP.hl; - RP.hl = temp - 1; - goto write_data_rg_a; - - case 0x02: // LD (BC),A - temp = RP.bc; - goto write_data_rg_a; - - case 0x12: // LD (DE),A - temp = RP.de; - goto write_data_rg_a; - - case 0x22: // LD (HL+),A - temp = RP.hl; - RP.hl = temp + 1; - goto write_data_rg_a; - - case 0xEA: // LD IND16,A (common) - temp = GET_ADDR(); - pc += 2; - write_data_rg_a: - WRITE_MEM( this, temp, RG.a ); - goto loop; - } - - case 0x06: // LD B,IMM - RG.b = data; - pc++; - goto loop; - - case 0x0E: // LD C,IMM - RG.c = data; - pc++; - goto loop; - - case 0x16: // LD D,IMM - RG.d = data; - pc++; - goto loop; - - case 0x1E: // LD E,IMM - RG.e = data; - pc++; - goto loop; - - case 0x26: // LD H,IMM - RG.h = data; - pc++; - goto loop; - - case 0x2E: // LD L,IMM - RG.l = data; - pc++; - goto loop; - - case 0x36: // LD (HL),IMM - WRITE_MEM( this, RP.hl, data ); - pc++; - goto loop; - - case 0x3E: // LD A,IMM - RG.a = data; - pc++; - goto loop; - -// Increment/decrement - - case 0x03: // INC BC - case 0x13: // INC DE - case 0x23: // INC HL - R16( (unsigned) op >> 4 )++; - goto loop; - - case 0x33: // INC SP - sp = WORD( sp + 1 ); - goto loop; - - case 0x0B: // DEC BC - case 0x1B: // DEC DE - case 0x2B: // DEC HL - R16( (unsigned) op >> 4 )--; - goto loop; - - case 0x3B: // DEC SP - sp = WORD( sp - 1 ); - goto loop; - - case 0x34: // INC (HL) - op = RP.hl; - data = READ_MEM( this, op ); - data++; - WRITE_MEM( this, op, data ); - goto inc_comm; - - case 0x04: // INC B - case 0x0C: // INC C (common) - case 0x14: // INC D - case 0x1C: // INC E - case 0x24: // INC H - case 0x2C: // INC L - case 0x3C: // INC A - op = op >> 3 & 7; - data = R8( op ) + 1; - R8( op ) = data; - inc_comm: - ph = data - 0x101; // N=0 H=* - cz = (cz & 0x100) + BYTE( data ); // C=- Z=* - goto loop; - - case 0x35: // DEC (HL) - op = RP.hl; - data = READ_MEM( this, op ); - data--; - WRITE_MEM( this, op, data ); - goto dec_comm; - - case 0x05: // DEC B - case 0x0D: // DEC C - case 0x15: // DEC D - case 0x1D: // DEC E - case 0x25: // DEC H - case 0x2D: // DEC L - case 0x3D: // DEC A - op = op >> 3 & 7; - data = R8( op ) - 1; - R8( op ) = data; - dec_comm: - ph = data + 1; // N=1 H=* - cz = (cz & 0x100) + BYTE( data ); // C=- Z=* - goto loop; - -// Add 16-bit - - case 0xF8: // LD HL,SP+n - case 0xE8:{// ADD SP,n - pc++; - int t = WORD( sp + SBYTE( data ) ); - cz = ((BYTE( sp ) + data) & 0x100) + 1; // Z=0 C=* - ph = (sp ^ data ^ t) | 0x100; // N=0 H=* - if ( op == 0xF8 ) - { - RP.hl = t; - goto loop; - } - sp = t; - goto loop; - } - - case 0x39: // ADD HL,SP - data = sp; - goto add_hl_comm; - - case 0x09: // ADD HL,BC - case 0x19: // ADD HL,DE - case 0x29: // ADD HL,HL - data = R16( (unsigned) op >> 4 ); - add_hl_comm: - ph = RP.hl ^ data; - data += RP.hl; - RP.hl = WORD( data ); - ph ^= data; - cz = BYTE( cz ) + (data >> 8 & 0x100); // C=* Z=- - ph = ((ph >> 8) ^ cz) | 0x100; // N=0 H=* - goto loop; - - case 0x86: // ADD (HL) - data = READ_MEM( this, RP.hl ); - goto add_comm; - - case 0x80: // ADD B - case 0x81: // ADD C - case 0x82: // ADD D - case 0x83: // ADD E - case 0x84: // ADD H - case 0x85: // ADD L - case 0x87: // ADD A - data = R8( op & 7 ); - goto add_comm; - - case 0xC6: // ADD IMM - pc++; - add_comm: - ph = (RG.a ^ data) | 0x100; // N=1 H=* - cz = RG.a + data; // C=* Z=* - RG.a = cz; - goto loop; - -// Add/Subtract - - case 0x8E: // ADC (HL) - data = READ_MEM( this, RP.hl ); - goto adc_comm; - - case 0x88: // ADC B - case 0x89: // ADC C - case 0x8A: // ADC D - case 0x8B: // ADC E - case 0x8C: // ADC H - case 0x8D: // ADC L - case 0x8F: // ADC A - data = R8( op & 7 ); - goto adc_comm; - - case 0xCE: // ADC IMM - pc++; - adc_comm: - ph = (RG.a ^ data) | 0x100; // N=1 H=* - cz = RG.a + data + (cz >> 8 & 1); // C=* Z=* - RG.a = cz; - goto loop; - - case 0x96: // SUB (HL) - data = READ_MEM( this, RP.hl ); - goto sub_comm; - - case 0x90: // SUB B - case 0x91: // SUB C - case 0x92: // SUB D - case 0x93: // SUB E - case 0x94: // SUB H - case 0x95: // SUB L - case 0x97: // SUB A - data = R8( op & 7 ); - goto sub_comm; - - case 0xD6: // SUB IMM - pc++; - sub_comm: - ph = RG.a ^ data; // N=1 H=* - cz = RG.a - data; // C=* Z=* - RG.a = cz; - goto loop; - - case 0x9E: // SBC (HL) - data = READ_MEM( this, RP.hl ); - goto sbc_comm; - - case 0x98: // SBC B - case 0x99: // SBC C - case 0x9A: // SBC D - case 0x9B: // SBC E - case 0x9C: // SBC H - case 0x9D: // SBC L - case 0x9F: // SBC A - data = R8( op & 7 ); - goto sbc_comm; - - case 0xDE: // SBC IMM - pc++; - sbc_comm: - ph = RG.a ^ data; // N=1 H=* - cz = RG.a - data - (cz >> 8 & 1); // C=* Z=* - RG.a = cz; - goto loop; - -// Logical - - case 0xA0: // AND B - case 0xA1: // AND C - case 0xA2: // AND D - case 0xA3: // AND E - case 0xA4: // AND H - case 0xA5: // AND L - data = R8( op & 7 ); - goto and_comm; - - case 0xA6: // AND (HL) - data = READ_MEM( this, RP.hl ); - goto and_comm; - case 0xE6: // AND IMM - pc++; - and_comm: - cz = RG.a & data; // C=0 Z=* - ph = ~cz; // N=0 H=1 - RG.a = cz; - goto loop; - - case 0xA7: // AND A - cz = RG.a; // C=0 Z=* - ph = ~RG.a; // N=0 H=1 - goto loop; - - case 0xB0: // OR B - case 0xB1: // OR C - case 0xB2: // OR D - case 0xB3: // OR E - case 0xB4: // OR H - case 0xB5: // OR L - data = R8( op & 7 ); - goto or_comm; - - case 0xB6: // OR (HL) - data = READ_MEM( this, RP.hl ); - goto or_comm; - case 0xF6: // OR IMM - pc++; - or_comm: - cz = RG.a | data; // C=0 Z=* - ph = cz | 0x100; // N=0 H=0 - RG.a = cz; - goto loop; - - case 0xB7: // OR A - cz = RG.a; // C=0 Z=* - ph = RG.a + 0x100; // N=0 H=0 - goto loop; - - case 0xA8: // XOR B - case 0xA9: // XOR C - case 0xAA: // XOR D - case 0xAB: // XOR E - case 0xAC: // XOR H - case 0xAD: // XOR L - data = R8( op & 7 ); - goto xor_comm; - - case 0xAE: // XOR (HL) - data = READ_MEM( this, RP.hl ); - pc--; - case 0xEE: // XOR IMM - pc++; - xor_comm: - cz = RG.a ^ data; // C=0 Z=* - ph = cz + 0x100; // N=0 H=0 - RG.a = cz; - goto loop; - - case 0xAF: // XOR A - RG.a = 0; - cz = 0; // C=0 Z=* - ph = 0x100; // N=0 H=0 - goto loop; - -// Stack - - case 0xF1: // POP AF - case 0xC1: // POP BC - case 0xD1: // POP DE - case 0xE1: // POP HL (common) - data = READ_MEM( this, sp ); - R16( op >> 4 & 3 ) = data + 0x100 * READ_MEM( this, (sp + 1) ); - sp = WORD( sp + 2 ); - if ( op != 0xF1 ) - goto loop; - - SET_FLAGS( RG.a ); - RG.a = RG.flags; - goto loop; - - case 0xC5: // PUSH BC - data = RP.bc; - goto push; - - case 0xD5: // PUSH DE - data = RP.de; - goto push; - - case 0xE5: // PUSH HL - data = RP.hl; - goto push; - - case 0xF5: // PUSH AF - GET_FLAGS( data ); - data += RG.a << 8; - goto push; - -// Flow control - - case 0xFF: case 0xC7: case 0xCF: case 0xD7: // RST - case 0xDF: case 0xE7: case 0xEF: case 0xF7: - data = pc; - pc = (op & 0x38) + cpu->rst_base; - goto push; - - case 0xCC: // CALL Z - pc += 2; - if ( CC_Z() ) - goto call; - goto loop; - - case 0xD4: // CALL NC - pc += 2; - if ( CC_NC() ) - goto call; - goto loop; - - case 0xDC: // CALL C - pc += 2; - if ( CC_C() ) - goto call; - goto loop; - - case 0xC0: // RET NZ - if ( CC_NZ() ) - goto ret; - goto loop; - - case 0xD0: // RET NC - if ( CC_NC() ) - goto ret; - goto loop; - - case 0xD8: // RET C - if ( CC_C() ) - goto ret; - goto loop; - - case 0x18: // JR - BRANCH_( true, 0 ) - - case 0x30: // JR NC - BRANCH( CC_NC() ) - - case 0x38: // JR C - BRANCH( CC_C() ) - - case 0xE9: // LD PC,HL - pc = RP.hl; - goto loop; - - case 0xC3: // JP (next-most-common) - pc = GET_ADDR(); - goto loop; - - case 0xC2: // JP NZ - pc += 2; - if ( CC_NZ() ) - goto jp_taken; - time -= 4; - goto loop; - - case 0xCA: // JP Z (most common) - pc += 2; - if ( CC_Z() ) - goto jp_taken; - time -= 4; - goto loop; - - jp_taken: - pc -= 2; - pc = GET_ADDR(); - goto loop; - - case 0xD2: // JP NC - pc += 2; - if ( CC_NC() ) - goto jp_taken; - time -= 4; - goto loop; - - case 0xDA: // JP C - pc += 2; - if ( CC_C() ) - goto jp_taken; - time -= 4; - goto loop; - -// Flags - - case 0x2F: // CPL - RG.a = ~RG.a; - ph = BYTE( ~cz ); // N=1 H=1 - goto loop; - - case 0x3F: // CCF - ph = cz | 0x100; // N=0 H=0 - cz ^= 0x100; // C=* Z=- - goto loop; - - case 0x37: // SCF - ph = cz | 0x100; // N=0 H=0 - cz |= 0x100; // C=1 Z=- - goto loop; - - case 0xF3: // DI - goto loop; - - case 0xFB: // EI - goto loop; - - case 0x27:{// DAA - unsigned a = RG.a; - int h = ph ^ cz; - if ( ph & 0x100 ) - { - if ( (h & 0x10) || (a & 0x0F) > 9 ) - a += 6; - - if ( (cz & 0x100) || a > 0x9F ) - a += 0x60; - } - else - { - if ( h & 0x10 ) - a = (a - 6) & 0xFF; - - if ( cz & 0x100 ) - a -= 0x60; - } - cz = (cz & 0x100) | a; // C=- Z=* - RG.a = a; - ph = (ph & 0x100) + BYTE( a ); // N=- H=0 - goto loop; - } - -// Special - - case 0x76: // HALT - case 0x10: // STOP - case 0xD3: case 0xDB: case 0xDD: // Illegal - case 0xE3: case 0xE4: case 0xEB: case 0xEC: case 0xED: // (all freeze cpu) - case 0xF4: case 0xFC: case 0xFD: - goto stop; - } - - // If this fails then an opcode isn't handled above - assert( false ); - -stop: - pc--; - - // copy state back - cpu->cpu_state_.time = time; - cpu->r.pc = pc; - cpu->r.sp = sp; - { - int t; - GET_FLAGS( t ); - RG.flags = t; - } - cpu->cpu_state = &cpu->cpu_state_; - cpu->r.rp = RP; -} diff --git a/apps/codecs/libgme/gb_oscs.c b/apps/codecs/libgme/gb_oscs.c deleted file mode 100644 index 09bb98238e..0000000000 --- a/apps/codecs/libgme/gb_oscs.c +++ /dev/null @@ -1,787 +0,0 @@ -// Gb_Snd_Emu 0.1.4. http://www.slack.net/~ant/ - -#include "gb_apu.h" - -/* Copyright (C) 2003-2008 Shay Green. This module is free software; you -can redistribute it and/or modify it under the terms of the GNU Lesser -General Public License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. This -module is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more -details. You should have received a copy of the GNU Lesser General Public -License along with this module; if not, write to the Free Software Foundation, -Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ - -#include "blargg_source.h" - -int const cgb_02 = 0; // enables bug in early CGB units that causes problems in some games -int const cgb_05 = 0; // enables CGB-05 zombie behavior - -int const trigger_mask = 0x80; -int const length_enabled = 0x40; - -void Osc_reset( struct Gb_Osc* this ) -{ - this->output = NULL; - this->last_amp = 0; - this->delay = 0; - this->phase = 0; - this->enabled = false; -} - -static inline void Osc_update_amp( struct Gb_Osc* this, blip_time_t time, int new_amp ) -{ - Blip_set_modified( this->output ); - int delta = new_amp - this->last_amp; - if ( delta ) - { - this->last_amp = new_amp; - Synth_offset( this->synth, time, delta, this->output ); - } -} - -// Units - -void Osc_clock_length( struct Gb_Osc* this ) -{ - if ( (this->regs [4] & length_enabled) && this->length_ctr ) - { - if ( --this->length_ctr <= 0 ) - this->enabled = false; - } -} - -void Noise_clock_envelope( struct Gb_Noise* this ) -{ - if ( this->env_enabled && --this->env_delay <= 0 && Noise_reload_env_timer( this ) ) - { - int v = this->volume + (this->osc.regs [2] & 0x08 ? +1 : -1); - if ( 0 <= v && v <= 15 ) - this->volume = v; - else - this->env_enabled = false; - } -} - -void Square_clock_envelope( struct Gb_Square* this ) -{ - if ( this->env_enabled && --this->env_delay <= 0 && Square_reload_env_timer( this ) ) - { - int v = this->volume + (this->osc.regs [2] & 0x08 ? +1 : -1); - if ( 0 <= v && v <= 15 ) - this->volume = v; - else - this->env_enabled = false; - } -} - -static inline void reload_sweep_timer( struct Gb_Square* this ) -{ - this->sweep_delay = (this->osc.regs [0] & period_mask) >> 4; - if ( !this->sweep_delay ) - this->sweep_delay = 8; -} - -static void calc_sweep( struct Gb_Square* this, bool update ) -{ - struct Gb_Osc* osc = &this->osc; - int const shift = osc->regs [0] & shift_mask; - int const delta = this->sweep_freq >> shift; - this->sweep_neg = (osc->regs [0] & 0x08) != 0; - int const freq = this->sweep_freq + (this->sweep_neg ? -delta : delta); - - if ( freq > 0x7FF ) - { - osc->enabled = false; - } - else if ( shift && update ) - { - this->sweep_freq = freq; - - osc->regs [3] = freq & 0xFF; - osc->regs [4] = (osc->regs [4] & ~0x07) | (freq >> 8 & 0x07); - } -} - -void clock_sweep( struct Gb_Square* this ) -{ - if ( --this->sweep_delay <= 0 ) - { - reload_sweep_timer( this ); - if ( this->sweep_enabled && (this->osc.regs [0] & period_mask) ) - { - calc_sweep( this, true ); - calc_sweep( this, false ); - } - } -} - -int wave_access( struct Gb_Wave* this, int addr ) -{ - if ( this->osc.enabled ) - { - addr = this->osc.phase & (wave_bank_size - 1); - if ( this->osc.mode == mode_dmg ) - { - addr++; - if ( this->osc.delay > clk_mul ) - return -1; // can only access within narrow time window while playing - } - addr >>= 1; - } - return addr & 0x0F; -} - -// write_register - -static int write_trig( struct Gb_Osc* this, int frame_phase, int max_len, int old_data ) -{ - int data = this->regs [4]; - - if ( (frame_phase & 1) && !(old_data & length_enabled) && this->length_ctr ) - { - if ( (data & length_enabled) || cgb_02 ) - this->length_ctr--; - } - - if ( data & trigger_mask ) - { - this->enabled = true; - if ( !this->length_ctr ) - { - this->length_ctr = max_len; - if ( (frame_phase & 1) && (data & length_enabled) ) - this->length_ctr--; - } - } - - if ( !this->length_ctr ) - this->enabled = false; - - return data & trigger_mask; -} - -static inline void Noise_zombie_volume( struct Gb_Noise* this, int old, int data ) -{ - int v = this->volume; - if ( this->osc.mode == mode_agb || cgb_05 ) - { - // CGB-05 behavior, very close to AGB behavior as well - if ( (old ^ data) & 8 ) - { - if ( !(old & 8) ) - { - v++; - if ( old & 7 ) - v++; - } - - v = 16 - v; - } - else if ( (old & 0x0F) == 8 ) - { - v++; - } - } - else - { - // CGB-04&02 behavior, very close to MGB behavior as well - if ( !(old & 7) && this->env_enabled ) - v++; - else if ( !(old & 8) ) - v += 2; - - if ( (old ^ data) & 8 ) - v = 16 - v; - } - this->volume = v & 0x0F; -} - -static inline void Square_zombie_volume( struct Gb_Square* this, int old, int data ) -{ - int v = this->volume; - if ( this->osc.mode == mode_agb || cgb_05 ) - { - // CGB-05 behavior, very close to AGB behavior as well - if ( (old ^ data) & 8 ) - { - if ( !(old & 8) ) - { - v++; - if ( old & 7 ) - v++; - } - - v = 16 - v; - } - else if ( (old & 0x0F) == 8 ) - { - v++; - } - } - else - { - // CGB-04&02 behavior, very close to MGB behavior as well - if ( !(old & 7) && this->env_enabled ) - v++; - else if ( !(old & 8) ) - v += 2; - - if ( (old ^ data) & 8 ) - v = 16 - v; - } - this->volume = v & 0x0F; -} - -static bool Square_write_register( struct Gb_Square* this, int frame_phase, int reg, int old_data, int data ) -{ - int const max_len = 64; - - switch ( reg ) - { - case 1: - this->osc.length_ctr = max_len - (data & (max_len - 1)); - break; - - case 2: - if ( !Square_dac_enabled( this ) ) - this->osc.enabled = false; - - Square_zombie_volume( this, old_data, data ); - - if ( (data & 7) && this->env_delay == 8 ) - { - this->env_delay = 1; - Square_clock_envelope( this ); // TODO: really happens at next length clock - } - break; - - case 4: - if ( write_trig( &this->osc, frame_phase, max_len, old_data ) ) - { - this->volume = this->osc.regs [2] >> 4; - Square_reload_env_timer( this ); - this->env_enabled = true; - if ( frame_phase == 7 ) - this->env_delay++; - if ( !Square_dac_enabled( this ) ) - this->osc.enabled = false; - this->osc.delay = (this->osc.delay & (4 * clk_mul - 1)) + Square_period( this ); - return true; - } - } - - return false; -} - -static inline void Noise_write_register( struct Gb_Noise* this, int frame_phase, int reg, int old_data, int data ) -{ - int const max_len = 64; - - switch ( reg ) - { - case 1: - this->osc.length_ctr = max_len - (data & (max_len - 1)); - break; - - case 2: - if ( !Noise_dac_enabled( this ) ) - this->osc.enabled = false; - - Noise_zombie_volume( this, old_data, data ); - - if ( (data & 7) && this->env_delay == 8 ) - { - this->env_delay = 1; - Noise_clock_envelope( this ); // TODO: really happens at next length clock - } - break; - - case 4: - if ( write_trig( &this->osc, frame_phase, max_len, old_data ) ) - { - this->volume = this->osc.regs [2] >> 4; - Noise_reload_env_timer( this ); - this->env_enabled = true; - if ( frame_phase == 7 ) - this->env_delay++; - if ( !Noise_dac_enabled( this ) ) - this->osc.enabled = false; - - this->osc.phase = 0x7FFF; - this->osc.delay += 8 * clk_mul; - } - } -} - -static inline void Sweep_write_register( struct Gb_Square* this, int frame_phase, int reg, int old_data, int data ) -{ - if ( reg == 0 && this->sweep_enabled && this->sweep_neg && !(data & 0x08) ) - this->osc.enabled = false; // sweep negate disabled after used - - if ( Square_write_register( this, frame_phase, reg, old_data, data ) ) - { - this->sweep_freq = Osc_frequency( &this->osc ); - this->sweep_neg = false; - reload_sweep_timer( this ); - this->sweep_enabled = (this->osc.regs [0] & (period_mask | shift_mask)) != 0; - if ( this->osc.regs [0] & shift_mask ) - calc_sweep( this, false ); - } -} - -static void corrupt_wave( struct Gb_Wave* this ) -{ - int pos = ((this->osc.phase + 1) & (wave_bank_size - 1)) >> 1; - if ( pos < 4 ) - this->wave_ram [0] = this->wave_ram [pos]; - else { - int i; - for ( i = 4; --i >= 0; ) - this->wave_ram [i] = this->wave_ram [(pos & ~3) + i]; - } -} - -static inline void Wave_write_register( struct Gb_Wave* this, int frame_phase, int reg, int old_data, int data ) -{ - int const max_len = 256; - - switch ( reg ) - { - case 0: - if ( !Wave_dac_enabled( this ) ) - this->osc.enabled = false; - break; - - case 1: - this->osc.length_ctr = max_len - data; - break; - - case 4: - { - bool was_enabled = this->osc.enabled; - if ( write_trig( &this->osc, frame_phase, max_len, old_data ) ) - { - if ( !Wave_dac_enabled( this ) ) - this->osc.enabled = false; - else if ( this->osc.mode == mode_dmg && was_enabled && - (unsigned) (this->osc.delay - 2 * clk_mul) < 2 * clk_mul ) - corrupt_wave( this ); - - this->osc.phase = 0; - this->osc.delay = Wave_period( this ) + 6 * clk_mul; - } - } - } -} - -void write_osc( struct Gb_Apu* this, int reg, int old_data, int data ) -{ - int index = (reg * 3 + 3) >> 4; // avoids divide - assert( index == reg / 5 ); - reg -= index * 5; - switch ( index ) - { - case 0: Sweep_write_register ( &this->square1, this->frame_phase, reg, old_data, data ); break; - case 1: Square_write_register( &this->square2, this->frame_phase, reg, old_data, data ); break; - case 2: Wave_write_register ( &this->wave, this->frame_phase, reg, old_data, data ); break; - case 3: Noise_write_register ( &this->noise, this->frame_phase, reg, old_data, data ); break; - } -} - -// Synthesis - -void Square_run( struct Gb_Square* this, blip_time_t time, blip_time_t end_time ) -{ - // Calc duty and phase - static byte const duty_offsets [4] = { 1, 1, 3, 7 }; - static byte const duties [4] = { 1, 2, 4, 6 }; - - struct Gb_Osc* osc = &this->osc; - int const duty_code = osc->regs [1] >> 6; - int duty_offset = duty_offsets [duty_code]; - int duty = duties [duty_code]; - if ( osc->mode == mode_agb ) - { - // AGB uses inverted duty - duty_offset -= duty; - duty = 8 - duty; - } - int ph = (osc->phase + duty_offset) & 7; - - // Determine what will be generated - int vol = 0; - struct Blip_Buffer* const out = osc->output; - if ( out ) - { - int amp = osc->dac_off_amp; - if ( Square_dac_enabled( this ) ) - { - if ( osc->enabled ) - vol = this->volume; - - amp = -dac_bias; - if ( osc->mode == mode_agb ) - amp = -(vol >> 1); - - // Play inaudible frequencies as constant amplitude - if ( Osc_frequency( osc ) >= 0x7FA && osc->delay < 32 * clk_mul ) - { - amp += (vol * duty) >> 3; - vol = 0; - } - - if ( ph < duty ) - { - amp += vol; - vol = -vol; - } - } - Osc_update_amp( osc, time, amp ); - } - - // Generate wave - time += osc->delay; - if ( time < end_time ) - { - int const per = Square_period( this ); - if ( !vol ) - { - #ifdef GB_APU_FAST - time = end_time; - #else - // Maintain phase when not playing - int count = (end_time - time + per - 1) / per; - ph += count; // will be masked below - time += (blip_time_t) count * per; - #endif - } - else - { - // Output amplitude transitions - int delta = vol; - do - { - ph = (ph + 1) & 7; - if ( ph == 0 || ph == duty ) - { - Synth_offset_inline( osc->synth, time, delta, out ); - delta = -delta; - } - time += per; - } - while ( time < end_time ); - - if ( delta != vol ) - osc->last_amp -= delta; - } - osc->phase = (ph - duty_offset) & 7; - } - osc->delay = time - end_time; -} - -#ifndef GB_APU_FAST -// Quickly runs LFSR for a large number of clocks. For use when noise is generating -// no sound. -static unsigned run_lfsr( unsigned s, unsigned mask, int count ) -{ - bool const optimized = true; // set to false to use only unoptimized loop in middle - - // optimization used in several places: - // ((s & (1 << b)) << n) ^ ((s & (1 << b)) << (n + 1)) = (s & (1 << b)) * (3 << n) - - if ( mask == 0x4000 && optimized ) - { - if ( count >= 32767 ) - count %= 32767; - - // Convert from Fibonacci to Galois configuration, - // shifted left 1 bit - s ^= (s & 1) * 0x8000; - - // Each iteration is equivalent to clocking LFSR 255 times - while ( (count -= 255) > 0 ) - s ^= ((s & 0xE) << 12) ^ ((s & 0xE) << 11) ^ (s >> 3); - count += 255; - - // Each iteration is equivalent to clocking LFSR 15 times - // (interesting similarity to single clocking below) - while ( (count -= 15) > 0 ) - s ^= ((s & 2) * (3 << 13)) ^ (s >> 1); - count += 15; - - // Remaining singles - while ( --count >= 0 ) - s = ((s & 2) * (3 << 13)) ^ (s >> 1); - - // Convert back to Fibonacci configuration - s &= 0x7FFF; - } - else if ( count < 8 || !optimized ) - { - // won't fully replace upper 8 bits, so have to do the unoptimized way - while ( --count >= 0 ) - s = (s >> 1 | mask) ^ (mask & -((s - 1) & 2)); - } - else - { - if ( count > 127 ) - { - count %= 127; - if ( !count ) - count = 127; // must run at least once - } - - // Need to keep one extra bit of history - s = s << 1 & 0xFF; - - // Convert from Fibonacci to Galois configuration, - // shifted left 2 bits - s ^= (s & 2) * 0x80; - - // Each iteration is equivalent to clocking LFSR 7 times - // (interesting similarity to single clocking below) - while ( (count -= 7) > 0 ) - s ^= ((s & 4) * (3 << 5)) ^ (s >> 1); - count += 7; - - // Remaining singles - while ( --count >= 0 ) - s = ((s & 4) * (3 << 5)) ^ (s >> 1); - - // Convert back to Fibonacci configuration and - // repeat last 8 bits above significant 7 - s = (s << 7 & 0x7F80) | (s >> 1 & 0x7F); - } - - return s; -} -#endif - -void Noise_run( struct Gb_Noise* this, blip_time_t time, blip_time_t end_time ) -{ - // Determine what will be generated - int vol = 0; - struct Gb_Osc* osc = &this->osc; - struct Blip_Buffer* const out = osc->output; - if ( out ) - { - int amp = osc->dac_off_amp; - if ( Noise_dac_enabled( this ) ) - { - if ( osc->enabled ) - vol = this->volume; - - amp = -dac_bias; - if ( osc->mode == mode_agb ) - amp = -(vol >> 1); - - if ( !(osc->phase & 1) ) - { - amp += vol; - vol = -vol; - } - } - - // AGB negates final output - if ( osc->mode == mode_agb ) - { - vol = -vol; - amp = -amp; - } - - Osc_update_amp( osc, time, amp ); - } - - // Run timer and calculate time of next LFSR clock - static byte const period1s [8] = { 1, 2, 4, 6, 8, 10, 12, 14 }; - int const period1 = period1s [osc->regs [3] & 7] * clk_mul; - - #ifdef GB_APU_FAST - time += delay; - #else - { - int extra = (end_time - time) - osc->delay; - int const per2 = period2( this, 8 ); - time += osc->delay + ((this->divider ^ (per2 >> 1)) & (per2 - 1)) * period1; - - int count = (extra < 0 ? 0 : (extra + period1 - 1) / period1); - this->divider = (this->divider - count) & period2_mask; - osc->delay = count * period1 - extra; - } - #endif - - // Generate wave - if ( time < end_time ) - { - unsigned const mask = lfsr_mask( this ); - unsigned bits = osc->phase; - - int per = period2( this, period1 * 8 ); - #ifdef GB_APU_FAST - // Noise can be THE biggest time hog; adjust as necessary - int const min_period = 24; - if ( per < min_period ) - per = min_period; - #endif - if ( period2_index( this ) >= 0xE ) - { - time = end_time; - } - else if ( !vol ) - { - #ifdef GB_APU_FAST - time = end_time; - #else - // Maintain phase when not playing - int count = (end_time - time + per - 1) / per; - time += (blip_time_t) count * per; - bits = run_lfsr( bits, ~mask, count ); - #endif - } - else - { - struct Blip_Synth* synth = osc->synth; // cache - - // Output amplitude transitions - int delta = -vol; - do - { - unsigned changed = bits + 1; - bits = bits >> 1 & mask; - if ( changed & 2 ) - { - bits |= ~mask; - delta = -delta; - Synth_offset_inline( synth, time, delta, out ); - } - time += per; - } - while ( time < end_time ); - - if ( delta == vol ) - osc->last_amp += delta; - } - osc->phase = bits; - } - - #ifdef GB_APU_FAST - osc->delay = time - end_time; - #endif -} - -void Wave_run( struct Gb_Wave* this, blip_time_t time, blip_time_t end_time ) -{ - // Calc volume -#ifdef GB_APU_NO_AGB - static byte const shifts [4] = { 4+4, 0+4, 1+4, 2+4 }; - int const volume_idx = this->regs [2] >> 5 & 3; - int const volume_shift = shifts [volume_idx]; - int const volume_mul = 1; -#else - static byte const volumes [8] = { 0, 4, 2, 1, 3, 3, 3, 3 }; - int const volume_shift = 2 + 4; - int const volume_idx = this->osc.regs [2] >> 5 & (this->agb_mask | 3); // 2 bits on DMG/CGB, 3 on AGB - int const volume_mul = volumes [volume_idx]; -#endif - - // Determine what will be generated - int playing = false; - struct Gb_Osc* osc = &this->osc; - struct Blip_Buffer* out = osc->output; - if ( out ) - { - int amp = osc->dac_off_amp; - if ( Wave_dac_enabled( this ) ) - { - // Play inaudible frequencies as constant amplitude - amp = 8 << 4; // really depends on average of all samples in wave - - // if delay is larger, constant amplitude won't start yet - if ( Osc_frequency( osc ) <= 0x7FB || osc->delay > 15 * clk_mul ) - { - if ( volume_mul && volume_shift != 4+4 ) - playing = (int) osc->enabled; - - amp = (this->sample_buf << (osc->phase << 2 & 4) & 0xF0) * playing; - } - - amp = ((amp * volume_mul) >> volume_shift) - dac_bias; - } - Osc_update_amp( osc, time, amp ); - } - - // Generate wave - time += osc->delay; - if ( time < end_time ) - { - byte const* wave = this->wave_ram; - - // wave size and bank - #ifdef GB_APU_NO_AGB - int const wave_mask = 0x1F; - int const swap_banks = 0; - #else - int const size20_mask = 0x20; - int const flags = osc->regs [0] & this->agb_mask; - int const wave_mask = (flags & size20_mask) | 0x1F; - int swap_banks = 0; - if ( flags & bank40_mask ) - { - swap_banks = flags & size20_mask; - wave += wave_bank_size/2 - (swap_banks >> 1); - } - #endif - - int ph = osc->phase ^ swap_banks; - ph = (ph + 1) & wave_mask; // pre-advance - - int const per = Wave_period( this ); - if ( !playing ) - { - #ifdef GB_APU_FAST - time = end_time; - #else - // Maintain phase when not playing - int count = (end_time - time + per - 1) / per; - ph += count; // will be masked below - time += (blip_time_t) count * per; - #endif - } - else - { - struct Blip_Synth* synth = osc->synth; // cache - - // Output amplitude transitions - int lamp = osc->last_amp + dac_bias; - do - { - // Extract nibble - int nibble = wave [ph >> 1] << (ph << 2 & 4) & 0xF0; - ph = (ph + 1) & wave_mask; - - // Scale by volume - int amp = (nibble * volume_mul) >> volume_shift; - - int delta = amp - lamp; - if ( delta ) - { - lamp = amp; - Synth_offset_inline( synth, time, delta, out ); - } - time += per; - } - while ( time < end_time ); - osc->last_amp = lamp - dac_bias; - } - ph = (ph - 1) & wave_mask; // undo pre-advance and mask position - - // Keep track of last byte read - if ( osc->enabled ) - this->sample_buf = wave [ph >> 1]; - - osc->phase = ph ^ swap_banks; // undo swapped banks - } - osc->delay = time - end_time; -} diff --git a/apps/codecs/libgme/gb_oscs.h b/apps/codecs/libgme/gb_oscs.h deleted file mode 100644 index 3c8dfef51f..0000000000 --- a/apps/codecs/libgme/gb_oscs.h +++ /dev/null @@ -1,187 +0,0 @@ -// Private oscillators used by Gb_Apu - -// Gb_Snd_Emu 0.1.4 -#ifndef GB_OSCS_H -#define GB_OSCS_H - -#include "blargg_common.h" -#include "blip_buffer.h" - -#ifndef GB_APU_OVERCLOCK - #define GB_APU_OVERCLOCK 1 -#endif - -#if GB_APU_OVERCLOCK & (GB_APU_OVERCLOCK - 1) - #error "GB_APU_OVERCLOCK must be a power of 2" -#endif - -enum { clk_mul = GB_APU_OVERCLOCK }; -enum { dac_bias = 7 }; - -struct Gb_Osc { - struct Blip_Buffer* outputs [4];// NULL, right, left, center - struct Blip_Buffer* output; // where to output sound - uint8_t* regs; // osc's 5 registers - int mode; // mode_dmg, mode_cgb, mode_agb - int dac_off_amp;// amplitude when DAC is off - int last_amp; // current amplitude in Blip_Buffer - - struct Blip_Synth* synth; - - int delay; // clocks until frequency timer expires - int length_ctr; // length counter - unsigned phase; // waveform phase (or equivalent) - bool enabled; // internal enabled flag -}; - -// 11-bit frequency in NRx3 and NRx4 -static inline int Osc_frequency( struct Gb_Osc* this ) { return (this->regs [4] & 7) * 0x100 + this->regs [3]; } - -void Osc_clock_length( struct Gb_Osc* this ); -void Osc_reset( struct Gb_Osc* this ); - -// Square - -enum { period_mask = 0x70 }; -enum { shift_mask = 0x07 }; - -struct Gb_Square { - struct Gb_Osc osc; - - int env_delay; - int volume; - bool env_enabled; - - // Sweep square - int sweep_freq; - int sweep_delay; - bool sweep_enabled; - bool sweep_neg; -}; - -void Square_run( struct Gb_Square* this, blip_time_t, blip_time_t ); -void Square_clock_envelope( struct Gb_Square* this ); - -static inline void Square_reset( struct Gb_Square* this ) -{ - this->env_delay = 0; - this->volume = 0; - Osc_reset( &this->osc ); - this->osc.delay = 0x40000000; // TODO: something less hacky (never clocked until first trigger) -} -// Frequency timer period -static inline int Square_period( struct Gb_Square* this ) { return (2048 - Osc_frequency( &this->osc )) * (4 * clk_mul); } -static inline int Square_dac_enabled( struct Gb_Square* this) { return this->osc.regs [2] & 0xF8; } -static inline int Square_reload_env_timer( struct Gb_Square* this ) -{ - int raw = this->osc.regs [2] & 7; - this->env_delay = (raw ? raw : 8); - return raw; -} - -// Sweep square - -void clock_sweep( struct Gb_Square* this ); - -static inline void Sweep_reset( struct Gb_Square* this ) -{ - this->sweep_freq = 0; - this->sweep_delay = 0; - this->sweep_enabled = false; - this->sweep_neg = false; - - this->env_delay = 0; - this->volume = 0; - Osc_reset( &this->osc ); - this->osc.delay = 0x40000000; // TODO: something less hacky (never clocked until first trigger) -} - -// Noise - -enum { period2_mask = 0x1FFFF }; - -struct Gb_Noise { - struct Gb_Osc osc; - - int env_delay; - int volume; - bool env_enabled; - - int divider; // noise has more complex frequency divider setup -}; - -void Noise_run( struct Gb_Noise* this, blip_time_t, blip_time_t ); - -static inline void Noise_reset( struct Gb_Noise* this ) -{ - this->divider = 0; - - this->env_delay = 0; - this->volume = 0; - Osc_reset( &this->osc ); - this->osc.delay = 4 * clk_mul; // TODO: remove? -} - -void Noise_clock_envelope( struct Gb_Noise* this ); - -// Non-zero if DAC is enabled -static inline int Noise_dac_enabled( struct Gb_Noise* this) { return this->osc.regs [2] & 0xF8; } -static inline int Noise_reload_env_timer( struct Gb_Noise* this ) -{ - int raw = this->osc.regs [2] & 7; - this->env_delay = (raw ? raw : 8); - return raw; -} - -static inline int period2_index( struct Gb_Noise* this ) { return this->osc.regs [3] >> 4; } -static inline int period2( struct Gb_Noise* this, int base ) { return base << period2_index( this ); } -static inline unsigned lfsr_mask( struct Gb_Noise* this ) { return (this->osc.regs [3] & 0x08) ? ~0x4040 : ~0x4000; } - -// Wave - -enum { bank40_mask = 0x40 }; -enum { wave_bank_size = 32 }; - -struct Gb_Wave { - struct Gb_Osc osc; - - int sample_buf; // last wave RAM byte read (hardware has this as well) - - int agb_mask; // 0xFF if AGB features enabled, 0 otherwise - uint8_t* wave_ram; // 32 bytes (64 nybbles), stored in APU -}; - -void Wave_run( struct Gb_Wave* this, blip_time_t, blip_time_t ); - -static inline void Wave_reset( struct Gb_Wave* this ) -{ - this->sample_buf = 0; - Osc_reset( &this->osc ); -} - -// Frequency timer period -static inline int Wave_period( struct Gb_Wave* this ) { return (2048 - Osc_frequency( &this->osc )) * (2 * clk_mul); } - -// Non-zero if DAC is enabled -static inline int Wave_dac_enabled( struct Gb_Wave* this ) { return this->osc.regs [0] & 0x80; } - -static inline uint8_t* wave_bank( struct Gb_Wave* this ) { return &this->wave_ram [(~this->osc.regs [0] & bank40_mask) >> 2 & this->agb_mask]; } - -// Wave index that would be accessed, or -1 if no access would occur -int wave_access( struct Gb_Wave* this, int addr ); - -// Reads/writes wave RAM -static inline int Wave_read( struct Gb_Wave* this, int addr ) -{ - int index = wave_access( this, addr ); - return (index < 0 ? 0xFF : wave_bank( this ) [index]); -} - -static inline void Wave_write( struct Gb_Wave* this, int addr, int data ) -{ - int index = wave_access( this, addr ); - if ( index >= 0 ) - wave_bank( this ) [index] = data;; -} - -#endif diff --git a/apps/codecs/libgme/gbs_cpu.c b/apps/codecs/libgme/gbs_cpu.c deleted file mode 100644 index 1015dd5358..0000000000 --- a/apps/codecs/libgme/gbs_cpu.c +++ /dev/null @@ -1,120 +0,0 @@ -// Game_Music_Emu 0.6-pre. http://www.slack.net/~ant/ - -#include "gbs_emu.h" -#include "blargg_endian.h" - -/* Copyright (C) 2003-2009 Shay Green. This module is free software; you -can redistribute it and/or modify it under the terms of the GNU Lesser -General Public License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. This -module is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more -details. You should have received a copy of the GNU Lesser General Public -License along with this module; if not, write to the Free Software Foundation, -Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ - -#include "blargg_source.h" - -#ifndef LOG_MEM - #define LOG_MEM( addr, str, data ) data -#endif - -int read_mem( struct Gbs_Emu* this, addr_t addr ) -{ - int result = *Cpu_get_code( &this->cpu, addr ); - if ( (unsigned) (addr - io_addr) < io_size ) - result = Apu_read_register( &this->apu, Time( this ), addr ); - - return LOG_MEM( addr, ">", result ); -} - -static inline void write_io_inline( struct Gbs_Emu* this, int offset, int data, int base ) -{ - if ( (unsigned) (offset - (io_addr - base)) < io_size ) - Apu_write_register( &this->apu, Time( this ), offset + base, data & 0xFF ); - else if ( (unsigned) (offset - (0xFF06 - base)) < 2 ) - update_timer( this ); - else if ( offset == io_base - base ) - this->ram [base - ram_addr + offset] = 0; // keep joypad return value 0 - else - this->ram [base - ram_addr + offset] = 0xFF; -} - -void write_mem( struct Gbs_Emu* this, addr_t addr, int data ) -{ - (void) LOG_MEM( addr, "<", data ); - - int offset = addr - ram_addr; - if ( (unsigned) offset < 0x10000 - ram_addr ) - { - this->ram [offset] = data; - - offset -= 0xE000 - ram_addr; - if ( (unsigned) offset < 0x1F80 ) - write_io_inline( this, offset, data, 0xE000 ); - } - else if ( (unsigned) (offset - (0x2000 - ram_addr)) < 0x2000 ) - { - set_bank( this, data & 0xFF ); - } -#ifndef NDEBUG - else if ( unsigned (addr - 0x8000) < 0x2000 || unsigned (addr - 0xE000) < 0x1F00 ) - { - /* dprintf( "Unmapped write $%04X\n", (unsigned) addr ); */ - } -#endif -} - -static void write_io_( struct Gbs_Emu* this, int offset, int data ) -{ - write_io_inline( this, offset, data, io_base ); -} - -static inline void write_io( struct Gbs_Emu* this, int offset, int data ) -{ - (void) LOG_MEM( offset + io_base, "<", data ); - - this->ram [io_base - ram_addr + offset] = data; - if ( (unsigned) offset < 0x80 ) - write_io_( this, offset, data ); -} - -static int read_io( struct Gbs_Emu* this, int offset ) -{ - int const io_base = 0xFF00; - int result = this->ram [io_base - ram_addr + offset]; - - if ( (unsigned) (offset - (io_addr - io_base)) < io_size ) - { - result = Apu_read_register( &this->apu, Time( this ), offset + io_base ); - (void) LOG_MEM( offset + io_base, ">", result ); - } - else - { - check( result == read_mem( offset + io_base ) ); - } - return result; -} - -#define READ_FAST( emu, addr, out ) \ -{\ - out = READ_CODE( addr );\ - if ( (unsigned) (addr - io_addr) < io_size )\ - out = LOG_MEM( addr, ">", Apu_read_register( &emu->apu, TIME() + emu->end_time, addr ) );\ - else\ - check( out == Read_mem( emu, addr ) );\ -} - -#define READ_MEM( emu, addr ) read_mem( emu, addr ) -#define WRITE_MEM( emu, addr, data ) write_mem( emu, addr, data ) - -#define WRITE_IO( emu, addr, data ) write_io( emu, addr, data ) -#define READ_IO( emu, addr, out ) out = read_io( emu, addr ) - -#define CPU_BEGIN \ -void run_cpu( struct Gbs_Emu* this )\ -{ \ - struct Gb_Cpu* cpu = &this->cpu; - #include "gb_cpu_run.h" -} diff --git a/apps/codecs/libgme/gbs_emu.c b/apps/codecs/libgme/gbs_emu.c deleted file mode 100644 index 7a6d484673..0000000000 --- a/apps/codecs/libgme/gbs_emu.c +++ /dev/null @@ -1,452 +0,0 @@ -// Game_Music_Emu 0.5.2. http://www.slack.net/~ant/ - -#include "gbs_emu.h" - -#include "blargg_endian.h" - -/* Copyright (C) 2003-2006 Shay Green. this module is free software; you -can redistribute it and/or modify it under the terms of the GNU Lesser -General Public License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. this -module is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more -details. You should have received a copy of the GNU Lesser General Public -License along with this module; if not, write to the Free Software Foundation, -Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ - -#include "blargg_source.h" - -const char gme_wrong_file_type [] = "Wrong file type for this emulator"; - -int const idle_addr = 0xF00D; -int const tempo_unit = 16; - -static void clear_track_vars( struct Gbs_Emu* this ) -{ - this->current_track_ = -1; - track_stop( &this->track_filter ); -} - -void Gbs_init( struct Gbs_Emu* this ) -{ - this->sample_rate_ = 0; - this->mute_mask_ = 0; - this->tempo_ = (int)(FP_ONE_TEMPO); - - // Unload - this->header.timer_mode = 0; - - // defaults - this->tfilter = *track_get_setup( &this->track_filter ); - this->tfilter.max_initial = 21; - this->tfilter.lookahead = 6; - this->track_filter.silence_ignored_ = false; - - Sound_set_gain( this, (int)(FP_ONE_GAIN*1.2) ); - - Rom_init( &this->rom, 0x4000 ); - - Apu_init( &this->apu ); - Cpu_init( &this->cpu ); - - this->tempo = tempo_unit; - this->sound_hardware = sound_gbs; - - // Reduce apu sound clicks? - Apu_reduce_clicks( &this->apu, true ); - - // clears fields - this->voice_count_ = 0; - this->voice_types_ = 0; - clear_track_vars( this ); -} - -static blargg_err_t check_gbs_header( void const* header ) -{ - if ( memcmp( header, "GBS", 3 ) ) - return gme_wrong_file_type; - return 0; -} - -// Setup - -blargg_err_t Gbs_load_mem( struct Gbs_Emu* this, void* data, long size ) -{ - // Unload - this->header.timer_mode = 0; - this->voice_count_ = 0; - this->track_count = 0; - this->m3u.size = 0; - clear_track_vars( this ); - - assert( offsetof (struct header_t,copyright [32]) == header_size ); - RETURN_ERR( Rom_load( &this->rom, data, size, header_size, &this->header, 0 ) ); - - RETURN_ERR( check_gbs_header( &this->header ) ); - - /* Ignore warnings? */ - /*if ( header_.vers != 1 ) - warning( "Unknown file version" ); - - if ( header_.timer_mode & 0x78 ) - warning( "Invalid timer mode" ); */ - - /* unsigned load_addr = get_le16( this->header.load_addr ); */ - /* if ( (header_.load_addr [1] | header_.init_addr [1] | header_.play_addr [1]) > 0x7F || - load_addr < 0x400 ) - warning( "Invalid load/init/play address" ); */ - - unsigned load_addr = get_le16( this->header.load_addr ); - /* if ( (this->header.load_addr [1] | this->header.init_addr [1] | this->header.play_addr [1]) > 0x7F || - load_addr < 0x400 ) - warning( "Invalid load/init/play address" ); */ - - this->cpu.rst_base = load_addr; - Rom_set_addr( &this->rom, load_addr ); - - this->voice_count_ = osc_count; - static int const types [osc_count] = { - wave_type+1, wave_type+2, wave_type+3, mixed_type+1 - }; - this->voice_types_ = types; - - Apu_volume( &this->apu, this->gain_ ); - - // Change clock rate & setup buffer - this->clock_rate_ = 4194304; - Buffer_clock_rate( &this->stereo_buf, 4194304 ); - RETURN_ERR( Buffer_set_channel_count( &this->stereo_buf, this->voice_count_, this->voice_types_ ) ); - this->buf_changed_count = Buffer_channels_changed_count( &this->stereo_buf ); - - // Post load - Sound_set_tempo( this, this->tempo_ ); - Sound_mute_voices( this, this->mute_mask_ ); - - // Set track count - this->track_count = this->header.track_count; - return 0; -} - -// Emulation - -// see gb_cpu_io.h for read/write functions - -void set_bank( struct Gbs_Emu* this, int n ) -{ - addr_t addr = mask_addr( n * this->rom.bank_size, this->rom.mask ); - if ( addr == 0 && this->rom.size > this->rom.bank_size ) - addr = this->rom.bank_size; // MBC1&2 behavior, bank 0 acts like bank 1 - Cpu_map_code( &this->cpu, this->rom.bank_size, this->rom.bank_size, Rom_at_addr( &this->rom, addr ) ); -} - -void update_timer( struct Gbs_Emu* this ) -{ - this->play_period = 70224 / tempo_unit; /// 59.73 Hz - - if ( this->header.timer_mode & 0x04 ) - { - // Using custom rate - static byte const rates [4] = { 6, 0, 2, 4 }; - // TODO: emulate double speed CPU mode rather than halving timer rate - int double_speed = this->header.timer_mode >> 7; - int shift = rates [this->ram [hi_page + 7] & 3] - double_speed; - this->play_period = (256 - this->ram [hi_page + 6]) << shift; - } - - this->play_period *= this->tempo; -} - -// Jumps to routine, given pointer to address in file header. Pushes idle_addr -// as return address, NOT old PC. -void jsr_then_stop( struct Gbs_Emu* this, byte const addr [] ) -{ - check( this->cpu.r.sp == get_le16( this->header.stack_ptr ) ); - this->cpu.r.pc = get_le16( addr ); - write_mem( this, --this->cpu.r.sp, idle_addr >> 8 ); - write_mem( this, --this->cpu.r.sp, idle_addr ); -} - -static blargg_err_t run_until( struct Gbs_Emu* this, int end ) -{ - this->end_time = end; - Cpu_set_time( &this->cpu, Cpu_time( &this->cpu ) - end ); - while ( true ) - { - run_cpu( this ); - if ( Cpu_time( &this->cpu ) >= 0 ) - break; - - if ( this->cpu.r.pc == idle_addr ) - { - if ( this->next_play > this->end_time ) - { - Cpu_set_time( &this->cpu, 0 ); - break; - } - - if ( Cpu_time( &this->cpu ) < this->next_play - this->end_time ) - Cpu_set_time( &this->cpu, this->next_play - this->end_time ); - this->next_play += this->play_period; - jsr_then_stop( this, this->header.play_addr ); - } - else if ( this->cpu.r.pc > 0xFFFF ) - { - /* warning( "PC wrapped around\n" ); */ - this->cpu.r.pc &= 0xFFFF; - } - else - { - /* warning( "Emulation error (illegal/unsupported instruction)" ); */ - this->cpu.r.pc = (this->cpu.r.pc + 1) & 0xFFFF; - Cpu_set_time( &this->cpu, Cpu_time( &this->cpu ) + 6 ); - } - } - - return 0; -} - -static blargg_err_t end_frame( struct Gbs_Emu* this, int end ) -{ - RETURN_ERR( run_until( this, end ) ); - - this->next_play -= end; - if ( this->next_play < 0 ) // happens when play routine takes too long - { - #if !defined(GBS_IGNORE_STARVED_PLAY) - check( false ); - #endif - this->next_play = 0; - } - - Apu_end_frame( &this->apu, end ); - - return 0; -} - -blargg_err_t run_clocks( struct Gbs_Emu* this, blip_time_t duration ) -{ - return end_frame( this, duration ); -} - -blargg_err_t play_( void* emu, int count, sample_t* out ) -{ - struct Gbs_Emu* this = (struct Gbs_Emu*) emu; - - int remain = count; - while ( remain ) - { - Buffer_disable_immediate_removal( &this->stereo_buf ); - remain -= Buffer_read_samples( &this->stereo_buf, &out [count - remain], remain ); - if ( remain ) - { - if ( this->buf_changed_count != Buffer_channels_changed_count( &this->stereo_buf ) ) - { - this->buf_changed_count = Buffer_channels_changed_count( &this->stereo_buf ); - - // Remute voices - Sound_mute_voices( this, this->mute_mask_ ); - } - int msec = Buffer_length( &this->stereo_buf ); - blip_time_t clocks_emulated = msec * this->clock_rate_ / 1000 - 100; - RETURN_ERR( run_clocks( this, clocks_emulated ) ); - assert( clocks_emulated ); - Buffer_end_frame( &this->stereo_buf, clocks_emulated ); - } - } - return 0; -} - -blargg_err_t Gbs_set_sample_rate( struct Gbs_Emu* this, int rate ) -{ - require( !this->sample_rate_ ); // sample rate can't be changed once set - Buffer_init( &this->stereo_buf ); - RETURN_ERR( Buffer_set_sample_rate( &this->stereo_buf, rate, 1000 / 20 ) ); - - // Set bass frequency - Buffer_bass_freq( &this->stereo_buf, 300 ); - - this->sample_rate_ = rate; - RETURN_ERR( track_init( &this->track_filter, this ) ); - this->tfilter.max_silence = 6 * stereo * this->sample_rate_; - return 0; -} - - -// Sound - -void Sound_mute_voice( struct Gbs_Emu* this, int index, bool mute ) -{ - require( (unsigned) index < (unsigned) this->voice_count_ ); - int bit = 1 << index; - int mask = this->mute_mask_ | bit; - if ( !mute ) - mask ^= bit; - Sound_mute_voices( this, mask ); -} - -void Sound_mute_voices( struct Gbs_Emu* this, int mask ) -{ - require( this->sample_rate_ ); // sample rate must be set first - this->mute_mask_ = mask; - - int i; - for ( i = this->voice_count_; i--; ) - { - if ( mask & (1 << i) ) - { - Apu_set_output( &this->apu, i, 0, 0, 0 ); - } - else - { - struct channel_t ch = Buffer_channel( &this->stereo_buf, i ); - assert( (ch.center && ch.left && ch.right) || - (!ch.center && !ch.left && !ch.right) ); // all or nothing - Apu_set_output( &this->apu, i, ch.center, ch.left, ch.right ); - } - } -} - -void Sound_set_tempo( struct Gbs_Emu* this, int t ) -{ - require( this->sample_rate_ ); // sample rate must be set first - int const min = (int)(FP_ONE_TEMPO*0.02); - int const max = (int)(FP_ONE_TEMPO*4.00); - if ( t < min ) t = min; - if ( t > max ) t = max; - this->tempo_ = t; - - this->tempo = (int) ((tempo_unit * FP_ONE_TEMPO) / t); - Apu_set_tempo( &this->apu, t ); - update_timer( this ); -} - -blargg_err_t Gbs_start_track( struct Gbs_Emu* this, int track ) -{ - clear_track_vars( this ); - - // Remap track if playlist available - if ( this->m3u.size > 0 ) { - struct entry_t* e = &this->m3u.entries[track]; - track = e->track; - } - - this->current_track_ = track; - Buffer_clear( &this->stereo_buf ); - - // Reset APU to state expected by most rips - static byte const sound_data [] = { - 0x80, 0xBF, 0x00, 0x00, 0xB8, // square 1 DAC disabled - 0x00, 0x3F, 0x00, 0x00, 0xB8, // square 2 DAC disabled - 0x7F, 0xFF, 0x9F, 0x00, 0xB8, // wave DAC disabled - 0x00, 0xFF, 0x00, 0x00, 0xB8, // noise DAC disabled - 0x77, 0xFF, 0x80, // max volume, all chans in center, power on - }; - - enum sound_t mode = this->sound_hardware; - if ( mode == sound_gbs ) - mode = (this->header.timer_mode & 0x80) ? sound_cgb : sound_dmg; - - Apu_reset( &this->apu, (enum gb_mode_t) mode, false ); - Apu_write_register( &this->apu, 0, 0xFF26, 0x80 ); // power on - int i; - for ( i = 0; i < (int) sizeof sound_data; i++ ) - Apu_write_register( &this->apu, 0, i + io_addr, sound_data [i] ); - Apu_end_frame( &this->apu, 1 ); // necessary to get click out of the way */ - - memset( this->ram, 0, 0x4000 ); - memset( this->ram + 0x4000, 0xFF, 0x1F80 ); - memset( this->ram + 0x5F80, 0, sizeof this->ram - 0x5F80 ); - this->ram [hi_page] = 0; // joypad reads back as 0 - this->ram [idle_addr - ram_addr] = 0xED; // illegal instruction - this->ram [hi_page + 6] = this->header.timer_modulo; - this->ram [hi_page + 7] = this->header.timer_mode; - - Cpu_reset( &this->cpu, this->rom.unmapped ); - Cpu_map_code( &this->cpu, ram_addr, 0x10000 - ram_addr, this->ram ); - Cpu_map_code( &this->cpu, 0, this->rom.bank_size, Rom_at_addr( &this->rom, 0 ) ); - set_bank( this, this->rom.size > this->rom.bank_size ); - - update_timer( this ); - this->next_play = this->play_period; - this->cpu.r.rp.fa = track; - this->cpu.r.sp = get_le16( this->header.stack_ptr ); - this->cpu_time = 0; - jsr_then_stop( this, this->header.init_addr ); - - // convert filter times to samples - struct setup_t s = this->tfilter; - s.max_initial *= this->sample_rate_ * stereo; - #ifdef GME_DISABLE_SILENCE_LOOKAHEAD - s.lookahead = 1; - #endif - track_setup( &this->track_filter, &s ); - - return track_start( &this->track_filter ); -} - - -// Track - -static int msec_to_samples( int msec, int sample_rate ) -{ - int sec = msec / 1000; - msec -= sec * 1000; - return (sec * sample_rate + msec * sample_rate / 1000) * stereo; -} - -int Track_tell( struct Gbs_Emu* this ) -{ - int rate = this->sample_rate_ * stereo; - int sec = track_sample_count( &this->track_filter ) / rate; - return sec * 1000 + (track_sample_count( &this->track_filter ) - sec * rate) * 1000 / rate; -} - -blargg_err_t Track_seek( struct Gbs_Emu* this, int msec ) -{ - int time = msec_to_samples( msec, this->sample_rate_ ); - if ( time < track_sample_count( &this->track_filter ) ) - RETURN_ERR( Gbs_start_track( this, this->current_track_ ) ); - return Track_skip( this, time - track_sample_count( &this->track_filter ) ); -} - -blargg_err_t skip_( void* emu, int count ) -{ - struct Gbs_Emu* this = (struct Gbs_Emu*) emu; - - // for long skip, mute sound - const int threshold = 32768; - if ( count > threshold ) - { - int saved_mute = this->mute_mask_; - Sound_mute_voices( this, ~0 ); - - int n = count - threshold/2; - n &= ~(2048-1); // round to multiple of 2048 - count -= n; - RETURN_ERR( skippy_( &this->track_filter, n ) ); - - Sound_mute_voices( this, saved_mute ); - } - - return skippy_( &this->track_filter, count ); -} - -blargg_err_t Track_skip( struct Gbs_Emu* this, int count ) -{ - require( this->current_track_ >= 0 ); // start_track() must have been called already - return track_skip( &this->track_filter, count ); -} - -void Track_set_fade( struct Gbs_Emu* this, int start_msec, int length_msec ) -{ - track_set_fade( &this->track_filter, msec_to_samples( start_msec, this->sample_rate_ ), - length_msec * this->sample_rate_ / (1000 / stereo) ); -} - -blargg_err_t Gbs_play( struct Gbs_Emu* this, int out_count, sample_t* out ) -{ - require( this->current_track_ >= 0 ); - require( out_count % stereo == 0 ); - return track_play( &this->track_filter, out_count, out ); -} diff --git a/apps/codecs/libgme/gbs_emu.h b/apps/codecs/libgme/gbs_emu.h deleted file mode 100644 index 72671b4658..0000000000 --- a/apps/codecs/libgme/gbs_emu.h +++ /dev/null @@ -1,192 +0,0 @@ -// Nintendo Game Boy GBS music file emulator - -// Game_Music_Emu 0.5.2 -#ifndef GBS_EMU_H -#define GBS_EMU_H - -#include "rom_data.h" -#include "multi_buffer.h" -#include "gb_apu.h" -#include "gb_cpu.h" -#include "m3u_playlist.h" -#include "track_filter.h" - -enum { joypad_addr = 0xFF00 }; -enum { ram_addr = 0xA000 }; -enum { hi_page = 0xFF00 - ram_addr }; -enum { io_base = 0xFF00 }; - -// Selects which sound hardware to use. AGB hardware is cleaner than the -// others. Doesn't take effect until next start_track(). -enum sound_t { - sound_dmg = mode_dmg, // Game Boy monochrome - sound_cgb = mode_cgb, // Game Boy Color - sound_agb = mode_agb, // Game Boy Advance - sound_gbs // Use DMG/CGB based on GBS (default) -}; - -// GBS file header -enum { header_size = 112 }; -struct header_t -{ - char tag [3]; - byte vers; - byte track_count; - byte first_track; - byte load_addr [2]; - byte init_addr [2]; - byte play_addr [2]; - byte stack_ptr [2]; - byte timer_modulo; - byte timer_mode; - char game [32]; - char author [32]; - char copyright [32]; -}; - -struct Gbs_Emu { - enum sound_t sound_hardware; - - int tempo; - - // timer - blip_time_t cpu_time; - blip_time_t end_time; - blip_time_t play_period; - blip_time_t next_play; - - // Sound - int clock_rate_; - int sample_rate_; - unsigned buf_changed_count; - int voice_count_; - int const* voice_types_; - int mute_mask_; - int gain_; - int tempo_; - - // track-specific - byte track_count; - int current_track_; - - // Larger items at the end - // Header for currently loaded file - struct header_t header; - - // M3u Playlist - struct M3u_Playlist m3u; - - struct setup_t tfilter; - struct Track_Filter track_filter; - - struct Gb_Apu apu; - struct Gb_Cpu cpu; - struct Multi_Buffer stereo_buf; - - // rom & ram - struct Rom_Data rom; - byte ram [0x4000 + 0x2000 + cpu_padding]; -}; - - -// Basic functionality -// Initializes Gbs_Emu structure -void Gbs_init( struct Gbs_Emu* this ); - -// Stops (clear) Gbs_Emu structure -void Gbs_stop( struct Gbs_Emu* this ); - -// Loads a file from memory -blargg_err_t Gbs_load_mem( struct Gbs_Emu* this, void* data, long size ); - -// Set output sample rate. Must be called only once before loading file. -blargg_err_t Gbs_set_sample_rate( struct Gbs_Emu* this, int sample_rate ); - -// Start a track, where 0 is the first track. Also clears warning string. -blargg_err_t Gbs_start_track( struct Gbs_Emu* this, int ); - -// Generate 'count' samples info 'buf'. Output is in stereo. Any emulation -// errors set warning string, and major errors also end track. -blargg_err_t Gbs_play( struct Gbs_Emu* this, int count, sample_t* buf ); - -// Track status/control -// Number of milliseconds (1000 msec = 1 second) played since beginning of track -int Track_tell( struct Gbs_Emu* this ); - -// Seek to new time in track. Seeking backwards or far forward can take a while. -blargg_err_t Track_seek( struct Gbs_Emu* this, int msec ); - -// Skip n samples -blargg_err_t Track_skip( struct Gbs_Emu* this, int n ); - -// Set start time and length of track fade out. Once fade ends track_ended() returns -// true. Fade time can be changed while track is playing. -void Track_set_fade( struct Gbs_Emu* this, int start_msec, int length_msec ); - -// True if a track has reached its end -static inline bool Track_ended( struct Gbs_Emu* this ) -{ - return track_ended( &this->track_filter ); -} - -// Disables automatic end-of-track detection and skipping of silence at beginning -static inline void Track_ignore_silence( struct Gbs_Emu* this, bool disable ) -{ - this->track_filter.silence_ignored_ = disable; -} - -// Get track length in milliseconds -static inline int Track_get_length( struct Gbs_Emu* this, int n ) -{ - int length = 120 * 1000; /* 2 minutes */ - if ( (this->m3u.size > 0) && (n < this->m3u.size) ) { - struct entry_t* entry = &this->m3u.entries [n]; - length = entry->length; - } - - return length; -} - - -// Sound customization -// Adjust song tempo, where 1.0 = normal, 0.5 = half speed, 2.0 = double speed. -// Track length as returned by track_info() assumes a tempo of 1.0. -void Sound_set_tempo( struct Gbs_Emu* this, int ); - -// Mute/unmute voice i, where voice 0 is first voice -void Sound_mute_voice( struct Gbs_Emu* this, int index, bool mute ); - -// Set muting state of all voices at once using a bit mask, where -1 mutes them all, -// 0 unmutes them all, 0x01 mutes just the first voice, etc. -void Sound_mute_voices( struct Gbs_Emu* this, int mask ); - -// Change overall output amplitude, where 1.0 results in minimal clamping. -// Must be called before set_sample_rate(). -static inline void Sound_set_gain( struct Gbs_Emu* this, int g ) -{ - assert( !this->sample_rate_ ); // you must set gain before setting sample rate - this->gain_ = g; -} - -// Emulation (You shouldn't touch these) - -blargg_err_t run_clocks( struct Gbs_Emu* this, blip_time_t duration ); -void set_bank( struct Gbs_Emu* this, int ); -void update_timer( struct Gbs_Emu* this ); - -// Runs CPU until time becomes >= 0 -void run_cpu( struct Gbs_Emu* this ); - -// Reads/writes memory and I/O -int read_mem( struct Gbs_Emu* this, addr_t addr ); -void write_mem( struct Gbs_Emu* this, addr_t addr, int data ); - -// Current time -static inline blip_time_t Time( struct Gbs_Emu* this ) -{ - return Cpu_time( &this->cpu ) + this->end_time; -} - -void jsr_then_stop( struct Gbs_Emu* this, byte const [] ); - -#endif diff --git a/apps/codecs/libgme/gme.h b/apps/codecs/libgme/gme.h deleted file mode 100644 index d6803704ce..0000000000 --- a/apps/codecs/libgme/gme.h +++ /dev/null @@ -1,18 +0,0 @@ -/* Game music emulator library C interface (also usable from C++) */ - -/* Game_Music_Emu 0.5.2 */ -#ifndef GME_H -#define GME_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Error string returned by library functions, or NULL if no error (success) */ -typedef const char* gme_err_t; - -#ifdef __cplusplus - } -#endif - -#endif diff --git a/apps/codecs/libgme/hes_apu.c b/apps/codecs/libgme/hes_apu.c deleted file mode 100644 index a9cd32c8aa..0000000000 --- a/apps/codecs/libgme/hes_apu.c +++ /dev/null @@ -1,371 +0,0 @@ -// Game_Music_Emu 0.5.2. http://www.slack.net/~ant/ - -#include "hes_apu.h" -#include - -/* Copyright (C) 2006 Shay Green. This module is free software; you -can redistribute it and/or modify it under the terms of the GNU Lesser -General Public License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. This -module is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more -details. You should have received a copy of the GNU Lesser General Public -License along with this module; if not, write to the Free Software Foundation, -Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ - -#include "blargg_source.h" - -enum { center_waves = 1 }; // reduces asymmetry and clamping when starting notes - -static void balance_changed( struct Hes_Apu* this, struct Hes_Osc* osc ) -{ - static short const log_table [32] = { // ~1.5 db per step - #define ENTRY( factor ) (short) (factor * amp_range / 31.0 + 0.5) - ENTRY( 0.000000 ),ENTRY( 0.005524 ),ENTRY( 0.006570 ),ENTRY( 0.007813 ), - ENTRY( 0.009291 ),ENTRY( 0.011049 ),ENTRY( 0.013139 ),ENTRY( 0.015625 ), - ENTRY( 0.018581 ),ENTRY( 0.022097 ),ENTRY( 0.026278 ),ENTRY( 0.031250 ), - ENTRY( 0.037163 ),ENTRY( 0.044194 ),ENTRY( 0.052556 ),ENTRY( 0.062500 ), - ENTRY( 0.074325 ),ENTRY( 0.088388 ),ENTRY( 0.105112 ),ENTRY( 0.125000 ), - ENTRY( 0.148651 ),ENTRY( 0.176777 ),ENTRY( 0.210224 ),ENTRY( 0.250000 ), - ENTRY( 0.297302 ),ENTRY( 0.353553 ),ENTRY( 0.420448 ),ENTRY( 0.500000 ), - ENTRY( 0.594604 ),ENTRY( 0.707107 ),ENTRY( 0.840896 ),ENTRY( 1.000000 ), - #undef ENTRY - }; - - int vol = (osc->control & 0x1F) - 0x1E * 2; - - int left = vol + (osc->balance >> 3 & 0x1E) + (this->balance >> 3 & 0x1E); - if ( left < 0 ) left = 0; - - int right = vol + (osc->balance << 1 & 0x1E) + (this->balance << 1 & 0x1E); - if ( right < 0 ) right = 0; - - // optimizing for the common case of being centered also allows easy - // panning using Effects_Buffer - - // Separate balance into center volume and additional on either left or right - osc->output [0] = osc->outputs [0]; // center - osc->output [1] = osc->outputs [2]; // right - int base = log_table [left ]; - int side = log_table [right] - base; - if ( side < 0 ) - { - base += side; - side = -side; - osc->output [1] = osc->outputs [1]; // left - } - - // Optimize when output is far left, center, or far right - if ( !base || osc->output [0] == osc->output [1] ) - { - base += side; - side = 0; - osc->output [0] = osc->output [1]; - osc->output [1] = NULL; - osc->last_amp [1] = 0; - } - - if ( center_waves ) - { - // TODO: this can leave a non-zero level in a buffer (minor) - osc->last_amp [0] += (base - osc->volume [0]) * 16; - osc->last_amp [1] += (side - osc->volume [1]) * 16; - } - - osc->volume [0] = base; - osc->volume [1] = side; -} - -void Apu_init( struct Hes_Apu* this ) -{ - struct Hes_Osc* osc = &this->oscs [osc_count]; - do - { - osc--; - osc->output [0] = NULL; - osc->output [1] = NULL; - osc->outputs [0] = NULL; - osc->outputs [1] = NULL; - osc->outputs [2] = NULL; - } - while ( osc != this->oscs ); - - Apu_reset( this ); -} - -void Apu_reset( struct Hes_Apu* this ) -{ - this->latch = 0; - this->balance = 0xFF; - - struct Hes_Osc* osc = &this->oscs [osc_count]; - do - { - osc--; - memset( osc, 0, offsetof (struct Hes_Osc,outputs) ); - osc->lfsr = 1; - osc->control = 0x40; - osc->balance = 0xFF; - } - while ( osc != this->oscs ); - - // Only last two oscs support noise - this->oscs [osc_count - 2].lfsr = 0x200C3; // equivalent to 1 in Fibonacci LFSR - this->oscs [osc_count - 1].lfsr = 0x200C3; -} - -void Apu_osc_output( struct Hes_Apu* this, int i, struct Blip_Buffer* center, struct Blip_Buffer* left, struct Blip_Buffer* right ) -{ - // Must be silent (all NULL), mono (left and right NULL), or stereo (none NULL) - require( !center || (center && !left && !right) || (center && left && right) ); - require( (unsigned) i < osc_count ); // fails if you pass invalid osc index - - if ( !center || !left || !right ) - { - left = center; - right = center; - } - - struct Hes_Osc* o = &this->oscs [i]; - o->outputs [0] = center; - o->outputs [1] = right; - o->outputs [2] = left; - balance_changed( this, o ); -} - -static void run_osc( struct Hes_Osc* o, struct Blip_Synth* syn, blip_time_t end_time ) -{ - int vol0 = o->volume [0]; - int vol1 = o->volume [1]; - int dac = o->dac; - - struct Blip_Buffer* out0 = o->output [0]; // cache often-used values - struct Blip_Buffer* out1 = o->output [1]; - if ( !(o->control & 0x80) ) - out0 = NULL; - - if ( out0 ) - { - // Update amplitudes - if ( out1 ) - { - int delta = dac * vol1 - o->last_amp [1]; - if ( delta ) - { - Synth_offset( syn, o->last_time, delta, out1 ); - Blip_set_modified( out1 ); - } - } - int delta = dac * vol0 - o->last_amp [0]; - if ( delta ) - { - Synth_offset( syn, o->last_time, delta, out0 ); - Blip_set_modified( out0 ); - } - - // Don't generate if silent - if ( !(vol0 | vol1) ) - out0 = NULL; - } - - // Generate noise - int noise = 0; - if ( o->lfsr ) - { - noise = o->noise & 0x80; - - blip_time_t time = o->last_time + o->noise_delay; - if ( time < end_time ) - { - int period = (~o->noise & 0x1F) * 128; - if ( !period ) - period = 64; - - if ( noise && out0 ) - { - unsigned lfsr = o->lfsr; - do - { - int new_dac = -(lfsr & 1); - lfsr = (lfsr >> 1) ^ (0x30061 & new_dac); - - int delta = (new_dac &= 0x1F) - dac; - if ( delta ) - { - dac = new_dac; - Synth_offset( syn, time, delta * vol0, out0 ); - if ( out1 ) - Synth_offset( syn, time, delta * vol1, out1 ); - } - time += period; - } - while ( time < end_time ); - - if ( !lfsr ) - { - lfsr = 1; - check( false ); - } - o->lfsr = lfsr; - - Blip_set_modified( out0 ); - if ( out1 ) - Blip_set_modified( out1 ); - } - else - { - // Maintain phase when silent - int count = (end_time - time + period - 1) / period; - time += count * period; - - // not worth it - //while ( count-- ) - // o->lfsr = (o->lfsr >> 1) ^ (0x30061 * (o->lfsr & 1)); - } - } - o->noise_delay = time - end_time; - } - - // Generate wave - blip_time_t time = o->last_time + o->delay; - if ( time < end_time ) - { - int phase = (o->phase + 1) & 0x1F; // pre-advance for optimal inner loop - int period = o->period * 2; - - if ( period >= 14 && out0 && !((o->control & 0x40) | noise) ) - { - do - { - int new_dac = o->wave [phase]; - phase = (phase + 1) & 0x1F; - int delta = new_dac - dac; - if ( delta ) - { - dac = new_dac; - Synth_offset( syn, time, delta * vol0, out0 ); - if ( out1 ) - Synth_offset( syn, time, delta * vol1, out1 ); - } - time += period; - } - while ( time < end_time ); - Blip_set_modified( out0 ); - if ( out1 ) - Blip_set_modified( out1 ); - } - else - { - // Maintain phase when silent - int count = end_time - time; - if ( !period ) - period = 1; - count = (count + period - 1) / period; - - phase += count; // phase will be masked below - time += count * period; - } - - // TODO: Find whether phase increments even when both volumes are zero. - // CAN'T simply check for out0 being non-NULL, since it could be NULL - // if channel is muted in player, but still has non-zero volume. - // City Hunter breaks when this check is removed. - if ( !(o->control & 0x40) && (vol0 | vol1) ) - o->phase = (phase - 1) & 0x1F; // undo pre-advance - } - o->delay = time - end_time; - check( o->delay >= 0 ); - - o->last_time = end_time; - o->dac = dac; - o->last_amp [0] = dac * vol0; - o->last_amp [1] = dac * vol1; -} - -void Apu_write_data( struct Hes_Apu* this, blip_time_t time, int addr, int data ) -{ - if ( addr == 0x800 ) - { - this->latch = data & 7; - } - else if ( addr == 0x801 ) - { - if ( this->balance != data ) - { - this->balance = data; - - struct Hes_Osc* osc = &this->oscs [osc_count]; - do - { - osc--; - run_osc( osc, &this->synth, time ); - balance_changed( this, this->oscs ); - } - while ( osc != this->oscs ); - } - } - else if ( this->latch < osc_count ) - { - struct Hes_Osc* osc = &this->oscs [this->latch]; - run_osc( osc, &this->synth, time ); - switch ( addr ) - { - case 0x802: - osc->period = (osc->period & 0xF00) | data; - break; - - case 0x803: - osc->period = (osc->period & 0x0FF) | ((data & 0x0F) << 8); - break; - - case 0x804: - if ( osc->control & 0x40 & ~data ) - osc->phase = 0; - osc->control = data; - balance_changed( this, osc ); - break; - - case 0x805: - osc->balance = data; - balance_changed( this, osc ); - break; - - case 0x806: - data &= 0x1F; - if ( !(osc->control & 0x40) ) - { - osc->wave [osc->phase] = data; - osc->phase = (osc->phase + 1) & 0x1F; - } - else if ( osc->control & 0x80 ) - { - osc->dac = data; - } - break; - - case 0x807: - osc->noise = data; - break; - - case 0x809: - if ( !(data & 0x80) && (data & 0x03) != 0 ) { - dprintf( "HES LFO not supported\n" ); - } - } - } -} - -void Apu_end_frame( struct Hes_Apu* this, blip_time_t end_time ) -{ - struct Hes_Osc* osc = &this->oscs [osc_count]; - do - { - osc--; - if ( end_time > osc->last_time ) - run_osc( osc, &this->synth, end_time ); - assert( osc->last_time >= end_time ); - osc->last_time -= end_time; - } - while ( osc != this->oscs ); -} diff --git a/apps/codecs/libgme/hes_apu.h b/apps/codecs/libgme/hes_apu.h deleted file mode 100644 index 0265e6a3ad..0000000000 --- a/apps/codecs/libgme/hes_apu.h +++ /dev/null @@ -1,66 +0,0 @@ -// Turbo Grafx 16 (PC Engine) PSG sound chip emulator - -// Game_Music_Emu 0.5.2 -#ifndef HES_APU_H -#define HES_APU_H - -#include "blargg_common.h" -#include "blargg_source.h" -#include "blip_buffer.h" - -enum { amp_range = 0x8000 }; -enum { osc_count = 6 }; // 0 <= chan < osc_count - -// Registers are at io_addr to io_addr+io_size-1 -enum { apu_io_addr = 0x0800 }; -enum { apu_io_size = 10 }; - -struct Hes_Osc -{ - byte wave [32]; - int delay; - int period; - int phase; - - int noise_delay; - byte noise; - unsigned lfsr; - - byte control; - byte balance; - byte dac; - short volume [2]; - int last_amp [2]; - - blip_time_t last_time; - struct Blip_Buffer* output [2]; - struct Blip_Buffer* outputs [3]; -}; - -void Osc_run_until( struct Hes_Osc* this, struct Blip_Synth* synth, blip_time_t ); - -struct Hes_Apu { - - int latch; - int balance; - struct Blip_Synth synth; - struct Hes_Osc oscs [osc_count]; -}; - -// Init HES apu sound chip -void Apu_init( struct Hes_Apu* this ); - -// Reset HES apu couns chip -void Apu_reset( struct Hes_Apu* this ); - -void Apu_osc_output( struct Hes_Apu* this, int index, struct Blip_Buffer* center, struct Blip_Buffer* left, struct Blip_Buffer* right ); - -// Emulates to time t, then writes data to addr -void Apu_write_data( struct Hes_Apu* this, blip_time_t, int addr, int data ); - -// Emulates to time t, then subtracts t from the current time. -// OK if previous write call had time slightly after t. -void Apu_end_frame( struct Hes_Apu* this, blip_time_t ); - -static inline void Apu_volume( struct Hes_Apu* this, int v ) { Synth_volume( &this->synth, (v*9)/5 / osc_count / amp_range ); } -#endif diff --git a/apps/codecs/libgme/hes_apu_adpcm.c b/apps/codecs/libgme/hes_apu_adpcm.c deleted file mode 100644 index de9b894f5d..0000000000 --- a/apps/codecs/libgme/hes_apu_adpcm.c +++ /dev/null @@ -1,297 +0,0 @@ -// Game_Music_Emu 0.6-pre. http://www.slack.net/~ant/ - -#include "hes_apu_adpcm.h" - -/* Copyright (C) 2006-2008 Shay Green. This module is free software; you -can redistribute it and/or modify it under the terms of the GNU Lesser -General Public License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. This -module is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more -details. You should have received a copy of the GNU Lesser General Public -License along with this module; if not, write to the Free Software Foundation, -Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ - - -void Adpcm_init( struct Hes_Apu_Adpcm* this ) -{ - this->output = NULL; - memset( &this->state, 0, sizeof( this->state ) ); - Adpcm_reset( this ); -} - -void Adpcm_reset( struct Hes_Apu_Adpcm* this ) -{ - this->last_time = 0; - this->next_timer = 0; - this->last_amp = 0; - - memset( &this->state.pcmbuf, 0, sizeof(this->state.pcmbuf) ); - memset( &this->state.port, 0, sizeof(this->state.port) ); - - this->state.ad_sample = 0; - this->state.ad_ref_index = 0; - - this->state.addr = 0; - this->state.freq = 0; - this->state.writeptr = 0; - this->state.readptr = 0; - this->state.playflag = 0; - this->state.repeatflag = 0; - this->state.length = 0; - this->state.volume = 0xFF; - this->state.fadetimer = 0; - this->state.fadecount = 0; -} - -static short stepsize[49] = { - 16, 17, 19, 21, 23, 25, 28, - 31, 34, 37, 41, 45, 50, 55, - 60, 66, 73, 80, 88, 97, 107, - 118, 130, 143, 157, 173, 190, 209, - 230, 253, 279, 307, 337, 371, 408, - 449, 494, 544, 598, 658, 724, 796, - 876, 963,1060,1166,1282,1411,1552 -}; - -static int Adpcm_decode( struct Hes_Apu_Adpcm* this,int code ); -static int Adpcm_decode( struct Hes_Apu_Adpcm* this,int code ) -{ - struct State* state = &this->state; - int step = stepsize[state->ad_ref_index]; - int delta; - int c = code & 7; -#if 1 - delta = 0; - if ( c & 4 ) delta += step; - step >>= 1; - if ( c & 2 ) delta += step; - step >>= 1; - if ( c & 1 ) delta += step; - step >>= 1; - delta += step; -#else - delta = ( ( c + c + 1 ) * step ) / 8; // maybe faster, but introduces rounding -#endif - if ( c != code ) - { - state->ad_sample -= delta; - if ( state->ad_sample < -2048 ) - state->ad_sample = -2048; - } - else - { - state->ad_sample += delta; - if ( state->ad_sample > 2047 ) - state->ad_sample = 2047; - } - - static int const steps [8] = { - -1, -1, -1, -1, 2, 4, 6, 8 - }; - state->ad_ref_index += steps [c]; - if ( state->ad_ref_index < 0 ) - state->ad_ref_index = 0; - else if ( state->ad_ref_index > 48 ) - state->ad_ref_index = 48; - - return state->ad_sample; -} - -static void Adpcm_run_until( struct Hes_Apu_Adpcm* this, blip_time_t end_time ); -static void Adpcm_run_until( struct Hes_Apu_Adpcm* this, blip_time_t end_time ) -{ - struct State* state = &this->state; - int volume = state->volume; - int fadetimer = state->fadetimer; - int fadecount = state->fadecount; - int last_time = this->last_time; - int next_timer = this->next_timer; - int last_amp = this->last_amp; - - struct Blip_Buffer* output = this->output; // cache often-used values - - while ( state->playflag && last_time < end_time ) - { - while ( last_time >= next_timer ) - { - if ( fadetimer ) - { - if ( fadecount > 0 ) - { - fadecount--; - volume = 0xFF * fadecount / fadetimer; - } - else if ( fadecount < 0 ) - { - fadecount++; - volume = 0xFF - ( 0xFF * fadecount / fadetimer ); - } - } - next_timer += 7159; // 7159091/1000; - } - int amp; - if ( state->ad_low_nibble ) - { - amp = Adpcm_decode( this, state->pcmbuf[ state->playptr ] & 0x0F ); - state->ad_low_nibble = false; - state->playptr++; - state->playedsamplecount++; - if ( state->playedsamplecount == state->playlength ) - { - state->playflag = 0; - } - } - else - { - amp = Adpcm_decode( this, state->pcmbuf[ state->playptr ] >> 4 ); - state->ad_low_nibble = true; - } - amp = amp * volume / 0xFF; - int delta = amp - last_amp; - if ( output && delta ) - { - last_amp = amp; - Synth_offset_inline( &this->synth, last_time, delta, output ); - } - last_time += state->freq; - } - - if ( !state->playflag ) - { - while ( next_timer <= end_time ) next_timer += 7159; // 7159091/1000 - last_time = end_time; - } - - this->last_time = last_time; - this->next_timer = next_timer; - this->last_amp = last_amp; - state->volume = volume; - state->fadetimer = fadetimer; - state->fadecount = fadecount; -} - -void Adpcm_write_data( struct Hes_Apu_Adpcm* this, blip_time_t time, int addr, int data ) -{ - if ( time > this->last_time ) Adpcm_run_until( this, time ); - struct State* state = &this->state; - - data &= 0xFF; - state->port[ addr & 15 ] = data; - switch ( addr & 15 ) - { - case 8: - state->addr &= 0xFF00; - state->addr |= data; - break; - case 9: - state->addr &= 0xFF; - state->addr |= data << 8; - break; - case 10: - state->pcmbuf[ state->writeptr++ ] = data; - state->playlength ++; - break; - case 11: - dprintf("ADPCM DMA 0x%02X", data); - break; - case 13: - if ( data & 0x80 ) - { - state->addr = 0; - state->freq = 0; - state->writeptr = 0; - state->readptr = 0; - state->playflag = 0; - state->repeatflag = 0; - state->length = 0; - state->volume = 0xFF; - } - if ( ( data & 3 ) == 3 ) - { - state->writeptr = state->addr; - } - if ( data & 8 ) - { - state->readptr = state->addr ? state->addr - 1 : state->addr; - } - if ( data & 0x10 ) - { - state->length = state->addr; - } - state->repeatflag = data & 0x20; - state->playflag = data & 0x40; - if ( state->playflag ) - { - state->playptr = state->readptr; - state->playlength = state->length + 1; - state->playedsamplecount = 0; - state->ad_sample = 0; - state->ad_low_nibble = false; - } - break; - case 14: - state->freq = 7159091 / ( 32000 / ( 16 - ( data & 15 ) ) ); - break; - case 15: - switch ( data & 15 ) - { - case 0: - case 8: - case 12: - state->fadetimer = -100; - state->fadecount = state->fadetimer; - break; - case 10: - state->fadetimer = 5000; - state->fadecount = state->fadetimer; - break; - case 14: - state->fadetimer = 1500; - state->fadecount = state->fadetimer; - break; - } - break; - } -} - -int Adpcm_read_data( struct Hes_Apu_Adpcm* this, blip_time_t time, int addr ) -{ - if ( time > this->last_time ) Adpcm_run_until( this, time ); - - struct State* state = &this->state; - switch ( addr & 15 ) - { - case 10: - return state->pcmbuf [state->readptr++]; - case 11: - return state->port [11] & ~1; - case 12: - if (!state->playflag) - { - state->port [12] |= 1; - state->port [12] &= ~8; - } - else - { - state->port [12] &= ~1; - state->port [12] |= 8; - } - return state->port [12]; - case 13: - return state->port [13]; - } - - return 0xFF; -} - -void Adpcm_end_frame( struct Hes_Apu_Adpcm* this, blip_time_t end_time ) -{ - Adpcm_run_until( this, end_time ); - this->last_time -= end_time; - this->next_timer -= end_time; - check( last_time >= 0 ); - if ( this->output ) - Blip_set_modified( this->output ); -} diff --git a/apps/codecs/libgme/hes_apu_adpcm.h b/apps/codecs/libgme/hes_apu_adpcm.h deleted file mode 100644 index afe160bb9c..0000000000 --- a/apps/codecs/libgme/hes_apu_adpcm.h +++ /dev/null @@ -1,89 +0,0 @@ -// Turbo Grafx 16 (PC Engine) ADPCM sound chip emulator - -// Game_Music_Emu 0.6-pre -#ifndef HES_APU_ADPCM_H -#define HES_APU_ADPCM_H - -#include "blargg_source.h" -#include "blargg_common.h" -#include "blip_buffer.h" - -enum { adpcm_amp_range = 2048 }; -enum { adpcm_osc_count = 1 }; // 0 <= chan < osc_count - -// Registers are at io_addr to io_addr+io_size-1 -enum { adpcm_io_addr = 0x1800 }; -enum { adpcm_io_size = 0x400 }; - -struct State -{ - byte pcmbuf [0x10000]; - byte port [0x10]; - int ad_sample; - int ad_ref_index; - bool ad_low_nibble; - int freq; - unsigned short addr; - unsigned short writeptr; - unsigned short readptr; - unsigned short playptr; - byte playflag; - byte repeatflag; - int length; - int playlength; - int playedsamplecount; - int volume; - int fadetimer; - int fadecount; -}; - -struct Hes_Apu_Adpcm { - struct State state; - struct Blip_Synth synth; - - struct Blip_Buffer* output; - blip_time_t last_time; - int next_timer; - int last_amp; -}; - -// Init HES adpcm sound chip -void Adpcm_init( struct Hes_Apu_Adpcm* this ); - -// Rest HES adpcm sound chip -void Adpcm_reset( struct Hes_Apu_Adpcm* this ); - -// Sets buffer(s) to generate sound into, or 0 to mute. If only center is not 0, -// output is mono. -static inline void Adpcm_set_output( struct Hes_Apu_Adpcm* this, int chan, struct Blip_Buffer* center, struct Blip_Buffer* left, struct Blip_Buffer* right ) -{ - // Must be silent (all NULL), mono (left and right NULL), or stereo (none NULL) - require( !center || (center && !left && !right) || (center && left && right) ); - require( (unsigned) chan < adpcm_osc_count ); // fails if you pass invalid osc index - -#if defined(ROCKBOX) - (void) chan; -#endif - - if ( !center || !left || !right ) - { - left = center; - right = center; - } - - this->output = center; -} - -// Emulates to time t, then writes data to addr -void Adpcm_write_data( struct Hes_Apu_Adpcm* this, blip_time_t t, int addr, int data ); - -// Emulates to time t, then reads from addr -int Adpcm_read_data( struct Hes_Apu_Adpcm* this, blip_time_t t, int addr ); - -// Emulates to time t, then subtracts t from the current time. -// OK if previous write call had time slightly after t. -void Adpcm_end_frame( struct Hes_Apu_Adpcm* this,blip_time_t t ); - -// Sets overall volume, where 1.0 is normal -static inline void Adpcm_volume( struct Hes_Apu_Adpcm* this, int v ) { Synth_volume( &this->synth, (v*3)/5 / adpcm_osc_count / adpcm_amp_range ); } -#endif diff --git a/apps/codecs/libgme/hes_cpu.c b/apps/codecs/libgme/hes_cpu.c deleted file mode 100644 index 6b833b3b98..0000000000 --- a/apps/codecs/libgme/hes_cpu.c +++ /dev/null @@ -1,121 +0,0 @@ -// Game_Music_Emu 0.5.2. http://www.slack.net/~ant/ - -#include "hes_emu.h" - -#include "blargg_endian.h" - -//#include "hes_cpu_log.h" - -/* Copyright (C) 2003-2006 Shay Green. This module is free software; you -can redistribute it and/or modify it under the terms of the GNU Lesser -General Public License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. This -module is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more -details. You should have received a copy of the GNU Lesser General Public -License along with this module; if not, write to the Free Software Foundation, -Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ - -#include "blargg_source.h" -#define PAGE HES_CPU_PAGE - -int read_mem( struct Hes_Emu* this, hes_addr_t addr ) -{ - check( addr < 0x10000 ); - int result = *Cpu_get_code( &this->cpu, addr ); - if ( this->cpu.mmr [PAGE( addr )] == 0xFF ) - result = read_mem_( this, addr ); - return result; -} - -void write_mem( struct Hes_Emu* this, hes_addr_t addr, int data ) -{ - check( addr < 0x10000 ); - byte* out = this->write_pages [PAGE( addr )]; - if ( out ) - out [addr & (page_size - 1)] = data; - else if ( this->cpu.mmr [PAGE( addr )] == 0xFF ) - write_mem_( this, addr, data ); -} - -void set_mmr( struct Hes_Emu* this, int page, int bank ) -{ - this->write_pages [page] = 0; - byte* data = Rom_at_addr( &this->rom, bank * page_size ); - if ( bank >= 0x80 ) - { - data = 0; - switch ( bank ) - { - case 0xF8: - data = this->ram; - break; - - case 0xF9: - case 0xFA: - case 0xFB: - data = &this->sgx [(bank - 0xF9) * page_size]; - break; - - default: - /* if ( bank != 0xFF ) - dprintf( "Unmapped bank $%02X\n", bank ); */ - data = this->rom.unmapped; - goto end; - } - - this->write_pages [page] = data; - } -end: - Cpu_set_mmr( &this->cpu, page, bank, data ); -} - -#define READ_FAST( addr, out ) \ -{\ - out = READ_CODE( addr );\ - if ( cpu->mmr [PAGE( addr )] == 0xFF )\ - {\ - FLUSH_TIME();\ - out = read_mem_( this, addr );\ - CACHE_TIME();\ - }\ -} - -#define WRITE_FAST( addr, data ) \ -{\ - int page = PAGE( addr );\ - byte* out = this->write_pages [page];\ - addr &= page_size - 1;\ - if ( out )\ - {\ - out [addr] = data;\ - }\ - else if ( cpu->mmr [page] == 0xFF )\ - {\ - FLUSH_TIME();\ - write_mem_( this, addr, data );\ - CACHE_TIME();\ - }\ -} - -#define READ_LOW( addr ) (this->ram [addr]) -#define WRITE_LOW( addr, data ) (this->ram [addr] = data) -#define READ_MEM( addr ) read_mem( this, addr ) -#define WRITE_MEM( addr, data ) write_mem( this, addr, data ) -#define WRITE_VDP( addr, data ) write_vdp( this, addr, data ) -#define CPU_DONE( result_out ) { FLUSH_TIME(); result_out = cpu_done( this ); CACHE_TIME(); } -#define SET_MMR( reg, bank ) set_mmr( this, reg, bank ) - -#define IDLE_ADDR idle_addr - -#define CPU_BEGIN \ -bool run_cpu( struct Hes_Emu* this, hes_time_t end_time )\ -{\ - struct Hes_Cpu* cpu = &this->cpu;\ - Cpu_set_end_time( cpu, end_time ); - - #include "hes_cpu_run.h" - - return illegal_encountered; -} diff --git a/apps/codecs/libgme/hes_cpu.h b/apps/codecs/libgme/hes_cpu.h deleted file mode 100644 index 0429eeaba0..0000000000 --- a/apps/codecs/libgme/hes_cpu.h +++ /dev/null @@ -1,132 +0,0 @@ -// PC Engine CPU emulator for use with HES music files - -// Game_Music_Emu 0.6-pre -#ifndef HES_CPU_H -#define HES_CPU_H - -#include "blargg_common.h" -#include "blargg_source.h" - -typedef int hes_time_t; // clock cycle count -typedef int hes_addr_t; // 16-bit address - -struct Hes_Emu; - -enum { future_time = INT_MAX/2 + 1 }; -enum { page_bits = 13 }; -enum { page_size = 1 << page_bits }; -enum { page_count = 0x10000 / page_size }; - -// Can read this many bytes past end of a page -enum { cpu_padding = 8 }; -enum { irq_inhibit_mask = 0x04 }; -enum { idle_addr = 0x1FFF }; - -// Cpu state -struct cpu_state_t { - byte const* code_map [page_count + 1]; - hes_time_t base; - int time; -}; - -// NOT kept updated during emulation. -struct registers_t { - uint16_t pc; - byte a; - byte x; - byte y; - byte flags; - byte sp; -}; - -struct Hes_Cpu { - struct registers_t r; - - hes_time_t irq_time_; - hes_time_t end_time_; - - struct cpu_state_t* cpu_state; // points to state_ or a local copy within run() - struct cpu_state_t cpu_state_; - - // page mapping registers - uint8_t mmr [page_count + 1]; - uint8_t ram [page_size]; -}; - -// Init cpu state -static inline void Cpu_init( struct Hes_Cpu* this ) -{ - this->cpu_state = &this->cpu_state_; -} - -// Reset hes cpu -void Cpu_reset( struct Hes_Cpu* this ); - -// Set end_time and run CPU from current time. Returns true if any illegal -// instructions were encountered. -bool Cpu_run( struct Hes_Emu* this, hes_time_t end_time ); - -// Time of ning of next instruction to be executed -static inline hes_time_t Cpu_time( struct Hes_Cpu* this ) -{ - return this->cpu_state->time + this->cpu_state->base; -} - -static inline void Cpu_set_time( struct Hes_Cpu* this, hes_time_t t ) { this->cpu_state->time = t - this->cpu_state->base; } -static inline void Cpu_adjust_time( struct Hes_Cpu* this, int delta ) { this->cpu_state->time += delta; } - -#define HES_CPU_PAGE( addr ) ((unsigned) (addr) >> page_bits) - -#ifdef BLARGG_NONPORTABLE - #define HES_CPU_OFFSET( addr ) (addr) -#else - #define HES_CPU_OFFSET( addr ) ((addr) & (page_size - 1)) -#endif - -static inline uint8_t const* Cpu_get_code( struct Hes_Cpu* this, hes_addr_t addr ) -{ - return this->cpu_state_.code_map [HES_CPU_PAGE( addr )] + HES_CPU_OFFSET( addr ); -} - -static inline void update_end_time( struct Hes_Cpu* this, hes_time_t end, hes_time_t irq ) -{ - if ( end > irq && !(this->r.flags & irq_inhibit_mask) ) - end = irq; - - this->cpu_state->time += this->cpu_state->base - end; - this->cpu_state->base = end; -} - -static inline hes_time_t Cpu_end_time( struct Hes_Cpu* this ) { return this->end_time_; } - -static inline void Cpu_set_irq_time( struct Hes_Cpu* this, hes_time_t t ) -{ - this->irq_time_ = t; - update_end_time( this, this->end_time_, t ); -} - -static inline void Cpu_set_end_time( struct Hes_Cpu* this, hes_time_t t ) -{ - this->end_time_ = t; - update_end_time( this, t, this->irq_time_ ); -} - -static inline void Cpu_end_frame( struct Hes_Cpu* this, hes_time_t t ) -{ - assert( this->cpu_state == &this->cpu_state_ ); - this->cpu_state_.base -= t; - if ( this->irq_time_ < future_time ) this->irq_time_ -= t; - if ( this->end_time_ < future_time ) this->end_time_ -= t; -} - -static inline void Cpu_set_mmr( struct Hes_Cpu* this, int reg, int bank, void const* code ) -{ - assert( (unsigned) reg <= page_count ); // allow page past end to be set - assert( (unsigned) bank < 0x100 ); - this->mmr [reg] = bank; - byte const* p = STATIC_CAST(byte const*,code) - HES_CPU_OFFSET( reg << page_bits ); - this->cpu_state->code_map [reg] = p; - this->cpu_state_.code_map [reg] = p; -} - -#endif diff --git a/apps/codecs/libgme/hes_cpu_run.h b/apps/codecs/libgme/hes_cpu_run.h deleted file mode 100644 index bfba2b6109..0000000000 --- a/apps/codecs/libgme/hes_cpu_run.h +++ /dev/null @@ -1,1344 +0,0 @@ -// Game_Music_Emu 0.6-pre. http://www.slack.net/~ant/ - -#if 0 -/* Define these macros in the source file before #including this file. -- Parameters might be expressions, so they are best evaluated only once, -though they NEVER have side-effects, so multiple evaluation is OK. -- Output parameters might be a multiple-assignment expression like "a=x", -so they must NOT be parenthesized. -- Except where noted, time() and related functions will NOT work -correctly inside a macro. TIME() is always correct, and FLUSH_TIME() and -CACHE_TIME() allow the time changing functions to work. -- Macros "returning" void may use a {} statement block. */ - - // 0 <= addr <= 0xFFFF + page_size - // time functions can be used - int READ_MEM( addr_t ); - void WRITE_MEM( addr_t, int data ); - - // 0 <= addr <= 0x1FF - int READ_LOW( addr_t ); - void WRITE_LOW( addr_t, int data ); - - // 0 <= addr <= 0xFFFF + page_size - // Used by common instructions. - int READ_FAST( addr_t, int& out ); - void WRITE_FAST( addr_t, int data ); - - // 0 <= addr <= 2 - // ST0, ST1, ST2 instructions - void WRITE_VDP( int addr, int data ); - -// The following can be used within macros: - - // Current time - hes_time_t TIME(); - - // Allows use of time functions - void FLUSH_TIME(); - - // Must be used before end of macro if FLUSH_TIME() was used earlier - void CACHE_TIME(); - -// Configuration (optional; commented behavior if defined) - - // Expanded just before beginning of code, to help debugger - #define CPU_BEGIN void my_run_cpu() { -#endif - -/* Copyright (C) 2003-2008 Shay Green. This module is free software; you -can redistribute it and/or modify it under the terms of the GNU Lesser -General Public License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. This -module is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more -details. You should have received a copy of the GNU Lesser General Public -License along with this module; if not, write to the Free Software Foundation, -Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ - -// TODO: support T flag, including clearing it at appropriate times? - -// all zero-page should really use whatever is at page 1, but that would -// reduce efficiency quite a bit -int const ram_addr = 0x2000; - -void Cpu_reset( struct Hes_Cpu* this ) -{ - check( this->cpu_state == &this->cpu_state_ ); - this->cpu_state = &this->cpu_state_; - - this->cpu_state_.time = 0; - this->cpu_state_.base = 0; - this->irq_time_ = future_time; - this->end_time_ = future_time; - - this->r.flags = 0x04; - this->r.sp = 0; - this->r.pc = 0; - this->r.a = 0; - this->r.x = 0; - this->r.y = 0; - - // Be sure "blargg_endian.h" has been #included - blargg_verify_byte_order(); -} - -// Allows MWCW debugger to step through code properly -#ifdef CPU_BEGIN - CPU_BEGIN -#endif - -// Time -#define TIME() (s_time + s.base) -#define FLUSH_TIME() {s.time = s_time;} -#define CACHE_TIME() {s_time = s.time;} - -// Memory -#define READ_STACK READ_LOW -#define WRITE_STACK WRITE_LOW - -#define CODE_PAGE( addr ) s.code_map [HES_CPU_PAGE( addr )] -#define CODE_OFFSET( addr ) HES_CPU_OFFSET( addr ) -#define READ_CODE( addr ) CODE_PAGE( addr ) [CODE_OFFSET( addr )] - -// Stack -#define SET_SP( v ) (sp = ((v) + 1) | 0x100) -#define GET_SP() ((sp - 1) & 0xFF) -#define SP( o ) ((sp + (o - (o>0)*0x100)) | 0x100) - -// Truncation -#define BYTE( n ) ((uint8_t ) (n)) /* (unsigned) n & 0xFF */ -#define SBYTE( n ) ((int8_t ) (n)) /* (BYTE( n ) ^ 0x80) - 0x80 */ -#define WORD( n ) ((uint16_t) (n)) /* (unsigned) n & 0xFFFF */ - -// Flags with hex value for clarity when used as mask. -// Stored in indicated variable during emulation. -int const n80 = 0x80; // nz -int const v40 = 0x40; // flags -//int const t20 = 0x20; -int const b10 = 0x10; -int const d08 = 0x08; // flags -int const i04 = 0x04; // flags -int const z02 = 0x02; // nz -int const c01 = 0x01; // c - -#define IS_NEG (nz & 0x8080) - -#define GET_FLAGS( out ) \ -{\ - out = flags & (v40 | d08 | i04);\ - out += ((nz >> 8) | nz) & n80;\ - out += c >> 8 & c01;\ - if ( !BYTE( nz ) )\ - out += z02;\ -} - -#define SET_FLAGS( in ) \ -{\ - flags = in & (v40 | d08 | i04);\ - c = nz = in << 8;\ - nz += ~in & z02;\ -} - -bool illegal_encountered = false; -{ - struct cpu_state_t s = cpu->cpu_state_; - cpu->cpu_state = &s; - // even on x86, using s.time in place of s_time was slower - int s_time = s.time; - - // registers - int pc = cpu->r.pc; - int a = cpu->r.a; - int x = cpu->r.x; - int y = cpu->r.y; - int sp; - SET_SP( cpu->r.sp ); - - // Flags - int flags; - int c; // carry set if (c & 0x100) != 0 - int nz; // Z set if (nz & 0xFF) == 0, N set if (nz & 0x8080) != 0 - { - int temp = cpu->r.flags; - SET_FLAGS( temp ); - } - -loop: - - #ifndef NDEBUG - { - hes_time_t correct = cpu->end_time_; - if ( !(flags & i04) && correct > cpu->irq_time_ ) - correct = cpu->irq_time_; - check( s.base == correct ); - /* - static int count; - if ( count == 1844 ) Debugger(); - if ( s.base != correct ) dprintf( "%ld\n", count ); - count++; - */ - } - #endif - - // Check all values - check( (unsigned) sp - 0x100 < 0x100 ); - check( (unsigned) pc < 0x10000 + 0x100 ); // +0x100 so emulator can catch wrap-around - check( (unsigned) a < 0x100 ); - check( (unsigned) x < 0x100 ); - check( (unsigned) y < 0x100 ); - - // Read instruction - byte const* instr = CODE_PAGE( pc ); - int opcode; - - if ( CODE_OFFSET(~0) == ~0 ) - { - opcode = instr [pc]; - pc++; - instr += pc; - } - else - { - instr += CODE_OFFSET( pc ); - opcode = *instr++; - pc++; - } - - // TODO: each reference lists slightly different timing values, ugh - static byte const clock_table [256] = - {// 0 1 2 3 4 5 6 7 8 9 A B C D E F - 1,7,3, 4,6,4,6,7,3,2,2,2,7,5,7,4,// 0 - 2,7,7, 4,6,4,6,7,2,5,2,2,7,5,7,4,// 1 - 7,7,3, 4,4,4,6,7,4,2,2,2,5,5,7,4,// 2 - 2,7,7, 2,4,4,6,7,2,5,2,2,5,5,7,4,// 3 - 7,7,3, 4,8,4,6,7,3,2,2,2,4,5,7,4,// 4 - 2,7,7, 5,2,4,6,7,2,5,3,2,2,5,7,4,// 5 - 7,7,2, 2,4,4,6,7,4,2,2,2,7,5,7,4,// 6 - 2,7,7,17,4,4,6,7,2,5,4,2,7,5,7,4,// 7 - 4,7,2, 7,4,4,4,7,2,2,2,2,5,5,5,4,// 8 - 2,7,7, 8,4,4,4,7,2,5,2,2,5,5,5,4,// 9 - 2,7,2, 7,4,4,4,7,2,2,2,2,5,5,5,4,// A - 2,7,7, 8,4,4,4,7,2,5,2,2,5,5,5,4,// B - 2,7,2,17,4,4,6,7,2,2,2,2,5,5,7,4,// C - 2,7,7,17,2,4,6,7,2,5,3,2,2,5,7,4,// D - 2,7,2,17,4,4,6,7,2,2,2,2,5,5,7,4,// E - 2,7,7,17,2,4,6,7,2,5,4,2,2,5,7,4 // F - }; // 0x00 was 8 - - // Update time - if ( s_time >= 0 ) - goto out_of_time; - - #ifdef HES_CPU_LOG_H - log_cpu( "new", pc - 1, opcode, instr [0], instr [1], instr [2], - instr [3], instr [4], instr [5], a, x, y ); - //log_opcode( opcode ); - #endif - - s_time += clock_table [opcode]; - - int data; - data = *instr; - - switch ( opcode ) - { -// Macros - -#define GET_MSB() (instr [1]) -#define ADD_PAGE( out ) (pc++, out = data + 0x100 * GET_MSB()); -#define GET_ADDR() GET_LE16( instr ) - -// TODO: is the penalty really always added? the original 6502 was much better -//#define PAGE_PENALTY( lsb ) (void) (s_time += (lsb) >> 8) -#define PAGE_PENALTY( lsb ) - -// Branch - -// TODO: more efficient way to handle negative branch that wraps PC around -#define BRANCH_( cond, adj )\ -{\ - pc++;\ - if ( !(cond) ) goto loop;\ - pc = (uint16_t) (pc + SBYTE( data ));\ - s_time += adj;\ - goto loop;\ -} - -#define BRANCH( cond ) BRANCH_( cond, 2 ) - - case 0xF0: // BEQ - BRANCH( !BYTE( nz ) ); - - case 0xD0: // BNE - BRANCH( BYTE( nz ) ); - - case 0x10: // BPL - BRANCH( !IS_NEG ); - - case 0x90: // BCC - BRANCH( !(c & 0x100) ) - - case 0x30: // BMI - BRANCH( IS_NEG ) - - case 0x50: // BVC - BRANCH( !(flags & v40) ) - - case 0x70: // BVS - BRANCH( flags & v40 ) - - case 0xB0: // BCS - BRANCH( c & 0x100 ) - - case 0x80: // BRA - branch_taken: - BRANCH_( true, 0 ); - - case 0xFF: - #ifdef IDLE_ADDR - if ( pc == IDLE_ADDR + 1 ) - goto idle_done; - #endif - - pc = (uint16_t) pc; - - case 0x0F: // BBRn - case 0x1F: - case 0x2F: - case 0x3F: - case 0x4F: - case 0x5F: - case 0x6F: - case 0x7F: - case 0x8F: // BBSn - case 0x9F: - case 0xAF: - case 0xBF: - case 0xCF: - case 0xDF: - case 0xEF: { - // Make two copies of bits, one negated - int t = 0x101 * READ_LOW( data ); - t ^= 0xFF; - pc++; - data = GET_MSB(); - BRANCH( t & (1 << (opcode >> 4)) ) - } - - case 0x4C: // JMP abs - pc = GET_ADDR(); - goto loop; - - case 0x7C: // JMP (ind+X) - data += x; - case 0x6C:{// JMP (ind) - data += 0x100 * GET_MSB(); - pc = GET_LE16( &READ_CODE( data ) ); - goto loop; - } - -// Subroutine - - case 0x44: // BSR - WRITE_STACK( SP( -1 ), pc >> 8 ); - sp = SP( -2 ); - WRITE_STACK( sp, pc ); - goto branch_taken; - - case 0x20: { // JSR - int temp = pc + 1; - pc = GET_ADDR(); - WRITE_STACK( SP( -1 ), temp >> 8 ); - sp = SP( -2 ); - WRITE_STACK( sp, temp ); - goto loop; - } - - case 0x60: // RTS - pc = 1 + READ_STACK( sp ); - pc += 0x100 * READ_STACK( SP( 1 ) ); - sp = SP( 2 ); - goto loop; - - case 0x00: // BRK - goto handle_brk; - -// Common - - case 0xBD:{// LDA abs,X - PAGE_PENALTY( data + x ); - int addr = GET_ADDR() + x; - pc += 2; - READ_FAST( addr, nz ); - a = nz; - goto loop; - } - - case 0x9D:{// STA abs,X - int addr = GET_ADDR() + x; - pc += 2; - WRITE_FAST( addr, a ); - goto loop; - } - - case 0x95: // STA zp,x - data = BYTE( data + x ); - case 0x85: // STA zp - pc++; - WRITE_LOW( data, a ); - goto loop; - - case 0xAE:{// LDX abs - int addr = GET_ADDR(); - pc += 2; - READ_FAST( addr, nz ); - x = nz; - goto loop; - } - - case 0xA5: // LDA zp - a = nz = READ_LOW( data ); - pc++; - goto loop; - -// Load/store - - { - int addr; - case 0x91: // STA (ind),Y - addr = 0x100 * READ_LOW( BYTE( data + 1 ) ); - addr += READ_LOW( data ) + y; - pc++; - goto sta_ptr; - - case 0x81: // STA (ind,X) - data = BYTE( data + x ); - case 0x92: // STA (ind) - addr = 0x100 * READ_LOW( BYTE( data + 1 ) ); - addr += READ_LOW( data ); - pc++; - goto sta_ptr; - - case 0x99: // STA abs,Y - data += y; - case 0x8D: // STA abs - addr = data + 0x100 * GET_MSB(); - pc += 2; - sta_ptr: - WRITE_FAST( addr, a ); - goto loop; - } - - { - int addr; - case 0xA1: // LDA (ind,X) - data = BYTE( data + x ); - case 0xB2: // LDA (ind) - addr = 0x100 * READ_LOW( BYTE( data + 1 ) ); - addr += READ_LOW( data ); - pc++; - goto a_nz_read_addr; - - case 0xB1:// LDA (ind),Y - addr = READ_LOW( data ) + y; - PAGE_PENALTY( addr ); - addr += 0x100 * READ_LOW( BYTE( data + 1 ) ); - pc++; - goto a_nz_read_addr; - - case 0xB9: // LDA abs,Y - data += y; - PAGE_PENALTY( data ); - case 0xAD: // LDA abs - addr = data + 0x100 * GET_MSB(); - pc += 2; - a_nz_read_addr: - READ_FAST( addr, nz ); - a = nz; - goto loop; - } - - case 0xBE:{// LDX abs,y - PAGE_PENALTY( data + y ); - int addr = GET_ADDR() + y; - pc += 2; - FLUSH_TIME(); - x = nz = READ_MEM( addr ); - CACHE_TIME(); - goto loop; - } - - case 0xB5: // LDA zp,x - a = nz = READ_LOW( BYTE( data + x ) ); - pc++; - goto loop; - - case 0xA9: // LDA #imm - pc++; - a = data; - nz = data; - goto loop; - -// Bit operations - - case 0x3C: // BIT abs,x - data += x; - case 0x2C:{// BIT abs - int addr; - ADD_PAGE( addr ); - FLUSH_TIME(); - nz = READ_MEM( addr ); - CACHE_TIME(); - goto bit_common; - } - case 0x34: // BIT zp,x - data = BYTE( data + x ); - case 0x24: // BIT zp - data = READ_LOW( data ); - case 0x89: // BIT imm - nz = data; - bit_common: - pc++; - flags = (flags & ~v40) + (nz & v40); - if ( nz & a ) - goto loop; // Z should be clear, and nz must be non-zero if nz & a is - nz <<= 8; // set Z flag without affecting N flag - goto loop; - - { - int addr; - - case 0xB3: // TST abs,x - addr = GET_MSB() + x; - goto tst_abs; - - case 0x93: // TST abs - addr = GET_MSB(); - tst_abs: - addr += 0x100 * instr [2]; - pc++; - FLUSH_TIME(); - nz = READ_MEM( addr ); - CACHE_TIME(); - goto tst_common; - } - - case 0xA3: // TST zp,x - nz = READ_LOW( BYTE( GET_MSB() + x ) ); - goto tst_common; - - case 0x83: // TST zp - nz = READ_LOW( GET_MSB() ); - tst_common: - pc += 2; - flags = (flags & ~v40) + (nz & v40); - if ( nz & data ) - goto loop; // Z should be clear, and nz must be non-zero if nz & data is - nz <<= 8; // set Z flag without affecting N flag - goto loop; - - { - int addr; - case 0x0C: // TSB abs - case 0x1C: // TRB abs - addr = GET_ADDR(); - pc++; - goto txb_addr; - - // TODO: everyone lists different behaviors for the flags flags, ugh - case 0x04: // TSB zp - case 0x14: // TRB zp - addr = data + ram_addr; - txb_addr: - FLUSH_TIME(); - nz = a | READ_MEM( addr ); - if ( opcode & 0x10 ) - nz ^= a; // bits from a will already be set, so this clears them - flags = (flags & ~v40) + (nz & v40); - pc++; - WRITE_MEM( addr, nz ); - CACHE_TIME(); - goto loop; - } - - case 0x07: // RMBn - case 0x17: - case 0x27: - case 0x37: - case 0x47: - case 0x57: - case 0x67: - case 0x77: - pc++; - READ_LOW( data ) &= ~(1 << (opcode >> 4)); - goto loop; - - case 0x87: // SMBn - case 0x97: - case 0xA7: - case 0xB7: - case 0xC7: - case 0xD7: - case 0xE7: - case 0xF7: - pc++; - READ_LOW( data ) |= 1 << ((opcode >> 4) - 8); - goto loop; - -// Load/store - - case 0x9E: // STZ abs,x - data += x; - case 0x9C: // STZ abs - ADD_PAGE( data ); - pc++; - FLUSH_TIME(); - WRITE_MEM( data, 0 ); - CACHE_TIME(); - goto loop; - - case 0x74: // STZ zp,x - data = BYTE( data + x ); - case 0x64: // STZ zp - pc++; - WRITE_LOW( data, 0 ); - goto loop; - - case 0x94: // STY zp,x - data = BYTE( data + x ); - case 0x84: // STY zp - pc++; - WRITE_LOW( data, y ); - goto loop; - - case 0x96: // STX zp,y - data = BYTE( data + y ); - case 0x86: // STX zp - pc++; - WRITE_LOW( data, x ); - goto loop; - - case 0xB6: // LDX zp,y - data = BYTE( data + y ); - case 0xA6: // LDX zp - data = READ_LOW( data ); - case 0xA2: // LDX #imm - pc++; - x = data; - nz = data; - goto loop; - - case 0xB4: // LDY zp,x - data = BYTE( data + x ); - case 0xA4: // LDY zp - data = READ_LOW( data ); - case 0xA0: // LDY #imm - pc++; - y = data; - nz = data; - goto loop; - - case 0xBC: // LDY abs,X - data += x; - PAGE_PENALTY( data ); - case 0xAC:{// LDY abs - int addr = data + 0x100 * GET_MSB(); - pc += 2; - FLUSH_TIME(); - y = nz = READ_MEM( addr ); - CACHE_TIME(); - goto loop; - } - - { - int temp; - case 0x8C: // STY abs - temp = y; - if ( 0 ) - case 0x8E: // STX abs - temp = x; - int addr = GET_ADDR(); - pc += 2; - FLUSH_TIME(); - WRITE_MEM( addr, temp ); - CACHE_TIME(); - goto loop; - } - -// Compare - - case 0xEC:{// CPX abs - int addr = GET_ADDR(); - pc++; - FLUSH_TIME(); - data = READ_MEM( addr ); - CACHE_TIME(); - goto cpx_data; - } - - case 0xE4: // CPX zp - data = READ_LOW( data ); - case 0xE0: // CPX #imm - cpx_data: - nz = x - data; - pc++; - c = ~nz; - nz = BYTE( nz ); - goto loop; - - case 0xCC:{// CPY abs - int addr = GET_ADDR(); - pc++; - FLUSH_TIME(); - data = READ_MEM( addr ); - CACHE_TIME(); - goto cpy_data; - } - - case 0xC4: // CPY zp - data = READ_LOW( data ); - case 0xC0: // CPY #imm - cpy_data: - nz = y - data; - pc++; - c = ~nz; - nz = BYTE( nz ); - goto loop; - -// Logical - -#define ARITH_ADDR_MODES( op )\ - case op - 0x04: /* (ind,x) */\ - data = BYTE( data + x );\ - case op + 0x0D: /* (ind) */\ - data = 0x100 * READ_LOW( BYTE( data + 1 ) ) + READ_LOW( data );\ - goto ptr##op;\ - case op + 0x0C:{/* (ind),y */\ - int temp = READ_LOW( data ) + y;\ - PAGE_PENALTY( temp );\ - data = temp + 0x100 * READ_LOW( BYTE( data + 1 ) );\ - goto ptr##op;\ - }\ - case op + 0x10: /* zp,X */\ - data = BYTE( data + x );\ - case op + 0x00: /* zp */\ - data = READ_LOW( data );\ - goto imm##op;\ - case op + 0x14: /* abs,Y */\ - data += y;\ - goto ind##op;\ - case op + 0x18: /* abs,X */\ - data += x;\ - ind##op:\ - PAGE_PENALTY( data );\ - case op + 0x08: /* abs */\ - ADD_PAGE( data );\ - ptr##op:\ - FLUSH_TIME();\ - data = READ_MEM( data );\ - CACHE_TIME();\ - case op + 0x04: /* imm */\ - imm##op: - - ARITH_ADDR_MODES( 0xC5 ) // CMP - nz = a - data; - pc++; - c = ~nz; - nz = BYTE( nz ); - goto loop; - - ARITH_ADDR_MODES( 0x25 ) // AND - nz = (a &= data); - pc++; - goto loop; - - ARITH_ADDR_MODES( 0x45 ) // EOR - nz = (a ^= data); - pc++; - goto loop; - - ARITH_ADDR_MODES( 0x05 ) // ORA - nz = (a |= data); - pc++; - goto loop; - -// Add/subtract - - ARITH_ADDR_MODES( 0xE5 ) // SBC - data ^= 0xFF; - goto adc_imm; - - ARITH_ADDR_MODES( 0x65 ) // ADC - adc_imm: { - /* if ( flags & d08 ) - dprintf( "Decimal mode not supported\n" ); */ - int carry = c >> 8 & 1; - int ov = (a ^ 0x80) + carry + SBYTE( data ); - flags = (flags & ~v40) + (ov >> 2 & v40); - c = nz = a + data + carry; - pc++; - a = BYTE( nz ); - goto loop; - } - -// Shift/rotate - - case 0x4A: // LSR A - c = 0; - case 0x6A: // ROR A - nz = c >> 1 & 0x80; - c = a << 8; - nz += a >> 1; - a = nz; - goto loop; - - case 0x0A: // ASL A - nz = a << 1; - c = nz; - a = BYTE( nz ); - goto loop; - - case 0x2A: { // ROL A - nz = a << 1; - int temp = c >> 8 & 1; - c = nz; - nz += temp; - a = BYTE( nz ); - goto loop; - } - - case 0x5E: // LSR abs,X - data += x; - case 0x4E: // LSR abs - c = 0; - case 0x6E: // ROR abs - ror_abs: { - ADD_PAGE( data ); - FLUSH_TIME(); - int temp = READ_MEM( data ); - nz = (c >> 1 & 0x80) + (temp >> 1); - c = temp << 8; - goto rotate_common; - } - - case 0x3E: // ROL abs,X - data += x; - goto rol_abs; - - case 0x1E: // ASL abs,X - data += x; - case 0x0E: // ASL abs - c = 0; - case 0x2E: // ROL abs - rol_abs: - ADD_PAGE( data ); - nz = c >> 8 & 1; - FLUSH_TIME(); - nz += (c = READ_MEM( data ) << 1); - rotate_common: - pc++; - WRITE_MEM( data, BYTE( nz ) ); - CACHE_TIME(); - goto loop; - - case 0x7E: // ROR abs,X - data += x; - goto ror_abs; - - case 0x76: // ROR zp,x - data = BYTE( data + x ); - goto ror_zp; - - case 0x56: // LSR zp,x - data = BYTE( data + x ); - case 0x46: // LSR zp - c = 0; - case 0x66: // ROR zp - ror_zp: { - int temp = READ_LOW( data ); - nz = (c >> 1 & 0x80) + (temp >> 1); - c = temp << 8; - goto write_nz_zp; - } - - case 0x36: // ROL zp,x - data = BYTE( data + x ); - goto rol_zp; - - case 0x16: // ASL zp,x - data = BYTE( data + x ); - case 0x06: // ASL zp - c = 0; - case 0x26: // ROL zp - rol_zp: - nz = c >> 8 & 1; - nz += (c = READ_LOW( data ) << 1); - goto write_nz_zp; - -// Increment/decrement - -#define INC_DEC( reg, n ) reg = BYTE( nz = reg + n ); goto loop; - - case 0x1A: // INA - INC_DEC( a, +1 ) - - case 0xE8: // INX - INC_DEC( x, +1 ) - - case 0xC8: // INY - INC_DEC( y, +1 ) - - case 0x3A: // DEA - INC_DEC( a, -1 ) - - case 0xCA: // DEX - INC_DEC( x, -1 ) - - case 0x88: // DEY - INC_DEC( y, -1 ) - - case 0xF6: // INC zp,x - data = BYTE( data + x ); - case 0xE6: // INC zp - nz = 1; - goto add_nz_zp; - - case 0xD6: // DEC zp,x - data = BYTE( data + x ); - case 0xC6: // DEC zp - nz = -1; - add_nz_zp: - nz += READ_LOW( data ); - write_nz_zp: - pc++; - WRITE_LOW( data, nz ); - goto loop; - - case 0xFE: // INC abs,x - data = x + GET_ADDR(); - goto inc_ptr; - - case 0xEE: // INC abs - data = GET_ADDR(); - inc_ptr: - nz = 1; - goto inc_common; - - case 0xDE: // DEC abs,x - data = x + GET_ADDR(); - goto dec_ptr; - - case 0xCE: // DEC abs - data = GET_ADDR(); - dec_ptr: - nz = -1; - inc_common: - FLUSH_TIME(); - pc += 2; - nz += READ_MEM( data ); - WRITE_MEM( data, BYTE( nz ) ); - CACHE_TIME(); - goto loop; - -// Transfer - - case 0xA8: // TAY - y = nz = a; - goto loop; - - case 0x98: // TYA - a = nz = y; - goto loop; - - case 0xAA: // TAX - x = nz = a; - goto loop; - - case 0x8A: // TXA - a = nz = x; - goto loop; - - case 0x9A: // TXS - SET_SP( x ); // verified (no flag change) - goto loop; - - case 0xBA: // TSX - x = nz = GET_SP(); - goto loop; - - #define SWAP_REGS( r1, r2 ) {\ - int t = r1;\ - r1 = r2;\ - r2 = t;\ - goto loop;\ - } - - case 0x02: // SXY - SWAP_REGS( x, y ); - - case 0x22: // SAX - SWAP_REGS( a, x ); - - case 0x42: // SAY - SWAP_REGS( a, y ); - - case 0x62: // CLA - a = 0; - goto loop; - - case 0x82: // CLX - x = 0; - goto loop; - - case 0xC2: // CLY - y = 0; - goto loop; - -// Stack - - case 0x48: // PHA - sp = SP( -1 ); - WRITE_STACK( sp, a ); - goto loop; - - case 0x68: // PLA - a = nz = READ_STACK( sp ); - sp = SP( 1 ); - goto loop; - - case 0xDA: // PHX - sp = SP( -1 ); - WRITE_STACK( sp, x ); - goto loop; - - case 0x5A: // PHY - sp = SP( -1 ); - WRITE_STACK( sp, y ); - goto loop; - - case 0x40:{// RTI - pc = READ_STACK( SP( 1 ) ); - pc += READ_STACK( SP( 2 ) ) * 0x100; - int temp = READ_STACK( sp ); - sp = SP( 3 ); - data = flags; - SET_FLAGS( temp ); - cpu->r.flags = flags; // update externally-visible I flag - if ( (data ^ flags) & i04 ) - { - hes_time_t new_time = cpu->end_time_; - if ( !(flags & i04) && new_time > cpu->irq_time_ ) - new_time = cpu->irq_time_; - int delta = s.base - new_time; - s.base = new_time; - s_time += delta; - } - goto loop; - } - - case 0xFA: // PLX - x = nz = READ_STACK( sp ); - sp = SP( 1 ); - goto loop; - - case 0x7A: // PLY - y = nz = READ_STACK( sp ); - sp = SP( 1 ); - goto loop; - - case 0x28:{// PLP - int temp = READ_STACK( sp ); - sp = SP( 1 ); - int changed = flags ^ temp; - SET_FLAGS( temp ); - if ( !(changed & i04) ) - goto loop; // I flag didn't change - if ( flags & i04 ) - goto handle_sei; - goto handle_cli; - } - - case 0x08:{// PHP - int temp; - GET_FLAGS( temp ); - sp = SP( -1 ); - WRITE_STACK( sp, temp | b10 ); - goto loop; - } - -// Flags - - case 0x38: // SEC - c = 0x100; - goto loop; - - case 0x18: // CLC - c = 0; - goto loop; - - case 0xB8: // CLV - flags &= ~v40; - goto loop; - - case 0xD8: // CLD - flags &= ~d08; - goto loop; - - case 0xF8: // SED - flags |= d08; - goto loop; - - case 0x58: // CLI - if ( !(flags & i04) ) - goto loop; - flags &= ~i04; - handle_cli: { - //dprintf( "CLI at %d\n", TIME ); - cpu->r.flags = flags; // update externally-visible I flag - int delta = s.base - cpu->irq_time_; - if ( delta <= 0 ) - { - if ( TIME() < cpu->irq_time_ ) - goto loop; - goto delayed_cli; - } - s.base = cpu->irq_time_; - s_time += delta; - if ( s_time < 0 ) - goto loop; - - if ( delta >= s_time + 1 ) - { - // delayed irq until after next instruction - s.base += s_time + 1; - s_time = -1; - cpu->irq_time_ = s.base; // TODO: remove, as only to satisfy debug check in loop - goto loop; - } - - // TODO: implement - delayed_cli: - dprintf( "Delayed CLI not supported\n" ); - goto loop; - } - - case 0x78: // SEI - if ( flags & i04 ) - goto loop; - flags |= i04; - handle_sei: { - cpu->r.flags = flags; // update externally-visible I flag - int delta = s.base - cpu->end_time_; - s.base = cpu->end_time_; - s_time += delta; - if ( s_time < 0 ) - goto loop; - - dprintf( "Delayed SEI not supported\n" ); - goto loop; - } - -// Special - - case 0x53:{// TAM - int bits = data; // avoid using data across function call - pc++; - for ( int i = 0; i < 8; i++ ) - if ( bits & (1 << i) ) - SET_MMR( i, a ); - goto loop; - } - - case 0x43:{// TMA - pc++; - byte const* in = cpu->mmr; - do - { - if ( data & 1 ) - a = *in; - in++; - } - while ( (data >>= 1) != 0 ); - goto loop; - } - - case 0x03: // ST0 - case 0x13: // ST1 - case 0x23:{// ST2 - int addr = opcode >> 4; - if ( addr ) - addr++; - pc++; - FLUSH_TIME(); - WRITE_VDP( addr, data ); - CACHE_TIME(); - goto loop; - } - - case 0xEA: // NOP - goto loop; - - case 0x54: // CSL - dprintf( "CSL not supported\n" ); - illegal_encountered = true; - goto loop; - - case 0xD4: // CSH - goto loop; - - case 0xF4: { // SET - //int operand = GET_MSB(); - dprintf( "SET not handled\n" ); - //switch ( data ) - //{ - //} - illegal_encountered = true; - goto loop; - } - -// Block transfer - - { - int in_alt; - int in_inc; - int out_alt; - int out_inc; - - case 0xE3: // TIA - in_alt = 0; - goto bxfer_alt; - - case 0xF3: // TAI - in_alt = 1; - bxfer_alt: - in_inc = in_alt ^ 1; - out_alt = in_inc; - out_inc = in_alt; - goto bxfer; - - case 0xD3: // TIN - in_inc = 1; - out_inc = 0; - goto bxfer_no_alt; - - case 0xC3: // TDD - in_inc = -1; - out_inc = -1; - goto bxfer_no_alt; - - case 0x73: // TII - in_inc = 1; - out_inc = 1; - bxfer_no_alt: - in_alt = 0; - out_alt = 0; - bxfer: - { - int in = GET_LE16( instr + 0 ); - int out = GET_LE16( instr + 2 ); - int count = GET_LE16( instr + 4 ); - if ( !count ) - count = 0x10000; - pc += 6; - WRITE_STACK( SP( -1 ), y ); - WRITE_STACK( SP( -2 ), a ); - WRITE_STACK( SP( -3 ), x ); - FLUSH_TIME(); - do - { - // TODO: reads from $0800-$1400 in I/O page should do I/O - int t = READ_MEM( in ); - in = WORD( in + in_inc ); - s.time += 6; - if ( in_alt ) - in_inc = -in_inc; - WRITE_MEM( out, t ); - out = WORD( out + out_inc ); - if ( out_alt ) - out_inc = -out_inc; - } - while ( --count ); - CACHE_TIME(); - goto loop; - } - } - -// Illegal - - default: - check( (unsigned) opcode <= 0xFF ); - dprintf( "Illegal opcode $%02X at $%04X\n", (int) opcode, (int) pc - 1 ); - illegal_encountered = true; - goto loop; - } - assert( false ); // catch missing 'goto loop' or accidental 'break' - - int result_; -handle_brk: - pc++; - result_ = 6; - -interrupt: - { - s_time += 7; - - // Save PC and read vector - WRITE_STACK( SP( -1 ), pc >> 8 ); - WRITE_STACK( SP( -2 ), pc ); - pc = GET_LE16( &READ_CODE( 0xFFF0 ) + result_ ); - - // Save flags - int temp; - GET_FLAGS( temp ); - if ( result_ == 6 ) - temp |= b10; // BRK sets B bit - sp = SP( -3 ); - WRITE_STACK( sp, temp ); - - // Update I flag in externally-visible flags - flags &= ~d08; - cpu->r.flags = (flags |= i04); - - // Update time - int delta = s.base - cpu->end_time_; - if ( delta >= 0 ) - goto loop; - s_time += delta; - s.base = cpu->end_time_; - goto loop; - } - -idle_done: - s_time = 0; - -out_of_time: - pc--; - - // Optional action that triggers interrupt or changes irq/end time - #ifdef CPU_DONE - { - CPU_DONE( result_ ); - if ( result_ >= 0 ) - goto interrupt; - if ( s_time < 0 ) - goto loop; - } - #endif - - // Flush cached state - cpu->r.pc = pc; - cpu->r.sp = GET_SP(); - cpu->r.a = a; - cpu->r.x = x; - cpu->r.y = y; - - int temp; - GET_FLAGS( temp ); - cpu->r.flags = temp; - - cpu->cpu_state_.base = s.base; - cpu->cpu_state_.time = s_time; - cpu->cpu_state = &cpu->cpu_state_; -} diff --git a/apps/codecs/libgme/hes_emu.c b/apps/codecs/libgme/hes_emu.c deleted file mode 100644 index d6bafea334..0000000000 --- a/apps/codecs/libgme/hes_emu.c +++ /dev/null @@ -1,644 +0,0 @@ -// Game_Music_Emu 0.5.2. http://www.slack.net/~ant/ - -#include "hes_emu.h" - -#include "blargg_endian.h" -#include "blargg_source.h" - -/* Copyright (C) 2006 Shay Green. This module is free software; you -can redistribute it and/or modify it under the terms of the GNU Lesser -General Public License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. This -module is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more -details. You should have received a copy of the GNU Lesser General Public -License along with this module; if not, write to the Free Software Foundation, -Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ - -int const timer_mask = 0x04; -int const vdp_mask = 0x02; -int const i_flag_mask = 0x04; -int const unmapped = 0xFF; - -int const period_60hz = 262 * 455; // scanlines * clocks per scanline - -const char gme_wrong_file_type [] = "Wrong file type for this emulator"; - -static void clear_track_vars( struct Hes_Emu* this ) -{ - this->current_track_ = -1; - track_stop( &this->track_filter ); -} - -void Hes_init( struct Hes_Emu* this ) -{ - this->sample_rate_ = 0; - this->mute_mask_ = 0; - this->tempo_ = (int)(FP_ONE_TEMPO); - - // defaults - this->tfilter = *track_get_setup( &this->track_filter ); - this->tfilter.max_initial = 2; - this->tfilter.lookahead = 6; - this->track_filter.silence_ignored_ = false; - - this->timer.raw_load = 0; - Sound_set_gain( this, (int)(FP_ONE_GAIN*1.11) ); - - Rom_init( &this->rom, 0x2000 ); - - Apu_init( &this->apu ); - Adpcm_init( &this->adpcm ); - Cpu_init( &this->cpu ); - - /* Set default track count */ - this->track_count = 255; - - // clears fields - this->voice_count_ = 0; - this->voice_types_ = 0; - clear_track_vars( this ); -} - -static blargg_err_t check_hes_header( void const* header ) -{ - if ( memcmp( header, "HESM", 4 ) ) - return gme_wrong_file_type; - return 0; -} - -// Setup - -blargg_err_t Hes_load_mem( struct Hes_Emu* this, void* data, long size ) -{ - // Unload - this->voice_count_ = 0; - this->track_count = 255; - this->m3u.size = 0; - clear_track_vars( this ); - - assert( offsetof (struct header_t,unused [4]) == header_size ); - RETURN_ERR( Rom_load( &this->rom, data, size, header_size, &this->header, unmapped ) ); - - RETURN_ERR( check_hes_header( this->header.tag ) ); - - /* if ( header_.vers != 0 ) - warning( "Unknown file version" ); - - if ( memcmp( header_.data_tag, "DATA", 4 ) ) - warning( "Data header missing" ); - - if ( memcmp( header_.unused, "\0\0\0\0", 4 ) ) - warning( "Unknown header data" ); */ - - // File spec supports multiple blocks, but I haven't found any, and - // many files have bad sizes in the only block, so it's simpler to - // just try to load the damn data as best as possible. - - int addr = get_le32( this->header.addr ); - /* int rom_size = get_le32( this->header.size ); */ - int const rom_max = 0x100000; - if ( (unsigned) addr >= (unsigned) rom_max ) - { - /* warning( "Invalid address" ); */ - addr &= rom_max - 1; - } - /* if ( (unsigned) (addr + size) > (unsigned) rom_max ) - warning( "Invalid size" ); - - if ( rom_size != rom.file_size() ) - { - if ( size <= rom.file_size() - 4 && !memcmp( rom.begin() + size, "DATA", 4 ) ) - warning( "Multiple DATA not supported" ); - else if ( size < rom.file_size() ) - warning( "Extra file data" ); - else - warning( "Missing file data" ); - } */ - - Rom_set_addr( &this->rom, addr ); - - this->voice_count_ = osc_count + adpcm_osc_count; - static int const types [osc_count + adpcm_osc_count] = { - wave_type+0, wave_type+1, wave_type+2, wave_type+3, mixed_type+0, mixed_type+1, mixed_type+2 - }; - this->voice_types_ = types; - - Apu_volume( &this->apu, this->gain_ ); - Adpcm_volume( &this->adpcm, this->gain_ ); - - // Setup buffer - this->clock_rate_ = 7159091; - Buffer_clock_rate( &this->stereo_buf, 7159091 ); - RETURN_ERR( Buffer_set_channel_count( &this->stereo_buf, this->voice_count_, this->voice_types_ ) ); - this->buf_changed_count = Buffer_channels_changed_count( &this->stereo_buf ); - - Sound_set_tempo( this, this->tempo_ ); - Sound_mute_voices( this, this->mute_mask_ ); - - return 0; -} - -// Emulation - -static void recalc_timer_load( struct Hes_Emu* this ) -{ - this->timer.load = this->timer.raw_load * this->timer_base + 1; -} - -// Hardware - -void run_until( struct Hes_Emu* this, hes_time_t present ) -{ - while ( this->vdp.next_vbl < present ) - this->vdp.next_vbl += this->play_period; - - hes_time_t elapsed = present - this->timer.last_time; - if ( elapsed > 0 ) - { - if ( this->timer.enabled ) - { - this->timer.count -= elapsed; - if ( this->timer.count <= 0 ) - this->timer.count += this->timer.load; - } - this->timer.last_time = present; - } -} - -void write_vdp( struct Hes_Emu* this, int addr, int data ) -{ - switch ( addr ) - { - case 0: - this->vdp.latch = data & 0x1F; - break; - - case 2: - if ( this->vdp.latch == 5 ) - { - /* if ( data & 0x04 ) - warning( "Scanline interrupt unsupported" ); */ - run_until( this, Cpu_time( &this->cpu ) ); - this->vdp.control = data; - irq_changed( this ); - } - /* else - { - dprintf( "VDP not supported: $%02X <- $%02X\n", vdp.latch, data ); - } */ - break; - - case 3: - /* dprintf( "VDP MSB not supported: $%02X <- $%02X\n", vdp.latch, data ); */ - break; - } -} - -void write_mem_( struct Hes_Emu* this, hes_addr_t addr, int data ) -{ - hes_time_t time = Cpu_time( &this->cpu ); - if ( (unsigned) (addr - apu_io_addr) < apu_io_size ) - { - // Avoid going way past end when a long block xfer is writing to I/O space. - // Not a problem for other registers below because they don't write to - // Blip_Buffer. - hes_time_t t = min( time, Cpu_end_time( &this->cpu ) + 8 ); - Apu_write_data( &this->apu, t, addr, data ); - return; - } - if ( (unsigned) (addr - adpcm_io_addr) < adpcm_io_size ) - { - hes_time_t t = min( time, Cpu_end_time( &this->cpu ) + 6 ); - Adpcm_write_data( &this->adpcm, t, addr, data ); - return; - } - - switch ( addr ) - { - case 0x0000: - case 0x0002: - case 0x0003: - write_vdp( this, addr, data ); - return; - - case 0x0C00: { - run_until( this, time ); - this->timer.raw_load = (data & 0x7F) + 1; - recalc_timer_load( this ); - this->timer.count = this->timer.load; - break; - } - - case 0x0C01: - data &= 1; - if ( this->timer.enabled == data ) - return; - run_until( this, time ); - this->timer.enabled = data; - if ( data ) - this->timer.count = this->timer.load; - break; - - case 0x1402: - run_until( this, time ); - this->irq.disables = data; - /* if ( (data & 0xF8) && (data & 0xF8) != 0xF8 ) // flag questionable values - dprintf( "Int mask: $%02X\n", data ); */ - break; - - case 0x1403: - run_until( this, time ); - if ( this->timer.enabled ) - this->timer.count = this->timer.load; - this->timer.fired = false; - break; - -#ifndef NDEBUG - case 0x1000: // I/O port - case 0x0402: // palette - case 0x0403: - case 0x0404: - case 0x0405: - return; - - default: - /* dprintf( "unmapped write $%04X <- $%02X\n", addr, data ); */ - return; -#endif - } - - irq_changed( this ); -} - -int read_mem_( struct Hes_Emu* this, hes_addr_t addr ) -{ - hes_time_t time = Cpu_time( &this->cpu ); - addr &= page_size - 1; - switch ( addr ) - { - case 0x0000: - if ( this->irq.vdp > time ) - return 0; - this->irq.vdp = future_time; - run_until( this, time ); - irq_changed( this ); - return 0x20; - - /* case 0x0002: - case 0x0003: - dprintf( "VDP read not supported: %d\n", addr ); - return 0; */ - - case 0x0C01: - //return timer.enabled; // TODO: remove? - case 0x0C00: - run_until( this, time ); - /* dprintf( "Timer count read\n" ); */ - return (unsigned) (this->timer.count - 1) / this->timer_base; - - case 0x1402: - return this->irq.disables; - - case 0x1403: - { - int status = 0; - if ( this->irq.timer <= time ) status |= timer_mask; - if ( this->irq.vdp <= time ) status |= vdp_mask; - return status; - } - - case 0x180A: - case 0x180B: - case 0x180C: - case 0x180D: - return Adpcm_read_data( &this->adpcm, time, addr ); - - #ifndef NDEBUG - case 0x1000: // I/O port - //case 0x180C: // CD-ROM - //case 0x180D: - break; - - /* default: - dprintf( "unmapped read $%04X\n", addr ); */ - #endif - } - - return unmapped; -} - -void irq_changed( struct Hes_Emu* this ) -{ - hes_time_t present = Cpu_time( &this->cpu ); - - if ( this->irq.timer > present ) - { - this->irq.timer = future_time; - if ( this->timer.enabled && !this->timer.fired ) - this->irq.timer = present + this->timer.count; - } - - if ( this->irq.vdp > present ) - { - this->irq.vdp = future_time; - if ( this->vdp.control & 0x08 ) - this->irq.vdp = this->vdp.next_vbl; - } - - hes_time_t time = future_time; - if ( !(this->irq.disables & timer_mask) ) time = this->irq.timer; - if ( !(this->irq.disables & vdp_mask) ) time = min( time, this->irq.vdp ); - - Cpu_set_irq_time( &this->cpu, time ); -} - -int cpu_done( struct Hes_Emu* this ) -{ - check( Cpu_time( &this->cpu ) >= Cpu_end_time( &this->cpu ) || - (!(this->cpu.r.flags & i_flag_mask) && Cpu_time( &this->cpu ) >= Cpu_irq_time( &this->cpu )) ); - - if ( !(this->cpu.r.flags & i_flag_mask) ) - { - hes_time_t present = Cpu_time( &this->cpu ); - - if ( this->irq.timer <= present && !(this->irq.disables & timer_mask) ) - { - this->timer.fired = true; - this->irq.timer = future_time; - irq_changed( this ); // overkill, but not worth writing custom code - return 0x0A; - } - - if ( this->irq.vdp <= present && !(this->irq.disables & vdp_mask) ) - { - // work around for bugs with music not acknowledging VDP - //run_until( present ); - //irq.vdp = cpu.future_time; - //irq_changed(); - return 0x08; - } - } - return -1; -} - -static void adjust_time( hes_time_t* time, hes_time_t delta ) -{ - if ( *time < future_time ) - { - *time -= delta; - if ( *time < 0 ) - *time = 0; - } -} - -static blargg_err_t end_frame( struct Hes_Emu* this, hes_time_t duration ) -{ - /* if ( run_cpu( this, duration ) ) - warning( "Emulation error (illegal instruction)" ); */ - run_cpu( this, duration ); - - check( Cpu_time( &this->cpu ) >= duration ); - //check( time() - duration < 20 ); // Txx instruction could cause going way over - - run_until( this, duration ); - - // end time frame - this->timer.last_time -= duration; - this->vdp.next_vbl -= duration; - Cpu_end_frame( &this->cpu, duration ); - adjust_time( &this->irq.timer, duration ); - adjust_time( &this->irq.vdp, duration ); - Apu_end_frame( &this->apu, duration ); - Adpcm_end_frame( &this->adpcm, duration ); - - return 0; -} - -static blargg_err_t run_clocks( struct Hes_Emu* this, blip_time_t* duration_ ) -{ - return end_frame( this, *duration_ ); -} - -blargg_err_t play_( void *emu, int count, sample_t out [] ) -{ - struct Hes_Emu* this = (struct Hes_Emu*) emu; - - int remain = count; - while ( remain ) - { - Buffer_disable_immediate_removal( &this->stereo_buf ); - remain -= Buffer_read_samples( &this->stereo_buf, &out [count - remain], remain ); - if ( remain ) - { - if ( this->buf_changed_count != Buffer_channels_changed_count( &this->stereo_buf ) ) - { - this->buf_changed_count = Buffer_channels_changed_count( &this->stereo_buf ); - - // Remute voices - Sound_mute_voices( this, this->mute_mask_ ); - } - int msec = Buffer_length( &this->stereo_buf ); - blip_time_t clocks_emulated = msec * this->clock_rate_ / 1000 - 100; - RETURN_ERR( run_clocks( this, &clocks_emulated ) ); - assert( clocks_emulated ); - Buffer_end_frame( &this->stereo_buf, clocks_emulated ); - } - } - return 0; -} - -// Music emu - -blargg_err_t Hes_set_sample_rate( struct Hes_Emu* this, int rate ) -{ - require( !this->sample_rate_ ); // sample rate can't be changed once set - Buffer_init( &this->stereo_buf ); - RETURN_ERR( Buffer_set_sample_rate( &this->stereo_buf, rate, 1000 / 20 ) ); - - // Set bass frequency - Buffer_bass_freq( &this->stereo_buf, 60 ); - - this->sample_rate_ = rate; - RETURN_ERR( track_init( &this->track_filter, this ) ); - this->tfilter.max_silence = 6 * stereo * this->sample_rate_; - return 0; -} - -void Sound_mute_voice( struct Hes_Emu* this, int index, bool mute ) -{ - require( (unsigned) index < (unsigned) this->voice_count_ ); - int bit = 1 << index; - int mask = this->mute_mask_ | bit; - if ( !mute ) - mask ^= bit; - Sound_mute_voices( this, mask ); -} - -void Sound_mute_voices( struct Hes_Emu* this, int mask ) -{ - require( this->sample_rate_ ); // sample rate must be set first - this->mute_mask_ = mask; - - // Set adpcm voice - struct channel_t ch = Buffer_channel( &this->stereo_buf, this->voice_count_ ); - if ( mask & (1 << this->voice_count_ ) ) - Adpcm_set_output( &this->adpcm, 0, 0, 0, 0 ); - else - Adpcm_set_output( &this->adpcm, 0, ch.center, ch.left, ch.right ); - - // Set apu voices - int i = this->voice_count_ - 1; - for ( ; i--; ) - { - if ( mask & (1 << i) ) - { - Apu_osc_output( &this->apu, i, 0, 0, 0 ); - } - else - { - struct channel_t ch = Buffer_channel( &this->stereo_buf, i ); - assert( (ch.center && ch.left && ch.right) || - (!ch.center && !ch.left && !ch.right) ); // all or nothing - Apu_osc_output( &this->apu, i, ch.center, ch.left, ch.right ); - } - } -} - -void Sound_set_tempo( struct Hes_Emu* this, int t ) -{ - require( this->sample_rate_ ); // sample rate must be set first - int const min = (int)(FP_ONE_TEMPO*0.02); - int const max = (int)(FP_ONE_TEMPO*4.00); - if ( t < min ) t = min; - if ( t > max ) t = max; - this->play_period = (hes_time_t) ((period_60hz*FP_ONE_TEMPO) / t); - this->timer_base = (int) ((1024*FP_ONE_TEMPO) / t); - recalc_timer_load( this ); - this->tempo_ = t; -} - -blargg_err_t Hes_start_track( struct Hes_Emu* this, int track ) -{ - clear_track_vars( this ); - - // Remap track if playlist available - if ( this->m3u.size > 0 ) { - struct entry_t* e = &this->m3u.entries[track]; - track = e->track; - } - - this->current_track_ = track; - - Buffer_clear( &this->stereo_buf ); - - memset( this->ram, 0, sizeof this->ram ); // some HES music relies on zero fill - memset( this->sgx, 0, sizeof this->sgx ); - - Apu_reset( &this->apu ); - Adpcm_reset( &this->adpcm ); - Cpu_reset( &this->cpu ); - - unsigned i; - for ( i = 0; i < sizeof this->header.banks; i++ ) - set_mmr( this, i, this->header.banks [i] ); - set_mmr( this, page_count, 0xFF ); // unmapped beyond end of address space - - this->irq.disables = timer_mask | vdp_mask; - this->irq.timer = future_time; - this->irq.vdp = future_time; - - this->timer.enabled = false; - this->timer.raw_load= 0x80; - this->timer.count = this->timer.load; - this->timer.fired = false; - this->timer.last_time = 0; - - this->vdp.latch = 0; - this->vdp.control = 0; - this->vdp.next_vbl = 0; - - this->ram [0x1FF] = (idle_addr - 1) >> 8; - this->ram [0x1FE] = (idle_addr - 1) & 0xFF; - this->cpu.r.sp = 0xFD; - this->cpu.r.pc = get_le16( this->header.init_addr ); - this->cpu.r.a = track; - - recalc_timer_load( this ); - - // convert filter times to samples - struct setup_t s = this->tfilter; - s.max_initial *= this->sample_rate_ * stereo; - #ifdef GME_DISABLE_SILENCE_LOOKAHEAD - s.lookahead = 1; - #endif - track_setup( &this->track_filter, &s ); - - return track_start( &this->track_filter ); -} - -// Tell/Seek - -static int msec_to_samples( int msec, int sample_rate ) -{ - int sec = msec / 1000; - msec -= sec * 1000; - return (sec * sample_rate + msec * sample_rate / 1000) * stereo; -} - -int Track_tell( struct Hes_Emu* this ) -{ - int rate = this->sample_rate_ * stereo; - int sec = track_sample_count( &this->track_filter ) / rate; - return sec * 1000 + (track_sample_count( &this->track_filter ) - sec * rate) * 1000 / rate; -} - -blargg_err_t Track_seek( struct Hes_Emu* this, int msec ) -{ - int time = msec_to_samples( msec, this->sample_rate_ ); - if ( time < track_sample_count( &this->track_filter ) ) - RETURN_ERR( Hes_start_track( this, this->current_track_ ) ); - return Track_skip( this, time - track_sample_count( &this->track_filter ) ); -} - -blargg_err_t skip_( void* emu, int count ) -{ - struct Hes_Emu* this = (struct Hes_Emu*) emu; - - // for long skip, mute sound - const int threshold = 32768; - if ( count > threshold ) - { - int saved_mute = this->mute_mask_; - Sound_mute_voices( this, ~0 ); - - int n = count - threshold/2; - n &= ~(2048-1); // round to multiple of 2048 - count -= n; - RETURN_ERR( skippy_( &this->track_filter, n ) ); - - Sound_mute_voices( this, saved_mute ); - } - - return skippy_( &this->track_filter, count ); -} - -blargg_err_t Track_skip( struct Hes_Emu* this, int count ) -{ - require( this->current_track_ >= 0 ); // start_track() must have been called already - return track_skip( &this->track_filter, count ); -} - -void Track_set_fade( struct Hes_Emu* this, int start_msec, int length_msec ) -{ - track_set_fade( &this->track_filter, msec_to_samples( start_msec, this->sample_rate_ ), - length_msec * this->sample_rate_ / (1000 / stereo) ); -} - -blargg_err_t Hes_play( struct Hes_Emu* this, int out_count, sample_t* out ) -{ - require( this->current_track_ >= 0 ); - require( out_count % stereo == 0 ); - return track_play( &this->track_filter, out_count, out ); -} diff --git a/apps/codecs/libgme/hes_emu.h b/apps/codecs/libgme/hes_emu.h deleted file mode 100644 index a1dd048498..0000000000 --- a/apps/codecs/libgme/hes_emu.h +++ /dev/null @@ -1,195 +0,0 @@ -// TurboGrafx-16/PC Engine HES music file emulator - -// Game_Music_Emu 0.5.2 -#ifndef HES_EMU_H -#define HES_EMU_H - -#include "blargg_source.h" - -#include "multi_buffer.h" -#include "rom_data.h" -#include "hes_apu.h" -#include "hes_apu_adpcm.h" -#include "hes_cpu.h" -#include "m3u_playlist.h" -#include "track_filter.h" - -// HES file header -enum { info_offset = 0x20 }; -enum { header_size = 0x20 }; -struct header_t -{ - byte tag [4]; - byte vers; - byte first_track; - byte init_addr [2]; - byte banks [8]; - byte data_tag [4]; - byte size [4]; - byte addr [4]; - byte unused [4]; -}; - - -struct timer_t { - hes_time_t last_time; - int count; - int load; - int raw_load; - byte enabled; - byte fired; -}; - -struct vdp_t { - hes_time_t next_vbl; - byte latch; - byte control; -}; - -struct irq_t { - hes_time_t timer; - hes_time_t vdp; - byte disables; -}; - -struct Hes_Emu { - hes_time_t play_period; - int timer_base; - - struct timer_t timer; - struct vdp_t vdp; - struct irq_t irq; - - // Sound - int clock_rate_; - int sample_rate_; - unsigned buf_changed_count; - int voice_count_; - int const* voice_types_; - int mute_mask_; - int tempo_; - int gain_; - - // track-specific - byte track_count; - int current_track_; - - // Larger files at the end - // Header for currently loaded file - struct header_t header; - - // M3u Playlist - struct M3u_Playlist m3u; - - struct setup_t tfilter; - struct Track_Filter track_filter; - - // Hes Cpu - struct Hes_Cpu cpu; - struct Rom_Data rom; - - struct Hes_Apu apu; - struct Hes_Apu_Adpcm adpcm; - - struct Multi_Buffer stereo_buf; - - // rom & ram - byte* write_pages [page_count + 1]; // 0 if unmapped or I/O space - byte ram [page_size]; - byte sgx [3 * page_size + cpu_padding]; -}; - - -// Basic functionality -// Initializes Hes_Emu structure -void Hes_init( struct Hes_Emu* this ); - -// Stops (clear) Hes_Emu structure -void Hes_stop( struct Hes_Emu* this ); - -// Loads a file from memory -blargg_err_t Hes_load_mem( struct Hes_Emu* this, void* data, long size ); - -// Set output sample rate. Must be called only once before loading file. -blargg_err_t Hes_set_sample_rate( struct Hes_Emu* this, int sample_rate ); - -// Start a track, where 0 is the first track. Also clears warning string. -blargg_err_t Hes_start_track( struct Hes_Emu* this, int ); - -// Generate 'count' samples info 'buf'. Output is in stereo. Any emulation -// errors set warning string, and major errors also end track. -blargg_err_t Hes_play( struct Hes_Emu* this, int count, sample_t* buf ); - -// Track status/control -// Number of milliseconds (1000 msec = 1 second) played since ning of track -int Track_tell( struct Hes_Emu* this ); - -// Seek to new time in track. Seeking backwards or far forward can take a while. -blargg_err_t Track_seek( struct Hes_Emu* this, int msec ); - -// Skip n samples -blargg_err_t Track_skip( struct Hes_Emu* this, int n ); - -// Set start time and length of track fade out. Once fade ends track_ended() returns -// true. Fade time can be changed while track is playing. -void Track_set_fade( struct Hes_Emu* this, int start_msec, int length_msec ); - -// True if a track has reached its end -static inline bool Track_ended( struct Hes_Emu* this ) -{ - return track_ended( &this->track_filter ); -} - -// Disables automatic end-of-track detection and skipping of silence at beginning -static inline void Track_ignore_silence( struct Hes_Emu* this, bool disable ) -{ - this->track_filter.silence_ignored_ = disable; -} - -// Get track length in milliseconds -static inline int Track_get_length( struct Hes_Emu* this, int n ) -{ - int length = 120 * 1000; /* 2 minutes */ - if ( (this->m3u.size > 0) && (n < this->m3u.size) ) { - struct entry_t* entry = &this->m3u.entries [n]; - length = entry->length; - } - - return length; -} - - -// Sound customization -// Adjust song tempo, where 1.0 = normal, 0.5 = half speed, 2.0 = double speed. -// Track length as returned by track_info() assumes a tempo of 1.0. -void Sound_set_tempo( struct Hes_Emu* this, int ); - -// Mute/unmute voice i, where voice 0 is first voice -void Sound_mute_voice( struct Hes_Emu* this, int index, bool mute ); - -// Set muting state of all voices at once using a bit mask, where -1 mutes them all, -// 0 unmutes them all, 0x01 mutes just the first voice, etc. -void Sound_mute_voices( struct Hes_Emu* this, int mask ); - -// Change overall output amplitude, where 1.0 results in minimal clamping. -// Must be called before set_sample_rate(). -static inline void Sound_set_gain( struct Hes_Emu* this, int g ) -{ - assert( !this->sample_rate_ ); // you must set gain before setting sample rate - this->gain_ = g; -} - -// Emulation (You shouldn't touch these) - -void irq_changed( struct Hes_Emu* this ); -void run_until( struct Hes_Emu* this, hes_time_t ); -bool run_cpu( struct Hes_Emu* this, hes_time_t end ); -int read_mem_( struct Hes_Emu* this, hes_addr_t ); -int read_mem( struct Hes_Emu* this, hes_addr_t ); -void write_mem_( struct Hes_Emu* this, hes_addr_t, int data ); -void write_mem( struct Hes_Emu* this, hes_addr_t, int ); -void write_vdp( struct Hes_Emu* this, int addr, int data ); -void set_mmr( struct Hes_Emu* this, int reg, int bank ); -int cpu_done( struct Hes_Emu* this ); - -#endif diff --git a/apps/codecs/libgme/inflate/bbfuncs.c b/apps/codecs/libgme/inflate/bbfuncs.c deleted file mode 100644 index 3b23c3b6db..0000000000 --- a/apps/codecs/libgme/inflate/bbfuncs.c +++ /dev/null @@ -1,147 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ - -#include "bbfuncs.h" - -#if defined(ROCKBOX) -#include "codeclib.h" -#endif - -void error_die(const char* msg) -{ - (void)msg; -} - -void error_msg(const char* msg) -{ - (void)msg; -} - -size_t safe_read(struct mbreader_t *md, void *buf, size_t count) -{ - ssize_t n; - - do { - n = mbread(md, buf, count); - } while (n < 0&&n!=-1); - - return n; -} - -/* - * Read all of the supplied buffer from a file This does multiple reads as - *necessary. Returns the amount read, or -1 on an error. A short read is - *returned on an end of file. - */ -ssize_t full_read(struct mbreader_t *md, void *buf, size_t len) -{ - ssize_t cc; - ssize_t total; - - total = 0; - - while (len) - { - cc = safe_read(md, buf, len); - - if (cc < 0) - return cc; /* read() returns -1 on failure. */ - - if (cc == 0) - break; - - buf = ((char *)buf) + cc; - total += cc; - len -= cc; - } - - return total; -} - -/* Die with an error message if we can't read the entire buffer. */ -void xread(struct mbreader_t *md, void *buf, ssize_t count) -{ - if (count) - { - ssize_t size = full_read(md, buf, count); - if (size != count) - error_die("short read"); - } -} - -/* Die with an error message if we can't read one character. */ -unsigned char xread_char(struct mbreader_t *md) -{ - unsigned char tmp; - - xread(md, &tmp, 1); - - return tmp; -} - -void check_header_gzip(struct mbreader_t *src_md) -{ - union { - unsigned char raw[8]; - struct { - unsigned char method; - unsigned char flags; - unsigned int mtime; - unsigned char xtra_flags; - unsigned char os_flags; - } formatted; - } header; - - xread(src_md, header.raw, 8); - - /* Check the compression method */ - if (header.formatted.method != 8) - error_die("Unknown compression method"); - - if (header.formatted.flags & 0x04) - { - /* bit 2 set: extra field present */ - unsigned char extra_short; - - extra_short = xread_char(src_md) + (xread_char(src_md) << 8); - while (extra_short > 0) - { - /* Ignore extra field */ - xread_char(src_md); - extra_short--; - } - } - - /* Discard original name if any */ - if (header.formatted.flags & 0x08) - /* bit 3 set: original file name present */ - while(xread_char(src_md) != 0) ; - - /* Discard file comment if any */ - if (header.formatted.flags & 0x10) - /* bit 4 set: file comment present */ - while(xread_char(src_md) != 0) ; - - /* Read the header checksum */ - if (header.formatted.flags & 0x02) - { - xread_char(src_md); - xread_char(src_md); - } -} diff --git a/apps/codecs/libgme/inflate/bbfuncs.h b/apps/codecs/libgme/inflate/bbfuncs.h deleted file mode 100644 index fe03ec1a3c..0000000000 --- a/apps/codecs/libgme/inflate/bbfuncs.h +++ /dev/null @@ -1,33 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ - -#ifndef BBFUNCS_H -#define BBFUNCS_H - -#include "mbreader.h" - -void error_die(const char* msg); -void error_msg(const char* msg); -size_t safe_read(struct mbreader_t *md, void *buf, size_t count); -ssize_t full_read(struct mbreader_t *md, void *buf, size_t len); -void xread(struct mbreader_t *md, void *buf, ssize_t count); -unsigned char xread_char(struct mbreader_t *md); -void check_header_gzip(struct mbreader_t *md); - -#endif diff --git a/apps/codecs/libgme/inflate/inflate.c b/apps/codecs/libgme/inflate/inflate.c deleted file mode 100644 index 130abe89be..0000000000 --- a/apps/codecs/libgme/inflate/inflate.c +++ /dev/null @@ -1,1156 +0,0 @@ -/* - * gunzip implementation for wikiviewer (c) Frederik M.J.V., 2006. - * some bug fixes by Adam Gashlin gunzip implementation for busybox - * - * Based on GNU gzip v1.2.4 Copyright (C) 1992-1993 Jean-loup Gailly. - * - * Originally adjusted for busybox by Sven Rudolph - * based on gzip sources - * - * Adjusted further by Erik Andersen to support files as - *well as stdin/stdout, and to generally behave itself wrt command line - *handling. - * - * General cleanup to better adhere to the style guide and make use of standard - *busybox functions by Glenn McGrath - * - * read_gz interface + associated hacking by Laurence Anderson - * - * Fixed huft_build() so decoding end-of-block code does not grab more bits than - *necessary (this is required by unzip applet), added inflate_cleanup() to free - *leaked bytebuffer memory (used in unzip.c), and some minor style guide - *cleanups by Ed Clark - * - * gzip (GNU zip) -- compress files with zip algorithm and 'compress' interface - *Copyright (C) 1992-1993 Jean-loup Gailly The unzip code was written and put in - *the public domain by Mark Adler. Portions of the lzw code are derived from the - *public domain 'compress' - * written by Spencer Thomas, Joe Orost, James Woods, Jim McKie, Steve Davies, - *Ken Turkowski, Dave Mack and Peter Jannesen. - * - * - * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. - */ - -#include -#ifndef NULL -#define NULL 0 -#endif -#define ENABLE_DESKTOP 0 -#define USE_DESKTOP(...) -#include "mallocer.h" -#include "bbfuncs.h" -#include "inflate.h" - -#define TRIM_FILE_ON_ERROR 1 - -typedef struct huft_s { - unsigned char e; /* number of extra bits or operation */ - unsigned char b; /* number of bits in this code or subcode */ - union { - unsigned short n; /* literal, length base, or distance base */ - struct huft_s *t; /* pointer to next level of table */ - } v; -} huft_t; - -/*static void *mainmembuf;*/ -static void *huftbuffer1; -static void *huftbuffer2; - -#define HUFT_MMP1 8 -#define HUFT_MMP2 9 - -static struct mbreader_t *gunzip_src_md; -static unsigned int gunzip_bytes_out; /* number of output bytes */ -static unsigned int gunzip_outbuf_count; /* bytes in output buffer */ - -/* gunzip_window size--must be a power of two, and at least 32K for zip's - deflate method */ -enum { - gunzip_wsize = 0x8000 -}; - -static unsigned char *gunzip_window; -static uint32_t ifl_total; - -static uint32_t gunzip_crc; - -/* If BMAX needs to be larger than 16, then h and x[] should be ulg. */ -#define BMAX 16 /* maximum bit length of any code (16 for explode) */ -#define N_MAX 288 /* maximum number of codes in any set */ - -/* bitbuffer */ -static unsigned int gunzip_bb; /* bit buffer */ -static unsigned char gunzip_bk; /* bits in bit buffer */ - -/* These control the size of the bytebuffer */ -static unsigned int bytebuffer_max = 0x8000; -static unsigned char *bytebuffer = NULL; -static unsigned int bytebuffer_offset = 0; -static unsigned int bytebuffer_size = 0; - -static const unsigned short mask_bits[] = { - 0x0000, 0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f, 0x00ff, - 0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff -}; - -/* Copy lengths for literal codes 257..285 */ -static const unsigned short cplens[] = { - 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51, 59, - 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0 -}; - -/* note: see note #13 above about the 258 in this list. */ -/* Extra bits for literal codes 257..285 */ -static const unsigned char cplext[] = { - 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, - 5, 5, 5, 0, 99, 99 -}; /* 99==invalid */ - -/* Copy offsets for distance codes 0..29 */ -static const unsigned short cpdist[] = { - 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513, - 769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577 -}; - -/* Extra bits for distance codes */ -static const unsigned char cpdext[] = { - 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, - 11, 11, 12, 12, 13, 13 -}; - -/* Tables for deflate from PKZIP's appnote.txt. */ -/* Order of the bit length code lengths */ -static const unsigned char border[] = { - 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 -}; - -static const uint32_t crc_table[256]= { - 0,1996959894,-301047508,-1727442502,124634137,1886057615, - -379345611,-1637575261,249268274,2044508324,-522852066, - -1747789432,162941995,2125561021,-407360249,-1866523247, - 498536548,1789927666,-205950648,-2067906082,450548861, - 1843258603,-187386543,-2083289657,325883990,1684777152, - -43845254,-1973040660,335633487,1661365465,-99664541, - -1928851979,997073096,1281953886,-715111964,-1570279054, - 1006888145,1258607687,-770865667,-1526024853,901097722, - 1119000684,-608450090,-1396901568,853044451,1172266101, - -589951537,-1412350631,651767980,1373503546,-925412992, - -1076862698,565507253,1454621731,-809855591,-1195530993, - 671266974,1594198024,-972236366,-1324619484,795835527, - 1483230225,-1050600021,-1234817731,1994146192,31158534, - -1731059524,-271249366,1907459465,112637215,-1614814043, - -390540237,2013776290,251722036,-1777751922,-519137256, - 2137656763,141376813,-1855689577,-429695999,1802195444, - 476864866,-2056965928,-228458418,1812370925,453092731, - -2113342271,-183516073,1706088902,314042704,-1950435094, - -54949764,1658658271,366619977,-1932296973,-69972891, - 1303535960,984961486,-1547960204,-725929758,1256170817, - 1037604311,-1529756563,-740887301,1131014506,879679996, - -1385723834,-631195440,1141124467,855842277,-1442165665, - -586318647,1342533948,654459306,-1106571248,-921952122, - 1466479909,544179635,-1184443383,-832445281,1591671054, - 702138776,-1328506846,-942167884,1504918807,783551873, - -1212326853,-1061524307,-306674912,-1698712650,62317068, - 1957810842,-355121351,-1647151185,81470997,1943803523, - -480048366,-1805370492,225274430,2053790376,-468791541, - -1828061283,167816743,2097651377,-267414716,-2029476910, - 503444072,1762050814,-144550051,-2140837941,426522225, - 1852507879,-19653770,-1982649376,282753626,1742555852, - -105259153,-1900089351,397917763,1622183637,-690576408, - -1580100738,953729732,1340076626,-776247311,-1497606297, - 1068828381,1219638859,-670225446,-1358292148,906185462, - 1090812512,-547295293,-1469587627,829329135,1181335161, - -882789492,-1134132454,628085408,1382605366,-871598187, - -1156888829,570562233,1426400815,-977650754,-1296233688, - 733239954,1555261956,-1026031705,-1244606671,752459403, - 1541320221,-1687895376,-328994266,1969922972,40735498, - -1677130071,-351390145,1913087877,83908371,-1782625662, - -491226604,2075208622,213261112,-1831694693,-438977011, - 2094854071,198958881,-2032938284,-237706686,1759359992, - 534414190,-2118248755,-155638181,1873836001,414664567, - -2012718362,-15766928,1711684554,285281116,-1889165569, - -127750551,1634467795,376229701,-1609899400,-686959890, - 1308918612,956543938,-1486412191,-799009033,1231636301, - 1047427035,-1362007478,-640263460,1088359270,936918000, - -1447252397,-558129467,1202900863,817233897,-1111625188, - -893730166,1404277552,615818150,-1160759803,-841546093, - 1423857449,601450431,-1285129682,-1000256840,1567103746, - 711928724,-1274298825,-1022587231,1510334235,755167117 -}; - -static unsigned int fill_bitbuffer(unsigned int bitbuffer, unsigned int *current, - const unsigned int required) -{ - while (*current < required) - { - if (bytebuffer_offset >= bytebuffer_size) - { - /* Leave the first 4 bytes empty so we can always unwind the - bitbuffer to the front of the bytebuffer, leave 4 bytes free at - end of tail so we can easily top up buffer in - check_trailer_gzip() */ - if (1 > (bytebuffer_size = safe_read(gunzip_src_md, &bytebuffer[4], - bytebuffer_max - 8))) - error_die("unexpected end of file"); - - bytebuffer_size += 4; - bytebuffer_offset = 4; - } - - bitbuffer |= ((unsigned int) bytebuffer[bytebuffer_offset]) << *current; - bytebuffer_offset++; - *current += 8; - } - return(bitbuffer); -} - -/* - * Free the malloc'ed tables built by huft_build(), which makes a linked list of - *the tables it made, with the links in a dummy first entry of each table. - * t: table to free - */ -static int huft_free(huft_t * t,unsigned char bufnum) -{ - wpw_reset_mempool(bufnum); - if(t==0) - { - } - - return 0; -} - -/* Given a list of code lengths and a maximum table size, make a set of tables - to decode that set of codes. Return zero on success, one if the given code - set is incomplete (the tables are still built in this case), two if the input - is invalid (all zero length codes or an oversubscribed set of lengths), and - three if not enough memory. - * - * b: code lengths in bits (all assumed <= BMAX) n: number of codes - *(assumed <= N_MAX) s: number of simple-valued codes (0..s-1) d: list of - *base values for non-simple codes e: list of extra bits for non-simple codes - *t: result: starting table m: maximum lookup bits, returns actual bufnum: - *the number of the memory pool to fetch memory from - */ -static -int huft_build(unsigned int *b, const unsigned int n, - const unsigned int s, const unsigned short *d, - const unsigned char *e, huft_t ** t, unsigned int *m, - unsigned char bufnum) -{ - unsigned a=0; /* counter for codes of length k */ - unsigned c[BMAX + 1]; /* bit length count table */ - unsigned eob_len=0; /* length of end-of-block code (value 256) */ - unsigned f=0; /* i repeats in table every f entries */ - int g=0; /* maximum code length */ - int htl=0; /* table level */ - unsigned i=0; /* counter, current code */ - unsigned j=0; /* counter */ - int k=0; /* number of bits in current code */ - unsigned *p; /* pointer into c[], b[], or v[] */ - huft_t *q; /* points to current table */ - huft_t r; /* table entry for structure assignment */ - huft_t *u[BMAX]; /* table stack */ - unsigned v[N_MAX]; /* values in order of bit length */ - int ws[BMAX+1]; /* bits decoded stack */ - int w=0; /* bits decoded */ - unsigned x[BMAX + 1]; /* bit offsets, then code stack */ - unsigned *xp; /* pointer into x */ - int y=0; /* number of dummy codes added */ - unsigned z=0; /* number of entries in current table */ - - /* Length of EOB code, if any */ - eob_len = n > 256 ? b[256] : BMAX; - - /* Generate counts for each bit length */ - memset((void *)c, 0, sizeof(c)); - p = b; - i = n; - do { - c[*p]++; /* assume all entries <= BMAX */ - p++; /* Can't combine with above line (Solaris bug) */ - } while (--i); - if (c[0] == n) /* null input--all zero length codes */ - { - *t = (huft_t *) NULL; - *m = 0; - return 2; - } - - /* Find minimum and maximum length, bound *m by those */ - for (j = 1; (c[j] == 0) && (j <= BMAX); j++) ; - - k = j; /* minimum code length */ - for (i = BMAX; (c[i] == 0) && i; i--) ; - - g = i; /* maximum code length */ - *m = (*m < j) ? j : ((*m > i) ? i : *m); - - /* Adjust last length count to fill out codes, if needed */ - for (y = 1 << j; j < i; j++, y <<= 1) - { - if ((y -= c[j]) < 0) - return 2; /* bad input: more codes than bits */ - } - - if ((y -= c[i]) < 0) - return 2; - - c[i] += y; - - /* Generate starting offsets into the value table for each length */ - x[1] = j = 0; - p = c + 1; - xp = x + 2; - while (--i) /* note that i == g from above */ - { - *xp++ = (j += *p++); - } - - /* Make a table of values in order of bit lengths */ - p = b; - i = 0; - do { - if ((j = *p++) != 0) - v[x[j]++] = i; - } while (++i < n); - - /* Generate the Huffman codes and for each, make the table entries */ - x[0] = i = 0; /* first Huffman code is zero */ - p = v; /* grab values in bit order */ - htl = -1; /* no tables yet--level -1 */ - w = ws[0] = 0; /* bits decoded */ - u[0] = (huft_t *) NULL; /* just to keep compilers happy */ - q = (huft_t *) NULL; /* ditto */ - z = 0; /* ditto */ - - /* go through the bit lengths (k already is bits in shortest code) */ - for (; k <= g; k++) - { - a = c[k]; - while (a--) - { - /* here i is the Huffman code of length k bits for value *p */ - /* make tables up to required level */ - while (k > ws[htl + 1]) - { - w = ws[++htl]; - - /* compute minimum size table less than or equal to *m bits */ - z = (z = g - w) > *m ? *m : z; /* upper limit on table size */ - if ((f = 1 << (j = k - w)) > a + 1) /* try a k-w bit table */ - { /* too few codes for k-w bit table */ - f -= a + 1; /* deduct codes from patterns left */ - xp = c + k; - while (++j < z) /* try smaller tables up to z bits */ - { - if ((f <<= 1) <= *++xp) - break; /* enough codes to use up j bits */ - - f -= *xp; /* else deduct codes from patterns */ - } - } - - j = ((unsigned)(w + j) > eob_len && (unsigned)w < eob_len) - ? eob_len - w : j; /* make EOB code end at table */ - z = 1 << j; /* table entries for j-bit table */ - ws[htl+1] = w + j; /* set bits decoded in stack */ - - /* allocate and link in new table */ - q = (huft_t *) wpw_malloc(bufnum,(z + 1) * sizeof(huft_t)); - if(q==0) - return 3; - - *t = q + 1; /* link to list for huft_free() */ - t = &(q->v.t); - u[htl] = ++q; /* table starts after link */ - - /* connect to last table, if there is one */ - if (htl) - { - x[htl] = i; /* save pattern for backing up */ - - /* bits to dump before this table */ - r.b = (unsigned char) (w - ws[htl - 1]); - r.e = (unsigned char) (16 + j); /* bits in this table */ - r.v.t = q; /* pointer to this table */ - j = (i & ((1 << w) - 1)) >> ws[htl - 1]; - u[htl - 1][j] = r; /* connect to last table */ - } - } - - /* set up table entry in r */ - r.b = (unsigned char) (k - w); - if (p >= v + n) - r.e = 99; /* out of values--invalid code */ - else if (*p < s) - { - r.e = (unsigned char) (*p < 256 ? 16 : 15); /* 256 is EOB - code */ - r.v.n = (unsigned short) (*p++); /* simple code is just the - value */ - } - else - { - r.e = (unsigned char) e[*p - s]; /* non-simple--look up in lists - */ - r.v.n = d[*p++ - s]; - } - - /* fill code-like entries with r */ - f = 1 << (k - w); - for (j = i >> w; j < z; j += f) - { - q[j] = r; - } - - /* backwards increment the k-bit code i */ - for (j = 1 << (k - 1); i &j; j >>= 1) - { - i ^= j; - } - i ^= j; - - /* backup over finished tables */ - while ((i & ((1 << w) - 1)) != x[htl]) - { - w = ws[--htl]; - } - } - } - - /* return actual size of base table */ - *m = ws[1]; - - /* Return true (1) if we were given an incomplete table */ - return y != 0 && g != 1; -} - -/* - * inflate (decompress) the codes in a deflated (compressed) block. Return an - *error code or zero if it all goes ok. - * - * tl, td: literal/length and distance decoder tables bl, bd: number of bits - *decoded by tl[] and td[] - */ -static int inflate_codes_resumeCopy = 0; -static int inflate_codes(huft_t * my_tl, huft_t * my_td, - const unsigned int my_bl, const unsigned int my_bd, - int setup) -{ - static unsigned int e; /* table entry flag/number of extra bits */ - static unsigned int n, d; /* length and index for copy */ - static unsigned int w; /* current gunzip_window position */ - static huft_t *t; /* pointer to table entry */ - static unsigned int ml, md; /* masks for bl and bd bits */ - static unsigned int b; /* bit buffer */ - static unsigned int k; /* number of bits in bit buffer */ - static huft_t *tl, *td; - static unsigned int bl, bd; - - if (setup) /* 1st time we are called, copy in variables */ - { - tl = my_tl; - td = my_td; - bl = my_bl; - bd = my_bd; - /* make local copies of globals */ - b = gunzip_bb; /* initialize bit buffer */ - k = gunzip_bk; - w = gunzip_outbuf_count; /* initialize gunzip_window position - */ - - /* inflate the coded data */ - ml = mask_bits[bl]; /* precompute masks for speed */ - md = mask_bits[bd]; - return 0; /* Don't actually do anything the first time */ - } - - if (inflate_codes_resumeCopy) goto do_copy; - - while (1) /* do until end of block */ - { - b = fill_bitbuffer(b, &k, bl); - if ((e = (t = tl + ((unsigned) b & ml))->e) > 16) - do { - if (e == 99) - error_die("inflate_codes error 1"); - - b >>= t->b; - k -= t->b; - e -= 16; - b = fill_bitbuffer(b, &k, e); - } while ((e = - (t = t->v.t + ((unsigned) b & mask_bits[e]))->e) > 16); - - b >>= t->b; - k -= t->b; - if (e == 16) /* then it's a literal */ - { - gunzip_window[w++] = (unsigned char) t->v.n; - if (w == gunzip_wsize) - { - gunzip_outbuf_count = (w); - w = 0; - return 1; /* We have a block to read */ - } - } - else /* it's an EOB or a length */ - { /* exit if end of block */ - if (e == 15) - break; - - /* get length of block to copy */ - b = fill_bitbuffer(b, &k, e); - n = t->v.n + ((unsigned) b & mask_bits[e]); - b >>= e; - k -= e; - - /* decode distance of block to copy */ - b = fill_bitbuffer(b, &k, bd); - if ((e = (t = td + ((unsigned) b & md))->e) > 16) - do { - if (e == 99) - error_die("inflate_codes error 2"); - - b >>= t->b; - k -= t->b; - e -= 16; - b = fill_bitbuffer(b, &k, e); - } while ((e = - (t = - t->v.t + ((unsigned) b & mask_bits[e]))->e) > 16); - - b >>= t->b; - k -= t->b; - b = fill_bitbuffer(b, &k, e); - d = w - t->v.n - ((unsigned) b & mask_bits[e]); - b >>= e; - k -= e; - - /* do the copy */ -do_copy: do { - n -= (e = - (e = - gunzip_wsize - ((d &= gunzip_wsize - 1) > w ? d : w)) > n ? n : e); - /* copy to new buffer to prevent possible overwrite */ - if (w - d >= e) /* (this test assumes unsigned comparison) - */ - { - memcpy(gunzip_window + w, gunzip_window + d, e); - w += e; - d += e; - } - else - { - /* do it slow to avoid memcpy() overlap */ - /* !NOMEMCPY */ - do { - gunzip_window[w++] = gunzip_window[d++]; - } while (--e); - } - - if (w == gunzip_wsize) - { - gunzip_outbuf_count = (w); - if (n) inflate_codes_resumeCopy = 1; - else inflate_codes_resumeCopy = 0; - - w = 0; - return 1; - } - } while (n); - inflate_codes_resumeCopy = 0; - } - } - - /* restore the globals from the locals */ - gunzip_outbuf_count = w; /* restore global gunzip_window pointer */ - gunzip_bb = b; /* restore global bit buffer */ - gunzip_bk = k; - - /* normally just after call to inflate_codes, but save code by putting it - here */ - /* free the decoding tables, return */ - huft_free(tl,HUFT_MMP1); - huft_free(td,HUFT_MMP2); - - /* done */ - return 0; -} - -static int inflate_stored(int my_n, int my_b_stored, int my_k_stored, int setup) -{ - static unsigned int n, b_stored, k_stored, w; - if (setup) - { - n = my_n; - b_stored = my_b_stored; - k_stored = my_k_stored; - w = gunzip_outbuf_count; /* initialize gunzip_window position */ - return 0; /* Don't do anything first time */ - } - - /* read and output the compressed data */ - while (n--) - { - b_stored = fill_bitbuffer(b_stored, &k_stored, 8); - gunzip_window[w++] = (unsigned char) b_stored; - if (w == gunzip_wsize) - { - gunzip_outbuf_count = (w); - w = 0; - b_stored >>= 8; - k_stored -= 8; - return 1; /* We have a block */ - } - - b_stored >>= 8; - k_stored -= 8; - } - - /* restore the globals from the locals */ - gunzip_outbuf_count = w; /* restore global gunzip_window pointer */ - gunzip_bb = b_stored; /* restore global bit buffer */ - gunzip_bk = k_stored; - return 0; /* Finished */ -} - -/* - * decompress an inflated block e: last block flag - * - * GLOBAL VARIABLES: bb, kk, - */ -/* Return values: -1 = inflate_stored, -2 = inflate_codes */ -static int inflate_block(int *e) -{ - unsigned t; /* block type */ - unsigned int b; /* bit buffer */ - unsigned int k; /* number of bits in bit buffer */ - - /* make local bit buffer */ - - b = gunzip_bb; - k = gunzip_bk; - - /* read in last block bit */ - b = fill_bitbuffer(b, &k, 1); - *e = (int) b & 1; - b >>= 1; - k -= 1; - - /* read in block type */ - b = fill_bitbuffer(b, &k, 2); - t = (unsigned) b & 3; - b >>= 2; - k -= 2; - - /* restore the global bit buffer */ - gunzip_bb = b; - gunzip_bk = k; - - /* inflate that block type */ - switch (t) - { - case 0: /* Inflate stored */ - { - unsigned int n=0; /* number of bytes in block */ - - /* make local copies of globals */ - unsigned int b_stored=gunzip_bb; /* bit buffer */ - unsigned int k_stored=gunzip_bk; /* number of bits in bit buffer */ - - /* go to byte boundary */ - n = k_stored & 7; - b_stored >>= n; - k_stored -= n; - - /* get the length and its complement */ - b_stored = fill_bitbuffer(b_stored, &k_stored, 16); - n = ((unsigned) b_stored & 0xffff); - b_stored >>= 16; - k_stored -= 16; - - b_stored = fill_bitbuffer(b_stored, &k_stored, 16); - if (n != (unsigned) ((~b_stored) & 0xffff)) - return 1; /* error in compressed data */ - - b_stored >>= 16; - k_stored -= 16; - - inflate_stored(n, b_stored, k_stored, 1); /* Setup inflate_stored */ - return -1; - } - case 1: /* Inflate fixed decompress an inflated type 1 (fixed - Huffman codes) block. We should either replace this - with a custom decoder, or at least precompute the - Huffman tables. - */ - { - int i; /* temporary variable */ - huft_t *tl; /* literal/length code table */ - huft_t *td; /* distance code table */ - unsigned int bl; /* lookup bits for tl */ - unsigned int bd; /* lookup bits for td */ - unsigned int l[288]; /* length list for huft_build */ - - /* set up literal table */ - for (i = 0; i < 144; i++) - { - l[i] = 8; - } - for (; i < 256; i++) - { - l[i] = 9; - } - for (; i < 280; i++) - { - l[i] = 7; - } - for (; i < 288; i++) /* make a complete, but wrong code set */ - { - l[i] = 8; - } - bl = 7; - if ((i = huft_build(l, 288, 257, cplens, cplext, &tl, &bl,HUFT_MMP1)) != 0) - return i; - - /* set up distance table */ - for (i = 0; i < 30; i++) /* make an incomplete code set */ - { - l[i] = 5; - } - bd = 5; - if ((i = huft_build(l, 30, 0, cpdist, cpdext, &td, &bd,HUFT_MMP2)) > 1) - { - huft_free(tl,HUFT_MMP1); - return i; - } - - /* decompress until an end-of-block code */ - inflate_codes(tl, td, bl, bd, 1); /* Setup inflate_codes */ - - /* huft_free code moved into inflate_codes */ - - return -2; - } - case 2: /* Inflate dynamic */ - { - const int dbits = 6; /* bits in base distance lookup table */ - const int lbits = 9; /* bits in base literal/length lookup table */ - - huft_t *tl; /* literal/length code table */ - huft_t *td; /* distance code table */ - unsigned int i; /* temporary variables */ - unsigned int j; - unsigned int l; /* last length */ - unsigned int m; /* mask for bit lengths table */ - unsigned int n; /* number of lengths to get */ - unsigned int bl; /* lookup bits for tl */ - unsigned int bd; /* lookup bits for td */ - unsigned int nb; /* number of bit length codes */ - unsigned int nl; /* number of literal/length codes */ - unsigned int nd; /* number of distance codes */ - - unsigned int ll[286 + 30]; /* literal/length and distance code - lengths */ - unsigned int b_dynamic; /* bit buffer */ - unsigned int k_dynamic; /* number of bits in bit buffer */ - - /* make local bit buffer */ - b_dynamic = gunzip_bb; - k_dynamic = gunzip_bk; - - /* read in table lengths */ - b_dynamic = fill_bitbuffer(b_dynamic, &k_dynamic, 5); - nl = 257 + ((unsigned int) b_dynamic & 0x1f); /* number of - literal/length codes - */ - - b_dynamic >>= 5; - k_dynamic -= 5; - b_dynamic = fill_bitbuffer(b_dynamic, &k_dynamic, 5); - nd = 1 + ((unsigned int) b_dynamic & 0x1f); /* number of distance - codes */ - - b_dynamic >>= 5; - k_dynamic -= 5; - b_dynamic = fill_bitbuffer(b_dynamic, &k_dynamic, 4); - nb = 4 + ((unsigned int) b_dynamic & 0xf); /* number of bit length - codes */ - - b_dynamic >>= 4; - k_dynamic -= 4; - if (nl > 286 || nd > 30) - return 1; /* bad lengths */ - - /* read in bit-length-code lengths */ - for (j = 0; j < nb; j++) - { - b_dynamic = fill_bitbuffer(b_dynamic, &k_dynamic, 3); - ll[border[j]] = (unsigned int) b_dynamic & 7; - b_dynamic >>= 3; - k_dynamic -= 3; - } - for (; j < 19; j++) - { - ll[border[j]] = 0; - } - - /* build decoding table for trees--single level, 7 bit lookup */ - bl = 7; - i = huft_build(ll, 19, 19, NULL, NULL, &tl, &bl,HUFT_MMP1); - if (i != 0) - { - if (i == 1) - huft_free(tl,HUFT_MMP1); - - return i; /* incomplete code set */ - } - - /* read in literal and distance code lengths */ - n = nl + nd; - m = mask_bits[bl]; - i = l = 0; - while ((unsigned int) i < n) - { - b_dynamic = fill_bitbuffer(b_dynamic, &k_dynamic, (unsigned int)bl); - j = (td = tl + ((unsigned int) b_dynamic & m))->b; - b_dynamic >>= j; - k_dynamic -= j; - j = td->v.n; - if (j < 16) /* length of code in bits (0..15) */ - ll[i++] = l = j; /* save last length in l */ - else if (j == 16) /* repeat last length 3 to 6 times */ - { - b_dynamic = fill_bitbuffer(b_dynamic, &k_dynamic, 2); - j = 3 + ((unsigned int) b_dynamic & 3); - b_dynamic >>= 2; - k_dynamic -= 2; - if ((unsigned int) i + j > n) - return 1; - - while (j--) - { - ll[i++] = l; - } - } - else if (j == 17) /* 3 to 10 zero length codes */ - { - b_dynamic = fill_bitbuffer(b_dynamic, &k_dynamic, 3); - j = 3 + ((unsigned int) b_dynamic & 7); - b_dynamic >>= 3; - k_dynamic -= 3; - if ((unsigned int) i + j > n) - return 1; - - while (j--) - { - ll[i++] = 0; - } - l = 0; - } - else /* j == 18: 11 to 138 zero length codes */ - { - b_dynamic = fill_bitbuffer(b_dynamic, &k_dynamic, 7); - j = 11 + ((unsigned int) b_dynamic & 0x7f); - b_dynamic >>= 7; - k_dynamic -= 7; - if ((unsigned int) i + j > n) - return 1; - - while (j--) - { - ll[i++] = 0; - } - l = 0; - } - } - - /* free decoding table for trees */ - huft_free(tl,HUFT_MMP1); - - /* restore the global bit buffer */ - gunzip_bb = b_dynamic; - gunzip_bk = k_dynamic; - - /* build the decoding tables for literal/length and distance codes */ - bl = lbits; - - if ((i = huft_build(ll, nl, 257, cplens, cplext, &tl, &bl,HUFT_MMP1)) != 0) - { - if (i == 1) - { - error_die("Incomplete literal tree"); - huft_free(tl,HUFT_MMP1); - } - - return i; /* incomplete code set */ - } - - bd = dbits; - if ((i = huft_build(ll + nl, nd, 0, cpdist, cpdext, &td, &bd,HUFT_MMP2)) != 0) - { - if (i == 1) - { - error_die("incomplete distance tree"); - huft_free(td,HUFT_MMP2); - } - - huft_free(tl,HUFT_MMP1); - return i; /* incomplete code set */ - } - - /* decompress until an end-of-block code */ - inflate_codes(tl, td, bl, bd, 1); /* Setup inflate_codes */ - - /* huft_free code moved into inflate_codes */ - - return -2; - } - default: - /* bad block type */ - error_die("bad block type"); - } - return 0; -} - -static void calculate_gunzip_crc(void) -{ - unsigned int n; - for (n = 0; n < gunzip_outbuf_count; n++) - { - gunzip_crc = crc_table[((int) gunzip_crc ^ (gunzip_window[n])) & 0xff] - ^ (gunzip_crc >> 8); - } - gunzip_bytes_out += gunzip_outbuf_count; -} - -static int inflate_get_next_window_method = -1; /* Method == -1 for stored, -2 - for codes */ -static int inflate_get_next_window_e = 0; -static int inflate_get_next_window_needAnotherBlock = 1; - -static int inflate_get_next_window(void) -{ - gunzip_outbuf_count = 0; - - while(1) - { - int ret=0; - if (inflate_get_next_window_needAnotherBlock) - { - if(inflate_get_next_window_e) - { - calculate_gunzip_crc(); - inflate_get_next_window_e = 0; - inflate_get_next_window_needAnotherBlock = 1; - return 0; - } /* Last block */ - - inflate_get_next_window_method = inflate_block(&inflate_get_next_window_e); - inflate_get_next_window_needAnotherBlock = 0; - } - - switch (inflate_get_next_window_method) - { - case -1: ret = inflate_stored(0,0,0,0); - break; - case -2: ret = inflate_codes(0,0,0,0,0); - break; - default: - error_die("inflate error"); - } - - if (ret == 1) - { - calculate_gunzip_crc(); - return 1; /* More data left */ - } - else inflate_get_next_window_needAnotherBlock = 1; /* End of that - block */ - } - /* Doesnt get here */ -} - -/* Initialise bytebuffer, be careful not to overfill the buffer */ -static void inflate_init(unsigned int bufsize) -{ - /* Set the bytebuffer size, default is same as gunzip_wsize */ - bytebuffer_max = bufsize + 8; - bytebuffer_offset = 4; - bytebuffer_size = 0; -} - -static void inflate_cleanup(void) -{ - /* free(bytebuffer); */ -} - -USE_DESKTOP(long long) static int -inflate_unzip(struct mbreader_t *in,char* outbuffer,uint32_t outbuflen) -{ - USE_DESKTOP(long long total = 0; ) - typedef void (*sig_type)(int); - - /* Allocate all global buffers (for DYN_ALLOC option) */ - gunzip_outbuf_count = 0; - gunzip_bytes_out = 0; - gunzip_src_md = in; - - /* initialize gunzip_window, bit buffer */ - gunzip_bk = 0; - gunzip_bb = 0; - - /* Create the crc table */ - gunzip_crc = ~0; - - /* Allocate space for buffer */ - while(1) - { - int ret = inflate_get_next_window(); - if((signed int)outbuflen-(signed int)gunzip_outbuf_count<0) - { - error_msg("write_error"); - #ifdef TRIM_FILE_ON_ERROR - return USE_DESKTOP(total) + 0; - #else - return -1; - #endif - } - - memcpy(outbuffer,gunzip_window,gunzip_outbuf_count); - outbuffer+=sizeof(char)*gunzip_outbuf_count; - ifl_total+=sizeof(char)*gunzip_outbuf_count; - outbuflen-=gunzip_outbuf_count; - USE_DESKTOP(total += gunzip_outbuf_count; ) - if (ret == 0) break; - } - - /* Store unused bytes in a global buffer so calling applets can access it */ - if (gunzip_bk >= 8) - { - /* Undo too much lookahead. The next read will be byte aligned so we can - discard unused bits in the last meaningful byte. */ - bytebuffer_offset--; - bytebuffer[bytebuffer_offset] = gunzip_bb & 0xff; - gunzip_bb >>= 8; - gunzip_bk -= 8; - } - - return USE_DESKTOP(total) + 0; -} - -USE_DESKTOP(long long) static int -inflate_gunzip(struct mbreader_t *in,char* outbuffer,uint32_t outbuflen) -{ - uint32_t stored_crc = 0; - unsigned int count; - USE_DESKTOP(long long total = ) inflate_unzip(in, outbuffer,outbuflen); - - USE_DESKTOP(if (total < 0) return total; - - ) - - /* top up the input buffer with the rest of the trailer */ - count = bytebuffer_size - bytebuffer_offset; - if (count < 8) - { - xread(in, &bytebuffer[bytebuffer_size], 8 - count); - bytebuffer_size += 8 - count; - } - - for (count = 0; count != 4; count++) - { - stored_crc |= (bytebuffer[bytebuffer_offset] << (count * 8)); - bytebuffer_offset++; - } - - /* Validate decompression - crc */ - if (stored_crc != (~gunzip_crc)) - { - error_msg("crc error"); - - #ifdef TRIM_FILE_ON_ERROR - return USE_DESKTOP(total) + 0; - #else - return -1; - #endif - } - - /* Validate decompression - size */ - if ((signed int)gunzip_bytes_out != - (bytebuffer[bytebuffer_offset] | (bytebuffer[bytebuffer_offset+1] << 8) | - (bytebuffer[bytebuffer_offset+2] << 16) | (bytebuffer[bytebuffer_offset+3] << 24))) - { - error_msg("incorrect length"); - return -1; - } - - return USE_DESKTOP(total) + 0; -} - -/*An allocated memory buffer at least 0x13100 (72448) bytes long*/ -uint32_t decompress(const char *inbuffer,uint32_t inbuflen,char* outbuffer,uint32_t outbuflen,uint32_t offset,char* membuf) -{ - signed char status=0; - int exitcode=0; - struct mbreader_t src_md; - ifl_total=0; - /* reset statics */ - inflate_codes_resumeCopy = 0; - inflate_get_next_window_method = -1; /* Method == -1 for stored, -2 for - codes */ - inflate_get_next_window_e = 0; - inflate_get_next_window_needAnotherBlock = 1; - /* init */ - inflate_init(0x8000-8); - /*Memory init*/ - huftbuffer1=membuf; - huftbuffer2=membuf+0x2A00; - gunzip_window=membuf+0x2A00+0xA00; - bytebuffer=membuf+0x2A00+0xA00+0x8000; - wpw_init_mempool_pdm(HUFT_MMP1,(unsigned char*)huftbuffer1,0x2A00); - wpw_init_mempool_pdm(HUFT_MMP2,(unsigned char*)huftbuffer2,0xA00); - - /* Initialize memory buffer reader */ - src_md.ptr = inbuffer; - src_md.size = inbuflen; - src_md.offset = offset; - - if ((exitcode=xread_char(&src_md)) == 0x1f) - { - unsigned char magic2; - magic2 = xread_char(&src_md); - if (magic2 == 0x8b) - { - check_header_gzip(&src_md); /* FIXME: xfunc? _or_die? */ - status = inflate_gunzip(&src_md, outbuffer,outbuflen); - } - else - { - error_msg("invalid magic"); - exitcode = -1; - } - - if (status < 0) - { - error_msg("error inflating"); - exitcode = -1; - } - } - else - { - error_msg("invalid magic"); - exitcode = -1; - } - - inflate_cleanup(); - wpw_destroy_mempool(HUFT_MMP1); - wpw_destroy_mempool(HUFT_MMP2); - - if(exitcode==-1) - return 0; - - return ifl_total; -} diff --git a/apps/codecs/libgme/inflate/inflate.h b/apps/codecs/libgme/inflate/inflate.h deleted file mode 100644 index 05164621b9..0000000000 --- a/apps/codecs/libgme/inflate/inflate.h +++ /dev/null @@ -1,30 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ - -#ifndef INFLATE_H -#define INFLATE_H -#include - -#if defined(ROCKBOX) -#include "codeclib.h" -#endif - -uint32_t decompress(const char *inbuffer,uint32_t inbuflen,char* outbuffer,uint32_t outbuflen, - uint32_t offset,char* membuf); -#endif diff --git a/apps/codecs/libgme/inflate/mallocer.c b/apps/codecs/libgme/inflate/mallocer.c deleted file mode 100644 index 41abedd09f..0000000000 --- a/apps/codecs/libgme/inflate/mallocer.c +++ /dev/null @@ -1,86 +0,0 @@ - -/* - Based on the wiki viewer mallocer - Copyright (C) 2005 Dave Chapman - - @ Modified to decompress memory buffer by gama - */ - -#include "mallocer.h" -#include "codeclib.h" - -unsigned char* mallocbuffer[MEMPOOL_MAX]; -long memory_ptr[MEMPOOL_MAX]; -size_t buffersize[MEMPOOL_MAX]; - -int wpw_init_mempool(unsigned char mempool) -{ - memory_ptr[mempool] = 0; - mallocbuffer[mempool] = (unsigned char *)ci->codec_get_buffer(&buffersize[mempool]); - // memset(mallocbuf[mempool], 0, bufsize[mempool]); - return 0; -} - -int wpw_init_mempool_pdm(unsigned char mempool, - unsigned char* mem,long memsize) -{ - memory_ptr[mempool] = 0; - mallocbuffer[mempool] = mem; - buffersize[mempool]=memsize; - return 0; -} - -void wpw_reset_mempool(unsigned char mempool) -{ - memory_ptr[mempool]=0; -} - -void wpw_destroy_mempool(unsigned char mempool) -{ - memory_ptr[mempool] = 0; - mallocbuffer[mempool] =0; - buffersize[mempool]=0; -} - -long wpw_available(unsigned char mempool) -{ - return buffersize[mempool]-memory_ptr[mempool]; -} - -void* wpw_malloc(unsigned char mempool,size_t size) -{ - void* x; - - if (memory_ptr[mempool] + size > buffersize[mempool] ) - return NULL; - - x=&mallocbuffer[mempool][memory_ptr[mempool]]; - memory_ptr[mempool]+=(size+3)&~3; /* Keep memory 32-bit aligned */ - - return(x); -} - -void* wpw_calloc(unsigned char mempool,size_t nmemb, size_t size) -{ - void* x; - x = wpw_malloc(mempool,nmemb*size); - if (x == NULL) - return NULL; - - memset(x,0,nmemb*size); - return(x); -} - -void wpw_free(unsigned char mempool,void* ptr) -{ - (void)ptr; - (void)mempool; -} - -void* wpw_realloc(unsigned char mempool,void* ptr, size_t size) -{ - void* x; - (void)ptr; - x = wpw_malloc(mempool,size); - return(x); -} diff --git a/apps/codecs/libgme/inflate/mallocer.h b/apps/codecs/libgme/inflate/mallocer.h deleted file mode 100644 index 091643443c..0000000000 --- a/apps/codecs/libgme/inflate/mallocer.h +++ /dev/null @@ -1,16 +0,0 @@ - -#define MEMPOOL_MAX 10 -#include -#include - -int wpw_init_mempool(unsigned char mempool); -int wpw_init_mempool_pdm(unsigned char mempool, - unsigned char* mem,long memsize); - -void wpw_reset_mempool(unsigned char mempool); -void wpw_destroy_mempool(unsigned char mempool); -void* wpw_malloc(unsigned char mempool,size_t size); -void* wpw_calloc(unsigned char mempool,size_t nmemb, size_t size); -void wpw_free(unsigned char mempool,void* ptr); -void* wpw_realloc(unsigned char mempool,void* ptr, size_t size); -long wpw_available(unsigned char mempool); diff --git a/apps/codecs/libgme/inflate/mbreader.c b/apps/codecs/libgme/inflate/mbreader.c deleted file mode 100644 index 825787927c..0000000000 --- a/apps/codecs/libgme/inflate/mbreader.c +++ /dev/null @@ -1,16 +0,0 @@ - -/* Memory buffer reader, simulates file read - @ gama -*/ - -#include "mbreader.h" - -int mbread(struct mbreader_t *md, void *buf, size_t n) -{ - if (!md) return -1; - size_t read_bytes = (md->offset+n) > md->size ? - md->size-md->offset : n; - memcpy(buf,md->ptr + md->offset,read_bytes); - md->offset += read_bytes; - return read_bytes; -} diff --git a/apps/codecs/libgme/inflate/mbreader.h b/apps/codecs/libgme/inflate/mbreader.h deleted file mode 100644 index d345c0c424..0000000000 --- a/apps/codecs/libgme/inflate/mbreader.h +++ /dev/null @@ -1,15 +0,0 @@ - -#ifndef MBREADER_H -#define MBREADER_H - -#include "codeclib.h" - -struct mbreader_t { - const char *ptr; - size_t size; - size_t offset; -}; - -int mbread(struct mbreader_t *md, void *buf, size_t n); - -#endif diff --git a/apps/codecs/libgme/kss_cpu.c b/apps/codecs/libgme/kss_cpu.c deleted file mode 100644 index 20601e608f..0000000000 --- a/apps/codecs/libgme/kss_cpu.c +++ /dev/null @@ -1,35 +0,0 @@ -// Game_Music_Emu 0.6-pre. http://www.slack.net/~ant/ - -#include "kss_emu.h" - -#include "blargg_endian.h" -//#include "z80_cpu_log.h" - -/* Copyright (C) 2006-2008 Shay Green. This module is free software; you -can redistribute it and/or modify it under the terms of the GNU Lesser -General Public License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. This -module is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more -details. You should have received a copy of the GNU Lesser General Public -License along with this module; if not, write to the Free Software Foundation, -Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ - -#include "blargg_source.h" - -#define OUT_PORT( addr, data ) cpu_out( this, TIME(), addr, data ) -#define IN_PORT( addr ) cpu_in( this, TIME(), addr ) -#define WRITE_MEM( addr, data ) {FLUSH_TIME(); cpu_write( this, addr, data );} -#define IDLE_ADDR idle_addr - -#define CPU_BEGIN \ -bool run_cpu( struct Kss_Emu* this, kss_time_t end_time )\ -{\ - struct Z80_Cpu *cpu = &this->cpu; \ - Z80_set_end_time( cpu, end_time ); - - #include "z80_cpu_run.h" - - return warning; -} diff --git a/apps/codecs/libgme/kss_emu.c b/apps/codecs/libgme/kss_emu.c deleted file mode 100644 index ba80ef613e..0000000000 --- a/apps/codecs/libgme/kss_emu.c +++ /dev/null @@ -1,714 +0,0 @@ -// Game_Music_Emu 0.6-pre. http://www.slack.net/~ant/ - -#include "kss_emu.h" - -#include "blargg_endian.h" - -/* Copyright (C) 2006 Shay Green. This module is free software; you -can redistribute it and/or modify it under the terms of the GNU Lesser -General Public License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. This -module is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more -details. You should have received a copy of the GNU Lesser General Public -License along with this module; if not, write to the Free Software Foundation, -Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ - -#include "blargg_source.h" - -int const clock_rate = 3579545; - -const char gme_wrong_file_type [] = "Wrong file type for this emulator"; - -static void clear_track_vars( struct Kss_Emu* this ) -{ - this->current_track = -1; - track_stop( &this->track_filter ); -} - -static blargg_err_t init_opl_apu( enum opl_type_t type, struct Opl_Apu* out ) -{ - blip_time_t const period = 72; - int const rate = clock_rate / period; - return Opl_init( out, rate * period, rate, period, type ); -} - -void Kss_init( struct Kss_Emu* this ) -{ - this->sample_rate = 0; - this->mute_mask_ = 0; - this->tempo = (int)(FP_ONE_TEMPO); - this->gain = (int)FP_ONE_GAIN; - this->chip_flags = 0; - - // defaults - this->tfilter = *track_get_setup( &this->track_filter ); - this->tfilter.max_initial = 2; - this->tfilter.lookahead = 6; - this->track_filter.silence_ignored_ = false; - - memset( this->unmapped_read, 0xFF, sizeof this->unmapped_read ); - - // Init all stuff - Buffer_init( &this->stereo_buf ); - - Z80_init( &this->cpu ); - Rom_init( &this->rom, page_size ); - - // Initialize all apus just once (?) - Sms_apu_init( &this->sms.psg); - Ay_apu_init( &this->msx.psg ); - Scc_init( &this->msx.scc ); - -#ifndef KSS_EMU_NO_FMOPL - init_opl_apu( type_smsfmunit, &this->sms.fm ); - init_opl_apu( type_msxmusic, &this->msx.music ); - init_opl_apu( type_msxaudio, &this->msx.audio ); -#endif - - this->voice_count = 0; - this->voice_types = 0; - clear_track_vars( this ); -} - -// Track info - -static blargg_err_t check_kss_header( void const* header ) -{ - if ( memcmp( header, "KSCC", 4 ) && memcmp( header, "KSSX", 4 ) ) - return gme_wrong_file_type; - return 0; -} - -// Setup - -static void update_gain_( struct Kss_Emu* this ) -{ - int g = this->gain; - if ( msx_music_enabled( this ) || msx_audio_enabled( this ) - || sms_fm_enabled( this ) ) - { - g = (g*3) / 4; //g *= 0.75; - } - else - { - if ( this->scc_accessed ) - g = (g*6) / 5; //g *= 1.2; - } - - if ( sms_psg_enabled( this ) ) Sms_apu_volume( &this->sms.psg, g ); - if ( sms_fm_enabled( this ) ) Opl_volume( &this->sms.fm, g ); - if ( msx_psg_enabled( this ) ) Ay_apu_volume( &this->msx.psg, g ); - if ( msx_scc_enabled( this ) ) Scc_volume( &this->msx.scc, g ); - if ( msx_music_enabled( this ) ) Opl_volume( &this->msx.music, g ); - if ( msx_audio_enabled( this ) ) Opl_volume( &this->msx.audio, g ); -} - -static void update_gain( struct Kss_Emu* this ) -{ - if ( this->scc_accessed ) - { - /* dprintf( "SCC accessed\n" ); */ - update_gain_( this ); - } -} - -blargg_err_t Kss_load_mem( struct Kss_Emu* this, const void* data, long size ) -{ - /* warning( core.warning() ); */ - memset( &this->header, 0, sizeof this->header ); - assert( offsetof (header_t,msx_audio_vol) == header_size - 1 ); - RETURN_ERR( Rom_load( &this->rom, data, size, header_base_size, &this->header, 0 ) ); - - RETURN_ERR( check_kss_header( this->header.tag ) ); - - this->chip_flags = 0; - this->header.last_track [0] = 255; - if ( this->header.tag [3] == 'C' ) - { - if ( this->header.extra_header ) - { - this->header.extra_header = 0; - /* warning( "Unknown data in header" ); */ - } - if ( this->header.device_flags & ~0x0F ) - { - this->header.device_flags &= 0x0F; - /* warning( "Unknown data in header" ); */ - } - } - else if ( this->header.extra_header ) - { - if ( this->header.extra_header != header_ext_size ) - { - this->header.extra_header = 0; - /* warning( "Invalid extra_header_size" ); */ - } - else - { - memcpy( this->header.data_size, this->rom.file_data, header_ext_size ); - } - } - - #ifndef NDEBUG - { - int ram_mode = this->header.device_flags & 0x84; // MSX - if ( this->header.device_flags & 0x02 ) // SMS - ram_mode = (this->header.device_flags & 0x88); - - if ( ram_mode ) - blargg_dprintf_( "RAM not supported\n" ); // TODO: support - } - #endif - - this->track_count = get_le16( this->header.last_track ) + 1; - this->m3u.size = 0; - - this->scc_enabled = false; - if ( this->header.device_flags & 0x02 ) // Sega Master System - { - int const osc_count = sms_osc_count + opl_osc_count; - - // sms.psg - this->voice_count = sms_osc_count; - static int const types [sms_osc_count + opl_osc_count] = { - wave_type+1, wave_type+3, wave_type+2, mixed_type+1, wave_type+0 - }; - this->voice_types = types; - this->chip_flags |= sms_psg_flag; - - // sms.fm - if ( this->header.device_flags & 0x01 ) - { - this->voice_count = osc_count; - this->chip_flags |= sms_fm_flag; - } - } - else // MSX - { - int const osc_count = ay_osc_count + opl_osc_count; - - // msx.psg - this->voice_count = ay_osc_count; - static int const types [ay_osc_count + opl_osc_count] = { - wave_type+1, wave_type+3, wave_type+2, wave_type+0 - }; - this->voice_types = types; - this->chip_flags |= msx_psg_flag; - - /* if ( this->header.device_flags & 0x10 ) - warning( "MSX stereo not supported" ); */ - - // msx.music - if ( this->header.device_flags & 0x01 ) - { - this->voice_count = osc_count; - this->chip_flags |= msx_music_flag; - } - - #ifndef KSS_EMU_NO_FMOPL - // msx.audio - if ( this->header.device_flags & 0x08 ) - { - this->voice_count = osc_count; - this->chip_flags |= msx_audio_flag; - } - #endif - - if ( !(this->header.device_flags & 0x80) ) - { - if ( !(this->header.device_flags & 0x84) ) - this->scc_enabled = scc_enabled_true; - - // msx.scc - this->chip_flags |= msx_scc_flag; - this->voice_count = ay_osc_count + scc_osc_count; - static int const types [ay_osc_count + scc_osc_count] = { - wave_type+1, wave_type+3, wave_type+2, - wave_type+0, wave_type+4, wave_type+5, wave_type+6, wave_type+7, - }; - this->voice_types = types; - } - } - - this->tfilter.lookahead = 6; - if ( sms_fm_enabled( this ) || msx_music_enabled( this ) || msx_audio_enabled( this ) ) - { - if ( !Opl_supported() ) - ; /* warning( "FM sound not supported" ); */ - else - this->tfilter.lookahead = 3; // Opl_Apu is really slow - } - - this->clock_rate_ = clock_rate; - Buffer_clock_rate( &this->stereo_buf, clock_rate ); - RETURN_ERR( Buffer_set_channel_count( &this->stereo_buf, this->voice_count, this->voice_types ) ); - this->buf_changed_count = Buffer_channels_changed_count( &this->stereo_buf ); - - Sound_set_tempo( this, this->tempo ); - Sound_mute_voices( this, this->mute_mask_ ); - return 0; -} - -static void set_voice( struct Kss_Emu* this, int i, struct Blip_Buffer* center, struct Blip_Buffer* left, struct Blip_Buffer* right ) -{ - if ( sms_psg_enabled( this ) ) // Sega Master System - { - i -= sms_osc_count; - if ( i < 0 ) - { - Sms_apu_set_output( &this->sms.psg, i + sms_osc_count, center, left, right ); - return; - } - - if ( sms_fm_enabled( this ) && i < opl_osc_count ) - Opl_set_output( &this->sms.fm, center ); - } - else if ( msx_psg_enabled( this ) ) // MSX - { - i -= ay_osc_count; - if ( i < 0 ) - { - Ay_apu_set_output( &this->msx.psg, i + ay_osc_count, center ); - return; - } - - if ( msx_scc_enabled( this ) && i < scc_osc_count ) Scc_set_output( &this->msx.scc, i, center ); - if ( msx_music_enabled( this ) && i < opl_osc_count ) Opl_set_output( &this->msx.music, center ); - if ( msx_audio_enabled( this ) && i < opl_osc_count ) Opl_set_output( &this->msx.audio, center ); - } -} - -// Emulation - -void jsr( struct Kss_Emu* this, byte const addr [] ) -{ - this->ram [--this->cpu.r.sp] = idle_addr >> 8; - this->ram [--this->cpu.r.sp] = idle_addr & 0xFF; - this->cpu.r.pc = get_le16( addr ); -} - -static void set_bank( struct Kss_Emu* this, int logical, int physical ) -{ - int const bank_size = (16 * 1024L) >> (this->header.bank_mode >> 7 & 1); - - int addr = 0x8000; - if ( logical && bank_size == 8 * 1024 ) - addr = 0xA000; - - physical -= this->header.first_bank; - if ( (unsigned) physical >= (unsigned) this->bank_count ) - { - byte* data = this->ram + addr; - Z80_map_mem( &this->cpu, addr, bank_size, data, data ); - } - else - { - int offset, phys = physical * bank_size; - for ( offset = 0; offset < bank_size; offset += page_size ) - Z80_map_mem( &this->cpu, addr + offset, page_size, - this->unmapped_write, Rom_at_addr( &this->rom, phys + offset ) ); - - } -} - -void cpu_write( struct Kss_Emu* this, addr_t addr, int data ) -{ - *Z80_write( &this->cpu, addr ) = data; - if ( (addr & this->scc_enabled) == 0x8000 ) { - // TODO: SCC+ support - - data &= 0xFF; - switch ( addr ) - { - case 0x9000: - set_bank( this, 0, data ); - return; - - case 0xB000: - set_bank( this, 1, data ); - return; - - case 0xBFFE: // selects between mapping areas (we just always enable both) - if ( data == 0 || data == 0x20 ) - return; - } - - int scc_addr = (addr & 0xDFFF) - 0x9800; - if ( msx_scc_enabled( this ) && (unsigned) scc_addr < 0xB0 ) - { - this->scc_accessed = true; - //if ( (unsigned) (scc_addr - 0x90) < 0x10 ) - // scc_addr -= 0x10; // 0x90-0x9F mirrors to 0x80-0x8F - if ( scc_addr < scc_reg_count ) - Scc_write( &this->msx.scc, Z80_time( &this->cpu ), addr, data ); - return; - } - } -} - -void cpu_out( struct Kss_Emu* this, kss_time_t time, kss_addr_t addr, int data ) -{ - data &= 0xFF; - switch ( addr & 0xFF ) - { - case 0xA0: - if ( msx_psg_enabled( this ) ) - Ay_apu_write_addr( &this->msx.psg, data ); - return; - - case 0xA1: - if ( msx_psg_enabled( this ) ) - Ay_apu_write_data( &this->msx.psg, time, data ); - return; - - case 0x06: - if ( sms_psg_enabled( this ) && (this->header.device_flags & 0x04) ) - { - Sms_apu_write_ggstereo( &this->sms.psg, time, data ); - return; - } - break; - - case 0x7E: - case 0x7F: - if ( sms_psg_enabled( this ) ) - { - Sms_apu_write_data( &this->sms.psg, time, data ); - return; - } - break; - - #define OPL_WRITE_HANDLER( base, name, opl )\ - case base : if ( name##_enabled( this ) ) { Opl_write_addr( opl, data ); return; } break;\ - case base+1: if ( name##_enabled( this ) ) { Opl_write_data( opl, time, data ); return; } break; - - OPL_WRITE_HANDLER( 0x7C, msx_music, &this->msx.music ) - OPL_WRITE_HANDLER( 0xC0, msx_audio, &this->msx.audio ) - OPL_WRITE_HANDLER( 0xF0, sms_fm, &this->sms.fm ) - - case 0xFE: - set_bank( this, 0, data ); - return; - - #ifndef NDEBUG - case 0xA8: // PPI - return; - #endif - } - - /* cpu_out( time, addr, data ); */ -} - -int cpu_in( struct Kss_Emu* this, kss_time_t time, kss_addr_t addr ) -{ - switch ( addr & 0xFF ) - { - case 0xC0: - case 0xC1: - if ( msx_audio_enabled( this ) ) - return Opl_read( &this->msx.audio, time, addr & 1 ); - break; - - case 0xA2: - if ( msx_psg_enabled( this ) ) - return Ay_apu_read( &this->msx.psg ); - break; - - #ifndef NDEBUG - case 0xA8: // PPI - return 0; - #endif - } - - /* return cpu_in( time, addr ); */ - return 0xFF; -} - -static blargg_err_t run_clocks( struct Kss_Emu* this, blip_time_t* duration_ ) -{ - blip_time_t duration = *duration_; - RETURN_ERR( end_frame( this, duration ) ); - - if ( sms_psg_enabled( this ) ) Sms_apu_end_frame( &this->sms.psg, duration ); - if ( sms_fm_enabled( this ) ) Opl_end_frame( &this->sms.fm, duration ); - if ( msx_psg_enabled( this ) ) Ay_apu_end_frame( &this->msx.psg, duration ); - if ( msx_scc_enabled( this ) ) Scc_end_frame( &this->msx.scc, duration ); - if ( msx_music_enabled( this ) ) Opl_end_frame( &this->msx.music, duration ); - if ( msx_audio_enabled( this ) ) Opl_end_frame( &this->msx.audio, duration ); - - return 0; -} - -blargg_err_t end_frame( struct Kss_Emu* this, kss_time_t end ) -{ - while ( Z80_time( &this->cpu ) < end ) - { - kss_time_t next = min( end, this->next_play ); - run_cpu( this, next ); - if ( this->cpu.r.pc == idle_addr ) - Z80_set_time( &this->cpu, next ); - - if ( Z80_time( &this->cpu ) >= this->next_play ) - { - this->next_play += this->play_period; - if ( this->cpu.r.pc == idle_addr ) - { - if ( !this->gain_updated ) - { - this->gain_updated = true; - update_gain( this ); - } - - jsr( this, this->header.play_addr ); - } - } - } - - this->next_play -= end; - check( this->next_play >= 0 ); - Z80_adjust_time( &this->cpu, -end ); - - return 0; -} - -// MUSIC - -blargg_err_t Kss_set_sample_rate( struct Kss_Emu* this, int rate ) -{ - require( !this->sample_rate ); // sample rate can't be changed once set - RETURN_ERR( Buffer_set_sample_rate( &this->stereo_buf, rate, 1000 / 20 ) ); - - // Set bass frequency - Buffer_bass_freq( &this->stereo_buf, 180 ); - - this->sample_rate = rate; - RETURN_ERR( track_init( &this->track_filter, this ) ); - this->tfilter.max_silence = 6 * stereo * this->sample_rate; - return 0; -} - -void Sound_mute_voice( struct Kss_Emu* this, int index, bool mute ) -{ - require( (unsigned) index < (unsigned) this->voice_count ); - int bit = 1 << index; - int mask = this->mute_mask_ | bit; - if ( !mute ) - mask ^= bit; - Sound_mute_voices( this, mask ); -} - -void Sound_mute_voices( struct Kss_Emu* this, int mask ) -{ - require( this->sample_rate ); // sample rate must be set first - this->mute_mask_ = mask; - - int i; - for ( i = this->voice_count; i--; ) - { - if ( mask & (1 << i) ) - { - set_voice( this, i, 0, 0, 0 ); - } - else - { - struct channel_t ch = Buffer_channel( &this->stereo_buf, i ); - assert( (ch.center && ch.left && ch.right) || - (!ch.center && !ch.left && !ch.right) ); // all or nothing - set_voice( this, i, ch.center, ch.left, ch.right ); - } - } -} - -void Sound_set_tempo( struct Kss_Emu* this, int t ) -{ - require( this->sample_rate ); // sample rate must be set first - int const min = (int)(FP_ONE_TEMPO*0.02); - int const max = (int)(FP_ONE_TEMPO*4.00); - if ( t < min ) t = min; - if ( t > max ) t = max; - this->tempo = t; - - blip_time_t period = - (this->header.device_flags & 0x40 ? clock_rate / 50 : clock_rate / 60); - this->play_period = (blip_time_t) ((period * FP_ONE_TEMPO) / t); -} - -blargg_err_t Kss_start_track( struct Kss_Emu* this, int track ) -{ - clear_track_vars( this ); - - // Remap track if playlist available - if ( this->m3u.size > 0 ) { - struct entry_t* e = &this->m3u.entries[track]; - track = e->track; - } - - this->current_track = track; - - Buffer_clear( &this->stereo_buf ); - - if ( sms_psg_enabled( this ) ) Sms_apu_reset( &this->sms.psg, 0, 0 ); - if ( sms_fm_enabled( this ) ) Opl_reset( &this->sms.fm ); - if ( msx_psg_enabled( this ) ) Ay_apu_reset( &this->msx.psg ); - if ( msx_scc_enabled( this ) ) Scc_reset( &this->msx.scc ); - if ( msx_music_enabled( this ) ) Opl_reset( &this->msx.music ); - if ( msx_audio_enabled( this ) ) Opl_reset( &this->msx.audio ); - - this->scc_accessed = false; - update_gain_( this ); - - memset( this->ram, 0xC9, 0x4000 ); - memset( this->ram + 0x4000, 0, sizeof this->ram - 0x4000 ); - - // copy driver code to lo RAM - static byte const bios [] = { - 0xD3, 0xA0, 0xF5, 0x7B, 0xD3, 0xA1, 0xF1, 0xC9, // $0001: WRTPSG - 0xD3, 0xA0, 0xDB, 0xA2, 0xC9 // $0009: RDPSG - }; - static byte const vectors [] = { - 0xC3, 0x01, 0x00, // $0093: WRTPSG vector - 0xC3, 0x09, 0x00, // $0096: RDPSG vector - }; - memcpy( this->ram + 0x01, bios, sizeof bios ); - memcpy( this->ram + 0x93, vectors, sizeof vectors ); - - // copy non-banked data into RAM - int load_addr = get_le16( this->header.load_addr ); - int orig_load_size = get_le16( this->header.load_size ); - int load_size = min( orig_load_size, (int) this->rom.file_size ); - load_size = min( load_size, (int) mem_size - load_addr ); - /* if ( load_size != orig_load_size ) - warning( "Excessive data size" ); */ - memcpy( this->ram + load_addr, this->rom.file_data + this->header.extra_header, load_size ); - - Rom_set_addr( &this->rom, -load_size - this->header.extra_header ); - - // check available bank data - int const bank_size = (16 * 1024L) >> (this->header.bank_mode >> 7 & 1); - int max_banks = (this->rom.file_size - load_size + bank_size - 1) / bank_size; - this->bank_count = this->header.bank_mode & 0x7F; - if ( this->bank_count > max_banks ) - { - this->bank_count = max_banks; - /* warning( "Bank data missing" ); */ - } - //dprintf( "load_size : $%X\n", load_size ); - //dprintf( "bank_size : $%X\n", bank_size ); - //dprintf( "bank_count: %d (%d claimed)\n", bank_count, this->header.bank_mode & 0x7F ); - - this->ram [idle_addr] = 0xFF; - Z80_reset( &this->cpu, this->unmapped_write, this->unmapped_read ); - Z80_map_mem( &this->cpu, 0, mem_size, this->ram, this->ram ); - - this->cpu.r.sp = 0xF380; - this->cpu.r.b.a = track; - this->cpu.r.b.h = 0; - this->next_play = this->play_period; - this->gain_updated = false; - jsr( this, this->header.init_addr ); - - // convert filter times to samples - struct setup_t s = this->tfilter; - s.max_initial *= this->sample_rate * stereo; - #ifdef GME_DISABLE_SILENCE_LOOKAHEAD - s.lookahead = 1; - #endif - track_setup( &this->track_filter, &s ); - - return track_start( &this->track_filter ); -} - -// Tell/Seek - -static int msec_to_samples( int msec, int sample_rate ) -{ - int sec = msec / 1000; - msec -= sec * 1000; - return (sec * sample_rate + msec * sample_rate / 1000) * stereo; -} - -int Track_tell( struct Kss_Emu* this ) -{ - int rate = this->sample_rate * stereo; - int sec = track_sample_count( &this->track_filter ) / rate; - return sec * 1000 + (track_sample_count( &this->track_filter ) - sec * rate) * 1000 / rate; -} - -blargg_err_t Track_seek( struct Kss_Emu* this, int msec ) -{ - int time = msec_to_samples( msec, this->sample_rate ); - if ( time < track_sample_count( &this->track_filter ) ) - RETURN_ERR( Kss_start_track( this, this->current_track ) ); - return Track_skip( this, time - track_sample_count( &this->track_filter ) ); -} - -blargg_err_t skip_( void *emu, int count ) -{ - struct Kss_Emu* this = (struct Kss_Emu*) emu; - - // for long skip, mute sound - const int threshold = 32768; - if ( count > threshold ) - { - int saved_mute = this->mute_mask_; - Sound_mute_voices( this, ~0 ); - - int n = count - threshold/2; - n &= ~(2048-1); // round to multiple of 2048 - count -= n; - RETURN_ERR( skippy_( &this->track_filter, n ) ); - - Sound_mute_voices( this, saved_mute ); - } - - return skippy_( &this->track_filter, count ); -} - -blargg_err_t Track_skip( struct Kss_Emu* this, int count ) -{ - require( this->current_track >= 0 ); // start_track() must have been called already - return track_skip( &this->track_filter, count ); -} - -void Track_set_fade( struct Kss_Emu* this, int start_msec, int length_msec ) -{ - track_set_fade( &this->track_filter, msec_to_samples( start_msec, this->sample_rate ), - length_msec * this->sample_rate / (1000 / stereo) ); -} - -blargg_err_t Kss_play( struct Kss_Emu* this, int out_count, sample_t* out ) -{ - require( this->current_track >= 0 ); - require( out_count % stereo == 0 ); - return track_play( &this->track_filter, out_count, out ); -} - -blargg_err_t play_( void *emu, int count, sample_t* out ) -{ - struct Kss_Emu* this = (struct Kss_Emu*) emu; - - int remain = count; - while ( remain ) - { - Buffer_disable_immediate_removal( &this->stereo_buf ); - remain -= Buffer_read_samples( &this->stereo_buf, &out [count - remain], remain ); - if ( remain ) - { - if ( this->buf_changed_count != Buffer_channels_changed_count( &this->stereo_buf ) ) - { - this->buf_changed_count = Buffer_channels_changed_count( &this->stereo_buf ); - - // Remute voices - Sound_mute_voices( this, this->mute_mask_ ); - } - int msec = Buffer_length( &this->stereo_buf ); - blip_time_t clocks_emulated = msec * this->clock_rate_ / 1000 - 100; - RETURN_ERR( run_clocks( this, &clocks_emulated ) ); - assert( clocks_emulated ); - Buffer_end_frame( &this->stereo_buf, clocks_emulated ); - } - } - return 0; -} diff --git a/apps/codecs/libgme/kss_emu.h b/apps/codecs/libgme/kss_emu.h deleted file mode 100644 index 382e4b807b..0000000000 --- a/apps/codecs/libgme/kss_emu.h +++ /dev/null @@ -1,223 +0,0 @@ -// MSX computer KSS music file emulator - -// Game_Music_Emu 0.5.5 -#ifndef KSS_EMU_H -#define KSS_EMU_H - -#include "gme.h" -#include "blargg_common.h" - -#include "rom_data.h" -#include "multi_buffer.h" - -#include "kss_scc_apu.h" -#include "z80_cpu.h" -#include "sms_apu.h" -#include "ay_apu.h" -#include "opl_apu.h" -#include "m3u_playlist.h" -#include "track_filter.h" - -typedef int kss_time_t; -typedef int kss_addr_t; -typedef struct Z80_Cpu Kss_Cpu; - -// Sound chip flags -enum { - sms_psg_flag = 1 << 0, - sms_fm_flag = 1 << 1, - msx_psg_flag = 1 << 2, - msx_scc_flag = 1 << 3, - msx_music_flag = 1 << 4, - msx_audio_flag = 1 << 5 -}; - -enum { idle_addr = 0xFFFF }; -enum { scc_enabled_true = 0xC000 }; -enum { mem_size = 0x10000 }; - -// KSS file header -enum { header_size = 0x20 }; -enum { header_base_size = 0x10 }; -enum { header_ext_size = header_size - header_base_size }; - -struct header_t -{ - byte tag [4]; - byte load_addr [2]; - byte load_size [2]; - byte init_addr [2]; - byte play_addr [2]; - byte first_bank; - byte bank_mode; - byte extra_header; - byte device_flags; - - // KSSX extended data, if extra_header==0x10 - byte data_size [4]; - byte unused [4]; - byte first_track [2]; - byte last_track [2]; // if no extended data, we set this to 0xFF - byte psg_vol; - byte scc_vol; - byte msx_music_vol; - byte msx_audio_vol; -}; - -struct sms_t { - struct Sms_Apu psg; - struct Opl_Apu fm; -}; - -struct msx_t { - struct Ay_Apu psg; - struct Scc_Apu scc; - struct Opl_Apu music; - struct Opl_Apu audio; -}; - -struct Kss_Emu { - struct header_t header; - - int chip_flags; - bool scc_accessed; - bool gain_updated; - - unsigned scc_enabled; // 0 or 0xC000 - int bank_count; - - blip_time_t play_period; - blip_time_t next_play; - int ay_latch; - - // general - int voice_count; - int const* voice_types; - int mute_mask_; - int tempo; - int gain; - - int sample_rate; - - // track-specific - int track_count; - int current_track; - - int clock_rate_; - unsigned buf_changed_count; - - // M3u Playlist - struct M3u_Playlist m3u; - - struct setup_t tfilter; - struct Track_Filter track_filter; - - struct sms_t sms; - struct msx_t msx; - - Kss_Cpu cpu; - struct Multi_Buffer stereo_buf; // NULL if using custom buffer - struct Rom_Data rom; - - byte unmapped_read [0x100]; - byte unmapped_write [page_size]; - byte ram [mem_size + cpu_padding]; -}; - -// Basic functionality (see Gme_File.h for file loading/track info functions) - -void Kss_init( struct Kss_Emu* this ); -blargg_err_t Kss_load_mem( struct Kss_Emu* this, const void* data, long size ); -blargg_err_t end_frame( struct Kss_Emu* this, kss_time_t ); - -// Set output sample rate. Must be called only once before loading file. -blargg_err_t Kss_set_sample_rate( struct Kss_Emu* this, int sample_rate ); - -// Start a track, where 0 is the first track. Also clears warning string. -blargg_err_t Kss_start_track( struct Kss_Emu* this, int track ); - -// Generate 'count' samples info 'buf'. Output is in stereo. Any emulation -// errors set warning string, and major errors also end track. -blargg_err_t Kss_play( struct Kss_Emu* this, int count, sample_t* buf ); - -// Track status/control - -// Number of milliseconds (1000 msec = 1 second) played since beginning of track -int Track_tell( struct Kss_Emu* this ); - -// Seek to new time in track. Seeking backwards or far forward can take a while. -blargg_err_t Track_seek( struct Kss_Emu* this, int msec ); - -// Skip n samples -blargg_err_t Track_skip( struct Kss_Emu* this, int n ); - -// Set start time and length of track fade out. Once fade ends track_ended() returns -// true. Fade time can be changed while track is playing. -void Track_set_fade( struct Kss_Emu* this, int start_msec, int length_msec ); - -// True if a track has reached its end -static inline bool Track_ended( struct Kss_Emu* this ) -{ - return track_ended( &this->track_filter ); -} - -// Disables automatic end-of-track detection and skipping of silence at beginning -static inline void Track_ignore_silence( struct Kss_Emu* this, bool disable ) -{ - this->track_filter.silence_ignored_ = disable; -} - -// Get track length in milliseconds -static inline int Track_get_length( struct Kss_Emu* this, int n ) -{ - int length = 0; - - if ( (this->m3u.size > 0) && (n < this->m3u.size) ) { - struct entry_t* entry = &this->m3u.entries [n]; - length = entry->length; - } - - if ( length <= 0 ) - length = 120 * 1000; /* 2 minutes */ - - return length; -} - -// Sound customization - -// Adjust song tempo, where 1.0 = normal, 0.5 = half speed, 2.0 = double speed. -// Track length as returned by track_info() assumes a tempo of 1.0. -void Sound_set_tempo( struct Kss_Emu* this, int t ); - -// Mute/unmute voice i, where voice 0 is first voice -void Sound_mute_voice( struct Kss_Emu* this, int index, bool mute ); - -// Set muting state of all voices at once using a bit mask, where -1 mutes them all, -// 0 unmutes them all, 0x01 mutes just the first voice, etc. -void Sound_mute_voices( struct Kss_Emu* this, int mask ); - -// Change overall output amplitude, where 1.0 results in minimal clamping. -// Must be called before set_sample_rate(). -static inline void Sound_set_gain( struct Kss_Emu* this, int g ) -{ - assert( !this->sample_rate ); // you must set gain before setting sample rate - this->gain = g; -} - -// Emulation (You shouldn't touch these -void cpu_write( struct Kss_Emu* this, kss_addr_t, int ); -int cpu_in( struct Kss_Emu* this, kss_time_t, kss_addr_t ); -void cpu_out( struct Kss_Emu* this, kss_time_t, kss_addr_t, int ); - -void cpu_write_( struct Kss_Emu* this, kss_addr_t addr, int data ); -bool run_cpu( struct Kss_Emu* this, kss_time_t end ); -void jsr( struct Kss_Emu* this, byte const addr [] ); - -static inline int sms_psg_enabled( struct Kss_Emu* this ) { return this->chip_flags & sms_psg_flag; } -static inline int sms_fm_enabled( struct Kss_Emu* this ) { return this->chip_flags & sms_fm_flag; } -static inline int msx_psg_enabled( struct Kss_Emu* this ) { return this->chip_flags & msx_psg_flag; } -static inline int msx_scc_enabled( struct Kss_Emu* this ) { return this->chip_flags & msx_scc_flag; } -static inline int msx_music_enabled( struct Kss_Emu* this ) { return this->chip_flags & msx_music_flag;} -static inline int msx_audio_enabled( struct Kss_Emu* this ) { return this->chip_flags & msx_audio_flag;} - -#endif diff --git a/apps/codecs/libgme/kss_scc_apu.c b/apps/codecs/libgme/kss_scc_apu.c deleted file mode 100644 index 1bec9b7f0e..0000000000 --- a/apps/codecs/libgme/kss_scc_apu.c +++ /dev/null @@ -1,166 +0,0 @@ -// Game_Music_Emu 0.6-pre. http://www.slack.net/~ant/ - -#include "kss_scc_apu.h" - -/* Copyright (C) 2006-2008 Shay Green. This module is free software; you -can redistribute it and/or modify it under the terms of the GNU Lesser -General Public License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. This -module is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more -details. You should have received a copy of the GNU Lesser General Public -License along with this module; if not, write to the Free Software Foundation, -Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ - -#include "blargg_source.h" - -// Tones above this frequency are treated as disabled tone at half volume. -// Power of two is more efficient (avoids division). -extern int const inaudible_freq; - -int const wave_size = 0x20; - -static void set_output( struct Scc_Apu* this, struct Blip_Buffer* buf ) -{ - int i; - for ( i = 0; i < scc_osc_count; ++i ) - Scc_set_output( this, i, buf ); -} - -void Scc_volume( struct Scc_Apu* this, int v ) -{ - Synth_volume( &this->synth, (v/2 - (v*7)/100) / scc_osc_count / scc_amp_range ); -} - -void Scc_reset( struct Scc_Apu* this ) -{ - this->last_time = 0; - - int i; - for ( i = scc_osc_count; --i >= 0; ) - memset( &this->oscs [i], 0, offsetof (struct scc_osc_t,output) ); - - memset( this->regs, 0, sizeof this->regs ); -} - -void Scc_init( struct Scc_Apu* this ) -{ - Synth_init( &this->synth); - - set_output( this, NULL ); - Scc_volume( this, (int)FP_ONE_VOLUME ); - Scc_reset( this ); -} - -static void run_until( struct Scc_Apu* this, blip_time_t end_time ) -{ - int index; - for ( index = 0; index < scc_osc_count; index++ ) - { - struct scc_osc_t* osc = &this->oscs [index]; - - struct Blip_Buffer* const output = osc->output; - if ( !output ) - continue; - - blip_time_t period = (this->regs [0xA0 + index * 2 + 1] & 0x0F) * 0x100 + - this->regs [0xA0 + index * 2] + 1; - int volume = 0; - if ( this->regs [0xAF] & (1 << index) ) - { - blip_time_t inaudible_period = (unsigned) (Blip_clock_rate( output ) + - inaudible_freq * 32) / (unsigned) (inaudible_freq * 16); - if ( period > inaudible_period ) - volume = (this->regs [0xAA + index] & 0x0F) * (scc_amp_range / 256 / 15); - } - - int8_t const* wave = (int8_t*) this->regs + index * wave_size; - /*if ( index == osc_count - 1 ) - wave -= wave_size; // last two oscs share same wave RAM*/ - - { - int delta = wave [osc->phase] * volume - osc->last_amp; - if ( delta ) - { - osc->last_amp += delta; - Blip_set_modified( output ); - Synth_offset( &this->synth, this->last_time, delta, output ); - } - } - - blip_time_t time = this->last_time + osc->delay; - if ( time < end_time ) - { - int phase = osc->phase; - if ( !volume ) - { - // maintain phase - int count = (end_time - time + period - 1) / period; - phase += count; // will be masked below - time += count * period; - } - else - { - int last_wave = wave [phase]; - phase = (phase + 1) & (wave_size - 1); // pre-advance for optimal inner loop - do - { - int delta = wave [phase] - last_wave; - phase = (phase + 1) & (wave_size - 1); - if ( delta ) - { - last_wave += delta; - Synth_offset_inline( &this->synth, time, delta * volume, output ); - } - time += period; - } - while ( time < end_time ); - - osc->last_amp = last_wave * volume; - Blip_set_modified( output ); - phase--; // undo pre-advance - } - osc->phase = phase & (wave_size - 1); - } - osc->delay = time - end_time; - } - this->last_time = end_time; -} - -void Scc_write( struct Scc_Apu* this, blip_time_t time, int addr, int data ) -{ - //assert( (unsigned) addr < reg_count ); - assert( ( addr >= 0x9800 && addr <= 0x988F ) || ( addr >= 0xB800 && addr <= 0xB8AF ) ); - run_until( this, time ); - - addr -= 0x9800; - if ( ( unsigned ) addr < 0x90 ) - { - if ( ( unsigned ) addr < 0x60 ) - this->regs [addr] = data; - else if ( ( unsigned ) addr < 0x80 ) - { - this->regs [addr] = this->regs[addr + 0x20] = data; - } - else if ( ( unsigned ) addr < 0x90 ) - { - this->regs [addr + 0x20] = data; - } - } - else - { - addr -= 0xB800 - 0x9800; - if ( ( unsigned ) addr < 0xB0 ) - this->regs [addr] = data; - } -} - -void Scc_end_frame( struct Scc_Apu* this, blip_time_t end_time ) -{ - if ( end_time > this->last_time ) - run_until( this, end_time ); - - this->last_time -= end_time; - assert( this->last_time >= 0 ); -} diff --git a/apps/codecs/libgme/kss_scc_apu.h b/apps/codecs/libgme/kss_scc_apu.h deleted file mode 100644 index a6962469ac..0000000000 --- a/apps/codecs/libgme/kss_scc_apu.h +++ /dev/null @@ -1,51 +0,0 @@ -// Konami SCC sound chip emulator - -// Game_Music_Emu 0.6-pre -#ifndef KSS_SCC_APU_H -#define KSS_SCC_APU_H - -#include "blargg_common.h" -#include "blip_buffer.h" - -enum { scc_reg_count = 0xB0 }; // 0 <= reg < reg_count -enum { scc_osc_count = 5 }; -enum { scc_amp_range = 0x8000 }; - -struct scc_osc_t -{ - int delay; - int phase; - int last_amp; - struct Blip_Buffer* output; -}; - -struct Scc_Apu { - struct scc_osc_t oscs [scc_osc_count]; - blip_time_t last_time; - unsigned char regs [scc_reg_count]; - - struct Blip_Synth synth; -}; - -void Scc_init( struct Scc_Apu* this ); - -// Resets sound chip -void Scc_reset( struct Scc_Apu* this ); - -// Set overall volume, where 1.0 is normal -void Scc_volume( struct Scc_Apu* this, int v ); - -static inline void Scc_set_output( struct Scc_Apu* this, int index, struct Blip_Buffer* b ) -{ - assert( (unsigned) index < scc_osc_count ); - this->oscs [index].output = b; -} - -// Emulates to time t, then writes data to reg -void Scc_write( struct Scc_Apu* this, blip_time_t time, int addr, int data ); - -// Emulates to time t, then subtracts t from the current time. -// OK if previous write call had time slightly after t. -void Scc_end_frame( struct Scc_Apu* this, blip_time_t end_time ); - -#endif diff --git a/apps/codecs/libgme/libay.make b/apps/codecs/libgme/libay.make deleted file mode 100644 index 0b5691c1f1..0000000000 --- a/apps/codecs/libgme/libay.make +++ /dev/null @@ -1,10 +0,0 @@ - -# libay -AYLIB := $(CODECDIR)/libay.a -AYLIB_SRC := $(call preprocess, $(APPSDIR)/codecs/libgme/AYSOURCES) -AYLIB_OBJ := $(call c2obj, $(AYLIB_SRC)) -OTHER_SRC += $(AYLIB_SRC) - -$(AYLIB): $(AYLIB_OBJ) - $(SILENT)$(shell rm -f $@) - $(call PRINTS,AR $(@F))$(AR) rcs $@ $^ >/dev/null diff --git a/apps/codecs/libgme/libemu2413.make b/apps/codecs/libgme/libemu2413.make deleted file mode 100644 index 2f489ced46..0000000000 --- a/apps/codecs/libgme/libemu2413.make +++ /dev/null @@ -1,10 +0,0 @@ - -# libemu2413 -EMU2413LIB := $(CODECDIR)/libemu2413.a -EMU2413LIB_SRC := $(call preprocess, $(APPSDIR)/codecs/libgme/EMU2413SOURCES) -EMU2413LIB_OBJ := $(call c2obj, $(EMU2413LIB_SRC)) -OTHER_SRC += $(EMU2413LIB_SRC) - -$(EMU2413LIB): $(EMU2413LIB_OBJ) - $(SILENT)$(shell rm -f $@) - $(call PRINTS,AR $(@F))$(AR) rcs $@ $^ >/dev/null diff --git a/apps/codecs/libgme/libgbs.make b/apps/codecs/libgme/libgbs.make deleted file mode 100644 index 6661a4994f..0000000000 --- a/apps/codecs/libgme/libgbs.make +++ /dev/null @@ -1,10 +0,0 @@ - -# libgbs -GBSLIB := $(CODECDIR)/libgbs.a -GBSLIB_SRC := $(call preprocess, $(APPSDIR)/codecs/libgme/GBSSOURCES) -GBSLIB_OBJ := $(call c2obj, $(GBSLIB_SRC)) -OTHER_SRC += $(GBSLIB_SRC) - -$(GBSLIB): $(GBSLIB_OBJ) - $(SILENT)$(shell rm -f $@) - $(call PRINTS,AR $(@F))$(AR) rcs $@ $^ >/dev/null diff --git a/apps/codecs/libgme/libhes.make b/apps/codecs/libgme/libhes.make deleted file mode 100644 index 81e29f8c5a..0000000000 --- a/apps/codecs/libgme/libhes.make +++ /dev/null @@ -1,10 +0,0 @@ - -# libhes -HESLIB := $(CODECDIR)/libhes.a -HESLIB_SRC := $(call preprocess, $(APPSDIR)/codecs/libgme/HESSOURCES) -HESLIB_OBJ := $(call c2obj, $(HESLIB_SRC)) -OTHER_SRC += $(HESLIB_SRC) - -$(HESLIB): $(HESLIB_OBJ) - $(SILENT)$(shell rm -f $@) - $(call PRINTS,AR $(@F))$(AR) rcs $@ $^ >/dev/null diff --git a/apps/codecs/libgme/libkss.make b/apps/codecs/libgme/libkss.make deleted file mode 100644 index c93d8d169f..0000000000 --- a/apps/codecs/libgme/libkss.make +++ /dev/null @@ -1,10 +0,0 @@ - -# libkss -KSSLIB := $(CODECDIR)/libkss.a -KSSLIB_SRC := $(call preprocess, $(APPSDIR)/codecs/libgme/KSSSOURCES) -KSSLIB_OBJ := $(call c2obj, $(KSSLIB_SRC)) -OTHER_SRC += $(KSSLIB_SRC) - -$(KSSLIB): $(KSSLIB_OBJ) - $(SILENT)$(shell rm -f $@) - $(call PRINTS,AR $(@F))$(AR) rcs $@ $^ >/dev/null diff --git a/apps/codecs/libgme/libnsf.make b/apps/codecs/libgme/libnsf.make deleted file mode 100644 index 9ab171711a..0000000000 --- a/apps/codecs/libgme/libnsf.make +++ /dev/null @@ -1,10 +0,0 @@ - -# libnsf -NSFLIB := $(CODECDIR)/libnsf.a -NSFLIB_SRC := $(call preprocess, $(APPSDIR)/codecs/libgme/NSFSOURCES) -NSFLIB_OBJ := $(call c2obj, $(NSFLIB_SRC)) -OTHER_SRC += $(NSFLIB_SRC) - -$(NSFLIB): $(NSFLIB_OBJ) - $(SILENT)$(shell rm -f $@) - $(call PRINTS,AR $(@F))$(AR) rcs $@ $^ >/dev/null diff --git a/apps/codecs/libgme/libsgc.make b/apps/codecs/libgme/libsgc.make deleted file mode 100644 index ddaec96081..0000000000 --- a/apps/codecs/libgme/libsgc.make +++ /dev/null @@ -1,10 +0,0 @@ - -# libsgc -SGCLIB := $(CODECDIR)/libsgc.a -SGCLIB_SRC := $(call preprocess, $(APPSDIR)/codecs/libgme/SGCSOURCES) -SGCLIB_OBJ := $(call c2obj, $(SGCLIB_SRC)) -OTHER_SRC += $(SGCLIB_SRC) - -$(SGCLIB): $(SGCLIB_OBJ) - $(SILENT)$(shell rm -f $@) - $(call PRINTS,AR $(@F))$(AR) rcs $@ $^ >/dev/null diff --git a/apps/codecs/libgme/libvgm.make b/apps/codecs/libgme/libvgm.make deleted file mode 100644 index cc492d5143..0000000000 --- a/apps/codecs/libgme/libvgm.make +++ /dev/null @@ -1,10 +0,0 @@ - -# libvgm -VGMLIB := $(CODECDIR)/libvgm.a -VGMLIB_SRC := $(call preprocess, $(APPSDIR)/codecs/libgme/VGMSOURCES) -VGMLIB_OBJ := $(call c2obj, $(VGMLIB_SRC)) -OTHER_SRC += $(VGMLIB_SRC) - -$(VGMLIB): $(VGMLIB_OBJ) - $(SILENT)$(shell rm -f $@) - $(call PRINTS,AR $(@F))$(AR) rcs $@ $^ >/dev/null diff --git a/apps/codecs/libgme/m3u_playlist.h b/apps/codecs/libgme/m3u_playlist.h deleted file mode 100644 index 06a5d3024b..0000000000 --- a/apps/codecs/libgme/m3u_playlist.h +++ /dev/null @@ -1,31 +0,0 @@ -// M3U entries parser, with support for subtrack information - -// Game_Music_Emu 0.5.2 -#ifndef M3U_PLAYLIST_H -#define M3U_PLAYILST_H - -#include "blargg_common.h" - -struct entry_t -{ - unsigned char track; // 1-based - int length; // milliseconds -}; - -/* Short version of the m3u playlist */ -struct M3u_Playlist -{ - unsigned char size; - struct entry_t *entries; -}; - -static inline void M3u_load_data(struct M3u_Playlist* this, void *addr) -{ - if( addr == NULL ) return; - /* m3u entries data must be at offset 100, - the first 99 bytes are used by metadata info */ - this->size = *(unsigned char *)(addr + 99); - this->entries = (struct entry_t *)(addr+100); -} - -#endif diff --git a/apps/codecs/libgme/msxtypes.h b/apps/codecs/libgme/msxtypes.h deleted file mode 100644 index 6224e0760c..0000000000 --- a/apps/codecs/libgme/msxtypes.h +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef MSX_TYPES -#define MSX_TYPES - -#ifdef __cplusplus -extern "C" { -#endif - - -#ifdef __GNUC__ -#define __int64 long long -#endif - -#ifdef _WIN32 -#define DIR_SEPARATOR "\\" -#else -#define DIR_SEPARATOR "/" -#endif - -/* So far, only support for MSVC types - */ -typedef unsigned char UInt8; -#ifndef __CARBON__ -typedef unsigned short UInt16; -typedef unsigned int UInt32; -typedef unsigned __int64 UInt64; -#endif -typedef signed char Int8; -typedef signed short Int16; -typedef signed int Int32; - -#ifdef __cplusplus -} -#endif - - -#endif diff --git a/apps/codecs/libgme/multi_buffer.c b/apps/codecs/libgme/multi_buffer.c deleted file mode 100644 index 554778c3de..0000000000 --- a/apps/codecs/libgme/multi_buffer.c +++ /dev/null @@ -1,286 +0,0 @@ -// Multi_Buffer 0.4.1. http://www.slack.net/~ant/ - -#include "multi_buffer.h" - -/* Copyright (C) 2003-2006 Shay Green. This module is free software; you -can redistribute it and/or modify it under the terms of the GNU Lesser -General Public License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. This -module is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more -details. You should have received a copy of the GNU Lesser General Public -License along with this module; if not, write to the Free Software Foundation, -Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ - -#include "blargg_source.h" - -// Tracked_Blip_Buffer - -int const blip_buffer_extra = 32; // TODO: explain why this value - -void Tracked_init( struct Tracked_Blip_Buffer* this ) -{ - Blip_init( &this->blip ); - this->last_non_silence = 0; -} - -void Tracked_clear( struct Tracked_Blip_Buffer* this ) -{ - this->last_non_silence = 0; - Blip_clear( &this->blip ); -} - -void Tracked_end_frame( struct Tracked_Blip_Buffer* this, blip_time_t t ) -{ - Blip_end_frame( &this->blip, t ); - if ( this->blip.modified ) - { - this->blip.modified = false; - this->last_non_silence = Blip_samples_avail( &this->blip ) + blip_buffer_extra; - } -} - -unsigned Tracked_non_silent( struct Tracked_Blip_Buffer* this ) -{ - return this->last_non_silence | unsettled( &this->blip ); -} - -static inline void remove_( struct Tracked_Blip_Buffer* this, int n ) -{ - if ( (this->last_non_silence -= n) < 0 ) - this->last_non_silence = 0; -} - -void Tracked_remove_silence( struct Tracked_Blip_Buffer* this, int n ) -{ - remove_( this, n ); - Blip_remove_silence( &this->blip, n ); -} - -void Tracked_remove_samples( struct Tracked_Blip_Buffer* this, int n ) -{ - remove_( this, n ); - Blip_remove_samples( &this->blip, n ); -} - -void Tracked_remove_all_samples( struct Tracked_Blip_Buffer* this ) -{ - int avail = Blip_samples_avail( &this->blip ); - if ( !Tracked_non_silent( this ) ) - Tracked_remove_silence( this, avail ); - else - Tracked_remove_samples( this, avail ); -} - -int Tracked_read_samples( struct Tracked_Blip_Buffer* this, blip_sample_t out [], int count ) -{ - count = Blip_read_samples( &this->blip, out, count, false ); - remove_( this, count ); - return count; -} - -// Stereo_Mixer - -// mixers use a single index value to improve performance on register-challenged processors -// offset goes from negative to zero - -void Mixer_init( struct Stereo_Mixer* this ) -{ - this->samples_read = 0; -} - -static void mix_mono( struct Stereo_Mixer* this, blip_sample_t out_ [], int count ) -{ - int const bass = this->bufs [2]->blip.bass_shift_; - delta_t const* center = this->bufs [2]->blip.buffer_ + this->samples_read; - int center_sum = this->bufs [2]->blip.reader_accum_; - - typedef blip_sample_t stereo_blip_sample_t [stereo]; - stereo_blip_sample_t* BLARGG_RESTRICT out = (stereo_blip_sample_t*) out_ + count; - int offset = -count; - do - { - int s = center_sum >> delta_bits; - - center_sum -= center_sum >> bass; - center_sum += center [offset]; - - BLIP_CLAMP( s, s ); - - out [offset] [0] = (blip_sample_t) s; - out [offset] [1] = (blip_sample_t) s; - } - while ( ++offset ); - - this->bufs [2]->blip.reader_accum_ = center_sum; -} - -static void mix_stereo( struct Stereo_Mixer* this, blip_sample_t out_ [], int count ) -{ - blip_sample_t* BLARGG_RESTRICT out = out_ + count * stereo; - // do left + center and right + center separately to reduce register load - struct Tracked_Blip_Buffer* const* buf = &this->bufs [2]; - while ( true ) // loop runs twice - { - --buf; - --out; - - int const bass = this->bufs [2]->blip.bass_shift_; - delta_t const* side = (*buf)->blip.buffer_ + this->samples_read; - delta_t const* center = this->bufs [2]->blip.buffer_ + this->samples_read; - - int side_sum = (*buf)->blip.reader_accum_; - int center_sum = this->bufs [2]->blip.reader_accum_; - - int offset = -count; - do - { - int s = (center_sum + side_sum) >> delta_bits; - - side_sum -= side_sum >> bass; - center_sum -= center_sum >> bass; - - side_sum += side [offset]; - center_sum += center [offset]; - - BLIP_CLAMP( s, s ); - - ++offset; // before write since out is decremented to slightly before end - out [offset * stereo] = (blip_sample_t) s; - } - while ( offset ); - - (*buf)->blip.reader_accum_ = side_sum; - - if ( buf != this->bufs ) - continue; - - // only end center once - this->bufs [2]->blip.reader_accum_ = center_sum; - break; - } -} - -void Mixer_read_pairs( struct Stereo_Mixer* this, blip_sample_t out [], int count ) -{ - // TODO: if caller never marks buffers as modified, uses mono - // except that buffer isn't cleared, so caller can encounter - // subtle problems and not realize the cause. - this->samples_read += count; - if ( Tracked_non_silent( this->bufs [0] ) | Tracked_non_silent( this->bufs [1] ) ) - mix_stereo( this, out, count ); - else - mix_mono( this, out, count ); -} - -// Multi_Buffer - -void Buffer_init( struct Multi_Buffer* this ) -{ - int const spf = 2; - - Tracked_init( &this->bufs [0] ); - Tracked_init( &this->bufs [1] ); - Tracked_init( &this->bufs [2] ); - - Mixer_init( &this->mixer ); - - this->length_ = 0; - this->sample_rate_ = 0; - this->channels_changed_count_ = 1; - this->channel_types_ = NULL; - this->channel_count_ = 0; - this->samples_per_frame_ = spf; - this->immediate_removal_ = true; - - this->mixer.bufs [2] = &this->bufs [2]; - this->mixer.bufs [0] = &this->bufs [0]; - this->mixer.bufs [1] = &this->bufs [1]; - - this->chan.center = &this->bufs [2].blip; - this->chan.left = &this->bufs [0].blip; - this->chan.right = &this->bufs [1].blip; -} - -blargg_err_t Buffer_set_sample_rate( struct Multi_Buffer* this, int rate, int msec ) -{ - int i; - for ( i = bufs_size; --i >= 0; ) - RETURN_ERR( Blip_set_sample_rate( &this->bufs [i].blip, rate, msec ) ); - - this->sample_rate_ = Blip_sample_rate( &this->bufs [0].blip ); - this->length_ = Blip_length( &this->bufs [0].blip ); - return 0; -} - -void Buffer_clock_rate( struct Multi_Buffer* this, int rate ) -{ - int i; - for ( i = bufs_size; --i >= 0; ) - Blip_set_clock_rate( &this->bufs [i].blip, rate ); -} - -void Buffer_bass_freq( struct Multi_Buffer* this, int bass ) -{ - int i; - for ( i = bufs_size; --i >= 0; ) - Blip_bass_freq( &this->bufs [i].blip, bass ); -} - -blargg_err_t Buffer_set_channel_count( struct Multi_Buffer* this, int n, int const* types ) -{ - this->channel_count_ = n; - this->channel_types_ = types; - return 0; -} - -struct channel_t Buffer_channel( struct Multi_Buffer* this, int i ) -{ - (void) i; - return this->chan; -} - -void Buffer_clear( struct Multi_Buffer* this ) -{ - int i; - this->mixer.samples_read = 0; - for ( i = bufs_size; --i >= 0; ) - Tracked_clear( &this->bufs [i] ); -} - -void Buffer_end_frame( struct Multi_Buffer* this, blip_time_t clock_count ) -{ - int i; - for ( i = bufs_size; --i >= 0; ) - Tracked_end_frame( &this->bufs [i], clock_count ); -} - -int Buffer_read_samples( struct Multi_Buffer* this, blip_sample_t out [], int out_size ) -{ - require( (out_size & 1) == 0 ); // must read an even number of samples - out_size = min( out_size, Buffer_samples_avail( this ) ); - - int pair_count = (int) (out_size >> 1); - if ( pair_count ) - { - Mixer_read_pairs( &this->mixer, out, pair_count ); - - if ( Buffer_samples_avail( this ) <= 0 || this->immediate_removal_ ) - { - int i; - for ( i = bufs_size; --i >= 0; ) - { - buf_t* b = &this->bufs [i]; - // TODO: might miss non-silence settling since it checks END of last read - if ( !Tracked_non_silent( b ) ) - Tracked_remove_silence( b, this->mixer.samples_read ); - else - Tracked_remove_samples( b, this->mixer.samples_read ); - } - this->mixer.samples_read = 0; - } - } - - return out_size; -} diff --git a/apps/codecs/libgme/multi_buffer.h b/apps/codecs/libgme/multi_buffer.h deleted file mode 100644 index e5efa5a230..0000000000 --- a/apps/codecs/libgme/multi_buffer.h +++ /dev/null @@ -1,114 +0,0 @@ -// Multi-channel sound buffer interface, stereo and effects buffers - -// Blip_Buffer 0.4.1 -#ifndef MULTI_BUFFER_H -#define MULTI_BUFFER_H - -#include "blargg_common.h" -#include "blip_buffer.h" - -// Get indexed channel, from 0 to channel count - 1 -struct channel_t { - struct Blip_Buffer* center; - struct Blip_Buffer* left; - struct Blip_Buffer* right; -}; - -enum { type_index_mask = 0xFF }; -enum { wave_type = 0x100, noise_type = 0x200, mixed_type = wave_type | noise_type }; -enum { stereo = 2 }; -enum { bufs_size = 3 }; - -// Tracked_Blip_Buffer -struct Tracked_Blip_Buffer { - struct Blip_Buffer blip; - int last_non_silence; -}; - -void Tracked_init( struct Tracked_Blip_Buffer* this ); -unsigned Tracked_non_silent( struct Tracked_Blip_Buffer* this ); -void Tracked_remove_all_samples( struct Tracked_Blip_Buffer * this ); -int Tracked_read_samples( struct Tracked_Blip_Buffer* this, blip_sample_t [], int ); -void Tracked_remove_silence( struct Tracked_Blip_Buffer* this, int ); -void Tracked_remove_samples( struct Tracked_Blip_Buffer* this, int ); -void Tracked_clear( struct Tracked_Blip_Buffer* this ); -void Tracked_end_frame( struct Tracked_Blip_Buffer* this, blip_time_t ); - -static inline delta_t unsettled( struct Blip_Buffer* this ) -{ - return this->reader_accum_ >> delta_bits; -} - -// Stereo Mixer -struct Stereo_Mixer { - struct Tracked_Blip_Buffer* bufs [3]; - int samples_read; -}; - -void Mixer_init( struct Stereo_Mixer* this ); -void Mixer_read_pairs( struct Stereo_Mixer* this, blip_sample_t out [], int count ); - -typedef struct Tracked_Blip_Buffer buf_t; - -// Multi_Buffer -struct Multi_Buffer { - unsigned channels_changed_count_; - int sample_rate_; - int length_; - int channel_count_; - int samples_per_frame_; - int const *channel_types_; - bool immediate_removal_; - - buf_t bufs [bufs_size]; - struct Stereo_Mixer mixer; - struct channel_t chan; -}; - -blargg_err_t Buffer_set_channel_count( struct Multi_Buffer* this, int n, int const* types ); - -// Buffers used for all channels -static inline struct Blip_Buffer* center( struct Multi_Buffer* this ) { return &this->bufs [2].blip; } -static inline struct Blip_Buffer* left( struct Multi_Buffer* this ) { return &this->bufs [0].blip; } -static inline struct Blip_Buffer* right( struct Multi_Buffer* this ) { return &this->bufs [1].blip; } - -// Initializes Multi_Buffer structure -void Buffer_init( struct Multi_Buffer* this ); - -blargg_err_t Buffer_set_sample_rate( struct Multi_Buffer* this, int, int msec ); -void Buffer_clock_rate( struct Multi_Buffer* this, int ); -void Buffer_bass_freq( struct Multi_Buffer* this, int ); -void Buffer_clear( struct Multi_Buffer* this ); -void Buffer_end_frame( struct Multi_Buffer* this, blip_time_t ) ICODE_ATTR; - -static inline int Buffer_length( struct Multi_Buffer* this ) -{ - return this->length_; -} - -// Count of changes to channel configuration. Incremented whenever -// a change is made to any of the Blip_Buffers for any channel. -static inline unsigned Buffer_channels_changed_count( struct Multi_Buffer* this ) -{ - return this->channels_changed_count_; -} - -static inline void Buffer_disable_immediate_removal( struct Multi_Buffer* this ) -{ - this->immediate_removal_ = false; -} - -static inline int Buffer_sample_rate( struct Multi_Buffer* this ) -{ - return this->sample_rate_; -} - -static inline int Buffer_samples_avail( struct Multi_Buffer* this ) -{ - return (Blip_samples_avail(&this->bufs [0].blip) - this->mixer.samples_read) * 2; -} - -int Buffer_read_samples( struct Multi_Buffer* this, blip_sample_t*, int ) ICODE_ATTR; -struct channel_t Buffer_channel( struct Multi_Buffer* this, int i ); - -#endif diff --git a/apps/codecs/libgme/nes_apu.c b/apps/codecs/libgme/nes_apu.c deleted file mode 100644 index b6c88bc7e7..0000000000 --- a/apps/codecs/libgme/nes_apu.c +++ /dev/null @@ -1,397 +0,0 @@ -// Nes_Snd_Emu 0.1.8. http://www.slack.net/~ant/ - -#include "nes_apu.h" - -/* Copyright (C) 2003-2006 Shay Green. This module is free software; you -can redistribute it and/or modify it under the terms of the GNU Lesser -General Public License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. This -module is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more -details. You should have received a copy of the GNU Lesser General Public -License along with this module; if not, write to the Free Software Foundation, -Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ - -#include "blargg_source.h" - -int const amp_range = 15; - -void Apu_init( struct Nes_Apu* this ) -{ - this->tempo_ = (int)(FP_ONE_TEMPO); - this->dmc.apu = this; - this->dmc.prg_reader = NULL; - this->irq_notifier_ = NULL; - - Synth_init( &this->square_synth ); - Synth_init( &this->triangle.synth ); - Synth_init( &this->noise.synth ); - Synth_init( &this->dmc.synth ); - - Square_set_synth( &this->square1, &this->square_synth ); - Square_set_synth( &this->square2, &this->square_synth ); - - this->oscs [0] = &this->square1.osc; - this->oscs [1] = &this->square2.osc; - this->oscs [2] = &this->triangle.osc; - this->oscs [3] = &this->noise.osc; - this->oscs [4] = &this->dmc.osc; - - Apu_output( this, NULL ); - this->dmc.nonlinear = false; - Apu_volume( this, (int)FP_ONE_VOLUME ); - Apu_reset( this, false, 0 ); -} - -#if 0 -// sq and tnd must use a fixed point frac where 1.0 = FP_ONE_VOLUME -void Apu_enable_nonlinear_( struct Nes_Apu* this, int sq, int tnd ) -{ - this->dmc.nonlinear = true; - Synth_volume( &this->square_synth, sq ); - - Synth_volume( &this->triangle.synth, (int)((long long)(FP_ONE_VOLUME * 2.752) * tnd / FP_ONE_VOLUME) ); - Synth_volume( &this->noise.synth , (int)((long long)(FP_ONE_VOLUME * 1.849) * tnd / FP_ONE_VOLUME) ); - Synth_volume( &this->dmc.synth , tnd ); - - this->square1 .osc.last_amp = 0; - this->square2 .osc.last_amp = 0; - this->triangle.osc.last_amp = 0; - this->noise .osc.last_amp = 0; - this->dmc .osc.last_amp = 0; -} -#endif - -void Apu_volume( struct Nes_Apu* this, int v ) -{ - if ( !this->dmc.nonlinear ) - { - Synth_volume( &this->square_synth, (int)((long long)((0.125 / 1.11) * FP_ONE_VOLUME) * v / amp_range / FP_ONE_VOLUME) ); // was 0.1128 1.108 - Synth_volume( &this->triangle.synth,(int)((long long)((0.150 / 1.11) * FP_ONE_VOLUME) * v / amp_range / FP_ONE_VOLUME) ); // was 0.12765 1.175 - Synth_volume( &this->noise.synth, (int)((long long)((0.095 / 1.11) * FP_ONE_VOLUME) * v / amp_range / FP_ONE_VOLUME) ); // was 0.0741 1.282 - Synth_volume( &this->dmc.synth, (int)((long long)((0.450 / 1.11) * FP_ONE_VOLUME) * v / 2048 / FP_ONE_VOLUME) ); // was 0.42545 1.058 - } -} - -void Apu_output( struct Nes_Apu* this, struct Blip_Buffer* buffer ) -{ - int i; - for ( i = 0; i < apu_osc_count; i++ ) - Apu_osc_output( this, i, buffer ); -} - -void Apu_set_tempo( struct Nes_Apu* this, int t ) -{ - this->tempo_ = t; - this->frame_period = (this->dmc.pal_mode ? 8314 : 7458); - if ( t != (int)FP_ONE_TEMPO ) - this->frame_period = (int) ((this->frame_period * FP_ONE_TEMPO) / t) & ~1; // must be even -} - -void Apu_reset( struct Nes_Apu* this, bool pal_mode, int initial_dmc_dac ) -{ - this->dmc.pal_mode = pal_mode; - Apu_set_tempo( this, this->tempo_ ); - - Square_reset( &this->square1 ); - Square_reset( &this->square2 ); - Triangle_reset( &this->triangle ); - Noise_reset( &this->noise ); - Dmc_reset( &this->dmc ); - - this->last_time = 0; - this->last_dmc_time = 0; - this->osc_enables = 0; - this->irq_flag = false; - this->earliest_irq_ = apu_no_irq; - this->frame_delay = 1; - Apu_write_register( this, 0, 0x4017, 0x00 ); - Apu_write_register( this, 0, 0x4015, 0x00 ); - - addr_t addr; - for ( addr = apu_io_addr; addr <= 0x4013; addr++ ) - Apu_write_register( this, 0, addr, (addr & 3) ? 0x00 : 0x10 ); - - this->dmc.dac = initial_dmc_dac; - if ( !this->dmc.nonlinear ) - this->triangle.osc.last_amp = 15; - if ( !this->dmc.nonlinear ) // TODO: remove? - this->dmc.osc.last_amp = initial_dmc_dac; // prevent output transition -} - -void Apu_irq_changed( struct Nes_Apu* this ) -{ - nes_time_t new_irq = this->dmc.next_irq; - if ( this->dmc.irq_flag | this->irq_flag ) { - new_irq = 0; - } - else if ( new_irq > this->next_irq ) { - new_irq = this->next_irq; - } - - if ( new_irq != this->earliest_irq_ ) { - this->earliest_irq_ = new_irq; - if ( this->irq_notifier_ ) - this->irq_notifier_( this->irq_data ); - } -} - -// frames - -void Apu_run_until( struct Nes_Apu* this, nes_time_t end_time ) -{ - require( end_time >= this->last_dmc_time ); - if ( end_time > Apu_next_dmc_read_time( this ) ) - { - nes_time_t start = this->last_dmc_time; - this->last_dmc_time = end_time; - Dmc_run( &this->dmc, start, end_time ); - } -} - -static void run_until_( struct Nes_Apu* this, nes_time_t end_time ) -{ - require( end_time >= this->last_time ); - - if ( end_time == this->last_time ) - return; - - if ( this->last_dmc_time < end_time ) - { - nes_time_t start = this->last_dmc_time; - this->last_dmc_time = end_time; - Dmc_run( &this->dmc, start, end_time ); - } - - while ( true ) - { - // earlier of next frame time or end time - nes_time_t time = this->last_time + this->frame_delay; - if ( time > end_time ) - time = end_time; - this->frame_delay -= time - this->last_time; - - // run oscs to present - Square_run( &this->square1, this->last_time, time ); - Square_run( &this->square2, this->last_time, time ); - Triangle_run( &this->triangle, this->last_time, time ); - Noise_run( &this->noise, this->last_time, time ); - this->last_time = time; - - if ( time == end_time ) - break; // no more frames to run - - // take frame-specific actions - this->frame_delay = this->frame_period; - switch ( this->frame++ ) - { - case 0: - if ( !(this->frame_mode & 0xC0) ) { - this->next_irq = time + this->frame_period * 4 + 2; - this->irq_flag = true; - } - // fall through - case 2: - // clock length and sweep on frames 0 and 2 - Osc_clock_length( &this->square1.osc, 0x20 ); - Osc_clock_length( &this->square2.osc, 0x20 ); - Osc_clock_length( &this->noise.osc, 0x20 ); - Osc_clock_length( &this->triangle.osc, 0x80 ); // different bit for halt flag on triangle - - Square_clock_sweep( &this->square1, -1 ); - Square_clock_sweep( &this->square2, 0 ); - - // frame 2 is slightly shorter in mode 1 - if ( this->dmc.pal_mode && this->frame == 3 ) - this->frame_delay -= 2; - break; - - case 1: - // frame 1 is slightly shorter in mode 0 - if ( !this->dmc.pal_mode ) - this->frame_delay -= 2; - break; - - case 3: - this->frame = 0; - - // frame 3 is almost twice as long in mode 1 - if ( this->frame_mode & 0x80 ) - this->frame_delay += this->frame_period - (this->dmc.pal_mode ? 2 : 6); - break; - } - - // clock envelopes and linear counter every frame - Triangle_clock_linear_counter( &this->triangle ); - Square_clock_envelope( &this->square1 ); - Square_clock_envelope( &this->square2 ); - Noise_clock_envelope( &this->noise ); - } -} - -static inline void zero_apu_osc( struct Nes_Osc* osc, struct Blip_Synth* synth, nes_time_t time ) -{ - struct Blip_Buffer* output = osc->output; - int last_amp = osc->last_amp; - osc->last_amp = 0; - if ( output && last_amp ) - Synth_offset( synth, time, -osc->last_amp, output ); -} - -void Apu_end_frame( struct Nes_Apu* this, nes_time_t end_time ) -{ - if ( end_time > this->last_time ) - run_until_( this, end_time ); - - if ( this->dmc.nonlinear ) - { - zero_apu_osc( &this->square1.osc, this->square1.synth, this->last_time ); - zero_apu_osc( &this->square2.osc, this->square2.synth, this->last_time ); - zero_apu_osc( &this->triangle.osc, &this->triangle.synth, this->last_time ); - zero_apu_osc( &this->noise.osc, &this->noise.synth, this->last_time ); - zero_apu_osc( &this->dmc.osc, &this->dmc.synth, this->last_time ); - } - - // make times relative to new frame - this->last_time -= end_time; - require( this->last_time >= 0 ); - - this->last_dmc_time -= end_time; - require( this->last_dmc_time >= 0 ); - - if ( this->next_irq != apu_no_irq ) { - this->next_irq -= end_time; - check( this->next_irq >= 0 ); - } - if ( this->dmc.next_irq != apu_no_irq ) { - this->dmc.next_irq -= end_time; - check( this->dmc.next_irq >= 0 ); - } - if ( this->earliest_irq_ != apu_no_irq ) { - this->earliest_irq_ -= end_time; - if ( this->earliest_irq_ < 0 ) - this->earliest_irq_ = 0; - } -} - -// registers - -static const unsigned char length_table [0x20] = { - 0x0A, 0xFE, 0x14, 0x02, 0x28, 0x04, 0x50, 0x06, - 0xA0, 0x08, 0x3C, 0x0A, 0x0E, 0x0C, 0x1A, 0x0E, - 0x0C, 0x10, 0x18, 0x12, 0x30, 0x14, 0x60, 0x16, - 0xC0, 0x18, 0x48, 0x1A, 0x10, 0x1C, 0x20, 0x1E -}; - -void Apu_write_register( struct Nes_Apu* this, nes_time_t time, addr_t addr, int data ) -{ - require( addr > 0x20 ); // addr must be actual address (i.e. 0x40xx) - require( (unsigned) data <= 0xFF ); - - // Ignore addresses outside range - if ( (unsigned) (addr - apu_io_addr) >= apu_io_size ) - return; - - run_until_( this, time ); - - if ( addr < 0x4014 ) - { - // Write to channel - int osc_index = (addr - apu_io_addr) >> 2; - struct Nes_Osc* osc = this->oscs [osc_index]; - - int reg = addr & 3; - osc->regs [reg] = data; - osc->reg_written [reg] = true; - - if ( osc_index == 4 ) - { - // handle DMC specially - Dmc_write_register( &this->dmc, reg, data ); - } - else if ( reg == 3 ) - { - // load length counter - if ( (this->osc_enables >> osc_index) & 1 ) - osc->length_counter = length_table [(data >> 3) & 0x1F]; - - // reset square phase - if ( osc_index == 0 ) this->square1.phase = square_phase_range - 1; - else if ( osc_index == 1 ) this->square2.phase = square_phase_range - 1; - } - } - else if ( addr == 0x4015 ) - { - // Channel enables - int i; - for ( i = apu_osc_count; i--; ) - if ( !((data >> i) & 1) ) - this->oscs [i]->length_counter = 0; - - bool recalc_irq = this->dmc.irq_flag; - this->dmc.irq_flag = false; - - int old_enables = this->osc_enables; - this->osc_enables = data; - if ( !(data & 0x10) ) { - this->dmc.next_irq = apu_no_irq; - recalc_irq = true; - } - else if ( !(old_enables & 0x10) ) { - Dmc_start( &this->dmc ); // dmc just enabled - } - - if ( recalc_irq ) - Apu_irq_changed( this ); - } - else if ( addr == 0x4017 ) - { - // Frame mode - this->frame_mode = data; - - bool irq_enabled = !(data & 0x40); - this->irq_flag &= irq_enabled; - this->next_irq = apu_no_irq; - - // mode 1 - this->frame_delay = (this->frame_delay & 1); - this->frame = 0; - - if ( !(data & 0x80) ) - { - // mode 0 - this->frame = 1; - this->frame_delay += this->frame_period; - if ( irq_enabled ) - this->next_irq = time + this->frame_delay + this->frame_period * 3 + 1; - } - - Apu_irq_changed( this ); - } -} - -int Apu_read_status( struct Nes_Apu* this, nes_time_t time ) -{ - run_until_( this, time - 1 ); - - int result = (this->dmc.irq_flag << 7) | (this->irq_flag << 6); - - int i; - for ( i = 0; i < apu_osc_count; i++ ) - if ( this->oscs [i]->length_counter ) - result |= 1 << i; - - run_until_( this, time ); - - if ( this->irq_flag ) - { - result |= 0x40; - this->irq_flag = false; - Apu_irq_changed( this ); - } - - //debug_printf( "%6d/%d Read $4015->$%02X\n", frame_delay, frame, result ); - - return result; -} diff --git a/apps/codecs/libgme/nes_apu.h b/apps/codecs/libgme/nes_apu.h deleted file mode 100644 index 152ec94a17..0000000000 --- a/apps/codecs/libgme/nes_apu.h +++ /dev/null @@ -1,137 +0,0 @@ -// NES 2A03 APU sound chip emulator - -// Nes_Snd_Emu 0.2.0-pre -#ifndef NES_APU_H -#define NES_APU_H - -#include "blargg_common.h" -#include "nes_oscs.h" - -enum { apu_status_addr = 0x4015 }; -enum { apu_osc_count = 5 }; -enum { apu_no_irq = INT_MAX/2 + 1 }; -enum { apu_irq_waiting = 0 }; - -enum { apu_io_addr = 0x4000 }; -enum { apu_io_size = 0x18 }; - -struct apu_state_t; - -struct Nes_Apu { - int tempo_; - nes_time_t last_time; // has been run until this time in current frame - nes_time_t last_dmc_time; - nes_time_t earliest_irq_; - nes_time_t next_irq; - int frame_period; - int frame_delay; // cycles until frame counter runs next - int frame; // current frame (0-3) - int osc_enables; - int frame_mode; - bool irq_flag; - - void (*irq_notifier_)( void* user_data ); - void* irq_data; - - Synth square_synth; // shared by squares - - struct Nes_Osc* oscs [apu_osc_count]; - struct Nes_Square square1; - struct Nes_Square square2; - struct Nes_Noise noise; - struct Nes_Triangle triangle; - struct Nes_Dmc dmc; -}; - -// Init Nes apu -void Apu_init( struct Nes_Apu* this ); - -// Set buffer to generate all sound into, or disable sound if NULL -void Apu_output( struct Nes_Apu* this, struct Blip_Buffer* ); - -// All time values are the number of cpu clock cycles relative to the -// beginning of the current time frame. Before resetting the cpu clock -// count, call end_frame( last_cpu_time ). - -// Write to register (0x4000-0x4017, except 0x4014 and 0x4016) -void Apu_write_register( struct Nes_Apu* this, nes_time_t, addr_t, int data ); - -// Read from status register at 0x4015 -int Apu_read_status( struct Nes_Apu* this, nes_time_t ); - -// Run all oscillators up to specified time, end current time frame, then -// start a new time frame at time 0. Time frames have no effect on emulation -// and each can be whatever length is convenient. -void Apu_end_frame( struct Nes_Apu* this, nes_time_t ); - -// Additional optional features (can be ignored without any problem) - -// Reset internal frame counter, registers, and all oscillators. -// Use PAL timing if pal_timing is true, otherwise use NTSC timing. -// Set the DMC oscillator's initial DAC value to initial_dmc_dac without -// any audible click. -void Apu_reset( struct Nes_Apu* this, bool pal_mode, int initial_dmc_dac ); - -// Adjust frame period -void Apu_set_tempo( struct Nes_Apu* this, int ); - -// Set overall volume (default is 1.0) -void Apu_volume( struct Nes_Apu* this, int ); - -// Run DMC until specified time, so that any DMC memory reads can be -// accounted for (i.e. inserting cpu wait states). -void Apu_run_until( struct Nes_Apu* this, nes_time_t ); - -// Set sound output of specific oscillator to buffer. If buffer is NULL, -// the specified oscillator is muted and emulation accuracy is reduced. -// The oscillators are indexed as follows: 0) Square 1, 1) Square 2, -// 2) Triangle, 3) Noise, 4) DMC. -static inline void Apu_osc_output( struct Nes_Apu* this, int osc, struct Blip_Buffer* buf ) -{ - assert( (unsigned) osc < apu_osc_count ); - this->oscs [osc]->output = buf; -} - -// Set memory reader callback used by DMC oscillator to fetch samples. -// When callback is invoked, 'user_data' is passed unchanged as the -// first parameter. -static inline void Apu_dmc_reader( struct Nes_Apu* this, int (*func)( void*, addr_t ), void* user_data ) -{ - this->dmc.prg_reader_data = user_data; - this->dmc.prg_reader = func; -} - -// Set IRQ time callback that is invoked when the time of earliest IRQ -// may have changed, or NULL to disable. When callback is invoked, -// 'user_data' is passed unchanged as the first parameter. -static inline void Apu_irq_notifier( struct Nes_Apu* this, void (*func)( void* user_data ), void* user_data ) -{ - this->irq_notifier_ = func; - this->irq_data = user_data; -} - -// Count number of DMC reads that would occur if 'run_until( t )' were executed. -// If last_read is not NULL, set *last_read to the earliest time that -// 'count_dmc_reads( time )' would result in the same result. -static inline int Apu_count_dmc_reads( struct Nes_Apu* this, nes_time_t time, nes_time_t* last_read ) -{ - return Dmc_count_reads( &this->dmc, time, last_read ); -} - -static inline nes_time_t Dmc_next_read_time( struct Nes_Dmc* this ) -{ - if ( this->osc.length_counter == 0 ) - return apu_no_irq; // not reading - - return this->apu->last_dmc_time + this->osc.delay + (this->bits_remain - 1) * this->period; -} - -// Time when next DMC memory read will occur -static inline nes_time_t Apu_next_dmc_read_time( struct Nes_Apu* this ) { return Dmc_next_read_time( &this->dmc ); } -void Apu_irq_changed( struct Nes_Apu* this ); - -#if 0 -// Experimental -void Apu_enable_nonlinear_( struct Nes_Apu* this, int sq, int tnd ); -#endif -#endif diff --git a/apps/codecs/libgme/nes_cpu.c b/apps/codecs/libgme/nes_cpu.c deleted file mode 100644 index 20925918c2..0000000000 --- a/apps/codecs/libgme/nes_cpu.c +++ /dev/null @@ -1,62 +0,0 @@ -// Game_Music_Emu 0.6-pre. http://www.slack.net/~ant/ - -#include "nes_cpu.h" - -#include "blargg_endian.h" - -/* Copyright (C) 2003-2008 Shay Green. This module is free software; you -can redistribute it and/or modify it under the terms of the GNU Lesser -General Public License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. This -module is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more -details. You should have received a copy of the GNU Lesser General Public -License along with this module; if not, write to the Free Software Foundation, -Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ - -#include "blargg_source.h" - -static inline void set_code_page( struct Nes_Cpu* this, int i, void const* p ) -{ - byte const* p2 = STATIC_CAST(byte const*,p) - NES_CPU_OFFSET( i * page_size ); - this->cpu_state->code_map [i] = p2; - this->cpu_state_.code_map [i] = p2; -} - -void Cpu_map_code( struct Nes_Cpu* this, addr_t start, int size, void const* data, int mirror_size ) -{ - // address range must begin and end on page boundaries - require( start % page_size == 0 ); - require( size % page_size == 0 ); - require( start + size <= 0x10000 ); - require( mirror_size % page_size == 0 ); - - int offset; - for ( offset = 0; offset < size; offset += page_size ) - set_code_page( this, NES_CPU_PAGE( start + offset ), - STATIC_CAST(char const*,data) + (offset & ((unsigned) mirror_size - 1)) ); -} - -void Cpu_reset( struct Nes_Cpu* this, void const* unmapped_page ) -{ - check( this->cpu_state == &this->cpu_state_ ); - this->cpu_state = &this->cpu_state_; - - this->r.flags = irq_inhibit_mask; - this->r.sp = 0xFF; - this->r.pc = 0; - this->r.a = 0; - this->r.x = 0; - this->r.y = 0; - - this->cpu_state_.time = 0; - this->cpu_state_.base = 0; - this->irq_time = future_time; - this->end_time = future_time; - - set_code_page( this, page_count, unmapped_page ); - Cpu_map_code( this, 0, 0x10000, unmapped_page, page_size ); - - blargg_verify_byte_order(); -} diff --git a/apps/codecs/libgme/nes_cpu.h b/apps/codecs/libgme/nes_cpu.h deleted file mode 100644 index e4538cd00c..0000000000 --- a/apps/codecs/libgme/nes_cpu.h +++ /dev/null @@ -1,109 +0,0 @@ -// NES cpu emulator - -// Game_Music_Emu 0.6-pre -#ifndef NES_CPU_H -#define NES_CPU_H - -#include "blargg_common.h" -#include "blargg_source.h" - -typedef int nes_time_t; -typedef int addr_t; - -enum { page_bits = 11 }; -enum { page_size = 1 << page_bits }; -enum { page_count = 0x10000 >> page_bits }; - -// Unmapped page should be filled with this -enum { halt_opcode = 0x22 }; - -enum { future_time = INT_MAX/2 + 1 }; -enum { irq_inhibit_mask = 0x04 }; - -// Can read this many bytes past end of a page -enum { cpu_padding = 8 }; - -struct registers_t { - uint16_t pc; - uint8_t a; - uint8_t x; - uint8_t y; - uint8_t flags; - uint8_t sp; -}; - -struct cpu_state_t { - uint8_t const* code_map [page_count + 1]; - nes_time_t base; - int time; -}; - -struct Nes_Cpu { - // NES 6502 registers. NOT kept updated during emulation. - struct registers_t r; - nes_time_t irq_time; - nes_time_t end_time; - - struct cpu_state_t* cpu_state; // points to cpu_state_ or a local copy - struct cpu_state_t cpu_state_; -}; - -static inline void Cpu_init( struct Nes_Cpu* this ) -{ - this->cpu_state = &this->cpu_state_; -} - -// Clears registers and maps all pages to unmapped_page -void Cpu_reset( struct Nes_Cpu* this, void const* unmapped_page ); - -// Maps code memory (memory accessed via the program counter). Start and size -// must be multiple of page_size. If mirror_size is non-zero, the first -// mirror_size bytes are repeated over the range. mirror_size must be a -// multiple of page_size. -void Cpu_map_code( struct Nes_Cpu* this, addr_t start, int size, void const* code, int mirror_size ); - -// Time of beginning of next instruction to be executed -static inline nes_time_t Cpu_time( struct Nes_Cpu* this ) { return this->cpu_state->time + this->cpu_state->base; } -static inline void Cpu_set_time( struct Nes_Cpu* this, nes_time_t t ) { this->cpu_state->time = t - this->cpu_state->base; } -static inline void Cpu_adjust_time( struct Nes_Cpu* this, int delta ) { this->cpu_state->time += delta; } - -// Clocks past end (negative if before) -static inline int Cpu_time_past_end( struct Nes_Cpu* this ) { return this->cpu_state->time; } - -#define NES_CPU_PAGE( addr ) ((unsigned) (addr) >> page_bits) - -#ifdef BLARGG_NONPORTABLE - #define NES_CPU_OFFSET( addr ) (addr) -#else - #define NES_CPU_OFFSET( addr ) ((addr) & (page_size - 1)) -#endif - -// Accesses emulated memory as cpu does -static inline uint8_t const* Cpu_get_code( struct Nes_Cpu* this, addr_t addr ) -{ - return this->cpu_state_.code_map [NES_CPU_PAGE( addr )] + NES_CPU_OFFSET( addr ); -} - -static inline void Cpu_update_end_time( struct Nes_Cpu* this, nes_time_t end, nes_time_t irq ) -{ - if ( end > irq && !(this->r.flags & irq_inhibit_mask) ) - end = irq; - - this->cpu_state->time += this->cpu_state->base - end; - this->cpu_state->base = end; -} - -// Time of next IRQ -static inline void Cpu_set_irq_time( struct Nes_Cpu* this, nes_time_t t ) -{ - this->irq_time = t; - Cpu_update_end_time( this, this->end_time, t ); -} - -static inline void Cpu_set_end_time( struct Nes_Cpu* this, nes_time_t t ) -{ - this->end_time = t; - Cpu_update_end_time( this, t, this->irq_time ); -} - -#endif diff --git a/apps/codecs/libgme/nes_cpu_run.h b/apps/codecs/libgme/nes_cpu_run.h deleted file mode 100644 index fd1fea9659..0000000000 --- a/apps/codecs/libgme/nes_cpu_run.h +++ /dev/null @@ -1,1122 +0,0 @@ -// NES 6502 cpu emulator run function - -#if 0 -/* Define these macros in the source file before #including this file. -- Parameters might be expressions, so they are best evaluated only once, -though they NEVER have side-effects, so multiple evaluation is OK. -- Output parameters might be a multiple-assignment expression like "a=x", -so they must NOT be parenthesized. -- Except where noted, time() and related functions will NOT work -correctly inside a macro. TIME() is always correct, and FLUSH_TIME() and -CACHE_TIME() allow the time changing functions to work. -- Macros "returning" void may use a {} statement block. */ - - // 0 <= addr <= 0xFFFF + page_size - // time functions can be used - int READ_MEM( addr_t ); - void WRITE_MEM( addr_t, int data ); - // 0 <= READ_MEM() <= 0xFF - - // 0 <= addr <= 0x1FF - int READ_LOW( addr_t ); - void WRITE_LOW( addr_t, int data ); - // 0 <= READ_LOW() <= 0xFF - - // Often-used instructions attempt these before using a normal memory access. - // Optional; defaults to READ_MEM() and WRITE_MEM() - bool CAN_READ_FAST( addr_t ); // if true, uses result of READ_FAST - void READ_FAST( addr_t, int& out ); // ALWAYS called BEFORE CAN_READ_FAST - bool CAN_WRITE_FAST( addr_t ); // if true, uses WRITE_FAST instead of WRITE_MEM - void WRITE_FAST( addr_t, int data ); - - // Used by instructions most often used to access the NES PPU (LDA abs and BIT abs). - // Optional; defaults to READ_MEM. - void READ_PPU( addr_t, int& out ); - // 0 <= out <= 0xFF - -// The following can be used within macros: - - // Current time - time_t TIME(); - - // Allows use of time functions - void FLUSH_TIME(); - - // Must be used before end of macro if FLUSH_TIME() was used earlier - void CACHE_TIME(); - -// Configuration (optional; commented behavior if defined) - - // Emulates dummy reads for indexed instructions - #define NES_CPU_DUMMY_READS 1 - - // Optimizes as if map_code( 0, 0x10000 + cpu_padding, FLAT_MEM ) is always in effect - #define FLAT_MEM my_mem_array - - // Expanded just before beginning of code, to help debugger - #define CPU_BEGIN void my_run_cpu() { - -#endif - -/* Copyright (C) 2003-2008 Shay Green. This module is free software; you -can redistribute it and/or modify it under the terms of the GNU Lesser -General Public License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. This -module is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more -details. You should have received a copy of the GNU Lesser General Public -License along with this module; if not, write to the Free Software Foundation, -Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ - -// Allows MWCW debugger to step through code properly -#ifdef CPU_BEGIN - CPU_BEGIN -#endif - -// Time -#define TIME() (s_time + s.base) -#define FLUSH_TIME() {s.time = s_time - time_offset;} -#define CACHE_TIME() {s_time = s.time + time_offset;} - -// Defaults -#ifndef CAN_WRITE_FAST - #define CAN_WRITE_FAST( addr ) 0 - #define WRITE_FAST( addr, data ) -#endif - -#ifndef CAN_READ_FAST - #define CAN_READ_FAST( addr ) 0 - #define READ_FAST( addr, out ) -#endif - -#ifndef READ_PPU - #define READ_PPU( addr, out )\ - {\ - FLUSH_TIME();\ - out = READ_MEM( addr );\ - CACHE_TIME();\ - } -#endif - -#define READ_STACK READ_LOW -#define WRITE_STACK WRITE_LOW - -// Dummy reads -#ifdef NES_CPU_DUMMY_READS - // TODO: optimize time handling - #define DUMMY_READ( addr, idx ) \ - if ( (addr & 0xFF) < idx )\ - {\ - int const time_offset = 1;\ - FLUSH_TIME();\ - READ_MEM( (addr - 0x100) );\ - CACHE_TIME();\ - } -#else - #define DUMMY_READ( addr, idx ) -#endif - -// Code -#ifdef FLAT_MEM - #define CODE_PAGE( addr ) (FLAT_MEM) - #define CODE_OFFSET( addr ) (addr) -#else - #define CODE_PAGE( addr ) (s.code_map [NES_CPU_PAGE( addr )]) - #define CODE_OFFSET( addr ) NES_CPU_OFFSET( addr ) -#endif -#define READ_CODE( addr ) (CODE_PAGE( addr ) [CODE_OFFSET( addr )]) - -// Stack -#define SET_SP( v ) (sp = ((v) + 1) | 0x100) -#define GET_SP() ((sp - 1) & 0xFF) -#define SP( o ) ((sp + (o - (o>0)*0x100)) | 0x100) - -// Truncation -#define BYTE( n ) ((uint8_t ) (n)) /* (unsigned) n & 0xFF */ -#define SBYTE( n ) ((int8_t ) (n)) /* (BYTE( n ) ^ 0x80) - 0x80 */ -#define WORD( n ) ((uint16_t) (n)) /* (unsigned) n & 0xFFFF */ - -// Flags with hex value for clarity when used as mask. -// Stored in indicated variable during emulation. -int const n80 = 0x80; // nz -int const v40 = 0x40; // flags -int const r20 = 0x20; -int const b10 = 0x10; -int const d08 = 0x08; // flags -int const i04 = 0x04; // flags -int const z02 = 0x02; // nz -int const c01 = 0x01; // c - -#define IS_NEG (nz & 0x8080) - -#define GET_FLAGS( out ) \ -{\ - out = flags & (v40 | d08 | i04);\ - out += ((nz >> 8) | nz) & n80;\ - out += c >> 8 & c01;\ - if ( !BYTE( nz ) )\ - out += z02;\ -} - -#define SET_FLAGS( in ) \ -{\ - flags = in & (v40 | d08 | i04);\ - c = nz = in << 8;\ - nz += ~in & z02;\ -} - -{ - int const time_offset = 0; - - // Local state - struct cpu_state_t s; - #ifdef FLAT_MEM - s.base = cpu->cpu_state_.base; - #else - s = cpu->cpu_state_; - #endif - cpu->cpu_state = &s; - int s_time = cpu->cpu_state_.time; // helps even on x86 - - // Registers - int pc = cpu->r.pc; - int a = cpu->r.a; - int x = cpu->r.x; - int y = cpu->r.y; - int sp; - SET_SP( cpu->r.sp ); - - // Flags - int flags; - int c; // carry set if (c & 0x100) != 0 - int nz; // Z set if (nz & 0xFF) == 0, N set if (nz & 0x8080) != 0 - { - int temp = cpu->r.flags; - SET_FLAGS( temp ); - } - -loop: - - // Check all values - check( (unsigned) sp - 0x100 < 0x100 ); - check( (unsigned) pc < 0x10000 ); - check( (unsigned) a < 0x100 ); - check( (unsigned) x < 0x100 ); - check( (unsigned) y < 0x100 ); - - // Read instruction - byte const* instr = CODE_PAGE( pc ); - int opcode; - - if ( CODE_OFFSET(~0) == ~0 ) - { - opcode = instr [pc]; - pc++; - instr += pc; - } - else - { - instr += CODE_OFFSET( pc ); - opcode = *instr++; - pc++; - } - - // local to function in case it helps optimizer - static byte const clock_table [256] = - {// 0 1 2 3 4 5 6 7 8 9 A B C D E F - 0,6,2,8,3,3,5,5,3,2,2,2,4,4,6,6,// 0 - 2,5,2,8,4,4,6,6,2,4,2,7,4,4,7,7,// 1 - 6,6,0,8,3,3,5,5,4,2,2,2,4,4,6,6,// 2 - 2,5,2,8,4,4,6,6,2,4,2,7,4,4,7,7,// 3 - 6,6,2,8,3,3,5,5,3,2,2,2,3,4,6,6,// 4 - 2,5,2,8,4,4,6,6,2,4,2,7,4,4,7,7,// 5 - 6,6,2,8,3,3,5,5,4,2,2,2,5,4,6,6,// 6 - 2,5,2,8,4,4,6,6,2,4,2,7,4,4,7,7,// 7 - 2,6,2,6,3,3,3,3,2,2,2,2,4,4,4,4,// 8 - 2,6,2,6,4,4,4,4,2,5,2,5,5,5,5,5,// 9 - 2,6,2,6,3,3,3,3,2,2,2,2,4,4,4,4,// A - 2,5,2,5,4,4,4,4,2,4,2,4,4,4,4,4,// B - 2,6,2,8,3,3,5,5,2,2,2,2,4,4,6,6,// C - 2,5,2,8,4,4,6,6,2,4,2,7,4,4,7,7,// D - 2,6,2,8,3,3,5,5,2,2,2,2,4,4,6,6,// E - 2,5,2,8,4,4,6,6,2,4,2,7,4,4,7,7 // F - }; // 0x00 was 7 and 0x22 was 2 - - // Update time - if ( s_time >= 0 ) - goto out_of_time; - - #ifdef CPU_INSTR_HOOK - { CPU_INSTR_HOOK( (pc-1), (&instr [-1]), a, x, y, GET_SP(), TIME() ); } - #endif - - s_time += clock_table [opcode]; - - int data; - data = *instr; - - switch ( opcode ) - { - -// Macros - -#define GET_MSB() (instr [1]) -#define ADD_PAGE( out ) (pc++, out = data + 0x100 * GET_MSB()) -#define GET_ADDR() GET_LE16( instr ) - -#define PAGE_PENALTY( lsb ) s_time += (lsb) >> 8; - -#define INC_DEC( reg, n ) reg = BYTE( nz = reg + n ); goto loop; - -#define IND_Y( cross, out ) {\ - int temp = READ_LOW( data ) + y;\ - out = temp + 0x100 * READ_LOW( BYTE( data + 1 ) );\ - cross( temp );\ - } - -#define IND_X( out ) {\ - int temp = data + x;\ - out = 0x100 * READ_LOW( BYTE( temp + 1 ) ) + READ_LOW( BYTE( temp ) );\ - } - -#define ARITH_ADDR_MODES( op )\ -case op - 0x04: /* (ind,x) */\ - IND_X( data )\ - goto ptr##op;\ -case op + 0x0C: /* (ind),y */\ - IND_Y( PAGE_PENALTY, data )\ - goto ptr##op;\ -case op + 0x10: /* zp,X */\ - data = BYTE( data + x );\ -case op + 0x00: /* zp */\ - data = READ_LOW( data );\ - goto imm##op;\ -case op + 0x14: /* abs,Y */\ - data += y;\ - goto ind##op;\ -case op + 0x18: /* abs,X */\ - data += x;\ -ind##op:\ - PAGE_PENALTY( data );\ -case op + 0x08: /* abs */\ - ADD_PAGE( data );\ -ptr##op:\ - FLUSH_TIME();\ - data = READ_MEM( data );\ - CACHE_TIME();\ -case op + 0x04: /* imm */\ -imm##op: - -// TODO: more efficient way to handle negative branch that wraps PC around -#define BRANCH( cond )\ -{\ - ++pc;\ - if ( !(cond) ) goto loop;\ - s_time++;\ - int offset = SBYTE( data );\ - s_time += (BYTE(pc) + offset) >> 8 & 1;\ - pc = WORD( pc + offset );\ - goto loop;\ -} - -// Often-Used - - case 0xB5: // LDA zp,x - a = nz = READ_LOW( BYTE( data + x ) ); - pc++; - goto loop; - - case 0xA5: // LDA zp - a = nz = READ_LOW( data ); - pc++; - goto loop; - - case 0xD0: // BNE - BRANCH( BYTE( nz ) ); - - case 0x20: { // JSR - int temp = pc + 1; - pc = GET_ADDR(); - WRITE_STACK( SP( -1 ), temp >> 8 ); - sp = SP( -2 ); - WRITE_STACK( sp, temp ); - goto loop; - } - - case 0x4C: // JMP abs - pc = GET_ADDR(); - goto loop; - - case 0xE8: // INX - INC_DEC( x, 1 ) - - case 0x10: // BPL - BRANCH( !IS_NEG ) - - ARITH_ADDR_MODES( 0xC5 ) // CMP - nz = a - data; - pc++; - c = ~nz; - nz &= 0xFF; - goto loop; - - case 0x30: // BMI - BRANCH( IS_NEG ) - - case 0xF0: // BEQ - BRANCH( !BYTE( nz ) ); - - case 0x95: // STA zp,x - data = BYTE( data + x ); - case 0x85: // STA zp - pc++; - WRITE_LOW( data, a ); - goto loop; - - case 0xC8: // INY - INC_DEC( y, 1 ) - - case 0xA8: // TAY - y = a; - nz = a; - goto loop; - - case 0x98: // TYA - a = y; - nz = y; - goto loop; - - case 0xAD:{// LDA abs - int addr = GET_ADDR(); - pc += 2; - READ_PPU( addr, a = nz ); - goto loop; - } - - case 0x60: // RTS - pc = 1 + READ_STACK( sp ); - pc += 0x100 * READ_STACK( SP( 1 ) ); - sp = SP( 2 ); - goto loop; - - { - int addr; - - case 0x8D: // STA abs - addr = GET_ADDR(); - pc += 2; - if ( CAN_WRITE_FAST( addr ) ) - { - WRITE_FAST( addr, a ); - goto loop; - } - sta_ptr: - FLUSH_TIME(); - WRITE_MEM( addr, a ); - CACHE_TIME(); - goto loop; - - case 0x99: // STA abs,Y - addr = y + GET_ADDR(); - pc += 2; - if ( CAN_WRITE_FAST( addr ) ) - { - WRITE_FAST( addr, a ); - goto loop; - } - goto sta_abs_x; - - case 0x9D: // STA abs,X (slightly more common than STA abs) - addr = x + GET_ADDR(); - pc += 2; - if ( CAN_WRITE_FAST( addr ) ) - { - WRITE_FAST( addr, a ); - goto loop; - } - DUMMY_READ( addr, x ); - sta_abs_x: - FLUSH_TIME(); - WRITE_MEM( addr, a ); - CACHE_TIME(); - goto loop; - - case 0x91: // STA (ind),Y - #define NO_PAGE_PENALTY( lsb ) - IND_Y( NO_PAGE_PENALTY, addr ) - pc++; - DUMMY_READ( addr, y ); - goto sta_ptr; - - case 0x81: // STA (ind,X) - IND_X( addr ) - pc++; - goto sta_ptr; - - } - - case 0xA9: // LDA #imm - pc++; - a = data; - nz = data; - goto loop; - - // common read instructions - { - int addr; - - case 0xA1: // LDA (ind,X) - IND_X( addr ) - pc++; - goto a_nz_read_addr; - - case 0xB1:// LDA (ind),Y - addr = READ_LOW( data ) + y; - PAGE_PENALTY( addr ); - addr += 0x100 * READ_LOW( BYTE( data + 1 ) ); - pc++; - READ_FAST( addr, a = nz ); - if ( CAN_READ_FAST( addr ) ) - goto loop; - DUMMY_READ( addr, y ); - goto a_nz_read_addr; - - case 0xB9: // LDA abs,Y - PAGE_PENALTY( data + y ); - addr = GET_ADDR() + y; - pc += 2; - READ_FAST( addr, a = nz ); - if ( CAN_READ_FAST( addr ) ) - goto loop; - goto a_nz_read_addr; - - case 0xBD: // LDA abs,X - PAGE_PENALTY( data + x ); - addr = GET_ADDR() + x; - pc += 2; - READ_FAST( addr, a = nz ); - if ( CAN_READ_FAST( addr ) ) - goto loop; - DUMMY_READ( addr, x ); - a_nz_read_addr: - FLUSH_TIME(); - a = nz = READ_MEM( addr ); - CACHE_TIME(); - goto loop; - - } - -// Branch - - case 0x50: // BVC - BRANCH( !(flags & v40) ) - - case 0x70: // BVS - BRANCH( flags & v40 ) - - case 0xB0: // BCS - BRANCH( c & 0x100 ) - - case 0x90: // BCC - BRANCH( !(c & 0x100) ) - -// Load/store - - case 0x94: // STY zp,x - data = BYTE( data + x ); - case 0x84: // STY zp - pc++; - WRITE_LOW( data, y ); - goto loop; - - case 0x96: // STX zp,y - data = BYTE( data + y ); - case 0x86: // STX zp - pc++; - WRITE_LOW( data, x ); - goto loop; - - case 0xB6: // LDX zp,y - data = BYTE( data + y ); - case 0xA6: // LDX zp - data = READ_LOW( data ); - case 0xA2: // LDX #imm - pc++; - x = data; - nz = data; - goto loop; - - case 0xB4: // LDY zp,x - data = BYTE( data + x ); - case 0xA4: // LDY zp - data = READ_LOW( data ); - case 0xA0: // LDY #imm - pc++; - y = data; - nz = data; - goto loop; - - case 0xBC: // LDY abs,X - data += x; - PAGE_PENALTY( data ); - case 0xAC:{// LDY abs - int addr = data + 0x100 * GET_MSB(); - pc += 2; - FLUSH_TIME(); - y = nz = READ_MEM( addr ); - CACHE_TIME(); - goto loop; - } - - case 0xBE: // LDX abs,y - data += y; - PAGE_PENALTY( data ); - case 0xAE:{// LDX abs - int addr = data + 0x100 * GET_MSB(); - pc += 2; - FLUSH_TIME(); - x = nz = READ_MEM( addr ); - CACHE_TIME(); - goto loop; - } - - { - int temp; - case 0x8C: // STY abs - temp = y; - goto store_abs; - - case 0x8E: // STX abs - temp = x; - store_abs: - { - int addr = GET_ADDR(); - pc += 2; - if ( CAN_WRITE_FAST( addr ) ) - { - WRITE_FAST( addr, temp ); - goto loop; - } - FLUSH_TIME(); - WRITE_MEM( addr, temp ); - CACHE_TIME(); - goto loop; - } - } - -// Compare - - case 0xEC: {// CPX abs - int addr = GET_ADDR(); - pc++; - FLUSH_TIME(); - data = READ_MEM( addr ); - CACHE_TIME(); - goto cpx_data; - } - - case 0xE4: // CPX zp - data = READ_LOW( data ); - case 0xE0: // CPX #imm - cpx_data: - nz = x - data; - pc++; - c = ~nz; - nz &= 0xFF; - goto loop; - - case 0xCC:{// CPY abs - int addr = GET_ADDR(); - pc++; - FLUSH_TIME(); - data = READ_MEM( addr ); - CACHE_TIME(); - goto cpy_data; - } - - case 0xC4: // CPY zp - data = READ_LOW( data ); - case 0xC0: // CPY #imm - cpy_data: - nz = y - data; - pc++; - c = ~nz; - nz &= 0xFF; - goto loop; - -// Logical - - ARITH_ADDR_MODES( 0x25 ) // AND - nz = (a &= data); - pc++; - goto loop; - - ARITH_ADDR_MODES( 0x45 ) // EOR - nz = (a ^= data); - pc++; - goto loop; - - ARITH_ADDR_MODES( 0x05 ) // ORA - nz = (a |= data); - pc++; - goto loop; - - case 0x2C:{// BIT abs - int addr = GET_ADDR(); - pc += 2; - READ_PPU( addr, nz ); - flags = (flags & ~v40) + (nz & v40); - if ( a & nz ) - goto loop; - nz <<= 8; // result must be zero, even if N bit is set - goto loop; - } - - case 0x24: // BIT zp - nz = READ_LOW( data ); - pc++; - flags = (flags & ~v40) + (nz & v40); - if ( a & nz ) - goto loop; // Z should be clear, and nz must be non-zero if nz & a is - nz <<= 8; // set Z flag without affecting N flag - goto loop; - -// Add/subtract - - ARITH_ADDR_MODES( 0xE5 ) // SBC - case 0xEB: // unofficial equivalent - data ^= 0xFF; - goto adc_imm; - - ARITH_ADDR_MODES( 0x65 ) // ADC - adc_imm: { - int carry = c >> 8 & 1; - int ov = (a ^ 0x80) + carry + SBYTE( data ); - flags = (flags & ~v40) + (ov >> 2 & v40); - c = nz = a + data + carry; - pc++; - a = BYTE( nz ); - goto loop; - } - -// Shift/rotate - - case 0x4A: // LSR A - c = 0; - case 0x6A: // ROR A - nz = c >> 1 & 0x80; - c = a << 8; - nz += a >> 1; - a = nz; - goto loop; - - case 0x0A: // ASL A - nz = a << 1; - c = nz; - a = BYTE( nz ); - goto loop; - - case 0x2A: { // ROL A - nz = a << 1; - int temp = c >> 8 & 1; - c = nz; - nz += temp; - a = BYTE( nz ); - goto loop; - } - - case 0x5E: // LSR abs,X - data += x; - case 0x4E: // LSR abs - c = 0; - case 0x6E: // ROR abs - ror_abs: { - ADD_PAGE( data ); - FLUSH_TIME(); - int temp = READ_MEM( data ); - nz = (c >> 1 & 0x80) + (temp >> 1); - c = temp << 8; - goto rotate_common; - } - - case 0x3E: // ROL abs,X - data += x; - goto rol_abs; - - case 0x1E: // ASL abs,X - data += x; - case 0x0E: // ASL abs - c = 0; - case 0x2E: // ROL abs - rol_abs: - ADD_PAGE( data ); - nz = c >> 8 & 1; - FLUSH_TIME(); - nz += (c = READ_MEM( data ) << 1); - rotate_common: - pc++; - WRITE_MEM( data, BYTE( nz ) ); - CACHE_TIME(); - goto loop; - - case 0x7E: // ROR abs,X - data += x; - goto ror_abs; - - case 0x76: // ROR zp,x - data = BYTE( data + x ); - goto ror_zp; - - case 0x56: // LSR zp,x - data = BYTE( data + x ); - case 0x46: // LSR zp - c = 0; - case 0x66: // ROR zp - ror_zp: { - int temp = READ_LOW( data ); - nz = (c >> 1 & 0x80) + (temp >> 1); - c = temp << 8; - goto write_nz_zp; - } - - case 0x36: // ROL zp,x - data = BYTE( data + x ); - goto rol_zp; - - case 0x16: // ASL zp,x - data = BYTE( data + x ); - case 0x06: // ASL zp - c = 0; - case 0x26: // ROL zp - rol_zp: - nz = c >> 8 & 1; - nz += (c = READ_LOW( data ) << 1); - goto write_nz_zp; - -// Increment/decrement - - case 0xCA: // DEX - INC_DEC( x, -1 ) - - case 0x88: // DEY - INC_DEC( y, -1 ) - - case 0xF6: // INC zp,x - data = BYTE( data + x ); - case 0xE6: // INC zp - nz = 1; - goto add_nz_zp; - - case 0xD6: // DEC zp,x - data = BYTE( data + x ); - case 0xC6: // DEC zp - nz = -1; - add_nz_zp: - nz += READ_LOW( data ); - write_nz_zp: - pc++; - WRITE_LOW( data, nz ); - goto loop; - - case 0xFE: // INC abs,x - data = x + GET_ADDR(); - goto inc_ptr; - - case 0xEE: // INC abs - data = GET_ADDR(); - inc_ptr: - nz = 1; - goto inc_common; - - case 0xDE: // DEC abs,x - data = x + GET_ADDR(); - goto dec_ptr; - - case 0xCE: // DEC abs - data = GET_ADDR(); - dec_ptr: - nz = -1; - inc_common: - FLUSH_TIME(); - pc += 2; - nz += READ_MEM( data ); - WRITE_MEM( data, BYTE( nz ) ); - CACHE_TIME(); - goto loop; - -// Transfer - - case 0xAA: // TAX - x = nz = a; - goto loop; - - case 0x8A: // TXA - a = nz = x; - goto loop; - - case 0x9A: // TXS - SET_SP( x ); // verified (no flag change) - goto loop; - - case 0xBA: // TSX - x = nz = GET_SP(); - goto loop; - -// Stack - - case 0x48: // PHA - sp = SP( -1 ); - WRITE_STACK( sp, a ); - goto loop; - - case 0x68: // PLA - a = nz = READ_STACK( sp ); - sp = SP( 1 ); - goto loop; - - case 0x40:{// RTI - pc = READ_STACK( SP( 1 ) ); - pc += READ_STACK( SP( 2 ) ) * 0x100; - int temp = READ_STACK( sp ); - sp = SP( 3 ); - data = flags; - SET_FLAGS( temp ); - cpu->r.flags = flags; // update externally-visible I flag - int delta = s.base - cpu->irq_time; - if ( delta <= 0 ) goto loop; // end_time < irq_time - if ( flags & i04 ) goto loop; - s_time += delta; - s.base = cpu->irq_time; - goto loop; - } - - case 0x28:{// PLP - int temp = READ_STACK( sp ); - sp = SP( 1 ); - int changed = flags ^ temp; - SET_FLAGS( temp ); - if ( !(changed & i04) ) - goto loop; // I flag didn't change - if ( flags & i04 ) - goto handle_sei; - goto handle_cli; - } - - case 0x08:{// PHP - int temp; - GET_FLAGS( temp ); - sp = SP( -1 ); - WRITE_STACK( sp, temp | (b10 | r20) ); - goto loop; - } - - case 0x6C:{// JMP (ind) - data = GET_ADDR(); - byte const* page = CODE_PAGE( data ); - pc = page [CODE_OFFSET( data )]; - data = (data & 0xFF00) + ((data + 1) & 0xFF); - pc += page [CODE_OFFSET( data )] * 0x100; - goto loop; - } - - case 0x00: // BRK - goto handle_brk; - -// Flags - - case 0x38: // SEC - c = 0x100; - goto loop; - - case 0x18: // CLC - c = 0; - goto loop; - - case 0xB8: // CLV - flags &= ~v40; - goto loop; - - case 0xD8: // CLD - flags &= ~d08; - goto loop; - - case 0xF8: // SED - flags |= d08; - goto loop; - - case 0x58: // CLI - if ( !(flags & i04) ) - goto loop; - flags &= ~i04; - handle_cli: { - //dprintf( "CLI at %d\n", TIME ); - cpu->r.flags = flags; // update externally-visible I flag - int delta = s.base - cpu->irq_time; - if ( delta <= 0 ) - { - if ( TIME() < cpu->irq_time ) - goto loop; - goto delayed_cli; - } - s.base = cpu->irq_time; - s_time += delta; - if ( s_time < 0 ) - goto loop; - - if ( delta >= s_time + 1 ) - { - // delayed irq until after next instruction - s.base += s_time + 1; - s_time = -1; - goto loop; - } - - // TODO: implement - delayed_cli: - dprintf( "Delayed CLI not emulated\n" ); - goto loop; - } - - case 0x78: // SEI - if ( flags & i04 ) - goto loop; - flags |= i04; - handle_sei: { - cpu->r.flags = flags; // update externally-visible I flag - int delta = s.base - cpu->end_time; - s.base = cpu->end_time; - s_time += delta; - if ( s_time < 0 ) - goto loop; - - dprintf( "Delayed SEI not emulated\n" ); - goto loop; - } - -// Unofficial - - // SKW - skip word - case 0x1C: case 0x3C: case 0x5C: case 0x7C: case 0xDC: case 0xFC: - PAGE_PENALTY( data + x ); - case 0x0C: - pc++; - // SKB - skip byte - case 0x74: case 0x04: case 0x14: case 0x34: case 0x44: case 0x54: case 0x64: - case 0x80: case 0x82: case 0x89: case 0xC2: case 0xD4: case 0xE2: case 0xF4: - pc++; - goto loop; - - // NOP - case 0xEA: case 0x1A: case 0x3A: case 0x5A: case 0x7A: case 0xDA: case 0xFA: - goto loop; - - case halt_opcode: // HLT - halt processor - if ( pc-- > 0x10000 ) - { - // handle wrap-around (assumes caller has put page of HLT at 0x10000) - pc = WORD( pc ); - goto loop; - } - case 0x02: case 0x12: case 0x32: case 0x42: case 0x52: - case 0x62: case 0x72: case 0x92: case 0xB2: case 0xD2: case 0xF2: - goto stop; - -// Unimplemented - - case 0xFF: // force 256-entry jump table for optimization purposes - c |= 1; // compiler doesn't know that this won't affect anything - default: - check( (unsigned) opcode < 0x100 ); - - #ifdef UNIMPL_INSTR - UNIMPL_INSTR(); - #endif - - // At least skip over proper number of bytes instruction uses - static unsigned char const illop_lens [8] = { - 0x40, 0x40, 0x40, 0x80, 0x40, 0x40, 0x80, 0xA0 - }; - int opcode = instr [-1]; - int len = illop_lens [opcode >> 2 & 7] >> (opcode << 1 & 6) & 3; - if ( opcode == 0x9C ) - len = 2; - pc += len; - - // Account for extra clock - if ( (opcode >> 4) == 0x0B ) - { - if ( opcode == 0xB3 ) - data = READ_LOW( data ); - if ( opcode != 0xB7 ) - PAGE_PENALTY( data + y ); - } - goto loop; - } - assert( false ); // catch missing 'goto loop' or accidental 'break' - - int result_; -handle_brk: - pc++; - result_ = b10 | 4; - -#ifdef CPU_DONE -interrupt: -#endif - { - s_time += 7; - - // Save PC and read vector - WRITE_STACK( SP( -1 ), pc >> 8 ); - WRITE_STACK( SP( -2 ), pc ); - pc = GET_LE16( &READ_CODE( 0xFFFA ) + (result_ & 4) ); - - // Save flags - int temp; - GET_FLAGS( temp ); - temp |= r20 + (result_ & b10); // B flag set for BRK - sp = SP( -3 ); - WRITE_STACK( sp, temp ); - - // Update I flag in externally-visible flags - cpu->r.flags = (flags |= i04); - - // Update time - int delta = s.base - cpu->end_time; - if ( delta >= 0 ) - goto loop; - s_time += delta; - s.base = cpu->end_time; - goto loop; - } - -out_of_time: - pc--; - - // Optional action that triggers interrupt or changes irq/end time - #ifdef CPU_DONE - { - CPU_DONE( result_ ); - if ( result_ >= 0 ) - goto interrupt; - if ( s_time < 0 ) - goto loop; - } - #endif -stop: - - // Flush cached state - cpu->r.pc = pc; - cpu->r.sp = GET_SP(); - cpu->r.a = a; - cpu->r.x = x; - cpu->r.y = y; - - int temp; - GET_FLAGS( temp ); - cpu->r.flags = temp; - - cpu->cpu_state_.base = s.base; - cpu->cpu_state_.time = s_time; - cpu->cpu_state = &cpu->cpu_state_; -} diff --git a/apps/codecs/libgme/nes_fds_apu.c b/apps/codecs/libgme/nes_fds_apu.c deleted file mode 100644 index dc0775d5d3..0000000000 --- a/apps/codecs/libgme/nes_fds_apu.c +++ /dev/null @@ -1,291 +0,0 @@ -// Game_Music_Emu 0.6-pre. http://www.slack.net/~ant/ - -#include "nes_fds_apu.h" - -/* Copyright (C) 2006 Shay Green. This module is free software; you -can redistribute it and/or modify it under the terms of the GNU Lesser -General Public License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. This -module is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more -details. You should have received a copy of the GNU Lesser General Public -License along with this module; if not, write to the Free Software Foundation, -Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ - -#include "blargg_source.h" - -int const fract_range = 65536; - -void Fds_init( struct Nes_Fds_Apu* this ) -{ - Synth_init( &this->synth ); - - this->lfo_tempo = lfo_base_tempo; - Fds_set_output( this, 0, NULL ); - Fds_volume( this, (int)FP_ONE_VOLUME ); - Fds_reset( this ); -} - -void Fds_reset( struct Nes_Fds_Apu* this ) -{ - memset( this->regs_, 0, sizeof this->regs_ ); - memset( this->mod_wave, 0, sizeof this->mod_wave ); - - this->last_time = 0; - this->env_delay = 0; - this->sweep_delay = 0; - this->wave_pos = 0; - this->last_amp = 0; - this->wave_fract = fract_range; - this->mod_fract = fract_range; - this->mod_pos = 0; - this->mod_write_pos = 0; - - static byte const initial_regs [0x0B] = { - 0x80, // disable envelope - 0, 0, 0xC0, // disable wave and lfo - 0x80, // disable sweep - 0, 0, 0x80, // disable modulation - 0, 0, 0xFF // LFO period // TODO: use 0xE8 as FDS ROM does? - }; - int i; - for ( i = 0; i < (int) sizeof initial_regs; i++ ) - { - // two writes to set both gain and period for envelope registers - Fds_write_( this, fds_io_addr + fds_wave_size + i, 0 ); - Fds_write_( this, fds_io_addr + fds_wave_size + i, initial_regs [i] ); - } -} - -void Fds_write_( struct Nes_Fds_Apu* this, unsigned addr, int data ) -{ - unsigned reg = addr - fds_io_addr; - if ( reg < fds_io_size ) - { - if ( reg < fds_wave_size ) - { - if ( *regs_nes (this, 0x4089) & 0x80 ) - this->regs_ [reg] = data & fds_wave_sample_max; - } - else - { - this->regs_ [reg] = data; - switch ( addr ) - { - case 0x4080: - if ( data & 0x80 ) - this->env_gain = data & 0x3F; - else - this->env_speed = (data & 0x3F) + 1; - break; - - case 0x4084: - if ( data & 0x80 ) - this->sweep_gain = data & 0x3F; - else - this->sweep_speed = (data & 0x3F) + 1; - break; - - case 0x4085: - this->mod_pos = this->mod_write_pos; - *regs_nes (this, 0x4085) = data & 0x7F; - break; - - case 0x4088: - if ( *regs_nes (this, 0x4087) & 0x80 ) - { - int pos = this->mod_write_pos; - data &= 0x07; - this->mod_wave [pos ] = data; - this->mod_wave [pos + 1] = data; - this->mod_write_pos = (pos + 2) & (fds_wave_size - 1); - this->mod_pos = (this->mod_pos + 2) & (fds_wave_size - 1); - } - break; - } - } - } -} - -void Fds_set_tempo( struct Nes_Fds_Apu* this, int t ) -{ - this->lfo_tempo = lfo_base_tempo; - if ( t != (int)FP_ONE_TEMPO ) - { - this->lfo_tempo = (int) ((lfo_base_tempo * FP_ONE_TEMPO) / t); - if ( this->lfo_tempo <= 0 ) - this->lfo_tempo = 1; - } -} - -void Fds_run_until( struct Nes_Fds_Apu* this, blip_time_t final_end_time ) -{ - int const wave_freq = (*regs_nes (this, 0x4083) & 0x0F) * 0x100 + *regs_nes (this, 0x4082); - struct Blip_Buffer* const output_ = this->output_; - if ( wave_freq && output_ && !((*regs_nes (this, 0x4089) | *regs_nes (this, 0x4083)) & 0x80) ) - { - Blip_set_modified( output_ ); - - // master_volume - #define MVOL_ENTRY( percent ) (fds_master_vol_max * percent + 50) / 100 - static unsigned char const master_volumes [4] = { - MVOL_ENTRY( 100 ), MVOL_ENTRY( 67 ), MVOL_ENTRY( 50 ), MVOL_ENTRY( 40 ) - }; - int const master_volume = master_volumes [*regs_nes (this, 0x4089) & 0x03]; - - // lfo_period - blip_time_t lfo_period = *regs_nes (this, 0x408A) * this->lfo_tempo; - if ( *regs_nes (this, 0x4083) & 0x40 ) - lfo_period = 0; - - // sweep setup - blip_time_t sweep_time = this->last_time + this->sweep_delay; - blip_time_t const sweep_period = lfo_period * this->sweep_speed; - if ( !sweep_period || *regs_nes (this, 0x4084) & 0x80 ) - sweep_time = final_end_time; - - // envelope setup - blip_time_t env_time = this->last_time + this->env_delay; - blip_time_t const env_period = lfo_period * this->env_speed; - if ( !env_period || *regs_nes (this, 0x4080) & 0x80 ) - env_time = final_end_time; - - // modulation - int mod_freq = 0; - if ( !(*regs_nes (this, 0x4087) & 0x80) ) - mod_freq = (*regs_nes (this, 0x4087) & 0x0F) * 0x100 + *regs_nes (this, 0x4086); - - blip_time_t end_time = this->last_time; - do - { - // sweep - if ( sweep_time <= end_time ) - { - sweep_time += sweep_period; - int mode = *regs_nes (this, 0x4084) >> 5 & 2; - int new_sweep_gain = this->sweep_gain + mode - 1; - if ( (unsigned) new_sweep_gain <= (unsigned) 0x80 >> mode ) - this->sweep_gain = new_sweep_gain; - else - *regs_nes (this, 0x4084) |= 0x80; // optimization only - } - - // envelope - if ( env_time <= end_time ) - { - env_time += env_period; - int mode = *regs_nes (this, 0x4080) >> 5 & 2; - int new_env_gain = this->env_gain + mode - 1; - if ( (unsigned) new_env_gain <= (unsigned) 0x80 >> mode ) - this->env_gain = new_env_gain; - else - *regs_nes (this, 0x4080) |= 0x80; // optimization only - } - - // new end_time - blip_time_t const start_time = end_time; - end_time = final_end_time; - if ( end_time > env_time ) end_time = env_time; - if ( end_time > sweep_time ) end_time = sweep_time; - - // frequency modulation - int freq = wave_freq; - if ( mod_freq ) - { - // time of next modulation clock - blip_time_t mod_time = start_time + (this->mod_fract + mod_freq - 1) / mod_freq; - if ( end_time > mod_time ) - end_time = mod_time; - - // run modulator up to next clock and save old sweep_bias - int sweep_bias = *regs_nes (this, 0x4085); - this->mod_fract -= (end_time - start_time) * mod_freq; - if ( this->mod_fract <= 0 ) - { - this->mod_fract += fract_range; - check( (unsigned) this->mod_fract <= fract_range ); - - static short const mod_table [8] = { 0, +1, +2, +4, 0, -4, -2, -1 }; - int mod = this->mod_wave [this->mod_pos]; - this->mod_pos = (this->mod_pos + 1) & (fds_wave_size - 1); - int new_sweep_bias = (sweep_bias + mod_table [mod]) & 0x7F; - if ( mod == 4 ) - new_sweep_bias = 0; - *regs_nes (this, 0x4085) = new_sweep_bias; - } - - // apply frequency modulation - sweep_bias = (sweep_bias ^ 0x40) - 0x40; - int factor = sweep_bias * this->sweep_gain; - int extra = factor & 0x0F; - factor >>= 4; - if ( extra ) - { - factor--; - if ( sweep_bias >= 0 ) - factor += 3; - } - if ( factor > 193 ) factor -= 258; - if ( factor < -64 ) factor += 256; - freq += (freq * factor) >> 6; - if ( freq <= 0 ) - continue; - } - - // wave - int wave_fract = this->wave_fract; - blip_time_t delay = (wave_fract + freq - 1) / freq; - blip_time_t time = start_time + delay; - - if ( time <= end_time ) - { - // at least one wave clock within start_time...end_time - - blip_time_t const min_delay = fract_range / freq; - int wave_pos = this->wave_pos; - - int volume = this->env_gain; - if ( volume > fds_vol_max ) - volume = fds_vol_max; - volume *= master_volume; - - int const min_fract = min_delay * freq; - - do - { - // clock wave - int amp = this->regs_ [wave_pos] * volume; - wave_pos = (wave_pos + 1) & (fds_wave_size - 1); - int delta = amp - this->last_amp; - if ( delta ) - { - this->last_amp = amp; - Synth_offset_inline( &this->synth, time, delta, output_ ); - } - - wave_fract += fract_range - delay * freq; - check( unsigned (fract_range - wave_fract) < freq ); - - // delay until next clock - delay = min_delay; - if ( wave_fract > min_fract ) - delay++; - check( delay && delay == (wave_fract + freq - 1) / freq ); - - time += delay; - } - while ( time <= end_time ); // TODO: using < breaks things, but <= is wrong - - this->wave_pos = wave_pos; - } - this->wave_fract = wave_fract - (end_time - (time - delay)) * freq; - check( this->wave_fract > 0 ); - } - while ( end_time < final_end_time ); - - this->env_delay = env_time - final_end_time; check( env_delay >= 0 ); - this->sweep_delay = sweep_time - final_end_time; check( sweep_delay >= 0 ); - } - this->last_time = final_end_time; -} diff --git a/apps/codecs/libgme/nes_fds_apu.h b/apps/codecs/libgme/nes_fds_apu.h deleted file mode 100644 index 8dac3b721a..0000000000 --- a/apps/codecs/libgme/nes_fds_apu.h +++ /dev/null @@ -1,116 +0,0 @@ -// NES FDS sound chip emulator - -// Game_Music_Emu 0.6-pre -#ifndef NES_FDS_APU_H -#define NES_FDS_APU_H - -#include "blargg_common.h" -#include "blip_buffer.h" - -enum { lfo_base_tempo = 8 }; -enum { fds_osc_count = 1 }; - -enum { fds_io_addr = 0x4040 }; -enum { fds_io_size = 0x53 }; - -enum { fds_wave_size = 0x40 }; -enum { fds_master_vol_max = 10 }; -enum { fds_vol_max = 0x20 }; -enum { fds_wave_sample_max = 0x3F }; - -struct Nes_Fds_Apu { - unsigned char regs_ [fds_io_size];// last written value to registers - int lfo_tempo; // normally 8; adjusted by set_tempo() - - int env_delay; - int env_speed; - int env_gain; - - int sweep_delay; - int sweep_speed; - int sweep_gain; - - int wave_pos; - int last_amp; - blip_time_t wave_fract; - - int mod_fract; - int mod_pos; - int mod_write_pos; - unsigned char mod_wave [fds_wave_size]; - - // synthesis - blip_time_t last_time; - struct Blip_Buffer* output_; - struct Blip_Synth synth; -}; - -// init -void Fds_init( struct Nes_Fds_Apu* this ); -// setup -void Fds_set_tempo( struct Nes_Fds_Apu* this, int t ); - -// emulation -void Fds_reset( struct Nes_Fds_Apu* this ); - -static inline void Fds_volume( struct Nes_Fds_Apu* this, int v ) -{ - Synth_volume( &this->synth, (v*14) / 100 / fds_master_vol_max / fds_vol_max / fds_wave_sample_max ); -} - -static inline void Fds_set_output( struct Nes_Fds_Apu* this, int i, struct Blip_Buffer* b ) -{ -#if defined(ROCKBOX) - (void) i; -#endif - - assert( (unsigned) i < fds_osc_count ); - this->output_ = b; -} - -void Fds_run_until( struct Nes_Fds_Apu* this, blip_time_t ); -static inline void Fds_end_frame( struct Nes_Fds_Apu* this, blip_time_t end_time ) -{ - if ( end_time > this->last_time ) - Fds_run_until( this, end_time ); - this->last_time -= end_time; - assert( this->last_time >= 0 ); -} - -void Fds_write_( struct Nes_Fds_Apu* this, unsigned addr, int data ); -static inline void Fds_write( struct Nes_Fds_Apu* this, blip_time_t time, unsigned addr, int data ) -{ - Fds_run_until( this, time ); - Fds_write_( this, addr, data ); -} - -static inline int Fds_read( struct Nes_Fds_Apu* this, blip_time_t time, unsigned addr ) -{ - Fds_run_until( this, time ); - - int result = 0xFF; - switch ( addr ) - { - case 0x4090: - result = this->env_gain; - break; - - case 0x4092: - result = this->sweep_gain; - break; - - default: - { - unsigned i = addr - fds_io_addr; - if ( i < fds_wave_size ) - result = this->regs_ [i]; - } - } - - return result | 0x40; -} - -// allow access to registers by absolute address (i.e. 0x4080) -static inline unsigned char* regs_nes( struct Nes_Fds_Apu* this, unsigned addr ) { return &this->regs_ [addr - fds_io_addr]; } - -#endif diff --git a/apps/codecs/libgme/nes_fme7_apu.c b/apps/codecs/libgme/nes_fme7_apu.c deleted file mode 100644 index 3e47e0b17c..0000000000 --- a/apps/codecs/libgme/nes_fme7_apu.c +++ /dev/null @@ -1,136 +0,0 @@ -// Game_Music_Emu 0.5.5. http://www.slack.net/~ant/ - -#include "nes_fme7_apu.h" - -#include - -/* Copyright (C) 2003-2006 Shay Green. This module is free software; you -can redistribute it and/or modify it under the terms of the GNU Lesser -General Public License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. This -module is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more -details. You should have received a copy of the GNU Lesser General Public -License along with this module; if not, write to the Free Software Foundation, -Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ - -#include "blargg_source.h" - -void Fme7_init( struct Nes_Fme7_Apu* this ) -{ - Synth_init( &this->synth ); - - Fme7_output( this, NULL ); - Fme7_volume( this, (int)FP_ONE_VOLUME ); - Fme7_reset( this ); -} - -void Fme7_reset( struct Nes_Fme7_Apu* this ) -{ - this->last_time = 0; - - int i; - for ( i = 0; i < fme7_osc_count; i++ ) - this->oscs [i].last_amp = 0; - - this->latch = 0; - memset( this->regs, 0, sizeof this->regs); - memset( this->phases, 0, sizeof this->phases ); - memset( this->delays, 0, sizeof this->delays ); -} - -static unsigned char const amp_table [16] = -{ - #define ENTRY( n ) (unsigned char) (n * amp_range + 0.5) - ENTRY(0.0000), ENTRY(0.0078), ENTRY(0.0110), ENTRY(0.0156), - ENTRY(0.0221), ENTRY(0.0312), ENTRY(0.0441), ENTRY(0.0624), - ENTRY(0.0883), ENTRY(0.1249), ENTRY(0.1766), ENTRY(0.2498), - ENTRY(0.3534), ENTRY(0.4998), ENTRY(0.7070), ENTRY(1.0000) - #undef ENTRY -}; - -void Fme7_run_until( struct Nes_Fme7_Apu* this, blip_time_t end_time ) -{ - require( end_time >= this->last_time ); - - int index; - for ( index = 0; index < fme7_osc_count; index++ ) - { - int mode = this->regs [7] >> index; - int vol_mode = this->regs [010 + index]; - int volume = amp_table [vol_mode & 0x0F]; - - struct Blip_Buffer* const osc_output = this->oscs [index].output; - if ( !osc_output ) - continue; - - // check for unsupported mode - #ifndef NDEBUG - if ( (mode & 011) <= 001 && vol_mode & 0x1F ) - debug_printf( "FME7 used unimplemented sound mode: %02X, vol_mode: %02X\n", - mode, vol_mode & 0x1F ); - #endif - - if ( (mode & 001) | (vol_mode & 0x10) ) - volume = 0; // noise and envelope aren't supported - - // period - int const period_factor = 16; - unsigned period = (this->regs [index * 2 + 1] & 0x0F) * 0x100 * period_factor + - this->regs [index * 2] * period_factor; - if ( period < 50 ) // around 22 kHz - { - volume = 0; - if ( !period ) // on my AY-3-8910A, period doesn't have extra one added - period = period_factor; - } - - // current amplitude - int amp = volume; - if ( !this->phases [index] ) - amp = 0; - - { - int delta = amp - this->oscs [index].last_amp; - if ( delta ) - { - this->oscs [index].last_amp = amp; - Blip_set_modified( osc_output ); - Synth_offset( &this->synth, this->last_time, delta, osc_output ); - } - } - - blip_time_t time = this->last_time + this->delays [index]; - if ( time < end_time ) - { - int delta = amp * 2 - volume; - Blip_set_modified( osc_output ); - if ( volume ) - { - do - { - delta = -delta; - Synth_offset_inline( &this->synth, time, delta, osc_output ); - time += period; - } - while ( time < end_time ); - - this->oscs [index].last_amp = (delta + volume) >> 1; - this->phases [index] = (delta > 0); - } - else - { - // maintain phase when silent - int count = (end_time - time + period - 1) / period; - this->phases [index] ^= count & 1; - time += count * period; - } - } - - this->delays [index] = time - end_time; - } - - this->last_time = end_time; -} - diff --git a/apps/codecs/libgme/nes_fme7_apu.h b/apps/codecs/libgme/nes_fme7_apu.h deleted file mode 100644 index c0eac4c765..0000000000 --- a/apps/codecs/libgme/nes_fme7_apu.h +++ /dev/null @@ -1,90 +0,0 @@ -// Sunsoft FME-7 sound emulator - -// Game_Music_Emu 0.6-pre -#ifndef NES_FME7_APU_H -#define NES_FME7_APU_H - -#include "blargg_common.h" -#include "blip_buffer.h" - -enum { fme7_reg_count = 14 }; - -// Mask and addresses of registers -enum { fme7_addr_mask = 0xE000 }; -enum { fme7_data_addr = 0xE000 }; -enum { fme7_latch_addr = 0xC000 }; -enum { fme7_osc_count = 3 }; - -enum { amp_range = 192 }; // can be any value; this gives best error/quality tradeoff - -struct osc_t { - struct Blip_Buffer* output; - int last_amp; -}; - -// static unsigned char const amp_table [16]; - -struct Nes_Fme7_Apu { - // fme7 apu state - uint8_t regs [fme7_reg_count]; - uint8_t phases [3]; // 0 or 1 - uint8_t latch; - uint16_t delays [3]; // a, b, c - - struct osc_t oscs [fme7_osc_count]; - blip_time_t last_time; - - struct Blip_Synth synth; -}; - -// See Nes_Apu.h for reference -void Fme7_init( struct Nes_Fme7_Apu* this ); -void Fme7_reset( struct Nes_Fme7_Apu* this ); - -static inline void Fme7_volume( struct Nes_Fme7_Apu* this, int v ) -{ - Synth_volume( &this->synth, (v/2 - (v*3)/25) / amp_range ); // to do: fine-tune -} - -static inline void Fme7_osc_output( struct Nes_Fme7_Apu* this, int i, struct Blip_Buffer* buf ) -{ - assert( (unsigned) i < fme7_osc_count ); - this->oscs [i].output = buf; -} - -static inline void Fme7_output( struct Nes_Fme7_Apu* this, struct Blip_Buffer* buf ) -{ - int i; - for ( i = 0; i < fme7_osc_count; i++ ) - Fme7_osc_output( this, i, buf ); -} - -// (addr & addr_mask) == latch_addr -static inline void Fme7_write_latch( struct Nes_Fme7_Apu* this, int data ) { this->latch = data; } - -// (addr & addr_mask) == data_addr -void Fme7_run_until( struct Nes_Fme7_Apu* this, blip_time_t end_time ); -static inline void Fme7_write_data( struct Nes_Fme7_Apu* this, blip_time_t time, int data ) -{ - if ( (unsigned) this->latch >= fme7_reg_count ) - { - #ifdef debug_printf - debug_printf( "FME7 write to %02X (past end of sound registers)\n", (int) latch ); - #endif - return; - } - - Fme7_run_until( this, time ); - this->regs [this->latch] = data; -} - -static inline void Fme7_end_frame( struct Nes_Fme7_Apu* this, blip_time_t time ) -{ - if ( time > this->last_time ) - Fme7_run_until( this, time ); - - assert( this->last_time >= time ); - this->last_time -= time; -} - -#endif diff --git a/apps/codecs/libgme/nes_mmc5_apu.h b/apps/codecs/libgme/nes_mmc5_apu.h deleted file mode 100644 index b696b49e97..0000000000 --- a/apps/codecs/libgme/nes_mmc5_apu.h +++ /dev/null @@ -1,61 +0,0 @@ -// NES MMC5 sound chip emulator - -// Nes_Snd_Emu 0.2.0-pre -#ifndef NES_MMC5_APU_H -#define NES_MMC5_APU_H - -#include "blargg_common.h" -#include "nes_apu.h" - -enum { mmc5_regs_addr = 0x5000 }; -enum { mmc5_regs_size = 0x16 }; -enum { mmc5_osc_count = 3 }; -enum { mmc5_exram_size = 1024 }; - -struct Nes_Mmc5_Apu { - struct Nes_Apu apu; - unsigned char exram [mmc5_exram_size]; -}; - -static inline void Mmc5_init( struct Nes_Mmc5_Apu* this ) -{ - Apu_init( &this->apu ); -} - -static inline void Mmc5_set_output( struct Nes_Mmc5_Apu* this, int i, struct Blip_Buffer* b ) -{ - // in: square 1, square 2, PCM - // out: square 1, square 2, skipped, skipped, PCM - if ( i > 1 ) - i += 2; - Apu_osc_output( &this->apu, i, b ); -} - -static inline void Mmc5_write_register( struct Nes_Mmc5_Apu* this, blip_time_t time, unsigned addr, int data ) -{ - switch ( addr ) - { - case 0x5015: // channel enables - data &= 0x03; // enable the square waves only - // fall through - case 0x5000: // Square 1 - case 0x5002: - case 0x5003: - case 0x5004: // Square 2 - case 0x5006: - case 0x5007: - case 0x5011: // DAC - Apu_write_register( &this->apu, time, addr - 0x1000, data ); - break; - - case 0x5010: // some things write to this for some reason - break; - -#ifdef BLARGG_DEBUG_H - default: - dprintf( "Unmapped MMC5 APU write: $%04X <- $%02X\n", addr, data ); -#endif - } -} - -#endif diff --git a/apps/codecs/libgme/nes_namco_apu.c b/apps/codecs/libgme/nes_namco_apu.c deleted file mode 100644 index 34df200bb6..0000000000 --- a/apps/codecs/libgme/nes_namco_apu.c +++ /dev/null @@ -1,138 +0,0 @@ -// Nes_Snd_Emu 0.1.8. http://www.slack.net/~ant/ - -#include "nes_namco_apu.h" - -/* Copyright (C) 2003-2006 Shay Green. This module is free software; you -can redistribute it and/or modify it under the terms of the GNU Lesser -General Public License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. This -module is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more -details. You should have received a copy of the GNU Lesser General Public -License along with this module; if not, write to the Free Software Foundation, -Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ - -#include "blargg_source.h" - -void Namco_init( struct Nes_Namco_Apu* this ) -{ - Synth_init( &this->synth ); - - Namco_output( this, NULL ); - Namco_volume( this, (int)FP_ONE_VOLUME ); - Namco_reset( this ); -} - -void Namco_reset( struct Nes_Namco_Apu* this ) -{ - this->last_time = 0; - this->addr_reg = 0; - - int i; - for ( i = 0; i < namco_reg_count; i++ ) - this->reg [i] = 0; - - for ( i = 0; i < namco_osc_count; i++ ) - { - struct Namco_Osc* osc = &this->oscs [i]; - osc->delay = 0; - osc->last_amp = 0; - osc->wave_pos = 0; - } -} - -void Namco_output( struct Nes_Namco_Apu* this, struct Blip_Buffer* buf ) -{ - int i; - for ( i = 0; i < namco_osc_count; i++ ) - Namco_osc_output( this, i, buf ); -} - -void Namco_end_frame( struct Nes_Namco_Apu* this, blip_time_t time ) -{ - if ( time > this->last_time ) - Namco_run_until( this, time ); - - assert( this->last_time >= time ); - this->last_time -= time; -} - -void Namco_run_until( struct Nes_Namco_Apu* this, blip_time_t nes_end_time ) -{ - int active_oscs = (this->reg [0x7F] >> 4 & 7) + 1; - int i; - for ( i = namco_osc_count - active_oscs; i < namco_osc_count; i++ ) - { - struct Namco_Osc* osc = &this->oscs [i]; - struct Blip_Buffer* output = osc->output; - if ( !output ) - continue; - - blip_resampled_time_t time = - Blip_resampled_time( output, this->last_time ) + osc->delay; - blip_resampled_time_t end_time = Blip_resampled_time( output, nes_end_time ); - osc->delay = 0; - if ( time < end_time ) - { - const uint8_t* osc_reg = &this->reg [i * 8 + 0x40]; - if ( !(osc_reg [4] & 0xE0) ) - continue; - - int volume = osc_reg [7] & 15; - if ( !volume ) - continue; - - int freq = (osc_reg [4] & 3) * 0x10000 + osc_reg [2] * 0x100L + osc_reg [0]; - if ( freq < 64 * active_oscs ) - continue; // prevent low frequencies from excessively delaying freq changes - - int const master_clock_divider = 12; // NES time derived via divider of master clock - int const n106_divider = 45; // N106 then divides master clock by this - int const max_freq = 0x3FFFF; - int const lowest_freq_period = (max_freq + 1) * n106_divider / master_clock_divider; - // divide by 8 to avoid overflow - blip_resampled_time_t period = - Blip_resampled_duration( output, lowest_freq_period / 8 ) / freq * 8 * active_oscs; - - int wave_size = 32 - (osc_reg [4] >> 2 & 7) * 4; - if ( !wave_size ) - continue; - - int last_amp = osc->last_amp; - int wave_pos = osc->wave_pos; - - Blip_set_modified( output ); - - do - { - // read wave sample - int addr = wave_pos + osc_reg [6]; - int sample = this->reg [addr >> 1] >> (addr << 2 & 4); - wave_pos++; - sample = (sample & 15) * volume; - - // output impulse if amplitude changed - int delta = sample - last_amp; - if ( delta ) - { - last_amp = sample; - Synth_offset_resampled( &this->synth, time, delta, output ); - } - - // next sample - time += period; - if ( wave_pos >= wave_size ) - wave_pos = 0; - } - while ( time < end_time ); - - osc->wave_pos = wave_pos; - osc->last_amp = last_amp; - } - osc->delay = time - end_time; - } - - this->last_time = nes_end_time; -} - diff --git a/apps/codecs/libgme/nes_namco_apu.h b/apps/codecs/libgme/nes_namco_apu.h deleted file mode 100644 index c428c894c3..0000000000 --- a/apps/codecs/libgme/nes_namco_apu.h +++ /dev/null @@ -1,71 +0,0 @@ -// Namco 106 sound chip emulator - -// Nes_Snd_Emu 0.1.8 -#ifndef NES_NAMCO_APU_H -#define NES_NAMCO_APU_H - -#include "blargg_common.h" -#include "blip_buffer.h" - -struct namco_state_t; - -enum { namco_osc_count = 8 }; -enum { namco_addr_reg_addr = 0xF800 }; -enum { namco_data_reg_addr = 0x4800 }; -enum { namco_reg_count = 0x80 }; - -struct Namco_Osc { - int delay; - struct Blip_Buffer* output; - short last_amp; - short wave_pos; -}; - -struct Nes_Namco_Apu { - struct Namco_Osc oscs [namco_osc_count]; - - blip_time_t last_time; - int addr_reg; - - uint8_t reg [namco_reg_count]; - - struct Blip_Synth synth; -}; - -// See Nes_Apu.h for reference. -void Namco_init( struct Nes_Namco_Apu* this ); -void Namco_output( struct Nes_Namco_Apu* this, struct Blip_Buffer* ); - -void Namco_reset( struct Nes_Namco_Apu* this ); -void Namco_end_frame( struct Nes_Namco_Apu* this, blip_time_t ); - -static inline uint8_t* namco_access( struct Nes_Namco_Apu* this ) -{ - int addr = this->addr_reg & 0x7F; - if ( this->addr_reg & 0x80 ) - this->addr_reg = (addr + 1) | 0x80; - return &this->reg [addr]; -} - -static inline void Namco_volume( struct Nes_Namco_Apu* this, int v ) { Synth_volume( &this->synth, v / 10 / namco_osc_count / 15 ); } - -// Write-only address register is at 0xF800 -static inline void Namco_write_addr( struct Nes_Namco_Apu* this, int v ) { this->addr_reg = v; } - -static inline int Namco_read_data( struct Nes_Namco_Apu* this ) { return *namco_access( this ); } - -static inline void Namco_osc_output( struct Nes_Namco_Apu* this, int i, struct Blip_Buffer* buf ) -{ - assert( (unsigned) i < namco_osc_count ); - this->oscs [i].output = buf; -} - -// Read/write data register is at 0x4800 -void Namco_run_until( struct Nes_Namco_Apu* this, blip_time_t ); -static inline void Namco_write_data( struct Nes_Namco_Apu* this, blip_time_t time, int data ) -{ - Namco_run_until( this, time ); - *namco_access( this ) = data; -} - -#endif diff --git a/apps/codecs/libgme/nes_oscs.c b/apps/codecs/libgme/nes_oscs.c deleted file mode 100644 index ac6e5759da..0000000000 --- a/apps/codecs/libgme/nes_oscs.c +++ /dev/null @@ -1,592 +0,0 @@ -// Nes_Snd_Emu 0.1.8. http://www.slack.net/~ant/ - -#include "nes_apu.h" - -/* Copyright (C) 2003-2006 Shay Green. This module is free software; you -can redistribute it and/or modify it under the terms of the GNU Lesser -General Public License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. This -module is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more -details. You should have received a copy of the GNU Lesser General Public -License along with this module; if not, write to the Free Software Foundation, -Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ - -#include "blargg_source.h" - -// Nes_Osc - -void Osc_clock_length( struct Nes_Osc* this, int halt_mask ) -{ - if ( this->length_counter && !(this->regs [0] & halt_mask) ) - this->length_counter--; -} - -// Nes_Square - -void Square_clock_envelope( struct Nes_Square* this ) -{ - struct Nes_Osc* osc = &this->osc; - int period = osc->regs [0] & 15; - if ( osc->reg_written [3] ) { - osc->reg_written [3] = false; - this->env_delay = period; - this->envelope = 15; - } - else if ( --this->env_delay < 0 ) { - this->env_delay = period; - if ( this->envelope | (osc->regs [0] & 0x20) ) - this->envelope = (this->envelope - 1) & 15; - } -} - -int Square_volume( struct Nes_Square* this ) -{ - struct Nes_Osc* osc = &this->osc; - return osc->length_counter == 0 ? 0 : (osc->regs [0] & 0x10) ? (osc->regs [0] & 15) : this->envelope; -} - -void Square_clock_sweep( struct Nes_Square* this, int negative_adjust ) -{ - struct Nes_Osc* osc = &this->osc; - int sweep = osc->regs [1]; - - if ( --this->sweep_delay < 0 ) - { - osc->reg_written [1] = true; - - int period = Osc_period( osc ); - int shift = sweep & shift_mask; - if ( shift && (sweep & 0x80) && period >= 8 ) - { - int offset = period >> shift; - - if ( sweep & negate_flag ) - offset = negative_adjust - offset; - - if ( period + offset < 0x800 ) - { - period += offset; - // rewrite period - osc->regs [2] = period & 0xFF; - osc->regs [3] = (osc->regs [3] & ~7) | ((period >> 8) & 7); - } - } - } - - if ( osc->reg_written [1] ) { - osc->reg_written [1] = false; - this->sweep_delay = (sweep >> 4) & 7; - } -} - -// TODO: clean up -static inline nes_time_t Square_maintain_phase( struct Nes_Square* this, nes_time_t time, nes_time_t end_time, - nes_time_t timer_period ) -{ - nes_time_t remain = end_time - time; - if ( remain > 0 ) - { - int count = (remain + timer_period - 1) / timer_period; - this->phase = (this->phase + count) & (square_phase_range - 1); - time += count * timer_period; - } - return time; -} - -void Square_run( struct Nes_Square* this, nes_time_t time, nes_time_t end_time ) -{ - struct Nes_Osc* osc = &this->osc; - const int period = Osc_period( osc ); - const int timer_period = (period + 1) * 2; - - if ( !osc->output ) - { - osc->delay = Square_maintain_phase( this, time + osc->delay, end_time, timer_period ) - end_time; - return; - } - - int offset = period >> (osc->regs [1] & shift_mask); - if ( osc->regs [1] & negate_flag ) - offset = 0; - - const int volume = Square_volume( this ); - if ( volume == 0 || period < 8 || (period + offset) >= 0x800 ) - { - if ( osc->last_amp ) { - Blip_set_modified( osc->output ); - Synth_offset( this->synth, time, -osc->last_amp, osc->output ); - osc->last_amp = 0; - } - - time += osc->delay; - time = Square_maintain_phase( this, time, end_time, timer_period ); - } - else - { - // handle duty select - int duty_select = (osc->regs [0] >> 6) & 3; - int duty = 1 << duty_select; // 1, 2, 4, 2 - int amp = 0; - if ( duty_select == 3 ) { - duty = 2; // negated 25% - amp = volume; - } - if ( this->phase < duty ) - amp ^= volume; - - Blip_set_modified( osc->output ); - { - int delta = Osc_update_amp( osc, amp ); - if ( delta ) - Synth_offset( this->synth, time, delta, osc->output ); - } - - time += osc->delay; - if ( time < end_time ) - { - struct Blip_Buffer* const output = osc->output; - Synth* synth = this->synth; - int delta = amp * 2 - volume; - int phase = this->phase; - - do { - phase = (phase + 1) & (square_phase_range - 1); - if ( phase == 0 || phase == duty ) { - delta = -delta; - Synth_offset_inline( synth, time, delta, output ); - } - time += timer_period; - } - while ( time < end_time ); - - osc->last_amp = (delta + volume) >> 1; - this->phase = phase; - } - } - - osc->delay = time - end_time; -} - -// Nes_Triangle - -void Triangle_clock_linear_counter( struct Nes_Triangle* this ) -{ - struct Nes_Osc* osc = &this->osc; - if ( osc->reg_written [3] ) - this->linear_counter = osc->regs [0] & 0x7F; - else if ( this->linear_counter ) - this->linear_counter--; - - if ( !(osc->regs [0] & 0x80) ) - osc->reg_written [3] = false; -} - -static inline int Triangle_calc_amp( struct Nes_Triangle* this ) -{ - int amp = Triangle_phase_range - this->phase; - if ( amp < 0 ) - amp = this->phase - (Triangle_phase_range + 1); - return amp; -} - -// TODO: clean up -static inline nes_time_t Triangle_maintain_phase( struct Nes_Triangle* this, nes_time_t time, nes_time_t end_time, - nes_time_t timer_period ) -{ - nes_time_t remain = end_time - time; - if ( remain > 0 ) - { - int count = (remain + timer_period - 1) / timer_period; - this->phase = ((unsigned) this->phase + 1 - count) & (Triangle_phase_range * 2 - 1); - this->phase++; - time += count * timer_period; - } - return time; -} - -void Triangle_run( struct Nes_Triangle* this, nes_time_t time, nes_time_t end_time ) -{ - struct Nes_Osc* osc = &this->osc; - const int timer_period = Osc_period( osc ) + 1; - if ( !osc->output ) - { - time += osc->delay; - osc->delay = 0; - if ( osc->length_counter && this->linear_counter && timer_period >= 3 ) - osc->delay = Triangle_maintain_phase( this, time, end_time, timer_period ) - end_time; - return; - } - - // to do: track phase when period < 3 - // to do: Output 7.5 on dac when period < 2? More accurate, but results in more clicks. - - int delta = Osc_update_amp( osc, Triangle_calc_amp( this ) ); - if ( delta ) - { - Blip_set_modified( osc->output ); - Synth_offset( &this->synth, time, delta, osc->output ); - } - - time += osc->delay; - if ( osc->length_counter == 0 || this->linear_counter == 0 || timer_period < 3 ) - { - time = end_time; - } - else if ( time < end_time ) - { - struct Blip_Buffer* const output = osc->output; - - int phase = this->phase; - int volume = 1; - if ( phase > Triangle_phase_range ) { - phase -= Triangle_phase_range; - volume = -volume; - } - Blip_set_modified( osc->output ); - - do { - if ( --phase == 0 ) { - phase = Triangle_phase_range; - volume = -volume; - } - else - { - Synth_offset_inline( &this->synth, time, volume, output ); - } - - time += timer_period; - } - while ( time < end_time ); - - if ( volume < 0 ) - phase += Triangle_phase_range; - this->phase = phase; - osc->last_amp = Triangle_calc_amp( this ); - } - osc->delay = time - end_time; -} - -// Nes_Dmc - -void Dmc_reset( struct Nes_Dmc* this ) -{ - this->address = 0; - this->dac = 0; - this->buf = 0; - this->bits_remain = 1; - this->bits = 0; - this->buf_full = false; - this->silence = true; - this->next_irq = apu_no_irq; - this->irq_flag = false; - this->irq_enabled = false; - - Osc_reset( &this->osc ); - this->period = 0x1AC; -} - -void Dmc_recalc_irq( struct Nes_Dmc* this ) -{ - struct Nes_Osc* osc = &this->osc; - nes_time_t irq = apu_no_irq; - if ( this->irq_enabled && osc->length_counter ) - irq = this->apu->last_dmc_time + osc->delay + - ((osc->length_counter - 1) * 8 + this->bits_remain - 1) * (nes_time_t) (this->period) + 1; - if ( irq != this->next_irq ) { - this->next_irq = irq; - Apu_irq_changed( this->apu ); - } -} - -int Dmc_count_reads( struct Nes_Dmc* this, nes_time_t time, nes_time_t* last_read ) -{ - struct Nes_Osc* osc = &this->osc; - if ( last_read ) - *last_read = time; - - if ( osc->length_counter == 0 ) - return 0; // not reading - - nes_time_t first_read = Dmc_next_read_time( this ); - nes_time_t avail = time - first_read; - if ( avail <= 0 ) - return 0; - - int count = (avail - 1) / (this->period * 8) + 1; - if ( !(osc->regs [0] & loop_flag) && count > osc->length_counter ) - count = osc->length_counter; - - if ( last_read ) - { - *last_read = first_read + (count - 1) * (this->period * 8) + 1; - check( *last_read <= time ); - check( count == count_reads( *last_read, NULL ) ); - check( count - 1 == count_reads( *last_read - 1, NULL ) ); - } - - return count; -} - -static short const dmc_period_table [2] [16] = { - {428, 380, 340, 320, 286, 254, 226, 214, // NTSC - 190, 160, 142, 128, 106, 84, 72, 54}, - - {398, 354, 316, 298, 276, 236, 210, 198, // PAL - 176, 148, 132, 118, 98, 78, 66, 50} -}; - -static inline void Dmc_reload_sample( struct Nes_Dmc* this ) -{ - this->address = 0x4000 + this->osc.regs [2] * 0x40; - this->osc.length_counter = this->osc.regs [3] * 0x10 + 1; -} - -static int const dmc_table [128] = -{ - 0, 24, 48, 71, 94, 118, 141, 163, 186, 209, 231, 253, 275, 297, 319, 340, - 361, 383, 404, 425, 445, 466, 486, 507, 527, 547, 567, 587, 606, 626, 645, 664, - 683, 702, 721, 740, 758, 777, 795, 813, 832, 850, 867, 885, 903, 920, 938, 955, - 972, 989,1006,1023,1040,1056,1073,1089,1105,1122,1138,1154,1170,1185,1201,1217, -1232,1248,1263,1278,1293,1308,1323,1338,1353,1368,1382,1397,1411,1425,1440,1454, -1468,1482,1496,1510,1523,1537,1551,1564,1578,1591,1604,1618,1631,1644,1657,1670, -1683,1695,1708,1721,1733,1746,1758,1771,1783,1795,1807,1819,1831,1843,1855,1867, -1879,1890,1902,1914,1925,1937,1948,1959,1971,1982,1993,2004,2015,2026,2037,2048, -}; - -static inline int update_amp_nonlinear( struct Nes_Dmc* this, int in ) -{ - if ( !this->nonlinear ) - in = dmc_table [in]; - int delta = in - this->osc.last_amp; - this->osc.last_amp = in; - return delta; -} - -void Dmc_write_register( struct Nes_Dmc* this, int addr, int data ) -{ - if ( addr == 0 ) - { - this->period = dmc_period_table [this->pal_mode] [data & 15]; - this->irq_enabled = (data & 0xC0) == 0x80; // enabled only if loop disabled - this->irq_flag &= this->irq_enabled; - Dmc_recalc_irq( this ); - } - else if ( addr == 1 ) - { - this->dac = data & 0x7F; - } -} - -void Dmc_start( struct Nes_Dmc* this ) -{ - Dmc_reload_sample( this ); - Dmc_fill_buffer( this ); - Dmc_recalc_irq( this ); -} - -void Dmc_fill_buffer( struct Nes_Dmc* this ) -{ - if ( !this->buf_full && this->osc.length_counter ) - { - require( this->prg_reader ); // prg_reader must be set - this->buf = this->prg_reader( this->prg_reader_data, 0x8000u + this->address ); - this->address = (this->address + 1) & 0x7FFF; - this->buf_full = true; - if ( --this->osc.length_counter == 0 ) - { - if ( this->osc.regs [0] & loop_flag ) { - Dmc_reload_sample( this ); - } - else { - this->apu->osc_enables &= ~0x10; - this->irq_flag = this->irq_enabled; - this->next_irq = apu_no_irq; - Apu_irq_changed( this->apu ); - } - } - } -} - -void Dmc_run( struct Nes_Dmc* this, nes_time_t time, nes_time_t end_time ) -{ - struct Nes_Osc* osc = &this->osc; - int delta = update_amp_nonlinear( this, this->dac ); - if ( !osc->output ) - { - this->silence = true; - } - else if ( delta ) - { - Blip_set_modified( osc->output ); - Synth_offset( &this->synth, time, delta, osc->output ); - } - - time += osc->delay; - if ( time < end_time ) - { - int bits_remain = this->bits_remain; - if ( this->silence && !this->buf_full ) - { - int count = (end_time - time + this->period - 1) / this->period; - bits_remain = (bits_remain - 1 + 8 - (count % 8)) % 8 + 1; - time += count * this->period; - } - else - { - struct Blip_Buffer* const output = osc->output; - const int period = this->period; - int bits = this->bits; - int dac = this->dac; - if ( output ) - Blip_set_modified( output ); - - do - { - if ( !this->silence ) - { - int step = (bits & 1) * 4 - 2; - bits >>= 1; - if ( (unsigned) (dac + step) <= 0x7F ) { - dac += step; - Synth_offset_inline( &this->synth, time, update_amp_nonlinear( this, dac ), output ); - } - } - - time += period; - - if ( --bits_remain == 0 ) - { - bits_remain = 8; - if ( !this->buf_full ) { - this->silence = true; - } - else - { - this->silence = false; - bits = this->buf; - this->buf_full = false; - if ( !output ) - this->silence = true; - Dmc_fill_buffer( this ); - } - } - } - while ( time < end_time ); - - this->dac = dac; - //osc->last_amp = dac; - this->bits = bits; - } - this->bits_remain = bits_remain; - } - osc->delay = time - end_time; -} - -// Nes_Noise - -static short const noise_period_table [16] = { - 0x004, 0x008, 0x010, 0x020, 0x040, 0x060, 0x080, 0x0A0, - 0x0CA, 0x0FE, 0x17C, 0x1FC, 0x2FA, 0x3F8, 0x7F2, 0xFE4 -}; - -void Noise_clock_envelope( struct Nes_Noise* this ) -{ - struct Nes_Osc* osc = &this->osc; - int period = osc->regs [0] & 15; - if ( osc->reg_written [3] ) { - osc->reg_written [3] = false; - this->env_delay = period; - this->envelope = 15; - } - else if ( --this->env_delay < 0 ) { - this->env_delay = period; - if ( this->envelope | (osc->regs [0] & 0x20) ) - this->envelope = (this->envelope - 1) & 15; - } -} - -int Noise_volume( struct Nes_Noise* this ) -{ - struct Nes_Osc* osc = &this->osc; - return osc->length_counter == 0 ? 0 : (osc->regs [0] & 0x10) ? (osc->regs [0] & 15) : this->envelope; -} - -void Noise_run( struct Nes_Noise* this, nes_time_t time, nes_time_t end_time ) -{ - struct Nes_Osc* osc = &this->osc; - int period = noise_period_table [osc->regs [2] & 15]; - - if ( !osc->output ) - { - // TODO: clean up - time += osc->delay; - osc->delay = time + (end_time - time + period - 1) / period * period - end_time; - return; - } - - const int volume = Noise_volume( this ); - int amp = (this->noise & 1) ? volume : 0; - { - int delta = Osc_update_amp( osc, amp ); - if ( delta ) - { - Blip_set_modified( osc->output ); - Synth_offset( &this->synth, time, delta, osc->output ); - } - } - - time += osc->delay; - if ( time < end_time ) - { - const int mode_flag = 0x80; - - if ( !volume ) - { - // round to next multiple of period - time += (end_time - time + period - 1) / period * period; - - // approximate noise cycling while muted, by shuffling up noise register - // to do: precise muted noise cycling? - if ( !(osc->regs [2] & mode_flag) ) { - int feedback = (this->noise << 13) ^ (this->noise << 14); - this->noise = (feedback & 0x4000) | (this->noise >> 1); - } - } - else - { - struct Blip_Buffer* const output = osc->output; - - // using resampled time avoids conversion in synth.offset() - blip_resampled_time_t rperiod = Blip_resampled_duration( output, period ); - blip_resampled_time_t rtime = Blip_resampled_time( output, time ); - - int noise = this->noise; - int delta = amp * 2 - volume; - const int tap = (osc->regs [2] & mode_flag ? 8 : 13); - Blip_set_modified( output ); - - do { - int feedback = (noise << tap) ^ (noise << 14); - time += period; - - if ( (noise + 1) & 2 ) { - // bits 0 and 1 of noise differ - delta = -delta; - Synth_offset_resampled( &this->synth, rtime, delta, output ); - } - - rtime += rperiod; - noise = (feedback & 0x4000) | (noise >> 1); - } - while ( time < end_time ); - - osc->last_amp = (delta + volume) >> 1; - this->noise = noise; - } - } - - osc->delay = time - end_time; -} - diff --git a/apps/codecs/libgme/nes_oscs.h b/apps/codecs/libgme/nes_oscs.h deleted file mode 100644 index 1eeb302e6c..0000000000 --- a/apps/codecs/libgme/nes_oscs.h +++ /dev/null @@ -1,164 +0,0 @@ -// Private oscillators used by Nes_Apu - -// Nes_Snd_Emu 0.1.8 -#ifndef NES_OSCS_H -#define NES_OSCS_H - -#include "blargg_common.h" -#include "blip_buffer.h" -#include "nes_cpu.h" - -struct Nes_Apu; - -struct Nes_Osc -{ - unsigned char regs [4]; - bool reg_written [4]; - struct Blip_Buffer* output; - int length_counter;// length counter (0 if unused by oscillator) - int delay; // delay until next (potential) transition - int last_amp; // last amplitude oscillator was outputting -}; - -void Osc_clock_length( struct Nes_Osc* this, int halt_mask ); -static inline int Osc_period( struct Nes_Osc* this ) -{ - return (this->regs [3] & 7) * 0x100 + (this->regs [2] & 0xFF); -} - -static inline void Osc_reset( struct Nes_Osc* this ) -{ - this->delay = 0; - this->last_amp = 0; -} - -static inline int Osc_update_amp( struct Nes_Osc* this, int amp ) -{ - int delta = amp - this->last_amp; - this->last_amp = amp; - return delta; -} - -// Nes_Square - -enum { negate_flag = 0x08 }; -enum { shift_mask = 0x07 }; -enum { square_phase_range = 8 }; - -typedef struct Blip_Synth Synth; - -struct Nes_Square -{ - struct Nes_Osc osc; - int envelope; - int env_delay; - int phase; - int sweep_delay; - - Synth* synth; // shared between squares -}; - -static inline void Square_set_synth( struct Nes_Square* this, Synth* s ) { this->synth = s; } - -void Square_clock_sweep( struct Nes_Square* this, int adjust ); -void Square_run( struct Nes_Square* this, nes_time_t, nes_time_t ); - -static inline void Square_reset( struct Nes_Square* this ) -{ - this->sweep_delay = 0; - this->envelope = 0; - this->env_delay = 0; - Osc_reset( &this->osc ); -} - -void Square_clock_envelope( struct Nes_Square* this ); -int Square_volume( struct Nes_Square* this ); - -// Nes_Triangle - -enum { Triangle_phase_range = 16 }; - -struct Nes_Triangle -{ - struct Nes_Osc osc; - - int phase; - int linear_counter; - struct Blip_Synth synth; -}; - -void Triangle_run( struct Nes_Triangle* this, nes_time_t, nes_time_t ); -void Triangle_clock_linear_counter( struct Nes_Triangle* this ); - -static inline void Triangle_reset( struct Nes_Triangle* this ) -{ - this->linear_counter = 0; - this->phase = 1; - Osc_reset( &this->osc ); -} - -// Nes_Noise -struct Nes_Noise -{ - struct Nes_Osc osc; - - int envelope; - int env_delay; - int noise; - struct Blip_Synth synth; -}; - -void Noise_clock_envelope( struct Nes_Noise* this ); -int Noise_volume( struct Nes_Noise* this ); -void Noise_run( struct Nes_Noise* this, nes_time_t, nes_time_t ); - -static inline void Noise_reset( struct Nes_Noise* this ) -{ - this->noise = 1 << 14; - this->envelope = 0; - this->env_delay = 0; - Osc_reset( &this->osc ); -} - -// Nes_Dmc - -enum { loop_flag = 0x40 }; - -struct Nes_Dmc -{ - struct Nes_Osc osc; - - int address; // address of next byte to read - int period; - int buf; - int bits_remain; - int bits; - bool buf_full; - bool silence; - - int dac; - - nes_time_t next_irq; - bool irq_enabled; - bool irq_flag; - bool pal_mode; - bool nonlinear; - - int (*prg_reader)( void*, int ); // needs to be initialized to prg read function - void* prg_reader_data; - - struct Nes_Apu* apu; - - struct Blip_Synth synth; -}; - -void Dmc_start( struct Nes_Dmc* this ); -void Dmc_write_register( struct Nes_Dmc* this, int, int ); -void Dmc_run( struct Nes_Dmc* this, nes_time_t, nes_time_t ); -void Dmc_recalc_irq( struct Nes_Dmc* this ); -void Dmc_fill_buffer( struct Nes_Dmc* this ); -void Dmc_reset( struct Nes_Dmc* this ); - -int Dmc_count_reads( struct Nes_Dmc* this, nes_time_t, nes_time_t* ); - -#endif diff --git a/apps/codecs/libgme/nes_vrc6_apu.c b/apps/codecs/libgme/nes_vrc6_apu.c deleted file mode 100644 index 99a9ae3fed..0000000000 --- a/apps/codecs/libgme/nes_vrc6_apu.c +++ /dev/null @@ -1,192 +0,0 @@ - // Nes_Snd_Emu 0.1.8. http://www.slack.net/~ant/ - -#include "nes_vrc6_apu.h" - -/* Copyright (C) 2003-2006 Shay Green. This module is free software; you -can redistribute it and/or modify it under the terms of the GNU Lesser -General Public License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. This -module is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more -details. You should have received a copy of the GNU Lesser General Public -License along with this module; if not, write to the Free Software Foundation, -Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ - -#include "blargg_source.h" - -void Vrc6_init( struct Nes_Vrc6_Apu* this ) -{ - Synth_init( &this->saw_synth ); - Synth_init( &this->square_synth ); - - Vrc6_output( this, NULL ); - Vrc6_volume( this, (int)FP_ONE_VOLUME ); - Vrc6_reset( this ); -} - -void Vrc6_reset( struct Nes_Vrc6_Apu* this ) -{ - this->last_time = 0; - int i; - for ( i = 0; i < vrc6_osc_count; i++ ) - { - struct Vrc6_Osc* osc = &this->oscs [i]; - int j; - for ( j = 0; j < vrc6_reg_count; j++ ) - osc->regs [j] = 0; - osc->delay = 0; - osc->last_amp = 0; - osc->phase = 1; - osc->amp = 0; - } -} - -void Vrc6_output( struct Nes_Vrc6_Apu* this, struct Blip_Buffer* buf ) -{ - int i; - for ( i = 0; i < vrc6_osc_count; i++ ) - Vrc6_osc_output( this, i, buf ); -} - -void run_square( struct Nes_Vrc6_Apu* this, struct Vrc6_Osc* osc, blip_time_t end_time ); -void run_saw( struct Nes_Vrc6_Apu* this, blip_time_t end_time ); -static void Vrc6_run_until( struct Nes_Vrc6_Apu* this, blip_time_t time ) -{ - require( time >= this->last_time ); - run_square( this, &this->oscs [0], time ); - run_square( this, &this->oscs [1], time ); - run_saw( this, time ); - this->last_time = time; -} - -void Vrc6_write_osc( struct Nes_Vrc6_Apu* this, blip_time_t time, int osc_index, int reg, int data ) -{ - require( (unsigned) osc_index < vrc6_osc_count ); - require( (unsigned) reg < vrc6_reg_count ); - - Vrc6_run_until( this, time ); - this->oscs [osc_index].regs [reg] = data; -} - -void Vrc6_end_frame( struct Nes_Vrc6_Apu* this, blip_time_t time ) -{ - if ( time > this->last_time ) - Vrc6_run_until( this, time ); - - assert( this->last_time >= time ); - this->last_time -= time; -} - -void run_square( struct Nes_Vrc6_Apu* this, struct Vrc6_Osc* osc, blip_time_t end_time ) -{ - struct Blip_Buffer* output = osc->output; - if ( !output ) - return; - - int volume = osc->regs [0] & 15; - if ( !(osc->regs [2] & 0x80) ) - volume = 0; - - int gate = osc->regs [0] & 0x80; - int duty = ((osc->regs [0] >> 4) & 7) + 1; - int delta = ((gate || osc->phase < duty) ? volume : 0) - osc->last_amp; - blip_time_t time = this->last_time; - if ( delta ) - { - osc->last_amp += delta; - Blip_set_modified( output ); - Synth_offset( &this->square_synth, time, delta, output ); - } - - time += osc->delay; - osc->delay = 0; - int period = Vrc6_osc_period( osc ); - if ( volume && !gate && period > 4 ) - { - if ( time < end_time ) - { - int phase = osc->phase; - Blip_set_modified( output ); - - do - { - phase++; - if ( phase == 16 ) - { - phase = 0; - osc->last_amp = volume; - Synth_offset( &this->square_synth, time, volume, output ); - } - if ( phase == duty ) - { - osc->last_amp = 0; - Synth_offset( &this->square_synth, time, -volume, output ); - } - time += period; - } - while ( time < end_time ); - - osc->phase = phase; - } - osc->delay = time - end_time; - } -} - -void run_saw( struct Nes_Vrc6_Apu* this, blip_time_t end_time ) -{ - struct Vrc6_Osc* osc = &this->oscs [2]; - struct Blip_Buffer* output = osc->output; - if ( !output ) - return; - Blip_set_modified( output ); - - int amp = osc->amp; - int amp_step = osc->regs [0] & 0x3F; - blip_time_t time = this->last_time; - int last_amp = osc->last_amp; - if ( !(osc->regs [2] & 0x80) || !(amp_step | amp) ) - { - osc->delay = 0; - int delta = (amp >> 3) - last_amp; - last_amp = amp >> 3; - Synth_offset( &this->saw_synth, time, delta, output ); - } - else - { - time += osc->delay; - if ( time < end_time ) - { - int period = Vrc6_osc_period( osc ) * 2; - int phase = osc->phase; - - do - { - if ( --phase == 0 ) - { - phase = 7; - amp = 0; - } - - int delta = (amp >> 3) - last_amp; - if ( delta ) - { - last_amp = amp >> 3; - Synth_offset( &this->saw_synth, time, delta, output ); - } - - time += period; - amp = (amp + amp_step) & 0xFF; - } - while ( time < end_time ); - - osc->phase = phase; - osc->amp = amp; - } - - osc->delay = time - end_time; - } - - osc->last_amp = last_amp; -} - diff --git a/apps/codecs/libgme/nes_vrc6_apu.h b/apps/codecs/libgme/nes_vrc6_apu.h deleted file mode 100644 index 57b8a42a79..0000000000 --- a/apps/codecs/libgme/nes_vrc6_apu.h +++ /dev/null @@ -1,62 +0,0 @@ -// Konami VRC6 sound chip emulator - -// Nes_Snd_Emu 0.2.0-pre -#ifndef NES_VRC6_APU_H -#define NES_VRC6_APU_H - -#include "blargg_common.h" -#include "blip_buffer.h" - -enum { vrc6_osc_count = 3 }; -enum { vrc6_reg_count = 3 }; -enum { vrc6_base_addr = 0x9000 }; -enum { vrc6_addr_step = 0x1000 }; - -struct Vrc6_Osc -{ - uint8_t regs [3]; - struct Blip_Buffer* output; - int delay; - int last_amp; - int phase; - int amp; // only used by saw -}; - -static inline int Vrc6_osc_period( struct Vrc6_Osc* this ) -{ - return (this->regs [2] & 0x0F) * 0x100 + this->regs [1] + 1; -} - -struct Nes_Vrc6_Apu { - struct Vrc6_Osc oscs [vrc6_osc_count]; - blip_time_t last_time; - - struct Blip_Synth saw_synth; - struct Blip_Synth square_synth; -}; - -// See Nes_Apu.h for reference -void Vrc6_init( struct Nes_Vrc6_Apu* this ); -void Vrc6_reset( struct Nes_Vrc6_Apu* this ); -void Vrc6_output( struct Nes_Vrc6_Apu* this, struct Blip_Buffer* ); -void Vrc6_end_frame( struct Nes_Vrc6_Apu* this, blip_time_t ); - -// Oscillator 0 write-only registers are at $9000-$9002 -// Oscillator 1 write-only registers are at $A000-$A002 -// Oscillator 2 write-only registers are at $B000-$B002 -void Vrc6_write_osc( struct Nes_Vrc6_Apu* this, blip_time_t, int osc, int reg, int data ); - -static inline void Vrc6_osc_output( struct Nes_Vrc6_Apu* this, int i, struct Blip_Buffer* buf ) -{ - assert( (unsigned) i < vrc6_osc_count ); - this->oscs [i].output = buf; -} - -static inline void Vrc6_volume( struct Nes_Vrc6_Apu* this, int v ) -{ - long long const factor = (long long)(FP_ONE_VOLUME * 0.0967 * 2); - Synth_volume( &this->saw_synth, (int)(v * factor / 31 / FP_ONE_VOLUME) ); - Synth_volume( &this->square_synth, (int)(v * factor / 2 / 15 / FP_ONE_VOLUME) ); -} - -#endif diff --git a/apps/codecs/libgme/nes_vrc7_apu.c b/apps/codecs/libgme/nes_vrc7_apu.c deleted file mode 100644 index 8d3c2e88a6..0000000000 --- a/apps/codecs/libgme/nes_vrc7_apu.c +++ /dev/null @@ -1,88 +0,0 @@ - -#include "nes_vrc7_apu.h" -#include "blargg_source.h" - -int const period = 36; // NES CPU clocks per FM clock - -void Vrc7_init( struct Nes_Vrc7_Apu* this ) -{ - Synth_init( &this->synth ); - - OPLL_new ( &this->opll, 3579545, 3579545 / 72 ); - OPLL_reset_patch( &this->opll, OPLL_VRC7_TONE ); - - this->osc.output = 0; - this->osc.last_amp = 0; - this->mask = 0; - - Vrc7_volume( this, (int)FP_ONE_VOLUME ); - Vrc7_reset( this ); -} - -void Vrc7_reset( struct Nes_Vrc7_Apu* this ) -{ - this->addr = 0; - this->next_time = 0; - this->osc.last_amp = 0; - - OPLL_reset (&this->opll); - OPLL_setMask(&this->opll, this->mask); -} - -void Vrc7_set_rate( struct Nes_Vrc7_Apu* this, int r ) -{ - OPLL_set_quality( &this->opll, r < 44100 ? 0 : 1 ); -} - -void Vrc7_write_reg( struct Nes_Vrc7_Apu* this, int data ) -{ - this->addr = data; -} - -void Vrc7_run_until( struct Nes_Vrc7_Apu* this, blip_time_t end_time ); -void Vrc7_write_data( struct Nes_Vrc7_Apu* this, blip_time_t time, int data ) -{ - if ( time > this->next_time ) - Vrc7_run_until( this, time ); - - OPLL_writeIO( &this->opll, 0, this->addr ); - OPLL_writeIO( &this->opll, 1, data ); -} - -void Vrc7_end_frame( struct Nes_Vrc7_Apu* this, blip_time_t time ) -{ - if ( time > this->next_time ) - Vrc7_run_until( this, time ); - - this->next_time -= time; - assert( this->next_time >= 0 ); - - if ( this->osc.output ) - Blip_set_modified( this->osc.output ); -} - -void Vrc7_run_until( struct Nes_Vrc7_Apu* this, blip_time_t end_time ) -{ - require( end_time > this->next_time ); - - blip_time_t time = this->next_time; - OPLL* opll = &this->opll; // cache - struct Blip_Buffer* const output = this-> osc.output; - if ( output ) - { - do - { - int amp = OPLL_calc( opll ) << 1; - int delta = amp - this->osc.last_amp; - if ( delta ) - { - this->osc.last_amp = amp; - Synth_offset_inline( &this->synth, time, delta, output ); - } - time += period; - } - while ( time < end_time ); - } - - this->next_time = time; -} diff --git a/apps/codecs/libgme/nes_vrc7_apu.h b/apps/codecs/libgme/nes_vrc7_apu.h deleted file mode 100644 index 1f45a435db..0000000000 --- a/apps/codecs/libgme/nes_vrc7_apu.h +++ /dev/null @@ -1,52 +0,0 @@ -// Konami VRC7 sound chip emulator - -#ifndef NES_VRC7_APU_H -#define NES_VRC7_APU_H - -#include "blargg_common.h" -#include "blip_buffer.h" - -#include "emu2413.h" - -enum { vrc7_osc_count = 6 }; - -struct vrc7_osc_t { - struct Blip_Buffer* output; - int last_amp; -}; - -struct Nes_Vrc7_Apu { - OPLL opll; - int addr; - blip_time_t next_time; - struct vrc7_osc_t osc; - struct Blip_Synth synth; - e_uint32 mask; -}; - -// See Nes_Apu.h for reference -void Vrc7_init( struct Nes_Vrc7_Apu* this ); -void Vrc7_reset( struct Nes_Vrc7_Apu* this ); -void Vrc7_set_rate( struct Nes_Vrc7_Apu* this, int r ); -void Vrc7_end_frame( struct Nes_Vrc7_Apu* this, blip_time_t ); - -void Vrc7_write_reg( struct Nes_Vrc7_Apu* this, int reg ); -void Vrc7_write_data( struct Nes_Vrc7_Apu* this, blip_time_t, int data ); - -void output_changed( struct Nes_Vrc7_Apu* this ); -static inline void Vrc7_set_output( struct Nes_Vrc7_Apu* this, int i, struct Blip_Buffer* buf ) -{ - assert( (unsigned) i < vrc7_osc_count ); - this->mask |= 1 << i; - - // Will use OPLL_setMask to mute voices - if ( buf ) { - this->mask ^= 1 << i; - this->osc.output = buf; - } -} - -// DB2LIN_AMP_BITS == 11, * 2 -static inline void Vrc7_volume( struct Nes_Vrc7_Apu* this, int v ) { Synth_volume( &this->synth, v / 3 / 4096 ); } - -#endif diff --git a/apps/codecs/libgme/nsf_cpu.c b/apps/codecs/libgme/nsf_cpu.c deleted file mode 100644 index 1f44bd3c3c..0000000000 --- a/apps/codecs/libgme/nsf_cpu.c +++ /dev/null @@ -1,115 +0,0 @@ -// Normal cpu for NSF emulator - -// Game_Music_Emu 0.6-pre. http://www.slack.net/~ant/ - -#include "nsf_emu.h" - -#include "blargg_endian.h" - -#ifdef BLARGG_DEBUG_H - //#define CPU_LOG_START 1000000 - //#include "nes_cpu_log.h" - #undef LOG_MEM -#endif - -/* Copyright (C) 2003-2008 Shay Green. This module is free software; you -can redistribute it and/or modify it under the terms of the GNU Lesser -General Public License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. This -module is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more -details. You should have received a copy of the GNU Lesser General Public -License along with this module; if not, write to the Free Software Foundation, -Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ - -#include "blargg_source.h" - -#ifndef LOG_MEM - #define LOG_MEM( addr, str, data ) data -#endif - -int read_mem( struct Nsf_Emu* this, addr_t addr ) -{ - int result = this->low_ram [addr & (low_ram_size-1)]; // also handles wrap-around - if ( addr & 0xE000 ) - { - result = *Cpu_get_code( &this->cpu, addr ); - if ( addr < sram_addr ) - { - if ( addr == apu_status_addr ) - result = Apu_read_status( &this->apu, Cpu_time( &this->cpu ) ); - else - result = cpu_read( this, addr ); - } - } - return LOG_MEM( addr, ">", result ); -} - -void write_mem( struct Nsf_Emu* this, addr_t addr, int data ) -{ - (void) LOG_MEM( addr, "<", data ); - - int offset = addr - sram_addr; - if ( (unsigned) offset < sram_size ) - { - sram( this ) [offset] = data; - } - else - { - // after sram because cpu handles most low_ram accesses internally already - int temp = addr & (low_ram_size-1); // also handles wrap-around - if ( !(addr & 0xE000) ) - { - this->low_ram [temp] = data; - } - else - { - int bank = addr - banks_addr; - if ( (unsigned) bank < bank_count ) - { - write_bank( this, bank, data ); - } - else if ( (unsigned) (addr - apu_io_addr) < apu_io_size ) - { - Apu_write_register( &this->apu, Cpu_time( &this->cpu ), addr, data ); - } - else - { - #ifndef NSF_EMU_APU_ONLY - // 0x8000-0xDFFF is writable - int i = addr - 0x8000; - if ( fds_enabled( this ) && (unsigned) i < fdsram_size ) - fdsram( this ) [i] = data; - else - #endif - cpu_write( this, addr, data ); - } - } - } -} - -#define READ_LOW( addr ) (LOG_MEM( addr, ">", this->low_ram [addr] )) -#define WRITE_LOW( addr, data ) (LOG_MEM( addr, "<", this->low_ram [addr] = data )) - -#define CAN_WRITE_FAST( addr ) (addr < low_ram_size) -#define WRITE_FAST WRITE_LOW - -// addr < 0x2000 || addr >= 0x8000 -#define CAN_READ_FAST( addr ) ((addr ^ 0x8000) < 0xA000) -#define READ_FAST( addr, out ) (LOG_MEM( addr, ">", out = READ_CODE( addr ) )) - -#define READ_MEM( addr ) read_mem( this, addr ) -#define WRITE_MEM( addr, data ) write_mem( this, addr, data ) - -#define CPU_BEGIN \ -bool run_cpu_until( struct Nsf_Emu* this, nes_time_t end ) \ -{ \ - struct Nes_Cpu* cpu = &this->cpu; \ - Cpu_set_end_time( cpu, end ); \ - if ( *Cpu_get_code( cpu, cpu->r.pc ) != halt_opcode ) \ - { - #include "nes_cpu_run.h" - } - return Cpu_time_past_end( cpu ) < 0; -} diff --git a/apps/codecs/libgme/nsf_emu.c b/apps/codecs/libgme/nsf_emu.c deleted file mode 100644 index d9fc4e031d..0000000000 --- a/apps/codecs/libgme/nsf_emu.c +++ /dev/null @@ -1,921 +0,0 @@ -// Game_Music_Emu 0.6-pre. http://www.slack.net/~ant/ - -#include "nsf_emu.h" -#include "multi_buffer.h" - -#include "blargg_endian.h" - -/* Copyright (C) 2003-2006 Shay Green. This module is free software; you -can redistribute it and/or modify it under the terms of the GNU Lesser -General Public License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. This -module is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more -details. You should have received a copy of the GNU Lesser General Public -License along with this module; if not, write to the Free Software Foundation, -Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ - -#include "blargg_source.h" - -const char gme_wrong_file_type [] = "Wrong file type for this emulator"; - -// number of frames until play interrupts init -int const initial_play_delay = 7; // KikiKaikai needed this to work -int const bank_size = 0x1000; -int const rom_addr = 0x8000; - -static void clear_track_vars( struct Nsf_Emu* this ) -{ - this->current_track = -1; - track_stop( &this->track_filter ); -} - -static int pcm_read( void* emu, int addr ) -{ - return *Cpu_get_code( &((struct Nsf_Emu*) emu)->cpu, addr ); -} - -void Nsf_init( struct Nsf_Emu* this ) -{ - this->sample_rate = 0; - this->mute_mask_ = 0; - this->tempo = (int)(FP_ONE_TEMPO); - this->gain = (int)(FP_ONE_GAIN); - - // defaults - this->tfilter = *track_get_setup( &this->track_filter ); - this->tfilter.max_initial = 2; - this->tfilter.lookahead = 6; - this->track_filter.silence_ignored_ = false; - - // Set sound gain - Sound_set_gain( this, (int)(FP_ONE_GAIN*1.2) ); - - // Init rom - Rom_init( &this->rom, bank_size ); - - // Init & clear nsfe info - Info_init( &this->info ); - Info_unload( &this->info ); // TODO: extremely hacky! - - Cpu_init( &this->cpu ); - Apu_init( &this->apu ); - Apu_dmc_reader( &this->apu, pcm_read, this ); - - // Unload - this->voice_count = 0; - memset( this->voice_types, 0, sizeof this->voice_types ); - clear_track_vars( this ); -} - -// Setup - -static void append_voices( struct Nsf_Emu* this, int const types [], int count ) -{ - assert( this->voice_count + count < max_voices ); - int i; - for ( i = 0; i < count; i++ ) { - this->voice_types [this->voice_count + i] = types [i]; - } - this->voice_count += count; -} - -static blargg_err_t init_sound( struct Nsf_Emu* this ) -{ -/* if ( header_.chip_flags & ~(fds_flag | namco_flag | vrc6_flag | fme7_flag) ) - warning( "Uses unsupported audio expansion hardware" ); **/ - - { - static int const types [apu_osc_count] = { - wave_type+1, wave_type+2, mixed_type+1, noise_type+0, mixed_type+1 - }; - append_voices( this, types, apu_osc_count ); - } - - int adjusted_gain = (this->gain * 4) / 3; - - #ifdef NSF_EMU_APU_ONLY - { - if ( this->header_.chip_flags ) - set_warning( "Uses unsupported audio expansion hardware" ); - } - #else - { - if ( vrc6_enabled( this ) ) - { - Vrc6_init( &this->vrc6 ); - adjusted_gain = (adjusted_gain*3) / 4; - - static int const types [vrc6_osc_count] = { - wave_type+3, wave_type+4, wave_type+5, - }; - append_voices( this, types, vrc6_osc_count ); - } - - if ( fme7_enabled( this ) ) - { - Fme7_init( &this->fme7 ); - adjusted_gain = (adjusted_gain*3) / 4; - - static int const types [fme7_osc_count] = { - wave_type+3, wave_type+4, wave_type+5, - }; - append_voices( this, types, fme7_osc_count ); - } - - if ( mmc5_enabled( this ) ) - { - Mmc5_init( &this->mmc5 ); - adjusted_gain = (adjusted_gain*3) / 4; - - - static int const types [mmc5_osc_count] = { - wave_type+3, wave_type+4, mixed_type+2 - }; - append_voices( this, types, mmc5_osc_count ); - } - - if ( fds_enabled( this ) ) - { - Fds_init( &this->fds ); - adjusted_gain = (adjusted_gain*3) / 4; - - static int const types [fds_osc_count] = { - wave_type+0 - }; - append_voices( this, types, fds_osc_count ); - } - - if ( namco_enabled( this ) ) - { - Namco_init( &this->namco ); - adjusted_gain = (adjusted_gain*3) / 4; - - static int const types [namco_osc_count] = { - wave_type+3, wave_type+4, wave_type+5, wave_type+ 6, - wave_type+7, wave_type+8, wave_type+9, wave_type+10, - }; - append_voices( this, types, namco_osc_count ); - } - - #ifndef NSF_EMU_NO_VRC7 - if ( vrc7_enabled( this ) ) - { - - Vrc7_init( &this->vrc7 ); - Vrc7_set_rate( &this->vrc7, this->sample_rate ); - - adjusted_gain = (adjusted_gain*3) / 4; - - static int const types [vrc7_osc_count] = { - wave_type+3, wave_type+4, wave_type+5, wave_type+6, - wave_type+7, wave_type+8 - }; - append_voices( this, types, vrc7_osc_count ); - } - - if ( vrc7_enabled( this ) ) Vrc7_volume( &this->vrc7, adjusted_gain ); - #endif - if ( namco_enabled( this ) ) Namco_volume( &this->namco, adjusted_gain ); - if ( vrc6_enabled( this ) ) Vrc6_volume( &this->vrc6, adjusted_gain ); - if ( fme7_enabled( this ) ) Fme7_volume( &this->fme7, adjusted_gain ); - if ( mmc5_enabled( this ) ) Apu_volume( &this->mmc5.apu, adjusted_gain ); - if ( fds_enabled( this ) ) Fds_volume( &this->fds, adjusted_gain ); - } - #endif - - if ( adjusted_gain > this->gain ) - adjusted_gain = this->gain; - - Apu_volume( &this->apu, adjusted_gain ); - - return 0; -} - -// Header stuff -static bool valid_tag( struct header_t* this ) -{ - return 0 == memcmp( this->tag, "NESM\x1A", 5 ); -} - -// True if file supports only PAL speed -static bool pal_only( struct header_t* this ) -{ - return (this->speed_flags & 3) == 1; -} - -static int clock_rate( struct header_t* this ) -{ - return pal_only( this ) ? (int)1662607.125 : (int)1789772.727272727; -} - -static int play_period( struct header_t* this ) -{ - // NTSC - int clocks = 29780; - int value = 0x411A; - byte const* rate_ptr = this->ntsc_speed; - - // PAL - if ( pal_only( this ) ) - { - clocks = 33247; - value = 0x4E20; - rate_ptr = this->pal_speed; - } - - // Default rate - int rate = get_le16( rate_ptr ); - if ( rate == 0 ) - rate = value; - - // Custom rate - if ( rate != value ) - clocks = (int) ((1LL * rate * clock_rate( this )) / 1000000); - - return clocks; -} - -// Gets address, given pointer to it in file header. If zero, returns rom_addr. -addr_t get_addr( byte const in [] ) -{ - addr_t addr = get_le16( in ); - if ( addr == 0 ) - addr = rom_addr; - return addr; -} - -static blargg_err_t check_nsf_header( struct header_t* h ) -{ - if ( !valid_tag( h ) ) - return gme_wrong_file_type; - return 0; -} - -blargg_err_t Nsf_load_mem( struct Nsf_Emu* this, void* data, long size ) -{ - // Unload - Info_unload( &this->info ); // TODO: extremely hacky! - this->m3u.size = 0; - - this->voice_count = 0; - clear_track_vars( this ); - - assert( offsetof (struct header_t,unused [4]) == header_size ); - - if ( !memcmp( data, "NESM\x1A", 5 ) ) { - Nsf_disable_playlist( this, true ); - - RETURN_ERR( Rom_load( &this->rom, data, size, header_size, &this->header, 0 ) ); - return Nsf_post_load( this ); - } - - blargg_err_t err = Info_load( &this->info, data, size, this ); - Nsf_disable_playlist( this, false ); - return err; -} - -blargg_err_t Nsf_post_load( struct Nsf_Emu* this ) -{ - RETURN_ERR( check_nsf_header( &this->header ) ); - - /* if ( header_.vers != 1 ) - warning( "Unknown file version" ); */ - - // set up data - addr_t load_addr = get_addr( this->header.load_addr ); - /* if ( load_addr < (fds_enabled() ? sram_addr : rom_addr) ) - warning( "Load address is too low" ); */ - - Rom_set_addr( &this->rom, load_addr % this->rom.bank_size ); - - /* if ( header_.vers != 1 ) - warning( "Unknown file version" ); */ - - set_play_period( this, play_period( &this->header ) ); - - // sound and memory - blargg_err_t err = init_sound( this ); - if ( err ) - return err; - - // Set track_count - this->track_count = this->header.track_count; - - // Change clock rate & setup buffer - this->clock_rate__ = clock_rate( &this->header ); - Buffer_clock_rate( &this->stereo_buf, this->clock_rate__ ); - RETURN_ERR( Buffer_set_channel_count( &this->stereo_buf, this->voice_count, this->voice_types ) ); - this->buf_changed_count = Buffer_channels_changed_count( &this->stereo_buf ); - - // Post load - Sound_set_tempo( this, this->tempo ); - Sound_mute_voices( this, this->mute_mask_ ); - return 0; -} - -void Nsf_disable_playlist( struct Nsf_Emu* this, bool b ) -{ - Info_disable_playlist( &this->info, b ); - this->track_count = this->info.track_count; -} - -void Nsf_clear_playlist( struct Nsf_Emu* this ) -{ - Nsf_disable_playlist( this, true ); -} - -void write_bank( struct Nsf_Emu* this, int bank, int data ) -{ - // Find bank in ROM - int offset = mask_addr( data * this->rom.bank_size, this->rom.mask ); - /* if ( offset >= rom.size() ) - warning( "invalid bank" ); */ - void const* rom_data = Rom_at_addr( &this->rom, offset ); - - #ifndef NSF_EMU_APU_ONLY - if ( bank < bank_count - fds_banks && fds_enabled( this ) ) - { - // TODO: FDS bank switching is kind of hacky, might need to - // treat ROM as RAM so changes won't get lost when switching. - byte* out = sram( this ); - if ( bank >= fds_banks ) - { - out = fdsram( this ); - bank -= fds_banks; - } - memcpy( &out [bank * this->rom.bank_size], rom_data, this->rom.bank_size ); - return; - } - #endif - - if ( bank >= fds_banks ) - Cpu_map_code( &this->cpu, (bank + 6) * this->rom.bank_size, this->rom.bank_size, rom_data, false ); -} - -static void map_memory( struct Nsf_Emu* this ) -{ - // Map standard things - Cpu_reset( &this->cpu, unmapped_code( this ) ); - Cpu_map_code( &this->cpu, 0, 0x2000, this->low_ram, low_ram_size ); // mirrored four times - Cpu_map_code( &this->cpu, sram_addr, sram_size, sram( this ), 0 ); - - // Determine initial banks - byte banks [bank_count]; - static byte const zero_banks [sizeof this->header.banks] = { 0 }; - if ( memcmp( this->header.banks, zero_banks, sizeof zero_banks ) ) - { - banks [0] = this->header.banks [6]; - banks [1] = this->header.banks [7]; - memcpy( banks + fds_banks, this->header.banks, sizeof this->header.banks ); - } - else - { - // No initial banks, so assign them based on load_addr - int i, first_bank = (get_addr( this->header.load_addr ) - sram_addr) / this->rom.bank_size; - unsigned total_banks = this->rom.size / this->rom.bank_size; - for ( i = bank_count; --i >= 0; ) - { - int bank = i - first_bank; - if ( (unsigned) bank >= total_banks ) - bank = 0; - banks [i] = bank; - } - } - - // Map banks - int i; - for ( i = (fds_enabled( this ) ? 0 : fds_banks); i < bank_count; ++i ) - write_bank( this, i, banks [i] ); - - // Map FDS RAM - if ( fds_enabled( this ) ) - Cpu_map_code( &this->cpu, rom_addr, fdsram_size, fdsram( this ), 0 ); -} - -static void set_voice( struct Nsf_Emu* this, int i, struct Blip_Buffer* buf, struct Blip_Buffer* left, struct Blip_Buffer* right) -{ -#if defined(ROCKBOX) - (void) left; - (void) right; -#endif - - if ( i < apu_osc_count ) - { - Apu_osc_output( &this->apu, i, buf ); - return; - } - i -= apu_osc_count; - - #ifndef NSF_EMU_APU_ONLY - { - if ( vrc6_enabled( this ) && (i -= vrc6_osc_count) < 0 ) - { - Vrc6_osc_output( &this->vrc6, i + vrc6_osc_count, buf ); - return; - } - - if ( fme7_enabled( this ) && (i -= fme7_osc_count) < 0 ) - { - Fme7_osc_output( &this->fme7, i + fme7_osc_count, buf ); - return; - } - - if ( mmc5_enabled( this ) && (i -= mmc5_osc_count) < 0 ) - { - Mmc5_set_output( &this->mmc5, i + mmc5_osc_count, buf ); - return; - } - - if ( fds_enabled( this ) && (i -= fds_osc_count) < 0 ) - { - Fds_set_output( &this->fds, i + fds_osc_count, buf ); - return; - } - - if ( namco_enabled( this ) && (i -= namco_osc_count) < 0 ) - { - Namco_osc_output( &this->namco, i + namco_osc_count, buf ); - return; - } - - #ifndef NSF_EMU_NO_VRC7 - if ( vrc7_enabled( this ) && (i -= vrc7_osc_count) < 0 ) - { - Vrc7_set_output( &this->vrc7, i + vrc7_osc_count, buf ); - return; - } - #endif - } - #endif -} - -// Emulation - -// Music Emu - -blargg_err_t Nsf_set_sample_rate( struct Nsf_Emu* this, int rate ) -{ - require( !this->sample_rate ); // sample rate can't be changed once set - Buffer_init( &this->stereo_buf ); - RETURN_ERR( Buffer_set_sample_rate( &this->stereo_buf, rate, 1000 / 20 ) ); - - // Set bass frequency - Buffer_bass_freq( &this->stereo_buf, 80 ); - - this->sample_rate = rate; - RETURN_ERR( track_init( &this->track_filter, this ) ); - this->tfilter.max_silence = 6 * stereo * this->sample_rate; - return 0; -} - -void Sound_mute_voice( struct Nsf_Emu* this, int index, bool mute ) -{ - require( (unsigned) index < (unsigned) this->voice_count ); - int bit = 1 << index; - int mask = this->mute_mask_ | bit; - if ( !mute ) - mask ^= bit; - Sound_mute_voices( this, mask ); -} - -void Sound_mute_voices( struct Nsf_Emu* this, int mask ) -{ - require( this->sample_rate ); // sample rate must be set first - this->mute_mask_ = mask; - - int i; - for ( i = this->voice_count; i--; ) - { - if ( mask & (1 << i) ) - { - set_voice( this, i, 0, 0, 0 ); - } - else - { - struct channel_t ch = Buffer_channel( &this->stereo_buf, i ); - assert( (ch.center && ch.left && ch.right) || - (!ch.center && !ch.left && !ch.right) ); // all or nothing - set_voice( this, i, ch.center, ch.left, ch.right ); - } - } -} - -void Sound_set_tempo( struct Nsf_Emu* this, int t ) -{ - require( this->sample_rate ); // sample rate must be set first - int const min = (int)(FP_ONE_TEMPO*0.02); - int const max = (int)(FP_ONE_TEMPO*4.00); - if ( t < min ) t = min; - if ( t > max ) t = max; - this->tempo = t; - - set_play_period( this, (int) ((play_period( &this->header ) * FP_ONE_TEMPO) / t) ); - - Apu_set_tempo( &this->apu, t ); - -#ifndef NSF_EMU_APU_ONLY - if ( fds_enabled( this ) ) - Fds_set_tempo( &this->fds, t ); -#endif -} - -static inline void push_byte( struct Nsf_Emu* this, int b ) -{ - this->low_ram [0x100 + this->cpu.r.sp--] = b; -} - -// Jumps to routine, given pointer to address in file header. Pushes idle_addr -// as return address, NOT old PC. -static void jsr_then_stop( struct Nsf_Emu* this, byte const addr [] ) -{ - this->cpu.r.pc = get_addr( addr ); - push_byte( this, (idle_addr - 1) >> 8 ); - push_byte( this, (idle_addr - 1) ); -} - -int cpu_read( struct Nsf_Emu* this, addr_t addr ) -{ - #ifndef NSF_EMU_APU_ONLY - { - if ( namco_enabled( this ) && addr == namco_data_reg_addr ) - return Namco_read_data( &this->namco ); - - if ( fds_enabled( this ) && (unsigned) (addr - fds_io_addr) < fds_io_size ) - return Fds_read( &this->fds, Cpu_time( &this->cpu ), addr ); - - if ( mmc5_enabled( this ) ) { - int i = addr - 0x5C00; - if ( (unsigned) i < mmc5_exram_size ) - return this->mmc5.exram [i]; - - int m = addr - 0x5205; - if ( (unsigned) m < 2 ) - return (this->mmc5_mul [0] * this->mmc5_mul [1]) >> (m * 8) & 0xFF; - } - } - #endif - - /* Unmapped read */ - return addr >> 8; -} - -void cpu_write( struct Nsf_Emu* this, addr_t addr, int data ) -{ - #ifndef NSF_EMU_APU_ONLY - { - if ( fds_enabled( this) && (unsigned) (addr - fds_io_addr) < fds_io_size ) - { - Fds_write( &this->fds, Cpu_time( &this->cpu ), addr, data ); - return; - } - - if ( namco_enabled( this) ) - { - if ( addr == namco_addr_reg_addr ) - { - Namco_write_addr( &this->namco, data ); - return; - } - - if ( addr == namco_data_reg_addr ) - { - Namco_write_data( &this->namco, Cpu_time( &this->cpu ), data ); - return; - } - } - - if ( vrc6_enabled( this) ) - { - int reg = addr & (vrc6_addr_step - 1); - int osc = (unsigned) (addr - vrc6_base_addr) / vrc6_addr_step; - if ( (unsigned) osc < vrc6_osc_count && (unsigned) reg < vrc6_reg_count ) - { - Vrc6_write_osc( &this->vrc6, Cpu_time( &this->cpu ), osc, reg, data ); - return; - } - } - - if ( fme7_enabled( this) && addr >= fme7_latch_addr ) - { - switch ( addr & fme7_addr_mask ) - { - case fme7_latch_addr: - Fme7_write_latch( &this->fme7, data ); - return; - - case fme7_data_addr: - Fme7_write_data( &this->fme7, Cpu_time( &this->cpu ), data ); - return; - } - } - - if ( mmc5_enabled( this) ) - { - if ( (unsigned) (addr - mmc5_regs_addr) < mmc5_regs_size ) - { - Mmc5_write_register( &this->mmc5, Cpu_time( &this->cpu ), addr, data ); - return; - } - - int m = addr - 0x5205; - if ( (unsigned) m < 2 ) - { - this->mmc5_mul [m] = data; - return; - } - - int i = addr - 0x5C00; - if ( (unsigned) i < mmc5_exram_size ) - { - this->mmc5.exram [i] = data; - return; - } - } - - #ifndef NSF_EMU_NO_VRC7 - if ( vrc7_enabled( this) ) - { - if ( addr == 0x9010 ) - { - Vrc7_write_reg( &this->vrc7, data ); - return; - } - - if ( (unsigned) (addr - 0x9028) <= 0x08 ) - { - Vrc7_write_data( &this->vrc7, Cpu_time( &this->cpu ), data ); - return; - } - } - #endif - } - #endif - - // Unmapped_write -} - -blargg_err_t Nsf_start_track( struct Nsf_Emu* this, int track ) -{ - clear_track_vars( this ); - - // Remap track if playlist available - if ( this->m3u.size > 0 ) { - struct entry_t* e = &this->m3u.entries[track]; - track = e->track; - } - else track = Info_remap_track( &this->info, track ); - - this->current_track = track; - Buffer_clear( &this->stereo_buf ); - - #ifndef NSF_EMU_APU_ONLY - if ( mmc5_enabled( this ) ) - { - this->mmc5_mul [0] = 0; - this->mmc5_mul [1] = 0; - memset( this->mmc5.exram, 0, mmc5_exram_size ); - } - - if ( fds_enabled( this ) ) Fds_reset( &this->fds ); - if ( namco_enabled( this ) ) Namco_reset( &this->namco ); - if ( vrc6_enabled( this ) ) Vrc6_reset( &this->vrc6 ); - if ( fme7_enabled( this ) ) Fme7_reset( &this->fme7 ); - if ( mmc5_enabled( this ) ) Apu_reset( &this->mmc5.apu, false, 0 ); - #ifndef NSF_EMU_NO_VRC7 - if ( vrc7_enabled( this ) ) Vrc7_reset( &this->vrc7 ); - #endif - #endif - - int speed_flags = 0; - #ifdef NSF_EMU_EXTRA_FLAGS - speed_flags = this->header.speed_flags; - #endif - - Apu_reset( &this->apu, pal_only( &this->header ), (speed_flags & 0x20) ? 0x3F : 0 ); - Apu_write_register( &this->apu, 0, 0x4015, 0x0F ); - Apu_write_register( &this->apu, 0, 0x4017, (speed_flags & 0x10) ? 0x80 : 0 ); - - memset( unmapped_code( this ), halt_opcode, unmapped_size ); - memset( this->low_ram, 0, low_ram_size ); - memset( sram( this ), 0, sram_size ); - - map_memory( this ); - - // Arrange time of first call to play routine - this->play_extra = 0; - this->next_play = this->play_period; - - this->play_delay = initial_play_delay; - this->saved_state.pc = idle_addr; - - // Setup for call to init routine - this->cpu.r.a = track; - this->cpu.r.x = pal_only( &this->header ); - this->cpu.r.sp = 0xFF; - jsr_then_stop( this, this->header.init_addr ); - /* if ( this->cpu.r.pc < get_addr( header.load_addr ) ) - warning( "Init address < load address" ); */ - - // convert filter times to samples - struct setup_t s = this->tfilter; - s.max_initial *= this->sample_rate * stereo; - #ifdef GME_DISABLE_SILENCE_LOOKAHEAD - s.lookahead = 1; - #endif - track_setup( &this->track_filter, &s ); - - return track_start( &this->track_filter ); -} - -void run_once( struct Nsf_Emu* this, nes_time_t end ) -{ - // Emulate until next play call if possible - if ( run_cpu_until( this, min( this->next_play, end ) ) ) - { - // Halt instruction encountered - - if ( this->cpu.r.pc != idle_addr ) - { - // special_event( "illegal instruction" ); - Cpu_set_time( &this->cpu, this->cpu.end_time ); - return; - } - - // Init/play routine returned - this->play_delay = 1; // play can now be called regularly - - if ( this->saved_state.pc == idle_addr ) - { - // nothing to run - nes_time_t t = this->cpu.end_time; - if ( Cpu_time( &this->cpu ) < t ) - Cpu_set_time( &this->cpu, t ); - } - else - { - // continue init routine that was interrupted by play routine - this->cpu.r = this->saved_state; - this->saved_state.pc = idle_addr; - } - } - - if ( Cpu_time( &this->cpu ) >= this->next_play ) - { - // Calculate time of next call to play routine - this->play_extra ^= 1; // extra clock every other call - this->next_play += this->play_period + this->play_extra; - - // Call routine if ready - if ( this->play_delay && !--this->play_delay ) - { - // Save state if init routine is still running - if ( this->cpu.r.pc != idle_addr ) - { - check( this->saved_state.pc == idle_addr ); - this->saved_state = this->cpu.r; - // special_event( "play called during init" ); - } - - jsr_then_stop( this, this->header.play_addr ); - } - } -} - -void run_until( struct Nsf_Emu* this, nes_time_t end ) -{ - while ( Cpu_time( &this->cpu ) < end ) - run_once( this, end ); -} - -static void end_frame( struct Nsf_Emu* this, nes_time_t end ) -{ - if ( Cpu_time( &this->cpu ) < end ) - run_until( this, end ); - Cpu_adjust_time( &this->cpu, -end ); - - // Localize to new time frame - this->next_play -= end; - check( this->next_play >= 0 ); - if ( this->next_play < 0 ) - this->next_play = 0; - - Apu_end_frame( &this->apu, end ); - - #ifndef NSF_EMU_APU_ONLY - if ( fds_enabled( this ) ) Fds_end_frame( &this->fds, end ); - if ( fme7_enabled( this ) ) Fme7_end_frame( &this->fme7, end ); - if ( mmc5_enabled( this ) ) Apu_end_frame( &this->mmc5.apu, end ); - if ( namco_enabled( this ) ) Namco_end_frame( &this->namco, end ); - if ( vrc6_enabled( this ) ) Vrc6_end_frame( &this->vrc6, end ); - #ifndef NSF_EMU_NO_VRC7 - if ( vrc7_enabled( this ) ) Vrc7_end_frame( &this->vrc7, end ); - #endif - #endif -} - -// Tell/Seek - -static int msec_to_samples( int msec, int sample_rate ) -{ - int sec = msec / 1000; - msec -= sec * 1000; - return (sec * sample_rate + msec * sample_rate / 1000) * stereo; -} - -int Track_tell( struct Nsf_Emu* this ) -{ - int rate = this->sample_rate * stereo; - int sec = track_sample_count( &this->track_filter ) / rate; - return sec * 1000 + (track_sample_count( &this->track_filter ) - sec * rate) * 1000 / rate; -} - -blargg_err_t Track_seek( struct Nsf_Emu* this, int msec ) -{ - int time = msec_to_samples( msec, this->sample_rate ); - if ( time < track_sample_count( &this->track_filter ) ) - RETURN_ERR( Nsf_start_track( this, this->current_track ) ); - return Track_skip( this, time - track_sample_count( &this->track_filter ) ); -} - -blargg_err_t Track_skip( struct Nsf_Emu* this, int count ) -{ - require( this->current_track >= 0 ); // start_track() must have been called already - return track_skip( &this->track_filter, count ); -} - -blargg_err_t skip_( void *emu, int count ) -{ - struct Nsf_Emu* this = (struct Nsf_Emu*) emu; - - // for long skip, mute sound - const int threshold = 32768; - if ( count > threshold ) - { - int saved_mute = this->mute_mask_; - Sound_mute_voices( this, ~0 ); - - int n = count - threshold/2; - n &= ~(2048-1); // round to multiple of 2048 - count -= n; - RETURN_ERR( skippy_( &this->track_filter, n ) ); - - Sound_mute_voices( this, saved_mute ); - } - - return skippy_( &this->track_filter, count ); -} - -// Fading - -void Track_set_fade( struct Nsf_Emu* this, int start_msec, int length_msec ) -{ - track_set_fade( &this->track_filter, msec_to_samples( start_msec, this->sample_rate ), - length_msec * this->sample_rate / (1000 / stereo) ); -} - -blargg_err_t Nsf_play( struct Nsf_Emu* this, int out_count, sample_t* out ) -{ - require( this->current_track >= 0 ); - require( out_count % stereo == 0 ); - return track_play( &this->track_filter, out_count, out ); -} - -blargg_err_t play_( void* emu, int count, sample_t* out ) -{ - struct Nsf_Emu* this = (struct Nsf_Emu*) emu; - - int remain = count; - while ( remain ) - { - Buffer_disable_immediate_removal( &this->stereo_buf ); - remain -= Buffer_read_samples( &this->stereo_buf, &out [count - remain], remain ); - if ( remain ) - { - if ( this->buf_changed_count != Buffer_channels_changed_count( &this->stereo_buf ) ) - { - this->buf_changed_count = Buffer_channels_changed_count( &this->stereo_buf ); - - // Remute voices - Sound_mute_voices( this, this->mute_mask_ ); - } - int msec = Buffer_length( &this->stereo_buf ); - blip_time_t clocks_emulated = msec * this->clock_rate__ / 1000 - 100; - RETURN_ERR( run_clocks( this, &clocks_emulated, msec ) ); - assert( clocks_emulated ); - Buffer_end_frame( &this->stereo_buf, clocks_emulated ); - } - } - return 0; -} - -blargg_err_t run_clocks( struct Nsf_Emu* this, blip_time_t* duration, int msec ) -{ -#if defined(ROCKBOX) - (void) msec; -#endif - - end_frame( this, *duration ); - return 0; -} diff --git a/apps/codecs/libgme/nsf_emu.h b/apps/codecs/libgme/nsf_emu.h deleted file mode 100644 index 00bdad4a4e..0000000000 --- a/apps/codecs/libgme/nsf_emu.h +++ /dev/null @@ -1,261 +0,0 @@ -// Nintendo NES/Famicom NSF music file emulator - -// Game_Music_Emu 0.5.5 -#ifndef NSF_EMU_H -#define NSF_EMU_H - -#include "rom_data.h" -#include "multi_buffer.h" -#include "nes_apu.h" -#include "nes_cpu.h" -#include "nsfe_info.h" -#include "m3u_playlist.h" -#include "track_filter.h" - -#ifndef NSF_EMU_APU_ONLY - #include "nes_namco_apu.h" - #include "nes_vrc6_apu.h" - #include "nes_fme7_apu.h" - #include "nes_fds_apu.h" - #include "nes_mmc5_apu.h" - #ifndef NSF_EMU_NO_VRC7 - #include "nes_vrc7_apu.h" - #endif -#endif - -// Sound chip flags -enum { - vrc6_flag = 1 << 0, - vrc7_flag = 1 << 1, - fds_flag = 1 << 2, - mmc5_flag = 1 << 3, - namco_flag = 1 << 4, - fme7_flag = 1 << 5 -}; - -enum { fds_banks = 2 }; -enum { bank_count = fds_banks + 8 }; - -enum { rom_begin = 0x8000 }; -enum { bank_select_addr = 0x5FF8 }; -enum { mem_size = 0x10000 }; - -// cpu sits here when waiting for next call to play routine -enum { idle_addr = 0x5FF6 }; -enum { banks_addr = idle_addr }; -enum { badop_addr = bank_select_addr }; - -enum { low_ram_size = 0x800 }; -enum { sram_size = 0x2000 }; -enum { fdsram_size = 0x6000 }; -enum { fdsram_offset = 0x2000 + page_size + 8 }; -enum { sram_addr = 0x6000 }; -enum { unmapped_size= page_size + 8 }; -enum { max_voices = 32 }; - -// NSF file header -enum { header_size = 0x80 }; -struct header_t -{ - char tag [5]; - byte vers; - byte track_count; - byte first_track; - byte load_addr [2]; - byte init_addr [2]; - byte play_addr [2]; - char game [32]; - char author [32]; - char copyright [32]; - byte ntsc_speed [2]; - byte banks [8]; - byte pal_speed [2]; - byte speed_flags; - byte chip_flags; - byte unused [4]; -}; - -struct Nsf_Emu { - // Play routine timing - nes_time_t next_play; - nes_time_t play_period; - int play_extra; - int play_delay; - struct registers_t saved_state; // of interrupted init routine - - // general - int voice_count; - int voice_types [32]; - int mute_mask_; - int tempo; - int gain; - - int sample_rate; - - // track-specific - int track_count; - int current_track; - - int clock_rate__; - unsigned buf_changed_count; - - // M3u Playlist - struct M3u_Playlist m3u; - - // Larger items at the end - #ifndef NSF_EMU_APU_ONLY - byte mmc5_mul [2]; - - struct Nes_Fds_Apu fds; - struct Nes_Mmc5_Apu mmc5; - struct Nes_Namco_Apu namco; - struct Nes_Vrc6_Apu vrc6; - struct Nes_Fme7_Apu fme7; - #ifndef NSF_EMU_NO_VRC7 - struct Nes_Vrc7_Apu vrc7; - #endif - #endif - - struct Nes_Cpu cpu; - struct Nes_Apu apu; - - // Header for currently loaded file - struct header_t header; - - struct setup_t tfilter; - struct Track_Filter track_filter; - - struct Multi_Buffer stereo_buf; - struct Rom_Data rom; - - // Extended nsf info - struct Nsfe_Info info; - - byte high_ram[fdsram_size + fdsram_offset]; - byte low_ram [low_ram_size]; -}; - -// Basic functionality (see Gme_File.h for file loading/track info functions) - -void Nsf_init( struct Nsf_Emu* this ); -blargg_err_t Nsf_load_mem( struct Nsf_Emu* this, void* data, long size ); -blargg_err_t Nsf_post_load( struct Nsf_Emu* this ); - -// Set output sample rate. Must be called only once before loading file. -blargg_err_t Nsf_set_sample_rate( struct Nsf_Emu* this, int sample_rate ); - -// Start a track, where 0 is the first track. Also clears warning string. -blargg_err_t Nsf_start_track( struct Nsf_Emu* this , int ); - -// Generate 'count' samples info 'buf'. Output is in stereo. Any emulation -// errors set warning string, and major errors also end track. -blargg_err_t Nsf_play( struct Nsf_Emu* this, int count, sample_t* buf ); - -void Nsf_clear_playlist( struct Nsf_Emu* this ); -void Nsf_disable_playlist( struct Nsf_Emu* this, bool b ); // use clear_playlist() - -// Track status/control - -// Number of milliseconds (1000 msec = 1 second) played since beginning of track -int Track_tell( struct Nsf_Emu* this ); - -// Seek to new time in track. Seeking backwards or far forward can take a while. -blargg_err_t Track_seek( struct Nsf_Emu* this, int msec ); - -// Skip n samples -blargg_err_t Track_skip( struct Nsf_Emu* this, int n ); - -// Set start time and length of track fade out. Once fade ends track_ended() returns -// true. Fade time can be changed while track is playing. -void Track_set_fade( struct Nsf_Emu* this, int start_msec, int length_msec ); - -// True if a track has reached its end -static inline bool Track_ended( struct Nsf_Emu* this ) -{ - return track_ended( &this->track_filter ); -} - -// Disables automatic end-of-track detection and skipping of silence at beginning -static inline void Track_ignore_silence( struct Nsf_Emu* this, bool disable ) -{ - this->track_filter.silence_ignored_ = disable; -} - -// Get track length in milliseconds -int Track_length( struct Nsf_Emu* this, int n ); - -// Sound customization - -// Adjust song tempo, where 1.0 = normal, 0.5 = half speed, 2.0 = double speed. -// Track length as returned by track_info() assumes a tempo of 1.0. -void Sound_set_tempo( struct Nsf_Emu* this, int t ); - -// Mute/unmute voice i, where voice 0 is first voice -void Sound_mute_voice( struct Nsf_Emu* this, int index, bool mute ); - -// Set muting state of all voices at once using a bit mask, where -1 mutes them all, -// 0 unmutes them all, 0x01 mutes just the first voice, etc. -void Sound_mute_voices( struct Nsf_Emu* this, int mask ); - -// Change overall output amplitude, where 1.0 results in minimal clamping. -// Must be called before set_sample_rate(). -static inline void Sound_set_gain( struct Nsf_Emu* this, int g ) -{ - assert( !this->sample_rate ); // you must set gain before setting sample rate - this->gain = g; -} - -// Emulation (You shouldn't touch these) - -blargg_err_t run_clocks( struct Nsf_Emu* this, blip_time_t* duration, int ); - -void write_bank( struct Nsf_Emu* this, int index, int data ); -int cpu_read( struct Nsf_Emu* this, addr_t ); -void cpu_write( struct Nsf_Emu* this, addr_t, int ); -addr_t get_addr( byte const [] ); -bool run_cpu_until( struct Nsf_Emu* this, nes_time_t end ); - -// Sets clocks between calls to play routine to p + 1/2 clock -static inline void set_play_period( struct Nsf_Emu* this, int p ) { this->play_period = p; } - -// Time play routine will next be called -static inline nes_time_t play_time( struct Nsf_Emu* this ) { return this->next_play; } - -// Emulates to at least time t. Might emulate a few clocks extra. -void run_until( struct Nsf_Emu* this, nes_time_t t ); - -// Runs cpu to at least time t and returns false, or returns true -// if it encounters illegal instruction (halt). -bool run_cpu_until( struct Nsf_Emu* this, nes_time_t t ); - -// cpu calls through to these to access memory (except instructions) -int read_mem( struct Nsf_Emu* this, addr_t ); -void write_mem( struct Nsf_Emu* this, addr_t, int ); - -// Address of play routine -static inline addr_t play_addr( struct Nsf_Emu* this ) { return get_addr( this->header.play_addr ); } - -// Same as run_until, except emulation stops for any event (routine returned, -// play routine called, illegal instruction). -void run_once( struct Nsf_Emu* this, nes_time_t ); - -// Reads byte as cpu would when executing code. Only works for RAM/ROM, -// NOT I/O like sound chips. -int read_code( struct Nsf_Emu* this, addr_t addr ); - -static inline byte* fdsram( struct Nsf_Emu* this ) { return &this->high_ram [fdsram_offset]; } -static inline byte* sram( struct Nsf_Emu* this ) { return this->high_ram; } -static inline byte* unmapped_code( struct Nsf_Emu* this ) { return &this->high_ram [sram_size]; } - -#ifndef NSF_EMU_APU_ONLY - static inline int fds_enabled( struct Nsf_Emu* this ) { return this->header.chip_flags & fds_flag; } - static inline int vrc6_enabled( struct Nsf_Emu* this ) { return this->header.chip_flags & vrc6_flag; } - #ifndef NSF_EMU_NO_VRC7 - static inline int vrc7_enabled( struct Nsf_Emu* this ) { return this->header.chip_flags & vrc7_flag; } - #endif - static inline int mmc5_enabled( struct Nsf_Emu* this ) { return this->header.chip_flags & mmc5_flag; } - static inline int namco_enabled( struct Nsf_Emu* this ) { return this->header.chip_flags & namco_flag; } - static inline int fme7_enabled( struct Nsf_Emu* this ) { return this->header.chip_flags & fme7_flag; } -#endif - -#endif diff --git a/apps/codecs/libgme/nsfe_info.c b/apps/codecs/libgme/nsfe_info.c deleted file mode 100644 index 337b1e580a..0000000000 --- a/apps/codecs/libgme/nsfe_info.c +++ /dev/null @@ -1,272 +0,0 @@ -// Game_Music_Emu 0.5.5. http://www.slack.net/~ant/ - -#include "nsf_emu.h" - -#include "blargg_endian.h" -#include - -/* Copyright (C) 2005-2006 Shay Green. This module is free software; you -can redistribute it and/or modify it under the terms of the GNU Lesser -General Public License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. This -module is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more -details. You should have received a copy of the GNU Lesser General Public -License along with this module; if not, write to the Free Software Foundation, -Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ - -#include "blargg_source.h" - -void Info_init( struct Nsfe_Info* this ) -{ - this->playlist_disabled = false; -} - -void Info_unload( struct Nsfe_Info* this ) -{ - memset(this->playlist, 0, 256); - memset(this->track_times, 0, 256 * sizeof(int32_t)); - - this->playlist_size = 0; - this->track_times_size = 0; -} - -// TODO: if no playlist, treat as if there is a playlist that is just 1,2,3,4,5... ? -void Info_disable_playlist( struct Nsfe_Info* this, bool b ) -{ - this->playlist_disabled = b; - this->track_count = this->playlist_size; - if ( !this->track_count || this->playlist_disabled ) - this->track_count = this->actual_track_count_; -} - -int Info_remap_track( struct Nsfe_Info* this, int track ) -{ - if ( !this->playlist_disabled && (unsigned) track < (unsigned) this->playlist_size ) - track = this->playlist [track]; - return track; -} - -const char eof_error [] = "Unexpected end of file"; - -// Read n bytes from memory buffer -static blargg_err_t in_read( void* dst, long bytes, void* data, long* offset, long size ) -{ - if ((*offset + bytes) > size) return eof_error; - - memcpy(dst, (char*) data + *offset, bytes); - *offset += bytes; - return 0; -} - -static blargg_err_t in_skip( long bytes, long *offset, long size ) -{ - if ((*offset + bytes) > size) return eof_error; - - *offset += bytes; - return 0; -} - -// Skip n bytes from memory buffer - -// Read multiple strings and separate into individual strings -static int read_strs( void* data, long bytes, long* offset, long size, - const char* strs [4] ) -{ - char* chars = (char*) data + *offset; - chars [bytes - 1] = 0; // in case last string doesn't have terminator - - if ( in_skip( bytes, offset, size) ) - return -1; - - int count = 0, i; - for ( i = 0; i < bytes; i++ ) - { - strs [count] = &chars [i]; - while ( i < bytes && chars [i] ) - i++; - - count++; - if (count >= 4) - break; - } - - return count; -} - -struct nsfe_info_t -{ - byte load_addr [2]; - byte init_addr [2]; - byte play_addr [2]; - byte speed_flags; - byte chip_flags; - byte track_count; - byte first_track; - byte unused [6]; -}; - -blargg_err_t Info_load( struct Nsfe_Info* this, void* data, long size, struct Nsf_Emu* nsf_emu ) -{ - long offset = 0; - int const nsfe_info_size = 16; - assert( offsetof (struct nsfe_info_t,unused [6]) == nsfe_info_size ); - - // check header - byte signature [4]; - blargg_err_t err = in_read( signature, sizeof signature, data, &offset, size ); - if ( err ) - return (err == eof_error ? gme_wrong_file_type : err); - if ( memcmp( signature, "NSFE", 4 ) ) { - } - - // free previous info - /* TODO: clear track_names */ - memset(this->playlist, 0, 256); - memset(this->track_times, 0, 256 * sizeof(int32_t)); - - this->playlist_size = 0; - this->track_times_size = 0; - - // default nsf header - static const struct header_t base_header = - { - {'N','E','S','M','\x1A'},// tag - 1, // version - 1, 1, // track count, first track - {0,0},{0,0},{0,0}, // addresses - "","","", // strings - {0x1A, 0x41}, // NTSC rate - {0,0,0,0,0,0,0,0}, // banks - {0x20, 0x4E}, // PAL rate - 0, 0, // flags - {0,0,0,0} // unused - }; - - memcpy( &nsf_emu->header, &base_header, sizeof base_header ); - - // parse tags - int phase = 0; - while ( phase != 3 ) - { - // read size and tag - byte block_header [2] [4]; - RETURN_ERR( in_read( block_header, sizeof block_header, data, &offset, size ) ); - - int chunk_size = get_le32( block_header [0] ); - int tag = get_le32( block_header [1] ); - - switch ( tag ) - { - case BLARGG_4CHAR('O','F','N','I'): { - check( phase == 0 ); - if ( chunk_size < 8 ) - return "Corrupt file"; - - struct nsfe_info_t finfo; - finfo.track_count = 1; - finfo.first_track = 0; - - RETURN_ERR( in_read( &finfo, min( chunk_size, nsfe_info_size ), - (char*) data, &offset, size ) ); - - if ( chunk_size > nsfe_info_size ) - RETURN_ERR( in_skip( chunk_size - nsfe_info_size, &offset, size ) ); - - phase = 1; - nsf_emu->header.speed_flags = finfo.speed_flags; - nsf_emu->header.chip_flags = finfo.chip_flags; - nsf_emu->header.track_count = finfo.track_count; - this->actual_track_count_ = finfo.track_count; - nsf_emu->header.first_track = finfo.first_track; - memcpy( nsf_emu->header.load_addr, finfo.load_addr, 2 * 3 ); - break; - } - - case BLARGG_4CHAR('K','N','A','B'): - if ( chunk_size > (int) sizeof nsf_emu->header.banks ) - return "Corrupt file"; - RETURN_ERR( in_read( nsf_emu->header.banks, chunk_size, data, &offset, size ) ); - break; - - case BLARGG_4CHAR('h','t','u','a'): { - const char* strs [4]; - int n = read_strs( data, chunk_size, &offset, size, strs ); - if ( n < 0 ) - return eof_error; - break; - } - - case BLARGG_4CHAR('e','m','i','t'): - this->track_times_size = chunk_size / 4; - RETURN_ERR( in_read( this->track_times, this->track_times_size * 4, data, &offset, size ) ); - break; - - case BLARGG_4CHAR('l','b','l','t'): - RETURN_ERR( in_skip( chunk_size, &offset, size ) ); - break; - - case BLARGG_4CHAR('t','s','l','p'): - this->playlist_size = chunk_size; - RETURN_ERR( in_read( &this->playlist [0], chunk_size, data, &offset, size ) ); - break; - - case BLARGG_4CHAR('A','T','A','D'): { - check( phase == 1 ); - phase = 2; - if ( !nsf_emu ) - { - RETURN_ERR( in_skip( chunk_size, &offset, size ) ); - } - else - { - // Avoid unexpected end of file - if ( (offset + chunk_size) > size ) - return eof_error; - - RETURN_ERR( Rom_load( &nsf_emu->rom, (char*) data + offset, chunk_size, 0, 0, 0 ) ); - RETURN_ERR( Nsf_post_load( nsf_emu ) ); - offset += chunk_size; - } - break; - } - - case BLARGG_4CHAR('D','N','E','N'): - check( phase == 2 ); - phase = 3; - break; - - default: - // tags that can be skipped start with a lowercase character - check( islower( (tag >> 24) & 0xFF ) ); - RETURN_ERR( in_skip( chunk_size, &offset, size ) ); - break; - } - } - - return 0; -} - -int Track_length( struct Nsf_Emu* this, int n ) -{ - int length = 0; - if ( (this->m3u.size > 0) && (n < this->m3u.size) ) { - struct entry_t* entry = &this->m3u.entries [n]; - length = entry->length; - } - else if ( (this->info.playlist_size > 0) && (n < this->info.playlist_size) ) { - int remapped = Info_remap_track( &this->info, n ); - if ( (unsigned) remapped < (unsigned) this->info.track_times_size ) - length = (int32_t) get_le32( &this->info.track_times [remapped] ); - } - else if( (unsigned) n < (unsigned) this->info.track_times_size ) - length = (int32_t) get_le32( &this->info.track_times [n] ); - - /* Length will be 2,30 minutes for one track songs, - and 1,45 minutes for multitrack songs */ - if ( length <= 0 ) - length = (this->track_count > 1 ? 105 : 150) * 1000; - - return length; -} diff --git a/apps/codecs/libgme/nsfe_info.h b/apps/codecs/libgme/nsfe_info.h deleted file mode 100644 index 9dcde7b68a..0000000000 --- a/apps/codecs/libgme/nsfe_info.h +++ /dev/null @@ -1,30 +0,0 @@ -// Nintendo NES/Famicom NSFE file info parser - -// Game_Music_Emu 0.5.5 -#ifndef NSFE_INFO_H -#define NSFE_INFO_H - -#include "blargg_common.h" - -struct Nsf_Emu; - -// Allows reading info from NSFE file without creating emulator -struct Nsfe_Info { - int playlist_size; - int track_times_size; - int track_count; - int actual_track_count_; - bool playlist_disabled; - - unsigned char playlist [256]; - int32_t track_times [256]; -}; - -void Info_init( struct Nsfe_Info* this ); -blargg_err_t Info_load( struct Nsfe_Info* this, void *data, long size, struct Nsf_Emu* ); -void Info_disable_playlist( struct Nsfe_Info* this, bool b ); -int Info_remap_track( struct Nsfe_Info* this, int i ); -void Info_unload( struct Nsfe_Info* this ); - - -#endif diff --git a/apps/codecs/libgme/opl_apu.c b/apps/codecs/libgme/opl_apu.c deleted file mode 100644 index b573baef11..0000000000 --- a/apps/codecs/libgme/opl_apu.c +++ /dev/null @@ -1,198 +0,0 @@ -#include "opl_apu.h" - -#include "blargg_source.h" - -/* NOTE: Removed unused chips ~ gama */ - -blargg_err_t Opl_init( struct Opl_Apu* this, long clock, long rate, blip_time_t period, enum opl_type_t type ) -{ - Synth_init( &this->synth ); - - this->type_ = type; - this->clock_ = clock; - this->rate_ = rate; - this->period_ = period; - Opl_set_output( this, 0 ); - Opl_volume( this, (int)FP_ONE_VOLUME ); - - switch (type) - { - case type_opll: - case type_msxmusic: - case type_smsfmunit: - OPLL_new ( &this->opll, clock, rate ); - OPLL_reset_patch( &this->opll, OPLL_2413_TONE ); - break; - case type_vrc7: - OPLL_new ( &this->opll, clock, rate ); - OPLL_reset_patch( &this->opll, OPLL_VRC7_TONE ); - break; - case type_msxaudio: - OPL_init( &this->opl, this->opl_memory, sizeof this->opl_memory ); - OPL_setSampleRate( &this->opl, rate, clock ); - OPL_setInternalVolume(&this->opl, 1 << 13); - break; - } - - Opl_reset( this ); - return 0; -} - -void Opl_shutdown( struct Opl_Apu* this ) -{ - switch (this->type_) - { - case type_opll: - case type_msxmusic: - case type_smsfmunit: - case type_vrc7: - OPLL_delete( &this->opll ); - break; - case type_msxaudio: break; - } -} - -void Opl_reset( struct Opl_Apu* this ) -{ - this->addr = 0; - this->next_time = 0; - this->last_amp = 0; - - switch (this->type_) - { - case type_opll: - case type_msxmusic: - case type_smsfmunit: - case type_vrc7: - OPLL_reset( &this->opll ); - OPLL_setMask( &this->opll, 0 ); - break; - case type_msxaudio: - OPL_reset( &this->opl ); - break; - } -} - -static void run_until( struct Opl_Apu* this, blip_time_t end_time ); -void Opl_write_data( struct Opl_Apu* this, blip_time_t time, int data ) -{ - run_until( this, time ); - switch (this->type_) - { - case type_opll: - case type_msxmusic: - case type_smsfmunit: - case type_vrc7: - OPLL_writeIO( &this->opll, 0, this->addr ); - OPLL_writeIO( &this->opll, 1, data ); - break; - case type_msxaudio: - OPL_writeReg( &this->opl, this->addr, data ); - break; - } -} - -int Opl_read( struct Opl_Apu* this, blip_time_t time, int port ) -{ - run_until( this, time ); - switch (this->type_) - { - case type_opll: - case type_msxmusic: - case type_smsfmunit: - case type_vrc7: - return OPLL_read( &this->opll, port ); - case type_msxaudio: - return OPL_readStatus( &this->opl ); - } - - return 0; -} - -void Opl_end_frame( struct Opl_Apu* this, blip_time_t time ) -{ - run_until( this, time ); - this->next_time -= time; - - if ( this->output_ ) - Blip_set_modified( this->output_ ); -} - -static void run_until( struct Opl_Apu* this, blip_time_t end_time ) -{ - if ( end_time > this->next_time ) - { - blip_time_t time_delta = end_time - this->next_time; - blip_time_t time = this->next_time; - unsigned count = time_delta / this->period_ + 1; - switch (this->type_) - { - case type_opll: - case type_msxmusic: - case type_smsfmunit: - case type_vrc7: - { - OPLL* opll = &this->opll; // cache - struct Blip_Buffer* const output = this->output_; - while ( count > 0 ) - { - unsigned todo = count; - if ( todo > 1024 ) todo = 1024; - short *buffer = OPLL_update_buffer(opll, todo); - - if ( output && buffer ) - { - int last_amp = this->last_amp; - unsigned i; - for ( i = 0; i < todo; i++ ) - { - int amp = buffer [i]; - int delta = amp - last_amp; - if ( delta ) - { - last_amp = amp; - Synth_offset_inline( &this->synth, time, delta, output ); - } - time += this->period_; - } - this->last_amp = last_amp; - } - count -= todo; - } - } - break; - case type_msxaudio: - { - struct Y8950* opl = &this->opl; - struct Blip_Buffer* const output = this->output_; - while ( count > 0 ) - { - unsigned todo = count; - if ( todo > 1024 ) todo = 1024; - int *buffer = OPL_updateBuffer(opl, todo); - - if ( output && buffer ) - { - int last_amp = this->last_amp; - unsigned i; - for ( i = 0; i < todo; i++ ) - { - int amp = buffer [i]; - int delta = amp - last_amp; - if ( delta ) - { - last_amp = amp; - Synth_offset_inline( &this->synth, time, delta, output ); - } - time += this->period_; - } - this->last_amp = last_amp; - } - count -= todo; - } - } - break; - } - this->next_time = time; - } -} diff --git a/apps/codecs/libgme/opl_apu.h b/apps/codecs/libgme/opl_apu.h deleted file mode 100644 index 76fa766492..0000000000 --- a/apps/codecs/libgme/opl_apu.h +++ /dev/null @@ -1,63 +0,0 @@ -#ifndef OPL_APU_H -#define OPL_APU_H - -#include "blargg_common.h" -#include "blargg_source.h" -#include "blip_buffer.h" - -#include "emu8950.h" -#include "emu2413.h" - -enum opl_type_t { type_opll = 0x10, type_msxmusic = 0x11, type_smsfmunit = 0x12, - type_vrc7 = 0x13, type_msxaudio = 0x21 }; - -enum { opl_osc_count = 1 }; - -struct Opl_Apu { - struct Blip_Buffer* output_; - enum opl_type_t type_; - - blip_time_t next_time; - int last_amp; - int addr; - - long clock_; - long rate_; - blip_time_t period_; - - struct Blip_Synth synth; - - // OPL chips - struct Y8950 opl; - OPLL opll; - - unsigned char regs[ 0x100 ]; - unsigned char opl_memory[ 32768 ]; -}; - -blargg_err_t Opl_init( struct Opl_Apu* this, long clock, long rate, blip_time_t period, enum opl_type_t type ); -void Opl_shutdown( struct Opl_Apu* this ); - -void Opl_reset( struct Opl_Apu* this ); -static inline void Opl_volume( struct Opl_Apu* this, int v ) { Synth_volume( &this->synth, v / (4096 * 6) ); } - -static inline void Opl_osc_output( struct Opl_Apu* this, int i, struct Blip_Buffer* buf ) -{ -#if defined(ROCKBOX) - (void) i; -#endif - assert( (unsigned) i < opl_osc_count ); - this->output_ = buf; -} - -static inline void Opl_set_output( struct Opl_Apu* this, struct Blip_Buffer* buf ) { Opl_osc_output( this, 0, buf ); } -void Opl_end_frame( struct Opl_Apu* this, blip_time_t ); - -static inline void Opl_write_addr( struct Opl_Apu* this, int data ) { this->addr = data; } -void Opl_write_data( struct Opl_Apu* this, blip_time_t, int data ); - -int Opl_read( struct Opl_Apu* this, blip_time_t, int port ); - -static inline bool Opl_supported( void ) { return true; } - -#endif diff --git a/apps/codecs/libgme/opltables.h b/apps/codecs/libgme/opltables.h deleted file mode 100644 index 50fc0a86c6..0000000000 --- a/apps/codecs/libgme/opltables.h +++ /dev/null @@ -1,242 +0,0 @@ -#ifndef _OPLTABLES_H_ -#define _OPLTABLES_H_ - -/* Precalculated emu8950 tables for use in Rockbox, - Calculated for 44Khz sampling rate */ - -static const short ar_adjust_coeff[] = { - 255, 227, 210, 198, 189, 181, 175, 170, 165, 161, 157, - 153, 150, 147, 144, 141, 139, 136, 134, 132, 130, 128, - 126, 125, 123, 121, 120, 118, 117, 115, 114, 113, 112, - 110, 109, 108, 107, 106, 105, 104, 103, 102, 101, 100, - 99, 98, 97, 96, 95, 94, 94, 93, 92, 91, 91, - 90, 89, 88, 88, 87, 86, 86, 85, 84, 84, 83, - 82, 82, 81, 81, 80, 79, 79, 78, 78, 77, 77, - 76, 76, 75, 75, 74, 74, 73, 73, 72, 72, 71, - 71, 70, 70, 69, 69, 69, 68, 68, 67, 67, 66, - 66, 66, 65, 65, 64, 64, 64, 63, 63, 62, 62, - 62, 61, 61, 61, 60, 60, 60, 59, 59, 59, 58, - 58, 58, 57, 57, 57, 56, 56, 56, 55, 55, 55, - 54, 54, 54, 53, 53, 53, 53, 52, 52, 52, 51, - 51, 51, 50, 50, 50, 50, 49, 49, 49, 49, 48, - 48, 48, 48, 47, 47, 47, 46, 46, 46, 46, 45, - 45, 45, 45, 44, 44, 44, 44, 44, 43, 43, 43, - 43, 42, 42, 42, 42, 41, 41, 41, 41, 41, 40, - 40, 40, 40, 39, 39, 39, 39, 39, 38, 38, 38, - 38, 38, 37, 37, 37, 37, 37, 36, 36, 36, 36, - 36, 35, 35, 35, 35, 35, 34, 34, 34, 34, 34, - 33, 33, 33, 33, 33, 33, 32, 32, 32, 32, 32, - 31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, - 30, 29, 29, 29, 29, 29, 29, 28, 28, 28, 28, - 28, 28, 27, 27, 27, 27, 27, 27, 26, 26, 26, - 26, 26, 26, 26, 25, 25, 25, 25, 25, 25, 25, - 24, 24, 24, 24, 24, 24, 23, 23, 23, 23, 23, - 23, 23, 22, 22, 22, 22, 22, 22, 22, 21, 21, - 21, 21, 21, 21, 21, 21, 20, 20, 20, 20, 20, - 20, 20, 19, 19, 19, 19, 19, 19, 19, 19, 18, - 18, 18, 18, 18, 18, 18, 18, 17, 17, 17, 17, - 17, 17, 17, 17, 16, 16, 16, 16, 16, 16, 16, - 16, 15, 15, 15, 15, 15, 15, 15, 15, 14, 14, - 14, 14, 14, 14, 14, 14, 14, 13, 13, 13, 13, - 13, 13, 13, 13, 13, 12, 12, 12, 12, 12, 12, - 12, 12, 12, 11, 11, 11, 11, 11, 11, 11, 11, - 11, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0 -}; - -static const short db2lin_coeff[] = { - 2047, 2003, 1960, 1918, 1877, 1837, 1798, 1759, 1722, 1685, 1649, - 1614, 1579, 1546, 1513, 1480, 1449, 1418, 1387, 1358, 1329, 1300, - 1273, 1245, 1219, 1193, 1167, 1142, 1118, 1094, 1071, 1048, 1025, - 1004, 982, 961, 941, 920, 901, 882, 863, 844, 826, 809, - 791, 774, 758, 742, 726, 710, 695, 680, 666, 651, 638, - 624, 611, 598, 585, 572, 560, 548, 536, 525, 514, 503, - 492, 481, 471, 461, 451, 442, 432, 423, 414, 405, 396, - 388, 380, 371, 364, 356, 348, 341, 333, 326, 319, 312, - 306, 299, 293, 287, 280, 274, 269, 263, 257, 252, 246, - 241, 236, 231, 226, 221, 216, 212, 207, 203, 198, 194, - 190, 186, 182, 178, 174, 170, 167, 163, 160, 156, 153, - 150, 147, 143, 140, 137, 134, 131, 129, 126, 123, 121, - 118, 115, 113, 111, 108, 106, 104, 101, 99, 97, 95, - 93, 91, 89, 87, 85, 83, 82, 80, 78, 76, 75, - 73, 72, 70, 69, 67, 66, 64, 63, 61, 60, 59, - 58, 56, 55, 54, 53, 52, 51, 49, 48, 47, 46, - 45, 44, 43, 42, 42, 41, 40, 39, 38, 37, 36, - 36, 35, 34, 33, 33, 32, 31, 31, 30, 29, 29, - 28, 27, 27, 26, 26, 25, 25, 24, 23, 23, 22, - 22, 21, 21, 21, 20, 20, 19, 19, 18, 18, 18, - 17, 17, 16, 16, 16, 15, 15, 15, 14, 14, 14, - 13, 13, 13, 13, 12, 12, 12, 12, 11, 11, 11, - 11, 10, 10, 10, 10, 9, 9, 9, 9, 9, 8, - 8, 8, 8, 8, 7, 7, 7, 7, 7, 7, 7, - 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, - 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0 -}; - -static const short sin_coeff[] = { - 511, 235, 203, 185, 171, 161, 152, 145, 139, 134, 129, - 124, 120, 117, 113, 110, 107, 104, 102, 99, 97, 95, - 92, 90, 88, 87, 85, 83, 81, 80, 78, 77, 75, - 74, 72, 71, 70, 69, 67, 66, 65, 64, 63, 62, - 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 52, - 51, 50, 49, 48, 48, 47, 46, 45, 45, 44, 43, - 43, 42, 41, 41, 40, 39, 39, 38, 38, 37, 37, - 36, 35, 35, 34, 34, 33, 33, 32, 32, 31, 31, - 30, 30, 29, 29, 28, 28, 28, 27, 27, 26, 26, - 25, 25, 25, 24, 24, 23, 23, 23, 22, 22, 22, - 21, 21, 21, 20, 20, 20, 19, 19, 19, 18, 18, - 18, 17, 17, 17, 16, 16, 16, 16, 15, 15, 15, - 14, 14, 14, 14, 13, 13, 13, 13, 12, 12, 12, - 12, 11, 11, 11, 11, 11, 10, 10, 10, 10, 9, - 9, 9, 9, 9, 8, 8, 8, 8, 8, 7, 7, - 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 5, - 5, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, - 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, -}; - -static const short pm0_coeff[] = { - 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, - 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, - 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, - 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, - 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, - 256, 256, 257, 257, 257, 257, 257, 257, 257, 257, 257, - 257, 257, 257, 257, 257, 257, 256, 256, 256, 256, 256, - 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, - 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, - 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, - 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, - 256, 256, 256, 256, 256, 256, 256, 256, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 254, - 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, - 254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, -}; - -static const short pm1_coeff[] = { - 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, - 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 257, - 257, 257, 257, 257, 257, 257, 257, 257, 257, 257, 257, - 257, 257, 257, 257, 257, 257, 257, 257, 257, 257, 257, - 257, 257, 257, 257, 257, 257, 257, 257, 257, 257, 257, - 257, 258, 258, 258, 258, 258, 258, 258, 258, 258, 258, - 258, 258, 258, 258, 258, 258, 258, 257, 257, 257, 257, - 257, 257, 257, 257, 257, 257, 257, 257, 257, 257, 257, - 257, 257, 257, 257, 257, 257, 257, 257, 257, 257, 257, - 257, 257, 257, 257, 257, 257, 257, 257, 257, 256, 256, - 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, - 256, 256, 256, 256, 256, 256, 256, 256, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 254, 254, 254, 254, 254, - 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, - 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, - 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 253, - 253, 253, 253, 253, 253, 253, 253, 253, 253, 253, 253, - 253, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, - 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, - 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, - 254, 254, 254, 254, 254, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, -}; - -static const short am0_coeff[] = { - 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, -}; - -static const short am1_coeff[] = { - 12, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, - 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 19, - 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, - 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, - 24, 24, 24, 24, 24, 24, 24, 24, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 24, 24, 24, 24, 24, 24, 24, 24, 23, 23, 23, - 23, 23, 23, 22, 22, 22, 22, 22, 21, 21, 21, - 21, 20, 20, 20, 20, 19, 19, 19, 19, 18, 18, - 18, 17, 17, 17, 17, 16, 16, 16, 15, 15, 15, - 14, 14, 14, 14, 13, 13, 13, 12, 12, 12, 11, - 11, 11, 10, 10, 10, 9, 9, 9, 9, 8, 8, - 8, 7, 7, 7, 7, 6, 6, 6, 5, 5, 5, - 5, 4, 4, 4, 4, 3, 3, 3, 3, 3, 2, - 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, - 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, - 5, 5, 5, 6, 6, 6, 7, 7, 7, 7, 8, - 8, 8, 9, 9, 9, 9, 10, 10, 10, 11, 11, - 11, 12, 12, -}; - -#endif diff --git a/apps/codecs/libgme/resampler.c b/apps/codecs/libgme/resampler.c deleted file mode 100644 index c4f42a9794..0000000000 --- a/apps/codecs/libgme/resampler.c +++ /dev/null @@ -1,218 +0,0 @@ -// Game_Music_Emu 0.5.5. http://www.slack.net/~ant/ - -#include "resampler.h" - -#include -#include - -/* Copyright (C) 2003-2006 Shay Green. This module is free software; you -can redistribute it and/or modify it under the terms of the GNU Lesser -General Public License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. This -module is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more -details. You should have received a copy of the GNU Lesser General Public -License along with this module; if not, write to the Free Software Foundation, -Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ - -#include "blargg_source.h" - -// TODO: fix this. hack since resampler holds back some output. -unsigned const resampler_extra = 34; - -enum { shift = 14 }; -int const unit = 1 << shift; - -blargg_err_t Resampler_setup( struct Resampler* this, int fm_rate, int fm_gain, int rate, int gain ) -{ - this->gain_ = (int)( ((1LL << gain_bits) * fm_gain * gain) / FP_ONE_GAIN ); - this->step = (int)( ((1LL << shift) * fm_rate) / rate + 1); - this->rate_ = this->step; - return 0; -} - -blargg_err_t Resampler_reset( struct Resampler* this, int pairs ) -{ - // expand allocations a bit - this->sample_buffer_size = (pairs + (pairs >> 2)) * 2; - Resampler_resize( this, pairs ); - this->resampler_size = this->oversamples_per_frame + (this->oversamples_per_frame >> 2); - - this->buffer_size = this->resampler_size; - this->pos = 0; - this->write_pos = 0; - - Resampler_clear( this ); - return 0; -} - -void Resampler_resize( struct Resampler* this, int pairs ) -{ - int new_sample_buf_size = pairs * 2; - if ( this->sample_buf_size != new_sample_buf_size ) - { - if ( new_sample_buf_size > this->sample_buffer_size ) - { - check(false); - return; - } - - this->sample_buf_size = new_sample_buf_size; - this->oversamples_per_frame = (int) ((pairs * this->rate_ * 2LL) / unit) + 2; - Resampler_clear( this ); - } -} - -static void mix_samples( struct Resampler* this, struct Blip_Buffer* blip_buf, dsample_t out_ [] ) -{ - int const bass = BLIP_READER_BASS( *blip_buf ); - BLIP_READER_BEGIN( sn, *blip_buf ); - - int count = this->sample_buf_size >> 1; - BLIP_READER_ADJ_( sn, count ); - - typedef dsample_t stereo_dsample_t [2]; - stereo_dsample_t* BLARGG_RESTRICT out = (stereo_dsample_t*) out_ + count; - stereo_dsample_t const* BLARGG_RESTRICT in = - (stereo_dsample_t const*) this->sample_buf + count; - int offset = -count; - int const gain = this->gain_; - do - { - int s = BLIP_READER_READ_RAW( sn ) >> (blip_sample_bits - 16); - BLIP_READER_NEXT_IDX_( sn, bass, offset ); - - int l = (in [offset] [0] * gain >> gain_bits) + s; - int r = (in [offset] [1] * gain >> gain_bits) + s; - - BLIP_CLAMP( l, l ); - out [offset] [0] = (blip_sample_t) l; - - BLIP_CLAMP( r, r ); - out [offset] [1] = (blip_sample_t) r; - } - while ( ++offset ); - - BLIP_READER_END( sn, *blip_buf ); -} - -static dsample_t const* resample_( struct Resampler* this, dsample_t** out_, - dsample_t const* out_end, dsample_t const in [], int in_size ) -{ - in_size -= write_offset; - if ( in_size > 0 ) - { - dsample_t* BLARGG_RESTRICT out = *out_; - dsample_t const* const in_end = in + in_size; - - int const step = this->step; - int pos = this->pos; - - // TODO: IIR filter, then linear resample - // TODO: detect skipped sample, allowing merging of IIR and resample? - - do - { - #define INTERP( i, out )\ - out = (in [0 + i] * (unit - pos) + ((in [2 + i] + in [4 + i] + in [6 + i]) << shift) +\ - in [8 + i] * pos) >> (shift + 2); - - int out_0; - INTERP( 0, out_0 ) - INTERP( 1, out [0] = out_0; out [1] ) - out += stereo; - - pos += step; - in += ((unsigned) pos >> shift) * stereo; - pos &= unit - 1; - } - while ( in < in_end && out < out_end ); - - this->pos = pos; - *out_ = out; - } - return in; -} - -static inline int resample_wrapper( struct Resampler* this, dsample_t out [], int* out_size, - dsample_t const in [], int in_size ) -{ - assert( Resampler_rate( this ) ); - - dsample_t* out_ = out; - int result = resample_( this, &out_, out + *out_size, in, in_size ) - in; - assert( out_ <= out + *out_size ); - assert( result <= in_size ); - - *out_size = out_ - out; - return result; -} - -static int skip_input( struct Resampler* this, int count ) -{ - this->write_pos -= count; - if ( this->write_pos < 0 ) // occurs when downsampling - { - count += this->write_pos; - this->write_pos = 0; - } - memmove( this->buf, &this->buf [count], this->write_pos * sizeof this->buf [0] ); - return count; -} - -static void play_frame_( struct Resampler* this, struct Blip_Buffer* blip_buf, dsample_t* out ) -{ - int pair_count = this->sample_buf_size >> 1; - blip_time_t blip_time = Blip_count_clocks( blip_buf, pair_count ); - int sample_count = this->oversamples_per_frame - this->write_pos + resampler_extra; - - int new_count = this->callback( this->callback_data, blip_time, sample_count, &this->buf [this->write_pos] ); - assert( new_count < this->resampler_size ); - - Blip_end_frame( blip_buf, blip_time ); - assert( Blip_samples_avail( blip_buf ) == pair_count ); - - this->write_pos += new_count; - assert( (unsigned) this->write_pos <= this->buffer_size ); - - int count = this->sample_buf_size; - if ( count ) - skip_input( this, resample_wrapper( this, this->sample_buf, &count, this->buf, this->write_pos ) ); - assert( count == this->sample_buf_size ); - - mix_samples( this, blip_buf, out ); - Blip_remove_samples( blip_buf, pair_count ); -} - -void Resampler_play( struct Resampler* this, int count, dsample_t* out, struct Blip_Buffer* blip_buf ) -{ - // empty extra buffer - int remain = this->sample_buf_size - this->buf_pos; - if ( remain ) - { - if ( remain > count ) - remain = count; - count -= remain; - memcpy( out, &this->sample_buf [this->buf_pos], remain * sizeof *out ); - out += remain; - this->buf_pos += remain; - } - - // entire frames - while ( count >= this->sample_buf_size ) - { - play_frame_( this, blip_buf, out ); - out += this->sample_buf_size; - count -= this->sample_buf_size; - } - - // extra - if ( count ) - { - play_frame_( this, blip_buf, this->sample_buf ); - this->buf_pos = count; - memcpy( out, this->sample_buf, count * sizeof *out ); - out += count; - } -} diff --git a/apps/codecs/libgme/resampler.h b/apps/codecs/libgme/resampler.h deleted file mode 100644 index 3f3710a54a..0000000000 --- a/apps/codecs/libgme/resampler.h +++ /dev/null @@ -1,75 +0,0 @@ -// Combination of Downsampler and Blip_Buffer mixing. Used by Sega FM emulators. - -// Game_Music_Emu 0.5.5 -#ifndef RESAMPLER_H -#define RESAMPLER_H - -#include "blargg_common.h" -#include "multi_buffer.h" - -typedef short dsample_t; - -enum { max_buf_size = 3960 }; -enum { max_resampler_size = 5942 }; -enum { write_offset = 8 * stereo }; -enum { gain_bits = 14 }; - -struct Resampler { - int (*callback)( void*, blip_time_t, int, dsample_t* ); - void* callback_data; - - int sample_buffer_size; - int sample_buf_size; - int oversamples_per_frame; - int buf_pos; - int resampler_size; - int gain_; - - int buffer_size; - int write_pos; - - int pos; - int step; - - int rate_; - - dsample_t sample_buf [max_buf_size]; - dsample_t buf [max_resampler_size]; // Internal resampler -}; - -static inline void Resampler_init( struct Resampler* this ) -{ - this->pos = 0; - this->write_pos = 0; - this->rate_ = 0; - this->sample_buf_size = 0; - this->sample_buffer_size = 0; - this->oversamples_per_frame = 0; -} - -blargg_err_t Resampler_reset( struct Resampler* this, int max_pairs ); -void Resampler_resize( struct Resampler* this, int pairs_per_frame ); -void Resampler_play( struct Resampler* this, int count, dsample_t* out, struct Blip_Buffer* ); - -static inline void Resampler_set_callback(struct Resampler* this, int (*func)( void*, blip_time_t, int, dsample_t* ), void* user_data ) -{ - this->callback = func; - this->callback_data = user_data; -} - -blargg_err_t Resampler_setup( struct Resampler* this, int fm_rate, int fm_gain, int rate, int gain ); - -static inline void Resampler_clear( struct Resampler* this ) -{ - this->buf_pos = this->sample_buf_size; - - this->pos = 0; - this->write_pos = 0; -} - -static inline int Resampler_rate( struct Resampler* this ) -{ - return this->rate_; -} - -#endif diff --git a/apps/codecs/libgme/rom_data.c b/apps/codecs/libgme/rom_data.c deleted file mode 100644 index 9c36a99d2d..0000000000 --- a/apps/codecs/libgme/rom_data.c +++ /dev/null @@ -1,68 +0,0 @@ -// Game_Music_Emu 0.5.2. http://www.slack.net/~ant/ - -#include "rom_data.h" - -/* Copyright (C) 2003-2006 Shay Green. This module is free software; you -can redistribute it and/or modify it under the terms of the GNU Lesser -General Public License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. This -module is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more -details. You should have received a copy of the GNU Lesser General Public -License along with this module; if not, write to the Free Software Foundation, -Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ - -#include -#include "blargg_source.h" - -// Rom_Data - -blargg_err_t Rom_load( struct Rom_Data* this, const void* data, long size, - int header_size, void* header_out, int fill ) -{ - int file_offset = this->pad_size; - - this->rom_addr = 0; - this->mask = 0; - this->size = 0; - - if ( size <= header_size ) // <= because there must be data after header - return gme_wrong_file_type; - - // Read header - memcpy( header_out, data, header_size ); - - this->file_size = size - header_size; - this->file_data = (byte*) data + header_size; - - memset( this->unmapped, fill, this->rom_size ); - memcpy( &this->unmapped [file_offset], this->file_data, - this->file_size < this->pad_size ? this->file_size : this->pad_size ); - - return 0; -} - -void Rom_set_addr( struct Rom_Data* this, int addr ) -{ - this->rom_addr = addr - this->bank_size - pad_extra; - - int rounded = (addr + this->file_size + this->bank_size - 1) / this->bank_size * this->bank_size; - if ( rounded <= 0 ) - { - rounded = 0; - } - else - { - int shift = 0; - unsigned int max_addr = (unsigned int) (rounded - 1); - while ( max_addr >> shift ) - shift++; - this->mask = (1L << shift) - 1; - } - - if ( addr < 0 ) - addr = 0; - this->size = rounded; - this->rsize_ = rounded - this->rom_addr + pad_extra; -} diff --git a/apps/codecs/libgme/rom_data.h b/apps/codecs/libgme/rom_data.h deleted file mode 100644 index b8bc54cd3f..0000000000 --- a/apps/codecs/libgme/rom_data.h +++ /dev/null @@ -1,83 +0,0 @@ -// Common aspects of emulators which use rom data - -// Game_Music_Emu 0.5.2 -#ifndef ROM_DATA_H -#define ROM_DATA_H - -#include "blargg_common.h" -#include "blargg_source.h" - -// ROM data handler, used by several Classic_Emu derivitives. Loads file data -// with padding on both sides, allowing direct use in bank mapping. The main purpose -// is to allow all file data to be loaded with only one read() call (for efficiency). - -extern const char gme_wrong_file_type []; // declared in gme.h - -enum { pad_extra = 8 }; -enum { max_bank_size = 0x4000 }; -enum { max_pad_size = max_bank_size + pad_extra }; -enum { max_rom_size = 2 * max_pad_size }; - -struct Rom_Data { - byte* file_data; - unsigned file_size; - - int rom_addr; - int bank_size; - int rom_size; - unsigned pad_size; - int mask; - int size; // TODO: eliminate - int rsize_; - - // Unmapped space - byte unmapped [max_rom_size]; -}; - -// Initialize rom -static inline void Rom_init( struct Rom_Data* this, int bank_size ) -{ - this->bank_size = bank_size; - this->pad_size = this->bank_size + pad_extra; - this->rom_size = 2 * this->pad_size; -} - -// Load file data, using already-loaded header 'h' if not NULL. Copy header -// from loaded file data into *out and fill unmapped bytes with 'fill'. -blargg_err_t Rom_load( struct Rom_Data* this, const void* data, long size, int header_size, void* header_out, int fill ); - -// Set address that file data should start at -void Rom_set_addr( struct Rom_Data* this, int addr ); - -// Mask address to nearest power of two greater than size() -static inline int mask_addr( int addr, int mask ) -{ - #ifdef check - check( addr <= mask ); - #endif - return addr & mask; -} - -// Pointer to page starting at addr. Returns unmapped() if outside data. -static inline byte* Rom_at_addr( struct Rom_Data* this, int addr ) -{ - unsigned offset = mask_addr( addr, this->mask ) - this->rom_addr; - if ( offset > (unsigned) (this->rsize_ - this->pad_size) ) - offset = 0; // unmapped - - if ( offset < this->pad_size ) return &this->unmapped [offset]; - else return &this->file_data [offset - this->pad_size]; -} - - -#ifndef GME_APU_HOOK - #define GME_APU_HOOK( emu, addr, data ) ((void) 0) -#endif - -#ifndef GME_FRAME_HOOK - #define GME_FRAME_HOOK( emu ) ((void) 0) -#else - #define GME_FRAME_HOOK_DEFINED 1 -#endif - -#endif diff --git a/apps/codecs/libgme/sgc_cpu.c b/apps/codecs/libgme/sgc_cpu.c deleted file mode 100644 index d23c01499b..0000000000 --- a/apps/codecs/libgme/sgc_cpu.c +++ /dev/null @@ -1,36 +0,0 @@ -// Game_Music_Emu 0.6-pre. http://www.slack.net/~ant/ - -#include "sgc_emu.h" - -#include "blargg_endian.h" -//#include "z80_cpu_log.h" - -/* Copyright (C) 2009 Shay Green. This module is free software; you -can redistribute it and/or modify it under the terms of the GNU Lesser -General Public License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. This -module is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more -details. You should have received a copy of the GNU Lesser General Public -License along with this module; if not, write to the Free Software Foundation, -Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ - -#include "blargg_source.h" - -#define OUT_PORT( addr, data ) cpu_out( this, TIME(), addr, data ) -#define IN_PORT( addr ) 0 // cpu in -#define WRITE_MEM( addr, data ) cpu_write( this, addr, data ) -#define IDLE_ADDR this->idle_addr -#define RST_BASE this->vectors_addr - -#define CPU_BEGIN \ -bool run_cpu( struct Sgc_Emu* this, cpu_time_t end_time )\ -{\ - Sgc_Cpu* cpu = &this->cpu; \ - Z80_set_end_time( cpu, end_time ); - - #include "z80_cpu_run.h" - - return warning; -} diff --git a/apps/codecs/libgme/sgc_emu.c b/apps/codecs/libgme/sgc_emu.c deleted file mode 100644 index 267f2c9271..0000000000 --- a/apps/codecs/libgme/sgc_emu.c +++ /dev/null @@ -1,480 +0,0 @@ -// Game_Music_Emu 0.6-pre. http://www.slack.net/~ant/ - -#include "sgc_emu.h" - -/* Copyright (C) 2009 Shay Green. This module is free software; you -can redistribute it and/or modify it under the terms of the GNU Lesser -General Public License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. This -module is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more -details. You should have received a copy of the GNU Lesser General Public -License aint with this module; if not, write to the Free Software Foundation, -Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ - -#include "blargg_source.h" - -int const osc_count = sms_osc_count + fm_apu_osc_count; - -const char gme_wrong_file_type [] = "Wrong file type for this emulator"; - -static void clear_track_vars( struct Sgc_Emu* this ) -{ - this->current_track = -1; - track_stop( &this->track_filter ); -} - -void Sgc_init( struct Sgc_Emu* this ) -{ - assert( offsetof (struct header_t,copyright [32]) == header_size ); - - this->sample_rate = 0; - this->mute_mask_ = 0; - this->tempo = (int)FP_ONE_TEMPO; - this->gain = (int)FP_ONE_GAIN; - - // defaults - this->tfilter = *track_get_setup( &this->track_filter ); - this->tfilter.max_initial = 2; - this->tfilter.lookahead = 6; - this->track_filter.silence_ignored_ = false; - - Sms_apu_init( &this->apu ); - Fm_apu_create( &this->fm_apu ); - - Rom_init( &this->rom, 0x4000 ); - Z80_init( &this->cpu ); - - Sound_set_gain( this, (int)(FP_ONE_GAIN*1.2) ); - - // Unload - this->voice_count = 0; - this->voice_types = 0; - clear_track_vars( this ); -} - -// Setup - -blargg_err_t Sgc_load_mem( struct Sgc_Emu* this, const void* data, long size ) -{ - RETURN_ERR( Rom_load( &this->rom, data, size, header_size, &this->header, 0 ) ); - - if ( !valid_tag( &this->header ) ) - return gme_wrong_file_type; - - /* if ( header.vers != 1 ) - warning( "Unknown file version" ); */ - - /* if ( header.system > 2 ) - warning( "Unknown system" ); */ - - addr_t load_addr = get_le16( this->header.load_addr ); - /* if ( load_addr < 0x400 ) - set_warning( "Invalid load address" ); */ - - Rom_set_addr( &this->rom, load_addr ); - this->play_period = clock_rate( this ) / 60; - - if ( sega_mapping( this ) && Fm_apu_supported() ) - RETURN_ERR( Fm_apu_init( &this->fm_apu, clock_rate( this ), clock_rate( this ) / 72 ) ); - - this->m3u.size = 0; - this->track_count = this->header.song_count; - this->voice_count = sega_mapping( this ) ? osc_count : sms_osc_count; - static int const types [sms_osc_count + fm_apu_osc_count] = { - wave_type+1, wave_type+2, wave_type+3, mixed_type+1, mixed_type+2 - }; - this->voice_types = types; - - Sms_apu_volume( &this->apu, this->gain ); - Fm_apu_volume( &this->fm_apu, this->gain ); - - // Setup buffer - this->clock_rate_ = clock_rate( this ); - Buffer_clock_rate( &this->stereo_buf, clock_rate( this ) ); - RETURN_ERR( Buffer_set_channel_count( &this->stereo_buf, this->voice_count, this->voice_types ) ); - this->buf_changed_count = Buffer_channels_changed_count( &this->stereo_buf ); - - Sound_set_tempo( this, this->tempo ); - Sound_mute_voices( this, this->mute_mask_ ); - return 0; -} - -static void Sound_set_voice( struct Sgc_Emu* this, int i, struct Blip_Buffer* c, struct Blip_Buffer* l, struct Blip_Buffer* r ) -{ - if ( i < sms_osc_count ) - Sms_apu_set_output( &this->apu, i, c, l, r ); - else - Fm_apu_set_output( &this->fm_apu, c ); -} - -static blargg_err_t run_clocks( struct Sgc_Emu* this, blip_time_t* duration, int msec ) -{ -#if defined(ROCKBOX) - (void) msec; -#endif - - cpu_time_t t = *duration; - while ( Z80_time( &this->cpu ) < t ) - { - cpu_time_t next = min( t, this->next_play ); - if ( run_cpu( this, next ) ) - { - /* warning( "Unsupported CPU instruction" ); */ - Z80_set_time( &this->cpu, next ); - } - - if ( this->cpu.r.pc == this->idle_addr ) - Z80_set_time( &this->cpu, next ); - - if ( Z80_time( &this->cpu ) >= this->next_play ) - { - this->next_play += this->play_period; - if ( this->cpu.r.pc == this->idle_addr ) - jsr( this, this->header.play_addr ); - } - } - - this->next_play -= t; - check( this->next_play >= 0 ); - Z80_adjust_time( &this->cpu, -t ); - - Sms_apu_end_frame( &this->apu, t ); - if ( sega_mapping( this ) && this->fm_accessed ) - { - if ( Fm_apu_supported() ) - Fm_apu_end_frame( &this->fm_apu, t ); - /* else - warning( "FM sound not supported" ); */ - } - - return 0; -} - -// Emulation - -void cpu_out( struct Sgc_Emu* this, cpu_time_t time, addr_t addr, int data ) -{ - int port = addr & 0xFF; - - if ( sega_mapping( this ) ) - { - switch ( port ) - { - case 0x06: - Sms_apu_write_ggstereo( &this->apu, time, data ); - return; - - case 0x7E: - case 0x7F: - Sms_apu_write_data( &this->apu, time, data ); /* dprintf( "$7E<-%02X\n", data ); */ - return; - - case 0xF0: - this->fm_accessed = true; - if ( Fm_apu_supported() ) - Fm_apu_write_addr( &this->fm_apu, data );//, dprintf( "$F0<-%02X\n", data ); - return; - - case 0xF1: - this->fm_accessed = true; - if ( Fm_apu_supported() ) - Fm_apu_write_data( &this->fm_apu, time, data );//, dprintf( "$F1<-%02X\n", data ); - return; - } - } - else if ( port >= 0xE0 ) - { - Sms_apu_write_data( &this->apu, time, data ); - return; - } -} - -void jsr( struct Sgc_Emu* this, byte addr [2] ) -{ - *Z80_write( &this->cpu, --this->cpu.r.sp ) = this->idle_addr >> 8; - *Z80_write( &this->cpu, --this->cpu.r.sp ) = this->idle_addr & 0xFF; - this->cpu.r.pc = get_le16( addr ); -} - -static void set_bank( struct Sgc_Emu* this, int bank, void const* data ) -{ - //dprintf( "map bank %d to %p\n", bank, (byte*) data - rom.at_addr( 0 ) ); - Z80_map_mem( &this->cpu, bank * this->rom.bank_size, this->rom.bank_size, this->unmapped_write, data ); -} - -void cpu_write( struct Sgc_Emu* this, addr_t addr, int data ) -{ - if ( (addr ^ 0xFFFC) > 3 || !sega_mapping( this ) ) - { - *Z80_write( &this->cpu, addr ) = data; - return; - } - - switch ( addr ) - { - case 0xFFFC: - Z80_map_mem_rw( &this->cpu, 2 * this->rom.bank_size, this->rom.bank_size, this->ram2 ); - if ( data & 0x08 ) - break; - - this->bank2 = this->ram2; - // FALL THROUGH - - case 0xFFFF: { - bool rom_mapped = (Z80_read( &this->cpu, 2 * this->rom.bank_size ) == this->bank2); - this->bank2 = Rom_at_addr( &this->rom, data * this->rom.bank_size ); - if ( rom_mapped ) - set_bank( this, 2, this->bank2 ); - break; - } - - case 0xFFFD: - set_bank( this, 0, Rom_at_addr( &this->rom, data * this->rom.bank_size ) ); - break; - - case 0xFFFE: - set_bank( this, 1, Rom_at_addr( &this->rom, data * this->rom.bank_size ) ); - break; - } -} - -blargg_err_t Sgc_set_sample_rate( struct Sgc_Emu* this, int rate ) -{ - require( !this->sample_rate ); // sample rate can't be changed once set - Buffer_init( &this->stereo_buf ); - Buffer_set_sample_rate( &this->stereo_buf, rate, 1000 / 20 ); - - // Set buffer bass - Buffer_bass_freq( &this->stereo_buf, 80 ); - - this->sample_rate = rate; - RETURN_ERR( track_init( &this->track_filter, this ) ); - this->tfilter.max_silence = 6 * stereo * this->sample_rate; - return 0; -} - -void Sound_mute_voice( struct Sgc_Emu* this, int index, bool mute ) -{ - require( (unsigned) index < (unsigned) this->voice_count ); - int bit = 1 << index; - int mask = this->mute_mask_ | bit; - if ( !mute ) - mask ^= bit; - Sound_mute_voices( this, mask ); -} - -void Sound_mute_voices( struct Sgc_Emu* this, int mask ) -{ - require( this->sample_rate ); // sample rate must be set first - this->mute_mask_ = mask; - - int i; - for ( i = this->voice_count; i--; ) - { - if ( mask & (1 << i) ) - { - Sound_set_voice( this, i, 0, 0, 0 ); - } - else - { - struct channel_t ch = Buffer_channel( &this->stereo_buf, i ); - assert( (ch.center && ch.left && ch.right) || - (!ch.center && !ch.left && !ch.right) ); // all or nothing - Sound_set_voice( this, i, ch.center, ch.left, ch.right ); - } - } -} - -void Sound_set_tempo( struct Sgc_Emu* this, int t ) -{ - require( this->sample_rate ); // sample rate must be set first - int const min = (int)(FP_ONE_TEMPO*0.02); - int const max = (int)(FP_ONE_TEMPO*4.00); - if ( t < min ) t = min; - if ( t > max ) t = max; - this->tempo = t; - - this->play_period = (int) ((clock_rate( this ) * FP_ONE_TEMPO) / (this->header.rate ? 50 : 60) / t); -} - -blargg_err_t Sgc_start_track( struct Sgc_Emu* this, int track ) -{ - clear_track_vars( this ); - - // Remap track if playlist available - if ( this->m3u.size > 0 ) { - struct entry_t* e = &this->m3u.entries[track]; - track = e->track; - } - - this->current_track = track; - - if ( sega_mapping( this ) ) - { - Sms_apu_reset( &this->apu, 0, 0 ); - Fm_apu_reset( &this->fm_apu ); - this->fm_accessed = false; - } - else - { - Sms_apu_reset( &this->apu, 0x0003, 15 ); - } - - memset( this->ram , 0, sizeof this->ram ); - memset( this->ram2, 0, sizeof this->ram2 ); - memset( this->vectors, 0xFF, sizeof this->vectors ); - Z80_reset( &this->cpu, this->unmapped_write, this->rom.unmapped ); - - if ( sega_mapping( this ) ) - { - this->vectors_addr = 0x10000 - page_size; - this->idle_addr = this->vectors_addr; - int i; - for ( i = 1; i < 8; ++i ) - { - this->vectors [i*8 + 0] = 0xC3; // JP addr - this->vectors [i*8 + 1] = this->header.rst_addrs [i - 1] & 0xff; - this->vectors [i*8 + 2] = this->header.rst_addrs [i - 1] >> 8; - } - - Z80_map_mem_rw( &this->cpu, 0xC000, 0x2000, this->ram ); - Z80_map_mem( &this->cpu, this->vectors_addr, page_size, this->unmapped_write, this->vectors ); - - this->bank2 = NULL; - for ( i = 0; i < 4; ++i ) - cpu_write( this, 0xFFFC + i, this->header.mapping [i] ); - } - else - { - if ( !this->coleco_bios ) - return "Coleco BIOS not set"; /* BLARGG_ERR( BLARGG_ERR_CALLER, "Coleco BIOS not set" ); */ - - this->vectors_addr = 0; - Z80_map_mem( &this->cpu, 0, 0x2000, this->unmapped_write, this->coleco_bios ); - int i; - for ( i = 0; i < 8; ++i ) - Z80_map_mem_rw( &this->cpu, 0x6000 + i*0x400, 0x400, this->ram ); - - this->idle_addr = 0x2000; - Z80_map_mem( &this->cpu, 0x2000, page_size, this->unmapped_write, this->vectors ); - - for ( i = 0; i < 0x8000 / this->rom.bank_size; ++i ) - { - int addr = 0x8000 + i*this->rom.bank_size; - Z80_map_mem( &this->cpu, addr, this->rom.bank_size, this->unmapped_write, Rom_at_addr( &this->rom, addr ) ); - } - } - - this->cpu.r.sp = get_le16( this->header.stack_ptr ); - this->cpu.r.b.a = track; - this->next_play = this->play_period; - - jsr( this, this->header.init_addr ); - - Buffer_clear( &this->stereo_buf ); - - // convert filter times to samples - struct setup_t s = this->tfilter; - s.max_initial *= this->sample_rate * stereo; - #ifdef GME_DISABLE_SILENCE_LOOKAHEAD - s.lookahead = 1; - #endif - track_setup( &this->track_filter, &s ); - - return track_start( &this->track_filter ); -} - -// Tell/Seek - -static int msec_to_samples( int msec, int sample_rate ) -{ - int sec = msec / 1000; - msec -= sec * 1000; - return (sec * sample_rate + msec * sample_rate / 1000) * stereo; -} - -int Track_tell( struct Sgc_Emu* this ) -{ - int rate = this->sample_rate * stereo; - int sec = track_sample_count( &this->track_filter ) / rate; - return sec * 1000 + (track_sample_count( &this->track_filter ) - sec * rate) * 1000 / rate; -} - -blargg_err_t Track_seek( struct Sgc_Emu* this, int msec ) -{ - int time = msec_to_samples( msec, this->sample_rate ); - if ( time < track_sample_count( &this->track_filter ) ) - RETURN_ERR( Sgc_start_track( this, this->current_track ) ); - return Track_skip( this, time - track_sample_count( &this->track_filter ) ); -} - -blargg_err_t Track_skip( struct Sgc_Emu* this, int count ) -{ - require( this->current_track >= 0 ); // start_track() must have been called already - return track_skip( &this->track_filter, count ); -} - -blargg_err_t skip_( void* emu, int count ) -{ - struct Sgc_Emu* this = (struct Sgc_Emu*) emu; - - // for long skip, mute sound - const int threshold = 32768; - if ( count > threshold ) - { - int saved_mute = this->mute_mask_; - Sound_mute_voices( this, ~0 ); - - int n = count - threshold/2; - n &= ~(2048-1); // round to multiple of 2048 - count -= n; - RETURN_ERR( skippy_( &this->track_filter, n ) ); - - Sound_mute_voices( this, saved_mute ); - } - - return skippy_( &this->track_filter, count ); -} - -void Track_set_fade( struct Sgc_Emu* this, int start_msec, int length_msec ) -{ - track_set_fade( &this->track_filter, msec_to_samples( start_msec, this->sample_rate ), - length_msec * this->sample_rate / (1000 / stereo) ); -} - -blargg_err_t Sgc_play( struct Sgc_Emu* this, int out_count, sample_t* out ) -{ - require( this->current_track >= 0 ); - require( out_count % stereo == 0 ); - return track_play( &this->track_filter, out_count, out ); -} - -blargg_err_t play_( void* emu, int count, sample_t out [] ) -{ - struct Sgc_Emu* this = (struct Sgc_Emu*) emu; - - int remain = count; - while ( remain ) - { - Buffer_disable_immediate_removal( &this->stereo_buf ); - remain -= Buffer_read_samples( &this->stereo_buf, &out [count - remain], remain ); - if ( remain ) - { - if ( this->buf_changed_count != Buffer_channels_changed_count( &this->stereo_buf ) ) - { - this->buf_changed_count = Buffer_channels_changed_count( &this->stereo_buf ); - - // Remute voices - Sound_mute_voices( this, this->mute_mask_ ); - } - int msec = Buffer_length( &this->stereo_buf ); - blip_time_t clocks_emulated = msec * this->clock_rate_ / 1000 - 100; - RETURN_ERR( run_clocks( this, &clocks_emulated, msec ) ); - assert( clocks_emulated ); - Buffer_end_frame( &this->stereo_buf, clocks_emulated ); - } - } - return 0; -} diff --git a/apps/codecs/libgme/sgc_emu.h b/apps/codecs/libgme/sgc_emu.h deleted file mode 100644 index 83cde1e6ae..0000000000 --- a/apps/codecs/libgme/sgc_emu.h +++ /dev/null @@ -1,195 +0,0 @@ -// Sega/Game Gear/Coleco SGC music file emulator - -// Game_Music_Emu 0.6-pre -#ifndef SGC_EMU_H -#define SGC_EMU_H - -#include "blargg_common.h" -#include "multi_buffer.h" - -#include "rom_data.h" -#include "z80_cpu.h" -#include "sms_fm_apu.h" -#include "sms_apu.h" -#include "m3u_playlist.h" -#include "track_filter.h" - -typedef struct Z80_Cpu Sgc_Cpu; - -// SGC file header -enum { header_size = 0xA0 }; -struct header_t -{ - char tag [4]; // "SGC\x1A" - byte vers; // 0x01 - byte rate; // 0=NTSC 1=PAL - byte reserved1 [2]; - byte load_addr [2]; - byte init_addr [2]; - byte play_addr [2]; - byte stack_ptr [2]; - byte reserved2 [2]; - byte rst_addrs [7*2]; - byte mapping [4]; // Used by Sega only - byte first_song; // Song to start playing first - byte song_count; - byte first_effect; - byte last_effect; - byte system; // 0=Master System 1=Game Gear 2=Colecovision - byte reserved3 [23]; - char game [32]; // strings can be 32 chars, NOT terminated - char author [32]; - char copyright [32]; -}; - -// True if header has valid file signature -static inline bool valid_tag( struct header_t* h ) -{ - return 0 == memcmp( h->tag, "SGC\x1A", 4 ); -} - -static inline int effect_count( struct header_t* h ) { return h->last_effect ? h->last_effect - h->first_effect + 1 : 0; } - -struct Sgc_Emu { - bool fm_accessed; - - cpu_time_t play_period; - cpu_time_t next_play; - void const* bank2; // ROM selected for bank 2, in case RAM is currently hiding it - addr_t vectors_addr; // RST vectors start here - addr_t idle_addr; // return address for init/play routines - void* coleco_bios; - - // general - int voice_count; - int const* voice_types; - int mute_mask_; - int tempo; - int gain; - - int sample_rate; - - // track-specific - int current_track; - int track_count; - - int clock_rate_; - unsigned buf_changed_count; - - // M3u Playlist - struct M3u_Playlist m3u; - struct header_t header; - - struct setup_t tfilter; - struct Track_Filter track_filter; - - struct Multi_Buffer stereo_buf; - - struct Sms_Apu apu; - struct Sms_Fm_Apu fm_apu; - - Sgc_Cpu cpu; - - // large items - struct Rom_Data rom; - byte vectors [page_size + page_padding]; - byte unmapped_write [0x4000]; - byte ram [0x2000 + page_padding]; - byte ram2 [0x4000 + page_padding]; -}; - -// Basic functionality (see Gme_File.h for file loading/track info functions) - -void Sgc_init( struct Sgc_Emu* this ); - -blargg_err_t Sgc_load_mem( struct Sgc_Emu* this, const void* data, long size ); - -static inline int clock_rate( struct Sgc_Emu* this ) { return this->header.rate ? 3546893 : 3579545; } - -// 0x2000 bytes -static inline void set_coleco_bios( struct Sgc_Emu* this, void* p ) { this->coleco_bios = p; } - -// Set output sample rate. Must be called only once before loading file. -blargg_err_t Sgc_set_sample_rate( struct Sgc_Emu* this, int sample_rate ); - -// Start a track, where 0 is the first track. Also clears warning string. -blargg_err_t Sgc_start_track( struct Sgc_Emu* this, int track ); - -// Generate 'count' samples info 'buf'. Output is in stereo. Any emulation -// errors set warning string, and major errors also end track. -blargg_err_t Sgc_play( struct Sgc_Emu* this, int count, sample_t* buf ); - -// Track status/control - -// Number of milliseconds (1000 msec = 1 second) played since beginning of track -int Track_tell( struct Sgc_Emu* this ); - -// Seek to new time in track. Seeking backwards or far forward can take a while. -blargg_err_t Track_seek( struct Sgc_Emu* this, int msec ); - -// Skip n samples -blargg_err_t Track_skip( struct Sgc_Emu* this, int n ); - -// Set start time and length of track fade out. Once fade ends track_ended() returns -// true. Fade time can be changed while track is playing. -void Track_set_fade( struct Sgc_Emu* this, int start_msec, int length_msec ); - -// True if a track has reached its end -static inline bool Track_ended( struct Sgc_Emu* this ) -{ - return track_ended( &this->track_filter ); -} - -// Disables automatic end-of-track detection and skipping of silence at beginning -static inline void Track_ignore_silence( struct Sgc_Emu* this, bool disable ) -{ - this->track_filter.silence_ignored_ = disable; -} - -// Get track length in milliseconds -static inline int Track_get_length( struct Sgc_Emu* this, int n ) -{ - int length = 120 * 1000; /* 2 minutes */ - if ( (this->m3u.size > 0) && (n < this->m3u.size) ) { - struct entry_t* entry = &this->m3u.entries [n]; - length = entry->length; - } - - return length; -} - -// Sound customization - -// Adjust song tempo, where 1.0 = normal, 0.5 = half speed, 2.0 = double speed. -// Track length as returned by track_info() assumes a tempo of 1.0. -void Sound_set_tempo( struct Sgc_Emu* this, int t ); - -// Mute/unmute voice i, where voice 0 is first voice -void Sound_mute_voice( struct Sgc_Emu* this, int index, bool mute ); - -// Set muting state of all voices at once using a bit mask, where -1 mutes them all, -// 0 unmutes them all, 0x01 mutes just the first voice, etc. -void Sound_mute_voices( struct Sgc_Emu* this, int mask ); - -// Change overall output amplitude, where 1.0 results in minimal clamping. -// Must be called before set_sample_rate(). -static inline void Sound_set_gain( struct Sgc_Emu* this, int g ) -{ - assert( !this->sample_rate ); // you must set gain before setting sample rate - this->gain = g; -} - -// True if Master System or Game Gear -static inline bool sega_mapping( struct Sgc_Emu* this ) -{ - return this->header.system <= 1; -} - -// Emulation (You shouldn't touch these) - -bool run_cpu( struct Sgc_Emu* this, cpu_time_t end_time ); -void cpu_out( struct Sgc_Emu* this, cpu_time_t time, addr_t addr, int data ); -void cpu_write( struct Sgc_Emu* this, addr_t addr, int data ); -void jsr( struct Sgc_Emu* this, byte addr [2] ); - -#endif diff --git a/apps/codecs/libgme/sms_apu.c b/apps/codecs/libgme/sms_apu.c deleted file mode 100644 index 379fcf1cbf..0000000000 --- a/apps/codecs/libgme/sms_apu.c +++ /dev/null @@ -1,306 +0,0 @@ -// Sms_Snd_Emu 0.1.1. http://www.slack.net/~ant/ - -#include "sms_apu.h" - -/* Copyright (C) 2003-2008 Shay Green. This module is free software; you -can redistribute it and/or modify it under the terms of the GNU Lesser -General Public License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. This -module is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more -details. You should have received a copy of the GNU Lesser General Public -License along with this module; if not, write to the Free Software Foundation, -Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ - -#include "blargg_source.h" - -int const noise_osc = 3; - -void Sms_apu_volume( struct Sms_Apu* this, int vol ) -{ - vol = (vol - (vol*3)/20) / sms_osc_count / 64; - Synth_volume( &this->synth, vol ); -} - -static inline int calc_output( struct Sms_Apu* this, int i ) -{ - int flags = this->ggstereo >> i; - return (flags >> 3 & 2) | (flags & 1); -} - -void Sms_apu_set_output( struct Sms_Apu* this, int i, struct Blip_Buffer* center, struct Blip_Buffer* left, struct Blip_Buffer* right ) -{ -#if defined(ROCKBOX) - (void) left; - (void) right; -#endif - - // Must be silent (all NULL), mono (left and right NULL), or stereo (none NULL) - require( !center || (center && !left && !right) || (center && left && right) ); - require( (unsigned) i < sms_osc_count ); // fails if you pass invalid osc index - - if ( center ) - { - unsigned const divisor = 16384 * 16 * 2; - this->min_tone_period = ((unsigned) Blip_clock_rate( center ) + divisor/2) / divisor; - } - - if ( !center || !left || !right ) - { - left = center; - right = center; - } - - struct Osc* o = &this->oscs [i]; - o->outputs [0] = NULL; - o->outputs [1] = right; - o->outputs [2] = left; - o->outputs [3] = center; - o->output = o->outputs [calc_output( this, i )]; -} - -static inline unsigned fibonacci_to_galois_lfsr( unsigned fibonacci, int width ) -{ - unsigned galois = 0; - while ( --width >= 0 ) - { - galois = (galois << 1) | (fibonacci & 1); - fibonacci >>= 1; - } - return galois; -} - -void Sms_apu_reset( struct Sms_Apu* this, unsigned feedback, int noise_width ) -{ - this->last_time = 0; - this->latch = 0; - this->ggstereo = 0; - - // Calculate noise feedback values - if ( !feedback || !noise_width ) - { - feedback = 0x0009; - noise_width = 16; - } - this->looped_feedback = 1 << (noise_width - 1); - this->noise_feedback = fibonacci_to_galois_lfsr( feedback, noise_width ); - - // Reset oscs - int i; - for ( i = sms_osc_count; --i >= 0; ) - { - struct Osc* o = &this->oscs [i]; - o->output = NULL; - o->last_amp = 0; - o->delay = 0; - o->phase = 0; - o->period = 0; - o->volume = 15; // silent - } - - this->oscs [noise_osc].phase = 0x8000; - Sms_apu_write_ggstereo( this, 0, 0xFF ); -} - -void Sms_apu_init( struct Sms_Apu* this ) -{ - this->min_tone_period = 7; - - Synth_init( &this->synth ); - - // Clear outputs to NULL FIRST - this->ggstereo = 0; - - int i; - for ( i = sms_osc_count; --i >= 0; ) - Sms_apu_set_output( this, i, NULL, NULL, NULL ); - - Sms_apu_volume( this, (int)FP_ONE_VOLUME ); - Sms_apu_reset( this, 0, 0 ); -} - -static void run_until( struct Sms_Apu* this, blip_time_t end_time ) -{ - require( end_time >= this->last_time ); - if ( end_time <= this->last_time ) - return; - - // Synthesize each oscillator - int idx; - for ( idx = sms_osc_count; --idx >= 0; ) - { - struct Osc* osc = &this->oscs [idx]; - int vol = 0; - int amp = 0; - - // Determine what will be generated - struct Blip_Buffer* const out = osc->output; - if ( out ) - { - // volumes [i] ~= 64 * pow( 1.26, 15 - i ) / pow( 1.26, 15 ) - static unsigned char const volumes [16] = { - 64, 50, 40, 32, 25, 20, 16, 13, 10, 8, 6, 5, 4, 3, 2, 0 - }; - - vol = volumes [osc->volume]; - amp = (osc->phase & 1) * vol; - - // Square freq above 16 kHz yields constant amplitude at half volume - if ( idx != noise_osc && osc->period < this->min_tone_period ) - { - amp = vol >> 1; - vol = 0; - } - - // Update amplitude - int delta = amp - osc->last_amp; - if ( delta ) - { - osc->last_amp = amp; - Synth_offset( &this->synth, this->last_time, delta, out ); - Blip_set_modified( out ); - } - } - - // Generate wave - blip_time_t time = this->last_time + osc->delay; - if ( time < end_time ) - { - // Calculate actual period - int period = osc->period; - if ( idx == noise_osc ) - { - period = 0x20 << (period & 3); - if ( period == 0x100 ) - period = this->oscs [2].period * 2; - } - period *= 0x10; - if ( !period ) - period = 0x10; - - // Maintain phase when silent - int phase = osc->phase; - if ( !vol ) - { - int count = (end_time - time + period - 1) / period; - time += count * period; - if ( idx != noise_osc ) // TODO: maintain noise LFSR phase? - phase ^= count & 1; - } - else - { - int delta = amp * 2 - vol; - - if ( idx != noise_osc ) - { - // Square - do - { - delta = -delta; - Synth_offset( &this->synth, time, delta, out ); - time += period; - } - while ( time < end_time ); - phase = (delta >= 0); - } - else - { - // Noise - unsigned const feedback = (osc->period & 4 ? this->noise_feedback : this->looped_feedback); - do - { - unsigned changed = phase + 1; - phase = ((phase & 1) * feedback) ^ (phase >> 1); - if ( changed & 2 ) // true if bits 0 and 1 differ - { - delta = -delta; - Synth_offset_inline( &this->synth, time, delta, out ); - } - time += period; - } - while ( time < end_time ); - check( phase ); - } - osc->last_amp = (phase & 1) * vol; - Blip_set_modified( out ); - } - osc->phase = phase; - } - osc->delay = time - end_time; - } - this->last_time = end_time; -} - -void Sms_apu_write_ggstereo( struct Sms_Apu* this, blip_time_t time, int data ) -{ - require( (unsigned) data <= 0xFF ); - - run_until( this, time ); - this->ggstereo = data; - - int i; - for ( i = sms_osc_count; --i >= 0; ) - { - struct Osc* osc = &this->oscs [i]; - - struct Blip_Buffer* old = osc->output; - osc->output = osc->outputs [calc_output( this, i )]; - if ( osc->output != old ) - { - int delta = -osc->last_amp; - if ( delta ) - { - osc->last_amp = 0; - if ( old ) - { - Blip_set_modified( old ); - Synth_offset( &this->synth, this->last_time, delta, old ); - } - } - } - } -} - -void Sms_apu_write_data( struct Sms_Apu* this, blip_time_t time, int data ) -{ - require( (unsigned) data <= 0xFF ); - - run_until( this, time ); - - if ( data & 0x80 ) - this->latch = data; - - // We want the raw values written so our save state format can be - // as close to hardware as possible and unspecific to any emulator. - int idx = this->latch >> 5 & 3; - struct Osc* osc = &this->oscs [idx]; - if ( this->latch & 0x10 ) - { - osc->volume = data & 0x0F; - } - else - { - if ( idx == noise_osc ) - osc->phase = 0x8000; // reset noise LFSR - - // Replace high 6 bits/low 4 bits of register with data - int lo = osc->period; - int hi = data << 4; - if ( idx == noise_osc || (data & 0x80) ) - { - hi = lo; - lo = data; - } - osc->period = (hi & 0x3F0) | (lo & 0x00F); - } -} - -void Sms_apu_end_frame( struct Sms_Apu* this, blip_time_t end_time ) -{ - if ( end_time > this->last_time ) - run_until( this, end_time ); - - this->last_time -= end_time; - assert( this->last_time >= 0 ); -} diff --git a/apps/codecs/libgme/sms_apu.h b/apps/codecs/libgme/sms_apu.h deleted file mode 100644 index 6dd65591ce..0000000000 --- a/apps/codecs/libgme/sms_apu.h +++ /dev/null @@ -1,63 +0,0 @@ -// Sega Master System SN76489 PSG sound chip emulator - -// Sms_Snd_Emu 0.1.2 -#ifndef SMS_APU_H -#define SMS_APU_H - -#include "blargg_common.h" -#include "blip_buffer.h" - -// 0: Square 1, 1: Square 2, 2: Square 3, 3: Noise -enum { sms_osc_count = 4 }; // 0 <= chan < osc_count - -struct Osc -{ - struct Blip_Buffer* outputs [4]; // NULL, right, left, center - struct Blip_Buffer* output; - int last_amp; - - int volume; - int period; - int delay; - unsigned phase; -}; - -struct Sms_Apu { - struct Osc oscs [sms_osc_count]; - int ggstereo; - int latch; - - blip_time_t last_time; - int min_tone_period; - unsigned noise_feedback; - unsigned looped_feedback; - struct Blip_Synth synth; -}; - -// Basics - -void Sms_apu_init( struct Sms_Apu* this ); - -// Sets buffer(s) to generate sound into, or 0 to mute. If only center is not 0, -// output is mono. -void Sms_apu_set_output( struct Sms_Apu* this, int i, struct Blip_Buffer* center, struct Blip_Buffer* left, struct Blip_Buffer* right); - -// Emulates to time t, then writes data to Game Gear left/right assignment byte -void Sms_apu_write_ggstereo( struct Sms_Apu* this, blip_time_t t, int data ); - -// Emulates to time t, then writes data -void Sms_apu_write_data( struct Sms_Apu* this, blip_time_t t, int data ); - -// Emulates to time t, then subtracts t from the current time. -// OK if previous write call had time slightly after t. -void Sms_apu_end_frame( struct Sms_Apu* this, blip_time_t t ); - -// More features - -// Resets sound chip and sets noise feedback bits and width -void Sms_apu_reset( struct Sms_Apu* this, unsigned noise_feedback, int noise_width ); - -// Sets overall volume, where 1.0 is normal -void Sms_apu_volume( struct Sms_Apu* this, int vol ); - -#endif diff --git a/apps/codecs/libgme/sms_fm_apu.c b/apps/codecs/libgme/sms_fm_apu.c deleted file mode 100644 index ee5ce48932..0000000000 --- a/apps/codecs/libgme/sms_fm_apu.c +++ /dev/null @@ -1,82 +0,0 @@ -#include "sms_fm_apu.h" - -#include "blargg_source.h" - -void Fm_apu_create( struct Sms_Fm_Apu* this ) -{ - Synth_init( &this->synth ); - Ym2413_init( &this->apu ); -} - -blargg_err_t Fm_apu_init( struct Sms_Fm_Apu* this, int clock_rate, int sample_rate ) -{ - this->period_ = (blip_time_t) (clock_rate / sample_rate); - CHECK_ALLOC( !Ym2413_set_rate( &this->apu, sample_rate, clock_rate ) ); - - Fm_apu_set_output( this, 0 ); - Fm_apu_volume( this, (int)FP_ONE_VOLUME ); - Fm_apu_reset( this ); - return 0; -} - -void Fm_apu_reset( struct Sms_Fm_Apu* this ) -{ - this->addr = 0; - this->next_time = 0; - this->last_amp = 0; - - Ym2413_reset( &this->apu ); -} - -void fm_run_until( struct Sms_Fm_Apu* this, blip_time_t end_time ); -void Fm_apu_write_data( struct Sms_Fm_Apu* this, blip_time_t time, int data ) -{ - if ( time > this->next_time ) - fm_run_until( this, time ); - - Ym2413_write( &this->apu, this->addr, data ); -} - -void fm_run_until( struct Sms_Fm_Apu* this, blip_time_t end_time ) -{ - assert( end_time > this->next_time ); - - struct Blip_Buffer* const output = this->output_; - if ( !output ) - { - this->next_time = end_time; - return; - } - - blip_time_t time = this->next_time; - struct Ym2413_Emu* emu = &this->apu; - do - { - short samples [2]; - Ym2413_run( emu, 1, samples ); - int amp = (samples [0] + samples [1]) >> 1; - - int delta = amp - this->last_amp; - if ( delta ) - { - this->last_amp = amp; - Synth_offset_inline( &this->synth, time, delta, output ); - } - time += this->period_; - } - while ( time < end_time ); - - this->next_time = time; -} - -void Fm_apu_end_frame( struct Sms_Fm_Apu* this, blip_time_t time ) -{ - if ( time > this->next_time ) - fm_run_until( this, time ); - - this->next_time -= time; - assert( this->next_time >= 0 ); - - if ( this->output_ ) - Blip_set_modified( this->output_ ); -} diff --git a/apps/codecs/libgme/sms_fm_apu.h b/apps/codecs/libgme/sms_fm_apu.h deleted file mode 100644 index 921db6cef1..0000000000 --- a/apps/codecs/libgme/sms_fm_apu.h +++ /dev/null @@ -1,43 +0,0 @@ -#ifndef SMS_FM_APU_H -#define SMS_FM_APU_H - -#include "blargg_common.h" -#include "blip_buffer.h" -#include "ym2413_emu.h" - -enum { fm_apu_osc_count = 1 }; - -struct Sms_Fm_Apu { - struct Blip_Buffer* output_; - blip_time_t next_time; - int last_amp; - int addr; - - int clock_; - int rate_; - blip_time_t period_; - - struct Blip_Synth synth; - struct Ym2413_Emu apu; -}; - -void Fm_apu_create( struct Sms_Fm_Apu* this ); - -static inline bool Fm_apu_supported( void ) { return Ym2413_supported(); } -blargg_err_t Fm_apu_init( struct Sms_Fm_Apu* this, int clock_rate, int sample_rate ); - -static inline void Fm_apu_set_output( struct Sms_Fm_Apu* this, struct Blip_Buffer* b ) -{ - this->output_ = b; -} - -static inline void Fm_apu_volume( struct Sms_Fm_Apu* this, int v ) { Synth_volume( &this->synth, (v*2) / 5 / 4096 ); } - -void Fm_apu_reset( struct Sms_Fm_Apu* this ); - -static inline void Fm_apu_write_addr( struct Sms_Fm_Apu* this, int data ) { this->addr = data; } -void Fm_apu_write_data( struct Sms_Fm_Apu* this, blip_time_t, int data ); - -void Fm_apu_end_frame( struct Sms_Fm_Apu* this, blip_time_t t ); - -#endif diff --git a/apps/codecs/libgme/track_filter.c b/apps/codecs/libgme/track_filter.c deleted file mode 100644 index d0d75f2ded..0000000000 --- a/apps/codecs/libgme/track_filter.c +++ /dev/null @@ -1,294 +0,0 @@ -// Game_Music_Emu 0.6-pre. http://www.slack.net/~ant/ - -#include "track_filter.h" - -/* Copyright (C) 2003-2008 Shay Green. This module is free software; you -can redistribute it and/or modify it under the terms of the GNU Lesser -General Public License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. This -module is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more -details. You should have received a copy of the GNU Lesser General Public -License along with this module; if not, write to the Free Software Foundation, -Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ - -#include "blargg_source.h" - -int const fade_block_size = 512; -int const fade_shift = 8; // fade ends with gain at 1.0 / (1 << fade_shift) -int const silence_threshold = 8; - -void track_create( struct Track_Filter* this ) -{ - this->emu_ = NULL; - this->setup_.max_initial = 0; - this->setup_.lookahead = 0; - this->setup_.max_silence = indefinite_count; - this->silence_ignored_ = false; - track_stop( this ); -} - -blargg_err_t track_init( struct Track_Filter* this, void* emu ) -{ - this->emu_ = emu; - return 0; -} - -static void clear_time_vars( struct Track_Filter* this ) -{ - this->emu_time = this->buf_remain; - this->out_time = 0; - this->silence_time = 0; - this->silence_count = 0; -} - -void track_stop( struct Track_Filter* this ) -{ - this->emu_track_ended_ = true; - this->track_ended_ = true; - this->fade_start = indefinite_count; - this->fade_step = 1; - this->buf_remain = 0; - this->emu_error = NULL; - clear_time_vars( this ); -} - -blargg_err_t track_start( struct Track_Filter* this ) -{ - this->emu_error = NULL; - track_stop( this ); - - this->emu_track_ended_ = false; - this->track_ended_ = false; - - if ( !this->silence_ignored_ ) - { - // play until non-silence or end of track - while ( this->emu_time < this->setup_.max_initial ) - { - fill_buf( this ); - if ( this->buf_remain | this->emu_track_ended_ ) - break; - } - } - - clear_time_vars( this ); - return this->emu_error; -} - -static void end_track_if_error( struct Track_Filter* this, blargg_err_t err ) -{ - if ( err ) - { - this->emu_error = err; - this->emu_track_ended_ = true; - } -} - -blargg_err_t track_skip( struct Track_Filter* this, int count ) -{ - this->emu_error = NULL; - this->out_time += count; - - // remove from silence and buf first - { - int n = min( count, this->silence_count ); - this->silence_count -= n; - count -= n; - - n = min( count, this->buf_remain ); - this->buf_remain -= n; - count -= n; - } - - if ( count && !this->emu_track_ended_ ) - { - this->emu_time += count; - this->silence_time = this->emu_time; // would otherwise be invalid - end_track_if_error( this, skip_( this->emu_, count ) ); - } - - if ( !(this->silence_count | this->buf_remain) ) // caught up to emulator, so update track ended - this->track_ended_ |= this->emu_track_ended_; - - return this->emu_error; -} - -blargg_err_t skippy_( struct Track_Filter* this, int count ) -{ - while ( count && !this->emu_track_ended_ ) - { - int n = buf_size; - if ( n > count ) - n = count; - count -= n; - RETURN_ERR( play_( this->emu_, n, this->buf ) ); - } - return 0; -} - -// Fading - -void track_set_fade( struct Track_Filter* this, int start, int length ) -{ - this->fade_start = start; - this->fade_step = length / (fade_block_size * fade_shift); - if ( this->fade_step < 1 ) - this->fade_step = 1; -} - -static bool is_fading( struct Track_Filter* this ) -{ - return this->out_time >= this->fade_start && this->fade_start != indefinite_count; -} - -// unit / pow( 2.0, (double) x / step ) -static int int_log( int x, int step, int unit ) -{ - int shift = x / step; - int fraction = (x - shift * step) * unit / step; - return ((unit - fraction) + (fraction >> 1)) >> shift; -} - -static void handle_fade( struct Track_Filter* this, sample_t out [], int out_count ) -{ - int i; - for ( i = 0; i < out_count; i += fade_block_size ) - { - int const shift = 14; - int const unit = 1 << shift; - int gain = int_log( (this->out_time + i - this->fade_start) / fade_block_size, - this->fade_step, unit ); - if ( gain < (unit >> fade_shift) ) - this->track_ended_ = this->emu_track_ended_ = true; - - sample_t* io = &out [i]; - for ( int count = min( fade_block_size, out_count - i ); count; --count ) - { - *io = (sample_t) ((*io * gain) >> shift); - ++io; - } - } -} - -// Silence detection - -static void emu_play( struct Track_Filter* this, sample_t out [], int count ) -{ - this->emu_time += count; - if ( !this->emu_track_ended_ ) - end_track_if_error( this, play_( this->emu_, count, out ) ); - else - memset( out, 0, count * sizeof *out ); -} - -// number of consecutive silent samples at end -static int count_silence( sample_t begin [], int size ) -{ - sample_t first = *begin; - *begin = silence_threshold * 2; // sentinel - sample_t* p = begin + size; - while ( (unsigned) (*--p + silence_threshold) <= (unsigned) silence_threshold * 2 ) { } - *begin = first; - return size - (p - begin); -} - -// fill internal buffer and check it for silence -void fill_buf( struct Track_Filter* this ) -{ - assert( !this->buf_remain ); - if ( !this->emu_track_ended_ ) - { - emu_play( this, this->buf, buf_size ); - int silence = count_silence( this->buf, buf_size ); - if ( silence < buf_size ) - { - this->silence_time = this->emu_time - silence; - this->buf_remain = buf_size; - return; - } - } - this->silence_count += buf_size; -} - -blargg_err_t track_play( struct Track_Filter* this, int out_count, sample_t out [] ) -{ - this->emu_error = NULL; - if ( this->track_ended_ ) - { - memset( out, 0, out_count * sizeof *out ); - } - else - { - assert( this->emu_time >= this->out_time ); - - // prints nifty graph of how far ahead we are when searching for silence - //dprintf( "%*s \n", int ((emu_time - out_time) * 7 / 44100), "*" ); - - // use any remaining silence samples - int pos = 0; - if ( this->silence_count ) - { - if ( !this->silence_ignored_ ) - { - // during a run of silence, run emulator at >=2x speed so it gets ahead - int ahead_time = this->setup_.lookahead * (this->out_time + out_count - this->silence_time) + - this->silence_time; - while ( this->emu_time < ahead_time && !(this->buf_remain | this->emu_track_ended_) ) - fill_buf( this ); - - // end track if sufficient silence has been found - if ( this->emu_time - this->silence_time > this->setup_.max_silence ) - { - this->track_ended_ = this->emu_track_ended_ = true; - this->silence_count = out_count; - this->buf_remain = 0; - } - } - - // fill from remaining silence - pos = min( this->silence_count, out_count ); - memset( out, 0, pos * sizeof *out ); - this->silence_count -= pos; - } - - // use any remaining samples from buffer - if ( this->buf_remain ) - { - int n = min( this->buf_remain, (int) (out_count - pos) ); - memcpy( out + pos, this->buf + (buf_size - this->buf_remain), n * sizeof *out ); - this->buf_remain -= n; - pos += n; - } - - // generate remaining samples normally - int remain = out_count - pos; - if ( remain ) - { - emu_play( this, out + pos, remain ); - this->track_ended_ |= this->emu_track_ended_; - - if ( this->silence_ignored_ && !is_fading( this ) ) - { - // if left unupdated, ahead_time could become too large - this->silence_time = this->emu_time; - } - else - { - // check end for a new run of silence - int silence = count_silence( out + pos, remain ); - if ( silence < remain ) - this->silence_time = this->emu_time - silence; - - if ( this->emu_time - this->silence_time >= buf_size ) - fill_buf( this ); // cause silence detection on next play() - } - } - - if ( is_fading( this ) ) - handle_fade( this, out, out_count ); - } - this->out_time += out_count; - return this->emu_error; -} diff --git a/apps/codecs/libgme/track_filter.h b/apps/codecs/libgme/track_filter.h deleted file mode 100644 index 3689be9620..0000000000 --- a/apps/codecs/libgme/track_filter.h +++ /dev/null @@ -1,90 +0,0 @@ -// Removes silence from beginning of track, fades end of track. Also looks ahead -// for excessive silence, and if found, ends track. - -// Game_Music_Emu 0.6-pre -#ifndef TRACK_FILTER_H -#define TRACK_FILTER_H - -#include "blargg_common.h" - -typedef short sample_t; -typedef int sample_count_t; - -enum { indefinite_count = INT_MAX/2 + 1 }; -enum { buf_size = 2048 }; - -struct setup_t { - sample_count_t max_initial; // maximum silence to strip from beginning of track - sample_count_t max_silence; // maximum silence in middle of track without it ending - int lookahead; // internal speed when looking ahead for silence (2=200% etc.) -}; - -struct Track_Filter { - void* emu_; - struct setup_t setup_; - const char* emu_error; - bool silence_ignored_; - - // Timing - int out_time; // number of samples played since start of track - int emu_time; // number of samples emulator has generated since start of track - int emu_track_ended_; // emulator has reached end of track - volatile int track_ended_; - - // Fading - int fade_start; - int fade_step; - - // Silence detection - int silence_time; // absolute number of samples where most recent silence began - int silence_count; // number of samples of silence to play before using buf - int buf_remain; // number of samples left in silence buffer - sample_t buf [buf_size]; -}; - -// Initializes filter. Must be done once before using object. -blargg_err_t track_init( struct Track_Filter* this, void* ); -void track_create( struct Track_Filter* this ); - -// Gets/sets setup -static inline struct setup_t const* track_get_setup( struct Track_Filter* this ) { return &this->setup_; } -static inline void track_setup( struct Track_Filter* this, struct setup_t const* s ) { this->setup_ = *s; } - -// Disables automatic end-of-track detection and skipping of silence at beginning -static inline void track_ignore_silence( struct Track_Filter* this, bool disable ) { this->silence_ignored_ = disable; } - -// Clears state and skips initial silence in track -blargg_err_t track_start( struct Track_Filter* this ); - -// Sets time that fade starts, and how long until track ends. -void track_set_fade( struct Track_Filter* this, sample_count_t start, sample_count_t length ); - -// Generates n samples into buf -blargg_err_t track_play( struct Track_Filter* this, int n, sample_t buf [] ); - -// Skips n samples -blargg_err_t track_skip( struct Track_Filter* this, int n ); - -// Number of samples played/skipped since start_track() -static inline int track_sample_count( struct Track_Filter* this ) { return this->out_time; } - -// True if track ended. Causes are end of source samples, end of fade, -// or excessive silence. -static inline bool track_ended( struct Track_Filter* this ) { return this->track_ended_; } - -// Clears state -void track_stop( struct Track_Filter* this ); - -// For use by callbacks - -// Sets internal "track ended" flag and stops generation of further source samples -static inline void track_set_end( struct Track_Filter* this ) { this->emu_track_ended_ = true; } - -// For use by skip_() callback -blargg_err_t skippy_( struct Track_Filter* this, int count ); -void fill_buf( struct Track_Filter* this ); - -// Skip and play callbacks -blargg_err_t skip_( void* emu, int count ); -blargg_err_t play_( void* emu, int count, sample_t out [] ); -#endif diff --git a/apps/codecs/libgme/vgm_emu.c b/apps/codecs/libgme/vgm_emu.c deleted file mode 100644 index 4b8953ccf4..0000000000 --- a/apps/codecs/libgme/vgm_emu.c +++ /dev/null @@ -1,858 +0,0 @@ -// Game_Music_Emu 0.5.5. http://www.slack.net/~ant/ - -#include "vgm_emu.h" - -#include "blargg_endian.h" -#include -#include - -/* Copyright (C) 2003-2006 Shay Green. This module is free software; you -can redistribute it and/or modify it under the terms of the GNU Lesser -General Public License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. This -module is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more -details. You should have received a copy of the GNU Lesser General Public -License along with this module; if not, write to the Free Software Foundation, -Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ - -#include "blargg_source.h" - -const char* const gme_wrong_file_type = "Wrong file type for this emulator"; - -int const fm_gain = 3; // FM emulators are internally quieter to avoid 16-bit overflow - -// VGM commands (Spec v1.50) -enum { - cmd_gg_stereo = 0x4F, - cmd_psg = 0x50, - cmd_ym2413 = 0x51, - cmd_ym2612_port0 = 0x52, - cmd_ym2612_port1 = 0x53, - cmd_ym2151 = 0x54, - cmd_delay = 0x61, - cmd_delay_735 = 0x62, - cmd_delay_882 = 0x63, - cmd_byte_delay = 0x64, - cmd_end = 0x66, - cmd_data_block = 0x67, - cmd_short_delay = 0x70, - cmd_pcm_delay = 0x80, - cmd_pcm_seek = 0xE0, - - pcm_block_type = 0x00, - ym2612_dac_port = 0x2A, - ym2612_dac_pan_port = 0xB6 -}; - -static void clear_track_vars( struct Vgm_Emu* this ) -{ - this->current_track = -1; - track_stop( &this->track_filter ); -} - -int play_frame( struct Vgm_Emu* this, blip_time_t blip_time, int sample_count, sample_t* buf ); -static int play_frame_( void* data, blip_time_t blip_time, int sample_count, short int* buf ) -{ - return play_frame( (struct Vgm_Emu*) data, blip_time, sample_count, buf ); -} - -void Vgm_init( struct Vgm_Emu* this ) -{ - this->sample_rate = 0; - this->mute_mask_ = 0; - this->tempo = (int)(FP_ONE_TEMPO); - - // defaults - this->tfilter = *track_get_setup( &this->track_filter ); - this->tfilter.max_initial = 2; - this->tfilter.lookahead = 1; - this->track_filter.silence_ignored_ = false; - - // Disable oversampling by default - this->disable_oversampling = true; - this->psg_rate = 0; - - Sms_apu_init( &this->psg ); - Synth_init( &this->pcm ); - - Buffer_init( &this->stereo_buf ); - Blip_init( &this->blip_buf ); - - // Init fm chips - Ym2413_init( &this->ym2413 ); - Ym2612_init( &this->ym2612 ); - - // Init resampler - Resampler_init( &this->resampler ); - Resampler_set_callback( &this->resampler, play_frame_, this ); - - // Set sound gain, a value too high - // will cause saturation - Sound_set_gain(this, (int)(FP_ONE_GAIN*0.7)); - - // Unload - this->voice_count = 0; - this->voice_types = 0; - clear_track_vars( this ); -} - -// Track info - -static byte const* skip_gd3_str( byte const* in, byte const* end ) -{ - while ( end - in >= 2 ) - { - in += 2; - if ( !(in [-2] | in [-1]) ) - break; - } - return in; -} - -static byte const* get_gd3_str( byte const* in, byte const* end, char* field ) -{ - byte const* mid = skip_gd3_str( in, end ); - int i, len = (mid - in) / 2 - 1; - if ( field && len > 0 ) - { - len = min( len, (int) gme_max_field ); - field [len] = 0; - for ( i = 0; i < len; i++ ) - field [i] = (in [i * 2 + 1] ? '?' : in [i * 2]); // TODO: convert to utf-8 - } - return mid; -} - -static byte const* get_gd3_pair( byte const* in, byte const* end, char* field ) -{ - return skip_gd3_str( get_gd3_str( in, end, field ), end ); -} - -static void parse_gd3( byte const* in, byte const* end, struct track_info_t* out ) -{ - in = get_gd3_pair( in, end, out->song ); - in = get_gd3_pair( in, end, out->game ); - in = get_gd3_pair( in, end, NULL ); // Skip system - in = get_gd3_pair( in, end, out->author ); -} - -int const gd3_header_size = 12; - -static int check_gd3_header( byte const* h, int remain ) -{ - if ( remain < gd3_header_size ) return 0; - if ( memcmp( h, "Gd3 ", 4 ) ) return 0; - if ( get_le32( h + 4 ) >= 0x200 ) return 0; - - int gd3_size = get_le32( h + 8 ); - if ( gd3_size > remain - gd3_header_size ) - gd3_size = remain - gd3_header_size; - return gd3_size; -} - -static byte const* gd3_data( struct Vgm_Emu* this, int* size ) -{ - if ( size ) - *size = 0; - - int gd3_offset = get_le32( header( this )->gd3_offset ) - 0x2C; - if ( gd3_offset < 0 ) - return 0; - - byte const* gd3 = this->file_begin + header_size + gd3_offset; - int gd3_size = check_gd3_header( gd3, this->file_end - gd3 ); - if ( !gd3_size ) - return 0; - - if ( size ) - *size = gd3_size + gd3_header_size; - - return gd3; -} - -static void get_vgm_length( struct header_t const* h, struct track_info_t* out ) -{ - int length = get_le32( h->track_duration ) * 10 / 441; - if ( length > 0 ) - { - int loop = get_le32( h->loop_duration ); - if ( loop > 0 && get_le32( h->loop_offset ) ) - { - out->loop_length = loop * 10 / 441; - out->intro_length = length - out->loop_length; - } - else - { - out->length = length; // 1000 / 44100 (VGM files used 44100 as timebase) - out->intro_length = length; // make it clear that track is no longer than length - out->loop_length = 0; - } - } -} - -static blargg_err_t track_info( struct Vgm_Emu* this, struct track_info_t* out ) -{ - memset(out, 0, sizeof *out); - get_vgm_length( header( this ), out ); - - int size; - byte const* gd3 = gd3_data( this, &size ); - if ( gd3 ) - parse_gd3( gd3 + gd3_header_size, gd3 + size, out ); - - return 0; -} - -static blargg_err_t check_vgm_header( struct header_t* h ) -{ - if ( memcmp( h->tag, "Vgm ", 4 ) ) - return gme_wrong_file_type; - return 0; -} - -static void set_voice( struct Vgm_Emu* this, int i, struct Blip_Buffer* c, struct Blip_Buffer* l, struct Blip_Buffer* r ) -{ - if ( i < sms_osc_count ) { - Sms_apu_set_output( &this->psg, i, c, l, r ); - } -} - -blargg_err_t setup_fm( struct Vgm_Emu* this ); -blargg_err_t Vgm_load_mem( struct Vgm_Emu* this, byte const* new_data, long new_size, bool parse_info ) -{ - // Unload - this->voice_count = 0; - clear_track_vars( this ); - - // Clear info - memset( &this->info, 0, sizeof this->info ); - - assert( offsetof (struct header_t,unused2 [8]) == header_size ); - - if ( new_size <= header_size ) - return gme_wrong_file_type; - - // Reset data pointers - this->file_begin = new_data; - this->file_end = new_data + new_size; - - struct header_t* h = (struct header_t*) new_data; - RETURN_ERR( check_vgm_header( h ) ); - check( get_le32( h.version ) <= 0x150 ); - - // If this was VGZ file gd3 parse info - if ( parse_info ) { - track_info( this, &this->info ); - - // If file was trimmed add an - // incomplete token to the game tag - if ( get_le32( h->data_size ) > (unsigned) new_size ) { - *((char *) this->file_end) = cmd_end; - strcat(this->info.game, "(Trimmed VGZ file)" ); - } - } - - // Get loop - this->loop_begin = this->file_end; - - // If file was trimmed don't loop - if ( get_le32( h->loop_offset ) && get_le32( h->data_size ) <= (unsigned) new_size ) - this->loop_begin = &new_data [get_le32( h->loop_offset ) + offsetof (struct header_t,loop_offset)]; - - // PSG rate - this->psg_rate = get_le32( h->psg_rate ); - if ( !this->psg_rate ) - this->psg_rate = 3579545; - - Blip_set_clock_rate( &this->blip_buf, this->psg_rate ); - - // Disable FM - this->fm_rate = 0; - Ym2612_enable( &this->ym2612, false ); - Ym2413_enable( &this->ym2413, false ); - - this->voice_count = sms_osc_count; - static int const types [8] = { - wave_type+1, wave_type+2, wave_type+3, noise_type+1, - 0, 0, 0, 0 - }; - this->voice_types = types; - - RETURN_ERR( setup_fm( this ) ); - - // do after FM in case output buffer is changed - // setup buffer - this->clock_rate_ = this->psg_rate; - Buffer_clock_rate( &this->stereo_buf, this->psg_rate ); - RETURN_ERR( Buffer_set_channel_count( &this->stereo_buf, this->voice_count, this->voice_types ) ); - this->buf_changed_count = Buffer_channels_changed_count( &this->stereo_buf ); - - // Post load - Sound_set_tempo( this, this->tempo ); - Sound_mute_voices( this, this->mute_mask_ ); - - // so we can start playback - this->current_track = 0; - return 0; -} - -void update_fm_rates( struct Vgm_Emu* this, int* ym2413_rate, int* ym2612_rate ); -static blargg_err_t init_fm( struct Vgm_Emu* this, int* rate ) -{ - int ym2612_rate = get_le32( header( this )->ym2612_rate ); - int ym2413_rate = get_le32( header( this )->ym2413_rate ); - if ( ym2413_rate && get_le32( header( this )->version ) < 0x110 ) - update_fm_rates( this, &ym2413_rate, &ym2612_rate ); - - if ( ym2612_rate ) - { - if ( !*rate ) - *rate = ym2612_rate / 144; - RETURN_ERR( Ym2612_set_rate( &this->ym2612, *rate, ym2612_rate ) ); - Ym2612_enable( &this->ym2612, true ); - } - else if ( ym2413_rate ) - { - if ( !*rate ) - *rate = ym2413_rate / 72; - int result = Ym2413_set_rate( &this->ym2413, *rate, ym2413_rate ); - if ( result == 2 ) - return "YM2413 FM sound not supported"; - CHECK_ALLOC( !result ); - Ym2413_enable( &this->ym2413, true ); - } - - this->fm_rate = *rate; - - return 0; -} - -blargg_err_t setup_fm( struct Vgm_Emu* this ) -{ - int fm_rate = 0; - if ( !this->disable_oversampling ) - fm_rate = (this->sample_rate * 3) / 2; // oversample factor = 1.5 - RETURN_ERR( init_fm( this, &fm_rate ) ); - - if ( uses_fm( this ) ) - { - this->voice_count = 8; - RETURN_ERR( Resampler_setup( &this->resampler, fm_rate, fm_gain, this->sample_rate, this->gain ) ); - RETURN_ERR( Resampler_reset( &this->resampler, Blip_length( &this->blip_buf ) * this->sample_rate / 1000 ) ); - Sms_apu_volume( &this->psg, ((this->gain/5)-(this->gain*5)/1000) * fm_gain ); - } - else - { - Sms_apu_volume( &this->psg, this->gain ); - } - - return 0; -} - -// Emulation - -blip_time_t run( struct Vgm_Emu* this, vgm_time_t end_time ); -static blip_time_t run_psg( struct Vgm_Emu* this, int msec ) -{ - blip_time_t t = run( this, msec * this->vgm_rate / 1000 ); - Sms_apu_end_frame( &this->psg, t ); - return t; -} - -static void check_end( struct Vgm_Emu* this ) -{ - if( this->pos >= this->file_end ) - track_set_end( &this->track_filter ); -} - -static blargg_err_t run_clocks( struct Vgm_Emu* this, blip_time_t* time_io, int msec ) -{ - check_end( this ); - *time_io = run_psg( this, msec ); - return 0; -} - -blargg_err_t play_( void *emu, int count, sample_t out [] ) -{ - struct Vgm_Emu* this = (struct Vgm_Emu*) emu; - - if ( !uses_fm( this ) ) { - int remain = count; - while ( remain ) - { - Buffer_disable_immediate_removal( &this->stereo_buf ); - remain -= Buffer_read_samples( &this->stereo_buf, &out [count - remain], remain ); - if ( remain ) - { - if ( this->buf_changed_count != Buffer_channels_changed_count( &this->stereo_buf ) ) - { - this->buf_changed_count = Buffer_channels_changed_count( &this->stereo_buf ); - - // Remute voices - Sound_mute_voices( this, this->mute_mask_ ); - } - int msec = Buffer_length( &this->stereo_buf ); - blip_time_t clocks_emulated = msec * this->clock_rate_ / 1000 - 100; - RETURN_ERR( run_clocks( this, &clocks_emulated, msec ) ); - assert( clocks_emulated ); - Buffer_end_frame( &this->stereo_buf, clocks_emulated ); - } - } - - return 0; - } - - Resampler_play( &this->resampler, count, out, &this->blip_buf ); - return 0; -} - -// Vgm_Emu_impl - -static inline int command_len( int command ) -{ - static byte const lens [0x10] = { - // 0 1 2 3 4 5 6 7 8 9 A B C D E F - 1,1,1,2,2,3,1,1,1,1,3,3,4,4,5,5 - }; - int len = lens [command >> 4]; - check( len != 1 ); - return len; -} - -static inline fm_time_t to_fm_time( struct Vgm_Emu* this, vgm_time_t t ) -{ - return (t * this->fm_time_factor + this->fm_time_offset) >> fm_time_bits; -} - -static inline blip_time_t to_psg_time( struct Vgm_Emu* this, vgm_time_t t ) -{ - return (t * this->blip_time_factor) >> blip_time_bits; -} - -static void write_pcm( struct Vgm_Emu* this, vgm_time_t vgm_time, int amp ) -{ - check( amp >= 0 ); - blip_time_t blip_time = to_psg_time( this, vgm_time ); - int old = this->dac_amp; - int delta = amp - old; - this->dac_amp = amp; - Blip_set_modified( &this->blip_buf ); - if ( old >= 0 ) // first write is ignored, to avoid click - Synth_offset_inline( &this->pcm, blip_time, delta, &this->blip_buf ); - else - this->dac_amp |= this->dac_disabled; -} - -blip_time_t run( struct Vgm_Emu* this, vgm_time_t end_time ) -{ - vgm_time_t vgm_time = this->vgm_time; - byte const* pos = this->pos; - /* if ( pos > this->file_end ) - { - warning( "Stream lacked end event" ); - } */ - - while ( vgm_time < end_time && pos < this->file_end ) - { - // TODO: be sure there are enough bytes left in stream for particular command - // so we don't read past end - switch ( *pos++ ) - { - case cmd_end: - pos = this->loop_begin; // if not looped, loop_begin == data_end - break; - - case cmd_delay_735: - vgm_time += 735; - break; - - case cmd_delay_882: - vgm_time += 882; - break; - - case cmd_gg_stereo: - Sms_apu_write_ggstereo( &this->psg, to_psg_time( this, vgm_time ), *pos++ ); - break; - - case cmd_psg: - Sms_apu_write_data( &this->psg, to_psg_time( this, vgm_time ), *pos++ ); - break; - - case cmd_delay: - vgm_time += pos [1] * 0x100 + pos [0]; - pos += 2; - break; - - case cmd_byte_delay: - vgm_time += *pos++; - break; - - case cmd_ym2413: - if ( Ym2413_run_until( &this->ym2413, to_fm_time( this, vgm_time ) ) ) - Ym2413_write( &this->ym2413, pos [0], pos [1] ); - pos += 2; - break; - - case cmd_ym2612_port0: - if ( pos [0] == ym2612_dac_port ) - { - write_pcm( this, vgm_time, pos [1] ); - } - else if ( Ym2612_run_until( &this->ym2612, to_fm_time( this, vgm_time ) ) ) - { - if ( pos [0] == 0x2B ) - { - this->dac_disabled = (pos [1] >> 7 & 1) - 1; - this->dac_amp |= this->dac_disabled; - } - Ym2612_write0( &this->ym2612, pos [0], pos [1] ); - } - pos += 2; - break; - - case cmd_ym2612_port1: - if ( Ym2612_run_until( &this->ym2612, to_fm_time( this, vgm_time ) ) ) - Ym2612_write1( &this->ym2612, pos [0], pos [1] ); - pos += 2; - break; - - case cmd_data_block: { - check( *pos == cmd_end ); - int type = pos [1]; - int size = get_le32( pos + 2 ); - pos += 6; - if ( type == pcm_block_type ) - this->pcm_data = pos; - pos += size; - break; - } - - case cmd_pcm_seek: - this->pcm_pos = this->pcm_data + pos [3] * 0x1000000 + pos [2] * 0x10000 + - pos [1] * 0x100 + pos [0]; - pos += 4; - break; - - default: { - int cmd = pos [-1]; - switch ( cmd & 0xF0 ) - { - case cmd_pcm_delay: - write_pcm( this, vgm_time, *this->pcm_pos++ ); - vgm_time += cmd & 0x0F; - break; - - case cmd_short_delay: - vgm_time += (cmd & 0x0F) + 1; - break; - - case 0x50: - pos += 2; - break; - - default: - pos += command_len( cmd ) - 1; - /* warning( "Unknown stream event" ); */ - } - } - } - } - vgm_time -= end_time; - this->pos = pos; - this->vgm_time = vgm_time; - - return to_psg_time( this, end_time ); -} - -int play_frame( struct Vgm_Emu* this, blip_time_t blip_time, int sample_count, blip_sample_t out [] ) -{ - check_end( this); - - // to do: timing is working mostly by luck - int min_pairs = (unsigned) sample_count / 2; - int vgm_time = (min_pairs << fm_time_bits) / this->fm_time_factor - 1; - assert( to_fm_time( this, vgm_time ) <= min_pairs ); - int pairs; - while ( (pairs = to_fm_time( this, vgm_time )) < min_pairs ) - vgm_time++; - //debug_printf( "pairs: %d, min_pairs: %d\n", pairs, min_pairs ); - - if ( Ym2612_enabled( &this->ym2612 ) ) - { - Ym2612_begin_frame( &this->ym2612, out ); - memset( out, 0, pairs * stereo * sizeof *out ); - } - else if ( Ym2413_enabled( &this->ym2413 ) ) - { - Ym2413_begin_frame( &this->ym2413, out ); - } - - run( this, vgm_time ); - Ym2612_run_until( &this->ym2612, pairs ); - Ym2413_run_until( &this->ym2413, pairs ); - - this->fm_time_offset = (vgm_time * this->fm_time_factor + this->fm_time_offset) - (pairs << fm_time_bits); - - Sms_apu_end_frame( &this->psg, blip_time ); - - return pairs * stereo; -} - -// Update pre-1.10 header FM rates by scanning commands -void update_fm_rates( struct Vgm_Emu* this, int* ym2413_rate, int* ym2612_rate ) -{ - byte const* p = this->file_begin + 0x40; - while ( p < this->file_end ) - { - switch ( *p ) - { - case cmd_end: - return; - - case cmd_psg: - case cmd_byte_delay: - p += 2; - break; - - case cmd_delay: - p += 3; - break; - - case cmd_data_block: - p += 7 + get_le32( p + 3 ); - break; - - case cmd_ym2413: - *ym2612_rate = 0; - return; - - case cmd_ym2612_port0: - case cmd_ym2612_port1: - *ym2612_rate = *ym2413_rate; - *ym2413_rate = 0; - return; - - case cmd_ym2151: - *ym2413_rate = 0; - *ym2612_rate = 0; - return; - - default: - p += command_len( *p ); - } - } -} - - -// Music Emu - -blargg_err_t Vgm_set_sample_rate( struct Vgm_Emu* this, int rate ) -{ - require( !this->sample_rate ); // sample rate can't be changed once set - RETURN_ERR( Blip_set_sample_rate( &this->blip_buf, rate, 1000 / 30 ) ); - RETURN_ERR( Buffer_set_sample_rate( &this->stereo_buf, rate, 1000 / 20 ) ); - - // Set bass frequency - Buffer_bass_freq( &this->stereo_buf, 80 ); - - this->sample_rate = rate; - RETURN_ERR( track_init( &this->track_filter, this ) ); - this->tfilter.max_silence = 6 * stereo * this->sample_rate; - return 0; -} - -void Sound_mute_voice( struct Vgm_Emu* this, int index, bool mute ) -{ - require( (unsigned) index < (unsigned) this->voice_count ); - int bit = 1 << index; - int mask = this->mute_mask_ | bit; - if ( !mute ) - mask ^= bit; - Sound_mute_voices( this, mask ); -} - -void Sound_mute_voices( struct Vgm_Emu* this, int mask ) -{ - require( this->sample_rate ); // sample rate must be set first - this->mute_mask_ = mask; - - int i; - for ( i = this->voice_count; i--; ) - { - if ( mask & (1 << i) ) - { - set_voice( this, i, 0, 0, 0 ); - } - else - { - struct channel_t ch = Buffer_channel( &this->stereo_buf, i ); - assert( (ch.center && ch.left && ch.right) || - (!ch.center && !ch.left && !ch.right) ); // all or nothing - set_voice( this, i, ch.center, ch.left, ch.right ); - } - } - - // TODO: what was this for? - //core.pcm.output( &core.blip_buf ); - - // TODO: silence PCM if FM isn't used? - if ( uses_fm( this ) ) - { - for ( i = sms_osc_count; --i >= 0; ) - Sms_apu_set_output( &this->psg, i, ( mask & 0x80 ) ? 0 : &this->blip_buf, NULL, NULL ); - if ( Ym2612_enabled( &this->ym2612 ) ) - { - Synth_volume( &this->pcm, (mask & 0x40) ? 0 : (int)((long long)(0.1115*FP_ONE_VOLUME) / 256 * fm_gain * this->gain / FP_ONE_VOLUME) ); - Ym2612_mute_voices( &this->ym2612, mask ); - } - - if ( Ym2413_enabled( &this->ym2413 ) ) - { - int m = mask & 0x3F; - if ( mask & 0x20 ) - m |= 0x01E0; // channels 5-8 - if ( mask & 0x40 ) - m |= 0x3E00; - Ym2413_mute_voices( &this->ym2413, m ); - } - } -} - -void Sound_set_tempo( struct Vgm_Emu* this, int t ) -{ - require( this->sample_rate ); // sample rate must be set first - int const min = (int)(FP_ONE_TEMPO*0.02); - int const max = (int)(FP_ONE_TEMPO*4.00); - if ( t < min ) t = min; - if ( t > max ) t = max; - this->tempo = t; - - if ( this->file_begin ) - { - this->vgm_rate = (long) ((44100LL * t) / FP_ONE_TEMPO); - this->blip_time_factor = (int) (((1LL << blip_time_bits) * Blip_clock_rate( &this->blip_buf )) / this->vgm_rate); - //debug_printf( "blip_time_factor: %ld\n", blip_time_factor ); - //debug_printf( "vgm_rate: %ld\n", vgm_rate ); - // TODO: remove? calculates vgm_rate more accurately (above differs at most by one Hz only) - //blip_time_factor = (long) floor( double (1L << blip_time_bits) * psg_rate / 44100 / t + 0.5 ); - //vgm_rate = (long) floor( double (1L << blip_time_bits) * psg_rate / blip_time_factor + 0.5 ); - - this->fm_time_factor = 2 + (int) ((this->fm_rate * (1LL << fm_time_bits)) / this->vgm_rate); - } -} - -blargg_err_t Vgm_start_track( struct Vgm_Emu* this ) -{ - clear_track_vars( this ); - - Sms_apu_reset( &this->psg, get_le16( header( this )->noise_feedback ), header( this )->noise_width ); - - this->dac_disabled = -1; - this->pos = this->file_begin + header_size; - this->pcm_data = this->pos; - this->pcm_pos = this->pos; - this->dac_amp = -1; - this->vgm_time = 0; - if ( get_le32( header( this )->version ) >= 0x150 ) - { - int data_offset = get_le32( header( this )->data_offset ); - check( data_offset ); - if ( data_offset ) - this->pos += data_offset + offsetof (struct header_t,data_offset) - 0x40; - } - - if ( uses_fm( this ) ) - { - if ( Ym2413_enabled( &this->ym2413 ) ) - Ym2413_reset( &this->ym2413 ); - - if ( Ym2612_enabled( &this->ym2612 ) ) - Ym2612_reset( &this->ym2612 ); - - Blip_clear( &this->blip_buf ); - Resampler_clear( &this->resampler ); - } - - this->fm_time_offset = 0; - - Buffer_clear( &this->stereo_buf ); - - // convert filter times to samples - struct setup_t s = this->tfilter; - s.max_initial *= this->sample_rate * stereo; - #ifdef GME_DISABLE_SILENCE_LOOKAHEAD - s.lookahead = 1; - #endif - track_setup( &this->track_filter, &s ); - - return track_start( &this->track_filter ); -} - -// Tell/Seek - -static int msec_to_samples( int msec, int sample_rate ) -{ - int sec = msec / 1000; - msec -= sec * 1000; - return (sec * sample_rate + msec * sample_rate / 1000) * stereo; -} - -int Track_tell( struct Vgm_Emu* this ) -{ - int rate = this->sample_rate * stereo; - int sec = track_sample_count( &this->track_filter ) / rate; - return sec * 1000 + (track_sample_count( &this->track_filter ) - sec * rate) * 1000 / rate; -} - -blargg_err_t Track_seek( struct Vgm_Emu* this, int msec ) -{ - int time = msec_to_samples( msec, this->sample_rate ); - if ( time < track_sample_count( &this->track_filter ) ) - RETURN_ERR( Vgm_start_track( this ) ); - return Track_skip( this, time - track_sample_count( &this->track_filter ) ); -} - -blargg_err_t Track_skip( struct Vgm_Emu* this, int count ) -{ - require( this->current_track >= 0 ); // start_track() must have been called already - return track_skip( &this->track_filter, count ); -} - -blargg_err_t skip_( void* emu, int count ) -{ - struct Vgm_Emu* this = (struct Vgm_Emu*) emu; - - // for long skip, mute sound - const int threshold = 32768; - if ( count > threshold ) - { - int saved_mute = this->mute_mask_; - Sound_mute_voices( this, ~0 ); - - int n = count - threshold/2; - n &= ~(2048-1); // round to multiple of 2048 - count -= n; - RETURN_ERR( skippy_( &this->track_filter, n ) ); - - Sound_mute_voices( this, saved_mute ); - } - - return skippy_( &this->track_filter, count ); -} - -// Fading - -void Track_set_fade( struct Vgm_Emu* this, int start_msec, int length_msec ) -{ - track_set_fade( &this->track_filter, msec_to_samples( start_msec, this->sample_rate ), - length_msec * this->sample_rate / (1000 / stereo) ); -} - -blargg_err_t Vgm_play( struct Vgm_Emu* this, int out_count, sample_t* out ) -{ - require( this->current_track >= 0 ); - require( out_count % stereo == 0 ); - return track_play( &this->track_filter, out_count, out ); -} diff --git a/apps/codecs/libgme/vgm_emu.h b/apps/codecs/libgme/vgm_emu.h deleted file mode 100644 index 8c39482008..0000000000 --- a/apps/codecs/libgme/vgm_emu.h +++ /dev/null @@ -1,206 +0,0 @@ -// Sega Master System/Mark III, Sega Genesis/Mega Drive, BBC Micro VGM music file emulator - -// Game_Music_Emu 0.6-pre -#ifndef VGM_EMU_H -#define VGM_EMU_H - -#include "blargg_common.h" -#include "blargg_source.h" - -#include "track_filter.h" -#include "resampler.h" -#include "multi_buffer.h" -#include "ym2413_emu.h" -#include "ym2612_emu.h" -#include "sms_apu.h" - -typedef int vgm_time_t; -typedef int fm_time_t; - -enum { fm_time_bits = 12 }; -enum { blip_time_bits = 12 }; - -// VGM header format -enum { header_size = 0x40 }; -struct header_t -{ - char tag [4]; - byte data_size [4]; - byte version [4]; - byte psg_rate [4]; - byte ym2413_rate [4]; - byte gd3_offset [4]; - byte track_duration [4]; - byte loop_offset [4]; - byte loop_duration [4]; - byte frame_rate [4]; - byte noise_feedback [2]; - byte noise_width; - byte unused1; - byte ym2612_rate [4]; - byte ym2151_rate [4]; - byte data_offset [4]; - byte unused2 [8]; -}; - -enum { gme_max_field = 63 }; -struct track_info_t -{ - /* times in milliseconds; -1 if unknown */ - int length; - int intro_length; - int loop_length; - - /* empty string if not available */ - char game [64]; - char song [96]; - char author [64]; -}; - -// Emulates VGM music using SN76489/SN76496 PSG, YM2612, and YM2413 FM sound chips. -// Supports custom sound buffer and frequency equalization when VGM uses just the PSG. -// FM sound chips can be run at their proper rates, or slightly higher to reduce -// aliasing on high notes. Currently YM2413 support requires that you supply a -// YM2413 sound chip emulator. I can provide one I've modified to work with the library. -struct Vgm_Emu { - int fm_rate; - int psg_rate; - int vgm_rate; - bool disable_oversampling; - - int fm_time_offset; - int fm_time_factor; - - int blip_time_factor; - - byte const* file_begin; - byte const* file_end; - - vgm_time_t vgm_time; - byte const* loop_begin; - byte const* pos; - - byte const* pcm_data; - byte const* pcm_pos; - int dac_amp; - int dac_disabled; // -1 if disabled - - // general - int current_track; - int clock_rate_; - unsigned buf_changed_count; - int max_initial_silence; - int voice_count; - int const *voice_types; - int mute_mask_; - int tempo; - int gain; - - int sample_rate; - - // larger items at the end - struct track_info_t info; - - struct setup_t tfilter; - struct Track_Filter track_filter; - - struct Ym2612_Emu ym2612; - struct Ym2413_Emu ym2413; - - struct Sms_Apu psg; - struct Blip_Synth pcm; - struct Blip_Buffer blip_buf; - - struct Resampler resampler; - struct Multi_Buffer stereo_buf; -}; - -void Vgm_init( struct Vgm_Emu* this ); - -// Disable running FM chips at higher than normal rate. Will result in slightly -// more aliasing of high notes. -static inline void Vgm_disable_oversampling( struct Vgm_Emu* this, bool disable ) { this->disable_oversampling = disable; } - -// Header for currently loaded file -static inline struct header_t *header( struct Vgm_Emu* this ) { return (struct header_t*) this->file_begin; } - -// Basic functionality (see Gme_File.h for file loading/track info functions) -blargg_err_t Vgm_load_mem( struct Vgm_Emu* this, byte const* new_data, long new_size, bool parse_info ); - -// True if any FM chips are used by file. Always false until init_fm() -// is called. -static inline bool uses_fm( struct Vgm_Emu* this ) { return Ym2612_enabled( &this->ym2612 ) || Ym2413_enabled( &this->ym2413 ); } - -// Set output sample rate. Must be called only once before loading file. -blargg_err_t Vgm_set_sample_rate( struct Vgm_Emu* this, int sample_rate ); - -// Start a track, where 0 is the first track. Also clears warning string. -blargg_err_t Vgm_start_track( struct Vgm_Emu* this ); - -// Generate 'count' samples info 'buf'. Output is in stereo. Any emulation -// errors set warning string, and major errors also end track. -blargg_err_t Vgm_play( struct Vgm_Emu* this, int count, sample_t* buf ); - -// Track status/control - -// Number of milliseconds (1000 msec = 1 second) played since beginning of track -int Track_tell( struct Vgm_Emu* this ); - -// Seek to new time in track. Seeking backwards or far forward can take a while. -blargg_err_t Track_seek( struct Vgm_Emu* this, int msec ); - -// Skip n samples -blargg_err_t Track_skip( struct Vgm_Emu* this, int n ); - -// Set start time and length of track fade out. Once fade ends track_ended() returns -// true. Fade time can be changed while track is playing. -void Track_set_fade( struct Vgm_Emu* this, int start_msec, int length_msec ); - -// True if a track has reached its end -static inline bool Track_ended( struct Vgm_Emu* this ) -{ - return track_ended( &this->track_filter ); -} - -// Disables automatic end-of-track detection and skipping of silence at beginning -static inline void Track_ignore_silence( struct Vgm_Emu* this, bool disable ) -{ - this->track_filter.silence_ignored_ = disable; -} - -// Get track length in milliseconds -static inline int Track_get_length( struct Vgm_Emu* this ) -{ - int length = this->info.length; - if ( length <= 0 ) - { - length = this->info.intro_length + 2 * this->info.loop_length; // intro + 2 loops - if ( length <= 0 ) - length = 150 * 1000; // 2.5 minutes - } - - return length; -} - -// Sound customization - -// Adjust song tempo, where 1.0 = normal, 0.5 = half speed, 2.0 = double speed. -// Track length as returned by track_info() assumes a tempo of 1.0. -void Sound_set_tempo( struct Vgm_Emu* this, int t ); - -// Mute/unmute voice i, where voice 0 is first voice -void Sound_mute_voice( struct Vgm_Emu* this, int index, bool mute ); - -// Set muting state of all voices at once using a bit mask, where -1 mutes them all, -// 0 unmutes them all, 0x01 mutes just the first voice, etc. -void Sound_mute_voices( struct Vgm_Emu* this, int mask ); - -// Change overall output amplitude, where 1.0 results in minimal clamping. -// Must be called before set_sample_rate(). -static inline void Sound_set_gain( struct Vgm_Emu* this, int g ) -{ - assert( !this->sample_rate ); // you must set gain before setting sample rate - this->gain = g; -} - -#endif diff --git a/apps/codecs/libgme/vrc7tone.h b/apps/codecs/libgme/vrc7tone.h deleted file mode 100644 index c589335c3c..0000000000 --- a/apps/codecs/libgme/vrc7tone.h +++ /dev/null @@ -1,20 +0,0 @@ -/* VRC7 TONES by okazaki@angel.ne.jp */ -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x33,0x01,0x09,0x0e,0x94,0x90,0x40,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x13,0x41,0x0f,0x0d,0xce,0xd3,0x43,0x13,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x01,0x12,0x1b,0x06,0xff,0xd2,0x00,0x32,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x61,0x61,0x1b,0x07,0xaf,0x63,0x20,0x28,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x22,0x21,0x1e,0x06,0xf0,0x76,0x08,0x28,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x66,0x21,0x15,0x00,0x93,0x94,0x20,0xf8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x21,0x61,0x1c,0x07,0x82,0x81,0x10,0x17,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x23,0x21,0x20,0x1f,0xc0,0x71,0x07,0x47,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x25,0x31,0x26,0x05,0x64,0x41,0x18,0xf8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x17,0x21,0x28,0x07,0xff,0x83,0x02,0xf8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x97,0x81,0x25,0x07,0xcf,0xc8,0x02,0x14,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x21,0x21,0x54,0x0f,0x80,0x7f,0x07,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x01,0x01,0x56,0x03,0xd3,0xb2,0x43,0x58,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x31,0x21,0x0c,0x03,0x82,0xc0,0x40,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x21,0x01,0x0c,0x03,0xd4,0xd3,0x40,0x84,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x07,0x21,0x14,0x00,0xee,0xf8,0xff,0xf8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x01,0x31,0x00,0x00,0xf8,0xf7,0xf8,0xf7,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x25,0x11,0x00,0x00,0xf8,0xfa,0xf8,0x55,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 diff --git a/apps/codecs/libgme/ym2413_emu.c b/apps/codecs/libgme/ym2413_emu.c deleted file mode 100644 index d9ada431ca..0000000000 --- a/apps/codecs/libgme/ym2413_emu.c +++ /dev/null @@ -1,45 +0,0 @@ -// Game_Music_Emu 0.5.5. http://www.slack.net/~ant/ - -#include "ym2413_emu.h" - -void Ym2413_init( struct Ym2413_Emu* this ) -{ - this->last_time = disabled_time; this->out = 0; -} - -int Ym2413_set_rate( struct Ym2413_Emu* this, int sample_rate, int clock_rate ) -{ - OPLL_new ( &this->opll, clock_rate, sample_rate ); - OPLL_reset_patch( &this->opll, OPLL_2413_TONE ); - - Ym2413_reset( this ); - return 0; -} - -void Ym2413_reset( struct Ym2413_Emu* this ) -{ - OPLL_reset( &this->opll ); - OPLL_setMask( &this->opll, 0 ); -} - -void Ym2413_write( struct Ym2413_Emu* this, int addr, int data ) -{ - OPLL_writeIO( &this->opll, 0, addr ); - OPLL_writeIO( &this->opll, 1, data ); -} - -void Ym2413_mute_voices( struct Ym2413_Emu* this, int mask ) -{ - OPLL_setMask( &this->opll, mask ); -} - -void Ym2413_run( struct Ym2413_Emu* this, int pair_count, short* out ) -{ - while ( pair_count-- ) - { - int s = OPLL_calc( &this->opll ) << 1; - out [0] = s; - out [1] = s; - out += 2; - } -} diff --git a/apps/codecs/libgme/ym2413_emu.h b/apps/codecs/libgme/ym2413_emu.h deleted file mode 100644 index 8f52b04fbd..0000000000 --- a/apps/codecs/libgme/ym2413_emu.h +++ /dev/null @@ -1,61 +0,0 @@ -// YM2413 FM sound chip emulator interface - -// Game_Music_Emu 0.6-pre -#ifndef YM2413_EMU_H -#define YM2413_EMU_H - -#include "blargg_common.h" -#include "emu2413.h" - -enum { out_chan_count = 2 }; // stereo -enum { channel_count = 14 }; -enum { disabled_time = -1 }; - -struct Ym2413_Emu { - OPLL opll; - - // Impl - int last_time; - short* out; -}; - -void Ym2413_init( struct Ym2413_Emu* this ); - -static inline bool Ym2413_supported( void ) { return true; } - -// Sets output sample rate and chip clock rates, in Hz. Returns non-zero -// if error. -int Ym2413_set_rate( struct Ym2413_Emu* this, int sample_rate, int clock_rate ); - -// Resets to power-up state -void Ym2413_reset( struct Ym2413_Emu* this ); - -// Mutes voice n if bit n (1 << n) of mask is set -void Ym2413_mute_voices( struct Ym2413_Emu* this, int mask ); - -// Writes data to addr -void Ym2413_write( struct Ym2413_Emu* this, int addr, int data ); - -// Runs and writes pair_count*2 samples to output -void Ym2413_run( struct Ym2413_Emu* this, int pair_count, short* out ); - -static inline void Ym2413_enable( struct Ym2413_Emu* this, bool b ) { this->last_time = b ? 0 : disabled_time; } -static inline bool Ym2413_enabled( struct Ym2413_Emu* this ) { return this->last_time != disabled_time; } -static inline void Ym2413_begin_frame( struct Ym2413_Emu* this, short* buf ) { this->out = buf; this->last_time = 0; } - -static inline int Ym2413_run_until( struct Ym2413_Emu* this, int time ) -{ - int count = time - this->last_time; - if ( count > 0 ) - { - if ( this->last_time < 0 ) - return false; - this->last_time = time; - short* p = this->out; - this->out += count * out_chan_count; - Ym2413_run( this, count, p ); - } - return true; -} - -#endif diff --git a/apps/codecs/libgme/ym2612_emu.c b/apps/codecs/libgme/ym2612_emu.c deleted file mode 100644 index 60df30a33c..0000000000 --- a/apps/codecs/libgme/ym2612_emu.c +++ /dev/null @@ -1,1374 +0,0 @@ -// Game_Music_Emu $vers. http://www.slack.net/~ant/ - -// Based on Gens 2.10 ym2612.c - -#include -#include -#include -#include -#include - -#include "ym2612_emu.h" - -/* Copyright (C) 2002 Stéphane Dallongeville (gens AT consolemul.com) */ -/* Copyright (C) 2004-2007 Shay Green. This module is free software; you -can redistribute it and/or modify it under the terms of the GNU Lesser -General Public License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. This -module is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more -details. You should have received a copy of the GNU Lesser General Public -License along with this module; if not, write to the Free Software Foundation, -Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ - -// This is mostly the original source in its C style and all. -// -// Somewhat optimized and simplified. Uses a template to generate the many -// variants of Update_Chan. Rewrote header file. In need of full rewrite by -// someone more familiar with FM sound and the YM2612. Has some inaccuracies -// compared to the Sega Genesis sound, particularly being mixed at such a -// high sample accuracy (the Genesis sounds like it has only 8 bit samples). -// - Shay - -// Ported again to c by gama. -// Not sure if performance is better than the original c version. - -#if !defined(YM2612_CALCUL_TABLES) - #include "ymtables.h" -#endif - -#ifdef YM2612_CALCUL_TABLES - #define FREQ_TAB_LOOKUP g->LFO_FREQ_TAB - #define ENV_TAB_LOOKUP g->LFO_ENV_TAB -#else - #define FREQ_TAB_LOOKUP lfo_freq_coeff - #define ENV_TAB_LOOKUP lfo_env_coeff -#endif - -const int output_bits = 14; - -static const unsigned char DT_DEF_TAB [4 * 32] = -{ -// FD = 0 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - -// FD = 1 - 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, - 2, 3, 3, 3, 4, 4, 4, 5, 5, 6, 6, 7, 8, 8, 8, 8, - -// FD = 2 - 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, - 5, 6, 6, 7, 8, 8, 9, 10, 11, 12, 13, 14, 16, 16, 16, 16, - -// FD = 3 - 2, 2, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 6, 6, 7, - 8 , 8, 9, 10, 11, 12, 13, 14, 16, 17, 19, 20, 22, 22, 22, 22 -}; - -static const unsigned char FKEY_TAB [16] = -{ - 0, 0, 0, 0, - 0, 0, 0, 1, - 2, 3, 3, 3, - 3, 3, 3, 3 -}; - -static const unsigned char LFO_AMS_TAB [4] = -{ - 31, 4, 1, 0 -}; - -static const unsigned char LFO_FMS_TAB [8] = -{ - LFO_FMS_BASE * 0, LFO_FMS_BASE * 1, - LFO_FMS_BASE * 2, LFO_FMS_BASE * 3, - LFO_FMS_BASE * 4, LFO_FMS_BASE * 6, - LFO_FMS_BASE * 12, LFO_FMS_BASE * 24 -}; - -int in0, in1, in2, in3; // current phase calculation -// int en0, en1, en2, en3; // current enveloppe calculation - -static inline void set_seg( struct slot_t* s, int seg ) -{ - s->env_xor = 0; - s->env_max = INT_MAX; - s->SEG = seg; - if ( seg & 4 ) - { - s->env_xor = ENV_MASK; - s->env_max = ENV_MASK; - } -} - -static inline void YM2612_Special_Update(void) { } - -static void KEY_ON( struct channel_* ch, struct tables_t *g, int nsl ) -{ - struct slot_t *SL = &(ch->SLOT [nsl]); // on recupere le bon pointeur de slot - - if (SL->Ecurp == RELEASE) // la touche est-elle rel'chee ? - { - SL->Fcnt = 0; - - // Fix Ecco 2 splash sound - - SL->Ecnt = (g->DECAY_TO_ATTACK [g->ENV_TAB [SL->Ecnt >> ENV_LBITS]] + ENV_ATTACK) & SL->ChgEnM; - SL->ChgEnM = ~0; - -// SL->Ecnt = g.DECAY_TO_ATTACK [g.ENV_TAB [SL->Ecnt >> ENV_LBITS]] + ENV_ATTACK; -// SL->Ecnt = 0; - - SL->Einc = SL->EincA; - SL->Ecmp = ENV_DECAY; - SL->Ecurp = ATTACK; - } -} - - -static void KEY_OFF( struct channel_* ch, struct tables_t *g, int nsl ) -{ - struct slot_t *SL = &(ch->SLOT [nsl]); // on recupere le bon pointeur de slot - - if (SL->Ecurp != RELEASE) // la touche est-elle appuyee ? - { - if (SL->Ecnt < ENV_DECAY) // attack phase ? - { - SL->Ecnt = (g->ENV_TAB [SL->Ecnt >> ENV_LBITS] << ENV_LBITS) + ENV_DECAY; - } - - SL->Einc = SL->EincR; - SL->Ecmp = ENV_END; - SL->Ecurp = RELEASE; - } -} - - -static int SLOT_SET( struct Ym2612_Impl* impl, int Adr, int data ) -{ - int nch = Adr & 3; - if ( nch == 3 ) - return 1; - - struct tables_t *g = &impl->g; - struct state_t *YM2612 = &impl->YM2612; - struct channel_* ch = &YM2612->CHANNEL [nch + (Adr & 0x100 ? 3 : 0)]; - struct slot_t* sl = &ch->SLOT [(Adr >> 2) & 3]; - - switch ( Adr & 0xF0 ) - { - case 0x30: - if ( (sl->MUL = (data & 0x0F)) != 0 ) sl->MUL <<= 1; - else sl->MUL = 1; - - sl->DT = (int*) g->DT_TAB [(data >> 4) & 7]; - - ch->SLOT [0].Finc = -1; - - break; - - case 0x40: - sl->TL = data & 0x7F; - - // SOR2 do a lot of TL adjustement and this fix R.Shinobi jump sound... - YM2612_Special_Update(); - -#if ((ENV_HBITS - 7) < 0) - sl->TLL = sl->TL >> (7 - ENV_HBITS); -#else - sl->TLL = sl->TL << (ENV_HBITS - 7); -#endif - - break; - - case 0x50: - sl->KSR_S = 3 - (data >> 6); - - ch->SLOT [0].Finc = -1; - - if (data &= 0x1F) sl->AR = (int*) &g->AR_TAB [data << 1]; - else sl->AR = (int*) &g->NULL_RATE [0]; - - sl->EincA = sl->AR [sl->KSR]; - if (sl->Ecurp == ATTACK) sl->Einc = sl->EincA; - break; - - case 0x60: - if ( (sl->AMSon = (data & 0x80)) != 0 ) sl->AMS = ch->AMS; - else sl->AMS = 31; - - if (data &= 0x1F) sl->DR = (int*) &g->DR_TAB [data << 1]; - else sl->DR = (int*) &g->NULL_RATE [0]; - - sl->EincD = sl->DR [sl->KSR]; - if (sl->Ecurp == DECAY) sl->Einc = sl->EincD; - break; - - case 0x70: - if (data &= 0x1F) sl->SR = (int*) &g->DR_TAB [data << 1]; - else sl->SR = (int*) &g->NULL_RATE [0]; - - sl->EincS = sl->SR [sl->KSR]; - if ((sl->Ecurp == SUBSTAIN) && (sl->Ecnt < ENV_END)) sl->Einc = sl->EincS; - break; - - case 0x80: - sl->SLL = g->SL_TAB [data >> 4]; - - sl->RR = (int*) &g->DR_TAB [((data & 0xF) << 2) + 2]; - - sl->EincR = sl->RR [sl->KSR]; - if ((sl->Ecurp == RELEASE) && (sl->Ecnt < ENV_END)) sl->Einc = sl->EincR; - break; - - case 0x90: - // SSG-EG envelope shapes : - /* - E At Al H - - 1 0 0 0 \\\\ - 1 0 0 1 \___ - 1 0 1 0 \/\/ - 1 0 1 1 \ - 1 1 0 0 //// - 1 1 0 1 / - 1 1 1 0 /\/\ - 1 1 1 1 /___ - - E = SSG-EG enable - At = Start negate - Al = Altern - H = Hold */ - - set_seg( sl, (data & 8) ? (data & 0x0F) : 0 ); - break; - } - - return 0; -} - - -static int CHANNEL_SET( struct state_t* YM2612, int Adr, int data ) -{ - int num = Adr & 3; - if ( num == 3 ) - return 1; - - struct channel_* ch = &YM2612->CHANNEL [num + (Adr & 0x100 ? 3 : 0)]; - - switch ( Adr & 0xFC ) - { - case 0xA0: - YM2612_Special_Update(); - - ch->FNUM [0] = (ch->FNUM [0] & 0x700) + data; - ch->KC [0] = (ch->FOCT [0] << 2) | FKEY_TAB [ch->FNUM [0] >> 7]; - - ch->SLOT [0].Finc = -1; - break; - - case 0xA4: - YM2612_Special_Update(); - - ch->FNUM [0] = (ch->FNUM [0] & 0x0FF) + ((data & 0x07) << 8); - ch->FOCT [0] = (data & 0x38) >> 3; - ch->KC [0] = (ch->FOCT [0] << 2) | FKEY_TAB [ch->FNUM [0] >> 7]; - - ch->SLOT [0].Finc = -1; - break; - - case 0xA8: - if ( Adr < 0x100 ) - { - num++; - - YM2612_Special_Update(); - - YM2612->CHANNEL [2].FNUM [num] = (YM2612->CHANNEL [2].FNUM [num] & 0x700) + data; - YM2612->CHANNEL [2].KC [num] = (YM2612->CHANNEL [2].FOCT [num] << 2) | - FKEY_TAB [YM2612->CHANNEL [2].FNUM [num] >> 7]; - - YM2612->CHANNEL [2].SLOT [0].Finc = -1; - } - break; - - case 0xAC: - if ( Adr < 0x100 ) - { - num++; - - YM2612_Special_Update(); - - YM2612->CHANNEL [2].FNUM [num] = (YM2612->CHANNEL [2].FNUM [num] & 0x0FF) + ((data & 0x07) << 8); - YM2612->CHANNEL [2].FOCT [num] = (data & 0x38) >> 3; - YM2612->CHANNEL [2].KC [num] = (YM2612->CHANNEL [2].FOCT [num] << 2) | - FKEY_TAB [YM2612->CHANNEL [2].FNUM [num] >> 7]; - - YM2612->CHANNEL [2].SLOT [0].Finc = -1; - } - break; - - case 0xB0: - if ( ch->ALGO != (data & 7) ) - { - // Fix VectorMan 2 heli sound (level 1) - YM2612_Special_Update(); - - ch->ALGO = data & 7; - - ch->SLOT [0].ChgEnM = 0; - ch->SLOT [1].ChgEnM = 0; - ch->SLOT [2].ChgEnM = 0; - ch->SLOT [3].ChgEnM = 0; - } - - ch->FB = 9 - ((data >> 3) & 7); // Real thing ? - -// if (ch->FB = ((data >> 3) & 7)) ch->FB = 9 - ch->FB; // Thunder force 4 (music stage 8), Gynoug, Aladdin bug sound... -// else ch->FB = 31; - break; - - case 0xB4: { - YM2612_Special_Update(); - - ch->LEFT = 0 - ((data >> 7) & 1); - ch->RIGHT = 0 - ((data >> 6) & 1); - - ch->AMS = LFO_AMS_TAB [(data >> 4) & 3]; - ch->FMS = LFO_FMS_TAB [data & 7]; - - int i; - for ( i = 0; i < 4; i++ ) - { - struct slot_t* sl = &ch->SLOT [i]; - sl->AMS = (sl->AMSon ? ch->AMS : 31); - } - break; - } - } - - return 0; -} - - -static int YM_SET( struct Ym2612_Impl* impl, int Adr, int data ) -{ - struct state_t* YM2612 = &impl->YM2612; - struct tables_t* g = &impl->g; - switch ( Adr ) - { - case 0x22: - if (data & 8) // LFO enable - { - // Cool Spot music 1, LFO modified severals time which - // distord the sound, have to check that on a real genesis... - - g->LFOinc = g->LFO_INC_TAB [data & 7]; - } - else - { - g->LFOinc = g->LFOcnt = 0; - } - break; - - case 0x24: - YM2612->TimerA = (YM2612->TimerA & 0x003) | (((int) data) << 2); - - if (YM2612->TimerAL != (1024 - YM2612->TimerA) << 12) - { - YM2612->TimerAcnt = YM2612->TimerAL = (1024 - YM2612->TimerA) << 12; - } - break; - - case 0x25: - YM2612->TimerA = (YM2612->TimerA & 0x3FC) | (data & 3); - - if (YM2612->TimerAL != (1024 - YM2612->TimerA) << 12) - { - YM2612->TimerAcnt = YM2612->TimerAL = (1024 - YM2612->TimerA) << 12; - } - break; - - case 0x26: - YM2612->TimerB = data; - - if (YM2612->TimerBL != (256 - YM2612->TimerB) << (4 + 12)) - { - YM2612->TimerBcnt = YM2612->TimerBL = (256 - YM2612->TimerB) << (4 + 12); - } - break; - - case 0x27: - // Parametre divers - // b7 = CSM MODE - // b6 = 3 slot mode - // b5 = reset b - // b4 = reset a - // b3 = timer enable b - // b2 = timer enable a - // b1 = load b - // b0 = load a - - if ((data ^ YM2612->Mode) & 0x40) - { - // We changed the channel 2 mode, so recalculate phase step - // This fix the punch sound in Street of Rage 2 - - YM2612_Special_Update(); - - YM2612->CHANNEL [2].SLOT [0].Finc = -1; // recalculate phase step - } - -// if ((data & 2) && (YM2612->Status & 2)) YM2612->TimerBcnt = YM2612->TimerBL; -// if ((data & 1) && (YM2612->Status & 1)) YM2612->TimerAcnt = YM2612->TimerAL; - -// YM2612->Status &= (~data >> 4); // Reset du Status au cas ou c'est demande - YM2612->Status &= (~data >> 4) & (data >> 2); // Reset Status - - YM2612->Mode = data; - break; - - case 0x28: { - int nch = data & 3; - if ( nch == 3 ) - return 1; - if ( data & 4 ) - nch += 3; - struct channel_* ch = &YM2612->CHANNEL [nch]; - - YM2612_Special_Update(); - - if (data & 0x10) KEY_ON(ch, g, S0); // On appuie sur la touche pour le slot 1 - else KEY_OFF(ch, g, S0); // On rel'che la touche pour le slot 1 - if (data & 0x20) KEY_ON(ch, g, S1); // On appuie sur la touche pour le slot 3 - else KEY_OFF(ch, g, S1); // On rel'che la touche pour le slot 3 - if (data & 0x40) KEY_ON(ch, g, S2); // On appuie sur la touche pour le slot 2 - else KEY_OFF(ch, g, S2); // On rel'che la touche pour le slot 2 - if (data & 0x80) KEY_ON(ch, g, S3); // On appuie sur la touche pour le slot 4 - else KEY_OFF(ch, g, S3); // On rel'che la touche pour le slot 4 - break; - } - - case 0x2B: - if (YM2612->DAC ^ (data & 0x80)) YM2612_Special_Update(); - - YM2612->DAC = data & 0x80; // activation/desactivation du DAC - break; - } - - return 0; -} - -void impl_reset( struct Ym2612_Impl* impl ); -static void impl_set_rate( struct Ym2612_Impl* impl, int sample_rate, int clock_rate ) -{ - assert( sample_rate ); - assert( !clock_rate || clock_rate > sample_rate ); - - int i; - - // 144 = 12 * (prescale * 2) = 12 * 6 * 2 - // prescale set to 6 by default - - int Frequency = (clock_rate ? (int)((FP_ONE_CLOCK * clock_rate) / sample_rate / 144) : (int)FP_ONE_CLOCK); - if ( abs( Frequency - FP_ONE_CLOCK ) < 1 ) - Frequency = FP_ONE_CLOCK; - impl->YM2612.TimerBase = Frequency; - - /* double Frequence = (double)Frequency / FP_ONE_CLOCK; */ - - // Tableau TL : - // [0 - 4095] = +output [4095 - ...] = +output overflow (fill with 0) - // [12288 - 16383] = -output [16384 - ...] = -output overflow (fill with 0) - -#ifdef YM2612_USE_TL_TAB - for ( i = 0; i < TL_LENGHT; i++ ) - { - if (i >= PG_CUT_OFF) // YM2612 cut off sound after 78 dB (14 bits output ?) - { - impl->g.TL_TAB [TL_LENGHT + i] = impl->g.TL_TAB [i] = 0; - } - else - { - // Decibel -> Voltage - #ifdef YM2612_CALCUL_TABLES - impl->g.TL_TAB [i] = (int) (MAX_OUT / pow( 10.0, ENV_STEP / 20.0f * i )); - #else - impl->g.TL_TAB [i] = tl_coeff [i]; - #endif - impl->g.TL_TAB [TL_LENGHT + i] = -impl->g.TL_TAB [i]; - } - } -#endif - - // Tableau SIN : - // impl->g.SIN_TAB [x] [y] = sin(x) * y; - // x = phase and y = volume - - impl->g.SIN_TAB [0] = impl->g.SIN_TAB [SIN_LENGHT / 2] = PG_CUT_OFF; - - for ( i = 1; i <= SIN_LENGHT / 4; i++ ) - { - // Sinus in dB - #ifdef YM2612_CALCUL_TABLES - double x = 20 * log10( 1 / sin( 2.0 * PI * i / SIN_LENGHT ) ); // convert to dB - - int j = (int) (x / ENV_STEP); // Get TL range - - if (j > PG_CUT_OFF) j = (int) PG_CUT_OFF; - #else - int j = sindb_coeff [i-1]; - #endif - - impl->g.SIN_TAB [i] = impl->g.SIN_TAB [(SIN_LENGHT / 2) - i] = j; - impl->g.SIN_TAB [(SIN_LENGHT / 2) + i] = impl->g.SIN_TAB [SIN_LENGHT - i] = TL_LENGHT + j; - } - - #ifdef YM2612_CALCUL_TABLES - // Tableau LFO (LFO wav) : - for ( i = 0; i < LFO_LENGHT; i++ ) - { - double x = 1 + sin( 2.0 * PI * i * (1.0 / LFO_LENGHT) ); // Sinus - x *= 11.8 / ENV_STEP / 2; // ajusted to MAX enveloppe modulation - - impl->g.LFO_ENV_TAB [i] = (int) x; - - x = sin( 2.0 * PI * i * (1.0 / LFO_LENGHT) ); // Sinus - x *= (1 << (LFO_HBITS - 1)) - 1; - - impl->g.LFO_FREQ_TAB [i] = (int) x; - } - #endif - - // Tableau Enveloppe : - // impl->g.ENV_TAB [0] -> impl->g.ENV_TAB [ENV_LENGHT - 1] = attack curve - // impl->g.ENV_TAB [ENV_LENGHT] -> impl->g.ENV_TAB [2 * ENV_LENGHT - 1] = decay curve - - for ( i = 0; i < ENV_LENGHT; i++ ) - { - // Attack curve (x^8 - music level 2 Vectorman 2) - #if defined(ROCKBOX) - int k; - int prescale = (31 - 2*ENV_HBITS); /* used to gain higher precision */ - int x = ENV_LENGHT * (1 << prescale); - for ( k = 0; k < 8; ++k) - { - x = ( x * ((ENV_LENGHT - 1) - i) ) / ENV_LENGHT; - } - x >>= prescale; - #else - double x = pow( ((ENV_LENGHT - 1) - i) / (double) ENV_LENGHT, 8.0 ); - x *= ENV_LENGHT; - #endif - - impl->g.ENV_TAB [i] = (int) x; - - // Decay curve (just linear) - impl->g.ENV_TAB [ENV_LENGHT + i] = i; - } - for ( i = 0; i < 8; i++ ) - impl->g.ENV_TAB [i + ENV_LENGHT * 2] = 0; - - impl->g.ENV_TAB [ENV_END >> ENV_LBITS] = ENV_LENGHT - 1; // for the stopped state - - // Tableau pour la conversion Attack -> Decay and Decay -> Attack - - int j = ENV_LENGHT - 1; - for ( i = 0; i < ENV_LENGHT; i++ ) - { - while ( j && impl->g.ENV_TAB [j] < i ) - j--; - - impl->g.DECAY_TO_ATTACK [i] = j << ENV_LBITS; - } - - // Tableau pour le Substain Level - - for ( i = 0; i < 15; i++ ) - { - int x = i * 3 * (int)( (1 << ENV_LBITS) / ENV_STEP); // 3 and not 6 (Mickey Mania first music for test) - - impl->g.SL_TAB [i] = x + ENV_DECAY; - } - - impl->g.SL_TAB [15] = ((ENV_LENGHT - 1) << ENV_LBITS) + ENV_DECAY; // special case : volume off - - // Tableau Frequency Step - - { - // * 1 / 2 because MUL = value * 2 - #if SIN_LBITS + SIN_HBITS - (21 - 7) < 0 - /* double const factor = Frequence / 2.0 / (1 << ((21 - 7) - SIN_LBITS - SIN_HBITS)); */ - int const factor = (int)(Frequency / 2 / (1 << ((21 - 7) - SIN_LBITS - SIN_HBITS)) / FP_ONE_CLOCK); - #else - /* double const factor = Frequence / 2.0 * (1 << (SIN_LBITS + SIN_HBITS - (21 - 7))); */ - int const factor = (int)(Frequency / 2 * (1 << (SIN_LBITS + SIN_HBITS - (21 - 7))) / FP_ONE_CLOCK); - #endif - for ( i = 0; i < 2048; i++ ) - { - impl->g.FINC_TAB [i] = i * factor; - } - } - - // Tableaux Attack & Decay Rate - - for ( i = 0; i < 4; i++ ) - { - impl->g.AR_TAB [i] = 0; - impl->g.DR_TAB [i] = 0; - } - - for ( i = 0; i < 60; i++ ) - { - long long x = - (4LL + ((i & 3))) * // bits 0-1 : 4*(x1.00, x1.25, x1.50, x1.75) - (ENV_LENGHT << ENV_LBITS) * // on ajuste pour le tableau impl->g.ENV_TAB - Frequency * - (1 << (i >> 2)) / // bits 2-5 : shift bits (x2^0 - x2^15) - FP_ONE_CLOCK / 4; - - long long x_AR = x / AR_RATE; - long long x_DR = x / DR_RATE; - - impl->g.AR_TAB [i + 4] = (unsigned int) ( x_AR > ((1LL<<32) - 1) ? ((1LL<<32) - 1) : x_AR ); - impl->g.DR_TAB [i + 4] = (unsigned int) ( x_DR > ((1LL<<32) - 1) ? ((1LL<<32) - 1) : x_DR ); - } - - for ( i = 64; i < 96; i++ ) - { - impl->g.AR_TAB [i] = impl->g.AR_TAB [63]; - impl->g.DR_TAB [i] = impl->g.DR_TAB [63]; - - impl->g.NULL_RATE [i - 64] = 0; - } - - for ( i = 96; i < 128; i++ ) - impl->g.AR_TAB [i] = 0; - - // Tableau Detune - { - #if SIN_LBITS + SIN_HBITS - 21 < 0 - /* double const factor = 1.0 / (1 << (21 - SIN_LBITS - SIN_HBITS)) * Frequence; */ - int const factor = Frequency / (1 << (21 - SIN_LBITS - SIN_HBITS)) / FP_ONE_CLOCK; - #else - /* double const factor = (1 << (SIN_LBITS + SIN_HBITS - 21)) * Frequence; */ - int const factor = Frequency * (1 << (SIN_LBITS + SIN_HBITS - 21)) / FP_ONE_CLOCK; - #endif - for ( i = 0; i < 4; i++ ) - { - int j; - for ( j = 0; j < 32; j++ ) - { - /* double y = DT_DEF_TAB [(i << 5) + j] * factor; */ - int y = DT_DEF_TAB [(i << 5) + j] * factor; - - impl->g.DT_TAB [i + 0] [j] = (int) y; - impl->g.DT_TAB [i + 4] [j] = (int) -y; - } - } - } - - // Tableau LFO - impl->g.LFO_INC_TAB [0] = (int) (3.98 * (1 << (LFO_HBITS + LFO_LBITS))) / sample_rate; - impl->g.LFO_INC_TAB [1] = (int) (5.56 * (1 << (LFO_HBITS + LFO_LBITS))) / sample_rate; - impl->g.LFO_INC_TAB [2] = (int) (6.02 * (1 << (LFO_HBITS + LFO_LBITS))) / sample_rate; - impl->g.LFO_INC_TAB [3] = (int) (6.37 * (1 << (LFO_HBITS + LFO_LBITS))) / sample_rate; - impl->g.LFO_INC_TAB [4] = (int) (6.88 * (1 << (LFO_HBITS + LFO_LBITS))) / sample_rate; - impl->g.LFO_INC_TAB [5] = (int) (9.63 * (1 << (LFO_HBITS + LFO_LBITS))) / sample_rate; - impl->g.LFO_INC_TAB [6] = (int) (48.1 * (1 << (LFO_HBITS + LFO_LBITS))) / sample_rate; - impl->g.LFO_INC_TAB [7] = (int) (72.2 * (1 << (LFO_HBITS + LFO_LBITS))) / sample_rate; - - impl_reset( impl ); -} - -const char* Ym2612_set_rate( struct Ym2612_Emu* this, int sample_rate, int clock_rate ) -{ -// Only set rates if necessary -#if defined(ROCKBOX) - static int last_sample_rate = 0, last_clock_rate = 0; - if (last_sample_rate == sample_rate && last_clock_rate == clock_rate) return 0; -#endif - memset( &this->impl.YM2612, 0, sizeof this->impl.YM2612 ); - impl_set_rate( &this->impl, sample_rate, clock_rate ); - - return 0; -} - -static inline void write0( struct Ym2612_Impl* impl, int opn_addr, int data ) -{ - assert( (unsigned) data <= 0xFF ); - - if ( opn_addr < 0x30 ) - { - impl->YM2612.REG [0] [opn_addr] = data; - YM_SET( impl, opn_addr, data ); - } - else if ( impl->YM2612.REG [0] [opn_addr] != data ) - { - impl->YM2612.REG [0] [opn_addr] = data; - - if ( opn_addr < 0xA0 ) - SLOT_SET( impl, opn_addr, data ); - else - CHANNEL_SET( &impl->YM2612, opn_addr, data ); - } -} - -static inline void write1( struct Ym2612_Impl* impl, int opn_addr, int data ) -{ - assert( (unsigned) data <= 0xFF ); - - if ( opn_addr >= 0x30 && impl->YM2612.REG [1] [opn_addr] != data ) - { - impl->YM2612.REG [1] [opn_addr] = data; - - if ( opn_addr < 0xA0 ) - SLOT_SET( impl, opn_addr + 0x100, data ); - else - CHANNEL_SET( &impl->YM2612, opn_addr + 0x100, data ); - } -} - -void impl_reset( struct Ym2612_Impl* impl ) -{ - impl->g.LFOcnt = 0; - impl->YM2612.TimerA = 0; - impl->YM2612.TimerAL = 0; - impl->YM2612.TimerAcnt = 0; - impl->YM2612.TimerB = 0; - impl->YM2612.TimerBL = 0; - impl->YM2612.TimerBcnt = 0; - impl->YM2612.DAC = 0; - - impl->YM2612.Status = 0; - - int i; - for ( i = 0; i < ym2612_channel_count; i++ ) - { - struct channel_* ch = &impl->YM2612.CHANNEL [i]; - - ch->LEFT = ~0; - ch->RIGHT = ~0; - ch->ALGO = 0; - ch->FB = 31; - ch->FMS = 0; - ch->AMS = 0; - - int j; - for ( j = 0 ;j < 4 ; j++ ) - { - ch->S0_OUT [j] = 0; - ch->FNUM [j] = 0; - ch->FOCT [j] = 0; - ch->KC [j] = 0; - - ch->SLOT [j].Fcnt = 0; - ch->SLOT [j].Finc = 0; - ch->SLOT [j].Ecnt = ENV_END; // Put it at the end of Decay phase... - ch->SLOT [j].Einc = 0; - ch->SLOT [j].Ecmp = 0; - ch->SLOT [j].Ecurp = RELEASE; - - ch->SLOT [j].ChgEnM = 0; - } - } - - for ( i = 0; i < 0x100; i++ ) - { - impl->YM2612.REG [0] [i] = -1; - impl->YM2612.REG [1] [i] = -1; - } - - for ( i = 0xB6; i >= 0xB4; i-- ) - { - write0( impl, i, 0xC0 ); - write1( impl, i, 0xC0 ); - } - - for ( i = 0xB2; i >= 0x22; i-- ) - { - write0( impl, i, 0 ); - write1( impl, i, 0 ); - } - - write0( impl, 0x2A, 0x80 ); -} - -void Ym2612_reset( struct Ym2612_Emu* this ) -{ - impl_reset( &this->impl ); -} - -void Ym2612_write0( struct Ym2612_Emu* this, int addr, int data ) -{ - write0( &this->impl, addr, data ); -} - -void Ym2612_write1( struct Ym2612_Emu* this, int addr, int data ) -{ - write1( &this->impl, addr, data ); -} - -void Ym2612_mute_voices( struct Ym2612_Emu* this, int mask ) { this->impl.mute_mask = mask; } - -static void update_envelope_( struct slot_t* sl ) -{ - switch ( sl->Ecurp ) - { - case 0: - // Env_Attack_Next - - // Verified with Gynoug even in HQ (explode SFX) - sl->Ecnt = ENV_DECAY; - - sl->Einc = sl->EincD; - sl->Ecmp = sl->SLL; - sl->Ecurp = DECAY; - break; - - case 1: - // Env_Decay_Next - - // Verified with Gynoug even in HQ (explode SFX) - sl->Ecnt = sl->SLL; - - sl->Einc = sl->EincS; - sl->Ecmp = ENV_END; - sl->Ecurp = SUBSTAIN; - break; - - case 2: - // Env_Substain_Next(slot_t *SL) - if (sl->SEG & 8) // SSG envelope type - { - int release = sl->SEG & 1; - - if ( !release ) - { - // re KEY ON - - // sl->Fcnt = 0; - // sl->ChgEnM = ~0; - - sl->Ecnt = 0; - sl->Einc = sl->EincA; - sl->Ecmp = ENV_DECAY; - sl->Ecurp = ATTACK; - } - - set_seg( sl, (sl->SEG << 1) & 4 ); - - if ( !release ) - break; - } - // fall through - - case 3: - // Env_Release_Next - sl->Ecnt = ENV_END; - sl->Einc = 0; - sl->Ecmp = ENV_END + 1; - break; - - // default: no op - } -} - -static inline void update_envelope( struct slot_t* sl ) -{ - int ecmp = sl->Ecmp; - if ( (sl->Ecnt += sl->Einc) >= ecmp ) - update_envelope_( sl ); -} - - -typedef void (*ym2612_update_chan_t)( struct tables_t*, struct channel_*, short*, int ); - -#define GET_CURRENT_PHASE \ -int in0 = ch->SLOT[S0].Fcnt; \ -int in1 = ch->SLOT[S1].Fcnt; \ -int in2 = ch->SLOT[S2].Fcnt; \ -int in3 = ch->SLOT[S3].Fcnt; \ - -#define GET_CURRENT_LFO \ -int YM2612_LFOinc = g->LFOinc; \ -int YM2612_LFOcnt = g->LFOcnt + YM2612_LFOinc; - -#define CALC_EN( x ) \ - int temp##x = ENV_TAB [ch->SLOT [S##x].Ecnt >> ENV_LBITS] + ch->SLOT [S##x].TLL; \ - int en##x = ((temp##x ^ ch->SLOT [S##x].env_xor) + (env_LFO >> ch->SLOT [S##x].AMS)) & \ - ((temp##x - ch->SLOT [S##x].env_max) >> 31); - -#define GET_ENV \ -int const env_LFO = ENV_TAB_LOOKUP [YM2612_LFOcnt >> LFO_LBITS & LFO_MASK]; \ -short const* const ENV_TAB = g->ENV_TAB; \ -CALC_EN( 0 ) \ -CALC_EN( 1 ) \ -CALC_EN( 2 ) \ -CALC_EN( 3 ) - -#ifndef YM2612_USE_TL_TAB -static inline int tl_level( int i ) -{ - if (i >= (PG_CUT_OFF + TL_LENGHT)) { - return 0; - } else if (i >= TL_LENGHT) { - return -tl_coeff [i - TL_LENGHT]; - } else if (i >= PG_CUT_OFF) { - return 0; - } else - return tl_coeff [i]; -} -#define SINT( i, o ) (tl_level (g->SIN_TAB [(i)] + (o))) -#else -#define SINT( i, o ) (g->TL_TAB [g->SIN_TAB [(i)] + (o)]) -#endif - -#define DO_FEEDBACK \ -int CH_S0_OUT_0 = ch->S0_OUT [0]; \ -{ \ - int temp = in0 + ((CH_S0_OUT_0 + CH_S0_OUT_1) >> ch->FB); \ - CH_S0_OUT_1 = CH_S0_OUT_0; \ - CH_S0_OUT_0 = SINT( (temp >> SIN_LBITS) & SIN_MASK, en0 ); \ -} \ - -#define DO_LIMIT \ -CH_OUTd >>= MAX_OUT_BITS - output_bits + 2; \ - -#define UPDATE_PHASE_CYCLE \ -unsigned freq_LFO = ((FREQ_TAB_LOOKUP [YM2612_LFOcnt >> LFO_LBITS & LFO_MASK] * \ - ch->FMS) >> (LFO_HBITS - 1 + 1)) + (1 << (LFO_FMS_LBITS - 1)); \ -YM2612_LFOcnt += YM2612_LFOinc; \ -in0 += (ch->SLOT [S0].Finc * freq_LFO) >> (LFO_FMS_LBITS - 1); \ -in1 += (ch->SLOT [S1].Finc * freq_LFO) >> (LFO_FMS_LBITS - 1); \ -in2 += (ch->SLOT [S2].Finc * freq_LFO) >> (LFO_FMS_LBITS - 1); \ -in3 += (ch->SLOT [S3].Finc * freq_LFO) >> (LFO_FMS_LBITS - 1); - -#define UPDATE_ENV \ -int t0 = buf [0] + (CH_OUTd & ch->LEFT); \ -int t1 = buf [1] + (CH_OUTd & ch->RIGHT); \ -update_envelope( &ch->SLOT [0] ); \ -update_envelope( &ch->SLOT [1] ); \ -update_envelope( &ch->SLOT [2] ); \ -update_envelope( &ch->SLOT [3] ); - -#define DO_OUTPUT_0 \ -ch->S0_OUT [0] = CH_S0_OUT_0; \ -buf [0] = t0; \ -buf [1] = t1; \ -buf += 2; \ - -#define DO_OUTPUT_1 \ -ch->S0_OUT [1] = CH_S0_OUT_1; - -#define UPDATE_PHASE \ -ch->SLOT [S0].Fcnt = in0; \ -ch->SLOT [S1].Fcnt = in1; \ -ch->SLOT [S2].Fcnt = in2; \ -ch->SLOT [S3].Fcnt = in3; - -static void ym2612_update_chan0( struct tables_t* g, struct channel_* ch, - short* buf, int length ) -{ - int not_end = ch->SLOT [S3].Ecnt - ENV_END; - int CH_S0_OUT_1 = ch->S0_OUT [1]; - - GET_CURRENT_PHASE - GET_CURRENT_LFO - - if ( !not_end ) - return; - - do - { - GET_ENV - DO_FEEDBACK - - int CH_OUTd; - int temp = in1 + CH_S0_OUT_1; - temp = in2 + SINT( (temp >> SIN_LBITS) & SIN_MASK, en1 ); - temp = in3 + SINT( (temp >> SIN_LBITS) & SIN_MASK, en2 ); - CH_OUTd = SINT( (temp >> SIN_LBITS) & SIN_MASK, en3 ); - - DO_LIMIT - UPDATE_PHASE_CYCLE - UPDATE_ENV - DO_OUTPUT_0 - } - while ( --length ); - DO_OUTPUT_1 - UPDATE_PHASE -} - -static void ym2612_update_chan1( struct tables_t* g, struct channel_* ch, - short* buf, int length ) -{ - int not_end = ch->SLOT [S3].Ecnt - ENV_END; - int CH_S0_OUT_1 = ch->S0_OUT [1]; - - GET_CURRENT_PHASE - GET_CURRENT_LFO - - if ( !not_end ) - return; - - do - { - GET_ENV - DO_FEEDBACK - - int CH_OUTd; - int temp = in2 + CH_S0_OUT_1 + SINT( (in1 >> SIN_LBITS) & SIN_MASK, en1 ); - temp = in3 + SINT( (temp >> SIN_LBITS) & SIN_MASK, en2 ); - CH_OUTd = SINT( (temp >> SIN_LBITS) & SIN_MASK, en3 ); - - DO_LIMIT - UPDATE_PHASE_CYCLE - UPDATE_ENV - DO_OUTPUT_0 - } - while ( --length ); - DO_OUTPUT_1 - UPDATE_PHASE -} - -static void ym2612_update_chan2( struct tables_t* g, struct channel_* ch, - short* buf, int length ) -{ - int not_end = ch->SLOT [S3].Ecnt - ENV_END; - int CH_S0_OUT_1 = ch->S0_OUT [1]; - - GET_CURRENT_PHASE - GET_CURRENT_LFO - - if ( !not_end ) - return; - - do - { - GET_ENV - DO_FEEDBACK - - int CH_OUTd; - int temp = in2 + SINT( (in1 >> SIN_LBITS) & SIN_MASK, en1 ); - temp = in3 + CH_S0_OUT_1 + SINT( (temp >> SIN_LBITS) & SIN_MASK, en2 ); - CH_OUTd = SINT( (temp >> SIN_LBITS) & SIN_MASK, en3 ); - - DO_LIMIT - UPDATE_PHASE_CYCLE - UPDATE_ENV - DO_OUTPUT_0 - } - while ( --length ); - DO_OUTPUT_1 - UPDATE_PHASE -} - -static void ym2612_update_chan3( struct tables_t* g, struct channel_* ch, - short* buf, int length ) -{ - int not_end = ch->SLOT [S3].Ecnt - ENV_END; - int CH_S0_OUT_1 = ch->S0_OUT [1]; - - GET_CURRENT_PHASE - GET_CURRENT_LFO - - if ( !not_end ) - return; - - do - { - GET_ENV - DO_FEEDBACK - - int CH_OUTd; - int temp = in1 + CH_S0_OUT_1; - temp = in3 + SINT( (temp >> SIN_LBITS) & SIN_MASK, en1 ) + - SINT( (in2 >> SIN_LBITS) & SIN_MASK, en2 ); - CH_OUTd = SINT( (temp >> SIN_LBITS) & SIN_MASK, en3 ); - - DO_LIMIT - UPDATE_PHASE_CYCLE - UPDATE_ENV - DO_OUTPUT_0 - } - while ( --length ); - DO_OUTPUT_1 - UPDATE_PHASE -} - -static void ym2612_update_chan4( struct tables_t* g, struct channel_* ch, - short* buf, int length ) -{ - int not_end = ch->SLOT [S3].Ecnt - ENV_END; - not_end |= ch->SLOT [S1].Ecnt - ENV_END; - - int CH_S0_OUT_1 = ch->S0_OUT [1]; - - GET_CURRENT_PHASE - GET_CURRENT_LFO - - if ( !not_end ) - return; - - do - { - GET_ENV - DO_FEEDBACK - - int CH_OUTd; - int temp = in3 + SINT( (in2 >> SIN_LBITS) & SIN_MASK, en2 ); - CH_OUTd = SINT( (temp >> SIN_LBITS) & SIN_MASK, en3 ) + - SINT( ((in1 + CH_S0_OUT_1) >> SIN_LBITS) & SIN_MASK, en1 ); - - DO_LIMIT - UPDATE_PHASE_CYCLE - UPDATE_ENV - DO_OUTPUT_0 - } - while ( --length ); - DO_OUTPUT_1 - UPDATE_PHASE -} - -static void ym2612_update_chan5( struct tables_t* g, struct channel_* ch, - short* buf, int length ) -{ - int not_end = ch->SLOT [S3].Ecnt - ENV_END; - not_end |= ch->SLOT [S2].Ecnt - ENV_END; - not_end |= ch->SLOT [S1].Ecnt - ENV_END; - - int CH_S0_OUT_1 = ch->S0_OUT [1]; - - GET_CURRENT_PHASE - GET_CURRENT_LFO - - if ( !not_end ) - return; - - do - { - GET_ENV - DO_FEEDBACK - - int CH_OUTd; - int temp = CH_S0_OUT_1; - CH_OUTd = SINT( ((in3 + temp) >> SIN_LBITS) & SIN_MASK, en3 ) + - SINT( ((in1 + temp) >> SIN_LBITS) & SIN_MASK, en1 ) + - SINT( ((in2 + temp) >> SIN_LBITS) & SIN_MASK, en2 ); - - DO_LIMIT - UPDATE_PHASE_CYCLE - UPDATE_ENV - DO_OUTPUT_0 - } - while ( --length ); - DO_OUTPUT_1 - UPDATE_PHASE -} - -static void ym2612_update_chan6( struct tables_t* g, struct channel_* ch, - short* buf, int length ) -{ - int not_end = ch->SLOT [S3].Ecnt - ENV_END; - not_end |= ch->SLOT [S2].Ecnt - ENV_END; - not_end |= ch->SLOT [S1].Ecnt - ENV_END; - - int CH_S0_OUT_1 = ch->S0_OUT [1]; - - GET_CURRENT_PHASE - GET_CURRENT_LFO - - if ( !not_end ) - return; - - do - { - GET_ENV - DO_FEEDBACK - - int CH_OUTd; - CH_OUTd = SINT( (in3 >> SIN_LBITS) & SIN_MASK, en3 ) + - SINT( ((in1 + CH_S0_OUT_1) >> SIN_LBITS) & SIN_MASK, en1 ) + - SINT( (in2 >> SIN_LBITS) & SIN_MASK, en2 ); - - DO_LIMIT - UPDATE_PHASE_CYCLE - UPDATE_ENV - DO_OUTPUT_0 - } - while ( --length ); - DO_OUTPUT_1 - UPDATE_PHASE -} - -static void ym2612_update_chan7( struct tables_t* g, struct channel_* ch, - short* buf, int length ) -{ - int not_end = ch->SLOT [S3].Ecnt - ENV_END; - not_end |= ch->SLOT [S0].Ecnt - ENV_END; - not_end |= ch->SLOT [S2].Ecnt - ENV_END; - not_end |= ch->SLOT [S1].Ecnt - ENV_END; - - int CH_S0_OUT_1 = ch->S0_OUT [1]; - - GET_CURRENT_PHASE - GET_CURRENT_LFO - - if ( !not_end ) - return; - - do - { - GET_ENV - DO_FEEDBACK - - int CH_OUTd; - CH_OUTd = SINT( (in3 >> SIN_LBITS) & SIN_MASK, en3 ) + - SINT( (in1 >> SIN_LBITS) & SIN_MASK, en1 ) + - SINT( (in2 >> SIN_LBITS) & SIN_MASK, en2 ) + CH_S0_OUT_1; - - DO_LIMIT - UPDATE_PHASE_CYCLE - UPDATE_ENV - DO_OUTPUT_0 - } - while ( --length ); - DO_OUTPUT_1 - UPDATE_PHASE -} - -static void (*UPDATE_CHAN[8])(struct tables_t* g, struct channel_* ch, - short* buf, int length) = -{ - (void *)ym2612_update_chan0, - (void *)ym2612_update_chan1, - (void *)ym2612_update_chan2, - (void *)ym2612_update_chan3, - (void *)ym2612_update_chan4, - (void *)ym2612_update_chan5, - (void *)ym2612_update_chan6, - (void *)ym2612_update_chan7 -}; - -static void run_timer( struct Ym2612_Impl* impl, int length ) -{ - int const step = 6; - int remain = length; - do - { - int n = step; - if ( n > remain ) - n = remain; - remain -= n; - - int i = n * impl->YM2612.TimerBase; - if (impl->YM2612.Mode & 1) // Timer A ON ? - { - // if ((impl->YM2612.TimerAcnt -= 14073) <= 0) // 13879=NTSC (old: 14475=NTSC 14586=PAL) - if ((impl->YM2612.TimerAcnt -= i) <= 0) - { - // timer a overflow - - impl->YM2612.Status |= (impl->YM2612.Mode & 0x04) >> 2; - impl->YM2612.TimerAcnt += impl->YM2612.TimerAL; - - if (impl->YM2612.Mode & 0x80) - { - KEY_ON( &impl->YM2612.CHANNEL [2], &impl->g, 0 ); - KEY_ON( &impl->YM2612.CHANNEL [2], &impl->g, 1 ); - KEY_ON( &impl->YM2612.CHANNEL [2], &impl->g, 2 ); - KEY_ON( &impl->YM2612.CHANNEL [2], &impl->g, 3 ); - } - } - } - - if (impl->YM2612.Mode & 2) // Timer B ON ? - { - // if ((impl->YM2612.TimerBcnt -= 14073) <= 0) // 13879=NTSC (old: 14475=NTSC 14586=PAL) - if ((impl->YM2612.TimerBcnt -= i) <= 0) - { - // timer b overflow - impl->YM2612.Status |= (impl->YM2612.Mode & 0x08) >> 2; - impl->YM2612.TimerBcnt += impl->YM2612.TimerBL; - } - } - } - while ( remain > 0 ); -} - -static void impl_run( struct Ym2612_Impl* impl, int pair_count, short out [] ) -{ - if ( pair_count <= 0 ) - return; - - if ( impl->YM2612.Mode & 3 ) - run_timer( impl, pair_count ); - - // Mise à jour des pas des compteurs-frequences s'ils ont ete modifies - - int chi; - for ( chi = 0; chi < ym2612_channel_count; chi++ ) - { - struct channel_* ch = &impl->YM2612.CHANNEL [chi]; - if ( ch->SLOT [0].Finc != -1 ) - continue; - - int i2 = 0; - if ( chi == 2 && (impl->YM2612.Mode & 0x40) ) - i2 = 2; - - int i; - for ( i = 0; i < 4; i++ ) - { - // static int seq [4] = { 2, 1, 3, 0 }; - // if ( i2 ) i2 = seq [i]; - - struct slot_t* sl = &ch->SLOT [i]; - int finc = impl->g.FINC_TAB [ch->FNUM [i2]] >> (7 - ch->FOCT [i2]); - int ksr = ch->KC [i2] >> sl->KSR_S; // keycode attenuation - sl->Finc = (finc + sl->DT [ch->KC [i2]]) * sl->MUL; - if (sl->KSR != ksr) // si le KSR a change alors - { // les differents taux pour l'enveloppe sont mis à jour - sl->KSR = ksr; - - sl->EincA = sl->AR [ksr]; - sl->EincD = sl->DR [ksr]; - sl->EincS = sl->SR [ksr]; - sl->EincR = sl->RR [ksr]; - - if (sl->Ecurp == ATTACK) - { - sl->Einc = sl->EincA; - } - else if (sl->Ecurp == DECAY) - { - sl->Einc = sl->EincD; - } - else if (sl->Ecnt < ENV_END) - { - if (sl->Ecurp == SUBSTAIN) - sl->Einc = sl->EincS; - else if (sl->Ecurp == RELEASE) - sl->Einc = sl->EincR; - } - } - - if ( i2 ) - i2 = (i2 ^ 2) ^ (i2 >> 1); - } - } - - int i; - for ( i = 0; i < ym2612_channel_count; i++ ) - { - if ( !(impl->mute_mask & (1 << i)) && (i != 5 || !impl->YM2612.DAC) ) - UPDATE_CHAN [impl->YM2612.CHANNEL [i].ALGO]( &impl->g, &impl->YM2612.CHANNEL [i], out, pair_count ); - } - - impl->g.LFOcnt += impl->g.LFOinc * pair_count; -} - -void Ym2612_run( struct Ym2612_Emu* this, int pair_count, short out [] ) { impl_run( &this->impl, pair_count, out ); } diff --git a/apps/codecs/libgme/ym2612_emu.h b/apps/codecs/libgme/ym2612_emu.h deleted file mode 100644 index 146d92a0a3..0000000000 --- a/apps/codecs/libgme/ym2612_emu.h +++ /dev/null @@ -1,248 +0,0 @@ -// YM2612 FM sound chip emulator - -// Game_Music_Emu 0.6-pre -#ifndef YM2612_EMU_H -#define YM2612_EMU_H - -#include "blargg_common.h" - -#if !defined(ROCKBOX) - #define YM2612_CALCUL_TABLES -#endif - -#if MEMORYSIZE > 2 - #define YM2612_USE_TL_TAB -#endif - -enum { ym2612_out_chan_count = 2 }; // stereo -enum { ym2612_channel_count = 6 }; -enum { ym2612_disabled_time = -1 }; - -struct slot_t -{ - const int *DT; // parametre detune - int MUL; // parametre "multiple de frequence" - int TL; // Total Level = volume lorsque l'enveloppe est au plus haut - int TLL; // Total Level ajusted - int SLL; // Sustin Level (ajusted) = volume où l'enveloppe termine sa premiere phase de regression - int KSR_S; // Key Scale Rate Shift = facteur de prise en compte du KSL dans la variations de l'enveloppe - int KSR; // Key Scale Rate = cette valeur est calculee par rapport à la frequence actuelle, elle va influer - // sur les differents parametres de l'enveloppe comme l'attaque, le decay ... comme dans la realite ! - int SEG; // Type enveloppe SSG - int env_xor; - int env_max; - - const int *AR; // Attack Rate (table pointeur) = Taux d'attaque (AR [KSR]) - const int *DR; // Decay Rate (table pointeur) = Taux pour la regression (DR [KSR]) - const int *SR; // Sustin Rate (table pointeur) = Taux pour le maintien (SR [KSR]) - const int *RR; // Release Rate (table pointeur) = Taux pour le rel'chement (RR [KSR]) - int Fcnt; // Frequency Count = compteur-frequence pour determiner l'amplitude actuelle (SIN [Finc >> 16]) - int Finc; // frequency step = pas d'incrementation du compteur-frequence - // plus le pas est grand, plus la frequence est aïgu (ou haute) - int Ecurp; // Envelope current phase = cette variable permet de savoir dans quelle phase - // de l'enveloppe on se trouve, par exemple phase d'attaque ou phase de maintenue ... - // en fonction de la valeur de cette variable, on va appeler une fonction permettant - // de mettre à jour l'enveloppe courante. - int Ecnt; // Envelope counter = le compteur-enveloppe permet de savoir où l'on se trouve dans l'enveloppe - int Einc; // Envelope step courant - int Ecmp; // Envelope counter limite pour la prochaine phase - int EincA; // Envelope step for Attack = pas d'incrementation du compteur durant la phase d'attaque - // cette valeur est egal à AR [KSR] - int EincD; // Envelope step for Decay = pas d'incrementation du compteur durant la phase de regression - // cette valeur est egal à DR [KSR] - int EincS; // Envelope step for Sustain = pas d'incrementation du compteur durant la phase de maintenue - // cette valeur est egal à SR [KSR] - int EincR; // Envelope step for Release = pas d'incrementation du compteur durant la phase de rel'chement - // cette valeur est egal à RR [KSR] - int *OUTp; // pointeur of SLOT output = pointeur permettant de connecter la sortie de ce slot à l'entree - // d'un autre ou carrement à la sortie de la voie - int INd; // input data of the slot = donnees en entree du slot - int ChgEnM; // Change envelop mask. - int AMS; // AMS depth level of this SLOT = degre de modulation de l'amplitude par le LFO - int AMSon; // AMS enable flag = drapeau d'activation de l'AMS -}; - -struct channel_ -{ - int S0_OUT [4]; // anciennes sorties slot 0 (pour le feed back) - int LEFT; // LEFT enable flag - int RIGHT; // RIGHT enable flag - int ALGO; // Algorythm = determine les connections entre les operateurs - int FB; // shift count of self feed back = degre de "Feed-Back" du SLOT 1 (il est son unique entree) - int FMS; // Frequency Modulation Sensitivity of channel = degre de modulation de la frequence sur la voie par le LFO - int AMS; // Amplitude Modulation Sensitivity of channel = degre de modulation de l'amplitude sur la voie par le LFO - int FNUM [4]; // hauteur frequence de la voie (+ 3 pour le mode special) - int FOCT [4]; // octave de la voie (+ 3 pour le mode special) - int KC [4]; // Key Code = valeur fonction de la frequence (voir KSR pour les slots, KSR = KC >> KSR_S) - struct slot_t SLOT [4]; // four slot.operators = les 4 slots de la voie - int FFlag; // Frequency step recalculation flag -}; - -struct state_t -{ - int TimerBase; // TimerBase calculation - int Status; // YM2612 Status (timer overflow) - int TimerA; // timerA limit = valeur jusqu'à laquelle le timer A doit compter - int TimerAL; - int TimerAcnt; // timerA counter = valeur courante du Timer A - int TimerB; // timerB limit = valeur jusqu'à laquelle le timer B doit compter - int TimerBL; - int TimerBcnt; // timerB counter = valeur courante du Timer B - int Mode; // Mode actuel des voie 3 et 6 (normal / special) - int DAC; // DAC enabled flag - struct channel_ CHANNEL [ym2612_channel_count]; // Les 6 voies du YM2612 - int REG [2] [0x100]; // Sauvegardes des valeurs de tout les registres, c'est facultatif - // cela nous rend le debuggage plus facile -}; - -#undef PI -#define PI 3.14159265358979323846 - -#define ATTACK 0 -#define DECAY 1 -#define SUBSTAIN 2 -#define RELEASE 3 - -// SIN_LBITS <= 16 -// LFO_HBITS <= 16 -// (SIN_LBITS + SIN_HBITS) <= 26 -// (ENV_LBITS + ENV_HBITS) <= 28 -// (LFO_LBITS + LFO_HBITS) <= 28 - -#define SIN_HBITS 12 // Sinus phase counter int part -#define SIN_LBITS (26 - SIN_HBITS) // Sinus phase counter float part (best setting) - -#if (SIN_LBITS > 16) -#define SIN_LBITS 16 // Can't be greater than 16 bits -#endif - -#define ENV_HBITS 12 // Env phase counter int part -#define ENV_LBITS (28 - ENV_HBITS) // Env phase counter float part (best setting) - -#define LFO_HBITS 10 // LFO phase counter int part -#define LFO_LBITS (28 - LFO_HBITS) // LFO phase counter float part (best setting) - -#define SIN_LENGHT (1 << SIN_HBITS) -#define ENV_LENGHT (1 << ENV_HBITS) -#define LFO_LENGHT (1 << LFO_HBITS) - -#define TL_LENGHT (ENV_LENGHT * 3) // Env + TL scaling + LFO - -#define SIN_MASK (SIN_LENGHT - 1) -#define ENV_MASK (ENV_LENGHT - 1) -#define LFO_MASK (LFO_LENGHT - 1) - -#define ENV_STEP (96.0 / ENV_LENGHT) // ENV_MAX = 96 dB - -#define ENV_ATTACK ((ENV_LENGHT * 0) << ENV_LBITS) -#define ENV_DECAY ((ENV_LENGHT * 1) << ENV_LBITS) -#define ENV_END ((ENV_LENGHT * 2) << ENV_LBITS) - -#define MAX_OUT_BITS (SIN_HBITS + SIN_LBITS + 2) // Modulation = -4 <--> +4 -#define MAX_OUT ((1 << MAX_OUT_BITS) - 1) - -#define PG_CUT_OFF ((int) (78.0 / ENV_STEP)) -//#define ENV_CUT_OFF ((int) (68.0 / ENV_STEP)) - -#define AR_RATE 399128 -#define DR_RATE 5514396 - -//#define AR_RATE 426136 -//#define DR_RATE (AR_RATE * 12) - -#define LFO_FMS_LBITS 9 // FIXED (LFO_FMS_BASE gives somethink as 1) -#define LFO_FMS_BASE ((int) (0.05946309436 * 0.0338 * (double) (1 << LFO_FMS_LBITS))) - -#define S0 0 // Stupid typo of the YM2612 -#define S1 2 -#define S2 1 -#define S3 3 - -struct tables_t -{ - short SIN_TAB [SIN_LENGHT]; // SINUS TABLE (offset into TL TABLE) - int LFOcnt; // LFO counter = compteur-frequence pour le LFO - int LFOinc; // LFO step counter = pas d'incrementation du compteur-frequence du LFO - // plus le pas est grand, plus la frequence est grande - unsigned int AR_TAB [128]; // Attack rate table - unsigned int DR_TAB [96]; // Decay rate table - unsigned int DT_TAB [8] [32]; // Detune table - unsigned int SL_TAB [16]; // Substain level table - unsigned int NULL_RATE [32]; // Table for NULL rate - int LFO_INC_TAB [8]; // LFO step table - - short ENV_TAB [2 * ENV_LENGHT + 8]; // ENV CURVE TABLE (attack & decay) -#ifdef YM2612_CALCUL_TABLES - short LFO_ENV_TAB [LFO_LENGHT]; // LFO AMS TABLE (adjusted for 11.8 dB) - short LFO_FREQ_TAB [LFO_LENGHT]; // LFO FMS TABLE -#endif -#ifdef YM2612_USE_TL_TAB - int TL_TAB [TL_LENGHT * 2]; // TOTAL LEVEL TABLE (positif and minus) -#endif - unsigned int DECAY_TO_ATTACK [ENV_LENGHT]; // Conversion from decay to attack phase - unsigned int FINC_TAB [2048]; // Frequency step table -}; - -struct Ym2612_Impl -{ - struct state_t YM2612; - int mute_mask; - struct tables_t g; -}; - -void impl_reset( struct Ym2612_Impl* impl ); - -struct Ym2612_Emu { - struct Ym2612_Impl impl; - - // Impl - int last_time; - int sample_rate; - int clock_rate; - short* out; -}; - -static inline void Ym2612_init( struct Ym2612_Emu* this_ ) -{ - this_->last_time = ym2612_disabled_time; this_->out = 0; - this_->impl.mute_mask = 0; -} - -// Sets sample rate and chip clock rate, in Hz. Returns non-zero -// if error. If clock_rate=0, uses sample_rate*144 -const char* Ym2612_set_rate( struct Ym2612_Emu* this_, int sample_rate, int clock_rate ); - -// Resets to power-up state -void Ym2612_reset( struct Ym2612_Emu* this_ ); - -// Mutes voice n if bit n (1 << n) of mask is set -void Ym2612_mute_voices( struct Ym2612_Emu* this_, int mask ); - -// Writes addr to register 0 then data to register 1 -void Ym2612_write0( struct Ym2612_Emu* this_, int addr, int data ); - -// Writes addr to register 2 then data to register 3 -void Ym2612_write1( struct Ym2612_Emu* this_, int addr, int data ); - -// Runs and adds pair_count*2 samples into current output buffer contents -void Ym2612_run( struct Ym2612_Emu* this_, int pair_count, short* out ); - -static inline void Ym2612_enable( struct Ym2612_Emu* this_, bool b ) { this_->last_time = b ? 0 : ym2612_disabled_time; } -static inline bool Ym2612_enabled( struct Ym2612_Emu* this_ ) { return this_->last_time != ym2612_disabled_time; } -static inline void Ym2612_begin_frame( struct Ym2612_Emu* this_, short* buf ) { this_->out = buf; this_->last_time = 0; } - -static inline int Ym2612_run_until( struct Ym2612_Emu* this_, int time ) -{ - int count = time - this_->last_time; - if ( count > 0 ) - { - if ( this_->last_time < 0 ) - return false; - this_->last_time = time; - short* p = this_->out; - this_->out += count * ym2612_out_chan_count; - Ym2612_run( this_, count, p ); - } - return true; -} -#endif diff --git a/apps/codecs/libgme/ymtables.h b/apps/codecs/libgme/ymtables.h deleted file mode 100644 index c1619026b2..0000000000 --- a/apps/codecs/libgme/ymtables.h +++ /dev/null @@ -1,559 +0,0 @@ -#ifndef _EMUTABLES_H_ -#define _EMUTABLES_H_ - -/* Precompiled ym2612 tables for use in Rockbox */ - -static const int tl_coeff[] = { - 268435455, 267712100, 266990695, 266271234, 265553712, 264838123, 264124462, 263412725, 262702906, 261994999, 261289000, - 260584903, 259882704, 259182396, 258483976, 257787438, 257092777, 256399988, 255709066, 255020006, 254332802, 253647450, - 252963945, 252282282, 251602456, 250924462, 250248294, 249573949, 248901421, 248230705, 247561797, 246894691, 246229383, - 245565867, 244904140, 244244195, 243586029, 242929637, 242275013, 241622154, 240971053, 240321708, 239674112, 239028261, - 238384150, 237741775, 237101131, 236462214, 235825018, 235189539, 234555773, 233923714, 233293359, 232664702, 232037740, - 231412466, 230788878, 230166970, 229546738, 228928178, 228311284, 227696052, 227082479, 226470558, 225860287, 225251660, - 224644674, 224039323, 223435603, 222833510, 222233039, 221634187, 221036948, 220441319, 219847295, 219254871, 218664044, - 218074809, 217487162, 216901098, 216316614, 215733704, 215152366, 214572594, 213994384, 213417732, 212842635, 212269087, - 211697084, 211126623, 210557699, 209990308, 209424446, 208860109, 208297293, 207735993, 207176206, 206617927, 206061153, - 205505879, 204952102, 204399816, 203849019, 203299706, 202751873, 202205517, 201660633, 201117217, 200575266, 200034774, - 199495740, 198958158, 198422024, 197887335, 197354088, 196822277, 196291899, 195762950, 195235427, 194709325, 194184641, - 193661370, 193139510, 192619056, 192100005, 191582352, 191066094, 190551228, 190037748, 189525653, 189014937, 188505598, - 187997631, 187491033, 186985800, 186481928, 185979414, 185478255, 184978446, 184479983, 183982864, 183487085, 182992641, - 182499530, 182007748, 181517291, 181028155, 180540338, 180053835, 179568643, 179084759, 178602178, 178120898, 177640915, - 177162225, 176684825, 176208712, 175733881, 175260330, 174788055, 174317053, 173847320, 173378853, 172911648, 172445702, - 171981012, 171517574, 171055385, 170594441, 170134740, 169676277, 169219049, 168763054, 168308287, 167854746, 167402427, - 166951327, 166501443, 166052770, 165605307, 165159050, 164713995, 164270139, 163827480, 163386013, 162945736, 162506646, - 162068738, 161632011, 161196460, 160762083, 160328877, 159896838, 159465963, 159036250, 158607694, 158180293, 157754044, - 157328943, 156904988, 156482176, 156060502, 155639965, 155220562, 154802288, 154385142, 153969119, 153554218, 153140435, - 152727766, 152316210, 151905763, 151496422, 151088184, 150681046, 150275005, 149870058, 149466203, 149063435, 148661753, - 148261154, 147861634, 147463190, 147065821, 146669522, 146274291, 145880125, 145487021, 145094976, 144703988, 144314054, - 143925170, 143537334, 143150543, 142764795, 142380086, 141996414, 141613775, 141232168, 140851589, 140472035, 140093505, - 139715994, 139339501, 138964022, 138589555, 138216097, 137843646, 137472198, 137101751, 136732302, 136363849, 135996388, - 135629918, 135264436, 134899938, 134536423, 134173887, 133812328, 133451743, 133092130, 132733486, 132375808, 132019095, - 131663342, 131308548, 130954711, 130601826, 130249893, 129898908, 129548869, 129199773, 128851618, 128504401, 128158119, - 127812771, 127468353, 127124864, 126782300, 126440659, 126099939, 125760137, 125421250, 125083277, 124746214, 124410060, - 124074812, 123740467, 123407023, 123074477, 122742828, 122412072, 122082208, 121753232, 121425143, 121097939, 120771615, - 120446172, 120121605, 119797912, 119475092, 119153142, 118832060, 118511843, 118192488, 117873994, 117556359, 117239579, - 116923653, 116608578, 116294353, 115980974, 115668439, 115356747, 115045894, 114735880, 114426700, 114118354, 113810839, - 113504152, 113198292, 112893256, 112589042, 112285648, 111983071, 111681310, 111380362, 111080225, 110780896, 110482375, - 110184657, 109887742, 109591627, 109296310, 109001789, 108708061, 108415125, 108122978, 107831619, 107541044, 107251253, - 106962243, 106674011, 106386556, 106099876, 105813968, 105528830, 105244461, 104960859, 104678020, 104395944, 104114628, - 103834069, 103554267, 103275219, 102996923, 102719377, 102442578, 102166526, 101891217, 101616650, 101342823, 101069734, - 100797381, 100525762, 100254875, 99984718, 99715288, 99446585, 99178606, 98911349, 98644812, 98378993, 98113891, - 97849503, 97585828, 97322863, 97060606, 96799057, 96538212, 96278070, 96018629, 95759887, 95501842, 95244493, - 94987837, 94731873, 94476599, 94222012, 93968112, 93714895, 93462361, 93210508, 92959333, 92708835, 92459012, - 92209863, 91961384, 91713575, 91466434, 91219959, 90974149, 90729000, 90484512, 90240683, 89997511, 89754994, - 89513131, 89271920, 89031358, 88791445, 88552178, 88313556, 88075578, 87838240, 87601542, 87365481, 87130057, - 86895267, 86661110, 86427584, 86194687, 85962418, 85730775, 85499756, 85269359, 85039583, 84810427, 84581888, - 84353965, 84126656, 83899959, 83673874, 83448397, 83223528, 82999266, 82775607, 82552551, 82330096, 82108241, - 81886984, 81666322, 81446256, 81226782, 81007900, 80789608, 80571904, 80354786, 80138254, 79922305, 79706938, - 79492151, 79277943, 79064313, 78851258, 78638777, 78426868, 78215531, 78004763, 77794564, 77584930, 77375862, - 77167357, 76959413, 76752031, 76545207, 76338940, 76133229, 75928072, 75723469, 75519416, 75315914, 75112960, - 74910552, 74708690, 74507373, 74306597, 74106363, 73906668, 73707512, 73508892, 73310807, 73113256, 72916237, - 72719749, 72523791, 72328361, 72133457, 71939079, 71745225, 71551892, 71359081, 71166789, 70975016, 70783759, - 70593018, 70402791, 70213076, 70023872, 69835179, 69646994, 69459315, 69272143, 69085475, 68899310, 68713647, - 68528484, 68343820, 68159653, 67975983, 67792808, 67610127, 67427937, 67246239, 67065030, 66884310, 66704076, - 66524328, 66345065, 66166285, 65987986, 65810168, 65632829, 65455968, 65279583, 65103674, 64928239, 64753277, - 64578786, 64404765, 64231213, 64058129, 63885511, 63713359, 63541670, 63370444, 63199679, 63029375, 62859529, - 62690141, 62521210, 62352734, 62184711, 62017142, 61850024, 61683357, 61517138, 61351368, 61186044, 61021166, - 60856731, 60692741, 60529192, 60366083, 60203414, 60041184, 59879391, 59718034, 59557111, 59396622, 59236566, - 59076941, 58917746, 58758980, 58600642, 58442730, 58285245, 58128183, 57971545, 57815329, 57659533, 57504158, - 57349201, 57194662, 57040539, 56886832, 56733539, 56580659, 56428190, 56276133, 56124486, 55973247, 55822415, - 55671990, 55521971, 55372355, 55223143, 55074333, 54925924, 54777915, 54630305, 54483092, 54336276, 54189856, - 54043830, 53898198, 53752959, 53608110, 53463652, 53319583, 53175903, 53032610, 52889702, 52747180, 52605042, - 52463287, 52321914, 52180922, 52040310, 51900076, 51760221, 51620743, 51481640, 51342912, 51204558, 51066577, - 50928968, 50791729, 50654860, 50518360, 50382228, 50246463, 50111064, 49976029, 49841359, 49707051, 49573105, - 49439520, 49306295, 49173429, 49040922, 48908771, 48776976, 48645537, 48514451, 48383719, 48253339, 48123311, - 47993633, 47864304, 47735324, 47606691, 47478405, 47350465, 47222869, 47095618, 46968709, 46842142, 46715916, - 46590031, 46464484, 46339276, 46214406, 46089871, 45965673, 45841809, 45718279, 45595082, 45472216, 45349682, - 45227478, 45105603, 44984057, 44862838, 44741946, 44621380, 44501139, 44381221, 44261627, 44142355, 44023404, - 43904774, 43786464, 43668472, 43550798, 43433442, 43316402, 43199677, 43083266, 42967170, 42851386, 42735914, - 42620753, 42505903, 42391362, 42277130, 42163206, 42049588, 41936277, 41823271, 41710570, 41598172, 41486077, - 41374285, 41262793, 41151602, 41040711, 40930118, 40819823, 40709826, 40600125, 40490720, 40381609, 40272793, - 40164269, 40056039, 39948099, 39840451, 39733093, 39626024, 39519243, 39412751, 39306545, 39200625, 39094991, - 38989642, 38884576, 38779794, 38675294, 38571075, 38467138, 38363480, 38260102, 38157002, 38054180, 37951635, - 37849367, 37747374, 37645656, 37544212, 37443042, 37342144, 37241518, 37141163, 37041078, 36941264, 36841718, - 36742440, 36643430, 36544687, 36446210, 36347998, 36250051, 36152368, 36054948, 35957790, 35860895, 35764260, - 35667886, 35571772, 35475916, 35380319, 35284980, 35189897, 35095071, 35000500, 34906184, 34812122, 34718314, - 34624758, 34531454, 34438402, 34345601, 34253050, 34160748, 34068695, 33976890, 33885332, 33794021, 33702956, - 33612137, 33521562, 33431231, 33341144, 33251299, 33161697, 33072336, 32983216, 32894336, 32805695, 32717294, - 32629130, 32541204, 32453515, 32366063, 32278846, 32191864, 32105116, 32018602, 31932322, 31846273, 31760457, - 31674872, 31589518, 31504393, 31419498, 31334832, 31250394, 31166183, 31082200, 30998442, 30914911, 30831604, - 30748522, 30665664, 30583029, 30500617, 30418426, 30336458, 30254710, 30173183, 30091875, 30010786, 29929916, - 29849263, 29768829, 29688610, 29608608, 29528822, 29449250, 29369893, 29290750, 29211820, 29133103, 29054598, - 28976304, 28898222, 28820350, 28742687, 28665234, 28587990, 28510954, 28434125, 28357503, 28281088, 28204879, - 28128875, 28053076, 27977482, 27902091, 27826903, 27751917, 27677134, 27602552, 27528172, 27453991, 27380011, - 27306230, 27232648, 27159264, 27086078, 27013089, 26940296, 26867700, 26795300, 26723094, 26651083, 26579267, - 26507643, 26436213, 26364975, 26293929, 26223075, 26152412, 26081939, 26011656, 25941562, 25871657, 25801940, - 25732412, 25663071, 25593916, 25524948, 25456166, 25387569, 25319157, 25250929, 25182886, 25115025, 25047348, - 24979852, 24912539, 24845407, 24778456, 24711686, 24645095, 24578684, 24512451, 24446397, 24380522, 24314823, - 24249302, 24183957, 24118789, 24053796, 23988978, 23924335, 23859866, 23795570, 23731448, 23667499, 23603722, - 23540117, 23476683, 23413421, 23350328, 23287406, 23224653, 23162070, 23099655, 23037408, 22975329, 22913417, - 22851673, 22790094, 22728681, 22667434, 22606352, 22545435, 22484682, 22424092, 22363666, 22303402, 22243301, - 22183362, 22123584, 22063968, 22004512, 21945216, 21886080, 21827104, 21768286, 21709627, 21651126, 21592783, - 21534597, 21476567, 21418694, 21360977, 21303416, 21246009, 21188758, 21131660, 21074717, 21017926, 20961289, - 20904805, 20848473, 20792292, 20736263, 20680385, 20624657, 20569080, 20513652, 20458374, 20403245, 20348264, - 20293432, 20238747, 20184209, 20129819, 20075575, 20021477, 19967525, 19913719, 19860057, 19806540, 19753167, - 19699938, 19646853, 19593910, 19541111, 19488453, 19435937, 19383563, 19331330, 19279238, 19227286, 19175474, - 19123802, 19072269, 19020875, 18969619, 18918502, 18867522, 18816680, 18765974, 18715405, 18664973, 18614676, - 18564515, 18514489, 18464598, 18414842, 18365219, 18315730, 18266375, 18217152, 18168062, 18119105, 18070279, - 18021585, 17973022, 17924590, 17876289, 17828118, 17780076, 17732164, 17684381, 17636727, 17589201, 17541803, - 17494533, 17447391, 17400375, 17353486, 17306724, 17260087, 17213577, 17167191, 17120930, 17074795, 17028783, - 16982896, 16937132, 16891491, 16845974, 16800579, 16755306, 16710155, 16665126, 16620219, 16575432, 16530766, - 16486221, 16441795, 16397490, 16353303, 16309236, 16265287, 16221457, 16177745, 16134151, 16090674, 16047314, - 16004072, 15960945, 15917935, 15875041, 15832263, 15789599, 15747051, 15704617, 15662298, 15620093, 15578001, - 15536023, 15494158, 15452406, 15410766, 15369239, 15327823, 15286519, 15245327, 15204245, 15163274, 15122414, - 15081663, 15041023, 15000491, 14960070, 14919757, 14879552, 14839456, 14799468, 14759588, 14719815, 14680150, - 14640591, 14601139, 14561793, 14522554, 14483420, 14444391, 14405468, 14366649, 14327935, 14289326, 14250820, - 14212418, 14174120, 14135925, 14097833, 14059843, 14021956, 13984171, 13946488, 13908906, 13871426, 13834047, - 13796768, 13759590, 13722512, 13685534, 13648655, 13611876, 13575196, 13538615, 13502132, 13465748, 13429462, - 13393273, 13357183, 13321189, 13285292, 13249492, 13213789, 13178182, 13142670, 13107255, 13071934, 13036709, - 13001579, 12966544, 12931603, 12896756, 12862003, 12827344, 12792778, 12758305, 12723925, 12689638, 12655443, - 12621341, 12587330, 12553411, 12519583, 12485846, 12452201, 12418646, 12385181, 12351807, 12318522, 12285327, - 12252222, 12219206, 12186279, 12153440, 12120690, 12088029, 12055455, 12022969, 11990571, 11958260, 11926036, - 11893899, 11861848, 11829884, 11798006, 11766214, 11734507, 11702886, 11671350, 11639900, 11608533, 11577252, - 11546055, 11514941, 11483912, 11452966, 11422104, 11391325, 11360628, 11330015, 11299484, 11269035, 11238668, - 11208384, 11178180, 11148058, 11118018, 11088058, 11058179, 11028380, 10998662, 10969024, 10939466, 10909987, - 10880588, 10851268, 10822027, 10792865, 10763781, 10734776, 10705849, 10677000, 10648228, 10619535, 10590918, - 10562379, 10533916, 10505530, 10477221, 10448988, 10420831, 10392750, 10364745, 10336815, 10308960, 10281180, - 10253476, 10225846, 10198290, 10170809, 10143401, 10116068, 10088808, 10061622, 10034509, 10007468, 9980501, - 9953607, 9926785, 9900035, 9873357, 9846752, 9820217, 9793755, 9767364, 9741043, 9714794, 9688616, - 9662508, 9636470, 9610503, 9584605, 9558778, 9533019, 9507331, 9481711, 9456161, 9430679, 9405266, - 9379922, 9354646, 9329438, 9304298, 9279225, 9254221, 9229283, 9204413, 9179610, 9154874, 9130204, - 9105601, 9081064, 9056593, 9032188, 9007849, 8983576, 8959368, 8935225, 8911147, 8887134, 8863186, - 8839302, 8815483, 8791728, 8768037, 8744409, 8720846, 8697346, 8673909, 8650535, 8627225, 8603977, - 8580792, 8557669, 8534608, 8511610, 8488674, 8465799, 8442987, 8420235, 8397545, 8374916, 8352348, - 8329841, 8307395, 8285009, 8262683, 8240418, 8218212, 8196067, 8173981, 8151954, 8129987, 8108079, - 8086230, 8064440, 8042709, 8021036, 7999422, 7977866, 7956368, 7934928, 7913545, 7892221, 7870954, - 7849744, 7828591, 7807495, 7786456, 7765474, 7744548, 7723679, 7702866, 7682109, 7661408, 7640763, - 7620173, 7599639, 7579160, 7558737, 7538368, 7518055, 7497796, 7477591, 7457441, 7437346, 7417304, - 7397317, 7377383, 7357503, 7337677, 7317904, 7298185, 7278518, 7258905, 7239344, 7219836, 7200381, - 7180978, 7161627, 7142329, 7123082, 7103888, 7084745, 7065654, 7046614, 7027625, 7008688, 6989802, - 6970966, 6952181, 6933447, 6914764, 6896130, 6877547, 6859014, 6840531, 6822098, 6803715, 6785381, - 6767096, 6748861, 6730675, 6712537, 6694449, 6676410, 6658419, 6640476, 6622582, 6604736, 6586938, - 6569188, 6551486, 6533832, 6516225, 6498666, 6481154, 6463689, 6446272, 6428901, 6411577, 6394299, - 6377069, 6359884, 6342746, 6325655, 6308609, 6291609, 6274655, 6257747, 6240884, 6224066, 6207294, - 6190568, 6173886, 6157249, 6140657, 6124110, 6107607, 6091149, 6074735, 6058365, 6042040, 6025758, - 6009521, 5993327, 5977177, 5961070, 5945007, 5928987, 5913010, 5897076, 5881185, 5865337, 5849532, - 5833769, 5818049, 5802371, 5786735, 5771141, 5755590, 5740080, 5724612, 5709186, 5693802, 5678459, - 5663157, 5647896, 5632677, 5617498, 5602361, 5587264, 5572208, 5557193, 5542218, 5527283, 5512389, - 5497534, 5482720, 5467946, 5453211, 5438517, 5423861, 5409246, 5394669, 5380132, 5365635, 5351176, - 5336756, 5322375, 5308033, 5293729, 5279464, 5265237, 5251049, 5236899, 5222787, 5208713, 5194677, - 5180679, 5166719, 5152796, 5138911, 5125063, 5111252, 5097479, 5083743, 5070044, 5056382, 5042756, - 5029167, 5015615, 5002100, 4988620, 4975178, 4961771, 4948400, 4935066, 4921767, 4908505, 4895278, - 4882086, 4868931, 4855810, 4842725, 4829676, 4816661, 4803682, 4790737, 4777827, 4764953, 4752112, - 4739307, 4726536, 4713799, 4701097, 4688429, 4675795, 4663195, 4650629, 4638097, 4625599, 4613134, - 4600703, 4588306, 4575941, 4563611, 4551313, 4539049, 4526817, 4514619, 4502453, 4490320, 4478220, - 4466153, 4454118, 4442115, 4430145, 4418207, 4406301, 4394428, 4382586, 4370776, 4358998, 4347252, - 4335538, 4323855, 4312203, 4300583, 4288994, 4277437, 4265910, 4254415, 4242950, 4231517, 4220114, - 4208742, 4197401, 4186090, 4174810, 4163560, 4152340, 4141151, 4129992, 4118863, 4107764, 4096694, - 4085655, 4074645, 4063665, 4052715, 4041794, 4030903, 4020041, 4009208, 3998404, 3987630, 3976884, - 3966168, 3955480, 3944821, 3934191, 3923590, 3913017, 3902472, 3891956, 3881469, 3871009, 3860578, - 3850175, 3839800, 3829453, 3819133, 3808842, 3798578, 3788342, 3778134, 3767953, 3757799, 3747673, - 3737574, 3727503, 3717458, 3707441, 3697450, 3687487, 3677550, 3667640, 3657757, 3647900, 3638070, - 3628267, 3618490, 3608739, 3599014, 3589316, 3579644, 3569998, 3560378, 3550783, 3541215, 3531673, - 3522156, 3512665, 3503199, 3493759, 3484344, 3474955, 3465591, 3456252, 3446939, 3437650, 3428387, - 3419148, 3409935, 3400746, 3391582, 3382443, 3373328, 3364238, 3355172, 3346131, 3337114, 3328122, - 3319153, 3310209, 3301289, 3292393, 3283521, 3274673, 3265849, 3257048, 3248271, 3239518, 3230789, - 3222083, 3213400, 3204741, 3196105, 3187493, 3178903, 3170337, 3161794, 3153274, 3144777, 3136302, - 3127851, 3119422, 3111016, 3102633, 3094272, 3085934, 3077619, 3069325, 3061054, 3052806, 3044579, - 3036375, 3028193, 3020033, 3011895, 3003779, 2995684, 2987612, 2979561, 2971532, 2963525, 2955539, - 2947575, 2939632, 2931710, 2923810, 2915931, 2908074, 2900237, 2892422, 2884628, 2876855, 2869102, - 2861371, 2853660, 2845971, 2838302, 2830653, 2823025, 2815418, 2807832, 2800265, 2792719, 2785194, - 2777689, 2770203, 2762739, 2755294, 2747869, 2740464, 2733080, 2725715, 2718370, 2711045, 2703739, - 2696453, 2689187, 2681941, 2674714, 2667506, 2660318, 2653149, 2646000, 2638870, 2631759, 2624667, - 2617594, 2610540, 2603506, 2596490, 2589493, 2582515, 2575556, 2568616, 2561694, 2554791, 2547907, - 2541041, 2534194, 2527365, 2520554, 2513762, 2506988, 2500233, 2493495, 2486776, 2480075, 2473392, - 2466727, 2460080, 2453450, 2446839, 2440246, 2433670, 2427112, 2420571, 2414049, 2407544, 2401056, - 2394586, 2388133, 2381698, 2375280, 2368879, 2362496, 2356130, 2349780, 2343448, 2337134, 2330836, - 2324555, 2318291, 2312044, 2305813, 2299600, 2293403, 2287223, 2281060, 2274913, 2268783, 2262669, - 2256572, 2250491, 2244427, 2238379, 2232347, 2226331, 2220332, 2214349, 2208382, 2202431, 2196496, - 2190577, 2184674, 2178787, 2172916, 2167060, 2161221, 2155397, 2149589, 2143796, 2138019, 2132258, - 2126512, 2120782, 2115067, 2109368, 2103683, 2098015, 2092361, 2086723, 2081100, 2075492, 2069899, - 2064321, 2058758, 2053211, 2047678, 2042160, 2036657, 2031169, 2025695, 2020237, 2014793, 2009364, - 2003949, 1998549, 1993163, 1987792, 1982436, 1977094, 1971766, 1966453, 1961154, 1955869, 1950599, - 1945342, 1940100, 1934872, 1929658, 1924458, 1919272, 1914101, 1908943, 1903799, 1898668, 1893552, - 1888450, 1883361, 1878286, 1873224, 1868176, 1863142, 1858122, 1853115, 1848121, 1843141, 1838174, - 1833221, 1828281, 1823354, 1818441, 1813540, 1808654, 1803780, 1798919, 1794072, 1789237, 1784416, - 1779607, 1774812, 1770029, 1765259, 1760502, 1755758, 1751027, 1746309, 1741603, 1736910, 1732229, - 1727561, 1722906, 1718263, 1713633, 1709015, 1704410, 1699817, 1695237, 1690669, 1686113, 1681569, - 1677038, 1672519, 1668012, 1663517, 1659034, 1654564, 1650105, 1645659, 1641224, 1636801, 1632391, - 1627992, 1623605, 1619230, 1614866, 1610515, 1606175, 1601847, 1597530, 1593225, 1588932, 1584650, - 1580380, 1576122, 1571874, 1567639, 1563414, 1559201, 1555000, 1550810, 1546631, 1542463, 1538306, - 1534161, 1530027, 1525904, 1521792, 1517691, 1513602, 1509523, 1505455, 1501399, 1497353, 1493318, - 1489294, 1485281, 1481278, 1477287, 1473306, 1469336, 1465376, 1461427, 1457489, 1453562, 1449645, - 1445738, 1441843, 1437957, 1434082, 1430218, 1426364, 1422520, 1418687, 1414864, 1411051, 1407249, - 1403457, 1399675, 1395903, 1392142, 1388390, 1384649, 1380918, 1377197, 1373486, 1369784, 1366093, - 1362412, 1358741, 1355079, 1351428, 1347786, 1344154, 1340532, 1336920, 1333317, 1329724, 1326141, - 1322567, 1319004, 1315449, 1311904, 1308369, 1304844, 1301327, 1297821, 1294323, 1290836, 1287357, - 1283888, 1280429, 1276978, 1273537, 1270105, 1266683, 1263269, 1259865, 1256470, 1253084, 1249708, - 1246340, 1242982, 1239632, 1236292, 1232960, 1229638, 1226324, 1223020, 1219724, 1216437, 1213159, - 1209890, 1206630, 1203378, 1200136, 1196902, 1193676, 1190460, 1187252, 1184052, 1180862, 1177680, - 1174506, 1171341, 1168185, 1165037, 1161897, 1158767, 1155644, 1152530, 1149424, 1146327, 1143238, - 1140157, 1137085, 1134021, 1130965, 1127917, 1124878, 1121846, 1118823, 1115809, 1112802, 1109803, - 1106813, 1103830, 1100855, 1097889, 1094931, 1091980, 1089037, 1086103, 1083176, 1080257, 1077346, - 1074443, 1071548, 1068660, 1065781, 1062909, 1060044, 1057188, 1054339, 1051498, 1048664, 1045839, - 1043020, 1040210, 1037407, 1034611, 1031823, 1029043, 1026270, 1023504, 1020746, 1017996, 1015252, - 1012517, 1009788, 1007067, 1004353, 1001647, 998948, 996256, 993571, 990894, 988224, 985561, - 982905, 980256, 977615, 974980, 972353, 969733, 967120, 964514, 961915, 959323, 956737, - 954159, 951588, 949024, 946467, 943916, 941373, 938836, 936306, 933783, 931267, 928757, - 926254, 923758, 921269, 918787, 916311, 913842, 911379, 908923, 906474, 904031, 901595, - 899166, 896743, 894326, 891916, 889513, 887116, 884725, 882341, 879963, 877592, 875227, - 872869, 870517, 868171, 865831, 863498, 861171, 858851, 856536, 854228, 851926, 849631, - 847341, 845058, 842781, 840510, 838245, 835986, 833733, 831487, 829246, 827011, 824783, - 822560, 820344, 818133, 815929, 813730, 811537, 809350, 807169, 804994, 802825, 800662, - 798504, 796352, 794206, 792066, 789932, 787803, 785680, 783563, 781452, 779346, 777246, - 775151, 773062, 770979, 768902, 766830, 764763, 762703, 760647, 758598, 756553, 754515, - 752482, 750454, 748432, 746415, 744403, 742397, 740397, 738402, 736412, 734428, 732448, - 730475, 728506, 726543, 724585, 722633, 720686, 718744, 716807, 714875, 712949, 711028, - 709112, 707201, 705295, 703394, 701499, 699609, 697723, 695843, 693968, 692098, 690233, - 688373, 686518, 684668, 682823, 680983, 679148, 677318, 675493, 673673, 671857, 670047, - 668241, 666441, 664645, 662854, 661067, 659286, 657510, 655738, 653971, 652208, 650451, - 648698, 646950, 645207, 643468, 641734, 640005, 638280, 636560, 634845, 633134, 631428, - 629727, 628030, 626337, 624650, 622966, 621288, 619613, 617944, 616279, 614618, 612962, - 611310, 609663, 608020, 606381, 604747, 603118, 601492, 599872, 598255, 596643, 595035, - 593432, 591833, 590238, 588647, 587061, 585479, 583901, 582328, 580759, 579194, 577633, - 576076, 574524, 572976, 571432, 569892, 568356, 566825, 565297, 563774, 562255, 560740, - 559229, 557722, 556219, 554720, 553225, 551734, 550248, 548765, 547286, 545811, 544341, - 542874, 541411, 539952, 538497, 537046, 535599, 534155, 532716, 531280, 529849, 528421, - 526997, 525577, 524161, 522748, 521340, 519935, 518534, 517136, 515743, 514353, 512967, - 511585, 510206, 508831, 507460, 506093, 504729, 503369, 502012, 500660, 499310, 497965, - 496623, 495285, 493950, 492619, 491292, 489968, 488648, 487331, 486018, 484708, 483402, - 482099, 480800, 479504, 478212, 476924, 475638, 474357, 473078, 471804, 470532, 469264, - 468000, 466739, 465481, 464227, 462976, 461728, 460484, 459243, 458005, 456771, 455540, - 454313, 453089, 451868, 450650, 449436, 448225, 447017, 445812, 444611, 443413, 442218, - 441026, 439838, 438653, 437470, 436292, 435116, 433943, 432774, 431608, 430445, 429285, - 428128, 426974, 425824, 424676, 423532, 422391, 421252, 420117, 418985, 417856, 416730, - 415607, 414487, 413370, 412256, 411146, 410038, 408933, 407831, 406732, 405636, 404543, - 403453, 402365, 401281, 400200, 399121, 398046, 396973, 395903, 394837, 393773, 392712, - 391653, 390598, 389545, 388496, 387449, 386405, 385363, 384325, 383289, 382257, 381226, - 380199, 379175, 378153, 377134, 376118, 375104, 374093, 373085, 372080, 371077, 370077, - 369080, 368085, 367094, 366104, 365118, 364134, 363153, 362174, 361198, 360225, 359254, - 358286, 357321, 356358, 355397, 354440, 353485, 352532, 351582, 350635, 349690, 348748, - 347808, 346871, 345936, 345004, 344074, 343147, 342222, 341300, 340380, 339463, 338548, - 337636, 336726, 335819, 334914, 334011, 333111, 332214, 331318, 330426, 329535, 328647, - 327762, 326878, 325997, 325119, 324243, 323369, 322498, 321629, 320762, 319898, 319036, - 318176, 317319, 316463, 315611, 314760, 313912, 313066, 312222, 311381, 310542, 309705, - 308871, 308038, 307208, 306380, 305555, 304731, 303910, 303091, 302275, 301460, 300648, - 299838, 299030, 298224, 297420, 296619, 295819, 295022, 294227, 293434, 292644, 291855, - 291069, 290284, 289502, 288722, 287944, 287168, 286394, 285622, 284853, 284085, 283320, - 282556, 281795, 281035, 280278, 279523, 278770, 278018, 277269, 276522, 275777, 275034, - 274293, 273553, 272816, 272081, 271348, 270617, 269888, 269160, 268435, 267712, 266990, - 266271, 265553, 264838, 264124, 263412, 262702, 261994, 261289, 260584, 259882, 259182, - 258483, 257787, 257092, 256399, 255709, 255020, 254332, 253647, 252963, 252282, 251602, - 250924, 250248, 249573, 248901, 248230, 247561, 246894, 246229, 245565, 244904, 244244, - 243586, 242929, 242275, 241622, 240971, 240321, 239674, 239028, 238384, 237741, 237101, - 236462, 235825, 235189, 234555, 233923, 233293, 232664, 232037, 231412, 230788, 230166, - 229546, 228928, 228311, 227696, 227082, 226470, 225860, 225251, 224644, 224039, 223435, - 222833, 222233, 221634, 221036, 220441, 219847, 219254, 218664, 218074, 217487, 216901, - 216316, 215733, 215152, 214572, 213994, 213417, 212842, 212269, 211697, 211126, 210557, - 209990, 209424, 208860, 208297, 207735, 207176, 206617, 206061, 205505, 204952, 204399, - 203849, 203299, 202751, 202205, 201660, 201117, 200575, 200034, 199495, 198958, 198422, - 197887, 197354, 196822, 196291, 195762, 195235, 194709, 194184, 193661, 193139, 192619, - 192100, 191582, 191066, 190551, 190037, 189525, 189014, 188505, 187997, 187491, 186985, - 186481, 185979, 185478, 184978, 184479, 183982, 183487, 182992, 182499, 182007, 181517, - 181028, 180540, 180053, 179568, 179084, 178602, 178120, 177640, 177162, 176684, 176208, - 175733, 175260, 174788, 174317, 173847, 173378, 172911, 172445, 171981, 171517, 171055, - 170594, 170134, 169676, 169219, 168763, 168308, 167854, 167402, 166951, 166501, 166052, - 165605, 165159, 164713, 164270, 163827, 163386, 162945, 162506, 162068, 161632, 161196, - 160762, 160328, 159896, 159465, 159036, 158607, 158180, 157754, 157328, 156904, 156482, - 156060, 155639, 155220, 154802, 154385, 153969, 153554, 153140, 152727, 152316, 151905, - 151496, 151088, 150681, 150275, 149870, 149466, 149063, 148661, 148261, 147861, 147463, - 147065, 146669, 146274, 145880, 145487, 145094, 144703, 144314, 143925, 143537, 143150, - 142764, 142380, 141996, 141613, 141232, 140851, 140472, 140093, 139715, 139339, 138964, - 138589, 138216, 137843, 137472, 137101, 136732, 136363, 135996, 135629, 135264, 134899, - 134536, 134173, 133812, 133451, 133092, 132733, 132375, 132019, 131663, 131308, 130954, - 130601, 130249, 129898, 129548, 129199, 128851, 128504, 128158, 127812, 127468, 127124, - 126782, 126440, 126099, 125760, 125421, 125083, 124746, 124410, 124074, 123740, 123407, - 123074, 122742, 122412, 122082, 121753, 121425, 121097, 120771, 120446, 120121, 119797, - 119475, 119153, 118832, 118511, 118192, 117873, 117556, 117239, 116923, 116608, 116294, - 115980, 115668, 115356, 115045, 114735, 114426, 114118, 113810, 113504, 113198, 112893, - 112589, 112285, 111983, 111681, 111380, 111080, 110780, 110482, 110184, 109887, 109591, - 109296, 109001, 108708, 108415, 108122, 107831, 107541, 107251, 106962, 106674, 106386, - 106099, 105813, 105528, 105244, 104960, 104678, 104395, 104114, 103834, 103554, 103275, - 102996, 102719, 102442, 102166, 101891, 101616, 101342, 101069, 100797, 100525, 100254, - 99984, 99715, 99446, 99178, 98911, 98644, 98378, 98113, 97849, 97585, 97322, - 97060, 96799, 96538, 96278, 96018, 95759, 95501, 95244, 94987, 94731, 94476, - 94222, 93968, 93714, 93462, 93210, 92959, 92708, 92459, 92209, 91961, 91713, - 91466, 91219, 90974, 90729, 90484, 90240, 89997, 89754, 89513, 89271, 89031, - 88791, 88552, 88313, 88075, 87838, 87601, 87365, 87130, 86895, 86661, 86427, - 86194, 85962, 85730, 85499, 85269, 85039, 84810, 84581, 84353, 84126, 83899, - 83673, 83448, 83223, 82999, 82775, 82552, 82330, 82108, 81886, 81666, 81446, - 81226, 81007, 80789, 80571, 80354, 80138, 79922, 79706, 79492, 79277, 79064, - 78851, 78638, 78426, 78215, 78004, 77794, 77584, 77375, 77167, 76959, 76752, - 76545, 76338, 76133, 75928, 75723, 75519, 75315, 75112, 74910, 74708, 74507, - 74306, 74106, 73906, 73707, 73508, 73310, 73113, 72916, 72719, 72523, 72328, - 72133, 71939, 71745, 71551, 71359, 71166, 70975, 70783, 70593, 70402, 70213, - 70023, 69835, 69646, 69459, 69272, 69085, 68899, 68713, 68528, 68343, 68159, - 67975, 67792, 67610, 67427, 67246, 67065, 66884, 66704, 66524, 66345, 66166, - 65987, 65810, 65632, 65455, 65279, 65103, 64928, 64753, 64578, 64404, 64231, - 64058, 63885, 63713, 63541, 63370, 63199, 63029, 62859, 62690, 62521, 62352, - 62184, 62017, 61850, 61683, 61517, 61351, 61186, 61021, 60856, 60692, 60529, - 60366, 60203, 60041, 59879, 59718, 59557, 59396, 59236, 59076, 58917, 58758, - 58600, 58442, 58285, 58128, 57971, 57815, 57659, 57504, 57349, 57194, 57040, - 56886, 56733, 56580, 56428, 56276, 56124, 55973, 55822, 55671, 55521, 55372, - 55223, 55074, 54925, 54777, 54630, 54483, 54336, 54189, 54043, 53898, 53752, - 53608, 53463, 53319, 53175, 53032, 52889, 52747, 52605, 52463, 52321, 52180, - 52040, 51900, 51760, 51620, 51481, 51342, 51204, 51066, 50928, 50791, 50654, - 50518, 50382, 50246, 50111, 49976, 49841, 49707, 49573, 49439, 49306, 49173, - 49040, 48908, 48776, 48645, 48514, 48383, 48253, 48123, 47993, 47864, 47735, - 47606, 47478, 47350, 47222, 47095, 46968, 46842, 46715, 46590, 46464, 46339, - 46214, 46089, 45965, 45841, 45718, 45595, 45472, 45349, 45227, 45105, 44984, - 44862, 44741, 44621, 44501, 44381, 44261, 44142, 44023, 43904, 43786, 43668, - 43550, 43433, 43316, 43199, 43083, 42967, 42851, 42735, 42620, 42505, 42391, - 42277, 42163, 42049, 41936, 41823, 41710, 41598, 41486, 41374, 41262, 41151, - 41040, 40930, 40819, 40709, 40600, 40490, 40381, 40272, 40164, 40056, 39948, - 39840, 39733, 39626, 39519, 39412, 39306, 39200, 39094, 38989, 38884, 38779, - 38675, 38571, 38467, 38363, 38260, 38157, 38054, 37951, 37849, 37747, 37645, - 37544, 37443, 37342, 37241, 37141, 37041, 36941, 36841, 36742, 36643, 36544, - 36446, 36347, 36250, 36152, 36054, 35957, 35860, 35764, 35667, 35571, 35475, - 35380, 35284, 35189, 35095, 35000, 34906, 34812, 34718, 34624, 34531, 34438, - 34345, 34253, 34160, 34068, 33976, 33885 -}; - -static const short sindb_coeff[] = { - 2401, 2144, 1994, 1887, 1804, 1737, 1680, 1630, 1587, 1548, 1512, 1480, 1450, - 1423, 1397, 1373, 1351, 1330, 1310, 1291, 1273, 1255, 1239, 1223, 1208, 1194, - 1180, 1166, 1153, 1141, 1128, 1117, 1105, 1094, 1084, 1073, 1063, 1053, 1043, - 1034, 1025, 1016, 1007, 999, 990, 982, 974, 967, 959, 952, 944, 937, - 930, 923, 916, 910, 903, 897, 890, 884, 878, 872, 866, 860, 855, - 849, 843, 838, 832, 827, 822, 817, 812, 807, 802, 797, 792, 787, - 783, 778, 773, 769, 764, 760, 756, 751, 747, 743, 739, 734, 730, - 726, 722, 718, 715, 711, 707, 703, 699, 696, 692, 688, 685, 681, - 678, 674, 671, 667, 664, 661, 657, 654, 651, 648, 644, 641, 638, - 635, 632, 629, 626, 623, 620, 617, 614, 611, 608, 605, 602, 599, - 597, 594, 591, 588, 586, 583, 580, 578, 575, 572, 570, 567, 565, - 562, 560, 557, 555, 552, 550, 547, 545, 542, 540, 538, 535, 533, - 531, 528, 526, 524, 522, 519, 517, 515, 513, 510, 508, 506, 504, - 502, 500, 498, 495, 493, 491, 489, 487, 485, 483, 481, 479, 477, - 475, 473, 471, 469, 467, 465, 464, 462, 460, 458, 456, 454, 452, - 450, 449, 447, 445, 443, 441, 440, 438, 436, 434, 433, 431, 429, - 427, 426, 424, 422, 421, 419, 417, 416, 414, 412, 411, 409, 408, - 406, 404, 403, 401, 400, 398, 396, 395, 393, 392, 390, 389, 387, - 386, 384, 383, 381, 380, 378, 377, 375, 374, 372, 371, 370, 368, - 367, 365, 364, 362, 361, 360, 358, 357, 355, 354, 353, 351, 350, - 349, 347, 346, 345, 343, 342, 341, 339, 338, 337, 336, 334, 333, - 332, 330, 329, 328, 327, 325, 324, 323, 322, 320, 319, 318, 317, - 316, 314, 313, 312, 311, 310, 308, 307, 306, 305, 304, 303, 301, - 300, 299, 298, 297, 296, 295, 293, 292, 291, 290, 289, 288, 287, - 286, 285, 284, 282, 281, 280, 279, 278, 277, 276, 275, 274, 273, - 272, 271, 270, 269, 268, 267, 266, 265, 264, 263, 262, 261, 260, - 259, 258, 257, 256, 255, 254, 253, 252, 251, 250, 249, 248, 247, - 246, 245, 244, 243, 242, 241, 240, 240, 239, 238, 237, 236, 235, - 234, 233, 232, 231, 230, 230, 229, 228, 227, 226, 225, 224, 223, - 222, 222, 221, 220, 219, 218, 217, 216, 216, 215, 214, 213, 212, - 211, 211, 210, 209, 208, 207, 206, 206, 205, 204, 203, 202, 202, - 201, 200, 199, 198, 198, 197, 196, 195, 195, 194, 193, 192, 191, - 191, 190, 189, 188, 188, 187, 186, 185, 185, 184, 183, 182, 182, - 181, 180, 180, 179, 178, 177, 177, 176, 175, 174, 174, 173, 172, - 172, 171, 170, 170, 169, 168, 167, 167, 166, 165, 165, 164, 163, - 163, 162, 161, 161, 160, 159, 159, 158, 157, 157, 156, 155, 155, - 154, 153, 153, 152, 151, 151, 150, 150, 149, 148, 148, 147, 146, - 146, 145, 145, 144, 143, 143, 142, 141, 141, 140, 140, 139, 138, - 138, 137, 137, 136, 135, 135, 134, 134, 133, 133, 132, 131, 131, - 130, 130, 129, 129, 128, 127, 127, 126, 126, 125, 125, 124, 123, - 123, 122, 122, 121, 121, 120, 120, 119, 119, 118, 117, 117, 116, - 116, 115, 115, 114, 114, 113, 113, 112, 112, 111, 111, 110, 110, - 109, 109, 108, 108, 107, 107, 106, 106, 105, 105, 104, 104, 103, - 103, 102, 102, 101, 101, 100, 100, 99, 99, 98, 98, 97, 97, - 96, 96, 95, 95, 94, 94, 94, 93, 93, 92, 92, 91, 91, - 90, 90, 89, 89, 89, 88, 88, 87, 87, 86, 86, 85, 85, - 85, 84, 84, 83, 83, 82, 82, 82, 81, 81, 80, 80, 79, - 79, 79, 78, 78, 77, 77, 77, 76, 76, 75, 75, 75, 74, - 74, 73, 73, 73, 72, 72, 71, 71, 71, 70, 70, 69, 69, - 69, 68, 68, 68, 67, 67, 66, 66, 66, 65, 65, 65, 64, - 64, 63, 63, 63, 62, 62, 62, 61, 61, 61, 60, 60, 59, - 59, 59, 58, 58, 58, 57, 57, 57, 56, 56, 56, 55, 55, - 55, 54, 54, 54, 53, 53, 53, 52, 52, 52, 51, 51, 51, - 50, 50, 50, 49, 49, 49, 49, 48, 48, 48, 47, 47, 47, - 46, 46, 46, 45, 45, 45, 45, 44, 44, 44, 43, 43, 43, - 43, 42, 42, 42, 41, 41, 41, 40, 40, 40, 40, 39, 39, - 39, 39, 38, 38, 38, 37, 37, 37, 37, 36, 36, 36, 36, - 35, 35, 35, 35, 34, 34, 34, 34, 33, 33, 33, 32, 32, - 32, 32, 31, 31, 31, 31, 31, 30, 30, 30, 30, 29, 29, - 29, 29, 28, 28, 28, 28, 27, 27, 27, 27, 27, 26, 26, - 26, 26, 25, 25, 25, 25, 25, 24, 24, 24, 24, 23, 23, - 23, 23, 23, 22, 22, 22, 22, 22, 21, 21, 21, 21, 21, - 20, 20, 20, 20, 20, 19, 19, 19, 19, 19, 19, 18, 18, - 18, 18, 18, 17, 17, 17, 17, 17, 17, 16, 16, 16, 16, - 16, 15, 15, 15, 15, 15, 15, 14, 14, 14, 14, 14, 14, - 13, 13, 13, 13, 13, 13, 13, 12, 12, 12, 12, 12, 12, - 11, 11, 11, 11, 11, 11, 11, 10, 10, 10, 10, 10, 10, - 10, 10, 9, 9, 9, 9, 9, 9, 9, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 7, 7, 7, 7, 7, 7, 7, 7, - 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 -}; - - -static const short lfo_freq_coeff[] = { - 0, 3, 6, 9, 12, 15, 18, 21, 25, 28, 31, 34, 37, - 40, 43, 46, 50, 53, 56, 59, 62, 65, 68, 71, 74, 78, - 81, 84, 87, 90, 93, 96, 99, 102, 105, 108, 111, 115, 118, - 121, 124, 127, 130, 133, 136, 139, 142, 145, 148, 151, 154, 157, - 160, 163, 166, 169, 172, 175, 178, 180, 183, 186, 189, 192, 195, - 198, 201, 204, 207, 209, 212, 215, 218, 221, 224, 226, 229, 232, - 235, 238, 240, 243, 246, 249, 251, 254, 257, 260, 262, 265, 268, - 270, 273, 276, 278, 281, 283, 286, 289, 291, 294, 296, 299, 301, - 304, 306, 309, 311, 314, 316, 319, 321, 324, 326, 328, 331, 333, - 336, 338, 340, 343, 345, 347, 350, 352, 354, 356, 359, 361, 363, - 365, 367, 370, 372, 374, 376, 378, 380, 382, 384, 386, 388, 391, - 393, 395, 396, 398, 400, 402, 404, 406, 408, 410, 412, 414, 415, - 417, 419, 421, 423, 424, 426, 428, 430, 431, 433, 435, 436, 438, - 439, 441, 443, 444, 446, 447, 449, 450, 452, 453, 455, 456, 457, - 459, 460, 461, 463, 464, 465, 467, 468, 469, 470, 472, 473, 474, - 475, 476, 477, 478, 480, 481, 482, 483, 484, 485, 486, 487, 488, - 488, 489, 490, 491, 492, 493, 494, 494, 495, 496, 497, 497, 498, - 499, 499, 500, 501, 501, 502, 502, 503, 504, 504, 504, 505, 505, - 506, 506, 507, 507, 507, 508, 508, 508, 509, 509, 509, 509, 510, - 510, 510, 510, 510, 510, 510, 510, 510, 510, 511, 510, 510, 510, - 510, 510, 510, 510, 510, 510, 510, 509, 509, 509, 509, 508, 508, - 508, 507, 507, 507, 506, 506, 505, 505, 504, 504, 504, 503, 502, - 502, 501, 501, 500, 499, 499, 498, 497, 497, 496, 495, 494, 494, - 493, 492, 491, 490, 489, 488, 488, 487, 486, 485, 484, 483, 482, - 481, 480, 478, 477, 476, 475, 474, 473, 472, 470, 469, 468, 467, - 465, 464, 463, 461, 460, 459, 457, 456, 455, 453, 452, 450, 449, - 447, 446, 444, 443, 441, 439, 438, 436, 435, 433, 431, 430, 428, - 426, 424, 423, 421, 419, 417, 415, 414, 412, 410, 408, 406, 404, - 402, 400, 398, 396, 395, 393, 391, 388, 386, 384, 382, 380, 378, - 376, 374, 372, 370, 367, 365, 363, 361, 359, 356, 354, 352, 350, - 347, 345, 343, 340, 338, 336, 333, 331, 328, 326, 324, 321, 319, - 316, 314, 311, 309, 306, 304, 301, 299, 296, 294, 291, 289, 286, - 283, 281, 278, 276, 273, 270, 268, 265, 262, 260, 257, 254, 251, - 249, 246, 243, 240, 238, 235, 232, 229, 226, 224, 221, 218, 215, - 212, 209, 207, 204, 201, 198, 195, 192, 189, 186, 183, 180, 178, - 175, 172, 169, 166, 163, 160, 157, 154, 151, 148, 145, 142, 139, - 136, 133, 130, 127, 124, 121, 118, 115, 111, 108, 105, 102, 99, - 96, 93, 90, 87, 84, 81, 78, 74, 71, 68, 65, 62, 59, - 56, 53, 50, 46, 43, 40, 37, 34, 31, 28, 25, 21, 18, - 15, 12, 9, 6, 3, 0, -3, -6, -9, -12, -15, -18, -21, - -25, -28, -31, -34, -37, -40, -43, -46, -50, -53, -56, -59, -62, - -65, -68, -71, -74, -78, -81, -84, -87, -90, -93, -96, -99, -102, - -105, -108, -111, -115, -118, -121, -124, -127, -130, -133, -136, -139, -142, - -145, -148, -151, -154, -157, -160, -163, -166, -169, -172, -175, -178, -180, - -183, -186, -189, -192, -195, -198, -201, -204, -207, -209, -212, -215, -218, - -221, -224, -226, -229, -232, -235, -238, -240, -243, -246, -249, -251, -254, - -257, -260, -262, -265, -268, -270, -273, -276, -278, -281, -283, -286, -289, - -291, -294, -296, -299, -301, -304, -306, -309, -311, -314, -316, -319, -321, - -324, -326, -328, -331, -333, -336, -338, -340, -343, -345, -347, -350, -352, - -354, -356, -359, -361, -363, -365, -367, -370, -372, -374, -376, -378, -380, - -382, -384, -386, -388, -391, -393, -395, -396, -398, -400, -402, -404, -406, - -408, -410, -412, -414, -415, -417, -419, -421, -423, -424, -426, -428, -430, - -431, -433, -435, -436, -438, -439, -441, -443, -444, -446, -447, -449, -450, - -452, -453, -455, -456, -457, -459, -460, -461, -463, -464, -465, -467, -468, - -469, -470, -472, -473, -474, -475, -476, -477, -478, -480, -481, -482, -483, - -484, -485, -486, -487, -488, -488, -489, -490, -491, -492, -493, -494, -494, - -495, -496, -497, -497, -498, -499, -499, -500, -501, -501, -502, -502, -503, - -504, -504, -504, -505, -505, -506, -506, -507, -507, -507, -508, -508, -508, - -509, -509, -509, -509, -510, -510, -510, -510, -510, -510, -510, -510, -510, - -510, -511, -510, -510, -510, -510, -510, -510, -510, -510, -510, -510, -509, - -509, -509, -509, -508, -508, -508, -507, -507, -507, -506, -506, -505, -505, - -504, -504, -504, -503, -502, -502, -501, -501, -500, -499, -499, -498, -497, - -497, -496, -495, -494, -494, -493, -492, -491, -490, -489, -488, -488, -487, - -486, -485, -484, -483, -482, -481, -480, -478, -477, -476, -475, -474, -473, - -472, -470, -469, -468, -467, -465, -464, -463, -461, -460, -459, -457, -456, - -455, -453, -452, -450, -449, -447, -446, -444, -443, -441, -439, -438, -436, - -435, -433, -431, -430, -428, -426, -424, -423, -421, -419, -417, -415, -414, - -412, -410, -408, -406, -404, -402, -400, -398, -396, -395, -393, -391, -388, - -386, -384, -382, -380, -378, -376, -374, -372, -370, -367, -365, -363, -361, - -359, -356, -354, -352, -350, -347, -345, -343, -340, -338, -336, -333, -331, - -328, -326, -324, -321, -319, -316, -314, -311, -309, -306, -304, -301, -299, - -296, -294, -291, -289, -286, -283, -281, -278, -276, -273, -270, -268, -265, - -262, -260, -257, -254, -251, -249, -246, -243, -240, -238, -235, -232, -229, - -226, -224, -221, -218, -215, -212, -209, -207, -204, -201, -198, -195, -192, - -189, -186, -183, -180, -178, -175, -172, -169, -166, -163, -160, -157, -154, - -151, -148, -145, -142, -139, -136, -133, -130, -127, -124, -121, -118, -115, - -111, -108, -105, -102, -99, -96, -93, -90, -87, -84, -81, -78, -74, - -71, -68, -65, -62, -59, -56, -53, -50, -46, -43, -40, -37, -34, - -31, -28, -25, -21, -18, -15, -12, -9, -6, -3 -}; - -static const short lfo_env_coeff[] = { - 251, 253, 254, 256, 257, 259, 260, 262, 264, 265, 267, 268, 270, - 271, 273, 274, 276, 277, 279, 281, 282, 284, 285, 287, 288, 290, - 291, 293, 294, 296, 297, 299, 300, 302, 303, 305, 306, 308, 309, - 311, 312, 314, 315, 317, 318, 320, 321, 323, 324, 326, 327, 329, - 330, 332, 333, 335, 336, 337, 339, 340, 342, 343, 345, 346, 348, - 349, 350, 352, 353, 355, 356, 357, 359, 360, 362, 363, 364, 366, - 367, 369, 370, 371, 373, 374, 375, 377, 378, 379, 381, 382, 383, - 385, 386, 387, 389, 390, 391, 392, 394, 395, 396, 397, 399, 400, - 401, 402, 404, 405, 406, 407, 409, 410, 411, 412, 413, 414, 416, - 417, 418, 419, 420, 421, 423, 424, 425, 426, 427, 428, 429, 430, - 431, 432, 434, 435, 436, 437, 438, 439, 440, 441, 442, 443, 444, - 445, 446, 447, 448, 449, 450, 451, 452, 453, 453, 454, 455, 456, - 457, 458, 459, 460, 461, 461, 462, 463, 464, 465, 466, 466, 467, - 468, 469, 469, 470, 471, 472, 473, 473, 474, 475, 475, 476, 477, - 477, 478, 479, 479, 480, 481, 481, 482, 483, 483, 484, 484, 485, - 486, 486, 487, 487, 488, 488, 489, 489, 490, 490, 491, 491, 492, - 492, 493, 493, 493, 494, 494, 495, 495, 495, 496, 496, 497, 497, - 497, 498, 498, 498, 498, 499, 499, 499, 500, 500, 500, 500, 500, - 501, 501, 501, 501, 501, 502, 502, 502, 502, 502, 502, 502, 502, - 503, 503, 503, 503, 503, 503, 503, 503, 503, 503, 503, 503, 503, - 503, 503, 503, 503, 503, 503, 502, 502, 502, 502, 502, 502, 502, - 502, 501, 501, 501, 501, 501, 500, 500, 500, 500, 500, 499, 499, - 499, 498, 498, 498, 498, 497, 497, 497, 496, 496, 495, 495, 495, - 494, 494, 493, 493, 493, 492, 492, 491, 491, 490, 490, 489, 489, - 488, 488, 487, 487, 486, 486, 485, 484, 484, 483, 483, 482, 481, - 481, 480, 479, 479, 478, 477, 477, 476, 475, 475, 474, 473, 473, - 472, 471, 470, 469, 469, 468, 467, 466, 466, 465, 464, 463, 462, - 461, 461, 460, 459, 458, 457, 456, 455, 454, 453, 453, 452, 451, - 450, 449, 448, 447, 446, 445, 444, 443, 442, 441, 440, 439, 438, - 437, 436, 435, 434, 432, 431, 430, 429, 428, 427, 426, 425, 424, - 423, 421, 420, 419, 418, 417, 416, 414, 413, 412, 411, 410, 409, - 407, 406, 405, 404, 402, 401, 400, 399, 397, 396, 395, 394, 392, - 391, 390, 389, 387, 386, 385, 383, 382, 381, 379, 378, 377, 375, - 374, 373, 371, 370, 369, 367, 366, 364, 363, 362, 360, 359, 357, - 356, 355, 353, 352, 350, 349, 348, 346, 345, 343, 342, 340, 339, - 337, 336, 335, 333, 332, 330, 329, 327, 326, 324, 323, 321, 320, - 318, 317, 315, 314, 312, 311, 309, 308, 306, 305, 303, 302, 300, - 299, 297, 296, 294, 293, 291, 290, 288, 287, 285, 284, 282, 281, - 279, 277, 276, 274, 273, 271, 270, 268, 267, 265, 264, 262, 260, - 259, 257, 256, 254, 253, 251, 250, 248, 247, 245, 244, 242, 240, - 239, 237, 236, 234, 233, 231, 230, 228, 227, 225, 223, 222, 220, - 219, 217, 216, 214, 213, 211, 210, 208, 207, 205, 204, 202, 201, - 199, 198, 196, 195, 193, 192, 190, 189, 187, 186, 184, 183, 181, - 180, 178, 177, 175, 174, 172, 171, 169, 168, 166, 165, 164, 162, - 161, 159, 158, 156, 155, 153, 152, 151, 149, 148, 146, 145, 144, - 142, 141, 139, 138, 137, 135, 134, 133, 131, 130, 129, 127, 126, - 124, 123, 122, 120, 119, 118, 117, 115, 114, 113, 111, 110, 109, - 108, 106, 105, 104, 103, 101, 100, 99, 98, 96, 95, 94, 93, - 92, 90, 89, 88, 87, 86, 84, 83, 82, 81, 80, 79, 78, - 77, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, - 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, - 50, 49, 48, 47, 46, 45, 45, 44, 43, 42, 41, 40, 39, - 39, 38, 37, 36, 35, 35, 34, 33, 32, 31, 31, 30, 29, - 29, 28, 27, 26, 26, 25, 24, 24, 23, 22, 22, 21, 20, - 20, 19, 19, 18, 17, 17, 16, 16, 15, 15, 14, 14, 13, - 13, 12, 12, 11, 11, 10, 10, 9, 9, 9, 8, 8, 7, - 7, 7, 6, 6, 6, 5, 5, 5, 4, 4, 4, 3, 3, - 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, - 2, 3, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, - 6, 7, 7, 7, 8, 8, 9, 9, 9, 10, 10, 11, 11, - 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, - 19, 19, 20, 20, 21, 22, 22, 23, 24, 24, 25, 26, 26, - 27, 28, 29, 29, 30, 31, 31, 32, 33, 34, 35, 35, 36, - 37, 38, 39, 39, 40, 41, 42, 43, 44, 45, 45, 46, 47, - 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, - 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, - 74, 75, 77, 78, 79, 80, 81, 82, 83, 84, 86, 87, 88, - 89, 90, 92, 93, 94, 95, 96, 98, 99, 100, 101, 103, 104, - 105, 106, 108, 109, 110, 111, 113, 114, 115, 117, 118, 119, 120, - 122, 123, 124, 126, 127, 129, 130, 131, 133, 134, 135, 137, 138, - 139, 141, 142, 144, 145, 146, 148, 149, 151, 152, 153, 155, 156, - 158, 159, 161, 162, 164, 165, 166, 168, 169, 171, 172, 174, 175, - 177, 178, 180, 181, 183, 184, 186, 187, 189, 190, 192, 193, 195, - 196, 198, 199, 201, 202, 204, 205, 207, 208, 210, 211, 213, 214, - 216, 217, 219, 220, 222, 223, 225, 227, 228, 230, 231, 233, 234, - 236, 237, 239, 240, 242, 244, 245, 247, 248, 250 -}; - -#endif diff --git a/apps/codecs/libgme/z80_cpu.c b/apps/codecs/libgme/z80_cpu.c deleted file mode 100644 index a31236020e..0000000000 --- a/apps/codecs/libgme/z80_cpu.c +++ /dev/null @@ -1,85 +0,0 @@ -// Game_Music_Emu 0.6-pre. http://www.slack.net/~ant/ - -#include "z80_cpu.h" - -/* Copyright (C) 2006-2008 Shay Green. This module is free software; you -can redistribute it and/or modify it under the terms of the GNU Lesser -General Public License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. This -module is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more -details. You should have received a copy of the GNU Lesser General Public -License along with this module; if not, write to the Free Software Foundation, -Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ - -#include "blargg_source.h" - -// flags, named with hex value for clarity -int const S80 = 0x80; -int const Z40 = 0x40; -int const F20 = 0x20; -int const H10 = 0x10; -int const F08 = 0x08; -int const V04 = 0x04; -int const P04 = 0x04; -int const N02 = 0x02; -int const C01 = 0x01; - -void Z80_init( struct Z80_Cpu* this ) -{ - this->cpu_state = &this->cpu_state_; - - int i; - for ( i = 0x100; --i >= 0; ) - { - int p, even = 1; - for ( p = i; p; p >>= 1 ) - even ^= p; - int n = (i & (S80 | F20 | F08)) | ((even & 1) * P04); - this->szpc [i] = n; - this->szpc [i + 0x100] = n | C01; - } - this->szpc [0x000] |= Z40; - this->szpc [0x100] |= Z40; -} - -static inline void set_page( struct Z80_Cpu* this, int i, void* write, void const* read ) -{ - int offset = Z80_CPU_OFFSET( i * page_size ); - byte * write2 = STATIC_CAST(byte *,write) - offset; - byte const* read2 = STATIC_CAST(byte const*,read ) - offset; - this->cpu_state_.write [i] = write2; - this->cpu_state_.read [i] = read2; - this->cpu_state->write [i] = write2; - this->cpu_state->read [i] = read2; -} - -void Z80_reset( struct Z80_Cpu* this, void* unmapped_write, void const* unmapped_read ) -{ - check( this->cpu_state == &this->cpu_state_ ); - this->cpu_state = &this->cpu_state_; - this->cpu_state_.time = 0; - this->cpu_state_.base = 0; - this->end_time_ = 0; - - int i; - for ( i = 0; i < page_count + 1; i++ ) - set_page( this, i, unmapped_write, unmapped_read ); - - memset( &this->r, 0, sizeof this->r ); -} - -void Z80_map_mem( struct Z80_Cpu* this, addr_t start, int size, void* write, void const* read ) -{ - // address range must begin and end on page boundaries - require( start % page_size == 0 ); - require( size % page_size == 0 ); - require( start + size <= 0x10000 ); - - int offset; - for ( offset = 0; offset < size; offset += page_size ) - set_page( this, (start + offset) >> page_bits, - STATIC_CAST(char *,write) + offset, - STATIC_CAST(char const*,read ) + offset ); -} diff --git a/apps/codecs/libgme/z80_cpu.h b/apps/codecs/libgme/z80_cpu.h deleted file mode 100644 index 341119b6b1..0000000000 --- a/apps/codecs/libgme/z80_cpu.h +++ /dev/null @@ -1,116 +0,0 @@ -// Z80 CPU emulator - -// Game_Music_Emu 0.6-pre -#ifndef Z80_CPU_H -#define Z80_CPU_H - -#include "blargg_source.h" -#include "blargg_endian.h" - -typedef int cpu_time_t; -typedef int addr_t; - -enum { page_bits = 10 }; -enum { page_size = 1 << page_bits }; -enum { page_count = 0x10000 / page_size }; - -// Can read this far past end of memory -enum { cpu_padding = 0x100 }; - -// Can read this many bytes past end of a page -enum { page_padding = 4 }; - -#ifdef BLARGG_BIG_ENDIAN - struct regs_t { byte b,c, d,e, h,l, flags,a; }; -#else - struct regs_t { byte c,b, e,d, l,h, a,flags; }; -#endif -// BOOST_STATIC_ASSERT( sizeof (regs_t) == 8 ); - -struct pairs_t { uint16_t bc, de, hl, fa; }; - -// Registers are not updated until run() returns -struct registers_t { - uint16_t pc; - uint16_t sp; - uint16_t ix; - uint16_t iy; - union { - struct regs_t b; // b.b, b.c, b.d, b.e, b.h, b.l, b.flags, b.a - struct pairs_t w; // w.bc, w.de, w.hl. w.fa - }; - union { - struct regs_t b; - struct pairs_t w; - } alt; - byte iff1; - byte iff2; - byte r; - byte i; - byte im; -}; - -struct cpu_state_t { - byte const* read [page_count + 1]; - byte * write [page_count + 1]; - cpu_time_t base; - cpu_time_t time; -}; - -struct Z80_Cpu { - byte szpc [0x200]; - cpu_time_t end_time_; - - struct cpu_state_t* cpu_state; // points to cpu_state_ or a local copy within run() - struct cpu_state_t cpu_state_; - - struct registers_t r; -}; - -void Z80_init( struct Z80_Cpu* this ); - -// Clears registers and maps all pages to unmapped -void Z80_reset( struct Z80_Cpu* this, void* unmapped_write, void const* unmapped_read ); - -// TODO: split mapping out of CPU - -// Maps memory. Start and size must be multiple of page_size. -void Z80_map_mem( struct Z80_Cpu* this, addr_t addr, int size, void* write, void const* read ); - -// Time of beginning of next instruction -static inline cpu_time_t Z80_time( struct Z80_Cpu* this ) { return this->cpu_state->time + this->cpu_state->base; } - -// Alter current time -static inline void Z80_set_time( struct Z80_Cpu* this, cpu_time_t t ) { this->cpu_state->time = t - this->cpu_state->base; } -static inline void Z80_adjust_time( struct Z80_Cpu* this, int delta ) { this->cpu_state->time += delta; } - -#ifdef BLARGG_NONPORTABLE - #define Z80_CPU_OFFSET( addr ) (addr) -#else - #define Z80_CPU_OFFSET( addr ) ((addr) & (page_size - 1)) -#endif - -// Maps address to pointer to that byte -static inline byte* Z80_write( struct Z80_Cpu* this, addr_t addr ) -{ - return this->cpu_state->write [(unsigned) addr >> page_bits] + Z80_CPU_OFFSET( addr ); -} - -static inline byte const* Z80_read( struct Z80_Cpu* this, addr_t addr ) -{ - return this->cpu_state->read [(unsigned) addr >> page_bits] + Z80_CPU_OFFSET( addr ); -} - -static inline void Z80_map_mem_rw( struct Z80_Cpu* this, addr_t addr, int size, void* p ) -{ - Z80_map_mem( this, addr, size, p, p ); -} - -static inline void Z80_set_end_time( struct Z80_Cpu* this, cpu_time_t t ) -{ - cpu_time_t delta = this->cpu_state->base - t; - this->cpu_state->base = t; - this->cpu_state->time += delta; -} - -#endif diff --git a/apps/codecs/libgme/z80_cpu_run.h b/apps/codecs/libgme/z80_cpu_run.h deleted file mode 100644 index a453487bb0..0000000000 --- a/apps/codecs/libgme/z80_cpu_run.h +++ /dev/null @@ -1,1696 +0,0 @@ -// Game_Music_Emu 0.6-pre. http://www.slack.net/~ant/ - -// Last validated with zexall 2009.12.05. -// Doesn't implement the R register or immediate interrupt after EI. -// Address wrap-around isn't completely correct, but is prevented from crashing emulator. -// 16-bit memory accesses are made directly to mapped memory, instead of using macro. - -#if 0 -/* Define these macros in the source file before #including this file. -- Parameters might be expressions, so they are best evaluated only once, -though they NEVER have side-effects, so multiple evaluation is OK. -- Output parameters might be a multiple-assignment expression like "a=x", -so they must NOT be parenthesized. -- Except where noted, time() and related functions will NOT work -correctly inside a macro. TIME() is always correct, and between FLUSH_TIME() and -CACHE_TIME() the normal time changing functions can be used. -- Macros "returning" void may use a {} statement block. */ - - // 0 <= addr <= 0xFFFF + 0x100 - // Optional; default uses whatever was set with map_mem() - int READ_MEM( addr_t ); - void WRITE_MEM( addr_t, int data ); - - // 0 <= port <= 0xFFFF (apparently upper 8 bits are output by hardware) - void OUT_PORT( int port, int data ); - int IN_PORT int port ); - - // Reference to Z80_Cpu object used for emulation - #define CPU cpu - -// The following can be used within macros: - - // Current time - time_t TIME(); - - // Allows use of time functions - void FLUSH_TIME(); - - // Must be used before end of macro if FLUSH_TIME() was used earlier - void CACHE_TIME(); - -// Configuration (optional; commented behavior if defined) - - // Optimizes as if map_mem( 0, 0x10000, FLAT_MEM, FLAT_MEM ) is always in effect - #define FLAT_MEM my_mem_array - - // If RST 7 ($FF) is encountered and PC = IDLE_ADDR, stops execution - #define IDLE_ADDR 0x1234 - - // Expanded just before beginning of code, to help debugger - #define CPU_BEGIN void my_run_cpu() { - -#endif - -/* Copyright (C) 2006-2008 Shay Green. This module is free software; you -can redistribute it and/or modify it under the terms of the GNU Lesser -General Public License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. This -module is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more -details. You should have received a copy of the GNU Lesser General Public -License along with this module; if not, write to the Free Software Foundation, -Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ - -#ifdef CPU_BEGIN - CPU_BEGIN -#endif - -#define R cpu->r - -// flags, named with hex value for clarity -int const S80 = 0x80; -int const Z40 = 0x40; -int const F20 = 0x20; -int const H10 = 0x10; -int const F08 = 0x08; -int const V04 = 0x04; -int const P04 = 0x04; -int const N02 = 0x02; -int const C01 = 0x01; - -#define SZ28P( n ) cpu->szpc [n] -#define SZ28PC( n ) cpu->szpc [n] -#define SZ28C( n ) (cpu->szpc [n] & ~P04) -#define SZ28( n ) SZ28C( n ) - -#define SET_R( n ) (void) (R.r = n) -#define GET_R() (R.r) - -// Time -#define TIME() (s_time + s.base) -#define FLUSH_TIME() {s.time = s_time;} -#define CACHE_TIME() {s_time = s.time;} - -// Memory -#define RW_MEM( addr, rw ) RW_PAGE( addr, rw ) [RW_OFFSET( addr )] -#define READ_CODE( addr ) RW_MEM( addr, read ) - -#ifdef FLAT_MEM - #define RW_PAGE( addr, rw ) FLAT_MEM - #define RW_OFFSET( addr ) (addr) - #define INSTR( off, addr ) READ_CODE( addr ) -#else - #define RW_PAGE( addr, rw ) s.rw [(unsigned) (addr) >> page_bits] - #define RW_OFFSET( addr ) Z80_CPU_OFFSET( addr ) - #define INSTR( off, addr ) instr [off] -#endif - -#ifndef READ_MEM - #define READ_MEM( addr ) RW_MEM( addr, read ) -#endif - -#ifndef WRITE_MEM - #define WRITE_MEM( addr, data ) (RW_MEM( addr, write ) = data) -#endif - -#define READ_WORD( addr ) GET_LE16( &RW_MEM( addr, read ) ) -#define WRITE_WORD( addr, data ) SET_LE16( &RW_MEM( addr, write ), data ) - -// Truncation -#define BYTE( n ) ((uint8_t ) (n)) /* (unsigned) n & 0xFF */ -#define SBYTE( n ) ((int8_t ) (n)) /* (BYTE( n ) ^ 0x80) - 0x80 */ -#define WORD( n ) ((uint16_t) (n)) /* (unsigned) n & 0xFFFF */ - -// Misc -#define CASE5( a, b, c, d, e ) case 0x##a:case 0x##b:case 0x##c:case 0x##d:case 0x##e -#define CASE6( a, b, c, d, e, f ) CASE5( a, b, c, d, e ): case 0x##f -#define CASE7( a, b, c, d, e, f, g ) CASE6( a, b, c, d, e, f ): case 0x##g -#define CASE8( a, b, c, d, e, f, g, h ) CASE7( a, b, c, d, e, f, g ): case 0x##h - -#ifdef BLARGG_BIG_ENDIAN - #define R8( n, offset ) ((r.r8_ - offset) [n]) -#elif BLARGG_LITTLE_ENDIAN - #define R8( n, offset ) ((r.r8_ - offset) [(n) ^ 1]) -#else - #error "Byte order of CPU must be known" -#endif - -#define R16( n, shift, offset ) (r.r16_ [((unsigned) (n) >> shift) - (offset >> shift)]) - -#define EX( x, y ) \ - {\ - int temp = x;\ - x = y;\ - y = temp;\ - } - -#define EXX( name ) \ - EX( R.alt.name, r.name ) - -bool warning = false; -{ - struct cpu_state_t s; - #ifdef FLAT_MEM - s.base = cpu->cpu_state_.base; - #else - s = cpu->cpu_state_; - #endif - cpu->cpu_state = &s; - - - union r_t { - struct regs_t b; - struct pairs_t w; - byte r8_ [8]; // indexed - uint16_t r16_ [4]; - } r; - r.b = R.b; - - cpu_time_t s_time = cpu->cpu_state_.time; - int pc = R.pc; - int sp = R.sp; - int ix = R.ix; // TODO: keep in memory for direct access? - int iy = R.iy; - int flags = R.b.flags; - - //goto loop; // confuses optimizer - s_time += 7; - pc -= 2; - -call_not_taken: - s_time -= 7; -jp_not_taken: - pc += 2; -loop: - - check( (unsigned) pc < 0x10000 + 1 ); // +1 so emulator can catch wrap-around - check( (unsigned) sp < 0x10000 ); - check( (unsigned) flags < 0x100 ); - check( (unsigned) ix < 0x10000 ); - check( (unsigned) iy < 0x10000 ); - - byte const* instr = RW_PAGE( pc, read ); - - int opcode; - - if ( RW_OFFSET( ~0 ) == ~0 ) - { - opcode = instr [RW_OFFSET( pc )]; - pc++; - instr += RW_OFFSET( pc ); - } - else - { - instr += RW_OFFSET( pc ); - opcode = *instr++; - pc++; - } - - static byte const clock_table [256 * 2] = { - // 0 1 2 3 4 5 6 7 8 9 A B C D E F - 4,10, 7, 6, 4, 4, 7, 4, 4,11, 7, 6, 4, 4, 7, 4, // 0 - 8,10, 7, 6, 4, 4, 7, 4,12,11, 7, 6, 4, 4, 7, 4, // 1 - 7,10,16, 6, 4, 4, 7, 4, 7,11,16, 6, 4, 4, 7, 4, // 2 - 7,10,13, 6,11,11,10, 4, 7,11,13, 6, 4, 4, 7, 4, // 3 - 4, 4, 4, 4, 4, 4, 7, 4, 4, 4, 4, 4, 4, 4, 7, 4, // 4 - 4, 4, 4, 4, 4, 4, 7, 4, 4, 4, 4, 4, 4, 4, 7, 4, // 5 - 4, 4, 4, 4, 4, 4, 7, 4, 4, 4, 4, 4, 4, 4, 7, 4, // 6 - 7, 7, 7, 7, 7, 7, 4, 7, 4, 4, 4, 4, 4, 4, 7, 4, // 7 - 4, 4, 4, 4, 4, 4, 7, 4, 4, 4, 4, 4, 4, 4, 7, 4, // 8 - 4, 4, 4, 4, 4, 4, 7, 4, 4, 4, 4, 4, 4, 4, 7, 4, // 9 - 4, 4, 4, 4, 4, 4, 7, 4, 4, 4, 4, 4, 4, 4, 7, 4, // A - 4, 4, 4, 4, 4, 4, 7, 4, 4, 4, 4, 4, 4, 4, 7, 4, // B - 11,10,10,10,17,11, 7,11,11,10,10, 8,17,17, 7,11, // C - 11,10,10,11,17,11, 7,11,11, 4,10,11,17, 8, 7,11, // D - 11,10,10,19,17,11, 7,11,11, 4,10, 4,17, 8, 7,11, // E - 11,10,10, 4,17,11, 7,11,11, 6,10, 4,17, 8, 7,11, // F - - // high four bits are $ED time - 8, low four bits are $DD/$FD time - 8 - //0 1 2 3 4 5 6 7 8 9 A B C D E F - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x06,0x0C,0x02,0x00,0x00,0x03,0x00,0x00,0x07,0x0C,0x02,0x00,0x00,0x03,0x00, - 0x00,0x00,0x00,0x00,0x0F,0x0F,0x0B,0x00,0x00,0x07,0x00,0x00,0x00,0x00,0x00,0x00, - 0x40,0x40,0x70,0xC0,0x00,0x60,0x0B,0x10,0x40,0x40,0x70,0xC0,0x00,0x60,0x0B,0x10, - 0x40,0x40,0x70,0xC0,0x00,0x60,0x0B,0x10,0x40,0x40,0x70,0xC0,0x00,0x60,0x0B,0x10, - 0x40,0x40,0x70,0xC0,0x00,0x60,0x0B,0xA0,0x40,0x40,0x70,0xC0,0x00,0x60,0x0B,0xA0, - 0x4B,0x4B,0x7B,0xCB,0x0B,0x6B,0x00,0x0B,0x40,0x40,0x70,0xC0,0x00,0x60,0x0B,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x0B,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0B,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x0B,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0B,0x00, - 0x80,0x80,0x80,0x80,0x00,0x00,0x0B,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x0B,0x00, - 0xD0,0xD0,0xD0,0xD0,0x00,0x00,0x0B,0x00,0xD0,0xD0,0xD0,0xD0,0x00,0x00,0x0B,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x06,0x00,0x0F,0x00,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00, - }; - - if ( s_time >= 0 ) - goto out_of_time; - s_time += clock_table [opcode]; - - #ifdef Z80_CPU_LOG_H - //log_opcode( opcode, READ_CODE( pc ) ); - z80_cpu_log( "log.txt", pc - 1, opcode, READ_CODE( pc ), - READ_CODE( pc + 1 ), READ_CODE( pc + 2 ) ); - z80_log_regs( r.b.a, r.w.bc, r.w.de, r.w.hl, sp, ix, iy ); - #endif - -#define GET_ADDR() GET_LE16( &INSTR( 0, pc ) ) - - int data; - data = INSTR( 0, pc ); - - switch ( opcode ) - { -// Common - - case 0x00: // NOP - CASE7( 40, 49, 52, 5B, 64, 6D, 7F ): // LD B,B etc. - goto loop; - - case 0x08:{// EX AF,AF' - EXX( b.a ); - EX( R.alt.b.flags, flags ); - goto loop; - } - - case 0xD3: // OUT (imm),A - pc++; - OUT_PORT( (data + r.b.a * 0x100), r.b.a ); - goto loop; - - case 0x2E: // LD L,imm - pc++; - r.b.l = data; - goto loop; - - case 0x3E: // LD A,imm - pc++; - r.b.a = data; - goto loop; - - case 0x3A:{// LD A,(addr) - int addr = GET_ADDR(); - pc += 2; - r.b.a = READ_MEM( addr ); - goto loop; - } - -// Conditional - -#define ZERO (flags & Z40) -#define CARRY (flags & C01) -#define EVEN (flags & P04) -#define MINUS (flags & S80) - -// JR -// TODO: more efficient way to handle negative branch that wraps PC around -#define JR_( cond, clocks ) {\ - pc++;\ - if ( !(cond) )\ - goto loop;\ - int offset = SBYTE( data );\ - pc = WORD( pc + offset );\ - s_time += clocks;\ - goto loop;\ -} - -#define JR( cond ) JR_( cond, 5 ) - - case 0x20: JR( !ZERO ) // JR NZ,disp - case 0x28: JR( ZERO ) // JR Z,disp - case 0x30: JR( !CARRY ) // JR NC,disp - case 0x38: JR( CARRY ) // JR C,disp - case 0x18: JR_( true,0) // JR disp - - case 0x10:{// DJNZ disp - int temp = r.b.b - 1; - r.b.b = temp; - JR( temp ) - } - -// JP -#define JP( cond ) \ - if ( !(cond) )\ - goto jp_not_taken;\ - pc = GET_ADDR();\ - goto loop; - - case 0xC2: JP( !ZERO ) // JP NZ,addr - case 0xCA: JP( ZERO ) // JP Z,addr - case 0xD2: JP( !CARRY ) // JP NC,addr - case 0xDA: JP( CARRY ) // JP C,addr - case 0xE2: JP( !EVEN ) // JP PO,addr - case 0xEA: JP( EVEN ) // JP PE,addr - case 0xF2: JP( !MINUS ) // JP P,addr - case 0xFA: JP( MINUS ) // JP M,addr - - case 0xC3: // JP addr - pc = GET_ADDR(); - goto loop; - - case 0xE9: // JP HL - pc = r.w.hl; - goto loop; - -// RET -#define RET( cond ) \ - if ( cond )\ - goto ret_taken;\ - s_time -= 6;\ - goto loop; - - case 0xC0: RET( !ZERO ) // RET NZ - case 0xC8: RET( ZERO ) // RET Z - case 0xD0: RET( !CARRY ) // RET NC - case 0xD8: RET( CARRY ) // RET C - case 0xE0: RET( !EVEN ) // RET PO - case 0xE8: RET( EVEN ) // RET PE - case 0xF0: RET( !MINUS ) // RET P - case 0xF8: RET( MINUS ) // RET M - - case 0xC9: // RET - ret_taken: - pc = READ_WORD( sp ); - sp = WORD( sp + 2 ); - goto loop; - -// CALL -#define CALL( cond ) \ - if ( cond )\ - goto call_taken;\ - goto call_not_taken; - - case 0xC4: CALL( !ZERO ) // CALL NZ,addr - case 0xCC: CALL( ZERO ) // CALL Z,addr - case 0xD4: CALL( !CARRY ) // CALL NC,addr - case 0xDC: CALL( CARRY ) // CALL C,addr - case 0xE4: CALL( !EVEN ) // CALL PO,addr - case 0xEC: CALL( EVEN ) // CALL PE,addr - case 0xF4: CALL( !MINUS ) // CALL P,addr - case 0xFC: CALL( MINUS ) // CALL M,addr - - case 0xCD:{// CALL addr - call_taken: { - int addr = pc + 2; - pc = GET_ADDR(); - sp = WORD( sp - 2 ); - WRITE_WORD( sp, addr ); - goto loop; - } - } - - case 0xFF: // RST - #ifdef IDLE_ADDR - if ( pc == IDLE_ADDR + 1 ) - goto hit_idle_addr; - #else - if ( pc > 0x10000 ) - { - pc = WORD( pc - 1 ); - s_time -= 11; - goto loop; - } - #endif - CASE7( C7, CF, D7, DF, E7, EF, F7 ): - data = pc; - pc = opcode & 0x38; - #ifdef RST_BASE - pc += RST_BASE; - #endif - goto push_data; - -// PUSH/POP - case 0xF5: // PUSH AF - data = r.b.a * 0x100u + flags; - goto push_data; - - case 0xC5: // PUSH BC - case 0xD5: // PUSH DE - case 0xE5: // PUSH HL - data = R16( opcode, 4, 0xC5 ); - push_data: - sp = WORD( sp - 2 ); - WRITE_WORD( sp, data ); - goto loop; - - case 0xF1: // POP AF - flags = READ_MEM( sp ); - r.b.a = READ_MEM( (sp + 1) ); - sp = WORD( sp + 2 ); - goto loop; - - case 0xC1: // POP BC - case 0xD1: // POP DE - case 0xE1: // POP HL - R16( opcode, 4, 0xC1 ) = READ_WORD( sp ); - sp = WORD( sp + 2 ); - goto loop; - -// ADC/ADD/SBC/SUB - case 0x96: // SUB (HL) - case 0x86: // ADD (HL) - flags &= ~C01; - case 0x9E: // SBC (HL) - case 0x8E: // ADC (HL) - data = READ_MEM( r.w.hl ); - goto adc_data; - - case 0xD6: // SUB A,imm - case 0xC6: // ADD imm - flags &= ~C01; - case 0xDE: // SBC A,imm - case 0xCE: // ADC imm - pc++; - goto adc_data; - - CASE7( 90, 91, 92, 93, 94, 95, 97 ): // SUB r - CASE7( 80, 81, 82, 83, 84, 85, 87 ): // ADD r - flags &= ~C01; - CASE7( 98, 99, 9A, 9B, 9C, 9D, 9F ): // SBC r - CASE7( 88, 89, 8A, 8B, 8C, 8D, 8F ): // ADC r - data = R8( opcode & 7, 0 ); - adc_data: { - int result = data + (flags & C01); - data ^= r.b.a; - flags = opcode >> 3 & N02; // bit 4 is set in subtract opcodes - if ( flags ) - result = -result; - result += r.b.a; - data ^= result; - flags +=(data & H10) + - ((data + 0x80) >> 6 & V04) + - SZ28C( result & 0x1FF ); - r.b.a = result; - goto loop; - } - -// CP - case 0xBE: // CP (HL) - data = READ_MEM( r.w.hl ); - goto cp_data; - - case 0xFE: // CP imm - pc++; - goto cp_data; - - CASE7( B8, B9, BA, BB, BC, BD, BF ): // CP r - data = R8( opcode, 0xB8 ); - cp_data: { - int result = r.b.a - data; - flags = N02 + (data & (F20 | F08)) + (result >> 8 & C01); - data ^= r.b.a; - flags +=(((result ^ r.b.a) & data) >> 5 & V04) + - (((data & H10) ^ result) & (S80 | H10)); - if ( BYTE( result ) ) - goto loop; - flags += Z40; - goto loop; - } - -// ADD HL,r.w - - case 0x39: // ADD HL,SP - data = sp; - goto add_hl_data; - - case 0x09: // ADD HL,BC - case 0x19: // ADD HL,DE - case 0x29: // ADD HL,HL - data = R16( opcode, 4, 0x09 ); - add_hl_data: { - int sum = r.w.hl + data; - data ^= r.w.hl; - r.w.hl = sum; - flags = (flags & (S80 | Z40 | V04)) + - (sum >> 16) + - (sum >> 8 & (F20 | F08)) + - ((data ^ sum) >> 8 & H10); - goto loop; - } - - case 0x27:{// DAA - int a = r.b.a; - if ( a > 0x99 ) - flags |= C01; - - int adjust = 0x60 * (flags & C01); - - if ( flags & H10 || (a & 0x0F) > 9 ) - adjust += 0x06; - - if ( flags & N02 ) - adjust = -adjust; - a += adjust; - - flags = (flags & (C01 | N02)) + - ((r.b.a ^ a) & H10) + - SZ28P( BYTE( a ) ); - r.b.a = a; - goto loop; - } - -// INC/DEC - case 0x34: // INC (HL) - data = READ_MEM( r.w.hl ) + 1; - WRITE_MEM( r.w.hl, data ); - goto inc_set_flags; - - CASE7( 04, 0C, 14, 1C, 24, 2C, 3C ): // INC r - data = ++R8( opcode >> 3, 0 ); - inc_set_flags: - flags = (flags & C01) + - (((data & 0x0F) - 1) & H10) + - SZ28( BYTE( data ) ); - if ( data != 0x80 ) - goto loop; - flags += V04; - goto loop; - - case 0x35: // DEC (HL) - data = READ_MEM( r.w.hl ) - 1; - WRITE_MEM( r.w.hl, data ); - goto dec_set_flags; - - CASE7( 05, 0D, 15, 1D, 25, 2D, 3D ): // DEC r - data = --R8( opcode >> 3, 0 ); - dec_set_flags: - flags = (flags & C01) + N02 + - (((data & 0x0F) + 1) & H10) + - SZ28( BYTE( data ) ); - if ( data != 0x7F ) - goto loop; - flags += V04; - goto loop; - - case 0x03: // INC BC - case 0x13: // INC DE - case 0x23: // INC HL - R16( opcode, 4, 0x03 )++; - goto loop; - - case 0x33: // INC SP - sp = WORD( sp + 1 ); - goto loop; - - case 0x0B: // DEC BC - case 0x1B: // DEC DE - case 0x2B: // DEC HL - R16( opcode, 4, 0x0B )--; - goto loop; - - case 0x3B: // DEC SP - sp = WORD( sp - 1 ); - goto loop; - -// AND - case 0xA6: // AND (HL) - data = READ_MEM( r.w.hl ); - goto and_data; - - case 0xE6: // AND imm - pc++; - goto and_data; - - CASE7( A0, A1, A2, A3, A4, A5, A7 ): // AND r - data = R8( opcode, 0xA0 ); - and_data: - r.b.a &= data; - flags = SZ28P( r.b.a ) + H10; - goto loop; - -// OR - case 0xB6: // OR (HL) - data = READ_MEM( r.w.hl ); - goto or_data; - - case 0xF6: // OR imm - pc++; - goto or_data; - - CASE7( B0, B1, B2, B3, B4, B5, B7 ): // OR r - data = R8( opcode, 0xB0 ); - or_data: - r.b.a |= data; - flags = SZ28P( r.b.a ); - goto loop; - -// XOR - case 0xAE: // XOR (HL) - data = READ_MEM( r.w.hl ); - goto xor_data; - - case 0xEE: // XOR imm - pc++; - goto xor_data; - - CASE7( A8, A9, AA, AB, AC, AD, AF ): // XOR r - data = R8( opcode, 0xA8 ); - xor_data: - r.b.a ^= data; - flags = SZ28P( r.b.a ); - goto loop; - -// LD - CASE7( 70, 71, 72, 73, 74, 75, 77 ): // LD (HL),r - WRITE_MEM( r.w.hl, R8( opcode, 0x70 ) ); - goto loop; - - CASE6( 41, 42, 43, 44, 45, 47 ): // LD B,r - CASE6( 48, 4A, 4B, 4C, 4D, 4F ): // LD C,r - CASE6( 50, 51, 53, 54, 55, 57 ): // LD D,r - CASE6( 58, 59, 5A, 5C, 5D, 5F ): // LD E,r - CASE6( 60, 61, 62, 63, 65, 67 ): // LD H,r - CASE6( 68, 69, 6A, 6B, 6C, 6F ): // LD L,r - CASE6( 78, 79, 7A, 7B, 7C, 7D ): // LD A,r - R8( opcode >> 3 & 7, 0 ) = R8( opcode & 7, 0 ); - goto loop; - - CASE5( 06, 0E, 16, 1E, 26 ): // LD r,imm - R8( opcode >> 3, 0 ) = data; - pc++; - goto loop; - - case 0x36: // LD (HL),imm - pc++; - WRITE_MEM( r.w.hl, data ); - goto loop; - - CASE7( 46, 4E, 56, 5E, 66, 6E, 7E ): // LD r,(HL) - R8( opcode >> 3, 8 ) = READ_MEM( r.w.hl ); - goto loop; - - case 0x01: // LD r.w,imm - case 0x11: - case 0x21: - R16( opcode, 4, 0x01 ) = GET_ADDR(); - pc += 2; - goto loop; - - case 0x31: // LD sp,imm - sp = GET_ADDR(); - pc += 2; - goto loop; - - case 0x2A:{// LD HL,(addr) - int addr = GET_ADDR(); - pc += 2; - r.w.hl = READ_WORD( addr ); - goto loop; - } - - case 0x32:{// LD (addr),A - int addr = GET_ADDR(); - pc += 2; - WRITE_MEM( addr, r.b.a ); - goto loop; - } - - case 0x22:{// LD (addr),HL - int addr = GET_ADDR(); - pc += 2; - WRITE_WORD( addr, r.w.hl ); - goto loop; - } - - case 0x02: // LD (BC),A - case 0x12: // LD (DE),A - WRITE_MEM( R16( opcode, 4, 0x02 ), r.b.a ); - goto loop; - - case 0x0A: // LD A,(BC) - case 0x1A: // LD A,(DE) - r.b.a = READ_MEM( R16( opcode, 4, 0x0A ) ); - goto loop; - - case 0xF9: // LD SP,HL - sp = r.w.hl; - goto loop; - -// Rotate - - case 0x07:{// RLCA - int temp = r.b.a; - temp = (temp << 1) + (temp >> 7); - flags = (flags & (S80 | Z40 | P04)) + - (temp & (F20 | F08 | C01)); - r.b.a = temp; - goto loop; - } - - case 0x0F:{// RRCA - int temp = r.b.a; - flags = (flags & (S80 | Z40 | P04)) + - (temp & C01); - temp = (temp << 7) + (temp >> 1); - flags += temp & (F20 | F08); - r.b.a = temp; - goto loop; - } - - case 0x17:{// RLA - int temp = (r.b.a << 1) + (flags & C01); - flags = (flags & (S80 | Z40 | P04)) + - (temp & (F20 | F08)) + - (temp >> 8); - r.b.a = temp; - goto loop; - } - - case 0x1F:{// RRA - int temp = (flags << 7) + (r.b.a >> 1); - flags = (flags & (S80 | Z40 | P04)) + - (temp & (F20 | F08)) + - (r.b.a & C01); - r.b.a = temp; - goto loop; - } - -// Misc - case 0x2F:{// CPL - int temp = ~r.b.a; - flags = (flags & (S80 | Z40 | P04 | C01)) + - (temp & (F20 | F08)) + - (H10 | N02); - r.b.a = temp; - goto loop; - } - - case 0x3F:{// CCF - flags = ((flags & (S80 | Z40 | P04 | C01)) ^ C01) + - (flags << 4 & H10) + - (r.b.a & (F20 | F08)); - goto loop; - } - - case 0x37: // SCF - flags = ((flags & (S80 | Z40 | P04)) | C01) + - (r.b.a & (F20 | F08)); - goto loop; - - case 0xDB: // IN A,(imm) - pc++; - r.b.a = IN_PORT( (data + r.b.a * 0x100) ); - goto loop; - - case 0xE3:{// EX (SP),HL - int temp = READ_WORD( sp ); - WRITE_WORD( sp, r.w.hl ); - r.w.hl = temp; - goto loop; - } - - case 0xEB: // EX DE,HL - EX( r.w.hl, r.w.de ); - goto loop; - - case 0xD9: // EXX DE,HL - EXX( w.bc ); - EXX( w.de ); - EXX( w.hl ); - goto loop; - - case 0xF3: // DI - R.iff1 = 0; - R.iff2 = 0; - goto loop; - - case 0xFB: // EI - R.iff1 = 1; - R.iff2 = 1; - // TODO: delayed effect - goto loop; - - case 0x76: // HALT - goto halt; - -//////////////////////////////////////// CB prefix - { - case 0xCB: - pc++; - switch ( data ) - { - - // Rotate left - - #define RLC( read, write ) {\ - int result = read;\ - result = BYTE( result << 1 ) + (result >> 7);\ - flags = SZ28P( result ) + (result & C01);\ - write;\ - goto loop;\ - } - - case 0x06: // RLC (HL) - s_time += 7; - data = r.w.hl; - rlc_data_addr: - RLC( READ_MEM( data ), WRITE_MEM( data, result ) ) - - CASE7( 00, 01, 02, 03, 04, 05, 07 ):{// RLC r - byte* reg = &R8( data, 0 ); - RLC( *reg, *reg = result ) - } - - #define RL( read, write ) {\ - int result = (read << 1) + (flags & C01);\ - flags = SZ28PC( result );\ - write;\ - goto loop;\ - } - - case 0x16: // RL (HL) - s_time += 7; - data = r.w.hl; - rl_data_addr: - RL( READ_MEM( data ), WRITE_MEM( data, result ) ) - - CASE7( 10, 11, 12, 13, 14, 15, 17 ):{// RL r - byte* reg = &R8( data, 0x10 ); - RL( *reg, *reg = result ) - } - - #define SLA( read, low_bit, write ) {\ - int result = (read << 1) + low_bit;\ - flags = SZ28PC( result );\ - write;\ - goto loop;\ - } - - case 0x26: // SLA (HL) - s_time += 7; - data = r.w.hl; - sla_data_addr: - SLA( READ_MEM( data ), 0, WRITE_MEM( data, result ) ) - - CASE7( 20, 21, 22, 23, 24, 25, 27 ):{// SLA r - byte* reg = &R8( data, 0x20 ); - SLA( *reg, 0, *reg = result ) - } - - case 0x36: // SLL (HL) - s_time += 7; - data = r.w.hl; - sll_data_addr: - SLA( READ_MEM( data ), 1, WRITE_MEM( data, result ) ) - - CASE7( 30, 31, 32, 33, 34, 35, 37 ):{// SLL r - byte* reg = &R8( data, 0x30 ); - SLA( *reg, 1, *reg = result ) - } - - // Rotate right - - #define RRC( read, write ) {\ - int result = read;\ - flags = result & C01;\ - result = BYTE( result << 7 ) + (result >> 1);\ - flags += SZ28P( result );\ - write;\ - goto loop;\ - } - - case 0x0E: // RRC (HL) - s_time += 7; - data = r.w.hl; - rrc_data_addr: - RRC( READ_MEM( data ), WRITE_MEM( data, result ) ) - - CASE7( 08, 09, 0A, 0B, 0C, 0D, 0F ):{// RRC r - byte* reg = &R8( data, 0x08 ); - RRC( *reg, *reg = result ) - } - - #define RR( read, write ) {\ - int result = read;\ - int temp = result & C01;\ - result = BYTE( flags << 7 ) + (result >> 1);\ - flags = SZ28P( result ) + temp;\ - write;\ - goto loop;\ - } - - case 0x1E: // RR (HL) - s_time += 7; - data = r.w.hl; - rr_data_addr: - RR( READ_MEM( data ), WRITE_MEM( data, result ) ) - - CASE7( 18, 19, 1A, 1B, 1C, 1D, 1F ):{// RR r - byte* reg = &R8( data, 0x18 ); - RR( *reg, *reg = result ) - } - - #define SRA( read, write ) {\ - int result = read;\ - flags = result & C01;\ - result = (result & 0x80) + (result >> 1);\ - flags += SZ28P( result );\ - write;\ - goto loop;\ - } - - case 0x2E: // SRA (HL) - data = r.w.hl; - s_time += 7; - sra_data_addr: - SRA( READ_MEM( data ), WRITE_MEM( data, result ) ) - - CASE7( 28, 29, 2A, 2B, 2C, 2D, 2F ):{// SRA r - byte* reg = &R8( data, 0x28 ); - SRA( *reg, *reg = result ) - } - - #define SRL( read, write ) {\ - int result = read;\ - flags = result & C01;\ - result >>= 1;\ - flags += SZ28P( result );\ - write;\ - goto loop;\ - } - - case 0x3E: // SRL (HL) - s_time += 7; - data = r.w.hl; - srl_data_addr: - SRL( READ_MEM( data ), WRITE_MEM( data, result ) ) - - CASE7( 38, 39, 3A, 3B, 3C, 3D, 3F ):{// SRL r - byte* reg = &R8( data, 0x38 ); - SRL( *reg, *reg = result ) - } - - // BIT - { - int temp; - CASE8( 46, 4E, 56, 5E, 66, 6E, 76, 7E ): // BIT b,(HL) - s_time += 4; - temp = READ_MEM( r.w.hl ); - flags &= C01; - goto bit_temp; - CASE7( 40, 41, 42, 43, 44, 45, 47 ): // BIT 0,r - CASE7( 48, 49, 4A, 4B, 4C, 4D, 4F ): // BIT 1,r - CASE7( 50, 51, 52, 53, 54, 55, 57 ): // BIT 2,r - CASE7( 58, 59, 5A, 5B, 5C, 5D, 5F ): // BIT 3,r - CASE7( 60, 61, 62, 63, 64, 65, 67 ): // BIT 4,r - CASE7( 68, 69, 6A, 6B, 6C, 6D, 6F ): // BIT 5,r - CASE7( 70, 71, 72, 73, 74, 75, 77 ): // BIT 6,r - CASE7( 78, 79, 7A, 7B, 7C, 7D, 7F ): // BIT 7,r - temp = R8( data & 7, 0 ); - flags = (flags & C01) + (temp & (F20 | F08)); - bit_temp: - temp = temp & (1 << (data >> 3 & 7)); - flags += (temp & S80) + H10; - flags += (unsigned) --temp >> 8 & (Z40 | P04); - goto loop; - } - - // SET/RES - CASE8( 86, 8E, 96, 9E, A6, AE, B6, BE ): // RES b,(HL) - CASE8( C6, CE, D6, DE, E6, EE, F6, FE ):{// SET b,(HL) - s_time += 7; - int temp = READ_MEM( r.w.hl ); - int bit = 1 << (data >> 3 & 7); - temp |= bit; // SET - if ( !(data & 0x40) ) - temp ^= bit; // RES - WRITE_MEM( r.w.hl, temp ); - goto loop; - } - - CASE7( C0, C1, C2, C3, C4, C5, C7 ): // SET 0,r - CASE7( C8, C9, CA, CB, CC, CD, CF ): // SET 1,r - CASE7( D0, D1, D2, D3, D4, D5, D7 ): // SET 2,r - CASE7( D8, D9, DA, DB, DC, DD, DF ): // SET 3,r - CASE7( E0, E1, E2, E3, E4, E5, E7 ): // SET 4,r - CASE7( E8, E9, EA, EB, EC, ED, EF ): // SET 5,r - CASE7( F0, F1, F2, F3, F4, F5, F7 ): // SET 6,r - CASE7( F8, F9, FA, FB, FC, FD, FF ): // SET 7,r - R8( data & 7, 0 ) |= 1 << (data >> 3 & 7); - goto loop; - - CASE7( 80, 81, 82, 83, 84, 85, 87 ): // RES 0,r - CASE7( 88, 89, 8A, 8B, 8C, 8D, 8F ): // RES 1,r - CASE7( 90, 91, 92, 93, 94, 95, 97 ): // RES 2,r - CASE7( 98, 99, 9A, 9B, 9C, 9D, 9F ): // RES 3,r - CASE7( A0, A1, A2, A3, A4, A5, A7 ): // RES 4,r - CASE7( A8, A9, AA, AB, AC, AD, AF ): // RES 5,r - CASE7( B0, B1, B2, B3, B4, B5, B7 ): // RES 6,r - CASE7( B8, B9, BA, BB, BC, BD, BF ): // RES 7,r - R8( data & 7, 0 ) &= ~(1 << (data >> 3 & 7)); - goto loop; - } - assert( false ); - } - -#undef GET_ADDR -#define GET_ADDR() GET_LE16( &INSTR( 1, pc ) ) - -//////////////////////////////////////// ED prefix - { - case 0xED: - pc++; - s_time += (clock_table + 256) [data] >> 4; - switch ( data ) - { - { - int temp; - case 0x72: // SBC HL,SP - case 0x7A: // ADC HL,SP - temp = sp; - if ( 0 ) - case 0x42: // SBC HL,BC - case 0x52: // SBC HL,DE - case 0x62: // SBC HL,HL - case 0x4A: // ADC HL,BC - case 0x5A: // ADC HL,DE - case 0x6A: // ADC HL,HL - temp = R16( data >> 3 & 6, 1, 0 ); - int sum = temp + (flags & C01); - flags = ~data >> 2 & N02; - if ( flags ) - sum = -sum; - sum += r.w.hl; - temp ^= r.w.hl; - temp ^= sum; - flags +=(sum >> 16 & C01) + - (temp >> 8 & H10) + - (sum >> 8 & (S80 | F20 | F08)) + - ((temp + 0x8000) >> 14 & V04); - r.w.hl = sum; - if ( WORD( sum ) ) - goto loop; - flags += Z40; - goto loop; - } - - CASE8( 40, 48, 50, 58, 60, 68, 70, 78 ):{// IN r,(C) - int temp = IN_PORT( r.w.bc ); - R8( data >> 3, 8 ) = temp; - flags = (flags & C01) + SZ28P( temp ); - goto loop; - } - - case 0x71: // OUT (C),0 - r.b.flags = 0; - CASE7( 41, 49, 51, 59, 61, 69, 79 ): // OUT (C),r - OUT_PORT( r.w.bc, R8( data >> 3, 8 ) ); - goto loop; - - { - int temp; - case 0x73: // LD (ADDR),SP - temp = sp; - if ( 0 ) - case 0x43: // LD (ADDR),BC - case 0x53: // LD (ADDR),DE - temp = R16( data, 4, 0x43 ); - int addr = GET_ADDR(); - pc += 2; - WRITE_WORD( addr, temp ); - goto loop; - } - - case 0x4B: // LD BC,(ADDR) - case 0x5B:{// LD DE,(ADDR) - int addr = GET_ADDR(); - pc += 2; - R16( data, 4, 0x4B ) = READ_WORD( addr ); - goto loop; - } - - case 0x7B:{// LD SP,(ADDR) - int addr = GET_ADDR(); - pc += 2; - sp = READ_WORD( addr ); - goto loop; - } - - case 0x67:{// RRD - int temp = READ_MEM( r.w.hl ); - WRITE_MEM( r.w.hl, ((r.b.a << 4) + (temp >> 4)) ); - temp = (r.b.a & 0xF0) + (temp & 0x0F); - flags = (flags & C01) + SZ28P( temp ); - r.b.a = temp; - goto loop; - } - - case 0x6F:{// RLD - int temp = READ_MEM( r.w.hl ); - WRITE_MEM( r.w.hl, ((temp << 4) + (r.b.a & 0x0F)) ); - temp = (r.b.a & 0xF0) + (temp >> 4); - flags = (flags & C01) + SZ28P( temp ); - r.b.a = temp; - goto loop; - } - - CASE8( 44, 4C, 54, 5C, 64, 6C, 74, 7C ): // NEG - opcode = 0x10; // flag to do SBC instead of ADC - flags &= ~C01; - data = r.b.a; - r.b.a = 0; - goto adc_data; - - { - int inc; - case 0xA9: // CPD - case 0xB9: // CPDR - inc = -1; - if ( 0 ) - case 0xA1: // CPI - case 0xB1: // CPIR - inc = +1; - int addr = r.w.hl; - r.w.hl = addr + inc; - int temp = READ_MEM( addr ); - - int result = r.b.a - temp; - flags = (flags & C01) + N02 + - ((((temp ^ r.b.a) & H10) ^ result) & (S80 | H10)); - - if ( !BYTE( result ) ) - flags += Z40; - result -= (flags & H10) >> 4; - flags += result & F08; - flags += result << 4 & F20; - if ( !--r.w.bc ) - goto loop; - - flags += V04; - if ( flags & Z40 || data < 0xB0 ) - goto loop; - - pc -= 2; - s_time += 5; - goto loop; - } - - { - int inc; - case 0xA8: // LDD - case 0xB8: // LDDR - inc = -1; - if ( 0 ) - case 0xA0: // LDI - case 0xB0: // LDIR - inc = +1; - int addr = r.w.hl; - r.w.hl = addr + inc; - int temp = READ_MEM( addr ); - - addr = r.w.de; - r.w.de = addr + inc; - WRITE_MEM( addr, temp ); - - temp += r.b.a; - flags = (flags & (S80 | Z40 | C01)) + - (temp & F08) + (temp << 4 & F20); - if ( !--r.w.bc ) - goto loop; - - flags += V04; - if ( data < 0xB0 ) - goto loop; - - pc -= 2; - s_time += 5; - goto loop; - } - - { - int inc; - case 0xAB: // OUTD - case 0xBB: // OTDR - inc = -1; - if ( 0 ) - case 0xA3: // OUTI - case 0xB3: // OTIR - inc = +1; - int addr = r.w.hl; - r.w.hl = addr + inc; - int temp = READ_MEM( addr ); - - int b = --r.b.b; - flags = (temp >> 6 & N02) + SZ28( b ); - if ( b && data >= 0xB0 ) - { - pc -= 2; - s_time += 5; - } - - OUT_PORT( r.w.bc, temp ); - goto loop; - } - - { - int inc; - case 0xAA: // IND - case 0xBA: // INDR - inc = -1; - if ( 0 ) - case 0xA2: // INI - case 0xB2: // INIR - inc = +1; - - int addr = r.w.hl; - r.w.hl = addr + inc; - - int temp = IN_PORT( r.w.bc ); - - int b = --r.b.b; - flags = (temp >> 6 & N02) + SZ28( b ); - if ( b && data >= 0xB0 ) - { - pc -= 2; - s_time += 5; - } - - WRITE_MEM( addr, temp ); - goto loop; - } - - case 0x47: // LD I,A - R.i = r.b.a; - goto loop; - - case 0x4F: // LD R,A - SET_R( r.b.a ); - dprintf( "LD R,A not supported\n" ); - warning = true; - goto loop; - - case 0x57: // LD A,I - r.b.a = R.i; - goto ld_ai_common; - - case 0x5F: // LD A,R - r.b.a = GET_R(); - dprintf( "LD A,R not supported\n" ); - warning = true; - ld_ai_common: - flags = (flags & C01) + SZ28( r.b.a ) + (R.iff2 << 2 & V04); - goto loop; - - CASE8( 45, 4D, 55, 5D, 65, 6D, 75, 7D ): // RETI/RETN - R.iff1 = R.iff2; - goto ret_taken; - - case 0x46: case 0x4E: case 0x66: case 0x6E: // IM 0 - R.im = 0; - goto loop; - - case 0x56: case 0x76: // IM 1 - R.im = 1; - goto loop; - - case 0x5E: case 0x7E: // IM 2 - R.im = 2; - goto loop; - - default: - dprintf( "Opcode $ED $%02X not supported\n", data ); - warning = true; - goto loop; - } - assert( false ); - } - -//////////////////////////////////////// DD/FD prefix - { - int ixy; - case 0xDD: - ixy = ix; - goto ix_prefix; - case 0xFD: - ixy = iy; - ix_prefix: - pc++; - int data2 = READ_CODE( pc ); - s_time += (clock_table + 256) [data] & 0x0F; - switch ( data ) - { - // TODO: more efficient way of avoid negative address - // TODO: avoid using this as argument to READ_MEM() since it is evaluated twice - #define IXY_DISP( ixy, disp ) WORD( (ixy ) + (disp)) - - #define SET_IXY( in ) if ( opcode == 0xDD ) ix = in; else iy = in; - - // ADD/ADC/SUB/SBC - - case 0x96: // SUB (IXY+disp) - case 0x86: // ADD (IXY+disp) - flags &= ~C01; - case 0x9E: // SBC (IXY+disp) - case 0x8E: // ADC (IXY+disp) - pc++; - opcode = data; - data = READ_MEM( IXY_DISP( ixy, SBYTE( data2 ) ) ); - goto adc_data; - - case 0x94: // SUB HXY - case 0x84: // ADD HXY - flags &= ~C01; - case 0x9C: // SBC HXY - case 0x8C: // ADC HXY - opcode = data; - data = ixy >> 8; - goto adc_data; - - case 0x95: // SUB LXY - case 0x85: // ADD LXY - flags &= ~C01; - case 0x9D: // SBC LXY - case 0x8D: // ADC LXY - opcode = data; - data = BYTE( ixy ); - goto adc_data; - - { - int temp; - case 0x39: // ADD IXY,SP - temp = sp; - goto add_ixy_data; - - case 0x29: // ADD IXY,HL - temp = ixy; - goto add_ixy_data; - - case 0x09: // ADD IXY,BC - case 0x19: // ADD IXY,DE - temp = R16( data, 4, 0x09 ); - add_ixy_data: { - int sum = ixy + temp; - temp ^= ixy; - ixy = WORD( sum ); - flags = (flags & (S80 | Z40 | V04)) + - (sum >> 16) + - (sum >> 8 & (F20 | F08)) + - ((temp ^ sum) >> 8 & H10); - goto set_ixy; - } - } - - // AND - case 0xA6: // AND (IXY+disp) - pc++; - data = READ_MEM( IXY_DISP( ixy, SBYTE( data2 ) ) ); - goto and_data; - - case 0xA4: // AND HXY - data = ixy >> 8; - goto and_data; - - case 0xA5: // AND LXY - data = BYTE( ixy ); - goto and_data; - - // OR - case 0xB6: // OR (IXY+disp) - pc++; - data = READ_MEM( IXY_DISP( ixy, SBYTE( data2 ) ) ); - goto or_data; - - case 0xB4: // OR HXY - data = ixy >> 8; - goto or_data; - - case 0xB5: // OR LXY - data = BYTE( ixy ); - goto or_data; - - // XOR - case 0xAE: // XOR (IXY+disp) - pc++; - data = READ_MEM( IXY_DISP( ixy, SBYTE( data2 ) ) ); - goto xor_data; - - case 0xAC: // XOR HXY - data = ixy >> 8; - goto xor_data; - - case 0xAD: // XOR LXY - data = BYTE( ixy ); - goto xor_data; - - // CP - case 0xBE: // CP (IXY+disp) - pc++; - data = READ_MEM( IXY_DISP( ixy, SBYTE( data2 ) ) ); - goto cp_data; - - case 0xBC: // CP HXY - data = ixy >> 8; - goto cp_data; - - case 0xBD: // CP LXY - data = BYTE( ixy ); - goto cp_data; - - // LD - CASE7( 70, 71, 72, 73, 74, 75, 77 ): // LD (IXY+disp),r - data = R8( data, 0x70 ); - if ( 0 ) - case 0x36: // LD (IXY+disp),imm - pc++, data = READ_CODE( pc ); - pc++; - WRITE_MEM( IXY_DISP( ixy, SBYTE( data2 ) ), data ); - goto loop; - - CASE5( 44, 4C, 54, 5C, 7C ): // LD r,HXY - R8( data >> 3, 8 ) = ixy >> 8; - goto loop; - - case 0x64: // LD HXY,HXY - case 0x6D: // LD LXY,LXY - goto loop; - - CASE5( 45, 4D, 55, 5D, 7D ): // LD r,LXY - R8( data >> 3, 8 ) = ixy; - goto loop; - - CASE7( 46, 4E, 56, 5E, 66, 6E, 7E ): // LD r,(IXY+disp) - pc++; - R8( data >> 3, 8 ) = READ_MEM( IXY_DISP( ixy, SBYTE( data2 ) ) ); - goto loop; - - case 0x26: // LD HXY,imm - pc++; - goto ld_hxy_data; - - case 0x65: // LD HXY,LXY - data2 = BYTE( ixy ); - goto ld_hxy_data; - - CASE5( 60, 61, 62, 63, 67 ): // LD HXY,r - data2 = R8( data, 0x60 ); - ld_hxy_data: - ixy = BYTE( ixy ) + (data2 << 8); - goto set_ixy; - - case 0x2E: // LD LXY,imm - pc++; - goto ld_lxy_data; - - case 0x6C: // LD LXY,HXY - data2 = ixy >> 8; - goto ld_lxy_data; - - CASE5( 68, 69, 6A, 6B, 6F ): // LD LXY,r - data2 = R8( data, 0x68 ); - ld_lxy_data: - ixy = (ixy & 0xFF00) + data2; - set_ixy: - if ( opcode == 0xDD ) - { - ix = ixy; - goto loop; - } - iy = ixy; - goto loop; - - case 0xF9: // LD SP,IXY - sp = ixy; - goto loop; - - case 0x22:{// LD (ADDR),IXY - int addr = GET_ADDR(); - pc += 2; - WRITE_WORD( addr, ixy ); - goto loop; - } - - case 0x21: // LD IXY,imm - ixy = GET_ADDR(); - pc += 2; - goto set_ixy; - - case 0x2A:{// LD IXY,(addr) - int addr = GET_ADDR(); - ixy = READ_WORD( addr ); - pc += 2; - goto set_ixy; - } - - // DD/FD CB prefix - case 0xCB: { - data = IXY_DISP( ixy, SBYTE( data2 ) ); - pc++; - data2 = READ_CODE( pc ); - pc++; - switch ( data2 ) - { - case 0x06: goto rlc_data_addr; // RLC (IXY) - case 0x16: goto rl_data_addr; // RL (IXY) - case 0x26: goto sla_data_addr; // SLA (IXY) - case 0x36: goto sll_data_addr; // SLL (IXY) - case 0x0E: goto rrc_data_addr; // RRC (IXY) - case 0x1E: goto rr_data_addr; // RR (IXY) - case 0x2E: goto sra_data_addr; // SRA (IXY) - case 0x3E: goto srl_data_addr; // SRL (IXY) - - CASE8( 46, 4E, 56, 5E, 66, 6E, 76, 7E ):{// BIT b,(IXY+disp) - int temp = READ_MEM( data ); - temp = temp & (1 << (data2 >> 3 & 7)); - flags = (flags & C01) + H10 + (temp & S80); - flags += (unsigned) --temp >> 8 & (Z40 | P04); - goto loop; - } - - CASE8( 86, 8E, 96, 9E, A6, AE, B6, BE ): // RES b,(IXY+disp) - CASE8( C6, CE, D6, DE, E6, EE, F6, FE ):{// SET b,(IXY+disp) - int temp = READ_MEM( data ); - int bit = 1 << (data2 >> 3 & 7); - temp |= bit; // SET - if ( !(data2 & 0x40) ) - temp ^= bit; // RES - WRITE_MEM( data, temp ); - goto loop; - } - - default: - dprintf( "Opcode $%02X $CB $%02X not supported\n", opcode, data2 ); - warning = true; - goto loop; - } - assert( false ); - } - - // INC/DEC - case 0x23: // INC IXY - ixy = WORD( ixy + 1 ); - goto set_ixy; - - case 0x2B: // DEC IXY - ixy = WORD( ixy - 1 ); - goto set_ixy; - - case 0x34: // INC (IXY+disp) - ixy = IXY_DISP( ixy, SBYTE( data2 ) ); - pc++; - data = READ_MEM( ixy ) + 1; - WRITE_MEM( ixy, data ); - goto inc_set_flags; - - case 0x35: // DEC (IXY+disp) - ixy = IXY_DISP( ixy, SBYTE( data2 ) ); - pc++; - data = READ_MEM( ixy ) - 1; - WRITE_MEM( ixy, data ); - goto dec_set_flags; - - case 0x24: // INC HXY - ixy = WORD( ixy + 0x100 ); - data = ixy >> 8; - goto inc_xy_common; - - case 0x2C: // INC LXY - data = BYTE( ixy + 1 ); - ixy = (ixy & 0xFF00) + data; - inc_xy_common: - if ( opcode == 0xDD ) - { - ix = ixy; - goto inc_set_flags; - } - iy = ixy; - goto inc_set_flags; - - case 0x25: // DEC HXY - ixy = WORD( ixy - 0x100 ); - data = ixy >> 8; - goto dec_xy_common; - - case 0x2D: // DEC LXY - data = BYTE( ixy - 1 ); - ixy = (ixy & 0xFF00) + data; - dec_xy_common: - if ( opcode == 0xDD ) - { - ix = ixy; - goto dec_set_flags; - } - iy = ixy; - goto dec_set_flags; - - // PUSH/POP - case 0xE5: // PUSH IXY - data = ixy; - goto push_data; - - case 0xE1:{// POP IXY - ixy = READ_WORD( sp ); - sp = WORD( sp + 2 ); - goto set_ixy; - } - - // Misc - - case 0xE9: // JP (IXY) - pc = ixy; - goto loop; - - case 0xE3:{// EX (SP),IXY - int temp = READ_WORD( sp ); - WRITE_WORD( sp, ixy ); - ixy = temp; - goto set_ixy; - } - - default: - dprintf( "Unnecessary DD/FD prefix encountered\n" ); - warning = true; - pc--; - goto loop; - } - assert( false ); - } - - } - dprintf( "Unhandled main opcode: $%02X\n", opcode ); - assert( false ); - -#ifdef IDLE_ADDR -hit_idle_addr: - s_time -= 11; - goto out_of_time; -#endif -halt: - s_time &= 3; // increment by multiple of 4 -out_of_time: - pc--; - - r.b.flags = flags; - R.ix = ix; - R.iy = iy; - R.sp = sp; - R.pc = pc; - R.b = r.b; - - cpu->cpu_state_.base = s.base; - cpu->cpu_state_.time = s_time; - cpu->cpu_state = &cpu->cpu_state_; -} diff --git a/apps/codecs/libm4a/SOURCES b/apps/codecs/libm4a/SOURCES deleted file mode 100644 index 01b93bef01..0000000000 --- a/apps/codecs/libm4a/SOURCES +++ /dev/null @@ -1,2 +0,0 @@ -m4a.c -demux.c diff --git a/apps/codecs/libm4a/demux.c b/apps/codecs/libm4a/demux.c deleted file mode 100644 index 7b09074c52..0000000000 --- a/apps/codecs/libm4a/demux.c +++ /dev/null @@ -1,826 +0,0 @@ -/* - * ALAC (Apple Lossless Audio Codec) decoder - * Copyright (c) 2005 David Hammerton - * All rights reserved. - * - * This is the quicktime container demuxer. - * - * http://crazney.net/programs/itunes/alac.html - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - * - */ - -#include -#include -#include - -#include "codeclib.h" - -#include "m4a.h" - -#undef DEBUGF -#if defined(DEBUG) -#define DEBUGF qtmovie->stream->ci->debugf -#else -#define DEBUGF(...) -#endif - -typedef struct -{ - stream_t *stream; - demux_res_t *res; -} qtmovie_t; - - -/* chunk handlers */ -static void read_chunk_ftyp(qtmovie_t *qtmovie, size_t chunk_len) -{ - fourcc_t type; - size_t size_remaining = chunk_len - 8; - - type = stream_read_uint32(qtmovie->stream); - size_remaining-=4; - if ((type != MAKEFOURCC('M','4','A',' ')) && - (type != MAKEFOURCC('m','4','a',' ')) && - (type != MAKEFOURCC('M','4','B',' ')) && - (type != MAKEFOURCC('m','p','4','2')) && - (type != MAKEFOURCC('3','g','p','6')) && - (type != MAKEFOURCC('q','t',' ',' ')) && - (type != MAKEFOURCC('i','s','o','m'))) - { - DEBUGF("not M4A file\n"); - return; - } - /* minor_ver = */ stream_read_uint32(qtmovie->stream); - size_remaining-=4; - - /* compatible brands */ - while (size_remaining) - { - /* unused */ - /*fourcc_t cbrand =*/ stream_read_uint32(qtmovie->stream); - size_remaining-=4; - } -} - -static uint32_t mp4ff_read_mp4_descr_length(stream_t* stream) -{ - uint8_t b; - uint8_t numBytes = 0; - uint32_t length = 0; - - do - { - b = stream_read_uint8(stream); - numBytes++; - length = (length << 7) | (b & 0x7F); - } while ((b & 0x80) && numBytes < 4); - - return length; -} - -/* The following function is based on mp4ff */ -static bool read_chunk_esds(qtmovie_t *qtmovie, size_t chunk_len) -{ - uint8_t tag; - uint32_t temp; - - (void)chunk_len; - /* version and flags */ - temp=stream_read_uint32(qtmovie->stream); - - /* get and verify ES_DescrTag */ - tag = stream_read_uint8(qtmovie->stream); - if (tag == 0x03) - { - /* read length */ - if (mp4ff_read_mp4_descr_length(qtmovie->stream) < 5 + 15) - { - return false; - } - /* skip 3 bytes */ - stream_skip(qtmovie->stream,3); - } else { - /* skip 2 bytes */ - stream_skip(qtmovie->stream,2); - } - - /* get and verify DecoderConfigDescrTab */ - if (stream_read_uint8(qtmovie->stream) != 0x04) - { - return false; - } - - /* read length */ - temp = mp4ff_read_mp4_descr_length(qtmovie->stream); - if (temp < 13) return false; - - /* audioType = */ stream_read_uint8(qtmovie->stream); - /* temp = */ stream_read_int32(qtmovie->stream);//0x15000414 ???? - /* maxBitrate = */ stream_read_int32(qtmovie->stream); - /* avgBitrate = */ stream_read_int32(qtmovie->stream); - - /* get and verify DecSpecificInfoTag */ - if (stream_read_uint8(qtmovie->stream) != 0x05) - { - return false; - } - - /* read length */ - qtmovie->res->codecdata_len = mp4ff_read_mp4_descr_length(qtmovie->stream); - if (qtmovie->res->codecdata_len > MAX_CODECDATA_SIZE) - { - DEBUGF("codecdata too large (%d) in esds\n", - (int)qtmovie->res->codecdata_len); - return false; - } - - stream_read(qtmovie->stream, qtmovie->res->codecdata_len, qtmovie->res->codecdata); - - /* will skip the remainder of the atom */ - return true; -} - -static bool read_chunk_stsd(qtmovie_t *qtmovie, size_t chunk_len) -{ - unsigned int i; - int j; - uint32_t numentries; - size_t size_remaining = chunk_len - 8; - bool got_codec_data = false; - - /* version */ - stream_read_uint8(qtmovie->stream); - size_remaining -= 1; - /* flags */ - stream_read_uint8(qtmovie->stream); - stream_read_uint8(qtmovie->stream); - stream_read_uint8(qtmovie->stream); - size_remaining -= 3; - - numentries = stream_read_uint32(qtmovie->stream); - size_remaining -= 4; - - /* if (numentries != 1) - { - DEBUGF("only expecting one entry in sample description atom!\n"); - return false; - } */ - - for (i = 0; i < numentries; i++) - { - uint32_t entry_size; - - uint32_t entry_remaining; - - entry_size = stream_read_uint32(qtmovie->stream); - qtmovie->res->format = stream_read_uint32(qtmovie->stream); - DEBUGF("format: %c%c%c%c\n",SPLITFOURCC(qtmovie->res->format)); - entry_remaining = entry_size; - entry_remaining -= 8; - - /* sound info: */ - - /* reserved + data reference index + sound version + reserved */ - stream_skip(qtmovie->stream, 6 + 2 + 2 + 6); - entry_remaining -= 6 + 2 + 2 + 6; - - qtmovie->res->num_channels = stream_read_uint16(qtmovie->stream); - qtmovie->res->sound_sample_size = stream_read_uint16(qtmovie->stream); - entry_remaining -= 4; - - /* packet size */ - stream_skip(qtmovie->stream, 2); - qtmovie->res->sound_sample_rate = stream_read_uint32(qtmovie->stream); - /* reserved size */ - stream_skip(qtmovie->stream, 2); - entry_remaining -= 8; - - /* remaining is codec data */ - - if ((qtmovie->res->format==MAKEFOURCC('a','l','a','c'))) { - if (qtmovie->stream->ci->id3->codectype!=AFMT_MP4_ALAC) { - return false; - } - - /* 12 = audio format atom, 8 = padding */ - qtmovie->res->codecdata_len = entry_remaining + 12 + 8; - if (qtmovie->res->codecdata_len > MAX_CODECDATA_SIZE) - { - DEBUGF("codecdata too large (%d) in stsd\n", - (int)qtmovie->res->codecdata_len); - return false; - } - - memset(qtmovie->res->codecdata, 0, qtmovie->res->codecdata_len); - /* audio format atom */ -#if 0 - /* The ALAC decoder skips these bytes, so there is no need to store them, - and this code isn't endian/alignment safe */ - ((unsigned int*)qtmovie->res->codecdata)[0] = 0x0c000000; - ((unsigned int*)qtmovie->res->codecdata)[1] = MAKEFOURCC('a','m','r','f'); - ((unsigned int*)qtmovie->res->codecdata)[2] = MAKEFOURCC('c','a','l','a'); -#endif - - stream_read(qtmovie->stream, - entry_remaining, - ((char*)qtmovie->res->codecdata) + 12); - entry_remaining -= entry_remaining; - got_codec_data = true; - - if (entry_remaining) - stream_skip(qtmovie->stream, entry_remaining); - - } else if (qtmovie->res->format==MAKEFOURCC('m','p','4','a')) { - if (qtmovie->stream->ci->id3->codectype!=AFMT_MP4_AAC && - qtmovie->stream->ci->id3->codectype!=AFMT_MP4_AAC_HE) { - return false; - } - - size_t sub_chunk_len; - fourcc_t sub_chunk_id; - - sub_chunk_len = stream_read_uint32(qtmovie->stream); - if (sub_chunk_len <= 1 || sub_chunk_len > entry_remaining) - { - DEBUGF("strange size (%lu) for chunk inside mp4a\n", - (unsigned long)sub_chunk_len); - return false; - } - - sub_chunk_id = stream_read_uint32(qtmovie->stream); - - if (sub_chunk_id != MAKEFOURCC('e','s','d','s')) - { - DEBUGF("Expected esds chunk inside mp4a, found %c%c%c%c\n",SPLITFOURCC(sub_chunk_id)); - return false; - } - - j=qtmovie->stream->ci->curpos+sub_chunk_len-8; - if (read_chunk_esds(qtmovie,sub_chunk_len)) { - if (j!=qtmovie->stream->ci->curpos) { - DEBUGF("curpos=%ld, j=%d - Skipping %ld bytes\n",qtmovie->stream->ci->curpos,j,j-qtmovie->stream->ci->curpos); - stream_skip(qtmovie->stream,j-qtmovie->stream->ci->curpos); - } - got_codec_data = true; - entry_remaining-=sub_chunk_len; - } else { - DEBUGF("Error reading esds\n"); - return false; - } - - DEBUGF("entry_remaining=%ld\n",(long)entry_remaining); - stream_skip(qtmovie->stream,entry_remaining); - - } else if (qtmovie->res->format==MAKEFOURCC('f','r','e','e')) { - /* Skip "filler" atom */ - stream_skip(qtmovie->stream,entry_remaining); - } else { - DEBUGF("expecting 'alac', 'mp4a' or 'free' data format, got %c%c%c%c\n", - SPLITFOURCC(qtmovie->res->format)); - return false; - } - } - return got_codec_data; -} - -static bool read_chunk_stts(qtmovie_t *qtmovie, size_t chunk_len) -{ - unsigned int i; - uint32_t numentries; - size_t size_remaining = chunk_len - 8; - - /* version */ - stream_read_uint8(qtmovie->stream); - size_remaining -= 1; - /* flags */ - stream_read_uint8(qtmovie->stream); - stream_read_uint8(qtmovie->stream); - stream_read_uint8(qtmovie->stream); - size_remaining -= 3; - - numentries = stream_read_uint32(qtmovie->stream); - size_remaining -= 4; - - qtmovie->res->num_time_to_samples = numentries; - qtmovie->res->time_to_sample = malloc(numentries * sizeof(*qtmovie->res->time_to_sample)); - - if (!qtmovie->res->time_to_sample) - { - DEBUGF("stts too large\n"); - return false; - } - - for (i = 0; i < numentries; i++) - { - qtmovie->res->time_to_sample[i].sample_count = stream_read_uint32(qtmovie->stream); - qtmovie->res->time_to_sample[i].sample_duration = stream_read_uint32(qtmovie->stream); - size_remaining -= 8; - } - - if (size_remaining) - { - DEBUGF("ehm, size remianing?\n"); - stream_skip(qtmovie->stream, size_remaining); - } - - return true; -} - -static bool read_chunk_stsz(qtmovie_t *qtmovie, size_t chunk_len) -{ - size_t size_remaining = chunk_len - 8; - - /* version */ - stream_read_uint8(qtmovie->stream); - size_remaining -= 1; - /* flags */ - stream_read_uint8(qtmovie->stream); - stream_read_uint8(qtmovie->stream); - stream_read_uint8(qtmovie->stream); - size_remaining -= 3; - - /* default sample size */ - if (stream_read_uint32(qtmovie->stream) != 0) - { - DEBUGF("i was expecting variable samples sizes\n"); - stream_read_uint32(qtmovie->stream); - size_remaining -= 4; - return true; - } - size_remaining -= 4; - - qtmovie->res->num_sample_byte_sizes = stream_read_uint32(qtmovie->stream); - size_remaining -= 4; - - if (size_remaining) - { - stream_skip(qtmovie->stream, size_remaining); - } - - return true; -} - -static bool read_chunk_stsc(qtmovie_t *qtmovie, size_t chunk_len) -{ - unsigned int i; - uint32_t numentries; - size_t size_remaining = chunk_len - 8; - - /* version + flags */ - stream_read_uint32(qtmovie->stream); - size_remaining -= 4; - - numentries = stream_read_uint32(qtmovie->stream); - size_remaining -= 4; - - qtmovie->res->num_sample_to_chunks = numentries; - qtmovie->res->sample_to_chunk = malloc(numentries * sizeof(sample_to_chunk_t)); - - if (!qtmovie->res->sample_to_chunk) - { - DEBUGF("stsc too large\n"); - return false; - } - - for (i = 0; i < numentries; i++) - { - qtmovie->res->sample_to_chunk[i].first_chunk = - stream_read_uint32(qtmovie->stream); - qtmovie->res->sample_to_chunk[i].num_samples = - stream_read_uint32(qtmovie->stream); - stream_read_uint32(qtmovie->stream); - size_remaining -= 12; - } - - if (size_remaining) - { - DEBUGF("ehm, size remianing?\n"); - stream_skip(qtmovie->stream, size_remaining); - } - - return true; -} - -static bool read_chunk_stco(qtmovie_t *qtmovie, size_t chunk_len) -{ - uint32_t i, k, old_i; - uint32_t numentries; - uint32_t idx = 0; - uint32_t frame; - uint32_t offset; - uint32_t old_first; - uint32_t new_first; - uint32_t old_frame; - size_t size_remaining = chunk_len - 8; - - /* version + flags */ - stream_read_uint32(qtmovie->stream); - size_remaining -= 4; - - numentries = stream_read_uint32(qtmovie->stream); - size_remaining -= 4; - - qtmovie->res->num_lookup_table = numentries; - qtmovie->res->lookup_table = malloc(numentries * sizeof(*qtmovie->res->lookup_table)); - - if (!qtmovie->res->lookup_table) - { - DEBUGF("stco too large to allocate lookup_table[]\n"); - return false; - } - - /* read first offset */ - offset = stream_read_uint32(qtmovie->stream); - size_remaining -= 4; - - /* Build up lookup table. The lookup table contains the sample index and - * byte position in the file for each chunk. This table is used to seek - * and resume (see m4a_seek() and m4a_seek_raw() in libm4a/m4a.c) and - * to skip empty chunks (see m4a_check_sample_offset() in codecs/aac.c and - * libm4a/m4a.c). - * The seek/resume precision is lower than using sample_byte_size[] and - * depends on numentries. Typically the resolution is ~1/10 of all frames - * which equals about 1/4-1/2 seconds. The loss of seek precision is - * accepted to be able to avoid allocation of the large sample_byte_size[] - * table. This reduces the memory consumption by a factor of 2 or even - * more. */ - i = 1; - old_i = 1; - frame = 0; - old_first = qtmovie->res->sample_to_chunk[0].first_chunk; - old_frame = qtmovie->res->sample_to_chunk[0].num_samples; - new_first = qtmovie->res->sample_to_chunk[1].first_chunk; - for (k = 1; k < numentries; ++k) - { - for (; i < qtmovie->res->num_sample_to_chunks; ++i) - { - if (i > old_i) - { - /* Only access sample_to_chunk[] if new data is required. */ - old_first = qtmovie->res->sample_to_chunk[i-1].first_chunk; - old_frame = qtmovie->res->sample_to_chunk[i-1].num_samples; - new_first = qtmovie->res->sample_to_chunk[i ].first_chunk; - old_i = i; - } - - if (new_first > k) - break; - - frame += (new_first - old_first) * old_frame; - } - frame += (k - old_first) * old_frame; - - qtmovie->res->lookup_table[idx].sample = frame; - qtmovie->res->lookup_table[idx].offset = offset; - idx++; - - frame -= (k - old_first) * old_frame; - - offset = stream_read_uint32(qtmovie->stream); - size_remaining -= 4; - } - /* zero-terminate the lookup table */ - qtmovie->res->lookup_table[idx].sample = 0; - qtmovie->res->lookup_table[idx].offset = 0; - - if (size_remaining) - { - DEBUGF("ehm, size remianing?\n"); - stream_skip(qtmovie->stream, size_remaining); - } - - return true; -} - -static bool read_chunk_stbl(qtmovie_t *qtmovie, size_t chunk_len) -{ - size_t size_remaining = chunk_len - 8; - - while (size_remaining) - { - size_t sub_chunk_len; - fourcc_t sub_chunk_id; - - sub_chunk_len = stream_read_uint32(qtmovie->stream); - if (sub_chunk_len <= 1 || sub_chunk_len > size_remaining) - { - DEBUGF("strange size (%lu) for chunk inside stbl\n", - (unsigned long)sub_chunk_len); - return false; - } - - sub_chunk_id = stream_read_uint32(qtmovie->stream); - - switch (sub_chunk_id) - { - case MAKEFOURCC('s','t','s','d'): - if (!read_chunk_stsd(qtmovie, sub_chunk_len)) { - return false; - } - break; - case MAKEFOURCC('s','t','t','s'): - if (!read_chunk_stts(qtmovie, sub_chunk_len)) - { - return false; - } - break; - case MAKEFOURCC('s','t','s','z'): - if (!read_chunk_stsz(qtmovie, sub_chunk_len)) - { - return false; - } - break; - case MAKEFOURCC('s','t','s','c'): - if (!read_chunk_stsc(qtmovie, sub_chunk_len)) - { - return false; - } - break; - case MAKEFOURCC('s','t','c','o'): - if (!read_chunk_stco(qtmovie, sub_chunk_len)) - { - return false; - } - break; - default: - /*DEBUGF("(stbl) unknown chunk id: %c%c%c%c\n", - SPLITFOURCC(sub_chunk_id));*/ - stream_skip(qtmovie->stream, sub_chunk_len - 8); - } - - size_remaining -= sub_chunk_len; - } - return true; -} - -static bool read_chunk_minf(qtmovie_t *qtmovie, size_t chunk_len) -{ - size_t size_remaining = chunk_len - 8; - uint32_t i; - - /* Check for smhd, only kind of minf we care about */ - - if ((i = stream_read_uint32(qtmovie->stream)) != 16) - { - DEBUGF("unexpected size in media info: %ld\n", (long)i); - stream_skip(qtmovie->stream, size_remaining-4); - return true; - } - - if (stream_read_uint32(qtmovie->stream) != MAKEFOURCC('s','m','h','d')) - { - DEBUGF("not a sound header! can't handle this.\n"); - return false; - } - - /* now skip the rest of the atom */ - stream_skip(qtmovie->stream, 16 - 8); - size_remaining -= 16; - - while (size_remaining) - { - size_t sub_chunk_len; - fourcc_t sub_chunk_id; - - sub_chunk_len = stream_read_uint32(qtmovie->stream); - - if (sub_chunk_len <= 1 || sub_chunk_len > size_remaining) - { - DEBUGF("strange size (%lu) for chunk inside minf\n", - (unsigned long)sub_chunk_len); - return false; - } - - sub_chunk_id = stream_read_uint32(qtmovie->stream); - - switch (sub_chunk_id) - { - case MAKEFOURCC('s','t','b','l'): - if (!read_chunk_stbl(qtmovie, sub_chunk_len)) { - return false; - } - break; - default: - /*DEBUGF("(minf) unknown chunk id: %c%c%c%c\n", - SPLITFOURCC(sub_chunk_id));*/ - stream_skip(qtmovie->stream, sub_chunk_len - 8); - break; - } - - size_remaining -= sub_chunk_len; - } - return true; -} - -static bool read_chunk_mdia(qtmovie_t *qtmovie, size_t chunk_len) -{ - size_t size_remaining = chunk_len - 8; - - while (size_remaining) - { - size_t sub_chunk_len; - fourcc_t sub_chunk_id; - - sub_chunk_len = stream_read_uint32(qtmovie->stream); - if (sub_chunk_len <= 1 || sub_chunk_len > size_remaining) - { - DEBUGF("strange size (%lu) for chunk inside mdia\n", - (unsigned long)sub_chunk_len); - return false; - } - - sub_chunk_id = stream_read_uint32(qtmovie->stream); - - switch (sub_chunk_id) - { - case MAKEFOURCC('m','i','n','f'): - if (!read_chunk_minf(qtmovie, sub_chunk_len)) { - return false; - } - break; - default: - /*DEBUGF("(mdia) unknown chunk id: %c%c%c%c\n", - SPLITFOURCC(sub_chunk_id));*/ - stream_skip(qtmovie->stream, sub_chunk_len - 8); - break; - } - - size_remaining -= sub_chunk_len; - } - return true; -} - -/* 'trak' - a movie track - contains other atoms */ -static bool read_chunk_trak(qtmovie_t *qtmovie, size_t chunk_len) -{ - size_t size_remaining = chunk_len - 8; - - while (size_remaining) - { - size_t sub_chunk_len; - fourcc_t sub_chunk_id; - - sub_chunk_len = stream_read_uint32(qtmovie->stream); - if (sub_chunk_len <= 1 || sub_chunk_len > size_remaining) - { - DEBUGF("strange size (%lu) for chunk inside trak\n", - (unsigned long)sub_chunk_len); - return false; - } - - sub_chunk_id = stream_read_uint32(qtmovie->stream); - - switch (sub_chunk_id) - { - case MAKEFOURCC('m','d','i','a'): - if (!read_chunk_mdia(qtmovie, sub_chunk_len)) { - return false; - } - break; - default: - /*DEBUGF("(trak) unknown chunk id: %c%c%c%c\n", - SPLITFOURCC(sub_chunk_id));*/ - stream_skip(qtmovie->stream, sub_chunk_len - 8); - break; - } - - size_remaining -= sub_chunk_len; - } - return true; -} - -/* 'moov' movie atom - contains other atoms */ -static bool read_chunk_moov(qtmovie_t *qtmovie, size_t chunk_len) -{ - size_t size_remaining = chunk_len - 8; - - while (size_remaining) - { - size_t sub_chunk_len; - fourcc_t sub_chunk_id; - - sub_chunk_len = stream_read_uint32(qtmovie->stream); - if (sub_chunk_len <= 1 || sub_chunk_len > size_remaining) - { - DEBUGF("strange size (%lu) for chunk inside moov\n", - (unsigned long)sub_chunk_len); - return false; - } - - sub_chunk_id = stream_read_uint32(qtmovie->stream); - - switch (sub_chunk_id) - { - case MAKEFOURCC('t','r','a','k'): - if (!read_chunk_trak(qtmovie, sub_chunk_len)) { - return false; - } - break; - default: - /*DEBUGF("(moov) unknown chunk id: %c%c%c%c\n", - SPLITFOURCC(sub_chunk_id));*/ - stream_skip(qtmovie->stream, sub_chunk_len - 8); - break; - } - - size_remaining -= sub_chunk_len; - } - return true; -} - -static void read_chunk_mdat(qtmovie_t *qtmovie, size_t chunk_len) -{ - size_t size_remaining = chunk_len - 8; - - qtmovie->res->mdat_len = size_remaining; -} - -int qtmovie_read(stream_t *file, demux_res_t *demux_res) -{ - qtmovie_t qtmovie; - - /* construct the stream */ - qtmovie.stream = file; - qtmovie.res = demux_res; - - /* read the chunks */ - while (1) - { - size_t chunk_len; - fourcc_t chunk_id; - - chunk_len = stream_read_uint32(qtmovie.stream); - if (stream_eof(qtmovie.stream)) - { - if(qtmovie.res->mdat_offset == 0 || qtmovie.res->format == 0) - return 0; - stream_seek(qtmovie.stream, qtmovie.res->mdat_offset); - return 1; - } - - if (chunk_len == 1) - { - //DEBUGF("need 64bit support\n"); - return 0; - } - chunk_id = stream_read_uint32(qtmovie.stream); - - //DEBUGF("Found a chunk %c%c%c%c, length=%d\n",SPLITFOURCC(chunk_id),chunk_len); - switch (chunk_id) - { - case MAKEFOURCC('f','t','y','p'): - read_chunk_ftyp(&qtmovie, chunk_len); - break; - case MAKEFOURCC('m','o','o','v'): - if (!read_chunk_moov(&qtmovie, chunk_len)) { - return 0; - } - break; - case MAKEFOURCC('m','d','a','t'): - /* There can be empty mdats before the real one. If so, skip them */ - if (chunk_len == 8) - break; - read_chunk_mdat(&qtmovie, chunk_len); - qtmovie.res->mdat_offset=stream_tell(qtmovie.stream); - /* If we've already seen the format, assume there's nothing - interesting after the mdat chunk (the file is "streamable"). - This avoids having to seek, which might cause rebuffering. */ - if(qtmovie.res->format > 0) - return 1; - stream_skip(qtmovie.stream, chunk_len - 8); - break; - - /* these following atoms can be skipped !!!! */ - case MAKEFOURCC('f','r','e','e'): - stream_skip(qtmovie.stream, chunk_len - 8); - break; - default: - //DEBUGF("(top) unknown chunk id: %c%c%c%c\n",SPLITFOURCC(chunk_id)); - return 0; - } - - } - return 0; -} - - diff --git a/apps/codecs/libm4a/libm4a.make b/apps/codecs/libm4a/libm4a.make deleted file mode 100644 index 9a8a4cb74a..0000000000 --- a/apps/codecs/libm4a/libm4a.make +++ /dev/null @@ -1,18 +0,0 @@ -# __________ __ ___. -# Open \______ \ ____ ____ | | _\_ |__ _______ ___ -# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / -# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < -# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ -# \/ \/ \/ \/ \/ -# $Id$ -# - -# libm4a -M4ALIB := $(CODECDIR)/libm4a.a -M4ALIB_SRC := $(call preprocess, $(APPSDIR)/codecs/libm4a/SOURCES) -M4ALIB_OBJ := $(call c2obj, $(M4ALIB_SRC)) -OTHER_SRC += $(M4ALIB_SRC) - -$(M4ALIB): $(M4ALIB_OBJ) - $(SILENT)$(shell rm -f $@) - $(call PRINTS,AR $(@F))$(AR) rcs $@ $^ >/dev/null diff --git a/apps/codecs/libm4a/m4a.c b/apps/codecs/libm4a/m4a.c deleted file mode 100644 index 5fe778ac03..0000000000 --- a/apps/codecs/libm4a/m4a.c +++ /dev/null @@ -1,267 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2005 Dave Chapman, 2011 Andree Buschmann - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ - -#include -#include -#include "m4a.h" - -/* Implementation of the stream.h functions used by libalac */ - -#define _Swap32(v) do { \ - v = (((v) & 0x000000FF) << 0x18) | \ - (((v) & 0x0000FF00) << 0x08) | \ - (((v) & 0x00FF0000) >> 0x08) | \ - (((v) & 0xFF000000) >> 0x18); } while(0) - -#define _Swap16(v) do { \ - v = (((v) & 0x00FF) << 0x08) | \ - (((v) & 0xFF00) >> 0x08); } while (0) - -/* A normal read without any byte-swapping */ -void stream_read(stream_t *stream, size_t size, void *buf) -{ - stream->ci->read_filebuf(buf,size); - if (stream->ci->curpos >= stream->ci->filesize) { stream->eof=1; } -} - -int32_t stream_read_int32(stream_t *stream) -{ - int32_t v; - stream_read(stream, 4, &v); -#ifdef ROCKBOX_LITTLE_ENDIAN - _Swap32(v); -#endif - return v; -} - -int32_t stream_tell(stream_t *stream) -{ - return stream->ci->curpos; -} - -uint32_t stream_read_uint32(stream_t *stream) -{ - uint32_t v; - stream_read(stream, 4, &v); -#ifdef ROCKBOX_LITTLE_ENDIAN - _Swap32(v); -#endif - return v; -} - -uint16_t stream_read_uint16(stream_t *stream) -{ - uint16_t v; - stream_read(stream, 2, &v); -#ifdef ROCKBOX_LITTLE_ENDIAN - _Swap16(v); -#endif - return v; -} - -uint8_t stream_read_uint8(stream_t *stream) -{ - uint8_t v; - stream_read(stream, 1, &v); - return v; -} - -void stream_skip(stream_t *stream, size_t skip) -{ - stream->ci->advance_buffer(skip); -} - -void stream_seek(stream_t *stream, size_t offset) -{ - stream->ci->seek_buffer(offset); -} - -int stream_eof(stream_t *stream) -{ - return stream->eof; -} - -void stream_create(stream_t *stream,struct codec_api* ci) -{ - stream->ci=ci; - stream->eof=0; -} - -/* Check if there is a dedicated byte position contained for the given frame. - * Return this byte position in case of success or return -1. This allows to - * skip empty samples. - * During standard playback the search result (index i) will always increase. - * Therefor we save this index and let the caller set this value again as start - * index when calling m4a_check_sample_offset() for the next frame. This - * reduces the overall loop count significantly. */ -int m4a_check_sample_offset(demux_res_t *demux_res, uint32_t frame, uint32_t *start) -{ - uint32_t i = *start; - for (i=0; inum_lookup_table; ++i) - { - if (demux_res->lookup_table[i].sample > frame || - demux_res->lookup_table[i].offset == 0) - return -1; - if (demux_res->lookup_table[i].sample == frame) - break; - } - *start = i; - return demux_res->lookup_table[i].offset; -} - -/* Find the exact or preceding frame in lookup_table[]. Return both frame - * and byte position of this match. */ -static void gather_offset(demux_res_t *demux_res, uint32_t *frame, uint32_t *offset) -{ - uint32_t i = 0; - for (i=0; inum_lookup_table; ++i) - { - if (demux_res->lookup_table[i].offset == 0) - break; - if (demux_res->lookup_table[i].sample > *frame) - break; - } - i = (i>0) ? i-1 : 0; /* We want the last chunk _before_ *frame. */ - *frame = demux_res->lookup_table[i].sample; - *offset = demux_res->lookup_table[i].offset; -} - -/* Seek to desired sound sample location. Return 1 on success (and modify - * sound_samples_done and current_sample), 0 if failed. - * - * Find the sample (=frame) that contains the given sound sample, find a best - * fit for this sample in the lookup_table[], seek to the byte position. */ -unsigned int m4a_seek(demux_res_t* demux_res, stream_t* stream, - uint32_t sound_sample_loc, uint32_t* sound_samples_done, - int* current_sample) -{ - uint32_t i = 0; - uint32_t tmp_var, tmp_cnt, tmp_dur; - uint32_t new_sample = 0; /* Holds the amount of chunks/frames. */ - uint32_t new_sound_sample = 0; /* Sums up total amount of samples. */ - uint32_t new_pos; /* Holds the desired chunk/frame index. */ - - /* First check we have the appropriate metadata - we should always - * have it. - */ - if (!demux_res->num_time_to_samples || !demux_res->num_sample_byte_sizes) - { - return 0; - } - - /* Find the destination block from time_to_sample array */ - time_to_sample_t *tab = demux_res->time_to_sample; - while (i < demux_res->num_time_to_samples) - { - tmp_cnt = tab[i].sample_count; - tmp_dur = tab[i].sample_duration; - tmp_var = tmp_cnt * tmp_dur; - if (sound_sample_loc <= new_sound_sample + tmp_var) - { - tmp_var = (sound_sample_loc - new_sound_sample); - new_sample += tmp_var / tmp_dur; - new_sound_sample += tmp_var; - break; - } - new_sample += tmp_cnt; - new_sound_sample += tmp_var; - ++i; - } - - /* We know the new sample (=frame), now calculate the file position. */ - gather_offset(demux_res, &new_sample, &new_pos); - - /* We know the new file position, so let's try to seek to it */ - if (stream->ci->seek_buffer(new_pos)) - { - *sound_samples_done = new_sound_sample; - *current_sample = new_sample; - return 1; - } - - return 0; -} - -/* Seek to the sample containing file_loc. Return 1 on success (and modify - * sound_samples_done and current_sample), 0 if failed. - * - * Seeking uses the following arrays: - * - * 1) the lookup_table array contains the file offset for the first sample - * of each chunk. - * - * 2) the time_to_sample array contains the duration (in sound samples) - * of each sample of data. - * - * Locate the chunk containing location (using lookup_table), find the first - * sample of that chunk (using lookup_table). Then use time_to_sample to - * calculate the sound_samples_done value. - */ -unsigned int m4a_seek_raw(demux_res_t* demux_res, stream_t* stream, - uint32_t file_loc, uint32_t* sound_samples_done, - int* current_sample) -{ - uint32_t i; - uint32_t chunk_sample = 0; - uint32_t total_samples = 0; - uint32_t new_sound_sample = 0; - uint32_t tmp_dur; - uint32_t tmp_cnt; - uint32_t new_pos; - - /* We know the desired byte offset, search for the chunk right before. - * Return the associated sample to this chunk as chunk_sample. */ - for (i=0; i < demux_res->num_lookup_table; ++i) - { - if (demux_res->lookup_table[i].offset > file_loc) - break; - } - i = (i>0) ? i-1 : 0; /* We want the last chunk _before_ file_loc. */ - chunk_sample = demux_res->lookup_table[i].sample; - new_pos = demux_res->lookup_table[i].offset; - - /* Get sound sample offset. */ - i = 0; - time_to_sample_t *tab2 = demux_res->time_to_sample; - while (i < demux_res->num_time_to_samples) - { - tmp_dur = tab2[i].sample_duration; - tmp_cnt = tab2[i].sample_count; - total_samples += tmp_cnt; - new_sound_sample += tmp_cnt * tmp_dur; - if (chunk_sample <= total_samples) - { - new_sound_sample += (chunk_sample - total_samples) * tmp_dur; - break; - } - ++i; - } - - /* Go to the new file position. */ - if (stream->ci->seek_buffer(new_pos)) - { - *sound_samples_done = new_sound_sample; - *current_sample = chunk_sample; - return 1; - } - - return 0; -} diff --git a/apps/codecs/libm4a/m4a.h b/apps/codecs/libm4a/m4a.h deleted file mode 100644 index aa8e768045..0000000000 --- a/apps/codecs/libm4a/m4a.h +++ /dev/null @@ -1,138 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2005 Dave Chapman - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ - -#ifndef _M4A_H -#define _M4A_H - -#include -#include - -/* AAC codecdata appears to always be less than 8 bytes - see - AudioSpecificConfig2 in libfaad/mp4.c - - ALAC codecdata appears to always be 44 bytes (see alac_set_info in - libalac/alac.c) but my test file contains 56 bytes. - - So we go safe and round up to 64 bytes - if we find more than this, - we give an error (even though we could possibly continue), so we - can increase this buffer. -*/ - -#define MAX_CODECDATA_SIZE 64 - -typedef struct { - struct codec_api* ci; - int eof; -} stream_t; - -typedef uint32_t fourcc_t; - -typedef struct -{ - uint32_t first_chunk; - uint32_t num_samples; -} sample_to_chunk_t; - -typedef struct -{ - uint32_t sample_count; - uint32_t sample_duration; -} time_to_sample_t; - -typedef struct -{ - uint32_t sample; - uint32_t offset; -} sample_offset_t; - -typedef struct -{ - uint16_t num_channels; - uint16_t sound_sample_size; - uint32_t sound_sample_rate; - fourcc_t format; - void *buf; - - sample_to_chunk_t *sample_to_chunk; - uint32_t num_sample_to_chunks; - - sample_offset_t *lookup_table; - uint32_t num_lookup_table; - - time_to_sample_t *time_to_sample; - uint32_t num_time_to_samples; - - uint32_t num_sample_byte_sizes; - - uint32_t codecdata_len; - uint8_t codecdata[MAX_CODECDATA_SIZE]; - - int mdat_offset; - uint32_t mdat_len; -#if 0 - void *mdat; -#endif -} demux_res_t; - -int qtmovie_read(stream_t *stream, demux_res_t *demux_res); - -#ifndef MAKEFOURCC -#define MAKEFOURCC(ch0, ch1, ch2, ch3) ( \ - ( (int32_t)(char)(ch0) << 24 ) | \ - ( (int32_t)(char)(ch1) << 16 ) | \ - ( (int32_t)(char)(ch2) << 8 ) | \ - ( (int32_t)(char)(ch3) ) ) -#endif - -#ifndef SLPITFOURCC -/* splits it into ch0, ch1, ch2, ch3 - use for printf's */ -#define SPLITFOURCC(code) \ - (char)((int32_t)code >> 24), \ - (char)((int32_t)code >> 16), \ - (char)((int32_t)code >> 8), \ - (char)code -#endif - -void stream_read(stream_t *stream, size_t len, void *buf); - -int32_t stream_tell(stream_t *stream); -int32_t stream_read_int32(stream_t *stream); -uint32_t stream_read_uint32(stream_t *stream); - -uint16_t stream_read_uint16(stream_t *stream); - -uint8_t stream_read_uint8(stream_t *stream); - -void stream_skip(stream_t *stream, size_t skip); -void stream_seek(stream_t *stream, size_t offset); - -int stream_eof(stream_t *stream); - -void stream_create(stream_t *stream,struct codec_api* ci); -unsigned int get_sample_offset(demux_res_t *demux_res, uint32_t sample); -unsigned int m4a_seek (demux_res_t* demux_res, stream_t* stream, - uint32_t sound_sample_loc, uint32_t* sound_samples_done, - int* current_sample); -unsigned int m4a_seek_raw (demux_res_t* demux_res, stream_t* stream, - uint32_t file_loc, uint32_t* sound_samples_done, int* current_sample); -int m4a_check_sample_offset(demux_res_t *demux_res, uint32_t frame, uint32_t *start); - -#endif /* STREAM_H */ diff --git a/apps/codecs/libmad/CHANGES b/apps/codecs/libmad/CHANGES deleted file mode 100644 index 3fa57ef0cf..0000000000 --- a/apps/codecs/libmad/CHANGES +++ /dev/null @@ -1,338 +0,0 @@ - - libmad - MPEG audio decoder library - Copyright (C) 2000-2004 Underbit Technologies, Inc. - - $Id$ - -=============================================================================== - -Version 0.15.1 (beta) - - * Updated to autoconf 2.59, automake 1.8.2, libtool 1.5.2. - - * Replaced Layer III IMDCT routine with one based on a faster algorithm, - improving both speed and accuracy. - - * Improved portability of the Huffman table initialization. - - * Fixed a problem that could result in an assertion failure in layer3.c - due to an invalid Layer III free format bitrate. - - * Improved the robustness of Layer II bitrate/mode combinations, and added - a new MAD_ERROR_BADMODE error enum. The allowability of low-bitrate - stereo streams is influenced by the --enable-strict-iso option to - `configure'. - -Version 0.15.0 (beta) - - * Updated to autoconf 2.57, automake 1.7.5, libtool 1.4.3. - - * Added new mad_f_div() API routine. - - * Added a 64th entry to the Layer I/Layer II scalefactor table, for better - compatibility with existing streams. The --enable-strict-iso option to - `configure' can be used to disable use of this entry. - - * Modified the header decoding routine to allow the reserved emphasis - value, for better compatibility with existing streams. The - --enable-strict-iso option to `configure' can be used to restore the - previous behavior of reporting this value as an error. - - * Added new MAD_EMPHASIS_RESERVED enumeration constant. - - * Fixed a bug in the ARM version of mad_f_scale64() discovered by Andre - McCurdy. - - * Rewrote PowerPC assembly for minor gains. - - * Modified mad_timer_fraction() to avoid the possibility of division by - zero when 0 is passed as the second argument. - - * Fixed a non-fatal problem caused by attempting to designate ancillary - bits in Layer III after a decoding error. - - * Changed to build a shared library by default. - - * Changed to use native Cygwin build by default; give --host=mingw32 to - `configure' to use MinGW (and avoid a dependency on the Cygwin DLL). - -Version 0.14.2 (beta) - - * Changed Cygwin builds to use MinGW; resulting Win32 executables no - longer have a dependency on Cygwin DLLs. - - * Added a new mad_stream_errorstr() API function to libmad for retrieving - a string description of the current error condition. - -Version 0.14.1 (beta) - - * Updated config.guess and config.sub to latest upstream versions. - - * Enabled libtool versioning rather than release numbering. - - * Improved the documentation in minimad.c. - - * Several other small fixes. - -Version 0.14.0 (beta) - - * Added a 64-bit FPM negation operation to improve performance of subband - synthesis on some platforms. - - * Improved MSVC++ portability and added MSVC++ project files. - - * Added rounding to Layer III requantization for slightly better accuracy. - -Version 0.13.0 (beta) - - * Ancillary data is now properly extracted from Layer III streams. - - * Rewrote the Layer III joint stereo decoding routine to correct a major - MPEG-2 problem and a minor MPEG-1 problem decoding intensity stereo. - - * Eliminated the dependency on sign-extending right shifts for Layer I and - Layer II. - - * Renamed `private' field to `private_bits' for better C++ compatibility. - - * Gratuitously renamed `sfreq' field to `samplerate' and - MAD_ERROR_BADSAMPLEFREQ constant to MAD_ERROR_BADSAMPLERATE. - - * Added `samplerate' and `channels' fields to synth.pcm struct to allow - these to be different from the decoded frame, and for simpler access. - - * Added new mad_stream_options() and mad_decoder_options() API entries for - special runtime decoding options. - - * Added new MAD_OPTION_IGNORECRC and MAD_OPTION_HALFSAMPLERATE options. - - * Added new MAD_FLAG_FREEFORMAT indicator flag. - - * Fixed some bugs in the async decoder. - - * Added a new mad_timer_multiply() API routine. - - * Eliminated `+' from asm constraints under Intel for better compatibility - with some compilers. - - * Fixed a PIC-related problem in imdct_l_arm.S. - - * Eliminated a static variable to make libmad thread-safe. - -Version 0.12.5 (beta) - - * Modified Layer III requantization to occur during Huffman decoding for - significant performance gains. - - * Optimized short block IMDCT by eliminating redundant calculations. - - * Made several other Layer III performance improvements; added - ASO_INTERLEAVE1, ASO_INTERLEAVE2, and ASO_ZEROCHECK - architecture-specific options for best performance on various - architectures. - - * Optimized synthesis DCT to store result values as soon as they are - calculated. - -Version 0.12.4 (beta) - - * New PowerPC fixed-point assembly courtesy of David Blythe. - - * Reorganized fixed-point assembly routines for easier maintenance and - better performance. - - * Improved performance of subband synthesis through better indexing and - fewer local variables. - - * Added alias reduction for the lower two subbands of mixed short blocks, - per a report of ambiguity with ISO/IEC 11172-3 and for uniformity with - most other implementations. Also improved alias reduction performance - using multiply/accumulate. - - * Added --enable-strict-iso option to `configure' to override best - accepted practices such as the alias reduction for mixed short blocks. - - * Improved performance of Layer III IMDCT by using longer - multiply/accumulate runs where possible. - -Version 0.12.3 (beta) - - * Added MPEG 2.5 support. - - * Added preliminary support for parameterizing the binary point position - in the fixed-point representation. - - * Added multiply/accumulate optimization to the Layer III IMDCT for long - blocks. - - * Fixed a bug in the handling of Layer III mixed_block_flag. - - * Fixed a configure problem when multiple -O CFLAGS are present. - -Version 0.12.2 (beta) - - * Rearranged the synthesis polyphase filterbank memory vector for better - locality of reference, and rewrote mad_synth_frame() to accommodate, - resulting in improved performance. - - * Discovered a combination of compiler optimization flags that further - improve performance. - - * Changed some array references in layer3.c to pointer derefs. - -Version 0.12.1 (beta) - - * Resolved the intensity + MS joint stereo issue (a simple bug). - OPT_ISKLUGE is no longer considered to be a kluge. - - * Fixed another, hopefully last main_data memory bug. - - * Split part of struct mad_frame into struct mad_header for convenience - and size. - -Version 0.12.0 (alpha) - - * Changed the build environment to use automake and libtool. A libmad - shared library can now be built using the --enable-shared option to - `configure'. - - * Added another callback to MAD's high-level decoder API after the frame - header has been read but before the frame's audio data is decoded. - - * Streamlined header processing so that mad_frame_decode() can be called - with or without having already called mad_frame_header(). - - * Fixed some other header reading miscellany, including CRC handling and - free bitrate detection, and frame length verification with free - bitrates. - - * Fixed a problem with Layer III free bitrates > 320 kbps. The main_data - buffer size should now be large enough to handle any size frame, by - virtue of the maximum possible part2_3_length. - - * Further developed the async API; arbitrary messages can now be passed to - the subsidiary decoding process. - - * Streamlined timer.c and extended its interface. It now has support for - video frame/field lengths, including output support for drop-frame - encoding. - - * Replaced many constant integer preprocessor defines with enums. - -Version 0.11.4 (beta) - - * Fixed free format bitrate discovery. - - * Changed the timer implementation and extended its interface. - - * Integrated Nicolas Pitre's patch for pre-shifting at compile-time and - for better multiply/accumulate code output. - - * Applied Simon Burge's patch to imdct_l_arm.S for a.out compatibility. - - * Added -mtune=strongarm for all ARM targets. - -Version 0.11.3 (beta) - - * Added new --enable-speed and --enable-accuracy options for `configure' - to automatically select appropriate SSO/ASO options, et al. - - * Modified subband synthesis to use multiply/accumulate optimization (if - available) for better speed and/or accuracy. - - * Incorporated Andre McCurdy's changes for further rounding optimizations - in the rest of his code. - -Version 0.11.2 (beta) - - * Incorporated Nicolas Pitre's ARM assembly and parameterized scaling - changes. - - * Incorporated Andre McCurdy's ARM assembly optimization (used only if - --enable-aso is given to `configure' to enable architecture-specific - optimizations.) - - * Reduced FPM_INTEL assembly to two instructions. - - * Fixed accuracy problems with certain FPM modes in synth.c. - - * Improved the accuracy of FPM_APPROX. - - * Improved the accuracy of SSO. - - * Improved sync discovery by checking for a sync word in the following - frame. - - * Minor code clean-up. - - * Added experimental rules for generating a libmad.so shared library. - -Version 0.11.1 (beta) - - * Moved libmad code into a separate directory. - - * Changed SSO to be disabled by default, as output accuracy is deemed to - be more important than speed in the general case. - - * Fixed a bug in Layer III sanity checking that could cause a crash on - certain random data input. - - * Extended the Layer III requantization table from 8191 to 8206 as some - encoders are known to use these values, even though ISO/IEC 11172-3 - suggests the maximum should be 8191. - -Version 0.11.0 (beta) - - * Implemented MPEG-2 extension to Lower Sampling Frequencies. - - * Improved Layer III performance by avoiding IMDCT calculation when all - input samples are zero. - - * Significantly reduced size of Layer II tables. - -Version 0.10.3 (beta) - - * Improved SSO output quality. - - * Made portable to cygwin. - - * Localized memory references in III_huffdecode() for better performance. - -Version 0.10.2 (beta) - - * Rewrote Layer III long block 36-point IMDCT routine for better - performance. - - * Improved subband synthesis fixed-point games somewhat. - -Version 0.10.1 (beta) - - * Added a subband synthesis optimization (SSO) which involves modifying - the fixed-point multiplication method during windowing. This produces - subtle differences in the output but improves performance greatly. - - * Added I_STEREO and MS_STEREO flags to frame struct. - - * Eliminated privately-used CRCFAILED flag. - - * Fixed a bug where Layer III decoding could crash on some badly-formatted - (e.g. non-MPEG) bitstreams. - - * Miscellaneous code clean-up. - -Version 0.10.0 (beta) - - * Added SPARC fixed-point math support. - - * Revamped libmad API for better high- and low-level support. - - * Documented more of the code. - - * Changed sync semantics such that new stream buffers are assumed to be - sync-aligned. - - * Changed Layer III to dynamically allocate static memory so as not to - waste it (about 6.4K) when only decoding Layer I or Layer II. - -=============================================================================== - diff --git a/apps/codecs/libmad/COPYING b/apps/codecs/libmad/COPYING deleted file mode 100644 index d60c31a97a..0000000000 --- a/apps/codecs/libmad/COPYING +++ /dev/null @@ -1,340 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General -Public License instead of this License. diff --git a/apps/codecs/libmad/COPYRIGHT b/apps/codecs/libmad/COPYRIGHT deleted file mode 100644 index ed91d2bac1..0000000000 --- a/apps/codecs/libmad/COPYRIGHT +++ /dev/null @@ -1,21 +0,0 @@ - - libmad - MPEG audio decoder library - Copyright (C) 2000-2004 Underbit Technologies, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - If you would like to negotiate alternate licensing terms, you may do - so by contacting: Underbit Technologies, Inc. - diff --git a/apps/codecs/libmad/CREDITS b/apps/codecs/libmad/CREDITS deleted file mode 100644 index 69016c201d..0000000000 --- a/apps/codecs/libmad/CREDITS +++ /dev/null @@ -1,116 +0,0 @@ - - libmad - MPEG audio decoder library - Copyright (C) 2000-2004 Underbit Technologies, Inc. - - $Id$ - -=============================================================================== - -AUTHOR - - Except where otherwise noted, all code was authored by: - - Robert Leslie - -CONTRIBUTORS - - Significant contributions have been incorporated with thanks to: - - Anonymous - 2002/03/15: frame.c - - Reported problem with use of reserved emphasis value. - 2003/08/31: layer12.c - - Suggested support for certain disallowed bitrate/mode - combinations. - - Niek Albers - 2003/04/21: layer3.c - - Reported runtime uninitialized use of `ptr' in designating - ancillary bits after a decoding error. - - Christian Biere - 2003/02/01: frame.c - - Reported assertion failure in layer3.c due to an - invalid/unsupported Layer III free format bitrate. - - David Blythe - 2001/01/30: fixed.h - - Provided initial PowerPC fixed-point assembly. - - Simon Burge - 2000/09/20: imdct_l_arm.S - - Suggested patch for a.out compatibility. - - Brian Cameron - 2003/07/02: huffman.c - - Suggested changes for improved portability. - - Joshua Haberman - 2001/08/10: decoder.c, huffman.c - - Suggested portability fixes. - - Timothy King - 2002/05/04: sf_table.dat, layer12.c - - Reported problem with use of (missing) scalefactor index 63. - - Felix von Leitner - 2003/01/21: fixed.h - - Suggested Intel scaling alternative for possible speedup. - - Andre McCurdy - 2000/08/10: imdct_l_arm.S - - ARM optimized assembly replacement for III_imdct_l(). - 2000/09/15: imdct_l_arm.S - - Applied Nicolas Pitre's rounding optimisation in all remaining - places. - 2001/02/10: layer3.c - - Inspiration for Huffman decoding and requantization rewrite, and - other miscellany. - 2001/03/24: imdct_l_arm.S - - Corrected PIC unsafe code. - 2002/02/16: fixed.h - - Discovered bug in ARM version of mad_f_scale64(). - - Haruhiko OGASAWARA - 2001/01/28: layer3.c - - Reported discrepancy in alias reduction for mixed short blocks. - - Brett Paterson - 2001/10/28: global.h - - Reported missing et al. under MS Embedded Visual C. - - Sean 'Shaleh' Perry - 2000/04/04: fixed.h - - Suggested use of size-dependent typedefs. - 2001/10/22: config.guess, config.sub - - Keep up to date for proper Debian packaging. - - Bertrand Petit - 2001/11/05: synth.h - - Suggested PCM channel enumeration constants. - 2001/11/05: stream.h - - Suggested MAD_ERROR_NONE enumeration constant. - 2001/11/05: stream.c - - Suggested mad_stream_errorstr() function. - - Nicolas Pitre - 2000/09/09: fixed.h - - Parameterized all scaling for correct use of all multiplication - methods within mad_synth_frame(). - - Rewrote the FPM_ARM version of mad_f_mul() so we have 64-bit - multiplication result, rounding and scaling with 3 instructions. - 2000/09/09: imdct_l_arm.S - - Optimized rounding + scaling operations. - 2000/09/17: synth.c - - Changed D[] run-time shifts to compile-time. - - Modified synthesis for better multiply/accumulate code output. - 2001/08/11: fixed.h, synth.c - - Suggested 64-bit FPM negation and negative term factorization - during synthesis. - 2001/08/11: fixed.h - - Suggested unrounded behavior for FPM_DEFAULT when OPT_SPEED. - 2001/11/19: fixed.c - - Suggested computation of any resampling ratio. - -=============================================================================== - diff --git a/apps/codecs/libmad/D.dat b/apps/codecs/libmad/D.dat deleted file mode 100644 index 2bff1a8890..0000000000 --- a/apps/codecs/libmad/D.dat +++ /dev/null @@ -1,607 +0,0 @@ -/* - * libmad - MPEG audio decoder library - * Copyright (C) 2000-2004 Underbit Technologies, Inc. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * $Id$ - */ - -/* - * These are the coefficients for the subband synthesis window. This is a - * reordered version of Table B.3 from ISO/IEC 11172-3. - * - * Every value is parameterized so that shift optimizations can be made at - * compile-time. For example, every value can be right-shifted 12 bits to - * minimize multiply instruction times without any loss of accuracy. - */ - - { PRESHIFT(0x00000000) /* 0.000000000 */, /* 0 */ - -PRESHIFT(0x0001d000) /* -0.000442505 */, - PRESHIFT(0x000d5000) /* 0.003250122 */, - -PRESHIFT(0x001cb000) /* -0.007003784 */, - PRESHIFT(0x007f5000) /* 0.031082153 */, - -PRESHIFT(0x01421000) /* -0.078628540 */, - PRESHIFT(0x019ae000) /* 0.100311279 */, - -PRESHIFT(0x09271000) /* -0.572036743 */, - PRESHIFT(0x1251e000) /* 1.144989014 */, - PRESHIFT(0x09271000) /* 0.572036743 */, - PRESHIFT(0x019ae000) /* 0.100311279 */, - PRESHIFT(0x01421000) /* 0.078628540 */, - PRESHIFT(0x007f5000) /* 0.031082153 */, - PRESHIFT(0x001cb000) /* 0.007003784 */, - PRESHIFT(0x000d5000) /* 0.003250122 */, - PRESHIFT(0x0001d000) /* 0.000442505 */, - - PRESHIFT(0x00000000) /* 0.000000000 */, - -PRESHIFT(0x0001d000) /* -0.000442505 */, - PRESHIFT(0x000d5000) /* 0.003250122 */, - -PRESHIFT(0x001cb000) /* -0.007003784 */, - PRESHIFT(0x007f5000) /* 0.031082153 */, - -PRESHIFT(0x01421000) /* -0.078628540 */, - PRESHIFT(0x019ae000) /* 0.100311279 */, - -PRESHIFT(0x09271000) /* -0.572036743 */, - PRESHIFT(0x1251e000) /* 1.144989014 */, - PRESHIFT(0x09271000) /* 0.572036743 */, - PRESHIFT(0x019ae000) /* 0.100311279 */, - PRESHIFT(0x01421000) /* 0.078628540 */, - PRESHIFT(0x007f5000) /* 0.031082153 */, - PRESHIFT(0x001cb000) /* 0.007003784 */, - PRESHIFT(0x000d5000) /* 0.003250122 */, - PRESHIFT(0x0001d000) /* 0.000442505 */ }, - - { -PRESHIFT(0x00001000) /* -0.000015259 */, /* 1 */ - -PRESHIFT(0x0001f000) /* -0.000473022 */, - PRESHIFT(0x000da000) /* 0.003326416 */, - -PRESHIFT(0x00207000) /* -0.007919312 */, - PRESHIFT(0x007d0000) /* 0.030517578 */, - -PRESHIFT(0x0158d000) /* -0.084182739 */, - PRESHIFT(0x01747000) /* 0.090927124 */, - -PRESHIFT(0x099a8000) /* -0.600219727 */, - PRESHIFT(0x124f0000) /* 1.144287109 */, - PRESHIFT(0x08b38000) /* 0.543823242 */, - PRESHIFT(0x01bde000) /* 0.108856201 */, - PRESHIFT(0x012b4000) /* 0.073059082 */, - PRESHIFT(0x0080f000) /* 0.031478882 */, - PRESHIFT(0x00191000) /* 0.006118774 */, - PRESHIFT(0x000d0000) /* 0.003173828 */, - PRESHIFT(0x0001a000) /* 0.000396729 */, - - -PRESHIFT(0x00001000) /* -0.000015259 */, - -PRESHIFT(0x0001f000) /* -0.000473022 */, - PRESHIFT(0x000da000) /* 0.003326416 */, - -PRESHIFT(0x00207000) /* -0.007919312 */, - PRESHIFT(0x007d0000) /* 0.030517578 */, - -PRESHIFT(0x0158d000) /* -0.084182739 */, - PRESHIFT(0x01747000) /* 0.090927124 */, - -PRESHIFT(0x099a8000) /* -0.600219727 */, - PRESHIFT(0x124f0000) /* 1.144287109 */, - PRESHIFT(0x08b38000) /* 0.543823242 */, - PRESHIFT(0x01bde000) /* 0.108856201 */, - PRESHIFT(0x012b4000) /* 0.073059082 */, - PRESHIFT(0x0080f000) /* 0.031478882 */, - PRESHIFT(0x00191000) /* 0.006118774 */, - PRESHIFT(0x000d0000) /* 0.003173828 */, - PRESHIFT(0x0001a000) /* 0.000396729 */ }, - - { -PRESHIFT(0x00001000) /* -0.000015259 */, /* 2 */ - -PRESHIFT(0x00023000) /* -0.000534058 */, - PRESHIFT(0x000de000) /* 0.003387451 */, - -PRESHIFT(0x00245000) /* -0.008865356 */, - PRESHIFT(0x007a0000) /* 0.029785156 */, - -PRESHIFT(0x016f7000) /* -0.089706421 */, - PRESHIFT(0x014a8000) /* 0.080688477 */, - -PRESHIFT(0x0a0d8000) /* -0.628295898 */, - PRESHIFT(0x12468000) /* 1.142211914 */, - PRESHIFT(0x083ff000) /* 0.515609741 */, - PRESHIFT(0x01dd8000) /* 0.116577148 */, - PRESHIFT(0x01149000) /* 0.067520142 */, - PRESHIFT(0x00820000) /* 0.031738281 */, - PRESHIFT(0x0015b000) /* 0.005294800 */, - PRESHIFT(0x000ca000) /* 0.003082275 */, - PRESHIFT(0x00018000) /* 0.000366211 */, - - -PRESHIFT(0x00001000) /* -0.000015259 */, - -PRESHIFT(0x00023000) /* -0.000534058 */, - PRESHIFT(0x000de000) /* 0.003387451 */, - -PRESHIFT(0x00245000) /* -0.008865356 */, - PRESHIFT(0x007a0000) /* 0.029785156 */, - -PRESHIFT(0x016f7000) /* -0.089706421 */, - PRESHIFT(0x014a8000) /* 0.080688477 */, - -PRESHIFT(0x0a0d8000) /* -0.628295898 */, - PRESHIFT(0x12468000) /* 1.142211914 */, - PRESHIFT(0x083ff000) /* 0.515609741 */, - PRESHIFT(0x01dd8000) /* 0.116577148 */, - PRESHIFT(0x01149000) /* 0.067520142 */, - PRESHIFT(0x00820000) /* 0.031738281 */, - PRESHIFT(0x0015b000) /* 0.005294800 */, - PRESHIFT(0x000ca000) /* 0.003082275 */, - PRESHIFT(0x00018000) /* 0.000366211 */ }, - - { -PRESHIFT(0x00001000) /* -0.000015259 */, /* 3 */ - -PRESHIFT(0x00026000) /* -0.000579834 */, - PRESHIFT(0x000e1000) /* 0.003433228 */, - -PRESHIFT(0x00285000) /* -0.009841919 */, - PRESHIFT(0x00765000) /* 0.028884888 */, - -PRESHIFT(0x0185d000) /* -0.095169067 */, - PRESHIFT(0x011d1000) /* 0.069595337 */, - -PRESHIFT(0x0a7fe000) /* -0.656219482 */, - PRESHIFT(0x12386000) /* 1.138763428 */, - PRESHIFT(0x07ccb000) /* 0.487472534 */, - PRESHIFT(0x01f9c000) /* 0.123474121 */, - PRESHIFT(0x00fdf000) /* 0.061996460 */, - PRESHIFT(0x00827000) /* 0.031845093 */, - PRESHIFT(0x00126000) /* 0.004486084 */, - PRESHIFT(0x000c4000) /* 0.002990723 */, - PRESHIFT(0x00015000) /* 0.000320435 */, - - -PRESHIFT(0x00001000) /* -0.000015259 */, - -PRESHIFT(0x00026000) /* -0.000579834 */, - PRESHIFT(0x000e1000) /* 0.003433228 */, - -PRESHIFT(0x00285000) /* -0.009841919 */, - PRESHIFT(0x00765000) /* 0.028884888 */, - -PRESHIFT(0x0185d000) /* -0.095169067 */, - PRESHIFT(0x011d1000) /* 0.069595337 */, - -PRESHIFT(0x0a7fe000) /* -0.656219482 */, - PRESHIFT(0x12386000) /* 1.138763428 */, - PRESHIFT(0x07ccb000) /* 0.487472534 */, - PRESHIFT(0x01f9c000) /* 0.123474121 */, - PRESHIFT(0x00fdf000) /* 0.061996460 */, - PRESHIFT(0x00827000) /* 0.031845093 */, - PRESHIFT(0x00126000) /* 0.004486084 */, - PRESHIFT(0x000c4000) /* 0.002990723 */, - PRESHIFT(0x00015000) /* 0.000320435 */ }, - - { -PRESHIFT(0x00001000) /* -0.000015259 */, /* 4 */ - -PRESHIFT(0x00029000) /* -0.000625610 */, - PRESHIFT(0x000e3000) /* 0.003463745 */, - -PRESHIFT(0x002c7000) /* -0.010848999 */, - PRESHIFT(0x0071e000) /* 0.027801514 */, - -PRESHIFT(0x019bd000) /* -0.100540161 */, - PRESHIFT(0x00ec0000) /* 0.057617187 */, - -PRESHIFT(0x0af15000) /* -0.683914185 */, - PRESHIFT(0x12249000) /* 1.133926392 */, - PRESHIFT(0x075a0000) /* 0.459472656 */, - PRESHIFT(0x0212c000) /* 0.129577637 */, - PRESHIFT(0x00e79000) /* 0.056533813 */, - PRESHIFT(0x00825000) /* 0.031814575 */, - PRESHIFT(0x000f4000) /* 0.003723145 */, - PRESHIFT(0x000be000) /* 0.002899170 */, - PRESHIFT(0x00013000) /* 0.000289917 */, - - -PRESHIFT(0x00001000) /* -0.000015259 */, - -PRESHIFT(0x00029000) /* -0.000625610 */, - PRESHIFT(0x000e3000) /* 0.003463745 */, - -PRESHIFT(0x002c7000) /* -0.010848999 */, - PRESHIFT(0x0071e000) /* 0.027801514 */, - -PRESHIFT(0x019bd000) /* -0.100540161 */, - PRESHIFT(0x00ec0000) /* 0.057617187 */, - -PRESHIFT(0x0af15000) /* -0.683914185 */, - PRESHIFT(0x12249000) /* 1.133926392 */, - PRESHIFT(0x075a0000) /* 0.459472656 */, - PRESHIFT(0x0212c000) /* 0.129577637 */, - PRESHIFT(0x00e79000) /* 0.056533813 */, - PRESHIFT(0x00825000) /* 0.031814575 */, - PRESHIFT(0x000f4000) /* 0.003723145 */, - PRESHIFT(0x000be000) /* 0.002899170 */, - PRESHIFT(0x00013000) /* 0.000289917 */ }, - - { -PRESHIFT(0x00001000) /* -0.000015259 */, /* 5 */ - -PRESHIFT(0x0002d000) /* -0.000686646 */, - PRESHIFT(0x000e4000) /* 0.003479004 */, - -PRESHIFT(0x0030b000) /* -0.011886597 */, - PRESHIFT(0x006cb000) /* 0.026535034 */, - -PRESHIFT(0x01b17000) /* -0.105819702 */, - PRESHIFT(0x00b77000) /* 0.044784546 */, - -PRESHIFT(0x0b619000) /* -0.711318970 */, - PRESHIFT(0x120b4000) /* 1.127746582 */, - PRESHIFT(0x06e81000) /* 0.431655884 */, - PRESHIFT(0x02288000) /* 0.134887695 */, - PRESHIFT(0x00d17000) /* 0.051132202 */, - PRESHIFT(0x0081b000) /* 0.031661987 */, - PRESHIFT(0x000c5000) /* 0.003005981 */, - PRESHIFT(0x000b7000) /* 0.002792358 */, - PRESHIFT(0x00011000) /* 0.000259399 */, - - -PRESHIFT(0x00001000) /* -0.000015259 */, - -PRESHIFT(0x0002d000) /* -0.000686646 */, - PRESHIFT(0x000e4000) /* 0.003479004 */, - -PRESHIFT(0x0030b000) /* -0.011886597 */, - PRESHIFT(0x006cb000) /* 0.026535034 */, - -PRESHIFT(0x01b17000) /* -0.105819702 */, - PRESHIFT(0x00b77000) /* 0.044784546 */, - -PRESHIFT(0x0b619000) /* -0.711318970 */, - PRESHIFT(0x120b4000) /* 1.127746582 */, - PRESHIFT(0x06e81000) /* 0.431655884 */, - PRESHIFT(0x02288000) /* 0.134887695 */, - PRESHIFT(0x00d17000) /* 0.051132202 */, - PRESHIFT(0x0081b000) /* 0.031661987 */, - PRESHIFT(0x000c5000) /* 0.003005981 */, - PRESHIFT(0x000b7000) /* 0.002792358 */, - PRESHIFT(0x00011000) /* 0.000259399 */ }, - - { -PRESHIFT(0x00001000) /* -0.000015259 */, /* 6 */ - -PRESHIFT(0x00031000) /* -0.000747681 */, - PRESHIFT(0x000e4000) /* 0.003479004 */, - -PRESHIFT(0x00350000) /* -0.012939453 */, - PRESHIFT(0x0066c000) /* 0.025085449 */, - -PRESHIFT(0x01c67000) /* -0.110946655 */, - PRESHIFT(0x007f5000) /* 0.031082153 */, - -PRESHIFT(0x0bd06000) /* -0.738372803 */, - PRESHIFT(0x11ec7000) /* 1.120223999 */, - PRESHIFT(0x06772000) /* 0.404083252 */, - PRESHIFT(0x023b3000) /* 0.139450073 */, - PRESHIFT(0x00bbc000) /* 0.045837402 */, - PRESHIFT(0x00809000) /* 0.031387329 */, - PRESHIFT(0x00099000) /* 0.002334595 */, - PRESHIFT(0x000b0000) /* 0.002685547 */, - PRESHIFT(0x00010000) /* 0.000244141 */, - - -PRESHIFT(0x00001000) /* -0.000015259 */, - -PRESHIFT(0x00031000) /* -0.000747681 */, - PRESHIFT(0x000e4000) /* 0.003479004 */, - -PRESHIFT(0x00350000) /* -0.012939453 */, - PRESHIFT(0x0066c000) /* 0.025085449 */, - -PRESHIFT(0x01c67000) /* -0.110946655 */, - PRESHIFT(0x007f5000) /* 0.031082153 */, - -PRESHIFT(0x0bd06000) /* -0.738372803 */, - PRESHIFT(0x11ec7000) /* 1.120223999 */, - PRESHIFT(0x06772000) /* 0.404083252 */, - PRESHIFT(0x023b3000) /* 0.139450073 */, - PRESHIFT(0x00bbc000) /* 0.045837402 */, - PRESHIFT(0x00809000) /* 0.031387329 */, - PRESHIFT(0x00099000) /* 0.002334595 */, - PRESHIFT(0x000b0000) /* 0.002685547 */, - PRESHIFT(0x00010000) /* 0.000244141 */ }, - - { -PRESHIFT(0x00002000) /* -0.000030518 */, /* 7 */ - -PRESHIFT(0x00035000) /* -0.000808716 */, - PRESHIFT(0x000e3000) /* 0.003463745 */, - -PRESHIFT(0x00397000) /* -0.014022827 */, - PRESHIFT(0x005ff000) /* 0.023422241 */, - -PRESHIFT(0x01dad000) /* -0.115921021 */, - PRESHIFT(0x0043a000) /* 0.016510010 */, - -PRESHIFT(0x0c3d9000) /* -0.765029907 */, - PRESHIFT(0x11c83000) /* 1.111373901 */, - PRESHIFT(0x06076000) /* 0.376800537 */, - PRESHIFT(0x024ad000) /* 0.143264771 */, - PRESHIFT(0x00a67000) /* 0.040634155 */, - PRESHIFT(0x007f0000) /* 0.031005859 */, - PRESHIFT(0x0006f000) /* 0.001693726 */, - PRESHIFT(0x000a9000) /* 0.002578735 */, - PRESHIFT(0x0000e000) /* 0.000213623 */, - - -PRESHIFT(0x00002000) /* -0.000030518 */, - -PRESHIFT(0x00035000) /* -0.000808716 */, - PRESHIFT(0x000e3000) /* 0.003463745 */, - -PRESHIFT(0x00397000) /* -0.014022827 */, - PRESHIFT(0x005ff000) /* 0.023422241 */, - -PRESHIFT(0x01dad000) /* -0.115921021 */, - PRESHIFT(0x0043a000) /* 0.016510010 */, - -PRESHIFT(0x0c3d9000) /* -0.765029907 */, - PRESHIFT(0x11c83000) /* 1.111373901 */, - PRESHIFT(0x06076000) /* 0.376800537 */, - PRESHIFT(0x024ad000) /* 0.143264771 */, - PRESHIFT(0x00a67000) /* 0.040634155 */, - PRESHIFT(0x007f0000) /* 0.031005859 */, - PRESHIFT(0x0006f000) /* 0.001693726 */, - PRESHIFT(0x000a9000) /* 0.002578735 */, - PRESHIFT(0x0000e000) /* 0.000213623 */ }, - - { -PRESHIFT(0x00002000) /* -0.000030518 */, /* 8 */ - -PRESHIFT(0x0003a000) /* -0.000885010 */, - PRESHIFT(0x000e0000) /* 0.003417969 */, - -PRESHIFT(0x003df000) /* -0.015121460 */, - PRESHIFT(0x00586000) /* 0.021575928 */, - -PRESHIFT(0x01ee6000) /* -0.120697021 */, - PRESHIFT(0x00046000) /* 0.001068115 */, - -PRESHIFT(0x0ca8d000) /* -0.791213989 */, - PRESHIFT(0x119e9000) /* 1.101211548 */, - PRESHIFT(0x05991000) /* 0.349868774 */, - PRESHIFT(0x02578000) /* 0.146362305 */, - PRESHIFT(0x0091a000) /* 0.035552979 */, - PRESHIFT(0x007d1000) /* 0.030532837 */, - PRESHIFT(0x00048000) /* 0.001098633 */, - PRESHIFT(0x000a1000) /* 0.002456665 */, - PRESHIFT(0x0000d000) /* 0.000198364 */, - - -PRESHIFT(0x00002000) /* -0.000030518 */, - -PRESHIFT(0x0003a000) /* -0.000885010 */, - PRESHIFT(0x000e0000) /* 0.003417969 */, - -PRESHIFT(0x003df000) /* -0.015121460 */, - PRESHIFT(0x00586000) /* 0.021575928 */, - -PRESHIFT(0x01ee6000) /* -0.120697021 */, - PRESHIFT(0x00046000) /* 0.001068115 */, - -PRESHIFT(0x0ca8d000) /* -0.791213989 */, - PRESHIFT(0x119e9000) /* 1.101211548 */, - PRESHIFT(0x05991000) /* 0.349868774 */, - PRESHIFT(0x02578000) /* 0.146362305 */, - PRESHIFT(0x0091a000) /* 0.035552979 */, - PRESHIFT(0x007d1000) /* 0.030532837 */, - PRESHIFT(0x00048000) /* 0.001098633 */, - PRESHIFT(0x000a1000) /* 0.002456665 */, - PRESHIFT(0x0000d000) /* 0.000198364 */ }, - - { -PRESHIFT(0x00002000) /* -0.000030518 */, /* 9 */ - -PRESHIFT(0x0003f000) /* -0.000961304 */, - PRESHIFT(0x000dd000) /* 0.003372192 */, - -PRESHIFT(0x00428000) /* -0.016235352 */, - PRESHIFT(0x00500000) /* 0.019531250 */, - -PRESHIFT(0x02011000) /* -0.125259399 */, - -PRESHIFT(0x003e6000) /* -0.015228271 */, - -PRESHIFT(0x0d11e000) /* -0.816864014 */, - PRESHIFT(0x116fc000) /* 1.089782715 */, - PRESHIFT(0x052c5000) /* 0.323318481 */, - PRESHIFT(0x02616000) /* 0.148773193 */, - PRESHIFT(0x007d6000) /* 0.030609131 */, - PRESHIFT(0x007aa000) /* 0.029937744 */, - PRESHIFT(0x00024000) /* 0.000549316 */, - PRESHIFT(0x0009a000) /* 0.002349854 */, - PRESHIFT(0x0000b000) /* 0.000167847 */, - - -PRESHIFT(0x00002000) /* -0.000030518 */, - -PRESHIFT(0x0003f000) /* -0.000961304 */, - PRESHIFT(0x000dd000) /* 0.003372192 */, - -PRESHIFT(0x00428000) /* -0.016235352 */, - PRESHIFT(0x00500000) /* 0.019531250 */, - -PRESHIFT(0x02011000) /* -0.125259399 */, - -PRESHIFT(0x003e6000) /* -0.015228271 */, - -PRESHIFT(0x0d11e000) /* -0.816864014 */, - PRESHIFT(0x116fc000) /* 1.089782715 */, - PRESHIFT(0x052c5000) /* 0.323318481 */, - PRESHIFT(0x02616000) /* 0.148773193 */, - PRESHIFT(0x007d6000) /* 0.030609131 */, - PRESHIFT(0x007aa000) /* 0.029937744 */, - PRESHIFT(0x00024000) /* 0.000549316 */, - PRESHIFT(0x0009a000) /* 0.002349854 */, - PRESHIFT(0x0000b000) /* 0.000167847 */ }, - - { -PRESHIFT(0x00002000) /* -0.000030518 */, /* 10 */ - -PRESHIFT(0x00044000) /* -0.001037598 */, - PRESHIFT(0x000d7000) /* 0.003280640 */, - -PRESHIFT(0x00471000) /* -0.017349243 */, - PRESHIFT(0x0046b000) /* 0.017257690 */, - -PRESHIFT(0x0212b000) /* -0.129562378 */, - -PRESHIFT(0x0084a000) /* -0.032379150 */, - -PRESHIFT(0x0d78a000) /* -0.841949463 */, - PRESHIFT(0x113be000) /* 1.077117920 */, - PRESHIFT(0x04c16000) /* 0.297210693 */, - PRESHIFT(0x02687000) /* 0.150497437 */, - PRESHIFT(0x0069c000) /* 0.025817871 */, - PRESHIFT(0x0077f000) /* 0.029281616 */, - PRESHIFT(0x00002000) /* 0.000030518 */, - PRESHIFT(0x00093000) /* 0.002243042 */, - PRESHIFT(0x0000a000) /* 0.000152588 */, - - -PRESHIFT(0x00002000) /* -0.000030518 */, - -PRESHIFT(0x00044000) /* -0.001037598 */, - PRESHIFT(0x000d7000) /* 0.003280640 */, - -PRESHIFT(0x00471000) /* -0.017349243 */, - PRESHIFT(0x0046b000) /* 0.017257690 */, - -PRESHIFT(0x0212b000) /* -0.129562378 */, - -PRESHIFT(0x0084a000) /* -0.032379150 */, - -PRESHIFT(0x0d78a000) /* -0.841949463 */, - PRESHIFT(0x113be000) /* 1.077117920 */, - PRESHIFT(0x04c16000) /* 0.297210693 */, - PRESHIFT(0x02687000) /* 0.150497437 */, - PRESHIFT(0x0069c000) /* 0.025817871 */, - PRESHIFT(0x0077f000) /* 0.029281616 */, - PRESHIFT(0x00002000) /* 0.000030518 */, - PRESHIFT(0x00093000) /* 0.002243042 */, - PRESHIFT(0x0000a000) /* 0.000152588 */ }, - - { -PRESHIFT(0x00003000) /* -0.000045776 */, /* 11 */ - -PRESHIFT(0x00049000) /* -0.001113892 */, - PRESHIFT(0x000d0000) /* 0.003173828 */, - -PRESHIFT(0x004ba000) /* -0.018463135 */, - PRESHIFT(0x003ca000) /* 0.014801025 */, - -PRESHIFT(0x02233000) /* -0.133590698 */, - -PRESHIFT(0x00ce4000) /* -0.050354004 */, - -PRESHIFT(0x0ddca000) /* -0.866363525 */, - PRESHIFT(0x1102f000) /* 1.063217163 */, - PRESHIFT(0x04587000) /* 0.271591187 */, - PRESHIFT(0x026cf000) /* 0.151596069 */, - PRESHIFT(0x0056c000) /* 0.021179199 */, - PRESHIFT(0x0074e000) /* 0.028533936 */, - -PRESHIFT(0x0001d000) /* -0.000442505 */, - PRESHIFT(0x0008b000) /* 0.002120972 */, - PRESHIFT(0x00009000) /* 0.000137329 */, - - -PRESHIFT(0x00003000) /* -0.000045776 */, - -PRESHIFT(0x00049000) /* -0.001113892 */, - PRESHIFT(0x000d0000) /* 0.003173828 */, - -PRESHIFT(0x004ba000) /* -0.018463135 */, - PRESHIFT(0x003ca000) /* 0.014801025 */, - -PRESHIFT(0x02233000) /* -0.133590698 */, - -PRESHIFT(0x00ce4000) /* -0.050354004 */, - -PRESHIFT(0x0ddca000) /* -0.866363525 */, - PRESHIFT(0x1102f000) /* 1.063217163 */, - PRESHIFT(0x04587000) /* 0.271591187 */, - PRESHIFT(0x026cf000) /* 0.151596069 */, - PRESHIFT(0x0056c000) /* 0.021179199 */, - PRESHIFT(0x0074e000) /* 0.028533936 */, - -PRESHIFT(0x0001d000) /* -0.000442505 */, - PRESHIFT(0x0008b000) /* 0.002120972 */, - PRESHIFT(0x00009000) /* 0.000137329 */ }, - - { -PRESHIFT(0x00003000) /* -0.000045776 */, /* 12 */ - -PRESHIFT(0x0004f000) /* -0.001205444 */, - PRESHIFT(0x000c8000) /* 0.003051758 */, - -PRESHIFT(0x00503000) /* -0.019577026 */, - PRESHIFT(0x0031a000) /* 0.012115479 */, - -PRESHIFT(0x02326000) /* -0.137298584 */, - -PRESHIFT(0x011b5000) /* -0.069168091 */, - -PRESHIFT(0x0e3dd000) /* -0.890090942 */, - PRESHIFT(0x10c54000) /* 1.048156738 */, - PRESHIFT(0x03f1b000) /* 0.246505737 */, - PRESHIFT(0x026ee000) /* 0.152069092 */, - PRESHIFT(0x00447000) /* 0.016708374 */, - PRESHIFT(0x00719000) /* 0.027725220 */, - -PRESHIFT(0x00039000) /* -0.000869751 */, - PRESHIFT(0x00084000) /* 0.002014160 */, - PRESHIFT(0x00008000) /* 0.000122070 */, - - -PRESHIFT(0x00003000) /* -0.000045776 */, - -PRESHIFT(0x0004f000) /* -0.001205444 */, - PRESHIFT(0x000c8000) /* 0.003051758 */, - -PRESHIFT(0x00503000) /* -0.019577026 */, - PRESHIFT(0x0031a000) /* 0.012115479 */, - -PRESHIFT(0x02326000) /* -0.137298584 */, - -PRESHIFT(0x011b5000) /* -0.069168091 */, - -PRESHIFT(0x0e3dd000) /* -0.890090942 */, - PRESHIFT(0x10c54000) /* 1.048156738 */, - PRESHIFT(0x03f1b000) /* 0.246505737 */, - PRESHIFT(0x026ee000) /* 0.152069092 */, - PRESHIFT(0x00447000) /* 0.016708374 */, - PRESHIFT(0x00719000) /* 0.027725220 */, - -PRESHIFT(0x00039000) /* -0.000869751 */, - PRESHIFT(0x00084000) /* 0.002014160 */, - PRESHIFT(0x00008000) /* 0.000122070 */ }, - - { -PRESHIFT(0x00004000) /* -0.000061035 */, /* 13 */ - -PRESHIFT(0x00055000) /* -0.001296997 */, - PRESHIFT(0x000bd000) /* 0.002883911 */, - -PRESHIFT(0x0054c000) /* -0.020690918 */, - PRESHIFT(0x0025d000) /* 0.009231567 */, - -PRESHIFT(0x02403000) /* -0.140670776 */, - -PRESHIFT(0x016ba000) /* -0.088775635 */, - -PRESHIFT(0x0e9be000) /* -0.913055420 */, - PRESHIFT(0x1082d000) /* 1.031936646 */, - PRESHIFT(0x038d4000) /* 0.221984863 */, - PRESHIFT(0x026e7000) /* 0.151962280 */, - PRESHIFT(0x0032e000) /* 0.012420654 */, - PRESHIFT(0x006df000) /* 0.026840210 */, - -PRESHIFT(0x00053000) /* -0.001266479 */, - PRESHIFT(0x0007d000) /* 0.001907349 */, - PRESHIFT(0x00007000) /* 0.000106812 */, - - -PRESHIFT(0x00004000) /* -0.000061035 */, - -PRESHIFT(0x00055000) /* -0.001296997 */, - PRESHIFT(0x000bd000) /* 0.002883911 */, - -PRESHIFT(0x0054c000) /* -0.020690918 */, - PRESHIFT(0x0025d000) /* 0.009231567 */, - -PRESHIFT(0x02403000) /* -0.140670776 */, - -PRESHIFT(0x016ba000) /* -0.088775635 */, - -PRESHIFT(0x0e9be000) /* -0.913055420 */, - PRESHIFT(0x1082d000) /* 1.031936646 */, - PRESHIFT(0x038d4000) /* 0.221984863 */, - PRESHIFT(0x026e7000) /* 0.151962280 */, - PRESHIFT(0x0032e000) /* 0.012420654 */, - PRESHIFT(0x006df000) /* 0.026840210 */, - -PRESHIFT(0x00053000) /* -0.001266479 */, - PRESHIFT(0x0007d000) /* 0.001907349 */, - PRESHIFT(0x00007000) /* 0.000106812 */ }, - - { -PRESHIFT(0x00004000) /* -0.000061035 */, /* 14 */ - -PRESHIFT(0x0005b000) /* -0.001388550 */, - PRESHIFT(0x000b1000) /* 0.002700806 */, - -PRESHIFT(0x00594000) /* -0.021789551 */, - PRESHIFT(0x00192000) /* 0.006134033 */, - -PRESHIFT(0x024c8000) /* -0.143676758 */, - -PRESHIFT(0x01bf2000) /* -0.109161377 */, - -PRESHIFT(0x0ef69000) /* -0.935195923 */, - PRESHIFT(0x103be000) /* 1.014617920 */, - PRESHIFT(0x032b4000) /* 0.198059082 */, - PRESHIFT(0x026bc000) /* 0.151306152 */, - PRESHIFT(0x00221000) /* 0.008316040 */, - PRESHIFT(0x006a2000) /* 0.025909424 */, - -PRESHIFT(0x0006a000) /* -0.001617432 */, - PRESHIFT(0x00075000) /* 0.001785278 */, - PRESHIFT(0x00007000) /* 0.000106812 */, - - -PRESHIFT(0x00004000) /* -0.000061035 */, - -PRESHIFT(0x0005b000) /* -0.001388550 */, - PRESHIFT(0x000b1000) /* 0.002700806 */, - -PRESHIFT(0x00594000) /* -0.021789551 */, - PRESHIFT(0x00192000) /* 0.006134033 */, - -PRESHIFT(0x024c8000) /* -0.143676758 */, - -PRESHIFT(0x01bf2000) /* -0.109161377 */, - -PRESHIFT(0x0ef69000) /* -0.935195923 */, - PRESHIFT(0x103be000) /* 1.014617920 */, - PRESHIFT(0x032b4000) /* 0.198059082 */, - PRESHIFT(0x026bc000) /* 0.151306152 */, - PRESHIFT(0x00221000) /* 0.008316040 */, - PRESHIFT(0x006a2000) /* 0.025909424 */, - -PRESHIFT(0x0006a000) /* -0.001617432 */, - PRESHIFT(0x00075000) /* 0.001785278 */, - PRESHIFT(0x00007000) /* 0.000106812 */ }, - - { -PRESHIFT(0x00005000) /* -0.000076294 */, /* 15 */ - -PRESHIFT(0x00061000) /* -0.001480103 */, - PRESHIFT(0x000a3000) /* 0.002487183 */, - -PRESHIFT(0x005da000) /* -0.022857666 */, - PRESHIFT(0x000b9000) /* 0.002822876 */, - -PRESHIFT(0x02571000) /* -0.146255493 */, - -PRESHIFT(0x0215c000) /* -0.130310059 */, - -PRESHIFT(0x0f4dc000) /* -0.956481934 */, - PRESHIFT(0x0ff0a000) /* 0.996246338 */, - PRESHIFT(0x02cbf000) /* 0.174789429 */, - PRESHIFT(0x0266e000) /* 0.150115967 */, - PRESHIFT(0x00120000) /* 0.004394531 */, - PRESHIFT(0x00662000) /* 0.024932861 */, - -PRESHIFT(0x0007f000) /* -0.001937866 */, - PRESHIFT(0x0006f000) /* 0.001693726 */, - PRESHIFT(0x00006000) /* 0.000091553 */, - - -PRESHIFT(0x00005000) /* -0.000076294 */, - -PRESHIFT(0x00061000) /* -0.001480103 */, - PRESHIFT(0x000a3000) /* 0.002487183 */, - -PRESHIFT(0x005da000) /* -0.022857666 */, - PRESHIFT(0x000b9000) /* 0.002822876 */, - -PRESHIFT(0x02571000) /* -0.146255493 */, - -PRESHIFT(0x0215c000) /* -0.130310059 */, - -PRESHIFT(0x0f4dc000) /* -0.956481934 */, - PRESHIFT(0x0ff0a000) /* 0.996246338 */, - PRESHIFT(0x02cbf000) /* 0.174789429 */, - PRESHIFT(0x0266e000) /* 0.150115967 */, - PRESHIFT(0x00120000) /* 0.004394531 */, - PRESHIFT(0x00662000) /* 0.024932861 */, - -PRESHIFT(0x0007f000) /* -0.001937866 */, - PRESHIFT(0x0006f000) /* 0.001693726 */, - PRESHIFT(0x00006000) /* 0.000091553 */ }, - - { -PRESHIFT(0x00005000) /* -0.000076294 */, /* 16 */ - -PRESHIFT(0x00068000) /* -0.001586914 */, - PRESHIFT(0x00092000) /* 0.002227783 */, - -PRESHIFT(0x0061f000) /* -0.023910522 */, - -PRESHIFT(0x0002d000) /* -0.000686646 */, - -PRESHIFT(0x025ff000) /* -0.148422241 */, - -PRESHIFT(0x026f7000) /* -0.152206421 */, - -PRESHIFT(0x0fa13000) /* -0.976852417 */, - PRESHIFT(0x0fa13000) /* 0.976852417 */, - PRESHIFT(0x026f7000) /* 0.152206421 */, - PRESHIFT(0x025ff000) /* 0.148422241 */, - PRESHIFT(0x0002d000) /* 0.000686646 */, - PRESHIFT(0x0061f000) /* 0.023910522 */, - -PRESHIFT(0x00092000) /* -0.002227783 */, - PRESHIFT(0x00068000) /* 0.001586914 */, - PRESHIFT(0x00005000) /* 0.000076294 */, - - -PRESHIFT(0x00005000) /* -0.000076294 */, - -PRESHIFT(0x00068000) /* -0.001586914 */, - PRESHIFT(0x00092000) /* 0.002227783 */, - -PRESHIFT(0x0061f000) /* -0.023910522 */, - -PRESHIFT(0x0002d000) /* -0.000686646 */, - -PRESHIFT(0x025ff000) /* -0.148422241 */, - -PRESHIFT(0x026f7000) /* -0.152206421 */, - -PRESHIFT(0x0fa13000) /* -0.976852417 */, - PRESHIFT(0x0fa13000) /* 0.976852417 */, - PRESHIFT(0x026f7000) /* 0.152206421 */, - PRESHIFT(0x025ff000) /* 0.148422241 */, - PRESHIFT(0x0002d000) /* 0.000686646 */, - PRESHIFT(0x0061f000) /* 0.023910522 */, - -PRESHIFT(0x00092000) /* -0.002227783 */, - PRESHIFT(0x00068000) /* 0.001586914 */, - PRESHIFT(0x00005000) /* 0.000076294 */ } diff --git a/apps/codecs/libmad/README b/apps/codecs/libmad/README deleted file mode 100644 index 524a94b29d..0000000000 --- a/apps/codecs/libmad/README +++ /dev/null @@ -1,241 +0,0 @@ - - libmad - MPEG audio decoder library - Copyright (C) 2000-2004 Underbit Technologies, Inc. - - $Id$ - -=============================================================================== - -INTRODUCTION - - MAD (libmad) is a high-quality MPEG audio decoder. It currently supports - MPEG-1 and the MPEG-2 extension to Lower Sampling Frequencies, as well as - the so-called MPEG 2.5 format. All three audio layers (Layer I, Layer II, - and Layer III a.k.a. MP3) are fully implemented. - - MAD does not yet support MPEG-2 multichannel audio (although it should be - backward compatible with such streams) nor does it currently support AAC. - - MAD has the following special features: - - - 24-bit PCM output - - 100% fixed-point (integer) computation - - completely new implementation based on the ISO/IEC standards - - distributed under the terms of the GNU General Public License (GPL) - - Because MAD provides full 24-bit PCM output, applications using MAD are - able to produce high quality audio. Even when the output device supports - only 16-bit PCM, applications can use the extra resolution to increase the - audible dynamic range through the use of dithering or noise shaping. - - Because MAD uses integer computation rather than floating point, it is - well suited for architectures without a floating point unit. All - calculations are performed with a 32-bit fixed-point integer - representation. - - Because MAD is a new implementation of the ISO/IEC standards, it is - unencumbered by the errors of other implementations. MAD is NOT a - derivation of the ISO reference source or any other code. Considerable - effort has been expended to ensure a correct implementation, even in cases - where the standards are ambiguous or misleading. - - Because MAD is distributed under the terms of the GPL, its redistribution - is not generally restricted, so long as the terms of the GPL are followed. - This means MAD can be incorporated into other software as long as that - software is also distributed under the GPL. (Should this be undesirable, - alternate arrangements may be possible by contacting Underbit.) - -=============================================================================== - -ABOUT THE CODE - - The code is optimized and performs very well, although specific - improvements can still be made. The output from the decoder library - consists of 32-bit signed linear fixed-point values that can be easily - scaled for any size PCM output, up to 24 bits per sample. - - The API for libmad can be found in the `mad.h' header file. Note that this - file is automatically generated, and will not exist until after you have - built the library. - - There are two APIs available, one high-level, and the other low-level. - With the low-level API, each step of the decoding process must be handled - explicitly, offering the greatest amount of control. With the high-level - API, after callbacks are configured, a single routine will decode an - entire bitstream. - - The high-level API may either be used synchronously or asynchronously. If - used asynchronously, decoding will occur in a separate process. - Communication is possible with the decoding process by passing control - messages. - - The file `minimad.c' contains an example usage of the libmad API that - shows only the bare minimum required to implement a useful decoder. It - expects a regular file to be redirected to standard input, and it sends - decoded 16-bit signed little-endian PCM samples to standard output. If a - decoding error occurs, it is reported to standard error and decoding - continues. Note that the scale() routine in this code is only provided as - an example; it rounds MAD's high-resolution samples down to 16 bits, but - does not perform any dithering or noise shaping. It is therefore not - recommended to use this routine as-is in your own code if sound quality is - important. - -Integer Performance - - To get the best possible performance, it is recommended that an assembly - version of the fixed-point multiply and related routines be selected. - Several such assembly routines have been written for various CPUs. - - If an assembly version is not available, a fast approximation version will - be used. This will result in reduced accuracy of the decoder. - - Alternatively, if 64-bit integers are supported as a datatype by the - compiler, another version can be used that is much more accurate. - However, using an assembly version is generally much faster and just as - accurate. - - More information can be gathered from the `fixed.h' header file. - - MAD's CPU-intensive subband synthesis routine can be further optimized at - the expense of a slight loss in output accuracy due to a modified method - for fixed-point multiplication with a small windowing constant. While this - is helpful for performance and the output accuracy loss is generally - undetectable, it is disabled by default and must be explicitly enabled. - - Under some architectures, other special optimizations may also be - available. - -Audio Quality - - The output from MAD has been found to satisfy the ISO/IEC 11172-4 - computational accuracy requirements for compliance. In most - configurations, MAD is a Full Layer III ISO/IEC 11172-3 audio decoder as - defined by the standard. - - When the approximation version of the fixed-point multiply is used, MAD is - a limited accuracy ISO/IEC 11172-3 audio decoder as defined by the - standard. - - MAD can alternatively be configured to produce output with less or more - accuracy than the default, as a tradeoff with performance. - - MAD produces output samples with a precision greater than 24 bits. Because - most output formats use fewer bits, typically 16, it is recommended that a - dithering algorithm be used (rather than rounding or truncating) to obtain - the highest quality audio. However, dithering may unfavorably affect an - analytic examination of the output (such as compliance testing); you may - therefore wish to use rounding in this case instead. - -Portability Issues - - GCC is preferred to compile the code, but other compilers may also work. - The assembly code in `fixed.h' depends on the inline assembly features of - your compiler. If you're not using GCC or MSVC++, you can either write - your own assembly macros or use the default (low quality output) version. - - The union initialization of `huffman.c' may not be portable to all - platforms when GCC is not used. - - The code should not be sensitive to word sizes or byte ordering, however - it does assume A % B has the same sign as A. - -=============================================================================== - -BUILDING AND INSTALLING - -Windows Platforms - - MAD can be built under Windows using either MSVC++ or Cygwin. A MSVC++ - project file can be found under the `msvc++' subdirectory. - - To build libmad using Cygwin, you will first need to install the Cygwin - tools: - - http://www.cygwin.com/ - - You may then proceed with the following POSIX instructions within the - Cygwin shell. - - Note that by default Cygwin will build a library that depends on the - Cygwin DLL. You can use MinGW to build a library that does not depend on - the Cygwin DLL. To do so, give the option --host=mingw32 to `configure'. - -POSIX Platforms (including Cygwin) - - The code is distributed with a `configure' script that will generate for - you a `Makefile' and a `config.h' for your platform. See the file - `INSTALL' for generic instructions. - - The specific options you may want to give `configure' are: - - --enable-speed optimize for speed over accuracy - - --enable-accuracy optimize for accuracy over speed - - --disable-debugging do not compile with debugging support, and - use more optimizations - - --disable-shared do not build a shared library - - Note that you need not specify one of --enable-speed or --enable-accuracy; - in its default configuration, MAD is optimized for both. You should only - use one of these options if you wish to compromise speed or accuracy for - the other. - - By default the package will build a shared library if possible for your - platform. If you want only a static library, use --disable-shared. - - It is not normally necessary to use the following options, but you may - fine-tune the configuration with them if desired: - - --enable-fpm=ARCH use the ARCH-specific version of the - fixed-point math assembly routines - (current options are: intel, arm, mips, - sparc, ppc; also allowed are: 64bit, approx) - - --enable-sso use the subband synthesis optimization, - with reduced accuracy - - --disable-aso do not use certain architecture-specific - optimizations - - By default an appropriate fixed-point assembly routine will be selected - for the configured host type, if it can be determined. Thus if you are - cross-compiling for another architecture, you should be sure either to - give `configure' a host type argument (--host) or to use an explicit - --enable-fpm option. - - If an appropriate assembly routine cannot be determined, the default - approximation version will be used. In this case, use of an alternate - --enable-fpm is highly recommended. - -Experimenting and Developing - - Further options for `configure' that may be useful to developers and - experimenters are: - - --enable-debugging enable diagnostic debugging support and - debugging symbols - - --enable-profiling generate `gprof' profiling code - - --enable-experimental enable code using the EXPERIMENTAL - preprocessor define - -=============================================================================== - -COPYRIGHT - - Please read the `COPYRIGHT' file for copyright and warranty information. - Also, the file `COPYING' contains the full text of the GNU GPL. - - Send inquiries, comments, bug reports, suggestions, patches, etc. to: - - Underbit Technologies, Inc. - - See also the MAD home page on the Web: - - http://www.underbit.com/products/mad/ - -=============================================================================== - diff --git a/apps/codecs/libmad/README.rockbox b/apps/codecs/libmad/README.rockbox deleted file mode 100644 index faddc0d391..0000000000 --- a/apps/codecs/libmad/README.rockbox +++ /dev/null @@ -1,23 +0,0 @@ -Library: libmad-0.15.1b (2004-02-17) -Imported: 2005-02-15 by Dave Chapman - - -This directory contains a local version of libmad for use by Rockbox -targets needing software MPEG audio decoding. - - -LICENSING INFORMATION - -libmad is (C) 2000-2004 Unibit Technologies, Inc. and licensed under -the terms of the GNU General Public License. See file "COPYRIGHT" in -this directory for more information. - - -IMPORT DETAILS - -The base version first imported into Rockbox was libmad-0.15.1b -(released on 2004-02-17), downloaded on 2005-02-15 from the files -section at http://sourceforge.net/projects/mad/ - -The autoconf/automake files were removed from the official source -tarball, as well as the "msvc++" subdirectory. diff --git a/apps/codecs/libmad/SOURCES b/apps/codecs/libmad/SOURCES deleted file mode 100644 index d81804ca38..0000000000 --- a/apps/codecs/libmad/SOURCES +++ /dev/null @@ -1,14 +0,0 @@ -bit.c -frame.c -huffman.c -layer12.c -layer3.c -stream.c -synth.c -#if defined(CPU_COLDFIRE) -imdct_mcf5249.S -#endif -#if defined(CPU_ARM) -imdct_l_arm.S -synth_full_arm.S -#endif diff --git a/apps/codecs/libmad/TODO b/apps/codecs/libmad/TODO deleted file mode 100644 index a397655c6c..0000000000 --- a/apps/codecs/libmad/TODO +++ /dev/null @@ -1,69 +0,0 @@ - - libmad - MPEG audio decoder library - Copyright (C) 2000-2004 Underbit Technologies, Inc. - - $Id$ - -=============================================================================== - -libmad: - - more API layers (buffering, PCM samples, dithering, etc.) - - x86 performance optimization compiler flags - - function documentation, general docs - - finish async API - - parse system streams? - - MPEG-2 MC, AAC? - - logarithmic multiplication? - - multiple frame decoding for better locality of reference? - - frame serial numbers, Layer III frame continuity checks - -fixed.h: - - experiment with FPM_INTEL: - -# if 1 -# define mad_f_scale64(hi, lo) \ - ({ mad_fixed_t __result; \ - asm ("shrl %3,%1\n\t" \ - "shll %4,%2\n\t" \ - "orl %2,%1" \ - : "=rm" (__result) \ - : "0" (lo), "r" (hi), \ - "I" (MAD_F_SCALEBITS), "I" (32 - MAD_F_SCALEBITS) \ - : "cc"); \ - __result; \ - }) -# else -# define mad_f_scale64(hi, lo) \ - ({ mad_fixed64hi_t __hi_; \ - mad_fixed64lo_t __lo_; \ - mad_fixed_t __result; \ - asm ("sall %2,%1" \ - : "=r" (__hi_) \ - : "0" (hi), "I" (32 - MAD_F_SCALEBITS) \ - : "cc"); \ - asm ("shrl %2,%1" \ - : "=r" (__lo_) \ - : "0" (lo), "I" (MAD_F_SCALEBITS) \ - : "cc"); \ - asm ("orl %1,%2" \ - : "=rm" (__result) \ - : "r" (__hi_), "0" (__lo_) \ - : "cc"); \ - __result; \ - }) -# endif - -libmad Layer I: - - check frame length sanity - -libmad Layer II: - - check frame length sanity - -libmad Layer III: - - circular buffer - - optimize zero_part from Huffman decoding throughout - - MPEG 2.5 8000 Hz sf bands? mixed blocks? - - stereo->mono conversion optimization? - - enable frame-at-a-time decoding - - improve portability of huffman.c - diff --git a/apps/codecs/libmad/VERSION b/apps/codecs/libmad/VERSION deleted file mode 100644 index d4e8f64aa2..0000000000 --- a/apps/codecs/libmad/VERSION +++ /dev/null @@ -1,7 +0,0 @@ -0.15.1b -configure.ac:24 -version.h:25-28 -msvc++/config.h:99,105,120 -msvc++/mad.h:41-44 - -Makefile.am:98-100 diff --git a/apps/codecs/libmad/bit.c b/apps/codecs/libmad/bit.c deleted file mode 100644 index c08806d385..0000000000 --- a/apps/codecs/libmad/bit.c +++ /dev/null @@ -1,218 +0,0 @@ -/* - * libmad - MPEG audio decoder library - * Copyright (C) 2000-2004 Underbit Technologies, Inc. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * $Id$ - */ - -# ifdef HAVE_CONFIG_H -# include "config.h" -# endif - -# include "global.h" - -# ifdef HAVE_LIMITS_H -# include -# else -# undef CHAR_BIT -# define CHAR_BIT 8 -# endif - -# include "bit.h" - -/* - * This is the lookup table for computing the CRC-check word. - * As described in section 2.4.3.1 and depicted in Figure A.9 - * of ISO/IEC 11172-3, the generator polynomial is: - * - * G(X) = X^16 + X^15 + X^2 + 1 - */ -static -unsigned short const crc_table[256] = { - 0x0000, 0x8005, 0x800f, 0x000a, 0x801b, 0x001e, 0x0014, 0x8011, - 0x8033, 0x0036, 0x003c, 0x8039, 0x0028, 0x802d, 0x8027, 0x0022, - 0x8063, 0x0066, 0x006c, 0x8069, 0x0078, 0x807d, 0x8077, 0x0072, - 0x0050, 0x8055, 0x805f, 0x005a, 0x804b, 0x004e, 0x0044, 0x8041, - 0x80c3, 0x00c6, 0x00cc, 0x80c9, 0x00d8, 0x80dd, 0x80d7, 0x00d2, - 0x00f0, 0x80f5, 0x80ff, 0x00fa, 0x80eb, 0x00ee, 0x00e4, 0x80e1, - 0x00a0, 0x80a5, 0x80af, 0x00aa, 0x80bb, 0x00be, 0x00b4, 0x80b1, - 0x8093, 0x0096, 0x009c, 0x8099, 0x0088, 0x808d, 0x8087, 0x0082, - - 0x8183, 0x0186, 0x018c, 0x8189, 0x0198, 0x819d, 0x8197, 0x0192, - 0x01b0, 0x81b5, 0x81bf, 0x01ba, 0x81ab, 0x01ae, 0x01a4, 0x81a1, - 0x01e0, 0x81e5, 0x81ef, 0x01ea, 0x81fb, 0x01fe, 0x01f4, 0x81f1, - 0x81d3, 0x01d6, 0x01dc, 0x81d9, 0x01c8, 0x81cd, 0x81c7, 0x01c2, - 0x0140, 0x8145, 0x814f, 0x014a, 0x815b, 0x015e, 0x0154, 0x8151, - 0x8173, 0x0176, 0x017c, 0x8179, 0x0168, 0x816d, 0x8167, 0x0162, - 0x8123, 0x0126, 0x012c, 0x8129, 0x0138, 0x813d, 0x8137, 0x0132, - 0x0110, 0x8115, 0x811f, 0x011a, 0x810b, 0x010e, 0x0104, 0x8101, - - 0x8303, 0x0306, 0x030c, 0x8309, 0x0318, 0x831d, 0x8317, 0x0312, - 0x0330, 0x8335, 0x833f, 0x033a, 0x832b, 0x032e, 0x0324, 0x8321, - 0x0360, 0x8365, 0x836f, 0x036a, 0x837b, 0x037e, 0x0374, 0x8371, - 0x8353, 0x0356, 0x035c, 0x8359, 0x0348, 0x834d, 0x8347, 0x0342, - 0x03c0, 0x83c5, 0x83cf, 0x03ca, 0x83db, 0x03de, 0x03d4, 0x83d1, - 0x83f3, 0x03f6, 0x03fc, 0x83f9, 0x03e8, 0x83ed, 0x83e7, 0x03e2, - 0x83a3, 0x03a6, 0x03ac, 0x83a9, 0x03b8, 0x83bd, 0x83b7, 0x03b2, - 0x0390, 0x8395, 0x839f, 0x039a, 0x838b, 0x038e, 0x0384, 0x8381, - - 0x0280, 0x8285, 0x828f, 0x028a, 0x829b, 0x029e, 0x0294, 0x8291, - 0x82b3, 0x02b6, 0x02bc, 0x82b9, 0x02a8, 0x82ad, 0x82a7, 0x02a2, - 0x82e3, 0x02e6, 0x02ec, 0x82e9, 0x02f8, 0x82fd, 0x82f7, 0x02f2, - 0x02d0, 0x82d5, 0x82df, 0x02da, 0x82cb, 0x02ce, 0x02c4, 0x82c1, - 0x8243, 0x0246, 0x024c, 0x8249, 0x0258, 0x825d, 0x8257, 0x0252, - 0x0270, 0x8275, 0x827f, 0x027a, 0x826b, 0x026e, 0x0264, 0x8261, - 0x0220, 0x8225, 0x822f, 0x022a, 0x823b, 0x023e, 0x0234, 0x8231, - 0x8213, 0x0216, 0x021c, 0x8219, 0x0208, 0x820d, 0x8207, 0x0202 -}; - -# define CRC_POLY 0x8005 - -#if INT_MAX != 0x7fffffff -#warning current libmad bit handling is optimized for architectures using 32 bit integers -#endif - -/* - * NAME: bit->init() - * DESCRIPTION: initialize bit pointer struct - */ -void mad_bit_init(struct mad_bitptr *bitptr, unsigned char const *byte) -{ - bitptr->ptr = (uint32_t*)((uintptr_t)byte & ~3); - bitptr->readbit = ((uintptr_t)byte & 3) << 3; -} - -/* - * NAME: bit->length() - * DESCRIPTION: return number of bits between start and end points - */ -unsigned int mad_bit_length(struct mad_bitptr const *begin, - struct mad_bitptr const *end) -{ - return end->readbit - begin->readbit; -} - -/* rockbox: not used -unsigned char mad_bit_bitsleft(struct mad_bitptr const *bitptr) -{ - return 8 - (bitptr->readbit & 7); -} -*/ - -/* - * NAME: bit->nextbyte() - * DESCRIPTION: return pointer to next unprocessed byte - */ -unsigned char const *mad_bit_nextbyte(struct mad_bitptr const *bitptr) -{ - return (unsigned char const*)bitptr->ptr + ((bitptr->readbit + 7) >> 3); -} - -/* - * NAME: bit->skip() - * DESCRIPTION: advance bit pointer - */ -void mad_bit_skip(struct mad_bitptr *bitptr, unsigned int len) -{ - bitptr->readbit += len; -} - -/* - * NAME: bit->read() - * DESCRIPTION: read an arbitrary number of bits and return their UIMSBF value - */ - -uint32_t mad_bit_read(struct mad_bitptr *bitptr, unsigned int len) ICODE_ATTR; -uint32_t mad_bit_read(struct mad_bitptr *bitptr, unsigned int len) -{ - uint32_t *curr = &bitptr->ptr[bitptr->readbit>>5]; - - if(len) - { - uint32_t r = betoh32(curr[0]) << (bitptr->readbit & 31); - - if((bitptr->readbit & 31) + len > 32) - r += betoh32(curr[1]) >> (-bitptr->readbit & 31); - - bitptr->readbit += len; - return r >> (32 - len); - } - - return 0; -} - -# if 0 /* rockbox: not used */ -/* - * NAME: bit->write() - * DESCRIPTION: write an arbitrary number of bits - */ -void mad_bit_write(struct mad_bitptr *bitptr, unsigned int len, - uint32_t value) -{ - unsigned char *ptr; - - ptr = (unsigned char *) bitptr->byte; - - /* ... */ -} -# endif - -/* - * NAME: bit->crc() - * DESCRIPTION: compute CRC-check word - */ -unsigned short mad_bit_crc(struct mad_bitptr bitptr, unsigned int len, - unsigned short init) -{ - register unsigned int crc; - - for (crc = init; len >= 32; len -= 32) { - register uint32_t data; - - data = mad_bit_read(&bitptr, 32); - - crc = (crc << 8) ^ crc_table[((crc >> 8) ^ (data >> 24)) & 0xff]; - crc = (crc << 8) ^ crc_table[((crc >> 8) ^ (data >> 16)) & 0xff]; - crc = (crc << 8) ^ crc_table[((crc >> 8) ^ (data >> 8)) & 0xff]; - crc = (crc << 8) ^ crc_table[((crc >> 8) ^ (data >> 0)) & 0xff]; - } - - switch (len / 8) { - case 3: crc = (crc << 8) ^ - crc_table[((crc >> 8) ^ mad_bit_read(&bitptr, 8)) & 0xff]; - case 2: crc = (crc << 8) ^ - crc_table[((crc >> 8) ^ mad_bit_read(&bitptr, 8)) & 0xff]; - case 1: crc = (crc << 8) ^ - crc_table[((crc >> 8) ^ mad_bit_read(&bitptr, 8)) & 0xff]; - - len %= 8; - - case 0: break; - } - - while (len--) { - register unsigned int msb; - - msb = mad_bit_read(&bitptr, 1) ^ (crc >> 15); - - crc <<= 1; - if (msb & 1) - crc ^= CRC_POLY; - } - - return crc & 0xffff; -} diff --git a/apps/codecs/libmad/bit.h b/apps/codecs/libmad/bit.h deleted file mode 100644 index 1c49522af5..0000000000 --- a/apps/codecs/libmad/bit.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * libmad - MPEG audio decoder library - * Copyright (C) 2000-2004 Underbit Technologies, Inc. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * $Id$ - */ - -# ifndef LIBMAD_BIT_H -# define LIBMAD_BIT_H - -struct mad_bitptr { - uint32_t *ptr; - uint32_t readbit; -}; - -void mad_bit_init(struct mad_bitptr *, unsigned char const *); - -# define mad_bit_finish(bitptr) /* nothing */ - -unsigned int mad_bit_length(struct mad_bitptr const *, - struct mad_bitptr const *); - -/* rockbox: not used -unsigned char mad_bit_bitsleft(struct mad_bitptr const *bitptr); -*/ -unsigned char const *mad_bit_nextbyte(struct mad_bitptr const *); - -void mad_bit_skip(struct mad_bitptr *, unsigned int); -uint32_t mad_bit_read(struct mad_bitptr *, unsigned int); -/* rockbox: not used -void mad_bit_write(struct mad_bitptr *, unsigned int, uint32_t); -*/ - -unsigned short mad_bit_crc(struct mad_bitptr, unsigned int, unsigned short); - -# endif diff --git a/apps/codecs/libmad/dct32_arm.S b/apps/codecs/libmad/dct32_arm.S deleted file mode 100644 index 440841bb5e..0000000000 --- a/apps/codecs/libmad/dct32_arm.S +++ /dev/null @@ -1,328 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2007 by Tomasz Malesinski - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ - -#include "mad_iram.h" - - .global dct32 - - .section ICODE_SECTION_MPA_ARM,"ax",%progbits - -dct32: - stmdb sp!, {r4-r11, lr} - sub sp, sp, #144 - str r0, [sp, #12] - str r1, [sp, #8] - str r2, [sp, #4] - str r3, [sp] - add r0, sp, #16 - add r1, r0, #128 - ldr r2, =bitrev -.shuffle: - ldr r5, [sp, #12] - ldr r3, [r2], #4 - sub r4, r5, r3, lsl #4 - add r3, r5, r3, lsl #4 - ldr r6, [r3] - ldr r8, [r4, #124] - add r6, r6, r8 - sub r8, r6, r8, lsl #1 - ldr r7, [r3, #8] - ldr lr, [r4, #116] - add r7, r7, lr - sub lr, r7, lr, lsl #1 - ldr r10, [r3, #64] - ldr r9, [r4, #60] - add r10, r10, r9 - sub r9, r10, r9, lsl #1 - ldr r11, [r3, #72] - ldr r12, [r4, #52] - add r11, r11, r12 - sub r12, r11, r12, lsl #1 - add r6, r6, r10 - sub r10, r6, r10, lsl #1 - add r7, r7, r11 - sub r11, r7, r11, lsl #1 - add r8, r8, r12 - sub r12, r8, r12, lsl #1 - add lr, lr, r9 - sub r9, lr, r9, lsl #1 - stmia r0!, {r6, r7, r8, r9, r10, r11, r12, lr} - cmp r0, r1 - bne .shuffle - ldr r0, =189812531 - add r1, sp, #16 - add r3, r1, #128 -.l2: - add r2, r1, #32 - ldmia r2, {r4, r5, r8, r9} - ldmia r1, {r6, r7, r10, r11} - add r6, r6, r4 - sub r4, r6, r4, lsl #1 - add r7, r7, r5 - sub r5, r7, r5, lsl #1 - stmia r2!, {r4, r5} - stmia r1!, {r6, r7} - add r9, r9, r8 - sub r8, r9, r8, lsl #1 - smull r4, r6, r9, r0 - movs r4, r4, lsr #28 - adc r4, r4, r6, lsl #4 - smull r5, r6, r8, r0 - movs r5, r5, lsr #28 - adc r5, r5, r6, lsl #4 - add r10, r10, r4 - sub r4, r10, r4, lsl #1 - add r11, r11, r5 - sub r5, r11, r5, lsl #1 - stmia r2!, {r4, r5} - stmia r1!, {r10, r11} - ldmia r2, {r5, r6, r8, r11} - ldmia r1, {r4, r7, r9, r10} - add r4, r4, r6 - sub r6, r4, r6, lsl #1 - add r7, r7, r5 - sub r5, r7, r5, lsl #1 - stmia r2!, {r6, r7} - stmia r1!, {r4, r5} - add r11, r11, r8 - sub r8, r11, r8, lsl #1 - smull r5, r4, r8, r0 - movs r5, r5, lsr #28 - adc r5, r5, r4, lsl #4 - smull r6, r4, r11, r0 - movs r6, r6, lsr #28 - adc r6, r6, r4, lsl #4 - add r9, r9, r5 - sub r5, r9, r5, lsl #1 - sub r10, r10, r6 - add r6, r10, r6, lsl #1 - stmia r2!, {r5, r6} - stmia r1!, {r9, r10} - add r1, r1, #32 - cmp r1, r3 - bne .l2 - add r2, sp, #16 - add r3, r2, #64 - ldr r0, =sincos - add r1, r0, #128 -.lbut8: - ldmia r3, {r7, r8} - ldmia r0, {r9, r10} - add r0, r0, #16 - smull r6, r5, r7, r9 - smlal r6, r5, r10, r8 - movs r6, r6, lsr #28 - adc r6, r6, r5, lsl #4 - smull r10, r5, r7, r10 - rsb r9, r9, #0 - smlal r10, r5, r8, r9 - movs r10, r10, lsr #28 - adc r5, r10, r5, lsl #4 - ldmia r2, {r7, r8} - add r7, r7, r5 - sub r5, r7, r5, lsl #1 - add r8, r8, r6 - sub r6, r8, r6, lsl #1 - stmia r3!, {r5, r6} - stmia r2!, {r7, r8} - cmp r0, r1 - bne .lbut8 - add r1, sp, #16 - ldr r2, =sincos - ldr r3, =sincos2 - ldr r0, [sp, #8] - mov r0, r0, lsl #2 - ldr r4, [sp, #4] - add r4, r4, r0 - ldr r5, [sp] - add r5, r5, #480 - add r5, r5, r0 - mov r0, #0 -.l4: - rsb r12, r0, #16 - and r12, r12, #15 - add lr, sp, #16 - add r12, lr, r12, lsl #3 - ldmia r1!, {r10, r11} - ldmia r12, {r6, r7} - add r6, r6, r10 - sub r10, r6, r10, lsl #1 - add r11, r11, r7 - sub r7, r11, r7, lsl #1 - ldmia r2!, {r12, lr} - smull r9, r8, r11, r12 - smlal r9, r8, lr, r10 - movs r9, r9, lsr #28 - adc r9, r9, r8, lsl #4 - smull lr, r8, r11, lr - rsb r12, r12, #0 - smlal lr, r8, r10, r12 - movs lr, lr, lsr #28 - adc r8, lr, r8, lsl #4 - add r6, r6, r8 - sub r8, r6, r8, lsl #1 - add r7, r7, r9 - sub r9, r7, r9, lsl #1 - add lr, r3, #128 - ldmia lr, {r10, r11} - smull lr, r12, r8, r11 - smlal lr, r12, r9, r10 - movs lr, lr, lsr #28 - adc r12, lr, r12, lsl #4 - str r12, [r4], #32 - cmp r0, #0 - cmpne r0, #8 - beq .skip1 - smull lr, r12, r8, r10 - rsb r9, r9, #0 - smlal lr, r12, r9, r11 - movs lr, lr, lsr #28 - adc r12, lr, r12, lsl #4 - add lr, r5, r0, lsl #6 - str r12, [lr, #-512] -.skip1: - ldmia r3!, {r10, r11} - smull lr, r12, r7, r10 - smlal lr, r12, r6, r11 - movs lr, lr, lsr #28 - adc r12, lr, r12, lsl #4 - str r12, [r5], #-32 - cmp r0, #0 - cmpne r0, #8 - beq .skip2 - smull lr, r12, r6, r10 - rsb r7, r7, #0 - smlal lr, r12, r7, r11 - movs lr, lr, lsr #28 - adc r12, lr, r12, lsl #4 - sub lr, r4, r0, lsl #6 - str r12, [lr, #480] -.skip2: - add r0, r0, #1 - cmp r0, #9 - bne .l4 - add sp, sp, #144 - ldmpc regs=r4-r11 -bitrev: - .word 0x0 - .word 0x2 - .word 0x1 - .word 0x3 - -sincos: - .word 0x0 - .word 0x10000000 - .word -0x31f1708 - .word 0xfb14be8 - .word -0x61f78aa - .word 0xec835e8 - .word -0x8e39d9d - .word 0xd4db315 - .word -0xb504f33 - .word 0xb504f33 - .word -0xd4db315 - .word 0x8e39d9d - .word -0xec835e8 - .word 0x61f78aa - .word -0xfb14be8 - .word 0x31f1708 - .word -0x10000000 - .word 0x0 - .word -0xfb14be8 - .word -0x31f1708 - .word -0xec835e8 - .word -0x61f78aa - .word -0xd4db315 - .word -0x8e39d9d - .word -0xb504f33 - .word -0xb504f33 - .word -0x8e39d9d - .word -0xd4db315 - .word -0x61f78aa - .word -0xec835e8 - .word -0x31f1708 - .word -0xfb14be8 - -sincos2: - .word 0x0 - .word 0x8000000 - .word 0x647d98 - .word 0x7fd8879 - .word 0xc8bd36 - .word 0x7f62369 - .word 0x12c8107 - .word 0x7e9d560 - .word 0x18f8b84 - .word 0x7d8a5f4 - .word 0x1f19f98 - .word 0x7c29fbf - .word 0x25280c6 - .word 0x7a7d056 - .word 0x2b1f34f - .word 0x7884841 - .word 0x30fbc55 - .word 0x7641af4 - .word 0x36ba201 - .word 0x73b5ebd - .word 0x3c56ba7 - .word 0x70e2cbc - .word 0x41ce1e6 - .word 0x6dca0d1 - .word 0x471cece - .word 0x6a6d98a - .word 0x4c3fdff - .word 0x66cf812 - .word 0x5133cc9 - .word 0x62f201b - .word 0x55f5a4d - .word 0x5ed77c9 - .word 0x5a8279a - .word 0x5a8279a - .word 0x5ed77c9 - .word 0x55f5a4d - .word 0x62f201b - .word 0x5133cc9 - .word 0x66cf812 - .word 0x4c3fdff - .word 0x6a6d98a - .word 0x471cece - .word 0x6dca0d1 - .word 0x41ce1e6 - .word 0x70e2cbc - .word 0x3c56ba7 - .word 0x73b5ebd - .word 0x36ba201 - .word 0x7641af4 - .word 0x30fbc55 - .word 0x7884841 - .word 0x2b1f34f - .word 0x7a7d056 - .word 0x25280c6 - .word 0x7c29fbf - .word 0x1f19f98 - .word 0x7d8a5f4 - .word 0x18f8b84 - .word 0x7e9d560 - .word 0x12c8107 - .word 0x7f62369 - .word 0xc8bd36 - .word 0x7fd8879 - .word 0x647d98 diff --git a/apps/codecs/libmad/fixed.h b/apps/codecs/libmad/fixed.h deleted file mode 100644 index 6015684644..0000000000 --- a/apps/codecs/libmad/fixed.h +++ /dev/null @@ -1,510 +0,0 @@ -/* - * libmad - MPEG audio decoder library - * Copyright (C) 2000-2004 Underbit Technologies, Inc. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * $Id$ - */ - -# ifndef LIBMAD_FIXED_H -# define LIBMAD_FIXED_H - -#include - -typedef int32_t mad_fixed_t; - -typedef int32_t mad_fixed64hi_t; -typedef uint32_t mad_fixed64lo_t; - -# if defined(_MSC_VER) -# define mad_fixed64_t signed __int64 -# elif 1 || defined(__GNUC__) -# define mad_fixed64_t signed long long -# endif - -# if defined(FPM_FLOAT) -typedef double mad_sample_t; -# else -typedef mad_fixed_t mad_sample_t; -# endif - -/* - * Fixed-point format: 0xABBBBBBB - * A == whole part (sign + 3 bits) - * B == fractional part (28 bits) - * - * Values are signed two's complement, so the effective range is: - * 0x80000000 to 0x7fffffff - * -8.0 to +7.9999999962747097015380859375 - * - * The smallest representable value is: - * 0x00000001 == 0.0000000037252902984619140625 (i.e. about 3.725e-9) - * - * 28 bits of fractional accuracy represent about - * 8.6 digits of decimal accuracy. - * - * Fixed-point numbers can be added or subtracted as normal - * integers, but multiplication requires shifting the 64-bit result - * from 56 fractional bits back to 28 (and rounding.) - * - * Changing the definition of MAD_F_FRACBITS is only partially - * supported, and must be done with care. - */ - -# define MAD_F_FRACBITS 28 - -# if MAD_F_FRACBITS == 28 -# define MAD_F(x) ((mad_fixed_t) (x##L)) -# else -# if MAD_F_FRACBITS < 28 -# warning "MAD_F_FRACBITS < 28" -# define MAD_F(x) ((mad_fixed_t) \ - (((x##L) + \ - (1L << (28 - MAD_F_FRACBITS - 1))) >> \ - (28 - MAD_F_FRACBITS))) -# elif MAD_F_FRACBITS > 28 -# error "MAD_F_FRACBITS > 28 not currently supported" -# define MAD_F(x) ((mad_fixed_t) \ - ((x##L) << (MAD_F_FRACBITS - 28))) -# endif -# endif - -# define MAD_F_MIN ((mad_fixed_t) -0x80000000L) -# define MAD_F_MAX ((mad_fixed_t) +0x7fffffffL) - -# define MAD_F_ONE MAD_F(0x10000000) - -# define mad_f_tofixed(x) ((mad_fixed_t) \ - ((x) * (double) (1L << MAD_F_FRACBITS) + 0.5)) -# define mad_f_todouble(x) ((double) \ - ((x) / (double) (1L << MAD_F_FRACBITS))) - -# define mad_f_intpart(x) ((x) >> MAD_F_FRACBITS) -# define mad_f_fracpart(x) ((x) & ((1L << MAD_F_FRACBITS) - 1)) - /* (x should be positive) */ - -# define mad_f_fromint(x) ((x) << MAD_F_FRACBITS) - -# define mad_f_add(x, y) ((x) + (y)) -# define mad_f_sub(x, y) ((x) - (y)) - -# if defined(FPM_FLOAT) -# error "FPM_FLOAT not yet supported" - -# undef MAD_F -# define MAD_F(x) mad_f_todouble(x) - -# define mad_f_mul(x, y) ((x) * (y)) -# define mad_f_scale64 - -# elif defined(FPM_64BIT) - -/* - * This version should be the most accurate if 64-bit types are supported by - * the compiler, although it may not be the most efficient. - */ -# if defined(OPT_ACCURACY) -# define mad_f_mul(x, y) \ - ((mad_fixed_t) \ - ((((mad_fixed64_t) (x) * (y)) + \ - (1L << (MAD_F_SCALEBITS - 1))) >> MAD_F_SCALEBITS)) -# else -# define mad_f_mul(x, y) \ - ((mad_fixed_t) (((mad_fixed64_t) (x) * (y)) >> MAD_F_SCALEBITS)) -# endif - -# define MAD_F_SCALEBITS MAD_F_FRACBITS - -/* --- Intel --------------------------------------------------------------- */ - -# elif defined(FPM_INTEL) - -# if defined(_MSC_VER) -# pragma warning(push) -# pragma warning(disable: 4035) /* no return value */ -static __forceinline -mad_fixed_t mad_f_mul_inline(mad_fixed_t x, mad_fixed_t y) -{ - enum { - fracbits = MAD_F_FRACBITS - }; - - __asm { - mov eax, x - imul y - shrd eax, edx, fracbits - } - - /* implicit return of eax */ -} -# pragma warning(pop) - -# define mad_f_mul mad_f_mul_inline -# define mad_f_scale64 -# else -/* - * This Intel version is fast and accurate; the disposition of the least - * significant bit depends on OPT_ACCURACY via mad_f_scale64(). - */ -# define MAD_F_MLX(hi, lo, x, y) \ - asm ("imull %3" \ - : "=a" (lo), "=d" (hi) \ - : "%a" (x), "rm" (y) \ - : "cc") - -# if defined(OPT_ACCURACY) -/* - * This gives best accuracy but is not very fast. - */ -# define MAD_F_MLA(hi, lo, x, y) \ - ({ mad_fixed64hi_t __hi; \ - mad_fixed64lo_t __lo; \ - MAD_F_MLX(__hi, __lo, (x), (y)); \ - asm ("addl %2,%0\n\t" \ - "adcl %3,%1" \ - : "=rm" (lo), "=rm" (hi) \ - : "r" (__lo), "r" (__hi), "0" (lo), "1" (hi) \ - : "cc"); \ - }) -# endif /* OPT_ACCURACY */ - -# if defined(OPT_ACCURACY) -/* - * Surprisingly, this is faster than SHRD followed by ADC. - */ -# define mad_f_scale64(hi, lo) \ - ({ mad_fixed64hi_t __hi_; \ - mad_fixed64lo_t __lo_; \ - mad_fixed_t __result; \ - asm ("addl %4,%2\n\t" \ - "adcl %5,%3" \ - : "=rm" (__lo_), "=rm" (__hi_) \ - : "0" (lo), "1" (hi), \ - "ir" (1L << (MAD_F_SCALEBITS - 1)), "ir" (0) \ - : "cc"); \ - asm ("shrdl %3,%2,%1" \ - : "=rm" (__result) \ - : "0" (__lo_), "r" (__hi_), "I" (MAD_F_SCALEBITS) \ - : "cc"); \ - __result; \ - }) -# elif defined(OPT_INTEL) -/* - * Alternate Intel scaling that may or may not perform better. - */ -# define mad_f_scale64(hi, lo) \ - ({ mad_fixed_t __result; \ - asm ("shrl %3,%1\n\t" \ - "shll %4,%2\n\t" \ - "orl %2,%1" \ - : "=rm" (__result) \ - : "0" (lo), "r" (hi), \ - "I" (MAD_F_SCALEBITS), "I" (32 - MAD_F_SCALEBITS) \ - : "cc"); \ - __result; \ - }) -# else -# define mad_f_scale64(hi, lo) \ - ({ mad_fixed_t __result; \ - asm ("shrdl %3,%2,%1" \ - : "=rm" (__result) \ - : "0" (lo), "r" (hi), "I" (MAD_F_SCALEBITS) \ - : "cc"); \ - __result; \ - }) -# endif /* OPT_ACCURACY */ - -# define MAD_F_SCALEBITS MAD_F_FRACBITS -# endif - -/* --- ARM ----------------------------------------------------------------- */ - -# elif defined(FPM_ARM) - -/* - * This ARM V4 version is as accurate as FPM_64BIT but much faster. The - * least significant bit is properly rounded at no CPU cycle cost! - */ -# if 1 -/* - * This is faster than the default implementation via MAD_F_MLX() and - * mad_f_scale64(). - */ -# define mad_f_mul(x, y) \ - ({ mad_fixed64hi_t __hi; \ - mad_fixed64lo_t __lo; \ - mad_fixed_t __result; \ - asm ("smull %0, %1, %3, %4\n\t" \ - "movs %0, %0, lsr %5\n\t" \ - "adc %2, %0, %1, lsl %6" \ - : "=&r" (__lo), "=&r" (__hi), "=r" (__result) \ - : "%r" (x), "r" (y), \ - "M" (MAD_F_SCALEBITS), "M" (32 - MAD_F_SCALEBITS) \ - : "cc"); \ - __result; \ - }) -# endif - -# define MAD_F_MLX(hi, lo, x, y) \ - asm ("smull %0, %1, %2, %3" \ - : "=&r" (lo), "=&r" (hi) \ - : "%r" (x), "r" (y)) - -# define MAD_F_MLA(hi, lo, x, y) \ - asm ("smlal %0, %1, %2, %3" \ - : "+r" (lo), "+r" (hi) \ - : "%r" (x), "r" (y)) - -# define MAD_F_MLN(hi, lo) \ - asm ("rsbs %0, %2, #0\n\t" \ - "rsc %1, %3, #0" \ - : "=r" (lo), "=r" (hi) \ - : "0" (lo), "1" (hi) \ - : "cc") - -# define mad_f_scale64(hi, lo) \ - ({ mad_fixed_t __result; \ - asm ("movs %0, %1, lsr %3\n\t" \ - "adc %0, %0, %2, lsl %4" \ - : "=&r" (__result) \ - : "r" (lo), "r" (hi), \ - "M" (MAD_F_SCALEBITS), "M" (32 - MAD_F_SCALEBITS) \ - : "cc"); \ - __result; \ - }) - -# define MAD_F_SCALEBITS MAD_F_FRACBITS - -/* --- MIPS ---------------------------------------------------------------- */ - -# elif defined(FPM_MIPS) - -/* - * This MIPS version is fast and accurate; the disposition of the least - * significant bit depends on OPT_ACCURACY via mad_f_scale64(). - */ -# define MAD_F_MLX(hi, lo, x, y) \ - asm ("mult %2,%3" \ - : "=l" (lo), "=h" (hi) \ - : "%r" (x), "r" (y)) - -# if defined(HAVE_MADD_ASM) -# define MAD_F_MLA(hi, lo, x, y) \ - asm ("madd %2,%3" \ - : "+l" (lo), "+h" (hi) \ - : "%r" (x), "r" (y)) -# elif defined(HAVE_MADD16_ASM) -/* - * This loses significant accuracy due to the 16-bit integer limit in the - * multiply/accumulate instruction. - */ -# define MAD_F_ML0(hi, lo, x, y) \ - asm ("mult %2,%3" \ - : "=l" (lo), "=h" (hi) \ - : "%r" ((x) >> 12), "r" ((y) >> 16)) -# define MAD_F_MLA(hi, lo, x, y) \ - asm ("madd16 %2,%3" \ - : "+l" (lo), "+h" (hi) \ - : "%r" ((x) >> 12), "r" ((y) >> 16)) -# define MAD_F_MLZ(hi, lo) ((mad_fixed_t) (lo)) -# endif - -# if defined(OPT_SPEED) -# define mad_f_scale64(hi, lo) \ - ((mad_fixed_t) ((hi) << (32 - MAD_F_SCALEBITS))) -# define MAD_F_SCALEBITS MAD_F_FRACBITS -# endif - -/* --- SPARC --------------------------------------------------------------- */ - -# elif defined(FPM_SPARC) - -/* - * This SPARC V8 version is fast and accurate; the disposition of the least - * significant bit depends on OPT_ACCURACY via mad_f_scale64(). - */ -# define MAD_F_MLX(hi, lo, x, y) \ - asm ("smul %2, %3, %0\n\t" \ - "rd %%y, %1" \ - : "=r" (lo), "=r" (hi) \ - : "%r" (x), "rI" (y)) - -/* --- PowerPC ------------------------------------------------------------- */ - -# elif defined(FPM_PPC) - -/* - * This PowerPC version is fast and accurate; the disposition of the least - * significant bit depends on OPT_ACCURACY via mad_f_scale64(). - */ -# define MAD_F_MLX(hi, lo, x, y) \ - do { \ - asm ("mullw %0,%1,%2" \ - : "=r" (lo) \ - : "%r" (x), "r" (y)); \ - asm ("mulhw %0,%1,%2" \ - : "=r" (hi) \ - : "%r" (x), "r" (y)); \ - } \ - while (0) - -# if defined(OPT_ACCURACY) -/* - * This gives best accuracy but is not very fast. - */ -# define MAD_F_MLA(hi, lo, x, y) \ - ({ mad_fixed64hi_t __hi; \ - mad_fixed64lo_t __lo; \ - MAD_F_MLX(__hi, __lo, (x), (y)); \ - asm ("addc %0,%2,%3\n\t" \ - "adde %1,%4,%5" \ - : "=r" (lo), "=r" (hi) \ - : "%r" (lo), "r" (__lo), \ - "%r" (hi), "r" (__hi) \ - : "xer"); \ - }) -# endif - -# if defined(OPT_ACCURACY) -/* - * This is slower than the truncating version below it. - */ -# define mad_f_scale64(hi, lo) \ - ({ mad_fixed_t __result, __round; \ - asm ("rotrwi %0,%1,%2" \ - : "=r" (__result) \ - : "r" (lo), "i" (MAD_F_SCALEBITS)); \ - asm ("extrwi %0,%1,1,0" \ - : "=r" (__round) \ - : "r" (__result)); \ - asm ("insrwi %0,%1,%2,0" \ - : "+r" (__result) \ - : "r" (hi), "i" (MAD_F_SCALEBITS)); \ - asm ("add %0,%1,%2" \ - : "=r" (__result) \ - : "%r" (__result), "r" (__round)); \ - __result; \ - }) -# else -# define mad_f_scale64(hi, lo) \ - ({ mad_fixed_t __result; \ - asm ("rotrwi %0,%1,%2" \ - : "=r" (__result) \ - : "r" (lo), "i" (MAD_F_SCALEBITS)); \ - asm ("insrwi %0,%1,%2,0" \ - : "+r" (__result) \ - : "r" (hi), "i" (MAD_F_SCALEBITS)); \ - __result; \ - }) -# endif - -# define MAD_F_SCALEBITS MAD_F_FRACBITS - -# elif defined(FPM_COLDFIRE_EMAC) - -/* mad_f_mul using the Coldfire MCF5249 EMAC unit. Loses 3 bits of accuracy. - Note that we don't define any of the libmad accumulator macros, as - any functions that use these should have the relevant sections rewritten - in assembler to utilise the EMAC accumulators properly. - Assumes the default +/- 3.28 fixed point format - */ -#define mad_f_mul(x, y) \ -({ \ - mad_fixed64hi_t hi; \ - asm volatile("mac.l %[a], %[b], %%acc0\n\t" \ - "movclr.l %%acc0, %[hi]\n\t" \ - "asl.l #3, %[hi]" \ - : [hi] "=d" (hi) \ - : [a] "r" ((x)), [b] "r" ((y))); \ - hi; \ -}) -/* Define dummy mad_f_scale64 to prevent libmad from defining MAD_F_SCALEBITS - below. Having MAD_F_SCALEBITS defined screws up the PRESHIFT macro in synth.c - */ -#define mad_f_scale64(hi, lo) (lo) - -/* --- Default ------------------------------------------------------------- */ - -# elif defined(FPM_DEFAULT) - -/* - * This version is the most portable but it loses significant accuracy. - * Furthermore, accuracy is biased against the second argument, so care - * should be taken when ordering operands. - * - * The scale factors are constant as this is not used with SSO. - * - * Pre-rounding is required to stay within the limits of compliance. - */ -# if defined(OPT_SPEED) -# define mad_f_mul(x, y) (((x) >> 12) * ((y) >> 16)) -# else -# define mad_f_mul(x, y) ((((x) + (1L << 11)) >> 12) * \ - (((y) + (1L << 15)) >> 16)) -# endif - -/* ------------------------------------------------------------------------- */ - -# else -# error "no FPM selected" -# endif - -/* default implementations */ - -# if !defined(mad_f_mul) -# define mad_f_mul(x, y) \ - ({ register mad_fixed64hi_t __hi; \ - register mad_fixed64lo_t __lo; \ - MAD_F_MLX(__hi, __lo, (x), (y)); \ - mad_f_scale64(__hi, __lo); \ - }) -# endif - -# if !defined(MAD_F_MLA) -# define MAD_F_ML0(hi, lo, x, y) ((lo) = mad_f_mul((x), (y))) -# define MAD_F_MLA(hi, lo, x, y) ((lo) += mad_f_mul((x), (y))) -# define MAD_F_MLN(hi, lo) ((lo) = -(lo)) -# define MAD_F_MLZ(hi, lo) ((void) (hi), (mad_fixed_t) (lo)) -# endif - -# if !defined(MAD_F_ML0) -# define MAD_F_ML0(hi, lo, x, y) MAD_F_MLX((hi), (lo), (x), (y)) -# endif - -# if !defined(MAD_F_MLN) -# define MAD_F_MLN(hi, lo) ((hi) = ((lo) = -(lo)) ? ~(hi) : -(hi)) -# endif - -# if !defined(MAD_F_MLZ) -# define MAD_F_MLZ(hi, lo) mad_f_scale64((hi), (lo)) -# endif - -# if !defined(mad_f_scale64) -# if defined(OPT_ACCURACY) -# define mad_f_scale64(hi, lo) \ - ((((mad_fixed_t) \ - (((hi) << (32 - (MAD_F_SCALEBITS - 1))) | \ - ((lo) >> (MAD_F_SCALEBITS - 1)))) + 1) >> 1) -# else -# define mad_f_scale64(hi, lo) \ - ((mad_fixed_t) \ - (((hi) << (32 - MAD_F_SCALEBITS)) | \ - ((lo) >> MAD_F_SCALEBITS))) -# endif -# define MAD_F_SCALEBITS MAD_F_FRACBITS -# endif - -# endif diff --git a/apps/codecs/libmad/frame.c b/apps/codecs/libmad/frame.c deleted file mode 100644 index 61671c7e13..0000000000 --- a/apps/codecs/libmad/frame.c +++ /dev/null @@ -1,499 +0,0 @@ -/* - * libmad - MPEG audio decoder library - * Copyright (C) 2000-2004 Underbit Technologies, Inc. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * $Id$ - */ - -# ifdef HAVE_CONFIG_H -# include "config.h" -# endif - -# include "global.h" - -# include "bit.h" -# include "stream.h" -# include "frame.h" -# include "timer.h" -# include "layer12.h" -# include "layer3.h" -# include "codeclib.h" - -static -unsigned long const bitrate_table[5][15] = { - /* MPEG-1 */ - { 0, 32000, 64000, 96000, 128000, 160000, 192000, 224000, /* Layer I */ - 256000, 288000, 320000, 352000, 384000, 416000, 448000 }, - { 0, 32000, 48000, 56000, 64000, 80000, 96000, 112000, /* Layer II */ - 128000, 160000, 192000, 224000, 256000, 320000, 384000 }, - { 0, 32000, 40000, 48000, 56000, 64000, 80000, 96000, /* Layer III */ - 112000, 128000, 160000, 192000, 224000, 256000, 320000 }, - - /* MPEG-2 LSF */ - { 0, 32000, 48000, 56000, 64000, 80000, 96000, 112000, /* Layer I */ - 128000, 144000, 160000, 176000, 192000, 224000, 256000 }, - { 0, 8000, 16000, 24000, 32000, 40000, 48000, 56000, /* Layers */ - 64000, 80000, 96000, 112000, 128000, 144000, 160000 } /* II & III */ -}; - -static -unsigned int const samplerate_table[3] = { 44100, 48000, 32000 }; - -static -int (*const decoder_table[3])(struct mad_stream *, struct mad_frame *) = { - mad_layer_I, - mad_layer_II, - mad_layer_III -}; - -/* - * NAME: header->init() - * DESCRIPTION: initialize header struct - */ -void mad_header_init(struct mad_header *header) -{ - header->layer = 0; - header->mode = 0; - header->mode_extension = 0; - header->emphasis = 0; - - header->bitrate = 0; - header->samplerate = 0; - - header->crc_check = 0; - header->crc_target = 0; - - header->flags = 0; - header->private_bits = 0; -/* rockbox: not used - header->duration = mad_timer_zero; -*/ -} - -/* - * NAME: frame->init() - * DESCRIPTION: initialize frame struct - */ -void mad_frame_init(struct mad_frame *frame) -{ - mad_header_init(&frame->header); - - frame->options = 0; -/* rockbox: comment this to proper zero this array in mad_frame_mute(). overlap - * is linked to an array in rockbox' apps/codecs/mpa.c before calling this. - frame->overlap = 0; -*/ - mad_frame_mute(frame); -} - -/* - * NAME: frame->finish() - * DESCRIPTION: deallocate any dynamic memory associated with frame - */ -/* rockbox: unused -void mad_frame_finish(struct mad_frame *frame) -{ - mad_header_finish(&frame->header); - - if (frame->overlap) { - free(frame->overlap); - frame->overlap = 0; - } -} -*/ - -/* - * NAME: decode_header() - * DESCRIPTION: read header data and following CRC word - */ -static -int decode_header(struct mad_header *header, struct mad_stream *stream) -{ - unsigned int index; - - header->flags = 0; - header->private_bits = 0; - - /* header() */ - - /* syncword */ - mad_bit_skip(&stream->ptr, 11); - - /* MPEG 2.5 indicator (really part of syncword) */ - if (mad_bit_read(&stream->ptr, 1) == 0) - header->flags |= MAD_FLAG_MPEG_2_5_EXT; - - /* ID */ - if (mad_bit_read(&stream->ptr, 1) == 0) - header->flags |= MAD_FLAG_LSF_EXT; - else if (header->flags & MAD_FLAG_MPEG_2_5_EXT) { - stream->error = MAD_ERROR_LOSTSYNC; - return -1; - } - - /* layer */ - header->layer = 4 - mad_bit_read(&stream->ptr, 2); - - if (header->layer == 4) { - stream->error = MAD_ERROR_BADLAYER; - return -1; - } - - /* protection_bit */ - if (mad_bit_read(&stream->ptr, 1) == 0) { - header->flags |= MAD_FLAG_PROTECTION; - header->crc_check = mad_bit_crc(stream->ptr, 16, 0xffff); - } - - /* bitrate_index */ - index = mad_bit_read(&stream->ptr, 4); - - if (index == 15) { - stream->error = MAD_ERROR_BADBITRATE; - return -1; - } - - if (header->flags & MAD_FLAG_LSF_EXT) - header->bitrate = bitrate_table[3 + (header->layer >> 1)][index]; - else - header->bitrate = bitrate_table[header->layer - 1][index]; - - /* sampling_frequency */ - index = mad_bit_read(&stream->ptr, 2); - - if (index == 3) { - stream->error = MAD_ERROR_BADSAMPLERATE; - return -1; - } - - header->samplerate = samplerate_table[index]; - - if (header->flags & MAD_FLAG_LSF_EXT) { - header->samplerate /= 2; - - if (header->flags & MAD_FLAG_MPEG_2_5_EXT) - header->samplerate /= 2; - } - - /* padding_bit */ - if (mad_bit_read(&stream->ptr, 1)) - header->flags |= MAD_FLAG_PADDING; - - /* private_bit */ - if (mad_bit_read(&stream->ptr, 1)) - header->private_bits |= MAD_PRIVATE_HEADER; - - /* mode */ - header->mode = 3 - mad_bit_read(&stream->ptr, 2); - - /* mode_extension */ - header->mode_extension = mad_bit_read(&stream->ptr, 2); - - /* copyright */ - if (mad_bit_read(&stream->ptr, 1)) - header->flags |= MAD_FLAG_COPYRIGHT; - - /* original/copy */ - if (mad_bit_read(&stream->ptr, 1)) - header->flags |= MAD_FLAG_ORIGINAL; - - /* emphasis */ - header->emphasis = mad_bit_read(&stream->ptr, 2); - -# if defined(OPT_STRICT) - /* - * ISO/IEC 11172-3 says this is a reserved emphasis value, but - * streams exist which use it anyway. Since the value is not important - * to the decoder proper, we allow it unless OPT_STRICT is defined. - */ - if (header->emphasis == MAD_EMPHASIS_RESERVED) { - stream->error = MAD_ERROR_BADEMPHASIS; - return -1; - } -# endif - - /* error_check() */ - - /* crc_check */ - if (header->flags & MAD_FLAG_PROTECTION) - header->crc_target = mad_bit_read(&stream->ptr, 16); - - return 0; -} - -/* - * NAME: free_bitrate() - * DESCRIPTION: attempt to discover the bitstream's free bitrate - */ -static -int free_bitrate(struct mad_stream *stream, struct mad_header const *header) -{ - struct mad_bitptr keep_ptr; - unsigned long rate = 0; - unsigned int pad_slot, slots_per_frame; - unsigned char const *ptr = 0; - - keep_ptr = stream->ptr; - - pad_slot = (header->flags & MAD_FLAG_PADDING) ? 1 : 0; - slots_per_frame = (header->layer == MAD_LAYER_III && - (header->flags & MAD_FLAG_LSF_EXT)) ? 72 : 144; - - while (mad_stream_sync(stream) == 0) { - struct mad_stream peek_stream; - struct mad_header peek_header; - - peek_stream = *stream; - peek_header = *header; - - if (decode_header(&peek_header, &peek_stream) == 0 && - peek_header.layer == header->layer && - peek_header.samplerate == header->samplerate) { - unsigned int N; - - ptr = mad_bit_nextbyte(&stream->ptr); - - N = ptr - stream->this_frame; - - if (header->layer == MAD_LAYER_I) { - rate = (unsigned long) header->samplerate * - (N - 4 * pad_slot + 4) / 48 / 1000; - } - else { - rate = (unsigned long) header->samplerate * - (N - pad_slot + 1) / slots_per_frame / 1000; - } - - if (rate >= 8) - break; - } - - mad_bit_skip(&stream->ptr, 8); - } - - stream->ptr = keep_ptr; - - if (rate < 8 || (header->layer == MAD_LAYER_III && rate > 640)) { - stream->error = MAD_ERROR_LOSTSYNC; - return -1; - } - - stream->freerate = rate * 1000; - - return 0; -} - -/* - * NAME: header->decode() - * DESCRIPTION: read the next frame header from the stream - */ -int mad_header_decode(struct mad_header *header, struct mad_stream *stream) -{ - register unsigned char const *ptr, *end; - unsigned int pad_slot, N; - - ptr = stream->next_frame; - end = stream->bufend; - - if (ptr == 0) { - stream->error = MAD_ERROR_BUFPTR; - goto fail; - } - - /* stream skip */ - /* rockbox: not used - if (stream->skiplen) { - if (!stream->sync) - ptr = stream->this_frame; - - if (end - ptr < (long) stream->skiplen) { - stream->skiplen -= end - ptr; - stream->next_frame = end; - - stream->error = MAD_ERROR_BUFLEN; - goto fail; - } - - ptr += stream->skiplen; - stream->skiplen = 0; - - stream->sync = 1; - } - */ - - sync: - /* synchronize */ - if (stream->sync) { - if (end - ptr < MAD_BUFFER_GUARD) { - stream->next_frame = ptr; - - stream->error = MAD_ERROR_BUFLEN; - goto fail; - } - else if (!(ptr[0] == 0xff && (ptr[1] & 0xe0) == 0xe0)) { - /* mark point where frame sync word was expected */ - stream->this_frame = ptr; - stream->next_frame = ptr + 1; - - stream->error = MAD_ERROR_LOSTSYNC; - goto fail; - } - } - else { - mad_bit_init(&stream->ptr, ptr); - - if (mad_stream_sync(stream) == -1) { - if (end - stream->next_frame >= MAD_BUFFER_GUARD) - stream->next_frame = end - MAD_BUFFER_GUARD; - - stream->error = MAD_ERROR_BUFLEN; - goto fail; - } - - ptr = mad_bit_nextbyte(&stream->ptr); - } - - /* begin processing */ - stream->this_frame = ptr; - stream->next_frame = ptr + 1; /* possibly bogus sync word */ - - mad_bit_init(&stream->ptr, stream->this_frame); - - if (decode_header(header, stream) == -1) - goto fail; - - /* calculate frame duration */ - /* rockbox: not used - mad_timer_set(&header->duration, 0, - 32 * MAD_NSBSAMPLES(header), header->samplerate); - */ - - /* calculate free bit rate */ - if (header->bitrate == 0) { - if ((stream->freerate == 0 || !stream->sync || - (header->layer == MAD_LAYER_III && stream->freerate > 640000)) && - free_bitrate(stream, header) == -1) - goto fail; - - header->bitrate = stream->freerate; - header->flags |= MAD_FLAG_FREEFORMAT; - } - - /* calculate beginning of next frame */ - pad_slot = (header->flags & MAD_FLAG_PADDING) ? 1 : 0; - - if (header->layer == MAD_LAYER_I) - N = ((12 * header->bitrate / header->samplerate) + pad_slot) * 4; - else { - unsigned int slots_per_frame; - - slots_per_frame = (header->layer == MAD_LAYER_III && - (header->flags & MAD_FLAG_LSF_EXT)) ? 72 : 144; - - N = (slots_per_frame * header->bitrate / header->samplerate) + pad_slot; - } - - /* verify there is enough data left in buffer to decode this frame */ - if ((long)(N + MAD_BUFFER_GUARD) > end - stream->this_frame) { - stream->next_frame = stream->this_frame; - - stream->error = MAD_ERROR_BUFLEN; - goto fail; - } - - stream->next_frame = stream->this_frame + N; - - if (!stream->sync) { - /* check that a valid frame header follows this frame */ - - ptr = stream->next_frame; - if (!(ptr[0] == 0xff && (ptr[1] & 0xe0) == 0xe0)) { - ptr = stream->next_frame = stream->this_frame + 1; - goto sync; - } - - stream->sync = 1; - } - - header->flags |= MAD_FLAG_INCOMPLETE; - - return 0; - - fail: - stream->sync = 0; - - return -1; -} - -/* - * NAME: frame->decode() - * DESCRIPTION: decode a single frame from a bitstream - */ -int mad_frame_decode(struct mad_frame *frame, struct mad_stream *stream) -{ - frame->options = stream->options; - - /* header() */ - /* error_check() */ - - if (!(frame->header.flags & MAD_FLAG_INCOMPLETE) && - mad_header_decode(&frame->header, stream) == -1) - goto fail; - - /* audio_data() */ - - frame->header.flags &= ~MAD_FLAG_INCOMPLETE; - - if (decoder_table[frame->header.layer - 1](stream, frame) == -1) { - if (!MAD_RECOVERABLE(stream->error)) - stream->next_frame = stream->this_frame; - - goto fail; - } - - /* ancillary_data() */ - - if (frame->header.layer != MAD_LAYER_III) { - struct mad_bitptr next_frame; - - mad_bit_init(&next_frame, stream->next_frame); - - stream->anc_ptr = stream->ptr; - stream->anc_bitlen = mad_bit_length(&stream->ptr, &next_frame); - - mad_bit_finish(&next_frame); - } - - - - return 0; - - fail: - stream->anc_bitlen = 0; - return -1; -} - -/* - * NAME: frame->mute() - * DESCRIPTION: zero all subband values so the frame becomes silent - */ -void mad_frame_mute(struct mad_frame *frame) -{ - memset((*frame->sbsample_prev), 0, sizeof(*frame->sbsample_prev)); - memset((*frame->sbsample) , 0, sizeof(*frame->sbsample)); - memset((*frame->overlap) , 0, sizeof(*frame->overlap)); -} diff --git a/apps/codecs/libmad/frame.h b/apps/codecs/libmad/frame.h deleted file mode 100644 index b1c6e0289d..0000000000 --- a/apps/codecs/libmad/frame.h +++ /dev/null @@ -1,124 +0,0 @@ -/* - * libmad - MPEG audio decoder library - * Copyright (C) 2000-2004 Underbit Technologies, Inc. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * $Id$ - */ - -# ifndef LIBMAD_FRAME_H -# define LIBMAD_FRAME_H - -# include "fixed.h" -# include "timer.h" -# include "stream.h" - -enum mad_layer { - MAD_LAYER_I = 1, /* Layer I */ - MAD_LAYER_II = 2, /* Layer II */ - MAD_LAYER_III = 3 /* Layer III */ -}; - -enum mad_mode { - MAD_MODE_SINGLE_CHANNEL = 0, /* single channel */ - MAD_MODE_DUAL_CHANNEL = 1, /* dual channel */ - MAD_MODE_JOINT_STEREO = 2, /* joint (MS/intensity) stereo */ - MAD_MODE_STEREO = 3 /* normal LR stereo */ -}; - -enum mad_emphasis { - MAD_EMPHASIS_NONE = 0, /* no emphasis */ - MAD_EMPHASIS_50_15_US = 1, /* 50/15 microseconds emphasis */ - MAD_EMPHASIS_CCITT_J_17 = 3, /* CCITT J.17 emphasis */ - MAD_EMPHASIS_RESERVED = 2 /* unknown emphasis */ -}; - -struct mad_header { - enum mad_layer layer; /* audio layer (1, 2, or 3) */ - enum mad_mode mode; /* channel mode (see above) */ - int mode_extension; /* additional mode info */ - enum mad_emphasis emphasis; /* de-emphasis to use (see above) */ - - unsigned long bitrate; /* stream bitrate (bps) */ - unsigned int samplerate; /* sampling frequency (Hz) */ - - unsigned short crc_check; /* frame CRC accumulator */ - unsigned short crc_target; /* final target CRC checksum */ - - int flags; /* flags (see below) */ - int private_bits; /* private bits (see below) */ - -#if 0 /* rockbox: not used */ - mad_timer_t duration; /* audio playing time of frame */ -#endif -}; - -struct mad_frame { - struct mad_header header; /* MPEG audio header */ - int options; /* decoding options (from stream) */ - - mad_fixed_t (*sbsample)[2][36][32] MEM_ALIGN_ATTR; /* synthesis subband filter samples */ - mad_fixed_t (*sbsample_prev)[2][36][32] MEM_ALIGN_ATTR; /* synthesis subband filter samples - from previous frame only needed - when synthesis is on cop */ - - mad_fixed_t (*overlap)[2][32][18] MEM_ALIGN_ATTR; /* Layer III block overlap data */ -}; - -# define MAD_NCHANNELS(header) ((header)->mode ? 2 : 1) -# define MAD_NSBSAMPLES(header) \ - ((header)->layer == MAD_LAYER_I ? 12 : \ - (((header)->layer == MAD_LAYER_III && \ - ((header)->flags & MAD_FLAG_LSF_EXT)) ? 18 : 36)) - -enum { - MAD_FLAG_NPRIVATE_III = 0x0007, /* number of Layer III private bits */ - MAD_FLAG_INCOMPLETE = 0x0008, /* header but not data is decoded */ - - MAD_FLAG_PROTECTION = 0x0010, /* frame has CRC protection */ - MAD_FLAG_COPYRIGHT = 0x0020, /* frame is copyright */ - MAD_FLAG_ORIGINAL = 0x0040, /* frame is original (else copy) */ - MAD_FLAG_PADDING = 0x0080, /* frame has additional slot */ - - MAD_FLAG_I_STEREO = 0x0100, /* uses intensity joint stereo */ - MAD_FLAG_MS_STEREO = 0x0200, /* uses middle/side joint stereo */ - MAD_FLAG_FREEFORMAT = 0x0400, /* uses free format bitrate */ - - MAD_FLAG_LSF_EXT = 0x1000, /* lower sampling freq. extension */ - MAD_FLAG_MC_EXT = 0x2000, /* multichannel audio extension */ - MAD_FLAG_MPEG_2_5_EXT = 0x4000 /* MPEG 2.5 (unofficial) extension */ -}; - -enum { - MAD_PRIVATE_HEADER = 0x0100, /* header private bit */ - MAD_PRIVATE_III = 0x001f /* Layer III private bits (up to 5) */ -}; - -void mad_header_init(struct mad_header *); - -# define mad_header_finish(header) /* nothing */ - -int mad_header_decode(struct mad_header *, struct mad_stream *); - -void mad_frame_init(struct mad_frame *); -/* rockbox: not used -void mad_frame_finish(struct mad_frame *);*/ - -int mad_frame_decode(struct mad_frame *, struct mad_stream *); - -void mad_frame_mute(struct mad_frame *); - -# endif diff --git a/apps/codecs/libmad/global.h b/apps/codecs/libmad/global.h deleted file mode 100644 index 50051f45b3..0000000000 --- a/apps/codecs/libmad/global.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * libmad - MPEG audio decoder library - * Copyright (C) 2000-2004 Underbit Technologies, Inc. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * $Id$ - */ - -#include "codeclib.h" - -# ifndef LIBMAD_GLOBAL_H -# define LIBMAD_GLOBAL_H - -#include "mad_iram.h" - -#if defined(CPU_COLDFIRE) -#define FPM_COLDFIRE_EMAC -#elif defined(CPU_ARM) -#define FPM_ARM -#elif defined(CPU_MIPS) -#define FPM_MIPS -#else -#define FPM_DEFAULT -#endif - -/* conditional debugging */ - -# if defined(DEBUG) && defined(NDEBUG) -# error "cannot define both DEBUG and NDEBUG" -# endif - -# if defined(DEBUG) -# include -# endif - -/* conditional features */ - -# if defined(OPT_SPEED) && defined(OPT_ACCURACY) -# error "cannot optimize for both speed and accuracy" -# endif - -# if defined(OPT_SPEED) && !defined(OPT_SSO) -# define OPT_SSO -# endif - -# if defined(HAVE_UNISTD_H) && defined(HAVE_WAITPID) && \ - defined(HAVE_FCNTL) && defined(HAVE_PIPE) && defined(HAVE_FORK) -# define USE_ASYNC -# endif - -# if !defined(HAVE_ASSERT_H) -# if defined(NDEBUG) -# define assert(x) /* nothing */ -# else -# define assert(x) do { if (!(x)) abort(); } while (0) -# endif -# endif - -# endif diff --git a/apps/codecs/libmad/huffman.c b/apps/codecs/libmad/huffman.c deleted file mode 100644 index bec44434a7..0000000000 --- a/apps/codecs/libmad/huffman.c +++ /dev/null @@ -1,3109 +0,0 @@ -/* - * libmad - MPEG audio decoder library - * Copyright (C) 2000-2004 Underbit Technologies, Inc. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * $Id$ - */ - -# ifdef HAVE_CONFIG_H -# include "config.h" -# endif - -# include "global.h" - -# include "huffman.h" - -/* - * These are the Huffman code words for Layer III. - * The data for these tables are derived from Table B.7 of ISO/IEC 11172-3. - * - * These tables support decoding up to 4 Huffman code bits at a time. - */ - -# if defined(__GNUC__) || \ - (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901) -# define PTR(offs, bits) { .ptr = { 0, bits, offs } } -# define V(v, w, x, y, hlen) { .value = { 1, hlen, v, w, x, y } } -# else -# define PTR(offs, bits) { { 0, bits, offs } } -# if defined(WORDS_BIGENDIAN) -# define V(v, w, x, y, hlen) { { 1, hlen, (v << 11) | (w << 10) | \ - (x << 9) | (y << 8) } } -# else -# define V(v, w, x, y, hlen) { { 1, hlen, (v << 0) | (w << 1) | \ - (x << 2) | (y << 3) } } -# endif -# endif - -static -union huffquad const hufftabA[] ICONST_ATTR_MPA_HUFFMAN = { - /* 0000 */ PTR(16, 2), - /* 0001 */ PTR(20, 2), - /* 0010 */ PTR(24, 1), - /* 0011 */ PTR(26, 1), - /* 0100 */ V(0, 0, 1, 0, 4), - /* 0101 */ V(0, 0, 0, 1, 4), - /* 0110 */ V(0, 1, 0, 0, 4), - /* 0111 */ V(1, 0, 0, 0, 4), - /* 1000 */ V(0, 0, 0, 0, 1), - /* 1001 */ V(0, 0, 0, 0, 1), - /* 1010 */ V(0, 0, 0, 0, 1), - /* 1011 */ V(0, 0, 0, 0, 1), - /* 1100 */ V(0, 0, 0, 0, 1), - /* 1101 */ V(0, 0, 0, 0, 1), - /* 1110 */ V(0, 0, 0, 0, 1), - /* 1111 */ V(0, 0, 0, 0, 1), - - /* 0000 ... */ - /* 00 */ V(1, 0, 1, 1, 2), /* 16 */ - /* 01 */ V(1, 1, 1, 1, 2), - /* 10 */ V(1, 1, 0, 1, 2), - /* 11 */ V(1, 1, 1, 0, 2), - - /* 0001 ... */ - /* 00 */ V(0, 1, 1, 1, 2), /* 20 */ - /* 01 */ V(0, 1, 0, 1, 2), - /* 10 */ V(1, 0, 0, 1, 1), - /* 11 */ V(1, 0, 0, 1, 1), - - /* 0010 ... */ - /* 0 */ V(0, 1, 1, 0, 1), /* 24 */ - /* 1 */ V(0, 0, 1, 1, 1), - - /* 0011 ... */ - /* 0 */ V(1, 0, 1, 0, 1), /* 26 */ - /* 1 */ V(1, 1, 0, 0, 1) -}; - -static -union huffquad const hufftabB[] ICONST_ATTR_MPA_HUFFMAN = { - /* 0000 */ V(1, 1, 1, 1, 4), - /* 0001 */ V(1, 1, 1, 0, 4), - /* 0010 */ V(1, 1, 0, 1, 4), - /* 0011 */ V(1, 1, 0, 0, 4), - /* 0100 */ V(1, 0, 1, 1, 4), - /* 0101 */ V(1, 0, 1, 0, 4), - /* 0110 */ V(1, 0, 0, 1, 4), - /* 0111 */ V(1, 0, 0, 0, 4), - /* 1000 */ V(0, 1, 1, 1, 4), - /* 1001 */ V(0, 1, 1, 0, 4), - /* 1010 */ V(0, 1, 0, 1, 4), - /* 1011 */ V(0, 1, 0, 0, 4), - /* 1100 */ V(0, 0, 1, 1, 4), - /* 1101 */ V(0, 0, 1, 0, 4), - /* 1110 */ V(0, 0, 0, 1, 4), - /* 1111 */ V(0, 0, 0, 0, 4) -}; - -# undef V -# undef PTR - -# if defined(__GNUC__) || \ - (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901) -# define PTR(offs, bits) { .ptr = { 0, bits, offs } } -# define V(x, y, hlen) { .value = { 1, hlen, x, y } } -# else -# define PTR(offs, bits) { { 0, bits, offs } } -# if defined(WORDS_BIGENDIAN) -# define V(x, y, hlen) { { 1, hlen, (x << 8) | (y << 4) } } -# else -# define V(x, y, hlen) { { 1, hlen, (x << 0) | (y << 4) } } -# endif -# endif - -static -union huffpair const hufftab0[] ICONST_ATTR_MPA_HUFFMAN = { - /* */ V(0, 0, 0) -}; - -static -union huffpair const hufftab1[] ICONST_ATTR_MPA_HUFFMAN = { - /* 000 */ V(1, 1, 3), - /* 001 */ V(0, 1, 3), - /* 010 */ V(1, 0, 2), - /* 011 */ V(1, 0, 2), - /* 100 */ V(0, 0, 1), - /* 101 */ V(0, 0, 1), - /* 110 */ V(0, 0, 1), - /* 111 */ V(0, 0, 1) -}; - -static -union huffpair const hufftab2[] ICONST_ATTR_MPA_HUFFMAN = { - /* 000 */ PTR(8, 3), - /* 001 */ V(1, 1, 3), - /* 010 */ V(0, 1, 3), - /* 011 */ V(1, 0, 3), - /* 100 */ V(0, 0, 1), - /* 101 */ V(0, 0, 1), - /* 110 */ V(0, 0, 1), - /* 111 */ V(0, 0, 1), - - /* 000 ... */ - /* 000 */ V(2, 2, 3), /* 8 */ - /* 001 */ V(0, 2, 3), - /* 010 */ V(1, 2, 2), - /* 011 */ V(1, 2, 2), - /* 100 */ V(2, 1, 2), - /* 101 */ V(2, 1, 2), - /* 110 */ V(2, 0, 2), - /* 111 */ V(2, 0, 2) -}; - -static -union huffpair const hufftab3[] ICONST_ATTR_MPA_HUFFMAN = { - /* 000 */ PTR(8, 3), - /* 001 */ V(1, 0, 3), - /* 010 */ V(1, 1, 2), - /* 011 */ V(1, 1, 2), - /* 100 */ V(0, 1, 2), - /* 101 */ V(0, 1, 2), - /* 110 */ V(0, 0, 2), - /* 111 */ V(0, 0, 2), - - /* 000 ... */ - /* 000 */ V(2, 2, 3), /* 8 */ - /* 001 */ V(0, 2, 3), - /* 010 */ V(1, 2, 2), - /* 011 */ V(1, 2, 2), - /* 100 */ V(2, 1, 2), - /* 101 */ V(2, 1, 2), - /* 110 */ V(2, 0, 2), - /* 111 */ V(2, 0, 2) -}; - -static -union huffpair const hufftab5[] ICONST_ATTR_MPA_HUFFMAN = { - /* 000 */ PTR(8, 4), - /* 001 */ V(1, 1, 3), - /* 010 */ V(0, 1, 3), - /* 011 */ V(1, 0, 3), - /* 100 */ V(0, 0, 1), - /* 101 */ V(0, 0, 1), - /* 110 */ V(0, 0, 1), - /* 111 */ V(0, 0, 1), - - /* 000 ... */ - /* 0000 */ PTR(24, 1), /* 8 */ - /* 0001 */ V(3, 2, 4), - /* 0010 */ V(3, 1, 3), - /* 0011 */ V(3, 1, 3), - /* 0100 */ V(1, 3, 4), - /* 0101 */ V(0, 3, 4), - /* 0110 */ V(3, 0, 4), - /* 0111 */ V(2, 2, 4), - /* 1000 */ V(1, 2, 3), - /* 1001 */ V(1, 2, 3), - /* 1010 */ V(2, 1, 3), - /* 1011 */ V(2, 1, 3), - /* 1100 */ V(0, 2, 3), - /* 1101 */ V(0, 2, 3), - /* 1110 */ V(2, 0, 3), - /* 1111 */ V(2, 0, 3), - - /* 000 0000 ... */ - /* 0 */ V(3, 3, 1), /* 24 */ - /* 1 */ V(2, 3, 1) -}; - -static -union huffpair const hufftab6[] ICONST_ATTR_MPA_HUFFMAN = { - /* 0000 */ PTR(16, 3), - /* 0001 */ PTR(24, 1), - /* 0010 */ PTR(26, 1), - /* 0011 */ V(1, 2, 4), - /* 0100 */ V(2, 1, 4), - /* 0101 */ V(2, 0, 4), - /* 0110 */ V(0, 1, 3), - /* 0111 */ V(0, 1, 3), - /* 1000 */ V(1, 1, 2), - /* 1001 */ V(1, 1, 2), - /* 1010 */ V(1, 1, 2), - /* 1011 */ V(1, 1, 2), - /* 1100 */ V(1, 0, 3), - /* 1101 */ V(1, 0, 3), - /* 1110 */ V(0, 0, 3), - /* 1111 */ V(0, 0, 3), - - /* 0000 ... */ - /* 000 */ V(3, 3, 3), /* 16 */ - /* 001 */ V(0, 3, 3), - /* 010 */ V(2, 3, 2), - /* 011 */ V(2, 3, 2), - /* 100 */ V(3, 2, 2), - /* 101 */ V(3, 2, 2), - /* 110 */ V(3, 0, 2), - /* 111 */ V(3, 0, 2), - - /* 0001 ... */ - /* 0 */ V(1, 3, 1), /* 24 */ - /* 1 */ V(3, 1, 1), - - /* 0010 ... */ - /* 0 */ V(2, 2, 1), /* 26 */ - /* 1 */ V(0, 2, 1) -}; - -static -union huffpair const hufftab7[] ICONST_ATTR_MPA_HUFFMAN = { - /* 0000 */ PTR(16, 4), - /* 0001 */ PTR(32, 4), - /* 0010 */ PTR(48, 2), - /* 0011 */ V(1, 1, 4), - /* 0100 */ V(0, 1, 3), - /* 0101 */ V(0, 1, 3), - /* 0110 */ V(1, 0, 3), - /* 0111 */ V(1, 0, 3), - /* 1000 */ V(0, 0, 1), - /* 1001 */ V(0, 0, 1), - /* 1010 */ V(0, 0, 1), - /* 1011 */ V(0, 0, 1), - /* 1100 */ V(0, 0, 1), - /* 1101 */ V(0, 0, 1), - /* 1110 */ V(0, 0, 1), - /* 1111 */ V(0, 0, 1), - - /* 0000 ... */ - /* 0000 */ PTR(52, 2), /* 16 */ - /* 0001 */ PTR(56, 1), - /* 0010 */ PTR(58, 1), - /* 0011 */ V(1, 5, 4), - /* 0100 */ V(5, 1, 4), - /* 0101 */ PTR(60, 1), - /* 0110 */ V(5, 0, 4), - /* 0111 */ PTR(62, 1), - /* 1000 */ V(2, 4, 4), - /* 1001 */ V(4, 2, 4), - /* 1010 */ V(1, 4, 3), - /* 1011 */ V(1, 4, 3), - /* 1100 */ V(4, 1, 3), - /* 1101 */ V(4, 1, 3), - /* 1110 */ V(4, 0, 3), - /* 1111 */ V(4, 0, 3), - - /* 0001 ... */ - /* 0000 */ V(0, 4, 4), /* 32 */ - /* 0001 */ V(2, 3, 4), - /* 0010 */ V(3, 2, 4), - /* 0011 */ V(0, 3, 4), - /* 0100 */ V(1, 3, 3), - /* 0101 */ V(1, 3, 3), - /* 0110 */ V(3, 1, 3), - /* 0111 */ V(3, 1, 3), - /* 1000 */ V(3, 0, 3), - /* 1001 */ V(3, 0, 3), - /* 1010 */ V(2, 2, 3), - /* 1011 */ V(2, 2, 3), - /* 1100 */ V(1, 2, 2), - /* 1101 */ V(1, 2, 2), - /* 1110 */ V(1, 2, 2), - /* 1111 */ V(1, 2, 2), - - /* 0010 ... */ - /* 00 */ V(2, 1, 1), /* 48 */ - /* 01 */ V(2, 1, 1), - /* 10 */ V(0, 2, 2), - /* 11 */ V(2, 0, 2), - - /* 0000 0000 ... */ - /* 00 */ V(5, 5, 2), /* 52 */ - /* 01 */ V(4, 5, 2), - /* 10 */ V(5, 4, 2), - /* 11 */ V(5, 3, 2), - - /* 0000 0001 ... */ - /* 0 */ V(3, 5, 1), /* 56 */ - /* 1 */ V(4, 4, 1), - - /* 0000 0010 ... */ - /* 0 */ V(2, 5, 1), /* 58 */ - /* 1 */ V(5, 2, 1), - - /* 0000 0101 ... */ - /* 0 */ V(0, 5, 1), /* 60 */ - /* 1 */ V(3, 4, 1), - - /* 0000 0111 ... */ - /* 0 */ V(4, 3, 1), /* 62 */ - /* 1 */ V(3, 3, 1) -}; - -# if 0 -/* this version saves 8 entries (16 bytes) at the expense of - an extra lookup in 4 out of 36 cases */ -static -union huffpair const hufftab8[] ICONST_ATTR_MPA_HUFFMAN = { - /* 0000 */ PTR(16, 4), - /* 0001 */ PTR(32, 2), - /* 0010 */ V(1, 2, 4), - /* 0011 */ V(2, 1, 4), - /* 0100 */ V(1, 1, 2), - /* 0101 */ V(1, 1, 2), - /* 0110 */ V(1, 1, 2), - /* 0111 */ V(1, 1, 2), - /* 1000 */ V(0, 1, 3), - /* 1001 */ V(0, 1, 3), - /* 1010 */ V(1, 0, 3), - /* 1011 */ V(1, 0, 3), - /* 1100 */ V(0, 0, 2), - /* 1101 */ V(0, 0, 2), - /* 1110 */ V(0, 0, 2), - /* 1111 */ V(0, 0, 2), - - /* 0000 ... */ - /* 0000 */ PTR(36, 3), /* 16 */ - /* 0001 */ PTR(44, 2), - /* 0010 */ PTR(48, 1), - /* 0011 */ V(1, 5, 4), - /* 0100 */ V(5, 1, 4), - /* 0101 */ PTR(50, 1), - /* 0110 */ PTR(52, 1), - /* 0111 */ V(2, 4, 4), - /* 1000 */ V(4, 2, 4), - /* 1001 */ V(1, 4, 4), - /* 1010 */ V(4, 1, 3), - /* 1011 */ V(4, 1, 3), - /* 1100 */ V(0, 4, 4), - /* 1101 */ V(4, 0, 4), - /* 1110 */ V(2, 3, 4), - /* 1111 */ V(3, 2, 4), - - /* 0001 ... */ - /* 00 */ PTR(54, 2), /* 32 */ - /* 01 */ V(2, 2, 2), - /* 10 */ V(0, 2, 2), - /* 11 */ V(2, 0, 2), - - /* 0000 0000 ... */ - /* 000 */ V(5, 5, 3), /* 36 */ - /* 001 */ V(5, 4, 3), - /* 010 */ V(4, 5, 2), - /* 011 */ V(4, 5, 2), - /* 100 */ V(5, 3, 1), - /* 101 */ V(5, 3, 1), - /* 110 */ V(5, 3, 1), - /* 111 */ V(5, 3, 1), - - /* 0000 0001 ... */ - /* 00 */ V(3, 5, 2), /* 44 */ - /* 01 */ V(4, 4, 2), - /* 10 */ V(2, 5, 1), - /* 11 */ V(2, 5, 1), - - /* 0000 0010 ... */ - /* 0 */ V(5, 2, 1), /* 48 */ - /* 1 */ V(0, 5, 1), - - /* 0000 0101 ... */ - /* 0 */ V(3, 4, 1), /* 50 */ - /* 1 */ V(4, 3, 1), - - /* 0000 0110 ... */ - /* 0 */ V(5, 0, 1), /* 52 */ - /* 1 */ V(3, 3, 1), - - /* 0001 00 ... */ - /* 00 */ V(1, 3, 2), /* 54 */ - /* 01 */ V(3, 1, 2), - /* 10 */ V(0, 3, 2), - /* 11 */ V(3, 0, 2), -}; -# else -static -union huffpair const hufftab8[] ICONST_ATTR_MPA_HUFFMAN = { - /* 0000 */ PTR(16, 4), - /* 0001 */ PTR(32, 4), - /* 0010 */ V(1, 2, 4), - /* 0011 */ V(2, 1, 4), - /* 0100 */ V(1, 1, 2), - /* 0101 */ V(1, 1, 2), - /* 0110 */ V(1, 1, 2), - /* 0111 */ V(1, 1, 2), - /* 1000 */ V(0, 1, 3), - /* 1001 */ V(0, 1, 3), - /* 1010 */ V(1, 0, 3), - /* 1011 */ V(1, 0, 3), - /* 1100 */ V(0, 0, 2), - /* 1101 */ V(0, 0, 2), - /* 1110 */ V(0, 0, 2), - /* 1111 */ V(0, 0, 2), - - /* 0000 ... */ - /* 0000 */ PTR(48, 3), /* 16 */ - /* 0001 */ PTR(56, 2), - /* 0010 */ PTR(60, 1), - /* 0011 */ V(1, 5, 4), - /* 0100 */ V(5, 1, 4), - /* 0101 */ PTR(62, 1), - /* 0110 */ PTR(64, 1), - /* 0111 */ V(2, 4, 4), - /* 1000 */ V(4, 2, 4), - /* 1001 */ V(1, 4, 4), - /* 1010 */ V(4, 1, 3), - /* 1011 */ V(4, 1, 3), - /* 1100 */ V(0, 4, 4), - /* 1101 */ V(4, 0, 4), - /* 1110 */ V(2, 3, 4), - /* 1111 */ V(3, 2, 4), - - /* 0001 ... */ - /* 0000 */ V(1, 3, 4), /* 32 */ - /* 0001 */ V(3, 1, 4), - /* 0010 */ V(0, 3, 4), - /* 0011 */ V(3, 0, 4), - /* 0100 */ V(2, 2, 2), - /* 0101 */ V(2, 2, 2), - /* 0110 */ V(2, 2, 2), - /* 0111 */ V(2, 2, 2), - /* 1000 */ V(0, 2, 2), - /* 1001 */ V(0, 2, 2), - /* 1010 */ V(0, 2, 2), - /* 1011 */ V(0, 2, 2), - /* 1100 */ V(2, 0, 2), - /* 1101 */ V(2, 0, 2), - /* 1110 */ V(2, 0, 2), - /* 1111 */ V(2, 0, 2), - - /* 0000 0000 ... */ - /* 000 */ V(5, 5, 3), /* 48 */ - /* 001 */ V(5, 4, 3), - /* 010 */ V(4, 5, 2), - /* 011 */ V(4, 5, 2), - /* 100 */ V(5, 3, 1), - /* 101 */ V(5, 3, 1), - /* 110 */ V(5, 3, 1), - /* 111 */ V(5, 3, 1), - - /* 0000 0001 ... */ - /* 00 */ V(3, 5, 2), /* 56 */ - /* 01 */ V(4, 4, 2), - /* 10 */ V(2, 5, 1), - /* 11 */ V(2, 5, 1), - - /* 0000 0010 ... */ - /* 0 */ V(5, 2, 1), /* 60 */ - /* 1 */ V(0, 5, 1), - - /* 0000 0101 ... */ - /* 0 */ V(3, 4, 1), /* 62 */ - /* 1 */ V(4, 3, 1), - - /* 0000 0110 ... */ - /* 0 */ V(5, 0, 1), /* 64 */ - /* 1 */ V(3, 3, 1) -}; -# endif - -static -union huffpair const hufftab9[] ICONST_ATTR_MPA_HUFFMAN = { - /* 0000 */ PTR(16, 4), - /* 0001 */ PTR(32, 3), - /* 0010 */ PTR(40, 2), - /* 0011 */ PTR(44, 2), - /* 0100 */ PTR(48, 1), - /* 0101 */ V(1, 2, 4), - /* 0110 */ V(2, 1, 4), - /* 0111 */ V(2, 0, 4), - /* 1000 */ V(1, 1, 3), - /* 1001 */ V(1, 1, 3), - /* 1010 */ V(0, 1, 3), - /* 1011 */ V(0, 1, 3), - /* 1100 */ V(1, 0, 3), - /* 1101 */ V(1, 0, 3), - /* 1110 */ V(0, 0, 3), - /* 1111 */ V(0, 0, 3), - - /* 0000 ... */ - /* 0000 */ PTR(50, 1), /* 16 */ - /* 0001 */ V(3, 5, 4), - /* 0010 */ V(5, 3, 4), - /* 0011 */ PTR(52, 1), - /* 0100 */ V(4, 4, 4), - /* 0101 */ V(2, 5, 4), - /* 0110 */ V(5, 2, 4), - /* 0111 */ V(1, 5, 4), - /* 1000 */ V(5, 1, 3), - /* 1001 */ V(5, 1, 3), - /* 1010 */ V(3, 4, 3), - /* 1011 */ V(3, 4, 3), - /* 1100 */ V(4, 3, 3), - /* 1101 */ V(4, 3, 3), - /* 1110 */ V(5, 0, 4), - /* 1111 */ V(0, 4, 4), - - /* 0001 ... */ - /* 000 */ V(2, 4, 3), /* 32 */ - /* 001 */ V(4, 2, 3), - /* 010 */ V(3, 3, 3), - /* 011 */ V(4, 0, 3), - /* 100 */ V(1, 4, 2), - /* 101 */ V(1, 4, 2), - /* 110 */ V(4, 1, 2), - /* 111 */ V(4, 1, 2), - - /* 0010 ... */ - /* 00 */ V(2, 3, 2), /* 40 */ - /* 01 */ V(3, 2, 2), - /* 10 */ V(1, 3, 1), - /* 11 */ V(1, 3, 1), - - /* 0011 ... */ - /* 00 */ V(3, 1, 1), /* 44 */ - /* 01 */ V(3, 1, 1), - /* 10 */ V(0, 3, 2), - /* 11 */ V(3, 0, 2), - - /* 0100 ... */ - /* 0 */ V(2, 2, 1), /* 48 */ - /* 1 */ V(0, 2, 1), - - /* 0000 0000 ... */ - /* 0 */ V(5, 5, 1), /* 50 */ - /* 1 */ V(4, 5, 1), - - /* 0000 0011 ... */ - /* 0 */ V(5, 4, 1), /* 52 */ - /* 1 */ V(0, 5, 1) -}; - -static -union huffpair const hufftab10[] ICONST_ATTR_MPA_HUFFMAN = { - /* 0000 */ PTR(16, 4), - /* 0001 */ PTR(32, 4), - /* 0010 */ PTR(48, 2), - /* 0011 */ V(1, 1, 4), - /* 0100 */ V(0, 1, 3), - /* 0101 */ V(0, 1, 3), - /* 0110 */ V(1, 0, 3), - /* 0111 */ V(1, 0, 3), - /* 1000 */ V(0, 0, 1), - /* 1001 */ V(0, 0, 1), - /* 1010 */ V(0, 0, 1), - /* 1011 */ V(0, 0, 1), - /* 1100 */ V(0, 0, 1), - /* 1101 */ V(0, 0, 1), - /* 1110 */ V(0, 0, 1), - /* 1111 */ V(0, 0, 1), - - /* 0000 ... */ - /* 0000 */ PTR(52, 3), /* 16 */ - /* 0001 */ PTR(60, 2), - /* 0010 */ PTR(64, 3), - /* 0011 */ PTR(72, 1), - /* 0100 */ PTR(74, 2), - /* 0101 */ PTR(78, 2), - /* 0110 */ PTR(82, 2), - /* 0111 */ V(1, 7, 4), - /* 1000 */ V(7, 1, 4), - /* 1001 */ PTR(86, 1), - /* 1010 */ PTR(88, 2), - /* 1011 */ PTR(92, 2), - /* 1100 */ V(1, 6, 4), - /* 1101 */ V(6, 1, 4), - /* 1110 */ V(6, 0, 4), - /* 1111 */ PTR(96, 1), - - /* 0001 ... */ - /* 0000 */ PTR(98, 1), /* 32 */ - /* 0001 */ PTR(100, 1), - /* 0010 */ V(1, 4, 4), - /* 0011 */ V(4, 1, 4), - /* 0100 */ V(4, 0, 4), - /* 0101 */ V(2, 3, 4), - /* 0110 */ V(3, 2, 4), - /* 0111 */ V(0, 3, 4), - /* 1000 */ V(1, 3, 3), - /* 1001 */ V(1, 3, 3), - /* 1010 */ V(3, 1, 3), - /* 1011 */ V(3, 1, 3), - /* 1100 */ V(3, 0, 3), - /* 1101 */ V(3, 0, 3), - /* 1110 */ V(2, 2, 3), - /* 1111 */ V(2, 2, 3), - - /* 0010 ... */ - /* 00 */ V(1, 2, 2), /* 48 */ - /* 01 */ V(2, 1, 2), - /* 10 */ V(0, 2, 2), - /* 11 */ V(2, 0, 2), - - /* 0000 0000 ... */ - /* 000 */ V(7, 7, 3), /* 52 */ - /* 001 */ V(6, 7, 3), - /* 010 */ V(7, 6, 3), - /* 011 */ V(5, 7, 3), - /* 100 */ V(7, 5, 3), - /* 101 */ V(6, 6, 3), - /* 110 */ V(4, 7, 2), - /* 111 */ V(4, 7, 2), - - /* 0000 0001 ... */ - /* 00 */ V(7, 4, 2), /* 60 */ - /* 01 */ V(5, 6, 2), - /* 10 */ V(6, 5, 2), - /* 11 */ V(3, 7, 2), - - /* 0000 0010 ... */ - /* 000 */ V(7, 3, 2), /* 64 */ - /* 001 */ V(7, 3, 2), - /* 010 */ V(4, 6, 2), - /* 011 */ V(4, 6, 2), - /* 100 */ V(5, 5, 3), - /* 101 */ V(5, 4, 3), - /* 110 */ V(6, 3, 2), - /* 111 */ V(6, 3, 2), - - /* 0000 0011 ... */ - /* 0 */ V(2, 7, 1), /* 72 */ - /* 1 */ V(7, 2, 1), - - /* 0000 0100 ... */ - /* 00 */ V(6, 4, 2), /* 74 */ - /* 01 */ V(0, 7, 2), - /* 10 */ V(7, 0, 1), - /* 11 */ V(7, 0, 1), - - /* 0000 0101 ... */ - /* 00 */ V(6, 2, 1), /* 78 */ - /* 01 */ V(6, 2, 1), - /* 10 */ V(4, 5, 2), - /* 11 */ V(3, 5, 2), - - /* 0000 0110 ... */ - /* 00 */ V(0, 6, 1), /* 82 */ - /* 01 */ V(0, 6, 1), - /* 10 */ V(5, 3, 2), - /* 11 */ V(4, 4, 2), - - /* 0000 1001 ... */ - /* 0 */ V(3, 6, 1), /* 86 */ - /* 1 */ V(2, 6, 1), - - /* 0000 1010 ... */ - /* 00 */ V(2, 5, 2), /* 88 */ - /* 01 */ V(5, 2, 2), - /* 10 */ V(1, 5, 1), - /* 11 */ V(1, 5, 1), - - /* 0000 1011 ... */ - /* 00 */ V(5, 1, 1), /* 92 */ - /* 01 */ V(5, 1, 1), - /* 10 */ V(3, 4, 2), - /* 11 */ V(4, 3, 2), - - /* 0000 1111 ... */ - /* 0 */ V(0, 5, 1), /* 96 */ - /* 1 */ V(5, 0, 1), - - /* 0001 0000 ... */ - /* 0 */ V(2, 4, 1), /* 98 */ - /* 1 */ V(4, 2, 1), - - /* 0001 0001 ... */ - /* 0 */ V(3, 3, 1), /* 100 */ - /* 1 */ V(0, 4, 1) -}; - -static -union huffpair const hufftab11[] ICONST_ATTR_MPA_HUFFMAN = { - /* 0000 */ PTR(16, 4), - /* 0001 */ PTR(32, 4), - /* 0010 */ PTR(48, 4), - /* 0011 */ PTR(64, 3), - /* 0100 */ V(1, 2, 4), - /* 0101 */ PTR(72, 1), - /* 0110 */ V(1, 1, 3), - /* 0111 */ V(1, 1, 3), - /* 1000 */ V(0, 1, 3), - /* 1001 */ V(0, 1, 3), - /* 1010 */ V(1, 0, 3), - /* 1011 */ V(1, 0, 3), - /* 1100 */ V(0, 0, 2), - /* 1101 */ V(0, 0, 2), - /* 1110 */ V(0, 0, 2), - /* 1111 */ V(0, 0, 2), - - /* 0000 ... */ - /* 0000 */ PTR(74, 2), /* 16 */ - /* 0001 */ PTR(78, 3), - /* 0010 */ PTR(86, 2), - /* 0011 */ PTR(90, 1), - /* 0100 */ PTR(92, 2), - /* 0101 */ V(2, 7, 4), - /* 0110 */ V(7, 2, 4), - /* 0111 */ PTR(96, 1), - /* 1000 */ V(7, 1, 3), - /* 1001 */ V(7, 1, 3), - /* 1010 */ V(1, 7, 4), - /* 1011 */ V(7, 0, 4), - /* 1100 */ V(3, 6, 4), - /* 1101 */ V(6, 3, 4), - /* 1110 */ V(6, 0, 4), - /* 1111 */ PTR(98, 1), - - /* 0001 ... */ - /* 0000 */ PTR(100, 1), /* 32 */ - /* 0001 */ V(1, 5, 4), - /* 0010 */ V(6, 2, 3), - /* 0011 */ V(6, 2, 3), - /* 0100 */ V(2, 6, 4), - /* 0101 */ V(0, 6, 4), - /* 0110 */ V(1, 6, 3), - /* 0111 */ V(1, 6, 3), - /* 1000 */ V(6, 1, 3), - /* 1001 */ V(6, 1, 3), - /* 1010 */ V(5, 1, 4), - /* 1011 */ V(3, 4, 4), - /* 1100 */ V(5, 0, 4), - /* 1101 */ PTR(102, 1), - /* 1110 */ V(2, 4, 4), - /* 1111 */ V(4, 2, 4), - - /* 0010 ... */ - /* 0000 */ V(1, 4, 4), /* 48 */ - /* 0001 */ V(4, 1, 4), - /* 0010 */ V(0, 4, 4), - /* 0011 */ V(4, 0, 4), - /* 0100 */ V(2, 3, 3), - /* 0101 */ V(2, 3, 3), - /* 0110 */ V(3, 2, 3), - /* 0111 */ V(3, 2, 3), - /* 1000 */ V(1, 3, 2), - /* 1001 */ V(1, 3, 2), - /* 1010 */ V(1, 3, 2), - /* 1011 */ V(1, 3, 2), - /* 1100 */ V(3, 1, 2), - /* 1101 */ V(3, 1, 2), - /* 1110 */ V(3, 1, 2), - /* 1111 */ V(3, 1, 2), - - /* 0011 ... */ - /* 000 */ V(0, 3, 3), /* 64 */ - /* 001 */ V(3, 0, 3), - /* 010 */ V(2, 2, 2), - /* 011 */ V(2, 2, 2), - /* 100 */ V(2, 1, 1), - /* 101 */ V(2, 1, 1), - /* 110 */ V(2, 1, 1), - /* 111 */ V(2, 1, 1), - - /* 0101 ... */ - /* 0 */ V(0, 2, 1), /* 72 */ - /* 1 */ V(2, 0, 1), - - /* 0000 0000 ... */ - /* 00 */ V(7, 7, 2), /* 74 */ - /* 01 */ V(6, 7, 2), - /* 10 */ V(7, 6, 2), - /* 11 */ V(7, 5, 2), - - /* 0000 0001 ... */ - /* 000 */ V(6, 6, 2), /* 78 */ - /* 001 */ V(6, 6, 2), - /* 010 */ V(4, 7, 2), - /* 011 */ V(4, 7, 2), - /* 100 */ V(7, 4, 2), - /* 101 */ V(7, 4, 2), - /* 110 */ V(5, 7, 3), - /* 111 */ V(5, 5, 3), - - /* 0000 0010 ... */ - /* 00 */ V(5, 6, 2), /* 86 */ - /* 01 */ V(6, 5, 2), - /* 10 */ V(3, 7, 1), - /* 11 */ V(3, 7, 1), - - /* 0000 0011 ... */ - /* 0 */ V(7, 3, 1), /* 90 */ - /* 1 */ V(4, 6, 1), - - /* 0000 0100 ... */ - /* 00 */ V(4, 5, 2), /* 92 */ - /* 01 */ V(5, 4, 2), - /* 10 */ V(3, 5, 2), - /* 11 */ V(5, 3, 2), - - /* 0000 0111 ... */ - /* 0 */ V(6, 4, 1), /* 96 */ - /* 1 */ V(0, 7, 1), - - /* 0000 1111 ... */ - /* 0 */ V(4, 4, 1), /* 98 */ - /* 1 */ V(2, 5, 1), - - /* 0001 0000 ... */ - /* 0 */ V(5, 2, 1), /* 100 */ - /* 1 */ V(0, 5, 1), - - /* 0001 1101 ... */ - /* 0 */ V(4, 3, 1), /* 102 */ - /* 1 */ V(3, 3, 1) -}; - -static -union huffpair const hufftab12[] ICONST_ATTR_MPA_HUFFMAN = { - /* 0000 */ PTR(16, 4), - /* 0001 */ PTR(32, 4), - /* 0010 */ PTR(48, 4), - /* 0011 */ PTR(64, 2), - /* 0100 */ PTR(68, 3), - /* 0101 */ PTR(76, 1), - /* 0110 */ V(1, 2, 4), - /* 0111 */ V(2, 1, 4), - /* 1000 */ PTR(78, 1), - /* 1001 */ V(0, 0, 4), - /* 1010 */ V(1, 1, 3), - /* 1011 */ V(1, 1, 3), - /* 1100 */ V(0, 1, 3), - /* 1101 */ V(0, 1, 3), - /* 1110 */ V(1, 0, 3), - /* 1111 */ V(1, 0, 3), - - /* 0000 ... */ - /* 0000 */ PTR(80, 2), /* 16 */ - /* 0001 */ PTR(84, 1), - /* 0010 */ PTR(86, 1), - /* 0011 */ PTR(88, 1), - /* 0100 */ V(5, 6, 4), - /* 0101 */ V(3, 7, 4), - /* 0110 */ PTR(90, 1), - /* 0111 */ V(2, 7, 4), - /* 1000 */ V(7, 2, 4), - /* 1001 */ V(4, 6, 4), - /* 1010 */ V(6, 4, 4), - /* 1011 */ V(1, 7, 4), - /* 1100 */ V(7, 1, 4), - /* 1101 */ PTR(92, 1), - /* 1110 */ V(3, 6, 4), - /* 1111 */ V(6, 3, 4), - - /* 0001 ... */ - /* 0000 */ V(4, 5, 4), /* 32 */ - /* 0001 */ V(5, 4, 4), - /* 0010 */ V(4, 4, 4), - /* 0011 */ PTR(94, 1), - /* 0100 */ V(2, 6, 3), - /* 0101 */ V(2, 6, 3), - /* 0110 */ V(6, 2, 3), - /* 0111 */ V(6, 2, 3), - /* 1000 */ V(6, 1, 3), - /* 1001 */ V(6, 1, 3), - /* 1010 */ V(1, 6, 4), - /* 1011 */ V(6, 0, 4), - /* 1100 */ V(3, 5, 4), - /* 1101 */ V(5, 3, 4), - /* 1110 */ V(2, 5, 4), - /* 1111 */ V(5, 2, 4), - - /* 0010 ... */ - /* 0000 */ V(1, 5, 3), /* 48 */ - /* 0001 */ V(1, 5, 3), - /* 0010 */ V(5, 1, 3), - /* 0011 */ V(5, 1, 3), - /* 0100 */ V(3, 4, 3), - /* 0101 */ V(3, 4, 3), - /* 0110 */ V(4, 3, 3), - /* 0111 */ V(4, 3, 3), - /* 1000 */ V(5, 0, 4), - /* 1001 */ V(0, 4, 4), - /* 1010 */ V(2, 4, 3), - /* 1011 */ V(2, 4, 3), - /* 1100 */ V(4, 2, 3), - /* 1101 */ V(4, 2, 3), - /* 1110 */ V(1, 4, 3), - /* 1111 */ V(1, 4, 3), - - /* 0011 ... */ - /* 00 */ V(3, 3, 2), /* 64 */ - /* 01 */ V(4, 1, 2), - /* 10 */ V(2, 3, 2), - /* 11 */ V(3, 2, 2), - - /* 0100 ... */ - /* 000 */ V(4, 0, 3), /* 68 */ - /* 001 */ V(0, 3, 3), - /* 010 */ V(3, 0, 2), - /* 011 */ V(3, 0, 2), - /* 100 */ V(1, 3, 1), - /* 101 */ V(1, 3, 1), - /* 110 */ V(1, 3, 1), - /* 111 */ V(1, 3, 1), - - /* 0101 ... */ - /* 0 */ V(3, 1, 1), /* 76 */ - /* 1 */ V(2, 2, 1), - - /* 1000 ... */ - /* 0 */ V(0, 2, 1), /* 78 */ - /* 1 */ V(2, 0, 1), - - /* 0000 0000 ... */ - /* 00 */ V(7, 7, 2), /* 80 */ - /* 01 */ V(6, 7, 2), - /* 10 */ V(7, 6, 1), - /* 11 */ V(7, 6, 1), - - /* 0000 0001 ... */ - /* 0 */ V(5, 7, 1), /* 84 */ - /* 1 */ V(7, 5, 1), - - /* 0000 0010 ... */ - /* 0 */ V(6, 6, 1), /* 86 */ - /* 1 */ V(4, 7, 1), - - /* 0000 0011 ... */ - /* 0 */ V(7, 4, 1), /* 88 */ - /* 1 */ V(6, 5, 1), - - /* 0000 0110 ... */ - /* 0 */ V(7, 3, 1), /* 90 */ - /* 1 */ V(5, 5, 1), - - /* 0000 1101 ... */ - /* 0 */ V(0, 7, 1), /* 92 */ - /* 1 */ V(7, 0, 1), - - /* 0001 0011 ... */ - /* 0 */ V(0, 6, 1), /* 94 */ - /* 1 */ V(0, 5, 1) -}; - -static -union huffpair const hufftab13[] ICONST_ATTR_MPA_HUFFMAN = { - /* 0000 */ PTR(16, 4), - /* 0001 */ PTR(32, 4), - /* 0010 */ PTR(48, 4), - /* 0011 */ PTR(64, 2), - /* 0100 */ V(1, 1, 4), - /* 0101 */ V(0, 1, 4), - /* 0110 */ V(1, 0, 3), - /* 0111 */ V(1, 0, 3), - /* 1000 */ V(0, 0, 1), - /* 1001 */ V(0, 0, 1), - /* 1010 */ V(0, 0, 1), - /* 1011 */ V(0, 0, 1), - /* 1100 */ V(0, 0, 1), - /* 1101 */ V(0, 0, 1), - /* 1110 */ V(0, 0, 1), - /* 1111 */ V(0, 0, 1), - - /* 0000 ... */ - /* 0000 */ PTR(68, 4), /* 16 */ - /* 0001 */ PTR(84, 4), - /* 0010 */ PTR(100, 4), - /* 0011 */ PTR(116, 4), - /* 0100 */ PTR(132, 4), - /* 0101 */ PTR(148, 4), - /* 0110 */ PTR(164, 3), - /* 0111 */ PTR(172, 3), - /* 1000 */ PTR(180, 3), - /* 1001 */ PTR(188, 3), - /* 1010 */ PTR(196, 3), - /* 1011 */ PTR(204, 3), - /* 1100 */ PTR(212, 1), - /* 1101 */ PTR(214, 2), - /* 1110 */ PTR(218, 3), - /* 1111 */ PTR(226, 1), - - /* 0001 ... */ - /* 0000 */ PTR(228, 2), /* 32 */ - /* 0001 */ PTR(232, 2), - /* 0010 */ PTR(236, 2), - /* 0011 */ PTR(240, 2), - /* 0100 */ V(8, 1, 4), - /* 0101 */ PTR(244, 1), - /* 0110 */ PTR(246, 1), - /* 0111 */ PTR(248, 1), - /* 1000 */ PTR(250, 2), - /* 1001 */ PTR(254, 1), - /* 1010 */ V(1, 5, 4), - /* 1011 */ V(5, 1, 4), - /* 1100 */ PTR(256, 1), - /* 1101 */ PTR(258, 1), - /* 1110 */ PTR(260, 1), - /* 1111 */ V(1, 4, 4), - - /* 0010 ... */ - /* 0000 */ V(4, 1, 3), /* 48 */ - /* 0001 */ V(4, 1, 3), - /* 0010 */ V(0, 4, 4), - /* 0011 */ V(4, 0, 4), - /* 0100 */ V(2, 3, 4), - /* 0101 */ V(3, 2, 4), - /* 0110 */ V(1, 3, 3), - /* 0111 */ V(1, 3, 3), - /* 1000 */ V(3, 1, 3), - /* 1001 */ V(3, 1, 3), - /* 1010 */ V(0, 3, 3), - /* 1011 */ V(0, 3, 3), - /* 1100 */ V(3, 0, 3), - /* 1101 */ V(3, 0, 3), - /* 1110 */ V(2, 2, 3), - /* 1111 */ V(2, 2, 3), - - /* 0011 ... */ - /* 00 */ V(1, 2, 2), /* 64 */ - /* 01 */ V(2, 1, 2), - /* 10 */ V(0, 2, 2), - /* 11 */ V(2, 0, 2), - - /* 0000 0000 ... */ - /* 0000 */ PTR(262, 4), /* 68 */ - /* 0001 */ PTR(278, 4), - /* 0010 */ PTR(294, 4), - /* 0011 */ PTR(310, 3), - /* 0100 */ PTR(318, 2), - /* 0101 */ PTR(322, 2), - /* 0110 */ PTR(326, 3), - /* 0111 */ PTR(334, 2), - /* 1000 */ PTR(338, 1), - /* 1001 */ PTR(340, 2), - /* 1010 */ PTR(344, 2), - /* 1011 */ PTR(348, 2), - /* 1100 */ PTR(352, 2), - /* 1101 */ PTR(356, 2), - /* 1110 */ V(1, 15, 4), - /* 1111 */ V(15, 1, 4), - - /* 0000 0001 ... */ - /* 0000 */ V(15, 0, 4), /* 84 */ - /* 0001 */ PTR(360, 1), - /* 0010 */ PTR(362, 1), - /* 0011 */ PTR(364, 1), - /* 0100 */ V(14, 2, 4), - /* 0101 */ PTR(366, 1), - /* 0110 */ V(1, 14, 4), - /* 0111 */ V(14, 1, 4), - /* 1000 */ PTR(368, 1), - /* 1001 */ PTR(370, 1), - /* 1010 */ PTR(372, 1), - /* 1011 */ PTR(374, 1), - /* 1100 */ PTR(376, 1), - /* 1101 */ PTR(378, 1), - /* 1110 */ V(12, 6, 4), - /* 1111 */ V(3, 13, 4), - - /* 0000 0010 ... */ - /* 0000 */ PTR(380, 1), /* 100 */ - /* 0001 */ V(2, 13, 4), - /* 0010 */ V(13, 2, 4), - /* 0011 */ V(1, 13, 4), - /* 0100 */ V(11, 7, 4), - /* 0101 */ PTR(382, 1), - /* 0110 */ PTR(384, 1), - /* 0111 */ V(12, 3, 4), - /* 1000 */ PTR(386, 1), - /* 1001 */ V(4, 11, 4), - /* 1010 */ V(13, 1, 3), - /* 1011 */ V(13, 1, 3), - /* 1100 */ V(0, 13, 4), - /* 1101 */ V(13, 0, 4), - /* 1110 */ V(8, 10, 4), - /* 1111 */ V(10, 8, 4), - - /* 0000 0011 ... */ - /* 0000 */ V(4, 12, 4), /* 116 */ - /* 0001 */ V(12, 4, 4), - /* 0010 */ V(6, 11, 4), - /* 0011 */ V(11, 6, 4), - /* 0100 */ V(3, 12, 3), - /* 0101 */ V(3, 12, 3), - /* 0110 */ V(2, 12, 3), - /* 0111 */ V(2, 12, 3), - /* 1000 */ V(12, 2, 3), - /* 1001 */ V(12, 2, 3), - /* 1010 */ V(5, 11, 3), - /* 1011 */ V(5, 11, 3), - /* 1100 */ V(11, 5, 4), - /* 1101 */ V(8, 9, 4), - /* 1110 */ V(1, 12, 3), - /* 1111 */ V(1, 12, 3), - - /* 0000 0100 ... */ - /* 0000 */ V(12, 1, 3), /* 132 */ - /* 0001 */ V(12, 1, 3), - /* 0010 */ V(9, 8, 4), - /* 0011 */ V(0, 12, 4), - /* 0100 */ V(12, 0, 3), - /* 0101 */ V(12, 0, 3), - /* 0110 */ V(11, 4, 4), - /* 0111 */ V(6, 10, 4), - /* 1000 */ V(10, 6, 4), - /* 1001 */ V(7, 9, 4), - /* 1010 */ V(3, 11, 3), - /* 1011 */ V(3, 11, 3), - /* 1100 */ V(11, 3, 3), - /* 1101 */ V(11, 3, 3), - /* 1110 */ V(8, 8, 4), - /* 1111 */ V(5, 10, 4), - - /* 0000 0101 ... */ - /* 0000 */ V(2, 11, 3), /* 148 */ - /* 0001 */ V(2, 11, 3), - /* 0010 */ V(10, 5, 4), - /* 0011 */ V(6, 9, 4), - /* 0100 */ V(10, 4, 3), - /* 0101 */ V(10, 4, 3), - /* 0110 */ V(7, 8, 4), - /* 0111 */ V(8, 7, 4), - /* 1000 */ V(9, 4, 3), - /* 1001 */ V(9, 4, 3), - /* 1010 */ V(7, 7, 4), - /* 1011 */ V(7, 6, 4), - /* 1100 */ V(11, 2, 2), - /* 1101 */ V(11, 2, 2), - /* 1110 */ V(11, 2, 2), - /* 1111 */ V(11, 2, 2), - - /* 0000 0110 ... */ - /* 000 */ V(1, 11, 2), /* 164 */ - /* 001 */ V(1, 11, 2), - /* 010 */ V(11, 1, 2), - /* 011 */ V(11, 1, 2), - /* 100 */ V(0, 11, 3), - /* 101 */ V(11, 0, 3), - /* 110 */ V(9, 6, 3), - /* 111 */ V(4, 10, 3), - - /* 0000 0111 ... */ - /* 000 */ V(3, 10, 3), /* 172 */ - /* 001 */ V(10, 3, 3), - /* 010 */ V(5, 9, 3), - /* 011 */ V(9, 5, 3), - /* 100 */ V(2, 10, 2), - /* 101 */ V(2, 10, 2), - /* 110 */ V(10, 2, 2), - /* 111 */ V(10, 2, 2), - - /* 0000 1000 ... */ - /* 000 */ V(1, 10, 2), /* 180 */ - /* 001 */ V(1, 10, 2), - /* 010 */ V(10, 1, 2), - /* 011 */ V(10, 1, 2), - /* 100 */ V(0, 10, 3), - /* 101 */ V(6, 8, 3), - /* 110 */ V(10, 0, 2), - /* 111 */ V(10, 0, 2), - - /* 0000 1001 ... */ - /* 000 */ V(8, 6, 3), /* 188 */ - /* 001 */ V(4, 9, 3), - /* 010 */ V(9, 3, 2), - /* 011 */ V(9, 3, 2), - /* 100 */ V(3, 9, 3), - /* 101 */ V(5, 8, 3), - /* 110 */ V(8, 5, 3), - /* 111 */ V(6, 7, 3), - - /* 0000 1010 ... */ - /* 000 */ V(2, 9, 2), /* 196 */ - /* 001 */ V(2, 9, 2), - /* 010 */ V(9, 2, 2), - /* 011 */ V(9, 2, 2), - /* 100 */ V(5, 7, 3), - /* 101 */ V(7, 5, 3), - /* 110 */ V(3, 8, 2), - /* 111 */ V(3, 8, 2), - - /* 0000 1011 ... */ - /* 000 */ V(8, 3, 2), /* 204 */ - /* 001 */ V(8, 3, 2), - /* 010 */ V(6, 6, 3), - /* 011 */ V(4, 7, 3), - /* 100 */ V(7, 4, 3), - /* 101 */ V(5, 6, 3), - /* 110 */ V(6, 5, 3), - /* 111 */ V(7, 3, 3), - - /* 0000 1100 ... */ - /* 0 */ V(1, 9, 1), /* 212 */ - /* 1 */ V(9, 1, 1), - - /* 0000 1101 ... */ - /* 00 */ V(0, 9, 2), /* 214 */ - /* 01 */ V(9, 0, 2), - /* 10 */ V(4, 8, 2), - /* 11 */ V(8, 4, 2), - - /* 0000 1110 ... */ - /* 000 */ V(7, 2, 2), /* 218 */ - /* 001 */ V(7, 2, 2), - /* 010 */ V(4, 6, 3), - /* 011 */ V(6, 4, 3), - /* 100 */ V(2, 8, 1), - /* 101 */ V(2, 8, 1), - /* 110 */ V(2, 8, 1), - /* 111 */ V(2, 8, 1), - - /* 0000 1111 ... */ - /* 0 */ V(8, 2, 1), /* 226 */ - /* 1 */ V(1, 8, 1), - - /* 0001 0000 ... */ - /* 00 */ V(3, 7, 2), /* 228 */ - /* 01 */ V(2, 7, 2), - /* 10 */ V(1, 7, 1), - /* 11 */ V(1, 7, 1), - - /* 0001 0001 ... */ - /* 00 */ V(7, 1, 1), /* 232 */ - /* 01 */ V(7, 1, 1), - /* 10 */ V(5, 5, 2), - /* 11 */ V(0, 7, 2), - - /* 0001 0010 ... */ - /* 00 */ V(7, 0, 2), /* 236 */ - /* 01 */ V(3, 6, 2), - /* 10 */ V(6, 3, 2), - /* 11 */ V(4, 5, 2), - - /* 0001 0011 ... */ - /* 00 */ V(5, 4, 2), /* 240 */ - /* 01 */ V(2, 6, 2), - /* 10 */ V(6, 2, 2), - /* 11 */ V(3, 5, 2), - - /* 0001 0101 ... */ - /* 0 */ V(0, 8, 1), /* 244 */ - /* 1 */ V(8, 0, 1), - - /* 0001 0110 ... */ - /* 0 */ V(1, 6, 1), /* 246 */ - /* 1 */ V(6, 1, 1), - - /* 0001 0111 ... */ - /* 0 */ V(0, 6, 1), /* 248 */ - /* 1 */ V(6, 0, 1), - - /* 0001 1000 ... */ - /* 00 */ V(5, 3, 2), /* 250 */ - /* 01 */ V(4, 4, 2), - /* 10 */ V(2, 5, 1), - /* 11 */ V(2, 5, 1), - - /* 0001 1001 ... */ - /* 0 */ V(5, 2, 1), /* 254 */ - /* 1 */ V(0, 5, 1), - - /* 0001 1100 ... */ - /* 0 */ V(3, 4, 1), /* 256 */ - /* 1 */ V(4, 3, 1), - - /* 0001 1101 ... */ - /* 0 */ V(5, 0, 1), /* 258 */ - /* 1 */ V(2, 4, 1), - - /* 0001 1110 ... */ - /* 0 */ V(4, 2, 1), /* 260 */ - /* 1 */ V(3, 3, 1), - - /* 0000 0000 0000 ... */ - /* 0000 */ PTR(388, 3), /* 262 */ - /* 0001 */ V(15, 15, 4), - /* 0010 */ V(14, 15, 4), - /* 0011 */ V(13, 15, 4), - /* 0100 */ V(14, 14, 4), - /* 0101 */ V(12, 15, 4), - /* 0110 */ V(13, 14, 4), - /* 0111 */ V(11, 15, 4), - /* 1000 */ V(15, 11, 4), - /* 1001 */ V(12, 14, 4), - /* 1010 */ V(13, 12, 4), - /* 1011 */ PTR(396, 1), - /* 1100 */ V(14, 12, 3), - /* 1101 */ V(14, 12, 3), - /* 1110 */ V(13, 13, 3), - /* 1111 */ V(13, 13, 3), - - /* 0000 0000 0001 ... */ - /* 0000 */ V(15, 10, 4), /* 278 */ - /* 0001 */ V(12, 13, 4), - /* 0010 */ V(11, 14, 3), - /* 0011 */ V(11, 14, 3), - /* 0100 */ V(14, 11, 3), - /* 0101 */ V(14, 11, 3), - /* 0110 */ V(9, 15, 3), - /* 0111 */ V(9, 15, 3), - /* 1000 */ V(15, 9, 3), - /* 1001 */ V(15, 9, 3), - /* 1010 */ V(14, 10, 3), - /* 1011 */ V(14, 10, 3), - /* 1100 */ V(11, 13, 3), - /* 1101 */ V(11, 13, 3), - /* 1110 */ V(13, 11, 3), - /* 1111 */ V(13, 11, 3), - - /* 0000 0000 0010 ... */ - /* 0000 */ V(8, 15, 3), /* 294 */ - /* 0001 */ V(8, 15, 3), - /* 0010 */ V(15, 8, 3), - /* 0011 */ V(15, 8, 3), - /* 0100 */ V(12, 12, 3), - /* 0101 */ V(12, 12, 3), - /* 0110 */ V(10, 14, 4), - /* 0111 */ V(9, 14, 4), - /* 1000 */ V(8, 14, 3), - /* 1001 */ V(8, 14, 3), - /* 1010 */ V(7, 15, 4), - /* 1011 */ V(7, 14, 4), - /* 1100 */ V(15, 7, 2), - /* 1101 */ V(15, 7, 2), - /* 1110 */ V(15, 7, 2), - /* 1111 */ V(15, 7, 2), - - /* 0000 0000 0011 ... */ - /* 000 */ V(13, 10, 2), /* 310 */ - /* 001 */ V(13, 10, 2), - /* 010 */ V(10, 13, 3), - /* 011 */ V(11, 12, 3), - /* 100 */ V(12, 11, 3), - /* 101 */ V(15, 6, 3), - /* 110 */ V(6, 15, 2), - /* 111 */ V(6, 15, 2), - - /* 0000 0000 0100 ... */ - /* 00 */ V(14, 8, 2), /* 318 */ - /* 01 */ V(5, 15, 2), - /* 10 */ V(9, 13, 2), - /* 11 */ V(13, 9, 2), - - /* 0000 0000 0101 ... */ - /* 00 */ V(15, 5, 2), /* 322 */ - /* 01 */ V(14, 7, 2), - /* 10 */ V(10, 12, 2), - /* 11 */ V(11, 11, 2), - - /* 0000 0000 0110 ... */ - /* 000 */ V(4, 15, 2), /* 326 */ - /* 001 */ V(4, 15, 2), - /* 010 */ V(15, 4, 2), - /* 011 */ V(15, 4, 2), - /* 100 */ V(12, 10, 3), - /* 101 */ V(14, 6, 3), - /* 110 */ V(15, 3, 2), - /* 111 */ V(15, 3, 2), - - /* 0000 0000 0111 ... */ - /* 00 */ V(3, 15, 1), /* 334 */ - /* 01 */ V(3, 15, 1), - /* 10 */ V(8, 13, 2), - /* 11 */ V(13, 8, 2), - - /* 0000 0000 1000 ... */ - /* 0 */ V(2, 15, 1), /* 338 */ - /* 1 */ V(15, 2, 1), - - /* 0000 0000 1001 ... */ - /* 00 */ V(6, 14, 2), /* 340 */ - /* 01 */ V(9, 12, 2), - /* 10 */ V(0, 15, 1), - /* 11 */ V(0, 15, 1), - - /* 0000 0000 1010 ... */ - /* 00 */ V(12, 9, 2), /* 344 */ - /* 01 */ V(5, 14, 2), - /* 10 */ V(10, 11, 1), - /* 11 */ V(10, 11, 1), - - /* 0000 0000 1011 ... */ - /* 00 */ V(7, 13, 2), /* 348 */ - /* 01 */ V(13, 7, 2), - /* 10 */ V(4, 14, 1), - /* 11 */ V(4, 14, 1), - - /* 0000 0000 1100 ... */ - /* 00 */ V(12, 8, 2), /* 352 */ - /* 01 */ V(13, 6, 2), - /* 10 */ V(3, 14, 1), - /* 11 */ V(3, 14, 1), - - /* 0000 0000 1101 ... */ - /* 00 */ V(11, 9, 1), /* 356 */ - /* 01 */ V(11, 9, 1), - /* 10 */ V(9, 11, 2), - /* 11 */ V(10, 10, 2), - - /* 0000 0001 0001 ... */ - /* 0 */ V(11, 10, 1), /* 360 */ - /* 1 */ V(14, 5, 1), - - /* 0000 0001 0010 ... */ - /* 0 */ V(14, 4, 1), /* 362 */ - /* 1 */ V(8, 12, 1), - - /* 0000 0001 0011 ... */ - /* 0 */ V(6, 13, 1), /* 364 */ - /* 1 */ V(14, 3, 1), - - /* 0000 0001 0101 ... */ - /* 0 */ V(2, 14, 1), /* 366 */ - /* 1 */ V(0, 14, 1), - - /* 0000 0001 1000 ... */ - /* 0 */ V(14, 0, 1), /* 368 */ - /* 1 */ V(5, 13, 1), - - /* 0000 0001 1001 ... */ - /* 0 */ V(13, 5, 1), /* 370 */ - /* 1 */ V(7, 12, 1), - - /* 0000 0001 1010 ... */ - /* 0 */ V(12, 7, 1), /* 372 */ - /* 1 */ V(4, 13, 1), - - /* 0000 0001 1011 ... */ - /* 0 */ V(8, 11, 1), /* 374 */ - /* 1 */ V(11, 8, 1), - - /* 0000 0001 1100 ... */ - /* 0 */ V(13, 4, 1), /* 376 */ - /* 1 */ V(9, 10, 1), - - /* 0000 0001 1101 ... */ - /* 0 */ V(10, 9, 1), /* 378 */ - /* 1 */ V(6, 12, 1), - - /* 0000 0010 0000 ... */ - /* 0 */ V(13, 3, 1), /* 380 */ - /* 1 */ V(7, 11, 1), - - /* 0000 0010 0101 ... */ - /* 0 */ V(5, 12, 1), /* 382 */ - /* 1 */ V(12, 5, 1), - - /* 0000 0010 0110 ... */ - /* 0 */ V(9, 9, 1), /* 384 */ - /* 1 */ V(7, 10, 1), - - /* 0000 0010 1000 ... */ - /* 0 */ V(10, 7, 1), /* 386 */ - /* 1 */ V(9, 7, 1), - - /* 0000 0000 0000 0000 ... */ - /* 000 */ V(15, 14, 3), /* 388 */ - /* 001 */ V(15, 12, 3), - /* 010 */ V(15, 13, 2), - /* 011 */ V(15, 13, 2), - /* 100 */ V(14, 13, 1), - /* 101 */ V(14, 13, 1), - /* 110 */ V(14, 13, 1), - /* 111 */ V(14, 13, 1), - - /* 0000 0000 0000 1011 ... */ - /* 0 */ V(10, 15, 1), /* 396 */ - /* 1 */ V(14, 9, 1) -}; - -static -union huffpair const hufftab15[] ICONST_ATTR_MPA_HUFFMAN = { - /* 0000 */ PTR(16, 4), - /* 0001 */ PTR(32, 4), - /* 0010 */ PTR(48, 4), - /* 0011 */ PTR(64, 4), - /* 0100 */ PTR(80, 4), - /* 0101 */ PTR(96, 3), - /* 0110 */ PTR(104, 3), - /* 0111 */ PTR(112, 2), - /* 1000 */ PTR(116, 1), - /* 1001 */ PTR(118, 1), - /* 1010 */ V(1, 1, 3), - /* 1011 */ V(1, 1, 3), - /* 1100 */ V(0, 1, 4), - /* 1101 */ V(1, 0, 4), - /* 1110 */ V(0, 0, 3), - /* 1111 */ V(0, 0, 3), - - /* 0000 ... */ - /* 0000 */ PTR(120, 4), /* 16 */ - /* 0001 */ PTR(136, 4), - /* 0010 */ PTR(152, 4), - /* 0011 */ PTR(168, 4), - /* 0100 */ PTR(184, 4), - /* 0101 */ PTR(200, 3), - /* 0110 */ PTR(208, 3), - /* 0111 */ PTR(216, 4), - /* 1000 */ PTR(232, 3), - /* 1001 */ PTR(240, 3), - /* 1010 */ PTR(248, 3), - /* 1011 */ PTR(256, 3), - /* 1100 */ PTR(264, 2), - /* 1101 */ PTR(268, 3), - /* 1110 */ PTR(276, 3), - /* 1111 */ PTR(284, 2), - - /* 0001 ... */ - /* 0000 */ PTR(288, 2), /* 32 */ - /* 0001 */ PTR(292, 2), - /* 0010 */ PTR(296, 2), - /* 0011 */ PTR(300, 2), - /* 0100 */ PTR(304, 2), - /* 0101 */ PTR(308, 2), - /* 0110 */ PTR(312, 2), - /* 0111 */ PTR(316, 2), - /* 1000 */ PTR(320, 1), - /* 1001 */ PTR(322, 1), - /* 1010 */ PTR(324, 1), - /* 1011 */ PTR(326, 2), - /* 1100 */ PTR(330, 1), - /* 1101 */ PTR(332, 1), - /* 1110 */ PTR(334, 2), - /* 1111 */ PTR(338, 1), - - /* 0010 ... */ - /* 0000 */ PTR(340, 1), /* 48 */ - /* 0001 */ PTR(342, 1), - /* 0010 */ V(9, 1, 4), - /* 0011 */ PTR(344, 1), - /* 0100 */ PTR(346, 1), - /* 0101 */ PTR(348, 1), - /* 0110 */ PTR(350, 1), - /* 0111 */ PTR(352, 1), - /* 1000 */ V(2, 8, 4), - /* 1001 */ V(8, 2, 4), - /* 1010 */ V(1, 8, 4), - /* 1011 */ V(8, 1, 4), - /* 1100 */ PTR(354, 1), - /* 1101 */ PTR(356, 1), - /* 1110 */ PTR(358, 1), - /* 1111 */ PTR(360, 1), - - /* 0011 ... */ - /* 0000 */ V(2, 7, 4), /* 64 */ - /* 0001 */ V(7, 2, 4), - /* 0010 */ V(6, 4, 4), - /* 0011 */ V(1, 7, 4), - /* 0100 */ V(5, 5, 4), - /* 0101 */ V(7, 1, 4), - /* 0110 */ PTR(362, 1), - /* 0111 */ V(3, 6, 4), - /* 1000 */ V(6, 3, 4), - /* 1001 */ V(4, 5, 4), - /* 1010 */ V(5, 4, 4), - /* 1011 */ V(2, 6, 4), - /* 1100 */ V(6, 2, 4), - /* 1101 */ V(1, 6, 4), - /* 1110 */ PTR(364, 1), - /* 1111 */ V(3, 5, 4), - - /* 0100 ... */ - /* 0000 */ V(6, 1, 3), /* 80 */ - /* 0001 */ V(6, 1, 3), - /* 0010 */ V(5, 3, 4), - /* 0011 */ V(4, 4, 4), - /* 0100 */ V(2, 5, 3), - /* 0101 */ V(2, 5, 3), - /* 0110 */ V(5, 2, 3), - /* 0111 */ V(5, 2, 3), - /* 1000 */ V(1, 5, 3), - /* 1001 */ V(1, 5, 3), - /* 1010 */ V(5, 1, 3), - /* 1011 */ V(5, 1, 3), - /* 1100 */ V(0, 5, 4), - /* 1101 */ V(5, 0, 4), - /* 1110 */ V(3, 4, 3), - /* 1111 */ V(3, 4, 3), - - /* 0101 ... */ - /* 000 */ V(4, 3, 3), /* 96 */ - /* 001 */ V(2, 4, 3), - /* 010 */ V(4, 2, 3), - /* 011 */ V(3, 3, 3), - /* 100 */ V(4, 1, 2), - /* 101 */ V(4, 1, 2), - /* 110 */ V(1, 4, 3), - /* 111 */ V(0, 4, 3), - - /* 0110 ... */ - /* 000 */ V(2, 3, 2), /* 104 */ - /* 001 */ V(2, 3, 2), - /* 010 */ V(3, 2, 2), - /* 011 */ V(3, 2, 2), - /* 100 */ V(4, 0, 3), - /* 101 */ V(0, 3, 3), - /* 110 */ V(1, 3, 2), - /* 111 */ V(1, 3, 2), - - /* 0111 ... */ - /* 00 */ V(3, 1, 2), /* 112 */ - /* 01 */ V(3, 0, 2), - /* 10 */ V(2, 2, 1), - /* 11 */ V(2, 2, 1), - - /* 1000 ... */ - /* 0 */ V(1, 2, 1), /* 116 */ - /* 1 */ V(2, 1, 1), - - /* 1001 ... */ - /* 0 */ V(0, 2, 1), /* 118 */ - /* 1 */ V(2, 0, 1), - - /* 0000 0000 ... */ - /* 0000 */ PTR(366, 1), /* 120 */ - /* 0001 */ PTR(368, 1), - /* 0010 */ V(14, 14, 4), - /* 0011 */ PTR(370, 1), - /* 0100 */ PTR(372, 1), - /* 0101 */ PTR(374, 1), - /* 0110 */ V(15, 11, 4), - /* 0111 */ PTR(376, 1), - /* 1000 */ V(13, 13, 4), - /* 1001 */ V(10, 15, 4), - /* 1010 */ V(15, 10, 4), - /* 1011 */ V(11, 14, 4), - /* 1100 */ V(14, 11, 4), - /* 1101 */ V(12, 13, 4), - /* 1110 */ V(13, 12, 4), - /* 1111 */ V(9, 15, 4), - - /* 0000 0001 ... */ - /* 0000 */ V(15, 9, 4), /* 136 */ - /* 0001 */ V(14, 10, 4), - /* 0010 */ V(11, 13, 4), - /* 0011 */ V(13, 11, 4), - /* 0100 */ V(8, 15, 4), - /* 0101 */ V(15, 8, 4), - /* 0110 */ V(12, 12, 4), - /* 0111 */ V(9, 14, 4), - /* 1000 */ V(14, 9, 4), - /* 1001 */ V(7, 15, 4), - /* 1010 */ V(15, 7, 4), - /* 1011 */ V(10, 13, 4), - /* 1100 */ V(13, 10, 4), - /* 1101 */ V(11, 12, 4), - /* 1110 */ V(6, 15, 4), - /* 1111 */ PTR(378, 1), - - /* 0000 0010 ... */ - /* 0000 */ V(12, 11, 3), /* 152 */ - /* 0001 */ V(12, 11, 3), - /* 0010 */ V(15, 6, 3), - /* 0011 */ V(15, 6, 3), - /* 0100 */ V(8, 14, 4), - /* 0101 */ V(14, 8, 4), - /* 0110 */ V(5, 15, 4), - /* 0111 */ V(9, 13, 4), - /* 1000 */ V(15, 5, 3), - /* 1001 */ V(15, 5, 3), - /* 1010 */ V(7, 14, 3), - /* 1011 */ V(7, 14, 3), - /* 1100 */ V(14, 7, 3), - /* 1101 */ V(14, 7, 3), - /* 1110 */ V(10, 12, 3), - /* 1111 */ V(10, 12, 3), - - /* 0000 0011 ... */ - /* 0000 */ V(12, 10, 3), /* 168 */ - /* 0001 */ V(12, 10, 3), - /* 0010 */ V(11, 11, 3), - /* 0011 */ V(11, 11, 3), - /* 0100 */ V(13, 9, 4), - /* 0101 */ V(8, 13, 4), - /* 0110 */ V(4, 15, 3), - /* 0111 */ V(4, 15, 3), - /* 1000 */ V(15, 4, 3), - /* 1001 */ V(15, 4, 3), - /* 1010 */ V(3, 15, 3), - /* 1011 */ V(3, 15, 3), - /* 1100 */ V(15, 3, 3), - /* 1101 */ V(15, 3, 3), - /* 1110 */ V(13, 8, 3), - /* 1111 */ V(13, 8, 3), - - /* 0000 0100 ... */ - /* 0000 */ V(14, 6, 3), /* 184 */ - /* 0001 */ V(14, 6, 3), - /* 0010 */ V(2, 15, 3), - /* 0011 */ V(2, 15, 3), - /* 0100 */ V(15, 2, 3), - /* 0101 */ V(15, 2, 3), - /* 0110 */ V(6, 14, 4), - /* 0111 */ V(15, 0, 4), - /* 1000 */ V(1, 15, 3), - /* 1001 */ V(1, 15, 3), - /* 1010 */ V(15, 1, 3), - /* 1011 */ V(15, 1, 3), - /* 1100 */ V(9, 12, 3), - /* 1101 */ V(9, 12, 3), - /* 1110 */ V(12, 9, 3), - /* 1111 */ V(12, 9, 3), - - /* 0000 0101 ... */ - /* 000 */ V(5, 14, 3), /* 200 */ - /* 001 */ V(10, 11, 3), - /* 010 */ V(11, 10, 3), - /* 011 */ V(14, 5, 3), - /* 100 */ V(7, 13, 3), - /* 101 */ V(13, 7, 3), - /* 110 */ V(4, 14, 3), - /* 111 */ V(14, 4, 3), - - /* 0000 0110 ... */ - /* 000 */ V(8, 12, 3), /* 208 */ - /* 001 */ V(12, 8, 3), - /* 010 */ V(3, 14, 3), - /* 011 */ V(6, 13, 3), - /* 100 */ V(13, 6, 3), - /* 101 */ V(14, 3, 3), - /* 110 */ V(9, 11, 3), - /* 111 */ V(11, 9, 3), - - /* 0000 0111 ... */ - /* 0000 */ V(2, 14, 3), /* 216 */ - /* 0001 */ V(2, 14, 3), - /* 0010 */ V(10, 10, 3), - /* 0011 */ V(10, 10, 3), - /* 0100 */ V(14, 2, 3), - /* 0101 */ V(14, 2, 3), - /* 0110 */ V(1, 14, 3), - /* 0111 */ V(1, 14, 3), - /* 1000 */ V(14, 1, 3), - /* 1001 */ V(14, 1, 3), - /* 1010 */ V(0, 14, 4), - /* 1011 */ V(14, 0, 4), - /* 1100 */ V(5, 13, 3), - /* 1101 */ V(5, 13, 3), - /* 1110 */ V(13, 5, 3), - /* 1111 */ V(13, 5, 3), - - /* 0000 1000 ... */ - /* 000 */ V(7, 12, 3), /* 232 */ - /* 001 */ V(12, 7, 3), - /* 010 */ V(4, 13, 3), - /* 011 */ V(8, 11, 3), - /* 100 */ V(13, 4, 2), - /* 101 */ V(13, 4, 2), - /* 110 */ V(11, 8, 3), - /* 111 */ V(9, 10, 3), - - /* 0000 1001 ... */ - /* 000 */ V(10, 9, 3), /* 240 */ - /* 001 */ V(6, 12, 3), - /* 010 */ V(12, 6, 3), - /* 011 */ V(3, 13, 3), - /* 100 */ V(13, 3, 2), - /* 101 */ V(13, 3, 2), - /* 110 */ V(13, 2, 2), - /* 111 */ V(13, 2, 2), - - /* 0000 1010 ... */ - /* 000 */ V(2, 13, 3), /* 248 */ - /* 001 */ V(0, 13, 3), - /* 010 */ V(1, 13, 2), - /* 011 */ V(1, 13, 2), - /* 100 */ V(7, 11, 2), - /* 101 */ V(7, 11, 2), - /* 110 */ V(11, 7, 2), - /* 111 */ V(11, 7, 2), - - /* 0000 1011 ... */ - /* 000 */ V(13, 1, 2), /* 256 */ - /* 001 */ V(13, 1, 2), - /* 010 */ V(5, 12, 3), - /* 011 */ V(13, 0, 3), - /* 100 */ V(12, 5, 2), - /* 101 */ V(12, 5, 2), - /* 110 */ V(8, 10, 2), - /* 111 */ V(8, 10, 2), - - /* 0000 1100 ... */ - /* 00 */ V(10, 8, 2), /* 264 */ - /* 01 */ V(4, 12, 2), - /* 10 */ V(12, 4, 2), - /* 11 */ V(6, 11, 2), - - /* 0000 1101 ... */ - /* 000 */ V(11, 6, 2), /* 268 */ - /* 001 */ V(11, 6, 2), - /* 010 */ V(9, 9, 3), - /* 011 */ V(0, 12, 3), - /* 100 */ V(3, 12, 2), - /* 101 */ V(3, 12, 2), - /* 110 */ V(12, 3, 2), - /* 111 */ V(12, 3, 2), - - /* 0000 1110 ... */ - /* 000 */ V(7, 10, 2), /* 276 */ - /* 001 */ V(7, 10, 2), - /* 010 */ V(10, 7, 2), - /* 011 */ V(10, 7, 2), - /* 100 */ V(10, 6, 2), - /* 101 */ V(10, 6, 2), - /* 110 */ V(12, 0, 3), - /* 111 */ V(0, 11, 3), - - /* 0000 1111 ... */ - /* 00 */ V(12, 2, 1), /* 284 */ - /* 01 */ V(12, 2, 1), - /* 10 */ V(2, 12, 2), - /* 11 */ V(5, 11, 2), - - /* 0001 0000 ... */ - /* 00 */ V(11, 5, 2), /* 288 */ - /* 01 */ V(1, 12, 2), - /* 10 */ V(8, 9, 2), - /* 11 */ V(9, 8, 2), - - /* 0001 0001 ... */ - /* 00 */ V(12, 1, 2), /* 292 */ - /* 01 */ V(4, 11, 2), - /* 10 */ V(11, 4, 2), - /* 11 */ V(6, 10, 2), - - /* 0001 0010 ... */ - /* 00 */ V(3, 11, 2), /* 296 */ - /* 01 */ V(7, 9, 2), - /* 10 */ V(11, 3, 1), - /* 11 */ V(11, 3, 1), - - /* 0001 0011 ... */ - /* 00 */ V(9, 7, 2), /* 300 */ - /* 01 */ V(8, 8, 2), - /* 10 */ V(2, 11, 2), - /* 11 */ V(5, 10, 2), - - /* 0001 0100 ... */ - /* 00 */ V(11, 2, 1), /* 304 */ - /* 01 */ V(11, 2, 1), - /* 10 */ V(10, 5, 2), - /* 11 */ V(1, 11, 2), - - /* 0001 0101 ... */ - /* 00 */ V(11, 1, 1), /* 308 */ - /* 01 */ V(11, 1, 1), - /* 10 */ V(11, 0, 2), - /* 11 */ V(6, 9, 2), - - /* 0001 0110 ... */ - /* 00 */ V(9, 6, 2), /* 312 */ - /* 01 */ V(4, 10, 2), - /* 10 */ V(10, 4, 2), - /* 11 */ V(7, 8, 2), - - /* 0001 0111 ... */ - /* 00 */ V(8, 7, 2), /* 316 */ - /* 01 */ V(3, 10, 2), - /* 10 */ V(10, 3, 1), - /* 11 */ V(10, 3, 1), - - /* 0001 1000 ... */ - /* 0 */ V(5, 9, 1), /* 320 */ - /* 1 */ V(9, 5, 1), - - /* 0001 1001 ... */ - /* 0 */ V(2, 10, 1), /* 322 */ - /* 1 */ V(10, 2, 1), - - /* 0001 1010 ... */ - /* 0 */ V(1, 10, 1), /* 324 */ - /* 1 */ V(10, 1, 1), - - /* 0001 1011 ... */ - /* 00 */ V(0, 10, 2), /* 326 */ - /* 01 */ V(10, 0, 2), - /* 10 */ V(6, 8, 1), - /* 11 */ V(6, 8, 1), - - /* 0001 1100 ... */ - /* 0 */ V(8, 6, 1), /* 330 */ - /* 1 */ V(4, 9, 1), - - /* 0001 1101 ... */ - /* 0 */ V(9, 4, 1), /* 332 */ - /* 1 */ V(3, 9, 1), - - /* 0001 1110 ... */ - /* 00 */ V(9, 3, 1), /* 334 */ - /* 01 */ V(9, 3, 1), - /* 10 */ V(7, 7, 2), - /* 11 */ V(0, 9, 2), - - /* 0001 1111 ... */ - /* 0 */ V(5, 8, 1), /* 338 */ - /* 1 */ V(8, 5, 1), - - /* 0010 0000 ... */ - /* 0 */ V(2, 9, 1), /* 340 */ - /* 1 */ V(6, 7, 1), - - /* 0010 0001 ... */ - /* 0 */ V(7, 6, 1), /* 342 */ - /* 1 */ V(9, 2, 1), - - /* 0010 0011 ... */ - /* 0 */ V(1, 9, 1), /* 344 */ - /* 1 */ V(9, 0, 1), - - /* 0010 0100 ... */ - /* 0 */ V(4, 8, 1), /* 346 */ - /* 1 */ V(8, 4, 1), - - /* 0010 0101 ... */ - /* 0 */ V(5, 7, 1), /* 348 */ - /* 1 */ V(7, 5, 1), - - /* 0010 0110 ... */ - /* 0 */ V(3, 8, 1), /* 350 */ - /* 1 */ V(8, 3, 1), - - /* 0010 0111 ... */ - /* 0 */ V(6, 6, 1), /* 352 */ - /* 1 */ V(4, 7, 1), - - /* 0010 1100 ... */ - /* 0 */ V(7, 4, 1), /* 354 */ - /* 1 */ V(0, 8, 1), - - /* 0010 1101 ... */ - /* 0 */ V(8, 0, 1), /* 356 */ - /* 1 */ V(5, 6, 1), - - /* 0010 1110 ... */ - /* 0 */ V(6, 5, 1), /* 358 */ - /* 1 */ V(3, 7, 1), - - /* 0010 1111 ... */ - /* 0 */ V(7, 3, 1), /* 360 */ - /* 1 */ V(4, 6, 1), - - /* 0011 0110 ... */ - /* 0 */ V(0, 7, 1), /* 362 */ - /* 1 */ V(7, 0, 1), - - /* 0011 1110 ... */ - /* 0 */ V(0, 6, 1), /* 364 */ - /* 1 */ V(6, 0, 1), - - /* 0000 0000 0000 ... */ - /* 0 */ V(15, 15, 1), /* 366 */ - /* 1 */ V(14, 15, 1), - - /* 0000 0000 0001 ... */ - /* 0 */ V(15, 14, 1), /* 368 */ - /* 1 */ V(13, 15, 1), - - /* 0000 0000 0011 ... */ - /* 0 */ V(15, 13, 1), /* 370 */ - /* 1 */ V(12, 15, 1), - - /* 0000 0000 0100 ... */ - /* 0 */ V(15, 12, 1), /* 372 */ - /* 1 */ V(13, 14, 1), - - /* 0000 0000 0101 ... */ - /* 0 */ V(14, 13, 1), /* 374 */ - /* 1 */ V(11, 15, 1), - - /* 0000 0000 0111 ... */ - /* 0 */ V(12, 14, 1), /* 376 */ - /* 1 */ V(14, 12, 1), - - /* 0000 0001 1111 ... */ - /* 0 */ V(10, 14, 1), /* 378 */ - /* 1 */ V(0, 15, 1) -}; - -static -union huffpair const hufftab16[] ICONST_ATTR_MPA_HUFFMAN = { - /* 0000 */ PTR(16, 4), - /* 0001 */ PTR(32, 4), - /* 0010 */ PTR(48, 4), - /* 0011 */ PTR(64, 2), - /* 0100 */ V(1, 1, 4), - /* 0101 */ V(0, 1, 4), - /* 0110 */ V(1, 0, 3), - /* 0111 */ V(1, 0, 3), - /* 1000 */ V(0, 0, 1), - /* 1001 */ V(0, 0, 1), - /* 1010 */ V(0, 0, 1), - /* 1011 */ V(0, 0, 1), - /* 1100 */ V(0, 0, 1), - /* 1101 */ V(0, 0, 1), - /* 1110 */ V(0, 0, 1), - /* 1111 */ V(0, 0, 1), - - /* 0000 ... */ - /* 0000 */ PTR(68, 3), /* 16 */ - /* 0001 */ PTR(76, 3), - /* 0010 */ PTR(84, 2), - /* 0011 */ V(15, 15, 4), - /* 0100 */ PTR(88, 2), - /* 0101 */ PTR(92, 1), - /* 0110 */ PTR(94, 4), - /* 0111 */ V(15, 2, 4), - /* 1000 */ PTR(110, 1), - /* 1001 */ V(1, 15, 4), - /* 1010 */ V(15, 1, 4), - /* 1011 */ PTR(112, 4), - /* 1100 */ PTR(128, 4), - /* 1101 */ PTR(144, 4), - /* 1110 */ PTR(160, 4), - /* 1111 */ PTR(176, 4), - - /* 0001 ... */ - /* 0000 */ PTR(192, 4), /* 32 */ - /* 0001 */ PTR(208, 3), - /* 0010 */ PTR(216, 3), - /* 0011 */ PTR(224, 3), - /* 0100 */ PTR(232, 3), - /* 0101 */ PTR(240, 3), - /* 0110 */ PTR(248, 3), - /* 0111 */ PTR(256, 3), - /* 1000 */ PTR(264, 2), - /* 1001 */ PTR(268, 2), - /* 1010 */ PTR(272, 1), - /* 1011 */ PTR(274, 2), - /* 1100 */ PTR(278, 2), - /* 1101 */ PTR(282, 1), - /* 1110 */ V(5, 1, 4), - /* 1111 */ PTR(284, 1), - - /* 0010 ... */ - /* 0000 */ PTR(286, 1), /* 48 */ - /* 0001 */ PTR(288, 1), - /* 0010 */ PTR(290, 1), - /* 0011 */ V(1, 4, 4), - /* 0100 */ V(4, 1, 4), - /* 0101 */ PTR(292, 1), - /* 0110 */ V(2, 3, 4), - /* 0111 */ V(3, 2, 4), - /* 1000 */ V(1, 3, 3), - /* 1001 */ V(1, 3, 3), - /* 1010 */ V(3, 1, 3), - /* 1011 */ V(3, 1, 3), - /* 1100 */ V(0, 3, 4), - /* 1101 */ V(3, 0, 4), - /* 1110 */ V(2, 2, 3), - /* 1111 */ V(2, 2, 3), - - /* 0011 ... */ - /* 00 */ V(1, 2, 2), /* 64 */ - /* 01 */ V(2, 1, 2), - /* 10 */ V(0, 2, 2), - /* 11 */ V(2, 0, 2), - - /* 0000 0000 ... */ - /* 000 */ V(14, 15, 3), /* 68 */ - /* 001 */ V(15, 14, 3), - /* 010 */ V(13, 15, 3), - /* 011 */ V(15, 13, 3), - /* 100 */ V(12, 15, 3), - /* 101 */ V(15, 12, 3), - /* 110 */ V(11, 15, 3), - /* 111 */ V(15, 11, 3), - - /* 0000 0001 ... */ - /* 000 */ V(10, 15, 2), /* 76 */ - /* 001 */ V(10, 15, 2), - /* 010 */ V(15, 10, 3), - /* 011 */ V(9, 15, 3), - /* 100 */ V(15, 9, 3), - /* 101 */ V(15, 8, 3), - /* 110 */ V(8, 15, 2), - /* 111 */ V(8, 15, 2), - - /* 0000 0010 ... */ - /* 00 */ V(7, 15, 2), /* 84 */ - /* 01 */ V(15, 7, 2), - /* 10 */ V(6, 15, 2), - /* 11 */ V(15, 6, 2), - - /* 0000 0100 ... */ - /* 00 */ V(5, 15, 2), /* 88 */ - /* 01 */ V(15, 5, 2), - /* 10 */ V(4, 15, 1), - /* 11 */ V(4, 15, 1), - - /* 0000 0101 ... */ - /* 0 */ V(15, 4, 1), /* 92 */ - /* 1 */ V(15, 3, 1), - - /* 0000 0110 ... */ - /* 0000 */ V(15, 0, 1), /* 94 */ - /* 0001 */ V(15, 0, 1), - /* 0010 */ V(15, 0, 1), - /* 0011 */ V(15, 0, 1), - /* 0100 */ V(15, 0, 1), - /* 0101 */ V(15, 0, 1), - /* 0110 */ V(15, 0, 1), - /* 0111 */ V(15, 0, 1), - /* 1000 */ V(3, 15, 2), - /* 1001 */ V(3, 15, 2), - /* 1010 */ V(3, 15, 2), - /* 1011 */ V(3, 15, 2), - /* 1100 */ PTR(294, 4), - /* 1101 */ PTR(310, 3), - /* 1110 */ PTR(318, 3), - /* 1111 */ PTR(326, 3), - - /* 0000 1000 ... */ - /* 0 */ V(2, 15, 1), /* 110 */ - /* 1 */ V(0, 15, 1), - - /* 0000 1011 ... */ - /* 0000 */ PTR(334, 2), /* 112 */ - /* 0001 */ PTR(338, 2), - /* 0010 */ PTR(342, 2), - /* 0011 */ PTR(346, 1), - /* 0100 */ PTR(348, 2), - /* 0101 */ PTR(352, 2), - /* 0110 */ PTR(356, 1), - /* 0111 */ PTR(358, 2), - /* 1000 */ PTR(362, 2), - /* 1001 */ PTR(366, 2), - /* 1010 */ PTR(370, 2), - /* 1011 */ V(14, 3, 4), - /* 1100 */ PTR(374, 1), - /* 1101 */ PTR(376, 1), - /* 1110 */ PTR(378, 1), - /* 1111 */ PTR(380, 1), - - /* 0000 1100 ... */ - /* 0000 */ PTR(382, 1), /* 128 */ - /* 0001 */ PTR(384, 1), - /* 0010 */ PTR(386, 1), - /* 0011 */ V(0, 13, 4), - /* 0100 */ PTR(388, 1), - /* 0101 */ PTR(390, 1), - /* 0110 */ PTR(392, 1), - /* 0111 */ V(3, 12, 4), - /* 1000 */ PTR(394, 1), - /* 1001 */ V(1, 12, 4), - /* 1010 */ V(12, 0, 4), - /* 1011 */ PTR(396, 1), - /* 1100 */ V(14, 2, 3), - /* 1101 */ V(14, 2, 3), - /* 1110 */ V(2, 14, 4), - /* 1111 */ V(1, 14, 4), - - /* 0000 1101 ... */ - /* 0000 */ V(13, 3, 4), /* 144 */ - /* 0001 */ V(2, 13, 4), - /* 0010 */ V(13, 2, 4), - /* 0011 */ V(13, 1, 4), - /* 0100 */ V(3, 11, 4), - /* 0101 */ PTR(398, 1), - /* 0110 */ V(1, 13, 3), - /* 0111 */ V(1, 13, 3), - /* 1000 */ V(12, 4, 4), - /* 1001 */ V(6, 11, 4), - /* 1010 */ V(12, 3, 4), - /* 1011 */ V(10, 7, 4), - /* 1100 */ V(2, 12, 3), - /* 1101 */ V(2, 12, 3), - /* 1110 */ V(12, 2, 4), - /* 1111 */ V(11, 5, 4), - - /* 0000 1110 ... */ - /* 0000 */ V(12, 1, 4), /* 160 */ - /* 0001 */ V(0, 12, 4), - /* 0010 */ V(4, 11, 4), - /* 0011 */ V(11, 4, 4), - /* 0100 */ V(6, 10, 4), - /* 0101 */ V(10, 6, 4), - /* 0110 */ V(11, 3, 3), - /* 0111 */ V(11, 3, 3), - /* 1000 */ V(5, 10, 4), - /* 1001 */ V(10, 5, 4), - /* 1010 */ V(2, 11, 3), - /* 1011 */ V(2, 11, 3), - /* 1100 */ V(11, 2, 3), - /* 1101 */ V(11, 2, 3), - /* 1110 */ V(1, 11, 3), - /* 1111 */ V(1, 11, 3), - - /* 0000 1111 ... */ - /* 0000 */ V(11, 1, 3), /* 176 */ - /* 0001 */ V(11, 1, 3), - /* 0010 */ V(0, 11, 4), - /* 0011 */ V(11, 0, 4), - /* 0100 */ V(6, 9, 4), - /* 0101 */ V(9, 6, 4), - /* 0110 */ V(4, 10, 4), - /* 0111 */ V(10, 4, 4), - /* 1000 */ V(7, 8, 4), - /* 1001 */ V(8, 7, 4), - /* 1010 */ V(10, 3, 3), - /* 1011 */ V(10, 3, 3), - /* 1100 */ V(3, 10, 4), - /* 1101 */ V(5, 9, 4), - /* 1110 */ V(2, 10, 3), - /* 1111 */ V(2, 10, 3), - - /* 0001 0000 ... */ - /* 0000 */ V(9, 5, 4), /* 192 */ - /* 0001 */ V(6, 8, 4), - /* 0010 */ V(10, 1, 3), - /* 0011 */ V(10, 1, 3), - /* 0100 */ V(8, 6, 4), - /* 0101 */ V(7, 7, 4), - /* 0110 */ V(9, 4, 3), - /* 0111 */ V(9, 4, 3), - /* 1000 */ V(4, 9, 4), - /* 1001 */ V(5, 7, 4), - /* 1010 */ V(6, 7, 3), - /* 1011 */ V(6, 7, 3), - /* 1100 */ V(10, 2, 2), - /* 1101 */ V(10, 2, 2), - /* 1110 */ V(10, 2, 2), - /* 1111 */ V(10, 2, 2), - - /* 0001 0001 ... */ - /* 000 */ V(1, 10, 2), /* 208 */ - /* 001 */ V(1, 10, 2), - /* 010 */ V(0, 10, 3), - /* 011 */ V(10, 0, 3), - /* 100 */ V(3, 9, 3), - /* 101 */ V(9, 3, 3), - /* 110 */ V(5, 8, 3), - /* 111 */ V(8, 5, 3), - - /* 0001 0010 ... */ - /* 000 */ V(2, 9, 2), /* 216 */ - /* 001 */ V(2, 9, 2), - /* 010 */ V(9, 2, 2), - /* 011 */ V(9, 2, 2), - /* 100 */ V(7, 6, 3), - /* 101 */ V(0, 9, 3), - /* 110 */ V(1, 9, 2), - /* 111 */ V(1, 9, 2), - - /* 0001 0011 ... */ - /* 000 */ V(9, 1, 2), /* 224 */ - /* 001 */ V(9, 1, 2), - /* 010 */ V(9, 0, 3), - /* 011 */ V(4, 8, 3), - /* 100 */ V(8, 4, 3), - /* 101 */ V(7, 5, 3), - /* 110 */ V(3, 8, 3), - /* 111 */ V(8, 3, 3), - - /* 0001 0100 ... */ - /* 000 */ V(6, 6, 3), /* 232 */ - /* 001 */ V(2, 8, 3), - /* 010 */ V(8, 2, 2), - /* 011 */ V(8, 2, 2), - /* 100 */ V(4, 7, 3), - /* 101 */ V(7, 4, 3), - /* 110 */ V(1, 8, 2), - /* 111 */ V(1, 8, 2), - - /* 0001 0101 ... */ - /* 000 */ V(8, 1, 2), /* 240 */ - /* 001 */ V(8, 1, 2), - /* 010 */ V(8, 0, 2), - /* 011 */ V(8, 0, 2), - /* 100 */ V(0, 8, 3), - /* 101 */ V(5, 6, 3), - /* 110 */ V(3, 7, 2), - /* 111 */ V(3, 7, 2), - - /* 0001 0110 ... */ - /* 000 */ V(7, 3, 2), /* 248 */ - /* 001 */ V(7, 3, 2), - /* 010 */ V(6, 5, 3), - /* 011 */ V(4, 6, 3), - /* 100 */ V(2, 7, 2), - /* 101 */ V(2, 7, 2), - /* 110 */ V(7, 2, 2), - /* 111 */ V(7, 2, 2), - - /* 0001 0111 ... */ - /* 000 */ V(6, 4, 3), /* 256 */ - /* 001 */ V(5, 5, 3), - /* 010 */ V(0, 7, 2), - /* 011 */ V(0, 7, 2), - /* 100 */ V(1, 7, 1), - /* 101 */ V(1, 7, 1), - /* 110 */ V(1, 7, 1), - /* 111 */ V(1, 7, 1), - - /* 0001 1000 ... */ - /* 00 */ V(7, 1, 1), /* 264 */ - /* 01 */ V(7, 1, 1), - /* 10 */ V(7, 0, 2), - /* 11 */ V(3, 6, 2), - - /* 0001 1001 ... */ - /* 00 */ V(6, 3, 2), /* 268 */ - /* 01 */ V(4, 5, 2), - /* 10 */ V(5, 4, 2), - /* 11 */ V(2, 6, 2), - - /* 0001 1010 ... */ - /* 0 */ V(6, 2, 1), /* 272 */ - /* 1 */ V(1, 6, 1), - - /* 0001 1011 ... */ - /* 00 */ V(6, 1, 1), /* 274 */ - /* 01 */ V(6, 1, 1), - /* 10 */ V(0, 6, 2), - /* 11 */ V(6, 0, 2), - - /* 0001 1100 ... */ - /* 00 */ V(5, 3, 1), /* 278 */ - /* 01 */ V(5, 3, 1), - /* 10 */ V(3, 5, 2), - /* 11 */ V(4, 4, 2), - - /* 0001 1101 ... */ - /* 0 */ V(2, 5, 1), /* 282 */ - /* 1 */ V(5, 2, 1), - - /* 0001 1111 ... */ - /* 0 */ V(1, 5, 1), /* 284 */ - /* 1 */ V(0, 5, 1), - - /* 0010 0000 ... */ - /* 0 */ V(3, 4, 1), /* 286 */ - /* 1 */ V(4, 3, 1), - - /* 0010 0001 ... */ - /* 0 */ V(5, 0, 1), /* 288 */ - /* 1 */ V(2, 4, 1), - - /* 0010 0010 ... */ - /* 0 */ V(4, 2, 1), /* 290 */ - /* 1 */ V(3, 3, 1), - - /* 0010 0101 ... */ - /* 0 */ V(0, 4, 1), /* 292 */ - /* 1 */ V(4, 0, 1), - - /* 0000 0110 1100 ... */ - /* 0000 */ V(12, 14, 4), /* 294 */ - /* 0001 */ PTR(400, 1), - /* 0010 */ V(13, 14, 3), - /* 0011 */ V(13, 14, 3), - /* 0100 */ V(14, 9, 3), - /* 0101 */ V(14, 9, 3), - /* 0110 */ V(14, 10, 4), - /* 0111 */ V(13, 9, 4), - /* 1000 */ V(14, 14, 2), - /* 1001 */ V(14, 14, 2), - /* 1010 */ V(14, 14, 2), - /* 1011 */ V(14, 14, 2), - /* 1100 */ V(14, 13, 3), - /* 1101 */ V(14, 13, 3), - /* 1110 */ V(14, 11, 3), - /* 1111 */ V(14, 11, 3), - - /* 0000 0110 1101 ... */ - /* 000 */ V(11, 14, 2), /* 310 */ - /* 001 */ V(11, 14, 2), - /* 010 */ V(12, 13, 2), - /* 011 */ V(12, 13, 2), - /* 100 */ V(13, 12, 3), - /* 101 */ V(13, 11, 3), - /* 110 */ V(10, 14, 2), - /* 111 */ V(10, 14, 2), - - /* 0000 0110 1110 ... */ - /* 000 */ V(12, 12, 2), /* 318 */ - /* 001 */ V(12, 12, 2), - /* 010 */ V(10, 13, 3), - /* 011 */ V(13, 10, 3), - /* 100 */ V(7, 14, 3), - /* 101 */ V(10, 12, 3), - /* 110 */ V(12, 10, 2), - /* 111 */ V(12, 10, 2), - - /* 0000 0110 1111 ... */ - /* 000 */ V(12, 9, 3), /* 326 */ - /* 001 */ V(7, 13, 3), - /* 010 */ V(5, 14, 2), - /* 011 */ V(5, 14, 2), - /* 100 */ V(11, 13, 1), - /* 101 */ V(11, 13, 1), - /* 110 */ V(11, 13, 1), - /* 111 */ V(11, 13, 1), - - /* 0000 1011 0000 ... */ - /* 00 */ V(9, 14, 1), /* 334 */ - /* 01 */ V(9, 14, 1), - /* 10 */ V(11, 12, 2), - /* 11 */ V(12, 11, 2), - - /* 0000 1011 0001 ... */ - /* 00 */ V(8, 14, 2), /* 338 */ - /* 01 */ V(14, 8, 2), - /* 10 */ V(9, 13, 2), - /* 11 */ V(14, 7, 2), - - /* 0000 1011 0010 ... */ - /* 00 */ V(11, 11, 2), /* 342 */ - /* 01 */ V(8, 13, 2), - /* 10 */ V(13, 8, 2), - /* 11 */ V(6, 14, 2), - - /* 0000 1011 0011 ... */ - /* 0 */ V(14, 6, 1), /* 346 */ - /* 1 */ V(9, 12, 1), - - /* 0000 1011 0100 ... */ - /* 00 */ V(10, 11, 2), /* 348 */ - /* 01 */ V(11, 10, 2), - /* 10 */ V(14, 5, 2), - /* 11 */ V(13, 7, 2), - - /* 0000 1011 0101 ... */ - /* 00 */ V(4, 14, 1), /* 352 */ - /* 01 */ V(4, 14, 1), - /* 10 */ V(14, 4, 2), - /* 11 */ V(8, 12, 2), - - /* 0000 1011 0110 ... */ - /* 0 */ V(12, 8, 1), /* 356 */ - /* 1 */ V(3, 14, 1), - - /* 0000 1011 0111 ... */ - /* 00 */ V(6, 13, 1), /* 358 */ - /* 01 */ V(6, 13, 1), - /* 10 */ V(13, 6, 2), - /* 11 */ V(9, 11, 2), - - /* 0000 1011 1000 ... */ - /* 00 */ V(11, 9, 2), /* 362 */ - /* 01 */ V(10, 10, 2), - /* 10 */ V(14, 1, 1), - /* 11 */ V(14, 1, 1), - - /* 0000 1011 1001 ... */ - /* 00 */ V(13, 4, 1), /* 366 */ - /* 01 */ V(13, 4, 1), - /* 10 */ V(11, 8, 2), - /* 11 */ V(10, 9, 2), - - /* 0000 1011 1010 ... */ - /* 00 */ V(7, 11, 1), /* 370 */ - /* 01 */ V(7, 11, 1), - /* 10 */ V(11, 7, 2), - /* 11 */ V(13, 0, 2), - - /* 0000 1011 1100 ... */ - /* 0 */ V(0, 14, 1), /* 374 */ - /* 1 */ V(14, 0, 1), - - /* 0000 1011 1101 ... */ - /* 0 */ V(5, 13, 1), /* 376 */ - /* 1 */ V(13, 5, 1), - - /* 0000 1011 1110 ... */ - /* 0 */ V(7, 12, 1), /* 378 */ - /* 1 */ V(12, 7, 1), - - /* 0000 1011 1111 ... */ - /* 0 */ V(4, 13, 1), /* 380 */ - /* 1 */ V(8, 11, 1), - - /* 0000 1100 0000 ... */ - /* 0 */ V(9, 10, 1), /* 382 */ - /* 1 */ V(6, 12, 1), - - /* 0000 1100 0001 ... */ - /* 0 */ V(12, 6, 1), /* 384 */ - /* 1 */ V(3, 13, 1), - - /* 0000 1100 0010 ... */ - /* 0 */ V(5, 12, 1), /* 386 */ - /* 1 */ V(12, 5, 1), - - /* 0000 1100 0100 ... */ - /* 0 */ V(8, 10, 1), /* 388 */ - /* 1 */ V(10, 8, 1), - - /* 0000 1100 0101 ... */ - /* 0 */ V(9, 9, 1), /* 390 */ - /* 1 */ V(4, 12, 1), - - /* 0000 1100 0110 ... */ - /* 0 */ V(11, 6, 1), /* 392 */ - /* 1 */ V(7, 10, 1), - - /* 0000 1100 1000 ... */ - /* 0 */ V(5, 11, 1), /* 394 */ - /* 1 */ V(8, 9, 1), - - /* 0000 1100 1011 ... */ - /* 0 */ V(9, 8, 1), /* 396 */ - /* 1 */ V(7, 9, 1), - - /* 0000 1101 0101 ... */ - /* 0 */ V(9, 7, 1), /* 398 */ - /* 1 */ V(8, 8, 1), - - /* 0000 0110 1100 0001 ... */ - /* 0 */ V(14, 12, 1), /* 400 */ - /* 1 */ V(13, 13, 1) -}; - -static -union huffpair const hufftab24[] ICONST_ATTR_MPA_HUFFMAN = { - /* 0000 */ PTR(16, 4), - /* 0001 */ PTR(32, 4), - /* 0010 */ PTR(48, 4), - /* 0011 */ V(15, 15, 4), - /* 0100 */ PTR(64, 4), - /* 0101 */ PTR(80, 4), - /* 0110 */ PTR(96, 4), - /* 0111 */ PTR(112, 4), - /* 1000 */ PTR(128, 4), - /* 1001 */ PTR(144, 4), - /* 1010 */ PTR(160, 3), - /* 1011 */ PTR(168, 2), - /* 1100 */ V(1, 1, 4), - /* 1101 */ V(0, 1, 4), - /* 1110 */ V(1, 0, 4), - /* 1111 */ V(0, 0, 4), - - /* 0000 ... */ - /* 0000 */ V(14, 15, 4), /* 16 */ - /* 0001 */ V(15, 14, 4), - /* 0010 */ V(13, 15, 4), - /* 0011 */ V(15, 13, 4), - /* 0100 */ V(12, 15, 4), - /* 0101 */ V(15, 12, 4), - /* 0110 */ V(11, 15, 4), - /* 0111 */ V(15, 11, 4), - /* 1000 */ V(15, 10, 3), - /* 1001 */ V(15, 10, 3), - /* 1010 */ V(10, 15, 4), - /* 1011 */ V(9, 15, 4), - /* 1100 */ V(15, 9, 3), - /* 1101 */ V(15, 9, 3), - /* 1110 */ V(15, 8, 3), - /* 1111 */ V(15, 8, 3), - - /* 0001 ... */ - /* 0000 */ V(8, 15, 4), /* 32 */ - /* 0001 */ V(7, 15, 4), - /* 0010 */ V(15, 7, 3), - /* 0011 */ V(15, 7, 3), - /* 0100 */ V(6, 15, 3), - /* 0101 */ V(6, 15, 3), - /* 0110 */ V(15, 6, 3), - /* 0111 */ V(15, 6, 3), - /* 1000 */ V(5, 15, 3), - /* 1001 */ V(5, 15, 3), - /* 1010 */ V(15, 5, 3), - /* 1011 */ V(15, 5, 3), - /* 1100 */ V(4, 15, 3), - /* 1101 */ V(4, 15, 3), - /* 1110 */ V(15, 4, 3), - /* 1111 */ V(15, 4, 3), - - /* 0010 ... */ - /* 0000 */ V(3, 15, 3), /* 48 */ - /* 0001 */ V(3, 15, 3), - /* 0010 */ V(15, 3, 3), - /* 0011 */ V(15, 3, 3), - /* 0100 */ V(2, 15, 3), - /* 0101 */ V(2, 15, 3), - /* 0110 */ V(15, 2, 3), - /* 0111 */ V(15, 2, 3), - /* 1000 */ V(15, 1, 3), - /* 1001 */ V(15, 1, 3), - /* 1010 */ V(1, 15, 4), - /* 1011 */ V(15, 0, 4), - /* 1100 */ PTR(172, 3), - /* 1101 */ PTR(180, 3), - /* 1110 */ PTR(188, 3), - /* 1111 */ PTR(196, 3), - - /* 0100 ... */ - /* 0000 */ PTR(204, 4), /* 64 */ - /* 0001 */ PTR(220, 3), - /* 0010 */ PTR(228, 3), - /* 0011 */ PTR(236, 3), - /* 0100 */ PTR(244, 2), - /* 0101 */ PTR(248, 2), - /* 0110 */ PTR(252, 2), - /* 0111 */ PTR(256, 2), - /* 1000 */ PTR(260, 2), - /* 1001 */ PTR(264, 2), - /* 1010 */ PTR(268, 2), - /* 1011 */ PTR(272, 2), - /* 1100 */ PTR(276, 2), - /* 1101 */ PTR(280, 3), - /* 1110 */ PTR(288, 2), - /* 1111 */ PTR(292, 2), - - /* 0101 ... */ - /* 0000 */ PTR(296, 2), /* 80 */ - /* 0001 */ PTR(300, 3), - /* 0010 */ PTR(308, 2), - /* 0011 */ PTR(312, 3), - /* 0100 */ PTR(320, 1), - /* 0101 */ PTR(322, 2), - /* 0110 */ PTR(326, 2), - /* 0111 */ PTR(330, 1), - /* 1000 */ PTR(332, 2), - /* 1001 */ PTR(336, 1), - /* 1010 */ PTR(338, 1), - /* 1011 */ PTR(340, 1), - /* 1100 */ PTR(342, 1), - /* 1101 */ PTR(344, 1), - /* 1110 */ PTR(346, 1), - /* 1111 */ PTR(348, 1), - - /* 0110 ... */ - /* 0000 */ PTR(350, 1), /* 96 */ - /* 0001 */ PTR(352, 1), - /* 0010 */ PTR(354, 1), - /* 0011 */ PTR(356, 1), - /* 0100 */ PTR(358, 1), - /* 0101 */ PTR(360, 1), - /* 0110 */ PTR(362, 1), - /* 0111 */ PTR(364, 1), - /* 1000 */ PTR(366, 1), - /* 1001 */ PTR(368, 1), - /* 1010 */ PTR(370, 2), - /* 1011 */ PTR(374, 1), - /* 1100 */ PTR(376, 2), - /* 1101 */ V(7, 3, 4), - /* 1110 */ PTR(380, 1), - /* 1111 */ V(7, 2, 4), - - /* 0111 ... */ - /* 0000 */ V(4, 6, 4), /* 112 */ - /* 0001 */ V(6, 4, 4), - /* 0010 */ V(5, 5, 4), - /* 0011 */ V(7, 1, 4), - /* 0100 */ V(3, 6, 4), - /* 0101 */ V(6, 3, 4), - /* 0110 */ V(4, 5, 4), - /* 0111 */ V(5, 4, 4), - /* 1000 */ V(2, 6, 4), - /* 1001 */ V(6, 2, 4), - /* 1010 */ V(1, 6, 4), - /* 1011 */ V(6, 1, 4), - /* 1100 */ PTR(382, 1), - /* 1101 */ V(3, 5, 4), - /* 1110 */ V(5, 3, 4), - /* 1111 */ V(4, 4, 4), - - /* 1000 ... */ - /* 0000 */ V(2, 5, 4), /* 128 */ - /* 0001 */ V(5, 2, 4), - /* 0010 */ V(1, 5, 4), - /* 0011 */ PTR(384, 1), - /* 0100 */ V(5, 1, 3), - /* 0101 */ V(5, 1, 3), - /* 0110 */ V(3, 4, 4), - /* 0111 */ V(4, 3, 4), - /* 1000 */ V(2, 4, 3), - /* 1001 */ V(2, 4, 3), - /* 1010 */ V(4, 2, 3), - /* 1011 */ V(4, 2, 3), - /* 1100 */ V(3, 3, 3), - /* 1101 */ V(3, 3, 3), - /* 1110 */ V(1, 4, 3), - /* 1111 */ V(1, 4, 3), - - /* 1001 ... */ - /* 0000 */ V(4, 1, 3), /* 144 */ - /* 0001 */ V(4, 1, 3), - /* 0010 */ V(0, 4, 4), - /* 0011 */ V(4, 0, 4), - /* 0100 */ V(2, 3, 3), - /* 0101 */ V(2, 3, 3), - /* 0110 */ V(3, 2, 3), - /* 0111 */ V(3, 2, 3), - /* 1000 */ V(1, 3, 2), - /* 1001 */ V(1, 3, 2), - /* 1010 */ V(1, 3, 2), - /* 1011 */ V(1, 3, 2), - /* 1100 */ V(3, 1, 2), - /* 1101 */ V(3, 1, 2), - /* 1110 */ V(3, 1, 2), - /* 1111 */ V(3, 1, 2), - - /* 1010 ... */ - /* 000 */ V(0, 3, 3), /* 160 */ - /* 001 */ V(3, 0, 3), - /* 010 */ V(2, 2, 2), - /* 011 */ V(2, 2, 2), - /* 100 */ V(1, 2, 1), - /* 101 */ V(1, 2, 1), - /* 110 */ V(1, 2, 1), - /* 111 */ V(1, 2, 1), - - /* 1011 ... */ - /* 00 */ V(2, 1, 1), /* 168 */ - /* 01 */ V(2, 1, 1), - /* 10 */ V(0, 2, 2), - /* 11 */ V(2, 0, 2), - - /* 0010 1100 ... */ - /* 000 */ V(0, 15, 1), /* 172 */ - /* 001 */ V(0, 15, 1), - /* 010 */ V(0, 15, 1), - /* 011 */ V(0, 15, 1), - /* 100 */ V(14, 14, 3), - /* 101 */ V(13, 14, 3), - /* 110 */ V(14, 13, 3), - /* 111 */ V(12, 14, 3), - - /* 0010 1101 ... */ - /* 000 */ V(14, 12, 3), /* 180 */ - /* 001 */ V(13, 13, 3), - /* 010 */ V(11, 14, 3), - /* 011 */ V(14, 11, 3), - /* 100 */ V(12, 13, 3), - /* 101 */ V(13, 12, 3), - /* 110 */ V(10, 14, 3), - /* 111 */ V(14, 10, 3), - - /* 0010 1110 ... */ - /* 000 */ V(11, 13, 3), /* 188 */ - /* 001 */ V(13, 11, 3), - /* 010 */ V(12, 12, 3), - /* 011 */ V(9, 14, 3), - /* 100 */ V(14, 9, 3), - /* 101 */ V(10, 13, 3), - /* 110 */ V(13, 10, 3), - /* 111 */ V(11, 12, 3), - - /* 0010 1111 ... */ - /* 000 */ V(12, 11, 3), /* 196 */ - /* 001 */ V(8, 14, 3), - /* 010 */ V(14, 8, 3), - /* 011 */ V(9, 13, 3), - /* 100 */ V(13, 9, 3), - /* 101 */ V(7, 14, 3), - /* 110 */ V(14, 7, 3), - /* 111 */ V(10, 12, 3), - - /* 0100 0000 ... */ - /* 0000 */ V(12, 10, 3), /* 204 */ - /* 0001 */ V(12, 10, 3), - /* 0010 */ V(11, 11, 3), - /* 0011 */ V(11, 11, 3), - /* 0100 */ V(8, 13, 3), - /* 0101 */ V(8, 13, 3), - /* 0110 */ V(13, 8, 3), - /* 0111 */ V(13, 8, 3), - /* 1000 */ V(0, 14, 4), - /* 1001 */ V(14, 0, 4), - /* 1010 */ V(0, 13, 3), - /* 1011 */ V(0, 13, 3), - /* 1100 */ V(14, 6, 2), - /* 1101 */ V(14, 6, 2), - /* 1110 */ V(14, 6, 2), - /* 1111 */ V(14, 6, 2), - - /* 0100 0001 ... */ - /* 000 */ V(6, 14, 3), /* 220 */ - /* 001 */ V(9, 12, 3), - /* 010 */ V(12, 9, 2), - /* 011 */ V(12, 9, 2), - /* 100 */ V(5, 14, 2), - /* 101 */ V(5, 14, 2), - /* 110 */ V(11, 10, 2), - /* 111 */ V(11, 10, 2), - - /* 0100 0010 ... */ - /* 000 */ V(14, 5, 2), /* 228 */ - /* 001 */ V(14, 5, 2), - /* 010 */ V(10, 11, 3), - /* 011 */ V(7, 13, 3), - /* 100 */ V(13, 7, 2), - /* 101 */ V(13, 7, 2), - /* 110 */ V(14, 4, 2), - /* 111 */ V(14, 4, 2), - - /* 0100 0011 ... */ - /* 000 */ V(8, 12, 2), /* 236 */ - /* 001 */ V(8, 12, 2), - /* 010 */ V(12, 8, 2), - /* 011 */ V(12, 8, 2), - /* 100 */ V(4, 14, 3), - /* 101 */ V(2, 14, 3), - /* 110 */ V(3, 14, 2), - /* 111 */ V(3, 14, 2), - - /* 0100 0100 ... */ - /* 00 */ V(6, 13, 2), /* 244 */ - /* 01 */ V(13, 6, 2), - /* 10 */ V(14, 3, 2), - /* 11 */ V(9, 11, 2), - - /* 0100 0101 ... */ - /* 00 */ V(11, 9, 2), /* 248 */ - /* 01 */ V(10, 10, 2), - /* 10 */ V(14, 2, 2), - /* 11 */ V(1, 14, 2), - - /* 0100 0110 ... */ - /* 00 */ V(14, 1, 2), /* 252 */ - /* 01 */ V(5, 13, 2), - /* 10 */ V(13, 5, 2), - /* 11 */ V(7, 12, 2), - - /* 0100 0111 ... */ - /* 00 */ V(12, 7, 2), /* 256 */ - /* 01 */ V(4, 13, 2), - /* 10 */ V(8, 11, 2), - /* 11 */ V(11, 8, 2), - - /* 0100 1000 ... */ - /* 00 */ V(13, 4, 2), /* 260 */ - /* 01 */ V(9, 10, 2), - /* 10 */ V(10, 9, 2), - /* 11 */ V(6, 12, 2), - - /* 0100 1001 ... */ - /* 00 */ V(12, 6, 2), /* 264 */ - /* 01 */ V(3, 13, 2), - /* 10 */ V(13, 3, 2), - /* 11 */ V(2, 13, 2), - - /* 0100 1010 ... */ - /* 00 */ V(13, 2, 2), /* 268 */ - /* 01 */ V(1, 13, 2), - /* 10 */ V(7, 11, 2), - /* 11 */ V(11, 7, 2), - - /* 0100 1011 ... */ - /* 00 */ V(13, 1, 2), /* 272 */ - /* 01 */ V(5, 12, 2), - /* 10 */ V(12, 5, 2), - /* 11 */ V(8, 10, 2), - - /* 0100 1100 ... */ - /* 00 */ V(10, 8, 2), /* 276 */ - /* 01 */ V(9, 9, 2), - /* 10 */ V(4, 12, 2), - /* 11 */ V(12, 4, 2), - - /* 0100 1101 ... */ - /* 000 */ V(6, 11, 2), /* 280 */ - /* 001 */ V(6, 11, 2), - /* 010 */ V(11, 6, 2), - /* 011 */ V(11, 6, 2), - /* 100 */ V(13, 0, 3), - /* 101 */ V(0, 12, 3), - /* 110 */ V(3, 12, 2), - /* 111 */ V(3, 12, 2), - - /* 0100 1110 ... */ - /* 00 */ V(12, 3, 2), /* 288 */ - /* 01 */ V(7, 10, 2), - /* 10 */ V(10, 7, 2), - /* 11 */ V(2, 12, 2), - - /* 0100 1111 ... */ - /* 00 */ V(12, 2, 2), /* 292 */ - /* 01 */ V(5, 11, 2), - /* 10 */ V(11, 5, 2), - /* 11 */ V(1, 12, 2), - - /* 0101 0000 ... */ - /* 00 */ V(8, 9, 2), /* 296 */ - /* 01 */ V(9, 8, 2), - /* 10 */ V(12, 1, 2), - /* 11 */ V(4, 11, 2), - - /* 0101 0001 ... */ - /* 000 */ V(12, 0, 3), /* 300 */ - /* 001 */ V(0, 11, 3), - /* 010 */ V(3, 11, 2), - /* 011 */ V(3, 11, 2), - /* 100 */ V(11, 0, 3), - /* 101 */ V(0, 10, 3), - /* 110 */ V(1, 10, 2), - /* 111 */ V(1, 10, 2), - - /* 0101 0010 ... */ - /* 00 */ V(11, 4, 1), /* 308 */ - /* 01 */ V(11, 4, 1), - /* 10 */ V(6, 10, 2), - /* 11 */ V(10, 6, 2), - - /* 0101 0011 ... */ - /* 000 */ V(7, 9, 2), /* 312 */ - /* 001 */ V(7, 9, 2), - /* 010 */ V(9, 7, 2), - /* 011 */ V(9, 7, 2), - /* 100 */ V(10, 0, 3), - /* 101 */ V(0, 9, 3), - /* 110 */ V(9, 0, 2), - /* 111 */ V(9, 0, 2), - - /* 0101 0100 ... */ - /* 0 */ V(11, 3, 1), /* 320 */ - /* 1 */ V(8, 8, 1), - - /* 0101 0101 ... */ - /* 00 */ V(2, 11, 2), /* 322 */ - /* 01 */ V(5, 10, 2), - /* 10 */ V(11, 2, 1), - /* 11 */ V(11, 2, 1), - - /* 0101 0110 ... */ - /* 00 */ V(10, 5, 2), /* 326 */ - /* 01 */ V(1, 11, 2), - /* 10 */ V(11, 1, 2), - /* 11 */ V(6, 9, 2), - - /* 0101 0111 ... */ - /* 0 */ V(9, 6, 1), /* 330 */ - /* 1 */ V(10, 4, 1), - - /* 0101 1000 ... */ - /* 00 */ V(4, 10, 2), /* 332 */ - /* 01 */ V(7, 8, 2), - /* 10 */ V(8, 7, 1), - /* 11 */ V(8, 7, 1), - - /* 0101 1001 ... */ - /* 0 */ V(3, 10, 1), /* 336 */ - /* 1 */ V(10, 3, 1), - - /* 0101 1010 ... */ - /* 0 */ V(5, 9, 1), /* 338 */ - /* 1 */ V(9, 5, 1), - - /* 0101 1011 ... */ - /* 0 */ V(2, 10, 1), /* 340 */ - /* 1 */ V(10, 2, 1), - - /* 0101 1100 ... */ - /* 0 */ V(10, 1, 1), /* 342 */ - /* 1 */ V(6, 8, 1), - - /* 0101 1101 ... */ - /* 0 */ V(8, 6, 1), /* 344 */ - /* 1 */ V(7, 7, 1), - - /* 0101 1110 ... */ - /* 0 */ V(4, 9, 1), /* 346 */ - /* 1 */ V(9, 4, 1), - - /* 0101 1111 ... */ - /* 0 */ V(3, 9, 1), /* 348 */ - /* 1 */ V(9, 3, 1), - - /* 0110 0000 ... */ - /* 0 */ V(5, 8, 1), /* 350 */ - /* 1 */ V(8, 5, 1), - - /* 0110 0001 ... */ - /* 0 */ V(2, 9, 1), /* 352 */ - /* 1 */ V(6, 7, 1), - - /* 0110 0010 ... */ - /* 0 */ V(7, 6, 1), /* 354 */ - /* 1 */ V(9, 2, 1), - - /* 0110 0011 ... */ - /* 0 */ V(1, 9, 1), /* 356 */ - /* 1 */ V(9, 1, 1), - - /* 0110 0100 ... */ - /* 0 */ V(4, 8, 1), /* 358 */ - /* 1 */ V(8, 4, 1), - - /* 0110 0101 ... */ - /* 0 */ V(5, 7, 1), /* 360 */ - /* 1 */ V(7, 5, 1), - - /* 0110 0110 ... */ - /* 0 */ V(3, 8, 1), /* 362 */ - /* 1 */ V(8, 3, 1), - - /* 0110 0111 ... */ - /* 0 */ V(6, 6, 1), /* 364 */ - /* 1 */ V(2, 8, 1), - - /* 0110 1000 ... */ - /* 0 */ V(8, 2, 1), /* 366 */ - /* 1 */ V(1, 8, 1), - - /* 0110 1001 ... */ - /* 0 */ V(4, 7, 1), /* 368 */ - /* 1 */ V(7, 4, 1), - - /* 0110 1010 ... */ - /* 00 */ V(8, 1, 1), /* 370 */ - /* 01 */ V(8, 1, 1), - /* 10 */ V(0, 8, 2), - /* 11 */ V(8, 0, 2), - - /* 0110 1011 ... */ - /* 0 */ V(5, 6, 1), /* 374 */ - /* 1 */ V(6, 5, 1), - - /* 0110 1100 ... */ - /* 00 */ V(1, 7, 1), /* 376 */ - /* 01 */ V(1, 7, 1), - /* 10 */ V(0, 7, 2), - /* 11 */ V(7, 0, 2), - - /* 0110 1110 ... */ - /* 0 */ V(3, 7, 1), /* 380 */ - /* 1 */ V(2, 7, 1), - - /* 0111 1100 ... */ - /* 0 */ V(0, 6, 1), /* 382 */ - /* 1 */ V(6, 0, 1), - - /* 1000 0011 ... */ - /* 0 */ V(0, 5, 1), /* 384 */ - /* 1 */ V(5, 0, 1) -}; - -# undef V -# undef PTR - -/* external tables */ - -union huffquad const *const mad_huff_quad_table[2] = { hufftabA, hufftabB }; - -struct hufftable const mad_huff_pair_table[32] = { - /* 0 */ { hufftab0, 0, 0 }, - /* 1 */ { hufftab1, 0, 3 }, - /* 2 */ { hufftab2, 0, 3 }, - /* 3 */ { hufftab3, 0, 3 }, - /* 4 */ { hufftab0, 0, 0 }, /* not used */ - /* 5 */ { hufftab5, 0, 3 }, - /* 6 */ { hufftab6, 0, 4 }, - /* 7 */ { hufftab7, 0, 4 }, - /* 8 */ { hufftab8, 0, 4 }, - /* 9 */ { hufftab9, 0, 4 }, - /* 10 */ { hufftab10, 0, 4 }, - /* 11 */ { hufftab11, 0, 4 }, - /* 12 */ { hufftab12, 0, 4 }, - /* 13 */ { hufftab13, 0, 4 }, - /* 14 */ { hufftab0, 0, 0 }, /* not used */ - /* 15 */ { hufftab15, 0, 4 }, - /* 16 */ { hufftab16, 1, 4 }, - /* 17 */ { hufftab16, 2, 4 }, - /* 18 */ { hufftab16, 3, 4 }, - /* 19 */ { hufftab16, 4, 4 }, - /* 20 */ { hufftab16, 6, 4 }, - /* 21 */ { hufftab16, 8, 4 }, - /* 22 */ { hufftab16, 10, 4 }, - /* 23 */ { hufftab16, 13, 4 }, - /* 24 */ { hufftab24, 4, 4 }, - /* 25 */ { hufftab24, 5, 4 }, - /* 26 */ { hufftab24, 6, 4 }, - /* 27 */ { hufftab24, 7, 4 }, - /* 28 */ { hufftab24, 8, 4 }, - /* 29 */ { hufftab24, 9, 4 }, - /* 30 */ { hufftab24, 11, 4 }, - /* 31 */ { hufftab24, 13, 4 } -}; diff --git a/apps/codecs/libmad/huffman.h b/apps/codecs/libmad/huffman.h deleted file mode 100644 index e4c1b35d93..0000000000 --- a/apps/codecs/libmad/huffman.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - * libmad - MPEG audio decoder library - * Copyright (C) 2000-2004 Underbit Technologies, Inc. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * $Id$ - */ - -# ifndef LIBMAD_HUFFMAN_H -# define LIBMAD_HUFFMAN_H - -union huffquad { - struct { - unsigned short final : 1; - unsigned short bits : 3; - unsigned short offset : 12; - } ptr; - struct { - unsigned short final : 1; - unsigned short hlen : 3; - unsigned short v : 1; - unsigned short w : 1; - unsigned short x : 1; - unsigned short y : 1; - } value; - unsigned short final : 1; -}; - -union huffpair { - struct { - unsigned short final : 1; - unsigned short bits : 3; - unsigned short offset : 12; - } ptr; - struct { - unsigned short final : 1; - unsigned short hlen : 3; - unsigned short x : 4; - unsigned short y : 4; - } value; - unsigned short final : 1; -}; - -struct hufftable { - union huffpair const *table; - unsigned short linbits; - unsigned short startbits; -}; - -extern union huffquad const *const mad_huff_quad_table[2]; -extern struct hufftable const mad_huff_pair_table[32]; - -# endif diff --git a/apps/codecs/libmad/imdct_l_arm.S b/apps/codecs/libmad/imdct_l_arm.S deleted file mode 100644 index b511ff169d..0000000000 --- a/apps/codecs/libmad/imdct_l_arm.S +++ /dev/null @@ -1,1001 +0,0 @@ -/***************************************************************************** -* Copyright (C) 2000-2001 Andre McCurdy -* -* This program is free software. you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation@ either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY, without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program@ if not, write to the Free Software -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -***************************************************************************** -* -* Notes: -* -* -***************************************************************************** -* -* $Id$ -* -* 2001/03/24: Andre McCurdy -* - Corrected PIC unsafe loading of address of 'imdct36_long_karray' -* -* 2000/09/20: Robert Leslie -* - Added a global symbol with leading underscore per suggestion of -* Simon Burge to support linking with the a.out format. -* -* 2000/09/15: Robert Leslie -* - Fixed a small bug where flags were changed before a conditional branch. -* -* 2000/09/15: Andre McCurdy -* - Applied Nicolas Pitre's rounding optimisation in all remaining places. -* -* 2000/09/09: Nicolas Pitre -* - Optimized rounding + scaling operations. -* -* 2000/08/09: Andre McCurdy -* - Original created. -* -****************************************************************************/ - -#include "config.h" - -/* - On entry: - - r0 = pointer to 18 element input array - r1 = pointer to 36 element output array - r2 = windowing block type - - - Stack frame created during execution of the function: - - Initial Holds: - Stack - pointer - minus: - - 0 - 4 lr - 8 r11 - 12 r10 - 16 r9 - 20 r8 - 24 r7 - 28 r6 - 32 r5 - 36 r4 - - 40 r2 : windowing block type - - 44 ct00 high - 48 ct00 low - 52 ct01 high - 56 ct01 low - 60 ct04 high - 64 ct04 low - 68 ct06 high - 72 ct06 low - 76 ct05 high - 80 ct05 low - 84 ct03 high - 88 ct03 low - 92 -ct05 high - 96 -ct05 low - 100 -ct07 high - 104 -ct07 low - 108 ct07 high - 112 ct07 low - 116 ct02 high - 120 ct02 low -*/ - -#define BLOCK_MODE_NORMAL 0 -#define BLOCK_MODE_START 1 -#define BLOCK_MODE_STOP 3 - - -#define X0 0x00 -#define X1 0x04 -#define X2 0x08 -#define X3 0x0C -#define X4 0x10 -#define X5 0x14 -#define X6 0x18 -#define X7 0x1c -#define X8 0x20 -#define X9 0x24 -#define X10 0x28 -#define X11 0x2c -#define X12 0x30 -#define X13 0x34 -#define X14 0x38 -#define X15 0x3c -#define X16 0x40 -#define X17 0x44 - -#define x0 0x00 -#define x1 0x04 -#define x2 0x08 -#define x3 0x0C -#define x4 0x10 -#define x5 0x14 -#define x6 0x18 -#define x7 0x1c -#define x8 0x20 -#define x9 0x24 -#define x10 0x28 -#define x11 0x2c -#define x12 0x30 -#define x13 0x34 -#define x14 0x38 -#define x15 0x3c -#define x16 0x40 -#define x17 0x44 -#define x18 0x48 -#define x19 0x4c -#define x20 0x50 -#define x21 0x54 -#define x22 0x58 -#define x23 0x5c -#define x24 0x60 -#define x25 0x64 -#define x26 0x68 -#define x27 0x6c -#define x28 0x70 -#define x29 0x74 -#define x30 0x78 -#define x31 0x7c -#define x32 0x80 -#define x33 0x84 -#define x34 0x88 -#define x35 0x8c - -#define K00 0x0ffc19fd -#define K01 0x00b2aa3e -#define K02 0x0fdcf549 -#define K03 0x0216a2a2 -#define K04 0x0f9ee890 -#define K05 0x03768962 -#define K06 0x0f426cb5 -#define K07 0x04cfb0e2 -#define K08 0x0ec835e8 -#define K09 0x061f78aa -#define K10 0x0e313245 -#define K11 0x07635284 -#define K12 0x0d7e8807 -#define K13 0x0898c779 -#define K14 0x0cb19346 -#define K15 0x09bd7ca0 -#define K16 0x0bcbe352 -#define K17 0x0acf37ad - -#define minus_K02 0xf0230ab7 - -#define WL0 0x00b2aa3e -#define WL1 0x0216a2a2 -#define WL2 0x03768962 -#define WL3 0x04cfb0e2 -#define WL4 0x061f78aa -#define WL5 0x07635284 -#define WL6 0x0898c779 -#define WL7 0x09bd7ca0 -#define WL8 0x0acf37ad -#define WL9 0x0bcbe352 -#define WL10 0x0cb19346 -#define WL11 0x0d7e8807 -#define WL12 0x0e313245 -#define WL13 0x0ec835e8 -#define WL14 0x0f426cb5 -#define WL15 0x0f9ee890 -#define WL16 0x0fdcf549 -#define WL17 0x0ffc19fd - - -@***************************************************************************** - - - .text - .align - - .global III_imdct_l - .global _III_imdct_l - -III_imdct_l: -_III_imdct_l: - - stmdb sp!, { r2, r4 - r11, lr } @ all callee saved regs, plus arg3 - - ldr r4, =K08 @ r4 = K08 - ldr r5, =K09 @ r5 = K09 - ldr r8, [r0, #X4] @ r8 = X4 - ldr r9, [r0, #X13] @ r9 = X13 - rsb r6, r4, #0 @ r6 = -K08 - rsb r7, r5, #0 @ r7 = -K09 - - smull r2, r3, r4, r8 @ r2..r3 = (X4 * K08) - smlal r2, r3, r5, r9 @ r2..r3 = (X4 * K08) + (X13 * K09) = ct01 - - smull r10, lr, r8, r5 @ r10..lr = (X4 * K09) - smlal r10, lr, r9, r6 @ r10..lr = (X4 * K09) + (X13 * -K08) = ct00 - - ldr r8, [r0, #X7] @ r8 = X7 - ldr r9, [r0, #X16] @ r9 = X16 - - stmdb sp!, { r2, r3, r10, lr } @ stack ct00_h, ct00_l, ct01_h, ct01_l - - add r8, r8, r9 @ r8 = (X7 + X16) - ldr r9, [r0, #X1] @ r9 = X1 - - smlal r2, r3, r6, r8 @ r2..r3 = ct01 + ((X7 + X16) * -K08) - smlal r2, r3, r7, r9 @ r2..r3 += (X1 * -K09) - - ldr r7, [r0, #X10] @ r7 = X10 - - rsbs r10, r10, #0 - rsc lr, lr, #0 @ r10..lr = -ct00 - - smlal r2, r3, r5, r7 @ r2..r3 += (X10 * K09) = ct06 - - smlal r10, lr, r9, r6 @ r10..lr = -ct00 + ( X1 * -K08) - smlal r10, lr, r8, r5 @ r10..lr += ((X7 + X16) * K09) - smlal r10, lr, r7, r4 @ r10..lr += ( X10 * K08) = ct04 - - stmdb sp!, { r2, r3, r10, lr } @ stack ct04_h, ct04_l, ct06_h, ct06_l - - @---- - - ldr r7, [r0, #X0] - ldr r8, [r0, #X11] - ldr r9, [r0, #X12] - sub r7, r7, r8 - sub r7, r7, r9 @ r7 = (X0 - X11 -X12) = ct14 - - ldr r9, [r0, #X3] - ldr r8, [r0, #X8] - ldr r11, [r0, #X15] - sub r8, r8, r9 - add r8, r8, r11 @ r8 = (X8 - X3 + X15) = ct16 - - add r11, r7, r8 @ r11 = ct14 + ct16 = ct18 - - smlal r2, r3, r6, r11 @ r2..r3 = ct06 + ((X0 - X11 - X3 + X15 + X8 - X12) * -K08) - - ldr r6, [r0, #X2] - ldr r9, [r0, #X9] - ldr r12, [r0, #X14] - sub r6, r6, r9 - sub r6, r6, r12 @ r6 = (X2 - X9 - X14) = ct15 - - ldr r9, [r0, #X5] - ldr r12, [r0, #X6] - sub r9, r9, r12 - ldr r12, [r0, #X17] - sub r9, r9, r12 @ r9 = (X5 - X6 - X17) = ct17 - - add r12, r9, r6 @ r12 = ct15 + ct17 = ct19 - - smlal r2, r3, r5, r12 @ r2..r3 += ((X2 - X9 + X5 - X6 - X17 - X14) * K09) - - smlal r10, lr, r11, r5 @ r10..lr = ct04 + (ct18 * K09) - smlal r10, lr, r12, r4 @ r10..lr = ct04 + (ct18 * K09) + (ct19 * K08) - - movs r2, r2, lsr #28 - adc r2, r2, r3, lsl #4 @ r2 = bits[59..28] of r2..r3 - str r2, [r1, #x22] @ store result x22 - - movs r10, r10, lsr #28 - adc r10, r10, lr, lsl #4 @ r10 = bits[59..28] of r10..lr - str r10, [r1, #x4] @ store result x4 - - @---- - - ldmia sp, { r2, r3, r4, r5 } @ r2..r3 = ct06, r4..r5 = ct04 (dont update sp) - - @ r2..r3 = ct06 - @ r4..r5 = ct04 - @ r6 = ct15 - @ r7 = ct14 - @ r8 = ct16 - @ r9 = ct17 - @ r10 = . - @ r11 = . - @ r12 = . - @ lr = . - - ldr r10, =K03 @ r10 = K03 - ldr lr, =K15 @ lr = K15 - - smlal r2, r3, r10, r7 @ r2..r3 = ct06 + (ct14 * K03) - smlal r4, r5, lr, r7 @ r4..r5 = ct04 + (ct14 * K15) - - ldr r12, =K14 @ r12 = K14 - rsb r10, r10, #0 @ r10 = -K03 - - smlal r2, r3, lr, r6 @ r2..r3 += (ct15 * K15) - smlal r4, r5, r10, r6 @ r4..r5 += (ct15 * -K03) - smlal r2, r3, r12, r8 @ r2..r3 += (ct16 * K14) - - ldr r11, =minus_K02 @ r11 = -K02 - rsb r12, r12, #0 @ r12 = -K14 - - smlal r4, r5, r12, r9 @ r4..r5 += (ct17 * -K14) - smlal r2, r3, r11, r9 @ r2..r3 += (ct17 * -K02) - smlal r4, r5, r11, r8 @ r4..r5 += (ct16 * -K02) - - movs r2, r2, lsr #28 - adc r2, r2, r3, lsl #4 @ r2 = bits[59..28] of r2..r3 - str r2, [r1, #x7] @ store result x7 - - movs r4, r4, lsr #28 - adc r4, r4, r5, lsl #4 @ r4 = bits[59..28] of r4..r5 - str r4, [r1, #x1] @ store result x1 - - @---- - - ldmia sp, { r2, r3, r4, r5 } @ r2..r3 = ct06, r4..r5 = ct04 (dont update sp) - - @ r2..r3 = ct06 - @ r4..r5 = ct04 - @ r6 = ct15 - @ r7 = ct14 - @ r8 = ct16 - @ r9 = ct17 - @ r10 = -K03 - @ r11 = -K02 - @ r12 = -K14 - @ lr = K15 - - rsbs r2, r2, #0 - rsc r3, r3, #0 @ r2..r3 = -ct06 - - smlal r2, r3, r12, r7 @ r2..r3 = -ct06 + (ct14 * -K14) - smlal r2, r3, r10, r8 @ r2..r3 += (ct16 * -K03) - - smlal r4, r5, r12, r6 @ r4..r5 = ct04 + (ct15 * -K14) - smlal r4, r5, r10, r9 @ r4..r5 += (ct17 * -K03) - smlal r4, r5, lr, r8 @ r4..r5 += (ct16 * K15) - smlal r4, r5, r11, r7 @ r4..r5 += (ct14 * -K02) - - rsb lr, lr, #0 @ lr = -K15 - rsb r11, r11, #0 @ r11 = K02 - - smlal r2, r3, lr, r9 @ r2..r3 += (ct17 * -K15) - smlal r2, r3, r11, r6 @ r2..r3 += (ct15 * K02) - - movs r4, r4, lsr #28 - adc r4, r4, r5, lsl #4 @ r4 = bits[59..28] of r4..r5 - str r4, [r1, #x25] @ store result x25 - - movs r2, r2, lsr #28 - adc r2, r2, r3, lsl #4 @ r2 = bits[59..28] of r2..r3 - str r2, [r1, #x19] @ store result x19 - - @---- - - ldr r2, [sp, #16] @ r2 = ct01_l - ldr r3, [sp, #20] @ r3 = ct01_h - - ldr r6, [r0, #X1] - ldr r8, [r0, #X7] - ldr r9, [r0, #X10] - ldr r7, [r0, #X16] - - rsbs r2, r2, #0 - rsc r3, r3, #0 @ r2..r3 = -ct01 - - mov r4, r2 - mov r5, r3 @ r4..r5 = -ct01 - - @ r2..r3 = -ct01 - @ r4..r5 = -ct01 - @ r6 = X1 - @ r7 = X16 - @ r8 = X7 - @ r9 = X10 - @ r10 = -K03 - @ r11 = K02 - @ r12 = -K14 - @ lr = -K15 - - smlal r4, r5, r12, r7 @ r4..r5 = -ct01 + (X16 * -K14) - smlal r2, r3, lr, r9 @ r2..r3 = -ct01 + (X10 * -K15) - - smlal r4, r5, r10, r8 @ r4..r5 += (X7 * -K03) - smlal r2, r3, r10, r7 @ r2..r3 += (X16 * -K03) - - smlal r4, r5, r11, r9 @ r4..r5 += (X10 * K02) - smlal r2, r3, r12, r8 @ r2..r3 += (X7 * -K14) - - rsb lr, lr, #0 @ lr = K15 - rsb r11, r11, #0 @ r11 = -K02 - - smlal r4, r5, lr, r6 @ r4..r5 += (X1 * K15) = ct05 - smlal r2, r3, r11, r6 @ r2..r3 += (X1 * -K02) = ct03 - - stmdb sp!, { r2, r3, r4, r5 } @ stack ct05_h, ct05_l, ct03_h, ct03_l - - rsbs r4, r4, #0 - rsc r5, r5, #0 @ r4..r5 = -ct05 - - stmdb sp!, { r4, r5 } @ stack -ct05_h, -ct05_l - - ldr r2, [sp, #48] @ r2 = ct00_l - ldr r3, [sp, #52] @ r3 = ct00_h - - rsb r10, r10, #0 @ r10 = K03 - - rsbs r4, r2, #0 - rsc r5, r3, #0 @ r4..r5 = -ct00 - - @ r2..r3 = ct00 - @ r4..r5 = -ct00 - @ r6 = X1 - @ r7 = X16 - @ r8 = X7 - @ r9 = X10 - @ r10 = K03 - @ r11 = -K02 - @ r12 = -K14 - @ lr = K15 - - smlal r4, r5, r10, r6 @ r4..r5 = -ct00 + (X1 * K03) - smlal r2, r3, r10, r9 @ r2..r3 = ct00 + (X10 * K03) - - smlal r4, r5, r12, r9 @ r4..r5 += (X10 * -K14) - smlal r2, r3, r12, r6 @ r2..r3 += (X1 * -K14) - - smlal r4, r5, r11, r7 @ r4..r5 += (X16 * -K02) - smlal r4, r5, lr, r8 @ r4..r5 += (X7 * K15) = ct07 - - rsb lr, lr, #0 @ lr = -K15 - rsb r11, r11, #0 @ r11 = K02 - - smlal r2, r3, r11, r8 @ r2..r3 += (X7 * K02) - smlal r2, r3, lr, r7 @ r2..r3 += (X16 * -K15) = ct02 - - rsbs r6, r4, #0 - rsc r7, r5, #0 @ r6..r7 = -ct07 - - stmdb sp!, { r2 - r7 } @ stack -ct07_h, -ct07_l, ct07_h, ct07_l, ct02_h, ct02_l - - - @---- - - add r2, pc, #(imdct36_long_karray-.-8) @ r2 = base address of Knn array (PIC safe ?) - - -loop: - ldr r12, [r0, #X0] - - ldmia r2!, { r5 - r11 } @ first 7 words from Karray element - - smull r3, r4, r5, r12 @ sum = (Kxx * X0) - ldr r12, [r0, #X2] - ldr r5, [r0, #X3] - smlal r3, r4, r6, r12 @ sum += (Kxx * X2) - ldr r12, [r0, #X5] - ldr r6, [r0, #X6] - smlal r3, r4, r7, r5 @ sum += (Kxx * X3) - smlal r3, r4, r8, r12 @ sum += (Kxx * X5) - ldr r12, [r0, #X8] - ldr r5, [r0, #X9] - smlal r3, r4, r9, r6 @ sum += (Kxx * X6) - smlal r3, r4, r10, r12 @ sum += (Kxx * X8) - smlal r3, r4, r11, r5 @ sum += (Kxx * X9) - - ldmia r2!, { r5 - r10 } @ final 6 words from Karray element - - ldr r11, [r0, #X11] - ldr r12, [r0, #X12] - smlal r3, r4, r5, r11 @ sum += (Kxx * X11) - ldr r11, [r0, #X14] - ldr r5, [r0, #X15] - smlal r3, r4, r6, r12 @ sum += (Kxx * X12) - smlal r3, r4, r7, r11 @ sum += (Kxx * X14) - ldr r11, [r0, #X17] - smlal r3, r4, r8, r5 @ sum += (Kxx * X15) - smlal r3, r4, r9, r11 @ sum += (Kxx * X17) - - add r5, sp, r10, lsr #16 @ create index back into stack for required ctxx - - ldmia r5, { r6, r7 } @ r6..r7 = ctxx - - mov r8, r10, lsl #16 @ push ctxx index off the top end - - adds r3, r3, r6 @ add low words - adc r4, r4, r7 @ add high words, with carry - movs r3, r3, lsr #28 - adc r3, r3, r4, lsl #4 @ r3 = bits[59..28] of r3..r4 - - str r3, [r1, r8, lsr #24] @ push completion flag off the bottom end - - movs r8, r8, lsl #8 @ push result location index off the top end - beq loop @ loop back if completion flag not set - b imdct_l_windowing @ branch to windowing stage if looping finished - -imdct36_long_karray: - - .word K17, -K13, K10, -K06, -K05, K01, -K00, K04, -K07, K11, K12, -K16, 0x00000000 - .word K13, K07, K16, K01, K10, -K05, K04, -K11, K00, -K17, K06, -K12, 0x00200800 - .word K11, K17, K05, K12, -K01, K06, -K07, K00, -K13, K04, -K16, K10, 0x00200c00 - .word K07, K00, -K12, K05, -K16, -K10, K11, -K17, K04, K13, K01, K06, 0x00001400 - .word K05, K10, -K00, -K17, K07, -K13, K12, K06, -K16, K01, -K11, -K04, 0x00181800 - .word K01, K05, -K07, -K11, K13, K17, -K16, -K12, K10, K06, -K04, -K00, 0x00102000 - .word -K16, K12, -K11, K07, K04, -K00, -K01, K05, -K06, K10, K13, -K17, 0x00284800 - .word -K12, K06, K17, -K00, -K11, K04, K05, -K10, K01, K16, -K07, -K13, 0x00085000 - .word -K10, K16, K04, -K13, -K00, K07, K06, -K01, -K12, -K05, K17, K11, 0x00105400 - .word -K06, -K01, K13, K04, K17, -K11, -K10, -K16, -K05, K12, K00, K07, 0x00185c00 - .word -K04, -K11, -K01, K16, K06, K12, K13, -K07, -K17, -K00, -K10, -K05, 0x00006000 - .word -K00, -K04, -K06, -K10, -K12, -K16, -K17, -K13, -K11, -K07, -K05, -K01, 0x00206801 - - - @---- - @------------------------------------------------------------------------- - @---- - -imdct_l_windowing: - - ldr r11, [sp, #80] @ fetch function parameter 3 from out of the stack - ldmia r1!, { r0, r2 - r9 } @ load 9 words from x0, update pointer - - @ r0 = x0 - @ r1 = &x[9] - @ r2 = x1 - @ r3 = x2 - @ r4 = x3 - @ r5 = x4 - @ r6 = x5 - @ r7 = x6 - @ r8 = x7 - @ r9 = x8 - @ r10 = . - @ r11 = window mode: (0 == normal), (1 == start block), (3 == stop block) - @ r12 = . - @ lr = . - - cmp r11, #BLOCK_MODE_STOP @ setup flags - rsb r10, r0, #0 @ r10 = -x0 (DONT change flags !!) - beq stop_block_x0_to_x17 - - - @ start and normal blocks are treated the same for x[0]..x[17] - -normal_block_x0_to_x17: - - ldr r12, =WL9 @ r12 = window_l[9] - - rsb r0, r9, #0 @ r0 = -x8 - rsb r9, r2, #0 @ r9 = -x1 - rsb r2, r8, #0 @ r2 = -x7 - rsb r8, r3, #0 @ r8 = -x2 - rsb r3, r7, #0 @ r3 = -x6 - rsb r7, r4, #0 @ r7 = -x3 - rsb r4, r6, #0 @ r4 = -x5 - rsb r6, r5, #0 @ r6 = -x4 - - @ r0 = -x8 - @ r1 = &x[9] - @ r2 = -x7 - @ r3 = -x6 - @ r4 = -x5 - @ r5 = . - @ r6 = -x4 - @ r7 = -x3 - @ r8 = -x2 - @ r9 = -x1 - @ r10 = -x0 - @ r11 = window mode: (0 == normal), (1 == start block), (3 == stop block) - @ r12 = window_l[9] - @ lr = . - - smull r5, lr, r12, r0 @ r5..lr = (window_l[9] * (x[9] == -x[8])) - ldr r12, =WL10 @ r12 = window_l[10] - movs r5, r5, lsr #28 - adc r0, r5, lr, lsl #4 @ r0 = bits[59..28] of windowed x9 - - smull r5, lr, r12, r2 @ r5..lr = (window_l[10] * (x[10] == -x[7])) - ldr r12, =WL11 @ r12 = window_l[11] - movs r5, r5, lsr #28 - adc r2, r5, lr, lsl #4 @ r2 = bits[59..28] of windowed x10 - - smull r5, lr, r12, r3 @ r5..lr = (window_l[11] * (x[11] == -x[6])) - ldr r12, =WL12 @ r12 = window_l[12] - movs r5, r5, lsr #28 - adc r3, r5, lr, lsl #4 @ r3 = bits[59..28] of windowed x11 - - smull r5, lr, r12, r4 @ r5..lr = (window_l[12] * (x[12] == -x[5])) - ldr r12, =WL13 @ r12 = window_l[13] - movs r5, r5, lsr #28 - adc r4, r5, lr, lsl #4 @ r4 = bits[59..28] of windowed x12 - - smull r5, lr, r12, r6 @ r5..lr = (window_l[13] * (x[13] == -x[4])) - ldr r12, =WL14 @ r12 = window_l[14] - movs r5, r5, lsr #28 - adc r6, r5, lr, lsl #4 @ r6 = bits[59..28] of windowed x13 - - smull r5, lr, r12, r7 @ r5..lr = (window_l[14] * (x[14] == -x[3])) - ldr r12, =WL15 @ r12 = window_l[15] - movs r5, r5, lsr #28 - adc r7, r5, lr, lsl #4 @ r7 = bits[59..28] of windowed x14 - - smull r5, lr, r12, r8 @ r5..lr = (window_l[15] * (x[15] == -x[2])) - ldr r12, =WL16 @ r12 = window_l[16] - movs r5, r5, lsr #28 - adc r8, r5, lr, lsl #4 @ r8 = bits[59..28] of windowed x15 - - smull r5, lr, r12, r9 @ r5..lr = (window_l[16] * (x[16] == -x[1])) - ldr r12, =WL17 @ r12 = window_l[17] - movs r5, r5, lsr #28 - adc r9, r5, lr, lsl #4 @ r9 = bits[59..28] of windowed x16 - - smull r5, lr, r12, r10 @ r5..lr = (window_l[17] * (x[17] == -x[0])) - ldr r12, =WL0 @ r12 = window_l[0] - movs r5, r5, lsr #28 - adc r10, r5, lr, lsl #4 @ r10 = bits[59..28] of windowed x17 - - - stmia r1, { r0, r2 - r4, r6 - r10 } @ store windowed x[9] .. x[17] - ldmdb r1!, { r0, r2 - r9 } @ load 9 words downto (and including) x0 - - - smull r10, lr, r12, r0 @ r10..lr = (window_l[0] * x[0]) - ldr r12, =WL1 @ r12 = window_l[1] - movs r10, r10, lsr #28 - adc r0, r10, lr, lsl #4 @ r0 = bits[59..28] of windowed x0 - - smull r10, lr, r12, r2 @ r10..lr = (window_l[1] * x[1]) - ldr r12, =WL2 @ r12 = window_l[2] - movs r10, r10, lsr #28 - adc r2, r10, lr, lsl #4 @ r2 = bits[59..28] of windowed x1 - - smull r10, lr, r12, r3 @ r10..lr = (window_l[2] * x[2]) - ldr r12, =WL3 @ r12 = window_l[3] - movs r10, r10, lsr #28 - adc r3, r10, lr, lsl #4 @ r3 = bits[59..28] of windowed x2 - - smull r10, lr, r12, r4 @ r10..lr = (window_l[3] * x[3]) - ldr r12, =WL4 @ r12 = window_l[4] - movs r10, r10, lsr #28 - adc r4, r10, lr, lsl #4 @ r4 = bits[59..28] of windowed x3 - - smull r10, lr, r12, r5 @ r10..lr = (window_l[4] * x[4]) - ldr r12, =WL5 @ r12 = window_l[5] - movs r10, r10, lsr #28 - adc r5, r10, lr, lsl #4 @ r5 = bits[59..28] of windowed x4 - - smull r10, lr, r12, r6 @ r10..lr = (window_l[5] * x[5]) - ldr r12, =WL6 @ r12 = window_l[6] - movs r10, r10, lsr #28 - adc r6, r10, lr, lsl #4 @ r6 = bits[59..28] of windowed x5 - - smull r10, lr, r12, r7 @ r10..lr = (window_l[6] * x[6]) - ldr r12, =WL7 @ r12 = window_l[7] - movs r10, r10, lsr #28 - adc r7, r10, lr, lsl #4 @ r7 = bits[59..28] of windowed x6 - - smull r10, lr, r12, r8 @ r10..lr = (window_l[7] * x[7]) - ldr r12, =WL8 @ r12 = window_l[8] - movs r10, r10, lsr #28 - adc r8, r10, lr, lsl #4 @ r8 = bits[59..28] of windowed x7 - - smull r10, lr, r12, r9 @ r10..lr = (window_l[8] * x[8]) - movs r10, r10, lsr #28 - adc r9, r10, lr, lsl #4 @ r9 = bits[59..28] of windowed x8 - - stmia r1, { r0, r2 - r9 } @ store windowed x[0] .. x[8] - - cmp r11, #BLOCK_MODE_START - beq start_block_x18_to_x35 - - - @---- - - -normal_block_x18_to_x35: - - ldr r11, =WL3 @ r11 = window_l[3] - ldr r12, =WL4 @ r12 = window_l[4] - - add r1, r1, #(18*4) @ r1 = &x[18] - - ldmia r1!, { r0, r2 - r4, r6 - r10 } @ load 9 words from x18, update pointer - - @ r0 = x18 - @ r1 = &x[27] - @ r2 = x19 - @ r3 = x20 - @ r4 = x21 - @ r5 = . - @ r6 = x22 - @ r7 = x23 - @ r8 = x24 - @ r9 = x25 - @ r10 = x26 - @ r11 = window_l[3] - @ r12 = window_l[4] - @ lr = . - - smull r5, lr, r12, r6 @ r5..lr = (window_l[4] * (x[22] == x[31])) - movs r5, r5, lsr #28 - adc r5, r5, lr, lsl #4 @ r5 = bits[59..28] of windowed x31 - - smull r6, lr, r11, r4 @ r5..lr = (window_l[3] * (x[21] == x[32])) - ldr r12, =WL5 @ r12 = window_l[5] - movs r6, r6, lsr #28 - adc r6, r6, lr, lsl #4 @ r6 = bits[59..28] of windowed x32 - - smull r4, lr, r12, r7 @ r4..lr = (window_l[5] * (x[23] == x[30])) - ldr r11, =WL1 @ r11 = window_l[1] - ldr r12, =WL2 @ r12 = window_l[2] - movs r4, r4, lsr #28 - adc r4, r4, lr, lsl #4 @ r4 = bits[59..28] of windowed x30 - - smull r7, lr, r12, r3 @ r7..lr = (window_l[2] * (x[20] == x[33])) - ldr r12, =WL6 @ r12 = window_l[6] - movs r7, r7, lsr #28 - adc r7, r7, lr, lsl #4 @ r7 = bits[59..28] of windowed x33 - - smull r3, lr, r12, r8 @ r3..lr = (window_l[6] * (x[24] == x[29])) - movs r3, r3, lsr #28 - adc r3, r3, lr, lsl #4 @ r3 = bits[59..28] of windowed x29 - - smull r8, lr, r11, r2 @ r7..lr = (window_l[1] * (x[19] == x[34])) - ldr r12, =WL7 @ r12 = window_l[7] - ldr r11, =WL8 @ r11 = window_l[8] - movs r8, r8, lsr #28 - adc r8, r8, lr, lsl #4 @ r8 = bits[59..28] of windowed x34 - - smull r2, lr, r12, r9 @ r7..lr = (window_l[7] * (x[25] == x[28])) - ldr r12, =WL0 @ r12 = window_l[0] - movs r2, r2, lsr #28 - adc r2, r2, lr, lsl #4 @ r2 = bits[59..28] of windowed x28 - - smull r9, lr, r12, r0 @ r3..lr = (window_l[0] * (x[18] == x[35])) - movs r9, r9, lsr #28 - adc r9, r9, lr, lsl #4 @ r9 = bits[59..28] of windowed x35 - - smull r0, lr, r11, r10 @ r7..lr = (window_l[8] * (x[26] == x[27])) - ldr r11, =WL16 @ r11 = window_l[16] - ldr r12, =WL17 @ r12 = window_l[17] - movs r0, r0, lsr #28 - adc r0, r0, lr, lsl #4 @ r0 = bits[59..28] of windowed x27 - - - stmia r1, { r0, r2 - r9 } @ store windowed x[27] .. x[35] - ldmdb r1!, { r0, r2 - r9 } @ load 9 words downto (and including) x18 - - - smull r10, lr, r12, r0 @ r10..lr = (window_l[17] * x[18]) - movs r10, r10, lsr #28 - adc r0, r10, lr, lsl #4 @ r0 = bits[59..28] of windowed x0 - - smull r10, lr, r11, r2 @ r10..lr = (window_l[16] * x[19]) - ldr r11, =WL14 @ r11 = window_l[14] - ldr r12, =WL15 @ r12 = window_l[15] - movs r10, r10, lsr #28 - adc r2, r10, lr, lsl #4 @ r2 = bits[59..28] of windowed x1 - - smull r10, lr, r12, r3 @ r10..lr = (window_l[15] * x[20]) - movs r10, r10, lsr #28 - adc r3, r10, lr, lsl #4 @ r3 = bits[59..28] of windowed x2 - - smull r10, lr, r11, r4 @ r10..lr = (window_l[14] * x[21]) - ldr r11, =WL12 @ r11 = window_l[12] - ldr r12, =WL13 @ r12 = window_l[13] - movs r10, r10, lsr #28 - adc r4, r10, lr, lsl #4 @ r4 = bits[59..28] of windowed x3 - - smull r10, lr, r12, r5 @ r10..lr = (window_l[13] * x[22]) - movs r10, r10, lsr #28 - adc r5, r10, lr, lsl #4 @ r5 = bits[59..28] of windowed x4 - - smull r10, lr, r11, r6 @ r10..lr = (window_l[12] * x[23]) - ldr r11, =WL10 @ r12 = window_l[10] - ldr r12, =WL11 @ r12 = window_l[11] - movs r10, r10, lsr #28 - adc r6, r10, lr, lsl #4 @ r6 = bits[59..28] of windowed x5 - - smull r10, lr, r12, r7 @ r10..lr = (window_l[11] * x[24]) - movs r10, r10, lsr #28 - adc r7, r10, lr, lsl #4 @ r7 = bits[59..28] of windowed x6 - - smull r10, lr, r11, r8 @ r10..lr = (window_l[10] * x[25]) - ldr r12, =WL9 @ r12 = window_l[9] - movs r10, r10, lsr #28 - adc r8, r10, lr, lsl #4 @ r8 = bits[59..28] of windowed x7 - - smull r10, lr, r12, r9 @ r10..lr = (window_l[9] * x[26]) - - movs r10, r10, lsr #28 - adc r9, r10, lr, lsl #4 @ r9 = bits[59..28] of windowed x8 - - stmia r1, { r0, r2 - r9 } @ store windowed x[18] .. x[26] - - @---- - @ NB there are 2 possible exits from this function - this is only one of them - @---- - - add sp, sp, #(21*4) @ return stack frame - ldmpc regs=r4-r11 @ restore callee saved regs, and return - - @---- - - -stop_block_x0_to_x17: - - @ r0 = x0 - @ r1 = &x[9] - @ r2 = x1 - @ r3 = x2 - @ r4 = x3 - @ r5 = x4 - @ r6 = x5 - @ r7 = x6 - @ r8 = x7 - @ r9 = x8 - @ r10 = -x0 - @ r11 = window mode: (0 == normal), (1 == start block), (3 == stop block) - @ r12 = . - @ lr = . - - rsb r0, r6, #0 @ r0 = -x5 - rsb r6, r2, #0 @ r6 = -x1 - rsb r2, r5, #0 @ r2 = -x4 - rsb r5, r3, #0 @ r5 = -x2 - rsb r3, r4, #0 @ r3 = -x3 - - add r1, r1, #(3*4) @ r1 = &x[12] - stmia r1, { r0, r2, r3, r5, r6, r10 } @ store unchanged x[12] .. x[17] - - ldr r0, =WL1 @ r0 = window_l[1] == window_s[0] - - rsb r10, r9, #0 @ r10 = -x8 - rsb r12, r8, #0 @ r12 = -x7 - rsb lr, r7, #0 @ lr = -x6 - - @ r0 = WL1 - @ r1 = &x[12] - @ r2 = . - @ r3 = . - @ r4 = . - @ r5 = . - @ r6 = . - @ r7 = x6 - @ r8 = x7 - @ r9 = x8 - @ r10 = -x8 - @ r11 = window mode: (0 == normal), (1 == start block), (3 == stop block) - @ r12 = -x7 - @ lr = -x6 - - smull r5, r6, r0, r7 @ r5..r6 = (window_l[1] * x[6]) - ldr r2, =WL4 @ r2 = window_l[4] == window_s[1] - movs r5, r5, lsr #28 - adc r7, r5, r6, lsl #4 @ r7 = bits[59..28] of windowed x6 - - smull r5, r6, r2, r8 @ r5..r6 = (window_l[4] * x[7]) - ldr r3, =WL7 @ r3 = window_l[7] == window_s[2] - movs r5, r5, lsr #28 - adc r8, r5, r6, lsl #4 @ r8 = bits[59..28] of windowed x7 - - smull r5, r6, r3, r9 @ r5..r6 = (window_l[7] * x[8]) - ldr r4, =WL10 @ r4 = window_l[10] == window_s[3] - movs r5, r5, lsr #28 - adc r9, r5, r6, lsl #4 @ r9 = bits[59..28] of windowed x8 - - smull r5, r6, r4, r10 @ r5..r6 = (window_l[10] * (x[9] == -x[8])) - ldr r0, =WL13 @ r0 = window_l[13] == window_s[4] - movs r5, r5, lsr #28 - adc r10, r5, r6, lsl #4 @ r10 = bits[59..28] of windowed x9 - - smull r5, r6, r0, r12 @ r5..r6 = (window_l[13] * (x[10] == -x[7])) - ldr r2, =WL16 @ r2 = window_l[16] == window_s[5] - movs r5, r5, lsr #28 - adc r12, r5, r6, lsl #4 @ r10 = bits[59..28] of windowed x9 - - smull r5, r6, r2, lr @ r5..r6 = (window_l[16] * (x[11] == -x[6])) - - ldr r0, =0x00 - - movs r5, r5, lsr #28 - adc lr, r5, r6, lsl #4 @ r10 = bits[59..28] of windowed x9 - - stmdb r1!, { r7 - r10, r12, lr } @ store windowed x[6] .. x[11] - - ldr r5, =0x00 - ldr r6, =0x00 - ldr r2, =0x00 - ldr r3, =0x00 - ldr r4, =0x00 - - stmdb r1!, { r0, r2 - r6 } @ store windowed x[0] .. x[5] - - b normal_block_x18_to_x35 - - - @---- - - -start_block_x18_to_x35: - - ldr r4, =WL1 @ r0 = window_l[1] == window_s[0] - - add r1, r1, #(24*4) @ r1 = &x[24] - - ldmia r1, { r0, r2, r3 } @ load 3 words from x24, dont update pointer - - @ r0 = x24 - @ r1 = &x[24] - @ r2 = x25 - @ r3 = x26 - @ r4 = WL1 - @ r5 = WL4 - @ r6 = WL7 - @ r7 = WL10 - @ r8 = WL13 - @ r9 = WL16 - @ r10 = . - @ r11 = . - @ r12 = . - @ lr = . - - ldr r5, =WL4 @ r5 = window_l[4] == window_s[1] - - smull r10, r11, r4, r0 @ r10..r11 = (window_l[1] * (x[24] == x[29])) - ldr r6, =WL7 @ r6 = window_l[7] == window_s[2] - movs r10, r10, lsr #28 - adc lr, r10, r11, lsl #4 @ lr = bits[59..28] of windowed x29 - - smull r10, r11, r5, r2 @ r10..r11 = (window_l[4] * (x[25] == x[28])) - ldr r7, =WL10 @ r7 = window_l[10] == window_s[3] - movs r10, r10, lsr #28 - adc r12, r10, r11, lsl #4 @ r12 = bits[59..28] of windowed x28 - - smull r10, r11, r6, r3 @ r10..r11 = (window_l[7] * (x[26] == x[27])) - ldr r8, =WL13 @ r8 = window_l[13] == window_s[4] - movs r10, r10, lsr #28 - adc r4, r10, r11, lsl #4 @ r4 = bits[59..28] of windowed x27 - - smull r10, r11, r7, r3 @ r10..r11 = (window_l[10] * x[26]) - ldr r9, =WL16 @ r9 = window_l[16] == window_s[5] - movs r10, r10, lsr #28 - adc r3, r10, r11, lsl #4 @ r3 = bits[59..28] of windowed x26 - - smull r10, r11, r8, r2 @ r10..r11 = (window_l[13] * x[25]) - ldr r5, =0x00 - movs r10, r10, lsr #28 - adc r2, r10, r11, lsl #4 @ r2 = bits[59..28] of windowed x25 - - smull r10, r11, r9, r0 @ r10..r11 = (window_l[16] * x[24]) - ldr r6, =0x00 - movs r10, r10, lsr #28 - adc r0, r10, r11, lsl #4 @ r0 = bits[59..28] of windowed x24 - - stmia r1!, { r0, r2, r3, r4, r12, lr } @ store windowed x[24] .. x[29] - - ldr r7, =0x00 - ldr r8, =0x00 - ldr r9, =0x00 - ldr r10, =0x00 - - stmia r1!, { r5 - r10 } @ store windowed x[30] .. x[35] - - @---- - @ NB there are 2 possible exits from this function - this is only one of them - @---- - - add sp, sp, #(21*4) @ return stack frame - ldmpc regs=r4-r11 @ restore callee saved regs, and return - - @---- - @END - @---- - diff --git a/apps/codecs/libmad/imdct_mcf5249.S b/apps/codecs/libmad/imdct_mcf5249.S deleted file mode 100644 index b5e2a12b0f..0000000000 --- a/apps/codecs/libmad/imdct_mcf5249.S +++ /dev/null @@ -1,124 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2005 by Thom Johansen - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ -/* this will also be the home to III_imdct_l in the future */ - - .global III_imdct_s -III_imdct_s: - /* we need to save 9 registers and 36 samples of temp buffer */ - lea.l (-45*4, %sp), %sp - movem.l %d2-%d7/%a2-%a4, (36*4, %sp) - move.l (45*4 + 4, %sp), %a2 /* a2 = X */ - move.l %sp, %a3 - - /* IMDCT */ - - /* if additional precision is needed in this block, it is possible to - * get more low bits out of the accext01 register _before_ doing the - * movclrs. - */ - moveq.l #3, %d5 /* we do three outer loop iterations */ -.imdctloop: /* outer loop label */ - lea.l imdct_s, %a1 /* load pointer to imdct coefs in a1 */ - movem.l (%a2), %d0-%d4/%a0 /* load some input data in d0-d4/a0 */ - lea.l (6*4, %a2), %a2 - - clr.l %d7 /* clear loop variable */ - move.l (%a1)+, %a4 /* load imdct coef in a4 */ -.macloop: /* inner loop label */ - mac.l %d0, %a4, (%a1)+, %a4, %acc0 /* mac sequence */ - mac.l %d1, %a4, (%a1)+, %a4, %acc0 - mac.l %d2, %a4, (%a1)+, %a4, %acc0 - mac.l %d3, %a4, (%a1)+, %a4, %acc0 - mac.l %d4, %a4, (%a1)+, %a4, %acc0 - mac.l %a0, %a4, (%a1)+, %a4, %acc0 - movclr.l %acc0, %d6 /* get result, left shifted once */ - asl.l #3, %d6 /* one shift free, shift three more */ - move.l %d6, (%a3, %d7.l*4) /* yptr[i] = result */ - neg.l %d6 - neg.l %d7 - move.l %d6, (5*4, %a3, %d7.l*4) /* yptr[5 - i] = -result */ - mac.l %d0, %a4, (%a1)+, %a4, %acc0 /* mac sequence */ - mac.l %d1, %a4, (%a1)+, %a4, %acc0 - mac.l %d2, %a4, (%a1)+, %a4, %acc0 - mac.l %d3, %a4, (%a1)+, %a4, %acc0 - mac.l %d4, %a4, (%a1)+, %a4, %acc0 - mac.l %a0, %a4, (%a1)+, %a4, %acc0 - movclr.l %acc0, %d6 /* get result */ - asl.l #3, %d6 - move.l %d6, (11*4, %a3, %d7.l*4) /* yptr[11 - i] = result */ - neg.l %d7 - move.l %d6, (6*4, %a3, %d7.l*4) /* yptr[i + 6] = result */ - addq.l #1, %d7 /* increment inner loop variable */ - moveq.l #3, %d6 - cmp.l %d6, %d7 /* we do three inner loop iterations */ - jne .macloop - - lea.l (12*4, %a3), %a3 /* add pointer increment */ - subq.l #1, %d5 /* decrement outer loop variable */ - jne .imdctloop - - /* windowing, overlapping and concatenation */ - - move.l (45*4 + 8, %sp), %a2 /* a2 = z */ - move.l %sp, %a3 /* a3 = tmp buffer ptr */ - lea.l window_s, %a4 /* a4 = window coef pointer */ - - moveq.l #6, %d7 /* six iterations */ -.overlaploop: - clr.l (%a2) /* z[i + 0] = 0 */ - move.l (%a4), %d0 - move.l (%a3), %d2 - mac.l %d0, %d2, (6*4, %a4), %d1, %acc0 - move.l (6*4, %a3), %d2 - movclr.l %acc0, %d6 - asl.l #3, %d6 - move.l %d6, (6*4, %a2) /* z[i + 6] = result */ - - mac.l %d1, %d2, (12*4, %a3), %d2, %acc0 - mac.l %d0, %d2, (18*4, %a3), %d2, %acc0 - movclr.l %acc0, %d6 - asl.l #3, %d6 - move.l %d6, (12*4, %a2) /* z[i + 12] = result */ - - mac.l %d1, %d2, (24*4, %a3), %d2, %acc0 - mac.l %d0, %d2, (30*4, %a3), %d2, %acc0 - movclr.l %acc0, %d6 - asl.l #3, %d6 - move.l %d6, (18*4, %a2) /* z[i + 18] = result */ - - mac.l %d1, %d2, %acc0 - movclr.l %acc0, %d6 - asl.l #3, %d6 - move.l %d6, (24*4, %a2) /* z[i + 24] = result */ - - clr.l (30*4, %a2) /* z[i + 30] = 0 */ - addq.l #4, %a2 /* increment all pointers */ - addq.l #4, %a3 - addq.l #4, %a4 - subq.l #1, %d7 /* decrement loop counter */ - jne .overlaploop - /* fall through to exit if we're done */ - - /* clean up */ - movem.l (36*4, %sp), %d2-%d7/%a2-%a4 - lea.l (45*4, %sp), %sp - rts - diff --git a/apps/codecs/libmad/imdct_s.dat b/apps/codecs/libmad/imdct_s.dat deleted file mode 100644 index 0f1f3c9b60..0000000000 --- a/apps/codecs/libmad/imdct_s.dat +++ /dev/null @@ -1,62 +0,0 @@ -/* - * libmad - MPEG audio decoder library - * Copyright (C) 2000-2004 Underbit Technologies, Inc. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * $Id$ - */ - - /* 0 */ { MAD_F(0x09bd7ca0) /* 0.608761429 */, - -MAD_F(0x0ec835e8) /* -0.923879533 */, - -MAD_F(0x0216a2a2) /* -0.130526192 */, - MAD_F(0x0fdcf549) /* 0.991444861 */, - -MAD_F(0x061f78aa) /* -0.382683432 */, - -MAD_F(0x0cb19346) /* -0.793353340 */ }, - - /* 6 */ { -MAD_F(0x0cb19346) /* -0.793353340 */, - MAD_F(0x061f78aa) /* 0.382683432 */, - MAD_F(0x0fdcf549) /* 0.991444861 */, - MAD_F(0x0216a2a2) /* 0.130526192 */, - -MAD_F(0x0ec835e8) /* -0.923879533 */, - -MAD_F(0x09bd7ca0) /* -0.608761429 */ }, - - /* 1 */ { MAD_F(0x061f78aa) /* 0.382683432 */, - -MAD_F(0x0ec835e8) /* -0.923879533 */, - MAD_F(0x0ec835e8) /* 0.923879533 */, - -MAD_F(0x061f78aa) /* -0.382683432 */, - -MAD_F(0x061f78aa) /* -0.382683432 */, - MAD_F(0x0ec835e8) /* 0.923879533 */ }, - - /* 7 */ { -MAD_F(0x0ec835e8) /* -0.923879533 */, - -MAD_F(0x061f78aa) /* -0.382683432 */, - MAD_F(0x061f78aa) /* 0.382683432 */, - MAD_F(0x0ec835e8) /* 0.923879533 */, - MAD_F(0x0ec835e8) /* 0.923879533 */, - MAD_F(0x061f78aa) /* 0.382683432 */ }, - - /* 2 */ { MAD_F(0x0216a2a2) /* 0.130526192 */, - -MAD_F(0x061f78aa) /* -0.382683432 */, - MAD_F(0x09bd7ca0) /* 0.608761429 */, - -MAD_F(0x0cb19346) /* -0.793353340 */, - MAD_F(0x0ec835e8) /* 0.923879533 */, - -MAD_F(0x0fdcf549) /* -0.991444861 */ }, - - /* 8 */ { -MAD_F(0x0fdcf549) /* -0.991444861 */, - -MAD_F(0x0ec835e8) /* -0.923879533 */, - -MAD_F(0x0cb19346) /* -0.793353340 */, - -MAD_F(0x09bd7ca0) /* -0.608761429 */, - -MAD_F(0x061f78aa) /* -0.382683432 */, - -MAD_F(0x0216a2a2) /* -0.130526192 */ } diff --git a/apps/codecs/libmad/layer12.c b/apps/codecs/libmad/layer12.c deleted file mode 100644 index e00bb64530..0000000000 --- a/apps/codecs/libmad/layer12.c +++ /dev/null @@ -1,537 +0,0 @@ -/* - * libmad - MPEG audio decoder library - * Copyright (C) 2000-2004 Underbit Technologies, Inc. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * $Id$ - */ - -# ifdef HAVE_CONFIG_H -# include "config.h" -# endif - -# include "global.h" - -# ifdef HAVE_LIMITS_H -# include -# else -# undef CHAR_BIT -# define CHAR_BIT 8 -# endif - -# include "fixed.h" -# include "bit.h" -# include "stream.h" -# include "frame.h" -# include "layer12.h" - -/* - * scalefactor table - * used in both Layer I and Layer II decoding - */ -static -mad_fixed_t const sf_table[64] ICONST_ATTR = { -# include "sf_table.dat" -}; - -/* --- Layer I ------------------------------------------------------------- */ - -/* linear scaling table */ -static -mad_fixed_t const linear_table[14] ICONST_ATTR = { - MAD_F(0x15555555), /* 2^2 / (2^2 - 1) == 1.33333333333333 */ - MAD_F(0x12492492), /* 2^3 / (2^3 - 1) == 1.14285714285714 */ - MAD_F(0x11111111), /* 2^4 / (2^4 - 1) == 1.06666666666667 */ - MAD_F(0x10842108), /* 2^5 / (2^5 - 1) == 1.03225806451613 */ - MAD_F(0x10410410), /* 2^6 / (2^6 - 1) == 1.01587301587302 */ - MAD_F(0x10204081), /* 2^7 / (2^7 - 1) == 1.00787401574803 */ - MAD_F(0x10101010), /* 2^8 / (2^8 - 1) == 1.00392156862745 */ - MAD_F(0x10080402), /* 2^9 / (2^9 - 1) == 1.00195694716243 */ - MAD_F(0x10040100), /* 2^10 / (2^10 - 1) == 1.00097751710655 */ - MAD_F(0x10020040), /* 2^11 / (2^11 - 1) == 1.00048851978505 */ - MAD_F(0x10010010), /* 2^12 / (2^12 - 1) == 1.00024420024420 */ - MAD_F(0x10008004), /* 2^13 / (2^13 - 1) == 1.00012208521548 */ - MAD_F(0x10004001), /* 2^14 / (2^14 - 1) == 1.00006103888177 */ - MAD_F(0x10002000) /* 2^15 / (2^15 - 1) == 1.00003051850948 */ -}; - -/* - * NAME: I_sample() - * DESCRIPTION: decode one requantized Layer I sample from a bitstream - */ -static inline -mad_fixed_t I_sample(struct mad_bitptr *ptr, unsigned int nb) -{ - mad_fixed_t sample; - - sample = mad_bit_read(ptr, nb); - - /* invert most significant bit, extend sign, then scale to fixed format */ - - sample ^= 1 << (nb - 1); - sample |= -(sample & (1 << (nb - 1))); - - sample <<= MAD_F_FRACBITS - (nb - 1); - - /* requantize the sample */ - - /* s'' = (2^nb / (2^nb - 1)) * (s''' + 2^(-nb + 1)) */ - - sample += MAD_F_ONE >> (nb - 1); - - return mad_f_mul(sample, linear_table[nb - 2]); - - /* s' = factor * s'' */ - /* (to be performed by caller) */ -} - -/* - * NAME: layer->I() - * DESCRIPTION: decode a single Layer I frame - */ -int mad_layer_I(struct mad_stream *stream, struct mad_frame *frame) -{ - struct mad_header *header = &frame->header; - unsigned int nch, bound, ch, s, sb, nb; - unsigned char allocation[2][32], scalefactor[2][32]; - - nch = MAD_NCHANNELS(header); - - bound = 32; - if (header->mode == MAD_MODE_JOINT_STEREO) { - header->flags |= MAD_FLAG_I_STEREO; - bound = 4 + header->mode_extension * 4; - } - - /* check CRC word */ - - if (header->flags & MAD_FLAG_PROTECTION) { - header->crc_check = - mad_bit_crc(stream->ptr, 4 * (bound * nch + (32 - bound)), - header->crc_check); - - if (header->crc_check != header->crc_target && - !(frame->options & MAD_OPTION_IGNORECRC)) { - stream->error = MAD_ERROR_BADCRC; - return -1; - } - } - - /* decode bit allocations */ - - for (sb = 0; sb < bound; ++sb) { - for (ch = 0; ch < nch; ++ch) { - nb = mad_bit_read(&stream->ptr, 4); - - if (nb == 15) { - stream->error = MAD_ERROR_BADBITALLOC; - return -1; - } - - allocation[ch][sb] = nb ? nb + 1 : 0; - } - } - - for (sb = bound; sb < 32; ++sb) { - nb = mad_bit_read(&stream->ptr, 4); - - if (nb == 15) { - stream->error = MAD_ERROR_BADBITALLOC; - return -1; - } - - allocation[0][sb] = - allocation[1][sb] = nb ? nb + 1 : 0; - } - - /* decode scalefactors */ - - for (sb = 0; sb < 32; ++sb) { - for (ch = 0; ch < nch; ++ch) { - if (allocation[ch][sb]) { - scalefactor[ch][sb] = mad_bit_read(&stream->ptr, 6); - -# if defined(OPT_STRICT) - /* - * Scalefactor index 63 does not appear in Table B.1 of - * ISO/IEC 11172-3. Nonetheless, other implementations accept it, - * so we only reject it if OPT_STRICT is defined. - */ - if (scalefactor[ch][sb] == 63) { - stream->error = MAD_ERROR_BADSCALEFACTOR; - return -1; - } -# endif - } - } - } - - /* decode samples */ - - for (s = 0; s < 12; ++s) { - for (sb = 0; sb < bound; ++sb) { - for (ch = 0; ch < nch; ++ch) { - nb = allocation[ch][sb]; - (*frame->sbsample)[ch][s][sb] = nb ? - mad_f_mul(I_sample(&stream->ptr, nb), - sf_table[scalefactor[ch][sb]]) : 0; - } - } - - for (sb = bound; sb < 32; ++sb) { - if ((nb = allocation[0][sb])) { - mad_fixed_t sample; - - sample = I_sample(&stream->ptr, nb); - - for (ch = 0; ch < nch; ++ch) { - (*frame->sbsample)[ch][s][sb] = - mad_f_mul(sample, sf_table[scalefactor[ch][sb]]); - } - } - else { - for (ch = 0; ch < nch; ++ch) - (*frame->sbsample)[ch][s][sb] = 0; - } - } - } - - return 0; -} - -/* --- Layer II ------------------------------------------------------------ */ - -/* possible quantization per subband table */ -static -struct { - unsigned int sblimit; - unsigned char const offsets[30]; -} const sbquant_table[5] = { - /* ISO/IEC 11172-3 Table B.2a */ - { 27, { 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 6, 3, 3, 3, 3, 3, /* 0 */ - 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0 } }, - /* ISO/IEC 11172-3 Table B.2b */ - { 30, { 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 6, 3, 3, 3, 3, 3, /* 1 */ - 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0 } }, - /* ISO/IEC 11172-3 Table B.2c */ - { 8, { 5, 5, 2, 2, 2, 2, 2, 2 } }, /* 2 */ - /* ISO/IEC 11172-3 Table B.2d */ - { 12, { 5, 5, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 } }, /* 3 */ - /* ISO/IEC 13818-3 Table B.1 */ - { 30, { 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, /* 4 */ - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 } } -}; - -/* bit allocation table */ -static -struct { - unsigned short nbal; - unsigned short offset; -} const bitalloc_table[8] = { - { 2, 0 }, /* 0 */ - { 2, 3 }, /* 1 */ - { 3, 3 }, /* 2 */ - { 3, 1 }, /* 3 */ - { 4, 2 }, /* 4 */ - { 4, 3 }, /* 5 */ - { 4, 4 }, /* 6 */ - { 4, 5 } /* 7 */ -}; - -/* offsets into quantization class table */ -static -unsigned char const offset_table[6][15] = { - { 0, 1, 16 }, /* 0 */ - { 0, 1, 2, 3, 4, 5, 16 }, /* 1 */ - { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 }, /* 2 */ - { 0, 1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }, /* 3 */ - { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 16 }, /* 4 */ - { 0, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 } /* 5 */ -}; - -/* quantization class table */ -static -struct quantclass { - unsigned short nlevels; - unsigned char group; - unsigned char bits; - mad_fixed_t C; - mad_fixed_t D; -} const qc_table[17] ICONST_ATTR = { -# include "qc_table.dat" -}; - -/* - * NAME: II_samples() - * DESCRIPTION: decode three requantized Layer II samples from a bitstream - */ -static -void II_samples(struct mad_bitptr *ptr, - struct quantclass const *quantclass, - mad_fixed_t output[3]) -{ - unsigned int nb, s, sample[3]; - - if ((nb = quantclass->group)) { - unsigned int c, nlevels; - - /* degrouping */ - c = mad_bit_read(ptr, quantclass->bits); - nlevels = quantclass->nlevels; - - for (s = 0; s < 3; ++s) { - sample[s] = c % nlevels; - c /= nlevels; - } - } - else { - nb = quantclass->bits; - - for (s = 0; s < 3; ++s) - sample[s] = mad_bit_read(ptr, nb); - } - - for (s = 0; s < 3; ++s) { - mad_fixed_t requantized; - - /* invert most significant bit, extend sign, then scale to fixed format */ - - requantized = sample[s] ^ (1 << (nb - 1)); - requantized |= -(requantized & (1 << (nb - 1))); - - requantized <<= MAD_F_FRACBITS - (nb - 1); - - /* requantize the sample */ - - /* s'' = C * (s''' + D) */ - - output[s] = mad_f_mul(requantized + quantclass->D, quantclass->C); - - /* s' = factor * s'' */ - /* (to be performed by caller) */ - } -} - -/* - * NAME: layer->II() - * DESCRIPTION: decode a single Layer II frame - */ -int mad_layer_II(struct mad_stream *stream, struct mad_frame *frame) -{ - struct mad_header *header = &frame->header; - struct mad_bitptr start; - unsigned int index, sblimit, nbal, nch, bound, gr, ch, s, sb; - unsigned char const *offsets; - unsigned char allocation[2][32], scfsi[2][32], scalefactor[2][32][3]; - mad_fixed_t samples[3]; - - nch = MAD_NCHANNELS(header); - - if (header->flags & MAD_FLAG_LSF_EXT) - index = 4; - else if (header->flags & MAD_FLAG_FREEFORMAT) - goto freeformat; - else { - unsigned long bitrate_per_channel; - - bitrate_per_channel = header->bitrate; - if (nch == 2) { - bitrate_per_channel /= 2; - -# if defined(OPT_STRICT) - /* - * ISO/IEC 11172-3 allows only single channel mode for 32, 48, 56, and - * 80 kbps bitrates in Layer II, but some encoders ignore this - * restriction. We enforce it if OPT_STRICT is defined. - */ - if (bitrate_per_channel <= 28000 || bitrate_per_channel == 40000) { - stream->error = MAD_ERROR_BADMODE; - return -1; - } -# endif - } - else { /* nch == 1 */ - if (bitrate_per_channel > 192000) { - /* - * ISO/IEC 11172-3 does not allow single channel mode for 224, 256, - * 320, or 384 kbps bitrates in Layer II. - */ - stream->error = MAD_ERROR_BADMODE; - return -1; - } - } - - if (bitrate_per_channel <= 48000) - index = (header->samplerate == 32000) ? 3 : 2; - else if (bitrate_per_channel <= 80000) - index = 0; - else { - freeformat: - index = (header->samplerate == 48000) ? 0 : 1; - } - } - - sblimit = sbquant_table[index].sblimit; - offsets = sbquant_table[index].offsets; - - bound = 32; - if (header->mode == MAD_MODE_JOINT_STEREO) { - header->flags |= MAD_FLAG_I_STEREO; - bound = 4 + header->mode_extension * 4; - } - - if (bound > sblimit) - bound = sblimit; - - start = stream->ptr; - - /* decode bit allocations */ - - for (sb = 0; sb < bound; ++sb) { - nbal = bitalloc_table[offsets[sb]].nbal; - - for (ch = 0; ch < nch; ++ch) - allocation[ch][sb] = mad_bit_read(&stream->ptr, nbal); - } - - for (sb = bound; sb < sblimit; ++sb) { - nbal = bitalloc_table[offsets[sb]].nbal; - - allocation[0][sb] = - allocation[1][sb] = mad_bit_read(&stream->ptr, nbal); - } - - /* decode scalefactor selection info */ - - for (sb = 0; sb < sblimit; ++sb) { - for (ch = 0; ch < nch; ++ch) { - if (allocation[ch][sb]) - scfsi[ch][sb] = mad_bit_read(&stream->ptr, 2); - } - } - - /* check CRC word */ - - if (header->flags & MAD_FLAG_PROTECTION) { - header->crc_check = - mad_bit_crc(start, mad_bit_length(&start, &stream->ptr), - header->crc_check); - - if (header->crc_check != header->crc_target && - !(frame->options & MAD_OPTION_IGNORECRC)) { - stream->error = MAD_ERROR_BADCRC; - return -1; - } - } - - /* decode scalefactors */ - - for (sb = 0; sb < sblimit; ++sb) { - for (ch = 0; ch < nch; ++ch) { - if (allocation[ch][sb]) { - scalefactor[ch][sb][0] = mad_bit_read(&stream->ptr, 6); - - switch (scfsi[ch][sb]) { - case 2: - scalefactor[ch][sb][2] = - scalefactor[ch][sb][1] = - scalefactor[ch][sb][0]; - break; - - case 0: - scalefactor[ch][sb][1] = mad_bit_read(&stream->ptr, 6); - /* fall through */ - - case 1: - case 3: - scalefactor[ch][sb][2] = mad_bit_read(&stream->ptr, 6); - } - - if (scfsi[ch][sb] & 1) - scalefactor[ch][sb][1] = scalefactor[ch][sb][scfsi[ch][sb] - 1]; - -# if defined(OPT_STRICT) - /* - * Scalefactor index 63 does not appear in Table B.1 of - * ISO/IEC 11172-3. Nonetheless, other implementations accept it, - * so we only reject it if OPT_STRICT is defined. - */ - if (scalefactor[ch][sb][0] == 63 || - scalefactor[ch][sb][1] == 63 || - scalefactor[ch][sb][2] == 63) { - stream->error = MAD_ERROR_BADSCALEFACTOR; - return -1; - } -# endif - } - } - } - - /* decode samples */ - - for (gr = 0; gr < 12; ++gr) { - for (sb = 0; sb < bound; ++sb) { - for (ch = 0; ch < nch; ++ch) { - if ((index = allocation[ch][sb])) { - int off = bitalloc_table[offsets[sb]].offset; - index = offset_table[off][index - 1]; - - II_samples(&stream->ptr, &qc_table[index], samples); - - for (s = 0; s < 3; ++s) { - (*frame->sbsample)[ch][3 * gr + s][sb] = - mad_f_mul(samples[s], sf_table[scalefactor[ch][sb][gr / 4]]); - } - } - else { - for (s = 0; s < 3; ++s) - (*frame->sbsample)[ch][3 * gr + s][sb] = 0; - } - } - } - - for (sb = bound; sb < sblimit; ++sb) { - if ((index = allocation[0][sb])) { - int off = bitalloc_table[offsets[sb]].offset; - index = offset_table[off][index - 1]; - - II_samples(&stream->ptr, &qc_table[index], samples); - - for (ch = 0; ch < nch; ++ch) { - for (s = 0; s < 3; ++s) { - (*frame->sbsample)[ch][3 * gr + s][sb] = - mad_f_mul(samples[s], sf_table[scalefactor[ch][sb][gr / 4]]); - } - } - } - else { - for (ch = 0; ch < nch; ++ch) { - for (s = 0; s < 3; ++s) - (*frame->sbsample)[ch][3 * gr + s][sb] = 0; - } - } - } - - for (ch = 0; ch < nch; ++ch) { - for (s = 0; s < 3; ++s) { - for (sb = sblimit; sb < 32; ++sb) - (*frame->sbsample)[ch][3 * gr + s][sb] = 0; - } - } - } - - return 0; -} diff --git a/apps/codecs/libmad/layer12.h b/apps/codecs/libmad/layer12.h deleted file mode 100644 index 3fe6bd8b0f..0000000000 --- a/apps/codecs/libmad/layer12.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * libmad - MPEG audio decoder library - * Copyright (C) 2000-2004 Underbit Technologies, Inc. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * $Id$ - */ - -# ifndef LIBMAD_LAYER12_H -# define LIBMAD_LAYER12_H - -# include "stream.h" -# include "frame.h" - -int mad_layer_I(struct mad_stream *, struct mad_frame *); -int mad_layer_II(struct mad_stream *, struct mad_frame *); - -# endif diff --git a/apps/codecs/libmad/layer3.c b/apps/codecs/libmad/layer3.c deleted file mode 100644 index a598ff2c95..0000000000 --- a/apps/codecs/libmad/layer3.c +++ /dev/null @@ -1,3107 +0,0 @@ -/* - * libmad - MPEG audio decoder library - * Copyright (C) 2000-2004 Underbit Technologies, Inc. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * $Id$ - */ - -# ifdef HAVE_CONFIG_H -# include "config.h" -# endif - -# include "global.h" - -# include - -# ifdef HAVE_ASSERT_H -# include -# endif - -# ifdef HAVE_LIMITS_H -# include -# else -# undef CHAR_BIT -# define CHAR_BIT 8 -# endif - -# include "fixed.h" -# include "bit.h" -# include "stream.h" -# include "frame.h" -# include "huffman.h" -# include "layer3.h" - -/* depending on the cpu "leftshift32" may be supported or not */ -# if defined(CPU_COLDFIRE) -#define MAXLSHIFT 32 -#else -#define MAXLSHIFT 31 -#endif - -/* --- Layer III ----------------------------------------------------------- */ - -enum { - count1table_select = 0x01, - scalefac_scale = 0x02, - preflag = 0x04, - mixed_block_flag = 0x08 -}; - -enum { - I_STEREO = 0x1, - MS_STEREO = 0x2 -}; - -struct sideinfo { - unsigned int main_data_begin; - unsigned int private_bits; - - unsigned char scfsi[2]; - - struct granule { - struct channel { - /* from side info */ - unsigned short part2_3_length; - unsigned short big_values; - unsigned short global_gain; - unsigned short scalefac_compress; - - unsigned char flags; - unsigned char block_type; - unsigned char table_select[3]; - unsigned char subblock_gain[3]; - unsigned char region0_count; - unsigned char region1_count; - - /* from main_data */ - unsigned char scalefac[39]; /* scalefac_l and/or scalefac_s */ - } ch[2]; - } gr[2]; -}; - -/* - * scalefactor bit lengths - * derived from section 2.4.2.7 of ISO/IEC 11172-3 - */ -static -struct { - unsigned char slen1; - unsigned char slen2; -} const sflen_table[16] = { - { 0, 0 }, { 0, 1 }, { 0, 2 }, { 0, 3 }, - { 3, 0 }, { 1, 1 }, { 1, 2 }, { 1, 3 }, - { 2, 1 }, { 2, 2 }, { 2, 3 }, { 3, 1 }, - { 3, 2 }, { 3, 3 }, { 4, 2 }, { 4, 3 } -}; - -/* - * number of LSF scalefactor band values - * derived from section 2.4.3.2 of ISO/IEC 13818-3 - */ -static -unsigned char const nsfb_table[6][3][4] = { - { { 6, 5, 5, 5 }, - { 9, 9, 9, 9 }, - { 6, 9, 9, 9 } }, - - { { 6, 5, 7, 3 }, - { 9, 9, 12, 6 }, - { 6, 9, 12, 6 } }, - - { { 11, 10, 0, 0 }, - { 18, 18, 0, 0 }, - { 15, 18, 0, 0 } }, - - { { 7, 7, 7, 0 }, - { 12, 12, 12, 0 }, - { 6, 15, 12, 0 } }, - - { { 6, 6, 6, 3 }, - { 12, 9, 9, 6 }, - { 6, 12, 9, 6 } }, - - { { 8, 8, 5, 0 }, - { 15, 12, 9, 0 }, - { 6, 18, 9, 0 } } -}; - -/* - * MPEG-1 scalefactor band widths - * derived from Table B.8 of ISO/IEC 11172-3 - */ -static -unsigned char const sfb_48000_long[] = { - 4, 4, 4, 4, 4, 4, 6, 6, 6, 8, 10, - 12, 16, 18, 22, 28, 34, 40, 46, 54, 54, 192 -}; - -static -unsigned char const sfb_44100_long[] = { - 4, 4, 4, 4, 4, 4, 6, 6, 8, 8, 10, - 12, 16, 20, 24, 28, 34, 42, 50, 54, 76, 158 -}; - -static -unsigned char const sfb_32000_long[] = { - 4, 4, 4, 4, 4, 4, 6, 6, 8, 10, 12, - 16, 20, 24, 30, 38, 46, 56, 68, 84, 102, 26 -}; - -static -unsigned char const sfb_48000_short[] = { - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 6, - 6, 6, 6, 6, 6, 10, 10, 10, 12, 12, 12, 14, 14, - 14, 16, 16, 16, 20, 20, 20, 26, 26, 26, 66, 66, 66 -}; - -static -unsigned char const sfb_44100_short[] = { - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 6, - 6, 6, 8, 8, 8, 10, 10, 10, 12, 12, 12, 14, 14, - 14, 18, 18, 18, 22, 22, 22, 30, 30, 30, 56, 56, 56 -}; - -static -unsigned char const sfb_32000_short[] = { - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 6, - 6, 6, 8, 8, 8, 12, 12, 12, 16, 16, 16, 20, 20, - 20, 26, 26, 26, 34, 34, 34, 42, 42, 42, 12, 12, 12 -}; - -static -unsigned char const sfb_48000_mixed[] = { - /* long */ 4, 4, 4, 4, 4, 4, 6, 6, - /* short */ 4, 4, 4, 6, 6, 6, 6, 6, 6, 10, - 10, 10, 12, 12, 12, 14, 14, 14, 16, 16, - 16, 20, 20, 20, 26, 26, 26, 66, 66, 66 -}; - -static -unsigned char const sfb_44100_mixed[] = { - /* long */ 4, 4, 4, 4, 4, 4, 6, 6, - /* short */ 4, 4, 4, 6, 6, 6, 8, 8, 8, 10, - 10, 10, 12, 12, 12, 14, 14, 14, 18, 18, - 18, 22, 22, 22, 30, 30, 30, 56, 56, 56 -}; - -static -unsigned char const sfb_32000_mixed[] = { - /* long */ 4, 4, 4, 4, 4, 4, 6, 6, - /* short */ 4, 4, 4, 6, 6, 6, 8, 8, 8, 12, - 12, 12, 16, 16, 16, 20, 20, 20, 26, 26, - 26, 34, 34, 34, 42, 42, 42, 12, 12, 12 -}; - -/* - * MPEG-2 scalefactor band widths - * derived from Table B.2 of ISO/IEC 13818-3 - */ -static -unsigned char const sfb_24000_long[] = { - 6, 6, 6, 6, 6, 6, 8, 10, 12, 14, 16, - 18, 22, 26, 32, 38, 46, 54, 62, 70, 76, 36 -}; - -static -unsigned char const sfb_22050_long[] = { - 6, 6, 6, 6, 6, 6, 8, 10, 12, 14, 16, - 20, 24, 28, 32, 38, 46, 52, 60, 68, 58, 54 -}; - -# define sfb_16000_long sfb_22050_long - -static -unsigned char const sfb_24000_short[] = { - 4, 4, 4, 4, 4, 4, 4, 4, 4, 6, 6, 6, 8, - 8, 8, 10, 10, 10, 12, 12, 12, 14, 14, 14, 18, 18, - 18, 24, 24, 24, 32, 32, 32, 44, 44, 44, 12, 12, 12 -}; - -static -unsigned char const sfb_22050_short[] = { - 4, 4, 4, 4, 4, 4, 4, 4, 4, 6, 6, 6, 6, - 6, 6, 8, 8, 8, 10, 10, 10, 14, 14, 14, 18, 18, - 18, 26, 26, 26, 32, 32, 32, 42, 42, 42, 18, 18, 18 -}; - -static -unsigned char const sfb_16000_short[] = { - 4, 4, 4, 4, 4, 4, 4, 4, 4, 6, 6, 6, 8, - 8, 8, 10, 10, 10, 12, 12, 12, 14, 14, 14, 18, 18, - 18, 24, 24, 24, 30, 30, 30, 40, 40, 40, 18, 18, 18 -}; - -static -unsigned char const sfb_24000_mixed[] = { - /* long */ 6, 6, 6, 6, 6, 6, - /* short */ 6, 6, 6, 8, 8, 8, 10, 10, 10, 12, - 12, 12, 14, 14, 14, 18, 18, 18, 24, 24, - 24, 32, 32, 32, 44, 44, 44, 12, 12, 12 -}; - -static -unsigned char const sfb_22050_mixed[] = { - /* long */ 6, 6, 6, 6, 6, 6, - /* short */ 6, 6, 6, 6, 6, 6, 8, 8, 8, 10, - 10, 10, 14, 14, 14, 18, 18, 18, 26, 26, - 26, 32, 32, 32, 42, 42, 42, 18, 18, 18 -}; - -static -unsigned char const sfb_16000_mixed[] = { - /* long */ 6, 6, 6, 6, 6, 6, - /* short */ 6, 6, 6, 8, 8, 8, 10, 10, 10, 12, - 12, 12, 14, 14, 14, 18, 18, 18, 24, 24, - 24, 30, 30, 30, 40, 40, 40, 18, 18, 18 -}; - -/* - * MPEG 2.5 scalefactor band widths - * derived from public sources - */ -# define sfb_12000_long sfb_16000_long -# define sfb_11025_long sfb_12000_long - -static -unsigned char const sfb_8000_long[] = { - 12, 12, 12, 12, 12, 12, 16, 20, 24, 28, 32, - 40, 48, 56, 64, 76, 90, 2, 2, 2, 2, 2 -}; - -# define sfb_12000_short sfb_16000_short -# define sfb_11025_short sfb_12000_short - -static -unsigned char const sfb_8000_short[] = { - 8, 8, 8, 8, 8, 8, 8, 8, 8, 12, 12, 12, 16, - 16, 16, 20, 20, 20, 24, 24, 24, 28, 28, 28, 36, 36, - 36, 2, 2, 2, 2, 2, 2, 2, 2, 2, 26, 26, 26 -}; - -# define sfb_12000_mixed sfb_16000_mixed -# define sfb_11025_mixed sfb_12000_mixed - -/* the 8000 Hz short block scalefactor bands do not break after - the first 36 frequency lines, so this is probably wrong */ -static -unsigned char const sfb_8000_mixed[] = { - /* long */ 12, 12, 12, - /* short */ 4, 4, 4, 8, 8, 8, 12, 12, 12, 16, 16, 16, - 20, 20, 20, 24, 24, 24, 28, 28, 28, 36, 36, 36, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 26, 26, 26 -}; - -static -struct { - unsigned char const *l; - unsigned char const *s; - unsigned char const *m; -} const sfbwidth_table[9] = { - { sfb_48000_long, sfb_48000_short, sfb_48000_mixed }, - { sfb_44100_long, sfb_44100_short, sfb_44100_mixed }, - { sfb_32000_long, sfb_32000_short, sfb_32000_mixed }, - { sfb_24000_long, sfb_24000_short, sfb_24000_mixed }, - { sfb_22050_long, sfb_22050_short, sfb_22050_mixed }, - { sfb_16000_long, sfb_16000_short, sfb_16000_mixed }, - { sfb_12000_long, sfb_12000_short, sfb_12000_mixed }, - { sfb_11025_long, sfb_11025_short, sfb_11025_mixed }, - { sfb_8000_long, sfb_8000_short, sfb_8000_mixed } -}; - -/* - * scalefactor band preemphasis (used only when preflag is set) - * derived from Table B.6 of ISO/IEC 11172-3 - */ -static -unsigned char const pretab[22] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 3, 3, 3, 2, 0 -}; - -/* - * table for requantization - * - * rq_table[x].mantissa * 2^(rq_table[x].exponent) = x^(4/3) - * - * format rq_table: bit31-27=exponent bit26-0=mantissa - */ -static -unsigned long const rq_table[8207] = { -# include "rq_table.dat" -}; - -/* - * fractional powers of two - * used for requantization and joint stereo decoding - * - * root_table[3 + x] = 2^(x/4) - */ -mad_fixed_t const root_table[7] ICONST_ATTR MEM_ALIGN_ATTR = { - MAD_F(0x09837f05) /* 2^(-3/4) == 0.59460355750136 */, - MAD_F(0x0b504f33) /* 2^(-2/4) == 0.70710678118655 */, - MAD_F(0x0d744fcd) /* 2^(-1/4) == 0.84089641525371 */, - MAD_F(0x10000000) /* 2^( 0/4) == 1.00000000000000 */, - MAD_F(0x1306fe0a) /* 2^(+1/4) == 1.18920711500272 */, - MAD_F(0x16a09e66) /* 2^(+2/4) == 1.41421356237310 */, - MAD_F(0x1ae89f99) /* 2^(+3/4) == 1.68179283050743 */ -}; - -/* - * coefficients for aliasing reduction - * derived from Table B.9 of ISO/IEC 11172-3 - * - * c[] = { -0.6, -0.535, -0.33, -0.185, -0.095, -0.041, -0.0142, -0.0037 } - * cs[i] = 1 / sqrt(1 + c[i]^2) - * ca[i] = c[i] / sqrt(1 + c[i]^2) - */ -mad_fixed_t const cs[8] ICONST_ATTR MEM_ALIGN_ATTR = { - +MAD_F(0x0db84a81) /* +0.857492926 */, +MAD_F(0x0e1b9d7f) /* +0.881741997 */, - +MAD_F(0x0f31adcf) /* +0.949628649 */, +MAD_F(0x0fbba815) /* +0.983314592 */, - +MAD_F(0x0feda417) /* +0.995517816 */, +MAD_F(0x0ffc8fc8) /* +0.999160558 */, - +MAD_F(0x0fff964c) /* +0.999899195 */, +MAD_F(0x0ffff8d3) /* +0.999993155 */ -}; - -mad_fixed_t const ca[8] ICONST_ATTR MEM_ALIGN_ATTR = { - -MAD_F(0x083b5fe7) /* -0.514495755 */, -MAD_F(0x078c36d2) /* -0.471731969 */, - -MAD_F(0x05039814) /* -0.313377454 */, -MAD_F(0x02e91dd1) /* -0.181913200 */, - -MAD_F(0x0183603a) /* -0.094574193 */, -MAD_F(0x00a7cb87) /* -0.040965583 */, - -MAD_F(0x003a2847) /* -0.014198569 */, -MAD_F(0x000f27b4) /* -0.003699975 */ -}; - -/* - * IMDCT coefficients for short blocks - * derived from section 2.4.3.4.10.2 of ISO/IEC 11172-3 - * - * imdct_s[i/even][k] = cos((PI / 24) * (2 * (i / 2) + 7) * (2 * k + 1)) - * imdct_s[i /odd][k] = cos((PI / 24) * (2 * (6 + (i-1)/2) + 7) * (2 * k + 1)) - */ -mad_fixed_t const imdct_s[6][6] ICONST_ATTR MEM_ALIGN_ATTR = { -# include "imdct_s.dat" -}; - -# if !defined(FPM_ARM) -/* - * windowing coefficients for long blocks - * derived from section 2.4.3.4.10.3 of ISO/IEC 11172-3 - * - * window_l[i] = sin((PI / 36) * (i + 1/2)) - */ -static -mad_fixed_t const window_l[36] ICONST_ATTR MEM_ALIGN_ATTR = { - MAD_F(0x00b2aa3e) /* 0.043619387 */, MAD_F(0x0216a2a2) /* 0.130526192 */, - MAD_F(0x03768962) /* 0.216439614 */, MAD_F(0x04cfb0e2) /* 0.300705800 */, - MAD_F(0x061f78aa) /* 0.382683432 */, MAD_F(0x07635284) /* 0.461748613 */, - MAD_F(0x0898c779) /* 0.537299608 */, MAD_F(0x09bd7ca0) /* 0.608761429 */, - MAD_F(0x0acf37ad) /* 0.675590208 */, MAD_F(0x0bcbe352) /* 0.737277337 */, - MAD_F(0x0cb19346) /* 0.793353340 */, MAD_F(0x0d7e8807) /* 0.843391446 */, - - MAD_F(0x0e313245) /* 0.887010833 */, MAD_F(0x0ec835e8) /* 0.923879533 */, - MAD_F(0x0f426cb5) /* 0.953716951 */, MAD_F(0x0f9ee890) /* 0.976296007 */, - MAD_F(0x0fdcf549) /* 0.991444861 */, MAD_F(0x0ffc19fd) /* 0.999048222 */, - MAD_F(0x0ffc19fd) /* 0.999048222 */, MAD_F(0x0fdcf549) /* 0.991444861 */, - MAD_F(0x0f9ee890) /* 0.976296007 */, MAD_F(0x0f426cb5) /* 0.953716951 */, - MAD_F(0x0ec835e8) /* 0.923879533 */, MAD_F(0x0e313245) /* 0.887010833 */, - - MAD_F(0x0d7e8807) /* 0.843391446 */, MAD_F(0x0cb19346) /* 0.793353340 */, - MAD_F(0x0bcbe352) /* 0.737277337 */, MAD_F(0x0acf37ad) /* 0.675590208 */, - MAD_F(0x09bd7ca0) /* 0.608761429 */, MAD_F(0x0898c779) /* 0.537299608 */, - MAD_F(0x07635284) /* 0.461748613 */, MAD_F(0x061f78aa) /* 0.382683432 */, - MAD_F(0x04cfb0e2) /* 0.300705800 */, MAD_F(0x03768962) /* 0.216439614 */, - MAD_F(0x0216a2a2) /* 0.130526192 */, MAD_F(0x00b2aa3e) /* 0.043619387 */, -}; -# endif /* FPM_ARM */ - -/* - * windowing coefficients for short blocks - * derived from section 2.4.3.4.10.3 of ISO/IEC 11172-3 - * - * window_s[i] = sin((PI / 12) * (i + 1/2)) - */ -mad_fixed_t const window_s[12] ICONST_ATTR MEM_ALIGN_ATTR = { - MAD_F(0x0216a2a2) /* 0.130526192 */, MAD_F(0x061f78aa) /* 0.382683432 */, - MAD_F(0x09bd7ca0) /* 0.608761429 */, MAD_F(0x0cb19346) /* 0.793353340 */, - MAD_F(0x0ec835e8) /* 0.923879533 */, MAD_F(0x0fdcf549) /* 0.991444861 */, - MAD_F(0x0fdcf549) /* 0.991444861 */, MAD_F(0x0ec835e8) /* 0.923879533 */, - MAD_F(0x0cb19346) /* 0.793353340 */, MAD_F(0x09bd7ca0) /* 0.608761429 */, - MAD_F(0x061f78aa) /* 0.382683432 */, MAD_F(0x0216a2a2) /* 0.130526192 */, -}; - -/* - * coefficients for intensity stereo processing - * derived from section 2.4.3.4.9.3 of ISO/IEC 11172-3 - * - * is_ratio[i] = tan(i * (PI / 12)) - * is_table[i] = is_ratio[i] / (1 + is_ratio[i]) - */ -static -mad_fixed_t const is_table[7] = { - MAD_F(0x00000000) /* 0.000000000 */, - MAD_F(0x0361962f) /* 0.211324865 */, - MAD_F(0x05db3d74) /* 0.366025404 */, - MAD_F(0x08000000) /* 0.500000000 */, - MAD_F(0x0a24c28c) /* 0.633974596 */, - MAD_F(0x0c9e69d1) /* 0.788675135 */, - MAD_F(0x10000000) /* 1.000000000 */ -}; - -/* - * coefficients for LSF intensity stereo processing - * derived from section 2.4.3.2 of ISO/IEC 13818-3 - * - * is_lsf_table[0][i] = (1 / sqrt(sqrt(2)))^(i + 1) - * is_lsf_table[1][i] = (1 / sqrt(2)) ^(i + 1) - */ -static -mad_fixed_t const is_lsf_table[2][15] = { - { - MAD_F(0x0d744fcd) /* 0.840896415 */, - MAD_F(0x0b504f33) /* 0.707106781 */, - MAD_F(0x09837f05) /* 0.594603558 */, - MAD_F(0x08000000) /* 0.500000000 */, - MAD_F(0x06ba27e6) /* 0.420448208 */, - MAD_F(0x05a8279a) /* 0.353553391 */, - MAD_F(0x04c1bf83) /* 0.297301779 */, - MAD_F(0x04000000) /* 0.250000000 */, - MAD_F(0x035d13f3) /* 0.210224104 */, - MAD_F(0x02d413cd) /* 0.176776695 */, - MAD_F(0x0260dfc1) /* 0.148650889 */, - MAD_F(0x02000000) /* 0.125000000 */, - MAD_F(0x01ae89fa) /* 0.105112052 */, - MAD_F(0x016a09e6) /* 0.088388348 */, - MAD_F(0x01306fe1) /* 0.074325445 */ - }, { - MAD_F(0x0b504f33) /* 0.707106781 */, - MAD_F(0x08000000) /* 0.500000000 */, - MAD_F(0x05a8279a) /* 0.353553391 */, - MAD_F(0x04000000) /* 0.250000000 */, - MAD_F(0x02d413cd) /* 0.176776695 */, - MAD_F(0x02000000) /* 0.125000000 */, - MAD_F(0x016a09e6) /* 0.088388348 */, - MAD_F(0x01000000) /* 0.062500000 */, - MAD_F(0x00b504f3) /* 0.044194174 */, - MAD_F(0x00800000) /* 0.031250000 */, - MAD_F(0x005a827a) /* 0.022097087 */, - MAD_F(0x00400000) /* 0.015625000 */, - MAD_F(0x002d413d) /* 0.011048543 */, - MAD_F(0x00200000) /* 0.007812500 */, - MAD_F(0x0016a09e) /* 0.005524272 */ - } -}; - -/* - * NAME: III_sideinfo() - * DESCRIPTION: decode frame side information from a bitstream - */ -static -enum mad_error III_sideinfo(struct mad_bitptr *ptr, unsigned int nch, - int lsf, struct sideinfo *si, - unsigned int *data_bitlen, - unsigned int *priv_bitlen) -{ - unsigned int ngr, gr, ch, i; - enum mad_error result = MAD_ERROR_NONE; - - *data_bitlen = 0; - *priv_bitlen = lsf ? ((nch == 1) ? 1 : 2) : ((nch == 1) ? 5 : 3); - - si->main_data_begin = mad_bit_read(ptr, lsf ? 8 : 9); - si->private_bits = mad_bit_read(ptr, *priv_bitlen); - - ngr = 1; - if (!lsf) { - ngr = 2; - - for (ch = 0; ch < nch; ++ch) - si->scfsi[ch] = mad_bit_read(ptr, 4); - } - - for (gr = 0; gr < ngr; ++gr) { - struct granule *granule = &si->gr[gr]; - - for (ch = 0; ch < nch; ++ch) { - struct channel *channel = &granule->ch[ch]; - - channel->part2_3_length = mad_bit_read(ptr, 12); - channel->big_values = mad_bit_read(ptr, 9); - channel->global_gain = mad_bit_read(ptr, 8); - channel->scalefac_compress = mad_bit_read(ptr, lsf ? 9 : 4); - - *data_bitlen += channel->part2_3_length; - - if (channel->big_values > 288 && result == 0) - result = MAD_ERROR_BADBIGVALUES; - - channel->flags = 0; - - /* window_switching_flag */ - if (mad_bit_read(ptr, 1)) { - channel->block_type = mad_bit_read(ptr, 2); - - if (channel->block_type == 0 && result == 0) - result = MAD_ERROR_BADBLOCKTYPE; - - if (!lsf && channel->block_type == 2 && si->scfsi[ch] && result == 0) - result = MAD_ERROR_BADSCFSI; - - channel->region0_count = 7; - channel->region1_count = 36; - - if (mad_bit_read(ptr, 1)) - channel->flags |= mixed_block_flag; - else if (channel->block_type == 2) - channel->region0_count = 8; - - for (i = 0; i < 2; ++i) - channel->table_select[i] = mad_bit_read(ptr, 5); - -# if defined(DEBUG) - channel->table_select[2] = 4; /* not used */ -# endif - - for (i = 0; i < 3; ++i) - channel->subblock_gain[i] = mad_bit_read(ptr, 3); - } - else { - channel->block_type = 0; - - for (i = 0; i < 3; ++i) - channel->table_select[i] = mad_bit_read(ptr, 5); - - channel->region0_count = mad_bit_read(ptr, 4); - channel->region1_count = mad_bit_read(ptr, 3); - } - - /* [preflag,] scalefac_scale, count1table_select */ - channel->flags |= mad_bit_read(ptr, lsf ? 2 : 3); - } - } - - return result; -} - -/* - * NAME: III_scalefactors_lsf() - * DESCRIPTION: decode channel scalefactors for LSF from a bitstream - */ -static -unsigned int III_scalefactors_lsf(struct mad_bitptr *ptr, - struct channel *channel, - struct channel *gr1ch, int mode_extension) -{ - struct mad_bitptr start; - unsigned int scalefac_compress, index, slen[4], part, n, i; - unsigned char const *nsfb; - - start = *ptr; - - scalefac_compress = channel->scalefac_compress; - index = (channel->block_type == 2) ? - ((channel->flags & mixed_block_flag) ? 2 : 1) : 0; - - if (!((mode_extension & I_STEREO) && gr1ch)) { - if (scalefac_compress < 400) { - slen[0] = (scalefac_compress >> 4) / 5; - slen[1] = (scalefac_compress >> 4) % 5; - slen[2] = (scalefac_compress % 16) >> 2; - slen[3] = scalefac_compress % 4; - - nsfb = nsfb_table[0][index]; - } - else if (scalefac_compress < 500) { - scalefac_compress -= 400; - - slen[0] = (scalefac_compress >> 2) / 5; - slen[1] = (scalefac_compress >> 2) % 5; - slen[2] = scalefac_compress % 4; - slen[3] = 0; - - nsfb = nsfb_table[1][index]; - } - else { - scalefac_compress -= 500; - - slen[0] = scalefac_compress / 3; - slen[1] = scalefac_compress % 3; - slen[2] = 0; - slen[3] = 0; - - channel->flags |= preflag; - - nsfb = nsfb_table[2][index]; - } - - n = 0; - for (part = 0; part < 4; ++part) { - for (i = 0; i < nsfb[part]; ++i) - channel->scalefac[n++] = mad_bit_read(ptr, slen[part]); - } - - while (n < 39) - channel->scalefac[n++] = 0; - } - else { /* (mode_extension & I_STEREO) && gr1ch (i.e. ch == 1) */ - scalefac_compress >>= 1; - - if (scalefac_compress < 180) { - slen[0] = scalefac_compress / 36; - slen[1] = (scalefac_compress % 36) / 6; - slen[2] = (scalefac_compress % 36) % 6; - slen[3] = 0; - - nsfb = nsfb_table[3][index]; - } - else if (scalefac_compress < 244) { - scalefac_compress -= 180; - - slen[0] = (scalefac_compress % 64) >> 4; - slen[1] = (scalefac_compress % 16) >> 2; - slen[2] = scalefac_compress % 4; - slen[3] = 0; - - nsfb = nsfb_table[4][index]; - } - else { - scalefac_compress -= 244; - - slen[0] = scalefac_compress / 3; - slen[1] = scalefac_compress % 3; - slen[2] = 0; - slen[3] = 0; - - nsfb = nsfb_table[5][index]; - } - - n = 0; - for (part = 0; part < 4; ++part) { - unsigned int max, is_pos; - - max = (1 << slen[part]) - 1; - - for (i = 0; i < nsfb[part]; ++i) { - is_pos = mad_bit_read(ptr, slen[part]); - - channel->scalefac[n] = is_pos; - gr1ch->scalefac[n++] = (is_pos == max); - } - } - - while (n < 39) { - channel->scalefac[n] = 0; - gr1ch->scalefac[n++] = 0; /* apparently not illegal */ - } - } - - return mad_bit_length(&start, ptr); -} - -/* - * NAME: III_scalefactors() - * DESCRIPTION: decode channel scalefactors of one granule from a bitstream - */ -static -unsigned int III_scalefactors(struct mad_bitptr *ptr, struct channel *channel, - struct channel const *gr0ch, unsigned int scfsi) -{ - struct mad_bitptr start; - unsigned int slen1, slen2, sfbi; - - start = *ptr; - - slen1 = sflen_table[channel->scalefac_compress].slen1; - slen2 = sflen_table[channel->scalefac_compress].slen2; - - if (channel->block_type == 2) { - unsigned int nsfb; - - sfbi = 0; - - nsfb = (channel->flags & mixed_block_flag) ? 8 + 3 * 3 : 6 * 3; - while (nsfb--) - channel->scalefac[sfbi++] = mad_bit_read(ptr, slen1); - - nsfb = 6 * 3; - while (nsfb--) - channel->scalefac[sfbi++] = mad_bit_read(ptr, slen2); - - nsfb = 1 * 3; - while (nsfb--) - channel->scalefac[sfbi++] = 0; - } - else { /* channel->block_type != 2 */ - if (scfsi & 0x8) { - for (sfbi = 0; sfbi < 6; ++sfbi) - channel->scalefac[sfbi] = gr0ch->scalefac[sfbi]; - } - else { - for (sfbi = 0; sfbi < 6; ++sfbi) - channel->scalefac[sfbi] = mad_bit_read(ptr, slen1); - } - - if (scfsi & 0x4) { - for (sfbi = 6; sfbi < 11; ++sfbi) - channel->scalefac[sfbi] = gr0ch->scalefac[sfbi]; - } - else { - for (sfbi = 6; sfbi < 11; ++sfbi) - channel->scalefac[sfbi] = mad_bit_read(ptr, slen1); - } - - if (scfsi & 0x2) { - for (sfbi = 11; sfbi < 16; ++sfbi) - channel->scalefac[sfbi] = gr0ch->scalefac[sfbi]; - } - else { - for (sfbi = 11; sfbi < 16; ++sfbi) - channel->scalefac[sfbi] = mad_bit_read(ptr, slen2); - } - - if (scfsi & 0x1) { - for (sfbi = 16; sfbi < 21; ++sfbi) - channel->scalefac[sfbi] = gr0ch->scalefac[sfbi]; - } - else { - for (sfbi = 16; sfbi < 21; ++sfbi) - channel->scalefac[sfbi] = mad_bit_read(ptr, slen2); - } - - channel->scalefac[21] = 0; - } - - return mad_bit_length(&start, ptr); -} - -/* - * The Layer III formula for requantization and scaling is defined by - * section 2.4.3.4.7.1 of ISO/IEC 11172-3, as follows: - * - * long blocks: - * xr[i] = sign(is[i]) * abs(is[i])^(4/3) * - * 2^((1/4) * (global_gain - 210)) * - * 2^-(scalefac_multiplier * - * (scalefac_l[sfb] + preflag * pretab[sfb])) - * - * short blocks: - * xr[i] = sign(is[i]) * abs(is[i])^(4/3) * - * 2^((1/4) * (global_gain - 210 - 8 * subblock_gain[w])) * - * 2^-(scalefac_multiplier * scalefac_s[sfb][w]) - * - * where: - * scalefac_multiplier = (scalefac_scale + 1) / 2 - * - * The routines III_exponents() and III_requantize() facilitate this - * calculation. - */ - -/* - * NAME: III_exponents() - * DESCRIPTION: calculate scalefactor exponents - */ -static -void III_exponents(struct channel const *channel, - unsigned char const *sfbwidth, signed int exponents[39]) -{ - signed int gain; - unsigned int scalefac_multiplier, sfbi; - - gain = (signed int) channel->global_gain - 210; - scalefac_multiplier = (channel->flags & scalefac_scale) ? 2 : 1; - - if (channel->block_type == 2) { - unsigned int l; - signed int gain0, gain1, gain2; - - sfbi = l = 0; - - if (channel->flags & mixed_block_flag) { - unsigned int premask; - - premask = (channel->flags & preflag) ? ~0 : 0; - - /* long block subbands 0-1 */ - - while (l < 36) { - exponents[sfbi] = gain - - (signed int) ((channel->scalefac[sfbi] + (pretab[sfbi] & premask)) << - scalefac_multiplier); - - l += sfbwidth[sfbi++]; - } - } - - /* this is probably wrong for 8000 Hz short/mixed blocks */ - - gain0 = gain - 8 * (signed int) channel->subblock_gain[0]; - gain1 = gain - 8 * (signed int) channel->subblock_gain[1]; - gain2 = gain - 8 * (signed int) channel->subblock_gain[2]; - - while (l < 576) { - exponents[sfbi + 0] = gain0 - - (signed int) (channel->scalefac[sfbi + 0] << scalefac_multiplier); - exponents[sfbi + 1] = gain1 - - (signed int) (channel->scalefac[sfbi + 1] << scalefac_multiplier); - exponents[sfbi + 2] = gain2 - - (signed int) (channel->scalefac[sfbi + 2] << scalefac_multiplier); - unsigned int w = sfbwidth[sfbi]; - l += 3 * w; - sfbi += 3; - } - } - else { /* channel->block_type != 2 */ - if (channel->flags & preflag) { - for (sfbi = 0; sfbi < 22; ++sfbi) { - exponents[sfbi] = gain - - (signed int) ((channel->scalefac[sfbi] + pretab[sfbi]) << - scalefac_multiplier); - } - } - else { - for (sfbi = 0; sfbi < 22; ++sfbi) { - exponents[sfbi] = gain - - (signed int) (channel->scalefac[sfbi] << scalefac_multiplier); - } - } - } -} - -/* - * NAME: III_requantize() - * DESCRIPTION: requantize one (positive) value - */ -static -mad_fixed_t III_requantize(unsigned int value, signed int exp) -{ - mad_fixed_t requantized; - signed int frac; - unsigned long power; - - frac = exp % 4; /* assumes sign(frac) == sign(exp) */ - exp /= 4; - - /* format rq_table: bit31-27=exponent bit26-0=mantissa */ - power = rq_table[value]; - requantized = power & 0x07ffffff; - exp += power >> 27; - - if (exp < 0) { - if (-exp >= (signed int) (sizeof(mad_fixed_t) * CHAR_BIT)) { - /* underflow */ - requantized = 0; - } - else { - requantized += 1L << (-exp - 1); - requantized >>= -exp; - } - } - else { - if (exp >= 5) { - /* overflow */ -# if defined(DEBUG) - fprintf(stderr, "requantize overflow (%f * 2^%d)\n", - mad_f_todouble(requantized), exp); -# endif - requantized = MAD_F_MAX; - } - else - requantized <<= exp; - } - - return frac ? mad_f_mul(requantized, root_table[3 + frac]) : requantized; -} - -/* we must take care that sz >= bits and sz < sizeof(long) lest bits == 0 */ -# if defined(CPU_ARM) -# define MASK(cache, sz, bits) \ - ({ unsigned long res; \ - asm ("mov %0, #1\n\t" \ - "rsb %0, %0, %0, lsl %3\n\t" \ - "and %0, %0, %1, lsr %2" \ - : "=&r" (res) : "r" (cache), "r" ((sz) - (bits)), "r" (bits)); \ - res; \ - }) -#else -# define MASK(cache, sz, bits) \ - (((cache) >> ((sz) - (bits))) & ((1 << (bits)) - 1)) -#endif -# define MASK1BIT(cache, sz) \ - ((cache) & (1 << ((sz) - 1))) - -/* - * NAME: III_huffdecode() - * DESCRIPTION: decode Huffman code words of one channel of one granule - */ -static -enum mad_error III_huffdecode(struct mad_bitptr *ptr, mad_fixed_t xrarr[576], - struct channel *channel, - unsigned char const *sfbwidth, - unsigned int part2_length) -{ - unsigned int bits; - signed int exponents[39], exp; - signed int const *expptr; - struct mad_bitptr peek; - signed int bits_left, cachesz; - register mad_fixed_t *xr; - mad_fixed_t const *sfbound; - register unsigned long bitcache; - - bits_left = (signed) channel->part2_3_length - (signed) part2_length; - if (bits_left < 0) - return MAD_ERROR_BADPART3LEN; - - III_exponents(channel, sfbwidth, exponents); - - peek = *ptr; - cachesz = 0; - sfbound = xr = xrarr; - mad_bit_skip(ptr, bits_left); - - /* big_values */ - { - int region; - struct hufftable const *entry; - union huffpair const *table; - unsigned int linbits, startbits, rcount; - mad_fixed_t reqcache[16]; - mad_fixed_t const *xr_end, *xr_big_val; - - rcount = 1; - expptr = &exponents[0]; - region = -1; - exp = 0x3210; /* start value */ - bitcache = 0; - linbits = startbits = 0; - table = NULL; - xr_big_val = xr + 2 * channel->big_values; - - while(xr < xr_big_val) - { - sfbound += *sfbwidth++; - xr_end = sfbound > xr_big_val ? xr_big_val : sfbound; - - /* change table if region boundary */ - if(--rcount == 0) - { - if(exp == 0x3210) - rcount = channel->region0_count + 1; - else - if(region == 0) - rcount = channel->region1_count + 1; - else - rcount = 0; /* all remaining */ - - entry = &mad_huff_pair_table[channel->table_select[++region]]; - table = entry->table; - linbits = entry->linbits; - startbits = entry->startbits; - - if(table == 0) - return MAD_ERROR_BADHUFFTABLE; - } - - if(exp != *expptr) - { - exp = *expptr; - /* clear cache */ - memset(reqcache, 0, sizeof(reqcache)); - } - - ++expptr; - - if(linbits) - { - for( ; xrfinal) - { - cachesz -= clumpsz; - clumpsz = pair->ptr.bits; - pair = &table[pair->ptr.offset + MASK(bitcache, cachesz, clumpsz)]; - } - - cachesz -= pair->value.hlen; - - /* x (0..14) */ - value = pair->value.x; - if(value == 0) - xr[0] = 0; - else - { - if(value == 15) - { - /* maxlinbits=13bit + sign(x,y)=2bit */ - if(cachesz < 15) - { - if(cachesz < 0) - return MAD_ERROR_BADHUFFDATA; /* cache underrun */ - - bits = MAXLSHIFT - cachesz; - bitcache = (bitcache << bits) | mad_bit_read(&peek, bits); - cachesz += bits; - } - - requantized = III_requantize(15+MASK(bitcache, cachesz, linbits), exp); - cachesz -= linbits; - } - else - { - if(reqcache[value]) - requantized = reqcache[value]; - else - requantized = reqcache[value] = III_requantize(value, exp); - } - - xr[0] = MASK1BIT(bitcache, cachesz--) ? -requantized : requantized; - } - - /* y (0..14) */ - value = pair->value.y; - if(value == 0) - xr[1] = 0; - else - { - if(value == 15) - { - /* maxlinbits=13bit + sign(y)=1bit */ - if(cachesz < 14) - { - if(cachesz < 0) - return MAD_ERROR_BADHUFFDATA; /* cache underrun */ - - bits = MAXLSHIFT - cachesz; - bitcache = (bitcache << bits) | mad_bit_read(&peek, bits); - cachesz += bits; - } - - requantized = III_requantize(15+MASK(bitcache, cachesz, linbits), exp); - cachesz -= linbits; - } - else - { - if(reqcache[value]) - requantized = reqcache[value]; - else - requantized = reqcache[value] = III_requantize(value, exp); - } - xr[1] = MASK1BIT(bitcache, cachesz--) ? -requantized : requantized; - } - } - } - else - { - for( ; xrfinal) - { - cachesz -= clumpsz; - - /* maxlookup=4bit + sign(x,y)=2bit */ - if(cachesz < 6) - { - if(cachesz < 0) - return MAD_ERROR_BADHUFFDATA; /* cache underrun */ - - bits = MAXLSHIFT - cachesz; - bitcache = (bitcache << bits) | mad_bit_read(&peek, bits); - cachesz += bits; - } - - clumpsz = pair->ptr.bits; - pair = &table[pair->ptr.offset + MASK(bitcache, cachesz, clumpsz)]; - } - - cachesz -= pair->value.hlen; - - /* x (0..1) */ - value = pair->value.x; - if(value == 0) - xr[0] = 0; - else - { - if(reqcache[value]) - requantized = reqcache[value]; - else - requantized = reqcache[value] = III_requantize(value, exp); - - xr[0] = MASK1BIT(bitcache, cachesz--) ? -requantized : requantized; - } - - /* y (0..1) */ - value = pair->value.y; - if(value == 0) - xr[1] = 0; - else - { - if(reqcache[value]) - requantized = reqcache[value]; - else - requantized = reqcache[value] = III_requantize(value, exp); - - xr[1] = MASK1BIT(bitcache, cachesz--) ? -requantized : requantized; - } - } - } - } - } - - bits_left = ptr->readbit - peek.readbit; - - if(bits_left + cachesz < 0) - return MAD_ERROR_BADHUFFDATA; /* big_values overrun */ - - /* count1 */ - { - union huffquad const *table; - register mad_fixed_t requantized; - - table = mad_huff_quad_table[channel->flags & count1table_select]; - - requantized = III_requantize(1, exp); - - while(xr <= &xrarr[572] && bits_left + cachesz > 0) - { - union huffquad const *quad; - - /* hcod (1..6) */ - if(cachesz < 10) - { - if(cachesz < 0) - return MAD_ERROR_BADHUFFDATA; /* cache underrun */ - - bits = MAXLSHIFT - cachesz; - bitcache = (bitcache << bits) | mad_bit_read(&peek, bits); - cachesz += bits; - bits_left -= bits; - } - - quad = &table[MASK(bitcache, cachesz, 4)]; - - /* quad tables guaranteed to have at most one extra lookup */ - if (!quad->final) { - cachesz -= 4; - - quad = &table[quad->ptr.offset + - MASK(bitcache, cachesz, quad->ptr.bits)]; - } - - cachesz -= quad->value.hlen; - - if (xr == sfbound) { - sfbound += *sfbwidth++; - - if (exp != *expptr) { - exp = *expptr; - requantized = III_requantize(1, exp); - } - - ++expptr; - } - - /* v (0..1) */ - xr[0] = quad->value.v ? - (MASK1BIT(bitcache, cachesz--) ? -requantized : requantized) : 0; - - /* w (0..1) */ - xr[1] = quad->value.w ? - (MASK1BIT(bitcache, cachesz--) ? -requantized : requantized) : 0; - - xr += 2; - - if (xr == sfbound) { - sfbound += *sfbwidth++; - - if (exp != *expptr) { - exp = *expptr; - requantized = III_requantize(1, exp); - } - - ++expptr; - } - - /* x (0..1) */ - xr[0] = quad->value.x ? - (MASK1BIT(bitcache, cachesz--) ? -requantized : requantized) : 0; - - /* y (0..1) */ - xr[1] = quad->value.y ? - (MASK1BIT(bitcache, cachesz--) ? -requantized : requantized) : 0; - - xr += 2; - } - - if(bits_left + cachesz < 0) - { - /* technically the bitstream is misformatted, but apparently - some encoders are just a bit sloppy with stuffing bits */ - xr -= 4; - } - } - - /* rzero */ - memset(xr, 0, (char*)&xrarr[576] - (char*)xr); - - return MAD_ERROR_NONE; -} - -# undef MASK -# undef MASK1BIT - -/* - * NAME: III_reorder() - * DESCRIPTION: reorder frequency lines of a short block into subband order - */ -static -void III_reorder(mad_fixed_t xr[576], struct channel const *channel, - unsigned char const sfbwidth[39]) -{ - mad_fixed_t tmp[32][3][6]; - unsigned int sb, l, f, w, sbw[3], sw[3]; - - /* this is probably wrong for 8000 Hz mixed blocks */ - - sb = 0; - if (channel->flags & mixed_block_flag) { - sb = 2; - - l = 0; - while (l < 36) - l += *sfbwidth++; - } - - for (w = 0; w < 3; ++w) { - sbw[w] = sb; - sw[w] = 0; - } - - f = *sfbwidth++; - w = 0; - - for (l = 18 * sb; l < 576; ++l) { - if (f-- == 0) { - f = *sfbwidth++ - 1; - w = (w + 1) % 3; - } - - unsigned int sbww = sbw[w]; - tmp[sbww][w][sw[w]++] = xr[l]; - - if (sw[w] == 6) { - sw[w] = 0; - ++sbw[w]; - } - } - - memcpy(&xr[18 * sb], &tmp[sb], (576 - 18 * sb) * sizeof(mad_fixed_t)); -} - -/* - * NAME: III_stereo() - * DESCRIPTION: perform joint stereo processing on a granule - */ -static -enum mad_error III_stereo(mad_fixed_t xr[2][576], - struct granule const *granule, - struct mad_header *header, - unsigned char const *sfbwidth) -{ - short modes[39]; - unsigned int sfbi, l, n, i; - - if (granule->ch[0].block_type != - granule->ch[1].block_type || - (granule->ch[0].flags & mixed_block_flag) != - (granule->ch[1].flags & mixed_block_flag)) - return MAD_ERROR_BADSTEREO; - - for (i = 0; i < 39; ++i) - modes[i] = header->mode_extension; - - /* intensity stereo */ - - if (header->mode_extension & I_STEREO) { - struct channel const *right_ch = &granule->ch[1]; - mad_fixed_t const *right_xr = xr[1]; - unsigned int is_pos; - - header->flags |= MAD_FLAG_I_STEREO; - - /* first determine which scalefactor bands are to be processed */ - - if (right_ch->block_type == 2) { - unsigned int lower, start, max, bound[3], w; - - lower = start = max = bound[0] = bound[1] = bound[2] = 0; - - sfbi = l = 0; - - if (right_ch->flags & mixed_block_flag) { - while (l < 36) { - n = sfbwidth[sfbi++]; - - for (i = 0; i < n; ++i) { - if (right_xr[i]) { - lower = sfbi; - break; - } - } - - right_xr += n; - l += n; - } - - start = sfbi; - } - - w = 0; - while (l < 576) { - n = sfbwidth[sfbi++]; - - for (i = 0; i < n; ++i) { - if (right_xr[i]) { - max = bound[w] = sfbi; - break; - } - } - - right_xr += n; - l += n; - w = (w + 1) % 3; - } - - if (max) - lower = start; - - /* long blocks */ - - for (i = 0; i < lower; ++i) - modes[i] = header->mode_extension & ~I_STEREO; - - /* short blocks */ - - w = 0; - for (i = start; i < max; ++i) { - if (i < bound[w]) - modes[i] = header->mode_extension & ~I_STEREO; - - w = (w + 1) % 3; - } - } - else { /* right_ch->block_type != 2 */ - unsigned int bound; - - bound = 0; - for (sfbi = l = 0; l < 576; l += n) { - n = sfbwidth[sfbi++]; - - for (i = 0; i < n; ++i) { - if (right_xr[i]) { - bound = sfbi; - break; - } - } - - right_xr += n; - } - - for (i = 0; i < bound; ++i) - modes[i] = header->mode_extension & ~I_STEREO; - } - - /* now do the actual processing */ - - if (header->flags & MAD_FLAG_LSF_EXT) { - unsigned char const *illegal_pos = granule[1].ch[1].scalefac; - mad_fixed_t const *lsf_scale; - - /* intensity_scale */ - lsf_scale = is_lsf_table[right_ch->scalefac_compress & 0x1]; - - for (sfbi = l = 0; l < 576; ++sfbi, l += n) { - n = sfbwidth[sfbi]; - - if (!(modes[sfbi] & I_STEREO)) - continue; - - if (illegal_pos[sfbi]) { - modes[sfbi] &= ~I_STEREO; - continue; - } - - is_pos = right_ch->scalefac[sfbi]; - - for (i = 0; i < n; ++i) { - register mad_fixed_t left; - - left = xr[0][l + i]; - - if (is_pos == 0) - xr[1][l + i] = left; - else { - register mad_fixed_t opposite; - - opposite = mad_f_mul(left, lsf_scale[(is_pos - 1) / 2]); - - if (is_pos & 1) { - xr[0][l + i] = opposite; - xr[1][l + i] = left; - } - else - xr[1][l + i] = opposite; - } - } - } - } - else { /* !(header->flags & MAD_FLAG_LSF_EXT) */ - for (sfbi = l = 0; l < 576; ++sfbi, l += n) { - n = sfbwidth[sfbi]; - - if (!(modes[sfbi] & I_STEREO)) - continue; - - is_pos = right_ch->scalefac[sfbi]; - - if (is_pos >= 7) { /* illegal intensity position */ - modes[sfbi] &= ~I_STEREO; - continue; - } - - for (i = 0; i < n; ++i) { - register mad_fixed_t left; - - left = xr[0][l + i]; - - xr[0][l + i] = mad_f_mul(left, is_table[ is_pos]); - xr[1][l + i] = mad_f_mul(left, is_table[6 - is_pos]); - } - } - } - } - - /* middle/side stereo */ - - if (header->mode_extension & MS_STEREO) { - register mad_fixed_t invsqrt2; - - header->flags |= MAD_FLAG_MS_STEREO; - - invsqrt2 = root_table[3 + -2]; - - for (sfbi = l = 0; l < 576; ++sfbi, l += n) { - n = sfbwidth[sfbi]; - - if (modes[sfbi] != MS_STEREO) - continue; - - for (i = 0; i < n; ++i) { - register mad_fixed_t m, s; - - m = xr[0][l + i]; - s = xr[1][l + i]; - - xr[0][l + i] = mad_f_mul(m + s, invsqrt2); /* l = (m + s) / sqrt(2) */ - xr[1][l + i] = mad_f_mul(m - s, invsqrt2); /* r = (m - s) / sqrt(2) */ - } - } - } - - return MAD_ERROR_NONE; -} - -#if defined(CPU_ARM) -void III_aliasreduce(mad_fixed_t xr[576], int lines); -#else -/* - * NAME: III_aliasreduce() - * DESCRIPTION: perform frequency line alias reduction - */ -static -void III_aliasreduce(mad_fixed_t xr[576], int lines) -{ - mad_fixed_t const *bound; - int i; - - bound = &xr[lines]; - for (xr += 18; xr < bound; xr += 18) { - for (i = 0; i < 8; ++i) { - register mad_fixed_t a, b; - register mad_fixed64hi_t hi; - register mad_fixed64lo_t lo; - - a = xr[-1 - i]; - b = xr[ i]; - -# if defined(CPU_COLDFIRE) - (void)hi, (void)lo; - asm volatile ("mac.l %[a], %[csi], %%acc0\n\t" - "msac.l %[b], %[cai], %%acc0\n\t" - "mac.l %[b], %[csi], %%acc1\n\t" - "mac.l %[a], %[cai], %%acc1\n\t" - "movclr.l %%acc0, %[a]\n\t" - "asl.l #3, %[a]\n\t" - "movclr.l %%acc1, %[b]\n\t" - "asl.l #3, %[b]\n\t" - : [a] "+d" (a), [b] "+d" (b) - : [csi] "r" (cs[i]), [cai] "r" (ca[i])); - xr[-1 - i] = a; - xr[ i] = b; -# else - MAD_F_ML0(hi, lo, a, cs[i]); - MAD_F_MLA(hi, lo, -b, ca[i]); - - xr[-1 - i] = MAD_F_MLZ(hi, lo); - - MAD_F_ML0(hi, lo, b, cs[i]); - MAD_F_MLA(hi, lo, a, ca[i]); - - xr[ i] = MAD_F_MLZ(hi, lo); -# endif - } - } -} -#endif - -# if defined(FPM_ARM) -void III_imdct_l(mad_fixed_t const [18], mad_fixed_t [36], unsigned int); -# else -/* - * NAME: imdct36 - * DESCRIPTION: perform X[18]->x[36] IMDCT - */ -# if defined(CPU_COLDFIRE) -/* emac optimized imdct36, it is very ugly and i hope to replace it soon. - * for now it is actually somewhat faster than the stock implementation. - */ -static inline -void imdct36(mad_fixed_t const X[18], mad_fixed_t x[36]) -{ - mad_fixed_t t[16]; - /* assumes FRACBITS = 28 */ - asm volatile ( - /* MAD_F_ML0(hi, lo, X[4], MAD_F(0x0ec835e8)); */ - /* MAD_F_MLA(hi, lo, X[13], MAD_F(0x061f78aa)); */ - /* t6 = MAD_F_MLZ(hi, lo); */ - "move.l (4*4, %[X]), %%d0\n" - "move.l #0x0ec835e8, %%d1\n" - "move.l #0x061f78aa, %%d2\n" - "mac.l %%d1, %%d0, (13*4, %[X]), %%d0, %%acc0\n" - "mac.l %%d2, %%d0, ( 1*4, %[X]), %%d0, %%acc0\n" - "move.l %%acc0, %%d7\n" - "asl.l #3, %%d7\n" - "move.l %%d7, (6*4, %[t])\n" - - /* MAD_F_ML0(hi, lo, (t14 = X[1] - X[10]), -MAD_F(0x0ec835e8)); */ - /* MAD_F_MLA(hi, lo, (t15 = X[7] + X[16]), MAD_F(0x061f78aa)); */ - /* t4 = MAD_F_MLZ(hi, lo); */ - /* MAD_F_MLA(hi, lo, t14, -MAD_F(0x061f78aa)); */ - /* MAD_F_MLA(hi, lo, t15, -MAD_F(0x0ec835e8)); */ - /* t0 = MAD_F_MLZ(hi, lo); */ - "sub.l (10*4, %[X]), %%d0\n" /* t14 */ - "msac.l %%d0, %%d1, %%acc1\n" - "msac.l %%d0, %%d2, (7*4, %[X]), %%d5, %%acc0\n" - "add.l (16*4, %[X]), %%d5\n" /* t15 */ - "mac.l %%d5, %%d2, %%acc1\n" - "msac.l %%d5, %%d1, ( %[X]), %%d5, %%acc0\n" - "movclr.l %%acc1, %%d6\n" - "asl.l #3, %%d6\n" /* t4 */ - "move.l %%d6, (4*4, %[t])\n" - "move.l %%acc0, %%d0\n" - "asl.l #3, %%d0\n" /* t0 */ - "move.l %%d0, (0*4, %[t])\n" - - /* MAD_F_MLA(hi, lo, (t8 =X[0]-X[11]-X[12]), MAD_F(0x0216a2a2)); */ - /* MAD_F_MLA(hi, lo, (t9 =X[2]-X[ 9]-X[14]), MAD_F(0x09bd7ca0)); */ - /* MAD_F_MLA(hi, lo, (t10=X[3]-X[ 8]-X[15]), -MAD_F(0x0cb19346)); */ - /* MAD_F_MLA(hi, lo, (t11=X[5]-X[ 6]-X[17]), -MAD_F(0x0fdcf549)); */ - /* x[10] = -(x[7] = MAD_F_MLZ(hi, lo)); */ - - /* MAD_F_ML0(hi, lo, t8, -MAD_F(0x0cb19346)); */ - /* MAD_F_MLA(hi, lo, t9, MAD_F(0x0fdcf549)); */ - /* MAD_F_MLA(hi, lo, t10, MAD_F(0x0216a2a2)); */ - /* MAD_F_MLA(hi, lo, t11, -MAD_F(0x09bd7ca0)); */ - /* x[19] = x[34] = MAD_F_MLZ(hi, lo) - t0; */ - - /* MAD_F_ML0(hi, lo, t8, MAD_F(0x09bd7ca0)); */ - /* MAD_F_MLA(hi, lo, t9, -MAD_F(0x0216a2a2)); */ - /* MAD_F_MLA(hi, lo, t10, MAD_F(0x0fdcf549)); */ - /* MAD_F_MLA(hi, lo, t11, -MAD_F(0x0cb19346)); */ - /* x[ 1] = MAD_F_MLZ(hi, lo); */ - - /* MAD_F_ML0(hi, lo, t8, -MAD_F(0x0fdcf549)); */ - /* MAD_F_MLA(hi, lo, t9, -MAD_F(0x0cb19346)); */ - /* MAD_F_MLA(hi, lo, t10, -MAD_F(0x09bd7ca0)); */ - /* MAD_F_MLA(hi, lo, t11, -MAD_F(0x0216a2a2)); */ - /* x[25] = MAD_F_MLZ(hi, lo); */ - - /* t12 = t8 - t10; */ - /* t13 = t9 + t11; */ - "move.l #0x0216a2a2, %%d1\n" - "move.l #0x0cb19346, %%d2\n" - "move.l #0x09bd7ca0, %%d3\n" - "move.l #0x0fdcf549, %%d4\n" - "sub.l (11*4, %[X]), %%d5\n" - "sub.l (12*4, %[X]), %%d5\n" - "mac.l %%d1, %%d5, %%acc0\n" - "msac.l %%d2, %%d5, %%acc1\n" - "mac.l %%d3, %%d5, %%acc2\n" - "msac.l %%d4, %%d5, (2*4, %[X]), %%d6, %%acc3\n" - "sub.l ( 9*4, %[X]), %%d6\n" - "sub.l (14*4, %[X]), %%d6\n" - "mac.l %%d3, %%d6, %%acc0\n" - "mac.l %%d4, %%d6, %%acc1\n" - "msac.l %%d1, %%d6, %%acc2\n" - "msac.l %%d2, %%d6, (3*4, %[X]), %%d7, %%acc3\n" - "sub.l ( 8*4, %[X]), %%d7\n" - "sub.l (15*4, %[X]), %%d7\n" - "sub.l %%d7, %%d5\n" /* d5: t12 */ - "move.l %%d5, (12*4, %[t])\n" - "msac.l %%d2, %%d7, %%acc0\n" - "mac.l %%d1, %%d7, %%acc1\n" - "mac.l %%d4, %%d7, %%acc2\n" - "msac.l %%d3, %%d7, (5*4, %[X]), %%d7, %%acc3\n" - "sub.l ( 6*4, %[X]), %%d7\n" - "sub.l (17*4, %[X]), %%d7\n" - "add.l %%d7, %%d6\n" /* d6: t13 */ - "move.l %%d6, (13*4, %[t])\n" - "msac.l %%d4, %%d7, %%acc0\n" - "msac.l %%d3, %%d7, %%acc1\n" - "msac.l %%d2, %%d7, %%acc2\n" - "msac.l %%d1, %%d7, (1*4, %[X]), %%d5, %%acc3\n" - - "movclr.l %%acc0, %%d7\n" - "asl.l #3, %%d7\n" - "move.l %%d7, (7*4, %[x])\n" - "neg.l %%d7\n" - "move.l %%d7, (10*4, %[x])\n" - - "movclr.l %%acc1, %%d7\n" - "asl.l #3, %%d7\n" - "sub.l %%d0, %%d7\n" - "move.l %%d7, (19*4, %[x])\n" - "move.l %%d7, (34*4, %[x])\n" - - "movclr.l %%acc2, %%d7\n" - "asl.l #3, %%d7\n" - "move.l %%d7, ( 1*4, %[x])\n" - - "movclr.l %%acc3, %%d7\n" - "asl.l #3, %%d7\n" - "move.l %%d7, (25*4, %[x])\n" - - /* MAD_F_ML0(hi, lo, X[1], -MAD_F(0x09bd7ca0)); */ - /* MAD_F_MLA(hi, lo, X[7], MAD_F(0x0216a2a2)); */ - /* MAD_F_MLA(hi, lo, X[10], -MAD_F(0x0fdcf549)); */ - /* MAD_F_MLA(hi, lo, X[16], MAD_F(0x0cb19346)); */ - /* t1 = MAD_F_MLZ(hi, lo) + t6; */ - - /* MAD_F_ML0(hi, lo, X[1], -MAD_F(0x0216a2a2)); */ - /* MAD_F_MLA(hi, lo, X[7], -MAD_F(0x09bd7ca0)); */ - /* MAD_F_MLA(hi, lo, X[10], MAD_F(0x0cb19346)); */ - /* MAD_F_MLA(hi, lo, X[16], MAD_F(0x0fdcf549)); */ - /* t3 = MAD_F_MLZ(hi, lo); */ - - /* MAD_F_ML0(hi, lo, X[1], -MAD_F(0x0fdcf549)); */ - /* MAD_F_MLA(hi, lo, X[7], -MAD_F(0x0cb19346)); */ - /* MAD_F_MLA(hi, lo, X[10], -MAD_F(0x09bd7ca0)); */ - /* MAD_F_MLA(hi, lo, X[16], -MAD_F(0x0216a2a2)); */ - /* t5 = MAD_F_MLZ(hi, lo) - t6; */ - "msac.l %%d3, %%d5, %%acc0\n" - "msac.l %%d1, %%d5, %%acc1\n" - "msac.l %%d4, %%d5, ( 7*4, %[X]), %%d5, %%acc2\n" - "mac.l %%d1, %%d5, %%acc0\n" - "msac.l %%d3, %%d5, %%acc1\n" - "msac.l %%d2, %%d5, (10*4, %[X]), %%d5, %%acc2\n" - "msac.l %%d4, %%d5, %%acc0\n" - "mac.l %%d2, %%d5, %%acc1\n" - "msac.l %%d3, %%d5, (16*4, %[X]), %%d5, %%acc2\n" - "mac.l %%d2, %%d5, %%acc0\n" - "mac.l %%d4, %%d5, %%acc1\n" - "msac.l %%d1, %%d5, ( 0*4, %[X]), %%d0, %%acc2\n" - - "movclr.l %%acc0, %%d7\n" - "asl.l #3, %%d7\n" - "add.l (6*4, %[t]), %%d7\n" /* t1 */ - - "movclr.l %%acc1, %%d5\n" - "asl.l #3, %%d5\n" /* t3 */ - - "movclr.l %%acc2, %%d6\n" - "asl.l #3, %%d6\n" - "sub.l (6*4, %[t]), %%d6\n" /* t5 */ - "move.l %%d6, (5*4, %[t])\n" - - /* MAD_F_ML0(hi, lo, X[0], MAD_F(0x03768962)); */ - /* MAD_F_MLA(hi, lo, X[2], MAD_F(0x0e313245)); */ - /* MAD_F_MLA(hi, lo, X[3], -MAD_F(0x0ffc19fd)); */ - /* MAD_F_MLA(hi, lo, X[5], -MAD_F(0x0acf37ad)); */ - /* MAD_F_MLA(hi, lo, X[6], MAD_F(0x04cfb0e2)); */ - /* MAD_F_MLA(hi, lo, X[8], -MAD_F(0x0898c779)); */ - /* MAD_F_MLA(hi, lo, X[9], MAD_F(0x0d7e8807)); */ - /* MAD_F_MLA(hi, lo, X[11], MAD_F(0x0f426cb5)); */ - /* MAD_F_MLA(hi, lo, X[12], -MAD_F(0x0bcbe352)); */ - /* MAD_F_MLA(hi, lo, X[14], MAD_F(0x00b2aa3e)); */ - /* MAD_F_MLA(hi, lo, X[15], -MAD_F(0x07635284)); */ - /* MAD_F_MLA(hi, lo, X[17], -MAD_F(0x0f9ee890)); */ - /* x[11] = -(x[6] = MAD_F_MLZ(hi, lo) + t1); */ - /* MAD_F_ML0(hi, lo, X[0], -MAD_F(0x0f426cb5)); */ - /* MAD_F_MLA(hi, lo, X[2], -MAD_F(0x00b2aa3e)); */ - /* MAD_F_MLA(hi, lo, X[3], MAD_F(0x0898c779)); */ - /* MAD_F_MLA(hi, lo, X[5], MAD_F(0x0f9ee890)); */ - /* MAD_F_MLA(hi, lo, X[6], MAD_F(0x0acf37ad)); */ - /* MAD_F_MLA(hi, lo, X[8], -MAD_F(0x07635284)); */ - /* MAD_F_MLA(hi, lo, X[9], -MAD_F(0x0e313245)); */ - /* MAD_F_MLA(hi, lo, X[11], -MAD_F(0x0bcbe352)); */ - /* MAD_F_MLA(hi, lo, X[12], -MAD_F(0x03768962)); */ - /* MAD_F_MLA(hi, lo, X[14], MAD_F(0x0d7e8807)); */ - /* MAD_F_MLA(hi, lo, X[15], MAD_F(0x0ffc19fd)); */ - /* MAD_F_MLA(hi, lo, X[17], MAD_F(0x04cfb0e2)); */ - /* x[23] = x[30] = MAD_F_MLZ(hi, lo) + t1; */ - /* MAD_F_ML0(hi, lo, X[0], -MAD_F(0x0bcbe352)); */ - /* MAD_F_MLA(hi, lo, X[2], MAD_F(0x0d7e8807)); */ - /* MAD_F_MLA(hi, lo, X[3], -MAD_F(0x07635284)); */ - /* MAD_F_MLA(hi, lo, X[5], MAD_F(0x04cfb0e2)); */ - /* MAD_F_MLA(hi, lo, X[6], MAD_F(0x0f9ee890)); */ - /* MAD_F_MLA(hi, lo, X[8], -MAD_F(0x0ffc19fd)); */ - /* MAD_F_MLA(hi, lo, X[9], -MAD_F(0x00b2aa3e)); */ - /* MAD_F_MLA(hi, lo, X[11], MAD_F(0x03768962)); */ - /* MAD_F_MLA(hi, lo, X[12], -MAD_F(0x0f426cb5)); */ - /* MAD_F_MLA(hi, lo, X[14], MAD_F(0x0e313245)); */ - /* MAD_F_MLA(hi, lo, X[15], MAD_F(0x0898c779)); */ - /* MAD_F_MLA(hi, lo, X[17], -MAD_F(0x0acf37ad)); */ - /* x[18] = x[35] = MAD_F_MLZ(hi, lo) - t1; */ - "move.l #0x03768962, %%d1\n" - "move.l #0x0f426cb5, %%d2\n" - "move.l #0x0bcbe352, %%d3\n" - "mac.l %%d1, %%d0, %%acc0\n" - "msac.l %%d2, %%d0, %%acc1\n" - "msac.l %%d3, %%d0, (11*4, %[X]), %%d0, %%acc2\n" - "mac.l %%d2, %%d0, %%acc0\n" - "msac.l %%d3, %%d0, %%acc1\n" - "mac.l %%d1, %%d0, (12*4, %[X]), %%d0, %%acc2\n" - "msac.l %%d3, %%d0, %%acc0\n" - "msac.l %%d1, %%d0, %%acc1\n" - "msac.l %%d2, %%d0, ( 2*4, %[X]), %%d0, %%acc2\n" - "move.l #0x0e313245, %%d1\n" - "move.l #0x00b2aa3e, %%d2\n" - "move.l #0x0d7e8807, %%d3\n" - "mac.l %%d1, %%d0, %%acc0\n" - "msac.l %%d2, %%d0, %%acc1\n" - "mac.l %%d3, %%d0, ( 9*4, %[X]), %%d0, %%acc2\n" - "mac.l %%d3, %%d0, %%acc0\n" - "msac.l %%d1, %%d0, %%acc1\n" - "msac.l %%d2, %%d0, (14*4, %[X]), %%d0, %%acc2\n" - "mac.l %%d2, %%d0, %%acc0\n" - "mac.l %%d3, %%d0, %%acc1\n" - "mac.l %%d1, %%d0, ( 3*4, %[X]), %%d0, %%acc2\n" - "move.l #0x0ffc19fd, %%d1\n" - "move.l #0x0898c779, %%d2\n" - "move.l #0x07635284, %%d3\n" - "msac.l %%d1, %%d0, %%acc0\n" - "mac.l %%d2, %%d0, %%acc1\n" - "msac.l %%d3, %%d0, ( 8*4, %[X]), %%d0, %%acc2\n" - "msac.l %%d2, %%d0, %%acc0\n" - "msac.l %%d3, %%d0, %%acc1\n" - "msac.l %%d1, %%d0, (15*4, %[X]), %%d0, %%acc2\n" - "msac.l %%d3, %%d0, %%acc0\n" - "mac.l %%d1, %%d0, %%acc1\n" - "mac.l %%d2, %%d0, ( 5*4, %[X]), %%d0, %%acc2\n" - "move.l #0x0acf37ad, %%d1\n" - "move.l #0x0f9ee890, %%d2\n" - "move.l #0x04cfb0e2, %%d3\n" - "msac.l %%d1, %%d0, %%acc0\n" - "mac.l %%d2, %%d0, %%acc1\n" - "mac.l %%d3, %%d0, ( 6*4, %[X]), %%d0, %%acc2\n" - "mac.l %%d3, %%d0, %%acc0\n" - "mac.l %%d1, %%d0, %%acc1\n" - "mac.l %%d2, %%d0, (17*4, %[X]), %%d0, %%acc2\n" - "msac.l %%d2, %%d0, %%acc0\n" - "mac.l %%d3, %%d0, %%acc1\n" - "msac.l %%d1, %%d0, ( 4*4, %[X]), %%d0, %%acc2\n" - - "movclr.l %%acc0, %%d6\n" - "asl.l #3, %%d6\n" - "add.l %%d7, %%d6\n" - "move.l %%d6, (6*4, %[x])\n" - "neg.l %%d6\n" - "move.l %%d6, (11*4, %[x])\n" - - "movclr.l %%acc1, %%d6\n" - "asl.l #3, %%d6\n" - "add.l %%d7, %%d6\n" - "move.l %%d6, (23*4, %[x])\n" - "move.l %%d6, (30*4, %[x])\n" - - "movclr.l %%acc2, %%d6\n" - "asl.l #3, %%d6\n" - "sub.l %%d7, %%d6\n" - "move.l %%d6, (18*4, %[x])\n" - "move.l %%d6, (35*4, %[x])\n" - - /* MAD_F_ML0(hi, lo, X[4], MAD_F(0x061f78aa)); */ - /* MAD_F_MLA(hi, lo, X[13], -MAD_F(0x0ec835e8)); */ - /* t3 += (t7 = MAD_F_MLZ(hi, lo)); */ - /* t4 -= t7; */ - "move.l #0x061f78aa, %%d1\n" - "mac.l %%d1, %%d0, (13*4, %[X]), %%d0, %%acc0\n" - "move.l #0x0ec835e8, %%d1\n" - "msac.l %%d1, %%d0, (1*4, %[X]), %%d0, %%acc0\n" - "move.l %%acc0, %%d6\n" - "asl.l #3, %%d6\n" /* t7 */ - "add.l %%d6, %%d5\n" /* t3 */ - "move.l (4*4, %[t]), %%d1\n" - "sub.l %%d6, %%d1\n" /* t4 */ - "move.l %%d1, (4*4, %[t])\n" - - /* MAD_F_MLA(hi, lo, X[1], -MAD_F(0x0cb19346)); */ - /* MAD_F_MLA(hi, lo, X[7], MAD_F(0x0fdcf549)); */ - /* MAD_F_MLA(hi, lo, X[10], MAD_F(0x0216a2a2)); */ - /* MAD_F_MLA(hi, lo, X[16], -MAD_F(0x09bd7ca0)); */ - /* t2 = MAD_F_MLZ(hi, lo); */ - "move.l #0x0cb19346, %%d1\n" - "msac.l %%d1, %%d0, ( 7*4, %[X]), %%d0, %%acc0\n" - "move.l #0x0fdcf549, %%d1\n" - "mac.l %%d1, %%d0, (10*4, %[X]), %%d0, %%acc0\n" - "move.l #0x0216a2a2, %%d1\n" - "mac.l %%d1, %%d0, (16*4, %[X]), %%d0, %%acc0\n" - "move.l #0x09bd7ca0, %%d1\n" - "msac.l %%d1, %%d0, ( %[X]), %%d0, %%acc0\n" - "move.l %%acc0, %%d7\n" - "asl.l #3, %%d7\n" /* t2 */ - - /* MAD_F_MLA(hi, lo, X[0], MAD_F(0x04cfb0e2)); */ - /* MAD_F_MLA(hi, lo, X[2], MAD_F(0x0ffc19fd)); */ - /* MAD_F_MLA(hi, lo, X[3], -MAD_F(0x0d7e8807)); */ - /* MAD_F_MLA(hi, lo, X[5], MAD_F(0x03768962)); */ - /* MAD_F_MLA(hi, lo, X[6], -MAD_F(0x0bcbe352)); */ - /* MAD_F_MLA(hi, lo, X[8], -MAD_F(0x0e313245)); */ - /* MAD_F_MLA(hi, lo, X[9], MAD_F(0x07635284)); */ - /* MAD_F_MLA(hi, lo, X[11], -MAD_F(0x0acf37ad)); */ - /* MAD_F_MLA(hi, lo, X[12], MAD_F(0x0f9ee890)); */ - /* MAD_F_MLA(hi, lo, X[14], MAD_F(0x0898c779)); */ - /* MAD_F_MLA(hi, lo, X[15], MAD_F(0x00b2aa3e)); */ - /* MAD_F_MLA(hi, lo, X[17], MAD_F(0x0f426cb5)); */ - /* x[12] = -(x[5] = MAD_F_MLZ(hi, lo)); */ - /* MAD_F_ML0(hi, lo, X[0], MAD_F(0x0acf37ad)); */ - /* MAD_F_MLA(hi, lo, X[2], -MAD_F(0x0898c779)); */ - /* MAD_F_MLA(hi, lo, X[3], MAD_F(0x0e313245)); */ - /* MAD_F_MLA(hi, lo, X[5], -MAD_F(0x0f426cb5)); */ - /* MAD_F_MLA(hi, lo, X[6], -MAD_F(0x03768962)); */ - /* MAD_F_MLA(hi, lo, X[8], MAD_F(0x00b2aa3e)); */ - /* MAD_F_MLA(hi, lo, X[9], -MAD_F(0x0ffc19fd)); */ - /* MAD_F_MLA(hi, lo, X[11], MAD_F(0x0f9ee890)); */ - /* MAD_F_MLA(hi, lo, X[12], -MAD_F(0x04cfb0e2)); */ - /* MAD_F_MLA(hi, lo, X[14], MAD_F(0x07635284)); */ - /* MAD_F_MLA(hi, lo, X[15], MAD_F(0x0d7e8807)); */ - /* MAD_F_MLA(hi, lo, X[17], -MAD_F(0x0bcbe352)); */ - /* x[17] = -(x[0] = MAD_F_MLZ(hi, lo) + t2); */ - /* MAD_F_ML0(hi, lo, X[0], -MAD_F(0x0f9ee890)); */ - /* MAD_F_MLA(hi, lo, X[2], -MAD_F(0x07635284)); */ - /* MAD_F_MLA(hi, lo, X[3], -MAD_F(0x00b2aa3e)); */ - /* MAD_F_MLA(hi, lo, X[5], MAD_F(0x0bcbe352)); */ - /* MAD_F_MLA(hi, lo, X[6], MAD_F(0x0f426cb5)); */ - /* MAD_F_MLA(hi, lo, X[8], MAD_F(0x0d7e8807)); */ - /* MAD_F_MLA(hi, lo, X[9], MAD_F(0x0898c779)); */ - /* MAD_F_MLA(hi, lo, X[11], -MAD_F(0x04cfb0e2)); */ - /* MAD_F_MLA(hi, lo, X[12], -MAD_F(0x0acf37ad)); */ - /* MAD_F_MLA(hi, lo, X[14], -MAD_F(0x0ffc19fd)); */ - /* MAD_F_MLA(hi, lo, X[15], -MAD_F(0x0e313245)); */ - /* MAD_F_MLA(hi, lo, X[17], -MAD_F(0x03768962)); */ - /* x[24] = x[29] = MAD_F_MLZ(hi, lo) + t2; */ - "move.l #0x0acf37ad, %%d1\n" - "move.l #0x0f9ee890, %%d2\n" - "move.l #0x04cfb0e2, %%d3\n" - "mac.l %%d3, %%d0, %%acc0\n" - "mac.l %%d1, %%d0, %%acc1\n" - "msac.l %%d2, %%d0, (11*4, %[X]), %%d0, %%acc2\n" - "msac.l %%d1, %%d0, %%acc0\n" - "mac.l %%d2, %%d0, %%acc1\n" - "msac.l %%d3, %%d0, (12*4, %[X]), %%d0, %%acc2\n" - "mac.l %%d2, %%d0, %%acc0\n" - "msac.l %%d3, %%d0, %%acc1\n" - "msac.l %%d1, %%d0, ( 2*4, %[X]), %%d0, %%acc2\n" - "move.l #0x0ffc19fd, %%d1\n" - "move.l #0x0898c779, %%d2\n" - "move.l #0x07635284, %%d3\n" - "mac.l %%d1, %%d0, %%acc0\n" - "msac.l %%d2, %%d0, %%acc1\n" - "msac.l %%d3, %%d0, ( 9*4, %[X]), %%d0, %%acc2\n" - "mac.l %%d3, %%d0, %%acc0\n" - "msac.l %%d1, %%d0, %%acc1\n" - "mac.l %%d2, %%d0, (14*4, %[X]), %%d0, %%acc2\n" - "mac.l %%d2, %%d0, %%acc0\n" - "mac.l %%d3, %%d0, %%acc1\n" - "msac.l %%d1, %%d0, ( 3*4, %[X]), %%d0, %%acc2\n" - "move.l #0x0e313245, %%d1\n" - "move.l #0x00b2aa3e, %%d2\n" - "move.l #0x0d7e8807, %%d3\n" - "msac.l %%d3, %%d0, %%acc0\n" - "mac.l %%d1, %%d0, %%acc1\n" - "msac.l %%d2, %%d0, ( 8*4, %[X]), %%d0, %%acc2\n" - "msac.l %%d1, %%d0, %%acc0\n" - "mac.l %%d2, %%d0, %%acc1\n" - "mac.l %%d3, %%d0, (15*4, %[X]), %%d0, %%acc2\n" - "mac.l %%d2, %%d0, %%acc0\n" - "mac.l %%d3, %%d0, %%acc1\n" - "msac.l %%d1, %%d0, ( 5*4, %[X]), %%d0, %%acc2\n" - "move.l #0x03768962, %%d1\n" - "move.l #0x0f426cb5, %%d2\n" - "move.l #0x0bcbe352, %%d3\n" - "mac.l %%d1, %%d0, %%acc0\n" - "msac.l %%d2, %%d0, %%acc1\n" - "mac.l %%d3, %%d0, ( 6*4, %[X]), %%d0, %%acc2\n" - "msac.l %%d3, %%d0, %%acc0\n" - "msac.l %%d1, %%d0, %%acc1\n" - "mac.l %%d2, %%d0, (17*4, %[X]), %%d0, %%acc2\n" - "mac.l %%d2, %%d0, %%acc0\n" - "msac.l %%d3, %%d0, %%acc1\n" - "msac.l %%d1, %%d0, ( %[X]), %%d0, %%acc2\n" - - "movclr.l %%acc0, %%d6\n" - "asl.l #3, %%d6\n" - "move.l %%d6, ( 5*4, %[x])\n" - "neg.l %%d6\n" - "move.l %%d6, (12*4, %[x])\n" - - "movclr.l %%acc1, %%d6\n" - "asl.l #3, %%d6\n" - "add.l %%d7, %%d6\n" - "move.l %%d6, ( %[x])\n" - "neg.l %%d6\n" - "move.l %%d6, (17*4, %[x])\n" - - "movclr.l %%acc2, %%d6\n" - "asl.l #3, %%d6\n" - "add.l %%d7, %%d6\n" - "move.l %%d6, (24*4, %[x])\n" - "move.l %%d6, (29*4, %[x])\n" - - /* MAD_F_ML0(hi, lo, X[0], MAD_F(0x00b2aa3e)); */ - /* MAD_F_MLA(hi, lo, X[2], MAD_F(0x03768962)); */ - /* MAD_F_MLA(hi, lo, X[3], -MAD_F(0x04cfb0e2)); */ - /* MAD_F_MLA(hi, lo, X[5], -MAD_F(0x07635284)); */ - /* MAD_F_MLA(hi, lo, X[6], MAD_F(0x0898c779)); */ - /* MAD_F_MLA(hi, lo, X[8], MAD_F(0x0acf37ad)); */ - /* MAD_F_MLA(hi, lo, X[9], -MAD_F(0x0bcbe352)); */ - /* MAD_F_MLA(hi, lo, X[11], -MAD_F(0x0d7e8807)); */ - /* MAD_F_MLA(hi, lo, X[12], MAD_F(0x0e313245)); */ - /* MAD_F_MLA(hi, lo, X[14], MAD_F(0x0f426cb5)); */ - /* MAD_F_MLA(hi, lo, X[15], -MAD_F(0x0f9ee890)); */ - /* MAD_F_MLA(hi, lo, X[17], -MAD_F(0x0ffc19fd)); */ - /* x[9] = -(x[8] = MAD_F_MLZ(hi, lo) + t3); */ - - /* MAD_F_ML0(hi, lo, X[0], -MAD_F(0x0e313245)); */ - /* MAD_F_MLA(hi, lo, X[2], MAD_F(0x0bcbe352)); */ - /* MAD_F_MLA(hi, lo, X[3], MAD_F(0x0f9ee890)); */ - /* MAD_F_MLA(hi, lo, X[5], -MAD_F(0x0898c779)); */ - /* MAD_F_MLA(hi, lo, X[6], -MAD_F(0x0ffc19fd)); */ - /* MAD_F_MLA(hi, lo, X[8], MAD_F(0x04cfb0e2)); */ - /* MAD_F_MLA(hi, lo, X[9], MAD_F(0x0f426cb5)); */ - /* MAD_F_MLA(hi, lo, X[11], -MAD_F(0x00b2aa3e)); */ - /* MAD_F_MLA(hi, lo, X[12], -MAD_F(0x0d7e8807)); */ - /* MAD_F_MLA(hi, lo, X[14], -MAD_F(0x03768962)); */ - /* MAD_F_MLA(hi, lo, X[15], MAD_F(0x0acf37ad)); */ - /* MAD_F_MLA(hi, lo, X[17], MAD_F(0x07635284)); */ - /* x[21] = x[32] = MAD_F_MLZ(hi, lo) + t3; */ - - /* MAD_F_ML0(hi, lo, X[0], -MAD_F(0x0d7e8807)); */ - /* MAD_F_MLA(hi, lo, X[2], MAD_F(0x0f426cb5)); */ - /* MAD_F_MLA(hi, lo, X[3], MAD_F(0x0acf37ad)); */ - /* MAD_F_MLA(hi, lo, X[5], -MAD_F(0x0ffc19fd)); */ - /* MAD_F_MLA(hi, lo, X[6], -MAD_F(0x07635284)); */ - /* MAD_F_MLA(hi, lo, X[8], MAD_F(0x0f9ee890)); */ - /* MAD_F_MLA(hi, lo, X[9], MAD_F(0x03768962)); */ - /* MAD_F_MLA(hi, lo, X[11], -MAD_F(0x0e313245)); */ - /* MAD_F_MLA(hi, lo, X[12], MAD_F(0x00b2aa3e)); */ - /* MAD_F_MLA(hi, lo, X[14], MAD_F(0x0bcbe352)); */ - /* MAD_F_MLA(hi, lo, X[15], -MAD_F(0x04cfb0e2)); */ - /* MAD_F_MLA(hi, lo, X[17], -MAD_F(0x0898c779)); */ - /* x[20] = x[33] = MAD_F_MLZ(hi, lo) - t3; */ - "move.l #0x0e313245, %%d1\n" - "move.l #0x00b2aa3e, %%d2\n" - "move.l #0x0d7e8807, %%d3\n" - "mac.l %%d2, %%d0, %%acc0\n" - "msac.l %%d1, %%d0, %%acc1\n" - "msac.l %%d3, %%d0, (11*4, %[X]), %%d0, %%acc2\n" - "msac.l %%d3, %%d0, %%acc0\n" - "msac.l %%d2, %%d0, %%acc1\n" - "msac.l %%d1, %%d0, (12*4, %[X]), %%d0, %%acc2\n" - "mac.l %%d1, %%d0, %%acc0\n" - "msac.l %%d3, %%d0, %%acc1\n" - "mac.l %%d2, %%d0, ( 2*4, %[X]), %%d0, %%acc2\n" - "move.l #0x03768962, %%d1\n" - "move.l #0x0f426cb5, %%d2\n" - "move.l #0x0bcbe352, %%d3\n" - "mac.l %%d1, %%d0, %%acc0\n" - "mac.l %%d3, %%d0, %%acc1\n" - "mac.l %%d2, %%d0, ( 9*4, %[X]), %%d0, %%acc2\n" - "msac.l %%d3, %%d0, %%acc0\n" - "mac.l %%d2, %%d0, %%acc1\n" - "mac.l %%d1, %%d0, (14*4, %[X]), %%d0, %%acc2\n" - "mac.l %%d2, %%d0, %%acc0\n" - "msac.l %%d1, %%d0, %%acc1\n" - "mac.l %%d3, %%d0, ( 3*4, %[X]), %%d0, %%acc2\n" - "move.l #0x0acf37ad, %%d1\n" - "move.l #0x0f9ee890, %%d2\n" - "move.l #0x04cfb0e2, %%d3\n" - "msac.l %%d3, %%d0, %%acc0\n" - "mac.l %%d2, %%d0, %%acc1\n" - "mac.l %%d1, %%d0, ( 8*4, %[X]), %%d0, %%acc2\n" - "mac.l %%d1, %%d0, %%acc0\n" - "mac.l %%d3, %%d0, %%acc1\n" - "mac.l %%d2, %%d0, (15*4, %[X]), %%d0, %%acc2\n" - "msac.l %%d2, %%d0, %%acc0\n" - "mac.l %%d1, %%d0, %%acc1\n" - "msac.l %%d3, %%d0, ( 5*4, %[X]), %%d0, %%acc2\n" - "move.l #0x0ffc19fd, %%d1\n" - "move.l #0x0898c779, %%d2\n" - "move.l #0x07635284, %%d3\n" - "msac.l %%d3, %%d0, %%acc0\n" - "msac.l %%d2, %%d0, %%acc1\n" - "msac.l %%d1, %%d0, ( 6*4, %[X]), %%d0, %%acc2\n" - "mac.l %%d2, %%d0, %%acc0\n" - "msac.l %%d1, %%d0, %%acc1\n" - "msac.l %%d3, %%d0, (17*4, %[X]), %%d0, %%acc2\n" - "msac.l %%d1, %%d0, %%acc0\n" - "mac.l %%d3, %%d0, %%acc1\n" - "msac.l %%d2, %%d0, (12*4, %[t]), %%d0, %%acc2\n" - - "movclr.l %%acc0, %%d6\n" - "asl.l #3, %%d6\n" - "add.l %%d5, %%d6\n" - "move.l %%d6, (8*4, %[x])\n" - "neg.l %%d6\n" - "move.l %%d6, (9*4, %[x])\n" - - "movclr.l %%acc1, %%d6\n" - "asl.l #3, %%d6\n" - "add.l %%d5, %%d6\n" - "move.l %%d6, (21*4, %[x])\n" - "move.l %%d6, (32*4, %[x])\n" - - "movclr.l %%acc2, %%d6\n" - "asl.l #3, %%d6\n" - "sub.l %%d5, %%d6\n" - "move.l %%d6, (20*4, %[x])\n" - "move.l %%d6, (33*4, %[x])\n" - - /* MAD_F_ML0(hi, lo, t12, -MAD_F(0x0ec835e8)); */ - /* MAD_F_MLA(hi, lo, t13, MAD_F(0x061f78aa)); */ - /* x[22] = x[31] = MAD_F_MLZ(hi, lo) + t0; */ - "move.l #0x0ec835e8, %%d1\n" - "move.l #0x061f78aa, %%d2\n" - "msac.l %%d1, %%d0, (13*4, %[t]), %%d3, %%acc0\n" - "mac.l %%d2, %%d3, ( 1*4, %[x]), %%d4, %%acc0\n" - "movclr.l %%acc0, %%d6\n" - "asl.l #3, %%d6\n" - "add.l (0*4, %[t]), %%d6\n" - "move.l %%d6, (22*4, %[x])\n" - "move.l %%d6, (31*4, %[x])\n" - - /* MAD_F_ML0(hi, lo, t12, MAD_F(0x061f78aa)); */ - /* MAD_F_MLA(hi, lo, t13, MAD_F(0x0ec835e8)); */ - /* x[13] = -(x[4] = MAD_F_MLZ(hi, lo) + t4); */ - /* x[16] = -(x[1] = x[1] + t4); */ - /* x[25] = x[28] = x[25] + t4; */ - "mac.l %%d2, %%d0, (4*4, %[t]), %%d2, %%acc0\n" - "mac.l %%d1, %%d3, ( %[X]), %%d0, %%acc0\n" - "movclr.l %%acc0, %%d6\n" - "asl.l #3, %%d6\n" - "add.l %%d2, %%d6\n" - "move.l %%d6, ( 4*4, %[x])\n" - "neg.l %%d6\n" - "move.l %%d6, (13*4, %[x])\n" - - "add.l %%d2, %%d4\n" - "move.l %%d4, ( 1*4, %[x])\n" - "neg.l %%d4\n" - "move.l %%d4, (16*4, %[x])\n" - - "move.l (25*4, %[x]), %%d4\n" - "add.l %%d2, %%d4\n" - "move.l %%d4, (25*4, %[x])\n" - "move.l %%d4, (28*4, %[x])\n" - - /* MAD_F_ML0(hi, lo, X[0], MAD_F(0x0898c779)); */ - /* MAD_F_MLA(hi, lo, X[2], MAD_F(0x04cfb0e2)); */ - /* MAD_F_MLA(hi, lo, X[3], MAD_F(0x0bcbe352)); */ - /* MAD_F_MLA(hi, lo, X[5], MAD_F(0x00b2aa3e)); */ - /* MAD_F_MLA(hi, lo, X[6], MAD_F(0x0e313245)); */ - /* MAD_F_MLA(hi, lo, X[8], -MAD_F(0x03768962)); */ - /* MAD_F_MLA(hi, lo, X[9], MAD_F(0x0f9ee890)); */ - /* MAD_F_MLA(hi, lo, X[11], -MAD_F(0x07635284)); */ - /* MAD_F_MLA(hi, lo, X[12], MAD_F(0x0ffc19fd)); */ - /* MAD_F_MLA(hi, lo, X[14], -MAD_F(0x0acf37ad)); */ - /* MAD_F_MLA(hi, lo, X[15], MAD_F(0x0f426cb5)); */ - /* MAD_F_MLA(hi, lo, X[17], -MAD_F(0x0d7e8807)); */ - /* x[15] = -(x[2] = MAD_F_MLZ(hi, lo) + t5); */ - /* MAD_F_ML0(hi, lo, X[0], MAD_F(0x07635284)); */ - /* MAD_F_MLA(hi, lo, X[2], MAD_F(0x0acf37ad)); */ - /* MAD_F_MLA(hi, lo, X[3], MAD_F(0x03768962)); */ - /* MAD_F_MLA(hi, lo, X[5], MAD_F(0x0d7e8807)); */ - /* MAD_F_MLA(hi, lo, X[6], -MAD_F(0x00b2aa3e)); */ - /* MAD_F_MLA(hi, lo, X[8], MAD_F(0x0f426cb5)); */ - /* MAD_F_MLA(hi, lo, X[9], -MAD_F(0x04cfb0e2)); */ - /* MAD_F_MLA(hi, lo, X[11], MAD_F(0x0ffc19fd)); */ - /* MAD_F_MLA(hi, lo, X[12], -MAD_F(0x0898c779)); */ - /* MAD_F_MLA(hi, lo, X[14], MAD_F(0x0f9ee890)); */ - /* MAD_F_MLA(hi, lo, X[15], -MAD_F(0x0bcbe352)); */ - /* MAD_F_MLA(hi, lo, X[17], MAD_F(0x0e313245)); */ - /* x[14] = -(x[3] = MAD_F_MLZ(hi, lo) + t5); */ - /* MAD_F_ML0(hi, lo, X[0], -MAD_F(0x0ffc19fd)); */ - /* MAD_F_MLA(hi, lo, X[2], -MAD_F(0x0f9ee890)); */ - /* MAD_F_MLA(hi, lo, X[3], -MAD_F(0x0f426cb5)); */ - /* MAD_F_MLA(hi, lo, X[5], -MAD_F(0x0e313245)); */ - /* MAD_F_MLA(hi, lo, X[6], -MAD_F(0x0d7e8807)); */ - /* MAD_F_MLA(hi, lo, X[8], -MAD_F(0x0bcbe352)); */ - /* MAD_F_MLA(hi, lo, X[9], -MAD_F(0x0acf37ad)); */ - /* MAD_F_MLA(hi, lo, X[11], -MAD_F(0x0898c779)); */ - /* MAD_F_MLA(hi, lo, X[12], -MAD_F(0x07635284)); */ - /* MAD_F_MLA(hi, lo, X[14], -MAD_F(0x04cfb0e2)); */ - /* MAD_F_MLA(hi, lo, X[15], -MAD_F(0x03768962)); */ - /* MAD_F_MLA(hi, lo, X[17], -MAD_F(0x00b2aa3e)); */ - /* x[26] = x[27] = MAD_F_MLZ(hi, lo) + t5; */ - "move.l #0x0ffc19fd, %%d1\n" - "move.l #0x0898c779, %%d2\n" - "move.l #0x07635284, %%d3\n" - "mac.l %%d2, %%d0, %%acc0\n" - "mac.l %%d3, %%d0, %%acc1\n" - "msac.l %%d1, %%d0, (11*4, %[X]), %%d0, %%acc2\n" - "msac.l %%d3, %%d0, %%acc0\n" - "mac.l %%d1, %%d0, %%acc1\n" - "msac.l %%d2, %%d0, (12*4, %[X]), %%d0, %%acc2\n" - "mac.l %%d1, %%d0, %%acc0\n" - "msac.l %%d2, %%d0, %%acc1\n" - "msac.l %%d3, %%d0, ( 2*4, %[X]), %%d0, %%acc2\n" - "move.l #0x0acf37ad, %%d1\n" - "move.l #0x0f9ee890, %%d2\n" - "move.l #0x04cfb0e2, %%d3\n" - "mac.l %%d3, %%d0, %%acc0\n" - "mac.l %%d1, %%d0, %%acc1\n" - "msac.l %%d2, %%d0, ( 9*4, %[X]), %%d0, %%acc2\n" - "mac.l %%d2, %%d0, %%acc0\n" - "msac.l %%d3, %%d0, %%acc1\n" - "msac.l %%d1, %%d0, (14*4, %[X]), %%d0, %%acc2\n" - "msac.l %%d1, %%d0, %%acc0\n" - "mac.l %%d2, %%d0, %%acc1\n" - "msac.l %%d3, %%d0, ( 3*4, %[X]), %%d0, %%acc2\n" - "move.l #0x03768962, %%d1\n" - "move.l #0x0f426cb5, %%d2\n" - "move.l #0x0bcbe352, %%d3\n" - "mac.l %%d3, %%d0, %%acc0\n" - "mac.l %%d1, %%d0, %%acc1\n" - "msac.l %%d2, %%d0, ( 8*4, %[X]), %%d0, %%acc2\n" - "msac.l %%d1, %%d0, %%acc0\n" - "mac.l %%d2, %%d0, %%acc1\n" - "msac.l %%d3, %%d0, (15*4, %[X]), %%d0, %%acc2\n" - "mac.l %%d2, %%d0, %%acc0\n" - "msac.l %%d3, %%d0, %%acc1\n" - "msac.l %%d1, %%d0, ( 5*4, %[X]), %%d0, %%acc2\n" - "move.l #0x0e313245, %%d1\n" - "move.l #0x00b2aa3e, %%d2\n" - "move.l #0x0d7e8807, %%d3\n" - "mac.l %%d2, %%d0, %%acc0\n" - "mac.l %%d3, %%d0, %%acc1\n" - "msac.l %%d1, %%d0, ( 6*4, %[X]), %%d0, %%acc2\n" - "mac.l %%d1, %%d0, %%acc0\n" - "msac.l %%d2, %%d0, %%acc1\n" - "msac.l %%d3, %%d0, (17*4, %[X]), %%d0, %%acc2\n" - "msac.l %%d3, %%d0, %%acc0\n" - "mac.l %%d1, %%d0, %%acc1\n" - "msac.l %%d2, %%d0, ( 5*4, %[t]), %%d6, %%acc2\n" - "movclr.l %%acc0, %%d7\n" - "asl.l #3, %%d7\n" - "add.l %%d6, %%d7\n" - "move.l %%d7, (2*4, %[x])\n" - "neg.l %%d7\n" - "move.l %%d7, (15*4, %[x])\n" - - "movclr.l %%acc1, %%d7\n" - "asl.l #3, %%d7\n" - "add.l %%d6, %%d7\n" - "move.l %%d7, (3*4, %[x])\n" - "neg.l %%d7\n" - "move.l %%d7, (14*4, %[x])\n" - - "movclr.l %%acc2, %%d7\n" - "asl.l #3, %%d7\n" - "add.l %%d6, %%d7\n" - "move.l %%d7, (26*4, %[x])\n" - "move.l %%d7, (27*4, %[x])\n" - - : : [X] "a" (X), [x] "a" (x), [t] "a" (t) - : "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7"); - /* pfew */ -} - -# else /* if defined(CPU_COLDFIRE) */ - -static inline -void imdct36(mad_fixed_t const X[18], mad_fixed_t x[36]) -{ - mad_fixed_t t0, t1, t2, t3, t4, t5, t6, t7; - mad_fixed_t t8, t9, t10, t11, t12, t13, t14, t15; - register mad_fixed64hi_t hi; - register mad_fixed64lo_t lo; - - MAD_F_ML0(hi, lo, (t14 = X[1] - X[10]), -MAD_F(0x0ec835e8)); - MAD_F_MLA(hi, lo, (t15 = X[7] + X[16]), MAD_F(0x061f78aa)); - t4 = MAD_F_MLZ(hi, lo); - - MAD_F_ML0(hi, lo, X[4], MAD_F(0x0ec835e8)); - MAD_F_MLA(hi, lo, X[13], MAD_F(0x061f78aa)); - t6 = MAD_F_MLZ(hi, lo); - - MAD_F_MLA(hi, lo, t14, -MAD_F(0x061f78aa)); - MAD_F_MLA(hi, lo, t15, -MAD_F(0x0ec835e8)); - t0 = MAD_F_MLZ(hi, lo); - - MAD_F_MLA(hi, lo, (t8 =X[0]-X[11]-X[12]), MAD_F(0x0216a2a2)); - MAD_F_MLA(hi, lo, (t9 =X[2]-X[ 9]-X[14]), MAD_F(0x09bd7ca0)); - MAD_F_MLA(hi, lo, (t10=X[3]-X[ 8]-X[15]), -MAD_F(0x0cb19346)); - MAD_F_MLA(hi, lo, (t11=X[5]-X[ 6]-X[17]), -MAD_F(0x0fdcf549)); - x[10] = -(x[7] = MAD_F_MLZ(hi, lo)); - - MAD_F_ML0(hi, lo, t8, -MAD_F(0x0cb19346)); - MAD_F_MLA(hi, lo, t9, MAD_F(0x0fdcf549)); - MAD_F_MLA(hi, lo, t10, MAD_F(0x0216a2a2)); - MAD_F_MLA(hi, lo, t11, -MAD_F(0x09bd7ca0)); - x[19] = x[34] = MAD_F_MLZ(hi, lo) - t0; - - MAD_F_ML0(hi, lo, t8, MAD_F(0x09bd7ca0)); - MAD_F_MLA(hi, lo, t9, -MAD_F(0x0216a2a2)); - MAD_F_MLA(hi, lo, t10, MAD_F(0x0fdcf549)); - MAD_F_MLA(hi, lo, t11, -MAD_F(0x0cb19346)); - x[ 1] = MAD_F_MLZ(hi, lo); - - MAD_F_ML0(hi, lo, t8, -MAD_F(0x0fdcf549)); - MAD_F_MLA(hi, lo, t9, -MAD_F(0x0cb19346)); - MAD_F_MLA(hi, lo, t10, -MAD_F(0x09bd7ca0)); - MAD_F_MLA(hi, lo, t11, -MAD_F(0x0216a2a2)); - x[25] = MAD_F_MLZ(hi, lo); - - t12 = t8 - t10; - t13 = t9 + t11; - - MAD_F_ML0(hi, lo, X[1], -MAD_F(0x09bd7ca0)); - MAD_F_MLA(hi, lo, X[7], MAD_F(0x0216a2a2)); - MAD_F_MLA(hi, lo, X[10], -MAD_F(0x0fdcf549)); - MAD_F_MLA(hi, lo, X[16], MAD_F(0x0cb19346)); - t1 = MAD_F_MLZ(hi, lo) + t6; - - MAD_F_ML0(hi, lo, X[1], -MAD_F(0x0216a2a2)); - MAD_F_MLA(hi, lo, X[7], -MAD_F(0x09bd7ca0)); - MAD_F_MLA(hi, lo, X[10], MAD_F(0x0cb19346)); - MAD_F_MLA(hi, lo, X[16], MAD_F(0x0fdcf549)); - t3 = MAD_F_MLZ(hi, lo); - - MAD_F_ML0(hi, lo, X[1], -MAD_F(0x0fdcf549)); - MAD_F_MLA(hi, lo, X[7], -MAD_F(0x0cb19346)); - MAD_F_MLA(hi, lo, X[10], -MAD_F(0x09bd7ca0)); - MAD_F_MLA(hi, lo, X[16], -MAD_F(0x0216a2a2)); - t5 = MAD_F_MLZ(hi, lo) - t6; - - MAD_F_ML0(hi, lo, X[0], MAD_F(0x03768962)); - MAD_F_MLA(hi, lo, X[2], MAD_F(0x0e313245)); - MAD_F_MLA(hi, lo, X[3], -MAD_F(0x0ffc19fd)); - MAD_F_MLA(hi, lo, X[5], -MAD_F(0x0acf37ad)); - MAD_F_MLA(hi, lo, X[6], MAD_F(0x04cfb0e2)); - MAD_F_MLA(hi, lo, X[8], -MAD_F(0x0898c779)); - MAD_F_MLA(hi, lo, X[9], MAD_F(0x0d7e8807)); - MAD_F_MLA(hi, lo, X[11], MAD_F(0x0f426cb5)); - MAD_F_MLA(hi, lo, X[12], -MAD_F(0x0bcbe352)); - MAD_F_MLA(hi, lo, X[14], MAD_F(0x00b2aa3e)); - MAD_F_MLA(hi, lo, X[15], -MAD_F(0x07635284)); - MAD_F_MLA(hi, lo, X[17], -MAD_F(0x0f9ee890)); - x[11] = -(x[6] = MAD_F_MLZ(hi, lo) + t1); - - MAD_F_ML0(hi, lo, X[0], -MAD_F(0x0f426cb5)); - MAD_F_MLA(hi, lo, X[2], -MAD_F(0x00b2aa3e)); - MAD_F_MLA(hi, lo, X[3], MAD_F(0x0898c779)); - MAD_F_MLA(hi, lo, X[5], MAD_F(0x0f9ee890)); - MAD_F_MLA(hi, lo, X[6], MAD_F(0x0acf37ad)); - MAD_F_MLA(hi, lo, X[8], -MAD_F(0x07635284)); - MAD_F_MLA(hi, lo, X[9], -MAD_F(0x0e313245)); - MAD_F_MLA(hi, lo, X[11], -MAD_F(0x0bcbe352)); - MAD_F_MLA(hi, lo, X[12], -MAD_F(0x03768962)); - MAD_F_MLA(hi, lo, X[14], MAD_F(0x0d7e8807)); - MAD_F_MLA(hi, lo, X[15], MAD_F(0x0ffc19fd)); - MAD_F_MLA(hi, lo, X[17], MAD_F(0x04cfb0e2)); - x[23] = x[30] = MAD_F_MLZ(hi, lo) + t1; - - MAD_F_ML0(hi, lo, X[0], -MAD_F(0x0bcbe352)); - MAD_F_MLA(hi, lo, X[2], MAD_F(0x0d7e8807)); - MAD_F_MLA(hi, lo, X[3], -MAD_F(0x07635284)); - MAD_F_MLA(hi, lo, X[5], MAD_F(0x04cfb0e2)); - MAD_F_MLA(hi, lo, X[6], MAD_F(0x0f9ee890)); - MAD_F_MLA(hi, lo, X[8], -MAD_F(0x0ffc19fd)); - MAD_F_MLA(hi, lo, X[9], -MAD_F(0x00b2aa3e)); - MAD_F_MLA(hi, lo, X[11], MAD_F(0x03768962)); - MAD_F_MLA(hi, lo, X[12], -MAD_F(0x0f426cb5)); - MAD_F_MLA(hi, lo, X[14], MAD_F(0x0e313245)); - MAD_F_MLA(hi, lo, X[15], MAD_F(0x0898c779)); - MAD_F_MLA(hi, lo, X[17], -MAD_F(0x0acf37ad)); - x[18] = x[35] = MAD_F_MLZ(hi, lo) - t1; - - MAD_F_ML0(hi, lo, X[4], MAD_F(0x061f78aa)); - MAD_F_MLA(hi, lo, X[13], -MAD_F(0x0ec835e8)); - t3+= (t7 = MAD_F_MLZ(hi, lo)); - t4-= t7; - - MAD_F_MLA(hi, lo, X[1], -MAD_F(0x0cb19346)); - MAD_F_MLA(hi, lo, X[7], MAD_F(0x0fdcf549)); - MAD_F_MLA(hi, lo, X[10], MAD_F(0x0216a2a2)); - MAD_F_MLA(hi, lo, X[16], -MAD_F(0x09bd7ca0)); - t2 = MAD_F_MLZ(hi, lo); - - MAD_F_MLA(hi, lo, X[0], MAD_F(0x04cfb0e2)); - MAD_F_MLA(hi, lo, X[2], MAD_F(0x0ffc19fd)); - MAD_F_MLA(hi, lo, X[3], -MAD_F(0x0d7e8807)); - MAD_F_MLA(hi, lo, X[5], MAD_F(0x03768962)); - MAD_F_MLA(hi, lo, X[6], -MAD_F(0x0bcbe352)); - MAD_F_MLA(hi, lo, X[8], -MAD_F(0x0e313245)); - MAD_F_MLA(hi, lo, X[9], MAD_F(0x07635284)); - MAD_F_MLA(hi, lo, X[11], -MAD_F(0x0acf37ad)); - MAD_F_MLA(hi, lo, X[12], MAD_F(0x0f9ee890)); - MAD_F_MLA(hi, lo, X[14], MAD_F(0x0898c779)); - MAD_F_MLA(hi, lo, X[15], MAD_F(0x00b2aa3e)); - MAD_F_MLA(hi, lo, X[17], MAD_F(0x0f426cb5)); - x[12] = -(x[5] = MAD_F_MLZ(hi, lo)); - - MAD_F_ML0(hi, lo, X[0], MAD_F(0x0acf37ad)); - MAD_F_MLA(hi, lo, X[2], -MAD_F(0x0898c779)); - MAD_F_MLA(hi, lo, X[3], MAD_F(0x0e313245)); - MAD_F_MLA(hi, lo, X[5], -MAD_F(0x0f426cb5)); - MAD_F_MLA(hi, lo, X[6], -MAD_F(0x03768962)); - MAD_F_MLA(hi, lo, X[8], MAD_F(0x00b2aa3e)); - MAD_F_MLA(hi, lo, X[9], -MAD_F(0x0ffc19fd)); - MAD_F_MLA(hi, lo, X[11], MAD_F(0x0f9ee890)); - MAD_F_MLA(hi, lo, X[12], -MAD_F(0x04cfb0e2)); - MAD_F_MLA(hi, lo, X[14], MAD_F(0x07635284)); - MAD_F_MLA(hi, lo, X[15], MAD_F(0x0d7e8807)); - MAD_F_MLA(hi, lo, X[17], -MAD_F(0x0bcbe352)); - x[17] = -(x[0] = MAD_F_MLZ(hi, lo) + t2); - - MAD_F_ML0(hi, lo, X[0], -MAD_F(0x0f9ee890)); - MAD_F_MLA(hi, lo, X[2], -MAD_F(0x07635284)); - MAD_F_MLA(hi, lo, X[3], -MAD_F(0x00b2aa3e)); - MAD_F_MLA(hi, lo, X[5], MAD_F(0x0bcbe352)); - MAD_F_MLA(hi, lo, X[6], MAD_F(0x0f426cb5)); - MAD_F_MLA(hi, lo, X[8], MAD_F(0x0d7e8807)); - MAD_F_MLA(hi, lo, X[9], MAD_F(0x0898c779)); - MAD_F_MLA(hi, lo, X[11], -MAD_F(0x04cfb0e2)); - MAD_F_MLA(hi, lo, X[12], -MAD_F(0x0acf37ad)); - MAD_F_MLA(hi, lo, X[14], -MAD_F(0x0ffc19fd)); - MAD_F_MLA(hi, lo, X[15], -MAD_F(0x0e313245)); - MAD_F_MLA(hi, lo, X[17], -MAD_F(0x03768962)); - x[24] = x[29] = MAD_F_MLZ(hi, lo) + t2; - - MAD_F_ML0(hi, lo, X[0], MAD_F(0x00b2aa3e)); - MAD_F_MLA(hi, lo, X[2], MAD_F(0x03768962)); - MAD_F_MLA(hi, lo, X[3], -MAD_F(0x04cfb0e2)); - MAD_F_MLA(hi, lo, X[5], -MAD_F(0x07635284)); - MAD_F_MLA(hi, lo, X[6], MAD_F(0x0898c779)); - MAD_F_MLA(hi, lo, X[8], MAD_F(0x0acf37ad)); - MAD_F_MLA(hi, lo, X[9], -MAD_F(0x0bcbe352)); - MAD_F_MLA(hi, lo, X[11], -MAD_F(0x0d7e8807)); - MAD_F_MLA(hi, lo, X[12], MAD_F(0x0e313245)); - MAD_F_MLA(hi, lo, X[14], MAD_F(0x0f426cb5)); - MAD_F_MLA(hi, lo, X[15], -MAD_F(0x0f9ee890)); - MAD_F_MLA(hi, lo, X[17], -MAD_F(0x0ffc19fd)); - x[9] = -(x[8] = MAD_F_MLZ(hi, lo) + t3); - - MAD_F_ML0(hi, lo, X[0], -MAD_F(0x0e313245)); - MAD_F_MLA(hi, lo, X[2], MAD_F(0x0bcbe352)); - MAD_F_MLA(hi, lo, X[3], MAD_F(0x0f9ee890)); - MAD_F_MLA(hi, lo, X[5], -MAD_F(0x0898c779)); - MAD_F_MLA(hi, lo, X[6], -MAD_F(0x0ffc19fd)); - MAD_F_MLA(hi, lo, X[8], MAD_F(0x04cfb0e2)); - MAD_F_MLA(hi, lo, X[9], MAD_F(0x0f426cb5)); - MAD_F_MLA(hi, lo, X[11], -MAD_F(0x00b2aa3e)); - MAD_F_MLA(hi, lo, X[12], -MAD_F(0x0d7e8807)); - MAD_F_MLA(hi, lo, X[14], -MAD_F(0x03768962)); - MAD_F_MLA(hi, lo, X[15], MAD_F(0x0acf37ad)); - MAD_F_MLA(hi, lo, X[17], MAD_F(0x07635284)); - x[21] = x[32] = MAD_F_MLZ(hi, lo) + t3; - - MAD_F_ML0(hi, lo, X[0], -MAD_F(0x0d7e8807)); - MAD_F_MLA(hi, lo, X[2], MAD_F(0x0f426cb5)); - MAD_F_MLA(hi, lo, X[3], MAD_F(0x0acf37ad)); - MAD_F_MLA(hi, lo, X[5], -MAD_F(0x0ffc19fd)); - MAD_F_MLA(hi, lo, X[6], -MAD_F(0x07635284)); - MAD_F_MLA(hi, lo, X[8], MAD_F(0x0f9ee890)); - MAD_F_MLA(hi, lo, X[9], MAD_F(0x03768962)); - MAD_F_MLA(hi, lo, X[11], -MAD_F(0x0e313245)); - MAD_F_MLA(hi, lo, X[12], MAD_F(0x00b2aa3e)); - MAD_F_MLA(hi, lo, X[14], MAD_F(0x0bcbe352)); - MAD_F_MLA(hi, lo, X[15], -MAD_F(0x04cfb0e2)); - MAD_F_MLA(hi, lo, X[17], -MAD_F(0x0898c779)); - x[20] = x[33] = MAD_F_MLZ(hi, lo) - t3; - - MAD_F_ML0(hi, lo, t12, -MAD_F(0x0ec835e8)); - MAD_F_MLA(hi, lo, t13, MAD_F(0x061f78aa)); - x[22] = x[31] = MAD_F_MLZ(hi, lo) + t0; - - MAD_F_ML0(hi, lo, t12, MAD_F(0x061f78aa)); - MAD_F_MLA(hi, lo, t13, MAD_F(0x0ec835e8)); - x[13] = -(x[4] = MAD_F_MLZ(hi, lo) + t4); - x[16] = -(x[1] = x[1] + t4); - x[25] = x[28] = x[25] + t4; - - MAD_F_ML0(hi, lo, X[0], MAD_F(0x0898c779)); - MAD_F_MLA(hi, lo, X[2], MAD_F(0x04cfb0e2)); - MAD_F_MLA(hi, lo, X[3], MAD_F(0x0bcbe352)); - MAD_F_MLA(hi, lo, X[5], MAD_F(0x00b2aa3e)); - MAD_F_MLA(hi, lo, X[6], MAD_F(0x0e313245)); - MAD_F_MLA(hi, lo, X[8], -MAD_F(0x03768962)); - MAD_F_MLA(hi, lo, X[9], MAD_F(0x0f9ee890)); - MAD_F_MLA(hi, lo, X[11], -MAD_F(0x07635284)); - MAD_F_MLA(hi, lo, X[12], MAD_F(0x0ffc19fd)); - MAD_F_MLA(hi, lo, X[14], -MAD_F(0x0acf37ad)); - MAD_F_MLA(hi, lo, X[15], MAD_F(0x0f426cb5)); - MAD_F_MLA(hi, lo, X[17], -MAD_F(0x0d7e8807)); - x[15] = -(x[2] = MAD_F_MLZ(hi, lo) + t5); - - MAD_F_ML0(hi, lo, X[0], MAD_F(0x07635284)); - MAD_F_MLA(hi, lo, X[2], MAD_F(0x0acf37ad)); - MAD_F_MLA(hi, lo, X[3], MAD_F(0x03768962)); - MAD_F_MLA(hi, lo, X[5], MAD_F(0x0d7e8807)); - MAD_F_MLA(hi, lo, X[6], -MAD_F(0x00b2aa3e)); - MAD_F_MLA(hi, lo, X[8], MAD_F(0x0f426cb5)); - MAD_F_MLA(hi, lo, X[9], -MAD_F(0x04cfb0e2)); - MAD_F_MLA(hi, lo, X[11], MAD_F(0x0ffc19fd)); - MAD_F_MLA(hi, lo, X[12], -MAD_F(0x0898c779)); - MAD_F_MLA(hi, lo, X[14], MAD_F(0x0f9ee890)); - MAD_F_MLA(hi, lo, X[15], -MAD_F(0x0bcbe352)); - MAD_F_MLA(hi, lo, X[17], MAD_F(0x0e313245)); - x[14] = -(x[3] = MAD_F_MLZ(hi, lo) + t5); - - MAD_F_ML0(hi, lo, X[0], -MAD_F(0x0ffc19fd)); - MAD_F_MLA(hi, lo, X[2], -MAD_F(0x0f9ee890)); - MAD_F_MLA(hi, lo, X[3], -MAD_F(0x0f426cb5)); - MAD_F_MLA(hi, lo, X[5], -MAD_F(0x0e313245)); - MAD_F_MLA(hi, lo, X[6], -MAD_F(0x0d7e8807)); - MAD_F_MLA(hi, lo, X[8], -MAD_F(0x0bcbe352)); - MAD_F_MLA(hi, lo, X[9], -MAD_F(0x0acf37ad)); - MAD_F_MLA(hi, lo, X[11], -MAD_F(0x0898c779)); - MAD_F_MLA(hi, lo, X[12], -MAD_F(0x07635284)); - MAD_F_MLA(hi, lo, X[14], -MAD_F(0x04cfb0e2)); - MAD_F_MLA(hi, lo, X[15], -MAD_F(0x03768962)); - MAD_F_MLA(hi, lo, X[17], -MAD_F(0x00b2aa3e)); - x[26] = x[27] = MAD_F_MLZ(hi, lo) + t5; -} -# endif /* CPU_COLDFIRE */ - -/* - * NAME: III_imdct_l() - * DESCRIPTION: perform IMDCT and windowing for long blocks - */ -static -void III_imdct_l(mad_fixed_t const X[18], mad_fixed_t z[36], - unsigned int block_type) -{ - unsigned int i; - - /* IMDCT */ - - imdct36(X, z); - - /* windowing */ - - switch (block_type) { - case 0: /* normal window */ -# if 1 - /* loop unrolled implementation */ - for (i = 0; i < 36; i += 4) { - z[i + 0] = mad_f_mul(z[i + 0], window_l[i + 0]); - z[i + 1] = mad_f_mul(z[i + 1], window_l[i + 1]); - z[i + 2] = mad_f_mul(z[i + 2], window_l[i + 2]); - z[i + 3] = mad_f_mul(z[i + 3], window_l[i + 3]); - } -# else - /* reference implementation */ - for (i = 0; i < 36; ++i) z[i] = mad_f_mul(z[i], window_l[i]); -# endif - break; - - case 1: /* start block */ - for (i = 0; i < 18; i += 3) { - z[i + 0] = mad_f_mul(z[i + 0], window_l[i + 0]); - z[i + 1] = mad_f_mul(z[i + 1], window_l[i + 1]); - z[i + 2] = mad_f_mul(z[i + 2], window_l[i + 2]); - } - /* (i = 18; i < 24; ++i) z[i] unchanged */ - for (i = 24; i < 30; ++i) z[i] = mad_f_mul(z[i], window_s[i - 18]); - for (i = 30; i < 36; ++i) z[i] = 0; - break; - - case 3: /* stop block */ - for (i = 0; i < 6; ++i) z[i] = 0; - for (i = 6; i < 12; ++i) z[i] = mad_f_mul(z[i], window_s[i - 6]); - /* (i = 12; i < 18; ++i) z[i] unchanged */ - for (i = 18; i < 36; i += 3) { - z[i + 0] = mad_f_mul(z[i + 0], window_l[i + 0]); - z[i + 1] = mad_f_mul(z[i + 1], window_l[i + 1]); - z[i + 2] = mad_f_mul(z[i + 2], window_l[i + 2]); - } - break; - } -} -# endif /* FPM_ARM */ - -/* - * NAME: III_imdct_s() - * DESCRIPTION: perform IMDCT and windowing for short blocks - */ - -# if defined(CPU_COLDFIRE) -void III_imdct_s(mad_fixed_t const X[18], mad_fixed_t z[36]); -#else - -static -void III_imdct_s(mad_fixed_t const X[18], mad_fixed_t z[36]) -{ - mad_fixed_t y[36], *yptr; - mad_fixed_t const *wptr; - int w, i; - register mad_fixed64hi_t hi; - register mad_fixed64lo_t lo; - - /* IMDCT */ - - yptr = &y[0]; - - for (w = 0; w < 3; ++w) { - register mad_fixed_t const (*s)[6]; - - s = imdct_s; - - for (i = 0; i < 3; ++i) { - MAD_F_ML0(hi, lo, X[0], (*s)[0]); - MAD_F_MLA(hi, lo, X[1], (*s)[1]); - MAD_F_MLA(hi, lo, X[2], (*s)[2]); - MAD_F_MLA(hi, lo, X[3], (*s)[3]); - MAD_F_MLA(hi, lo, X[4], (*s)[4]); - MAD_F_MLA(hi, lo, X[5], (*s)[5]); - - yptr[i + 0] = MAD_F_MLZ(hi, lo); - yptr[5 - i] = -yptr[i + 0]; - - ++s; - - MAD_F_ML0(hi, lo, X[0], (*s)[0]); - MAD_F_MLA(hi, lo, X[1], (*s)[1]); - MAD_F_MLA(hi, lo, X[2], (*s)[2]); - MAD_F_MLA(hi, lo, X[3], (*s)[3]); - MAD_F_MLA(hi, lo, X[4], (*s)[4]); - MAD_F_MLA(hi, lo, X[5], (*s)[5]); - - yptr[ i + 6] = MAD_F_MLZ(hi, lo); - yptr[11 - i] = yptr[i + 6]; - - ++s; - } - - yptr += 12; - X += 6; - } - - /* windowing, overlapping and concatenation */ - - yptr = &y[0]; - wptr = &window_s[0]; - - for (i = 0; i < 6; ++i) { - z[i + 0] = 0; - z[i + 6] = mad_f_mul(yptr[ 0 + 0], wptr[0]); - - MAD_F_ML0(hi, lo, yptr[ 0 + 6], wptr[6]); - MAD_F_MLA(hi, lo, yptr[12 + 0], wptr[0]); - - z[i + 12] = MAD_F_MLZ(hi, lo); - - MAD_F_ML0(hi, lo, yptr[12 + 6], wptr[6]); - MAD_F_MLA(hi, lo, yptr[24 + 0], wptr[0]); - - z[i + 18] = MAD_F_MLZ(hi, lo); - - z[i + 24] = mad_f_mul(yptr[24 + 6], wptr[6]); - z[i + 30] = 0; - - ++yptr; - ++wptr; - } -} - -#endif - -#ifdef CPU_ARM -void III_overlap(mad_fixed_t const output[36], mad_fixed_t overlap[18], - mad_fixed_t sample[18][32], unsigned int sb); -#else - -/* - * NAME: III_overlap() - * DESCRIPTION: perform overlap-add of windowed IMDCT outputs - */ -static -void III_overlap(mad_fixed_t const output[36], mad_fixed_t overlap[18], - mad_fixed_t sample[18][32], unsigned int sb) -{ - unsigned int i; - for (i = 0; i < 18; ++i) { - sample[i][sb] = output[i + 0] + overlap[i]; - overlap[i] = output[i + 18]; - } -} -#endif - -/* - * NAME: III_overlap_z() - * DESCRIPTION: perform "overlap-add" of zero IMDCT outputs - */ -static inline -void III_overlap_z(mad_fixed_t overlap[18], - mad_fixed_t sample[18][32], unsigned int sb) -{ - unsigned int i; - for (i = 0; i < 18; ++i) { - sample[i][sb] = overlap[i]; - overlap[i] = 0; - } -} - -/* - * NAME: III_freqinver() - * DESCRIPTION: perform subband frequency inversion for odd sample lines - */ -static -void III_freqinver(mad_fixed_t sample[18][32], unsigned int sb) -{ - unsigned int i; - for (i = 1; i < 18; i += 2) - sample[i][sb] = -sample[i][sb]; -} - -/* - * NAME: III_decode() - * DESCRIPTION: decode frame main_data - */ -static -enum mad_error III_decode(struct mad_bitptr *ptr, struct mad_frame *frame, - struct sideinfo *si, unsigned int nch) -{ - struct mad_header *header = &frame->header; - unsigned int sfreqi, ngr, gr; - - { - unsigned int sfreq; - - sfreq = header->samplerate; - if (header->flags & MAD_FLAG_MPEG_2_5_EXT) - sfreq *= 2; - - /* 48000 => 0, 44100 => 1, 32000 => 2, - 24000 => 3, 22050 => 4, 16000 => 5 */ - sfreqi = ((sfreq >> 7) & 0x000f) + - ((sfreq >> 15) & 0x0001) - 8; - - if (header->flags & MAD_FLAG_MPEG_2_5_EXT) - sfreqi += 3; - } - - /* scalefactors, Huffman decoding, requantization */ - - ngr = (header->flags & MAD_FLAG_LSF_EXT) ? 1 : 2; - - for (gr = 0; gr < ngr; ++gr) { - struct granule *granule = &si->gr[gr]; - unsigned char const *sfbwidth[2]; - mad_fixed_t xr[2][576]; - unsigned int ch; - enum mad_error error; - - for (ch = 0; ch < nch; ++ch) { - struct channel *channel = &granule->ch[ch]; - unsigned int part2_length; - - sfbwidth[ch] = sfbwidth_table[sfreqi].l; - if (channel->block_type == 2) { - sfbwidth[ch] = (channel->flags & mixed_block_flag) ? - sfbwidth_table[sfreqi].m : sfbwidth_table[sfreqi].s; - } - - if (header->flags & MAD_FLAG_LSF_EXT) { - part2_length = III_scalefactors_lsf(ptr, channel, - ch == 0 ? 0 : &si->gr[1].ch[1], - header->mode_extension); - } - else { - part2_length = III_scalefactors(ptr, channel, &si->gr[0].ch[ch], - gr == 0 ? 0 : si->scfsi[ch]); - } - - error = III_huffdecode(ptr, xr[ch], channel, sfbwidth[ch], part2_length); - if (error) - return error; - } - - /* joint stereo processing */ - - if (header->mode == MAD_MODE_JOINT_STEREO && header->mode_extension) { - error = III_stereo(xr, granule, header, sfbwidth[0]); - if (error) - return error; - } - - /* reordering, alias reduction, IMDCT, overlap-add, frequency inversion */ - - for (ch = 0; ch < nch; ++ch) { - struct channel const *channel = &granule->ch[ch]; - mad_fixed_t (*sample)[32] = &((*frame->sbsample)[ch][18 * gr]); - unsigned int sb, l, i, sblimit; - mad_fixed_t output[36]; - - if (channel->block_type == 2) { - III_reorder(xr[ch], channel, sfbwidth[ch]); - -# if !defined(OPT_STRICT) - /* - * According to ISO/IEC 11172-3, "Alias reduction is not applied for - * granules with block_type == 2 (short block)." However, other - * sources suggest alias reduction should indeed be performed on the - * lower two subbands of mixed blocks. Most other implementations do - * this, so by default we will too. - */ - if (channel->flags & mixed_block_flag) - III_aliasreduce(xr[ch], 36); -# endif - } - else - III_aliasreduce(xr[ch], 576); - - l = 0; - - /* subbands 0-1 */ - - if (channel->block_type != 2 || (channel->flags & mixed_block_flag)) { - unsigned int block_type; - - block_type = channel->block_type; - if (channel->flags & mixed_block_flag) - block_type = 0; - - /* long blocks */ - for (sb = 0; sb < 2; ++sb, l += 18) { - III_imdct_l(&xr[ch][l], output, block_type); - III_overlap(output, (*frame->overlap)[ch][sb], sample, sb); - } - } - else { - /* short blocks */ - for (sb = 0; sb < 2; ++sb, l += 18) { - III_imdct_s(&xr[ch][l], output); - III_overlap(output, (*frame->overlap)[ch][sb], sample, sb); - } - } - - III_freqinver(sample, 1); - - /* (nonzero) subbands 2-31 */ - -/* - i = 576; - while (i > 36 && xr[ch][i - 1] == 0) - --i; -*/ - - { - /* saves ~600k cycles */ - mad_fixed_t *p = &xr[ch][576]; - mad_fixed_t tmp = xr[ch][35]; - xr[ch][35] = 1; - while (!*--p); - xr[ch][35] = tmp; - i = p - &xr[ch][0] + 1; - } - sblimit = 32 - (576 - i) / 18; - - if (channel->block_type != 2) { - /* long blocks */ - for (sb = 2; sb < sblimit; ++sb, l += 18) { - III_imdct_l(&xr[ch][l], output, channel->block_type); - III_overlap(output, (*frame->overlap)[ch][sb], sample, sb); - - if (sb & 1) - III_freqinver(sample, sb); - } - } - else { - /* short blocks */ - for (sb = 2; sb < sblimit; ++sb, l += 18) { - III_imdct_s(&xr[ch][l], output); - III_overlap(output, (*frame->overlap)[ch][sb], sample, sb); - - if (sb & 1) - III_freqinver(sample, sb); - } - } - - /* remaining (zero) subbands */ - - for (sb = sblimit; sb < 32; ++sb) { - III_overlap_z((*frame->overlap)[ch][sb], sample, sb); - - if (sb & 1) - III_freqinver(sample, sb); - } - } - } - - return MAD_ERROR_NONE; -} - -/* - * NAME: layer->III() - * DESCRIPTION: decode a single Layer III frame - */ -int mad_layer_III(struct mad_stream *stream, struct mad_frame *frame) -{ - struct mad_header *header = &frame->header; - unsigned int nch, priv_bitlen, next_md_begin = 0; - unsigned int si_len, data_bitlen, md_len; - unsigned int frame_space, frame_used, frame_free; - struct mad_bitptr ptr; - struct sideinfo si; - enum mad_error error; - int result = 0; - -#if 0 /* rockbox: do not allocate */ - /* allocate Layer III dynamic structures */ - /* rockbox: not used. Both pointers are linked to an array in rockbox' - * apps/codecs/mpa.c before calling this. */ - if (stream->main_data == 0) { - stream->main_data = malloc(MAD_BUFFER_MDLEN); - if (stream->main_data == 0) { - stream->error = MAD_ERROR_NOMEM; - return -1; - } - } - - if (frame->overlap == 0) { - frame->overlap = calloc(2 * 32 * 18, sizeof(mad_fixed_t)); - if (frame->overlap == 0) { - stream->error = MAD_ERROR_NOMEM; - return -1; - } - } -#else - /* rockbox: This should not happen. Return with error. */ - if ((stream->main_data == 0) || (frame->overlap == 0)) { - stream->error = MAD_ERROR_NOMEM; - return -1; - } -#endif /* rockbox */ - - nch = MAD_NCHANNELS(header); - si_len = (header->flags & MAD_FLAG_LSF_EXT) ? - (nch == 1 ? 9 : 17) : (nch == 1 ? 17 : 32); - - /* check frame sanity */ - - if (stream->next_frame - mad_bit_nextbyte(&stream->ptr) < - (signed int) si_len) { - stream->error = MAD_ERROR_BADFRAMELEN; - stream->md_len = 0; - return -1; - } - - /* check CRC word */ - - if (header->flags & MAD_FLAG_PROTECTION) { - header->crc_check = - mad_bit_crc(stream->ptr, si_len * CHAR_BIT, header->crc_check); - - if (header->crc_check != header->crc_target && - !(frame->options & MAD_OPTION_IGNORECRC)) { - stream->error = MAD_ERROR_BADCRC; - result = -1; - } - } - - /* decode frame side information */ - - error = III_sideinfo(&stream->ptr, nch, header->flags & MAD_FLAG_LSF_EXT, - &si, &data_bitlen, &priv_bitlen); - if (error && result == 0) { - stream->error = error; - result = -1; - } - - header->flags |= priv_bitlen; - header->private_bits |= si.private_bits; - - /* find main_data of next frame */ - - { - struct mad_bitptr peek; - unsigned long header; - - mad_bit_init(&peek, stream->next_frame); - - header = mad_bit_read(&peek, 32); - if ((header & 0xffe60000L) /* syncword | layer */ == 0xffe20000L) { - if (!(header & 0x00010000L)) /* protection_bit */ - mad_bit_skip(&peek, 16); /* crc_check */ - - next_md_begin = - mad_bit_read(&peek, (header & 0x00080000L) /* ID */ ? 9 : 8); - } - - mad_bit_finish(&peek); - } - - /* find main_data of this frame */ - - frame_space = stream->next_frame - mad_bit_nextbyte(&stream->ptr); - - if (next_md_begin > si.main_data_begin + frame_space) - next_md_begin = 0; - - md_len = si.main_data_begin + frame_space - next_md_begin; - - frame_used = 0; - - if (si.main_data_begin == 0) { - ptr = stream->ptr; - stream->md_len = 0; - - frame_used = md_len; - } - else { - if (si.main_data_begin > stream->md_len) { - if (result == 0) { - stream->error = MAD_ERROR_BADDATAPTR; - result = -1; - } - } - else { - mad_bit_init(&ptr, - *stream->main_data + stream->md_len - si.main_data_begin); - - if (md_len > si.main_data_begin) { - assert(stream->md_len + md_len - - si.main_data_begin <= MAD_BUFFER_MDLEN); - - memcpy(*stream->main_data + stream->md_len, - mad_bit_nextbyte(&stream->ptr), - frame_used = md_len - si.main_data_begin); - stream->md_len += frame_used; - } - } - } - - frame_free = frame_space - frame_used; - - /* decode main_data */ - - if (result == 0) { - error = III_decode(&ptr, frame, &si, nch); - if (error) { - stream->error = error; - result = -1; - } - - /* designate ancillary bits */ - - stream->anc_ptr = ptr; - stream->anc_bitlen = md_len * CHAR_BIT - data_bitlen; - } - -# if 0 && defined(DEBUG) - fprintf(stderr, - "main_data_begin:%u, md_len:%u, frame_free:%u, " - "data_bitlen:%u, anc_bitlen: %u\n", - si.main_data_begin, md_len, frame_free, - data_bitlen, stream->anc_bitlen); -# endif - - /* preload main_data buffer with up to 511 bytes for next frame(s) */ - - if (frame_free >= next_md_begin) { - memcpy(*stream->main_data, - stream->next_frame - next_md_begin, next_md_begin); - stream->md_len = next_md_begin; - } - else { - if (md_len < si.main_data_begin) { - unsigned int extra; - - extra = si.main_data_begin - md_len; - if (extra + frame_free > next_md_begin) - extra = next_md_begin - frame_free; - - if (extra < stream->md_len) { - memmove(*stream->main_data, - *stream->main_data + stream->md_len - extra, extra); - stream->md_len = extra; - } - } - else - stream->md_len = 0; - - memcpy(*stream->main_data + stream->md_len, - stream->next_frame - frame_free, frame_free); - stream->md_len += frame_free; - } - - return result; -} diff --git a/apps/codecs/libmad/layer3.h b/apps/codecs/libmad/layer3.h deleted file mode 100644 index 15948037e9..0000000000 --- a/apps/codecs/libmad/layer3.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * libmad - MPEG audio decoder library - * Copyright (C) 2000-2004 Underbit Technologies, Inc. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * $Id$ - */ - -# ifndef LIBMAD_LAYER3_H -# define LIBMAD_LAYER3_H - -# include "stream.h" -# include "frame.h" - -int mad_layer_III(struct mad_stream *, struct mad_frame *); - -# endif diff --git a/apps/codecs/libmad/libmad.make b/apps/codecs/libmad/libmad.make deleted file mode 100644 index 4ed8ab1e8c..0000000000 --- a/apps/codecs/libmad/libmad.make +++ /dev/null @@ -1,66 +0,0 @@ -# __________ __ ___. -# Open \______ \ ____ ____ | | _\_ |__ _______ ___ -# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / -# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < -# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ -# \/ \/ \/ \/ \/ -# $Id$ -# - -# we need to build two different mad libraries -# (one for codec, one for mpegplayer) -# so a little trickery is necessary - -# Extract optimization level ('-O') from compile flags. Will be set later. -MADFLAGS = $(filter-out -O%,$(CODECFLAGS)) -I$(APPSDIR)/codecs/libmad -MADFLAGS += -UDEBUG -DNDEBUG -DHAVE_LIMITS_H - -# libmad is faster on ARM-targets with -O1 than -O2 -ifeq ($(ARCH),arch_arm) - MADFLAGS += -O1 -else - MADFLAGS += -O2 -endif - -# MPEGplayer -MPEGMADFLAGS = $(MADFLAGS) -DMPEGPLAYER - -# libmad -MADLIB := $(CODECDIR)/libmad.a -MADLIB_SRC := $(call preprocess, $(APPSDIR)/codecs/libmad/SOURCES) -MADLIB_OBJ := $(call c2obj, $(MADLIB_SRC)) -OTHER_SRC += $(MADLIB_SRC) - -$(MADLIB): $(MADLIB_OBJ) - $(SILENT)$(shell rm -f $@) - $(call PRINTS,AR $(@F))$(AR) rcs $@ $^ >/dev/null - -# libmad-mpeg -MPEGMADLIB := $(CODECDIR)/libmad-mpeg.a -MPEGMADLIB_SRC := $(call preprocess, $(APPSDIR)/codecs/libmad/SOURCES) -MPEGMADLIB_OBJ := $(addsuffix .o,$(basename $(subst $(ROOTDIR)/apps/codecs/libmad,$(BUILDDIR)/apps/codecs/libmad-mpeg,$(MPEGMADLIB_SRC)))) - -$(MPEGMADLIB): $(MPEGMADLIB_OBJ) - $(call PRINTS,AR $(@F))$(AR) rcs $@ $^ >/dev/null - -# pattern rules - -$(CODECDIR)/libmad-mpeg/%.o : $(ROOTDIR)/apps/codecs/libmad/%.c - $(SILENT)mkdir -p $(dir $@) - $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<)) \ - $(CC) $(MPEGMADFLAGS) -c $< -o $@ - -$(CODECDIR)/libmad-mpeg/%.o : $(ROOTDIR)/apps/codecs/libmad/%.S - $(SILENT)mkdir -p $(dir $@) - $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<)) \ - $(CC) $(MPEGMADFLAGS) $(ASMFLAGS) -c $< -o $@ - -$(CODECDIR)/libmad/%.o: $(ROOTDIR)/apps/codecs/libmad/%.c - $(SILENT)mkdir -p $(dir $@) - $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<)) \ - $(CC) $(MADFLAGS) -c $< -o $@ - -$(CODECDIR)/libmad/%.o: $(ROOTDIR)/apps/codecs/libmad/%.S - $(SILENT)mkdir -p $(dir $@) - $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<)) \ - $(CC) $(MADFLAGS) $(ASMFLAGS) -c $< -o $@ diff --git a/apps/codecs/libmad/mad.h b/apps/codecs/libmad/mad.h deleted file mode 100644 index 3ae0d88a0e..0000000000 --- a/apps/codecs/libmad/mad.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * libmad - MPEG audio decoder library - * Copyright (C) 2000-2004 Underbit Technologies, Inc. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * If you would like to negotiate alternate licensing terms, you may do - * so by contacting: Underbit Technologies, Inc. - */ - -#include - -#define FPM_DEFAULT - -#include "fixed.h" -#include "bit.h" -#include "stream.h" -#include "frame.h" -#include "synth.h" diff --git a/apps/codecs/libmad/mad_iram.h b/apps/codecs/libmad/mad_iram.h deleted file mode 100644 index ac0b64cca9..0000000000 --- a/apps/codecs/libmad/mad_iram.h +++ /dev/null @@ -1,57 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2007 Dave Chapman - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ - -/* Define how IRAM is used on the various targets. Note that this - file is included by both .c and .S files so must not contain any C - code. -*/ - -#ifndef _LIBMAD_IRAM_H -#define _LIBMAD_IRAM_H - -#include "config.h" - -#if (CONFIG_PLATFORM&PLATFORM_HOSTED) -#define ICODE_SECTION_MPA_ARM .text -#define IBSS_SECTION_MPA_ARM .bss -#define ICODE_ATTR_MPA_SYNTH -#define ICONST_ATTR_MPA_HUFFMAN -#else -/* Code performs slower in IRAM on PP502x and there is no space in - mpegplayer on the PP5002. S3C2440 doesn't have any IRAM available for - codecs */ -#if defined(CPU_PP502x) || (CONFIG_CPU == PP5002 && defined(MPEGPLAYER)) -#define ICODE_SECTION_MPA_ARM .text -#define ICODE_ATTR_MPA_SYNTH -#else -#define ICODE_SECTION_MPA_ARM .icode -#define ICODE_ATTR_MPA_SYNTH ICODE_ATTR -#endif - -#define IBSS_SECTION_MPA_ARM .ibss - -#ifndef ICONST_ATTR_MPA_HUFFMAN -#define ICONST_ATTR_MPA_HUFFMAN ICONST_ATTR -#endif - -#endif - -#endif /* MAD_IRAM_H */ diff --git a/apps/codecs/libmad/qc_table.dat b/apps/codecs/libmad/qc_table.dat deleted file mode 100644 index d28a207049..0000000000 --- a/apps/codecs/libmad/qc_table.dat +++ /dev/null @@ -1,77 +0,0 @@ -/* - * libmad - MPEG audio decoder library - * Copyright (C) 2000-2004 Underbit Technologies, Inc. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * $Id$ - */ - -/* - * These are the Layer II classes of quantization. - * The table is derived from Table B.4 of ISO/IEC 11172-3. - */ - - { 3, 2, 5, - MAD_F(0x15555555) /* 1.33333333333 => 1.33333333209, e 0.00000000124 */, - MAD_F(0x08000000) /* 0.50000000000 => 0.50000000000, e 0.00000000000 */ }, - { 5, 3, 7, - MAD_F(0x1999999a) /* 1.60000000000 => 1.60000000149, e -0.00000000149 */, - MAD_F(0x08000000) /* 0.50000000000 => 0.50000000000, e 0.00000000000 */ }, - { 7, 0, 3, - MAD_F(0x12492492) /* 1.14285714286 => 1.14285714179, e 0.00000000107 */, - MAD_F(0x04000000) /* 0.25000000000 => 0.25000000000, e 0.00000000000 */ }, - { 9, 4, 10, - MAD_F(0x1c71c71c) /* 1.77777777777 => 1.77777777612, e 0.00000000165 */, - MAD_F(0x08000000) /* 0.50000000000 => 0.50000000000, e 0.00000000000 */ }, - { 15, 0, 4, - MAD_F(0x11111111) /* 1.06666666666 => 1.06666666642, e 0.00000000024 */, - MAD_F(0x02000000) /* 0.12500000000 => 0.12500000000, e 0.00000000000 */ }, - { 31, 0, 5, - MAD_F(0x10842108) /* 1.03225806452 => 1.03225806355, e 0.00000000097 */, - MAD_F(0x01000000) /* 0.06250000000 => 0.06250000000, e 0.00000000000 */ }, - { 63, 0, 6, - MAD_F(0x10410410) /* 1.01587301587 => 1.01587301493, e 0.00000000094 */, - MAD_F(0x00800000) /* 0.03125000000 => 0.03125000000, e 0.00000000000 */ }, - { 127, 0, 7, - MAD_F(0x10204081) /* 1.00787401575 => 1.00787401572, e 0.00000000003 */, - MAD_F(0x00400000) /* 0.01562500000 => 0.01562500000, e 0.00000000000 */ }, - { 255, 0, 8, - MAD_F(0x10101010) /* 1.00392156863 => 1.00392156839, e 0.00000000024 */, - MAD_F(0x00200000) /* 0.00781250000 => 0.00781250000, e 0.00000000000 */ }, - { 511, 0, 9, - MAD_F(0x10080402) /* 1.00195694716 => 1.00195694715, e 0.00000000001 */, - MAD_F(0x00100000) /* 0.00390625000 => 0.00390625000, e 0.00000000000 */ }, - { 1023, 0, 10, - MAD_F(0x10040100) /* 1.00097751711 => 1.00097751617, e 0.00000000094 */, - MAD_F(0x00080000) /* 0.00195312500 => 0.00195312500, e 0.00000000000 */ }, - { 2047, 0, 11, - MAD_F(0x10020040) /* 1.00048851979 => 1.00048851967, e 0.00000000012 */, - MAD_F(0x00040000) /* 0.00097656250 => 0.00097656250, e 0.00000000000 */ }, - { 4095, 0, 12, - MAD_F(0x10010010) /* 1.00024420024 => 1.00024420023, e 0.00000000001 */, - MAD_F(0x00020000) /* 0.00048828125 => 0.00048828125, e 0.00000000000 */ }, - { 8191, 0, 13, - MAD_F(0x10008004) /* 1.00012208522 => 1.00012208521, e 0.00000000001 */, - MAD_F(0x00010000) /* 0.00024414063 => 0.00024414062, e 0.00000000000 */ }, - { 16383, 0, 14, - MAD_F(0x10004001) /* 1.00006103888 => 1.00006103888, e -0.00000000000 */, - MAD_F(0x00008000) /* 0.00012207031 => 0.00012207031, e -0.00000000000 */ }, - { 32767, 0, 15, - MAD_F(0x10002000) /* 1.00003051851 => 1.00003051758, e 0.00000000093 */, - MAD_F(0x00004000) /* 0.00006103516 => 0.00006103516, e 0.00000000000 */ }, - { 65535, 0, 16, - MAD_F(0x10001000) /* 1.00001525902 => 1.00001525879, e 0.00000000023 */, - MAD_F(0x00002000) /* 0.00003051758 => 0.00003051758, e 0.00000000000 */ } diff --git a/apps/codecs/libmad/rq_table.dat b/apps/codecs/libmad/rq_table.dat deleted file mode 100644 index b3a37c13cd..0000000000 --- a/apps/codecs/libmad/rq_table.dat +++ /dev/null @@ -1,8747 +0,0 @@ -/* - * libmad - MPEG audio decoder library - * Copyright (C) 2000-2004 Underbit Technologies, Inc. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * $Id$ - */ - -/* - * This is the lookup table used to compute x^(4/3) for Layer III - * requantization. To maintain the best possible accuracy, the value is - * stored as a normalized mantissa with exponent. The requantization - * algorithm recombines these parts with appropriate scaling. - */ - - /* 0 */ 0x00000000 | (0 << 27) /* 0.000000000 */, - /* 1 */ 0x04000000 | (2 << 27) /* 0.250000000 */, - /* 2 */ 0x050a28be | (3 << 27) /* 0.314980262 */, - /* 3 */ 0x0453a5cd | (4 << 27) /* 0.270421794 */, - /* 4 */ 0x06597fa9 | (4 << 27) /* 0.396850263 */, - /* 5 */ 0x04466275 | (5 << 27) /* 0.267183742 */, - /* 6 */ 0x05738c72 | (5 << 27) /* 0.340710111 */, - /* 7 */ 0x06b1fc81 | (5 << 27) /* 0.418453696 */, - /* 8 */ 0x04000000 | (6 << 27) /* 0.250000000 */, - /* 9 */ 0x04ae20d7 | (6 << 27) /* 0.292511788 */, - /* 10 */ 0x0562d694 | (6 << 27) /* 0.336630420 */, - /* 11 */ 0x061dae96 | (6 << 27) /* 0.382246578 */, - /* 12 */ 0x06de47f4 | (6 << 27) /* 0.429267841 */, - /* 13 */ 0x07a44f7a | (6 << 27) /* 0.477614858 */, - /* 14 */ 0x0437be65 | (7 << 27) /* 0.263609310 */, - /* 15 */ 0x049fc824 | (7 << 27) /* 0.289009227 */, - - /* 16 */ 0x050a28be | (7 << 27) /* 0.314980262 */, - /* 17 */ 0x0576c6f5 | (7 << 27) /* 0.341498336 */, - /* 18 */ 0x05e58c0b | (7 << 27) /* 0.368541759 */, - /* 19 */ 0x06566361 | (7 << 27) /* 0.396090870 */, - /* 20 */ 0x06c93a2e | (7 << 27) /* 0.424127753 */, - /* 21 */ 0x073dff3e | (7 << 27) /* 0.452635998 */, - /* 22 */ 0x07b4a2bc | (7 << 27) /* 0.481600510 */, - /* 23 */ 0x04168b05 | (8 << 27) /* 0.255503674 */, - /* 24 */ 0x0453a5cd | (8 << 27) /* 0.270421794 */, - /* 25 */ 0x04919b6a | (8 << 27) /* 0.285548607 */, - /* 26 */ 0x04d065fb | (8 << 27) /* 0.300878507 */, - /* 27 */ 0x05100000 | (8 << 27) /* 0.316406250 */, - /* 28 */ 0x05506451 | (8 << 27) /* 0.332126919 */, - /* 29 */ 0x05918e15 | (8 << 27) /* 0.348035890 */, - /* 30 */ 0x05d378bb | (8 << 27) /* 0.364128809 */, - /* 31 */ 0x06161ff3 | (8 << 27) /* 0.380401563 */, - - /* 32 */ 0x06597fa9 | (8 << 27) /* 0.396850263 */, - /* 33 */ 0x069d9400 | (8 << 27) /* 0.413471222 */, - /* 34 */ 0x06e2594c | (8 << 27) /* 0.430260942 */, - /* 35 */ 0x0727cc11 | (8 << 27) /* 0.447216097 */, - /* 36 */ 0x076de8fc | (8 << 27) /* 0.464333519 */, - /* 37 */ 0x07b4ace3 | (8 << 27) /* 0.481610189 */, - /* 38 */ 0x07fc14bf | (8 << 27) /* 0.499043224 */, - /* 39 */ 0x04220ed7 | (9 << 27) /* 0.258314934 */, - /* 40 */ 0x04466275 | (9 << 27) /* 0.267183742 */, - /* 41 */ 0x046b03e7 | (9 << 27) /* 0.276126771 */, - /* 42 */ 0x048ff1e8 | (9 << 27) /* 0.285142811 */, - /* 43 */ 0x04b52b3f | (9 << 27) /* 0.294230696 */, - /* 44 */ 0x04daaec0 | (9 << 27) /* 0.303389310 */, - /* 45 */ 0x05007b49 | (9 << 27) /* 0.312617576 */, - /* 46 */ 0x05268fc6 | (9 << 27) /* 0.321914457 */, - /* 47 */ 0x054ceb2a | (9 << 27) /* 0.331278957 */, - - /* 48 */ 0x05738c72 | (9 << 27) /* 0.340710111 */, - /* 49 */ 0x059a72a5 | (9 << 27) /* 0.350206992 */, - /* 50 */ 0x05c19cd3 | (9 << 27) /* 0.359768701 */, - /* 51 */ 0x05e90a12 | (9 << 27) /* 0.369394372 */, - /* 52 */ 0x0610b982 | (9 << 27) /* 0.379083164 */, - /* 53 */ 0x0638aa48 | (9 << 27) /* 0.388834268 */, - /* 54 */ 0x0660db91 | (9 << 27) /* 0.398646895 */, - /* 55 */ 0x06894c90 | (9 << 27) /* 0.408520284 */, - /* 56 */ 0x06b1fc81 | (9 << 27) /* 0.418453696 */, - /* 57 */ 0x06daeaa1 | (9 << 27) /* 0.428446415 */, - /* 58 */ 0x07041636 | (9 << 27) /* 0.438497744 */, - /* 59 */ 0x072d7e8b | (9 << 27) /* 0.448607009 */, - /* 60 */ 0x075722ef | (9 << 27) /* 0.458773552 */, - /* 61 */ 0x078102b8 | (9 << 27) /* 0.468996735 */, - /* 62 */ 0x07ab1d3e | (9 << 27) /* 0.479275937 */, - /* 63 */ 0x07d571e0 | (9 << 27) /* 0.489610555 */, - - /* 64 */ 0x04000000 | (10 << 27) /* 0.250000000 */, - /* 65 */ 0x04156381 | (10 << 27) /* 0.255221850 */, - /* 66 */ 0x042ae32a | (10 << 27) /* 0.260470548 */, - /* 67 */ 0x04407eb1 | (10 << 27) /* 0.265745823 */, - /* 68 */ 0x045635cf | (10 << 27) /* 0.271047409 */, - /* 69 */ 0x046c083e | (10 << 27) /* 0.276375048 */, - /* 70 */ 0x0481f5bb | (10 << 27) /* 0.281728487 */, - /* 71 */ 0x0497fe03 | (10 << 27) /* 0.287107481 */, - /* 72 */ 0x04ae20d7 | (10 << 27) /* 0.292511788 */, - /* 73 */ 0x04c45df6 | (10 << 27) /* 0.297941173 */, - /* 74 */ 0x04dab524 | (10 << 27) /* 0.303395408 */, - /* 75 */ 0x04f12624 | (10 << 27) /* 0.308874267 */, - /* 76 */ 0x0507b0bc | (10 << 27) /* 0.314377532 */, - /* 77 */ 0x051e54b1 | (10 << 27) /* 0.319904987 */, - /* 78 */ 0x053511cb | (10 << 27) /* 0.325456423 */, - /* 79 */ 0x054be7d4 | (10 << 27) /* 0.331031635 */, - - /* 80 */ 0x0562d694 | (10 << 27) /* 0.336630420 */, - /* 81 */ 0x0579ddd8 | (10 << 27) /* 0.342252584 */, - /* 82 */ 0x0590fd6c | (10 << 27) /* 0.347897931 */, - /* 83 */ 0x05a8351c | (10 << 27) /* 0.353566275 */, - /* 84 */ 0x05bf84b8 | (10 << 27) /* 0.359257429 */, - /* 85 */ 0x05d6ec0e | (10 << 27) /* 0.364971213 */, - /* 86 */ 0x05ee6aef | (10 << 27) /* 0.370707448 */, - /* 87 */ 0x0606012b | (10 << 27) /* 0.376465960 */, - /* 88 */ 0x061dae96 | (10 << 27) /* 0.382246578 */, - /* 89 */ 0x06357302 | (10 << 27) /* 0.388049134 */, - /* 90 */ 0x064d4e43 | (10 << 27) /* 0.393873464 */, - /* 91 */ 0x0665402d | (10 << 27) /* 0.399719406 */, - /* 92 */ 0x067d4896 | (10 << 27) /* 0.405586801 */, - /* 93 */ 0x06956753 | (10 << 27) /* 0.411475493 */, - /* 94 */ 0x06ad9c3d | (10 << 27) /* 0.417385331 */, - /* 95 */ 0x06c5e72b | (10 << 27) /* 0.423316162 */, - - /* 96 */ 0x06de47f4 | (10 << 27) /* 0.429267841 */, - /* 97 */ 0x06f6be73 | (10 << 27) /* 0.435240221 */, - /* 98 */ 0x070f4a80 | (10 << 27) /* 0.441233161 */, - /* 99 */ 0x0727ebf7 | (10 << 27) /* 0.447246519 */, - /* 100 */ 0x0740a2b2 | (10 << 27) /* 0.453280160 */, - /* 101 */ 0x07596e8d | (10 << 27) /* 0.459333946 */, - /* 102 */ 0x07724f64 | (10 << 27) /* 0.465407744 */, - /* 103 */ 0x078b4514 | (10 << 27) /* 0.471501425 */, - /* 104 */ 0x07a44f7a | (10 << 27) /* 0.477614858 */, - /* 105 */ 0x07bd6e75 | (10 << 27) /* 0.483747918 */, - /* 106 */ 0x07d6a1e2 | (10 << 27) /* 0.489900479 */, - /* 107 */ 0x07efe9a1 | (10 << 27) /* 0.496072418 */, - /* 108 */ 0x0404a2c9 | (11 << 27) /* 0.251131807 */, - /* 109 */ 0x04115aca | (11 << 27) /* 0.254236974 */, - /* 110 */ 0x041e1cc4 | (11 << 27) /* 0.257351652 */, - /* 111 */ 0x042ae8a7 | (11 << 27) /* 0.260475783 */, - - /* 112 */ 0x0437be65 | (11 << 27) /* 0.263609310 */, - /* 113 */ 0x04449dee | (11 << 27) /* 0.266752177 */, - /* 114 */ 0x04518733 | (11 << 27) /* 0.269904329 */, - /* 115 */ 0x045e7a26 | (11 << 27) /* 0.273065710 */, - /* 116 */ 0x046b76b9 | (11 << 27) /* 0.276236269 */, - /* 117 */ 0x04787cdc | (11 << 27) /* 0.279415952 */, - /* 118 */ 0x04858c83 | (11 << 27) /* 0.282604707 */, - /* 119 */ 0x0492a59f | (11 << 27) /* 0.285802482 */, - /* 120 */ 0x049fc824 | (11 << 27) /* 0.289009227 */, - /* 121 */ 0x04acf402 | (11 << 27) /* 0.292224893 */, - /* 122 */ 0x04ba292e | (11 << 27) /* 0.295449429 */, - /* 123 */ 0x04c7679a | (11 << 27) /* 0.298682788 */, - /* 124 */ 0x04d4af3a | (11 << 27) /* 0.301924921 */, - /* 125 */ 0x04e20000 | (11 << 27) /* 0.305175781 */, - /* 126 */ 0x04ef59e0 | (11 << 27) /* 0.308435322 */, - /* 127 */ 0x04fcbcce | (11 << 27) /* 0.311703498 */, - - /* 128 */ 0x050a28be | (11 << 27) /* 0.314980262 */, - /* 129 */ 0x05179da4 | (11 << 27) /* 0.318265572 */, - /* 130 */ 0x05251b73 | (11 << 27) /* 0.321559381 */, - /* 131 */ 0x0532a220 | (11 << 27) /* 0.324861647 */, - /* 132 */ 0x054031a0 | (11 << 27) /* 0.328172327 */, - /* 133 */ 0x054dc9e7 | (11 << 27) /* 0.331491377 */, - /* 134 */ 0x055b6ae9 | (11 << 27) /* 0.334818756 */, - /* 135 */ 0x0569149c | (11 << 27) /* 0.338154423 */, - /* 136 */ 0x0576c6f5 | (11 << 27) /* 0.341498336 */, - /* 137 */ 0x058481e9 | (11 << 27) /* 0.344850455 */, - /* 138 */ 0x0592456d | (11 << 27) /* 0.348210741 */, - /* 139 */ 0x05a01176 | (11 << 27) /* 0.351579152 */, - /* 140 */ 0x05ade5fa | (11 << 27) /* 0.354955651 */, - /* 141 */ 0x05bbc2ef | (11 << 27) /* 0.358340200 */, - /* 142 */ 0x05c9a84a | (11 << 27) /* 0.361732758 */, - /* 143 */ 0x05d79601 | (11 << 27) /* 0.365133291 */, - - /* 144 */ 0x05e58c0b | (11 << 27) /* 0.368541759 */, - /* 145 */ 0x05f38a5d | (11 << 27) /* 0.371958126 */, - /* 146 */ 0x060190ee | (11 << 27) /* 0.375382356 */, - /* 147 */ 0x060f9fb3 | (11 << 27) /* 0.378814413 */, - /* 148 */ 0x061db6a5 | (11 << 27) /* 0.382254261 */, - /* 149 */ 0x062bd5b8 | (11 << 27) /* 0.385701865 */, - /* 150 */ 0x0639fce4 | (11 << 27) /* 0.389157191 */, - /* 151 */ 0x06482c1f | (11 << 27) /* 0.392620204 */, - /* 152 */ 0x06566361 | (11 << 27) /* 0.396090870 */, - /* 153 */ 0x0664a2a0 | (11 << 27) /* 0.399569155 */, - /* 154 */ 0x0672e9d4 | (11 << 27) /* 0.403055027 */, - /* 155 */ 0x068138f3 | (11 << 27) /* 0.406548452 */, - /* 156 */ 0x068f8ff5 | (11 << 27) /* 0.410049398 */, - /* 157 */ 0x069deed1 | (11 << 27) /* 0.413557833 */, - /* 158 */ 0x06ac557f | (11 << 27) /* 0.417073724 */, - /* 159 */ 0x06bac3f6 | (11 << 27) /* 0.420597041 */, - - /* 160 */ 0x06c93a2e | (11 << 27) /* 0.424127753 */, - /* 161 */ 0x06d7b81f | (11 << 27) /* 0.427665827 */, - /* 162 */ 0x06e63dc0 | (11 << 27) /* 0.431211234 */, - /* 163 */ 0x06f4cb09 | (11 << 27) /* 0.434763944 */, - /* 164 */ 0x07035ff3 | (11 << 27) /* 0.438323927 */, - /* 165 */ 0x0711fc75 | (11 << 27) /* 0.441891153 */, - /* 166 */ 0x0720a087 | (11 << 27) /* 0.445465593 */, - /* 167 */ 0x072f4c22 | (11 << 27) /* 0.449047217 */, - /* 168 */ 0x073dff3e | (11 << 27) /* 0.452635998 */, - /* 169 */ 0x074cb9d3 | (11 << 27) /* 0.456231906 */, - /* 170 */ 0x075b7bdb | (11 << 27) /* 0.459834914 */, - /* 171 */ 0x076a454c | (11 << 27) /* 0.463444993 */, - /* 172 */ 0x07791620 | (11 << 27) /* 0.467062117 */, - /* 173 */ 0x0787ee50 | (11 << 27) /* 0.470686258 */, - /* 174 */ 0x0796cdd4 | (11 << 27) /* 0.474317388 */, - /* 175 */ 0x07a5b4a5 | (11 << 27) /* 0.477955481 */, - - /* 176 */ 0x07b4a2bc | (11 << 27) /* 0.481600510 */, - /* 177 */ 0x07c39812 | (11 << 27) /* 0.485252449 */, - /* 178 */ 0x07d294a0 | (11 << 27) /* 0.488911273 */, - /* 179 */ 0x07e1985f | (11 << 27) /* 0.492576954 */, - /* 180 */ 0x07f0a348 | (11 << 27) /* 0.496249468 */, - /* 181 */ 0x07ffb554 | (11 << 27) /* 0.499928790 */, - /* 182 */ 0x0407673f | (12 << 27) /* 0.251807447 */, - /* 183 */ 0x040ef75e | (12 << 27) /* 0.253653877 */, - /* 184 */ 0x04168b05 | (12 << 27) /* 0.255503674 */, - /* 185 */ 0x041e2230 | (12 << 27) /* 0.257356825 */, - /* 186 */ 0x0425bcdd | (12 << 27) /* 0.259213318 */, - /* 187 */ 0x042d5b07 | (12 << 27) /* 0.261073141 */, - /* 188 */ 0x0434fcad | (12 << 27) /* 0.262936282 */, - /* 189 */ 0x043ca1c9 | (12 << 27) /* 0.264802730 */, - /* 190 */ 0x04444a5a | (12 << 27) /* 0.266672472 */, - /* 191 */ 0x044bf65d | (12 << 27) /* 0.268545497 */, - - /* 192 */ 0x0453a5cd | (12 << 27) /* 0.270421794 */, - /* 193 */ 0x045b58a9 | (12 << 27) /* 0.272301352 */, - /* 194 */ 0x04630eed | (12 << 27) /* 0.274184158 */, - /* 195 */ 0x046ac896 | (12 << 27) /* 0.276070203 */, - /* 196 */ 0x047285a2 | (12 << 27) /* 0.277959474 */, - /* 197 */ 0x047a460c | (12 << 27) /* 0.279851960 */, - /* 198 */ 0x048209d3 | (12 << 27) /* 0.281747652 */, - /* 199 */ 0x0489d0f4 | (12 << 27) /* 0.283646538 */, - /* 200 */ 0x04919b6a | (12 << 27) /* 0.285548607 */, - /* 201 */ 0x04996935 | (12 << 27) /* 0.287453849 */, - /* 202 */ 0x04a13a50 | (12 << 27) /* 0.289362253 */, - /* 203 */ 0x04a90eba | (12 << 27) /* 0.291273810 */, - /* 204 */ 0x04b0e66e | (12 << 27) /* 0.293188507 */, - /* 205 */ 0x04b8c16c | (12 << 27) /* 0.295106336 */, - /* 206 */ 0x04c09faf | (12 << 27) /* 0.297027285 */, - /* 207 */ 0x04c88135 | (12 << 27) /* 0.298951346 */, - - /* 208 */ 0x04d065fb | (12 << 27) /* 0.300878507 */, - /* 209 */ 0x04d84dff | (12 << 27) /* 0.302808759 */, - /* 210 */ 0x04e0393e | (12 << 27) /* 0.304742092 */, - /* 211 */ 0x04e827b6 | (12 << 27) /* 0.306678497 */, - /* 212 */ 0x04f01963 | (12 << 27) /* 0.308617963 */, - /* 213 */ 0x04f80e44 | (12 << 27) /* 0.310560480 */, - /* 214 */ 0x05000655 | (12 << 27) /* 0.312506041 */, - /* 215 */ 0x05080195 | (12 << 27) /* 0.314454634 */, - /* 216 */ 0x05100000 | (12 << 27) /* 0.316406250 */, - /* 217 */ 0x05180194 | (12 << 27) /* 0.318360880 */, - /* 218 */ 0x0520064f | (12 << 27) /* 0.320318516 */, - /* 219 */ 0x05280e2d | (12 << 27) /* 0.322279147 */, - /* 220 */ 0x0530192e | (12 << 27) /* 0.324242764 */, - /* 221 */ 0x0538274e | (12 << 27) /* 0.326209359 */, - /* 222 */ 0x0540388a | (12 << 27) /* 0.328178922 */, - /* 223 */ 0x05484ce2 | (12 << 27) /* 0.330151445 */, - - /* 224 */ 0x05506451 | (12 << 27) /* 0.332126919 */, - /* 225 */ 0x05587ed5 | (12 << 27) /* 0.334105334 */, - /* 226 */ 0x05609c6e | (12 << 27) /* 0.336086683 */, - /* 227 */ 0x0568bd17 | (12 << 27) /* 0.338070956 */, - /* 228 */ 0x0570e0cf | (12 << 27) /* 0.340058145 */, - /* 229 */ 0x05790793 | (12 << 27) /* 0.342048241 */, - /* 230 */ 0x05813162 | (12 << 27) /* 0.344041237 */, - /* 231 */ 0x05895e39 | (12 << 27) /* 0.346037122 */, - /* 232 */ 0x05918e15 | (12 << 27) /* 0.348035890 */, - /* 233 */ 0x0599c0f4 | (12 << 27) /* 0.350037532 */, - /* 234 */ 0x05a1f6d5 | (12 << 27) /* 0.352042040 */, - /* 235 */ 0x05aa2fb5 | (12 << 27) /* 0.354049405 */, - /* 236 */ 0x05b26b92 | (12 << 27) /* 0.356059619 */, - /* 237 */ 0x05baaa69 | (12 << 27) /* 0.358072674 */, - /* 238 */ 0x05c2ec39 | (12 << 27) /* 0.360088563 */, - /* 239 */ 0x05cb3100 | (12 << 27) /* 0.362107278 */, - - /* 240 */ 0x05d378bb | (12 << 27) /* 0.364128809 */, - /* 241 */ 0x05dbc368 | (12 << 27) /* 0.366153151 */, - /* 242 */ 0x05e41105 | (12 << 27) /* 0.368180294 */, - /* 243 */ 0x05ec6190 | (12 << 27) /* 0.370210231 */, - /* 244 */ 0x05f4b507 | (12 << 27) /* 0.372242955 */, - /* 245 */ 0x05fd0b68 | (12 << 27) /* 0.374278458 */, - /* 246 */ 0x060564b1 | (12 << 27) /* 0.376316732 */, - /* 247 */ 0x060dc0e0 | (12 << 27) /* 0.378357769 */, - /* 248 */ 0x06161ff3 | (12 << 27) /* 0.380401563 */, - /* 249 */ 0x061e81e8 | (12 << 27) /* 0.382448106 */, - /* 250 */ 0x0626e6bc | (12 << 27) /* 0.384497391 */, - /* 251 */ 0x062f4e6f | (12 << 27) /* 0.386549409 */, - /* 252 */ 0x0637b8fd | (12 << 27) /* 0.388604155 */, - /* 253 */ 0x06402666 | (12 << 27) /* 0.390661620 */, - /* 254 */ 0x064896a7 | (12 << 27) /* 0.392721798 */, - /* 255 */ 0x065109be | (12 << 27) /* 0.394784681 */, - - /* 256 */ 0x06597fa9 | (12 << 27) /* 0.396850263 */, - /* 257 */ 0x0661f867 | (12 << 27) /* 0.398918536 */, - /* 258 */ 0x066a73f5 | (12 << 27) /* 0.400989493 */, - /* 259 */ 0x0672f252 | (12 << 27) /* 0.403063128 */, - /* 260 */ 0x067b737c | (12 << 27) /* 0.405139433 */, - /* 261 */ 0x0683f771 | (12 << 27) /* 0.407218402 */, - /* 262 */ 0x068c7e2f | (12 << 27) /* 0.409300027 */, - /* 263 */ 0x069507b5 | (12 << 27) /* 0.411384303 */, - /* 264 */ 0x069d9400 | (12 << 27) /* 0.413471222 */, - /* 265 */ 0x06a6230f | (12 << 27) /* 0.415560778 */, - /* 266 */ 0x06aeb4e0 | (12 << 27) /* 0.417652964 */, - /* 267 */ 0x06b74971 | (12 << 27) /* 0.419747773 */, - /* 268 */ 0x06bfe0c0 | (12 << 27) /* 0.421845199 */, - /* 269 */ 0x06c87acc | (12 << 27) /* 0.423945235 */, - /* 270 */ 0x06d11794 | (12 << 27) /* 0.426047876 */, - /* 271 */ 0x06d9b714 | (12 << 27) /* 0.428153114 */, - - /* 272 */ 0x06e2594c | (12 << 27) /* 0.430260942 */, - /* 273 */ 0x06eafe3a | (12 << 27) /* 0.432371356 */, - /* 274 */ 0x06f3a5dc | (12 << 27) /* 0.434484348 */, - /* 275 */ 0x06fc5030 | (12 << 27) /* 0.436599912 */, - /* 276 */ 0x0704fd35 | (12 << 27) /* 0.438718042 */, - /* 277 */ 0x070dacea | (12 << 27) /* 0.440838732 */, - /* 278 */ 0x07165f4b | (12 << 27) /* 0.442961975 */, - /* 279 */ 0x071f1459 | (12 << 27) /* 0.445087765 */, - /* 280 */ 0x0727cc11 | (12 << 27) /* 0.447216097 */, - /* 281 */ 0x07308671 | (12 << 27) /* 0.449346964 */, - /* 282 */ 0x07394378 | (12 << 27) /* 0.451480360 */, - /* 283 */ 0x07420325 | (12 << 27) /* 0.453616280 */, - /* 284 */ 0x074ac575 | (12 << 27) /* 0.455754717 */, - /* 285 */ 0x07538a67 | (12 << 27) /* 0.457895665 */, - /* 286 */ 0x075c51fa | (12 << 27) /* 0.460039119 */, - /* 287 */ 0x07651c2c | (12 << 27) /* 0.462185072 */, - - /* 288 */ 0x076de8fc | (12 << 27) /* 0.464333519 */, - /* 289 */ 0x0776b867 | (12 << 27) /* 0.466484455 */, - /* 290 */ 0x077f8a6d | (12 << 27) /* 0.468637872 */, - /* 291 */ 0x07885f0b | (12 << 27) /* 0.470793767 */, - /* 292 */ 0x07913641 | (12 << 27) /* 0.472952132 */, - /* 293 */ 0x079a100c | (12 << 27) /* 0.475112962 */, - /* 294 */ 0x07a2ec6c | (12 << 27) /* 0.477276252 */, - /* 295 */ 0x07abcb5f | (12 << 27) /* 0.479441997 */, - /* 296 */ 0x07b4ace3 | (12 << 27) /* 0.481610189 */, - /* 297 */ 0x07bd90f6 | (12 << 27) /* 0.483780825 */, - /* 298 */ 0x07c67798 | (12 << 27) /* 0.485953899 */, - /* 299 */ 0x07cf60c7 | (12 << 27) /* 0.488129404 */, - /* 300 */ 0x07d84c81 | (12 << 27) /* 0.490307336 */, - /* 301 */ 0x07e13ac5 | (12 << 27) /* 0.492487690 */, - /* 302 */ 0x07ea2b92 | (12 << 27) /* 0.494670459 */, - /* 303 */ 0x07f31ee6 | (12 << 27) /* 0.496855639 */, - - /* 304 */ 0x07fc14bf | (12 << 27) /* 0.499043224 */, - /* 305 */ 0x0402868e | (13 << 27) /* 0.250616605 */, - /* 306 */ 0x040703ff | (13 << 27) /* 0.251712795 */, - /* 307 */ 0x040b82b0 | (13 << 27) /* 0.252810180 */, - /* 308 */ 0x041002a1 | (13 << 27) /* 0.253908756 */, - /* 309 */ 0x041483d1 | (13 << 27) /* 0.255008523 */, - /* 310 */ 0x04190640 | (13 << 27) /* 0.256109476 */, - /* 311 */ 0x041d89ed | (13 << 27) /* 0.257211614 */, - /* 312 */ 0x04220ed7 | (13 << 27) /* 0.258314934 */, - /* 313 */ 0x042694fe | (13 << 27) /* 0.259419433 */, - /* 314 */ 0x042b1c60 | (13 << 27) /* 0.260525110 */, - /* 315 */ 0x042fa4fe | (13 << 27) /* 0.261631960 */, - /* 316 */ 0x04342ed7 | (13 << 27) /* 0.262739982 */, - /* 317 */ 0x0438b9e9 | (13 << 27) /* 0.263849174 */, - /* 318 */ 0x043d4635 | (13 << 27) /* 0.264959533 */, - /* 319 */ 0x0441d3b9 | (13 << 27) /* 0.266071056 */, - - /* 320 */ 0x04466275 | (13 << 27) /* 0.267183742 */, - /* 321 */ 0x044af269 | (13 << 27) /* 0.268297587 */, - /* 322 */ 0x044f8393 | (13 << 27) /* 0.269412589 */, - /* 323 */ 0x045415f3 | (13 << 27) /* 0.270528746 */, - /* 324 */ 0x0458a989 | (13 << 27) /* 0.271646056 */, - /* 325 */ 0x045d3e53 | (13 << 27) /* 0.272764515 */, - /* 326 */ 0x0461d451 | (13 << 27) /* 0.273884123 */, - /* 327 */ 0x04666b83 | (13 << 27) /* 0.275004875 */, - /* 328 */ 0x046b03e7 | (13 << 27) /* 0.276126771 */, - /* 329 */ 0x046f9d7e | (13 << 27) /* 0.277249808 */, - /* 330 */ 0x04743847 | (13 << 27) /* 0.278373983 */, - /* 331 */ 0x0478d440 | (13 << 27) /* 0.279499294 */, - /* 332 */ 0x047d716a | (13 << 27) /* 0.280625739 */, - /* 333 */ 0x04820fc3 | (13 << 27) /* 0.281753315 */, - /* 334 */ 0x0486af4c | (13 << 27) /* 0.282882021 */, - /* 335 */ 0x048b5003 | (13 << 27) /* 0.284011853 */, - - /* 336 */ 0x048ff1e8 | (13 << 27) /* 0.285142811 */, - /* 337 */ 0x049494fb | (13 << 27) /* 0.286274891 */, - /* 338 */ 0x0499393a | (13 << 27) /* 0.287408091 */, - /* 339 */ 0x049ddea5 | (13 << 27) /* 0.288542409 */, - /* 340 */ 0x04a2853c | (13 << 27) /* 0.289677844 */, - /* 341 */ 0x04a72cfe | (13 << 27) /* 0.290814392 */, - /* 342 */ 0x04abd5ea | (13 << 27) /* 0.291952051 */, - /* 343 */ 0x04b08000 | (13 << 27) /* 0.293090820 */, - /* 344 */ 0x04b52b3f | (13 << 27) /* 0.294230696 */, - /* 345 */ 0x04b9d7a7 | (13 << 27) /* 0.295371678 */, - /* 346 */ 0x04be8537 | (13 << 27) /* 0.296513762 */, - /* 347 */ 0x04c333ee | (13 << 27) /* 0.297656947 */, - /* 348 */ 0x04c7e3cc | (13 << 27) /* 0.298801231 */, - /* 349 */ 0x04cc94d1 | (13 << 27) /* 0.299946611 */, - /* 350 */ 0x04d146fb | (13 << 27) /* 0.301093085 */, - /* 351 */ 0x04d5fa4b | (13 << 27) /* 0.302240653 */, - - /* 352 */ 0x04daaec0 | (13 << 27) /* 0.303389310 */, - /* 353 */ 0x04df6458 | (13 << 27) /* 0.304539056 */, - /* 354 */ 0x04e41b14 | (13 << 27) /* 0.305689888 */, - /* 355 */ 0x04e8d2f3 | (13 << 27) /* 0.306841804 */, - /* 356 */ 0x04ed8bf5 | (13 << 27) /* 0.307994802 */, - /* 357 */ 0x04f24618 | (13 << 27) /* 0.309148880 */, - /* 358 */ 0x04f7015d | (13 << 27) /* 0.310304037 */, - /* 359 */ 0x04fbbdc3 | (13 << 27) /* 0.311460269 */, - /* 360 */ 0x05007b49 | (13 << 27) /* 0.312617576 */, - /* 361 */ 0x050539ef | (13 << 27) /* 0.313775954 */, - /* 362 */ 0x0509f9b4 | (13 << 27) /* 0.314935403 */, - /* 363 */ 0x050eba98 | (13 << 27) /* 0.316095920 */, - /* 364 */ 0x05137c9a | (13 << 27) /* 0.317257503 */, - /* 365 */ 0x05183fba | (13 << 27) /* 0.318420150 */, - /* 366 */ 0x051d03f7 | (13 << 27) /* 0.319583859 */, - /* 367 */ 0x0521c950 | (13 << 27) /* 0.320748629 */, - - /* 368 */ 0x05268fc6 | (13 << 27) /* 0.321914457 */, - /* 369 */ 0x052b5757 | (13 << 27) /* 0.323081342 */, - /* 370 */ 0x05302003 | (13 << 27) /* 0.324249281 */, - /* 371 */ 0x0534e9ca | (13 << 27) /* 0.325418273 */, - /* 372 */ 0x0539b4ab | (13 << 27) /* 0.326588316 */, - /* 373 */ 0x053e80a6 | (13 << 27) /* 0.327759407 */, - /* 374 */ 0x05434db9 | (13 << 27) /* 0.328931546 */, - /* 375 */ 0x05481be5 | (13 << 27) /* 0.330104730 */, - /* 376 */ 0x054ceb2a | (13 << 27) /* 0.331278957 */, - /* 377 */ 0x0551bb85 | (13 << 27) /* 0.332454225 */, - /* 378 */ 0x05568cf8 | (13 << 27) /* 0.333630533 */, - /* 379 */ 0x055b5f81 | (13 << 27) /* 0.334807879 */, - /* 380 */ 0x05603321 | (13 << 27) /* 0.335986261 */, - /* 381 */ 0x056507d6 | (13 << 27) /* 0.337165677 */, - /* 382 */ 0x0569dda0 | (13 << 27) /* 0.338346125 */, - /* 383 */ 0x056eb47f | (13 << 27) /* 0.339527604 */, - - /* 384 */ 0x05738c72 | (13 << 27) /* 0.340710111 */, - /* 385 */ 0x05786578 | (13 << 27) /* 0.341893646 */, - /* 386 */ 0x057d3f92 | (13 << 27) /* 0.343078205 */, - /* 387 */ 0x05821abf | (13 << 27) /* 0.344263788 */, - /* 388 */ 0x0586f6fd | (13 << 27) /* 0.345450393 */, - /* 389 */ 0x058bd44e | (13 << 27) /* 0.346638017 */, - /* 390 */ 0x0590b2b0 | (13 << 27) /* 0.347826659 */, - /* 391 */ 0x05959222 | (13 << 27) /* 0.349016318 */, - /* 392 */ 0x059a72a5 | (13 << 27) /* 0.350206992 */, - /* 393 */ 0x059f5438 | (13 << 27) /* 0.351398678 */, - /* 394 */ 0x05a436da | (13 << 27) /* 0.352591376 */, - /* 395 */ 0x05a91a8c | (13 << 27) /* 0.353785083 */, - /* 396 */ 0x05adff4c | (13 << 27) /* 0.354979798 */, - /* 397 */ 0x05b2e51a | (13 << 27) /* 0.356175519 */, - /* 398 */ 0x05b7cbf5 | (13 << 27) /* 0.357372244 */, - /* 399 */ 0x05bcb3de | (13 << 27) /* 0.358569972 */, - - /* 400 */ 0x05c19cd3 | (13 << 27) /* 0.359768701 */, - /* 401 */ 0x05c686d5 | (13 << 27) /* 0.360968429 */, - /* 402 */ 0x05cb71e2 | (13 << 27) /* 0.362169156 */, - /* 403 */ 0x05d05dfb | (13 << 27) /* 0.363370878 */, - /* 404 */ 0x05d54b1f | (13 << 27) /* 0.364573594 */, - /* 405 */ 0x05da394d | (13 << 27) /* 0.365777304 */, - /* 406 */ 0x05df2885 | (13 << 27) /* 0.366982004 */, - /* 407 */ 0x05e418c7 | (13 << 27) /* 0.368187694 */, - /* 408 */ 0x05e90a12 | (13 << 27) /* 0.369394372 */, - /* 409 */ 0x05edfc66 | (13 << 27) /* 0.370602036 */, - /* 410 */ 0x05f2efc2 | (13 << 27) /* 0.371810684 */, - /* 411 */ 0x05f7e426 | (13 << 27) /* 0.373020316 */, - /* 412 */ 0x05fcd992 | (13 << 27) /* 0.374230929 */, - /* 413 */ 0x0601d004 | (13 << 27) /* 0.375442522 */, - /* 414 */ 0x0606c77d | (13 << 27) /* 0.376655093 */, - /* 415 */ 0x060bbffd | (13 << 27) /* 0.377868641 */, - - /* 416 */ 0x0610b982 | (13 << 27) /* 0.379083164 */, - /* 417 */ 0x0615b40c | (13 << 27) /* 0.380298661 */, - /* 418 */ 0x061aaf9c | (13 << 27) /* 0.381515130 */, - /* 419 */ 0x061fac2f | (13 << 27) /* 0.382732569 */, - /* 420 */ 0x0624a9c7 | (13 << 27) /* 0.383950977 */, - /* 421 */ 0x0629a863 | (13 << 27) /* 0.385170352 */, - /* 422 */ 0x062ea802 | (13 << 27) /* 0.386390694 */, - /* 423 */ 0x0633a8a3 | (13 << 27) /* 0.387611999 */, - /* 424 */ 0x0638aa48 | (13 << 27) /* 0.388834268 */, - /* 425 */ 0x063dacee | (13 << 27) /* 0.390057497 */, - /* 426 */ 0x0642b096 | (13 << 27) /* 0.391281687 */, - /* 427 */ 0x0647b53f | (13 << 27) /* 0.392506834 */, - /* 428 */ 0x064cbae9 | (13 << 27) /* 0.393732939 */, - /* 429 */ 0x0651c193 | (13 << 27) /* 0.394959999 */, - /* 430 */ 0x0656c93d | (13 << 27) /* 0.396188012 */, - /* 431 */ 0x065bd1e7 | (13 << 27) /* 0.397416978 */, - - /* 432 */ 0x0660db91 | (13 << 27) /* 0.398646895 */, - /* 433 */ 0x0665e639 | (13 << 27) /* 0.399877761 */, - /* 434 */ 0x066af1df | (13 << 27) /* 0.401109575 */, - /* 435 */ 0x066ffe84 | (13 << 27) /* 0.402342335 */, - /* 436 */ 0x06750c26 | (13 << 27) /* 0.403576041 */, - /* 437 */ 0x067a1ac6 | (13 << 27) /* 0.404810690 */, - /* 438 */ 0x067f2a62 | (13 << 27) /* 0.406046281 */, - /* 439 */ 0x06843afb | (13 << 27) /* 0.407282813 */, - /* 440 */ 0x06894c90 | (13 << 27) /* 0.408520284 */, - /* 441 */ 0x068e5f21 | (13 << 27) /* 0.409758693 */, - /* 442 */ 0x069372ae | (13 << 27) /* 0.410998038 */, - /* 443 */ 0x06988735 | (13 << 27) /* 0.412238319 */, - /* 444 */ 0x069d9cb7 | (13 << 27) /* 0.413479532 */, - /* 445 */ 0x06a2b333 | (13 << 27) /* 0.414721679 */, - /* 446 */ 0x06a7caa9 | (13 << 27) /* 0.415964756 */, - /* 447 */ 0x06ace318 | (13 << 27) /* 0.417208762 */, - - /* 448 */ 0x06b1fc81 | (13 << 27) /* 0.418453696 */, - /* 449 */ 0x06b716e2 | (13 << 27) /* 0.419699557 */, - /* 450 */ 0x06bc323b | (13 << 27) /* 0.420946343 */, - /* 451 */ 0x06c14e8d | (13 << 27) /* 0.422194054 */, - /* 452 */ 0x06c66bd6 | (13 << 27) /* 0.423442686 */, - /* 453 */ 0x06cb8a17 | (13 << 27) /* 0.424692240 */, - /* 454 */ 0x06d0a94e | (13 << 27) /* 0.425942714 */, - /* 455 */ 0x06d5c97c | (13 << 27) /* 0.427194106 */, - /* 456 */ 0x06daeaa1 | (13 << 27) /* 0.428446415 */, - /* 457 */ 0x06e00cbb | (13 << 27) /* 0.429699640 */, - /* 458 */ 0x06e52fca | (13 << 27) /* 0.430953779 */, - /* 459 */ 0x06ea53cf | (13 << 27) /* 0.432208832 */, - /* 460 */ 0x06ef78c8 | (13 << 27) /* 0.433464796 */, - /* 461 */ 0x06f49eb6 | (13 << 27) /* 0.434721671 */, - /* 462 */ 0x06f9c597 | (13 << 27) /* 0.435979455 */, - /* 463 */ 0x06feed6d | (13 << 27) /* 0.437238146 */, - - /* 464 */ 0x07041636 | (13 << 27) /* 0.438497744 */, - /* 465 */ 0x07093ff2 | (13 << 27) /* 0.439758248 */, - /* 466 */ 0x070e6aa0 | (13 << 27) /* 0.441019655 */, - /* 467 */ 0x07139641 | (13 << 27) /* 0.442281965 */, - /* 468 */ 0x0718c2d3 | (13 << 27) /* 0.443545176 */, - /* 469 */ 0x071df058 | (13 << 27) /* 0.444809288 */, - /* 470 */ 0x07231ecd | (13 << 27) /* 0.446074298 */, - /* 471 */ 0x07284e34 | (13 << 27) /* 0.447340205 */, - /* 472 */ 0x072d7e8b | (13 << 27) /* 0.448607009 */, - /* 473 */ 0x0732afd2 | (13 << 27) /* 0.449874708 */, - /* 474 */ 0x0737e209 | (13 << 27) /* 0.451143300 */, - /* 475 */ 0x073d1530 | (13 << 27) /* 0.452412785 */, - /* 476 */ 0x07424946 | (13 << 27) /* 0.453683161 */, - /* 477 */ 0x07477e4b | (13 << 27) /* 0.454954427 */, - /* 478 */ 0x074cb43e | (13 << 27) /* 0.456226581 */, - /* 479 */ 0x0751eb20 | (13 << 27) /* 0.457499623 */, - - /* 480 */ 0x075722ef | (13 << 27) /* 0.458773552 */, - /* 481 */ 0x075c5bac | (13 << 27) /* 0.460048365 */, - /* 482 */ 0x07619557 | (13 << 27) /* 0.461324062 */, - /* 483 */ 0x0766cfee | (13 << 27) /* 0.462600642 */, - /* 484 */ 0x076c0b72 | (13 << 27) /* 0.463878102 */, - /* 485 */ 0x077147e2 | (13 << 27) /* 0.465156443 */, - /* 486 */ 0x0776853e | (13 << 27) /* 0.466435663 */, - /* 487 */ 0x077bc385 | (13 << 27) /* 0.467715761 */, - /* 488 */ 0x078102b8 | (13 << 27) /* 0.468996735 */, - /* 489 */ 0x078642d6 | (13 << 27) /* 0.470278584 */, - /* 490 */ 0x078b83de | (13 << 27) /* 0.471561307 */, - /* 491 */ 0x0790c5d1 | (13 << 27) /* 0.472844904 */, - /* 492 */ 0x079608ae | (13 << 27) /* 0.474129372 */, - /* 493 */ 0x079b4c74 | (13 << 27) /* 0.475414710 */, - /* 494 */ 0x07a09124 | (13 << 27) /* 0.476700918 */, - /* 495 */ 0x07a5d6bd | (13 << 27) /* 0.477987994 */, - - /* 496 */ 0x07ab1d3e | (13 << 27) /* 0.479275937 */, - /* 497 */ 0x07b064a8 | (13 << 27) /* 0.480564746 */, - /* 498 */ 0x07b5acfb | (13 << 27) /* 0.481854420 */, - /* 499 */ 0x07baf635 | (13 << 27) /* 0.483144957 */, - /* 500 */ 0x07c04056 | (13 << 27) /* 0.484436356 */, - /* 501 */ 0x07c58b5f | (13 << 27) /* 0.485728617 */, - /* 502 */ 0x07cad74e | (13 << 27) /* 0.487021738 */, - /* 503 */ 0x07d02424 | (13 << 27) /* 0.488315717 */, - /* 504 */ 0x07d571e0 | (13 << 27) /* 0.489610555 */, - /* 505 */ 0x07dac083 | (13 << 27) /* 0.490906249 */, - /* 506 */ 0x07e0100a | (13 << 27) /* 0.492202799 */, - /* 507 */ 0x07e56078 | (13 << 27) /* 0.493500203 */, - /* 508 */ 0x07eab1ca | (13 << 27) /* 0.494798460 */, - /* 509 */ 0x07f00401 | (13 << 27) /* 0.496097570 */, - /* 510 */ 0x07f5571d | (13 << 27) /* 0.497397530 */, - /* 511 */ 0x07faab1c | (13 << 27) /* 0.498698341 */, - - /* 512 */ 0x04000000 | (14 << 27) /* 0.250000000 */, - /* 513 */ 0x0402aae3 | (14 << 27) /* 0.250651254 */, - /* 514 */ 0x04055638 | (14 << 27) /* 0.251302930 */, - /* 515 */ 0x040801ff | (14 << 27) /* 0.251955030 */, - /* 516 */ 0x040aae37 | (14 << 27) /* 0.252607552 */, - /* 517 */ 0x040d5ae0 | (14 << 27) /* 0.253260495 */, - /* 518 */ 0x041007fa | (14 << 27) /* 0.253913860 */, - /* 519 */ 0x0412b586 | (14 << 27) /* 0.254567645 */, - /* 520 */ 0x04156381 | (14 << 27) /* 0.255221850 */, - /* 521 */ 0x041811ee | (14 << 27) /* 0.255876475 */, - /* 522 */ 0x041ac0cb | (14 << 27) /* 0.256531518 */, - /* 523 */ 0x041d7018 | (14 << 27) /* 0.257186980 */, - /* 524 */ 0x04201fd5 | (14 << 27) /* 0.257842860 */, - /* 525 */ 0x0422d003 | (14 << 27) /* 0.258499157 */, - /* 526 */ 0x042580a0 | (14 << 27) /* 0.259155872 */, - /* 527 */ 0x042831ad | (14 << 27) /* 0.259813002 */, - - /* 528 */ 0x042ae32a | (14 << 27) /* 0.260470548 */, - /* 529 */ 0x042d9516 | (14 << 27) /* 0.261128510 */, - /* 530 */ 0x04304772 | (14 << 27) /* 0.261786886 */, - /* 531 */ 0x0432fa3d | (14 << 27) /* 0.262445676 */, - /* 532 */ 0x0435ad76 | (14 << 27) /* 0.263104880 */, - /* 533 */ 0x0438611f | (14 << 27) /* 0.263764497 */, - /* 534 */ 0x043b1536 | (14 << 27) /* 0.264424527 */, - /* 535 */ 0x043dc9bc | (14 << 27) /* 0.265084969 */, - /* 536 */ 0x04407eb1 | (14 << 27) /* 0.265745823 */, - /* 537 */ 0x04433414 | (14 << 27) /* 0.266407088 */, - /* 538 */ 0x0445e9e5 | (14 << 27) /* 0.267068763 */, - /* 539 */ 0x0448a024 | (14 << 27) /* 0.267730848 */, - /* 540 */ 0x044b56d1 | (14 << 27) /* 0.268393343 */, - /* 541 */ 0x044e0dec | (14 << 27) /* 0.269056248 */, - /* 542 */ 0x0450c575 | (14 << 27) /* 0.269719560 */, - /* 543 */ 0x04537d6b | (14 << 27) /* 0.270383281 */, - - /* 544 */ 0x045635cf | (14 << 27) /* 0.271047409 */, - /* 545 */ 0x0458ee9f | (14 << 27) /* 0.271711944 */, - /* 546 */ 0x045ba7dd | (14 << 27) /* 0.272376886 */, - /* 547 */ 0x045e6188 | (14 << 27) /* 0.273042234 */, - /* 548 */ 0x04611ba0 | (14 << 27) /* 0.273707988 */, - /* 549 */ 0x0463d625 | (14 << 27) /* 0.274374147 */, - /* 550 */ 0x04669116 | (14 << 27) /* 0.275040710 */, - /* 551 */ 0x04694c74 | (14 << 27) /* 0.275707677 */, - /* 552 */ 0x046c083e | (14 << 27) /* 0.276375048 */, - /* 553 */ 0x046ec474 | (14 << 27) /* 0.277042822 */, - /* 554 */ 0x04718116 | (14 << 27) /* 0.277710999 */, - /* 555 */ 0x04743e25 | (14 << 27) /* 0.278379578 */, - /* 556 */ 0x0476fb9f | (14 << 27) /* 0.279048558 */, - /* 557 */ 0x0479b984 | (14 << 27) /* 0.279717940 */, - /* 558 */ 0x047c77d6 | (14 << 27) /* 0.280387722 */, - /* 559 */ 0x047f3693 | (14 << 27) /* 0.281057905 */, - - /* 560 */ 0x0481f5bb | (14 << 27) /* 0.281728487 */, - /* 561 */ 0x0484b54e | (14 << 27) /* 0.282399469 */, - /* 562 */ 0x0487754c | (14 << 27) /* 0.283070849 */, - /* 563 */ 0x048a35b6 | (14 << 27) /* 0.283742628 */, - /* 564 */ 0x048cf68a | (14 << 27) /* 0.284414805 */, - /* 565 */ 0x048fb7c8 | (14 << 27) /* 0.285087379 */, - /* 566 */ 0x04927972 | (14 << 27) /* 0.285760350 */, - /* 567 */ 0x04953b85 | (14 << 27) /* 0.286433717 */, - /* 568 */ 0x0497fe03 | (14 << 27) /* 0.287107481 */, - /* 569 */ 0x049ac0eb | (14 << 27) /* 0.287781640 */, - /* 570 */ 0x049d843e | (14 << 27) /* 0.288456194 */, - /* 571 */ 0x04a047fa | (14 << 27) /* 0.289131142 */, - /* 572 */ 0x04a30c20 | (14 << 27) /* 0.289806485 */, - /* 573 */ 0x04a5d0af | (14 << 27) /* 0.290482221 */, - /* 574 */ 0x04a895a8 | (14 << 27) /* 0.291158351 */, - /* 575 */ 0x04ab5b0b | (14 << 27) /* 0.291834873 */, - - /* 576 */ 0x04ae20d7 | (14 << 27) /* 0.292511788 */, - /* 577 */ 0x04b0e70c | (14 << 27) /* 0.293189094 */, - /* 578 */ 0x04b3adaa | (14 << 27) /* 0.293866792 */, - /* 579 */ 0x04b674b1 | (14 << 27) /* 0.294544881 */, - /* 580 */ 0x04b93c21 | (14 << 27) /* 0.295223360 */, - /* 581 */ 0x04bc03fa | (14 << 27) /* 0.295902229 */, - /* 582 */ 0x04becc3b | (14 << 27) /* 0.296581488 */, - /* 583 */ 0x04c194e4 | (14 << 27) /* 0.297261136 */, - /* 584 */ 0x04c45df6 | (14 << 27) /* 0.297941173 */, - /* 585 */ 0x04c72771 | (14 << 27) /* 0.298621598 */, - /* 586 */ 0x04c9f153 | (14 << 27) /* 0.299302411 */, - /* 587 */ 0x04ccbb9d | (14 << 27) /* 0.299983611 */, - /* 588 */ 0x04cf864f | (14 << 27) /* 0.300665198 */, - /* 589 */ 0x04d25169 | (14 << 27) /* 0.301347172 */, - /* 590 */ 0x04d51ceb | (14 << 27) /* 0.302029532 */, - /* 591 */ 0x04d7e8d4 | (14 << 27) /* 0.302712277 */, - - /* 592 */ 0x04dab524 | (14 << 27) /* 0.303395408 */, - /* 593 */ 0x04dd81dc | (14 << 27) /* 0.304078923 */, - /* 594 */ 0x04e04efb | (14 << 27) /* 0.304762823 */, - /* 595 */ 0x04e31c81 | (14 << 27) /* 0.305447106 */, - /* 596 */ 0x04e5ea6e | (14 << 27) /* 0.306131773 */, - /* 597 */ 0x04e8b8c2 | (14 << 27) /* 0.306816823 */, - /* 598 */ 0x04eb877c | (14 << 27) /* 0.307502256 */, - /* 599 */ 0x04ee569d | (14 << 27) /* 0.308188071 */, - /* 600 */ 0x04f12624 | (14 << 27) /* 0.308874267 */, - /* 601 */ 0x04f3f612 | (14 << 27) /* 0.309560845 */, - /* 602 */ 0x04f6c666 | (14 << 27) /* 0.310247804 */, - /* 603 */ 0x04f99721 | (14 << 27) /* 0.310935143 */, - /* 604 */ 0x04fc6841 | (14 << 27) /* 0.311622862 */, - /* 605 */ 0x04ff39c7 | (14 << 27) /* 0.312310961 */, - /* 606 */ 0x05020bb3 | (14 << 27) /* 0.312999439 */, - /* 607 */ 0x0504de05 | (14 << 27) /* 0.313688296 */, - - /* 608 */ 0x0507b0bc | (14 << 27) /* 0.314377532 */, - /* 609 */ 0x050a83d8 | (14 << 27) /* 0.315067145 */, - /* 610 */ 0x050d575b | (14 << 27) /* 0.315757136 */, - /* 611 */ 0x05102b42 | (14 << 27) /* 0.316447504 */, - /* 612 */ 0x0512ff8e | (14 << 27) /* 0.317138249 */, - /* 613 */ 0x0515d440 | (14 << 27) /* 0.317829370 */, - /* 614 */ 0x0518a956 | (14 << 27) /* 0.318520867 */, - /* 615 */ 0x051b7ed1 | (14 << 27) /* 0.319212739 */, - /* 616 */ 0x051e54b1 | (14 << 27) /* 0.319904987 */, - /* 617 */ 0x05212af5 | (14 << 27) /* 0.320597609 */, - /* 618 */ 0x0524019e | (14 << 27) /* 0.321290606 */, - /* 619 */ 0x0526d8ab | (14 << 27) /* 0.321983976 */, - /* 620 */ 0x0529b01d | (14 << 27) /* 0.322677720 */, - /* 621 */ 0x052c87f2 | (14 << 27) /* 0.323371837 */, - /* 622 */ 0x052f602c | (14 << 27) /* 0.324066327 */, - /* 623 */ 0x053238ca | (14 << 27) /* 0.324761189 */, - - /* 624 */ 0x053511cb | (14 << 27) /* 0.325456423 */, - /* 625 */ 0x0537eb30 | (14 << 27) /* 0.326152028 */, - /* 626 */ 0x053ac4f9 | (14 << 27) /* 0.326848005 */, - /* 627 */ 0x053d9f25 | (14 << 27) /* 0.327544352 */, - /* 628 */ 0x054079b5 | (14 << 27) /* 0.328241070 */, - /* 629 */ 0x054354a8 | (14 << 27) /* 0.328938157 */, - /* 630 */ 0x05462ffe | (14 << 27) /* 0.329635614 */, - /* 631 */ 0x05490bb7 | (14 << 27) /* 0.330333440 */, - /* 632 */ 0x054be7d4 | (14 << 27) /* 0.331031635 */, - /* 633 */ 0x054ec453 | (14 << 27) /* 0.331730198 */, - /* 634 */ 0x0551a134 | (14 << 27) /* 0.332429129 */, - /* 635 */ 0x05547e79 | (14 << 27) /* 0.333128427 */, - /* 636 */ 0x05575c20 | (14 << 27) /* 0.333828093 */, - /* 637 */ 0x055a3a2a | (14 << 27) /* 0.334528126 */, - /* 638 */ 0x055d1896 | (14 << 27) /* 0.335228525 */, - /* 639 */ 0x055ff764 | (14 << 27) /* 0.335929290 */, - - /* 640 */ 0x0562d694 | (14 << 27) /* 0.336630420 */, - /* 641 */ 0x0565b627 | (14 << 27) /* 0.337331916 */, - /* 642 */ 0x0568961b | (14 << 27) /* 0.338033777 */, - /* 643 */ 0x056b7671 | (14 << 27) /* 0.338736002 */, - /* 644 */ 0x056e5729 | (14 << 27) /* 0.339438592 */, - /* 645 */ 0x05713843 | (14 << 27) /* 0.340141545 */, - /* 646 */ 0x057419be | (14 << 27) /* 0.340844862 */, - /* 647 */ 0x0576fb9a | (14 << 27) /* 0.341548541 */, - /* 648 */ 0x0579ddd8 | (14 << 27) /* 0.342252584 */, - /* 649 */ 0x057cc077 | (14 << 27) /* 0.342956988 */, - /* 650 */ 0x057fa378 | (14 << 27) /* 0.343661754 */, - /* 651 */ 0x058286d9 | (14 << 27) /* 0.344366882 */, - /* 652 */ 0x05856a9b | (14 << 27) /* 0.345072371 */, - /* 653 */ 0x05884ebe | (14 << 27) /* 0.345778221 */, - /* 654 */ 0x058b3342 | (14 << 27) /* 0.346484431 */, - /* 655 */ 0x058e1827 | (14 << 27) /* 0.347191002 */, - - /* 656 */ 0x0590fd6c | (14 << 27) /* 0.347897931 */, - /* 657 */ 0x0593e311 | (14 << 27) /* 0.348605221 */, - /* 658 */ 0x0596c917 | (14 << 27) /* 0.349312869 */, - /* 659 */ 0x0599af7d | (14 << 27) /* 0.350020876 */, - /* 660 */ 0x059c9643 | (14 << 27) /* 0.350729240 */, - /* 661 */ 0x059f7d6a | (14 << 27) /* 0.351437963 */, - /* 662 */ 0x05a264f0 | (14 << 27) /* 0.352147044 */, - /* 663 */ 0x05a54cd6 | (14 << 27) /* 0.352856481 */, - /* 664 */ 0x05a8351c | (14 << 27) /* 0.353566275 */, - /* 665 */ 0x05ab1dc2 | (14 << 27) /* 0.354276426 */, - /* 666 */ 0x05ae06c7 | (14 << 27) /* 0.354986932 */, - /* 667 */ 0x05b0f02b | (14 << 27) /* 0.355697795 */, - /* 668 */ 0x05b3d9f0 | (14 << 27) /* 0.356409012 */, - /* 669 */ 0x05b6c413 | (14 << 27) /* 0.357120585 */, - /* 670 */ 0x05b9ae95 | (14 << 27) /* 0.357832512 */, - /* 671 */ 0x05bc9977 | (14 << 27) /* 0.358544794 */, - - /* 672 */ 0x05bf84b8 | (14 << 27) /* 0.359257429 */, - /* 673 */ 0x05c27057 | (14 << 27) /* 0.359970419 */, - /* 674 */ 0x05c55c56 | (14 << 27) /* 0.360683761 */, - /* 675 */ 0x05c848b3 | (14 << 27) /* 0.361397456 */, - /* 676 */ 0x05cb356e | (14 << 27) /* 0.362111504 */, - /* 677 */ 0x05ce2289 | (14 << 27) /* 0.362825904 */, - /* 678 */ 0x05d11001 | (14 << 27) /* 0.363540655 */, - /* 679 */ 0x05d3fdd8 | (14 << 27) /* 0.364255759 */, - /* 680 */ 0x05d6ec0e | (14 << 27) /* 0.364971213 */, - /* 681 */ 0x05d9daa1 | (14 << 27) /* 0.365687018 */, - /* 682 */ 0x05dcc993 | (14 << 27) /* 0.366403174 */, - /* 683 */ 0x05dfb8e2 | (14 << 27) /* 0.367119680 */, - /* 684 */ 0x05e2a890 | (14 << 27) /* 0.367836535 */, - /* 685 */ 0x05e5989b | (14 << 27) /* 0.368553740 */, - /* 686 */ 0x05e88904 | (14 << 27) /* 0.369271294 */, - /* 687 */ 0x05eb79cb | (14 << 27) /* 0.369989197 */, - - /* 688 */ 0x05ee6aef | (14 << 27) /* 0.370707448 */, - /* 689 */ 0x05f15c70 | (14 << 27) /* 0.371426047 */, - /* 690 */ 0x05f44e4f | (14 << 27) /* 0.372144994 */, - /* 691 */ 0x05f7408b | (14 << 27) /* 0.372864289 */, - /* 692 */ 0x05fa3324 | (14 << 27) /* 0.373583930 */, - /* 693 */ 0x05fd261b | (14 << 27) /* 0.374303918 */, - /* 694 */ 0x0600196e | (14 << 27) /* 0.375024253 */, - /* 695 */ 0x06030d1e | (14 << 27) /* 0.375744934 */, - /* 696 */ 0x0606012b | (14 << 27) /* 0.376465960 */, - /* 697 */ 0x0608f595 | (14 << 27) /* 0.377187332 */, - /* 698 */ 0x060bea5c | (14 << 27) /* 0.377909049 */, - /* 699 */ 0x060edf7f | (14 << 27) /* 0.378631110 */, - /* 700 */ 0x0611d4fe | (14 << 27) /* 0.379353516 */, - /* 701 */ 0x0614cada | (14 << 27) /* 0.380076266 */, - /* 702 */ 0x0617c112 | (14 << 27) /* 0.380799360 */, - /* 703 */ 0x061ab7a6 | (14 << 27) /* 0.381522798 */, - - /* 704 */ 0x061dae96 | (14 << 27) /* 0.382246578 */, - /* 705 */ 0x0620a5e3 | (14 << 27) /* 0.382970701 */, - /* 706 */ 0x06239d8b | (14 << 27) /* 0.383695167 */, - /* 707 */ 0x0626958f | (14 << 27) /* 0.384419975 */, - /* 708 */ 0x06298def | (14 << 27) /* 0.385145124 */, - /* 709 */ 0x062c86aa | (14 << 27) /* 0.385870615 */, - /* 710 */ 0x062f7fc1 | (14 << 27) /* 0.386596448 */, - /* 711 */ 0x06327934 | (14 << 27) /* 0.387322621 */, - /* 712 */ 0x06357302 | (14 << 27) /* 0.388049134 */, - /* 713 */ 0x06386d2b | (14 << 27) /* 0.388775988 */, - /* 714 */ 0x063b67b0 | (14 << 27) /* 0.389503182 */, - /* 715 */ 0x063e6290 | (14 << 27) /* 0.390230715 */, - /* 716 */ 0x06415dcb | (14 << 27) /* 0.390958588 */, - /* 717 */ 0x06445960 | (14 << 27) /* 0.391686799 */, - /* 718 */ 0x06475551 | (14 << 27) /* 0.392415349 */, - /* 719 */ 0x064a519c | (14 << 27) /* 0.393144238 */, - - /* 720 */ 0x064d4e43 | (14 << 27) /* 0.393873464 */, - /* 721 */ 0x06504b44 | (14 << 27) /* 0.394603028 */, - /* 722 */ 0x0653489f | (14 << 27) /* 0.395332930 */, - /* 723 */ 0x06564655 | (14 << 27) /* 0.396063168 */, - /* 724 */ 0x06594465 | (14 << 27) /* 0.396793743 */, - /* 725 */ 0x065c42d0 | (14 << 27) /* 0.397524655 */, - /* 726 */ 0x065f4195 | (14 << 27) /* 0.398255903 */, - /* 727 */ 0x066240b4 | (14 << 27) /* 0.398987487 */, - /* 728 */ 0x0665402d | (14 << 27) /* 0.399719406 */, - /* 729 */ 0x06684000 | (14 << 27) /* 0.400451660 */, - /* 730 */ 0x066b402d | (14 << 27) /* 0.401184249 */, - /* 731 */ 0x066e40b3 | (14 << 27) /* 0.401917173 */, - /* 732 */ 0x06714194 | (14 << 27) /* 0.402650431 */, - /* 733 */ 0x067442ce | (14 << 27) /* 0.403384024 */, - /* 734 */ 0x06774462 | (14 << 27) /* 0.404117949 */, - /* 735 */ 0x067a464f | (14 << 27) /* 0.404852209 */, - - /* 736 */ 0x067d4896 | (14 << 27) /* 0.405586801 */, - /* 737 */ 0x06804b36 | (14 << 27) /* 0.406321726 */, - /* 738 */ 0x06834e2f | (14 << 27) /* 0.407056983 */, - /* 739 */ 0x06865181 | (14 << 27) /* 0.407792573 */, - /* 740 */ 0x0689552c | (14 << 27) /* 0.408528495 */, - /* 741 */ 0x068c5931 | (14 << 27) /* 0.409264748 */, - /* 742 */ 0x068f5d8e | (14 << 27) /* 0.410001332 */, - /* 743 */ 0x06926245 | (14 << 27) /* 0.410738247 */, - /* 744 */ 0x06956753 | (14 << 27) /* 0.411475493 */, - /* 745 */ 0x06986cbb | (14 << 27) /* 0.412213070 */, - /* 746 */ 0x069b727b | (14 << 27) /* 0.412950976 */, - /* 747 */ 0x069e7894 | (14 << 27) /* 0.413689213 */, - /* 748 */ 0x06a17f05 | (14 << 27) /* 0.414427779 */, - /* 749 */ 0x06a485cf | (14 << 27) /* 0.415166674 */, - /* 750 */ 0x06a78cf1 | (14 << 27) /* 0.415905897 */, - /* 751 */ 0x06aa946b | (14 << 27) /* 0.416645450 */, - - /* 752 */ 0x06ad9c3d | (14 << 27) /* 0.417385331 */, - /* 753 */ 0x06b0a468 | (14 << 27) /* 0.418125540 */, - /* 754 */ 0x06b3acea | (14 << 27) /* 0.418866076 */, - /* 755 */ 0x06b6b5c4 | (14 << 27) /* 0.419606940 */, - /* 756 */ 0x06b9bef6 | (14 << 27) /* 0.420348132 */, - /* 757 */ 0x06bcc880 | (14 << 27) /* 0.421089650 */, - /* 758 */ 0x06bfd261 | (14 << 27) /* 0.421831494 */, - /* 759 */ 0x06c2dc9a | (14 << 27) /* 0.422573665 */, - /* 760 */ 0x06c5e72b | (14 << 27) /* 0.423316162 */, - /* 761 */ 0x06c8f213 | (14 << 27) /* 0.424058985 */, - /* 762 */ 0x06cbfd52 | (14 << 27) /* 0.424802133 */, - /* 763 */ 0x06cf08e9 | (14 << 27) /* 0.425545607 */, - /* 764 */ 0x06d214d7 | (14 << 27) /* 0.426289405 */, - /* 765 */ 0x06d5211c | (14 << 27) /* 0.427033528 */, - /* 766 */ 0x06d82db8 | (14 << 27) /* 0.427777975 */, - /* 767 */ 0x06db3aaa | (14 << 27) /* 0.428522746 */, - - /* 768 */ 0x06de47f4 | (14 << 27) /* 0.429267841 */, - /* 769 */ 0x06e15595 | (14 << 27) /* 0.430013259 */, - /* 770 */ 0x06e4638d | (14 << 27) /* 0.430759001 */, - /* 771 */ 0x06e771db | (14 << 27) /* 0.431505065 */, - /* 772 */ 0x06ea807f | (14 << 27) /* 0.432251452 */, - /* 773 */ 0x06ed8f7b | (14 << 27) /* 0.432998162 */, - /* 774 */ 0x06f09ecc | (14 << 27) /* 0.433745193 */, - /* 775 */ 0x06f3ae75 | (14 << 27) /* 0.434492546 */, - /* 776 */ 0x06f6be73 | (14 << 27) /* 0.435240221 */, - /* 777 */ 0x06f9cec8 | (14 << 27) /* 0.435988217 */, - /* 778 */ 0x06fcdf72 | (14 << 27) /* 0.436736534 */, - /* 779 */ 0x06fff073 | (14 << 27) /* 0.437485172 */, - /* 780 */ 0x070301ca | (14 << 27) /* 0.438234130 */, - /* 781 */ 0x07061377 | (14 << 27) /* 0.438983408 */, - /* 782 */ 0x0709257a | (14 << 27) /* 0.439733006 */, - /* 783 */ 0x070c37d2 | (14 << 27) /* 0.440482924 */, - - /* 784 */ 0x070f4a80 | (14 << 27) /* 0.441233161 */, - /* 785 */ 0x07125d84 | (14 << 27) /* 0.441983717 */, - /* 786 */ 0x071570de | (14 << 27) /* 0.442734592 */, - /* 787 */ 0x0718848d | (14 << 27) /* 0.443485785 */, - /* 788 */ 0x071b9891 | (14 << 27) /* 0.444237296 */, - /* 789 */ 0x071eaceb | (14 << 27) /* 0.444989126 */, - /* 790 */ 0x0721c19a | (14 << 27) /* 0.445741273 */, - /* 791 */ 0x0724d69e | (14 << 27) /* 0.446493738 */, - /* 792 */ 0x0727ebf7 | (14 << 27) /* 0.447246519 */, - /* 793 */ 0x072b01a6 | (14 << 27) /* 0.447999618 */, - /* 794 */ 0x072e17a9 | (14 << 27) /* 0.448753033 */, - /* 795 */ 0x07312e01 | (14 << 27) /* 0.449506765 */, - /* 796 */ 0x073444ae | (14 << 27) /* 0.450260813 */, - /* 797 */ 0x07375bb0 | (14 << 27) /* 0.451015176 */, - /* 798 */ 0x073a7307 | (14 << 27) /* 0.451769856 */, - /* 799 */ 0x073d8ab2 | (14 << 27) /* 0.452524850 */, - - /* 800 */ 0x0740a2b2 | (14 << 27) /* 0.453280160 */, - /* 801 */ 0x0743bb06 | (14 << 27) /* 0.454035784 */, - /* 802 */ 0x0746d3af | (14 << 27) /* 0.454791723 */, - /* 803 */ 0x0749ecac | (14 << 27) /* 0.455547976 */, - /* 804 */ 0x074d05fe | (14 << 27) /* 0.456304543 */, - /* 805 */ 0x07501fa3 | (14 << 27) /* 0.457061423 */, - /* 806 */ 0x0753399d | (14 << 27) /* 0.457818618 */, - /* 807 */ 0x075653eb | (14 << 27) /* 0.458576125 */, - /* 808 */ 0x07596e8d | (14 << 27) /* 0.459333946 */, - /* 809 */ 0x075c8983 | (14 << 27) /* 0.460092079 */, - /* 810 */ 0x075fa4cc | (14 << 27) /* 0.460850524 */, - /* 811 */ 0x0762c06a | (14 << 27) /* 0.461609282 */, - /* 812 */ 0x0765dc5b | (14 << 27) /* 0.462368352 */, - /* 813 */ 0x0768f8a0 | (14 << 27) /* 0.463127733 */, - /* 814 */ 0x076c1538 | (14 << 27) /* 0.463887426 */, - /* 815 */ 0x076f3224 | (14 << 27) /* 0.464647430 */, - - /* 816 */ 0x07724f64 | (14 << 27) /* 0.465407744 */, - /* 817 */ 0x07756cf7 | (14 << 27) /* 0.466168370 */, - /* 818 */ 0x07788add | (14 << 27) /* 0.466929306 */, - /* 819 */ 0x077ba916 | (14 << 27) /* 0.467690552 */, - /* 820 */ 0x077ec7a3 | (14 << 27) /* 0.468452108 */, - /* 821 */ 0x0781e683 | (14 << 27) /* 0.469213973 */, - /* 822 */ 0x078505b5 | (14 << 27) /* 0.469976148 */, - /* 823 */ 0x0788253b | (14 << 27) /* 0.470738632 */, - /* 824 */ 0x078b4514 | (14 << 27) /* 0.471501425 */, - /* 825 */ 0x078e653f | (14 << 27) /* 0.472264527 */, - /* 826 */ 0x079185be | (14 << 27) /* 0.473027937 */, - /* 827 */ 0x0794a68f | (14 << 27) /* 0.473791655 */, - /* 828 */ 0x0797c7b2 | (14 << 27) /* 0.474555681 */, - /* 829 */ 0x079ae929 | (14 << 27) /* 0.475320014 */, - /* 830 */ 0x079e0af1 | (14 << 27) /* 0.476084655 */, - /* 831 */ 0x07a12d0c | (14 << 27) /* 0.476849603 */, - - /* 832 */ 0x07a44f7a | (14 << 27) /* 0.477614858 */, - /* 833 */ 0x07a7723a | (14 << 27) /* 0.478380420 */, - /* 834 */ 0x07aa954c | (14 << 27) /* 0.479146288 */, - /* 835 */ 0x07adb8b0 | (14 << 27) /* 0.479912463 */, - /* 836 */ 0x07b0dc67 | (14 << 27) /* 0.480678943 */, - /* 837 */ 0x07b4006f | (14 << 27) /* 0.481445729 */, - /* 838 */ 0x07b724ca | (14 << 27) /* 0.482212820 */, - /* 839 */ 0x07ba4976 | (14 << 27) /* 0.482980216 */, - /* 840 */ 0x07bd6e75 | (14 << 27) /* 0.483747918 */, - /* 841 */ 0x07c093c5 | (14 << 27) /* 0.484515924 */, - /* 842 */ 0x07c3b967 | (14 << 27) /* 0.485284235 */, - /* 843 */ 0x07c6df5a | (14 << 27) /* 0.486052849 */, - /* 844 */ 0x07ca059f | (14 << 27) /* 0.486821768 */, - /* 845 */ 0x07cd2c36 | (14 << 27) /* 0.487590991 */, - /* 846 */ 0x07d0531e | (14 << 27) /* 0.488360517 */, - /* 847 */ 0x07d37a57 | (14 << 27) /* 0.489130346 */, - - /* 848 */ 0x07d6a1e2 | (14 << 27) /* 0.489900479 */, - /* 849 */ 0x07d9c9be | (14 << 27) /* 0.490670914 */, - /* 850 */ 0x07dcf1ec | (14 << 27) /* 0.491441651 */, - /* 851 */ 0x07e01a6a | (14 << 27) /* 0.492212691 */, - /* 852 */ 0x07e3433a | (14 << 27) /* 0.492984033 */, - /* 853 */ 0x07e66c5a | (14 << 27) /* 0.493755677 */, - /* 854 */ 0x07e995cc | (14 << 27) /* 0.494527623 */, - /* 855 */ 0x07ecbf8e | (14 << 27) /* 0.495299870 */, - /* 856 */ 0x07efe9a1 | (14 << 27) /* 0.496072418 */, - /* 857 */ 0x07f31405 | (14 << 27) /* 0.496845266 */, - /* 858 */ 0x07f63eba | (14 << 27) /* 0.497618416 */, - /* 859 */ 0x07f969c0 | (14 << 27) /* 0.498391866 */, - /* 860 */ 0x07fc9516 | (14 << 27) /* 0.499165616 */, - /* 861 */ 0x07ffc0bc | (14 << 27) /* 0.499939666 */, - /* 862 */ 0x04017659 | (15 << 27) /* 0.250357008 */, - /* 863 */ 0x04030c7d | (15 << 27) /* 0.250744333 */, - - /* 864 */ 0x0404a2c9 | (15 << 27) /* 0.251131807 */, - /* 865 */ 0x0406393d | (15 << 27) /* 0.251519431 */, - /* 866 */ 0x0407cfd9 | (15 << 27) /* 0.251907204 */, - /* 867 */ 0x0409669d | (15 << 27) /* 0.252295127 */, - /* 868 */ 0x040afd89 | (15 << 27) /* 0.252683198 */, - /* 869 */ 0x040c949e | (15 << 27) /* 0.253071419 */, - /* 870 */ 0x040e2bda | (15 << 27) /* 0.253459789 */, - /* 871 */ 0x040fc33e | (15 << 27) /* 0.253848307 */, - /* 872 */ 0x04115aca | (15 << 27) /* 0.254236974 */, - /* 873 */ 0x0412f27e | (15 << 27) /* 0.254625790 */, - /* 874 */ 0x04148a5a | (15 << 27) /* 0.255014755 */, - /* 875 */ 0x0416225d | (15 << 27) /* 0.255403867 */, - /* 876 */ 0x0417ba89 | (15 << 27) /* 0.255793128 */, - /* 877 */ 0x041952dc | (15 << 27) /* 0.256182537 */, - /* 878 */ 0x041aeb57 | (15 << 27) /* 0.256572095 */, - /* 879 */ 0x041c83fa | (15 << 27) /* 0.256961800 */, - - /* 880 */ 0x041e1cc4 | (15 << 27) /* 0.257351652 */, - /* 881 */ 0x041fb5b6 | (15 << 27) /* 0.257741653 */, - /* 882 */ 0x04214ed0 | (15 << 27) /* 0.258131801 */, - /* 883 */ 0x0422e811 | (15 << 27) /* 0.258522097 */, - /* 884 */ 0x04248179 | (15 << 27) /* 0.258912540 */, - /* 885 */ 0x04261b0a | (15 << 27) /* 0.259303130 */, - /* 886 */ 0x0427b4c2 | (15 << 27) /* 0.259693868 */, - /* 887 */ 0x04294ea1 | (15 << 27) /* 0.260084752 */, - /* 888 */ 0x042ae8a7 | (15 << 27) /* 0.260475783 */, - /* 889 */ 0x042c82d6 | (15 << 27) /* 0.260866961 */, - /* 890 */ 0x042e1d2b | (15 << 27) /* 0.261258286 */, - /* 891 */ 0x042fb7a8 | (15 << 27) /* 0.261649758 */, - /* 892 */ 0x0431524c | (15 << 27) /* 0.262041376 */, - /* 893 */ 0x0432ed17 | (15 << 27) /* 0.262433140 */, - /* 894 */ 0x0434880a | (15 << 27) /* 0.262825051 */, - /* 895 */ 0x04362324 | (15 << 27) /* 0.263217107 */, - - /* 896 */ 0x0437be65 | (15 << 27) /* 0.263609310 */, - /* 897 */ 0x043959cd | (15 << 27) /* 0.264001659 */, - /* 898 */ 0x043af55d | (15 << 27) /* 0.264394153 */, - /* 899 */ 0x043c9113 | (15 << 27) /* 0.264786794 */, - /* 900 */ 0x043e2cf1 | (15 << 27) /* 0.265179580 */, - /* 901 */ 0x043fc8f6 | (15 << 27) /* 0.265572511 */, - /* 902 */ 0x04416522 | (15 << 27) /* 0.265965588 */, - /* 903 */ 0x04430174 | (15 << 27) /* 0.266358810 */, - /* 904 */ 0x04449dee | (15 << 27) /* 0.266752177 */, - /* 905 */ 0x04463a8f | (15 << 27) /* 0.267145689 */, - /* 906 */ 0x0447d756 | (15 << 27) /* 0.267539347 */, - /* 907 */ 0x04497445 | (15 << 27) /* 0.267933149 */, - /* 908 */ 0x044b115a | (15 << 27) /* 0.268327096 */, - /* 909 */ 0x044cae96 | (15 << 27) /* 0.268721187 */, - /* 910 */ 0x044e4bf9 | (15 << 27) /* 0.269115423 */, - /* 911 */ 0x044fe983 | (15 << 27) /* 0.269509804 */, - - /* 912 */ 0x04518733 | (15 << 27) /* 0.269904329 */, - /* 913 */ 0x0453250a | (15 << 27) /* 0.270298998 */, - /* 914 */ 0x0454c308 | (15 << 27) /* 0.270693811 */, - /* 915 */ 0x0456612d | (15 << 27) /* 0.271088768 */, - /* 916 */ 0x0457ff78 | (15 << 27) /* 0.271483869 */, - /* 917 */ 0x04599dea | (15 << 27) /* 0.271879114 */, - /* 918 */ 0x045b3c82 | (15 << 27) /* 0.272274503 */, - /* 919 */ 0x045cdb41 | (15 << 27) /* 0.272670035 */, - /* 920 */ 0x045e7a26 | (15 << 27) /* 0.273065710 */, - /* 921 */ 0x04601932 | (15 << 27) /* 0.273461530 */, - /* 922 */ 0x0461b864 | (15 << 27) /* 0.273857492 */, - /* 923 */ 0x046357bd | (15 << 27) /* 0.274253597 */, - /* 924 */ 0x0464f73c | (15 << 27) /* 0.274649846 */, - /* 925 */ 0x046696e2 | (15 << 27) /* 0.275046238 */, - /* 926 */ 0x046836ae | (15 << 27) /* 0.275442772 */, - /* 927 */ 0x0469d6a0 | (15 << 27) /* 0.275839449 */, - - /* 928 */ 0x046b76b9 | (15 << 27) /* 0.276236269 */, - /* 929 */ 0x046d16f7 | (15 << 27) /* 0.276633232 */, - /* 930 */ 0x046eb75c | (15 << 27) /* 0.277030337 */, - /* 931 */ 0x047057e8 | (15 << 27) /* 0.277427584 */, - /* 932 */ 0x0471f899 | (15 << 27) /* 0.277824973 */, - /* 933 */ 0x04739971 | (15 << 27) /* 0.278222505 */, - /* 934 */ 0x04753a6f | (15 << 27) /* 0.278620179 */, - /* 935 */ 0x0476db92 | (15 << 27) /* 0.279017995 */, - /* 936 */ 0x04787cdc | (15 << 27) /* 0.279415952 */, - /* 937 */ 0x047a1e4c | (15 << 27) /* 0.279814051 */, - /* 938 */ 0x047bbfe2 | (15 << 27) /* 0.280212292 */, - /* 939 */ 0x047d619e | (15 << 27) /* 0.280610675 */, - /* 940 */ 0x047f0380 | (15 << 27) /* 0.281009199 */, - /* 941 */ 0x0480a588 | (15 << 27) /* 0.281407864 */, - /* 942 */ 0x048247b6 | (15 << 27) /* 0.281806670 */, - /* 943 */ 0x0483ea0a | (15 << 27) /* 0.282205618 */, - - /* 944 */ 0x04858c83 | (15 << 27) /* 0.282604707 */, - /* 945 */ 0x04872f22 | (15 << 27) /* 0.283003936 */, - /* 946 */ 0x0488d1e8 | (15 << 27) /* 0.283403307 */, - /* 947 */ 0x048a74d3 | (15 << 27) /* 0.283802818 */, - /* 948 */ 0x048c17e3 | (15 << 27) /* 0.284202470 */, - /* 949 */ 0x048dbb1a | (15 << 27) /* 0.284602263 */, - /* 950 */ 0x048f5e76 | (15 << 27) /* 0.285002195 */, - /* 951 */ 0x049101f8 | (15 << 27) /* 0.285402269 */, - /* 952 */ 0x0492a59f | (15 << 27) /* 0.285802482 */, - /* 953 */ 0x0494496c | (15 << 27) /* 0.286202836 */, - /* 954 */ 0x0495ed5f | (15 << 27) /* 0.286603329 */, - /* 955 */ 0x04979177 | (15 << 27) /* 0.287003963 */, - /* 956 */ 0x049935b5 | (15 << 27) /* 0.287404737 */, - /* 957 */ 0x049ada19 | (15 << 27) /* 0.287805650 */, - /* 958 */ 0x049c7ea1 | (15 << 27) /* 0.288206703 */, - /* 959 */ 0x049e2350 | (15 << 27) /* 0.288607895 */, - - /* 960 */ 0x049fc824 | (15 << 27) /* 0.289009227 */, - /* 961 */ 0x04a16d1d | (15 << 27) /* 0.289410699 */, - /* 962 */ 0x04a3123b | (15 << 27) /* 0.289812309 */, - /* 963 */ 0x04a4b77f | (15 << 27) /* 0.290214059 */, - /* 964 */ 0x04a65ce8 | (15 << 27) /* 0.290615948 */, - /* 965 */ 0x04a80277 | (15 << 27) /* 0.291017976 */, - /* 966 */ 0x04a9a82b | (15 << 27) /* 0.291420143 */, - /* 967 */ 0x04ab4e04 | (15 << 27) /* 0.291822449 */, - /* 968 */ 0x04acf402 | (15 << 27) /* 0.292224893 */, - /* 969 */ 0x04ae9a26 | (15 << 27) /* 0.292627476 */, - /* 970 */ 0x04b0406e | (15 << 27) /* 0.293030197 */, - /* 971 */ 0x04b1e6dc | (15 << 27) /* 0.293433057 */, - /* 972 */ 0x04b38d6f | (15 << 27) /* 0.293836055 */, - /* 973 */ 0x04b53427 | (15 << 27) /* 0.294239192 */, - /* 974 */ 0x04b6db05 | (15 << 27) /* 0.294642466 */, - /* 975 */ 0x04b88207 | (15 << 27) /* 0.295045879 */, - - /* 976 */ 0x04ba292e | (15 << 27) /* 0.295449429 */, - /* 977 */ 0x04bbd07a | (15 << 27) /* 0.295853118 */, - /* 978 */ 0x04bd77ec | (15 << 27) /* 0.296256944 */, - /* 979 */ 0x04bf1f82 | (15 << 27) /* 0.296660907 */, - /* 980 */ 0x04c0c73d | (15 << 27) /* 0.297065009 */, - /* 981 */ 0x04c26f1d | (15 << 27) /* 0.297469248 */, - /* 982 */ 0x04c41722 | (15 << 27) /* 0.297873624 */, - /* 983 */ 0x04c5bf4c | (15 << 27) /* 0.298278137 */, - /* 984 */ 0x04c7679a | (15 << 27) /* 0.298682788 */, - /* 985 */ 0x04c9100d | (15 << 27) /* 0.299087576 */, - /* 986 */ 0x04cab8a6 | (15 << 27) /* 0.299492500 */, - /* 987 */ 0x04cc6163 | (15 << 27) /* 0.299897562 */, - /* 988 */ 0x04ce0a44 | (15 << 27) /* 0.300302761 */, - /* 989 */ 0x04cfb34b | (15 << 27) /* 0.300708096 */, - /* 990 */ 0x04d15c76 | (15 << 27) /* 0.301113568 */, - /* 991 */ 0x04d305c5 | (15 << 27) /* 0.301519176 */, - - /* 992 */ 0x04d4af3a | (15 << 27) /* 0.301924921 */, - /* 993 */ 0x04d658d2 | (15 << 27) /* 0.302330802 */, - /* 994 */ 0x04d80290 | (15 << 27) /* 0.302736820 */, - /* 995 */ 0x04d9ac72 | (15 << 27) /* 0.303142973 */, - /* 996 */ 0x04db5679 | (15 << 27) /* 0.303549263 */, - /* 997 */ 0x04dd00a4 | (15 << 27) /* 0.303955689 */, - /* 998 */ 0x04deaaf3 | (15 << 27) /* 0.304362251 */, - /* 999 */ 0x04e05567 | (15 << 27) /* 0.304768948 */, - /* 1000 */ 0x04e20000 | (15 << 27) /* 0.305175781 */, - /* 1001 */ 0x04e3aabd | (15 << 27) /* 0.305582750 */, - /* 1002 */ 0x04e5559e | (15 << 27) /* 0.305989854 */, - /* 1003 */ 0x04e700a3 | (15 << 27) /* 0.306397094 */, - /* 1004 */ 0x04e8abcd | (15 << 27) /* 0.306804470 */, - /* 1005 */ 0x04ea571c | (15 << 27) /* 0.307211980 */, - /* 1006 */ 0x04ec028e | (15 << 27) /* 0.307619626 */, - /* 1007 */ 0x04edae25 | (15 << 27) /* 0.308027406 */, - - /* 1008 */ 0x04ef59e0 | (15 << 27) /* 0.308435322 */, - /* 1009 */ 0x04f105bf | (15 << 27) /* 0.308843373 */, - /* 1010 */ 0x04f2b1c3 | (15 << 27) /* 0.309251558 */, - /* 1011 */ 0x04f45dea | (15 << 27) /* 0.309659879 */, - /* 1012 */ 0x04f60a36 | (15 << 27) /* 0.310068333 */, - /* 1013 */ 0x04f7b6a6 | (15 << 27) /* 0.310476923 */, - /* 1014 */ 0x04f9633a | (15 << 27) /* 0.310885647 */, - /* 1015 */ 0x04fb0ff2 | (15 << 27) /* 0.311294505 */, - /* 1016 */ 0x04fcbcce | (15 << 27) /* 0.311703498 */, - /* 1017 */ 0x04fe69ce | (15 << 27) /* 0.312112625 */, - /* 1018 */ 0x050016f3 | (15 << 27) /* 0.312521885 */, - /* 1019 */ 0x0501c43b | (15 << 27) /* 0.312931280 */, - /* 1020 */ 0x050371a7 | (15 << 27) /* 0.313340809 */, - /* 1021 */ 0x05051f37 | (15 << 27) /* 0.313750472 */, - /* 1022 */ 0x0506cceb | (15 << 27) /* 0.314160269 */, - /* 1023 */ 0x05087ac2 | (15 << 27) /* 0.314570199 */, - - /* 1024 */ 0x050a28be | (15 << 27) /* 0.314980262 */, - /* 1025 */ 0x050bd6de | (15 << 27) /* 0.315390460 */, - /* 1026 */ 0x050d8521 | (15 << 27) /* 0.315800790 */, - /* 1027 */ 0x050f3388 | (15 << 27) /* 0.316211255 */, - /* 1028 */ 0x0510e213 | (15 << 27) /* 0.316621852 */, - /* 1029 */ 0x051290c2 | (15 << 27) /* 0.317032582 */, - /* 1030 */ 0x05143f94 | (15 << 27) /* 0.317443446 */, - /* 1031 */ 0x0515ee8a | (15 << 27) /* 0.317854442 */, - /* 1032 */ 0x05179da4 | (15 << 27) /* 0.318265572 */, - /* 1033 */ 0x05194ce1 | (15 << 27) /* 0.318676834 */, - /* 1034 */ 0x051afc42 | (15 << 27) /* 0.319088229 */, - /* 1035 */ 0x051cabc7 | (15 << 27) /* 0.319499756 */, - /* 1036 */ 0x051e5b6f | (15 << 27) /* 0.319911417 */, - /* 1037 */ 0x05200b3a | (15 << 27) /* 0.320323209 */, - /* 1038 */ 0x0521bb2a | (15 << 27) /* 0.320735134 */, - /* 1039 */ 0x05236b3d | (15 << 27) /* 0.321147192 */, - - /* 1040 */ 0x05251b73 | (15 << 27) /* 0.321559381 */, - /* 1041 */ 0x0526cbcd | (15 << 27) /* 0.321971703 */, - /* 1042 */ 0x05287c4a | (15 << 27) /* 0.322384156 */, - /* 1043 */ 0x052a2cea | (15 << 27) /* 0.322796742 */, - /* 1044 */ 0x052bddae | (15 << 27) /* 0.323209460 */, - /* 1045 */ 0x052d8e96 | (15 << 27) /* 0.323622309 */, - /* 1046 */ 0x052f3fa1 | (15 << 27) /* 0.324035290 */, - /* 1047 */ 0x0530f0cf | (15 << 27) /* 0.324448403 */, - /* 1048 */ 0x0532a220 | (15 << 27) /* 0.324861647 */, - /* 1049 */ 0x05345395 | (15 << 27) /* 0.325275023 */, - /* 1050 */ 0x0536052d | (15 << 27) /* 0.325688530 */, - /* 1051 */ 0x0537b6e8 | (15 << 27) /* 0.326102168 */, - /* 1052 */ 0x053968c6 | (15 << 27) /* 0.326515938 */, - /* 1053 */ 0x053b1ac8 | (15 << 27) /* 0.326929839 */, - /* 1054 */ 0x053ccced | (15 << 27) /* 0.327343870 */, - /* 1055 */ 0x053e7f35 | (15 << 27) /* 0.327758033 */, - - /* 1056 */ 0x054031a0 | (15 << 27) /* 0.328172327 */, - /* 1057 */ 0x0541e42e | (15 << 27) /* 0.328586751 */, - /* 1058 */ 0x054396df | (15 << 27) /* 0.329001306 */, - /* 1059 */ 0x054549b4 | (15 << 27) /* 0.329415992 */, - /* 1060 */ 0x0546fcab | (15 << 27) /* 0.329830808 */, - /* 1061 */ 0x0548afc6 | (15 << 27) /* 0.330245755 */, - /* 1062 */ 0x054a6303 | (15 << 27) /* 0.330660832 */, - /* 1063 */ 0x054c1663 | (15 << 27) /* 0.331076039 */, - /* 1064 */ 0x054dc9e7 | (15 << 27) /* 0.331491377 */, - /* 1065 */ 0x054f7d8d | (15 << 27) /* 0.331906845 */, - /* 1066 */ 0x05513156 | (15 << 27) /* 0.332322443 */, - /* 1067 */ 0x0552e542 | (15 << 27) /* 0.332738170 */, - /* 1068 */ 0x05549951 | (15 << 27) /* 0.333154028 */, - /* 1069 */ 0x05564d83 | (15 << 27) /* 0.333570016 */, - /* 1070 */ 0x055801d8 | (15 << 27) /* 0.333986133 */, - /* 1071 */ 0x0559b64f | (15 << 27) /* 0.334402380 */, - - /* 1072 */ 0x055b6ae9 | (15 << 27) /* 0.334818756 */, - /* 1073 */ 0x055d1fa6 | (15 << 27) /* 0.335235262 */, - /* 1074 */ 0x055ed486 | (15 << 27) /* 0.335651898 */, - /* 1075 */ 0x05608988 | (15 << 27) /* 0.336068662 */, - /* 1076 */ 0x05623ead | (15 << 27) /* 0.336485556 */, - /* 1077 */ 0x0563f3f5 | (15 << 27) /* 0.336902579 */, - /* 1078 */ 0x0565a960 | (15 << 27) /* 0.337319732 */, - /* 1079 */ 0x05675eed | (15 << 27) /* 0.337737013 */, - /* 1080 */ 0x0569149c | (15 << 27) /* 0.338154423 */, - /* 1081 */ 0x056aca6f | (15 << 27) /* 0.338571962 */, - /* 1082 */ 0x056c8064 | (15 << 27) /* 0.338989630 */, - /* 1083 */ 0x056e367b | (15 << 27) /* 0.339407426 */, - /* 1084 */ 0x056fecb5 | (15 << 27) /* 0.339825351 */, - /* 1085 */ 0x0571a311 | (15 << 27) /* 0.340243405 */, - /* 1086 */ 0x05735990 | (15 << 27) /* 0.340661587 */, - /* 1087 */ 0x05751032 | (15 << 27) /* 0.341079898 */, - - /* 1088 */ 0x0576c6f5 | (15 << 27) /* 0.341498336 */, - /* 1089 */ 0x05787ddc | (15 << 27) /* 0.341916903 */, - /* 1090 */ 0x057a34e4 | (15 << 27) /* 0.342335598 */, - /* 1091 */ 0x057bec0f | (15 << 27) /* 0.342754421 */, - /* 1092 */ 0x057da35d | (15 << 27) /* 0.343173373 */, - /* 1093 */ 0x057f5acc | (15 << 27) /* 0.343592452 */, - /* 1094 */ 0x0581125e | (15 << 27) /* 0.344011659 */, - /* 1095 */ 0x0582ca12 | (15 << 27) /* 0.344430993 */, - /* 1096 */ 0x058481e9 | (15 << 27) /* 0.344850455 */, - /* 1097 */ 0x058639e2 | (15 << 27) /* 0.345270045 */, - /* 1098 */ 0x0587f1fd | (15 << 27) /* 0.345689763 */, - /* 1099 */ 0x0589aa3a | (15 << 27) /* 0.346109608 */, - /* 1100 */ 0x058b629a | (15 << 27) /* 0.346529580 */, - /* 1101 */ 0x058d1b1b | (15 << 27) /* 0.346949679 */, - /* 1102 */ 0x058ed3bf | (15 << 27) /* 0.347369906 */, - /* 1103 */ 0x05908c85 | (15 << 27) /* 0.347790260 */, - - /* 1104 */ 0x0592456d | (15 << 27) /* 0.348210741 */, - /* 1105 */ 0x0593fe77 | (15 << 27) /* 0.348631348 */, - /* 1106 */ 0x0595b7a3 | (15 << 27) /* 0.349052083 */, - /* 1107 */ 0x059770f1 | (15 << 27) /* 0.349472945 */, - /* 1108 */ 0x05992a61 | (15 << 27) /* 0.349893933 */, - /* 1109 */ 0x059ae3f3 | (15 << 27) /* 0.350315048 */, - /* 1110 */ 0x059c9da8 | (15 << 27) /* 0.350736290 */, - /* 1111 */ 0x059e577e | (15 << 27) /* 0.351157658 */, - /* 1112 */ 0x05a01176 | (15 << 27) /* 0.351579152 */, - /* 1113 */ 0x05a1cb90 | (15 << 27) /* 0.352000773 */, - /* 1114 */ 0x05a385cc | (15 << 27) /* 0.352422520 */, - /* 1115 */ 0x05a5402a | (15 << 27) /* 0.352844394 */, - /* 1116 */ 0x05a6faa9 | (15 << 27) /* 0.353266393 */, - /* 1117 */ 0x05a8b54b | (15 << 27) /* 0.353688519 */, - /* 1118 */ 0x05aa700e | (15 << 27) /* 0.354110771 */, - /* 1119 */ 0x05ac2af3 | (15 << 27) /* 0.354533148 */, - - /* 1120 */ 0x05ade5fa | (15 << 27) /* 0.354955651 */, - /* 1121 */ 0x05afa123 | (15 << 27) /* 0.355378281 */, - /* 1122 */ 0x05b15c6d | (15 << 27) /* 0.355801035 */, - /* 1123 */ 0x05b317d9 | (15 << 27) /* 0.356223916 */, - /* 1124 */ 0x05b4d367 | (15 << 27) /* 0.356646922 */, - /* 1125 */ 0x05b68f16 | (15 << 27) /* 0.357070053 */, - /* 1126 */ 0x05b84ae7 | (15 << 27) /* 0.357493310 */, - /* 1127 */ 0x05ba06da | (15 << 27) /* 0.357916692 */, - /* 1128 */ 0x05bbc2ef | (15 << 27) /* 0.358340200 */, - /* 1129 */ 0x05bd7f25 | (15 << 27) /* 0.358763832 */, - /* 1130 */ 0x05bf3b7c | (15 << 27) /* 0.359187590 */, - /* 1131 */ 0x05c0f7f5 | (15 << 27) /* 0.359611472 */, - /* 1132 */ 0x05c2b490 | (15 << 27) /* 0.360035480 */, - /* 1133 */ 0x05c4714c | (15 << 27) /* 0.360459613 */, - /* 1134 */ 0x05c62e2a | (15 << 27) /* 0.360883870 */, - /* 1135 */ 0x05c7eb29 | (15 << 27) /* 0.361308252 */, - - /* 1136 */ 0x05c9a84a | (15 << 27) /* 0.361732758 */, - /* 1137 */ 0x05cb658c | (15 << 27) /* 0.362157390 */, - /* 1138 */ 0x05cd22ef | (15 << 27) /* 0.362582145 */, - /* 1139 */ 0x05cee074 | (15 << 27) /* 0.363007026 */, - /* 1140 */ 0x05d09e1b | (15 << 27) /* 0.363432030 */, - /* 1141 */ 0x05d25be2 | (15 << 27) /* 0.363857159 */, - /* 1142 */ 0x05d419cb | (15 << 27) /* 0.364282412 */, - /* 1143 */ 0x05d5d7d5 | (15 << 27) /* 0.364707789 */, - /* 1144 */ 0x05d79601 | (15 << 27) /* 0.365133291 */, - /* 1145 */ 0x05d9544e | (15 << 27) /* 0.365558916 */, - /* 1146 */ 0x05db12bc | (15 << 27) /* 0.365984665 */, - /* 1147 */ 0x05dcd14c | (15 << 27) /* 0.366410538 */, - /* 1148 */ 0x05de8ffc | (15 << 27) /* 0.366836535 */, - /* 1149 */ 0x05e04ece | (15 << 27) /* 0.367262655 */, - /* 1150 */ 0x05e20dc1 | (15 << 27) /* 0.367688900 */, - /* 1151 */ 0x05e3ccd5 | (15 << 27) /* 0.368115267 */, - - /* 1152 */ 0x05e58c0b | (15 << 27) /* 0.368541759 */, - /* 1153 */ 0x05e74b61 | (15 << 27) /* 0.368968373 */, - /* 1154 */ 0x05e90ad9 | (15 << 27) /* 0.369395111 */, - /* 1155 */ 0x05eaca72 | (15 << 27) /* 0.369821973 */, - /* 1156 */ 0x05ec8a2b | (15 << 27) /* 0.370248957 */, - /* 1157 */ 0x05ee4a06 | (15 << 27) /* 0.370676065 */, - /* 1158 */ 0x05f00a02 | (15 << 27) /* 0.371103295 */, - /* 1159 */ 0x05f1ca1f | (15 << 27) /* 0.371530649 */, - /* 1160 */ 0x05f38a5d | (15 << 27) /* 0.371958126 */, - /* 1161 */ 0x05f54abc | (15 << 27) /* 0.372385725 */, - /* 1162 */ 0x05f70b3c | (15 << 27) /* 0.372813448 */, - /* 1163 */ 0x05f8cbdc | (15 << 27) /* 0.373241292 */, - /* 1164 */ 0x05fa8c9e | (15 << 27) /* 0.373669260 */, - /* 1165 */ 0x05fc4d81 | (15 << 27) /* 0.374097350 */, - /* 1166 */ 0x05fe0e84 | (15 << 27) /* 0.374525563 */, - /* 1167 */ 0x05ffcfa8 | (15 << 27) /* 0.374953898 */, - - /* 1168 */ 0x060190ee | (15 << 27) /* 0.375382356 */, - /* 1169 */ 0x06035254 | (15 << 27) /* 0.375810936 */, - /* 1170 */ 0x060513da | (15 << 27) /* 0.376239638 */, - /* 1171 */ 0x0606d582 | (15 << 27) /* 0.376668462 */, - /* 1172 */ 0x0608974a | (15 << 27) /* 0.377097408 */, - /* 1173 */ 0x060a5934 | (15 << 27) /* 0.377526476 */, - /* 1174 */ 0x060c1b3d | (15 << 27) /* 0.377955667 */, - /* 1175 */ 0x060ddd68 | (15 << 27) /* 0.378384979 */, - /* 1176 */ 0x060f9fb3 | (15 << 27) /* 0.378814413 */, - /* 1177 */ 0x0611621f | (15 << 27) /* 0.379243968 */, - /* 1178 */ 0x061324ac | (15 << 27) /* 0.379673646 */, - /* 1179 */ 0x0614e759 | (15 << 27) /* 0.380103444 */, - /* 1180 */ 0x0616aa27 | (15 << 27) /* 0.380533365 */, - /* 1181 */ 0x06186d16 | (15 << 27) /* 0.380963407 */, - /* 1182 */ 0x061a3025 | (15 << 27) /* 0.381393570 */, - /* 1183 */ 0x061bf354 | (15 << 27) /* 0.381823855 */, - - /* 1184 */ 0x061db6a5 | (15 << 27) /* 0.382254261 */, - /* 1185 */ 0x061f7a15 | (15 << 27) /* 0.382684788 */, - /* 1186 */ 0x06213da7 | (15 << 27) /* 0.383115436 */, - /* 1187 */ 0x06230158 | (15 << 27) /* 0.383546205 */, - /* 1188 */ 0x0624c52a | (15 << 27) /* 0.383977096 */, - /* 1189 */ 0x0626891d | (15 << 27) /* 0.384408107 */, - /* 1190 */ 0x06284d30 | (15 << 27) /* 0.384839239 */, - /* 1191 */ 0x062a1164 | (15 << 27) /* 0.385270492 */, - /* 1192 */ 0x062bd5b8 | (15 << 27) /* 0.385701865 */, - /* 1193 */ 0x062d9a2c | (15 << 27) /* 0.386133359 */, - /* 1194 */ 0x062f5ec1 | (15 << 27) /* 0.386564974 */, - /* 1195 */ 0x06312376 | (15 << 27) /* 0.386996709 */, - /* 1196 */ 0x0632e84b | (15 << 27) /* 0.387428565 */, - /* 1197 */ 0x0634ad41 | (15 << 27) /* 0.387860541 */, - /* 1198 */ 0x06367257 | (15 << 27) /* 0.388292637 */, - /* 1199 */ 0x0638378d | (15 << 27) /* 0.388724854 */, - - /* 1200 */ 0x0639fce4 | (15 << 27) /* 0.389157191 */, - /* 1201 */ 0x063bc25b | (15 << 27) /* 0.389589648 */, - /* 1202 */ 0x063d87f2 | (15 << 27) /* 0.390022225 */, - /* 1203 */ 0x063f4da9 | (15 << 27) /* 0.390454922 */, - /* 1204 */ 0x06411380 | (15 << 27) /* 0.390887739 */, - /* 1205 */ 0x0642d978 | (15 << 27) /* 0.391320675 */, - /* 1206 */ 0x06449f8f | (15 << 27) /* 0.391753732 */, - /* 1207 */ 0x064665c7 | (15 << 27) /* 0.392186908 */, - /* 1208 */ 0x06482c1f | (15 << 27) /* 0.392620204 */, - /* 1209 */ 0x0649f297 | (15 << 27) /* 0.393053619 */, - /* 1210 */ 0x064bb92f | (15 << 27) /* 0.393487154 */, - /* 1211 */ 0x064d7fe8 | (15 << 27) /* 0.393920808 */, - /* 1212 */ 0x064f46c0 | (15 << 27) /* 0.394354582 */, - /* 1213 */ 0x06510db8 | (15 << 27) /* 0.394788475 */, - /* 1214 */ 0x0652d4d0 | (15 << 27) /* 0.395222488 */, - /* 1215 */ 0x06549c09 | (15 << 27) /* 0.395656619 */, - - /* 1216 */ 0x06566361 | (15 << 27) /* 0.396090870 */, - /* 1217 */ 0x06582ad9 | (15 << 27) /* 0.396525239 */, - /* 1218 */ 0x0659f271 | (15 << 27) /* 0.396959728 */, - /* 1219 */ 0x065bba29 | (15 << 27) /* 0.397394336 */, - /* 1220 */ 0x065d8201 | (15 << 27) /* 0.397829062 */, - /* 1221 */ 0x065f49f9 | (15 << 27) /* 0.398263907 */, - /* 1222 */ 0x06611211 | (15 << 27) /* 0.398698871 */, - /* 1223 */ 0x0662da49 | (15 << 27) /* 0.399133954 */, - /* 1224 */ 0x0664a2a0 | (15 << 27) /* 0.399569155 */, - /* 1225 */ 0x06666b17 | (15 << 27) /* 0.400004475 */, - /* 1226 */ 0x066833ae | (15 << 27) /* 0.400439913 */, - /* 1227 */ 0x0669fc65 | (15 << 27) /* 0.400875470 */, - /* 1228 */ 0x066bc53c | (15 << 27) /* 0.401311145 */, - /* 1229 */ 0x066d8e32 | (15 << 27) /* 0.401746938 */, - /* 1230 */ 0x066f5748 | (15 << 27) /* 0.402182850 */, - /* 1231 */ 0x0671207e | (15 << 27) /* 0.402618879 */, - - /* 1232 */ 0x0672e9d4 | (15 << 27) /* 0.403055027 */, - /* 1233 */ 0x0674b349 | (15 << 27) /* 0.403491293 */, - /* 1234 */ 0x06767cde | (15 << 27) /* 0.403927676 */, - /* 1235 */ 0x06784692 | (15 << 27) /* 0.404364178 */, - /* 1236 */ 0x067a1066 | (15 << 27) /* 0.404800797 */, - /* 1237 */ 0x067bda5a | (15 << 27) /* 0.405237535 */, - /* 1238 */ 0x067da46d | (15 << 27) /* 0.405674390 */, - /* 1239 */ 0x067f6ea0 | (15 << 27) /* 0.406111362 */, - /* 1240 */ 0x068138f3 | (15 << 27) /* 0.406548452 */, - /* 1241 */ 0x06830365 | (15 << 27) /* 0.406985660 */, - /* 1242 */ 0x0684cdf6 | (15 << 27) /* 0.407422985 */, - /* 1243 */ 0x068698a8 | (15 << 27) /* 0.407860427 */, - /* 1244 */ 0x06886378 | (15 << 27) /* 0.408297987 */, - /* 1245 */ 0x068a2e68 | (15 << 27) /* 0.408735664 */, - /* 1246 */ 0x068bf978 | (15 << 27) /* 0.409173458 */, - /* 1247 */ 0x068dc4a7 | (15 << 27) /* 0.409611370 */, - - /* 1248 */ 0x068f8ff5 | (15 << 27) /* 0.410049398 */, - /* 1249 */ 0x06915b63 | (15 << 27) /* 0.410487544 */, - /* 1250 */ 0x069326f0 | (15 << 27) /* 0.410925806 */, - /* 1251 */ 0x0694f29c | (15 << 27) /* 0.411364185 */, - /* 1252 */ 0x0696be68 | (15 << 27) /* 0.411802681 */, - /* 1253 */ 0x06988a54 | (15 << 27) /* 0.412241294 */, - /* 1254 */ 0x069a565e | (15 << 27) /* 0.412680024 */, - /* 1255 */ 0x069c2288 | (15 << 27) /* 0.413118870 */, - /* 1256 */ 0x069deed1 | (15 << 27) /* 0.413557833 */, - /* 1257 */ 0x069fbb3a | (15 << 27) /* 0.413996912 */, - /* 1258 */ 0x06a187c1 | (15 << 27) /* 0.414436108 */, - /* 1259 */ 0x06a35468 | (15 << 27) /* 0.414875420 */, - /* 1260 */ 0x06a5212f | (15 << 27) /* 0.415314849 */, - /* 1261 */ 0x06a6ee14 | (15 << 27) /* 0.415754393 */, - /* 1262 */ 0x06a8bb18 | (15 << 27) /* 0.416194054 */, - /* 1263 */ 0x06aa883c | (15 << 27) /* 0.416633831 */, - - /* 1264 */ 0x06ac557f | (15 << 27) /* 0.417073724 */, - /* 1265 */ 0x06ae22e1 | (15 << 27) /* 0.417513734 */, - /* 1266 */ 0x06aff062 | (15 << 27) /* 0.417953859 */, - /* 1267 */ 0x06b1be03 | (15 << 27) /* 0.418394100 */, - /* 1268 */ 0x06b38bc2 | (15 << 27) /* 0.418834457 */, - /* 1269 */ 0x06b559a1 | (15 << 27) /* 0.419274929 */, - /* 1270 */ 0x06b7279e | (15 << 27) /* 0.419715518 */, - /* 1271 */ 0x06b8f5bb | (15 << 27) /* 0.420156222 */, - /* 1272 */ 0x06bac3f6 | (15 << 27) /* 0.420597041 */, - /* 1273 */ 0x06bc9251 | (15 << 27) /* 0.421037977 */, - /* 1274 */ 0x06be60cb | (15 << 27) /* 0.421479027 */, - /* 1275 */ 0x06c02f63 | (15 << 27) /* 0.421920193 */, - /* 1276 */ 0x06c1fe1b | (15 << 27) /* 0.422361475 */, - /* 1277 */ 0x06c3ccf1 | (15 << 27) /* 0.422802871 */, - /* 1278 */ 0x06c59be7 | (15 << 27) /* 0.423244383 */, - /* 1279 */ 0x06c76afb | (15 << 27) /* 0.423686010 */, - - /* 1280 */ 0x06c93a2e | (15 << 27) /* 0.424127753 */, - /* 1281 */ 0x06cb0981 | (15 << 27) /* 0.424569610 */, - /* 1282 */ 0x06ccd8f2 | (15 << 27) /* 0.425011582 */, - /* 1283 */ 0x06cea881 | (15 << 27) /* 0.425453669 */, - /* 1284 */ 0x06d07830 | (15 << 27) /* 0.425895871 */, - /* 1285 */ 0x06d247fe | (15 << 27) /* 0.426338188 */, - /* 1286 */ 0x06d417ea | (15 << 27) /* 0.426780620 */, - /* 1287 */ 0x06d5e7f5 | (15 << 27) /* 0.427223166 */, - /* 1288 */ 0x06d7b81f | (15 << 27) /* 0.427665827 */, - /* 1289 */ 0x06d98868 | (15 << 27) /* 0.428108603 */, - /* 1290 */ 0x06db58cf | (15 << 27) /* 0.428551493 */, - /* 1291 */ 0x06dd2955 | (15 << 27) /* 0.428994497 */, - /* 1292 */ 0x06def9fa | (15 << 27) /* 0.429437616 */, - /* 1293 */ 0x06e0cabe | (15 << 27) /* 0.429880849 */, - /* 1294 */ 0x06e29ba0 | (15 << 27) /* 0.430324197 */, - /* 1295 */ 0x06e46ca1 | (15 << 27) /* 0.430767659 */, - - /* 1296 */ 0x06e63dc0 | (15 << 27) /* 0.431211234 */, - /* 1297 */ 0x06e80efe | (15 << 27) /* 0.431654924 */, - /* 1298 */ 0x06e9e05b | (15 << 27) /* 0.432098728 */, - /* 1299 */ 0x06ebb1d6 | (15 << 27) /* 0.432542647 */, - /* 1300 */ 0x06ed8370 | (15 << 27) /* 0.432986678 */, - /* 1301 */ 0x06ef5529 | (15 << 27) /* 0.433430824 */, - /* 1302 */ 0x06f12700 | (15 << 27) /* 0.433875084 */, - /* 1303 */ 0x06f2f8f5 | (15 << 27) /* 0.434319457 */, - /* 1304 */ 0x06f4cb09 | (15 << 27) /* 0.434763944 */, - /* 1305 */ 0x06f69d3c | (15 << 27) /* 0.435208545 */, - /* 1306 */ 0x06f86f8d | (15 << 27) /* 0.435653259 */, - /* 1307 */ 0x06fa41fd | (15 << 27) /* 0.436098087 */, - /* 1308 */ 0x06fc148b | (15 << 27) /* 0.436543029 */, - /* 1309 */ 0x06fde737 | (15 << 27) /* 0.436988083 */, - /* 1310 */ 0x06ffba02 | (15 << 27) /* 0.437433251 */, - /* 1311 */ 0x07018ceb | (15 << 27) /* 0.437878533 */, - - /* 1312 */ 0x07035ff3 | (15 << 27) /* 0.438323927 */, - /* 1313 */ 0x07053319 | (15 << 27) /* 0.438769435 */, - /* 1314 */ 0x0707065d | (15 << 27) /* 0.439215056 */, - /* 1315 */ 0x0708d9c0 | (15 << 27) /* 0.439660790 */, - /* 1316 */ 0x070aad41 | (15 << 27) /* 0.440106636 */, - /* 1317 */ 0x070c80e1 | (15 << 27) /* 0.440552596 */, - /* 1318 */ 0x070e549f | (15 << 27) /* 0.440998669 */, - /* 1319 */ 0x0710287b | (15 << 27) /* 0.441444855 */, - /* 1320 */ 0x0711fc75 | (15 << 27) /* 0.441891153 */, - /* 1321 */ 0x0713d08d | (15 << 27) /* 0.442337564 */, - /* 1322 */ 0x0715a4c4 | (15 << 27) /* 0.442784088 */, - /* 1323 */ 0x07177919 | (15 << 27) /* 0.443230724 */, - /* 1324 */ 0x07194d8c | (15 << 27) /* 0.443677473 */, - /* 1325 */ 0x071b221e | (15 << 27) /* 0.444124334 */, - /* 1326 */ 0x071cf6ce | (15 << 27) /* 0.444571308 */, - /* 1327 */ 0x071ecb9b | (15 << 27) /* 0.445018394 */, - - /* 1328 */ 0x0720a087 | (15 << 27) /* 0.445465593 */, - /* 1329 */ 0x07227591 | (15 << 27) /* 0.445912903 */, - /* 1330 */ 0x07244ab9 | (15 << 27) /* 0.446360326 */, - /* 1331 */ 0x07262000 | (15 << 27) /* 0.446807861 */, - /* 1332 */ 0x0727f564 | (15 << 27) /* 0.447255509 */, - /* 1333 */ 0x0729cae7 | (15 << 27) /* 0.447703268 */, - /* 1334 */ 0x072ba087 | (15 << 27) /* 0.448151139 */, - /* 1335 */ 0x072d7646 | (15 << 27) /* 0.448599122 */, - /* 1336 */ 0x072f4c22 | (15 << 27) /* 0.449047217 */, - /* 1337 */ 0x0731221d | (15 << 27) /* 0.449495424 */, - /* 1338 */ 0x0732f835 | (15 << 27) /* 0.449943742 */, - /* 1339 */ 0x0734ce6c | (15 << 27) /* 0.450392173 */, - /* 1340 */ 0x0736a4c1 | (15 << 27) /* 0.450840715 */, - /* 1341 */ 0x07387b33 | (15 << 27) /* 0.451289368 */, - /* 1342 */ 0x073a51c4 | (15 << 27) /* 0.451738133 */, - /* 1343 */ 0x073c2872 | (15 << 27) /* 0.452187010 */, - - /* 1344 */ 0x073dff3e | (15 << 27) /* 0.452635998 */, - /* 1345 */ 0x073fd628 | (15 << 27) /* 0.453085097 */, - /* 1346 */ 0x0741ad30 | (15 << 27) /* 0.453534308 */, - /* 1347 */ 0x07438456 | (15 << 27) /* 0.453983630 */, - /* 1348 */ 0x07455b9a | (15 << 27) /* 0.454433063 */, - /* 1349 */ 0x074732fc | (15 << 27) /* 0.454882607 */, - /* 1350 */ 0x07490a7b | (15 << 27) /* 0.455332262 */, - /* 1351 */ 0x074ae218 | (15 << 27) /* 0.455782029 */, - /* 1352 */ 0x074cb9d3 | (15 << 27) /* 0.456231906 */, - /* 1353 */ 0x074e91ac | (15 << 27) /* 0.456681894 */, - /* 1354 */ 0x075069a3 | (15 << 27) /* 0.457131993 */, - /* 1355 */ 0x075241b7 | (15 << 27) /* 0.457582203 */, - /* 1356 */ 0x075419e9 | (15 << 27) /* 0.458032524 */, - /* 1357 */ 0x0755f239 | (15 << 27) /* 0.458482956 */, - /* 1358 */ 0x0757caa7 | (15 << 27) /* 0.458933498 */, - /* 1359 */ 0x0759a332 | (15 << 27) /* 0.459384151 */, - - /* 1360 */ 0x075b7bdb | (15 << 27) /* 0.459834914 */, - /* 1361 */ 0x075d54a1 | (15 << 27) /* 0.460285788 */, - /* 1362 */ 0x075f2d85 | (15 << 27) /* 0.460736772 */, - /* 1363 */ 0x07610687 | (15 << 27) /* 0.461187867 */, - /* 1364 */ 0x0762dfa6 | (15 << 27) /* 0.461639071 */, - /* 1365 */ 0x0764b8e3 | (15 << 27) /* 0.462090387 */, - /* 1366 */ 0x0766923e | (15 << 27) /* 0.462541812 */, - /* 1367 */ 0x07686bb6 | (15 << 27) /* 0.462993348 */, - /* 1368 */ 0x076a454c | (15 << 27) /* 0.463444993 */, - /* 1369 */ 0x076c1eff | (15 << 27) /* 0.463896749 */, - /* 1370 */ 0x076df8d0 | (15 << 27) /* 0.464348615 */, - /* 1371 */ 0x076fd2be | (15 << 27) /* 0.464800591 */, - /* 1372 */ 0x0771acca | (15 << 27) /* 0.465252676 */, - /* 1373 */ 0x077386f3 | (15 << 27) /* 0.465704872 */, - /* 1374 */ 0x0775613a | (15 << 27) /* 0.466157177 */, - /* 1375 */ 0x07773b9e | (15 << 27) /* 0.466609592 */, - - /* 1376 */ 0x07791620 | (15 << 27) /* 0.467062117 */, - /* 1377 */ 0x077af0bf | (15 << 27) /* 0.467514751 */, - /* 1378 */ 0x077ccb7c | (15 << 27) /* 0.467967495 */, - /* 1379 */ 0x077ea656 | (15 << 27) /* 0.468420349 */, - /* 1380 */ 0x0780814d | (15 << 27) /* 0.468873312 */, - /* 1381 */ 0x07825c62 | (15 << 27) /* 0.469326384 */, - /* 1382 */ 0x07843794 | (15 << 27) /* 0.469779566 */, - /* 1383 */ 0x078612e3 | (15 << 27) /* 0.470232857 */, - /* 1384 */ 0x0787ee50 | (15 << 27) /* 0.470686258 */, - /* 1385 */ 0x0789c9da | (15 << 27) /* 0.471139767 */, - /* 1386 */ 0x078ba581 | (15 << 27) /* 0.471593386 */, - /* 1387 */ 0x078d8146 | (15 << 27) /* 0.472047114 */, - /* 1388 */ 0x078f5d28 | (15 << 27) /* 0.472500951 */, - /* 1389 */ 0x07913927 | (15 << 27) /* 0.472954896 */, - /* 1390 */ 0x07931543 | (15 << 27) /* 0.473408951 */, - /* 1391 */ 0x0794f17d | (15 << 27) /* 0.473863115 */, - - /* 1392 */ 0x0796cdd4 | (15 << 27) /* 0.474317388 */, - /* 1393 */ 0x0798aa48 | (15 << 27) /* 0.474771769 */, - /* 1394 */ 0x079a86d9 | (15 << 27) /* 0.475226259 */, - /* 1395 */ 0x079c6388 | (15 << 27) /* 0.475680858 */, - /* 1396 */ 0x079e4053 | (15 << 27) /* 0.476135565 */, - /* 1397 */ 0x07a01d3c | (15 << 27) /* 0.476590381 */, - /* 1398 */ 0x07a1fa42 | (15 << 27) /* 0.477045306 */, - /* 1399 */ 0x07a3d765 | (15 << 27) /* 0.477500339 */, - /* 1400 */ 0x07a5b4a5 | (15 << 27) /* 0.477955481 */, - /* 1401 */ 0x07a79202 | (15 << 27) /* 0.478410731 */, - /* 1402 */ 0x07a96f7d | (15 << 27) /* 0.478866089 */, - /* 1403 */ 0x07ab4d14 | (15 << 27) /* 0.479321555 */, - /* 1404 */ 0x07ad2ac8 | (15 << 27) /* 0.479777130 */, - /* 1405 */ 0x07af089a | (15 << 27) /* 0.480232813 */, - /* 1406 */ 0x07b0e688 | (15 << 27) /* 0.480688604 */, - /* 1407 */ 0x07b2c494 | (15 << 27) /* 0.481144503 */, - - /* 1408 */ 0x07b4a2bc | (15 << 27) /* 0.481600510 */, - /* 1409 */ 0x07b68102 | (15 << 27) /* 0.482056625 */, - /* 1410 */ 0x07b85f64 | (15 << 27) /* 0.482512848 */, - /* 1411 */ 0x07ba3de4 | (15 << 27) /* 0.482969179 */, - /* 1412 */ 0x07bc1c80 | (15 << 27) /* 0.483425618 */, - /* 1413 */ 0x07bdfb39 | (15 << 27) /* 0.483882164 */, - /* 1414 */ 0x07bfda0f | (15 << 27) /* 0.484338818 */, - /* 1415 */ 0x07c1b902 | (15 << 27) /* 0.484795580 */, - /* 1416 */ 0x07c39812 | (15 << 27) /* 0.485252449 */, - /* 1417 */ 0x07c5773f | (15 << 27) /* 0.485709426 */, - /* 1418 */ 0x07c75689 | (15 << 27) /* 0.486166511 */, - /* 1419 */ 0x07c935ef | (15 << 27) /* 0.486623703 */, - /* 1420 */ 0x07cb1573 | (15 << 27) /* 0.487081002 */, - /* 1421 */ 0x07ccf513 | (15 << 27) /* 0.487538409 */, - /* 1422 */ 0x07ced4d0 | (15 << 27) /* 0.487995923 */, - /* 1423 */ 0x07d0b4aa | (15 << 27) /* 0.488453544 */, - - /* 1424 */ 0x07d294a0 | (15 << 27) /* 0.488911273 */, - /* 1425 */ 0x07d474b3 | (15 << 27) /* 0.489369108 */, - /* 1426 */ 0x07d654e4 | (15 << 27) /* 0.489827051 */, - /* 1427 */ 0x07d83530 | (15 << 27) /* 0.490285101 */, - /* 1428 */ 0x07da159a | (15 << 27) /* 0.490743258 */, - /* 1429 */ 0x07dbf620 | (15 << 27) /* 0.491201522 */, - /* 1430 */ 0x07ddd6c3 | (15 << 27) /* 0.491659892 */, - /* 1431 */ 0x07dfb783 | (15 << 27) /* 0.492118370 */, - /* 1432 */ 0x07e1985f | (15 << 27) /* 0.492576954 */, - /* 1433 */ 0x07e37958 | (15 << 27) /* 0.493035645 */, - /* 1434 */ 0x07e55a6e | (15 << 27) /* 0.493494443 */, - /* 1435 */ 0x07e73ba0 | (15 << 27) /* 0.493953348 */, - /* 1436 */ 0x07e91cef | (15 << 27) /* 0.494412359 */, - /* 1437 */ 0x07eafe5a | (15 << 27) /* 0.494871476 */, - /* 1438 */ 0x07ecdfe2 | (15 << 27) /* 0.495330701 */, - /* 1439 */ 0x07eec187 | (15 << 27) /* 0.495790031 */, - - /* 1440 */ 0x07f0a348 | (15 << 27) /* 0.496249468 */, - /* 1441 */ 0x07f28526 | (15 << 27) /* 0.496709012 */, - /* 1442 */ 0x07f46720 | (15 << 27) /* 0.497168662 */, - /* 1443 */ 0x07f64937 | (15 << 27) /* 0.497628418 */, - /* 1444 */ 0x07f82b6a | (15 << 27) /* 0.498088280 */, - /* 1445 */ 0x07fa0dba | (15 << 27) /* 0.498548248 */, - /* 1446 */ 0x07fbf026 | (15 << 27) /* 0.499008323 */, - /* 1447 */ 0x07fdd2af | (15 << 27) /* 0.499468503 */, - /* 1448 */ 0x07ffb554 | (15 << 27) /* 0.499928790 */, - /* 1449 */ 0x0400cc0b | (16 << 27) /* 0.250194591 */, - /* 1450 */ 0x0401bd7a | (16 << 27) /* 0.250424840 */, - /* 1451 */ 0x0402aef7 | (16 << 27) /* 0.250655143 */, - /* 1452 */ 0x0403a083 | (16 << 27) /* 0.250885498 */, - /* 1453 */ 0x0404921c | (16 << 27) /* 0.251115906 */, - /* 1454 */ 0x040583c4 | (16 << 27) /* 0.251346367 */, - /* 1455 */ 0x0406757a | (16 << 27) /* 0.251576880 */, - - /* 1456 */ 0x0407673f | (16 << 27) /* 0.251807447 */, - /* 1457 */ 0x04085911 | (16 << 27) /* 0.252038066 */, - /* 1458 */ 0x04094af1 | (16 << 27) /* 0.252268738 */, - /* 1459 */ 0x040a3ce0 | (16 << 27) /* 0.252499463 */, - /* 1460 */ 0x040b2edd | (16 << 27) /* 0.252730240 */, - /* 1461 */ 0x040c20e8 | (16 << 27) /* 0.252961071 */, - /* 1462 */ 0x040d1301 | (16 << 27) /* 0.253191953 */, - /* 1463 */ 0x040e0529 | (16 << 27) /* 0.253422889 */, - /* 1464 */ 0x040ef75e | (16 << 27) /* 0.253653877 */, - /* 1465 */ 0x040fe9a1 | (16 << 27) /* 0.253884918 */, - /* 1466 */ 0x0410dbf3 | (16 << 27) /* 0.254116011 */, - /* 1467 */ 0x0411ce53 | (16 << 27) /* 0.254347157 */, - /* 1468 */ 0x0412c0c1 | (16 << 27) /* 0.254578356 */, - /* 1469 */ 0x0413b33d | (16 << 27) /* 0.254809606 */, - /* 1470 */ 0x0414a5c7 | (16 << 27) /* 0.255040910 */, - /* 1471 */ 0x0415985f | (16 << 27) /* 0.255272266 */, - - /* 1472 */ 0x04168b05 | (16 << 27) /* 0.255503674 */, - /* 1473 */ 0x04177db9 | (16 << 27) /* 0.255735135 */, - /* 1474 */ 0x0418707c | (16 << 27) /* 0.255966648 */, - /* 1475 */ 0x0419634c | (16 << 27) /* 0.256198213 */, - /* 1476 */ 0x041a562a | (16 << 27) /* 0.256429831 */, - /* 1477 */ 0x041b4917 | (16 << 27) /* 0.256661501 */, - /* 1478 */ 0x041c3c11 | (16 << 27) /* 0.256893223 */, - /* 1479 */ 0x041d2f1a | (16 << 27) /* 0.257124998 */, - /* 1480 */ 0x041e2230 | (16 << 27) /* 0.257356825 */, - /* 1481 */ 0x041f1555 | (16 << 27) /* 0.257588704 */, - /* 1482 */ 0x04200888 | (16 << 27) /* 0.257820635 */, - /* 1483 */ 0x0420fbc8 | (16 << 27) /* 0.258052619 */, - /* 1484 */ 0x0421ef17 | (16 << 27) /* 0.258284654 */, - /* 1485 */ 0x0422e273 | (16 << 27) /* 0.258516742 */, - /* 1486 */ 0x0423d5de | (16 << 27) /* 0.258748882 */, - /* 1487 */ 0x0424c956 | (16 << 27) /* 0.258981074 */, - - /* 1488 */ 0x0425bcdd | (16 << 27) /* 0.259213318 */, - /* 1489 */ 0x0426b071 | (16 << 27) /* 0.259445614 */, - /* 1490 */ 0x0427a414 | (16 << 27) /* 0.259677962 */, - /* 1491 */ 0x042897c4 | (16 << 27) /* 0.259910362 */, - /* 1492 */ 0x04298b83 | (16 << 27) /* 0.260142814 */, - /* 1493 */ 0x042a7f4f | (16 << 27) /* 0.260375318 */, - /* 1494 */ 0x042b7329 | (16 << 27) /* 0.260607874 */, - /* 1495 */ 0x042c6711 | (16 << 27) /* 0.260840481 */, - /* 1496 */ 0x042d5b07 | (16 << 27) /* 0.261073141 */, - /* 1497 */ 0x042e4f0b | (16 << 27) /* 0.261305852 */, - /* 1498 */ 0x042f431d | (16 << 27) /* 0.261538616 */, - /* 1499 */ 0x0430373d | (16 << 27) /* 0.261771431 */, - /* 1500 */ 0x04312b6b | (16 << 27) /* 0.262004297 */, - /* 1501 */ 0x04321fa6 | (16 << 27) /* 0.262237216 */, - /* 1502 */ 0x043313f0 | (16 << 27) /* 0.262470186 */, - /* 1503 */ 0x04340847 | (16 << 27) /* 0.262703208 */, - - /* 1504 */ 0x0434fcad | (16 << 27) /* 0.262936282 */, - /* 1505 */ 0x0435f120 | (16 << 27) /* 0.263169407 */, - /* 1506 */ 0x0436e5a1 | (16 << 27) /* 0.263402584 */, - /* 1507 */ 0x0437da2f | (16 << 27) /* 0.263635813 */, - /* 1508 */ 0x0438cecc | (16 << 27) /* 0.263869093 */, - /* 1509 */ 0x0439c377 | (16 << 27) /* 0.264102425 */, - /* 1510 */ 0x043ab82f | (16 << 27) /* 0.264335808 */, - /* 1511 */ 0x043bacf5 | (16 << 27) /* 0.264569243 */, - /* 1512 */ 0x043ca1c9 | (16 << 27) /* 0.264802730 */, - /* 1513 */ 0x043d96ab | (16 << 27) /* 0.265036267 */, - /* 1514 */ 0x043e8b9b | (16 << 27) /* 0.265269857 */, - /* 1515 */ 0x043f8098 | (16 << 27) /* 0.265503498 */, - /* 1516 */ 0x044075a3 | (16 << 27) /* 0.265737190 */, - /* 1517 */ 0x04416abc | (16 << 27) /* 0.265970933 */, - /* 1518 */ 0x04425fe3 | (16 << 27) /* 0.266204728 */, - /* 1519 */ 0x04435518 | (16 << 27) /* 0.266438574 */, - - /* 1520 */ 0x04444a5a | (16 << 27) /* 0.266672472 */, - /* 1521 */ 0x04453fab | (16 << 27) /* 0.266906421 */, - /* 1522 */ 0x04463508 | (16 << 27) /* 0.267140421 */, - /* 1523 */ 0x04472a74 | (16 << 27) /* 0.267374472 */, - /* 1524 */ 0x04481fee | (16 << 27) /* 0.267608575 */, - /* 1525 */ 0x04491575 | (16 << 27) /* 0.267842729 */, - /* 1526 */ 0x044a0b0a | (16 << 27) /* 0.268076934 */, - /* 1527 */ 0x044b00ac | (16 << 27) /* 0.268311190 */, - /* 1528 */ 0x044bf65d | (16 << 27) /* 0.268545497 */, - /* 1529 */ 0x044cec1b | (16 << 27) /* 0.268779856 */, - /* 1530 */ 0x044de1e7 | (16 << 27) /* 0.269014265 */, - /* 1531 */ 0x044ed7c0 | (16 << 27) /* 0.269248726 */, - /* 1532 */ 0x044fcda8 | (16 << 27) /* 0.269483238 */, - /* 1533 */ 0x0450c39c | (16 << 27) /* 0.269717800 */, - /* 1534 */ 0x0451b99f | (16 << 27) /* 0.269952414 */, - /* 1535 */ 0x0452afaf | (16 << 27) /* 0.270187079 */, - - /* 1536 */ 0x0453a5cd | (16 << 27) /* 0.270421794 */, - /* 1537 */ 0x04549bf9 | (16 << 27) /* 0.270656561 */, - /* 1538 */ 0x04559232 | (16 << 27) /* 0.270891379 */, - /* 1539 */ 0x04568879 | (16 << 27) /* 0.271126247 */, - /* 1540 */ 0x04577ece | (16 << 27) /* 0.271361166 */, - /* 1541 */ 0x04587530 | (16 << 27) /* 0.271596136 */, - /* 1542 */ 0x04596ba0 | (16 << 27) /* 0.271831157 */, - /* 1543 */ 0x045a621e | (16 << 27) /* 0.272066229 */, - /* 1544 */ 0x045b58a9 | (16 << 27) /* 0.272301352 */, - /* 1545 */ 0x045c4f42 | (16 << 27) /* 0.272536525 */, - /* 1546 */ 0x045d45e9 | (16 << 27) /* 0.272771749 */, - /* 1547 */ 0x045e3c9d | (16 << 27) /* 0.273007024 */, - /* 1548 */ 0x045f335e | (16 << 27) /* 0.273242350 */, - /* 1549 */ 0x04602a2e | (16 << 27) /* 0.273477726 */, - /* 1550 */ 0x0461210b | (16 << 27) /* 0.273713153 */, - /* 1551 */ 0x046217f5 | (16 << 27) /* 0.273948630 */, - - /* 1552 */ 0x04630eed | (16 << 27) /* 0.274184158 */, - /* 1553 */ 0x046405f3 | (16 << 27) /* 0.274419737 */, - /* 1554 */ 0x0464fd06 | (16 << 27) /* 0.274655366 */, - /* 1555 */ 0x0465f427 | (16 << 27) /* 0.274891046 */, - /* 1556 */ 0x0466eb55 | (16 << 27) /* 0.275126776 */, - /* 1557 */ 0x0467e291 | (16 << 27) /* 0.275362557 */, - /* 1558 */ 0x0468d9db | (16 << 27) /* 0.275598389 */, - /* 1559 */ 0x0469d132 | (16 << 27) /* 0.275834270 */, - /* 1560 */ 0x046ac896 | (16 << 27) /* 0.276070203 */, - /* 1561 */ 0x046bc009 | (16 << 27) /* 0.276306185 */, - /* 1562 */ 0x046cb788 | (16 << 27) /* 0.276542218 */, - /* 1563 */ 0x046daf15 | (16 << 27) /* 0.276778302 */, - /* 1564 */ 0x046ea6b0 | (16 << 27) /* 0.277014435 */, - /* 1565 */ 0x046f9e58 | (16 << 27) /* 0.277250619 */, - /* 1566 */ 0x0470960e | (16 << 27) /* 0.277486854 */, - /* 1567 */ 0x04718dd1 | (16 << 27) /* 0.277723139 */, - - /* 1568 */ 0x047285a2 | (16 << 27) /* 0.277959474 */, - /* 1569 */ 0x04737d80 | (16 << 27) /* 0.278195859 */, - /* 1570 */ 0x0474756c | (16 << 27) /* 0.278432294 */, - /* 1571 */ 0x04756d65 | (16 << 27) /* 0.278668780 */, - /* 1572 */ 0x0476656b | (16 << 27) /* 0.278905316 */, - /* 1573 */ 0x04775d7f | (16 << 27) /* 0.279141902 */, - /* 1574 */ 0x047855a1 | (16 << 27) /* 0.279378538 */, - /* 1575 */ 0x04794dd0 | (16 << 27) /* 0.279615224 */, - /* 1576 */ 0x047a460c | (16 << 27) /* 0.279851960 */, - /* 1577 */ 0x047b3e56 | (16 << 27) /* 0.280088747 */, - /* 1578 */ 0x047c36ae | (16 << 27) /* 0.280325583 */, - /* 1579 */ 0x047d2f12 | (16 << 27) /* 0.280562470 */, - /* 1580 */ 0x047e2784 | (16 << 27) /* 0.280799406 */, - /* 1581 */ 0x047f2004 | (16 << 27) /* 0.281036393 */, - /* 1582 */ 0x04801891 | (16 << 27) /* 0.281273429 */, - /* 1583 */ 0x0481112b | (16 << 27) /* 0.281510516 */, - - /* 1584 */ 0x048209d3 | (16 << 27) /* 0.281747652 */, - /* 1585 */ 0x04830288 | (16 << 27) /* 0.281984838 */, - /* 1586 */ 0x0483fb4b | (16 << 27) /* 0.282222075 */, - /* 1587 */ 0x0484f41b | (16 << 27) /* 0.282459361 */, - /* 1588 */ 0x0485ecf8 | (16 << 27) /* 0.282696697 */, - /* 1589 */ 0x0486e5e3 | (16 << 27) /* 0.282934082 */, - /* 1590 */ 0x0487dedb | (16 << 27) /* 0.283171518 */, - /* 1591 */ 0x0488d7e1 | (16 << 27) /* 0.283409003 */, - /* 1592 */ 0x0489d0f4 | (16 << 27) /* 0.283646538 */, - /* 1593 */ 0x048aca14 | (16 << 27) /* 0.283884123 */, - /* 1594 */ 0x048bc341 | (16 << 27) /* 0.284121757 */, - /* 1595 */ 0x048cbc7c | (16 << 27) /* 0.284359441 */, - /* 1596 */ 0x048db5c4 | (16 << 27) /* 0.284597175 */, - /* 1597 */ 0x048eaf1a | (16 << 27) /* 0.284834959 */, - /* 1598 */ 0x048fa87d | (16 << 27) /* 0.285072792 */, - /* 1599 */ 0x0490a1ed | (16 << 27) /* 0.285310675 */, - - /* 1600 */ 0x04919b6a | (16 << 27) /* 0.285548607 */, - /* 1601 */ 0x049294f5 | (16 << 27) /* 0.285786589 */, - /* 1602 */ 0x04938e8d | (16 << 27) /* 0.286024621 */, - /* 1603 */ 0x04948833 | (16 << 27) /* 0.286262702 */, - /* 1604 */ 0x049581e5 | (16 << 27) /* 0.286500832 */, - /* 1605 */ 0x04967ba5 | (16 << 27) /* 0.286739012 */, - /* 1606 */ 0x04977573 | (16 << 27) /* 0.286977242 */, - /* 1607 */ 0x04986f4d | (16 << 27) /* 0.287215521 */, - /* 1608 */ 0x04996935 | (16 << 27) /* 0.287453849 */, - /* 1609 */ 0x049a632a | (16 << 27) /* 0.287692227 */, - /* 1610 */ 0x049b5d2c | (16 << 27) /* 0.287930654 */, - /* 1611 */ 0x049c573c | (16 << 27) /* 0.288169131 */, - /* 1612 */ 0x049d5159 | (16 << 27) /* 0.288407657 */, - /* 1613 */ 0x049e4b83 | (16 << 27) /* 0.288646232 */, - /* 1614 */ 0x049f45ba | (16 << 27) /* 0.288884857 */, - /* 1615 */ 0x04a03ffe | (16 << 27) /* 0.289123530 */, - - /* 1616 */ 0x04a13a50 | (16 << 27) /* 0.289362253 */, - /* 1617 */ 0x04a234af | (16 << 27) /* 0.289601026 */, - /* 1618 */ 0x04a32f1b | (16 << 27) /* 0.289839847 */, - /* 1619 */ 0x04a42995 | (16 << 27) /* 0.290078718 */, - /* 1620 */ 0x04a5241b | (16 << 27) /* 0.290317638 */, - /* 1621 */ 0x04a61eaf | (16 << 27) /* 0.290556607 */, - /* 1622 */ 0x04a71950 | (16 << 27) /* 0.290795626 */, - /* 1623 */ 0x04a813fe | (16 << 27) /* 0.291034693 */, - /* 1624 */ 0x04a90eba | (16 << 27) /* 0.291273810 */, - /* 1625 */ 0x04aa0982 | (16 << 27) /* 0.291512975 */, - /* 1626 */ 0x04ab0458 | (16 << 27) /* 0.291752190 */, - /* 1627 */ 0x04abff3b | (16 << 27) /* 0.291991453 */, - /* 1628 */ 0x04acfa2b | (16 << 27) /* 0.292230766 */, - /* 1629 */ 0x04adf528 | (16 << 27) /* 0.292470128 */, - /* 1630 */ 0x04aef032 | (16 << 27) /* 0.292709539 */, - /* 1631 */ 0x04afeb4a | (16 << 27) /* 0.292948998 */, - - /* 1632 */ 0x04b0e66e | (16 << 27) /* 0.293188507 */, - /* 1633 */ 0x04b1e1a0 | (16 << 27) /* 0.293428065 */, - /* 1634 */ 0x04b2dcdf | (16 << 27) /* 0.293667671 */, - /* 1635 */ 0x04b3d82b | (16 << 27) /* 0.293907326 */, - /* 1636 */ 0x04b4d384 | (16 << 27) /* 0.294147031 */, - /* 1637 */ 0x04b5ceea | (16 << 27) /* 0.294386784 */, - /* 1638 */ 0x04b6ca5e | (16 << 27) /* 0.294626585 */, - /* 1639 */ 0x04b7c5de | (16 << 27) /* 0.294866436 */, - /* 1640 */ 0x04b8c16c | (16 << 27) /* 0.295106336 */, - /* 1641 */ 0x04b9bd06 | (16 << 27) /* 0.295346284 */, - /* 1642 */ 0x04bab8ae | (16 << 27) /* 0.295586281 */, - /* 1643 */ 0x04bbb463 | (16 << 27) /* 0.295826327 */, - /* 1644 */ 0x04bcb024 | (16 << 27) /* 0.296066421 */, - /* 1645 */ 0x04bdabf3 | (16 << 27) /* 0.296306564 */, - /* 1646 */ 0x04bea7cf | (16 << 27) /* 0.296546756 */, - /* 1647 */ 0x04bfa3b8 | (16 << 27) /* 0.296786996 */, - - /* 1648 */ 0x04c09faf | (16 << 27) /* 0.297027285 */, - /* 1649 */ 0x04c19bb2 | (16 << 27) /* 0.297267623 */, - /* 1650 */ 0x04c297c2 | (16 << 27) /* 0.297508009 */, - /* 1651 */ 0x04c393df | (16 << 27) /* 0.297748444 */, - /* 1652 */ 0x04c49009 | (16 << 27) /* 0.297988927 */, - /* 1653 */ 0x04c58c41 | (16 << 27) /* 0.298229459 */, - /* 1654 */ 0x04c68885 | (16 << 27) /* 0.298470039 */, - /* 1655 */ 0x04c784d6 | (16 << 27) /* 0.298710668 */, - /* 1656 */ 0x04c88135 | (16 << 27) /* 0.298951346 */, - /* 1657 */ 0x04c97da0 | (16 << 27) /* 0.299192071 */, - /* 1658 */ 0x04ca7a18 | (16 << 27) /* 0.299432846 */, - /* 1659 */ 0x04cb769e | (16 << 27) /* 0.299673668 */, - /* 1660 */ 0x04cc7330 | (16 << 27) /* 0.299914539 */, - /* 1661 */ 0x04cd6fcf | (16 << 27) /* 0.300155459 */, - /* 1662 */ 0x04ce6c7b | (16 << 27) /* 0.300396426 */, - /* 1663 */ 0x04cf6935 | (16 << 27) /* 0.300637443 */, - - /* 1664 */ 0x04d065fb | (16 << 27) /* 0.300878507 */, - /* 1665 */ 0x04d162ce | (16 << 27) /* 0.301119620 */, - /* 1666 */ 0x04d25fae | (16 << 27) /* 0.301360781 */, - /* 1667 */ 0x04d35c9b | (16 << 27) /* 0.301601990 */, - /* 1668 */ 0x04d45995 | (16 << 27) /* 0.301843247 */, - /* 1669 */ 0x04d5569c | (16 << 27) /* 0.302084553 */, - /* 1670 */ 0x04d653b0 | (16 << 27) /* 0.302325907 */, - /* 1671 */ 0x04d750d1 | (16 << 27) /* 0.302567309 */, - /* 1672 */ 0x04d84dff | (16 << 27) /* 0.302808759 */, - /* 1673 */ 0x04d94b3a | (16 << 27) /* 0.303050257 */, - /* 1674 */ 0x04da4881 | (16 << 27) /* 0.303291804 */, - /* 1675 */ 0x04db45d6 | (16 << 27) /* 0.303533399 */, - /* 1676 */ 0x04dc4337 | (16 << 27) /* 0.303775041 */, - /* 1677 */ 0x04dd40a6 | (16 << 27) /* 0.304016732 */, - /* 1678 */ 0x04de3e21 | (16 << 27) /* 0.304258471 */, - /* 1679 */ 0x04df3ba9 | (16 << 27) /* 0.304500257 */, - - /* 1680 */ 0x04e0393e | (16 << 27) /* 0.304742092 */, - /* 1681 */ 0x04e136e0 | (16 << 27) /* 0.304983975 */, - /* 1682 */ 0x04e2348f | (16 << 27) /* 0.305225906 */, - /* 1683 */ 0x04e3324b | (16 << 27) /* 0.305467885 */, - /* 1684 */ 0x04e43013 | (16 << 27) /* 0.305709911 */, - /* 1685 */ 0x04e52de9 | (16 << 27) /* 0.305951986 */, - /* 1686 */ 0x04e62bcb | (16 << 27) /* 0.306194108 */, - /* 1687 */ 0x04e729ba | (16 << 27) /* 0.306436279 */, - /* 1688 */ 0x04e827b6 | (16 << 27) /* 0.306678497 */, - /* 1689 */ 0x04e925bf | (16 << 27) /* 0.306920763 */, - /* 1690 */ 0x04ea23d4 | (16 << 27) /* 0.307163077 */, - /* 1691 */ 0x04eb21f7 | (16 << 27) /* 0.307405438 */, - /* 1692 */ 0x04ec2026 | (16 << 27) /* 0.307647848 */, - /* 1693 */ 0x04ed1e62 | (16 << 27) /* 0.307890305 */, - /* 1694 */ 0x04ee1cab | (16 << 27) /* 0.308132810 */, - /* 1695 */ 0x04ef1b01 | (16 << 27) /* 0.308375362 */, - - /* 1696 */ 0x04f01963 | (16 << 27) /* 0.308617963 */, - /* 1697 */ 0x04f117d3 | (16 << 27) /* 0.308860611 */, - /* 1698 */ 0x04f2164f | (16 << 27) /* 0.309103306 */, - /* 1699 */ 0x04f314d8 | (16 << 27) /* 0.309346050 */, - /* 1700 */ 0x04f4136d | (16 << 27) /* 0.309588841 */, - /* 1701 */ 0x04f51210 | (16 << 27) /* 0.309831679 */, - /* 1702 */ 0x04f610bf | (16 << 27) /* 0.310074565 */, - /* 1703 */ 0x04f70f7b | (16 << 27) /* 0.310317499 */, - /* 1704 */ 0x04f80e44 | (16 << 27) /* 0.310560480 */, - /* 1705 */ 0x04f90d19 | (16 << 27) /* 0.310803509 */, - /* 1706 */ 0x04fa0bfc | (16 << 27) /* 0.311046586 */, - /* 1707 */ 0x04fb0aeb | (16 << 27) /* 0.311289710 */, - /* 1708 */ 0x04fc09e7 | (16 << 27) /* 0.311532881 */, - /* 1709 */ 0x04fd08ef | (16 << 27) /* 0.311776100 */, - /* 1710 */ 0x04fe0805 | (16 << 27) /* 0.312019366 */, - /* 1711 */ 0x04ff0727 | (16 << 27) /* 0.312262680 */, - - /* 1712 */ 0x05000655 | (16 << 27) /* 0.312506041 */, - /* 1713 */ 0x05010591 | (16 << 27) /* 0.312749449 */, - /* 1714 */ 0x050204d9 | (16 << 27) /* 0.312992905 */, - /* 1715 */ 0x0503042e | (16 << 27) /* 0.313236408 */, - /* 1716 */ 0x0504038f | (16 << 27) /* 0.313479959 */, - /* 1717 */ 0x050502fe | (16 << 27) /* 0.313723556 */, - /* 1718 */ 0x05060279 | (16 << 27) /* 0.313967202 */, - /* 1719 */ 0x05070200 | (16 << 27) /* 0.314210894 */, - /* 1720 */ 0x05080195 | (16 << 27) /* 0.314454634 */, - /* 1721 */ 0x05090136 | (16 << 27) /* 0.314698420 */, - /* 1722 */ 0x050a00e3 | (16 << 27) /* 0.314942255 */, - /* 1723 */ 0x050b009e | (16 << 27) /* 0.315186136 */, - /* 1724 */ 0x050c0065 | (16 << 27) /* 0.315430064 */, - /* 1725 */ 0x050d0039 | (16 << 27) /* 0.315674040 */, - /* 1726 */ 0x050e0019 | (16 << 27) /* 0.315918063 */, - /* 1727 */ 0x050f0006 | (16 << 27) /* 0.316162133 */, - - /* 1728 */ 0x05100000 | (16 << 27) /* 0.316406250 */, - /* 1729 */ 0x05110006 | (16 << 27) /* 0.316650414 */, - /* 1730 */ 0x05120019 | (16 << 27) /* 0.316894625 */, - /* 1731 */ 0x05130039 | (16 << 27) /* 0.317138884 */, - /* 1732 */ 0x05140065 | (16 << 27) /* 0.317383189 */, - /* 1733 */ 0x0515009e | (16 << 27) /* 0.317627541 */, - /* 1734 */ 0x051600e3 | (16 << 27) /* 0.317871941 */, - /* 1735 */ 0x05170135 | (16 << 27) /* 0.318116387 */, - /* 1736 */ 0x05180194 | (16 << 27) /* 0.318360880 */, - /* 1737 */ 0x051901ff | (16 << 27) /* 0.318605421 */, - /* 1738 */ 0x051a0277 | (16 << 27) /* 0.318850008 */, - /* 1739 */ 0x051b02fc | (16 << 27) /* 0.319094642 */, - /* 1740 */ 0x051c038d | (16 << 27) /* 0.319339323 */, - /* 1741 */ 0x051d042a | (16 << 27) /* 0.319584051 */, - /* 1742 */ 0x051e04d4 | (16 << 27) /* 0.319828826 */, - /* 1743 */ 0x051f058b | (16 << 27) /* 0.320073647 */, - - /* 1744 */ 0x0520064f | (16 << 27) /* 0.320318516 */, - /* 1745 */ 0x0521071f | (16 << 27) /* 0.320563431 */, - /* 1746 */ 0x052207fb | (16 << 27) /* 0.320808393 */, - /* 1747 */ 0x052308e4 | (16 << 27) /* 0.321053402 */, - /* 1748 */ 0x052409da | (16 << 27) /* 0.321298457 */, - /* 1749 */ 0x05250adc | (16 << 27) /* 0.321543560 */, - /* 1750 */ 0x05260bea | (16 << 27) /* 0.321788709 */, - /* 1751 */ 0x05270d06 | (16 << 27) /* 0.322033904 */, - /* 1752 */ 0x05280e2d | (16 << 27) /* 0.322279147 */, - /* 1753 */ 0x05290f62 | (16 << 27) /* 0.322524436 */, - /* 1754 */ 0x052a10a3 | (16 << 27) /* 0.322769771 */, - /* 1755 */ 0x052b11f0 | (16 << 27) /* 0.323015154 */, - /* 1756 */ 0x052c134a | (16 << 27) /* 0.323260583 */, - /* 1757 */ 0x052d14b0 | (16 << 27) /* 0.323506058 */, - /* 1758 */ 0x052e1623 | (16 << 27) /* 0.323751580 */, - /* 1759 */ 0x052f17a2 | (16 << 27) /* 0.323997149 */, - - /* 1760 */ 0x0530192e | (16 << 27) /* 0.324242764 */, - /* 1761 */ 0x05311ac6 | (16 << 27) /* 0.324488426 */, - /* 1762 */ 0x05321c6b | (16 << 27) /* 0.324734134 */, - /* 1763 */ 0x05331e1c | (16 << 27) /* 0.324979889 */, - /* 1764 */ 0x05341fda | (16 << 27) /* 0.325225690 */, - /* 1765 */ 0x053521a4 | (16 << 27) /* 0.325471538 */, - /* 1766 */ 0x0536237b | (16 << 27) /* 0.325717432 */, - /* 1767 */ 0x0537255e | (16 << 27) /* 0.325963372 */, - /* 1768 */ 0x0538274e | (16 << 27) /* 0.326209359 */, - /* 1769 */ 0x0539294a | (16 << 27) /* 0.326455392 */, - /* 1770 */ 0x053a2b52 | (16 << 27) /* 0.326701472 */, - /* 1771 */ 0x053b2d67 | (16 << 27) /* 0.326947598 */, - /* 1772 */ 0x053c2f89 | (16 << 27) /* 0.327193770 */, - /* 1773 */ 0x053d31b6 | (16 << 27) /* 0.327439989 */, - /* 1774 */ 0x053e33f1 | (16 << 27) /* 0.327686254 */, - /* 1775 */ 0x053f3637 | (16 << 27) /* 0.327932565 */, - - /* 1776 */ 0x0540388a | (16 << 27) /* 0.328178922 */, - /* 1777 */ 0x05413aea | (16 << 27) /* 0.328425326 */, - /* 1778 */ 0x05423d56 | (16 << 27) /* 0.328671776 */, - /* 1779 */ 0x05433fce | (16 << 27) /* 0.328918272 */, - /* 1780 */ 0x05444253 | (16 << 27) /* 0.329164814 */, - /* 1781 */ 0x054544e4 | (16 << 27) /* 0.329411403 */, - /* 1782 */ 0x05464781 | (16 << 27) /* 0.329658038 */, - /* 1783 */ 0x05474a2b | (16 << 27) /* 0.329904718 */, - /* 1784 */ 0x05484ce2 | (16 << 27) /* 0.330151445 */, - /* 1785 */ 0x05494fa4 | (16 << 27) /* 0.330398218 */, - /* 1786 */ 0x054a5273 | (16 << 27) /* 0.330645037 */, - /* 1787 */ 0x054b554e | (16 << 27) /* 0.330891903 */, - /* 1788 */ 0x054c5836 | (16 << 27) /* 0.331138814 */, - /* 1789 */ 0x054d5b2a | (16 << 27) /* 0.331385771 */, - /* 1790 */ 0x054e5e2b | (16 << 27) /* 0.331632774 */, - /* 1791 */ 0x054f6138 | (16 << 27) /* 0.331879824 */, - - /* 1792 */ 0x05506451 | (16 << 27) /* 0.332126919 */, - /* 1793 */ 0x05516776 | (16 << 27) /* 0.332374060 */, - /* 1794 */ 0x05526aa8 | (16 << 27) /* 0.332621247 */, - /* 1795 */ 0x05536de6 | (16 << 27) /* 0.332868480 */, - /* 1796 */ 0x05547131 | (16 << 27) /* 0.333115759 */, - /* 1797 */ 0x05557487 | (16 << 27) /* 0.333363084 */, - /* 1798 */ 0x055677ea | (16 << 27) /* 0.333610455 */, - /* 1799 */ 0x05577b5a | (16 << 27) /* 0.333857872 */, - /* 1800 */ 0x05587ed5 | (16 << 27) /* 0.334105334 */, - /* 1801 */ 0x0559825e | (16 << 27) /* 0.334352843 */, - /* 1802 */ 0x055a85f2 | (16 << 27) /* 0.334600397 */, - /* 1803 */ 0x055b8992 | (16 << 27) /* 0.334847997 */, - /* 1804 */ 0x055c8d3f | (16 << 27) /* 0.335095642 */, - /* 1805 */ 0x055d90f9 | (16 << 27) /* 0.335343334 */, - /* 1806 */ 0x055e94be | (16 << 27) /* 0.335591071 */, - /* 1807 */ 0x055f9890 | (16 << 27) /* 0.335838854 */, - - /* 1808 */ 0x05609c6e | (16 << 27) /* 0.336086683 */, - /* 1809 */ 0x0561a058 | (16 << 27) /* 0.336334557 */, - /* 1810 */ 0x0562a44f | (16 << 27) /* 0.336582477 */, - /* 1811 */ 0x0563a851 | (16 << 27) /* 0.336830443 */, - /* 1812 */ 0x0564ac60 | (16 << 27) /* 0.337078454 */, - /* 1813 */ 0x0565b07c | (16 << 27) /* 0.337326511 */, - /* 1814 */ 0x0566b4a3 | (16 << 27) /* 0.337574614 */, - /* 1815 */ 0x0567b8d7 | (16 << 27) /* 0.337822762 */, - /* 1816 */ 0x0568bd17 | (16 << 27) /* 0.338070956 */, - /* 1817 */ 0x0569c163 | (16 << 27) /* 0.338319195 */, - /* 1818 */ 0x056ac5bc | (16 << 27) /* 0.338567480 */, - /* 1819 */ 0x056bca20 | (16 << 27) /* 0.338815811 */, - /* 1820 */ 0x056cce91 | (16 << 27) /* 0.339064186 */, - /* 1821 */ 0x056dd30e | (16 << 27) /* 0.339312608 */, - /* 1822 */ 0x056ed798 | (16 << 27) /* 0.339561075 */, - /* 1823 */ 0x056fdc2d | (16 << 27) /* 0.339809587 */, - - /* 1824 */ 0x0570e0cf | (16 << 27) /* 0.340058145 */, - /* 1825 */ 0x0571e57d | (16 << 27) /* 0.340306748 */, - /* 1826 */ 0x0572ea37 | (16 << 27) /* 0.340555397 */, - /* 1827 */ 0x0573eefd | (16 << 27) /* 0.340804091 */, - /* 1828 */ 0x0574f3d0 | (16 << 27) /* 0.341052830 */, - /* 1829 */ 0x0575f8ae | (16 << 27) /* 0.341301615 */, - /* 1830 */ 0x0576fd99 | (16 << 27) /* 0.341550445 */, - /* 1831 */ 0x05780290 | (16 << 27) /* 0.341799321 */, - /* 1832 */ 0x05790793 | (16 << 27) /* 0.342048241 */, - /* 1833 */ 0x057a0ca3 | (16 << 27) /* 0.342297207 */, - /* 1834 */ 0x057b11be | (16 << 27) /* 0.342546219 */, - /* 1835 */ 0x057c16e6 | (16 << 27) /* 0.342795275 */, - /* 1836 */ 0x057d1c1a | (16 << 27) /* 0.343044377 */, - /* 1837 */ 0x057e2159 | (16 << 27) /* 0.343293524 */, - /* 1838 */ 0x057f26a6 | (16 << 27) /* 0.343542717 */, - /* 1839 */ 0x05802bfe | (16 << 27) /* 0.343791954 */, - - /* 1840 */ 0x05813162 | (16 << 27) /* 0.344041237 */, - /* 1841 */ 0x058236d2 | (16 << 27) /* 0.344290564 */, - /* 1842 */ 0x05833c4f | (16 << 27) /* 0.344539937 */, - /* 1843 */ 0x058441d8 | (16 << 27) /* 0.344789356 */, - /* 1844 */ 0x0585476c | (16 << 27) /* 0.345038819 */, - /* 1845 */ 0x05864d0d | (16 << 27) /* 0.345288327 */, - /* 1846 */ 0x058752ba | (16 << 27) /* 0.345537880 */, - /* 1847 */ 0x05885873 | (16 << 27) /* 0.345787479 */, - /* 1848 */ 0x05895e39 | (16 << 27) /* 0.346037122 */, - /* 1849 */ 0x058a640a | (16 << 27) /* 0.346286811 */, - /* 1850 */ 0x058b69e7 | (16 << 27) /* 0.346536545 */, - /* 1851 */ 0x058c6fd1 | (16 << 27) /* 0.346786323 */, - /* 1852 */ 0x058d75c6 | (16 << 27) /* 0.347036147 */, - /* 1853 */ 0x058e7bc8 | (16 << 27) /* 0.347286015 */, - /* 1854 */ 0x058f81d5 | (16 << 27) /* 0.347535929 */, - /* 1855 */ 0x059087ef | (16 << 27) /* 0.347785887 */, - - /* 1856 */ 0x05918e15 | (16 << 27) /* 0.348035890 */, - /* 1857 */ 0x05929447 | (16 << 27) /* 0.348285939 */, - /* 1858 */ 0x05939a84 | (16 << 27) /* 0.348536032 */, - /* 1859 */ 0x0594a0ce | (16 << 27) /* 0.348786170 */, - /* 1860 */ 0x0595a724 | (16 << 27) /* 0.349036353 */, - /* 1861 */ 0x0596ad86 | (16 << 27) /* 0.349286580 */, - /* 1862 */ 0x0597b3f4 | (16 << 27) /* 0.349536853 */, - /* 1863 */ 0x0598ba6e | (16 << 27) /* 0.349787170 */, - /* 1864 */ 0x0599c0f4 | (16 << 27) /* 0.350037532 */, - /* 1865 */ 0x059ac786 | (16 << 27) /* 0.350287939 */, - /* 1866 */ 0x059bce25 | (16 << 27) /* 0.350538391 */, - /* 1867 */ 0x059cd4cf | (16 << 27) /* 0.350788887 */, - /* 1868 */ 0x059ddb85 | (16 << 27) /* 0.351039428 */, - /* 1869 */ 0x059ee247 | (16 << 27) /* 0.351290014 */, - /* 1870 */ 0x059fe915 | (16 << 27) /* 0.351540645 */, - /* 1871 */ 0x05a0efef | (16 << 27) /* 0.351791320 */, - - /* 1872 */ 0x05a1f6d5 | (16 << 27) /* 0.352042040 */, - /* 1873 */ 0x05a2fdc7 | (16 << 27) /* 0.352292804 */, - /* 1874 */ 0x05a404c5 | (16 << 27) /* 0.352543613 */, - /* 1875 */ 0x05a50bcf | (16 << 27) /* 0.352794467 */, - /* 1876 */ 0x05a612e5 | (16 << 27) /* 0.353045365 */, - /* 1877 */ 0x05a71a07 | (16 << 27) /* 0.353296308 */, - /* 1878 */ 0x05a82135 | (16 << 27) /* 0.353547296 */, - /* 1879 */ 0x05a9286f | (16 << 27) /* 0.353798328 */, - /* 1880 */ 0x05aa2fb5 | (16 << 27) /* 0.354049405 */, - /* 1881 */ 0x05ab3707 | (16 << 27) /* 0.354300526 */, - /* 1882 */ 0x05ac3e65 | (16 << 27) /* 0.354551691 */, - /* 1883 */ 0x05ad45ce | (16 << 27) /* 0.354802901 */, - /* 1884 */ 0x05ae4d44 | (16 << 27) /* 0.355054156 */, - /* 1885 */ 0x05af54c6 | (16 << 27) /* 0.355305455 */, - /* 1886 */ 0x05b05c53 | (16 << 27) /* 0.355556799 */, - /* 1887 */ 0x05b163ed | (16 << 27) /* 0.355808187 */, - - /* 1888 */ 0x05b26b92 | (16 << 27) /* 0.356059619 */, - /* 1889 */ 0x05b37343 | (16 << 27) /* 0.356311096 */, - /* 1890 */ 0x05b47b00 | (16 << 27) /* 0.356562617 */, - /* 1891 */ 0x05b582c9 | (16 << 27) /* 0.356814182 */, - /* 1892 */ 0x05b68a9e | (16 << 27) /* 0.357065792 */, - /* 1893 */ 0x05b7927f | (16 << 27) /* 0.357317446 */, - /* 1894 */ 0x05b89a6c | (16 << 27) /* 0.357569145 */, - /* 1895 */ 0x05b9a265 | (16 << 27) /* 0.357820887 */, - /* 1896 */ 0x05baaa69 | (16 << 27) /* 0.358072674 */, - /* 1897 */ 0x05bbb27a | (16 << 27) /* 0.358324506 */, - /* 1898 */ 0x05bcba96 | (16 << 27) /* 0.358576381 */, - /* 1899 */ 0x05bdc2be | (16 << 27) /* 0.358828301 */, - /* 1900 */ 0x05becaf2 | (16 << 27) /* 0.359080265 */, - /* 1901 */ 0x05bfd332 | (16 << 27) /* 0.359332273 */, - /* 1902 */ 0x05c0db7e | (16 << 27) /* 0.359584326 */, - /* 1903 */ 0x05c1e3d6 | (16 << 27) /* 0.359836423 */, - - /* 1904 */ 0x05c2ec39 | (16 << 27) /* 0.360088563 */, - /* 1905 */ 0x05c3f4a9 | (16 << 27) /* 0.360340748 */, - /* 1906 */ 0x05c4fd24 | (16 << 27) /* 0.360592977 */, - /* 1907 */ 0x05c605ab | (16 << 27) /* 0.360845251 */, - /* 1908 */ 0x05c70e3e | (16 << 27) /* 0.361097568 */, - /* 1909 */ 0x05c816dd | (16 << 27) /* 0.361349929 */, - /* 1910 */ 0x05c91f87 | (16 << 27) /* 0.361602335 */, - /* 1911 */ 0x05ca283e | (16 << 27) /* 0.361854784 */, - /* 1912 */ 0x05cb3100 | (16 << 27) /* 0.362107278 */, - /* 1913 */ 0x05cc39ce | (16 << 27) /* 0.362359815 */, - /* 1914 */ 0x05cd42a8 | (16 << 27) /* 0.362612397 */, - /* 1915 */ 0x05ce4b8d | (16 << 27) /* 0.362865022 */, - /* 1916 */ 0x05cf547f | (16 << 27) /* 0.363117692 */, - /* 1917 */ 0x05d05d7c | (16 << 27) /* 0.363370405 */, - /* 1918 */ 0x05d16685 | (16 << 27) /* 0.363623163 */, - /* 1919 */ 0x05d26f9a | (16 << 27) /* 0.363875964 */, - - /* 1920 */ 0x05d378bb | (16 << 27) /* 0.364128809 */, - /* 1921 */ 0x05d481e7 | (16 << 27) /* 0.364381698 */, - /* 1922 */ 0x05d58b1f | (16 << 27) /* 0.364634632 */, - /* 1923 */ 0x05d69463 | (16 << 27) /* 0.364887608 */, - /* 1924 */ 0x05d79db3 | (16 << 27) /* 0.365140629 */, - /* 1925 */ 0x05d8a70f | (16 << 27) /* 0.365393694 */, - /* 1926 */ 0x05d9b076 | (16 << 27) /* 0.365646802 */, - /* 1927 */ 0x05dab9e9 | (16 << 27) /* 0.365899955 */, - /* 1928 */ 0x05dbc368 | (16 << 27) /* 0.366153151 */, - /* 1929 */ 0x05dcccf2 | (16 << 27) /* 0.366406390 */, - /* 1930 */ 0x05ddd689 | (16 << 27) /* 0.366659674 */, - /* 1931 */ 0x05dee02b | (16 << 27) /* 0.366913001 */, - /* 1932 */ 0x05dfe9d8 | (16 << 27) /* 0.367166372 */, - /* 1933 */ 0x05e0f392 | (16 << 27) /* 0.367419787 */, - /* 1934 */ 0x05e1fd57 | (16 << 27) /* 0.367673246 */, - /* 1935 */ 0x05e30728 | (16 << 27) /* 0.367926748 */, - - /* 1936 */ 0x05e41105 | (16 << 27) /* 0.368180294 */, - /* 1937 */ 0x05e51aed | (16 << 27) /* 0.368433883 */, - /* 1938 */ 0x05e624e1 | (16 << 27) /* 0.368687517 */, - /* 1939 */ 0x05e72ee1 | (16 << 27) /* 0.368941193 */, - /* 1940 */ 0x05e838ed | (16 << 27) /* 0.369194914 */, - /* 1941 */ 0x05e94304 | (16 << 27) /* 0.369448678 */, - /* 1942 */ 0x05ea4d27 | (16 << 27) /* 0.369702485 */, - /* 1943 */ 0x05eb5756 | (16 << 27) /* 0.369956336 */, - /* 1944 */ 0x05ec6190 | (16 << 27) /* 0.370210231 */, - /* 1945 */ 0x05ed6bd6 | (16 << 27) /* 0.370464169 */, - /* 1946 */ 0x05ee7628 | (16 << 27) /* 0.370718151 */, - /* 1947 */ 0x05ef8085 | (16 << 27) /* 0.370972177 */, - /* 1948 */ 0x05f08aee | (16 << 27) /* 0.371226245 */, - /* 1949 */ 0x05f19563 | (16 << 27) /* 0.371480358 */, - /* 1950 */ 0x05f29fe3 | (16 << 27) /* 0.371734513 */, - /* 1951 */ 0x05f3aa6f | (16 << 27) /* 0.371988712 */, - - /* 1952 */ 0x05f4b507 | (16 << 27) /* 0.372242955 */, - /* 1953 */ 0x05f5bfab | (16 << 27) /* 0.372497241 */, - /* 1954 */ 0x05f6ca5a | (16 << 27) /* 0.372751570 */, - /* 1955 */ 0x05f7d514 | (16 << 27) /* 0.373005943 */, - /* 1956 */ 0x05f8dfdb | (16 << 27) /* 0.373260359 */, - /* 1957 */ 0x05f9eaad | (16 << 27) /* 0.373514819 */, - /* 1958 */ 0x05faf58a | (16 << 27) /* 0.373769322 */, - /* 1959 */ 0x05fc0073 | (16 << 27) /* 0.374023868 */, - /* 1960 */ 0x05fd0b68 | (16 << 27) /* 0.374278458 */, - /* 1961 */ 0x05fe1669 | (16 << 27) /* 0.374533091 */, - /* 1962 */ 0x05ff2175 | (16 << 27) /* 0.374787767 */, - /* 1963 */ 0x06002c8d | (16 << 27) /* 0.375042486 */, - /* 1964 */ 0x060137b0 | (16 << 27) /* 0.375297249 */, - /* 1965 */ 0x060242df | (16 << 27) /* 0.375552055 */, - /* 1966 */ 0x06034e19 | (16 << 27) /* 0.375806904 */, - /* 1967 */ 0x0604595f | (16 << 27) /* 0.376061796 */, - - /* 1968 */ 0x060564b1 | (16 << 27) /* 0.376316732 */, - /* 1969 */ 0x0606700f | (16 << 27) /* 0.376571710 */, - /* 1970 */ 0x06077b77 | (16 << 27) /* 0.376826732 */, - /* 1971 */ 0x060886ec | (16 << 27) /* 0.377081797 */, - /* 1972 */ 0x0609926c | (16 << 27) /* 0.377336905 */, - /* 1973 */ 0x060a9df8 | (16 << 27) /* 0.377592057 */, - /* 1974 */ 0x060ba98f | (16 << 27) /* 0.377847251 */, - /* 1975 */ 0x060cb532 | (16 << 27) /* 0.378102489 */, - /* 1976 */ 0x060dc0e0 | (16 << 27) /* 0.378357769 */, - /* 1977 */ 0x060ecc9a | (16 << 27) /* 0.378613093 */, - /* 1978 */ 0x060fd860 | (16 << 27) /* 0.378868460 */, - /* 1979 */ 0x0610e431 | (16 << 27) /* 0.379123870 */, - /* 1980 */ 0x0611f00d | (16 << 27) /* 0.379379322 */, - /* 1981 */ 0x0612fbf5 | (16 << 27) /* 0.379634818 */, - /* 1982 */ 0x061407e9 | (16 << 27) /* 0.379890357 */, - /* 1983 */ 0x061513e8 | (16 << 27) /* 0.380145939 */, - - /* 1984 */ 0x06161ff3 | (16 << 27) /* 0.380401563 */, - /* 1985 */ 0x06172c09 | (16 << 27) /* 0.380657231 */, - /* 1986 */ 0x0618382b | (16 << 27) /* 0.380912942 */, - /* 1987 */ 0x06194458 | (16 << 27) /* 0.381168695 */, - /* 1988 */ 0x061a5091 | (16 << 27) /* 0.381424492 */, - /* 1989 */ 0x061b5cd5 | (16 << 27) /* 0.381680331 */, - /* 1990 */ 0x061c6925 | (16 << 27) /* 0.381936213 */, - /* 1991 */ 0x061d7581 | (16 << 27) /* 0.382192138 */, - /* 1992 */ 0x061e81e8 | (16 << 27) /* 0.382448106 */, - /* 1993 */ 0x061f8e5a | (16 << 27) /* 0.382704117 */, - /* 1994 */ 0x06209ad8 | (16 << 27) /* 0.382960171 */, - /* 1995 */ 0x0621a761 | (16 << 27) /* 0.383216267 */, - /* 1996 */ 0x0622b3f6 | (16 << 27) /* 0.383472406 */, - /* 1997 */ 0x0623c096 | (16 << 27) /* 0.383728588 */, - /* 1998 */ 0x0624cd42 | (16 << 27) /* 0.383984813 */, - /* 1999 */ 0x0625d9f9 | (16 << 27) /* 0.384241080 */, - - /* 2000 */ 0x0626e6bc | (16 << 27) /* 0.384497391 */, - /* 2001 */ 0x0627f38a | (16 << 27) /* 0.384753744 */, - /* 2002 */ 0x06290064 | (16 << 27) /* 0.385010139 */, - /* 2003 */ 0x062a0d49 | (16 << 27) /* 0.385266578 */, - /* 2004 */ 0x062b1a3a | (16 << 27) /* 0.385523059 */, - /* 2005 */ 0x062c2736 | (16 << 27) /* 0.385779582 */, - /* 2006 */ 0x062d343d | (16 << 27) /* 0.386036149 */, - /* 2007 */ 0x062e4150 | (16 << 27) /* 0.386292758 */, - /* 2008 */ 0x062f4e6f | (16 << 27) /* 0.386549409 */, - /* 2009 */ 0x06305b99 | (16 << 27) /* 0.386806104 */, - /* 2010 */ 0x063168ce | (16 << 27) /* 0.387062840 */, - /* 2011 */ 0x0632760f | (16 << 27) /* 0.387319620 */, - /* 2012 */ 0x0633835b | (16 << 27) /* 0.387576442 */, - /* 2013 */ 0x063490b2 | (16 << 27) /* 0.387833306 */, - /* 2014 */ 0x06359e15 | (16 << 27) /* 0.388090213 */, - /* 2015 */ 0x0636ab83 | (16 << 27) /* 0.388347163 */, - - /* 2016 */ 0x0637b8fd | (16 << 27) /* 0.388604155 */, - /* 2017 */ 0x0638c682 | (16 << 27) /* 0.388861190 */, - /* 2018 */ 0x0639d413 | (16 << 27) /* 0.389118267 */, - /* 2019 */ 0x063ae1af | (16 << 27) /* 0.389375386 */, - /* 2020 */ 0x063bef56 | (16 << 27) /* 0.389632548 */, - /* 2021 */ 0x063cfd09 | (16 << 27) /* 0.389889752 */, - /* 2022 */ 0x063e0ac7 | (16 << 27) /* 0.390146999 */, - /* 2023 */ 0x063f1891 | (16 << 27) /* 0.390404289 */, - /* 2024 */ 0x06402666 | (16 << 27) /* 0.390661620 */, - /* 2025 */ 0x06413446 | (16 << 27) /* 0.390918994 */, - /* 2026 */ 0x06424232 | (16 << 27) /* 0.391176411 */, - /* 2027 */ 0x06435029 | (16 << 27) /* 0.391433869 */, - /* 2028 */ 0x06445e2b | (16 << 27) /* 0.391691371 */, - /* 2029 */ 0x06456c39 | (16 << 27) /* 0.391948914 */, - /* 2030 */ 0x06467a52 | (16 << 27) /* 0.392206500 */, - /* 2031 */ 0x06478877 | (16 << 27) /* 0.392464128 */, - - /* 2032 */ 0x064896a7 | (16 << 27) /* 0.392721798 */, - /* 2033 */ 0x0649a4e2 | (16 << 27) /* 0.392979511 */, - /* 2034 */ 0x064ab328 | (16 << 27) /* 0.393237266 */, - /* 2035 */ 0x064bc17a | (16 << 27) /* 0.393495063 */, - /* 2036 */ 0x064ccfd8 | (16 << 27) /* 0.393752902 */, - /* 2037 */ 0x064dde40 | (16 << 27) /* 0.394010784 */, - /* 2038 */ 0x064eecb4 | (16 << 27) /* 0.394268707 */, - /* 2039 */ 0x064ffb33 | (16 << 27) /* 0.394526673 */, - /* 2040 */ 0x065109be | (16 << 27) /* 0.394784681 */, - /* 2041 */ 0x06521854 | (16 << 27) /* 0.395042732 */, - /* 2042 */ 0x065326f5 | (16 << 27) /* 0.395300824 */, - /* 2043 */ 0x065435a1 | (16 << 27) /* 0.395558959 */, - /* 2044 */ 0x06554459 | (16 << 27) /* 0.395817135 */, - /* 2045 */ 0x0656531c | (16 << 27) /* 0.396075354 */, - /* 2046 */ 0x065761ea | (16 << 27) /* 0.396333615 */, - /* 2047 */ 0x065870c4 | (16 << 27) /* 0.396591918 */, - - /* 2048 */ 0x06597fa9 | (16 << 27) /* 0.396850263 */, - /* 2049 */ 0x065a8e99 | (16 << 27) /* 0.397108650 */, - /* 2050 */ 0x065b9d95 | (16 << 27) /* 0.397367079 */, - /* 2051 */ 0x065cac9c | (16 << 27) /* 0.397625550 */, - /* 2052 */ 0x065dbbae | (16 << 27) /* 0.397884063 */, - /* 2053 */ 0x065ecacb | (16 << 27) /* 0.398142619 */, - /* 2054 */ 0x065fd9f4 | (16 << 27) /* 0.398401216 */, - /* 2055 */ 0x0660e928 | (16 << 27) /* 0.398659855 */, - /* 2056 */ 0x0661f867 | (16 << 27) /* 0.398918536 */, - /* 2057 */ 0x066307b1 | (16 << 27) /* 0.399177259 */, - /* 2058 */ 0x06641707 | (16 << 27) /* 0.399436024 */, - /* 2059 */ 0x06652668 | (16 << 27) /* 0.399694831 */, - /* 2060 */ 0x066635d4 | (16 << 27) /* 0.399953679 */, - /* 2061 */ 0x0667454c | (16 << 27) /* 0.400212570 */, - /* 2062 */ 0x066854ce | (16 << 27) /* 0.400471503 */, - /* 2063 */ 0x0669645c | (16 << 27) /* 0.400730477 */, - - /* 2064 */ 0x066a73f5 | (16 << 27) /* 0.400989493 */, - /* 2065 */ 0x066b839a | (16 << 27) /* 0.401248551 */, - /* 2066 */ 0x066c9349 | (16 << 27) /* 0.401507651 */, - /* 2067 */ 0x066da304 | (16 << 27) /* 0.401766793 */, - /* 2068 */ 0x066eb2ca | (16 << 27) /* 0.402025976 */, - /* 2069 */ 0x066fc29b | (16 << 27) /* 0.402285202 */, - /* 2070 */ 0x0670d278 | (16 << 27) /* 0.402544469 */, - /* 2071 */ 0x0671e25f | (16 << 27) /* 0.402803777 */, - /* 2072 */ 0x0672f252 | (16 << 27) /* 0.403063128 */, - /* 2073 */ 0x06740250 | (16 << 27) /* 0.403322520 */, - /* 2074 */ 0x0675125a | (16 << 27) /* 0.403581954 */, - /* 2075 */ 0x0676226e | (16 << 27) /* 0.403841430 */, - /* 2076 */ 0x0677328e | (16 << 27) /* 0.404100947 */, - /* 2077 */ 0x067842b9 | (16 << 27) /* 0.404360506 */, - /* 2078 */ 0x067952ef | (16 << 27) /* 0.404620107 */, - /* 2079 */ 0x067a6330 | (16 << 27) /* 0.404879749 */, - - /* 2080 */ 0x067b737c | (16 << 27) /* 0.405139433 */, - /* 2081 */ 0x067c83d4 | (16 << 27) /* 0.405399159 */, - /* 2082 */ 0x067d9436 | (16 << 27) /* 0.405658926 */, - /* 2083 */ 0x067ea4a4 | (16 << 27) /* 0.405918735 */, - /* 2084 */ 0x067fb51d | (16 << 27) /* 0.406178585 */, - /* 2085 */ 0x0680c5a2 | (16 << 27) /* 0.406438477 */, - /* 2086 */ 0x0681d631 | (16 << 27) /* 0.406698410 */, - /* 2087 */ 0x0682e6cb | (16 << 27) /* 0.406958385 */, - /* 2088 */ 0x0683f771 | (16 << 27) /* 0.407218402 */, - /* 2089 */ 0x06850822 | (16 << 27) /* 0.407478460 */, - /* 2090 */ 0x068618de | (16 << 27) /* 0.407738559 */, - /* 2091 */ 0x068729a5 | (16 << 27) /* 0.407998700 */, - /* 2092 */ 0x06883a77 | (16 << 27) /* 0.408258883 */, - /* 2093 */ 0x06894b55 | (16 << 27) /* 0.408519107 */, - /* 2094 */ 0x068a5c3d | (16 << 27) /* 0.408779372 */, - /* 2095 */ 0x068b6d31 | (16 << 27) /* 0.409039679 */, - - /* 2096 */ 0x068c7e2f | (16 << 27) /* 0.409300027 */, - /* 2097 */ 0x068d8f39 | (16 << 27) /* 0.409560417 */, - /* 2098 */ 0x068ea04e | (16 << 27) /* 0.409820848 */, - /* 2099 */ 0x068fb16e | (16 << 27) /* 0.410081321 */, - /* 2100 */ 0x0690c299 | (16 << 27) /* 0.410341834 */, - /* 2101 */ 0x0691d3cf | (16 << 27) /* 0.410602390 */, - /* 2102 */ 0x0692e511 | (16 << 27) /* 0.410862986 */, - /* 2103 */ 0x0693f65d | (16 << 27) /* 0.411123624 */, - /* 2104 */ 0x069507b5 | (16 << 27) /* 0.411384303 */, - /* 2105 */ 0x06961917 | (16 << 27) /* 0.411645024 */, - /* 2106 */ 0x06972a85 | (16 << 27) /* 0.411905785 */, - /* 2107 */ 0x06983bfe | (16 << 27) /* 0.412166588 */, - /* 2108 */ 0x06994d82 | (16 << 27) /* 0.412427433 */, - /* 2109 */ 0x069a5f11 | (16 << 27) /* 0.412688318 */, - /* 2110 */ 0x069b70ab | (16 << 27) /* 0.412949245 */, - /* 2111 */ 0x069c8250 | (16 << 27) /* 0.413210213 */, - - /* 2112 */ 0x069d9400 | (16 << 27) /* 0.413471222 */, - /* 2113 */ 0x069ea5bb | (16 << 27) /* 0.413732273 */, - /* 2114 */ 0x069fb781 | (16 << 27) /* 0.413993364 */, - /* 2115 */ 0x06a0c953 | (16 << 27) /* 0.414254497 */, - /* 2116 */ 0x06a1db2f | (16 << 27) /* 0.414515671 */, - /* 2117 */ 0x06a2ed16 | (16 << 27) /* 0.414776886 */, - /* 2118 */ 0x06a3ff09 | (16 << 27) /* 0.415038142 */, - /* 2119 */ 0x06a51106 | (16 << 27) /* 0.415299440 */, - /* 2120 */ 0x06a6230f | (16 << 27) /* 0.415560778 */, - /* 2121 */ 0x06a73522 | (16 << 27) /* 0.415822157 */, - /* 2122 */ 0x06a84741 | (16 << 27) /* 0.416083578 */, - /* 2123 */ 0x06a9596a | (16 << 27) /* 0.416345040 */, - /* 2124 */ 0x06aa6b9f | (16 << 27) /* 0.416606542 */, - /* 2125 */ 0x06ab7ddf | (16 << 27) /* 0.416868086 */, - /* 2126 */ 0x06ac9029 | (16 << 27) /* 0.417129671 */, - /* 2127 */ 0x06ada27f | (16 << 27) /* 0.417391297 */, - - /* 2128 */ 0x06aeb4e0 | (16 << 27) /* 0.417652964 */, - /* 2129 */ 0x06afc74b | (16 << 27) /* 0.417914672 */, - /* 2130 */ 0x06b0d9c2 | (16 << 27) /* 0.418176420 */, - /* 2131 */ 0x06b1ec43 | (16 << 27) /* 0.418438210 */, - /* 2132 */ 0x06b2fed0 | (16 << 27) /* 0.418700041 */, - /* 2133 */ 0x06b41168 | (16 << 27) /* 0.418961912 */, - /* 2134 */ 0x06b5240a | (16 << 27) /* 0.419223825 */, - /* 2135 */ 0x06b636b8 | (16 << 27) /* 0.419485778 */, - /* 2136 */ 0x06b74971 | (16 << 27) /* 0.419747773 */, - /* 2137 */ 0x06b85c34 | (16 << 27) /* 0.420009808 */, - /* 2138 */ 0x06b96f03 | (16 << 27) /* 0.420271884 */, - /* 2139 */ 0x06ba81dc | (16 << 27) /* 0.420534001 */, - /* 2140 */ 0x06bb94c1 | (16 << 27) /* 0.420796159 */, - /* 2141 */ 0x06bca7b0 | (16 << 27) /* 0.421058358 */, - /* 2142 */ 0x06bdbaaa | (16 << 27) /* 0.421320597 */, - /* 2143 */ 0x06becdb0 | (16 << 27) /* 0.421582878 */, - - /* 2144 */ 0x06bfe0c0 | (16 << 27) /* 0.421845199 */, - /* 2145 */ 0x06c0f3db | (16 << 27) /* 0.422107561 */, - /* 2146 */ 0x06c20702 | (16 << 27) /* 0.422369964 */, - /* 2147 */ 0x06c31a33 | (16 << 27) /* 0.422632407 */, - /* 2148 */ 0x06c42d6f | (16 << 27) /* 0.422894891 */, - /* 2149 */ 0x06c540b6 | (16 << 27) /* 0.423157416 */, - /* 2150 */ 0x06c65408 | (16 << 27) /* 0.423419982 */, - /* 2151 */ 0x06c76765 | (16 << 27) /* 0.423682588 */, - /* 2152 */ 0x06c87acc | (16 << 27) /* 0.423945235 */, - /* 2153 */ 0x06c98e3f | (16 << 27) /* 0.424207923 */, - /* 2154 */ 0x06caa1bd | (16 << 27) /* 0.424470652 */, - /* 2155 */ 0x06cbb545 | (16 << 27) /* 0.424733421 */, - /* 2156 */ 0x06ccc8d9 | (16 << 27) /* 0.424996230 */, - /* 2157 */ 0x06cddc77 | (16 << 27) /* 0.425259081 */, - /* 2158 */ 0x06cef020 | (16 << 27) /* 0.425521972 */, - /* 2159 */ 0x06d003d4 | (16 << 27) /* 0.425784903 */, - - /* 2160 */ 0x06d11794 | (16 << 27) /* 0.426047876 */, - /* 2161 */ 0x06d22b5e | (16 << 27) /* 0.426310889 */, - /* 2162 */ 0x06d33f32 | (16 << 27) /* 0.426573942 */, - /* 2163 */ 0x06d45312 | (16 << 27) /* 0.426837036 */, - /* 2164 */ 0x06d566fd | (16 << 27) /* 0.427100170 */, - /* 2165 */ 0x06d67af2 | (16 << 27) /* 0.427363345 */, - /* 2166 */ 0x06d78ef3 | (16 << 27) /* 0.427626561 */, - /* 2167 */ 0x06d8a2fe | (16 << 27) /* 0.427889817 */, - /* 2168 */ 0x06d9b714 | (16 << 27) /* 0.428153114 */, - /* 2169 */ 0x06dacb35 | (16 << 27) /* 0.428416451 */, - /* 2170 */ 0x06dbdf61 | (16 << 27) /* 0.428679828 */, - /* 2171 */ 0x06dcf398 | (16 << 27) /* 0.428943246 */, - /* 2172 */ 0x06de07d9 | (16 << 27) /* 0.429206704 */, - /* 2173 */ 0x06df1c26 | (16 << 27) /* 0.429470203 */, - /* 2174 */ 0x06e0307d | (16 << 27) /* 0.429733743 */, - /* 2175 */ 0x06e144df | (16 << 27) /* 0.429997322 */, - - /* 2176 */ 0x06e2594c | (16 << 27) /* 0.430260942 */, - /* 2177 */ 0x06e36dc4 | (16 << 27) /* 0.430524603 */, - /* 2178 */ 0x06e48246 | (16 << 27) /* 0.430788304 */, - /* 2179 */ 0x06e596d4 | (16 << 27) /* 0.431052045 */, - /* 2180 */ 0x06e6ab6c | (16 << 27) /* 0.431315826 */, - /* 2181 */ 0x06e7c00f | (16 << 27) /* 0.431579648 */, - /* 2182 */ 0x06e8d4bd | (16 << 27) /* 0.431843511 */, - /* 2183 */ 0x06e9e976 | (16 << 27) /* 0.432107413 */, - /* 2184 */ 0x06eafe3a | (16 << 27) /* 0.432371356 */, - /* 2185 */ 0x06ec1308 | (16 << 27) /* 0.432635339 */, - /* 2186 */ 0x06ed27e2 | (16 << 27) /* 0.432899362 */, - /* 2187 */ 0x06ee3cc6 | (16 << 27) /* 0.433163426 */, - /* 2188 */ 0x06ef51b4 | (16 << 27) /* 0.433427530 */, - /* 2189 */ 0x06f066ae | (16 << 27) /* 0.433691674 */, - /* 2190 */ 0x06f17bb3 | (16 << 27) /* 0.433955859 */, - /* 2191 */ 0x06f290c2 | (16 << 27) /* 0.434220083 */, - - /* 2192 */ 0x06f3a5dc | (16 << 27) /* 0.434484348 */, - /* 2193 */ 0x06f4bb01 | (16 << 27) /* 0.434748653 */, - /* 2194 */ 0x06f5d030 | (16 << 27) /* 0.435012998 */, - /* 2195 */ 0x06f6e56b | (16 << 27) /* 0.435277383 */, - /* 2196 */ 0x06f7fab0 | (16 << 27) /* 0.435541809 */, - /* 2197 */ 0x06f91000 | (16 << 27) /* 0.435806274 */, - /* 2198 */ 0x06fa255a | (16 << 27) /* 0.436070780 */, - /* 2199 */ 0x06fb3ac0 | (16 << 27) /* 0.436335326 */, - /* 2200 */ 0x06fc5030 | (16 << 27) /* 0.436599912 */, - /* 2201 */ 0x06fd65ab | (16 << 27) /* 0.436864538 */, - /* 2202 */ 0x06fe7b31 | (16 << 27) /* 0.437129204 */, - /* 2203 */ 0x06ff90c2 | (16 << 27) /* 0.437393910 */, - /* 2204 */ 0x0700a65d | (16 << 27) /* 0.437658657 */, - /* 2205 */ 0x0701bc03 | (16 << 27) /* 0.437923443 */, - /* 2206 */ 0x0702d1b4 | (16 << 27) /* 0.438188269 */, - /* 2207 */ 0x0703e76f | (16 << 27) /* 0.438453136 */, - - /* 2208 */ 0x0704fd35 | (16 << 27) /* 0.438718042 */, - /* 2209 */ 0x07061306 | (16 << 27) /* 0.438982988 */, - /* 2210 */ 0x070728e2 | (16 << 27) /* 0.439247975 */, - /* 2211 */ 0x07083ec9 | (16 << 27) /* 0.439513001 */, - /* 2212 */ 0x070954ba | (16 << 27) /* 0.439778067 */, - /* 2213 */ 0x070a6ab6 | (16 << 27) /* 0.440043173 */, - /* 2214 */ 0x070b80bc | (16 << 27) /* 0.440308320 */, - /* 2215 */ 0x070c96ce | (16 << 27) /* 0.440573506 */, - /* 2216 */ 0x070dacea | (16 << 27) /* 0.440838732 */, - /* 2217 */ 0x070ec310 | (16 << 27) /* 0.441103997 */, - /* 2218 */ 0x070fd942 | (16 << 27) /* 0.441369303 */, - /* 2219 */ 0x0710ef7e | (16 << 27) /* 0.441634649 */, - /* 2220 */ 0x071205c5 | (16 << 27) /* 0.441900034 */, - /* 2221 */ 0x07131c17 | (16 << 27) /* 0.442165460 */, - /* 2222 */ 0x07143273 | (16 << 27) /* 0.442430925 */, - /* 2223 */ 0x071548da | (16 << 27) /* 0.442696430 */, - - /* 2224 */ 0x07165f4b | (16 << 27) /* 0.442961975 */, - /* 2225 */ 0x071775c8 | (16 << 27) /* 0.443227559 */, - /* 2226 */ 0x07188c4f | (16 << 27) /* 0.443493184 */, - /* 2227 */ 0x0719a2e0 | (16 << 27) /* 0.443758848 */, - /* 2228 */ 0x071ab97d | (16 << 27) /* 0.444024552 */, - /* 2229 */ 0x071bd024 | (16 << 27) /* 0.444290296 */, - /* 2230 */ 0x071ce6d6 | (16 << 27) /* 0.444556079 */, - /* 2231 */ 0x071dfd92 | (16 << 27) /* 0.444821902 */, - /* 2232 */ 0x071f1459 | (16 << 27) /* 0.445087765 */, - /* 2233 */ 0x07202b2b | (16 << 27) /* 0.445353668 */, - /* 2234 */ 0x07214207 | (16 << 27) /* 0.445619610 */, - /* 2235 */ 0x072258ee | (16 << 27) /* 0.445885592 */, - /* 2236 */ 0x07236fe0 | (16 << 27) /* 0.446151614 */, - /* 2237 */ 0x072486dc | (16 << 27) /* 0.446417675 */, - /* 2238 */ 0x07259de3 | (16 << 27) /* 0.446683776 */, - /* 2239 */ 0x0726b4f4 | (16 << 27) /* 0.446949917 */, - - /* 2240 */ 0x0727cc11 | (16 << 27) /* 0.447216097 */, - /* 2241 */ 0x0728e338 | (16 << 27) /* 0.447482317 */, - /* 2242 */ 0x0729fa69 | (16 << 27) /* 0.447748576 */, - /* 2243 */ 0x072b11a5 | (16 << 27) /* 0.448014875 */, - /* 2244 */ 0x072c28ec | (16 << 27) /* 0.448281214 */, - /* 2245 */ 0x072d403d | (16 << 27) /* 0.448547592 */, - /* 2246 */ 0x072e5799 | (16 << 27) /* 0.448814010 */, - /* 2247 */ 0x072f6f00 | (16 << 27) /* 0.449080467 */, - /* 2248 */ 0x07308671 | (16 << 27) /* 0.449346964 */, - /* 2249 */ 0x07319ded | (16 << 27) /* 0.449613501 */, - /* 2250 */ 0x0732b573 | (16 << 27) /* 0.449880076 */, - /* 2251 */ 0x0733cd04 | (16 << 27) /* 0.450146692 */, - /* 2252 */ 0x0734e4a0 | (16 << 27) /* 0.450413347 */, - /* 2253 */ 0x0735fc46 | (16 << 27) /* 0.450680041 */, - /* 2254 */ 0x073713f7 | (16 << 27) /* 0.450946775 */, - /* 2255 */ 0x07382bb2 | (16 << 27) /* 0.451213548 */, - - /* 2256 */ 0x07394378 | (16 << 27) /* 0.451480360 */, - /* 2257 */ 0x073a5b49 | (16 << 27) /* 0.451747213 */, - /* 2258 */ 0x073b7324 | (16 << 27) /* 0.452014104 */, - /* 2259 */ 0x073c8b0a | (16 << 27) /* 0.452281035 */, - /* 2260 */ 0x073da2fa | (16 << 27) /* 0.452548005 */, - /* 2261 */ 0x073ebaf5 | (16 << 27) /* 0.452815015 */, - /* 2262 */ 0x073fd2fa | (16 << 27) /* 0.453082064 */, - /* 2263 */ 0x0740eb0a | (16 << 27) /* 0.453349152 */, - /* 2264 */ 0x07420325 | (16 << 27) /* 0.453616280 */, - /* 2265 */ 0x07431b4a | (16 << 27) /* 0.453883447 */, - /* 2266 */ 0x0744337a | (16 << 27) /* 0.454150653 */, - /* 2267 */ 0x07454bb4 | (16 << 27) /* 0.454417899 */, - /* 2268 */ 0x074663f8 | (16 << 27) /* 0.454685184 */, - /* 2269 */ 0x07477c48 | (16 << 27) /* 0.454952508 */, - /* 2270 */ 0x074894a2 | (16 << 27) /* 0.455219872 */, - /* 2271 */ 0x0749ad06 | (16 << 27) /* 0.455487275 */, - - /* 2272 */ 0x074ac575 | (16 << 27) /* 0.455754717 */, - /* 2273 */ 0x074bddee | (16 << 27) /* 0.456022198 */, - /* 2274 */ 0x074cf672 | (16 << 27) /* 0.456289719 */, - /* 2275 */ 0x074e0f01 | (16 << 27) /* 0.456557278 */, - /* 2276 */ 0x074f279a | (16 << 27) /* 0.456824877 */, - /* 2277 */ 0x0750403e | (16 << 27) /* 0.457092516 */, - /* 2278 */ 0x075158ec | (16 << 27) /* 0.457360193 */, - /* 2279 */ 0x075271a4 | (16 << 27) /* 0.457627909 */, - /* 2280 */ 0x07538a67 | (16 << 27) /* 0.457895665 */, - /* 2281 */ 0x0754a335 | (16 << 27) /* 0.458163460 */, - /* 2282 */ 0x0755bc0d | (16 << 27) /* 0.458431294 */, - /* 2283 */ 0x0756d4f0 | (16 << 27) /* 0.458699167 */, - /* 2284 */ 0x0757eddd | (16 << 27) /* 0.458967079 */, - /* 2285 */ 0x075906d5 | (16 << 27) /* 0.459235030 */, - /* 2286 */ 0x075a1fd7 | (16 << 27) /* 0.459503021 */, - /* 2287 */ 0x075b38e3 | (16 << 27) /* 0.459771050 */, - - /* 2288 */ 0x075c51fa | (16 << 27) /* 0.460039119 */, - /* 2289 */ 0x075d6b1c | (16 << 27) /* 0.460307226 */, - /* 2290 */ 0x075e8448 | (16 << 27) /* 0.460575373 */, - /* 2291 */ 0x075f9d7f | (16 << 27) /* 0.460843559 */, - /* 2292 */ 0x0760b6c0 | (16 << 27) /* 0.461111783 */, - /* 2293 */ 0x0761d00b | (16 << 27) /* 0.461380047 */, - /* 2294 */ 0x0762e961 | (16 << 27) /* 0.461648350 */, - /* 2295 */ 0x076402c1 | (16 << 27) /* 0.461916691 */, - /* 2296 */ 0x07651c2c | (16 << 27) /* 0.462185072 */, - /* 2297 */ 0x076635a2 | (16 << 27) /* 0.462453492 */, - /* 2298 */ 0x07674f22 | (16 << 27) /* 0.462721950 */, - /* 2299 */ 0x076868ac | (16 << 27) /* 0.462990448 */, - /* 2300 */ 0x07698240 | (16 << 27) /* 0.463258984 */, - /* 2301 */ 0x076a9be0 | (16 << 27) /* 0.463527560 */, - /* 2302 */ 0x076bb589 | (16 << 27) /* 0.463796174 */, - /* 2303 */ 0x076ccf3d | (16 << 27) /* 0.464064827 */, - - /* 2304 */ 0x076de8fc | (16 << 27) /* 0.464333519 */, - /* 2305 */ 0x076f02c5 | (16 << 27) /* 0.464602250 */, - /* 2306 */ 0x07701c98 | (16 << 27) /* 0.464871020 */, - /* 2307 */ 0x07713676 | (16 << 27) /* 0.465139829 */, - /* 2308 */ 0x0772505e | (16 << 27) /* 0.465408676 */, - /* 2309 */ 0x07736a51 | (16 << 27) /* 0.465677563 */, - /* 2310 */ 0x0774844e | (16 << 27) /* 0.465946488 */, - /* 2311 */ 0x07759e55 | (16 << 27) /* 0.466215452 */, - /* 2312 */ 0x0776b867 | (16 << 27) /* 0.466484455 */, - /* 2313 */ 0x0777d283 | (16 << 27) /* 0.466753496 */, - /* 2314 */ 0x0778ecaa | (16 << 27) /* 0.467022577 */, - /* 2315 */ 0x077a06db | (16 << 27) /* 0.467291696 */, - /* 2316 */ 0x077b2117 | (16 << 27) /* 0.467560854 */, - /* 2317 */ 0x077c3b5d | (16 << 27) /* 0.467830050 */, - /* 2318 */ 0x077d55ad | (16 << 27) /* 0.468099285 */, - /* 2319 */ 0x077e7008 | (16 << 27) /* 0.468368560 */, - - /* 2320 */ 0x077f8a6d | (16 << 27) /* 0.468637872 */, - /* 2321 */ 0x0780a4dc | (16 << 27) /* 0.468907224 */, - /* 2322 */ 0x0781bf56 | (16 << 27) /* 0.469176614 */, - /* 2323 */ 0x0782d9da | (16 << 27) /* 0.469446043 */, - /* 2324 */ 0x0783f469 | (16 << 27) /* 0.469715510 */, - /* 2325 */ 0x07850f02 | (16 << 27) /* 0.469985016 */, - /* 2326 */ 0x078629a5 | (16 << 27) /* 0.470254561 */, - /* 2327 */ 0x07874453 | (16 << 27) /* 0.470524145 */, - /* 2328 */ 0x07885f0b | (16 << 27) /* 0.470793767 */, - /* 2329 */ 0x078979ce | (16 << 27) /* 0.471063427 */, - /* 2330 */ 0x078a949a | (16 << 27) /* 0.471333126 */, - /* 2331 */ 0x078baf72 | (16 << 27) /* 0.471602864 */, - /* 2332 */ 0x078cca53 | (16 << 27) /* 0.471872641 */, - /* 2333 */ 0x078de53f | (16 << 27) /* 0.472142456 */, - /* 2334 */ 0x078f0035 | (16 << 27) /* 0.472412309 */, - /* 2335 */ 0x07901b36 | (16 << 27) /* 0.472682201 */, - - /* 2336 */ 0x07913641 | (16 << 27) /* 0.472952132 */, - /* 2337 */ 0x07925156 | (16 << 27) /* 0.473222101 */, - /* 2338 */ 0x07936c76 | (16 << 27) /* 0.473492108 */, - /* 2339 */ 0x079487a0 | (16 << 27) /* 0.473762155 */, - /* 2340 */ 0x0795a2d4 | (16 << 27) /* 0.474032239 */, - /* 2341 */ 0x0796be13 | (16 << 27) /* 0.474302362 */, - /* 2342 */ 0x0797d95c | (16 << 27) /* 0.474572524 */, - /* 2343 */ 0x0798f4af | (16 << 27) /* 0.474842724 */, - /* 2344 */ 0x079a100c | (16 << 27) /* 0.475112962 */, - /* 2345 */ 0x079b2b74 | (16 << 27) /* 0.475383239 */, - /* 2346 */ 0x079c46e7 | (16 << 27) /* 0.475653554 */, - /* 2347 */ 0x079d6263 | (16 << 27) /* 0.475923908 */, - /* 2348 */ 0x079e7dea | (16 << 27) /* 0.476194300 */, - /* 2349 */ 0x079f997b | (16 << 27) /* 0.476464731 */, - /* 2350 */ 0x07a0b516 | (16 << 27) /* 0.476735200 */, - /* 2351 */ 0x07a1d0bc | (16 << 27) /* 0.477005707 */, - - /* 2352 */ 0x07a2ec6c | (16 << 27) /* 0.477276252 */, - /* 2353 */ 0x07a40827 | (16 << 27) /* 0.477546836 */, - /* 2354 */ 0x07a523eb | (16 << 27) /* 0.477817459 */, - /* 2355 */ 0x07a63fba | (16 << 27) /* 0.478088119 */, - /* 2356 */ 0x07a75b93 | (16 << 27) /* 0.478358818 */, - /* 2357 */ 0x07a87777 | (16 << 27) /* 0.478629555 */, - /* 2358 */ 0x07a99364 | (16 << 27) /* 0.478900331 */, - /* 2359 */ 0x07aaaf5c | (16 << 27) /* 0.479171145 */, - /* 2360 */ 0x07abcb5f | (16 << 27) /* 0.479441997 */, - /* 2361 */ 0x07ace76b | (16 << 27) /* 0.479712887 */, - /* 2362 */ 0x07ae0382 | (16 << 27) /* 0.479983816 */, - /* 2363 */ 0x07af1fa3 | (16 << 27) /* 0.480254782 */, - /* 2364 */ 0x07b03bcf | (16 << 27) /* 0.480525787 */, - /* 2365 */ 0x07b15804 | (16 << 27) /* 0.480796831 */, - /* 2366 */ 0x07b27444 | (16 << 27) /* 0.481067912 */, - /* 2367 */ 0x07b3908e | (16 << 27) /* 0.481339032 */, - - /* 2368 */ 0x07b4ace3 | (16 << 27) /* 0.481610189 */, - /* 2369 */ 0x07b5c941 | (16 << 27) /* 0.481881385 */, - /* 2370 */ 0x07b6e5aa | (16 << 27) /* 0.482152620 */, - /* 2371 */ 0x07b8021d | (16 << 27) /* 0.482423892 */, - /* 2372 */ 0x07b91e9b | (16 << 27) /* 0.482695202 */, - /* 2373 */ 0x07ba3b22 | (16 << 27) /* 0.482966551 */, - /* 2374 */ 0x07bb57b4 | (16 << 27) /* 0.483237938 */, - /* 2375 */ 0x07bc7450 | (16 << 27) /* 0.483509362 */, - /* 2376 */ 0x07bd90f6 | (16 << 27) /* 0.483780825 */, - /* 2377 */ 0x07beada7 | (16 << 27) /* 0.484052326 */, - /* 2378 */ 0x07bfca61 | (16 << 27) /* 0.484323865 */, - /* 2379 */ 0x07c0e726 | (16 << 27) /* 0.484595443 */, - /* 2380 */ 0x07c203f5 | (16 << 27) /* 0.484867058 */, - /* 2381 */ 0x07c320cf | (16 << 27) /* 0.485138711 */, - /* 2382 */ 0x07c43db2 | (16 << 27) /* 0.485410402 */, - /* 2383 */ 0x07c55aa0 | (16 << 27) /* 0.485682131 */, - - /* 2384 */ 0x07c67798 | (16 << 27) /* 0.485953899 */, - /* 2385 */ 0x07c7949a | (16 << 27) /* 0.486225704 */, - /* 2386 */ 0x07c8b1a7 | (16 << 27) /* 0.486497547 */, - /* 2387 */ 0x07c9cebd | (16 << 27) /* 0.486769429 */, - /* 2388 */ 0x07caebde | (16 << 27) /* 0.487041348 */, - /* 2389 */ 0x07cc0909 | (16 << 27) /* 0.487313305 */, - /* 2390 */ 0x07cd263e | (16 << 27) /* 0.487585300 */, - /* 2391 */ 0x07ce437d | (16 << 27) /* 0.487857333 */, - /* 2392 */ 0x07cf60c7 | (16 << 27) /* 0.488129404 */, - /* 2393 */ 0x07d07e1b | (16 << 27) /* 0.488401513 */, - /* 2394 */ 0x07d19b79 | (16 << 27) /* 0.488673660 */, - /* 2395 */ 0x07d2b8e1 | (16 << 27) /* 0.488945845 */, - /* 2396 */ 0x07d3d653 | (16 << 27) /* 0.489218067 */, - /* 2397 */ 0x07d4f3cf | (16 << 27) /* 0.489490328 */, - /* 2398 */ 0x07d61156 | (16 << 27) /* 0.489762626 */, - /* 2399 */ 0x07d72ee6 | (16 << 27) /* 0.490034962 */, - - /* 2400 */ 0x07d84c81 | (16 << 27) /* 0.490307336 */, - /* 2401 */ 0x07d96a26 | (16 << 27) /* 0.490579748 */, - /* 2402 */ 0x07da87d5 | (16 << 27) /* 0.490852198 */, - /* 2403 */ 0x07dba58f | (16 << 27) /* 0.491124686 */, - /* 2404 */ 0x07dcc352 | (16 << 27) /* 0.491397211 */, - /* 2405 */ 0x07dde120 | (16 << 27) /* 0.491669774 */, - /* 2406 */ 0x07defef7 | (16 << 27) /* 0.491942375 */, - /* 2407 */ 0x07e01cd9 | (16 << 27) /* 0.492215014 */, - /* 2408 */ 0x07e13ac5 | (16 << 27) /* 0.492487690 */, - /* 2409 */ 0x07e258bc | (16 << 27) /* 0.492760404 */, - /* 2410 */ 0x07e376bc | (16 << 27) /* 0.493033156 */, - /* 2411 */ 0x07e494c6 | (16 << 27) /* 0.493305946 */, - /* 2412 */ 0x07e5b2db | (16 << 27) /* 0.493578773 */, - /* 2413 */ 0x07e6d0f9 | (16 << 27) /* 0.493851638 */, - /* 2414 */ 0x07e7ef22 | (16 << 27) /* 0.494124541 */, - /* 2415 */ 0x07e90d55 | (16 << 27) /* 0.494397481 */, - - /* 2416 */ 0x07ea2b92 | (16 << 27) /* 0.494670459 */, - /* 2417 */ 0x07eb49d9 | (16 << 27) /* 0.494943475 */, - /* 2418 */ 0x07ec682a | (16 << 27) /* 0.495216529 */, - /* 2419 */ 0x07ed8686 | (16 << 27) /* 0.495489620 */, - /* 2420 */ 0x07eea4eb | (16 << 27) /* 0.495762748 */, - /* 2421 */ 0x07efc35b | (16 << 27) /* 0.496035915 */, - /* 2422 */ 0x07f0e1d4 | (16 << 27) /* 0.496309119 */, - /* 2423 */ 0x07f20058 | (16 << 27) /* 0.496582360 */, - /* 2424 */ 0x07f31ee6 | (16 << 27) /* 0.496855639 */, - /* 2425 */ 0x07f43d7e | (16 << 27) /* 0.497128956 */, - /* 2426 */ 0x07f55c20 | (16 << 27) /* 0.497402310 */, - /* 2427 */ 0x07f67acc | (16 << 27) /* 0.497675702 */, - /* 2428 */ 0x07f79982 | (16 << 27) /* 0.497949132 */, - /* 2429 */ 0x07f8b842 | (16 << 27) /* 0.498222598 */, - /* 2430 */ 0x07f9d70c | (16 << 27) /* 0.498496103 */, - /* 2431 */ 0x07faf5e1 | (16 << 27) /* 0.498769645 */, - - /* 2432 */ 0x07fc14bf | (16 << 27) /* 0.499043224 */, - /* 2433 */ 0x07fd33a8 | (16 << 27) /* 0.499316841 */, - /* 2434 */ 0x07fe529a | (16 << 27) /* 0.499590496 */, - /* 2435 */ 0x07ff7197 | (16 << 27) /* 0.499864188 */, - /* 2436 */ 0x0400484f | (17 << 27) /* 0.250068959 */, - /* 2437 */ 0x0400d7d7 | (17 << 27) /* 0.250205842 */, - /* 2438 */ 0x04016764 | (17 << 27) /* 0.250342744 */, - /* 2439 */ 0x0401f6f7 | (17 << 27) /* 0.250479665 */, - /* 2440 */ 0x0402868e | (17 << 27) /* 0.250616605 */, - /* 2441 */ 0x0403162b | (17 << 27) /* 0.250753563 */, - /* 2442 */ 0x0403a5cc | (17 << 27) /* 0.250890540 */, - /* 2443 */ 0x04043573 | (17 << 27) /* 0.251027536 */, - /* 2444 */ 0x0404c51e | (17 << 27) /* 0.251164550 */, - /* 2445 */ 0x040554cf | (17 << 27) /* 0.251301583 */, - /* 2446 */ 0x0405e484 | (17 << 27) /* 0.251438635 */, - /* 2447 */ 0x0406743f | (17 << 27) /* 0.251575706 */, - - /* 2448 */ 0x040703ff | (17 << 27) /* 0.251712795 */, - /* 2449 */ 0x040793c3 | (17 << 27) /* 0.251849903 */, - /* 2450 */ 0x0408238d | (17 << 27) /* 0.251987029 */, - /* 2451 */ 0x0408b35b | (17 << 27) /* 0.252124174 */, - /* 2452 */ 0x0409432f | (17 << 27) /* 0.252261338 */, - /* 2453 */ 0x0409d308 | (17 << 27) /* 0.252398520 */, - /* 2454 */ 0x040a62e5 | (17 << 27) /* 0.252535721 */, - /* 2455 */ 0x040af2c8 | (17 << 27) /* 0.252672941 */, - /* 2456 */ 0x040b82b0 | (17 << 27) /* 0.252810180 */, - /* 2457 */ 0x040c129c | (17 << 27) /* 0.252947436 */, - /* 2458 */ 0x040ca28e | (17 << 27) /* 0.253084712 */, - /* 2459 */ 0x040d3284 | (17 << 27) /* 0.253222006 */, - /* 2460 */ 0x040dc280 | (17 << 27) /* 0.253359319 */, - /* 2461 */ 0x040e5281 | (17 << 27) /* 0.253496651 */, - /* 2462 */ 0x040ee286 | (17 << 27) /* 0.253634001 */, - /* 2463 */ 0x040f7291 | (17 << 27) /* 0.253771369 */, - - /* 2464 */ 0x041002a1 | (17 << 27) /* 0.253908756 */, - /* 2465 */ 0x041092b5 | (17 << 27) /* 0.254046162 */, - /* 2466 */ 0x041122cf | (17 << 27) /* 0.254183587 */, - /* 2467 */ 0x0411b2ed | (17 << 27) /* 0.254321030 */, - /* 2468 */ 0x04124311 | (17 << 27) /* 0.254458491 */, - /* 2469 */ 0x0412d339 | (17 << 27) /* 0.254595971 */, - /* 2470 */ 0x04136367 | (17 << 27) /* 0.254733470 */, - /* 2471 */ 0x0413f399 | (17 << 27) /* 0.254870987 */, - /* 2472 */ 0x041483d1 | (17 << 27) /* 0.255008523 */, - /* 2473 */ 0x0415140d | (17 << 27) /* 0.255146077 */, - /* 2474 */ 0x0415a44f | (17 << 27) /* 0.255283650 */, - /* 2475 */ 0x04163495 | (17 << 27) /* 0.255421241 */, - /* 2476 */ 0x0416c4e1 | (17 << 27) /* 0.255558851 */, - /* 2477 */ 0x04175531 | (17 << 27) /* 0.255696480 */, - /* 2478 */ 0x0417e586 | (17 << 27) /* 0.255834127 */, - /* 2479 */ 0x041875e1 | (17 << 27) /* 0.255971792 */, - - /* 2480 */ 0x04190640 | (17 << 27) /* 0.256109476 */, - /* 2481 */ 0x041996a4 | (17 << 27) /* 0.256247179 */, - /* 2482 */ 0x041a270d | (17 << 27) /* 0.256384900 */, - /* 2483 */ 0x041ab77b | (17 << 27) /* 0.256522639 */, - /* 2484 */ 0x041b47ef | (17 << 27) /* 0.256660397 */, - /* 2485 */ 0x041bd867 | (17 << 27) /* 0.256798174 */, - /* 2486 */ 0x041c68e4 | (17 << 27) /* 0.256935969 */, - /* 2487 */ 0x041cf966 | (17 << 27) /* 0.257073782 */, - /* 2488 */ 0x041d89ed | (17 << 27) /* 0.257211614 */, - /* 2489 */ 0x041e1a79 | (17 << 27) /* 0.257349465 */, - /* 2490 */ 0x041eab0a | (17 << 27) /* 0.257487334 */, - /* 2491 */ 0x041f3b9f | (17 << 27) /* 0.257625221 */, - /* 2492 */ 0x041fcc3a | (17 << 27) /* 0.257763127 */, - /* 2493 */ 0x04205cda | (17 << 27) /* 0.257901051 */, - /* 2494 */ 0x0420ed7f | (17 << 27) /* 0.258038994 */, - /* 2495 */ 0x04217e28 | (17 << 27) /* 0.258176955 */, - - /* 2496 */ 0x04220ed7 | (17 << 27) /* 0.258314934 */, - /* 2497 */ 0x04229f8a | (17 << 27) /* 0.258452932 */, - /* 2498 */ 0x04233043 | (17 << 27) /* 0.258590948 */, - /* 2499 */ 0x0423c100 | (17 << 27) /* 0.258728983 */, - /* 2500 */ 0x042451c3 | (17 << 27) /* 0.258867036 */, - /* 2501 */ 0x0424e28a | (17 << 27) /* 0.259005108 */, - /* 2502 */ 0x04257356 | (17 << 27) /* 0.259143198 */, - /* 2503 */ 0x04260428 | (17 << 27) /* 0.259281307 */, - /* 2504 */ 0x042694fe | (17 << 27) /* 0.259419433 */, - /* 2505 */ 0x042725d9 | (17 << 27) /* 0.259557579 */, - /* 2506 */ 0x0427b6b9 | (17 << 27) /* 0.259695742 */, - /* 2507 */ 0x0428479e | (17 << 27) /* 0.259833924 */, - /* 2508 */ 0x0428d888 | (17 << 27) /* 0.259972124 */, - /* 2509 */ 0x04296976 | (17 << 27) /* 0.260110343 */, - /* 2510 */ 0x0429fa6a | (17 << 27) /* 0.260248580 */, - /* 2511 */ 0x042a8b63 | (17 << 27) /* 0.260386836 */, - - /* 2512 */ 0x042b1c60 | (17 << 27) /* 0.260525110 */, - /* 2513 */ 0x042bad63 | (17 << 27) /* 0.260663402 */, - /* 2514 */ 0x042c3e6a | (17 << 27) /* 0.260801712 */, - /* 2515 */ 0x042ccf77 | (17 << 27) /* 0.260940041 */, - /* 2516 */ 0x042d6088 | (17 << 27) /* 0.261078388 */, - /* 2517 */ 0x042df19e | (17 << 27) /* 0.261216754 */, - /* 2518 */ 0x042e82b9 | (17 << 27) /* 0.261355137 */, - /* 2519 */ 0x042f13d9 | (17 << 27) /* 0.261493540 */, - /* 2520 */ 0x042fa4fe | (17 << 27) /* 0.261631960 */, - /* 2521 */ 0x04303628 | (17 << 27) /* 0.261770399 */, - /* 2522 */ 0x0430c757 | (17 << 27) /* 0.261908856 */, - /* 2523 */ 0x0431588b | (17 << 27) /* 0.262047331 */, - /* 2524 */ 0x0431e9c3 | (17 << 27) /* 0.262185825 */, - /* 2525 */ 0x04327b01 | (17 << 27) /* 0.262324337 */, - /* 2526 */ 0x04330c43 | (17 << 27) /* 0.262462867 */, - /* 2527 */ 0x04339d8a | (17 << 27) /* 0.262601416 */, - - /* 2528 */ 0x04342ed7 | (17 << 27) /* 0.262739982 */, - /* 2529 */ 0x0434c028 | (17 << 27) /* 0.262878568 */, - /* 2530 */ 0x0435517e | (17 << 27) /* 0.263017171 */, - /* 2531 */ 0x0435e2d9 | (17 << 27) /* 0.263155792 */, - /* 2532 */ 0x04367439 | (17 << 27) /* 0.263294432 */, - /* 2533 */ 0x0437059e | (17 << 27) /* 0.263433090 */, - /* 2534 */ 0x04379707 | (17 << 27) /* 0.263571767 */, - /* 2535 */ 0x04382876 | (17 << 27) /* 0.263710461 */, - /* 2536 */ 0x0438b9e9 | (17 << 27) /* 0.263849174 */, - /* 2537 */ 0x04394b61 | (17 << 27) /* 0.263987905 */, - /* 2538 */ 0x0439dcdf | (17 << 27) /* 0.264126655 */, - /* 2539 */ 0x043a6e61 | (17 << 27) /* 0.264265422 */, - /* 2540 */ 0x043affe8 | (17 << 27) /* 0.264404208 */, - /* 2541 */ 0x043b9174 | (17 << 27) /* 0.264543012 */, - /* 2542 */ 0x043c2305 | (17 << 27) /* 0.264681834 */, - /* 2543 */ 0x043cb49a | (17 << 27) /* 0.264820674 */, - - /* 2544 */ 0x043d4635 | (17 << 27) /* 0.264959533 */, - /* 2545 */ 0x043dd7d4 | (17 << 27) /* 0.265098410 */, - /* 2546 */ 0x043e6979 | (17 << 27) /* 0.265237305 */, - /* 2547 */ 0x043efb22 | (17 << 27) /* 0.265376218 */, - /* 2548 */ 0x043f8cd0 | (17 << 27) /* 0.265515149 */, - /* 2549 */ 0x04401e83 | (17 << 27) /* 0.265654099 */, - /* 2550 */ 0x0440b03b | (17 << 27) /* 0.265793066 */, - /* 2551 */ 0x044141f7 | (17 << 27) /* 0.265932052 */, - /* 2552 */ 0x0441d3b9 | (17 << 27) /* 0.266071056 */, - /* 2553 */ 0x04426580 | (17 << 27) /* 0.266210078 */, - /* 2554 */ 0x0442f74b | (17 << 27) /* 0.266349119 */, - /* 2555 */ 0x0443891b | (17 << 27) /* 0.266488177 */, - /* 2556 */ 0x04441af0 | (17 << 27) /* 0.266627254 */, - /* 2557 */ 0x0444acca | (17 << 27) /* 0.266766349 */, - /* 2558 */ 0x04453ea9 | (17 << 27) /* 0.266905462 */, - /* 2559 */ 0x0445d08d | (17 << 27) /* 0.267044593 */, - - /* 2560 */ 0x04466275 | (17 << 27) /* 0.267183742 */, - /* 2561 */ 0x0446f463 | (17 << 27) /* 0.267322909 */, - /* 2562 */ 0x04478655 | (17 << 27) /* 0.267462094 */, - /* 2563 */ 0x0448184c | (17 << 27) /* 0.267601298 */, - /* 2564 */ 0x0448aa48 | (17 << 27) /* 0.267740519 */, - /* 2565 */ 0x04493c49 | (17 << 27) /* 0.267879759 */, - /* 2566 */ 0x0449ce4f | (17 << 27) /* 0.268019017 */, - /* 2567 */ 0x044a6059 | (17 << 27) /* 0.268158293 */, - /* 2568 */ 0x044af269 | (17 << 27) /* 0.268297587 */, - /* 2569 */ 0x044b847d | (17 << 27) /* 0.268436899 */, - /* 2570 */ 0x044c1696 | (17 << 27) /* 0.268576229 */, - /* 2571 */ 0x044ca8b4 | (17 << 27) /* 0.268715577 */, - /* 2572 */ 0x044d3ad7 | (17 << 27) /* 0.268854943 */, - /* 2573 */ 0x044dccff | (17 << 27) /* 0.268994328 */, - /* 2574 */ 0x044e5f2b | (17 << 27) /* 0.269133730 */, - /* 2575 */ 0x044ef15d | (17 << 27) /* 0.269273150 */, - - /* 2576 */ 0x044f8393 | (17 << 27) /* 0.269412589 */, - /* 2577 */ 0x045015ce | (17 << 27) /* 0.269552045 */, - /* 2578 */ 0x0450a80e | (17 << 27) /* 0.269691520 */, - /* 2579 */ 0x04513a53 | (17 << 27) /* 0.269831013 */, - /* 2580 */ 0x0451cc9c | (17 << 27) /* 0.269970523 */, - /* 2581 */ 0x04525eeb | (17 << 27) /* 0.270110052 */, - /* 2582 */ 0x0452f13e | (17 << 27) /* 0.270249599 */, - /* 2583 */ 0x04538396 | (17 << 27) /* 0.270389163 */, - /* 2584 */ 0x045415f3 | (17 << 27) /* 0.270528746 */, - /* 2585 */ 0x0454a855 | (17 << 27) /* 0.270668347 */, - /* 2586 */ 0x04553abb | (17 << 27) /* 0.270807965 */, - /* 2587 */ 0x0455cd27 | (17 << 27) /* 0.270947602 */, - /* 2588 */ 0x04565f97 | (17 << 27) /* 0.271087257 */, - /* 2589 */ 0x0456f20c | (17 << 27) /* 0.271226930 */, - /* 2590 */ 0x04578486 | (17 << 27) /* 0.271366620 */, - /* 2591 */ 0x04581705 | (17 << 27) /* 0.271506329 */, - - /* 2592 */ 0x0458a989 | (17 << 27) /* 0.271646056 */, - /* 2593 */ 0x04593c11 | (17 << 27) /* 0.271785800 */, - /* 2594 */ 0x0459ce9e | (17 << 27) /* 0.271925563 */, - /* 2595 */ 0x045a6130 | (17 << 27) /* 0.272065343 */, - /* 2596 */ 0x045af3c7 | (17 << 27) /* 0.272205142 */, - /* 2597 */ 0x045b8663 | (17 << 27) /* 0.272344958 */, - /* 2598 */ 0x045c1903 | (17 << 27) /* 0.272484793 */, - /* 2599 */ 0x045caba9 | (17 << 27) /* 0.272624645 */, - /* 2600 */ 0x045d3e53 | (17 << 27) /* 0.272764515 */, - /* 2601 */ 0x045dd102 | (17 << 27) /* 0.272904403 */, - /* 2602 */ 0x045e63b6 | (17 << 27) /* 0.273044310 */, - /* 2603 */ 0x045ef66e | (17 << 27) /* 0.273184234 */, - /* 2604 */ 0x045f892b | (17 << 27) /* 0.273324176 */, - /* 2605 */ 0x04601bee | (17 << 27) /* 0.273464136 */, - /* 2606 */ 0x0460aeb5 | (17 << 27) /* 0.273604113 */, - /* 2607 */ 0x04614180 | (17 << 27) /* 0.273744109 */, - - /* 2608 */ 0x0461d451 | (17 << 27) /* 0.273884123 */, - /* 2609 */ 0x04626727 | (17 << 27) /* 0.274024154 */, - /* 2610 */ 0x0462fa01 | (17 << 27) /* 0.274164204 */, - /* 2611 */ 0x04638ce0 | (17 << 27) /* 0.274304271 */, - /* 2612 */ 0x04641fc4 | (17 << 27) /* 0.274444356 */, - /* 2613 */ 0x0464b2ac | (17 << 27) /* 0.274584459 */, - /* 2614 */ 0x0465459a | (17 << 27) /* 0.274724580 */, - /* 2615 */ 0x0465d88c | (17 << 27) /* 0.274864719 */, - /* 2616 */ 0x04666b83 | (17 << 27) /* 0.275004875 */, - /* 2617 */ 0x0466fe7f | (17 << 27) /* 0.275145050 */, - /* 2618 */ 0x0467917f | (17 << 27) /* 0.275285242 */, - /* 2619 */ 0x04682485 | (17 << 27) /* 0.275425452 */, - /* 2620 */ 0x0468b78f | (17 << 27) /* 0.275565681 */, - /* 2621 */ 0x04694a9e | (17 << 27) /* 0.275705926 */, - /* 2622 */ 0x0469ddb2 | (17 << 27) /* 0.275846190 */, - /* 2623 */ 0x046a70ca | (17 << 27) /* 0.275986472 */, - - /* 2624 */ 0x046b03e7 | (17 << 27) /* 0.276126771 */, - /* 2625 */ 0x046b970a | (17 << 27) /* 0.276267088 */, - /* 2626 */ 0x046c2a31 | (17 << 27) /* 0.276407423 */, - /* 2627 */ 0x046cbd5c | (17 << 27) /* 0.276547776 */, - /* 2628 */ 0x046d508d | (17 << 27) /* 0.276688147 */, - /* 2629 */ 0x046de3c2 | (17 << 27) /* 0.276828535 */, - /* 2630 */ 0x046e76fc | (17 << 27) /* 0.276968942 */, - /* 2631 */ 0x046f0a3b | (17 << 27) /* 0.277109366 */, - /* 2632 */ 0x046f9d7e | (17 << 27) /* 0.277249808 */, - /* 2633 */ 0x047030c7 | (17 << 27) /* 0.277390267 */, - /* 2634 */ 0x0470c414 | (17 << 27) /* 0.277530745 */, - /* 2635 */ 0x04715766 | (17 << 27) /* 0.277671240 */, - /* 2636 */ 0x0471eabc | (17 << 27) /* 0.277811753 */, - /* 2637 */ 0x04727e18 | (17 << 27) /* 0.277952284 */, - /* 2638 */ 0x04731178 | (17 << 27) /* 0.278092832 */, - /* 2639 */ 0x0473a4dd | (17 << 27) /* 0.278233399 */, - - /* 2640 */ 0x04743847 | (17 << 27) /* 0.278373983 */, - /* 2641 */ 0x0474cbb5 | (17 << 27) /* 0.278514584 */, - /* 2642 */ 0x04755f29 | (17 << 27) /* 0.278655204 */, - /* 2643 */ 0x0475f2a1 | (17 << 27) /* 0.278795841 */, - /* 2644 */ 0x0476861d | (17 << 27) /* 0.278936496 */, - /* 2645 */ 0x0477199f | (17 << 27) /* 0.279077169 */, - /* 2646 */ 0x0477ad25 | (17 << 27) /* 0.279217860 */, - /* 2647 */ 0x047840b0 | (17 << 27) /* 0.279358568 */, - /* 2648 */ 0x0478d440 | (17 << 27) /* 0.279499294 */, - /* 2649 */ 0x047967d5 | (17 << 27) /* 0.279640037 */, - /* 2650 */ 0x0479fb6e | (17 << 27) /* 0.279780799 */, - /* 2651 */ 0x047a8f0c | (17 << 27) /* 0.279921578 */, - /* 2652 */ 0x047b22af | (17 << 27) /* 0.280062375 */, - /* 2653 */ 0x047bb657 | (17 << 27) /* 0.280203189 */, - /* 2654 */ 0x047c4a03 | (17 << 27) /* 0.280344021 */, - /* 2655 */ 0x047cddb4 | (17 << 27) /* 0.280484871 */, - - /* 2656 */ 0x047d716a | (17 << 27) /* 0.280625739 */, - /* 2657 */ 0x047e0524 | (17 << 27) /* 0.280766624 */, - /* 2658 */ 0x047e98e4 | (17 << 27) /* 0.280907527 */, - /* 2659 */ 0x047f2ca8 | (17 << 27) /* 0.281048447 */, - /* 2660 */ 0x047fc071 | (17 << 27) /* 0.281189385 */, - /* 2661 */ 0x0480543e | (17 << 27) /* 0.281330341 */, - /* 2662 */ 0x0480e811 | (17 << 27) /* 0.281471315 */, - /* 2663 */ 0x04817be8 | (17 << 27) /* 0.281612306 */, - /* 2664 */ 0x04820fc3 | (17 << 27) /* 0.281753315 */, - /* 2665 */ 0x0482a3a4 | (17 << 27) /* 0.281894341 */, - /* 2666 */ 0x04833789 | (17 << 27) /* 0.282035386 */, - /* 2667 */ 0x0483cb73 | (17 << 27) /* 0.282176447 */, - /* 2668 */ 0x04845f62 | (17 << 27) /* 0.282317527 */, - /* 2669 */ 0x0484f355 | (17 << 27) /* 0.282458624 */, - /* 2670 */ 0x0485874d | (17 << 27) /* 0.282599738 */, - /* 2671 */ 0x04861b4a | (17 << 27) /* 0.282740871 */, - - /* 2672 */ 0x0486af4c | (17 << 27) /* 0.282882021 */, - /* 2673 */ 0x04874352 | (17 << 27) /* 0.283023188 */, - /* 2674 */ 0x0487d75d | (17 << 27) /* 0.283164373 */, - /* 2675 */ 0x04886b6d | (17 << 27) /* 0.283305576 */, - /* 2676 */ 0x0488ff82 | (17 << 27) /* 0.283446796 */, - /* 2677 */ 0x0489939b | (17 << 27) /* 0.283588034 */, - /* 2678 */ 0x048a27b9 | (17 << 27) /* 0.283729290 */, - /* 2679 */ 0x048abbdc | (17 << 27) /* 0.283870563 */, - /* 2680 */ 0x048b5003 | (17 << 27) /* 0.284011853 */, - /* 2681 */ 0x048be42f | (17 << 27) /* 0.284153161 */, - /* 2682 */ 0x048c7860 | (17 << 27) /* 0.284294487 */, - /* 2683 */ 0x048d0c96 | (17 << 27) /* 0.284435831 */, - /* 2684 */ 0x048da0d0 | (17 << 27) /* 0.284577192 */, - /* 2685 */ 0x048e350f | (17 << 27) /* 0.284718570 */, - /* 2686 */ 0x048ec953 | (17 << 27) /* 0.284859966 */, - /* 2687 */ 0x048f5d9b | (17 << 27) /* 0.285001380 */, - - /* 2688 */ 0x048ff1e8 | (17 << 27) /* 0.285142811 */, - /* 2689 */ 0x0490863a | (17 << 27) /* 0.285284259 */, - /* 2690 */ 0x04911a91 | (17 << 27) /* 0.285425726 */, - /* 2691 */ 0x0491aeec | (17 << 27) /* 0.285567209 */, - /* 2692 */ 0x0492434c | (17 << 27) /* 0.285708711 */, - /* 2693 */ 0x0492d7b0 | (17 << 27) /* 0.285850229 */, - /* 2694 */ 0x04936c1a | (17 << 27) /* 0.285991766 */, - /* 2695 */ 0x04940088 | (17 << 27) /* 0.286133319 */, - /* 2696 */ 0x049494fb | (17 << 27) /* 0.286274891 */, - /* 2697 */ 0x04952972 | (17 << 27) /* 0.286416480 */, - /* 2698 */ 0x0495bdee | (17 << 27) /* 0.286558086 */, - /* 2699 */ 0x0496526f | (17 << 27) /* 0.286699710 */, - /* 2700 */ 0x0496e6f5 | (17 << 27) /* 0.286841351 */, - /* 2701 */ 0x04977b7f | (17 << 27) /* 0.286983010 */, - /* 2702 */ 0x0498100e | (17 << 27) /* 0.287124686 */, - /* 2703 */ 0x0498a4a1 | (17 << 27) /* 0.287266380 */, - - /* 2704 */ 0x0499393a | (17 << 27) /* 0.287408091 */, - /* 2705 */ 0x0499cdd7 | (17 << 27) /* 0.287549820 */, - /* 2706 */ 0x049a6278 | (17 << 27) /* 0.287691566 */, - /* 2707 */ 0x049af71f | (17 << 27) /* 0.287833330 */, - /* 2708 */ 0x049b8bca | (17 << 27) /* 0.287975111 */, - /* 2709 */ 0x049c207a | (17 << 27) /* 0.288116909 */, - /* 2710 */ 0x049cb52e | (17 << 27) /* 0.288258725 */, - /* 2711 */ 0x049d49e7 | (17 << 27) /* 0.288400559 */, - /* 2712 */ 0x049ddea5 | (17 << 27) /* 0.288542409 */, - /* 2713 */ 0x049e7367 | (17 << 27) /* 0.288684278 */, - /* 2714 */ 0x049f082f | (17 << 27) /* 0.288826163 */, - /* 2715 */ 0x049f9cfa | (17 << 27) /* 0.288968067 */, - /* 2716 */ 0x04a031cb | (17 << 27) /* 0.289109987 */, - /* 2717 */ 0x04a0c6a0 | (17 << 27) /* 0.289251925 */, - /* 2718 */ 0x04a15b7a | (17 << 27) /* 0.289393881 */, - /* 2719 */ 0x04a1f059 | (17 << 27) /* 0.289535854 */, - - /* 2720 */ 0x04a2853c | (17 << 27) /* 0.289677844 */, - /* 2721 */ 0x04a31a24 | (17 << 27) /* 0.289819851 */, - /* 2722 */ 0x04a3af10 | (17 << 27) /* 0.289961876 */, - /* 2723 */ 0x04a44401 | (17 << 27) /* 0.290103919 */, - /* 2724 */ 0x04a4d8f7 | (17 << 27) /* 0.290245979 */, - /* 2725 */ 0x04a56df2 | (17 << 27) /* 0.290388056 */, - /* 2726 */ 0x04a602f1 | (17 << 27) /* 0.290530150 */, - /* 2727 */ 0x04a697f5 | (17 << 27) /* 0.290672262 */, - /* 2728 */ 0x04a72cfe | (17 << 27) /* 0.290814392 */, - /* 2729 */ 0x04a7c20b | (17 << 27) /* 0.290956538 */, - /* 2730 */ 0x04a8571d | (17 << 27) /* 0.291098703 */, - /* 2731 */ 0x04a8ec33 | (17 << 27) /* 0.291240884 */, - /* 2732 */ 0x04a9814e | (17 << 27) /* 0.291383083 */, - /* 2733 */ 0x04aa166e | (17 << 27) /* 0.291525299 */, - /* 2734 */ 0x04aaab93 | (17 << 27) /* 0.291667532 */, - /* 2735 */ 0x04ab40bc | (17 << 27) /* 0.291809783 */, - - /* 2736 */ 0x04abd5ea | (17 << 27) /* 0.291952051 */, - /* 2737 */ 0x04ac6b1c | (17 << 27) /* 0.292094337 */, - /* 2738 */ 0x04ad0053 | (17 << 27) /* 0.292236640 */, - /* 2739 */ 0x04ad958f | (17 << 27) /* 0.292378960 */, - /* 2740 */ 0x04ae2ad0 | (17 << 27) /* 0.292521297 */, - /* 2741 */ 0x04aec015 | (17 << 27) /* 0.292663652 */, - /* 2742 */ 0x04af555e | (17 << 27) /* 0.292806024 */, - /* 2743 */ 0x04afeaad | (17 << 27) /* 0.292948414 */, - /* 2744 */ 0x04b08000 | (17 << 27) /* 0.293090820 */, - /* 2745 */ 0x04b11557 | (17 << 27) /* 0.293233244 */, - /* 2746 */ 0x04b1aab4 | (17 << 27) /* 0.293375686 */, - /* 2747 */ 0x04b24015 | (17 << 27) /* 0.293518144 */, - /* 2748 */ 0x04b2d57a | (17 << 27) /* 0.293660620 */, - /* 2749 */ 0x04b36ae4 | (17 << 27) /* 0.293803113 */, - /* 2750 */ 0x04b40053 | (17 << 27) /* 0.293945624 */, - /* 2751 */ 0x04b495c7 | (17 << 27) /* 0.294088151 */, - - /* 2752 */ 0x04b52b3f | (17 << 27) /* 0.294230696 */, - /* 2753 */ 0x04b5c0bc | (17 << 27) /* 0.294373259 */, - /* 2754 */ 0x04b6563d | (17 << 27) /* 0.294515838 */, - /* 2755 */ 0x04b6ebc3 | (17 << 27) /* 0.294658435 */, - /* 2756 */ 0x04b7814e | (17 << 27) /* 0.294801049 */, - /* 2757 */ 0x04b816dd | (17 << 27) /* 0.294943680 */, - /* 2758 */ 0x04b8ac71 | (17 << 27) /* 0.295086329 */, - /* 2759 */ 0x04b9420a | (17 << 27) /* 0.295228995 */, - /* 2760 */ 0x04b9d7a7 | (17 << 27) /* 0.295371678 */, - /* 2761 */ 0x04ba6d49 | (17 << 27) /* 0.295514378 */, - /* 2762 */ 0x04bb02ef | (17 << 27) /* 0.295657095 */, - /* 2763 */ 0x04bb989a | (17 << 27) /* 0.295799830 */, - /* 2764 */ 0x04bc2e4a | (17 << 27) /* 0.295942582 */, - /* 2765 */ 0x04bcc3fe | (17 << 27) /* 0.296085351 */, - /* 2766 */ 0x04bd59b7 | (17 << 27) /* 0.296228138 */, - /* 2767 */ 0x04bdef74 | (17 << 27) /* 0.296370941 */, - - /* 2768 */ 0x04be8537 | (17 << 27) /* 0.296513762 */, - /* 2769 */ 0x04bf1afd | (17 << 27) /* 0.296656600 */, - /* 2770 */ 0x04bfb0c9 | (17 << 27) /* 0.296799455 */, - /* 2771 */ 0x04c04699 | (17 << 27) /* 0.296942327 */, - /* 2772 */ 0x04c0dc6d | (17 << 27) /* 0.297085217 */, - /* 2773 */ 0x04c17247 | (17 << 27) /* 0.297228124 */, - /* 2774 */ 0x04c20824 | (17 << 27) /* 0.297371048 */, - /* 2775 */ 0x04c29e07 | (17 << 27) /* 0.297513989 */, - /* 2776 */ 0x04c333ee | (17 << 27) /* 0.297656947 */, - /* 2777 */ 0x04c3c9da | (17 << 27) /* 0.297799922 */, - /* 2778 */ 0x04c45fca | (17 << 27) /* 0.297942915 */, - /* 2779 */ 0x04c4f5bf | (17 << 27) /* 0.298085925 */, - /* 2780 */ 0x04c58bb8 | (17 << 27) /* 0.298228951 */, - /* 2781 */ 0x04c621b6 | (17 << 27) /* 0.298371996 */, - /* 2782 */ 0x04c6b7b9 | (17 << 27) /* 0.298515057 */, - /* 2783 */ 0x04c74dc0 | (17 << 27) /* 0.298658135 */, - - /* 2784 */ 0x04c7e3cc | (17 << 27) /* 0.298801231 */, - /* 2785 */ 0x04c879dd | (17 << 27) /* 0.298944343 */, - /* 2786 */ 0x04c90ff2 | (17 << 27) /* 0.299087473 */, - /* 2787 */ 0x04c9a60c | (17 << 27) /* 0.299230620 */, - /* 2788 */ 0x04ca3c2a | (17 << 27) /* 0.299373784 */, - /* 2789 */ 0x04cad24d | (17 << 27) /* 0.299516965 */, - /* 2790 */ 0x04cb6874 | (17 << 27) /* 0.299660163 */, - /* 2791 */ 0x04cbfea0 | (17 << 27) /* 0.299803378 */, - /* 2792 */ 0x04cc94d1 | (17 << 27) /* 0.299946611 */, - /* 2793 */ 0x04cd2b06 | (17 << 27) /* 0.300089860 */, - /* 2794 */ 0x04cdc140 | (17 << 27) /* 0.300233127 */, - /* 2795 */ 0x04ce577f | (17 << 27) /* 0.300376411 */, - /* 2796 */ 0x04ceedc2 | (17 << 27) /* 0.300519711 */, - /* 2797 */ 0x04cf8409 | (17 << 27) /* 0.300663029 */, - /* 2798 */ 0x04d01a55 | (17 << 27) /* 0.300806364 */, - /* 2799 */ 0x04d0b0a6 | (17 << 27) /* 0.300949716 */, - - /* 2800 */ 0x04d146fb | (17 << 27) /* 0.301093085 */, - /* 2801 */ 0x04d1dd55 | (17 << 27) /* 0.301236472 */, - /* 2802 */ 0x04d273b4 | (17 << 27) /* 0.301379875 */, - /* 2803 */ 0x04d30a17 | (17 << 27) /* 0.301523295 */, - /* 2804 */ 0x04d3a07f | (17 << 27) /* 0.301666733 */, - /* 2805 */ 0x04d436eb | (17 << 27) /* 0.301810187 */, - /* 2806 */ 0x04d4cd5c | (17 << 27) /* 0.301953659 */, - /* 2807 */ 0x04d563d1 | (17 << 27) /* 0.302097147 */, - /* 2808 */ 0x04d5fa4b | (17 << 27) /* 0.302240653 */, - /* 2809 */ 0x04d690ca | (17 << 27) /* 0.302384175 */, - /* 2810 */ 0x04d7274d | (17 << 27) /* 0.302527715 */, - /* 2811 */ 0x04d7bdd5 | (17 << 27) /* 0.302671271 */, - /* 2812 */ 0x04d85461 | (17 << 27) /* 0.302814845 */, - /* 2813 */ 0x04d8eaf2 | (17 << 27) /* 0.302958436 */, - /* 2814 */ 0x04d98187 | (17 << 27) /* 0.303102044 */, - /* 2815 */ 0x04da1821 | (17 << 27) /* 0.303245668 */, - - /* 2816 */ 0x04daaec0 | (17 << 27) /* 0.303389310 */, - /* 2817 */ 0x04db4563 | (17 << 27) /* 0.303532969 */, - /* 2818 */ 0x04dbdc0a | (17 << 27) /* 0.303676645 */, - /* 2819 */ 0x04dc72b7 | (17 << 27) /* 0.303820337 */, - /* 2820 */ 0x04dd0967 | (17 << 27) /* 0.303964047 */, - /* 2821 */ 0x04dda01d | (17 << 27) /* 0.304107774 */, - /* 2822 */ 0x04de36d7 | (17 << 27) /* 0.304251517 */, - /* 2823 */ 0x04decd95 | (17 << 27) /* 0.304395278 */, - /* 2824 */ 0x04df6458 | (17 << 27) /* 0.304539056 */, - /* 2825 */ 0x04dffb20 | (17 << 27) /* 0.304682850 */, - /* 2826 */ 0x04e091ec | (17 << 27) /* 0.304826662 */, - /* 2827 */ 0x04e128bc | (17 << 27) /* 0.304970491 */, - /* 2828 */ 0x04e1bf92 | (17 << 27) /* 0.305114336 */, - /* 2829 */ 0x04e2566b | (17 << 27) /* 0.305258199 */, - /* 2830 */ 0x04e2ed4a | (17 << 27) /* 0.305402078 */, - /* 2831 */ 0x04e3842d | (17 << 27) /* 0.305545974 */, - - /* 2832 */ 0x04e41b14 | (17 << 27) /* 0.305689888 */, - /* 2833 */ 0x04e4b200 | (17 << 27) /* 0.305833818 */, - /* 2834 */ 0x04e548f1 | (17 << 27) /* 0.305977765 */, - /* 2835 */ 0x04e5dfe6 | (17 << 27) /* 0.306121729 */, - /* 2836 */ 0x04e676df | (17 << 27) /* 0.306265710 */, - /* 2837 */ 0x04e70dde | (17 << 27) /* 0.306409708 */, - /* 2838 */ 0x04e7a4e0 | (17 << 27) /* 0.306553723 */, - /* 2839 */ 0x04e83be7 | (17 << 27) /* 0.306697755 */, - /* 2840 */ 0x04e8d2f3 | (17 << 27) /* 0.306841804 */, - /* 2841 */ 0x04e96a04 | (17 << 27) /* 0.306985869 */, - /* 2842 */ 0x04ea0118 | (17 << 27) /* 0.307129952 */, - /* 2843 */ 0x04ea9832 | (17 << 27) /* 0.307274051 */, - /* 2844 */ 0x04eb2f50 | (17 << 27) /* 0.307418168 */, - /* 2845 */ 0x04ebc672 | (17 << 27) /* 0.307562301 */, - /* 2846 */ 0x04ec5d99 | (17 << 27) /* 0.307706451 */, - /* 2847 */ 0x04ecf4c5 | (17 << 27) /* 0.307850618 */, - - /* 2848 */ 0x04ed8bf5 | (17 << 27) /* 0.307994802 */, - /* 2849 */ 0x04ee2329 | (17 << 27) /* 0.308139003 */, - /* 2850 */ 0x04eeba63 | (17 << 27) /* 0.308283220 */, - /* 2851 */ 0x04ef51a0 | (17 << 27) /* 0.308427455 */, - /* 2852 */ 0x04efe8e2 | (17 << 27) /* 0.308571706 */, - /* 2853 */ 0x04f08029 | (17 << 27) /* 0.308715974 */, - /* 2854 */ 0x04f11774 | (17 << 27) /* 0.308860260 */, - /* 2855 */ 0x04f1aec4 | (17 << 27) /* 0.309004561 */, - /* 2856 */ 0x04f24618 | (17 << 27) /* 0.309148880 */, - /* 2857 */ 0x04f2dd71 | (17 << 27) /* 0.309293216 */, - /* 2858 */ 0x04f374cf | (17 << 27) /* 0.309437568 */, - /* 2859 */ 0x04f40c30 | (17 << 27) /* 0.309581938 */, - /* 2860 */ 0x04f4a397 | (17 << 27) /* 0.309726324 */, - /* 2861 */ 0x04f53b02 | (17 << 27) /* 0.309870727 */, - /* 2862 */ 0x04f5d271 | (17 << 27) /* 0.310015147 */, - /* 2863 */ 0x04f669e5 | (17 << 27) /* 0.310159583 */, - - /* 2864 */ 0x04f7015d | (17 << 27) /* 0.310304037 */, - /* 2865 */ 0x04f798da | (17 << 27) /* 0.310448507 */, - /* 2866 */ 0x04f8305c | (17 << 27) /* 0.310592994 */, - /* 2867 */ 0x04f8c7e2 | (17 << 27) /* 0.310737498 */, - /* 2868 */ 0x04f95f6c | (17 << 27) /* 0.310882018 */, - /* 2869 */ 0x04f9f6fb | (17 << 27) /* 0.311026556 */, - /* 2870 */ 0x04fa8e8f | (17 << 27) /* 0.311171110 */, - /* 2871 */ 0x04fb2627 | (17 << 27) /* 0.311315681 */, - /* 2872 */ 0x04fbbdc3 | (17 << 27) /* 0.311460269 */, - /* 2873 */ 0x04fc5564 | (17 << 27) /* 0.311604874 */, - /* 2874 */ 0x04fced0a | (17 << 27) /* 0.311749495 */, - /* 2875 */ 0x04fd84b4 | (17 << 27) /* 0.311894133 */, - /* 2876 */ 0x04fe1c62 | (17 << 27) /* 0.312038788 */, - /* 2877 */ 0x04feb415 | (17 << 27) /* 0.312183460 */, - /* 2878 */ 0x04ff4bcd | (17 << 27) /* 0.312328148 */, - /* 2879 */ 0x04ffe389 | (17 << 27) /* 0.312472854 */, - - /* 2880 */ 0x05007b49 | (17 << 27) /* 0.312617576 */, - /* 2881 */ 0x0501130e | (17 << 27) /* 0.312762314 */, - /* 2882 */ 0x0501aad8 | (17 << 27) /* 0.312907070 */, - /* 2883 */ 0x050242a6 | (17 << 27) /* 0.313051842 */, - /* 2884 */ 0x0502da78 | (17 << 27) /* 0.313196631 */, - /* 2885 */ 0x0503724f | (17 << 27) /* 0.313341437 */, - /* 2886 */ 0x05040a2b | (17 << 27) /* 0.313486259 */, - /* 2887 */ 0x0504a20b | (17 << 27) /* 0.313631098 */, - /* 2888 */ 0x050539ef | (17 << 27) /* 0.313775954 */, - /* 2889 */ 0x0505d1d8 | (17 << 27) /* 0.313920827 */, - /* 2890 */ 0x050669c5 | (17 << 27) /* 0.314065716 */, - /* 2891 */ 0x050701b7 | (17 << 27) /* 0.314210622 */, - /* 2892 */ 0x050799ae | (17 << 27) /* 0.314355545 */, - /* 2893 */ 0x050831a9 | (17 << 27) /* 0.314500484 */, - /* 2894 */ 0x0508c9a8 | (17 << 27) /* 0.314645440 */, - /* 2895 */ 0x050961ac | (17 << 27) /* 0.314790413 */, - - /* 2896 */ 0x0509f9b4 | (17 << 27) /* 0.314935403 */, - /* 2897 */ 0x050a91c1 | (17 << 27) /* 0.315080409 */, - /* 2898 */ 0x050b29d2 | (17 << 27) /* 0.315225432 */, - /* 2899 */ 0x050bc1e8 | (17 << 27) /* 0.315370472 */, - /* 2900 */ 0x050c5a02 | (17 << 27) /* 0.315515528 */, - /* 2901 */ 0x050cf221 | (17 << 27) /* 0.315660601 */, - /* 2902 */ 0x050d8a44 | (17 << 27) /* 0.315805690 */, - /* 2903 */ 0x050e226c | (17 << 27) /* 0.315950797 */, - /* 2904 */ 0x050eba98 | (17 << 27) /* 0.316095920 */, - /* 2905 */ 0x050f52c9 | (17 << 27) /* 0.316241059 */, - /* 2906 */ 0x050feafe | (17 << 27) /* 0.316386216 */, - /* 2907 */ 0x05108337 | (17 << 27) /* 0.316531388 */, - /* 2908 */ 0x05111b75 | (17 << 27) /* 0.316676578 */, - /* 2909 */ 0x0511b3b8 | (17 << 27) /* 0.316821784 */, - /* 2910 */ 0x05124bff | (17 << 27) /* 0.316967007 */, - /* 2911 */ 0x0512e44a | (17 << 27) /* 0.317112247 */, - - /* 2912 */ 0x05137c9a | (17 << 27) /* 0.317257503 */, - /* 2913 */ 0x051414ee | (17 << 27) /* 0.317402775 */, - /* 2914 */ 0x0514ad47 | (17 << 27) /* 0.317548065 */, - /* 2915 */ 0x051545a5 | (17 << 27) /* 0.317693371 */, - /* 2916 */ 0x0515de06 | (17 << 27) /* 0.317838693 */, - /* 2917 */ 0x0516766d | (17 << 27) /* 0.317984033 */, - /* 2918 */ 0x05170ed7 | (17 << 27) /* 0.318129388 */, - /* 2919 */ 0x0517a746 | (17 << 27) /* 0.318274761 */, - /* 2920 */ 0x05183fba | (17 << 27) /* 0.318420150 */, - /* 2921 */ 0x0518d832 | (17 << 27) /* 0.318565555 */, - /* 2922 */ 0x051970ae | (17 << 27) /* 0.318710978 */, - /* 2923 */ 0x051a092f | (17 << 27) /* 0.318856416 */, - /* 2924 */ 0x051aa1b5 | (17 << 27) /* 0.319001872 */, - /* 2925 */ 0x051b3a3f | (17 << 27) /* 0.319147344 */, - /* 2926 */ 0x051bd2cd | (17 << 27) /* 0.319292832 */, - /* 2927 */ 0x051c6b60 | (17 << 27) /* 0.319438338 */, - - /* 2928 */ 0x051d03f7 | (17 << 27) /* 0.319583859 */, - /* 2929 */ 0x051d9c92 | (17 << 27) /* 0.319729398 */, - /* 2930 */ 0x051e3532 | (17 << 27) /* 0.319874952 */, - /* 2931 */ 0x051ecdd7 | (17 << 27) /* 0.320020524 */, - /* 2932 */ 0x051f6680 | (17 << 27) /* 0.320166112 */, - /* 2933 */ 0x051fff2d | (17 << 27) /* 0.320311716 */, - /* 2934 */ 0x052097df | (17 << 27) /* 0.320457337 */, - /* 2935 */ 0x05213095 | (17 << 27) /* 0.320602975 */, - /* 2936 */ 0x0521c950 | (17 << 27) /* 0.320748629 */, - /* 2937 */ 0x0522620f | (17 << 27) /* 0.320894300 */, - /* 2938 */ 0x0522fad3 | (17 << 27) /* 0.321039987 */, - /* 2939 */ 0x0523939b | (17 << 27) /* 0.321185691 */, - /* 2940 */ 0x05242c68 | (17 << 27) /* 0.321331411 */, - /* 2941 */ 0x0524c538 | (17 << 27) /* 0.321477148 */, - /* 2942 */ 0x05255e0e | (17 << 27) /* 0.321622901 */, - /* 2943 */ 0x0525f6e8 | (17 << 27) /* 0.321768671 */, - - /* 2944 */ 0x05268fc6 | (17 << 27) /* 0.321914457 */, - /* 2945 */ 0x052728a9 | (17 << 27) /* 0.322060260 */, - /* 2946 */ 0x0527c190 | (17 << 27) /* 0.322206079 */, - /* 2947 */ 0x05285a7b | (17 << 27) /* 0.322351915 */, - /* 2948 */ 0x0528f36b | (17 << 27) /* 0.322497768 */, - /* 2949 */ 0x05298c5f | (17 << 27) /* 0.322643636 */, - /* 2950 */ 0x052a2558 | (17 << 27) /* 0.322789522 */, - /* 2951 */ 0x052abe55 | (17 << 27) /* 0.322935424 */, - /* 2952 */ 0x052b5757 | (17 << 27) /* 0.323081342 */, - /* 2953 */ 0x052bf05d | (17 << 27) /* 0.323227277 */, - /* 2954 */ 0x052c8968 | (17 << 27) /* 0.323373228 */, - /* 2955 */ 0x052d2277 | (17 << 27) /* 0.323519196 */, - /* 2956 */ 0x052dbb8a | (17 << 27) /* 0.323665180 */, - /* 2957 */ 0x052e54a2 | (17 << 27) /* 0.323811180 */, - /* 2958 */ 0x052eedbe | (17 << 27) /* 0.323957197 */, - /* 2959 */ 0x052f86de | (17 << 27) /* 0.324103231 */, - - /* 2960 */ 0x05302003 | (17 << 27) /* 0.324249281 */, - /* 2961 */ 0x0530b92d | (17 << 27) /* 0.324395347 */, - /* 2962 */ 0x0531525b | (17 << 27) /* 0.324541430 */, - /* 2963 */ 0x0531eb8d | (17 << 27) /* 0.324687530 */, - /* 2964 */ 0x053284c4 | (17 << 27) /* 0.324833646 */, - /* 2965 */ 0x05331dff | (17 << 27) /* 0.324979778 */, - /* 2966 */ 0x0533b73e | (17 << 27) /* 0.325125926 */, - /* 2967 */ 0x05345082 | (17 << 27) /* 0.325272091 */, - /* 2968 */ 0x0534e9ca | (17 << 27) /* 0.325418273 */, - /* 2969 */ 0x05358317 | (17 << 27) /* 0.325564471 */, - /* 2970 */ 0x05361c68 | (17 << 27) /* 0.325710685 */, - /* 2971 */ 0x0536b5be | (17 << 27) /* 0.325856916 */, - /* 2972 */ 0x05374f17 | (17 << 27) /* 0.326003163 */, - /* 2973 */ 0x0537e876 | (17 << 27) /* 0.326149427 */, - /* 2974 */ 0x053881d9 | (17 << 27) /* 0.326295707 */, - /* 2975 */ 0x05391b40 | (17 << 27) /* 0.326442003 */, - - /* 2976 */ 0x0539b4ab | (17 << 27) /* 0.326588316 */, - /* 2977 */ 0x053a4e1b | (17 << 27) /* 0.326734645 */, - /* 2978 */ 0x053ae78f | (17 << 27) /* 0.326880990 */, - /* 2979 */ 0x053b8108 | (17 << 27) /* 0.327027352 */, - /* 2980 */ 0x053c1a85 | (17 << 27) /* 0.327173730 */, - /* 2981 */ 0x053cb407 | (17 << 27) /* 0.327320125 */, - /* 2982 */ 0x053d4d8d | (17 << 27) /* 0.327466536 */, - /* 2983 */ 0x053de717 | (17 << 27) /* 0.327612963 */, - /* 2984 */ 0x053e80a6 | (17 << 27) /* 0.327759407 */, - /* 2985 */ 0x053f1a39 | (17 << 27) /* 0.327905867 */, - /* 2986 */ 0x053fb3d0 | (17 << 27) /* 0.328052344 */, - /* 2987 */ 0x05404d6c | (17 << 27) /* 0.328198837 */, - /* 2988 */ 0x0540e70c | (17 << 27) /* 0.328345346 */, - /* 2989 */ 0x054180b1 | (17 << 27) /* 0.328491871 */, - /* 2990 */ 0x05421a5a | (17 << 27) /* 0.328638413 */, - /* 2991 */ 0x0542b407 | (17 << 27) /* 0.328784971 */, - - /* 2992 */ 0x05434db9 | (17 << 27) /* 0.328931546 */, - /* 2993 */ 0x0543e76f | (17 << 27) /* 0.329078137 */, - /* 2994 */ 0x0544812a | (17 << 27) /* 0.329224744 */, - /* 2995 */ 0x05451ae9 | (17 << 27) /* 0.329371367 */, - /* 2996 */ 0x0545b4ac | (17 << 27) /* 0.329518007 */, - /* 2997 */ 0x05464e74 | (17 << 27) /* 0.329664663 */, - /* 2998 */ 0x0546e840 | (17 << 27) /* 0.329811336 */, - /* 2999 */ 0x05478211 | (17 << 27) /* 0.329958024 */, - /* 3000 */ 0x05481be5 | (17 << 27) /* 0.330104730 */, - /* 3001 */ 0x0548b5bf | (17 << 27) /* 0.330251451 */, - /* 3002 */ 0x05494f9c | (17 << 27) /* 0.330398189 */, - /* 3003 */ 0x0549e97e | (17 << 27) /* 0.330544943 */, - /* 3004 */ 0x054a8364 | (17 << 27) /* 0.330691713 */, - /* 3005 */ 0x054b1d4f | (17 << 27) /* 0.330838499 */, - /* 3006 */ 0x054bb73e | (17 << 27) /* 0.330985302 */, - /* 3007 */ 0x054c5132 | (17 << 27) /* 0.331132121 */, - - /* 3008 */ 0x054ceb2a | (17 << 27) /* 0.331278957 */, - /* 3009 */ 0x054d8526 | (17 << 27) /* 0.331425808 */, - /* 3010 */ 0x054e1f26 | (17 << 27) /* 0.331572676 */, - /* 3011 */ 0x054eb92b | (17 << 27) /* 0.331719560 */, - /* 3012 */ 0x054f5334 | (17 << 27) /* 0.331866461 */, - /* 3013 */ 0x054fed42 | (17 << 27) /* 0.332013377 */, - /* 3014 */ 0x05508754 | (17 << 27) /* 0.332160310 */, - /* 3015 */ 0x0551216b | (17 << 27) /* 0.332307260 */, - /* 3016 */ 0x0551bb85 | (17 << 27) /* 0.332454225 */, - /* 3017 */ 0x055255a4 | (17 << 27) /* 0.332601207 */, - /* 3018 */ 0x0552efc8 | (17 << 27) /* 0.332748205 */, - /* 3019 */ 0x055389f0 | (17 << 27) /* 0.332895219 */, - /* 3020 */ 0x0554241c | (17 << 27) /* 0.333042249 */, - /* 3021 */ 0x0554be4c | (17 << 27) /* 0.333189296 */, - /* 3022 */ 0x05555881 | (17 << 27) /* 0.333336359 */, - /* 3023 */ 0x0555f2ba | (17 << 27) /* 0.333483438 */, - - /* 3024 */ 0x05568cf8 | (17 << 27) /* 0.333630533 */, - /* 3025 */ 0x0557273a | (17 << 27) /* 0.333777645 */, - /* 3026 */ 0x0557c180 | (17 << 27) /* 0.333924772 */, - /* 3027 */ 0x05585bcb | (17 << 27) /* 0.334071916 */, - /* 3028 */ 0x0558f61a | (17 << 27) /* 0.334219076 */, - /* 3029 */ 0x0559906d | (17 << 27) /* 0.334366253 */, - /* 3030 */ 0x055a2ac5 | (17 << 27) /* 0.334513445 */, - /* 3031 */ 0x055ac521 | (17 << 27) /* 0.334660654 */, - /* 3032 */ 0x055b5f81 | (17 << 27) /* 0.334807879 */, - /* 3033 */ 0x055bf9e6 | (17 << 27) /* 0.334955120 */, - /* 3034 */ 0x055c944f | (17 << 27) /* 0.335102377 */, - /* 3035 */ 0x055d2ebd | (17 << 27) /* 0.335249651 */, - /* 3036 */ 0x055dc92e | (17 << 27) /* 0.335396941 */, - /* 3037 */ 0x055e63a5 | (17 << 27) /* 0.335544246 */, - /* 3038 */ 0x055efe1f | (17 << 27) /* 0.335691568 */, - /* 3039 */ 0x055f989e | (17 << 27) /* 0.335838906 */, - - /* 3040 */ 0x05603321 | (17 << 27) /* 0.335986261 */, - /* 3041 */ 0x0560cda8 | (17 << 27) /* 0.336133631 */, - /* 3042 */ 0x05616834 | (17 << 27) /* 0.336281018 */, - /* 3043 */ 0x056202c4 | (17 << 27) /* 0.336428421 */, - /* 3044 */ 0x05629d59 | (17 << 27) /* 0.336575840 */, - /* 3045 */ 0x056337f2 | (17 << 27) /* 0.336723275 */, - /* 3046 */ 0x0563d28f | (17 << 27) /* 0.336870726 */, - /* 3047 */ 0x05646d30 | (17 << 27) /* 0.337018193 */, - /* 3048 */ 0x056507d6 | (17 << 27) /* 0.337165677 */, - /* 3049 */ 0x0565a280 | (17 << 27) /* 0.337313176 */, - /* 3050 */ 0x05663d2f | (17 << 27) /* 0.337460692 */, - /* 3051 */ 0x0566d7e1 | (17 << 27) /* 0.337608224 */, - /* 3052 */ 0x05677298 | (17 << 27) /* 0.337755772 */, - /* 3053 */ 0x05680d54 | (17 << 27) /* 0.337903336 */, - /* 3054 */ 0x0568a814 | (17 << 27) /* 0.338050916 */, - /* 3055 */ 0x056942d8 | (17 << 27) /* 0.338198513 */, - - /* 3056 */ 0x0569dda0 | (17 << 27) /* 0.338346125 */, - /* 3057 */ 0x056a786d | (17 << 27) /* 0.338493753 */, - /* 3058 */ 0x056b133e | (17 << 27) /* 0.338641398 */, - /* 3059 */ 0x056bae13 | (17 << 27) /* 0.338789059 */, - /* 3060 */ 0x056c48ed | (17 << 27) /* 0.338936736 */, - /* 3061 */ 0x056ce3cb | (17 << 27) /* 0.339084429 */, - /* 3062 */ 0x056d7ead | (17 << 27) /* 0.339232138 */, - /* 3063 */ 0x056e1994 | (17 << 27) /* 0.339379863 */, - /* 3064 */ 0x056eb47f | (17 << 27) /* 0.339527604 */, - /* 3065 */ 0x056f4f6e | (17 << 27) /* 0.339675361 */, - /* 3066 */ 0x056fea62 | (17 << 27) /* 0.339823134 */, - /* 3067 */ 0x0570855a | (17 << 27) /* 0.339970924 */, - /* 3068 */ 0x05712056 | (17 << 27) /* 0.340118729 */, - /* 3069 */ 0x0571bb56 | (17 << 27) /* 0.340266550 */, - /* 3070 */ 0x0572565b | (17 << 27) /* 0.340414388 */, - /* 3071 */ 0x0572f164 | (17 << 27) /* 0.340562242 */, - - /* 3072 */ 0x05738c72 | (17 << 27) /* 0.340710111 */, - /* 3073 */ 0x05742784 | (17 << 27) /* 0.340857997 */, - /* 3074 */ 0x0574c29a | (17 << 27) /* 0.341005899 */, - /* 3075 */ 0x05755db4 | (17 << 27) /* 0.341153816 */, - /* 3076 */ 0x0575f8d3 | (17 << 27) /* 0.341301750 */, - /* 3077 */ 0x057693f6 | (17 << 27) /* 0.341449700 */, - /* 3078 */ 0x05772f1d | (17 << 27) /* 0.341597666 */, - /* 3079 */ 0x0577ca49 | (17 << 27) /* 0.341745648 */, - /* 3080 */ 0x05786578 | (17 << 27) /* 0.341893646 */, - /* 3081 */ 0x057900ad | (17 << 27) /* 0.342041659 */, - /* 3082 */ 0x05799be5 | (17 << 27) /* 0.342189689 */, - /* 3083 */ 0x057a3722 | (17 << 27) /* 0.342337735 */, - /* 3084 */ 0x057ad263 | (17 << 27) /* 0.342485797 */, - /* 3085 */ 0x057b6da8 | (17 << 27) /* 0.342633875 */, - /* 3086 */ 0x057c08f2 | (17 << 27) /* 0.342781969 */, - /* 3087 */ 0x057ca440 | (17 << 27) /* 0.342930079 */, - - /* 3088 */ 0x057d3f92 | (17 << 27) /* 0.343078205 */, - /* 3089 */ 0x057ddae9 | (17 << 27) /* 0.343226347 */, - /* 3090 */ 0x057e7644 | (17 << 27) /* 0.343374505 */, - /* 3091 */ 0x057f11a3 | (17 << 27) /* 0.343522679 */, - /* 3092 */ 0x057fad06 | (17 << 27) /* 0.343670869 */, - /* 3093 */ 0x0580486e | (17 << 27) /* 0.343819075 */, - /* 3094 */ 0x0580e3da | (17 << 27) /* 0.343967296 */, - /* 3095 */ 0x05817f4a | (17 << 27) /* 0.344115534 */, - /* 3096 */ 0x05821abf | (17 << 27) /* 0.344263788 */, - /* 3097 */ 0x0582b638 | (17 << 27) /* 0.344412058 */, - /* 3098 */ 0x058351b5 | (17 << 27) /* 0.344560343 */, - /* 3099 */ 0x0583ed36 | (17 << 27) /* 0.344708645 */, - /* 3100 */ 0x058488bc | (17 << 27) /* 0.344856963 */, - /* 3101 */ 0x05852446 | (17 << 27) /* 0.345005296 */, - /* 3102 */ 0x0585bfd4 | (17 << 27) /* 0.345153646 */, - /* 3103 */ 0x05865b67 | (17 << 27) /* 0.345302011 */, - - /* 3104 */ 0x0586f6fd | (17 << 27) /* 0.345450393 */, - /* 3105 */ 0x05879298 | (17 << 27) /* 0.345598790 */, - /* 3106 */ 0x05882e38 | (17 << 27) /* 0.345747203 */, - /* 3107 */ 0x0588c9dc | (17 << 27) /* 0.345895632 */, - /* 3108 */ 0x05896583 | (17 << 27) /* 0.346044077 */, - /* 3109 */ 0x058a0130 | (17 << 27) /* 0.346192538 */, - /* 3110 */ 0x058a9ce0 | (17 << 27) /* 0.346341015 */, - /* 3111 */ 0x058b3895 | (17 << 27) /* 0.346489508 */, - /* 3112 */ 0x058bd44e | (17 << 27) /* 0.346638017 */, - /* 3113 */ 0x058c700b | (17 << 27) /* 0.346786542 */, - /* 3114 */ 0x058d0bcd | (17 << 27) /* 0.346935082 */, - /* 3115 */ 0x058da793 | (17 << 27) /* 0.347083639 */, - /* 3116 */ 0x058e435d | (17 << 27) /* 0.347232211 */, - /* 3117 */ 0x058edf2b | (17 << 27) /* 0.347380799 */, - /* 3118 */ 0x058f7afe | (17 << 27) /* 0.347529403 */, - /* 3119 */ 0x059016d5 | (17 << 27) /* 0.347678023 */, - - /* 3120 */ 0x0590b2b0 | (17 << 27) /* 0.347826659 */, - /* 3121 */ 0x05914e8f | (17 << 27) /* 0.347975311 */, - /* 3122 */ 0x0591ea73 | (17 << 27) /* 0.348123979 */, - /* 3123 */ 0x0592865b | (17 << 27) /* 0.348272662 */, - /* 3124 */ 0x05932247 | (17 << 27) /* 0.348421362 */, - /* 3125 */ 0x0593be37 | (17 << 27) /* 0.348570077 */, - /* 3126 */ 0x05945a2c | (17 << 27) /* 0.348718808 */, - /* 3127 */ 0x0594f625 | (17 << 27) /* 0.348867555 */, - /* 3128 */ 0x05959222 | (17 << 27) /* 0.349016318 */, - /* 3129 */ 0x05962e24 | (17 << 27) /* 0.349165097 */, - /* 3130 */ 0x0596ca2a | (17 << 27) /* 0.349313892 */, - /* 3131 */ 0x05976634 | (17 << 27) /* 0.349462702 */, - /* 3132 */ 0x05980242 | (17 << 27) /* 0.349611528 */, - /* 3133 */ 0x05989e54 | (17 << 27) /* 0.349760370 */, - /* 3134 */ 0x05993a6b | (17 << 27) /* 0.349909228 */, - /* 3135 */ 0x0599d686 | (17 << 27) /* 0.350058102 */, - - /* 3136 */ 0x059a72a5 | (17 << 27) /* 0.350206992 */, - /* 3137 */ 0x059b0ec9 | (17 << 27) /* 0.350355897 */, - /* 3138 */ 0x059baaf1 | (17 << 27) /* 0.350504818 */, - /* 3139 */ 0x059c471d | (17 << 27) /* 0.350653756 */, - /* 3140 */ 0x059ce34d | (17 << 27) /* 0.350802708 */, - /* 3141 */ 0x059d7f81 | (17 << 27) /* 0.350951677 */, - /* 3142 */ 0x059e1bba | (17 << 27) /* 0.351100662 */, - /* 3143 */ 0x059eb7f7 | (17 << 27) /* 0.351249662 */, - /* 3144 */ 0x059f5438 | (17 << 27) /* 0.351398678 */, - /* 3145 */ 0x059ff07e | (17 << 27) /* 0.351547710 */, - /* 3146 */ 0x05a08cc7 | (17 << 27) /* 0.351696758 */, - /* 3147 */ 0x05a12915 | (17 << 27) /* 0.351845821 */, - /* 3148 */ 0x05a1c567 | (17 << 27) /* 0.351994901 */, - /* 3149 */ 0x05a261be | (17 << 27) /* 0.352143996 */, - /* 3150 */ 0x05a2fe18 | (17 << 27) /* 0.352293107 */, - /* 3151 */ 0x05a39a77 | (17 << 27) /* 0.352442233 */, - - /* 3152 */ 0x05a436da | (17 << 27) /* 0.352591376 */, - /* 3153 */ 0x05a4d342 | (17 << 27) /* 0.352740534 */, - /* 3154 */ 0x05a56fad | (17 << 27) /* 0.352889708 */, - /* 3155 */ 0x05a60c1d | (17 << 27) /* 0.353038898 */, - /* 3156 */ 0x05a6a891 | (17 << 27) /* 0.353188103 */, - /* 3157 */ 0x05a7450a | (17 << 27) /* 0.353337325 */, - /* 3158 */ 0x05a7e186 | (17 << 27) /* 0.353486562 */, - /* 3159 */ 0x05a87e07 | (17 << 27) /* 0.353635814 */, - /* 3160 */ 0x05a91a8c | (17 << 27) /* 0.353785083 */, - /* 3161 */ 0x05a9b715 | (17 << 27) /* 0.353934367 */, - /* 3162 */ 0x05aa53a2 | (17 << 27) /* 0.354083667 */, - /* 3163 */ 0x05aaf034 | (17 << 27) /* 0.354232983 */, - /* 3164 */ 0x05ab8cca | (17 << 27) /* 0.354382314 */, - /* 3165 */ 0x05ac2964 | (17 << 27) /* 0.354531662 */, - /* 3166 */ 0x05acc602 | (17 << 27) /* 0.354681025 */, - /* 3167 */ 0x05ad62a5 | (17 << 27) /* 0.354830403 */, - - /* 3168 */ 0x05adff4c | (17 << 27) /* 0.354979798 */, - /* 3169 */ 0x05ae9bf7 | (17 << 27) /* 0.355129208 */, - /* 3170 */ 0x05af38a6 | (17 << 27) /* 0.355278634 */, - /* 3171 */ 0x05afd559 | (17 << 27) /* 0.355428075 */, - /* 3172 */ 0x05b07211 | (17 << 27) /* 0.355577533 */, - /* 3173 */ 0x05b10ecd | (17 << 27) /* 0.355727006 */, - /* 3174 */ 0x05b1ab8d | (17 << 27) /* 0.355876494 */, - /* 3175 */ 0x05b24851 | (17 << 27) /* 0.356025999 */, - /* 3176 */ 0x05b2e51a | (17 << 27) /* 0.356175519 */, - /* 3177 */ 0x05b381e6 | (17 << 27) /* 0.356325054 */, - /* 3178 */ 0x05b41eb7 | (17 << 27) /* 0.356474606 */, - /* 3179 */ 0x05b4bb8c | (17 << 27) /* 0.356624173 */, - /* 3180 */ 0x05b55866 | (17 << 27) /* 0.356773756 */, - /* 3181 */ 0x05b5f543 | (17 << 27) /* 0.356923354 */, - /* 3182 */ 0x05b69225 | (17 << 27) /* 0.357072969 */, - /* 3183 */ 0x05b72f0b | (17 << 27) /* 0.357222598 */, - - /* 3184 */ 0x05b7cbf5 | (17 << 27) /* 0.357372244 */, - /* 3185 */ 0x05b868e3 | (17 << 27) /* 0.357521905 */, - /* 3186 */ 0x05b905d6 | (17 << 27) /* 0.357671582 */, - /* 3187 */ 0x05b9a2cd | (17 << 27) /* 0.357821275 */, - /* 3188 */ 0x05ba3fc8 | (17 << 27) /* 0.357970983 */, - /* 3189 */ 0x05badcc7 | (17 << 27) /* 0.358120707 */, - /* 3190 */ 0x05bb79ca | (17 << 27) /* 0.358270446 */, - /* 3191 */ 0x05bc16d2 | (17 << 27) /* 0.358420201 */, - /* 3192 */ 0x05bcb3de | (17 << 27) /* 0.358569972 */, - /* 3193 */ 0x05bd50ee | (17 << 27) /* 0.358719758 */, - /* 3194 */ 0x05bdee02 | (17 << 27) /* 0.358869560 */, - /* 3195 */ 0x05be8b1a | (17 << 27) /* 0.359019378 */, - /* 3196 */ 0x05bf2837 | (17 << 27) /* 0.359169211 */, - /* 3197 */ 0x05bfc558 | (17 << 27) /* 0.359319060 */, - /* 3198 */ 0x05c0627d | (17 << 27) /* 0.359468925 */, - /* 3199 */ 0x05c0ffa6 | (17 << 27) /* 0.359618805 */, - - /* 3200 */ 0x05c19cd3 | (17 << 27) /* 0.359768701 */, - /* 3201 */ 0x05c23a05 | (17 << 27) /* 0.359918612 */, - /* 3202 */ 0x05c2d73a | (17 << 27) /* 0.360068540 */, - /* 3203 */ 0x05c37474 | (17 << 27) /* 0.360218482 */, - /* 3204 */ 0x05c411b2 | (17 << 27) /* 0.360368440 */, - /* 3205 */ 0x05c4aef5 | (17 << 27) /* 0.360518414 */, - /* 3206 */ 0x05c54c3b | (17 << 27) /* 0.360668404 */, - /* 3207 */ 0x05c5e986 | (17 << 27) /* 0.360818409 */, - /* 3208 */ 0x05c686d5 | (17 << 27) /* 0.360968429 */, - /* 3209 */ 0x05c72428 | (17 << 27) /* 0.361118466 */, - /* 3210 */ 0x05c7c17f | (17 << 27) /* 0.361268517 */, - /* 3211 */ 0x05c85eda | (17 << 27) /* 0.361418585 */, - /* 3212 */ 0x05c8fc3a | (17 << 27) /* 0.361568668 */, - /* 3213 */ 0x05c9999e | (17 << 27) /* 0.361718766 */, - /* 3214 */ 0x05ca3706 | (17 << 27) /* 0.361868881 */, - /* 3215 */ 0x05cad472 | (17 << 27) /* 0.362019010 */, - - /* 3216 */ 0x05cb71e2 | (17 << 27) /* 0.362169156 */, - /* 3217 */ 0x05cc0f57 | (17 << 27) /* 0.362319316 */, - /* 3218 */ 0x05ccaccf | (17 << 27) /* 0.362469493 */, - /* 3219 */ 0x05cd4a4c | (17 << 27) /* 0.362619685 */, - /* 3220 */ 0x05cde7cd | (17 << 27) /* 0.362769892 */, - /* 3221 */ 0x05ce8552 | (17 << 27) /* 0.362920115 */, - /* 3222 */ 0x05cf22dc | (17 << 27) /* 0.363070354 */, - /* 3223 */ 0x05cfc069 | (17 << 27) /* 0.363220608 */, - /* 3224 */ 0x05d05dfb | (17 << 27) /* 0.363370878 */, - /* 3225 */ 0x05d0fb91 | (17 << 27) /* 0.363521163 */, - /* 3226 */ 0x05d1992b | (17 << 27) /* 0.363671464 */, - /* 3227 */ 0x05d236c9 | (17 << 27) /* 0.363821780 */, - /* 3228 */ 0x05d2d46c | (17 << 27) /* 0.363972112 */, - /* 3229 */ 0x05d37212 | (17 << 27) /* 0.364122459 */, - /* 3230 */ 0x05d40fbd | (17 << 27) /* 0.364272822 */, - /* 3231 */ 0x05d4ad6c | (17 << 27) /* 0.364423200 */, - - /* 3232 */ 0x05d54b1f | (17 << 27) /* 0.364573594 */, - /* 3233 */ 0x05d5e8d6 | (17 << 27) /* 0.364724004 */, - /* 3234 */ 0x05d68691 | (17 << 27) /* 0.364874429 */, - /* 3235 */ 0x05d72451 | (17 << 27) /* 0.365024869 */, - /* 3236 */ 0x05d7c215 | (17 << 27) /* 0.365175325 */, - /* 3237 */ 0x05d85fdc | (17 << 27) /* 0.365325796 */, - /* 3238 */ 0x05d8fda8 | (17 << 27) /* 0.365476283 */, - /* 3239 */ 0x05d99b79 | (17 << 27) /* 0.365626786 */, - /* 3240 */ 0x05da394d | (17 << 27) /* 0.365777304 */, - /* 3241 */ 0x05dad726 | (17 << 27) /* 0.365927837 */, - /* 3242 */ 0x05db7502 | (17 << 27) /* 0.366078386 */, - /* 3243 */ 0x05dc12e3 | (17 << 27) /* 0.366228950 */, - /* 3244 */ 0x05dcb0c8 | (17 << 27) /* 0.366379530 */, - /* 3245 */ 0x05dd4eb1 | (17 << 27) /* 0.366530125 */, - /* 3246 */ 0x05ddec9e | (17 << 27) /* 0.366680736 */, - /* 3247 */ 0x05de8a90 | (17 << 27) /* 0.366831362 */, - - /* 3248 */ 0x05df2885 | (17 << 27) /* 0.366982004 */, - /* 3249 */ 0x05dfc67f | (17 << 27) /* 0.367132661 */, - /* 3250 */ 0x05e0647d | (17 << 27) /* 0.367283334 */, - /* 3251 */ 0x05e1027f | (17 << 27) /* 0.367434022 */, - /* 3252 */ 0x05e1a085 | (17 << 27) /* 0.367584725 */, - /* 3253 */ 0x05e23e8f | (17 << 27) /* 0.367735444 */, - /* 3254 */ 0x05e2dc9e | (17 << 27) /* 0.367886179 */, - /* 3255 */ 0x05e37ab0 | (17 << 27) /* 0.368036929 */, - /* 3256 */ 0x05e418c7 | (17 << 27) /* 0.368187694 */, - /* 3257 */ 0x05e4b6e2 | (17 << 27) /* 0.368338475 */, - /* 3258 */ 0x05e55501 | (17 << 27) /* 0.368489271 */, - /* 3259 */ 0x05e5f324 | (17 << 27) /* 0.368640082 */, - /* 3260 */ 0x05e6914c | (17 << 27) /* 0.368790909 */, - /* 3261 */ 0x05e72f77 | (17 << 27) /* 0.368941752 */, - /* 3262 */ 0x05e7cda7 | (17 << 27) /* 0.369092610 */, - /* 3263 */ 0x05e86bda | (17 << 27) /* 0.369243483 */, - - /* 3264 */ 0x05e90a12 | (17 << 27) /* 0.369394372 */, - /* 3265 */ 0x05e9a84e | (17 << 27) /* 0.369545276 */, - /* 3266 */ 0x05ea468e | (17 << 27) /* 0.369696195 */, - /* 3267 */ 0x05eae4d3 | (17 << 27) /* 0.369847130 */, - /* 3268 */ 0x05eb831b | (17 << 27) /* 0.369998080 */, - /* 3269 */ 0x05ec2168 | (17 << 27) /* 0.370149046 */, - /* 3270 */ 0x05ecbfb8 | (17 << 27) /* 0.370300027 */, - /* 3271 */ 0x05ed5e0d | (17 << 27) /* 0.370451024 */, - /* 3272 */ 0x05edfc66 | (17 << 27) /* 0.370602036 */, - /* 3273 */ 0x05ee9ac3 | (17 << 27) /* 0.370753063 */, - /* 3274 */ 0x05ef3924 | (17 << 27) /* 0.370904105 */, - /* 3275 */ 0x05efd78a | (17 << 27) /* 0.371055163 */, - /* 3276 */ 0x05f075f3 | (17 << 27) /* 0.371206237 */, - /* 3277 */ 0x05f11461 | (17 << 27) /* 0.371357326 */, - /* 3278 */ 0x05f1b2d3 | (17 << 27) /* 0.371508430 */, - /* 3279 */ 0x05f25148 | (17 << 27) /* 0.371659549 */, - - /* 3280 */ 0x05f2efc2 | (17 << 27) /* 0.371810684 */, - /* 3281 */ 0x05f38e40 | (17 << 27) /* 0.371961834 */, - /* 3282 */ 0x05f42cc3 | (17 << 27) /* 0.372113000 */, - /* 3283 */ 0x05f4cb49 | (17 << 27) /* 0.372264181 */, - /* 3284 */ 0x05f569d3 | (17 << 27) /* 0.372415377 */, - /* 3285 */ 0x05f60862 | (17 << 27) /* 0.372566589 */, - /* 3286 */ 0x05f6a6f5 | (17 << 27) /* 0.372717816 */, - /* 3287 */ 0x05f7458b | (17 << 27) /* 0.372869058 */, - /* 3288 */ 0x05f7e426 | (17 << 27) /* 0.373020316 */, - /* 3289 */ 0x05f882c5 | (17 << 27) /* 0.373171589 */, - /* 3290 */ 0x05f92169 | (17 << 27) /* 0.373322877 */, - /* 3291 */ 0x05f9c010 | (17 << 27) /* 0.373474181 */, - /* 3292 */ 0x05fa5ebb | (17 << 27) /* 0.373625500 */, - /* 3293 */ 0x05fafd6b | (17 << 27) /* 0.373776834 */, - /* 3294 */ 0x05fb9c1e | (17 << 27) /* 0.373928184 */, - /* 3295 */ 0x05fc3ad6 | (17 << 27) /* 0.374079549 */, - - /* 3296 */ 0x05fcd992 | (17 << 27) /* 0.374230929 */, - /* 3297 */ 0x05fd7852 | (17 << 27) /* 0.374382325 */, - /* 3298 */ 0x05fe1716 | (17 << 27) /* 0.374533735 */, - /* 3299 */ 0x05feb5de | (17 << 27) /* 0.374685162 */, - /* 3300 */ 0x05ff54aa | (17 << 27) /* 0.374836603 */, - /* 3301 */ 0x05fff37b | (17 << 27) /* 0.374988060 */, - /* 3302 */ 0x0600924f | (17 << 27) /* 0.375139532 */, - /* 3303 */ 0x06013128 | (17 << 27) /* 0.375291019 */, - /* 3304 */ 0x0601d004 | (17 << 27) /* 0.375442522 */, - /* 3305 */ 0x06026ee5 | (17 << 27) /* 0.375594040 */, - /* 3306 */ 0x06030dca | (17 << 27) /* 0.375745573 */, - /* 3307 */ 0x0603acb3 | (17 << 27) /* 0.375897122 */, - /* 3308 */ 0x06044ba0 | (17 << 27) /* 0.376048685 */, - /* 3309 */ 0x0604ea91 | (17 << 27) /* 0.376200265 */, - /* 3310 */ 0x06058987 | (17 << 27) /* 0.376351859 */, - /* 3311 */ 0x06062880 | (17 << 27) /* 0.376503468 */, - - /* 3312 */ 0x0606c77d | (17 << 27) /* 0.376655093 */, - /* 3313 */ 0x0607667f | (17 << 27) /* 0.376806733 */, - /* 3314 */ 0x06080585 | (17 << 27) /* 0.376958389 */, - /* 3315 */ 0x0608a48f | (17 << 27) /* 0.377110059 */, - /* 3316 */ 0x0609439c | (17 << 27) /* 0.377261745 */, - /* 3317 */ 0x0609e2ae | (17 << 27) /* 0.377413446 */, - /* 3318 */ 0x060a81c4 | (17 << 27) /* 0.377565163 */, - /* 3319 */ 0x060b20df | (17 << 27) /* 0.377716894 */, - /* 3320 */ 0x060bbffd | (17 << 27) /* 0.377868641 */, - /* 3321 */ 0x060c5f1f | (17 << 27) /* 0.378020403 */, - /* 3322 */ 0x060cfe46 | (17 << 27) /* 0.378172181 */, - /* 3323 */ 0x060d9d70 | (17 << 27) /* 0.378323973 */, - /* 3324 */ 0x060e3c9f | (17 << 27) /* 0.378475781 */, - /* 3325 */ 0x060edbd1 | (17 << 27) /* 0.378627604 */, - /* 3326 */ 0x060f7b08 | (17 << 27) /* 0.378779442 */, - /* 3327 */ 0x06101a43 | (17 << 27) /* 0.378931296 */, - - /* 3328 */ 0x0610b982 | (17 << 27) /* 0.379083164 */, - /* 3329 */ 0x061158c5 | (17 << 27) /* 0.379235048 */, - /* 3330 */ 0x0611f80c | (17 << 27) /* 0.379386947 */, - /* 3331 */ 0x06129757 | (17 << 27) /* 0.379538862 */, - /* 3332 */ 0x061336a6 | (17 << 27) /* 0.379690791 */, - /* 3333 */ 0x0613d5fa | (17 << 27) /* 0.379842736 */, - /* 3334 */ 0x06147551 | (17 << 27) /* 0.379994696 */, - /* 3335 */ 0x061514ad | (17 << 27) /* 0.380146671 */, - /* 3336 */ 0x0615b40c | (17 << 27) /* 0.380298661 */, - /* 3337 */ 0x06165370 | (17 << 27) /* 0.380450666 */, - /* 3338 */ 0x0616f2d8 | (17 << 27) /* 0.380602687 */, - /* 3339 */ 0x06179243 | (17 << 27) /* 0.380754723 */, - /* 3340 */ 0x061831b3 | (17 << 27) /* 0.380906774 */, - /* 3341 */ 0x0618d127 | (17 << 27) /* 0.381058840 */, - /* 3342 */ 0x0619709f | (17 << 27) /* 0.381210921 */, - /* 3343 */ 0x061a101b | (17 << 27) /* 0.381363018 */, - - /* 3344 */ 0x061aaf9c | (17 << 27) /* 0.381515130 */, - /* 3345 */ 0x061b4f20 | (17 << 27) /* 0.381667257 */, - /* 3346 */ 0x061beea8 | (17 << 27) /* 0.381819399 */, - /* 3347 */ 0x061c8e34 | (17 << 27) /* 0.381971556 */, - /* 3348 */ 0x061d2dc5 | (17 << 27) /* 0.382123728 */, - /* 3349 */ 0x061dcd59 | (17 << 27) /* 0.382275916 */, - /* 3350 */ 0x061e6cf2 | (17 << 27) /* 0.382428118 */, - /* 3351 */ 0x061f0c8f | (17 << 27) /* 0.382580336 */, - /* 3352 */ 0x061fac2f | (17 << 27) /* 0.382732569 */, - /* 3353 */ 0x06204bd4 | (17 << 27) /* 0.382884817 */, - /* 3354 */ 0x0620eb7d | (17 << 27) /* 0.383037080 */, - /* 3355 */ 0x06218b2a | (17 << 27) /* 0.383189358 */, - /* 3356 */ 0x06222adb | (17 << 27) /* 0.383341652 */, - /* 3357 */ 0x0622ca90 | (17 << 27) /* 0.383493960 */, - /* 3358 */ 0x06236a49 | (17 << 27) /* 0.383646284 */, - /* 3359 */ 0x06240a06 | (17 << 27) /* 0.383798623 */, - - /* 3360 */ 0x0624a9c7 | (17 << 27) /* 0.383950977 */, - /* 3361 */ 0x0625498d | (17 << 27) /* 0.384103346 */, - /* 3362 */ 0x0625e956 | (17 << 27) /* 0.384255730 */, - /* 3363 */ 0x06268923 | (17 << 27) /* 0.384408129 */, - /* 3364 */ 0x062728f5 | (17 << 27) /* 0.384560544 */, - /* 3365 */ 0x0627c8ca | (17 << 27) /* 0.384712973 */, - /* 3366 */ 0x062868a4 | (17 << 27) /* 0.384865418 */, - /* 3367 */ 0x06290881 | (17 << 27) /* 0.385017878 */, - /* 3368 */ 0x0629a863 | (17 << 27) /* 0.385170352 */, - /* 3369 */ 0x062a4849 | (17 << 27) /* 0.385322842 */, - /* 3370 */ 0x062ae832 | (17 << 27) /* 0.385475347 */, - /* 3371 */ 0x062b8820 | (17 << 27) /* 0.385627867 */, - /* 3372 */ 0x062c2812 | (17 << 27) /* 0.385780402 */, - /* 3373 */ 0x062cc808 | (17 << 27) /* 0.385932953 */, - /* 3374 */ 0x062d6802 | (17 << 27) /* 0.386085518 */, - /* 3375 */ 0x062e0800 | (17 << 27) /* 0.386238098 */, - - /* 3376 */ 0x062ea802 | (17 << 27) /* 0.386390694 */, - /* 3377 */ 0x062f4808 | (17 << 27) /* 0.386543304 */, - /* 3378 */ 0x062fe812 | (17 << 27) /* 0.386695930 */, - /* 3379 */ 0x06308820 | (17 << 27) /* 0.386848570 */, - /* 3380 */ 0x06312832 | (17 << 27) /* 0.387001226 */, - /* 3381 */ 0x0631c849 | (17 << 27) /* 0.387153897 */, - /* 3382 */ 0x06326863 | (17 << 27) /* 0.387306582 */, - /* 3383 */ 0x06330881 | (17 << 27) /* 0.387459283 */, - /* 3384 */ 0x0633a8a3 | (17 << 27) /* 0.387611999 */, - /* 3385 */ 0x063448ca | (17 << 27) /* 0.387764730 */, - /* 3386 */ 0x0634e8f4 | (17 << 27) /* 0.387917476 */, - /* 3387 */ 0x06358923 | (17 << 27) /* 0.388070237 */, - /* 3388 */ 0x06362955 | (17 << 27) /* 0.388223013 */, - /* 3389 */ 0x0636c98c | (17 << 27) /* 0.388375804 */, - /* 3390 */ 0x063769c6 | (17 << 27) /* 0.388528610 */, - /* 3391 */ 0x06380a05 | (17 << 27) /* 0.388681431 */, - - /* 3392 */ 0x0638aa48 | (17 << 27) /* 0.388834268 */, - /* 3393 */ 0x06394a8e | (17 << 27) /* 0.388987119 */, - /* 3394 */ 0x0639ead9 | (17 << 27) /* 0.389139985 */, - /* 3395 */ 0x063a8b28 | (17 << 27) /* 0.389292866 */, - /* 3396 */ 0x063b2b7b | (17 << 27) /* 0.389445762 */, - /* 3397 */ 0x063bcbd1 | (17 << 27) /* 0.389598674 */, - /* 3398 */ 0x063c6c2c | (17 << 27) /* 0.389751600 */, - /* 3399 */ 0x063d0c8b | (17 << 27) /* 0.389904541 */, - /* 3400 */ 0x063dacee | (17 << 27) /* 0.390057497 */, - /* 3401 */ 0x063e4d55 | (17 << 27) /* 0.390210468 */, - /* 3402 */ 0x063eedc0 | (17 << 27) /* 0.390363455 */, - /* 3403 */ 0x063f8e2f | (17 << 27) /* 0.390516456 */, - /* 3404 */ 0x06402ea2 | (17 << 27) /* 0.390669472 */, - /* 3405 */ 0x0640cf19 | (17 << 27) /* 0.390822503 */, - /* 3406 */ 0x06416f94 | (17 << 27) /* 0.390975549 */, - /* 3407 */ 0x06421013 | (17 << 27) /* 0.391128611 */, - - /* 3408 */ 0x0642b096 | (17 << 27) /* 0.391281687 */, - /* 3409 */ 0x0643511d | (17 << 27) /* 0.391434778 */, - /* 3410 */ 0x0643f1a8 | (17 << 27) /* 0.391587884 */, - /* 3411 */ 0x06449237 | (17 << 27) /* 0.391741005 */, - /* 3412 */ 0x064532ca | (17 << 27) /* 0.391894141 */, - /* 3413 */ 0x0645d361 | (17 << 27) /* 0.392047292 */, - /* 3414 */ 0x064673fc | (17 << 27) /* 0.392200458 */, - /* 3415 */ 0x0647149c | (17 << 27) /* 0.392353638 */, - /* 3416 */ 0x0647b53f | (17 << 27) /* 0.392506834 */, - /* 3417 */ 0x064855e6 | (17 << 27) /* 0.392660045 */, - /* 3418 */ 0x0648f691 | (17 << 27) /* 0.392813271 */, - /* 3419 */ 0x06499740 | (17 << 27) /* 0.392966511 */, - /* 3420 */ 0x064a37f4 | (17 << 27) /* 0.393119767 */, - /* 3421 */ 0x064ad8ab | (17 << 27) /* 0.393273038 */, - /* 3422 */ 0x064b7966 | (17 << 27) /* 0.393426323 */, - /* 3423 */ 0x064c1a25 | (17 << 27) /* 0.393579623 */, - - /* 3424 */ 0x064cbae9 | (17 << 27) /* 0.393732939 */, - /* 3425 */ 0x064d5bb0 | (17 << 27) /* 0.393886269 */, - /* 3426 */ 0x064dfc7b | (17 << 27) /* 0.394039614 */, - /* 3427 */ 0x064e9d4b | (17 << 27) /* 0.394192974 */, - /* 3428 */ 0x064f3e1e | (17 << 27) /* 0.394346349 */, - /* 3429 */ 0x064fdef5 | (17 << 27) /* 0.394499739 */, - /* 3430 */ 0x06507fd0 | (17 << 27) /* 0.394653144 */, - /* 3431 */ 0x065120b0 | (17 << 27) /* 0.394806564 */, - /* 3432 */ 0x0651c193 | (17 << 27) /* 0.394959999 */, - /* 3433 */ 0x0652627a | (17 << 27) /* 0.395113448 */, - /* 3434 */ 0x06530366 | (17 << 27) /* 0.395266913 */, - /* 3435 */ 0x0653a455 | (17 << 27) /* 0.395420392 */, - /* 3436 */ 0x06544548 | (17 << 27) /* 0.395573886 */, - /* 3437 */ 0x0654e640 | (17 << 27) /* 0.395727395 */, - /* 3438 */ 0x0655873b | (17 << 27) /* 0.395880919 */, - /* 3439 */ 0x0656283a | (17 << 27) /* 0.396034458 */, - - /* 3440 */ 0x0656c93d | (17 << 27) /* 0.396188012 */, - /* 3441 */ 0x06576a45 | (17 << 27) /* 0.396341581 */, - /* 3442 */ 0x06580b50 | (17 << 27) /* 0.396495164 */, - /* 3443 */ 0x0658ac5f | (17 << 27) /* 0.396648763 */, - /* 3444 */ 0x06594d73 | (17 << 27) /* 0.396802376 */, - /* 3445 */ 0x0659ee8a | (17 << 27) /* 0.396956004 */, - /* 3446 */ 0x065a8fa5 | (17 << 27) /* 0.397109647 */, - /* 3447 */ 0x065b30c4 | (17 << 27) /* 0.397263305 */, - /* 3448 */ 0x065bd1e7 | (17 << 27) /* 0.397416978 */, - /* 3449 */ 0x065c730f | (17 << 27) /* 0.397570666 */, - /* 3450 */ 0x065d143a | (17 << 27) /* 0.397724368 */, - /* 3451 */ 0x065db569 | (17 << 27) /* 0.397878085 */, - /* 3452 */ 0x065e569c | (17 << 27) /* 0.398031818 */, - /* 3453 */ 0x065ef7d3 | (17 << 27) /* 0.398185565 */, - /* 3454 */ 0x065f990e | (17 << 27) /* 0.398339326 */, - /* 3455 */ 0x06603a4e | (17 << 27) /* 0.398493103 */, - - /* 3456 */ 0x0660db91 | (17 << 27) /* 0.398646895 */, - /* 3457 */ 0x06617cd8 | (17 << 27) /* 0.398800701 */, - /* 3458 */ 0x06621e23 | (17 << 27) /* 0.398954522 */, - /* 3459 */ 0x0662bf72 | (17 << 27) /* 0.399108358 */, - /* 3460 */ 0x066360c5 | (17 << 27) /* 0.399262209 */, - /* 3461 */ 0x0664021c | (17 << 27) /* 0.399416075 */, - /* 3462 */ 0x0664a377 | (17 << 27) /* 0.399569955 */, - /* 3463 */ 0x066544d6 | (17 << 27) /* 0.399723851 */, - /* 3464 */ 0x0665e639 | (17 << 27) /* 0.399877761 */, - /* 3465 */ 0x066687a0 | (17 << 27) /* 0.400031686 */, - /* 3466 */ 0x0667290b | (17 << 27) /* 0.400185625 */, - /* 3467 */ 0x0667ca79 | (17 << 27) /* 0.400339580 */, - /* 3468 */ 0x06686bec | (17 << 27) /* 0.400493549 */, - /* 3469 */ 0x06690d63 | (17 << 27) /* 0.400647534 */, - /* 3470 */ 0x0669aede | (17 << 27) /* 0.400801533 */, - /* 3471 */ 0x066a505d | (17 << 27) /* 0.400955546 */, - - /* 3472 */ 0x066af1df | (17 << 27) /* 0.401109575 */, - /* 3473 */ 0x066b9366 | (17 << 27) /* 0.401263618 */, - /* 3474 */ 0x066c34f1 | (17 << 27) /* 0.401417676 */, - /* 3475 */ 0x066cd67f | (17 << 27) /* 0.401571749 */, - /* 3476 */ 0x066d7812 | (17 << 27) /* 0.401725837 */, - /* 3477 */ 0x066e19a9 | (17 << 27) /* 0.401879939 */, - /* 3478 */ 0x066ebb43 | (17 << 27) /* 0.402034056 */, - /* 3479 */ 0x066f5ce2 | (17 << 27) /* 0.402188188 */, - /* 3480 */ 0x066ffe84 | (17 << 27) /* 0.402342335 */, - /* 3481 */ 0x0670a02a | (17 << 27) /* 0.402496497 */, - /* 3482 */ 0x067141d5 | (17 << 27) /* 0.402650673 */, - /* 3483 */ 0x0671e383 | (17 << 27) /* 0.402804864 */, - /* 3484 */ 0x06728535 | (17 << 27) /* 0.402959070 */, - /* 3485 */ 0x067326ec | (17 << 27) /* 0.403113291 */, - /* 3486 */ 0x0673c8a6 | (17 << 27) /* 0.403267526 */, - /* 3487 */ 0x06746a64 | (17 << 27) /* 0.403421776 */, - - /* 3488 */ 0x06750c26 | (17 << 27) /* 0.403576041 */, - /* 3489 */ 0x0675adec | (17 << 27) /* 0.403730320 */, - /* 3490 */ 0x06764fb6 | (17 << 27) /* 0.403884615 */, - /* 3491 */ 0x0676f184 | (17 << 27) /* 0.404038924 */, - /* 3492 */ 0x06779356 | (17 << 27) /* 0.404193247 */, - /* 3493 */ 0x0678352c | (17 << 27) /* 0.404347586 */, - /* 3494 */ 0x0678d706 | (17 << 27) /* 0.404501939 */, - /* 3495 */ 0x067978e4 | (17 << 27) /* 0.404656307 */, - /* 3496 */ 0x067a1ac6 | (17 << 27) /* 0.404810690 */, - /* 3497 */ 0x067abcac | (17 << 27) /* 0.404965087 */, - /* 3498 */ 0x067b5e95 | (17 << 27) /* 0.405119499 */, - /* 3499 */ 0x067c0083 | (17 << 27) /* 0.405273926 */, - /* 3500 */ 0x067ca275 | (17 << 27) /* 0.405428368 */, - /* 3501 */ 0x067d446a | (17 << 27) /* 0.405582824 */, - /* 3502 */ 0x067de664 | (17 << 27) /* 0.405737295 */, - /* 3503 */ 0x067e8861 | (17 << 27) /* 0.405891781 */, - - /* 3504 */ 0x067f2a62 | (17 << 27) /* 0.406046281 */, - /* 3505 */ 0x067fcc68 | (17 << 27) /* 0.406200796 */, - /* 3506 */ 0x06806e71 | (17 << 27) /* 0.406355326 */, - /* 3507 */ 0x0681107e | (17 << 27) /* 0.406509870 */, - /* 3508 */ 0x0681b28f | (17 << 27) /* 0.406664429 */, - /* 3509 */ 0x068254a4 | (17 << 27) /* 0.406819003 */, - /* 3510 */ 0x0682f6bd | (17 << 27) /* 0.406973592 */, - /* 3511 */ 0x068398da | (17 << 27) /* 0.407128195 */, - /* 3512 */ 0x06843afb | (17 << 27) /* 0.407282813 */, - /* 3513 */ 0x0684dd20 | (17 << 27) /* 0.407437445 */, - /* 3514 */ 0x06857f49 | (17 << 27) /* 0.407592093 */, - /* 3515 */ 0x06862176 | (17 << 27) /* 0.407746754 */, - /* 3516 */ 0x0686c3a6 | (17 << 27) /* 0.407901431 */, - /* 3517 */ 0x068765db | (17 << 27) /* 0.408056122 */, - /* 3518 */ 0x06880814 | (17 << 27) /* 0.408210828 */, - /* 3519 */ 0x0688aa50 | (17 << 27) /* 0.408365549 */, - - /* 3520 */ 0x06894c90 | (17 << 27) /* 0.408520284 */, - /* 3521 */ 0x0689eed5 | (17 << 27) /* 0.408675034 */, - /* 3522 */ 0x068a911d | (17 << 27) /* 0.408829798 */, - /* 3523 */ 0x068b3369 | (17 << 27) /* 0.408984577 */, - /* 3524 */ 0x068bd5b9 | (17 << 27) /* 0.409139371 */, - /* 3525 */ 0x068c780e | (17 << 27) /* 0.409294180 */, - /* 3526 */ 0x068d1a66 | (17 << 27) /* 0.409449003 */, - /* 3527 */ 0x068dbcc1 | (17 << 27) /* 0.409603840 */, - /* 3528 */ 0x068e5f21 | (17 << 27) /* 0.409758693 */, - /* 3529 */ 0x068f0185 | (17 << 27) /* 0.409913560 */, - /* 3530 */ 0x068fa3ed | (17 << 27) /* 0.410068441 */, - /* 3531 */ 0x06904658 | (17 << 27) /* 0.410223338 */, - /* 3532 */ 0x0690e8c8 | (17 << 27) /* 0.410378249 */, - /* 3533 */ 0x06918b3c | (17 << 27) /* 0.410533174 */, - /* 3534 */ 0x06922db3 | (17 << 27) /* 0.410688114 */, - /* 3535 */ 0x0692d02e | (17 << 27) /* 0.410843069 */, - - /* 3536 */ 0x069372ae | (17 << 27) /* 0.410998038 */, - /* 3537 */ 0x06941531 | (17 << 27) /* 0.411153022 */, - /* 3538 */ 0x0694b7b8 | (17 << 27) /* 0.411308021 */, - /* 3539 */ 0x06955a43 | (17 << 27) /* 0.411463034 */, - /* 3540 */ 0x0695fcd2 | (17 << 27) /* 0.411618062 */, - /* 3541 */ 0x06969f65 | (17 << 27) /* 0.411773104 */, - /* 3542 */ 0x069741fb | (17 << 27) /* 0.411928161 */, - /* 3543 */ 0x0697e496 | (17 << 27) /* 0.412083232 */, - /* 3544 */ 0x06988735 | (17 << 27) /* 0.412238319 */, - /* 3545 */ 0x069929d7 | (17 << 27) /* 0.412393419 */, - /* 3546 */ 0x0699cc7e | (17 << 27) /* 0.412548535 */, - /* 3547 */ 0x069a6f28 | (17 << 27) /* 0.412703664 */, - /* 3548 */ 0x069b11d6 | (17 << 27) /* 0.412858809 */, - /* 3549 */ 0x069bb489 | (17 << 27) /* 0.413013968 */, - /* 3550 */ 0x069c573f | (17 << 27) /* 0.413169142 */, - /* 3551 */ 0x069cf9f9 | (17 << 27) /* 0.413324330 */, - - /* 3552 */ 0x069d9cb7 | (17 << 27) /* 0.413479532 */, - /* 3553 */ 0x069e3f78 | (17 << 27) /* 0.413634750 */, - /* 3554 */ 0x069ee23e | (17 << 27) /* 0.413789982 */, - /* 3555 */ 0x069f8508 | (17 << 27) /* 0.413945228 */, - /* 3556 */ 0x06a027d5 | (17 << 27) /* 0.414100489 */, - /* 3557 */ 0x06a0caa7 | (17 << 27) /* 0.414255765 */, - /* 3558 */ 0x06a16d7c | (17 << 27) /* 0.414411055 */, - /* 3559 */ 0x06a21055 | (17 << 27) /* 0.414566359 */, - /* 3560 */ 0x06a2b333 | (17 << 27) /* 0.414721679 */, - /* 3561 */ 0x06a35614 | (17 << 27) /* 0.414877012 */, - /* 3562 */ 0x06a3f8f9 | (17 << 27) /* 0.415032361 */, - /* 3563 */ 0x06a49be2 | (17 << 27) /* 0.415187723 */, - /* 3564 */ 0x06a53ece | (17 << 27) /* 0.415343101 */, - /* 3565 */ 0x06a5e1bf | (17 << 27) /* 0.415498493 */, - /* 3566 */ 0x06a684b4 | (17 << 27) /* 0.415653899 */, - /* 3567 */ 0x06a727ac | (17 << 27) /* 0.415809320 */, - - /* 3568 */ 0x06a7caa9 | (17 << 27) /* 0.415964756 */, - /* 3569 */ 0x06a86da9 | (17 << 27) /* 0.416120206 */, - /* 3570 */ 0x06a910ad | (17 << 27) /* 0.416275670 */, - /* 3571 */ 0x06a9b3b5 | (17 << 27) /* 0.416431149 */, - /* 3572 */ 0x06aa56c1 | (17 << 27) /* 0.416586643 */, - /* 3573 */ 0x06aaf9d1 | (17 << 27) /* 0.416742151 */, - /* 3574 */ 0x06ab9ce5 | (17 << 27) /* 0.416897673 */, - /* 3575 */ 0x06ac3ffc | (17 << 27) /* 0.417053210 */, - /* 3576 */ 0x06ace318 | (17 << 27) /* 0.417208762 */, - /* 3577 */ 0x06ad8637 | (17 << 27) /* 0.417364328 */, - /* 3578 */ 0x06ae295b | (17 << 27) /* 0.417519909 */, - /* 3579 */ 0x06aecc82 | (17 << 27) /* 0.417675504 */, - /* 3580 */ 0x06af6fad | (17 << 27) /* 0.417831113 */, - /* 3581 */ 0x06b012dc | (17 << 27) /* 0.417986737 */, - /* 3582 */ 0x06b0b60f | (17 << 27) /* 0.418142376 */, - /* 3583 */ 0x06b15946 | (17 << 27) /* 0.418298029 */, - - /* 3584 */ 0x06b1fc81 | (17 << 27) /* 0.418453696 */, - /* 3585 */ 0x06b29fbf | (17 << 27) /* 0.418609378 */, - /* 3586 */ 0x06b34302 | (17 << 27) /* 0.418765075 */, - /* 3587 */ 0x06b3e648 | (17 << 27) /* 0.418920786 */, - /* 3588 */ 0x06b48992 | (17 << 27) /* 0.419076511 */, - /* 3589 */ 0x06b52ce0 | (17 << 27) /* 0.419232251 */, - /* 3590 */ 0x06b5d032 | (17 << 27) /* 0.419388005 */, - /* 3591 */ 0x06b67388 | (17 << 27) /* 0.419543774 */, - /* 3592 */ 0x06b716e2 | (17 << 27) /* 0.419699557 */, - /* 3593 */ 0x06b7ba3f | (17 << 27) /* 0.419855355 */, - /* 3594 */ 0x06b85da1 | (17 << 27) /* 0.420011167 */, - /* 3595 */ 0x06b90106 | (17 << 27) /* 0.420166994 */, - /* 3596 */ 0x06b9a470 | (17 << 27) /* 0.420322835 */, - /* 3597 */ 0x06ba47dd | (17 << 27) /* 0.420478690 */, - /* 3598 */ 0x06baeb4e | (17 << 27) /* 0.420634560 */, - /* 3599 */ 0x06bb8ec3 | (17 << 27) /* 0.420790445 */, - - /* 3600 */ 0x06bc323b | (17 << 27) /* 0.420946343 */, - /* 3601 */ 0x06bcd5b8 | (17 << 27) /* 0.421102257 */, - /* 3602 */ 0x06bd7939 | (17 << 27) /* 0.421258184 */, - /* 3603 */ 0x06be1cbd | (17 << 27) /* 0.421414127 */, - /* 3604 */ 0x06bec045 | (17 << 27) /* 0.421570083 */, - /* 3605 */ 0x06bf63d1 | (17 << 27) /* 0.421726054 */, - /* 3606 */ 0x06c00761 | (17 << 27) /* 0.421882040 */, - /* 3607 */ 0x06c0aaf5 | (17 << 27) /* 0.422038039 */, - /* 3608 */ 0x06c14e8d | (17 << 27) /* 0.422194054 */, - /* 3609 */ 0x06c1f229 | (17 << 27) /* 0.422350082 */, - /* 3610 */ 0x06c295c8 | (17 << 27) /* 0.422506125 */, - /* 3611 */ 0x06c3396c | (17 << 27) /* 0.422662183 */, - /* 3612 */ 0x06c3dd13 | (17 << 27) /* 0.422818255 */, - /* 3613 */ 0x06c480be | (17 << 27) /* 0.422974341 */, - /* 3614 */ 0x06c5246d | (17 << 27) /* 0.423130442 */, - /* 3615 */ 0x06c5c820 | (17 << 27) /* 0.423286557 */, - - /* 3616 */ 0x06c66bd6 | (17 << 27) /* 0.423442686 */, - /* 3617 */ 0x06c70f91 | (17 << 27) /* 0.423598830 */, - /* 3618 */ 0x06c7b34f | (17 << 27) /* 0.423754988 */, - /* 3619 */ 0x06c85712 | (17 << 27) /* 0.423911161 */, - /* 3620 */ 0x06c8fad8 | (17 << 27) /* 0.424067348 */, - /* 3621 */ 0x06c99ea2 | (17 << 27) /* 0.424223550 */, - /* 3622 */ 0x06ca4270 | (17 << 27) /* 0.424379765 */, - /* 3623 */ 0x06cae641 | (17 << 27) /* 0.424535996 */, - /* 3624 */ 0x06cb8a17 | (17 << 27) /* 0.424692240 */, - /* 3625 */ 0x06cc2df0 | (17 << 27) /* 0.424848499 */, - /* 3626 */ 0x06ccd1ce | (17 << 27) /* 0.425004772 */, - /* 3627 */ 0x06cd75af | (17 << 27) /* 0.425161060 */, - /* 3628 */ 0x06ce1994 | (17 << 27) /* 0.425317362 */, - /* 3629 */ 0x06cebd7d | (17 << 27) /* 0.425473678 */, - /* 3630 */ 0x06cf6169 | (17 << 27) /* 0.425630009 */, - /* 3631 */ 0x06d0055a | (17 << 27) /* 0.425786354 */, - - /* 3632 */ 0x06d0a94e | (17 << 27) /* 0.425942714 */, - /* 3633 */ 0x06d14d47 | (17 << 27) /* 0.426099088 */, - /* 3634 */ 0x06d1f143 | (17 << 27) /* 0.426255476 */, - /* 3635 */ 0x06d29543 | (17 << 27) /* 0.426411878 */, - /* 3636 */ 0x06d33947 | (17 << 27) /* 0.426568295 */, - /* 3637 */ 0x06d3dd4e | (17 << 27) /* 0.426724726 */, - /* 3638 */ 0x06d4815a | (17 << 27) /* 0.426881172 */, - /* 3639 */ 0x06d52569 | (17 << 27) /* 0.427037632 */, - /* 3640 */ 0x06d5c97c | (17 << 27) /* 0.427194106 */, - /* 3641 */ 0x06d66d93 | (17 << 27) /* 0.427350594 */, - /* 3642 */ 0x06d711ae | (17 << 27) /* 0.427507097 */, - /* 3643 */ 0x06d7b5cd | (17 << 27) /* 0.427663614 */, - /* 3644 */ 0x06d859f0 | (17 << 27) /* 0.427820146 */, - /* 3645 */ 0x06d8fe16 | (17 << 27) /* 0.427976692 */, - /* 3646 */ 0x06d9a240 | (17 << 27) /* 0.428133252 */, - /* 3647 */ 0x06da466f | (17 << 27) /* 0.428289826 */, - - /* 3648 */ 0x06daeaa1 | (17 << 27) /* 0.428446415 */, - /* 3649 */ 0x06db8ed6 | (17 << 27) /* 0.428603018 */, - /* 3650 */ 0x06dc3310 | (17 << 27) /* 0.428759635 */, - /* 3651 */ 0x06dcd74d | (17 << 27) /* 0.428916267 */, - /* 3652 */ 0x06dd7b8f | (17 << 27) /* 0.429072913 */, - /* 3653 */ 0x06de1fd4 | (17 << 27) /* 0.429229573 */, - /* 3654 */ 0x06dec41d | (17 << 27) /* 0.429386248 */, - /* 3655 */ 0x06df686a | (17 << 27) /* 0.429542937 */, - /* 3656 */ 0x06e00cbb | (17 << 27) /* 0.429699640 */, - /* 3657 */ 0x06e0b10f | (17 << 27) /* 0.429856357 */, - /* 3658 */ 0x06e15567 | (17 << 27) /* 0.430013089 */, - /* 3659 */ 0x06e1f9c4 | (17 << 27) /* 0.430169835 */, - /* 3660 */ 0x06e29e24 | (17 << 27) /* 0.430326595 */, - /* 3661 */ 0x06e34287 | (17 << 27) /* 0.430483370 */, - /* 3662 */ 0x06e3e6ef | (17 << 27) /* 0.430640159 */, - /* 3663 */ 0x06e48b5b | (17 << 27) /* 0.430796962 */, - - /* 3664 */ 0x06e52fca | (17 << 27) /* 0.430953779 */, - /* 3665 */ 0x06e5d43d | (17 << 27) /* 0.431110611 */, - /* 3666 */ 0x06e678b4 | (17 << 27) /* 0.431267457 */, - /* 3667 */ 0x06e71d2f | (17 << 27) /* 0.431424317 */, - /* 3668 */ 0x06e7c1ae | (17 << 27) /* 0.431581192 */, - /* 3669 */ 0x06e86630 | (17 << 27) /* 0.431738080 */, - /* 3670 */ 0x06e90ab7 | (17 << 27) /* 0.431894983 */, - /* 3671 */ 0x06e9af41 | (17 << 27) /* 0.432051900 */, - /* 3672 */ 0x06ea53cf | (17 << 27) /* 0.432208832 */, - /* 3673 */ 0x06eaf860 | (17 << 27) /* 0.432365778 */, - /* 3674 */ 0x06eb9cf6 | (17 << 27) /* 0.432522737 */, - /* 3675 */ 0x06ec418f | (17 << 27) /* 0.432679712 */, - /* 3676 */ 0x06ece62d | (17 << 27) /* 0.432836700 */, - /* 3677 */ 0x06ed8ace | (17 << 27) /* 0.432993703 */, - /* 3678 */ 0x06ee2f73 | (17 << 27) /* 0.433150720 */, - /* 3679 */ 0x06eed41b | (17 << 27) /* 0.433307751 */, - - /* 3680 */ 0x06ef78c8 | (17 << 27) /* 0.433464796 */, - /* 3681 */ 0x06f01d78 | (17 << 27) /* 0.433621856 */, - /* 3682 */ 0x06f0c22c | (17 << 27) /* 0.433778929 */, - /* 3683 */ 0x06f166e4 | (17 << 27) /* 0.433936017 */, - /* 3684 */ 0x06f20ba0 | (17 << 27) /* 0.434093120 */, - /* 3685 */ 0x06f2b060 | (17 << 27) /* 0.434250236 */, - /* 3686 */ 0x06f35523 | (17 << 27) /* 0.434407367 */, - /* 3687 */ 0x06f3f9eb | (17 << 27) /* 0.434564512 */, - /* 3688 */ 0x06f49eb6 | (17 << 27) /* 0.434721671 */, - /* 3689 */ 0x06f54385 | (17 << 27) /* 0.434878844 */, - /* 3690 */ 0x06f5e857 | (17 << 27) /* 0.435036032 */, - /* 3691 */ 0x06f68d2e | (17 << 27) /* 0.435193233 */, - /* 3692 */ 0x06f73208 | (17 << 27) /* 0.435350449 */, - /* 3693 */ 0x06f7d6e6 | (17 << 27) /* 0.435507679 */, - /* 3694 */ 0x06f87bc8 | (17 << 27) /* 0.435664924 */, - /* 3695 */ 0x06f920ae | (17 << 27) /* 0.435822182 */, - - /* 3696 */ 0x06f9c597 | (17 << 27) /* 0.435979455 */, - /* 3697 */ 0x06fa6a85 | (17 << 27) /* 0.436136741 */, - /* 3698 */ 0x06fb0f76 | (17 << 27) /* 0.436294042 */, - /* 3699 */ 0x06fbb46b | (17 << 27) /* 0.436451358 */, - /* 3700 */ 0x06fc5964 | (17 << 27) /* 0.436608687 */, - /* 3701 */ 0x06fcfe60 | (17 << 27) /* 0.436766031 */, - /* 3702 */ 0x06fda361 | (17 << 27) /* 0.436923388 */, - /* 3703 */ 0x06fe4865 | (17 << 27) /* 0.437080760 */, - /* 3704 */ 0x06feed6d | (17 << 27) /* 0.437238146 */, - /* 3705 */ 0x06ff9279 | (17 << 27) /* 0.437395547 */, - /* 3706 */ 0x07003788 | (17 << 27) /* 0.437552961 */, - /* 3707 */ 0x0700dc9c | (17 << 27) /* 0.437710389 */, - /* 3708 */ 0x070181b3 | (17 << 27) /* 0.437867832 */, - /* 3709 */ 0x070226ce | (17 << 27) /* 0.438025289 */, - /* 3710 */ 0x0702cbed | (17 << 27) /* 0.438182760 */, - /* 3711 */ 0x0703710f | (17 << 27) /* 0.438340245 */, - - /* 3712 */ 0x07041636 | (17 << 27) /* 0.438497744 */, - /* 3713 */ 0x0704bb60 | (17 << 27) /* 0.438655258 */, - /* 3714 */ 0x0705608e | (17 << 27) /* 0.438812785 */, - /* 3715 */ 0x070605c0 | (17 << 27) /* 0.438970327 */, - /* 3716 */ 0x0706aaf5 | (17 << 27) /* 0.439127883 */, - /* 3717 */ 0x0707502f | (17 << 27) /* 0.439285453 */, - /* 3718 */ 0x0707f56c | (17 << 27) /* 0.439443037 */, - /* 3719 */ 0x07089aad | (17 << 27) /* 0.439600635 */, - /* 3720 */ 0x07093ff2 | (17 << 27) /* 0.439758248 */, - /* 3721 */ 0x0709e53a | (17 << 27) /* 0.439915874 */, - /* 3722 */ 0x070a8a86 | (17 << 27) /* 0.440073515 */, - /* 3723 */ 0x070b2fd7 | (17 << 27) /* 0.440231170 */, - /* 3724 */ 0x070bd52a | (17 << 27) /* 0.440388839 */, - /* 3725 */ 0x070c7a82 | (17 << 27) /* 0.440546522 */, - /* 3726 */ 0x070d1fde | (17 << 27) /* 0.440704219 */, - /* 3727 */ 0x070dc53d | (17 << 27) /* 0.440861930 */, - - /* 3728 */ 0x070e6aa0 | (17 << 27) /* 0.441019655 */, - /* 3729 */ 0x070f1007 | (17 << 27) /* 0.441177395 */, - /* 3730 */ 0x070fb571 | (17 << 27) /* 0.441335148 */, - /* 3731 */ 0x07105ae0 | (17 << 27) /* 0.441492916 */, - /* 3732 */ 0x07110052 | (17 << 27) /* 0.441650697 */, - /* 3733 */ 0x0711a5c8 | (17 << 27) /* 0.441808493 */, - /* 3734 */ 0x07124b42 | (17 << 27) /* 0.441966303 */, - /* 3735 */ 0x0712f0bf | (17 << 27) /* 0.442124127 */, - /* 3736 */ 0x07139641 | (17 << 27) /* 0.442281965 */, - /* 3737 */ 0x07143bc6 | (17 << 27) /* 0.442439817 */, - /* 3738 */ 0x0714e14f | (17 << 27) /* 0.442597683 */, - /* 3739 */ 0x071586db | (17 << 27) /* 0.442755564 */, - /* 3740 */ 0x07162c6c | (17 << 27) /* 0.442913458 */, - /* 3741 */ 0x0716d200 | (17 << 27) /* 0.443071366 */, - /* 3742 */ 0x07177798 | (17 << 27) /* 0.443229289 */, - /* 3743 */ 0x07181d34 | (17 << 27) /* 0.443387226 */, - - /* 3744 */ 0x0718c2d3 | (17 << 27) /* 0.443545176 */, - /* 3745 */ 0x07196877 | (17 << 27) /* 0.443703141 */, - /* 3746 */ 0x071a0e1e | (17 << 27) /* 0.443861120 */, - /* 3747 */ 0x071ab3c9 | (17 << 27) /* 0.444019113 */, - /* 3748 */ 0x071b5977 | (17 << 27) /* 0.444177119 */, - /* 3749 */ 0x071bff2a | (17 << 27) /* 0.444335140 */, - /* 3750 */ 0x071ca4e0 | (17 << 27) /* 0.444493175 */, - /* 3751 */ 0x071d4a9a | (17 << 27) /* 0.444651224 */, - /* 3752 */ 0x071df058 | (17 << 27) /* 0.444809288 */, - /* 3753 */ 0x071e9619 | (17 << 27) /* 0.444967365 */, - /* 3754 */ 0x071f3bde | (17 << 27) /* 0.445125456 */, - /* 3755 */ 0x071fe1a8 | (17 << 27) /* 0.445283561 */, - /* 3756 */ 0x07208774 | (17 << 27) /* 0.445441680 */, - /* 3757 */ 0x07212d45 | (17 << 27) /* 0.445599814 */, - /* 3758 */ 0x0721d319 | (17 << 27) /* 0.445757961 */, - /* 3759 */ 0x072278f1 | (17 << 27) /* 0.445916122 */, - - /* 3760 */ 0x07231ecd | (17 << 27) /* 0.446074298 */, - /* 3761 */ 0x0723c4ad | (17 << 27) /* 0.446232487 */, - /* 3762 */ 0x07246a90 | (17 << 27) /* 0.446390690 */, - /* 3763 */ 0x07251077 | (17 << 27) /* 0.446548908 */, - /* 3764 */ 0x0725b662 | (17 << 27) /* 0.446707139 */, - /* 3765 */ 0x07265c51 | (17 << 27) /* 0.446865385 */, - /* 3766 */ 0x07270244 | (17 << 27) /* 0.447023644 */, - /* 3767 */ 0x0727a83a | (17 << 27) /* 0.447181918 */, - /* 3768 */ 0x07284e34 | (17 << 27) /* 0.447340205 */, - /* 3769 */ 0x0728f431 | (17 << 27) /* 0.447498507 */, - /* 3770 */ 0x07299a33 | (17 << 27) /* 0.447656822 */, - /* 3771 */ 0x072a4038 | (17 << 27) /* 0.447815152 */, - /* 3772 */ 0x072ae641 | (17 << 27) /* 0.447973495 */, - /* 3773 */ 0x072b8c4e | (17 << 27) /* 0.448131853 */, - /* 3774 */ 0x072c325e | (17 << 27) /* 0.448290224 */, - /* 3775 */ 0x072cd873 | (17 << 27) /* 0.448448609 */, - - /* 3776 */ 0x072d7e8b | (17 << 27) /* 0.448607009 */, - /* 3777 */ 0x072e24a7 | (17 << 27) /* 0.448765422 */, - /* 3778 */ 0x072ecac6 | (17 << 27) /* 0.448923850 */, - /* 3779 */ 0x072f70e9 | (17 << 27) /* 0.449082291 */, - /* 3780 */ 0x07301710 | (17 << 27) /* 0.449240746 */, - /* 3781 */ 0x0730bd3b | (17 << 27) /* 0.449399216 */, - /* 3782 */ 0x0731636a | (17 << 27) /* 0.449557699 */, - /* 3783 */ 0x0732099c | (17 << 27) /* 0.449716196 */, - /* 3784 */ 0x0732afd2 | (17 << 27) /* 0.449874708 */, - /* 3785 */ 0x0733560c | (17 << 27) /* 0.450033233 */, - /* 3786 */ 0x0733fc49 | (17 << 27) /* 0.450191772 */, - /* 3787 */ 0x0734a28b | (17 << 27) /* 0.450350325 */, - /* 3788 */ 0x073548d0 | (17 << 27) /* 0.450508892 */, - /* 3789 */ 0x0735ef18 | (17 << 27) /* 0.450667473 */, - /* 3790 */ 0x07369565 | (17 << 27) /* 0.450826068 */, - /* 3791 */ 0x07373bb5 | (17 << 27) /* 0.450984677 */, - - /* 3792 */ 0x0737e209 | (17 << 27) /* 0.451143300 */, - /* 3793 */ 0x07388861 | (17 << 27) /* 0.451301937 */, - /* 3794 */ 0x07392ebc | (17 << 27) /* 0.451460588 */, - /* 3795 */ 0x0739d51c | (17 << 27) /* 0.451619252 */, - /* 3796 */ 0x073a7b7f | (17 << 27) /* 0.451777931 */, - /* 3797 */ 0x073b21e5 | (17 << 27) /* 0.451936623 */, - /* 3798 */ 0x073bc850 | (17 << 27) /* 0.452095330 */, - /* 3799 */ 0x073c6ebe | (17 << 27) /* 0.452254050 */, - /* 3800 */ 0x073d1530 | (17 << 27) /* 0.452412785 */, - /* 3801 */ 0x073dbba6 | (17 << 27) /* 0.452571533 */, - /* 3802 */ 0x073e621f | (17 << 27) /* 0.452730295 */, - /* 3803 */ 0x073f089c | (17 << 27) /* 0.452889071 */, - /* 3804 */ 0x073faf1d | (17 << 27) /* 0.453047861 */, - /* 3805 */ 0x074055a2 | (17 << 27) /* 0.453206665 */, - /* 3806 */ 0x0740fc2a | (17 << 27) /* 0.453365483 */, - /* 3807 */ 0x0741a2b6 | (17 << 27) /* 0.453524315 */, - - /* 3808 */ 0x07424946 | (17 << 27) /* 0.453683161 */, - /* 3809 */ 0x0742efd9 | (17 << 27) /* 0.453842020 */, - /* 3810 */ 0x07439671 | (17 << 27) /* 0.454000894 */, - /* 3811 */ 0x07443d0c | (17 << 27) /* 0.454159781 */, - /* 3812 */ 0x0744e3aa | (17 << 27) /* 0.454318683 */, - /* 3813 */ 0x07458a4d | (17 << 27) /* 0.454477598 */, - /* 3814 */ 0x074630f3 | (17 << 27) /* 0.454636527 */, - /* 3815 */ 0x0746d79d | (17 << 27) /* 0.454795470 */, - /* 3816 */ 0x07477e4b | (17 << 27) /* 0.454954427 */, - /* 3817 */ 0x074824fc | (17 << 27) /* 0.455113397 */, - /* 3818 */ 0x0748cbb1 | (17 << 27) /* 0.455272382 */, - /* 3819 */ 0x0749726a | (17 << 27) /* 0.455431381 */, - /* 3820 */ 0x074a1927 | (17 << 27) /* 0.455590393 */, - /* 3821 */ 0x074abfe7 | (17 << 27) /* 0.455749419 */, - /* 3822 */ 0x074b66ab | (17 << 27) /* 0.455908459 */, - /* 3823 */ 0x074c0d73 | (17 << 27) /* 0.456067513 */, - - /* 3824 */ 0x074cb43e | (17 << 27) /* 0.456226581 */, - /* 3825 */ 0x074d5b0d | (17 << 27) /* 0.456385663 */, - /* 3826 */ 0x074e01e0 | (17 << 27) /* 0.456544759 */, - /* 3827 */ 0x074ea8b7 | (17 << 27) /* 0.456703868 */, - /* 3828 */ 0x074f4f91 | (17 << 27) /* 0.456862992 */, - /* 3829 */ 0x074ff66f | (17 << 27) /* 0.457022129 */, - /* 3830 */ 0x07509d51 | (17 << 27) /* 0.457181280 */, - /* 3831 */ 0x07514437 | (17 << 27) /* 0.457340445 */, - /* 3832 */ 0x0751eb20 | (17 << 27) /* 0.457499623 */, - /* 3833 */ 0x0752920d | (17 << 27) /* 0.457658816 */, - /* 3834 */ 0x075338fd | (17 << 27) /* 0.457818022 */, - /* 3835 */ 0x0753dff2 | (17 << 27) /* 0.457977243 */, - /* 3836 */ 0x075486ea | (17 << 27) /* 0.458136477 */, - /* 3837 */ 0x07552de6 | (17 << 27) /* 0.458295725 */, - /* 3838 */ 0x0755d4e5 | (17 << 27) /* 0.458454987 */, - /* 3839 */ 0x07567be8 | (17 << 27) /* 0.458614262 */, - - /* 3840 */ 0x075722ef | (17 << 27) /* 0.458773552 */, - /* 3841 */ 0x0757c9fa | (17 << 27) /* 0.458932855 */, - /* 3842 */ 0x07587108 | (17 << 27) /* 0.459092172 */, - /* 3843 */ 0x0759181a | (17 << 27) /* 0.459251503 */, - /* 3844 */ 0x0759bf30 | (17 << 27) /* 0.459410848 */, - /* 3845 */ 0x075a664a | (17 << 27) /* 0.459570206 */, - /* 3846 */ 0x075b0d67 | (17 << 27) /* 0.459729579 */, - /* 3847 */ 0x075bb488 | (17 << 27) /* 0.459888965 */, - /* 3848 */ 0x075c5bac | (17 << 27) /* 0.460048365 */, - /* 3849 */ 0x075d02d5 | (17 << 27) /* 0.460207779 */, - /* 3850 */ 0x075daa01 | (17 << 27) /* 0.460367206 */, - /* 3851 */ 0x075e5130 | (17 << 27) /* 0.460526648 */, - /* 3852 */ 0x075ef864 | (17 << 27) /* 0.460686103 */, - /* 3853 */ 0x075f9f9b | (17 << 27) /* 0.460845572 */, - /* 3854 */ 0x076046d6 | (17 << 27) /* 0.461005055 */, - /* 3855 */ 0x0760ee14 | (17 << 27) /* 0.461164552 */, - - /* 3856 */ 0x07619557 | (17 << 27) /* 0.461324062 */, - /* 3857 */ 0x07623c9d | (17 << 27) /* 0.461483586 */, - /* 3858 */ 0x0762e3e6 | (17 << 27) /* 0.461643124 */, - /* 3859 */ 0x07638b34 | (17 << 27) /* 0.461802676 */, - /* 3860 */ 0x07643285 | (17 << 27) /* 0.461962242 */, - /* 3861 */ 0x0764d9d9 | (17 << 27) /* 0.462121821 */, - /* 3862 */ 0x07658132 | (17 << 27) /* 0.462281414 */, - /* 3863 */ 0x0766288e | (17 << 27) /* 0.462441021 */, - /* 3864 */ 0x0766cfee | (17 << 27) /* 0.462600642 */, - /* 3865 */ 0x07677751 | (17 << 27) /* 0.462760276 */, - /* 3866 */ 0x07681eb9 | (17 << 27) /* 0.462919924 */, - /* 3867 */ 0x0768c624 | (17 << 27) /* 0.463079586 */, - /* 3868 */ 0x07696d92 | (17 << 27) /* 0.463239262 */, - /* 3869 */ 0x076a1505 | (17 << 27) /* 0.463398951 */, - /* 3870 */ 0x076abc7b | (17 << 27) /* 0.463558655 */, - /* 3871 */ 0x076b63f4 | (17 << 27) /* 0.463718372 */, - - /* 3872 */ 0x076c0b72 | (17 << 27) /* 0.463878102 */, - /* 3873 */ 0x076cb2f3 | (17 << 27) /* 0.464037847 */, - /* 3874 */ 0x076d5a78 | (17 << 27) /* 0.464197605 */, - /* 3875 */ 0x076e0200 | (17 << 27) /* 0.464357377 */, - /* 3876 */ 0x076ea98c | (17 << 27) /* 0.464517163 */, - /* 3877 */ 0x076f511c | (17 << 27) /* 0.464676962 */, - /* 3878 */ 0x076ff8b0 | (17 << 27) /* 0.464836776 */, - /* 3879 */ 0x0770a047 | (17 << 27) /* 0.464996603 */, - /* 3880 */ 0x077147e2 | (17 << 27) /* 0.465156443 */, - /* 3881 */ 0x0771ef80 | (17 << 27) /* 0.465316298 */, - /* 3882 */ 0x07729723 | (17 << 27) /* 0.465476166 */, - /* 3883 */ 0x07733ec9 | (17 << 27) /* 0.465636048 */, - /* 3884 */ 0x0773e672 | (17 << 27) /* 0.465795943 */, - /* 3885 */ 0x07748e20 | (17 << 27) /* 0.465955853 */, - /* 3886 */ 0x077535d1 | (17 << 27) /* 0.466115776 */, - /* 3887 */ 0x0775dd85 | (17 << 27) /* 0.466275713 */, - - /* 3888 */ 0x0776853e | (17 << 27) /* 0.466435663 */, - /* 3889 */ 0x07772cfa | (17 << 27) /* 0.466595627 */, - /* 3890 */ 0x0777d4ba | (17 << 27) /* 0.466755605 */, - /* 3891 */ 0x07787c7d | (17 << 27) /* 0.466915597 */, - /* 3892 */ 0x07792444 | (17 << 27) /* 0.467075602 */, - /* 3893 */ 0x0779cc0f | (17 << 27) /* 0.467235621 */, - /* 3894 */ 0x077a73dd | (17 << 27) /* 0.467395654 */, - /* 3895 */ 0x077b1baf | (17 << 27) /* 0.467555701 */, - /* 3896 */ 0x077bc385 | (17 << 27) /* 0.467715761 */, - /* 3897 */ 0x077c6b5f | (17 << 27) /* 0.467875835 */, - /* 3898 */ 0x077d133c | (17 << 27) /* 0.468035922 */, - /* 3899 */ 0x077dbb1d | (17 << 27) /* 0.468196023 */, - /* 3900 */ 0x077e6301 | (17 << 27) /* 0.468356138 */, - /* 3901 */ 0x077f0ae9 | (17 << 27) /* 0.468516267 */, - /* 3902 */ 0x077fb2d5 | (17 << 27) /* 0.468676409 */, - /* 3903 */ 0x07805ac5 | (17 << 27) /* 0.468836565 */, - - /* 3904 */ 0x078102b8 | (17 << 27) /* 0.468996735 */, - /* 3905 */ 0x0781aaaf | (17 << 27) /* 0.469156918 */, - /* 3906 */ 0x078252aa | (17 << 27) /* 0.469317115 */, - /* 3907 */ 0x0782faa8 | (17 << 27) /* 0.469477326 */, - /* 3908 */ 0x0783a2aa | (17 << 27) /* 0.469637550 */, - /* 3909 */ 0x07844aaf | (17 << 27) /* 0.469797788 */, - /* 3910 */ 0x0784f2b8 | (17 << 27) /* 0.469958040 */, - /* 3911 */ 0x07859ac5 | (17 << 27) /* 0.470118305 */, - /* 3912 */ 0x078642d6 | (17 << 27) /* 0.470278584 */, - /* 3913 */ 0x0786eaea | (17 << 27) /* 0.470438877 */, - /* 3914 */ 0x07879302 | (17 << 27) /* 0.470599183 */, - /* 3915 */ 0x07883b1e | (17 << 27) /* 0.470759503 */, - /* 3916 */ 0x0788e33d | (17 << 27) /* 0.470919836 */, - /* 3917 */ 0x07898b60 | (17 << 27) /* 0.471080184 */, - /* 3918 */ 0x078a3386 | (17 << 27) /* 0.471240545 */, - /* 3919 */ 0x078adbb0 | (17 << 27) /* 0.471400919 */, - - /* 3920 */ 0x078b83de | (17 << 27) /* 0.471561307 */, - /* 3921 */ 0x078c2c10 | (17 << 27) /* 0.471721709 */, - /* 3922 */ 0x078cd445 | (17 << 27) /* 0.471882125 */, - /* 3923 */ 0x078d7c7e | (17 << 27) /* 0.472042554 */, - /* 3924 */ 0x078e24ba | (17 << 27) /* 0.472202996 */, - /* 3925 */ 0x078eccfb | (17 << 27) /* 0.472363453 */, - /* 3926 */ 0x078f753e | (17 << 27) /* 0.472523923 */, - /* 3927 */ 0x07901d86 | (17 << 27) /* 0.472684406 */, - /* 3928 */ 0x0790c5d1 | (17 << 27) /* 0.472844904 */, - /* 3929 */ 0x07916e20 | (17 << 27) /* 0.473005414 */, - /* 3930 */ 0x07921672 | (17 << 27) /* 0.473165939 */, - /* 3931 */ 0x0792bec8 | (17 << 27) /* 0.473326477 */, - /* 3932 */ 0x07936722 | (17 << 27) /* 0.473487029 */, - /* 3933 */ 0x07940f80 | (17 << 27) /* 0.473647594 */, - /* 3934 */ 0x0794b7e1 | (17 << 27) /* 0.473808173 */, - /* 3935 */ 0x07956045 | (17 << 27) /* 0.473968765 */, - - /* 3936 */ 0x079608ae | (17 << 27) /* 0.474129372 */, - /* 3937 */ 0x0796b11a | (17 << 27) /* 0.474289991 */, - /* 3938 */ 0x0797598a | (17 << 27) /* 0.474450625 */, - /* 3939 */ 0x079801fd | (17 << 27) /* 0.474611272 */, - /* 3940 */ 0x0798aa74 | (17 << 27) /* 0.474771932 */, - /* 3941 */ 0x079952ee | (17 << 27) /* 0.474932606 */, - /* 3942 */ 0x0799fb6d | (17 << 27) /* 0.475093294 */, - /* 3943 */ 0x079aa3ef | (17 << 27) /* 0.475253995 */, - /* 3944 */ 0x079b4c74 | (17 << 27) /* 0.475414710 */, - /* 3945 */ 0x079bf4fd | (17 << 27) /* 0.475575439 */, - /* 3946 */ 0x079c9d8a | (17 << 27) /* 0.475736181 */, - /* 3947 */ 0x079d461b | (17 << 27) /* 0.475896936 */, - /* 3948 */ 0x079deeaf | (17 << 27) /* 0.476057705 */, - /* 3949 */ 0x079e9747 | (17 << 27) /* 0.476218488 */, - /* 3950 */ 0x079f3fe2 | (17 << 27) /* 0.476379285 */, - /* 3951 */ 0x079fe881 | (17 << 27) /* 0.476540095 */, - - /* 3952 */ 0x07a09124 | (17 << 27) /* 0.476700918 */, - /* 3953 */ 0x07a139ca | (17 << 27) /* 0.476861755 */, - /* 3954 */ 0x07a1e274 | (17 << 27) /* 0.477022606 */, - /* 3955 */ 0x07a28b22 | (17 << 27) /* 0.477183470 */, - /* 3956 */ 0x07a333d3 | (17 << 27) /* 0.477344348 */, - /* 3957 */ 0x07a3dc88 | (17 << 27) /* 0.477505239 */, - /* 3958 */ 0x07a48541 | (17 << 27) /* 0.477666144 */, - /* 3959 */ 0x07a52dfd | (17 << 27) /* 0.477827062 */, - /* 3960 */ 0x07a5d6bd | (17 << 27) /* 0.477987994 */, - /* 3961 */ 0x07a67f80 | (17 << 27) /* 0.478148940 */, - /* 3962 */ 0x07a72847 | (17 << 27) /* 0.478309899 */, - /* 3963 */ 0x07a7d112 | (17 << 27) /* 0.478470871 */, - /* 3964 */ 0x07a879e1 | (17 << 27) /* 0.478631857 */, - /* 3965 */ 0x07a922b3 | (17 << 27) /* 0.478792857 */, - /* 3966 */ 0x07a9cb88 | (17 << 27) /* 0.478953870 */, - /* 3967 */ 0x07aa7462 | (17 << 27) /* 0.479114897 */, - - /* 3968 */ 0x07ab1d3e | (17 << 27) /* 0.479275937 */, - /* 3969 */ 0x07abc61f | (17 << 27) /* 0.479436991 */, - /* 3970 */ 0x07ac6f03 | (17 << 27) /* 0.479598058 */, - /* 3971 */ 0x07ad17eb | (17 << 27) /* 0.479759139 */, - /* 3972 */ 0x07adc0d6 | (17 << 27) /* 0.479920233 */, - /* 3973 */ 0x07ae69c6 | (17 << 27) /* 0.480081341 */, - /* 3974 */ 0x07af12b8 | (17 << 27) /* 0.480242463 */, - /* 3975 */ 0x07afbbaf | (17 << 27) /* 0.480403598 */, - /* 3976 */ 0x07b064a8 | (17 << 27) /* 0.480564746 */, - /* 3977 */ 0x07b10da6 | (17 << 27) /* 0.480725908 */, - /* 3978 */ 0x07b1b6a7 | (17 << 27) /* 0.480887083 */, - /* 3979 */ 0x07b25fac | (17 << 27) /* 0.481048272 */, - /* 3980 */ 0x07b308b5 | (17 << 27) /* 0.481209475 */, - /* 3981 */ 0x07b3b1c1 | (17 << 27) /* 0.481370691 */, - /* 3982 */ 0x07b45ad0 | (17 << 27) /* 0.481531920 */, - /* 3983 */ 0x07b503e4 | (17 << 27) /* 0.481693163 */, - - /* 3984 */ 0x07b5acfb | (17 << 27) /* 0.481854420 */, - /* 3985 */ 0x07b65615 | (17 << 27) /* 0.482015690 */, - /* 3986 */ 0x07b6ff33 | (17 << 27) /* 0.482176973 */, - /* 3987 */ 0x07b7a855 | (17 << 27) /* 0.482338270 */, - /* 3988 */ 0x07b8517b | (17 << 27) /* 0.482499580 */, - /* 3989 */ 0x07b8faa4 | (17 << 27) /* 0.482660904 */, - /* 3990 */ 0x07b9a3d0 | (17 << 27) /* 0.482822242 */, - /* 3991 */ 0x07ba4d01 | (17 << 27) /* 0.482983592 */, - /* 3992 */ 0x07baf635 | (17 << 27) /* 0.483144957 */, - /* 3993 */ 0x07bb9f6c | (17 << 27) /* 0.483306335 */, - /* 3994 */ 0x07bc48a7 | (17 << 27) /* 0.483467726 */, - /* 3995 */ 0x07bcf1e6 | (17 << 27) /* 0.483629131 */, - /* 3996 */ 0x07bd9b28 | (17 << 27) /* 0.483790549 */, - /* 3997 */ 0x07be446e | (17 << 27) /* 0.483951980 */, - /* 3998 */ 0x07beedb8 | (17 << 27) /* 0.484113426 */, - /* 3999 */ 0x07bf9705 | (17 << 27) /* 0.484274884 */, - - /* 4000 */ 0x07c04056 | (17 << 27) /* 0.484436356 */, - /* 4001 */ 0x07c0e9aa | (17 << 27) /* 0.484597842 */, - /* 4002 */ 0x07c19302 | (17 << 27) /* 0.484759341 */, - /* 4003 */ 0x07c23c5e | (17 << 27) /* 0.484920853 */, - /* 4004 */ 0x07c2e5bd | (17 << 27) /* 0.485082379 */, - /* 4005 */ 0x07c38f20 | (17 << 27) /* 0.485243918 */, - /* 4006 */ 0x07c43887 | (17 << 27) /* 0.485405471 */, - /* 4007 */ 0x07c4e1f1 | (17 << 27) /* 0.485567037 */, - /* 4008 */ 0x07c58b5f | (17 << 27) /* 0.485728617 */, - /* 4009 */ 0x07c634d0 | (17 << 27) /* 0.485890210 */, - /* 4010 */ 0x07c6de45 | (17 << 27) /* 0.486051817 */, - /* 4011 */ 0x07c787bd | (17 << 27) /* 0.486213436 */, - /* 4012 */ 0x07c83139 | (17 << 27) /* 0.486375070 */, - /* 4013 */ 0x07c8dab9 | (17 << 27) /* 0.486536717 */, - /* 4014 */ 0x07c9843c | (17 << 27) /* 0.486698377 */, - /* 4015 */ 0x07ca2dc3 | (17 << 27) /* 0.486860051 */, - - /* 4016 */ 0x07cad74e | (17 << 27) /* 0.487021738 */, - /* 4017 */ 0x07cb80dc | (17 << 27) /* 0.487183438 */, - /* 4018 */ 0x07cc2a6e | (17 << 27) /* 0.487345152 */, - /* 4019 */ 0x07ccd403 | (17 << 27) /* 0.487506879 */, - /* 4020 */ 0x07cd7d9c | (17 << 27) /* 0.487668620 */, - /* 4021 */ 0x07ce2739 | (17 << 27) /* 0.487830374 */, - /* 4022 */ 0x07ced0d9 | (17 << 27) /* 0.487992142 */, - /* 4023 */ 0x07cf7a7d | (17 << 27) /* 0.488153923 */, - /* 4024 */ 0x07d02424 | (17 << 27) /* 0.488315717 */, - /* 4025 */ 0x07d0cdcf | (17 << 27) /* 0.488477525 */, - /* 4026 */ 0x07d1777e | (17 << 27) /* 0.488639346 */, - /* 4027 */ 0x07d22130 | (17 << 27) /* 0.488801181 */, - /* 4028 */ 0x07d2cae5 | (17 << 27) /* 0.488963029 */, - /* 4029 */ 0x07d3749f | (17 << 27) /* 0.489124890 */, - /* 4030 */ 0x07d41e5c | (17 << 27) /* 0.489286765 */, - /* 4031 */ 0x07d4c81c | (17 << 27) /* 0.489448653 */, - - /* 4032 */ 0x07d571e0 | (17 << 27) /* 0.489610555 */, - /* 4033 */ 0x07d61ba8 | (17 << 27) /* 0.489772470 */, - /* 4034 */ 0x07d6c573 | (17 << 27) /* 0.489934398 */, - /* 4035 */ 0x07d76f42 | (17 << 27) /* 0.490096340 */, - /* 4036 */ 0x07d81915 | (17 << 27) /* 0.490258295 */, - /* 4037 */ 0x07d8c2eb | (17 << 27) /* 0.490420263 */, - /* 4038 */ 0x07d96cc4 | (17 << 27) /* 0.490582245 */, - /* 4039 */ 0x07da16a2 | (17 << 27) /* 0.490744240 */, - /* 4040 */ 0x07dac083 | (17 << 27) /* 0.490906249 */, - /* 4041 */ 0x07db6a67 | (17 << 27) /* 0.491068271 */, - /* 4042 */ 0x07dc144f | (17 << 27) /* 0.491230306 */, - /* 4043 */ 0x07dcbe3b | (17 << 27) /* 0.491392355 */, - /* 4044 */ 0x07dd682a | (17 << 27) /* 0.491554417 */, - /* 4045 */ 0x07de121d | (17 << 27) /* 0.491716492 */, - /* 4046 */ 0x07debc13 | (17 << 27) /* 0.491878581 */, - /* 4047 */ 0x07df660d | (17 << 27) /* 0.492040683 */, - - /* 4048 */ 0x07e0100a | (17 << 27) /* 0.492202799 */, - /* 4049 */ 0x07e0ba0c | (17 << 27) /* 0.492364928 */, - /* 4050 */ 0x07e16410 | (17 << 27) /* 0.492527070 */, - /* 4051 */ 0x07e20e19 | (17 << 27) /* 0.492689225 */, - /* 4052 */ 0x07e2b824 | (17 << 27) /* 0.492851394 */, - /* 4053 */ 0x07e36234 | (17 << 27) /* 0.493013576 */, - /* 4054 */ 0x07e40c47 | (17 << 27) /* 0.493175772 */, - /* 4055 */ 0x07e4b65e | (17 << 27) /* 0.493337981 */, - /* 4056 */ 0x07e56078 | (17 << 27) /* 0.493500203 */, - /* 4057 */ 0x07e60a95 | (17 << 27) /* 0.493662438 */, - /* 4058 */ 0x07e6b4b7 | (17 << 27) /* 0.493824687 */, - /* 4059 */ 0x07e75edc | (17 << 27) /* 0.493986949 */, - /* 4060 */ 0x07e80904 | (17 << 27) /* 0.494149225 */, - /* 4061 */ 0x07e8b330 | (17 << 27) /* 0.494311514 */, - /* 4062 */ 0x07e95d60 | (17 << 27) /* 0.494473816 */, - /* 4063 */ 0x07ea0793 | (17 << 27) /* 0.494636131 */, - - /* 4064 */ 0x07eab1ca | (17 << 27) /* 0.494798460 */, - /* 4065 */ 0x07eb5c04 | (17 << 27) /* 0.494960802 */, - /* 4066 */ 0x07ec0642 | (17 << 27) /* 0.495123158 */, - /* 4067 */ 0x07ecb084 | (17 << 27) /* 0.495285526 */, - /* 4068 */ 0x07ed5ac9 | (17 << 27) /* 0.495447908 */, - /* 4069 */ 0x07ee0512 | (17 << 27) /* 0.495610304 */, - /* 4070 */ 0x07eeaf5e | (17 << 27) /* 0.495772712 */, - /* 4071 */ 0x07ef59ae | (17 << 27) /* 0.495935134 */, - /* 4072 */ 0x07f00401 | (17 << 27) /* 0.496097570 */, - /* 4073 */ 0x07f0ae58 | (17 << 27) /* 0.496260018 */, - /* 4074 */ 0x07f158b3 | (17 << 27) /* 0.496422480 */, - /* 4075 */ 0x07f20311 | (17 << 27) /* 0.496584955 */, - /* 4076 */ 0x07f2ad72 | (17 << 27) /* 0.496747444 */, - /* 4077 */ 0x07f357d8 | (17 << 27) /* 0.496909945 */, - /* 4078 */ 0x07f40240 | (17 << 27) /* 0.497072460 */, - /* 4079 */ 0x07f4acad | (17 << 27) /* 0.497234989 */, - - /* 4080 */ 0x07f5571d | (17 << 27) /* 0.497397530 */, - /* 4081 */ 0x07f60190 | (17 << 27) /* 0.497560085 */, - /* 4082 */ 0x07f6ac07 | (17 << 27) /* 0.497722653 */, - /* 4083 */ 0x07f75682 | (17 << 27) /* 0.497885235 */, - /* 4084 */ 0x07f80100 | (17 << 27) /* 0.498047829 */, - /* 4085 */ 0x07f8ab82 | (17 << 27) /* 0.498210437 */, - /* 4086 */ 0x07f95607 | (17 << 27) /* 0.498373058 */, - /* 4087 */ 0x07fa0090 | (17 << 27) /* 0.498535693 */, - /* 4088 */ 0x07faab1c | (17 << 27) /* 0.498698341 */, - /* 4089 */ 0x07fb55ac | (17 << 27) /* 0.498861002 */, - /* 4090 */ 0x07fc0040 | (17 << 27) /* 0.499023676 */, - /* 4091 */ 0x07fcaad7 | (17 << 27) /* 0.499186364 */, - /* 4092 */ 0x07fd5572 | (17 << 27) /* 0.499349064 */, - /* 4093 */ 0x07fe0010 | (17 << 27) /* 0.499511778 */, - /* 4094 */ 0x07feaab2 | (17 << 27) /* 0.499674506 */, - /* 4095 */ 0x07ff5557 | (17 << 27) /* 0.499837246 */, - - /* 4096 */ 0x04000000 | (18 << 27) /* 0.250000000 */, - /* 4097 */ 0x04005556 | (18 << 27) /* 0.250081384 */, - /* 4098 */ 0x0400aaae | (18 << 27) /* 0.250162774 */, - /* 4099 */ 0x04010008 | (18 << 27) /* 0.250244170 */, - /* 4100 */ 0x04015563 | (18 << 27) /* 0.250325574 */, - /* 4101 */ 0x0401aac1 | (18 << 27) /* 0.250406984 */, - /* 4102 */ 0x04020020 | (18 << 27) /* 0.250488400 */, - /* 4103 */ 0x04025581 | (18 << 27) /* 0.250569824 */, - /* 4104 */ 0x0402aae3 | (18 << 27) /* 0.250651254 */, - /* 4105 */ 0x04030048 | (18 << 27) /* 0.250732690 */, - /* 4106 */ 0x040355ae | (18 << 27) /* 0.250814133 */, - /* 4107 */ 0x0403ab16 | (18 << 27) /* 0.250895583 */, - /* 4108 */ 0x04040080 | (18 << 27) /* 0.250977039 */, - /* 4109 */ 0x040455eb | (18 << 27) /* 0.251058502 */, - /* 4110 */ 0x0404ab59 | (18 << 27) /* 0.251139971 */, - /* 4111 */ 0x040500c8 | (18 << 27) /* 0.251221448 */, - - /* 4112 */ 0x04055638 | (18 << 27) /* 0.251302930 */, - /* 4113 */ 0x0405abab | (18 << 27) /* 0.251384420 */, - /* 4114 */ 0x0406011f | (18 << 27) /* 0.251465916 */, - /* 4115 */ 0x04065696 | (18 << 27) /* 0.251547418 */, - /* 4116 */ 0x0406ac0e | (18 << 27) /* 0.251628927 */, - /* 4117 */ 0x04070187 | (18 << 27) /* 0.251710443 */, - /* 4118 */ 0x04075703 | (18 << 27) /* 0.251791965 */, - /* 4119 */ 0x0407ac80 | (18 << 27) /* 0.251873494 */, - /* 4120 */ 0x040801ff | (18 << 27) /* 0.251955030 */, - /* 4121 */ 0x04085780 | (18 << 27) /* 0.252036572 */, - /* 4122 */ 0x0408ad02 | (18 << 27) /* 0.252118121 */, - /* 4123 */ 0x04090287 | (18 << 27) /* 0.252199676 */, - /* 4124 */ 0x0409580d | (18 << 27) /* 0.252281238 */, - /* 4125 */ 0x0409ad95 | (18 << 27) /* 0.252362807 */, - /* 4126 */ 0x040a031e | (18 << 27) /* 0.252444382 */, - /* 4127 */ 0x040a58aa | (18 << 27) /* 0.252525963 */, - - /* 4128 */ 0x040aae37 | (18 << 27) /* 0.252607552 */, - /* 4129 */ 0x040b03c6 | (18 << 27) /* 0.252689147 */, - /* 4130 */ 0x040b5957 | (18 << 27) /* 0.252770748 */, - /* 4131 */ 0x040baee9 | (18 << 27) /* 0.252852356 */, - /* 4132 */ 0x040c047e | (18 << 27) /* 0.252933971 */, - /* 4133 */ 0x040c5a14 | (18 << 27) /* 0.253015592 */, - /* 4134 */ 0x040cafab | (18 << 27) /* 0.253097220 */, - /* 4135 */ 0x040d0545 | (18 << 27) /* 0.253178854 */, - /* 4136 */ 0x040d5ae0 | (18 << 27) /* 0.253260495 */, - /* 4137 */ 0x040db07d | (18 << 27) /* 0.253342143 */, - /* 4138 */ 0x040e061c | (18 << 27) /* 0.253423797 */, - /* 4139 */ 0x040e5bbd | (18 << 27) /* 0.253505457 */, - /* 4140 */ 0x040eb15f | (18 << 27) /* 0.253587125 */, - /* 4141 */ 0x040f0703 | (18 << 27) /* 0.253668799 */, - /* 4142 */ 0x040f5ca9 | (18 << 27) /* 0.253750479 */, - /* 4143 */ 0x040fb251 | (18 << 27) /* 0.253832166 */, - - /* 4144 */ 0x041007fa | (18 << 27) /* 0.253913860 */, - /* 4145 */ 0x04105da6 | (18 << 27) /* 0.253995560 */, - /* 4146 */ 0x0410b353 | (18 << 27) /* 0.254077266 */, - /* 4147 */ 0x04110901 | (18 << 27) /* 0.254158980 */, - /* 4148 */ 0x04115eb2 | (18 << 27) /* 0.254240700 */, - /* 4149 */ 0x0411b464 | (18 << 27) /* 0.254322426 */, - /* 4150 */ 0x04120a18 | (18 << 27) /* 0.254404159 */, - /* 4151 */ 0x04125fce | (18 << 27) /* 0.254485899 */, - /* 4152 */ 0x0412b586 | (18 << 27) /* 0.254567645 */, - /* 4153 */ 0x04130b3f | (18 << 27) /* 0.254649397 */, - /* 4154 */ 0x041360fa | (18 << 27) /* 0.254731157 */, - /* 4155 */ 0x0413b6b7 | (18 << 27) /* 0.254812922 */, - /* 4156 */ 0x04140c75 | (18 << 27) /* 0.254894695 */, - /* 4157 */ 0x04146236 | (18 << 27) /* 0.254976474 */, - /* 4158 */ 0x0414b7f8 | (18 << 27) /* 0.255058259 */, - /* 4159 */ 0x04150dbc | (18 << 27) /* 0.255140051 */, - - /* 4160 */ 0x04156381 | (18 << 27) /* 0.255221850 */, - /* 4161 */ 0x0415b949 | (18 << 27) /* 0.255303655 */, - /* 4162 */ 0x04160f12 | (18 << 27) /* 0.255385467 */, - /* 4163 */ 0x041664dd | (18 << 27) /* 0.255467285 */, - /* 4164 */ 0x0416baaa | (18 << 27) /* 0.255549110 */, - /* 4165 */ 0x04171078 | (18 << 27) /* 0.255630941 */, - /* 4166 */ 0x04176648 | (18 << 27) /* 0.255712779 */, - /* 4167 */ 0x0417bc1a | (18 << 27) /* 0.255794624 */, - /* 4168 */ 0x041811ee | (18 << 27) /* 0.255876475 */, - /* 4169 */ 0x041867c3 | (18 << 27) /* 0.255958332 */, - /* 4170 */ 0x0418bd9b | (18 << 27) /* 0.256040196 */, - /* 4171 */ 0x04191374 | (18 << 27) /* 0.256122067 */, - /* 4172 */ 0x0419694e | (18 << 27) /* 0.256203944 */, - /* 4173 */ 0x0419bf2b | (18 << 27) /* 0.256285828 */, - /* 4174 */ 0x041a1509 | (18 << 27) /* 0.256367718 */, - /* 4175 */ 0x041a6ae9 | (18 << 27) /* 0.256449615 */, - - /* 4176 */ 0x041ac0cb | (18 << 27) /* 0.256531518 */, - /* 4177 */ 0x041b16ae | (18 << 27) /* 0.256613428 */, - /* 4178 */ 0x041b6c94 | (18 << 27) /* 0.256695344 */, - /* 4179 */ 0x041bc27b | (18 << 27) /* 0.256777267 */, - /* 4180 */ 0x041c1863 | (18 << 27) /* 0.256859197 */, - /* 4181 */ 0x041c6e4e | (18 << 27) /* 0.256941133 */, - /* 4182 */ 0x041cc43a | (18 << 27) /* 0.257023076 */, - /* 4183 */ 0x041d1a28 | (18 << 27) /* 0.257105025 */, - /* 4184 */ 0x041d7018 | (18 << 27) /* 0.257186980 */, - /* 4185 */ 0x041dc60a | (18 << 27) /* 0.257268942 */, - /* 4186 */ 0x041e1bfd | (18 << 27) /* 0.257350911 */, - /* 4187 */ 0x041e71f2 | (18 << 27) /* 0.257432886 */, - /* 4188 */ 0x041ec7e9 | (18 << 27) /* 0.257514868 */, - /* 4189 */ 0x041f1de1 | (18 << 27) /* 0.257596856 */, - /* 4190 */ 0x041f73dc | (18 << 27) /* 0.257678851 */, - /* 4191 */ 0x041fc9d8 | (18 << 27) /* 0.257760852 */, - - /* 4192 */ 0x04201fd5 | (18 << 27) /* 0.257842860 */, - /* 4193 */ 0x042075d5 | (18 << 27) /* 0.257924875 */, - /* 4194 */ 0x0420cbd6 | (18 << 27) /* 0.258006895 */, - /* 4195 */ 0x042121d9 | (18 << 27) /* 0.258088923 */, - /* 4196 */ 0x042177de | (18 << 27) /* 0.258170957 */, - /* 4197 */ 0x0421cde5 | (18 << 27) /* 0.258252997 */, - /* 4198 */ 0x042223ed | (18 << 27) /* 0.258335044 */, - /* 4199 */ 0x042279f7 | (18 << 27) /* 0.258417097 */, - /* 4200 */ 0x0422d003 | (18 << 27) /* 0.258499157 */, - /* 4201 */ 0x04232611 | (18 << 27) /* 0.258581224 */, - /* 4202 */ 0x04237c20 | (18 << 27) /* 0.258663297 */, - /* 4203 */ 0x0423d231 | (18 << 27) /* 0.258745376 */, - /* 4204 */ 0x04242844 | (18 << 27) /* 0.258827462 */, - /* 4205 */ 0x04247e58 | (18 << 27) /* 0.258909555 */, - /* 4206 */ 0x0424d46e | (18 << 27) /* 0.258991654 */, - /* 4207 */ 0x04252a87 | (18 << 27) /* 0.259073760 */, - - /* 4208 */ 0x042580a0 | (18 << 27) /* 0.259155872 */, - /* 4209 */ 0x0425d6bc | (18 << 27) /* 0.259237990 */, - /* 4210 */ 0x04262cd9 | (18 << 27) /* 0.259320115 */, - /* 4211 */ 0x042682f8 | (18 << 27) /* 0.259402247 */, - /* 4212 */ 0x0426d919 | (18 << 27) /* 0.259484385 */, - /* 4213 */ 0x04272f3b | (18 << 27) /* 0.259566529 */, - /* 4214 */ 0x04278560 | (18 << 27) /* 0.259648680 */, - /* 4215 */ 0x0427db86 | (18 << 27) /* 0.259730838 */, - /* 4216 */ 0x042831ad | (18 << 27) /* 0.259813002 */, - /* 4217 */ 0x042887d7 | (18 << 27) /* 0.259895173 */, - /* 4218 */ 0x0428de02 | (18 << 27) /* 0.259977350 */, - /* 4219 */ 0x0429342f | (18 << 27) /* 0.260059533 */, - /* 4220 */ 0x04298a5e | (18 << 27) /* 0.260141723 */, - /* 4221 */ 0x0429e08e | (18 << 27) /* 0.260223920 */, - /* 4222 */ 0x042a36c0 | (18 << 27) /* 0.260306123 */, - /* 4223 */ 0x042a8cf4 | (18 << 27) /* 0.260388332 */, - - /* 4224 */ 0x042ae32a | (18 << 27) /* 0.260470548 */, - /* 4225 */ 0x042b3962 | (18 << 27) /* 0.260552771 */, - /* 4226 */ 0x042b8f9b | (18 << 27) /* 0.260635000 */, - /* 4227 */ 0x042be5d6 | (18 << 27) /* 0.260717235 */, - /* 4228 */ 0x042c3c12 | (18 << 27) /* 0.260799477 */, - /* 4229 */ 0x042c9251 | (18 << 27) /* 0.260881725 */, - /* 4230 */ 0x042ce891 | (18 << 27) /* 0.260963980 */, - /* 4231 */ 0x042d3ed3 | (18 << 27) /* 0.261046242 */, - /* 4232 */ 0x042d9516 | (18 << 27) /* 0.261128510 */, - /* 4233 */ 0x042deb5c | (18 << 27) /* 0.261210784 */, - /* 4234 */ 0x042e41a3 | (18 << 27) /* 0.261293065 */, - /* 4235 */ 0x042e97ec | (18 << 27) /* 0.261375352 */, - /* 4236 */ 0x042eee36 | (18 << 27) /* 0.261457646 */, - /* 4237 */ 0x042f4482 | (18 << 27) /* 0.261539946 */, - /* 4238 */ 0x042f9ad1 | (18 << 27) /* 0.261622253 */, - /* 4239 */ 0x042ff120 | (18 << 27) /* 0.261704566 */, - - /* 4240 */ 0x04304772 | (18 << 27) /* 0.261786886 */, - /* 4241 */ 0x04309dc5 | (18 << 27) /* 0.261869212 */, - /* 4242 */ 0x0430f41a | (18 << 27) /* 0.261951545 */, - /* 4243 */ 0x04314a71 | (18 << 27) /* 0.262033884 */, - /* 4244 */ 0x0431a0c9 | (18 << 27) /* 0.262116229 */, - /* 4245 */ 0x0431f723 | (18 << 27) /* 0.262198581 */, - /* 4246 */ 0x04324d7f | (18 << 27) /* 0.262280940 */, - /* 4247 */ 0x0432a3dd | (18 << 27) /* 0.262363305 */, - /* 4248 */ 0x0432fa3d | (18 << 27) /* 0.262445676 */, - /* 4249 */ 0x0433509e | (18 << 27) /* 0.262528054 */, - /* 4250 */ 0x0433a701 | (18 << 27) /* 0.262610438 */, - /* 4251 */ 0x0433fd65 | (18 << 27) /* 0.262692829 */, - /* 4252 */ 0x043453cc | (18 << 27) /* 0.262775227 */, - /* 4253 */ 0x0434aa34 | (18 << 27) /* 0.262857630 */, - /* 4254 */ 0x0435009d | (18 << 27) /* 0.262940040 */, - /* 4255 */ 0x04355709 | (18 << 27) /* 0.263022457 */, - - /* 4256 */ 0x0435ad76 | (18 << 27) /* 0.263104880 */, - /* 4257 */ 0x043603e5 | (18 << 27) /* 0.263187310 */, - /* 4258 */ 0x04365a56 | (18 << 27) /* 0.263269746 */, - /* 4259 */ 0x0436b0c9 | (18 << 27) /* 0.263352188 */, - /* 4260 */ 0x0437073d | (18 << 27) /* 0.263434637 */, - /* 4261 */ 0x04375db3 | (18 << 27) /* 0.263517093 */, - /* 4262 */ 0x0437b42a | (18 << 27) /* 0.263599554 */, - /* 4263 */ 0x04380aa4 | (18 << 27) /* 0.263682023 */, - /* 4264 */ 0x0438611f | (18 << 27) /* 0.263764497 */, - /* 4265 */ 0x0438b79c | (18 << 27) /* 0.263846979 */, - /* 4266 */ 0x04390e1a | (18 << 27) /* 0.263929466 */, - /* 4267 */ 0x0439649b | (18 << 27) /* 0.264011960 */, - /* 4268 */ 0x0439bb1d | (18 << 27) /* 0.264094461 */, - /* 4269 */ 0x043a11a1 | (18 << 27) /* 0.264176968 */, - /* 4270 */ 0x043a6826 | (18 << 27) /* 0.264259481 */, - /* 4271 */ 0x043abead | (18 << 27) /* 0.264342001 */, - - /* 4272 */ 0x043b1536 | (18 << 27) /* 0.264424527 */, - /* 4273 */ 0x043b6bc1 | (18 << 27) /* 0.264507060 */, - /* 4274 */ 0x043bc24d | (18 << 27) /* 0.264589599 */, - /* 4275 */ 0x043c18dc | (18 << 27) /* 0.264672145 */, - /* 4276 */ 0x043c6f6c | (18 << 27) /* 0.264754697 */, - /* 4277 */ 0x043cc5fd | (18 << 27) /* 0.264837255 */, - /* 4278 */ 0x043d1c91 | (18 << 27) /* 0.264919820 */, - /* 4279 */ 0x043d7326 | (18 << 27) /* 0.265002392 */, - /* 4280 */ 0x043dc9bc | (18 << 27) /* 0.265084969 */, - /* 4281 */ 0x043e2055 | (18 << 27) /* 0.265167554 */, - /* 4282 */ 0x043e76ef | (18 << 27) /* 0.265250144 */, - /* 4283 */ 0x043ecd8b | (18 << 27) /* 0.265332741 */, - /* 4284 */ 0x043f2429 | (18 << 27) /* 0.265415345 */, - /* 4285 */ 0x043f7ac8 | (18 << 27) /* 0.265497955 */, - /* 4286 */ 0x043fd169 | (18 << 27) /* 0.265580571 */, - /* 4287 */ 0x0440280c | (18 << 27) /* 0.265663194 */, - - /* 4288 */ 0x04407eb1 | (18 << 27) /* 0.265745823 */, - /* 4289 */ 0x0440d557 | (18 << 27) /* 0.265828459 */, - /* 4290 */ 0x04412bff | (18 << 27) /* 0.265911101 */, - /* 4291 */ 0x044182a9 | (18 << 27) /* 0.265993749 */, - /* 4292 */ 0x0441d955 | (18 << 27) /* 0.266076404 */, - /* 4293 */ 0x04423002 | (18 << 27) /* 0.266159065 */, - /* 4294 */ 0x044286b1 | (18 << 27) /* 0.266241733 */, - /* 4295 */ 0x0442dd61 | (18 << 27) /* 0.266324407 */, - /* 4296 */ 0x04433414 | (18 << 27) /* 0.266407088 */, - /* 4297 */ 0x04438ac8 | (18 << 27) /* 0.266489775 */, - /* 4298 */ 0x0443e17e | (18 << 27) /* 0.266572468 */, - /* 4299 */ 0x04443835 | (18 << 27) /* 0.266655168 */, - /* 4300 */ 0x04448eef | (18 << 27) /* 0.266737874 */, - /* 4301 */ 0x0444e5aa | (18 << 27) /* 0.266820587 */, - /* 4302 */ 0x04453c66 | (18 << 27) /* 0.266903306 */, - /* 4303 */ 0x04459325 | (18 << 27) /* 0.266986031 */, - - /* 4304 */ 0x0445e9e5 | (18 << 27) /* 0.267068763 */, - /* 4305 */ 0x044640a7 | (18 << 27) /* 0.267151501 */, - /* 4306 */ 0x0446976a | (18 << 27) /* 0.267234246 */, - /* 4307 */ 0x0446ee30 | (18 << 27) /* 0.267316997 */, - /* 4308 */ 0x044744f7 | (18 << 27) /* 0.267399755 */, - /* 4309 */ 0x04479bc0 | (18 << 27) /* 0.267482518 */, - /* 4310 */ 0x0447f28a | (18 << 27) /* 0.267565289 */, - /* 4311 */ 0x04484956 | (18 << 27) /* 0.267648065 */, - /* 4312 */ 0x0448a024 | (18 << 27) /* 0.267730848 */, - /* 4313 */ 0x0448f6f4 | (18 << 27) /* 0.267813638 */, - /* 4314 */ 0x04494dc5 | (18 << 27) /* 0.267896434 */, - /* 4315 */ 0x0449a498 | (18 << 27) /* 0.267979236 */, - /* 4316 */ 0x0449fb6d | (18 << 27) /* 0.268062045 */, - /* 4317 */ 0x044a5243 | (18 << 27) /* 0.268144860 */, - /* 4318 */ 0x044aa91c | (18 << 27) /* 0.268227681 */, - /* 4319 */ 0x044afff6 | (18 << 27) /* 0.268310509 */, - - /* 4320 */ 0x044b56d1 | (18 << 27) /* 0.268393343 */, - /* 4321 */ 0x044badaf | (18 << 27) /* 0.268476184 */, - /* 4322 */ 0x044c048e | (18 << 27) /* 0.268559031 */, - /* 4323 */ 0x044c5b6f | (18 << 27) /* 0.268641885 */, - /* 4324 */ 0x044cb251 | (18 << 27) /* 0.268724744 */, - /* 4325 */ 0x044d0935 | (18 << 27) /* 0.268807611 */, - /* 4326 */ 0x044d601b | (18 << 27) /* 0.268890483 */, - /* 4327 */ 0x044db703 | (18 << 27) /* 0.268973362 */, - /* 4328 */ 0x044e0dec | (18 << 27) /* 0.269056248 */, - /* 4329 */ 0x044e64d7 | (18 << 27) /* 0.269139139 */, - /* 4330 */ 0x044ebbc4 | (18 << 27) /* 0.269222037 */, - /* 4331 */ 0x044f12b3 | (18 << 27) /* 0.269304942 */, - /* 4332 */ 0x044f69a3 | (18 << 27) /* 0.269387853 */, - /* 4333 */ 0x044fc095 | (18 << 27) /* 0.269470770 */, - /* 4334 */ 0x04501788 | (18 << 27) /* 0.269553694 */, - /* 4335 */ 0x04506e7e | (18 << 27) /* 0.269636624 */, - - /* 4336 */ 0x0450c575 | (18 << 27) /* 0.269719560 */, - /* 4337 */ 0x04511c6e | (18 << 27) /* 0.269802503 */, - /* 4338 */ 0x04517368 | (18 << 27) /* 0.269885452 */, - /* 4339 */ 0x0451ca64 | (18 << 27) /* 0.269968408 */, - /* 4340 */ 0x04522162 | (18 << 27) /* 0.270051370 */, - /* 4341 */ 0x04527862 | (18 << 27) /* 0.270134338 */, - /* 4342 */ 0x0452cf63 | (18 << 27) /* 0.270217312 */, - /* 4343 */ 0x04532666 | (18 << 27) /* 0.270300293 */, - /* 4344 */ 0x04537d6b | (18 << 27) /* 0.270383281 */, - /* 4345 */ 0x0453d472 | (18 << 27) /* 0.270466275 */, - /* 4346 */ 0x04542b7a | (18 << 27) /* 0.270549275 */, - /* 4347 */ 0x04548284 | (18 << 27) /* 0.270632281 */, - /* 4348 */ 0x0454d98f | (18 << 27) /* 0.270715294 */, - /* 4349 */ 0x0455309c | (18 << 27) /* 0.270798313 */, - /* 4350 */ 0x045587ab | (18 << 27) /* 0.270881339 */, - /* 4351 */ 0x0455debc | (18 << 27) /* 0.270964371 */, - - /* 4352 */ 0x045635cf | (18 << 27) /* 0.271047409 */, - /* 4353 */ 0x04568ce3 | (18 << 27) /* 0.271130454 */, - /* 4354 */ 0x0456e3f9 | (18 << 27) /* 0.271213505 */, - /* 4355 */ 0x04573b10 | (18 << 27) /* 0.271296562 */, - /* 4356 */ 0x04579229 | (18 << 27) /* 0.271379626 */, - /* 4357 */ 0x0457e944 | (18 << 27) /* 0.271462696 */, - /* 4358 */ 0x04584061 | (18 << 27) /* 0.271545772 */, - /* 4359 */ 0x0458977f | (18 << 27) /* 0.271628855 */, - /* 4360 */ 0x0458ee9f | (18 << 27) /* 0.271711944 */, - /* 4361 */ 0x045945c1 | (18 << 27) /* 0.271795040 */, - /* 4362 */ 0x04599ce5 | (18 << 27) /* 0.271878142 */, - /* 4363 */ 0x0459f40a | (18 << 27) /* 0.271961250 */, - /* 4364 */ 0x045a4b31 | (18 << 27) /* 0.272044365 */, - /* 4365 */ 0x045aa259 | (18 << 27) /* 0.272127486 */, - /* 4366 */ 0x045af984 | (18 << 27) /* 0.272210613 */, - /* 4367 */ 0x045b50b0 | (18 << 27) /* 0.272293746 */, - - /* 4368 */ 0x045ba7dd | (18 << 27) /* 0.272376886 */, - /* 4369 */ 0x045bff0d | (18 << 27) /* 0.272460033 */, - /* 4370 */ 0x045c563e | (18 << 27) /* 0.272543185 */, - /* 4371 */ 0x045cad71 | (18 << 27) /* 0.272626344 */, - /* 4372 */ 0x045d04a5 | (18 << 27) /* 0.272709510 */, - /* 4373 */ 0x045d5bdc | (18 << 27) /* 0.272792681 */, - /* 4374 */ 0x045db313 | (18 << 27) /* 0.272875859 */, - /* 4375 */ 0x045e0a4d | (18 << 27) /* 0.272959044 */, - /* 4376 */ 0x045e6188 | (18 << 27) /* 0.273042234 */, - /* 4377 */ 0x045eb8c5 | (18 << 27) /* 0.273125431 */, - /* 4378 */ 0x045f1004 | (18 << 27) /* 0.273208635 */, - /* 4379 */ 0x045f6745 | (18 << 27) /* 0.273291844 */, - /* 4380 */ 0x045fbe87 | (18 << 27) /* 0.273375060 */, - /* 4381 */ 0x046015cb | (18 << 27) /* 0.273458283 */, - /* 4382 */ 0x04606d10 | (18 << 27) /* 0.273541511 */, - /* 4383 */ 0x0460c457 | (18 << 27) /* 0.273624747 */, - - /* 4384 */ 0x04611ba0 | (18 << 27) /* 0.273707988 */, - /* 4385 */ 0x046172eb | (18 << 27) /* 0.273791236 */, - /* 4386 */ 0x0461ca37 | (18 << 27) /* 0.273874490 */, - /* 4387 */ 0x04622185 | (18 << 27) /* 0.273957750 */, - /* 4388 */ 0x046278d5 | (18 << 27) /* 0.274041017 */, - /* 4389 */ 0x0462d026 | (18 << 27) /* 0.274124290 */, - /* 4390 */ 0x0463277a | (18 << 27) /* 0.274207569 */, - /* 4391 */ 0x04637ece | (18 << 27) /* 0.274290855 */, - /* 4392 */ 0x0463d625 | (18 << 27) /* 0.274374147 */, - /* 4393 */ 0x04642d7d | (18 << 27) /* 0.274457445 */, - /* 4394 */ 0x046484d7 | (18 << 27) /* 0.274540749 */, - /* 4395 */ 0x0464dc33 | (18 << 27) /* 0.274624060 */, - /* 4396 */ 0x04653390 | (18 << 27) /* 0.274707378 */, - /* 4397 */ 0x04658aef | (18 << 27) /* 0.274790701 */, - /* 4398 */ 0x0465e250 | (18 << 27) /* 0.274874031 */, - /* 4399 */ 0x046639b2 | (18 << 27) /* 0.274957367 */, - - /* 4400 */ 0x04669116 | (18 << 27) /* 0.275040710 */, - /* 4401 */ 0x0466e87c | (18 << 27) /* 0.275124059 */, - /* 4402 */ 0x04673fe3 | (18 << 27) /* 0.275207414 */, - /* 4403 */ 0x0467974d | (18 << 27) /* 0.275290775 */, - /* 4404 */ 0x0467eeb7 | (18 << 27) /* 0.275374143 */, - /* 4405 */ 0x04684624 | (18 << 27) /* 0.275457517 */, - /* 4406 */ 0x04689d92 | (18 << 27) /* 0.275540897 */, - /* 4407 */ 0x0468f502 | (18 << 27) /* 0.275624284 */, - /* 4408 */ 0x04694c74 | (18 << 27) /* 0.275707677 */, - /* 4409 */ 0x0469a3e7 | (18 << 27) /* 0.275791076 */, - /* 4410 */ 0x0469fb5c | (18 << 27) /* 0.275874482 */, - /* 4411 */ 0x046a52d3 | (18 << 27) /* 0.275957894 */, - /* 4412 */ 0x046aaa4b | (18 << 27) /* 0.276041312 */, - /* 4413 */ 0x046b01c5 | (18 << 27) /* 0.276124737 */, - /* 4414 */ 0x046b5941 | (18 << 27) /* 0.276208167 */, - /* 4415 */ 0x046bb0bf | (18 << 27) /* 0.276291605 */, - - /* 4416 */ 0x046c083e | (18 << 27) /* 0.276375048 */, - /* 4417 */ 0x046c5fbf | (18 << 27) /* 0.276458498 */, - /* 4418 */ 0x046cb741 | (18 << 27) /* 0.276541954 */, - /* 4419 */ 0x046d0ec5 | (18 << 27) /* 0.276625416 */, - /* 4420 */ 0x046d664b | (18 << 27) /* 0.276708885 */, - /* 4421 */ 0x046dbdd3 | (18 << 27) /* 0.276792360 */, - /* 4422 */ 0x046e155c | (18 << 27) /* 0.276875841 */, - /* 4423 */ 0x046e6ce7 | (18 << 27) /* 0.276959328 */, - /* 4424 */ 0x046ec474 | (18 << 27) /* 0.277042822 */, - /* 4425 */ 0x046f1c02 | (18 << 27) /* 0.277126322 */, - /* 4426 */ 0x046f7392 | (18 << 27) /* 0.277209829 */, - /* 4427 */ 0x046fcb24 | (18 << 27) /* 0.277293341 */, - /* 4428 */ 0x047022b8 | (18 << 27) /* 0.277376860 */, - /* 4429 */ 0x04707a4d | (18 << 27) /* 0.277460385 */, - /* 4430 */ 0x0470d1e4 | (18 << 27) /* 0.277543917 */, - /* 4431 */ 0x0471297c | (18 << 27) /* 0.277627455 */, - - /* 4432 */ 0x04718116 | (18 << 27) /* 0.277710999 */, - /* 4433 */ 0x0471d8b2 | (18 << 27) /* 0.277794549 */, - /* 4434 */ 0x04723050 | (18 << 27) /* 0.277878106 */, - /* 4435 */ 0x047287ef | (18 << 27) /* 0.277961669 */, - /* 4436 */ 0x0472df90 | (18 << 27) /* 0.278045238 */, - /* 4437 */ 0x04733733 | (18 << 27) /* 0.278128813 */, - /* 4438 */ 0x04738ed7 | (18 << 27) /* 0.278212395 */, - /* 4439 */ 0x0473e67d | (18 << 27) /* 0.278295983 */, - /* 4440 */ 0x04743e25 | (18 << 27) /* 0.278379578 */, - /* 4441 */ 0x047495ce | (18 << 27) /* 0.278463178 */, - /* 4442 */ 0x0474ed79 | (18 << 27) /* 0.278546785 */, - /* 4443 */ 0x04754526 | (18 << 27) /* 0.278630398 */, - /* 4444 */ 0x04759cd4 | (18 << 27) /* 0.278714018 */, - /* 4445 */ 0x0475f484 | (18 << 27) /* 0.278797643 */, - /* 4446 */ 0x04764c36 | (18 << 27) /* 0.278881275 */, - /* 4447 */ 0x0476a3ea | (18 << 27) /* 0.278964914 */, - - /* 4448 */ 0x0476fb9f | (18 << 27) /* 0.279048558 */, - /* 4449 */ 0x04775356 | (18 << 27) /* 0.279132209 */, - /* 4450 */ 0x0477ab0e | (18 << 27) /* 0.279215866 */, - /* 4451 */ 0x047802c8 | (18 << 27) /* 0.279299529 */, - /* 4452 */ 0x04785a84 | (18 << 27) /* 0.279383199 */, - /* 4453 */ 0x0478b242 | (18 << 27) /* 0.279466875 */, - /* 4454 */ 0x04790a01 | (18 << 27) /* 0.279550557 */, - /* 4455 */ 0x047961c2 | (18 << 27) /* 0.279634245 */, - /* 4456 */ 0x0479b984 | (18 << 27) /* 0.279717940 */, - /* 4457 */ 0x047a1149 | (18 << 27) /* 0.279801641 */, - /* 4458 */ 0x047a690f | (18 << 27) /* 0.279885348 */, - /* 4459 */ 0x047ac0d6 | (18 << 27) /* 0.279969061 */, - /* 4460 */ 0x047b18a0 | (18 << 27) /* 0.280052781 */, - /* 4461 */ 0x047b706b | (18 << 27) /* 0.280136507 */, - /* 4462 */ 0x047bc837 | (18 << 27) /* 0.280220239 */, - /* 4463 */ 0x047c2006 | (18 << 27) /* 0.280303978 */, - - /* 4464 */ 0x047c77d6 | (18 << 27) /* 0.280387722 */, - /* 4465 */ 0x047ccfa8 | (18 << 27) /* 0.280471473 */, - /* 4466 */ 0x047d277b | (18 << 27) /* 0.280555230 */, - /* 4467 */ 0x047d7f50 | (18 << 27) /* 0.280638994 */, - /* 4468 */ 0x047dd727 | (18 << 27) /* 0.280722764 */, - /* 4469 */ 0x047e2eff | (18 << 27) /* 0.280806540 */, - /* 4470 */ 0x047e86d9 | (18 << 27) /* 0.280890322 */, - /* 4471 */ 0x047edeb5 | (18 << 27) /* 0.280974110 */, - /* 4472 */ 0x047f3693 | (18 << 27) /* 0.281057905 */, - /* 4473 */ 0x047f8e72 | (18 << 27) /* 0.281141706 */, - /* 4474 */ 0x047fe653 | (18 << 27) /* 0.281225513 */, - /* 4475 */ 0x04803e35 | (18 << 27) /* 0.281309326 */, - /* 4476 */ 0x04809619 | (18 << 27) /* 0.281393146 */, - /* 4477 */ 0x0480edff | (18 << 27) /* 0.281476972 */, - /* 4478 */ 0x048145e7 | (18 << 27) /* 0.281560804 */, - /* 4479 */ 0x04819dd0 | (18 << 27) /* 0.281644643 */, - - /* 4480 */ 0x0481f5bb | (18 << 27) /* 0.281728487 */, - /* 4481 */ 0x04824da7 | (18 << 27) /* 0.281812338 */, - /* 4482 */ 0x0482a595 | (18 << 27) /* 0.281896195 */, - /* 4483 */ 0x0482fd85 | (18 << 27) /* 0.281980059 */, - /* 4484 */ 0x04835577 | (18 << 27) /* 0.282063928 */, - /* 4485 */ 0x0483ad6a | (18 << 27) /* 0.282147804 */, - /* 4486 */ 0x0484055f | (18 << 27) /* 0.282231686 */, - /* 4487 */ 0x04845d56 | (18 << 27) /* 0.282315574 */, - /* 4488 */ 0x0484b54e | (18 << 27) /* 0.282399469 */, - /* 4489 */ 0x04850d48 | (18 << 27) /* 0.282483370 */, - /* 4490 */ 0x04856544 | (18 << 27) /* 0.282567277 */, - /* 4491 */ 0x0485bd41 | (18 << 27) /* 0.282651190 */, - /* 4492 */ 0x04861540 | (18 << 27) /* 0.282735109 */, - /* 4493 */ 0x04866d40 | (18 << 27) /* 0.282819035 */, - /* 4494 */ 0x0486c543 | (18 << 27) /* 0.282902967 */, - /* 4495 */ 0x04871d47 | (18 << 27) /* 0.282986905 */, - - /* 4496 */ 0x0487754c | (18 << 27) /* 0.283070849 */, - /* 4497 */ 0x0487cd54 | (18 << 27) /* 0.283154800 */, - /* 4498 */ 0x0488255d | (18 << 27) /* 0.283238757 */, - /* 4499 */ 0x04887d67 | (18 << 27) /* 0.283322720 */, - /* 4500 */ 0x0488d574 | (18 << 27) /* 0.283406689 */, - /* 4501 */ 0x04892d82 | (18 << 27) /* 0.283490665 */, - /* 4502 */ 0x04898591 | (18 << 27) /* 0.283574646 */, - /* 4503 */ 0x0489dda3 | (18 << 27) /* 0.283658634 */, - /* 4504 */ 0x048a35b6 | (18 << 27) /* 0.283742628 */, - /* 4505 */ 0x048a8dca | (18 << 27) /* 0.283826629 */, - /* 4506 */ 0x048ae5e1 | (18 << 27) /* 0.283910635 */, - /* 4507 */ 0x048b3df9 | (18 << 27) /* 0.283994648 */, - /* 4508 */ 0x048b9612 | (18 << 27) /* 0.284078667 */, - /* 4509 */ 0x048bee2e | (18 << 27) /* 0.284162692 */, - /* 4510 */ 0x048c464b | (18 << 27) /* 0.284246723 */, - /* 4511 */ 0x048c9e69 | (18 << 27) /* 0.284330761 */, - - /* 4512 */ 0x048cf68a | (18 << 27) /* 0.284414805 */, - /* 4513 */ 0x048d4eac | (18 << 27) /* 0.284498855 */, - /* 4514 */ 0x048da6cf | (18 << 27) /* 0.284582911 */, - /* 4515 */ 0x048dfef5 | (18 << 27) /* 0.284666974 */, - /* 4516 */ 0x048e571c | (18 << 27) /* 0.284751042 */, - /* 4517 */ 0x048eaf44 | (18 << 27) /* 0.284835117 */, - /* 4518 */ 0x048f076f | (18 << 27) /* 0.284919198 */, - /* 4519 */ 0x048f5f9b | (18 << 27) /* 0.285003285 */, - /* 4520 */ 0x048fb7c8 | (18 << 27) /* 0.285087379 */, - /* 4521 */ 0x04900ff8 | (18 << 27) /* 0.285171479 */, - /* 4522 */ 0x04906829 | (18 << 27) /* 0.285255584 */, - /* 4523 */ 0x0490c05b | (18 << 27) /* 0.285339697 */, - /* 4524 */ 0x04911890 | (18 << 27) /* 0.285423815 */, - /* 4525 */ 0x049170c6 | (18 << 27) /* 0.285507939 */, - /* 4526 */ 0x0491c8fd | (18 << 27) /* 0.285592070 */, - /* 4527 */ 0x04922137 | (18 << 27) /* 0.285676207 */, - - /* 4528 */ 0x04927972 | (18 << 27) /* 0.285760350 */, - /* 4529 */ 0x0492d1ae | (18 << 27) /* 0.285844499 */, - /* 4530 */ 0x049329ed | (18 << 27) /* 0.285928655 */, - /* 4531 */ 0x0493822c | (18 << 27) /* 0.286012816 */, - /* 4532 */ 0x0493da6e | (18 << 27) /* 0.286096984 */, - /* 4533 */ 0x049432b1 | (18 << 27) /* 0.286181158 */, - /* 4534 */ 0x04948af6 | (18 << 27) /* 0.286265338 */, - /* 4535 */ 0x0494e33d | (18 << 27) /* 0.286349525 */, - /* 4536 */ 0x04953b85 | (18 << 27) /* 0.286433717 */, - /* 4537 */ 0x049593cf | (18 << 27) /* 0.286517916 */, - /* 4538 */ 0x0495ec1b | (18 << 27) /* 0.286602121 */, - /* 4539 */ 0x04964468 | (18 << 27) /* 0.286686332 */, - /* 4540 */ 0x04969cb7 | (18 << 27) /* 0.286770550 */, - /* 4541 */ 0x0496f508 | (18 << 27) /* 0.286854773 */, - /* 4542 */ 0x04974d5a | (18 << 27) /* 0.286939003 */, - /* 4543 */ 0x0497a5ae | (18 << 27) /* 0.287023239 */, - - /* 4544 */ 0x0497fe03 | (18 << 27) /* 0.287107481 */, - /* 4545 */ 0x0498565a | (18 << 27) /* 0.287191729 */, - /* 4546 */ 0x0498aeb3 | (18 << 27) /* 0.287275983 */, - /* 4547 */ 0x0499070e | (18 << 27) /* 0.287360244 */, - /* 4548 */ 0x04995f6a | (18 << 27) /* 0.287444511 */, - /* 4549 */ 0x0499b7c8 | (18 << 27) /* 0.287528784 */, - /* 4550 */ 0x049a1027 | (18 << 27) /* 0.287613063 */, - /* 4551 */ 0x049a6889 | (18 << 27) /* 0.287697348 */, - /* 4552 */ 0x049ac0eb | (18 << 27) /* 0.287781640 */, - /* 4553 */ 0x049b1950 | (18 << 27) /* 0.287865937 */, - /* 4554 */ 0x049b71b6 | (18 << 27) /* 0.287950241 */, - /* 4555 */ 0x049bca1e | (18 << 27) /* 0.288034551 */, - /* 4556 */ 0x049c2287 | (18 << 27) /* 0.288118867 */, - /* 4557 */ 0x049c7af2 | (18 << 27) /* 0.288203190 */, - /* 4558 */ 0x049cd35f | (18 << 27) /* 0.288287518 */, - /* 4559 */ 0x049d2bce | (18 << 27) /* 0.288371853 */, - - /* 4560 */ 0x049d843e | (18 << 27) /* 0.288456194 */, - /* 4561 */ 0x049ddcaf | (18 << 27) /* 0.288540541 */, - /* 4562 */ 0x049e3523 | (18 << 27) /* 0.288624894 */, - /* 4563 */ 0x049e8d98 | (18 << 27) /* 0.288709253 */, - /* 4564 */ 0x049ee60e | (18 << 27) /* 0.288793619 */, - /* 4565 */ 0x049f3e87 | (18 << 27) /* 0.288877990 */, - /* 4566 */ 0x049f9701 | (18 << 27) /* 0.288962368 */, - /* 4567 */ 0x049fef7c | (18 << 27) /* 0.289046752 */, - /* 4568 */ 0x04a047fa | (18 << 27) /* 0.289131142 */, - /* 4569 */ 0x04a0a079 | (18 << 27) /* 0.289215538 */, - /* 4570 */ 0x04a0f8f9 | (18 << 27) /* 0.289299941 */, - /* 4571 */ 0x04a1517c | (18 << 27) /* 0.289384349 */, - /* 4572 */ 0x04a1a9ff | (18 << 27) /* 0.289468764 */, - /* 4573 */ 0x04a20285 | (18 << 27) /* 0.289553185 */, - /* 4574 */ 0x04a25b0c | (18 << 27) /* 0.289637612 */, - /* 4575 */ 0x04a2b395 | (18 << 27) /* 0.289722045 */, - - /* 4576 */ 0x04a30c20 | (18 << 27) /* 0.289806485 */, - /* 4577 */ 0x04a364ac | (18 << 27) /* 0.289890930 */, - /* 4578 */ 0x04a3bd3a | (18 << 27) /* 0.289975382 */, - /* 4579 */ 0x04a415c9 | (18 << 27) /* 0.290059840 */, - /* 4580 */ 0x04a46e5a | (18 << 27) /* 0.290144304 */, - /* 4581 */ 0x04a4c6ed | (18 << 27) /* 0.290228774 */, - /* 4582 */ 0x04a51f81 | (18 << 27) /* 0.290313250 */, - /* 4583 */ 0x04a57818 | (18 << 27) /* 0.290397733 */, - /* 4584 */ 0x04a5d0af | (18 << 27) /* 0.290482221 */, - /* 4585 */ 0x04a62949 | (18 << 27) /* 0.290566716 */, - /* 4586 */ 0x04a681e4 | (18 << 27) /* 0.290651217 */, - /* 4587 */ 0x04a6da80 | (18 << 27) /* 0.290735724 */, - /* 4588 */ 0x04a7331f | (18 << 27) /* 0.290820237 */, - /* 4589 */ 0x04a78bbf | (18 << 27) /* 0.290904756 */, - /* 4590 */ 0x04a7e460 | (18 << 27) /* 0.290989281 */, - /* 4591 */ 0x04a83d03 | (18 << 27) /* 0.291073813 */, - - /* 4592 */ 0x04a895a8 | (18 << 27) /* 0.291158351 */, - /* 4593 */ 0x04a8ee4f | (18 << 27) /* 0.291242894 */, - /* 4594 */ 0x04a946f7 | (18 << 27) /* 0.291327444 */, - /* 4595 */ 0x04a99fa1 | (18 << 27) /* 0.291412001 */, - /* 4596 */ 0x04a9f84c | (18 << 27) /* 0.291496563 */, - /* 4597 */ 0x04aa50fa | (18 << 27) /* 0.291581131 */, - /* 4598 */ 0x04aaa9a8 | (18 << 27) /* 0.291665706 */, - /* 4599 */ 0x04ab0259 | (18 << 27) /* 0.291750286 */, - /* 4600 */ 0x04ab5b0b | (18 << 27) /* 0.291834873 */, - /* 4601 */ 0x04abb3bf | (18 << 27) /* 0.291919466 */, - /* 4602 */ 0x04ac0c74 | (18 << 27) /* 0.292004065 */, - /* 4603 */ 0x04ac652b | (18 << 27) /* 0.292088670 */, - /* 4604 */ 0x04acbde4 | (18 << 27) /* 0.292173281 */, - /* 4605 */ 0x04ad169e | (18 << 27) /* 0.292257899 */, - /* 4606 */ 0x04ad6f5a | (18 << 27) /* 0.292342522 */, - /* 4607 */ 0x04adc818 | (18 << 27) /* 0.292427152 */, - - /* 4608 */ 0x04ae20d7 | (18 << 27) /* 0.292511788 */, - /* 4609 */ 0x04ae7998 | (18 << 27) /* 0.292596430 */, - /* 4610 */ 0x04aed25a | (18 << 27) /* 0.292681078 */, - /* 4611 */ 0x04af2b1e | (18 << 27) /* 0.292765732 */, - /* 4612 */ 0x04af83e4 | (18 << 27) /* 0.292850392 */, - /* 4613 */ 0x04afdcac | (18 << 27) /* 0.292935058 */, - /* 4614 */ 0x04b03575 | (18 << 27) /* 0.293019731 */, - /* 4615 */ 0x04b08e40 | (18 << 27) /* 0.293104409 */, - /* 4616 */ 0x04b0e70c | (18 << 27) /* 0.293189094 */, - /* 4617 */ 0x04b13fda | (18 << 27) /* 0.293273785 */, - /* 4618 */ 0x04b198aa | (18 << 27) /* 0.293358482 */, - /* 4619 */ 0x04b1f17b | (18 << 27) /* 0.293443185 */, - /* 4620 */ 0x04b24a4e | (18 << 27) /* 0.293527894 */, - /* 4621 */ 0x04b2a322 | (18 << 27) /* 0.293612609 */, - /* 4622 */ 0x04b2fbf9 | (18 << 27) /* 0.293697331 */, - /* 4623 */ 0x04b354d1 | (18 << 27) /* 0.293782058 */, - - /* 4624 */ 0x04b3adaa | (18 << 27) /* 0.293866792 */, - /* 4625 */ 0x04b40685 | (18 << 27) /* 0.293951532 */, - /* 4626 */ 0x04b45f62 | (18 << 27) /* 0.294036278 */, - /* 4627 */ 0x04b4b840 | (18 << 27) /* 0.294121029 */, - /* 4628 */ 0x04b51120 | (18 << 27) /* 0.294205788 */, - /* 4629 */ 0x04b56a02 | (18 << 27) /* 0.294290552 */, - /* 4630 */ 0x04b5c2e6 | (18 << 27) /* 0.294375322 */, - /* 4631 */ 0x04b61bcb | (18 << 27) /* 0.294460098 */, - /* 4632 */ 0x04b674b1 | (18 << 27) /* 0.294544881 */, - /* 4633 */ 0x04b6cd99 | (18 << 27) /* 0.294629669 */, - /* 4634 */ 0x04b72683 | (18 << 27) /* 0.294714464 */, - /* 4635 */ 0x04b77f6f | (18 << 27) /* 0.294799265 */, - /* 4636 */ 0x04b7d85c | (18 << 27) /* 0.294884072 */, - /* 4637 */ 0x04b8314b | (18 << 27) /* 0.294968885 */, - /* 4638 */ 0x04b88a3b | (18 << 27) /* 0.295053704 */, - /* 4639 */ 0x04b8e32d | (18 << 27) /* 0.295138529 */, - - /* 4640 */ 0x04b93c21 | (18 << 27) /* 0.295223360 */, - /* 4641 */ 0x04b99516 | (18 << 27) /* 0.295308197 */, - /* 4642 */ 0x04b9ee0d | (18 << 27) /* 0.295393041 */, - /* 4643 */ 0x04ba4706 | (18 << 27) /* 0.295477890 */, - /* 4644 */ 0x04baa000 | (18 << 27) /* 0.295562746 */, - /* 4645 */ 0x04baf8fc | (18 << 27) /* 0.295647608 */, - /* 4646 */ 0x04bb51fa | (18 << 27) /* 0.295732476 */, - /* 4647 */ 0x04bbaaf9 | (18 << 27) /* 0.295817349 */, - /* 4648 */ 0x04bc03fa | (18 << 27) /* 0.295902229 */, - /* 4649 */ 0x04bc5cfc | (18 << 27) /* 0.295987115 */, - /* 4650 */ 0x04bcb600 | (18 << 27) /* 0.296072008 */, - /* 4651 */ 0x04bd0f06 | (18 << 27) /* 0.296156906 */, - /* 4652 */ 0x04bd680d | (18 << 27) /* 0.296241810 */, - /* 4653 */ 0x04bdc116 | (18 << 27) /* 0.296326721 */, - /* 4654 */ 0x04be1a21 | (18 << 27) /* 0.296411637 */, - /* 4655 */ 0x04be732d | (18 << 27) /* 0.296496560 */, - - /* 4656 */ 0x04becc3b | (18 << 27) /* 0.296581488 */, - /* 4657 */ 0x04bf254a | (18 << 27) /* 0.296666423 */, - /* 4658 */ 0x04bf7e5b | (18 << 27) /* 0.296751364 */, - /* 4659 */ 0x04bfd76e | (18 << 27) /* 0.296836311 */, - /* 4660 */ 0x04c03083 | (18 << 27) /* 0.296921264 */, - /* 4661 */ 0x04c08999 | (18 << 27) /* 0.297006223 */, - /* 4662 */ 0x04c0e2b0 | (18 << 27) /* 0.297091188 */, - /* 4663 */ 0x04c13bca | (18 << 27) /* 0.297176159 */, - /* 4664 */ 0x04c194e4 | (18 << 27) /* 0.297261136 */, - /* 4665 */ 0x04c1ee01 | (18 << 27) /* 0.297346120 */, - /* 4666 */ 0x04c2471f | (18 << 27) /* 0.297431109 */, - /* 4667 */ 0x04c2a03f | (18 << 27) /* 0.297516105 */, - /* 4668 */ 0x04c2f960 | (18 << 27) /* 0.297601106 */, - /* 4669 */ 0x04c35283 | (18 << 27) /* 0.297686114 */, - /* 4670 */ 0x04c3aba8 | (18 << 27) /* 0.297771128 */, - /* 4671 */ 0x04c404ce | (18 << 27) /* 0.297856147 */, - - /* 4672 */ 0x04c45df6 | (18 << 27) /* 0.297941173 */, - /* 4673 */ 0x04c4b720 | (18 << 27) /* 0.298026205 */, - /* 4674 */ 0x04c5104b | (18 << 27) /* 0.298111243 */, - /* 4675 */ 0x04c56978 | (18 << 27) /* 0.298196287 */, - /* 4676 */ 0x04c5c2a7 | (18 << 27) /* 0.298281337 */, - /* 4677 */ 0x04c61bd7 | (18 << 27) /* 0.298366393 */, - /* 4678 */ 0x04c67508 | (18 << 27) /* 0.298451456 */, - /* 4679 */ 0x04c6ce3c | (18 << 27) /* 0.298536524 */, - /* 4680 */ 0x04c72771 | (18 << 27) /* 0.298621598 */, - /* 4681 */ 0x04c780a7 | (18 << 27) /* 0.298706679 */, - /* 4682 */ 0x04c7d9df | (18 << 27) /* 0.298791765 */, - /* 4683 */ 0x04c83319 | (18 << 27) /* 0.298876858 */, - /* 4684 */ 0x04c88c55 | (18 << 27) /* 0.298961956 */, - /* 4685 */ 0x04c8e592 | (18 << 27) /* 0.299047061 */, - /* 4686 */ 0x04c93ed1 | (18 << 27) /* 0.299132172 */, - /* 4687 */ 0x04c99811 | (18 << 27) /* 0.299217288 */, - - /* 4688 */ 0x04c9f153 | (18 << 27) /* 0.299302411 */, - /* 4689 */ 0x04ca4a97 | (18 << 27) /* 0.299387540 */, - /* 4690 */ 0x04caa3dc | (18 << 27) /* 0.299472675 */, - /* 4691 */ 0x04cafd23 | (18 << 27) /* 0.299557816 */, - /* 4692 */ 0x04cb566b | (18 << 27) /* 0.299642963 */, - /* 4693 */ 0x04cbafb5 | (18 << 27) /* 0.299728116 */, - /* 4694 */ 0x04cc0901 | (18 << 27) /* 0.299813275 */, - /* 4695 */ 0x04cc624e | (18 << 27) /* 0.299898440 */, - /* 4696 */ 0x04ccbb9d | (18 << 27) /* 0.299983611 */, - /* 4697 */ 0x04cd14ee | (18 << 27) /* 0.300068789 */, - /* 4698 */ 0x04cd6e40 | (18 << 27) /* 0.300153972 */, - /* 4699 */ 0x04cdc794 | (18 << 27) /* 0.300239161 */, - /* 4700 */ 0x04ce20e9 | (18 << 27) /* 0.300324357 */, - /* 4701 */ 0x04ce7a40 | (18 << 27) /* 0.300409558 */, - /* 4702 */ 0x04ced399 | (18 << 27) /* 0.300494765 */, - /* 4703 */ 0x04cf2cf3 | (18 << 27) /* 0.300579979 */, - - /* 4704 */ 0x04cf864f | (18 << 27) /* 0.300665198 */, - /* 4705 */ 0x04cfdfad | (18 << 27) /* 0.300750424 */, - /* 4706 */ 0x04d0390c | (18 << 27) /* 0.300835656 */, - /* 4707 */ 0x04d0926d | (18 << 27) /* 0.300920893 */, - /* 4708 */ 0x04d0ebcf | (18 << 27) /* 0.301006137 */, - /* 4709 */ 0x04d14533 | (18 << 27) /* 0.301091387 */, - /* 4710 */ 0x04d19e99 | (18 << 27) /* 0.301176643 */, - /* 4711 */ 0x04d1f800 | (18 << 27) /* 0.301261904 */, - /* 4712 */ 0x04d25169 | (18 << 27) /* 0.301347172 */, - /* 4713 */ 0x04d2aad4 | (18 << 27) /* 0.301432446 */, - /* 4714 */ 0x04d30440 | (18 << 27) /* 0.301517726 */, - /* 4715 */ 0x04d35dae | (18 << 27) /* 0.301603012 */, - /* 4716 */ 0x04d3b71d | (18 << 27) /* 0.301688304 */, - /* 4717 */ 0x04d4108e | (18 << 27) /* 0.301773602 */, - /* 4718 */ 0x04d46a01 | (18 << 27) /* 0.301858906 */, - /* 4719 */ 0x04d4c375 | (18 << 27) /* 0.301944216 */, - - /* 4720 */ 0x04d51ceb | (18 << 27) /* 0.302029532 */, - /* 4721 */ 0x04d57662 | (18 << 27) /* 0.302114854 */, - /* 4722 */ 0x04d5cfdb | (18 << 27) /* 0.302200182 */, - /* 4723 */ 0x04d62956 | (18 << 27) /* 0.302285516 */, - /* 4724 */ 0x04d682d2 | (18 << 27) /* 0.302370856 */, - /* 4725 */ 0x04d6dc50 | (18 << 27) /* 0.302456203 */, - /* 4726 */ 0x04d735d0 | (18 << 27) /* 0.302541555 */, - /* 4727 */ 0x04d78f51 | (18 << 27) /* 0.302626913 */, - /* 4728 */ 0x04d7e8d4 | (18 << 27) /* 0.302712277 */, - /* 4729 */ 0x04d84258 | (18 << 27) /* 0.302797648 */, - /* 4730 */ 0x04d89bde | (18 << 27) /* 0.302883024 */, - /* 4731 */ 0x04d8f566 | (18 << 27) /* 0.302968406 */, - /* 4732 */ 0x04d94eef | (18 << 27) /* 0.303053794 */, - /* 4733 */ 0x04d9a87a | (18 << 27) /* 0.303139189 */, - /* 4734 */ 0x04da0207 | (18 << 27) /* 0.303224589 */, - /* 4735 */ 0x04da5b95 | (18 << 27) /* 0.303309995 */, - - /* 4736 */ 0x04dab524 | (18 << 27) /* 0.303395408 */, - /* 4737 */ 0x04db0eb6 | (18 << 27) /* 0.303480826 */, - /* 4738 */ 0x04db6849 | (18 << 27) /* 0.303566251 */, - /* 4739 */ 0x04dbc1dd | (18 << 27) /* 0.303651681 */, - /* 4740 */ 0x04dc1b73 | (18 << 27) /* 0.303737117 */, - /* 4741 */ 0x04dc750b | (18 << 27) /* 0.303822560 */, - /* 4742 */ 0x04dccea5 | (18 << 27) /* 0.303908008 */, - /* 4743 */ 0x04dd2840 | (18 << 27) /* 0.303993463 */, - /* 4744 */ 0x04dd81dc | (18 << 27) /* 0.304078923 */, - /* 4745 */ 0x04dddb7a | (18 << 27) /* 0.304164390 */, - /* 4746 */ 0x04de351a | (18 << 27) /* 0.304249862 */, - /* 4747 */ 0x04de8ebc | (18 << 27) /* 0.304335340 */, - /* 4748 */ 0x04dee85f | (18 << 27) /* 0.304420825 */, - /* 4749 */ 0x04df4203 | (18 << 27) /* 0.304506315 */, - /* 4750 */ 0x04df9baa | (18 << 27) /* 0.304591812 */, - /* 4751 */ 0x04dff552 | (18 << 27) /* 0.304677314 */, - - /* 4752 */ 0x04e04efb | (18 << 27) /* 0.304762823 */, - /* 4753 */ 0x04e0a8a6 | (18 << 27) /* 0.304848337 */, - /* 4754 */ 0x04e10253 | (18 << 27) /* 0.304933858 */, - /* 4755 */ 0x04e15c01 | (18 << 27) /* 0.305019384 */, - /* 4756 */ 0x04e1b5b1 | (18 << 27) /* 0.305104917 */, - /* 4757 */ 0x04e20f63 | (18 << 27) /* 0.305190455 */, - /* 4758 */ 0x04e26916 | (18 << 27) /* 0.305275999 */, - /* 4759 */ 0x04e2c2cb | (18 << 27) /* 0.305361550 */, - /* 4760 */ 0x04e31c81 | (18 << 27) /* 0.305447106 */, - /* 4761 */ 0x04e37639 | (18 << 27) /* 0.305532669 */, - /* 4762 */ 0x04e3cff3 | (18 << 27) /* 0.305618237 */, - /* 4763 */ 0x04e429ae | (18 << 27) /* 0.305703811 */, - /* 4764 */ 0x04e4836b | (18 << 27) /* 0.305789392 */, - /* 4765 */ 0x04e4dd29 | (18 << 27) /* 0.305874978 */, - /* 4766 */ 0x04e536e9 | (18 << 27) /* 0.305960571 */, - /* 4767 */ 0x04e590ab | (18 << 27) /* 0.306046169 */, - - /* 4768 */ 0x04e5ea6e | (18 << 27) /* 0.306131773 */, - /* 4769 */ 0x04e64433 | (18 << 27) /* 0.306217383 */, - /* 4770 */ 0x04e69df9 | (18 << 27) /* 0.306303000 */, - /* 4771 */ 0x04e6f7c1 | (18 << 27) /* 0.306388622 */, - /* 4772 */ 0x04e7518b | (18 << 27) /* 0.306474250 */, - /* 4773 */ 0x04e7ab56 | (18 << 27) /* 0.306559885 */, - /* 4774 */ 0x04e80523 | (18 << 27) /* 0.306645525 */, - /* 4775 */ 0x04e85ef2 | (18 << 27) /* 0.306731171 */, - /* 4776 */ 0x04e8b8c2 | (18 << 27) /* 0.306816823 */, - /* 4777 */ 0x04e91293 | (18 << 27) /* 0.306902481 */, - /* 4778 */ 0x04e96c67 | (18 << 27) /* 0.306988145 */, - /* 4779 */ 0x04e9c63b | (18 << 27) /* 0.307073816 */, - /* 4780 */ 0x04ea2012 | (18 << 27) /* 0.307159492 */, - /* 4781 */ 0x04ea79ea | (18 << 27) /* 0.307245174 */, - /* 4782 */ 0x04ead3c4 | (18 << 27) /* 0.307330862 */, - /* 4783 */ 0x04eb2d9f | (18 << 27) /* 0.307416556 */, - - /* 4784 */ 0x04eb877c | (18 << 27) /* 0.307502256 */, - /* 4785 */ 0x04ebe15b | (18 << 27) /* 0.307587962 */, - /* 4786 */ 0x04ec3b3b | (18 << 27) /* 0.307673674 */, - /* 4787 */ 0x04ec951c | (18 << 27) /* 0.307759392 */, - /* 4788 */ 0x04ecef00 | (18 << 27) /* 0.307845115 */, - /* 4789 */ 0x04ed48e5 | (18 << 27) /* 0.307930845 */, - /* 4790 */ 0x04eda2cb | (18 << 27) /* 0.308016581 */, - /* 4791 */ 0x04edfcb3 | (18 << 27) /* 0.308102323 */, - /* 4792 */ 0x04ee569d | (18 << 27) /* 0.308188071 */, - /* 4793 */ 0x04eeb088 | (18 << 27) /* 0.308273824 */, - /* 4794 */ 0x04ef0a75 | (18 << 27) /* 0.308359584 */, - /* 4795 */ 0x04ef6464 | (18 << 27) /* 0.308445350 */, - /* 4796 */ 0x04efbe54 | (18 << 27) /* 0.308531121 */, - /* 4797 */ 0x04f01846 | (18 << 27) /* 0.308616899 */, - /* 4798 */ 0x04f07239 | (18 << 27) /* 0.308702682 */, - /* 4799 */ 0x04f0cc2e | (18 << 27) /* 0.308788472 */, - - /* 4800 */ 0x04f12624 | (18 << 27) /* 0.308874267 */, - /* 4801 */ 0x04f1801d | (18 << 27) /* 0.308960068 */, - /* 4802 */ 0x04f1da16 | (18 << 27) /* 0.309045876 */, - /* 4803 */ 0x04f23412 | (18 << 27) /* 0.309131689 */, - /* 4804 */ 0x04f28e0f | (18 << 27) /* 0.309217508 */, - /* 4805 */ 0x04f2e80d | (18 << 27) /* 0.309303334 */, - /* 4806 */ 0x04f3420d | (18 << 27) /* 0.309389165 */, - /* 4807 */ 0x04f39c0f | (18 << 27) /* 0.309475002 */, - /* 4808 */ 0x04f3f612 | (18 << 27) /* 0.309560845 */, - /* 4809 */ 0x04f45017 | (18 << 27) /* 0.309646694 */, - /* 4810 */ 0x04f4aa1e | (18 << 27) /* 0.309732549 */, - /* 4811 */ 0x04f50426 | (18 << 27) /* 0.309818410 */, - /* 4812 */ 0x04f55e30 | (18 << 27) /* 0.309904277 */, - /* 4813 */ 0x04f5b83b | (18 << 27) /* 0.309990150 */, - /* 4814 */ 0x04f61248 | (18 << 27) /* 0.310076028 */, - /* 4815 */ 0x04f66c56 | (18 << 27) /* 0.310161913 */, - - /* 4816 */ 0x04f6c666 | (18 << 27) /* 0.310247804 */, - /* 4817 */ 0x04f72078 | (18 << 27) /* 0.310333700 */, - /* 4818 */ 0x04f77a8b | (18 << 27) /* 0.310419603 */, - /* 4819 */ 0x04f7d4a0 | (18 << 27) /* 0.310505511 */, - /* 4820 */ 0x04f82eb7 | (18 << 27) /* 0.310591426 */, - /* 4821 */ 0x04f888cf | (18 << 27) /* 0.310677346 */, - /* 4822 */ 0x04f8e2e9 | (18 << 27) /* 0.310763272 */, - /* 4823 */ 0x04f93d04 | (18 << 27) /* 0.310849205 */, - /* 4824 */ 0x04f99721 | (18 << 27) /* 0.310935143 */, - /* 4825 */ 0x04f9f13f | (18 << 27) /* 0.311021087 */, - /* 4826 */ 0x04fa4b5f | (18 << 27) /* 0.311107037 */, - /* 4827 */ 0x04faa581 | (18 << 27) /* 0.311192993 */, - /* 4828 */ 0x04faffa4 | (18 << 27) /* 0.311278955 */, - /* 4829 */ 0x04fb59c9 | (18 << 27) /* 0.311364923 */, - /* 4830 */ 0x04fbb3ef | (18 << 27) /* 0.311450897 */, - /* 4831 */ 0x04fc0e17 | (18 << 27) /* 0.311536877 */, - - /* 4832 */ 0x04fc6841 | (18 << 27) /* 0.311622862 */, - /* 4833 */ 0x04fcc26c | (18 << 27) /* 0.311708854 */, - /* 4834 */ 0x04fd1c99 | (18 << 27) /* 0.311794851 */, - /* 4835 */ 0x04fd76c7 | (18 << 27) /* 0.311880855 */, - /* 4836 */ 0x04fdd0f7 | (18 << 27) /* 0.311966864 */, - /* 4837 */ 0x04fe2b29 | (18 << 27) /* 0.312052880 */, - /* 4838 */ 0x04fe855c | (18 << 27) /* 0.312138901 */, - /* 4839 */ 0x04fedf91 | (18 << 27) /* 0.312224928 */, - /* 4840 */ 0x04ff39c7 | (18 << 27) /* 0.312310961 */, - /* 4841 */ 0x04ff93ff | (18 << 27) /* 0.312397000 */, - /* 4842 */ 0x04ffee38 | (18 << 27) /* 0.312483045 */, - /* 4843 */ 0x05004874 | (18 << 27) /* 0.312569096 */, - /* 4844 */ 0x0500a2b0 | (18 << 27) /* 0.312655153 */, - /* 4845 */ 0x0500fcef | (18 << 27) /* 0.312741216 */, - /* 4846 */ 0x0501572e | (18 << 27) /* 0.312827284 */, - /* 4847 */ 0x0501b170 | (18 << 27) /* 0.312913359 */, - - /* 4848 */ 0x05020bb3 | (18 << 27) /* 0.312999439 */, - /* 4849 */ 0x050265f8 | (18 << 27) /* 0.313085526 */, - /* 4850 */ 0x0502c03e | (18 << 27) /* 0.313171618 */, - /* 4851 */ 0x05031a86 | (18 << 27) /* 0.313257716 */, - /* 4852 */ 0x050374cf | (18 << 27) /* 0.313343820 */, - /* 4853 */ 0x0503cf1a | (18 << 27) /* 0.313429931 */, - /* 4854 */ 0x05042967 | (18 << 27) /* 0.313516047 */, - /* 4855 */ 0x050483b5 | (18 << 27) /* 0.313602168 */, - /* 4856 */ 0x0504de05 | (18 << 27) /* 0.313688296 */, - /* 4857 */ 0x05053856 | (18 << 27) /* 0.313774430 */, - /* 4858 */ 0x050592a9 | (18 << 27) /* 0.313860570 */, - /* 4859 */ 0x0505ecfd | (18 << 27) /* 0.313946715 */, - /* 4860 */ 0x05064754 | (18 << 27) /* 0.314032867 */, - /* 4861 */ 0x0506a1ab | (18 << 27) /* 0.314119024 */, - /* 4862 */ 0x0506fc04 | (18 << 27) /* 0.314205187 */, - /* 4863 */ 0x0507565f | (18 << 27) /* 0.314291357 */, - - /* 4864 */ 0x0507b0bc | (18 << 27) /* 0.314377532 */, - /* 4865 */ 0x05080b1a | (18 << 27) /* 0.314463713 */, - /* 4866 */ 0x05086579 | (18 << 27) /* 0.314549900 */, - /* 4867 */ 0x0508bfdb | (18 << 27) /* 0.314636092 */, - /* 4868 */ 0x05091a3d | (18 << 27) /* 0.314722291 */, - /* 4869 */ 0x050974a2 | (18 << 27) /* 0.314808496 */, - /* 4870 */ 0x0509cf08 | (18 << 27) /* 0.314894706 */, - /* 4871 */ 0x050a296f | (18 << 27) /* 0.314980923 */, - /* 4872 */ 0x050a83d8 | (18 << 27) /* 0.315067145 */, - /* 4873 */ 0x050ade43 | (18 << 27) /* 0.315153373 */, - /* 4874 */ 0x050b38af | (18 << 27) /* 0.315239607 */, - /* 4875 */ 0x050b931d | (18 << 27) /* 0.315325847 */, - /* 4876 */ 0x050bed8d | (18 << 27) /* 0.315412093 */, - /* 4877 */ 0x050c47fe | (18 << 27) /* 0.315498345 */, - /* 4878 */ 0x050ca271 | (18 << 27) /* 0.315584603 */, - /* 4879 */ 0x050cfce5 | (18 << 27) /* 0.315670866 */, - - /* 4880 */ 0x050d575b | (18 << 27) /* 0.315757136 */, - /* 4881 */ 0x050db1d2 | (18 << 27) /* 0.315843411 */, - /* 4882 */ 0x050e0c4b | (18 << 27) /* 0.315929693 */, - /* 4883 */ 0x050e66c5 | (18 << 27) /* 0.316015980 */, - /* 4884 */ 0x050ec141 | (18 << 27) /* 0.316102273 */, - /* 4885 */ 0x050f1bbf | (18 << 27) /* 0.316188572 */, - /* 4886 */ 0x050f763e | (18 << 27) /* 0.316274877 */, - /* 4887 */ 0x050fd0bf | (18 << 27) /* 0.316361187 */, - /* 4888 */ 0x05102b42 | (18 << 27) /* 0.316447504 */, - /* 4889 */ 0x051085c6 | (18 << 27) /* 0.316533826 */, - /* 4890 */ 0x0510e04b | (18 << 27) /* 0.316620155 */, - /* 4891 */ 0x05113ad3 | (18 << 27) /* 0.316706489 */, - /* 4892 */ 0x0511955b | (18 << 27) /* 0.316792829 */, - /* 4893 */ 0x0511efe6 | (18 << 27) /* 0.316879175 */, - /* 4894 */ 0x05124a72 | (18 << 27) /* 0.316965527 */, - /* 4895 */ 0x0512a4ff | (18 << 27) /* 0.317051885 */, - - /* 4896 */ 0x0512ff8e | (18 << 27) /* 0.317138249 */, - /* 4897 */ 0x05135a1f | (18 << 27) /* 0.317224618 */, - /* 4898 */ 0x0513b4b1 | (18 << 27) /* 0.317310994 */, - /* 4899 */ 0x05140f45 | (18 << 27) /* 0.317397375 */, - /* 4900 */ 0x051469da | (18 << 27) /* 0.317483762 */, - /* 4901 */ 0x0514c471 | (18 << 27) /* 0.317570155 */, - /* 4902 */ 0x05151f0a | (18 << 27) /* 0.317656554 */, - /* 4903 */ 0x051579a4 | (18 << 27) /* 0.317742959 */, - /* 4904 */ 0x0515d440 | (18 << 27) /* 0.317829370 */, - /* 4905 */ 0x05162edd | (18 << 27) /* 0.317915786 */, - /* 4906 */ 0x0516897c | (18 << 27) /* 0.318002209 */, - /* 4907 */ 0x0516e41c | (18 << 27) /* 0.318088637 */, - /* 4908 */ 0x05173ebe | (18 << 27) /* 0.318175071 */, - /* 4909 */ 0x05179962 | (18 << 27) /* 0.318261511 */, - /* 4910 */ 0x0517f407 | (18 << 27) /* 0.318347957 */, - /* 4911 */ 0x05184eae | (18 << 27) /* 0.318434409 */, - - /* 4912 */ 0x0518a956 | (18 << 27) /* 0.318520867 */, - /* 4913 */ 0x05190400 | (18 << 27) /* 0.318607330 */, - /* 4914 */ 0x05195eab | (18 << 27) /* 0.318693800 */, - /* 4915 */ 0x0519b958 | (18 << 27) /* 0.318780275 */, - /* 4916 */ 0x051a1407 | (18 << 27) /* 0.318866756 */, - /* 4917 */ 0x051a6eb7 | (18 << 27) /* 0.318953243 */, - /* 4918 */ 0x051ac969 | (18 << 27) /* 0.319039736 */, - /* 4919 */ 0x051b241c | (18 << 27) /* 0.319126235 */, - /* 4920 */ 0x051b7ed1 | (18 << 27) /* 0.319212739 */, - /* 4921 */ 0x051bd987 | (18 << 27) /* 0.319299250 */, - /* 4922 */ 0x051c3440 | (18 << 27) /* 0.319385766 */, - /* 4923 */ 0x051c8ef9 | (18 << 27) /* 0.319472288 */, - /* 4924 */ 0x051ce9b4 | (18 << 27) /* 0.319558816 */, - /* 4925 */ 0x051d4471 | (18 << 27) /* 0.319645350 */, - /* 4926 */ 0x051d9f2f | (18 << 27) /* 0.319731890 */, - /* 4927 */ 0x051df9ef | (18 << 27) /* 0.319818435 */, - - /* 4928 */ 0x051e54b1 | (18 << 27) /* 0.319904987 */, - /* 4929 */ 0x051eaf74 | (18 << 27) /* 0.319991544 */, - /* 4930 */ 0x051f0a38 | (18 << 27) /* 0.320078107 */, - /* 4931 */ 0x051f64ff | (18 << 27) /* 0.320164676 */, - /* 4932 */ 0x051fbfc6 | (18 << 27) /* 0.320251251 */, - /* 4933 */ 0x05201a90 | (18 << 27) /* 0.320337832 */, - /* 4934 */ 0x0520755b | (18 << 27) /* 0.320424419 */, - /* 4935 */ 0x0520d027 | (18 << 27) /* 0.320511011 */, - /* 4936 */ 0x05212af5 | (18 << 27) /* 0.320597609 */, - /* 4937 */ 0x052185c5 | (18 << 27) /* 0.320684213 */, - /* 4938 */ 0x0521e096 | (18 << 27) /* 0.320770823 */, - /* 4939 */ 0x05223b69 | (18 << 27) /* 0.320857439 */, - /* 4940 */ 0x0522963d | (18 << 27) /* 0.320944061 */, - /* 4941 */ 0x0522f113 | (18 << 27) /* 0.321030688 */, - /* 4942 */ 0x05234bea | (18 << 27) /* 0.321117322 */, - /* 4943 */ 0x0523a6c3 | (18 << 27) /* 0.321203961 */, - - /* 4944 */ 0x0524019e | (18 << 27) /* 0.321290606 */, - /* 4945 */ 0x05245c7a | (18 << 27) /* 0.321377257 */, - /* 4946 */ 0x0524b758 | (18 << 27) /* 0.321463913 */, - /* 4947 */ 0x05251237 | (18 << 27) /* 0.321550576 */, - /* 4948 */ 0x05256d18 | (18 << 27) /* 0.321637244 */, - /* 4949 */ 0x0525c7fb | (18 << 27) /* 0.321723919 */, - /* 4950 */ 0x052622df | (18 << 27) /* 0.321810599 */, - /* 4951 */ 0x05267dc4 | (18 << 27) /* 0.321897285 */, - /* 4952 */ 0x0526d8ab | (18 << 27) /* 0.321983976 */, - /* 4953 */ 0x05273394 | (18 << 27) /* 0.322070674 */, - /* 4954 */ 0x05278e7e | (18 << 27) /* 0.322157377 */, - /* 4955 */ 0x0527e96a | (18 << 27) /* 0.322244087 */, - /* 4956 */ 0x05284457 | (18 << 27) /* 0.322330802 */, - /* 4957 */ 0x05289f46 | (18 << 27) /* 0.322417523 */, - /* 4958 */ 0x0528fa37 | (18 << 27) /* 0.322504249 */, - /* 4959 */ 0x05295529 | (18 << 27) /* 0.322590982 */, - - /* 4960 */ 0x0529b01d | (18 << 27) /* 0.322677720 */, - /* 4961 */ 0x052a0b12 | (18 << 27) /* 0.322764465 */, - /* 4962 */ 0x052a6609 | (18 << 27) /* 0.322851215 */, - /* 4963 */ 0x052ac101 | (18 << 27) /* 0.322937971 */, - /* 4964 */ 0x052b1bfb | (18 << 27) /* 0.323024732 */, - /* 4965 */ 0x052b76f7 | (18 << 27) /* 0.323111500 */, - /* 4966 */ 0x052bd1f4 | (18 << 27) /* 0.323198273 */, - /* 4967 */ 0x052c2cf2 | (18 << 27) /* 0.323285052 */, - /* 4968 */ 0x052c87f2 | (18 << 27) /* 0.323371837 */, - /* 4969 */ 0x052ce2f4 | (18 << 27) /* 0.323458628 */, - /* 4970 */ 0x052d3df7 | (18 << 27) /* 0.323545425 */, - /* 4971 */ 0x052d98fc | (18 << 27) /* 0.323632227 */, - /* 4972 */ 0x052df403 | (18 << 27) /* 0.323719036 */, - /* 4973 */ 0x052e4f0b | (18 << 27) /* 0.323805850 */, - /* 4974 */ 0x052eaa14 | (18 << 27) /* 0.323892670 */, - /* 4975 */ 0x052f051f | (18 << 27) /* 0.323979496 */, - - /* 4976 */ 0x052f602c | (18 << 27) /* 0.324066327 */, - /* 4977 */ 0x052fbb3a | (18 << 27) /* 0.324153165 */, - /* 4978 */ 0x0530164a | (18 << 27) /* 0.324240008 */, - /* 4979 */ 0x0530715b | (18 << 27) /* 0.324326857 */, - /* 4980 */ 0x0530cc6e | (18 << 27) /* 0.324413712 */, - /* 4981 */ 0x05312783 | (18 << 27) /* 0.324500572 */, - /* 4982 */ 0x05318299 | (18 << 27) /* 0.324587439 */, - /* 4983 */ 0x0531ddb0 | (18 << 27) /* 0.324674311 */, - /* 4984 */ 0x053238ca | (18 << 27) /* 0.324761189 */, - /* 4985 */ 0x053293e4 | (18 << 27) /* 0.324848073 */, - /* 4986 */ 0x0532ef01 | (18 << 27) /* 0.324934963 */, - /* 4987 */ 0x05334a1e | (18 << 27) /* 0.325021858 */, - /* 4988 */ 0x0533a53e | (18 << 27) /* 0.325108760 */, - /* 4989 */ 0x0534005f | (18 << 27) /* 0.325195667 */, - /* 4990 */ 0x05345b81 | (18 << 27) /* 0.325282580 */, - /* 4991 */ 0x0534b6a5 | (18 << 27) /* 0.325369498 */, - - /* 4992 */ 0x053511cb | (18 << 27) /* 0.325456423 */, - /* 4993 */ 0x05356cf2 | (18 << 27) /* 0.325543353 */, - /* 4994 */ 0x0535c81b | (18 << 27) /* 0.325630290 */, - /* 4995 */ 0x05362345 | (18 << 27) /* 0.325717232 */, - /* 4996 */ 0x05367e71 | (18 << 27) /* 0.325804179 */, - /* 4997 */ 0x0536d99f | (18 << 27) /* 0.325891133 */, - /* 4998 */ 0x053734ce | (18 << 27) /* 0.325978092 */, - /* 4999 */ 0x05378ffe | (18 << 27) /* 0.326065057 */, - /* 5000 */ 0x0537eb30 | (18 << 27) /* 0.326152028 */, - /* 5001 */ 0x05384664 | (18 << 27) /* 0.326239005 */, - /* 5002 */ 0x0538a199 | (18 << 27) /* 0.326325988 */, - /* 5003 */ 0x0538fcd0 | (18 << 27) /* 0.326412976 */, - /* 5004 */ 0x05395808 | (18 << 27) /* 0.326499970 */, - /* 5005 */ 0x0539b342 | (18 << 27) /* 0.326586970 */, - /* 5006 */ 0x053a0e7d | (18 << 27) /* 0.326673976 */, - /* 5007 */ 0x053a69ba | (18 << 27) /* 0.326760988 */, - - /* 5008 */ 0x053ac4f9 | (18 << 27) /* 0.326848005 */, - /* 5009 */ 0x053b2039 | (18 << 27) /* 0.326935028 */, - /* 5010 */ 0x053b7b7b | (18 << 27) /* 0.327022057 */, - /* 5011 */ 0x053bd6be | (18 << 27) /* 0.327109092 */, - /* 5012 */ 0x053c3203 | (18 << 27) /* 0.327196132 */, - /* 5013 */ 0x053c8d49 | (18 << 27) /* 0.327283178 */, - /* 5014 */ 0x053ce891 | (18 << 27) /* 0.327370231 */, - /* 5015 */ 0x053d43da | (18 << 27) /* 0.327457288 */, - /* 5016 */ 0x053d9f25 | (18 << 27) /* 0.327544352 */, - /* 5017 */ 0x053dfa72 | (18 << 27) /* 0.327631421 */, - /* 5018 */ 0x053e55c0 | (18 << 27) /* 0.327718497 */, - /* 5019 */ 0x053eb10f | (18 << 27) /* 0.327805578 */, - /* 5020 */ 0x053f0c61 | (18 << 27) /* 0.327892665 */, - /* 5021 */ 0x053f67b3 | (18 << 27) /* 0.327979757 */, - /* 5022 */ 0x053fc308 | (18 << 27) /* 0.328066855 */, - /* 5023 */ 0x05401e5e | (18 << 27) /* 0.328153960 */, - - /* 5024 */ 0x054079b5 | (18 << 27) /* 0.328241070 */, - /* 5025 */ 0x0540d50e | (18 << 27) /* 0.328328185 */, - /* 5026 */ 0x05413068 | (18 << 27) /* 0.328415307 */, - /* 5027 */ 0x05418bc4 | (18 << 27) /* 0.328502434 */, - /* 5028 */ 0x0541e722 | (18 << 27) /* 0.328589567 */, - /* 5029 */ 0x05424281 | (18 << 27) /* 0.328676706 */, - /* 5030 */ 0x05429de2 | (18 << 27) /* 0.328763850 */, - /* 5031 */ 0x0542f944 | (18 << 27) /* 0.328851001 */, - /* 5032 */ 0x054354a8 | (18 << 27) /* 0.328938157 */, - /* 5033 */ 0x0543b00d | (18 << 27) /* 0.329025319 */, - /* 5034 */ 0x05440b74 | (18 << 27) /* 0.329112486 */, - /* 5035 */ 0x054466dd | (18 << 27) /* 0.329199660 */, - /* 5036 */ 0x0544c247 | (18 << 27) /* 0.329286839 */, - /* 5037 */ 0x05451db2 | (18 << 27) /* 0.329374024 */, - /* 5038 */ 0x0545791f | (18 << 27) /* 0.329461215 */, - /* 5039 */ 0x0545d48e | (18 << 27) /* 0.329548411 */, - - /* 5040 */ 0x05462ffe | (18 << 27) /* 0.329635614 */, - /* 5041 */ 0x05468b70 | (18 << 27) /* 0.329722822 */, - /* 5042 */ 0x0546e6e3 | (18 << 27) /* 0.329810036 */, - /* 5043 */ 0x05474258 | (18 << 27) /* 0.329897255 */, - /* 5044 */ 0x05479dce | (18 << 27) /* 0.329984481 */, - /* 5045 */ 0x0547f946 | (18 << 27) /* 0.330071712 */, - /* 5046 */ 0x054854c0 | (18 << 27) /* 0.330158949 */, - /* 5047 */ 0x0548b03b | (18 << 27) /* 0.330246191 */, - /* 5048 */ 0x05490bb7 | (18 << 27) /* 0.330333440 */, - /* 5049 */ 0x05496735 | (18 << 27) /* 0.330420694 */, - /* 5050 */ 0x0549c2b5 | (18 << 27) /* 0.330507954 */, - /* 5051 */ 0x054a1e36 | (18 << 27) /* 0.330595220 */, - /* 5052 */ 0x054a79b9 | (18 << 27) /* 0.330682491 */, - /* 5053 */ 0x054ad53d | (18 << 27) /* 0.330769768 */, - /* 5054 */ 0x054b30c3 | (18 << 27) /* 0.330857051 */, - /* 5055 */ 0x054b8c4b | (18 << 27) /* 0.330944340 */, - - /* 5056 */ 0x054be7d4 | (18 << 27) /* 0.331031635 */, - /* 5057 */ 0x054c435e | (18 << 27) /* 0.331118935 */, - /* 5058 */ 0x054c9eea | (18 << 27) /* 0.331206241 */, - /* 5059 */ 0x054cfa78 | (18 << 27) /* 0.331293553 */, - /* 5060 */ 0x054d5607 | (18 << 27) /* 0.331380870 */, - /* 5061 */ 0x054db197 | (18 << 27) /* 0.331468193 */, - /* 5062 */ 0x054e0d2a | (18 << 27) /* 0.331555522 */, - /* 5063 */ 0x054e68bd | (18 << 27) /* 0.331642857 */, - /* 5064 */ 0x054ec453 | (18 << 27) /* 0.331730198 */, - /* 5065 */ 0x054f1fe9 | (18 << 27) /* 0.331817544 */, - /* 5066 */ 0x054f7b82 | (18 << 27) /* 0.331904896 */, - /* 5067 */ 0x054fd71c | (18 << 27) /* 0.331992254 */, - /* 5068 */ 0x055032b7 | (18 << 27) /* 0.332079617 */, - /* 5069 */ 0x05508e54 | (18 << 27) /* 0.332166986 */, - /* 5070 */ 0x0550e9f3 | (18 << 27) /* 0.332254361 */, - /* 5071 */ 0x05514593 | (18 << 27) /* 0.332341742 */, - - /* 5072 */ 0x0551a134 | (18 << 27) /* 0.332429129 */, - /* 5073 */ 0x0551fcd8 | (18 << 27) /* 0.332516521 */, - /* 5074 */ 0x0552587c | (18 << 27) /* 0.332603919 */, - /* 5075 */ 0x0552b423 | (18 << 27) /* 0.332691323 */, - /* 5076 */ 0x05530fca | (18 << 27) /* 0.332778732 */, - /* 5077 */ 0x05536b74 | (18 << 27) /* 0.332866147 */, - /* 5078 */ 0x0553c71f | (18 << 27) /* 0.332953568 */, - /* 5079 */ 0x055422cb | (18 << 27) /* 0.333040995 */, - /* 5080 */ 0x05547e79 | (18 << 27) /* 0.333128427 */, - /* 5081 */ 0x0554da29 | (18 << 27) /* 0.333215865 */, - /* 5082 */ 0x055535da | (18 << 27) /* 0.333303309 */, - /* 5083 */ 0x0555918c | (18 << 27) /* 0.333390759 */, - /* 5084 */ 0x0555ed40 | (18 << 27) /* 0.333478214 */, - /* 5085 */ 0x055648f6 | (18 << 27) /* 0.333565675 */, - /* 5086 */ 0x0556a4ad | (18 << 27) /* 0.333653142 */, - /* 5087 */ 0x05570066 | (18 << 27) /* 0.333740615 */, - - /* 5088 */ 0x05575c20 | (18 << 27) /* 0.333828093 */, - /* 5089 */ 0x0557b7dc | (18 << 27) /* 0.333915577 */, - /* 5090 */ 0x05581399 | (18 << 27) /* 0.334003067 */, - /* 5091 */ 0x05586f58 | (18 << 27) /* 0.334090562 */, - /* 5092 */ 0x0558cb19 | (18 << 27) /* 0.334178063 */, - /* 5093 */ 0x055926db | (18 << 27) /* 0.334265570 */, - /* 5094 */ 0x0559829e | (18 << 27) /* 0.334353083 */, - /* 5095 */ 0x0559de63 | (18 << 27) /* 0.334440601 */, - /* 5096 */ 0x055a3a2a | (18 << 27) /* 0.334528126 */, - /* 5097 */ 0x055a95f2 | (18 << 27) /* 0.334615655 */, - /* 5098 */ 0x055af1bb | (18 << 27) /* 0.334703191 */, - /* 5099 */ 0x055b4d87 | (18 << 27) /* 0.334790732 */, - /* 5100 */ 0x055ba953 | (18 << 27) /* 0.334878279 */, - /* 5101 */ 0x055c0522 | (18 << 27) /* 0.334965832 */, - /* 5102 */ 0x055c60f1 | (18 << 27) /* 0.335053391 */, - /* 5103 */ 0x055cbcc3 | (18 << 27) /* 0.335140955 */, - - /* 5104 */ 0x055d1896 | (18 << 27) /* 0.335228525 */, - /* 5105 */ 0x055d746a | (18 << 27) /* 0.335316100 */, - /* 5106 */ 0x055dd040 | (18 << 27) /* 0.335403682 */, - /* 5107 */ 0x055e2c17 | (18 << 27) /* 0.335491269 */, - /* 5108 */ 0x055e87f0 | (18 << 27) /* 0.335578861 */, - /* 5109 */ 0x055ee3cb | (18 << 27) /* 0.335666460 */, - /* 5110 */ 0x055f3fa7 | (18 << 27) /* 0.335754064 */, - /* 5111 */ 0x055f9b85 | (18 << 27) /* 0.335841674 */, - /* 5112 */ 0x055ff764 | (18 << 27) /* 0.335929290 */, - /* 5113 */ 0x05605344 | (18 << 27) /* 0.336016911 */, - /* 5114 */ 0x0560af27 | (18 << 27) /* 0.336104538 */, - /* 5115 */ 0x05610b0a | (18 << 27) /* 0.336192171 */, - /* 5116 */ 0x056166f0 | (18 << 27) /* 0.336279809 */, - /* 5117 */ 0x0561c2d7 | (18 << 27) /* 0.336367453 */, - /* 5118 */ 0x05621ebf | (18 << 27) /* 0.336455103 */, - /* 5119 */ 0x05627aa9 | (18 << 27) /* 0.336542759 */, - - /* 5120 */ 0x0562d694 | (18 << 27) /* 0.336630420 */, - /* 5121 */ 0x05633281 | (18 << 27) /* 0.336718087 */, - /* 5122 */ 0x05638e70 | (18 << 27) /* 0.336805760 */, - /* 5123 */ 0x0563ea60 | (18 << 27) /* 0.336893439 */, - /* 5124 */ 0x05644651 | (18 << 27) /* 0.336981123 */, - /* 5125 */ 0x0564a244 | (18 << 27) /* 0.337068813 */, - /* 5126 */ 0x0564fe39 | (18 << 27) /* 0.337156508 */, - /* 5127 */ 0x05655a2f | (18 << 27) /* 0.337244209 */, - /* 5128 */ 0x0565b627 | (18 << 27) /* 0.337331916 */, - /* 5129 */ 0x05661220 | (18 << 27) /* 0.337419629 */, - /* 5130 */ 0x05666e1a | (18 << 27) /* 0.337507347 */, - /* 5131 */ 0x0566ca17 | (18 << 27) /* 0.337595071 */, - /* 5132 */ 0x05672614 | (18 << 27) /* 0.337682801 */, - /* 5133 */ 0x05678214 | (18 << 27) /* 0.337770537 */, - /* 5134 */ 0x0567de15 | (18 << 27) /* 0.337858278 */, - /* 5135 */ 0x05683a17 | (18 << 27) /* 0.337946025 */, - - /* 5136 */ 0x0568961b | (18 << 27) /* 0.338033777 */, - /* 5137 */ 0x0568f220 | (18 << 27) /* 0.338121535 */, - /* 5138 */ 0x05694e27 | (18 << 27) /* 0.338209299 */, - /* 5139 */ 0x0569aa30 | (18 << 27) /* 0.338297069 */, - /* 5140 */ 0x056a063a | (18 << 27) /* 0.338384844 */, - /* 5141 */ 0x056a6245 | (18 << 27) /* 0.338472625 */, - /* 5142 */ 0x056abe52 | (18 << 27) /* 0.338560412 */, - /* 5143 */ 0x056b1a61 | (18 << 27) /* 0.338648204 */, - /* 5144 */ 0x056b7671 | (18 << 27) /* 0.338736002 */, - /* 5145 */ 0x056bd283 | (18 << 27) /* 0.338823806 */, - /* 5146 */ 0x056c2e96 | (18 << 27) /* 0.338911616 */, - /* 5147 */ 0x056c8aab | (18 << 27) /* 0.338999431 */, - /* 5148 */ 0x056ce6c1 | (18 << 27) /* 0.339087252 */, - /* 5149 */ 0x056d42d9 | (18 << 27) /* 0.339175078 */, - /* 5150 */ 0x056d9ef2 | (18 << 27) /* 0.339262910 */, - /* 5151 */ 0x056dfb0d | (18 << 27) /* 0.339350748 */, - - /* 5152 */ 0x056e5729 | (18 << 27) /* 0.339438592 */, - /* 5153 */ 0x056eb347 | (18 << 27) /* 0.339526441 */, - /* 5154 */ 0x056f0f66 | (18 << 27) /* 0.339614296 */, - /* 5155 */ 0x056f6b87 | (18 << 27) /* 0.339702157 */, - /* 5156 */ 0x056fc7aa | (18 << 27) /* 0.339790023 */, - /* 5157 */ 0x057023cd | (18 << 27) /* 0.339877895 */, - /* 5158 */ 0x05707ff3 | (18 << 27) /* 0.339965773 */, - /* 5159 */ 0x0570dc1a | (18 << 27) /* 0.340053656 */, - /* 5160 */ 0x05713843 | (18 << 27) /* 0.340141545 */, - /* 5161 */ 0x0571946d | (18 << 27) /* 0.340229440 */, - /* 5162 */ 0x0571f098 | (18 << 27) /* 0.340317340 */, - /* 5163 */ 0x05724cc5 | (18 << 27) /* 0.340405246 */, - /* 5164 */ 0x0572a8f4 | (18 << 27) /* 0.340493158 */, - /* 5165 */ 0x05730524 | (18 << 27) /* 0.340581075 */, - /* 5166 */ 0x05736156 | (18 << 27) /* 0.340668999 */, - /* 5167 */ 0x0573bd89 | (18 << 27) /* 0.340756927 */, - - /* 5168 */ 0x057419be | (18 << 27) /* 0.340844862 */, - /* 5169 */ 0x057475f4 | (18 << 27) /* 0.340932802 */, - /* 5170 */ 0x0574d22c | (18 << 27) /* 0.341020748 */, - /* 5171 */ 0x05752e65 | (18 << 27) /* 0.341108699 */, - /* 5172 */ 0x05758aa0 | (18 << 27) /* 0.341196656 */, - /* 5173 */ 0x0575e6dc | (18 << 27) /* 0.341284619 */, - /* 5174 */ 0x0576431a | (18 << 27) /* 0.341372587 */, - /* 5175 */ 0x05769f59 | (18 << 27) /* 0.341460562 */, - /* 5176 */ 0x0576fb9a | (18 << 27) /* 0.341548541 */, - /* 5177 */ 0x057757dd | (18 << 27) /* 0.341636527 */, - /* 5178 */ 0x0577b421 | (18 << 27) /* 0.341724518 */, - /* 5179 */ 0x05781066 | (18 << 27) /* 0.341812515 */, - /* 5180 */ 0x05786cad | (18 << 27) /* 0.341900517 */, - /* 5181 */ 0x0578c8f5 | (18 << 27) /* 0.341988525 */, - /* 5182 */ 0x0579253f | (18 << 27) /* 0.342076539 */, - /* 5183 */ 0x0579818b | (18 << 27) /* 0.342164558 */, - - /* 5184 */ 0x0579ddd8 | (18 << 27) /* 0.342252584 */, - /* 5185 */ 0x057a3a27 | (18 << 27) /* 0.342340614 */, - /* 5186 */ 0x057a9677 | (18 << 27) /* 0.342428651 */, - /* 5187 */ 0x057af2c8 | (18 << 27) /* 0.342516693 */, - /* 5188 */ 0x057b4f1c | (18 << 27) /* 0.342604741 */, - /* 5189 */ 0x057bab70 | (18 << 27) /* 0.342692794 */, - /* 5190 */ 0x057c07c6 | (18 << 27) /* 0.342780853 */, - /* 5191 */ 0x057c641e | (18 << 27) /* 0.342868918 */, - /* 5192 */ 0x057cc077 | (18 << 27) /* 0.342956988 */, - /* 5193 */ 0x057d1cd2 | (18 << 27) /* 0.343045064 */, - /* 5194 */ 0x057d792e | (18 << 27) /* 0.343133146 */, - /* 5195 */ 0x057dd58c | (18 << 27) /* 0.343221233 */, - /* 5196 */ 0x057e31eb | (18 << 27) /* 0.343309326 */, - /* 5197 */ 0x057e8e4c | (18 << 27) /* 0.343397425 */, - /* 5198 */ 0x057eeaae | (18 << 27) /* 0.343485529 */, - /* 5199 */ 0x057f4712 | (18 << 27) /* 0.343573639 */, - - /* 5200 */ 0x057fa378 | (18 << 27) /* 0.343661754 */, - /* 5201 */ 0x057fffde | (18 << 27) /* 0.343749876 */, - /* 5202 */ 0x05805c47 | (18 << 27) /* 0.343838003 */, - /* 5203 */ 0x0580b8b1 | (18 << 27) /* 0.343926135 */, - /* 5204 */ 0x0581151c | (18 << 27) /* 0.344014273 */, - /* 5205 */ 0x05817189 | (18 << 27) /* 0.344102417 */, - /* 5206 */ 0x0581cdf7 | (18 << 27) /* 0.344190566 */, - /* 5207 */ 0x05822a67 | (18 << 27) /* 0.344278722 */, - /* 5208 */ 0x058286d9 | (18 << 27) /* 0.344366882 */, - /* 5209 */ 0x0582e34c | (18 << 27) /* 0.344455049 */, - /* 5210 */ 0x05833fc0 | (18 << 27) /* 0.344543221 */, - /* 5211 */ 0x05839c36 | (18 << 27) /* 0.344631398 */, - /* 5212 */ 0x0583f8ae | (18 << 27) /* 0.344719582 */, - /* 5213 */ 0x05845527 | (18 << 27) /* 0.344807771 */, - /* 5214 */ 0x0584b1a1 | (18 << 27) /* 0.344895965 */, - /* 5215 */ 0x05850e1e | (18 << 27) /* 0.344984165 */, - - /* 5216 */ 0x05856a9b | (18 << 27) /* 0.345072371 */, - /* 5217 */ 0x0585c71a | (18 << 27) /* 0.345160583 */, - /* 5218 */ 0x0586239b | (18 << 27) /* 0.345248800 */, - /* 5219 */ 0x0586801d | (18 << 27) /* 0.345337023 */, - /* 5220 */ 0x0586dca1 | (18 << 27) /* 0.345425251 */, - /* 5221 */ 0x05873926 | (18 << 27) /* 0.345513485 */, - /* 5222 */ 0x058795ac | (18 << 27) /* 0.345601725 */, - /* 5223 */ 0x0587f235 | (18 << 27) /* 0.345689970 */, - /* 5224 */ 0x05884ebe | (18 << 27) /* 0.345778221 */, - /* 5225 */ 0x0588ab49 | (18 << 27) /* 0.345866478 */, - /* 5226 */ 0x058907d6 | (18 << 27) /* 0.345954740 */, - /* 5227 */ 0x05896464 | (18 << 27) /* 0.346043008 */, - /* 5228 */ 0x0589c0f4 | (18 << 27) /* 0.346131281 */, - /* 5229 */ 0x058a1d85 | (18 << 27) /* 0.346219560 */, - /* 5230 */ 0x058a7a18 | (18 << 27) /* 0.346307845 */, - /* 5231 */ 0x058ad6ac | (18 << 27) /* 0.346396135 */, - - /* 5232 */ 0x058b3342 | (18 << 27) /* 0.346484431 */, - /* 5233 */ 0x058b8fd9 | (18 << 27) /* 0.346572733 */, - /* 5234 */ 0x058bec72 | (18 << 27) /* 0.346661040 */, - /* 5235 */ 0x058c490c | (18 << 27) /* 0.346749353 */, - /* 5236 */ 0x058ca5a8 | (18 << 27) /* 0.346837671 */, - /* 5237 */ 0x058d0246 | (18 << 27) /* 0.346925996 */, - /* 5238 */ 0x058d5ee4 | (18 << 27) /* 0.347014325 */, - /* 5239 */ 0x058dbb85 | (18 << 27) /* 0.347102661 */, - /* 5240 */ 0x058e1827 | (18 << 27) /* 0.347191002 */, - /* 5241 */ 0x058e74ca | (18 << 27) /* 0.347279348 */, - /* 5242 */ 0x058ed16f | (18 << 27) /* 0.347367700 */, - /* 5243 */ 0x058f2e15 | (18 << 27) /* 0.347456058 */, - /* 5244 */ 0x058f8abd | (18 << 27) /* 0.347544422 */, - /* 5245 */ 0x058fe766 | (18 << 27) /* 0.347632791 */, - /* 5246 */ 0x05904411 | (18 << 27) /* 0.347721165 */, - /* 5247 */ 0x0590a0be | (18 << 27) /* 0.347809546 */, - - /* 5248 */ 0x0590fd6c | (18 << 27) /* 0.347897931 */, - /* 5249 */ 0x05915a1b | (18 << 27) /* 0.347986323 */, - /* 5250 */ 0x0591b6cc | (18 << 27) /* 0.348074720 */, - /* 5251 */ 0x0592137e | (18 << 27) /* 0.348163123 */, - /* 5252 */ 0x05927032 | (18 << 27) /* 0.348251531 */, - /* 5253 */ 0x0592cce8 | (18 << 27) /* 0.348339945 */, - /* 5254 */ 0x0593299f | (18 << 27) /* 0.348428365 */, - /* 5255 */ 0x05938657 | (18 << 27) /* 0.348516790 */, - /* 5256 */ 0x0593e311 | (18 << 27) /* 0.348605221 */, - /* 5257 */ 0x05943fcd | (18 << 27) /* 0.348693657 */, - /* 5258 */ 0x05949c8a | (18 << 27) /* 0.348782099 */, - /* 5259 */ 0x0594f948 | (18 << 27) /* 0.348870547 */, - /* 5260 */ 0x05955608 | (18 << 27) /* 0.348959000 */, - /* 5261 */ 0x0595b2ca | (18 << 27) /* 0.349047459 */, - /* 5262 */ 0x05960f8c | (18 << 27) /* 0.349135923 */, - /* 5263 */ 0x05966c51 | (18 << 27) /* 0.349224393 */, - - /* 5264 */ 0x0596c917 | (18 << 27) /* 0.349312869 */, - /* 5265 */ 0x059725de | (18 << 27) /* 0.349401350 */, - /* 5266 */ 0x059782a7 | (18 << 27) /* 0.349489837 */, - /* 5267 */ 0x0597df72 | (18 << 27) /* 0.349578329 */, - /* 5268 */ 0x05983c3e | (18 << 27) /* 0.349666827 */, - /* 5269 */ 0x0598990c | (18 << 27) /* 0.349755331 */, - /* 5270 */ 0x0598f5db | (18 << 27) /* 0.349843840 */, - /* 5271 */ 0x059952ab | (18 << 27) /* 0.349932355 */, - /* 5272 */ 0x0599af7d | (18 << 27) /* 0.350020876 */, - /* 5273 */ 0x059a0c51 | (18 << 27) /* 0.350109402 */, - /* 5274 */ 0x059a6926 | (18 << 27) /* 0.350197933 */, - /* 5275 */ 0x059ac5fc | (18 << 27) /* 0.350286470 */, - /* 5276 */ 0x059b22d4 | (18 << 27) /* 0.350375013 */, - /* 5277 */ 0x059b7fae | (18 << 27) /* 0.350463562 */, - /* 5278 */ 0x059bdc89 | (18 << 27) /* 0.350552116 */, - /* 5279 */ 0x059c3965 | (18 << 27) /* 0.350640675 */, - - /* 5280 */ 0x059c9643 | (18 << 27) /* 0.350729240 */, - /* 5281 */ 0x059cf323 | (18 << 27) /* 0.350817811 */, - /* 5282 */ 0x059d5004 | (18 << 27) /* 0.350906388 */, - /* 5283 */ 0x059dace6 | (18 << 27) /* 0.350994970 */, - /* 5284 */ 0x059e09cb | (18 << 27) /* 0.351083557 */, - /* 5285 */ 0x059e66b0 | (18 << 27) /* 0.351172150 */, - /* 5286 */ 0x059ec397 | (18 << 27) /* 0.351260749 */, - /* 5287 */ 0x059f2080 | (18 << 27) /* 0.351349353 */, - /* 5288 */ 0x059f7d6a | (18 << 27) /* 0.351437963 */, - /* 5289 */ 0x059fda55 | (18 << 27) /* 0.351526579 */, - /* 5290 */ 0x05a03742 | (18 << 27) /* 0.351615200 */, - /* 5291 */ 0x05a09431 | (18 << 27) /* 0.351703827 */, - /* 5292 */ 0x05a0f121 | (18 << 27) /* 0.351792459 */, - /* 5293 */ 0x05a14e12 | (18 << 27) /* 0.351881097 */, - /* 5294 */ 0x05a1ab05 | (18 << 27) /* 0.351969740 */, - /* 5295 */ 0x05a207fa | (18 << 27) /* 0.352058389 */, - - /* 5296 */ 0x05a264f0 | (18 << 27) /* 0.352147044 */, - /* 5297 */ 0x05a2c1e7 | (18 << 27) /* 0.352235704 */, - /* 5298 */ 0x05a31ee1 | (18 << 27) /* 0.352324369 */, - /* 5299 */ 0x05a37bdb | (18 << 27) /* 0.352413041 */, - /* 5300 */ 0x05a3d8d7 | (18 << 27) /* 0.352501718 */, - /* 5301 */ 0x05a435d5 | (18 << 27) /* 0.352590400 */, - /* 5302 */ 0x05a492d4 | (18 << 27) /* 0.352679088 */, - /* 5303 */ 0x05a4efd4 | (18 << 27) /* 0.352767782 */, - /* 5304 */ 0x05a54cd6 | (18 << 27) /* 0.352856481 */, - /* 5305 */ 0x05a5a9da | (18 << 27) /* 0.352945186 */, - /* 5306 */ 0x05a606df | (18 << 27) /* 0.353033896 */, - /* 5307 */ 0x05a663e5 | (18 << 27) /* 0.353122612 */, - /* 5308 */ 0x05a6c0ed | (18 << 27) /* 0.353211333 */, - /* 5309 */ 0x05a71df7 | (18 << 27) /* 0.353300061 */, - /* 5310 */ 0x05a77b02 | (18 << 27) /* 0.353388793 */, - /* 5311 */ 0x05a7d80e | (18 << 27) /* 0.353477531 */, - - /* 5312 */ 0x05a8351c | (18 << 27) /* 0.353566275 */, - /* 5313 */ 0x05a8922c | (18 << 27) /* 0.353655024 */, - /* 5314 */ 0x05a8ef3c | (18 << 27) /* 0.353743779 */, - /* 5315 */ 0x05a94c4f | (18 << 27) /* 0.353832540 */, - /* 5316 */ 0x05a9a963 | (18 << 27) /* 0.353921306 */, - /* 5317 */ 0x05aa0678 | (18 << 27) /* 0.354010077 */, - /* 5318 */ 0x05aa638f | (18 << 27) /* 0.354098855 */, - /* 5319 */ 0x05aac0a8 | (18 << 27) /* 0.354187637 */, - /* 5320 */ 0x05ab1dc2 | (18 << 27) /* 0.354276426 */, - /* 5321 */ 0x05ab7add | (18 << 27) /* 0.354365220 */, - /* 5322 */ 0x05abd7fa | (18 << 27) /* 0.354454019 */, - /* 5323 */ 0x05ac3518 | (18 << 27) /* 0.354542824 */, - /* 5324 */ 0x05ac9238 | (18 << 27) /* 0.354631635 */, - /* 5325 */ 0x05acef5a | (18 << 27) /* 0.354720451 */, - /* 5326 */ 0x05ad4c7d | (18 << 27) /* 0.354809272 */, - /* 5327 */ 0x05ada9a1 | (18 << 27) /* 0.354898100 */, - - /* 5328 */ 0x05ae06c7 | (18 << 27) /* 0.354986932 */, - /* 5329 */ 0x05ae63ee | (18 << 27) /* 0.355075771 */, - /* 5330 */ 0x05aec117 | (18 << 27) /* 0.355164615 */, - /* 5331 */ 0x05af1e41 | (18 << 27) /* 0.355253464 */, - /* 5332 */ 0x05af7b6d | (18 << 27) /* 0.355342319 */, - /* 5333 */ 0x05afd89b | (18 << 27) /* 0.355431180 */, - /* 5334 */ 0x05b035c9 | (18 << 27) /* 0.355520046 */, - /* 5335 */ 0x05b092fa | (18 << 27) /* 0.355608917 */, - /* 5336 */ 0x05b0f02b | (18 << 27) /* 0.355697795 */, - /* 5337 */ 0x05b14d5f | (18 << 27) /* 0.355786677 */, - /* 5338 */ 0x05b1aa94 | (18 << 27) /* 0.355875566 */, - /* 5339 */ 0x05b207ca | (18 << 27) /* 0.355964460 */, - /* 5340 */ 0x05b26502 | (18 << 27) /* 0.356053359 */, - /* 5341 */ 0x05b2c23b | (18 << 27) /* 0.356142264 */, - /* 5342 */ 0x05b31f76 | (18 << 27) /* 0.356231175 */, - /* 5343 */ 0x05b37cb2 | (18 << 27) /* 0.356320091 */, - - /* 5344 */ 0x05b3d9f0 | (18 << 27) /* 0.356409012 */, - /* 5345 */ 0x05b4372f | (18 << 27) /* 0.356497940 */, - /* 5346 */ 0x05b4946f | (18 << 27) /* 0.356586872 */, - /* 5347 */ 0x05b4f1b2 | (18 << 27) /* 0.356675811 */, - /* 5348 */ 0x05b54ef5 | (18 << 27) /* 0.356764754 */, - /* 5349 */ 0x05b5ac3a | (18 << 27) /* 0.356853704 */, - /* 5350 */ 0x05b60981 | (18 << 27) /* 0.356942659 */, - /* 5351 */ 0x05b666c9 | (18 << 27) /* 0.357031619 */, - /* 5352 */ 0x05b6c413 | (18 << 27) /* 0.357120585 */, - /* 5353 */ 0x05b7215e | (18 << 27) /* 0.357209557 */, - /* 5354 */ 0x05b77eab | (18 << 27) /* 0.357298534 */, - /* 5355 */ 0x05b7dbf9 | (18 << 27) /* 0.357387516 */, - /* 5356 */ 0x05b83948 | (18 << 27) /* 0.357476504 */, - /* 5357 */ 0x05b89699 | (18 << 27) /* 0.357565498 */, - /* 5358 */ 0x05b8f3ec | (18 << 27) /* 0.357654497 */, - /* 5359 */ 0x05b95140 | (18 << 27) /* 0.357743502 */, - - /* 5360 */ 0x05b9ae95 | (18 << 27) /* 0.357832512 */, - /* 5361 */ 0x05ba0bec | (18 << 27) /* 0.357921528 */, - /* 5362 */ 0x05ba6945 | (18 << 27) /* 0.358010550 */, - /* 5363 */ 0x05bac69f | (18 << 27) /* 0.358099576 */, - /* 5364 */ 0x05bb23fa | (18 << 27) /* 0.358188609 */, - /* 5365 */ 0x05bb8157 | (18 << 27) /* 0.358277647 */, - /* 5366 */ 0x05bbdeb6 | (18 << 27) /* 0.358366690 */, - /* 5367 */ 0x05bc3c16 | (18 << 27) /* 0.358455739 */, - /* 5368 */ 0x05bc9977 | (18 << 27) /* 0.358544794 */, - /* 5369 */ 0x05bcf6da | (18 << 27) /* 0.358633854 */, - /* 5370 */ 0x05bd543e | (18 << 27) /* 0.358722920 */, - /* 5371 */ 0x05bdb1a4 | (18 << 27) /* 0.358811991 */, - /* 5372 */ 0x05be0f0b | (18 << 27) /* 0.358901067 */, - /* 5373 */ 0x05be6c74 | (18 << 27) /* 0.358990150 */, - /* 5374 */ 0x05bec9df | (18 << 27) /* 0.359079237 */, - /* 5375 */ 0x05bf274a | (18 << 27) /* 0.359168331 */, - - /* 5376 */ 0x05bf84b8 | (18 << 27) /* 0.359257429 */, - /* 5377 */ 0x05bfe226 | (18 << 27) /* 0.359346534 */, - /* 5378 */ 0x05c03f97 | (18 << 27) /* 0.359435644 */, - /* 5379 */ 0x05c09d08 | (18 << 27) /* 0.359524759 */, - /* 5380 */ 0x05c0fa7c | (18 << 27) /* 0.359613880 */, - /* 5381 */ 0x05c157f0 | (18 << 27) /* 0.359703006 */, - /* 5382 */ 0x05c1b566 | (18 << 27) /* 0.359792138 */, - /* 5383 */ 0x05c212de | (18 << 27) /* 0.359881276 */, - /* 5384 */ 0x05c27057 | (18 << 27) /* 0.359970419 */, - /* 5385 */ 0x05c2cdd2 | (18 << 27) /* 0.360059567 */, - /* 5386 */ 0x05c32b4e | (18 << 27) /* 0.360148721 */, - /* 5387 */ 0x05c388cb | (18 << 27) /* 0.360237881 */, - /* 5388 */ 0x05c3e64b | (18 << 27) /* 0.360327046 */, - /* 5389 */ 0x05c443cb | (18 << 27) /* 0.360416216 */, - /* 5390 */ 0x05c4a14d | (18 << 27) /* 0.360505392 */, - /* 5391 */ 0x05c4fed1 | (18 << 27) /* 0.360594574 */, - - /* 5392 */ 0x05c55c56 | (18 << 27) /* 0.360683761 */, - /* 5393 */ 0x05c5b9dc | (18 << 27) /* 0.360772953 */, - /* 5394 */ 0x05c61764 | (18 << 27) /* 0.360862152 */, - /* 5395 */ 0x05c674ed | (18 << 27) /* 0.360951355 */, - /* 5396 */ 0x05c6d278 | (18 << 27) /* 0.361040564 */, - /* 5397 */ 0x05c73005 | (18 << 27) /* 0.361129779 */, - /* 5398 */ 0x05c78d93 | (18 << 27) /* 0.361218999 */, - /* 5399 */ 0x05c7eb22 | (18 << 27) /* 0.361308225 */, - /* 5400 */ 0x05c848b3 | (18 << 27) /* 0.361397456 */, - /* 5401 */ 0x05c8a645 | (18 << 27) /* 0.361486693 */, - /* 5402 */ 0x05c903d9 | (18 << 27) /* 0.361575935 */, - /* 5403 */ 0x05c9616e | (18 << 27) /* 0.361665183 */, - /* 5404 */ 0x05c9bf05 | (18 << 27) /* 0.361754436 */, - /* 5405 */ 0x05ca1c9d | (18 << 27) /* 0.361843695 */, - /* 5406 */ 0x05ca7a37 | (18 << 27) /* 0.361932959 */, - /* 5407 */ 0x05cad7d2 | (18 << 27) /* 0.362022229 */, - - /* 5408 */ 0x05cb356e | (18 << 27) /* 0.362111504 */, - /* 5409 */ 0x05cb930d | (18 << 27) /* 0.362200785 */, - /* 5410 */ 0x05cbf0ac | (18 << 27) /* 0.362290071 */, - /* 5411 */ 0x05cc4e4d | (18 << 27) /* 0.362379362 */, - /* 5412 */ 0x05ccabf0 | (18 << 27) /* 0.362468660 */, - /* 5413 */ 0x05cd0994 | (18 << 27) /* 0.362557962 */, - /* 5414 */ 0x05cd6739 | (18 << 27) /* 0.362647271 */, - /* 5415 */ 0x05cdc4e0 | (18 << 27) /* 0.362736584 */, - /* 5416 */ 0x05ce2289 | (18 << 27) /* 0.362825904 */, - /* 5417 */ 0x05ce8033 | (18 << 27) /* 0.362915228 */, - /* 5418 */ 0x05ceddde | (18 << 27) /* 0.363004559 */, - /* 5419 */ 0x05cf3b8b | (18 << 27) /* 0.363093894 */, - /* 5420 */ 0x05cf9939 | (18 << 27) /* 0.363183236 */, - /* 5421 */ 0x05cff6e9 | (18 << 27) /* 0.363272582 */, - /* 5422 */ 0x05d0549a | (18 << 27) /* 0.363361935 */, - /* 5423 */ 0x05d0b24d | (18 << 27) /* 0.363451292 */, - - /* 5424 */ 0x05d11001 | (18 << 27) /* 0.363540655 */, - /* 5425 */ 0x05d16db7 | (18 << 27) /* 0.363630024 */, - /* 5426 */ 0x05d1cb6e | (18 << 27) /* 0.363719398 */, - /* 5427 */ 0x05d22927 | (18 << 27) /* 0.363808778 */, - /* 5428 */ 0x05d286e1 | (18 << 27) /* 0.363898163 */, - /* 5429 */ 0x05d2e49d | (18 << 27) /* 0.363987554 */, - /* 5430 */ 0x05d3425a | (18 << 27) /* 0.364076950 */, - /* 5431 */ 0x05d3a018 | (18 << 27) /* 0.364166352 */, - /* 5432 */ 0x05d3fdd8 | (18 << 27) /* 0.364255759 */, - /* 5433 */ 0x05d45b9a | (18 << 27) /* 0.364345171 */, - /* 5434 */ 0x05d4b95d | (18 << 27) /* 0.364434589 */, - /* 5435 */ 0x05d51721 | (18 << 27) /* 0.364524013 */, - /* 5436 */ 0x05d574e7 | (18 << 27) /* 0.364613442 */, - /* 5437 */ 0x05d5d2af | (18 << 27) /* 0.364702877 */, - /* 5438 */ 0x05d63078 | (18 << 27) /* 0.364792317 */, - /* 5439 */ 0x05d68e42 | (18 << 27) /* 0.364881762 */, - - /* 5440 */ 0x05d6ec0e | (18 << 27) /* 0.364971213 */, - /* 5441 */ 0x05d749db | (18 << 27) /* 0.365060669 */, - /* 5442 */ 0x05d7a7aa | (18 << 27) /* 0.365150131 */, - /* 5443 */ 0x05d8057a | (18 << 27) /* 0.365239599 */, - /* 5444 */ 0x05d8634c | (18 << 27) /* 0.365329072 */, - /* 5445 */ 0x05d8c11f | (18 << 27) /* 0.365418550 */, - /* 5446 */ 0x05d91ef4 | (18 << 27) /* 0.365508034 */, - /* 5447 */ 0x05d97cca | (18 << 27) /* 0.365597523 */, - /* 5448 */ 0x05d9daa1 | (18 << 27) /* 0.365687018 */, - /* 5449 */ 0x05da387a | (18 << 27) /* 0.365776518 */, - /* 5450 */ 0x05da9655 | (18 << 27) /* 0.365866024 */, - /* 5451 */ 0x05daf431 | (18 << 27) /* 0.365955536 */, - /* 5452 */ 0x05db520e | (18 << 27) /* 0.366045052 */, - /* 5453 */ 0x05dbafed | (18 << 27) /* 0.366134574 */, - /* 5454 */ 0x05dc0dce | (18 << 27) /* 0.366224102 */, - /* 5455 */ 0x05dc6baf | (18 << 27) /* 0.366313635 */, - - /* 5456 */ 0x05dcc993 | (18 << 27) /* 0.366403174 */, - /* 5457 */ 0x05dd2778 | (18 << 27) /* 0.366492718 */, - /* 5458 */ 0x05dd855e | (18 << 27) /* 0.366582267 */, - /* 5459 */ 0x05dde346 | (18 << 27) /* 0.366671822 */, - /* 5460 */ 0x05de412f | (18 << 27) /* 0.366761383 */, - /* 5461 */ 0x05de9f1a | (18 << 27) /* 0.366850949 */, - /* 5462 */ 0x05defd06 | (18 << 27) /* 0.366940520 */, - /* 5463 */ 0x05df5af3 | (18 << 27) /* 0.367030097 */, - /* 5464 */ 0x05dfb8e2 | (18 << 27) /* 0.367119680 */, - /* 5465 */ 0x05e016d3 | (18 << 27) /* 0.367209267 */, - /* 5466 */ 0x05e074c5 | (18 << 27) /* 0.367298861 */, - /* 5467 */ 0x05e0d2b8 | (18 << 27) /* 0.367388459 */, - /* 5468 */ 0x05e130ad | (18 << 27) /* 0.367478064 */, - /* 5469 */ 0x05e18ea4 | (18 << 27) /* 0.367567673 */, - /* 5470 */ 0x05e1ec9c | (18 << 27) /* 0.367657288 */, - /* 5471 */ 0x05e24a95 | (18 << 27) /* 0.367746909 */, - - /* 5472 */ 0x05e2a890 | (18 << 27) /* 0.367836535 */, - /* 5473 */ 0x05e3068c | (18 << 27) /* 0.367926167 */, - /* 5474 */ 0x05e3648a | (18 << 27) /* 0.368015804 */, - /* 5475 */ 0x05e3c289 | (18 << 27) /* 0.368105446 */, - /* 5476 */ 0x05e4208a | (18 << 27) /* 0.368195094 */, - /* 5477 */ 0x05e47e8c | (18 << 27) /* 0.368284747 */, - /* 5478 */ 0x05e4dc8f | (18 << 27) /* 0.368374406 */, - /* 5479 */ 0x05e53a94 | (18 << 27) /* 0.368464070 */, - /* 5480 */ 0x05e5989b | (18 << 27) /* 0.368553740 */, - /* 5481 */ 0x05e5f6a3 | (18 << 27) /* 0.368643415 */, - /* 5482 */ 0x05e654ac | (18 << 27) /* 0.368733096 */, - /* 5483 */ 0x05e6b2b7 | (18 << 27) /* 0.368822782 */, - /* 5484 */ 0x05e710c4 | (18 << 27) /* 0.368912473 */, - /* 5485 */ 0x05e76ed2 | (18 << 27) /* 0.369002170 */, - /* 5486 */ 0x05e7cce1 | (18 << 27) /* 0.369091873 */, - /* 5487 */ 0x05e82af2 | (18 << 27) /* 0.369181581 */, - - /* 5488 */ 0x05e88904 | (18 << 27) /* 0.369271294 */, - /* 5489 */ 0x05e8e718 | (18 << 27) /* 0.369361013 */, - /* 5490 */ 0x05e9452d | (18 << 27) /* 0.369450737 */, - /* 5491 */ 0x05e9a343 | (18 << 27) /* 0.369540467 */, - /* 5492 */ 0x05ea015c | (18 << 27) /* 0.369630202 */, - /* 5493 */ 0x05ea5f75 | (18 << 27) /* 0.369719942 */, - /* 5494 */ 0x05eabd90 | (18 << 27) /* 0.369809688 */, - /* 5495 */ 0x05eb1bad | (18 << 27) /* 0.369899440 */, - /* 5496 */ 0x05eb79cb | (18 << 27) /* 0.369989197 */, - /* 5497 */ 0x05ebd7ea | (18 << 27) /* 0.370078959 */, - /* 5498 */ 0x05ec360b | (18 << 27) /* 0.370168727 */, - /* 5499 */ 0x05ec942d | (18 << 27) /* 0.370258500 */, - /* 5500 */ 0x05ecf251 | (18 << 27) /* 0.370348279 */, - /* 5501 */ 0x05ed5076 | (18 << 27) /* 0.370438063 */, - /* 5502 */ 0x05edae9d | (18 << 27) /* 0.370527853 */, - /* 5503 */ 0x05ee0cc5 | (18 << 27) /* 0.370617648 */, - - /* 5504 */ 0x05ee6aef | (18 << 27) /* 0.370707448 */, - /* 5505 */ 0x05eec91a | (18 << 27) /* 0.370797254 */, - /* 5506 */ 0x05ef2746 | (18 << 27) /* 0.370887065 */, - /* 5507 */ 0x05ef8574 | (18 << 27) /* 0.370976882 */, - /* 5508 */ 0x05efe3a4 | (18 << 27) /* 0.371066704 */, - /* 5509 */ 0x05f041d5 | (18 << 27) /* 0.371156532 */, - /* 5510 */ 0x05f0a007 | (18 << 27) /* 0.371246365 */, - /* 5511 */ 0x05f0fe3b | (18 << 27) /* 0.371336203 */, - /* 5512 */ 0x05f15c70 | (18 << 27) /* 0.371426047 */, - /* 5513 */ 0x05f1baa7 | (18 << 27) /* 0.371515897 */, - /* 5514 */ 0x05f218df | (18 << 27) /* 0.371605751 */, - /* 5515 */ 0x05f27719 | (18 << 27) /* 0.371695612 */, - /* 5516 */ 0x05f2d554 | (18 << 27) /* 0.371785477 */, - /* 5517 */ 0x05f33390 | (18 << 27) /* 0.371875348 */, - /* 5518 */ 0x05f391cf | (18 << 27) /* 0.371965225 */, - /* 5519 */ 0x05f3f00e | (18 << 27) /* 0.372055107 */, - - /* 5520 */ 0x05f44e4f | (18 << 27) /* 0.372144994 */, - /* 5521 */ 0x05f4ac91 | (18 << 27) /* 0.372234887 */, - /* 5522 */ 0x05f50ad5 | (18 << 27) /* 0.372324785 */, - /* 5523 */ 0x05f5691b | (18 << 27) /* 0.372414689 */, - /* 5524 */ 0x05f5c761 | (18 << 27) /* 0.372504598 */, - /* 5525 */ 0x05f625aa | (18 << 27) /* 0.372594513 */, - /* 5526 */ 0x05f683f3 | (18 << 27) /* 0.372684433 */, - /* 5527 */ 0x05f6e23f | (18 << 27) /* 0.372774358 */, - /* 5528 */ 0x05f7408b | (18 << 27) /* 0.372864289 */, - /* 5529 */ 0x05f79ed9 | (18 << 27) /* 0.372954225 */, - /* 5530 */ 0x05f7fd29 | (18 << 27) /* 0.373044167 */, - /* 5531 */ 0x05f85b7a | (18 << 27) /* 0.373134114 */, - /* 5532 */ 0x05f8b9cc | (18 << 27) /* 0.373224066 */, - /* 5533 */ 0x05f91820 | (18 << 27) /* 0.373314024 */, - /* 5534 */ 0x05f97675 | (18 << 27) /* 0.373403987 */, - /* 5535 */ 0x05f9d4cc | (18 << 27) /* 0.373493956 */, - - /* 5536 */ 0x05fa3324 | (18 << 27) /* 0.373583930 */, - /* 5537 */ 0x05fa917e | (18 << 27) /* 0.373673910 */, - /* 5538 */ 0x05faefd9 | (18 << 27) /* 0.373763895 */, - /* 5539 */ 0x05fb4e36 | (18 << 27) /* 0.373853885 */, - /* 5540 */ 0x05fbac94 | (18 << 27) /* 0.373943881 */, - /* 5541 */ 0x05fc0af3 | (18 << 27) /* 0.374033882 */, - /* 5542 */ 0x05fc6954 | (18 << 27) /* 0.374123889 */, - /* 5543 */ 0x05fcc7b7 | (18 << 27) /* 0.374213901 */, - /* 5544 */ 0x05fd261b | (18 << 27) /* 0.374303918 */, - /* 5545 */ 0x05fd8480 | (18 << 27) /* 0.374393941 */, - /* 5546 */ 0x05fde2e7 | (18 << 27) /* 0.374483970 */, - /* 5547 */ 0x05fe414f | (18 << 27) /* 0.374574003 */, - /* 5548 */ 0x05fe9fb9 | (18 << 27) /* 0.374664042 */, - /* 5549 */ 0x05fefe24 | (18 << 27) /* 0.374754087 */, - /* 5550 */ 0x05ff5c91 | (18 << 27) /* 0.374844137 */, - /* 5551 */ 0x05ffbaff | (18 << 27) /* 0.374934192 */, - - /* 5552 */ 0x0600196e | (18 << 27) /* 0.375024253 */, - /* 5553 */ 0x060077df | (18 << 27) /* 0.375114319 */, - /* 5554 */ 0x0600d651 | (18 << 27) /* 0.375204391 */, - /* 5555 */ 0x060134c5 | (18 << 27) /* 0.375294468 */, - /* 5556 */ 0x0601933b | (18 << 27) /* 0.375384550 */, - /* 5557 */ 0x0601f1b1 | (18 << 27) /* 0.375474638 */, - /* 5558 */ 0x0602502a | (18 << 27) /* 0.375564731 */, - /* 5559 */ 0x0602aea3 | (18 << 27) /* 0.375654830 */, - /* 5560 */ 0x06030d1e | (18 << 27) /* 0.375744934 */, - /* 5561 */ 0x06036b9b | (18 << 27) /* 0.375835043 */, - /* 5562 */ 0x0603ca19 | (18 << 27) /* 0.375925158 */, - /* 5563 */ 0x06042898 | (18 << 27) /* 0.376015278 */, - /* 5564 */ 0x06048719 | (18 << 27) /* 0.376105404 */, - /* 5565 */ 0x0604e59c | (18 << 27) /* 0.376195535 */, - /* 5566 */ 0x0605441f | (18 << 27) /* 0.376285671 */, - /* 5567 */ 0x0605a2a5 | (18 << 27) /* 0.376375813 */, - - /* 5568 */ 0x0606012b | (18 << 27) /* 0.376465960 */, - /* 5569 */ 0x06065fb4 | (18 << 27) /* 0.376556113 */, - /* 5570 */ 0x0606be3d | (18 << 27) /* 0.376646271 */, - /* 5571 */ 0x06071cc8 | (18 << 27) /* 0.376736434 */, - /* 5572 */ 0x06077b55 | (18 << 27) /* 0.376826603 */, - /* 5573 */ 0x0607d9e3 | (18 << 27) /* 0.376916777 */, - /* 5574 */ 0x06083872 | (18 << 27) /* 0.377006957 */, - /* 5575 */ 0x06089703 | (18 << 27) /* 0.377097141 */, - /* 5576 */ 0x0608f595 | (18 << 27) /* 0.377187332 */, - /* 5577 */ 0x06095429 | (18 << 27) /* 0.377277528 */, - /* 5578 */ 0x0609b2be | (18 << 27) /* 0.377367729 */, - /* 5579 */ 0x060a1155 | (18 << 27) /* 0.377457935 */, - /* 5580 */ 0x060a6fed | (18 << 27) /* 0.377548147 */, - /* 5581 */ 0x060ace86 | (18 << 27) /* 0.377638364 */, - /* 5582 */ 0x060b2d21 | (18 << 27) /* 0.377728587 */, - /* 5583 */ 0x060b8bbe | (18 << 27) /* 0.377818815 */, - - /* 5584 */ 0x060bea5c | (18 << 27) /* 0.377909049 */, - /* 5585 */ 0x060c48fb | (18 << 27) /* 0.377999288 */, - /* 5586 */ 0x060ca79c | (18 << 27) /* 0.378089532 */, - /* 5587 */ 0x060d063e | (18 << 27) /* 0.378179781 */, - /* 5588 */ 0x060d64e1 | (18 << 27) /* 0.378270036 */, - /* 5589 */ 0x060dc387 | (18 << 27) /* 0.378360297 */, - /* 5590 */ 0x060e222d | (18 << 27) /* 0.378450563 */, - /* 5591 */ 0x060e80d5 | (18 << 27) /* 0.378540834 */, - /* 5592 */ 0x060edf7f | (18 << 27) /* 0.378631110 */, - /* 5593 */ 0x060f3e29 | (18 << 27) /* 0.378721392 */, - /* 5594 */ 0x060f9cd6 | (18 << 27) /* 0.378811680 */, - /* 5595 */ 0x060ffb83 | (18 << 27) /* 0.378901972 */, - /* 5596 */ 0x06105a33 | (18 << 27) /* 0.378992270 */, - /* 5597 */ 0x0610b8e3 | (18 << 27) /* 0.379082574 */, - /* 5598 */ 0x06111795 | (18 << 27) /* 0.379172883 */, - /* 5599 */ 0x06117649 | (18 << 27) /* 0.379263197 */, - - /* 5600 */ 0x0611d4fe | (18 << 27) /* 0.379353516 */, - /* 5601 */ 0x061233b4 | (18 << 27) /* 0.379443841 */, - /* 5602 */ 0x0612926c | (18 << 27) /* 0.379534172 */, - /* 5603 */ 0x0612f125 | (18 << 27) /* 0.379624507 */, - /* 5604 */ 0x06134fe0 | (18 << 27) /* 0.379714848 */, - /* 5605 */ 0x0613ae9c | (18 << 27) /* 0.379805195 */, - /* 5606 */ 0x06140d5a | (18 << 27) /* 0.379895547 */, - /* 5607 */ 0x06146c19 | (18 << 27) /* 0.379985904 */, - /* 5608 */ 0x0614cada | (18 << 27) /* 0.380076266 */, - /* 5609 */ 0x0615299c | (18 << 27) /* 0.380166634 */, - /* 5610 */ 0x0615885f | (18 << 27) /* 0.380257008 */, - /* 5611 */ 0x0615e724 | (18 << 27) /* 0.380347386 */, - /* 5612 */ 0x061645ea | (18 << 27) /* 0.380437770 */, - /* 5613 */ 0x0616a4b2 | (18 << 27) /* 0.380528160 */, - /* 5614 */ 0x0617037b | (18 << 27) /* 0.380618555 */, - /* 5615 */ 0x06176246 | (18 << 27) /* 0.380708955 */, - - /* 5616 */ 0x0617c112 | (18 << 27) /* 0.380799360 */, - /* 5617 */ 0x06181fdf | (18 << 27) /* 0.380889771 */, - /* 5618 */ 0x06187eae | (18 << 27) /* 0.380980187 */, - /* 5619 */ 0x0618dd7e | (18 << 27) /* 0.381070609 */, - /* 5620 */ 0x06193c50 | (18 << 27) /* 0.381161036 */, - /* 5621 */ 0x06199b24 | (18 << 27) /* 0.381251468 */, - /* 5622 */ 0x0619f9f8 | (18 << 27) /* 0.381341906 */, - /* 5623 */ 0x061a58ce | (18 << 27) /* 0.381432349 */, - /* 5624 */ 0x061ab7a6 | (18 << 27) /* 0.381522798 */, - /* 5625 */ 0x061b167f | (18 << 27) /* 0.381613251 */, - /* 5626 */ 0x061b7559 | (18 << 27) /* 0.381703711 */, - /* 5627 */ 0x061bd435 | (18 << 27) /* 0.381794175 */, - /* 5628 */ 0x061c3313 | (18 << 27) /* 0.381884645 */, - /* 5629 */ 0x061c91f1 | (18 << 27) /* 0.381975120 */, - /* 5630 */ 0x061cf0d2 | (18 << 27) /* 0.382065601 */, - /* 5631 */ 0x061d4fb3 | (18 << 27) /* 0.382156087 */, - - /* 5632 */ 0x061dae96 | (18 << 27) /* 0.382246578 */, - /* 5633 */ 0x061e0d7b | (18 << 27) /* 0.382337075 */, - /* 5634 */ 0x061e6c61 | (18 << 27) /* 0.382427577 */, - /* 5635 */ 0x061ecb48 | (18 << 27) /* 0.382518084 */, - /* 5636 */ 0x061f2a31 | (18 << 27) /* 0.382608597 */, - /* 5637 */ 0x061f891b | (18 << 27) /* 0.382699115 */, - /* 5638 */ 0x061fe807 | (18 << 27) /* 0.382789638 */, - /* 5639 */ 0x062046f4 | (18 << 27) /* 0.382880167 */, - /* 5640 */ 0x0620a5e3 | (18 << 27) /* 0.382970701 */, - /* 5641 */ 0x062104d3 | (18 << 27) /* 0.383061241 */, - /* 5642 */ 0x062163c4 | (18 << 27) /* 0.383151786 */, - /* 5643 */ 0x0621c2b7 | (18 << 27) /* 0.383242336 */, - /* 5644 */ 0x062221ab | (18 << 27) /* 0.383332891 */, - /* 5645 */ 0x062280a1 | (18 << 27) /* 0.383423452 */, - /* 5646 */ 0x0622df98 | (18 << 27) /* 0.383514018 */, - /* 5647 */ 0x06233e91 | (18 << 27) /* 0.383604590 */, - - /* 5648 */ 0x06239d8b | (18 << 27) /* 0.383695167 */, - /* 5649 */ 0x0623fc86 | (18 << 27) /* 0.383785749 */, - /* 5650 */ 0x06245b83 | (18 << 27) /* 0.383876337 */, - /* 5651 */ 0x0624ba82 | (18 << 27) /* 0.383966930 */, - /* 5652 */ 0x06251981 | (18 << 27) /* 0.384057528 */, - /* 5653 */ 0x06257883 | (18 << 27) /* 0.384148132 */, - /* 5654 */ 0x0625d785 | (18 << 27) /* 0.384238741 */, - /* 5655 */ 0x06263689 | (18 << 27) /* 0.384329355 */, - /* 5656 */ 0x0626958f | (18 << 27) /* 0.384419975 */, - /* 5657 */ 0x0626f496 | (18 << 27) /* 0.384510600 */, - /* 5658 */ 0x0627539e | (18 << 27) /* 0.384601230 */, - /* 5659 */ 0x0627b2a8 | (18 << 27) /* 0.384691866 */, - /* 5660 */ 0x062811b3 | (18 << 27) /* 0.384782507 */, - /* 5661 */ 0x062870c0 | (18 << 27) /* 0.384873153 */, - /* 5662 */ 0x0628cfce | (18 << 27) /* 0.384963805 */, - /* 5663 */ 0x06292ede | (18 << 27) /* 0.385054462 */, - - /* 5664 */ 0x06298def | (18 << 27) /* 0.385145124 */, - /* 5665 */ 0x0629ed01 | (18 << 27) /* 0.385235792 */, - /* 5666 */ 0x062a4c15 | (18 << 27) /* 0.385326465 */, - /* 5667 */ 0x062aab2a | (18 << 27) /* 0.385417143 */, - /* 5668 */ 0x062b0a41 | (18 << 27) /* 0.385507827 */, - /* 5669 */ 0x062b6959 | (18 << 27) /* 0.385598516 */, - /* 5670 */ 0x062bc873 | (18 << 27) /* 0.385689211 */, - /* 5671 */ 0x062c278e | (18 << 27) /* 0.385779910 */, - /* 5672 */ 0x062c86aa | (18 << 27) /* 0.385870615 */, - /* 5673 */ 0x062ce5c8 | (18 << 27) /* 0.385961326 */, - /* 5674 */ 0x062d44e8 | (18 << 27) /* 0.386052041 */, - /* 5675 */ 0x062da408 | (18 << 27) /* 0.386142762 */, - /* 5676 */ 0x062e032a | (18 << 27) /* 0.386233489 */, - /* 5677 */ 0x062e624e | (18 << 27) /* 0.386324221 */, - /* 5678 */ 0x062ec173 | (18 << 27) /* 0.386414958 */, - /* 5679 */ 0x062f209a | (18 << 27) /* 0.386505700 */, - - /* 5680 */ 0x062f7fc1 | (18 << 27) /* 0.386596448 */, - /* 5681 */ 0x062fdeeb | (18 << 27) /* 0.386687201 */, - /* 5682 */ 0x06303e16 | (18 << 27) /* 0.386777959 */, - /* 5683 */ 0x06309d42 | (18 << 27) /* 0.386868723 */, - /* 5684 */ 0x0630fc6f | (18 << 27) /* 0.386959492 */, - /* 5685 */ 0x06315b9e | (18 << 27) /* 0.387050266 */, - /* 5686 */ 0x0631bacf | (18 << 27) /* 0.387141045 */, - /* 5687 */ 0x06321a01 | (18 << 27) /* 0.387231830 */, - /* 5688 */ 0x06327934 | (18 << 27) /* 0.387322621 */, - /* 5689 */ 0x0632d869 | (18 << 27) /* 0.387413416 */, - /* 5690 */ 0x0633379f | (18 << 27) /* 0.387504217 */, - /* 5691 */ 0x063396d7 | (18 << 27) /* 0.387595023 */, - /* 5692 */ 0x0633f610 | (18 << 27) /* 0.387685835 */, - /* 5693 */ 0x0634554a | (18 << 27) /* 0.387776652 */, - /* 5694 */ 0x0634b486 | (18 << 27) /* 0.387867474 */, - /* 5695 */ 0x063513c3 | (18 << 27) /* 0.387958301 */, - - /* 5696 */ 0x06357302 | (18 << 27) /* 0.388049134 */, - /* 5697 */ 0x0635d242 | (18 << 27) /* 0.388139972 */, - /* 5698 */ 0x06363184 | (18 << 27) /* 0.388230816 */, - /* 5699 */ 0x063690c7 | (18 << 27) /* 0.388321665 */, - /* 5700 */ 0x0636f00b | (18 << 27) /* 0.388412519 */, - /* 5701 */ 0x06374f51 | (18 << 27) /* 0.388503378 */, - /* 5702 */ 0x0637ae99 | (18 << 27) /* 0.388594243 */, - /* 5703 */ 0x06380de1 | (18 << 27) /* 0.388685113 */, - /* 5704 */ 0x06386d2b | (18 << 27) /* 0.388775988 */, - /* 5705 */ 0x0638cc77 | (18 << 27) /* 0.388866869 */, - /* 5706 */ 0x06392bc4 | (18 << 27) /* 0.388957755 */, - /* 5707 */ 0x06398b12 | (18 << 27) /* 0.389048646 */, - /* 5708 */ 0x0639ea62 | (18 << 27) /* 0.389139542 */, - /* 5709 */ 0x063a49b4 | (18 << 27) /* 0.389230444 */, - /* 5710 */ 0x063aa906 | (18 << 27) /* 0.389321352 */, - /* 5711 */ 0x063b085a | (18 << 27) /* 0.389412264 */, - - /* 5712 */ 0x063b67b0 | (18 << 27) /* 0.389503182 */, - /* 5713 */ 0x063bc707 | (18 << 27) /* 0.389594105 */, - /* 5714 */ 0x063c265f | (18 << 27) /* 0.389685033 */, - /* 5715 */ 0x063c85b9 | (18 << 27) /* 0.389775967 */, - /* 5716 */ 0x063ce514 | (18 << 27) /* 0.389866906 */, - /* 5717 */ 0x063d4471 | (18 << 27) /* 0.389957850 */, - /* 5718 */ 0x063da3cf | (18 << 27) /* 0.390048800 */, - /* 5719 */ 0x063e032f | (18 << 27) /* 0.390139755 */, - /* 5720 */ 0x063e6290 | (18 << 27) /* 0.390230715 */, - /* 5721 */ 0x063ec1f2 | (18 << 27) /* 0.390321681 */, - /* 5722 */ 0x063f2156 | (18 << 27) /* 0.390412651 */, - /* 5723 */ 0x063f80bb | (18 << 27) /* 0.390503628 */, - /* 5724 */ 0x063fe022 | (18 << 27) /* 0.390594609 */, - /* 5725 */ 0x06403f8a | (18 << 27) /* 0.390685596 */, - /* 5726 */ 0x06409ef3 | (18 << 27) /* 0.390776588 */, - /* 5727 */ 0x0640fe5e | (18 << 27) /* 0.390867585 */, - - /* 5728 */ 0x06415dcb | (18 << 27) /* 0.390958588 */, - /* 5729 */ 0x0641bd38 | (18 << 27) /* 0.391049596 */, - /* 5730 */ 0x06421ca7 | (18 << 27) /* 0.391140609 */, - /* 5731 */ 0x06427c18 | (18 << 27) /* 0.391231627 */, - /* 5732 */ 0x0642db8a | (18 << 27) /* 0.391322651 */, - /* 5733 */ 0x06433afd | (18 << 27) /* 0.391413680 */, - /* 5734 */ 0x06439a72 | (18 << 27) /* 0.391504714 */, - /* 5735 */ 0x0643f9e9 | (18 << 27) /* 0.391595754 */, - /* 5736 */ 0x06445960 | (18 << 27) /* 0.391686799 */, - /* 5737 */ 0x0644b8d9 | (18 << 27) /* 0.391777849 */, - /* 5738 */ 0x06451854 | (18 << 27) /* 0.391868905 */, - /* 5739 */ 0x064577d0 | (18 << 27) /* 0.391959966 */, - /* 5740 */ 0x0645d74d | (18 << 27) /* 0.392051032 */, - /* 5741 */ 0x064636cc | (18 << 27) /* 0.392142103 */, - /* 5742 */ 0x0646964c | (18 << 27) /* 0.392233180 */, - /* 5743 */ 0x0646f5ce | (18 << 27) /* 0.392324262 */, - - /* 5744 */ 0x06475551 | (18 << 27) /* 0.392415349 */, - /* 5745 */ 0x0647b4d5 | (18 << 27) /* 0.392506442 */, - /* 5746 */ 0x0648145b | (18 << 27) /* 0.392597540 */, - /* 5747 */ 0x064873e3 | (18 << 27) /* 0.392688643 */, - /* 5748 */ 0x0648d36b | (18 << 27) /* 0.392779751 */, - /* 5749 */ 0x064932f6 | (18 << 27) /* 0.392870865 */, - /* 5750 */ 0x06499281 | (18 << 27) /* 0.392961984 */, - /* 5751 */ 0x0649f20e | (18 << 27) /* 0.393053108 */, - /* 5752 */ 0x064a519c | (18 << 27) /* 0.393144238 */, - /* 5753 */ 0x064ab12c | (18 << 27) /* 0.393235372 */, - /* 5754 */ 0x064b10be | (18 << 27) /* 0.393326513 */, - /* 5755 */ 0x064b7050 | (18 << 27) /* 0.393417658 */, - /* 5756 */ 0x064bcfe4 | (18 << 27) /* 0.393508809 */, - /* 5757 */ 0x064c2f7a | (18 << 27) /* 0.393599965 */, - /* 5758 */ 0x064c8f11 | (18 << 27) /* 0.393691126 */, - /* 5759 */ 0x064ceea9 | (18 << 27) /* 0.393782292 */, - - /* 5760 */ 0x064d4e43 | (18 << 27) /* 0.393873464 */, - /* 5761 */ 0x064dadde | (18 << 27) /* 0.393964641 */, - /* 5762 */ 0x064e0d7a | (18 << 27) /* 0.394055823 */, - /* 5763 */ 0x064e6d18 | (18 << 27) /* 0.394147011 */, - /* 5764 */ 0x064eccb8 | (18 << 27) /* 0.394238204 */, - /* 5765 */ 0x064f2c59 | (18 << 27) /* 0.394329402 */, - /* 5766 */ 0x064f8bfb | (18 << 27) /* 0.394420605 */, - /* 5767 */ 0x064feb9e | (18 << 27) /* 0.394511814 */, - /* 5768 */ 0x06504b44 | (18 << 27) /* 0.394603028 */, - /* 5769 */ 0x0650aaea | (18 << 27) /* 0.394694247 */, - /* 5770 */ 0x06510a92 | (18 << 27) /* 0.394785472 */, - /* 5771 */ 0x06516a3b | (18 << 27) /* 0.394876702 */, - /* 5772 */ 0x0651c9e6 | (18 << 27) /* 0.394967937 */, - /* 5773 */ 0x06522992 | (18 << 27) /* 0.395059177 */, - /* 5774 */ 0x06528940 | (18 << 27) /* 0.395150423 */, - /* 5775 */ 0x0652e8ef | (18 << 27) /* 0.395241673 */, - - /* 5776 */ 0x0653489f | (18 << 27) /* 0.395332930 */, - /* 5777 */ 0x0653a851 | (18 << 27) /* 0.395424191 */, - /* 5778 */ 0x06540804 | (18 << 27) /* 0.395515458 */, - /* 5779 */ 0x065467b9 | (18 << 27) /* 0.395606730 */, - /* 5780 */ 0x0654c76f | (18 << 27) /* 0.395698007 */, - /* 5781 */ 0x06552726 | (18 << 27) /* 0.395789289 */, - /* 5782 */ 0x065586df | (18 << 27) /* 0.395880577 */, - /* 5783 */ 0x0655e699 | (18 << 27) /* 0.395971870 */, - /* 5784 */ 0x06564655 | (18 << 27) /* 0.396063168 */, - /* 5785 */ 0x0656a612 | (18 << 27) /* 0.396154472 */, - /* 5786 */ 0x065705d0 | (18 << 27) /* 0.396245780 */, - /* 5787 */ 0x06576590 | (18 << 27) /* 0.396337094 */, - /* 5788 */ 0x0657c552 | (18 << 27) /* 0.396428414 */, - /* 5789 */ 0x06582514 | (18 << 27) /* 0.396519738 */, - /* 5790 */ 0x065884d9 | (18 << 27) /* 0.396611068 */, - /* 5791 */ 0x0658e49e | (18 << 27) /* 0.396702403 */, - - /* 5792 */ 0x06594465 | (18 << 27) /* 0.396793743 */, - /* 5793 */ 0x0659a42e | (18 << 27) /* 0.396885089 */, - /* 5794 */ 0x065a03f7 | (18 << 27) /* 0.396976440 */, - /* 5795 */ 0x065a63c3 | (18 << 27) /* 0.397067796 */, - /* 5796 */ 0x065ac38f | (18 << 27) /* 0.397159157 */, - /* 5797 */ 0x065b235d | (18 << 27) /* 0.397250524 */, - /* 5798 */ 0x065b832d | (18 << 27) /* 0.397341896 */, - /* 5799 */ 0x065be2fe | (18 << 27) /* 0.397433273 */, - /* 5800 */ 0x065c42d0 | (18 << 27) /* 0.397524655 */, - /* 5801 */ 0x065ca2a3 | (18 << 27) /* 0.397616043 */, - /* 5802 */ 0x065d0279 | (18 << 27) /* 0.397707436 */, - /* 5803 */ 0x065d624f | (18 << 27) /* 0.397798834 */, - /* 5804 */ 0x065dc227 | (18 << 27) /* 0.397890237 */, - /* 5805 */ 0x065e2200 | (18 << 27) /* 0.397981646 */, - /* 5806 */ 0x065e81db | (18 << 27) /* 0.398073059 */, - /* 5807 */ 0x065ee1b7 | (18 << 27) /* 0.398164479 */, - - /* 5808 */ 0x065f4195 | (18 << 27) /* 0.398255903 */, - /* 5809 */ 0x065fa174 | (18 << 27) /* 0.398347333 */, - /* 5810 */ 0x06600154 | (18 << 27) /* 0.398438767 */, - /* 5811 */ 0x06606136 | (18 << 27) /* 0.398530207 */, - /* 5812 */ 0x0660c119 | (18 << 27) /* 0.398621653 */, - /* 5813 */ 0x066120fd | (18 << 27) /* 0.398713103 */, - /* 5814 */ 0x066180e3 | (18 << 27) /* 0.398804559 */, - /* 5815 */ 0x0661e0cb | (18 << 27) /* 0.398896020 */, - /* 5816 */ 0x066240b4 | (18 << 27) /* 0.398987487 */, - /* 5817 */ 0x0662a09e | (18 << 27) /* 0.399078958 */, - /* 5818 */ 0x06630089 | (18 << 27) /* 0.399170435 */, - /* 5819 */ 0x06636077 | (18 << 27) /* 0.399261917 */, - /* 5820 */ 0x0663c065 | (18 << 27) /* 0.399353404 */, - /* 5821 */ 0x06642055 | (18 << 27) /* 0.399444897 */, - /* 5822 */ 0x06648046 | (18 << 27) /* 0.399536395 */, - /* 5823 */ 0x0664e039 | (18 << 27) /* 0.399627898 */, - - /* 5824 */ 0x0665402d | (18 << 27) /* 0.399719406 */, - /* 5825 */ 0x0665a022 | (18 << 27) /* 0.399810919 */, - /* 5826 */ 0x06660019 | (18 << 27) /* 0.399902438 */, - /* 5827 */ 0x06666011 | (18 << 27) /* 0.399993962 */, - /* 5828 */ 0x0666c00b | (18 << 27) /* 0.400085491 */, - /* 5829 */ 0x06672006 | (18 << 27) /* 0.400177026 */, - /* 5830 */ 0x06678003 | (18 << 27) /* 0.400268565 */, - /* 5831 */ 0x0667e000 | (18 << 27) /* 0.400360110 */, - /* 5832 */ 0x06684000 | (18 << 27) /* 0.400451660 */, - /* 5833 */ 0x0668a000 | (18 << 27) /* 0.400543216 */, - /* 5834 */ 0x06690003 | (18 << 27) /* 0.400634776 */, - /* 5835 */ 0x06696006 | (18 << 27) /* 0.400726342 */, - /* 5836 */ 0x0669c00b | (18 << 27) /* 0.400817913 */, - /* 5837 */ 0x066a2011 | (18 << 27) /* 0.400909489 */, - /* 5838 */ 0x066a8019 | (18 << 27) /* 0.401001071 */, - /* 5839 */ 0x066ae022 | (18 << 27) /* 0.401092657 */, - - /* 5840 */ 0x066b402d | (18 << 27) /* 0.401184249 */, - /* 5841 */ 0x066ba039 | (18 << 27) /* 0.401275847 */, - /* 5842 */ 0x066c0046 | (18 << 27) /* 0.401367449 */, - /* 5843 */ 0x066c6055 | (18 << 27) /* 0.401459057 */, - /* 5844 */ 0x066cc065 | (18 << 27) /* 0.401550670 */, - /* 5845 */ 0x066d2076 | (18 << 27) /* 0.401642288 */, - /* 5846 */ 0x066d8089 | (18 << 27) /* 0.401733911 */, - /* 5847 */ 0x066de09e | (18 << 27) /* 0.401825540 */, - /* 5848 */ 0x066e40b3 | (18 << 27) /* 0.401917173 */, - /* 5849 */ 0x066ea0cb | (18 << 27) /* 0.402008812 */, - /* 5850 */ 0x066f00e3 | (18 << 27) /* 0.402100457 */, - /* 5851 */ 0x066f60fd | (18 << 27) /* 0.402192106 */, - /* 5852 */ 0x066fc118 | (18 << 27) /* 0.402283761 */, - /* 5853 */ 0x06702135 | (18 << 27) /* 0.402375420 */, - /* 5854 */ 0x06708153 | (18 << 27) /* 0.402467086 */, - /* 5855 */ 0x0670e173 | (18 << 27) /* 0.402558756 */, - - /* 5856 */ 0x06714194 | (18 << 27) /* 0.402650431 */, - /* 5857 */ 0x0671a1b6 | (18 << 27) /* 0.402742112 */, - /* 5858 */ 0x067201da | (18 << 27) /* 0.402833798 */, - /* 5859 */ 0x067261ff | (18 << 27) /* 0.402925489 */, - /* 5860 */ 0x0672c226 | (18 << 27) /* 0.403017186 */, - /* 5861 */ 0x0673224e | (18 << 27) /* 0.403108887 */, - /* 5862 */ 0x06738277 | (18 << 27) /* 0.403200594 */, - /* 5863 */ 0x0673e2a2 | (18 << 27) /* 0.403292306 */, - /* 5864 */ 0x067442ce | (18 << 27) /* 0.403384024 */, - /* 5865 */ 0x0674a2fc | (18 << 27) /* 0.403475746 */, - /* 5866 */ 0x0675032b | (18 << 27) /* 0.403567474 */, - /* 5867 */ 0x0675635b | (18 << 27) /* 0.403659207 */, - /* 5868 */ 0x0675c38d | (18 << 27) /* 0.403750945 */, - /* 5869 */ 0x067623c0 | (18 << 27) /* 0.403842688 */, - /* 5870 */ 0x067683f4 | (18 << 27) /* 0.403934437 */, - /* 5871 */ 0x0676e42a | (18 << 27) /* 0.404026190 */, - - /* 5872 */ 0x06774462 | (18 << 27) /* 0.404117949 */, - /* 5873 */ 0x0677a49b | (18 << 27) /* 0.404209714 */, - /* 5874 */ 0x067804d5 | (18 << 27) /* 0.404301483 */, - /* 5875 */ 0x06786510 | (18 << 27) /* 0.404393258 */, - /* 5876 */ 0x0678c54d | (18 << 27) /* 0.404485037 */, - /* 5877 */ 0x0679258c | (18 << 27) /* 0.404576822 */, - /* 5878 */ 0x067985cb | (18 << 27) /* 0.404668613 */, - /* 5879 */ 0x0679e60c | (18 << 27) /* 0.404760408 */, - /* 5880 */ 0x067a464f | (18 << 27) /* 0.404852209 */, - /* 5881 */ 0x067aa693 | (18 << 27) /* 0.404944014 */, - /* 5882 */ 0x067b06d8 | (18 << 27) /* 0.405035825 */, - /* 5883 */ 0x067b671f | (18 << 27) /* 0.405127642 */, - /* 5884 */ 0x067bc767 | (18 << 27) /* 0.405219463 */, - /* 5885 */ 0x067c27b1 | (18 << 27) /* 0.405311290 */, - /* 5886 */ 0x067c87fc | (18 << 27) /* 0.405403122 */, - /* 5887 */ 0x067ce848 | (18 << 27) /* 0.405494959 */, - - /* 5888 */ 0x067d4896 | (18 << 27) /* 0.405586801 */, - /* 5889 */ 0x067da8e5 | (18 << 27) /* 0.405678648 */, - /* 5890 */ 0x067e0935 | (18 << 27) /* 0.405770501 */, - /* 5891 */ 0x067e6987 | (18 << 27) /* 0.405862359 */, - /* 5892 */ 0x067ec9da | (18 << 27) /* 0.405954222 */, - /* 5893 */ 0x067f2a2f | (18 << 27) /* 0.406046090 */, - /* 5894 */ 0x067f8a85 | (18 << 27) /* 0.406137963 */, - /* 5895 */ 0x067feadd | (18 << 27) /* 0.406229842 */, - /* 5896 */ 0x06804b36 | (18 << 27) /* 0.406321726 */, - /* 5897 */ 0x0680ab90 | (18 << 27) /* 0.406413615 */, - /* 5898 */ 0x06810beb | (18 << 27) /* 0.406505509 */, - /* 5899 */ 0x06816c49 | (18 << 27) /* 0.406597408 */, - /* 5900 */ 0x0681cca7 | (18 << 27) /* 0.406689313 */, - /* 5901 */ 0x06822d07 | (18 << 27) /* 0.406781223 */, - /* 5902 */ 0x06828d68 | (18 << 27) /* 0.406873138 */, - /* 5903 */ 0x0682edcb | (18 << 27) /* 0.406965058 */, - - /* 5904 */ 0x06834e2f | (18 << 27) /* 0.407056983 */, - /* 5905 */ 0x0683ae94 | (18 << 27) /* 0.407148914 */, - /* 5906 */ 0x06840efb | (18 << 27) /* 0.407240850 */, - /* 5907 */ 0x06846f63 | (18 << 27) /* 0.407332791 */, - /* 5908 */ 0x0684cfcd | (18 << 27) /* 0.407424737 */, - /* 5909 */ 0x06853038 | (18 << 27) /* 0.407516688 */, - /* 5910 */ 0x068590a4 | (18 << 27) /* 0.407608645 */, - /* 5911 */ 0x0685f112 | (18 << 27) /* 0.407700606 */, - /* 5912 */ 0x06865181 | (18 << 27) /* 0.407792573 */, - /* 5913 */ 0x0686b1f2 | (18 << 27) /* 0.407884545 */, - /* 5914 */ 0x06871264 | (18 << 27) /* 0.407976522 */, - /* 5915 */ 0x068772d7 | (18 << 27) /* 0.408068505 */, - /* 5916 */ 0x0687d34c | (18 << 27) /* 0.408160492 */, - /* 5917 */ 0x068833c2 | (18 << 27) /* 0.408252485 */, - /* 5918 */ 0x06889439 | (18 << 27) /* 0.408344483 */, - /* 5919 */ 0x0688f4b2 | (18 << 27) /* 0.408436486 */, - - /* 5920 */ 0x0689552c | (18 << 27) /* 0.408528495 */, - /* 5921 */ 0x0689b5a8 | (18 << 27) /* 0.408620508 */, - /* 5922 */ 0x068a1625 | (18 << 27) /* 0.408712527 */, - /* 5923 */ 0x068a76a4 | (18 << 27) /* 0.408804551 */, - /* 5924 */ 0x068ad724 | (18 << 27) /* 0.408896580 */, - /* 5925 */ 0x068b37a5 | (18 << 27) /* 0.408988614 */, - /* 5926 */ 0x068b9827 | (18 << 27) /* 0.409080653 */, - /* 5927 */ 0x068bf8ac | (18 << 27) /* 0.409172698 */, - /* 5928 */ 0x068c5931 | (18 << 27) /* 0.409264748 */, - /* 5929 */ 0x068cb9b8 | (18 << 27) /* 0.409356803 */, - /* 5930 */ 0x068d1a40 | (18 << 27) /* 0.409448863 */, - /* 5931 */ 0x068d7aca | (18 << 27) /* 0.409540928 */, - /* 5932 */ 0x068ddb54 | (18 << 27) /* 0.409632999 */, - /* 5933 */ 0x068e3be1 | (18 << 27) /* 0.409725074 */, - /* 5934 */ 0x068e9c6f | (18 << 27) /* 0.409817155 */, - /* 5935 */ 0x068efcfe | (18 << 27) /* 0.409909241 */, - - /* 5936 */ 0x068f5d8e | (18 << 27) /* 0.410001332 */, - /* 5937 */ 0x068fbe20 | (18 << 27) /* 0.410093428 */, - /* 5938 */ 0x06901eb4 | (18 << 27) /* 0.410185530 */, - /* 5939 */ 0x06907f48 | (18 << 27) /* 0.410277637 */, - /* 5940 */ 0x0690dfde | (18 << 27) /* 0.410369748 */, - /* 5941 */ 0x06914076 | (18 << 27) /* 0.410461865 */, - /* 5942 */ 0x0691a10f | (18 << 27) /* 0.410553988 */, - /* 5943 */ 0x069201a9 | (18 << 27) /* 0.410646115 */, - /* 5944 */ 0x06926245 | (18 << 27) /* 0.410738247 */, - /* 5945 */ 0x0692c2e2 | (18 << 27) /* 0.410830385 */, - /* 5946 */ 0x06932380 | (18 << 27) /* 0.410922528 */, - /* 5947 */ 0x06938420 | (18 << 27) /* 0.411014676 */, - /* 5948 */ 0x0693e4c1 | (18 << 27) /* 0.411106829 */, - /* 5949 */ 0x06944563 | (18 << 27) /* 0.411198987 */, - /* 5950 */ 0x0694a607 | (18 << 27) /* 0.411291151 */, - /* 5951 */ 0x069506ad | (18 << 27) /* 0.411383320 */, - - /* 5952 */ 0x06956753 | (18 << 27) /* 0.411475493 */, - /* 5953 */ 0x0695c7fc | (18 << 27) /* 0.411567672 */, - /* 5954 */ 0x069628a5 | (18 << 27) /* 0.411659857 */, - /* 5955 */ 0x06968950 | (18 << 27) /* 0.411752046 */, - /* 5956 */ 0x0696e9fc | (18 << 27) /* 0.411844240 */, - /* 5957 */ 0x06974aaa | (18 << 27) /* 0.411936440 */, - /* 5958 */ 0x0697ab59 | (18 << 27) /* 0.412028645 */, - /* 5959 */ 0x06980c09 | (18 << 27) /* 0.412120855 */, - /* 5960 */ 0x06986cbb | (18 << 27) /* 0.412213070 */, - /* 5961 */ 0x0698cd6e | (18 << 27) /* 0.412305290 */, - /* 5962 */ 0x06992e23 | (18 << 27) /* 0.412397516 */, - /* 5963 */ 0x06998ed9 | (18 << 27) /* 0.412489746 */, - /* 5964 */ 0x0699ef90 | (18 << 27) /* 0.412581982 */, - /* 5965 */ 0x069a5049 | (18 << 27) /* 0.412674223 */, - /* 5966 */ 0x069ab103 | (18 << 27) /* 0.412766469 */, - /* 5967 */ 0x069b11bf | (18 << 27) /* 0.412858720 */, - - /* 5968 */ 0x069b727b | (18 << 27) /* 0.412950976 */, - /* 5969 */ 0x069bd33a | (18 << 27) /* 0.413043238 */, - /* 5970 */ 0x069c33f9 | (18 << 27) /* 0.413135505 */, - /* 5971 */ 0x069c94ba | (18 << 27) /* 0.413227776 */, - /* 5972 */ 0x069cf57d | (18 << 27) /* 0.413320053 */, - /* 5973 */ 0x069d5641 | (18 << 27) /* 0.413412335 */, - /* 5974 */ 0x069db706 | (18 << 27) /* 0.413504623 */, - /* 5975 */ 0x069e17cc | (18 << 27) /* 0.413596915 */, - /* 5976 */ 0x069e7894 | (18 << 27) /* 0.413689213 */, - /* 5977 */ 0x069ed95e | (18 << 27) /* 0.413781515 */, - /* 5978 */ 0x069f3a28 | (18 << 27) /* 0.413873823 */, - /* 5979 */ 0x069f9af4 | (18 << 27) /* 0.413966136 */, - /* 5980 */ 0x069ffbc2 | (18 << 27) /* 0.414058454 */, - /* 5981 */ 0x06a05c91 | (18 << 27) /* 0.414150778 */, - /* 5982 */ 0x06a0bd61 | (18 << 27) /* 0.414243106 */, - /* 5983 */ 0x06a11e32 | (18 << 27) /* 0.414335440 */, - - /* 5984 */ 0x06a17f05 | (18 << 27) /* 0.414427779 */, - /* 5985 */ 0x06a1dfda | (18 << 27) /* 0.414520122 */, - /* 5986 */ 0x06a240b0 | (18 << 27) /* 0.414612471 */, - /* 5987 */ 0x06a2a187 | (18 << 27) /* 0.414704826 */, - /* 5988 */ 0x06a3025f | (18 << 27) /* 0.414797185 */, - /* 5989 */ 0x06a36339 | (18 << 27) /* 0.414889549 */, - /* 5990 */ 0x06a3c414 | (18 << 27) /* 0.414981919 */, - /* 5991 */ 0x06a424f1 | (18 << 27) /* 0.415074294 */, - /* 5992 */ 0x06a485cf | (18 << 27) /* 0.415166674 */, - /* 5993 */ 0x06a4e6ae | (18 << 27) /* 0.415259059 */, - /* 5994 */ 0x06a5478f | (18 << 27) /* 0.415351449 */, - /* 5995 */ 0x06a5a871 | (18 << 27) /* 0.415443844 */, - /* 5996 */ 0x06a60955 | (18 << 27) /* 0.415536244 */, - /* 5997 */ 0x06a66a3a | (18 << 27) /* 0.415628650 */, - /* 5998 */ 0x06a6cb20 | (18 << 27) /* 0.415721061 */, - /* 5999 */ 0x06a72c08 | (18 << 27) /* 0.415813476 */, - - /* 6000 */ 0x06a78cf1 | (18 << 27) /* 0.415905897 */, - /* 6001 */ 0x06a7eddb | (18 << 27) /* 0.415998324 */, - /* 6002 */ 0x06a84ec7 | (18 << 27) /* 0.416090755 */, - /* 6003 */ 0x06a8afb4 | (18 << 27) /* 0.416183191 */, - /* 6004 */ 0x06a910a3 | (18 << 27) /* 0.416275633 */, - /* 6005 */ 0x06a97193 | (18 << 27) /* 0.416368079 */, - /* 6006 */ 0x06a9d284 | (18 << 27) /* 0.416460531 */, - /* 6007 */ 0x06aa3377 | (18 << 27) /* 0.416552988 */, - /* 6008 */ 0x06aa946b | (18 << 27) /* 0.416645450 */, - /* 6009 */ 0x06aaf561 | (18 << 27) /* 0.416737917 */, - /* 6010 */ 0x06ab5657 | (18 << 27) /* 0.416830389 */, - /* 6011 */ 0x06abb750 | (18 << 27) /* 0.416922867 */, - /* 6012 */ 0x06ac1849 | (18 << 27) /* 0.417015349 */, - /* 6013 */ 0x06ac7944 | (18 << 27) /* 0.417107837 */, - /* 6014 */ 0x06acda41 | (18 << 27) /* 0.417200330 */, - /* 6015 */ 0x06ad3b3e | (18 << 27) /* 0.417292828 */, - - /* 6016 */ 0x06ad9c3d | (18 << 27) /* 0.417385331 */, - /* 6017 */ 0x06adfd3e | (18 << 27) /* 0.417477839 */, - /* 6018 */ 0x06ae5e40 | (18 << 27) /* 0.417570352 */, - /* 6019 */ 0x06aebf43 | (18 << 27) /* 0.417662871 */, - /* 6020 */ 0x06af2047 | (18 << 27) /* 0.417755394 */, - /* 6021 */ 0x06af814d | (18 << 27) /* 0.417847923 */, - /* 6022 */ 0x06afe255 | (18 << 27) /* 0.417940457 */, - /* 6023 */ 0x06b0435e | (18 << 27) /* 0.418032996 */, - /* 6024 */ 0x06b0a468 | (18 << 27) /* 0.418125540 */, - /* 6025 */ 0x06b10573 | (18 << 27) /* 0.418218089 */, - /* 6026 */ 0x06b16680 | (18 << 27) /* 0.418310643 */, - /* 6027 */ 0x06b1c78e | (18 << 27) /* 0.418403203 */, - /* 6028 */ 0x06b2289e | (18 << 27) /* 0.418495767 */, - /* 6029 */ 0x06b289af | (18 << 27) /* 0.418588337 */, - /* 6030 */ 0x06b2eac1 | (18 << 27) /* 0.418680911 */, - /* 6031 */ 0x06b34bd5 | (18 << 27) /* 0.418773491 */, - - /* 6032 */ 0x06b3acea | (18 << 27) /* 0.418866076 */, - /* 6033 */ 0x06b40e00 | (18 << 27) /* 0.418958666 */, - /* 6034 */ 0x06b46f18 | (18 << 27) /* 0.419051262 */, - /* 6035 */ 0x06b4d031 | (18 << 27) /* 0.419143862 */, - /* 6036 */ 0x06b5314c | (18 << 27) /* 0.419236467 */, - /* 6037 */ 0x06b59268 | (18 << 27) /* 0.419329078 */, - /* 6038 */ 0x06b5f385 | (18 << 27) /* 0.419421694 */, - /* 6039 */ 0x06b654a4 | (18 << 27) /* 0.419514314 */, - /* 6040 */ 0x06b6b5c4 | (18 << 27) /* 0.419606940 */, - /* 6041 */ 0x06b716e6 | (18 << 27) /* 0.419699571 */, - /* 6042 */ 0x06b77808 | (18 << 27) /* 0.419792208 */, - /* 6043 */ 0x06b7d92d | (18 << 27) /* 0.419884849 */, - /* 6044 */ 0x06b83a52 | (18 << 27) /* 0.419977495 */, - /* 6045 */ 0x06b89b79 | (18 << 27) /* 0.420070147 */, - /* 6046 */ 0x06b8fca1 | (18 << 27) /* 0.420162803 */, - /* 6047 */ 0x06b95dcb | (18 << 27) /* 0.420255465 */, - - /* 6048 */ 0x06b9bef6 | (18 << 27) /* 0.420348132 */, - /* 6049 */ 0x06ba2023 | (18 << 27) /* 0.420440803 */, - /* 6050 */ 0x06ba8150 | (18 << 27) /* 0.420533481 */, - /* 6051 */ 0x06bae280 | (18 << 27) /* 0.420626163 */, - /* 6052 */ 0x06bb43b0 | (18 << 27) /* 0.420718850 */, - /* 6053 */ 0x06bba4e2 | (18 << 27) /* 0.420811542 */, - /* 6054 */ 0x06bc0615 | (18 << 27) /* 0.420904240 */, - /* 6055 */ 0x06bc674a | (18 << 27) /* 0.420996942 */, - /* 6056 */ 0x06bcc880 | (18 << 27) /* 0.421089650 */, - /* 6057 */ 0x06bd29b7 | (18 << 27) /* 0.421182362 */, - /* 6058 */ 0x06bd8af0 | (18 << 27) /* 0.421275080 */, - /* 6059 */ 0x06bdec2a | (18 << 27) /* 0.421367803 */, - /* 6060 */ 0x06be4d66 | (18 << 27) /* 0.421460531 */, - /* 6061 */ 0x06beaea3 | (18 << 27) /* 0.421553264 */, - /* 6062 */ 0x06bf0fe1 | (18 << 27) /* 0.421646003 */, - /* 6063 */ 0x06bf7120 | (18 << 27) /* 0.421738746 */, - - /* 6064 */ 0x06bfd261 | (18 << 27) /* 0.421831494 */, - /* 6065 */ 0x06c033a4 | (18 << 27) /* 0.421924248 */, - /* 6066 */ 0x06c094e7 | (18 << 27) /* 0.422017007 */, - /* 6067 */ 0x06c0f62c | (18 << 27) /* 0.422109770 */, - /* 6068 */ 0x06c15773 | (18 << 27) /* 0.422202539 */, - /* 6069 */ 0x06c1b8bb | (18 << 27) /* 0.422295313 */, - /* 6070 */ 0x06c21a04 | (18 << 27) /* 0.422388092 */, - /* 6071 */ 0x06c27b4e | (18 << 27) /* 0.422480876 */, - /* 6072 */ 0x06c2dc9a | (18 << 27) /* 0.422573665 */, - /* 6073 */ 0x06c33de8 | (18 << 27) /* 0.422666460 */, - /* 6074 */ 0x06c39f36 | (18 << 27) /* 0.422759259 */, - /* 6075 */ 0x06c40086 | (18 << 27) /* 0.422852064 */, - /* 6076 */ 0x06c461d8 | (18 << 27) /* 0.422944873 */, - /* 6077 */ 0x06c4c32a | (18 << 27) /* 0.423037688 */, - /* 6078 */ 0x06c5247f | (18 << 27) /* 0.423130508 */, - /* 6079 */ 0x06c585d4 | (18 << 27) /* 0.423223333 */, - - /* 6080 */ 0x06c5e72b | (18 << 27) /* 0.423316162 */, - /* 6081 */ 0x06c64883 | (18 << 27) /* 0.423408997 */, - /* 6082 */ 0x06c6a9dd | (18 << 27) /* 0.423501838 */, - /* 6083 */ 0x06c70b38 | (18 << 27) /* 0.423594683 */, - /* 6084 */ 0x06c76c94 | (18 << 27) /* 0.423687533 */, - /* 6085 */ 0x06c7cdf2 | (18 << 27) /* 0.423780389 */, - /* 6086 */ 0x06c82f51 | (18 << 27) /* 0.423873249 */, - /* 6087 */ 0x06c890b1 | (18 << 27) /* 0.423966115 */, - /* 6088 */ 0x06c8f213 | (18 << 27) /* 0.424058985 */, - /* 6089 */ 0x06c95376 | (18 << 27) /* 0.424151861 */, - /* 6090 */ 0x06c9b4da | (18 << 27) /* 0.424244742 */, - /* 6091 */ 0x06ca1640 | (18 << 27) /* 0.424337628 */, - /* 6092 */ 0x06ca77a8 | (18 << 27) /* 0.424430519 */, - /* 6093 */ 0x06cad910 | (18 << 27) /* 0.424523415 */, - /* 6094 */ 0x06cb3a7a | (18 << 27) /* 0.424616316 */, - /* 6095 */ 0x06cb9be5 | (18 << 27) /* 0.424709222 */, - - /* 6096 */ 0x06cbfd52 | (18 << 27) /* 0.424802133 */, - /* 6097 */ 0x06cc5ec0 | (18 << 27) /* 0.424895050 */, - /* 6098 */ 0x06ccc030 | (18 << 27) /* 0.424987971 */, - /* 6099 */ 0x06cd21a0 | (18 << 27) /* 0.425080898 */, - /* 6100 */ 0x06cd8313 | (18 << 27) /* 0.425173829 */, - /* 6101 */ 0x06cde486 | (18 << 27) /* 0.425266766 */, - /* 6102 */ 0x06ce45fb | (18 << 27) /* 0.425359708 */, - /* 6103 */ 0x06cea771 | (18 << 27) /* 0.425452655 */, - /* 6104 */ 0x06cf08e9 | (18 << 27) /* 0.425545607 */, - /* 6105 */ 0x06cf6a62 | (18 << 27) /* 0.425638564 */, - /* 6106 */ 0x06cfcbdc | (18 << 27) /* 0.425731526 */, - /* 6107 */ 0x06d02d58 | (18 << 27) /* 0.425824493 */, - /* 6108 */ 0x06d08ed5 | (18 << 27) /* 0.425917465 */, - /* 6109 */ 0x06d0f053 | (18 << 27) /* 0.426010443 */, - /* 6110 */ 0x06d151d3 | (18 << 27) /* 0.426103425 */, - /* 6111 */ 0x06d1b354 | (18 << 27) /* 0.426196412 */, - - /* 6112 */ 0x06d214d7 | (18 << 27) /* 0.426289405 */, - /* 6113 */ 0x06d2765a | (18 << 27) /* 0.426382403 */, - /* 6114 */ 0x06d2d7e0 | (18 << 27) /* 0.426475405 */, - /* 6115 */ 0x06d33966 | (18 << 27) /* 0.426568413 */, - /* 6116 */ 0x06d39aee | (18 << 27) /* 0.426661426 */, - /* 6117 */ 0x06d3fc77 | (18 << 27) /* 0.426754444 */, - /* 6118 */ 0x06d45e02 | (18 << 27) /* 0.426847467 */, - /* 6119 */ 0x06d4bf8e | (18 << 27) /* 0.426940495 */, - /* 6120 */ 0x06d5211c | (18 << 27) /* 0.427033528 */, - /* 6121 */ 0x06d582aa | (18 << 27) /* 0.427126566 */, - /* 6122 */ 0x06d5e43a | (18 << 27) /* 0.427219609 */, - /* 6123 */ 0x06d645cc | (18 << 27) /* 0.427312657 */, - /* 6124 */ 0x06d6a75f | (18 << 27) /* 0.427405711 */, - /* 6125 */ 0x06d708f3 | (18 << 27) /* 0.427498769 */, - /* 6126 */ 0x06d76a88 | (18 << 27) /* 0.427591833 */, - /* 6127 */ 0x06d7cc1f | (18 << 27) /* 0.427684901 */, - - /* 6128 */ 0x06d82db8 | (18 << 27) /* 0.427777975 */, - /* 6129 */ 0x06d88f51 | (18 << 27) /* 0.427871054 */, - /* 6130 */ 0x06d8f0ec | (18 << 27) /* 0.427964137 */, - /* 6131 */ 0x06d95288 | (18 << 27) /* 0.428057226 */, - /* 6132 */ 0x06d9b426 | (18 << 27) /* 0.428150320 */, - /* 6133 */ 0x06da15c5 | (18 << 27) /* 0.428243419 */, - /* 6134 */ 0x06da7766 | (18 << 27) /* 0.428336523 */, - /* 6135 */ 0x06dad907 | (18 << 27) /* 0.428429632 */, - /* 6136 */ 0x06db3aaa | (18 << 27) /* 0.428522746 */, - /* 6137 */ 0x06db9c4f | (18 << 27) /* 0.428615865 */, - /* 6138 */ 0x06dbfdf5 | (18 << 27) /* 0.428708989 */, - /* 6139 */ 0x06dc5f9c | (18 << 27) /* 0.428802119 */, - /* 6140 */ 0x06dcc145 | (18 << 27) /* 0.428895253 */, - /* 6141 */ 0x06dd22ee | (18 << 27) /* 0.428988392 */, - /* 6142 */ 0x06dd849a | (18 << 27) /* 0.429081537 */, - /* 6143 */ 0x06dde646 | (18 << 27) /* 0.429174686 */, - - /* 6144 */ 0x06de47f4 | (18 << 27) /* 0.429267841 */, - /* 6145 */ 0x06dea9a4 | (18 << 27) /* 0.429361001 */, - /* 6146 */ 0x06df0b54 | (18 << 27) /* 0.429454165 */, - /* 6147 */ 0x06df6d06 | (18 << 27) /* 0.429547335 */, - /* 6148 */ 0x06dfceba | (18 << 27) /* 0.429640510 */, - /* 6149 */ 0x06e0306f | (18 << 27) /* 0.429733690 */, - /* 6150 */ 0x06e09225 | (18 << 27) /* 0.429826874 */, - /* 6151 */ 0x06e0f3dc | (18 << 27) /* 0.429920064 */, - /* 6152 */ 0x06e15595 | (18 << 27) /* 0.430013259 */, - /* 6153 */ 0x06e1b74f | (18 << 27) /* 0.430106459 */, - /* 6154 */ 0x06e2190b | (18 << 27) /* 0.430199664 */, - /* 6155 */ 0x06e27ac8 | (18 << 27) /* 0.430292875 */, - /* 6156 */ 0x06e2dc86 | (18 << 27) /* 0.430386090 */, - /* 6157 */ 0x06e33e46 | (18 << 27) /* 0.430479310 */, - /* 6158 */ 0x06e3a007 | (18 << 27) /* 0.430572535 */, - /* 6159 */ 0x06e401c9 | (18 << 27) /* 0.430665765 */, - - /* 6160 */ 0x06e4638d | (18 << 27) /* 0.430759001 */, - /* 6161 */ 0x06e4c552 | (18 << 27) /* 0.430852241 */, - /* 6162 */ 0x06e52718 | (18 << 27) /* 0.430945487 */, - /* 6163 */ 0x06e588e0 | (18 << 27) /* 0.431038737 */, - /* 6164 */ 0x06e5eaa9 | (18 << 27) /* 0.431131993 */, - /* 6165 */ 0x06e64c73 | (18 << 27) /* 0.431225253 */, - /* 6166 */ 0x06e6ae3f | (18 << 27) /* 0.431318519 */, - /* 6167 */ 0x06e7100c | (18 << 27) /* 0.431411790 */, - /* 6168 */ 0x06e771db | (18 << 27) /* 0.431505065 */, - /* 6169 */ 0x06e7d3ab | (18 << 27) /* 0.431598346 */, - /* 6170 */ 0x06e8357c | (18 << 27) /* 0.431691632 */, - /* 6171 */ 0x06e8974e | (18 << 27) /* 0.431784923 */, - /* 6172 */ 0x06e8f922 | (18 << 27) /* 0.431878218 */, - /* 6173 */ 0x06e95af8 | (18 << 27) /* 0.431971519 */, - /* 6174 */ 0x06e9bcce | (18 << 27) /* 0.432064825 */, - /* 6175 */ 0x06ea1ea6 | (18 << 27) /* 0.432158136 */, - - /* 6176 */ 0x06ea807f | (18 << 27) /* 0.432251452 */, - /* 6177 */ 0x06eae25a | (18 << 27) /* 0.432344773 */, - /* 6178 */ 0x06eb4436 | (18 << 27) /* 0.432438099 */, - /* 6179 */ 0x06eba614 | (18 << 27) /* 0.432531431 */, - /* 6180 */ 0x06ec07f2 | (18 << 27) /* 0.432624767 */, - /* 6181 */ 0x06ec69d2 | (18 << 27) /* 0.432718108 */, - /* 6182 */ 0x06eccbb4 | (18 << 27) /* 0.432811454 */, - /* 6183 */ 0x06ed2d97 | (18 << 27) /* 0.432904805 */, - /* 6184 */ 0x06ed8f7b | (18 << 27) /* 0.432998162 */, - /* 6185 */ 0x06edf160 | (18 << 27) /* 0.433091523 */, - /* 6186 */ 0x06ee5347 | (18 << 27) /* 0.433184889 */, - /* 6187 */ 0x06eeb52f | (18 << 27) /* 0.433278261 */, - /* 6188 */ 0x06ef1719 | (18 << 27) /* 0.433371637 */, - /* 6189 */ 0x06ef7904 | (18 << 27) /* 0.433465019 */, - /* 6190 */ 0x06efdaf0 | (18 << 27) /* 0.433558405 */, - /* 6191 */ 0x06f03cde | (18 << 27) /* 0.433651797 */, - - /* 6192 */ 0x06f09ecc | (18 << 27) /* 0.433745193 */, - /* 6193 */ 0x06f100bd | (18 << 27) /* 0.433838595 */, - /* 6194 */ 0x06f162ae | (18 << 27) /* 0.433932001 */, - /* 6195 */ 0x06f1c4a1 | (18 << 27) /* 0.434025413 */, - /* 6196 */ 0x06f22696 | (18 << 27) /* 0.434118830 */, - /* 6197 */ 0x06f2888b | (18 << 27) /* 0.434212251 */, - /* 6198 */ 0x06f2ea82 | (18 << 27) /* 0.434305678 */, - /* 6199 */ 0x06f34c7b | (18 << 27) /* 0.434399110 */, - /* 6200 */ 0x06f3ae75 | (18 << 27) /* 0.434492546 */, - /* 6201 */ 0x06f41070 | (18 << 27) /* 0.434585988 */, - /* 6202 */ 0x06f4726c | (18 << 27) /* 0.434679435 */, - /* 6203 */ 0x06f4d46a | (18 << 27) /* 0.434772887 */, - /* 6204 */ 0x06f53669 | (18 << 27) /* 0.434866344 */, - /* 6205 */ 0x06f59869 | (18 << 27) /* 0.434959806 */, - /* 6206 */ 0x06f5fa6b | (18 << 27) /* 0.435053272 */, - /* 6207 */ 0x06f65c6e | (18 << 27) /* 0.435146744 */, - - /* 6208 */ 0x06f6be73 | (18 << 27) /* 0.435240221 */, - /* 6209 */ 0x06f72079 | (18 << 27) /* 0.435333703 */, - /* 6210 */ 0x06f78280 | (18 << 27) /* 0.435427190 */, - /* 6211 */ 0x06f7e489 | (18 << 27) /* 0.435520682 */, - /* 6212 */ 0x06f84693 | (18 << 27) /* 0.435614179 */, - /* 6213 */ 0x06f8a89e | (18 << 27) /* 0.435707681 */, - /* 6214 */ 0x06f90aaa | (18 << 27) /* 0.435801188 */, - /* 6215 */ 0x06f96cb8 | (18 << 27) /* 0.435894700 */, - /* 6216 */ 0x06f9cec8 | (18 << 27) /* 0.435988217 */, - /* 6217 */ 0x06fa30d8 | (18 << 27) /* 0.436081739 */, - /* 6218 */ 0x06fa92ea | (18 << 27) /* 0.436175266 */, - /* 6219 */ 0x06faf4fe | (18 << 27) /* 0.436268799 */, - /* 6220 */ 0x06fb5712 | (18 << 27) /* 0.436362336 */, - /* 6221 */ 0x06fbb928 | (18 << 27) /* 0.436455878 */, - /* 6222 */ 0x06fc1b40 | (18 << 27) /* 0.436549425 */, - /* 6223 */ 0x06fc7d58 | (18 << 27) /* 0.436642977 */, - - /* 6224 */ 0x06fcdf72 | (18 << 27) /* 0.436736534 */, - /* 6225 */ 0x06fd418e | (18 << 27) /* 0.436830096 */, - /* 6226 */ 0x06fda3ab | (18 << 27) /* 0.436923664 */, - /* 6227 */ 0x06fe05c9 | (18 << 27) /* 0.437017236 */, - /* 6228 */ 0x06fe67e8 | (18 << 27) /* 0.437110813 */, - /* 6229 */ 0x06feca09 | (18 << 27) /* 0.437204395 */, - /* 6230 */ 0x06ff2c2b | (18 << 27) /* 0.437297982 */, - /* 6231 */ 0x06ff8e4f | (18 << 27) /* 0.437391575 */, - /* 6232 */ 0x06fff073 | (18 << 27) /* 0.437485172 */, - /* 6233 */ 0x0700529a | (18 << 27) /* 0.437578774 */, - /* 6234 */ 0x0700b4c1 | (18 << 27) /* 0.437672381 */, - /* 6235 */ 0x070116ea | (18 << 27) /* 0.437765994 */, - /* 6236 */ 0x07017914 | (18 << 27) /* 0.437859611 */, - /* 6237 */ 0x0701db40 | (18 << 27) /* 0.437953233 */, - /* 6238 */ 0x07023d6c | (18 << 27) /* 0.438046860 */, - /* 6239 */ 0x07029f9b | (18 << 27) /* 0.438140493 */, - - /* 6240 */ 0x070301ca | (18 << 27) /* 0.438234130 */, - /* 6241 */ 0x070363fb | (18 << 27) /* 0.438327772 */, - /* 6242 */ 0x0703c62d | (18 << 27) /* 0.438421419 */, - /* 6243 */ 0x07042861 | (18 << 27) /* 0.438515072 */, - /* 6244 */ 0x07048a96 | (18 << 27) /* 0.438608729 */, - /* 6245 */ 0x0704eccc | (18 << 27) /* 0.438702391 */, - /* 6246 */ 0x07054f04 | (18 << 27) /* 0.438796059 */, - /* 6247 */ 0x0705b13d | (18 << 27) /* 0.438889731 */, - /* 6248 */ 0x07061377 | (18 << 27) /* 0.438983408 */, - /* 6249 */ 0x070675b3 | (18 << 27) /* 0.439077090 */, - /* 6250 */ 0x0706d7f0 | (18 << 27) /* 0.439170778 */, - /* 6251 */ 0x07073a2e | (18 << 27) /* 0.439264470 */, - /* 6252 */ 0x07079c6e | (18 << 27) /* 0.439358167 */, - /* 6253 */ 0x0707feaf | (18 << 27) /* 0.439451869 */, - /* 6254 */ 0x070860f1 | (18 << 27) /* 0.439545577 */, - /* 6255 */ 0x0708c335 | (18 << 27) /* 0.439639289 */, - - /* 6256 */ 0x0709257a | (18 << 27) /* 0.439733006 */, - /* 6257 */ 0x070987c0 | (18 << 27) /* 0.439826728 */, - /* 6258 */ 0x0709ea08 | (18 << 27) /* 0.439920456 */, - /* 6259 */ 0x070a4c51 | (18 << 27) /* 0.440014188 */, - /* 6260 */ 0x070aae9b | (18 << 27) /* 0.440107925 */, - /* 6261 */ 0x070b10e7 | (18 << 27) /* 0.440201667 */, - /* 6262 */ 0x070b7334 | (18 << 27) /* 0.440295414 */, - /* 6263 */ 0x070bd583 | (18 << 27) /* 0.440389167 */, - /* 6264 */ 0x070c37d2 | (18 << 27) /* 0.440482924 */, - /* 6265 */ 0x070c9a23 | (18 << 27) /* 0.440576686 */, - /* 6266 */ 0x070cfc76 | (18 << 27) /* 0.440670453 */, - /* 6267 */ 0x070d5eca | (18 << 27) /* 0.440764225 */, - /* 6268 */ 0x070dc11f | (18 << 27) /* 0.440858002 */, - /* 6269 */ 0x070e2375 | (18 << 27) /* 0.440951784 */, - /* 6270 */ 0x070e85cd | (18 << 27) /* 0.441045572 */, - /* 6271 */ 0x070ee826 | (18 << 27) /* 0.441139364 */, - - /* 6272 */ 0x070f4a80 | (18 << 27) /* 0.441233161 */, - /* 6273 */ 0x070facdc | (18 << 27) /* 0.441326963 */, - /* 6274 */ 0x07100f39 | (18 << 27) /* 0.441420770 */, - /* 6275 */ 0x07107198 | (18 << 27) /* 0.441514582 */, - /* 6276 */ 0x0710d3f8 | (18 << 27) /* 0.441608399 */, - /* 6277 */ 0x07113659 | (18 << 27) /* 0.441702221 */, - /* 6278 */ 0x071198bb | (18 << 27) /* 0.441796048 */, - /* 6279 */ 0x0711fb1f | (18 << 27) /* 0.441889880 */, - /* 6280 */ 0x07125d84 | (18 << 27) /* 0.441983717 */, - /* 6281 */ 0x0712bfeb | (18 << 27) /* 0.442077559 */, - /* 6282 */ 0x07132253 | (18 << 27) /* 0.442171406 */, - /* 6283 */ 0x071384bc | (18 << 27) /* 0.442265257 */, - /* 6284 */ 0x0713e726 | (18 << 27) /* 0.442359114 */, - /* 6285 */ 0x07144992 | (18 << 27) /* 0.442452976 */, - /* 6286 */ 0x0714abff | (18 << 27) /* 0.442546843 */, - /* 6287 */ 0x07150e6e | (18 << 27) /* 0.442640715 */, - - /* 6288 */ 0x071570de | (18 << 27) /* 0.442734592 */, - /* 6289 */ 0x0715d34f | (18 << 27) /* 0.442828473 */, - /* 6290 */ 0x071635c1 | (18 << 27) /* 0.442922360 */, - /* 6291 */ 0x07169835 | (18 << 27) /* 0.443016252 */, - /* 6292 */ 0x0716faaa | (18 << 27) /* 0.443110148 */, - /* 6293 */ 0x07175d21 | (18 << 27) /* 0.443204050 */, - /* 6294 */ 0x0717bf99 | (18 << 27) /* 0.443297957 */, - /* 6295 */ 0x07182212 | (18 << 27) /* 0.443391868 */, - /* 6296 */ 0x0718848d | (18 << 27) /* 0.443485785 */, - /* 6297 */ 0x0718e709 | (18 << 27) /* 0.443579706 */, - /* 6298 */ 0x07194986 | (18 << 27) /* 0.443673633 */, - /* 6299 */ 0x0719ac04 | (18 << 27) /* 0.443767564 */, - /* 6300 */ 0x071a0e84 | (18 << 27) /* 0.443861501 */, - /* 6301 */ 0x071a7105 | (18 << 27) /* 0.443955442 */, - /* 6302 */ 0x071ad388 | (18 << 27) /* 0.444049389 */, - /* 6303 */ 0x071b360c | (18 << 27) /* 0.444143340 */, - - /* 6304 */ 0x071b9891 | (18 << 27) /* 0.444237296 */, - /* 6305 */ 0x071bfb18 | (18 << 27) /* 0.444331258 */, - /* 6306 */ 0x071c5d9f | (18 << 27) /* 0.444425224 */, - /* 6307 */ 0x071cc029 | (18 << 27) /* 0.444519195 */, - /* 6308 */ 0x071d22b3 | (18 << 27) /* 0.444613171 */, - /* 6309 */ 0x071d853f | (18 << 27) /* 0.444707153 */, - /* 6310 */ 0x071de7cc | (18 << 27) /* 0.444801139 */, - /* 6311 */ 0x071e4a5b | (18 << 27) /* 0.444895130 */, - /* 6312 */ 0x071eaceb | (18 << 27) /* 0.444989126 */, - /* 6313 */ 0x071f0f7c | (18 << 27) /* 0.445083127 */, - /* 6314 */ 0x071f720e | (18 << 27) /* 0.445177133 */, - /* 6315 */ 0x071fd4a2 | (18 << 27) /* 0.445271144 */, - /* 6316 */ 0x07203737 | (18 << 27) /* 0.445365160 */, - /* 6317 */ 0x072099ce | (18 << 27) /* 0.445459181 */, - /* 6318 */ 0x0720fc66 | (18 << 27) /* 0.445553206 */, - /* 6319 */ 0x07215eff | (18 << 27) /* 0.445647237 */, - - /* 6320 */ 0x0721c19a | (18 << 27) /* 0.445741273 */, - /* 6321 */ 0x07222436 | (18 << 27) /* 0.445835314 */, - /* 6322 */ 0x072286d3 | (18 << 27) /* 0.445929359 */, - /* 6323 */ 0x0722e971 | (18 << 27) /* 0.446023410 */, - /* 6324 */ 0x07234c11 | (18 << 27) /* 0.446117466 */, - /* 6325 */ 0x0723aeb2 | (18 << 27) /* 0.446211526 */, - /* 6326 */ 0x07241155 | (18 << 27) /* 0.446305592 */, - /* 6327 */ 0x072473f9 | (18 << 27) /* 0.446399662 */, - /* 6328 */ 0x0724d69e | (18 << 27) /* 0.446493738 */, - /* 6329 */ 0x07253944 | (18 << 27) /* 0.446587818 */, - /* 6330 */ 0x07259bec | (18 << 27) /* 0.446681903 */, - /* 6331 */ 0x0725fe95 | (18 << 27) /* 0.446775994 */, - /* 6332 */ 0x07266140 | (18 << 27) /* 0.446870089 */, - /* 6333 */ 0x0726c3ec | (18 << 27) /* 0.446964189 */, - /* 6334 */ 0x07272699 | (18 << 27) /* 0.447058294 */, - /* 6335 */ 0x07278947 | (18 << 27) /* 0.447152404 */, - - /* 6336 */ 0x0727ebf7 | (18 << 27) /* 0.447246519 */, - /* 6337 */ 0x07284ea8 | (18 << 27) /* 0.447340639 */, - /* 6338 */ 0x0728b15b | (18 << 27) /* 0.447434764 */, - /* 6339 */ 0x0729140f | (18 << 27) /* 0.447528894 */, - /* 6340 */ 0x072976c4 | (18 << 27) /* 0.447623029 */, - /* 6341 */ 0x0729d97a | (18 << 27) /* 0.447717169 */, - /* 6342 */ 0x072a3c32 | (18 << 27) /* 0.447811314 */, - /* 6343 */ 0x072a9eeb | (18 << 27) /* 0.447905463 */, - /* 6344 */ 0x072b01a6 | (18 << 27) /* 0.447999618 */, - /* 6345 */ 0x072b6461 | (18 << 27) /* 0.448093778 */, - /* 6346 */ 0x072bc71e | (18 << 27) /* 0.448187942 */, - /* 6347 */ 0x072c29dd | (18 << 27) /* 0.448282112 */, - /* 6348 */ 0x072c8c9d | (18 << 27) /* 0.448376286 */, - /* 6349 */ 0x072cef5e | (18 << 27) /* 0.448470466 */, - /* 6350 */ 0x072d5220 | (18 << 27) /* 0.448564650 */, - /* 6351 */ 0x072db4e4 | (18 << 27) /* 0.448658839 */, - - /* 6352 */ 0x072e17a9 | (18 << 27) /* 0.448753033 */, - /* 6353 */ 0x072e7a6f | (18 << 27) /* 0.448847233 */, - /* 6354 */ 0x072edd37 | (18 << 27) /* 0.448941437 */, - /* 6355 */ 0x072f4000 | (18 << 27) /* 0.449035646 */, - /* 6356 */ 0x072fa2ca | (18 << 27) /* 0.449129860 */, - /* 6357 */ 0x07300596 | (18 << 27) /* 0.449224079 */, - /* 6358 */ 0x07306863 | (18 << 27) /* 0.449318303 */, - /* 6359 */ 0x0730cb32 | (18 << 27) /* 0.449412531 */, - /* 6360 */ 0x07312e01 | (18 << 27) /* 0.449506765 */, - /* 6361 */ 0x073190d2 | (18 << 27) /* 0.449601004 */, - /* 6362 */ 0x0731f3a5 | (18 << 27) /* 0.449695247 */, - /* 6363 */ 0x07325678 | (18 << 27) /* 0.449789496 */, - /* 6364 */ 0x0732b94d | (18 << 27) /* 0.449883749 */, - /* 6365 */ 0x07331c23 | (18 << 27) /* 0.449978008 */, - /* 6366 */ 0x07337efb | (18 << 27) /* 0.450072271 */, - /* 6367 */ 0x0733e1d4 | (18 << 27) /* 0.450166540 */, - - /* 6368 */ 0x073444ae | (18 << 27) /* 0.450260813 */, - /* 6369 */ 0x0734a78a | (18 << 27) /* 0.450355091 */, - /* 6370 */ 0x07350a67 | (18 << 27) /* 0.450449374 */, - /* 6371 */ 0x07356d45 | (18 << 27) /* 0.450543662 */, - /* 6372 */ 0x0735d025 | (18 << 27) /* 0.450637955 */, - /* 6373 */ 0x07363306 | (18 << 27) /* 0.450732253 */, - /* 6374 */ 0x073695e8 | (18 << 27) /* 0.450826556 */, - /* 6375 */ 0x0736f8cb | (18 << 27) /* 0.450920864 */, - /* 6376 */ 0x07375bb0 | (18 << 27) /* 0.451015176 */, - /* 6377 */ 0x0737be96 | (18 << 27) /* 0.451109494 */, - /* 6378 */ 0x0738217e | (18 << 27) /* 0.451203817 */, - /* 6379 */ 0x07388467 | (18 << 27) /* 0.451298144 */, - /* 6380 */ 0x0738e751 | (18 << 27) /* 0.451392477 */, - /* 6381 */ 0x07394a3d | (18 << 27) /* 0.451486814 */, - /* 6382 */ 0x0739ad29 | (18 << 27) /* 0.451581156 */, - /* 6383 */ 0x073a1017 | (18 << 27) /* 0.451675503 */, - - /* 6384 */ 0x073a7307 | (18 << 27) /* 0.451769856 */, - /* 6385 */ 0x073ad5f8 | (18 << 27) /* 0.451864213 */, - /* 6386 */ 0x073b38ea | (18 << 27) /* 0.451958575 */, - /* 6387 */ 0x073b9bdd | (18 << 27) /* 0.452052942 */, - /* 6388 */ 0x073bfed2 | (18 << 27) /* 0.452147313 */, - /* 6389 */ 0x073c61c8 | (18 << 27) /* 0.452241690 */, - /* 6390 */ 0x073cc4bf | (18 << 27) /* 0.452336072 */, - /* 6391 */ 0x073d27b8 | (18 << 27) /* 0.452430458 */, - /* 6392 */ 0x073d8ab2 | (18 << 27) /* 0.452524850 */, - /* 6393 */ 0x073dedae | (18 << 27) /* 0.452619246 */, - /* 6394 */ 0x073e50aa | (18 << 27) /* 0.452713648 */, - /* 6395 */ 0x073eb3a8 | (18 << 27) /* 0.452808054 */, - /* 6396 */ 0x073f16a8 | (18 << 27) /* 0.452902465 */, - /* 6397 */ 0x073f79a8 | (18 << 27) /* 0.452996882 */, - /* 6398 */ 0x073fdcaa | (18 << 27) /* 0.453091303 */, - /* 6399 */ 0x07403fad | (18 << 27) /* 0.453185729 */, - - /* 6400 */ 0x0740a2b2 | (18 << 27) /* 0.453280160 */, - /* 6401 */ 0x074105b8 | (18 << 27) /* 0.453374595 */, - /* 6402 */ 0x074168bf | (18 << 27) /* 0.453469036 */, - /* 6403 */ 0x0741cbc8 | (18 << 27) /* 0.453563482 */, - /* 6404 */ 0x07422ed2 | (18 << 27) /* 0.453657932 */, - /* 6405 */ 0x074291dd | (18 << 27) /* 0.453752388 */, - /* 6406 */ 0x0742f4e9 | (18 << 27) /* 0.453846848 */, - /* 6407 */ 0x074357f7 | (18 << 27) /* 0.453941314 */, - /* 6408 */ 0x0743bb06 | (18 << 27) /* 0.454035784 */, - /* 6409 */ 0x07441e17 | (18 << 27) /* 0.454130259 */, - /* 6410 */ 0x07448129 | (18 << 27) /* 0.454224739 */, - /* 6411 */ 0x0744e43c | (18 << 27) /* 0.454319224 */, - /* 6412 */ 0x07454750 | (18 << 27) /* 0.454413714 */, - /* 6413 */ 0x0745aa66 | (18 << 27) /* 0.454508209 */, - /* 6414 */ 0x07460d7d | (18 << 27) /* 0.454602708 */, - /* 6415 */ 0x07467095 | (18 << 27) /* 0.454697213 */, - - /* 6416 */ 0x0746d3af | (18 << 27) /* 0.454791723 */, - /* 6417 */ 0x074736ca | (18 << 27) /* 0.454886237 */, - /* 6418 */ 0x074799e7 | (18 << 27) /* 0.454980756 */, - /* 6419 */ 0x0747fd04 | (18 << 27) /* 0.455075281 */, - /* 6420 */ 0x07486023 | (18 << 27) /* 0.455169810 */, - /* 6421 */ 0x0748c344 | (18 << 27) /* 0.455264344 */, - /* 6422 */ 0x07492665 | (18 << 27) /* 0.455358883 */, - /* 6423 */ 0x07498988 | (18 << 27) /* 0.455453427 */, - /* 6424 */ 0x0749ecac | (18 << 27) /* 0.455547976 */, - /* 6425 */ 0x074a4fd2 | (18 << 27) /* 0.455642529 */, - /* 6426 */ 0x074ab2f9 | (18 << 27) /* 0.455737088 */, - /* 6427 */ 0x074b1621 | (18 << 27) /* 0.455831652 */, - /* 6428 */ 0x074b794b | (18 << 27) /* 0.455926220 */, - /* 6429 */ 0x074bdc75 | (18 << 27) /* 0.456020793 */, - /* 6430 */ 0x074c3fa1 | (18 << 27) /* 0.456115372 */, - /* 6431 */ 0x074ca2cf | (18 << 27) /* 0.456209955 */, - - /* 6432 */ 0x074d05fe | (18 << 27) /* 0.456304543 */, - /* 6433 */ 0x074d692e | (18 << 27) /* 0.456399136 */, - /* 6434 */ 0x074dcc5f | (18 << 27) /* 0.456493733 */, - /* 6435 */ 0x074e2f92 | (18 << 27) /* 0.456588336 */, - /* 6436 */ 0x074e92c6 | (18 << 27) /* 0.456682944 */, - /* 6437 */ 0x074ef5fb | (18 << 27) /* 0.456777556 */, - /* 6438 */ 0x074f5932 | (18 << 27) /* 0.456872174 */, - /* 6439 */ 0x074fbc6a | (18 << 27) /* 0.456966796 */, - /* 6440 */ 0x07501fa3 | (18 << 27) /* 0.457061423 */, - /* 6441 */ 0x075082de | (18 << 27) /* 0.457156056 */, - /* 6442 */ 0x0750e61a | (18 << 27) /* 0.457250693 */, - /* 6443 */ 0x07514957 | (18 << 27) /* 0.457345335 */, - /* 6444 */ 0x0751ac96 | (18 << 27) /* 0.457439981 */, - /* 6445 */ 0x07520fd6 | (18 << 27) /* 0.457534633 */, - /* 6446 */ 0x07527317 | (18 << 27) /* 0.457629290 */, - /* 6447 */ 0x0752d659 | (18 << 27) /* 0.457723951 */, - - /* 6448 */ 0x0753399d | (18 << 27) /* 0.457818618 */, - /* 6449 */ 0x07539ce2 | (18 << 27) /* 0.457913289 */, - /* 6450 */ 0x07540029 | (18 << 27) /* 0.458007965 */, - /* 6451 */ 0x07546371 | (18 << 27) /* 0.458102646 */, - /* 6452 */ 0x0754c6ba | (18 << 27) /* 0.458197332 */, - /* 6453 */ 0x07552a04 | (18 << 27) /* 0.458292023 */, - /* 6454 */ 0x07558d50 | (18 << 27) /* 0.458386719 */, - /* 6455 */ 0x0755f09d | (18 << 27) /* 0.458481420 */, - /* 6456 */ 0x075653eb | (18 << 27) /* 0.458576125 */, - /* 6457 */ 0x0756b73b | (18 << 27) /* 0.458670836 */, - /* 6458 */ 0x07571a8c | (18 << 27) /* 0.458765551 */, - /* 6459 */ 0x07577dde | (18 << 27) /* 0.458860271 */, - /* 6460 */ 0x0757e131 | (18 << 27) /* 0.458954996 */, - /* 6461 */ 0x07584486 | (18 << 27) /* 0.459049726 */, - /* 6462 */ 0x0758a7dd | (18 << 27) /* 0.459144461 */, - /* 6463 */ 0x07590b34 | (18 << 27) /* 0.459239201 */, - - /* 6464 */ 0x07596e8d | (18 << 27) /* 0.459333946 */, - /* 6465 */ 0x0759d1e7 | (18 << 27) /* 0.459428695 */, - /* 6466 */ 0x075a3542 | (18 << 27) /* 0.459523450 */, - /* 6467 */ 0x075a989f | (18 << 27) /* 0.459618209 */, - /* 6468 */ 0x075afbfd | (18 << 27) /* 0.459712973 */, - /* 6469 */ 0x075b5f5d | (18 << 27) /* 0.459807742 */, - /* 6470 */ 0x075bc2bd | (18 << 27) /* 0.459902516 */, - /* 6471 */ 0x075c261f | (18 << 27) /* 0.459997295 */, - /* 6472 */ 0x075c8983 | (18 << 27) /* 0.460092079 */, - /* 6473 */ 0x075cece7 | (18 << 27) /* 0.460186867 */, - /* 6474 */ 0x075d504d | (18 << 27) /* 0.460281661 */, - /* 6475 */ 0x075db3b5 | (18 << 27) /* 0.460376459 */, - /* 6476 */ 0x075e171d | (18 << 27) /* 0.460471262 */, - /* 6477 */ 0x075e7a87 | (18 << 27) /* 0.460566071 */, - /* 6478 */ 0x075eddf2 | (18 << 27) /* 0.460660884 */, - /* 6479 */ 0x075f415f | (18 << 27) /* 0.460755701 */, - - /* 6480 */ 0x075fa4cc | (18 << 27) /* 0.460850524 */, - /* 6481 */ 0x0760083b | (18 << 27) /* 0.460945352 */, - /* 6482 */ 0x07606bac | (18 << 27) /* 0.461040184 */, - /* 6483 */ 0x0760cf1e | (18 << 27) /* 0.461135022 */, - /* 6484 */ 0x07613291 | (18 << 27) /* 0.461229864 */, - /* 6485 */ 0x07619605 | (18 << 27) /* 0.461324711 */, - /* 6486 */ 0x0761f97b | (18 << 27) /* 0.461419563 */, - /* 6487 */ 0x07625cf2 | (18 << 27) /* 0.461514420 */, - /* 6488 */ 0x0762c06a | (18 << 27) /* 0.461609282 */, - /* 6489 */ 0x076323e3 | (18 << 27) /* 0.461704149 */, - /* 6490 */ 0x0763875e | (18 << 27) /* 0.461799020 */, - /* 6491 */ 0x0763eadb | (18 << 27) /* 0.461893897 */, - /* 6492 */ 0x07644e58 | (18 << 27) /* 0.461988778 */, - /* 6493 */ 0x0764b1d7 | (18 << 27) /* 0.462083664 */, - /* 6494 */ 0x07651557 | (18 << 27) /* 0.462178555 */, - /* 6495 */ 0x076578d8 | (18 << 27) /* 0.462273451 */, - - /* 6496 */ 0x0765dc5b | (18 << 27) /* 0.462368352 */, - /* 6497 */ 0x07663fdf | (18 << 27) /* 0.462463257 */, - /* 6498 */ 0x0766a364 | (18 << 27) /* 0.462558168 */, - /* 6499 */ 0x076706eb | (18 << 27) /* 0.462653083 */, - /* 6500 */ 0x07676a73 | (18 << 27) /* 0.462748003 */, - /* 6501 */ 0x0767cdfc | (18 << 27) /* 0.462842928 */, - /* 6502 */ 0x07683187 | (18 << 27) /* 0.462937858 */, - /* 6503 */ 0x07689513 | (18 << 27) /* 0.463032793 */, - /* 6504 */ 0x0768f8a0 | (18 << 27) /* 0.463127733 */, - /* 6505 */ 0x07695c2e | (18 << 27) /* 0.463222678 */, - /* 6506 */ 0x0769bfbe | (18 << 27) /* 0.463317627 */, - /* 6507 */ 0x076a234f | (18 << 27) /* 0.463412581 */, - /* 6508 */ 0x076a86e2 | (18 << 27) /* 0.463507540 */, - /* 6509 */ 0x076aea75 | (18 << 27) /* 0.463602504 */, - /* 6510 */ 0x076b4e0a | (18 << 27) /* 0.463697473 */, - /* 6511 */ 0x076bb1a1 | (18 << 27) /* 0.463792447 */, - - /* 6512 */ 0x076c1538 | (18 << 27) /* 0.463887426 */, - /* 6513 */ 0x076c78d1 | (18 << 27) /* 0.463982409 */, - /* 6514 */ 0x076cdc6c | (18 << 27) /* 0.464077398 */, - /* 6515 */ 0x076d4007 | (18 << 27) /* 0.464172391 */, - /* 6516 */ 0x076da3a4 | (18 << 27) /* 0.464267389 */, - /* 6517 */ 0x076e0742 | (18 << 27) /* 0.464362392 */, - /* 6518 */ 0x076e6ae2 | (18 << 27) /* 0.464457399 */, - /* 6519 */ 0x076ece82 | (18 << 27) /* 0.464552412 */, - /* 6520 */ 0x076f3224 | (18 << 27) /* 0.464647430 */, - /* 6521 */ 0x076f95c8 | (18 << 27) /* 0.464742452 */, - /* 6522 */ 0x076ff96c | (18 << 27) /* 0.464837479 */, - /* 6523 */ 0x07705d12 | (18 << 27) /* 0.464932511 */, - /* 6524 */ 0x0770c0ba | (18 << 27) /* 0.465027548 */, - /* 6525 */ 0x07712462 | (18 << 27) /* 0.465122590 */, - /* 6526 */ 0x0771880c | (18 << 27) /* 0.465217637 */, - /* 6527 */ 0x0771ebb7 | (18 << 27) /* 0.465312688 */, - - /* 6528 */ 0x07724f64 | (18 << 27) /* 0.465407744 */, - /* 6529 */ 0x0772b312 | (18 << 27) /* 0.465502806 */, - /* 6530 */ 0x077316c1 | (18 << 27) /* 0.465597872 */, - /* 6531 */ 0x07737a71 | (18 << 27) /* 0.465692943 */, - /* 6532 */ 0x0773de23 | (18 << 27) /* 0.465788018 */, - /* 6533 */ 0x077441d6 | (18 << 27) /* 0.465883099 */, - /* 6534 */ 0x0774a58a | (18 << 27) /* 0.465978184 */, - /* 6535 */ 0x07750940 | (18 << 27) /* 0.466073275 */, - /* 6536 */ 0x07756cf7 | (18 << 27) /* 0.466168370 */, - /* 6537 */ 0x0775d0af | (18 << 27) /* 0.466263470 */, - /* 6538 */ 0x07763468 | (18 << 27) /* 0.466358575 */, - /* 6539 */ 0x07769823 | (18 << 27) /* 0.466453684 */, - /* 6540 */ 0x0776fbdf | (18 << 27) /* 0.466548799 */, - /* 6541 */ 0x07775f9d | (18 << 27) /* 0.466643918 */, - /* 6542 */ 0x0777c35c | (18 << 27) /* 0.466739043 */, - /* 6543 */ 0x0778271c | (18 << 27) /* 0.466834172 */, - - /* 6544 */ 0x07788add | (18 << 27) /* 0.466929306 */, - /* 6545 */ 0x0778ee9f | (18 << 27) /* 0.467024445 */, - /* 6546 */ 0x07795263 | (18 << 27) /* 0.467119588 */, - /* 6547 */ 0x0779b629 | (18 << 27) /* 0.467214737 */, - /* 6548 */ 0x077a19ef | (18 << 27) /* 0.467309890 */, - /* 6549 */ 0x077a7db7 | (18 << 27) /* 0.467405048 */, - /* 6550 */ 0x077ae180 | (18 << 27) /* 0.467500211 */, - /* 6551 */ 0x077b454b | (18 << 27) /* 0.467595379 */, - /* 6552 */ 0x077ba916 | (18 << 27) /* 0.467690552 */, - /* 6553 */ 0x077c0ce3 | (18 << 27) /* 0.467785729 */, - /* 6554 */ 0x077c70b2 | (18 << 27) /* 0.467880912 */, - /* 6555 */ 0x077cd481 | (18 << 27) /* 0.467976099 */, - /* 6556 */ 0x077d3852 | (18 << 27) /* 0.468071291 */, - /* 6557 */ 0x077d9c24 | (18 << 27) /* 0.468166488 */, - /* 6558 */ 0x077dfff8 | (18 << 27) /* 0.468261690 */, - /* 6559 */ 0x077e63cd | (18 << 27) /* 0.468356896 */, - - /* 6560 */ 0x077ec7a3 | (18 << 27) /* 0.468452108 */, - /* 6561 */ 0x077f2b7a | (18 << 27) /* 0.468547324 */, - /* 6562 */ 0x077f8f53 | (18 << 27) /* 0.468642545 */, - /* 6563 */ 0x077ff32d | (18 << 27) /* 0.468737771 */, - /* 6564 */ 0x07805708 | (18 << 27) /* 0.468833002 */, - /* 6565 */ 0x0780bae5 | (18 << 27) /* 0.468928237 */, - /* 6566 */ 0x07811ec3 | (18 << 27) /* 0.469023478 */, - /* 6567 */ 0x078182a2 | (18 << 27) /* 0.469118723 */, - /* 6568 */ 0x0781e683 | (18 << 27) /* 0.469213973 */, - /* 6569 */ 0x07824a64 | (18 << 27) /* 0.469309228 */, - /* 6570 */ 0x0782ae47 | (18 << 27) /* 0.469404488 */, - /* 6571 */ 0x0783122c | (18 << 27) /* 0.469499752 */, - /* 6572 */ 0x07837612 | (18 << 27) /* 0.469595022 */, - /* 6573 */ 0x0783d9f9 | (18 << 27) /* 0.469690296 */, - /* 6574 */ 0x07843de1 | (18 << 27) /* 0.469785575 */, - /* 6575 */ 0x0784a1ca | (18 << 27) /* 0.469880859 */, - - /* 6576 */ 0x078505b5 | (18 << 27) /* 0.469976148 */, - /* 6577 */ 0x078569a2 | (18 << 27) /* 0.470071442 */, - /* 6578 */ 0x0785cd8f | (18 << 27) /* 0.470166740 */, - /* 6579 */ 0x0786317e | (18 << 27) /* 0.470262043 */, - /* 6580 */ 0x0786956e | (18 << 27) /* 0.470357351 */, - /* 6581 */ 0x0786f95f | (18 << 27) /* 0.470452664 */, - /* 6582 */ 0x07875d52 | (18 << 27) /* 0.470547982 */, - /* 6583 */ 0x0787c146 | (18 << 27) /* 0.470643305 */, - /* 6584 */ 0x0788253b | (18 << 27) /* 0.470738632 */, - /* 6585 */ 0x07888932 | (18 << 27) /* 0.470833964 */, - /* 6586 */ 0x0788ed2a | (18 << 27) /* 0.470929301 */, - /* 6587 */ 0x07895123 | (18 << 27) /* 0.471024643 */, - /* 6588 */ 0x0789b51d | (18 << 27) /* 0.471119990 */, - /* 6589 */ 0x078a1919 | (18 << 27) /* 0.471215341 */, - /* 6590 */ 0x078a7d16 | (18 << 27) /* 0.471310698 */, - /* 6591 */ 0x078ae114 | (18 << 27) /* 0.471406059 */, - - /* 6592 */ 0x078b4514 | (18 << 27) /* 0.471501425 */, - /* 6593 */ 0x078ba915 | (18 << 27) /* 0.471596796 */, - /* 6594 */ 0x078c0d17 | (18 << 27) /* 0.471692171 */, - /* 6595 */ 0x078c711a | (18 << 27) /* 0.471787552 */, - /* 6596 */ 0x078cd51f | (18 << 27) /* 0.471882937 */, - /* 6597 */ 0x078d3925 | (18 << 27) /* 0.471978327 */, - /* 6598 */ 0x078d9d2d | (18 << 27) /* 0.472073722 */, - /* 6599 */ 0x078e0135 | (18 << 27) /* 0.472169122 */, - /* 6600 */ 0x078e653f | (18 << 27) /* 0.472264527 */, - /* 6601 */ 0x078ec94b | (18 << 27) /* 0.472359936 */, - /* 6602 */ 0x078f2d57 | (18 << 27) /* 0.472455350 */, - /* 6603 */ 0x078f9165 | (18 << 27) /* 0.472550769 */, - /* 6604 */ 0x078ff574 | (18 << 27) /* 0.472646193 */, - /* 6605 */ 0x07905985 | (18 << 27) /* 0.472741622 */, - /* 6606 */ 0x0790bd96 | (18 << 27) /* 0.472837055 */, - /* 6607 */ 0x079121a9 | (18 << 27) /* 0.472932493 */, - - /* 6608 */ 0x079185be | (18 << 27) /* 0.473027937 */, - /* 6609 */ 0x0791e9d3 | (18 << 27) /* 0.473123384 */, - /* 6610 */ 0x07924dea | (18 << 27) /* 0.473218837 */, - /* 6611 */ 0x0792b202 | (18 << 27) /* 0.473314295 */, - /* 6612 */ 0x0793161c | (18 << 27) /* 0.473409757 */, - /* 6613 */ 0x07937a37 | (18 << 27) /* 0.473505224 */, - /* 6614 */ 0x0793de53 | (18 << 27) /* 0.473600696 */, - /* 6615 */ 0x07944270 | (18 << 27) /* 0.473696173 */, - /* 6616 */ 0x0794a68f | (18 << 27) /* 0.473791655 */, - /* 6617 */ 0x07950aaf | (18 << 27) /* 0.473887141 */, - /* 6618 */ 0x07956ed0 | (18 << 27) /* 0.473982632 */, - /* 6619 */ 0x0795d2f2 | (18 << 27) /* 0.474078128 */, - /* 6620 */ 0x07963716 | (18 << 27) /* 0.474173629 */, - /* 6621 */ 0x07969b3b | (18 << 27) /* 0.474269135 */, - /* 6622 */ 0x0796ff62 | (18 << 27) /* 0.474364645 */, - /* 6623 */ 0x07976389 | (18 << 27) /* 0.474460161 */, - - /* 6624 */ 0x0797c7b2 | (18 << 27) /* 0.474555681 */, - /* 6625 */ 0x07982bdd | (18 << 27) /* 0.474651205 */, - /* 6626 */ 0x07989008 | (18 << 27) /* 0.474746735 */, - /* 6627 */ 0x0798f435 | (18 << 27) /* 0.474842270 */, - /* 6628 */ 0x07995863 | (18 << 27) /* 0.474937809 */, - /* 6629 */ 0x0799bc92 | (18 << 27) /* 0.475033353 */, - /* 6630 */ 0x079a20c3 | (18 << 27) /* 0.475128902 */, - /* 6631 */ 0x079a84f5 | (18 << 27) /* 0.475224456 */, - /* 6632 */ 0x079ae929 | (18 << 27) /* 0.475320014 */, - /* 6633 */ 0x079b4d5d | (18 << 27) /* 0.475415578 */, - /* 6634 */ 0x079bb193 | (18 << 27) /* 0.475511146 */, - /* 6635 */ 0x079c15ca | (18 << 27) /* 0.475606719 */, - /* 6636 */ 0x079c7a03 | (18 << 27) /* 0.475702296 */, - /* 6637 */ 0x079cde3c | (18 << 27) /* 0.475797879 */, - /* 6638 */ 0x079d4277 | (18 << 27) /* 0.475893466 */, - /* 6639 */ 0x079da6b4 | (18 << 27) /* 0.475989058 */, - - /* 6640 */ 0x079e0af1 | (18 << 27) /* 0.476084655 */, - /* 6641 */ 0x079e6f30 | (18 << 27) /* 0.476180257 */, - /* 6642 */ 0x079ed370 | (18 << 27) /* 0.476275863 */, - /* 6643 */ 0x079f37b2 | (18 << 27) /* 0.476371475 */, - /* 6644 */ 0x079f9bf5 | (18 << 27) /* 0.476467091 */, - /* 6645 */ 0x07a00039 | (18 << 27) /* 0.476562712 */, - /* 6646 */ 0x07a0647e | (18 << 27) /* 0.476658338 */, - /* 6647 */ 0x07a0c8c5 | (18 << 27) /* 0.476753968 */, - /* 6648 */ 0x07a12d0c | (18 << 27) /* 0.476849603 */, - /* 6649 */ 0x07a19156 | (18 << 27) /* 0.476945243 */, - /* 6650 */ 0x07a1f5a0 | (18 << 27) /* 0.477040888 */, - /* 6651 */ 0x07a259ec | (18 << 27) /* 0.477136538 */, - /* 6652 */ 0x07a2be39 | (18 << 27) /* 0.477232193 */, - /* 6653 */ 0x07a32287 | (18 << 27) /* 0.477327852 */, - /* 6654 */ 0x07a386d7 | (18 << 27) /* 0.477423516 */, - /* 6655 */ 0x07a3eb28 | (18 << 27) /* 0.477519185 */, - - /* 6656 */ 0x07a44f7a | (18 << 27) /* 0.477614858 */, - /* 6657 */ 0x07a4b3ce | (18 << 27) /* 0.477710537 */, - /* 6658 */ 0x07a51822 | (18 << 27) /* 0.477806220 */, - /* 6659 */ 0x07a57c78 | (18 << 27) /* 0.477901908 */, - /* 6660 */ 0x07a5e0d0 | (18 << 27) /* 0.477997601 */, - /* 6661 */ 0x07a64528 | (18 << 27) /* 0.478093299 */, - /* 6662 */ 0x07a6a982 | (18 << 27) /* 0.478189001 */, - /* 6663 */ 0x07a70ddd | (18 << 27) /* 0.478284708 */, - /* 6664 */ 0x07a7723a | (18 << 27) /* 0.478380420 */, - /* 6665 */ 0x07a7d698 | (18 << 27) /* 0.478476137 */, - /* 6666 */ 0x07a83af7 | (18 << 27) /* 0.478571858 */, - /* 6667 */ 0x07a89f57 | (18 << 27) /* 0.478667585 */, - /* 6668 */ 0x07a903b9 | (18 << 27) /* 0.478763316 */, - /* 6669 */ 0x07a9681c | (18 << 27) /* 0.478859052 */, - /* 6670 */ 0x07a9cc80 | (18 << 27) /* 0.478954793 */, - /* 6671 */ 0x07aa30e5 | (18 << 27) /* 0.479050538 */, - - /* 6672 */ 0x07aa954c | (18 << 27) /* 0.479146288 */, - /* 6673 */ 0x07aaf9b4 | (18 << 27) /* 0.479242043 */, - /* 6674 */ 0x07ab5e1e | (18 << 27) /* 0.479337803 */, - /* 6675 */ 0x07abc288 | (18 << 27) /* 0.479433568 */, - /* 6676 */ 0x07ac26f4 | (18 << 27) /* 0.479529337 */, - /* 6677 */ 0x07ac8b61 | (18 << 27) /* 0.479625111 */, - /* 6678 */ 0x07acefd0 | (18 << 27) /* 0.479720890 */, - /* 6679 */ 0x07ad543f | (18 << 27) /* 0.479816674 */, - /* 6680 */ 0x07adb8b0 | (18 << 27) /* 0.479912463 */, - /* 6681 */ 0x07ae1d23 | (18 << 27) /* 0.480008256 */, - /* 6682 */ 0x07ae8196 | (18 << 27) /* 0.480104054 */, - /* 6683 */ 0x07aee60b | (18 << 27) /* 0.480199857 */, - /* 6684 */ 0x07af4a81 | (18 << 27) /* 0.480295664 */, - /* 6685 */ 0x07afaef9 | (18 << 27) /* 0.480391477 */, - /* 6686 */ 0x07b01372 | (18 << 27) /* 0.480487294 */, - /* 6687 */ 0x07b077ec | (18 << 27) /* 0.480583116 */, - - /* 6688 */ 0x07b0dc67 | (18 << 27) /* 0.480678943 */, - /* 6689 */ 0x07b140e4 | (18 << 27) /* 0.480774774 */, - /* 6690 */ 0x07b1a561 | (18 << 27) /* 0.480870611 */, - /* 6691 */ 0x07b209e1 | (18 << 27) /* 0.480966452 */, - /* 6692 */ 0x07b26e61 | (18 << 27) /* 0.481062298 */, - /* 6693 */ 0x07b2d2e3 | (18 << 27) /* 0.481158148 */, - /* 6694 */ 0x07b33766 | (18 << 27) /* 0.481254004 */, - /* 6695 */ 0x07b39bea | (18 << 27) /* 0.481349864 */, - /* 6696 */ 0x07b4006f | (18 << 27) /* 0.481445729 */, - /* 6697 */ 0x07b464f6 | (18 << 27) /* 0.481541598 */, - /* 6698 */ 0x07b4c97e | (18 << 27) /* 0.481637473 */, - /* 6699 */ 0x07b52e08 | (18 << 27) /* 0.481733352 */, - /* 6700 */ 0x07b59292 | (18 << 27) /* 0.481829236 */, - /* 6701 */ 0x07b5f71e | (18 << 27) /* 0.481925125 */, - /* 6702 */ 0x07b65bac | (18 << 27) /* 0.482021019 */, - /* 6703 */ 0x07b6c03a | (18 << 27) /* 0.482116917 */, - - /* 6704 */ 0x07b724ca | (18 << 27) /* 0.482212820 */, - /* 6705 */ 0x07b7895b | (18 << 27) /* 0.482308728 */, - /* 6706 */ 0x07b7eded | (18 << 27) /* 0.482404640 */, - /* 6707 */ 0x07b85281 | (18 << 27) /* 0.482500558 */, - /* 6708 */ 0x07b8b716 | (18 << 27) /* 0.482596480 */, - /* 6709 */ 0x07b91bac | (18 << 27) /* 0.482692407 */, - /* 6710 */ 0x07b98044 | (18 << 27) /* 0.482788339 */, - /* 6711 */ 0x07b9e4dc | (18 << 27) /* 0.482884275 */, - /* 6712 */ 0x07ba4976 | (18 << 27) /* 0.482980216 */, - /* 6713 */ 0x07baae12 | (18 << 27) /* 0.483076162 */, - /* 6714 */ 0x07bb12ae | (18 << 27) /* 0.483172113 */, - /* 6715 */ 0x07bb774c | (18 << 27) /* 0.483268069 */, - /* 6716 */ 0x07bbdbeb | (18 << 27) /* 0.483364029 */, - /* 6717 */ 0x07bc408c | (18 << 27) /* 0.483459994 */, - /* 6718 */ 0x07bca52d | (18 << 27) /* 0.483555964 */, - /* 6719 */ 0x07bd09d0 | (18 << 27) /* 0.483651939 */, - - /* 6720 */ 0x07bd6e75 | (18 << 27) /* 0.483747918 */, - /* 6721 */ 0x07bdd31a | (18 << 27) /* 0.483843902 */, - /* 6722 */ 0x07be37c1 | (18 << 27) /* 0.483939891 */, - /* 6723 */ 0x07be9c69 | (18 << 27) /* 0.484035885 */, - /* 6724 */ 0x07bf0113 | (18 << 27) /* 0.484131883 */, - /* 6725 */ 0x07bf65bd | (18 << 27) /* 0.484227886 */, - /* 6726 */ 0x07bfca69 | (18 << 27) /* 0.484323894 */, - /* 6727 */ 0x07c02f16 | (18 << 27) /* 0.484419907 */, - /* 6728 */ 0x07c093c5 | (18 << 27) /* 0.484515924 */, - /* 6729 */ 0x07c0f875 | (18 << 27) /* 0.484611946 */, - /* 6730 */ 0x07c15d26 | (18 << 27) /* 0.484707973 */, - /* 6731 */ 0x07c1c1d8 | (18 << 27) /* 0.484804005 */, - /* 6732 */ 0x07c2268b | (18 << 27) /* 0.484900041 */, - /* 6733 */ 0x07c28b40 | (18 << 27) /* 0.484996083 */, - /* 6734 */ 0x07c2eff6 | (18 << 27) /* 0.485092128 */, - /* 6735 */ 0x07c354ae | (18 << 27) /* 0.485188179 */, - - /* 6736 */ 0x07c3b967 | (18 << 27) /* 0.485284235 */, - /* 6737 */ 0x07c41e21 | (18 << 27) /* 0.485380295 */, - /* 6738 */ 0x07c482dc | (18 << 27) /* 0.485476360 */, - /* 6739 */ 0x07c4e798 | (18 << 27) /* 0.485572430 */, - /* 6740 */ 0x07c54c56 | (18 << 27) /* 0.485668504 */, - /* 6741 */ 0x07c5b115 | (18 << 27) /* 0.485764583 */, - /* 6742 */ 0x07c615d6 | (18 << 27) /* 0.485860667 */, - /* 6743 */ 0x07c67a97 | (18 << 27) /* 0.485956756 */, - /* 6744 */ 0x07c6df5a | (18 << 27) /* 0.486052849 */, - /* 6745 */ 0x07c7441e | (18 << 27) /* 0.486148948 */, - /* 6746 */ 0x07c7a8e4 | (18 << 27) /* 0.486245051 */, - /* 6747 */ 0x07c80daa | (18 << 27) /* 0.486341158 */, - /* 6748 */ 0x07c87272 | (18 << 27) /* 0.486437271 */, - /* 6749 */ 0x07c8d73c | (18 << 27) /* 0.486533388 */, - /* 6750 */ 0x07c93c06 | (18 << 27) /* 0.486629510 */, - /* 6751 */ 0x07c9a0d2 | (18 << 27) /* 0.486725637 */, - - /* 6752 */ 0x07ca059f | (18 << 27) /* 0.486821768 */, - /* 6753 */ 0x07ca6a6d | (18 << 27) /* 0.486917905 */, - /* 6754 */ 0x07cacf3d | (18 << 27) /* 0.487014045 */, - /* 6755 */ 0x07cb340e | (18 << 27) /* 0.487110191 */, - /* 6756 */ 0x07cb98e0 | (18 << 27) /* 0.487206342 */, - /* 6757 */ 0x07cbfdb4 | (18 << 27) /* 0.487302497 */, - /* 6758 */ 0x07cc6288 | (18 << 27) /* 0.487398657 */, - /* 6759 */ 0x07ccc75e | (18 << 27) /* 0.487494821 */, - /* 6760 */ 0x07cd2c36 | (18 << 27) /* 0.487590991 */, - /* 6761 */ 0x07cd910e | (18 << 27) /* 0.487687165 */, - /* 6762 */ 0x07cdf5e8 | (18 << 27) /* 0.487783344 */, - /* 6763 */ 0x07ce5ac3 | (18 << 27) /* 0.487879528 */, - /* 6764 */ 0x07cebfa0 | (18 << 27) /* 0.487975716 */, - /* 6765 */ 0x07cf247d | (18 << 27) /* 0.488071909 */, - /* 6766 */ 0x07cf895c | (18 << 27) /* 0.488168107 */, - /* 6767 */ 0x07cfee3c | (18 << 27) /* 0.488264310 */, - - /* 6768 */ 0x07d0531e | (18 << 27) /* 0.488360517 */, - /* 6769 */ 0x07d0b801 | (18 << 27) /* 0.488456729 */, - /* 6770 */ 0x07d11ce5 | (18 << 27) /* 0.488552946 */, - /* 6771 */ 0x07d181ca | (18 << 27) /* 0.488649167 */, - /* 6772 */ 0x07d1e6b0 | (18 << 27) /* 0.488745394 */, - /* 6773 */ 0x07d24b98 | (18 << 27) /* 0.488841625 */, - /* 6774 */ 0x07d2b081 | (18 << 27) /* 0.488937860 */, - /* 6775 */ 0x07d3156c | (18 << 27) /* 0.489034101 */, - /* 6776 */ 0x07d37a57 | (18 << 27) /* 0.489130346 */, - /* 6777 */ 0x07d3df44 | (18 << 27) /* 0.489226596 */, - /* 6778 */ 0x07d44432 | (18 << 27) /* 0.489322851 */, - /* 6779 */ 0x07d4a922 | (18 << 27) /* 0.489419110 */, - /* 6780 */ 0x07d50e13 | (18 << 27) /* 0.489515375 */, - /* 6781 */ 0x07d57305 | (18 << 27) /* 0.489611643 */, - /* 6782 */ 0x07d5d7f8 | (18 << 27) /* 0.489707917 */, - /* 6783 */ 0x07d63cec | (18 << 27) /* 0.489804195 */, - - /* 6784 */ 0x07d6a1e2 | (18 << 27) /* 0.489900479 */, - /* 6785 */ 0x07d706d9 | (18 << 27) /* 0.489996766 */, - /* 6786 */ 0x07d76bd2 | (18 << 27) /* 0.490093059 */, - /* 6787 */ 0x07d7d0cb | (18 << 27) /* 0.490189356 */, - /* 6788 */ 0x07d835c6 | (18 << 27) /* 0.490285658 */, - /* 6789 */ 0x07d89ac2 | (18 << 27) /* 0.490381965 */, - /* 6790 */ 0x07d8ffc0 | (18 << 27) /* 0.490478277 */, - /* 6791 */ 0x07d964be | (18 << 27) /* 0.490574593 */, - /* 6792 */ 0x07d9c9be | (18 << 27) /* 0.490670914 */, - /* 6793 */ 0x07da2ebf | (18 << 27) /* 0.490767239 */, - /* 6794 */ 0x07da93c2 | (18 << 27) /* 0.490863570 */, - /* 6795 */ 0x07daf8c6 | (18 << 27) /* 0.490959905 */, - /* 6796 */ 0x07db5dcb | (18 << 27) /* 0.491056245 */, - /* 6797 */ 0x07dbc2d1 | (18 << 27) /* 0.491152589 */, - /* 6798 */ 0x07dc27d9 | (18 << 27) /* 0.491248939 */, - /* 6799 */ 0x07dc8ce1 | (18 << 27) /* 0.491345293 */, - - /* 6800 */ 0x07dcf1ec | (18 << 27) /* 0.491441651 */, - /* 6801 */ 0x07dd56f7 | (18 << 27) /* 0.491538015 */, - /* 6802 */ 0x07ddbc04 | (18 << 27) /* 0.491634383 */, - /* 6803 */ 0x07de2111 | (18 << 27) /* 0.491730756 */, - /* 6804 */ 0x07de8621 | (18 << 27) /* 0.491827134 */, - /* 6805 */ 0x07deeb31 | (18 << 27) /* 0.491923516 */, - /* 6806 */ 0x07df5043 | (18 << 27) /* 0.492019903 */, - /* 6807 */ 0x07dfb556 | (18 << 27) /* 0.492116295 */, - /* 6808 */ 0x07e01a6a | (18 << 27) /* 0.492212691 */, - /* 6809 */ 0x07e07f80 | (18 << 27) /* 0.492309093 */, - /* 6810 */ 0x07e0e496 | (18 << 27) /* 0.492405499 */, - /* 6811 */ 0x07e149ae | (18 << 27) /* 0.492501909 */, - /* 6812 */ 0x07e1aec8 | (18 << 27) /* 0.492598325 */, - /* 6813 */ 0x07e213e2 | (18 << 27) /* 0.492694745 */, - /* 6814 */ 0x07e278fe | (18 << 27) /* 0.492791170 */, - /* 6815 */ 0x07e2de1b | (18 << 27) /* 0.492887599 */, - - /* 6816 */ 0x07e3433a | (18 << 27) /* 0.492984033 */, - /* 6817 */ 0x07e3a859 | (18 << 27) /* 0.493080472 */, - /* 6818 */ 0x07e40d7a | (18 << 27) /* 0.493176916 */, - /* 6819 */ 0x07e4729c | (18 << 27) /* 0.493273365 */, - /* 6820 */ 0x07e4d7c0 | (18 << 27) /* 0.493369818 */, - /* 6821 */ 0x07e53ce4 | (18 << 27) /* 0.493466275 */, - /* 6822 */ 0x07e5a20a | (18 << 27) /* 0.493562738 */, - /* 6823 */ 0x07e60732 | (18 << 27) /* 0.493659205 */, - /* 6824 */ 0x07e66c5a | (18 << 27) /* 0.493755677 */, - /* 6825 */ 0x07e6d184 | (18 << 27) /* 0.493852154 */, - /* 6826 */ 0x07e736af | (18 << 27) /* 0.493948635 */, - /* 6827 */ 0x07e79bdb | (18 << 27) /* 0.494045122 */, - /* 6828 */ 0x07e80109 | (18 << 27) /* 0.494141612 */, - /* 6829 */ 0x07e86638 | (18 << 27) /* 0.494238108 */, - /* 6830 */ 0x07e8cb68 | (18 << 27) /* 0.494334608 */, - /* 6831 */ 0x07e93099 | (18 << 27) /* 0.494431113 */, - - /* 6832 */ 0x07e995cc | (18 << 27) /* 0.494527623 */, - /* 6833 */ 0x07e9fb00 | (18 << 27) /* 0.494624137 */, - /* 6834 */ 0x07ea6035 | (18 << 27) /* 0.494720656 */, - /* 6835 */ 0x07eac56b | (18 << 27) /* 0.494817180 */, - /* 6836 */ 0x07eb2aa3 | (18 << 27) /* 0.494913709 */, - /* 6837 */ 0x07eb8fdc | (18 << 27) /* 0.495010242 */, - /* 6838 */ 0x07ebf516 | (18 << 27) /* 0.495106780 */, - /* 6839 */ 0x07ec5a51 | (18 << 27) /* 0.495203322 */, - /* 6840 */ 0x07ecbf8e | (18 << 27) /* 0.495299870 */, - /* 6841 */ 0x07ed24cc | (18 << 27) /* 0.495396422 */, - /* 6842 */ 0x07ed8a0b | (18 << 27) /* 0.495492978 */, - /* 6843 */ 0x07edef4c | (18 << 27) /* 0.495589540 */, - /* 6844 */ 0x07ee548e | (18 << 27) /* 0.495686106 */, - /* 6845 */ 0x07eeb9d1 | (18 << 27) /* 0.495782677 */, - /* 6846 */ 0x07ef1f15 | (18 << 27) /* 0.495879252 */, - /* 6847 */ 0x07ef845b | (18 << 27) /* 0.495975833 */, - - /* 6848 */ 0x07efe9a1 | (18 << 27) /* 0.496072418 */, - /* 6849 */ 0x07f04ee9 | (18 << 27) /* 0.496169007 */, - /* 6850 */ 0x07f0b433 | (18 << 27) /* 0.496265602 */, - /* 6851 */ 0x07f1197d | (18 << 27) /* 0.496362201 */, - /* 6852 */ 0x07f17ec9 | (18 << 27) /* 0.496458804 */, - /* 6853 */ 0x07f1e416 | (18 << 27) /* 0.496555413 */, - /* 6854 */ 0x07f24965 | (18 << 27) /* 0.496652026 */, - /* 6855 */ 0x07f2aeb5 | (18 << 27) /* 0.496748644 */, - /* 6856 */ 0x07f31405 | (18 << 27) /* 0.496845266 */, - /* 6857 */ 0x07f37958 | (18 << 27) /* 0.496941894 */, - /* 6858 */ 0x07f3deab | (18 << 27) /* 0.497038526 */, - /* 6859 */ 0x07f44400 | (18 << 27) /* 0.497135162 */, - /* 6860 */ 0x07f4a956 | (18 << 27) /* 0.497231804 */, - /* 6861 */ 0x07f50ead | (18 << 27) /* 0.497328450 */, - /* 6862 */ 0x07f57405 | (18 << 27) /* 0.497425100 */, - /* 6863 */ 0x07f5d95f | (18 << 27) /* 0.497521756 */, - - /* 6864 */ 0x07f63eba | (18 << 27) /* 0.497618416 */, - /* 6865 */ 0x07f6a416 | (18 << 27) /* 0.497715081 */, - /* 6866 */ 0x07f70974 | (18 << 27) /* 0.497811750 */, - /* 6867 */ 0x07f76ed3 | (18 << 27) /* 0.497908425 */, - /* 6868 */ 0x07f7d433 | (18 << 27) /* 0.498005103 */, - /* 6869 */ 0x07f83994 | (18 << 27) /* 0.498101787 */, - /* 6870 */ 0x07f89ef7 | (18 << 27) /* 0.498198475 */, - /* 6871 */ 0x07f9045a | (18 << 27) /* 0.498295168 */, - /* 6872 */ 0x07f969c0 | (18 << 27) /* 0.498391866 */, - /* 6873 */ 0x07f9cf26 | (18 << 27) /* 0.498488568 */, - /* 6874 */ 0x07fa348e | (18 << 27) /* 0.498585275 */, - /* 6875 */ 0x07fa99f6 | (18 << 27) /* 0.498681987 */, - /* 6876 */ 0x07faff60 | (18 << 27) /* 0.498778704 */, - /* 6877 */ 0x07fb64cc | (18 << 27) /* 0.498875425 */, - /* 6878 */ 0x07fbca38 | (18 << 27) /* 0.498972150 */, - /* 6879 */ 0x07fc2fa6 | (18 << 27) /* 0.499068881 */, - - /* 6880 */ 0x07fc9516 | (18 << 27) /* 0.499165616 */, - /* 6881 */ 0x07fcfa86 | (18 << 27) /* 0.499262356 */, - /* 6882 */ 0x07fd5ff8 | (18 << 27) /* 0.499359101 */, - /* 6883 */ 0x07fdc56b | (18 << 27) /* 0.499455850 */, - /* 6884 */ 0x07fe2adf | (18 << 27) /* 0.499552604 */, - /* 6885 */ 0x07fe9054 | (18 << 27) /* 0.499649362 */, - /* 6886 */ 0x07fef5cb | (18 << 27) /* 0.499746126 */, - /* 6887 */ 0x07ff5b43 | (18 << 27) /* 0.499842894 */, - /* 6888 */ 0x07ffc0bc | (18 << 27) /* 0.499939666 */, - /* 6889 */ 0x0400131b | (19 << 27) /* 0.250018222 */, - /* 6890 */ 0x040045d9 | (19 << 27) /* 0.250066613 */, - /* 6891 */ 0x04007897 | (19 << 27) /* 0.250115006 */, - /* 6892 */ 0x0400ab57 | (19 << 27) /* 0.250163402 */, - /* 6893 */ 0x0400de16 | (19 << 27) /* 0.250211800 */, - /* 6894 */ 0x040110d7 | (19 << 27) /* 0.250260200 */, - /* 6895 */ 0x04014398 | (19 << 27) /* 0.250308603 */, - - /* 6896 */ 0x04017659 | (19 << 27) /* 0.250357008 */, - /* 6897 */ 0x0401a91c | (19 << 27) /* 0.250405415 */, - /* 6898 */ 0x0401dbdf | (19 << 27) /* 0.250453825 */, - /* 6899 */ 0x04020ea2 | (19 << 27) /* 0.250502237 */, - /* 6900 */ 0x04024166 | (19 << 27) /* 0.250550652 */, - /* 6901 */ 0x0402742b | (19 << 27) /* 0.250599068 */, - /* 6902 */ 0x0402a6f0 | (19 << 27) /* 0.250647488 */, - /* 6903 */ 0x0402d9b6 | (19 << 27) /* 0.250695909 */, - /* 6904 */ 0x04030c7d | (19 << 27) /* 0.250744333 */, - /* 6905 */ 0x04033f44 | (19 << 27) /* 0.250792759 */, - /* 6906 */ 0x0403720c | (19 << 27) /* 0.250841187 */, - /* 6907 */ 0x0403a4d5 | (19 << 27) /* 0.250889618 */, - /* 6908 */ 0x0403d79e | (19 << 27) /* 0.250938051 */, - /* 6909 */ 0x04040a68 | (19 << 27) /* 0.250986487 */, - /* 6910 */ 0x04043d32 | (19 << 27) /* 0.251034924 */, - /* 6911 */ 0x04046ffd | (19 << 27) /* 0.251083365 */, - - /* 6912 */ 0x0404a2c9 | (19 << 27) /* 0.251131807 */, - /* 6913 */ 0x0404d595 | (19 << 27) /* 0.251180252 */, - /* 6914 */ 0x04050862 | (19 << 27) /* 0.251228699 */, - /* 6915 */ 0x04053b30 | (19 << 27) /* 0.251277148 */, - /* 6916 */ 0x04056dfe | (19 << 27) /* 0.251325600 */, - /* 6917 */ 0x0405a0cd | (19 << 27) /* 0.251374054 */, - /* 6918 */ 0x0405d39c | (19 << 27) /* 0.251422511 */, - /* 6919 */ 0x0406066c | (19 << 27) /* 0.251470970 */, - /* 6920 */ 0x0406393d | (19 << 27) /* 0.251519431 */, - /* 6921 */ 0x04066c0e | (19 << 27) /* 0.251567894 */, - /* 6922 */ 0x04069ee0 | (19 << 27) /* 0.251616360 */, - /* 6923 */ 0x0406d1b3 | (19 << 27) /* 0.251664828 */, - /* 6924 */ 0x04070486 | (19 << 27) /* 0.251713299 */, - /* 6925 */ 0x0407375a | (19 << 27) /* 0.251761772 */, - /* 6926 */ 0x04076a2e | (19 << 27) /* 0.251810247 */, - /* 6927 */ 0x04079d03 | (19 << 27) /* 0.251858724 */, - - /* 6928 */ 0x0407cfd9 | (19 << 27) /* 0.251907204 */, - /* 6929 */ 0x040802af | (19 << 27) /* 0.251955686 */, - /* 6930 */ 0x04083586 | (19 << 27) /* 0.252004171 */, - /* 6931 */ 0x0408685e | (19 << 27) /* 0.252052658 */, - /* 6932 */ 0x04089b36 | (19 << 27) /* 0.252101147 */, - /* 6933 */ 0x0408ce0f | (19 << 27) /* 0.252149638 */, - /* 6934 */ 0x040900e8 | (19 << 27) /* 0.252198132 */, - /* 6935 */ 0x040933c2 | (19 << 27) /* 0.252246628 */, - /* 6936 */ 0x0409669d | (19 << 27) /* 0.252295127 */, - /* 6937 */ 0x04099978 | (19 << 27) /* 0.252343627 */, - /* 6938 */ 0x0409cc54 | (19 << 27) /* 0.252392131 */, - /* 6939 */ 0x0409ff31 | (19 << 27) /* 0.252440636 */, - /* 6940 */ 0x040a320e | (19 << 27) /* 0.252489144 */, - /* 6941 */ 0x040a64ec | (19 << 27) /* 0.252537654 */, - /* 6942 */ 0x040a97cb | (19 << 27) /* 0.252586166 */, - /* 6943 */ 0x040acaaa | (19 << 27) /* 0.252634681 */, - - /* 6944 */ 0x040afd89 | (19 << 27) /* 0.252683198 */, - /* 6945 */ 0x040b306a | (19 << 27) /* 0.252731718 */, - /* 6946 */ 0x040b634b | (19 << 27) /* 0.252780240 */, - /* 6947 */ 0x040b962c | (19 << 27) /* 0.252828764 */, - /* 6948 */ 0x040bc90e | (19 << 27) /* 0.252877290 */, - /* 6949 */ 0x040bfbf1 | (19 << 27) /* 0.252925819 */, - /* 6950 */ 0x040c2ed5 | (19 << 27) /* 0.252974350 */, - /* 6951 */ 0x040c61b9 | (19 << 27) /* 0.253022883 */, - /* 6952 */ 0x040c949e | (19 << 27) /* 0.253071419 */, - /* 6953 */ 0x040cc783 | (19 << 27) /* 0.253119957 */, - /* 6954 */ 0x040cfa69 | (19 << 27) /* 0.253168498 */, - /* 6955 */ 0x040d2d4f | (19 << 27) /* 0.253217040 */, - /* 6956 */ 0x040d6037 | (19 << 27) /* 0.253265585 */, - /* 6957 */ 0x040d931e | (19 << 27) /* 0.253314133 */, - /* 6958 */ 0x040dc607 | (19 << 27) /* 0.253362682 */, - /* 6959 */ 0x040df8f0 | (19 << 27) /* 0.253411234 */, - - /* 6960 */ 0x040e2bda | (19 << 27) /* 0.253459789 */, - /* 6961 */ 0x040e5ec4 | (19 << 27) /* 0.253508345 */, - /* 6962 */ 0x040e91af | (19 << 27) /* 0.253556904 */, - /* 6963 */ 0x040ec49b | (19 << 27) /* 0.253605466 */, - /* 6964 */ 0x040ef787 | (19 << 27) /* 0.253654029 */, - /* 6965 */ 0x040f2a74 | (19 << 27) /* 0.253702595 */, - /* 6966 */ 0x040f5d61 | (19 << 27) /* 0.253751164 */, - /* 6967 */ 0x040f904f | (19 << 27) /* 0.253799734 */, - /* 6968 */ 0x040fc33e | (19 << 27) /* 0.253848307 */, - /* 6969 */ 0x040ff62d | (19 << 27) /* 0.253896883 */, - /* 6970 */ 0x0410291d | (19 << 27) /* 0.253945460 */, - /* 6971 */ 0x04105c0e | (19 << 27) /* 0.253994040 */, - /* 6972 */ 0x04108eff | (19 << 27) /* 0.254042622 */, - /* 6973 */ 0x0410c1f1 | (19 << 27) /* 0.254091207 */, - /* 6974 */ 0x0410f4e3 | (19 << 27) /* 0.254139794 */, - /* 6975 */ 0x041127d6 | (19 << 27) /* 0.254188383 */, - - /* 6976 */ 0x04115aca | (19 << 27) /* 0.254236974 */, - /* 6977 */ 0x04118dbe | (19 << 27) /* 0.254285568 */, - /* 6978 */ 0x0411c0b3 | (19 << 27) /* 0.254334165 */, - /* 6979 */ 0x0411f3a9 | (19 << 27) /* 0.254382763 */, - /* 6980 */ 0x0412269f | (19 << 27) /* 0.254431364 */, - /* 6981 */ 0x04125996 | (19 << 27) /* 0.254479967 */, - /* 6982 */ 0x04128c8d | (19 << 27) /* 0.254528572 */, - /* 6983 */ 0x0412bf85 | (19 << 27) /* 0.254577180 */, - /* 6984 */ 0x0412f27e | (19 << 27) /* 0.254625790 */, - /* 6985 */ 0x04132577 | (19 << 27) /* 0.254674403 */, - /* 6986 */ 0x04135871 | (19 << 27) /* 0.254723017 */, - /* 6987 */ 0x04138b6c | (19 << 27) /* 0.254771635 */, - /* 6988 */ 0x0413be67 | (19 << 27) /* 0.254820254 */, - /* 6989 */ 0x0413f163 | (19 << 27) /* 0.254868876 */, - /* 6990 */ 0x0414245f | (19 << 27) /* 0.254917500 */, - /* 6991 */ 0x0414575c | (19 << 27) /* 0.254966126 */, - - /* 6992 */ 0x04148a5a | (19 << 27) /* 0.255014755 */, - /* 6993 */ 0x0414bd58 | (19 << 27) /* 0.255063386 */, - /* 6994 */ 0x0414f057 | (19 << 27) /* 0.255112019 */, - /* 6995 */ 0x04152356 | (19 << 27) /* 0.255160655 */, - /* 6996 */ 0x04155657 | (19 << 27) /* 0.255209292 */, - /* 6997 */ 0x04158957 | (19 << 27) /* 0.255257933 */, - /* 6998 */ 0x0415bc59 | (19 << 27) /* 0.255306575 */, - /* 6999 */ 0x0415ef5b | (19 << 27) /* 0.255355220 */, - /* 7000 */ 0x0416225d | (19 << 27) /* 0.255403867 */, - /* 7001 */ 0x04165561 | (19 << 27) /* 0.255452517 */, - /* 7002 */ 0x04168864 | (19 << 27) /* 0.255501169 */, - /* 7003 */ 0x0416bb69 | (19 << 27) /* 0.255549823 */, - /* 7004 */ 0x0416ee6e | (19 << 27) /* 0.255598479 */, - /* 7005 */ 0x04172174 | (19 << 27) /* 0.255647138 */, - /* 7006 */ 0x0417547a | (19 << 27) /* 0.255695799 */, - /* 7007 */ 0x04178781 | (19 << 27) /* 0.255744463 */, - - /* 7008 */ 0x0417ba89 | (19 << 27) /* 0.255793128 */, - /* 7009 */ 0x0417ed91 | (19 << 27) /* 0.255841796 */, - /* 7010 */ 0x0418209a | (19 << 27) /* 0.255890467 */, - /* 7011 */ 0x041853a3 | (19 << 27) /* 0.255939139 */, - /* 7012 */ 0x041886ad | (19 << 27) /* 0.255987814 */, - /* 7013 */ 0x0418b9b8 | (19 << 27) /* 0.256036492 */, - /* 7014 */ 0x0418ecc3 | (19 << 27) /* 0.256085171 */, - /* 7015 */ 0x04191fcf | (19 << 27) /* 0.256133853 */, - /* 7016 */ 0x041952dc | (19 << 27) /* 0.256182537 */, - /* 7017 */ 0x041985e9 | (19 << 27) /* 0.256231224 */, - /* 7018 */ 0x0419b8f7 | (19 << 27) /* 0.256279913 */, - /* 7019 */ 0x0419ec05 | (19 << 27) /* 0.256328604 */, - /* 7020 */ 0x041a1f15 | (19 << 27) /* 0.256377297 */, - /* 7021 */ 0x041a5224 | (19 << 27) /* 0.256425993 */, - /* 7022 */ 0x041a8534 | (19 << 27) /* 0.256474691 */, - /* 7023 */ 0x041ab845 | (19 << 27) /* 0.256523392 */, - - /* 7024 */ 0x041aeb57 | (19 << 27) /* 0.256572095 */, - /* 7025 */ 0x041b1e69 | (19 << 27) /* 0.256620800 */, - /* 7026 */ 0x041b517c | (19 << 27) /* 0.256669507 */, - /* 7027 */ 0x041b848f | (19 << 27) /* 0.256718217 */, - /* 7028 */ 0x041bb7a3 | (19 << 27) /* 0.256766929 */, - /* 7029 */ 0x041beab8 | (19 << 27) /* 0.256815643 */, - /* 7030 */ 0x041c1dcd | (19 << 27) /* 0.256864359 */, - /* 7031 */ 0x041c50e3 | (19 << 27) /* 0.256913078 */, - /* 7032 */ 0x041c83fa | (19 << 27) /* 0.256961800 */, - /* 7033 */ 0x041cb711 | (19 << 27) /* 0.257010523 */, - /* 7034 */ 0x041cea28 | (19 << 27) /* 0.257059249 */, - /* 7035 */ 0x041d1d41 | (19 << 27) /* 0.257107977 */, - /* 7036 */ 0x041d505a | (19 << 27) /* 0.257156708 */, - /* 7037 */ 0x041d8373 | (19 << 27) /* 0.257205440 */, - /* 7038 */ 0x041db68e | (19 << 27) /* 0.257254175 */, - /* 7039 */ 0x041de9a8 | (19 << 27) /* 0.257302913 */, - - /* 7040 */ 0x041e1cc4 | (19 << 27) /* 0.257351652 */, - /* 7041 */ 0x041e4fe0 | (19 << 27) /* 0.257400394 */, - /* 7042 */ 0x041e82fd | (19 << 27) /* 0.257449139 */, - /* 7043 */ 0x041eb61a | (19 << 27) /* 0.257497885 */, - /* 7044 */ 0x041ee938 | (19 << 27) /* 0.257546634 */, - /* 7045 */ 0x041f1c57 | (19 << 27) /* 0.257595386 */, - /* 7046 */ 0x041f4f76 | (19 << 27) /* 0.257644139 */, - /* 7047 */ 0x041f8296 | (19 << 27) /* 0.257692895 */, - /* 7048 */ 0x041fb5b6 | (19 << 27) /* 0.257741653 */, - /* 7049 */ 0x041fe8d7 | (19 << 27) /* 0.257790414 */, - /* 7050 */ 0x04201bf9 | (19 << 27) /* 0.257839176 */, - /* 7051 */ 0x04204f1b | (19 << 27) /* 0.257887941 */, - /* 7052 */ 0x0420823e | (19 << 27) /* 0.257936709 */, - /* 7053 */ 0x0420b561 | (19 << 27) /* 0.257985478 */, - /* 7054 */ 0x0420e885 | (19 << 27) /* 0.258034250 */, - /* 7055 */ 0x04211baa | (19 << 27) /* 0.258083025 */, - - /* 7056 */ 0x04214ed0 | (19 << 27) /* 0.258131801 */, - /* 7057 */ 0x042181f6 | (19 << 27) /* 0.258180580 */, - /* 7058 */ 0x0421b51c | (19 << 27) /* 0.258229361 */, - /* 7059 */ 0x0421e843 | (19 << 27) /* 0.258278145 */, - /* 7060 */ 0x04221b6b | (19 << 27) /* 0.258326931 */, - /* 7061 */ 0x04224e94 | (19 << 27) /* 0.258375719 */, - /* 7062 */ 0x042281bd | (19 << 27) /* 0.258424509 */, - /* 7063 */ 0x0422b4e6 | (19 << 27) /* 0.258473302 */, - /* 7064 */ 0x0422e811 | (19 << 27) /* 0.258522097 */, - /* 7065 */ 0x04231b3c | (19 << 27) /* 0.258570894 */, - /* 7066 */ 0x04234e67 | (19 << 27) /* 0.258619694 */, - /* 7067 */ 0x04238193 | (19 << 27) /* 0.258668496 */, - /* 7068 */ 0x0423b4c0 | (19 << 27) /* 0.258717300 */, - /* 7069 */ 0x0423e7ee | (19 << 27) /* 0.258766106 */, - /* 7070 */ 0x04241b1c | (19 << 27) /* 0.258814915 */, - /* 7071 */ 0x04244e4a | (19 << 27) /* 0.258863726 */, - - /* 7072 */ 0x04248179 | (19 << 27) /* 0.258912540 */, - /* 7073 */ 0x0424b4a9 | (19 << 27) /* 0.258961356 */, - /* 7074 */ 0x0424e7da | (19 << 27) /* 0.259010174 */, - /* 7075 */ 0x04251b0b | (19 << 27) /* 0.259058994 */, - /* 7076 */ 0x04254e3d | (19 << 27) /* 0.259107817 */, - /* 7077 */ 0x0425816f | (19 << 27) /* 0.259156642 */, - /* 7078 */ 0x0425b4a2 | (19 << 27) /* 0.259205469 */, - /* 7079 */ 0x0425e7d6 | (19 << 27) /* 0.259254298 */, - /* 7080 */ 0x04261b0a | (19 << 27) /* 0.259303130 */, - /* 7081 */ 0x04264e3f | (19 << 27) /* 0.259351964 */, - /* 7082 */ 0x04268174 | (19 << 27) /* 0.259400801 */, - /* 7083 */ 0x0426b4aa | (19 << 27) /* 0.259449639 */, - /* 7084 */ 0x0426e7e1 | (19 << 27) /* 0.259498480 */, - /* 7085 */ 0x04271b18 | (19 << 27) /* 0.259547324 */, - /* 7086 */ 0x04274e50 | (19 << 27) /* 0.259596169 */, - /* 7087 */ 0x04278188 | (19 << 27) /* 0.259645017 */, - - /* 7088 */ 0x0427b4c2 | (19 << 27) /* 0.259693868 */, - /* 7089 */ 0x0427e7fb | (19 << 27) /* 0.259742720 */, - /* 7090 */ 0x04281b36 | (19 << 27) /* 0.259791575 */, - /* 7091 */ 0x04284e71 | (19 << 27) /* 0.259840432 */, - /* 7092 */ 0x042881ac | (19 << 27) /* 0.259889291 */, - /* 7093 */ 0x0428b4e8 | (19 << 27) /* 0.259938153 */, - /* 7094 */ 0x0428e825 | (19 << 27) /* 0.259987017 */, - /* 7095 */ 0x04291b63 | (19 << 27) /* 0.260035883 */, - /* 7096 */ 0x04294ea1 | (19 << 27) /* 0.260084752 */, - /* 7097 */ 0x042981df | (19 << 27) /* 0.260133623 */, - /* 7098 */ 0x0429b51f | (19 << 27) /* 0.260182496 */, - /* 7099 */ 0x0429e85f | (19 << 27) /* 0.260231372 */, - /* 7100 */ 0x042a1b9f | (19 << 27) /* 0.260280249 */, - /* 7101 */ 0x042a4ee0 | (19 << 27) /* 0.260329129 */, - /* 7102 */ 0x042a8222 | (19 << 27) /* 0.260378012 */, - /* 7103 */ 0x042ab564 | (19 << 27) /* 0.260426896 */, - - /* 7104 */ 0x042ae8a7 | (19 << 27) /* 0.260475783 */, - /* 7105 */ 0x042b1beb | (19 << 27) /* 0.260524673 */, - /* 7106 */ 0x042b4f2f | (19 << 27) /* 0.260573564 */, - /* 7107 */ 0x042b8274 | (19 << 27) /* 0.260622458 */, - /* 7108 */ 0x042bb5ba | (19 << 27) /* 0.260671354 */, - /* 7109 */ 0x042be900 | (19 << 27) /* 0.260720252 */, - /* 7110 */ 0x042c1c46 | (19 << 27) /* 0.260769153 */, - /* 7111 */ 0x042c4f8e | (19 << 27) /* 0.260818056 */, - /* 7112 */ 0x042c82d6 | (19 << 27) /* 0.260866961 */, - /* 7113 */ 0x042cb61e | (19 << 27) /* 0.260915869 */, - /* 7114 */ 0x042ce967 | (19 << 27) /* 0.260964779 */, - /* 7115 */ 0x042d1cb1 | (19 << 27) /* 0.261013691 */, - /* 7116 */ 0x042d4ffb | (19 << 27) /* 0.261062606 */, - /* 7117 */ 0x042d8346 | (19 << 27) /* 0.261111522 */, - /* 7118 */ 0x042db692 | (19 << 27) /* 0.261160441 */, - /* 7119 */ 0x042de9de | (19 << 27) /* 0.261209363 */, - - /* 7120 */ 0x042e1d2b | (19 << 27) /* 0.261258286 */, - /* 7121 */ 0x042e5078 | (19 << 27) /* 0.261307212 */, - /* 7122 */ 0x042e83c6 | (19 << 27) /* 0.261356140 */, - /* 7123 */ 0x042eb715 | (19 << 27) /* 0.261405071 */, - /* 7124 */ 0x042eea64 | (19 << 27) /* 0.261454004 */, - /* 7125 */ 0x042f1db4 | (19 << 27) /* 0.261502939 */, - /* 7126 */ 0x042f5105 | (19 << 27) /* 0.261551876 */, - /* 7127 */ 0x042f8456 | (19 << 27) /* 0.261600816 */, - /* 7128 */ 0x042fb7a8 | (19 << 27) /* 0.261649758 */, - /* 7129 */ 0x042feafa | (19 << 27) /* 0.261698702 */, - /* 7130 */ 0x04301e4d | (19 << 27) /* 0.261747649 */, - /* 7131 */ 0x043051a1 | (19 << 27) /* 0.261796597 */, - /* 7132 */ 0x043084f5 | (19 << 27) /* 0.261845548 */, - /* 7133 */ 0x0430b84a | (19 << 27) /* 0.261894502 */, - /* 7134 */ 0x0430eb9f | (19 << 27) /* 0.261943458 */, - /* 7135 */ 0x04311ef5 | (19 << 27) /* 0.261992416 */, - - /* 7136 */ 0x0431524c | (19 << 27) /* 0.262041376 */, - /* 7137 */ 0x043185a3 | (19 << 27) /* 0.262090338 */, - /* 7138 */ 0x0431b8fb | (19 << 27) /* 0.262139303 */, - /* 7139 */ 0x0431ec54 | (19 << 27) /* 0.262188270 */, - /* 7140 */ 0x04321fad | (19 << 27) /* 0.262237240 */, - /* 7141 */ 0x04325306 | (19 << 27) /* 0.262286211 */, - /* 7142 */ 0x04328661 | (19 << 27) /* 0.262335185 */, - /* 7143 */ 0x0432b9bc | (19 << 27) /* 0.262384162 */, - /* 7144 */ 0x0432ed17 | (19 << 27) /* 0.262433140 */, - /* 7145 */ 0x04332074 | (19 << 27) /* 0.262482121 */, - /* 7146 */ 0x043353d0 | (19 << 27) /* 0.262531104 */, - /* 7147 */ 0x0433872e | (19 << 27) /* 0.262580089 */, - /* 7148 */ 0x0433ba8c | (19 << 27) /* 0.262629077 */, - /* 7149 */ 0x0433edea | (19 << 27) /* 0.262678067 */, - /* 7150 */ 0x0434214a | (19 << 27) /* 0.262727059 */, - /* 7151 */ 0x043454aa | (19 << 27) /* 0.262776054 */, - - /* 7152 */ 0x0434880a | (19 << 27) /* 0.262825051 */, - /* 7153 */ 0x0434bb6b | (19 << 27) /* 0.262874050 */, - /* 7154 */ 0x0434eecd | (19 << 27) /* 0.262923051 */, - /* 7155 */ 0x0435222f | (19 << 27) /* 0.262972055 */, - /* 7156 */ 0x04355592 | (19 << 27) /* 0.263021061 */, - /* 7157 */ 0x043588f6 | (19 << 27) /* 0.263070069 */, - /* 7158 */ 0x0435bc5a | (19 << 27) /* 0.263119079 */, - /* 7159 */ 0x0435efbf | (19 << 27) /* 0.263168092 */, - /* 7160 */ 0x04362324 | (19 << 27) /* 0.263217107 */, - /* 7161 */ 0x0436568a | (19 << 27) /* 0.263266125 */, - /* 7162 */ 0x043689f1 | (19 << 27) /* 0.263315144 */, - /* 7163 */ 0x0436bd58 | (19 << 27) /* 0.263364166 */, - /* 7164 */ 0x0436f0c0 | (19 << 27) /* 0.263413191 */, - /* 7165 */ 0x04372428 | (19 << 27) /* 0.263462217 */, - /* 7166 */ 0x04375791 | (19 << 27) /* 0.263511246 */, - /* 7167 */ 0x04378afb | (19 << 27) /* 0.263560277 */, - - /* 7168 */ 0x0437be65 | (19 << 27) /* 0.263609310 */, - /* 7169 */ 0x0437f1d0 | (19 << 27) /* 0.263658346 */, - /* 7170 */ 0x0438253c | (19 << 27) /* 0.263707384 */, - /* 7171 */ 0x043858a8 | (19 << 27) /* 0.263756424 */, - /* 7172 */ 0x04388c14 | (19 << 27) /* 0.263805466 */, - /* 7173 */ 0x0438bf82 | (19 << 27) /* 0.263854511 */, - /* 7174 */ 0x0438f2f0 | (19 << 27) /* 0.263903558 */, - /* 7175 */ 0x0439265e | (19 << 27) /* 0.263952607 */, - /* 7176 */ 0x043959cd | (19 << 27) /* 0.264001659 */, - /* 7177 */ 0x04398d3d | (19 << 27) /* 0.264050713 */, - /* 7178 */ 0x0439c0ae | (19 << 27) /* 0.264099769 */, - /* 7179 */ 0x0439f41f | (19 << 27) /* 0.264148827 */, - /* 7180 */ 0x043a2790 | (19 << 27) /* 0.264197888 */, - /* 7181 */ 0x043a5b02 | (19 << 27) /* 0.264246951 */, - /* 7182 */ 0x043a8e75 | (19 << 27) /* 0.264296016 */, - /* 7183 */ 0x043ac1e9 | (19 << 27) /* 0.264345084 */, - - /* 7184 */ 0x043af55d | (19 << 27) /* 0.264394153 */, - /* 7185 */ 0x043b28d2 | (19 << 27) /* 0.264443225 */, - /* 7186 */ 0x043b5c47 | (19 << 27) /* 0.264492300 */, - /* 7187 */ 0x043b8fbd | (19 << 27) /* 0.264541376 */, - /* 7188 */ 0x043bc333 | (19 << 27) /* 0.264590455 */, - /* 7189 */ 0x043bf6aa | (19 << 27) /* 0.264639536 */, - /* 7190 */ 0x043c2a22 | (19 << 27) /* 0.264688620 */, - /* 7191 */ 0x043c5d9a | (19 << 27) /* 0.264737706 */, - /* 7192 */ 0x043c9113 | (19 << 27) /* 0.264786794 */, - /* 7193 */ 0x043cc48d | (19 << 27) /* 0.264835884 */, - /* 7194 */ 0x043cf807 | (19 << 27) /* 0.264884976 */, - /* 7195 */ 0x043d2b82 | (19 << 27) /* 0.264934071 */, - /* 7196 */ 0x043d5efd | (19 << 27) /* 0.264983168 */, - /* 7197 */ 0x043d9279 | (19 << 27) /* 0.265032268 */, - /* 7198 */ 0x043dc5f6 | (19 << 27) /* 0.265081369 */, - /* 7199 */ 0x043df973 | (19 << 27) /* 0.265130473 */, - - /* 7200 */ 0x043e2cf1 | (19 << 27) /* 0.265179580 */, - /* 7201 */ 0x043e6070 | (19 << 27) /* 0.265228688 */, - /* 7202 */ 0x043e93ef | (19 << 27) /* 0.265277799 */, - /* 7203 */ 0x043ec76e | (19 << 27) /* 0.265326912 */, - /* 7204 */ 0x043efaef | (19 << 27) /* 0.265376027 */, - /* 7205 */ 0x043f2e6f | (19 << 27) /* 0.265425145 */, - /* 7206 */ 0x043f61f1 | (19 << 27) /* 0.265474264 */, - /* 7207 */ 0x043f9573 | (19 << 27) /* 0.265523387 */, - /* 7208 */ 0x043fc8f6 | (19 << 27) /* 0.265572511 */, - /* 7209 */ 0x043ffc79 | (19 << 27) /* 0.265621638 */, - /* 7210 */ 0x04402ffd | (19 << 27) /* 0.265670766 */, - /* 7211 */ 0x04406382 | (19 << 27) /* 0.265719898 */, - /* 7212 */ 0x04409707 | (19 << 27) /* 0.265769031 */, - /* 7213 */ 0x0440ca8d | (19 << 27) /* 0.265818167 */, - /* 7214 */ 0x0440fe13 | (19 << 27) /* 0.265867305 */, - /* 7215 */ 0x0441319a | (19 << 27) /* 0.265916445 */, - - /* 7216 */ 0x04416522 | (19 << 27) /* 0.265965588 */, - /* 7217 */ 0x044198aa | (19 << 27) /* 0.266014732 */, - /* 7218 */ 0x0441cc33 | (19 << 27) /* 0.266063880 */, - /* 7219 */ 0x0441ffbc | (19 << 27) /* 0.266113029 */, - /* 7220 */ 0x04423346 | (19 << 27) /* 0.266162181 */, - /* 7221 */ 0x044266d1 | (19 << 27) /* 0.266211334 */, - /* 7222 */ 0x04429a5c | (19 << 27) /* 0.266260491 */, - /* 7223 */ 0x0442cde8 | (19 << 27) /* 0.266309649 */, - /* 7224 */ 0x04430174 | (19 << 27) /* 0.266358810 */, - /* 7225 */ 0x04433501 | (19 << 27) /* 0.266407973 */, - /* 7226 */ 0x0443688f | (19 << 27) /* 0.266457138 */, - /* 7227 */ 0x04439c1d | (19 << 27) /* 0.266506305 */, - /* 7228 */ 0x0443cfac | (19 << 27) /* 0.266555475 */, - /* 7229 */ 0x0444033c | (19 << 27) /* 0.266604647 */, - /* 7230 */ 0x044436cc | (19 << 27) /* 0.266653822 */, - /* 7231 */ 0x04446a5d | (19 << 27) /* 0.266702998 */, - - /* 7232 */ 0x04449dee | (19 << 27) /* 0.266752177 */, - /* 7233 */ 0x0444d180 | (19 << 27) /* 0.266801358 */, - /* 7234 */ 0x04450513 | (19 << 27) /* 0.266850541 */, - /* 7235 */ 0x044538a6 | (19 << 27) /* 0.266899727 */, - /* 7236 */ 0x04456c39 | (19 << 27) /* 0.266948915 */, - /* 7237 */ 0x04459fce | (19 << 27) /* 0.266998105 */, - /* 7238 */ 0x0445d363 | (19 << 27) /* 0.267047298 */, - /* 7239 */ 0x044606f8 | (19 << 27) /* 0.267096492 */, - /* 7240 */ 0x04463a8f | (19 << 27) /* 0.267145689 */, - /* 7241 */ 0x04466e25 | (19 << 27) /* 0.267194888 */, - /* 7242 */ 0x0446a1bd | (19 << 27) /* 0.267244090 */, - /* 7243 */ 0x0446d555 | (19 << 27) /* 0.267293294 */, - /* 7244 */ 0x044708ee | (19 << 27) /* 0.267342500 */, - /* 7245 */ 0x04473c87 | (19 << 27) /* 0.267391708 */, - /* 7246 */ 0x04477021 | (19 << 27) /* 0.267440919 */, - /* 7247 */ 0x0447a3bb | (19 << 27) /* 0.267490131 */, - - /* 7248 */ 0x0447d756 | (19 << 27) /* 0.267539347 */, - /* 7249 */ 0x04480af2 | (19 << 27) /* 0.267588564 */, - /* 7250 */ 0x04483e8e | (19 << 27) /* 0.267637783 */, - /* 7251 */ 0x0448722b | (19 << 27) /* 0.267687005 */, - /* 7252 */ 0x0448a5c9 | (19 << 27) /* 0.267736229 */, - /* 7253 */ 0x0448d967 | (19 << 27) /* 0.267785456 */, - /* 7254 */ 0x04490d05 | (19 << 27) /* 0.267834685 */, - /* 7255 */ 0x044940a5 | (19 << 27) /* 0.267883915 */, - /* 7256 */ 0x04497445 | (19 << 27) /* 0.267933149 */, - /* 7257 */ 0x0449a7e5 | (19 << 27) /* 0.267982384 */, - /* 7258 */ 0x0449db86 | (19 << 27) /* 0.268031622 */, - /* 7259 */ 0x044a0f28 | (19 << 27) /* 0.268080862 */, - /* 7260 */ 0x044a42ca | (19 << 27) /* 0.268130104 */, - /* 7261 */ 0x044a766d | (19 << 27) /* 0.268179349 */, - /* 7262 */ 0x044aaa11 | (19 << 27) /* 0.268228595 */, - /* 7263 */ 0x044addb5 | (19 << 27) /* 0.268277844 */, - - /* 7264 */ 0x044b115a | (19 << 27) /* 0.268327096 */, - /* 7265 */ 0x044b44ff | (19 << 27) /* 0.268376349 */, - /* 7266 */ 0x044b78a5 | (19 << 27) /* 0.268425605 */, - /* 7267 */ 0x044bac4c | (19 << 27) /* 0.268474863 */, - /* 7268 */ 0x044bdff3 | (19 << 27) /* 0.268524123 */, - /* 7269 */ 0x044c139b | (19 << 27) /* 0.268573386 */, - /* 7270 */ 0x044c4743 | (19 << 27) /* 0.268622651 */, - /* 7271 */ 0x044c7aec | (19 << 27) /* 0.268671918 */, - /* 7272 */ 0x044cae96 | (19 << 27) /* 0.268721187 */, - /* 7273 */ 0x044ce240 | (19 << 27) /* 0.268770459 */, - /* 7274 */ 0x044d15eb | (19 << 27) /* 0.268819733 */, - /* 7275 */ 0x044d4997 | (19 << 27) /* 0.268869009 */, - /* 7276 */ 0x044d7d43 | (19 << 27) /* 0.268918287 */, - /* 7277 */ 0x044db0ef | (19 << 27) /* 0.268967568 */, - /* 7278 */ 0x044de49d | (19 << 27) /* 0.269016851 */, - /* 7279 */ 0x044e184b | (19 << 27) /* 0.269066136 */, - - /* 7280 */ 0x044e4bf9 | (19 << 27) /* 0.269115423 */, - /* 7281 */ 0x044e7fa8 | (19 << 27) /* 0.269164713 */, - /* 7282 */ 0x044eb358 | (19 << 27) /* 0.269214005 */, - /* 7283 */ 0x044ee708 | (19 << 27) /* 0.269263299 */, - /* 7284 */ 0x044f1ab9 | (19 << 27) /* 0.269312595 */, - /* 7285 */ 0x044f4e6b | (19 << 27) /* 0.269361894 */, - /* 7286 */ 0x044f821d | (19 << 27) /* 0.269411195 */, - /* 7287 */ 0x044fb5cf | (19 << 27) /* 0.269460498 */, - /* 7288 */ 0x044fe983 | (19 << 27) /* 0.269509804 */, - /* 7289 */ 0x04501d37 | (19 << 27) /* 0.269559111 */, - /* 7290 */ 0x045050eb | (19 << 27) /* 0.269608421 */, - /* 7291 */ 0x045084a0 | (19 << 27) /* 0.269657734 */, - /* 7292 */ 0x0450b856 | (19 << 27) /* 0.269707048 */, - /* 7293 */ 0x0450ec0d | (19 << 27) /* 0.269756365 */, - /* 7294 */ 0x04511fc4 | (19 << 27) /* 0.269805684 */, - /* 7295 */ 0x0451537b | (19 << 27) /* 0.269855005 */, - - /* 7296 */ 0x04518733 | (19 << 27) /* 0.269904329 */, - /* 7297 */ 0x0451baec | (19 << 27) /* 0.269953654 */, - /* 7298 */ 0x0451eea5 | (19 << 27) /* 0.270002982 */, - /* 7299 */ 0x0452225f | (19 << 27) /* 0.270052313 */, - /* 7300 */ 0x0452561a | (19 << 27) /* 0.270101645 */, - /* 7301 */ 0x045289d5 | (19 << 27) /* 0.270150980 */, - /* 7302 */ 0x0452bd91 | (19 << 27) /* 0.270200317 */, - /* 7303 */ 0x0452f14d | (19 << 27) /* 0.270249656 */, - /* 7304 */ 0x0453250a | (19 << 27) /* 0.270298998 */, - /* 7305 */ 0x045358c8 | (19 << 27) /* 0.270348341 */, - /* 7306 */ 0x04538c86 | (19 << 27) /* 0.270397687 */, - /* 7307 */ 0x0453c045 | (19 << 27) /* 0.270447036 */, - /* 7308 */ 0x0453f405 | (19 << 27) /* 0.270496386 */, - /* 7309 */ 0x045427c5 | (19 << 27) /* 0.270545739 */, - /* 7310 */ 0x04545b85 | (19 << 27) /* 0.270595094 */, - /* 7311 */ 0x04548f46 | (19 << 27) /* 0.270644451 */, - - /* 7312 */ 0x0454c308 | (19 << 27) /* 0.270693811 */, - /* 7313 */ 0x0454f6cb | (19 << 27) /* 0.270743173 */, - /* 7314 */ 0x04552a8e | (19 << 27) /* 0.270792537 */, - /* 7315 */ 0x04555e51 | (19 << 27) /* 0.270841903 */, - /* 7316 */ 0x04559216 | (19 << 27) /* 0.270891271 */, - /* 7317 */ 0x0455c5db | (19 << 27) /* 0.270940642 */, - /* 7318 */ 0x0455f9a0 | (19 << 27) /* 0.270990015 */, - /* 7319 */ 0x04562d66 | (19 << 27) /* 0.271039390 */, - /* 7320 */ 0x0456612d | (19 << 27) /* 0.271088768 */, - /* 7321 */ 0x045694f4 | (19 << 27) /* 0.271138148 */, - /* 7322 */ 0x0456c8bc | (19 << 27) /* 0.271187530 */, - /* 7323 */ 0x0456fc84 | (19 << 27) /* 0.271236914 */, - /* 7324 */ 0x0457304e | (19 << 27) /* 0.271286301 */, - /* 7325 */ 0x04576417 | (19 << 27) /* 0.271335689 */, - /* 7326 */ 0x045797e2 | (19 << 27) /* 0.271385080 */, - /* 7327 */ 0x0457cbac | (19 << 27) /* 0.271434474 */, - - /* 7328 */ 0x0457ff78 | (19 << 27) /* 0.271483869 */, - /* 7329 */ 0x04583344 | (19 << 27) /* 0.271533267 */, - /* 7330 */ 0x04586711 | (19 << 27) /* 0.271582667 */, - /* 7331 */ 0x04589ade | (19 << 27) /* 0.271632069 */, - /* 7332 */ 0x0458ceac | (19 << 27) /* 0.271681474 */, - /* 7333 */ 0x0459027b | (19 << 27) /* 0.271730880 */, - /* 7334 */ 0x0459364a | (19 << 27) /* 0.271780289 */, - /* 7335 */ 0x04596a19 | (19 << 27) /* 0.271829701 */, - /* 7336 */ 0x04599dea | (19 << 27) /* 0.271879114 */, - /* 7337 */ 0x0459d1bb | (19 << 27) /* 0.271928530 */, - /* 7338 */ 0x045a058c | (19 << 27) /* 0.271977948 */, - /* 7339 */ 0x045a395e | (19 << 27) /* 0.272027368 */, - /* 7340 */ 0x045a6d31 | (19 << 27) /* 0.272076790 */, - /* 7341 */ 0x045aa104 | (19 << 27) /* 0.272126215 */, - /* 7342 */ 0x045ad4d8 | (19 << 27) /* 0.272175642 */, - /* 7343 */ 0x045b08ad | (19 << 27) /* 0.272225071 */, - - /* 7344 */ 0x045b3c82 | (19 << 27) /* 0.272274503 */, - /* 7345 */ 0x045b7058 | (19 << 27) /* 0.272323936 */, - /* 7346 */ 0x045ba42e | (19 << 27) /* 0.272373372 */, - /* 7347 */ 0x045bd805 | (19 << 27) /* 0.272422810 */, - /* 7348 */ 0x045c0bdd | (19 << 27) /* 0.272472251 */, - /* 7349 */ 0x045c3fb5 | (19 << 27) /* 0.272521693 */, - /* 7350 */ 0x045c738e | (19 << 27) /* 0.272571138 */, - /* 7351 */ 0x045ca767 | (19 << 27) /* 0.272620585 */, - /* 7352 */ 0x045cdb41 | (19 << 27) /* 0.272670035 */, - /* 7353 */ 0x045d0f1b | (19 << 27) /* 0.272719486 */, - /* 7354 */ 0x045d42f7 | (19 << 27) /* 0.272768940 */, - /* 7355 */ 0x045d76d2 | (19 << 27) /* 0.272818396 */, - /* 7356 */ 0x045daaaf | (19 << 27) /* 0.272867855 */, - /* 7357 */ 0x045dde8c | (19 << 27) /* 0.272917315 */, - /* 7358 */ 0x045e1269 | (19 << 27) /* 0.272966778 */, - /* 7359 */ 0x045e4647 | (19 << 27) /* 0.273016243 */, - - /* 7360 */ 0x045e7a26 | (19 << 27) /* 0.273065710 */, - /* 7361 */ 0x045eae06 | (19 << 27) /* 0.273115180 */, - /* 7362 */ 0x045ee1e6 | (19 << 27) /* 0.273164652 */, - /* 7363 */ 0x045f15c6 | (19 << 27) /* 0.273214126 */, - /* 7364 */ 0x045f49a7 | (19 << 27) /* 0.273263602 */, - /* 7365 */ 0x045f7d89 | (19 << 27) /* 0.273313081 */, - /* 7366 */ 0x045fb16c | (19 << 27) /* 0.273362561 */, - /* 7367 */ 0x045fe54f | (19 << 27) /* 0.273412044 */, - /* 7368 */ 0x04601932 | (19 << 27) /* 0.273461530 */, - /* 7369 */ 0x04604d16 | (19 << 27) /* 0.273511017 */, - /* 7370 */ 0x046080fb | (19 << 27) /* 0.273560507 */, - /* 7371 */ 0x0460b4e1 | (19 << 27) /* 0.273609999 */, - /* 7372 */ 0x0460e8c7 | (19 << 27) /* 0.273659493 */, - /* 7373 */ 0x04611cad | (19 << 27) /* 0.273708989 */, - /* 7374 */ 0x04615094 | (19 << 27) /* 0.273758488 */, - /* 7375 */ 0x0461847c | (19 << 27) /* 0.273807989 */, - - /* 7376 */ 0x0461b864 | (19 << 27) /* 0.273857492 */, - /* 7377 */ 0x0461ec4d | (19 << 27) /* 0.273906997 */, - /* 7378 */ 0x04622037 | (19 << 27) /* 0.273956505 */, - /* 7379 */ 0x04625421 | (19 << 27) /* 0.274006015 */, - /* 7380 */ 0x0462880c | (19 << 27) /* 0.274055527 */, - /* 7381 */ 0x0462bbf7 | (19 << 27) /* 0.274105041 */, - /* 7382 */ 0x0462efe3 | (19 << 27) /* 0.274154558 */, - /* 7383 */ 0x046323d0 | (19 << 27) /* 0.274204076 */, - /* 7384 */ 0x046357bd | (19 << 27) /* 0.274253597 */, - /* 7385 */ 0x04638bab | (19 << 27) /* 0.274303121 */, - /* 7386 */ 0x0463bf99 | (19 << 27) /* 0.274352646 */, - /* 7387 */ 0x0463f388 | (19 << 27) /* 0.274402174 */, - /* 7388 */ 0x04642778 | (19 << 27) /* 0.274451704 */, - /* 7389 */ 0x04645b68 | (19 << 27) /* 0.274501236 */, - /* 7390 */ 0x04648f59 | (19 << 27) /* 0.274550771 */, - /* 7391 */ 0x0464c34a | (19 << 27) /* 0.274600307 */, - - /* 7392 */ 0x0464f73c | (19 << 27) /* 0.274649846 */, - /* 7393 */ 0x04652b2f | (19 << 27) /* 0.274699387 */, - /* 7394 */ 0x04655f22 | (19 << 27) /* 0.274748931 */, - /* 7395 */ 0x04659316 | (19 << 27) /* 0.274798476 */, - /* 7396 */ 0x0465c70a | (19 << 27) /* 0.274848024 */, - /* 7397 */ 0x0465faff | (19 << 27) /* 0.274897574 */, - /* 7398 */ 0x04662ef5 | (19 << 27) /* 0.274947126 */, - /* 7399 */ 0x046662eb | (19 << 27) /* 0.274996681 */, - /* 7400 */ 0x046696e2 | (19 << 27) /* 0.275046238 */, - /* 7401 */ 0x0466cad9 | (19 << 27) /* 0.275095797 */, - /* 7402 */ 0x0466fed1 | (19 << 27) /* 0.275145358 */, - /* 7403 */ 0x046732ca | (19 << 27) /* 0.275194921 */, - /* 7404 */ 0x046766c3 | (19 << 27) /* 0.275244487 */, - /* 7405 */ 0x04679abd | (19 << 27) /* 0.275294055 */, - /* 7406 */ 0x0467ceb7 | (19 << 27) /* 0.275343625 */, - /* 7407 */ 0x046802b2 | (19 << 27) /* 0.275393198 */, - - /* 7408 */ 0x046836ae | (19 << 27) /* 0.275442772 */, - /* 7409 */ 0x04686aaa | (19 << 27) /* 0.275492349 */, - /* 7410 */ 0x04689ea7 | (19 << 27) /* 0.275541928 */, - /* 7411 */ 0x0468d2a4 | (19 << 27) /* 0.275591509 */, - /* 7412 */ 0x046906a2 | (19 << 27) /* 0.275641093 */, - /* 7413 */ 0x04693aa1 | (19 << 27) /* 0.275690679 */, - /* 7414 */ 0x04696ea0 | (19 << 27) /* 0.275740267 */, - /* 7415 */ 0x0469a2a0 | (19 << 27) /* 0.275789857 */, - /* 7416 */ 0x0469d6a0 | (19 << 27) /* 0.275839449 */, - /* 7417 */ 0x046a0aa1 | (19 << 27) /* 0.275889044 */, - /* 7418 */ 0x046a3ea3 | (19 << 27) /* 0.275938641 */, - /* 7419 */ 0x046a72a5 | (19 << 27) /* 0.275988240 */, - /* 7420 */ 0x046aa6a8 | (19 << 27) /* 0.276037842 */, - /* 7421 */ 0x046adaab | (19 << 27) /* 0.276087445 */, - /* 7422 */ 0x046b0eaf | (19 << 27) /* 0.276137051 */, - /* 7423 */ 0x046b42b3 | (19 << 27) /* 0.276186659 */, - - /* 7424 */ 0x046b76b9 | (19 << 27) /* 0.276236269 */, - /* 7425 */ 0x046baabe | (19 << 27) /* 0.276285882 */, - /* 7426 */ 0x046bdec5 | (19 << 27) /* 0.276335497 */, - /* 7427 */ 0x046c12cc | (19 << 27) /* 0.276385113 */, - /* 7428 */ 0x046c46d3 | (19 << 27) /* 0.276434733 */, - /* 7429 */ 0x046c7adb | (19 << 27) /* 0.276484354 */, - /* 7430 */ 0x046caee4 | (19 << 27) /* 0.276533978 */, - /* 7431 */ 0x046ce2ee | (19 << 27) /* 0.276583604 */, - /* 7432 */ 0x046d16f7 | (19 << 27) /* 0.276633232 */, - /* 7433 */ 0x046d4b02 | (19 << 27) /* 0.276682862 */, - /* 7434 */ 0x046d7f0d | (19 << 27) /* 0.276732495 */, - /* 7435 */ 0x046db319 | (19 << 27) /* 0.276782129 */, - /* 7436 */ 0x046de725 | (19 << 27) /* 0.276831766 */, - /* 7437 */ 0x046e1b32 | (19 << 27) /* 0.276881406 */, - /* 7438 */ 0x046e4f40 | (19 << 27) /* 0.276931047 */, - /* 7439 */ 0x046e834e | (19 << 27) /* 0.276980691 */, - - /* 7440 */ 0x046eb75c | (19 << 27) /* 0.277030337 */, - /* 7441 */ 0x046eeb6c | (19 << 27) /* 0.277079985 */, - /* 7442 */ 0x046f1f7c | (19 << 27) /* 0.277129635 */, - /* 7443 */ 0x046f538c | (19 << 27) /* 0.277179288 */, - /* 7444 */ 0x046f879d | (19 << 27) /* 0.277228942 */, - /* 7445 */ 0x046fbbaf | (19 << 27) /* 0.277278600 */, - /* 7446 */ 0x046fefc1 | (19 << 27) /* 0.277328259 */, - /* 7447 */ 0x047023d4 | (19 << 27) /* 0.277377920 */, - /* 7448 */ 0x047057e8 | (19 << 27) /* 0.277427584 */, - /* 7449 */ 0x04708bfc | (19 << 27) /* 0.277477250 */, - /* 7450 */ 0x0470c011 | (19 << 27) /* 0.277526918 */, - /* 7451 */ 0x0470f426 | (19 << 27) /* 0.277576588 */, - /* 7452 */ 0x0471283c | (19 << 27) /* 0.277626261 */, - /* 7453 */ 0x04715c52 | (19 << 27) /* 0.277675936 */, - /* 7454 */ 0x04719069 | (19 << 27) /* 0.277725613 */, - /* 7455 */ 0x0471c481 | (19 << 27) /* 0.277775292 */, - - /* 7456 */ 0x0471f899 | (19 << 27) /* 0.277824973 */, - /* 7457 */ 0x04722cb2 | (19 << 27) /* 0.277874657 */, - /* 7458 */ 0x047260cc | (19 << 27) /* 0.277924343 */, - /* 7459 */ 0x047294e6 | (19 << 27) /* 0.277974031 */, - /* 7460 */ 0x0472c900 | (19 << 27) /* 0.278023722 */, - /* 7461 */ 0x0472fd1b | (19 << 27) /* 0.278073414 */, - /* 7462 */ 0x04733137 | (19 << 27) /* 0.278123109 */, - /* 7463 */ 0x04736554 | (19 << 27) /* 0.278172806 */, - /* 7464 */ 0x04739971 | (19 << 27) /* 0.278222505 */, - /* 7465 */ 0x0473cd8e | (19 << 27) /* 0.278272207 */, - /* 7466 */ 0x047401ad | (19 << 27) /* 0.278321910 */, - /* 7467 */ 0x047435cb | (19 << 27) /* 0.278371616 */, - /* 7468 */ 0x047469eb | (19 << 27) /* 0.278421324 */, - /* 7469 */ 0x04749e0b | (19 << 27) /* 0.278471035 */, - /* 7470 */ 0x0474d22c | (19 << 27) /* 0.278520747 */, - /* 7471 */ 0x0475064d | (19 << 27) /* 0.278570462 */, - - /* 7472 */ 0x04753a6f | (19 << 27) /* 0.278620179 */, - /* 7473 */ 0x04756e91 | (19 << 27) /* 0.278669898 */, - /* 7474 */ 0x0475a2b4 | (19 << 27) /* 0.278719619 */, - /* 7475 */ 0x0475d6d7 | (19 << 27) /* 0.278769343 */, - /* 7476 */ 0x04760afc | (19 << 27) /* 0.278819069 */, - /* 7477 */ 0x04763f20 | (19 << 27) /* 0.278868797 */, - /* 7478 */ 0x04767346 | (19 << 27) /* 0.278918527 */, - /* 7479 */ 0x0476a76c | (19 << 27) /* 0.278968260 */, - /* 7480 */ 0x0476db92 | (19 << 27) /* 0.279017995 */, - /* 7481 */ 0x04770fba | (19 << 27) /* 0.279067731 */, - /* 7482 */ 0x047743e1 | (19 << 27) /* 0.279117471 */, - /* 7483 */ 0x0477780a | (19 << 27) /* 0.279167212 */, - /* 7484 */ 0x0477ac33 | (19 << 27) /* 0.279216956 */, - /* 7485 */ 0x0477e05c | (19 << 27) /* 0.279266701 */, - /* 7486 */ 0x04781486 | (19 << 27) /* 0.279316449 */, - /* 7487 */ 0x047848b1 | (19 << 27) /* 0.279366200 */, - - /* 7488 */ 0x04787cdc | (19 << 27) /* 0.279415952 */, - /* 7489 */ 0x0478b108 | (19 << 27) /* 0.279465707 */, - /* 7490 */ 0x0478e535 | (19 << 27) /* 0.279515464 */, - /* 7491 */ 0x04791962 | (19 << 27) /* 0.279565223 */, - /* 7492 */ 0x04794d8f | (19 << 27) /* 0.279614984 */, - /* 7493 */ 0x047981be | (19 << 27) /* 0.279664748 */, - /* 7494 */ 0x0479b5ed | (19 << 27) /* 0.279714513 */, - /* 7495 */ 0x0479ea1c | (19 << 27) /* 0.279764281 */, - /* 7496 */ 0x047a1e4c | (19 << 27) /* 0.279814051 */, - /* 7497 */ 0x047a527d | (19 << 27) /* 0.279863824 */, - /* 7498 */ 0x047a86ae | (19 << 27) /* 0.279913598 */, - /* 7499 */ 0x047abae0 | (19 << 27) /* 0.279963375 */, - /* 7500 */ 0x047aef12 | (19 << 27) /* 0.280013154 */, - /* 7501 */ 0x047b2346 | (19 << 27) /* 0.280062935 */, - /* 7502 */ 0x047b5779 | (19 << 27) /* 0.280112719 */, - /* 7503 */ 0x047b8bad | (19 << 27) /* 0.280162504 */, - - /* 7504 */ 0x047bbfe2 | (19 << 27) /* 0.280212292 */, - /* 7505 */ 0x047bf418 | (19 << 27) /* 0.280262082 */, - /* 7506 */ 0x047c284e | (19 << 27) /* 0.280311875 */, - /* 7507 */ 0x047c5c84 | (19 << 27) /* 0.280361669 */, - /* 7508 */ 0x047c90bb | (19 << 27) /* 0.280411466 */, - /* 7509 */ 0x047cc4f3 | (19 << 27) /* 0.280461265 */, - /* 7510 */ 0x047cf92c | (19 << 27) /* 0.280511066 */, - /* 7511 */ 0x047d2d65 | (19 << 27) /* 0.280560869 */, - /* 7512 */ 0x047d619e | (19 << 27) /* 0.280610675 */, - /* 7513 */ 0x047d95d8 | (19 << 27) /* 0.280660483 */, - /* 7514 */ 0x047dca13 | (19 << 27) /* 0.280710292 */, - /* 7515 */ 0x047dfe4e | (19 << 27) /* 0.280760105 */, - /* 7516 */ 0x047e328a | (19 << 27) /* 0.280809919 */, - /* 7517 */ 0x047e66c7 | (19 << 27) /* 0.280859736 */, - /* 7518 */ 0x047e9b04 | (19 << 27) /* 0.280909554 */, - /* 7519 */ 0x047ecf42 | (19 << 27) /* 0.280959375 */, - - /* 7520 */ 0x047f0380 | (19 << 27) /* 0.281009199 */, - /* 7521 */ 0x047f37bf | (19 << 27) /* 0.281059024 */, - /* 7522 */ 0x047f6bff | (19 << 27) /* 0.281108852 */, - /* 7523 */ 0x047fa03f | (19 << 27) /* 0.281158682 */, - /* 7524 */ 0x047fd47f | (19 << 27) /* 0.281208514 */, - /* 7525 */ 0x048008c1 | (19 << 27) /* 0.281258348 */, - /* 7526 */ 0x04803d02 | (19 << 27) /* 0.281308184 */, - /* 7527 */ 0x04807145 | (19 << 27) /* 0.281358023 */, - /* 7528 */ 0x0480a588 | (19 << 27) /* 0.281407864 */, - /* 7529 */ 0x0480d9cc | (19 << 27) /* 0.281457707 */, - /* 7530 */ 0x04810e10 | (19 << 27) /* 0.281507552 */, - /* 7531 */ 0x04814255 | (19 << 27) /* 0.281557400 */, - /* 7532 */ 0x0481769a | (19 << 27) /* 0.281607250 */, - /* 7533 */ 0x0481aae0 | (19 << 27) /* 0.281657101 */, - /* 7534 */ 0x0481df27 | (19 << 27) /* 0.281706956 */, - /* 7535 */ 0x0482136e | (19 << 27) /* 0.281756812 */, - - /* 7536 */ 0x048247b6 | (19 << 27) /* 0.281806670 */, - /* 7537 */ 0x04827bfe | (19 << 27) /* 0.281856531 */, - /* 7538 */ 0x0482b047 | (19 << 27) /* 0.281906394 */, - /* 7539 */ 0x0482e491 | (19 << 27) /* 0.281956259 */, - /* 7540 */ 0x048318db | (19 << 27) /* 0.282006127 */, - /* 7541 */ 0x04834d26 | (19 << 27) /* 0.282055996 */, - /* 7542 */ 0x04838171 | (19 << 27) /* 0.282105868 */, - /* 7543 */ 0x0483b5bd | (19 << 27) /* 0.282155742 */, - /* 7544 */ 0x0483ea0a | (19 << 27) /* 0.282205618 */, - /* 7545 */ 0x04841e57 | (19 << 27) /* 0.282255496 */, - /* 7546 */ 0x048452a4 | (19 << 27) /* 0.282305377 */, - /* 7547 */ 0x048486f3 | (19 << 27) /* 0.282355260 */, - /* 7548 */ 0x0484bb42 | (19 << 27) /* 0.282405145 */, - /* 7549 */ 0x0484ef91 | (19 << 27) /* 0.282455032 */, - /* 7550 */ 0x048523e1 | (19 << 27) /* 0.282504921 */, - /* 7551 */ 0x04855832 | (19 << 27) /* 0.282554813 */, - - /* 7552 */ 0x04858c83 | (19 << 27) /* 0.282604707 */, - /* 7553 */ 0x0485c0d5 | (19 << 27) /* 0.282654603 */, - /* 7554 */ 0x0485f527 | (19 << 27) /* 0.282704501 */, - /* 7555 */ 0x0486297a | (19 << 27) /* 0.282754401 */, - /* 7556 */ 0x04865dce | (19 << 27) /* 0.282804304 */, - /* 7557 */ 0x04869222 | (19 << 27) /* 0.282854209 */, - /* 7558 */ 0x0486c677 | (19 << 27) /* 0.282904116 */, - /* 7559 */ 0x0486facc | (19 << 27) /* 0.282954025 */, - /* 7560 */ 0x04872f22 | (19 << 27) /* 0.283003936 */, - /* 7561 */ 0x04876379 | (19 << 27) /* 0.283053850 */, - /* 7562 */ 0x048797d0 | (19 << 27) /* 0.283103766 */, - /* 7563 */ 0x0487cc28 | (19 << 27) /* 0.283153684 */, - /* 7564 */ 0x04880080 | (19 << 27) /* 0.283203604 */, - /* 7565 */ 0x048834d9 | (19 << 27) /* 0.283253527 */, - /* 7566 */ 0x04886933 | (19 << 27) /* 0.283303451 */, - /* 7567 */ 0x04889d8d | (19 << 27) /* 0.283353378 */, - - /* 7568 */ 0x0488d1e8 | (19 << 27) /* 0.283403307 */, - /* 7569 */ 0x04890643 | (19 << 27) /* 0.283453238 */, - /* 7570 */ 0x04893a9f | (19 << 27) /* 0.283503172 */, - /* 7571 */ 0x04896efb | (19 << 27) /* 0.283553107 */, - /* 7572 */ 0x0489a358 | (19 << 27) /* 0.283603045 */, - /* 7573 */ 0x0489d7b6 | (19 << 27) /* 0.283652985 */, - /* 7574 */ 0x048a0c14 | (19 << 27) /* 0.283702927 */, - /* 7575 */ 0x048a4073 | (19 << 27) /* 0.283752872 */, - /* 7576 */ 0x048a74d3 | (19 << 27) /* 0.283802818 */, - /* 7577 */ 0x048aa933 | (19 << 27) /* 0.283852767 */, - /* 7578 */ 0x048add93 | (19 << 27) /* 0.283902718 */, - /* 7579 */ 0x048b11f5 | (19 << 27) /* 0.283952671 */, - /* 7580 */ 0x048b4656 | (19 << 27) /* 0.284002627 */, - /* 7581 */ 0x048b7ab9 | (19 << 27) /* 0.284052584 */, - /* 7582 */ 0x048baf1c | (19 << 27) /* 0.284102544 */, - /* 7583 */ 0x048be37f | (19 << 27) /* 0.284152506 */, - - /* 7584 */ 0x048c17e3 | (19 << 27) /* 0.284202470 */, - /* 7585 */ 0x048c4c48 | (19 << 27) /* 0.284252436 */, - /* 7586 */ 0x048c80ad | (19 << 27) /* 0.284302405 */, - /* 7587 */ 0x048cb513 | (19 << 27) /* 0.284352376 */, - /* 7588 */ 0x048ce97a | (19 << 27) /* 0.284402349 */, - /* 7589 */ 0x048d1de1 | (19 << 27) /* 0.284452324 */, - /* 7590 */ 0x048d5249 | (19 << 27) /* 0.284502301 */, - /* 7591 */ 0x048d86b1 | (19 << 27) /* 0.284552281 */, - /* 7592 */ 0x048dbb1a | (19 << 27) /* 0.284602263 */, - /* 7593 */ 0x048def83 | (19 << 27) /* 0.284652246 */, - /* 7594 */ 0x048e23ed | (19 << 27) /* 0.284702233 */, - /* 7595 */ 0x048e5858 | (19 << 27) /* 0.284752221 */, - /* 7596 */ 0x048e8cc3 | (19 << 27) /* 0.284802211 */, - /* 7597 */ 0x048ec12f | (19 << 27) /* 0.284852204 */, - /* 7598 */ 0x048ef59b | (19 << 27) /* 0.284902199 */, - /* 7599 */ 0x048f2a08 | (19 << 27) /* 0.284952196 */, - - /* 7600 */ 0x048f5e76 | (19 << 27) /* 0.285002195 */, - /* 7601 */ 0x048f92e4 | (19 << 27) /* 0.285052197 */, - /* 7602 */ 0x048fc753 | (19 << 27) /* 0.285102201 */, - /* 7603 */ 0x048ffbc2 | (19 << 27) /* 0.285152206 */, - /* 7604 */ 0x04903032 | (19 << 27) /* 0.285202214 */, - /* 7605 */ 0x049064a3 | (19 << 27) /* 0.285252225 */, - /* 7606 */ 0x04909914 | (19 << 27) /* 0.285302237 */, - /* 7607 */ 0x0490cd86 | (19 << 27) /* 0.285352252 */, - /* 7608 */ 0x049101f8 | (19 << 27) /* 0.285402269 */, - /* 7609 */ 0x0491366b | (19 << 27) /* 0.285452288 */, - /* 7610 */ 0x04916ade | (19 << 27) /* 0.285502309 */, - /* 7611 */ 0x04919f52 | (19 << 27) /* 0.285552332 */, - /* 7612 */ 0x0491d3c7 | (19 << 27) /* 0.285602358 */, - /* 7613 */ 0x0492083c | (19 << 27) /* 0.285652386 */, - /* 7614 */ 0x04923cb2 | (19 << 27) /* 0.285702416 */, - /* 7615 */ 0x04927128 | (19 << 27) /* 0.285752448 */, - - /* 7616 */ 0x0492a59f | (19 << 27) /* 0.285802482 */, - /* 7617 */ 0x0492da17 | (19 << 27) /* 0.285852519 */, - /* 7618 */ 0x04930e8f | (19 << 27) /* 0.285902557 */, - /* 7619 */ 0x04934308 | (19 << 27) /* 0.285952598 */, - /* 7620 */ 0x04937781 | (19 << 27) /* 0.286002641 */, - /* 7621 */ 0x0493abfb | (19 << 27) /* 0.286052687 */, - /* 7622 */ 0x0493e076 | (19 << 27) /* 0.286102734 */, - /* 7623 */ 0x049414f1 | (19 << 27) /* 0.286152784 */, - /* 7624 */ 0x0494496c | (19 << 27) /* 0.286202836 */, - /* 7625 */ 0x04947de9 | (19 << 27) /* 0.286252890 */, - /* 7626 */ 0x0494b266 | (19 << 27) /* 0.286302946 */, - /* 7627 */ 0x0494e6e3 | (19 << 27) /* 0.286353005 */, - /* 7628 */ 0x04951b61 | (19 << 27) /* 0.286403065 */, - /* 7629 */ 0x04954fe0 | (19 << 27) /* 0.286453128 */, - /* 7630 */ 0x0495845f | (19 << 27) /* 0.286503193 */, - /* 7631 */ 0x0495b8df | (19 << 27) /* 0.286553260 */, - - /* 7632 */ 0x0495ed5f | (19 << 27) /* 0.286603329 */, - /* 7633 */ 0x049621e0 | (19 << 27) /* 0.286653401 */, - /* 7634 */ 0x04965662 | (19 << 27) /* 0.286703475 */, - /* 7635 */ 0x04968ae4 | (19 << 27) /* 0.286753551 */, - /* 7636 */ 0x0496bf67 | (19 << 27) /* 0.286803629 */, - /* 7637 */ 0x0496f3ea | (19 << 27) /* 0.286853709 */, - /* 7638 */ 0x0497286e | (19 << 27) /* 0.286903792 */, - /* 7639 */ 0x04975cf2 | (19 << 27) /* 0.286953876 */, - /* 7640 */ 0x04979177 | (19 << 27) /* 0.287003963 */, - /* 7641 */ 0x0497c5fd | (19 << 27) /* 0.287054052 */, - /* 7642 */ 0x0497fa83 | (19 << 27) /* 0.287104143 */, - /* 7643 */ 0x04982f0a | (19 << 27) /* 0.287154237 */, - /* 7644 */ 0x04986392 | (19 << 27) /* 0.287204332 */, - /* 7645 */ 0x0498981a | (19 << 27) /* 0.287254430 */, - /* 7646 */ 0x0498cca2 | (19 << 27) /* 0.287304530 */, - /* 7647 */ 0x0499012c | (19 << 27) /* 0.287354632 */, - - /* 7648 */ 0x049935b5 | (19 << 27) /* 0.287404737 */, - /* 7649 */ 0x04996a40 | (19 << 27) /* 0.287454843 */, - /* 7650 */ 0x04999ecb | (19 << 27) /* 0.287504952 */, - /* 7651 */ 0x0499d356 | (19 << 27) /* 0.287555063 */, - /* 7652 */ 0x049a07e2 | (19 << 27) /* 0.287605176 */, - /* 7653 */ 0x049a3c6f | (19 << 27) /* 0.287655291 */, - /* 7654 */ 0x049a70fc | (19 << 27) /* 0.287705409 */, - /* 7655 */ 0x049aa58a | (19 << 27) /* 0.287755528 */, - /* 7656 */ 0x049ada19 | (19 << 27) /* 0.287805650 */, - /* 7657 */ 0x049b0ea8 | (19 << 27) /* 0.287855774 */, - /* 7658 */ 0x049b4337 | (19 << 27) /* 0.287905900 */, - /* 7659 */ 0x049b77c8 | (19 << 27) /* 0.287956028 */, - /* 7660 */ 0x049bac58 | (19 << 27) /* 0.288006159 */, - /* 7661 */ 0x049be0ea | (19 << 27) /* 0.288056292 */, - /* 7662 */ 0x049c157c | (19 << 27) /* 0.288106427 */, - /* 7663 */ 0x049c4a0e | (19 << 27) /* 0.288156564 */, - - /* 7664 */ 0x049c7ea1 | (19 << 27) /* 0.288206703 */, - /* 7665 */ 0x049cb335 | (19 << 27) /* 0.288256844 */, - /* 7666 */ 0x049ce7ca | (19 << 27) /* 0.288306988 */, - /* 7667 */ 0x049d1c5e | (19 << 27) /* 0.288357134 */, - /* 7668 */ 0x049d50f4 | (19 << 27) /* 0.288407282 */, - /* 7669 */ 0x049d858a | (19 << 27) /* 0.288457432 */, - /* 7670 */ 0x049dba21 | (19 << 27) /* 0.288507584 */, - /* 7671 */ 0x049deeb8 | (19 << 27) /* 0.288557739 */, - /* 7672 */ 0x049e2350 | (19 << 27) /* 0.288607895 */, - /* 7673 */ 0x049e57e8 | (19 << 27) /* 0.288658054 */, - /* 7674 */ 0x049e8c81 | (19 << 27) /* 0.288708215 */, - /* 7675 */ 0x049ec11b | (19 << 27) /* 0.288758379 */, - /* 7676 */ 0x049ef5b5 | (19 << 27) /* 0.288808544 */, - /* 7677 */ 0x049f2a50 | (19 << 27) /* 0.288858712 */, - /* 7678 */ 0x049f5eeb | (19 << 27) /* 0.288908881 */, - /* 7679 */ 0x049f9387 | (19 << 27) /* 0.288959053 */, - - /* 7680 */ 0x049fc824 | (19 << 27) /* 0.289009227 */, - /* 7681 */ 0x049ffcc1 | (19 << 27) /* 0.289059404 */, - /* 7682 */ 0x04a0315e | (19 << 27) /* 0.289109582 */, - /* 7683 */ 0x04a065fd | (19 << 27) /* 0.289159763 */, - /* 7684 */ 0x04a09a9b | (19 << 27) /* 0.289209946 */, - /* 7685 */ 0x04a0cf3b | (19 << 27) /* 0.289260131 */, - /* 7686 */ 0x04a103db | (19 << 27) /* 0.289310318 */, - /* 7687 */ 0x04a1387b | (19 << 27) /* 0.289360507 */, - /* 7688 */ 0x04a16d1d | (19 << 27) /* 0.289410699 */, - /* 7689 */ 0x04a1a1be | (19 << 27) /* 0.289460893 */, - /* 7690 */ 0x04a1d661 | (19 << 27) /* 0.289511088 */, - /* 7691 */ 0x04a20b04 | (19 << 27) /* 0.289561287 */, - /* 7692 */ 0x04a23fa7 | (19 << 27) /* 0.289611487 */, - /* 7693 */ 0x04a2744b | (19 << 27) /* 0.289661689 */, - /* 7694 */ 0x04a2a8f0 | (19 << 27) /* 0.289711894 */, - /* 7695 */ 0x04a2dd95 | (19 << 27) /* 0.289762101 */, - - /* 7696 */ 0x04a3123b | (19 << 27) /* 0.289812309 */, - /* 7697 */ 0x04a346e2 | (19 << 27) /* 0.289862521 */, - /* 7698 */ 0x04a37b89 | (19 << 27) /* 0.289912734 */, - /* 7699 */ 0x04a3b030 | (19 << 27) /* 0.289962949 */, - /* 7700 */ 0x04a3e4d8 | (19 << 27) /* 0.290013167 */, - /* 7701 */ 0x04a41981 | (19 << 27) /* 0.290063387 */, - /* 7702 */ 0x04a44e2b | (19 << 27) /* 0.290113609 */, - /* 7703 */ 0x04a482d5 | (19 << 27) /* 0.290163833 */, - /* 7704 */ 0x04a4b77f | (19 << 27) /* 0.290214059 */, - /* 7705 */ 0x04a4ec2a | (19 << 27) /* 0.290264288 */, - /* 7706 */ 0x04a520d6 | (19 << 27) /* 0.290314519 */, - /* 7707 */ 0x04a55582 | (19 << 27) /* 0.290364751 */, - /* 7708 */ 0x04a58a2f | (19 << 27) /* 0.290414986 */, - /* 7709 */ 0x04a5bedd | (19 << 27) /* 0.290465224 */, - /* 7710 */ 0x04a5f38b | (19 << 27) /* 0.290515463 */, - /* 7711 */ 0x04a62839 | (19 << 27) /* 0.290565705 */, - - /* 7712 */ 0x04a65ce8 | (19 << 27) /* 0.290615948 */, - /* 7713 */ 0x04a69198 | (19 << 27) /* 0.290666194 */, - /* 7714 */ 0x04a6c648 | (19 << 27) /* 0.290716442 */, - /* 7715 */ 0x04a6faf9 | (19 << 27) /* 0.290766692 */, - /* 7716 */ 0x04a72fab | (19 << 27) /* 0.290816945 */, - /* 7717 */ 0x04a7645d | (19 << 27) /* 0.290867199 */, - /* 7718 */ 0x04a79910 | (19 << 27) /* 0.290917456 */, - /* 7719 */ 0x04a7cdc3 | (19 << 27) /* 0.290967715 */, - /* 7720 */ 0x04a80277 | (19 << 27) /* 0.291017976 */, - /* 7721 */ 0x04a8372b | (19 << 27) /* 0.291068239 */, - /* 7722 */ 0x04a86be0 | (19 << 27) /* 0.291118505 */, - /* 7723 */ 0x04a8a096 | (19 << 27) /* 0.291168772 */, - /* 7724 */ 0x04a8d54c | (19 << 27) /* 0.291219042 */, - /* 7725 */ 0x04a90a03 | (19 << 27) /* 0.291269314 */, - /* 7726 */ 0x04a93eba | (19 << 27) /* 0.291319588 */, - /* 7727 */ 0x04a97372 | (19 << 27) /* 0.291369865 */, - - /* 7728 */ 0x04a9a82b | (19 << 27) /* 0.291420143 */, - /* 7729 */ 0x04a9dce4 | (19 << 27) /* 0.291470424 */, - /* 7730 */ 0x04aa119d | (19 << 27) /* 0.291520706 */, - /* 7731 */ 0x04aa4658 | (19 << 27) /* 0.291570991 */, - /* 7732 */ 0x04aa7b13 | (19 << 27) /* 0.291621278 */, - /* 7733 */ 0x04aaafce | (19 << 27) /* 0.291671568 */, - /* 7734 */ 0x04aae48a | (19 << 27) /* 0.291721859 */, - /* 7735 */ 0x04ab1947 | (19 << 27) /* 0.291772153 */, - /* 7736 */ 0x04ab4e04 | (19 << 27) /* 0.291822449 */, - /* 7737 */ 0x04ab82c2 | (19 << 27) /* 0.291872747 */, - /* 7738 */ 0x04abb780 | (19 << 27) /* 0.291923047 */, - /* 7739 */ 0x04abec3f | (19 << 27) /* 0.291973349 */, - /* 7740 */ 0x04ac20fe | (19 << 27) /* 0.292023653 */, - /* 7741 */ 0x04ac55be | (19 << 27) /* 0.292073960 */, - /* 7742 */ 0x04ac8a7f | (19 << 27) /* 0.292124269 */, - /* 7743 */ 0x04acbf40 | (19 << 27) /* 0.292174580 */, - - /* 7744 */ 0x04acf402 | (19 << 27) /* 0.292224893 */, - /* 7745 */ 0x04ad28c5 | (19 << 27) /* 0.292275208 */, - /* 7746 */ 0x04ad5d88 | (19 << 27) /* 0.292325526 */, - /* 7747 */ 0x04ad924b | (19 << 27) /* 0.292375845 */, - /* 7748 */ 0x04adc70f | (19 << 27) /* 0.292426167 */, - /* 7749 */ 0x04adfbd4 | (19 << 27) /* 0.292476491 */, - /* 7750 */ 0x04ae3099 | (19 << 27) /* 0.292526817 */, - /* 7751 */ 0x04ae655f | (19 << 27) /* 0.292577145 */, - /* 7752 */ 0x04ae9a26 | (19 << 27) /* 0.292627476 */, - /* 7753 */ 0x04aeceed | (19 << 27) /* 0.292677808 */, - /* 7754 */ 0x04af03b4 | (19 << 27) /* 0.292728143 */, - /* 7755 */ 0x04af387d | (19 << 27) /* 0.292778480 */, - /* 7756 */ 0x04af6d45 | (19 << 27) /* 0.292828819 */, - /* 7757 */ 0x04afa20f | (19 << 27) /* 0.292879160 */, - /* 7758 */ 0x04afd6d9 | (19 << 27) /* 0.292929504 */, - /* 7759 */ 0x04b00ba3 | (19 << 27) /* 0.292979849 */, - - /* 7760 */ 0x04b0406e | (19 << 27) /* 0.293030197 */, - /* 7761 */ 0x04b0753a | (19 << 27) /* 0.293080547 */, - /* 7762 */ 0x04b0aa06 | (19 << 27) /* 0.293130899 */, - /* 7763 */ 0x04b0ded3 | (19 << 27) /* 0.293181253 */, - /* 7764 */ 0x04b113a1 | (19 << 27) /* 0.293231610 */, - /* 7765 */ 0x04b1486f | (19 << 27) /* 0.293281968 */, - /* 7766 */ 0x04b17d3d | (19 << 27) /* 0.293332329 */, - /* 7767 */ 0x04b1b20c | (19 << 27) /* 0.293382692 */, - /* 7768 */ 0x04b1e6dc | (19 << 27) /* 0.293433057 */, - /* 7769 */ 0x04b21bad | (19 << 27) /* 0.293483424 */, - /* 7770 */ 0x04b2507d | (19 << 27) /* 0.293533794 */, - /* 7771 */ 0x04b2854f | (19 << 27) /* 0.293584165 */, - /* 7772 */ 0x04b2ba21 | (19 << 27) /* 0.293634539 */, - /* 7773 */ 0x04b2eef4 | (19 << 27) /* 0.293684915 */, - /* 7774 */ 0x04b323c7 | (19 << 27) /* 0.293735293 */, - /* 7775 */ 0x04b3589b | (19 << 27) /* 0.293785673 */, - - /* 7776 */ 0x04b38d6f | (19 << 27) /* 0.293836055 */, - /* 7777 */ 0x04b3c244 | (19 << 27) /* 0.293886440 */, - /* 7778 */ 0x04b3f71a | (19 << 27) /* 0.293936826 */, - /* 7779 */ 0x04b42bf0 | (19 << 27) /* 0.293987215 */, - /* 7780 */ 0x04b460c7 | (19 << 27) /* 0.294037606 */, - /* 7781 */ 0x04b4959e | (19 << 27) /* 0.294087999 */, - /* 7782 */ 0x04b4ca76 | (19 << 27) /* 0.294138395 */, - /* 7783 */ 0x04b4ff4e | (19 << 27) /* 0.294188792 */, - /* 7784 */ 0x04b53427 | (19 << 27) /* 0.294239192 */, - /* 7785 */ 0x04b56901 | (19 << 27) /* 0.294289593 */, - /* 7786 */ 0x04b59ddb | (19 << 27) /* 0.294339997 */, - /* 7787 */ 0x04b5d2b6 | (19 << 27) /* 0.294390403 */, - /* 7788 */ 0x04b60791 | (19 << 27) /* 0.294440812 */, - /* 7789 */ 0x04b63c6d | (19 << 27) /* 0.294491222 */, - /* 7790 */ 0x04b6714a | (19 << 27) /* 0.294541635 */, - /* 7791 */ 0x04b6a627 | (19 << 27) /* 0.294592049 */, - - /* 7792 */ 0x04b6db05 | (19 << 27) /* 0.294642466 */, - /* 7793 */ 0x04b70fe3 | (19 << 27) /* 0.294692885 */, - /* 7794 */ 0x04b744c2 | (19 << 27) /* 0.294743306 */, - /* 7795 */ 0x04b779a1 | (19 << 27) /* 0.294793730 */, - /* 7796 */ 0x04b7ae81 | (19 << 27) /* 0.294844155 */, - /* 7797 */ 0x04b7e362 | (19 << 27) /* 0.294894583 */, - /* 7798 */ 0x04b81843 | (19 << 27) /* 0.294945013 */, - /* 7799 */ 0x04b84d24 | (19 << 27) /* 0.294995445 */, - /* 7800 */ 0x04b88207 | (19 << 27) /* 0.295045879 */, - /* 7801 */ 0x04b8b6ea | (19 << 27) /* 0.295096315 */, - /* 7802 */ 0x04b8ebcd | (19 << 27) /* 0.295146753 */, - /* 7803 */ 0x04b920b1 | (19 << 27) /* 0.295197194 */, - /* 7804 */ 0x04b95596 | (19 << 27) /* 0.295247637 */, - /* 7805 */ 0x04b98a7b | (19 << 27) /* 0.295298082 */, - /* 7806 */ 0x04b9bf61 | (19 << 27) /* 0.295348529 */, - /* 7807 */ 0x04b9f447 | (19 << 27) /* 0.295398978 */, - - /* 7808 */ 0x04ba292e | (19 << 27) /* 0.295449429 */, - /* 7809 */ 0x04ba5e16 | (19 << 27) /* 0.295499883 */, - /* 7810 */ 0x04ba92fe | (19 << 27) /* 0.295550338 */, - /* 7811 */ 0x04bac7e6 | (19 << 27) /* 0.295600796 */, - /* 7812 */ 0x04bafcd0 | (19 << 27) /* 0.295651256 */, - /* 7813 */ 0x04bb31b9 | (19 << 27) /* 0.295701718 */, - /* 7814 */ 0x04bb66a4 | (19 << 27) /* 0.295752183 */, - /* 7815 */ 0x04bb9b8f | (19 << 27) /* 0.295802649 */, - /* 7816 */ 0x04bbd07a | (19 << 27) /* 0.295853118 */, - /* 7817 */ 0x04bc0566 | (19 << 27) /* 0.295903588 */, - /* 7818 */ 0x04bc3a53 | (19 << 27) /* 0.295954061 */, - /* 7819 */ 0x04bc6f40 | (19 << 27) /* 0.296004536 */, - /* 7820 */ 0x04bca42e | (19 << 27) /* 0.296055013 */, - /* 7821 */ 0x04bcd91d | (19 << 27) /* 0.296105493 */, - /* 7822 */ 0x04bd0e0c | (19 << 27) /* 0.296155974 */, - /* 7823 */ 0x04bd42fb | (19 << 27) /* 0.296206458 */, - - /* 7824 */ 0x04bd77ec | (19 << 27) /* 0.296256944 */, - /* 7825 */ 0x04bdacdc | (19 << 27) /* 0.296307432 */, - /* 7826 */ 0x04bde1ce | (19 << 27) /* 0.296357922 */, - /* 7827 */ 0x04be16c0 | (19 << 27) /* 0.296408414 */, - /* 7828 */ 0x04be4bb2 | (19 << 27) /* 0.296458908 */, - /* 7829 */ 0x04be80a5 | (19 << 27) /* 0.296509405 */, - /* 7830 */ 0x04beb599 | (19 << 27) /* 0.296559904 */, - /* 7831 */ 0x04beea8d | (19 << 27) /* 0.296610404 */, - /* 7832 */ 0x04bf1f82 | (19 << 27) /* 0.296660907 */, - /* 7833 */ 0x04bf5477 | (19 << 27) /* 0.296711413 */, - /* 7834 */ 0x04bf896d | (19 << 27) /* 0.296761920 */, - /* 7835 */ 0x04bfbe64 | (19 << 27) /* 0.296812429 */, - /* 7836 */ 0x04bff35b | (19 << 27) /* 0.296862941 */, - /* 7837 */ 0x04c02852 | (19 << 27) /* 0.296913455 */, - /* 7838 */ 0x04c05d4b | (19 << 27) /* 0.296963971 */, - /* 7839 */ 0x04c09243 | (19 << 27) /* 0.297014489 */, - - /* 7840 */ 0x04c0c73d | (19 << 27) /* 0.297065009 */, - /* 7841 */ 0x04c0fc37 | (19 << 27) /* 0.297115531 */, - /* 7842 */ 0x04c13131 | (19 << 27) /* 0.297166056 */, - /* 7843 */ 0x04c1662d | (19 << 27) /* 0.297216582 */, - /* 7844 */ 0x04c19b28 | (19 << 27) /* 0.297267111 */, - /* 7845 */ 0x04c1d025 | (19 << 27) /* 0.297317642 */, - /* 7846 */ 0x04c20521 | (19 << 27) /* 0.297368175 */, - /* 7847 */ 0x04c23a1f | (19 << 27) /* 0.297418710 */, - /* 7848 */ 0x04c26f1d | (19 << 27) /* 0.297469248 */, - /* 7849 */ 0x04c2a41b | (19 << 27) /* 0.297519787 */, - /* 7850 */ 0x04c2d91b | (19 << 27) /* 0.297570329 */, - /* 7851 */ 0x04c30e1a | (19 << 27) /* 0.297620873 */, - /* 7852 */ 0x04c3431b | (19 << 27) /* 0.297671418 */, - /* 7853 */ 0x04c3781c | (19 << 27) /* 0.297721967 */, - /* 7854 */ 0x04c3ad1d | (19 << 27) /* 0.297772517 */, - /* 7855 */ 0x04c3e21f | (19 << 27) /* 0.297823069 */, - - /* 7856 */ 0x04c41722 | (19 << 27) /* 0.297873624 */, - /* 7857 */ 0x04c44c25 | (19 << 27) /* 0.297924180 */, - /* 7858 */ 0x04c48129 | (19 << 27) /* 0.297974739 */, - /* 7859 */ 0x04c4b62d | (19 << 27) /* 0.298025300 */, - /* 7860 */ 0x04c4eb32 | (19 << 27) /* 0.298075863 */, - /* 7861 */ 0x04c52038 | (19 << 27) /* 0.298126429 */, - /* 7862 */ 0x04c5553e | (19 << 27) /* 0.298176996 */, - /* 7863 */ 0x04c58a44 | (19 << 27) /* 0.298227565 */, - /* 7864 */ 0x04c5bf4c | (19 << 27) /* 0.298278137 */, - /* 7865 */ 0x04c5f453 | (19 << 27) /* 0.298328711 */, - /* 7866 */ 0x04c6295c | (19 << 27) /* 0.298379287 */, - /* 7867 */ 0x04c65e65 | (19 << 27) /* 0.298429865 */, - /* 7868 */ 0x04c6936e | (19 << 27) /* 0.298480445 */, - /* 7869 */ 0x04c6c878 | (19 << 27) /* 0.298531028 */, - /* 7870 */ 0x04c6fd83 | (19 << 27) /* 0.298581612 */, - /* 7871 */ 0x04c7328e | (19 << 27) /* 0.298632199 */, - - /* 7872 */ 0x04c7679a | (19 << 27) /* 0.298682788 */, - /* 7873 */ 0x04c79ca7 | (19 << 27) /* 0.298733379 */, - /* 7874 */ 0x04c7d1b4 | (19 << 27) /* 0.298783972 */, - /* 7875 */ 0x04c806c1 | (19 << 27) /* 0.298834567 */, - /* 7876 */ 0x04c83bcf | (19 << 27) /* 0.298885165 */, - /* 7877 */ 0x04c870de | (19 << 27) /* 0.298935764 */, - /* 7878 */ 0x04c8a5ed | (19 << 27) /* 0.298986366 */, - /* 7879 */ 0x04c8dafd | (19 << 27) /* 0.299036970 */, - /* 7880 */ 0x04c9100d | (19 << 27) /* 0.299087576 */, - /* 7881 */ 0x04c9451e | (19 << 27) /* 0.299138184 */, - /* 7882 */ 0x04c97a30 | (19 << 27) /* 0.299188794 */, - /* 7883 */ 0x04c9af42 | (19 << 27) /* 0.299239406 */, - /* 7884 */ 0x04c9e455 | (19 << 27) /* 0.299290021 */, - /* 7885 */ 0x04ca1968 | (19 << 27) /* 0.299340638 */, - /* 7886 */ 0x04ca4e7c | (19 << 27) /* 0.299391256 */, - /* 7887 */ 0x04ca8391 | (19 << 27) /* 0.299441877 */, - - /* 7888 */ 0x04cab8a6 | (19 << 27) /* 0.299492500 */, - /* 7889 */ 0x04caedbb | (19 << 27) /* 0.299543126 */, - /* 7890 */ 0x04cb22d1 | (19 << 27) /* 0.299593753 */, - /* 7891 */ 0x04cb57e8 | (19 << 27) /* 0.299644382 */, - /* 7892 */ 0x04cb8d00 | (19 << 27) /* 0.299695014 */, - /* 7893 */ 0x04cbc217 | (19 << 27) /* 0.299745648 */, - /* 7894 */ 0x04cbf730 | (19 << 27) /* 0.299796284 */, - /* 7895 */ 0x04cc2c49 | (19 << 27) /* 0.299846922 */, - /* 7896 */ 0x04cc6163 | (19 << 27) /* 0.299897562 */, - /* 7897 */ 0x04cc967d | (19 << 27) /* 0.299948204 */, - /* 7898 */ 0x04cccb98 | (19 << 27) /* 0.299998849 */, - /* 7899 */ 0x04cd00b3 | (19 << 27) /* 0.300049495 */, - /* 7900 */ 0x04cd35cf | (19 << 27) /* 0.300100144 */, - /* 7901 */ 0x04cd6aeb | (19 << 27) /* 0.300150795 */, - /* 7902 */ 0x04cda008 | (19 << 27) /* 0.300201448 */, - /* 7903 */ 0x04cdd526 | (19 << 27) /* 0.300252103 */, - - /* 7904 */ 0x04ce0a44 | (19 << 27) /* 0.300302761 */, - /* 7905 */ 0x04ce3f63 | (19 << 27) /* 0.300353420 */, - /* 7906 */ 0x04ce7482 | (19 << 27) /* 0.300404082 */, - /* 7907 */ 0x04cea9a2 | (19 << 27) /* 0.300454745 */, - /* 7908 */ 0x04cedec3 | (19 << 27) /* 0.300505411 */, - /* 7909 */ 0x04cf13e4 | (19 << 27) /* 0.300556079 */, - /* 7910 */ 0x04cf4906 | (19 << 27) /* 0.300606749 */, - /* 7911 */ 0x04cf7e28 | (19 << 27) /* 0.300657421 */, - /* 7912 */ 0x04cfb34b | (19 << 27) /* 0.300708096 */, - /* 7913 */ 0x04cfe86e | (19 << 27) /* 0.300758772 */, - /* 7914 */ 0x04d01d92 | (19 << 27) /* 0.300809451 */, - /* 7915 */ 0x04d052b6 | (19 << 27) /* 0.300860132 */, - /* 7916 */ 0x04d087db | (19 << 27) /* 0.300910815 */, - /* 7917 */ 0x04d0bd01 | (19 << 27) /* 0.300961500 */, - /* 7918 */ 0x04d0f227 | (19 << 27) /* 0.301012187 */, - /* 7919 */ 0x04d1274e | (19 << 27) /* 0.301062876 */, - - /* 7920 */ 0x04d15c76 | (19 << 27) /* 0.301113568 */, - /* 7921 */ 0x04d1919e | (19 << 27) /* 0.301164261 */, - /* 7922 */ 0x04d1c6c6 | (19 << 27) /* 0.301214957 */, - /* 7923 */ 0x04d1fbef | (19 << 27) /* 0.301265655 */, - /* 7924 */ 0x04d23119 | (19 << 27) /* 0.301316355 */, - /* 7925 */ 0x04d26643 | (19 << 27) /* 0.301367057 */, - /* 7926 */ 0x04d29b6e | (19 << 27) /* 0.301417761 */, - /* 7927 */ 0x04d2d099 | (19 << 27) /* 0.301468468 */, - /* 7928 */ 0x04d305c5 | (19 << 27) /* 0.301519176 */, - /* 7929 */ 0x04d33af2 | (19 << 27) /* 0.301569887 */, - /* 7930 */ 0x04d3701f | (19 << 27) /* 0.301620599 */, - /* 7931 */ 0x04d3a54d | (19 << 27) /* 0.301671314 */, - /* 7932 */ 0x04d3da7b | (19 << 27) /* 0.301722031 */, - /* 7933 */ 0x04d40faa | (19 << 27) /* 0.301772751 */, - /* 7934 */ 0x04d444d9 | (19 << 27) /* 0.301823472 */, - /* 7935 */ 0x04d47a09 | (19 << 27) /* 0.301874195 */, - - /* 7936 */ 0x04d4af3a | (19 << 27) /* 0.301924921 */, - /* 7937 */ 0x04d4e46b | (19 << 27) /* 0.301975649 */, - /* 7938 */ 0x04d5199c | (19 << 27) /* 0.302026378 */, - /* 7939 */ 0x04d54ecf | (19 << 27) /* 0.302077110 */, - /* 7940 */ 0x04d58401 | (19 << 27) /* 0.302127845 */, - /* 7941 */ 0x04d5b935 | (19 << 27) /* 0.302178581 */, - /* 7942 */ 0x04d5ee69 | (19 << 27) /* 0.302229319 */, - /* 7943 */ 0x04d6239d | (19 << 27) /* 0.302280060 */, - /* 7944 */ 0x04d658d2 | (19 << 27) /* 0.302330802 */, - /* 7945 */ 0x04d68e08 | (19 << 27) /* 0.302381547 */, - /* 7946 */ 0x04d6c33e | (19 << 27) /* 0.302432294 */, - /* 7947 */ 0x04d6f875 | (19 << 27) /* 0.302483043 */, - /* 7948 */ 0x04d72dad | (19 << 27) /* 0.302533794 */, - /* 7949 */ 0x04d762e5 | (19 << 27) /* 0.302584547 */, - /* 7950 */ 0x04d7981d | (19 << 27) /* 0.302635303 */, - /* 7951 */ 0x04d7cd56 | (19 << 27) /* 0.302686060 */, - - /* 7952 */ 0x04d80290 | (19 << 27) /* 0.302736820 */, - /* 7953 */ 0x04d837ca | (19 << 27) /* 0.302787581 */, - /* 7954 */ 0x04d86d05 | (19 << 27) /* 0.302838345 */, - /* 7955 */ 0x04d8a240 | (19 << 27) /* 0.302889111 */, - /* 7956 */ 0x04d8d77c | (19 << 27) /* 0.302939879 */, - /* 7957 */ 0x04d90cb9 | (19 << 27) /* 0.302990650 */, - /* 7958 */ 0x04d941f6 | (19 << 27) /* 0.303041422 */, - /* 7959 */ 0x04d97734 | (19 << 27) /* 0.303092197 */, - /* 7960 */ 0x04d9ac72 | (19 << 27) /* 0.303142973 */, - /* 7961 */ 0x04d9e1b1 | (19 << 27) /* 0.303193752 */, - /* 7962 */ 0x04da16f0 | (19 << 27) /* 0.303244533 */, - /* 7963 */ 0x04da4c30 | (19 << 27) /* 0.303295316 */, - /* 7964 */ 0x04da8171 | (19 << 27) /* 0.303346101 */, - /* 7965 */ 0x04dab6b2 | (19 << 27) /* 0.303396889 */, - /* 7966 */ 0x04daebf4 | (19 << 27) /* 0.303447678 */, - /* 7967 */ 0x04db2136 | (19 << 27) /* 0.303498469 */, - - /* 7968 */ 0x04db5679 | (19 << 27) /* 0.303549263 */, - /* 7969 */ 0x04db8bbc | (19 << 27) /* 0.303600059 */, - /* 7970 */ 0x04dbc100 | (19 << 27) /* 0.303650857 */, - /* 7971 */ 0x04dbf644 | (19 << 27) /* 0.303701657 */, - /* 7972 */ 0x04dc2b8a | (19 << 27) /* 0.303752459 */, - /* 7973 */ 0x04dc60cf | (19 << 27) /* 0.303803263 */, - /* 7974 */ 0x04dc9616 | (19 << 27) /* 0.303854070 */, - /* 7975 */ 0x04dccb5c | (19 << 27) /* 0.303904878 */, - /* 7976 */ 0x04dd00a4 | (19 << 27) /* 0.303955689 */, - /* 7977 */ 0x04dd35ec | (19 << 27) /* 0.304006502 */, - /* 7978 */ 0x04dd6b34 | (19 << 27) /* 0.304057317 */, - /* 7979 */ 0x04dda07d | (19 << 27) /* 0.304108134 */, - /* 7980 */ 0x04ddd5c7 | (19 << 27) /* 0.304158953 */, - /* 7981 */ 0x04de0b11 | (19 << 27) /* 0.304209774 */, - /* 7982 */ 0x04de405c | (19 << 27) /* 0.304260597 */, - /* 7983 */ 0x04de75a7 | (19 << 27) /* 0.304311423 */, - - /* 7984 */ 0x04deaaf3 | (19 << 27) /* 0.304362251 */, - /* 7985 */ 0x04dee040 | (19 << 27) /* 0.304413080 */, - /* 7986 */ 0x04df158d | (19 << 27) /* 0.304463912 */, - /* 7987 */ 0x04df4adb | (19 << 27) /* 0.304514746 */, - /* 7988 */ 0x04df8029 | (19 << 27) /* 0.304565582 */, - /* 7989 */ 0x04dfb578 | (19 << 27) /* 0.304616421 */, - /* 7990 */ 0x04dfeac7 | (19 << 27) /* 0.304667261 */, - /* 7991 */ 0x04e02017 | (19 << 27) /* 0.304718103 */, - /* 7992 */ 0x04e05567 | (19 << 27) /* 0.304768948 */, - /* 7993 */ 0x04e08ab8 | (19 << 27) /* 0.304819795 */, - /* 7994 */ 0x04e0c00a | (19 << 27) /* 0.304870644 */, - /* 7995 */ 0x04e0f55c | (19 << 27) /* 0.304921495 */, - /* 7996 */ 0x04e12aaf | (19 << 27) /* 0.304972348 */, - /* 7997 */ 0x04e16002 | (19 << 27) /* 0.305023203 */, - /* 7998 */ 0x04e19556 | (19 << 27) /* 0.305074060 */, - /* 7999 */ 0x04e1caab | (19 << 27) /* 0.305124920 */, - - /* 8000 */ 0x04e20000 | (19 << 27) /* 0.305175781 */, - /* 8001 */ 0x04e23555 | (19 << 27) /* 0.305226645 */, - /* 8002 */ 0x04e26aac | (19 << 27) /* 0.305277511 */, - /* 8003 */ 0x04e2a002 | (19 << 27) /* 0.305328379 */, - /* 8004 */ 0x04e2d55a | (19 << 27) /* 0.305379249 */, - /* 8005 */ 0x04e30ab2 | (19 << 27) /* 0.305430121 */, - /* 8006 */ 0x04e3400a | (19 << 27) /* 0.305480995 */, - /* 8007 */ 0x04e37563 | (19 << 27) /* 0.305531872 */, - /* 8008 */ 0x04e3aabd | (19 << 27) /* 0.305582750 */, - /* 8009 */ 0x04e3e017 | (19 << 27) /* 0.305633631 */, - /* 8010 */ 0x04e41572 | (19 << 27) /* 0.305684513 */, - /* 8011 */ 0x04e44acd | (19 << 27) /* 0.305735398 */, - /* 8012 */ 0x04e48029 | (19 << 27) /* 0.305786285 */, - /* 8013 */ 0x04e4b585 | (19 << 27) /* 0.305837174 */, - /* 8014 */ 0x04e4eae2 | (19 << 27) /* 0.305888066 */, - /* 8015 */ 0x04e52040 | (19 << 27) /* 0.305938959 */, - - /* 8016 */ 0x04e5559e | (19 << 27) /* 0.305989854 */, - /* 8017 */ 0x04e58afd | (19 << 27) /* 0.306040752 */, - /* 8018 */ 0x04e5c05c | (19 << 27) /* 0.306091652 */, - /* 8019 */ 0x04e5f5bc | (19 << 27) /* 0.306142554 */, - /* 8020 */ 0x04e62b1c | (19 << 27) /* 0.306193457 */, - /* 8021 */ 0x04e6607d | (19 << 27) /* 0.306244364 */, - /* 8022 */ 0x04e695df | (19 << 27) /* 0.306295272 */, - /* 8023 */ 0x04e6cb41 | (19 << 27) /* 0.306346182 */, - /* 8024 */ 0x04e700a3 | (19 << 27) /* 0.306397094 */, - /* 8025 */ 0x04e73607 | (19 << 27) /* 0.306448009 */, - /* 8026 */ 0x04e76b6b | (19 << 27) /* 0.306498925 */, - /* 8027 */ 0x04e7a0cf | (19 << 27) /* 0.306549844 */, - /* 8028 */ 0x04e7d634 | (19 << 27) /* 0.306600765 */, - /* 8029 */ 0x04e80b99 | (19 << 27) /* 0.306651688 */, - /* 8030 */ 0x04e84100 | (19 << 27) /* 0.306702613 */, - /* 8031 */ 0x04e87666 | (19 << 27) /* 0.306753540 */, - - /* 8032 */ 0x04e8abcd | (19 << 27) /* 0.306804470 */, - /* 8033 */ 0x04e8e135 | (19 << 27) /* 0.306855401 */, - /* 8034 */ 0x04e9169e | (19 << 27) /* 0.306906334 */, - /* 8035 */ 0x04e94c07 | (19 << 27) /* 0.306957270 */, - /* 8036 */ 0x04e98170 | (19 << 27) /* 0.307008208 */, - /* 8037 */ 0x04e9b6da | (19 << 27) /* 0.307059148 */, - /* 8038 */ 0x04e9ec45 | (19 << 27) /* 0.307110090 */, - /* 8039 */ 0x04ea21b0 | (19 << 27) /* 0.307161034 */, - /* 8040 */ 0x04ea571c | (19 << 27) /* 0.307211980 */, - /* 8041 */ 0x04ea8c88 | (19 << 27) /* 0.307262928 */, - /* 8042 */ 0x04eac1f5 | (19 << 27) /* 0.307313879 */, - /* 8043 */ 0x04eaf762 | (19 << 27) /* 0.307364831 */, - /* 8044 */ 0x04eb2cd0 | (19 << 27) /* 0.307415786 */, - /* 8045 */ 0x04eb623f | (19 << 27) /* 0.307466743 */, - /* 8046 */ 0x04eb97ae | (19 << 27) /* 0.307517702 */, - /* 8047 */ 0x04ebcd1e | (19 << 27) /* 0.307568663 */, - - /* 8048 */ 0x04ec028e | (19 << 27) /* 0.307619626 */, - /* 8049 */ 0x04ec37ff | (19 << 27) /* 0.307670591 */, - /* 8050 */ 0x04ec6d71 | (19 << 27) /* 0.307721558 */, - /* 8051 */ 0x04eca2e3 | (19 << 27) /* 0.307772528 */, - /* 8052 */ 0x04ecd855 | (19 << 27) /* 0.307823499 */, - /* 8053 */ 0x04ed0dc8 | (19 << 27) /* 0.307874473 */, - /* 8054 */ 0x04ed433c | (19 << 27) /* 0.307925449 */, - /* 8055 */ 0x04ed78b0 | (19 << 27) /* 0.307976426 */, - /* 8056 */ 0x04edae25 | (19 << 27) /* 0.308027406 */, - /* 8057 */ 0x04ede39a | (19 << 27) /* 0.308078389 */, - /* 8058 */ 0x04ee1910 | (19 << 27) /* 0.308129373 */, - /* 8059 */ 0x04ee4e87 | (19 << 27) /* 0.308180359 */, - /* 8060 */ 0x04ee83fe | (19 << 27) /* 0.308231347 */, - /* 8061 */ 0x04eeb976 | (19 << 27) /* 0.308282338 */, - /* 8062 */ 0x04eeeeee | (19 << 27) /* 0.308333331 */, - /* 8063 */ 0x04ef2467 | (19 << 27) /* 0.308384325 */, - - /* 8064 */ 0x04ef59e0 | (19 << 27) /* 0.308435322 */, - /* 8065 */ 0x04ef8f5a | (19 << 27) /* 0.308486321 */, - /* 8066 */ 0x04efc4d5 | (19 << 27) /* 0.308537322 */, - /* 8067 */ 0x04effa50 | (19 << 27) /* 0.308588325 */, - /* 8068 */ 0x04f02fcb | (19 << 27) /* 0.308639331 */, - /* 8069 */ 0x04f06547 | (19 << 27) /* 0.308690338 */, - /* 8070 */ 0x04f09ac4 | (19 << 27) /* 0.308741348 */, - /* 8071 */ 0x04f0d041 | (19 << 27) /* 0.308792359 */, - /* 8072 */ 0x04f105bf | (19 << 27) /* 0.308843373 */, - /* 8073 */ 0x04f13b3e | (19 << 27) /* 0.308894389 */, - /* 8074 */ 0x04f170bd | (19 << 27) /* 0.308945407 */, - /* 8075 */ 0x04f1a63c | (19 << 27) /* 0.308996427 */, - /* 8076 */ 0x04f1dbbd | (19 << 27) /* 0.309047449 */, - /* 8077 */ 0x04f2113d | (19 << 27) /* 0.309098473 */, - /* 8078 */ 0x04f246bf | (19 << 27) /* 0.309149499 */, - /* 8079 */ 0x04f27c40 | (19 << 27) /* 0.309200528 */, - - /* 8080 */ 0x04f2b1c3 | (19 << 27) /* 0.309251558 */, - /* 8081 */ 0x04f2e746 | (19 << 27) /* 0.309302591 */, - /* 8082 */ 0x04f31cc9 | (19 << 27) /* 0.309353626 */, - /* 8083 */ 0x04f3524d | (19 << 27) /* 0.309404663 */, - /* 8084 */ 0x04f387d2 | (19 << 27) /* 0.309455702 */, - /* 8085 */ 0x04f3bd57 | (19 << 27) /* 0.309506743 */, - /* 8086 */ 0x04f3f2dd | (19 << 27) /* 0.309557786 */, - /* 8087 */ 0x04f42864 | (19 << 27) /* 0.309608831 */, - /* 8088 */ 0x04f45dea | (19 << 27) /* 0.309659879 */, - /* 8089 */ 0x04f49372 | (19 << 27) /* 0.309710928 */, - /* 8090 */ 0x04f4c8fa | (19 << 27) /* 0.309761980 */, - /* 8091 */ 0x04f4fe83 | (19 << 27) /* 0.309813033 */, - /* 8092 */ 0x04f5340c | (19 << 27) /* 0.309864089 */, - /* 8093 */ 0x04f56996 | (19 << 27) /* 0.309915147 */, - /* 8094 */ 0x04f59f20 | (19 << 27) /* 0.309966207 */, - /* 8095 */ 0x04f5d4ab | (19 << 27) /* 0.310017269 */, - - /* 8096 */ 0x04f60a36 | (19 << 27) /* 0.310068333 */, - /* 8097 */ 0x04f63fc2 | (19 << 27) /* 0.310119400 */, - /* 8098 */ 0x04f6754f | (19 << 27) /* 0.310170468 */, - /* 8099 */ 0x04f6aadc | (19 << 27) /* 0.310221539 */, - /* 8100 */ 0x04f6e06a | (19 << 27) /* 0.310272611 */, - /* 8101 */ 0x04f715f8 | (19 << 27) /* 0.310323686 */, - /* 8102 */ 0x04f74b87 | (19 << 27) /* 0.310374763 */, - /* 8103 */ 0x04f78116 | (19 << 27) /* 0.310425842 */, - /* 8104 */ 0x04f7b6a6 | (19 << 27) /* 0.310476923 */, - /* 8105 */ 0x04f7ec37 | (19 << 27) /* 0.310528006 */, - /* 8106 */ 0x04f821c8 | (19 << 27) /* 0.310579091 */, - /* 8107 */ 0x04f85759 | (19 << 27) /* 0.310630179 */, - /* 8108 */ 0x04f88cec | (19 << 27) /* 0.310681268 */, - /* 8109 */ 0x04f8c27e | (19 << 27) /* 0.310732360 */, - /* 8110 */ 0x04f8f812 | (19 << 27) /* 0.310783453 */, - /* 8111 */ 0x04f92da6 | (19 << 27) /* 0.310834549 */, - - /* 8112 */ 0x04f9633a | (19 << 27) /* 0.310885647 */, - /* 8113 */ 0x04f998cf | (19 << 27) /* 0.310936747 */, - /* 8114 */ 0x04f9ce65 | (19 << 27) /* 0.310987849 */, - /* 8115 */ 0x04fa03fb | (19 << 27) /* 0.311038953 */, - /* 8116 */ 0x04fa3992 | (19 << 27) /* 0.311090059 */, - /* 8117 */ 0x04fa6f29 | (19 << 27) /* 0.311141168 */, - /* 8118 */ 0x04faa4c1 | (19 << 27) /* 0.311192278 */, - /* 8119 */ 0x04fada59 | (19 << 27) /* 0.311243390 */, - /* 8120 */ 0x04fb0ff2 | (19 << 27) /* 0.311294505 */, - /* 8121 */ 0x04fb458c | (19 << 27) /* 0.311345622 */, - /* 8122 */ 0x04fb7b26 | (19 << 27) /* 0.311396741 */, - /* 8123 */ 0x04fbb0c1 | (19 << 27) /* 0.311447862 */, - /* 8124 */ 0x04fbe65c | (19 << 27) /* 0.311498985 */, - /* 8125 */ 0x04fc1bf8 | (19 << 27) /* 0.311550110 */, - /* 8126 */ 0x04fc5194 | (19 << 27) /* 0.311601237 */, - /* 8127 */ 0x04fc8731 | (19 << 27) /* 0.311652366 */, - - /* 8128 */ 0x04fcbcce | (19 << 27) /* 0.311703498 */, - /* 8129 */ 0x04fcf26c | (19 << 27) /* 0.311754631 */, - /* 8130 */ 0x04fd280b | (19 << 27) /* 0.311805767 */, - /* 8131 */ 0x04fd5daa | (19 << 27) /* 0.311856905 */, - /* 8132 */ 0x04fd934a | (19 << 27) /* 0.311908044 */, - /* 8133 */ 0x04fdc8ea | (19 << 27) /* 0.311959186 */, - /* 8134 */ 0x04fdfe8b | (19 << 27) /* 0.312010330 */, - /* 8135 */ 0x04fe342c | (19 << 27) /* 0.312061476 */, - /* 8136 */ 0x04fe69ce | (19 << 27) /* 0.312112625 */, - /* 8137 */ 0x04fe9f71 | (19 << 27) /* 0.312163775 */, - /* 8138 */ 0x04fed514 | (19 << 27) /* 0.312214927 */, - /* 8139 */ 0x04ff0ab8 | (19 << 27) /* 0.312266082 */, - /* 8140 */ 0x04ff405c | (19 << 27) /* 0.312317238 */, - /* 8141 */ 0x04ff7601 | (19 << 27) /* 0.312368397 */, - /* 8142 */ 0x04ffaba6 | (19 << 27) /* 0.312419558 */, - /* 8143 */ 0x04ffe14c | (19 << 27) /* 0.312470720 */, - - /* 8144 */ 0x050016f3 | (19 << 27) /* 0.312521885 */, - /* 8145 */ 0x05004c9a | (19 << 27) /* 0.312573052 */, - /* 8146 */ 0x05008241 | (19 << 27) /* 0.312624222 */, - /* 8147 */ 0x0500b7e9 | (19 << 27) /* 0.312675393 */, - /* 8148 */ 0x0500ed92 | (19 << 27) /* 0.312726566 */, - /* 8149 */ 0x0501233b | (19 << 27) /* 0.312777742 */, - /* 8150 */ 0x050158e5 | (19 << 27) /* 0.312828919 */, - /* 8151 */ 0x05018e90 | (19 << 27) /* 0.312880099 */, - /* 8152 */ 0x0501c43b | (19 << 27) /* 0.312931280 */, - /* 8153 */ 0x0501f9e6 | (19 << 27) /* 0.312982464 */, - /* 8154 */ 0x05022f92 | (19 << 27) /* 0.313033650 */, - /* 8155 */ 0x0502653f | (19 << 27) /* 0.313084838 */, - /* 8156 */ 0x05029aec | (19 << 27) /* 0.313136028 */, - /* 8157 */ 0x0502d09a | (19 << 27) /* 0.313187220 */, - /* 8158 */ 0x05030648 | (19 << 27) /* 0.313238414 */, - /* 8159 */ 0x05033bf7 | (19 << 27) /* 0.313289611 */, - - /* 8160 */ 0x050371a7 | (19 << 27) /* 0.313340809 */, - /* 8161 */ 0x0503a757 | (19 << 27) /* 0.313392010 */, - /* 8162 */ 0x0503dd07 | (19 << 27) /* 0.313443212 */, - /* 8163 */ 0x050412b9 | (19 << 27) /* 0.313494417 */, - /* 8164 */ 0x0504486a | (19 << 27) /* 0.313545624 */, - /* 8165 */ 0x05047e1d | (19 << 27) /* 0.313596833 */, - /* 8166 */ 0x0504b3cf | (19 << 27) /* 0.313648044 */, - /* 8167 */ 0x0504e983 | (19 << 27) /* 0.313699257 */, - /* 8168 */ 0x05051f37 | (19 << 27) /* 0.313750472 */, - /* 8169 */ 0x050554eb | (19 << 27) /* 0.313801689 */, - /* 8170 */ 0x05058aa0 | (19 << 27) /* 0.313852909 */, - /* 8171 */ 0x0505c056 | (19 << 27) /* 0.313904130 */, - /* 8172 */ 0x0505f60c | (19 << 27) /* 0.313955354 */, - /* 8173 */ 0x05062bc3 | (19 << 27) /* 0.314006579 */, - /* 8174 */ 0x0506617a | (19 << 27) /* 0.314057807 */, - /* 8175 */ 0x05069732 | (19 << 27) /* 0.314109037 */, - - /* 8176 */ 0x0506cceb | (19 << 27) /* 0.314160269 */, - /* 8177 */ 0x050702a4 | (19 << 27) /* 0.314211502 */, - /* 8178 */ 0x0507385d | (19 << 27) /* 0.314262739 */, - /* 8179 */ 0x05076e17 | (19 << 27) /* 0.314313977 */, - /* 8180 */ 0x0507a3d2 | (19 << 27) /* 0.314365217 */, - /* 8181 */ 0x0507d98d | (19 << 27) /* 0.314416459 */, - /* 8182 */ 0x05080f49 | (19 << 27) /* 0.314467704 */, - /* 8183 */ 0x05084506 | (19 << 27) /* 0.314518950 */, - /* 8184 */ 0x05087ac2 | (19 << 27) /* 0.314570199 */, - /* 8185 */ 0x0508b080 | (19 << 27) /* 0.314621449 */, - /* 8186 */ 0x0508e63e | (19 << 27) /* 0.314672702 */, - /* 8187 */ 0x05091bfd | (19 << 27) /* 0.314723957 */, - /* 8188 */ 0x050951bc | (19 << 27) /* 0.314775214 */, - /* 8189 */ 0x0509877c | (19 << 27) /* 0.314826473 */, - /* 8190 */ 0x0509bd3c | (19 << 27) /* 0.314877734 */, - /* 8191 */ 0x0509f2fd | (19 << 27) /* 0.314928997 */, - - /* 8192 */ 0x050a28be | (19 << 27) /* 0.314980262 */, - /* 8193 */ 0x050a5e80 | (19 << 27) /* 0.315031530 */, - /* 8194 */ 0x050a9443 | (19 << 27) /* 0.315082799 */, - /* 8195 */ 0x050aca06 | (19 << 27) /* 0.315134071 */, - /* 8196 */ 0x050affc9 | (19 << 27) /* 0.315185344 */, - /* 8197 */ 0x050b358e | (19 << 27) /* 0.315236620 */, - /* 8198 */ 0x050b6b52 | (19 << 27) /* 0.315287898 */, - /* 8199 */ 0x050ba118 | (19 << 27) /* 0.315339178 */, - /* 8200 */ 0x050bd6de | (19 << 27) /* 0.315390460 */, - /* 8201 */ 0x050c0ca4 | (19 << 27) /* 0.315441744 */, - /* 8202 */ 0x050c426b | (19 << 27) /* 0.315493030 */, - /* 8203 */ 0x050c7833 | (19 << 27) /* 0.315544318 */, - /* 8204 */ 0x050cadfb | (19 << 27) /* 0.315595608 */, - /* 8205 */ 0x050ce3c4 | (19 << 27) /* 0.315646901 */, - /* 8206 */ 0x050d198d | (19 << 27) /* 0.315698195 */, diff --git a/apps/codecs/libmad/sf_table.dat b/apps/codecs/libmad/sf_table.dat deleted file mode 100644 index de084d97da..0000000000 --- a/apps/codecs/libmad/sf_table.dat +++ /dev/null @@ -1,106 +0,0 @@ -/* - * libmad - MPEG audio decoder library - * Copyright (C) 2000-2004 Underbit Technologies, Inc. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * $Id$ - */ - -/* - * These are the scalefactor values for Layer I and Layer II. - * The values are from Table B.1 of ISO/IEC 11172-3. - * - * There is some error introduced by the 32-bit fixed-point representation; - * the amount of error is shown. For 16-bit PCM output, this shouldn't be - * too much of a problem. - * - * Strictly speaking, Table B.1 has only 63 entries (0-62), thus a strict - * interpretation of ISO/IEC 11172-3 would suggest that a scalefactor index of - * 63 is invalid. However, for better compatibility with current practices, we - * add a 64th entry. - */ - - MAD_F(0x20000000), /* 2.000000000000 => 2.000000000000, e 0.000000000000 */ - MAD_F(0x1965fea5), /* 1.587401051968 => 1.587401051074, e 0.000000000894 */ - MAD_F(0x1428a2fa), /* 1.259921049895 => 1.259921051562, e -0.000000001667 */ - MAD_F(0x10000000), /* 1.000000000000 => 1.000000000000, e 0.000000000000 */ - MAD_F(0x0cb2ff53), /* 0.793700525984 => 0.793700527400, e -0.000000001416 */ - MAD_F(0x0a14517d), /* 0.629960524947 => 0.629960525781, e -0.000000000833 */ - MAD_F(0x08000000), /* 0.500000000000 => 0.500000000000, e 0.000000000000 */ - MAD_F(0x06597fa9), /* 0.396850262992 => 0.396850261837, e 0.000000001155 */ - - MAD_F(0x050a28be), /* 0.314980262474 => 0.314980261028, e 0.000000001446 */ - MAD_F(0x04000000), /* 0.250000000000 => 0.250000000000, e 0.000000000000 */ - MAD_F(0x032cbfd5), /* 0.198425131496 => 0.198425132781, e -0.000000001285 */ - MAD_F(0x0285145f), /* 0.157490131237 => 0.157490130514, e 0.000000000723 */ - MAD_F(0x02000000), /* 0.125000000000 => 0.125000000000, e 0.000000000000 */ - MAD_F(0x01965fea), /* 0.099212565748 => 0.099212564528, e 0.000000001220 */ - MAD_F(0x01428a30), /* 0.078745065618 => 0.078745067120, e -0.000000001501 */ - MAD_F(0x01000000), /* 0.062500000000 => 0.062500000000, e 0.000000000000 */ - - MAD_F(0x00cb2ff5), /* 0.049606282874 => 0.049606282264, e 0.000000000610 */ - MAD_F(0x00a14518), /* 0.039372532809 => 0.039372533560, e -0.000000000751 */ - MAD_F(0x00800000), /* 0.031250000000 => 0.031250000000, e 0.000000000000 */ - MAD_F(0x006597fb), /* 0.024803141437 => 0.024803142995, e -0.000000001558 */ - MAD_F(0x0050a28c), /* 0.019686266405 => 0.019686266780, e -0.000000000375 */ - MAD_F(0x00400000), /* 0.015625000000 => 0.015625000000, e 0.000000000000 */ - MAD_F(0x0032cbfd), /* 0.012401570719 => 0.012401569635, e 0.000000001084 */ - MAD_F(0x00285146), /* 0.009843133202 => 0.009843133390, e -0.000000000188 */ - - MAD_F(0x00200000), /* 0.007812500000 => 0.007812500000, e 0.000000000000 */ - MAD_F(0x001965ff), /* 0.006200785359 => 0.006200786680, e -0.000000001321 */ - MAD_F(0x001428a3), /* 0.004921566601 => 0.004921566695, e -0.000000000094 */ - MAD_F(0x00100000), /* 0.003906250000 => 0.003906250000, e 0.000000000000 */ - MAD_F(0x000cb2ff), /* 0.003100392680 => 0.003100391477, e 0.000000001202 */ - MAD_F(0x000a1451), /* 0.002460783301 => 0.002460781485, e 0.000000001816 */ - MAD_F(0x00080000), /* 0.001953125000 => 0.001953125000, e 0.000000000000 */ - MAD_F(0x00065980), /* 0.001550196340 => 0.001550197601, e -0.000000001262 */ - - MAD_F(0x00050a29), /* 0.001230391650 => 0.001230392605, e -0.000000000955 */ - MAD_F(0x00040000), /* 0.000976562500 => 0.000976562500, e 0.000000000000 */ - MAD_F(0x00032cc0), /* 0.000775098170 => 0.000775098801, e -0.000000000631 */ - MAD_F(0x00028514), /* 0.000615195825 => 0.000615194440, e 0.000000001385 */ - MAD_F(0x00020000), /* 0.000488281250 => 0.000488281250, e 0.000000000000 */ - MAD_F(0x00019660), /* 0.000387549085 => 0.000387549400, e -0.000000000315 */ - MAD_F(0x0001428a), /* 0.000307597913 => 0.000307597220, e 0.000000000693 */ - MAD_F(0x00010000), /* 0.000244140625 => 0.000244140625, e 0.000000000000 */ - - MAD_F(0x0000cb30), /* 0.000193774542 => 0.000193774700, e -0.000000000158 */ - MAD_F(0x0000a145), /* 0.000153798956 => 0.000153798610, e 0.000000000346 */ - MAD_F(0x00008000), /* 0.000122070313 => 0.000122070313, e 0.000000000000 */ - MAD_F(0x00006598), /* 0.000096887271 => 0.000096887350, e -0.000000000079 */ - MAD_F(0x000050a3), /* 0.000076899478 => 0.000076901168, e -0.000000001689 */ - MAD_F(0x00004000), /* 0.000061035156 => 0.000061035156, e 0.000000000000 */ - MAD_F(0x000032cc), /* 0.000048443636 => 0.000048443675, e -0.000000000039 */ - MAD_F(0x00002851), /* 0.000038449739 => 0.000038448721, e 0.000000001018 */ - - MAD_F(0x00002000), /* 0.000030517578 => 0.000030517578, e 0.000000000000 */ - MAD_F(0x00001966), /* 0.000024221818 => 0.000024221838, e -0.000000000020 */ - MAD_F(0x00001429), /* 0.000019224870 => 0.000019226223, e -0.000000001354 */ - MAD_F(0x00001000), /* 0.000015258789 => 0.000015258789, e -0.000000000000 */ - MAD_F(0x00000cb3), /* 0.000012110909 => 0.000012110919, e -0.000000000010 */ - MAD_F(0x00000a14), /* 0.000009612435 => 0.000009611249, e 0.000000001186 */ - MAD_F(0x00000800), /* 0.000007629395 => 0.000007629395, e -0.000000000000 */ - MAD_F(0x00000659), /* 0.000006055454 => 0.000006053597, e 0.000000001858 */ - - MAD_F(0x0000050a), /* 0.000004806217 => 0.000004805624, e 0.000000000593 */ - MAD_F(0x00000400), /* 0.000003814697 => 0.000003814697, e 0.000000000000 */ - MAD_F(0x0000032d), /* 0.000003027727 => 0.000003028661, e -0.000000000934 */ - MAD_F(0x00000285), /* 0.000002403109 => 0.000002402812, e 0.000000000296 */ - MAD_F(0x00000200), /* 0.000001907349 => 0.000001907349, e -0.000000000000 */ - MAD_F(0x00000196), /* 0.000001513864 => 0.000001512468, e 0.000000001396 */ - MAD_F(0x00000143), /* 0.000001201554 => 0.000001203269, e -0.000000001714 */ - MAD_F(0x00000000) /* this compatibility entry is not part of Table B.1 */ diff --git a/apps/codecs/libmad/stream.c b/apps/codecs/libmad/stream.c deleted file mode 100644 index 2958afc118..0000000000 --- a/apps/codecs/libmad/stream.c +++ /dev/null @@ -1,165 +0,0 @@ -/* - * libmad - MPEG audio decoder library - * Copyright (C) 2000-2004 Underbit Technologies, Inc. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * $Id$ - */ - -# ifdef HAVE_CONFIG_H -# include "config.h" -# endif - -# include "global.h" - -# include "bit.h" -# include "stream.h" - -/* - * NAME: stream->init() - * DESCRIPTION: initialize stream struct - */ -void mad_stream_init(struct mad_stream *stream) -{ - stream->buffer = 0; - stream->bufend = 0; - /* rockbox: not used - stream->skiplen = 0; */ - - stream->sync = 0; - stream->freerate = 0; - - stream->this_frame = 0; - stream->next_frame = 0; - mad_bit_init(&stream->ptr, 0); - - mad_bit_init(&stream->anc_ptr, 0); - stream->anc_bitlen = 0; - -/* rockbox: comment this to avoid allocation in following code. main_data is - * linked to an array in rockbox' apps/codecs/mpa.c before calling this. - stream->main_data = 0; -*/ - stream->md_len = 0; - - stream->options = 0; - stream->error = MAD_ERROR_NONE; -} - -/* - * NAME: stream->finish() - * DESCRIPTION: deallocate any dynamic memory associated with stream - */ -/* rockbox: not used -void mad_stream_finish(struct mad_stream *stream) -{ - if (stream->main_data) { - free(stream->main_data); - stream->main_data = 0; - } - - mad_bit_finish(&stream->anc_ptr); - mad_bit_finish(&stream->ptr); -} */ - -/* - * NAME: stream->buffer() - * DESCRIPTION: set stream buffer pointers - */ -void mad_stream_buffer(struct mad_stream *stream, - unsigned char const *buffer, unsigned long length) -{ - stream->buffer = buffer; - stream->bufend = buffer + length; - - stream->this_frame = buffer; - stream->next_frame = buffer; - - stream->sync = 1; - - mad_bit_init(&stream->ptr, buffer); -} - -/* - * NAME: stream->skip() - * DESCRIPTION: arrange to skip bytes before the next frame - */ -/* rockbox: not used -void mad_stream_skip(struct mad_stream *stream, unsigned long length) -{ - stream->skiplen += length; -} */ - -/* - * NAME: stream->sync() - * DESCRIPTION: locate the next stream sync word - */ -int mad_stream_sync(struct mad_stream *stream) -{ - register unsigned char const *ptr, *end; - - ptr = mad_bit_nextbyte(&stream->ptr); - end = stream->bufend; - - while (ptr < end - 1 && - !(ptr[0] == 0xff && (ptr[1] & 0xe0) == 0xe0)) - ++ptr; - - if (end - ptr < MAD_BUFFER_GUARD) - return -1; - - mad_bit_init(&stream->ptr, ptr); - - return 0; -} - -/* - * NAME: stream->errorstr() - * DESCRIPTION: return a string description of the current error condition - */ -char const *mad_stream_errorstr(struct mad_stream const *stream) -{ - switch (stream->error) { - case MAD_ERROR_NONE: return "no error"; - - case MAD_ERROR_BUFLEN: return "input buffer too small (or EOF)"; - case MAD_ERROR_BUFPTR: return "invalid (null) buffer pointer"; - - case MAD_ERROR_NOMEM: return "not enough memory"; - - case MAD_ERROR_LOSTSYNC: return "lost synchronization"; - case MAD_ERROR_BADLAYER: return "reserved header layer value"; - case MAD_ERROR_BADBITRATE: return "forbidden bitrate value"; - case MAD_ERROR_BADSAMPLERATE: return "reserved sample frequency value"; - case MAD_ERROR_BADEMPHASIS: return "reserved emphasis value"; - - case MAD_ERROR_BADCRC: return "CRC check failed"; - case MAD_ERROR_BADBITALLOC: return "forbidden bit allocation value"; - case MAD_ERROR_BADSCALEFACTOR: return "bad scalefactor index"; - case MAD_ERROR_BADMODE: return "bad bitrate/mode combination"; - case MAD_ERROR_BADFRAMELEN: return "bad frame length"; - case MAD_ERROR_BADBIGVALUES: return "bad big_values count"; - case MAD_ERROR_BADBLOCKTYPE: return "reserved block_type"; - case MAD_ERROR_BADSCFSI: return "bad scalefactor selection info"; - case MAD_ERROR_BADDATAPTR: return "bad main_data_begin pointer"; - case MAD_ERROR_BADPART3LEN: return "bad audio data length"; - case MAD_ERROR_BADHUFFTABLE: return "bad Huffman table select"; - case MAD_ERROR_BADHUFFDATA: return "Huffman data overrun"; - case MAD_ERROR_BADSTEREO: return "incompatible block_type for JS"; - } - - return 0; -} diff --git a/apps/codecs/libmad/stream.h b/apps/codecs/libmad/stream.h deleted file mode 100644 index 0aafb98787..0000000000 --- a/apps/codecs/libmad/stream.h +++ /dev/null @@ -1,113 +0,0 @@ -/* - * libmad - MPEG audio decoder library - * Copyright (C) 2000-2004 Underbit Technologies, Inc. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * $Id$ - */ - -# ifndef LIBMAD_STREAM_H -# define LIBMAD_STREAM_H - -# include "bit.h" - -# define MAD_BUFFER_GUARD 8 -# define MAD_BUFFER_MDLEN (511 + 2048 + MAD_BUFFER_GUARD) - -enum mad_error { - MAD_ERROR_NONE = 0x0000, /* no error */ - - MAD_ERROR_BUFLEN = 0x0001, /* input buffer too small (or EOF) */ - MAD_ERROR_BUFPTR = 0x0002, /* invalid (null) buffer pointer */ - - MAD_ERROR_NOMEM = 0x0031, /* not enough memory */ - - MAD_ERROR_LOSTSYNC = 0x0101, /* lost synchronization */ - MAD_ERROR_BADLAYER = 0x0102, /* reserved header layer value */ - MAD_ERROR_BADBITRATE = 0x0103, /* forbidden bitrate value */ - MAD_ERROR_BADSAMPLERATE = 0x0104, /* reserved sample frequency value */ - MAD_ERROR_BADEMPHASIS = 0x0105, /* reserved emphasis value */ - - MAD_ERROR_BADCRC = 0x0201, /* CRC check failed */ - MAD_ERROR_BADBITALLOC = 0x0211, /* forbidden bit allocation value */ - MAD_ERROR_BADSCALEFACTOR = 0x0221, /* bad scalefactor index */ - MAD_ERROR_BADMODE = 0x0222, /* bad bitrate/mode combination */ - MAD_ERROR_BADFRAMELEN = 0x0231, /* bad frame length */ - MAD_ERROR_BADBIGVALUES = 0x0232, /* bad big_values count */ - MAD_ERROR_BADBLOCKTYPE = 0x0233, /* reserved block_type */ - MAD_ERROR_BADSCFSI = 0x0234, /* bad scalefactor selection info */ - MAD_ERROR_BADDATAPTR = 0x0235, /* bad main_data_begin pointer */ - MAD_ERROR_BADPART3LEN = 0x0236, /* bad audio data length */ - MAD_ERROR_BADHUFFTABLE = 0x0237, /* bad Huffman table select */ - MAD_ERROR_BADHUFFDATA = 0x0238, /* Huffman data overrun */ - MAD_ERROR_BADSTEREO = 0x0239 /* incompatible block_type for JS */ -}; - -# define MAD_RECOVERABLE(error) ((error) & 0xff00) - -struct mad_stream { - unsigned char const *buffer; /* input bitstream buffer */ - unsigned char const *bufend; /* end of buffer */ - /* rockbox: not used - unsigned long skiplen; */ /* bytes to skip before next frame */ - - int sync; /* stream sync found */ - unsigned long freerate; /* free bitrate (fixed) */ - - unsigned char const *this_frame; /* start of current frame */ - unsigned char const *next_frame; /* start of next frame */ - struct mad_bitptr ptr; /* current processing bit pointer */ - - struct mad_bitptr anc_ptr; /* ancillary bits pointer */ - unsigned int anc_bitlen; /* number of ancillary bits */ - - unsigned char (*main_data)[MAD_BUFFER_MDLEN] MEM_ALIGN_ATTR; - /* Layer III main_data() */ - unsigned int md_len; /* bytes in main_data */ - - int options; /* decoding options (see below) */ - enum mad_error error; /* error code (see above) */ -}; - -enum { - MAD_OPTION_IGNORECRC = 0x0001, /* ignore CRC errors */ -# if 0 /* rockbox: unused */ - MAD_OPTION_HALFSAMPLERATE = 0x0002 /* generate PCM at 1/2 sample rate */ -# endif -# if 0 /* not yet implemented */ - MAD_OPTION_LEFTCHANNEL = 0x0010, /* decode left channel only */ - MAD_OPTION_RIGHTCHANNEL = 0x0020, /* decode right channel only */ - MAD_OPTION_SINGLECHANNEL = 0x0030 /* combine channels */ -# endif -}; - -void mad_stream_init(struct mad_stream *); -/* rockbox: not used -void mad_stream_finish(struct mad_stream *); */ - -# define mad_stream_options(stream, opts) \ - ((void) ((stream)->options = (opts))) - -void mad_stream_buffer(struct mad_stream *, - unsigned char const *, unsigned long); -/* rockbox: not used -void mad_stream_skip(struct mad_stream *, unsigned long); */ - -int mad_stream_sync(struct mad_stream *); - -char const *mad_stream_errorstr(struct mad_stream const *); - -# endif diff --git a/apps/codecs/libmad/synth.c b/apps/codecs/libmad/synth.c deleted file mode 100644 index ebcf3d5015..0000000000 --- a/apps/codecs/libmad/synth.c +++ /dev/null @@ -1,1232 +0,0 @@ -/* - * libmad - MPEG audio decoder library - * Copyright (C) 2000-2004 Underbit Technologies, Inc. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * $Id$ - */ - -# ifdef HAVE_CONFIG_H -# include "config.h" -# endif - -# include "global.h" - -# include "fixed.h" -# include "frame.h" -# include "synth.h" - -/* - * NAME: synth->init() - * DESCRIPTION: initialize synth struct - */ -void mad_synth_init(struct mad_synth *synth) -{ - mad_synth_mute(synth); - - synth->phase = 0; - - synth->pcm.samplerate = 0; - synth->pcm.channels = 0; - synth->pcm.length = 0; - #if defined(CPU_COLDFIRE) - /* init the emac unit here, since this function should always be called - before using libmad */ - coldfire_set_macsr(EMAC_FRACTIONAL | EMAC_SATURATE | EMAC_ROUND); - #endif -} - -/* - * NAME: synth->mute() - * DESCRIPTION: zero all polyphase filterbank values, resetting synthesis - */ -void mad_synth_mute(struct mad_synth *synth) -{ - memset(synth->filter, 0, sizeof(synth->filter)); -} - -#if 0 /* dct32 asm implementation is slower on current arm systems */ -/* #ifdef FPM_ARM */ - -void dct32(mad_fixed_t const in[32], unsigned int slot, - mad_fixed_t lo[16][8], mad_fixed_t hi[16][8]); - -#else - -/* - * An optional optimization called here the Subband Synthesis Optimization - * (SSO) improves the performance of subband synthesis at the expense of - * accuracy. - * - * The idea is to simplify 32x32->64-bit multiplication to 32x32->32 such - * that extra scaling and rounding are not necessary. This often allows the - * compiler to use faster 32-bit multiply-accumulate instructions instead of - * explicit 64-bit multiply, shift, and add instructions. - * - * SSO works like this: a full 32x32->64-bit multiply of two mad_fixed_t - * values requires the result to be right-shifted 28 bits to be properly - * scaled to the same fixed-point format. Right shifts can be applied at any - * time to either operand or to the result, so the optimization involves - * careful placement of these shifts to minimize the loss of accuracy. - * - * First, a 14-bit shift is applied with rounding at compile-time to the D[] - * table of coefficients for the subband synthesis window. This only loses 2 - * bits of accuracy because the lower 12 bits are always zero. A second - * 12-bit shift occurs after the DCT calculation. This loses 12 bits of - * accuracy. Finally, a third 2-bit shift occurs just before the sample is - * saved in the PCM buffer. 14 + 12 + 2 == 28 bits. - */ - -/* FPM_DEFAULT without OPT_SSO will actually not work. */ -# if defined(FPM_DEFAULT) && !defined(OPT_SSO) -# define OPT_SSO -# endif - -/* second SSO shift, with rounding */ -# if defined(OPT_SSO) -# define SHIFT(x) (((x) + (1L << 11)) >> 12) -# else -# define SHIFT(x) (x) -# endif - -/* possible DCT speed optimization */ -# if defined(FPM_COLDFIRE_EMAC) -/* This is a Coldfire version of the OPT_SPEED optimisation below, but in the - case of Coldfire it does not loose additional precision. */ -# define MUL(x, y) \ - ({ \ - mad_fixed64hi_t hi; \ - asm volatile("mac.l %[a], %[b], %%acc0\n\t" \ - "movclr.l %%acc0, %[hi]" \ - : [hi] "=r" (hi) \ - : [a] "r" ((x)), [b] "r" ((y))); \ - hi; \ - }) -# elif defined(FPM_ARM) -/* This is an ARM version of the OPT_SPEED optimisation below. This - implementation will loose 1 bit of accuracy. */ -# define MUL(x, y) \ - ({ \ - mad_fixed64lo_t lo; \ - mad_fixed64hi_t hi; \ - asm volatile ( \ - "smull %[lo], %[hi], %[a], %[b]\n\t" /* hi = result */ \ - "mov %[hi], %[hi], lsl #1" /* hi <<= 1 */ \ - : [lo]"=&r"(lo), [hi]"=&r"(hi) \ - : [a]"r"(x), [b]"r"(y)); \ - hi; \ - }) -# elif defined(OPT_SPEED) && defined(MAD_F_MLX) -# define MUL(x, y) \ - ({ mad_fixed64hi_t hi; \ - mad_fixed64lo_t lo; \ - MAD_F_MLX(hi, lo, (x), (y)); \ - hi << (32 - MAD_F_SCALEBITS - 3); \ - }) -# else -# define MUL(x, y) mad_f_mul((x), (y>>3)) -# endif - -/* - * NAME: dct32() - * DESCRIPTION: perform fast in[32]->out[32] DCT - */ -static -void dct32(mad_fixed_t const in[32], unsigned int slot, - mad_fixed_t lo[16][8], mad_fixed_t hi[16][8]) -{ - mad_fixed_t t0, t1, t2, t3, t4, t5, t6, t7; - mad_fixed_t t8, t9, t10, t11, t12, t13, t14, t15; - mad_fixed_t t16, t17, t18, t19, t20, t21, t22, t23; - mad_fixed_t t24, t25, t26, t27, t28, t29, t30, t31; - mad_fixed_t t32, t33, t34, t35, t36, t37, t38, t39; - mad_fixed_t t40, t41, t42, t43, t44, t45, t46, t47; - mad_fixed_t t48, t49, t50, t51, t52, t53, t54, t55; - mad_fixed_t t56, t57, t58, t59, t60, t61, t62, t63; - mad_fixed_t t64, t65, t66, t67, t68, t69, t70, t71; - mad_fixed_t t72, t73, t74, t75, t76, t77, t78, t79; - mad_fixed_t t80, t81, t82, t83, t84, t85, t86, t87; - mad_fixed_t t88, t89, t90, t91, t92, t93, t94, t95; - mad_fixed_t t96, t97, t98, t99, t100, t101, t102, t103; - mad_fixed_t t104, t105, t106, t107, t108, t109, t110, t111; - mad_fixed_t t112, t113, t114, t115, t116, t117, t118, t119; - mad_fixed_t t120, t121, t122, t123, t124, t125, t126, t127; - mad_fixed_t t128, t129, t130, t131, t132, t133, t134, t135; - mad_fixed_t t136, t137, t138, t139, t140, t141, t142, t143; - mad_fixed_t t144, t145, t146, t147, t148, t149, t150, t151; - mad_fixed_t t152, t153, t154, t155, t156, t157, t158, t159; - mad_fixed_t t160, t161, t162, t163, t164, t165, t166, t167; - mad_fixed_t t168, t169, t170, t171, t172, t173, t174, t175; - mad_fixed_t t176; - - /* costab[i] = cos(PI / (2 * 32) * i) */ -#define costab1 MAD_F(0x7fd8878e) /* 0.998795456 */ -#define costab2 MAD_F(0x7f62368f) /* 0.995184727 */ -#define costab3 MAD_F(0x7e9d55fc) /* 0.989176510 */ -#define costab4 MAD_F(0x7d8a5f40) /* 0.980785280 */ -#define costab5 MAD_F(0x7c29fbee) /* 0.970031253 */ -#define costab6 MAD_F(0x7a7d055b) /* 0.956940336 */ -#define costab7 MAD_F(0x78848414) /* 0.941544065 */ -#define costab8 MAD_F(0x7641af3d) /* 0.923879533 */ -#define costab9 MAD_F(0x73b5ebd1) /* 0.903989293 */ -#define costab10 MAD_F(0x70e2cbc6) /* 0.881921264 */ -#define costab11 MAD_F(0x6dca0d14) /* 0.857728610 */ -#define costab12 MAD_F(0x6a5d98a4) /* 0.831469612 */ -#define costab13 MAD_F(0x66cf8120) /* 0.803207531 */ -#define costab14 MAD_F(0x62f201ac) /* 0.773010453 */ -#define costab15 MAD_F(0x5ed77c8a) /* 0.740951125 */ -#define costab16 MAD_F(0x5a82799a) /* 0.707106781 */ -#define costab17 MAD_F(0x55f5a4d2) /* 0.671558955 */ -#define costab18 MAD_F(0x5133cc94) /* 0.634393284 */ -#define costab19 MAD_F(0x4c3fdff4) /* 0.595699304 */ -#define costab20 MAD_F(0x471cece7) /* 0.555570233 */ -#define costab21 MAD_F(0x41ce1e65) /* 0.514102744 */ -#define costab22 MAD_F(0x3c56ba70) /* 0.471396737 */ -#define costab23 MAD_F(0x36ba2014) /* 0.427555093 */ -#define costab24 MAD_F(0x30fbc54d) /* 0.382683432 */ -#define costab25 MAD_F(0x2b1f34eb) /* 0.336889853 */ -#define costab26 MAD_F(0x25280c5e) /* 0.290284677 */ -#define costab27 MAD_F(0x1f19f97b) /* 0.242980180 */ -#define costab28 MAD_F(0x18f8b83c) /* 0.195090322 */ -#define costab29 MAD_F(0x12c8106f) /* 0.146730474 */ -#define costab30 MAD_F(0x0c8bd35e) /* 0.098017140 */ -#define costab31 MAD_F(0x0647d97c) /* 0.049067674 */ - - t0 = in[0] + in[31]; t16 = MUL(in[0] - in[31], costab1); - t1 = in[15] + in[16]; t17 = MUL(in[15] - in[16], costab31); - - t41 = t16 + t17; - t59 = MUL(t16 - t17, costab2); - t33 = t0 + t1; - t50 = MUL(t0 - t1, costab2); - - t2 = in[7] + in[24]; t18 = MUL(in[7] - in[24], costab15); - t3 = in[8] + in[23]; t19 = MUL(in[8] - in[23], costab17); - - t42 = t18 + t19; - t60 = MUL(t18 - t19, costab30); - t34 = t2 + t3; - t51 = MUL(t2 - t3, costab30); - - t4 = in[3] + in[28]; t20 = MUL(in[3] - in[28], costab7); - t5 = in[12] + in[19]; t21 = MUL(in[12] - in[19], costab25); - - t43 = t20 + t21; - t61 = MUL(t20 - t21, costab14); - t35 = t4 + t5; - t52 = MUL(t4 - t5, costab14); - - t6 = in[4] + in[27]; t22 = MUL(in[4] - in[27], costab9); - t7 = in[11] + in[20]; t23 = MUL(in[11] - in[20], costab23); - - t44 = t22 + t23; - t62 = MUL(t22 - t23, costab18); - t36 = t6 + t7; - t53 = MUL(t6 - t7, costab18); - - t8 = in[1] + in[30]; t24 = MUL(in[1] - in[30], costab3); - t9 = in[14] + in[17]; t25 = MUL(in[14] - in[17], costab29); - - t45 = t24 + t25; - t63 = MUL(t24 - t25, costab6); - t37 = t8 + t9; - t54 = MUL(t8 - t9, costab6); - - t10 = in[6] + in[25]; t26 = MUL(in[6] - in[25], costab13); - t11 = in[9] + in[22]; t27 = MUL(in[9] - in[22], costab19); - - t46 = t26 + t27; - t64 = MUL(t26 - t27, costab26); - t38 = t10 + t11; - t55 = MUL(t10 - t11, costab26); - - t12 = in[2] + in[29]; t28 = MUL(in[2] - in[29], costab5); - t13 = in[13] + in[18]; t29 = MUL(in[13] - in[18], costab27); - - t47 = t28 + t29; - t65 = MUL(t28 - t29, costab10); - t39 = t12 + t13; - t56 = MUL(t12 - t13, costab10); - - t14 = in[5] + in[26]; t30 = MUL(in[5] - in[26], costab11); - t15 = in[10] + in[21]; t31 = MUL(in[10] - in[21], costab21); - - t48 = t30 + t31; - t66 = MUL(t30 - t31, costab22); - t40 = t14 + t15; - t57 = MUL(t14 - t15, costab22); - - t69 = t33 + t34; t89 = MUL(t33 - t34, costab4); - t70 = t35 + t36; t90 = MUL(t35 - t36, costab28); - t71 = t37 + t38; t91 = MUL(t37 - t38, costab12); - t72 = t39 + t40; t92 = MUL(t39 - t40, costab20); - t73 = t41 + t42; t94 = MUL(t41 - t42, costab4); - t74 = t43 + t44; t95 = MUL(t43 - t44, costab28); - t75 = t45 + t46; t96 = MUL(t45 - t46, costab12); - t76 = t47 + t48; t97 = MUL(t47 - t48, costab20); - - t78 = t50 + t51; t100 = MUL(t50 - t51, costab4); - t79 = t52 + t53; t101 = MUL(t52 - t53, costab28); - t80 = t54 + t55; t102 = MUL(t54 - t55, costab12); - t81 = t56 + t57; t103 = MUL(t56 - t57, costab20); - - t83 = t59 + t60; t106 = MUL(t59 - t60, costab4); - t84 = t61 + t62; t107 = MUL(t61 - t62, costab28); - t85 = t63 + t64; t108 = MUL(t63 - t64, costab12); - t86 = t65 + t66; t109 = MUL(t65 - t66, costab20); - - t113 = t69 + t70; - t114 = t71 + t72; - - /* 0 */ hi[15][slot] = SHIFT(t113 + t114); - /* 16 */ lo[ 0][slot] = SHIFT(MUL(t113 - t114, costab16)); - - t115 = t73 + t74; - t116 = t75 + t76; - - t32 = t115 + t116; - - /* 1 */ hi[14][slot] = SHIFT(t32); - - t118 = t78 + t79; - t119 = t80 + t81; - - t58 = t118 + t119; - - /* 2 */ hi[13][slot] = SHIFT(t58); - - t121 = t83 + t84; - t122 = t85 + t86; - - t67 = t121 + t122; - - t49 = (t67 * 2) - t32; - - /* 3 */ hi[12][slot] = SHIFT(t49); - - t125 = t89 + t90; - t126 = t91 + t92; - - t93 = t125 + t126; - - /* 4 */ hi[11][slot] = SHIFT(t93); - - t128 = t94 + t95; - t129 = t96 + t97; - - t98 = t128 + t129; - - t68 = (t98 * 2) - t49; - - /* 5 */ hi[10][slot] = SHIFT(t68); - - t132 = t100 + t101; - t133 = t102 + t103; - - t104 = t132 + t133; - - t82 = (t104 * 2) - t58; - - /* 6 */ hi[ 9][slot] = SHIFT(t82); - - t136 = t106 + t107; - t137 = t108 + t109; - - t110 = t136 + t137; - - t87 = (t110 * 2) - t67; - - t77 = (t87 * 2) - t68; - - /* 7 */ hi[ 8][slot] = SHIFT(t77); - - t141 = MUL(t69 - t70, costab8); - t142 = MUL(t71 - t72, costab24); - t143 = t141 + t142; - - /* 8 */ hi[ 7][slot] = SHIFT(t143); - /* 24 */ lo[ 8][slot] = - SHIFT((MUL(t141 - t142, costab16) * 2) - t143); - - t144 = MUL(t73 - t74, costab8); - t145 = MUL(t75 - t76, costab24); - t146 = t144 + t145; - - t88 = (t146 * 2) - t77; - - /* 9 */ hi[ 6][slot] = SHIFT(t88); - - t148 = MUL(t78 - t79, costab8); - t149 = MUL(t80 - t81, costab24); - t150 = t148 + t149; - - t105 = (t150 * 2) - t82; - - /* 10 */ hi[ 5][slot] = SHIFT(t105); - - t152 = MUL(t83 - t84, costab8); - t153 = MUL(t85 - t86, costab24); - t154 = t152 + t153; - - t111 = (t154 * 2) - t87; - - t99 = (t111 * 2) - t88; - - /* 11 */ hi[ 4][slot] = SHIFT(t99); - - t157 = MUL(t89 - t90, costab8); - t158 = MUL(t91 - t92, costab24); - t159 = t157 + t158; - - t127 = (t159 * 2) - t93; - - /* 12 */ hi[ 3][slot] = SHIFT(t127); - - t160 = (MUL(t125 - t126, costab16) * 2) - t127; - - /* 20 */ lo[ 4][slot] = SHIFT(t160); - /* 28 */ lo[12][slot] = - SHIFT((((MUL(t157 - t158, costab16) * 2) - t159) * 2) - t160); - - t161 = MUL(t94 - t95, costab8); - t162 = MUL(t96 - t97, costab24); - t163 = t161 + t162; - - t130 = (t163 * 2) - t98; - - t112 = (t130 * 2) - t99; - - /* 13 */ hi[ 2][slot] = SHIFT(t112); - - t164 = (MUL(t128 - t129, costab16) * 2) - t130; - - t166 = MUL(t100 - t101, costab8); - t167 = MUL(t102 - t103, costab24); - t168 = t166 + t167; - - t134 = (t168 * 2) - t104; - - t120 = (t134 * 2) - t105; - - /* 14 */ hi[ 1][slot] = SHIFT(t120); - - t135 = (MUL(t118 - t119, costab16) * 2) - t120; - - /* 18 */ lo[ 2][slot] = SHIFT(t135); - - t169 = (MUL(t132 - t133, costab16) * 2) - t134; - - t151 = (t169 * 2) - t135; - - /* 22 */ lo[ 6][slot] = SHIFT(t151); - - t170 = (((MUL(t148 - t149, costab16) * 2) - t150) * 2) - t151; - - /* 26 */ lo[10][slot] = SHIFT(t170); - /* 30 */ lo[14][slot] = - SHIFT((((((MUL(t166 - t167, costab16) * 2) - - t168) * 2) - t169) * 2) - t170); - - t171 = MUL(t106 - t107, costab8); - t172 = MUL(t108 - t109, costab24); - t173 = t171 + t172; - - t138 = (t173 * 2) - t110; - - t123 = (t138 * 2) - t111; - - t139 = (MUL(t121 - t122, costab16) * 2) - t123; - - t117 = (t123 * 2) - t112; - - /* 15 */ hi[ 0][slot] = SHIFT(t117); - - t124 = (MUL(t115 - t116, costab16) * 2) - t117; - - /* 17 */ lo[ 1][slot] = SHIFT(t124); - - t131 = (t139 * 2) - t124; - - /* 19 */ lo[ 3][slot] = SHIFT(t131); - - t140 = (t164 * 2) - t131; - - /* 21 */ lo[ 5][slot] = SHIFT(t140); - - t174 = (MUL(t136 - t137, costab16) * 2) - t138; - - t155 = (t174 * 2) - t139; - - t147 = (t155 * 2) - t140; - - /* 23 */ lo[ 7][slot] = SHIFT(t147); - - t156 = (((MUL(t144 - t145, costab16) * 2) - t146) * 2) - t147; - - /* 25 */ lo[ 9][slot] = SHIFT(t156); - - t175 = (((MUL(t152 - t153, costab16) * 2) - t154) * 2) - t155; - - t165 = (t175 * 2) - t156; - - /* 27 */ lo[11][slot] = SHIFT(t165); - - t176 = (((((MUL(t161 - t162, costab16) * 2) - - t163) * 2) - t164) * 2) - t165; - - /* 29 */ lo[13][slot] = SHIFT(t176); - /* 31 */ lo[15][slot] = - SHIFT((((((((MUL(t171 - t172, costab16) * 2) - - t173) * 2) - t174) * 2) - t175) * 2) - t176); - - /* - * Totals: - * 80 multiplies - * 80 additions - * 119 subtractions - * 49 shifts (not counting SSO) - */ -} - -# undef MUL -# undef SHIFT - -#endif - -/* third SSO shift and/or D[] optimization preshift */ - -# if defined(OPT_SSO) -# if MAD_F_FRACBITS != 28 -# error "MAD_F_FRACBITS must be 28 to use OPT_SSO" -# endif -# define ML0(hi, lo, x, y) ((lo) = (x) * (y)) -# define MLA(hi, lo, x, y) ((lo) += (x) * (y)) -# define MLN(hi, lo) ((lo) = -(lo)) -# define MLZ(hi, lo) ((void) (hi), (mad_fixed_t) (lo)) -# define SHIFT(x) ((x) >> 2) -# define PRESHIFT(x) ((MAD_F(x) + (1L << 13)) >> 14) -# else -# define ML0(hi, lo, x, y) MAD_F_ML0((hi), (lo), (x), (y)) -# define MLA(hi, lo, x, y) MAD_F_MLA((hi), (lo), (x), (y)) -# define MLN(hi, lo) MAD_F_MLN((hi), (lo)) -# define MLZ(hi, lo) MAD_F_MLZ((hi), (lo)) -# define SHIFT(x) (x) -# if defined(MAD_F_SCALEBITS) -# undef MAD_F_SCALEBITS -# define MAD_F_SCALEBITS (MAD_F_FRACBITS - 12) -# define PRESHIFT(x) (MAD_F(x) >> 12) -# else -# define PRESHIFT(x) MAD_F(x) -# endif -# endif - -static -mad_fixed_t const D[17][32] ICONST_ATTR MEM_ALIGN_ATTR = { -# include "D.dat" -}; - -/* - * NAME: synth->full() - * DESCRIPTION: perform full frequency PCM synthesis - */ -/* optimised version of synth_full */ -# ifdef FPM_COLDFIRE_EMAC - -#define SYNTH_EMAC1(res, f1, pD) \ - asm volatile( \ - "movem.l (%0), %%d0-%%d7 \n\t" \ - "move.l (%1), %%a5 \n\t" \ - "mac.l %%d0, %%a5, 56(%1), %%a5, %%acc0\n\t" \ - "mac.l %%d1, %%a5, 48(%1), %%a5, %%acc0\n\t" \ - "mac.l %%d2, %%a5, 40(%1), %%a5, %%acc0\n\t" \ - "mac.l %%d3, %%a5, 32(%1), %%a5, %%acc0\n\t" \ - "mac.l %%d4, %%a5, 24(%1), %%a5, %%acc0\n\t" \ - "mac.l %%d5, %%a5, 16(%1), %%a5, %%acc0\n\t" \ - "mac.l %%d6, %%a5, 8(%1), %%a5, %%acc0\n\t" \ - "mac.l %%d7, %%a5, %%acc0\n\t" \ - : \ - : "a" (*f1), "a" (*pD) \ - : "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", "a5"); \ - asm volatile ( \ - "movclr.l %%acc0, %0 \n\t" \ - : "=d" (res)); - -#define SYNTH_EMAC2(res, f1, f2, pD) \ - asm volatile( \ - "movem.l (%0), %%d0-%%d7 \n\t" \ - "move.l 4(%1), %%a5 \n\t" \ - "msac.l %%d0, %%a5, 60(%1), %%a5, %%acc0\n\t" \ - "msac.l %%d1, %%a5, 52(%1), %%a5, %%acc0\n\t" \ - "msac.l %%d2, %%a5, 44(%1), %%a5, %%acc0\n\t" \ - "msac.l %%d3, %%a5, 36(%1), %%a5, %%acc0\n\t" \ - "msac.l %%d4, %%a5, 28(%1), %%a5, %%acc0\n\t" \ - "msac.l %%d5, %%a5, 20(%1), %%a5, %%acc0\n\t" \ - "msac.l %%d6, %%a5, 12(%1), %%a5, %%acc0\n\t" \ - "msac.l %%d7, %%a5, (%1), %%a5, %%acc0\n\t" \ - "movem.l (%2), %%d0-%%d7 \n\t" \ - "mac.l %%d0, %%a5, 56(%1), %%a5, %%acc0\n\t" \ - "mac.l %%d1, %%a5, 48(%1), %%a5, %%acc0\n\t" \ - "mac.l %%d2, %%a5, 40(%1), %%a5, %%acc0\n\t" \ - "mac.l %%d3, %%a5, 32(%1), %%a5, %%acc0\n\t" \ - "mac.l %%d4, %%a5, 24(%1), %%a5, %%acc0\n\t" \ - "mac.l %%d5, %%a5, 16(%1), %%a5, %%acc0\n\t" \ - "mac.l %%d6, %%a5, 8(%1), %%a5, %%acc0\n\t" \ - "mac.l %%d7, %%a5, %%acc0\n\t" \ - : \ - : "a" (*f1), "a" (*pD), "a" (*f2) \ - : "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", "a5", "memory"); \ - asm volatile ( \ - "movclr.l %%acc0, %0 \n\t" \ - : "=d" (res)); - -#define SYNTH_EMAC_ODD_SBSAMPLE(f1, f2, pD1, pD2, res1, res2) \ - asm volatile ( \ - "movem.l (%0), %%d0-%%d7 \n\t" \ - "move.l 4(%2), %%a5 \n\t" \ - "msac.l %%d0, %%a5, 60(%2), %%a5, %%acc0\n\t" \ - "msac.l %%d1, %%a5, 52(%2), %%a5, %%acc0\n\t" \ - "msac.l %%d2, %%a5, 44(%2), %%a5, %%acc0\n\t" \ - "msac.l %%d3, %%a5, 36(%2), %%a5, %%acc0\n\t" \ - "msac.l %%d4, %%a5, 28(%2), %%a5, %%acc0\n\t" \ - "msac.l %%d5, %%a5, 20(%2), %%a5, %%acc0\n\t" \ - "msac.l %%d6, %%a5, 12(%2), %%a5, %%acc0\n\t" \ - "msac.l %%d7, %%a5, 112(%3), %%a5, %%acc0\n\t" \ - "mac.l %%d7, %%a5, 104(%3), %%a5, %%acc1\n\t" \ - "mac.l %%d6, %%a5, 96(%3), %%a5, %%acc1\n\t" \ - "mac.l %%d5, %%a5, 88(%3), %%a5, %%acc1\n\t" \ - "mac.l %%d4, %%a5, 80(%3), %%a5, %%acc1\n\t" \ - "mac.l %%d3, %%a5, 72(%3), %%a5, %%acc1\n\t" \ - "mac.l %%d2, %%a5, 64(%3), %%a5, %%acc1\n\t" \ - "mac.l %%d1, %%a5, 120(%3), %%a5, %%acc1\n\t" \ - "mac.l %%d0, %%a5, 8(%2), %%a5, %%acc1\n\t" \ - "movem.l (%1), %%d0-%%d7 \n\t" \ - "mac.l %%d7, %%a5, 16(%2), %%a5, %%acc0\n\t" \ - "mac.l %%d6, %%a5, 24(%2), %%a5, %%acc0\n\t" \ - "mac.l %%d5, %%a5, 32(%2), %%a5, %%acc0\n\t" \ - "mac.l %%d4, %%a5, 40(%2), %%a5, %%acc0\n\t" \ - "mac.l %%d3, %%a5, 48(%2), %%a5, %%acc0\n\t" \ - "mac.l %%d2, %%a5, 56(%2), %%a5, %%acc0\n\t" \ - "mac.l %%d1, %%a5, (%2), %%a5, %%acc0\n\t" \ - "mac.l %%d0, %%a5, 60(%3), %%a5, %%acc0\n\t" \ - "mac.l %%d0, %%a5, 68(%3), %%a5, %%acc1\n\t" \ - "mac.l %%d1, %%a5, 76(%3), %%a5, %%acc1\n\t" \ - "mac.l %%d2, %%a5, 84(%3), %%a5, %%acc1\n\t" \ - "mac.l %%d3, %%a5, 92(%3), %%a5, %%acc1\n\t" \ - "mac.l %%d4, %%a5, 100(%3), %%a5, %%acc1\n\t" \ - "mac.l %%d5, %%a5, 108(%3), %%a5, %%acc1\n\t" \ - "mac.l %%d6, %%a5, 116(%3), %%a5, %%acc1\n\t" \ - "mac.l %%d7, %%a5, %%acc1\n\t" \ - : \ - : "a" (*f1), "a" (*f2), "a" (*pD1), "a" (*pD2) \ - : "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", "a5", "memory"); \ - asm volatile( \ - "movclr.l %%acc0, %0\n\t" \ - "movclr.l %%acc1, %1\n\t" \ - : "=d" (res1), "=d" (res2) ); - -#define SYNTH_EMAC_EVEN_SBSAMPLE(f1, f2, pD1, pD2, res1, res2) \ - asm volatile ( \ - "movem.l (%0), %%d0-%%d7 \n\t" \ - "move.l (%2), %%a5 \n\t" \ - "msac.l %%d0, %%a5, 56(%2), %%a5, %%acc0\n\t" \ - "msac.l %%d1, %%a5, 48(%2), %%a5, %%acc0\n\t" \ - "msac.l %%d2, %%a5, 40(%2), %%a5, %%acc0\n\t" \ - "msac.l %%d3, %%a5, 32(%2), %%a5, %%acc0\n\t" \ - "msac.l %%d4, %%a5, 24(%2), %%a5, %%acc0\n\t" \ - "msac.l %%d5, %%a5, 16(%2), %%a5, %%acc0\n\t" \ - "msac.l %%d6, %%a5, 8(%2), %%a5, %%acc0\n\t" \ - "msac.l %%d7, %%a5, 116(%3), %%a5, %%acc0\n\t" \ - "mac.l %%d7, %%a5, 108(%3), %%a5, %%acc1\n\t" \ - "mac.l %%d6, %%a5, 100(%3), %%a5, %%acc1\n\t" \ - "mac.l %%d5, %%a5, 92(%3), %%a5, %%acc1\n\t" \ - "mac.l %%d4, %%a5, 84(%3), %%a5, %%acc1\n\t" \ - "mac.l %%d3, %%a5, 76(%3), %%a5, %%acc1\n\t" \ - "mac.l %%d2, %%a5, 68(%3), %%a5, %%acc1\n\t" \ - "mac.l %%d1, %%a5, 60(%3), %%a5, %%acc1\n\t" \ - "mac.l %%d0, %%a5, 12(%2), %%a5, %%acc1\n\t" \ - "movem.l (%1), %%d0-%%d7 \n\t" \ - "mac.l %%d7, %%a5, 20(%2), %%a5, %%acc0\n\t" \ - "mac.l %%d6, %%a5, 28(%2), %%a5, %%acc0\n\t" \ - "mac.l %%d5, %%a5, 36(%2), %%a5, %%acc0\n\t" \ - "mac.l %%d4, %%a5, 44(%2), %%a5, %%acc0\n\t" \ - "mac.l %%d3, %%a5, 52(%2), %%a5, %%acc0\n\t" \ - "mac.l %%d2, %%a5, 60(%2), %%a5, %%acc0\n\t" \ - "mac.l %%d1, %%a5, 4(%2), %%a5, %%acc0\n\t" \ - "mac.l %%d0, %%a5, 120(%3), %%a5, %%acc0\n\t" \ - "mac.l %%d0, %%a5, 64(%3), %%a5, %%acc1\n\t" \ - "mac.l %%d1, %%a5, 72(%3), %%a5, %%acc1\n\t" \ - "mac.l %%d2, %%a5, 80(%3), %%a5, %%acc1\n\t" \ - "mac.l %%d3, %%a5, 88(%3), %%a5, %%acc1\n\t" \ - "mac.l %%d4, %%a5, 96(%3), %%a5, %%acc1\n\t" \ - "mac.l %%d5, %%a5, 104(%3), %%a5, %%acc1\n\t" \ - "mac.l %%d6, %%a5, 112(%3), %%a5, %%acc1\n\t" \ - "mac.l %%d7, %%a5, %%acc1\n\t" \ - : \ - : "a" (*f1), "a" (*f2), "a" (*pD1), "a" (*pD2) \ - : "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", "a5", "memory"); \ - asm volatile( \ - "movclr.l %%acc0, %0\n\t" \ - "movclr.l %%acc1, %1\n\t" \ - : "=d" (res1), "=d" (res2) ); - -static -void synth_full(struct mad_synth *synth, struct mad_frame const *frame, - unsigned int nch, unsigned int ns) -{ - int sb; - unsigned int phase, ch, s, p; - mad_fixed_t *pcm, (*filter)[2][2][16][8]; - mad_fixed_t (*sbsample)[36][32]; - mad_fixed_t (*fe)[8], (*fx)[8], (*fo)[8]; - mad_fixed_t const (*D0ptr)[32]; - mad_fixed_t const (*D1ptr)[32]; - mad_fixed64hi_t hi0, hi1; - - for (ch = 0; ch < nch; ++ch) { - sbsample = &(*frame->sbsample_prev)[ch]; - filter = &synth->filter[ch]; - phase = synth->phase; - pcm = synth->pcm.samples[ch]; - - for (s = 0; s < ns; ++s) { - dct32((*sbsample)[s], phase >> 1, - (*filter)[0][phase & 1], (*filter)[1][phase & 1]); - - p = (phase - 1) & 0xf; - - /* calculate 32 samples */ - fe = &(*filter)[0][ phase & 1][0]; - fx = &(*filter)[0][~phase & 1][0]; - fo = &(*filter)[1][~phase & 1][0]; - - D0ptr = (void*)&D[0][ p]; - D1ptr = (void*)&D[0][-p]; - - if(s & 1) - { - SYNTH_EMAC2(hi0, fx, fe, D0ptr); - pcm[0] = hi0 << 3; /* shift result to libmad's fixed point format */ - pcm += 16; - - for (sb = 15; sb; sb--, fo++) { - ++fe; - ++D0ptr; - ++D1ptr; - - /* D[32 - sb][i] == -D[sb][31 - i] */ - SYNTH_EMAC_ODD_SBSAMPLE(fo, fe, D0ptr, D1ptr, hi0, hi1); - pcm[-sb] = hi0 << 3; - pcm[ sb] = hi1 << 3; - } - - ++D0ptr; - SYNTH_EMAC1(hi0, fo, D0ptr+1); - pcm[0] = -(hi0 << 3); - } - else - { - SYNTH_EMAC2(hi0, fe, fx, D0ptr); - pcm[0] = -(hi0 << 3); /* shift result to libmad's fixed point format */ - pcm += 16; - - for (sb = 15; sb; sb--, fo++) { - ++fe; - ++D0ptr; - ++D1ptr; - - /* D[32 - sb][i] == -D[sb][31 - i] */ - SYNTH_EMAC_EVEN_SBSAMPLE(fo, fe, D0ptr, D1ptr, hi0, hi1); - pcm[-sb] = hi0 << 3; - pcm[ sb] = hi1 << 3; - } - - ++D0ptr; - SYNTH_EMAC1(hi0, fo, D0ptr); - pcm[0] = -(hi0 << 3); - } - pcm += 16; - phase = (phase + 1) % 16; - } - } -} - -#elif defined(FPM_ARM) - -#define PROD_O(hi, lo, f, ptr) \ - ({ \ - mad_fixed_t *__p = (f); \ - asm("ldmia %2!, {r0, r1, r2, r3}\n\t" \ - "ldr r4, [%3, #0]\n\t" \ - "ldr r12, [%3, #56]\n\t" \ - "smull %0, %1, r0, r4\n\t" \ - "ldr r4, [%3, #48]\n\t" \ - "smlal %0, %1, r1, r12\n\t" \ - "ldr r12, [%3, #40]\n\t" \ - "smlal %0, %1, r2, r4\n\t" \ - "smlal %0, %1, r3, r12\n\t" \ - "ldmia %2, {r0, r1, r2, r3}\n\t" \ - "ldr r4, [%3, #32]\n\t" \ - "ldr r12, [%3, #24]\n\t" \ - "smlal %0, %1, r0, r4\n\t" \ - "ldr r4, [%3, #16]\n\t" \ - "smlal %0, %1, r1, r12\n\t" \ - "ldr r12, [%3, #8]\n\t" \ - "smlal %0, %1, r2, r4\n\t" \ - "smlal %0, %1, r3, r12\n\t" \ - : "=&r" (lo), "=&r" (hi), "+r" (__p) \ - : "r" (ptr) \ - : "r0", "r1", "r2", "r3", "r4", "r12"); \ - }) - -#define PROD_A(hi, lo, f, ptr) \ - ({ \ - mad_fixed_t *__p = (f); \ - asm("ldmia %2!, {r0, r1, r2, r3}\n\t" \ - "ldr r4, [%3, #0]\n\t" \ - "ldr r12, [%3, #56]\n\t" \ - "smlal %0, %1, r0, r4\n\t" \ - "ldr r4, [%3, #48]\n\t" \ - "smlal %0, %1, r1, r12\n\t" \ - "ldr r12, [%3, #40]\n\t" \ - "smlal %0, %1, r2, r4\n\t" \ - "smlal %0, %1, r3, r12\n\t" \ - "ldmia %2, {r0, r1, r2, r3}\n\t" \ - "ldr r4, [%3, #32]\n\t" \ - "ldr r12, [%3, #24]\n\t" \ - "smlal %0, %1, r0, r4\n\t" \ - "ldr r4, [%3, #16]\n\t" \ - "smlal %0, %1, r1, r12\n\t" \ - "ldr r12, [%3, #8]\n\t" \ - "smlal %0, %1, r2, r4\n\t" \ - "smlal %0, %1, r3, r12\n\t" \ - : "+r" (lo), "+r" (hi), "+r" (__p) \ - : "r" (ptr) \ - : "r0", "r1", "r2", "r3", "r4", "r12"); \ - }) - -void synth_full_odd_sbsample (mad_fixed_t *pcm, - mad_fixed_t (*fo)[8], - mad_fixed_t (*fe)[8], - mad_fixed_t const (*D0ptr)[32], - mad_fixed_t const (*D1ptr)[32]); -void synth_full_even_sbsample(mad_fixed_t *pcm, - mad_fixed_t (*fo)[8], - mad_fixed_t (*fe)[8], - mad_fixed_t const (*D0ptr)[32], - mad_fixed_t const (*D1ptr)[32]); - -static -void synth_full(struct mad_synth *synth, struct mad_frame const *frame, - unsigned int nch, unsigned int ns) ICODE_ATTR_MPA_SYNTH; -static -void synth_full(struct mad_synth *synth, struct mad_frame const *frame, - unsigned int nch, unsigned int ns) -{ - int p; - unsigned int phase, ch, s; - mad_fixed_t *pcm, (*filter)[2][2][16][8]; - mad_fixed_t (*sbsample)[36][32]; - mad_fixed_t (*fe)[8], (*fx)[8], (*fo)[8]; - mad_fixed_t const (*D0ptr)[32], *ptr; - mad_fixed_t const (*D1ptr)[32]; - mad_fixed64hi_t hi; - mad_fixed64lo_t lo; - - for (ch = 0; ch < nch; ++ch) { - sbsample = &(*frame->sbsample_prev)[ch]; - filter = &synth->filter[ch]; - phase = synth->phase; - pcm = synth->pcm.samples[ch]; - - for (s = 0; s < ns; ++s) { - dct32((*sbsample)[s], phase >> 1, - (*filter)[0][phase & 1], (*filter)[1][phase & 1]); - - p = (phase - 1) & 0xf; - - /* calculate 32 samples */ - fe = &(*filter)[0][ phase & 1][0]; - fx = &(*filter)[0][~phase & 1][0]; - fo = &(*filter)[1][~phase & 1][0]; - - D0ptr = (void*)&D[0][ p]; - D1ptr = (void*)&D[0][-p]; - - if(s & 1) - { - ptr = *D0ptr; - PROD_O(hi, lo, *fx, ptr+1); - MLN(hi, lo); - PROD_A(hi, lo, *fe, ptr); - pcm[0] = SHIFT(MLZ(hi, lo)); - pcm += 16; - - synth_full_odd_sbsample(pcm, fo, fe, D0ptr, D1ptr); - D0ptr += 15; - D1ptr += 15; - fo += 15; - fe += 15; - - ptr = *(D0ptr + 1); - PROD_O(hi, lo, *fo, ptr+1); - pcm[0] = SHIFT(-MLZ(hi, lo)); - } - else - { - ptr = *D0ptr; - PROD_O(hi, lo, *fx, ptr); - MLN(hi, lo); - PROD_A(hi, lo, *fe, ptr+1); - pcm[0] = SHIFT(MLZ(hi, lo)); - pcm += 16; - - synth_full_even_sbsample(pcm, fo, fe, D0ptr, D1ptr); - D0ptr += 15; - D1ptr += 15; - fo += 15; - fe += 15; - - ptr = *(D0ptr + 1); - PROD_O(hi, lo, *fo, ptr); - pcm[0] = SHIFT(-MLZ(hi, lo)); - } - - pcm += 16; - phase = (phase + 1) % 16; - } - } -} - -# else /* not FPM_COLDFIRE_EMAC and not FPM_ARM */ - -#define PROD_O(hi, lo, f, ptr, offset) \ - ML0(hi, lo, (*f)[0], ptr[ 0+offset]); \ - MLA(hi, lo, (*f)[1], ptr[14+offset]); \ - MLA(hi, lo, (*f)[2], ptr[12+offset]); \ - MLA(hi, lo, (*f)[3], ptr[10+offset]); \ - MLA(hi, lo, (*f)[4], ptr[ 8+offset]); \ - MLA(hi, lo, (*f)[5], ptr[ 6+offset]); \ - MLA(hi, lo, (*f)[6], ptr[ 4+offset]); \ - MLA(hi, lo, (*f)[7], ptr[ 2+offset]); - -#define PROD_A(hi, lo, f, ptr, offset) \ - MLA(hi, lo, (*f)[0], ptr[ 0+offset]); \ - MLA(hi, lo, (*f)[1], ptr[14+offset]); \ - MLA(hi, lo, (*f)[2], ptr[12+offset]); \ - MLA(hi, lo, (*f)[3], ptr[10+offset]); \ - MLA(hi, lo, (*f)[4], ptr[ 8+offset]); \ - MLA(hi, lo, (*f)[5], ptr[ 6+offset]); \ - MLA(hi, lo, (*f)[6], ptr[ 4+offset]); \ - MLA(hi, lo, (*f)[7], ptr[ 2+offset]); - -#define PROD_SB(hi, lo, ptr, offset, first_idx, last_idx) \ - ML0(hi, lo, (*fe)[0], ptr[first_idx]); \ - MLA(hi, lo, (*fe)[1], ptr[16+offset]); \ - MLA(hi, lo, (*fe)[2], ptr[18+offset]); \ - MLA(hi, lo, (*fe)[3], ptr[20+offset]); \ - MLA(hi, lo, (*fe)[4], ptr[22+offset]); \ - MLA(hi, lo, (*fe)[5], ptr[24+offset]); \ - MLA(hi, lo, (*fe)[6], ptr[26+offset]); \ - MLA(hi, lo, (*fe)[7], ptr[28+offset]); \ - MLA(hi, lo, (*fo)[7], ptr[29-offset]); \ - MLA(hi, lo, (*fo)[6], ptr[27-offset]); \ - MLA(hi, lo, (*fo)[5], ptr[25-offset]); \ - MLA(hi, lo, (*fo)[4], ptr[23-offset]); \ - MLA(hi, lo, (*fo)[3], ptr[21-offset]); \ - MLA(hi, lo, (*fo)[2], ptr[19-offset]); \ - MLA(hi, lo, (*fo)[1], ptr[17-offset]); \ - MLA(hi, lo, (*fo)[0], ptr[last_idx ]); - -static -void synth_full(struct mad_synth *synth, struct mad_frame const *frame, - unsigned int nch, unsigned int ns) -{ - int p, sb; - unsigned int phase, ch, s; - mad_fixed_t *pcm, (*filter)[2][2][16][8]; - mad_fixed_t (*sbsample)[36][32]; - mad_fixed_t (*fe)[8], (*fx)[8], (*fo)[8]; - mad_fixed_t const (*D0ptr)[32], *ptr; - mad_fixed_t const (*D1ptr)[32]; - mad_fixed64hi_t hi; - mad_fixed64lo_t lo; - - for (ch = 0; ch < nch; ++ch) { - sbsample = &(*frame->sbsample_prev)[ch]; - filter = &synth->filter[ch]; - phase = synth->phase; - pcm = synth->pcm.samples[ch]; - - for (s = 0; s < ns; ++s) { - dct32((*sbsample)[s], phase >> 1, - (*filter)[0][phase & 1], (*filter)[1][phase & 1]); - - p = (phase - 1) & 0xf; - - /* calculate 32 samples */ - fe = &(*filter)[0][ phase & 1][0]; - fx = &(*filter)[0][~phase & 1][0]; - fo = &(*filter)[1][~phase & 1][0]; - - D0ptr = (void*)&D[0][ p]; - D1ptr = (void*)&D[0][-p]; - - if(s & 1) - { - ptr = *D0ptr; - PROD_O(hi, lo, fx, ptr, 1) - MLN(hi, lo); - PROD_A(hi, lo, fe, ptr, 0) - pcm[0] = SHIFT(MLZ(hi, lo)); - pcm += 16; - - for (sb = 15; sb; sb--, fo++) - { - ++fe; - ++D0ptr; - ++D1ptr; - - /* D[32 - sb][i] == -D[sb][31 - i] */ - ptr = *D0ptr; - PROD_O(hi, lo, fo, ptr, 1) - MLN(hi, lo); - PROD_A(hi, lo, fe, ptr, 0) - pcm[-sb] = SHIFT(MLZ(hi, lo)); - - ptr = *D1ptr; - PROD_SB(hi, lo, ptr, 1, 15, 30) - pcm[sb] = SHIFT(MLZ(hi, lo)); - } - - ptr = *(D0ptr + 1); - PROD_O(hi, lo, fo, ptr, 1) - pcm[0] = SHIFT(-MLZ(hi, lo)); - } - else - { - ptr = *D0ptr; - PROD_O(hi, lo, fx, ptr, 0) - MLN(hi, lo); - PROD_A(hi, lo, fe, ptr, 1) - pcm[0] = SHIFT(MLZ(hi, lo)); - pcm += 16; - - for (sb = 15; sb; sb--, fo++) - { - ++fe; - ++D0ptr; - ++D1ptr; - - /* D[32 - sb][i] == -D[sb][31 - i] */ - ptr = *D0ptr; - PROD_O(hi, lo, fo, ptr, 0) - MLN(hi, lo); - PROD_A(hi, lo, fe, ptr, 1) - pcm[-sb] = SHIFT(MLZ(hi, lo)); - - ptr = *D1ptr; - PROD_SB(hi, lo, ptr, 0, 30, 15) - pcm[sb] = SHIFT(MLZ(hi, lo)); - } - - ptr = *(D0ptr + 1); - PROD_O(hi, lo, fo, ptr, 0) - pcm[0] = SHIFT(-MLZ(hi, lo)); - } - - pcm += 16; - phase = (phase + 1) % 16; - } - } -} -# endif /* FPM_COLDFIRE_EMAC, FPM_ARM */ - -#if 0 /* rockbox: unused */ -/* - * NAME: synth->half() - * DESCRIPTION: perform half frequency PCM synthesis - */ -static -void synth_half(struct mad_synth *synth, struct mad_frame const *frame, - unsigned int nch, unsigned int ns) -{ - unsigned int phase, ch, s, sb, pe, po; - mad_fixed_t *pcm1, *pcm2, (*filter)[2][2][16][8]; - mad_fixed_t (*sbsample)[36][32]; - register mad_fixed_t (*fe)[8], (*fx)[8], (*fo)[8]; - register mad_fixed_t const (*Dptr)[32], *ptr; - register mad_fixed64hi_t hi; - register mad_fixed64lo_t lo; - - for (ch = 0; ch < nch; ++ch) { - sbsample = &(*frame->sbsample_prev)[ch]; - filter = &synth->filter[ch]; - phase = synth->phase; - pcm1 = synth->pcm.samples[ch]; - - for (s = 0; s < ns; ++s) { - dct32((*sbsample)[s], phase >> 1, - (*filter)[0][phase & 1], (*filter)[1][phase & 1]); - - pe = phase & ~1; - po = ((phase - 1) & 0xf) | 1; - - /* calculate 16 samples */ - - fe = &(*filter)[0][ phase & 1][0]; - fx = &(*filter)[0][~phase & 1][0]; - fo = &(*filter)[1][~phase & 1][0]; - - Dptr = &D[0]; - - ptr = *Dptr + po; - ML0(hi, lo, (*fx)[0], ptr[ 0]); - MLA(hi, lo, (*fx)[1], ptr[14]); - MLA(hi, lo, (*fx)[2], ptr[12]); - MLA(hi, lo, (*fx)[3], ptr[10]); - MLA(hi, lo, (*fx)[4], ptr[ 8]); - MLA(hi, lo, (*fx)[5], ptr[ 6]); - MLA(hi, lo, (*fx)[6], ptr[ 4]); - MLA(hi, lo, (*fx)[7], ptr[ 2]); - MLN(hi, lo); - - ptr = *Dptr + pe; - MLA(hi, lo, (*fe)[0], ptr[ 0]); - MLA(hi, lo, (*fe)[1], ptr[14]); - MLA(hi, lo, (*fe)[2], ptr[12]); - MLA(hi, lo, (*fe)[3], ptr[10]); - MLA(hi, lo, (*fe)[4], ptr[ 8]); - MLA(hi, lo, (*fe)[5], ptr[ 6]); - MLA(hi, lo, (*fe)[6], ptr[ 4]); - MLA(hi, lo, (*fe)[7], ptr[ 2]); - - *pcm1++ = SHIFT(MLZ(hi, lo)); - - pcm2 = pcm1 + 14; - - for (sb = 1; sb < 16; ++sb) { - ++fe; - ++Dptr; - - /* D[32 - sb][i] == -D[sb][31 - i] */ - - if (!(sb & 1)) { - ptr = *Dptr + po; - ML0(hi, lo, (*fo)[0], ptr[ 0]); - MLA(hi, lo, (*fo)[1], ptr[14]); - MLA(hi, lo, (*fo)[2], ptr[12]); - MLA(hi, lo, (*fo)[3], ptr[10]); - MLA(hi, lo, (*fo)[4], ptr[ 8]); - MLA(hi, lo, (*fo)[5], ptr[ 6]); - MLA(hi, lo, (*fo)[6], ptr[ 4]); - MLA(hi, lo, (*fo)[7], ptr[ 2]); - MLN(hi, lo); - - ptr = *Dptr + pe; - MLA(hi, lo, (*fe)[7], ptr[ 2]); - MLA(hi, lo, (*fe)[6], ptr[ 4]); - MLA(hi, lo, (*fe)[5], ptr[ 6]); - MLA(hi, lo, (*fe)[4], ptr[ 8]); - MLA(hi, lo, (*fe)[3], ptr[10]); - MLA(hi, lo, (*fe)[2], ptr[12]); - MLA(hi, lo, (*fe)[1], ptr[14]); - MLA(hi, lo, (*fe)[0], ptr[ 0]); - - *pcm1++ = SHIFT(MLZ(hi, lo)); - - ptr = *Dptr - po; - ML0(hi, lo, (*fo)[7], ptr[31 - 2]); - MLA(hi, lo, (*fo)[6], ptr[31 - 4]); - MLA(hi, lo, (*fo)[5], ptr[31 - 6]); - MLA(hi, lo, (*fo)[4], ptr[31 - 8]); - MLA(hi, lo, (*fo)[3], ptr[31 - 10]); - MLA(hi, lo, (*fo)[2], ptr[31 - 12]); - MLA(hi, lo, (*fo)[1], ptr[31 - 14]); - MLA(hi, lo, (*fo)[0], ptr[31 - 16]); - - ptr = *Dptr - pe; - MLA(hi, lo, (*fe)[0], ptr[31 - 16]); - MLA(hi, lo, (*fe)[1], ptr[31 - 14]); - MLA(hi, lo, (*fe)[2], ptr[31 - 12]); - MLA(hi, lo, (*fe)[3], ptr[31 - 10]); - MLA(hi, lo, (*fe)[4], ptr[31 - 8]); - MLA(hi, lo, (*fe)[5], ptr[31 - 6]); - MLA(hi, lo, (*fe)[6], ptr[31 - 4]); - MLA(hi, lo, (*fe)[7], ptr[31 - 2]); - - *pcm2-- = SHIFT(MLZ(hi, lo)); - } - - ++fo; - } - - ++Dptr; - - ptr = *Dptr + po; - ML0(hi, lo, (*fo)[0], ptr[ 0]); - MLA(hi, lo, (*fo)[1], ptr[14]); - MLA(hi, lo, (*fo)[2], ptr[12]); - MLA(hi, lo, (*fo)[3], ptr[10]); - MLA(hi, lo, (*fo)[4], ptr[ 8]); - MLA(hi, lo, (*fo)[5], ptr[ 6]); - MLA(hi, lo, (*fo)[6], ptr[ 4]); - MLA(hi, lo, (*fo)[7], ptr[ 2]); - - *pcm1 = SHIFT(-MLZ(hi, lo)); - pcm1 += 8; - - phase = (phase + 1) % 16; - } - } -} -#endif /* unused */ - -/* - * NAME: synth->frame() - * DESCRIPTION: perform PCM synthesis of frame subband samples - */ -void mad_synth_frame(struct mad_synth *synth, struct mad_frame const *frame) -{ - unsigned int nch, ns; -#if 0 /* rockbox: unused */ - void (*synth_frame)(struct mad_synth *, struct mad_frame const *, - unsigned int, unsigned int); -#endif - - nch = MAD_NCHANNELS(&frame->header); - ns = MAD_NSBSAMPLES(&frame->header); - - synth->pcm.samplerate = frame->header.samplerate; - synth->pcm.channels = nch; - synth->pcm.length = 32 * ns; - -#if 0 /* rockbox: unused */ - synth_frame = synth_full; - - if (frame->options & MAD_OPTION_HALFSAMPLERATE) { - synth->pcm.samplerate /= 2; - synth->pcm.length /= 2; - - synth_frame = synth_half; - } - - synth_frame(synth, frame, nch, ns); -#else - synth_full(synth, frame, nch, ns); -#endif - - synth->phase = (synth->phase + ns) % 16; -} diff --git a/apps/codecs/libmad/synth.h b/apps/codecs/libmad/synth.h deleted file mode 100644 index 93dd3946d4..0000000000 --- a/apps/codecs/libmad/synth.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * libmad - MPEG audio decoder library - * Copyright (C) 2000-2004 Underbit Technologies, Inc. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * $Id$ - */ - -# ifndef LIBMAD_SYNTH_H -# define LIBMAD_SYNTH_H - -# include "fixed.h" -# include "frame.h" - -struct mad_pcm { - unsigned int samplerate; /* sampling frequency (Hz) */ - unsigned short channels; /* number of channels */ - unsigned short length; /* number of samples per channel */ - mad_fixed_t samples[2][1152] MEM_ALIGN_ATTR; /* PCM output samples [ch][sample] */ -}; - -struct mad_synth { - mad_fixed_t filter[2][2][2][16][8] MEM_ALIGN_ATTR; /* polyphase filterbank outputs */ - /* [ch][eo][peo][s][v] */ - - unsigned int phase; /* current processing phase */ - - struct mad_pcm pcm; /* PCM output */ -}; - -void mad_synth_init(struct mad_synth *); - -# define mad_synth_finish(synth) /* nothing */ - -void mad_synth_mute(struct mad_synth *); - -void mad_synth_frame(struct mad_synth *, struct mad_frame const *); - -# endif diff --git a/apps/codecs/libmad/synth_full_arm.S b/apps/codecs/libmad/synth_full_arm.S deleted file mode 100644 index 0a4f9b93c2..0000000000 --- a/apps/codecs/libmad/synth_full_arm.S +++ /dev/null @@ -1,340 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2007 by Tomasz Malesinski - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ - -#include "config.h" -#include "mad_iram.h" - - .section ICODE_SECTION_MPA_ARM,"ax",%progbits - - .global synth_full_odd_sbsample - .global synth_full_even_sbsample - - /* - ;; r0 = pcm (pushed on the stack to free a register) - ;; r1 = fo - ;; r2 = fe - ;; r3 = D0ptr - ;; r4 = D1ptr - - ;; r5 = loop counter - ;; r6,r7 accumulator1 - ;; r8,r9 accumulator2 - */ - -synth_full_odd_sbsample: - stmdb sp!, {r0, r4-r11, lr} - ldr r4, [sp, #40] - mov r5, #15 - add r2, r2, #32 -.l: - /* ;; PROD_O and odd half of SB_SAMPLE*/ - add r3, r3, #128 - add r4, r4, #128 - ldr r7, [r3, #4] - ldmia r1!, {r0, r10, r11, lr} - ldr r9, [r4, #120] - smull r6, r7, r0, r7 - ldr r12, [r3, #60] - smull r8, r9, r0, r9 - ldr r0, [r3, #52] - smlal r6, r7, r10, r12 - ldr r12, [r3, #44] - smlal r6, r7, r11, r0 - ldr r0, [r4, #64] - smlal r6, r7, lr, r12 - ldr r12, [r4, #72] - smlal r8, r9, r10, r0 - ldr r0, [r4, #80] - smlal r8, r9, r11, r12 - smlal r8, r9, lr, r0 - ldr r0, [r3, #36] - - ldmia r1!, {r10, r11, r12, lr} - smlal r6, r7, r10, r0 - - ldr r0, [r4, #88] /*;;1 cycle stall on arm9, but we free up r10*/ - smlal r8, r9, r10, r0 - - ldr r0, [r3, #28] - ldr r10, [r3, #20] - smlal r6, r7, r11, r0 - ldr r0, [r3, #12] - smlal r6, r7, r12, r10 - ldr r10, [r4, #96] - smlal r6, r7, lr, r0 - ldr r0, [r4, #104] - smlal r8, r9, r11, r10 - ldr r10, [r4, #112] - smlal r8, r9, r12, r0 - smlal r8, r9, lr, r10 - - rsbs r6, r6, #0 - rsc r7, r7, #0 - - /* ;; PROD_A and even half of SB_SAMPLE*/ - ldr r0, [r3, #0] - ldmia r2!, {r10, r11, r12, lr} - smlal r6, r7, r10, r0 - - ldr r0, [r4, #60] /*;;1 cycle stall on arm9, but we free up r10*/ - smlal r8, r9, r10, r0 - ldr r10, [r3, #56] - ldr r0, [r3, #48] - smlal r6, r7, r11, r10 - ldr r10, [r3, #40] - smlal r6, r7, r12, r0 - ldr r0, [r4, #68] - smlal r6, r7, lr, r10 - ldr r10, [r4, #76] - smlal r8, r9, r11, r0 - ldr r0, [r4, #84] - smlal r8, r9, r12, r10 - smlal r8, r9, lr, r0 - - ldr r0, [r3, #32] - ldmia r2!, {r10, r11, r12, lr} - smlal r6, r7, r10, r0 - - ldr r0, [r4, #92] /*;;1 cycle stall on arm9, but we free up r10*/ - smlal r8, r9, r10, r0 - - ldr r0, [r3, #24] - ldr r10, [r3, #16] - smlal r6, r7, r11, r0 - ldr r0, [r3, #8] - smlal r6, r7, r12, r10 - ldr r10, [r4, #100] - smlal r6, r7, lr, r0 - ldr r0, [r4, #108] - smlal r8, r9, r11, r10 - ldr r10, [r4, #116] - smlal r8, r9, r12, r0 - smlal r8, r9, lr, r10 - - ldr r0, [sp] - - movs r6, r6, lsr #16 - adc r6, r6, r7, lsl #16 - str r6, [r0, -r5, lsl #2] - - movs r8, r8, lsr #16 - adc r8, r8, r9, lsl #16 - str r8, [r0, r5, lsl #2] - - subs r5, r5, #1 - bne .l - - ldmpc regs="r0,r4-r11" - -synth_full_even_sbsample: - stmdb sp!, {r0, r4-r11, lr} - ldr r4, [sp, #40] - mov r5, #15 - add r2, r2, #32 -.l2: - /* ;; PROD_O and odd half of SB_SAMPLE*/ - add r3, r3, #128 - add r4, r4, #128 - ldr r7, [r3, #0] - ldmia r1!, {r0, r10, r11, lr} - ldr r9, [r4, #60] - smull r6, r7, r0, r7 - ldr r12, [r3, #56] - smull r8, r9, r0, r9 - ldr r0, [r3, #48] - smlal r6, r7, r10, r12 - ldr r12, [r3, #40] - smlal r6, r7, r11, r0 - ldr r0, [r4, #68] - smlal r6, r7, lr, r12 - - ldr r12, [r4, #76] - smlal r8, r9, r10, r0 - ldr r0, [r4, #84] - smlal r8, r9, r11, r12 - smlal r8, r9, lr, r0 - - ldr r0, [r3, #32] - ldmia r1!, {r10, r11, r12, lr} - - smlal r6, r7, r10, r0 - ldr r0, [r4, #92] - smlal r8, r9, r10, r0 - ldr r0, [r3, #24] - ldr r10, [r3, #16] - smlal r6, r7, r11, r0 - ldr r0, [r3, #8] - smlal r6, r7, r12, r10 - ldr r10, [r4, #100] - smlal r6, r7, lr, r0 - ldr r0, [r4, #108] - smlal r8, r9, r11, r10 - ldr r10, [r4, #116] - smlal r8, r9, r12, r0 - smlal r8, r9, lr, r10 - - rsbs r6, r6, #0 - rsc r7, r7, #0 - - ldr r0, [r3, #4] - ldmia r2!, {r10, r11, r12, lr} - smlal r6, r7, r10, r0 - ldr r0, [r4, #120] /*;;1 cycle stall on arm9, but we free up r10*/ - smlal r8, r9, r10, r0 - ldr r0, [r3, #60] - ldr r10, [r3, #52] - smlal r6, r7, r11, r0 - ldr r0, [r3, #44] - smlal r6, r7, r12, r10 - ldr r10, [r4, #64] - smlal r6, r7, lr, r0 - - ldr r0, [r4, #72] - smlal r8, r9, r11, r10 - ldr r10, [r4, #80] - smlal r8, r9, r12, r0 - - smlal r8, r9, lr, r10 - - ldr r0, [r3, #36] - ldmia r2!, {r10, r11, r12, lr} - smlal r6, r7, r10, r0 - ldr r0, [r4, #88] /*;;1 cycle stall on arm9, but we free up r10*/ - smlal r8, r9, r10, r0 - - ldr r0, [r3, #28] - ldr r10, [r3, #20] - smlal r6, r7, r11, r0 - ldr r0, [r3, #12] - smlal r6, r7, r12, r10 - ldr r10, [r4, #96] - smlal r6, r7, lr, r0 - ldr r0, [r4, #104] - smlal r8, r9, r11, r10 - ldr r10, [r4, #112] - smlal r8, r9, r12, r0 - smlal r8, r9, lr, r10 - - ldr r0, [sp] - - movs r6, r6, lsr #16 - adc r6, r6, r7, lsl #16 - str r6, [r0, -r5, lsl #2] - - movs r8, r8, lsr #16 - adc r8, r8, r9, lsl #16 - str r8, [r0, r5, lsl #2] - - subs r5, r5, #1 - bne .l2 - - ldmpc regs="r0,r4-r11" - - .global III_aliasreduce - -III_aliasreduce: - stmdb sp!, {r4-r11, lr} - add r1, r0, r1, lsl #2 - add r0, r0, #72 -.arl1: - mov r2, #8 - mov r3, r0 @ a - mov r4, r0 @ b - ldr r5, =csa @ cs/ca -.arl2: - ldmdb r3, {r6, r12} - ldmia r4, {r7, lr} - - ldmia r5!, {r8, r9} - smull r10, r11, r7, r8 - smlal r10, r11, r12, r9 - movs r10, r10, lsr #28 - adc r10, r10, r11, lsl #4 - - rsb r7, r7, #0 - smull r11, r8, r12, r8 - smlal r11, r8, r7, r9 - movs r11, r11, lsr #28 - adc r11, r11, r8, lsl #4 - - ldmia r5!, {r8, r9} - smull r12, r7, lr, r8 - smlal r12, r7, r6, r9 - movs r12, r12, lsr #28 - adc r12, r12, r7, lsl #4 - stmia r4!, {r10, r12} - - rsb lr, lr, #0 - smull r7, r10, r6, r8 - smlal r7, r10, lr, r9 - movs r7, r7, lsr #28 - adc r7, r7, r10, lsl #4 - stmdb r3!, {r7, r11} - - subs r2, r2, #2 - bne .arl2 - add r0, r0, #72 - cmp r0, r1 - blo .arl1 - ldmpc regs=r4-r11 - -csa: - .word +0x0db84a81 - .word -0x083b5fe7 - .word +0x0e1b9d7f - .word -0x078c36d2 - .word +0x0f31adcf - .word -0x05039814 - .word +0x0fbba815 - .word -0x02e91dd1 - .word +0x0feda417 - .word -0x0183603a - .word +0x0ffc8fc8 - .word -0x00a7cb87 - .word +0x0fff964c - .word -0x003a2847 - .word +0x0ffff8d3 - .word -0x000f27b4 - - .global III_overlap -III_overlap: - stmdb sp!, {r4-r7, lr} - add r2, r2, r3, lsl #2 - mov r3, #6 -.ol: - ldmia r0!, {r4, r5, r6} - ldmia r1!, {r7, r12, lr} - add r4, r4, r7 - add r5, r5, r12 - add r6, r6, lr - str r4, [r2], #128 - str r5, [r2], #128 - str r6, [r2], #128 - subs r3, r3, #1 - bne .ol - sub r1, r1, #72 - ldmia r0!, {r4, r5, r6, r7, r12, lr} - stmia r1!, {r4, r5, r6, r7, r12, lr} - ldmia r0!, {r4, r5, r6, r7, r12, lr} - stmia r1!, {r4, r5, r6, r7, r12, lr} - ldmia r0!, {r4, r5, r6, r7, r12, lr} - stmia r1!, {r4, r5, r6, r7, r12, lr} - ldmpc regs=r4-r7 diff --git a/apps/codecs/libmusepack/AUTHORS b/apps/codecs/libmusepack/AUTHORS deleted file mode 100644 index 1bcac63765..0000000000 --- a/apps/codecs/libmusepack/AUTHORS +++ /dev/null @@ -1,10 +0,0 @@ -libmpcdec is the result of the work of many people: - -* Andree Buschmann and Frank Klemm - Original implementation and core development. - -* Peter Pawlowski and Benoit Amiaux - Portability and further optimizations. - -* Miles Egan - Port to pure C, documentation, and api refinements. diff --git a/apps/codecs/libmusepack/COPYING b/apps/codecs/libmusepack/COPYING deleted file mode 100644 index 10190c014a..0000000000 --- a/apps/codecs/libmusepack/COPYING +++ /dev/null @@ -1,31 +0,0 @@ -Copyright (c) 2005, The Musepack Development Team -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - - * Neither the name of the The Musepack Development Team nor the - names of its contributors may be used to endorse or promote - products derived from this software without specific prior - written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/apps/codecs/libmusepack/ChangeLog b/apps/codecs/libmusepack/ChangeLog deleted file mode 100644 index 6c998480bd..0000000000 --- a/apps/codecs/libmusepack/ChangeLog +++ /dev/null @@ -1,40 +0,0 @@ -1.3.0 - * first sv8 release - * major changes in the API (decoder and demuxer are split) - -1.2.3 - * Reduced memory usage and code size. Patch by Peter Pawlowski - -1.2.2 - * Fixed compilation under OpenBSD - * Unix EOF again - -1.2.1 - * Warnings cleanup, patch by Tomas Salfischberger, Thom Johansen and - Daniel Stenberg (Rockbox) - * Mplayer interface, patch by Reimar Doffinger - * Unix EOF everywhere - -1.2 - * 1.1.1 broke the API (BOOL type changed to mpc_bool_t). Version bumped to 1.2 to reflect the major change. Sorry to those who were caught by this error - * Fixed relative/absolute includes (#include "stuff.h" in /include/mpcdec, #include in src/) - * Added msvc project files - * Changed mpc_reader_t structure, any specific data of the reader's - implementations should be hidden behind the (void*) data pointer. (example - in default implementation mpc_reader_file) - * Renamed to libmpcdec (to make room for libmpcenc) - -1.1.1 - * fix for fixed-point mode bug - -1.1 - * add compliance & cleanup patches from Michael Roitzsch of xine project - * switch to BSD license - * port to pure C - * add doxygen documentation - * revise API somewhat - -1.0.3 - * autotools build process - * sample binary added - * floating-point mode by default diff --git a/apps/codecs/libmusepack/SOURCES b/apps/codecs/libmusepack/SOURCES deleted file mode 100644 index 60d762afd2..0000000000 --- a/apps/codecs/libmusepack/SOURCES +++ /dev/null @@ -1,14 +0,0 @@ -crc32.c -huffman.c -mpc_bits_reader.c -mpc_decoder.c -mpc_demux.c -requant.c -streaminfo.c -synth_filter.c -#if defined(CPU_ARM) -synth_filter_arm.S -#endif -#if defined(CPU_COLDFIRE) -synth_filter_coldfire.S -#endif diff --git a/apps/codecs/libmusepack/crc32.c b/apps/codecs/libmusepack/crc32.c deleted file mode 100644 index 7613f1c2c8..0000000000 --- a/apps/codecs/libmusepack/crc32.c +++ /dev/null @@ -1,57 +0,0 @@ -/* -* C Implementation: crc32 -* -* code from http://www.w3.org/TR/PNG/#D-CRCAppendix -* -*/ -#include "internal.h" - -/* Table of CRCs of all 8-bit messages. */ -static unsigned long crc_table[256]; - -/* Flag: has the table been computed? Initially false. */ -static int crc_table_computed = 0; - -/* Make the table for a fast CRC. */ -static void make_crc_table(void) -{ - unsigned long c; - int n, k; - - for (n = 0; n < 256; n++) { - c = (unsigned long) n; - for (k = 0; k < 8; k++) { - if (c & 1) - c = 0xedb88320L ^ (c >> 1); - else - c = c >> 1; - } - crc_table[n] = c; - } - crc_table_computed = 1; -} - - -/* Update a running CRC with the bytes buf[0..len-1]--the CRC - should be initialized to all 1's, and the transmitted value - is the 1's complement of the final running CRC (see the - crc() routine below). */ - -static unsigned long update_crc(unsigned long crc, unsigned char *buf, int len) -{ - unsigned long c = crc; - int n; - - if (!crc_table_computed) - make_crc_table(); - for (n = 0; n < len; n++) { - c = crc_table[(c ^ buf[n]) & 0xff] ^ (c >> 8); - } - return c; -} - -/* Return the CRC of the bytes buf[0..len-1]. */ -unsigned long mpc_crc32(unsigned char *buf, int len) -{ - return update_crc(0xffffffffL, buf, len) ^ 0xffffffffL; -} diff --git a/apps/codecs/libmusepack/decoder.h b/apps/codecs/libmusepack/decoder.h deleted file mode 100644 index 1acacae8d9..0000000000 --- a/apps/codecs/libmusepack/decoder.h +++ /dev/null @@ -1,101 +0,0 @@ -/* - Copyright (c) 2005-2009, The Musepack Development Team - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are - met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - - * Neither the name of the The Musepack Development Team nor the - names of its contributors may be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -/// \file decoder.h -#ifndef _MPCDEC_DECODER_H_ -#define _MPCDEC_DECODER_H_ -#ifdef WIN32 -#pragma once -#endif - -#include "reader.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define SEEKING_TABLE_SIZE 256u -// set it to SLOW_SEEKING_WINDOW to not use fast seeking -#define FAST_SEEKING_WINDOW 32 -// set it to FAST_SEEKING_WINDOW to only use fast seeking -#define SLOW_SEEKING_WINDOW 0x80000000 - -enum { - MPC_V_MEM = 2304, - MPC_DECODER_MEMSIZE = 16384, // overall buffer size -}; - -struct mpc_decoder_t { - /// @name internal state variables - //@{ - mpc_uint32_t stream_version; ///< Streamversion of stream - mpc_int32_t max_band; ///< Maximum band-index used in stream (0...31) - mpc_uint32_t ms; ///< Mid/side stereo (0: off, 1: on) - mpc_uint32_t channels; ///< Number of channels in stream - - mpc_uint64_t samples; ///< Number of samples in stream - - mpc_uint64_t decoded_samples; ///< Number of samples decoded from file begining - mpc_uint32_t samples_to_skip; ///< Number samples to skip (used for seeking) - mpc_int32_t last_max_band; ///< number of bands used in the last frame - - // randomizer state variables - mpc_uint32_t __r1; - mpc_uint32_t __r2; - - mpc_int32_t SCF_Index_L [32] [3]; - mpc_int32_t SCF_Index_R [32] [3]; // holds scalefactor-indices - mpc_quantizer Q [32]; // holds quantized samples - mpc_int32_t Res_L [32]; - mpc_int32_t Res_R [32]; // holds the chosen quantizer for each subband - mpc_bool_t DSCF_Flag_L [32]; - mpc_bool_t DSCF_Flag_R [32]; // differential SCF used? - mpc_int32_t SCFI_L [32]; - mpc_int32_t SCFI_R [32]; // describes order of transmitted SCF - mpc_bool_t MS_Flag[32]; // MS used? -#ifdef MPC_FIXED_POINT - mpc_uint8_t SCF_shift[256]; -#endif - - MPC_SAMPLE_FORMAT *V_L; - MPC_SAMPLE_FORMAT *V_R; - MPC_SAMPLE_FORMAT *Y_L; - MPC_SAMPLE_FORMAT *Y_R; - mpc_uint32_t SCF[256]; ///< holds adapted scalefactors (for clipping prevention) - //@} -}; - -#ifdef __cplusplus -} -#endif -#endif diff --git a/apps/codecs/libmusepack/huffman.c b/apps/codecs/libmusepack/huffman.c deleted file mode 100644 index c304775623..0000000000 --- a/apps/codecs/libmusepack/huffman.c +++ /dev/null @@ -1,530 +0,0 @@ -/* - Copyright (c) 2005-2009, The Musepack Development Team - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are - met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - - * Neither the name of the The Musepack Development Team nor the - names of its contributors may be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -/// \file huffman.c -/// Implementations of sv7/sv8 huffman decoding functions. -#include "mpcdec.h" -#include "huffman.h" - - -// sv7 huffman tables -static const mpc_huffman mpc_table_HuffHdr [10] ICONST_ATTR = { - {0x8000, 1, 0}, {0x6000, 3, 1}, {0x5e00, 7,-4}, {0x5d80, 9, 3}, {0x5d00, 9, 4}, - {0x5c00, 8,-5}, {0x5800, 6, 2}, {0x5000, 5,-3}, {0x4000, 4,-2}, {0x0000, 2,-1} -}; - -const mpc_huffman mpc_table_HuffSCFI [4] ICONST_ATTR = { - {0x8000, 1, 1}, {0x6000, 3, 2}, {0x4000, 3, 0}, {0x0000, 2, 3} -}; - -static const mpc_huffman mpc_table_HuffDSCF [16] ICONST_ATTR = { - {0xf800, 5, 5}, {0xf000, 5,-4}, {0xe000, 4, 3}, {0xd000, 4,-3}, - {0xc000, 4, 8}, {0xa000, 3, 1}, {0x9000, 4, 0}, {0x8800, 5,-5}, - {0x8400, 6, 7}, {0x8000, 6,-7}, {0x6000, 3,-1}, {0x4000, 3, 2}, - {0x3000, 4, 4}, {0x2800, 5, 6}, {0x2000, 5,-6}, {0x0000, 3,-2} -}; - -static const mpc_huffman mpc_table_HuffQ1 [2] [27] ICONST_ATTR = { - { - {0xe000, 3, 13}, {0xdc00, 6, 26}, {0xd800, 6, 0}, - {0xd400, 6, 20}, {0xd000, 6, 6}, {0xc000, 4, 14}, - {0xb000, 4, 12}, {0xa000, 4, 4}, {0x9000, 4, 22}, - {0x8c00, 6, 8}, {0x8800, 6, 18}, {0x8400, 6, 24}, - {0x8000, 6, 2}, {0x7000, 4, 16}, {0x6000, 4, 10}, - {0x5800, 5, 17}, {0x5000, 5, 9}, {0x4800, 5, 1}, - {0x4000, 5, 25}, {0x3800, 5, 5}, {0x3000, 5, 21}, - {0x2800, 5, 3}, {0x2000, 5, 11}, {0x1800, 5, 15}, - {0x1000, 5, 23}, {0x0800, 5, 19}, {0x0000, 5, 7} - }, { - {0x8000, 1, 13}, {0x7e00, 7, 15}, {0x7c00, 7, 1}, - {0x7a00, 7, 11}, {0x7800, 7, 7}, {0x7600, 7, 17}, - {0x7400, 7, 25}, {0x7200, 7, 19}, {0x7180, 9, 8}, - {0x7100, 9, 18}, {0x7080, 9, 2}, {0x7000, 9, 24}, - {0x6e00, 7, 3}, {0x6c00, 7, 23}, {0x6a00, 7, 21}, - {0x6800, 7, 5}, {0x6700, 8, 0}, {0x6600, 8, 26}, - {0x6500, 8, 6}, {0x6400, 8, 20}, {0x6000, 6, 9}, - {0x5000, 4, 14}, {0x4000, 4, 12}, {0x3000, 4, 4}, - {0x2000, 4, 22}, {0x1000, 4, 16}, {0x0000, 4, 10} - } -}; - -static const mpc_huffman mpc_table_HuffQ2 [2] [25] ICONST_ATTR = { - { - {0xf000, 4, 13}, {0xe000, 4, 17}, {0xd000, 4, 7}, {0xc000, 4, 11}, {0xbc00, 6, 1}, - {0xb800, 6, 23}, {0xb600, 7, 4}, {0xb400, 7, 20}, {0xb200, 7, 0}, {0xb000, 7, 24}, - {0xa800, 5, 22}, {0xa000, 5, 10}, {0x8000, 3, 12}, {0x7800, 5, 2}, {0x7000, 5, 14}, - {0x6000, 4, 6}, {0x5000, 4, 18}, {0x4000, 4, 8}, {0x3000, 4, 16}, {0x2800, 5, 9}, - {0x2000, 5, 5}, {0x1800, 5, 15}, {0x1000, 5, 21}, {0x0800, 5, 19}, {0x0000, 5, 3} - }, { - {0xf800, 5, 18}, {0xf000, 5, 6}, {0xe800, 5, 8}, {0xe700, 8, 3}, {0xe6c0,10, 24}, - {0xe680,10, 4}, {0xe640,10, 0}, {0xe600,10, 20}, {0xe400, 7, 23}, {0xe200, 7, 1}, - {0xe000, 7, 19}, {0xd800, 5, 16}, {0xd600, 7, 15}, {0xd400, 7, 21}, {0xd200, 7, 9}, - {0xd000, 7, 5}, {0xcc00, 6, 2}, {0xc800, 6, 10}, {0xc400, 6, 14}, {0xc000, 6, 22}, - {0x8000, 2, 12}, {0x6000, 3, 13}, {0x4000, 3, 17}, {0x2000, 3, 11}, {0x0000, 3, 7} - } -}; - -static const mpc_huffman mpc_table_HuffQ3 [2] [7] ICONST_ATTR = { - { - {0xe000, 3, 1}, {0xd000, 4, 3}, {0xc000, 4,-3}, {0xa000, 3, 2}, - {0x8000, 3,-2}, {0x4000, 2, 0}, {0x0000, 2,-1} - }, { - {0xc000, 2, 0}, {0x8000, 2,-1}, {0x4000, 2, 1}, {0x3000, 4,-2}, - {0x2800, 5, 3}, {0x2000, 5,-3}, {0x0000, 3, 2} - } -}; - -static const mpc_huffman mpc_table_HuffQ4 [2] [9] ICONST_ATTR = { - { - {0xe000, 3, 0}, {0xc000, 3,-1}, {0xa000, 3, 1}, - {0x8000, 3,-2}, {0x6000, 3, 2}, {0x5000, 4,-4}, - {0x4000, 4, 4}, {0x2000, 3, 3}, {0x0000, 3,-3} - }, { - {0xe000, 3, 1}, {0xd000, 4, 2}, {0xc000, 4,-3}, - {0x8000, 2, 0}, {0x6000, 3,-2}, {0x5000, 4, 3}, - {0x4800, 5,-4}, {0x4000, 5, 4}, {0x0000, 2,-1} - } -}; - -static const mpc_huffman mpc_table_HuffQ5 [2] [15] ICONST_ATTR = { - { - {0xf000, 4, 2}, {0xe800, 5, 5}, {0xe400, 6,-7}, {0xe000, 6, 7}, {0xd000, 4,-3}, - {0xc000, 4, 3}, {0xb800, 5,-6}, {0xb000, 5, 6}, {0xa000, 4,-4}, {0x9000, 4, 4}, - {0x8000, 4,-5}, {0x6000, 3, 0}, {0x4000, 3,-1}, {0x2000, 3, 1}, {0x0000, 3,-2} - }, { - {0xf000, 4, 3}, {0xe800, 5, 4}, {0xe600, 7, 6}, {0xe500, 8,-7}, {0xe400, 8, 7}, - {0xe000, 6,-6}, {0xc000, 3, 0}, {0xa000, 3,-1}, {0x8000, 3, 1}, {0x6000, 3,-2}, - {0x4000, 3, 2}, {0x3800, 5,-5}, {0x3000, 5, 5}, {0x2000, 4,-4}, {0x0000, 3,-3} - } -}; - -static const mpc_huffman mpc_table_HuffQ6 [2] [31] ICONST_ATTR = { - { - {0xf800, 5, 3}, {0xf000, 5, -4}, {0xec00, 6,-11}, {0xe800, 6, 12}, {0xe000, 5, 4}, - {0xd800, 5, 6}, {0xd000, 5, -5}, {0xc800, 5, 5}, {0xc000, 5, 7}, {0xb800, 5, -7}, - {0xb400, 6,-12}, {0xb000, 6,-13}, {0xa800, 5, -6}, {0xa000, 5, 8}, {0x9800, 5, -8}, - {0x9000, 5, 9}, {0x8800, 5, -9}, {0x8400, 6, 13}, {0x8200, 7,-15}, {0x8000, 7, 15}, - {0x7000, 4, 0}, {0x6800, 5,-10}, {0x6000, 5, 10}, {0x5000, 4, -1}, {0x4000, 4, 2}, - {0x3000, 4, 1}, {0x2000, 4, -2}, {0x1c00, 6, 14}, {0x1800, 6,-14}, {0x1000, 5, 11}, - {0x0000, 4, -3} - }, { - {0xf800, 5, -6}, {0xf000, 5, 6}, {0xe000, 4, 1}, {0xd000, 4, -1}, {0xce00, 7, 10}, - {0xcc00, 7,-10}, {0xcb00, 8,-11}, {0xca80, 9,-12}, {0xca60,11, 13}, {0xca58,13, 15}, - {0xca50,13,-14}, {0xca48,13, 14}, {0xca40,13,-15}, {0xca00,10,-13}, {0xc900, 8, 11}, - {0xc800, 8, 12}, {0xc400, 6, -9}, {0xc000, 6, 9}, {0xb000, 4, -2}, {0xa000, 4, 2}, - {0x9000, 4, 3}, {0x8000, 4, -3}, {0x7800, 5, -7}, {0x7000, 5, 7}, {0x6000, 4, -4}, - {0x5000, 4, 4}, {0x4800, 5, -8}, {0x4000, 5, 8}, {0x3000, 4, 5}, {0x2000, 4, -5}, - {0x0000, 3, 0} - } -}; - -static const mpc_huffman mpc_table_HuffQ7 [2] [63] ICONST_ATTR = { - { - {0xfc00, 6, 7}, {0xf800, 6, 8}, {0xf400, 6, 9}, {0xf000, 6, -8}, {0xec00, 6, 11}, - {0xea00, 7, 21}, {0xe900, 8,-28}, {0xe800, 8, 28}, {0xe400, 6, -9}, {0xe200, 7,-22}, - {0xe000, 7,-21}, {0xdc00, 6,-10}, {0xd800, 6,-11}, {0xd400, 6, 10}, {0xd000, 6, 12}, - {0xcc00, 6,-13}, {0xca00, 7, 22}, {0xc800, 7, 23}, {0xc400, 6,-12}, {0xc000, 6, 13}, - {0xbc00, 6, 14}, {0xb800, 6,-14}, {0xb600, 7,-23}, {0xb500, 8,-29}, {0xb400, 8, 29}, - {0xb000, 6,-15}, {0xac00, 6, 15}, {0xa800, 6, 16}, {0xa400, 6,-16}, {0xa200, 7,-24}, - {0xa000, 7, 24}, {0x9c00, 6, 17}, {0x9a00, 7,-25}, {0x9900, 8,-30}, {0x9800, 8, 30}, - {0x9400, 6,-17}, {0x9000, 6, 18}, {0x8c00, 6,-18}, {0x8a00, 7, 25}, {0x8800, 7, 26}, - {0x8400, 6, 19}, {0x8200, 7,-26}, {0x8000, 7,-27}, {0x7800, 5, 2}, {0x7400, 6,-19}, - {0x7000, 6, 20}, {0x6800, 5, -1}, {0x6700, 8,-31}, {0x6600, 8, 31}, {0x6400, 7, 27}, - {0x6000, 6,-20}, {0x5800, 5, 1}, {0x5000, 5, -5}, {0x4800, 5, -3}, {0x4000, 5, 3}, - {0x3800, 5, 0}, {0x3000, 5, -2}, {0x2800, 5, -4}, {0x2000, 5, 4}, {0x1800, 5, 5}, - {0x1000, 5, -6}, {0x0800, 5, 6}, {0x0000, 5, -7} - }, { - {0xf800, 5, -1}, {0xf000, 5, 2}, {0xe800, 5, -2}, {0xe000, 5, 3}, {0xdf00, 8,-20}, - {0xdec0,10, 24}, {0xdebc,14, 28}, {0xdeb8,14,-28}, {0xdeb4,14,-30}, {0xdeb0,14, 30}, - {0xdea0,12,-27}, {0xde9c,14, 29}, {0xde98,14,-29}, {0xde94,14, 31}, {0xde90,14,-31}, - {0xde80,12, 27}, {0xde00, 9,-22}, {0xdc00, 7,-17}, {0xd800, 6,-11}, {0xd000, 5, -3}, - {0xc800, 5, 4}, {0xc000, 5, -4}, {0xbe00, 7, 17}, {0xbd00, 8, 20}, {0xbc80, 9, 22}, - {0xbc40,10,-25}, {0xbc00,10,-26}, {0xb800, 6, 12}, {0xb000, 5, 5}, {0xa800, 5, -5}, - {0xa000, 5, 6}, {0x9800, 5, -6}, {0x9400, 6,-12}, {0x9200, 7,-18}, {0x9000, 7, 18}, - {0x8c00, 6, 13}, {0x8800, 6,-13}, {0x8000, 5, -7}, {0x7c00, 6, 14}, {0x7b00, 8, 21}, - {0x7a00, 8,-21}, {0x7800, 7,-19}, {0x7000, 5, 7}, {0x6800, 5, 8}, {0x6400, 6,-14}, - {0x6000, 6,-15}, {0x5800, 5, -8}, {0x5400, 6, 15}, {0x5200, 7, 19}, {0x51c0,10, 25}, - {0x5180,10, 26}, {0x5100, 9,-23}, {0x5080, 9, 23}, {0x5000, 9,-24}, {0x4800, 5,-9}, - {0x4000, 5, 9}, {0x3c00, 6, 16}, {0x3800, 6,-16}, {0x3000, 5, 10}, {0x2000, 4, 0}, - {0x1800, 5,-10}, {0x1000, 5, 11}, {0x0000, 4, 1} - } -}; - -// sv8 huffman tables -static const mpc_huffman mpc_huff_SCFI_1 [3] ICONST_ATTR = { - {0x8000, 1, 1}, {0x4000, 2, 2}, {0x0, 3, 3} -}; // 3 -static const mpc_int8_t mpc_sym_SCFI_1 [4] ICONST_ATTR = { - 2, 3, 1, 0 -}; -static const mpc_huffman mpc_huff_SCFI_2 [5] ICONST_ATTR = { - {0x8000, 2, 3}, {0x4000, 3, 5}, {0x1800, 5, 11}, {0x400, 6, 14}, {0x0, 7, 15} -}; // 5 -static const mpc_int8_t mpc_sym_SCFI_2 [16] ICONST_ATTR = { - 15, 10, 14, 11, 13, 9, 7, 6, 5, 12, 8, 3, 2, 0, 4, 1 -}; - -static const mpc_huffman mpc_huff_DSCF_1 [12] ICONST_ATTR = { - {0xa000, 3, 7}, {0x4000, 4, 12}, {0x2800, 5, 16}, {0x1800, 6, 21}, - {0x0e00, 7, 27}, {0x0700, 8, 34}, {0x0380, 9, 41}, {0x0140, 10, 48}, - {0x0080, 11, 53}, {0x0030, 12, 57}, {0x0018, 13, 60}, {0x0000, 14, 63} -}; // 12 -static const mpc_int8_t mpc_sym_DSCF_1 [64] ICONST_ATTR = { - 35, 34, 33, 36, 32, 30, 29, 27, 26, 37, 28, 25, 39, 38, 24, 23, - 40, 22, 21, 20, 19, 43, 42, 41, 18, 17, 16, 15, 46, 45, 44, 14, - 13, 12, 11, 49, 48, 47, 31, 10, 9, 8, 7, 6, 52, 51, 50, 5, - 4, 3, 54, 53, 2, 1, 0, 57, 56, 55, 63, 62, 61, 60, 59, 58 -}; -static const mpc_huffman mpc_huff_DSCF_2 [13] ICONST_ATTR = { - {0x6000, 3, 7}, {0x3000, 4, 10}, {0x1800, 5, 13}, {0x1000, 6, 16}, - {0x0a00, 7, 20}, {0x0600, 8, 25}, {0x0380, 9, 31}, {0x01c0, 10, 38}, - {0x00e0, 11, 45}, {0x0050, 12, 52}, {0x0020, 13, 57}, {0x000c, 14, 61}, - {0x0000, 15, 64} -}; // 13 -static const mpc_int8_t mpc_sym_DSCF_2 [65] ICONST_ATTR = { - 33, 32, 31, 30, 29, 34, 28, 27, 36, 35, 26, 37, 25, 38, 24, 23, - 40, 39, 22, 21, 42, 41, 20, 19, 18, 45, 44, 43, 17, 16, 15, 14, - 48, 47, 46, 13, 12, 11, 10, 64, 52, 51, 50, 49, 9, 8, 7, 6, - 55, 54, 53, 5, 4, 3, 58, 57, 56, 2, 1, 63, 62, 61, 60, 59, - 0 -}; - -static const mpc_huffman mpc_huff_Bands [12] ICONST_ATTR = { - {0x8000, 1, 1}, {0x4000, 2, 2}, {0x2000, 3, 3}, {0x1000, 5, 6}, - {0x0800, 6, 8}, {0x0600, 7, 10}, {0x0300, 8, 13}, {0x0200, 9, 16}, - {0x0140, 10, 20}, {0x00c0, 11, 25}, {0x0010, 12, 31}, {0x0000, 13, 32} -}; // 12 -static const mpc_int8_t mpc_sym_Bands [33] ICONST_ATTR = { - 0, 32, 1, 31, 2, 30, 3, 4, 29, 6, 5, 28, 7, 27, 26, 8, - 25, 24, 23, 9, 22, 21, 20, 18, 17, 16, 15, 14, 12, 11, 10, 19, - 13 -}; - -static const mpc_huffman mpc_huff_Res_1 [16] ICONST_ATTR = { - {0x8000, 1, 1}, {0x4000, 2, 2}, {0x2000, 3, 3}, {0x1000, 4, 4}, - {0x0800, 5, 5}, {0x0400, 6, 6}, {0x0200, 7, 7}, {0x0100, 8, 8}, - {0x0080, 9, 9}, {0x0040, 10, 10}, {0x0020, 11, 11}, {0x0010, 12, 12}, - {0x0008, 13, 13}, {0x0004, 14, 14}, {0x0002, 15, 15}, {0x0000, 16, 16} -}; // 16 -static const mpc_int8_t mpc_sym_Res_1 [17] ICONST_ATTR = { - 0, 1, 16, 2, 3, 4, 5, 15, 6, 7, 8, 9, 10, 11, 12, 14, 13 -}; -static const mpc_huffman mpc_huff_Res_2 [12] ICONST_ATTR = { - {0x4000, 2, 3}, {0x2000, 3, 4}, {0x1000, 4, 5}, {0x0800, 5, 6}, - {0x0400, 6, 7}, {0x0200, 7, 8}, {0x0100, 8, 9}, {0x0080, 9, 10}, - {0x0040, 10, 11}, {0x0020, 11, 12}, {0x0010, 12, 13}, {0x0000, 14, 16} -}; // 12 -static const mpc_int8_t mpc_sym_Res_2 [17] ICONST_ATTR = { - 16, 1, 0, 2, 15, 3, 14, 4, 5, 13, 6, 12, 7, 11, 10, 9, 8 -}; - -static const mpc_huffman mpc_huff_Q1 [10] ICONST_ATTR = { - {0x6000, 3, 7}, {0x1000, 4, 10}, {0x0800, 5, 11}, {0x0400, 6, 12}, - {0x0200, 7, 13}, {0x0100, 8, 14}, {0x0080, 9, 15}, {0x0040, 10, 16}, - {0x0020, 11, 17}, {0x0000, 12, 18} -}; // 10 -static const mpc_int8_t mpc_sym_Q1 [19] ICONST_ATTR = { - 7, 6, 5, 4, 3, 10, 9, 8, 2, 1, 11, 0, 12, 13, 14, 15, 16, 18, 17 -}; - -static const mpc_huffman mpc_huff_Q2_1 [10] ICONST_ATTR = { - {0xe000, 3, 7}, {0x8000, 4, 14}, {0x3c00, 6, 38}, {0x2a00, 7, 53}, - {0x1200, 8, 74}, {0x0600, 9, 92}, {0x03c0, 10,104}, {0x0060, 11,119}, - {0x0020, 12,122}, {0x0000, 13,124} -}; // 10 -static const mpc_int8_t mpc_sym_Q2_1 [125] ICONST_ATTR = { - 62, 87, 67, 63, 61, 57, 37, 93, 92, 88, 86, 83, 82, 81, 68, 66, 58, 56, 42, 41, 38, 36, 32, 31,112, - 91, 72, 64, 60, 52, 43, 33, 12,117,113,111,107, 97, 89, 85, 77, 73, 71, 69, 65, 59, 55, 53, 51, 47, - 39, 35, 27, 17, 13, 11, 7,118,116,108,106, 98, 96, 94, 90, 84, 80, 78, 76, 48, 46, 44, 40, 34, 30, - 28, 26, 18, 16, 8, 6,122,110,102, 74, 70, 54, 50, 22, 2,123,121,119,115,114,109,105,103,101, 99, - 95, 79, 75, 49, 45, 29, 25, 23, 21, 19, 15, 14, 10, 9, 5, 3, 1,124,104, 20, 0,120,100, 24, 4 -}; -static const mpc_huffman mpc_huff_Q2_2 [9] ICONST_ATTR = { - {0xf000, 4, 15}, {0x7000, 5, 30}, {0x4800, 6, 44}, - {0x3c00, 7, 62}, {0x0c00, 8, 92}, {0x0780, 9,104}, - {0x00c0, 10,119}, {0x0040, 11,122}, {0x0000, 12,124} -}; // 9 -static const mpc_int8_t mpc_sym_Q2_2 [125] ICONST_ATTR = { - 62, 92, 87, 86, 82, 68, 67, 66, 63, 61, 58, 57, 56, 42, 38, 37, 32, 93, 91, 88, 83, 81, 43, 41, 36, - 33, 31,112, 72, 64, 60, 52, 12,118,117,116,113,111,108,107,106, 98, 97, 96, 94, 90, 89, 85, 84, 80, - 78, 77, 76, 73, 71, 69, 65, 59, 55, 53, 51, 48, 47, 46, 44, 40, 39, 35, 34, 30, 28, 27, 26, 18, 17, - 16, 13, 11, 8, 7, 6,122,110, 74, 70, 54, 50, 22, 14, 2,123,121,119,115,114,109,105,103,102,101, - 99, 95, 79, 75, 49, 45, 29, 25, 23, 21, 19, 15, 10, 9, 5, 3, 1,124,104, 20, 0,120,100, 24, 4 -}; - -static const mpc_huffman mpc_huff_Q3 [7] ICONST_ATTR = { - {0xe000, 3, 7}, {0x8000, 4, 14}, {0x5000, 5, 22}, {0x2400, 6, 32}, - {0x0a00, 7, 41}, {0x0200, 8, 46}, {0x0000, 9, 48} -}; // 7 -static const mpc_int8_t mpc_sym_Q3 [49] ICONST_ATTR = { - 0, 17, 16, 1, 15,-16, -1, - 32, 31, 2, 14,-15,-32, 34, - 33, 47, 46, 18, 30,-14, -2, - -31,-17,-18, 49, 48, 63, 19, - 29, 3, 13,-13, -3,-30,-47, - -48,-33, 50, 62, 35, 45,-29, - -19,-46,-34, 51, 61,-45,-35 -}; - -static const mpc_huffman mpc_huff_Q4 [8] ICONST_ATTR = { - {0xf000, 4, 15}, {0x9000, 5, 30}, {0x3400, 6, 48}, {0x1800, 7, 61}, - {0x0500, 8, 73}, {0x0100, 9, 78}, {0x0000, 10, 80}, {0x0000, 0, 90} -}; // 8 -static const mpc_int8_t mpc_sym_Q4 [91] ICONST_ATTR = { - 0, 32, 17, 16, 31, 2, 1, 15, 14,-15,-16, -1,-32, 49, 48, - 34, 33, 47, 46, 19, 18, 30, 29, 3, 13,-13,-14, -2, -3,-30, - -31,-17,-18,-47,-48,-33, 64, 50, 63, 62, 35, 45, 4, 12,-29, - -19,-46,-34,-64,-49, 66, 65, 79, 78, 51, 61, 36, 44, 20, 28, - -12, -4,-28,-20,-45,-35,-62,-63,-50, 67, 77, 52, 60,-44,-36, - -61,-51, 68, 76,-60,-52, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0 -}; - -static const mpc_huffman mpc_huff_Q5_1 [6] ICONST_ATTR = { - {0xc000, 2, 3}, {0x4000, 3, 6}, {0x2000, 4, 8}, - {0x1000, 5, 10}, {0x0800, 6, 12}, {0x0000, 7, 14} -}; // 6 -static const mpc_int8_t mpc_sym_Q5_1 [15] ICONST_ATTR = { - 0, 2, 1, -1, -2, 3, -3, 4, -4, 5, -5, 7, 6, -6, -7 -}; -static const mpc_huffman mpc_huff_Q5_2 [4] ICONST_ATTR = { - {0x6000, 3, 7}, {0x2000, 4, 10}, {0x1000, 5, 12}, {0x0, 6, 14} -}; // 4 -static const mpc_int8_t mpc_sym_Q5_2 [15] ICONST_ATTR = { - 2, 1, 0, -1, -2, 4, 3, -3, -4, 5, -5, 7, 6, -6, -7 -}; - -static const mpc_huffman mpc_huff_Q6_1 [8] ICONST_ATTR = { - {0xc000, 2, 3}, {0x8000, 3, 6}, {0x4000, 4, 10}, {0x2800, 5, 14}, - {0x0c00, 6, 19}, {0x0800, 7, 22}, {0x0400, 8, 26}, {0x0000, 9, 30} -}; // 8 -static const mpc_int8_t mpc_sym_Q6_1 [31] ICONST_ATTR = { - 0, 1, -1, 3, 2, -2, -3, 4, -4, -5, 8, 7, 6, 5, -6, - -7, -8, 9, -9, 11, 10,-10,-11, 15, 14, 13, 12,-12,-13,-14, - -15 -}; -static const mpc_huffman mpc_huff_Q6_2 [5] ICONST_ATTR = { - {0x5000, 4, 15}, {0x2000, 5, 20}, {0x1000, 6, 24}, {0x400, 7, 28}, {0x0, 8, 30} -}; // 5 -static const mpc_int8_t mpc_sym_Q6_2 [31] ICONST_ATTR = { - 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, 8, 7, 6, -6, - -7, -8, 10, 9, -9,-10, 13, 12, 11,-11,-12,-13, 15, 14,-14, - -15 -}; - -static const mpc_huffman mpc_huff_Q7_1 [9] ICONST_ATTR_MPC_LARGE_IRAM = { - {0xc000, 2, 3}, {0x8000, 3, 6}, {0x6000, 4, 10}, - {0x4000, 5, 16}, {0x2800, 6, 24}, {0x1400, 7, 34}, - {0x0a00, 8, 44}, {0x0400, 9, 54}, {0x0000, 10, 62} -}; // 9 -static const mpc_int8_t mpc_sym_Q7_1 [63] ICONST_ATTR_MPC_LARGE_IRAM = { - 0, 1, -1, 2, -2, 4, 3, -3, -4, 7, 6, 5, -5, -6, -7, - 13, 11, 10, 9, 8, -8, -9,-10,-11,-12, 17, 16, 15, 14, 12, - -13,-14,-15,-16,-17, 28, 27, 21, 20, 19, 18,-18,-19,-20,-21, - -27,-28, 31, 30, 29, 26, 25, 24, 23, 22,-22,-23,-24,-25,-26, - -29,-30,-31 -}; -static const mpc_huffman mpc_huff_Q7_2 [5] ICONST_ATTR_MPC_LARGE_IRAM = { - {0x6000, 5, 31}, {0x2400, 6, 43}, {0x1000, 7, 52}, {0x200, 8, 60}, {0x0, 9, 62} -}; // 5 -static const mpc_int8_t mpc_sym_Q7_2 [63] ICONST_ATTR_MPC_LARGE_IRAM = { - 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, - -5, -6, -7, -8, -9, 17, 16, 15, 14, 13, 12, 11,-10,-11,-12, - -13,-14,-15,-16,-17, 22, 21, 20, 19, 18,-18,-19,-20,-21,-22, - 29, 28, 27, 26, 25, 24, 23,-23,-24,-25,-26,-27,-28,-29, 31, - 30,-30,-31 -}; - -static const mpc_huffman mpc_huff_Q8_1 [11] ICONST_ATTR_MPC_LARGE_IRAM = { - {0xc000, 2, 3}, {0x8000, 3, 6}, {0x7000, 4, 10}, {0x5800, 5, 17}, - {0x3800, 6, 28}, {0x2800, 7, 42}, {0x1900, 8, 62}, {0x0d00, 9, 87}, - {0x0280, 10,113}, {0x0060, 11,123}, {0x0000, 12,126} -}; // 11 -static const mpc_int8_t mpc_sym_Q8_1 [127] ICONST_ATTR_MPC_LARGE_IRAM = { - 0, 1, -1, -2, 3, 2, -3, 7, 6, 5, 4, -4, -5, -6, -7, 11, 10, 9, 8, -8, - -9,-10,-11, 19, 18, 17, 16, 15, 14, 13, 12,-12,-13,-14,-15,-16,-17,-19, 56, 55, - 31, 28, 27, 26, 25, 24, 23, 22, 21, 20,-18,-20,-21,-22,-23,-24,-25,-26,-27,-33, - -54,-56, 63, 62, 61, 60, 59, 58, 57, 54, 53, 43, 40, 39, 38, 37, 36, 35, 34, 33, - 32, 30, 29,-28,-29,-30,-31,-32,-34,-35,-36,-37,-38,-39,-40,-41,-43,-53,-55,-57, - -58,-59,-60,-61, 49, 47, 46, 45, 44, 42, 41,-42,-44,-45,-46,-47,-48,-49,-50,-62, - -63, 52, 51, 50, 48,-51,-52 -}; -static const mpc_huffman mpc_huff_Q8_2 [4] ICONST_ATTR_MPC_LARGE_IRAM = { - {0x9800, 6, 63}, {0x2a00, 7, 101}, {0x400, 8, 122}, {0x0, 9, 126} -}; // 4 -static const mpc_int8_t mpc_sym_Q8_2 [127] ICONST_ATTR_MPC_LARGE_IRAM = { - 13, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, - -8, -9,-10,-11,-12,-13, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, - 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 12,-14,-15,-16,-17,-18,-19,-20, - -21,-22,-23,-24,-25,-26,-27,-28,-29,-30,-31,-32,-33,-34,-35,-36,-37,-38,-39,-40, - -41, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, - 40,-42,-43,-44,-45,-46,-47,-48,-49,-50,-51,-52,-53,-54,-55,-56,-57,-58,-59, 63, - 62, 61, 60,-60,-61,-62,-63 -}; - -static const mpc_huffman mpc_huff_Q9up [6] ICONST_ATTR_MPC_LARGE_IRAM = { - {0xf800, 6, 63}, {0xac00, 7,125}, {0x2600, 8, -45}, - {0x0280, 9, -7}, {0x0040, 10, -2}, {0x0000, 11, -1} -}; // 6 -static const mpc_int8_t mpc_sym_Q9up [256] ICONST_ATTR_MPC_LARGE_IRAM = { - -128, 127,-108,-110,-111,-112,-113,-114,-115,-116,-117,-118,-119,-120,-121,-122, - -123,-124,-125,-126,-127, 126, 125, 124, 123, 122, 121, 120, 119, 118, 117, 116, - 115, 114, 113, 112, 111, 110, 109, 108, -44, -45, -46, -47, -48, -49, -50, -51, - -52, -53, -54, -55, -56, -57, -58, -59, -60, -61, -62, -63, -64, -65, -66, -67, - -68, -69, -70, -71, -72, -73, -74, -75, -76, -77, -78, -79, -80, -81, -82, -83, - -84, -85, -86, -87, -88, -89, -90, -91, -92, -93, -94, -95, -96, -97, -98, -99, - -100,-101,-102,-103,-104,-105,-106,-107,-109, 107, 106, 105, 104, 103, 102, 101, - 100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, - 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, - 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, - 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 40, 20, 19, -7, -8, - -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -20, -21, -22, -23, -24, - -25, -26, -27, -28, -29, -30, -31, -32, -33, -34, -35, -36, -37, -38, -39, -40, - -41, -42, -43, 41, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, - 27, 26, 25, 24, 23, 22, 21, 18, 17, 16, 15, 14, 13, 12, 11, 10, - 9, 8, 7, 6, 5, -3, -4, -5, -6, 4, 3, 2, 1, 0, -1, -2 -}; - -/* sv7 lookup tables */ -mpc_lut_data mpc_HuffHdr IBSS_ATTR_MPC_LARGE_IRAM; -mpc_lut_data mpc_HuffDSCF IBSS_ATTR_MPC_LARGE_IRAM; -mpc_lut_data mpc_HuffQ [7] [2] IBSS_ATTR_MPC_LARGE_IRAM; - -/* sv8 lookup tables */ -mpc_can_data mpc_can_SCFI[2] IBSS_ATTR_MPC_LARGE_IRAM; -mpc_can_data mpc_can_DSCF[2] IBSS_ATTR_MPC_LARGE_IRAM; -mpc_can_data mpc_can_Bands IBSS_ATTR_MPC_LARGE_IRAM; -mpc_can_data mpc_can_Res[2] IBSS_ATTR_MPC_LARGE_IRAM; -mpc_can_data mpc_can_Q1 IBSS_ATTR_MPC_LARGE_IRAM; -mpc_can_data mpc_can_Q9up IBSS_ATTR_MPC_LARGE_IRAM; -mpc_can_data mpc_can_Q [6][2] IBSS_ATTR_MPC_LARGE_IRAM; - -static void huff_fill_lut(const mpc_huffman *table, mpc_huff_lut *lut, const int bits) -{ - int i, idx = 0; - const int shift = 16 - bits; - for (i = (1 << bits) - 1; i >= 0 ; i--) { - if ((table[idx].Code >> shift) < i) { - lut[i].Length = table[idx].Length; - lut[i].Value = table[idx].Value; - } else { - if (table[idx].Length <= bits) { - lut[i].Length = table[idx].Length; - lut[i].Value = table[idx].Value; - } else { - lut[i].Length = 0; - lut[i].Value = idx; - } - if (i != 0) - do { - idx++; - } while ((table[idx].Code >> shift) == i); - } - } -} - -static void can_fill_lut(mpc_can_data * data, const int bits) -{ - int i, idx = 0; - const int shift = 16 - bits; - const mpc_huffman * table = data->table; - const mpc_int8_t * sym = data->sym; - mpc_huff_lut * lut = data->lut; - for (i = (1 << bits) - 1; i >= 0 ; i--) { - if ((table[idx].Code >> shift) < i) { - if (table[idx].Length <= bits) { - lut[i].Length = table[idx].Length; - lut[i].Value = sym[(table[idx].Value - (i >> (bits - table[idx].Length))) & 0xFF]; - } else { - lut[i].Length = 0; - lut[i].Value = idx; - } - } else { - if (table[idx].Length <= bits) { - lut[i].Length = table[idx].Length; - lut[i].Value = sym[(table[idx].Value - (i >> (bits - table[idx].Length))) & 0xFF]; - } else { - lut[i].Length = 0; - lut[i].Value = idx; - } - if (i != 0) - do { - idx++; - } while ((table[idx].Code >> shift) == i); - } - } -} - -void huff_init_lut(const int bits) -{ - /* sv7: create vlc lookup tables */ - mpc_HuffDSCF.table = mpc_table_HuffDSCF ; huff_fill_lut(mpc_HuffDSCF.table , mpc_HuffDSCF.lut , bits); - mpc_HuffHdr.table = mpc_table_HuffHdr ; huff_fill_lut(mpc_HuffHdr.table , mpc_HuffHdr.lut , bits); - mpc_HuffQ[0][0].table = mpc_table_HuffQ1[0]; huff_fill_lut(mpc_HuffQ[0][0].table, mpc_HuffQ[0][0].lut, bits); - mpc_HuffQ[0][1].table = mpc_table_HuffQ1[1]; huff_fill_lut(mpc_HuffQ[0][1].table, mpc_HuffQ[0][1].lut, bits); - mpc_HuffQ[1][0].table = mpc_table_HuffQ2[0]; huff_fill_lut(mpc_HuffQ[1][0].table, mpc_HuffQ[1][0].lut, bits); - mpc_HuffQ[1][1].table = mpc_table_HuffQ2[1]; huff_fill_lut(mpc_HuffQ[1][1].table, mpc_HuffQ[1][1].lut, bits); - mpc_HuffQ[2][0].table = mpc_table_HuffQ3[0]; huff_fill_lut(mpc_HuffQ[2][0].table, mpc_HuffQ[2][0].lut, bits); - mpc_HuffQ[2][1].table = mpc_table_HuffQ3[1]; huff_fill_lut(mpc_HuffQ[2][1].table, mpc_HuffQ[2][1].lut, bits); - mpc_HuffQ[3][0].table = mpc_table_HuffQ4[0]; huff_fill_lut(mpc_HuffQ[3][0].table, mpc_HuffQ[3][0].lut, bits); - mpc_HuffQ[3][1].table = mpc_table_HuffQ4[1]; huff_fill_lut(mpc_HuffQ[3][1].table, mpc_HuffQ[3][1].lut, bits); - mpc_HuffQ[4][0].table = mpc_table_HuffQ5[0]; huff_fill_lut(mpc_HuffQ[4][0].table, mpc_HuffQ[4][0].lut, bits); - mpc_HuffQ[4][1].table = mpc_table_HuffQ5[1]; huff_fill_lut(mpc_HuffQ[4][1].table, mpc_HuffQ[4][1].lut, bits); - mpc_HuffQ[5][0].table = mpc_table_HuffQ6[0]; huff_fill_lut(mpc_HuffQ[5][0].table, mpc_HuffQ[5][0].lut, bits); - mpc_HuffQ[5][1].table = mpc_table_HuffQ6[1]; huff_fill_lut(mpc_HuffQ[5][1].table, mpc_HuffQ[5][1].lut, bits); - mpc_HuffQ[6][0].table = mpc_table_HuffQ7[0]; huff_fill_lut(mpc_HuffQ[6][0].table, mpc_HuffQ[6][0].lut, bits); - mpc_HuffQ[6][1].table = mpc_table_HuffQ7[1]; huff_fill_lut(mpc_HuffQ[6][1].table, mpc_HuffQ[6][1].lut, bits); - - /* sv8: create vlc lookup tables */ - mpc_can_Bands.table = mpc_huff_Bands ; mpc_can_Bands.sym = mpc_sym_Bands; - mpc_can_SCFI[0].table = mpc_huff_SCFI_1; mpc_can_SCFI[0].sym = mpc_sym_SCFI_1; can_fill_lut(&mpc_can_SCFI[0], bits); - mpc_can_SCFI[1].table = mpc_huff_SCFI_2; mpc_can_SCFI[1].sym = mpc_sym_SCFI_2; can_fill_lut(&mpc_can_SCFI[1], bits); - mpc_can_DSCF[0].table = mpc_huff_DSCF_1; mpc_can_DSCF[0].sym = mpc_sym_DSCF_1; can_fill_lut(&mpc_can_DSCF[0], bits); - mpc_can_DSCF[1].table = mpc_huff_DSCF_2; mpc_can_DSCF[1].sym = mpc_sym_DSCF_2; can_fill_lut(&mpc_can_DSCF[1], bits); - mpc_can_Res[0].table = mpc_huff_Res_1 ; mpc_can_Res[0].sym = mpc_sym_Res_1 ; can_fill_lut(&mpc_can_Res[0] , bits); - mpc_can_Res[1].table = mpc_huff_Res_2 ; mpc_can_Res[1].sym = mpc_sym_Res_2 ; can_fill_lut(&mpc_can_Res[1] , bits); - mpc_can_Q1.table = mpc_huff_Q1 ; mpc_can_Q1.sym = mpc_sym_Q1 ; can_fill_lut(&mpc_can_Q1 , bits); - mpc_can_Q9up.table = mpc_huff_Q9up ; mpc_can_Q9up.sym = mpc_sym_Q9up ; can_fill_lut(&mpc_can_Q9up , bits); - mpc_can_Q[0][0].table = mpc_huff_Q2_1 ; mpc_can_Q[0][0].sym = mpc_sym_Q2_1 ; can_fill_lut(&mpc_can_Q[0][0], bits); - mpc_can_Q[0][1].table = mpc_huff_Q2_2 ; mpc_can_Q[0][1].sym = mpc_sym_Q2_2 ; can_fill_lut(&mpc_can_Q[0][1], bits); - mpc_can_Q[1][0].table = mpc_huff_Q3 ; mpc_can_Q[1][0].sym = mpc_sym_Q3 ; can_fill_lut(&mpc_can_Q[1][0], bits); - mpc_can_Q[1][1].table = mpc_huff_Q4 ; mpc_can_Q[1][1].sym = mpc_sym_Q4 ; can_fill_lut(&mpc_can_Q[1][1], bits); - mpc_can_Q[2][0].table = mpc_huff_Q5_1 ; mpc_can_Q[2][0].sym = mpc_sym_Q5_1 ; can_fill_lut(&mpc_can_Q[2][0], bits); - mpc_can_Q[2][1].table = mpc_huff_Q5_2 ; mpc_can_Q[2][1].sym = mpc_sym_Q5_2 ; can_fill_lut(&mpc_can_Q[2][1], bits); - mpc_can_Q[3][0].table = mpc_huff_Q6_1 ; mpc_can_Q[3][0].sym = mpc_sym_Q6_1 ; can_fill_lut(&mpc_can_Q[3][0], bits); - mpc_can_Q[3][1].table = mpc_huff_Q6_2 ; mpc_can_Q[3][1].sym = mpc_sym_Q6_2 ; can_fill_lut(&mpc_can_Q[3][1], bits); - mpc_can_Q[4][0].table = mpc_huff_Q7_1 ; mpc_can_Q[4][0].sym = mpc_sym_Q7_1 ; can_fill_lut(&mpc_can_Q[4][0], bits); - mpc_can_Q[4][1].table = mpc_huff_Q7_2 ; mpc_can_Q[4][1].sym = mpc_sym_Q7_2 ; can_fill_lut(&mpc_can_Q[4][1], bits); - mpc_can_Q[5][0].table = mpc_huff_Q8_1 ; mpc_can_Q[5][0].sym = mpc_sym_Q8_1 ; can_fill_lut(&mpc_can_Q[5][0], bits); - mpc_can_Q[5][1].table = mpc_huff_Q8_2 ; mpc_can_Q[5][1].sym = mpc_sym_Q8_2 ; can_fill_lut(&mpc_can_Q[5][1], bits); -} diff --git a/apps/codecs/libmusepack/huffman.h b/apps/codecs/libmusepack/huffman.h deleted file mode 100644 index 1244149184..0000000000 --- a/apps/codecs/libmusepack/huffman.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - Copyright (c) 2005-2009, The Musepack Development Team - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are - met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - - * Neither the name of the The Musepack Development Team nor the - names of its contributors may be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -/// \file huffman.h -/// Data structures and functions for huffman coding. - -#ifndef _MPCDEC_HUFFMAN_H_ -#define _MPCDEC_HUFFMAN_H_ -#ifdef WIN32 -#pragma once -#endif - -#include "mpc_types.h" - -#ifdef __cplusplus -extern "C" { -#endif - -// LUT size parameter, LUT size is 1 << LUT_DEPTH -#define LUT_DEPTH 6 - -/// Huffman table entry. -typedef struct mpc_huffman_t { - mpc_uint16_t Code; - mpc_uint8_t Length; - mpc_int8_t Value; -} mpc_huffman; - -/// Huffman LUT entry. -typedef struct mpc_huff_lut_t { - mpc_uint8_t Length; - mpc_int8_t Value; -} mpc_huff_lut; - -/// Type used for huffman LUT decoding -typedef struct mpc_lut_data_t { - mpc_huffman const *table; - mpc_huff_lut lut[1 << LUT_DEPTH]; -} mpc_lut_data; - -/// Type used for canonical huffman decoding -typedef struct mpc_can_data_t { - mpc_huffman const *table; - mpc_int8_t const *sym; - mpc_huff_lut lut[1 << LUT_DEPTH]; -} mpc_can_data; - -void huff_init_lut(const int bits); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/apps/codecs/libmusepack/internal.h b/apps/codecs/libmusepack/internal.h deleted file mode 100644 index 897e6a7b17..0000000000 --- a/apps/codecs/libmusepack/internal.h +++ /dev/null @@ -1,123 +0,0 @@ -/* - Copyright (c) 2005-2009, The Musepack Development Team - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are - met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - - * Neither the name of the The Musepack Development Team nor the - names of its contributors may be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -/// \file internal.h -/// Definitions and structures used only internally by the libmpcdec. -#ifndef _MPCDEC_INTERNAL_H_ -#define _MPCDEC_INTERNAL_H_ -#ifdef WIN32 -#pragma once -#endif -#ifdef __cplusplus -extern "C" { -#endif - -#include "mpcdec.h" - -/* rockbox: not used, rockbox's swap32 is used now. -/// Big/little endian 32 bit byte swapping routine. -static mpc_inline -mpc_uint32_t mpc_swap32(mpc_uint32_t val) { - return (((val & 0xFF000000) >> 24) | ((val & 0x00FF0000) >> 8) - | ((val & 0x0000FF00) << 8) | ((val & 0x000000FF) << 24)); -} -*/ -typedef struct mpc_block_t { - char key[2]; // block key - mpc_uint64_t size; // block size minus the block header size -} mpc_block; - -#define MAX_FRAME_SIZE 4352 -#define DEMUX_BUFFER_SIZE (32768 - MAX_FRAME_SIZE) // need some space as sand box - -struct mpc_demux_t { - mpc_reader * r; - mpc_decoder * d; - mpc_streaminfo si; - - // buffer - mpc_uint8_t *buffer; - mpc_size_t bytes_total; - mpc_bits_reader bits_reader; - mpc_int32_t block_bits; /// bits remaining in current audio block - mpc_uint_t block_frames; /// frames remaining in current audio block - - // seeking - mpc_seek_t * seek_table; - mpc_uint_t seek_pwr; /// distance between 2 frames in seek_table = 2^seek_pwr - mpc_uint32_t seek_table_size; /// used size in seek_table - - // chapters -/* rockbox: not used - mpc_seek_t chap_pos; /// supposed position of the first chapter block - mpc_int_t chap_nb; /// number of chapters (-1 if unknown, 0 if no chapter) - mpc_chap_info * chap; /// chapters position and tag -*/ -}; - -/** - * checks if a block key is valid - * @param key the two caracters key to check - * @return MPC_STATUS_FAIL if the key is invalid, MPC_STATUS_OK else - */ -static mpc_inline mpc_status mpc_check_key(char * key) -{ - if (key[0] < 65 || key[0] > 90 || key[1] < 65 || key[1] > 90) - return MPC_STATUS_FAIL; - return MPC_STATUS_OK; -} - -/// helper functions used by multiple files -mpc_uint32_t mpc_random_int(mpc_decoder *d); // in synth_filter.c -void mpc_decoder_init_quant(mpc_decoder *d, MPC_SAMPLE_FORMAT factor); // in requant.c -void mpc_decoder_synthese_filter_float(mpc_decoder *d, MPC_SAMPLE_FORMAT* OutData, mpc_int_t channels); -unsigned long mpc_crc32(unsigned char *buf, int len); - -// streaminfo.c -mpc_status streaminfo_read_header_sv8(mpc_streaminfo* si, - const mpc_bits_reader * r_in, - mpc_size_t block_size); -mpc_status streaminfo_read_header_sv7(mpc_streaminfo* si, mpc_bits_reader * r_in); -void streaminfo_encoder_info(mpc_streaminfo* si, const mpc_bits_reader * r_in); -void streaminfo_gain(mpc_streaminfo* si, const mpc_bits_reader * r_in); - -// mpc_decoder.c -void mpc_decoder_reset_scf(mpc_decoder * d, int value); - -#define MPC_IS_FAILURE(X) ((int)(X) < (int)MPC_STATUS_OK) -#define MPC_AUTO_FAIL(X) { mpc_status s = (X); if (MPC_IS_FAILURE(s)) return s; } - -#ifdef __cplusplus -} -#endif -#endif diff --git a/apps/codecs/libmusepack/libmusepack.make b/apps/codecs/libmusepack/libmusepack.make deleted file mode 100644 index ac201c4552..0000000000 --- a/apps/codecs/libmusepack/libmusepack.make +++ /dev/null @@ -1,18 +0,0 @@ -# __________ __ ___. -# Open \______ \ ____ ____ | | _\_ |__ _______ ___ -# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / -# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < -# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ -# \/ \/ \/ \/ \/ -# $Id$ -# - -# libmusepack -MUSEPACKLIB := $(CODECDIR)/libmusepack.a -MUSEPACKLIB_SRC := $(call preprocess, $(APPSDIR)/codecs/libmusepack/SOURCES) -MUSEPACKLIB_OBJ := $(call c2obj, $(MUSEPACKLIB_SRC)) -OTHER_SRC += $(MUSEPACKLIB_SRC) - -$(MUSEPACKLIB): $(MUSEPACKLIB_OBJ) - $(SILENT)$(shell rm -f $@) - $(call PRINTS,AR $(@F))$(AR) rcs $@ $^ >/dev/null diff --git a/apps/codecs/libmusepack/minimax.h b/apps/codecs/libmusepack/minimax.h deleted file mode 100644 index 1192626567..0000000000 --- a/apps/codecs/libmusepack/minimax.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Musepack audio compression - * Copyright (C) 1999-2004 Buschmann/Klemm/Piecha/Wolf - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#pragma once - -# define clip(x,min,max) ( (x) < (min) ? (min) : (x) > (max) ? (max) : (x) ) - -#ifdef __cplusplus - -# define maxi(A,B) ( (A) >? (B) ) -# define mini(A,B) ( (A) ? (B) ) -# define mind(A,B) ( (A) ? (B) ) -# define minf(A,B) ( (A) (B) ? (A) : (B) ) -# define mini(A,B) ( (A) < (B) ? (A) : (B) ) -# define maxd(A,B) ( (A) > (B) ? (A) : (B) ) -# define mind(A,B) ( (A) < (B) ? (A) : (B) ) -# define maxf(A,B) ( (A) > (B) ? (A) : (B) ) -# define minf(A,B) ( (A) < (B) ? (A) : (B) ) - -#endif - -#ifdef __GNUC__ - -# define absi(A) abs (A) -# define absf(A) fabsf (A) -# define absd(A) fabs (A) - -#else - -# define absi(A) ( (A) >= 0 ? (A) : -(A) ) -# define absf(A) ( (A) >= 0.f ? (A) : -(A) ) -# define absd(A) ( (A) >= 0. ? (A) : -(A) ) - -#endif - diff --git a/apps/codecs/libmusepack/mpc_bits_reader.c b/apps/codecs/libmusepack/mpc_bits_reader.c deleted file mode 100644 index c917ad510a..0000000000 --- a/apps/codecs/libmusepack/mpc_bits_reader.c +++ /dev/null @@ -1,181 +0,0 @@ -/* - Copyright (c) 2007-2009, The Musepack Development Team - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are - met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - - * Neither the name of the The Musepack Development Team nor the - names of its contributors may be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include "mpcdec.h" -#include "internal.h" -#include "huffman.h" -#include "mpc_bits_reader.h" - -const mpc_uint32_t Cnk[MAX_ENUM / 2][MAX_ENUM] ICONST_ATTR_MPC_BITSREADER = -{ - {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31}, - {0, 0, 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120, 136, 153, 171, 190, 210, 231, 253, 276, 300, 325, 351, 378, 406, 435, 465}, - {0, 0, 0, 1, 4, 10, 20, 35, 56, 84, 120, 165, 220, 286, 364, 455, 560, 680, 816, 969, 1140, 1330, 1540, 1771, 2024, 2300, 2600, 2925, 3276, 3654, 4060, 4495}, - {0, 0, 0, 0, 1, 5, 15, 35, 70, 126, 210, 330, 495, 715, 1001, 1365, 1820, 2380, 3060, 3876, 4845, 5985, 7315, 8855, 10626, 12650, 14950, 17550, 20475, 23751, 27405, 31465}, - {0, 0, 0, 0, 0, 1, 6, 21, 56, 126, 252, 462, 792, 1287, 2002, 3003, 4368, 6188, 8568, 11628, 15504, 20349, 26334, 33649, 42504, 53130, 65780, 80730, 98280, 118755, 142506, 169911}, - {0, 0, 0, 0, 0, 0, 1, 7, 28, 84, 210, 462, 924, 1716, 3003, 5005, 8008, 12376, 18564, 27132, 38760, 54264, 74613, 100947, 134596, 177100, 230230, 296010, 376740, 475020, 593775, 736281}, - {0, 0, 0, 0, 0, 0, 0, 1, 8, 36, 120, 330, 792, 1716, 3432, 6435, 11440, 19448, 31824, 50388, 77520, 116280, 170544, 245157, 346104, 480700, 657800, 888030, 1184040, 1560780, 2035800, 2629575}, - {0, 0, 0, 0, 0, 0, 0, 0, 1, 9, 45, 165, 495, 1287, 3003, 6435, 12870, 24310, 43758, 75582, 125970, 203490, 319770, 490314, 735471, 1081575, 1562275, 2220075, 3108105, 4292145, 5852925, 7888725}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 10, 55, 220, 715, 2002, 5005, 11440, 24310, 48620, 92378, 167960, 293930, 497420, 817190, 1307504, 2042975, 3124550, 4686825, 6906900, 10015005, 14307150, 20160075}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 11, 66, 286, 1001, 3003, 8008, 19448, 43758, 92378, 184756, 352716, 646646, 1144066, 1961256, 3268760, 5311735, 8436285, 13123110, 20030010, 30045015, 44352165}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 12, 78, 364, 1365, 4368, 12376, 31824, 75582, 167960, 352716, 705432, 1352078, 2496144, 4457400, 7726160, 13037895, 21474180, 34597290, 54627300, 84672315}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 13, 91, 455, 1820, 6188, 18564, 50388, 125970, 293930, 646646, 1352078, 2704156, 5200300, 9657700, 17383860, 30421755, 51895935, 86493225, 141120525}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 14, 105, 560, 2380, 8568, 27132, 77520, 203490, 497420, 1144066, 2496144, 5200300, 10400600, 20058300, 37442160, 67863915, 119759850, 206253075}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 15, 120, 680, 3060, 11628, 38760, 116280, 319770, 817190, 1961256, 4457400, 9657700, 20058300, 40116600, 77558760, 145422675, 265182525}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 16, 136, 816, 3876, 15504, 54264, 170544, 490314, 1307504, 3268760, 7726160, 17383860, 37442160, 77558760, 155117520, 300540195}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 17, 153, 969, 4845, 20349, 74613, 245157, 735471, 2042975, 5311735, 13037895, 30421755, 67863915, 145422675, 300540195} -}; - -const mpc_uint8_t Cnk_len[MAX_ENUM / 2][MAX_ENUM] ICONST_ATTR_MPC_BITSREADER = -{ - {0, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5}, - {0, 0, 2, 3, 4, 4, 5, 5, 6, 6, 6, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9}, - {0, 0, 0, 2, 4, 5, 6, 6, 7, 7, 8, 8, 9, 9, 9, 10, 10, 10, 10, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 13, 13}, - {0, 0, 0, 0, 3, 4, 6, 7, 7, 8, 9, 9, 10, 10, 11, 11, 12, 12, 12, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 15, 16}, - {0, 0, 0, 0, 0, 3, 5, 6, 7, 8, 9, 10, 11, 11, 12, 13, 13, 14, 14, 14, 15, 15, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18}, - {0, 0, 0, 0, 0, 0, 3, 5, 7, 8, 9, 10, 11, 12, 13, 13, 14, 15, 15, 16, 16, 17, 17, 18, 18, 18, 19, 19, 19, 20, 20, 20}, - {0, 0, 0, 0, 0, 0, 0, 3, 6, 7, 9, 10, 11, 12, 13, 14, 15, 15, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 21, 22, 22}, - {0, 0, 0, 0, 0, 0, 0, 0, 4, 6, 8, 9, 11, 12, 13, 14, 15, 16, 17, 17, 18, 19, 19, 20, 21, 21, 22, 22, 23, 23, 23, 24}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 6, 8, 10, 11, 13, 14, 15, 16, 17, 18, 19, 19, 20, 21, 21, 22, 23, 23, 24, 24, 25, 25}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 7, 9, 10, 12, 13, 15, 16, 17, 18, 19, 20, 21, 21, 22, 23, 24, 24, 25, 25, 26, 26}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 7, 9, 11, 13, 14, 15, 17, 18, 19, 20, 21, 22, 23, 23, 24, 25, 26, 26, 27, 27}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 7, 9, 11, 13, 15, 16, 17, 19, 20, 21, 22, 23, 24, 25, 25, 26, 27, 28, 28}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 7, 10, 12, 14, 15, 17, 18, 19, 21, 22, 23, 24, 25, 26, 27, 27, 28, 29}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 7, 10, 12, 14, 16, 17, 19, 20, 21, 23, 24, 25, 26, 27, 28, 28, 29}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 8, 10, 12, 14, 16, 18, 19, 21, 22, 23, 25, 26, 27, 28, 29, 30}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 8, 10, 13, 15, 17, 18, 20, 21, 23, 24, 25, 27, 28, 29, 30} - -}; - -const mpc_uint32_t Cnk_lost[MAX_ENUM / 2][MAX_ENUM] ICONST_ATTR_MPC_BITSREADER = -{ - {0, 0, 1, 0, 3, 2, 1, 0, 7, 6, 5, 4, 3, 2, 1, 0, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0}, - {0, 0, 1, 2, 6, 1, 11, 4, 28, 19, 9, 62, 50, 37, 23, 8, 120, 103, 85, 66, 46, 25, 3, 236, 212, 187, 161, 134, 106, 77, 47, 16}, - {0, 0, 0, 0, 6, 12, 29, 8, 44, 8, 91, 36, 226, 148, 57, 464, 344, 208, 55, 908, 718, 508, 277, 24, 1796, 1496, 1171, 820, 442, 36, 3697, 3232}, - {0, 0, 0, 0, 3, 1, 29, 58, 2, 46, 182, 17, 309, 23, 683, 228, 1716, 1036, 220, 3347, 2207, 877, 7529, 5758, 3734, 1434, 15218, 12293, 9017, 5363, 1303, 29576}, - {0, 0, 0, 0, 0, 2, 11, 8, 2, 4, 50, 232, 761, 46, 1093, 3824, 2004, 7816, 4756, 880, 12419, 6434, 31887, 23032, 12406, 65292, 50342, 32792, 12317, 119638, 92233, 60768}, - {0, 0, 0, 0, 0, 0, 1, 4, 44, 46, 50, 100, 332, 1093, 3187, 184, 4008, 14204, 5636, 26776, 11272, 56459, 30125, 127548, 85044, 31914, 228278, 147548, 49268, 454801, 312295, 142384}, - {0, 0, 0, 0, 0, 0, 0, 0, 28, 8, 182, 232, 332, 664, 1757, 4944, 13320, 944, 15148, 53552, 14792, 91600, 16987, 178184, 43588, 390776, 160546, 913112, 536372, 61352, 1564729, 828448}, - {0, 0, 0, 0, 0, 0, 0, 0, 7, 19, 91, 17, 761, 1093, 1757, 3514, 8458, 21778, 55490, 5102, 58654, 204518, 33974, 313105, 1015577, 534877, 1974229, 1086199, 4096463, 2535683, 499883, 6258916}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 9, 36, 309, 46, 3187, 4944, 8458, 16916, 38694, 94184, 230358, 26868, 231386, 789648, 54177, 1069754, 3701783, 1481708, 6762211, 2470066, 13394357, 5505632}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 62, 226, 23, 1093, 184, 13320, 21778, 38694, 77388, 171572, 401930, 953086, 135896, 925544, 3076873, 8340931, 3654106, 13524422, 3509417, 22756699, 2596624}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 50, 148, 683, 3824, 4008, 944, 55490, 94184, 171572, 343144, 745074, 1698160, 3931208, 662448, 3739321, 12080252, 32511574, 12481564, 49545413, 5193248}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 37, 57, 228, 2004, 14204, 15148, 5102, 230358, 401930, 745074, 1490148, 3188308, 7119516, 16170572, 3132677, 15212929, 47724503, 127314931, 42642616}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 23, 464, 1716, 7816, 5636, 53552, 58654, 26868, 953086, 1698160, 3188308, 6376616, 13496132, 29666704, 66353813, 14457878, 62182381, 189497312}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 8, 344, 1036, 4756, 26776, 14792, 204518, 231386, 135896, 3931208, 7119516, 13496132, 26992264, 56658968, 123012781, 3252931, 65435312}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 120, 208, 220, 880, 11272, 91600, 33974, 789648, 925544, 662448, 16170572, 29666704, 56658968, 113317936, 236330717, 508019104}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15, 103, 55, 3347, 12419, 56459, 16987, 313105, 54177, 3076873, 3739321, 3132677, 66353813, 123012781, 236330717} -}; - -static const mpc_uint8_t log2[32] ICONST_ATTR_MPC_BITSREADER = -{ 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6}; - -static const mpc_uint8_t log2_lost[32] ICONST_ATTR_MPC_BITSREADER = -{ 0, 1, 0, 3, 2, 1, 0, 7, 6, 5, 4, 3, 2, 1, 0, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 31}; - -mpc_int32_t mpc_bits_golomb_dec(mpc_bits_reader * r, const mpc_uint_t k) -{ - unsigned int l = 0; - unsigned int code = r->buff[0] & ((1 << r->count) - 1); - - while( code == 0 ) { - l += r->count; - r->buff++; - code = r->buff[0]; - r->count = 8; - } - - while( ((1 << (r->count - 1)) & code) == 0 ) { - l++; - r->count--; - } - r->count--; - - while( r->count < k ) { - r->buff++; - r->count += 8; - code = (code << 8) | r->buff[0]; - } - - r->count -= k; - - return (l << k) | ((code >> r->count) & ((1 << k) - 1)); -} - -mpc_uint32_t mpc_bits_log_dec(mpc_bits_reader * r, mpc_uint_t max) -{ - mpc_uint32_t value = 0; - if (max == 0) - return 0; - if (log2[max - 1] > 1) - value = mpc_bits_read(r, log2[max - 1] - 1); - if (value >= log2_lost[max - 1]) - value = ((value << 1) | mpc_bits_read(r, 1)) - log2_lost[max - 1]; - return value; -} - -unsigned int mpc_bits_get_size(mpc_bits_reader * r, mpc_uint64_t * p_size) -{ - unsigned char tmp; - mpc_uint64_t size = 0; - unsigned int ret = 0; - - do { - tmp = mpc_bits_read(r, 8); - size = (size << 7) | (tmp & 0x7F); - ret++; - } while((tmp & 0x80)); - - *p_size = size; - return ret; -} - -int mpc_bits_get_block(mpc_bits_reader * r, mpc_block * p_block) -{ - int size = 2; - - p_block->size = 0; - p_block->key[0] = mpc_bits_read(r, 8); - p_block->key[1] = mpc_bits_read(r, 8); - - size += mpc_bits_get_size(r, &(p_block->size)); - - if (p_block->size >= (mpc_uint64_t)size) // check if the block size doesn't conflict with the header size - p_block->size -= (mpc_uint64_t)size; - - return size; -} - - - diff --git a/apps/codecs/libmusepack/mpc_bits_reader.h b/apps/codecs/libmusepack/mpc_bits_reader.h deleted file mode 100644 index 1233720c74..0000000000 --- a/apps/codecs/libmusepack/mpc_bits_reader.h +++ /dev/null @@ -1,175 +0,0 @@ -/* - Copyright (c) 2007-2009, The Musepack Development Team - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are - met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - - * Neither the name of the The Musepack Development Team nor the - names of its contributors may be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#define MAX_ENUM 32 - -MPC_API int mpc_bits_get_block(mpc_bits_reader * r, mpc_block * p_block); -mpc_int32_t mpc_bits_golomb_dec(mpc_bits_reader * r, const mpc_uint_t k); -MPC_API unsigned int mpc_bits_get_size(mpc_bits_reader * r, mpc_uint64_t * p_size); -mpc_uint32_t mpc_bits_log_dec(mpc_bits_reader * r, mpc_uint_t max); - -extern const mpc_uint32_t Cnk [MAX_ENUM / 2][MAX_ENUM]; -extern const mpc_uint8_t Cnk_len [MAX_ENUM / 2][MAX_ENUM]; -extern const mpc_uint32_t Cnk_lost[MAX_ENUM / 2][MAX_ENUM]; - -// can read up to 31 bits -static mpc_inline mpc_uint32_t mpc_bits_read(mpc_bits_reader * r, const unsigned int nb_bits) -{ - mpc_uint32_t ret; - - r->buff -= (int)(r->count - nb_bits) >> 3; - r->count = (r->count - nb_bits) & 0x07; - - ret = (r->buff[0] | (r->buff[-1] << 8)) >> r->count; - if (nb_bits > (16 - r->count)) { - ret |= (mpc_uint32_t)((r->buff[-2] << 16) | (r->buff[-3] << 24)) >> r->count; - if (nb_bits > 24 && r->count != 0) - ret |= r->buff[-4] << (32 - r->count); - } - - return ret & ((1 << nb_bits) - 1); -} - -#if defined(CPU_COLDFIRE) -/* rockbox: This is specific code to optimize demux performance on Coldfire - * CPUs. Coldfire CPUs are very sensible to RAM accesses. As the bitstream - * buffer does not fit into IRAM the read accesses to the uint8 buffer are very - * expensive in terms of CPU cycles. - * The following code uses two variables in IRAM. The variable last_code keeps - * the 4-byte value of buf[0]<<16 | buf[1]<<8 | buf[2]. As long as buf[0] will - * read from the same address the following code will avoid re-reading of the - * buffers. If buf[0] did advance to the next uint8-entry since the last call - * the following will only need to load 1 uint8-entry instead of 3. - */ -static mpc_inline mpc_uint16_t get_code_from_buffer(mpc_bits_reader *r) -{ - /* Buffer advanced by 1 entry since last call */ - if (r->buff == r->buffered_addr + 1) { - r->buffered_code = (r->buffered_code<<8) | r->buff[2]; - r->buffered_addr = r->buff; - } - /* Buffer must be fully re-read */ - else if (r->buff != r->buffered_addr) { - r->buffered_code = (r->buff[0] << 16) | (r->buff[1] << 8) | r->buff[2]; - r->buffered_addr = r->buff; - } - - return (mpc_uint16_t)((r->buffered_code >> r->count) & 0xFFFF); -} -#else -/* Use the decoder's default implementation. This is faster on non-Coldfire targets */ -#define get_code_from_buffer(r) (mpc_uint16_t)((((r->buff[0] << 16) | (r->buff[1] << 8) | r->buff[2]) >> r->count) & 0xFFFF); -#endif - -// basic huffman decoding routine -// works with maximum lengths up to 16 -static mpc_inline mpc_int32_t mpc_bits_huff_dec(mpc_bits_reader * r, const mpc_huffman *Table) -{ - const mpc_uint16_t code = get_code_from_buffer(r); - - while (code < Table->Code) Table++; - - r->buff -= (int)(r->count - Table->Length) >> 3; - r->count = (r->count - Table->Length) & 0x07; - - return Table->Value; -} - -static mpc_inline mpc_int32_t mpc_bits_can_dec(mpc_bits_reader * r, const mpc_can_data *can) -{ - const mpc_uint16_t code = get_code_from_buffer(r); - const mpc_huff_lut tmp = can->lut[code >> (16 - LUT_DEPTH)]; - const mpc_huffman * Table; - - if (tmp.Length != 0) { - r->buff -= (int)(r->count - tmp.Length) >> 3; - r->count = (r->count - tmp.Length) & 0x07; - return tmp.Value; - } - - Table = can->table + (unsigned char)tmp.Value; - while (code < Table->Code) Table++; - - r->buff -= (int)(r->count - Table->Length) >> 3; - r->count = (r->count - Table->Length) & 0x07; - - return can->sym[(Table->Value - (code >> (16 - Table->Length))) & 0xFF] ; -} - -// LUT-based huffman decoding routine -// works with maximum lengths up to 16 -static mpc_inline mpc_int32_t mpc_bits_huff_lut(mpc_bits_reader * r, const mpc_lut_data *lut) -{ - const mpc_uint16_t code = get_code_from_buffer(r); - const mpc_huff_lut tmp = lut->lut[code >> (16 - LUT_DEPTH)]; - const mpc_huffman * Table; - - if (tmp.Length != 0) { - r->buff -= (int)(r->count - tmp.Length) >> 3; - r->count = (r->count - tmp.Length) & 0x07; - return tmp.Value; - } - - Table = lut->table + (unsigned char)tmp.Value; - while (code < Table->Code) Table++; - - r->buff -= (int)(r->count - Table->Length) >> 3; - r->count = (r->count - Table->Length) & 0x07; - - return Table->Value; -} - -static mpc_inline mpc_uint32_t mpc_bits_enum_dec(mpc_bits_reader * r, mpc_uint_t k, mpc_uint_t n) -{ - mpc_uint32_t bits = 0; - mpc_uint32_t code; - const mpc_uint32_t * C = Cnk[k-1]; - - code = mpc_bits_read(r, Cnk_len[k-1][n-1] - 1); - - if (code >= Cnk_lost[k-1][n-1]) - code = ((code << 1) | mpc_bits_read(r, 1)) - Cnk_lost[k-1][n-1]; - - do { - n--; - if (code >= C[n]) { - bits |= 1 << n; - code -= C[n]; - C -= MAX_ENUM; - k--; - } - } while(k > 0); - - return bits; -} diff --git a/apps/codecs/libmusepack/mpc_decoder.c b/apps/codecs/libmusepack/mpc_decoder.c deleted file mode 100644 index 3bfc4cc7fc..0000000000 --- a/apps/codecs/libmusepack/mpc_decoder.c +++ /dev/null @@ -1,767 +0,0 @@ -/* - Copyright (c) 2005-2009, The Musepack Development Team - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are - met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - - * Neither the name of the The Musepack Development Team nor the - names of its contributors may be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -/// \file mpc_decoder.c -/// Core decoding routines and logic. - -#include -#include -#include "mpcdec.h" -#include "minimax.h" -#include "decoder.h" -#include "huffman.h" -#include "internal.h" -#include "mpcdec_math.h" -#include "requant.h" -#include "mpc_bits_reader.h" - -//SV7 tables -extern const mpc_lut_data mpc_HuffQ [7] [2]; -extern const mpc_lut_data mpc_HuffHdr; -extern const mpc_huffman mpc_table_HuffSCFI [ 4]; -extern const mpc_lut_data mpc_HuffDSCF; - -//SV8 tables -extern const mpc_can_data mpc_can_Bands; -extern const mpc_can_data mpc_can_SCFI[2]; -extern const mpc_can_data mpc_can_DSCF[2]; -extern const mpc_can_data mpc_can_Res [2]; -extern const mpc_can_data mpc_can_Q [8][2]; -extern const mpc_can_data mpc_can_Q1; -extern const mpc_can_data mpc_can_Q9up; - -//Decoder globals (g_Y_L and g_Y_R do not fit into iram for all targets) -static mpc_decoder g_mpc_decoder IBSS_ATTR; -static MPC_SAMPLE_FORMAT g_V_L[MPC_V_MEM + 960 ] IBSS_ATTR MEM_ALIGN_ATTR; -static MPC_SAMPLE_FORMAT g_Y_L[MPC_FRAME_LENGTH] IBSS_ATTR_MPC_LARGE_IRAM MEM_ALIGN_ATTR; -static MPC_SAMPLE_FORMAT g_V_R[MPC_V_MEM + 960 ] IBSS_ATTR MEM_ALIGN_ATTR; -static MPC_SAMPLE_FORMAT g_Y_R[MPC_FRAME_LENGTH] IBSS_ATTR_MPC_LARGE_IRAM MEM_ALIGN_ATTR; - -//SV7 globals (decoding results for bundled quantizers (3- and 5-step)) -static const mpc_int32_t g_sv7_idx30[] ICONST_ATTR = -{-1, 0, 1,-1, 0, 1,-1, 0, 1,-1, 0, 1,-1, 0, 1,-1, 0, 1,-1, 0, 1,-1, 0, 1,-1, 0, 1}; -static const mpc_int32_t g_sv7_idx31[] ICONST_ATTR = -{-1,-1,-1, 0, 0, 0, 1, 1, 1,-1,-1,-1, 0, 0, 0, 1, 1, 1,-1,-1,-1, 0, 0, 0, 1, 1, 1}; -static const mpc_int32_t g_sv7_idx32[] ICONST_ATTR = -{-1,-1,-1,-1,-1,-1,-1,-1,-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1}; -static const mpc_int32_t g_sv7_idx50[] ICONST_ATTR = -{-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2}; -static const mpc_int32_t g_sv7_idx51[] ICONST_ATTR = -{-2,-2,-2,-2,-2,-1,-1,-1,-1,-1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2}; - -//SV8 globals (decoding results for bundled quantizers (3- and 5-step)) -static const mpc_int8_t g_sv8_idx50[125] ICONST_ATTR = -{-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2, - -2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2, - -2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2, - -2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2, - -2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2}; -static const mpc_int8_t g_sv8_idx51[125] ICONST_ATTR = -{-2,-2,-2,-2,-2,-1,-1,-1,-1,-1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, - -2,-2,-2,-2,-2,-1,-1,-1,-1,-1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, - -2,-2,-2,-2,-2,-1,-1,-1,-1,-1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, - -2,-2,-2,-2,-2,-1,-1,-1,-1,-1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, - -2,-2,-2,-2,-2,-1,-1,-1,-1,-1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2}; -static const mpc_int8_t g_sv8_idx52[125] ICONST_ATTR = -{-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2, - -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2}; -static const mpc_int8_t g_sv8_HuffQ2_var[125] ICONST_ATTR = -{ 6, 5, 4, 5, 6, 5, 4, 3, 4, 5, 4, 3, 2, 3, 4, 5, 4, 3, 4, 5, 6, 5, 4, 5, 6, - 5, 4, 3, 4, 5, 4, 3, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 3, 4, 5, 4, 3, 4, 5, - 4, 3, 2, 3, 4, 3, 2, 1, 2, 3, 2, 1, 0, 1, 2, 3, 2, 1, 2, 3, 4, 3, 2, 3, 4, - 5, 4, 3, 4, 5, 4, 3, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 3, 4, 5, 4, 3, 4, 5, - 6, 5, 4, 5, 6, 5, 4, 3, 4, 5, 4, 3, 2, 3, 4, 5, 4, 3, 4, 5, 6, 5, 4, 5, 6}; - -//------------------------------------------------------------------------------ -// types -//------------------------------------------------------------------------------ -enum -{ - MEMSIZE = MPC_DECODER_MEMSIZE, // overall buffer size - MEMSIZE2 = (MEMSIZE/2), // size of one buffer - MEMMASK = (MEMSIZE-1) -}; - -//------------------------------------------------------------------------------ -// forward declarations -//------------------------------------------------------------------------------ -static void mpc_decoder_requantisierung (mpc_decoder *d) - ICODE_ATTR_MPC_LARGE_IRAM; -static void mpc_decoder_read_bitstream_sv7(mpc_decoder * d, - mpc_bits_reader * r) - ICODE_ATTR_MPC_LARGE_IRAM; -static void mpc_decoder_read_bitstream_sv8(mpc_decoder * d, - mpc_bits_reader * r, - mpc_bool_t is_key_frame) - ICODE_ATTR_MPC_SV8_BS_DEC; - -//------------------------------------------------------------------------------ -// macros -//------------------------------------------------------------------------------ -#define REQUANT_M1_S1_SAMPLES(IDX) \ - *(YL+=IDX) = (templ = MPC_MULTIPLY_FLOAT_INT(facL,*L++))+(tempr = MPC_MULTIPLY_FLOAT_INT(facR,*R++)); \ - *(YR+=IDX) = templ - tempr; - -#define REQUANT_M1_S1(SUBFRAME) \ - facL = MPC_MULTIPLY_SCF( Cc[d->Res_L[Band]] , d->SCF_Index_L[Band][SUBFRAME] & 0xFF); \ - facR = MPC_MULTIPLY_SCF( Cc[d->Res_R[Band]] , d->SCF_Index_R[Band][SUBFRAME] & 0xFF); \ - for (n = 0; n < 12; n+=4, YL += 32, YR += 32) { \ - REQUANT_M1_S1_SAMPLES( 0); \ - REQUANT_M1_S1_SAMPLES(32); \ - REQUANT_M1_S1_SAMPLES(32); \ - REQUANT_M1_S1_SAMPLES(32); \ - } - -#define REQUANT_M1_S0_SAMPLES(IDX) \ - *(YR+=IDX) = *(YL+=IDX) = MPC_MULTIPLY_FLOAT_INT(facL,*L++); - -#define REQUANT_M1_S0(SUBFRAME) \ - facL = MPC_MULTIPLY_SCF( Cc[d->Res_L[Band]] , d->SCF_Index_L[Band][SUBFRAME] & 0xFF); \ - for (n = 0; n < 12; n+=4, YL += 32, YR += 32) { \ - REQUANT_M1_S0_SAMPLES( 0); \ - REQUANT_M1_S0_SAMPLES(32); \ - REQUANT_M1_S0_SAMPLES(32); \ - REQUANT_M1_S0_SAMPLES(32); \ - } - -#define REQUANT_M0_S1_SAMPLES(IDX) \ - *(YR+=IDX) = -(*(YL+=IDX) = MPC_MULTIPLY_FLOAT_INT(facR,*R++)); - -#define REQUANT_M0_S1(SUBFRAME) \ - facR = MPC_MULTIPLY_SCF( Cc[d->Res_R[Band]] , d->SCF_Index_R[Band][SUBFRAME] & 0xFF); \ - for (n = 0; n < 12; n+=4, YL += 32, YR += 32) { \ - REQUANT_M0_S1_SAMPLES( 0); \ - REQUANT_M0_S1_SAMPLES(32); \ - REQUANT_M0_S1_SAMPLES(32); \ - REQUANT_M0_S1_SAMPLES(32); \ - } - -#define REQUANT_L1_R1_SAMPLES(IDX) \ - *(YL+=IDX) = MPC_MULTIPLY_FLOAT_INT(facL,*L++); \ - *(YR+=IDX) = MPC_MULTIPLY_FLOAT_INT(facR,*R++); - -#define REQUANT_L1_R1(SUBFRAME) \ - facL = MPC_MULTIPLY_SCF( Cc[d->Res_L[Band]] , d->SCF_Index_L[Band][SUBFRAME] & 0xFF); \ - facR = MPC_MULTIPLY_SCF( Cc[d->Res_R[Band]] , d->SCF_Index_R[Band][SUBFRAME] & 0xFF); \ - for (n = 0; n < 12; n+=4, YL += 32, YR += 32) { \ - REQUANT_L1_R1_SAMPLES( 0); \ - REQUANT_L1_R1_SAMPLES(32); \ - REQUANT_L1_R1_SAMPLES(32); \ - REQUANT_L1_R1_SAMPLES(32); \ - } - -#define REQUANT_L1_R0_SAMPLES(IDX) \ - *(YL+=IDX) = MPC_MULTIPLY_FLOAT_INT(facL,*L++); \ - *(YR+=IDX) = 0; - -#define REQUANT_L1_R0(SUBFRAME) \ - facL = MPC_MULTIPLY_SCF( Cc[d->Res_L[Band]] , d->SCF_Index_L[Band][SUBFRAME] & 0xFF); \ - for (n = 0; n < 12; n+=4, YL += 32, YR += 32) { \ - REQUANT_L1_R0_SAMPLES( 0); \ - REQUANT_L1_R0_SAMPLES(32); \ - REQUANT_L1_R0_SAMPLES(32); \ - REQUANT_L1_R0_SAMPLES(32); \ - } - -#define REQUANT_L0_R1_SAMPLES(IDX) \ - *(YL+=IDX) = 0; \ - *(YR+=IDX) = MPC_MULTIPLY_FLOAT_INT(facR,*R++); - -#define REQUANT_L0_R1(SUBFRAME) \ - facR = MPC_MULTIPLY_SCF( Cc[d->Res_R[Band]] , d->SCF_Index_R[Band][SUBFRAME] & 0xFF); \ - for (n = 0; n < 12; n+=4, YL += 32, YR += 32) { \ - REQUANT_L0_R1_SAMPLES( 0); \ - REQUANT_L0_R1_SAMPLES(32); \ - REQUANT_L0_R1_SAMPLES(32); \ - REQUANT_L0_R1_SAMPLES(32); \ - } - -#define REQUANT_SILENCE_SAMPLES(IDX) \ - *(YR+=IDX) = *(YL+=IDX) = 0; - -#define REQUANT_SILENCE \ - for (n = 0; n < 36; n+=4, YL += 32, YR += 32) { \ - REQUANT_SILENCE_SAMPLES( 0); \ - REQUANT_SILENCE_SAMPLES(32); \ - REQUANT_SILENCE_SAMPLES(32); \ - REQUANT_SILENCE_SAMPLES(32); \ - } - -/** - * set the scf indexes for seeking use - * needed only for sv7 seeking - * @param d - */ -void mpc_decoder_reset_scf(mpc_decoder * d, int value) -{ - memset(d->SCF_Index_L, value, sizeof d->SCF_Index_L ); - memset(d->SCF_Index_R, value, sizeof d->SCF_Index_R ); -} - -static void mpc_decoder_setup(mpc_decoder *d) -{ -#if defined(CPU_COLDFIRE) - coldfire_set_macsr(EMAC_FRACTIONAL | EMAC_SATURATE); -#endif - - memset(d, 0, sizeof *d); - - d->__r1 = 1; - d->__r2 = 1; - d->V_L = g_V_L; - d->V_R = g_V_R; - d->Y_L = g_Y_L; - d->Y_R = g_Y_R; - - memset(d->V_L, 0, sizeof(g_V_L)); - memset(d->V_R, 0, sizeof(g_V_R)); - memset(d->Y_L, 0, sizeof(g_Y_L)); - memset(d->Y_R, 0, sizeof(g_Y_R)); - - mpc_decoder_init_quant(d, MAKE_MPC_SAMPLE(1.0)); -} - -static void mpc_decoder_set_streaminfo(mpc_decoder *d, mpc_streaminfo *si) -{ - d->stream_version = si->stream_version; - d->ms = si->ms; - d->max_band = si->max_band; - d->channels = si->channels; - d->samples_to_skip = MPC_DECODER_SYNTH_DELAY + si->beg_silence; - - if (si->stream_version == 7 && si->is_true_gapless) - d->samples = ((si->samples + MPC_FRAME_LENGTH - 1) / MPC_FRAME_LENGTH) * MPC_FRAME_LENGTH; - else - d->samples = si->samples; -} - -mpc_decoder * mpc_decoder_init(mpc_streaminfo *si) -{ - mpc_decoder* p_tmp = &g_mpc_decoder; - - if (p_tmp != 0) { - mpc_decoder_setup(p_tmp); - mpc_decoder_set_streaminfo(p_tmp, si); - huff_init_lut(LUT_DEPTH); - } - - return p_tmp; -} - -/* rockbox: not used -void mpc_decoder_exit(mpc_decoder *d) -{ - (void)d; -} -*/ - -void mpc_decoder_decode_frame(mpc_decoder * d, - mpc_bits_reader * r, - mpc_frame_info * i) -{ - mpc_bits_reader r_sav = *r; - mpc_int64_t samples_left; - - samples_left = d->samples - d->decoded_samples + MPC_DECODER_SYNTH_DELAY; - - if (samples_left <= 0 && d->samples != 0) { - i->samples = 0; - i->bits = -1; - return; - } - - if (d->stream_version == 8) { - mpc_decoder_read_bitstream_sv8(d, r, i->is_key_frame); - } else { - mpc_decoder_read_bitstream_sv7(d, r); - } - - if (d->samples_to_skip < MPC_FRAME_LENGTH + MPC_DECODER_SYNTH_DELAY) { - mpc_decoder_requantisierung(d); - mpc_decoder_synthese_filter_float(d, i->buffer, d->channels); - } - - d->decoded_samples += MPC_FRAME_LENGTH; - - // reconstruct exact filelength - if (d->decoded_samples - d->samples < MPC_FRAME_LENGTH && d->stream_version == 7) { - int last_frame_samples = mpc_bits_read(r, 11); - if (d->decoded_samples == d->samples) { - if (last_frame_samples == 0) last_frame_samples = MPC_FRAME_LENGTH; - d->samples += last_frame_samples - MPC_FRAME_LENGTH; - samples_left += last_frame_samples - MPC_FRAME_LENGTH; - } - } - - i->samples = samples_left > MPC_FRAME_LENGTH ? MPC_FRAME_LENGTH : samples_left < 0 ? 0 : (mpc_uint32_t) samples_left; - i->bits = (mpc_uint32_t) (((r->buff - r_sav.buff) << 3) + r_sav.count - r->count); - - if (d->samples_to_skip) { - if (i->samples <= d->samples_to_skip) { - d->samples_to_skip -= i->samples; - i->samples = 0; - } else { - i->samples -= d->samples_to_skip; - - /* move valid samples to beginning for channel 0. noninterleaved! */ - memmove(i->buffer, - i->buffer + d->samples_to_skip, - i->samples * sizeof(MPC_SAMPLE_FORMAT)); - /* move valid samples to beginning for channel 1. noninterleaved! */ - memmove(i->buffer + MPC_FRAME_LENGTH, - i->buffer + MPC_FRAME_LENGTH + d->samples_to_skip, - i->samples * sizeof(MPC_SAMPLE_FORMAT)); - - d->samples_to_skip = 0; - } - } -} - -static void -mpc_decoder_requantisierung(mpc_decoder *d) -{ - mpc_int32_t Band; - mpc_int32_t n; - MPC_SAMPLE_FORMAT facL; - MPC_SAMPLE_FORMAT facR; - MPC_SAMPLE_FORMAT templ; - MPC_SAMPLE_FORMAT tempr; - MPC_SAMPLE_FORMAT* YL; - MPC_SAMPLE_FORMAT* YR; - mpc_int16_t* L; - mpc_int16_t* R; - const mpc_int32_t Last_Band = d->max_band; - -#ifdef MPC_FIXED_POINT -#if MPC_FIXED_POINT_FRACTPART == 14 -#define MPC_MULTIPLY_SCF(CcVal, SCF_idx) \ - MPC_MULTIPLY_EX(CcVal, d->SCF[SCF_idx], d->SCF_shift[SCF_idx]) -#else - -#error FIXME, Cc table is in 18.14 format - -#endif -#else -#define MPC_MULTIPLY_SCF(CcVal, SCF_idx) \ - MPC_MULTIPLY(CcVal, d->SCF[SCF_idx]) -#endif - // requantization and scaling of subband-samples - for ( Band = 0; Band <= Last_Band; Band++ ) { // setting pointers - YL = d->Y_L + Band; - YR = d->Y_R + Band; - L = d->Q[Band].L; - R = d->Q[Band].R; - /************************** MS-coded **************************/ - if ( d->MS_Flag [Band] ) { - if ( d->Res_L [Band] ) { - if ( d->Res_R [Band] ) { // M!=0, S!=0 - REQUANT_M1_S1(0); - REQUANT_M1_S1(1); - REQUANT_M1_S1(2); - } else { // M!=0, S==0 - REQUANT_M1_S0(0); - REQUANT_M1_S0(1); - REQUANT_M1_S0(2); - } - } else { - if ( d->Res_R[Band] ) // M==0, S!=0 - { - REQUANT_M0_S1(0); - REQUANT_M0_S1(1); - REQUANT_M0_S1(2); - } else { // M==0, S==0 - REQUANT_SILENCE; - } - } - } - /************************** LR-coded **************************/ - else { - if ( d->Res_L [Band] ) { - if ( d->Res_R [Band] ) { // L!=0, R!=0 - REQUANT_L1_R1(0); - REQUANT_L1_R1(1); - REQUANT_L1_R1(2); - } else { // L!=0, R==0 - REQUANT_L1_R0(0); - REQUANT_L1_R0(1); - REQUANT_L1_R0(2); - } - } - else { - if ( d->Res_R [Band] ) { // L==0, R!=0 - REQUANT_L0_R1(0); - REQUANT_L0_R1(1); - REQUANT_L0_R1(2); - } else { // L==0, R==0 - REQUANT_SILENCE; - } - } - } - } -} - -static void mpc_decoder_read_bitstream_sv7(mpc_decoder * d, mpc_bits_reader * r) -{ - mpc_int32_t n, idx, Max_used_Band = 0; - - /***************************** Header *****************************/ - - // first subband - d->Res_L[0] = mpc_bits_read(r, 4); - d->Res_R[0] = mpc_bits_read(r, 4); - if (!(d->Res_L[0] == 0 && d->Res_R[0] == 0)) { - if (d->ms) - d->MS_Flag[0] = mpc_bits_read(r, 1); - Max_used_Band = 1; - } - - // consecutive subbands - for ( n = 1; n <= d->max_band; n++ ) { - idx = mpc_bits_huff_lut(r, & mpc_HuffHdr); - d->Res_L[n] = (idx!=4) ? d->Res_L[n - 1] + idx : (int) mpc_bits_read(r, 4); - - idx = mpc_bits_huff_lut(r, & mpc_HuffHdr); - d->Res_R[n] = (idx!=4) ? d->Res_R[n - 1] + idx : (int) mpc_bits_read(r, 4); - - if (!(d->Res_L[n] == 0 && d->Res_R[n] == 0)) { - if (d->ms) - d->MS_Flag[n] = mpc_bits_read(r, 1); - Max_used_Band = n + 1; - } - } - - /****************************** SCFI ******************************/ - for ( n = 0; n < Max_used_Band; n++ ) { - if (d->Res_L[n]) - d->SCFI_L[n] = mpc_bits_huff_dec(r, mpc_table_HuffSCFI); - if (d->Res_R[n]) - d->SCFI_R[n] = mpc_bits_huff_dec(r, mpc_table_HuffSCFI); - } - - /**************************** SCF/DSCF ****************************/ - for ( n = 0; n < Max_used_Band; n++ ) { - mpc_int32_t * SCF = d->SCF_Index_L[n]; - mpc_uint32_t Res = d->Res_L[n], SCFI = d->SCFI_L[n]; - do { - if (Res) { - switch (SCFI) { - case 1: - idx = mpc_bits_huff_lut(r, & mpc_HuffDSCF); - SCF[0] = (idx!=8) ? SCF[2] + idx : (int) mpc_bits_read(r, 6); - idx = mpc_bits_huff_lut(r, & mpc_HuffDSCF); - SCF[1] = (idx!=8) ? SCF[0] + idx : (int) mpc_bits_read(r, 6); - SCF[2] = SCF[1]; - break; - case 3: - idx = mpc_bits_huff_lut(r, & mpc_HuffDSCF); - SCF[0] = (idx!=8) ? SCF[2] + idx : (int) mpc_bits_read(r, 6); - SCF[1] = SCF[0]; - SCF[2] = SCF[1]; - break; - case 2: - idx = mpc_bits_huff_lut(r, & mpc_HuffDSCF); - SCF[0] = (idx!=8) ? SCF[2] + idx : (int) mpc_bits_read(r, 6); - SCF[1] = SCF[0]; - idx = mpc_bits_huff_lut(r, & mpc_HuffDSCF); - SCF[2] = (idx!=8) ? SCF[1] + idx : (int) mpc_bits_read(r, 6); - break; - case 0: - idx = mpc_bits_huff_lut(r, & mpc_HuffDSCF); - SCF[0] = (idx!=8) ? SCF[2] + idx : (int) mpc_bits_read(r, 6); - idx = mpc_bits_huff_lut(r, & mpc_HuffDSCF); - SCF[1] = (idx!=8) ? SCF[0] + idx : (int) mpc_bits_read(r, 6); - idx = mpc_bits_huff_lut(r, & mpc_HuffDSCF); - SCF[2] = (idx!=8) ? SCF[1] + idx : (int) mpc_bits_read(r, 6); - break; - default: - return; - } - if (SCF[0] > 1024) - SCF[0] = 0x8080; - if (SCF[1] > 1024) - SCF[1] = 0x8080; - if (SCF[2] > 1024) - SCF[2] = 0x8080; - } - Res = d->Res_R[n]; - SCFI = d->SCFI_R[n]; - } while ( SCF == d->SCF_Index_L[n] && (SCF = d->SCF_Index_R[n])); - } - -// if (d->seeking == TRUE) -// return; - - /***************************** Samples ****************************/ - for ( n = 0; n < Max_used_Band; n++ ) { - mpc_int16_t *q = d->Q[n].L, Res = d->Res_L[n]; - do { - mpc_uint32_t nbit; - mpc_int32_t k, dc; - const mpc_lut_data *Table; - switch (Res) { - case -2: case -3: case -4: case -5: case -6: case -7: case -8: case -9: - case -10: case -11: case -12: case -13: case -14: case -15: case -16: case -17: case 0: - break; - case -1: - for (k=0; k<36; k++ ) { - mpc_uint32_t tmp = mpc_random_int(d); - q[k] = ((tmp >> 24) & 0xFF) + ((tmp >> 16) & 0xFF) + ((tmp >> 8) & 0xFF) + ((tmp >> 0) & 0xFF) - 510; - } - break; - case 1: - Table = & mpc_HuffQ[0][mpc_bits_read(r, 1)]; - for ( k = 0; k < 36; k += 3) { - idx = mpc_bits_huff_lut(r, Table); - q[k] = g_sv7_idx30[idx]; - q[k + 1] = g_sv7_idx31[idx]; - q[k + 2] = g_sv7_idx32[idx]; - } - break; - case 2: - Table = & mpc_HuffQ[1][mpc_bits_read(r, 1)]; - for ( k = 0; k < 36; k += 2) { - idx = mpc_bits_huff_lut(r, Table); - q[k] = g_sv7_idx50[idx]; - q[k + 1] = g_sv7_idx51[idx]; - } - break; - case 3: - case 4: - case 5: - case 6: - case 7: - Table = & mpc_HuffQ[Res - 1][mpc_bits_read(r, 1)]; - for ( k = 0; k < 36; k++ ) - q[k] = mpc_bits_huff_lut(r, Table); - break; - case 8: case 9: case 10: case 11: case 12: case 13: case 14: case 15: case 16: case 17: - nbit = Res_bit[Res]; - dc = Dc[Res]; - for ( k = 0; k < 36; k++ ) - q[k] = (mpc_int32_t)mpc_bits_read(r, nbit) - dc; - break; - default: - return; - } - - Res = d->Res_R[n]; - } while (q == d->Q[n].L && (q = d->Q[n].R)); - } -} - -static void mpc_decoder_read_bitstream_sv8(mpc_decoder * d, mpc_bits_reader * r, mpc_bool_t is_key_frame) -{ - mpc_int32_t n, Max_used_Band; - const mpc_can_data * Table, * Tables[2]; - - /***************************** Header *****************************/ - - if (is_key_frame == MPC_TRUE) { - Max_used_Band = mpc_bits_log_dec(r, d->max_band + 1); - } else { - Max_used_Band = d->last_max_band + mpc_bits_can_dec(r, & mpc_can_Bands); - if (Max_used_Band > 32) Max_used_Band -= 33; - } - d->last_max_band = Max_used_Band; - - if (Max_used_Band) { - d->Res_L[Max_used_Band-1] = mpc_bits_can_dec(r, & mpc_can_Res[0]); - d->Res_R[Max_used_Band-1] = mpc_bits_can_dec(r, & mpc_can_Res[0]); - if (d->Res_L[Max_used_Band-1] > 15) d->Res_L[Max_used_Band-1] -= 17; - if (d->Res_R[Max_used_Band-1] > 15) d->Res_R[Max_used_Band-1] -= 17; - for ( n = Max_used_Band - 2; n >= 0; n--) { - d->Res_L[n] = mpc_bits_can_dec(r, & mpc_can_Res[d->Res_L[n + 1] > 2]) + d->Res_L[n + 1]; - if (d->Res_L[n] > 15) d->Res_L[n] -= 17; - d->Res_R[n] = mpc_bits_can_dec(r, & mpc_can_Res[d->Res_R[n + 1] > 2]) + d->Res_R[n + 1]; - if (d->Res_R[n] > 15) d->Res_R[n] -= 17; - } - - if (d->ms) { - mpc_uint_t cnt = 0, tot = 0; - mpc_uint32_t tmp = 0; - for( n = 0; n < Max_used_Band; n++) - if ( d->Res_L[n] != 0 || d->Res_R[n] != 0 ) - tot++; - cnt = mpc_bits_log_dec(r, tot); - if (cnt != 0 && cnt != tot) - tmp = mpc_bits_enum_dec(r, mini(cnt, tot-cnt), tot); - if (cnt * 2 > tot) tmp = ~tmp; - for( n = Max_used_Band - 1; n >= 0; n--) - if ( d->Res_L[n] != 0 || d->Res_R[n] != 0 ) { - d->MS_Flag[n] = tmp & 1; - tmp >>= 1; - } - } - } - - for( n = Max_used_Band; n <= d->max_band; n++) - d->Res_L[n] = d->Res_R[n] = 0; - - /****************************** SCFI ******************************/ - if (is_key_frame == MPC_TRUE){ - for( n = 0; n < 32; n++) - d->DSCF_Flag_L[n] = d->DSCF_Flag_R[n] = 1; // new block -> force key frame - } - - Tables[0] = & mpc_can_SCFI[0]; - Tables[1] = & mpc_can_SCFI[1]; - for ( n = 0; n < Max_used_Band; n++ ) { - int tmp = 0, cnt = -1; - if (d->Res_L[n]) cnt++; - if (d->Res_R[n]) cnt++; - if (cnt >= 0) { - tmp = mpc_bits_can_dec(r, Tables[cnt]); - if (d->Res_L[n]) d->SCFI_L[n] = tmp >> (2 * cnt); - if (d->Res_R[n]) d->SCFI_R[n] = tmp & 3; - } - } - - /**************************** SCF/DSCF ****************************/ - - for ( n = 0; n < Max_used_Band; n++ ) { - mpc_int32_t * SCF = d->SCF_Index_L[n]; - mpc_uint32_t Res = d->Res_L[n], SCFI = d->SCFI_L[n]; - mpc_bool_t * DSCF_Flag = &d->DSCF_Flag_L[n]; - - do { - if ( Res ) { - int m; - if (*DSCF_Flag == 1) { - SCF[0] = (mpc_int32_t)mpc_bits_read(r, 7) - 6; - *DSCF_Flag = 0; - } else { - mpc_uint_t tmp = mpc_bits_can_dec(r, & mpc_can_DSCF[1]); - if (tmp == 64) - tmp += mpc_bits_read(r, 6); - SCF[0] = ((SCF[2] - 25 + tmp) & 127) - 6; - } - for( m = 0; m < 2; m++){ - if (((SCFI << m) & 2) == 0) { - mpc_uint_t tmp = mpc_bits_can_dec(r, & mpc_can_DSCF[0]); - if (tmp == 31) - tmp = 64 + mpc_bits_read(r, 6); - SCF[m + 1] = ((SCF[m] - 25 + tmp) & 127) - 6; - } else - SCF[m + 1] = SCF[m]; - } - } - Res = d->Res_R[n]; - SCFI = d->SCFI_R[n]; - DSCF_Flag = &d->DSCF_Flag_R[n]; - } while ( SCF == d->SCF_Index_L[n] && (SCF = d->SCF_Index_R[n])); - } - - /***************************** Samples ****************************/ - for ( n = 0; n < Max_used_Band; n++ ) { - mpc_int16_t *q = d->Q[n].L, Res = d->Res_L[n]; - static const mpc_uint32_t thres[] = {0, 0, 3, 0, 0, 1, 3, 4, 8}; - do { - mpc_uint32_t nbit; - mpc_uint32_t k = 0, idx = 1, dc; - if (Res != 0) { - if (Res == 2) { - Tables[0] = & mpc_can_Q [0][0]; - Tables[1] = & mpc_can_Q [0][1]; - idx = 2 * thres[Res]; - for ( ; k < 36; k += 3) { - int tmp = mpc_bits_can_dec(r, Tables[idx > thres[Res]]); - q[k] = g_sv8_idx50[tmp]; - q[k + 1] = g_sv8_idx51[tmp]; - q[k + 2] = g_sv8_idx52[tmp]; - idx = (idx >> 1) + g_sv8_HuffQ2_var[tmp]; - } - } else if (Res == 1) { - Table = & mpc_can_Q1; - for( ; k < 36; ){ - mpc_uint32_t kmax = k + 18; - mpc_uint_t cnt = mpc_bits_can_dec(r, Table); - idx = 0; - if (cnt > 0 && cnt < 18) - idx = mpc_bits_enum_dec(r, cnt <= 9 ? cnt : 18 - cnt, 18); - if (cnt > 9) idx = ~idx; - for ( ; k < kmax; k++) { - q[k] = 0; - if ( idx & (1 << 17) ) - q[k] = (mpc_bits_read(r, 1) << 1) - 1; - idx <<= 1; - } - } - } else if (Res == -1) { - for ( ; k<36; k++ ) { - mpc_uint32_t tmp = mpc_random_int(d); - q[k] = ((tmp >> 24) & 0xFF) + ((tmp >> 16) & 0xFF) + ((tmp >> 8) & 0xFF) + ((tmp >> 0) & 0xFF) - 510; - } - } else if (Res <= 4) { - Table = & mpc_can_Q[1][Res - 3]; - for ( ; k < 36; k += 2 ) { - union { - mpc_int8_t sym; - struct { mpc_int8_t s1:4, s2:4; }; - } tmp; - tmp.sym = mpc_bits_can_dec(r, Table); - q[k] = tmp.s1; - q[k + 1] = tmp.s2; - } - } else if (Res <= 8) { - Tables[0] = & mpc_can_Q [Res - 3][0]; - Tables[1] = & mpc_can_Q [Res - 3][1]; - idx = 2 * thres[Res]; - for ( ; k < 36; k++ ) { - q[k] = mpc_bits_can_dec(r, Tables[idx > thres[Res]]); - idx = (idx >> 1) + absi(q[k]); - } - } else if (Res == 9) { - dc = Dc[Res]; - for ( ; k < 36; k++ ) { - q[k] = (unsigned char) mpc_bits_can_dec(r, & mpc_can_Q9up); - q[k] -= dc; - } - } else { - nbit = (Res - 9); - dc = Dc[Res]; - for ( ; k < 36; k++ ) { - q[k] = (unsigned char) mpc_bits_can_dec(r, & mpc_can_Q9up); - q[k] = (q[k] << nbit) | mpc_bits_read(r, nbit); - q[k] -= dc; - } - } - } - - Res = d->Res_R[n]; - } while (q == d->Q[n].L && (q = d->Q[n].R)); - } -} - diff --git a/apps/codecs/libmusepack/mpc_demux.c b/apps/codecs/libmusepack/mpc_demux.c deleted file mode 100644 index 9523163c0e..0000000000 --- a/apps/codecs/libmusepack/mpc_demux.c +++ /dev/null @@ -1,730 +0,0 @@ -/* - Copyright (c) 2005-2009, The Musepack Development Team - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are - met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - - * Neither the name of the The Musepack Development Team nor the - names of its contributors may be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include -#include -#include "streaminfo.h" -#include "mpcdec.h" -#include "internal.h" -#include "decoder.h" -#include "huffman.h" -#include "mpc_bits_reader.h" - -#include - -/// maximum number of seek points in the table. The distance between points will -/// be adapted so this value is never exceeded. -#define MAX_SEEK_TABLE_SIZE 8192 - -// defines -#define MAX_BUFFER_SIZE (DEMUX_BUFFER_SIZE + MAX_FRAME_SIZE) - -// globals -static mpc_uint8_t g_buffer[MAX_BUFFER_SIZE] IBSS_ATTR_MPC_BITBUFFER; -static mpc_seek_t g_seek_table[MAX_SEEK_TABLE_SIZE]; -static mpc_demux g_mpc_demux IBSS_ATTR; - -enum { - MPC_BUFFER_SWAP = 1, - MPC_BUFFER_FULL = 2, -}; - -static void mpc_demux_clear_buff(mpc_demux * d) -{ - d->bytes_total = 0; - d->bits_reader.buff = d->buffer; - d->bits_reader.count = 8; - d->bits_reader.buffered_addr = 0; - d->bits_reader.buffered_code = 0; - d->block_bits = 0; - d->block_frames = 0; - memset(d->buffer, 0, sizeof(g_buffer)); -} - -static mpc_uint32_t -mpc_demux_fill(mpc_demux * d, mpc_uint32_t min_bytes, int flags) -{ - mpc_uint32_t unread_bytes = d->bytes_total + d->buffer - d->bits_reader.buff - - ((8 - d->bits_reader.count) >> 3); - mpc_int32_t offset = 0; - - if (min_bytes == 0 || min_bytes > MAX_BUFFER_SIZE || - (unread_bytes < min_bytes && flags & MPC_BUFFER_FULL)) - min_bytes = MAX_BUFFER_SIZE; - - if (unread_bytes < min_bytes) { - mpc_uint32_t bytes2read = min_bytes - unread_bytes; - mpc_uint32_t bytes_free = MAX_BUFFER_SIZE - d->bytes_total; - - if (flags & MPC_BUFFER_SWAP) { - bytes2read &= -1 << 2; - offset = (unread_bytes + 3) & ( -1 << 2); - offset -= unread_bytes; - } - - if (bytes2read > bytes_free) { - if (d->bits_reader.count == 0) { - d->bits_reader.count = 8; - d->bits_reader.buff++; - } - memmove(d->buffer + offset, d->bits_reader.buff, unread_bytes); - d->bits_reader.buff = d->buffer + offset; - d->bytes_total = unread_bytes + offset; - /* reset Coldfire optimized read when rebuffering */ - d->bits_reader.buffered_addr = 0; - d->bits_reader.buffered_code = 0; - } - bytes2read = d->r->read(d->r, d->buffer + d->bytes_total, bytes2read); - if (flags & MPC_BUFFER_SWAP){ - unsigned int i, * tmp = (unsigned int *) (d->buffer + d->bytes_total); - for(i = 0 ;i < (bytes2read >> 2); i++) - tmp[i] = swap32(tmp[i]); - } - d->bytes_total += bytes2read; - return bytes2read; - } - - return (mpc_uint32_t) -1; -} - -/** - * seek to a bit position in the stream - * @param d demuxer context - * @param fpos position in the stream in bits from the beginning of mpc datas - * @param min_bytes number of bytes to load after seeking - */ -static mpc_status -mpc_demux_seek(mpc_demux * d, mpc_seek_t fpos, mpc_uint32_t min_bytes) { - // d->bits_reader.buff - d->buffer = current byte position within buffer - // d->bytes_total = buffer is filled with bytes_total bytes - // fpos = desired file position in bit (not byte) - // buf_fpos = desired byte position within buffer - mpc_seek_t next_pos = fpos>>3; - mpc_int_t buf_fpos = next_pos - d->r->tell(d->r) + d->bytes_total; - - // is desired byte position within lower and upper boundaries of buffer? - if (buf_fpos >= 0 && buf_fpos + min_bytes <= d->bytes_total) { - // desired bytes are available in current buffer - d->bits_reader.buff += buf_fpos - (d->bits_reader.buff - d->buffer); - d->bits_reader.count = 8 - (fpos & 7); - } else { - // buffer needs to be refilled - if (d->si.stream_version == 7) - next_pos = ((next_pos - d->si.header_position) & (-1 << 2)) + d->si.header_position; - buf_fpos = fpos - (next_pos << 3); - if (!d->r->seek(d->r, (mpc_int32_t) next_pos)) - return MPC_STATUS_FAIL; - mpc_demux_clear_buff(d); - if (d->si.stream_version == 7) - mpc_demux_fill(d, MAX_BUFFER_SIZE, MPC_BUFFER_FULL | MPC_BUFFER_SWAP); - else - mpc_demux_fill(d, MAX_BUFFER_SIZE, MPC_BUFFER_FULL); - d->bits_reader.buff += buf_fpos >> 3; - d->bits_reader.count = 8 - (buf_fpos & 7); - } - - return MPC_STATUS_OK; -} - -/** - * return the current position in the stream (in bits) from the beginning - * of the file - * @param d demuxer context - * @return current stream position in bits - */ -static mpc_seek_t mpc_demux_pos(mpc_demux * d) -{ - return (((mpc_seek_t)(d->r->tell(d->r)) - d->bytes_total + - d->bits_reader.buff - d->buffer) << 3) + 8 - d->bits_reader.count; -} - -/** - * Searches for a ID3v2-tag and reads the length (in bytes) of it. - * - * @param d demuxer context - * @return size of tag, in bytes - * @return MPC_STATUS_FAIL on errors of any kind - */ -static mpc_int32_t mpc_demux_skip_id3v2(mpc_demux * d) -{ - mpc_uint8_t tmp [4]; - mpc_bool_t footerPresent; // ID3v2.4-flag - mpc_int32_t size; - - // we must be at the beginning of the stream - mpc_demux_fill(d, 3, 0); - - // check id3-tag - if ( 0 != memcmp( d->bits_reader.buff, "ID3", 3 ) ) - return 0; - - mpc_demux_fill(d, 10, 0); - - mpc_bits_read(&d->bits_reader, 24); // read ID3 - mpc_bits_read(&d->bits_reader, 16); // read tag version - - tmp[0] = mpc_bits_read(&d->bits_reader, 8); // read flags - footerPresent = tmp[0] & 0x10; - if ( tmp[0] & 0x0F ) - return MPC_STATUS_FAIL; // not (yet???) allowed - - tmp[0] = mpc_bits_read(&d->bits_reader, 8); // read size - tmp[1] = mpc_bits_read(&d->bits_reader, 8); // read size - tmp[2] = mpc_bits_read(&d->bits_reader, 8); // read size - tmp[3] = mpc_bits_read(&d->bits_reader, 8); // read size - - if ( (tmp[0] | tmp[1] | tmp[2] | tmp[3]) & 0x80 ) - return MPC_STATUS_FAIL; // not allowed - - // read headerSize (syncsave: 4 * $0xxxxxxx = 28 significant bits) - size = tmp[0] << 21; - size |= tmp[1] << 14; - size |= tmp[2] << 7; - size |= tmp[3]; - - size += 10; //header - - if ( footerPresent ) size += 10; - - // This is called before file headers get read, streamversion etc isn't yet known, demuxing isn't properly initialized and we can't call mpc_demux_seek() from here. - mpc_demux_clear_buff(d); - if (!d->r->seek(d->r, size)) - return MPC_STATUS_FAIL; - - return size; -} - -static mpc_status mpc_demux_seek_init(mpc_demux * d) -{ - size_t seek_table_size; - if (d->seek_table != 0) - return MPC_STATUS_OK; - - d->seek_pwr = 6; - if (d->si.block_pwr > d->seek_pwr) - d->seek_pwr = d->si.block_pwr; - seek_table_size = (2 + d->si.samples / (MPC_FRAME_LENGTH << d->seek_pwr)); - while (seek_table_size > MAX_SEEK_TABLE_SIZE) { - d->seek_pwr++; - seek_table_size = (2 + d->si.samples / (MPC_FRAME_LENGTH << d->seek_pwr)); - } - d->seek_table = g_seek_table; - if (d->seek_table == 0) - return MPC_STATUS_FAIL; - d->seek_table[0] = (mpc_seek_t)mpc_demux_pos(d); - d->seek_table_size = 1; - - return MPC_STATUS_OK; -} - -/* rockbox: do not use -static mpc_status mpc_demux_ST(mpc_demux * d) -{ - mpc_uint64_t tmp; - mpc_seek_t * table, last[2]; - mpc_bits_reader r = d->bits_reader; - mpc_uint_t i, diff_pwr = 0, mask; - mpc_uint32_t file_table_size; - - if (d->seek_table != 0) - return MPC_STATUS_OK; - - mpc_bits_get_size(&r, &tmp); - file_table_size = (mpc_seek_t) tmp; - d->seek_pwr = d->si.block_pwr + mpc_bits_read(&r, 4); - - tmp = 2 + d->si.samples / (MPC_FRAME_LENGTH << d->seek_pwr); - while (tmp > MAX_SEEK_TABLE_SIZE) { - d->seek_pwr++; - diff_pwr++; - tmp = 2 + d->si.samples / (MPC_FRAME_LENGTH << d->seek_pwr); - } - if ((file_table_size >> diff_pwr) > tmp) - file_table_size = tmp << diff_pwr; - d->seek_table = g_seek_table; - d->seek_table_size = (file_table_size + ((1 << diff_pwr) - 1)) >> diff_pwr; - - table = d->seek_table; - mpc_bits_get_size(&r, &tmp); - table[0] = last[0] = (mpc_seek_t) (tmp + d->si.header_position) * 8; - - if (d->seek_table_size == 1) - return MPC_STATUS_OK; - - mpc_bits_get_size(&r, &tmp); - last[1] = (mpc_seek_t) (tmp + d->si.header_position) * 8; - if (diff_pwr == 0) table[1] = last[1]; - - mask = (1 << diff_pwr) - 1; - for (i = 2; i < file_table_size; i++) { - int code = mpc_bits_golomb_dec(&r, 12); - if (code & 1) - code = -(code & (-1 << 1)); - code <<= 2; - last[i & 1] = code + 2 * last[(i-1) & 1] - last[i & 1]; - if ((i & mask) == 0) - table[i >> diff_pwr] = last[i & 1]; - } - return MPC_STATUS_OK; -} - -static mpc_status mpc_demux_SP(mpc_demux * d, int size, int block_size) -{ - mpc_seek_t cur; - mpc_uint64_t ptr; - mpc_block b; - int st_head_size; - - cur = mpc_demux_pos(d); - mpc_bits_get_size(&d->bits_reader, &ptr); - MPC_AUTO_FAIL( mpc_demux_seek(d, (ptr - size) * 8 + cur, 11) ); - st_head_size = mpc_bits_get_block(&d->bits_reader, &b); - if (memcmp(b.key, "ST", 2) == 0) { - d->chap_pos = (ptr - size + b.size + st_head_size) * 8 + cur; - d->chap_nb = -1; - if (mpc_demux_fill(d, (mpc_uint32_t) b.size, 0) < b.size) - return MPC_STATUS_FAIL; - MPC_AUTO_FAIL( mpc_demux_ST(d) ); - } - return mpc_demux_seek(d, cur, 11 + block_size); -} -*/ -/* rockbox: not used -static void mpc_demux_chap_empty(mpc_demux * d) { - free(d->chap); d->chap = 0; - d->chap_nb = 0; // -1 for undefined, 0 for no chapters - d->chap_pos = 0; -} -*/ -/* rockbox: not used -static mpc_status mpc_demux_chap_find_inner(mpc_demux * d) -{ - mpc_block b; - int tag_size = 0, chap_size = 0, size, i = 0; - - d->chap_nb = 0; - - if (d->si.stream_version < 8) - return MPC_STATUS_OK; - - if (d->chap_pos == 0) { - mpc_uint64_t cur_pos = (d->si.header_position + 4) * 8; - MPC_AUTO_FAIL( mpc_demux_seek(d, cur_pos, 11) ); // seek to the beginning of the stream - size = mpc_bits_get_block(&d->bits_reader, &b); - while (memcmp(b.key, "SE", 2) != 0) { - mpc_uint64_t new_pos = cur_pos + (size + b.size) * 8; - MPC_AUTO_FAIL(mpc_check_key(b.key)); - - if (memcmp(b.key, "CT", 2) == 0) { - if (d->chap_pos == 0) d->chap_pos = cur_pos; - } else { - d->chap_pos = 0; - } - if (new_pos <= cur_pos) - return MPC_STATUS_FAIL; - cur_pos = new_pos; - - MPC_AUTO_FAIL( mpc_demux_seek(d, cur_pos, 11) ); - size = mpc_bits_get_block(&d->bits_reader, &b); - } - if (d->chap_pos == 0) - d->chap_pos = cur_pos; - } - - mpc_demux_seek(d, d->chap_pos, 20); - size = mpc_bits_get_block(&d->bits_reader, &b); - while (memcmp(b.key, "CT", 2) == 0) { - mpc_uint64_t chap_sample; - d->chap_nb++; - chap_size += size; - size = mpc_bits_get_size(&d->bits_reader, &chap_sample) + 4; - chap_size += size; - tag_size += b.size - size; - MPC_AUTO_FAIL( mpc_demux_seek(d, d->chap_pos + (chap_size + tag_size) * 8, 20) ); - size = mpc_bits_get_block(&d->bits_reader, &b); - } - - if (d->chap_nb > 0) { - char * ptag; - d->chap = malloc(sizeof(mpc_chap_info) * d->chap_nb + tag_size); - if (d->chap == 0) - return MPC_STATUS_FAIL; - - ptag = (char*)(d->chap + d->chap_nb); - - MPC_AUTO_FAIL( mpc_demux_seek(d, d->chap_pos, 11) ); - size = mpc_bits_get_block(&d->bits_reader, &b); - while (memcmp(b.key, "CT", 2) == 0) { - mpc_uint_t tmp_size; - char * tmp_ptag = ptag; - if (mpc_demux_fill(d, 11 + (mpc_uint32_t) b.size, 0) < b.size) - return MPC_STATUS_FAIL; - size = mpc_bits_get_size(&d->bits_reader, &d->chap[i].sample) + 4; - d->chap[i].gain = (mpc_uint16_t) mpc_bits_read(&d->bits_reader, 16); - d->chap[i].peak = (mpc_uint16_t) mpc_bits_read(&d->bits_reader, 16); - - tmp_size = b.size - size; - do { - mpc_uint_t rd_size = tmp_size; - mpc_uint8_t * tmp_buff = d->bits_reader.buff + ((8 - d->bits_reader.count) >> 3); - mpc_uint32_t avail_bytes = d->bytes_total + d->buffer - tmp_buff; - rd_size = mini(rd_size, avail_bytes); - memcpy(tmp_ptag, tmp_buff, rd_size); - tmp_size -= rd_size; - tmp_ptag += rd_size; - d->bits_reader.buff += rd_size; - mpc_demux_fill(d, tmp_size, 0); - } while (tmp_size > 0); - - d->chap[i].tag_size = b.size - size; - d->chap[i].tag = ptag; - ptag += b.size - size; - i++; - size = mpc_bits_get_block(&d->bits_reader, &b); - } - } - - d->bits_reader.buff -= size; - return MPC_STATUS_OK; -} -*/ -/* rockbox: not used -static mpc_status mpc_demux_chap_find(mpc_demux * d) { - mpc_status s = mpc_demux_chap_find_inner(d); - if (MPC_IS_FAILURE(s)) - mpc_demux_chap_empty(d); - return s; -} -*/ -/** - * Gets the number of chapters in the stream - * @param d pointer to a musepack demuxer - * @return the number of chapters found in the stream - */ -/* rockbox: not used -mpc_int_t mpc_demux_chap_nb(mpc_demux * d) -{ - if (d->chap_nb == -1) - mpc_demux_chap_find(d); - return d->chap_nb; -} -*/ -/** - * Gets datas associated to a given chapter - * The chapter tag is an APEv2 tag without the preamble - * @param d pointer to a musepack demuxer - * @param chap_nb chapter number you want datas (from 0 to mpc_demux_chap_nb(d) - 1) - * @return the chapter information structure - */ -/* rockbox: not used -mpc_chap_info const * mpc_demux_chap(mpc_demux * d, int chap_nb) -{ - if (d->chap_nb == -1) - mpc_demux_chap_find(d); - if (chap_nb >= d->chap_nb || chap_nb < 0) - return 0; - return &d->chap[chap_nb]; -} -*/ - -static mpc_status mpc_demux_header(mpc_demux * d) -{ - char magic[4]; - - d->si.pns = 0xFF; -/* rockbox: not used - d->si.profile_name = "n.a."; -*/ - // get header position - d->si.header_position = mpc_demux_skip_id3v2(d); - if(d->si.header_position < 0) - return MPC_STATUS_FAIL; - - d->si.tag_offset = d->si.total_file_length = d->r->get_size(d->r); - - mpc_demux_fill(d, 4, 0); - magic[0] = mpc_bits_read(&d->bits_reader, 8); - magic[1] = mpc_bits_read(&d->bits_reader, 8); - magic[2] = mpc_bits_read(&d->bits_reader, 8); - magic[3] = mpc_bits_read(&d->bits_reader, 8); - - if (memcmp(magic, "MP+", 3) == 0) { - d->si.stream_version = magic[3] & 15; - d->si.pns = magic[3] >> 4; - if (d->si.stream_version != 7) - return MPC_STATUS_FAIL; - if (mpc_demux_fill(d, 6 * 4, MPC_BUFFER_SWAP) < 6 * 4) // header block size + endian convertion - return MPC_STATUS_FAIL; - MPC_AUTO_FAIL( streaminfo_read_header_sv7(&d->si, &d->bits_reader) ); - } else if (memcmp(magic, "MPCK", 4) == 0) { - mpc_block b; - int size; - mpc_demux_fill(d, 11, 0); // max header block size - size = mpc_bits_get_block(&d->bits_reader, &b); - while( memcmp(b.key, "AP", 2) != 0 ){ // scan all blocks until audio - if (mpc_check_key(b.key) != MPC_STATUS_OK) - return MPC_STATUS_FAIL; - if (b.size > (mpc_uint64_t) MAX_BUFFER_SIZE - 11) - return MPC_STATUS_FAIL; - - if (mpc_demux_fill(d, 11 + (mpc_uint32_t) b.size, 0) <= b.size) - return MPC_STATUS_FAIL; - - if (memcmp(b.key, "SH", 2) == 0) { - MPC_AUTO_FAIL( streaminfo_read_header_sv8(&d->si, &d->bits_reader, (mpc_uint32_t) b.size) ); - } else if (memcmp(b.key, "RG", 2) == 0) { - streaminfo_gain(&d->si, &d->bits_reader); - } else if (memcmp(b.key, "EI", 2) == 0) { - streaminfo_encoder_info(&d->si, &d->bits_reader); -/* rockbox: do not use - } else if (memcmp(b.key, "SO", 2) == 0) { - MPC_AUTO_FAIL( mpc_demux_SP(d, size, (mpc_uint32_t) b.size) ); - } else if (memcmp(b.key, "ST", 2) == 0) { - MPC_AUTO_FAIL( mpc_demux_ST(d) ); -*/ - } - d->bits_reader.buff += b.size; - size = mpc_bits_get_block(&d->bits_reader, &b); - } - d->bits_reader.buff -= size; - if (d->si.stream_version == 0) // si not initialized !!! - return MPC_STATUS_FAIL; - } else { - return MPC_STATUS_FAIL; - } - - return MPC_STATUS_OK; -} - -mpc_demux * mpc_demux_init(mpc_reader * p_reader) -{ - mpc_demux* p_tmp = &g_mpc_demux; - - if (p_tmp != 0) { - memset(p_tmp, 0, sizeof(mpc_demux)); - p_tmp->buffer = g_buffer; - p_tmp->r = p_reader; -/* rockbox: not used - p_tmp->chap_nb = -1; -*/ - mpc_demux_clear_buff(p_tmp); - if (mpc_demux_header(p_tmp) == MPC_STATUS_OK && - mpc_demux_seek_init(p_tmp) == MPC_STATUS_OK) { - p_tmp->d = mpc_decoder_init(&p_tmp->si); - } else { - if (p_tmp->seek_table) - memset(p_tmp->seek_table, 0, sizeof(g_seek_table)); - p_tmp = 0; - } - } - - return p_tmp; -} - -/* rockbox: not used -void mpc_demux_exit(mpc_demux * d) -{ - mpc_decoder_exit(d->d); - memset(d->seek_table, 0, sizeof(g_seek_table)); -} -*/ - -void mpc_demux_get_info(mpc_demux * d, mpc_streaminfo * i) -{ - memcpy(i, &d->si, sizeof d->si); -} - -static mpc_status mpc_demux_decode_inner(mpc_demux * d, mpc_frame_info * i) -{ - mpc_bits_reader r; - if (d->si.stream_version >= 8) { - i->is_key_frame = MPC_FALSE; - - if (d->block_frames == 0) { - mpc_block b = {{0,0},0}; - d->bits_reader.count &= -8; - if (d->d->decoded_samples == (d->seek_table_size << d->seek_pwr) * MPC_FRAME_LENGTH) { - d->seek_table[d->seek_table_size] = (mpc_seek_t) mpc_demux_pos(d); - d->seek_table_size ++; - } - mpc_demux_fill(d, 11, MPC_BUFFER_FULL); // max header block size - mpc_bits_get_block(&d->bits_reader, &b); - while( memcmp(b.key, "AP", 2) != 0 ) { // scan all blocks until audio - MPC_AUTO_FAIL( mpc_check_key(b.key) ); - - if (memcmp(b.key, "SE", 2) == 0) { // end block - i->bits = -1; - return MPC_STATUS_OK; - } - - if (mpc_demux_fill(d, 11 + (mpc_uint32_t) b.size, MPC_BUFFER_FULL) < b.size) - return MPC_STATUS_FAIL; - - d->bits_reader.buff += b.size; - mpc_bits_get_block(&d->bits_reader, &b); - } - d->block_bits = (mpc_uint32_t) b.size * 8; - d->block_frames = 1 << d->si.block_pwr; - i->is_key_frame = MPC_TRUE; - } - mpc_demux_fill(d, MAX_FRAME_SIZE, MPC_BUFFER_FULL); - r = d->bits_reader; - mpc_decoder_decode_frame(d->d, &d->bits_reader, i); - d->block_bits -= ((d->bits_reader.buff - r.buff) << 3) + r.count - d->bits_reader.count; - d->block_frames--; - if (d->block_bits < 0 || (d->block_frames == 0 && d->block_bits > 7)) - return MPC_STATUS_FAIL; - } else { - if (d->d->decoded_samples == (d->seek_table_size << d->seek_pwr) * MPC_FRAME_LENGTH) { - d->seek_table[d->seek_table_size] = (mpc_seek_t) mpc_demux_pos(d); - d->seek_table_size ++; - } - mpc_demux_fill(d, MAX_FRAME_SIZE, MPC_BUFFER_FULL | MPC_BUFFER_SWAP); - d->block_bits = (mpc_int_t) mpc_bits_read(&d->bits_reader, 20); // read frame size - if (MPC_FRAME_LENGTH > d->d->samples - d->d->decoded_samples - 1) d->block_bits += 11; // we will read last frame size - r = d->bits_reader; - mpc_decoder_decode_frame(d->d, &d->bits_reader, i); - if (i->bits != -1 && d->block_bits != (mpc_int32_t)(((d->bits_reader.buff - r.buff) << 3) + r.count - d->bits_reader.count)) - return MPC_STATUS_FAIL; - } - if (i->bits != -1 && d->buffer + d->bytes_total < d->bits_reader.buff + ((8 - d->bits_reader.count) >> 3)) - return MPC_STATUS_FAIL; - - return MPC_STATUS_OK; -} - -mpc_status mpc_demux_decode(mpc_demux * d, mpc_frame_info * i) { - mpc_status s = mpc_demux_decode_inner(d, i); - if (MPC_IS_FAILURE(s)) - i->bits = -1; // we pretend it's end of file - return s; -} - -/* rockbox: not used -mpc_status mpc_demux_seek_second(mpc_demux * d, double seconds) -{ - return mpc_demux_seek_sample(d, (mpc_int64_t)(seconds * (double)d->si.sample_freq + 0.5)); -} -*/ - -mpc_status mpc_demux_seek_sample(mpc_demux * d, mpc_uint64_t destsample) -{ - mpc_uint32_t fwd, samples_to_skip, i; - mpc_uint32_t block_samples = MPC_FRAME_LENGTH << d->si.block_pwr; - mpc_seek_t fpos; - - destsample += d->si.beg_silence; - if (destsample > d->si.samples) destsample = d->si.samples; - fwd = (mpc_uint32_t) (destsample / block_samples); - samples_to_skip = MPC_DECODER_SYNTH_DELAY + - (mpc_uint32_t) (destsample % block_samples); - if (d->si.stream_version == 7) { - if (fwd > 32) { - fwd -= 32; - samples_to_skip += MPC_FRAME_LENGTH * 32; - } else { - samples_to_skip += MPC_FRAME_LENGTH * fwd; - fwd = 0; - } - } - - i = fwd >> (d->seek_pwr - d->si.block_pwr); - if (i >= d->seek_table_size) - i = d->seek_table_size - 1; - fpos = d->seek_table[i]; - i <<= d->seek_pwr - d->si.block_pwr; - d->d->decoded_samples = i * block_samples; - - if (d->si.stream_version >= 8) { - mpc_block b; - int size; - mpc_demux_seek(d, fpos, 11); - size = mpc_bits_get_block(&d->bits_reader, &b); - while(i < fwd) { - if (memcmp(b.key, "AP", 2) == 0) { - if (d->d->decoded_samples == (d->seek_table_size << d->seek_pwr) * MPC_FRAME_LENGTH) { - d->seek_table[d->seek_table_size] = (mpc_seek_t) mpc_demux_pos(d) - 8 * size; - d->seek_table_size ++; - } - d->d->decoded_samples += block_samples; - i++; - } - fpos += ((mpc_uint32_t)b.size + size) * 8; - mpc_demux_seek(d, fpos, 11); - size = mpc_bits_get_block(&d->bits_reader, &b); - } - d->bits_reader.buff -= size; - } else { - mpc_decoder_reset_scf(d->d, fwd != 0); - mpc_demux_seek(d, fpos, 4); - for( ; i < fwd; i++){ - if (d->d->decoded_samples == (d->seek_table_size << d->seek_pwr) * MPC_FRAME_LENGTH) { - d->seek_table[d->seek_table_size] = (mpc_seek_t) mpc_demux_pos(d); - d->seek_table_size ++; - } - d->d->decoded_samples += block_samples; - fpos += mpc_bits_read(&d->bits_reader, 20) + 20; - mpc_demux_seek(d, fpos, 4); - } - } - d->d->samples_to_skip = samples_to_skip; - return MPC_STATUS_OK; -} - -/* rockbox: not used -void mpc_set_replay_level(mpc_demux * d, float level, mpc_bool_t use_gain, - mpc_bool_t use_title, mpc_bool_t clip_prevention) -{ - float peak = (float) ( use_title ? d->si.peak_title : d->si.peak_album ); - float gain = (float) ( use_title ? d->si.gain_title : d->si.gain_album ); - - if(!use_gain && !clip_prevention) - return; - - if(!peak) - peak = 1.; - else - peak = (float) ( (1 << 15) / pow(10, peak / (20 * 256)) ); - - if(!gain) - gain = 1.; - else - gain = (float) pow(10, (level - gain / 256) / 20); - - if(clip_prevention && (peak < gain || !use_gain)) - gain = peak; - - mpc_decoder_scale_output(d->d, gain); -} -*/ diff --git a/apps/codecs/libmusepack/mpc_types.h b/apps/codecs/libmusepack/mpc_types.h deleted file mode 100644 index 0e7aa9d2c3..0000000000 --- a/apps/codecs/libmusepack/mpc_types.h +++ /dev/null @@ -1,145 +0,0 @@ -/* - Copyright (c) 2005-2009, The Musepack Development Team - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are - met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - - * Neither the name of the The Musepack Development Team nor the - names of its contributors may be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -#ifndef _MPC_TYPES_H_ -#define _MPC_TYPES_H_ -#ifdef WIN32 -#pragma once -#endif - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef _MSC_VER -typedef __int8 mpc_int8_t; -typedef unsigned __int8 mpc_uint8_t; -typedef __int16 mpc_int16_t; -typedef unsigned __int16 mpc_uint16_t; -typedef __int32 mpc_int32_t; -typedef unsigned __int32 mpc_uint32_t; -typedef __int64 mpc_int64_t; -typedef unsigned __int64 mpc_uint64_t; -#define mpc_inline __inline -#else -typedef signed char mpc_int8_t; -typedef unsigned char mpc_uint8_t; -typedef short mpc_int16_t; -typedef unsigned short mpc_uint16_t; -typedef int mpc_int32_t; -typedef unsigned int mpc_uint32_t; -typedef long long mpc_int64_t; -typedef unsigned long long mpc_uint64_t; -#define mpc_inline inline -#endif - -typedef int mpc_int_t; -typedef unsigned int mpc_uint_t; -typedef size_t mpc_size_t; -typedef mpc_uint8_t mpc_bool_t; - -// #define LONG_SEEK_TABLE -#ifdef LONG_SEEK_TABLE // define as needed (mpc_uint32_t supports files up to 512 MB) -typedef mpc_uint64_t mpc_seek_t; -#else -typedef mpc_uint32_t mpc_seek_t; -#endif - -# define mpc_int64_min -9223372036854775808ll -# define mpc_int64_max 9223372036854775807ll - -typedef struct mpc_quantizer { - mpc_int16_t L [36]; - mpc_int16_t R [36]; -} mpc_quantizer; - -/// Libmpcdec error codes -typedef enum mpc_status { - // Success. - MPC_STATUS_OK = 0, - // Generic failure (I/O error or invalid file). - MPC_STATUS_FAIL = -1 -} mpc_status; - -#define MPC_FIXED_POINT -#define MPC_FIXED_POINT_SHIFT 16 - -#ifdef MPC_FIXED_POINT -# define MPC_FIXED_POINT_FRACTPART 14 -# define MPC_FIXED_POINT_SCALE_SHIFT (MPC_FIXED_POINT_SHIFT + MPC_FIXED_POINT_FRACTPART) -# define MPC_FIXED_POINT_SCALE (1 << (MPC_FIXED_POINT_SCALE_SHIFT - 1)) -typedef mpc_int32_t MPC_SAMPLE_FORMAT; -#else -typedef float MPC_SAMPLE_FORMAT; -#endif - -enum { - MPC_FALSE = 0, - MPC_TRUE = !MPC_FALSE -}; - -//// 'Cdecl' forces the use of standard C/C++ calling convention /////// -#if defined _WIN32 -# define mpc_cdecl __cdecl -#elif defined __ZTC__ -# define mpc_cdecl _cdecl -#elif defined __TURBOC__ -# define mpc_cdecl cdecl -#else -# define mpc_cdecl -#endif - -/* DLL building support on win32 hosts */ -#ifndef MPC_API -# ifdef DLL_EXPORT /* defined by libtool (if required) */ -# define MPC_API __declspec(dllexport) -# endif -# ifdef MPC_DLL_IMPORT /* define if linking with this dll */ -# define MPC_API __declspec(dllimport) -# endif -# ifndef MPC_API /* static linking or !_WIN32 */ -# if defined(__GNUC__) && (__GNUC__ >= 4) -# define MPC_API __attribute__ ((visibility("default"))) -# else -# define MPC_API -# endif -# endif -#endif - -#ifdef __cplusplus -} -#endif -#endif diff --git a/apps/codecs/libmusepack/mpcdec.h b/apps/codecs/libmusepack/mpcdec.h deleted file mode 100644 index 85536e726a..0000000000 --- a/apps/codecs/libmusepack/mpcdec.h +++ /dev/null @@ -1,212 +0,0 @@ -/* - Copyright (c) 2005-2009, The Musepack Development Team - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are - met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - - * Neither the name of the The Musepack Development Team nor the - names of its contributors may be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -/// \file mpcdec.h -/// Top level include file for libmpcdec. -#ifndef _MPCDEC_H_ -#define _MPCDEC_H_ -#ifdef WIN32 -#pragma once -#endif - -#include "reader.h" -#include "streaminfo.h" -#include "config.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#if (CONFIG_CPU == MCF5250) -/* Enough IRAM but performance suffers with ICODE_ATTR. */ -#define IBSS_ATTR_MPC_LARGE_IRAM IBSS_ATTR -#define ICODE_ATTR_MPC_LARGE_IRAM -#define ICONST_ATTR_MPC_LARGE_IRAM ICONST_ATTR -/* Does not fit into IRAM. */ -#define IBSS_ATTR_MPC_BITBUFFER -#define ICODE_ATTR_MPC_SV8_BS_DEC -/* Keep the data arrays of bitsreadr.c in IRAM. */ -#define ICONST_ATTR_MPC_BITSREADER ICONST_ATTR - -#elif (CONFIG_CPU == PP5022) || (CONFIG_CPU == PP5024) -/* Enough IRAM to move additional data and code to it. */ -#define IBSS_ATTR_MPC_LARGE_IRAM IBSS_ATTR -#define ICODE_ATTR_MPC_LARGE_IRAM ICODE_ATTR -#define ICONST_ATTR_MPC_LARGE_IRAM ICONST_ATTR -/* Does not fit into IRAM. */ -#define IBSS_ATTR_MPC_BITBUFFER -#define ICODE_ATTR_MPC_SV8_BS_DEC -/* Not putting the data arrays of bitsreader.c to IRAM allows to move the - * sv7/sv8 bitstream demuxing into IRAM. This config is faster. */ -#define ICONST_ATTR_MPC_BITSREADER - -#elif defined(CPU_S5L870X) -/* Enough IRAM to move additional data and code to it. */ -#define IBSS_ATTR_MPC_LARGE_IRAM IBSS_ATTR -#define ICODE_ATTR_MPC_LARGE_IRAM ICODE_ATTR -#define ICONST_ATTR_MPC_LARGE_IRAM ICONST_ATTR -/* Faster when moved to IRAM. */ -#define IBSS_ATTR_MPC_BITBUFFER IBSS_ATTR -#define ICODE_ATTR_MPC_SV8_BS_DEC ICODE_ATTR -/* Not faster when moved to IRAM. */ -#define ICONST_ATTR_MPC_BITSREADER - -#else -/* Not enough IRAM available. */ -#define IBSS_ATTR_MPC_LARGE_IRAM -#define ICODE_ATTR_MPC_LARGE_IRAM -#define ICONST_ATTR_MPC_LARGE_IRAM -#define IBSS_ATTR_MPC_BITBUFFER -#define ICODE_ATTR_MPC_SV8_BS_DEC -#define ICONST_ATTR_MPC_BITSREADER -#endif - -enum { - MPC_FRAME_LENGTH = (36 * 32), ///< Samples per mpc frame - MPC_DECODER_BUFFER_LENGTH = (MPC_FRAME_LENGTH * 2), ///< Required buffer size for decoder (2 channels) - MPC_DECODER_SYNTH_DELAY = 481 -}; - -typedef struct mpc_decoder_t mpc_decoder; -typedef struct mpc_demux_t mpc_demux; - -typedef struct mpc_bits_reader_t { - unsigned char * buff; /// pointer on current byte - unsigned int count; /// unread bits in current byte - mpc_uint8_t *buffered_addr; /// used for rockbox Coldfire optimization only - mpc_uint32_t buffered_code; /// used for rockbox Coldfire optimization only -} mpc_bits_reader; - -typedef struct mpc_frame_info_t { - mpc_uint32_t samples; /// number of samples in the frame (counting once for multiple channels) - mpc_int32_t bits; /// number of bits consumed by this frame (-1) if end of stream - MPC_SAMPLE_FORMAT * buffer; /// frame samples buffer (size = samples * channels * sizeof(MPC_SAMPLE_FORMAT)) - mpc_bool_t is_key_frame; /// 1 if this frame is a key frame (first in block) 0 else. Set by the demuxer. -} mpc_frame_info; - -/* rockbox: not used -typedef struct mpc_chap_info_t { - mpc_uint64_t sample; /// sample where the chapter starts - mpc_uint16_t gain; /// replaygain chapter value - mpc_uint16_t peak; /// peak chapter loudness level - mpc_uint_t tag_size; /// size of the tag element (0 if no tag is present for this chapter) - char * tag; /// pointer to an APEv2 tag without the preamble -} mpc_chap_info; -*/ - -/// Initializes mpc decoder with the supplied stream info parameters. -/// \param si streaminfo structure indicating format of source stream -/// \return pointer on the initialized decoder structure if successful, 0 if not -MPC_API mpc_decoder * mpc_decoder_init(mpc_streaminfo *si); - -/* rockbox: not used -/// Releases input mpc decoder -MPC_API void mpc_decoder_exit(mpc_decoder *p_dec); -*/ - -/** - * Sets decoder sample scaling factor. All decoded samples will be multiplied - * by this factor. Useful for applying replay gain. - * @param scale_factor multiplicative scaling factor - */ -/* rockbox: changed to static -MPC_API void mpc_decoder_scale_output(mpc_decoder *p_dec, double scale_factor); -*/ - -MPC_API void mpc_decoder_decode_frame(mpc_decoder * d, mpc_bits_reader * r, mpc_frame_info * i); - -// This is the gain reference used in old replaygain -#define MPC_OLD_GAIN_REF 64.82 - -/** - * init demuxer - * @param p_reader initialized mpc_reader pointer - * @return an initialized mpc_demux pointer - */ -MPC_API mpc_demux * mpc_demux_init(mpc_reader * p_reader); -/* rockbox: not used -/// free demuxer -MPC_API void mpc_demux_exit(mpc_demux * d); -*/ -/** - * Calls mpc_decoder_scale_output to set the scaling factor according to the - * replay gain stream information and the supplied ouput level - * @param d pointer to a musepack demuxer - * @param level the desired ouput level (in db). Must be MPC_OLD_GAIN_REF (64.82 db) if you want to get the old replaygain behavior - * @param use_gain set it to MPC_TRUE if you want to set the scaling factor according to the stream gain - * @param use_title MPC_TRUE : uses the title gain, MPC_FALSE : uses the album gain - * @param clip_prevention MPC_TRUE : uses cliping prevention - */ -/* rockbox: not used -MPC_API void mpc_set_replay_level(mpc_demux * d, float level, mpc_bool_t use_gain, - mpc_bool_t use_title, mpc_bool_t clip_prevention); -*/ -/// decode frame -MPC_API mpc_status mpc_demux_decode(mpc_demux * d, mpc_frame_info * i); -/// get streaminfo -MPC_API void mpc_demux_get_info(mpc_demux * d, mpc_streaminfo * i); -/// seeks to a given sample -MPC_API mpc_status mpc_demux_seek_sample(mpc_demux * d, mpc_uint64_t destsample); -/* rockbox: not used -/// seeks to a given second -MPC_API mpc_status mpc_demux_seek_second(mpc_demux * d, double seconds); -*/ - -/* rockbox: keep static -/// \return the current position in the stream (in bits) from the beginning of the file -MPC_API mpc_seek_t mpc_demux_pos(mpc_demux * d); -*/ - -/// chapters : only for sv8 streams -/** - * Gets the number of chapters in the stream - * @param d pointer to a musepack demuxer - * @return the number of chapters found in the stream - */ -/* rockbox: not used -MPC_API mpc_int_t mpc_demux_chap_nb(mpc_demux * d); -*/ -/** - * Gets datas associated to a given chapter - * The chapter tag is an APEv2 tag without the preamble - * @param d pointer to a musepack demuxer - * @param chap_nb chapter number you want datas (from 0 to mpc_demux_chap_nb(d) - 1) - * @return the chapter information structure - */ -/* rockbox: not used -MPC_API mpc_chap_info const * mpc_demux_chap(mpc_demux * d, int chap_nb); -*/ -#ifdef __cplusplus -} -#endif -#endif diff --git a/apps/codecs/libmusepack/mpcdec_math.h b/apps/codecs/libmusepack/mpcdec_math.h deleted file mode 100644 index 955681f4e5..0000000000 --- a/apps/codecs/libmusepack/mpcdec_math.h +++ /dev/null @@ -1,231 +0,0 @@ -/* - Copyright (c) 2005, The Musepack Development Team - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are - met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - - * Neither the name of the The Musepack Development Team nor the - names of its contributors may be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/// \file math.h -/// Libmpcdec internal math routines. - -#ifndef _mpcdec_math_h_ -#define _mpcdec_math_h_ - -#include "mpc_types.h" - -#define MPC_FIXED_POINT_SHIFT 16 - -#ifdef MPC_FIXED_POINT - - #ifdef _WIN32_WCE - #include - #define MPC_HAVE_MULHIGH - #endif - - typedef mpc_int64_t MPC_SAMPLE_FORMAT_MULTIPLY; - - #define MAKE_MPC_SAMPLE(X) (MPC_SAMPLE_FORMAT)((double)(X) * (double)(((mpc_int64_t)1)<>Y) - -#if defined(CPU_COLDFIRE) - - #define MPC_MULTIPLY(X,Y) mpc_multiply((X), (Y)) - #define MPC_MULTIPLY_EX(X,Y,Z) mpc_multiply_ex((X), (Y), (Z)) - - static inline MPC_SAMPLE_FORMAT mpc_multiply(MPC_SAMPLE_FORMAT x, - MPC_SAMPLE_FORMAT y) - { - MPC_SAMPLE_FORMAT t1, t2; - asm volatile ( - "mac.l %[x],%[y],%%acc0\n" /* multiply */ - "mulu.l %[y],%[x] \n" /* get lower half, avoid emac stall */ - "movclr.l %%acc0,%[t1] \n" /* get higher half */ - "moveq.l #17,%[t2] \n" - "asl.l %[t2],%[t1] \n" /* hi <<= 17, plus one free */ - "moveq.l #14,%[t2] \n" - "lsr.l %[t2],%[x] \n" /* (unsigned)lo >>= 14 */ - "or.l %[x],%[t1] \n" /* combine result */ - : /* outputs */ - [t1]"=&d"(t1), - [t2]"=&d"(t2), - [x] "+d" (x) - : /* inputs */ - [y] "d" (y) - ); - return t1; - } - - static inline MPC_SAMPLE_FORMAT mpc_multiply_ex(MPC_SAMPLE_FORMAT x, - MPC_SAMPLE_FORMAT y, - unsigned shift) - { - MPC_SAMPLE_FORMAT t1, t2; - asm volatile ( - "mac.l %[x],%[y],%%acc0\n" /* multiply */ - "mulu.l %[y],%[x] \n" /* get lower half, avoid emac stall */ - "movclr.l %%acc0,%[t1] \n" /* get higher half */ - "moveq.l #31,%[t2] \n" - "sub.l %[sh],%[t2] \n" /* t2 = 31 - shift */ - "ble.s 1f \n" - "asl.l %[t2],%[t1] \n" /* hi <<= 31 - shift */ - "lsr.l %[sh],%[x] \n" /* (unsigned)lo >>= shift */ - "or.l %[x],%[t1] \n" /* combine result */ - "bra.s 2f \n" - "1: \n" - "neg.l %[t2] \n" /* t2 = shift - 31 */ - "asr.l %[t2],%[t1] \n" /* hi >>= t2 */ - "2: \n" - : /* outputs */ - [t1]"=&d"(t1), - [t2]"=&d"(t2), - [x] "+d" (x) - : /* inputs */ - [y] "d" (y), - [sh]"d" (shift) - ); - return t1; - } - #elif defined(CPU_ARM) - /* Calculate: result = (X*Y)>>14 */ - #define MPC_MULTIPLY(X,Y) \ - ({ \ - MPC_SAMPLE_FORMAT lo; \ - MPC_SAMPLE_FORMAT hi; \ - asm volatile ( \ - "smull %[lo], %[hi], %[x], %[y] \n\t" /* multiply */ \ - "mov %[lo], %[lo], lsr #14 \n\t" /* lo >>= 14 */ \ - "orr %[lo], %[lo], %[hi], lsl #18" /* lo |= (hi << 18) */ \ - : [lo]"=&r"(lo), [hi]"=&r"(hi) \ - : [x]"r"(X), [y]"r"(Y)); \ - lo; \ - }) - - /* Calculate: result = (X*Y)>>Z */ - #define MPC_MULTIPLY_EX(X,Y,Z) \ - ({ \ - MPC_SAMPLE_FORMAT lo; \ - MPC_SAMPLE_FORMAT hi; \ - asm volatile ( \ - "smull %[lo], %[hi], %[x], %[y] \n\t" /* multiply */ \ - "mov %[lo], %[lo], lsr %[shr] \n\t" /* lo >>= Z */ \ - "orr %[lo], %[lo], %[hi], lsl %[shl]" /* lo |= (hi << (32-Z)) */ \ - : [lo]"=&r"(lo), [hi]"=&r"(hi) \ - : [x]"r"(X), [y]"r"(Y), [shr]"r"(Z), [shl]"r"(32-Z)); \ - lo; \ - }) - #else /* libmusepack standard */ - - #define MPC_MULTIPLY_NOTRUNCATE(X,Y) \ - (((MPC_SAMPLE_FORMAT_MULTIPLY)(X) * (MPC_SAMPLE_FORMAT_MULTIPLY)(Y)) >> MPC_FIXED_POINT_FRACTPART) - - #define MPC_MULTIPLY_EX_NOTRUNCATE(X,Y,Z) \ - (((MPC_SAMPLE_FORMAT_MULTIPLY)(X) * (MPC_SAMPLE_FORMAT_MULTIPLY)(Y)) >> (Z)) - - #ifdef _DEBUG - static inline MPC_SAMPLE_FORMAT MPC_MULTIPLY(MPC_SAMPLE_FORMAT item1,MPC_SAMPLE_FORMAT item2) - { - MPC_SAMPLE_FORMAT_MULTIPLY temp = MPC_MULTIPLY_NOTRUNCATE(item1,item2); - assert(temp == (MPC_SAMPLE_FORMAT_MULTIPLY)(MPC_SAMPLE_FORMAT)temp); - return (MPC_SAMPLE_FORMAT)temp; - } - - static inline MPC_SAMPLE_FORMAT MPC_MULTIPLY_EX(MPC_SAMPLE_FORMAT item1,MPC_SAMPLE_FORMAT item2,unsigned shift) - { - MPC_SAMPLE_FORMAT_MULTIPLY temp = MPC_MULTIPLY_EX_NOTRUNCATE(item1,item2,shift); - assert(temp == (MPC_SAMPLE_FORMAT_MULTIPLY)(MPC_SAMPLE_FORMAT)temp); - return (MPC_SAMPLE_FORMAT)temp; - } - #else - #define MPC_MULTIPLY(X,Y) ((MPC_SAMPLE_FORMAT)MPC_MULTIPLY_NOTRUNCATE(X,Y)) - #define MPC_MULTIPLY_EX(X,Y,Z) ((MPC_SAMPLE_FORMAT)MPC_MULTIPLY_EX_NOTRUNCATE(X,Y,Z)) - #endif - - #endif - - #ifdef MPC_HAVE_MULHIGH - #define MPC_MULTIPLY_FRACT(X,Y) _MulHigh(X,Y) - #else - #if defined(CPU_COLDFIRE) - /* loses one bit of accuracy. The rest of the macros won't be as easy as this... */ - #define MPC_MULTIPLY_FRACT(X,Y) \ - ({ \ - MPC_SAMPLE_FORMAT t; \ - asm volatile ( \ - "mac.l %[A], %[B], %%acc0\n\t" \ - "movclr.l %%acc0, %[t] \n\t" \ - "asr.l #1, %[t] \n\t" \ - : [t] "=d" (t) \ - : [A] "r" ((X)), [B] "r" ((Y))); \ - t; \ - }) - #elif defined(CPU_ARM) - /* Calculate: result = (X*Y)>>32, without need for >>32 */ - #define MPC_MULTIPLY_FRACT(X,Y) \ - ({ \ - MPC_SAMPLE_FORMAT lo; \ - MPC_SAMPLE_FORMAT hi; \ - asm volatile ( \ - "smull %[lo], %[hi], %[x], %[y]" /* hi = result */ \ - : [lo]"=&r"(lo), [hi]"=&r"(hi) \ - : [x]"r"(X), [y]"r"(Y)); \ - hi; \ - }) - #else - #define MPC_MULTIPLY_FRACT(X,Y) MPC_MULTIPLY_EX(X,Y,32) - #endif - #endif - - #define MPC_MAKE_FRACT_CONST(X) (MPC_SAMPLE_FORMAT)((X) * (double)(((mpc_int64_t)1)<<32) ) - - #define MPC_MULTIPLY_FLOAT_INT(X,Y) ((X)*(Y)) - -#else - //in floating-point mode, decoded samples are in -1...1 range - - typedef float MPC_SAMPLE_FORMAT; - - #define MAKE_MPC_SAMPLE(X) ((MPC_SAMPLE_FORMAT)(X)) - #define MAKE_MPC_SAMPLE_EX(X,Y) ((MPC_SAMPLE_FORMAT)(X)) - - #define MPC_MULTIPLY_FRACT(X,Y) ((X)*(Y)) - #define MPC_MAKE_FRACT_CONST(X) (X) - - #define MPC_MULTIPLY_FLOAT_INT(X,Y) ((X)*(Y)) - #define MPC_MULTIPLY(X,Y) ((X)*(Y)) - #define MPC_MULTIPLY_EX(X,Y,Z) ((X)*(Y)) - - #define MPC_SHR_RND(X, Y) (X) - -#endif - -#endif // _mpcdec_math_h_ - diff --git a/apps/codecs/libmusepack/reader.h b/apps/codecs/libmusepack/reader.h deleted file mode 100644 index c46844cd59..0000000000 --- a/apps/codecs/libmusepack/reader.h +++ /dev/null @@ -1,100 +0,0 @@ -/* - Copyright (c) 2005-2009, The Musepack Development Team - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are - met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - - * Neither the name of the The Musepack Development Team nor the - names of its contributors may be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -/// \file reader.h -#ifndef _MPCDEC_READER_H_ -#define _MPCDEC_READER_H_ -#ifdef WIN32 -#pragma once -#endif - -#include "mpc_types.h" -#include - -#ifdef __cplusplus -extern "C" { -#endif - - -/// \brief Stream reader interface structure. -/// -/// This is the structure you must supply to the musepack decoding library -/// to feed it with raw data. Implement the five member functions to provide -/// a functional reader. -typedef struct mpc_reader_t mpc_reader; -struct mpc_reader_t { - /// Reads size bytes of data into buffer at ptr. - mpc_int32_t (*read)(mpc_reader *p_reader, void *ptr, mpc_int32_t size); - - /// Seeks to byte position offset. - mpc_bool_t (*seek)(mpc_reader *p_reader, mpc_int32_t offset); - - /// Returns the current byte offset in the stream. - mpc_int32_t (*tell)(mpc_reader *p_reader); - - /// Returns the total length of the source stream, in bytes. - mpc_int32_t (*get_size)(mpc_reader *p_reader); - - /* rockbox: not used - /// True if the stream is a seekable stream. - mpc_bool_t (*canseek)(mpc_reader *p_reader); - - /// Field that can be used to identify a particular instance of - /// reader or carry along data associated with that reader. - void *data; - */ -}; -/* rockbox: not used -/// Initializes reader with default stdio file reader implementation. Use -/// this if you're just reading from a plain file. -/// -/// \param r p_reader handle to initialize -/// \param filename input filename to attach to the reader -MPC_API mpc_status mpc_reader_init_stdio(mpc_reader *p_reader, const char *filename); - -/// Initializes reader with default stdio file reader implementation. Use -/// this if you prefer to open the file yourself. -/// -/// \param r p_reader handle to initialize -/// \param p_file input file handle (already open) -MPC_API mpc_status mpc_reader_init_stdio_stream(mpc_reader * p_reader, FILE * p_file); - -/// Release reader with default stdio file reader implementation. -/// -/// \param r reader handle to release -MPC_API void mpc_reader_exit_stdio(mpc_reader *p_reader); -*/ -#ifdef __cplusplus -} -#endif -#endif diff --git a/apps/codecs/libmusepack/requant.c b/apps/codecs/libmusepack/requant.c deleted file mode 100644 index fc27dfd199..0000000000 --- a/apps/codecs/libmusepack/requant.c +++ /dev/null @@ -1,184 +0,0 @@ -/* - Copyright (c) 2005-2009, The Musepack Development Team - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are - met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - - * Neither the name of the The Musepack Development Team nor the - names of its contributors may be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -/// \file requant.c -/// Requantization function implementations. -/// \todo document me -#include "mpcdec.h" -#include "requant.h" -#include "mpcdec_math.h" -#include "decoder.h" -#include "internal.h" -#include - -/* C O N S T A N T S */ -// Bits per sample for chosen quantizer -const mpc_uint8_t Res_bit [18] ICONST_ATTR = { - 0, 0, 0, 0, 0, 0, 0, 0, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 -}; - -// Requantization coefficients -// 65536/step bzw. 65536/(2*D+1) - -#define _(X) MAKE_MPC_SAMPLE_EX(X,14) - -const MPC_SAMPLE_FORMAT __Cc [1 + 18] ICONST_ATTR = { - _(111.285962475327f), // 32768/2/255*sqrt(3) - _(65536.000000000000f), _(21845.333333333332f), _(13107.200000000001f), _(9362.285714285713f), - _(7281.777777777777f), _(4369.066666666666f), _(2114.064516129032f), _(1040.253968253968f), - _(516.031496062992f), _(257.003921568627f), _(128.250489236790f), _(64.062561094819f), - _(32.015632633121f), _(16.003907203907f), _(8.000976681723f), _(4.000244155527f), - _(2.000061037018f), _(1.000015259021f) -}; - -#undef _ - -// Requantization offset -// 2*D+1 = steps of quantizer -const mpc_int16_t __Dc [1 + 18] ICONST_ATTR = { - 2, - 0, 1, 2, 3, 4, 7, 15, 31, 63, - 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767 -}; - -// Table'ized SCF calculated from mpc_decoder_scale_output(d, 1.0) -static const mpc_uint32_t SCF[] = { - 1289035711, 1073741824, 1788812356, 1490046106, 1241179595, 1033878604, 861200887, 717363687, - 597550081, 497747664, 414614180, 345365595, 287682863, 239634262, 199610707, 166271859, - 138501244, 115368858, 96100028, 80049465, 66679657, 55542865, 46266132, 38538793, - 32102070, 26740403, 22274239, 18554010, 15455132, 12873826, 10723648, 8932591, - 7440676, 6197939, 5162763, 4300482, 3582218, 2983918, 2485546, 2070412, - 1724613, 1436569, 1196634, 996773, 830293, 691618, 576104, 479883, - 399734, 332970, 277358, 231034, 192446, 160304, 133530, 111228, - 92651, 77176, 64286, 53549, 44605, 37155, 30949, 25780, - 21474, 17888, 14900, 12411, 10338, 8612, 7173, 5975, - 4977, 4146, 3453, 2876, 2396, 1996, 1662, 1385, - 1153, 961, 800, 666, 555, 462, 385, 321, - 267, 222, 185, 154, 128, 107, 89, 74, - 61, 51, 43, 35, 29, 24, 20, 17, - 14, 11, 9, 8, 6, 5, 4, 3, - 3, 2, 2, 1, 1, 1, 1, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 2147483648, 2147483648, 2147483648, 2147483648, 2147483648, 2147483648, 2147483648, - 2147483648, 2147483648, 2147483648, 2147483648, 1930697728, 1608233877, 1339627724, 1115883992, - 1859019579, 1548527365, 1289893354, 1074456223, 1790002518, 1491037488, 1242005398, 2069132964, - 1723547752, 1435681952, 1195895306, 1992315335, 1659560152, 1382381519, 1151497076, 1918349601, - 1597948125, 1331059892, 1108747153, 1847129882, 1538623477, 1281643607, 2135168687, 1778554232, - 1481501287, 1234061927, 2055899448, 1712524489, 1426499787, 1188246741, 1979573121, 1648946134, - 1373540247, 1144132468, 1906080447, 1587728158, 1322546856, 1101655960, 1835316227, 1528782931, - 1273446622, 2121512828, 1767179166, 1472026076, 1226169259, 2042750570, 1701571728, 1417376349, - 1180647093, 1966912401, 1638400000, 1364755521, 1136814961, 1893889764, 1577573554, 1314088268, - 1094610119, 1823578129, 1519005322, 1265302063, 2107944308, 1755876851, 1462611466, 1218327071, - 2029685788, 1690689017, 1408311261, 1173096050, 1954332656, 1627921315, 1356026979, 1129544254, - 1881777048, 1567483896, 1305683778, 1087609341, 1811915104, 1509290248, 1257209594, 2094462567, - 1744646821, 1453257069, 1210535039, 2016704564, 1679875908, 1399304151, 1165593302, 1941833367, - 1617509648, 1347354262, 1122320049, 1869741801, 1557458768, 1297333040, 1080653338, 1800326672, - 1499637308, 1249168882, 2081067051, 1733488616, 1443962500, 1202792843, 2003806364, 1669131957, - 1390354647, 1158138538, 1929414019, 1607164572, 1338737013, 1115142047, 1857783528, 1547497758 -}; - -// Table'ized SCF_shift calculated from mpc_decoder_scale_output(d, 1.0) -static const mpc_uint8_t SCF_shift[] = { - 30, 30, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, - 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, - 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, - 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, - 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, - 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, - 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, - 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, - 31, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 1, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, - 5, 5, 5, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, - 9, 9, 10, 10, 10, 10, 11, 11, 11, 12, 12, 12, 12, 13, 13, 13, - 13, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 17, 17, 17, 17, - 18, 18, 18, 18, 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 22, - 22, 22, 22, 23, 23, 23, 23, 24, 24, 24, 24, 25, 25, 25, 25, 26, - 26, 26, 27, 27, 27, 27, 28, 28, 28, 28, 29, 29, 29, 29, 30, 30 -}; - -/* F U N C T I O N S */ -/* not used anymore, tables from above are used -#ifdef MPC_FIXED_POINT -static mpc_uint32_t find_shift(double fval) -{ - mpc_int64_t val = (mpc_int64_t) fval; - mpc_uint32_t ptr = 0; - if(val<0) - val = -val; - while(val) - { - val >>= 1; - ptr++; - } - return ptr > 31 ? 0 : 31 - ptr; -} -#endif - -#define SET_SCF(N,X) d->SCF[N] = MAKE_MPC_SAMPLE_EX(X,d->SCF_shift[N] = (mpc_uint8_t) find_shift(X)); - -static void -mpc_decoder_scale_output(mpc_decoder *d, double factor) -{ - mpc_int32_t n; double f1, f2; - -#ifndef MPC_FIXED_POINT - factor *= 1.0 / (double) (1<<(MPC_FIXED_POINT_SHIFT-1)); -#else - factor *= 1.0 / (double) (1<<(16-MPC_FIXED_POINT_SHIFT)); -#endif - f1 = f2 = factor; - - // handles +1.58...-98.41 dB, where's scf[n] / scf[n-1] = 1.20050805774840750476 - - SET_SCF(1,factor); - - f1 *= 0.83298066476582673961; - f2 *= 1/0.83298066476582673961; - - for ( n = 1; n <= 128; n++ ) { - SET_SCF((mpc_uint8_t)(1+n),f1); - SET_SCF((mpc_uint8_t)(1-n),f2); - f1 *= 0.83298066476582673961; - f2 *= 1/0.83298066476582673961; - } -} -*/ -void -mpc_decoder_init_quant(mpc_decoder *d, MPC_SAMPLE_FORMAT factor) -{ - //mpc_decoder_scale_output(d, (double)factor / MPC_FIXED_POINT_SHIFT) - (void)factor; - memcpy(d->SCF, SCF, sizeof(d->SCF)); - memcpy(d->SCF_shift, SCF_shift, sizeof(d->SCF_shift)); -} diff --git a/apps/codecs/libmusepack/requant.h b/apps/codecs/libmusepack/requant.h deleted file mode 100644 index 908fda30eb..0000000000 --- a/apps/codecs/libmusepack/requant.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - Copyright (c) 2005-2009, The Musepack Development Team - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are - met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - - * Neither the name of the The Musepack Development Team nor the - names of its contributors may be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -/// \file requant.h -/// Requantization function definitions. -#ifndef _MPCDEC_REQUANT_H_ -#define _MPCDEC_REQUANT_H_ -#ifdef WIN32 -#pragma once -#endif - -#include "mpc_types.h" - -#ifdef __cplusplus -extern "C" { -#endif - - -/* C O N S T A N T S */ -extern const mpc_uint8_t Res_bit [18]; ///< Bits per sample for chosen quantizer -extern const MPC_SAMPLE_FORMAT __Cc [1 + 18]; ///< Requantization coefficients -extern const mpc_int16_t __Dc [1 + 18]; ///< Requantization offset - -#define Cc (__Cc + 1) -#define Dc (__Dc + 1) - - -#ifdef __cplusplus -} -#endif -#endif diff --git a/apps/codecs/libmusepack/streaminfo.c b/apps/codecs/libmusepack/streaminfo.c deleted file mode 100644 index 6b4d3df0c1..0000000000 --- a/apps/codecs/libmusepack/streaminfo.c +++ /dev/null @@ -1,255 +0,0 @@ -/* - Copyright (c) 2005-2009, The Musepack Development Team - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are - met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - - * Neither the name of the The Musepack Development Team nor the - names of its contributors may be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -/// \file streaminfo.c -/// Implementation of streaminfo reading functions. - -#include -#include "mpcdec.h" -#include "streaminfo.h" -#include -#include "internal.h" -#include "huffman.h" -#include "mpc_bits_reader.h" - -/* rockbox: not used -static const char na[] = "n.a."; -static char const * const versionNames[] = { - na, "'Unstable/Experimental'", na, na, na, "'quality 0'", "'quality 1'", - "'Telephone'", "'Thumb'", "'Radio'", "'Standard'", "'Extreme'", "'Insane'", - "'BrainDead'", "'quality 9'", "'quality 10'" -}; -*/ -static const mpc_int32_t samplefreqs[8] = { 44100, 48000, 37800, 32000 }; -/* rockbox: not used -static const char * -mpc_get_version_string(float profile) // profile is 0...15, where 7...13 is used -{ - return profile >= sizeof versionNames / sizeof *versionNames ? na : versionNames[(int)profile]; -} -*/ -/* rockbox: not used -static void -mpc_get_encoder_string(mpc_streaminfo* si) -{ - int ver = si->encoder_version; - if (si->stream_version >= 8) - ver = (si->encoder_version >> 24) * 100 + ((si->encoder_version >> 16) & 0xFF); - if (ver <= 116) { - if (ver == 0) { - sprintf(si->encoder, "Buschmann 1.7.0...9, Klemm 0.90...1.05"); - } else { - switch (ver % 10) { - case 0: - sprintf(si->encoder, "Release %u.%u", ver / 100, - ver / 10 % 10); - break; - case 2: case 4: case 6: case 8: - sprintf(si->encoder, "Beta %u.%02u", ver / 100, - ver % 100); - break; - default: - sprintf(si->encoder, "--Alpha-- %u.%02u", - ver / 100, ver % 100); - break; - } - } - } else { - int major = si->encoder_version >> 24; - int minor = (si->encoder_version >> 16) & 0xFF; - int build = (si->encoder_version >> 8) & 0xFF; - char * tmp = "--Stable--"; - - if (minor & 1) - tmp = "--Unstable--"; - - sprintf(si->encoder, "%s %u.%u.%u", tmp, major, minor, build); - } -} -*/ - -static mpc_status check_streaminfo(mpc_streaminfo * si) -{ - if (si->max_band == 0 || si->max_band >= 32 - || si->channels > 2 || si->channels == 0 || si->sample_freq == 0) - return MPC_STATUS_FAIL; - return MPC_STATUS_OK; -} - -/// Reads streaminfo from SV7 header. -mpc_status -streaminfo_read_header_sv7(mpc_streaminfo* si, mpc_bits_reader * r) -{ - mpc_uint32_t frames, last_frame_samples; - - si->bitrate = 0; - frames = (mpc_bits_read(r, 16) << 16) | mpc_bits_read(r, 16); - mpc_bits_read(r, 1); // intensity stereo : should be 0 - si->ms = mpc_bits_read(r, 1); - si->max_band = mpc_bits_read(r, 6); - si->profile = mpc_bits_read(r, 4); -/* rockbox: not used - si->profile_name = mpc_get_version_string(si->profile); -*/ - mpc_bits_read(r, 2); // Link ? - si->sample_freq = samplefreqs[mpc_bits_read(r, 2)]; - mpc_bits_read(r, 16); // Estimatedpeak_title - si->gain_title = (mpc_uint16_t) mpc_bits_read(r, 16); - si->peak_title = (mpc_uint16_t) mpc_bits_read(r, 16); - si->gain_album = (mpc_uint16_t) mpc_bits_read(r, 16); - si->peak_album = (mpc_uint16_t) mpc_bits_read(r, 16); - si->is_true_gapless = mpc_bits_read(r, 1); // true gapless: used? - last_frame_samples = mpc_bits_read(r, 11); // true gapless: valid samples for last frame - si->fast_seek = mpc_bits_read(r, 1); // fast seeking - mpc_bits_read(r, 19); // unused - si->encoder_version = mpc_bits_read(r, 8); - si->channels = 2; - si->block_pwr = 0; - -/* rockbox: not used - // convert gain info - if (si->gain_title != 0) { - int tmp = (int)((MPC_OLD_GAIN_REF - (mpc_int16_t)si->gain_title / 100.) * 256. + .5); - if (tmp >= (1 << 16) || tmp < 0) tmp = 0; - si->gain_title = (mpc_int16_t) tmp; - } - - if (si->gain_album != 0) { - int tmp = (int)((MPC_OLD_GAIN_REF - (mpc_int16_t)si->gain_album / 100.) * 256. + .5); - if (tmp >= (1 << 16) || tmp < 0) tmp = 0; - si->gain_album = (mpc_int16_t) tmp; - } - - if (si->peak_title != 0) - si->peak_title = (mpc_uint16_t) (log10(si->peak_title) * 20 * 256 + .5); - - if (si->peak_album != 0) - si->peak_album = (mpc_uint16_t) (log10(si->peak_album) * 20 * 256 + .5); - - mpc_get_encoder_string(si); -*/ - - if (last_frame_samples == 0) last_frame_samples = MPC_FRAME_LENGTH; - else if (last_frame_samples > MPC_FRAME_LENGTH) return MPC_STATUS_FAIL; - si->samples = (mpc_int64_t) frames * MPC_FRAME_LENGTH; - if (si->is_true_gapless) - si->samples -= (MPC_FRAME_LENGTH - last_frame_samples); - else - si->samples -= MPC_DECODER_SYNTH_DELAY; - - si->average_bitrate = 8LL * (si->tag_offset - si->header_position) - * si->sample_freq / si->samples; - - return check_streaminfo(si); -} - -/// Reads replay gain datas -void streaminfo_gain(mpc_streaminfo* si, const mpc_bits_reader * r_in) -{ - mpc_bits_reader r = *r_in; - - int version = mpc_bits_read(&r, 8); // gain version - if (version != 1) // we only know ver 1 - return; - si->gain_title = (mpc_uint16_t) mpc_bits_read(&r, 16); - si->peak_title = (mpc_uint16_t) mpc_bits_read(&r, 16); - si->gain_album = (mpc_uint16_t) mpc_bits_read(&r, 16); - si->peak_album = (mpc_uint16_t) mpc_bits_read(&r, 16); -} - -/// Reads streaminfo from SV8 header. -mpc_status -streaminfo_read_header_sv8(mpc_streaminfo* si, const mpc_bits_reader * r_in, - mpc_size_t block_size) -{ - mpc_uint32_t CRC; - mpc_bits_reader r = *r_in; - - CRC = (mpc_bits_read(&r, 16) << 16) | mpc_bits_read(&r, 16); - if (CRC != mpc_crc32(r.buff + 1 - (r.count >> 3), (int)block_size - 4)) - return MPC_STATUS_FAIL; - - si->stream_version = mpc_bits_read(&r, 8); - if (si->stream_version != 8) - return MPC_STATUS_FAIL; - - mpc_bits_get_size(&r, &si->samples); - mpc_bits_get_size(&r, &si->beg_silence); - - si->is_true_gapless = 1; - si->sample_freq = samplefreqs[mpc_bits_read(&r, 3)]; - si->max_band = mpc_bits_read(&r, 5) + 1; - si->channels = mpc_bits_read(&r, 4) + 1; - si->ms = mpc_bits_read(&r, 1); - si->block_pwr = mpc_bits_read(&r, 3) * 2; - - si->bitrate = 0; - - if ((si->samples - si->beg_silence) != 0) - si->average_bitrate = 8LL * (si->tag_offset - si->header_position) - * si->sample_freq / (si->samples - si->beg_silence); - - return check_streaminfo(si); -} - -/// Reads encoder informations -void streaminfo_encoder_info(mpc_streaminfo* si, const mpc_bits_reader * r_in) -{ - mpc_bits_reader r = *r_in; - - si->profile = mpc_bits_read(&r, 7); // to be divided by 8 -/* rockbox: not used - si->profile_name = mpc_get_version_string(si->profile); -*/ - si->pns = mpc_bits_read(&r, 1); - si->encoder_version = mpc_bits_read(&r, 8) << 24; // major - si->encoder_version |= mpc_bits_read(&r, 8) << 16; // minor - si->encoder_version |= mpc_bits_read(&r, 8) << 8; // build - -/* rockbox: not used - mpc_get_encoder_string(si); -*/ -} - -/* rockbox: not used -double -mpc_streaminfo_get_length(mpc_streaminfo * si) -{ - return (double) (si->samples - si->beg_silence) / si->sample_freq; -} - -mpc_int64_t mpc_streaminfo_get_length_samples(mpc_streaminfo *si) -{ - return si->samples - si->beg_silence; -} -*/ diff --git a/apps/codecs/libmusepack/streaminfo.h b/apps/codecs/libmusepack/streaminfo.h deleted file mode 100644 index 52e97936a0..0000000000 --- a/apps/codecs/libmusepack/streaminfo.h +++ /dev/null @@ -1,114 +0,0 @@ -/* - Copyright (c) 2005-2009, The Musepack Development Team - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are - met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - - * Neither the name of the The Musepack Development Team nor the - names of its contributors may be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -/// \file streaminfo.h -#ifndef _MPCDEC_STREAMINFO_H_ -#define _MPCDEC_STREAMINFO_H_ -#ifdef WIN32 -#pragma once -#endif - -#include "mpc_types.h" - -#ifdef __cplusplus -extern "C" { -#endif - - -typedef mpc_int32_t mpc_streaminfo_off_t; - -/// \brief mpc stream properties structure -/// -/// Structure containing all the properties of an mpc stream. Populated -/// by the streaminfo_read function. -typedef struct mpc_streaminfo { - /// @name Core mpc stream properties - //@{ - mpc_uint32_t sample_freq; ///< Sample frequency of stream - mpc_uint32_t channels; ///< Number of channels in stream - mpc_uint32_t stream_version; ///< Streamversion of stream - mpc_uint32_t bitrate; ///< Bitrate of stream file (in bps) - mpc_uint32_t average_bitrate; ///< Average bitrate of stream (in bits/sec) - mpc_uint32_t max_band; ///< Maximum band-index used in stream (0...31) - mpc_uint32_t ms; ///< Mid/side stereo (0: off, 1: on) - mpc_uint32_t fast_seek; ///< True if stream supports fast-seeking (sv7) - mpc_uint32_t block_pwr; ///< Number of frames in a block = 2^block_pwr (sv8) - //@} - - /// @name Replaygain properties - //@{ - mpc_uint16_t gain_title; ///< Replaygain title value - mpc_uint16_t gain_album; ///< Replaygain album value - mpc_uint16_t peak_album; ///< Peak album loudness level - mpc_uint16_t peak_title; ///< Peak title loudness level - //@} - - /// @name True gapless properties - //@{ - mpc_uint32_t is_true_gapless; ///< True gapless? (0: no, 1: yes) - mpc_uint64_t samples; ///< Number of samples in the stream - mpc_uint64_t beg_silence; ///< Number of samples that must not be played at the beginning of the stream - //@} - - /// @name Encoder informations - //@{ - mpc_uint32_t encoder_version; ///< Version of encoder used -/* rockbox: not used - char encoder[256]; ///< Encoder name -*/ - mpc_bool_t pns; ///< pns used - mpc_uint32_t profile; ///< Quality profile of stream -/* rockbox: not used - const char* profile_name; ///< Name of profile used by stream -*/ - //@} - - - mpc_streaminfo_off_t header_position; ///< Byte offset of position of header in stream - mpc_streaminfo_off_t tag_offset; ///< Offset to file tags - mpc_streaminfo_off_t total_file_length; ///< Total length of underlying file -} mpc_streaminfo; - -/* rockbox: not used -/// Gets length of stream si, in seconds. -/// \return length of stream in seconds -MPC_API double mpc_streaminfo_get_length(mpc_streaminfo *si); - -/// Returns length of stream si, in samples. -/// \return length of stream in samples -MPC_API mpc_int64_t mpc_streaminfo_get_length_samples(mpc_streaminfo *si); -*/ -#ifdef __cplusplus -} -#endif -#endif diff --git a/apps/codecs/libmusepack/synth_filter.c b/apps/codecs/libmusepack/synth_filter.c deleted file mode 100644 index 3ad2b236a0..0000000000 --- a/apps/codecs/libmusepack/synth_filter.c +++ /dev/null @@ -1,610 +0,0 @@ -/* - Copyright (c) 2005, The Musepack Development Team - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are - met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - - * Neither the name of the The Musepack Development Team nor the - names of its contributors may be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/// \file synth_filter.c -/// Synthesis functions. -/// \todo document me -#include -#include -#include "mpcdec.h" -#include "decoder.h" -#include "mpcdec_math.h" -#include "internal.h" - -/* C O N S T A N T S */ -#undef _ - -#if defined(MPC_FIXED_POINT) - #if defined(CPU_ARM) - #if ARM_ARCH >= 6 - // on ARMv6 we use 32*32=64>>32 multiplies (smmul/smmla) so we need to scale up the D coefficients - // the ARM11 multiplier doesn't have early termination so the magnitude of the multiplicands does not - // matter for speed. - #define D(value) (value << (14)) - #else - // do not up-scale D-values to achieve higher speed in smull/mlal - // operations. saves ~14/8 = 1.75 cycles per multiplication - #define D(value) (value) - #endif - // in this configuration a post-shift by >>16 is needed after synthesis - #else - // saturate to +/- 2^31 (= value << (31-17)), D-values are +/- 2^17 - #define D(value) (value << (14)) - #endif -#else - // IMPORTANT: internal scaling is somehow strange for floating point, therefore we scale the coefficients Di_opt - // by the correct amount to have proper scaled output - #define D(value) MAKE_MPC_SAMPLE((double)value*(double)(0x1000)) -#endif - -// Di_opt coefficients are +/- 2^17 (pre-shifted by <<16) -static const MPC_SAMPLE_FORMAT Di_opt [512] ICONST_ATTR MEM_ALIGN_ATTR = { -/* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 */ -/* 0 */ D( 0), -D( 29), D(213), -D( 459), D(2037), -D(5153), D( 6574), -D(37489), D(75038), D(37489), D(6574), D(5153), D(2037), D(459), D(213), D(29), -/* 1 */ -D( 1), -D( 31), D(218), -D( 519), D(2000), -D(5517), D( 5959), -D(39336), D(74992), D(35640), D(7134), D(4788), D(2063), D(401), D(208), D(26), -/* 2 */ -D( 1), -D( 35), D(222), -D( 581), D(1952), -D(5879), D( 5288), -D(41176), D(74856), D(33791), D(7640), D(4425), D(2080), D(347), D(202), D(24), -/* 3 */ -D( 1), -D( 38), D(225), -D( 645), D(1893), -D(6237), D( 4561), -D(43006), D(74630), D(31947), D(8092), D(4063), D(2087), D(294), D(196), D(21), -/* 4 */ -D( 1), -D( 41), D(227), -D( 711), D(1822), -D(6589), D( 3776), -D(44821), D(74313), D(30112), D(8492), D(3705), D(2085), D(244), D(190), D(19), -/* 5 */ -D( 1), -D( 45), D(228), -D( 779), D(1739), -D(6935), D( 2935), -D(46617), D(73908), D(28289), D(8840), D(3351), D(2075), D(197), D(183), D(17), -/* 6 */ -D( 1), -D( 49), D(228), -D( 848), D(1644), -D(7271), D( 2037), -D(48390), D(73415), D(26482), D(9139), D(3004), D(2057), D(153), D(176), D(16), -/* 7 */ -D( 2), -D( 53), D(227), -D( 919), D(1535), -D(7597), D( 1082), -D(50137), D(72835), D(24694), D(9389), D(2663), D(2032), D(111), D(169), D(14), -/* 8 */ -D( 2), -D( 58), D(224), -D( 991), D(1414), -D(7910), D( 70), -D(51853), D(72169), D(22929), D(9592), D(2330), D(2001), D( 72), D(161), D(13), -/* 9 */ -D( 2), -D( 63), D(221), -D(1064), D(1280), -D(8209), -D( 998), -D(53534), D(71420), D(21189), D(9750), D(2006), D(1962), D( 36), D(154), D(11), -/* 10 */ -D( 2), -D( 68), D(215), -D(1137), D(1131), -D(8491), -D( 2122), -D(55178), D(70590), D(19478), D(9863), D(1692), D(1919), D( 2), D(147), D(10), -/* 11 */ -D( 3), -D( 73), D(208), -D(1210), D( 970), -D(8755), -D( 3300), -D(56778), D(69679), D(17799), D(9935), D(1388), D(1870), -D( 29), D(139), D( 9), -/* 12 */ -D( 3), -D( 79), D(200), -D(1283), D( 794), -D(8998), -D( 4533), -D(58333), D(68692), D(16155), D(9966), D(1095), D(1817), -D( 57), D(132), D( 8), -/* 13 */ -D( 4), -D( 85), D(189), -D(1356), D( 605), -D(9219), -D( 5818), -D(59838), D(67629), D(14548), D(9959), D( 814), D(1759), -D( 83), D(125), D( 7), -/* 14 */ -D( 4), -D( 91), D(177), -D(1428), D( 402), -D(9416), -D( 7154), -D(61289), D(66494), D(12980), D(9916), D( 545), D(1698), -D(106), D(117), D( 7), -/* 15 */ -D( 5), -D( 97), D(163), -D(1498), D( 185), -D(9585), -D( 8540), -D(62684), D(65290), D(11455), D(9838), D( 288), D(1634), -D(127), D(111), D( 6), -/* 16 */ -D( 5), -D(104), D(146), -D(1567), -D( 45), -D(9727), -D( 9975), -D(64019), D(64019), D( 9975), D(9727), D( 45), D(1567), -D(146), D(104), D( 5), -/* 17 */ -D( 6), -D(111), D(127), -D(1634), -D( 288), -D(9838), -D(11455), -D(65290), D(62684), D( 8540), D(9585), -D( 185), D(1498), -D(163), D( 97), D( 5), -/* 18 */ -D( 7), -D(117), D(106), -D(1698), -D( 545), -D(9916), -D(12980), -D(66494), D(61289), D( 7154), D(9416), -D( 402), D(1428), -D(177), D( 91), D( 4), -/* 19 */ -D( 7), -D(125), D( 83), -D(1759), -D( 814), -D(9959), -D(14548), -D(67629), D(59838), D( 5818), D(9219), -D( 605), D(1356), -D(189), D( 85), D( 4), -/* 20 */ -D( 8), -D(132), D( 57), -D(1817), -D(1095), -D(9966), -D(16155), -D(68692), D(58333), D( 4533), D(8998), -D( 794), D(1283), -D(200), D( 79), D( 3), -/* 21 */ -D( 9), -D(139), D( 29), -D(1870), -D(1388), -D(9935), -D(17799), -D(69679), D(56778), D( 3300), D(8755), -D( 970), D(1210), -D(208), D( 73), D( 3), -/* 22 */ -D(10), -D(147), -D( 2), -D(1919), -D(1692), -D(9863), -D(19478), -D(70590), D(55178), D( 2122), D(8491), -D(1131), D(1137), -D(215), D( 68), D( 2), -/* 23 */ -D(11), -D(154), -D( 36), -D(1962), -D(2006), -D(9750), -D(21189), -D(71420), D(53534), D( 998), D(8209), -D(1280), D(1064), -D(221), D( 63), D( 2), -/* 24 */ -D(13), -D(161), -D( 72), -D(2001), -D(2330), -D(9592), -D(22929), -D(72169), D(51853), -D( 70), D(7910), -D(1414), D( 991), -D(224), D( 58), D( 2), -/* 25 */ -D(14), -D(169), -D(111), -D(2032), -D(2663), -D(9389), -D(24694), -D(72835), D(50137), -D( 1082), D(7597), -D(1535), D( 919), -D(227), D( 53), D( 2), -/* 26 */ -D(16), -D(176), -D(153), -D(2057), -D(3004), -D(9139), -D(26482), -D(73415), D(48390), -D( 2037), D(7271), -D(1644), D( 848), -D(228), D( 49), D( 1), -/* 27 */ -D(17), -D(183), -D(197), -D(2075), -D(3351), -D(8840), -D(28289), -D(73908), D(46617), -D( 2935), D(6935), -D(1739), D( 779), -D(228), D( 45), D( 1), -/* 28 */ -D(19), -D(190), -D(244), -D(2085), -D(3705), -D(8492), -D(30112), -D(74313), D(44821), -D( 3776), D(6589), -D(1822), D( 711), -D(227), D( 41), D( 1), -/* 29 */ -D(21), -D(196), -D(294), -D(2087), -D(4063), -D(8092), -D(31947), -D(74630), D(43006), -D( 4561), D(6237), -D(1893), D( 645), -D(225), D( 38), D( 1), -/* 30 */ -D(24), -D(202), -D(347), -D(2080), -D(4425), -D(7640), -D(33791), -D(74856), D(41176), -D( 5288), D(5879), -D(1952), D( 581), -D(222), D( 35), D( 1), -/* 31 */ -D(26), -D(208), -D(401), -D(2063), -D(4788), -D(7134), -D(35640), -D(74992), D(39336), -D( 5959), D(5517), -D(2000), D( 519), -D(218), D( 31), D( 1) -}; - -#undef D - -// DCT32-coefficients were expanded (<<) by DCT32_COEFFICIENT_EXPAND -#define DCT32_COEFFICIENT_EXPAND 31 - -#if defined(MPC_FIXED_POINT) - // define 64=32x32-multiplication for DCT-coefficients with samples. Via usage of MPC_FRACT highly optimized assembler might be used - // MULTIPLY_FRACT will perform >>32 after multiplication, as coef were expanded by DCT32_COEFFICIENT_EXPAND we'll correct this on the result. - // Will loose 4 bit accuracy on result in fract part without effect on final audio result - #define MPC_DCT32_MUL(sample, coef) (MPC_MULTIPLY_FRACT(sample,coef) << (32-DCT32_COEFFICIENT_EXPAND)) - #define MPC_DCT32_SHIFT(sample) (sample) -#else - // for floating point use the standard multiplication macro - #define MPC_DCT32_MUL(sample, coef) (MPC_MULTIPLY(sample, coef) ) - #define MPC_DCT32_SHIFT(sample) (sample) -#endif - -/****************************************************************************** - * mpc_dct32(const int *in, int *out) - * - * mpc_dct32 is a dct32 with in[32]->dct[32] that contains the mirroring from - * dct[32] to the expected out[64]. The symmetry is - * out[16] = 0, - * out[ 0..15] = dct[ 0..15], - * out[32..17] = -dct[ 0..15], - * out[33..48] = -dct[16..31], - * out[63..48] = -dct[16..31]. - * The cos-tab has the format s0.31. - *****************************************************************************/ -void -mpc_dct32(const MPC_SAMPLE_FORMAT *in, MPC_SAMPLE_FORMAT *v) -ICODE_ATTR_MPC_LARGE_IRAM; - -void -mpc_dct32(const MPC_SAMPLE_FORMAT *in, MPC_SAMPLE_FORMAT *v) -{ - MPC_SAMPLE_FORMAT t0, t1, t2, t3, t4, t5, t6, t7; - MPC_SAMPLE_FORMAT t8, t9, t10, t11, t12, t13, t14, t15; - MPC_SAMPLE_FORMAT t16, t17, t18, t19, t20, t21, t22, t23; - MPC_SAMPLE_FORMAT t24, t25, t26, t27, t28, t29, t30, t31; - MPC_SAMPLE_FORMAT t32, t33, t34, t35, t36, t37, t38, t39; - MPC_SAMPLE_FORMAT t40, t41, t42, t43, t44, t45, t46, t47; - MPC_SAMPLE_FORMAT t48, t49, t50, t51, t52, t53, t54, t55; - MPC_SAMPLE_FORMAT t56, t57, t58, t59, t60, t61, t62, t63; - MPC_SAMPLE_FORMAT t64, t65, t66, t67, t68, t69, t70, t71; - MPC_SAMPLE_FORMAT t72, t73, t74, t75, t76, t77, t78, t79; - MPC_SAMPLE_FORMAT t80, t81, t82, t83, t84, t85, t86, t87; - MPC_SAMPLE_FORMAT t88, t89, t90, t91, t92, t93, t94, t95; - MPC_SAMPLE_FORMAT t96, t97, t98, t99, t100, t101, t102, t103; - MPC_SAMPLE_FORMAT t104, t105, t106, t107, t108, t109, t110, t111; - MPC_SAMPLE_FORMAT t112, t113, t114, t115, t116, t117, t118, t119; - MPC_SAMPLE_FORMAT t120, t121, t122, t123, t124, t125, t126, t127; - MPC_SAMPLE_FORMAT t128, t129, t130, t131, t132, t133, t134, t135; - MPC_SAMPLE_FORMAT t136, t137, t138, t139, t140, t141, t142, t143; - MPC_SAMPLE_FORMAT t144, t145, t146, t147, t148, t149, t150, t151; - MPC_SAMPLE_FORMAT t152, t153, t154, t155, t156, t157, t158, t159; - MPC_SAMPLE_FORMAT t160, t161, t162, t163, t164, t165, t166, t167; - MPC_SAMPLE_FORMAT t168, t169, t170, t171, t172, t173, t174, t175; - MPC_SAMPLE_FORMAT t176; - - /* costab[i] = cos(PI / (2 * 32) * i) */ -#define costab01 (0x7fd8878e) /* 0.998795456 */ -#define costab02 (0x7f62368f) /* 0.995184727 */ -#define costab03 (0x7e9d55fc) /* 0.989176510 */ -#define costab04 (0x7d8a5f40) /* 0.980785280 */ -#define costab05 (0x7c29fbee) /* 0.970031253 */ -#define costab06 (0x7a7d055b) /* 0.956940336 */ -#define costab07 (0x78848414) /* 0.941544065 */ -#define costab08 (0x7641af3d) /* 0.923879533 */ -#define costab09 (0x73b5ebd1) /* 0.903989293 */ -#define costab10 (0x70e2cbc6) /* 0.881921264 */ -#define costab11 (0x6dca0d14) /* 0.857728610 */ -#define costab12 (0x6a6d98a4) /* 0.831469612 */ -#define costab13 (0x66cf8120) /* 0.803207531 */ -#define costab14 (0x62f201ac) /* 0.773010453 */ -#define costab15 (0x5ed77c8a) /* 0.740951125 */ -#define costab16 (0x5a82799a) /* 0.707106781 */ -#define costab17 (0x55f5a4d2) /* 0.671558955 */ -#define costab18 (0x5133cc94) /* 0.634393284 */ -#define costab19 (0x4c3fdff4) /* 0.595699304 */ -#define costab20 (0x471cece7) /* 0.555570233 */ -#define costab21 (0x41ce1e65) /* 0.514102744 */ -#define costab22 (0x3c56ba70) /* 0.471396737 */ -#define costab23 (0x36ba2014) /* 0.427555093 */ -#define costab24 (0x30fbc54d) /* 0.382683432 */ -#define costab25 (0x2b1f34eb) /* 0.336889853 */ -#define costab26 (0x25280c5e) /* 0.290284677 */ -#define costab27 (0x1f19f97b) /* 0.242980180 */ -#define costab28 (0x18f8b83c) /* 0.195090322 */ -#define costab29 (0x12c8106f) /* 0.146730474 */ -#define costab30 (0x0c8bd35e) /* 0.098017140 */ -#define costab31 (0x0647d97c) /* 0.049067674 */ - - t0 = in[ 0] + in[31]; t16 = MPC_DCT32_MUL(in[ 0] - in[31], costab01); - t1 = in[15] + in[16]; t17 = MPC_DCT32_MUL(in[15] - in[16], costab31); - - t41 = t16 + t17; - t59 = MPC_DCT32_MUL(t16 - t17, costab02); - t33 = t0 + t1; - t50 = MPC_DCT32_MUL(t0 - t1, costab02); - - t2 = in[ 7] + in[24]; t18 = MPC_DCT32_MUL(in[ 7] - in[24], costab15); - t3 = in[ 8] + in[23]; t19 = MPC_DCT32_MUL(in[ 8] - in[23], costab17); - - t42 = t18 + t19; - t60 = MPC_DCT32_MUL(t18 - t19, costab30); - t34 = t2 + t3; - t51 = MPC_DCT32_MUL(t2 - t3, costab30); - - t4 = in[ 3] + in[28]; t20 = MPC_DCT32_MUL(in[ 3] - in[28], costab07); - t5 = in[12] + in[19]; t21 = MPC_DCT32_MUL(in[12] - in[19], costab25); - - t43 = t20 + t21; - t61 = MPC_DCT32_MUL(t20 - t21, costab14); - t35 = t4 + t5; - t52 = MPC_DCT32_MUL(t4 - t5, costab14); - - t6 = in[ 4] + in[27]; t22 = MPC_DCT32_MUL(in[ 4] - in[27], costab09); - t7 = in[11] + in[20]; t23 = MPC_DCT32_MUL(in[11] - in[20], costab23); - - t44 = t22 + t23; - t62 = MPC_DCT32_MUL(t22 - t23, costab18); - t36 = t6 + t7; - t53 = MPC_DCT32_MUL(t6 - t7, costab18); - - t8 = in[ 1] + in[30]; t24 = MPC_DCT32_MUL(in[ 1] - in[30], costab03); - t9 = in[14] + in[17]; t25 = MPC_DCT32_MUL(in[14] - in[17], costab29); - - t45 = t24 + t25; - t63 = MPC_DCT32_MUL(t24 - t25, costab06); - t37 = t8 + t9; - t54 = MPC_DCT32_MUL(t8 - t9, costab06); - - t10 = in[ 6] + in[25]; t26 = MPC_DCT32_MUL(in[ 6] - in[25], costab13); - t11 = in[ 9] + in[22]; t27 = MPC_DCT32_MUL(in[ 9] - in[22], costab19); - - t46 = t26 + t27; - t64 = MPC_DCT32_MUL(t26 - t27, costab26); - t38 = t10 + t11; - t55 = MPC_DCT32_MUL(t10 - t11, costab26); - - t12 = in[ 2] + in[29]; t28 = MPC_DCT32_MUL(in[ 2] - in[29], costab05); - t13 = in[13] + in[18]; t29 = MPC_DCT32_MUL(in[13] - in[18], costab27); - - t47 = t28 + t29; - t65 = MPC_DCT32_MUL(t28 - t29, costab10); - t39 = t12 + t13; - t56 = MPC_DCT32_MUL(t12 - t13, costab10); - - t14 = in[ 5] + in[26]; t30 = MPC_DCT32_MUL(in[ 5] - in[26], costab11); - t15 = in[10] + in[21]; t31 = MPC_DCT32_MUL(in[10] - in[21], costab21); - - t48 = t30 + t31; - t66 = MPC_DCT32_MUL(t30 - t31, costab22); - t40 = t14 + t15; - t57 = MPC_DCT32_MUL(t14 - t15, costab22); - - t69 = t33 + t34; t89 = MPC_DCT32_MUL(t33 - t34, costab04); - t70 = t35 + t36; t90 = MPC_DCT32_MUL(t35 - t36, costab28); - t71 = t37 + t38; t91 = MPC_DCT32_MUL(t37 - t38, costab12); - t72 = t39 + t40; t92 = MPC_DCT32_MUL(t39 - t40, costab20); - t73 = t41 + t42; t94 = MPC_DCT32_MUL(t41 - t42, costab04); - t74 = t43 + t44; t95 = MPC_DCT32_MUL(t43 - t44, costab28); - t75 = t45 + t46; t96 = MPC_DCT32_MUL(t45 - t46, costab12); - t76 = t47 + t48; t97 = MPC_DCT32_MUL(t47 - t48, costab20); - - t78 = t50 + t51; t100 = MPC_DCT32_MUL(t50 - t51, costab04); - t79 = t52 + t53; t101 = MPC_DCT32_MUL(t52 - t53, costab28); - t80 = t54 + t55; t102 = MPC_DCT32_MUL(t54 - t55, costab12); - t81 = t56 + t57; t103 = MPC_DCT32_MUL(t56 - t57, costab20); - - t83 = t59 + t60; t106 = MPC_DCT32_MUL(t59 - t60, costab04); - t84 = t61 + t62; t107 = MPC_DCT32_MUL(t61 - t62, costab28); - t85 = t63 + t64; t108 = MPC_DCT32_MUL(t63 - t64, costab12); - t86 = t65 + t66; t109 = MPC_DCT32_MUL(t65 - t66, costab20); - - t113 = t69 + t70; - t114 = t71 + t72; - - /* 0 */ v[48] = -MPC_DCT32_SHIFT(t113 + t114); - /* 16 */ v[32] = -(v[ 0] = MPC_DCT32_SHIFT(MPC_DCT32_MUL(t113 - t114, costab16))); - - t115 = t73 + t74; - t116 = t75 + t76; - - t32 = t115 + t116; - - /* 1 */ v[49] = v[47] = -MPC_DCT32_SHIFT(t32); - - t118 = t78 + t79; - t119 = t80 + t81; - - t58 = t118 + t119; - - /* 2 */ v[50] = v[46] = -MPC_DCT32_SHIFT(t58); - - t121 = t83 + t84; - t122 = t85 + t86; - - t67 = t121 + t122; - - t49 = (t67 * 2) - t32; - - /* 3 */ v[51] = v[45] = -MPC_DCT32_SHIFT(t49); - - t125 = t89 + t90; - t126 = t91 + t92; - - t93 = t125 + t126; - - /* 4 */ v[52] = v[44] = -MPC_DCT32_SHIFT(t93); - - t128 = t94 + t95; - t129 = t96 + t97; - - t98 = t128 + t129; - - t68 = (t98 * 2) - t49; - - /* 5 */ v[53] = v[43] = -MPC_DCT32_SHIFT(t68); - - t132 = t100 + t101; - t133 = t102 + t103; - - t104 = t132 + t133; - - t82 = (t104 * 2) - t58; - - /* 6 */ v[54] = v[42] = -MPC_DCT32_SHIFT(t82); - - t136 = t106 + t107; - t137 = t108 + t109; - - t110 = t136 + t137; - - t87 = (t110 * 2) - t67; - - t77 = (t87 * 2) - t68; - - /* 7 */ v[55] = v[41] = -MPC_DCT32_SHIFT(t77); - - t141 = MPC_DCT32_MUL(t69 - t70, costab08); - t142 = MPC_DCT32_MUL(t71 - t72, costab24); - t143 = t141 + t142; - - /* 8 */ v[56] = v[40] = -MPC_DCT32_SHIFT(t143); - /* 24 */ v[24] = -(v[ 8] = MPC_DCT32_SHIFT((MPC_DCT32_MUL(t141 - t142, costab16) * 2) - t143)); - - t144 = MPC_DCT32_MUL(t73 - t74, costab08); - t145 = MPC_DCT32_MUL(t75 - t76, costab24); - t146 = t144 + t145; - - t88 = (t146 * 2) - t77; - - /* 9 */ v[57] = v[39] = -MPC_DCT32_SHIFT(t88); - - t148 = MPC_DCT32_MUL(t78 - t79, costab08); - t149 = MPC_DCT32_MUL(t80 - t81, costab24); - t150 = t148 + t149; - - t105 = (t150 * 2) - t82; - - /* 10 */ v[58] = v[38] = -MPC_DCT32_SHIFT(t105); - - t152 = MPC_DCT32_MUL(t83 - t84, costab08); - t153 = MPC_DCT32_MUL(t85 - t86, costab24); - t154 = t152 + t153; - - t111 = (t154 * 2) - t87; - - t99 = (t111 * 2) - t88; - - /* 11 */ v[59] = v[37] = -MPC_DCT32_SHIFT(t99); - - t157 = MPC_DCT32_MUL(t89 - t90, costab08); - t158 = MPC_DCT32_MUL(t91 - t92, costab24); - t159 = t157 + t158; - - t127 = (t159 * 2) - t93; - - /* 12 */ v[60] = v[36] = -MPC_DCT32_SHIFT(t127); - - t160 = (MPC_DCT32_MUL(t125 - t126, costab16) * 2) - t127; - - /* 20 */ v[28] = -(v[ 4] = MPC_DCT32_SHIFT(t160)); - /* 28 */ v[20] = -(v[12] = MPC_DCT32_SHIFT((((MPC_DCT32_MUL(t157 - t158, costab16) * 2) - t159) * 2) - t160)); - - t161 = MPC_DCT32_MUL(t94 - t95, costab08); - t162 = MPC_DCT32_MUL(t96 - t97, costab24); - t163 = t161 + t162; - - t130 = (t163 * 2) - t98; - - t112 = (t130 * 2) - t99; - - /* 13 */ v[61] = v[35] = -MPC_DCT32_SHIFT(t112); - - t164 = (MPC_DCT32_MUL(t128 - t129, costab16) * 2) - t130; - - t166 = MPC_DCT32_MUL(t100 - t101, costab08); - t167 = MPC_DCT32_MUL(t102 - t103, costab24); - t168 = t166 + t167; - - t134 = (t168 * 2) - t104; - - t120 = (t134 * 2) - t105; - - /* 14 */ v[62] = v[34] = -MPC_DCT32_SHIFT(t120); - - t135 = (MPC_DCT32_MUL(t118 - t119, costab16) * 2) - t120; - - /* 18 */ v[30] = -(v[ 2] = MPC_DCT32_SHIFT(t135)); - - t169 = (MPC_DCT32_MUL(t132 - t133, costab16) * 2) - t134; - - t151 = (t169 * 2) - t135; - - /* 22 */ v[26] = -(v[ 6] = MPC_DCT32_SHIFT(t151)); - - t170 = (((MPC_DCT32_MUL(t148 - t149, costab16) * 2) - t150) * 2) - t151; - - /* 26 */ v[22] = -(v[10] = MPC_DCT32_SHIFT(t170)); - /* 30 */ v[18] = -(v[14] = MPC_DCT32_SHIFT((((((MPC_DCT32_MUL(t166 - t167, costab16) * 2) - t168) * 2) - t169) * 2) - t170)); - - t171 = MPC_DCT32_MUL(t106 - t107, costab08); - t172 = MPC_DCT32_MUL(t108 - t109, costab24); - t173 = t171 + t172; - - t138 = (t173 * 2) - t110; - - t123 = (t138 * 2) - t111; - - t139 = (MPC_DCT32_MUL(t121 - t122, costab16) * 2) - t123; - - t117 = (t123 * 2) - t112; - - /* 15 */ v[63] = v[33] =-MPC_DCT32_SHIFT(t117); - - t124 = (MPC_DCT32_MUL(t115 - t116, costab16) * 2) - t117; - - /* 17 */ v[31] = -(v[ 1] = MPC_DCT32_SHIFT(t124)); - - t131 = (t139 * 2) - t124; - - /* 19 */ v[29] = -(v[ 3] = MPC_DCT32_SHIFT(t131)); - - t140 = (t164 * 2) - t131; - - /* 21 */ v[27] = -(v[ 5] = MPC_DCT32_SHIFT(t140)); - - t174 = (MPC_DCT32_MUL(t136 - t137, costab16) * 2) - t138; - - t155 = (t174 * 2) - t139; - - t147 = (t155 * 2) - t140; - - /* 23 */ v[25] = -(v[ 7] = MPC_DCT32_SHIFT(t147)); - - t156 = (((MPC_DCT32_MUL(t144 - t145, costab16) * 2) - t146) * 2) - t147; - - /* 25 */ v[23] = -(v[ 9] = MPC_DCT32_SHIFT(t156)); - - t175 = (((MPC_DCT32_MUL(t152 - t153, costab16) * 2) - t154) * 2) - t155; - - t165 = (t175 * 2) - t156; - - /* 27 */ v[21] = -(v[11] = MPC_DCT32_SHIFT(t165)); - - t176 = (((((MPC_DCT32_MUL(t161 - t162, costab16) * 2) - t163) * 2) - t164) * 2) - t165; - - /* 29 */ v[19] = -(v[13] = MPC_DCT32_SHIFT(t176)); - /* 31 */ v[17] = -(v[15] = MPC_DCT32_SHIFT((((((((MPC_DCT32_MUL(t171 - t172, costab16) * 2) - t173) * 2) - t174) * 2) - t175) * 2) - t176)); -} - -#if defined(CPU_ARM) || defined(CPU_COLDFIRE) -extern void -mpc_decoder_windowing_D(MPC_SAMPLE_FORMAT * Data, - const MPC_SAMPLE_FORMAT * V, - const MPC_SAMPLE_FORMAT * D); -#else -static void -mpc_decoder_windowing_D(MPC_SAMPLE_FORMAT * Data, - const MPC_SAMPLE_FORMAT * V, - const MPC_SAMPLE_FORMAT * D) -{ - mpc_int32_t k; - - // 64=64x64-multiply (FIXED_POINT) or float=float*float (!FIXED_POINT) in C - for ( k = 0; k < 32; k++, D += 16, V++ ) - { - *Data = MPC_MULTIPLY_EX(V[ 0],D[ 0],30) + MPC_MULTIPLY_EX(V[ 96],D[ 1],30) - + MPC_MULTIPLY_EX(V[128],D[ 2],30) + MPC_MULTIPLY_EX(V[224],D[ 3],30) - + MPC_MULTIPLY_EX(V[256],D[ 4],30) + MPC_MULTIPLY_EX(V[352],D[ 5],30) - + MPC_MULTIPLY_EX(V[384],D[ 6],30) + MPC_MULTIPLY_EX(V[480],D[ 7],30) - + MPC_MULTIPLY_EX(V[512],D[ 8],30) + MPC_MULTIPLY_EX(V[608],D[ 9],30) - + MPC_MULTIPLY_EX(V[640],D[10],30) + MPC_MULTIPLY_EX(V[736],D[11],30) - + MPC_MULTIPLY_EX(V[768],D[12],30) + MPC_MULTIPLY_EX(V[864],D[13],30) - + MPC_MULTIPLY_EX(V[896],D[14],30) + MPC_MULTIPLY_EX(V[992],D[15],30); - Data += 1; - // total: 16 muls, 15 adds, 16 shifts - } -} -#endif /* CPU_ARM || CPU_COLDFIRE */ - -static void -mpc_full_synthesis_filter(MPC_SAMPLE_FORMAT *OutData, MPC_SAMPLE_FORMAT *V, - const MPC_SAMPLE_FORMAT *Y) ICODE_ATTR_MPC_LARGE_IRAM; -static void -mpc_full_synthesis_filter(MPC_SAMPLE_FORMAT *OutData, MPC_SAMPLE_FORMAT *V, - const MPC_SAMPLE_FORMAT *Y) -{ - mpc_uint32_t n; - - if (NULL != OutData) - { - for ( n = 0; n < 36; n++, Y += 32, OutData += 32 ) - { - V -= 64; - mpc_dct32(Y, V); - mpc_decoder_windowing_D( OutData, V, Di_opt ); - } - } -} - -void -mpc_decoder_synthese_filter_float(mpc_decoder *d, MPC_SAMPLE_FORMAT *OutData, - int num_channels) -{ - (void)num_channels; - - /********* left channel ********/ - memmove(d->V_L + MPC_V_MEM, d->V_L, 960 * sizeof(MPC_SAMPLE_FORMAT) ); - mpc_full_synthesis_filter(OutData, - (MPC_SAMPLE_FORMAT *)(d->V_L + MPC_V_MEM), - (MPC_SAMPLE_FORMAT *)(d->Y_L)); - - /******** right channel ********/ - memmove(d->V_R + MPC_V_MEM, d->V_R, 960 * sizeof(MPC_SAMPLE_FORMAT) ); - mpc_full_synthesis_filter((OutData == NULL ? NULL : OutData + MPC_FRAME_LENGTH), - (MPC_SAMPLE_FORMAT *)(d->V_R + MPC_V_MEM), - (MPC_SAMPLE_FORMAT *)(d->Y_R)); -} - -/*******************************************/ -/* */ -/* dithered synthesis */ -/* */ -/*******************************************/ - -static const unsigned char Parity [256] = { // parity - 0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1, - 1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0, - 1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0, - 0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1, - 1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0, - 0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1, - 0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1, - 1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0 -}; - -/* - * This is a simple random number generator with good quality for audio purposes. - * It consists of two polycounters with opposite rotation direction and different - * periods. The periods are coprime, so the total period is the product of both. - * - * ------------------------------------------------------------------------------------------------- - * +-> |31:30:29:28:27:26:25:24:23:22:21:20:19:18:17:16:15:14:13:12:11:10: 9: 8: 7: 6: 5: 4: 3: 2: 1: 0| - * | ------------------------------------------------------------------------------------------------- - * | | | | | | | - * | +--+--+--+-XOR-+--------+ - * | | - * +--------------------------------------------------------------------------------------+ - * - * ------------------------------------------------------------------------------------------------- - * |31:30:29:28:27:26:25:24:23:22:21:20:19:18:17:16:15:14:13:12:11:10: 9: 8: 7: 6: 5: 4: 3: 2: 1: 0| <-+ - * ------------------------------------------------------------------------------------------------- | - * | | | | | - * +--+----XOR----+--+ | - * | | - * +----------------------------------------------------------------------------------------+ - * - * - * The first has an period of 3*5*17*257*65537, the second of 7*47*73*178481, - * which gives a period of 18.410.713.077.675.721.215. The result is the - * XORed values of both generators. - */ -mpc_uint32_t -mpc_random_int(mpc_decoder *d) -{ -#if 1 - mpc_uint32_t t1, t2, t3, t4; - - t3 = t1 = d->__r1; t4 = t2 = d->__r2; // Parity calculation is done via table lookup, this is also available - t1 &= 0xF5; t2 >>= 25; // on CPUs without parity, can be implemented in C and avoid unpredictable - t1 = Parity [t1]; t2 &= 0x63; // jumps and slow rotate through the carry flag operations. - t1 <<= 31; t2 = Parity [t2]; - - return (d->__r1 = (t3 >> 1) | t1 ) ^ (d->__r2 = (t4 + t4) | t2 ); -#else - return (d->__r1 = (d->__r1 >> 1) | ((mpc_uint32_t)Parity [d->__r1 & 0xF5] << 31) ) ^ - (d->__r2 = (d->__r2 << 1) | (mpc_uint32_t)Parity [(d->__r2 >> 25) & 0x63] ); -#endif -} diff --git a/apps/codecs/libmusepack/synth_filter_arm.S b/apps/codecs/libmusepack/synth_filter_arm.S deleted file mode 100644 index 9bd4e04626..0000000000 --- a/apps/codecs/libmusepack/synth_filter_arm.S +++ /dev/null @@ -1,693 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2008 by Andree Buschmann - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ - -#include "config.h" - -#if defined(CPU_S5L870X) - /* Moving this asm routine to iram is (little) faster on S5L870x. */ - .section .icode, "ax", %progbits -#else - .section .text, "ax", %progbits -#endif - -/**************************************************************************** - * void mpc_decoder_windowing_D(...) - * - * 2nd step within synthesis filter. Does the dewindowing. - * 64=32x32 multiplies - * Uses un-shifted D[]-values. D[] will always be the second operand of - * smull/smlal to achieve higher speed as D[] has lower amplitude than V[]. - ****************************************************************************/ - .align 2 - .global mpc_decoder_windowing_D - .type mpc_decoder_windowing_D, %function -#if 0 -mpc_decoder_windowing_D: - /* r0 = Data[] */ - /* r1 = V[] */ - /* r2 = D[] */ - /* lr = counter */ - /************************************************************************ - * Reference implementation. - ***********************************************************************/ - stmfd sp!, {r4-r8, lr} - - mov lr, #32 -.loop32: - ldmia r2!, { r3-r6 } /* load D[00..03] */ - ldr r7, [r1] /* 0 */ - smull r8, r12, r7, r3 - ldr r7, [r1, #96*4] /* 1 */ - smlal r8, r12, r7, r4 - ldr r7, [r1, #128*4] /* 2 */ - smlal r8, r12, r7, r5 - ldr r7, [r1, #224*4] /* 3 */ - smlal r8, r12, r7, r6 - ldmia r2!, { r3-r6 } /* load D[04..07] */ - ldr r7, [r1, #256*4] /* 4 */ - smlal r8, r12, r7, r3 - ldr r7, [r1, #352*4] /* 5 */ - smlal r8, r12, r7, r4 - ldr r7, [r1, #384*4] /* 6 */ - smlal r8, r12, r7, r5 - ldr r7, [r1, #480*4] /* 7 */ - smlal r8, r12, r7, r6 - ldmia r2!, { r3-r6 } /* load D[08..11] */ - ldr r7, [r1, #512*4] /* 8 */ - smlal r8, r12, r7, r3 - ldr r7, [r1, #608*4] /* 9 */ - smlal r8, r12, r7, r4 - ldr r7, [r1, #640*4] /* 10 */ - smlal r8, r12, r7, r5 - ldr r7, [r1, #736*4] /* 11 */ - smlal r8, r12, r7, r6 - ldmia r2!, { r3-r6 } /* load D[12..15] */ - ldr r7, [r1, #768*4] /* 12 */ - smlal r8, r12, r7, r3 - ldr r7, [r1, #864*4] /* 13 */ - smlal r8, r12, r7, r4 - ldr r7, [r1, #896*4] /* 14 */ - smlal r8, r12, r7, r5 - ldr r7, [r1, #992*4] /* 15 */ - smlal r8, r12, r7, r6 - mov r8, r8, lsr #16 - orr r8, r8, r12, lsl #16 /* (lo>>16) || (hi<<16) */ - str r8, [r0], #4 /* store Data */ - add r1, r1, #4 /* V++ */ - - subs lr, lr, #1 - bgt .loop32 - - ldmpc regs=r4-r8 -#elif defined(CPU_ARM7TDMI) /* arm7 only */ -mpc_decoder_windowing_D: - /* r0 = Data[] */ - /* r1 = V[] */ - /* r2 = D[] */ - /* lr = counter */ - /************************************************************************ - * Further speed up through making use of symmetries within D[]-window. - * The row V[00] can be extracted as it has symmetries within this single - * row. 8 smull/mlal and 8 ldr's can be saved at the cost of 2 add's. - * The rows V[01..15] are symmetric to V[31..17]. 15 x 16 ldr's can be - * saved at the cost of 15 x 4 + 1 add's. - * The row V[16] can be extracted as it has symmetries within this single - * row. 8 smull/mlal and 8 ldr's can be saved. - * Used for arm7 only. For arm9 and above see implementation below. - ***********************************************************************/ - stmfd sp!, {r4-r11, lr} - - /****************************************** - * row 0 with internal symmetry - *****************************************/ - add r2, r2, #4 /* D+=1, r2 = D[01] as D[00] = 0 */ - ldmia r2!, { r3-r6 } /* load D[01..04] */ - ldr r7 , [r1, #96*4] /* 1 */ - ldr r10, [r1, #992*4] /* 15 */ - rsb r10, r10, r7 /* V[01] - V[15] */ - smull r8, r9, r10, r3 - ldr r7 , [r1, #128*4] /* 2 */ - ldr r10, [r1, #896*4] /* 14 */ - add r10, r10, r7 /* V[02] + V[14] */ - smlal r8, r9, r10, r4 - ldr r7 , [r1, #224*4] /* 3 */ - ldr r10, [r1, #864*4] /* 13 */ - rsb r10, r10, r7 /* V[03] - V[13] */ - smlal r8, r9, r10, r5 - ldr r7 , [r1, #256*4] /* 4 */ - ldr r10, [r1, #768*4] /* 12 */ - add r10, r10, r7 /* V[04] + V[12] */ - smlal r8, r9, r10, r6 - ldmia r2!, { r3-r6 } /* load D[05..08] */ - ldr r7 , [r1, #352*4] /* 5 */ - ldr r10, [r1, #736*4] /* 11 */ - rsb r10, r10, r7 /* V[05] - V[11] */ - smlal r8, r9, r10, r3 - ldr r7 , [r1, #384*4] /* 6 */ - ldr r10, [r1, #640*4] /* 10 */ - add r10, r10, r7 /* V[06] + V[10] */ - smlal r8, r9, r10, r4 - ldr r7 , [r1, #480*4] /* 7 */ - ldr r10, [r1, #608*4] /* 9 */ - rsb r10, r10, r7 /* V[07] - V[09] */ - smlal r8, r9, r10, r5 - ldr r10, [r1, #512*4] /* 8 */ - smlal r8, r9, r10, r6 - mov r8, r8, lsr #16 - orr r8, r8, r9, lsl #16 /* (lo>>16) || (hi<<16) */ - str r8, [r0], #4 /* store Data */ - add r1, r1, #4 /* V+=1, r1 = V[01] */ - add r2, r2, #7*4 /* D+=7, r2 = D[16] */ - - /****************************************** - * rows 01..15 are symmetric to rows 31..17 - * r8 = lo, r9 = hi of 01..15 - * r1 = V[01..15] - * r10 = lo, r11 = hi of 31..17 - * r12 = V[31..16] - *****************************************/ - mov lr, #15*8 - add r12, r1, #30*4 /* r12 = V[31] */ -.loop15: - ldmia r2!, { r3-r6 } /* load D[00..03] */ - ldr r7, [r12, #768*4] /* 12 */ - smull r10, r11, r7, r6 - ldr r7, [r12, #864*4] /* 13 */ - smlal r10, r11, r7, r5 - ldr r7, [r12, #896*4] /* 14 */ - smlal r10, r11, r7, r4 - ldr r7, [r12, #992*4] /* 15 */ - smlal r10, r11, r7, r3 - ldr r7, [r1] /* 0 */ - smull r8, r9, r7, r3 - ldr r7, [r1, #96*4] /* 1 */ - smlal r8, r9, r7, r4 - ldr r7, [r1, #128*4] /* 2 */ - smlal r8, r9, r7, r5 - ldr r7, [r1, #224*4] /* 3 */ - smlal r8, r9, r7, r6 - ldmia r2!, { r3-r6 } /* load D[04..07] */ - ldr r7, [r1, #256*4] /* 4 */ - smlal r8, r9, r7, r3 - ldr r7, [r1, #352*4] /* 5 */ - smlal r8, r9, r7, r4 - ldr r7, [r1, #384*4] /* 6 */ - smlal r8, r9, r7, r5 - ldr r7, [r1, #480*4] /* 7 */ - smlal r8, r9, r7, r6 - ldr r7, [r12, #512*4] /* 8 */ - smlal r10, r11, r7, r6 - ldr r7, [r12, #608*4] /* 9 */ - smlal r10, r11, r7, r5 - ldr r7, [r12, #640*4] /* 10 */ - smlal r10, r11, r7, r4 - ldr r7, [r12, #736*4] /* 11 */ - smlal r10, r11, r7, r3 - ldmia r2!, { r3-r6 } /* load D[08..11] */ - ldr r7, [r12, #256*4] /* 4 */ - smlal r10, r11, r7, r6 - ldr r7, [r12, #352*4] /* 5 */ - smlal r10, r11, r7, r5 - ldr r7, [r12, #384*4] /* 6 */ - smlal r10, r11, r7, r4 - ldr r7, [r12, #480*4] /* 7 */ - smlal r10, r11, r7, r3 - ldr r7, [r1, #512*4] /* 8 */ - smlal r8, r9, r7, r3 - ldr r7, [r1, #608*4] /* 9 */ - smlal r8, r9, r7, r4 - ldr r7, [r1, #640*4] /* 10 */ - smlal r8, r9, r7, r5 - ldr r7, [r1, #736*4] /* 11 */ - smlal r8, r9, r7, r6 - ldmia r2!, { r3-r6 } /* load D[12..15] */ - ldr r7, [r1, #768*4] /* 12 */ - smlal r8, r9, r7, r3 - ldr r7, [r1, #864*4] /* 13 */ - smlal r8, r9, r7, r4 - ldr r7, [r1, #896*4] /* 14 */ - smlal r8, r9, r7, r5 - ldr r7, [r1, #992*4] /* 15 */ - smlal r8, r9, r7, r6 - ldr r7, [r12] /* 0 */ - smlal r10, r11, r7, r6 - ldr r7, [r12, #96*4] /* 1 */ - smlal r10, r11, r7, r5 - ldr r7, [r12, #128*4] /* 2 */ - smlal r10, r11, r7, r4 - ldr r7, [r12, #224*4] /* 3 */ - smlal r10, r11, r7, r3 - /* store Data[01..15] */ - mov r8, r8, lsr #16 - orr r8, r8, r9, lsl #16 /* (lo>>16) || (hi<<16) */ - /* store Data[31..17] */ - mov r10, r10, lsr #16 - orr r10, r10, r11, lsl #16 /* (lo>>16) || (hi<<16) */ - rsb r10, r10, #0 /* r10 = -r10 */ - str r10, [r0, lr] /* store Data */ - str r8, [r0], #4 /* store Data */ - /* correct adresses for next loop */ - sub r12, r12, #4 /* r12 = V-- */ - add r1, r1, #4 /* r1 = V++ */ - /* next loop */ - subs lr, lr, #8 - bgt .loop15 - - /****************************************** - * V[16] with internal symmetry - *****************************************/ - ldmia r2!, { r3-r6 } /* load D[00..03] */ - ldr r7 , [r1] /* 0 */ - ldr r10, [r1, #992*4] /* 15 */ - rsb r10, r10, r7 /* V[00] - V[15] */ - smull r8, r9, r10, r3 - ldr r7 , [r1, #96*4] /* 1 */ - ldr r10, [r1, #896*4] /* 14 */ - rsb r10, r10, r7 /* V[01] - V[14] */ - smlal r8, r9, r10, r4 - ldr r7 , [r1, #128*4] /* 2 */ - ldr r10, [r1, #864*4] /* 13 */ - rsb r10, r10, r7 /* V[02] - V[13] */ - smlal r8, r9, r10, r5 - ldr r7 , [r1, #224*4] /* 3 */ - ldr r10, [r1, #768*4] /* 12 */ - rsb r10, r10, r7 /* V[03] - V[12] */ - smlal r8, r9, r10, r6 - ldmia r2!, { r3-r6 } /* load D[04..07] */ - ldr r7 , [r1, #256*4] /* 4 */ - ldr r10, [r1, #736*4] /* 11 */ - rsb r10, r10, r7 /* V[04] - V[11] */ - smlal r8, r9, r10, r3 - ldr r7 , [r1, #352*4] /* 5 */ - ldr r10, [r1, #640*4] /* 10 */ - rsb r10, r10, r7 /* V[05] - V[10] */ - smlal r8, r9, r10, r4 - ldr r7 , [r1, #384*4] /* 6 */ - ldr r10, [r1, #608*4] /* 9 */ - rsb r10, r10, r7 /* V[06] - V[09] */ - smlal r8, r9, r10, r5 - ldr r7 , [r1, #480*4] /* 7 */ - ldr r10, [r1, #512*4] /* 8 */ - rsb r10, r10, r7 /* V[07] - V[08] */ - smlal r8, r9, r10, r6 - mov r8, r8, lsr #16 - orr r8, r8, r9, lsl #16 /* (lo>>16) || (hi<<16) */ - str r8, [r0], #4 /* store Data */ - - ldmpc regs=r4-r11 -#elif ARM_ARCH < 6 /* arm9 and above */ - mpc_decoder_windowing_D: - /* r0 = Data[] */ - /* r1 = V[] */ - /* r2 = D[] */ - /* lr = counter */ - /************************************************************************ - * Further speed up through making use of symmetries within D[]-window. - * The row V[00] can be extracted as it has symmetries within this single - * row. 8 smull/mlal and 8 ldr's can be saved at the cost of 2 add's. - * The rows V[01..15] are symmetric to V[31..17]. 15 x 16 ldr's can be - * saved at the cost of 15 x 4 + 1 add's. - * The row V[16] can be extracted as it has symmetries within this single - * row. 8 smull/mlal and 8 ldr's can be saved. - * On arm9 (still armv4 architecture) reducing stalls after ldr/ldm speeds - * up decoding even though several ldm-calls are replaced with ldr to free - * 2 registers. - ***********************************************************************/ - stmfd sp!, {r4-r11, lr} - - /****************************************** - * row 0 with internal symmetry - *****************************************/ - add r2, r2, #4 /* D+=1, r2 = D[01] as D[00] = 0 */ - ldmia r2!, { r3-r6 } /* load D[01..04] */ - ldr r7 , [r1, #96*4] /* 1 */ - ldr r10, [r1, #992*4] /* 15 */ - ldr r11, [r1, #128*4] /* 2 */ - ldr r12, [r1, #896*4] /* 14 */ - rsb r10, r10, r7 /* V[01] - V[15] */ - smull r8, r9, r10, r3 - ldr r7 , [r1, #224*4] /* 3 */ - ldr r10, [r1, #864*4] /* 13 */ - add r12, r12, r11 /* V[02] + V[14] */ - smlal r8, r9, r12, r4 - ldr r11, [r1, #256*4] /* 4 */ - ldr r12, [r1, #768*4] /* 12 */ - rsb r10, r10, r7 /* V[03] - V[13] */ - smlal r8, r9, r10, r5 - ldr r7 , [r1, #352*4] /* 5 */ - ldr r10, [r1, #736*4] /* 11 */ - add r12, r12, r11 /* V[04] + V[12] */ - smlal r8, r9, r12, r6 - ldmia r2!, { r3-r6 } /* load D[05..08] */ - ldr r11, [r1, #384*4] /* 6 */ - ldr r12, [r1, #640*4] /* 10 */ - rsb r10, r10, r7 /* V[05] - V[11] */ - smlal r8, r9, r10, r3 - ldr r7 , [r1, #480*4] /* 7 */ - ldr r10, [r1, #608*4] /* 9 */ - add r12, r12, r11 /* V[06] + V[10] */ - smlal r8, r9, r12, r4 - ldr r11, [r1, #512*4] /* 8 */ - rsb r10, r10, r7 /* V[07] - V[09] */ - smlal r8, r9, r10, r5 - smlal r8, r9, r11, r6 - mov r8, r8, lsr #16 - orr r8, r8, r9, lsl #16 /* (lo>>16) || (hi<<16) */ - str r8, [r0], #4 /* store Data */ - add r1, r1, #4 /* V+=1, r1 = V[01] */ - add r2, r2, #7*4 /* D+=7, r2 = D[16] */ - - /****************************************** - * rows 01..15 are symmetric to rows 31..17 - * r8 = lo, r9 = hi of 01..15 - * r1 = V[01..15] - * r10 = lo, r11 = hi of 31..17 - * r12 = V[31..16] - *****************************************/ - mov lr, #15*8 - add r12, r1, #30*4 /* r12 = V[31] */ -.loop15: - ldmia r2!, { r3-r4 } /* load D[00..01] */ - ldr r7, [r12, #896*4] /* 14 */ - ldr r5, [r12, #992*4] /* 15 */ - smull r10, r11, r7, r4 - ldr r7, [r1] /* 0 */ - smlal r10, r11, r5, r3 - ldr r5, [r1, #96*4] /* 1 */ - smull r8, r9, r7, r3 - ldr r7, [r12, #768*4] /* 12 */ - smlal r8, r9, r5, r4 - ldmia r2!, { r3-r4 } /* load D[02..03] */ - ldr r5, [r12, #864*4] /* 13 */ - smlal r10, r11, r7, r4 - ldr r7, [r1, #128*4] /* 2 */ - smlal r10, r11, r5, r3 - ldr r5, [r1, #224*4] /* 3 */ - smlal r8, r9, r7, r3 - ldr r7, [r1, #256*4] /* 4 */ - smlal r8, r9, r5, r4 - ldmia r2!, { r3-r4 } /* load D[04..04] */ - ldr r5, [r1, #352*4] /* 5 */ - smlal r8, r9, r7, r3 - ldr r7, [r12, #640*4] /* 10 */ - smlal r8, r9, r5, r4 - ldr r5, [r12, #736*4] /* 11 */ - smlal r10, r11, r7, r4 - ldr r7, [r1, #384*4] /* 6 */ - smlal r10, r11, r5, r3 - ldmia r2!, { r3-r4 } /* load D[06..07] */ - ldr r5, [r1, #480*4] /* 7 */ - smlal r8, r9, r7, r3 - ldr r7, [r12, #512*4] /* 8 */ - smlal r8, r9, r5, r4 - ldr r5, [r12, #608*4] /* 9 */ - smlal r10, r11, r7, r4 - ldr r7, [r12, #384*4] /* 6 */ - smlal r10, r11, r5, r3 - ldmia r2!, { r3-r4 } /* load D[08..09] */ - ldr r5, [r12, #480*4] /* 7 */ - smlal r10, r11, r7, r4 - ldr r7, [r1, #512*4] /* 8 */ - smlal r10, r11, r5, r3 - ldr r5, [r1, #608*4] /* 9 */ - smlal r8, r9, r7, r3 - ldr r7, [r1, #640*4] /* 10 */ - smlal r8, r9, r5, r4 - ldmia r2!, { r3-r4 } /* load D[10..11] */ - ldr r5, [r1, #736*4] /* 11 */ - smlal r8, r9, r7, r3 - ldr r7, [r12, #256*4] /* 4 */ - smlal r8, r9, r5, r4 - ldr r5, [r12, #352*4] /* 5 */ - smlal r10, r11, r7, r4 - ldr r7, [r1, #768*4] /* 12 */ - smlal r10, r11, r5, r3 - ldmia r2!, { r3-r4 } /* load D[12..13] */ - ldr r5, [r1, #864*4] /* 13 */ - smlal r8, r9, r7, r3 - ldr r7, [r12, #128*4] /* 2 */ - smlal r8, r9, r5, r4 - ldr r5, [r12, #224*4] /* 3 */ - smlal r10, r11, r7, r4 - ldr r7, [r12] /* 0 */ - smlal r10, r11, r5, r3 - ldmia r2!, { r3-r4 } /* load D[14..15] */ - ldr r5, [r12, #96*4] /* 1 */ - smlal r10, r11, r7, r4 - ldr r7, [r1, #896*4] /* 14 */ - smlal r10, r11, r5, r3 - ldr r5, [r1, #992*4] /* 15 */ - smlal r8, r9, r7, r3 - smlal r8, r9, r5, r4 - /* store Data[01..15] */ - mov r8, r8, lsr #16 - orr r8, r8, r9, lsl #16 /* (lo>>16) || (hi<<16) */ - /* store Data[31..17] */ - mov r10, r10, lsr #16 - orr r10, r10, r11, lsl #16 /* (lo>>16) || (hi<<16) */ - rsb r10, r10, #0 /* r10 = -r10 */ - str r10, [r0, lr] /* store Data */ - str r8, [r0], #4 /* store Data */ - /* correct adresses for next loop */ - sub r12, r12, #4 /* r12 = V-- */ - add r1, r1, #4 /* r1 = V++ */ - /* next loop */ - subs lr, lr, #8 - bgt .loop15 - - /****************************************** - * V[16] with internal symmetry - *****************************************/ - ldmia r2!, { r3-r6 } /* load D[00..03] */ - ldr r7 , [r1] /* 0 */ - ldr r10, [r1, #992*4] /* 15 */ - ldr r11, [r1, #96*4] /* 1 */ - ldr r12, [r1, #896*4] /* 14 */ - rsb r10, r10, r7 /* V[00] - V[15] */ - smull r8, r9, r10, r3 - ldr r7 , [r1, #128*4] /* 2 */ - ldr r10, [r1, #864*4] /* 13 */ - rsb r12, r12, r11 /* V[01] - V[14] */ - smlal r8, r9, r12, r4 - ldr r11, [r1, #224*4] /* 3 */ - ldr r12, [r1, #768*4] /* 12 */ - rsb r10, r10, r7 /* V[02] - V[13] */ - smlal r8, r9, r10, r5 - ldr r7 , [r1, #256*4] /* 4 */ - ldr r10, [r1, #736*4] /* 11 */ - rsb r12, r12, r11 /* V[03] - V[12] */ - smlal r8, r9, r12, r6 - ldmia r2!, { r3-r6 } /* load D[04..07] */ - ldr r11, [r1, #352*4] /* 5 */ - ldr r12, [r1, #640*4] /* 10 */ - rsb r10, r10, r7 /* V[04] - V[11] */ - smlal r8, r9, r10, r3 - ldr r7 , [r1, #384*4] /* 6 */ - ldr r10, [r1, #608*4] /* 9 */ - rsb r12, r12, r11 /* V[05] - V[10] */ - smlal r8, r9, r12, r4 - ldr r11, [r1, #480*4] /* 7 */ - ldr r12, [r1, #512*4] /* 8 */ - rsb r10, r10, r7 /* V[06] - V[09] */ - smlal r8, r9, r10, r5 - rsb r12, r12, r11 /* V[07] - V[08] */ - smlal r8, r9, r12, r6 - mov r8, r8, lsr #16 - orr r8, r8, r9, lsl #16 /* (lo>>16) || (hi<<16) */ - str r8, [r0], #4 /* store Data */ - - ldmpc regs=r4-r11 -#else - mpc_decoder_windowing_D: - /* r0 = Data[] */ - /* r1 = V[] */ - /* r2 = D[] */ - /* lr = counter */ - /************************************************************************ - * Further speed up through making use of symmetries within D[]-window. - * The row V[00] can be extracted as it has symmetries within this single - * row. 8 smull/mlal and 8 ldr's can be saved at the cost of 2 add's. - * The rows V[01..15] are symmetric to V[31..17]. 15 x 16 ldr's can be - * saved at the cost of 15 x 4 + 1 add's. - * The row V[16] can be extracted as it has symmetries within this single - * row. 8 smull/mlal and 8 ldr's can be saved. - * On armv6 use smmulr/smlalr which are faster than smull/smlal and only - * accumulate the top 32 bits of the result so that frees up 2 - * registers so we can ldm larger blocks. - ***********************************************************************/ - stmfd sp!, {r4-r11, lr} - - /****************************************** - * row 0 with internal symmetry - *****************************************/ - add r2, r2, #4 /* D+=1, r2 = D[01] as D[00] = 0 */ - ldmia r2!, { r3-r6 } /* load D[01..04] */ - ldr r7 , [r1, #96*4] /* 1 */ - ldr r10, [r1, #992*4] /* 15 */ - ldr r11, [r1, #128*4] /* 2 */ - rsb r10, r10, r7 /* V[01] - V[15] */ - ldr r12, [r1, #896*4] /* 14 */ - smmulr r9, r10, r3 - ldr r7 , [r1, #224*4] /* 3 */ - add r12, r12, r11 /* V[02] + V[14] */ - ldr r10, [r1, #864*4] /* 13 */ - smmlar r9, r12, r4, r9 - ldr r11, [r1, #256*4] /* 4 */ - rsb r10, r10, r7 /* V[03] - V[13] */ - ldr r12, [r1, #768*4] /* 12 */ - smmlar r9, r10, r5, r9 - ldr r7 , [r1, #352*4] /* 5 */ - add r12, r12, r11 /* V[04] + V[12] */ - ldr r10, [r1, #736*4] /* 11 */ - smmlar r9, r12, r6, r9 - ldmia r2!, { r3-r6 } /* load D[05..08] */ - ldr r11, [r1, #384*4] /* 6 */ - rsb r10, r10, r7 /* V[05] - V[11] */ - ldr r12, [r1, #640*4] /* 10 */ - smmlar r9, r10, r3, r9 - ldr r7 , [r1, #480*4] /* 7 */ - add r12, r12, r11 /* V[06] + V[10] */ - ldr r10, [r1, #608*4] /* 9 */ - smmlar r9, r12, r4, r9 - rsb r10, r10, r7 /* V[07] - V[09] */ - ldr r11, [r1, #512*4] /* 8 */ - smmlar r9, r10, r5, r9 - add r1, r1, #4 /* V+=1, r1 = V[01] */ - smmlar r9, r11, r6, r9 - add r2, r2, #7*4 /* D+=7, r2 = D[16] */ - mov r9, r9, lsl #2 - str r9, [r0], #4 /* store Data */ - - /****************************************** - * rows 01..15 are symmetric to rows 31..17 - * r9 = acc of 01..15 - * r1 = V[01..15] - * r11 = acc of 31..17 - * r12 = V[31..16] - *****************************************/ - mov lr, #15*8 - add r12, r1, #30*4 /* r12 = V[31] */ -.loop15: - ldmia r2!, { r3-r6 } /* load D[00..03] */ - ldr r7, [r12, #896*4] /* 14 */ - ldr r8, [r12, #992*4] /* 15 */ - smmulr r11, r7, r4 - ldr r7, [r1] /* 0 */ - smmlar r11, r8, r3, r11 - ldr r8, [r1, #96*4] /* 1 */ - smmulr r9, r7, r3 - ldr r7, [r12, #768*4] /* 12 */ - smmlar r9, r8, r4, r9 - ldr r8, [r12, #864*4] /* 13 */ - smmlar r11, r7, r6, r11 - ldr r7, [r1, #128*4] /* 2 */ - smmlar r11, r8, r5, r11 - ldr r8, [r1, #224*4] /* 3 */ - smmlar r9, r7, r5, r9 - ldr r7, [r1, #256*4] /* 4 */ - smmlar r9, r8, r6, r9 - ldmia r2!, { r3-r6 } /* load D[04..07] */ - ldr r8, [r1, #352*4] /* 5 */ - smmlar r9, r7, r3, r9 - ldr r7, [r12, #640*4] /* 10 */ - smmlar r9, r8, r4, r9 - ldr r8, [r12, #736*4] /* 11 */ - smmlar r11, r7, r4, r11 - ldr r7, [r1, #384*4] /* 6 */ - smmlar r11, r8, r3, r11 - ldr r8, [r1, #480*4] /* 7 */ - smmlar r9, r7, r5, r9 - ldr r7, [r12, #512*4] /* 8 */ - smmlar r9, r8, r6, r9 - ldr r8, [r12, #608*4] /* 9 */ - smmlar r11, r7, r6, r11 - ldr r7, [r12, #384*4] /* 6 */ - smmlar r11, r8, r5, r11 - ldmia r2!, { r3-r6 } /* load D[08..11] */ - ldr r8, [r12, #480*4] /* 7 */ - smmlar r11, r7, r4, r11 - ldr r7, [r1, #512*4] /* 8 */ - smmlar r11, r8, r3, r11 - ldr r8, [r1, #608*4] /* 9 */ - smmlar r9, r7, r3, r9 - ldr r7, [r1, #640*4] /* 10 */ - smmlar r9, r8, r4, r9 - ldr r8, [r1, #736*4] /* 11 */ - smmlar r9, r7, r5, r9 - ldr r7, [r12, #256*4] /* 4 */ - smmlar r9, r8, r6, r9 - ldr r8, [r12, #352*4] /* 5 */ - smmlar r11, r7, r6, r11 - ldr r7, [r1, #768*4] /* 12 */ - smmlar r11, r8, r5, r11 - ldmia r2!, { r3-r6 } /* load D[12..15] */ - ldr r8, [r1, #864*4] /* 13 */ - smmlar r9, r7, r3, r9 - ldr r7, [r12, #128*4] /* 2 */ - smmlar r9, r8, r4, r9 - ldr r8, [r12, #224*4] /* 3 */ - smmlar r11, r7, r4, r11 - ldr r7, [r12] /* 0 */ - smmlar r11, r8, r3, r11 - ldr r8, [r12, #96*4] /* 1 */ - smmlar r11, r7, r6, r11 - ldr r7, [r1, #896*4] /* 14 */ - smmlar r11, r8, r5, r11 - ldr r8, [r1, #992*4] /* 15 */ - smmlar r9, r7, r5, r9 - sub r12, r12, #4 /* r12 = V-- correct adresses for next loop */ - smmlar r9, r8, r6, r9 - add r1, r1, #4 /* r1 = V++ correct adresses for next loop */ - rsb r11, r11, #0 /* r11 = -r11 */ - /* store Data[01..15] */ - mov r9, r9, lsl #2 - /* store Data[31..17] */ - mov r11, r11, lsl #2 - str r11, [r0, lr] /* store Data */ - str r9, [r0], #4 /* store Data */ - /* next loop */ - subs lr, lr, #8 - bgt .loop15 - - /****************************************** - * V[16] with internal symmetry - *****************************************/ - ldmia r2!, { r3-r6 } /* load D[00..03] */ - ldr r7 , [r1] /* 0 */ - ldr r10, [r1, #992*4] /* 15 */ - ldr r11, [r1, #96*4] /* 1 */ - rsb r10, r10, r7 /* V[00] - V[15] */ - ldr r12, [r1, #896*4] /* 14 */ - smmulr r9, r10, r3 - ldr r7 , [r1, #128*4] /* 2 */ - rsb r12, r12, r11 /* V[01] - V[14] */ - ldr r10, [r1, #864*4] /* 13 */ - smmlar r9, r12, r4, r9 - ldr r11, [r1, #224*4] /* 3 */ - rsb r10, r10, r7 /* V[02] - V[13] */ - ldr r12, [r1, #768*4] /* 12 */ - smmlar r9, r10, r5, r9 - ldr r7 , [r1, #256*4] /* 4 */ - rsb r12, r12, r11 /* V[03] - V[12] */ - ldr r10, [r1, #736*4] /* 11 */ - smmlar r9, r12, r6, r9 - ldmia r2!, { r3-r6 } /* load D[04..07] */ - ldr r11, [r1, #352*4] /* 5 */ - rsb r10, r10, r7 /* V[04] - V[11] */ - ldr r12, [r1, #640*4] /* 10 */ - smmlar r9, r10, r3, r9 - ldr r7 , [r1, #384*4] /* 6 */ - rsb r12, r12, r11 /* V[05] - V[10] */ - ldr r10, [r1, #608*4] /* 9 */ - smmlar r9, r12, r4, r9 - ldr r11, [r1, #480*4] /* 7 */ - rsb r10, r10, r7 /* V[06] - V[09] */ - ldr r12, [r1, #512*4] /* 8 */ - smmlar r9, r10, r5, r9 - rsb r12, r12, r11 /* V[07] - V[08] */ - smmlar r9, r12, r6, r9 - mov r9, r9, lsl #2 - str r9, [r0], #4 /* store Data */ - - ldmpc regs=r4-r11 -#endif -.mpc_dewindowing_end: - .size mpc_decoder_windowing_D,.mpc_dewindowing_end-mpc_decoder_windowing_D diff --git a/apps/codecs/libmusepack/synth_filter_coldfire.S b/apps/codecs/libmusepack/synth_filter_coldfire.S deleted file mode 100644 index 758ab3d496..0000000000 --- a/apps/codecs/libmusepack/synth_filter_coldfire.S +++ /dev/null @@ -1,78 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2005 by Thom Johansen - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ - -#include "config.h" -/* - * static void - * mpc_decoder_windowing_D(MPC_SAMPLE_FORMAT * Data, - * const MPC_SAMPLE_FORMAT * V, - * const MPC_SAMPLE_FORMAT * D) - */ - -#if defined(USE_IRAM) - .section .icode -#else - .text -#endif - .align 2 - .global mpc_decoder_windowing_D - .type mpc_decoder_windowing_D, @function - -mpc_decoder_windowing_D: - lea.l (-9*4, %sp), %sp - movem.l %d2-%d7/%a2-%a4, (%sp) | save some registers - movem.l (9*4+4, %sp), %a0-%a2 | a0 = Data, a1 = V, a2 = D - moveq.l #32, %d0 | loop counter - - move.l (%a1), %a4 - 0: | loop - movem.l (%a2), %d1-%d7/%a3 - - mac.l %d1, %a4, ( 96*4, %a1), %a4, %acc0 - mac.l %d2, %a4, (128*4, %a1), %a4, %acc0 - mac.l %d3, %a4, (224*4, %a1), %a4, %acc0 - mac.l %d4, %a4, (256*4, %a1), %a4, %acc0 - mac.l %d5, %a4, (352*4, %a1), %a4, %acc0 - mac.l %d6, %a4, (384*4, %a1), %a4, %acc0 - mac.l %d7, %a4, (480*4, %a1), %a4, %acc0 - mac.l %a3, %a4, (512*4, %a1), %a4, %acc0 - movem.l (8*4, %a2), %d1-%d7/%a3 - mac.l %d1, %a4, (608*4, %a1), %a4, %acc0 - mac.l %d2, %a4, (640*4, %a1), %a4, %acc0 - mac.l %d3, %a4, (736*4, %a1), %a4, %acc0 - mac.l %d4, %a4, (768*4, %a1), %a4, %acc0 - mac.l %d5, %a4, (864*4, %a1), %a4, %acc0 - mac.l %d6, %a4, (896*4, %a1), %a4, %acc0 - mac.l %d7, %a4, (992*4, %a1), %a4, %acc0 - mac.l %a3, %a4, ( 4, %a1), %a4, %acc0 - - lea.l (16*4, %a2), %a2 - addq.l #4, %a1 - movclr.l %acc0, %d1 - lsl.l #1, %d1 - move.l %d1, (%a0)+ - subq.l #1, %d0 - bne 0b - - movem.l (%sp), %d2-%d7/%a2-%a4 | restore stacked regs - lea.l (9*4, %sp), %sp - rts - diff --git a/apps/codecs/libpcm/SOURCES b/apps/codecs/libpcm/SOURCES deleted file mode 100644 index 356c9cdbb7..0000000000 --- a/apps/codecs/libpcm/SOURCES +++ /dev/null @@ -1,11 +0,0 @@ -linear_pcm.c -itut_g711.c -dvi_adpcm.c -ieee_float.c -adpcm_seek.c -dialogic_oki_adpcm.c -ms_adpcm.c -yamaha_adpcm.c -ima_adpcm_common.c -qt_ima_adpcm.c -swf_adpcm.c diff --git a/apps/codecs/libpcm/adpcm_seek.c b/apps/codecs/libpcm/adpcm_seek.c deleted file mode 100644 index ce49d5fcd3..0000000000 --- a/apps/codecs/libpcm/adpcm_seek.c +++ /dev/null @@ -1,101 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2010 Yoshihisa Uchida - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ -#include "adpcm_seek.h" -#include "codeclib.h" - -/* - * The helper functions in order to seek for the adpcm codec - * which does not include the header each the data block. - */ - -#define MAX_STORE_COUNT 1000 - -static struct adpcm_data seek_table[MAX_STORE_COUNT]; -static int seek_count; -static int cur_count; -static int max_ratio; -static int cur_ratio; - -void init_seek_table(uint32_t max_count) -{ - int i = 0; - - for ( ; i < MAX_STORE_COUNT; i++) - { - seek_table[i].is_valid = false; - } - seek_count = max_count / MAX_STORE_COUNT + 1; - max_ratio = max_count / seek_count + 1; - cur_count = 0; - cur_ratio = -1; -} - -void add_adpcm_data(struct adpcm_data *data) -{ - if (--cur_count <= 0) - { - cur_count = seek_count; - if (++cur_ratio >= max_ratio) - cur_ratio = max_ratio - 1; - - if (!seek_table[cur_ratio].is_valid) - { - seek_table[cur_ratio].pcmdata[0] = data->pcmdata[0]; - seek_table[cur_ratio].pcmdata[1] = data->pcmdata[1]; - seek_table[cur_ratio].step[0] = data->step[0]; - seek_table[cur_ratio].step[1] = data->step[1]; - seek_table[cur_ratio].is_valid = true; - } - } -} - -uint32_t seek(uint32_t count, struct adpcm_data *seek_data, - uint8_t *(*read_buffer)(size_t *realsize), - int (*decode)(const uint8_t *inbuf, size_t inbufsize)) -{ - int new_ratio = count / seek_count; - - if (new_ratio >= max_ratio) - new_ratio = max_ratio - 1; - - if (!seek_table[new_ratio].is_valid) - { - uint8_t *buffer; - size_t n; - - do - { - buffer = read_buffer(&n); - if (n == 0) - break; - decode(buffer, n); - } while (cur_ratio < new_ratio); - } - - seek_data->pcmdata[0] = seek_table[new_ratio].pcmdata[0]; - seek_data->pcmdata[1] = seek_table[new_ratio].pcmdata[1]; - seek_data->step[0] = seek_table[new_ratio].step[0]; - seek_data->step[1] = seek_table[new_ratio].step[1]; - - cur_ratio = new_ratio; - cur_count = seek_count; - return cur_ratio * seek_count; -} diff --git a/apps/codecs/libpcm/adpcm_seek.h b/apps/codecs/libpcm/adpcm_seek.h deleted file mode 100644 index 2dd3f000b1..0000000000 --- a/apps/codecs/libpcm/adpcm_seek.h +++ /dev/null @@ -1,39 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2010 Yoshihisa Uchida - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ -#ifndef CODEC_LIBPCM_ADPCM_SEEK_H -#define CODEC_LIBPCM_ADPCM_SEEK_H - -#include -#include -#include - -struct adpcm_data { - int16_t pcmdata[2]; - uint16_t step[2]; - bool is_valid; -}; - -void init_seek_table(uint32_t max_count); -void add_adpcm_data(struct adpcm_data *data); -uint32_t seek(uint32_t seek_time, struct adpcm_data *seek_data, - uint8_t *(*read_buffer)(size_t *realsize), - int (*decode)(const uint8_t *inbuf, size_t inbufsize)); -#endif diff --git a/apps/codecs/libpcm/dialogic_oki_adpcm.c b/apps/codecs/libpcm/dialogic_oki_adpcm.c deleted file mode 100644 index 60090aaa89..0000000000 --- a/apps/codecs/libpcm/dialogic_oki_adpcm.c +++ /dev/null @@ -1,183 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2010 Yoshihisa Uchida - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ -#include "codeclib.h" -#include "adpcm_seek.h" -#include "support_formats.h" - -/* - * Dialogic OKI ADPCM - * - * References - * [1] Dialogic Corporation, Dialogic ADPCM Algorithm, 1988 - * [2] MultimediaWiki, Dialogic IMA ADPCM, URL:http://wiki.multimedia.cx/index.php?title=Dialogic_IMA_ADPCM - * [3] sox source code, src/adpcms.c - * [4] Tetsuya Isaki, NetBSD:/sys/dev/audio.c, http://www.tri-tree.gr.jp/~isaki/NetBSD/src/sys/dev/ic/msm6258.c.html - */ - -static const uint16_t step_table[] ICONST_ATTR = { - 16, 17, 19, 21, 23, 25, 28, 31, 34, 37, 41, 45, 50, 55, - 60, 66, 73, 80, 88, 97, 107, 118, 130, 143, 157, 173, 190, 209, - 230, 253, 279, 307, 337, 371, 408, 449, 494, 544, 598, 658, 724, 796, - 876, 963, 1060, 1166, 1282, 1411, 1552, -}; - -static const int index_table[] ICONST_ATTR = { - -1, -1, -1, -1, 2, 4, 6, 8 -}; - -static struct adpcm_data cur_data; -static int blocksperchunk; - -static struct pcm_format *fmt; - -static bool set_format(struct pcm_format *format) -{ - uint32_t max_chunk_count; - - fmt = format; - - if (fmt->bitspersample != 4) - { - DEBUGF("CODEC_ERROR: dialogic oki adpcm must be 4 bitspersample: %d\n", - fmt->bitspersample); - return false; - } - - if (fmt->channels != 1) - { - DEBUGF("CODEC_ERROR: dialogic oki adpcm must be monaural\n"); - return false; - } - - /* blockalign = 2 samples */ - fmt->blockalign = 1; - fmt->samplesperblock = 2; - - /* chunksize = about 1/32[sec] data */ - blocksperchunk = ci->id3->frequency >> 6; - fmt->chunksize = blocksperchunk * fmt->blockalign; - - max_chunk_count = (uint64_t)ci->id3->length * ci->id3->frequency - / (2000LL * fmt->chunksize); - - /* initialize seek table */ - init_seek_table(max_chunk_count); - /* add first data */ - add_adpcm_data(&cur_data); - - return true; -} - -static int16_t create_pcmdata(uint8_t nibble) -{ - int16_t delta; - int16_t index = cur_data.step[0]; - int16_t step = step_table[index]; - - delta = (step >> 3); - if (nibble & 4) delta += step; - if (nibble & 2) delta += (step >> 1); - if (nibble & 1) delta += (step >> 2); - - if (nibble & 0x08) - cur_data.pcmdata[0] -= delta; - else - cur_data.pcmdata[0] += delta; - - CLIP(cur_data.pcmdata[0], -2048, 2047); - - index += index_table[nibble & 0x07]; - CLIP(index, 0, 48); - cur_data.step[0] = index; - - return cur_data.pcmdata[0]; -} - -static int decode(const uint8_t *inbuf, size_t inbufsize, - int32_t *outbuf, int *outbufcount) -{ - size_t nsamples = 0; - - while (inbufsize) - { - *outbuf++ = create_pcmdata(*inbuf >> 4) << (PCM_OUTPUT_DEPTH - 12); - *outbuf++ = create_pcmdata(*inbuf ) << (PCM_OUTPUT_DEPTH - 12); - nsamples += 2; - - inbuf++; - inbufsize--; - } - - *outbufcount = nsamples; - add_adpcm_data(&cur_data); - - return CODEC_OK; -} - -static int decode_for_seek(const uint8_t *inbuf, size_t inbufsize) -{ - while (inbufsize) - { - create_pcmdata(*inbuf >> 4); - create_pcmdata(*inbuf ); - - inbuf++; - inbufsize--; - } - - add_adpcm_data(&cur_data); - - return CODEC_OK; -} - -static struct pcm_pos *get_seek_pos(uint32_t seek_val, int seek_mode, - uint8_t *(*read_buffer)(size_t *realsize)) -{ - static struct pcm_pos newpos; - uint32_t seek_count = (seek_mode == PCM_SEEK_TIME)? - ((uint64_t)seek_val * ci->id3->frequency / 1000LL) - / (blocksperchunk * fmt->samplesperblock) : - seek_val / (unsigned long)fmt->chunksize; - uint32_t new_count = seek(seek_count, &cur_data, read_buffer, &decode_for_seek); - - newpos.pos = new_count * fmt->chunksize; - newpos.samples = new_count * blocksperchunk * fmt->samplesperblock; - return &newpos; -} - -static const struct pcm_codec codec = { - set_format, - get_seek_pos, - decode, - }; - -const struct pcm_codec *get_dialogic_oki_adpcm_codec(void) -{ - /* - * initialize first pcm data, step index - * because the dialogic oki adpcm is always monaural, - * pcmdata[1], step[1] do not use. - */ - cur_data.pcmdata[0] = 0; - cur_data.step[0] = 0; - - return &codec; -} diff --git a/apps/codecs/libpcm/dvi_adpcm.c b/apps/codecs/libpcm/dvi_adpcm.c deleted file mode 100644 index 2e702ca394..0000000000 --- a/apps/codecs/libpcm/dvi_adpcm.c +++ /dev/null @@ -1,308 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2005 Dave Chapman - * Copyright (C) 2009 Yoshihisa Uchida - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ -#include "codeclib.h" -#include "ima_adpcm_common.h" -#include "support_formats.h" - -/* - * Intel DVI ADPCM (IMA ADPCM) - * - * References - * [1] The IMA Digital Audio Focus and Technical Working Groups, - * Recommended Practices for Enhancing Digital Audio Compatibility - * in Multimedia Systems Revision 3.00, 1992 - * [2] Microsoft Corporation, New Multimedia Data Types and Data Techniques, - * Revision:3.0, 1994 - * [3] ffmpeg source code, libavcodec/adpcm.c - */ - -static struct pcm_format *fmt; - -static bool set_format(struct pcm_format *format) -{ - fmt = format; - - if (fmt->bitspersample < 2 || fmt->bitspersample > 5) - { - DEBUGF("CODEC_ERROR: dvi adpcm must be 2, 3, 4 or 5 bitspersample: %d\n", - fmt->bitspersample); - return false; - } - - fmt->chunksize = fmt->blockalign; - - init_ima_adpcm_decoder(fmt->bitspersample, NULL); - return true; -} - -static struct pcm_pos *get_seek_pos(uint32_t seek_val, int seek_mode, - uint8_t *(*read_buffer)(size_t *realsize)) -{ - static struct pcm_pos newpos; - uint32_t newblock = (seek_mode == PCM_SEEK_TIME) ? - ((uint64_t)seek_val * ci->id3->frequency / 1000LL) - / fmt->samplesperblock : - seek_val / fmt->blockalign; - - (void)read_buffer; - newpos.pos = newblock * fmt->blockalign; - newpos.samples = newblock * fmt->samplesperblock; - return &newpos; -} - -static inline void decode_2bit(const uint8_t **inbuf, size_t inbufsize, - int32_t **outbuf, int *outbufcount) -{ - int ch; - int i; - int32_t *pcmbuf; - int samples; - - samples = inbufsize / (4 * fmt->channels) - 1; - *outbufcount += (samples << 4); - while (samples-- > 0) - { - for (ch = 0; ch < fmt->channels; ch++) - { - pcmbuf = *outbuf + ch; - for (i = 0; i < 4; i++) - { - *pcmbuf = create_pcmdata(ch, **inbuf ) << IMA_ADPCM_INC_DEPTH; - pcmbuf += fmt->channels; - *pcmbuf = create_pcmdata(ch, **inbuf >> 2) << IMA_ADPCM_INC_DEPTH; - pcmbuf += fmt->channels; - *pcmbuf = create_pcmdata(ch, **inbuf >> 4) << IMA_ADPCM_INC_DEPTH; - pcmbuf += fmt->channels; - *pcmbuf = create_pcmdata(ch, **inbuf >> 6) << IMA_ADPCM_INC_DEPTH; - pcmbuf += fmt->channels; - (*inbuf)++; - } - } - *outbuf += 16 * fmt->channels; - } -} - -static inline void decode_3bit(const uint8_t **inbuf, size_t inbufsize, - int32_t **outbuf, int *outbufcount) -{ - const uint8_t *adpcmbuf; - uint32_t adpcms; - int ch; - int i; - int32_t *pcmbuf; - int samples; - - samples = (inbufsize - 4 * fmt->channels) / (12 * fmt->channels); - *outbufcount += (samples << 5); - while (samples--) - { - for (ch = 0; ch < fmt->channels; ch++) - { - adpcmbuf = *inbuf + ch * 4; - pcmbuf = *outbuf + ch; - adpcms = *adpcmbuf++; - adpcms |= (*adpcmbuf++) << 8; - adpcms |= (*adpcmbuf++) << 16; - for (i = 0; i < 8; i++) - { - *pcmbuf = create_pcmdata(ch, adpcms >> (3 * i)) << IMA_ADPCM_INC_DEPTH; - pcmbuf += fmt->channels; - } - adpcms = *adpcmbuf++; - adpcmbuf += (fmt->channels - 1) * 4; - adpcms |= (*adpcmbuf++) << 8; - adpcms |= (*adpcmbuf++) << 16; - for (i = 0; i < 8; i++) - { - *pcmbuf = create_pcmdata(ch, adpcms >> (3 * i)) << IMA_ADPCM_INC_DEPTH; - pcmbuf += fmt->channels; - } - adpcms = *adpcmbuf++; - adpcms |= (*adpcmbuf++) << 8; - adpcmbuf += (fmt->channels - 1) * 4; - adpcms |= (*adpcmbuf++) << 16; - for (i = 0; i < 8; i++) - { - *pcmbuf = create_pcmdata(ch, adpcms >> (3 * i)) << IMA_ADPCM_INC_DEPTH; - pcmbuf += fmt->channels; - } - adpcms = *adpcmbuf++; - adpcms |= (*adpcmbuf++) << 8; - adpcms |= (*adpcmbuf++) << 16; - for (i = 0; i < 8; i++) - { - *pcmbuf = create_pcmdata(ch, adpcms >> (3 * i)) << IMA_ADPCM_INC_DEPTH; - pcmbuf += fmt->channels; - } - } - *outbuf += 32 * fmt->channels; - *inbuf += 12 * fmt->channels; - } -} - -static inline void decode_4bit(const uint8_t **inbuf, size_t inbufsize, - int32_t **outbuf, int *outbufcount) -{ - int ch; - int i; - int32_t *pcmbuf; - int samples; - - samples = inbufsize / (4 * fmt->channels) - 1; - *outbufcount += (samples << 3); - while (samples-- > 0) - { - for (ch = 0; ch < fmt->channels; ch++) - { - pcmbuf = *outbuf + ch; - for (i = 0; i < 4; i++) - { - *pcmbuf = create_pcmdata_size4(ch, **inbuf ) << IMA_ADPCM_INC_DEPTH; - pcmbuf += fmt->channels; - *pcmbuf = create_pcmdata_size4(ch, **inbuf >> 4) << IMA_ADPCM_INC_DEPTH; - pcmbuf += fmt->channels; - (*inbuf)++; - } - } - *outbuf += 8 * fmt->channels; - } -} - -static inline void decode_5bit(const uint8_t **inbuf, size_t inbufsize, - int32_t **outbuf, int *outbufcount) -{ - const uint8_t *adpcmbuf; - uint64_t adpcms; - int ch; - int i; - int32_t *pcmbuf; - int samples; - - samples = (inbufsize - 4 * fmt->channels) / (20 * fmt->channels); - *outbufcount += (samples << 5); - while (samples--) - { - for (ch = 0; ch < fmt->channels; ch++) - { - adpcmbuf = *inbuf + ch * 4; - pcmbuf = *outbuf + ch; - adpcms = *adpcmbuf++; - adpcms |= (*adpcmbuf++) << 8; - adpcms |= (*adpcmbuf++) << 16; - adpcms |= (uint64_t)(*adpcmbuf++) << 24; - adpcmbuf += (fmt->channels - 1) * 4; - adpcms |= (uint64_t)(*adpcmbuf++) << 32; - for (i = 0; i < 8; i++) - { - *pcmbuf = create_pcmdata(ch, adpcms >> (5 * i)) << IMA_ADPCM_INC_DEPTH; - pcmbuf += fmt->channels; - } - adpcms = *adpcmbuf++; - adpcms |= (*adpcmbuf++) << 8; - adpcms |= (*adpcmbuf++) << 16; - adpcmbuf += (fmt->channels - 1) * 4; - adpcms |= (uint64_t)(*adpcmbuf++) << 24; - adpcms |= (uint64_t)(*adpcmbuf++) << 32; - for (i = 0; i < 8; i++) - { - *pcmbuf = create_pcmdata(ch, adpcms >> (5 * i)) << IMA_ADPCM_INC_DEPTH; - pcmbuf += fmt->channels; - } - adpcms = *adpcmbuf++; - adpcms |= (*adpcmbuf++) << 8; - adpcmbuf += (fmt->channels - 1) * 4; - adpcms |= (*adpcmbuf++) << 16; - adpcms |= (uint64_t)(*adpcmbuf++) << 24; - adpcms |= (uint64_t)(*adpcmbuf++) << 32; - for (i = 0; i < 8; i++) - { - *pcmbuf = create_pcmdata(ch, adpcms >> (5 * i)) << IMA_ADPCM_INC_DEPTH; - pcmbuf += fmt->channels; - } - adpcms = *adpcmbuf++; - adpcmbuf += (fmt->channels - 1) * 4; - adpcms |= (*adpcmbuf++) << 8; - adpcms |= (*adpcmbuf++) << 16; - adpcms |= (uint64_t)(*adpcmbuf++) << 24; - adpcms |= (uint64_t)(*adpcmbuf++) << 32; - for (i = 0; i < 8; i++) - { - *pcmbuf = create_pcmdata(ch, adpcms >> (5 * i)) << IMA_ADPCM_INC_DEPTH; - pcmbuf += fmt->channels; - } - } - *outbuf += 32 * fmt->channels; - *inbuf += 20 * fmt->channels; - } -} - -static int decode(const uint8_t *inbuf, size_t inbufsize, - int32_t *outbuf, int *outbufcount) -{ - int ch; - int32_t init_pcmdata[2]; - int8_t init_index[2]; - - *outbufcount = 0; - for (ch = 0; ch < fmt->channels; ch++) - { - init_pcmdata[ch] = inbuf[0] | (inbuf[1] << 8); - if (init_pcmdata[ch] > 32767) - init_pcmdata[ch] -= 65536; - - init_index[ch] = inbuf[2]; - if (init_index[ch] > 88 || init_index[ch] < 0) - { - DEBUGF("CODEC_ERROR: dvi adpcm illegal step index=%d > 88\n", - init_index[ch]); - return CODEC_ERROR; - } - inbuf += 4; - - *outbuf++ = init_pcmdata[ch] << IMA_ADPCM_INC_DEPTH; - } - - *outbufcount += 1; - set_decode_parameters(fmt->channels, init_pcmdata, init_index); - - if (fmt->bitspersample == 4) - decode_4bit(&inbuf, inbufsize, &outbuf, outbufcount); - else if (fmt->bitspersample == 3) - decode_3bit(&inbuf, inbufsize, &outbuf, outbufcount); - else if (fmt->bitspersample == 5) - decode_5bit(&inbuf, inbufsize, &outbuf, outbufcount); - else /* fmt->bitspersample == 2 */ - decode_2bit(&inbuf, inbufsize, &outbuf, outbufcount); - - return CODEC_OK; -} - -static const struct pcm_codec codec = { - set_format, - get_seek_pos, - decode, - }; - -const struct pcm_codec *get_dvi_adpcm_codec(void) -{ - return &codec; -} diff --git a/apps/codecs/libpcm/ieee_float.c b/apps/codecs/libpcm/ieee_float.c deleted file mode 100644 index 639390bcd5..0000000000 --- a/apps/codecs/libpcm/ieee_float.c +++ /dev/null @@ -1,165 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2009 Yoshihisa Uchida - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ -#include "codeclib.h" -#include "pcm_common.h" -#include "support_formats.h" - -/* - * IEEE float - */ - -static struct pcm_format *fmt; - -static bool set_format(struct pcm_format *format) -{ - fmt = format; - - if (fmt->channels == 0) - { - DEBUGF("CODEC_ERROR: channels is 0\n"); - return false; - } - - if (fmt->bitspersample != 32 && fmt->bitspersample != 64) - { - DEBUGF("CODEC_ERROR: ieee float must be 32 or 64 bitspersample: %d\n", - fmt->bitspersample); - return false; - } - - fmt->bytespersample = fmt->bitspersample >> 3; - - if (fmt->blockalign == 0) - fmt->blockalign = fmt->bytespersample * fmt->channels; - - fmt->samplesperblock = fmt->blockalign / (fmt->bytespersample * fmt->channels); - - /* chunksize = about 1/50[sec] data */ - fmt->chunksize = (ci->id3->frequency / (50 * fmt->samplesperblock)) - * fmt->blockalign; - - return true; -} - -static struct pcm_pos *get_seek_pos(uint32_t seek_val, int seek_mode, - uint8_t *(*read_buffer)(size_t *realsize)) -{ - static struct pcm_pos newpos; - uint32_t newblock = (seek_mode == PCM_SEEK_TIME) ? - ((uint64_t)seek_val * ci->id3->frequency / 1000LL) - / fmt->samplesperblock : - seek_val / fmt->blockalign; - - (void)read_buffer; - newpos.pos = newblock * fmt->blockalign; - newpos.samples = newblock * fmt->samplesperblock; - return &newpos; -} - -static int decode(const uint8_t *inbuf, size_t inbufsize, - int32_t *outbuf, int *outbufsize) -{ - uint32_t i; - int32_t pcm; - int16_t exp; - int sgn; - - if (fmt->bitspersample == 32) - { - for (i = 0; i < inbufsize; i += 4) - { - if (fmt->is_little_endian) - { - pcm = (inbuf[0]<<5)|(inbuf[1]<<13)|((inbuf[2]|0x80)<<21); - exp = ((inbuf[2]>>7)|((inbuf[3]&0x7f)<<1)) - 127; - sgn = inbuf[3] & 0x80; - } - else - { - pcm = (inbuf[3]<<5)|(inbuf[2]<<13)|((inbuf[1]|0x80)<<21); - exp = ((inbuf[1]>>7)|((inbuf[0]&0x7f)<<1)) - 127; - sgn = inbuf[0] & 0x80; - } - if (exp > -29 && exp < 0) - { - pcm >>= -exp; - if (sgn) - pcm = -pcm; - } - else if (exp < -28) - pcm = 0; - else - pcm = (sgn)?-(1<<28):(1<<28)-1; - - outbuf[i/4] = pcm; - inbuf += 4; - } - *outbufsize = inbufsize >> 2; - } - else - { - for (i = 0; i < inbufsize; i += 8) - { - if (fmt->is_little_endian) - { - pcm = inbuf[3]|(inbuf[4]<<8)|(inbuf[5]<<16)|(((inbuf[6]&0x0f)|0x10)<<24); - exp = (((inbuf[6]&0xf0)>>4)|((inbuf[7]&0x7f)<<4)) - 1023; - sgn = inbuf[7] & 0x80; - } - else - { - pcm = inbuf[4]|(inbuf[3]<<8)|(inbuf[2]<<16)|(((inbuf[1]&0x0f)|0x10)<<24); - exp = (((inbuf[1]&0xf0)>>4)|((inbuf[0]&0x7f)<<4)) - 1023; - sgn = inbuf[0] & 0x80; - } - if (exp > -29 && exp < 0) - { - pcm >>= -exp; - if (sgn) - pcm = -pcm; - } - else if (exp < -28) - pcm = 0; - else - pcm = (sgn)?-(1<<28):(1<<28)-1; - - outbuf[i/8] = pcm; - inbuf += 8; - } - *outbufsize = inbufsize >> 3; - } - - if (fmt->channels == 2) - *outbufsize >>= 1; - - return CODEC_OK; -} - -static const struct pcm_codec codec = { - set_format, - get_seek_pos, - decode, - }; - -const struct pcm_codec *get_ieee_float_codec(void) -{ - return &codec; -} diff --git a/apps/codecs/libpcm/ima_adpcm_common.c b/apps/codecs/libpcm/ima_adpcm_common.c deleted file mode 100644 index 724cce31b0..0000000000 --- a/apps/codecs/libpcm/ima_adpcm_common.c +++ /dev/null @@ -1,171 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2010 Yoshihisa Uchida - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ -#include "codeclib.h" -#include "pcm_common.h" -#include "ima_adpcm_common.h" - -/* - * Functions for IMA ADPCM and IMA ADPCM series format - * - * References - * [1] The IMA Digital Audio Focus and Technical Working Groups, - * Recommended Practices for Enhancing Digital Audio Compatibility - * in Multimedia Systems Revision 3.00, 1992 - * [2] Microsoft Corporation, New Multimedia Data Types and Data Techniques, - * Revision:3.0, 1994 - * [3] ffmpeg source code, libavcodec/adpcm.c - */ - -/* step table */ -static const uint16_t step_table[89] ICONST_ATTR = { - 7, 8, 9, 10, 11, 12, 13, 14, - 16, 17, 19, 21, 23, 25, 28, 31, - 34, 37, 41, 45, 50, 55, 60, 66, - 73, 80, 88, 97, 107, 118, 130, 143, - 157, 173, 190, 209, 230, 253, 279, 307, - 337, 371, 408, 449, 494, 544, 598, 658, - 724, 796, 876, 963, 1060, 1166, 1282, 1411, - 1552, 1707, 1878, 2066, 2272, 2499, 2749, 3024, - 3327, 3660, 4026, 4428, 4871, 5358, 5894, 6484, - 7132, 7845, 8630, 9493, 10442, 11487, 12635, 13899, - 15289, 16818, 18500, 20350, 22385, 24623, 27086, 29794, - 32767 -}; - -/* step index tables */ -static const int index_tables[4][16] ICONST_ATTR = { - /* adpcm data size is 2 */ - { -1, 2 }, - /* adpcm data size is 3 */ - { -1, -1, 1, 2 }, - /* adpcm data size is 4 */ - { -1, -1, -1, -1, 2, 4, 6, 8 }, - /* adpcm data size is 5 */ - { -1, -1, -1, -1, -1, -1, -1, -1, 1, 2, 4, 6, 8, 10, 13, 16 }, -}; - -static int32_t pcmdata[2]; -static int8_t indices[2]; - -static int adpcm_data_size; -static uint8_t step_mask; -static uint8_t step_sign_mask; -static int8_t step_shift; -static const int *use_index_table; - -/* - * Before first decoding, this function must be executed. - * - * params - * bit: adpcm data size (2 <= bit <= 5). - * index_table: step index table - * if index_table is null, then step index table - * is used index_tables[bit-2]. - */ -void init_ima_adpcm_decoder(int bit, const int *index_table) -{ - adpcm_data_size = bit; - step_sign_mask = 1 << (adpcm_data_size - 1); - step_mask = step_sign_mask - 1; - step_shift = adpcm_data_size - 2; - if (index_table) - use_index_table = index_table; - else - use_index_table = index_tables[adpcm_data_size - 2]; -} - -/* - * When starting decoding for each block, this function must be executed. - * - * params - * channels: channel count - * init_pcmdata: array of init pcmdata - * init_index: array of init step indexes - */ -void set_decode_parameters(int channels, int32_t *init_pcmdata, int8_t *init_index) -{ - int ch; - - for (ch = 0; ch < channels; ch++) - { - pcmdata[ch] = init_pcmdata[ch]; - indices[ch] = init_index[ch]; - } -} - -/* - * convert ADPCM to PCM for any adpcm data size. - * - * If adpcm_data_size is 4, then you use create_pcmdata_size4() - * in place of this functon. - */ -int16_t create_pcmdata(int ch, uint8_t nibble) -{ - int check_bit = 1 << step_shift; - int32_t delta = 0; - int16_t step = step_table[indices[ch]]; - - do { - if (nibble & check_bit) - delta += step; - step >>= 1; - check_bit >>= 1; - } while (check_bit); - delta += step; - - if (nibble & step_sign_mask) - pcmdata[ch] -= delta; - else - pcmdata[ch] += delta; - - indices[ch] += use_index_table[nibble & step_mask]; - CLIP(indices[ch], 0, 88); - - CLIP(pcmdata[ch], -32768, 32767); - - return (int16_t)pcmdata[ch]; -} - -/* - * convert ADPCM to PCM when adpcm data size is 4. - */ -int16_t create_pcmdata_size4(int ch, uint8_t nibble) -{ - int32_t delta; - int16_t step = step_table[indices[ch]]; - - delta = (step >> 3); - if (nibble & 4) delta += step; - if (nibble & 2) delta += (step >> 1); - if (nibble & 1) delta += (step >> 2); - - if (nibble & 0x08) - pcmdata[ch] -= delta; - else - pcmdata[ch] += delta; - - indices[ch] += use_index_table[nibble & 0x07]; - CLIP(indices[ch], 0, 88); - - CLIP(pcmdata[ch], -32768, 32767); - - return (int16_t)pcmdata[ch]; -} diff --git a/apps/codecs/libpcm/ima_adpcm_common.h b/apps/codecs/libpcm/ima_adpcm_common.h deleted file mode 100644 index 46fd6083ec..0000000000 --- a/apps/codecs/libpcm/ima_adpcm_common.h +++ /dev/null @@ -1,33 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2010 Yoshihisa Uchida - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ -#ifndef CODEC_LIBPCM_IMA_ADPCM_COMMON_H -#define CODEC_LIBPCM_IMA_ADPCM_COMMON_H - -#include -#include - -#define IMA_ADPCM_INC_DEPTH (PCM_OUTPUT_DEPTH - 16) - -void init_ima_adpcm_decoder(int bit, const int *index_table); -void set_decode_parameters(int channels, int32_t *init_pcmdata, int8_t *init_index); -int16_t create_pcmdata(int ch, uint8_t nibble); -int16_t create_pcmdata_size4(int ch, uint8_t nibble); -#endif diff --git a/apps/codecs/libpcm/itut_g711.c b/apps/codecs/libpcm/itut_g711.c deleted file mode 100644 index 88ff5f59e6..0000000000 --- a/apps/codecs/libpcm/itut_g711.c +++ /dev/null @@ -1,204 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2005 Dave Chapman - * Copyright (C) 2009 Yoshihisa Uchida - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ -#include "codeclib.h" -#include "support_formats.h" - -/* - * ITU-T G.711 A-law mu-law - */ - -static const int16_t alaw2linear16[256] ICONST_ATTR = { - -5504, -5248, -6016, -5760, -4480, -4224, -4992, - -4736, -7552, -7296, -8064, -7808, -6528, -6272, - -7040, -6784, -2752, -2624, -3008, -2880, -2240, - -2112, -2496, -2368, -3776, -3648, -4032, -3904, - -3264, -3136, -3520, -3392, -22016, -20992, -24064, - -23040, -17920, -16896, -19968, -18944, -30208, -29184, - -32256, -31232, -26112, -25088, -28160, -27136, -11008, - -10496, -12032, -11520, -8960, -8448, -9984, -9472, - -15104, -14592, -16128, -15616, -13056, -12544, -14080, - -13568, -344, -328, -376, -360, -280, -264, - -312, -296, -472, -456, -504, -488, -408, - -392, -440, -424, -88, -72, -120, -104, - -24, -8, -56, -40, -216, -200, -248, - -232, -152, -136, -184, -168, -1376, -1312, - -1504, -1440, -1120, -1056, -1248, -1184, -1888, - -1824, -2016, -1952, -1632, -1568, -1760, -1696, - -688, -656, -752, -720, -560, -528, -624, - -592, -944, -912, -1008, -976, -816, -784, - -880, -848, 5504, 5248, 6016, 5760, 4480, - 4224, 4992, 4736, 7552, 7296, 8064, 7808, - 6528, 6272, 7040, 6784, 2752, 2624, 3008, - 2880, 2240, 2112, 2496, 2368, 3776, 3648, - 4032, 3904, 3264, 3136, 3520, 3392, 22016, - 20992, 24064, 23040, 17920, 16896, 19968, 18944, - 30208, 29184, 32256, 31232, 26112, 25088, 28160, - 27136, 11008, 10496, 12032, 11520, 8960, 8448, - 9984, 9472, 15104, 14592, 16128, 15616, 13056, - 12544, 14080, 13568, 344, 328, 376, 360, - 280, 264, 312, 296, 472, 456, 504, - 488, 408, 392, 440, 424, 88, 72, - 120, 104, 24, 8, 56, 40, 216, - 200, 248, 232, 152, 136, 184, 168, - 1376, 1312, 1504, 1440, 1120, 1056, 1248, - 1184, 1888, 1824, 2016, 1952, 1632, 1568, - 1760, 1696, 688, 656, 752, 720, 560, - 528, 624, 592, 944, 912, 1008, 976, - 816, 784, 880, 848 -}; - -static const int16_t ulaw2linear16[256] ICONST_ATTR = { - -32124, -31100, -30076, -29052, -28028, -27004, -25980, - -24956, -23932, -22908, -21884, -20860, -19836, -18812, - -17788, -16764, -15996, -15484, -14972, -14460, -13948, - -13436, -12924, -12412, -11900, -11388, -10876, -10364, - -9852, -9340, -8828, -8316, -7932, -7676, -7420, - -7164, -6908, -6652, -6396, -6140, -5884, -5628, - -5372, -5116, -4860, -4604, -4348, -4092, -3900, - -3772, -3644, -3516, -3388, -3260, -3132, -3004, - -2876, -2748, -2620, -2492, -2364, -2236, -2108, - -1980, -1884, -1820, -1756, -1692, -1628, -1564, - -1500, -1436, -1372, -1308, -1244, -1180, -1116, - -1052, -988, -924, -876, -844, -812, -780, - -748, -716, -684, -652, -620, -588, -556, - -524, -492, -460, -428, -396, -372, -356, - -340, -324, -308, -292, -276, -260, -244, - -228, -212, -196, -180, -164, -148, -132, - -120, -112, -104, -96, -88, -80, -72, - -64, -56, -48, -40, -32, -24, -16, - -8, 0, 32124, 31100, 30076, 29052, 28028, - 27004, 25980, 24956, 23932, 22908, 21884, 20860, - 19836, 18812, 17788, 16764, 15996, 15484, 14972, - 14460, 13948, 13436, 12924, 12412, 11900, 11388, - 10876, 10364, 9852, 9340, 8828, 8316, 7932, - 7676, 7420, 7164, 6908, 6652, 6396, 6140, - 5884, 5628, 5372, 5116, 4860, 4604, 4348, - 4092, 3900, 3772, 3644, 3516, 3388, 3260, - 3132, 3004, 2876, 2748, 2620, 2492, 2364, - 2236, 2108, 1980, 1884, 1820, 1756, 1692, - 1628, 1564, 1500, 1436, 1372, 1308, 1244, - 1180, 1116, 1052, 988, 924, 876, 844, - 812, 780, 748, 716, 684, 652, 620, - 588, 556, 524, 492, 460, 428, 396, - 372, 356, 340, 324, 308, 292, 276, - 260, 244, 228, 212, 196, 180, 164, - 148, 132, 120, 112, 104, 96, 88, - 80, 72, 64, 56, 48, 40, 32, - 24, 16, 8, 0 -}; - -static struct pcm_format *fmt; - -static bool set_format(struct pcm_format *format) -{ - fmt = format; - - if (fmt->channels == 0) - { - DEBUGF("CODEC_ERROR: channels is 0\n"); - return false; - } - - if (fmt->bitspersample != 8) - { - DEBUGF("CODEC_ERROR: alaw and mulaw must have 8 bitspersample: %d\n", - fmt->bitspersample); - return false; - } - - fmt->bytespersample = 1; - - if (fmt->blockalign == 0) - fmt->blockalign = fmt->channels; - - fmt->samplesperblock = fmt->blockalign / fmt->channels; - - /* chunksize = about 1/50[sec] data */ - fmt->chunksize = (ci->id3->frequency / (50 * fmt->samplesperblock)) - * fmt->blockalign; - - return true; -} - -static struct pcm_pos *get_seek_pos(uint32_t seek_val, int seek_mode, - uint8_t *(*read_buffer)(size_t *realsize)) -{ - static struct pcm_pos newpos; - uint32_t newblock = (seek_mode == PCM_SEEK_TIME) ? - ((uint64_t)seek_val * ci->id3->frequency / 1000LL) - / fmt->samplesperblock : - seek_val / fmt->blockalign; - - (void)read_buffer; - newpos.pos = newblock * fmt->blockalign; - newpos.samples = newblock * fmt->samplesperblock; - return &newpos; -} - -static int decode_alaw(const uint8_t *inbuf, size_t inbufsize, - int32_t *outbuf, int *outbufsize) -{ - uint32_t i; - - for (i = 0; i < inbufsize; i++) - outbuf[i] = alaw2linear16[inbuf[i]] << (PCM_OUTPUT_DEPTH - 16); - - *outbufsize = (fmt->channels == 2) ? (inbufsize >> 1) : inbufsize; - - return CODEC_OK; -} - -static int decode_mulaw(const uint8_t *inbuf, size_t inbufsize, - int32_t *outbuf, int *outbufsize) -{ - uint32_t i; - - for (i = 0; i < inbufsize; i++) - outbuf[i] = ulaw2linear16[inbuf[i]] << (PCM_OUTPUT_DEPTH - 16); - - *outbufsize = (fmt->channels == 2) ? (inbufsize >> 1) : inbufsize; - - return CODEC_OK; -} - -static const struct pcm_codec alaw_codec = { - set_format, - get_seek_pos, - decode_alaw, - }; - -static const struct pcm_codec mulaw_codec = { - set_format, - get_seek_pos, - decode_mulaw, - }; - -const struct pcm_codec *get_itut_g711_alaw_codec(void) -{ - return &alaw_codec; -} - -const struct pcm_codec *get_itut_g711_mulaw_codec(void) -{ - return &mulaw_codec; -} - diff --git a/apps/codecs/libpcm/libpcm.make b/apps/codecs/libpcm/libpcm.make deleted file mode 100644 index 1188bde1b0..0000000000 --- a/apps/codecs/libpcm/libpcm.make +++ /dev/null @@ -1,18 +0,0 @@ -# __________ __ ___. -# Open \______ \ ____ ____ | | _\_ |__ _______ ___ -# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / -# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < -# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ -# \/ \/ \/ \/ \/ -# $Id$ -# - -# libpcm -PCMSLIB := $(CODECDIR)/libpcm.a -PCMSLIB_SRC := $(call preprocess, $(APPSDIR)/codecs/libpcm/SOURCES) -PCMSLIB_OBJ := $(call c2obj, $(PCMSLIB_SRC)) -OTHER_SRC += $(PCMSLIB_SRC) - -$(PCMSLIB): $(PCMSLIB_OBJ) - $(SILENT)$(shell rm -f $@) - $(call PRINTS,AR $(@F))$(AR) rcs $@ $^ >/dev/null diff --git a/apps/codecs/libpcm/linear_pcm.c b/apps/codecs/libpcm/linear_pcm.c deleted file mode 100644 index 5c3c140b8c..0000000000 --- a/apps/codecs/libpcm/linear_pcm.c +++ /dev/null @@ -1,294 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2005 Dave Chapman - * Copyright (C) 2009 Yoshihisa Uchida - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ -#include "codeclib.h" -#include "support_formats.h" - -/* - * Linear PCM - */ - -#define INC_DEPTH_8 (PCM_OUTPUT_DEPTH - 8) -#define INC_DEPTH_16 (PCM_OUTPUT_DEPTH - 16) -#define INC_DEPTH_24 (PCM_OUTPUT_DEPTH - 24) -#define DEC_DEPTH_32 (32 - PCM_OUTPUT_DEPTH) - - -static struct pcm_format *fmt; - -static bool set_format(struct pcm_format *format) -{ - fmt = format; - - if (fmt->channels == 0) - { - DEBUGF("CODEC_ERROR: channels is 0\n"); - return false; - } - - if (fmt->bitspersample == 0) - { - DEBUGF("CODEC_ERROR: bitspersample is 0\n"); - return false; - } - - if (fmt->bitspersample > 32) - { - DEBUGF("CODEC_ERROR: pcm with more than 32 bitspersample " - "is unsupported\n"); - return false; - } - - fmt->bytespersample = fmt->bitspersample >> 3; - - if (fmt->blockalign == 0) - fmt->blockalign = fmt->bytespersample * fmt->channels; - - fmt->samplesperblock = fmt->blockalign / (fmt->bytespersample * fmt->channels); - - /* chunksize = about 1/50[sec] data */ - fmt->chunksize = (ci->id3->frequency / (50 * fmt->samplesperblock)) - * fmt->blockalign; - - return true; -} - -static struct pcm_pos *get_seek_pos(uint32_t seek_val, int seek_mode, - uint8_t *(*read_buffer)(size_t *realsize)) -{ - static struct pcm_pos newpos; - uint32_t newblock = (seek_mode == PCM_SEEK_TIME) ? - ((uint64_t)seek_val * ci->id3->frequency / 1000LL) - / fmt->samplesperblock : - seek_val / fmt->blockalign; - - (void)read_buffer; - newpos.pos = newblock * fmt->blockalign; - newpos.samples = newblock * fmt->samplesperblock; - return &newpos; -} - -/* 8bit decode functions */ -static inline void decode_s8(const uint8_t *inbuf, size_t inbufsize, int32_t *outbuf) -{ - size_t i = 0; - - for ( ; i < inbufsize; i++) - outbuf[i] = SE(inbuf[i]) << INC_DEPTH_8; -} - -static inline void decode_u8(const uint8_t *inbuf, size_t inbufsize, int32_t *outbuf) -{ - size_t i = 0; - - for ( ; i < inbufsize; i++) - outbuf[i] = SFT(inbuf[i]) << INC_DEPTH_8; -} - -/* 16bit decode functions */ -static inline void decode_s16le(const uint8_t *inbuf, size_t inbufsize, int32_t *outbuf) -{ - size_t i = 0; - - for ( ; i < inbufsize; i += 2) - outbuf[i/2] = (inbuf[i] << INC_DEPTH_16)|(SE(inbuf[i+1]) << INC_DEPTH_8); -} - -static inline void decode_u16le(const uint8_t *inbuf, size_t inbufsize, int32_t *outbuf) -{ - size_t i = 0; - - for ( ; i < inbufsize; i += 2) - outbuf[i/2] = (inbuf[i] << INC_DEPTH_16)|(SFT(inbuf[i+1]) << INC_DEPTH_8); -} - -static inline void decode_s16be(const uint8_t *inbuf, size_t inbufsize, int32_t *outbuf) -{ - size_t i = 0; - - for ( ; i < inbufsize; i += 2) - outbuf[i/2] = (inbuf[i+1] << INC_DEPTH_16)|(SE(inbuf[i]) << INC_DEPTH_8); -} - -static inline void decode_u16be(const uint8_t *inbuf, size_t inbufsize, int32_t *outbuf) -{ - size_t i = 0; - - for ( ; i < inbufsize; i += 2) - outbuf[i/2] = (inbuf[i+1] << INC_DEPTH_16)|(SFT(inbuf[i]) << INC_DEPTH_8); -} - -/* 24bit decode functions */ -static inline void decode_s24le(const uint8_t *inbuf, size_t inbufsize, int32_t *outbuf) -{ - size_t i = 0; - - for ( ; i < inbufsize; i += 3) - outbuf[i/3] = (inbuf[i] << INC_DEPTH_24)|(inbuf[i+1] << INC_DEPTH_16)| - (SE(inbuf[i+2]) << INC_DEPTH_8); -} - -static inline void decode_u24le(const uint8_t *inbuf, size_t inbufsize, int32_t *outbuf) -{ - size_t i = 0; - - for ( ; i < inbufsize; i += 3) - outbuf[i/3] = (inbuf[i] << INC_DEPTH_24)|(inbuf[i+1] << INC_DEPTH_16)| - (SFT(inbuf[i+2]) << INC_DEPTH_8); -} - -static inline void decode_s24be(const uint8_t *inbuf, size_t inbufsize, int32_t *outbuf) -{ - size_t i = 0; - - for ( ; i < inbufsize; i += 3) - outbuf[i/3] = (inbuf[i+2] << INC_DEPTH_24)|(inbuf[i+1] << INC_DEPTH_16)| - (SE(inbuf[i]) << INC_DEPTH_8); -} - -static inline void decode_u24be(const uint8_t *inbuf, size_t inbufsize, int32_t *outbuf) -{ - size_t i = 0; - - for ( ; i < inbufsize; i += 3) - outbuf[i/3] = (inbuf[i+2] << INC_DEPTH_24)|(inbuf[i+1] << INC_DEPTH_16)| - (SFT(inbuf[i]) << INC_DEPTH_8); -} - -/* 32bit decode functions */ -static inline void decode_s32le(const uint8_t *inbuf, size_t inbufsize, int32_t *outbuf) -{ - size_t i = 0; - - for ( ; i < inbufsize; i += 4) - outbuf[i/4] = (inbuf[i] >> DEC_DEPTH_32)|(inbuf[i+1] << INC_DEPTH_24)| - (inbuf[i+2] << INC_DEPTH_16)|(SE(inbuf[i+3]) << INC_DEPTH_8); -} - -static inline void decode_u32le(const uint8_t *inbuf, size_t inbufsize, int32_t *outbuf) -{ - size_t i = 0; - - for ( ; i < inbufsize; i += 4) - outbuf[i/4] = (inbuf[i] >> DEC_DEPTH_32)|(inbuf[i+1] << INC_DEPTH_24)| - (inbuf[i+2] << INC_DEPTH_16)|(SFT(inbuf[i+3]) << INC_DEPTH_8); -} - -static inline void decode_s32be(const uint8_t *inbuf, size_t inbufsize, int32_t *outbuf) -{ - size_t i = 0; - - for ( ; i < inbufsize; i += 4) - outbuf[i/4] = (inbuf[i+3] >> DEC_DEPTH_32)|(inbuf[i+2] << INC_DEPTH_24)| - (inbuf[i+1] << INC_DEPTH_16)|(SE(inbuf[i]) << INC_DEPTH_8); -} - -static inline void decode_u32be(const uint8_t *inbuf, size_t inbufsize, int32_t *outbuf) -{ - size_t i = 0; - - for ( ; i < inbufsize; i += 4) - outbuf[i/4] = (inbuf[i+3] >> DEC_DEPTH_32)|(inbuf[i+2] << INC_DEPTH_24)| - (inbuf[i+1] << INC_DEPTH_16)|(SFT(inbuf[i]) << INC_DEPTH_8); -} - -static int decode(const uint8_t *inbuf, size_t inbufsize, int32_t *outbuf, int *outbufcount) -{ - if (fmt->bitspersample > 24) - { - if (fmt->is_little_endian) - { - if (fmt->is_signed) - decode_s32le(inbuf, inbufsize, outbuf); - else - decode_u32le(inbuf, inbufsize, outbuf); - } - else - { - if (fmt->is_signed) - decode_s32be(inbuf, inbufsize, outbuf); - else - decode_u32be(inbuf, inbufsize, outbuf); - } - *outbufcount = inbufsize >> 2; - } - else if (fmt->bitspersample > 16) - { - if (fmt->is_little_endian) - { - if (fmt->is_signed) - decode_s24le(inbuf, inbufsize, outbuf); - else - decode_u24le(inbuf, inbufsize, outbuf); - } - else - { - if (fmt->is_signed) - decode_s24be(inbuf, inbufsize, outbuf); - else - decode_u24be(inbuf, inbufsize, outbuf); - } - *outbufcount = inbufsize / 3; - } - else if (fmt->bitspersample > 8) - { - if (fmt->is_little_endian) - { - if (fmt->is_signed) - decode_s16le(inbuf, inbufsize, outbuf); - else - decode_u16le(inbuf, inbufsize, outbuf); - } - else - { - if (fmt->is_signed) - decode_s16be(inbuf, inbufsize, outbuf); - else - decode_u16be(inbuf, inbufsize, outbuf); - } - *outbufcount = inbufsize >> 1; - } - else - { - if (fmt->is_signed) - decode_s8(inbuf, inbufsize, outbuf); - else - decode_u8(inbuf, inbufsize, outbuf); - - *outbufcount = inbufsize; - } - - if (fmt->channels == 2) - *outbufcount >>= 1; - - return CODEC_OK; -} - -static const struct pcm_codec codec = { - set_format, - get_seek_pos, - decode, - }; - -const struct pcm_codec *get_linear_pcm_codec(void) -{ - return &codec; -} diff --git a/apps/codecs/libpcm/ms_adpcm.c b/apps/codecs/libpcm/ms_adpcm.c deleted file mode 100644 index a385d6c99f..0000000000 --- a/apps/codecs/libpcm/ms_adpcm.c +++ /dev/null @@ -1,168 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2010 Yoshihisa Uchida - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ -#include "codeclib.h" -#include "support_formats.h" - -/* - * Microsoft ADPCM - * - * References - * [1] Microsoft, New Multimedia Data Types and Data Techniques Revision 3.0, 1994 - * [2] MulitimediaWiki, Microsoft ADPCM, 2006 - * (http://wiki.multimedia.cx/index.php?title=Microsoft_ADPCM) - * [3] ffmpeg source code, libavcodec/adpcm.c - */ - -#define ADPCM_NUM_COEFF 7 - -static int16_t dec_coeff[2][2]; -static uint16_t delta[2]; -static int16_t sample[2][2]; - -static struct pcm_format *fmt; - -static const int16_t adaptation_table[] ICONST_ATTR = { - 230, 230, 230, 230, 307, 409, 512, 614, - 768, 614, 512, 409, 307, 230, 230, 230 -}; - -static bool set_format(struct pcm_format *format) -{ - fmt = format; - - if (fmt->bitspersample != 4) - { - DEBUGF("CODEC_ERROR: microsoft adpcm must be 4 bitspersample: %d\n", - fmt->bitspersample); - return false; - } - - fmt->chunksize = fmt->blockalign; - - return true; -} - -static struct pcm_pos *get_seek_pos(uint32_t seek_val, int seek_mode, - uint8_t *(*read_buffer)(size_t *realsize)) -{ - static struct pcm_pos newpos; - uint32_t newblock = (seek_mode == PCM_SEEK_TIME) ? - ((uint64_t)seek_val * ci->id3->frequency / 1000LL) - / fmt->samplesperblock : - seek_val / fmt->blockalign; - - (void)read_buffer; - newpos.pos = newblock * fmt->blockalign; - newpos.samples = newblock * fmt->samplesperblock; - return &newpos; -} - -static int16_t create_pcmdata(int ch, uint8_t nibble) -{ - int32_t pcmdata; - - pcmdata = (sample[ch][0] * dec_coeff[ch][0] + - sample[ch][1] * dec_coeff[ch][1]) / 256; - pcmdata += (delta[ch] * (nibble - ((nibble & 0x8) << 1))); - - CLIP(pcmdata, -32768, 32767); - - sample[ch][1] = sample[ch][0]; - sample[ch][0] = pcmdata; - - delta[ch] = (adaptation_table[nibble] * delta[ch]) >> 8; - if (delta[ch] < 16) - delta[ch] = 16; - - return (int16_t)pcmdata; -} - -static int decode(const uint8_t *inbuf, size_t inbufsize, - int32_t *outbuf, int *outbufcount) -{ - int ch; - size_t nsamples = 0; - int size = fmt->samplesperblock; - - /* read block header */ - for (ch = 0; ch < fmt->channels; ch++) - { - if (*inbuf >= ADPCM_NUM_COEFF) - { - DEBUGF("CODEC_ERROR: microsoft adpcm illegal initial coeff=%d > 7\n", - *inbuf); - return CODEC_ERROR; - } - dec_coeff[ch][0] = fmt->coeffs[*inbuf][0]; - dec_coeff[ch][1] = fmt->coeffs[*inbuf][1]; - inbuf++; - } - - for (ch = 0; ch < fmt->channels; ch++) - { - delta[ch] = inbuf[0] | (SE(inbuf[1]) << 8); - inbuf += 2; - } - - for (ch = 0; ch < fmt->channels; ch++) - { - sample[ch][0] = inbuf[0] | (SE(inbuf[1]) << 8); - inbuf += 2; - } - - for (ch = 0; ch < fmt->channels; ch++) - { - sample[ch][1] = inbuf[0] | (SE(inbuf[1]) << 8); - inbuf += 2; - } - - inbufsize -= 7 * fmt->channels; - ch = fmt->channels - 1; - - while (size-- > 0) - { - *outbuf++ = create_pcmdata(0, *inbuf >> 4 ) << (PCM_OUTPUT_DEPTH - 16); - *outbuf++ = create_pcmdata(ch, *inbuf & 0xf) << (PCM_OUTPUT_DEPTH - 16); - nsamples += 2; - - inbuf++; - inbufsize--; - if (inbufsize <= 0) - break; - } - - if (fmt->channels == 2) - nsamples >>= 1; - *outbufcount = nsamples; - - return CODEC_OK; -} - -static const struct pcm_codec codec = { - set_format, - get_seek_pos, - decode, - }; - -const struct pcm_codec *get_ms_adpcm_codec(void) -{ - return &codec; -} diff --git a/apps/codecs/libpcm/pcm_common.h b/apps/codecs/libpcm/pcm_common.h deleted file mode 100644 index 90e29c98ee..0000000000 --- a/apps/codecs/libpcm/pcm_common.h +++ /dev/null @@ -1,190 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2009 Yoshihisa Uchida - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ -#ifndef CODEC_LIBPCM_PCM_COMMON_H -#define CODEC_LIBPCM_PCM_COMMON_H - -#include -#include -#include - -/* decoded pcm sample depth (sample 28bit + sign 1bit) */ -#define PCM_OUTPUT_DEPTH 29 - -/* Macro that sign extends an unsigned byte */ -#define SE(x) ((int32_t)((int8_t)(x))) - -/* Macro that shift to -0x80. (0 .. 127 to -128 .. -1, 128 .. 255 to 0 .. 127) */ -#define SFT(x) ((int32_t)x-0x80) - -/* Macro that clipping data */ -#define CLIP(data, min, max) \ -if ((data) > (max)) data = max; \ -else if ((data) < (min)) data = min; - -/* nums of msadpcm coeffs - * In many case, nNumCoef is 7. - * Depending upon the encoder, as for this value there is a possibility - * of increasing more. - * If you found the file where this value exceeds 7, please report. - */ -#define MSADPCM_NUM_COEFF 7 - -struct pcm_format { - /* - * RIFF: wFormatTag (in 'fmt ' chunk) - * AIFF: compressionType (in 'COMM' chunk) - */ - uint32_t formattag; - - /* - * RIFF: wChannels (in 'fmt ' chunk) - * AIFF: numChannels (in 'COMM' chunk) - */ - uint16_t channels; - - /* - * RIFF: dwSamplesPerSec (in 'fmt ' chunk) - * AIFF: sampleRate (in 'COMM' chunk) - */ - uint32_t samplespersec; - - /* RIFF: dwAvgBytesPerSec (in 'fmt ' chunk) */ - uint32_t avgbytespersec; - - /* - * RIFF: wBlockAlign (in 'fmt ' chunk) - * AIFF: blockSize (in 'SSND' chunk) - */ - uint16_t blockalign; - - /* - * RIFF: wBitsPerSample (in 'fmt ' chunk) - * AIFF: sampleSize (in 'COMM' chunk) - */ - uint16_t bitspersample; - - /* RIFF: wSize (in 'fmt ' chunk) */ - uint16_t size; - - /* RIFF: dSamplesPerBlock (in 'fmt ' chunk) */ - uint16_t samplesperblock; - - /* RIFF: wTotalSamples (in 'fact' chunk) */ - uint16_t totalsamples; - - /* the following values are not RIFF/AIFF chunk values */ - - /* bytes per sample */ - int bytespersample; - - /* chunk size */ - long chunksize; - - /* data size */ - uint32_t numbytes; - - /* - * data endian - * true: little endian, false: big endian - */ - bool is_little_endian; - - /* - * data signess - * true: signed, false: unsigned - */ - bool is_signed; - - /* the following values are format speciffic parameters */ - - /* microsoft adpcm: aCoeff */ - int16_t coeffs[MSADPCM_NUM_COEFF][2]; -}; - -struct pcm_pos { - uint32_t pos; - uint32_t samples; -}; - -#define PCM_SEEK_TIME 0 -#define PCM_SEEK_POS 1 - -struct pcm_codec { - /* - * sets the format speciffic RIFF/AIFF header information and checks the pcm_format. - * - * [In/Out] format - * the structure which supplies RIFF/AIFF header information. - * - * return - * true: RIFF/AIFF header check OK - * false: RIFF/AIFF header check NG - */ - bool (*set_format)(struct pcm_format *format); - - /* - * get seek position - * - * [In] seek_val - * seek time [ms] or seek position - * - * [In] seek_mode - * if seek_mode sets PCM_SEEK_TIME, then seek_val means the seek time. - * if seek_mode sets PCM_SEEK_POS, then seek_val means the seek position. - * - * [In] read_buffer - * the function which reads the data from the file (chunksize bytes read). - * - * return - * position after the seeking. - */ - struct pcm_pos *(*get_seek_pos)(uint32_t seek_val, int seek_mode, - uint8_t *(*read_buffer)(size_t *realsize)); - - /* - * decode wave data. - * - * [In] inbuf - * the start pointer of wave data buffer. - * - * [In] inbufsize - * wave data buffer size (bytes). - * - * [Out] outbuf - * the start pointer of the buffer which supplies decoded pcm data. - * - * [Out] outbufcount - * decoded pcm data count. - * - * return - * CODEC_OK: decode succeed. - * CODEC_ERROR: decode failure. - */ - int (*decode)(const uint8_t *inbuf, size_t inbufsize, - int32_t *outbuf, int *outbufcount); -}; - -struct pcm_entry { - uint32_t format_tag; - const struct pcm_codec *(*get_codec)(void); -}; - -#endif diff --git a/apps/codecs/libpcm/qt_ima_adpcm.c b/apps/codecs/libpcm/qt_ima_adpcm.c deleted file mode 100644 index d7b3360eb3..0000000000 --- a/apps/codecs/libpcm/qt_ima_adpcm.c +++ /dev/null @@ -1,138 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2010 Yoshihisa Uchida - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ -#include "codeclib.h" -#include "ima_adpcm_common.h" -#include "support_formats.h" - -/* - * Apple QuickTime IMA ADPCM - * - * References - * [1] Multimedia Wiki, Apple QuickTime IMA ADPCM - * URL:http://wiki.multimedia.cx/index.php?title=Apple_QuickTime_IMA_ADPCM - * [2] Apple Inc., Technical Note TN1081 Understanding the Differences Between - * Apple and Windows IMA-ADPCM Compressed Sound Files, 1996 - * [3] ffmpeg source code, libavcodec/adpcm.c - */ - -static struct pcm_format *fmt; - -static bool set_format(struct pcm_format *format) -{ - fmt = format; - - if (fmt->bitspersample != 4) - { - DEBUGF("CODEC_ERROR: quicktime ima adpcm must be 4 bitspersample: %d\n", - fmt->bitspersample); - return false; - } - - fmt->blockalign = 34 * fmt->channels; - fmt->samplesperblock = 64; - - /* chunksize = about 1/50[s] data */ - fmt->chunksize = (ci->id3->frequency / (50 * fmt->samplesperblock)) - * fmt->blockalign; - - init_ima_adpcm_decoder(4, NULL); - return true; -} - -static struct pcm_pos *get_seek_pos(uint32_t seek_val, int seek_mode, - uint8_t *(*read_buffer)(size_t *realsize)) -{ - static struct pcm_pos newpos; - uint32_t newblock = (seek_mode == PCM_SEEK_TIME) ? - ((uint64_t)seek_val * ci->id3->frequency / 1000LL) - / fmt->samplesperblock : - seek_val / fmt->blockalign; - - (void)read_buffer; - newpos.pos = newblock * fmt->blockalign; - newpos.samples = newblock * fmt->samplesperblock; - return &newpos; -} - -static int decode(const uint8_t *inbuf, size_t inbufsize, - int32_t *outbuf, int *outbufcount) -{ - int ch; - size_t nsamples = 0; - int block_size; - int32_t *pcmbuf; - int32_t init_pcmdata; - int8_t init_index; - - while (inbufsize > 0) - { - for (ch = 0; ch < fmt->channels; ch++) - { - /* read block header */ - init_pcmdata = (inbuf[0] << 8)|(inbuf[1] & 0x80); - if (init_pcmdata > 32767) - init_pcmdata -= 65536; - - init_index = inbuf[1] & 0x7f; - if (init_index > 88) - { - DEBUGF("CODEC_ERROR: quicktime ima adpcm illegal step index=%d > 88\n", - init_index); - return CODEC_ERROR; - } - - inbuf += 2; - inbufsize -= 2; - - set_decode_parameters(1, &init_pcmdata, &init_index); - - /* read block data */ - pcmbuf = outbuf + ch; - for (block_size = 32; block_size > 0 && inbufsize > 0; block_size--, inbufsize--) - { - *pcmbuf = create_pcmdata_size4(ch, *inbuf ) << IMA_ADPCM_INC_DEPTH; - pcmbuf += fmt->channels; - *pcmbuf = create_pcmdata_size4(ch, *inbuf >> 4) << IMA_ADPCM_INC_DEPTH; - pcmbuf += fmt->channels; - nsamples += 2; - inbuf++; - } - } - outbuf += 64 * fmt->channels; - } - - if (fmt->channels == 2) - nsamples >>= 1; - *outbufcount = nsamples; - - return CODEC_OK; -} - -static const struct pcm_codec codec = { - set_format, - get_seek_pos, - decode, - }; - -const struct pcm_codec *get_qt_ima_adpcm_codec(void) -{ - return &codec; -} diff --git a/apps/codecs/libpcm/support_formats.h b/apps/codecs/libpcm/support_formats.h deleted file mode 100644 index b1e089e464..0000000000 --- a/apps/codecs/libpcm/support_formats.h +++ /dev/null @@ -1,55 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2009 Yoshihisa Uchida - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ -#ifndef CODEC_LIBPCM_SUPPORT_FORMATS_H -#define CODEC_LIBPCM_SUPPORT_FORMATS_H - -#include "pcm_common.h" - -/* Linear PCM */ -const struct pcm_codec *get_linear_pcm_codec(void); - -/* ITU-T G.711 A-law */ -const struct pcm_codec *get_itut_g711_alaw_codec(void); - -/* ITU-T G.711 mu-law */ -const struct pcm_codec *get_itut_g711_mulaw_codec(void); - -/* Intel DVI ADPCM (IMA ADPCM) */ -const struct pcm_codec *get_dvi_adpcm_codec(void); - -/* IEEE float */ -const struct pcm_codec *get_ieee_float_codec(void); - -/* Microsoft ADPCM */ -const struct pcm_codec *get_ms_adpcm_codec(void); - -/* Dialogic OKI ADPCM */ -const struct pcm_codec *get_dialogic_oki_adpcm_codec(void); - -/* YAMAHA ADPCM */ -const struct pcm_codec *get_yamaha_adpcm_codec(void); - -/* Apple QuickTime IMA ADPCM */ -const struct pcm_codec *get_qt_ima_adpcm_codec(void); - -/* Adobe SWF ADPCM */ -const struct pcm_codec *get_swf_adpcm_codec(void); -#endif diff --git a/apps/codecs/libpcm/swf_adpcm.c b/apps/codecs/libpcm/swf_adpcm.c deleted file mode 100644 index c440fd1303..0000000000 --- a/apps/codecs/libpcm/swf_adpcm.c +++ /dev/null @@ -1,236 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2010 Yoshihisa Uchida - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ -#include "codeclib.h" -#include "ima_adpcm_common.h" -#include "support_formats.h" - -/* - * Adobe SWF ADPCM - * - * References - * [1] Adobe, SWF File Format Specification Version 10, 2008 - * [2] Jack Jansen, adpcm.c in adpcm.zip - * [3] ffmpeg source code, libavcodec/adpcm.c - */ - -/* step index table when bitspersample is 3. - * (when bitspersample is 2, 4, 5, step index table uses the table - * which is defined ima_adpcm_common.c.) - */ -static const int index_table[4] ICONST_ATTR = { - -1, -1, 2, 4, -}; - -static int validity_bits = 8; -static bool first_block = true; -static int blockbits = 0; -static int lastbytebits = 0; -static bool after_seek = false; - -static struct pcm_format *fmt; - -#define GET_SAMPLE_COUNT(s) ((((s) << 3) / fmt->channels - 22) / fmt->bitspersample + 1) - -static bool set_format(struct pcm_format *format) -{ - fmt = format; - - if (fmt->bitspersample < 2 || fmt->bitspersample > 5) - { - DEBUGF("CODEC_ERROR: swf adpcm must be 2, 3, 4 or 5 bitspersample: %d\n", - fmt->bitspersample); - return false; - } - - if (fmt->samplesperblock == 0) - fmt->samplesperblock = (((fmt->blockalign << 3) - 2) / fmt->channels - 22) - / fmt->bitspersample + 1; - - blockbits = ((fmt->samplesperblock - 1) * fmt->bitspersample + 22) * fmt->channels; - - /* - * chunksize = about 93 [ms] data (frequency:44.1kHz, 4096 [sample/block]) - * chunksize changes depending upon the position of block. - */ - fmt->chunksize = (blockbits + 9) >> 3; - - /* initialize for ima adpcm common functions */ - if (fmt->bitspersample == 3) - init_ima_adpcm_decoder(fmt->bitspersample, index_table); - else - init_ima_adpcm_decoder(fmt->bitspersample, NULL); - - return true; -} - -static struct pcm_pos *get_seek_pos(uint32_t seek_val, int seek_mode, - uint8_t *(*read_buffer)(size_t *realsize)) -{ - static struct pcm_pos newpos; - uint32_t chunkbits = blockbits; - uint32_t seekblocks = (seek_mode == PCM_SEEK_TIME)? - ((uint64_t)seek_val * ci->id3->frequency) - / (1000LL * fmt->samplesperblock) : - ((seek_val << 3) - 2) / blockbits; - uint32_t seekbits = seekblocks * blockbits + 2; - - (void)read_buffer; - - newpos.pos = seekbits >> 3; - newpos.samples = seekblocks * fmt->samplesperblock; - - if (newpos.pos == 0) - { - first_block = true; - lastbytebits = 0; - } - else - { - first_block = false; - lastbytebits = seekbits & 0x07; - if (lastbytebits != 0) - chunkbits -= (8 - lastbytebits); - } - - /* calculates next read bytes */ - fmt->chunksize = (chunkbits >> 3) + (((chunkbits & 0x07) > 0)?1:0) - + ((lastbytebits > 0)?1:0); - - after_seek = true; - return &newpos; -} - -static uint8_t get_data(const uint8_t **buf, int bit) -{ - uint8_t res = 0; - uint8_t mask = (1 << bit) - 1; - - if (validity_bits >= bit) - { - validity_bits -= bit; - return (**buf >> validity_bits) & mask; - } - - if (validity_bits > 0) - res = **buf << (bit - validity_bits); - - validity_bits += 8 - bit; - res = (res | (*(++(*buf)) >> validity_bits)) & mask; - return res; -} - -static int decode(const uint8_t *inbuf, size_t inbufsize, - int32_t *outbuf, int *outbufcount) -{ - int ch; - int adpcm_code_size; - int count = ((size_t)fmt->chunksize == inbufsize) ? fmt->samplesperblock : - GET_SAMPLE_COUNT(inbufsize); - int32_t init_pcmdata[2]; - int8_t init_index[2]; - static uint8_t lastbyte = 0; - - validity_bits = 8; - *outbufcount = count; - - /* read block header */ - ch = fmt->channels - 1; - if (first_block) - { - adpcm_code_size = get_data(&inbuf, 2) + 2; - if (fmt->bitspersample != adpcm_code_size) - { - DEBUGF("CODEC_ERROR: swf adpcm different adpcm code size=%d != %d\n", - adpcm_code_size, fmt->bitspersample); - return CODEC_ERROR; - } - init_pcmdata[0] = (get_data(&inbuf, 8) << 8) | get_data(&inbuf, 8); - - lastbytebits = 0; - first_block = false; - } - else - { - if (after_seek && lastbytebits > 0) - { - lastbyte = *inbuf++; - after_seek = false; - } - if (lastbytebits > 0) - init_pcmdata[0] = ((lastbyte << (8 + lastbytebits)) | - (get_data(&inbuf, 8) << lastbytebits) | - get_data(&inbuf, lastbytebits)) & 65535; - else - init_pcmdata[0] = (get_data(&inbuf, 8) << 8) | get_data(&inbuf, 8); - } - after_seek = false; - - init_index[0] = get_data(&inbuf, 6); - if (init_pcmdata[0] > 32767) - init_pcmdata[0] -= 65536; - - if (ch > 0) - { - init_pcmdata[1] = (get_data(&inbuf, 8) << 8) | get_data(&inbuf, 8); - init_index[1] = get_data(&inbuf, 6); - if (init_pcmdata[1] > 32767) - init_pcmdata[1] -= 65536; - } - - *outbuf++ = init_pcmdata[0] << IMA_ADPCM_INC_DEPTH; - if (ch > 0) - *outbuf++ = init_pcmdata[1] << IMA_ADPCM_INC_DEPTH; - - set_decode_parameters(fmt->channels, init_pcmdata, init_index); - - /* read block data */ - while (--count > 0) - { - *outbuf++ = create_pcmdata(0, get_data(&inbuf, fmt->bitspersample)) - << IMA_ADPCM_INC_DEPTH; - if (ch > 0) - *outbuf++ = create_pcmdata(ch, get_data(&inbuf, fmt->bitspersample)) - << IMA_ADPCM_INC_DEPTH; - } - - lastbyte = *inbuf; - lastbytebits = (8 - validity_bits) & 0x07; - - /* calculates next read bytes */ - fmt->chunksize = (blockbits - validity_bits + 7) >> 3; - - return CODEC_OK; -} - -static const struct pcm_codec codec = { - set_format, - get_seek_pos, - decode, - }; - -const struct pcm_codec *get_swf_adpcm_codec(void) -{ - first_block = true; - lastbytebits = 0; - after_seek = false; - - return &codec; -} diff --git a/apps/codecs/libpcm/yamaha_adpcm.c b/apps/codecs/libpcm/yamaha_adpcm.c deleted file mode 100644 index c67fe7524a..0000000000 --- a/apps/codecs/libpcm/yamaha_adpcm.c +++ /dev/null @@ -1,250 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2010 Yoshihisa Uchida - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ -#include "codeclib.h" -#include "adpcm_seek.h" -#include "support_formats.h" - -/* - * YAMAHA ADPCM - * - * References - * [1] YAMAHA, YAMAHA ADPCM ACM Driver Version 1.0.0.0, 2005 - * [2] BlendWorks, YM2608 ADPCM, - * http://web.archive.org/web/20050208190547/www.memb.jp/~dearna/ma/ym2608/adpcm.html - * [3] Naoyuki Sawa, ADPCM no shikumi #1, - * http://www.piece-me.org/piece-lab/adpcm/adpcm1.html - * [4] ffmpeg source code, libavcodec/adpcm.c - */ - -/* ADPCM data block layout - * - * when the block header exists. (for example, encoding by YAMAHA ADPCM ACM Driver) - * blockAlign = (frequency / 60 + 4) * channels. - * - * block - * (channels = 1) - * int16_t first value (Little endian) - * uint16_t first predictor (Little endian) - * uint8_t ADPCM data (1st data: 0-3 bit, 2nd data: 4-7 bit) - * .... - * - * (channels = 2) - * int16_t Left channel first value (Little endian) - * uint16_t Left channel first predictor (Little endian) - * int16_t Right channel first value (Little endian) - * uint16_t Right channel first predictor (Little endian) - * uint8_t ADPCM data (Left channel: 0-3 bit, Right channel: 4-7 bit) - * .... - * - * when the block header does not exist. (for example, encoding by ffmpeg) - * blockAlign = 8000 - * - * block - * (channels = 1) - * uint8_t ADPCM data (1st data: 0-3 bit, 2nd data: 4-7 bit) - * .... - * - * (channels = 2) - * uint8_t ADPCM data (Left channel: 0-3 bit, Right channel: 4-7 bit) - * .... - */ - -static const int32_t amplification_table[] ICONST_ATTR = { - 230, 230, 230, 230, 307, 409, 512, 614, 230, 230, 230, 230, 307, 409, 512, 614 -}; - -static bool has_block_header = false; - -static struct adpcm_data cur_data; -static int blocksperchunk; - -static struct pcm_format *fmt; - -static bool set_format(struct pcm_format *format) -{ - fmt = format; - - if (fmt->channels == 0) - { - DEBUGF("CODEC_ERROR: channels is 0\n"); - return false; - } - - if (fmt->bitspersample != 4) - { - DEBUGF("CODEC_ERROR: yamaha adpcm must be 4 bitspersample: %d\n", - fmt->bitspersample); - return false; - } - - /* check exists block header */ - if (fmt->blockalign == ((ci->id3->frequency / 60) + 4) * fmt->channels) - { - has_block_header = true; - - /* chunksize = about 1/30 [sec] data */ - fmt->chunksize = fmt->blockalign; - blocksperchunk = 1; - } - else - { - uint32_t max_chunk_count; - - has_block_header = false; - - /* blockalign = 2 * channels samples */ - fmt->blockalign = fmt->channels; - fmt->samplesperblock = 2; - - /* chunksize = about 1/32[sec] data */ - blocksperchunk = ci->id3->frequency >> 6; - fmt->chunksize = blocksperchunk * fmt->blockalign; - - max_chunk_count = (uint64_t)ci->id3->length * ci->id3->frequency - / (2000LL * fmt->chunksize / fmt->channels); - - /* initialize seek table */ - init_seek_table(max_chunk_count); - /* add first data */ - add_adpcm_data(&cur_data); - } - - return true; -} - -static int16_t create_pcmdata(int ch, uint8_t nibble) -{ - int32_t tmp_pcmdata = cur_data.pcmdata[ch]; - int32_t step = cur_data.step[ch]; - int32_t delta = step >> 3; - - if (nibble & 4) delta += step; - if (nibble & 2) delta += (step >> 1); - if (nibble & 1) delta += (step >> 2); - - if (nibble & 0x08) - tmp_pcmdata -= delta; - else - tmp_pcmdata += delta; - - CLIP(tmp_pcmdata, -32768, 32767); - cur_data.pcmdata[ch] = tmp_pcmdata; - - step = (step * amplification_table[nibble & 0x07]) >> 8; - CLIP(step, 127, 24576); - cur_data.step[ch] = step; - - return cur_data.pcmdata[ch]; -} - -static int decode(const uint8_t *inbuf, size_t inbufsize, - int32_t *outbuf, int *outbufcount) -{ - int ch; - size_t nsamples = 0; - - /* read block header */ - if (has_block_header) - { - for (ch = 0; ch < fmt->channels; ch++) - { - cur_data.pcmdata[ch] = inbuf[0] | (SE(inbuf[1]) << 8); - cur_data.step[ch] = inbuf[2] | (inbuf[3] << 8); - - inbuf += 4; - inbufsize -= 4; - } - } - - /* read block data */ - ch = fmt->channels - 1; - while (inbufsize) - { - *outbuf++ = create_pcmdata(0, *inbuf ) << (PCM_OUTPUT_DEPTH - 16); - *outbuf++ = create_pcmdata(ch, *inbuf >> 4) << (PCM_OUTPUT_DEPTH - 16); - nsamples += 2; - - inbuf++; - inbufsize--; - } - - if (fmt->channels == 2) - nsamples >>= 1; - *outbufcount = nsamples; - - if (!has_block_header) - add_adpcm_data(&cur_data); - - return CODEC_OK; -} - -static int decode_for_seek(const uint8_t *inbuf, size_t inbufsize) -{ - int ch = fmt->channels - 1; - - while (inbufsize) - { - create_pcmdata(0, *inbuf ); - create_pcmdata(ch, *inbuf >> 4); - - inbuf++; - inbufsize--; - } - - add_adpcm_data(&cur_data); - - return CODEC_OK; -} - -static struct pcm_pos *get_seek_pos(uint32_t seek_val, int seek_mode, - uint8_t *(*read_buffer)(size_t *realsize)) -{ - static struct pcm_pos newpos; - uint32_t new_count = (seek_mode == PCM_SEEK_TIME)? - ((uint64_t)seek_val * ci->id3->frequency / 1000LL) - / (blocksperchunk * fmt->samplesperblock) : - seek_val / (unsigned long)fmt->chunksize; - - if (!has_block_header) - { - new_count = seek(new_count, &cur_data, read_buffer, &decode_for_seek); - } - newpos.pos = new_count * fmt->chunksize; - newpos.samples = new_count * blocksperchunk * fmt->samplesperblock; - return &newpos; -} - -static struct pcm_codec codec = { - set_format, - get_seek_pos, - decode, - }; - -const struct pcm_codec *get_yamaha_adpcm_codec(void) -{ - /* initialize first step, pcm data */ - cur_data.pcmdata[0] = 0; - cur_data.pcmdata[1] = 0; - cur_data.step[0] = 127; - cur_data.step[1] = 127; - - return &codec; -} diff --git a/apps/codecs/librm/SOURCES b/apps/codecs/librm/SOURCES deleted file mode 100644 index e0ff169fae..0000000000 --- a/apps/codecs/librm/SOURCES +++ /dev/null @@ -1 +0,0 @@ -rm.c diff --git a/apps/codecs/librm/bytestream.h b/apps/codecs/librm/bytestream.h deleted file mode 100644 index c2a968a4bd..0000000000 --- a/apps/codecs/librm/bytestream.h +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef RM_BYTESTREAM_H -#define RM_BYTESTREAM_H - -#include - -static inline void advance_buffer(uint8_t **buf, int val) -{ - *buf += val; -} - -static inline uint8_t rm_get_uint8(uint8_t *buf) -{ - return (uint8_t)buf[0]; -} - -static inline uint16_t rm_get_uint16be(uint8_t *buf) -{ - return (uint16_t)((buf[0] << 8)|buf[1]); -} - -static inline uint32_t rm_get_uint32be(uint8_t *buf) -{ - return (uint32_t)((buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3]); -} - -static inline uint16_t rm_get_uint16le(uint8_t *buf) -{ - return (uint16_t)((buf[1] << 8)|buf[0]); -} - -static inline uint32_t rm_get_uint32le(uint8_t *buf) -{ - return (uint32_t)((buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0]); -} - -#endif /* RM_BYTESTREAM_H */ - diff --git a/apps/codecs/librm/librm.make b/apps/codecs/librm/librm.make deleted file mode 100644 index 7f2c34c9ac..0000000000 --- a/apps/codecs/librm/librm.make +++ /dev/null @@ -1,18 +0,0 @@ -# __________ __ ___. -# Open \______ \ ____ ____ | | _\_ |__ _______ ___ -# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / -# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < -# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ -# \/ \/ \/ \/ \/ -# $Id: librm.make 20151 2009-03-01 09:04:15Z amiconn $ -# - -# librm -RMLIB := $(CODECDIR)/librm.a -RMLIB_SRC := $(call preprocess, $(APPSDIR)/codecs/librm/SOURCES) -RMLIB_OBJ := $(call c2obj, $(RMLIB_SRC)) -OTHER_SRC += $(RMLIB_SRC) - -$(RMLIB): $(RMLIB_OBJ) - $(SILENT)$(shell rm -f $@) - $(call PRINTS,AR $(@F))$(AR) rcs $@ $^ >/dev/null diff --git a/apps/codecs/librm/rm.c b/apps/codecs/librm/rm.c deleted file mode 100644 index eabbe5d92a..0000000000 --- a/apps/codecs/librm/rm.c +++ /dev/null @@ -1,592 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2008 Dave Chapman - * Copyright (C) 2009 Mohamed Tarek - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ -#include -#include - -#include "rm.h" -#ifdef ROCKBOX -#include "codeclib.h" -#endif - -#define SWAP(a, b) do{uint8_t SWAP_tmp= b; b= a; a= SWAP_tmp;}while(0) - -#ifdef TEST -#include -#include -#include "inttypes.h" -#include - -int filesize(int fd) -{ - struct stat buf; - - if (fstat(fd,&buf) == -1) { - return -1; - } else { - return (int)buf.st_size; - } -} - -static int read_uint8(int fd, uint8_t* buf) -{ - unsigned char tmp[1]; - int res; - - res=read(fd, tmp, 1); - *buf = tmp[0]; - return res; -} - -static int read_uint16be(int fd, uint16_t* buf) -{ - unsigned char tmp[2]; - int res; - - res=read(fd, tmp, 2); - *buf = (tmp[0] << 8) | tmp[1]; - return res; -} - -static int read_uint32be(int fd, uint32_t* buf) -{ - unsigned char tmp[4]; - int res; - - res=read(fd, tmp, 4); - *buf = (tmp[0] << 24) | (tmp[1] << 16) | (tmp[2] << 8) | tmp[3]; - return res; -} - - -static void print_cook_extradata(RMContext *rmctx) { - - DEBUGF(" cook_version = 0x%08x\n", rm_get_uint32be(rmctx->codec_extradata)); - DEBUGF(" samples_per_frame_per_channel = %d\n", rm_get_uint16be(&rmctx->codec_extradata[4])); - DEBUGF(" number_of_subbands_in_freq_domain = %d\n", rm_get_uint16be(&rmctx->codec_extradata[6])); - if(rmctx->extradata_size == 16) { - DEBUGF(" joint_stereo_subband_start = %d\n",rm_get_uint16be(&rmctx->codec_extradata[12])); - DEBUGF(" joint_stereo_vlc_bits = %d\n", rm_get_uint16be(&rmctx->codec_extradata[14])); - } -} - - -struct real_object_t -{ - uint32_t fourcc; - uint32_t size; - uint16_t version; -}; - -#define FOURCC(a,b,c,d) (((a)<<24) | ((b) << 16) | ((c) << 8) | (d)) - -static int real_read_object_header(int fd, struct real_object_t* obj) -{ - int n; - - if ((n = read_uint32be(fd, &obj->fourcc)) <= 0) return n; - if ((n = read_uint32be(fd, &obj->size)) <= 0) return n; - if ((n = read_uint16be(fd, &obj->version)) <= 0) return n; - - return 1; -} - -static char* fourcc2str(uint32_t f) -{ - static char res[5]; - - res[0] = (f & 0xff000000) >> 24; - res[1] = (f & 0xff0000) >> 16; - res[2] = (f & 0xff00) >> 8; - res[3] = (f & 0xff); - res[4] = 0; - - return res; -} - -static int read_str(int fd, char* buf) -{ - uint8_t len; - int res; - - res = read(fd, &len, 1); - res = read(fd, buf, len); - buf[len]=0; - - return len+1; -} - -static int real_read_audio_stream_info(int fd, RMContext *rmctx) -{ - int skipped = 0; - uint32_t version; - struct real_object_t obj; - memset(&obj,0,sizeof(obj)); - uint32_t header_size; - uint16_t flavor; - uint32_t coded_framesize; - uint32_t unknown1; - uint32_t unknown2; - uint32_t unknown3; - uint16_t unknown4; - uint16_t unknown5; - uint16_t unknown6; - uint16_t unknown7; - uint32_t unknown8; - uint8_t interleaver_id_length; - uint32_t interleaver_id; - uint8_t fourcc_length; - uint32_t fourcc = 0; - uint8_t unknown9; - uint16_t unknown10; - uint8_t unknown11; - - read_uint32be(fd, &version); - skipped += 4; - - DEBUGF(" version=0x%04x\n",((version >> 16) & 0xff)); - if (((version >> 16) & 0xff) == 3) { - /* Very old version */ - } else { - real_read_object_header(fd, &obj); - skipped += 10; - read_uint32be(fd, &header_size); - skipped += 4; - /* obj.size will be filled with an unknown value, replaced with header_size */ - DEBUGF(" Object: %s, size: %d bytes, version: 0x%04x\n",fourcc2str(obj.fourcc),header_size,obj.version); - - read_uint16be(fd, &flavor); - read_uint32be(fd, &coded_framesize); - read_uint32be(fd, &unknown1); - read_uint32be(fd, &unknown2); - read_uint32be(fd, &unknown3); - read_uint16be(fd, &rmctx->sub_packet_h); - read_uint16be(fd, &rmctx->block_align); - read_uint16be(fd, &rmctx->sub_packet_size); - read_uint16be(fd, &unknown4); - skipped += 26; - if (((version >> 16) & 0xff) == 5) - { - read_uint16be(fd, &unknown5); - read_uint16be(fd, &unknown6); - read_uint16be(fd, &unknown7); - skipped += 6; - } - read_uint16be(fd, &rmctx->sample_rate); - read_uint32be(fd, &unknown8); - read_uint16be(fd, &rmctx->nb_channels); - skipped += 8; - if (((version >> 16) & 0xff) == 4) - { - read_uint8(fd, &interleaver_id_length); - read_uint32be(fd, &interleaver_id); - read_uint8(fd, &fourcc_length); - read_uint32be(fd, &fourcc); - skipped += 10; - } - if (((version >> 16) & 0xff) == 5) - { - read_uint32be(fd, &interleaver_id); - read_uint32be(fd, &fourcc); - skipped += 8; - } - read_uint8(fd,&unknown9); - read_uint16be(fd,&unknown10); - skipped += 3; - if (((version >> 16) & 0xff) == 5) - { - read_uint8(fd, &unknown11); - skipped += 1; - } - - switch(fourcc) { - case FOURCC('c','o','o','k'): - rmctx->codec_type = CODEC_COOK; - read_uint32be(fd, &rmctx->extradata_size); - skipped += 4; - read(fd, rmctx->codec_extradata, rmctx->extradata_size); - skipped += rmctx->extradata_size; - break; - - case FOURCC('a','t','r','c'): - rmctx->codec_type = CODEC_ATRAC; - read_uint32be(fd, &rmctx->extradata_size); - skipped += 4; - read(fd, rmctx->codec_extradata, rmctx->extradata_size); - skipped += rmctx->extradata_size; - break; - - case FOURCC('r','a','a','c'): - case FOURCC('r','a','c','p'): - rmctx->codec_type = CODEC_AAC; - read_uint32be(fd, &rmctx->extradata_size); - skipped += 4; - read(fd, rmctx->codec_extradata, rmctx->extradata_size); - skipped += rmctx->extradata_size; - break; - - case FOURCC('d','n','e','t'): - rmctx->codec_type = CODEC_AC3; - break; - - default: /* Not a supported codec */ - return -1; - } - - - DEBUGF(" flavor = %d\n",flavor); - DEBUGF(" coded_frame_size = %d\n",coded_framesize); - DEBUGF(" sub_packet_h = %d\n",rmctx->sub_packet_h); - DEBUGF(" frame_size = %d\n",rmctx->block_align); - DEBUGF(" sub_packet_size = %d\n",rmctx->sub_packet_size); - DEBUGF(" sample_rate= %d\n",rmctx->sample_rate); - DEBUGF(" channels= %d\n",rmctx->nb_channels); - DEBUGF(" fourcc = %s\n",fourcc2str(fourcc)); - DEBUGF(" codec_extra_data_length = %d\n",rmctx->extradata_size); - if(rmctx->codec_type == CODEC_COOK) { - DEBUGF(" cook_extradata :\n"); - print_cook_extradata(rmctx); - } - - } - - return skipped; -} - -int real_parse_header(int fd, RMContext *rmctx) -{ - struct real_object_t obj; - memset(&obj,0,sizeof(obj)); - int res; - int skipped; - off_t curpos; - - uint32_t unknown1; - uint32_t unknown2; - - uint32_t max_bitrate; - uint32_t avg_bitrate = 0; - uint32_t max_packet_size; - uint32_t avg_packet_size; - uint32_t packet_count; - uint32_t duration; - uint32_t preroll; - uint32_t index_offset; - uint16_t num_streams; - uint16_t flags = 0; - - uint16_t stream_id; - uint32_t start_time; - char desc[256]; - char mimetype[256]; - uint32_t codec_data_size; - uint32_t v; - - char title[256]; - char author[256]; - char copyright[256]; - char comment[256]; - - uint32_t next_data_off; - uint8_t header_end; - - curpos = lseek(fd, 0, SEEK_SET); - res = real_read_object_header(fd, &obj); - - if (obj.fourcc == FOURCC('.','r','a',0xfd)) - { - /* Very old .ra format - not yet supported */ - return -1; - } - else if (obj.fourcc != FOURCC('.','R','M','F')) - { - return -1; - } - - read_uint32be(fd, &unknown1); - read_uint32be(fd, &unknown2); - - DEBUGF("Object: %s, size: %d bytes, version: 0x%04x, pos: %d\n",fourcc2str(obj.fourcc),(int)obj.size,obj.version,(int)curpos); - DEBUGF(" unknown1=%d (0x%08x)\n",unknown1,unknown1); - DEBUGF(" unknown2=%d (0x%08x)\n",unknown2,unknown2); - - res = real_read_object_header(fd, &obj); - header_end = 0; - while(res) - { - DEBUGF("Object: %s, size: %d bytes, version: 0x%04x, pos: %d\n",fourcc2str(obj.fourcc),(int)obj.size,obj.version,(int)curpos); - skipped = 10; - if(obj.fourcc == FOURCC('I','N','D','X')) - break; - switch (obj.fourcc) - { - case FOURCC('P','R','O','P'): /* File properties */ - read_uint32be(fd, &max_bitrate); - read_uint32be(fd, &rmctx->bit_rate); /*avg bitrate*/ - read_uint32be(fd, &max_packet_size); - read_uint32be(fd, &avg_packet_size); - read_uint32be(fd, &packet_count); - read_uint32be(fd, &rmctx->duration); - read_uint32be(fd, &preroll); - read_uint32be(fd, &index_offset); - read_uint32be(fd, &rmctx->data_offset); - read_uint16be(fd, &num_streams); - read_uint16be(fd, &rmctx->flags); - skipped += 40; - - DEBUGF(" max_bitrate = %d\n",max_bitrate); - DEBUGF(" avg_bitrate = %d\n",avg_bitrate); - DEBUGF(" max_packet_size = %d\n",max_packet_size); - DEBUGF(" avg_packet_size = %d\n",avg_packet_size); - DEBUGF(" packet_count = %d\n",packet_count); - DEBUGF(" duration = %d\n",rmctx->duration); - DEBUGF(" preroll = %d\n",preroll); - DEBUGF(" index_offset = %d\n",index_offset); - DEBUGF(" data_offset = %d\n",rmctx->data_offset); - DEBUGF(" num_streams = %d\n",num_streams); - DEBUGF(" flags=0x%04x\n",flags); - break; - - case FOURCC('C','O','N','T'): - /* Four strings - Title, Author, Copyright, Comment */ - skipped += read_str(fd,title); - skipped += read_str(fd,author); - skipped += read_str(fd,copyright); - skipped += read_str(fd,comment); - - DEBUGF(" title=\"%s\"\n",title); - DEBUGF(" author=\"%s\"\n",author); - DEBUGF(" copyright=\"%s\"\n",copyright); - DEBUGF(" comment=\"%s\"\n",comment); - break; - - case FOURCC('M','D','P','R'): /* Media properties */ - read_uint16be(fd,&stream_id); - skipped += 2; - read_uint32be(fd,&max_bitrate); - skipped += 4; - read_uint32be(fd,&avg_bitrate); - skipped += 4; - read_uint32be(fd,&max_packet_size); - skipped += 4; - read_uint32be(fd,&avg_packet_size); - skipped += 4; - read_uint32be(fd,&start_time); - skipped += 4; - read_uint32be(fd,&preroll); - skipped += 4; - read_uint32be(fd,&duration); - skipped += 4; - skipped += read_str(fd,desc); - skipped += read_str(fd,mimetype); - read_uint32be(fd,&codec_data_size); - skipped += 4; - //From ffmpeg: codec_pos = url_ftell(pb); - read_uint32be(fd,&v); - skipped += 4; - - DEBUGF(" stream_id = 0x%04x\n",stream_id); - DEBUGF(" max_bitrate = %d\n",max_bitrate); - DEBUGF(" avg_bitrate = %d\n",avg_bitrate); - DEBUGF(" max_packet_size = %d\n",max_packet_size); - DEBUGF(" avg_packet_size = %d\n",avg_packet_size); - DEBUGF(" start_time = %d\n",start_time); - DEBUGF(" preroll = %d\n",preroll); - DEBUGF(" duration = %d\n",duration); - DEBUGF(" desc=\"%s\"\n",desc); - DEBUGF(" mimetype=\"%s\"\n",mimetype); - DEBUGF(" codec_data_size = %d\n",codec_data_size); - DEBUGF(" v=\"%s\"\n", fourcc2str(v)); - - if (v == FOURCC('.','r','a',0xfd)) - { - skipped += real_read_audio_stream_info(fd, rmctx); - } - - break; - - case FOURCC('D','A','T','A'): - - read_uint32be(fd,&rmctx->nb_packets); - skipped += 4; - read_uint32be(fd,&next_data_off); - skipped += 4; - if (!rmctx->nb_packets && (rmctx->flags & 4)) - rmctx->nb_packets = 3600 * 25; - - /*** - * nb_packets correction : - * in some samples, number of packets may not exactly form - * an integer number of scrambling units. This is corrected - * by constructing a partially filled unit out of the few - * remaining samples at the end of decoding. - ***/ - if(rmctx->nb_packets % rmctx->sub_packet_h) - rmctx->nb_packets += rmctx->sub_packet_h - (rmctx->nb_packets % rmctx->sub_packet_h); - - DEBUGF(" data_nb_packets = %d\n",rmctx->nb_packets); - DEBUGF(" next DATA offset = %d\n",next_data_off); - header_end = 1; - break; - } - if(header_end) break; - curpos = lseek(fd, obj.size - skipped, SEEK_CUR); - res = real_read_object_header(fd, &obj); - } - - - return 0; -} - -void rm_get_packet_fd(int fd,RMContext *rmctx, RMPacket *pkt) -{ - uint8_t unknown,packet_group; - uint16_t x; - uint16_t sps = rmctx->sub_packet_size; - uint16_t h = rmctx->sub_packet_h; - uint16_t y = rmctx->sub_packet_cnt; - uint16_t w = rmctx->audio_framesize; - int res; - do - { - y = rmctx->sub_packet_cnt; - read_uint16be(fd,&pkt->version); - read_uint16be(fd,&pkt->length); - read_uint16be(fd,&pkt->stream_number); - read_uint32be(fd,&pkt->timestamp); - DEBUGF(" version = %d\n" - " length = %d\n" - " stream = %d\n" - " timestmp= %d\n",pkt->version,pkt->length,pkt->stream_number,pkt->timestamp); - - if(pkt->version == 0) - { - read_uint8(fd,&packet_group); - read_uint8(fd,&pkt->flags); - } - if(pkt->version == 1) - read_uint8(fd,&unknown); - - if (pkt->flags & 2) /* keyframe */ - y = rmctx->sub_packet_cnt = 0; - if (!y) /* if keyframe update playback elapsed time */ - rmctx->audiotimestamp = pkt->timestamp; - - for(x = 0 ; x < w/sps; x++) - { - res = read(fd,pkt->data+(sps*(h*x+((h+1)/2)*(y&1)+(y>>1))), sps); - } - rmctx->audio_pkt_cnt++; - }while(++(rmctx->sub_packet_cnt) < h); - -} -#endif /*TEST*/ - -int rm_get_packet(uint8_t **src,RMContext *rmctx, RMPacket *pkt) -{ - int consumed = 0; - /* rockbox: comment 'set but unused' variables - uint8_t unknown; - */ - uint16_t x, place; - uint16_t sps = rmctx->sub_packet_size; - uint16_t h = rmctx->sub_packet_h; - uint16_t y = rmctx->sub_packet_cnt; - uint16_t w = rmctx->audio_framesize; - do - { - y = rmctx->sub_packet_cnt; - pkt->version = rm_get_uint16be(*src); - - /* Simple error checking */ - if(pkt->version != 0 && pkt->version != 1) - { - DEBUGF("parsing packets failed\n"); - return -1; - } - - pkt->length = rm_get_uint16be(*src+2); - pkt->stream_number = rm_get_uint16be(*src+4); - pkt->timestamp = rm_get_uint32be(*src+6); - /*DEBUGF(" version = %d\n" - " length = %d\n" - " stream = %d\n" - " timestamp= %d\n\n",pkt->version,pkt->length,pkt->stream_number,pkt->timestamp);*/ - /* unknown =*/ rm_get_uint8(*src+10); - pkt->flags = rm_get_uint8(*src+11); - - if(pkt->version == 1) - /* unknown = */ rm_get_uint8(*src+10); - - if (pkt->flags & 2) /* keyframe */ - y = rmctx->sub_packet_cnt = 0; - if (!y) - rmctx->audiotimestamp = pkt->timestamp; - - /* Skip packet header */ - advance_buffer(src, PACKET_HEADER_SIZE); - consumed += PACKET_HEADER_SIZE; - if (rmctx->codec_type == CODEC_COOK || rmctx->codec_type == CODEC_ATRAC) { - for(x = 0 ; x < w/sps; x++) - { - place = sps*(h*x+((h+1)/2)*(y&1)+(y>>1)); - pkt->frames[place/sps] = *src; - advance_buffer(src,sps); - consumed += sps; - } - } - else if (rmctx->codec_type == CODEC_AAC) { - rmctx->sub_packet_cnt = (rm_get_uint16be(*src) & 0xf0) >> 4; - advance_buffer(src, 2); - consumed += 2; - if (rmctx->sub_packet_cnt) { - for(x = 0; x < rmctx->sub_packet_cnt; x++) { - rmctx->sub_packet_lengths[x] = rm_get_uint16be(*src); - advance_buffer(src, 2); - consumed += 2; - } - rmctx->audio_pkt_cnt = --rmctx->sub_packet_cnt; - } - } - - else if (rmctx->codec_type == CODEC_AC3) { - /* The byte order of the data is reversed from standard AC3 */ - for(x = 0; x < pkt->length - PACKET_HEADER_SIZE; x+=2) { - SWAP((*src)[0], (*src)[1]); - *src += 2; - } - *src -= x; - } - rmctx->audio_pkt_cnt++; - }while(++(rmctx->sub_packet_cnt) < h); - -return consumed; -} - -#ifdef DEBUG -void dump_rm_context(RMContext *rmctx) -{ - DEBUGF("block_align = %d\n", rmctx->block_align); - DEBUGF("nb_channels = %d\n", rmctx->nb_channels); - DEBUGF("sample_rate = %d\n", rmctx->sample_rate); - DEBUGF("bit_rate = %d\n", rmctx->bit_rate ); -} -#endif diff --git a/apps/codecs/librm/rm.h b/apps/codecs/librm/rm.h deleted file mode 100644 index c4a4e3a77e..0000000000 --- a/apps/codecs/librm/rm.h +++ /dev/null @@ -1,102 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2009 Mohamed Tarek - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ -#ifndef _RM_H -#define _RM_H - -#include -#include -#include "bytestream.h" - -#define MAX_EXTRADATA_SIZE 16 -#define DATA_HEADER_SIZE 18 -#define PACKET_HEADER_SIZE 12 - -enum codecs { - CODEC_COOK, - CODEC_AAC, - CODEC_AC3, - CODEC_ATRAC -}; - -typedef struct rm_packet -{ - uint8_t *frames[100]; /* Pointers to ordered audio frames in buffer */ - uint16_t version; - uint16_t length; - uint32_t timestamp; - uint16_t stream_number; - uint8_t flags; - -#ifdef TEST - uint8_t data[30000]; /* Reordered data. No malloc, hence the size */ -#endif -}RMPacket; - -typedef struct rm_context -{ - /* Demux Context */ - int old_format; - int current_stream; - int remaining_len; - int audio_stream_num; /*< Stream number for audio packets*/ - int audio_pkt_cnt; /* Output packet counter*/ - - /* Stream Variables */ - uint32_t data_offset; - uint32_t duration; - uint32_t audiotimestamp; /* Audio packet timestamp*/ - uint16_t sub_packet_cnt; /* Subpacket counter, used while reading */ - uint16_t sub_packet_size, sub_packet_h, coded_framesize; /* Descrambling parameters from container */ - uint16_t audio_framesize; /* Audio frame size from container */ - uint16_t sub_packet_lengths[16]; /* Length of each subpacket */ - - /* Codec Context */ - enum codecs codec_type; - uint16_t block_align; - uint32_t nb_packets; - int frame_number; - uint16_t sample_rate; - uint16_t nb_channels; - uint32_t bit_rate; - uint16_t flags; - - /*codec extradata*/ - uint32_t extradata_size; - uint8_t codec_extradata[MAX_EXTRADATA_SIZE]; - -} RMContext; - -int real_parse_header(int fd, RMContext *rmctx); - -/* Get a (sub_packet_h*frames_per_packet) number of audio frames from a memory buffer */ -int rm_get_packet(uint8_t **src,RMContext *rmctx, RMPacket *pkt); - -#ifdef TEST - -int filesize(int fd); -void advance_buffer(uint8_t **buf, int val); - -/* Get a (sub_packet_h*frames_per_packet) number of audio frames from a file descriptor */ -void rm_get_packet_fd(int fd,RMContext *rmctx, RMPacket *pkt); - -#endif /* TEST */ - -#endif /* _RM_H */ diff --git a/apps/codecs/libspc/SOURCES b/apps/codecs/libspc/SOURCES deleted file mode 100644 index 901232a6eb..0000000000 --- a/apps/codecs/libspc/SOURCES +++ /dev/null @@ -1,4 +0,0 @@ -spc_cpu.c -spc_dsp.c -spc_emu.c -spc_profiler.c diff --git a/apps/codecs/libspc/libspc.make b/apps/codecs/libspc/libspc.make deleted file mode 100644 index 8cf04dc5c8..0000000000 --- a/apps/codecs/libspc/libspc.make +++ /dev/null @@ -1,18 +0,0 @@ -# __________ __ ___. -# Open \______ \ ____ ____ | | _\_ |__ _______ ___ -# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / -# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < -# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ -# \/ \/ \/ \/ \/ -# $Id$ -# - -# libspc -SPCLIB := $(CODECDIR)/libspc.a -SPCLIB_SRC := $(call preprocess, $(APPSDIR)/codecs/libspc/SOURCES) -SPCLIB_OBJ := $(call c2obj, $(SPCLIB_SRC)) -OTHER_SRC += $(SPCLIB_SRC) - -$(SPCLIB): $(SPCLIB_OBJ) - $(SILENT)$(shell rm -f $@) - $(call PRINTS,AR $(@F))$(AR) rcs $@ $^ >/dev/null diff --git a/apps/codecs/libspc/spc_codec.h b/apps/codecs/libspc/spc_codec.h deleted file mode 100644 index 7f6b6e2e9f..0000000000 --- a/apps/codecs/libspc/spc_codec.h +++ /dev/null @@ -1,491 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2007-2008 Michael Sevakis (jhMikeS) - * Copyright (C) 2006-2007 Adam Gashlin (hcs) - * Copyright (C) 2004-2007 Shay Green (blargg) - * Copyright (C) 2002 Brad Martin - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ - -/* lovingly ripped off from Game_Music_Emu 0.5.2. http://www.slack.net/~ant/ */ -/* DSP Based on Brad Martin's OpenSPC DSP emulator */ -/* tag reading from sexyspc by John Brawn (John_Brawn@yahoo.com) and others */ - -#ifndef _SPC_CODEC_H_ -#define _SPC_CODEC_H_ - -/* rather than comment out asserts, just define NDEBUG */ -#ifndef NDEBUG -#define NDEBUG -#endif -#include - -/** Basic configuration options **/ - -#ifndef ARM_ARCH -#define ARM_ARCH 0 -#endif - -#define SPC_DUAL_CORE 1 - -#if !defined(SPC_DUAL_CORE) || NUM_CORES == 1 -#undef SPC_DUAL_CORE -#define SPC_DUAL_CORE 0 -#endif - -/* Only some targets are fast enough for gaussian and realtime BRR decode */ -#if CONFIG_CPU == S3C2440 || CONFIG_CPU == IMX31L || \ - CONFIG_CPU == AS3525 || CONFIG_CPU == AS3525v2 || \ - defined(CPU_S5L870X) || \ - (CONFIG_PLATFORM & PLATFORM_HOSTED) || MEMORYSIZE <= 2 - /* Don't cache BRR waves */ - #define SPC_BRRCACHE 0 - - /* Allow gaussian interpolation */ - #define SPC_NOINTERP 0 - - /* Allow echo processing */ - #define SPC_NOECHO 0 -#elif defined(CPU_COLDFIRE) - /* Cache BRR waves */ - #define SPC_BRRCACHE 1 - - /* Disable gaussian interpolation */ - #define SPC_NOINTERP 1 - - /* Allow echo processing */ - #define SPC_NOECHO 0 -#elif defined (CPU_PP) && SPC_DUAL_CORE - /* Cache BRR waves */ - #define SPC_BRRCACHE 1 - - /* Disable gaussian interpolation */ - #define SPC_NOINTERP 1 - - /* Allow echo processing */ - #define SPC_NOECHO 0 -#else - /* Cache BRR waves */ - #define SPC_BRRCACHE 1 - - /* Disable gaussian interpolation */ - #define SPC_NOINTERP 1 - - /* Disable echo processing */ - #define SPC_NOECHO 1 -#endif - -#if (CONFIG_CPU == MCF5250) -#define IBSS_ATTR_SPC IBSS_ATTR -#define ICODE_ATTR_SPC ICODE_ATTR -#define ICONST_ATTR_SPC ICONST_ATTR -/* Not enough IRAM available to move further data to it. */ -#define IBSS_ATTR_SPC_LARGE_IRAM - -#elif (CONFIG_CPU == PP5020) -/* spc is slower on PP5020 when moving data to IRAM. */ -#define IBSS_ATTR_SPC -#define ICODE_ATTR_SPC -#define ICONST_ATTR_SPC -/* Not enough IRAM available to move further data to it. */ -#define IBSS_ATTR_SPC_LARGE_IRAM - -#elif (CONFIG_CPU == PP5022) || (CONFIG_CPU == PP5024) -#define IBSS_ATTR_SPC IBSS_ATTR -#define ICODE_ATTR_SPC ICODE_ATTR -#define ICONST_ATTR_SPC ICONST_ATTR -/* Not enough IRAM available to move further data to it. */ -#define IBSS_ATTR_SPC_LARGE_IRAM - -#elif defined(CPU_S5L870X) -#define IBSS_ATTR_SPC IBSS_ATTR -#define ICODE_ATTR_SPC ICODE_ATTR -#define ICONST_ATTR_SPC ICONST_ATTR -/* Very large IRAM. Move even more data to it. */ -#define IBSS_ATTR_SPC_LARGE_IRAM IBSS_ATTR - -#else -#define IBSS_ATTR_SPC IBSS_ATTR -#define ICODE_ATTR_SPC ICODE_ATTR -#define ICONST_ATTR_SPC ICONST_ATTR -/* Not enough IRAM available to move further data to it. */ -#define IBSS_ATTR_SPC_LARGE_IRAM -#endif - -#if SPC_DUAL_CORE - #undef SHAREDBSS_ATTR - #define SHAREDBSS_ATTR __attribute__ ((section(".ibss"))) - #undef SHAREDDATA_ATTR - #define SHAREDDATA_ATTR __attribute__((section(".idata"))) -#endif - -/* Samples per channel per iteration */ -#if defined(CPU_PP) && NUM_CORES == 1 -#define WAV_CHUNK_SIZE 2048 -#else -#define WAV_CHUNK_SIZE 1024 -#endif - -/**************** Little-endian handling ****************/ - -static inline unsigned get_le16( void const* p ) -{ - return ((unsigned char const*) p) [1] * 0x100u + - ((unsigned char const*) p) [0]; -} - -static inline int get_le16s( void const* p ) -{ - return ((signed char const*) p) [1] * 0x100 + - ((unsigned char const*) p) [0]; -} - -static inline void set_le16( void* p, unsigned n ) -{ - ((unsigned char*) p) [1] = (unsigned char) (n >> 8); - ((unsigned char*) p) [0] = (unsigned char) n; -} - -#define GET_LE16( addr ) get_le16( addr ) -#define GET_LE16A( addr ) get_le16( addr ) -#define SET_LE16( addr, data ) set_le16( addr, data ) -#define INT16A( addr ) (*(uint16_t*) (addr)) -#define INT16SA( addr ) (*(int16_t*) (addr)) - -#ifdef ROCKBOX_LITTLE_ENDIAN - #define GET_LE16SA( addr ) (*( int16_t*) (addr)) - #define SET_LE16A( addr, data ) (void) (*(uint16_t*) (addr) = (data)) -#else - #define GET_LE16SA( addr ) get_le16s( addr ) - #define SET_LE16A( addr, data ) set_le16 ( addr, data ) -#endif - -struct Spc_Emu; -#define THIS struct Spc_Emu* const this - -/* The CPU portion (shock!) */ - -struct cpu_regs_t -{ - long pc; /* more than 16 bits to allow overflow detection */ - uint8_t a; - uint8_t x; - uint8_t y; - uint8_t status; - uint8_t sp; -}; - -struct src_dir -{ - uint16_t start; - uint16_t loop; -}; - -struct cpu_ram_t -{ - union { - uint8_t padding1 [0x100]; - uint16_t align; - } padding1 [1]; - union { - uint8_t ram [0x10000]; - struct src_dir sd [0x10000/sizeof(struct src_dir)]; - }; - uint8_t padding2 [0x100]; -}; - -#undef RAM -#define RAM ram.ram -extern struct cpu_ram_t ram; - -long CPU_run( THIS, long start_time ) ICODE_ATTR_SPC; -void CPU_Init( THIS ); - -/* The DSP portion (awe!) */ -enum { VOICE_COUNT = 8 }; -enum { REGISTER_COUNT = 128 }; - -struct raw_voice_t -{ - int8_t volume [2]; - uint8_t rate [2]; - uint8_t waveform; - uint8_t adsr [2]; /* envelope rates for attack, decay, and sustain */ - uint8_t gain; /* envelope gain (if not using ADSR) */ - int8_t envx; /* current envelope level */ - int8_t outx; /* current sample */ - int8_t unused [6]; -}; - -struct globals_t -{ - int8_t unused1 [12]; - int8_t volume_0; /* 0C Main Volume Left (-.7) */ - int8_t echo_feedback; /* 0D Echo Feedback (-.7) */ - int8_t unused2 [14]; - int8_t volume_1; /* 1C Main Volume Right (-.7) */ - int8_t unused3 [15]; - int8_t echo_volume_0; /* 2C Echo Volume Left (-.7) */ - uint8_t pitch_mods; /* 2D Pitch Modulation on/off for each voice */ - int8_t unused4 [14]; - int8_t echo_volume_1; /* 3C Echo Volume Right (-.7) */ - uint8_t noise_enables; /* 3D Noise output on/off for each voice */ - int8_t unused5 [14]; - uint8_t key_ons; /* 4C Key On for each voice */ - uint8_t echo_ons; /* 4D Echo on/off for each voice */ - int8_t unused6 [14]; - uint8_t key_offs; /* 5C key off for each voice - (instantiates release mode) */ - uint8_t wave_page; /* 5D source directory (wave table offsets) */ - int8_t unused7 [14]; - uint8_t flags; /* 6C flags and noise freq */ - uint8_t echo_page; /* 6D */ - int8_t unused8 [14]; - uint8_t wave_ended; /* 7C */ - uint8_t echo_delay; /* 7D ms >> 4 */ - char unused9 [2]; -}; - -enum state_t -{ /* -1, 0, +1 allows more efficient if statements */ - state_decay = -1, - state_sustain = 0, - state_attack = +1, - state_release = 2 -}; - -struct cache_entry_t -{ - int16_t const* samples; - unsigned end; /* past-the-end position */ - unsigned loop; /* number of samples in loop */ - unsigned start_addr; -}; - -enum { BRR_BLOCK_SIZE = 16 }; -enum { BRR_CACHE_SIZE = 0x20000 + 32} ; - -struct voice_t -{ -#if SPC_BRRCACHE - int16_t const* samples; - long wave_end; - int wave_loop; -#else - int16_t samples [3 + BRR_BLOCK_SIZE + 1]; - int block_header; /* header byte from current block */ -#endif - uint8_t const* addr; - short volume [2]; - long position;/* position in samples buffer, with 12-bit fraction */ - short envx; - short env_mode; - short env_timer; - short key_on_delay; -}; - -#if SPC_BRRCACHE -/* a little extra for samples that go past end */ -extern int16_t BRRcache [BRR_CACHE_SIZE]; -#endif - -enum { FIR_BUF_HALF = 8 }; - -#if defined(CPU_COLDFIRE) -/* global because of the large aligment requirement for hardware masking - - * L-R interleaved 16-bit samples for easy loading and mac.w use. - */ -enum -{ - FIR_BUF_CNT = FIR_BUF_HALF, - FIR_BUF_SIZE = FIR_BUF_CNT * sizeof ( int32_t ), - FIR_BUF_ALIGN = FIR_BUF_SIZE * 2, - FIR_BUF_MASK = ~((FIR_BUF_ALIGN / 2) | (sizeof ( int32_t ) - 1)) -}; -#elif defined (CPU_ARM) -#if ARM_ARCH >= 6 -enum -{ - FIR_BUF_CNT = FIR_BUF_HALF * 2, - FIR_BUF_SIZE = FIR_BUF_CNT * sizeof ( int32_t ), - FIR_BUF_ALIGN = FIR_BUF_SIZE, - FIR_BUF_MASK = ~((FIR_BUF_ALIGN / 2) | (sizeof ( int32_t ) - 1)) -}; -#else -enum -{ - FIR_BUF_CNT = FIR_BUF_HALF * 2 * 2, - FIR_BUF_SIZE = FIR_BUF_CNT * sizeof ( int32_t ), - FIR_BUF_ALIGN = FIR_BUF_SIZE, - FIR_BUF_MASK = ~((FIR_BUF_ALIGN / 2) | (sizeof ( int32_t ) * 2 - 1)) -}; -#endif /* ARM_ARCH */ -#endif /* CPU_* */ - -struct Spc_Dsp -{ - union - { - struct raw_voice_t voice [VOICE_COUNT]; - uint8_t reg [REGISTER_COUNT]; - struct globals_t g; - int16_t align; - } r; - - unsigned echo_pos; - int keys_down; - int noise_count; - uint16_t noise; /* also read as int16_t */ - -#if defined(CPU_COLDFIRE) - /* FIR history is interleaved. Hardware handles wrapping by mask. - * |LR|LR|LR|LR|LR|LR|LR|LR| */ - int32_t *fir_ptr; - /* wrapped address just behind current position - - allows mac.w to increment and mask fir_ptr */ - int32_t *last_fir_ptr; - /* copy of echo FIR constants as int16_t for use with mac.w */ - int16_t fir_coeff [VOICE_COUNT]; -#elif defined (CPU_ARM) - /* fir_buf [i + 8] == fir_buf [i], to avoid wrap checking in FIR code */ - int32_t *fir_ptr; -#if ARM_ARCH >= 6 - /* FIR history is interleaved with guard to eliminate wrap checking - * when convolving. - * |LR|LR|LR|LR|LR|LR|LR|LR|--|--|--|--|--|--|--|--| */ - /* copy of echo FIR constants as int16_t, loaded as int32 for - * halfword, packed multiples */ - int16_t fir_coeff [VOICE_COUNT]; -#else - /* FIR history is interleaved with guard to eliminate wrap checking - * when convolving. - * |LL|RR|LL|RR|LL|RR|LL|RR|LL|RR|LL|RR|LL|RR|LL|RR|... - * |--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--| */ - /* copy of echo FIR constants as int32_t, for faster access */ - int32_t fir_coeff [VOICE_COUNT]; -#endif /* ARM_ARCH */ -#else /* Unoptimized CPU */ - /* fir_buf [i + 8] == fir_buf [i], to avoid wrap checking in FIR code */ - int fir_pos; /* (0 to 7) */ - int fir_buf [FIR_BUF_HALF * 2] [2]; - /* copy of echo FIR constants as int, for faster access */ - int fir_coeff [VOICE_COUNT]; -#endif - - struct voice_t voice_state [VOICE_COUNT]; - -#if SPC_BRRCACHE - uint8_t oldsize; - struct cache_entry_t wave_entry [256]; - struct cache_entry_t wave_entry_old [256]; -#endif -}; - -void DSP_run_( struct Spc_Dsp* this, long count, int32_t* out_buf ) ICODE_ATTR_SPC; -void DSP_reset( struct Spc_Dsp* this ); - -static inline void DSP_run( struct Spc_Dsp* this, long count, int32_t* out ) -{ - /* Should we just fill the buffer with silence? Flags won't be cleared */ - /* during this run so it seems it should keep resetting every sample. */ - if ( this->r.g.flags & 0x80 ) - DSP_reset( this ); - - DSP_run_( this, count, out ); -} - -/**************** SPC emulator ****************/ -/* 1.024 MHz clock / 32000 samples per second */ -enum { CLOCKS_PER_SAMPLE = 32 }; - -enum { EXTRA_CLOCKS = CLOCKS_PER_SAMPLE / 2 }; - -/* using this disables timer (since this will always be in the future) */ -enum { TIMER_DISABLED_TIME = 127 }; - -enum { ROM_SIZE = 64 }; -enum { ROM_ADDR = 0xFFC0 }; - -enum { TIMER_COUNT = 3 }; - -struct Timer -{ - long next_tick; - int period; - int count; - int shift; - int enabled; - int counter; -}; - -struct Spc_Emu -{ - uint8_t cycle_table [0x100]; - struct cpu_regs_t r; - - int32_t* sample_buf; - long next_dsp; - int rom_enabled; - int extra_cycles; - - struct Timer timer [TIMER_COUNT]; - - /* large objects at end */ - struct Spc_Dsp dsp; - uint8_t extra_ram [ROM_SIZE]; - uint8_t boot_rom [ROM_SIZE]; -}; - -enum { SPC_FILE_SIZE = 0x10180 }; - -struct spc_file_t -{ - char signature [27]; - char unused [10]; - uint8_t pc [2]; - uint8_t a; - uint8_t x; - uint8_t y; - uint8_t status; - uint8_t sp; - char unused2 [212]; - uint8_t ram [0x10000]; - uint8_t dsp [128]; - uint8_t ipl_rom [128]; -}; - -void SPC_Init( THIS ); - -int SPC_load_spc( THIS, const void* data, long size ); - -/**************** DSP interaction ****************/ -void DSP_write( struct Spc_Dsp* this, int i, int data ) ICODE_ATTR_SPC; - -static inline int DSP_read( struct Spc_Dsp* this, int i ) -{ - assert( (unsigned) i < REGISTER_COUNT ); - return this->r.reg [i]; -} - -int SPC_read( THIS, unsigned addr, long const time ) ICODE_ATTR_SPC; -void SPC_write( THIS, unsigned addr, int data, long const time ) ICODE_ATTR_SPC; - -/**************** Sample generation ****************/ -int SPC_play( THIS, long count, int32_t* out ) ICODE_ATTR_SPC; - -#endif /* _SPC_CODEC_H_ */ diff --git a/apps/codecs/libspc/spc_cpu.c b/apps/codecs/libspc/spc_cpu.c deleted file mode 100644 index 23dcc257de..0000000000 --- a/apps/codecs/libspc/spc_cpu.c +++ /dev/null @@ -1,1049 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2006-2007 Adam Gashlin (hcs) - * Copyright (C) 2004-2007 Shay Green (blargg) - * Copyright (C) 2002 Brad Martin - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ - -/* The CPU portion (shock!) */ -#include "codeclib.h" -#include "spc_codec.h" -#include "spc_profiler.h" - -#undef check -#define check assert - -#define READ( addr ) (SPC_read( this, addr, spc_time_ )) -#define WRITE( addr, value ) (SPC_write( this, addr, value, spc_time_ )) - -#define READ_DP( addr ) READ( (addr) + dp ) -#define WRITE_DP( addr, value ) WRITE( (addr) + dp, value ) - -#define READ_PROG16( addr ) GET_LE16( RAM + (addr) ) - -#define READ_PC( pc ) (*(pc)) -#define READ_PC16( pc ) GET_LE16( pc ) - -#define SET_PC( n ) (pc = RAM + (n)) -#define GET_PC() (pc - RAM) - -static unsigned char const cycle_table [0x100] = { - 2,8,4,5,3,4,3,6,2,6,5,4,5,4,6,8, /* 0 */ - 2,8,4,5,4,5,5,6,5,5,6,5,2,2,4,6, /* 1 */ - 2,8,4,5,3,4,3,6,2,6,5,4,5,4,5,4, /* 2 */ - 2,8,4,5,4,5,5,6,5,5,6,5,2,2,3,8, /* 3 */ - 2,8,4,5,3,4,3,6,2,6,4,4,5,4,6,6, /* 4 */ - 2,8,4,5,4,5,5,6,5,5,4,5,2,2,4,3, /* 5 */ - 2,8,4,5,3,4,3,6,2,6,4,4,5,4,5,5, /* 6 */ - 2,8,4,5,4,5,5,6,5,5,5,5,2,2,3,6, /* 7 */ - 2,8,4,5,3,4,3,6,2,6,5,4,5,2,4,5, /* 8 */ - 2,8,4,5,4,5,5,6,5,5,5,5,2,2,12,5,/* 9 */ - 3,8,4,5,3,4,3,6,2,6,4,4,5,2,4,4, /* A */ - 2,8,4,5,4,5,5,6,5,5,5,5,2,2,3,4, /* B */ - 3,8,4,5,4,5,4,7,2,5,6,4,5,2,4,9, /* C */ - 2,8,4,5,5,6,6,7,4,5,4,5,2,2,6,3, /* D */ - 2,8,4,5,3,4,3,6,2,4,5,3,4,3,4,3, /* E */ - 2,8,4,5,4,5,5,6,3,4,5,4,2,2,4,3 /* F */ -}; - -#define MEM_BIT() CPU_mem_bit( this, pc, spc_time_ ) - -static unsigned CPU_mem_bit( THIS, uint8_t const* pc, long const spc_time_ ) - ICODE_ATTR_SPC; - -static unsigned CPU_mem_bit( THIS, uint8_t const* pc, long const spc_time_ ) -{ - unsigned addr = READ_PC16( pc ); - unsigned t = READ( addr & 0x1FFF ) >> (addr >> 13); - return (t << 8) & 0x100; -} - -/* status flags */ -enum { st_n = 0x80 }; -enum { st_v = 0x40 }; -enum { st_p = 0x20 }; -enum { st_b = 0x10 }; -enum { st_h = 0x08 }; -enum { st_i = 0x04 }; -enum { st_z = 0x02 }; -enum { st_c = 0x01 }; - -#define IS_NEG (nz & 0x880) - -#define CALC_STATUS( out )\ -{\ - out = status & ~(st_n | st_z | st_c);\ - out |= (c >> 8) & st_c;\ - out |= (dp >> 3) & st_p;\ - if ( IS_NEG ) out |= st_n;\ - if ( !(nz & 0xFF) ) out |= st_z;\ -} - -#define SET_STATUS( in )\ -{\ - status = in & ~(st_n | st_z | st_c | st_p);\ - c = in << 8;\ - nz = ((in << 4) & 0x800) | (~in & st_z);\ - dp = (in << 3) & 0x100;\ -} - - -/* stack */ -#define PUSH( v ) (*--sp = (uint8_t) (v)) -#define PUSH16( v ) (sp -= 2, SET_LE16( sp, v )) -#define POP() (*sp++) -#define SET_SP( v ) (sp = RAM + 0x101 + (v)) -#define GET_SP() (sp - 0x101 - RAM) - -long CPU_run( THIS, long start_time ) -{ -#if 0 - ENTER_TIMER(cpu); -#endif - - register long spc_time_ = start_time; - -#ifdef CPU_ARM - uint8_t* const ram_ = ram.ram; - #undef RAM - #define RAM ram_ -#endif - - int a = this->r.a; - int x = this->r.x; - int y = this->r.y; - - uint8_t const* pc; - SET_PC( this->r.pc ); - - uint8_t* sp; - SET_SP( this->r.sp ); - - int status; - int c; - int nz; - unsigned dp; - { - int temp = this->r.status; - SET_STATUS( temp ); - } - - goto loop; - - /* main loop */ -cbranch_taken_loop: - pc += *(int8_t const*) pc; - spc_time_ += 2; -inc_pc_loop: - pc++; -loop: - check( (unsigned) GET_PC() < 0x10000 ); - check( (unsigned) GET_SP() < 0x100 ); - check( (unsigned) a < 0x100 ); - check( (unsigned) x < 0x100 ); - check( (unsigned) y < 0x100 ); - - unsigned opcode = *pc; - int cycles = this->cycle_table [opcode]; - unsigned data = *++pc; - if ( (spc_time_ += cycles) > 0 ) - goto out_of_time; - switch ( opcode ) - { - -/* Common instructions */ - -#define BRANCH( cond )\ -{\ - pc++;\ - int offset = (int8_t) data;\ - if ( cond ) {\ - pc += offset;\ - spc_time_ += 2;\ - }\ - goto loop;\ -} - - case 0xF0: /* BEQ (most common) */ - BRANCH( !(uint8_t) nz ) - - case 0xD0: /* BNE */ - BRANCH( (uint8_t) nz ) - - case 0x3F: /* CALL */ - PUSH16( GET_PC() + 2 ); - SET_PC( READ_PC16( pc ) ); - goto loop; - - case 0x6F: /* RET */ - SET_PC( POP() ); - pc += POP() * 0x100; - goto loop; - -#define CASE( n ) case n: - -/* Define common address modes based on opcode for immediate mode. Execution - ends with data set to the address of the operand. */ -#define ADDR_MODES( op )\ - CASE( op - 0x02 ) /* (X) */\ - data = x + dp;\ - pc--;\ - goto end_##op;\ - CASE( op + 0x0F ) /* (dp)+Y */\ - data = READ_PROG16( data + dp ) + y;\ - goto end_##op;\ - CASE( op - 0x01 ) /* (dp+X) */\ - data = READ_PROG16( ((uint8_t) (data + x)) + dp );\ - goto end_##op;\ - CASE( op + 0x0E ) /* abs+Y */\ - data += y;\ - goto abs_##op;\ - CASE( op + 0x0D ) /* abs+X */\ - data += x;\ - CASE( op - 0x03 ) /* abs */\ - abs_##op:\ - data += 0x100 * READ_PC( ++pc );\ - goto end_##op;\ - CASE( op + 0x0C ) /* dp+X */\ - data = (uint8_t) (data + x);\ - CASE( op - 0x04 ) /* dp */\ - data += dp;\ - end_##op: - -/* 1. 8-bit Data Transmission Commands. Group I */ - - ADDR_MODES( 0xE8 ) /* MOV A,addr */ - /*case 0xE4:*/ /* MOV a,dp (most common) */ - mov_a_addr: - a = nz = READ( data ); - goto inc_pc_loop; - case 0xBF: /* MOV A,(X)+ */ - data = x + dp; - x = (uint8_t) (x + 1); - pc--; - goto mov_a_addr; - - case 0xE8: /* MOV A,imm */ - a = data; - nz = data; - goto inc_pc_loop; - - case 0xF9: /* MOV X,dp+Y */ - data = (uint8_t) (data + y); - case 0xF8: /* MOV X,dp */ - data += dp; - goto mov_x_addr; - case 0xE9: /* MOV X,abs */ - data = READ_PC16( pc ); - pc++; - mov_x_addr: - data = READ( data ); - case 0xCD: /* MOV X,imm */ - x = data; - nz = data; - goto inc_pc_loop; - - case 0xFB: /* MOV Y,dp+X */ - data = (uint8_t) (data + x); - case 0xEB: /* MOV Y,dp */ - data += dp; - goto mov_y_addr; - case 0xEC: /* MOV Y,abs */ - data = READ_PC16( pc ); - pc++; - mov_y_addr: - data = READ( data ); - case 0x8D: /* MOV Y,imm */ - y = data; - nz = data; - goto inc_pc_loop; - -/* 2. 8-BIT DATA TRANSMISSION COMMANDS, GROUP 2 */ - - ADDR_MODES( 0xC8 ) /* MOV addr,A */ - WRITE( data, a ); - goto inc_pc_loop; - - { - int temp; - case 0xCC: /* MOV abs,Y */ - temp = y; - goto mov_abs_temp; - case 0xC9: /* MOV abs,X */ - temp = x; - mov_abs_temp: - WRITE( READ_PC16( pc ), temp ); - pc += 2; - goto loop; - } - - case 0xD9: /* MOV dp+Y,X */ - data = (uint8_t) (data + y); - case 0xD8: /* MOV dp,X */ - WRITE( data + dp, x ); - goto inc_pc_loop; - - case 0xDB: /* MOV dp+X,Y */ - data = (uint8_t) (data + x); - case 0xCB: /* MOV dp,Y */ - WRITE( data + dp, y ); - goto inc_pc_loop; - - case 0xFA: /* MOV dp,dp */ - data = READ( data + dp ); - case 0x8F: /* MOV dp,#imm */ - WRITE_DP( READ_PC( ++pc ), data ); - goto inc_pc_loop; - -/* 3. 8-BIT DATA TRANSMISSIN COMMANDS, GROUP 3. */ - - case 0x7D: /* MOV A,X */ - a = x; - nz = x; - goto loop; - - case 0xDD: /* MOV A,Y */ - a = y; - nz = y; - goto loop; - - case 0x5D: /* MOV X,A */ - x = a; - nz = a; - goto loop; - - case 0xFD: /* MOV Y,A */ - y = a; - nz = a; - goto loop; - - case 0x9D: /* MOV X,SP */ - x = nz = GET_SP(); - goto loop; - - case 0xBD: /* MOV SP,X */ - SET_SP( x ); - goto loop; - - /*case 0xC6:*/ /* MOV (X),A (handled by MOV addr,A in group 2) */ - - case 0xAF: /* MOV (X)+,A */ - WRITE_DP( x, a ); - x++; - goto loop; - -/* 5. 8-BIT LOGIC OPERATION COMMANDS */ - -#define LOGICAL_OP( op, func )\ - ADDR_MODES( op ) /* addr */\ - data = READ( data );\ - case op: /* imm */\ - nz = a func##= data;\ - goto inc_pc_loop;\ - { unsigned addr;\ - case op + 0x11: /* X,Y */\ - data = READ_DP( y );\ - addr = x + dp;\ - pc--;\ - goto addr_##op;\ - case op + 0x01: /* dp,dp */\ - data = READ_DP( data );\ - case op + 0x10: /*dp,imm*/\ - addr = READ_PC( ++pc ) + dp;\ - addr_##op:\ - nz = data func READ( addr );\ - WRITE( addr, nz );\ - goto inc_pc_loop;\ - } - - LOGICAL_OP( 0x28, & ); /* AND */ - - LOGICAL_OP( 0x08, | ); /* OR */ - - LOGICAL_OP( 0x48, ^ ); /* EOR */ - -/* 4. 8-BIT ARITHMETIC OPERATION COMMANDS */ - - ADDR_MODES( 0x68 ) /* CMP addr */ - data = READ( data ); - case 0x68: /* CMP imm */ - nz = a - data; - c = ~nz; - nz &= 0xFF; - goto inc_pc_loop; - - case 0x79: /* CMP (X),(Y) */ - data = READ_DP( x ); - nz = data - READ_DP( y ); - c = ~nz; - nz &= 0xFF; - goto loop; - - case 0x69: /* CMP (dp),(dp) */ - data = READ_DP( data ); - case 0x78: /* CMP dp,imm */ - nz = READ_DP( READ_PC( ++pc ) ) - data; - c = ~nz; - nz &= 0xFF; - goto inc_pc_loop; - - case 0x3E: /* CMP X,dp */ - data += dp; - goto cmp_x_addr; - case 0x1E: /* CMP X,abs */ - data = READ_PC16( pc ); - pc++; - cmp_x_addr: - data = READ( data ); - case 0xC8: /* CMP X,imm */ - nz = x - data; - c = ~nz; - nz &= 0xFF; - goto inc_pc_loop; - - case 0x7E: /* CMP Y,dp */ - data += dp; - goto cmp_y_addr; - case 0x5E: /* CMP Y,abs */ - data = READ_PC16( pc ); - pc++; - cmp_y_addr: - data = READ( data ); - case 0xAD: /* CMP Y,imm */ - nz = y - data; - c = ~nz; - nz &= 0xFF; - goto inc_pc_loop; - - { - int addr; - case 0xB9: /* SBC (x),(y) */ - case 0x99: /* ADC (x),(y) */ - pc--; /* compensate for inc later */ - data = READ_DP( x ); - addr = y + dp; - goto adc_addr; - case 0xA9: /* SBC dp,dp */ - case 0x89: /* ADC dp,dp */ - data = READ_DP( data ); - case 0xB8: /* SBC dp,imm */ - case 0x98: /* ADC dp,imm */ - addr = READ_PC( ++pc ) + dp; - adc_addr: - nz = READ( addr ); - goto adc_data; - -/* catch ADC and SBC together, then decode later based on operand */ -#undef CASE -#define CASE( n ) case n: case (n) + 0x20: - ADDR_MODES( 0x88 ) /* ADC/SBC addr */ - data = READ( data ); - case 0xA8: /* SBC imm */ - case 0x88: /* ADC imm */ - addr = -1; /* A */ - nz = a; - adc_data: { - if ( opcode & 0x20 ) - data ^= 0xFF; /* SBC */ - int carry = (c >> 8) & 1; - int ov = (nz ^ 0x80) + carry + (int8_t) data; /* sign-extend */ - int hc = (nz & 15) + carry; - c = nz += data + carry; - hc = (nz & 15) - hc; - status = (status & ~(st_v | st_h)) | ((ov >> 2) & st_v) | - ((hc >> 1) & st_h); - if ( addr < 0 ) { - a = (uint8_t) nz; - goto inc_pc_loop; - } - WRITE( addr, (uint8_t) nz ); - goto inc_pc_loop; - } - - } - -/* 6. ADDITION & SUBTRACTION COMMANDS */ - -#define INC_DEC_REG( reg, n )\ - nz = reg + n;\ - reg = (uint8_t) nz;\ - goto loop; - - case 0xBC: INC_DEC_REG( a, 1 ) /* INC A */ - case 0x3D: INC_DEC_REG( x, 1 ) /* INC X */ - case 0xFC: INC_DEC_REG( y, 1 ) /* INC Y */ - - case 0x9C: INC_DEC_REG( a, -1 ) /* DEC A */ - case 0x1D: INC_DEC_REG( x, -1 ) /* DEC X */ - case 0xDC: INC_DEC_REG( y, -1 ) /* DEC Y */ - - case 0x9B: /* DEC dp+X */ - case 0xBB: /* INC dp+X */ - data = (uint8_t) (data + x); - case 0x8B: /* DEC dp */ - case 0xAB: /* INC dp */ - data += dp; - goto inc_abs; - case 0x8C: /* DEC abs */ - case 0xAC: /* INC abs */ - data = READ_PC16( pc ); - pc++; - inc_abs: - nz = ((opcode >> 4) & 2) - 1; - nz += READ( data ); - WRITE( data, (uint8_t) nz ); - goto inc_pc_loop; - -/* 7. SHIFT, ROTATION COMMANDS */ - - case 0x5C: /* LSR A */ - c = 0; - case 0x7C:{/* ROR A */ - nz = ((c >> 1) & 0x80) | (a >> 1); - c = a << 8; - a = nz; - goto loop; - } - - case 0x1C: /* ASL A */ - c = 0; - case 0x3C:{/* ROL A */ - int temp = (c >> 8) & 1; - c = a << 1; - nz = c | temp; - a = (uint8_t) nz; - goto loop; - } - - case 0x0B: /* ASL dp */ - c = 0; - data += dp; - goto rol_mem; - case 0x1B: /* ASL dp+X */ - c = 0; - case 0x3B: /* ROL dp+X */ - data = (uint8_t) (data + x); - case 0x2B: /* ROL dp */ - data += dp; - goto rol_mem; - case 0x0C: /* ASL abs */ - c = 0; - case 0x2C: /* ROL abs */ - data = READ_PC16( pc ); - pc++; - rol_mem: - nz = (c >> 8) & 1; - nz |= (c = READ( data ) << 1); - WRITE( data, (uint8_t) nz ); - goto inc_pc_loop; - - case 0x4B: /* LSR dp */ - c = 0; - data += dp; - goto ror_mem; - case 0x5B: /* LSR dp+X */ - c = 0; - case 0x7B: /* ROR dp+X */ - data = (uint8_t) (data + x); - case 0x6B: /* ROR dp */ - data += dp; - goto ror_mem; - case 0x4C: /* LSR abs */ - c = 0; - case 0x6C: /* ROR abs */ - data = READ_PC16( pc ); - pc++; - ror_mem: { - int temp = READ( data ); - nz = ((c >> 1) & 0x80) | (temp >> 1); - c = temp << 8; - WRITE( data, nz ); - goto inc_pc_loop; - } - - case 0x9F: /* XCN */ - nz = a = (a >> 4) | (uint8_t) (a << 4); - goto loop; - -/* 8. 16-BIT TRANSMISION COMMANDS */ - - case 0xBA: /* MOVW YA,dp */ - a = READ_DP( data ); - nz = (a & 0x7F) | (a >> 1); - y = READ_DP( (uint8_t) (data + 1) ); - nz |= y; - goto inc_pc_loop; - - case 0xDA: /* MOVW dp,YA */ - WRITE_DP( data, a ); - WRITE_DP( (uint8_t) (data + 1), y ); - goto inc_pc_loop; - -/* 9. 16-BIT OPERATION COMMANDS */ - - case 0x3A: /* INCW dp */ - case 0x1A:{/* DECW dp */ - data += dp; - - /* low byte */ - int temp = READ( data ); - temp += ((opcode >> 4) & 2) - 1; /* +1 for INCW, -1 for DECW */ - nz = ((temp >> 1) | temp) & 0x7F; - WRITE( data, (uint8_t) temp ); - - /* high byte */ - data = ((uint8_t) (data + 1)) + dp; - temp >>= 8; - temp = (uint8_t) (temp + READ( data )); - nz |= temp; - WRITE( data, temp ); - - goto inc_pc_loop; - } - - case 0x9A: /* SUBW YA,dp */ - case 0x7A: /* ADDW YA,dp */ - { - /* read 16-bit addend */ - int temp = READ_DP( data ); - int sign = READ_DP( (uint8_t) (data + 1) ); - temp += 0x100 * sign; - status &= ~(st_v | st_h); - - /* to do: fix half-carry for SUBW (it's probably wrong) */ - - /* for SUBW, negate and truncate to 16 bits */ - if ( opcode & 0x80 ) { - temp = (temp ^ 0xFFFF) + 1; - sign = temp >> 8; - } - - /* add low byte (A) */ - temp += a; - a = (uint8_t) temp; - nz = (temp | (temp >> 1)) & 0x7F; - - /* add high byte (Y) */ - temp >>= 8; - c = y + temp; - nz = (nz | c) & 0xFF; - - /* half-carry (temporary avoids CodeWarrior optimizer bug) */ - unsigned hc = (c & 15) - (y & 15); - status |= (hc >> 4) & st_h; - - /* overflow if sign of YA changed when previous sign - and addend sign were same */ - status |= (((c ^ y) & ~(y ^ sign)) >> 1) & st_v; - - y = (uint8_t) c; - - goto inc_pc_loop; - } - - case 0x5A: { /* CMPW YA,dp */ - int temp = a - READ_DP( data ); - nz = ((temp >> 1) | temp) & 0x7F; - temp = y + (temp >> 8); - temp -= READ_DP( (uint8_t) (data + 1) ); - nz |= temp; - c = ~temp; - nz &= 0xFF; - goto inc_pc_loop; - } - -/* 10. MULTIPLICATION & DIVISON COMMANDS */ - - case 0xCF: { /* MUL YA */ - unsigned temp = y * a; - a = (uint8_t) temp; - nz = ((temp >> 1) | temp) & 0x7F; - y = temp >> 8; - nz |= y; - goto loop; - } - - case 0x9E: /* DIV YA,X */ - { - /* behavior based on SPC CPU tests */ - - status &= ~(st_h | st_v); - - if ( (y & 15) >= (x & 15) ) - status |= st_h; - - if ( y >= x ) - status |= st_v; - - unsigned ya = y * 0x100 + a; - if ( y < x * 2 ) - { - a = ya / x; - y = ya - a * x; - } - else - { - a = 255 - (ya - x * 0x200) / (256 - x); - y = x + (ya - x * 0x200) % (256 - x); - } - - nz = (uint8_t) a; - a = (uint8_t) a; - - goto loop; - } - -/* 11. DECIMAL COMPENSATION COMMANDS */ - - /* seem unused */ - /* case 0xDF: */ /* DAA */ - /* case 0xBE: */ /* DAS */ - -/* 12. BRANCHING COMMANDS */ - - case 0x2F: /* BRA rel */ - pc += (int8_t) data; - goto inc_pc_loop; - - case 0x30: /* BMI */ - BRANCH( IS_NEG ) - - case 0x10: /* BPL */ - BRANCH( !IS_NEG ) - - case 0xB0: /* BCS */ - BRANCH( c & 0x100 ) - - case 0x90: /* BCC */ - BRANCH( !(c & 0x100) ) - - case 0x70: /* BVS */ - BRANCH( status & st_v ) - - case 0x50: /* BVC */ - BRANCH( !(status & st_v) ) - - case 0x03: /* BBS dp.bit,rel */ - case 0x23: - case 0x43: - case 0x63: - case 0x83: - case 0xA3: - case 0xC3: - case 0xE3: - pc++; - if ( (READ_DP( data ) >> (opcode >> 5)) & 1 ) - goto cbranch_taken_loop; - goto inc_pc_loop; - - case 0x13: /* BBC dp.bit,rel */ - case 0x33: - case 0x53: - case 0x73: - case 0x93: - case 0xB3: - case 0xD3: - case 0xF3: - pc++; - if ( !((READ_DP( data ) >> (opcode >> 5)) & 1) ) - goto cbranch_taken_loop; - goto inc_pc_loop; - - case 0xDE: /* CBNE dp+X,rel */ - data = (uint8_t) (data + x); - /* fall through */ - case 0x2E: /* CBNE dp,rel */ - pc++; - if ( READ_DP( data ) != a ) - goto cbranch_taken_loop; - goto inc_pc_loop; - - case 0xFE: /* DBNZ Y,rel */ - y = (uint8_t) (y - 1); - BRANCH( y ) - - case 0x6E: { /* DBNZ dp,rel */ - pc++; - unsigned temp = READ_DP( data ) - 1; - WRITE_DP( (uint8_t) data, (uint8_t) temp ); - if ( temp ) - goto cbranch_taken_loop; - goto inc_pc_loop; - } - - case 0x1F: /* JMP (abs+X) */ - SET_PC( READ_PC16( pc ) + x ); - /* fall through */ - case 0x5F: /* JMP abs */ - SET_PC( READ_PC16( pc ) ); - goto loop; - -/* 13. SUB-ROUTINE CALL RETURN COMMANDS */ - - case 0x0F:{/* BRK */ - check( 0 ); /* untested */ - PUSH16( GET_PC() + 1 ); - SET_PC( READ_PROG16( 0xFFDE ) ); /* vector address verified */ - int temp; - CALC_STATUS( temp ); - PUSH( temp ); - status = (status | st_b) & ~st_i; - goto loop; - } - - case 0x4F: /* PCALL offset */ - PUSH16( GET_PC() + 1 ); - SET_PC( 0xFF00 + data ); - goto loop; - - case 0x01: /* TCALL n */ - case 0x11: - case 0x21: - case 0x31: - case 0x41: - case 0x51: - case 0x61: - case 0x71: - case 0x81: - case 0x91: - case 0xA1: - case 0xB1: - case 0xC1: - case 0xD1: - case 0xE1: - case 0xF1: - PUSH16( GET_PC() ); - SET_PC( READ_PROG16( 0xFFDE - (opcode >> 3) ) ); - goto loop; - -/* 14. STACK OPERATION COMMANDS */ - - { - int temp; - case 0x7F: /* RET1 */ - temp = POP(); - SET_PC( POP() ); - pc += POP() << 8; - goto set_status; - case 0x8E: /* POP PSW */ - temp = POP(); - set_status: - SET_STATUS( temp ); - goto loop; - } - - case 0x0D: { /* PUSH PSW */ - int temp; - CALC_STATUS( temp ); - PUSH( temp ); - goto loop; - } - - case 0x2D: /* PUSH A */ - PUSH( a ); - goto loop; - - case 0x4D: /* PUSH X */ - PUSH( x ); - goto loop; - - case 0x6D: /* PUSH Y */ - PUSH( y ); - goto loop; - - case 0xAE: /* POP A */ - a = POP(); - goto loop; - - case 0xCE: /* POP X */ - x = POP(); - goto loop; - - case 0xEE: /* POP Y */ - y = POP(); - goto loop; - -/* 15. BIT OPERATION COMMANDS */ - - case 0x02: /* SET1 */ - case 0x22: - case 0x42: - case 0x62: - case 0x82: - case 0xA2: - case 0xC2: - case 0xE2: - case 0x12: /* CLR1 */ - case 0x32: - case 0x52: - case 0x72: - case 0x92: - case 0xB2: - case 0xD2: - case 0xF2: { - data += dp; - int bit = 1 << (opcode >> 5); - int mask = ~bit; - if ( opcode & 0x10 ) - bit = 0; - WRITE( data, (READ( data ) & mask) | bit ); - goto inc_pc_loop; - } - - case 0x0E: /* TSET1 abs */ - case 0x4E:{/* TCLR1 abs */ - data = READ_PC16( pc ); - pc += 2; - unsigned temp = READ( data ); - nz = temp & a; - temp &= ~a; - if ( !(opcode & 0x40) ) - temp |= a; - WRITE( data, temp ); - goto loop; - } - - case 0x4A: /* AND1 C,mem.bit */ - c &= MEM_BIT(); - pc += 2; - goto loop; - - case 0x6A: /* AND1 C,/mem.bit */ - check( 0 ); /* untested */ - c &= ~MEM_BIT(); - pc += 2; - goto loop; - - case 0x0A: /* OR1 C,mem.bit */ - check( 0 ); /* untested */ - c |= MEM_BIT(); - pc += 2; - goto loop; - - case 0x2A: /* OR1 C,/mem.bit */ - check( 0 ); /* untested */ - c |= ~MEM_BIT(); - pc += 2; - goto loop; - - case 0x8A: /* EOR1 C,mem.bit */ - c ^= MEM_BIT(); - pc += 2; - goto loop; - - case 0xEA: { /* NOT1 mem.bit */ - data = READ_PC16( pc ); - pc += 2; - unsigned temp = READ( data & 0x1FFF ); - temp ^= 1 << (data >> 13); - WRITE( data & 0x1FFF, temp ); - goto loop; - } - - case 0xCA: { /* MOV1 mem.bit,C */ - data = READ_PC16( pc ); - pc += 2; - unsigned temp = READ( data & 0x1FFF ); - unsigned bit = data >> 13; - temp = (temp & ~(1 << bit)) | (((c >> 8) & 1) << bit); - WRITE( data & 0x1FFF, temp ); - goto loop; - } - - case 0xAA: /* MOV1 C,mem.bit */ - c = MEM_BIT(); - pc += 2; - goto loop; - -/* 16. PROGRAM STATUS FLAG OPERATION COMMANDS */ - - case 0x60: /* CLRC */ - c = 0; - goto loop; - - case 0x80: /* SETC */ - c = ~0; - goto loop; - - case 0xED: /* NOTC */ - c ^= 0x100; - goto loop; - - case 0xE0: /* CLRV */ - status &= ~(st_v | st_h); - goto loop; - - case 0x20: /* CLRP */ - dp = 0; - goto loop; - - case 0x40: /* SETP */ - dp = 0x100; - goto loop; - - case 0xA0: /* EI */ - check( 0 ); /* untested */ - status |= st_i; - goto loop; - - case 0xC0: /* DI */ - check( 0 ); /* untested */ - status &= ~st_i; - goto loop; - -/* 17. OTHER COMMANDS */ - - case 0x00: /* NOP */ - goto loop; - - /*case 0xEF:*/ /* SLEEP */ - /*case 0xFF:*/ /* STOP */ - case 0xFF: - c |= 1; /* force switch table to have 256 entries, - hopefully helping optimizer */ - } /* switch */ - - /* unhandled instructions fall out of switch so emulator can catch them */ - -out_of_time: - /* undo partial execution of opcode */ - spc_time_ -= this->cycle_table [*--pc]; - { - int temp; - CALC_STATUS( temp ); - this->r.status = (uint8_t) temp; - } - - this->r.pc = GET_PC(); - this->r.sp = (uint8_t) GET_SP(); - this->r.a = (uint8_t) a; - this->r.x = (uint8_t) x; - this->r.y = (uint8_t) y; - -#if 0 - EXIT_TIMER(cpu); -#endif - return spc_time_; -} - -void CPU_Init( THIS ) -{ - ci->memcpy( this->cycle_table, cycle_table, sizeof cycle_table ); -} - diff --git a/apps/codecs/libspc/spc_dsp.c b/apps/codecs/libspc/spc_dsp.c deleted file mode 100644 index 6350c4c331..0000000000 --- a/apps/codecs/libspc/spc_dsp.c +++ /dev/null @@ -1,1594 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2007-2008 Michael Sevakis (jhMikeS) - * Copyright (C) 2006-2007 Adam Gashlin (hcs) - * Copyright (C) 2004-2007 Shay Green (blargg) - * Copyright (C) 2002 Brad Martin - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ - -/* The DSP portion (awe!) */ -#include "codeclib.h" -#include "spc_codec.h" -#include "spc_profiler.h" - -#if defined(CPU_COLDFIRE) || defined (CPU_ARM) -int32_t fir_buf[FIR_BUF_CNT] IBSS_ATTR_SPC - __attribute__((aligned(FIR_BUF_ALIGN*1))); -#endif -#if SPC_BRRCACHE -/* a little extra for samples that go past end */ -int16_t BRRcache [BRR_CACHE_SIZE] CACHEALIGN_ATTR; -#endif - -void DSP_write( struct Spc_Dsp* this, int i, int data ) -{ - assert( (unsigned) i < REGISTER_COUNT ); - - this->r.reg [i] = data; - int high = i >> 4; - int low = i & 0x0F; - if ( low < 2 ) /* voice volumes */ - { - int left = *(int8_t const*) &this->r.reg [i & ~1]; - int right = *(int8_t const*) &this->r.reg [i | 1]; - struct voice_t* v = this->voice_state + high; - v->volume [0] = left; - v->volume [1] = right; - } - else if ( low == 0x0F ) /* fir coefficients */ - { - this->fir_coeff [7 - high] = (int8_t) data; /* sign-extend */ - } -} - -#define CLAMP16( n ) clip_sample_16( n ) - -#if SPC_BRRCACHE -static void decode_brr( struct Spc_Dsp* this, unsigned start_addr, - struct voice_t* voice, - struct raw_voice_t const* const raw_voice ) ICODE_ATTR_SPC; -static void decode_brr( struct Spc_Dsp* this, unsigned start_addr, - struct voice_t* voice, - struct raw_voice_t const* const raw_voice ) -{ - /* setup same variables as where decode_brr() is called from */ - #undef RAM - #define RAM ram.ram - - struct src_dir const* const sd = - &ram.sd[this->r.g.wave_page * 0x100/sizeof(struct src_dir)]; - struct cache_entry_t* const wave_entry = - &this->wave_entry [raw_voice->waveform]; - - /* the following block can be put in place of the call to - decode_brr() below - */ - { - DEBUGF( "decode at %08x (wave #%d)\n", - start_addr, raw_voice->waveform ); - - /* see if in cache */ - int i; - for ( i = 0; i < this->oldsize; i++ ) - { - struct cache_entry_t* e = &this->wave_entry_old [i]; - if ( e->start_addr == start_addr ) - { - DEBUGF( "found in wave_entry_old (oldsize=%d)\n", - this->oldsize ); - *wave_entry = *e; - goto wave_in_cache; - } - } - - wave_entry->start_addr = start_addr; - - uint8_t const* const loop_ptr = - RAM + letoh16(sd[raw_voice->waveform].loop); - short* loop_start = 0; - - short* out = BRRcache + start_addr * 2; - wave_entry->samples = out; - *out++ = 0; - int smp1 = 0; - int smp2 = 0; - - uint8_t const* addr = RAM + start_addr; - int block_header; - do - { - if ( addr == loop_ptr ) - { - loop_start = out; - DEBUGF( "loop at %08lx (wave #%d)\n", - (unsigned long)(addr - RAM), raw_voice->waveform ); - } - - /* header */ - block_header = *addr; - addr += 9; - voice->addr = addr; - int const filter = (block_header & 0x0C) - 0x08; - - /* scaling - (invalid scaling gives -4096 for neg nybble, 0 for pos) */ - static unsigned char const right_shifts [16] = { - 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 29, 29, 29, - }; - static unsigned char const left_shifts [16] = { - 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 11, 11, 11 - }; - int const scale = block_header >> 4; - int const right_shift = right_shifts [scale]; - int const left_shift = left_shifts [scale]; - - /* output position */ - out += BRR_BLOCK_SIZE; - int offset = -BRR_BLOCK_SIZE << 2; - - do /* decode and filter 16 samples */ - { - /* Get nybble, sign-extend, then scale - get byte, select which nybble, sign-extend, then shift based - on scaling. also handles invalid scaling values. */ - int delta = (int) (int8_t) (addr [offset >> 3] << (offset & 4)) - >> right_shift << left_shift; - - out [offset >> 2] = smp2; - - if ( filter == 0 ) /* mode 0x08 (30-90% of the time) */ - { - delta -= smp2 >> 1; - delta += smp2 >> 5; - smp2 = smp1; - delta += smp1; - delta += (-smp1 - (smp1 >> 1)) >> 5; - } - else - { - if ( filter == -4 ) /* mode 0x04 */ - { - delta += smp1 >> 1; - delta += (-smp1) >> 5; - } - else if ( filter > -4 ) /* mode 0x0C */ - { - delta -= smp2 >> 1; - delta += (smp2 + (smp2 >> 1)) >> 4; - delta += smp1; - delta += (-smp1 * 13) >> 7; - } - smp2 = smp1; - } - - delta = CLAMP16( delta ); - smp1 = (int16_t) (delta * 2); /* sign-extend */ - } - while ( (offset += 4) != 0 ); - - /* if next block has end flag set, this block ends early */ - /* (verified) */ - if ( (block_header & 3) != 3 && (*addr & 3) == 1 ) - { - /* skip last 9 samples */ - out -= 9; - goto early_end; - } - } - while ( !(block_header & 1) && addr < RAM + 0x10000 ); - - out [0] = smp2; - out [1] = smp1; - - early_end: - wave_entry->end = (out - 1 - wave_entry->samples) << 12; - - wave_entry->loop = 0; - if ( (block_header & 2) ) - { - if ( loop_start ) - { - int loop = out - loop_start; - wave_entry->loop = loop; - wave_entry->end += 0x3000; - out [2] = loop_start [2]; - out [3] = loop_start [3]; - out [4] = loop_start [4]; - } - else - { - DEBUGF( "loop point outside initial wave\n" ); - } - } - - DEBUGF( "end at %08lx (wave #%d)\n", - (unsigned long)(addr - RAM), raw_voice->waveform ); - - /* add to cache */ - this->wave_entry_old [this->oldsize++] = *wave_entry; -wave_in_cache:; - } -} -#endif - -static void key_on(struct Spc_Dsp* const this, struct voice_t* const voice, - struct src_dir const* const sd, - struct raw_voice_t const* const raw_voice, - const int key_on_delay, const int vbit) ICODE_ATTR_SPC; -static void key_on(struct Spc_Dsp* const this, struct voice_t* const voice, - struct src_dir const* const sd, - struct raw_voice_t const* const raw_voice, - const int key_on_delay, const int vbit) { - #undef RAM - #define RAM ram.ram - int const env_rate_init = 0x7800; - voice->key_on_delay = key_on_delay; - if ( key_on_delay == 0 ) - { - this->keys_down |= vbit; - voice->envx = 0; - voice->env_mode = state_attack; - voice->env_timer = env_rate_init; /* TODO: inaccurate? */ - unsigned start_addr = letoh16(sd[raw_voice->waveform].start); - #if !SPC_BRRCACHE - { - voice->addr = RAM + start_addr; - /* BRR filter uses previous samples */ - voice->samples [BRR_BLOCK_SIZE + 1] = 0; - voice->samples [BRR_BLOCK_SIZE + 2] = 0; - /* decode three samples immediately */ - voice->position = (BRR_BLOCK_SIZE + 3) * 0x1000 - 1; - voice->block_header = 0; /* "previous" BRR header */ - } - #else - { - voice->position = 3 * 0x1000 - 1; - struct cache_entry_t* const wave_entry = - &this->wave_entry [raw_voice->waveform]; - - /* predecode BRR if not already */ - if ( wave_entry->start_addr != start_addr ) - { - /* the following line can be replaced by the indicated block - in decode_brr() */ - decode_brr( this, start_addr, voice, raw_voice ); - } - - voice->samples = wave_entry->samples; - voice->wave_end = wave_entry->end; - voice->wave_loop = wave_entry->loop; - } - #endif - } -} - -void DSP_run_( struct Spc_Dsp* this, long count, int32_t* out_buf ) -{ - #undef RAM -#if defined(CPU_ARM) && !SPC_BRRCACHE - uint8_t* const ram_ = ram.ram; - #define RAM ram_ -#else - #define RAM ram.ram -#endif -#if 0 - EXIT_TIMER(cpu); - ENTER_TIMER(dsp); -#endif - - /* Here we check for keys on/off. Docs say that successive writes - to KON/KOF must be separated by at least 2 Ts periods or risk - being neglected. Therefore DSP only looks at these during an - update, and not at the time of the write. Only need to do this - once however, since the regs haven't changed over the whole - period we need to catch up with. */ - - { - int key_ons = this->r.g.key_ons; - int key_offs = this->r.g.key_offs; - /* keying on a voice resets that bit in ENDX */ - this->r.g.wave_ended &= ~key_ons; - /* key_off bits prevent key_on from being acknowledged */ - this->r.g.key_ons = key_ons & key_offs; - - /* process key events outside loop, since they won't re-occur */ - struct voice_t* voice = this->voice_state + 8; - int vbit = 0x80; - do - { - --voice; - if ( key_offs & vbit ) - { - voice->env_mode = state_release; - voice->key_on_delay = 0; - } - else if ( key_ons & vbit ) - { - voice->key_on_delay = 8; - } - } - while ( (vbit >>= 1) != 0 ); - } - - struct src_dir const* const sd = - &ram.sd[this->r.g.wave_page * 0x100/sizeof(struct src_dir)]; - - #ifdef ROCKBOX_BIG_ENDIAN - /* Convert endiannesses before entering loops - these - get used alot */ - const uint32_t rates[VOICE_COUNT] = - { - GET_LE16A( this->r.voice[0].rate ) & 0x3FFF, - GET_LE16A( this->r.voice[1].rate ) & 0x3FFF, - GET_LE16A( this->r.voice[2].rate ) & 0x3FFF, - GET_LE16A( this->r.voice[3].rate ) & 0x3FFF, - GET_LE16A( this->r.voice[4].rate ) & 0x3FFF, - GET_LE16A( this->r.voice[5].rate ) & 0x3FFF, - GET_LE16A( this->r.voice[6].rate ) & 0x3FFF, - GET_LE16A( this->r.voice[7].rate ) & 0x3FFF, - }; - #define VOICE_RATE(x) *(x) - #define IF_RBE(...) __VA_ARGS__ - #ifdef CPU_COLDFIRE - /* Initialize mask register with the buffer address mask */ - asm volatile ("move.l %[m], %%mask" : : [m]"i"(FIR_BUF_MASK)); - const int echo_wrap = (this->r.g.echo_delay & 15) * 0x800; - const int echo_start = this->r.g.echo_page * 0x100; - #endif /* CPU_COLDFIRE */ - #else - #define VOICE_RATE(x) (GET_LE16(raw_voice->rate) & 0x3FFF) - #define IF_RBE(...) - #endif /* ROCKBOX_BIG_ENDIAN */ - -#if !SPC_NOINTERP - int const slow_gaussian = (this->r.g.pitch_mods >> 1) | - this->r.g.noise_enables; -#endif - /* (g.flags & 0x40) ? 30 : 14 */ - int const global_muting = ((this->r.g.flags & 0x40) >> 2) + 14 - 8; - int const global_vol_0 = this->r.g.volume_0; - int const global_vol_1 = this->r.g.volume_1; - - /* each rate divides exactly into 0x7800 without remainder */ - int const env_rate_init = 0x7800; - static unsigned short const env_rates [0x20] ICONST_ATTR_SPC = - { - 0x0000, 0x000F, 0x0014, 0x0018, 0x001E, 0x0028, 0x0030, 0x003C, - 0x0050, 0x0060, 0x0078, 0x00A0, 0x00C0, 0x00F0, 0x0140, 0x0180, - 0x01E0, 0x0280, 0x0300, 0x03C0, 0x0500, 0x0600, 0x0780, 0x0A00, - 0x0C00, 0x0F00, 0x1400, 0x1800, 0x1E00, 0x2800, 0x3C00, 0x7800 - }; - - do /* one pair of output samples per iteration */ - { - /* Noise */ - if ( this->r.g.noise_enables ) - { - if ( (this->noise_count -= - env_rates [this->r.g.flags & 0x1F]) <= 0 ) - { - this->noise_count = env_rate_init; - int feedback = (this->noise << 13) ^ (this->noise << 14); - this->noise = (feedback & 0x8000) ^ (this->noise >> 1 & ~1); - } - } - -#if !SPC_NOECHO - int echo_0 = 0; - int echo_1 = 0; -#endif - long prev_outx = 0; /* TODO: correct value for first channel? */ - int chans_0 = 0; - int chans_1 = 0; - /* TODO: put raw_voice pointer in voice_t? */ - struct raw_voice_t * raw_voice = this->r.voice; - struct voice_t* voice = this->voice_state; - int vbit = 1; - IF_RBE( const uint32_t* vr = rates; ) - for ( ; vbit < 0x100; vbit <<= 1, ++voice, ++raw_voice IF_RBE( , ++vr ) ) - { - /* pregen involves checking keyon, etc */ -#if 0 - ENTER_TIMER(dsp_pregen); -#endif - - /* Key on events are delayed */ - int key_on_delay = voice->key_on_delay; - - if ( UNLIKELY ( --key_on_delay >= 0 ) ) /* <1% of the time */ - { - key_on(this,voice,sd,raw_voice,key_on_delay,vbit); - } - - if ( !(this->keys_down & vbit) ) /* Silent channel */ - { - silent_chan: - raw_voice->envx = 0; - raw_voice->outx = 0; - prev_outx = 0; - continue; - } - - /* Envelope */ - { - int const ENV_RANGE = 0x800; - int env_mode = voice->env_mode; - int adsr0 = raw_voice->adsr [0]; - int env_timer; - if ( LIKELY ( env_mode != state_release ) ) /* 99% of the time */ - { - env_timer = voice->env_timer; - if ( LIKELY ( adsr0 & 0x80 ) ) /* 79% of the time */ - { - int adsr1 = raw_voice->adsr [1]; - if ( LIKELY ( env_mode == state_sustain ) ) /* 74% of the time */ - { - if ( (env_timer -= env_rates [adsr1 & 0x1F]) > 0 ) - goto write_env_timer; - - int envx = voice->envx; - envx--; /* envx *= 255 / 256 */ - envx -= envx >> 8; - voice->envx = envx; - /* TODO: should this be 8? */ - raw_voice->envx = envx >> 4; - goto init_env_timer; - } - else if ( env_mode < 0 ) /* 25% state_decay */ - { - int envx = voice->envx; - if ( (env_timer -= - env_rates [(adsr0 >> 3 & 0x0E) + 0x10]) <= 0 ) - { - envx--; /* envx *= 255 / 256 */ - envx -= envx >> 8; - voice->envx = envx; - /* TODO: should this be 8? */ - raw_voice->envx = envx >> 4; - env_timer = env_rate_init; - } - - int sustain_level = adsr1 >> 5; - if ( envx <= (sustain_level + 1) * 0x100 ) - voice->env_mode = state_sustain; - - goto write_env_timer; - } - else /* state_attack */ - { - int t = adsr0 & 0x0F; - if ( (env_timer -= env_rates [t * 2 + 1]) > 0 ) - goto write_env_timer; - - int envx = voice->envx; - - int const step = ENV_RANGE / 64; - envx += step; - if ( t == 15 ) - envx += ENV_RANGE / 2 - step; - - if ( envx >= ENV_RANGE ) - { - envx = ENV_RANGE - 1; - voice->env_mode = state_decay; - } - voice->envx = envx; - /* TODO: should this be 8? */ - raw_voice->envx = envx >> 4; - goto init_env_timer; - } - } - else /* gain mode */ - { - int t = raw_voice->gain; - if ( t < 0x80 ) - { - raw_voice->envx = t; - voice->envx = t << 4; - goto env_end; - } - else - { - if ( (env_timer -= env_rates [t & 0x1F]) > 0 ) - goto write_env_timer; - - int envx = voice->envx; - int mode = t >> 5; - if ( mode <= 5 ) /* decay */ - { - int step = ENV_RANGE / 64; - if ( mode == 5 ) /* exponential */ - { - envx--; /* envx *= 255 / 256 */ - step = envx >> 8; - } - if ( (envx -= step) < 0 ) - { - envx = 0; - if ( voice->env_mode == state_attack ) - voice->env_mode = state_decay; - } - } - else /* attack */ - { - int const step = ENV_RANGE / 64; - envx += step; - if ( mode == 7 && - envx >= ENV_RANGE * 3 / 4 + step ) - envx += ENV_RANGE / 256 - step; - - if ( envx >= ENV_RANGE ) - envx = ENV_RANGE - 1; - } - voice->envx = envx; - /* TODO: should this be 8? */ - raw_voice->envx = envx >> 4; - goto init_env_timer; - } - } - } - else /* state_release */ - { - int envx = voice->envx; - if ( (envx -= ENV_RANGE / 256) > 0 ) - { - voice->envx = envx; - raw_voice->envx = envx >> 8; - goto env_end; - } - else - { - /* bit was set, so this clears it */ - this->keys_down ^= vbit; - voice->envx = 0; - goto silent_chan; - } - } - init_env_timer: - env_timer = env_rate_init; - write_env_timer: - voice->env_timer = env_timer; - env_end:; - } -#if 0 - EXIT_TIMER(dsp_pregen); - - ENTER_TIMER(dsp_gen); -#endif - #if !SPC_BRRCACHE - /* Decode BRR block */ - if ( voice->position >= BRR_BLOCK_SIZE * 0x1000 ) - { - voice->position -= BRR_BLOCK_SIZE * 0x1000; - - uint8_t const* addr = voice->addr; - if ( addr >= RAM + 0x10000 ) - addr -= 0x10000; - - /* action based on previous block's header */ - if ( voice->block_header & 1 ) - { - addr = RAM + letoh16(sd[raw_voice->waveform].loop); - this->r.g.wave_ended |= vbit; - if ( !(voice->block_header & 2) ) /* 1% of the time */ - { - /* first block was end block; - don't play anything (verified) */ - /* bit was set, so this clears it */ - this->keys_down ^= vbit; - - /* since voice->envx is 0, - samples and position don't matter */ - raw_voice->envx = 0; - voice->envx = 0; - goto skip_decode; - } - } - - /* header */ - int const block_header = *addr; - addr += 9; - voice->addr = addr; - voice->block_header = block_header; - - /* previous samples */ - int smp2 = voice->samples [BRR_BLOCK_SIZE + 1]; - int smp1 = voice->samples [BRR_BLOCK_SIZE + 2]; - voice->samples [0] = voice->samples [BRR_BLOCK_SIZE]; - - /* output position */ - short* out = voice->samples + (1 + BRR_BLOCK_SIZE); - int offset = -BRR_BLOCK_SIZE << 2; - - /* if next block has end flag set, - this block ends early (verified) */ - if ( (block_header & 3) != 3 && (*addr & 3) == 1 ) - { - /* arrange for last 9 samples to be skipped */ - int const skip = 9; - out += (skip & 1); - voice->samples [skip] = voice->samples [BRR_BLOCK_SIZE]; - voice->position += skip * 0x1000; - offset = (-BRR_BLOCK_SIZE + (skip & ~1)) << 2; - addr -= skip / 2; - /* force sample to end on next decode */ - voice->block_header = 1; - } - - int const filter = block_header & 0x0c; - int const scale = block_header >> 4; - - if ( filter == 0x08 ) /* filter 2 (30-90% of the time) */ - { - /* y[n] = x[n] + 61/32 * y[n-1] - 15/16 * y[n-2] */ - do /* decode and filter 16 samples */ - { - /* Get nybble, sign-extend, then scale - get byte, select which nybble, sign-extend, then shift - based on scaling. */ - int delta = (int8_t)(addr [offset >> 3] << (offset & 4)) >> 4; - delta = (delta << scale) >> 1; - - if (scale > 0xc) - delta = (delta >> 17) << 11; - - out [offset >> 2] = smp2; - - delta -= smp2 >> 1; - delta += smp2 >> 5; - delta += smp1; - delta += (-smp1 - (smp1 >> 1)) >> 5; - - delta = CLAMP16( delta ); - smp2 = smp1; - smp1 = (int16_t) (delta * 2); /* sign-extend */ - } - while ( (offset += 4) != 0 ); - } - else if ( filter == 0x04 ) /* filter 1 */ - { - /* y[n] = x[n] + 15/16 * y[n-1] */ - do /* decode and filter 16 samples */ - { - /* Get nybble, sign-extend, then scale - get byte, select which nybble, sign-extend, then shift - based on scaling. */ - int delta = (int8_t)(addr [offset >> 3] << (offset & 4)) >> 4; - delta = (delta << scale) >> 1; - - if (scale > 0xc) - delta = (delta >> 17) << 11; - - out [offset >> 2] = smp2; - - delta += smp1 >> 1; - delta += (-smp1) >> 5; - - delta = CLAMP16( delta ); - smp2 = smp1; - smp1 = (int16_t) (delta * 2); /* sign-extend */ - } - while ( (offset += 4) != 0 ); - } - else if ( filter == 0x0c ) /* filter 3 */ - { - /* y[n] = x[n] + 115/64 * y[n-1] - 13/16 * y[n-2] */ - do /* decode and filter 16 samples */ - { - /* Get nybble, sign-extend, then scale - get byte, select which nybble, sign-extend, then shift - based on scaling. */ - int delta = (int8_t)(addr [offset >> 3] << (offset & 4)) >> 4; - delta = (delta << scale) >> 1; - - if (scale > 0xc) - delta = (delta >> 17) << 11; - - out [offset >> 2] = smp2; - - delta -= smp2 >> 1; - delta += (smp2 + (smp2 >> 1)) >> 4; - delta += smp1; - delta += (-smp1 * 13) >> 7; - - delta = CLAMP16( delta ); - smp2 = smp1; - smp1 = (int16_t) (delta * 2); /* sign-extend */ - } - while ( (offset += 4) != 0 ); - } - else /* filter 0 */ - { - /* y[n] = x[n] */ - do /* decode and filter 16 samples */ - { - /* Get nybble, sign-extend, then scale - get byte, select which nybble, sign-extend, then shift - based on scaling. */ - int delta = (int8_t)(addr [offset >> 3] << (offset & 4)) >> 4; - delta = (delta << scale) >> 1; - - if (scale > 0xc) - delta = (delta >> 17) << 11; - - out [offset >> 2] = smp2; - - smp2 = smp1; - smp1 = delta * 2; - } - while ( (offset += 4) != 0 ); - } - - out [0] = smp2; - out [1] = smp1; - - skip_decode:; - } - #endif /* !SPC_BRRCACHE */ - /* Get rate (with possible modulation) */ - int rate = VOICE_RATE(vr); - if ( this->r.g.pitch_mods & vbit ) - rate = (rate * (prev_outx + 32768)) >> 15; - - #if !SPC_NOINTERP - /* Interleved gauss table (to improve cache coherency). */ - /* gauss [i * 2 + j] = normal_gauss [(1 - j) * 256 + i] */ - static short const gauss [512] ICONST_ATTR_SPC MEM_ALIGN_ATTR = - { -370,1305, 366,1305, 362,1304, 358,1304, 354,1304, 351,1304, 347,1304, 343,1303, -339,1303, 336,1303, 332,1302, 328,1302, 325,1301, 321,1300, 318,1300, 314,1299, -311,1298, 307,1297, 304,1297, 300,1296, 297,1295, 293,1294, 290,1293, 286,1292, -283,1291, 280,1290, 276,1288, 273,1287, 270,1286, 267,1284, 263,1283, 260,1282, -257,1280, 254,1279, 251,1277, 248,1275, 245,1274, 242,1272, 239,1270, 236,1269, -233,1267, 230,1265, 227,1263, 224,1261, 221,1259, 218,1257, 215,1255, 212,1253, -210,1251, 207,1248, 204,1246, 201,1244, 199,1241, 196,1239, 193,1237, 191,1234, -188,1232, 186,1229, 183,1227, 180,1224, 178,1221, 175,1219, 173,1216, 171,1213, -168,1210, 166,1207, 163,1205, 161,1202, 159,1199, 156,1196, 154,1193, 152,1190, -150,1186, 147,1183, 145,1180, 143,1177, 141,1174, 139,1170, 137,1167, 134,1164, -132,1160, 130,1157, 128,1153, 126,1150, 124,1146, 122,1143, 120,1139, 118,1136, -117,1132, 115,1128, 113,1125, 111,1121, 109,1117, 107,1113, 106,1109, 104,1106, -102,1102, 100,1098, 99,1094, 97,1090, 95,1086, 94,1082, 92,1078, 90,1074, - 89,1070, 87,1066, 86,1061, 84,1057, 83,1053, 81,1049, 80,1045, 78,1040, - 77,1036, 76,1032, 74,1027, 73,1023, 71,1019, 70,1014, 69,1010, 67,1005, - 66,1001, 65, 997, 64, 992, 62, 988, 61, 983, 60, 978, 59, 974, 58, 969, - 56, 965, 55, 960, 54, 955, 53, 951, 52, 946, 51, 941, 50, 937, 49, 932, - 48, 927, 47, 923, 46, 918, 45, 913, 44, 908, 43, 904, 42, 899, 41, 894, - 40, 889, 39, 884, 38, 880, 37, 875, 36, 870, 36, 865, 35, 860, 34, 855, - 33, 851, 32, 846, 32, 841, 31, 836, 30, 831, 29, 826, 29, 821, 28, 816, - 27, 811, 27, 806, 26, 802, 25, 797, 24, 792, 24, 787, 23, 782, 23, 777, - 22, 772, 21, 767, 21, 762, 20, 757, 20, 752, 19, 747, 19, 742, 18, 737, - 17, 732, 17, 728, 16, 723, 16, 718, 15, 713, 15, 708, 15, 703, 14, 698, - 14, 693, 13, 688, 13, 683, 12, 678, 12, 674, 11, 669, 11, 664, 11, 659, - 10, 654, 10, 649, 10, 644, 9, 640, 9, 635, 9, 630, 8, 625, 8, 620, - 8, 615, 7, 611, 7, 606, 7, 601, 6, 596, 6, 592, 6, 587, 6, 582, - 5, 577, 5, 573, 5, 568, 5, 563, 4, 559, 4, 554, 4, 550, 4, 545, - 4, 540, 3, 536, 3, 531, 3, 527, 3, 522, 3, 517, 2, 513, 2, 508, - 2, 504, 2, 499, 2, 495, 2, 491, 2, 486, 1, 482, 1, 477, 1, 473, - 1, 469, 1, 464, 1, 460, 1, 456, 1, 451, 1, 447, 1, 443, 1, 439, - 0, 434, 0, 430, 0, 426, 0, 422, 0, 418, 0, 414, 0, 410, 0, 405, - 0, 401, 0, 397, 0, 393, 0, 389, 0, 385, 0, 381, 0, 378, 0, 374, - }; - /* Gaussian interpolation using most recent 4 samples */ - long position = voice->position; - voice->position += rate; - short const* interp = voice->samples + (position >> 12); - int offset = position >> 4 & 0xFF; - - /* Only left half of gaussian kernel is in table, so we must mirror - for right half */ - short const* fwd = gauss + offset * 2; - short const* rev = gauss + 510 - offset * 2; - - /* Use faster gaussian interpolation when exact result isn't needed - by pitch modulator of next channel */ - int amp_0, amp_1; /* Also serve as temps _0, and _1 */ - if ( LIKELY ( !(slow_gaussian & vbit) ) ) /* 99% of the time */ - { - /* Main optimization is lack of clamping. Not a problem since - output never goes more than +/- 16 outside 16-bit range and - things are clamped later anyway. Other optimization is to - preserve fractional accuracy, eliminating several masks. */ - #if defined (CPU_ARM) - int output; - int _2, _3; /* All-purpose temps */ - /* Multiple ASM blocks keep regs free and reduce result - * latency issues. */ - #if ARM_ARCH >= 6 - /* Interpolate */ - asm volatile ( - "ldr %[_0], [%[interp]] \r\n" /* _0=i0i1 */ - "ldr %[_2], [%[fwd]] \r\n" /* _2=f0f1 */ - "ldr %[_1], [%[interp], #4] \r\n" /* _1=i2i3 */ - "ldr %[_3], [%[rev]] \r\n" /* _3=r0r1 */ - "smuad %[out], %[_0], %[_2] \r\n" /* out=f0*i0 + f1*i1 */ - "smladx %[out], %[_1], %[_3], %[out] \r\n" /* out+=r1*i2 + r0*i3 */ - : [out]"=r"(output), - [_0]"=&r"(amp_0), [_1]"=&r"(amp_1), - [_2]"=&r"(_2), [_3]"=r"(_3) - : [fwd]"r"(fwd), [rev]"r"(rev), - [interp]"r"(interp)); - /* Apply voice envelope */ - asm volatile ( - "mov %[_2], %[out], asr #(11-5) \r\n" /* To do >> 16 later */ - "mul %[out], %[_2], %[envx] \r\n" /* and avoid exp. shift */ - : [out]"+r"(output), [_2]"=&r"(_2) - : [envx]"r"((int)voice->envx)); - /* Apply left and right volume */ - asm volatile ( - "smulwb %[amp_0], %[out], %[vvol_0] \r\n" /* (32x16->48)[47:16]->[31:0] */ - "smulwb %[amp_1], %[out], %[vvol_1] \r\n" - : [out]"+r"(output), - [amp_0]"=&r"(amp_0), [amp_1]"=r"(amp_1) - : [vvol_0]"r"(voice->volume[0]), - [vvol_1]"r"(voice->volume[1])); - - raw_voice->outx = output >> (8+5); /* 'output' still 5 bits too big */ - #else /* ARM_ARCH < 6 */ - /* Perform gaussian interpolation on four samples */ - asm volatile ( - "ldrsh %[_0], [%[interp]] \r\n" - "ldrsh %[_2], [%[fwd]] \r\n" - "ldrsh %[_1], [%[interp], #2] \r\n" - "ldrsh %[_3], [%[fwd], #2] \r\n" - "mul %[out], %[_0], %[_2] \r\n" /* out= fwd[0]*interp[0] */ - "ldrsh %[_0], [%[interp], #4] \r\n" - "ldrsh %[_2], [%[rev], #2] \r\n" - "mla %[out], %[_1], %[_3], %[out] \r\n" /* out+=fwd[1]*interp[1] */ - "ldrsh %[_1], [%[interp], #6] \r\n" - "ldrsh %[_3], [%[rev]] \r\n" - "mla %[out], %[_0], %[_2], %[out] \r\n" /* out+=rev[1]*interp[2] */ - "mla %[out], %[_1], %[_3], %[out] \r\n" /* out+=rev[0]*interp[3] */ - : [out]"=&r"(output), - [_0]"=&r"(amp_0), [_1]"=&r"(amp_1), - [_2]"=&r"(_2), [_3]"=&r"(_3) - : [fwd]"r"(fwd), [rev]"r"(rev), - [interp]"r"(interp)); - /* Apply voice envelope */ - asm volatile ( - "mov %[_2], %[out], asr #11 \r\n" - "mul %[out], %[_2], %[envx] \r\n" - : [out]"+r"(output), [_2]"=&r"(_2) - : [envx]"r"((int)voice->envx)); - /* Reduce and apply left and right volume */ - asm volatile ( - "mov %[out], %[out], asr #11 \r\n" - "mul %[amp_0], %[out], %[vvol_0] \r\n" - "mul %[amp_1], %[out], %[vvol_1] \r\n" - : [out]"+r"(output), - [amp_0]"=&r"(amp_0), [amp_1]"=r"(amp_1) - : [vvol_0]"r"((int)voice->volume[0]), - [vvol_1]"r"((int)voice->volume[1])); - - raw_voice->outx = output >> 8; - #endif /* ARM_ARCH */ - #else /* Unoptimized CPU */ - int output = (((fwd [0] * interp [0] + - fwd [1] * interp [1] + - rev [1] * interp [2] + - rev [0] * interp [3] ) >> 11) * voice->envx) >> 11; - - /* duplicated here to give compiler more to run in parallel */ - amp_0 = voice->volume [0] * output; - amp_1 = voice->volume [1] * output; - - raw_voice->outx = output >> 8; - #endif /* CPU_* */ - } - else /* slow gaussian */ - { - #if defined(CPU_ARM) - #if ARM_ARCH >= 6 - int output = *(int16_t*) &this->noise; - - if ( !(this->r.g.noise_enables & vbit) ) - { - /* Interpolate */ - int _2, _3; - asm volatile ( - /* NOTE: often-unaligned accesses */ - "ldr %[_0], [%[interp]] \r\n" /* _0=i0i1 */ - "ldr %[_2], [%[fwd]] \r\n" /* _2=f0f1 */ - "ldr %[_1], [%[interp], #4] \r\n" /* _1=i2i3 */ - "ldr %[_3], [%[rev]] \r\n" /* _3=f2f3 */ - "smulbb %[out], %[_0], %[_2] \r\n" /* out=f0*i0 */ - "smultt %[_0], %[_0], %[_2] \r\n" /* _0=f1*i1 */ - "smulbt %[_2], %[_1], %[_3] \r\n" /* _2=r1*i2 */ - "smultb %[_3], %[_1], %[_3] \r\n" /* _3=r0*i3 */ - : [out]"=r"(output), - [_0]"=&r"(amp_0), [_1]"=&r"(amp_1), - [_2]"=&r"(_2), [_3]"=r"(_3) - : [fwd]"r"(fwd), [rev]"r"(rev), - [interp]"r"(interp)); - asm volatile ( - "mov %[out], %[out], asr#12 \r\n" - "add %[_0], %[out], %[_0], asr #12 \r\n" - "add %[_2], %[_0], %[_2], asr #12 \r\n" - "pkhbt %[_0], %[_2], %[_3], asl #4 \r\n" /* _3[31:16], _2[15:0] */ - "sadd16 %[_0], %[_0], %[_0] \r\n" /* _3[31:16]*2, _2[15:0]*2 */ - "qsubaddx %[out], %[_0], %[_0] \r\n" /* out[15:0]= - * sat16(_3[31:16]+_2[15:0]) */ - : [out]"+r"(output), - [_0]"+r"(amp_0), [_2]"+r"(_2), [_3]"+r"(_3)); - } - /* Apply voice envelope */ - asm volatile ( - "smulbb %[out], %[out], %[envx] \r\n" - : [out]"+r"(output) - : [envx]"r"(voice->envx)); - /* Reduce and apply left and right volume */ - asm volatile ( - "mov %[out], %[out], asr #11 \r\n" - "bic %[out], %[out], #0x1 \r\n" - "mul %[amp_0], %[out], %[vvol_0] \r\n" - "mul %[amp_1], %[out], %[vvol_1] \r\n" - : [out]"+r"(output), - [amp_0]"=&r"(amp_0), [amp_1]"=r"(amp_1) - : [vvol_0]"r"((int)voice->volume[0]), - [vvol_1]"r"((int)voice->volume[1])); - - prev_outx = output; - raw_voice->outx = output >> 8; - #else /* ARM_ARCH < 6 */ - int output = *(int16_t*) &this->noise; - - if ( !(this->r.g.noise_enables & vbit) ) - { - /* Interpolate */ - int _2, _3; - asm volatile ( - "ldrsh %[_0], [%[interp]] \r\n" - "ldrsh %[_2], [%[fwd]] \r\n" - "ldrsh %[_1], [%[interp], #2] \r\n" - "ldrsh %[_3], [%[fwd], #2] \r\n" - "mul %[out], %[_2], %[_0] \r\n" /* fwd[0]*interp[0] */ - "ldrsh %[_2], [%[rev], #2] \r\n" - "mul %[_0], %[_3], %[_1] \r\n" /* fwd[1]*interp[1] */ - "ldrsh %[_1], [%[interp], #4] \r\n" - "mov %[out], %[out], asr #12 \r\n" - "ldrsh %[_3], [%[rev]] \r\n" - "mul %[_2], %[_1], %[_2] \r\n" /* rev[1]*interp[2] */ - "ldrsh %[_1], [%[interp], #6] \r\n" - "add %[_0], %[out], %[_0], asr #12 \r\n" - "mul %[_3], %[_1], %[_3] \r\n" /* rev[0]*interp[3] */ - "add %[_2], %[_0], %[_2], asr #12 \r\n" - "mov %[_2], %[_2], lsl #17 \r\n" - "mov %[_3], %[_3], asr #12 \r\n" - "mov %[_3], %[_3], asl #1 \r\n" - "add %[out], %[_3], %[_2], asr #16 \r\n" - : [out]"=&r"(output), - [_0]"=&r"(amp_0), [_1]"=&r"(amp_1), - [_2]"=&r"(_2), [_3]"=&r"(_3) - : [fwd]"r"(fwd), [rev]"r"(rev), - [interp]"r"(interp)); - - output = CLAMP16(output); - } - /* Apply voice envelope */ - asm volatile ( - "mul %[_0], %[out], %[envx] \r\n" - : [_0]"=r"(amp_0) - : [out]"r"(output), [envx]"r"((int)voice->envx)); - /* Reduce and apply left and right volume */ - asm volatile ( - "mov %[out], %[amp_0], asr #11 \r\n" /* amp_0 = _0 */ - "bic %[out], %[out], #0x1 \r\n" - "mul %[amp_0], %[out], %[vvol_0] \r\n" - "mul %[amp_1], %[out], %[vvol_1] \r\n" - : [out]"+r"(output), - [amp_0]"+r"(amp_0), [amp_1]"=r"(amp_1) - : [vvol_0]"r"((int)voice->volume[0]), - [vvol_1]"r"((int)voice->volume[1])); - - prev_outx = output; - raw_voice->outx = output >> 8; - #endif /* ARM_ARCH >= 6 */ - #else /* Unoptimized CPU */ - int output = *(int16_t*) &this->noise; - - if ( !(this->r.g.noise_enables & vbit) ) - { - output = (fwd [0] * interp [0]) & ~0xFFF; - output = (output + fwd [1] * interp [1]) & ~0xFFF; - output = (output + rev [1] * interp [2]) >> 12; - output = (int16_t) (output * 2); - output += ((rev [0] * interp [3]) >> 12) * 2; - output = CLAMP16( output ); - } - output = (output * voice->envx) >> 11 & ~1; - - /* duplicated here to give compiler more to run in parallel */ - amp_0 = voice->volume [0] * output; - amp_1 = voice->volume [1] * output; - - prev_outx = output; - raw_voice->outx = output >> 8; - #endif /* CPU_* */ - } - #else /* SPCNOINTERP */ - /* two-point linear interpolation */ - #ifdef CPU_COLDFIRE - int amp_0 = (int16_t)this->noise; - int amp_1; - - if ( (this->r.g.noise_enables & vbit) == 0 ) - { - uint32_t f = voice->position; - int32_t y0; - - /** - * Formula (fastest found so far of MANY): - * output = y0 + f*y1 - f*y0 - */ - asm volatile ( - /* separate fractional and whole parts */ - "move.l %[f], %[y1] \r\n" - "and.l #0xfff, %[f] \r\n" - "lsr.l %[sh], %[y1] \r\n" - /* load samples y0 (upper) & y1 (lower) */ - "move.l 2(%[s], %[y1].l*2), %[y1] \r\n" - /* %acc0 = f*y1 */ - "mac.w %[f]l, %[y1]l, %%acc0 \r\n" - /* %acc0 -= f*y0 */ - "msac.w %[f]l, %[y1]u, %%acc0 \r\n" - /* separate out y0 and sign extend */ - "swap %[y1] \r\n" - "movea.w %[y1], %[y0] \r\n" - /* fetch result, scale down and add y0 */ - "movclr.l %%acc0, %[y1] \r\n" - /* output = y0 + (result >> 12) */ - "asr.l %[sh], %[y1] \r\n" - "add.l %[y0], %[y1] \r\n" - : [f]"+d"(f), [y0]"=&a"(y0), [y1]"=&d"(amp_0) - : [s]"a"(voice->samples), [sh]"d"(12)); - } - - /* apply voice envelope to output */ - asm volatile ( - "mac.w %[out]l, %[envx]l, %%acc0 \r\n" - : - : [out]"r"(amp_0), [envx]"r"(voice->envx)); - - /* advance voice position */ - voice->position += rate; - - /* fetch output, scale and apply left and right - voice volume */ - asm volatile ( - "movclr.l %%acc0, %[out] \r\n" - "asr.l %[sh], %[out] \r\n" - "mac.l %[vvol_0], %[out], %%acc0 \r\n" - "mac.l %[vvol_1], %[out], %%acc1 \r\n" - : [out]"=&d"(amp_0) - : [vvol_0]"r"((int)voice->volume[0]), - [vvol_1]"r"((int)voice->volume[1]), - [sh]"d"(11)); - - /* save this output into previous, scale and save in - output register */ - prev_outx = amp_0; - raw_voice->outx = amp_0 >> 8; - - /* fetch final voice output */ - asm volatile ( - "movclr.l %%acc0, %[amp_0] \r\n" - "movclr.l %%acc1, %[amp_1] \r\n" - : [amp_0]"=r"(amp_0), [amp_1]"=r"(amp_1)); - #elif defined (CPU_ARM) - int amp_0, amp_1; - - if ( (this->r.g.noise_enables & vbit) != 0 ) - { - amp_0 = *(int16_t *)&this->noise; - } - else - { - uint32_t f = voice->position; - amp_0 = (uint32_t)voice->samples; - - asm volatile( - "mov %[y1], %[f], lsr #12 \r\n" - "eor %[f], %[f], %[y1], lsl #12 \r\n" - "add %[y1], %[y0], %[y1], lsl #1 \r\n" - "ldrsh %[y0], [%[y1], #2] \r\n" - "ldrsh %[y1], [%[y1], #4] \r\n" - "sub %[y1], %[y1], %[y0] \r\n" - "mul %[f], %[y1], %[f] \r\n" - "add %[y0], %[y0], %[f], asr #12 \r\n" - : [f]"+r"(f), [y0]"+r"(amp_0), [y1]"=&r"(amp_1)); - } - - voice->position += rate; - - asm volatile( - "mul %[amp_1], %[amp_0], %[envx] \r\n" - "mov %[amp_0], %[amp_1], asr #11 \r\n" - "mov %[amp_1], %[amp_0], asr #8 \r\n" - : [amp_0]"+r"(amp_0), [amp_1]"=r"(amp_1) - : [envx]"r"(voice->envx)); - - prev_outx = amp_0; - raw_voice->outx = (int8_t)amp_1; - - asm volatile( - "mul %[amp_1], %[amp_0], %[vol_1] \r\n" - "mul %[amp_0], %[vol_0], %[amp_0] \r\n" - : [amp_0]"+r"(amp_0), [amp_1]"=&r"(amp_1) - : [vol_0]"r"((int)voice->volume[0]), - [vol_1]"r"((int)voice->volume[1])); - #else /* Unoptimized CPU */ - int output; - - if ( (this->r.g.noise_enables & vbit) == 0 ) - { - int const fraction = voice->position & 0xfff; - short const* const pos = (voice->samples + (voice->position >> 12)) + 1; - output = pos[0] + ((fraction * (pos[1] - pos[0])) >> 12); - } else { - output = *(int16_t *)&this->noise; - } - - voice->position += rate; - - output = (output * voice->envx) >> 11; - - /* duplicated here to give compiler more to run in parallel */ - int amp_0 = voice->volume [0] * output; - int amp_1 = voice->volume [1] * output; - - prev_outx = output; - raw_voice->outx = (int8_t) (output >> 8); - #endif /* CPU_* */ - #endif /* SPCNOINTERP */ - - #if SPC_BRRCACHE - if ( voice->position >= voice->wave_end ) - { - long loop_len = voice->wave_loop << 12; - voice->position -= loop_len; - this->r.g.wave_ended |= vbit; - if ( !loop_len ) - { - this->keys_down ^= vbit; - raw_voice->envx = 0; - voice->envx = 0; - } - } - #endif -#if 0 - EXIT_TIMER(dsp_gen); - - ENTER_TIMER(dsp_mix); -#endif - chans_0 += amp_0; - chans_1 += amp_1; - #if !SPC_NOECHO - if ( this->r.g.echo_ons & vbit ) - { - echo_0 += amp_0; - echo_1 += amp_1; - } - #endif -#if 0 - EXIT_TIMER(dsp_mix); -#endif - } - /* end of voice loop */ - - #if !SPC_NOECHO - #ifdef CPU_COLDFIRE - /* Read feedback from echo buffer */ - int echo_pos = this->echo_pos; - uint8_t* const echo_ptr = RAM + ((echo_start + echo_pos) & 0xFFFF); - echo_pos += 4; - if ( echo_pos >= echo_wrap ) - echo_pos = 0; - this->echo_pos = echo_pos; - int fb = swap_odd_even32(*(int32_t *)echo_ptr); - int out_0, out_1; - - /* Keep last 8 samples */ - *this->last_fir_ptr = fb; - this->last_fir_ptr = this->fir_ptr; - - /* Apply echo FIR filter to output samples read from echo buffer - - circular buffer is hardware incremented and masked; FIR - coefficients and buffer history are loaded in parallel with - multiply accumulate operations. Shift left by one here and once - again when calculating feedback to have sample values justified - to bit 31 in the output to ease endian swap, interleaving and - clamping before placing result in the program's echo buffer. */ - int _0, _1, _2; - asm volatile ( - "move.l (%[fir_c]) , %[_2] \r\n" - "mac.w %[fb]u, %[_2]u, <<, (%[fir_p])+&, %[_0], %%acc0 \r\n" - "mac.w %[fb]l, %[_2]u, <<, (%[fir_p])& , %[_1], %%acc1 \r\n" - "mac.w %[_0]u, %[_2]l, << , %%acc0 \r\n" - "mac.w %[_0]l, %[_2]l, <<, 4(%[fir_c]) , %[_2], %%acc1 \r\n" - "mac.w %[_1]u, %[_2]u, <<, 4(%[fir_p])& , %[_0], %%acc0 \r\n" - "mac.w %[_1]l, %[_2]u, <<, 8(%[fir_p])& , %[_1], %%acc1 \r\n" - "mac.w %[_0]u, %[_2]l, << , %%acc0 \r\n" - "mac.w %[_0]l, %[_2]l, <<, 8(%[fir_c]) , %[_2], %%acc1 \r\n" - "mac.w %[_1]u, %[_2]u, <<, 12(%[fir_p])& , %[_0], %%acc0 \r\n" - "mac.w %[_1]l, %[_2]u, <<, 16(%[fir_p])& , %[_1], %%acc1 \r\n" - "mac.w %[_0]u, %[_2]l, << , %%acc0 \r\n" - "mac.w %[_0]l, %[_2]l, <<, 12(%[fir_c]) , %[_2], %%acc1 \r\n" - "mac.w %[_1]u, %[_2]u, <<, 20(%[fir_p])& , %[_0], %%acc0 \r\n" - "mac.w %[_1]l, %[_2]u, << , %%acc1 \r\n" - "mac.w %[_0]u, %[_2]l, << , %%acc0 \r\n" - "mac.w %[_0]l, %[_2]l, << , %%acc1 \r\n" - : [_0]"=&r"(_0), [_1]"=&r"(_1), [_2]"=&r"(_2), - [fir_p]"+a"(this->fir_ptr) - : [fir_c]"a"(this->fir_coeff), [fb]"r"(fb) - ); - - /* Generate output */ - asm volatile ( - /* fetch filter results _after_ gcc loads asm - block parameters to eliminate emac stalls */ - "movclr.l %%acc0, %[out_0] \r\n" - "movclr.l %%acc1, %[out_1] \r\n" - /* apply global volume */ - "mac.l %[chans_0], %[gv_0] , %%acc2 \r\n" - "mac.l %[chans_1], %[gv_1] , %%acc3 \r\n" - /* apply echo volume and add to final output */ - "mac.l %[ev_0], %[out_0], >>, %%acc2 \r\n" - "mac.l %[ev_1], %[out_1], >>, %%acc3 \r\n" - : [out_0]"=&r"(out_0), [out_1]"=&r"(out_1) - : [chans_0]"r"(chans_0), [gv_0]"r"(global_vol_0), - [ev_0]"r"((int)this->r.g.echo_volume_0), - [chans_1]"r"(chans_1), [gv_1]"r"(global_vol_1), - [ev_1]"r"((int)this->r.g.echo_volume_1) - ); - - /* Feedback into echo buffer */ - if ( !(this->r.g.flags & 0x20) ) - { - int sh = 1 << 9; - - asm volatile ( - /* scale echo voices; saturate if overflow */ - "mac.l %[sh], %[e1] , %%acc1 \r\n" - "mac.l %[sh], %[e0] , %%acc0 \r\n" - /* add scaled output from FIR filter */ - "mac.l %[out_1], %[ef], <<, %%acc1 \r\n" - "mac.l %[out_0], %[ef], <<, %%acc0 \r\n" - /* swap and fetch feedback results - simply - swap_odd_even32 mixed in between macs and - movclrs to mitigate stall issues */ - "move.l #0x00ff00ff, %[sh] \r\n" - "movclr.l %%acc1, %[e1] \r\n" - "swap %[e1] \r\n" - "movclr.l %%acc0, %[e0] \r\n" - "move.w %[e1], %[e0] \r\n" - "and.l %[e0], %[sh] \r\n" - "eor.l %[sh], %[e0] \r\n" - "lsl.l #8, %[sh] \r\n" - "lsr.l #8, %[e0] \r\n" - "or.l %[sh], %[e0] \r\n" - /* save final feedback into echo buffer */ - "move.l %[e0], (%[echo_ptr]) \r\n" - : [e0]"+d"(echo_0), [e1]"+d"(echo_1), [sh]"+d"(sh) - : [out_0]"r"(out_0), [out_1]"r"(out_1), - [ef]"r"((int)this->r.g.echo_feedback), - [echo_ptr]"a"((int32_t *)echo_ptr) - ); - } - - /* Output final samples */ - asm volatile ( - /* fetch output saved in %acc2 and %acc3 */ - "movclr.l %%acc2, %[out_0] \r\n" - "movclr.l %%acc3, %[out_1] \r\n" - /* scale right by global_muting shift */ - "asr.l %[gm], %[out_0] \r\n" - "asr.l %[gm], %[out_1] \r\n" - : [out_0]"=&d"(out_0), [out_1]"=&d"(out_1) - : [gm]"d"(global_muting) - ); - - out_buf [ 0] = out_0; - out_buf [WAV_CHUNK_SIZE] = out_1; - out_buf ++; - #elif defined (CPU_ARM) - /* Read feedback from echo buffer */ - int echo_pos = this->echo_pos; - uint8_t* const echo_ptr = RAM + - ((this->r.g.echo_page * 0x100 + echo_pos) & 0xFFFF); - echo_pos += 4; - if ( echo_pos >= (this->r.g.echo_delay & 15) * 0x800 ) - echo_pos = 0; - this->echo_pos = echo_pos; - - #if ARM_ARCH >= 6 - int32_t *fir_ptr, *fir_coeff; - int fb_0, fb_1; - - /* Apply FIR */ - - /* Keep last 8 samples */ - asm volatile ( - "ldr %[fb_0], [%[echo_p]] \r\n" - "add %[fir_p], %[t_fir_p], #4 \r\n" - "bic %[t_fir_p], %[fir_p], %[mask] \r\n" - "str %[fb_0], [%[fir_p], #-4] \r\n" - /* duplicate at +8 eliminates wrap checking below */ - "str %[fb_0], [%[fir_p], #28] \r\n" - : [fir_p]"=&r"(fir_ptr), [t_fir_p]"+r"(this->fir_ptr), - [fb_0]"=&r"(fb_0) - : [echo_p]"r"(echo_ptr), [mask]"i"(~FIR_BUF_MASK)); - - fir_coeff = (int32_t *)this->fir_coeff; - - /* Fugly, but the best version found. */ - int _0; - asm volatile ( /* L0R0 = acc0 */ - "ldmia %[fir_p]!, { r2-r5 } \r\n" /* L1R1-L4R4 = r2-r5 */ - "ldmia %[fir_c]!, { r0-r1 } \r\n" /* C0C1-C2C3 = r0-r1 */ - "pkhbt %[_0], %[acc0], r2, asl #16 \r\n" /* L0R0,L1R1->L0L1,R0R1 */ - "pkhtb r2, r2, %[acc0], asr #16 \r\n" - "smuad %[acc0], %[_0], r0 \r\n" /* acc0=L0*C0+L1*C1 */ - "smuad %[acc1], r2, r0 \r\n" /* acc1=R0*C0+R1*C1 */ - "pkhbt %[_0], r3, r4, asl #16 \r\n" /* L2R2,L3R3->L2L3,R2R3 */ - "pkhtb r4, r4, r3, asr #16 \r\n" - "smlad %[acc0], %[_0], r1, %[acc0] \r\n" /* acc0+=L2*C2+L3*C3 */ - "smlad %[acc1], r4, r1, %[acc1] \r\n" /* acc1+=R2*C2+R3*C3 */ - "ldmia %[fir_p], { r2-r4 } \r\n" /* L5R5-L7R7 = r2-r4 */ - "ldmia %[fir_c], { r0-r1 } \r\n" /* C4C5-C6C7 = r0-r1 */ - "pkhbt %[_0], r5, r2, asl #16 \r\n" /* L4R4,L5R5->L4L5,R4R5 */ - "pkhtb r2, r2, r5, asr #16 \r\n" - "smlad %[acc0], %[_0], r0, %[acc0] \r\n" /* acc0+=L4*C4+L5*C5 */ - "smlad %[acc1], r2, r0, %[acc1] \r\n" /* acc1+=R4*C4+R5*C5 */ - "pkhbt %[_0], r3, r4, asl #16 \r\n" /* L6R6,L7R7->L6L7,R6R7 */ - "pkhtb r4, r4, r3, asr #16 \r\n" - "smlad %[acc0], %[_0], r1, %[acc0] \r\n" /* acc0+=L6*C6+L7*C7 */ - "smlad %[acc1], r4, r1, %[acc1] \r\n" /* acc1+=R6*C6+R7*C7 */ - : [acc0]"+r"(fb_0), [acc1]"=&r"(fb_1), [_0]"=&r"(_0), - [fir_p]"+r"(fir_ptr), [fir_c]"+r"(fir_coeff) - : - : "r0", "r1", "r2", "r3", "r4", "r5"); - - /* Generate output */ - int amp_0, amp_1; - - asm volatile ( - "mul %[amp_0], %[gvol_0], %[chans_0] \r\n" - "mul %[amp_1], %[gvol_1], %[chans_1] \r\n" - : [amp_0]"=&r"(amp_0), [amp_1]"=r"(amp_1) - : [gvol_0]"r"(global_vol_0), [gvol_1]"r"(global_vol_1), - [chans_0]"r"(chans_0), [chans_1]"r"(chans_1)); - asm volatile ( - "mla %[amp_0], %[fb_0], %[ev_0], %[amp_0] \r\n" - "mla %[amp_1], %[fb_1], %[ev_1], %[amp_1] \r\n" - : [amp_0]"+r"(amp_0), [amp_1]"+r"(amp_1) - : [fb_0]"r"(fb_0), [fb_1]"r"(fb_1), - [ev_0]"r"((int)this->r.g.echo_volume_0), - [ev_1]"r"((int)this->r.g.echo_volume_1)); - - out_buf [ 0] = amp_0 >> global_muting; - out_buf [WAV_CHUNK_SIZE] = amp_1 >> global_muting; - out_buf ++; - - if ( !(this->r.g.flags & 0x20) ) - { - /* Feedback into echo buffer */ - int e0, e1; - - asm volatile ( - "mov %[e0], %[echo_0], asl #7 \r\n" - "mov %[e1], %[echo_1], asl #7 \r\n" - "mla %[e0], %[fb_0], %[efb], %[e0] \r\n" - "mla %[e1], %[fb_1], %[efb], %[e1] \r\n" - : [e0]"=&r"(e0), [e1]"=&r"(e1) - : [echo_0]"r"(echo_0), [echo_1]"r"(echo_1), - [fb_0]"r"(fb_0), [fb_1]"r"(fb_1), - [efb]"r"((int)this->r.g.echo_feedback)); - asm volatile ( - "ssat %[e0], #16, %[e0], asr #14 \r\n" - "ssat %[e1], #16, %[e1], asr #14 \r\n" - "pkhbt %[e0], %[e0], %[e1], lsl #16 \r\n" - "str %[e0], [%[echo_p]] \r\n" - : [e0]"+r"(e0), [e1]"+r"(e1) - : [echo_p]"r"(echo_ptr)); - } - #else /* ARM_ARCH < 6 */ - int fb_0 = GET_LE16SA( echo_ptr ); - int fb_1 = GET_LE16SA( echo_ptr + 2 ); - int32_t *fir_ptr, *fir_coeff; - - /* Keep last 8 samples */ - - /* Apply FIR */ - asm volatile ( - "add %[fir_p], %[t_fir_p], #8 \r\n" - "bic %[t_fir_p], %[fir_p], %[mask] \r\n" - "str %[fb_0], [%[fir_p], #-8] \r\n" - "str %[fb_1], [%[fir_p], #-4] \r\n" - /* duplicate at +8 eliminates wrap checking below */ - "str %[fb_0], [%[fir_p], #56] \r\n" - "str %[fb_1], [%[fir_p], #60] \r\n" - : [fir_p]"=&r"(fir_ptr), [t_fir_p]"+r"(this->fir_ptr) - : [fb_0]"r"(fb_0), [fb_1]"r"(fb_1), [mask]"i"(~FIR_BUF_MASK)); - - fir_coeff = this->fir_coeff; - - asm volatile ( - "ldmia %[fir_c]!, { r0-r1 } \r\n" - "ldmia %[fir_p]!, { r4-r5 } \r\n" - "mul %[fb_0], r0, %[fb_0] \r\n" - "mul %[fb_1], r0, %[fb_1] \r\n" - "mla %[fb_0], r4, r1, %[fb_0] \r\n" - "mla %[fb_1], r5, r1, %[fb_1] \r\n" - "ldmia %[fir_c]!, { r0-r1 } \r\n" - "ldmia %[fir_p]!, { r2-r5 } \r\n" - "mla %[fb_0], r2, r0, %[fb_0] \r\n" - "mla %[fb_1], r3, r0, %[fb_1] \r\n" - "mla %[fb_0], r4, r1, %[fb_0] \r\n" - "mla %[fb_1], r5, r1, %[fb_1] \r\n" - "ldmia %[fir_c]!, { r0-r1 } \r\n" - "ldmia %[fir_p]!, { r2-r5 } \r\n" - "mla %[fb_0], r2, r0, %[fb_0] \r\n" - "mla %[fb_1], r3, r0, %[fb_1] \r\n" - "mla %[fb_0], r4, r1, %[fb_0] \r\n" - "mla %[fb_1], r5, r1, %[fb_1] \r\n" - "ldmia %[fir_c]!, { r0-r1 } \r\n" - "ldmia %[fir_p]!, { r2-r5 } \r\n" - "mla %[fb_0], r2, r0, %[fb_0] \r\n" - "mla %[fb_1], r3, r0, %[fb_1] \r\n" - "mla %[fb_0], r4, r1, %[fb_0] \r\n" - "mla %[fb_1], r5, r1, %[fb_1] \r\n" - : [fb_0]"+r"(fb_0), [fb_1]"+r"(fb_1), - [fir_p]"+r"(fir_ptr), [fir_c]"+r"(fir_coeff) - : - : "r0", "r1", "r2", "r3", "r4", "r5"); - - /* Generate output */ - int amp_0 = (chans_0 * global_vol_0 + fb_0 * this->r.g.echo_volume_0) - >> global_muting; - int amp_1 = (chans_1 * global_vol_1 + fb_1 * this->r.g.echo_volume_1) - >> global_muting; - - out_buf [ 0] = amp_0; - out_buf [WAV_CHUNK_SIZE] = amp_1; - out_buf ++; - - if ( !(this->r.g.flags & 0x20) ) - { - /* Feedback into echo buffer */ - int e0 = (echo_0 >> 7) + ((fb_0 * this->r.g.echo_feedback) >> 14); - int e1 = (echo_1 >> 7) + ((fb_1 * this->r.g.echo_feedback) >> 14); - e0 = CLAMP16( e0 ); - SET_LE16A( echo_ptr , e0 ); - e1 = CLAMP16( e1 ); - SET_LE16A( echo_ptr + 2, e1 ); - } - #endif /* ARM_ARCH */ - #else /* Unoptimized CPU */ - /* Read feedback from echo buffer */ - int echo_pos = this->echo_pos; - uint8_t* const echo_ptr = RAM + - ((this->r.g.echo_page * 0x100 + echo_pos) & 0xFFFF); - echo_pos += 4; - if ( echo_pos >= (this->r.g.echo_delay & 15) * 0x800 ) - echo_pos = 0; - this->echo_pos = echo_pos; - int fb_0 = GET_LE16SA( echo_ptr ); - int fb_1 = GET_LE16SA( echo_ptr + 2 ); - - /* Keep last 8 samples */ - int (* const fir_ptr) [2] = this->fir_buf + this->fir_pos; - this->fir_pos = (this->fir_pos + 1) & (FIR_BUF_HALF - 1); - fir_ptr [ 0] [0] = fb_0; - fir_ptr [ 0] [1] = fb_1; - /* duplicate at +8 eliminates wrap checking below */ - fir_ptr [FIR_BUF_HALF] [0] = fb_0; - fir_ptr [FIR_BUF_HALF] [1] = fb_1; - - /* Apply FIR */ - fb_0 *= this->fir_coeff [0]; - fb_1 *= this->fir_coeff [0]; - - #define DO_PT( i )\ - fb_0 += fir_ptr [i] [0] * this->fir_coeff [i];\ - fb_1 += fir_ptr [i] [1] * this->fir_coeff [i]; - - DO_PT( 1 ) - DO_PT( 2 ) - DO_PT( 3 ) - DO_PT( 4 ) - DO_PT( 5 ) - DO_PT( 6 ) - DO_PT( 7 ) - - /* Generate output */ - int amp_0 = (chans_0 * global_vol_0 + fb_0 * this->r.g.echo_volume_0) - >> global_muting; - int amp_1 = (chans_1 * global_vol_1 + fb_1 * this->r.g.echo_volume_1) - >> global_muting; - out_buf [ 0] = amp_0; - out_buf [WAV_CHUNK_SIZE] = amp_1; - out_buf ++; - - if ( !(this->r.g.flags & 0x20) ) - { - /* Feedback into echo buffer */ - int e0 = (echo_0 >> 7) + ((fb_0 * this->r.g.echo_feedback) >> 14); - int e1 = (echo_1 >> 7) + ((fb_1 * this->r.g.echo_feedback) >> 14); - e0 = CLAMP16( e0 ); - SET_LE16A( echo_ptr , e0 ); - e1 = CLAMP16( e1 ); - SET_LE16A( echo_ptr + 2, e1 ); - } - #endif /* CPU_* */ - #else /* SPCNOECHO == 1*/ - /* Generate output */ - int amp_0 = (chans_0 * global_vol_0) >> global_muting; - int amp_1 = (chans_1 * global_vol_1) >> global_muting; - out_buf [ 0] = amp_0; - out_buf [WAV_CHUNK_SIZE] = amp_1; - out_buf ++; - #endif /* SPCNOECHO */ - } - while ( --count ); -#if 0 - EXIT_TIMER(dsp); - ENTER_TIMER(cpu); -#endif -} - -void DSP_reset( struct Spc_Dsp* this ) -{ - this->keys_down = 0; - this->echo_pos = 0; - this->noise_count = 0; - this->noise = 2; - - this->r.g.flags = 0xE0; /* reset, mute, echo off */ - this->r.g.key_ons = 0; - - ci->memset( this->voice_state, 0, sizeof this->voice_state ); - - int i; - for ( i = VOICE_COUNT; --i >= 0; ) - { - struct voice_t* v = this->voice_state + i; - v->env_mode = state_release; - v->addr = ram.ram; - } - - #if SPC_BRRCACHE - this->oldsize = 0; - for ( i = 0; i < 256; i++ ) - this->wave_entry [i].start_addr = -1; - #endif - -#if defined(CPU_COLDFIRE) - this->fir_ptr = fir_buf; - this->last_fir_ptr = &fir_buf [7]; - ci->memset( fir_buf, 0, sizeof fir_buf ); -#elif defined (CPU_ARM) - this->fir_ptr = fir_buf; - ci->memset( fir_buf, 0, sizeof fir_buf ); -#else - this->fir_pos = 0; - ci->memset( this->fir_buf, 0, sizeof this->fir_buf ); -#endif - - assert( offsetof (struct globals_t,unused9 [2]) == REGISTER_COUNT ); - assert( sizeof (this->r.voice) == REGISTER_COUNT ); -} diff --git a/apps/codecs/libspc/spc_emu.c b/apps/codecs/libspc/spc_emu.c deleted file mode 100644 index 5ea5b0cdeb..0000000000 --- a/apps/codecs/libspc/spc_emu.c +++ /dev/null @@ -1,397 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2006-2007 Adam Gashlin (hcs) - * Copyright (C) 2004-2007 Shay Green (blargg) - * Copyright (C) 2002 Brad Martin - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ -#include "codeclib.h" -#include "spc_codec.h" -#include "spc_profiler.h" - -/* lovingly ripped off from Game_Music_Emu 0.5.2. http://www.slack.net/~ant/ */ -/* DSP Based on Brad Martin's OpenSPC DSP emulator */ -/* tag reading from sexyspc by John Brawn (John_Brawn@yahoo.com) and others */ - -struct cpu_ram_t ram IBSS_ATTR_SPC_LARGE_IRAM CACHEALIGN_ATTR; - -/**************** Timers ****************/ - -static void Timer_run_( struct Timer* t, long time ) ICODE_ATTR_SPC; -static void Timer_run_( struct Timer* t, long time ) -{ - /* when disabled, next_tick should always be in the future */ - assert( t->enabled ); - - int elapsed = ((time - t->next_tick) >> t->shift) + 1; - t->next_tick += elapsed << t->shift; - - elapsed += t->count; - if ( elapsed >= t->period ) /* avoid unnecessary division */ - { - int n = elapsed / t->period; - elapsed -= n * t->period; - t->counter = (t->counter + n) & 15; - } - t->count = elapsed; -} - -static inline void Timer_run( struct Timer* t, long time ) -{ - if ( time >= t->next_tick ) - Timer_run_( t, time ); -} - -/**************** SPC emulator ****************/ -/* 1.024 MHz clock / 32000 samples per second */ - -static void SPC_enable_rom( THIS, int enable ) -{ - if ( this->rom_enabled != enable ) - { - this->rom_enabled = enable; - ci->memcpy( RAM + ROM_ADDR, (enable ? this->boot_rom : this->extra_ram), ROM_SIZE ); - /* TODO: ROM can still get overwritten when DSP writes to echo buffer */ - } -} - -void SPC_Init( THIS ) -{ - this->timer [0].shift = 4 + 3; /* 8 kHz */ - this->timer [1].shift = 4 + 3; /* 8 kHz */ - this->timer [2].shift = 4; /* 8 kHz */ - - /* Put STOP instruction around memory to catch PC underflow/overflow. */ - ci->memset( ram.padding1, 0xFF, sizeof ram.padding1 ); - ci->memset( ram.padding2, 0xFF, sizeof ram.padding2 ); - - /* A few tracks read from the last four bytes of IPL ROM */ - this->boot_rom [sizeof this->boot_rom - 2] = 0xC0; - this->boot_rom [sizeof this->boot_rom - 1] = 0xFF; - ci->memset( this->boot_rom, 0, sizeof this->boot_rom - 2 ); - - /* Have DSP in a defined state in case EMU is run and hasn't loaded - * a program yet */ - DSP_reset(&this->dsp); -} - -static void SPC_load_state( THIS, struct cpu_regs_t const* cpu_state, - const void* new_ram, const void* dsp_state ) -{ - ci->memcpy(&(this->r),cpu_state,sizeof this->r); - - /* ram */ - ci->memcpy( RAM, new_ram, sizeof RAM ); - ci->memcpy( this->extra_ram, RAM + ROM_ADDR, sizeof this->extra_ram ); - - /* boot rom (have to force enable_rom() to update it) */ - this->rom_enabled = !(RAM [0xF1] & 0x80); - SPC_enable_rom( this, !this->rom_enabled ); - - /* dsp */ - /* some SPCs rely on DSP immediately generating one sample */ - this->extra_cycles = 32; - DSP_reset( &this->dsp ); - int i; - for ( i = 0; i < REGISTER_COUNT; i++ ) - DSP_write( &this->dsp, i, ((uint8_t const*) dsp_state) [i] ); - - /* timers */ - for ( i = 0; i < TIMER_COUNT; i++ ) - { - struct Timer* t = &this->timer [i]; - - t->next_tick = -EXTRA_CLOCKS; - t->enabled = (RAM [0xF1] >> i) & 1; - if ( !t->enabled ) - t->next_tick = TIMER_DISABLED_TIME; - t->count = 0; - t->counter = RAM [0xFD + i] & 15; - - int p = RAM [0xFA + i]; - if ( !p ) - p = 0x100; - t->period = p; - } - - /* Handle registers which already give 0 when read by - setting RAM and not changing it. - Put STOP instruction in registers which can be read, - to catch attempted execution. */ - RAM [0xF0] = 0; - RAM [0xF1] = 0; - RAM [0xF3] = 0xFF; - RAM [0xFA] = 0; - RAM [0xFB] = 0; - RAM [0xFC] = 0; - RAM [0xFD] = 0xFF; - RAM [0xFE] = 0xFF; - RAM [0xFF] = 0xFF; -} - -static void clear_echo( THIS ) -{ - if ( !(DSP_read( &this->dsp, 0x6C ) & 0x20) ) - { - unsigned addr = 0x100 * DSP_read( &this->dsp, 0x6D ); - size_t size = 0x800 * DSP_read( &this->dsp, 0x7D ); - size_t max_size = sizeof RAM - addr; - if ( size > max_size ) - size = sizeof RAM - addr; - ci->memset( RAM + addr, 0xFF, size ); - } -} - -int SPC_load_spc( THIS, const void* data, long size ) -{ - struct spc_file_t const* spc = (struct spc_file_t const*) data; - struct cpu_regs_t regs; - - if ( size < SPC_FILE_SIZE ) - return -1; - - if ( ci->memcmp( spc->signature, "SNES-SPC700 Sound File Data", 27 ) != 0 ) - return -1; - - regs.pc = spc->pc [1] * 0x100 + spc->pc [0]; - regs.a = spc->a; - regs.x = spc->x; - regs.y = spc->y; - regs.status = spc->status; - regs.sp = spc->sp; - - if ( (unsigned long) size >= sizeof *spc ) - ci->memcpy( this->boot_rom, spc->ipl_rom, sizeof this->boot_rom ); - - SPC_load_state( this, ®s, spc->ram, spc->dsp ); - - clear_echo(this); - - return 0; -} - -/**************** DSP interaction ****************/ -static void SPC_run_dsp_( THIS, long time ) ICODE_ATTR_SPC; -static void SPC_run_dsp_( THIS, long time ) -{ - /* divide by CLOCKS_PER_SAMPLE */ - int count = ((time - this->next_dsp) >> 5) + 1; - int32_t* buf = this->sample_buf; - this->sample_buf = buf + count; - this->next_dsp += count * CLOCKS_PER_SAMPLE; - DSP_run( &this->dsp, count, buf ); -} - -static inline void SPC_run_dsp( THIS, long time ) -{ - if ( time >= this->next_dsp ) - SPC_run_dsp_( this, time ); -} - -int SPC_read( THIS, unsigned addr, long const time ) -{ - int result = RAM [addr]; - - if ( ((unsigned) (addr - 0xF0)) < 0x10 ) - { - assert( 0xF0 <= addr && addr <= 0xFF ); - - /* counters */ - int i = addr - 0xFD; - if ( i >= 0 ) - { - struct Timer* t = &this->timer [i]; - Timer_run( t, time ); - result = t->counter; - t->counter = 0; - } - /* dsp */ - else if ( addr == 0xF3 ) - { - SPC_run_dsp( this, time ); - result = DSP_read( &this->dsp, RAM [0xF2] & 0x7F ); - } - } - return result; -} - -void SPC_write( THIS, unsigned addr, int data, long const time ) -{ - /* first page is very common */ - if ( addr < 0xF0 ) - { - RAM [addr] = (uint8_t) data; - } - else switch ( addr ) - { - /* RAM */ - default: - if ( addr < ROM_ADDR ) - { - RAM [addr] = (uint8_t) data; - } - else - { - this->extra_ram [addr - ROM_ADDR] = (uint8_t) data; - if ( !this->rom_enabled ) - RAM [addr] = (uint8_t) data; - } - break; - - /* DSP */ - /*case 0xF2:*/ /* mapped to RAM */ - case 0xF3: { - SPC_run_dsp( this, time ); - int reg = RAM [0xF2]; - if ( reg < REGISTER_COUNT ) { - DSP_write( &this->dsp, reg, data ); - } - else { - /*dprintf( "DSP write to $%02X\n", (int) reg ); */ - } - break; - } - - case 0xF0: /* Test register */ - /*dprintf( "Wrote $%02X to $F0\n", (int) data ); */ - break; - - /* Config */ - case 0xF1: - { - int i; - /* timers */ - for ( i = 0; i < TIMER_COUNT; i++ ) - { - struct Timer * t = this->timer+i; - if ( !(data & (1 << i)) ) - { - t->enabled = 0; - t->next_tick = TIMER_DISABLED_TIME; - } - else if ( !t->enabled ) - { - /* just enabled */ - t->enabled = 1; - t->counter = 0; - t->count = 0; - t->next_tick = time; - } - } - - /* port clears */ - if ( data & 0x10 ) - { - RAM [0xF4] = 0; - RAM [0xF5] = 0; - } - if ( data & 0x20 ) - { - RAM [0xF6] = 0; - RAM [0xF7] = 0; - } - - SPC_enable_rom( this, (data & 0x80) != 0 ); - break; - } - - /* Ports */ - case 0xF4: - case 0xF5: - case 0xF6: - case 0xF7: - /* to do: handle output ports */ - break; - - /* verified on SNES that these are read/write (RAM) */ - /*case 0xF8: */ - /*case 0xF9: */ - - /* Timers */ - case 0xFA: - case 0xFB: - case 0xFC: { - int i = addr - 0xFA; - struct Timer* t = &this->timer [i]; - if ( (t->period & 0xFF) != data ) - { - Timer_run( t, time ); - this->timer[i].period = data ? data : 0x100; - } - break; - } - - /* Counters (cleared on write) */ - case 0xFD: - case 0xFE: - case 0xFF: - /*dprintf( "Wrote to counter $%02X\n", (int) addr ); */ - this->timer [addr - 0xFD].counter = 0; - break; - } -} - -/**************** Sample generation ****************/ -int SPC_play( THIS, long count, int32_t* out ) -{ - int i; - assert( count % 2 == 0 ); /* output is always in pairs of samples */ - - long start_time = -(count >> 1) * CLOCKS_PER_SAMPLE - EXTRA_CLOCKS; - - /* DSP output is made on-the-fly when DSP registers are read or written */ - this->sample_buf = out; - this->next_dsp = start_time + CLOCKS_PER_SAMPLE; - - /* Localize timer next_tick times and run them to the present to prevent - a running but ignored timer's next_tick from getting too far behind - and overflowing. */ - for ( i = 0; i < TIMER_COUNT; i++ ) - { - struct Timer* t = &this->timer [i]; - if ( t->enabled ) - { - t->next_tick += start_time + EXTRA_CLOCKS; - Timer_run( t, start_time ); - } - } - - /* Run from start_time to 0, pre-advancing by extra cycles from last run */ - this->extra_cycles = CPU_run( this, start_time + this->extra_cycles ) + - EXTRA_CLOCKS; - if ( this->extra_cycles < 0 ) - { - /*dprintf( "Unhandled instruction $%02X, pc = $%04X\n", - (int) CPU_read( r.pc ), (unsigned) r.pc ); */ - - return -1; - } - - /* Catch DSP up to present */ -#if 0 - ENTER_TIMER(cpu); -#endif - SPC_run_dsp( this, -EXTRA_CLOCKS ); -#if 0 - EXIT_TIMER(cpu); -#endif - assert( this->next_dsp == CLOCKS_PER_SAMPLE - EXTRA_CLOCKS ); - assert( this->sample_buf - out == count ); - - return 0; -} diff --git a/apps/codecs/libspc/spc_profiler.c b/apps/codecs/libspc/spc_profiler.c deleted file mode 100644 index 0ced8b5bd3..0000000000 --- a/apps/codecs/libspc/spc_profiler.c +++ /dev/null @@ -1,66 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2006-2007 Adam Gashlin (hcs) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ - -/* lovingly ripped off from Game_Music_Emu 0.5.2. http://www.slack.net/~ant/ */ -/* DSP Based on Brad Martin's OpenSPC DSP emulator */ -/* tag reading from sexyspc by John Brawn (John_Brawn@yahoo.com) and others */ - -#if defined(SPC_PROFILE) && defined(USEC_TIMER) - -#include "codeclib.h" -#include "spc_codec.h" -#define SPC_DEFINE_PROFILER_TIMERS -#include "spc_profiler.h" - -void reset_profile_timers(void) -{ - RESET_TIMER(total); - RESET_TIMER(render); -#if 0 - RESET_TIMER(cpu); - RESET_TIMER(dsp); - RESET_TIMER(dsp_pregen); - RESET_TIMER(dsp_gen); - RESET_TIMER(dsp_mix); -#endif -} - -void print_timers(char * path) -{ - int logfd = ci->open("/spclog.txt",O_WRONLY|O_CREAT|O_APPEND, 0666); - ci->fdprintf(logfd,"%s:\t",path); - ci->fdprintf(logfd,"%10ld total\t",READ_TIMER(total)); - PRINT_TIMER_PCT(render,total,"render"); -#if 0 - PRINT_TIMER_PCT(cpu,total,"CPU"); - PRINT_TIMER_PCT(dsp,total,"DSP"); - ci->fdprintf(logfd,"("); - PRINT_TIMER_PCT(dsp_pregen,dsp,"pregen"); - PRINT_TIMER_PCT(dsp_gen,dsp,"gen"); - PRINT_TIMER_PCT(dsp_mix,dsp,"mix"); -#endif - ci->fdprintf(logfd,"\n"); - - ci->close(logfd); - logfd=-1; -} - -#endif /* #if defined(SPC_PROFILE) && defined(USEC_TIMER) */ diff --git a/apps/codecs/libspc/spc_profiler.h b/apps/codecs/libspc/spc_profiler.h deleted file mode 100644 index 405ee43ef9..0000000000 --- a/apps/codecs/libspc/spc_profiler.h +++ /dev/null @@ -1,72 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2006-2007 Adam Gashlin (hcs) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ - -/* a fun simple elapsed time profiler */ -#ifndef _SPC_PROFILER_H_ -#define _SPC_PROFILER_H_ - -#if defined(SPC_PROFILE) && defined(USEC_TIMER) - -#ifdef SPC_DEFINE_PROFILER_TIMERS -#define CREATE_TIMER(name) uint32_t spc_timer_##name##_start,\ - spc_timer_##name##_total -#else -#define CREATE_TIMER(name) extern uint32_t spc_timer_##name##_start,\ - spc_timer_##name##_total -#endif - -#define ENTER_TIMER(name) spc_timer_##name##_start=USEC_TIMER -#define EXIT_TIMER(name) spc_timer_##name##_total+=\ - (USEC_TIMER-spc_timer_##name##_start) -#define READ_TIMER(name) (spc_timer_##name##_total) -#define RESET_TIMER(name) spc_timer_##name##_total=0 - -#define PRINT_TIMER_PCT(bname,tname,nstr) ci->fdprintf( \ - logfd,"%10ld ",READ_TIMER(bname));\ - ci->fdprintf(logfd,"(%3d%%) " nstr "\t",\ - ((uint64_t)READ_TIMER(bname))*100/READ_TIMER(tname)) - -CREATE_TIMER(total); -CREATE_TIMER(render); -#if 0 -CREATE_TIMER(cpu); -CREATE_TIMER(dsp); -CREATE_TIMER(dsp_pregen); -CREATE_TIMER(dsp_gen); -CREATE_TIMER(dsp_mix); -#endif - -void reset_profile_timers(void); -void print_timers(char * path); - -#else - -#define CREATE_TIMER(name) -#define ENTER_TIMER(name) -#define EXIT_TIMER(name) -#define READ_TIMER(name) -#define RESET_TIMER(name) -#define print_timers(path) -#define reset_profile_timers() - -#endif - -#endif /* _SPC_PROFILER_H_ */ diff --git a/apps/codecs/libspeex/COPYING b/apps/codecs/libspeex/COPYING deleted file mode 100644 index 3b6b579cf3..0000000000 --- a/apps/codecs/libspeex/COPYING +++ /dev/null @@ -1,34 +0,0 @@ -Copyright 2002-2006 - Xiph.org Foundation - Jean-Marc Valin - David Rowe - EpicGames - Analog Devices - Commonwealth Scientific and Industrial Research Organisation (CSIRO) - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - -- Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - -- Redistributions in binary form must reproduce the above copyright -notice, this list of conditions and the following disclaimer in the -documentation and/or other materials provided with the distribution. - -- Neither the name of the Xiph.org Foundation nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR -CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/apps/codecs/libspeex/README.rockbox b/apps/codecs/libspeex/README.rockbox deleted file mode 100644 index 84fff59b60..0000000000 --- a/apps/codecs/libspeex/README.rockbox +++ /dev/null @@ -1,30 +0,0 @@ -Library: libspeex-1.2beta3 (SVN version 14054) -Imported: 2007-03-12 by Dan Everton - - -This directory contains a local version of libspeex for decoding Ogg/Speex -audio streams. - - -LICENSING INFORMATION - -Speex is available under the terms of the Xiph.Org variant of the BSD -license, which is both an open source and free software license. The -license is described in the COPYING file in this directory. - - -IMPORT DETAILS - -The .[ch] files from speex/libspeex/ and speex/include/ were imported -into Rockbox. This includes the test files. Some hackery was done to -the include files so that they #include properly when built in Rockbox. - -A simple config-speex.h file was added to enable libspeex's fixed-point -integer-only mode and to specify the endianness of the target CPU. Also, -ARM specific optimisations were enabled. - -Since some parts of Speex still rely on functions, a simple -include was created to get these parts to compile. Stub functions can be -found in rockbox.c in this directory. - - diff --git a/apps/codecs/libspeex/SOURCES b/apps/codecs/libspeex/SOURCES deleted file mode 100644 index 575bcb5bae..0000000000 --- a/apps/codecs/libspeex/SOURCES +++ /dev/null @@ -1,45 +0,0 @@ -bits.c -cb_search.c -exc_10_16_table.c -exc_10_32_table.c -exc_20_32_table.c -exc_5_256_table.c -exc_5_64_table.c -exc_8_128_table.c -filters.c -gain_table.c -gain_table_lbr.c -hexc_10_32_table.c -hexc_table.c -high_lsp_tables.c -lsp.c -lsp_tables_nb.c -ltp.c -modes.c -modes_wb.c -nb_celp.c -quant_lsp.c -sb_celp.c -speex.c -speex_callbacks.c -#ifndef ROCKBOX_VOICE_CODEC -#ifndef ROCKBOX_VOICE_ENCODER -oggframing.c -#endif -stereo.c -speex_header.c -#endif -#ifdef ROCKBOX_VOICE_ENCODER -lpc.c -vbr.c -vq.c -window.c -resample.c -#else -#ifdef CPU_COLDFIRE -filters_cf.S -ltp_cf.S -#elif defined(CPU_ARM) -filters_arm4.S -#endif -#endif diff --git a/apps/codecs/libspeex/_kiss_fft_guts.h b/apps/codecs/libspeex/_kiss_fft_guts.h deleted file mode 100644 index 12c055040f..0000000000 --- a/apps/codecs/libspeex/_kiss_fft_guts.h +++ /dev/null @@ -1,166 +0,0 @@ -/* -Copyright (c) 2003-2004, Mark Borgerding - -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - * Neither the author nor the names of any contributors may be used to endorse or promote products derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifdef MIN -#undef MIN -#endif -#define MIN(a,b) ((a)<(b) ? (a):(b)) -#ifdef MAX -#undef MAX -#endif -#define MAX(a,b) ((a)>(b) ? (a):(b)) - -/* kiss_fft.h - defines kiss_fft_scalar as either short or a float type - and defines - typedef struct { kiss_fft_scalar r; kiss_fft_scalar i; }kiss_fft_cpx; */ -#include "kiss_fft.h" -#include "math_approx.h" - -#define MAXFACTORS 32 -/* e.g. an fft of length 128 has 4 factors - as far as kissfft is concerned - 4*4*4*2 - */ - -struct kiss_fft_state{ - int nfft; - int inverse; - int factors[2*MAXFACTORS]; - kiss_fft_cpx twiddles[1]; -}; - -/* - Explanation of macros dealing with complex math: - - C_MUL(m,a,b) : m = a*b - C_FIXDIV( c , div ) : if a fixed point impl., c /= div. noop otherwise - C_SUB( res, a,b) : res = a - b - C_SUBFROM( res , a) : res -= a - C_ADDTO( res , a) : res += a - * */ -#ifdef FIXED_POINT -#include "arch.h" -# define FRACBITS 15 -# define SAMPPROD spx_int32_t -#define SAMP_MAX 32767 - -#define SAMP_MIN -SAMP_MAX - -#if defined(CHECK_OVERFLOW) -# define CHECK_OVERFLOW_OP(a,op,b) \ - if ( (SAMPPROD)(a) op (SAMPPROD)(b) > SAMP_MAX || (SAMPPROD)(a) op (SAMPPROD)(b) < SAMP_MIN ) { \ - fprintf(stderr,"WARNING:overflow @ " __FILE__ "(%d): (%d " #op" %d) = %ld\n",__LINE__,(a),(b),(SAMPPROD)(a) op (SAMPPROD)(b) ); } -#endif - - -# define smul(a,b) ( (SAMPPROD)(a)*(b) ) -# define sround( x ) (kiss_fft_scalar)( ( (x) + (1<<(FRACBITS-1)) ) >> FRACBITS ) - -# define S_MUL(a,b) sround( smul(a,b) ) - -# define C_MUL(m,a,b) \ - do{ (m).r = sround( smul((a).r,(b).r) - smul((a).i,(b).i) ); \ - (m).i = sround( smul((a).r,(b).i) + smul((a).i,(b).r) ); }while(0) - -# define C_MUL4(m,a,b) \ - do{ (m).r = PSHR32( smul((a).r,(b).r) - smul((a).i,(b).i),17 ); \ - (m).i = PSHR32( smul((a).r,(b).i) + smul((a).i,(b).r),17 ); }while(0) - -# define DIVSCALAR(x,k) \ - (x) = sround( smul( x, SAMP_MAX/k ) ) - -# define C_FIXDIV(c,div) \ - do { DIVSCALAR( (c).r , div); \ - DIVSCALAR( (c).i , div); }while (0) - -# define C_MULBYSCALAR( c, s ) \ - do{ (c).r = sround( smul( (c).r , s ) ) ;\ - (c).i = sround( smul( (c).i , s ) ) ; }while(0) - -#else /* not FIXED_POINT*/ - -# define S_MUL(a,b) ( (a)*(b) ) -#define C_MUL(m,a,b) \ - do{ (m).r = (a).r*(b).r - (a).i*(b).i;\ - (m).i = (a).r*(b).i + (a).i*(b).r; }while(0) - -#define C_MUL4(m,a,b) C_MUL(m,a,b) - -# define C_FIXDIV(c,div) /* NOOP */ -# define C_MULBYSCALAR( c, s ) \ - do{ (c).r *= (s);\ - (c).i *= (s); }while(0) -#endif - -#ifndef CHECK_OVERFLOW_OP -# define CHECK_OVERFLOW_OP(a,op,b) /* noop */ -#endif - -#define C_ADD( res, a,b)\ - do { \ - CHECK_OVERFLOW_OP((a).r,+,(b).r)\ - CHECK_OVERFLOW_OP((a).i,+,(b).i)\ - (res).r=(a).r+(b).r; (res).i=(a).i+(b).i; \ - }while(0) -#define C_SUB( res, a,b)\ - do { \ - CHECK_OVERFLOW_OP((a).r,-,(b).r)\ - CHECK_OVERFLOW_OP((a).i,-,(b).i)\ - (res).r=(a).r-(b).r; (res).i=(a).i-(b).i; \ - }while(0) -#define C_ADDTO( res , a)\ - do { \ - CHECK_OVERFLOW_OP((res).r,+,(a).r)\ - CHECK_OVERFLOW_OP((res).i,+,(a).i)\ - (res).r += (a).r; (res).i += (a).i;\ - }while(0) - -#define C_SUBFROM( res , a)\ - do {\ - CHECK_OVERFLOW_OP((res).r,-,(a).r)\ - CHECK_OVERFLOW_OP((res).i,-,(a).i)\ - (res).r -= (a).r; (res).i -= (a).i; \ - }while(0) - - -#ifdef FIXED_POINT -# define KISS_FFT_COS(phase) floor(MIN(32767,MAX(-32767,.5+32768 * cos (phase)))) -# define KISS_FFT_SIN(phase) floor(MIN(32767,MAX(-32767,.5+32768 * sin (phase)))) -# define HALF_OF(x) ((x)>>1) -#elif defined(USE_SIMD) -# define KISS_FFT_COS(phase) _mm_set1_ps( cos(phase) ) -# define KISS_FFT_SIN(phase) _mm_set1_ps( sin(phase) ) -# define HALF_OF(x) ((x)*_mm_set1_ps(.5)) -#else -# define KISS_FFT_COS(phase) (kiss_fft_scalar) cos(phase) -# define KISS_FFT_SIN(phase) (kiss_fft_scalar) sin(phase) -# define HALF_OF(x) ((x)*.5) -#endif - -#define kf_cexp(x,phase) \ - do{ \ - (x)->r = KISS_FFT_COS(phase);\ - (x)->i = KISS_FFT_SIN(phase);\ - }while(0) -#define kf_cexp2(x,phase) \ - do{ \ - (x)->r = spx_cos_norm((phase));\ - (x)->i = spx_cos_norm((phase)-32768);\ -}while(0) - - -/* a debugging function */ -#define pcpx(c)\ - fprintf(stderr,"%g + %gi\n",(double)((c)->r),(double)((c)->i) ) diff --git a/apps/codecs/libspeex/arch.h b/apps/codecs/libspeex/arch.h deleted file mode 100644 index 35b5363837..0000000000 --- a/apps/codecs/libspeex/arch.h +++ /dev/null @@ -1,242 +0,0 @@ -/* Copyright (C) 2003 Jean-Marc Valin */ -/** - @file arch.h - @brief Various architecture definitions Speex -*/ -/* - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of the Xiph.org Foundation nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef ARCH_H -#define ARCH_H - -#include "config-speex.h" - -#ifndef SPEEX_VERSION -#define SPEEX_MAJOR_VERSION 1 /**< Major Speex version. */ -#define SPEEX_MINOR_VERSION 1 /**< Minor Speex version. */ -#define SPEEX_MICRO_VERSION 15 /**< Micro Speex version. */ -#define SPEEX_EXTRA_VERSION "" /**< Extra Speex version. */ -#define SPEEX_VERSION "speex-1.2beta4" /**< Speex version string. */ -#endif - -/* A couple test to catch stupid option combinations */ -#ifdef FIXED_POINT - -#ifdef FLOATING_POINT -#error You cannot compile as floating point and fixed point at the same time -#endif -#ifdef _USE_SSE -#error SSE is only for floating-point -#endif -#if ((defined (ARM4_ASM)||defined (ARM4_ASM)) && defined(BFIN_ASM)) || (defined (ARM4_ASM)&&defined(ARM5E_ASM)) -#error Make up your mind. What CPU do you have? -#endif -#ifdef VORBIS_PSYCHO -#error Vorbis-psy model currently not implemented in fixed-point -#endif - -#else - -#ifndef FLOATING_POINT -#error You now need to define either FIXED_POINT or FLOATING_POINT -#endif -#if defined (ARM4_ASM) || defined(ARM5E_ASM) || defined(BFIN_ASM) -#error I suppose you can have a [ARM4/ARM5E/Blackfin] that has float instructions? -#endif -#ifdef FIXED_POINT_DEBUG -#error "Don't you think enabling fixed-point is a good thing to do if you want to debug that?" -#endif - - -#endif - -#ifndef OUTSIDE_SPEEX -#include "speex/speex_types.h" -#endif - -#undef ABS -#define ABS(x) ((x) < 0 ? (-(x)) : (x)) /**< Absolute integer value. */ -#define ABS16(x) ((x) < 0 ? (-(x)) : (x)) /**< Absolute 16-bit value. */ -#define MIN16(a,b) ((a) < (b) ? (a) : (b)) /**< Maximum 16-bit value. */ -#define MAX16(a,b) ((a) > (b) ? (a) : (b)) /**< Maximum 16-bit value. */ -#define ABS32(x) ((x) < 0 ? (-(x)) : (x)) /**< Absolute 32-bit value. */ -#define MIN32(a,b) ((a) < (b) ? (a) : (b)) /**< Maximum 32-bit value. */ -#define MAX32(a,b) ((a) > (b) ? (a) : (b)) /**< Maximum 32-bit value. */ - -#ifdef FIXED_POINT - -typedef spx_int16_t spx_word16_t; -typedef spx_int32_t spx_word32_t; -typedef spx_word32_t spx_mem_t; -typedef spx_word16_t spx_coef_t; -typedef spx_word16_t spx_lsp_t; -typedef spx_word32_t spx_sig_t; - -#define Q15ONE 32767 - -#define LPC_SCALING 8192 -#define SIG_SCALING 16384 -#define LSP_SCALING 8192. -#define GAMMA_SCALING 32768. -#define GAIN_SCALING 64 -#define GAIN_SCALING_1 0.015625 - -#define LPC_SHIFT 13 -#define LSP_SHIFT 13 -#define SIG_SHIFT 14 -#define GAIN_SHIFT 6 - -#define VERY_SMALL 0 -#define VERY_LARGE32 ((spx_word32_t)2147483647) -#define VERY_LARGE16 ((spx_word16_t)32767) -#define Q15_ONE ((spx_word16_t)32767) - - -#ifdef FIXED_DEBUG -#include "fixed_debug.h" -#else - -#include "fixed_generic.h" - -#ifdef ARM5E_ASM -#include "fixed_arm5e.h" -#elif defined (ARM4_ASM) -#include "fixed_arm4.h" -#elif defined (BFIN_ASM) -#include "fixed_bfin.h" -#endif - -#endif - - -#else - -typedef float spx_mem_t; -typedef float spx_coef_t; -typedef float spx_lsp_t; -typedef float spx_sig_t; -typedef float spx_word16_t; -typedef float spx_word32_t; - -#define Q15ONE 1.0f -#define LPC_SCALING 1.f -#define SIG_SCALING 1.f -#define LSP_SCALING 1.f -#define GAMMA_SCALING 1.f -#define GAIN_SCALING 1.f -#define GAIN_SCALING_1 1.f - - -#define VERY_SMALL 1e-15f -#define VERY_LARGE32 1e15f -#define VERY_LARGE16 1e15f -#define Q15_ONE ((spx_word16_t)1.f) - -#define QCONST16(x,bits) (x) -#define QCONST32(x,bits) (x) - -#define NEG16(x) (-(x)) -#define NEG32(x) (-(x)) -#define EXTRACT16(x) (x) -#define EXTEND32(x) (x) -#define SHR16(a,shift) (a) -#define SHL16(a,shift) (a) -#define SHR32(a,shift) (a) -#define SHL32(a,shift) (a) -#define PSHR16(a,shift) (a) -#define PSHR32(a,shift) (a) -#define VSHR32(a,shift) (a) -#define SATURATE16(x,a) (x) -#define SATURATE32(x,a) (x) - -#define PSHR(a,shift) (a) -#define SHR(a,shift) (a) -#define SHL(a,shift) (a) -#define SATURATE(x,a) (x) - -#define ADD16(a,b) ((a)+(b)) -#define SUB16(a,b) ((a)-(b)) -#define ADD32(a,b) ((a)+(b)) -#define SUB32(a,b) ((a)-(b)) -#define MULT16_16_16(a,b) ((a)*(b)) -#define MULT16_16(a,b) ((spx_word32_t)(a)*(spx_word32_t)(b)) -#define MAC16_16(c,a,b) ((c)+(spx_word32_t)(a)*(spx_word32_t)(b)) - -#define MULT16_32_Q11(a,b) ((a)*(b)) -#define MULT16_32_Q13(a,b) ((a)*(b)) -#define MULT16_32_Q14(a,b) ((a)*(b)) -#define MULT16_32_Q15(a,b) ((a)*(b)) -#define MULT16_32_P15(a,b) ((a)*(b)) - -#define MAC16_32_Q11(c,a,b) ((c)+(a)*(b)) -#define MAC16_32_Q15(c,a,b) ((c)+(a)*(b)) - -#define MAC16_16_Q11(c,a,b) ((c)+(a)*(b)) -#define MAC16_16_Q13(c,a,b) ((c)+(a)*(b)) -#define MAC16_16_P13(c,a,b) ((c)+(a)*(b)) -#define MULT16_16_Q11_32(a,b) ((a)*(b)) -#define MULT16_16_Q13(a,b) ((a)*(b)) -#define MULT16_16_Q14(a,b) ((a)*(b)) -#define MULT16_16_Q15(a,b) ((a)*(b)) -#define MULT16_16_P15(a,b) ((a)*(b)) -#define MULT16_16_P13(a,b) ((a)*(b)) -#define MULT16_16_P14(a,b) ((a)*(b)) - -#define DIV32_16(a,b) (((spx_word32_t)(a))/(spx_word16_t)(b)) -#define PDIV32_16(a,b) (((spx_word32_t)(a))/(spx_word16_t)(b)) -#define DIV32(a,b) (((spx_word32_t)(a))/(spx_word32_t)(b)) -#define PDIV32(a,b) (((spx_word32_t)(a))/(spx_word32_t)(b)) - - -#endif - - -#if defined (CONFIG_TI_C54X) || defined (CONFIG_TI_C55X) - -/* 2 on TI C5x DSP */ -#define BYTES_PER_CHAR 2 -#define BITS_PER_CHAR 16 -#define LOG2_BITS_PER_CHAR 4 - -#else - -#define BYTES_PER_CHAR 1 -#define BITS_PER_CHAR 8 -#define LOG2_BITS_PER_CHAR 3 - -#endif - - - -#ifdef FIXED_DEBUG -long long spx_mips=0; -#endif - - -#endif diff --git a/apps/codecs/libspeex/bits.c b/apps/codecs/libspeex/bits.c deleted file mode 100644 index c7a5c14ede..0000000000 --- a/apps/codecs/libspeex/bits.c +++ /dev/null @@ -1,399 +0,0 @@ -/* Copyright (C) 2002 Jean-Marc Valin - File: speex_bits.c - - Handles bit packing/unpacking - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of the Xiph.org Foundation nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*/ - -#ifdef HAVE_CONFIG_H -#include "config-speex.h" -#endif - -#include "speex/speex_bits.h" -#include "arch.h" -#include "os_support.h" - -/* Maximum size of the bit-stream (for fixed-size allocation) */ -#ifndef MAX_CHARS_PER_FRAME -#define MAX_CHARS_PER_FRAME (2000/BYTES_PER_CHAR) -#endif - -#ifdef ROCKBOX_VOICE_ENCODER -void speex_bits_init(SpeexBits *bits) -{ - bits->chars = (char*)speex_alloc(MAX_CHARS_PER_FRAME); - if (!bits->chars) - return; - - bits->buf_size = MAX_CHARS_PER_FRAME; - - bits->owner=1; - - speex_bits_reset(bits); -} -#endif - -#if 0 -/* Rockbox: unused */ -void speex_bits_init_buffer(SpeexBits *bits, void *buff, int buf_size) -{ - bits->chars = (char*)buff; - bits->buf_size = buf_size; - - bits->owner=0; - - speex_bits_reset(bits); -} -#endif - -void speex_bits_set_bit_buffer(SpeexBits *bits, void *buff, int buf_size) -{ - bits->chars = (char*)buff; - bits->buf_size = buf_size; - - bits->owner=0; - - bits->nbBits=buf_size<charPtr=0; - bits->bitPtr=0; - bits->overflow=0; - -} - -#ifndef ROCKBOX_VOICE_CODEC -void speex_bits_destroy(SpeexBits *bits) -{ - if (bits->owner) - speex_free(bits->chars); - /* Will do something once the allocation is dynamic */ -} -#endif - -#ifdef ROCKBOX_VOICE_ENCODER -void speex_bits_reset(SpeexBits *bits) -{ - /* We only need to clear the first byte now */ - bits->chars[0]=0; - bits->nbBits=0; - bits->charPtr=0; - bits->bitPtr=0; - bits->overflow=0; -} -#endif - -#if 0 -/* Rockbox: unused */ -void speex_bits_rewind(SpeexBits *bits) -{ - bits->charPtr=0; - bits->bitPtr=0; - bits->overflow=0; -} -#endif - -#if !defined(SPEEX_VOICE_ENCODER) && !defined(ROCKBOX_VOICE_CODEC) -void speex_bits_read_from(SpeexBits *bits, char *chars, int len) -{ - int i; - int nchars = len / BYTES_PER_CHAR; - if (nchars > bits->buf_size) - { - speex_notify("Packet is larger than allocated buffer"); - if (bits->owner) - { - char *tmp = (char*)speex_realloc(bits->chars, nchars); - if (tmp) - { - bits->buf_size=nchars; - bits->chars=tmp; - } else { - nchars=bits->buf_size; - speex_warning("Could not resize input buffer: truncating input"); - } - } else { - speex_warning("Do not own input buffer: truncating oversize input"); - nchars=bits->buf_size; - } - } -#if (BYTES_PER_CHAR==2) -/* Swap bytes to proper endian order (could be done externally) */ -#define HTOLS(A) ((((A) >> 8)&0xff)|(((A) & 0xff)<<8)) -#else -#define HTOLS(A) (A) -#endif - for (i=0;ichars[i]=HTOLS(chars[i]); - - bits->nbBits=nchars<charPtr=0; - bits->bitPtr=0; - bits->overflow=0; -} - -static void speex_bits_flush(SpeexBits *bits) -{ - int nchars = ((bits->nbBits+BITS_PER_CHAR-1)>>LOG2_BITS_PER_CHAR); - if (bits->charPtr>0) - SPEEX_MOVE(bits->chars, &bits->chars[bits->charPtr], nchars-bits->charPtr); - bits->nbBits -= bits->charPtr<charPtr=0; -} - -void speex_bits_read_whole_bytes(SpeexBits *bits, char *chars, int nbytes) -{ - int i,pos; - int nchars = nbytes/BYTES_PER_CHAR; - - if (((bits->nbBits+BITS_PER_CHAR-1)>>LOG2_BITS_PER_CHAR)+nchars > bits->buf_size) - { - /* Packet is larger than allocated buffer */ - if (bits->owner) - { - char *tmp = (char*)speex_realloc(bits->chars, (bits->nbBits>>LOG2_BITS_PER_CHAR)+nchars+1); - if (tmp) - { - bits->buf_size=(bits->nbBits>>LOG2_BITS_PER_CHAR)+nchars+1; - bits->chars=tmp; - } else { - nchars=bits->buf_size-(bits->nbBits>>LOG2_BITS_PER_CHAR)-1; - speex_warning("Could not resize input buffer: truncating oversize input"); - } - } else { - speex_warning("Do not own input buffer: truncating oversize input"); - nchars=bits->buf_size; - } - } - - speex_bits_flush(bits); - pos=bits->nbBits>>LOG2_BITS_PER_CHAR; - for (i=0;ichars[pos+i]=HTOLS(chars[i]); - bits->nbBits+=nchars<bitPtr; - charPtr=bits->charPtr; - nbBits=bits->nbBits; - speex_bits_insert_terminator(bits); - bits->bitPtr=bitPtr; - bits->charPtr=charPtr; - bits->nbBits=nbBits; - - if (max_nchars > ((bits->nbBits+BITS_PER_CHAR-1)>>LOG2_BITS_PER_CHAR)) - max_nchars = ((bits->nbBits+BITS_PER_CHAR-1)>>LOG2_BITS_PER_CHAR); - - for (i=0;ichars[i]); - return max_nchars*BYTES_PER_CHAR; -} - -int speex_bits_write_whole_bytes(SpeexBits *bits, char *chars, int max_nbytes) -{ - int max_nchars = max_nbytes/BYTES_PER_CHAR; - int i; - if (max_nchars > ((bits->nbBits)>>LOG2_BITS_PER_CHAR)) - max_nchars = ((bits->nbBits)>>LOG2_BITS_PER_CHAR); - for (i=0;ichars[i]); - - if (bits->bitPtr>0) - bits->chars[0]=bits->chars[max_nchars]; - else - bits->chars[0]=0; - bits->charPtr=0; - bits->nbBits &= (BITS_PER_CHAR-1); - return max_nchars*BYTES_PER_CHAR; -} - -void speex_bits_pack(SpeexBits *bits, int data, int nbBits) -{ - unsigned int d=data; - - if (bits->charPtr+((nbBits+bits->bitPtr)>>LOG2_BITS_PER_CHAR) >= bits->buf_size) - { - speex_notify("Buffer too small to pack bits"); - if (bits->owner) - { - int new_nchars = ((bits->buf_size+5)*3)>>1; - char *tmp = (char*)speex_realloc(bits->chars, new_nchars); - if (tmp) - { - bits->buf_size=new_nchars; - bits->chars=tmp; - } else { - speex_warning("Could not resize input buffer: not packing"); - return; - } - } else { - speex_warning("Do not own input buffer: not packing"); - return; - } - } - - while(nbBits) - { - int bit; - bit = (d>>(nbBits-1))&1; - bits->chars[bits->charPtr] |= bit<<(BITS_PER_CHAR-1-bits->bitPtr); - bits->bitPtr++; - - if (bits->bitPtr==BITS_PER_CHAR) - { - bits->bitPtr=0; - bits->charPtr++; - bits->chars[bits->charPtr] = 0; - } - bits->nbBits++; - nbBits--; - } -} -#endif /* SPEEX_DISABLE_ENCODER */ - -#if 0 -/* Rockbox: unused */ -int speex_bits_unpack_signed(SpeexBits *bits, int nbBits) -{ - unsigned int d=speex_bits_unpack_unsigned(bits,nbBits); - /* If number is negative */ - if (d>>(nbBits-1)) - { - d |= (-1)<charPtr<bitPtr+nbBits>bits->nbBits) - bits->overflow=1; - if (bits->overflow) - return 0; - while(nbBits) - { - d<<=1; - d |= (bits->chars[bits->charPtr]>>(BITS_PER_CHAR-1 - bits->bitPtr))&1; - bits->bitPtr++; - if (bits->bitPtr==BITS_PER_CHAR) - { - bits->bitPtr=0; - bits->charPtr++; - } - nbBits--; - } - return d; -} - -#if 0 -/* Rockbox: unused */ -unsigned int speex_bits_peek_unsigned(SpeexBits *bits, int nbBits) -{ - unsigned int d=0; - int bitPtr, charPtr; - char *chars; - - if ((bits->charPtr<bitPtr+nbBits>bits->nbBits) - bits->overflow=1; - if (bits->overflow) - return 0; - - bitPtr=bits->bitPtr; - charPtr=bits->charPtr; - chars = bits->chars; - while(nbBits) - { - d<<=1; - d |= (chars[charPtr]>>(BITS_PER_CHAR-1 - bitPtr))&1; - bitPtr++; - if (bitPtr==BITS_PER_CHAR) - { - bitPtr=0; - charPtr++; - } - nbBits--; - } - return d; -} -#endif - -int speex_bits_peek(SpeexBits *bits) -{ - if ((bits->charPtr<bitPtr+1>bits->nbBits) - bits->overflow=1; - if (bits->overflow) - return 0; - return (bits->chars[bits->charPtr]>>(BITS_PER_CHAR-1 - bits->bitPtr))&1; -} - -void speex_bits_advance(SpeexBits *bits, int n) -{ - if (((bits->charPtr<bitPtr+n>bits->nbBits) || bits->overflow){ - bits->overflow=1; - return; - } - bits->charPtr += (bits->bitPtr+n) >> LOG2_BITS_PER_CHAR; /* divide by BITS_PER_CHAR */ - bits->bitPtr = (bits->bitPtr+n) & (BITS_PER_CHAR-1); /* modulo by BITS_PER_CHAR */ -} - -int speex_bits_remaining(SpeexBits *bits) -{ - if (bits->overflow) - return -1; - else - return bits->nbBits-((bits->charPtr<bitPtr); -} - -#if 0 -/* Rockbox: unused */ -int speex_bits_nbytes(SpeexBits *bits) -{ - return ((bits->nbBits+BITS_PER_CHAR-1)>>LOG2_BITS_PER_CHAR); -} -#endif - -#ifndef SPEEX_DISABLE_ENCODER -void speex_bits_insert_terminator(SpeexBits *bits) -{ - if (bits->bitPtr) - speex_bits_pack(bits, 0, 1); - while (bits->bitPtr) - speex_bits_pack(bits, 1, 1); -} -#endif /* SPEEX_DISABLE_ENCODER */ diff --git a/apps/codecs/libspeex/cb_search.c b/apps/codecs/libspeex/cb_search.c deleted file mode 100644 index 35fe3a2f67..0000000000 --- a/apps/codecs/libspeex/cb_search.c +++ /dev/null @@ -1,621 +0,0 @@ -/* Copyright (C) 2002-2006 Jean-Marc Valin - File: cb_search.c - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of the Xiph.org Foundation nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifdef HAVE_CONFIG_H -#include "config-speex.h" -#endif - -#include "cb_search.h" -#include "filters.h" -#include "stack_alloc.h" -#include "vq.h" -#include "arch.h" -#include "math_approx.h" -#include "os_support.h" - -#ifdef _USE_SSE -#include "cb_search_sse.h" -#elif defined(ARM4_ASM) || defined(ARM5E_ASM) -#include "cb_search_arm4.h" -#elif defined(BFIN_ASM) -#include "cb_search_bfin.h" -#endif - -#ifndef SPEEX_DISABLE_ENCODER -#ifndef OVERRIDE_COMPUTE_WEIGHTED_CODEBOOK -static void compute_weighted_codebook(const signed char *shape_cb, const spx_word16_t *r, spx_word16_t *resp, spx_word16_t *resp2, spx_word32_t *E, int shape_cb_size, int subvect_size, char *stack) -{ - int i, j, k; - VARDECL(spx_word16_t *shape); - ALLOC(shape, subvect_size, spx_word16_t); - for (i=0;isubvect_size; - nb_subvect = params->nb_subvect; - shape_cb_size = 1<shape_bits; - shape_cb = params->shape_cb; - have_sign = params->have_sign; - ALLOC(resp, shape_cb_size*subvect_size, spx_word16_t); -#ifdef _USE_SSE - ALLOC(resp2, (shape_cb_size*subvect_size)>>2, __m128); - ALLOC(E, shape_cb_size>>2, __m128); -#else - resp2 = resp; - ALLOC(E, shape_cb_size, spx_word32_t); -#endif - ALLOC(t, nsf, spx_word16_t); - ALLOC(e, nsf, spx_sig_t); - - /* FIXME: Do we still need to copy the target? */ - SPEEX_COPY(t, target, nsf); - - compute_weighted_codebook(shape_cb, r, resp, resp2, E, shape_cb_size, subvect_size, stack); - - for (i=0;ishape_bits+have_sign); - - { - int rind; - spx_word16_t *res; - spx_word16_t sign=1; - rind = best_index; - if (rind>=shape_cb_size) - { - sign=-1; - rind-=shape_cb_size; - } - res = resp+rind*subvect_size; - if (sign>0) - for (m=0;m=shape_cb_size) - { - sign=-1; - rind-=shape_cb_size; - } - - q=subvect_size-m; -#ifdef FIXED_POINT - g=sign*shape_cb[rind*subvect_size+m]; -#else - g=sign*0.03125*shape_cb[rind*subvect_size+m]; -#endif - target_update(t+subvect_size*(i+1), g, r+q, nsf-subvect_size*(i+1)); - } - } - - /* Update excitation */ - /* FIXME: We could update the excitation directly above */ - for (j=0;j10) - N=10; - /* Complexity isn't as important for the codebooks as it is for the pitch */ - N=(2*N)/3; - if (N<1) - N=1; - if (N==1) - { - split_cb_search_shape_sign_N1(target,ak,awk1,awk2,par,p,nsf,exc,r,bits,stack,update_target); - return; - } - ALLOC(ot2, N, spx_word16_t*); - ALLOC(nt2, N, spx_word16_t*); - ALLOC(oind, N, int*); - ALLOC(nind, N, int*); - - params = (const split_cb_params *) par; - subvect_size = params->subvect_size; - nb_subvect = params->nb_subvect; - shape_cb_size = 1<shape_bits; - shape_cb = params->shape_cb; - have_sign = params->have_sign; - ALLOC(resp, shape_cb_size*subvect_size, spx_word16_t); -#ifdef _USE_SSE - ALLOC(resp2, (shape_cb_size*subvect_size)>>2, __m128); - ALLOC(E, shape_cb_size>>2, __m128); -#else - resp2 = resp; - ALLOC(E, shape_cb_size, spx_word32_t); -#endif - ALLOC(t, nsf, spx_word16_t); - ALLOC(e, nsf, spx_sig_t); - ALLOC(ind, nb_subvect, int); - - ALLOC(tmp, 2*N*nsf, spx_word16_t); - for (i=0;im;n--) - { - ndist[n] = ndist[n-1]; - best_nind[n] = best_nind[n-1]; - best_ntarget[n] = best_ntarget[n-1]; - } - /* n is equal to m here, so they're interchangeable */ - ndist[m] = err; - best_nind[n] = best_index[k]; - best_ntarget[n] = j; - break; - } - } - } - } - if (i==0) - break; - } - for (j=0;j=shape_cb_size) - { - sign=-1; - rind-=shape_cb_size; - } - - q=subvect_size-m; -#ifdef FIXED_POINT - g=sign*shape_cb[rind*subvect_size+m]; -#else - g=sign*0.03125*shape_cb[rind*subvect_size+m]; -#endif - target_update(nt[j]+subvect_size*(i+1), g, r+q, nsf-subvect_size*(i+1)); - } - - for (q=0;qshape_bits+have_sign); - } - - /* Put everything back together */ - for (i=0;i=shape_cb_size) - { - sign=-1; - rind-=shape_cb_size; - } -#ifdef FIXED_POINT - if (sign==1) - { - for (j=0;jsubvect_size; - nb_subvect = params->nb_subvect; - shape_cb = params->shape_cb; - have_sign = params->have_sign; - - ALLOC(ind, nb_subvect, int); - ALLOC(signs, nb_subvect, int); - - /* Decode codewords and gains */ - for (i=0;ishape_bits); - } - /* Compute decoded excitation */ - for (i=0;i>>= 13;\n\t" - "A1 += R0.L*R0.L (IS);\n\t" - "W[P3++] = R0;\n\t" - "P0 += 1;\n\t" - "P2 += 2;\n\t" - "LOOP_END outter%=;\n\t" - "P4 = %4;\n\t" - "R1 = A1;\n\t" - "[P4] = R1;\n\t" - : - : "m" (subvect_size), "m" (shape_cb), "m" (r), "m" (resp), "m" (E) - : "A0", "P0", "P1", "P2", "P3", "P4", "R0", "R1", "R2", "I0", "I1", "L0", - "L1", "A0", "A1", "memory" -#if !(__GNUC__ == 3) - , "LC0", "LC1" /* gcc 3.4 doesn't know about LC registers */ -#endif - ); - shape_cb += subvect_size; - resp += subvect_size; - E++; - } -} - -#define OVERRIDE_TARGET_UPDATE -static inline void target_update(spx_word16_t *t, spx_word16_t g, spx_word16_t *r, int len) -{ - if (!len) - return; - __asm__ __volatile__ - ( - "I0 = %0;\n\t" - "I1 = %1;\n\t" - "L0 = 0;\n\t" - "L1 = 0;\n\t" - "R2 = 4096;\n\t" - "LOOP tupdate%= LC0 = %3;\n\t" - "LOOP_BEGIN tupdate%=;\n\t" - "R0.L = W[I0] || R1.L = W[I1++];\n\t" - "R1 = (A1 = R1.L*%2.L) (IS);\n\t" - "R1 = R1 + R2;\n\t" - "R1 >>>= 13;\n\t" - "R0.L = R0.L - R1.L;\n\t" - "W[I0++] = R0.L;\n\t" - "LOOP_END tupdate%=;\n\t" - : - : "a" (t), "a" (r), "d" (g), "a" (len) - : "R0", "R1", "R2", "A1", "I0", "I1", "L0", "L1" - ); -} diff --git a/apps/codecs/libspeex/cb_search_sse.h b/apps/codecs/libspeex/cb_search_sse.h deleted file mode 100644 index 8b039686fb..0000000000 --- a/apps/codecs/libspeex/cb_search_sse.h +++ /dev/null @@ -1,84 +0,0 @@ -/* Copyright (C) 2004 Jean-Marc Valin */ -/** - @file cb_search_sse.h - @brief Fixed codebook functions (SSE version) -*/ -/* - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of the Xiph.org Foundation nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include - -static inline void _spx_mm_getr_ps (__m128 U, float *__Z, float *__Y, float *__X, float *__W) -{ - union { - float __a[4]; - __m128 __v; - } __u; - - __u.__v = U; - - *__Z = __u.__a[0]; - *__Y = __u.__a[1]; - *__X = __u.__a[2]; - *__W = __u.__a[3]; - -} - -#define OVERRIDE_COMPUTE_WEIGHTED_CODEBOOK -static void compute_weighted_codebook(const signed char *shape_cb, const spx_sig_t *_r, float *resp, __m128 *resp2, __m128 *E, int shape_cb_size, int subvect_size, char *stack) -{ - int i, j, k; - __m128 resj, EE; - VARDECL(__m128 *r); - VARDECL(__m128 *shape); - ALLOC(r, subvect_size, __m128); - ALLOC(shape, subvect_size, __m128); - for(j=0;j>2] = EE; - } -} diff --git a/apps/codecs/libspeex/config-speex.h b/apps/codecs/libspeex/config-speex.h deleted file mode 100644 index 7e0672c150..0000000000 --- a/apps/codecs/libspeex/config-speex.h +++ /dev/null @@ -1,186 +0,0 @@ -#ifndef ROCKBOX_VOICE_ENCODER -#include "codeclib.h" -#include "autoconf.h" -#else -#define ICODE_ATTR -#define IDATA_ATTR -#define IBSS_ATTR -#define ICONST_ATTR -#endif -/* config.h. Generated from config.h.in by configure. */ -/* config.h.in. Generated from configure.ac by autoheader. */ - -#ifndef ROCKBOX_VOICE_ENCODER - -#define DISABLE_FLOAT_API -#define DISABLE_VBR - -/* Make use of ARM4E assembly optimizations */ -#if defined(CPU_ARM) -#define ARM4_ASM -#endif - -/* Make use of Coldfire assembly optimizations */ -#if defined(CPU_COLDFIRE) -#define COLDFIRE_ASM -#endif - -/* Make use of Blackfin assembly optimizations */ -/* #undef BFIN_ASM */ -#endif /* ROCKBOX_VOICE_ENCODER */ - -/* Disable wideband codec */ -/* #undef DISABLE_WIDEBAND */ - -/* Enable valgrind extra checks */ -/* #undef ENABLE_VALGRIND */ - -/* Debug fixed-point implementation */ -/* #undef FIXED_DEBUG */ - -#ifndef ROCKBOX_VOICE_ENCODER -/* Compile target codec as fixed point */ -#define FIXED_POINT -#else -/* Compile voice clip encoder as floating point */ -#define FLOATING_POINT -#endif - -#ifndef ROCKBOX_VOICE_CODEC -#define EXC_ICONST_ATTR ICONST_ATTR -#define GAIN_ICONST_ATTR ICONST_ATTR -#define HEXC_ICONST_ATTR ICONST_ATTR -#define LSP_ICONST_ATTR ICONST_ATTR -#else -#define EXC_ICONST_ATTR -#define GAIN_ICONST_ATTR -#define HEXC_ICONST_ATTR -#define LSP_ICONST_ATTR -#endif - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_DLFCN_H */ - -/* Define to 1 if you have the `getopt_long' function. */ -#define HAVE_GETOPT_LONG 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_INTTYPES_H 1 - -/* Define to 1 if you have the `m' library (-lm). */ -/* #undef HAVE_LIBM */ - -/* Define to 1 if you have the `winmm' library (-lwinmm). */ -/* #undef HAVE_LIBWINMM */ - -/* Define to 1 if you have the header file. */ -/* #define HAVE_MEMORY_H 1 */ - -/* Define to 1 if you have the header file. */ -#define HAVE_STDINT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STDLIB_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STRINGS_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STRING_H 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_SYS_AUDIOIO_H */ - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_SOUNDCARD_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_STAT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_TYPES_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_UNISTD_H 1 - -/* Define to the address where bug reports for this package should be sent. */ -#define PACKAGE_BUGREPORT "" - -/* Define to the full name of this package. */ -#define PACKAGE_NAME "" - -/* Define to the full name and version of this package. */ -#define PACKAGE_STRING "" - -/* Define to the one symbol short name of this package. */ -#define PACKAGE_TARNAME "" - -/* Define to the version of this package. */ -#define PACKAGE_VERSION "" - -/* Reduce precision to 16 bits (EXPERIMENTAL) */ -/* #undef PRECISION16 */ - -/* The size of `int', as computed by sizeof. */ -#define SIZEOF_INT 4 - -/* The size of `long', as computed by sizeof. */ -#define SIZEOF_LONG 4 - -/* The size of `short', as computed by sizeof. */ -#define SIZEOF_SHORT 2 - -/* Version extra */ -#define SPEEX_EXTRA_VERSION "-git" - -/* Version major */ -#define SPEEX_MAJOR_VERSION 1 - -/* Version micro */ -#define SPEEX_MICRO_VERSION 15 - -/* Version minor */ -#define SPEEX_MINOR_VERSION 1 - -/* Complete version string */ -#define SPEEX_VERSION "1.2beta3" - -/* Define to 1 if you have the ANSI C header files. */ -#define STDC_HEADERS 1 - -/* Enable support for TI C55X DSP */ -/* #undef TI_C55X */ - -/* Make use of alloca */ -/* #undef USE_ALLOCA */ - -/* Use C99 variable-size arrays */ -#define VAR_ARRAYS - -/* Enable Vorbis-style psychoacoustics (EXPERIMENTAL) */ -/* #undef VORBIS_PSYCHO */ - -/* Define to 1 if your processor stores words with the most significant byte - first (like Motorola and SPARC, unlike Intel and VAX). */ -#ifdef ROCKBOX_BIG_ENDIAN -#define WORDS_BIGENDIAN 1 -#endif - -/* Enable SSE support */ -/* #undef _USE_SSE */ - -/* Define to empty if `const' does not conform to ANSI C. */ -/* #undef const */ - -/* Define to `__inline__' or `__inline' if that's what the C compiler - calls it, or to nothing if 'inline' is not supported under any name. */ -#ifndef __cplusplus -/* #undef inline */ -#endif - -/* Define to equivalent of C99 restrict keyword, or to nothing if this is not - supported. Do not define if restrict is supported directly. */ -#define restrict __restrict - -#define RELEASE 1 - diff --git a/apps/codecs/libspeex/exc_10_16_table.c b/apps/codecs/libspeex/exc_10_16_table.c deleted file mode 100644 index 755c5a0b7f..0000000000 --- a/apps/codecs/libspeex/exc_10_16_table.c +++ /dev/null @@ -1,51 +0,0 @@ -/* Copyright (C) 2002 Jean-Marc Valin - File: exc_10_16_table.c - Codebook for excitation in narrowband CELP mode (3200 bps) - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of the Xiph.org Foundation nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include "config-speex.h" - -const signed char exc_10_16_table[160] EXC_ICONST_ATTR = { -22,39,14,44,11,35,-2,23,-4,6, -46,-28,13,-27,-23,12,4,20,-5,9, -37,-18,-23,23,0,9,-6,-20,4,-1, --17,-5,-4,17,0,1,9,-2,1,2, -2,-12,8,-25,39,15,9,16,-55,-11, -9,11,5,10,-2,-60,8,13,-6,11, --16,27,-47,-12,11,1,16,-7,9,-3, --29,9,-14,25,-19,34,36,12,40,-10, --3,-24,-14,-37,-21,-35,-2,-36,3,-6, -67,28,6,-17,-3,-12,-16,-15,-17,-7, --59,-36,-13,1,7,1,2,10,2,11, -13,10,8,-2,7,3,5,4,2,2, --3,-8,4,-5,6,7,-42,15,35,-2, --46,38,28,-20,-9,1,7,-3,0,-2, -0,0,0,0,0,0,0,0,0,0, --15,-28,52,32,5,-5,-17,-20,-10,-1}; diff --git a/apps/codecs/libspeex/exc_10_32_table.c b/apps/codecs/libspeex/exc_10_32_table.c deleted file mode 100644 index 1c94b5511c..0000000000 --- a/apps/codecs/libspeex/exc_10_32_table.c +++ /dev/null @@ -1,67 +0,0 @@ -/* Copyright (C) 2002 Jean-Marc Valin - File: exc_10_32_table.c - Codebook for excitation in narrowband CELP mode (4000 bps) - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of the Xiph.org Foundation nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include "config-speex.h" - -const signed char exc_10_32_table[320] EXC_ICONST_ATTR = { -7,17,17,27,25,22,12,4,-3,0, -28,-36,39,-24,-15,3,-9,15,-5,10, -31,-28,11,31,-21,9,-11,-11,-2,-7, --25,14,-22,31,4,-14,19,-12,14,-5, -4,-7,4,-5,9,0,-2,42,-47,-16, -1,8,0,9,23,-57,0,28,-11,6, --31,55,-45,3,-5,4,2,-2,4,-7, --3,6,-2,7,-3,12,5,8,54,-10, -8,-7,-8,-24,-25,-27,-14,-5,8,5, -44,23,5,-9,-11,-11,-13,-9,-12,-8, --29,-8,-22,6,-15,3,-12,-1,-5,-3, -34,-1,29,-16,17,-4,12,2,1,4, --2,-4,2,-1,11,-3,-52,28,30,-9, --32,25,44,-20,-24,4,6,-1,0,0, -0,0,0,0,0,0,0,0,0,0, --25,-10,22,29,13,-13,-22,-13,-4,0, --4,-16,10,15,-36,-24,28,25,-1,-3, -66,-33,-11,-15,6,0,3,4,-2,5, -24,-20,-47,29,19,-2,-4,-1,0,-1, --2,3,1,8,-11,5,5,-57,28,28, -0,-16,4,-4,12,-6,-1,2,-20,61, --9,24,-22,-42,29,6,17,8,4,2, --65,15,8,10,5,6,5,3,2,-2, --3,5,-9,4,-5,23,13,23,-3,-63, -3,-5,-4,-6,0,-3,23,-36,-46,9, -5,5,8,4,9,-5,1,-3,10,1, --6,10,-11,24,-47,31,22,-12,14,-10, -6,11,-7,-7,7,-31,51,-12,-6,7, -6,-17,9,-11,-20,52,-19,3,-6,-6, --8,-5,23,-41,37,1,-21,10,-14,8, -7,5,-15,-15,23,39,-26,-33,7,2, --32,-30,-21,-8,4,12,17,15,14,11}; diff --git a/apps/codecs/libspeex/exc_20_32_table.c b/apps/codecs/libspeex/exc_20_32_table.c deleted file mode 100644 index 40dbb34e9e..0000000000 --- a/apps/codecs/libspeex/exc_20_32_table.c +++ /dev/null @@ -1,67 +0,0 @@ -/* Copyright (C) 2002 Jean-Marc Valin - File: exc_20_32_table.c - Codebook for excitation in narrowband CELP mode (2000 bps) - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of the Xiph.org Foundation nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include "config-speex.h" - -const signed char exc_20_32_table[640] EXC_ICONST_ATTR = { -12,32,25,46,36,33,9,14,-3,6,1,-8,0,-10,-5,-7,-7,-7,-5,-5, -31,-27,24,-32,-4,10,-11,21,-3,19,23,-9,22,24,-10,-1,-10,-13,-7,-11, -42,-33,31,19,-8,0,-10,-16,1,-21,-17,10,-8,14,8,4,11,-2,5,-2, --33,11,-16,33,11,-4,9,-4,11,2,6,-5,8,-5,11,-4,-6,26,-36,-16, -0,4,-2,-8,12,6,-1,34,-46,-22,9,9,21,9,5,-66,-5,26,2,10, -13,2,19,9,12,-81,3,13,13,0,-14,22,-35,6,-7,-4,6,-6,10,-6, --31,38,-33,0,-10,-11,5,-12,12,-17,5,0,-6,13,-9,10,8,25,33,2, --12,8,-6,10,-2,21,7,17,43,5,11,-7,-9,-20,-36,-20,-23,-4,-4,-3, -27,-9,-9,-49,-39,-38,-11,-9,6,5,23,25,5,3,3,4,1,2,-3,-1, -87,39,17,-21,-9,-19,-9,-15,-13,-14,-17,-11,-10,-11,-8,-6,-1,-3,-3,-1, --54,-34,-27,-8,-11,-4,-5,0,0,4,8,6,9,7,9,7,6,5,5,5, -48,10,19,-10,12,-1,9,-3,2,5,-3,2,-2,-2,0,-2,-26,6,9,-7, --16,-9,2,7,7,-5,-43,11,22,-11,-9,34,37,-15,-13,-6,1,-1,1,1, --64,56,52,-11,-27,5,4,3,1,2,1,3,-1,-4,-4,-10,-7,-4,-4,2, --1,-7,-7,-12,-10,-15,-9,-5,-5,-11,-16,-13,6,16,4,-13,-16,-10,-4,2, --47,-13,25,47,19,-14,-20,-8,-17,0,-3,-13,1,6,-17,-14,15,1,10,6, --24,0,-10,19,-69,-8,14,49,17,-5,33,-29,3,-4,0,2,-8,5,-6,2, -120,-56,-12,-47,23,-9,6,-5,1,2,-5,1,-10,4,-1,-1,4,-1,0,-3, -30,-52,-67,30,22,11,-1,-4,3,0,7,2,0,1,-10,-4,-8,-13,5,1, -1,-1,5,13,-9,-3,-10,-62,22,48,-4,-6,2,3,5,1,1,4,1,13, -3,-20,10,-9,13,-2,-4,9,-20,44,-1,20,-32,-67,19,0,28,11,8,2, --11,15,-19,-53,31,2,34,10,6,-4,-58,8,10,13,14,1,12,2,0,0, --128,37,-8,44,-9,26,-3,18,2,6,11,-1,9,1,5,3,0,1,1,2, -12,3,-2,-3,7,25,9,18,-6,-37,3,-8,-16,3,-10,-7,17,-34,-44,11, -17,-15,-3,-16,-1,-13,11,-46,-65,-2,8,13,2,4,4,5,15,5,9,6, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, --9,19,-12,12,-28,38,29,-1,12,2,5,23,-10,3,4,-15,21,-4,3,3, -6,17,-9,-4,-8,-20,26,5,-10,6,1,-19,18,-15,-12,47,-6,-2,-7,-9, --1,-17,-2,-2,-14,30,-14,2,-7,-4,-1,-12,11,-25,16,-3,-12,11,-7,7, --17,1,19,-28,31,-7,-10,7,-10,3,12,5,-16,6,24,41,-29,-54,0,1, -7,-1,5,-6,13,10,-4,-8,8,-9,-27,-53,-38,-1,10,19,17,16,12,12, -0,3,-7,-4,13,12,-31,-14,6,-5,3,5,17,43,50,25,10,1,-6,-2}; diff --git a/apps/codecs/libspeex/exc_5_256_table.c b/apps/codecs/libspeex/exc_5_256_table.c deleted file mode 100644 index 1a32057956..0000000000 --- a/apps/codecs/libspeex/exc_5_256_table.c +++ /dev/null @@ -1,291 +0,0 @@ -/* Copyright (C) 2002 Jean-Marc Valin - File: exc_5_256_table.c - Codebook for excitation in narrowband CELP mode (12800 bps) - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of the Xiph.org Foundation nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include "config-speex.h" - -const signed char exc_5_256_table[1280] EXC_ICONST_ATTR = { --8,-37,5,-43,5, -73,61,39,12,-3, --61,-32,2,42,30, --3,17,-27,9,34, -20,-1,-5,2,23, --7,-46,26,53,-47, -20,-2,-33,-89,-51, --64,27,11,15,-34, --5,-56,25,-9,-1, --29,1,40,67,-23, --16,16,33,19,7, -14,85,22,-10,-10, --12,-7,-1,52,89, -29,11,-20,-37,-46, --15,17,-24,-28,24, -2,1,0,23,-101, -23,14,-1,-23,-18, -9,5,-13,38,1, --28,-28,4,27,51, --26,34,-40,35,47, -54,38,-54,-26,-6, -42,-25,13,-30,-36, -18,41,-4,-33,23, --32,-7,-4,51,-3, -17,-52,56,-47,36, --2,-21,36,10,8, --33,31,19,9,-5, --40,10,-9,-21,19, -18,-78,-18,-5,0, --26,-36,-47,-51,-44, -18,40,27,-2,29, -49,-26,2,32,-54, -30,-73,54,3,-5, -36,22,53,10,-1, --84,-53,-29,-5,3, --44,53,-51,4,22, -71,-35,-1,33,-5, --27,-7,36,17,-23, --39,16,-9,-55,-15, --20,39,-35,6,-39, --14,18,48,-64,-17, --15,9,39,81,37, --68,37,47,-21,-6, --104,13,6,9,-2, -35,8,-23,18,42, -45,21,33,-5,-49, -9,-6,-43,-56,39, -2,-16,-25,87,1, --3,-9,17,-25,-11, --9,-1,10,2,-14, --14,4,-1,-10,28, --23,40,-32,26,-9, -26,4,-27,-23,3, -42,-60,1,49,-3, -27,10,-52,-40,-2, -18,45,-23,17,-44, -3,-3,17,-46,52, --40,-47,25,75,31, --49,53,30,-30,-32, --36,38,-6,-15,-16, -54,-27,-48,3,38, --29,-32,-22,-14,-4, --23,-13,32,-39,9, -8,-45,-13,34,-16, -49,40,32,31,28, -23,23,32,47,59, --68,8,62,44,25, --14,-24,-65,-16,36, -67,-25,-38,-21,4, --33,-2,42,5,-63, -40,11,26,-42,-23, --61,79,-31,23,-20, -10,-32,53,-25,-36, -10,-26,-5,3,0, --71,5,-10,-37,1, --24,21,-54,-17,1, --29,-25,-15,-27,32, -68,45,-16,-37,-18, --5,1,0,-77,71, --6,3,-20,71,-67, -29,-35,10,-30,19, -4,16,17,5,0, --14,19,2,28,26, -59,3,2,24,39, -55,-50,-45,-18,-17, -33,-35,14,-1,1, -8,87,-35,-29,0, --27,13,-7,23,-13, -37,-40,50,-35,14, -19,-7,-14,49,54, --5,22,-2,-29,-8, --27,38,13,27,48, -12,-41,-21,-15,28, -7,-16,-24,-19,-20, -11,-20,9,2,13, -23,-20,11,27,-27, -71,-69,8,2,-6, -22,12,16,16,9, --16,-8,-17,1,25, -1,40,-37,-33,66, -94,53,4,-22,-25, --41,-42,25,35,-16, --15,57,31,-29,-32, -21,16,-60,45,15, --1,7,57,-26,-47, --29,11,8,15,19, --105,-8,54,27,10, --17,6,-12,-1,-10, -4,0,23,-10,31, -13,11,10,12,-64, -23,-3,-8,-19,16, -52,24,-40,16,10, -40,5,9,0,-13, --7,-21,-8,-6,-7, --21,59,16,-53,18, --60,11,-47,14,-18, -25,-13,-24,4,-39, -16,-28,54,26,-67, -30,27,-20,-52,20, --12,55,12,18,-16, -39,-14,-6,-26,56, --88,-55,12,25,26, --37,6,75,0,-34, --81,54,-30,1,-7, -49,-23,-14,21,10, --62,-58,-57,-47,-34, -15,-4,34,-78,31, -25,-11,7,50,-10, -42,-63,14,-36,-4, -57,55,57,53,42, --42,-1,15,40,37, -15,25,-11,6,1, -31,-2,-6,-1,-7, --64,34,28,30,-1, -3,21,0,-88,-12, --56,25,-28,40,8, --28,-14,9,12,2, --6,-17,22,49,-6, --26,14,28,-20,4, --12,50,35,40,13, --38,-58,-29,17,30, -22,60,26,-54,-39, --12,58,-28,-63,10, --21,-8,-12,26,-62, -6,-10,-11,-22,-6, --7,4,1,18,2, --70,11,14,4,13, -19,-24,-34,24,67, -17,51,-21,13,23, -54,-30,48,1,-13, -80,26,-16,-2,13, --4,6,-30,29,-24, -73,-58,30,-27,20, --2,-21,41,45,30, --27,-3,-5,-18,-20, --49,-3,-35,10,42, --19,-67,-53,-11,9, -13,-15,-33,-51,-30, -15,7,25,-30,4, -28,-22,-34,54,-29, -39,-46,20,16,34, --4,47,75,1,-44, --55,-24,7,-1,9, --42,50,-8,-36,41, -68,0,-4,-10,-23, --15,-50,64,36,-9, --27,12,25,-38,-47, --37,32,-49,51,-36, -2,-4,69,-26,19, -7,45,67,46,13, --63,46,15,-47,4, --41,13,-6,5,-21, -37,26,-55,-7,33, --1,-28,10,-17,-64, --14,0,-36,-17,93, --3,-9,-66,44,-21, -3,-12,38,-6,-13, --12,19,13,43,-43, --10,-12,6,-5,9, --49,32,-5,2,4, -5,15,-16,10,-21, -8,-62,-8,64,8, -79,-1,-66,-49,-18, -5,40,-5,-30,-45, -1,-6,21,-32,93, --18,-30,-21,32,21, --18,22,8,5,-41, --54,80,22,-10,-7, --8,-23,-64,66,56, --14,-30,-41,-46,-14, --29,-37,27,-14,42, --2,-9,-29,34,14, -33,-14,22,4,10, -26,26,28,32,23, --72,-32,3,0,-14, -35,-42,-78,-32,6, -29,-18,-45,-5,7, --33,-45,-3,-22,-34, -8,-8,4,-51,-25, --9,59,-78,21,-5, --25,-48,66,-15,-17, --24,-49,-13,25,-23, --64,-6,40,-24,-19, --11,57,-33,-8,1, -10,-52,-54,28,39, -49,34,-11,-61,-41, --43,10,15,-15,51, -30,15,-51,32,-34, --2,-34,14,18,16, -1,1,-3,-3,1, -1,-18,6,16,48, -12,-5,-42,7,36, -48,7,-20,-10,7, -12,2,54,39,-38, -37,54,4,-11,-8, --46,-10,5,-10,-34, -46,-12,29,-37,39, -36,-11,24,56,17, -14,20,25,0,-25, --28,55,-7,-5,27, -3,9,-26,-8,6, --24,-10,-30,-31,-34, -18,4,22,21,40, --1,-29,-37,-8,-21, -92,-29,11,-3,11, -73,23,22,7,4, --44,-9,-11,21,-13, -11,9,-78,-1,47, -114,-12,-37,-19,-5, --11,-22,19,12,-30, -7,38,45,-21,-8, --9,55,-45,56,-21, -7,17,46,-57,-87, --6,27,31,31,7, --56,-12,46,21,-5, --12,36,3,3,-21, -43,19,12,-7,9, --14,0,-9,-33,-91, -7,26,3,-11,64, -83,-31,-46,25,2, -9,5,2,2,-1, -20,-17,10,-5,-27, --8,20,8,-19,16, --21,-13,-31,5,5, -42,24,9,34,-20, -28,-61,22,11,-39, -64,-20,-1,-30,-9, --20,24,-25,-24,-29, -22,-60,6,-5,41, --9,-87,14,34,15, --57,52,69,15,-3, --102,58,16,3,6, -60,-75,-32,26,7, --57,-27,-32,-24,-21, --29,-16,62,-46,31, -30,-27,-15,7,15}; diff --git a/apps/codecs/libspeex/exc_5_64_table.c b/apps/codecs/libspeex/exc_5_64_table.c deleted file mode 100644 index 7d29f60373..0000000000 --- a/apps/codecs/libspeex/exc_5_64_table.c +++ /dev/null @@ -1,99 +0,0 @@ -/* Copyright (C) 2002 Jean-Marc Valin - File: exc_5_64_table.c - Codebook for excitation in narrowband CELP mode (9600 bps) - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of the Xiph.org Foundation nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include "config-speex.h" - -const signed char exc_5_64_table[320] EXC_ICONST_ATTR = { -1,5,-15,49,-66, --48,-4,50,-44,7, -37,16,-18,25,-26, --26,-15,19,19,-27, --47,28,57,5,-17, --32,-41,68,21,-2, -64,56,8,-16,-13, --26,-9,-16,11,6, --39,25,-19,22,-31, -20,-45,55,-43,10, --16,47,-40,40,-20, --51,3,-17,-14,-15, --24,53,-20,-46,46, -27,-68,32,3,-18, --5,9,-31,16,-9, --10,-1,-23,48,95, -47,25,-41,-32,-3, -15,-25,-55,36,41, --27,20,5,13,14, --22,5,2,-23,18, -46,-15,17,-18,-34, --5,-8,27,-55,73, -16,2,-1,-17,40, --78,33,0,2,19, -4,53,-16,-15,-16, --28,-3,-13,49,8, --7,-29,27,-13,32, -20,32,-61,16,14, -41,44,40,24,20, -7,4,48,-60,-77, -17,-6,-48,65,-15, -32,-30,-71,-10,-3, --6,10,-2,-7,-29, --56,67,-30,7,-5, -86,-6,-10,0,5, --31,60,34,-38,-3, -24,10,-2,30,23, -24,-41,12,70,-43, -15,-17,6,13,16, --13,8,30,-15,-8, -5,23,-34,-98,-4, --13,13,-48,-31,70, -12,31,25,24,-24, -26,-7,33,-16,8, -5,-11,-14,-8,-65, -13,10,-2,-9,0, --3,-68,5,35,7, -0,-31,-1,-17,-9, --9,16,-37,-18,-1, -69,-48,-28,22,-21, --11,5,49,55,23, --86,-36,16,2,13, -63,-51,30,-11,13, -24,-18,-6,14,-19, -1,41,9,-5,27, --36,-44,-34,-37,-21, --26,31,-39,15,43, -5,-8,29,20,-8, --20,-52,-28,-1,13, -26,-34,-10,-9,27, --8,8,27,-66,4, -12,-22,49,10,-77, -32,-18,3,-38,12, --3,-1,2,2,0}; diff --git a/apps/codecs/libspeex/exc_8_128_table.c b/apps/codecs/libspeex/exc_8_128_table.c deleted file mode 100644 index 02a58e052c..0000000000 --- a/apps/codecs/libspeex/exc_8_128_table.c +++ /dev/null @@ -1,163 +0,0 @@ -/* Copyright (C) 2002 Jean-Marc Valin - File: exc_8_128_table.c - Codebook for excitation in narrowband CELP mode (7000 bps) - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of the Xiph.org Foundation nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include "config-speex.h" - -const signed char exc_8_128_table[1024] EXC_ICONST_ATTR = { --14,9,13,-32,2,-10,31,-10, --8,-8,6,-4,-1,10,-64,23, -6,20,13,6,8,-22,16,34, -7,42,-49,-28,5,26,4,-15, -41,34,41,32,33,24,23,14, -8,40,34,4,-24,-41,-19,-15, -13,-13,33,-54,24,27,-44,33, -27,-15,-15,24,-19,14,-36,14, --9,24,-12,-4,37,-5,16,-34, -5,10,33,-15,-54,-16,12,25, -12,1,2,0,3,-1,-4,-4, -11,2,-56,54,27,-20,13,-6, --46,-41,-33,-11,-5,7,12,14, --14,-5,8,20,6,3,4,-8, --5,-42,11,8,-14,25,-2,2, -13,11,-22,39,-9,9,5,-45, --9,7,-9,12,-7,34,-17,-102, -7,2,-42,18,35,-9,-34,11, --5,-2,3,22,46,-52,-25,-9, --94,8,11,-5,-5,-5,4,-7, --35,-7,54,5,-32,3,24,-9, --22,8,65,37,-1,-12,-23,-6, --9,-28,55,-33,14,-3,2,18, --60,41,-17,8,-16,17,-11,0, --11,29,-28,37,9,-53,33,-14, --9,7,-25,-7,-11,26,-32,-8, -24,-21,22,-19,19,-10,29,-14, -0,0,0,0,0,0,0,0, --5,-52,10,41,6,-30,-4,16, -32,22,-27,-22,32,-3,-28,-3, -3,-35,6,17,23,21,8,2, -4,-45,-17,14,23,-4,-31,-11, --3,14,1,19,-11,2,61,-8, -9,-12,7,-10,12,-3,-24,99, --48,23,50,-37,-5,-23,0,8, --14,35,-64,-5,46,-25,13,-1, --49,-19,-15,9,34,50,25,11, --6,-9,-16,-20,-32,-33,-32,-27, -10,-8,12,-15,56,-14,-32,33, -3,-9,1,65,-9,-9,-10,-2, --6,-23,9,17,3,-28,13,-32, -4,-2,-10,4,-16,76,12,-52, -6,13,33,-6,4,-14,-9,-3, -1,-15,-16,28,1,-15,11,16, -9,4,-21,-37,-40,-6,22,12, --15,-23,-14,-17,-16,-9,-10,-9, -13,-39,41,5,-9,16,-38,25, -46,-47,4,49,-14,17,-2,6, -18,5,-6,-33,-22,44,50,-2, -1,3,-6,7,7,-3,-21,38, --18,34,-14,-41,60,-13,6,16, --24,35,19,-13,-36,24,3,-17, --14,-10,36,44,-44,-29,-3,3, --54,-8,12,55,26,4,-2,-5, -2,-11,22,-23,2,22,1,-25, --39,66,-49,21,-8,-2,10,-14, --60,25,6,10,27,-25,16,5, --2,-9,26,-13,-20,58,-2,7, -52,-9,2,5,-4,-15,23,-1, --38,23,8,27,-6,0,-27,-7, -39,-10,-14,26,11,-45,-12,9, --5,34,4,-35,10,43,-22,-11, -56,-7,20,1,10,1,-26,9, -94,11,-27,-14,-13,1,-11,0, -14,-5,-6,-10,-4,-15,-8,-41, -21,-5,1,-28,-8,22,-9,33, --23,-4,-4,-12,39,4,-7,3, --60,80,8,-17,2,-6,12,-5, -1,9,15,27,31,30,27,23, -61,47,26,10,-5,-8,-12,-13, -5,-18,25,-15,-4,-15,-11,12, --2,-2,-16,-2,-6,24,12,11, --4,9,1,-9,14,-45,57,12, -20,-35,26,11,-64,32,-10,-10, -42,-4,-9,-16,32,24,7,10, -52,-11,-57,29,0,8,0,-6, -17,-17,-56,-40,7,20,18,12, --6,16,5,7,-1,9,1,10, -29,12,16,13,-2,23,7,9, --3,-4,-5,18,-64,13,55,-25, -9,-9,24,14,-25,15,-11,-40, --30,37,1,-19,22,-5,-31,13, --2,0,7,-4,16,-67,12,66, --36,24,-8,18,-15,-23,19,0, --45,-7,4,3,-13,13,35,5, -13,33,10,27,23,0,-7,-11, -43,-74,36,-12,2,5,-8,6, --33,11,-16,-14,-5,-7,-3,17, --34,27,-16,11,-9,15,33,-31, -8,-16,7,-6,-7,63,-55,-17, -11,-1,20,-46,34,-30,6,9, -19,28,-9,5,-24,-8,-23,-2, -31,-19,-16,-5,-15,-18,0,26, -18,37,-5,-15,-2,17,5,-27, -21,-33,44,12,-27,-9,17,11, -25,-21,-31,-7,13,33,-8,-25, --7,7,-10,4,-6,-9,48,-82, --23,-8,6,11,-23,3,-3,49, --29,25,31,4,14,16,9,-4, --18,10,-26,3,5,-44,-9,9, --47,-55,15,9,28,1,4,-3, -46,6,-6,-38,-29,-31,-15,-6, -3,0,14,-6,8,-54,-50,33, --5,1,-14,33,-48,26,-4,-5, --3,-5,-3,-5,-28,-22,77,55, --1,2,10,10,-9,-14,-66,-49, -11,-36,-6,-20,10,-10,16,12, -4,-1,-16,45,-44,-50,31,-2, -25,42,23,-32,-22,0,11,20, --40,-35,-40,-36,-32,-26,-21,-13, -52,-22,6,-24,-20,17,-5,-8, -36,-25,-11,21,-26,6,34,-8, -7,20,-3,5,-25,-8,18,-5, --9,-4,1,-9,20,20,39,48, --24,9,5,-65,22,29,4,3, --43,-11,32,-6,9,19,-27,-10, --47,-14,24,10,-7,-36,-7,-1, --4,-5,-5,16,53,25,-26,-29, --4,-12,45,-58,-34,33,-5,2, --1,27,-48,31,-15,22,-5,4, -7,7,-25,-3,11,-22,16,-12, -8,-3,7,-11,45,14,-73,-19, -56,-46,24,-20,28,-12,-2,-1, --36,-3,-33,19,-6,7,2,-15, -5,-31,-45,8,35,13,20,0, --9,48,-13,-43,-3,-13,2,-5, -72,-68,-27,2,1,-2,-7,5, -36,33,-40,-12,-4,-5,23,19}; diff --git a/apps/codecs/libspeex/fftwrap.c b/apps/codecs/libspeex/fftwrap.c deleted file mode 100644 index 2312f755d6..0000000000 --- a/apps/codecs/libspeex/fftwrap.c +++ /dev/null @@ -1,288 +0,0 @@ -/* Copyright (C) 2005-2006 Jean-Marc Valin - File: fftwrap.c - - Wrapper for various FFTs - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of the Xiph.org Foundation nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*/ - -#ifdef HAVE_CONFIG_H -#include "config-speex.h" -#endif - -/*#define USE_SMALLFT*/ -#define USE_KISS_FFT - - -#include "arch.h" -#include "os_support.h" - -#define MAX_FFT_SIZE 2048 - -#ifdef FIXED_POINT -static int maximize_range(spx_word16_t *in, spx_word16_t *out, spx_word16_t bound, int len) -{ - int i, shift; - spx_word16_t max_val = 0; - for (i=0;imax_val) - max_val = in[i]; - if (-in[i]>max_val) - max_val = -in[i]; - } - shift=0; - while (max_val <= (bound>>1) && max_val != 0) - { - max_val <<= 1; - shift++; - } - for (i=0;i - -void *spx_fft_init(int size) -{ - struct drft_lookup *table; - table = speex_alloc(sizeof(struct drft_lookup)); - spx_drft_init((struct drft_lookup *)table, size); - return (void*)table; -} - -void spx_fft_destroy(void *table) -{ - spx_drft_clear(table); - speex_free(table); -} - -void spx_fft(void *table, float *in, float *out) -{ - if (in==out) - { - int i; - float scale = 1./((struct drft_lookup *)table)->n; - speex_warning("FFT should not be done in-place"); - for (i=0;i<((struct drft_lookup *)table)->n;i++) - out[i] = scale*in[i]; - } else { - int i; - float scale = 1./((struct drft_lookup *)table)->n; - for (i=0;i<((struct drft_lookup *)table)->n;i++) - out[i] = scale*in[i]; - } - spx_drft_forward((struct drft_lookup *)table, out); -} - -void spx_ifft(void *table, float *in, float *out) -{ - if (in==out) - { - speex_warning("FFT should not be done in-place"); - } else { - int i; - for (i=0;i<((struct drft_lookup *)table)->n;i++) - out[i] = in[i]; - } - spx_drft_backward((struct drft_lookup *)table, out); -} - -#elif defined(USE_KISS_FFT) - -#include "kiss_fftr.h" -#include "kiss_fft.h" - -struct kiss_config { - kiss_fftr_cfg forward; - kiss_fftr_cfg backward; - int N; -}; - -void *spx_fft_init(int size) -{ - struct kiss_config *table; - table = (struct kiss_config*)speex_alloc(sizeof(struct kiss_config)); - table->forward = kiss_fftr_alloc(size,0,NULL,NULL); - table->backward = kiss_fftr_alloc(size,1,NULL,NULL); - table->N = size; - return table; -} - -void spx_fft_destroy(void *table) -{ - struct kiss_config *t = (struct kiss_config *)table; - kiss_fftr_free(t->forward); - kiss_fftr_free(t->backward); - speex_free(table); -} - -#ifdef FIXED_POINT - -void spx_fft(void *table, spx_word16_t *in, spx_word16_t *out) -{ - int shift; - struct kiss_config *t = (struct kiss_config *)table; - shift = maximize_range(in, in, 32000, t->N); - kiss_fftr2(t->forward, in, out); - renorm_range(in, in, shift, t->N); - renorm_range(out, out, shift, t->N); -} - -#else - -void spx_fft(void *table, spx_word16_t *in, spx_word16_t *out) -{ - int i; - float scale; - struct kiss_config *t = (struct kiss_config *)table; - scale = 1./t->N; - kiss_fftr2(t->forward, in, out); - for (i=0;iN;i++) - out[i] *= scale; -} -#endif - -void spx_ifft(void *table, spx_word16_t *in, spx_word16_t *out) -{ - struct kiss_config *t = (struct kiss_config *)table; - kiss_fftri2(t->backward, in, out); -} - - -#else - -#error No other FFT implemented - -#endif - - -#ifdef FIXED_POINT -/*#include "smallft.h"*/ - - -void spx_fft_float(void *table, float *in, float *out) -{ - int i; -#ifdef USE_SMALLFT - int N = ((struct drft_lookup *)table)->n; -#elif defined(USE_KISS_FFT) - int N = ((struct kiss_config *)table)->N; -#else -#endif -#ifdef VAR_ARRAYS - spx_word16_t _in[N]; - spx_word16_t _out[N]; -#else - spx_word16_t _in[MAX_FFT_SIZE]; - spx_word16_t _out[MAX_FFT_SIZE]; -#endif - for (i=0;iN); - scale = 1./((struct kiss_config *)table)->N; - for (i=0;i<((struct kiss_config *)table)->N;i++) - out[i] = scale*in[i]; - spx_drft_forward(&t, out); - spx_drft_clear(&t); - } -#endif -} - -void spx_ifft_float(void *table, float *in, float *out) -{ - int i; -#ifdef USE_SMALLFT - int N = ((struct drft_lookup *)table)->n; -#elif defined(USE_KISS_FFT) - int N = ((struct kiss_config *)table)->N; -#else -#endif -#ifdef VAR_ARRAYS - spx_word16_t _in[N]; - spx_word16_t _out[N]; -#else - spx_word16_t _in[MAX_FFT_SIZE]; - spx_word16_t _out[MAX_FFT_SIZE]; -#endif - for (i=0;iN); - for (i=0;i<((struct kiss_config *)table)->N;i++) - out[i] = in[i]; - spx_drft_backward(&t, out); - spx_drft_clear(&t); - } -#endif -} - -#else - -void spx_fft_float(void *table, float *in, float *out) -{ - spx_fft(table, in, out); -} -void spx_ifft_float(void *table, float *in, float *out) -{ - spx_ifft(table, in, out); -} - -#endif diff --git a/apps/codecs/libspeex/fftwrap.h b/apps/codecs/libspeex/fftwrap.h deleted file mode 100644 index dfaf489441..0000000000 --- a/apps/codecs/libspeex/fftwrap.h +++ /dev/null @@ -1,58 +0,0 @@ -/* Copyright (C) 2005 Jean-Marc Valin - File: fftwrap.h - - Wrapper for various FFTs - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of the Xiph.org Foundation nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*/ - -#ifndef FFTWRAP_H -#define FFTWRAP_H - -#include "arch.h" - -/** Compute tables for an FFT */ -void *spx_fft_init(int size); - -/** Destroy tables for an FFT */ -void spx_fft_destroy(void *table); - -/** Forward (real to half-complex) transform */ -void spx_fft(void *table, spx_word16_t *in, spx_word16_t *out); - -/** Backward (half-complex to real) transform */ -void spx_ifft(void *table, spx_word16_t *in, spx_word16_t *out); - -/** Forward (real to half-complex) transform of float data */ -void spx_fft_float(void *table, float *in, float *out); - -/** Backward (half-complex to real) transform of float data */ -void spx_ifft_float(void *table, float *in, float *out); - -#endif diff --git a/apps/codecs/libspeex/filterbank.c b/apps/codecs/libspeex/filterbank.c deleted file mode 100644 index d2a8f1af90..0000000000 --- a/apps/codecs/libspeex/filterbank.c +++ /dev/null @@ -1,227 +0,0 @@ -/* Copyright (C) 2006 Jean-Marc Valin */ -/** - @file filterbank.c - @brief Converting between psd and filterbank - */ -/* - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are - met: - - 1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - 3. The name of the author may not be used to endorse or promote products - derived from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, - INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifdef HAVE_CONFIG_H -#include "config-speex.h" -#endif - -#include "filterbank.h" -#include "arch.h" -#include -#include "math_approx.h" -#include "os_support.h" - -#ifdef FIXED_POINT - -#define toBARK(n) (MULT16_16(26829,spx_atan(SHR32(MULT16_16(97,n),2))) + MULT16_16(4588,spx_atan(MULT16_32_Q15(20,MULT16_16(n,n)))) + MULT16_16(3355,n)) - -#else -#define toBARK(n) (13.1f*atan(.00074f*(n))+2.24f*atan((n)*(n)*1.85e-8f)+1e-4f*(n)) -#endif - -#define toMEL(n) (2595.f*log10(1.f+(n)/700.f)) - -FilterBank *filterbank_new(int banks, spx_word32_t sampling, int len, int type) -{ - FilterBank *bank; - spx_word32_t df; - spx_word32_t max_mel, mel_interval; - int i; - int id1; - int id2; - df = DIV32(SHL32(sampling,15),MULT16_16(2,len)); - max_mel = toBARK(EXTRACT16(sampling/2)); - mel_interval = PDIV32(max_mel,banks-1); - - bank = (FilterBank*)speex_alloc(sizeof(FilterBank)); - bank->nb_banks = banks; - bank->len = len; - bank->bank_left = (int*)speex_alloc(len*sizeof(int)); - bank->bank_right = (int*)speex_alloc(len*sizeof(int)); - bank->filter_left = (spx_word16_t*)speex_alloc(len*sizeof(spx_word16_t)); - bank->filter_right = (spx_word16_t*)speex_alloc(len*sizeof(spx_word16_t)); - /* Think I can safely disable normalisation that for fixed-point (and probably float as well) */ -#ifndef FIXED_POINT - bank->scaling = (float*)speex_alloc(banks*sizeof(float)); -#endif - for (i=0;i max_mel) - break; -#ifdef FIXED_POINT - id1 = DIV32(mel,mel_interval); -#else - id1 = (int)(floor(mel/mel_interval)); -#endif - if (id1>banks-2) - { - id1 = banks-2; - val = Q15_ONE; - } else { - val = DIV32_16(mel - id1*mel_interval,EXTRACT16(PSHR32(mel_interval,15))); - } - id2 = id1+1; - bank->bank_left[i] = id1; - bank->filter_left[i] = SUB16(Q15_ONE,val); - bank->bank_right[i] = id2; - bank->filter_right[i] = val; - } - - /* Think I can safely disable normalisation for fixed-point (and probably float as well) */ -#ifndef FIXED_POINT - for (i=0;inb_banks;i++) - bank->scaling[i] = 0; - for (i=0;ilen;i++) - { - int id = bank->bank_left[i]; - bank->scaling[id] += bank->filter_left[i]; - id = bank->bank_right[i]; - bank->scaling[id] += bank->filter_right[i]; - } - for (i=0;inb_banks;i++) - bank->scaling[i] = Q15_ONE/(bank->scaling[i]); -#endif - return bank; -} - -void filterbank_destroy(FilterBank *bank) -{ - speex_free(bank->bank_left); - speex_free(bank->bank_right); - speex_free(bank->filter_left); - speex_free(bank->filter_right); -#ifndef FIXED_POINT - speex_free(bank->scaling); -#endif - speex_free(bank); -} - -void filterbank_compute_bank32(FilterBank *bank, spx_word32_t *ps, spx_word32_t *mel) -{ - int i; - for (i=0;inb_banks;i++) - mel[i] = 0; - - for (i=0;ilen;i++) - { - int id; - id = bank->bank_left[i]; - mel[id] += MULT16_32_P15(bank->filter_left[i],ps[i]); - id = bank->bank_right[i]; - mel[id] += MULT16_32_P15(bank->filter_right[i],ps[i]); - } - /* Think I can safely disable normalisation that for fixed-point (and probably float as well) */ -#ifndef FIXED_POINT - /*for (i=0;inb_banks;i++) - mel[i] = MULT16_32_P15(Q15(bank->scaling[i]),mel[i]); - */ -#endif -} - -void filterbank_compute_psd16(FilterBank *bank, spx_word16_t *mel, spx_word16_t *ps) -{ - int i; - for (i=0;ilen;i++) - { - spx_word32_t tmp; - int id1, id2; - id1 = bank->bank_left[i]; - id2 = bank->bank_right[i]; - tmp = MULT16_16(mel[id1],bank->filter_left[i]); - tmp += MULT16_16(mel[id2],bank->filter_right[i]); - ps[i] = EXTRACT16(PSHR32(tmp,15)); - } -} - - -#ifndef FIXED_POINT -void filterbank_compute_bank(FilterBank *bank, float *ps, float *mel) -{ - int i; - for (i=0;inb_banks;i++) - mel[i] = 0; - - for (i=0;ilen;i++) - { - int id = bank->bank_left[i]; - mel[id] += bank->filter_left[i]*ps[i]; - id = bank->bank_right[i]; - mel[id] += bank->filter_right[i]*ps[i]; - } - for (i=0;inb_banks;i++) - mel[i] *= bank->scaling[i]; -} - -void filterbank_compute_psd(FilterBank *bank, float *mel, float *ps) -{ - int i; - for (i=0;ilen;i++) - { - int id = bank->bank_left[i]; - ps[i] = mel[id]*bank->filter_left[i]; - id = bank->bank_right[i]; - ps[i] += mel[id]*bank->filter_right[i]; - } -} - -void filterbank_psy_smooth(FilterBank *bank, float *ps, float *mask) -{ - /* Low freq slope: 14 dB/Bark*/ - /* High freq slope: 9 dB/Bark*/ - /* Noise vs tone: 5 dB difference */ - /* FIXME: Temporary kludge */ - float bark[100]; - int i; - /* Assumes 1/3 Bark resolution */ - float decay_low = 0.34145f; - float decay_high = 0.50119f; - filterbank_compute_bank(bank, ps, bark); - for (i=1;inb_banks;i++) - { - /*float decay_high = 13-1.6*log10(bark[i-1]); - decay_high = pow(10,(-decay_high/30.f));*/ - bark[i] = bark[i] + decay_high*bark[i-1]; - } - for (i=bank->nb_banks-2;i>=0;i--) - { - bark[i] = bark[i] + decay_low*bark[i+1]; - } - filterbank_compute_psd(bank, bark, mask); -} - -#endif diff --git a/apps/codecs/libspeex/filterbank.h b/apps/codecs/libspeex/filterbank.h deleted file mode 100644 index 3e889a22f7..0000000000 --- a/apps/codecs/libspeex/filterbank.h +++ /dev/null @@ -1,66 +0,0 @@ -/* Copyright (C) 2006 Jean-Marc Valin */ -/** - @file filterbank.h - @brief Converting between psd and filterbank - */ -/* - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are - met: - - 1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - 3. The name of the author may not be used to endorse or promote products - derived from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, - INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef FILTERBANK_H -#define FILTERBANK_H - -#include "arch.h" - -typedef struct { - int *bank_left; - int *bank_right; - spx_word16_t *filter_left; - spx_word16_t *filter_right; -#ifndef FIXED_POINT - float *scaling; -#endif - int nb_banks; - int len; -} FilterBank; - - -FilterBank *filterbank_new(int banks, spx_word32_t sampling, int len, int type); - -void filterbank_destroy(FilterBank *bank); - -void filterbank_compute_bank32(FilterBank *bank, spx_word32_t *ps, spx_word32_t *mel); - -void filterbank_compute_psd16(FilterBank *bank, spx_word16_t *mel, spx_word16_t *psd); - -#ifndef FIXED_POINT -void filterbank_compute_bank(FilterBank *bank, float *psd, float *mel); -void filterbank_compute_psd(FilterBank *bank, float *mel, float *psd); -#endif - - -#endif diff --git a/apps/codecs/libspeex/filters.c b/apps/codecs/libspeex/filters.c deleted file mode 100644 index 09f93c2a59..0000000000 --- a/apps/codecs/libspeex/filters.c +++ /dev/null @@ -1,845 +0,0 @@ -/* Copyright (C) 2002-2006 Jean-Marc Valin - File: filters.c - Various analysis/synthesis filters - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of the Xiph.org Foundation nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifdef HAVE_CONFIG_H -#include "config-speex.h" -#endif - -#include "filters.h" -#include "stack_alloc.h" -#include "arch.h" -#include "math_approx.h" -#include "ltp.h" -#include - -#ifdef _USE_SSE -#include "filters_sse.h" -#elif defined (ARM4_ASM) || defined(ARM5E_ASM) -#include "filters_arm4.h" -#define OVERRIDE_IIR_MEM16 -#define OVERRIDE_QMF_SYNTH -#define OVERRIDE_SIGNAL_MUL -#elif defined (COLDFIRE_ASM) -#define OVERRIDE_IIR_MEM16 -#define OVERRIDE_QMF_SYNTH -#define OVERRIDE_SIGNAL_MUL -#elif defined (BFIN_ASM) -#include "filters_bfin.h" -#endif - - - -void bw_lpc(spx_word16_t gamma, const spx_coef_t *lpc_in, spx_coef_t *lpc_out, int order) -{ - int i; - spx_word16_t tmp=gamma; - for (i=0;i=min_val && vec[i] <= max_val)) - { - if (vec[i] < min_val) - vec[i] = min_val; - else if (vec[i] > max_val) - vec[i] = max_val; - else /* Has to be NaN */ - vec[i] = 0; - } - } -} - -void highpass(const spx_word16_t *x, spx_word16_t *y, int len, int filtID, spx_mem_t *mem) -{ - int i; -#ifdef FIXED_POINT - static const spx_word16_t Pcoef[5][3] ICONST_ATTR = {{16384, -31313, 14991}, {16384, -31569, 15249}, {16384, -31677, 15328}, {16384, -32313, 15947}, {16384, -22446, 6537}}; - static const spx_word16_t Zcoef[5][3] ICONST_ATTR = {{15672, -31344, 15672}, {15802, -31601, 15802}, {15847, -31694, 15847}, {16162, -32322, 16162}, {14418, -28836, 14418}}; -#else - const spx_word16_t Pcoef[5][3] = {{1.00000f, -1.91120f, 0.91498f}, {1.00000f, -1.92683f, 0.93071f}, {1.00000f, -1.93338f, 0.93553f}, {1.00000f, -1.97226f, 0.97332f}, {1.00000f, -1.37000f, 0.39900f}}; - const spx_word16_t Zcoef[5][3] = {{0.95654f, -1.91309f, 0.95654f}, {0.96446f, -1.92879f, 0.96446f}, {0.96723f, -1.93445f, 0.96723f}, {0.98645f, -1.97277f, 0.98645f}, {0.88000f, -1.76000f, 0.88000f}}; -#endif - const spx_word16_t *den, *num; - if (filtID>4) - filtID=4; - - den = Pcoef[filtID]; num = Zcoef[filtID]; - /*return;*/ - for (i=0;i SHL32(EXTEND32(SIG_SCALING), 8)) - { - spx_word16_t scale_1; - scale = PSHR32(scale, SIG_SHIFT); - scale_1 = EXTRACT16(PDIV32_16(SHL32(EXTEND32(SIG_SCALING),7),scale)); - for (i=0;i SHR32(EXTEND32(SIG_SCALING), 2)) { - spx_word16_t scale_1; - scale = PSHR32(scale, SIG_SHIFT-5); - scale_1 = DIV32_16(SHL32(EXTEND32(SIG_SCALING),3),scale); - for (i=0;i max_val) - max_val = tmp; - } - - sig_shift=0; - while (max_val>16383) - { - sig_shift++; - max_val >>= 1; - } - - for (i=0;i max_val) - max_val = tmp; - } - if (max_val>16383) - { - spx_word32_t sum=0; - for (i=0;i= max_val) - max_val = tmp; - } - - sig_shift=0; - while (max_val>max_scale) - { - sig_shift++; - max_val >>= 1; - } - - for (i=0;i>1; - for (i=0;i>1; - N2 = N>>1; - ALLOC(xx1, M2+N2, spx_word16_t); - ALLOC(xx2, M2+N2, spx_word16_t); - - for (i = 0; i < N2; i++) - xx1[i] = x1[N2-1-i]; - for (i = 0; i < M2; i++) - xx1[N2+i] = mem1[2*i+1]; - for (i = 0; i < N2; i++) - xx2[i] = x2[N2-1-i]; - for (i = 0; i < M2; i++) - xx2[N2+i] = mem2[2*i+1]; - - for (i = 0; i < N2; i += 2) { - spx_sig_t y0, y1, y2, y3; - spx_word16_t x10, x20; - - y0 = y1 = y2 = y3 = 0; - x10 = xx1[N2-2-i]; - x20 = xx2[N2-2-i]; - - for (j = 0; j < M2; j += 2) { - spx_word16_t x11, x21; - spx_word16_t a0, a1; - - a0 = a[2*j]; - a1 = a[2*j+1]; - x11 = xx1[N2-1+j-i]; - x21 = xx2[N2-1+j-i]; - -#ifdef FIXED_POINT - /* We multiply twice by the same coef to avoid overflows */ - y0 = MAC16_16(MAC16_16(y0, a0, x11), NEG16(a0), x21); - y1 = MAC16_16(MAC16_16(y1, a1, x11), a1, x21); - y2 = MAC16_16(MAC16_16(y2, a0, x10), NEG16(a0), x20); - y3 = MAC16_16(MAC16_16(y3, a1, x10), a1, x20); -#else - y0 = ADD32(y0,MULT16_16(a0, x11-x21)); - y1 = ADD32(y1,MULT16_16(a1, x11+x21)); - y2 = ADD32(y2,MULT16_16(a0, x10-x20)); - y3 = ADD32(y3,MULT16_16(a1, x10+x20)); -#endif - a0 = a[2*j+2]; - a1 = a[2*j+3]; - x10 = xx1[N2+j-i]; - x20 = xx2[N2+j-i]; - -#ifdef FIXED_POINT - /* We multiply twice by the same coef to avoid overflows */ - y0 = MAC16_16(MAC16_16(y0, a0, x10), NEG16(a0), x20); - y1 = MAC16_16(MAC16_16(y1, a1, x10), a1, x20); - y2 = MAC16_16(MAC16_16(y2, a0, x11), NEG16(a0), x21); - y3 = MAC16_16(MAC16_16(y3, a1, x11), a1, x21); -#else - y0 = ADD32(y0,MULT16_16(a0, x10-x20)); - y1 = ADD32(y1,MULT16_16(a1, x10+x20)); - y2 = ADD32(y2,MULT16_16(a0, x11-x21)); - y3 = ADD32(y3,MULT16_16(a1, x11+x21)); -#endif - } -#ifdef FIXED_POINT - y[2*i] = EXTRACT16(SATURATE32(PSHR32(y0,15),32767)); - y[2*i+1] = EXTRACT16(SATURATE32(PSHR32(y1,15),32767)); - y[2*i+2] = EXTRACT16(SATURATE32(PSHR32(y2,15),32767)); - y[2*i+3] = EXTRACT16(SATURATE32(PSHR32(y3,15),32767)); -#else - /* Normalize up explicitly if we're in float */ - y[2*i] = 2.f*y0; - y[2*i+1] = 2.f*y1; - y[2*i+2] = 2.f*y2; - y[2*i+3] = 2.f*y3; -#endif - } - - for (i = 0; i < M2; i++) - mem1[2*i+1] = xx1[i]; - for (i = 0; i < M2; i++) - mem2[2*i+1] = xx2[i]; -} -#endif - -#ifdef FIXED_POINT -#if 0 -const spx_word16_t shift_filt[3][7] = {{-33, 1043, -4551, 19959, 19959, -4551, 1043}, - {-98, 1133, -4425, 29179, 8895, -2328, 444}, - {444, -2328, 8895, 29179, -4425, 1133, -98}}; -#else -const spx_word16_t shift_filt[3][7] = {{-390, 1540, -4993, 20123, 20123, -4993, 1540}, - {-1064, 2817, -6694, 31589, 6837, -990, -209}, - {-209, -990, 6837, 31589, -6694, 2817, -1064}}; -#endif -#else -#if 0 -const float shift_filt[3][7] = {{-9.9369e-04, 3.1831e-02, -1.3889e-01, 6.0910e-01, 6.0910e-01, -1.3889e-01, 3.1831e-02}, - {-0.0029937, 0.0345613, -0.1350474, 0.8904793, 0.2714479, -0.0710304, 0.0135403}, - {0.0135403, -0.0710304, 0.2714479, 0.8904793, -0.1350474, 0.0345613, -0.0029937}}; -#else -const float shift_filt[3][7] = {{-0.011915f, 0.046995f, -0.152373f, 0.614108f, 0.614108f, -0.152373f, 0.046995f}, - {-0.0324855f, 0.0859768f, -0.2042986f, 0.9640297f, 0.2086420f, -0.0302054f, -0.0063646f}, - {-0.0063646f, -0.0302054f, 0.2086420f, 0.9640297f, -0.2042986f, 0.0859768f, -0.0324855f}}; -#endif -#endif - -static int interp_pitch( -spx_word16_t *exc, /*decoded excitation*/ -spx_word16_t *interp, /*decoded excitation*/ -int pitch, /*pitch period*/ -int len -) -{ - int i,j,k; - spx_word32_t corr[4][7]; - spx_word32_t maxcorr; - int maxi, maxj; - for (i=0;i<7;i++) - { - corr[0][i] = inner_prod(exc, exc-pitch-3+i, len); - } - for (i=0;i<3;i++) - { - for (j=0;j<7;j++) - { - int i1, i2; - spx_word32_t tmp=0; - i1 = 3-j; - if (i1<0) - i1 = 0; - i2 = 10-j; - if (i2>7) - i2 = 7; - for (k=i1;k maxcorr) - { - maxcorr = corr[i][j]; - maxi=i; - maxj=j; - } - } - } - for (i=0;i0) - { - for (k=0;k<7;k++) - { - tmp += MULT16_16(exc[i-(pitch-maxj+3)+k-3],shift_filt[maxi-1][k]); - } - } else { - tmp = SHL32(exc[i-(pitch-maxj+3)],15); - } - interp[i] = PSHR32(tmp,15); - } - return pitch-maxj+3; -} - -void multicomb( -spx_word16_t *exc, /*decoded excitation*/ -spx_word16_t *new_exc, /*enhanced excitation*/ -spx_coef_t *ak, /*LPC filter coefs*/ -int p, /*LPC order*/ -int nsf, /*sub-frame size*/ -int pitch, /*pitch period*/ -int max_pitch, -spx_word16_t comb_gain, /*gain of comb filter*/ -char *stack -) -{ - (void)ak; - (void)p; - (void)stack; - int i; - VARDECL(spx_word16_t *iexc); - spx_word16_t old_ener, new_ener; - int corr_pitch; - - spx_word16_t iexc0_mag, iexc1_mag, exc_mag; - spx_word32_t corr0, corr1; - spx_word16_t gain0, gain1; - spx_word16_t pgain1, pgain2; - spx_word16_t c1, c2; - spx_word16_t g1, g2; - spx_word16_t ngain; - spx_word16_t gg1, gg2; -#ifdef FIXED_POINT - int scaledown=0; -#endif -#if 0 /* Set to 1 to enable full pitch search */ - int nol_pitch[6]; - spx_word16_t nol_pitch_coef[6]; - spx_word16_t ol_pitch_coef; - open_loop_nbest_pitch(exc, 20, 120, nsf, - nol_pitch, nol_pitch_coef, 6, stack); - corr_pitch=nol_pitch[0]; - ol_pitch_coef = nol_pitch_coef[0]; - /*Try to remove pitch multiples*/ - for (i=1;i<6;i++) - { -#ifdef FIXED_POINT - if ((nol_pitch_coef[i]>MULT16_16_Q15(nol_pitch_coef[0],19661)) && -#else - if ((nol_pitch_coef[i]>.6*nol_pitch_coef[0]) && -#endif - (ABS(2*nol_pitch[i]-corr_pitch)<=2 || ABS(3*nol_pitch[i]-corr_pitch)<=3 || - ABS(4*nol_pitch[i]-corr_pitch)<=4 || ABS(5*nol_pitch[i]-corr_pitch)<=5)) - { - corr_pitch = nol_pitch[i]; - } - } -#else - corr_pitch = pitch; -#endif - - ALLOC(iexc, 2*nsf, spx_word16_t); - - interp_pitch(exc, iexc, corr_pitch, 80); - if (corr_pitch>max_pitch) - interp_pitch(exc, iexc+nsf, 2*corr_pitch, 80); - else - interp_pitch(exc, iexc+nsf, -corr_pitch, 80); - -#ifdef FIXED_POINT - for (i=0;i16383) - { - scaledown = 1; - break; - } - } - if (scaledown) - { - for (i=0;i MULT16_16(iexc0_mag,exc_mag)) - pgain1 = QCONST16(1., 14); - else - pgain1 = PDIV32_16(SHL32(PDIV32(corr0, exc_mag),14),iexc0_mag); - if (corr1 > MULT16_16(iexc1_mag,exc_mag)) - pgain2 = QCONST16(1., 14); - else - pgain2 = PDIV32_16(SHL32(PDIV32(corr1, exc_mag),14),iexc1_mag); - gg1 = PDIV32_16(SHL32(EXTEND32(exc_mag),8), iexc0_mag); - gg2 = PDIV32_16(SHL32(EXTEND32(exc_mag),8), iexc1_mag); - if (comb_gain>0) - { -#ifdef FIXED_POINT - c1 = (MULT16_16_Q15(QCONST16(.4,15),comb_gain)+QCONST16(.07,15)); - c2 = QCONST16(.5,15)+MULT16_16_Q14(QCONST16(1.72,14),(c1-QCONST16(.07,15))); -#else - c1 = .4*comb_gain+.07; - c2 = .5+1.72*(c1-.07); -#endif - } else - { - c1=c2=0; - } -#ifdef FIXED_POINT - g1 = 32767 - MULT16_16_Q13(MULT16_16_Q15(c2, pgain1),pgain1); - g2 = 32767 - MULT16_16_Q13(MULT16_16_Q15(c2, pgain2),pgain2); -#else - g1 = 1-c2*pgain1*pgain1; - g2 = 1-c2*pgain2*pgain2; -#endif - if (g1max_pitch) - { - gain0 = MULT16_16_Q15(QCONST16(.7,15),MULT16_16_Q14(g1,gg1)); - gain1 = MULT16_16_Q15(QCONST16(.3,15),MULT16_16_Q14(g2,gg2)); - } else { - gain0 = MULT16_16_Q15(QCONST16(.6,15),MULT16_16_Q14(g1,gg1)); - gain1 = MULT16_16_Q15(QCONST16(.6,15),MULT16_16_Q14(g2,gg2)); - } - for (i=0;i new_ener) - old_ener = new_ener; - ngain = PDIV32_16(SHL32(EXTEND32(old_ener),14),new_ener); - - for (i=0;i> 13 + x[i] - mov r5, #0x7f00 - orr r5, r5, #0xff @ r5 = 32767 - cmp r14, r5 - movgt r14, r5 @ Clip positive - cmn r14, r5 - rsblt r14, r5, #0 @ Clip negative - strh r14, [r2], #2 @ Write result to y[i] - - ldrsh r4, [r1] - mul r5, r4, r14 - sub r5, r6, r5 @ mem[0] = mem[1] - den[0]*y[i] - ldrsh r4, [r1, #2] - mul r6, r4, r14 - sub r6, r7, r6 @ mem[1] = mem[2] - den[1]*y[i] - ldrsh r4, [r1, #4] - mul r7, r4, r14 - sub r7, r8, r7 @ mem[2] = mem[3] - den[2]*y[i] - ldrsh r4, [r1, #6] - mul r8, r4, r14 - sub r8, r9, r8 @ mem[3] = mem[4] - den[3]*y[i] - ldrsh r4, [r1, #8] - mul r9, r4, r14 - sub r9, r10, r9 @ mem[4] = mem[5] - den[4]*y[i] - ldrsh r4, [r1, #10] - mul r10, r4, r14 - sub r10, r11, r10 @ mem[5] = mem[6] - den[5]*y[i] - ldrsh r4, [r1, #12] - mul r11, r4, r14 - sub r11, r12, r11 @ mem[6] = mem[7] - den[6]*y[i] - ldrsh r4, [r1, #14] - mul r12, r4, r14 - rsb r12, r12, #0 @ mem[7] = -den[7]*y[i] - subs r3, r3, #1 - bne 0b - ldr r4, [sp, #40] @ r4 = mem - stmia r4, { r5-r12 } @ Save back mem[] - ldmpc regs=r4-r11 @ Exit - -.order_10: - ldmia r4, { r5-r9 } @ r5-r9 = mem[0..4] - add r5, r5, #4096 @ Rounding constant - ldrsh r14, [r0], #2 - add r14, r14, r5, asr #13 @ (mem[0] + 4096) >> 13 + x[i] - mov r5, #0x7f00 - orr r5, r5, #0xff @ r5 = 32767 - cmp r14, r5 - movgt r14, r5 @ Clip positive - cmn r14, r5 - rsblt r14, r5, #0 @ Clip negative - strh r14, [r2], #2 @ Write result to y[i] - - ldmia r1!, { r10-r12 } @ r10-r12 = den[0..5] - mov r5, r10, lsl #16 - mov r5, r5, asr #16 - mul r5, r14, r5 - sub r5, r6, r5 @ mem[0] = mem[1] - den[0]*y[i] - mov r10, r10, asr #16 - mul r6, r14, r10 - sub r6, r7, r6 @ mem[1] = mem[2] - den[1]*y[i] - mov r10, r11, lsl #16 - mov r10, r10, asr #16 - mul r7, r14, r10 - sub r7, r8, r7 @ mem[2] = mem[3] - den[2]*y[i] - mov r10, r11, asr #16 - mul r8, r14, r10 - sub r8, r9, r8 @ mem[3] = mem[4] - den[3]*y[i] - stmia r4!, { r5-r8 } @ Write back mem[0..3], r4 = &mem[4] - mov r10, r12, lsl #16 - mov r10, r10, asr #16 - mul r5, r14, r10 - - ldmib r4, { r6-r10 } @ r6-r10 = mem[5..9] - sub r5, r6, r5 @ mem[4] = mem[5] - den[4]*y[i] - mov r12, r12, asr #16 - mul r6, r14, r12 - sub r6, r7, r6 @ mem[5] = mem[6] - den[5]*y[i] - ldmia r1!, { r11-r12 } @ r11-r12 = den[6..9] - mov r7, r11, lsl #16 - mov r7, r7, asr #16 - mul r7, r14, r7 - sub r7, r8, r7 @ mem[6] = mem[7] - den[6]*y[i] - mov r11, r11, asr #16 - mul r8, r14, r11 - sub r8, r9, r8 @ mem[7] = mem[8] - den[7]*y[i] - mov r11, r12, lsl #16 - mov r11, r11, asr #16 - mul r9, r14, r11 - sub r9, r10, r9 @ mem[8] = mem[9] - den[8]*y[i] - mov r12, r12, asr #16 - mul r10, r14, r12 - rsb r10, r10, #0 @ mem[9] = -den[9]*y[i] - stmia r4!, { r5-r10 } @ Write back mem[4..9] - sub r4, r4, #10*4 - sub r1, r1, #10*2 - subs r3, r3, #1 - bne .order_10 - ldmpc regs=r4-r11 @ Exit - - -/* void qmf_synth(const spx_word16_t *x1, const spx_word16_t *x2, const spx_word16_t *a, spx_word16_t *y, int N, int M, spx_word32_t *mem1, spx_word32_t *mem2, char *stack) */ - .global qmf_synth -qmf_synth: - stmdb sp!, { r4-r11, lr } - add r7, sp, #36 @ r0 = x1, r1 = x2, r2 = a, r3 = y - ldmia r7, { r4-r7 } @ r4 = N, r5 = M, r6 = mem1, r7 = mem2 - - add r8, r4, r5 - sub r9, sp, r8 @ r9 = sp - (N + M >> 1) = xx2 - sub r8, r9, r8 @ r8 = r9 - (N + M >> 1) = xx1 - str sp, [r8, #-4] @ Stack old sp - sub sp, r8, #4 @ Update sp - - add r0, r0, r4 @ x1 += N >> 1 - add r1, r1, r4 @ x2 += N >> 1 - mov r14, r4 @ Loop counter is N -0: - @ Backwards copy x1 and x2 arrays to xx1 and xx2, assume N2 is power of two - @ N should always be a multiple of four, so this should be OK - ldmdb r0!, { r10-r11 } - mov r12, r10, ror #16 - mov r11, r11, ror #16 - stmia r8!, { r11-r12 } - ldmdb r1!, { r10-r11 } - mov r12, r10, ror #16 - mov r11, r11, ror #16 - stmia r9!, { r11-r12 } - subs r14, r14, #8 - bne 0b - - @ Copy alternate members of mem1 and mem2 to last part of xx1 and xx2 - mov r14, r5 @ Loop counter is M - add r6, r6, #2 - add r7, r7, #2 - stmdb sp!, { r6-r7 } @ Stack &mem1[1], &mem2[1] -0: - ldrh r10, [r6], #4 - ldrh r11, [r6], #4 - ldrh r12, [r7], #4 - orr r10, r10, r11, lsl #16 - ldrh r11, [r7], #4 - orr r11, r12, r11, lsl #16 - str r10, [r8], #4 - str r11, [r9], #4 - subs r14, r14, #4 - bne 0b - - sub r0, r8, r5 @ r0 = &xx1[N2] - sub r1, r9, r5 @ r1 = &xx2[N2] - str r4, [sp, #-4]! @ Stack N - mov r4, r5 - str r4, [sp, #-4]! @ Stack M - @ Main loop, register usage: - @ r0 = xx1, r1 = xx2, r2 = a, r3 = y, r4 = M, r5 = x10, r6 = x11, r7 = x20 - @ r8 = x21, r9 = [a1, a0], r10 = acc0, r11 = acc1, r12 = acc2, r14 = acc3 -0: @ Outerloop - mov r10, #16384 @ Init acccumulators to rounding const - mov r11, #16384 - mov r12, #16384 - mov r14, #16384 - - ldrsh r5, [r0, #-4]! @ r5 = x10, r0 = &xx1[N2 - 2] - ldrsh r7, [r1, #-4]! @ r7 = x20, r1 = &xx2[N2 - 2] -1: @ Innerloop - ldrsh r9, [r2], #2 @ r9 = a0 - ldrsh r6, [r0, #2]! @ r6 = x11 - ldrsh r8, [r1, #2]! @ r8 = x21 - sub r5, r5, r7 @ r5 = x10 - x20 - add r7, r5, r7, asl #1 @ r7 = x10 + x20 - mla r12, r9, r5, r12 @ acc2 += a0*(x10 - x20) - sub r5, r6, r8 @ r5 = x11 - x21 - mla r10, r9, r5, r10 @ acc0 += a0*(x11 - x21) - ldrsh r9, [r2], #2 @ r9 = a1 - add r5, r6, r8 @ r5 = x11 + x21 - mla r14, r9, r7, r14 @ acc3 += a1*(x10 + x20) - mla r11, r9, r5, r11 @ acc1 += a1*(x11 + x21) - - ldrsh r9, [r2], #2 @ r9 = a1 - ldrsh r5, [r0, #2]! @ r5 = x10 - ldrsh r7, [r1, #2]! @ r7 = x20 - sub r6, r6, r8 @ r6 = x11 - x21 - add r8, r6, r8, asl #1 @ r8 = x11 + x21 - mla r12, r9, r6, r12 @ acc2 += a0*(x11 - x21) - sub r6, r5, r7 @ r6 = x10 - x20 - mla r10, r9, r6, r10 @ acc0 += a0*(x10 - x20) - ldrsh r9, [r2], #2 @ r9 = a1 - add r6, r5, r7 @ r5 = x10 + x20 - mla r14, r9, r8, r14 @ acc3 += a1*(x11 + x21) - mla r11, r9, r6, r11 @ acc1 += a1*(x10 + x10) - subs r4, r4, #4 - bne 1b - - ldr r4, [sp] @ r4 = M - sub r2, r2, r4, lsl #1 @ r2 = &a[0] - sub r0, r0, r4 @ r0 = &xx1[N2 - 2 - i] - sub r1, r1, r4 @ r1 = &xx2[N2 - 2 - i] - - mov r10, r10, asr #15 @ Shift outputs down - mov r11, r11, asr #15 - mov r12, r12, asr #15 - mov r14, r14, asr #15 - - @ Clip output to -32768..32767 range, which works fine despite not being - @ Speex' usual clipping range. - mvn r9, #0x8000 - mov r5, r10, asr #15 - teq r5, r5, asr #31 - eorne r10, r9, r5, asr #31 - mov r5, r11, asr #15 - teq r5, r5, asr #31 - eorne r11, r9, r5, asr #31 - mov r5, r12, asr #15 - teq r5, r5, asr #31 - eorne r12, r9, r5, asr #31 - mov r5, r14, asr #15 - teq r5, r5, asr #31 - eorne r14, r9, r5, asr #31 - - strh r10, [r3], #2 @ Write outputs - strh r11, [r3], #2 - strh r12, [r3], #2 - strh r14, [r3], #2 - ldr r10, [sp, #4] @ Load N - subs r10, r10, #4 @ Are we done? - strne r10, [sp, #4] @ no -> - bne 0b @ do outer loop - - @ Copy start of xx1 and xx2 back to alternate mem1 and mem2 entries - @ r0 and r1 are &xx1[0] and &xx2[0] at this point - add sp, sp, #8 - ldmia sp, { r5-r6, sp } @ Fetch &mem1[1], &mem2[1], restore sp -0: - ldr r7, [r0], #4 - ldr r8, [r1], #4 - strh r7, [r5], #4 - strh r8, [r6], #4 - mov r7, r7, lsr #16 - mov r8, r8, lsr #16 - strh r7, [r5], #4 - strh r8, [r6], #4 - subs r4, r4, #4 - bne 0b - ldmpc regs=r4-r11 @ Exit - - -/* void signal_mul(const spx_sig_t *x, spx_sig_t *y, spx_word32_t scale, int len) */ - .global signal_mul -signal_mul: - stmdb sp!, { r4-r8, lr } -0: - ldmia r0!, { r5-r8 } @ Load four input samples - smull r5, r12, r2, r5 - mov r12, r12, lsl #18 @ Recombine upper and lower parts - orr r5, r12, r5, lsr #14 - smull r6, r12, r2, r6 - mov r12, r12, lsl #18 - orr r6, r12, r6, lsr #14 - smull r7, r12, r2, r7 - mov r12, r12, lsl #18 - orr r7, r12, r7, lsr #14 - smull r8, r12, r2, r8 - mov r12, r12, lsl #18 - orr r8, r12, r8, lsr #14 - stmia r1!, { r5-r8 } @ Store four output samples - subs r3, r3, #4 @ Are we done? - bne 0b - - ldmpc regs=r4-r8 @ Exit - diff --git a/apps/codecs/libspeex/filters_arm4.h b/apps/codecs/libspeex/filters_arm4.h deleted file mode 100644 index 18c2a7d448..0000000000 --- a/apps/codecs/libspeex/filters_arm4.h +++ /dev/null @@ -1,96 +0,0 @@ -/* Copyright (C) 2004 Jean-Marc Valin */ -/** - @file filters_arm4.h - @brief Various analysis/synthesis filters (ARM4 version) -*/ -/* - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of the Xiph.org Foundation nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#define OVERRIDE_NORMALIZE16 -int normalize16(const spx_sig_t *x, spx_word16_t *y, spx_sig_t max_scale, int len) -{ - spx_sig_t max_val=1; - int sig_shift; - int dead1, dead2, dead3, dead4, dead5, dead6; - - __asm__ __volatile__ ( - "\tmov %1, #1 \n" - "\tmov %3, #0 \n" - - ".normalize16loop1%=: \n" - - "\tldr %4, [%0], #4 \n" - "\tcmp %4, %1 \n" - "\tmovgt %1, %4 \n" - "\tcmp %4, %3 \n" - "\tmovlt %3, %4 \n" - - "\tsubs %2, %2, #1 \n" - "\tbne .normalize16loop1%=\n" - - "\trsb %3, %3, #0 \n" - "\tcmp %1, %3 \n" - "\tmovlt %1, %3 \n" - : "=r" (dead1), "=r" (max_val), "=r" (dead3), "=r" (dead4), - "=r" (dead5), "=r" (dead6) - : "0" (x), "2" (len) - : "cc", "memory"); - - sig_shift=0; - while (max_val>max_scale) - { - sig_shift++; - max_val >>= 1; - } - - __asm__ __volatile__ ( - ".normalize16loop%=: \n" - - "\tldr %4, [%0], #4 \n" - "\tldr %5, [%0], #4 \n" - "\tmov %4, %4, asr %3 \n" - "\tstrh %4, [%1], #2 \n" - "\tldr %4, [%0], #4 \n" - "\tmov %5, %5, asr %3 \n" - "\tstrh %5, [%1], #2 \n" - "\tldr %5, [%0], #4 \n" - "\tmov %4, %4, asr %3 \n" - "\tstrh %4, [%1], #2 \n" - "\tsubs %2, %2, #1 \n" - "\tmov %5, %5, asr %3 \n" - "\tstrh %5, [%1], #2 \n" - - "\tbge .normalize16loop%=\n" - : "=r" (dead1), "=r" (dead2), "=r" (dead3), "=r" (dead4), - "=r" (dead5), "=r" (dead6) - : "0" (x), "1" (y), "2" (len>>2), "3" (sig_shift) - : "cc", "memory"); - return sig_shift; -} - diff --git a/apps/codecs/libspeex/filters_bfin.h b/apps/codecs/libspeex/filters_bfin.h deleted file mode 100644 index 1e433ee167..0000000000 --- a/apps/codecs/libspeex/filters_bfin.h +++ /dev/null @@ -1,515 +0,0 @@ -/* Copyright (C) 2005 Analog Devices */ -/** - @file filters_bfin.h - @brief Various analysis/synthesis filters (Blackfin version) -*/ -/* - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of the Xiph.org Foundation nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#define OVERRIDE_NORMALIZE16 -int normalize16(const spx_sig_t *x, spx_word16_t *y, spx_sig_t max_scale, int len) -{ - spx_sig_t max_val=1; - int sig_shift; - __asm__ - ( - "%0 = 0;\n\t" - "I0 = %1;\n\t" - "L0 = 0;\n\t" - "R1 = [I0++];\n\t" - "LOOP norm_max%= LC0 = %2;\n\t" - "LOOP_BEGIN norm_max%=;\n\t" - "R2 = ABS R1 || R1 = [I0++];\n\t" - "%0 = MAX(%0, R2);\n\t" - "LOOP_END norm_max%=;\n\t" - : "=&d" (max_val) - : "a" (x), "a" (len) - : "R1", "R2" - ); - - sig_shift=0; - while (max_val>max_scale) - { - sig_shift++; - max_val >>= 1; - } - - __asm__ __volatile__ - ( - "I0 = %0;\n\t" - "L0 = 0;\n\t" - "P1 = %1;\n\t" - "R0 = [I0++];\n\t" - "LOOP norm_shift%= LC0 = %3;\n\t" - "LOOP_BEGIN norm_shift%=;\n\t" - "R1 = ASHIFT R0 by %2.L || R0 = [I0++];\n\t" - "W[P1++] = R1;\n\t" - "LOOP_END norm_shift%=;\n\t" - "R1 = ASHIFT R0 by %2.L;\n\t" - "W[P1++] = R1;\n\t" - : : "a" (x), "a" (y), "d" (-sig_shift), "a" (len-1) - : "I0", "L0", "P1", "R0", "R1", "memory" - ); - return sig_shift; -} - - - -#define OVERRIDE_FILTER_MEM16 -void filter_mem16(const spx_word16_t *_x, const spx_coef_t *num, const spx_coef_t *den, spx_word16_t *_y, int N, int ord, spx_mem_t *mem, char *stack) -{ - VARDECL(spx_word32_t *xy2); - VARDECL(spx_word32_t *numden_a); - spx_word32_t *xy; - spx_word16_t *numden; - int i; - - ALLOC(xy2, (N+1), spx_word32_t); - ALLOC(numden_a, (2*ord+2), spx_word32_t); - xy = xy2+1; - numden = (spx_word16_t*) numden_a; - - for (i=0;i>> 13;\n\t" - "W[%0] = R3.L;\n\t" - "R0 <<= 1;\n\t" - "R1 = R1 + R0;\n\t" - "R1 >>>= 13;\n\t" - "W[%1] = R1.L;\n\t" - "LOOP_END samples%=;\n\t" - : "=a" (ytmp2), "=a" (y) - : "a" (awk2), "a" (ak), "d" (ord), "m" (N), "0" (ytmp2), "1" (y) - : "A0", "A1", "R0", "R1", "R2", "R3", "I0", "I1", "I2", "I3", "L0", "L1", "L2", "L3", "A0", "A1" - ); -} - - - -#if 0 /* Equivalent C function for filter_mem2 and compute_impulse_response */ -#define min(a,b) ((a)<(b) ? (a):(b)) - -void compute_impulse_response(const spx_coef_t *ak, const spx_coef_t *awk1, const spx_coef_t *awk2, spx_word16_t *y, int N, int ord, char *stack) -{ - int i,j; - VARDECL(spx_word16_t *ytmp); - ALLOC(ytmp, N, spx_word16_t); - - y[0] = LPC_SCALING; - for (i=0;i> 13 with rounding - move.w (%a3)+, %d0 - ext.l %d0 - add.l %d1, %d0 | Add with x[i] - move.l #32767, %d1 - move.l #65534, %a6 - add.l %d1, %d0 | Bias result to [-1..65534] - cmp.l %a6, %d0 | Now do clip to [0..65534] range - jls 2f - jpl 1f - clr.l %d0 | Clip low - .word 0x51fa | trapf.w, shadow next insn -1: - move.l %a6, %d0 | Clip high -2: - sub.l %d1, %d0 | Bias clipped result back to [-32767..32767] - move.w %d0, (%a5)+ | Write result to y[i] - neg.l %d0 | msac.w is bugged in gas, do this for now - move.l (%a4)+, %a6 | Fetch den[0] and den[1] - mac.w %a6u, %d0l, %acc0 - mac.w %a6l, %d0l, (%a4)+, %a6, %acc1 - mac.w %a6u, %d0l, %acc2 - mac.w %a6l, %d0l, (%a4)+, %a6, %acc3 - movclr.l %acc0, %d1 - add.l %d2, %d1 | mem[0] = mem[1] - den[0]*y[i] - movclr.l %acc1, %d2 - add.l %d3, %d2 | mem[1] = mem[2] - den[1]*y[i] - movclr.l %acc2, %d3 - add.l %d4, %d3 | mem[2] = mem[3] - den[2]*y[i] - movclr.l %acc3, %d4 - add.l %d5, %d4 | mem[3] = mem[4] - den[3]*y[i] - mac.w %a6u, %d0l, %acc0 - mac.w %a6l, %d0l, (%a4)+, %a6, %acc1 - mac.w %a6u, %d0l, %acc2 - mac.w %a6l, %d0l, %acc3 - lea.l (-16, %a4), %a4 | wrap den pointer back to den[0] - movclr.l %acc0, %d5 - add.l %d6, %d5 | mem[4] = mem[5] - den[4]*y[i] - movclr.l %acc1, %d6 - add.l %d7, %d6 | mem[5] = mem[6] - den[5]*y[i] - movclr.l %acc2, %d7 - add.l %a0, %d7 | mem[6] = mem[7] - den[6]*y[i] - movclr.l %acc3, %a0 | mem[7] = -den[7]*y[i] - subq.l #1, (44+16, %sp) | Have we done all samples? - jne 0b - move.l (44+24, %sp), %a6 | Fetch mem pointer - movem.l %d1-%d7/%a0, (%a6) | Save back mem[] - jra .exit - - | d0 = y[i], d1-d7, a0-a2 = mem[0] .. mem[9] - | a3 = x, a4 = den, a5 = y, a6 = temp -.order_10: - movem.l (%a6), %d1-%d7/%a0-%a2 | Fetch mem[] array -0: - moveq.l #13, %d0 - add.l #4096, %d1 - asr.l %d0, %d1 | mem[0] >> 13 with rounding - move.w (%a3)+, %d0 - ext.l %d0 - add.l %d1, %d0 | Add with x[i] - move.l #32767, %d1 - move.l #65534, %a6 - add.l %d1, %d0 | Bias result to [-1..65534] - cmp.l %a6, %d0 | Now do clip to [0..65534] range - jls 2f - jpl 1f - clr.l %d0 | Clip low - .word 0x51fa | trapf.w, shadow next insn -1: - move.l %a6, %d0 | Clip high -2: - sub.l %d1, %d0 | Bias clipped result back to [-32767..32767] - move.w %d0, (%a5)+ | Write result to y[i] - neg.l %d0 | msac.w is bugged in gas, do this for now - move.l (%a4)+, %a6 | Fetch den[0] and den[1] - mac.w %a6u, %d0l, %acc0 - mac.w %a6l, %d0l, (%a4)+, %a6, %acc1 - mac.w %a6u, %d0l, %acc2 - mac.w %a6l, %d0l, (%a4)+, %a6, %acc3 - movclr.l %acc0, %d1 - add.l %d2, %d1 | mem[0] = mem[1] - den[0]*y[i] - movclr.l %acc1, %d2 - add.l %d3, %d2 | mem[1] = mem[2] - den[1]*y[i] - movclr.l %acc2, %d3 - add.l %d4, %d3 | mem[2] = mem[3] - den[2]*y[i] - movclr.l %acc3, %d4 - add.l %d5, %d4 | mem[3] = mem[4] - den[3]*y[i] - mac.w %a6u, %d0l, %acc0 - mac.w %a6l, %d0l, (%a4)+, %a6, %acc1 - mac.w %a6u, %d0l, %acc2 - mac.w %a6l, %d0l, (%a4)+, %a6, %acc3 - lea.l (-20, %a4), %a4 | wrap den pointer back to den[0] - movclr.l %acc0, %d5 - add.l %d6, %d5 | mem[4] = mem[5] - den[4]*y[i] - movclr.l %acc1, %d6 - add.l %d7, %d6 | mem[5] = mem[6] - den[5]*y[i] - movclr.l %acc2, %d7 - add.l %a0, %d7 | mem[6] = mem[7] - den[6]*y[i] - movclr.l %acc3, %a0 - add.l %a1, %a0 | mem[7] = mem[8] - den[7]*y[i] - mac.w %a6u, %d0l, %acc0 - mac.w %a6l, %d0l, %acc1 - movclr.l %acc0, %a1 - add.l %a2, %a1 | mem[8] = mem[9] - den[8]*y[i] - movclr.l %acc1, %a2 | mem[9] = -den[9]*y[i] - - subq.l #1, (44+16, %sp) | Have we done all samples? - jne 0b - move.l (44+24, %sp), %a6 | Fetch mem pointer - movem.l %d1-%d7/%a0-%a2, (%a6) | Save back mem[] - -.exit: - movem.l (%sp), %d2-%d7/%a2-%a6 - lea.l (44, %sp), %sp - rts - - -/* void qmf_synth(const spx_word16_t *x1, const spx_word16_t *x2, const spx_word16_t *a, spx_word16_t *y, int N, int M, spx_word32_t *mem1, spx_word32_t *mem2, char *stack) */ - .global qmf_synth -qmf_synth: - lea.l (-44, %sp), %sp - movem.l %d2-%d7/%a2-%a6, (%sp) - movem.l (44+4, %sp), %a0-%a3 | a0 = x1, a1 = x2, a2 = a, a3 = y - movem.l (44+20, %sp), %d0-%d1/%a4-%a5 | d0 = N, d1 = M, a4 = mem1,a5 = mem2 - move.l #0x80, %macsr | Enable saturation - - | Comments make more sense when compared to the reference C version - move.l %a2, %d6 | Backup a - lsr.l #1, %d0 | N2 = N >> 1 - lsr.l #1, %d1 | M2 = M >> 1 - move.l %d1, %d7 | Backup M2 - clr.l %d2 - sub.l %d0, %d2 - sub.l %d1, %d2 | d2 = -(N2 + M2) - lea.l (%sp, %d2.l*2), %a2 | Alloc two buffers of N2 + M2 shorts - lea.l (%a2, %d2.l*2), %a6 | a2 = xx1, a6 = xx2 - move.l %sp, %d3 - move.l %a6, %sp | Update sp - move.l %d3, -(%sp) | Stack old %sp - - | Backwards copy x1 and x2 arrays to xx1 and xx2, assume N2 is power of two - | TODO: these copying loops probably have more potential for optimization - lea.l (%a0, %d0.l*2), %a0 | x1 += N2 - lea.l (%a1, %d0.l*2), %a1 | x2 += N2 - move.l %d0, %d2 | Loop counter is N2 -0: - move.l -(%a0), %d3 - swap.w %d3 - move.l %d3, (%a2)+ - move.l -(%a1), %d3 - swap.w %d3 - move.l %d3, (%a6)+ - subq.l #2, %d2 - jne 0b - - | Copy alternate members of mem1 and mem2 to last part of xx1 and xx2 - move.l %d1, %d2 | Loop counter is M2 - addq.l #2, %a4 | a4 = &mem1[1] - addq.l #2, %a5 | a5 = &mem2[1] - move.l %a4, %d3 | Backup mem1 and mem2 - move.l %a5, %d4 -0: - move.w (%a4), (%a2)+ - move.w (%a5), (%a6)+ - addq.l #4, %a4 - addq.l #4, %a5 - subq.l #1, %d2 - jne 0b - move.l %d3, %a4 | a4 = &mem1[1] - move.l %d4, %a5 | a5 = &mem2[1] - - clr.l %d2 - sub.l %d1, %d2 | d2 = -M2 - lea.l (-4, %a2, %d2.l*2), %a0 | a0 = &xx1[N2 - 2] - lea.l (-4, %a6, %d2.l*2), %a1 | a1 = &xx2[N2 - 2] - move.l %d6, %a2 | a2 = a - - | Main loop, register usage: - | d0 = N2 counter, d1 = M2 counter, d7 = M2 backup - | d2 = x10, d3 = x11, d4 = x20, d5 = x21, d6 = [a0, a1] - | a0 = xx1, a1 = xx2, a2 = a, a3 = y, a4 = mem1, a5 = mem2 -0: | Outerloop - move.l #32768, %d2 | Rounding constant - move.l %d2, %acc0 - move.l %d2, %acc1 - move.l %d2, %acc2 - move.l %d2, %acc3 - move.w (%a0)+, %d2 | d2 = x10 - move.w (%a1)+, %d4 | d4 = x20 - move.l (%a2)+, %d6 | d6 = [a0, a1] -1: | Innerloop - move.w (%a0)+, %d3 | d3 = x11 - move.w (%a1)+, %d5 | d5 = x21 - mac.w %d6u, %d3l, <<, %acc0 | acc0 += a0*x11 - msac.w %d6u, %d5l, <<, %acc0 | acc0 -= a0*x21 - mac.w %d6l, %d3l, <<, %acc1 | acc1 += a1*x11 - mac.w %d6l, %d5l, <<, %acc1 | acc1 += a1*x21 - mac.w %d6u, %d2l, <<, %acc2 | acc2 += a0*x10 - msac.w %d6u, %d4l, <<, %acc2 | acc2 -= a0*x20 - mac.w %d6l, %d2l, <<, %acc3 | acc3 += a1*x10 - mac.w %d6l, %d4l, <<, (%a2)+, %d6, %acc3 | acc3 += a1*x20 - - move.w (%a0)+, %d2 | d2 = x10 - move.w (%a1)+, %d4 | d4 = x20 - mac.w %d6u, %d2l, <<, %acc0 | acc0 += a0*x10 - msac.w %d6u, %d4l, <<, %acc0 | acc0 -= a0*x20 - mac.w %d6l, %d2l, <<, %acc1 | acc1 += a1*x10 - mac.w %d6l, %d4l, <<, %acc1 | acc1 += a1*x20 - mac.w %d6u, %d3l, <<, %acc2 | acc2 += a0*x11 - msac.w %d6u, %d5l, <<, %acc2 | acc2 -= a0*x21 - mac.w %d6l, %d3l, <<, %acc3 | acc3 += a1*x11 - mac.w %d6l, %d5l, <<, (%a2)+, %d6, %acc3 | acc3 += a1*x21 - subq.l #2, %d1 - jne 1b - - sub.l %d7, %d1 | d1 = -M2 - lea.l (-4, %a2, %d1.l*4), %a2 | a2 = &a[0] - lea.l (-6, %a0, %d1.l*2), %a0 | a0 = &xx1[N2 - 2 - i] - lea.l (-6, %a1, %d1.l*2), %a1 | a1 = &xx2[N2 - 2 - i] - neg.l %d1 | d1 = M2 - movclr.l %acc0, %d2 - movclr.l %acc1, %d3 - movclr.l %acc2, %d4 - movclr.l %acc3, %d5 - swap.w %d2 | Shift 16 right - swap.w %d3 - swap.w %d4 - swap.w %d5 - | Thanks to the extra shift in the mac chain, we get clipping for free. - | The clipping will be [-32768..32767], not Speex standard [-32767..32767], - | but since qmf_synth() is called so late in the signal chain, it should - | work fine. - move.w %d2, (%a3)+ | Write results to y[] - move.w %d3, (%a3)+ - move.w %d4, (%a3)+ - move.w %d5, (%a3)+ - subq.l #2, %d0 - jne 0b - - | Copy start of xx1 and xx2 back to alternate mem1 and mem2 entries - addq.l #4, %a0 | a0 = &xx1[0] - addq.l #4, %a1 | a1 = &xx2[0] -0: - move.w (%a0)+, (%a4) - move.w (%a1)+, (%a5) - addq.l #4, %a4 - addq.l #4, %a5 - subq.l #1, %d1 - jne 0b - - move.l #0, %macsr - move.l (%sp), %sp - movem.l (%sp), %d2-%d7/%a2-%a6 - lea.l (44, %sp), %sp - rts - - -/* void signal_mul(const spx_sig_t *x, spx_sig_t *y, spx_word32_t scale, int len) */ - .global signal_mul -signal_mul: - lea.l (-20, %sp), %sp - movem.l %d2-%d6, (%sp) - movem.l (20+4, %sp), %a0-%a1 | a0 = x, a1 = y - movem.l (20+12, %sp), %d0-%d1 | d0 = scale, d1 = len - moveq.l #0x20, %d6 - move.l %d6, %macsr | Set MAC unit to fractional mode - asl.l #3, %d0 | Pre-scale 'scale' - moveq.l #9, %d6 -0: - movem.l (%a0), %d2-%d5 | Fetch input - asl.l %d6, %d2 | Shift each value 9 to the left - asl.l %d6, %d3 - asl.l %d6, %d4 - asl.l %d6, %d5 - mac.l %d2, %d0, %acc0 | Do multiplies - mac.l %d3, %d0, %acc1 - mac.l %d4, %d0, %acc2 - mac.l %d5, %d0, %acc3 - lea.l (16, %a0), %a0 - movclr.l %acc0, %d2 - movclr.l %acc1, %d3 - movclr.l %acc2, %d4 - movclr.l %acc3, %d5 - asl.l #5, %d2 | Adjust to proper format - asl.l #5, %d3 - asl.l #5, %d4 - asl.l #5, %d5 - movem.l %d2-%d5, (%a1) | Save output - lea.l (16, %a1), %a1 - subq.l #4, %d1 - jne 0b - - clr.l %d0 - move.l %d0, %macsr | Set MAC unit back to integer mode - movem.l (%sp), %d2-%d6 - lea.l (20, %sp), %sp - rts - diff --git a/apps/codecs/libspeex/filters_sse.h b/apps/codecs/libspeex/filters_sse.h deleted file mode 100644 index 4bb333daf3..0000000000 --- a/apps/codecs/libspeex/filters_sse.h +++ /dev/null @@ -1,336 +0,0 @@ -/* Copyright (C) 2002 Jean-Marc Valin */ -/** - @file filters_sse.h - @brief Various analysis/synthesis filters (SSE version) -*/ -/* - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of the Xiph.org Foundation nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include - -void filter_mem16_10(const float *x, const float *_num, const float *_den, float *y, int N, int ord, float *_mem) -{ - __m128 num[3], den[3], mem[3]; - - int i; - - /* Copy numerator, denominator and memory to aligned xmm */ - for (i=0;i<2;i++) - { - mem[i] = _mm_loadu_ps(_mem+4*i); - num[i] = _mm_loadu_ps(_num+4*i); - den[i] = _mm_loadu_ps(_den+4*i); - } - mem[2] = _mm_setr_ps(_mem[8], _mem[9], 0, 0); - num[2] = _mm_setr_ps(_num[8], _num[9], 0, 0); - den[2] = _mm_setr_ps(_den[8], _den[9], 0, 0); - - for (i=0;i>1; - __asm__ ( - "P0 = 15;\n\t" - "R0 = %1;\n\t" - "R1 = %2;\n\t" - //"R0 = R0 + R1;\n\t" - "R0 <<= 1;\n\t" - "DIVS (R0, R1);\n\t" - "LOOP divide%= LC0 = P0;\n\t" - "LOOP_BEGIN divide%=;\n\t" - "DIVQ (R0, R1);\n\t" - "LOOP_END divide%=;\n\t" - "R0 = R0.L;\n\t" - "%0 = R0;\n\t" - : "=m" (res) - : "m" (a), "m" (bb) - : "P0", "R0", "R1", "cc"); - return res; -} - -#undef DIV32_16 -static inline spx_word16_t DIV32_16(spx_word32_t a, spx_word16_t b) -{ - spx_word32_t res, bb; - bb = b; - /* Make the roundinf consistent with the C version - (do we need to do that?)*/ - if (a<0) - a += (b-1); - __asm__ ( - "P0 = 15;\n\t" - "R0 = %1;\n\t" - "R1 = %2;\n\t" - "R0 <<= 1;\n\t" - "DIVS (R0, R1);\n\t" - "LOOP divide%= LC0 = P0;\n\t" - "LOOP_BEGIN divide%=;\n\t" - "DIVQ (R0, R1);\n\t" - "LOOP_END divide%=;\n\t" - "R0 = R0.L;\n\t" - "%0 = R0;\n\t" - : "=m" (res) - : "m" (a), "m" (bb) - : "P0", "R0", "R1", "cc"); - return res; -} - -#undef MAX16 -static inline spx_word16_t MAX16(spx_word16_t a, spx_word16_t b) -{ - spx_word32_t res; - __asm__ ( - "%1 = %1.L (X);\n\t" - "%2 = %2.L (X);\n\t" - "%0 = MAX(%1,%2);" - : "=d" (res) - : "%d" (a), "d" (b) - ); - return res; -} - -#undef MULT16_32_Q15 -static inline spx_word32_t MULT16_32_Q15(spx_word16_t a, spx_word32_t b) -{ - spx_word32_t res; - __asm__ - ( - "A1 = %2.L*%1.L (M);\n\t" - "A1 = A1 >>> 15;\n\t" - "%0 = (A1 += %2.L*%1.H) ;\n\t" - : "=&W" (res), "=&d" (b) - : "d" (a), "1" (b) - : "A1" - ); - return res; -} - -#undef MAC16_32_Q15 -static inline spx_word32_t MAC16_32_Q15(spx_word32_t c, spx_word16_t a, spx_word32_t b) -{ - spx_word32_t res; - __asm__ - ( - "A1 = %2.L*%1.L (M);\n\t" - "A1 = A1 >>> 15;\n\t" - "%0 = (A1 += %2.L*%1.H);\n\t" - "%0 = %0 + %4;\n\t" - : "=&W" (res), "=&d" (b) - : "d" (a), "1" (b), "d" (c) - : "A1" - ); - return res; -} - -#undef MULT16_32_Q14 -static inline spx_word32_t MULT16_32_Q14(spx_word16_t a, spx_word32_t b) -{ - spx_word32_t res; - __asm__ - ( - "%2 <<= 1;\n\t" - "A1 = %1.L*%2.L (M);\n\t" - "A1 = A1 >>> 15;\n\t" - "%0 = (A1 += %1.L*%2.H);\n\t" - : "=W" (res), "=d" (a), "=d" (b) - : "1" (a), "2" (b) - : "A1" - ); - return res; -} - -#undef MAC16_32_Q14 -static inline spx_word32_t MAC16_32_Q14(spx_word32_t c, spx_word16_t a, spx_word32_t b) -{ - spx_word32_t res; - __asm__ - ( - "%1 <<= 1;\n\t" - "A1 = %2.L*%1.L (M);\n\t" - "A1 = A1 >>> 15;\n\t" - "%0 = (A1 += %2.L*%1.H);\n\t" - "%0 = %0 + %4;\n\t" - : "=&W" (res), "=&d" (b) - : "d" (a), "1" (b), "d" (c) - : "A1" - ); - return res; -} - -#endif diff --git a/apps/codecs/libspeex/fixed_debug.h b/apps/codecs/libspeex/fixed_debug.h deleted file mode 100644 index d5c449f4d9..0000000000 --- a/apps/codecs/libspeex/fixed_debug.h +++ /dev/null @@ -1,487 +0,0 @@ -/* Copyright (C) 2003 Jean-Marc Valin */ -/** - @file fixed_debug.h - @brief Fixed-point operations with debugging -*/ -/* - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of the Xiph.org Foundation nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef FIXED_DEBUG_H -#define FIXED_DEBUG_H - -#include - -extern long long spx_mips; -#define MIPS_INC spx_mips++, - -#define QCONST16(x,bits) ((spx_word16_t)(.5+(x)*(((spx_word32_t)1)<<(bits)))) -#define QCONST32(x,bits) ((spx_word32_t)(.5+(x)*(((spx_word32_t)1)<<(bits)))) - - -#define VERIFY_SHORT(x) ((x)<=32767&&(x)>=-32768) -#define VERIFY_INT(x) ((x)<=2147483647LL&&(x)>=-2147483648LL) - -static inline short NEG16(int x) -{ - int res; - if (!VERIFY_SHORT(x)) - { - fprintf (stderr, "NEG16: input is not short: %d\n", (int)x); - } - res = -x; - if (!VERIFY_SHORT(res)) - fprintf (stderr, "NEG16: output is not short: %d\n", (int)res); - spx_mips++; - return res; -} -static inline int NEG32(long long x) -{ - long long res; - if (!VERIFY_INT(x)) - { - fprintf (stderr, "NEG16: input is not int: %d\n", (int)x); - } - res = -x; - if (!VERIFY_INT(res)) - fprintf (stderr, "NEG16: output is not int: %d\n", (int)res); - spx_mips++; - return res; -} - -#define EXTRACT16(x) _EXTRACT16(x, __FILE__, __LINE__) -static inline short _EXTRACT16(int x, char *file, int line) -{ - int res; - if (!VERIFY_SHORT(x)) - { - fprintf (stderr, "EXTRACT16: input is not short: %d in %s: line %d\n", x, file, line); - } - res = x; - spx_mips++; - return res; -} - -#define EXTEND32(x) _EXTEND32(x, __FILE__, __LINE__) -static inline int _EXTEND32(int x, char *file, int line) -{ - int res; - if (!VERIFY_SHORT(x)) - { - fprintf (stderr, "EXTEND32: input is not short: %d in %s: line %d\n", x, file, line); - } - res = x; - spx_mips++; - return res; -} - -#define SHR16(a, shift) _SHR16(a, shift, __FILE__, __LINE__) -static inline short _SHR16(int a, int shift, char *file, int line) -{ - int res; - if (!VERIFY_SHORT(a) || !VERIFY_SHORT(shift)) - { - fprintf (stderr, "SHR16: inputs are not short: %d >> %d in %s: line %d\n", a, shift, file, line); - } - res = a>>shift; - if (!VERIFY_SHORT(res)) - fprintf (stderr, "SHR16: output is not short: %d in %s: line %d\n", res, file, line); - spx_mips++; - return res; -} -#define SHL16(a, shift) _SHL16(a, shift, __FILE__, __LINE__) -static inline short _SHL16(int a, int shift, char *file, int line) -{ - int res; - if (!VERIFY_SHORT(a) || !VERIFY_SHORT(shift)) - { - fprintf (stderr, "SHL16: inputs are not short: %d %d in %s: line %d\n", a, shift, file, line); - } - res = a<>shift; - if (!VERIFY_INT(res)) - { - fprintf (stderr, "SHR32: output is not int: %d\n", (int)res); - } - spx_mips++; - return res; -} -static inline int SHL32(long long a, int shift) -{ - long long res; - if (!VERIFY_INT(a) || !VERIFY_SHORT(shift)) - { - fprintf (stderr, "SHL32: inputs are not int: %d %d\n", (int)a, shift); - } - res = a<>1))),shift)) -#define PSHR32(a,shift) (SHR32(ADD32((a),((1<<((shift))>>1))),shift)) -#define VSHR32(a, shift) (((shift)>0) ? SHR32(a, shift) : SHL32(a, -(shift))) - -#define SATURATE16(x,a) (((x)>(a) ? (a) : (x)<-(a) ? -(a) : (x))) -#define SATURATE32(x,a) (((x)>(a) ? (a) : (x)<-(a) ? -(a) : (x))) - -//#define SHR(a,shift) ((a) >> (shift)) -//#define SHL(a,shift) ((a) << (shift)) - -#define ADD16(a, b) _ADD16(a, b, __FILE__, __LINE__) -static inline short _ADD16(int a, int b, char *file, int line) -{ - int res; - if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b)) - { - fprintf (stderr, "ADD16: inputs are not short: %d %d in %s: line %d\n", a, b, file, line); - } - res = a+b; - if (!VERIFY_SHORT(res)) - { - fprintf (stderr, "ADD16: output is not short: %d+%d=%d in %s: line %d\n", a,b,res, file, line); - } - spx_mips++; - return res; -} - -#define SUB16(a, b) _SUB16(a, b, __FILE__, __LINE__) -static inline short _SUB16(int a, int b, char *file, int line) -{ - int res; - if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b)) - { - fprintf (stderr, "SUB16: inputs are not short: %d %d in %s: line %d\n", a, b, file, line); - } - res = a-b; - if (!VERIFY_SHORT(res)) - fprintf (stderr, "SUB16: output is not short: %d in %s: line %d\n", res, file, line); - spx_mips++; - return res; -} - -#define ADD32(a, b) _ADD32(a, b, __FILE__, __LINE__) -static inline int _ADD32(long long a, long long b, char *file, int line) -{ - long long res; - if (!VERIFY_INT(a) || !VERIFY_INT(b)) - { - fprintf (stderr, "ADD32: inputs are not int: %d %d in %s: line %d\n", (int)a, (int)b, file, line); - } - res = a+b; - if (!VERIFY_INT(res)) - { - fprintf (stderr, "ADD32: output is not int: %d in %s: line %d\n", (int)res, file, line); - } - spx_mips++; - return res; -} - -static inline int SUB32(long long a, long long b) -{ - long long res; - if (!VERIFY_INT(a) || !VERIFY_INT(b)) - { - fprintf (stderr, "SUB32: inputs are not int: %d %d\n", (int)a, (int)b); - } - res = a-b; - if (!VERIFY_INT(res)) - fprintf (stderr, "SUB32: output is not int: %d\n", (int)res); - spx_mips++; - return res; -} - -#define ADD64(a,b) (MIPS_INC(a)+(b)) - -/* result fits in 16 bits */ -static inline short MULT16_16_16(int a, int b) -{ - int res; - if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b)) - { - fprintf (stderr, "MULT16_16_16: inputs are not short: %d %d\n", a, b); - } - res = a*b; - if (!VERIFY_SHORT(res)) - fprintf (stderr, "MULT16_16_16: output is not short: %d\n", res); - spx_mips++; - return res; -} - -#define MULT16_16(a, b) _MULT16_16(a, b, __FILE__, __LINE__) -static inline int _MULT16_16(int a, int b, char *file, int line) -{ - long long res; - if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b)) - { - fprintf (stderr, "MULT16_16: inputs are not short: %d %d in %s: line %d\n", a, b, file, line); - } - res = ((long long)a)*b; - if (!VERIFY_INT(res)) - fprintf (stderr, "MULT16_16: output is not int: %d in %s: line %d\n", (int)res, file, line); - spx_mips++; - return res; -} - -#define MAC16_16(c,a,b) (spx_mips--,ADD32((c),MULT16_16((a),(b)))) -#define MAC16_16_Q11(c,a,b) (EXTRACT16(ADD16((c),EXTRACT16(SHR32(MULT16_16((a),(b)),11))))) -#define MAC16_16_Q13(c,a,b) (EXTRACT16(ADD16((c),EXTRACT16(SHR32(MULT16_16((a),(b)),13))))) -#define MAC16_16_P13(c,a,b) (EXTRACT16(ADD32((c),SHR32(ADD32(4096,MULT16_16((a),(b))),13)))) - - -#define MULT16_32_QX(a, b, Q) _MULT16_32_QX(a, b, Q, __FILE__, __LINE__) -static inline int _MULT16_32_QX(int a, long long b, int Q, char *file, int line) -{ - long long res; - if (!VERIFY_SHORT(a) || !VERIFY_INT(b)) - { - fprintf (stderr, "MULT16_32_Q%d: inputs are not short+int: %d %d in %s: line %d\n", Q, (int)a, (int)b, file, line); - } - if (ABS32(b)>=(1<<(15+Q))) - fprintf (stderr, "MULT16_32_Q%d: second operand too large: %d %d in %s: line %d\n", Q, (int)a, (int)b, file, line); - res = (((long long)a)*(long long)b) >> Q; - if (!VERIFY_INT(res)) - fprintf (stderr, "MULT16_32_Q%d: output is not int: %d*%d=%d in %s: line %d\n", Q, (int)a, (int)b,(int)res, file, line); - spx_mips+=5; - return res; -} - -static inline int MULT16_32_PX(int a, long long b, int Q) -{ - long long res; - if (!VERIFY_SHORT(a) || !VERIFY_INT(b)) - { - fprintf (stderr, "MULT16_32_P%d: inputs are not short+int: %d %d\n", Q, (int)a, (int)b); - } - if (ABS32(b)>=(1<<(15+Q))) - fprintf (stderr, "MULT16_32_Q%d: second operand too large: %d %d\n", Q, (int)a, (int)b); - res = ((((long long)a)*(long long)b) + ((1<>1))>> Q; - if (!VERIFY_INT(res)) - fprintf (stderr, "MULT16_32_P%d: output is not int: %d*%d=%d\n", Q, (int)a, (int)b,(int)res); - spx_mips+=5; - return res; -} - - -#define MULT16_32_Q11(a,b) MULT16_32_QX(a,b,11) -#define MAC16_32_Q11(c,a,b) ADD32((c),MULT16_32_Q11((a),(b))) -#define MULT16_32_Q12(a,b) MULT16_32_QX(a,b,12) -#define MULT16_32_Q13(a,b) MULT16_32_QX(a,b,13) -#define MULT16_32_Q14(a,b) MULT16_32_QX(a,b,14) -#define MULT16_32_Q15(a,b) MULT16_32_QX(a,b,15) -#define MULT16_32_P15(a,b) MULT16_32_PX(a,b,15) -#define MAC16_32_Q15(c,a,b) ADD32((c),MULT16_32_Q15((a),(b))) - -static inline int SATURATE(int a, int b) -{ - if (a>b) - a=b; - if (a<-b) - a = -b; - return a; -} - -static inline int MULT16_16_Q11_32(int a, int b) -{ - long long res; - if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b)) - { - fprintf (stderr, "MULT16_16_Q11: inputs are not short: %d %d\n", a, b); - } - res = ((long long)a)*b; - res >>= 11; - if (!VERIFY_INT(res)) - fprintf (stderr, "MULT16_16_Q11: output is not short: %d*%d=%d\n", (int)a, (int)b, (int)res); - spx_mips+=3; - return res; -} -static inline short MULT16_16_Q13(int a, int b) -{ - long long res; - if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b)) - { - fprintf (stderr, "MULT16_16_Q13: inputs are not short: %d %d\n", a, b); - } - res = ((long long)a)*b; - res >>= 13; - if (!VERIFY_SHORT(res)) - fprintf (stderr, "MULT16_16_Q13: output is not short: %d*%d=%d\n", a, b, (int)res); - spx_mips+=3; - return res; -} -static inline short MULT16_16_Q14(int a, int b) -{ - long long res; - if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b)) - { - fprintf (stderr, "MULT16_16_Q14: inputs are not short: %d %d\n", a, b); - } - res = ((long long)a)*b; - res >>= 14; - if (!VERIFY_SHORT(res)) - fprintf (stderr, "MULT16_16_Q14: output is not short: %d\n", (int)res); - spx_mips+=3; - return res; -} -static inline short MULT16_16_Q15(int a, int b) -{ - long long res; - if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b)) - { - fprintf (stderr, "MULT16_16_Q15: inputs are not short: %d %d\n", a, b); - } - res = ((long long)a)*b; - res >>= 15; - if (!VERIFY_SHORT(res)) - { - fprintf (stderr, "MULT16_16_Q15: output is not short: %d\n", (int)res); - } - spx_mips+=3; - return res; -} - -static inline short MULT16_16_P13(int a, int b) -{ - long long res; - if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b)) - { - fprintf (stderr, "MULT16_16_P13: inputs are not short: %d %d\n", a, b); - } - res = ((long long)a)*b; - res += 4096; - if (!VERIFY_INT(res)) - fprintf (stderr, "MULT16_16_P13: overflow: %d*%d=%d\n", a, b, (int)res); - res >>= 13; - if (!VERIFY_SHORT(res)) - fprintf (stderr, "MULT16_16_P13: output is not short: %d*%d=%d\n", a, b, (int)res); - spx_mips+=4; - return res; -} -static inline short MULT16_16_P14(int a, int b) -{ - long long res; - if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b)) - { - fprintf (stderr, "MULT16_16_P14: inputs are not short: %d %d\n", a, b); - } - res = ((long long)a)*b; - res += 8192; - if (!VERIFY_INT(res)) - fprintf (stderr, "MULT16_16_P14: overflow: %d*%d=%d\n", a, b, (int)res); - res >>= 14; - if (!VERIFY_SHORT(res)) - fprintf (stderr, "MULT16_16_P14: output is not short: %d*%d=%d\n", a, b, (int)res); - spx_mips+=4; - return res; -} -static inline short MULT16_16_P15(int a, int b) -{ - long long res; - if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b)) - { - fprintf (stderr, "MULT16_16_P15: inputs are not short: %d %d\n", a, b); - } - res = ((long long)a)*b; - res += 16384; - if (!VERIFY_INT(res)) - fprintf (stderr, "MULT16_16_P15: overflow: %d*%d=%d\n", a, b, (int)res); - res >>= 15; - if (!VERIFY_SHORT(res)) - fprintf (stderr, "MULT16_16_P15: output is not short: %d*%d=%d\n", a, b, (int)res); - spx_mips+=4; - return res; -} - -#define DIV32_16(a, b) _DIV32_16(a, b, __FILE__, __LINE__) - -static inline int _DIV32_16(long long a, long long b, char *file, int line) -{ - long long res; - if (b==0) - { - fprintf(stderr, "DIV32_16: divide by zero: %d/%d in %s: line %d\n", (int)a, (int)b, file, line); - return 0; - } - if (!VERIFY_INT(a) || !VERIFY_SHORT(b)) - { - fprintf (stderr, "DIV32_16: inputs are not int/short: %d %d in %s: line %d\n", (int)a, (int)b, file, line); - } - res = a/b; - if (!VERIFY_SHORT(res)) - { - fprintf (stderr, "DIV32_16: output is not short: %d / %d = %d in %s: line %d\n", (int)a,(int)b,(int)res, file, line); - if (res>32767) - res = 32767; - if (res<-32768) - res = -32768; - } - spx_mips+=20; - return res; -} - -#define DIV32(a, b) _DIV32(a, b, __FILE__, __LINE__) -static inline int _DIV32(long long a, long long b, char *file, int line) -{ - long long res; - if (b==0) - { - fprintf(stderr, "DIV32: divide by zero: %d/%d in %s: line %d\n", (int)a, (int)b, file, line); - return 0; - } - - if (!VERIFY_INT(a) || !VERIFY_INT(b)) - { - fprintf (stderr, "DIV32: inputs are not int/short: %d %d in %s: line %d\n", (int)a, (int)b, file, line); - } - res = a/b; - if (!VERIFY_INT(res)) - fprintf (stderr, "DIV32: output is not int: %d in %s: line %d\n", (int)res, file, line); - spx_mips+=36; - return res; -} -#define PDIV32(a,b) DIV32(ADD32((a),(b)>>1),b) -#define PDIV32_16(a,b) DIV32_16(ADD32((a),(b)>>1),b) - -#endif diff --git a/apps/codecs/libspeex/fixed_generic.h b/apps/codecs/libspeex/fixed_generic.h deleted file mode 100644 index 2948177c0b..0000000000 --- a/apps/codecs/libspeex/fixed_generic.h +++ /dev/null @@ -1,106 +0,0 @@ -/* Copyright (C) 2003 Jean-Marc Valin */ -/** - @file fixed_generic.h - @brief Generic fixed-point operations -*/ -/* - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of the Xiph.org Foundation nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef FIXED_GENERIC_H -#define FIXED_GENERIC_H - -#define QCONST16(x,bits) ((spx_word16_t)(.5+(x)*(((spx_word32_t)1)<<(bits)))) -#define QCONST32(x,bits) ((spx_word32_t)(.5+(x)*(((spx_word32_t)1)<<(bits)))) - -#define NEG16(x) (-(x)) -#define NEG32(x) (-(x)) -#define EXTRACT16(x) ((spx_word16_t)(x)) -#define EXTEND32(x) ((spx_word32_t)(x)) -#define SHR16(a,shift) ((a) >> (shift)) -#define SHL16(a,shift) ((a) << (shift)) -#define SHR32(a,shift) ((a) >> (shift)) -#define SHL32(a,shift) ((a) << (shift)) -#define PSHR16(a,shift) (SHR16((a)+((1<<((shift))>>1)),shift)) -#define PSHR32(a,shift) (SHR32((a)+((1<<((shift))>>1)),shift)) -#define VSHR32(a, shift) (((shift)>0) ? SHR32(a, shift) : SHL32(a, -(shift))) -#define SATURATE16(x,a) (((x)>(a) ? (a) : (x)<-(a) ? -(a) : (x))) -#define SATURATE32(x,a) (((x)>(a) ? (a) : (x)<-(a) ? -(a) : (x))) - -#define SHR(a,shift) ((a) >> (shift)) -#define SHL(a,shift) ((spx_word32_t)(a) << (shift)) -#define PSHR(a,shift) (SHR((a)+((1<<((shift))>>1)),shift)) -#define SATURATE(x,a) (((x)>(a) ? (a) : (x)<-(a) ? -(a) : (x))) - - -#define ADD16(a,b) ((spx_word16_t)((spx_word16_t)(a)+(spx_word16_t)(b))) -#define SUB16(a,b) ((spx_word16_t)(a)-(spx_word16_t)(b)) -#define ADD32(a,b) ((spx_word32_t)(a)+(spx_word32_t)(b)) -#define SUB32(a,b) ((spx_word32_t)(a)-(spx_word32_t)(b)) - - -/* result fits in 16 bits */ -#define MULT16_16_16(a,b) ((((spx_word16_t)(a))*((spx_word16_t)(b)))) - -/* (spx_word32_t)(spx_word16_t) gives TI compiler a hint that it's 16x16->32 multiply */ -#define MULT16_16(a,b) (((spx_word32_t)(spx_word16_t)(a))*((spx_word32_t)(spx_word16_t)(b))) - -#define MAC16_16(c,a,b) (ADD32((c),MULT16_16((a),(b)))) -#define MULT16_32_Q12(a,b) ADD32(MULT16_16((a),SHR((b),12)), SHR(MULT16_16((a),((b)&0x00000fff)),12)) -#define MULT16_32_Q13(a,b) ADD32(MULT16_16((a),SHR((b),13)), SHR(MULT16_16((a),((b)&0x00001fff)),13)) -#define MULT16_32_Q14(a,b) ADD32(MULT16_16((a),SHR((b),14)), SHR(MULT16_16((a),((b)&0x00003fff)),14)) - -#define MULT16_32_Q11(a,b) ADD32(MULT16_16((a),SHR((b),11)), SHR(MULT16_16((a),((b)&0x000007ff)),11)) -#define MAC16_32_Q11(c,a,b) ADD32(c,ADD32(MULT16_16((a),SHR((b),11)), SHR(MULT16_16((a),((b)&0x000007ff)),11))) - -#define MULT16_32_P15(a,b) ADD32(MULT16_16((a),SHR((b),15)), PSHR(MULT16_16((a),((b)&0x00007fff)),15)) -#define MULT16_32_Q15(a,b) ADD32(MULT16_16((a),SHR((b),15)), SHR(MULT16_16((a),((b)&0x00007fff)),15)) -#define MAC16_32_Q15(c,a,b) ADD32(c,ADD32(MULT16_16((a),SHR((b),15)), SHR(MULT16_16((a),((b)&0x00007fff)),15))) - - -#define MAC16_16_Q11(c,a,b) (ADD32((c),SHR(MULT16_16((a),(b)),11))) -#define MAC16_16_Q13(c,a,b) (ADD32((c),SHR(MULT16_16((a),(b)),13))) -#define MAC16_16_P13(c,a,b) (ADD32((c),SHR(ADD32(4096,MULT16_16((a),(b))),13))) - -#define MULT16_16_Q11_32(a,b) (SHR(MULT16_16((a),(b)),11)) -#define MULT16_16_Q13(a,b) (SHR(MULT16_16((a),(b)),13)) -#define MULT16_16_Q14(a,b) (SHR(MULT16_16((a),(b)),14)) -#define MULT16_16_Q15(a,b) (SHR(MULT16_16((a),(b)),15)) - -#define MULT16_16_P13(a,b) (SHR(ADD32(4096,MULT16_16((a),(b))),13)) -#define MULT16_16_P14(a,b) (SHR(ADD32(8192,MULT16_16((a),(b))),14)) -#define MULT16_16_P15(a,b) (SHR(ADD32(16384,MULT16_16((a),(b))),15)) - -#define MUL_16_32_R15(a,bh,bl) ADD32(MULT16_16((a),(bh)), SHR(MULT16_16((a),(bl)),15)) - -#define DIV32_16(a,b) ((spx_word16_t)(((spx_word32_t)(a))/((spx_word16_t)(b)))) -#define PDIV32_16(a,b) ((spx_word16_t)(((spx_word32_t)(a)+((spx_word16_t)(b)>>1))/((spx_word16_t)(b)))) -#define DIV32(a,b) (((spx_word32_t)(a))/((spx_word32_t)(b))) -#define PDIV32(a,b) (((spx_word32_t)(a)+((spx_word16_t)(b)>>1))/((spx_word32_t)(b))) - -#endif diff --git a/apps/codecs/libspeex/gain_table.c b/apps/codecs/libspeex/gain_table.c deleted file mode 100644 index bf236e80fc..0000000000 --- a/apps/codecs/libspeex/gain_table.c +++ /dev/null @@ -1,162 +0,0 @@ -/* Copyright (C) 2002 Jean-Marc Valin - File: gain_table.c - Codebook for 3-tap pitch prediction gain (128 entries) - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are - met: - - 1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - 3. The name of the author may not be used to endorse or promote products - derived from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, - INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. -*/ - -#include "config-speex.h" - -const signed char gain_cdbk_nb[512] GAIN_ICONST_ATTR = { --32, -32, -32, 0, --28, -67, -5, 33, --42, -6, -32, 18, --57, -10, -54, 35, --16, 27, -41, 42, -19, -19, -40, 36, --45, 24, -21, 40, --8, -14, -18, 28, -1, 14, -58, 53, --18, -88, -39, 39, --38, 21, -18, 37, --19, 20, -43, 38, -10, 17, -48, 54, --52, -58, -13, 33, --44, -1, -11, 32, --12, -11, -34, 22, -14, 0, -46, 46, --37, -35, -34, 5, --25, 44, -30, 43, -6, -4, -63, 49, --31, 43, -41, 43, --23, 30, -43, 41, --43, 26, -14, 44, --33, 1, -13, 27, --13, 18, -37, 37, --46, -73, -45, 34, --36, 24, -25, 34, --36, -11, -20, 19, --25, 12, -18, 33, --36, -69, -59, 34, --45, 6, 8, 46, --22, -14, -24, 18, --1, 13, -44, 44, --39, -48, -26, 15, --32, 31, -37, 34, --33, 15, -46, 31, --24, 30, -36, 37, --41, 31, -23, 41, --50, 22, -4, 50, --22, 2, -21, 28, --17, 30, -34, 40, --7, -60, -28, 29, --38, 42, -28, 42, --44, -11, 21, 43, --16, 8, -44, 34, --39, -55, -43, 21, --11, -35, 26, 41, --9, 0, -34, 29, --8, 121, -81, 113, -7, -16, -22, 33, --37, 33, -31, 36, --27, -7, -36, 17, --34, 70, -57, 65, --37, -11, -48, 21, --40, 17, -1, 44, --33, 6, -6, 33, --9, 0, -20, 34, --21, 69, -33, 57, --29, 33, -31, 35, --55, 12, -1, 49, --33, 27, -22, 35, --50, -33, -47, 17, --50, 54, 51, 94, --1, -5, -44, 35, --4, 22, -40, 45, --39, -66, -25, 24, --33, 1, -26, 20, --24, -23, -25, 12, --11, 21, -45, 44, --25, -45, -19, 17, --43, 105, -16, 82, -5, -21, 1, 41, --16, 11, -33, 30, --13, -99, -4, 57, --37, 33, -15, 44, --25, 37, -63, 54, --36, 24, -31, 31, --53, -56, -38, 26, --41, -4, 4, 37, --33, 13, -30, 24, -49, 52, -94, 114, --5, -30, -15, 23, -1, 38, -40, 56, --23, 12, -36, 29, --17, 40, -47, 51, --37, -41, -39, 11, --49, 34, 0, 58, --18, -7, -4, 34, --16, 17, -27, 35, -30, 5, -62, 65, -4, 48, -68, 76, --43, 11, -11, 38, --18, 19, -15, 41, --23, -62, -39, 23, --42, 10, -2, 41, --21, -13, -13, 25, --9, 13, -47, 42, --23, -62, -24, 24, --44, 60, -21, 58, --18, -3, -52, 32, --22, 22, -36, 34, --75, 57, 16, 90, --19, 3, 10, 45, --29, 23, -38, 32, --5, -62, -51, 38, --51, 40, -18, 53, --42, 13, -24, 32, --34, 14, -20, 30, --56, -75, -26, 37, --26, 32, 15, 59, --26, 17, -29, 29, --7, 28, -52, 53, --12, -30, 5, 30, --5, -48, -5, 35, -2, 2, -43, 40, -21, 16, 16, 75, --25, -45, -32, 10, --43, 18, -10, 42, -9, 0, -1, 52, --1, 7, -30, 36, -19, -48, -4, 48, --28, 25, -29, 32, --22, 0, -31, 22, --32, 17, -10, 36, --64, -41, -62, 36, --52, 15, 16, 58, --30, -22, -32, 6, --7, 9, -38, 36}; diff --git a/apps/codecs/libspeex/gain_table_lbr.c b/apps/codecs/libspeex/gain_table_lbr.c deleted file mode 100644 index b74df318a3..0000000000 --- a/apps/codecs/libspeex/gain_table_lbr.c +++ /dev/null @@ -1,66 +0,0 @@ -/* Copyright (C) 2002 Jean-Marc Valin - File: gain_table_lbr.c - Codebook for 3-tap pitch prediction gain (32 entries) - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are - met: - - 1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - 3. The name of the author may not be used to endorse or promote products - derived from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, - INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. -*/ - -#include "config-speex.h" - -const signed char gain_cdbk_lbr[128] GAIN_ICONST_ATTR = { --32, -32, -32, 0, --31, -58, -16, 22, --41, -24, -43, 14, --56, -22, -55, 29, --13, 33, -41, 47, --4, -39, -9, 29, --41, 15, -12, 38, --8, -15, -12, 31, -1, 2, -44, 40, --22, -66, -42, 27, --38, 28, -23, 38, --21, 14, -37, 31, -0, 21, -50, 52, --53, -71, -27, 33, --37, -1, -19, 25, --19, -5, -28, 22, -6, 65, -44, 74, --33, -48, -33, 9, --40, 57, -14, 58, --17, 4, -45, 32, --31, 38, -33, 36, --23, 28, -40, 39, --43, 29, -12, 46, --34, 13, -23, 28, --16, 15, -27, 34, --14, -82, -15, 43, --31, 25, -32, 29, --21, 5, -5, 38, --47, -63, -51, 33, --46, 12, 3, 47, --28, -17, -29, 11, --10, 14, -40, 38}; diff --git a/apps/codecs/libspeex/hexc_10_32_table.c b/apps/codecs/libspeex/hexc_10_32_table.c deleted file mode 100644 index 9a924e7ff0..0000000000 --- a/apps/codecs/libspeex/hexc_10_32_table.c +++ /dev/null @@ -1,68 +0,0 @@ -/* Copyright (C) 2002 Jean-Marc Valin - File: hexc_10_32_table.c - Codebook for high-band excitation in SB-CELP mode (4000 bps) - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of the Xiph.org Foundation nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include "config-speex.h" - -const signed char hexc_10_32_table[320] HEXC_ICONST_ATTR = { --3, -2, -1, 0, -4, 5, 35, -40, -9, 13, --44, 5, -27, -1, -7, 6, -11, 7, -8, 7, -19, -14, 15, -4, 9, -10, 10, -8, 10, -9, --1, 1, 0, 0, 2, 5, -18, 22, -53, 50, -1, -23, 50, -36, 15, 3, -13, 14, -10, 6, -1, 5, -3, 4, -2, 5, -32, 25, 5, -2, --1, -4, 1, 11, -29, 26, -6, -15, 30, -18, -0, 15, -17, 40, -41, 3, 9, -2, -2, 3, --3, -1, -5, 2, 21, -6, -16, -21, 23, 2, -60, 15, 16, -16, -9, 14, 9, -1, 7, -9, -0, 1, 1, 0, -1, -6, 17, -28, 54, -45, --1, 1, -1, -6, -6, 2, 11, 26, -29, -2, -46, -21, 34, 12, -23, 32, -23, 16, -10, 3, -66, 19, -20, 24, 7, 11, -3, 0, -3, -1, --50, -46, 2, -18, -3, 4, -1, -2, 3, -3, --19, 41, -36, 9, 11, -24, 21, -16, 9, -3, --25, -3, 10, 18, -9, -2, -5, -1, -5, 6, --4, -3, 2, -26, 21, -19, 35, -15, 7, -13, -17, -19, 39, -43, 48, -31, 16, -9, 7, -2, --5, 3, -4, 9, -19, 27, -55, 63, -35, 10, -26, -44, -2, 9, 4, 1, -6, 8, -9, 5, --8, -1, -3, -16, 45, -42, 5, 15, -16, 10, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, --16, 24, -55, 47, -38, 27, -19, 7, -3, 1, -16, 27, 20, -19, 18, 5, -7, 1, -5, 2, --6, 8, -22, 0, -3, -3, 8, -1, 7, -8, -1, -3, 5, 0, 17, -48, 58, -52, 29, -7, --2, 3, -10, 6, -26, 58, -31, 1, -6, 3, -93, -29, 39, 3, 17, 5, 6, -1, -1, -1, -27, 13, 10, 19, -7, -34, 12, 10, -4, 9, --76, 9, 8, -28, -2, -11, 2, -1, 3, 1, --83, 38, -39, 4, -16, -6, -2, -5, 5, -2, -}; diff --git a/apps/codecs/libspeex/hexc_table.c b/apps/codecs/libspeex/hexc_table.c deleted file mode 100644 index d892abd18c..0000000000 --- a/apps/codecs/libspeex/hexc_table.c +++ /dev/null @@ -1,164 +0,0 @@ -/* Copyright (C) 2002 Jean-Marc Valin - File: hexc_table.c - Codebook for high-band excitation in SB-CELP mode (8000 bps with sign) - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of the Xiph.org Foundation nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include "config-speex.h" - -const signed char hexc_table[1024] HEXC_ICONST_ATTR = { --24, 21, -20, 5, -5, -7, 14, -10, -2, -27, 16, -20, 0, -32, 26, 19, -8, -11, -41, 31, 28, -27, -32, 34, -42, 34, -17, 22, -10, 13, -29, 18, --12, -26, -24, 11, 22, 5, -5, -5, -54, -68, -43, 57, -25, 24, 4, 4, -26, -8, -12, -17, 54, 30, -45, 1, -10, -15, 18, -41, 11, 68, -67, 37, --16, -24, -16, 38, -22, 6, -29, 30, -66, -27, 5, 7, -16, 13, 2, -12, --7, -3, -20, 36, 4, -28, 9, 3, -32, 48, 26, 39, 3, 0, 7, -21, --13, 5, -82, -7, 73, -20, 34, -9, --5, 1, -1, 10, -5, -10, -1, 9, -1, -9, 10, 0, -14, 11, -1, -2, --1, 11, 20, 96, -81, -22, -12, -9, --58, 9, 24, -30, 26, -35, 27, -12, -13, -18, 56, -59, 15, -7, 23, -15, --1, 6, -25, 14, -22, -20, 47, -11, -16, 2, 38, -23, -19, -30, -9, 40, --11, 5, 4, -6, 8, 26, -21, -11, -127, 4, 1, 6, -9, 2, -7, -2, --3, 7, -5, 10, -19, 7, -106, 91, --3, 9, -4, 21, -8, 26, -80, 8, -1, -2, -10, -17, -17, -27, 32, 71, -6, -29, 11, -23, 54, -38, 29, -22, -39, 87, -31, -12, -20, 3, -2, -2, -2, 20, 0, -1, -35, 27, 9, -6, --12, 3, -12, -6, 13, 1, 14, -22, --59, -15, -17, -25, 13, -7, 7, 3, -0, 1, -7, 6, -3, 61, -37, -23, --23, -29, 38, -31, 27, 1, -8, 2, --27, 23, -26, 36, -34, 5, 24, -24, --6, 7, 3, -59, 78, -62, 44, -16, -1, 6, 0, 17, 8, 45, 0, -110, -6, 14, -2, 32, -77, -56, 62, -3, -3, -13, 4, -16, 102, -15, -36, -1, -9, -113, 6, 23, 0, 9, 9, 5, --8, -1, -14, 5, -12, 121, -53, -27, --8, -9, 22, -13, 3, 2, -3, 1, --2, -71, 95, 38, -19, 15, -16, -5, -71, 10, 2, -32, -13, -5, 15, -1, --2, -14, -85, 30, 29, 6, 3, 2, -0, 0, 0, 0, 0, 0, 0, 0, -2, -65, -56, -9, 18, 18, 23, -14, --2, 0, 12, -29, 26, -12, 1, 2, --12, -64, 90, -6, 4, 1, 5, -5, --110, -3, -31, 22, -29, 9, 0, 8, --40, -5, 21, -5, -5, 13, 10, -18, -40, 1, 35, -20, 30, -28, 11, -6, -19, 7, 14, 18, -64, 9, -6, 16, -51, 68, 8, 16, 12, -8, 0, -9, -20, -22, 25, 7, -4, -13, 41, -35, -93, -18, -54, 11, -1, 1, -9, 4, --66, 66, -31, 20, -22, 25, -23, 11, -10, 9, 19, 15, 11, -5, -31, -10, --23, -28, -6, -6, -3, -4, 5, 3, --28, 22, -11, -42, 25, -25, -16, 41, -34, 47, -6, 2, 42, -19, -22, 5, --39, 32, 6, -35, 22, 17, -30, 8, --26, -11, -11, 3, -12, 33, 33, -37, -21, -1, 6, -4, 3, 0, -5, 5, -12, -12, 57, 27, -61, -3, 20, -17, -2, 0, 4, 0, -2, -33, -58, 81, --23, 39, -10, -5, 2, 6, -7, 5, -4, -3, -2, -13, -23, -72, 107, 15, --5, 0, -7, -3, -6, 5, -4, 15, -47, 12, -31, 25, -16, 8, 22, -25, --62, -56, -18, 14, 28, 12, 2, -11, -74, -66, 41, -20, -7, 16, -20, 16, --8, 0, -16, 4, -19, 92, 12, -59, --14, -39, 49, -25, -16, 23, -27, 19, --3, -33, 19, 85, -29, 6, -7, -10, -16, -7, -12, 1, -6, 2, 4, -2, -64, 10, -25, 41, -2, -31, 15, 0, -110, 50, 69, 35, 28, 19, -10, 2, --43, -49, -56, -15, -16, 10, 3, 12, --1, -8, 1, 26, -12, -1, 7, -11, --27, 41, 25, 1, -11, -18, 22, -7, --1, -47, -8, 23, -3, -17, -7, 18, --125, 59, -5, 3, 18, 1, 2, 3, -27, -35, 65, -53, 50, -46, 37, -21, --28, 7, 14, -37, -5, -5, 12, 5, --8, 78, -19, 21, -6, -16, 8, -7, -5, 2, 7, 2, 10, -6, 12, -60, -44, 11, -36, -32, 31, 0, 2, -2, -2, 1, -3, 7, -10, 17, -21, 10, -6, -2, 19, -2, 59, -38, -86, 38, -8, -41, -30, -45, -33, 7, 15, 28, -29, -7, 24, -40, 7, 7, 5, -2, -9, 24, -23, -18, 6, -29, 30, 2, -28, 49, -11, -46, 10, 43, -13, -9, --1, -3, -7, -7, -17, -6, 97, -33, --21, 3, 5, 1, 12, -43, -8, 28, -7, -43, -7, 17, -20, 19, -1, 2, --13, 9, 54, 34, 9, -28, -11, -9, --17, 110, -59, 44, -26, 0, 3, -12, --47, 73, -34, -43, 38, -33, 16, -5, --46, -4, -6, -2, -25, 19, -29, 28, --13, 5, 14, 27, -40, -43, 4, 32, --13, -2, -35, -4, 112, -42, 9, -12, -37, -28, 17, 14, -19, 35, -39, 23, -3, -14, -1, -57, -5, 94, -9, 3, --39, 5, 30, -10, -32, 42, -13, -14, --97, -63, 30, -9, 1, -7, 12, 5, -20, 17, -9, -36, -30, 25, 47, -9, --15, 12, -22, 98, -8, -50, 15, -27, -21, -16, -11, 2, 12, -10, 10, -3, -33, 36, -96, 0, -17, 31, -9, 9, -3, -20, 13, -11, 8, -4, 10, -10, -9, 1, 112, -70, -27, 5, -21, 2, --57, -3, -29, 10, 19, -21, 21, -10, --66, -3, 91, -35, 30, -12, 0, -7, -59, -28, 26, 2, 14, -18, 1, 1, -11, 17, 20, -54, -59, 27, 4, 29, -32, 5, 19, 12, -4, 1, 7, -10, -5, -2, 10, 0, 23, -5, 28, -104, -46, 11, 16, 3, 29, 1, -8, -14, -1, 7, -50, 88, -62, 26, 8, -17, --14, 50, 0, 32, -12, -3, -27, 18, --8, -5, 8, 3, -20, -11, 37, -12, -9, 33, 46, -101, -1, -4, 1, 6, --1, 28, -42, -15, 16, 5, -1, -2, --55, 85, 38, -9, -4, 11, -2, -9, --6, 3, -20, -10, -77, 89, 24, -3, --104, -57, -26, -31, -20, -6, -9, 14, -20, -23, 46, -15, -31, 28, 1, -15, --2, 6, -2, 31, 45, -76, 23, -25, -}; diff --git a/apps/codecs/libspeex/high_lsp_tables.c b/apps/codecs/libspeex/high_lsp_tables.c deleted file mode 100644 index 56dc0f9faa..0000000000 --- a/apps/codecs/libspeex/high_lsp_tables.c +++ /dev/null @@ -1,165 +0,0 @@ -/* Copyright (C) 2002 Jean-Marc Valin - File: high_lsp_tables.c - Codebooks for high-band LSPs in SB-CELP mode - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are - met: - - 1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - 3. The name of the author may not be used to endorse or promote products - derived from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, - INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. -*/ - -#include "config-speex.h" - -const signed char high_lsp_cdbk[512] LSP_ICONST_ATTR ={ -39,12,-14,-20,-29,-61,-67,-76, --32,-71,-67,68,77,46,34,5, --13,-48,-46,-72,-81,-84,-60,-58, --40,-28,82,93,68,45,29,3, --19,-47,-28,-43,-35,-30,-8,-13, --39,-91,-91,-123,-96,10,10,-6, --18,-55,-60,-91,-56,-36,-27,-16, --48,-75,40,28,-10,-28,35,9, -37,19,1,-20,-31,-41,-18,-25, --35,-68,-80,45,27,-1,47,13, -0,-29,-35,-57,-50,-79,-73,-38, --19,5,35,14,-10,-23,16,-8, -5,-24,-40,-62,-23,-27,-22,-16, --18,-46,-72,-77,43,21,33,1, --80,-70,-70,-64,-56,-52,-39,-33, --31,-38,-19,-19,-15,32,33,-2, -7,-15,-15,-24,-23,-33,-41,-56, --24,-57,5,89,64,41,27,5, --9,-47,-60,-97,-97,-124,-20,-9, --44,-73,31,29,-4,64,48,7, --35,-57,0,-3,-26,-47,-3,-6, --40,-76,-79,-48,12,81,55,10, -9,-24,-43,-73,-57,-69,16,5, --28,-53,18,29,20,0,-4,-11, -6,-13,23,7,-17,-35,-37,-37, --30,-68,-63,6,24,-9,-14,3, -21,-13,-27,-57,-49,-80,-24,-41, --5,-16,-5,1,45,25,12,-7, -3,-15,-6,-16,-15,-8,6,-13, --42,-81,-80,-87,14,1,-10,-3, --43,-69,-46,-24,-28,-29,36,6, --43,-56,-12,12,54,79,43,9, -54,22,2,8,-12,-43,-46,-52, --38,-69,-89,-5,75,38,33,5, --13,-53,-62,-87,-89,-113,-99,-55, --34,-37,62,55,33,16,21,-2, --17,-46,-29,-38,-38,-48,-39,-42, --36,-75,-72,-88,-48,-30,21,2, --15,-57,-64,-98,-84,-76,25,1, --46,-80,-12,18,-7,3,34,6, -38,31,23,4,-1,20,14,-15, --43,-78,-91,-24,14,-3,54,16, -0,-27,-28,-44,-56,-83,-92,-89, --3,34,56,41,36,22,20,-8, --7,-35,-42,-62,-49,3,12,-10, --50,-87,-96,-66,92,70,38,9, --70,-71,-62,-42,-39,-43,-11,-7, --50,-79,-58,-50,-31,32,31,-6, --4,-25,7,-17,-38,-70,-58,-27, --43,-83,-28,59,36,20,31,2, --27,-71,-80,-109,-98,-75,-33,-32, --31,-2,33,15,-6,43,33,-5, -0,-22,-10,-27,-34,-49,-11,-20, --41,-91,-100,-121,-39,57,41,10, --19,-50,-38,-59,-60,-70,-18,-20, --8,-31,-8,-15,1,-14,-26,-25, -33,21,32,17,1,-19,-19,-26, --58,-81,-35,-22,45,30,11,-11, -3,-26,-48,-87,-67,-83,-58,3, --1,-26,-20,44,10,25,39,5, --9,-35,-27,-38,7,10,4,-9, --42,-85,-102,-127,52,44,28,10, --47,-61,-40,-39,-17,-1,-10,-33, --42,-74,-48,21,-4,70,52,10}; - - -const signed char high_lsp_cdbk2[512] LSP_ICONST_ATTR ={ --36,-62,6,-9,-10,-14,-56,23, -1,-26,23,-48,-17,12,8,-7, -23,29,-36,-28,-6,-29,-17,-5, -40,23,10,10,-46,-13,36,6, -4,-30,-29,62,32,-32,-1,22, --14,1,-4,-22,-45,2,54,4, --30,-57,-59,-12,27,-3,-31,8, --9,5,10,-14,32,66,19,9, -2,-25,-37,23,-15,18,-38,-31, -5,-9,-21,15,0,22,62,30, -15,-12,-14,-46,77,21,33,3, -34,29,-19,50,2,11,9,-38, --12,-37,62,1,-15,54,32,6, -2,-24,20,35,-21,2,19,24, --13,55,4,9,39,-19,30,-1, --21,73,54,33,8,18,3,15, -6,-19,-47,6,-3,-48,-50,1, -26,20,8,-23,-50,65,-14,-55, --17,-31,-37,-28,53,-1,-17,-53, -1,57,11,-8,-25,-30,-37,64, -5,-52,-45,15,23,31,15,14, --25,24,33,-2,-44,-56,-18,6, --21,-43,4,-12,17,-37,20,-10, -34,15,2,15,55,21,-11,-31, --6,46,25,16,-9,-25,-8,-62, -28,17,20,-32,-29,26,30,25, --19,2,-16,-17,26,-51,2,50, -42,19,-66,23,29,-2,3,19, --19,-37,32,15,6,30,-34,13, -11,-5,40,31,10,-42,4,-9, -26,-9,-70,17,-2,-23,20,-22, --55,51,-24,-31,22,-22,15,-13, -3,-10,-28,-16,56,4,-63,11, --18,-15,-18,-38,-35,16,-7,34, --1,-21,-49,-47,9,-37,7,8, -69,55,20,6,-33,-45,-10,-9, -6,-9,12,71,15,-3,-42,-7, --24,32,-35,-2,-42,-17,-5,0, --2,-33,-54,13,-12,-34,47,23, -19,55,7,-8,74,31,14,16, --23,-26,19,12,-18,-49,-28,-31, --20,2,-14,-20,-47,78,40,13, --23,-11,21,-6,18,1,47,5, -38,35,32,46,22,8,13,16, --14,18,51,19,40,39,11,-26, --1,-17,47,2,-53,-15,31,-22, -38,21,-15,-16,5,-33,53,15, --38,86,11,-3,-24,49,13,-4, --11,-18,28,20,-12,-27,-26,35, --25,-35,-3,-20,-61,30,10,-55, --12,-22,-52,-54,-14,19,-32,-12, -45,15,-8,-48,-9,11,-32,8, --16,-34,-13,51,18,38,-2,-32, --17,22,-2,-18,-28,-70,59,27, --28,-19,-10,-20,-9,-9,-8,-21, -21,-8,35,-2,45,-3,-9,12, -0,30,7,-39,43,27,-38,-91, -30,26,19,-55,-4,63,14,-17, -13,9,13,2,7,4,6,61, -72,-1,-17,29,-1,-22,-17,8, --28,-37,63,44,41,3,2,14, -9,-6,75,-8,-7,-12,-15,-12, -13,9,-4,30,-22,-65,15,0, --45,4,-4,1,5,22,11,23}; diff --git a/apps/codecs/libspeex/jitter.c b/apps/codecs/libspeex/jitter.c deleted file mode 100644 index d9f6c67b86..0000000000 --- a/apps/codecs/libspeex/jitter.c +++ /dev/null @@ -1,839 +0,0 @@ -/* Copyright (C) 2002 Jean-Marc Valin - File: speex_jitter.h - - Adaptive jitter buffer for Speex - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of the Xiph.org Foundation nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*/ - -/* -TODO: -- Add short-term estimate -- Defensive programming - + warn when last returned < last desired (begative buffering) - + warn if update_delay not called between get() and tick() or is called twice in a row -- Linked list structure for holding the packets instead of the current fixed-size array - + return memory to a pool - + allow pre-allocation of the pool - + optional max number of elements -- Statistics - + drift - + loss - + late - + jitter - + buffering delay -*/ -#ifdef HAVE_CONFIG_H -#include "config-speex.h" -#endif - - -#include "arch.h" -#include "speex/speex.h" -#include "speex/speex_bits.h" -#include "speex/speex_jitter.h" -#include "os_support.h" - -#ifndef NULL -#define NULL 0 -#endif - -#define SPEEX_JITTER_MAX_BUFFER_SIZE 200 /**< Maximum number of packets in jitter buffer */ - -#define TSUB(a,b) ((spx_int32_t)((a)-(b))) - -#define GT32(a,b) (((spx_int32_t)((a)-(b)))>0) -#define GE32(a,b) (((spx_int32_t)((a)-(b)))>=0) -#define LT32(a,b) (((spx_int32_t)((a)-(b)))<0) -#define LE32(a,b) (((spx_int32_t)((a)-(b)))<=0) - -#define ROUND_DOWN(x, step) ((x)<0 ? ((x)-(step)+1)/(step)*(step) : (x)/(step)*(step)) - -#define MAX_TIMINGS 20 -#define MAX_BUFFERS 3 -#define TOP_DELAY 20 - -/** Buffer that keeps the time of arrival of the latest packets */ -struct TimingBuffer { - int filled; /**< Number of entries occupied in "timing" and "counts"*/ - int curr_count; /**< Number of packet timings we got (including those we discarded) */ - spx_int16_t timing[MAX_TIMINGS]; /**< Sorted list of all timings ("latest" packets first) */ - spx_int16_t counts[MAX_TIMINGS]; /**< Order the packets were put in (will be used for short-term estimate) */ -}; - -static void tb_init(struct TimingBuffer *tb) -{ - tb->filled = 0; - tb->curr_count = 0; -} - -/* Add the timing of a new packet to the TimingBuffer */ -static void tb_add(struct TimingBuffer *tb, spx_int16_t timing) -{ - int pos; - /* Discard packet that won't make it into the list because they're too early */ - if (tb->filled >= MAX_TIMINGS && timing >= tb->timing[tb->filled-1]) - { - tb->curr_count++; - return; - } - - /* Find where the timing info goes in the sorted list */ - pos = 0; - /* FIXME: Do bisection instead of linear search */ - while (posfilled && timing >= tb->timing[pos]) - { - pos++; - } - - speex_assert(pos <= tb->filled && pos < MAX_TIMINGS); - - /* Shift everything so we can perform the insertion */ - if (pos < tb->filled) - { - int move_size = tb->filled-pos; - if (tb->filled == MAX_TIMINGS) - move_size -= 1; - SPEEX_COPY(&tb->timing[pos+1], &tb->timing[pos], move_size); - SPEEX_COPY(&tb->counts[pos+1], &tb->counts[pos], move_size); - } - /* Insert */ - tb->timing[pos] = timing; - tb->counts[pos] = tb->curr_count; - - tb->curr_count++; - if (tb->filledfilled++; -} - - - -/** Jitter buffer structure */ -struct JitterBuffer_ { - spx_uint32_t pointer_timestamp; /**< Timestamp of what we will *get* next */ - spx_uint32_t last_returned_timestamp; /**< Useful for getting the next packet with the same timestamp (for fragmented media) */ - spx_uint32_t next_stop; /**< Estimated time the next get() will be called */ - - spx_int32_t buffered; /**< Amount of data we think is still buffered by the application (timestamp units)*/ - - JitterBufferPacket packets[SPEEX_JITTER_MAX_BUFFER_SIZE]; /**< Packets stored in the buffer */ - spx_uint32_t arrival[SPEEX_JITTER_MAX_BUFFER_SIZE]; /**< Packet arrival time (0 means it was late, even though it's a valid timestamp) */ - - void (*destroy) (void *); /**< Callback for destroying a packet */ - - spx_int32_t delay_step; /**< Size of the steps when adjusting buffering (timestamp units) */ - spx_int32_t concealment_size; /**< Size of the packet loss concealment "units" */ - int reset_state; /**< True if state was just reset */ - int buffer_margin; /**< How many frames we want to keep in the buffer (lower bound) */ - int late_cutoff; /**< How late must a packet be for it not to be considered at all */ - int interp_requested; /**< An interpolation is requested by speex_jitter_update_delay() */ - int auto_adjust; /**< Whether to automatically adjust the delay at any time */ - - struct TimingBuffer _tb[MAX_BUFFERS]; /**< Don't use those directly */ - struct TimingBuffer *timeBuffers[MAX_BUFFERS]; /**< Storing arrival time of latest frames so we can compute some stats */ - int window_size; /**< Total window over which the late frames are counted */ - int subwindow_size; /**< Sub-window size for faster computation */ - int max_late_rate; /**< Absolute maximum amount of late packets tolerable (in percent) */ - int latency_tradeoff; /**< Latency equivalent of losing one percent of packets */ - int auto_tradeoff; /**< Latency equivalent of losing one percent of packets (automatic default) */ - - int lost_count; /**< Number of consecutive lost packets */ -}; - -/** Based on available data, this computes the optimal delay for the jitter buffer. - The optimised function is in timestamp units and is: - cost = delay + late_factor*[number of frames that would be late if we used that delay] - @param tb Array of buffers - @param late_factor Equivalent cost of a late frame (in timestamp units) - */ -static spx_int16_t compute_opt_delay(JitterBuffer *jitter) -{ - int i; - spx_int16_t opt=0; - spx_int32_t best_cost=0x7fffffff; - int late = 0; - int pos[MAX_BUFFERS]; - int tot_count; - float late_factor; - int penalty_taken = 0; - int best = 0; - int worst = 0; - spx_int32_t deltaT; - struct TimingBuffer *tb; - - tb = jitter->_tb; - - /* Number of packet timings we have received (including those we didn't keep) */ - tot_count = 0; - for (i=0;ilatency_tradeoff != 0) - late_factor = jitter->latency_tradeoff * 100.0f / tot_count; - else - late_factor = jitter->auto_tradeoff * jitter->window_size/tot_count; - - /*fprintf(stderr, "late_factor = %f\n", late_factor);*/ - for (i=0;idelay_step); - pos[next]++; - - /* Actual cost function that tells us how bad using this delay would be */ - cost = -latest + late_factor*late; - /*fprintf(stderr, "cost %d = %d + %f * %d\n", cost, -latest, late_factor, late);*/ - if (cost < best_cost) - { - best_cost = cost; - opt = latest; - } - } else { - break; - } - - /* For the next timing we will consider, there will be one more late packet to count */ - late++; - /* Two-frame penalty if we're going to increase the amount of late frames (hysteresis) */ - if (latest >= 0 && !penalty_taken) - { - penalty_taken = 1; - late+=2; - } - } - - deltaT = best-worst; - /* This is a default "automatic latency tradeoff" when none is provided */ - jitter->auto_tradeoff = 1 + deltaT/TOP_DELAY; - /*fprintf(stderr, "auto_tradeoff = %d (%d %d %d)\n", jitter->auto_tradeoff, best, worst, i);*/ - - /* FIXME: Compute a short-term estimate too and combine with the long-term one */ - - /* Prevents reducing the buffer size when we haven't really had much data */ - if (tot_count < TOP_DELAY && opt > 0) - return 0; - return opt; -} - - -/** Initialise jitter buffer */ -JitterBuffer *jitter_buffer_init(int step_size) -{ - JitterBuffer *jitter = (JitterBuffer*)speex_alloc(sizeof(JitterBuffer)); - if (jitter) - { - int i; - spx_int32_t tmp; - for (i=0;ipackets[i].data=NULL; - jitter->delay_step = step_size; - jitter->concealment_size = step_size; - /*FIXME: Should this be 0 or 1?*/ - jitter->buffer_margin = 0; - jitter->late_cutoff = 50; - jitter->destroy = NULL; - jitter->latency_tradeoff = 0; - jitter->auto_adjust = 1; - tmp = 4; - jitter_buffer_ctl(jitter, JITTER_BUFFER_SET_MAX_LATE_RATE, &tmp); - jitter_buffer_reset(jitter); - } - return jitter; -} - -/** Reset jitter buffer */ -void jitter_buffer_reset(JitterBuffer *jitter) -{ - int i; - for (i=0;ipackets[i].data) - { - if (jitter->destroy) - jitter->destroy(jitter->packets[i].data); - else - speex_free(jitter->packets[i].data); - jitter->packets[i].data = NULL; - } - } - /* Timestamp is actually undefined at this point */ - jitter->pointer_timestamp = 0; - jitter->next_stop = 0; - jitter->reset_state = 1; - jitter->lost_count = 0; - jitter->buffered = 0; - jitter->auto_tradeoff = 32000; - - for (i=0;i_tb[i]); - jitter->timeBuffers[i] = &jitter->_tb[i]; - } - /*fprintf (stderr, "reset\n");*/ -} - -/** Destroy jitter buffer */ -void jitter_buffer_destroy(JitterBuffer *jitter) -{ - jitter_buffer_reset(jitter); - speex_free(jitter); -} - -/** Take the following timing into consideration for future calculations */ -static void update_timings(JitterBuffer *jitter, spx_int32_t timing) -{ - if (timing < -32767) - timing = -32767; - if (timing > 32767) - timing = 32767; - /* If the current sub-window is full, perform a rotation and discard oldest sub-widow */ - if (jitter->timeBuffers[0]->curr_count >= jitter->subwindow_size) - { - int i; - /*fprintf(stderr, "Rotate buffer\n");*/ - struct TimingBuffer *tmp = jitter->timeBuffers[MAX_BUFFERS-1]; - for (i=MAX_BUFFERS-1;i>=1;i--) - jitter->timeBuffers[i] = jitter->timeBuffers[i-1]; - jitter->timeBuffers[0] = tmp; - tb_init(jitter->timeBuffers[0]); - } - tb_add(jitter->timeBuffers[0], timing); -} - -/** Compensate all timings when we do an adjustment of the buffering */ -static void shift_timings(JitterBuffer *jitter, spx_int16_t amount) -{ - int i, j; - for (i=0;itimeBuffers[i]->filled;j++) - jitter->timeBuffers[i]->timing[j] += amount; - } -} - - -/** Put one packet into the jitter buffer */ -void jitter_buffer_put(JitterBuffer *jitter, const JitterBufferPacket *packet) -{ - int i,j; - int late; - /*fprintf (stderr, "put packet %d %d\n", timestamp, span);*/ - - /* Cleanup buffer (remove old packets that weren't played) */ - if (!jitter->reset_state) - { - for (i=0;ipackets[i].data && LE32(jitter->packets[i].timestamp + jitter->packets[i].span, jitter->pointer_timestamp)) - { - /*fprintf (stderr, "cleaned (not played)\n");*/ - if (jitter->destroy) - jitter->destroy(jitter->packets[i].data); - else - speex_free(jitter->packets[i].data); - jitter->packets[i].data = NULL; - } - } - } - - /*fprintf(stderr, "arrival: %d %d %d\n", packet->timestamp, jitter->next_stop, jitter->pointer_timestamp);*/ - /* Check if packet is late (could still be useful though) */ - if (!jitter->reset_state && LT32(packet->timestamp, jitter->next_stop)) - { - update_timings(jitter, ((spx_int32_t)packet->timestamp) - ((spx_int32_t)jitter->next_stop) - jitter->buffer_margin); - late = 1; - } else { - late = 0; - } - - /* Only insert the packet if it's not hopelessly late (i.e. totally useless) */ - if (jitter->reset_state || GE32(packet->timestamp+packet->span+jitter->delay_step, jitter->pointer_timestamp)) - { - - /*Find an empty slot in the buffer*/ - for (i=0;ipackets[i].data==NULL) - break; - } - - /*No place left in the buffer, need to make room for it by discarding the oldest packet */ - if (i==SPEEX_JITTER_MAX_BUFFER_SIZE) - { - int earliest=jitter->packets[0].timestamp; - i=0; - for (j=1;jpackets[i].data || LT32(jitter->packets[j].timestamp,earliest)) - { - earliest = jitter->packets[j].timestamp; - i=j; - } - } - if (jitter->destroy) - jitter->destroy(jitter->packets[i].data); - else - speex_free(jitter->packets[i].data); - jitter->packets[i].data=NULL; - if (jitter->lost_count>20) - { - jitter_buffer_reset(jitter); - } - /*fprintf (stderr, "Buffer is full, discarding earliest frame %d (currently at %d)\n", timestamp, jitter->pointer_timestamp);*/ - } - - /* Copy packet in buffer */ - if (jitter->destroy) - { - jitter->packets[i].data = packet->data; - } else { - jitter->packets[i].data=(char*)speex_alloc(packet->len); - for (j=0;jlen;j++) - jitter->packets[i].data[j]=packet->data[j]; - } - jitter->packets[i].timestamp=packet->timestamp; - jitter->packets[i].span=packet->span; - jitter->packets[i].len=packet->len; - jitter->packets[i].sequence=packet->sequence; - jitter->packets[i].user_data=packet->user_data; - if (jitter->reset_state || late) - jitter->arrival[i] = 0; - else - jitter->arrival[i] = jitter->next_stop; - } - - -} - -/** Get one packet from the jitter buffer */ -int jitter_buffer_get(JitterBuffer *jitter, JitterBufferPacket *packet, spx_int32_t desired_span, spx_int32_t *start_offset) -{ - int i; - unsigned int j; - int incomplete = 0; - spx_int16_t opt; - - if (start_offset != NULL) - *start_offset = 0; - - /* Syncing on the first call */ - if (jitter->reset_state) - { - int found = 0; - /* Find the oldest packet */ - spx_uint32_t oldest=0; - for (i=0;ipackets[i].data && (!found || LT32(jitter->packets[i].timestamp,oldest))) - { - oldest = jitter->packets[i].timestamp; - found = 1; - } - } - if (found) - { - jitter->reset_state=0; - jitter->pointer_timestamp = oldest; - jitter->next_stop = oldest; - } else { - packet->timestamp = 0; - packet->span = jitter->interp_requested; - return JITTER_BUFFER_MISSING; - } - } - - - jitter->last_returned_timestamp = jitter->pointer_timestamp; - - if (jitter->interp_requested != 0) - { - packet->timestamp = jitter->pointer_timestamp; - packet->span = jitter->interp_requested; - - /* Increment the pointer because it got decremented in the delay update */ - jitter->pointer_timestamp += jitter->interp_requested; - packet->len = 0; - /*fprintf (stderr, "Deferred interpolate\n");*/ - - jitter->interp_requested = 0; - - jitter->buffered = packet->span - desired_span; - - return JITTER_BUFFER_INSERTION; - } - - /* Searching for the packet that fits best */ - - /* Search the buffer for a packet with the right timestamp and spanning the whole current chunk */ - for (i=0;ipackets[i].data && jitter->packets[i].timestamp==jitter->pointer_timestamp && GE32(jitter->packets[i].timestamp+jitter->packets[i].span,jitter->pointer_timestamp+desired_span)) - break; - } - - /* If no match, try for an "older" packet that still spans (fully) the current chunk */ - if (i==SPEEX_JITTER_MAX_BUFFER_SIZE) - { - for (i=0;ipackets[i].data && LE32(jitter->packets[i].timestamp, jitter->pointer_timestamp) && GE32(jitter->packets[i].timestamp+jitter->packets[i].span,jitter->pointer_timestamp+desired_span)) - break; - } - } - - /* If still no match, try for an "older" packet that spans part of the current chunk */ - if (i==SPEEX_JITTER_MAX_BUFFER_SIZE) - { - for (i=0;ipackets[i].data && LE32(jitter->packets[i].timestamp, jitter->pointer_timestamp) && GT32(jitter->packets[i].timestamp+jitter->packets[i].span,jitter->pointer_timestamp)) - break; - } - } - - /* If still no match, try for earliest packet possible */ - if (i==SPEEX_JITTER_MAX_BUFFER_SIZE) - { - int found = 0; - spx_uint32_t best_time=0; - int best_span=0; - int besti=0; - for (i=0;ipackets[i].data && LT32(jitter->packets[i].timestamp,jitter->pointer_timestamp+desired_span) && GE32(jitter->packets[i].timestamp,jitter->pointer_timestamp)) - { - if (!found || LT32(jitter->packets[i].timestamp,best_time) || (jitter->packets[i].timestamp==best_time && GT32(jitter->packets[i].span,best_span))) - { - best_time = jitter->packets[i].timestamp; - best_span = jitter->packets[i].span; - besti = i; - found = 1; - } - } - } - if (found) - { - i=besti; - incomplete = 1; - /*fprintf (stderr, "incomplete: %d %d %d %d\n", jitter->packets[i].timestamp, jitter->pointer_timestamp, chunk_size, jitter->packets[i].span);*/ - } - } - - /* If we find something */ - if (i!=SPEEX_JITTER_MAX_BUFFER_SIZE) - { - spx_int32_t offset; - - /* We (obviously) haven't lost this packet */ - jitter->lost_count = 0; - - /* In this case, 0 isn't as a valid timestamp */ - if (jitter->arrival[i] != 0) - { - update_timings(jitter, ((spx_int32_t)jitter->packets[i].timestamp) - ((spx_int32_t)jitter->arrival[i]) - jitter->buffer_margin); - } - - - if (jitter->packets[i].len > packet->len) - { - speex_warning_int("jitter_buffer_get(): packet too large to fit. Size is", jitter->packets[i].len); - } else { - packet->len = jitter->packets[i].len; - } - /* Copy packet */ - if (jitter->destroy) - { - packet->data = jitter->packets[i].data; - } else { - for (j=0;jlen;j++) - packet->data[j] = jitter->packets[i].data[j]; - /* Remove packet */ - speex_free(jitter->packets[i].data); - } - jitter->packets[i].data = NULL; - /* Set timestamp and span (if requested) */ - offset = (spx_int32_t)jitter->packets[i].timestamp-(spx_int32_t)jitter->pointer_timestamp; - if (start_offset != NULL) - *start_offset = offset; - else if (offset != 0) - speex_warning_int("jitter_buffer_get() discarding non-zero start_offset", offset); - - packet->timestamp = jitter->packets[i].timestamp; - jitter->last_returned_timestamp = packet->timestamp; - - packet->span = jitter->packets[i].span; - packet->sequence = jitter->packets[i].sequence; - packet->user_data = jitter->packets[i].user_data; - /* Point to the end of the current packet */ - jitter->pointer_timestamp = jitter->packets[i].timestamp+jitter->packets[i].span; - - jitter->buffered = packet->span - desired_span; - - if (start_offset != NULL) - jitter->buffered += *start_offset; - - return JITTER_BUFFER_OK; - } - - - /* If we haven't found anything worth returning */ - - /*fprintf (stderr, "not found\n");*/ - jitter->lost_count++; - /*fprintf (stderr, "m");*/ - /*fprintf (stderr, "lost_count = %d\n", jitter->lost_count);*/ - - opt = compute_opt_delay(jitter); - - /* Should we force an increase in the buffer or just do normal interpolation? */ - if (opt < 0) - { - /* Need to increase buffering */ - - /* Shift histogram to compensate */ - shift_timings(jitter, -opt); - - packet->timestamp = jitter->pointer_timestamp; - packet->span = -opt; - /* Don't move the pointer_timestamp forward */ - packet->len = 0; - - jitter->buffered = packet->span - desired_span; - return JITTER_BUFFER_INSERTION; - /*jitter->pointer_timestamp -= jitter->delay_step;*/ - /*fprintf (stderr, "Forced to interpolate\n");*/ - } else { - /* Normal packet loss */ - packet->timestamp = jitter->pointer_timestamp; - - desired_span = ROUND_DOWN(desired_span, jitter->concealment_size); - packet->span = desired_span; - jitter->pointer_timestamp += desired_span; - packet->len = 0; - - jitter->buffered = packet->span - desired_span; - return JITTER_BUFFER_MISSING; - /*fprintf (stderr, "Normal loss\n");*/ - } - - -} - -int jitter_buffer_get_another(JitterBuffer *jitter, JitterBufferPacket *packet) -{ - int i, j; - for (i=0;ipackets[i].data && jitter->packets[i].timestamp==jitter->last_returned_timestamp) - break; - } - if (i!=SPEEX_JITTER_MAX_BUFFER_SIZE) - { - /* Copy packet */ - packet->len = jitter->packets[i].len; - if (jitter->destroy) - { - packet->data = jitter->packets[i].data; - } else { - for (j=0;jlen;j++) - packet->data[j] = jitter->packets[i].data[j]; - /* Remove packet */ - speex_free(jitter->packets[i].data); - } - jitter->packets[i].data = NULL; - packet->timestamp = jitter->packets[i].timestamp; - packet->span = jitter->packets[i].span; - packet->sequence = jitter->packets[i].sequence; - packet->user_data = jitter->packets[i].user_data; - return JITTER_BUFFER_OK; - } else { - packet->data = NULL; - packet->len = 0; - packet->span = 0; - return JITTER_BUFFER_MISSING; - } -} - -/* Let the jitter buffer know it's the right time to adjust the buffering delay to the network conditions */ -static int _jitter_buffer_update_delay(JitterBuffer *jitter, JitterBufferPacket *packet, spx_int32_t *start_offset) -{ - spx_int16_t opt = compute_opt_delay(jitter); - /*fprintf(stderr, "opt adjustment is %d ", opt);*/ - - if (opt < 0) - { - shift_timings(jitter, -opt); - - jitter->pointer_timestamp += opt; - jitter->interp_requested = -opt; - /*fprintf (stderr, "Decision to interpolate %d samples\n", -opt);*/ - } else if (opt > 0) - { - shift_timings(jitter, -opt); - jitter->pointer_timestamp += opt; - /*fprintf (stderr, "Decision to drop %d samples\n", opt);*/ - } - - return opt; -} - -/* Let the jitter buffer know it's the right time to adjust the buffering delay to the network conditions */ -int jitter_buffer_update_delay(JitterBuffer *jitter, JitterBufferPacket *packet, spx_int32_t *start_offset) -{ - /* If the programmer calls jitter_buffer_update_delay() directly, - automatically disable auto-adjustment */ - jitter->auto_adjust = 0; - - return _jitter_buffer_update_delay(jitter, packet, start_offset); -} - -/** Get pointer timestamp of jitter buffer */ -int jitter_buffer_get_pointer_timestamp(JitterBuffer *jitter) -{ - return jitter->pointer_timestamp; -} - -void jitter_buffer_tick(JitterBuffer *jitter) -{ - /* Automatically-adjust the buffering delay if requested */ - if (jitter->auto_adjust) - _jitter_buffer_update_delay(jitter, NULL, NULL); - - if (jitter->buffered >= 0) - { - jitter->next_stop = jitter->pointer_timestamp - jitter->buffered; - } else { - jitter->next_stop = jitter->pointer_timestamp; - speex_warning_int("jitter buffer sees negative buffering, your code might be broken. Value is ", jitter->buffered); - } - jitter->buffered = 0; -} - -void jitter_buffer_remaining_span(JitterBuffer *jitter, spx_uint32_t rem) -{ - /* Automatically-adjust the buffering delay if requested */ - if (jitter->auto_adjust) - _jitter_buffer_update_delay(jitter, NULL, NULL); - - if (jitter->buffered < 0) - speex_warning_int("jitter buffer sees negative buffering, your code might be broken. Value is ", jitter->buffered); - jitter->next_stop = jitter->pointer_timestamp - rem; -} - - -/* Used like the ioctl function to control the jitter buffer parameters */ -int jitter_buffer_ctl(JitterBuffer *jitter, int request, void *ptr) -{ - int count, i; - switch(request) - { - case JITTER_BUFFER_SET_MARGIN: - jitter->buffer_margin = *(spx_int32_t*)ptr; - break; - case JITTER_BUFFER_GET_MARGIN: - *(spx_int32_t*)ptr = jitter->buffer_margin; - break; - case JITTER_BUFFER_GET_AVALIABLE_COUNT: - count = 0; - for (i=0;ipackets[i].data && LE32(jitter->pointer_timestamp, jitter->packets[i].timestamp)) - { - count++; - } - } - *(spx_int32_t*)ptr = count; - break; - case JITTER_BUFFER_SET_DESTROY_CALLBACK: - jitter->destroy = (void (*) (void *))ptr; - break; - case JITTER_BUFFER_GET_DESTROY_CALLBACK: - *(void (**) (void *))ptr = jitter->destroy; - break; - case JITTER_BUFFER_SET_DELAY_STEP: - jitter->delay_step = *(spx_int32_t*)ptr; - break; - case JITTER_BUFFER_GET_DELAY_STEP: - *(spx_int32_t*)ptr = jitter->delay_step; - break; - case JITTER_BUFFER_SET_CONCEALMENT_SIZE: - jitter->concealment_size = *(spx_int32_t*)ptr; - break; - case JITTER_BUFFER_GET_CONCEALMENT_SIZE: - *(spx_int32_t*)ptr = jitter->concealment_size; - break; - case JITTER_BUFFER_SET_MAX_LATE_RATE: - jitter->max_late_rate = *(spx_int32_t*)ptr; - jitter->window_size = 100*TOP_DELAY/jitter->max_late_rate; - jitter->subwindow_size = jitter->window_size/MAX_BUFFERS; - break; - case JITTER_BUFFER_GET_MAX_LATE_RATE: - *(spx_int32_t*)ptr = jitter->max_late_rate; - break; - case JITTER_BUFFER_SET_LATE_COST: - jitter->latency_tradeoff = *(spx_int32_t*)ptr; - break; - case JITTER_BUFFER_GET_LATE_COST: - *(spx_int32_t*)ptr = jitter->latency_tradeoff; - break; - default: - speex_warning_int("Unknown jitter_buffer_ctl request: ", request); - return -1; - } - return 0; -} - diff --git a/apps/codecs/libspeex/kiss_fft.c b/apps/codecs/libspeex/kiss_fft.c deleted file mode 100644 index 5b699a362f..0000000000 --- a/apps/codecs/libspeex/kiss_fft.c +++ /dev/null @@ -1,523 +0,0 @@ -/* -Copyright (c) 2003-2004, Mark Borgerding -Copyright (c) 2005-2007, Jean-Marc Valin - -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - * Neither the author nor the names of any contributors may be used to endorse or promote products derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - -#ifdef HAVE_CONFIG_H -#include "config-speex.h" -#endif - -#include "_kiss_fft_guts.h" -#include "arch.h" -#include "os_support.h" - -/* The guts header contains all the multiplication and addition macros that are defined for - fixed or floating point complex numbers. It also delares the kf_ internal functions. - */ - -static void kf_bfly2( - kiss_fft_cpx * Fout, - const size_t fstride, - const kiss_fft_cfg st, - int m, - int N, - int mm - ) -{ - kiss_fft_cpx * Fout2; - kiss_fft_cpx * tw1; - kiss_fft_cpx t; - if (!st->inverse) { - int i,j; - kiss_fft_cpx * Fout_beg = Fout; - for (i=0;itwiddles; - for(j=0;jr , tw1->r),MULT16_16(Fout2->i , tw1->i)), 1); - ti = SHR32(ADD32(MULT16_16(Fout2->i , tw1->r),MULT16_16(Fout2->r , tw1->i)), 1); - tw1 += fstride; - Fout2->r = PSHR32(SUB32(SHL32(EXTEND32(Fout->r), 14), tr), 15); - Fout2->i = PSHR32(SUB32(SHL32(EXTEND32(Fout->i), 14), ti), 15); - Fout->r = PSHR32(ADD32(SHL32(EXTEND32(Fout->r), 14), tr), 15); - Fout->i = PSHR32(ADD32(SHL32(EXTEND32(Fout->i), 14), ti), 15); - ++Fout2; - ++Fout; - } - } - } else { - int i,j; - kiss_fft_cpx * Fout_beg = Fout; - for (i=0;itwiddles; - for(j=0;jinverse) - { - kiss_fft_cpx * Fout_beg = Fout; - for (i=0;itwiddles; - for (j=0;jtwiddles; - for (j=0;jr = PSHR16(Fout->r, 2); - Fout->i = PSHR16(Fout->i, 2); - C_SUB( scratch[5] , *Fout, scratch[1] ); - C_ADDTO(*Fout, scratch[1]); - C_ADD( scratch[3] , scratch[0] , scratch[2] ); - C_SUB( scratch[4] , scratch[0] , scratch[2] ); - Fout[m2].r = PSHR16(Fout[m2].r, 2); - Fout[m2].i = PSHR16(Fout[m2].i, 2); - C_SUB( Fout[m2], *Fout, scratch[3] ); - tw1 += fstride; - tw2 += fstride*2; - tw3 += fstride*3; - C_ADDTO( *Fout , scratch[3] ); - - Fout[m].r = scratch[5].r + scratch[4].i; - Fout[m].i = scratch[5].i - scratch[4].r; - Fout[m3].r = scratch[5].r - scratch[4].i; - Fout[m3].i = scratch[5].i + scratch[4].r; - ++Fout; - } - } - } -} - -static void kf_bfly3( - kiss_fft_cpx * Fout, - const size_t fstride, - const kiss_fft_cfg st, - size_t m - ) -{ - size_t k=m; - const size_t m2 = 2*m; - kiss_fft_cpx *tw1,*tw2; - kiss_fft_cpx scratch[5]; - kiss_fft_cpx epi3; - epi3 = st->twiddles[fstride*m]; - - tw1=tw2=st->twiddles; - - do{ - if (!st->inverse) { - C_FIXDIV(*Fout,3); C_FIXDIV(Fout[m],3); C_FIXDIV(Fout[m2],3); - } - - C_MUL(scratch[1],Fout[m] , *tw1); - C_MUL(scratch[2],Fout[m2] , *tw2); - - C_ADD(scratch[3],scratch[1],scratch[2]); - C_SUB(scratch[0],scratch[1],scratch[2]); - tw1 += fstride; - tw2 += fstride*2; - - Fout[m].r = Fout->r - HALF_OF(scratch[3].r); - Fout[m].i = Fout->i - HALF_OF(scratch[3].i); - - C_MULBYSCALAR( scratch[0] , epi3.i ); - - C_ADDTO(*Fout,scratch[3]); - - Fout[m2].r = Fout[m].r + scratch[0].i; - Fout[m2].i = Fout[m].i - scratch[0].r; - - Fout[m].r -= scratch[0].i; - Fout[m].i += scratch[0].r; - - ++Fout; - }while(--k); -} - -static void kf_bfly5( - kiss_fft_cpx * Fout, - const size_t fstride, - const kiss_fft_cfg st, - int m - ) -{ - kiss_fft_cpx *Fout0,*Fout1,*Fout2,*Fout3,*Fout4; - int u; - kiss_fft_cpx scratch[13]; - kiss_fft_cpx * twiddles = st->twiddles; - kiss_fft_cpx *tw; - kiss_fft_cpx ya,yb; - ya = twiddles[fstride*m]; - yb = twiddles[fstride*2*m]; - - Fout0=Fout; - Fout1=Fout0+m; - Fout2=Fout0+2*m; - Fout3=Fout0+3*m; - Fout4=Fout0+4*m; - - tw=st->twiddles; - for ( u=0; uinverse) { - C_FIXDIV( *Fout0,5); C_FIXDIV( *Fout1,5); C_FIXDIV( *Fout2,5); C_FIXDIV( *Fout3,5); C_FIXDIV( *Fout4,5); - } - scratch[0] = *Fout0; - - C_MUL(scratch[1] ,*Fout1, tw[u*fstride]); - C_MUL(scratch[2] ,*Fout2, tw[2*u*fstride]); - C_MUL(scratch[3] ,*Fout3, tw[3*u*fstride]); - C_MUL(scratch[4] ,*Fout4, tw[4*u*fstride]); - - C_ADD( scratch[7],scratch[1],scratch[4]); - C_SUB( scratch[10],scratch[1],scratch[4]); - C_ADD( scratch[8],scratch[2],scratch[3]); - C_SUB( scratch[9],scratch[2],scratch[3]); - - Fout0->r += scratch[7].r + scratch[8].r; - Fout0->i += scratch[7].i + scratch[8].i; - - scratch[5].r = scratch[0].r + S_MUL(scratch[7].r,ya.r) + S_MUL(scratch[8].r,yb.r); - scratch[5].i = scratch[0].i + S_MUL(scratch[7].i,ya.r) + S_MUL(scratch[8].i,yb.r); - - scratch[6].r = S_MUL(scratch[10].i,ya.i) + S_MUL(scratch[9].i,yb.i); - scratch[6].i = -S_MUL(scratch[10].r,ya.i) - S_MUL(scratch[9].r,yb.i); - - C_SUB(*Fout1,scratch[5],scratch[6]); - C_ADD(*Fout4,scratch[5],scratch[6]); - - scratch[11].r = scratch[0].r + S_MUL(scratch[7].r,yb.r) + S_MUL(scratch[8].r,ya.r); - scratch[11].i = scratch[0].i + S_MUL(scratch[7].i,yb.r) + S_MUL(scratch[8].i,ya.r); - scratch[12].r = - S_MUL(scratch[10].i,yb.i) + S_MUL(scratch[9].i,ya.i); - scratch[12].i = S_MUL(scratch[10].r,yb.i) - S_MUL(scratch[9].r,ya.i); - - C_ADD(*Fout2,scratch[11],scratch[12]); - C_SUB(*Fout3,scratch[11],scratch[12]); - - ++Fout0;++Fout1;++Fout2;++Fout3;++Fout4; - } -} - -/* perform the butterfly for one stage of a mixed radix FFT */ -static void kf_bfly_generic( - kiss_fft_cpx * Fout, - const size_t fstride, - const kiss_fft_cfg st, - int m, - int p - ) -{ - int u,k,q1,q; - kiss_fft_cpx * twiddles = st->twiddles; - kiss_fft_cpx t; - kiss_fft_cpx scratchbuf[17]; - int Norig = st->nfft; - - /*CHECKBUF(scratchbuf,nscratchbuf,p);*/ - if (p>17) - speex_fatal("KissFFT: max radix supported is 17"); - - for ( u=0; uinverse) { - C_FIXDIV(scratchbuf[q1],p); - } - k += m; - } - - k=u; - for ( q1=0 ; q1

=Norig) twidx-=Norig; - C_MUL(t,scratchbuf[q] , twiddles[twidx] ); - C_ADDTO( Fout[ k ] ,t); - } - k += m; - } - } -} - -static -void kf_shuffle( - kiss_fft_cpx * Fout, - const kiss_fft_cpx * f, - const size_t fstride, - int in_stride, - int * factors, - const kiss_fft_cfg st - ) -{ - const int p=*factors++; /* the radix */ - const int m=*factors++; /* stage's fft length/p */ - - /*printf ("fft %d %d %d %d %d %d\n", p*m, m, p, s2, fstride*in_stride, N);*/ - if (m==1) - { - int j; - for (j=0;j32000 || (spx_int32_t)p*(spx_int32_t)p > n) - p = n; /* no more factors, skip to end */ - } - n /= p; - *facbuf++ = p; - *facbuf++ = n; - } while (n > 1); -} -/* - * - * User-callable function to allocate all necessary storage space for the fft. - * - * The return value is a contiguous block of memory, allocated with malloc. As such, - * It can be freed with free(), rather than a kiss_fft-specific function. - * */ -kiss_fft_cfg kiss_fft_alloc(int nfft,int inverse_fft,void * mem,size_t * lenmem ) -{ - kiss_fft_cfg st=NULL; - size_t memneeded = sizeof(struct kiss_fft_state) - + sizeof(kiss_fft_cpx)*(nfft-1); /* twiddle factors*/ - - if ( lenmem==NULL ) { - st = ( kiss_fft_cfg)KISS_FFT_MALLOC( memneeded ); - }else{ - if (mem != NULL && *lenmem >= memneeded) - st = (kiss_fft_cfg)mem; - *lenmem = memneeded; - } - if (st) { - int i; - st->nfft=nfft; - st->inverse = inverse_fft; -#ifdef FIXED_POINT - for (i=0;iinverse) - phase = -phase; - kf_cexp2(st->twiddles+i, DIV32(SHL32(phase,17),nfft)); - } -#else - for (i=0;iinverse) - phase *= -1; - kf_cexp(st->twiddles+i, phase ); - } -#endif - kf_factor(nfft,st->factors); - } - return st; -} - - - - -void kiss_fft_stride(kiss_fft_cfg st,const kiss_fft_cpx *fin,kiss_fft_cpx *fout,int in_stride) -{ - if (fin == fout) - { - speex_fatal("In-place FFT not supported"); - /*CHECKBUF(tmpbuf,ntmpbuf,st->nfft); - kf_work(tmpbuf,fin,1,in_stride, st->factors,st); - SPEEX_MOVE(fout,tmpbuf,st->nfft);*/ - } else { - kf_shuffle( fout, fin, 1,in_stride, st->factors,st); - kf_work( fout, fin, 1,in_stride, st->factors,st, 1, in_stride, 1); - } -} - -void kiss_fft(kiss_fft_cfg cfg,const kiss_fft_cpx *fin,kiss_fft_cpx *fout) -{ - kiss_fft_stride(cfg,fin,fout,1); -} - diff --git a/apps/codecs/libspeex/kiss_fft.h b/apps/codecs/libspeex/kiss_fft.h deleted file mode 100644 index 43319b1ba8..0000000000 --- a/apps/codecs/libspeex/kiss_fft.h +++ /dev/null @@ -1,108 +0,0 @@ -#ifndef KISS_FFT_H -#define KISS_FFT_H - -#include -#include -#include "arch.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* - ATTENTION! - If you would like a : - -- a utility that will handle the caching of fft objects - -- real-only (no imaginary time component ) FFT - -- a multi-dimensional FFT - -- a command-line utility to perform ffts - -- a command-line utility to perform fast-convolution filtering - - Then see kfc.h kiss_fftr.h kiss_fftnd.h fftutil.c kiss_fastfir.c - in the tools/ directory. -*/ - -#ifdef USE_SIMD -# include -# define kiss_fft_scalar __m128 -#define KISS_FFT_MALLOC(nbytes) memalign(16,nbytes) -#else -#define KISS_FFT_MALLOC speex_alloc -#endif - - -#ifdef FIXED_POINT -#include "arch.h" -# define kiss_fft_scalar spx_int16_t -#else -# ifndef kiss_fft_scalar -/* default is float */ -# define kiss_fft_scalar float -# endif -#endif - -typedef struct { - kiss_fft_scalar r; - kiss_fft_scalar i; -}kiss_fft_cpx; - -typedef struct kiss_fft_state* kiss_fft_cfg; - -/* - * kiss_fft_alloc - * - * Initialize a FFT (or IFFT) algorithm's cfg/state buffer. - * - * typical usage: kiss_fft_cfg mycfg=kiss_fft_alloc(1024,0,NULL,NULL); - * - * The return value from fft_alloc is a cfg buffer used internally - * by the fft routine or NULL. - * - * If lenmem is NULL, then kiss_fft_alloc will allocate a cfg buffer using malloc. - * The returned value should be free()d when done to avoid memory leaks. - * - * The state can be placed in a user supplied buffer 'mem': - * If lenmem is not NULL and mem is not NULL and *lenmem is large enough, - * then the function places the cfg in mem and the size used in *lenmem - * and returns mem. - * - * If lenmem is not NULL and ( mem is NULL or *lenmem is not large enough), - * then the function returns NULL and places the minimum cfg - * buffer size in *lenmem. - * */ - -kiss_fft_cfg kiss_fft_alloc(int nfft,int inverse_fft,void * mem,size_t * lenmem); - -/* - * kiss_fft(cfg,in_out_buf) - * - * Perform an FFT on a complex input buffer. - * for a forward FFT, - * fin should be f[0] , f[1] , ... ,f[nfft-1] - * fout will be F[0] , F[1] , ... ,F[nfft-1] - * Note that each element is complex and can be accessed like - f[k].r and f[k].i - * */ -void kiss_fft(kiss_fft_cfg cfg,const kiss_fft_cpx *fin,kiss_fft_cpx *fout); - -/* - A more generic version of the above function. It reads its input from every Nth sample. - * */ -void kiss_fft_stride(kiss_fft_cfg cfg,const kiss_fft_cpx *fin,kiss_fft_cpx *fout,int fin_stride); - -/* If kiss_fft_alloc allocated a buffer, it is one contiguous - buffer and can be simply free()d when no longer needed*/ -#define kiss_fft_free speex_free - -/* - Cleans up some memory that gets managed internally. Not necessary to call, but it might clean up - your compiler output to call this before you exit. -*/ -void kiss_fft_cleanup(void); - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/apps/codecs/libspeex/kiss_fftr.c b/apps/codecs/libspeex/kiss_fftr.c deleted file mode 100644 index 1c694b195d..0000000000 --- a/apps/codecs/libspeex/kiss_fftr.c +++ /dev/null @@ -1,297 +0,0 @@ -/* -Copyright (c) 2003-2004, Mark Borgerding - -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - * Neither the author nor the names of any contributors may be used to endorse or promote products derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifdef HAVE_CONFIG_H -#include "config-speex.h" -#endif - -#include "os_support.h" -#include "kiss_fftr.h" -#include "_kiss_fft_guts.h" - -struct kiss_fftr_state{ - kiss_fft_cfg substate; - kiss_fft_cpx * tmpbuf; - kiss_fft_cpx * super_twiddles; -#ifdef USE_SIMD - long pad; -#endif -}; - -kiss_fftr_cfg kiss_fftr_alloc(int nfft,int inverse_fft,void * mem,size_t * lenmem) -{ - int i; - kiss_fftr_cfg st = NULL; - size_t subsize, memneeded; - - if (nfft & 1) { - speex_warning("Real FFT optimization must be even.\n"); - return NULL; - } - nfft >>= 1; - - kiss_fft_alloc (nfft, inverse_fft, NULL, &subsize); - memneeded = sizeof(struct kiss_fftr_state) + subsize + sizeof(kiss_fft_cpx) * ( nfft * 2); - - if (lenmem == NULL) { - st = (kiss_fftr_cfg) KISS_FFT_MALLOC (memneeded); - } else { - if (*lenmem >= memneeded) - st = (kiss_fftr_cfg) mem; - *lenmem = memneeded; - } - if (!st) - return NULL; - - st->substate = (kiss_fft_cfg) (st + 1); /*just beyond kiss_fftr_state struct */ - st->tmpbuf = (kiss_fft_cpx *) (((char *) st->substate) + subsize); - st->super_twiddles = st->tmpbuf + nfft; - kiss_fft_alloc(nfft, inverse_fft, st->substate, &subsize); - -#ifdef FIXED_POINT - for (i=0;i>1); - if (!inverse_fft) - phase = -phase; - kf_cexp2(st->super_twiddles+i, DIV32(SHL32(phase,16),nfft)); - } -#else - for (i=0;isuper_twiddles+i, phase ); - } -#endif - return st; -} - -void kiss_fftr(kiss_fftr_cfg st,const kiss_fft_scalar *timedata,kiss_fft_cpx *freqdata) -{ - /* input buffer timedata is stored row-wise */ - int k,ncfft; - kiss_fft_cpx fpnk,fpk,f1k,f2k,tw,tdc; - - if ( st->substate->inverse) { - speex_fatal("kiss fft usage error: improper alloc\n"); - } - - ncfft = st->substate->nfft; - - /*perform the parallel fft of two real signals packed in real,imag*/ - kiss_fft( st->substate , (const kiss_fft_cpx*)timedata, st->tmpbuf ); - /* The real part of the DC element of the frequency spectrum in st->tmpbuf - * contains the sum of the even-numbered elements of the input time sequence - * The imag part is the sum of the odd-numbered elements - * - * The sum of tdc.r and tdc.i is the sum of the input time sequence. - * yielding DC of input time sequence - * The difference of tdc.r - tdc.i is the sum of the input (dot product) [1,-1,1,-1... - * yielding Nyquist bin of input time sequence - */ - - tdc.r = st->tmpbuf[0].r; - tdc.i = st->tmpbuf[0].i; - C_FIXDIV(tdc,2); - CHECK_OVERFLOW_OP(tdc.r ,+, tdc.i); - CHECK_OVERFLOW_OP(tdc.r ,-, tdc.i); - freqdata[0].r = tdc.r + tdc.i; - freqdata[ncfft].r = tdc.r - tdc.i; -#ifdef USE_SIMD - freqdata[ncfft].i = freqdata[0].i = _mm_set1_ps(0); -#else - freqdata[ncfft].i = freqdata[0].i = 0; -#endif - - for ( k=1;k <= ncfft/2 ; ++k ) { - fpk = st->tmpbuf[k]; - fpnk.r = st->tmpbuf[ncfft-k].r; - fpnk.i = - st->tmpbuf[ncfft-k].i; - C_FIXDIV(fpk,2); - C_FIXDIV(fpnk,2); - - C_ADD( f1k, fpk , fpnk ); - C_SUB( f2k, fpk , fpnk ); - C_MUL( tw , f2k , st->super_twiddles[k]); - - freqdata[k].r = HALF_OF(f1k.r + tw.r); - freqdata[k].i = HALF_OF(f1k.i + tw.i); - freqdata[ncfft-k].r = HALF_OF(f1k.r - tw.r); - freqdata[ncfft-k].i = HALF_OF(tw.i - f1k.i); - } -} - -void kiss_fftri(kiss_fftr_cfg st,const kiss_fft_cpx *freqdata, kiss_fft_scalar *timedata) -{ - /* input buffer timedata is stored row-wise */ - int k, ncfft; - - if (st->substate->inverse == 0) { - speex_fatal("kiss fft usage error: improper alloc\n"); - } - - ncfft = st->substate->nfft; - - st->tmpbuf[0].r = freqdata[0].r + freqdata[ncfft].r; - st->tmpbuf[0].i = freqdata[0].r - freqdata[ncfft].r; - /*C_FIXDIV(st->tmpbuf[0],2);*/ - - for (k = 1; k <= ncfft / 2; ++k) { - kiss_fft_cpx fk, fnkc, fek, fok, tmp; - fk = freqdata[k]; - fnkc.r = freqdata[ncfft - k].r; - fnkc.i = -freqdata[ncfft - k].i; - /*C_FIXDIV( fk , 2 ); - C_FIXDIV( fnkc , 2 );*/ - - C_ADD (fek, fk, fnkc); - C_SUB (tmp, fk, fnkc); - C_MUL (fok, tmp, st->super_twiddles[k]); - C_ADD (st->tmpbuf[k], fek, fok); - C_SUB (st->tmpbuf[ncfft - k], fek, fok); -#ifdef USE_SIMD - st->tmpbuf[ncfft - k].i *= _mm_set1_ps(-1.0); -#else - st->tmpbuf[ncfft - k].i *= -1; -#endif - } - kiss_fft (st->substate, st->tmpbuf, (kiss_fft_cpx *) timedata); -} - -void kiss_fftr2(kiss_fftr_cfg st,const kiss_fft_scalar *timedata,kiss_fft_scalar *freqdata) -{ - /* input buffer timedata is stored row-wise */ - int k,ncfft; - kiss_fft_cpx f2k,tdc; - spx_word32_t f1kr, f1ki, twr, twi; - - if ( st->substate->inverse) { - speex_fatal("kiss fft usage error: improper alloc\n"); - } - - ncfft = st->substate->nfft; - - /*perform the parallel fft of two real signals packed in real,imag*/ - kiss_fft( st->substate , (const kiss_fft_cpx*)timedata, st->tmpbuf ); - /* The real part of the DC element of the frequency spectrum in st->tmpbuf - * contains the sum of the even-numbered elements of the input time sequence - * The imag part is the sum of the odd-numbered elements - * - * The sum of tdc.r and tdc.i is the sum of the input time sequence. - * yielding DC of input time sequence - * The difference of tdc.r - tdc.i is the sum of the input (dot product) [1,-1,1,-1... - * yielding Nyquist bin of input time sequence - */ - - tdc.r = st->tmpbuf[0].r; - tdc.i = st->tmpbuf[0].i; - C_FIXDIV(tdc,2); - CHECK_OVERFLOW_OP(tdc.r ,+, tdc.i); - CHECK_OVERFLOW_OP(tdc.r ,-, tdc.i); - freqdata[0] = tdc.r + tdc.i; - freqdata[2*ncfft-1] = tdc.r - tdc.i; - - for ( k=1;k <= ncfft/2 ; ++k ) - { - /*fpk = st->tmpbuf[k]; - fpnk.r = st->tmpbuf[ncfft-k].r; - fpnk.i = - st->tmpbuf[ncfft-k].i; - C_FIXDIV(fpk,2); - C_FIXDIV(fpnk,2); - - C_ADD( f1k, fpk , fpnk ); - C_SUB( f2k, fpk , fpnk ); - - C_MUL( tw , f2k , st->super_twiddles[k]); - - freqdata[2*k-1] = HALF_OF(f1k.r + tw.r); - freqdata[2*k] = HALF_OF(f1k.i + tw.i); - freqdata[2*(ncfft-k)-1] = HALF_OF(f1k.r - tw.r); - freqdata[2*(ncfft-k)] = HALF_OF(tw.i - f1k.i); - */ - - /*f1k.r = PSHR32(ADD32(EXTEND32(st->tmpbuf[k].r), EXTEND32(st->tmpbuf[ncfft-k].r)),1); - f1k.i = PSHR32(SUB32(EXTEND32(st->tmpbuf[k].i), EXTEND32(st->tmpbuf[ncfft-k].i)),1); - f2k.r = PSHR32(SUB32(EXTEND32(st->tmpbuf[k].r), EXTEND32(st->tmpbuf[ncfft-k].r)),1); - f2k.i = SHR32(ADD32(EXTEND32(st->tmpbuf[k].i), EXTEND32(st->tmpbuf[ncfft-k].i)),1); - - C_MUL( tw , f2k , st->super_twiddles[k]); - - freqdata[2*k-1] = HALF_OF(f1k.r + tw.r); - freqdata[2*k] = HALF_OF(f1k.i + tw.i); - freqdata[2*(ncfft-k)-1] = HALF_OF(f1k.r - tw.r); - freqdata[2*(ncfft-k)] = HALF_OF(tw.i - f1k.i); - */ - f2k.r = SHR32(SUB32(EXTEND32(st->tmpbuf[k].r), EXTEND32(st->tmpbuf[ncfft-k].r)),1); - f2k.i = PSHR32(ADD32(EXTEND32(st->tmpbuf[k].i), EXTEND32(st->tmpbuf[ncfft-k].i)),1); - - f1kr = SHL32(ADD32(EXTEND32(st->tmpbuf[k].r), EXTEND32(st->tmpbuf[ncfft-k].r)),13); - f1ki = SHL32(SUB32(EXTEND32(st->tmpbuf[k].i), EXTEND32(st->tmpbuf[ncfft-k].i)),13); - - twr = SHR32(SUB32(MULT16_16(f2k.r,st->super_twiddles[k].r),MULT16_16(f2k.i,st->super_twiddles[k].i)), 1); - twi = SHR32(ADD32(MULT16_16(f2k.i,st->super_twiddles[k].r),MULT16_16(f2k.r,st->super_twiddles[k].i)), 1); - -#ifdef FIXED_POINT - freqdata[2*k-1] = PSHR32(f1kr + twr, 15); - freqdata[2*k] = PSHR32(f1ki + twi, 15); - freqdata[2*(ncfft-k)-1] = PSHR32(f1kr - twr, 15); - freqdata[2*(ncfft-k)] = PSHR32(twi - f1ki, 15); -#else - freqdata[2*k-1] = .5f*(f1kr + twr); - freqdata[2*k] = .5f*(f1ki + twi); - freqdata[2*(ncfft-k)-1] = .5f*(f1kr - twr); - freqdata[2*(ncfft-k)] = .5f*(twi - f1ki); - -#endif - } -} - -void kiss_fftri2(kiss_fftr_cfg st,const kiss_fft_scalar *freqdata,kiss_fft_scalar *timedata) -{ - /* input buffer timedata is stored row-wise */ - int k, ncfft; - - if (st->substate->inverse == 0) { - speex_fatal ("kiss fft usage error: improper alloc\n"); - } - - ncfft = st->substate->nfft; - - st->tmpbuf[0].r = freqdata[0] + freqdata[2*ncfft-1]; - st->tmpbuf[0].i = freqdata[0] - freqdata[2*ncfft-1]; - /*C_FIXDIV(st->tmpbuf[0],2);*/ - - for (k = 1; k <= ncfft / 2; ++k) { - kiss_fft_cpx fk, fnkc, fek, fok, tmp; - fk.r = freqdata[2*k-1]; - fk.i = freqdata[2*k]; - fnkc.r = freqdata[2*(ncfft - k)-1]; - fnkc.i = -freqdata[2*(ncfft - k)]; - /*C_FIXDIV( fk , 2 ); - C_FIXDIV( fnkc , 2 );*/ - - C_ADD (fek, fk, fnkc); - C_SUB (tmp, fk, fnkc); - C_MUL (fok, tmp, st->super_twiddles[k]); - C_ADD (st->tmpbuf[k], fek, fok); - C_SUB (st->tmpbuf[ncfft - k], fek, fok); -#ifdef USE_SIMD - st->tmpbuf[ncfft - k].i *= _mm_set1_ps(-1.0); -#else - st->tmpbuf[ncfft - k].i *= -1; -#endif - } - kiss_fft (st->substate, st->tmpbuf, (kiss_fft_cpx *) timedata); -} diff --git a/apps/codecs/libspeex/kiss_fftr.h b/apps/codecs/libspeex/kiss_fftr.h deleted file mode 100644 index 7bfb423340..0000000000 --- a/apps/codecs/libspeex/kiss_fftr.h +++ /dev/null @@ -1,51 +0,0 @@ -#ifndef KISS_FTR_H -#define KISS_FTR_H - -#include "kiss_fft.h" -#ifdef __cplusplus -extern "C" { -#endif - - -/* - - Real optimized version can save about 45% cpu time vs. complex fft of a real seq. - - - - */ - -typedef struct kiss_fftr_state *kiss_fftr_cfg; - - -kiss_fftr_cfg kiss_fftr_alloc(int nfft,int inverse_fft,void * mem, size_t * lenmem); -/* - nfft must be even - - If you don't care to allocate space, use mem = lenmem = NULL -*/ - - -void kiss_fftr(kiss_fftr_cfg cfg,const kiss_fft_scalar *timedata,kiss_fft_cpx *freqdata); -/* - input timedata has nfft scalar points - output freqdata has nfft/2+1 complex points -*/ - -void kiss_fftr2(kiss_fftr_cfg st,const kiss_fft_scalar *timedata,kiss_fft_scalar *freqdata); - -void kiss_fftri(kiss_fftr_cfg cfg,const kiss_fft_cpx *freqdata,kiss_fft_scalar *timedata); - -void kiss_fftri2(kiss_fftr_cfg st,const kiss_fft_scalar *freqdata, kiss_fft_scalar *timedata); - -/* - input freqdata has nfft/2+1 complex points - output timedata has nfft scalar points -*/ - -#define kiss_fftr_free speex_free - -#ifdef __cplusplus -} -#endif -#endif diff --git a/apps/codecs/libspeex/libspeex.make b/apps/codecs/libspeex/libspeex.make deleted file mode 100644 index 1089982d27..0000000000 --- a/apps/codecs/libspeex/libspeex.make +++ /dev/null @@ -1,66 +0,0 @@ -# __________ __ ___. -# Open \______ \ ____ ____ | | _\_ |__ _______ ___ -# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / -# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < -# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ -# \/ \/ \/ \/ \/ -# $Id$ -# - -# we need to build two different speex libraries -# (one for codec, one for core voice) -# so a little trickery is necessary - -# disable strict aliasing optimizations for now, it gives warnings due to -# some horrid typecasting -_SPEEXFLAGS = $(filter-out -fstrict-aliasing, $(CODECFLAGS)) \ - -fno-strict-aliasing -DHAVE_CONFIG_H -DSPEEX_DISABLE_ENCODER \ - -I$(APPSDIR)/codecs/libspeex - -# build voice codec with core -O switch -VOICESPEEXFLAGS = $(filter-out -ffunction-sections, $(filter-out -DCODEC,$(_SPEEXFLAGS))) -DROCKBOX_VOICE_CODEC - -# libspeex is faster on ARM-targets with -O1 instead of -O2 -SPEEXFLAGS = $(filter-out -O%,$(_SPEEXFLAGS)) - -ifeq ($(ARCH),arch_arm) - SPEEXFLAGS += -O1 -else - SPEEXFLAGS += -O2 -endif - -# libspeex -SPEEXLIB := $(CODECDIR)/libspeex.a -SPEEXLIB_SRC := $(call preprocess, $(APPSDIR)/codecs/libspeex/SOURCES) -SPEEXLIB_OBJ := $(call c2obj, $(SPEEXLIB_SRC)) -OTHER_SRC += $(SPEEXLIB_SRC) - -$(SPEEXLIB): $(SPEEXLIB_OBJ) - $(SILENT)$(shell rm -f $@) - $(call PRINTS,AR $(@F))$(AR) rcs $@ $^ >/dev/null - -# libspeex-voice -VOICESPEEXLIB := $(CODECDIR)/libspeex-voice.a -VOICESPEEXLIB_SRC := $(call preprocess, $(APPSDIR)/codecs/libspeex/SOURCES) -VOICESPEEXLIB_OBJ := $(addsuffix .o,$(basename $(subst $(ROOTDIR)/apps/codecs/libspeex,$(BUILDDIR)/apps/codecs/libspeex-voice,$(VOICESPEEXLIB_SRC)))) - -$(VOICESPEEXLIB): $(VOICESPEEXLIB_OBJ) - $(call PRINTS,AR $(@F))$(AR) rcs $@ $^ >/dev/null - -# pattern rules - -$(CODECDIR)/libspeex-voice/%.o : $(ROOTDIR)/apps/codecs/libspeex/%.c - $(SILENT)mkdir -p $(dir $@) - $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) $(VOICESPEEXFLAGS) -c $< -o $@ - -$(CODECDIR)/libspeex-voice/%.o : $(ROOTDIR)/apps/codecs/libspeex/%.S - $(SILENT)mkdir -p $(dir $@) - $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) $(VOICESPEEXFLAGS) $(ASMFLAGS) -c $< -o $@ - -$(CODECDIR)/libspeex/%.o: $(ROOTDIR)/apps/codecs/libspeex/%.c - $(SILENT)mkdir -p $(dir $@) - $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) $(SPEEXFLAGS) -c $< -o $@ - -$(CODECDIR)/libspeex/%.o: $(ROOTDIR)/apps/codecs/libspeex/%.S - $(SILENT)mkdir -p $(dir $@) - $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) $(SPEEXFLAGS) $(ASMFLAGS) -c $< -o $@ diff --git a/apps/codecs/libspeex/lpc.c b/apps/codecs/libspeex/lpc.c deleted file mode 100644 index 9845633a6c..0000000000 --- a/apps/codecs/libspeex/lpc.c +++ /dev/null @@ -1,201 +0,0 @@ -/* - Copyright 1992, 1993, 1994 by Jutta Degener and Carsten Bormann, - Technische Universitaet Berlin - - Any use of this software is permitted provided that this notice is not - removed and that neither the authors nor the Technische Universitaet Berlin - are deemed to have made any representations as to the suitability of this - software for any purpose nor are held responsible for any defects of - this software. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE. - - As a matter of courtesy, the authors request to be informed about uses - this software has found, about bugs in this software, and about any - improvements that may be of general interest. - - Berlin, 28.11.1994 - Jutta Degener - Carsten Bormann - - - Code modified by Jean-Marc Valin - - Speex License: - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of the Xiph.org Foundation nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifdef HAVE_CONFIG_H -#include "config-speex.h" -#endif - -#include "lpc.h" - -#ifdef BFIN_ASM -#include "lpc_bfin.h" -#endif - -/* LPC analysis - * - * The next two functions calculate linear prediction coefficients - * and/or the related reflection coefficients from the first P_MAX+1 - * values of the autocorrelation function. - */ - -/* Invented by N. Levinson in 1947, modified by J. Durbin in 1959. - */ - -/* returns minimum mean square error */ -spx_word32_t _spx_lpc( -spx_coef_t *lpc, /* out: [0...p-1] LPC coefficients */ -const spx_word16_t *ac, /* in: [0...p] autocorrelation values */ -int p -) -{ - int i, j; - spx_word16_t r; - spx_word16_t error = ac[0]; - - if (ac[0] == 0) - { - for (i = 0; i < p; i++) - lpc[i] = 0; - return 0; - } - - for (i = 0; i < p; i++) { - - /* Sum up this iteration's reflection coefficient */ - spx_word32_t rr = NEG32(SHL32(EXTEND32(ac[i + 1]),13)); - for (j = 0; j < i; j++) - rr = SUB32(rr,MULT16_16(lpc[j],ac[i - j])); -#ifdef FIXED_POINT - r = DIV32_16(rr+PSHR32(error,1),ADD16(error,8)); -#else - r = rr/(error+.003*ac[0]); -#endif - /* Update LPC coefficients and total error */ - lpc[i] = r; - for (j = 0; j < i>>1; j++) - { - spx_word16_t tmp = lpc[j]; - lpc[j] = MAC16_16_P13(lpc[j],r,lpc[i-1-j]); - lpc[i-1-j] = MAC16_16_P13(lpc[i-1-j],r,tmp); - } - if (i & 1) - lpc[j] = MAC16_16_P13(lpc[j],lpc[j],r); - - error = SUB16(error,MULT16_16_Q13(r,MULT16_16_Q13(error,r))); - } - return error; -} - - -#ifdef FIXED_POINT - -/* Compute the autocorrelation - * ,--, - * ac(i) = > x(n) * x(n-i) for all n - * `--' - * for lags between 0 and lag-1, and x == 0 outside 0...n-1 - */ - -#ifndef OVERRIDE_SPEEX_AUTOCORR -void _spx_autocorr( -const spx_word16_t *x, /* in: [0...n-1] samples x */ -spx_word16_t *ac, /* out: [0...lag-1] ac values */ -int lag, -int n -) -{ - spx_word32_t d; - int i, j; - spx_word32_t ac0=1; - int shift, ac_shift; - - for (j=0;j x(n) * x(n-i) for all n - * `--' - * for lags between 0 and lag-1, and x == 0 outside 0...n-1 - */ -void _spx_autocorr( -const spx_word16_t *x, /* in: [0...n-1] samples x */ -float *ac, /* out: [0...lag-1] ac values */ -int lag, -int n -) -{ - float d; - int i; - while (lag--) - { - for (i = lag, d = 0; i < n; i++) - d += x[i] * x[i-lag]; - ac[lag] = d; - } - ac[0] += 10; -} - -#endif - - diff --git a/apps/codecs/libspeex/lpc.h b/apps/codecs/libspeex/lpc.h deleted file mode 100644 index 952ecdd933..0000000000 --- a/apps/codecs/libspeex/lpc.h +++ /dev/null @@ -1,53 +0,0 @@ -/* Copyright (C) 2002 Jean-Marc Valin */ -/** - @file lpc.h - @brief Functions for LPC (Linear Prediction Coefficients) analysis -*/ -/* - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of the Xiph.org Foundation nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef LPC_H -#define LPC_H - -#include "arch.h" - -void _spx_autocorr( - const spx_word16_t * x, /* in: [0...n-1] samples x */ - spx_word16_t *ac, /* out: [0...lag-1] ac values */ - int lag, int n); - -spx_word32_t /* returns minimum mean square error */ -_spx_lpc( - spx_coef_t * lpc, /* [0...p-1] LPC coefficients */ - const spx_word16_t * ac, /* in: [0...p] autocorrelation values */ - int p - ); - - -#endif diff --git a/apps/codecs/libspeex/lpc_bfin.h b/apps/codecs/libspeex/lpc_bfin.h deleted file mode 100644 index 7310ffba52..0000000000 --- a/apps/codecs/libspeex/lpc_bfin.h +++ /dev/null @@ -1,131 +0,0 @@ -/* Copyright (C) 2005 Analog Devices */ -/** - @file lpc_bfin.h - @author Jean-Marc Valin - @brief Functions for LPC (Linear Prediction Coefficients) analysis (Blackfin version) -*/ -/* - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of the Xiph.org Foundation nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#define OVERRIDE_SPEEX_AUTOCORR -void _spx_autocorr( -const spx_word16_t *x, /* in: [0...n-1] samples x */ -spx_word16_t *ac, /* out: [0...lag-1] ac values */ -int lag, -int n - ) -{ - spx_word32_t d; - const spx_word16_t *xs; - int i, j; - spx_word32_t ac0=1; - spx_word32_t ac32[11], *ac32top; - int shift, ac_shift; - ac32top = ac32+lag-1; - int lag_1, N_lag; - int nshift; - lag_1 = lag-1; - N_lag = n-lag_1; - for (j=0;j> 1;\n\t" - "LOOP_BEGIN pitch%=;\n\t" - "I1 = P0;\n\t" - "A1 = A0 = 0;\n\t" - "R1 = [I1++];\n\t" - "LOOP inner_prod%= LC1 = P3 >> 1;\n\t" - "LOOP_BEGIN inner_prod%=;\n\t" - "A1 += R0.L*R1.H, A0 += R0.L*R1.L (IS) || R1.L = W[I1++];\n\t" - "A1 += R0.H*R1.L, A0 += R0.H*R1.H (IS) || R1.H = W[I1++] || R0 = [I0++];\n\t" - "LOOP_END inner_prod%=;\n\t" - "A0 = ASHIFT A0 by R4.L;\n\t" - "A1 = ASHIFT A1 by R4.L;\n\t" - - "R2 = A0, R3 = A1;\n\t" - "[P1--] = R2;\n\t" - "[P1--] = R3;\n\t" - "P0 += 4;\n\t" - "LOOP_END pitch%=;\n\t" - : : "m" (xs), "m" (x), "m" (ac32top), "m" (N_lag), "m" (lag_1), "m" (nshift) - : "A0", "A1", "P0", "P1", "P2", "P3", "P4", "R0", "R1", "R2", "R3", "R4", "I0", "I1", "L0", "L1", "B0", "B1", "memory" - ); - d=0; - for (j=0;j -#include "lsp.h" -#include "stack_alloc.h" -#include "math_approx.h" - -#ifndef M_PI -#define M_PI 3.14159265358979323846 /* pi */ -#endif - -#ifndef NULL -#define NULL 0 -#endif - -#ifdef FIXED_POINT - -#define FREQ_SCALE 16384 - -/*#define ANGLE2X(a) (32768*cos(((a)/8192.)))*/ -#define ANGLE2X(a) (SHL16(spx_cos(a),2)) - -/*#define X2ANGLE(x) (acos(.00006103515625*(x))*LSP_SCALING)*/ -#define X2ANGLE(x) (spx_acos(x)) - -#ifdef BFIN_ASM -#include "lsp_bfin.h" -#endif - -#else - -/*#define C1 0.99940307 -#define C2 -0.49558072 -#define C3 0.03679168*/ - -#define FREQ_SCALE 1. -#define ANGLE2X(a) (spx_cos(a)) -#define X2ANGLE(x) (acos(x)) - -#endif - - -/*---------------------------------------------------------------------------*\ - - FUNCTION....: cheb_poly_eva() - - AUTHOR......: David Rowe - DATE CREATED: 24/2/93 - - This function evaluates a series of Chebyshev polynomials - -\*---------------------------------------------------------------------------*/ - -#ifndef SPEEX_DISABLE_ENCODER - -#ifdef FIXED_POINT - -#ifndef OVERRIDE_CHEB_POLY_EVA -static inline spx_word32_t cheb_poly_eva( - spx_word16_t *coef, /* P or Q coefs in Q13 format */ - spx_word16_t x, /* cos of freq (-1.0 to 1.0) in Q14 format */ - int m, /* LPC order/2 */ - char *stack -) -{ - int i; - spx_word16_t b0, b1; - spx_word32_t sum; - - /*Prevents overflows*/ - if (x>16383) - x = 16383; - if (x<-16383) - x = -16383; - - /* Initialise values */ - b1=16384; - b0=x; - - /* Evaluate Chebyshev series formulation usin g iterative approach */ - sum = ADD32(EXTEND32(coef[m]), EXTEND32(MULT16_16_P14(coef[m-1],x))); - for(i=2;i<=m;i++) - { - spx_word16_t tmp=b0; - b0 = SUB16(MULT16_16_Q13(x,b0), b1); - b1 = tmp; - sum = ADD32(sum, EXTEND32(MULT16_16_P14(coef[m-i],b0))); - } - - return sum; -} -#endif - -#else - -static float cheb_poly_eva(spx_word32_t *coef, spx_word16_t x, int m, char *stack) -{ - int k; - float b0, b1, tmp; - - /* Initial conditions */ - b0=0; /* b_(m+1) */ - b1=0; /* b_(m+2) */ - - x*=2; - - /* Calculate the b_(k) */ - for(k=m;k>0;k--) - { - tmp=b0; /* tmp holds the previous value of b0 */ - b0=x*b0-b1+coef[m-k]; /* b0 holds its new value based on b0 and b1 */ - b1=tmp; /* b1 holds the previous value of b0 */ - } - - return(-b1+.5*x*b0+coef[m]); -} -#endif - -/*---------------------------------------------------------------------------*\ - - FUNCTION....: lpc_to_lsp() - - AUTHOR......: David Rowe - DATE CREATED: 24/2/93 - - This function converts LPC coefficients to LSP - coefficients. - -\*---------------------------------------------------------------------------*/ - -#ifdef FIXED_POINT -#define SIGN_CHANGE(a,b) (((a)&0x70000000)^((b)&0x70000000)||(b==0)) -#else -#define SIGN_CHANGE(a,b) (((a)*(b))<0.0) -#endif - - -int lpc_to_lsp (spx_coef_t *a,int lpcrdr,spx_lsp_t *freq,int nb,spx_word16_t delta, char *stack) -/* float *a lpc coefficients */ -/* int lpcrdr order of LPC coefficients (10) */ -/* float *freq LSP frequencies in the x domain */ -/* int nb number of sub-intervals (4) */ -/* float delta grid spacing interval (0.02) */ - - -{ - spx_word16_t temp_xr,xl,xr,xm=0; - spx_word32_t psuml,psumr,psumm,temp_psumr/*,temp_qsumr*/; - int i,j,m,flag,k; - VARDECL(spx_word32_t *Q); /* ptrs for memory allocation */ - VARDECL(spx_word32_t *P); - VARDECL(spx_word16_t *Q16); /* ptrs for memory allocation */ - VARDECL(spx_word16_t *P16); - spx_word32_t *px; /* ptrs of respective P'(z) & Q'(z) */ - spx_word32_t *qx; - spx_word32_t *p; - spx_word32_t *q; - spx_word16_t *pt; /* ptr used for cheb_poly_eval() - whether P' or Q' */ - int roots=0; /* DR 8/2/94: number of roots found */ - flag = 1; /* program is searching for a root when, - 1 else has found one */ - m = lpcrdr/2; /* order of P'(z) & Q'(z) polynomials */ - - /* Allocate memory space for polynomials */ - ALLOC(Q, (m+1), spx_word32_t); - ALLOC(P, (m+1), spx_word32_t); - - /* determine P'(z)'s and Q'(z)'s coefficients where - P'(z) = P(z)/(1 + z^(-1)) and Q'(z) = Q(z)/(1-z^(-1)) */ - - px = P; /* initialise ptrs */ - qx = Q; - p = px; - q = qx; - -#ifdef FIXED_POINT - *px++ = LPC_SCALING; - *qx++ = LPC_SCALING; - for(i=0;i=32768) - speex_warning_int("px", *px); - if (fabs(*qx)>=32768) - speex_warning_int("qx", *qx);*/ - *px = PSHR32(*px,2); - *qx = PSHR32(*qx,2); - px++; - qx++; - } - /* The reason for this lies in the way cheb_poly_eva() is implemented for fixed-point */ - P[m] = PSHR32(P[m],3); - Q[m] = PSHR32(Q[m],3); -#else - *px++ = LPC_SCALING; - *qx++ = LPC_SCALING; - for(i=0;i= -FREQ_SCALE)){ - spx_word16_t dd; - /* Modified by JMV to provide smaller steps around x=+-1 */ -#ifdef FIXED_POINT - dd = MULT16_16_Q15(delta,SUB16(FREQ_SCALE, MULT16_16_Q14(MULT16_16_Q14(xl,xl),14000))); - if (psuml<512 && psuml>-512) - dd = PSHR16(dd,1); -#else - dd=delta*(1-.9*xl*xl); - if (fabs(psuml)<.2) - dd *= .5; -#endif - xr = SUB16(xl, dd); /* interval spacing */ - psumr = cheb_poly_eva(pt,xr,m,stack);/* poly(xl-delta_x) */ - temp_psumr = psumr; - temp_xr = xr; - - /* if no sign change increment xr and re-evaluate poly(xr). Repeat til - sign change. - if a sign change has occurred the interval is bisected and then - checked again for a sign change which determines in which - interval the zero lies in. - If there is no sign change between poly(xm) and poly(xl) set interval - between xm and xr else set interval between xl and xr and repeat till - root is located within the specified limits */ - - if(SIGN_CHANGE(psumr,psuml)) - { - roots++; - - psumm=psuml; - for(k=0;k<=nb;k++){ -#ifdef FIXED_POINT - xm = ADD16(PSHR16(xl,1),PSHR16(xr,1)); /* bisect the interval */ -#else - xm = .5*(xl+xr); /* bisect the interval */ -#endif - psumm=cheb_poly_eva(pt,xm,m,stack); - /*if(psumm*psuml>0.)*/ - if(!SIGN_CHANGE(psumm,psuml)) - { - psuml=psumm; - xl=xm; - } else { - psumr=psumm; - xr=xm; - } - } - - /* once zero is found, reset initial interval to xr */ - freq[j] = X2ANGLE(xm); - xl = xm; - flag = 0; /* reset flag for next search */ - } - else{ - psuml=temp_psumr; - xl=temp_xr; - } - } - } - return(roots); -} - -#endif /* SPEEX_DISABLE_ENCODER */ - -/*---------------------------------------------------------------------------*\ - - FUNCTION....: lsp_to_lpc() - - AUTHOR......: David Rowe - DATE CREATED: 24/2/93 - - Converts LSP coefficients to LPC coefficients. - -\*---------------------------------------------------------------------------*/ - -#ifdef FIXED_POINT - -void lsp_to_lpc(spx_lsp_t *freq,spx_coef_t *ak,int lpcrdr, char *stack) -/* float *freq array of LSP frequencies in the x domain */ -/* float *ak array of LPC coefficients */ -/* int lpcrdr order of LPC coefficients */ -{ - (void)stack; - int i,j; - spx_word32_t xout1,xout2,xin; - spx_word32_t mult, a; - VARDECL(spx_word16_t *freqn); - VARDECL(spx_word32_t **xp); - VARDECL(spx_word32_t *xpmem); - VARDECL(spx_word32_t **xq); - VARDECL(spx_word32_t *xqmem); - int m = lpcrdr>>1; - - /* - - Reconstruct P(z) and Q(z) by cascading second order polynomials - in form 1 - 2cos(w)z(-1) + z(-2), where w is the LSP frequency. - In the time domain this is: - - y(n) = x(n) - 2cos(w)x(n-1) + x(n-2) - - This is what the ALLOCS below are trying to do: - - int xp[m+1][lpcrdr+1+2]; // P matrix in QIMP - int xq[m+1][lpcrdr+1+2]; // Q matrix in QIMP - - These matrices store the output of each stage on each row. The - final (m-th) row has the output of the final (m-th) cascaded - 2nd order filter. The first row is the impulse input to the - system (not written as it is known). - - The version below takes advantage of the fact that a lot of the - outputs are zero or known, for example if we put an inpulse - into the first section the "clock" it 10 times only the first 3 - outputs samples are non-zero (it's an FIR filter). - */ - - ALLOC(xp, (m+1), spx_word32_t*); - ALLOC(xpmem, (m+1)*(lpcrdr+1+2), spx_word32_t); - - ALLOC(xq, (m+1), spx_word32_t*); - ALLOC(xqmem, (m+1)*(lpcrdr+1+2), spx_word32_t); - - for(i=0; i<=m; i++) { - xp[i] = xpmem + i*(lpcrdr+1+2); - xq[i] = xqmem + i*(lpcrdr+1+2); - } - - /* work out 2cos terms in Q14 */ - - ALLOC(freqn, lpcrdr, spx_word16_t); - for (i=0;i 32767) a = 32767; - ak[j-1] = (short)a; - - } - -} - -#else - -void lsp_to_lpc(spx_lsp_t *freq,spx_coef_t *ak,int lpcrdr, char *stack) -/* float *freq array of LSP frequencies in the x domain */ -/* float *ak array of LPC coefficients */ -/* int lpcrdr order of LPC coefficients */ - - -{ - int i,j; - float xout1,xout2,xin1,xin2; - VARDECL(float *Wp); - float *pw,*n1,*n2,*n3,*n4=NULL; - VARDECL(float *x_freq); - int m = lpcrdr>>1; - - ALLOC(Wp, 4*m+2, float); - pw = Wp; - - /* initialise contents of array */ - - for(i=0;i<=4*m+1;i++){ /* set contents of buffer to 0 */ - *pw++ = 0.0; - } - - /* Set pointers up */ - - pw = Wp; - xin1 = 1.0; - xin2 = 1.0; - - ALLOC(x_freq, lpcrdr, float); - for (i=0;i0) - ak[j-1] = (xout1 + xout2)*0.5f; - *(n4+1) = xin1; - *(n4+2) = xin2; - - xin1 = 0.0; - xin2 = 0.0; - } - -} -#endif - - -#ifdef FIXED_POINT - -/*Makes sure the LSPs are stable*/ -void lsp_enforce_margin(spx_lsp_t *lsp, int len, spx_word16_t margin) -{ - int i; - spx_word16_t m = margin; - spx_word16_t m2 = 25736-margin; - - if (lsp[0]m2) - lsp[len-1]=m2; - for (i=1;ilsp[i+1]-m) - lsp[i]= SHR16(lsp[i],1) + SHR16(lsp[i+1]-m,1); - } -} - - -void lsp_interpolate(spx_lsp_t *old_lsp, spx_lsp_t *new_lsp, spx_lsp_t *interp_lsp, int len, int subframe, int nb_subframes) -{ - int i; - spx_word16_t tmp = DIV32_16(SHL32(EXTEND32(1 + subframe),14),nb_subframes); - spx_word16_t tmp2 = 16384-tmp; - for (i=0;iLSP_SCALING*(M_PI-margin)) - lsp[len-1]=LSP_SCALING*(M_PI-margin); - for (i=1;ilsp[i+1]-LSP_SCALING*margin) - lsp[i]= .5f* (lsp[i] + lsp[i+1]-LSP_SCALING*margin); - } -} - - -void lsp_interpolate(spx_lsp_t *old_lsp, spx_lsp_t *new_lsp, spx_lsp_t *interp_lsp, int len, int subframe, int nb_subframes) -{ - int i; - float tmp = (1.0f + subframe)/nb_subframes; - for (i=0;i>>= 14;\n\t" - "R3 = R3 + R5;\n\t" - - "R0 = R2;\n\t" /* R0: b0 */ - "R1 = 16384;\n\t" /* R1: b1 */ - "LOOP cpe%= LC0 = %3;\n\t" - "LOOP_BEGIN cpe%=;\n\t" - "P1 = R0;\n\t" - "R0 = R2.L * R0.L (IS) || R5 = W[P0--] (X);\n\t" - "R0 >>>= 13;\n\t" - "R0 = R0 - R1;\n\t" - "R1 = P1;\n\t" - "R5 = R5.L * R0.L (IS);\n\t" - "R5 = R5 + R4;\n\t" - "R5 >>>= 14;\n\t" - "R3 = R3 + R5;\n\t" - "LOOP_END cpe%=;\n\t" - "%0 = R3;\n\t" - : "=&d" (sum) - : "a" (x), "a" (&coef[m]), "a" (m-1) - : "R0", "R1", "R3", "R2", "R4", "R5", "P0", "P1" - ); - return sum; -} -#endif - - - diff --git a/apps/codecs/libspeex/lsp_tables_nb.c b/apps/codecs/libspeex/lsp_tables_nb.c deleted file mode 100644 index 6bdd2e4d0f..0000000000 --- a/apps/codecs/libspeex/lsp_tables_nb.c +++ /dev/null @@ -1,362 +0,0 @@ -/* Copyright (C) 2002 Jean-Marc Valin - File: lsp_tables_nb.c - Codebooks for LSPs in narrowband CELP mode - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are - met: - - 1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - 3. The name of the author may not be used to endorse or promote products - derived from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, - INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. -*/ - -#include "config-speex.h" - -const signed char cdbk_nb[640] LSP_ICONST_ATTR = { -30,19,38,34,40,32,46,43,58,43, -5,-18,-25,-40,-33,-55,-52,20,34,28, --20,-63,-97,-92,61,53,47,49,53,75, --14,-53,-77,-79,0,-3,-5,19,22,26, --9,-53,-55,66,90,72,85,68,74,52, --4,-41,-58,-31,-18,-31,27,32,30,18, -24,3,8,5,-12,-3,26,28,74,63, --2,-39,-67,-77,-106,-74,59,59,73,65, -44,40,71,72,82,83,98,88,89,60, --6,-31,-47,-48,-13,-39,-9,7,2,79, --1,-39,-60,-17,87,81,65,50,45,19, --21,-67,-91,-87,-41,-50,7,18,39,74, -10,-31,-28,39,24,13,23,5,56,45, -29,10,-5,-13,-11,-35,-18,-8,-10,-8, --25,-71,-77,-21,2,16,50,63,87,87, -5,-32,-40,-51,-68,0,12,6,54,34, -5,-12,32,52,68,64,69,59,65,45, -14,-16,-31,-40,-65,-67,41,49,47,37, --11,-52,-75,-84,-4,57,48,42,42,33, --11,-51,-68,-6,13,0,8,-8,26,32, --23,-53,0,36,56,76,97,105,111,97, --1,-28,-39,-40,-43,-54,-44,-40,-18,35, -16,-20,-19,-28,-42,29,47,38,74,45, -3,-29,-48,-62,-80,-104,-33,56,59,59, -10,17,46,72,84,101,117,123,123,106, --7,-33,-49,-51,-70,-67,-27,-31,70,67, --16,-62,-85,-20,82,71,86,80,85,74, --19,-58,-75,-45,-29,-33,-18,-25,45,57, --12,-42,-5,12,28,36,52,64,81,82, -13,-9,-27,-28,22,3,2,22,26,6, --6,-44,-51,2,15,10,48,43,49,34, --19,-62,-84,-89,-102,-24,8,17,61,68, -39,24,23,19,16,-5,12,15,27,15, --8,-44,-49,-60,-18,-32,-28,52,54,62, --8,-48,-77,-70,66,101,83,63,61,37, --12,-50,-75,-64,33,17,13,25,15,77, -1,-42,-29,72,64,46,49,31,61,44, --8,-47,-54,-46,-30,19,20,-1,-16,0, -16,-12,-18,-9,-26,-27,-10,-22,53,45, --10,-47,-75,-82,-105,-109,8,25,49,77, -50,65,114,117,124,118,115,96,90,61, --9,-45,-63,-60,-75,-57,8,11,20,29, -0,-35,-49,-43,40,47,35,40,55,38, --24,-76,-103,-112,-27,3,23,34,52,75, -8,-29,-43,12,63,38,35,29,24,8, -25,11,1,-15,-18,-43,-7,37,40,21, --20,-56,-19,-19,-4,-2,11,29,51,63, --2,-44,-62,-75,-89,30,57,51,74,51, -50,46,68,64,65,52,63,55,65,43, -18,-9,-26,-35,-55,-69,3,6,8,17, --15,-61,-86,-97,1,86,93,74,78,67, --1,-38,-66,-48,48,39,29,25,17,-1, -13,13,29,39,50,51,69,82,97,98, --2,-36,-46,-27,-16,-30,-13,-4,-7,-4, -25,-5,-11,-6,-25,-21,33,12,31,29, --8,-38,-52,-63,-68,-89,-33,-1,10,74, --2,-15,59,91,105,105,101,87,84,62, --7,-33,-50,-35,-54,-47,25,17,82,81, --13,-56,-83,21,58,31,42,25,72,65, --24,-66,-91,-56,9,-2,21,10,69,75, -2,-24,11,22,25,28,38,34,48,33, -7,-29,-26,17,15,-1,14,0,-2,0, --6,-41,-67,6,-2,-9,19,2,85,74, --22,-67,-84,-71,-50,3,11,-9,2,62}; - -const signed char cdbk_nb_low1[320] LSP_ICONST_ATTR = { --34,-52,-15,45,2, -23,21,52,24,-33, --9,-1,9,-44,-41, --13,-17,44,22,-17, --6,-4,-1,22,38, -26,16,2,50,27, --35,-34,-9,-41,6, -0,-16,-34,51,8, --14,-31,-49,15,-33, -45,49,33,-11,-37, --62,-54,45,11,-5, --72,11,-1,-12,-11, -24,27,-11,-43,46, -43,33,-12,-9,-1, -1,-4,-23,-57,-71, -11,8,16,17,-8, --20,-31,-41,53,48, --16,3,65,-24,-8, --23,-32,-37,-32,-49, --10,-17,6,38,5, --9,-17,-46,8,52, -3,6,45,40,39, --7,-6,-34,-74,31, -8,1,-16,43,68, --11,-19,-31,4,6, -0,-6,-17,-16,-38, --16,-30,2,9,-39, --16,-1,43,-10,48, -3,3,-16,-31,-3, -62,68,43,13,3, --10,8,20,-56,12, -12,-2,-18,22,-15, --40,-36,1,7,41, -0,1,46,-6,-62, --4,-12,-2,-11,-83, --13,-2,91,33,-10, -0,4,-11,-16,79, -32,37,14,9,51, --21,-28,-56,-34,0, -21,9,-26,11,28, --42,-54,-23,-2,-15, -31,30,8,-39,-66, --39,-36,31,-28,-40, --46,35,40,22,24, -33,48,23,-34,14, -40,32,17,27,-3, -25,26,-13,-61,-17, -11,4,31,60,-6, --26,-41,-64,13,16, --26,54,31,-11,-23, --9,-11,-34,-71,-21, --34,-35,55,50,29, --22,-27,-50,-38,57, -33,42,57,48,26, -11,0,-49,-31,26, --4,-14,5,78,37, -17,0,-49,-12,-23, -26,14,2,2,-43, --17,-12,10,-8,-4, -8,18,12,-6,20, --12,-6,-13,-25,34, -15,40,49,7,8, -13,20,20,-19,-22, --2,-8,2,51,-51}; - -const signed char cdbk_nb_low2[320] LSP_ICONST_ATTR = { --6,53,-21,-24,4, -26,17,-4,-37,25, -17,-36,-13,31,3, --6,27,15,-10,31, -28,26,-10,-10,-40, -16,-7,15,13,41, --9,0,-4,50,-6, --7,14,38,22,0, --48,2,1,-13,-19, -32,-3,-60,11,-17, --1,-24,-34,-1,35, --5,-27,28,44,13, -25,15,42,-11,15, -51,35,-36,20,8, --4,-12,-29,19,-47, -49,-15,-4,16,-29, --39,14,-30,4,25, --9,-5,-51,-14,-3, --40,-32,38,5,-9, --8,-4,-1,-22,71, --3,14,26,-18,-22, -24,-41,-25,-24,6, -23,19,-10,39,-26, --27,65,45,2,-7, --26,-8,22,-12,16, -15,16,-35,-5,33, --21,-8,0,23,33, -34,6,21,36,6, --7,-22,8,-37,-14, -31,38,11,-4,-3, --39,-32,-8,32,-23, --6,-12,16,20,-28, --4,23,13,-52,-1, -22,6,-33,-40,-6, -4,-62,13,5,-26, -35,39,11,2,57, --11,9,-20,-28,-33, -52,-5,-6,-2,22, --14,-16,-48,35,1, --58,20,13,33,-1, --74,56,-18,-22,-31, -12,6,-14,4,-2, --9,-47,10,-3,29, --17,-5,61,14,47, --12,2,72,-39,-17, -92,64,-53,-51,-15, --30,-38,-41,-29,-28, -27,9,36,9,-35, --42,81,-21,20,25, --16,-5,-17,-35,21, -15,-28,48,2,-2, -9,-19,29,-40,30, --18,-18,18,-16,-57, -15,-20,-12,-15,-37, --15,33,-39,21,-22, --13,35,11,13,-38, --63,29,23,-27,32, -18,3,-26,42,33, --64,-66,-17,16,56, -2,36,3,31,21, --41,-39,8,-57,14, -37,-2,19,-36,-19, --23,-29,-16,1,-3, --8,-10,31,64,-65}; - -const signed char cdbk_nb_high1[320] LSP_ICONST_ATTR = { --26,-8,29,21,4, -19,-39,33,-7,-36, -56,54,48,40,29, --4,-24,-42,-66,-43, --60,19,-2,37,41, --10,-37,-60,-64,18, --22,77,73,40,25, -4,19,-19,-66,-2, -11,5,21,14,26, --25,-86,-4,18,1, -26,-37,10,37,-1, -24,-12,-59,-11,20, --6,34,-16,-16,42, -19,-28,-51,53,32, -4,10,62,21,-12, --34,27,4,-48,-48, --50,-49,31,-7,-21, --42,-25,-4,-43,-22, -59,2,27,12,-9, --6,-16,-8,-32,-58, --16,-29,-5,41,23, --30,-33,-46,-13,-10, --38,52,52,1,-17, --9,10,26,-25,-6, -33,-20,53,55,25, --32,-5,-42,23,21, -66,5,-28,20,9, -75,29,-7,-42,-39, -15,3,-23,21,6, -11,1,-29,14,63, -10,54,26,-24,-51, --49,7,-23,-51,15, --66,1,60,25,10, -0,-30,-4,-15,17, -19,59,40,4,-5, -33,6,-22,-58,-70, --5,23,-6,60,44, --29,-16,-47,-29,52, --19,50,28,16,35, -31,36,0,-21,6, -21,27,22,42,7, --66,-40,-8,7,19, -46,0,-4,60,36, -45,-7,-29,-6,-32, --39,2,6,-9,33, -20,-51,-34,18,-6, -19,6,11,5,-19, --29,-2,42,-11,-45, --21,-55,57,37,2, --14,-67,-16,-27,-38, -69,48,19,2,-17, -20,-20,-16,-34,-17, --25,-61,10,73,45, -16,-40,-64,-17,-29, --22,56,17,-39,8, --11,8,-25,-18,-13, --19,8,54,57,36, --17,-26,-4,6,-21, -40,42,-4,20,31, -53,10,-34,-53,31, --17,35,0,15,-6, --20,-63,-73,22,25, -29,17,8,-29,-39, --69,18,15,-15,-5}; - -const signed char cdbk_nb_high2[320] LSP_ICONST_ATTR = { -11,47,16,-9,-46, --32,26,-64,34,-5, -38,-7,47,20,2, --73,-99,-3,-45,20, -70,-52,15,-6,-7, --82,31,21,47,51, -39,-3,9,0,-41, --7,-15,-54,2,0, -27,-31,9,-45,-22, --38,-24,-24,8,-33, -23,5,50,-36,-17, --18,-51,-2,13,19, -43,12,-15,-12,61, -38,38,7,13,0, -6,-1,3,62,9, -27,22,-33,38,-35, --9,30,-43,-9,-32, --1,4,-4,1,-5, --11,-8,38,31,11, --10,-42,-21,-37,1, -43,15,-13,-35,-19, --18,15,23,-26,59, -1,-21,53,8,-41, --50,-14,-28,4,21, -25,-28,-40,5,-40, --41,4,51,-33,-8, --8,1,17,-60,12, -25,-41,17,34,43, -19,45,7,-37,24, --15,56,-2,35,-10, -48,4,-47,-2,5, --5,-54,5,-3,-33, --10,30,-2,-44,-24, --38,9,-9,42,4, -6,-56,44,-16,9, --40,-26,18,-20,10, -28,-41,-21,-4,13, --18,32,-30,-3,37, -15,22,28,50,-40, -3,-29,-64,7,51, --19,-11,17,-27,-40, --64,24,-12,-7,-27, -3,37,48,-1,2, --9,-38,-34,46,1, -27,-6,19,-13,26, -10,34,20,25,40, -50,-6,-7,30,9, --24,0,-23,71,-61, -22,58,-34,-4,2, --49,-33,25,30,-8, --6,-16,77,2,38, --8,-35,-6,-30,56, -78,31,33,-20,13, --39,20,22,4,21, --8,4,-6,10,-83, --41,9,-25,-43,15, --7,-12,-34,-39,-37, --33,19,30,16,-33, -42,-25,25,-68,44, --15,-11,-4,23,50, -14,4,-39,-43,20, --30,60,9,-20,7, -16,19,-33,37,29, -16,-35,7,38,-27}; diff --git a/apps/codecs/libspeex/ltp.c b/apps/codecs/libspeex/ltp.c deleted file mode 100644 index 9f10bc09d8..0000000000 --- a/apps/codecs/libspeex/ltp.c +++ /dev/null @@ -1,856 +0,0 @@ -/* Copyright (C) 2002-2006 Jean-Marc Valin - File: ltp.c - Long-Term Prediction functions - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of the Xiph.org Foundation nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifdef HAVE_CONFIG_H -#include "config-speex.h" -#endif - -#include -#include "ltp.h" -#include "stack_alloc.h" -#include "filters.h" -#include "speex/speex_bits.h" -#include "math_approx.h" -#include "os_support.h" - -#ifndef NULL -#define NULL 0 -#endif - - -#ifdef _USE_SSE -#include "ltp_sse.h" -#elif defined (ARM4_ASM) || defined(ARM5E_ASM) -#include "ltp_arm4.h" -#elif defined (COLDFIRE_ASM) -#define OVERRIDE_INNER_PROD -#elif defined (BFIN_ASM) -#include "ltp_bfin.h" -#endif - -#ifndef OVERRIDE_INNER_PROD -spx_word32_t inner_prod(const spx_word16_t *x, const spx_word16_t *y, int len) -{ - spx_word32_t sum=0; - len >>= 2; - while(len--) - { - spx_word32_t part=0; - part = MAC16_16(part,*x++,*y++); - part = MAC16_16(part,*x++,*y++); - part = MAC16_16(part,*x++,*y++); - part = MAC16_16(part,*x++,*y++); - /* HINT: If you had a 40-bit accumulator, you could shift only at the end */ - sum = ADD32(sum,SHR32(part,6)); - } - return sum; -} -#endif - -#ifndef SPEEX_DISABLE_ENCODER -#ifndef OVERRIDE_PITCH_XCORR -#if 0 /* HINT: Enable this for machines with enough registers (i.e. not x86) */ -void pitch_xcorr(const spx_word16_t *_x, const spx_word16_t *_y, spx_word32_t *corr, int len, int nb_pitch, char *stack) -{ - int i,j; - for (i=0;i16383) - { - scaledown=1; - break; - } - } - /* If the weighted input is close to saturation, then we scale it down */ - if (scaledown) - { - for (i=-end;iMULT16_16(best_score[N-1],ADD16(1,ener16[i-start]))) - { - /* We can safely put it last and then check */ - best_score[N-1]=tmp; - best_ener[N-1]=ener16[i-start]+1; - pitch[N-1]=i; - /* Check if it comes in front of others */ - for (j=0;jMULT16_16(best_score[j],ADD16(1,ener16[i-start]))) - { - for (k=N-1;k>j;k--) - { - best_score[k]=best_score[k-1]; - best_ener[k]=best_ener[k-1]; - pitch[k]=pitch[k-1]; - } - best_score[j]=tmp; - best_ener[j]=ener16[i-start]+1; - pitch[j]=i; - break; - } - } - } - } - - /* Compute open-loop gain if necessary */ - if (gain) - { - for (j=0;jbest_sum && gain_sum<=max_gain) { - best_sum=sum; - best_cdbk=i; - } - } - - return best_cdbk; -} -#endif - -/** Finds the best quantized 3-tap pitch predictor by analysis by synthesis */ -static spx_word32_t pitch_gain_search_3tap( -const spx_word16_t target[], /* Target vector */ -const spx_coef_t ak[], /* LPCs for this subframe */ -const spx_coef_t awk1[], /* Weighted LPCs #1 for this subframe */ -const spx_coef_t awk2[], /* Weighted LPCs #2 for this subframe */ -spx_sig_t exc[], /* Excitation */ -const signed char *gain_cdbk, -int gain_cdbk_size, -int pitch, /* Pitch value */ -int p, /* Number of LPC coeffs */ -int nsf, /* Number of samples in subframe */ -SpeexBits *bits, -char *stack, -const spx_word16_t *exc2, -const spx_word16_t *r, -spx_word16_t *new_target, -int *cdbk_index, -int plc_tuning, -spx_word32_t cumul_gain, -int scaledown -) -{ - int i,j; - VARDECL(spx_word16_t *tmp1); - VARDECL(spx_word16_t *e); - spx_word16_t *x[3]; - spx_word32_t corr[3]; - spx_word32_t A[3][3]; - spx_word16_t gain[3]; - spx_word32_t err; - spx_word16_t max_gain=128; - int best_cdbk=0; - - ALLOC(tmp1, 3*nsf, spx_word16_t); - ALLOC(e, nsf, spx_word16_t); - - if (cumul_gain > 262144) - max_gain = 31; - - x[0]=tmp1; - x[1]=tmp1+nsf; - x[2]=tmp1+2*nsf; - - for (j=0;j=0;i--) - { - spx_word16_t e0=exc2[-pitch-1+i]; -#ifdef FIXED_POINT - /* Scale excitation down if needed (avoiding overflow) */ - if (scaledown) - e0 = SHR16(e0,1); -#endif - x[i][0]=MULT16_16_Q14(r[0], e0); - for (j=0;j30) - plc_tuning=30; -#ifdef FIXED_POINT - C[0] = SHL32(C[0],1); - C[1] = SHL32(C[1],1); - C[2] = SHL32(C[2],1); - C[3] = SHL32(C[3],1); - C[4] = SHL32(C[4],1); - C[5] = SHL32(C[5],1); - C[6] = MAC16_32_Q15(C[6],MULT16_16_16(plc_tuning,655),C[6]); - C[7] = MAC16_32_Q15(C[7],MULT16_16_16(plc_tuning,655),C[7]); - C[8] = MAC16_32_Q15(C[8],MULT16_16_16(plc_tuning,655),C[8]); - normalize16(C, C16, 32767, 9); -#else - C[6]*=.5*(1+.02*plc_tuning); - C[7]*=.5*(1+.02*plc_tuning); - C[8]*=.5*(1+.02*plc_tuning); -#endif - - best_cdbk = pitch_gain_search_3tap_vq(gain_cdbk, gain_cdbk_size, C16, max_gain); - -#ifdef FIXED_POINT - gain[0] = ADD16(32,(spx_word16_t)gain_cdbk[best_cdbk*4]); - gain[1] = ADD16(32,(spx_word16_t)gain_cdbk[best_cdbk*4+1]); - gain[2] = ADD16(32,(spx_word16_t)gain_cdbk[best_cdbk*4+2]); - /*printf ("%d %d %d %d\n",gain[0],gain[1],gain[2], best_cdbk);*/ -#else - gain[0] = 0.015625*gain_cdbk[best_cdbk*4] + .5; - gain[1] = 0.015625*gain_cdbk[best_cdbk*4+1]+ .5; - gain[2] = 0.015625*gain_cdbk[best_cdbk*4+2]+ .5; -#endif - *cdbk_index=best_cdbk; - } - - SPEEX_MEMSET(exc, 0, nsf); - for (i=0;i<3;i++) - { - int j; - int tmp1, tmp3; - int pp=pitch+1-i; - tmp1=nsf; - if (tmp1>pp) - tmp1=pp; - for (j=0;jpp+pitch) - tmp3=pp+pitch; - for (j=tmp1;jgain_bits; - gain_cdbk = params->gain_cdbk + 4*gain_cdbk_size*cdbk_offset; - - N=complexity; - if (N>10) - N=10; - if (N<1) - N=1; - - ALLOC(nbest, N, int); - params = (const ltp_params*) par; - - if (endpitch_bits); - speex_bits_pack(bits, 0, params->gain_bits); - SPEEX_MEMSET(exc, 0, nsf); - return start; - } - -#ifdef FIXED_POINT - /* Check if we need to scale everything down in the pitch search to avoid overflows */ - for (i=0;i16383) - { - scaledown=1; - break; - } - } - for (i=-end;i16383) - { - scaledown=1; - break; - } - } -#endif - if (N>end-start+1) - N=end-start+1; - if (end != start) - open_loop_nbest_pitch(sw, start, end, nsf, nbest, NULL, N, stack); - else - nbest[0] = start; - - ALLOC(best_exc, nsf, spx_sig_t); - ALLOC(new_target, nsf, spx_word16_t); - ALLOC(best_target, nsf, spx_word16_t); - - for (i=0;ipitch_bits); - speex_bits_pack(bits, best_gain_index, params->gain_bits); -#ifdef FIXED_POINT - *cumul_gain = MULT16_32_Q13(SHL16(params->gain_cdbk[4*best_gain_index+3],8), MAX32(1024,*cumul_gain)); -#else - *cumul_gain = 0.03125*MAX32(1024,*cumul_gain)*params->gain_cdbk[4*best_gain_index+3]; -#endif - /*printf ("%f\n", cumul_gain);*/ - /*printf ("encode pitch: %d %d\n", best_pitch, best_gain_index);*/ - SPEEX_COPY(exc, best_exc, nsf); - SPEEX_COPY(target, best_target, nsf); -#ifdef FIXED_POINT - /* Scale target back up if needed */ - if (scaledown) - { - for (i=0;igain_bits; - gain_cdbk = params->gain_cdbk + 4*gain_cdbk_size*cdbk_offset; - - pitch = speex_bits_unpack_unsigned(bits, params->pitch_bits); - pitch += start; - gain_index = speex_bits_unpack_unsigned(bits, params->gain_bits); - /*printf ("decode pitch: %d %d\n", pitch, gain_index);*/ -#ifdef FIXED_POINT - gain[0] = ADD16(32,(spx_word16_t)gain_cdbk[gain_index*4]); - gain[1] = ADD16(32,(spx_word16_t)gain_cdbk[gain_index*4+1]); - gain[2] = ADD16(32,(spx_word16_t)gain_cdbk[gain_index*4+2]); -#else - gain[0] = 0.015625*gain_cdbk[gain_index*4]+.5; - gain[1] = 0.015625*gain_cdbk[gain_index*4+1]+.5; - gain[2] = 0.015625*gain_cdbk[gain_index*4+2]+.5; -#endif - - if (count_lost && pitch > subframe_offset) - { - spx_word16_t gain_sum; - if (1) { -#ifdef FIXED_POINT - spx_word16_t tmp = count_lost < 4 ? last_pitch_gain : SHR16(last_pitch_gain,1); - if (tmp>62) - tmp=62; -#else - spx_word16_t tmp = count_lost < 4 ? last_pitch_gain : 0.5 * last_pitch_gain; - if (tmp>.95) - tmp=.95; -#endif - gain_sum = gain_3tap_to_1tap(gain); - - if (gain_sum > tmp) - { - spx_word16_t fact = DIV32_16(SHL32(EXTEND32(tmp),14),gain_sum); - for (i=0;i<3;i++) - gain[i]=MULT16_16_Q14(fact,gain[i]); - } - - } - - } - - *pitch_val = pitch; - gain_val[0]=gain[0]; - gain_val[1]=gain[1]; - gain_val[2]=gain[2]; - gain[0] = SHL16(gain[0],7); - gain[1] = SHL16(gain[1],7); - gain[2] = SHL16(gain[2],7); - SPEEX_MEMSET(exc_out, 0, nsf); - for (i=0;i<3;i++) - { - int j; - int tmp1, tmp3; - int pp=pitch+1-i; - tmp1=nsf; - if (tmp1>pp) - tmp1=pp; - for (j=0;jpp+pitch) - tmp3=pp+pitch; - for (j=tmp1;j63) - pitch_coef=63; -#else - if (pitch_coef>.99) - pitch_coef=.99; -#endif - for (i=0;i63) - pitch_coef=63; -#else - if (pitch_coef>.99) - pitch_coef=.99; -#endif - for (i=0;i0 ? g[0] : -SHR16(g[0],1)) + (g[2]>0 ? g[2] : -SHR16(g[2],1))) -#else -#define gain_3tap_to_1tap(g) (ABS(g[1]) + (g[0]>0 ? g[0] : -.5*g[0]) + (g[2]>0 ? g[2] : -.5*g[2])) -#endif - -spx_word32_t inner_prod(const spx_word16_t *x, const spx_word16_t *y, int len); -void pitch_xcorr(const spx_word16_t *_x, const spx_word16_t *_y, spx_word32_t *corr, int len, int nb_pitch, char *stack); - -void open_loop_nbest_pitch(spx_word16_t *sw, int start, int end, int len, int *pitch, spx_word16_t *gain, int N, char *stack); - - -/** Finds the best quantized 3-tap pitch predictor by analysis by synthesis */ -int pitch_search_3tap( -spx_word16_t target[], /* Target vector */ -spx_word16_t *sw, -spx_coef_t ak[], /* LPCs for this subframe */ -spx_coef_t awk1[], /* Weighted LPCs #1 for this subframe */ -spx_coef_t awk2[], /* Weighted LPCs #2 for this subframe */ -spx_sig_t exc[], /* Overlapping codebook */ -const void *par, -int start, /* Smallest pitch value allowed */ -int end, /* Largest pitch value allowed */ -spx_word16_t pitch_coef, /* Voicing (pitch) coefficient */ -int p, /* Number of LPC coeffs */ -int nsf, /* Number of samples in subframe */ -SpeexBits *bits, -char *stack, -spx_word16_t *exc2, -spx_word16_t *r, -int complexity, -int cdbk_offset, -int plc_tuning, -spx_word32_t *cumul_gain -); - -/*Unquantize adaptive codebook and update pitch contribution*/ -void pitch_unquant_3tap( -spx_word16_t exc[], /* Input excitation */ -spx_word32_t exc_out[], /* Output excitation */ -int start, /* Smallest pitch value allowed */ -int end, /* Largest pitch value allowed */ -spx_word16_t pitch_coef, /* Voicing (pitch) coefficient */ -const void *par, -int nsf, /* Number of samples in subframe */ -int *pitch_val, -spx_word16_t *gain_val, -SpeexBits *bits, -char *stack, -int lost, -int subframe_offset, -spx_word16_t last_pitch_gain, -int cdbk_offset -); - -/** Forced pitch delay and gain */ -int forced_pitch_quant( -spx_word16_t target[], /* Target vector */ -spx_word16_t *sw, -spx_coef_t ak[], /* LPCs for this subframe */ -spx_coef_t awk1[], /* Weighted LPCs #1 for this subframe */ -spx_coef_t awk2[], /* Weighted LPCs #2 for this subframe */ -spx_sig_t exc[], /* Excitation */ -const void *par, -int start, /* Smallest pitch value allowed */ -int end, /* Largest pitch value allowed */ -spx_word16_t pitch_coef, /* Voicing (pitch) coefficient */ -int p, /* Number of LPC coeffs */ -int nsf, /* Number of samples in subframe */ -SpeexBits *bits, -char *stack, -spx_word16_t *exc2, -spx_word16_t *r, -int complexity, -int cdbk_offset, -int plc_tuning, -spx_word32_t *cumul_gain -); - -/** Unquantize forced pitch delay and gain */ -void forced_pitch_unquant( -spx_word16_t exc[], /* Input excitation */ -spx_word32_t exc_out[], /* Output excitation */ -int start, /* Smallest pitch value allowed */ -int end, /* Largest pitch value allowed */ -spx_word16_t pitch_coef, /* Voicing (pitch) coefficient */ -const void *par, -int nsf, /* Number of samples in subframe */ -int *pitch_val, -spx_word16_t *gain_val, -SpeexBits *bits, -char *stack, -int lost, -int subframe_offset, -spx_word16_t last_pitch_gain, -int cdbk_offset -); diff --git a/apps/codecs/libspeex/ltp_arm4.h b/apps/codecs/libspeex/ltp_arm4.h deleted file mode 100644 index 46ecfa40ec..0000000000 --- a/apps/codecs/libspeex/ltp_arm4.h +++ /dev/null @@ -1,188 +0,0 @@ -/* Copyright (C) 2004 Jean-Marc Valin */ -/** - @file ltp_arm4.h - @brief Long-Term Prediction functions (ARM4 version) -*/ -/* - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of the Xiph.org Foundation nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#define OVERRIDE_INNER_PROD -spx_word32_t inner_prod(const spx_word16_t *x, const spx_word16_t *y, int len) -{ - spx_word32_t sum1=0,sum2=0; - spx_word16_t *deadx, *deady; - int deadlen, dead1, dead2, dead3, dead4, dead5, dead6; - __asm__ __volatile__ ( - "\tldrsh %5, [%0], #2 \n" - "\tldrsh %6, [%1], #2 \n" - ".inner_prod_loop%=:\n" - "\tsub %7, %7, %7\n" - "\tsub %10, %10, %10\n" - - "\tldrsh %8, [%0], #2 \n" - "\tldrsh %9, [%1], #2 \n" - "\tmla %7, %5, %6, %7\n" - "\tldrsh %5, [%0], #2 \n" - "\tldrsh %6, [%1], #2 \n" - "\tmla %10, %8, %9, %10\n" - "\tldrsh %8, [%0], #2 \n" - "\tldrsh %9, [%1], #2 \n" - "\tmla %7, %5, %6, %7\n" - "\tldrsh %5, [%0], #2 \n" - "\tldrsh %6, [%1], #2 \n" - "\tmla %10, %8, %9, %10\n" - - "\tldrsh %8, [%0], #2 \n" - "\tldrsh %9, [%1], #2 \n" - "\tmla %7, %5, %6, %7\n" - "\tldrsh %5, [%0], #2 \n" - "\tldrsh %6, [%1], #2 \n" - "\tmla %10, %8, %9, %10\n" - "\tldrsh %8, [%0], #2 \n" - "\tldrsh %9, [%1], #2 \n" - "\tmla %7, %5, %6, %7\n" - "\tldrsh %5, [%0], #2 \n" - "\tldrsh %6, [%1], #2 \n" - "\tmla %10, %8, %9, %10\n" - - "\tsubs %4, %4, #1\n" - "\tadd %2, %2, %7, asr #5\n" - "\tadd %3, %3, %10, asr #5\n" - "\tbne .inner_prod_loop%=\n" - : "=r" (deadx), "=r" (deady), "+r" (sum1), "+r" (sum2), - "=r" (deadlen), "=r" (dead1), "=r" (dead2), "=r" (dead3), - "=r" (dead4), "=r" (dead5), "=r" (dead6) - : "0" (x), "1" (y), "4" (len>>3) - : "cc", "memory" - ); - return (sum1+sum2)>>1; -} - -#define OVERRIDE_PITCH_XCORR -void pitch_xcorr(const spx_word16_t *_x, const spx_word16_t *_y, spx_word32_t *corr, int len, int nb_pitch, char *stack) -{ - (void)stack; - int i,j; - for (i=0;i>> 6;\n\t" - "R0 = A0;\n\t" - "%0 = R0;\n\t" - : "=m" (sum) - : "m" (x), "m" (y), "d" (len-1) - : "P0", "P1", "P2", "R0", "R1", "A0", "I0", "I1", "L0", "L1", "R3" - ); - return sum; -} - -#define OVERRIDE_PITCH_XCORR -void pitch_xcorr(const spx_word16_t *_x, const spx_word16_t *_y, spx_word32_t *corr, int len, int nb_pitch, char *stack) -{ - corr += nb_pitch - 1; - __asm__ __volatile__ ( - "P2 = %0;\n\t" - "I0 = P2;\n\t" /* x in I0 */ - "B0 = P2;\n\t" /* x in B0 */ - "R0 = %3;\n\t" /* len in R0 */ - "P3 = %3;\n\t" - "P3 += -2;\n\t" /* len in R0 */ - "P4 = %4;\n\t" /* nb_pitch in R0 */ - "R1 = R0 << 1;\n\t" /* number of bytes in x */ - "L0 = R1;\n\t" - "P0 = %1;\n\t" - - "P1 = %2;\n\t" - "B1 = P1;\n\t" - "L1 = 0;\n\t" /*Disable looping on I1*/ - - "r0 = [I0++];\n\t" - "LOOP pitch%= LC0 = P4 >> 1;\n\t" - "LOOP_BEGIN pitch%=;\n\t" - "I1 = P0;\n\t" - "A1 = A0 = 0;\n\t" - "R1 = [I1++];\n\t" - "LOOP inner_prod%= LC1 = P3 >> 1;\n\t" - "LOOP_BEGIN inner_prod%=;\n\t" - "A1 += R0.L*R1.H, A0 += R0.L*R1.L (IS) || R1.L = W[I1++];\n\t" - "A1 += R0.H*R1.L, A0 += R0.H*R1.H (IS) || R1.H = W[I1++] || R0 = [I0++];\n\t" - "LOOP_END inner_prod%=;\n\t" - "A1 += R0.L*R1.H, A0 += R0.L*R1.L (IS) || R1.L = W[I1++];\n\t" - "A1 += R0.H*R1.L, A0 += R0.H*R1.H (IS) || R0 = [I0++];\n\t" - "A0 = A0 >>> 6;\n\t" - "A1 = A1 >>> 6;\n\t" - "R2 = A0, R3 = A1;\n\t" - "[P1--] = r2;\n\t" - "[P1--] = r3;\n\t" - "P0 += 4;\n\t" - "LOOP_END pitch%=;\n\t" - "L0 = 0;\n\t" - : : "m" (_x), "m" (_y), "m" (corr), "m" (len), "m" (nb_pitch) - : "A0", "A1", "P0", "P1", "P2", "P3", "P4", "R0", "R1", "R2", "R3", "I0", "I1", "L0", "L1", "B0", "B1", "memory" - ); -} - -#define OVERRIDE_COMPUTE_PITCH_ERROR -static inline spx_word32_t compute_pitch_error(spx_word16_t *C, spx_word16_t *g, spx_word16_t pitch_control) -{ - spx_word32_t sum; - __asm__ __volatile__ - ( - "A0 = 0;\n\t" - - "R0 = W[%1++];\n\t" - "R1.L = %2.L*%5.L (IS);\n\t" - "A0 += R1.L*R0.L (IS) || R0 = W[%1++];\n\t" - - "R1.L = %3.L*%5.L (IS);\n\t" - "A0 += R1.L*R0.L (IS) || R0 = W[%1++];\n\t" - - "R1.L = %4.L*%5.L (IS);\n\t" - "A0 += R1.L*R0.L (IS) || R0 = W[%1++];\n\t" - - "R1.L = %2.L*%3.L (IS);\n\t" - "A0 -= R1.L*R0.L (IS) || R0 = W[%1++];\n\t" - - "R1.L = %4.L*%3.L (IS);\n\t" - "A0 -= R1.L*R0.L (IS) || R0 = W[%1++];\n\t" - - "R1.L = %4.L*%2.L (IS);\n\t" - "A0 -= R1.L*R0.L (IS) || R0 = W[%1++];\n\t" - - "R1.L = %2.L*%2.L (IS);\n\t" - "A0 -= R1.L*R0.L (IS) || R0 = W[%1++];\n\t" - - "R1.L = %3.L*%3.L (IS);\n\t" - "A0 -= R1.L*R0.L (IS) || R0 = W[%1++];\n\t" - - "R1.L = %4.L*%4.L (IS);\n\t" - "A0 -= R1.L*R0.L (IS);\n\t" - - "%0 = A0;\n\t" - : "=&D" (sum), "=a" (C) - : "d" (g[0]), "d" (g[1]), "d" (g[2]), "d" (pitch_control), "1" (C) - : "R0", "R1", "R2", "A0" - ); - return sum; -} - -#define OVERRIDE_OPEN_LOOP_NBEST_PITCH -#ifdef OVERRIDE_OPEN_LOOP_NBEST_PITCH -void open_loop_nbest_pitch(spx_word16_t *sw, int start, int end, int len, int *pitch, spx_word16_t *gain, int N, char *stack) -{ - int i,j,k; - VARDECL(spx_word32_t *best_score); - VARDECL(spx_word32_t *best_ener); - spx_word32_t e0; - VARDECL(spx_word32_t *corr); - VARDECL(spx_word32_t *energy); - - ALLOC(best_score, N, spx_word32_t); - ALLOC(best_ener, N, spx_word32_t); - ALLOC(corr, end-start+1, spx_word32_t); - ALLOC(energy, end-start+2, spx_word32_t); - - for (i=0;i>>= 6;\n\t" -" R1 = R1 + R2;\n\t" -" R0 >>>= 6;\n\t" -" R1 = R1 - R0;\n\t" -" R2 = MAX(R1,R3);\n\t" -"eu2: [P0++] = R2;\n\t" - : : "d" (energy), "d" (&sw[-start-1]), "d" (&sw[-start+len-1]), - "a" (end-start) - : "P0", "I1", "I2", "R0", "R1", "R2", "R3" -#if (__GNUC__ == 4) - , "LC1" -#endif - ); - - pitch_xcorr(sw, sw-end, corr, len, end-start+1, stack); - - /* FIXME: Fixed-point and floating-point code should be merged */ - { - VARDECL(spx_word16_t *corr16); - VARDECL(spx_word16_t *ener16); - ALLOC(corr16, end-start+1, spx_word16_t); - ALLOC(ener16, end-start+1, spx_word16_t); - /* Normalize to 180 so we can square it and it still fits in 16 bits */ - normalize16(corr, corr16, 180, end-start+1); - normalize16(energy, ener16, 180, end-start+1); - - if (N == 1) { - /* optimised asm to handle N==1 case */ - __asm__ __volatile__ - ( -" I0 = %1;\n\t" /* I0: corr16[] */ -" L0 = 0;\n\t" -" I1 = %2;\n\t" /* I1: energy */ -" L1 = 0;\n\t" -" R2 = -1;\n\t" /* R2: best score */ -" R3 = 0;\n\t" /* R3: best energy */ -" P0 = %4;\n\t" /* P0: best pitch */ -" P1 = %4;\n\t" /* P1: counter */ -" LSETUP (sl1, sl2) LC1 = %3;\n\t" -"sl1: R0.L = W [I0++] || R1.L = W [I1++];\n\t" -" R0 = R0.L * R0.L (IS);\n\t" -" R1 += 1;\n\t" -" R4 = R0.L * R3.L;\n\t" -" R5 = R2.L * R1.L;\n\t" -" cc = R5 < R4;\n\t" -" if cc R2 = R0;\n\t" -" if cc R3 = R1;\n\t" -" if cc P0 = P1;\n\t" -"sl2: P1 += 1;\n\t" -" %0 = P0;\n\t" - : "=&d" (pitch[0]) - : "a" (corr16), "a" (ener16), "a" (end+1-start), "d" (start) - : "P0", "P1", "I0", "I1", "R0", "R1", "R2", "R3", "R4", "R5" -#if (__GNUC__ == 4) - , "LC1" -#endif - ); - - } - else { - for (i=start;i<=end;i++) - { - spx_word16_t tmp = MULT16_16_16(corr16[i-start],corr16[i-start]); - /* Instead of dividing the tmp by the energy, we multiply on the other side */ - if (MULT16_16(tmp,best_ener[N-1])>MULT16_16(best_score[N-1],ADD16(1,ener16[i-start]))) - { - /* We can safely put it last and then check */ - best_score[N-1]=tmp; - best_ener[N-1]=ener16[i-start]+1; - pitch[N-1]=i; - /* Check if it comes in front of others */ - for (j=0;jMULT16_16(best_score[j],ADD16(1,ener16[i-start]))) - { - for (k=N-1;k>j;k--) - { - best_score[k]=best_score[k-1]; - best_ener[k]=best_ener[k-1]; - pitch[k]=pitch[k-1]; - } - best_score[j]=tmp; - best_ener[j]=ener16[i-start]+1; - pitch[j]=i; - break; - } - } - } - } - } - } - - /* Compute open-loop gain */ - if (gain) - { - for (j=0;jbest_sum && gain_sum<=max_gain) ------ (1) - - if (sum>best_sum && !(gain_sum>max_gain)) ------ (2) - - if (max_gain<=gain_sum) { ------ (3) - sum = -VERY_LARGE32; - } - if (best_sum<=sum) - - The blackin cc instructions are all of the form: - - cc = x < y (or cc = x <= y) -*/ -" R1 = B0\n\t" -" R2 = %5\n\t" -" R3 = %6\n\t" -" cc = R2 <= R1;\n\t" -" if cc R0 = R3;\n\t" -" cc = %0 <= R0;\n\t" -" if cc %0 = R0;\n\t" -" if cc %1 = P1;\n\t" - -"pgs2: P1 += 1;\n\t" - - : "=&d" (best_sum), "=&d" (best_cdbk) - : "a" (gain_cdbk), "a" (C16), "a" (gain_cdbk_size), "a" (max_gain), - "b" (-VERY_LARGE32) - : "R0", "R1", "R2", "R3", "R4", "P0", - "P1", "I1", "L1", "A0", "B0" -#if (__GNUC__ == 4) - , "LC1" -#endif - ); - - return best_cdbk; -} -#endif - diff --git a/apps/codecs/libspeex/ltp_cf.S b/apps/codecs/libspeex/ltp_cf.S deleted file mode 100644 index a1baed6d41..0000000000 --- a/apps/codecs/libspeex/ltp_cf.S +++ /dev/null @@ -1,85 +0,0 @@ -/* Copyright (C) 2007 Thom Johansen */ -/** - @file ltp_cf.S - @brief Long-Term Prediction functions (Coldfire version) -*/ -/* - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of the Xiph.org Foundation nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - .text -/* spx_word32_t inner_prod(const spx_word16_t *x, const spx_word16_t *y, int len) */ - .global inner_prod -inner_prod: - lea.l (-28, %sp), %sp - movem.l %d2-%d7/%a2, (%sp) - movem.l (28+4, %sp), %a0-%a1 | a0 = x, a1 = y - move.l (28+12, %sp), %d0 | d0 = len - - | We assume we're never called with a 'len' of zero - btst #2, %d0 | Check if we need to do one round of four - jeq 0f | samples before we do runs of eight - movem.l (%a0), %d1-%d2 | Fetch four samples from x - movem.l (%a1), %d3-%d4 | Fetch four samples from y - mac.w %d1u, %d3u, %acc0 - mac.w %d1l, %d3l, %acc0 - mac.w %d2u, %d4u, %acc0 - mac.w %d2l, %d4l, %acc0 - addq.l #8, %a0 - addq.l #8, %a1 - subq.l #4, %d0 - jeq .save - -0: - movem.l (%a0), %d1-%d4 | Fetch eight samples from x - movem.l (%a1), %d5-%d7/%a2 | Fetch eight samples from y - mac.w %d1u, %d5u, %acc0 - mac.w %d1l, %d5l, %acc0 - mac.w %d2u, %d6u, %acc0 - mac.w %d2l, %d6l, %acc0 - mac.w %d3u, %d7u, %acc0 - mac.w %d3l, %d7l, %acc0 - mac.w %d4u, %a2u, %acc0 - mac.w %d4l, %a2l, %acc0 - lea.l (16, %a0), %a0 - lea.l (16, %a1), %a1 - subq.l #8, %d0 - jne 0b - -.save: - move.l %accext01, %d1 | Fetch top 8 bits of answer - movclr.l %acc0, %d0 | Fetch lower 32 bits - lsr.l #6, %d0 - moveq.l #26, %d2 - asl.l %d2, %d1 - or.l %d1, %d0 | Combine (top << 26) | (lower >> 6) - - movem.l (%sp), %d2-%d7/%a2 - lea.l (28, %sp), %sp - rts - diff --git a/apps/codecs/libspeex/ltp_sse.h b/apps/codecs/libspeex/ltp_sse.h deleted file mode 100644 index bed6eaac9a..0000000000 --- a/apps/codecs/libspeex/ltp_sse.h +++ /dev/null @@ -1,92 +0,0 @@ -/* Copyright (C) 2002 Jean-Marc Valin */ -/** - @file ltp_sse.h - @brief Long-Term Prediction functions (SSE version) -*/ -/* - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of the Xiph.org Foundation nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include - -#define OVERRIDE_INNER_PROD -float inner_prod(const float *a, const float *b, int len) -{ - int i; - float ret; - __m128 sum = _mm_setzero_ps(); - for (i=0;i<(len>>2);i+=2) - { - sum = _mm_add_ps(sum, _mm_mul_ps(_mm_loadu_ps(a+0), _mm_loadu_ps(b+0))); - sum = _mm_add_ps(sum, _mm_mul_ps(_mm_loadu_ps(a+4), _mm_loadu_ps(b+4))); - a += 8; - b += 8; - } - sum = _mm_add_ps(sum, _mm_movehl_ps(sum, sum)); - sum = _mm_add_ss(sum, _mm_shuffle_ps(sum, sum, 0x55)); - _mm_store_ss(&ret, sum); - return ret; -} - -#define OVERRIDE_PITCH_XCORR -void pitch_xcorr(const float *_x, const float *_y, float *corr, int len, int nb_pitch, char *stack) -{ - int i, offset; - VARDECL(__m128 *x); - VARDECL(__m128 *y); - int N, L; - N = len>>2; - L = nb_pitch>>2; - ALLOC(x, N, __m128); - ALLOC(y, N+L, __m128); - for (i=0;i=(spx_int32_t)65536) - { - x >>= 16; - r += 16; - } - if (x>=256) - { - x >>= 8; - r += 8; - } - if (x>=16) - { - x >>= 4; - r += 4; - } - if (x>=4) - { - x >>= 2; - r += 2; - } - if (x>=2) - { - r += 1; - } - return r; -} - -static inline spx_int16_t spx_ilog4(spx_uint32_t x) -{ - int r=0; - if (x>=(spx_int32_t)65536) - { - x >>= 16; - r += 8; - } - if (x>=256) - { - x >>= 8; - r += 4; - } - if (x>=16) - { - x >>= 4; - r += 2; - } - if (x>=4) - { - r += 1; - } - return r; -} - -#ifdef FIXED_POINT - -/** Generate a pseudo-random number */ -static inline spx_word16_t speex_rand(spx_word16_t std, spx_int32_t *seed) -{ - spx_word32_t res; - *seed = 1664525 * *seed + 1013904223; - res = MULT16_16(EXTRACT16(SHR32(*seed,16)),std); - return EXTRACT16(PSHR32(SUB32(res, SHR32(res, 3)),14)); -} - -/* sqrt(x) ~= 0.22178 + 1.29227*x - 0.77070*x^2 + 0.25723*x^3 (for .25 < x < 1) */ -/*#define C0 3634 -#define C1 21173 -#define C2 -12627 -#define C3 4215*/ - -/* sqrt(x) ~= 0.22178 + 1.29227*x - 0.77070*x^2 + 0.25659*x^3 (for .25 < x < 1) */ -#define C0 3634 -#define C1 21173 -#define C2 -12627 -#define C3 4204 - -static inline spx_word16_t spx_sqrt(spx_word32_t x) -{ - int k; - spx_word32_t rt; - k = spx_ilog4(x)-6; - x = VSHR32(x, (k<<1)); - rt = ADD16(C0, MULT16_16_Q14(x, ADD16(C1, MULT16_16_Q14(x, ADD16(C2, MULT16_16_Q14(x, (C3))))))); - rt = VSHR32(rt,7-k); - return rt; -} - -/* log(x) ~= -2.18151 + 4.20592*x - 2.88938*x^2 + 0.86535*x^3 (for .5 < x < 1) */ - - -#define A1 16469 -#define A2 2242 -#define A3 1486 - -static inline spx_word16_t spx_acos(spx_word16_t x) -{ - int s=0; - spx_word16_t ret; - spx_word16_t sq; - if (x<0) - { - s=1; - x = NEG16(x); - } - x = SUB16(16384,x); - - x = x >> 1; - sq = MULT16_16_Q13(x, ADD16(A1, MULT16_16_Q13(x, ADD16(A2, MULT16_16_Q13(x, (A3)))))); - ret = spx_sqrt(SHL32(EXTEND32(sq),13)); - - /*ret = spx_sqrt(67108864*(-1.6129e-04 + 2.0104e+00*f + 2.7373e-01*f*f + 1.8136e-01*f*f*f));*/ - if (s) - ret = SUB16(25736,ret); - return ret; -} - - -#define K1 8192 -#define K2 -4096 -#define K3 340 -#define K4 -10 - -static inline spx_word16_t spx_cos(spx_word16_t x) -{ - spx_word16_t x2; - - if (x<12868) - { - x2 = MULT16_16_P13(x,x); - return ADD32(K1, MULT16_16_P13(x2, ADD32(K2, MULT16_16_P13(x2, ADD32(K3, MULT16_16_P13(K4, x2)))))); - } else { - x = SUB16(25736,x); - x2 = MULT16_16_P13(x,x); - return SUB32(-K1, MULT16_16_P13(x2, ADD32(K2, MULT16_16_P13(x2, ADD32(K3, MULT16_16_P13(K4, x2)))))); - } -} - -#define L1 32767 -#define L2 -7651 -#define L3 8277 -#define L4 -626 - -static inline spx_word16_t _spx_cos_pi_2(spx_word16_t x) -{ - spx_word16_t x2; - - x2 = MULT16_16_P15(x,x); - return ADD16(1,MIN16(32766,ADD32(SUB16(L1,x2), MULT16_16_P15(x2, ADD32(L2, MULT16_16_P15(x2, ADD32(L3, MULT16_16_P15(L4, x2)))))))); -} - -static inline spx_word16_t spx_cos_norm(spx_word32_t x) -{ - x = x&0x0001ffff; - if (x>SHL32(EXTEND32(1), 16)) - x = SUB32(SHL32(EXTEND32(1), 17),x); - if (x&0x00007fff) - { - if (x14) - return 0x7fffffff; - else if (integer < -15) - return 0; - frac = SHL16(x-SHL16(integer,11),3); - frac = ADD16(D0, MULT16_16_Q14(frac, ADD16(D1, MULT16_16_Q14(frac, ADD16(D2 , MULT16_16_Q14(D3,frac)))))); - return VSHR32(EXTEND32(frac), -integer-2); -} - -/* Input in Q11 format, output in Q16 */ -static inline spx_word32_t spx_exp(spx_word16_t x) -{ - if (x>21290) - return 0x7fffffff; - else if (x<-21290) - return 0; - else - return spx_exp2(MULT16_16_P14(23637,x)); -} -#define M1 32767 -#define M2 -21 -#define M3 -11943 -#define M4 4936 - -static inline spx_word16_t spx_atan01(spx_word16_t x) -{ - return MULT16_16_P15(x, ADD32(M1, MULT16_16_P15(x, ADD32(M2, MULT16_16_P15(x, ADD32(M3, MULT16_16_P15(M4, x))))))); -} - -#undef M1 -#undef M2 -#undef M3 -#undef M4 - -/* Input in Q15, output in Q14 */ -static inline spx_word16_t spx_atan(spx_word32_t x) -{ - if (x <= 32767) - { - return SHR16(spx_atan01(x),1); - } else { - int e = spx_ilog2(x); - if (e>=29) - return 25736; - x = DIV32_16(SHL32(EXTEND32(32767),29-e), EXTRACT16(SHR32(x, e-14))); - return SUB16(25736, SHR16(spx_atan01(x),1)); - } -} -#else - -#ifndef M_PI -#define M_PI 3.14159265358979323846 /* pi */ -#endif - -#define C1 0.9999932946f -#define C2 -0.4999124376f -#define C3 0.0414877472f -#define C4 -0.0012712095f - - -#define SPX_PI_2 1.5707963268 -static inline spx_word16_t spx_cos(spx_word16_t x) -{ - if (x>16) - -#else - -static const spx_float_t MIN_LEAK = .005f; - -/* Constants for the two-path filter */ -static const spx_float_t VAR1_SMOOTH = .36f; -static const spx_float_t VAR2_SMOOTH = .7225f; -static const spx_float_t VAR1_UPDATE = .5f; -static const spx_float_t VAR2_UPDATE = .25f; -static const spx_float_t VAR_BACKTRACK = 4.f; -#define TOP16(x) (x) -#endif - - -#define PLAYBACK_DELAY 2 - -void speex_echo_get_residual(SpeexEchoState *st, spx_word32_t *Yout, int len); - - -/** Speex echo cancellation state. */ -struct SpeexEchoState_ { - int frame_size; /**< Number of samples processed each time */ - int window_size; - int M; - int cancel_count; - int adapted; - int saturated; - int screwed_up; - spx_int32_t sampling_rate; - spx_word16_t spec_average; - spx_word16_t beta0; - spx_word16_t beta_max; - spx_word32_t sum_adapt; - spx_word16_t leak_estimate; - - spx_word16_t *e; /* scratch */ - spx_word16_t *x; /* Far-end input buffer (2N) */ - spx_word16_t *X; /* Far-end buffer (M+1 frames) in frequency domain */ - spx_word16_t *input; /* scratch */ - spx_word16_t *y; /* scratch */ - spx_word16_t *last_y; - spx_word16_t *Y; /* scratch */ - spx_word16_t *E; - spx_word32_t *PHI; /* scratch */ - spx_word32_t *W; /* (Background) filter weights */ -#ifdef TWO_PATH - spx_word16_t *foreground; /* Foreground filter weights */ - spx_word32_t Davg1; /* 1st recursive average of the residual power difference */ - spx_word32_t Davg2; /* 2nd recursive average of the residual power difference */ - spx_float_t Dvar1; /* Estimated variance of 1st estimator */ - spx_float_t Dvar2; /* Estimated variance of 2nd estimator */ -#endif - spx_word32_t *power; /* Power of the far-end signal */ - spx_float_t *power_1;/* Inverse power of far-end */ - spx_word16_t *wtmp; /* scratch */ -#ifdef FIXED_POINT - spx_word16_t *wtmp2; /* scratch */ -#endif - spx_word32_t *Rf; /* scratch */ - spx_word32_t *Yf; /* scratch */ - spx_word32_t *Xf; /* scratch */ - spx_word32_t *Eh; - spx_word32_t *Yh; - spx_float_t Pey; - spx_float_t Pyy; - spx_word16_t *window; - spx_word16_t *prop; - void *fft_table; - spx_word16_t memX, memD, memE; - spx_word16_t preemph; - spx_word16_t notch_radius; - spx_mem_t notch_mem[2]; - - /* NOTE: If you only use speex_echo_cancel() and want to save some memory, remove this */ - spx_int16_t *play_buf; - int play_buf_pos; - int play_buf_started; -}; - -static inline void filter_dc_notch16(const spx_int16_t *in, spx_word16_t radius, spx_word16_t *out, int len, spx_mem_t *mem) -{ - int i; - spx_word16_t den2; -#ifdef FIXED_POINT - den2 = MULT16_16_Q15(radius,radius) + MULT16_16_Q15(QCONST16(.7,15),MULT16_16_Q15(32767-radius,32767-radius)); -#else - den2 = radius*radius + .7*(1-radius)*(1-radius); -#endif - /*printf ("%d %d %d %d %d %d\n", num[0], num[1], num[2], den[0], den[1], den[2]);*/ - for (i=0;i>= 1; - while(len--) - { - spx_word32_t part=0; - part = MAC16_16(part,*x++,*y++); - part = MAC16_16(part,*x++,*y++); - /* HINT: If you had a 40-bit accumulator, you could shift only at the end */ - sum = ADD32(sum,SHR32(part,6)); - } - return sum; -} - -/** Compute power spectrum of a half-complex (packed) vector */ -static inline void power_spectrum(const spx_word16_t *X, spx_word32_t *ps, int N) -{ - int i, j; - ps[0]=MULT16_16(X[0],X[0]); - for (i=1,j=1;i max_sum) - max_sum = prop[i]; - } - for (i=0;i -static FILE *rFile=NULL, *pFile=NULL, *oFile=NULL; - -static void dump_audio(const spx_int16_t *rec, const spx_int16_t *play, const spx_int16_t *out, int len) -{ - if (!(rFile && pFile && oFile)) - { - speex_fatal("Dump files not open"); - } - fwrite(rec, sizeof(spx_int16_t), len, rFile); - fwrite(play, sizeof(spx_int16_t), len, pFile); - fwrite(out, sizeof(spx_int16_t), len, oFile); -} -#endif - -/** Creates a new echo canceller state */ -SpeexEchoState *speex_echo_state_init(int frame_size, int filter_length) -{ - int i,N,M; - SpeexEchoState *st = (SpeexEchoState *)speex_alloc(sizeof(SpeexEchoState)); - -#ifdef DUMP_ECHO_CANCEL_DATA - if (rFile || pFile || oFile) - speex_fatal("Opening dump files twice"); - rFile = fopen("aec_rec.sw", "wb"); - pFile = fopen("aec_play.sw", "wb"); - oFile = fopen("aec_out.sw", "wb"); -#endif - - st->frame_size = frame_size; - st->window_size = 2*frame_size; - N = st->window_size; - M = st->M = (filter_length+st->frame_size-1)/frame_size; - st->cancel_count=0; - st->sum_adapt = 0; - st->saturated = 0; - st->screwed_up = 0; - /* This is the default sampling rate */ - st->sampling_rate = 8000; - st->spec_average = DIV32_16(SHL32(EXTEND32(st->frame_size), 15), st->sampling_rate); -#ifdef FIXED_POINT - st->beta0 = DIV32_16(SHL32(EXTEND32(st->frame_size), 16), st->sampling_rate); - st->beta_max = DIV32_16(SHL32(EXTEND32(st->frame_size), 14), st->sampling_rate); -#else - st->beta0 = (2.0f*st->frame_size)/st->sampling_rate; - st->beta_max = (.5f*st->frame_size)/st->sampling_rate; -#endif - st->leak_estimate = 0; - - st->fft_table = spx_fft_init(N); - - st->e = (spx_word16_t*)speex_alloc(N*sizeof(spx_word16_t)); - st->x = (spx_word16_t*)speex_alloc(N*sizeof(spx_word16_t)); - st->input = (spx_word16_t*)speex_alloc(st->frame_size*sizeof(spx_word16_t)); - st->y = (spx_word16_t*)speex_alloc(N*sizeof(spx_word16_t)); - st->last_y = (spx_word16_t*)speex_alloc(N*sizeof(spx_word16_t)); - st->Yf = (spx_word32_t*)speex_alloc((st->frame_size+1)*sizeof(spx_word32_t)); - st->Rf = (spx_word32_t*)speex_alloc((st->frame_size+1)*sizeof(spx_word32_t)); - st->Xf = (spx_word32_t*)speex_alloc((st->frame_size+1)*sizeof(spx_word32_t)); - st->Yh = (spx_word32_t*)speex_alloc((st->frame_size+1)*sizeof(spx_word32_t)); - st->Eh = (spx_word32_t*)speex_alloc((st->frame_size+1)*sizeof(spx_word32_t)); - - st->X = (spx_word16_t*)speex_alloc((M+1)*N*sizeof(spx_word16_t)); - st->Y = (spx_word16_t*)speex_alloc(N*sizeof(spx_word16_t)); - st->E = (spx_word16_t*)speex_alloc(N*sizeof(spx_word16_t)); - st->W = (spx_word32_t*)speex_alloc(M*N*sizeof(spx_word32_t)); -#ifdef TWO_PATH - st->foreground = (spx_word16_t*)speex_alloc(M*N*sizeof(spx_word16_t)); -#endif - st->PHI = (spx_word32_t*)speex_alloc(N*sizeof(spx_word32_t)); - st->power = (spx_word32_t*)speex_alloc((frame_size+1)*sizeof(spx_word32_t)); - st->power_1 = (spx_float_t*)speex_alloc((frame_size+1)*sizeof(spx_float_t)); - st->window = (spx_word16_t*)speex_alloc(N*sizeof(spx_word16_t)); - st->prop = (spx_word16_t*)speex_alloc(M*sizeof(spx_word16_t)); - st->wtmp = (spx_word16_t*)speex_alloc(N*sizeof(spx_word16_t)); -#ifdef FIXED_POINT - st->wtmp2 = (spx_word16_t*)speex_alloc(N*sizeof(spx_word16_t)); - for (i=0;i>1;i++) - { - st->window[i] = (16383-SHL16(spx_cos(DIV32_16(MULT16_16(25736,i<<1),N)),1)); - st->window[N-i-1] = st->window[i]; - } -#else - for (i=0;iwindow[i] = .5-.5*cos(2*M_PI*i/N); -#endif - for (i=0;i<=st->frame_size;i++) - st->power_1[i] = FLOAT_ONE; - for (i=0;iW[i] = 0; - { - spx_word32_t sum = 0; - /* Ratio of ~10 between adaptation rate of first and last block */ - spx_word16_t decay = SHR32(spx_exp(NEG16(DIV32_16(QCONST16(2.4,11),M))),1); - st->prop[0] = QCONST16(.7, 15); - sum = EXTEND32(st->prop[0]); - for (i=1;iprop[i] = MULT16_16_Q15(st->prop[i-1], decay); - sum = ADD32(sum, EXTEND32(st->prop[i])); - } - for (i=M-1;i>=0;i--) - { - st->prop[i] = DIV32(MULT16_16(QCONST16(.8,15), st->prop[i]),sum); - } - } - - st->memX=st->memD=st->memE=0; - st->preemph = QCONST16(.9,15); - if (st->sampling_rate<12000) - st->notch_radius = QCONST16(.9, 15); - else if (st->sampling_rate<24000) - st->notch_radius = QCONST16(.982, 15); - else - st->notch_radius = QCONST16(.992, 15); - - st->notch_mem[0] = st->notch_mem[1] = 0; - st->adapted = 0; - st->Pey = st->Pyy = FLOAT_ONE; - -#ifdef TWO_PATH - st->Davg1 = st->Davg2 = 0; - st->Dvar1 = st->Dvar2 = FLOAT_ZERO; -#endif - - st->play_buf = (spx_int16_t*)speex_alloc((PLAYBACK_DELAY+1)*st->frame_size*sizeof(spx_int16_t)); - st->play_buf_pos = PLAYBACK_DELAY*st->frame_size; - st->play_buf_started = 0; - - return st; -} - -/** Resets echo canceller state */ -void speex_echo_state_reset(SpeexEchoState *st) -{ - int i, M, N; - st->cancel_count=0; - st->screwed_up = 0; - N = st->window_size; - M = st->M; - for (i=0;iW[i] = 0; -#ifdef TWO_PATH - for (i=0;iforeground[i] = 0; -#endif - for (i=0;iX[i] = 0; - for (i=0;i<=st->frame_size;i++) - { - st->power[i] = 0; - st->power_1[i] = FLOAT_ONE; - st->Eh[i] = 0; - st->Yh[i] = 0; - } - for (i=0;iframe_size;i++) - { - st->last_y[i] = 0; - } - for (i=0;iE[i] = 0; - st->x[i] = 0; - } - st->notch_mem[0] = st->notch_mem[1] = 0; - st->memX=st->memD=st->memE=0; - - st->saturated = 0; - st->adapted = 0; - st->sum_adapt = 0; - st->Pey = st->Pyy = FLOAT_ONE; -#ifdef TWO_PATH - st->Davg1 = st->Davg2 = 0; - st->Dvar1 = st->Dvar2 = FLOAT_ZERO; -#endif - for (i=0;i<3*st->frame_size;i++) - st->play_buf[i] = 0; - st->play_buf_pos = PLAYBACK_DELAY*st->frame_size; - st->play_buf_started = 0; - -} - -/** Destroys an echo canceller state */ -void speex_echo_state_destroy(SpeexEchoState *st) -{ - spx_fft_destroy(st->fft_table); - - speex_free(st->e); - speex_free(st->x); - speex_free(st->input); - speex_free(st->y); - speex_free(st->last_y); - speex_free(st->Yf); - speex_free(st->Rf); - speex_free(st->Xf); - speex_free(st->Yh); - speex_free(st->Eh); - - speex_free(st->X); - speex_free(st->Y); - speex_free(st->E); - speex_free(st->W); -#ifdef TWO_PATH - speex_free(st->foreground); -#endif - speex_free(st->PHI); - speex_free(st->power); - speex_free(st->power_1); - speex_free(st->window); - speex_free(st->prop); - speex_free(st->wtmp); -#ifdef FIXED_POINT - speex_free(st->wtmp2); -#endif - speex_free(st->play_buf); - speex_free(st); - -#ifdef DUMP_ECHO_CANCEL_DATA - fclose(rFile); - fclose(pFile); - fclose(oFile); - rFile = pFile = oFile = NULL; -#endif -} - -void speex_echo_capture(SpeexEchoState *st, const spx_int16_t *rec, spx_int16_t *out) -{ - int i; - /*speex_warning_int("capture with fill level ", st->play_buf_pos/st->frame_size);*/ - st->play_buf_started = 1; - if (st->play_buf_pos>=st->frame_size) - { - speex_echo_cancellation(st, rec, st->play_buf, out); - st->play_buf_pos -= st->frame_size; - for (i=0;iplay_buf_pos;i++) - st->play_buf[i] = st->play_buf[i+st->frame_size]; - } else { - speex_warning("No playback frame available (your application is buggy and/or got xruns)"); - if (st->play_buf_pos!=0) - { - speex_warning("internal playback buffer corruption?"); - st->play_buf_pos = 0; - } - for (i=0;iframe_size;i++) - out[i] = rec[i]; - } -} - -void speex_echo_playback(SpeexEchoState *st, const spx_int16_t *play) -{ - /*speex_warning_int("playback with fill level ", st->play_buf_pos/st->frame_size);*/ - if (!st->play_buf_started) - { - speex_warning("discarded first playback frame"); - return; - } - if (st->play_buf_pos<=PLAYBACK_DELAY*st->frame_size) - { - int i; - for (i=0;iframe_size;i++) - st->play_buf[st->play_buf_pos+i] = play[i]; - st->play_buf_pos += st->frame_size; - if (st->play_buf_pos <= (PLAYBACK_DELAY-1)*st->frame_size) - { - speex_warning("Auto-filling the buffer (your application is buggy and/or got xruns)"); - for (i=0;iframe_size;i++) - st->play_buf[st->play_buf_pos+i] = play[i]; - st->play_buf_pos += st->frame_size; - } - } else { - speex_warning("Had to discard a playback frame (your application is buggy and/or got xruns)"); - } -} - -/** Performs echo cancellation on a frame (deprecated, last arg now ignored) */ -void speex_echo_cancel(SpeexEchoState *st, const spx_int16_t *in, const spx_int16_t *far_end, spx_int16_t *out, spx_int32_t *Yout) -{ - speex_echo_cancellation(st, in, far_end, out); -} - -/** Performs echo cancellation on a frame */ -void speex_echo_cancellation(SpeexEchoState *st, const spx_int16_t *in, const spx_int16_t *far_end, spx_int16_t *out) -{ - int i,j; - int N,M; - spx_word32_t Syy,See,Sxx,Sdd, Sff; -#ifdef TWO_PATH - spx_word32_t Dbf; - int update_foreground; -#endif - spx_word32_t Sey; - spx_word16_t ss, ss_1; - spx_float_t Pey = FLOAT_ONE, Pyy=FLOAT_ONE; - spx_float_t alpha, alpha_1; - spx_word16_t RER; - spx_word32_t tmp32; - - N = st->window_size; - M = st->M; - st->cancel_count++; -#ifdef FIXED_POINT - ss=DIV32_16(11469,M); - ss_1 = SUB16(32767,ss); -#else - ss=.35/M; - ss_1 = 1-ss; -#endif - - /* Apply a notch filter to make sure DC doesn't end up causing problems */ - filter_dc_notch16(in, st->notch_radius, st->input, st->frame_size, st->notch_mem); - /* Copy input data to buffer and apply pre-emphasis */ - for (i=0;iframe_size;i++) - { - spx_word32_t tmp32; - tmp32 = SUB32(EXTEND32(far_end[i]), EXTEND32(MULT16_16_P15(st->preemph, st->memX))); -#ifdef FIXED_POINT - /* If saturation occurs here, we need to freeze adaptation for M+1 frames (not just one) */ - if (tmp32 > 32767) - { - tmp32 = 32767; - st->saturated = M+1; - } - if (tmp32 < -32767) - { - tmp32 = -32767; - st->saturated = M+1; - } -#endif - st->x[i+st->frame_size] = EXTRACT16(tmp32); - st->memX = far_end[i]; - - tmp32 = SUB32(EXTEND32(st->input[i]), EXTEND32(MULT16_16_P15(st->preemph, st->memD))); -#ifdef FIXED_POINT - if (tmp32 > 32767) - { - tmp32 = 32767; - if (st->saturated == 0) - st->saturated = 1; - } - if (tmp32 < -32767) - { - tmp32 = -32767; - if (st->saturated == 0) - st->saturated = 1; - } -#endif - st->memD = st->input[i]; - st->input[i] = tmp32; - } - - /* Shift memory: this could be optimized eventually*/ - for (j=M-1;j>=0;j--) - { - for (i=0;iX[(j+1)*N+i] = st->X[j*N+i]; - } - - /* Convert x (far end) to frequency domain */ - spx_fft(st->fft_table, st->x, &st->X[0]); - for (i=0;ilast_y[i] = st->x[i]; - Sxx = mdf_inner_prod(st->x+st->frame_size, st->x+st->frame_size, st->frame_size); - for (i=0;iframe_size;i++) - st->x[i] = st->x[i+st->frame_size]; - /* From here on, the top part of x is used as scratch space */ - -#ifdef TWO_PATH - /* Compute foreground filter */ - spectral_mul_accum16(st->X, st->foreground, st->Y, N, M); - spx_ifft(st->fft_table, st->Y, st->e); - for (i=0;iframe_size;i++) - st->e[i] = SUB16(st->input[i], st->e[i+st->frame_size]); - Sff = mdf_inner_prod(st->e, st->e, st->frame_size); -#endif - - /* Adjust proportional adaption rate */ - mdf_adjust_prop (st->W, N, M, st->prop); - /* Compute weight gradient */ - if (st->saturated == 0) - { - for (j=M-1;j>=0;j--) - { - weighted_spectral_mul_conj(st->power_1, FLOAT_SHL(PSEUDOFLOAT(st->prop[j]),-15), &st->X[(j+1)*N], st->E, st->PHI, N); - for (i=0;iW[j*N+i] = ADD32(st->W[j*N+i], st->PHI[i]); - - } - } else { - st->saturated--; - } - - /* Update weight to prevent circular convolution (MDF / AUMDF) */ - for (j=0;jcancel_count%(M-1) == j-1) - { -#ifdef FIXED_POINT - for (i=0;iwtmp2[i] = EXTRACT16(PSHR32(st->W[j*N+i],NORMALIZE_SCALEDOWN+16)); - spx_ifft(st->fft_table, st->wtmp2, st->wtmp); - for (i=0;iframe_size;i++) - { - st->wtmp[i]=0; - } - for (i=st->frame_size;iwtmp[i]=SHL16(st->wtmp[i],NORMALIZE_SCALEUP); - } - spx_fft(st->fft_table, st->wtmp, st->wtmp2); - /* The "-1" in the shift is a sort of kludge that trades less efficient update speed for decrease noise */ - for (i=0;iW[j*N+i] -= SHL32(EXTEND32(st->wtmp2[i]),16+NORMALIZE_SCALEDOWN-NORMALIZE_SCALEUP-1); -#else - spx_ifft(st->fft_table, &st->W[j*N], st->wtmp); - for (i=st->frame_size;iwtmp[i]=0; - } - spx_fft(st->fft_table, st->wtmp, &st->W[j*N]); -#endif - } - } - - /* Compute filter response Y */ - spectral_mul_accum(st->X, st->W, st->Y, N, M); - spx_ifft(st->fft_table, st->Y, st->y); - -#ifdef TWO_PATH - /* Difference in response, this is used to estimate the variance of our residual power estimate */ - for (i=0;iframe_size;i++) - st->e[i] = SUB16(st->e[i+st->frame_size], st->y[i+st->frame_size]); - Dbf = 10+mdf_inner_prod(st->e, st->e, st->frame_size); -#endif - - for (i=0;iframe_size;i++) - st->e[i] = SUB16(st->input[i], st->y[i+st->frame_size]); - See = mdf_inner_prod(st->e, st->e, st->frame_size); -#ifndef TWO_PATH - Sff = See; -#endif - -#ifdef TWO_PATH - /* Logic for updating the foreground filter */ - - /* For two time windows, compute the mean of the energy difference, as well as the variance */ - st->Davg1 = ADD32(MULT16_32_Q15(QCONST16(.6f,15),st->Davg1), MULT16_32_Q15(QCONST16(.4f,15),SUB32(Sff,See))); - st->Davg2 = ADD32(MULT16_32_Q15(QCONST16(.85f,15),st->Davg2), MULT16_32_Q15(QCONST16(.15f,15),SUB32(Sff,See))); - st->Dvar1 = FLOAT_ADD(FLOAT_MULT(VAR1_SMOOTH, st->Dvar1), FLOAT_MUL32U(MULT16_32_Q15(QCONST16(.4f,15),Sff), MULT16_32_Q15(QCONST16(.4f,15),Dbf))); - st->Dvar2 = FLOAT_ADD(FLOAT_MULT(VAR2_SMOOTH, st->Dvar2), FLOAT_MUL32U(MULT16_32_Q15(QCONST16(.15f,15),Sff), MULT16_32_Q15(QCONST16(.15f,15),Dbf))); - - /* Equivalent float code: - st->Davg1 = .6*st->Davg1 + .4*(Sff-See); - st->Davg2 = .85*st->Davg2 + .15*(Sff-See); - st->Dvar1 = .36*st->Dvar1 + .16*Sff*Dbf; - st->Dvar2 = .7225*st->Dvar2 + .0225*Sff*Dbf; - */ - - update_foreground = 0; - /* Check if we have a statistically significant reduction in the residual echo */ - /* Note that this is *not* Gaussian, so we need to be careful about the longer tail */ - if (FLOAT_GT(FLOAT_MUL32U(SUB32(Sff,See),ABS32(SUB32(Sff,See))), FLOAT_MUL32U(Sff,Dbf))) - update_foreground = 1; - else if (FLOAT_GT(FLOAT_MUL32U(st->Davg1, ABS32(st->Davg1)), FLOAT_MULT(VAR1_UPDATE,(st->Dvar1)))) - update_foreground = 1; - else if (FLOAT_GT(FLOAT_MUL32U(st->Davg2, ABS32(st->Davg2)), FLOAT_MULT(VAR2_UPDATE,(st->Dvar2)))) - update_foreground = 1; - - /* Do we update? */ - if (update_foreground) - { - st->Davg1 = st->Davg2 = 0; - st->Dvar1 = st->Dvar2 = FLOAT_ZERO; - /* Copy background filter to foreground filter */ - for (i=0;iforeground[i] = EXTRACT16(PSHR32(st->W[i],16)); - /* Apply a smooth transition so as to not introduce blocking artifacts */ - for (i=0;iframe_size;i++) - st->e[i+st->frame_size] = MULT16_16_Q15(st->window[i+st->frame_size],st->e[i+st->frame_size]) + MULT16_16_Q15(st->window[i],st->y[i+st->frame_size]); - } else { - int reset_background=0; - /* Otherwise, check if the background filter is significantly worse */ - if (FLOAT_GT(FLOAT_MUL32U(NEG32(SUB32(Sff,See)),ABS32(SUB32(Sff,See))), FLOAT_MULT(VAR_BACKTRACK,FLOAT_MUL32U(Sff,Dbf)))) - reset_background = 1; - if (FLOAT_GT(FLOAT_MUL32U(NEG32(st->Davg1), ABS32(st->Davg1)), FLOAT_MULT(VAR_BACKTRACK,st->Dvar1))) - reset_background = 1; - if (FLOAT_GT(FLOAT_MUL32U(NEG32(st->Davg2), ABS32(st->Davg2)), FLOAT_MULT(VAR_BACKTRACK,st->Dvar2))) - reset_background = 1; - if (reset_background) - { - /* Copy foreground filter to background filter */ - for (i=0;iW[i] = SHL32(EXTEND32(st->foreground[i]),16); - /* We also need to copy the output so as to get correct adaptation */ - for (i=0;iframe_size;i++) - st->y[i+st->frame_size] = st->e[i+st->frame_size]; - for (i=0;iframe_size;i++) - st->e[i] = SUB16(st->input[i], st->y[i+st->frame_size]); - See = Sff; - st->Davg1 = st->Davg2 = 0; - st->Dvar1 = st->Dvar2 = FLOAT_ZERO; - } - } -#endif - - /* Compute error signal (for the output with de-emphasis) */ - for (i=0;iframe_size;i++) - { - spx_word32_t tmp_out; -#ifdef TWO_PATH - tmp_out = SUB32(EXTEND32(st->input[i]), EXTEND32(st->e[i+st->frame_size])); -#else - tmp_out = SUB32(EXTEND32(st->input[i]), EXTEND32(st->y[i+st->frame_size])); -#endif - /* Saturation */ - if (tmp_out>32767) - tmp_out = 32767; - else if (tmp_out<-32768) - tmp_out = -32768; - tmp_out = ADD32(tmp_out, EXTEND32(MULT16_16_P15(st->preemph, st->memE))); - /* This is an arbitrary test for saturation in the microphone signal */ - if (in[i] <= -32000 || in[i] >= 32000) - { - tmp_out = 0; - if (st->saturated == 0) - st->saturated = 1; - } - out[i] = (spx_int16_t)tmp_out; - st->memE = tmp_out; - } - -#ifdef DUMP_ECHO_CANCEL_DATA - dump_audio(in, far_end, out, st->frame_size); -#endif - - /* Compute error signal (filter update version) */ - for (i=0;iframe_size;i++) - { - st->e[i+st->frame_size] = st->e[i]; - st->e[i] = 0; - } - - /* Compute a bunch of correlations */ - Sey = mdf_inner_prod(st->e+st->frame_size, st->y+st->frame_size, st->frame_size); - Syy = mdf_inner_prod(st->y+st->frame_size, st->y+st->frame_size, st->frame_size); - Sdd = mdf_inner_prod(st->input, st->input, st->frame_size); - - /*printf ("%f %f %f %f\n", Sff, See, Syy, Sdd, st->update_cond);*/ - - /* Do some sanity check */ - if (!(Syy>=0 && Sxx>=0 && See >= 0) -#ifndef FIXED_POINT - || !(Sff < N*1e9 && Syy < N*1e9 && Sxx < N*1e9) -#endif - ) - { - /* Things have gone really bad */ - st->screwed_up += 50; - for (i=0;iframe_size;i++) - out[i] = 0; - } else if (SHR32(Sff, 2) > ADD32(Sdd, SHR32(MULT16_16(N, 10000),6))) - { - /* AEC seems to add lots of echo instead of removing it, let's see if it will improve */ - st->screwed_up++; - } else { - /* Everything's fine */ - st->screwed_up=0; - } - if (st->screwed_up>=50) - { - speex_warning("The echo canceller started acting funny and got slapped (reset). It swears it will behave now."); - speex_echo_state_reset(st); - return; - } - - /* Add a small noise floor to make sure not to have problems when dividing */ - See = MAX32(See, SHR32(MULT16_16(N, 100),6)); - - /* Convert error to frequency domain */ - spx_fft(st->fft_table, st->e, st->E); - for (i=0;iframe_size;i++) - st->y[i] = 0; - spx_fft(st->fft_table, st->y, st->Y); - - /* Compute power spectrum of far end (X), error (E) and filter response (Y) */ - power_spectrum(st->E, st->Rf, N); - power_spectrum(st->Y, st->Yf, N); - power_spectrum(st->X, st->Xf, N); - - /* Smooth far end energy estimate over time */ - for (j=0;j<=st->frame_size;j++) - st->power[j] = MULT16_32_Q15(ss_1,st->power[j]) + 1 + MULT16_32_Q15(ss,st->Xf[j]); - - /* Enable this to compute the power based only on the tail (would need to compute more - efficiently to make this really useful */ - if (0) - { - float scale2 = .5f/M; - for (j=0;j<=st->frame_size;j++) - st->power[j] = 100; - for (i=0;iX[i*N], st->Xf, N); - for (j=0;j<=st->frame_size;j++) - st->power[j] += scale2*st->Xf[j]; - } - } - - /* Compute filtered spectra and (cross-)correlations */ - for (j=st->frame_size;j>=0;j--) - { - spx_float_t Eh, Yh; - Eh = PSEUDOFLOAT(st->Rf[j] - st->Eh[j]); - Yh = PSEUDOFLOAT(st->Yf[j] - st->Yh[j]); - Pey = FLOAT_ADD(Pey,FLOAT_MULT(Eh,Yh)); - Pyy = FLOAT_ADD(Pyy,FLOAT_MULT(Yh,Yh)); -#ifdef FIXED_POINT - st->Eh[j] = MAC16_32_Q15(MULT16_32_Q15(SUB16(32767,st->spec_average),st->Eh[j]), st->spec_average, st->Rf[j]); - st->Yh[j] = MAC16_32_Q15(MULT16_32_Q15(SUB16(32767,st->spec_average),st->Yh[j]), st->spec_average, st->Yf[j]); -#else - st->Eh[j] = (1-st->spec_average)*st->Eh[j] + st->spec_average*st->Rf[j]; - st->Yh[j] = (1-st->spec_average)*st->Yh[j] + st->spec_average*st->Yf[j]; -#endif - } - - Pyy = FLOAT_SQRT(Pyy); - Pey = FLOAT_DIVU(Pey,Pyy); - - /* Compute correlation updatete rate */ - tmp32 = MULT16_32_Q15(st->beta0,Syy); - if (tmp32 > MULT16_32_Q15(st->beta_max,See)) - tmp32 = MULT16_32_Q15(st->beta_max,See); - alpha = FLOAT_DIV32(tmp32, See); - alpha_1 = FLOAT_SUB(FLOAT_ONE, alpha); - /* Update correlations (recursive average) */ - st->Pey = FLOAT_ADD(FLOAT_MULT(alpha_1,st->Pey) , FLOAT_MULT(alpha,Pey)); - st->Pyy = FLOAT_ADD(FLOAT_MULT(alpha_1,st->Pyy) , FLOAT_MULT(alpha,Pyy)); - if (FLOAT_LT(st->Pyy, FLOAT_ONE)) - st->Pyy = FLOAT_ONE; - /* We don't really hope to get better than 33 dB (MIN_LEAK-3dB) attenuation anyway */ - if (FLOAT_LT(st->Pey, FLOAT_MULT(MIN_LEAK,st->Pyy))) - st->Pey = FLOAT_MULT(MIN_LEAK,st->Pyy); - if (FLOAT_GT(st->Pey, st->Pyy)) - st->Pey = st->Pyy; - /* leak_estimate is the linear regression result */ - st->leak_estimate = FLOAT_EXTRACT16(FLOAT_SHL(FLOAT_DIVU(st->Pey, st->Pyy),14)); - /* This looks like a stupid bug, but it's right (because we convert from Q14 to Q15) */ - if (st->leak_estimate > 16383) - st->leak_estimate = 32767; - else - st->leak_estimate = SHL16(st->leak_estimate,1); - /*printf ("%f\n", st->leak_estimate);*/ - - /* Compute Residual to Error Ratio */ -#ifdef FIXED_POINT - tmp32 = MULT16_32_Q15(st->leak_estimate,Syy); - tmp32 = ADD32(SHR32(Sxx,13), ADD32(tmp32, SHL32(tmp32,1))); - /* Check for y in e (lower bound on RER) */ - { - spx_float_t bound = PSEUDOFLOAT(Sey); - bound = FLOAT_DIVU(FLOAT_MULT(bound, bound), PSEUDOFLOAT(ADD32(1,Syy))); - if (FLOAT_GT(bound, PSEUDOFLOAT(See))) - tmp32 = See; - else if (tmp32 < FLOAT_EXTRACT32(bound)) - tmp32 = FLOAT_EXTRACT32(bound); - } - if (tmp32 > SHR32(See,1)) - tmp32 = SHR32(See,1); - RER = FLOAT_EXTRACT16(FLOAT_SHL(FLOAT_DIV32(tmp32,See),15)); -#else - RER = (.0001*Sxx + 3.*MULT16_32_Q15(st->leak_estimate,Syy)) / See; - /* Check for y in e (lower bound on RER) */ - if (RER < Sey*Sey/(1+See*Syy)) - RER = Sey*Sey/(1+See*Syy); - if (RER > .5) - RER = .5; -#endif - - /* We consider that the filter has had minimal adaptation if the following is true*/ - if (!st->adapted && st->sum_adapt > SHL32(EXTEND32(M),15) && MULT16_32_Q15(st->leak_estimate,Syy) > MULT16_32_Q15(QCONST16(.03f,15),Syy)) - { - st->adapted = 1; - } - - if (st->adapted) - { - /* Normal learning rate calculation once we're past the minimal adaptation phase */ - for (i=0;i<=st->frame_size;i++) - { - spx_word32_t r, e; - /* Compute frequency-domain adaptation mask */ - r = MULT16_32_Q15(st->leak_estimate,SHL32(st->Yf[i],3)); - e = SHL32(st->Rf[i],3)+1; -#ifdef FIXED_POINT - if (r>SHR32(e,1)) - r = SHR32(e,1); -#else - if (r>.5*e) - r = .5*e; -#endif - r = MULT16_32_Q15(QCONST16(.7,15),r) + MULT16_32_Q15(QCONST16(.3,15),(spx_word32_t)(MULT16_32_Q15(RER,e))); - /*st->power_1[i] = adapt_rate*r/(e*(1+st->power[i]));*/ - st->power_1[i] = FLOAT_SHL(FLOAT_DIV32_FLOAT(r,FLOAT_MUL32U(e,st->power[i]+10)),WEIGHT_SHIFT+16); - } - } else { - /* Temporary adaption rate if filter is not yet adapted enough */ - spx_word16_t adapt_rate=0; - - if (Sxx > SHR32(MULT16_16(N, 1000),6)) - { - tmp32 = MULT16_32_Q15(QCONST16(.25f, 15), Sxx); -#ifdef FIXED_POINT - if (tmp32 > SHR32(See,2)) - tmp32 = SHR32(See,2); -#else - if (tmp32 > .25*See) - tmp32 = .25*See; -#endif - adapt_rate = FLOAT_EXTRACT16(FLOAT_SHL(FLOAT_DIV32(tmp32, See),15)); - } - for (i=0;i<=st->frame_size;i++) - st->power_1[i] = FLOAT_SHL(FLOAT_DIV32(EXTEND32(adapt_rate),ADD32(st->power[i],10)),WEIGHT_SHIFT+1); - - - /* How much have we adapted so far? */ - st->sum_adapt = ADD32(st->sum_adapt,adapt_rate); - } - - /* Save residual echo so it can be used by the nonlinear processor */ - if (st->adapted) - { - /* If the filter is adapted, take the filtered echo */ - for (i=0;iframe_size;i++) - st->last_y[i] = st->last_y[st->frame_size+i]; - for (i=0;iframe_size;i++) - st->last_y[st->frame_size+i] = in[i]-out[i]; - } else { - /* If filter isn't adapted yet, all we can do is take the far end signal directly */ - /* moved earlier: for (i=0;ilast_y[i] = st->x[i];*/ - } - -} - -/* Compute spectrum of estimated echo for use in an echo post-filter */ -void speex_echo_get_residual(SpeexEchoState *st, spx_word32_t *residual_echo, int len) -{ - int i; - spx_word16_t leak2; - int N; - - N = st->window_size; - - /* Apply hanning window (should pre-compute it)*/ - for (i=0;iy[i] = MULT16_16_Q15(st->window[i],st->last_y[i]); - - /* Compute power spectrum of the echo */ - spx_fft(st->fft_table, st->y, st->Y); - power_spectrum(st->Y, residual_echo, N); - -#ifdef FIXED_POINT - if (st->leak_estimate > 16383) - leak2 = 32767; - else - leak2 = SHL16(st->leak_estimate, 1); -#else - if (st->leak_estimate>.5) - leak2 = 1; - else - leak2 = 2*st->leak_estimate; -#endif - /* Estimate residual echo */ - for (i=0;i<=st->frame_size;i++) - residual_echo[i] = (spx_int32_t)MULT16_32_Q15(leak2,residual_echo[i]); - -} - -int speex_echo_ctl(SpeexEchoState *st, int request, void *ptr) -{ - switch(request) - { - - case SPEEX_ECHO_GET_FRAME_SIZE: - (*(int*)ptr) = st->frame_size; - break; - case SPEEX_ECHO_SET_SAMPLING_RATE: - st->sampling_rate = (*(int*)ptr); - st->spec_average = DIV32_16(SHL32(EXTEND32(st->frame_size), 15), st->sampling_rate); -#ifdef FIXED_POINT - st->beta0 = DIV32_16(SHL32(EXTEND32(st->frame_size), 16), st->sampling_rate); - st->beta_max = DIV32_16(SHL32(EXTEND32(st->frame_size), 14), st->sampling_rate); -#else - st->beta0 = (2.0f*st->frame_size)/st->sampling_rate; - st->beta_max = (.5f*st->frame_size)/st->sampling_rate; -#endif - if (st->sampling_rate<12000) - st->notch_radius = QCONST16(.9, 15); - else if (st->sampling_rate<24000) - st->notch_radius = QCONST16(.982, 15); - else - st->notch_radius = QCONST16(.992, 15); - break; - case SPEEX_ECHO_GET_SAMPLING_RATE: - (*(int*)ptr) = st->sampling_rate; - break; - default: - speex_warning_int("Unknown speex_echo_ctl request: ", request); - return -1; - } - return 0; -} diff --git a/apps/codecs/libspeex/misc_bfin.h b/apps/codecs/libspeex/misc_bfin.h deleted file mode 100644 index 77b082c057..0000000000 --- a/apps/codecs/libspeex/misc_bfin.h +++ /dev/null @@ -1,54 +0,0 @@ -/* Copyright (C) 2005 Analog Devices */ -/** - @file misc_bfin.h - @author Jean-Marc Valin - @brief Various compatibility routines for Speex (Blackfin version) -*/ -/* - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of the Xiph.org Foundation nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#define OVERRIDE_SPEEX_MOVE -void *speex_move (void *dest, void *src, int n) -{ - __asm__ __volatile__ - ( - "L0 = 0;\n\t" - "I0 = %0;\n\t" - "R0 = [I0++];\n\t" - "LOOP move%= LC0 = %2;\n\t" - "LOOP_BEGIN move%=;\n\t" - "[%1++] = R0 || R0 = [I0++];\n\t" - "LOOP_END move%=;\n\t" - "[%1++] = R0;\n\t" - : "=a" (src), "=a" (dest) - : "a" ((n>>2)-1), "0" (src), "1" (dest) - : "R0", "I0", "L0", "memory" - ); - return dest; -} diff --git a/apps/codecs/libspeex/modes.c b/apps/codecs/libspeex/modes.c deleted file mode 100644 index d1046f1cfb..0000000000 --- a/apps/codecs/libspeex/modes.c +++ /dev/null @@ -1,484 +0,0 @@ -/* Copyright (C) 2002-2006 Jean-Marc Valin - File: modes.c - - Describes the different modes of the codec - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of the Xiph.org Foundation nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*/ - -#ifdef HAVE_CONFIG_H -#include "config-speex.h" -#endif - -#include "modes.h" -#include "ltp.h" -#include "quant_lsp.h" -#include "cb_search.h" -#include "sb_celp.h" -#include "nb_celp.h" -#include "vbr.h" -#include "arch.h" -#include - -#ifndef NULL -#define NULL 0 -#endif - - -/* Extern declarations for all codebooks we use here */ -extern const signed char gain_cdbk_nb[]; -extern const signed char gain_cdbk_lbr[]; -extern const signed char exc_5_256_table[]; -extern const signed char exc_5_64_table[]; -extern const signed char exc_8_128_table[]; -extern const signed char exc_10_32_table[]; -extern const signed char exc_10_16_table[]; -extern const signed char exc_20_32_table[]; - - -/* Parameters for Long-Term Prediction (LTP)*/ -static const ltp_params ltp_params_nb = { - gain_cdbk_nb, - 7, - 7 -}; - -/* Parameters for Long-Term Prediction (LTP)*/ -static const ltp_params ltp_params_vlbr = { - gain_cdbk_lbr, - 5, - 0 -}; - -/* Parameters for Long-Term Prediction (LTP)*/ -static const ltp_params ltp_params_lbr = { - gain_cdbk_lbr, - 5, - 7 -}; - -/* Parameters for Long-Term Prediction (LTP)*/ -static const ltp_params ltp_params_med = { - gain_cdbk_lbr, - 5, - 7 -}; - -/* Split-VQ innovation parameters for very low bit-rate narrowband */ -static const split_cb_params split_cb_nb_vlbr = { - 10, /*subvect_size*/ - 4, /*nb_subvect*/ - exc_10_16_table, /*shape_cb*/ - 4, /*shape_bits*/ - 0, -}; - -/* Split-VQ innovation parameters for very low bit-rate narrowband */ -static const split_cb_params split_cb_nb_ulbr = { - 20, /*subvect_size*/ - 2, /*nb_subvect*/ - exc_20_32_table, /*shape_cb*/ - 5, /*shape_bits*/ - 0, -}; - -/* Split-VQ innovation parameters for low bit-rate narrowband */ -static const split_cb_params split_cb_nb_lbr = { - 10, /*subvect_size*/ - 4, /*nb_subvect*/ - exc_10_32_table, /*shape_cb*/ - 5, /*shape_bits*/ - 0, -}; - - -/* Split-VQ innovation parameters narrowband */ -static const split_cb_params split_cb_nb = { - 5, /*subvect_size*/ - 8, /*nb_subvect*/ - exc_5_64_table, /*shape_cb*/ - 6, /*shape_bits*/ - 0, -}; - -/* Split-VQ innovation parameters narrowband */ -static const split_cb_params split_cb_nb_med = { - 8, /*subvect_size*/ - 5, /*nb_subvect*/ - exc_8_128_table, /*shape_cb*/ - 7, /*shape_bits*/ - 0, -}; - -/* Split-VQ innovation for low-band wideband */ -static const split_cb_params split_cb_sb = { - 5, /*subvect_size*/ - 8, /*nb_subvect*/ - exc_5_256_table, /*shape_cb*/ - 8, /*shape_bits*/ - 0, -}; - - - -/* 2150 bps "vocoder-like" mode for comfort noise */ -static const SpeexSubmode nb_submode1 = { - 0, - 1, - 0, - 0, -#ifndef SPEEX_DISABLE_ENCODER - /* LSP quantization */ - lsp_quant_lbr, - lsp_unquant_lbr, - /* No pitch quantization */ - forced_pitch_quant, - forced_pitch_unquant, - NULL, - /* No innovation quantization (noise only) */ - noise_codebook_quant, - noise_codebook_unquant, -#else - /* LSP quantization */ - NULL, - lsp_unquant_lbr, - /* No pitch quantization */ - NULL, - forced_pitch_unquant, - NULL, - /* No innovation quantization (noise only) */ - NULL, - noise_codebook_unquant, -#endif - NULL, - -1, - 43 -}; - -/* 3.95 kbps very low bit-rate mode */ -static const SpeexSubmode nb_submode8 = { - 0, - 1, - 0, - 0, -#ifndef SPEEX_DISABLE_ENCODER - /*LSP quantization*/ - lsp_quant_lbr, - lsp_unquant_lbr, - /*No pitch quantization*/ - forced_pitch_quant, - forced_pitch_unquant, - NULL, - /*Innovation quantization*/ - split_cb_search_shape_sign, - split_cb_shape_sign_unquant, - &split_cb_nb_ulbr, -#else - /*LSP quantization*/ - NULL, - lsp_unquant_lbr, - /*No pitch quantization*/ - NULL, - forced_pitch_unquant, - NULL, - /*Innovation quantization*/ - NULL, - split_cb_shape_sign_unquant, - &split_cb_nb_ulbr, -#endif - QCONST16(.5,15), - 79 -}; - -/* 5.95 kbps very low bit-rate mode */ -static const SpeexSubmode nb_submode2 = { - 0, - 0, - 0, - 0, -#ifndef SPEEX_DISABLE_ENCODER - /*LSP quantization*/ - lsp_quant_lbr, - lsp_unquant_lbr, - /*No pitch quantization*/ - pitch_search_3tap, - pitch_unquant_3tap, - <p_params_vlbr, - /*Innovation quantization*/ - split_cb_search_shape_sign, - split_cb_shape_sign_unquant, - &split_cb_nb_vlbr, -#else - /*LSP quantization*/ - NULL, - lsp_unquant_lbr, - /*No pitch quantization*/ - NULL, - pitch_unquant_3tap, - <p_params_vlbr, - /*Innovation quantization*/ - NULL, - split_cb_shape_sign_unquant, - &split_cb_nb_vlbr, -#endif - QCONST16(.6,15), - 119 -}; - -/* 8 kbps low bit-rate mode */ -static const SpeexSubmode nb_submode3 = { - -1, - 0, - 1, - 0, -#ifndef SPEEX_DISABLE_ENCODER - /*LSP quantization*/ - lsp_quant_lbr, - lsp_unquant_lbr, - /*Pitch quantization*/ - pitch_search_3tap, - pitch_unquant_3tap, - <p_params_lbr, - /*Innovation quantization*/ - split_cb_search_shape_sign, - split_cb_shape_sign_unquant, - &split_cb_nb_lbr, -#else - /*LSP quantization*/ - NULL, - lsp_unquant_lbr, - /*Pitch quantization*/ - NULL, - pitch_unquant_3tap, - <p_params_lbr, - /*Innovation quantization*/ - NULL, - split_cb_shape_sign_unquant, - &split_cb_nb_lbr, -#endif - QCONST16(.55,15), - 160 -}; - -/* 11 kbps medium bit-rate mode */ -static const SpeexSubmode nb_submode4 = { - -1, - 0, - 1, - 0, -#ifndef SPEEX_DISABLE_ENCODER - /*LSP quantization*/ - lsp_quant_lbr, - lsp_unquant_lbr, - /*Pitch quantization*/ - pitch_search_3tap, - pitch_unquant_3tap, - <p_params_med, - /*Innovation quantization*/ - split_cb_search_shape_sign, - split_cb_shape_sign_unquant, - &split_cb_nb_med, -#else - /*LSP quantization*/ - NULL, - lsp_unquant_lbr, - /*Pitch quantization*/ - NULL, - pitch_unquant_3tap, - <p_params_med, - /*Innovation quantization*/ - NULL, - split_cb_shape_sign_unquant, - &split_cb_nb_med, -#endif - QCONST16(.45,15), - 220 -}; - -/* 15 kbps high bit-rate mode */ -static const SpeexSubmode nb_submode5 = { - -1, - 0, - 3, - 0, -#ifndef SPEEX_DISABLE_ENCODER - /*LSP quantization*/ - lsp_quant_nb, - lsp_unquant_nb, - /*Pitch quantization*/ - pitch_search_3tap, - pitch_unquant_3tap, - <p_params_nb, - /*Innovation quantization*/ - split_cb_search_shape_sign, - split_cb_shape_sign_unquant, - &split_cb_nb, -#else - /*LSP quantization*/ - NULL, - lsp_unquant_nb, - /*Pitch quantization*/ - NULL, - pitch_unquant_3tap, - <p_params_nb, - /*Innovation quantization*/ - NULL, - split_cb_shape_sign_unquant, - &split_cb_nb, -#endif - QCONST16(.3,15), - 300 -}; - -/* 18.2 high bit-rate mode */ -static const SpeexSubmode nb_submode6 = { - -1, - 0, - 3, - 0, -#ifndef SPEEX_DISABLE_ENCODER - /*LSP quantization*/ - lsp_quant_nb, - lsp_unquant_nb, - /*Pitch quantization*/ - pitch_search_3tap, - pitch_unquant_3tap, - <p_params_nb, - /*Innovation quantization*/ - split_cb_search_shape_sign, - split_cb_shape_sign_unquant, - &split_cb_sb, -#else - /*LSP quantization*/ - NULL, - lsp_unquant_nb, - /*Pitch quantization*/ - NULL, - pitch_unquant_3tap, - <p_params_nb, - /*Innovation quantization*/ - NULL, - split_cb_shape_sign_unquant, - &split_cb_sb, -#endif - QCONST16(.2,15), - 364 -}; - -/* 24.6 kbps high bit-rate mode */ -static const SpeexSubmode nb_submode7 = { - -1, - 0, - 3, - 1, -#ifndef SPEEX_DISABLE_ENCODER - /*LSP quantization*/ - lsp_quant_nb, - lsp_unquant_nb, - /*Pitch quantization*/ - pitch_search_3tap, - pitch_unquant_3tap, - <p_params_nb, - /*Innovation quantization*/ - split_cb_search_shape_sign, - split_cb_shape_sign_unquant, - &split_cb_nb, -#else - /*LSP quantization*/ - NULL, - lsp_unquant_nb, - /*Pitch quantization*/ - NULL, - pitch_unquant_3tap, - <p_params_nb, - /*Innovation quantization*/ - NULL, - split_cb_shape_sign_unquant, - &split_cb_nb, -#endif - QCONST16(.1,15), - 492 -}; - - -/* Default mode for narrowband */ -static const SpeexNBMode nb_mode = { - 160, /*frameSize*/ - 40, /*subframeSize*/ - 10, /*lpcSize*/ - 17, /*pitchStart*/ - 144, /*pitchEnd*/ -#ifdef FIXED_POINT - 29491, 19661, /* gamma1, gamma2 */ -#else - 0.9, 0.6, /* gamma1, gamma2 */ -#endif - QCONST16(.0002,15), /*lpc_floor*/ - {NULL, &nb_submode1, &nb_submode2, &nb_submode3, &nb_submode4, &nb_submode5, &nb_submode6, &nb_submode7, - &nb_submode8, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, - 5, - {1, 8, 2, 3, 3, 4, 4, 5, 5, 6, 7} -}; - - -/* Default mode for narrowband */ -const SpeexMode speex_nb_mode = { - &nb_mode, - nb_mode_query, - "narrowband", - 0, - 4, -#ifndef SPEEX_DISABLE_ENCODER - &nb_encoder_init, - &nb_encoder_destroy, - &nb_encode, - &nb_decoder_init, - &nb_decoder_destroy, - &nb_decode, - &nb_encoder_ctl, - &nb_decoder_ctl, -#else -/* NULL, - NULL, - NULL, */ - &nb_decoder_init, - &nb_decoder_destroy, - &nb_decode, -/* NULL, */ - &nb_decoder_ctl, -#endif -}; - - - -int speex_mode_query(const SpeexMode *mode, int request, void *ptr) -{ - return mode->query(mode->mode, request, ptr); -} - diff --git a/apps/codecs/libspeex/modes.h b/apps/codecs/libspeex/modes.h deleted file mode 100644 index 0fa1c3460e..0000000000 --- a/apps/codecs/libspeex/modes.h +++ /dev/null @@ -1,161 +0,0 @@ -/* Copyright (C) 2002-2006 Jean-Marc Valin */ -/** - @file modes.h - @brief Describes the different modes of the codec -*/ -/* - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of the Xiph.org Foundation nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*/ - -#ifndef MODES_H -#define MODES_H - -#include "speex/speex.h" -#include "speex/speex_bits.h" -#include "arch.h" - -#define NB_SUBMODES 16 -#define NB_SUBMODE_BITS 4 - -#define SB_SUBMODES 8 -#define SB_SUBMODE_BITS 3 - -/* Used internally, NOT TO BE USED in applications */ -/** Used internally*/ -#define SPEEX_GET_PI_GAIN 100 -/** Used internally*/ -#define SPEEX_GET_EXC 101 -/** Used internally*/ -#define SPEEX_GET_INNOV 102 -/** Used internally*/ -#define SPEEX_GET_DTX_STATUS 103 -/** Used internally*/ -#define SPEEX_SET_INNOVATION_SAVE 104 -/** Used internally*/ -#define SPEEX_SET_WIDEBAND 105 - -/** Used internally*/ -#define SPEEX_GET_STACK 106 - - -/** Quantizes LSPs */ -typedef void (*lsp_quant_func)(spx_lsp_t *, spx_lsp_t *, int, SpeexBits *); - -/** Decodes quantized LSPs */ -typedef void (*lsp_unquant_func)(spx_lsp_t *, int, SpeexBits *); - - -/** Long-term predictor quantization */ -typedef int (*ltp_quant_func)(spx_word16_t *, spx_word16_t *, spx_coef_t *, spx_coef_t *, - spx_coef_t *, spx_sig_t *, const void *, int, int, spx_word16_t, - int, int, SpeexBits*, char *, spx_word16_t *, spx_word16_t *, int, int, int, spx_word32_t *); - -/** Long-term un-quantize */ -typedef void (*ltp_unquant_func)(spx_word16_t *, spx_word32_t *, int, int, spx_word16_t, const void *, int, int *, - spx_word16_t *, SpeexBits*, char*, int, int, spx_word16_t, int); - - -/** Innovation quantization function */ -typedef void (*innovation_quant_func)(spx_word16_t *, spx_coef_t *, spx_coef_t *, spx_coef_t *, const void *, int, int, - spx_sig_t *, spx_word16_t *, SpeexBits *, char *, int, int); - -/** Innovation unquantization function */ -typedef void (*innovation_unquant_func)(spx_sig_t *, const void *, int, SpeexBits*, char *, spx_int32_t *); - -/** Description of a Speex sub-mode (wither narrowband or wideband */ -typedef struct SpeexSubmode { - int lbr_pitch; /**< Set to -1 for "normal" modes, otherwise encode pitch using a global pitch and allowing a +- lbr_pitch variation (for low not-rates)*/ - int forced_pitch_gain; /**< Use the same (forced) pitch gain for all sub-frames */ - int have_subframe_gain; /**< Number of bits to use as sub-frame innovation gain */ - int double_codebook; /**< Apply innovation quantization twice for higher quality (and higher bit-rate)*/ - /*LSP functions*/ - lsp_quant_func lsp_quant; /**< LSP quantization function */ - lsp_unquant_func lsp_unquant; /**< LSP unquantization function */ - - /*Long-term predictor functions*/ - ltp_quant_func ltp_quant; /**< Long-term predictor (pitch) quantizer */ - ltp_unquant_func ltp_unquant; /**< Long-term predictor (pitch) un-quantizer */ - const void *ltp_params; /**< Pitch parameters (options) */ - - /*Quantization of innovation*/ - innovation_quant_func innovation_quant; /**< Innovation quantization */ - innovation_unquant_func innovation_unquant; /**< Innovation un-quantization */ - const void *innovation_params; /**< Innovation quantization parameters*/ - - spx_word16_t comb_gain; /**< Gain of enhancer comb filter */ - - int bits_per_frame; /**< Number of bits per frame after encoding*/ -} SpeexSubmode; - -/** Struct defining the encoding/decoding mode*/ -typedef struct SpeexNBMode { - int frameSize; /**< Size of frames used for encoding */ - int subframeSize; /**< Size of sub-frames used for encoding */ - int lpcSize; /**< Order of LPC filter */ - int pitchStart; /**< Smallest pitch value allowed */ - int pitchEnd; /**< Largest pitch value allowed */ - - spx_word16_t gamma1; /**< Perceptual filter parameter #1 */ - spx_word16_t gamma2; /**< Perceptual filter parameter #2 */ - spx_word16_t lpc_floor; /**< Noise floor for LPC analysis */ - - const SpeexSubmode *submodes[NB_SUBMODES]; /**< Sub-mode data for the mode */ - int defaultSubmode; /**< Default sub-mode to use when encoding */ - int quality_map[11]; /**< Mode corresponding to each quality setting */ -} SpeexNBMode; - - -/** Struct defining the encoding/decoding mode for SB-CELP (wideband) */ -typedef struct SpeexSBMode { - const SpeexMode *nb_mode; /**< Embedded narrowband mode */ - int frameSize; /**< Size of frames used for encoding */ - int subframeSize; /**< Size of sub-frames used for encoding */ - int lpcSize; /**< Order of LPC filter */ - spx_word16_t gamma1; /**< Perceptual filter parameter #1 */ - spx_word16_t gamma2; /**< Perceptual filter parameter #1 */ - spx_word16_t lpc_floor; /**< Noise floor for LPC analysis */ - spx_word16_t folding_gain; - - const SpeexSubmode *submodes[SB_SUBMODES]; /**< Sub-mode data for the mode */ - int defaultSubmode; /**< Default sub-mode to use when encoding */ - int low_quality_map[11]; /**< Mode corresponding to each quality setting */ - int quality_map[11]; /**< Mode corresponding to each quality setting */ -#ifndef DISABLE_VBR - const float (*vbr_thresh)[11]; -#endif - int nb_modes; -} SpeexSBMode; - -int speex_encode_native(void *state, spx_word16_t *in, SpeexBits *bits); -int speex_decode_native(void *state, SpeexBits *bits, spx_word16_t *out); - -int nb_mode_query(const void *mode, int request, void *ptr); -int wb_mode_query(const void *mode, int request, void *ptr); - -#endif diff --git a/apps/codecs/libspeex/modes_wb.c b/apps/codecs/libspeex/modes_wb.c deleted file mode 100644 index 93922afa2f..0000000000 --- a/apps/codecs/libspeex/modes_wb.c +++ /dev/null @@ -1,374 +0,0 @@ -/* Copyright (C) 2002-2007 Jean-Marc Valin - File: modes.c - - Describes the wideband modes of the codec - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of the Xiph.org Foundation nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*/ - -#ifdef HAVE_CONFIG_H -#include "config-speex.h" -#endif - -#include "modes.h" -#include "ltp.h" -#include "quant_lsp.h" -#include "cb_search.h" -#include "sb_celp.h" -#include "nb_celp.h" -#include "vbr.h" -#include "arch.h" -#include -#include "os_support.h" - - -#ifndef NULL -#define NULL 0 -#endif - -#ifndef ROCKBOX_VOICE_CODEC -const SpeexMode * const speex_mode_list[SPEEX_NB_MODES] = {&speex_nb_mode, &speex_wb_mode, &speex_uwb_mode}; -#else -const SpeexMode * const speex_mode_list[SPEEX_NB_MODES] = {&speex_nb_mode, &speex_wb_mode, NULL}; -#endif - -extern const signed char hexc_table[]; -extern const signed char hexc_10_32_table[]; - -#ifndef DISABLE_WIDEBAND - -/* Split-VQ innovation for high-band wideband */ -static const split_cb_params split_cb_high = { - 8, /*subvect_size*/ - 5, /*nb_subvect*/ - hexc_table, /*shape_cb*/ - 7, /*shape_bits*/ - 1, -}; - - -/* Split-VQ innovation for high-band wideband */ -static const split_cb_params split_cb_high_lbr = { - 10, /*subvect_size*/ - 4, /*nb_subvect*/ - hexc_10_32_table, /*shape_cb*/ - 5, /*shape_bits*/ - 0, -}; - -#endif - - -static const SpeexSubmode wb_submode1 = { - 0, - 0, - 1, - 0, - /*LSP quantization*/ -#ifndef SPEEX_DISABLE_ENCODER - lsp_quant_high, - lsp_unquant_high, -#else - NULL, - lsp_unquant_high, -#endif - /*Pitch quantization*/ - NULL, - NULL, - NULL, - /*No innovation quantization*/ - NULL, - NULL, - NULL, - -1, - 36 -}; - - -static const SpeexSubmode wb_submode2 = { - 0, - 0, - 1, - 0, -#ifndef SPEEX_DISABLE_ENCODER - /*LSP quantization*/ - lsp_quant_high, - lsp_unquant_high, - /*Pitch quantization*/ - NULL, - NULL, - NULL, - /*Innovation quantization*/ - split_cb_search_shape_sign, - split_cb_shape_sign_unquant, -#else - /*LSP quantization*/ - NULL, - lsp_unquant_high, - /*Pitch quantization*/ - NULL, - NULL, - NULL, - /*Innovation quantization*/ - NULL, - split_cb_shape_sign_unquant, -#endif -#ifdef DISABLE_WIDEBAND - NULL, -#else - &split_cb_high_lbr, -#endif - -1, - 112 -}; - - -static const SpeexSubmode wb_submode3 = { - 0, - 0, - 1, - 0, -#ifndef SPEEX_DISABLE_ENCODER - /*LSP quantization*/ - lsp_quant_high, - lsp_unquant_high, - /*Pitch quantization*/ - NULL, - NULL, - NULL, - /*Innovation quantization*/ - split_cb_search_shape_sign, - split_cb_shape_sign_unquant, -#else - /*LSP quantization*/ - NULL, - lsp_unquant_high, - /*Pitch quantization*/ - NULL, - NULL, - NULL, - /*Innovation quantization*/ - NULL, - split_cb_shape_sign_unquant, -#endif -#ifdef DISABLE_WIDEBAND - NULL, -#else - &split_cb_high, -#endif - -1, - 192 -}; - -static const SpeexSubmode wb_submode4 = { - 0, - 0, - 1, - 1, -#ifndef SPEEX_DISABLE_ENCODER - /*LSP quantization*/ - lsp_quant_high, - lsp_unquant_high, - /*Pitch quantization*/ - NULL, - NULL, - NULL, - /*Innovation quantization*/ - split_cb_search_shape_sign, - split_cb_shape_sign_unquant, -#else - /*LSP quantization*/ - NULL, - lsp_unquant_high, - /*Pitch quantization*/ - NULL, - NULL, - NULL, - /*Innovation quantization*/ - NULL, - split_cb_shape_sign_unquant, -#endif -#ifdef DISABLE_WIDEBAND - NULL, -#else - &split_cb_high, -#endif - -1, - 352 -}; - - -/* Split-band wideband CELP mode*/ -static const SpeexSBMode sb_wb_mode = { - &speex_nb_mode, - 160, /*frameSize*/ - 40, /*subframeSize*/ - 8, /*lpcSize*/ -#ifdef FIXED_POINT - 29491, 19661, /* gamma1, gamma2 */ -#else - 0.9, 0.6, /* gamma1, gamma2 */ -#endif - QCONST16(.0002,15), /*lpc_floor*/ - QCONST16(0.9f,15), - {NULL, &wb_submode1, &wb_submode2, &wb_submode3, &wb_submode4, NULL, NULL, NULL}, - 3, - {1, 8, 2, 3, 4, 5, 5, 6, 6, 7, 7}, - {1, 1, 1, 1, 1, 1, 2, 2, 3, 3, 4}, -#ifndef DISABLE_VBR - vbr_hb_thresh, -#endif - 5 -}; - - -const SpeexMode speex_wb_mode = { - &sb_wb_mode, - wb_mode_query, - "wideband (sub-band CELP)", - 1, - 4, -#ifndef SPEEX_DISABLE_ENCODER - &sb_encoder_init, - &sb_encoder_destroy, - &sb_encode, - &sb_decoder_init, - &sb_decoder_destroy, - &sb_decode, - &sb_encoder_ctl, - &sb_decoder_ctl, -#else -/* NULL, - NULL, - NULL, */ - &sb_decoder_init, - &sb_decoder_destroy, - &sb_decode, -/* NULL, */ - &sb_decoder_ctl, -#endif -}; - - - -/* "Ultra-wideband" mode stuff */ - - - -#ifndef ROCKBOX_VOICE_CODEC -/* Split-band "ultra-wideband" (32 kbps) CELP mode*/ -static const SpeexSBMode sb_uwb_mode = { - &speex_wb_mode, - 320, /*frameSize*/ - 80, /*subframeSize*/ - 8, /*lpcSize*/ -#ifdef FIXED_POINT - 29491, 19661, /* gamma1, gamma2 */ -#else - 0.9, 0.6, /* gamma1, gamma2 */ -#endif - QCONST16(.0002,15), /*lpc_floor*/ - QCONST16(0.7f,15), - {NULL, &wb_submode1, NULL, NULL, NULL, NULL, NULL, NULL}, - 1, - {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, - {0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, -#ifndef DISABLE_VBR - vbr_uhb_thresh, -#endif - 2 -}; -#endif - -int wb_mode_query(const void *mode, int request, void *ptr) -{ - const SpeexSBMode *m = (const SpeexSBMode*)mode; - - switch (request) - { - case SPEEX_MODE_FRAME_SIZE: - *((int*)ptr)=2*m->frameSize; - break; - case SPEEX_SUBMODE_BITS_PER_FRAME: - if (*((int*)ptr)==0) - *((int*)ptr) = SB_SUBMODE_BITS+1; - else if (m->submodes[*((int*)ptr)]==NULL) - *((int*)ptr) = -1; - else - *((int*)ptr) = m->submodes[*((int*)ptr)]->bits_per_frame; - break; - default: - speex_warning_int("Unknown wb_mode_query request: ", request); - return -1; - } - return 0; -} - - -#ifndef ROCKBOX_VOICE_CODEC -const SpeexMode speex_uwb_mode = { - &sb_uwb_mode, - wb_mode_query, - "ultra-wideband (sub-band CELP)", - 2, - 4, -#ifndef SPEEX_DISABLE_ENCODER - &sb_encoder_init, - &sb_encoder_destroy, - &sb_encode, - &sb_decoder_init, - &sb_decoder_destroy, - &sb_decode, - &sb_encoder_ctl, - &sb_decoder_ctl, -#else -/* NULL, - NULL, - NULL, */ - &sb_decoder_init, - &sb_decoder_destroy, - &sb_decode, -/* NULL, */ - &sb_decoder_ctl, -#endif -}; -#endif - -/* We have defined speex_lib_get_mode() as a macro in speex.h */ -#undef speex_lib_get_mode - -const SpeexMode * speex_lib_get_mode (int mode) -{ - if (mode < 0 || mode >= SPEEX_NB_MODES) return NULL; - - return speex_mode_list[mode]; -} - - - diff --git a/apps/codecs/libspeex/nb_celp.c b/apps/codecs/libspeex/nb_celp.c deleted file mode 100644 index 364f987472..0000000000 --- a/apps/codecs/libspeex/nb_celp.c +++ /dev/null @@ -1,1917 +0,0 @@ -/* Copyright (C) 2002-2006 Jean-Marc Valin - File: nb_celp.c - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of the Xiph.org Foundation nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifdef HAVE_CONFIG_H -#include "config-speex.h" -#endif - -#include -#include "nb_celp.h" -#include "lpc.h" -#include "lsp.h" -#include "ltp.h" -#include "quant_lsp.h" -#include "cb_search.h" -#include "filters.h" -#include "stack_alloc.h" -#include "vq.h" -#include "speex/speex_bits.h" -#include "vbr.h" -#include "arch.h" -#include "math_approx.h" -#include "os_support.h" -#include "speex/speex_callbacks.h" - -#ifdef VORBIS_PSYCHO -#include "vorbis_psy.h" -#endif - -#ifndef M_PI -#define M_PI 3.14159265358979323846 /* pi */ -#endif - -#ifndef NULL -#define NULL 0 -#endif - -#define SUBMODE(x) st->submodes[st->submodeID]->x - -/* Default size for the encoder and decoder stack (can be changed at compile time). - This does not apply when using variable-size arrays or alloca. */ -#ifndef NB_ENC_STACK -#define NB_ENC_STACK (8000*sizeof(spx_sig_t)) -#endif - -#ifndef NB_DEC_STACK -#define NB_DEC_STACK (4000*sizeof(spx_sig_t)) -#endif - - -#ifdef FIXED_POINT -const spx_word32_t ol_gain_table[32] ICONST_ATTR = {18900, 25150, 33468, 44536, 59265, 78865, 104946, 139653, 185838, 247297, 329081, 437913, 582736, 775454, 1031906, 1373169, 1827293, 2431601, 3235761, 4305867, 5729870, 7624808, 10146425, 13501971, 17967238, 23909222, 31816294, 42338330, 56340132, 74972501, 99766822, 132760927}; -const spx_word16_t exc_gain_quant_scal3_bound[7] ICONST_ATTR = {1841, 3883, 6051, 8062, 10444, 13580, 18560}; -const spx_word16_t exc_gain_quant_scal3[8] ICONST_ATTR = {1002, 2680, 5086, 7016, 9108, 11781, 15380, 21740}; -const spx_word16_t exc_gain_quant_scal1_bound[1] ICONST_ATTR = {14385}; -const spx_word16_t exc_gain_quant_scal1[2] ICONST_ATTR = {11546, 17224}; - -#define LSP_MARGIN 16 -#define LSP_DELTA1 6553 -#define LSP_DELTA2 1638 - -#else - -const float exc_gain_quant_scal3_bound[7]={0.112338f, 0.236980f, 0.369316f, 0.492054f, 0.637471f, 0.828874f, 1.132784f}; -const float exc_gain_quant_scal3[8]={0.061130f, 0.163546f, 0.310413f, 0.428220f, 0.555887f, 0.719055f, 0.938694f, 1.326874f}; -const float exc_gain_quant_scal1_bound[1]={0.87798f}; -const float exc_gain_quant_scal1[2]={0.70469f, 1.05127f}; - -#define LSP_MARGIN .002f -#define LSP_DELTA1 .2f -#define LSP_DELTA2 .05f - -#endif - -#ifdef VORBIS_PSYCHO -#define EXTRA_BUFFER 100 -#else -#define EXTRA_BUFFER 0 -#endif - - -#define sqr(x) ((x)*(x)) - -extern const spx_word16_t lag_window[]; -extern const spx_word16_t lpc_window[]; - -#ifndef SPEEX_DISABLE_ENCODER -void *nb_encoder_init(const SpeexMode *m) -{ - EncState *st; - const SpeexNBMode *mode; - int i; - - mode=(const SpeexNBMode *)m->mode; - st = (EncState*)speex_alloc(sizeof(EncState)); - if (!st) - return NULL; -#if defined(VAR_ARRAYS) || defined (USE_ALLOCA) - st->stack = NULL; -#else - st->stack = (char*)speex_alloc_scratch(NB_ENC_STACK); -#endif - - st->mode=m; - - st->frameSize = mode->frameSize; - st->nbSubframes=mode->frameSize/mode->subframeSize; - st->subframeSize=mode->subframeSize; - st->windowSize = st->frameSize+st->subframeSize; - st->lpcSize = mode->lpcSize; - st->gamma1=mode->gamma1; - st->gamma2=mode->gamma2; - st->min_pitch=mode->pitchStart; - st->max_pitch=mode->pitchEnd; - st->lpc_floor = mode->lpc_floor; - - st->submodes=mode->submodes; - st->submodeID=st->submodeSelect=mode->defaultSubmode; - st->bounded_pitch = 1; - - st->encode_submode = 1; - -#ifdef VORBIS_PSYCHO - st->psy = vorbis_psy_init(8000, 256); - st->curve = (float*)speex_alloc(128*sizeof(float)); - st->old_curve = (float*)speex_alloc(128*sizeof(float)); - st->psy_window = (float*)speex_alloc(256*sizeof(float)); -#endif - - st->cumul_gain = 1024; - - /* Allocating input buffer */ - st->winBuf = (spx_word16_t*)speex_alloc((st->windowSize-st->frameSize)*sizeof(spx_word16_t)); - /* Allocating excitation buffer */ - st->excBuf = (spx_word16_t*)speex_alloc((mode->frameSize+mode->pitchEnd+2)*sizeof(spx_word16_t)); - st->exc = st->excBuf + mode->pitchEnd + 2; - st->swBuf = (spx_word16_t*)speex_alloc((mode->frameSize+mode->pitchEnd+2)*sizeof(spx_word16_t)); - st->sw = st->swBuf + mode->pitchEnd + 2; - - st->window= lpc_window; - - /* Create the window for autocorrelation (lag-windowing) */ - st->lagWindow = lag_window; - - st->old_lsp = (spx_lsp_t*)speex_alloc((st->lpcSize)*sizeof(spx_lsp_t)); - st->old_qlsp = (spx_lsp_t*)speex_alloc((st->lpcSize)*sizeof(spx_lsp_t)); - st->first = 1; - for (i=0;ilpcSize;i++) - st->old_lsp[i]= DIV32(MULT16_16(QCONST16(3.1415927f, LSP_SHIFT), i+1), st->lpcSize+1); - - st->mem_sp = (spx_mem_t*)speex_alloc((st->lpcSize)*sizeof(spx_mem_t)); - st->mem_sw = (spx_mem_t*)speex_alloc((st->lpcSize)*sizeof(spx_mem_t)); - st->mem_sw_whole = (spx_mem_t*)speex_alloc((st->lpcSize)*sizeof(spx_mem_t)); - st->mem_exc = (spx_mem_t*)speex_alloc((st->lpcSize)*sizeof(spx_mem_t)); - st->mem_exc2 = (spx_mem_t*)speex_alloc((st->lpcSize)*sizeof(spx_mem_t)); - - st->pi_gain = (spx_word32_t*)speex_alloc((st->nbSubframes)*sizeof(spx_word32_t)); - st->innov_rms_save = NULL; - - st->pitch = (int*)speex_alloc((st->nbSubframes)*sizeof(int)); - -#ifndef DISABLE_VBR - st->vbr = (VBRState*)speex_alloc(sizeof(VBRState)); - vbr_init(st->vbr); - st->vbr_quality = 8; - st->vbr_enabled = 0; - st->vbr_max = 0; - st->vad_enabled = 0; - st->dtx_enabled = 0; - st->dtx_count=0; - st->abr_enabled = 0; - st->abr_drift = 0; - st->abr_drift2 = 0; -#endif /* #ifndef DISABLE_VBR */ - - st->plc_tuning = 2; - st->complexity=2; - st->sampling_rate=8000; - st->isWideband = 0; - st->highpass_enabled = 1; - -#ifdef ENABLE_VALGRIND - VALGRIND_MAKE_READABLE(st, NB_ENC_STACK); -#endif - return st; -} - -void nb_encoder_destroy(void *state) -{ - EncState *st=(EncState *)state; - /* Free all allocated memory */ -#if !(defined(VAR_ARRAYS) || defined (USE_ALLOCA)) - speex_free_scratch(st->stack); -#endif - - speex_free (st->winBuf); - speex_free (st->excBuf); - speex_free (st->old_qlsp); - speex_free (st->swBuf); - - speex_free (st->old_lsp); - speex_free (st->mem_sp); - speex_free (st->mem_sw); - speex_free (st->mem_sw_whole); - speex_free (st->mem_exc); - speex_free (st->mem_exc2); - speex_free (st->pi_gain); - speex_free (st->pitch); - -#ifndef DISABLE_VBR - vbr_destroy(st->vbr); - speex_free (st->vbr); -#endif /* #ifndef DISABLE_VBR */ - -#ifdef VORBIS_PSYCHO - vorbis_psy_destroy(st->psy); - speex_free (st->curve); - speex_free (st->old_curve); - speex_free (st->psy_window); -#endif - - /*Free state memory... should be last*/ - speex_free(st); -} - -int nb_encode(void *state, void *vin, SpeexBits *bits) -{ - EncState *st; - int i, sub, roots; - int ol_pitch; - spx_word16_t ol_pitch_coef; - spx_word32_t ol_gain; - VARDECL(spx_word16_t *ringing); - VARDECL(spx_word16_t *target); - VARDECL(spx_sig_t *innov); - VARDECL(spx_word32_t *exc32); - VARDECL(spx_mem_t *mem); - VARDECL(spx_coef_t *bw_lpc1); - VARDECL(spx_coef_t *bw_lpc2); - VARDECL(spx_coef_t *lpc); - VARDECL(spx_lsp_t *lsp); - VARDECL(spx_lsp_t *qlsp); - VARDECL(spx_lsp_t *interp_lsp); - VARDECL(spx_lsp_t *interp_qlsp); - VARDECL(spx_coef_t *interp_lpc); - VARDECL(spx_coef_t *interp_qlpc); - char *stack; - VARDECL(spx_word16_t *syn_resp); - VARDECL(spx_word16_t *real_exc); - - spx_word32_t ener=0; - spx_word16_t fine_gain; - spx_word16_t *in = (spx_word16_t*)vin; - - st=(EncState *)state; - stack=st->stack; - - ALLOC(lpc, st->lpcSize, spx_coef_t); - ALLOC(bw_lpc1, st->lpcSize, spx_coef_t); - ALLOC(bw_lpc2, st->lpcSize, spx_coef_t); - ALLOC(lsp, st->lpcSize, spx_lsp_t); - ALLOC(qlsp, st->lpcSize, spx_lsp_t); - ALLOC(interp_lsp, st->lpcSize, spx_lsp_t); - ALLOC(interp_qlsp, st->lpcSize, spx_lsp_t); - ALLOC(interp_lpc, st->lpcSize, spx_coef_t); - ALLOC(interp_qlpc, st->lpcSize, spx_coef_t); - - /* Move signals 1 frame towards the past */ - SPEEX_MOVE(st->excBuf, st->excBuf+st->frameSize, st->max_pitch+2); - SPEEX_MOVE(st->swBuf, st->swBuf+st->frameSize, st->max_pitch+2); - - if (st->highpass_enabled) - highpass(in, in, st->frameSize, (st->isWideband?HIGHPASS_WIDEBAND:HIGHPASS_NARROWBAND)|HIGHPASS_INPUT, st->mem_hp); - - { - VARDECL(spx_word16_t *w_sig); - VARDECL(spx_word16_t *autocorr); - ALLOC(w_sig, st->windowSize, spx_word16_t); - ALLOC(autocorr, st->lpcSize+1, spx_word16_t); - /* Window for analysis */ - for (i=0;iwindowSize-st->frameSize;i++) - w_sig[i] = EXTRACT16(SHR32(MULT16_16(st->winBuf[i],st->window[i]),SIG_SHIFT)); - for (;iwindowSize;i++) - w_sig[i] = EXTRACT16(SHR32(MULT16_16(in[i-st->windowSize+st->frameSize],st->window[i]),SIG_SHIFT)); - /* Compute auto-correlation */ - _spx_autocorr(w_sig, autocorr, st->lpcSize+1, st->windowSize); - autocorr[0] = ADD16(autocorr[0],MULT16_16_Q15(autocorr[0],st->lpc_floor)); /* Noise floor in auto-correlation domain */ - - /* Lag windowing: equivalent to filtering in the power-spectrum domain */ - for (i=0;ilpcSize+1;i++) - autocorr[i] = MULT16_16_Q14(autocorr[i],st->lagWindow[i]); - - /* Levinson-Durbin */ - _spx_lpc(lpc, autocorr, st->lpcSize); - /* LPC to LSPs (x-domain) transform */ - roots=lpc_to_lsp (lpc, st->lpcSize, lsp, 10, LSP_DELTA1, stack); - /* Check if we found all the roots */ - if (roots!=st->lpcSize) - { - /*If we can't find all LSP's, do some damage control and use previous filter*/ - for (i=0;ilpcSize;i++) - { - lsp[i]=st->old_lsp[i]; - } - } - } - - - - - /* Whole frame analysis (open-loop estimation of pitch and excitation gain) */ - { - int diff = st->windowSize-st->frameSize; - if (st->first) - for (i=0;ilpcSize;i++) - interp_lsp[i] = lsp[i]; - else - lsp_interpolate(st->old_lsp, lsp, interp_lsp, st->lpcSize, st->nbSubframes, st->nbSubframes<<1); - - lsp_enforce_margin(interp_lsp, st->lpcSize, LSP_MARGIN); - - /* Compute interpolated LPCs (unquantized) for whole frame*/ - lsp_to_lpc(interp_lsp, interp_lpc, st->lpcSize,stack); - - - /*Open-loop pitch*/ - if (!st->submodes[st->submodeID] || (st->complexity>2 && SUBMODE(have_subframe_gain)<3) || SUBMODE(forced_pitch_gain) || SUBMODE(lbr_pitch) != -1 -#ifndef DISABLE_VBR - || st->vbr_enabled || st->vad_enabled -#endif - ) - { - int nol_pitch[6]; - spx_word16_t nol_pitch_coef[6]; - - bw_lpc(st->gamma1, interp_lpc, bw_lpc1, st->lpcSize); - bw_lpc(st->gamma2, interp_lpc, bw_lpc2, st->lpcSize); - - SPEEX_COPY(st->sw, st->winBuf, diff); - SPEEX_COPY(st->sw+diff, in, st->frameSize-diff); - filter_mem16(st->sw, bw_lpc1, bw_lpc2, st->sw, st->frameSize, st->lpcSize, st->mem_sw_whole, stack); - - open_loop_nbest_pitch(st->sw, st->min_pitch, st->max_pitch, st->frameSize, - nol_pitch, nol_pitch_coef, 6, stack); - ol_pitch=nol_pitch[0]; - ol_pitch_coef = nol_pitch_coef[0]; - /*Try to remove pitch multiples*/ - for (i=1;i<6;i++) - { -#ifdef FIXED_POINT - if ((nol_pitch_coef[i]>MULT16_16_Q15(nol_pitch_coef[0],27853)) && -#else - if ((nol_pitch_coef[i]>.85*nol_pitch_coef[0]) && -#endif - (ABS(2*nol_pitch[i]-ol_pitch)<=2 || ABS(3*nol_pitch[i]-ol_pitch)<=3 || - ABS(4*nol_pitch[i]-ol_pitch)<=4 || ABS(5*nol_pitch[i]-ol_pitch)<=5)) - { - /*ol_pitch_coef=nol_pitch_coef[i];*/ - ol_pitch = nol_pitch[i]; - } - } - /*if (ol_pitch>50) - ol_pitch/=2;*/ - /*ol_pitch_coef = sqrt(ol_pitch_coef);*/ - - } else { - ol_pitch=0; - ol_pitch_coef=0; - } - - /*Compute "real" excitation*/ - SPEEX_COPY(st->exc, st->winBuf, diff); - SPEEX_COPY(st->exc+diff, in, st->frameSize-diff); - fir_mem16(st->exc, interp_lpc, st->exc, st->frameSize, st->lpcSize, st->mem_exc, stack); - - /* Compute open-loop excitation gain */ - { - spx_word16_t g = compute_rms16(st->exc, st->frameSize); - if (st->submodeID!=1 && ol_pitch>0) - ol_gain = MULT16_16(g, MULT16_16_Q14(QCONST16(1.1,14), - spx_sqrt(QCONST32(1.,28)-MULT16_32_Q15(QCONST16(.8,15),SHL32(MULT16_16(ol_pitch_coef,ol_pitch_coef),16))))); - else - ol_gain = SHL32(EXTEND32(g),SIG_SHIFT); - } - } - -#ifdef VORBIS_PSYCHO - SPEEX_MOVE(st->psy_window, st->psy_window+st->frameSize, 256-st->frameSize); - SPEEX_COPY(&st->psy_window[256-st->frameSize], in, st->frameSize); - compute_curve(st->psy, st->psy_window, st->curve); - /*print_vec(st->curve, 128, "curve");*/ - if (st->first) - SPEEX_COPY(st->old_curve, st->curve, 128); -#endif - - /*VBR stuff*/ -#ifndef DISABLE_VBR - if (st->vbr && (st->vbr_enabled||st->vad_enabled)) - { - float lsp_dist=0; - for (i=0;ilpcSize;i++) - lsp_dist += (st->old_lsp[i] - lsp[i])*(st->old_lsp[i] - lsp[i]); - lsp_dist /= LSP_SCALING*LSP_SCALING; - - if (st->abr_enabled) - { - float qual_change=0; - if (st->abr_drift2 * st->abr_drift > 0) - { - /* Only adapt if long-term and short-term drift are the same sign */ - qual_change = -.00001*st->abr_drift/(1+st->abr_count); - if (qual_change>.05) - qual_change=.05; - if (qual_change<-.05) - qual_change=-.05; - } - st->vbr_quality += qual_change; - if (st->vbr_quality>10) - st->vbr_quality=10; - if (st->vbr_quality<0) - st->vbr_quality=0; - } - - st->relative_quality = vbr_analysis(st->vbr, in, st->frameSize, ol_pitch, GAIN_SCALING_1*ol_pitch_coef); - /*if (delta_qual<0)*/ - /* delta_qual*=.1*(3+st->vbr_quality);*/ - if (st->vbr_enabled) - { - spx_int32_t mode; - int choice=0; - float min_diff=100; - mode = 8; - while (mode) - { - int v1; - float thresh; - v1=(int)floor(st->vbr_quality); - if (v1==10) - thresh = vbr_nb_thresh[mode][v1]; - else - thresh = (st->vbr_quality-v1)*vbr_nb_thresh[mode][v1+1] + (1+v1-st->vbr_quality)*vbr_nb_thresh[mode][v1]; - if (st->relative_quality > thresh && - st->relative_quality-threshrelative_quality-thresh; - } - mode--; - } - mode=choice; - if (mode==0) - { - if (st->dtx_count==0 || lsp_dist>.05 || !st->dtx_enabled || st->dtx_count>20) - { - mode=1; - st->dtx_count=1; - } else { - mode=0; - st->dtx_count++; - } - } else { - st->dtx_count=0; - } - - speex_encoder_ctl(state, SPEEX_SET_MODE, &mode); - if (st->vbr_max>0) - { - spx_int32_t rate; - speex_encoder_ctl(state, SPEEX_GET_BITRATE, &rate); - if (rate > st->vbr_max) - { - rate = st->vbr_max; - speex_encoder_ctl(state, SPEEX_SET_BITRATE, &rate); - } - } - - if (st->abr_enabled) - { - spx_int32_t bitrate; - speex_encoder_ctl(state, SPEEX_GET_BITRATE, &bitrate); - st->abr_drift+=(bitrate-st->abr_enabled); - st->abr_drift2 = .95*st->abr_drift2 + .05*(bitrate-st->abr_enabled); - st->abr_count += 1.0; - } - - } else { - /*VAD only case*/ - int mode; - if (st->relative_quality<2) - { - if (st->dtx_count==0 || lsp_dist>.05 || !st->dtx_enabled || st->dtx_count>20) - { - st->dtx_count=1; - mode=1; - } else { - mode=0; - st->dtx_count++; - } - } else { - st->dtx_count = 0; - mode=st->submodeSelect; - } - /*speex_encoder_ctl(state, SPEEX_SET_MODE, &mode);*/ - st->submodeID=mode; - } - } else { - st->relative_quality = -1; - } -#endif /* #ifndef DISABLE_VBR */ - - if (st->encode_submode) - { - /* First, transmit a zero for narrowband */ - speex_bits_pack(bits, 0, 1); - - /* Transmit the sub-mode we use for this frame */ - speex_bits_pack(bits, st->submodeID, NB_SUBMODE_BITS); - - } - - /* If null mode (no transmission), just set a couple things to zero*/ - if (st->submodes[st->submodeID] == NULL) - { - for (i=0;iframeSize;i++) - st->exc[i]=st->sw[i]=VERY_SMALL; - - for (i=0;ilpcSize;i++) - st->mem_sw[i]=0; - st->first=1; - st->bounded_pitch = 1; - - SPEEX_COPY(st->winBuf, in+2*st->frameSize-st->windowSize, st->windowSize-st->frameSize); - - /* Clear memory (no need to really compute it) */ - for (i=0;ilpcSize;i++) - st->mem_sp[i] = 0; - return 0; - - } - - /* LSP Quantization */ - if (st->first) - { - for (i=0;ilpcSize;i++) - st->old_lsp[i] = lsp[i]; - } - - - /*Quantize LSPs*/ -#if 1 /*0 for unquantized*/ - SUBMODE(lsp_quant)(lsp, qlsp, st->lpcSize, bits); -#else - for (i=0;ilpcSize;i++) - qlsp[i]=lsp[i]; -#endif - - /*If we use low bit-rate pitch mode, transmit open-loop pitch*/ - if (SUBMODE(lbr_pitch)!=-1) - { - speex_bits_pack(bits, ol_pitch-st->min_pitch, 7); - } - - if (SUBMODE(forced_pitch_gain)) - { - int quant; - /* This just damps the pitch a bit, because it tends to be too aggressive when forced */ - ol_pitch_coef = MULT16_16_Q15(QCONST16(.9,15), ol_pitch_coef); -#ifdef FIXED_POINT - quant = PSHR16(MULT16_16_16(15, ol_pitch_coef),GAIN_SHIFT); -#else - quant = (int)floor(.5+15*ol_pitch_coef*GAIN_SCALING_1); -#endif - if (quant>15) - quant=15; - if (quant<0) - quant=0; - speex_bits_pack(bits, quant, 4); - ol_pitch_coef=MULT16_16_P15(QCONST16(0.066667,15),SHL16(quant,GAIN_SHIFT)); - } - - - /*Quantize and transmit open-loop excitation gain*/ -#ifdef FIXED_POINT - { - int qe = scal_quant32(ol_gain, ol_gain_table, 32); - /*ol_gain = exp(qe/3.5)*SIG_SCALING;*/ - ol_gain = MULT16_32_Q15(28406,ol_gain_table[qe]); - speex_bits_pack(bits, qe, 5); - } -#else - { - int qe = (int)(floor(.5+3.5*log(ol_gain*1.0/SIG_SCALING))); - if (qe<0) - qe=0; - if (qe>31) - qe=31; - ol_gain = exp(qe/3.5)*SIG_SCALING; - speex_bits_pack(bits, qe, 5); - } -#endif - - - - /* Special case for first frame */ - if (st->first) - { - for (i=0;ilpcSize;i++) - st->old_qlsp[i] = qlsp[i]; - } - - /* Target signal */ - ALLOC(target, st->subframeSize, spx_word16_t); - ALLOC(innov, st->subframeSize, spx_sig_t); - ALLOC(exc32, st->subframeSize, spx_word32_t); - ALLOC(ringing, st->subframeSize, spx_word16_t); - ALLOC(syn_resp, st->subframeSize, spx_word16_t); - ALLOC(real_exc, st->subframeSize, spx_word16_t); - ALLOC(mem, st->lpcSize, spx_mem_t); - - /* Loop on sub-frames */ - for (sub=0;subnbSubframes;sub++) - { - int offset; - spx_word16_t *sw; - spx_word16_t *exc; - int pitch; - int response_bound = st->subframeSize; - - /* Offset relative to start of frame */ - offset = st->subframeSize*sub; - /* Excitation */ - exc=st->exc+offset; - /* Weighted signal */ - sw=st->sw+offset; - - /* LSP interpolation (quantized and unquantized) */ - lsp_interpolate(st->old_lsp, lsp, interp_lsp, st->lpcSize, sub, st->nbSubframes); - lsp_interpolate(st->old_qlsp, qlsp, interp_qlsp, st->lpcSize, sub, st->nbSubframes); - - /* Make sure the filters are stable */ - lsp_enforce_margin(interp_lsp, st->lpcSize, LSP_MARGIN); - lsp_enforce_margin(interp_qlsp, st->lpcSize, LSP_MARGIN); - - /* Compute interpolated LPCs (quantized and unquantized) */ - lsp_to_lpc(interp_lsp, interp_lpc, st->lpcSize,stack); - - lsp_to_lpc(interp_qlsp, interp_qlpc, st->lpcSize, stack); - - /* Compute analysis filter gain at w=pi (for use in SB-CELP) */ - { - spx_word32_t pi_g=LPC_SCALING; - for (i=0;ilpcSize;i+=2) - { - /*pi_g += -st->interp_qlpc[i] + st->interp_qlpc[i+1];*/ - pi_g = ADD32(pi_g, SUB32(EXTEND32(interp_qlpc[i+1]),EXTEND32(interp_qlpc[i]))); - } - st->pi_gain[sub] = pi_g; - } - -#ifdef VORBIS_PSYCHO - { - float curr_curve[128]; - float fact = ((float)sub+1.0f)/st->nbSubframes; - for (i=0;i<128;i++) - curr_curve[i] = (1.0f-fact)*st->old_curve[i] + fact*st->curve[i]; - curve_to_lpc(st->psy, curr_curve, bw_lpc1, bw_lpc2, 10); - } -#else - /* Compute bandwidth-expanded (unquantized) LPCs for perceptual weighting */ - bw_lpc(st->gamma1, interp_lpc, bw_lpc1, st->lpcSize); - if (st->gamma2>=0) - bw_lpc(st->gamma2, interp_lpc, bw_lpc2, st->lpcSize); - else - { - for (i=0;ilpcSize;i++) - bw_lpc2[i]=0; - } - /*print_vec(st->bw_lpc1, 10, "bw_lpc");*/ -#endif - - /*FIXME: This will break if we change the window size */ - speex_assert(st->windowSize-st->frameSize == st->subframeSize); - if (sub==0) - { - for (i=0;isubframeSize;i++) - real_exc[i] = sw[i] = st->winBuf[i]; - } else { - for (i=0;isubframeSize;i++) - real_exc[i] = sw[i] = in[i+((sub-1)*st->subframeSize)]; - } - fir_mem16(real_exc, interp_qlpc, real_exc, st->subframeSize, st->lpcSize, st->mem_exc2, stack); - - if (st->complexity==0) - response_bound >>= 1; - compute_impulse_response(interp_qlpc, bw_lpc1, bw_lpc2, syn_resp, response_bound, st->lpcSize, stack); - for (i=response_bound;isubframeSize;i++) - syn_resp[i]=VERY_SMALL; - - /* Compute zero response of A(z/g1) / ( A(z/g2) * A(z) ) */ - for (i=0;ilpcSize;i++) - mem[i]=SHL32(st->mem_sp[i],1); - for (i=0;isubframeSize;i++) - ringing[i] = VERY_SMALL; -#ifdef SHORTCUTS2 - iir_mem16(ringing, interp_qlpc, ringing, response_bound, st->lpcSize, mem, stack); - for (i=0;ilpcSize;i++) - mem[i]=SHL32(st->mem_sw[i],1); - filter_mem16(ringing, st->bw_lpc1, st->bw_lpc2, ringing, response_bound, st->lpcSize, mem, stack); - SPEEX_MEMSET(&ringing[response_bound], 0, st->subframeSize-response_bound); -#else - iir_mem16(ringing, interp_qlpc, ringing, st->subframeSize, st->lpcSize, mem, stack); - for (i=0;ilpcSize;i++) - mem[i]=SHL32(st->mem_sw[i],1); - filter_mem16(ringing, bw_lpc1, bw_lpc2, ringing, st->subframeSize, st->lpcSize, mem, stack); -#endif - - /* Compute weighted signal */ - for (i=0;ilpcSize;i++) - mem[i]=st->mem_sw[i]; - filter_mem16(sw, bw_lpc1, bw_lpc2, sw, st->subframeSize, st->lpcSize, mem, stack); - - if (st->complexity==0) - for (i=0;ilpcSize;i++) - st->mem_sw[i]=mem[i]; - - /* Compute target signal (saturation prevents overflows on clipped input speech) */ - for (i=0;isubframeSize;i++) - target[i]=EXTRACT16(SATURATE(SUB32(sw[i],PSHR32(ringing[i],1)),32767)); - - /* Reset excitation */ - SPEEX_MEMSET(exc, 0, st->subframeSize); - - /* If we have a long-term predictor (otherwise, something's wrong) */ - speex_assert (SUBMODE(ltp_quant)); - { - int pit_min, pit_max; - /* Long-term prediction */ - if (SUBMODE(lbr_pitch) != -1) - { - /* Low bit-rate pitch handling */ - int margin; - margin = SUBMODE(lbr_pitch); - if (margin) - { - if (ol_pitch < st->min_pitch+margin-1) - ol_pitch=st->min_pitch+margin-1; - if (ol_pitch > st->max_pitch-margin) - ol_pitch=st->max_pitch-margin; - pit_min = ol_pitch-margin+1; - pit_max = ol_pitch+margin; - } else { - pit_min=pit_max=ol_pitch; - } - } else { - pit_min = st->min_pitch; - pit_max = st->max_pitch; - } - - /* Force pitch to use only the current frame if needed */ - if (st->bounded_pitch && pit_max>offset) - pit_max=offset; - - /* Perform pitch search */ - pitch = SUBMODE(ltp_quant)(target, sw, interp_qlpc, bw_lpc1, bw_lpc2, - exc32, SUBMODE(ltp_params), pit_min, pit_max, ol_pitch_coef, - st->lpcSize, st->subframeSize, bits, stack, - exc, syn_resp, st->complexity, 0, st->plc_tuning, &st->cumul_gain); - - st->pitch[sub]=pitch; - } - /* Quantization of innovation */ - SPEEX_MEMSET(innov, 0, st->subframeSize); - - /* FIXME: Make sure this is save from overflows (so far so good) */ - for (i=0;isubframeSize;i++) - real_exc[i] = EXTRACT16(SUB32(EXTEND32(real_exc[i]), PSHR32(exc32[i],SIG_SHIFT-1))); - - ener = SHL32(EXTEND32(compute_rms16(real_exc, st->subframeSize)),SIG_SHIFT); - - /*FIXME: Should use DIV32_16 and make sure result fits in 16 bits */ -#ifdef FIXED_POINT - { - spx_word32_t f = PDIV32(ener,PSHR32(ol_gain,SIG_SHIFT)); - if (f<=32767) - fine_gain = f; - else - fine_gain = 32767; - } -#else - fine_gain = PDIV32_16(ener,PSHR32(ol_gain,SIG_SHIFT)); -#endif - /* Calculate gain correction for the sub-frame (if any) */ - if (SUBMODE(have_subframe_gain)) - { - int qe; - if (SUBMODE(have_subframe_gain)==3) - { - qe = scal_quant(fine_gain, exc_gain_quant_scal3_bound, 8); - speex_bits_pack(bits, qe, 3); - ener=MULT16_32_Q14(exc_gain_quant_scal3[qe],ol_gain); - } else { - qe = scal_quant(fine_gain, exc_gain_quant_scal1_bound, 2); - speex_bits_pack(bits, qe, 1); - ener=MULT16_32_Q14(exc_gain_quant_scal1[qe],ol_gain); - } - } else { - ener=ol_gain; - } - - /*printf ("%f %f\n", ener, ol_gain);*/ - - /* Normalize innovation */ - signal_div(target, target, ener, st->subframeSize); - - /* Quantize innovation */ - speex_assert (SUBMODE(innovation_quant)); - { - /* Codebook search */ - SUBMODE(innovation_quant)(target, interp_qlpc, bw_lpc1, bw_lpc2, - SUBMODE(innovation_params), st->lpcSize, st->subframeSize, - innov, syn_resp, bits, stack, st->complexity, SUBMODE(double_codebook)); - - /* De-normalize innovation and update excitation */ - signal_mul(innov, innov, ener, st->subframeSize); - - for (i=0;isubframeSize;i++) - exc[i] = EXTRACT16(SATURATE32(PSHR32(ADD32(SHL32(exc32[i],1),innov[i]),SIG_SHIFT),32767)); - - /* In some (rare) modes, we do a second search (more bits) to reduce noise even more */ - if (SUBMODE(double_codebook)) { - char *tmp_stack=stack; - VARDECL(spx_sig_t *innov2); - ALLOC(innov2, st->subframeSize, spx_sig_t); - SPEEX_MEMSET(innov2, 0, st->subframeSize); - for (i=0;isubframeSize;i++) - target[i]=MULT16_16_P13(QCONST16(2.2f,13), target[i]); - SUBMODE(innovation_quant)(target, interp_qlpc, bw_lpc1, bw_lpc2, - SUBMODE(innovation_params), st->lpcSize, st->subframeSize, - innov2, syn_resp, bits, stack, st->complexity, 0); - signal_mul(innov2, innov2, MULT16_32_Q15(QCONST16(0.454545f,15),ener), st->subframeSize); - for (i=0;isubframeSize;i++) - innov[i] = ADD32(innov[i],innov2[i]); - stack = tmp_stack; - } - for (i=0;isubframeSize;i++) - exc[i] = EXTRACT16(SATURATE32(PSHR32(ADD32(SHL32(exc32[i],1),innov[i]),SIG_SHIFT),32767)); - if (st->innov_rms_save) - { - st->innov_rms_save[sub] = compute_rms(innov, st->subframeSize); - } - } - - /* Final signal synthesis from excitation */ - iir_mem16(exc, interp_qlpc, sw, st->subframeSize, st->lpcSize, st->mem_sp, stack); - - /* Compute weighted signal again, from synthesized speech (not sure it's the right thing) */ - if (st->complexity!=0) - filter_mem16(sw, bw_lpc1, bw_lpc2, sw, st->subframeSize, st->lpcSize, st->mem_sw, stack); - - } - - /* Store the LSPs for interpolation in the next frame */ - if (st->submodeID>=1) - { - for (i=0;ilpcSize;i++) - st->old_lsp[i] = lsp[i]; - for (i=0;ilpcSize;i++) - st->old_qlsp[i] = qlsp[i]; - } - -#ifdef VORBIS_PSYCHO - if (st->submodeID>=1) - SPEEX_COPY(st->old_curve, st->curve, 128); -#endif - - if (st->submodeID==1) - { -#ifndef DISABLE_VBR - if (st->dtx_count) - speex_bits_pack(bits, 15, 4); - else -#endif - speex_bits_pack(bits, 0, 4); - } - - /* The next frame will not be the first (Duh!) */ - st->first = 0; - SPEEX_COPY(st->winBuf, in+2*st->frameSize-st->windowSize, st->windowSize-st->frameSize); - - if (SUBMODE(innovation_quant) == noise_codebook_quant || st->submodeID==0) - st->bounded_pitch = 1; - else - st->bounded_pitch = 0; - - return 1; -} -#endif /* SPEEX_DISABLE_ENCODER */ - -static DecState global_decstate IBSS_ATTR; - -void *nb_decoder_init(const SpeexMode *m) -{ - DecState *st = &global_decstate; - const SpeexNBMode *mode; - int i; - - mode=(const SpeexNBMode*)m->mode; -/* - st = (DecState *)speex_alloc(sizeof(DecState)); - if (!st) - return NULL; -*/ - memset(st, 0, sizeof(*st)); -#if defined(VAR_ARRAYS) || defined (USE_ALLOCA) - st->stack = NULL; -#else - st->stack = (char*)speex_alloc_scratch(NB_DEC_STACK); -#endif - - st->mode=m; - - - st->encode_submode = 1; - - st->first=1; - /* Codec parameters, should eventually have several "modes"*/ - st->frameSize = mode->frameSize; - st->nbSubframes=mode->frameSize/mode->subframeSize; - st->subframeSize=mode->subframeSize; - st->lpcSize = mode->lpcSize; - st->min_pitch=mode->pitchStart; - st->max_pitch=mode->pitchEnd; - - st->submodes=mode->submodes; - st->submodeID=mode->defaultSubmode; - - st->lpc_enh_enabled=1; - - /* st->excBuf = (spx_word16_t*)speex_alloc((st->frameSize + 2*st->max_pitch + st->subframeSize + 12)*sizeof(spx_word16_t)); */ - st->exc = st->excBuf + 2*st->max_pitch + st->subframeSize + 6; - SPEEX_MEMSET(st->excBuf, 0, st->frameSize + st->max_pitch); - - /* st->interp_qlpc = (spx_coef_t*)speex_alloc(st->lpcSize*sizeof(spx_coef_t)); */ - /* st->old_qlsp = (spx_lsp_t*)speex_alloc(st->lpcSize*sizeof(spx_lsp_t)); */ - /* st->mem_sp = (spx_mem_t*)speex_alloc(st->lpcSize*sizeof(spx_mem_t)); */ - /* st->pi_gain = (spx_word32_t*)speex_alloc((st->nbSubframes)*sizeof(spx_word32_t)); */ - st->last_pitch = 40; - st->count_lost=0; - st->pitch_gain_buf[0] = st->pitch_gain_buf[1] = st->pitch_gain_buf[2] = 0; - st->pitch_gain_buf_idx = 0; - st->seed = 1000; - - st->sampling_rate=8000; - st->last_ol_gain = 0; - - st->user_callback.func = &speex_default_user_handler; - st->user_callback.data = NULL; - for (i=0;i<16;i++) - st->speex_callbacks[i].func = NULL; - - st->voc_m1=st->voc_m2=st->voc_mean=0; - st->voc_offset=0; - st->dtx_enabled=0; - st->isWideband = 0; - st->highpass_enabled = 1; - -#ifdef CPU_COLDFIRE - coldfire_set_macsr(0); // Integer mode -#endif -#ifdef ENABLE_VALGRIND - VALGRIND_MAKE_READABLE(st, NB_DEC_STACK); -#endif - return st; -} - -void nb_decoder_destroy(void *state) -{ -#if !(defined(VAR_ARRAYS) || defined (USE_ALLOCA)) - DecState *st; - st=(DecState*)state; - speex_free_scratch(st->stack); -#else - (void)state; -#endif -/* - speex_free (st->excBuf); - speex_free (st->interp_qlpc); - speex_free (st->old_qlsp); - speex_free (st->mem_sp); - speex_free (st->pi_gain); - - speex_free(state); -*/ -} - -#define median3(a, b, c) ((a) < (b) ? ((b) < (c) ? (b) : ((a) < (c) ? (c) : (a))) : ((c) < (b) ? (b) : ((c) < (a) ? (c) : (a)))) - -#ifdef FIXED_POINT -const spx_word16_t attenuation[10] = {32767, 31483, 27923, 22861, 17278, 12055, 7764, 4616, 2533, 1283}; -#else -const spx_word16_t attenuation[10] = {1., 0.961, 0.852, 0.698, 0.527, 0.368, 0.237, 0.141, 0.077, 0.039}; - -#endif - -#ifndef ROCKBOX_VOICE_CODEC -static void nb_decode_lost(DecState *st, spx_word16_t *out, char *stack) -{ - int i; - int pitch_val; - spx_word16_t pitch_gain; - spx_word16_t fact; - spx_word16_t gain_med; - spx_word16_t innov_gain; - spx_word16_t noise_gain; - - if (st->count_lost<10) - fact = attenuation[st->count_lost]; - else - fact = 0; - - gain_med = median3(st->pitch_gain_buf[0], st->pitch_gain_buf[1], st->pitch_gain_buf[2]); - if (gain_med < st->last_pitch_gain) - st->last_pitch_gain = gain_med; - -#ifdef FIXED_POINT - pitch_gain = st->last_pitch_gain; - if (pitch_gain>54) - pitch_gain = 54; - pitch_gain = SHL16(pitch_gain, 9); -#else - pitch_gain = GAIN_SCALING_1*st->last_pitch_gain; - if (pitch_gain>.85) - pitch_gain=.85; -#endif - pitch_gain = MULT16_16_Q15(fact,pitch_gain) + VERY_SMALL; - /* FIXME: This was rms of innovation (not exc) */ - innov_gain = compute_rms16(st->exc, st->frameSize); - noise_gain = MULT16_16_Q15(innov_gain, MULT16_16_Q15(fact, SUB16(Q15ONE,MULT16_16_Q15(pitch_gain,pitch_gain)))); - /* Shift all buffers by one frame */ - SPEEX_MOVE(st->excBuf, st->excBuf+st->frameSize, 2*st->max_pitch + st->subframeSize + 12); - - - pitch_val = st->last_pitch + SHR32((spx_int32_t)speex_rand(1+st->count_lost, &st->seed),SIG_SHIFT); - if (pitch_val > st->max_pitch) - pitch_val = st->max_pitch; - if (pitch_val < st->min_pitch) - pitch_val = st->min_pitch; - for (i=0;iframeSize;i++) - { - st->exc[i]= MULT16_16_Q15(pitch_gain, (st->exc[i-pitch_val]+VERY_SMALL)) + - speex_rand(noise_gain, &st->seed); - } - - bw_lpc(QCONST16(.98,15), st->interp_qlpc, st->interp_qlpc, st->lpcSize); - iir_mem16(&st->exc[-st->subframeSize], st->interp_qlpc, out, st->frameSize, - st->lpcSize, st->mem_sp, stack); - highpass(out, out, st->frameSize, HIGHPASS_NARROWBAND|HIGHPASS_OUTPUT, st->mem_hp); - - st->first = 0; - st->count_lost++; - st->pitch_gain_buf[st->pitch_gain_buf_idx++] = PSHR16(pitch_gain,9); - if (st->pitch_gain_buf_idx > 2) /* rollover */ - st->pitch_gain_buf_idx = 0; -} -#endif - -/* Just so we don't need to carry the complete wideband mode information */ -static const unsigned short wb_skip_table[8] = {0, 36, 112, 192, 352, 0, 0, 0}; - -int nb_decode(void *state, SpeexBits *bits, void *vout) -{ - DecState *st; - int i, sub; - int pitch; - spx_word16_t pitch_gain[3]; - spx_word32_t ol_gain=0; - int ol_pitch=0; - spx_word16_t ol_pitch_coef=0; - int best_pitch=40; - spx_word16_t best_pitch_gain=0; - int wideband; - int m; - char *stack; - VARDECL(spx_sig_t *innov); - VARDECL(spx_word32_t *exc32); - VARDECL(spx_coef_t *ak); - VARDECL(spx_lsp_t *qlsp); - spx_word16_t pitch_average=0; - - spx_word16_t *out = (spx_word16_t*)vout; - VARDECL(spx_lsp_t *interp_qlsp); - - st=(DecState*)state; - stack=st->stack; - - /* Check if we're in DTX mode*/ - if (!bits && st->dtx_enabled) - { - st->submodeID=0; - } else - { - /* If bits is NULL, consider the packet to be lost (what could we do anyway) */ -#ifndef ROCKBOX_VOICE_CODEC - if (!bits) - { - nb_decode_lost(st, out, stack); - return 0; - } -#endif - - if (st->encode_submode) - { - - /* Search for next narrowband block (handle requests, skip wideband blocks) */ - do { - if (speex_bits_remaining(bits)<5) - return -1; - wideband = speex_bits_unpack_unsigned(bits, 1); - if (wideband) /* Skip wideband block (for compatibility) */ - { - int submode; - int advance; - advance = submode = speex_bits_unpack_unsigned(bits, SB_SUBMODE_BITS); - /*speex_mode_query(&speex_wb_mode, SPEEX_SUBMODE_BITS_PER_FRAME, &advance);*/ - advance = wb_skip_table[submode]; - if (advance < 0) - { - speex_notify("Invalid mode encountered. The stream is corrupted."); - return -2; - } - advance -= (SB_SUBMODE_BITS+1); - speex_bits_advance(bits, advance); - - if (speex_bits_remaining(bits)<5) - return -1; - wideband = speex_bits_unpack_unsigned(bits, 1); - if (wideband) - { - advance = submode = speex_bits_unpack_unsigned(bits, SB_SUBMODE_BITS); - /*speex_mode_query(&speex_wb_mode, SPEEX_SUBMODE_BITS_PER_FRAME, &advance);*/ - advance = wb_skip_table[submode]; - if (advance < 0) - { - speex_notify("Invalid mode encountered. The stream is corrupted."); - return -2; - } - advance -= (SB_SUBMODE_BITS+1); - speex_bits_advance(bits, advance); - wideband = speex_bits_unpack_unsigned(bits, 1); - if (wideband) - { - speex_notify("More than two wideband layers found. The stream is corrupted."); - return -2; - } - - } - } - if (speex_bits_remaining(bits)<4) - return -1; - /* FIXME: Check for overflow */ - m = speex_bits_unpack_unsigned(bits, 4); - if (m==15) /* We found a terminator */ - { - return -1; - } else if (m==14) /* Speex in-band request */ - { - int ret = speex_inband_handler(bits, st->speex_callbacks, state); - if (ret) - return ret; - } else if (m==13) /* User in-band request */ - { - int ret = st->user_callback.func(bits, state, st->user_callback.data); - if (ret) - return ret; - } else if (m>8) /* Invalid mode */ - { - speex_notify("Invalid mode encountered. The stream is corrupted."); - return -2; - } - - } while (m>8); - - /* Get the sub-mode that was used */ - st->submodeID = m; - } - - } - - /* Shift all buffers by one frame */ - SPEEX_MOVE(st->excBuf, st->excBuf+st->frameSize, 2*st->max_pitch + st->subframeSize + 12); - - /* If null mode (no transmission), just set a couple things to zero*/ - if (st->submodes[st->submodeID] == NULL) - { - VARDECL(spx_coef_t *lpc); - ALLOC(lpc, st->lpcSize, spx_coef_t); - bw_lpc(QCONST16(0.93f,15), st->interp_qlpc, lpc, st->lpcSize); - { - spx_word16_t innov_gain=0; - /* FIXME: This was innov, not exc */ - innov_gain = compute_rms16(st->exc, st->frameSize); - for (i=0;iframeSize;i++) - st->exc[i]=speex_rand(innov_gain, &st->seed); - } - - - st->first=1; - - /* Final signal synthesis from excitation */ - iir_mem16(st->exc, lpc, out, st->frameSize, st->lpcSize, st->mem_sp, stack); - - st->count_lost=0; - return 0; - } - - ALLOC(qlsp, st->lpcSize, spx_lsp_t); - - /* Unquantize LSPs */ - SUBMODE(lsp_unquant)(qlsp, st->lpcSize, bits); - - /*Damp memory if a frame was lost and the LSP changed too much*/ - if (st->count_lost) - { - spx_word16_t fact; - spx_word32_t lsp_dist=0; - for (i=0;ilpcSize;i++) - lsp_dist = ADD32(lsp_dist, EXTEND32(ABS(st->old_qlsp[i] - qlsp[i]))); -#ifdef FIXED_POINT - fact = SHR16(19661,SHR32(lsp_dist,LSP_SHIFT+2)); -#else - fact = .6*exp(-.2*lsp_dist); -#endif - for (i=0;ilpcSize;i++) - st->mem_sp[i] = MULT16_32_Q15(fact,st->mem_sp[i]); - } - - - /* Handle first frame and lost-packet case */ - if (st->first || st->count_lost) - { - for (i=0;ilpcSize;i++) - st->old_qlsp[i] = qlsp[i]; - } - - /* Get open-loop pitch estimation for low bit-rate pitch coding */ - if (SUBMODE(lbr_pitch)!=-1) - { - ol_pitch = st->min_pitch+speex_bits_unpack_unsigned(bits, 7); - } - - if (SUBMODE(forced_pitch_gain)) - { - int quant; - quant = speex_bits_unpack_unsigned(bits, 4); - ol_pitch_coef=MULT16_16_P15(QCONST16(0.066667,15),SHL16(quant,GAIN_SHIFT)); - } - - /* Get global excitation gain */ - { - int qe; - qe = speex_bits_unpack_unsigned(bits, 5); -#ifdef FIXED_POINT - /* FIXME: Perhaps we could slightly lower the gain here when the output is going to saturate? */ - ol_gain = MULT16_32_Q15(28406,ol_gain_table[qe]); -#else - ol_gain = SIG_SCALING*exp(qe/3.5); -#endif - } - - ALLOC(ak, st->lpcSize, spx_coef_t); - ALLOC(innov, st->subframeSize, spx_sig_t); - ALLOC(exc32, st->subframeSize, spx_word32_t); - - if (st->submodeID==1) - { - int extra; - extra = speex_bits_unpack_unsigned(bits, 4); - - if (extra==15) - st->dtx_enabled=1; - else - st->dtx_enabled=0; - } - if (st->submodeID>1) - st->dtx_enabled=0; - - /*Loop on subframes */ - for (sub=0;subnbSubframes;sub++) - { - int offset; - spx_word16_t *exc; - spx_word16_t *innov_save = NULL; - spx_word16_t tmp; - - /* Offset relative to start of frame */ - offset = st->subframeSize*sub; - /* Excitation */ - exc=st->exc+offset; - - if (st->innov_save) - innov_save = st->innov_save+offset; - - - /* Reset excitation */ - SPEEX_MEMSET(exc, 0, st->subframeSize); - - /*Adaptive codebook contribution*/ - speex_assert (SUBMODE(ltp_unquant)); - { - int pit_min, pit_max; - /* Handle pitch constraints if any */ - if (SUBMODE(lbr_pitch) != -1) - { - int margin; - margin = SUBMODE(lbr_pitch); - if (margin) - { -/* GT - need optimization? - if (ol_pitch < st->min_pitch+margin-1) - ol_pitch=st->min_pitch+margin-1; - if (ol_pitch > st->max_pitch-margin) - ol_pitch=st->max_pitch-margin; - pit_min = ol_pitch-margin+1; - pit_max = ol_pitch+margin; -*/ - pit_min = ol_pitch-margin+1; - if (pit_min < st->min_pitch) - pit_min = st->min_pitch; - pit_max = ol_pitch+margin; - if (pit_max > st->max_pitch) - pit_max = st->max_pitch; - } else { - pit_min = pit_max = ol_pitch; - } - } else { - pit_min = st->min_pitch; - pit_max = st->max_pitch; - } - - - - SUBMODE(ltp_unquant)(exc, exc32, pit_min, pit_max, ol_pitch_coef, SUBMODE(ltp_params), - st->subframeSize, &pitch, &pitch_gain[0], bits, stack, - st->count_lost, offset, st->last_pitch_gain, 0); - - /* Ensuring that things aren't blowing up as would happen if e.g. an encoder is - crafting packets to make us produce NaNs and slow down the decoder (vague DoS threat). - We can probably be even more aggressive and limit to 15000 or so. */ - sanitize_values32(exc32, NEG32(QCONST32(32000,SIG_SHIFT-1)), QCONST32(32000,SIG_SHIFT-1), st->subframeSize); - - tmp = gain_3tap_to_1tap(pitch_gain); - - pitch_average += tmp; - if ((tmp>best_pitch_gain&&ABS(2*best_pitch-pitch)>=3&&ABS(3*best_pitch-pitch)>=4&&ABS(4*best_pitch-pitch)>=5) - || (tmp>MULT16_16_Q15(QCONST16(.6,15),best_pitch_gain)&&(ABS(best_pitch-2*pitch)<3||ABS(best_pitch-3*pitch)<4||ABS(best_pitch-4*pitch)<5)) - || (MULT16_16_Q15(QCONST16(.67,15),tmp)>best_pitch_gain&&(ABS(2*best_pitch-pitch)<3||ABS(3*best_pitch-pitch)<4||ABS(4*best_pitch-pitch)<5)) ) - { - best_pitch = pitch; - if (tmp > best_pitch_gain) - best_pitch_gain = tmp; - } - } - - /* Unquantize the innovation */ - { - int q_energy; - spx_word32_t ener; - - SPEEX_MEMSET(innov, 0, st->subframeSize); - - /* Decode sub-frame gain correction */ - if (SUBMODE(have_subframe_gain)==3) - { - q_energy = speex_bits_unpack_unsigned(bits, 3); - ener = MULT16_32_Q14(exc_gain_quant_scal3[q_energy],ol_gain); - } else if (SUBMODE(have_subframe_gain)==1) - { - q_energy = speex_bits_unpack_unsigned(bits, 1); - ener = MULT16_32_Q14(exc_gain_quant_scal1[q_energy],ol_gain); - } else { - ener = ol_gain; - } - - speex_assert (SUBMODE(innovation_unquant)); - { - /*Fixed codebook contribution*/ - SUBMODE(innovation_unquant)(innov, SUBMODE(innovation_params), st->subframeSize, bits, stack, &st->seed); - /* De-normalize innovation and update excitation */ - - signal_mul(innov, innov, ener, st->subframeSize); - - /* Decode second codebook (only for some modes) */ - if (SUBMODE(double_codebook)) - { - char *tmp_stack=stack; - VARDECL(spx_sig_t *innov2); - ALLOC(innov2, st->subframeSize, spx_sig_t); - SPEEX_MEMSET(innov2, 0, st->subframeSize); - SUBMODE(innovation_unquant)(innov2, SUBMODE(innovation_params), st->subframeSize, bits, stack, &st->seed); - signal_mul(innov2, innov2, MULT16_32_Q15(QCONST16(0.454545f,15),ener), st->subframeSize); - for (i=0;isubframeSize;i++) - innov[i] = ADD32(innov[i], innov2[i]); - stack = tmp_stack; - } - for (i=0;isubframeSize;i++) - exc[i]=EXTRACT16(SATURATE32(PSHR32(ADD32(SHL32(exc32[i],1),innov[i]),SIG_SHIFT),32767)); - /*print_vec(exc, 40, "innov");*/ - if (innov_save) - { - for (i=0;isubframeSize;i++) - innov_save[i] = EXTRACT16(PSHR32(innov[i], SIG_SHIFT)); - } - } - - /*Vocoder mode*/ - if (st->submodeID==1) - { - spx_word16_t g=ol_pitch_coef; - g=MULT16_16_P14(QCONST16(1.5f,14),(g-QCONST16(.2f,6))); - if (g<0) - g=0; - if (g>GAIN_SCALING) - g=GAIN_SCALING; - - SPEEX_MEMSET(exc, 0, st->subframeSize); - while (st->voc_offsetsubframeSize) - { - /* exc[st->voc_offset]= g*sqrt(2*ol_pitch)*ol_gain; - Not quite sure why we need the factor of two in the sqrt */ - if (st->voc_offset>=0) - exc[st->voc_offset]=MULT16_16(spx_sqrt(MULT16_16_16(2,ol_pitch)),EXTRACT16(PSHR32(MULT16_16(g,PSHR32(ol_gain,SIG_SHIFT)),6))); - st->voc_offset+=ol_pitch; - } - st->voc_offset -= st->subframeSize; - - for (i=0;isubframeSize;i++) - { - spx_word16_t exci=exc[i]; - exc[i]= ADD16(ADD16(MULT16_16_Q15(QCONST16(.7f,15),exc[i]) , MULT16_16_Q15(QCONST16(.3f,15),st->voc_m1)), - SUB16(MULT16_16_Q15(Q15_ONE-MULT16_16_16(QCONST16(.85f,9),g),EXTRACT16(PSHR32(innov[i],SIG_SHIFT))), - MULT16_16_Q15(MULT16_16_16(QCONST16(.15f,9),g),EXTRACT16(PSHR32(st->voc_m2,SIG_SHIFT))) - )); - st->voc_m1 = exci; - st->voc_m2=innov[i]; - st->voc_mean = EXTRACT16(PSHR32(ADD32(MULT16_16(QCONST16(.8f,15),st->voc_mean), MULT16_16(QCONST16(.2f,15),exc[i])), 15)); - exc[i]-=st->voc_mean; - } - } - - } - } - - ALLOC(interp_qlsp, st->lpcSize, spx_lsp_t); - - if (st->lpc_enh_enabled && SUBMODE(comb_gain)>0 && !st->count_lost) - { - multicomb(st->exc-st->subframeSize, out, st->interp_qlpc, st->lpcSize, 2*st->subframeSize, best_pitch, 40, SUBMODE(comb_gain), stack); - multicomb(st->exc+st->subframeSize, out+2*st->subframeSize, st->interp_qlpc, st->lpcSize, 2*st->subframeSize, best_pitch, 40, SUBMODE(comb_gain), stack); - } else { - SPEEX_COPY(out, &st->exc[-st->subframeSize], st->frameSize); - } - - /* If the last packet was lost, re-scale the excitation to obtain the same energy as encoded in ol_gain */ - if (st->count_lost) - { - spx_word16_t exc_ener; - spx_word32_t gain32; - spx_word16_t gain; - exc_ener = compute_rms16 (st->exc, st->frameSize); - gain32 = PDIV32(ol_gain, ADD16(exc_ener,1)); -#ifdef FIXED_POINT - if (gain32 > 32767) - gain32 = 32767; - gain = EXTRACT16(gain32); -#else - if (gain32 > 2) - gain32=2; - gain = gain32; -#endif - for (i=0;iframeSize;i++) - { - st->exc[i] = MULT16_16_Q14(gain, st->exc[i]); - out[i]=st->exc[i-st->subframeSize]; - } - } - - /*Loop on subframes */ - for (sub=0;subnbSubframes;sub++) - { - int offset; - spx_word16_t *sp; - - /* Offset relative to start of frame */ - offset = st->subframeSize*sub; - /* Original signal */ - sp=out+offset; - - /* LSP interpolation (quantized and unquantized) */ - lsp_interpolate(st->old_qlsp, qlsp, interp_qlsp, st->lpcSize, sub, st->nbSubframes); - - /* Make sure the LSP's are stable */ - lsp_enforce_margin(interp_qlsp, st->lpcSize, LSP_MARGIN); - - /* Compute interpolated LPCs (unquantized) */ - lsp_to_lpc(interp_qlsp, ak, st->lpcSize, stack); - - /* Compute analysis filter at w=pi */ - { - spx_word32_t pi_g=LPC_SCALING; - for (i=0;ilpcSize;i+=2) - { - /*pi_g += -st->interp_qlpc[i] + st->interp_qlpc[i+1];*/ - pi_g = ADD32(pi_g, SUB32(EXTEND32(ak[i+1]),EXTEND32(ak[i]))); - } - st->pi_gain[sub] = pi_g; - } - - iir_mem16(sp, st->interp_qlpc, sp, st->subframeSize, st->lpcSize, - st->mem_sp, stack); - - for (i=0;ilpcSize;i++) - st->interp_qlpc[i] = ak[i]; - - } - - if (st->highpass_enabled) - highpass(out, out, st->frameSize, (st->isWideband?HIGHPASS_WIDEBAND:HIGHPASS_NARROWBAND)|HIGHPASS_OUTPUT, st->mem_hp); - /*for (i=0;iframeSize;i++) - printf ("%d\n", (int)st->frame[i]);*/ - - /* Tracking output level */ - st->level = 1+PSHR32(ol_gain,SIG_SHIFT); - st->max_level = MAX16(MULT16_16_Q15(QCONST16(.99f,15), st->max_level), st->level); - st->min_level = MIN16(ADD16(1,MULT16_16_Q14(QCONST16(1.01f,14), st->min_level)), st->level); - if (st->max_level < st->min_level+1) - st->max_level = st->min_level+1; - /*printf ("%f %f %f %d\n", og, st->min_level, st->max_level, update);*/ - - /* Store the LSPs for interpolation in the next frame */ - for (i=0;ilpcSize;i++) - st->old_qlsp[i] = qlsp[i]; - - /* The next frame will not be the first (Duh!) */ - st->first = 0; - st->count_lost=0; - st->last_pitch = best_pitch; -#ifdef FIXED_POINT - st->last_pitch_gain = PSHR16(pitch_average,2); -#else - st->last_pitch_gain = .25*pitch_average; -#endif - st->pitch_gain_buf[st->pitch_gain_buf_idx++] = st->last_pitch_gain; - if (st->pitch_gain_buf_idx > 2) /* rollover */ - st->pitch_gain_buf_idx = 0; - - st->last_ol_gain = ol_gain; - - return 0; -} - -#ifndef SPEEX_DISABLE_ENCODER -int nb_encoder_ctl(void *state, int request, void *ptr) -{ - EncState *st; - st=(EncState*)state; - switch(request) - { - case SPEEX_GET_FRAME_SIZE: - (*(spx_int32_t*)ptr) = st->frameSize; - break; - case SPEEX_SET_LOW_MODE: - case SPEEX_SET_MODE: - st->submodeSelect = st->submodeID = (*(spx_int32_t*)ptr); - break; - case SPEEX_GET_LOW_MODE: - case SPEEX_GET_MODE: - (*(spx_int32_t*)ptr) = st->submodeID; - break; -#ifndef DISABLE_VBR - case SPEEX_SET_VBR: - st->vbr_enabled = (*(spx_int32_t*)ptr); - break; - case SPEEX_GET_VBR: - (*(spx_int32_t*)ptr) = st->vbr_enabled; - break; - case SPEEX_SET_VAD: - st->vad_enabled = (*(spx_int32_t*)ptr); - break; - case SPEEX_GET_VAD: - (*(spx_int32_t*)ptr) = st->vad_enabled; - break; - case SPEEX_SET_DTX: - st->dtx_enabled = (*(spx_int32_t*)ptr); - break; - case SPEEX_GET_DTX: - (*(spx_int32_t*)ptr) = st->dtx_enabled; - break; - case SPEEX_SET_ABR: - st->abr_enabled = (*(spx_int32_t*)ptr); - st->vbr_enabled = st->abr_enabled!=0; - if (st->vbr_enabled) - { - spx_int32_t i=10; - spx_int32_t rate, target; - float vbr_qual; - target = (*(spx_int32_t*)ptr); - while (i>=0) - { - speex_encoder_ctl(st, SPEEX_SET_QUALITY, &i); - speex_encoder_ctl(st, SPEEX_GET_BITRATE, &rate); - if (rate <= target) - break; - i--; - } - vbr_qual=i; - if (vbr_qual<0) - vbr_qual=0; - speex_encoder_ctl(st, SPEEX_SET_VBR_QUALITY, &vbr_qual); - st->abr_count=0; - st->abr_drift=0; - st->abr_drift2=0; - } - - break; - case SPEEX_GET_ABR: - (*(spx_int32_t*)ptr) = st->abr_enabled; - break; -#endif /* #ifndef DISABLE_VBR */ -#if !defined(DISABLE_VBR) && !defined(DISABLE_FLOAT_API) - case SPEEX_SET_VBR_QUALITY: - st->vbr_quality = (*(float*)ptr); - break; - case SPEEX_GET_VBR_QUALITY: - (*(float*)ptr) = st->vbr_quality; - break; -#endif /* !defined(DISABLE_VBR) && !defined(DISABLE_FLOAT_API) */ - case SPEEX_SET_QUALITY: - { - int quality = (*(spx_int32_t*)ptr); - if (quality < 0) - quality = 0; - if (quality > 10) - quality = 10; - st->submodeSelect = st->submodeID = ((const SpeexNBMode*)(st->mode->mode))->quality_map[quality]; - } - break; - case SPEEX_SET_COMPLEXITY: - st->complexity = (*(spx_int32_t*)ptr); - if (st->complexity<0) - st->complexity=0; - break; - case SPEEX_GET_COMPLEXITY: - (*(spx_int32_t*)ptr) = st->complexity; - break; - case SPEEX_SET_BITRATE: - { - spx_int32_t i=10; - spx_int32_t rate, target; - target = (*(spx_int32_t*)ptr); - while (i>=0) - { - speex_encoder_ctl(st, SPEEX_SET_QUALITY, &i); - speex_encoder_ctl(st, SPEEX_GET_BITRATE, &rate); - if (rate <= target) - break; - i--; - } - } - break; - case SPEEX_GET_BITRATE: - if (st->submodes[st->submodeID]) - (*(spx_int32_t*)ptr) = st->sampling_rate*SUBMODE(bits_per_frame)/st->frameSize; - else - (*(spx_int32_t*)ptr) = st->sampling_rate*(NB_SUBMODE_BITS+1)/st->frameSize; - break; - case SPEEX_SET_SAMPLING_RATE: - st->sampling_rate = (*(spx_int32_t*)ptr); - break; - case SPEEX_GET_SAMPLING_RATE: - (*(spx_int32_t*)ptr)=st->sampling_rate; - break; - case SPEEX_RESET_STATE: - { - int i; - st->bounded_pitch = 1; - st->first = 1; - for (i=0;ilpcSize;i++) - st->old_lsp[i]= DIV32(MULT16_16(QCONST16(3.1415927f, LSP_SHIFT), i+1), st->lpcSize+1); - for (i=0;ilpcSize;i++) - st->mem_sw[i]=st->mem_sw_whole[i]=st->mem_sp[i]=st->mem_exc[i]=0; - for (i=0;iframeSize+st->max_pitch+1;i++) - st->excBuf[i]=st->swBuf[i]=0; - for (i=0;iwindowSize-st->frameSize;i++) - st->winBuf[i]=0; - } - break; - case SPEEX_SET_SUBMODE_ENCODING: - st->encode_submode = (*(spx_int32_t*)ptr); - break; - case SPEEX_GET_SUBMODE_ENCODING: - (*(spx_int32_t*)ptr) = st->encode_submode; - break; - case SPEEX_GET_LOOKAHEAD: - (*(spx_int32_t*)ptr)=(st->windowSize-st->frameSize); - break; - case SPEEX_SET_PLC_TUNING: - st->plc_tuning = (*(spx_int32_t*)ptr); - if (st->plc_tuning>100) - st->plc_tuning=100; - break; - case SPEEX_GET_PLC_TUNING: - (*(spx_int32_t*)ptr)=(st->plc_tuning); - break; -#ifndef DISABLE_VBR - case SPEEX_SET_VBR_MAX_BITRATE: - st->vbr_max = (*(spx_int32_t*)ptr); - break; - case SPEEX_GET_VBR_MAX_BITRATE: - (*(spx_int32_t*)ptr) = st->vbr_max; - break; -#endif /* #ifndef DISABLE_VBR */ - case SPEEX_SET_HIGHPASS: - st->highpass_enabled = (*(spx_int32_t*)ptr); - break; - case SPEEX_GET_HIGHPASS: - (*(spx_int32_t*)ptr) = st->highpass_enabled; - break; - - /* This is all internal stuff past this point */ - case SPEEX_GET_PI_GAIN: - { - int i; - spx_word32_t *g = (spx_word32_t*)ptr; - for (i=0;inbSubframes;i++) - g[i]=st->pi_gain[i]; - } - break; - case SPEEX_GET_EXC: - { - int i; - for (i=0;inbSubframes;i++) - ((spx_word16_t*)ptr)[i] = compute_rms16(st->exc+i*st->subframeSize, st->subframeSize); - } - break; -#ifndef DISABLE_VBR - case SPEEX_GET_RELATIVE_QUALITY: - (*(float*)ptr)=st->relative_quality; - break; -#endif /* #ifndef DISABLE_VBR */ - case SPEEX_SET_INNOVATION_SAVE: - st->innov_rms_save = (spx_word16_t*)ptr; - break; - case SPEEX_SET_WIDEBAND: - st->isWideband = *((spx_int32_t*)ptr); - break; - case SPEEX_GET_STACK: - *((char**)ptr) = st->stack; - break; - default: - speex_warning_int("Unknown nb_ctl request: ", request); - return -1; - } - return 0; -} -#endif /* SPEEX_DISABLE_ENCODER */ - -int nb_decoder_ctl(void *state, int request, void *ptr) -{ - DecState *st; - st=(DecState*)state; - switch(request) - { - case SPEEX_SET_LOW_MODE: - case SPEEX_SET_MODE: - st->submodeID = (*(spx_int32_t*)ptr); - break; - case SPEEX_GET_LOW_MODE: - case SPEEX_GET_MODE: - (*(spx_int32_t*)ptr) = st->submodeID; - break; - case SPEEX_SET_ENH: - st->lpc_enh_enabled = *((spx_int32_t*)ptr); - break; - case SPEEX_GET_ENH: - *((spx_int32_t*)ptr) = st->lpc_enh_enabled; - break; - case SPEEX_GET_FRAME_SIZE: - (*(spx_int32_t*)ptr) = st->frameSize; - break; - case SPEEX_GET_BITRATE: - if (st->submodes[st->submodeID]) - (*(spx_int32_t*)ptr) = st->sampling_rate*SUBMODE(bits_per_frame)/st->frameSize; - else - (*(spx_int32_t*)ptr) = st->sampling_rate*(NB_SUBMODE_BITS+1)/st->frameSize; - break; - case SPEEX_SET_SAMPLING_RATE: - st->sampling_rate = (*(spx_int32_t*)ptr); - break; - case SPEEX_GET_SAMPLING_RATE: - (*(spx_int32_t*)ptr)=st->sampling_rate; - break; - case SPEEX_SET_HANDLER: - { - SpeexCallback *c = (SpeexCallback*)ptr; - st->speex_callbacks[c->callback_id].func=c->func; - st->speex_callbacks[c->callback_id].data=c->data; - st->speex_callbacks[c->callback_id].callback_id=c->callback_id; - } - break; - case SPEEX_SET_USER_HANDLER: - { - SpeexCallback *c = (SpeexCallback*)ptr; - st->user_callback.func=c->func; - st->user_callback.data=c->data; - st->user_callback.callback_id=c->callback_id; - } - break; - case SPEEX_RESET_STATE: - { - int i; - for (i=0;ilpcSize;i++) - st->mem_sp[i]=0; - for (i=0;iframeSize + st->max_pitch + 1;i++) - st->excBuf[i]=0; - } - break; - case SPEEX_SET_SUBMODE_ENCODING: - st->encode_submode = (*(spx_int32_t*)ptr); - break; - case SPEEX_GET_SUBMODE_ENCODING: - (*(spx_int32_t*)ptr) = st->encode_submode; - break; - case SPEEX_GET_LOOKAHEAD: - (*(spx_int32_t*)ptr)=st->subframeSize; - break; - case SPEEX_SET_HIGHPASS: - st->highpass_enabled = (*(spx_int32_t*)ptr); - break; - case SPEEX_GET_HIGHPASS: - (*(spx_int32_t*)ptr) = st->highpass_enabled; - break; - /* FIXME: Convert to fixed-point and re-enable even when float API is disabled */ -#ifndef DISABLE_FLOAT_API - case SPEEX_GET_ACTIVITY: - { - float ret; - ret = log(st->level/st->min_level)/log(st->max_level/st->min_level); - if (ret>1) - ret = 1; - /* Done in a strange way to catch NaNs as well */ - if (!(ret > 0)) - ret = 0; - /*printf ("%f %f %f %f\n", st->level, st->min_level, st->max_level, ret);*/ - (*(spx_int32_t*)ptr) = (int)(100*ret); - } - break; -#endif - case SPEEX_GET_PI_GAIN: - { - int i; - spx_word32_t *g = (spx_word32_t*)ptr; - for (i=0;inbSubframes;i++) - g[i]=st->pi_gain[i]; - } - break; - case SPEEX_GET_EXC: - { - int i; - for (i=0;inbSubframes;i++) - ((spx_word16_t*)ptr)[i] = compute_rms16(st->exc+i*st->subframeSize, st->subframeSize); - } - break; - case SPEEX_GET_DTX_STATUS: - *((spx_int32_t*)ptr) = st->dtx_enabled; - break; - case SPEEX_SET_INNOVATION_SAVE: - st->innov_save = (spx_word16_t*)ptr; - break; - case SPEEX_SET_WIDEBAND: - st->isWideband = *((spx_int32_t*)ptr); - break; - case SPEEX_GET_STACK: - *((char**)ptr) = st->stack; - break; - default: - speex_warning_int("Unknown nb_ctl request: ", request); - return -1; - } - return 0; -} diff --git a/apps/codecs/libspeex/nb_celp.h b/apps/codecs/libspeex/nb_celp.h deleted file mode 100644 index 30edbefaeb..0000000000 --- a/apps/codecs/libspeex/nb_celp.h +++ /dev/null @@ -1,205 +0,0 @@ -/* Copyright (C) 2002-2006 Jean-Marc Valin */ -/** - @file nb_celp.h - @brief Narrowband CELP encoder/decoder -*/ -/* - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of the Xiph.org Foundation nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*/ - -#ifndef NB_CELP_H -#define NB_CELP_H - -#include "modes.h" -#include "speex/speex_bits.h" -#include "speex/speex_callbacks.h" -#include "vbr.h" -#include "filters.h" - -#ifdef VORBIS_PSYCHO -#include "vorbis_psy.h" -#endif - -/**Structure representing the full state of the narrowband encoder*/ -typedef struct EncState { - const SpeexMode *mode; /**< Mode corresponding to the state */ - int first; /**< Is this the first frame? */ - int frameSize; /**< Size of frames */ - int subframeSize; /**< Size of sub-frames */ - int nbSubframes; /**< Number of sub-frames */ - int windowSize; /**< Analysis (LPC) window length */ - int lpcSize; /**< LPC order */ - int min_pitch; /**< Minimum pitch value allowed */ - int max_pitch; /**< Maximum pitch value allowed */ - - spx_word32_t cumul_gain; /**< Product of previously used pitch gains (Q10) */ - int bounded_pitch; /**< Next frame should not rely on previous frames for pitch */ - int ol_pitch; /**< Open-loop pitch */ - int ol_voiced; /**< Open-loop voiced/non-voiced decision */ - int *pitch; - -#ifdef VORBIS_PSYCHO - VorbisPsy *psy; - float *psy_window; - float *curve; - float *old_curve; -#endif - - spx_word16_t gamma1; /**< Perceptual filter: A(z/gamma1) */ - spx_word16_t gamma2; /**< Perceptual filter: A(z/gamma2) */ - spx_word16_t lpc_floor; /**< Noise floor multiplier for A[0] in LPC analysis*/ - char *stack; /**< Pseudo-stack allocation for temporary memory */ - spx_word16_t *winBuf; /**< Input buffer (original signal) */ - spx_word16_t *excBuf; /**< Excitation buffer */ - spx_word16_t *exc; /**< Start of excitation frame */ - spx_word16_t *swBuf; /**< Weighted signal buffer */ - spx_word16_t *sw; /**< Start of weighted signal frame */ - const spx_word16_t *window; /**< Temporary (Hanning) window */ - const spx_word16_t *lagWindow; /**< Window applied to auto-correlation */ - spx_lsp_t *old_lsp; /**< LSPs for previous frame */ - spx_lsp_t *old_qlsp; /**< Quantized LSPs for previous frame */ - spx_mem_t *mem_sp; /**< Filter memory for signal synthesis */ - spx_mem_t *mem_sw; /**< Filter memory for perceptually-weighted signal */ - spx_mem_t *mem_sw_whole; /**< Filter memory for perceptually-weighted signal (whole frame)*/ - spx_mem_t *mem_exc; /**< Filter memory for excitation (whole frame) */ - spx_mem_t *mem_exc2; /**< Filter memory for excitation (whole frame) */ - spx_mem_t mem_hp[2]; /**< High-pass filter memory */ - spx_word32_t *pi_gain; /**< Gain of LPC filter at theta=pi (fe/2) */ - spx_word16_t *innov_rms_save; /**< If non-NULL, innovation RMS is copied here */ - -#ifndef DISABLE_VBR - VBRState *vbr; /**< State of the VBR data */ - float vbr_quality; /**< Quality setting for VBR encoding */ - float relative_quality; /**< Relative quality that will be needed by VBR */ - spx_int32_t vbr_enabled; /**< 1 for enabling VBR, 0 otherwise */ - spx_int32_t vbr_max; /**< Max bit-rate allowed in VBR mode */ - int vad_enabled; /**< 1 for enabling VAD, 0 otherwise */ - int dtx_enabled; /**< 1 for enabling DTX, 0 otherwise */ - int dtx_count; /**< Number of consecutive DTX frames */ - spx_int32_t abr_enabled; /**< ABR setting (in bps), 0 if off */ - float abr_drift; - float abr_drift2; - float abr_count; -#endif /* #ifndef DISABLE_VBR */ - - int complexity; /**< Complexity setting (0-10 from least complex to most complex) */ - spx_int32_t sampling_rate; - int plc_tuning; - int encode_submode; - const SpeexSubmode * const *submodes; /**< Sub-mode data */ - int submodeID; /**< Activated sub-mode */ - int submodeSelect; /**< Mode chosen by the user (may differ from submodeID if VAD is on) */ - int isWideband; /**< Is this used as part of the embedded wideband codec */ - int highpass_enabled; /**< Is the input filter enabled */ -} EncState; - -/**Structure representing the full state of the narrowband decoder*/ -typedef struct DecState { - const SpeexMode *mode; /**< Mode corresponding to the state */ - int first; /**< Is this the first frame? */ - int count_lost; /**< Was the last frame lost? */ - int frameSize; /**< Size of frames */ - int subframeSize; /**< Size of sub-frames */ - int nbSubframes; /**< Number of sub-frames */ - int lpcSize; /**< LPC order */ - int min_pitch; /**< Minimum pitch value allowed */ - int max_pitch; /**< Maximum pitch value allowed */ - spx_int32_t sampling_rate; - - spx_word16_t last_ol_gain; /**< Open-loop gain for previous frame */ - - char *stack; /**< Pseudo-stack allocation for temporary memory */ - /* Size calculated from maximum values of frameSize, max_pitch and - * subframeSize, being respectively 160, 144 and 40 */ - spx_word16_t excBuf[500]; /**< Excitation buffer */ - spx_word16_t *exc; /**< Start of excitation frame */ - spx_lsp_t old_qlsp[10]; /**< Quantized LSPs for previous frame */ - spx_coef_t interp_qlpc[10]; /**< Interpolated quantized LPCs */ - spx_mem_t mem_sp[10]; /**< Filter memory for synthesis signal */ - spx_mem_t mem_hp[2]; /**< High-pass filter memory */ - spx_word32_t pi_gain[4]; /**< Gain of LPC filter at theta=pi (fe/2) */ - spx_word16_t *innov_save; /** If non-NULL, innovation is copied here */ - - spx_word16_t level; - spx_word16_t max_level; - spx_word16_t min_level; - - /* This is used in packet loss concealment */ - int last_pitch; /**< Pitch of last correctly decoded frame */ - spx_word16_t last_pitch_gain; /**< Pitch gain of last correctly decoded frame */ - spx_word16_t pitch_gain_buf[3]; /**< Pitch gain of last decoded frames */ - int pitch_gain_buf_idx; /**< Tail of the buffer */ - spx_int32_t seed; /** Seed used for random number generation */ - - int encode_submode; - const SpeexSubmode * const *submodes; /**< Sub-mode data */ - int submodeID; /**< Activated sub-mode */ - int lpc_enh_enabled; /**< 1 when LPC enhancer is on, 0 otherwise */ - SpeexCallback speex_callbacks[SPEEX_MAX_CALLBACKS]; - - SpeexCallback user_callback; - - /*Vocoder data*/ - spx_word16_t voc_m1; - spx_word32_t voc_m2; - spx_word16_t voc_mean; - int voc_offset; - - int dtx_enabled; - int isWideband; /**< Is this used as part of the embedded wideband codec */ - int highpass_enabled; /**< Is the input filter enabled */ -} DecState; - -/** Initializes encoder state*/ -void *nb_encoder_init(const SpeexMode *m); - -/** De-allocates encoder state resources*/ -void nb_encoder_destroy(void *state); - -/** Encodes one frame*/ -int nb_encode(void *state, void *in, SpeexBits *bits); - - -/** Initializes decoder state*/ -void *nb_decoder_init(const SpeexMode *m); - -/** De-allocates decoder state resources*/ -void nb_decoder_destroy(void *state); - -/** Decodes one frame*/ -int nb_decode(void *state, SpeexBits *bits, void *out); - -/** ioctl-like function for controlling a narrowband encoder */ -int nb_encoder_ctl(void *state, int request, void *ptr); - -/** ioctl-like function for controlling a narrowband decoder */ -int nb_decoder_ctl(void *state, int request, void *ptr); - - -#endif diff --git a/apps/codecs/libspeex/oggframing.c b/apps/codecs/libspeex/oggframing.c deleted file mode 100644 index 42d29502a8..0000000000 --- a/apps/codecs/libspeex/oggframing.c +++ /dev/null @@ -1,909 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2002 * - * by the Xiph.Org Foundation http://www.xiph.org/ * - * * - ******************************************************************** - - function: code raw [Vorbis] packets into framed OggSquish stream and - decode Ogg streams back into raw packets - last mod: $Id$ - - note: The CRC code is directly derived from public domain code by - Ross Williams (ross@guest.adelaide.edu.au). See docs/framing.html - for details. - - ********************************************************************/ - -//#include "config-tremor.h" -#include -#include "speex/ogg.h" -#include "arch.h" - -/* A complete description of Ogg framing exists in docs/framing.html */ - -int spx_ogg_page_version(spx_ogg_page *og){ - return((int)(og->header[4])); -} - -int spx_ogg_page_continued(spx_ogg_page *og){ - return((int)(og->header[5]&0x01)); -} - -int spx_ogg_page_bos(spx_ogg_page *og){ - return((int)(og->header[5]&0x02)); -} - -int spx_ogg_page_eos(spx_ogg_page *og){ - return((int)(og->header[5]&0x04)); -} - -spx_ogg_int64_t spx_ogg_page_granulepos(spx_ogg_page *og){ - unsigned char *page=og->header; - spx_ogg_int64_t granulepos=page[13]&(0xff); - granulepos= (granulepos<<8)|(page[12]&0xff); - granulepos= (granulepos<<8)|(page[11]&0xff); - granulepos= (granulepos<<8)|(page[10]&0xff); - granulepos= (granulepos<<8)|(page[9]&0xff); - granulepos= (granulepos<<8)|(page[8]&0xff); - granulepos= (granulepos<<8)|(page[7]&0xff); - granulepos= (granulepos<<8)|(page[6]&0xff); - return(granulepos); -} - -int spx_ogg_page_serialno(spx_ogg_page *og){ - return(og->header[14] | - (og->header[15]<<8) | - (og->header[16]<<16) | - (og->header[17]<<24)); -} - -long spx_ogg_page_pageno(spx_ogg_page *og){ - return(og->header[18] | - (og->header[19]<<8) | - (og->header[20]<<16) | - (og->header[21]<<24)); -} - - - -/* returns the number of packets that are completed on this page (if - the leading packet is begun on a previous page, but ends on this - page, it's counted */ - -/* NOTE: -If a page consists of a packet begun on a previous page, and a new -packet begun (but not completed) on this page, the return will be: - spx_ogg_page_packets(page) ==1, - spx_ogg_page_continued(page) !=0 - -If a page happens to be a single packet that was begun on a -previous page, and spans to the next page (in the case of a three or -more page packet), the return will be: - spx_ogg_page_packets(page) ==0, - spx_ogg_page_continued(page) !=0 -*/ - -int spx_ogg_page_packets(spx_ogg_page *og){ - int i,n=og->header[26],count=0; - for(i=0;iheader[27+i]<255)count++; - return(count); -} - - -#if 0 -/* helper to initialize lookup for direct-table CRC (illustrative; we - use the static init below) */ - -static spx_ogg_uint32_t _spx_ogg_crc_entry(unsigned long index){ - int i; - unsigned long r; - - r = index << 24; - for (i=0; i<8; i++) - if (r & 0x80000000UL) - r = (r << 1) ^ 0x04c11db7; /* The same as the ethernet generator - polynomial, although we use an - unreflected alg and an init/final - of 0, not 0xffffffff */ - else - r<<=1; - return (r & 0xffffffffUL); -} -#endif - -static const spx_ogg_uint32_t crc_lookup[256]={ - 0x00000000,0x04c11db7,0x09823b6e,0x0d4326d9, - 0x130476dc,0x17c56b6b,0x1a864db2,0x1e475005, - 0x2608edb8,0x22c9f00f,0x2f8ad6d6,0x2b4bcb61, - 0x350c9b64,0x31cd86d3,0x3c8ea00a,0x384fbdbd, - 0x4c11db70,0x48d0c6c7,0x4593e01e,0x4152fda9, - 0x5f15adac,0x5bd4b01b,0x569796c2,0x52568b75, - 0x6a1936c8,0x6ed82b7f,0x639b0da6,0x675a1011, - 0x791d4014,0x7ddc5da3,0x709f7b7a,0x745e66cd, - 0x9823b6e0,0x9ce2ab57,0x91a18d8e,0x95609039, - 0x8b27c03c,0x8fe6dd8b,0x82a5fb52,0x8664e6e5, - 0xbe2b5b58,0xbaea46ef,0xb7a96036,0xb3687d81, - 0xad2f2d84,0xa9ee3033,0xa4ad16ea,0xa06c0b5d, - 0xd4326d90,0xd0f37027,0xddb056fe,0xd9714b49, - 0xc7361b4c,0xc3f706fb,0xceb42022,0xca753d95, - 0xf23a8028,0xf6fb9d9f,0xfbb8bb46,0xff79a6f1, - 0xe13ef6f4,0xe5ffeb43,0xe8bccd9a,0xec7dd02d, - 0x34867077,0x30476dc0,0x3d044b19,0x39c556ae, - 0x278206ab,0x23431b1c,0x2e003dc5,0x2ac12072, - 0x128e9dcf,0x164f8078,0x1b0ca6a1,0x1fcdbb16, - 0x018aeb13,0x054bf6a4,0x0808d07d,0x0cc9cdca, - 0x7897ab07,0x7c56b6b0,0x71159069,0x75d48dde, - 0x6b93dddb,0x6f52c06c,0x6211e6b5,0x66d0fb02, - 0x5e9f46bf,0x5a5e5b08,0x571d7dd1,0x53dc6066, - 0x4d9b3063,0x495a2dd4,0x44190b0d,0x40d816ba, - 0xaca5c697,0xa864db20,0xa527fdf9,0xa1e6e04e, - 0xbfa1b04b,0xbb60adfc,0xb6238b25,0xb2e29692, - 0x8aad2b2f,0x8e6c3698,0x832f1041,0x87ee0df6, - 0x99a95df3,0x9d684044,0x902b669d,0x94ea7b2a, - 0xe0b41de7,0xe4750050,0xe9362689,0xedf73b3e, - 0xf3b06b3b,0xf771768c,0xfa325055,0xfef34de2, - 0xc6bcf05f,0xc27dede8,0xcf3ecb31,0xcbffd686, - 0xd5b88683,0xd1799b34,0xdc3abded,0xd8fba05a, - 0x690ce0ee,0x6dcdfd59,0x608edb80,0x644fc637, - 0x7a089632,0x7ec98b85,0x738aad5c,0x774bb0eb, - 0x4f040d56,0x4bc510e1,0x46863638,0x42472b8f, - 0x5c007b8a,0x58c1663d,0x558240e4,0x51435d53, - 0x251d3b9e,0x21dc2629,0x2c9f00f0,0x285e1d47, - 0x36194d42,0x32d850f5,0x3f9b762c,0x3b5a6b9b, - 0x0315d626,0x07d4cb91,0x0a97ed48,0x0e56f0ff, - 0x1011a0fa,0x14d0bd4d,0x19939b94,0x1d528623, - 0xf12f560e,0xf5ee4bb9,0xf8ad6d60,0xfc6c70d7, - 0xe22b20d2,0xe6ea3d65,0xeba91bbc,0xef68060b, - 0xd727bbb6,0xd3e6a601,0xdea580d8,0xda649d6f, - 0xc423cd6a,0xc0e2d0dd,0xcda1f604,0xc960ebb3, - 0xbd3e8d7e,0xb9ff90c9,0xb4bcb610,0xb07daba7, - 0xae3afba2,0xaafbe615,0xa7b8c0cc,0xa379dd7b, - 0x9b3660c6,0x9ff77d71,0x92b45ba8,0x9675461f, - 0x8832161a,0x8cf30bad,0x81b02d74,0x857130c3, - 0x5d8a9099,0x594b8d2e,0x5408abf7,0x50c9b640, - 0x4e8ee645,0x4a4ffbf2,0x470cdd2b,0x43cdc09c, - 0x7b827d21,0x7f436096,0x7200464f,0x76c15bf8, - 0x68860bfd,0x6c47164a,0x61043093,0x65c52d24, - 0x119b4be9,0x155a565e,0x18197087,0x1cd86d30, - 0x029f3d35,0x065e2082,0x0b1d065b,0x0fdc1bec, - 0x3793a651,0x3352bbe6,0x3e119d3f,0x3ad08088, - 0x2497d08d,0x2056cd3a,0x2d15ebe3,0x29d4f654, - 0xc5a92679,0xc1683bce,0xcc2b1d17,0xc8ea00a0, - 0xd6ad50a5,0xd26c4d12,0xdf2f6bcb,0xdbee767c, - 0xe3a1cbc1,0xe760d676,0xea23f0af,0xeee2ed18, - 0xf0a5bd1d,0xf464a0aa,0xf9278673,0xfde69bc4, - 0x89b8fd09,0x8d79e0be,0x803ac667,0x84fbdbd0, - 0x9abc8bd5,0x9e7d9662,0x933eb0bb,0x97ffad0c, - 0xafb010b1,0xab710d06,0xa6322bdf,0xa2f33668, - 0xbcb4666d,0xb8757bda,0xb5365d03,0xb1f740b4}; - -/* init the encode/decode logical stream state */ - -int spx_ogg_stream_init(spx_ogg_stream_state *os,int serialno){ - if(os){ - memset(os,0,sizeof(*os)); - os->body_storage=16*1024; - os->body_data=_spx_ogg_malloc(os->body_storage*sizeof(*os->body_data)); - - os->lacing_storage=1024; - os->lacing_vals=_spx_ogg_malloc(os->lacing_storage*sizeof(*os->lacing_vals)); - os->granule_vals=_spx_ogg_malloc(os->lacing_storage*sizeof(*os->granule_vals)); - - os->serialno=serialno; - - return(0); - } - return(-1); -} - -/* _clear does not free os, only the non-flat storage within */ -int spx_ogg_stream_clear(spx_ogg_stream_state *os){ - if(os){ - if(os->body_data)_spx_ogg_free(os->body_data); - if(os->lacing_vals)_spx_ogg_free(os->lacing_vals); - if(os->granule_vals)_spx_ogg_free(os->granule_vals); - - memset(os,0,sizeof(*os)); - } - return(0); -} - -int spx_ogg_stream_destroy(spx_ogg_stream_state *os){ - if(os){ - spx_ogg_stream_clear(os); - _spx_ogg_free(os); - } - return(0); -} - -/* Helpers for spx_ogg_stream_encode; this keeps the structure and - what's happening fairly clear */ - -static void _os_body_expand(spx_ogg_stream_state *os,int needed){ - if(os->body_storage<=os->body_fill+needed){ - os->body_storage+=(needed+1024); - os->body_data=_spx_ogg_realloc(os->body_data,os->body_storage*sizeof(*os->body_data)); - } -} - -static void _os_lacing_expand(spx_ogg_stream_state *os,int needed){ - if(os->lacing_storage<=os->lacing_fill+needed){ - os->lacing_storage+=(needed+32); - os->lacing_vals=_spx_ogg_realloc(os->lacing_vals,os->lacing_storage*sizeof(*os->lacing_vals)); - os->granule_vals=_spx_ogg_realloc(os->granule_vals,os->lacing_storage*sizeof(*os->granule_vals)); - } -} - -/* checksum the page */ -/* Direct table CRC; note that this will be faster in the future if we - perform the checksum silmultaneously with other copies */ - -void spx_ogg_page_checksum_set(spx_ogg_page *og){ - if(og){ - spx_ogg_uint32_t crc_reg=0; - int i; - - /* safety; needed for API behavior, but not framing code */ - og->header[22]=0; - og->header[23]=0; - og->header[24]=0; - og->header[25]=0; - - for(i=0;iheader_len;i++) - crc_reg=(crc_reg<<8)^crc_lookup[((crc_reg >> 24)&0xff)^og->header[i]]; - for(i=0;ibody_len;i++) - crc_reg=(crc_reg<<8)^crc_lookup[((crc_reg >> 24)&0xff)^og->body[i]]; - - og->header[22]=(unsigned char)(crc_reg&0xff); - og->header[23]=(unsigned char)((crc_reg>>8)&0xff); - og->header[24]=(unsigned char)((crc_reg>>16)&0xff); - og->header[25]=(unsigned char)((crc_reg>>24)&0xff); - } -} - -/* submit data to the internal buffer of the framing engine */ -int spx_ogg_stream_packetin(spx_ogg_stream_state *os,spx_ogg_packet *op){ - int lacing_vals=op->bytes/255+1,i; - - if(os->body_returned){ - /* advance packet data according to the body_returned pointer. We - had to keep it around to return a pointer into the buffer last - call */ - - os->body_fill-=os->body_returned; - if(os->body_fill) - memmove(os->body_data,os->body_data+os->body_returned, - os->body_fill); - os->body_returned=0; - } - - /* make sure we have the buffer storage */ - _os_body_expand(os,op->bytes); - _os_lacing_expand(os,lacing_vals); - - /* Copy in the submitted packet. Yes, the copy is a waste; this is - the liability of overly clean abstraction for the time being. It - will actually be fairly easy to eliminate the extra copy in the - future */ - - memcpy(os->body_data+os->body_fill,op->packet,op->bytes); - os->body_fill+=op->bytes; - - /* Store lacing vals for this packet */ - for(i=0;ilacing_vals[os->lacing_fill+i]=255; - os->granule_vals[os->lacing_fill+i]=os->granulepos; - } - os->lacing_vals[os->lacing_fill+i]=(op->bytes)%255; - os->granulepos=os->granule_vals[os->lacing_fill+i]=op->granulepos; - - /* flag the first segment as the beginning of the packet */ - os->lacing_vals[os->lacing_fill]|= 0x100; - - os->lacing_fill+=lacing_vals; - - /* for the sake of completeness */ - os->packetno++; - - if(op->e_o_s)os->e_o_s=1; - - return(0); -} - -/* This will flush remaining packets into a page (returning nonzero), - even if there is not enough data to trigger a flush normally - (undersized page). If there are no packets or partial packets to - flush, spx_ogg_stream_flush returns 0. Note that spx_ogg_stream_flush will - try to flush a normal sized page like spx_ogg_stream_pageout; a call to - spx_ogg_stream_flush does not guarantee that all packets have flushed. - Only a return value of 0 from spx_ogg_stream_flush indicates all packet - data is flushed into pages. - - since spx_ogg_stream_flush will flush the last page in a stream even if - it's undersized, you almost certainly want to use spx_ogg_stream_pageout - (and *not* spx_ogg_stream_flush) unless you specifically need to flush - an page regardless of size in the middle of a stream. */ - -int spx_ogg_stream_flush(spx_ogg_stream_state *os,spx_ogg_page *og){ - int i; - int vals=0; - int maxvals=(os->lacing_fill>255?255:os->lacing_fill); - int bytes=0; - long acc=0; - spx_ogg_int64_t granule_pos=-1; - - if(maxvals==0)return(0); - - /* construct a page */ - /* decide how many segments to include */ - - /* If this is the initial header case, the first page must only include - the initial header packet */ - if(os->b_o_s==0){ /* 'initial header page' case */ - granule_pos=0; - for(vals=0;valslacing_vals[vals]&0x0ff)<255){ - vals++; - break; - } - } - }else{ - for(vals=0;vals4096)break; - acc+=os->lacing_vals[vals]&0x0ff; - if((os->lacing_vals[vals]&0xff)<255) - granule_pos=os->granule_vals[vals]; - } - } - - /* construct the header in temp storage */ - memcpy(os->header,"OggS",4); - - /* stream structure version */ - os->header[4]=0x00; - - /* continued packet flag? */ - os->header[5]=0x00; - if((os->lacing_vals[0]&0x100)==0)os->header[5]|=0x01; - /* first page flag? */ - if(os->b_o_s==0)os->header[5]|=0x02; - /* last page flag? */ - if(os->e_o_s && os->lacing_fill==vals)os->header[5]|=0x04; - os->b_o_s=1; - - /* 64 bits of PCM position */ - for(i=6;i<14;i++){ - os->header[i]=(unsigned char)(granule_pos&0xff); - granule_pos>>=8; - } - - /* 32 bits of stream serial number */ - { - long serialno=os->serialno; - for(i=14;i<18;i++){ - os->header[i]=(unsigned char)(serialno&0xff); - serialno>>=8; - } - } - - /* 32 bits of page counter (we have both counter and page header - because this val can roll over) */ - if(os->pageno==-1)os->pageno=0; /* because someone called - stream_reset; this would be a - strange thing to do in an - encode stream, but it has - plausible uses */ - { - long pageno=os->pageno++; - for(i=18;i<22;i++){ - os->header[i]=(unsigned char)(pageno&0xff); - pageno>>=8; - } - } - - /* zero for computation; filled in later */ - os->header[22]=0; - os->header[23]=0; - os->header[24]=0; - os->header[25]=0; - - /* segment table */ - os->header[26]=(unsigned char)(vals&0xff); - for(i=0;iheader[i+27]=(unsigned char)(os->lacing_vals[i]&0xff); - - /* set pointers in the spx_ogg_page struct */ - og->header=os->header; - og->header_len=os->header_fill=vals+27; - og->body=os->body_data+os->body_returned; - og->body_len=bytes; - - /* advance the lacing data and set the body_returned pointer */ - - os->lacing_fill-=vals; - memmove(os->lacing_vals,os->lacing_vals+vals,os->lacing_fill*sizeof(*os->lacing_vals)); - memmove(os->granule_vals,os->granule_vals+vals,os->lacing_fill*sizeof(*os->granule_vals)); - os->body_returned+=bytes; - - /* calculate the checksum */ - - spx_ogg_page_checksum_set(og); - - /* done */ - return(1); -} - - -/* This constructs pages from buffered packet segments. The pointers -returned are to static buffers; do not free. The returned buffers are -good only until the next call (using the same spx_ogg_stream_state) */ - -int spx_ogg_stream_pageout(spx_ogg_stream_state *os, spx_ogg_page *og){ - - if((os->e_o_s&&os->lacing_fill) || /* 'were done, now flush' case */ - os->body_fill-os->body_returned > 4096 ||/* 'page nominal size' case */ - os->lacing_fill>=255 || /* 'segment table full' case */ - (os->lacing_fill&&!os->b_o_s)){ /* 'initial header page' case */ - - return(spx_ogg_stream_flush(os,og)); - } - - /* not enough data to construct a page and not end of stream */ - return(0); -} - -int spx_ogg_stream_eos(spx_ogg_stream_state *os){ - return os->e_o_s; -} - -/* DECODING PRIMITIVES: packet streaming layer **********************/ - -/* This has two layers to place more of the multi-serialno and paging - control in the application's hands. First, we expose a data buffer - using spx_ogg_sync_buffer(). The app either copies into the - buffer, or passes it directly to read(), etc. We then call - spx_ogg_sync_wrote() to tell how many bytes we just added. - - Pages are returned (pointers into the buffer in spx_ogg_sync_state) - by spx_ogg_sync_pageout(). The page is then submitted to - spx_ogg_stream_pagein() along with the appropriate - spx_ogg_stream_state* (ie, matching serialno). We then get raw - packets out calling spx_ogg_stream_packetout() with a - spx_ogg_stream_state. */ - -/* initialize the struct to a known state */ -int spx_ogg_sync_init(spx_ogg_sync_state *oy){ - if(oy){ - memset(oy,0,sizeof(*oy)); - } - return(0); -} - -/* clear non-flat storage within */ -int spx_ogg_sync_clear(spx_ogg_sync_state *oy){ - if(oy){ - if(oy->data)_spx_ogg_free(oy->data); - spx_ogg_sync_init(oy); - } - return(0); -} - -int spx_ogg_sync_destroy(spx_ogg_sync_state *oy){ - if(oy){ - spx_ogg_sync_clear(oy); - _spx_ogg_free(oy); - } - return(0); -} -void spx_ogg_alloc_buffer(spx_ogg_sync_state *oy, long size){ - long newsize=size+oy->fill+size; /* an extra page to be nice */ - if(oy->data){ - oy->data=_spx_ogg_realloc(oy->data,newsize); - }else - oy->data=_spx_ogg_malloc(newsize); - oy->storage=newsize; - return; -} - -char *spx_ogg_sync_buffer(spx_ogg_sync_state *oy, long size){ - - /* first, clear out any space that has been previously returned */ - if(oy->returned){ - oy->fill-=oy->returned; - if(oy->fill>0) - memmove(oy->data,oy->data+oy->returned,oy->fill); - oy->returned=0; - } - - if(size>oy->storage-oy->fill){ - /* We need to extend the internal buffer */ - long newsize=size+oy->fill+4096; /* an extra page to be nice */ - if(oy->data){ - oy->data=_spx_ogg_realloc(oy->data,newsize); - }else - oy->data=_spx_ogg_malloc(newsize); - oy->storage=newsize; - } - - /* expose a segment at least as large as requested at the fill mark */ - return((char *)oy->data+oy->fill); -} - -int spx_ogg_sync_wrote(spx_ogg_sync_state *oy, long bytes){ - if(oy->fill+bytes>oy->storage)return(-1); - oy->fill+=bytes; - return(0); -} - -/* sync the stream. This is meant to be useful for finding page - boundaries. - - return values for this: - -n) skipped n bytes - 0) page not ready; more data (no bytes skipped) - n) page synced at current location; page length n bytes - -*/ - -long spx_ogg_sync_pageseek(spx_ogg_sync_state *oy,spx_ogg_page *og){ - unsigned char *page=oy->data+oy->returned; - unsigned char *next; - long bytes=oy->fill-oy->returned; - - if(oy->headerbytes==0){ - int headerbytes,i; - if(bytes<27)return(0); /* not enough for a header */ - - /* verify capture pattern */ - if(memcmp(page,"OggS",4))goto sync_fail; - - headerbytes=page[26]+27; - if(bytesbodybytes+=page[27+i]; - oy->headerbytes=headerbytes; - } - - if(oy->bodybytes+oy->headerbytes>bytes)return(0); - - /* The whole test page is buffered. Verify the checksum */ - { - /* Grab the checksum bytes, set the header field to zero */ - char chksum[4]; - spx_ogg_page log; - - memcpy(chksum,page+22,4); - memset(page+22,0,4); - - /* set up a temp page struct and recompute the checksum */ - log.header=page; - log.header_len=oy->headerbytes; - log.body=page+oy->headerbytes; - log.body_len=oy->bodybytes; - spx_ogg_page_checksum_set(&log); - - /* Compare */ - if(memcmp(chksum,page+22,4)){ - /* D'oh. Mismatch! Corrupt page (or miscapture and not a page - at all) */ - /* replace the computed checksum with the one actually read in */ - memcpy(page+22,chksum,4); - - /* Bad checksum. Lose sync */ - goto sync_fail; - } - } - - /* yes, have a whole page all ready to go */ - { - unsigned char *page=oy->data+oy->returned; - long bytes; - - if(og){ - og->header=page; - og->header_len=oy->headerbytes; - og->body=page+oy->headerbytes; - og->body_len=oy->bodybytes; - } - - oy->unsynced=0; - oy->returned+=(bytes=oy->headerbytes+oy->bodybytes); - oy->headerbytes=0; - oy->bodybytes=0; - return(bytes); - } - - sync_fail: - - oy->headerbytes=0; - oy->bodybytes=0; - - /* search for possible capture */ - next=memchr(page+1,'O',bytes-1); - if(!next) - next=oy->data+oy->fill; - - oy->returned=next-oy->data; - return(-(next-page)); -} - -/* sync the stream and get a page. Keep trying until we find a page. - Supress 'sync errors' after reporting the first. - - return values: - -1) recapture (hole in data) - 0) need more data - 1) page returned - - Returns pointers into buffered data; invalidated by next call to - _stream, _clear, _init, or _buffer */ - -int spx_ogg_sync_pageout(spx_ogg_sync_state *oy, spx_ogg_page *og){ - - /* all we need to do is verify a page at the head of the stream - buffer. If it doesn't verify, we look for the next potential - frame */ - - for(;;){ - long ret=spx_ogg_sync_pageseek(oy,og); - if(ret>0){ - /* have a page */ - return(1); - } - if(ret==0){ - /* need more data */ - return(0); - } - - /* head did not start a synced page... skipped some bytes */ - if(!oy->unsynced){ - oy->unsynced=1; - return(-1); - } - - /* loop. keep looking */ - - } -} - -/* add the incoming page to the stream state; we decompose the page - into packet segments here as well. */ - -int spx_ogg_stream_pagein(spx_ogg_stream_state *os, spx_ogg_page *og){ - unsigned char *header=og->header; - unsigned char *body=og->body; - long bodysize=og->body_len; - int segptr=0; - - int version=spx_ogg_page_version(og); - int continued=spx_ogg_page_continued(og); - int bos=spx_ogg_page_bos(og); - int eos=spx_ogg_page_eos(og); - spx_ogg_int64_t granulepos=spx_ogg_page_granulepos(og); - int serialno=spx_ogg_page_serialno(og); - long pageno=spx_ogg_page_pageno(og); - int segments=header[26]; - - /* clean up 'returned data' */ - { - long lr=os->lacing_returned; - long br=os->body_returned; - - /* body data */ - if(br){ - os->body_fill-=br; - if(os->body_fill) - memmove(os->body_data,os->body_data+br,os->body_fill); - os->body_returned=0; - } - - if(lr){ - /* segment table */ - if(os->lacing_fill-lr){ - memmove(os->lacing_vals,os->lacing_vals+lr, - (os->lacing_fill-lr)*sizeof(*os->lacing_vals)); - memmove(os->granule_vals,os->granule_vals+lr, - (os->lacing_fill-lr)*sizeof(*os->granule_vals)); - } - os->lacing_fill-=lr; - os->lacing_packet-=lr; - os->lacing_returned=0; - } - } - - /* check the serial number */ - if(serialno!=os->serialno)return(-1); - if(version>0)return(-1); - - _os_lacing_expand(os,segments+1); - - /* are we in sequence? */ - if(pageno!=os->pageno){ - int i; - - /* unroll previous partial packet (if any) */ - for(i=os->lacing_packet;ilacing_fill;i++) - os->body_fill-=os->lacing_vals[i]&0xff; - os->lacing_fill=os->lacing_packet; - - /* make a note of dropped data in segment table */ - if(os->pageno!=-1){ - os->lacing_vals[os->lacing_fill++]=0x400; - os->lacing_packet++; - } - } - - /* are we a 'continued packet' page? If so, we may need to skip - some segments */ - if(continued){ - if(os->lacing_fill<1 || - os->lacing_vals[os->lacing_fill-1]==0x400){ - bos=0; - for(;segptrbody_data+os->body_fill,body,bodysize); - os->body_fill+=bodysize; - } - - { - int saved=-1; - while(segptrlacing_vals[os->lacing_fill]=val; - os->granule_vals[os->lacing_fill]=-1; - - if(bos){ - os->lacing_vals[os->lacing_fill]|=0x100; - bos=0; - } - - if(val<255)saved=os->lacing_fill; - - os->lacing_fill++; - segptr++; - - if(val<255)os->lacing_packet=os->lacing_fill; - } - - /* set the granulepos on the last granuleval of the last full packet */ - if(saved!=-1){ - os->granule_vals[saved]=granulepos; - } - - } - - if(eos){ - os->e_o_s=1; - if(os->lacing_fill>0) - os->lacing_vals[os->lacing_fill-1]|=0x200; - } - - os->pageno=pageno+1; - - return(0); -} - -/* clear things to an initial state. Good to call, eg, before seeking */ -int spx_ogg_sync_reset(spx_ogg_sync_state *oy){ - oy->fill=0; - oy->returned=0; - oy->unsynced=0; - oy->headerbytes=0; - oy->bodybytes=0; - return(0); -} - -int spx_ogg_stream_reset(spx_ogg_stream_state *os){ - os->body_fill=0; - os->body_returned=0; - - os->lacing_fill=0; - os->lacing_packet=0; - os->lacing_returned=0; - - os->header_fill=0; - - os->e_o_s=0; - os->b_o_s=0; - os->pageno=-1; - os->packetno=0; - os->granulepos=0; - - return(0); -} - -int spx_ogg_stream_reset_serialno(spx_ogg_stream_state *os,int serialno){ - spx_ogg_stream_reset(os); - os->serialno=serialno; - return(0); -} - -static int _packetout(spx_ogg_stream_state *os,spx_ogg_packet *op,int adv){ - - /* The last part of decode. We have the stream broken into packet - segments. Now we need to group them into packets (or return the - out of sync markers) */ - - int ptr=os->lacing_returned; - - if(os->lacing_packet<=ptr)return(0); - - if(os->lacing_vals[ptr]&0x400){ - /* we need to tell the codec there's a gap; it might need to - handle previous packet dependencies. */ - os->lacing_returned++; - os->packetno++; - return(-1); - } - - if(!op && !adv)return(1); /* just using peek as an inexpensive way - to ask if there's a whole packet - waiting */ - - /* Gather the whole packet. We'll have no holes or a partial packet */ - { - int size=os->lacing_vals[ptr]&0xff; - int bytes=size; - int eos=os->lacing_vals[ptr]&0x200; /* last packet of the stream? */ - int bos=os->lacing_vals[ptr]&0x100; /* first packet of the stream? */ - - while(size==255){ - int val=os->lacing_vals[++ptr]; - size=val&0xff; - if(val&0x200)eos=0x200; - bytes+=size; - } - - if(op){ - op->e_o_s=eos; - op->b_o_s=bos; - op->packet=os->body_data+os->body_returned; - op->packetno=os->packetno; - op->granulepos=os->granule_vals[ptr]; - op->bytes=bytes; - } - - if(adv){ - os->body_returned+=bytes; - os->lacing_returned=ptr+1; - os->packetno++; - } - } - return(1); -} - -int spx_ogg_stream_packetout(spx_ogg_stream_state *os,spx_ogg_packet *op){ - return _packetout(os,op,1); -} - -int spx_ogg_stream_packetpeek(spx_ogg_stream_state *os,spx_ogg_packet *op){ - return _packetout(os,op,0); -} - -void spx_ogg_packet_clear(spx_ogg_packet *op) { - _spx_ogg_free(op->packet); - memset(op, 0, sizeof(*op)); -} - diff --git a/apps/codecs/libspeex/os_support.h b/apps/codecs/libspeex/os_support.h deleted file mode 100644 index 71d24753c1..0000000000 --- a/apps/codecs/libspeex/os_support.h +++ /dev/null @@ -1,165 +0,0 @@ -/* Copyright (C) 2007 Jean-Marc Valin - - File: os_support.h - This is the (tiny) OS abstraction layer. Aside from math.h, this is the - only place where system headers are allowed. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are - met: - - 1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - 3. The name of the author may not be used to endorse or promote products - derived from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, - INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef OS_SUPPORT_H -#define OS_SUPPORT_H - -#include "config-speex.h" -#include "rockbox.h" - -#include -#include -#include - -/** Speex wrapper for calloc. To do your own dynamic allocation, all you need to do is replace this function, speex_realloc and speex_free - NOTE: speex_alloc needs to CLEAR THE MEMORY */ -#ifndef OVERRIDE_SPEEX_ALLOC -static inline void *speex_alloc (int size) -{ - /* WARNING: this is not equivalent to malloc(). If you want to use malloc() - or your own allocator, YOU NEED TO CLEAR THE MEMORY ALLOCATED. Otherwise - you will experience strange bugs */ - return calloc(size,1); -} -#endif - -/** Same as speex_alloc, except that the area is only needed inside a Speex call (might cause problem with wideband though) */ -#ifndef OVERRIDE_SPEEX_ALLOC_SCRATCH -static inline void *speex_alloc_scratch (int size) -{ - /* Scratch space doesn't need to be cleared */ - return calloc(size,1); -} -#endif - -/** Speex wrapper for realloc. To do your own dynamic allocation, all you need to do is replace this function, speex_alloc and speex_free */ -#ifndef OVERRIDE_SPEEX_REALLOC -static inline void *speex_realloc (void *ptr, int size) -{ - return realloc(ptr, size); -} -#endif - -/** Speex wrapper for calloc. To do your own dynamic allocation, all you need to do is replace this function, speex_realloc and speex_alloc */ -#ifndef OVERRIDE_SPEEX_FREE -static inline void speex_free (void *ptr) -{ - free(ptr); -} -#endif - -/** Same as speex_free, except that the area is only needed inside a Speex call (might cause problem with wideband though) */ -#ifndef OVERRIDE_SPEEX_FREE_SCRATCH -static inline void speex_free_scratch (void *ptr) -{ - free(ptr); -} -#endif - -/** Copy n bytes of memory from src to dst. The 0* term provides compile-time type checking */ -#ifndef OVERRIDE_SPEEX_COPY -#define SPEEX_COPY(dst, src, n) (memcpy((dst), (src), (n)*sizeof(*(dst)) + 0*((dst)-(src)) )) -#endif - -/** Copy n bytes of memory from src to dst, allowing overlapping regions. The 0* term - provides compile-time type checking */ -#ifndef OVERRIDE_SPEEX_MOVE -#define SPEEX_MOVE(dst, src, n) (memmove((dst), (src), (n)*sizeof(*(dst)) + 0*((dst)-(src)) )) -#endif - -/** Set n bytes of memory to value of c, starting at address s */ -#ifndef OVERRIDE_SPEEX_MEMSET -#define SPEEX_MEMSET(dst, c, n) (memset((dst), (c), (n)*sizeof(*(dst)))) -#endif - - -#ifndef OVERRIDE_SPEEX_FATAL -static inline void _speex_fatal(const char *str, const char *file, int line) -{ - fprintf (stderr, "Fatal (internal) error in %s, line %d: %s\n", file, line, str); - exit(1); -} -#endif - -#ifndef OVERRIDE_SPEEX_WARNING -static inline void speex_warning(const char *str) -{ -#ifndef DISABLE_WARNINGS - fprintf (stderr, "warning: %s\n", str); -#endif -} -#endif - -#ifndef OVERRIDE_SPEEX_WARNING_INT -static inline void speex_warning_int(const char *str, int val) -{ -#ifndef DISABLE_WARNINGS - fprintf (stderr, "warning: %s %d\n", str, val); -#endif -} -#endif - -#ifndef OVERRIDE_SPEEX_NOTIFY -static inline void speex_notify(const char *str) -{ -#ifndef DISABLE_NOTIFICATIONS - fprintf (stderr, "notification: %s\n", str); -#endif -} -#endif - -#ifndef OVERRIDE_SPEEX_PUTC -/** Speex wrapper for putc */ -static inline void _speex_putc(int ch, void *file) -{ - FILE *f = (FILE *)file; - fprintf(f, "%c", ch); -} -#endif - -#define speex_fatal(str) _speex_fatal(str, __FILE__, __LINE__); -#define speex_assert(cond) {if (!(cond)) {speex_fatal("assertion failed: " #cond);}} - -#ifndef RELEASE -static inline void print_vec(float *vec, int len, char *name) -{ - int i; - printf ("%s ", name); - for (i=0;i -#include "speex/speex_preprocess.h" -#include "speex/speex_echo.h" -#include "arch.h" -#include "fftwrap.h" -#include "filterbank.h" -#include "math_approx.h" -#include "os_support.h" - -#ifndef M_PI -#define M_PI 3.14159263 -#endif - -#define LOUDNESS_EXP 5.f -#define AMP_SCALE .001f -#define AMP_SCALE_1 1000.f - -#define NB_BANDS 24 - -#define SPEECH_PROB_START_DEFAULT QCONST16(0.35f,15) -#define SPEECH_PROB_CONTINUE_DEFAULT QCONST16(0.20f,15) -#define NOISE_SUPPRESS_DEFAULT -15 -#define ECHO_SUPPRESS_DEFAULT -40 -#define ECHO_SUPPRESS_ACTIVE_DEFAULT -15 - -#ifndef NULL -#define NULL 0 -#endif - -#define SQR(x) ((x)*(x)) -#define SQR16(x) (MULT16_16((x),(x))) -#define SQR16_Q15(x) (MULT16_16_Q15((x),(x))) - -#ifdef FIXED_POINT -static inline spx_word16_t DIV32_16_Q8(spx_word32_t a, spx_word32_t b) -{ - if (SHR32(a,7) >= b) - { - return 32767; - } else { - if (b>=QCONST32(1,23)) - { - a = SHR32(a,8); - b = SHR32(b,8); - } - if (b>=QCONST32(1,19)) - { - a = SHR32(a,4); - b = SHR32(b,4); - } - if (b>=QCONST32(1,15)) - { - a = SHR32(a,4); - b = SHR32(b,4); - } - a = SHL32(a,8); - return PDIV32_16(a,b); - } - -} -static inline spx_word16_t DIV32_16_Q15(spx_word32_t a, spx_word32_t b) -{ - if (SHR32(a,15) >= b) - { - return 32767; - } else { - if (b>=QCONST32(1,23)) - { - a = SHR32(a,8); - b = SHR32(b,8); - } - if (b>=QCONST32(1,19)) - { - a = SHR32(a,4); - b = SHR32(b,4); - } - if (b>=QCONST32(1,15)) - { - a = SHR32(a,4); - b = SHR32(b,4); - } - a = SHL32(a,15)-a; - return DIV32_16(a,b); - } -} -#define SNR_SCALING 256.f -#define SNR_SCALING_1 0.0039062f -#define SNR_SHIFT 8 - -#define FRAC_SCALING 32767.f -#define FRAC_SCALING_1 3.0518e-05 -#define FRAC_SHIFT 1 - -#define EXPIN_SCALING 2048.f -#define EXPIN_SCALING_1 0.00048828f -#define EXPIN_SHIFT 11 -#define EXPOUT_SCALING_1 1.5259e-05 - -#define NOISE_SHIFT 7 - -#else - -#define DIV32_16_Q8(a,b) ((a)/(b)) -#define DIV32_16_Q15(a,b) ((a)/(b)) -#define SNR_SCALING 1.f -#define SNR_SCALING_1 1.f -#define SNR_SHIFT 0 -#define FRAC_SCALING 1.f -#define FRAC_SCALING_1 1.f -#define FRAC_SHIFT 0 -#define NOISE_SHIFT 0 - -#define EXPIN_SCALING 1.f -#define EXPIN_SCALING_1 1.f -#define EXPOUT_SCALING_1 1.f - -#endif - -/** Speex pre-processor state. */ -struct SpeexPreprocessState_ { - /* Basic info */ - int frame_size; /**< Number of samples processed each time */ - int ps_size; /**< Number of points in the power spectrum */ - int sampling_rate; /**< Sampling rate of the input/output */ - int nbands; - FilterBank *bank; - - /* Parameters */ - int denoise_enabled; - int vad_enabled; - int dereverb_enabled; - spx_word16_t reverb_decay; - spx_word16_t reverb_level; - spx_word16_t speech_prob_start; - spx_word16_t speech_prob_continue; - int noise_suppress; - int echo_suppress; - int echo_suppress_active; - SpeexEchoState *echo_state; - - /* DSP-related arrays */ - spx_word16_t *frame; /**< Processing frame (2*ps_size) */ - spx_word16_t *ft; /**< Processing frame in freq domain (2*ps_size) */ - spx_word32_t *ps; /**< Current power spectrum */ - spx_word16_t *gain2; /**< Adjusted gains */ - spx_word16_t *gain_floor; /**< Minimum gain allowed */ - spx_word16_t *window; /**< Analysis/Synthesis window */ - spx_word32_t *noise; /**< Noise estimate */ - spx_word32_t *reverb_estimate; /**< Estimate of reverb energy */ - spx_word32_t *old_ps; /**< Power spectrum for last frame */ - spx_word16_t *gain; /**< Ephraim Malah gain */ - spx_word16_t *prior; /**< A-priori SNR */ - spx_word16_t *post; /**< A-posteriori SNR */ - - spx_word32_t *S; /**< Smoothed power spectrum */ - spx_word32_t *Smin; /**< See Cohen paper */ - spx_word32_t *Stmp; /**< See Cohen paper */ - int *update_prob; /**< Probability of speech presence for noise update */ - - spx_word16_t *zeta; /**< Smoothed a priori SNR */ - spx_word32_t *echo_noise; - spx_word32_t *residual_echo; - - /* Misc */ - spx_word16_t *inbuf; /**< Input buffer (overlapped analysis) */ - spx_word16_t *outbuf; /**< Output buffer (for overlap and add) */ - - /* AGC stuff, only for floating point for now */ -#ifndef FIXED_POINT - int agc_enabled; - float agc_level; - float loudness_accum; - float *loudness_weight; /**< Perceptual loudness curve */ - float loudness; /**< Loudness estimate */ - float agc_gain; /**< Current AGC gain */ - int nb_loudness_adapt; /**< Number of frames used for loudness adaptation so far */ - float max_gain; /**< Maximum gain allowed */ - float max_increase_step; /**< Maximum increase in gain from one frame to another */ - float max_decrease_step; /**< Maximum decrease in gain from one frame to another */ - float prev_loudness; /**< Loudness of previous frame */ - float init_max; /**< Current gain limit during initialisation */ -#endif - int nb_adapt; /**< Number of frames used for adaptation so far */ - int was_speech; - int min_count; /**< Number of frames processed so far */ - void *fft_lookup; /**< Lookup table for the FFT */ -#ifdef FIXED_POINT - int frame_shift; -#endif -}; - - -static void conj_window(spx_word16_t *w, int len) -{ - int i; - for (i=0;i19) - return ADD32(EXTEND32(Q15_ONE),EXTEND32(DIV32_16(QCONST32(.1296,23), SHR32(xx,EXPIN_SHIFT-SNR_SHIFT)))); - frac = SHL32(xx-SHL32(ind,10),5); - return SHL32(DIV32_16(PSHR32(MULT16_16(Q15_ONE-frac,table[ind]) + MULT16_16(frac,table[ind+1]),7),(spx_sqrt(SHL32(xx,15)+6711))),7); -} - -static inline spx_word16_t qcurve(spx_word16_t x) -{ - x = MAX16(x, 1); - return DIV32_16(SHL32(EXTEND32(32767),9),ADD16(512,MULT16_16_Q15(QCONST16(.60f,15),DIV32_16(32767,x)))); -} - -/* Compute the gain floor based on different floors for the background noise and residual echo */ -static void compute_gain_floor(int noise_suppress, int effective_echo_suppress, spx_word32_t *noise, spx_word32_t *echo, spx_word16_t *gain_floor, int len) -{ - int i; - - if (noise_suppress > effective_echo_suppress) - { - spx_word16_t noise_gain, gain_ratio; - noise_gain = EXTRACT16(MIN32(Q15_ONE,SHR32(spx_exp(MULT16_16(QCONST16(0.11513,11),noise_suppress)),1))); - gain_ratio = EXTRACT16(MIN32(Q15_ONE,SHR32(spx_exp(MULT16_16(QCONST16(.2302585f,11),effective_echo_suppress-noise_suppress)),1))); - - /* gain_floor = sqrt [ (noise*noise_floor + echo*echo_floor) / (noise+echo) ] */ - for (i=0;i19) - return FRAC_SCALING*(1+.1296/x); - frac = 2*x-integer; - return FRAC_SCALING*((1-frac)*table[ind] + frac*table[ind+1])/sqrt(x+.0001f); -} - -static inline spx_word16_t qcurve(spx_word16_t x) -{ - return 1.f/(1.f+.15f/(SNR_SCALING_1*x)); -} - -static void compute_gain_floor(int noise_suppress, int effective_echo_suppress, spx_word32_t *noise, spx_word32_t *echo, spx_word16_t *gain_floor, int len) -{ - int i; - float echo_floor; - float noise_floor; - - noise_floor = exp(.2302585f*noise_suppress); - echo_floor = exp(.2302585f*effective_echo_suppress); - - /* Compute the gain floor based on different floors for the background noise and residual echo */ - for (i=0;iframe_size = frame_size; - - /* Round ps_size down to the nearest power of two */ -#if 0 - i=1; - st->ps_size = st->frame_size; - while(1) - { - if (st->ps_size & ~i) - { - st->ps_size &= ~i; - i<<=1; - } else { - break; - } - } - - - if (st->ps_size < 3*st->frame_size/4) - st->ps_size = st->ps_size * 3 / 2; -#else - st->ps_size = st->frame_size; -#endif - - N = st->ps_size; - N3 = 2*N - st->frame_size; - N4 = st->frame_size - N3; - - st->sampling_rate = sampling_rate; - st->denoise_enabled = 1; - st->vad_enabled = 0; - st->dereverb_enabled = 0; - st->reverb_decay = 0; - st->reverb_level = 0; - st->noise_suppress = NOISE_SUPPRESS_DEFAULT; - st->echo_suppress = ECHO_SUPPRESS_DEFAULT; - st->echo_suppress_active = ECHO_SUPPRESS_ACTIVE_DEFAULT; - - st->speech_prob_start = SPEECH_PROB_START_DEFAULT; - st->speech_prob_continue = SPEECH_PROB_CONTINUE_DEFAULT; - - st->echo_state = NULL; - - st->nbands = NB_BANDS; - M = st->nbands; - st->bank = filterbank_new(M, sampling_rate, N, 1); - - st->frame = (spx_word16_t*)speex_alloc(2*N*sizeof(spx_word16_t)); - st->window = (spx_word16_t*)speex_alloc(2*N*sizeof(spx_word16_t)); - st->ft = (spx_word16_t*)speex_alloc(2*N*sizeof(spx_word16_t)); - - st->ps = (spx_word32_t*)speex_alloc((N+M)*sizeof(spx_word32_t)); - st->noise = (spx_word32_t*)speex_alloc((N+M)*sizeof(spx_word32_t)); - st->echo_noise = (spx_word32_t*)speex_alloc((N+M)*sizeof(spx_word32_t)); - st->residual_echo = (spx_word32_t*)speex_alloc((N+M)*sizeof(spx_word32_t)); - st->reverb_estimate = (spx_word32_t*)speex_alloc((N+M)*sizeof(spx_word32_t)); - st->old_ps = (spx_word32_t*)speex_alloc((N+M)*sizeof(spx_word32_t)); - st->prior = (spx_word16_t*)speex_alloc((N+M)*sizeof(spx_word16_t)); - st->post = (spx_word16_t*)speex_alloc((N+M)*sizeof(spx_word16_t)); - st->gain = (spx_word16_t*)speex_alloc((N+M)*sizeof(spx_word16_t)); - st->gain2 = (spx_word16_t*)speex_alloc((N+M)*sizeof(spx_word16_t)); - st->gain_floor = (spx_word16_t*)speex_alloc((N+M)*sizeof(spx_word16_t)); - st->zeta = (spx_word16_t*)speex_alloc((N+M)*sizeof(spx_word16_t)); - - st->S = (spx_word32_t*)speex_alloc(N*sizeof(spx_word32_t)); - st->Smin = (spx_word32_t*)speex_alloc(N*sizeof(spx_word32_t)); - st->Stmp = (spx_word32_t*)speex_alloc(N*sizeof(spx_word32_t)); - st->update_prob = (int*)speex_alloc(N*sizeof(int)); - - st->inbuf = (spx_word16_t*)speex_alloc(N3*sizeof(spx_word16_t)); - st->outbuf = (spx_word16_t*)speex_alloc(N3*sizeof(spx_word16_t)); - - conj_window(st->window, 2*N3); - for (i=2*N3;i<2*st->ps_size;i++) - st->window[i]=Q15_ONE; - - if (N4>0) - { - for (i=N3-1;i>=0;i--) - { - st->window[i+N3+N4]=st->window[i+N3]; - st->window[i+N3]=1; - } - } - for (i=0;inoise[i]=QCONST32(1.f,NOISE_SHIFT); - st->reverb_estimate[i]=0; - st->old_ps[i]=1; - st->gain[i]=Q15_ONE; - st->post[i]=SHL16(1, SNR_SHIFT); - st->prior[i]=SHL16(1, SNR_SHIFT); - } - - for (i=0;iupdate_prob[i] = 1; - for (i=0;iinbuf[i]=0; - st->outbuf[i]=0; - } -#ifndef FIXED_POINT - st->agc_enabled = 0; - st->agc_level = 8000; - st->loudness_weight = (float*)speex_alloc(N*sizeof(float)); - for (i=0;iloudness_weight[i] = .5f*(1.f/(1.f+ff/8000.f))+1.f*exp(-.5f*(ff-3800.f)*(ff-3800.f)/9e5f);*/ - st->loudness_weight[i] = .35f-.35f*ff/16000.f+.73f*exp(-.5f*(ff-3800)*(ff-3800)/9e5f); - if (st->loudness_weight[i]<.01f) - st->loudness_weight[i]=.01f; - st->loudness_weight[i] *= st->loudness_weight[i]; - } - /*st->loudness = pow(AMP_SCALE*st->agc_level,LOUDNESS_EXP);*/ - st->loudness = 1e-15; - st->agc_gain = 1; - st->nb_loudness_adapt = 0; - st->max_gain = 30; - st->max_increase_step = exp(0.11513f * 12.*st->frame_size / st->sampling_rate); - st->max_decrease_step = exp(-0.11513f * 40.*st->frame_size / st->sampling_rate); - st->prev_loudness = 1; - st->init_max = 1; -#endif - st->was_speech = 0; - - st->fft_lookup = spx_fft_init(2*N); - - st->nb_adapt=0; - st->min_count=0; - return st; -} - -void speex_preprocess_state_destroy(SpeexPreprocessState *st) -{ - speex_free(st->frame); - speex_free(st->ft); - speex_free(st->ps); - speex_free(st->gain2); - speex_free(st->gain_floor); - speex_free(st->window); - speex_free(st->noise); - speex_free(st->reverb_estimate); - speex_free(st->old_ps); - speex_free(st->gain); - speex_free(st->prior); - speex_free(st->post); -#ifndef FIXED_POINT - speex_free(st->loudness_weight); -#endif - speex_free(st->echo_noise); - speex_free(st->residual_echo); - - speex_free(st->S); - speex_free(st->Smin); - speex_free(st->Stmp); - speex_free(st->update_prob); - speex_free(st->zeta); - - speex_free(st->inbuf); - speex_free(st->outbuf); - - spx_fft_destroy(st->fft_lookup); - filterbank_destroy(st->bank); - speex_free(st); -} - -/* FIXME: The AGC doesn't work yet with fixed-point*/ -#ifndef FIXED_POINT -static void speex_compute_agc(SpeexPreprocessState *st, spx_word16_t Pframe, spx_word16_t *ft) -{ - int i; - int N = st->ps_size; - float target_gain; - float loudness=1.f; - float rate; - - for (i=2;ips[i]* st->loudness_weight[i]; - } - loudness=sqrt(loudness); - /*if (loudness < 2*pow(st->loudness, 1.0/LOUDNESS_EXP) && - loudness*2 > pow(st->loudness, 1.0/LOUDNESS_EXP))*/ - if (Pframe>.3f) - { - st->nb_loudness_adapt++; - /*rate=2.0f*Pframe*Pframe/(1+st->nb_loudness_adapt);*/ - rate = .03*Pframe*Pframe; - st->loudness = (1-rate)*st->loudness + (rate)*pow(AMP_SCALE*loudness, LOUDNESS_EXP); - st->loudness_accum = (1-rate)*st->loudness_accum + rate; - if (st->init_max < st->max_gain && st->nb_adapt > 20) - st->init_max *= 1.f + .1f*Pframe*Pframe; - } - /*printf ("%f %f %f %f\n", Pframe, loudness, pow(st->loudness, 1.0f/LOUDNESS_EXP), st->loudness2);*/ - - target_gain = AMP_SCALE*st->agc_level*pow(st->loudness/(1e-4+st->loudness_accum), -1.0f/LOUDNESS_EXP); - - if ((Pframe>.5 && st->nb_adapt > 20) || target_gain < st->agc_gain) - { - if (target_gain > st->max_increase_step*st->agc_gain) - target_gain = st->max_increase_step*st->agc_gain; - if (target_gain < st->max_decrease_step*st->agc_gain && loudness < 10*st->prev_loudness) - target_gain = st->max_decrease_step*st->agc_gain; - if (target_gain > st->max_gain) - target_gain = st->max_gain; - if (target_gain > st->init_max) - target_gain = st->init_max; - - st->agc_gain = target_gain; - } - /*fprintf (stderr, "%f %f %f\n", loudness, (float)AMP_SCALE_1*pow(st->loudness, 1.0f/LOUDNESS_EXP), st->agc_gain);*/ - - for (i=0;i<2*N;i++) - ft[i] *= st->agc_gain; - st->prev_loudness = loudness; -} -#endif - -static void preprocess_analysis(SpeexPreprocessState *st, spx_int16_t *x) -{ - int i; - int N = st->ps_size; - int N3 = 2*N - st->frame_size; - int N4 = st->frame_size - N3; - spx_word32_t *ps=st->ps; - - /* 'Build' input frame */ - for (i=0;iframe[i]=st->inbuf[i]; - for (i=0;iframe_size;i++) - st->frame[N3+i]=x[i]; - - /* Update inbuf */ - for (i=0;iinbuf[i]=x[N4+i]; - - /* Windowing */ - for (i=0;i<2*N;i++) - st->frame[i] = MULT16_16_Q15(st->frame[i], st->window[i]); - -#ifdef FIXED_POINT - { - spx_word16_t max_val=0; - for (i=0;i<2*N;i++) - max_val = MAX16(max_val, ABS16(st->frame[i])); - st->frame_shift = 14-spx_ilog2(EXTEND32(max_val)); - for (i=0;i<2*N;i++) - st->frame[i] = SHL16(st->frame[i], st->frame_shift); - } -#endif - - /* Perform FFT */ - spx_fft(st->fft_lookup, st->frame, st->ft); - - /* Power spectrum */ - ps[0]=MULT16_16(st->ft[0],st->ft[0]); - for (i=1;ift[2*i-1],st->ft[2*i-1]) + MULT16_16(st->ft[2*i],st->ft[2*i]); - for (i=0;ips[i] = PSHR32(st->ps[i], 2*st->frame_shift); - - filterbank_compute_bank32(st->bank, ps, ps+N); -} - -static void update_noise_prob(SpeexPreprocessState *st) -{ - int i; - int min_range; - int N = st->ps_size; - - for (i=1;iS[i] = MULT16_32_Q15(QCONST16(.8f,15),st->S[i]) + MULT16_32_Q15(QCONST16(.05f,15),st->ps[i-1]) - + MULT16_32_Q15(QCONST16(.1f,15),st->ps[i]) + MULT16_32_Q15(QCONST16(.05f,15),st->ps[i+1]); - st->S[0] = MULT16_32_Q15(QCONST16(.8f,15),st->S[0]) + MULT16_32_Q15(QCONST16(.2f,15),st->ps[0]); - st->S[N-1] = MULT16_32_Q15(QCONST16(.8f,15),st->S[N-1]) + MULT16_32_Q15(QCONST16(.2f,15),st->ps[N-1]); - - if (st->nb_adapt==1) - { - for (i=0;iSmin[i] = st->Stmp[i] = 0; - } - - if (st->nb_adapt < 100) - min_range = 15; - else if (st->nb_adapt < 1000) - min_range = 50; - else if (st->nb_adapt < 10000) - min_range = 150; - else - min_range = 300; - if (st->min_count > min_range) - { - st->min_count = 0; - for (i=0;iSmin[i] = MIN32(st->Stmp[i], st->S[i]); - st->Stmp[i] = st->S[i]; - } - } else { - for (i=0;iSmin[i] = MIN32(st->Smin[i], st->S[i]); - st->Stmp[i] = MIN32(st->Stmp[i], st->S[i]); - } - } - for (i=0;iS[i]) > ADD32(st->Smin[i],EXTEND32(20))) - st->update_prob[i] = 1; - else - st->update_prob[i] = 0; - /*fprintf (stderr, "%f ", st->S[i]/st->Smin[i]);*/ - /*fprintf (stderr, "%f ", st->update_prob[i]);*/ - } - -} - -#define NOISE_OVERCOMPENS 1. - -void speex_echo_get_residual(SpeexEchoState *st, spx_word32_t *Yout, int len); - -int speex_preprocess(SpeexPreprocessState *st, spx_int16_t *x, spx_int32_t *echo) -{ - return speex_preprocess_run(st, x); -} - -int speex_preprocess_run(SpeexPreprocessState *st, spx_int16_t *x) -{ - int i; - int M; - int N = st->ps_size; - int N3 = 2*N - st->frame_size; - int N4 = st->frame_size - N3; - spx_word32_t *ps=st->ps; - spx_word32_t Zframe; - spx_word16_t Pframe; - spx_word16_t beta, beta_1; - spx_word16_t effective_echo_suppress; - - st->nb_adapt++; - if (st->nb_adapt>20000) - st->nb_adapt = 20000; - st->min_count++; - - beta = MAX16(QCONST16(.03,15),DIV32_16(Q15_ONE,st->nb_adapt)); - beta_1 = Q15_ONE-beta; - M = st->nbands; - /* Deal with residual echo if provided */ - if (st->echo_state) - { - speex_echo_get_residual(st->echo_state, st->residual_echo, N); -#ifndef FIXED_POINT - /* If there are NaNs or ridiculous values, it'll show up in the DC and we just reset everything to zero */ - if (!(st->residual_echo[0] >=0 && st->residual_echo[0]residual_echo[i] = 0; - } -#endif - for (i=0;iecho_noise[i] = MAX32(MULT16_32_Q15(QCONST16(.6f,15),st->echo_noise[i]), st->residual_echo[i]); - filterbank_compute_bank32(st->bank, st->echo_noise, st->echo_noise+N); - } else { - for (i=0;iecho_noise[i] = 0; - } - preprocess_analysis(st, x); - - update_noise_prob(st); - - /* Noise estimation always updated for the 10 first frames */ - /*if (st->nb_adapt<10) - { - for (i=1;iupdate_prob[i] = 0; - } - */ - - /* Update the noise estimate for the frequencies where it can be */ - for (i=0;iupdate_prob[i] || st->ps[i] < PSHR32(st->noise[i], NOISE_SHIFT)) - st->noise[i] = MAX32(EXTEND32(0),MULT16_32_Q15(beta_1,st->noise[i]) + MULT16_32_Q15(beta,SHL32(st->ps[i],NOISE_SHIFT))); - } - filterbank_compute_bank32(st->bank, st->noise, st->noise+N); - - /* Special case for first frame */ - if (st->nb_adapt==1) - for (i=0;iold_ps[i] = ps[i]; - - /* Compute a posteriori SNR */ - for (i=0;inoise[i],NOISE_SHIFT)) , st->echo_noise[i]) , st->reverb_estimate[i]); - - /* A posteriori SNR = ps/noise - 1*/ - st->post[i] = SUB16(DIV32_16_Q8(ps[i],tot_noise), QCONST16(1.f,SNR_SHIFT)); - st->post[i]=MIN16(st->post[i], QCONST16(100.f,SNR_SHIFT)); - - /* Computing update gamma = .1 + .9*(old/(old+noise))^2 */ - gamma = QCONST16(.1f,15)+MULT16_16_Q15(QCONST16(.89f,15),SQR16_Q15(DIV32_16_Q15(st->old_ps[i],ADD32(st->old_ps[i],tot_noise)))); - - /* A priori SNR update = gamma*max(0,post) + (1-gamma)*old/noise */ - st->prior[i] = EXTRACT16(PSHR32(ADD32(MULT16_16(gamma,MAX16(0,st->post[i])), MULT16_16(Q15_ONE-gamma,DIV32_16_Q8(st->old_ps[i],tot_noise))), 15)); - st->prior[i]=MIN16(st->prior[i], QCONST16(100.f,SNR_SHIFT)); - } - - /*print_vec(st->post, N+M, "");*/ - - /* Recursive average of the a priori SNR. A bit smoothed for the psd components */ - st->zeta[0] = PSHR32(ADD32(MULT16_16(QCONST16(.7f,15),st->zeta[0]), MULT16_16(QCONST16(.3f,15),st->prior[0])),15); - for (i=1;izeta[i] = PSHR32(ADD32(ADD32(ADD32(MULT16_16(QCONST16(.7f,15),st->zeta[i]), MULT16_16(QCONST16(.15f,15),st->prior[i])), - MULT16_16(QCONST16(.075f,15),st->prior[i-1])), MULT16_16(QCONST16(.075f,15),st->prior[i+1])),15); - for (i=N-1;izeta[i] = PSHR32(ADD32(MULT16_16(QCONST16(.7f,15),st->zeta[i]), MULT16_16(QCONST16(.3f,15),st->prior[i])),15); - - /* Speech probability of presence for the entire frame is based on the average filterbank a priori SNR */ - Zframe = 0; - for (i=N;izeta[i])); - Pframe = QCONST16(.1f,15)+MULT16_16_Q15(QCONST16(.899f,15),qcurve(DIV32_16(Zframe,st->nbands))); - - effective_echo_suppress = EXTRACT16(PSHR32(ADD32(MULT16_16(SUB16(Q15_ONE,Pframe), st->echo_suppress), MULT16_16(Pframe, st->echo_suppress_active)),15)); - - compute_gain_floor(st->noise_suppress, effective_echo_suppress, st->noise+N, st->echo_noise+N, st->gain_floor+N, M); - - /* Compute Ephraim & Malah gain speech probability of presence for each critical band (Bark scale) - Technically this is actually wrong because the EM gaim assumes a slightly different probability - distribution */ - for (i=N;iprior[i]), 15), ADD16(st->prior[i], SHL32(1,SNR_SHIFT))); - theta = MULT16_32_P15(prior_ratio, QCONST32(1.f,EXPIN_SHIFT)+SHL32(EXTEND32(st->post[i]),EXPIN_SHIFT-SNR_SHIFT)); - - MM = hypergeom_gain(theta); - /* Gain with bound */ - st->gain[i] = EXTRACT16(MIN32(Q15_ONE, MULT16_32_Q15(prior_ratio, MM))); - /* Save old Bark power spectrum */ - st->old_ps[i] = MULT16_32_P15(QCONST16(.2f,15),st->old_ps[i]) + MULT16_32_P15(MULT16_16_P15(QCONST16(.8f,15),SQR16_Q15(st->gain[i])),ps[i]); - - P1 = QCONST16(.199f,15)+MULT16_16_Q15(QCONST16(.8f,15),qcurve (st->zeta[i])); - q = Q15_ONE-MULT16_16_Q15(Pframe,P1); -#ifdef FIXED_POINT - theta = MIN32(theta, EXTEND32(32767)); -/*Q8*/tmp = MULT16_16_Q15((SHL32(1,SNR_SHIFT)+st->prior[i]),EXTRACT16(MIN32(Q15ONE,SHR32(spx_exp(-EXTRACT16(theta)),1)))); - tmp = MIN16(QCONST16(3.,SNR_SHIFT), tmp); /* Prevent overflows in the next line*/ -/*Q8*/tmp = EXTRACT16(PSHR32(MULT16_16(PDIV32_16(SHL32(EXTEND32(q),8),(Q15_ONE-q)),tmp),8)); - st->gain2[i]=DIV32_16(SHL32(EXTEND32(32767),SNR_SHIFT), ADD16(256,tmp)); -#else - st->gain2[i]=1/(1.f + (q/(1.f-q))*(1+st->prior[i])*exp(-theta)); -#endif - } - /* Convert the EM gains and speech prob to linear frequency */ - filterbank_compute_psd16(st->bank,st->gain2+N, st->gain2); - filterbank_compute_psd16(st->bank,st->gain+N, st->gain); - - /* Use 1 for linear gain resolution (best) or 0 for Bark gain resolution (faster) */ - if (1) - { - filterbank_compute_psd16(st->bank,st->gain_floor+N, st->gain_floor); - - /* Compute gain according to the Ephraim-Malah algorithm -- linear frequency */ - for (i=0;iprior[i]), 15), ADD16(st->prior[i], SHL32(1,SNR_SHIFT))); - theta = MULT16_32_P15(prior_ratio, QCONST32(1.f,EXPIN_SHIFT)+SHL32(EXTEND32(st->post[i]),EXPIN_SHIFT-SNR_SHIFT)); - - /* Optimal estimator for loudness domain */ - MM = hypergeom_gain(theta); - /* EM gain with bound */ - g = EXTRACT16(MIN32(Q15_ONE, MULT16_32_Q15(prior_ratio, MM))); - /* Interpolated speech probability of presence */ - p = st->gain2[i]; - - /* Constrain the gain to be close to the Bark scale gain */ - if (MULT16_16_Q15(QCONST16(.333f,15),g) > st->gain[i]) - g = MULT16_16(3,st->gain[i]); - st->gain[i] = g; - - /* Save old power spectrum */ - st->old_ps[i] = MULT16_32_P15(QCONST16(.2f,15),st->old_ps[i]) + MULT16_32_P15(MULT16_16_P15(QCONST16(.8f,15),SQR16_Q15(st->gain[i])),ps[i]); - - /* Apply gain floor */ - if (st->gain[i] < st->gain_floor[i]) - st->gain[i] = st->gain_floor[i]; - - /* Exponential decay model for reverberation (unused) */ - /*st->reverb_estimate[i] = st->reverb_decay*st->reverb_estimate[i] + st->reverb_decay*st->reverb_level*st->gain[i]*st->gain[i]*st->ps[i];*/ - - /* Take into account speech probability of presence (loudness domain MMSE estimator) */ - /* gain2 = [p*sqrt(gain)+(1-p)*sqrt(gain _floor) ]^2 */ - tmp = MULT16_16_P15(p,spx_sqrt(SHL32(EXTEND32(st->gain[i]),15))) + MULT16_16_P15(SUB16(Q15_ONE,p),spx_sqrt(SHL32(EXTEND32(st->gain_floor[i]),15))); - st->gain2[i]=SQR16_Q15(tmp); - - /* Use this if you want a log-domain MMSE estimator instead */ - /*st->gain2[i] = pow(st->gain[i], p) * pow(st->gain_floor[i],1.f-p);*/ - } - } else { - for (i=N;igain2[i]; - st->gain[i] = MAX16(st->gain[i], st->gain_floor[i]); - tmp = MULT16_16_P15(p,spx_sqrt(SHL32(EXTEND32(st->gain[i]),15))) + MULT16_16_P15(SUB16(Q15_ONE,p),spx_sqrt(SHL32(EXTEND32(st->gain_floor[i]),15))); - st->gain2[i]=SQR16_Q15(tmp); - } - filterbank_compute_psd16(st->bank,st->gain2+N, st->gain2); - } - - /* If noise suppression is off, don't apply the gain (but then why call this in the first place!) */ - if (!st->denoise_enabled) - { - for (i=0;igain2[i]=Q15_ONE; - } - - /* Apply computed gain */ - for (i=1;ift[2*i-1] = MULT16_16_P15(st->gain2[i],st->ft[2*i-1]); - st->ft[2*i] = MULT16_16_P15(st->gain2[i],st->ft[2*i]); - } - st->ft[0] = MULT16_16_P15(st->gain2[0],st->ft[0]); - st->ft[2*N-1] = MULT16_16_P15(st->gain2[N-1],st->ft[2*N-1]); - - /*FIXME: This *will* not work for fixed-point */ -#ifndef FIXED_POINT - if (st->agc_enabled) - speex_compute_agc(st, Pframe, st->ft); -#endif - - /* Inverse FFT with 1/N scaling */ - spx_ifft(st->fft_lookup, st->ft, st->frame); - /* Scale back to original (lower) amplitude */ - for (i=0;i<2*N;i++) - st->frame[i] = PSHR16(st->frame[i], st->frame_shift); - - /*FIXME: This *will* not work for fixed-point */ -#ifndef FIXED_POINT - if (st->agc_enabled) - { - float max_sample=0; - for (i=0;i<2*N;i++) - if (fabs(st->frame[i])>max_sample) - max_sample = fabs(st->frame[i]); - if (max_sample>28000.f) - { - float damp = 28000.f/max_sample; - for (i=0;i<2*N;i++) - st->frame[i] *= damp; - } - } -#endif - - /* Synthesis window (for WOLA) */ - for (i=0;i<2*N;i++) - st->frame[i] = MULT16_16_Q15(st->frame[i], st->window[i]); - - /* Perform overlap and add */ - for (i=0;ioutbuf[i] + st->frame[i]; - for (i=0;iframe[N3+i]; - - /* Update outbuf */ - for (i=0;ioutbuf[i] = st->frame[st->frame_size+i]; - - /* FIXME: This VAD is a kludge */ - if (st->vad_enabled) - { - if (Pframe > st->speech_prob_start || (st->was_speech && Pframe > st->speech_prob_continue)) - { - st->was_speech=1; - return 1; - } else - { - st->was_speech=0; - return 0; - } - } else { - return 1; - } -} - -void speex_preprocess_estimate_update(SpeexPreprocessState *st, spx_int16_t *x) -{ - int i; - int N = st->ps_size; - int N3 = 2*N - st->frame_size; - int M; - spx_word32_t *ps=st->ps; - - M = st->nbands; - st->min_count++; - - preprocess_analysis(st, x); - - update_noise_prob(st); - - for (i=1;iupdate_prob[i] || st->ps[i] < PSHR32(st->noise[i],NOISE_SHIFT)) - { - st->noise[i] = MULT16_32_Q15(QCONST16(.95f,15),st->noise[i]) + MULT16_32_Q15(QCONST16(.05f,15),SHL32(st->ps[i],NOISE_SHIFT)); - } - } - - for (i=0;ioutbuf[i] = MULT16_16_Q15(x[st->frame_size-N3+i],st->window[st->frame_size+i]); - - /* Save old power spectrum */ - for (i=0;iold_ps[i] = ps[i]; - - for (i=0;ireverb_estimate[i] = MULT16_32_Q15(st->reverb_decay, st->reverb_estimate[i]); -} - - -int speex_preprocess_ctl(SpeexPreprocessState *state, int request, void *ptr) -{ - int i; - SpeexPreprocessState *st; - st=(SpeexPreprocessState*)state; - switch(request) - { - case SPEEX_PREPROCESS_SET_DENOISE: - st->denoise_enabled = (*(spx_int32_t*)ptr); - break; - case SPEEX_PREPROCESS_GET_DENOISE: - (*(spx_int32_t*)ptr) = st->denoise_enabled; - break; -#ifndef FIXED_POINT - case SPEEX_PREPROCESS_SET_AGC: - st->agc_enabled = (*(spx_int32_t*)ptr); - break; - case SPEEX_PREPROCESS_GET_AGC: - (*(spx_int32_t*)ptr) = st->agc_enabled; - break; -#ifndef DISABLE_FLOAT_API - case SPEEX_PREPROCESS_SET_AGC_LEVEL: - st->agc_level = (*(float*)ptr); - if (st->agc_level<1) - st->agc_level=1; - if (st->agc_level>32768) - st->agc_level=32768; - break; - case SPEEX_PREPROCESS_GET_AGC_LEVEL: - (*(float*)ptr) = st->agc_level; - break; -#endif /* #ifndef DISABLE_FLOAT_API */ - case SPEEX_PREPROCESS_SET_AGC_INCREMENT: - st->max_increase_step = exp(0.11513f * (*(spx_int32_t*)ptr)*st->frame_size / st->sampling_rate); - break; - case SPEEX_PREPROCESS_GET_AGC_INCREMENT: - (*(spx_int32_t*)ptr) = floor(.5+8.6858*log(st->max_increase_step)*st->sampling_rate/st->frame_size); - break; - case SPEEX_PREPROCESS_SET_AGC_DECREMENT: - st->max_decrease_step = exp(0.11513f * (*(spx_int32_t*)ptr)*st->frame_size / st->sampling_rate); - break; - case SPEEX_PREPROCESS_GET_AGC_DECREMENT: - (*(spx_int32_t*)ptr) = floor(.5+8.6858*log(st->max_decrease_step)*st->sampling_rate/st->frame_size); - break; - case SPEEX_PREPROCESS_SET_AGC_MAX_GAIN: - st->max_gain = exp(0.11513f * (*(spx_int32_t*)ptr)); - break; - case SPEEX_PREPROCESS_GET_AGC_MAX_GAIN: - (*(spx_int32_t*)ptr) = floor(.5+8.6858*log(st->max_gain)); - break; -#endif - case SPEEX_PREPROCESS_SET_VAD: - speex_warning("The VAD has been replaced by a hack pending a complete rewrite"); - st->vad_enabled = (*(spx_int32_t*)ptr); - break; - case SPEEX_PREPROCESS_GET_VAD: - (*(spx_int32_t*)ptr) = st->vad_enabled; - break; - - case SPEEX_PREPROCESS_SET_DEREVERB: - st->dereverb_enabled = (*(spx_int32_t*)ptr); - for (i=0;ips_size;i++) - st->reverb_estimate[i]=0; - break; - case SPEEX_PREPROCESS_GET_DEREVERB: - (*(spx_int32_t*)ptr) = st->dereverb_enabled; - break; - - case SPEEX_PREPROCESS_SET_DEREVERB_LEVEL: - /* FIXME: Re-enable when de-reverberation is actually enabled again */ - /*st->reverb_level = (*(float*)ptr);*/ - break; - case SPEEX_PREPROCESS_GET_DEREVERB_LEVEL: - /* FIXME: Re-enable when de-reverberation is actually enabled again */ - /*(*(float*)ptr) = st->reverb_level;*/ - break; - - case SPEEX_PREPROCESS_SET_DEREVERB_DECAY: - /* FIXME: Re-enable when de-reverberation is actually enabled again */ - /*st->reverb_decay = (*(float*)ptr);*/ - break; - case SPEEX_PREPROCESS_GET_DEREVERB_DECAY: - /* FIXME: Re-enable when de-reverberation is actually enabled again */ - /*(*(float*)ptr) = st->reverb_decay;*/ - break; - - case SPEEX_PREPROCESS_SET_PROB_START: - *(spx_int32_t*)ptr = MIN32(100,MAX32(0, *(spx_int32_t*)ptr)); - st->speech_prob_start = DIV32_16(MULT16_16(Q15ONE,*(spx_int32_t*)ptr), 100); - break; - case SPEEX_PREPROCESS_GET_PROB_START: - (*(spx_int32_t*)ptr) = MULT16_16_Q15(st->speech_prob_start, 100); - break; - - case SPEEX_PREPROCESS_SET_PROB_CONTINUE: - *(spx_int32_t*)ptr = MIN32(100,MAX32(0, *(spx_int32_t*)ptr)); - st->speech_prob_continue = DIV32_16(MULT16_16(Q15ONE,*(spx_int32_t*)ptr), 100); - break; - case SPEEX_PREPROCESS_GET_PROB_CONTINUE: - (*(spx_int32_t*)ptr) = MULT16_16_Q15(st->speech_prob_continue, 100); - break; - - case SPEEX_PREPROCESS_SET_NOISE_SUPPRESS: - st->noise_suppress = -ABS(*(spx_int32_t*)ptr); - break; - case SPEEX_PREPROCESS_GET_NOISE_SUPPRESS: - (*(spx_int32_t*)ptr) = st->noise_suppress; - break; - case SPEEX_PREPROCESS_SET_ECHO_SUPPRESS: - st->echo_suppress = -ABS(*(spx_int32_t*)ptr); - break; - case SPEEX_PREPROCESS_GET_ECHO_SUPPRESS: - (*(spx_int32_t*)ptr) = st->echo_suppress; - break; - case SPEEX_PREPROCESS_SET_ECHO_SUPPRESS_ACTIVE: - st->echo_suppress_active = -ABS(*(spx_int32_t*)ptr); - break; - case SPEEX_PREPROCESS_GET_ECHO_SUPPRESS_ACTIVE: - (*(spx_int32_t*)ptr) = st->echo_suppress_active; - break; - case SPEEX_PREPROCESS_SET_ECHO_STATE: - st->echo_state = (SpeexEchoState*)ptr; - break; - case SPEEX_PREPROCESS_GET_ECHO_STATE: - ptr = (void*)st->echo_state; - break; -#ifndef FIXED_POINT - case SPEEX_PREPROCESS_GET_AGC_LOUDNESS: - (*(spx_int32_t*)ptr) = pow(st->loudness, 1.0/LOUDNESS_EXP); - break; -#endif - - default: - speex_warning_int("Unknown speex_preprocess_ctl request: ", request); - return -1; - } - return 0; -} diff --git a/apps/codecs/libspeex/pseudofloat.h b/apps/codecs/libspeex/pseudofloat.h deleted file mode 100644 index 448dd61ffe..0000000000 --- a/apps/codecs/libspeex/pseudofloat.h +++ /dev/null @@ -1,382 +0,0 @@ -/* Copyright (C) 2005 Jean-Marc Valin */ -/** - @file pseudofloat.h - @brief Pseudo-floating point - * This header file provides a lightweight floating point type for - * use on fixed-point platforms when a large dynamic range is - * required. The new type is not compatible with the 32-bit IEEE format, - * it is not even remotely as accurate as 32-bit floats, and is not - * even guaranteed to produce even remotely correct results for code - * other than Speex. It makes all kinds of shortcuts that are acceptable - * for Speex, but may not be acceptable for your application. You're - * quite welcome to reuse this code and improve it, but don't assume - * it works out of the box. Most likely, it doesn't. - */ -/* - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of the Xiph.org Foundation nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef PSEUDOFLOAT_H -#define PSEUDOFLOAT_H - -#include "arch.h" -#include "os_support.h" -#include "math_approx.h" -#include - -#ifdef FIXED_POINT - -typedef struct { - spx_int16_t m; - spx_int16_t e; -} spx_float_t; - -static const spx_float_t FLOAT_ZERO = {0,0}; -static const spx_float_t FLOAT_ONE = {16384,-14}; -static const spx_float_t FLOAT_HALF = {16384,-15}; - -#ifdef MIN -#undef MIN -#endif -#define MIN(a,b) ((a)<(b)?(a):(b)) -static inline spx_float_t PSEUDOFLOAT(spx_int32_t x) -{ - int e=0; - int sign=0; - if (x<0) - { - sign = 1; - x = -x; - } - if (x==0) - { - spx_float_t r = {0,0}; - return r; - } - e = spx_ilog2(ABS32(x))-14; - x = VSHR32(x, e); - if (sign) - { - spx_float_t r; - r.m = -x; - r.e = e; - return r; - } - else - { - spx_float_t r; - r.m = x; - r.e = e; - return r; - } -} - - -static inline spx_float_t FLOAT_ADD(spx_float_t a, spx_float_t b) -{ - spx_float_t r; - if (a.m==0) - return b; - else if (b.m==0) - return a; - if ((a).e > (b).e) - { - r.m = ((a).m>>1) + ((b).m>>MIN(15,(a).e-(b).e+1)); - r.e = (a).e+1; - } - else - { - r.m = ((b).m>>1) + ((a).m>>MIN(15,(b).e-(a).e+1)); - r.e = (b).e+1; - } - if (r.m>0) - { - if (r.m<16384) - { - r.m<<=1; - r.e-=1; - } - } else { - if (r.m>-16384) - { - r.m<<=1; - r.e-=1; - } - } - /*printf ("%f + %f = %f\n", REALFLOAT(a), REALFLOAT(b), REALFLOAT(r));*/ - return r; -} - -static inline spx_float_t FLOAT_SUB(spx_float_t a, spx_float_t b) -{ - spx_float_t r; - if (a.m==0) - return b; - else if (b.m==0) - return a; - if ((a).e > (b).e) - { - r.m = ((a).m>>1) - ((b).m>>MIN(15,(a).e-(b).e+1)); - r.e = (a).e+1; - } - else - { - r.m = ((a).m>>MIN(15,(b).e-(a).e+1)) - ((b).m>>1); - r.e = (b).e+1; - } - if (r.m>0) - { - if (r.m<16384) - { - r.m<<=1; - r.e-=1; - } - } else { - if (r.m>-16384) - { - r.m<<=1; - r.e-=1; - } - } - /*printf ("%f + %f = %f\n", REALFLOAT(a), REALFLOAT(b), REALFLOAT(r));*/ - return r; -} - -static inline int FLOAT_LT(spx_float_t a, spx_float_t b) -{ - if (a.m==0) - return b.m>0; - else if (b.m==0) - return a.m<0; - if ((a).e > (b).e) - return ((a).m>>1) < ((b).m>>MIN(15,(a).e-(b).e+1)); - else - return ((b).m>>1) > ((a).m>>MIN(15,(b).e-(a).e+1)); - -} - -static inline int FLOAT_GT(spx_float_t a, spx_float_t b) -{ - return FLOAT_LT(b,a); -} - -static inline spx_float_t FLOAT_MULT(spx_float_t a, spx_float_t b) -{ - spx_float_t r; - r.m = (spx_int16_t)((spx_int32_t)(a).m*(b).m>>15); - r.e = (a).e+(b).e+15; - if (r.m>0) - { - if (r.m<16384) - { - r.m<<=1; - r.e-=1; - } - } else { - if (r.m>-16384) - { - r.m<<=1; - r.e-=1; - } - } - /*printf ("%f * %f = %f\n", REALFLOAT(a), REALFLOAT(b), REALFLOAT(r));*/ - return r; -} - -static inline spx_float_t FLOAT_AMULT(spx_float_t a, spx_float_t b) -{ - spx_float_t r; - r.m = (spx_int16_t)((spx_int32_t)(a).m*(b).m>>15); - r.e = (a).e+(b).e+15; - return r; -} - - -static inline spx_float_t FLOAT_SHL(spx_float_t a, int b) -{ - spx_float_t r; - r.m = a.m; - r.e = a.e+b; - return r; -} - -static inline spx_int16_t FLOAT_EXTRACT16(spx_float_t a) -{ - if (a.e<0) - return EXTRACT16((EXTEND32(a.m)+(EXTEND32(1)<<(-a.e-1)))>>-a.e); - else - return a.m<>-a.e; - else - return EXTEND32(a.m)<=SHL32(EXTEND32(b.m-1),15)) - { - a >>= 1; - e++; - } - r.m = DIV32_16(a,b.m); - r.e = e-b.e; - return r; -} - - -/* Do NOT attempt to divide by a negative number */ -static inline spx_float_t FLOAT_DIV32(spx_word32_t a, spx_word32_t b) -{ - int e0=0,e=0; - spx_float_t r; - if (a==0) - { - return FLOAT_ZERO; - } - if (b>32767) - { - e0 = spx_ilog2(b)-14; - b = VSHR32(b, e0); - e0 = -e0; - } - e = spx_ilog2(ABS32(a))-spx_ilog2(b-1)-15; - a = VSHR32(a, e); - if (ABS32(a)>=SHL32(EXTEND32(b-1),15)) - { - a >>= 1; - e++; - } - e += e0; - r.m = DIV32_16(a,b); - r.e = e; - return r; -} - -/* Do NOT attempt to divide by a negative number */ -static inline spx_float_t FLOAT_DIVU(spx_float_t a, spx_float_t b) -{ - int e=0; - spx_int32_t num; - spx_float_t r; - if (b.m<=0) - { - speex_warning_int("Attempted to divide by", b.m); - return FLOAT_ONE; - } - num = a.m; - a.m = ABS16(a.m); - while (a.m >= b.m) - { - e++; - a.m >>= 1; - } - num = num << (15-e); - r.m = DIV32_16(num,b.m); - r.e = a.e-b.e-15+e; - return r; -} - -static inline spx_float_t FLOAT_SQRT(spx_float_t a) -{ - spx_float_t r; - spx_int32_t m; - m = SHL32(EXTEND32(a.m), 14); - r.e = a.e - 14; - if (r.e & 1) - { - r.e -= 1; - m <<= 1; - } - r.e >>= 1; - r.m = spx_sqrt(m); - return r; -} - -#else - -#define spx_float_t float -#define FLOAT_ZERO 0.f -#define FLOAT_ONE 1.f -#define FLOAT_HALF 0.5f -#define PSEUDOFLOAT(x) (x) -#define FLOAT_MULT(a,b) ((a)*(b)) -#define FLOAT_AMULT(a,b) ((a)*(b)) -#define FLOAT_MUL32(a,b) ((a)*(b)) -#define FLOAT_DIV32(a,b) ((a)/(b)) -#define FLOAT_EXTRACT16(a) (a) -#define FLOAT_EXTRACT32(a) (a) -#define FLOAT_ADD(a,b) ((a)+(b)) -#define FLOAT_SUB(a,b) ((a)-(b)) -#define REALFLOAT(x) (x) -#define FLOAT_DIV32_FLOAT(a,b) ((a)/(b)) -#define FLOAT_MUL32U(a,b) ((a)*(b)) -#define FLOAT_SHL(a,b) (a) -#define FLOAT_LT(a,b) ((a)<(b)) -#define FLOAT_GT(a,b) ((a)>(b)) -#define FLOAT_DIVU(a,b) ((a)/(b)) -#define FLOAT_SQRT(a) (spx_sqrt(a)) - -#endif - -#endif diff --git a/apps/codecs/libspeex/quant_lsp.c b/apps/codecs/libspeex/quant_lsp.c deleted file mode 100644 index 9b9104c842..0000000000 --- a/apps/codecs/libspeex/quant_lsp.c +++ /dev/null @@ -1,391 +0,0 @@ -/* Copyright (C) 2002 Jean-Marc Valin - File: quant_lsp.c - LSP vector quantization - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of the Xiph.org Foundation nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifdef HAVE_CONFIG_H -#include "config-speex.h" -#endif - -#include "quant_lsp.h" -#include "os_support.h" -#include -#ifndef M_PI -#define M_PI 3.14159265358979323846 -#endif - -#include "arch.h" - -#ifdef BFIN_ASM -#include "quant_lsp_bfin.h" -#endif - -#ifdef FIXED_POINT - -#define LSP_LINEAR(i) (SHL16(i+1,11)) -#define LSP_LINEAR_HIGH(i) (ADD16(MULT16_16_16(i,2560),6144)) -#define LSP_DIV_256(x) (SHL16((spx_word16_t)x, 5)) -#define LSP_DIV_512(x) (SHL16((spx_word16_t)x, 4)) -#define LSP_DIV_1024(x) (SHL16((spx_word16_t)x, 3)) -#define LSP_PI 25736 - -#else - -#define LSP_LINEAR(i) (.25*(i)+.25) -#define LSP_LINEAR_HIGH(i) (.3125*(i)+.75) -#define LSP_SCALE 256. -#define LSP_DIV_256(x) (0.0039062*(x)) -#define LSP_DIV_512(x) (0.0019531*(x)) -#define LSP_DIV_1024(x) (0.00097656*(x)) -#define LSP_PI M_PI - -#endif - -#ifndef SPEEX_DISABLE_ENCODER -static void compute_quant_weights(spx_lsp_t *qlsp, spx_word16_t *quant_weight, int order) -{ - int i; - spx_word16_t tmp1, tmp2; - for (i=0;i tmp2 ? tmp1 : tmp2; - }*/ - - for (i=0;i>> 16;\n\t" -" R1 = (A1 += R2.L*R0.H) (IS);\n\t" -"lwq4: R3 = R3 + R1;\n\t" - -" cc =R3<%0;\n\t" -" if cc %0=R3;\n\t" -" if cc %1=R5;\n\t" -"lwq2: R5 += 1;\n\t" -" L0 = 0;\n\t" -" L1 = 0;\n\t" - : "=&d" (best_dist), "=&d" (best_id) - : "a" (x), "a" (weight), "b" (cdbk), "a" (nbVec), "a" (nbDim) - : "I0", "I1", "P2", "R0", "R1", "R2", "R3", "R5", "A1", - "L0", "L1", "B0", "B1" - ); - - for (j=0;j -static void *speex_alloc (int size) {return calloc(size,1);} -static void *speex_realloc (void *ptr, int size) {return realloc(ptr, size);} -static void speex_free (void *ptr) {free(ptr);} -#include "speex_resampler.h" -#include "arch.h" -#else /* OUTSIDE_SPEEX */ - -#include "speex/speex_resampler.h" -#include "arch.h" -#include "os_support.h" -#endif /* OUTSIDE_SPEEX */ - -#include - -#ifndef M_PI -#define M_PI 3.14159263 -#endif - -#ifdef FIXED_POINT -#define WORD2INT(x) ((x) < -32767 ? -32768 : ((x) > 32766 ? 32767 : (x))) -#else -#define WORD2INT(x) ((x) < -32767.5f ? -32768 : ((x) > 32766.5f ? 32767 : floor(.5+(x)))) -#endif - -/*#define float double*/ -#define FILTER_SIZE 64 -#define OVERSAMPLE 8 - -#define IMAX(a,b) ((a) > (b) ? (a) : (b)) -#define IMIN(a,b) ((a) < (b) ? (a) : (b)) - -#ifndef NULL -#define NULL 0 -#endif - -typedef int (*resampler_basic_func)(SpeexResamplerState *, spx_uint32_t , const spx_word16_t *, spx_uint32_t *, spx_word16_t *, spx_uint32_t *); - -struct SpeexResamplerState_ { - spx_uint32_t in_rate; - spx_uint32_t out_rate; - spx_uint32_t num_rate; - spx_uint32_t den_rate; - - int quality; - spx_uint32_t nb_channels; - spx_uint32_t filt_len; - spx_uint32_t mem_alloc_size; - int int_advance; - int frac_advance; - float cutoff; - spx_uint32_t oversample; - int initialised; - int started; - - /* These are per-channel */ - spx_int32_t *last_sample; - spx_uint32_t *samp_frac_num; - spx_uint32_t *magic_samples; - - spx_word16_t *mem; - spx_word16_t *sinc_table; - spx_uint32_t sinc_table_length; - resampler_basic_func resampler_ptr; - - int in_stride; - int out_stride; -} ; - -static double kaiser12_table[68] = { - 0.99859849, 1.00000000, 0.99859849, 0.99440475, 0.98745105, 0.97779076, - 0.96549770, 0.95066529, 0.93340547, 0.91384741, 0.89213598, 0.86843014, - 0.84290116, 0.81573067, 0.78710866, 0.75723148, 0.72629970, 0.69451601, - 0.66208321, 0.62920216, 0.59606986, 0.56287762, 0.52980938, 0.49704014, - 0.46473455, 0.43304576, 0.40211431, 0.37206735, 0.34301800, 0.31506490, - 0.28829195, 0.26276832, 0.23854851, 0.21567274, 0.19416736, 0.17404546, - 0.15530766, 0.13794294, 0.12192957, 0.10723616, 0.09382272, 0.08164178, - 0.07063950, 0.06075685, 0.05193064, 0.04409466, 0.03718069, 0.03111947, - 0.02584161, 0.02127838, 0.01736250, 0.01402878, 0.01121463, 0.00886058, - 0.00691064, 0.00531256, 0.00401805, 0.00298291, 0.00216702, 0.00153438, - 0.00105297, 0.00069463, 0.00043489, 0.00025272, 0.00013031, 0.0000527734, - 0.00001000, 0.00000000}; -/* -static double kaiser12_table[36] = { - 0.99440475, 1.00000000, 0.99440475, 0.97779076, 0.95066529, 0.91384741, - 0.86843014, 0.81573067, 0.75723148, 0.69451601, 0.62920216, 0.56287762, - 0.49704014, 0.43304576, 0.37206735, 0.31506490, 0.26276832, 0.21567274, - 0.17404546, 0.13794294, 0.10723616, 0.08164178, 0.06075685, 0.04409466, - 0.03111947, 0.02127838, 0.01402878, 0.00886058, 0.00531256, 0.00298291, - 0.00153438, 0.00069463, 0.00025272, 0.0000527734, 0.00000500, 0.00000000}; -*/ -static double kaiser10_table[36] = { - 0.99537781, 1.00000000, 0.99537781, 0.98162644, 0.95908712, 0.92831446, - 0.89005583, 0.84522401, 0.79486424, 0.74011713, 0.68217934, 0.62226347, - 0.56155915, 0.50119680, 0.44221549, 0.38553619, 0.33194107, 0.28205962, - 0.23636152, 0.19515633, 0.15859932, 0.12670280, 0.09935205, 0.07632451, - 0.05731132, 0.04193980, 0.02979584, 0.02044510, 0.01345224, 0.00839739, - 0.00488951, 0.00257636, 0.00115101, 0.00035515, 0.00000000, 0.00000000}; - -static double kaiser8_table[36] = { - 0.99635258, 1.00000000, 0.99635258, 0.98548012, 0.96759014, 0.94302200, - 0.91223751, 0.87580811, 0.83439927, 0.78875245, 0.73966538, 0.68797126, - 0.63451750, 0.58014482, 0.52566725, 0.47185369, 0.41941150, 0.36897272, - 0.32108304, 0.27619388, 0.23465776, 0.19672670, 0.16255380, 0.13219758, - 0.10562887, 0.08273982, 0.06335451, 0.04724088, 0.03412321, 0.02369490, - 0.01563093, 0.00959968, 0.00527363, 0.00233883, 0.00050000, 0.00000000}; - -static double kaiser6_table[36] = { - 0.99733006, 1.00000000, 0.99733006, 0.98935595, 0.97618418, 0.95799003, - 0.93501423, 0.90755855, 0.87598009, 0.84068475, 0.80211977, 0.76076565, - 0.71712752, 0.67172623, 0.62508937, 0.57774224, 0.53019925, 0.48295561, - 0.43647969, 0.39120616, 0.34752997, 0.30580127, 0.26632152, 0.22934058, - 0.19505503, 0.16360756, 0.13508755, 0.10953262, 0.08693120, 0.06722600, - 0.05031820, 0.03607231, 0.02432151, 0.01487334, 0.00752000, 0.00000000}; - -struct FuncDef { - double *table; - int oversample; -}; - -static struct FuncDef _KAISER12 = {kaiser12_table, 64}; -#define KAISER12 (&_KAISER12) -/*static struct FuncDef _KAISER12 = {kaiser12_table, 32}; -#define KAISER12 (&_KAISER12)*/ -static struct FuncDef _KAISER10 = {kaiser10_table, 32}; -#define KAISER10 (&_KAISER10) -static struct FuncDef _KAISER8 = {kaiser8_table, 32}; -#define KAISER8 (&_KAISER8) -static struct FuncDef _KAISER6 = {kaiser6_table, 32}; -#define KAISER6 (&_KAISER6) - -struct QualityMapping { - int base_length; - int oversample; - float downsample_bandwidth; - float upsample_bandwidth; - struct FuncDef *window_func; -}; - - -/* This table maps conversion quality to internal parameters. There are two - reasons that explain why the up-sampling bandwidth is larger than the - down-sampling bandwidth: - 1) When up-sampling, we can assume that the spectrum is already attenuated - close to the Nyquist rate (from an A/D or a previous resampling filter) - 2) Any aliasing that occurs very close to the Nyquist rate will be masked - by the sinusoids/noise just below the Nyquist rate (guaranteed only for - up-sampling). -*/ -static const struct QualityMapping quality_map[11] = { - { 8, 4, 0.830f, 0.860f, KAISER6 }, /* Q0 */ - { 16, 4, 0.850f, 0.880f, KAISER6 }, /* Q1 */ - { 32, 4, 0.882f, 0.910f, KAISER6 }, /* Q2 */ /* 82.3% cutoff ( ~60 dB stop) 6 */ - { 48, 8, 0.895f, 0.917f, KAISER8 }, /* Q3 */ /* 84.9% cutoff ( ~80 dB stop) 8 */ - { 64, 8, 0.921f, 0.940f, KAISER8 }, /* Q4 */ /* 88.7% cutoff ( ~80 dB stop) 8 */ - { 80, 16, 0.922f, 0.940f, KAISER10}, /* Q5 */ /* 89.1% cutoff (~100 dB stop) 10 */ - { 96, 16, 0.940f, 0.945f, KAISER10}, /* Q6 */ /* 91.5% cutoff (~100 dB stop) 10 */ - {128, 16, 0.950f, 0.950f, KAISER10}, /* Q7 */ /* 93.1% cutoff (~100 dB stop) 10 */ - {160, 16, 0.960f, 0.960f, KAISER10}, /* Q8 */ /* 94.5% cutoff (~100 dB stop) 10 */ - {192, 32, 0.968f, 0.968f, KAISER12}, /* Q9 */ /* 95.5% cutoff (~100 dB stop) 10 */ - {256, 32, 0.975f, 0.975f, KAISER12}, /* Q10 */ /* 96.6% cutoff (~100 dB stop) 10 */ -}; -/*8,24,40,56,80,104,128,160,200,256,320*/ -static double compute_func(float x, struct FuncDef *func) -{ - float y, frac; - double interp[4]; - int ind; - y = x*func->oversample; - ind = (int)floor(y); - frac = (y-ind); - /* CSE with handle the repeated powers */ - interp[3] = -0.1666666667*frac + 0.1666666667*(frac*frac*frac); - interp[2] = frac + 0.5*(frac*frac) - 0.5*(frac*frac*frac); - /*interp[2] = 1.f - 0.5f*frac - frac*frac + 0.5f*frac*frac*frac;*/ - interp[0] = -0.3333333333*frac + 0.5*(frac*frac) - 0.1666666667*(frac*frac*frac); - /* Just to make sure we don't have rounding problems */ - interp[1] = 1.f-interp[3]-interp[2]-interp[0]; - - /*sum = frac*accum[1] + (1-frac)*accum[2];*/ - return interp[0]*func->table[ind] + interp[1]*func->table[ind+1] + interp[2]*func->table[ind+2] + interp[3]*func->table[ind+3]; -} - -#if 0 -#include -int main(int argc, char **argv) -{ - int i; - for (i=0;i<256;i++) - { - printf ("%f\n", compute_func(i/256., KAISER12)); - } - return 0; -} -#endif - -#ifdef FIXED_POINT -/* The slow way of computing a sinc for the table. Should improve that some day */ -static spx_word16_t sinc(float cutoff, float x, int N, struct FuncDef *window_func) -{ - /*fprintf (stderr, "%f ", x);*/ - float xx = x * cutoff; - if (fabs(x)<1e-6f) - return WORD2INT(32768.*cutoff); - else if (fabs(x) > .5f*N) - return 0; - /*FIXME: Can it really be any slower than this? */ - return WORD2INT(32768.*cutoff*sin(M_PI*xx)/(M_PI*xx) * compute_func(fabs(2.*x/N), window_func)); -} -#else -/* The slow way of computing a sinc for the table. Should improve that some day */ -static spx_word16_t sinc(float cutoff, float x, int N, struct FuncDef *window_func) -{ - /*fprintf (stderr, "%f ", x);*/ - float xx = x * cutoff; - if (fabs(x)<1e-6) - return cutoff; - else if (fabs(x) > .5*N) - return 0; - /*FIXME: Can it really be any slower than this? */ - return cutoff*sin(M_PI*xx)/(M_PI*xx) * compute_func(fabs(2.*x/N), window_func); -} -#endif - -#ifdef FIXED_POINT -static void cubic_coef(spx_word16_t x, spx_word16_t interp[4]) -{ - /* Compute interpolation coefficients. I'm not sure whether this corresponds to cubic interpolation - but I know it's MMSE-optimal on a sinc */ - spx_word16_t x2, x3; - x2 = MULT16_16_P15(x, x); - x3 = MULT16_16_P15(x, x2); - interp[0] = PSHR32(MULT16_16(QCONST16(-0.16667f, 15),x) + MULT16_16(QCONST16(0.16667f, 15),x3),15); - interp[1] = EXTRACT16(EXTEND32(x) + SHR32(SUB32(EXTEND32(x2),EXTEND32(x3)),1)); - interp[3] = PSHR32(MULT16_16(QCONST16(-0.33333f, 15),x) + MULT16_16(QCONST16(.5f,15),x2) - MULT16_16(QCONST16(0.16667f, 15),x3),15); - /* Just to make sure we don't have rounding problems */ - interp[2] = Q15_ONE-interp[0]-interp[1]-interp[3]; - if (interp[2]<32767) - interp[2]+=1; -} -#else -static void cubic_coef(spx_word16_t frac, spx_word16_t interp[4]) -{ - /* Compute interpolation coefficients. I'm not sure whether this corresponds to cubic interpolation - but I know it's MMSE-optimal on a sinc */ - interp[0] = -0.16667f*frac + 0.16667f*frac*frac*frac; - interp[1] = frac + 0.5f*frac*frac - 0.5f*frac*frac*frac; - /*interp[2] = 1.f - 0.5f*frac - frac*frac + 0.5f*frac*frac*frac;*/ - interp[3] = -0.33333f*frac + 0.5f*frac*frac - 0.16667f*frac*frac*frac; - /* Just to make sure we don't have rounding problems */ - interp[2] = 1.-interp[0]-interp[1]-interp[3]; -} -#endif - -static int resampler_basic_direct_single(SpeexResamplerState *st, spx_uint32_t channel_index, const spx_word16_t *in, spx_uint32_t *in_len, spx_word16_t *out, spx_uint32_t *out_len) -{ - int N = st->filt_len; - int out_sample = 0; - spx_word16_t *mem; - int last_sample = st->last_sample[channel_index]; - spx_uint32_t samp_frac_num = st->samp_frac_num[channel_index]; - mem = st->mem + channel_index * st->mem_alloc_size; - while (!(last_sample >= (spx_int32_t)*in_len || out_sample >= (spx_int32_t)*out_len)) - { - int j; - spx_word32_t sum=0; - - /* We already have all the filter coefficients pre-computed in the table */ - const spx_word16_t *ptr; - /* Do the memory part */ - for (j=0;last_sample-N+1+j < 0;j++) - { - sum += MULT16_16(mem[last_sample+j],st->sinc_table[samp_frac_num*st->filt_len+j]); - } - - /* Do the new part */ - if (in != NULL) - { - ptr = in+st->in_stride*(last_sample-N+1+j); - for (;jsinc_table[samp_frac_num*st->filt_len+j]); - ptr += st->in_stride; - } - } - - *out = PSHR32(sum,15); - out += st->out_stride; - out_sample++; - last_sample += st->int_advance; - samp_frac_num += st->frac_advance; - if (samp_frac_num >= st->den_rate) - { - samp_frac_num -= st->den_rate; - last_sample++; - } - } - st->last_sample[channel_index] = last_sample; - st->samp_frac_num[channel_index] = samp_frac_num; - return out_sample; -} - -#ifdef FIXED_POINT -#else -/* This is the same as the previous function, except with a double-precision accumulator */ -static int resampler_basic_direct_double(SpeexResamplerState *st, spx_uint32_t channel_index, const spx_word16_t *in, spx_uint32_t *in_len, spx_word16_t *out, spx_uint32_t *out_len) -{ - int N = st->filt_len; - int out_sample = 0; - spx_word16_t *mem; - int last_sample = st->last_sample[channel_index]; - spx_uint32_t samp_frac_num = st->samp_frac_num[channel_index]; - mem = st->mem + channel_index * st->mem_alloc_size; - while (!(last_sample >= (spx_int32_t)*in_len || out_sample >= (spx_int32_t)*out_len)) - { - int j; - double sum=0; - - /* We already have all the filter coefficients pre-computed in the table */ - const spx_word16_t *ptr; - /* Do the memory part */ - for (j=0;last_sample-N+1+j < 0;j++) - { - sum += MULT16_16(mem[last_sample+j],(double)st->sinc_table[samp_frac_num*st->filt_len+j]); - } - - /* Do the new part */ - if (in != NULL) - { - ptr = in+st->in_stride*(last_sample-N+1+j); - for (;jsinc_table[samp_frac_num*st->filt_len+j]); - ptr += st->in_stride; - } - } - - *out = sum; - out += st->out_stride; - out_sample++; - last_sample += st->int_advance; - samp_frac_num += st->frac_advance; - if (samp_frac_num >= st->den_rate) - { - samp_frac_num -= st->den_rate; - last_sample++; - } - } - st->last_sample[channel_index] = last_sample; - st->samp_frac_num[channel_index] = samp_frac_num; - return out_sample; -} -#endif - -static int resampler_basic_interpolate_single(SpeexResamplerState *st, spx_uint32_t channel_index, const spx_word16_t *in, spx_uint32_t *in_len, spx_word16_t *out, spx_uint32_t *out_len) -{ - int N = st->filt_len; - int out_sample = 0; - spx_word16_t *mem; - int last_sample = st->last_sample[channel_index]; - spx_uint32_t samp_frac_num = st->samp_frac_num[channel_index]; - mem = st->mem + channel_index * st->mem_alloc_size; - while (!(last_sample >= (spx_int32_t)*in_len || out_sample >= (spx_int32_t)*out_len)) - { - int j; - spx_word32_t sum=0; - - /* We need to interpolate the sinc filter */ - spx_word32_t accum[4] = {0.f,0.f, 0.f, 0.f}; - spx_word16_t interp[4]; - const spx_word16_t *ptr; - int offset; - spx_word16_t frac; - offset = samp_frac_num*st->oversample/st->den_rate; -#ifdef FIXED_POINT - frac = PDIV32(SHL32((samp_frac_num*st->oversample) % st->den_rate,15),st->den_rate); -#else - frac = ((float)((samp_frac_num*st->oversample) % st->den_rate))/st->den_rate; -#endif - /* This code is written like this to make it easy to optimise with SIMD. - For most DSPs, it would be best to split the loops in two because most DSPs - have only two accumulators */ - for (j=0;last_sample-N+1+j < 0;j++) - { - spx_word16_t curr_mem = mem[last_sample+j]; - accum[0] += MULT16_16(curr_mem,st->sinc_table[4+(j+1)*st->oversample-offset-2]); - accum[1] += MULT16_16(curr_mem,st->sinc_table[4+(j+1)*st->oversample-offset-1]); - accum[2] += MULT16_16(curr_mem,st->sinc_table[4+(j+1)*st->oversample-offset]); - accum[3] += MULT16_16(curr_mem,st->sinc_table[4+(j+1)*st->oversample-offset+1]); - } - - if (in != NULL) - { - ptr = in+st->in_stride*(last_sample-N+1+j); - /* Do the new part */ - for (;jin_stride; - accum[0] += MULT16_16(curr_in,st->sinc_table[4+(j+1)*st->oversample-offset-2]); - accum[1] += MULT16_16(curr_in,st->sinc_table[4+(j+1)*st->oversample-offset-1]); - accum[2] += MULT16_16(curr_in,st->sinc_table[4+(j+1)*st->oversample-offset]); - accum[3] += MULT16_16(curr_in,st->sinc_table[4+(j+1)*st->oversample-offset+1]); - } - } - cubic_coef(frac, interp); - sum = MULT16_32_Q15(interp[0],accum[0]) + MULT16_32_Q15(interp[1],accum[1]) + MULT16_32_Q15(interp[2],accum[2]) + MULT16_32_Q15(interp[3],accum[3]); - - *out = PSHR32(sum,15); - out += st->out_stride; - out_sample++; - last_sample += st->int_advance; - samp_frac_num += st->frac_advance; - if (samp_frac_num >= st->den_rate) - { - samp_frac_num -= st->den_rate; - last_sample++; - } - } - st->last_sample[channel_index] = last_sample; - st->samp_frac_num[channel_index] = samp_frac_num; - return out_sample; -} - -#ifdef FIXED_POINT -#else -/* This is the same as the previous function, except with a double-precision accumulator */ -static int resampler_basic_interpolate_double(SpeexResamplerState *st, spx_uint32_t channel_index, const spx_word16_t *in, spx_uint32_t *in_len, spx_word16_t *out, spx_uint32_t *out_len) -{ - int N = st->filt_len; - int out_sample = 0; - spx_word16_t *mem; - int last_sample = st->last_sample[channel_index]; - spx_uint32_t samp_frac_num = st->samp_frac_num[channel_index]; - mem = st->mem + channel_index * st->mem_alloc_size; - while (!(last_sample >= (spx_int32_t)*in_len || out_sample >= (spx_int32_t)*out_len)) - { - int j; - spx_word32_t sum=0; - - /* We need to interpolate the sinc filter */ - double accum[4] = {0.f,0.f, 0.f, 0.f}; - float interp[4]; - const spx_word16_t *ptr; - float alpha = ((float)samp_frac_num)/st->den_rate; - int offset = samp_frac_num*st->oversample/st->den_rate; - float frac = alpha*st->oversample - offset; - /* This code is written like this to make it easy to optimise with SIMD. - For most DSPs, it would be best to split the loops in two because most DSPs - have only two accumulators */ - for (j=0;last_sample-N+1+j < 0;j++) - { - double curr_mem = mem[last_sample+j]; - accum[0] += MULT16_16(curr_mem,st->sinc_table[4+(j+1)*st->oversample-offset-2]); - accum[1] += MULT16_16(curr_mem,st->sinc_table[4+(j+1)*st->oversample-offset-1]); - accum[2] += MULT16_16(curr_mem,st->sinc_table[4+(j+1)*st->oversample-offset]); - accum[3] += MULT16_16(curr_mem,st->sinc_table[4+(j+1)*st->oversample-offset+1]); - } - if (in != NULL) - { - ptr = in+st->in_stride*(last_sample-N+1+j); - /* Do the new part */ - for (;jin_stride; - accum[0] += MULT16_16(curr_in,st->sinc_table[4+(j+1)*st->oversample-offset-2]); - accum[1] += MULT16_16(curr_in,st->sinc_table[4+(j+1)*st->oversample-offset-1]); - accum[2] += MULT16_16(curr_in,st->sinc_table[4+(j+1)*st->oversample-offset]); - accum[3] += MULT16_16(curr_in,st->sinc_table[4+(j+1)*st->oversample-offset+1]); - } - } - cubic_coef(frac, interp); - sum = interp[0]*accum[0] + interp[1]*accum[1] + interp[2]*accum[2] + interp[3]*accum[3]; - - *out = PSHR32(sum,15); - out += st->out_stride; - out_sample++; - last_sample += st->int_advance; - samp_frac_num += st->frac_advance; - if (samp_frac_num >= st->den_rate) - { - samp_frac_num -= st->den_rate; - last_sample++; - } - } - st->last_sample[channel_index] = last_sample; - st->samp_frac_num[channel_index] = samp_frac_num; - return out_sample; -} -#endif - -static void update_filter(SpeexResamplerState *st) -{ - spx_uint32_t old_length; - - old_length = st->filt_len; - st->oversample = quality_map[st->quality].oversample; - st->filt_len = quality_map[st->quality].base_length; - - if (st->num_rate > st->den_rate) - { - /* down-sampling */ - st->cutoff = quality_map[st->quality].downsample_bandwidth * st->den_rate / st->num_rate; - /* FIXME: divide the numerator and denominator by a certain amount if they're too large */ - st->filt_len = st->filt_len*st->num_rate / st->den_rate; - /* Round down to make sure we have a multiple of 4 */ - st->filt_len &= (~0x3); - if (2*st->den_rate < st->num_rate) - st->oversample >>= 1; - if (4*st->den_rate < st->num_rate) - st->oversample >>= 1; - if (8*st->den_rate < st->num_rate) - st->oversample >>= 1; - if (16*st->den_rate < st->num_rate) - st->oversample >>= 1; - if (st->oversample < 1) - st->oversample = 1; - } else { - /* up-sampling */ - st->cutoff = quality_map[st->quality].upsample_bandwidth; - } - - /* Choose the resampling type that requires the least amount of memory */ - if (st->den_rate <= st->oversample) - { - spx_uint32_t i; - if (!st->sinc_table) - st->sinc_table = (spx_word16_t *)speex_alloc(st->filt_len*st->den_rate*sizeof(spx_word16_t)); - else if (st->sinc_table_length < st->filt_len*st->den_rate) - { - st->sinc_table = (spx_word16_t *)speex_realloc(st->sinc_table,st->filt_len*st->den_rate*sizeof(spx_word16_t)); - st->sinc_table_length = st->filt_len*st->den_rate; - } - for (i=0;iden_rate;i++) - { - spx_int32_t j; - for (j=0;jfilt_len;j++) - { - st->sinc_table[i*st->filt_len+j] = sinc(st->cutoff,((j-(spx_int32_t)st->filt_len/2+1)-((float)i)/st->den_rate), st->filt_len, quality_map[st->quality].window_func); - } - } -#ifdef FIXED_POINT - st->resampler_ptr = resampler_basic_direct_single; -#else - if (st->quality>8) - st->resampler_ptr = resampler_basic_direct_double; - else - st->resampler_ptr = resampler_basic_direct_single; -#endif - /*fprintf (stderr, "resampler uses direct sinc table and normalised cutoff %f\n", cutoff);*/ - } else { - spx_int32_t i; - if (!st->sinc_table) - st->sinc_table = (spx_word16_t *)speex_alloc((st->filt_len*st->oversample+8)*sizeof(spx_word16_t)); - else if (st->sinc_table_length < st->filt_len*st->oversample+8) - { - st->sinc_table = (spx_word16_t *)speex_realloc(st->sinc_table,(st->filt_len*st->oversample+8)*sizeof(spx_word16_t)); - st->sinc_table_length = st->filt_len*st->oversample+8; - } - for (i=-4;i<(spx_int32_t)(st->oversample*st->filt_len+4);i++) - st->sinc_table[i+4] = sinc(st->cutoff,(i/(float)st->oversample - st->filt_len/2), st->filt_len, quality_map[st->quality].window_func); -#ifdef FIXED_POINT - st->resampler_ptr = resampler_basic_interpolate_single; -#else - if (st->quality>8) - st->resampler_ptr = resampler_basic_interpolate_double; - else - st->resampler_ptr = resampler_basic_interpolate_single; -#endif - /*fprintf (stderr, "resampler uses interpolated sinc table and normalised cutoff %f\n", cutoff);*/ - } - st->int_advance = st->num_rate/st->den_rate; - st->frac_advance = st->num_rate%st->den_rate; - - - /* Here's the place where we update the filter memory to take into account - the change in filter length. It's probably the messiest part of the code - due to handling of lots of corner cases. */ - if (!st->mem) - { - spx_uint32_t i; - st->mem = (spx_word16_t*)speex_alloc(st->nb_channels*(st->filt_len-1) * sizeof(spx_word16_t)); - for (i=0;inb_channels*(st->filt_len-1);i++) - st->mem[i] = 0; - st->mem_alloc_size = st->filt_len-1; - /*speex_warning("init filter");*/ - } else if (!st->started) - { - spx_uint32_t i; - st->mem = (spx_word16_t*)speex_realloc(st->mem, st->nb_channels*(st->filt_len-1) * sizeof(spx_word16_t)); - for (i=0;inb_channels*(st->filt_len-1);i++) - st->mem[i] = 0; - st->mem_alloc_size = st->filt_len-1; - /*speex_warning("reinit filter");*/ - } else if (st->filt_len > old_length) - { - spx_int32_t i; - /* Increase the filter length */ - /*speex_warning("increase filter size");*/ - int old_alloc_size = st->mem_alloc_size; - if (st->filt_len-1 > st->mem_alloc_size) - { - st->mem = (spx_word16_t*)speex_realloc(st->mem, st->nb_channels*(st->filt_len-1) * sizeof(spx_word16_t)); - st->mem_alloc_size = st->filt_len-1; - } - for (i=st->nb_channels-1;i>=0;i--) - { - spx_int32_t j; - spx_uint32_t olen = old_length; - /*if (st->magic_samples[i])*/ - { - /* Try and remove the magic samples as if nothing had happened */ - - /* FIXME: This is wrong but for now we need it to avoid going over the array bounds */ - olen = old_length + 2*st->magic_samples[i]; - for (j=old_length-2+st->magic_samples[i];j>=0;j--) - st->mem[i*st->mem_alloc_size+j+st->magic_samples[i]] = st->mem[i*old_alloc_size+j]; - for (j=0;jmagic_samples[i];j++) - st->mem[i*st->mem_alloc_size+j] = 0; - st->magic_samples[i] = 0; - } - if (st->filt_len > olen) - { - /* If the new filter length is still bigger than the "augmented" length */ - /* Copy data going backward */ - for (j=0;jmem[i*st->mem_alloc_size+(st->filt_len-2-j)] = st->mem[i*st->mem_alloc_size+(olen-2-j)]; - /* Then put zeros for lack of anything better */ - for (;jfilt_len-1;j++) - st->mem[i*st->mem_alloc_size+(st->filt_len-2-j)] = 0; - /* Adjust last_sample */ - st->last_sample[i] += (st->filt_len - olen)/2; - } else { - /* Put back some of the magic! */ - st->magic_samples[i] = (olen - st->filt_len)/2; - for (j=0;jfilt_len-1+st->magic_samples[i];j++) - st->mem[i*st->mem_alloc_size+j] = st->mem[i*st->mem_alloc_size+j+st->magic_samples[i]]; - } - } - } else if (st->filt_len < old_length) - { - spx_uint32_t i; - /* Reduce filter length, this a bit tricky. We need to store some of the memory as "magic" - samples so they can be used directly as input the next time(s) */ - for (i=0;inb_channels;i++) - { - spx_uint32_t j; - spx_uint32_t old_magic = st->magic_samples[i]; - st->magic_samples[i] = (old_length - st->filt_len)/2; - /* We must copy some of the memory that's no longer used */ - /* Copy data going backward */ - for (j=0;jfilt_len-1+st->magic_samples[i]+old_magic;j++) - st->mem[i*st->mem_alloc_size+j] = st->mem[i*st->mem_alloc_size+j+st->magic_samples[i]]; - st->magic_samples[i] += old_magic; - } - } - -} - -SpeexResamplerState *speex_resampler_init(spx_uint32_t nb_channels, spx_uint32_t in_rate, spx_uint32_t out_rate, int quality, int *err) -{ - return speex_resampler_init_frac(nb_channels, in_rate, out_rate, in_rate, out_rate, quality, err); -} - -SpeexResamplerState *speex_resampler_init_frac(spx_uint32_t nb_channels, spx_uint32_t ratio_num, spx_uint32_t ratio_den, spx_uint32_t in_rate, spx_uint32_t out_rate, int quality, int *err) -{ - spx_uint32_t i; - SpeexResamplerState *st; - if (quality > 10 || quality < 0) - { - if (err) - *err = RESAMPLER_ERR_INVALID_ARG; - return NULL; - } - st = (SpeexResamplerState *)speex_alloc(sizeof(SpeexResamplerState)); - st->initialised = 0; - st->started = 0; - st->in_rate = 0; - st->out_rate = 0; - st->num_rate = 0; - st->den_rate = 0; - st->quality = -1; - st->sinc_table_length = 0; - st->mem_alloc_size = 0; - st->filt_len = 0; - st->mem = 0; - st->resampler_ptr = 0; - - st->cutoff = 1.f; - st->nb_channels = nb_channels; - st->in_stride = 1; - st->out_stride = 1; - - /* Per channel data */ - st->last_sample = (spx_int32_t*)speex_alloc(nb_channels*sizeof(int)); - st->magic_samples = (spx_uint32_t*)speex_alloc(nb_channels*sizeof(int)); - st->samp_frac_num = (spx_uint32_t*)speex_alloc(nb_channels*sizeof(int)); - for (i=0;ilast_sample[i] = 0; - st->magic_samples[i] = 0; - st->samp_frac_num[i] = 0; - } - - speex_resampler_set_quality(st, quality); - speex_resampler_set_rate_frac(st, ratio_num, ratio_den, in_rate, out_rate); - - - update_filter(st); - - st->initialised = 1; - if (err) - *err = RESAMPLER_ERR_SUCCESS; - - return st; -} - -void speex_resampler_destroy(SpeexResamplerState *st) -{ - speex_free(st->mem); - speex_free(st->sinc_table); - speex_free(st->last_sample); - speex_free(st->magic_samples); - speex_free(st->samp_frac_num); - speex_free(st); -} - - - -static int speex_resampler_process_native(SpeexResamplerState *st, spx_uint32_t channel_index, const spx_word16_t *in, spx_uint32_t *in_len, spx_word16_t *out, spx_uint32_t *out_len) -{ - int j=0; - int N = st->filt_len; - int out_sample = 0; - spx_word16_t *mem; - spx_uint32_t tmp_out_len = 0; - mem = st->mem + channel_index * st->mem_alloc_size; - st->started = 1; - - /* Handle the case where we have samples left from a reduction in filter length */ - if (st->magic_samples[channel_index]) - { - int istride_save; - spx_uint32_t tmp_in_len; - spx_uint32_t tmp_magic; - - istride_save = st->in_stride; - tmp_in_len = st->magic_samples[channel_index]; - tmp_out_len = *out_len; - /* magic_samples needs to be set to zero to avoid infinite recursion */ - tmp_magic = st->magic_samples[channel_index]; - st->magic_samples[channel_index] = 0; - st->in_stride = 1; - speex_resampler_process_native(st, channel_index, mem+N-1, &tmp_in_len, out, &tmp_out_len); - st->in_stride = istride_save; - /*speex_warning_int("extra samples:", tmp_out_len);*/ - /* If we couldn't process all "magic" input samples, save the rest for next time */ - if (tmp_in_len < tmp_magic) - { - spx_uint32_t i; - st->magic_samples[channel_index] = tmp_magic-tmp_in_len; - for (i=0;imagic_samples[channel_index];i++) - mem[N-1+i]=mem[N-1+i+tmp_in_len]; - } - out += tmp_out_len*st->out_stride; - *out_len -= tmp_out_len; - } - - /* Call the right resampler through the function ptr */ - out_sample = st->resampler_ptr(st, channel_index, in, in_len, out, out_len); - - if (st->last_sample[channel_index] < (spx_int32_t)*in_len) - *in_len = st->last_sample[channel_index]; - *out_len = out_sample+tmp_out_len; - st->last_sample[channel_index] -= *in_len; - - for (j=0;jin_stride*(j+*in_len-N+1)]; - - return RESAMPLER_ERR_SUCCESS; -} - -#define FIXED_STACK_ALLOC 1024 - -#ifdef FIXED_POINT -int speex_resampler_process_float(SpeexResamplerState *st, spx_uint32_t channel_index, const float *in, spx_uint32_t *in_len, float *out, spx_uint32_t *out_len) -{ - spx_uint32_t i; - int istride_save, ostride_save; -#ifdef VAR_ARRAYS - spx_word16_t x[*in_len]; - spx_word16_t y[*out_len]; - /*VARDECL(spx_word16_t *x); - VARDECL(spx_word16_t *y); - ALLOC(x, *in_len, spx_word16_t); - ALLOC(y, *out_len, spx_word16_t);*/ - istride_save = st->in_stride; - ostride_save = st->out_stride; - for (i=0;i<*in_len;i++) - x[i] = WORD2INT(in[i*st->in_stride]); - st->in_stride = st->out_stride = 1; - speex_resampler_process_native(st, channel_index, x, in_len, y, out_len); - st->in_stride = istride_save; - st->out_stride = ostride_save; - for (i=0;i<*out_len;i++) - out[i*st->out_stride] = y[i]; -#else - spx_word16_t x[FIXED_STACK_ALLOC]; - spx_word16_t y[FIXED_STACK_ALLOC]; - spx_uint32_t ilen=*in_len, olen=*out_len; - istride_save = st->in_stride; - ostride_save = st->out_stride; - while (ilen && olen) - { - spx_uint32_t ichunk, ochunk; - ichunk = ilen; - ochunk = olen; - if (ichunk>FIXED_STACK_ALLOC) - ichunk=FIXED_STACK_ALLOC; - if (ochunk>FIXED_STACK_ALLOC) - ochunk=FIXED_STACK_ALLOC; - for (i=0;iin_stride]); - st->in_stride = st->out_stride = 1; - speex_resampler_process_native(st, channel_index, x, &ichunk, y, &ochunk); - st->in_stride = istride_save; - st->out_stride = ostride_save; - for (i=0;iout_stride] = y[i]; - out += ochunk; - in += ichunk; - ilen -= ichunk; - olen -= ochunk; - } - *in_len -= ilen; - *out_len -= olen; -#endif - return RESAMPLER_ERR_SUCCESS; -} -int speex_resampler_process_int(SpeexResamplerState *st, spx_uint32_t channel_index, const spx_int16_t *in, spx_uint32_t *in_len, spx_int16_t *out, spx_uint32_t *out_len) -{ - return speex_resampler_process_native(st, channel_index, in, in_len, out, out_len); -} -#else -int speex_resampler_process_float(SpeexResamplerState *st, spx_uint32_t channel_index, const float *in, spx_uint32_t *in_len, float *out, spx_uint32_t *out_len) -{ - return speex_resampler_process_native(st, channel_index, in, in_len, out, out_len); -} -int speex_resampler_process_int(SpeexResamplerState *st, spx_uint32_t channel_index, const spx_int16_t *in, spx_uint32_t *in_len, spx_int16_t *out, spx_uint32_t *out_len) -{ - spx_uint32_t i; - int istride_save, ostride_save; -#ifdef VAR_ARRAYS - spx_word16_t x[*in_len]; - spx_word16_t y[*out_len]; - /*VARDECL(spx_word16_t *x); - VARDECL(spx_word16_t *y); - ALLOC(x, *in_len, spx_word16_t); - ALLOC(y, *out_len, spx_word16_t);*/ - istride_save = st->in_stride; - ostride_save = st->out_stride; - for (i=0;i<*in_len;i++) - x[i] = in[i*st->in_stride]; - st->in_stride = st->out_stride = 1; - speex_resampler_process_native(st, channel_index, x, in_len, y, out_len); - st->in_stride = istride_save; - st->out_stride = ostride_save; - for (i=0;i<*out_len;i++) - out[i*st->out_stride] = WORD2INT(y[i]); -#else - spx_word16_t x[FIXED_STACK_ALLOC]; - spx_word16_t y[FIXED_STACK_ALLOC]; - spx_uint32_t ilen=*in_len, olen=*out_len; - istride_save = st->in_stride; - ostride_save = st->out_stride; - while (ilen && olen) - { - spx_uint32_t ichunk, ochunk; - ichunk = ilen; - ochunk = olen; - if (ichunk>FIXED_STACK_ALLOC) - ichunk=FIXED_STACK_ALLOC; - if (ochunk>FIXED_STACK_ALLOC) - ochunk=FIXED_STACK_ALLOC; - for (i=0;iin_stride]; - st->in_stride = st->out_stride = 1; - speex_resampler_process_native(st, channel_index, x, &ichunk, y, &ochunk); - st->in_stride = istride_save; - st->out_stride = ostride_save; - for (i=0;iout_stride] = WORD2INT(y[i]); - out += ochunk; - in += ichunk; - ilen -= ichunk; - olen -= ochunk; - } - *in_len -= ilen; - *out_len -= olen; -#endif - return RESAMPLER_ERR_SUCCESS; -} -#endif - -int speex_resampler_process_interleaved_float(SpeexResamplerState *st, const float *in, spx_uint32_t *in_len, float *out, spx_uint32_t *out_len) -{ - spx_uint32_t i; - int istride_save, ostride_save; - spx_uint32_t bak_len = *out_len; - istride_save = st->in_stride; - ostride_save = st->out_stride; - st->in_stride = st->out_stride = st->nb_channels; - for (i=0;inb_channels;i++) - { - *out_len = bak_len; - if (in != NULL) - speex_resampler_process_float(st, i, in+i, in_len, out+i, out_len); - else - speex_resampler_process_float(st, i, NULL, in_len, out+i, out_len); - } - st->in_stride = istride_save; - st->out_stride = ostride_save; - return RESAMPLER_ERR_SUCCESS; -} - - -int speex_resampler_process_interleaved_int(SpeexResamplerState *st, const spx_int16_t *in, spx_uint32_t *in_len, spx_int16_t *out, spx_uint32_t *out_len) -{ - spx_uint32_t i; - int istride_save, ostride_save; - spx_uint32_t bak_len = *out_len; - istride_save = st->in_stride; - ostride_save = st->out_stride; - st->in_stride = st->out_stride = st->nb_channels; - for (i=0;inb_channels;i++) - { - *out_len = bak_len; - if (in != NULL) - speex_resampler_process_int(st, i, in+i, in_len, out+i, out_len); - else - speex_resampler_process_int(st, i, NULL, in_len, out+i, out_len); - } - st->in_stride = istride_save; - st->out_stride = ostride_save; - return RESAMPLER_ERR_SUCCESS; -} - -int speex_resampler_set_rate(SpeexResamplerState *st, spx_uint32_t in_rate, spx_uint32_t out_rate) -{ - return speex_resampler_set_rate_frac(st, in_rate, out_rate, in_rate, out_rate); -} - -void speex_resampler_get_rate(SpeexResamplerState *st, spx_uint32_t *in_rate, spx_uint32_t *out_rate) -{ - *in_rate = st->in_rate; - *out_rate = st->out_rate; -} - -int speex_resampler_set_rate_frac(SpeexResamplerState *st, spx_uint32_t ratio_num, spx_uint32_t ratio_den, spx_uint32_t in_rate, spx_uint32_t out_rate) -{ - spx_uint32_t fact; - spx_uint32_t old_den; - spx_uint32_t i; - if (st->in_rate == in_rate && st->out_rate == out_rate && st->num_rate == ratio_num && st->den_rate == ratio_den) - return RESAMPLER_ERR_SUCCESS; - - old_den = st->den_rate; - st->in_rate = in_rate; - st->out_rate = out_rate; - st->num_rate = ratio_num; - st->den_rate = ratio_den; - /* FIXME: This is terribly inefficient, but who cares (at least for now)? */ - for (fact=2;fact<=IMIN(st->num_rate, st->den_rate);fact++) - { - while ((st->num_rate % fact == 0) && (st->den_rate % fact == 0)) - { - st->num_rate /= fact; - st->den_rate /= fact; - } - } - - if (old_den > 0) - { - for (i=0;inb_channels;i++) - { - st->samp_frac_num[i]=st->samp_frac_num[i]*st->den_rate/old_den; - /* Safety net */ - if (st->samp_frac_num[i] >= st->den_rate) - st->samp_frac_num[i] = st->den_rate-1; - } - } - - if (st->initialised) - update_filter(st); - return RESAMPLER_ERR_SUCCESS; -} - -void speex_resampler_get_ratio(SpeexResamplerState *st, spx_uint32_t *ratio_num, spx_uint32_t *ratio_den) -{ - *ratio_num = st->num_rate; - *ratio_den = st->den_rate; -} - -int speex_resampler_set_quality(SpeexResamplerState *st, int quality) -{ - if (quality > 10 || quality < 0) - return RESAMPLER_ERR_INVALID_ARG; - if (st->quality == quality) - return RESAMPLER_ERR_SUCCESS; - st->quality = quality; - if (st->initialised) - update_filter(st); - return RESAMPLER_ERR_SUCCESS; -} - -void speex_resampler_get_quality(SpeexResamplerState *st, int *quality) -{ - *quality = st->quality; -} - -void speex_resampler_set_input_stride(SpeexResamplerState *st, spx_uint32_t stride) -{ - st->in_stride = stride; -} - -void speex_resampler_get_input_stride(SpeexResamplerState *st, spx_uint32_t *stride) -{ - *stride = st->in_stride; -} - -void speex_resampler_set_output_stride(SpeexResamplerState *st, spx_uint32_t stride) -{ - st->out_stride = stride; -} - -void speex_resampler_get_output_stride(SpeexResamplerState *st, spx_uint32_t *stride) -{ - *stride = st->out_stride; -} - -int speex_resampler_skip_zeros(SpeexResamplerState *st) -{ - spx_uint32_t i; - for (i=0;inb_channels;i++) - st->last_sample[i] = st->filt_len/2; - return RESAMPLER_ERR_SUCCESS; -} - -int speex_resampler_reset_mem(SpeexResamplerState *st) -{ - spx_uint32_t i; - for (i=0;inb_channels*(st->filt_len-1);i++) - st->mem[i] = 0; - return RESAMPLER_ERR_SUCCESS; -} - -const char *speex_resampler_strerror(int err) -{ - switch (err) - { - case RESAMPLER_ERR_SUCCESS: - return "Success."; - case RESAMPLER_ERR_ALLOC_FAILED: - return "Memory allocation failed."; - case RESAMPLER_ERR_BAD_STATE: - return "Bad resampler state."; - case RESAMPLER_ERR_INVALID_ARG: - return "Invalid argument."; - case RESAMPLER_ERR_PTR_OVERLAP: - return "Input and output buffers overlap."; - default: - return "Unknown error. Bad error code or strange version mismatch."; - } -} diff --git a/apps/codecs/libspeex/rockbox.h b/apps/codecs/libspeex/rockbox.h deleted file mode 100644 index 459c8b532f..0000000000 --- a/apps/codecs/libspeex/rockbox.h +++ /dev/null @@ -1,119 +0,0 @@ -/************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * - * Copyright (C) 2007 Dan Everton - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ***************************************************************************/ - -#ifndef SPEEX_ROCKBOX_H -#define SPEEX_ROCKBOX_H - -/* We don't want all this stuff if we're building encoder */ -#ifndef ROCKBOX_VOICE_ENCODER - -#include "codeclib.h" -#include "debug.h" - -#if !defined(ROCKBOX_VOICE_CODEC) - -#if defined(DEBUG) || defined(SIMULATOR) -#undef DEBUGF -#define DEBUGF ci->debugf -#endif - - -#ifdef ROCKBOX_HAS_LOGF -#undef LOGF -#define LOGF ci->logf -#endif - -#endif /* ROCKBOX_VOICE_CODEC */ - -#define OVERRIDE_SPEEX_ALLOC 1 -static inline void *speex_alloc (int size) -{ - return codec_calloc(size, 1); -} - -#define OVERRIDE_SPEEX_ALLOC_SCRATCH 1 -static inline void *speex_alloc_scratch (int size) -{ - return codec_calloc(size,1); -} - -#define OVERRIDE_SPEEX_REALLOC 1 -static inline void *speex_realloc (void *ptr, int size) -{ - return codec_realloc(ptr, size); -} - -#define OVERRIDE_SPEEX_FREE 1 -static inline void speex_free (void *ptr) -{ - codec_free(ptr); -} - -#define OVERRIDE_SPEEX_FREE_SCRATCH 1 -static inline void speex_free_scratch (void *ptr) -{ - codec_free(ptr); -} - -#define OVERRIDE_SPEEX_FATAL 1 -static inline void _speex_fatal(const char *str, const char *file, int line) -{ - (void)str; - (void)file; - (void)line; - DEBUGF("Fatal error: %s\n", str); - //exit(1); -} - -#define OVERRIDE_SPEEX_WARNING 1 -static inline void speex_warning(const char *str) -{ - (void)str; - DEBUGF("warning: %s\n", str); -} - -#define OVERRIDE_SPEEX_WARNING_INT 1 -static inline void speex_warning_int(const char *str, int val) -{ - (void)str; - (void)val; - DEBUGF("warning: %s %d\n", str, val); -} - -#define OVERRIDE_SPEEX_NOTIFY 1 -static inline void speex_notify(const char *str) -{ - (void)str; - DEBUGF("notice: %s\n", str); -} - -#define OVERRIDE_SPEEX_PUTC 1 -static inline void _speex_putc(int ch, void *file) -{ - (void)ch; - (void)file; - //FILE *f = (FILE *)file; - //printf("%c", ch); -} - -#endif /* ROCKBOX_VOICE_ENCODER */ - -#endif - diff --git a/apps/codecs/libspeex/sb_celp.c b/apps/codecs/libspeex/sb_celp.c deleted file mode 100644 index b28744812f..0000000000 --- a/apps/codecs/libspeex/sb_celp.c +++ /dev/null @@ -1,1510 +0,0 @@ -/* Copyright (C) 2002-2006 Jean-Marc Valin - File: sb_celp.c - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of the Xiph.org Foundation nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifdef HAVE_CONFIG_H -#include "config-speex.h" -#endif - -#include -#include "sb_celp.h" -#include "filters.h" -#include "lpc.h" -#include "lsp.h" -#include "stack_alloc.h" -#include "cb_search.h" -#include "quant_lsp.h" -#include "vq.h" -#include "ltp.h" -#include "arch.h" -#include "math_approx.h" -#include "os_support.h" - -#ifndef NULL -#define NULL 0 -#endif - -/* Default size for the encoder and decoder stack (can be changed at compile time). - This does not apply when using variable-size arrays or alloca. */ -#ifndef SB_ENC_STACK -#define SB_ENC_STACK (10000*sizeof(spx_sig_t)) -#endif - -#ifndef SB_DEC_STACK -#define SB_DEC_STACK (6000*sizeof(spx_sig_t)) -#endif - - -#ifdef DISABLE_WIDEBAND -void *sb_encoder_init(const SpeexMode *m) -{ - speex_fatal("Wideband and Ultra-wideband are disabled"); - return NULL; -} -void sb_encoder_destroy(void *state) -{ - speex_fatal("Wideband and Ultra-wideband are disabled"); -} -int sb_encode(void *state, void *vin, SpeexBits *bits) -{ - speex_fatal("Wideband and Ultra-wideband are disabled"); - return -2; -} -void *sb_decoder_init(const SpeexMode *m) -{ - speex_fatal("Wideband and Ultra-wideband are disabled"); - return NULL; -} -void sb_decoder_destroy(void *state) -{ - speex_fatal("Wideband and Ultra-wideband are disabled"); -} -int sb_decode(void *state, SpeexBits *bits, void *vout) -{ - speex_fatal("Wideband and Ultra-wideband are disabled"); - return -2; -} -int sb_encoder_ctl(void *state, int request, void *ptr) -{ - speex_fatal("Wideband and Ultra-wideband are disabled"); - return -2; -} -int sb_decoder_ctl(void *state, int request, void *ptr) -{ - speex_fatal("Wideband and Ultra-wideband are disabled"); - return -2; -} -#else - - -#ifndef M_PI -#define M_PI 3.14159265358979323846 /* pi */ -#endif - -#define sqr(x) ((x)*(x)) - -#define SUBMODE(x) st->submodes[st->submodeID]->x - -#ifdef FIXED_POINT -static const spx_word16_t gc_quant_bound[16] ICONST_ATTR = {125, 164, 215, 282, 370, 484, 635, 832, 1090, 1428, 1871, 2452, 3213, 4210, 5516, 7228}; -static const spx_word16_t fold_quant_bound[32] ICONST_ATTR = { - 39, 44, 50, 57, 64, 73, 83, 94, - 106, 120, 136, 154, 175, 198, 225, 255, - 288, 327, 370, 420, 476, 539, 611, 692, - 784, 889, 1007, 1141, 1293, 1465, 1660, 1881}; -#define LSP_MARGIN 410 -#define LSP_DELTA1 6553 -#define LSP_DELTA2 1638 - -#else - -static const spx_word16_t gc_quant_bound[16] = { - 0.97979, 1.28384, 1.68223, 2.20426, 2.88829, 3.78458, 4.95900, 6.49787, - 8.51428, 11.15642, 14.61846, 19.15484, 25.09895, 32.88761, 43.09325, 56.46588}; -static const spx_word16_t fold_quant_bound[32] = { - 0.30498, 0.34559, 0.39161, 0.44375, 0.50283, 0.56979, 0.64565, 0.73162, - 0.82903, 0.93942, 1.06450, 1.20624, 1.36685, 1.54884, 1.75506, 1.98875, - 2.25355, 2.55360, 2.89361, 3.27889, 3.71547, 4.21018, 4.77076, 5.40598, - 6.12577, 6.94141, 7.86565, 8.91295, 10.09969, 11.44445, 12.96826, 14.69497}; - -#define LSP_MARGIN .05 -#define LSP_DELTA1 .2 -#define LSP_DELTA2 .05 - -#endif - -#define QMF_ORDER 64 - -#ifdef FIXED_POINT -static const spx_word16_t h0[64] ICONST_ATTR = {2, -7, -7, 18, 15, -39, -25, 75, 35, -130, -41, 212, 38, -327, -17, 483, -32, -689, 124, 956, -283, -1307, 543, 1780, -973, -2467, 1733, 3633, -3339, -6409, 9059, 30153, 30153, 9059, -6409, -3339, 3633, 1733, -2467, -973, 1780, 543, -1307, -283, 956, 124, -689, -32, 483, -17, -327, 38, 212, -41, -130, 35, 75, -25, -39, 15, 18, -7, -7, 2}; - -#else -static const float h0[64] = { - 3.596189e-05f, -0.0001123515f, - -0.0001104587f, 0.0002790277f, - 0.0002298438f, -0.0005953563f, - -0.0003823631f, 0.00113826f, - 0.0005308539f, -0.001986177f, - -0.0006243724f, 0.003235877f, - 0.0005743159f, -0.004989147f, - -0.0002584767f, 0.007367171f, - -0.0004857935f, -0.01050689f, - 0.001894714f, 0.01459396f, - -0.004313674f, -0.01994365f, - 0.00828756f, 0.02716055f, - -0.01485397f, -0.03764973f, - 0.026447f, 0.05543245f, - -0.05095487f, -0.09779096f, - 0.1382363f, 0.4600981f, - 0.4600981f, 0.1382363f, - -0.09779096f, -0.05095487f, - 0.05543245f, 0.026447f, - -0.03764973f, -0.01485397f, - 0.02716055f, 0.00828756f, - -0.01994365f, -0.004313674f, - 0.01459396f, 0.001894714f, - -0.01050689f, -0.0004857935f, - 0.007367171f, -0.0002584767f, - -0.004989147f, 0.0005743159f, - 0.003235877f, -0.0006243724f, - -0.001986177f, 0.0005308539f, - 0.00113826f, -0.0003823631f, - -0.0005953563f, 0.0002298438f, - 0.0002790277f, -0.0001104587f, - -0.0001123515f, 3.596189e-05f -}; - -#endif - -extern const spx_word16_t lag_window[]; -extern const spx_word16_t lpc_window[]; - -#ifndef SPEEX_DISABLE_ENCODER -void *sb_encoder_init(const SpeexMode *m) -{ - int i; - spx_int32_t tmp; - SBEncState *st; - const SpeexSBMode *mode; - - st = (SBEncState*)speex_alloc(sizeof(SBEncState)); - if (!st) - return NULL; - st->mode = m; - mode = (const SpeexSBMode*)m->mode; - - - st->st_low = speex_encoder_init(mode->nb_mode); -#if defined(VAR_ARRAYS) || defined (USE_ALLOCA) - st->stack = NULL; -#else - /*st->stack = (char*)speex_alloc_scratch(SB_ENC_STACK);*/ - speex_encoder_ctl(st->st_low, SPEEX_GET_STACK, &st->stack); -#endif - - st->full_frame_size = 2*mode->frameSize; - st->frame_size = mode->frameSize; - st->subframeSize = mode->subframeSize; - st->nbSubframes = mode->frameSize/mode->subframeSize; - st->windowSize = st->frame_size+st->subframeSize; - st->lpcSize=mode->lpcSize; - - st->encode_submode = 1; - st->submodes=mode->submodes; - st->submodeSelect = st->submodeID=mode->defaultSubmode; - - tmp=9; - speex_encoder_ctl(st->st_low, SPEEX_SET_QUALITY, &tmp); - tmp=1; - speex_encoder_ctl(st->st_low, SPEEX_SET_WIDEBAND, &tmp); - - st->lpc_floor = mode->lpc_floor; - st->gamma1=mode->gamma1; - st->gamma2=mode->gamma2; - st->first=1; - - st->high=(spx_word16_t*)speex_alloc((st->windowSize-st->frame_size)*sizeof(spx_word16_t)); - - st->h0_mem=(spx_word16_t*)speex_alloc((QMF_ORDER)*sizeof(spx_word16_t)); - st->h1_mem=(spx_word16_t*)speex_alloc((QMF_ORDER)*sizeof(spx_word16_t)); - - st->window= lpc_window; - - st->lagWindow = lag_window; - - st->old_lsp = (spx_lsp_t*)speex_alloc(st->lpcSize*sizeof(spx_lsp_t)); - st->old_qlsp = (spx_lsp_t*)speex_alloc(st->lpcSize*sizeof(spx_lsp_t)); - st->interp_qlpc = (spx_coef_t*)speex_alloc(st->lpcSize*sizeof(spx_coef_t)); - st->pi_gain = (spx_word32_t*)speex_alloc((st->nbSubframes)*sizeof(spx_word32_t)); - st->exc_rms = (spx_word16_t*)speex_alloc((st->nbSubframes)*sizeof(spx_word16_t)); - st->innov_rms_save = NULL; - - st->mem_sp = (spx_mem_t*)speex_alloc((st->lpcSize)*sizeof(spx_mem_t)); - st->mem_sp2 = (spx_mem_t*)speex_alloc((st->lpcSize)*sizeof(spx_mem_t)); - st->mem_sw = (spx_mem_t*)speex_alloc((st->lpcSize)*sizeof(spx_mem_t)); - - for (i=0;ilpcSize;i++) - st->old_lsp[i]= DIV32(MULT16_16(QCONST16(3.1415927f, LSP_SHIFT), i+1), st->lpcSize+1); - -#ifndef DISABLE_VBR - st->vbr_quality = 8; - st->vbr_enabled = 0; - st->vbr_max = 0; - st->vbr_max_high = 20000; /* We just need a big value here */ - st->vad_enabled = 0; - st->abr_enabled = 0; - st->relative_quality=0; -#endif /* #ifndef DISABLE_VBR */ - - st->complexity=2; - speex_encoder_ctl(st->st_low, SPEEX_GET_SAMPLING_RATE, &st->sampling_rate); - st->sampling_rate*=2; -#ifdef ENABLE_VALGRIND - VALGRIND_MAKE_READABLE(st, (st->stack-(char*)st)); -#endif - return st; -} - -void sb_encoder_destroy(void *state) -{ - SBEncState *st=(SBEncState*)state; - - speex_encoder_destroy(st->st_low); -#if !(defined(VAR_ARRAYS) || defined (USE_ALLOCA)) - /*speex_free_scratch(st->stack);*/ -#endif - - speex_free(st->high); - - speex_free(st->h0_mem); - speex_free(st->h1_mem); - - speex_free(st->old_lsp); - speex_free(st->old_qlsp); - speex_free(st->interp_qlpc); - speex_free(st->pi_gain); - speex_free(st->exc_rms); - - speex_free(st->mem_sp); - speex_free(st->mem_sp2); - speex_free(st->mem_sw); - - - speex_free(st); -} - - -int sb_encode(void *state, void *vin, SpeexBits *bits) -{ - SBEncState *st; - int i, roots, sub; - char *stack; - VARDECL(spx_mem_t *mem); - VARDECL(spx_sig_t *innov); - VARDECL(spx_word16_t *target); - VARDECL(spx_word16_t *syn_resp); - VARDECL(spx_word32_t *low_pi_gain); - spx_word16_t *low; - spx_word16_t *high; - VARDECL(spx_word16_t *low_exc_rms); - VARDECL(spx_word16_t *low_innov_rms); - const SpeexSBMode *mode; - spx_int32_t dtx; - spx_word16_t *in = (spx_word16_t*)vin; - spx_word16_t e_low=0, e_high=0; - VARDECL(spx_coef_t *lpc); - VARDECL(spx_coef_t *interp_lpc); - VARDECL(spx_coef_t *bw_lpc1); - VARDECL(spx_coef_t *bw_lpc2); - VARDECL(spx_lsp_t *lsp); - VARDECL(spx_lsp_t *qlsp); - VARDECL(spx_lsp_t *interp_lsp); - VARDECL(spx_lsp_t *interp_qlsp); - - st = (SBEncState*)state; - stack=st->stack; - mode = (const SpeexSBMode*)(st->mode->mode); - low = in; - high = in+st->frame_size; - - /* High-band buffering / sync with low band */ - /* Compute the two sub-bands by filtering with QMF h0*/ - qmf_decomp(in, h0, low, high, st->full_frame_size, QMF_ORDER, st->h0_mem, stack); - -#ifndef DISABLE_VBR - if (st->vbr_enabled || st->vad_enabled) - { - /* Need to compute things here before the signal is trashed by the encoder */ - /*FIXME: Are the two signals (low, high) in sync? */ - e_low = compute_rms16(low, st->frame_size); - e_high = compute_rms16(high, st->frame_size); - } -#endif /* #ifndef DISABLE_VBR */ - - ALLOC(low_innov_rms, st->nbSubframes, spx_word16_t); - speex_encoder_ctl(st->st_low, SPEEX_SET_INNOVATION_SAVE, low_innov_rms); - /* Encode the narrowband part*/ - speex_encode_native(st->st_low, low, bits); - - high = high - (st->windowSize-st->frame_size); - SPEEX_COPY(high, st->high, st->windowSize-st->frame_size); - SPEEX_COPY(st->high, &high[st->frame_size], st->windowSize-st->frame_size); - - - ALLOC(low_pi_gain, st->nbSubframes, spx_word32_t); - ALLOC(low_exc_rms, st->nbSubframes, spx_word16_t); - speex_encoder_ctl(st->st_low, SPEEX_GET_PI_GAIN, low_pi_gain); - speex_encoder_ctl(st->st_low, SPEEX_GET_EXC, low_exc_rms); - - speex_encoder_ctl(st->st_low, SPEEX_GET_LOW_MODE, &dtx); - - if (dtx==0) - dtx=1; - else - dtx=0; - - ALLOC(lpc, st->lpcSize, spx_coef_t); - ALLOC(interp_lpc, st->lpcSize, spx_coef_t); - ALLOC(bw_lpc1, st->lpcSize, spx_coef_t); - ALLOC(bw_lpc2, st->lpcSize, spx_coef_t); - - ALLOC(lsp, st->lpcSize, spx_lsp_t); - ALLOC(qlsp, st->lpcSize, spx_lsp_t); - ALLOC(interp_lsp, st->lpcSize, spx_lsp_t); - ALLOC(interp_qlsp, st->lpcSize, spx_lsp_t); - - { - VARDECL(spx_word16_t *autocorr); - VARDECL(spx_word16_t *w_sig); - ALLOC(autocorr, st->lpcSize+1, spx_word16_t); - ALLOC(w_sig, st->windowSize, spx_word16_t); - /* Window for analysis */ - /* FIXME: This is a kludge */ - if (st->subframeSize==80) - { - for (i=0;iwindowSize;i++) - w_sig[i] = EXTRACT16(SHR32(MULT16_16(high[i],st->window[i>>1]),SIG_SHIFT)); - } else { - for (i=0;iwindowSize;i++) - w_sig[i] = EXTRACT16(SHR32(MULT16_16(high[i],st->window[i]),SIG_SHIFT)); - } - /* Compute auto-correlation */ - _spx_autocorr(w_sig, autocorr, st->lpcSize+1, st->windowSize); - autocorr[0] = ADD16(autocorr[0],MULT16_16_Q15(autocorr[0],st->lpc_floor)); /* Noise floor in auto-correlation domain */ - - /* Lag windowing: equivalent to filtering in the power-spectrum domain */ - for (i=0;ilpcSize+1;i++) - autocorr[i] = MULT16_16_Q14(autocorr[i],st->lagWindow[i]); - - /* Levinson-Durbin */ - _spx_lpc(lpc, autocorr, st->lpcSize); - } - - /* LPC to LSPs (x-domain) transform */ - roots=lpc_to_lsp (lpc, st->lpcSize, lsp, 10, LSP_DELTA1, stack); - if (roots!=st->lpcSize) - { - roots = lpc_to_lsp (lpc, st->lpcSize, lsp, 10, LSP_DELTA2, stack); - if (roots!=st->lpcSize) { - /*If we can't find all LSP's, do some damage control and use a flat filter*/ - for (i=0;ilpcSize;i++) - { - lsp[i]=st->old_lsp[i]; - } - } - } - -#ifndef DISABLE_VBR - /* VBR code */ - if ((st->vbr_enabled || st->vad_enabled) && !dtx) - { - float ratio; - if (st->abr_enabled) - { - float qual_change=0; - if (st->abr_drift2 * st->abr_drift > 0) - { - /* Only adapt if long-term and short-term drift are the same sign */ - qual_change = -.00001*st->abr_drift/(1+st->abr_count); - if (qual_change>.1) - qual_change=.1; - if (qual_change<-.1) - qual_change=-.1; - } - st->vbr_quality += qual_change; - if (st->vbr_quality>10) - st->vbr_quality=10; - if (st->vbr_quality<0) - st->vbr_quality=0; - } - - - ratio = 2*log((1.f+e_high)/(1.f+e_low)); - - speex_encoder_ctl(st->st_low, SPEEX_GET_RELATIVE_QUALITY, &st->relative_quality); - if (ratio<-4) - ratio=-4; - if (ratio>2) - ratio=2; - /*if (ratio>-2)*/ - if (st->vbr_enabled) - { - spx_int32_t modeid; - modeid = mode->nb_modes-1; - st->relative_quality+=1.0*(ratio+2); - if (st->relative_quality<-1) - st->relative_quality=-1; - while (modeid) - { - int v1; - float thresh; - v1=(int)floor(st->vbr_quality); - if (v1==10) - thresh = mode->vbr_thresh[modeid][v1]; - else - thresh = (st->vbr_quality-v1) * mode->vbr_thresh[modeid][v1+1] + - (1+v1-st->vbr_quality) * mode->vbr_thresh[modeid][v1]; - if (st->relative_quality >= thresh && st->sampling_rate*st->submodes[modeid]->bits_per_frame/st->full_frame_size <= st->vbr_max_high) - break; - modeid--; - } - speex_encoder_ctl(state, SPEEX_SET_HIGH_MODE, &modeid); - if (st->abr_enabled) - { - spx_int32_t bitrate; - speex_encoder_ctl(state, SPEEX_GET_BITRATE, &bitrate); - st->abr_drift+=(bitrate-st->abr_enabled); - st->abr_drift2 = .95*st->abr_drift2 + .05*(bitrate-st->abr_enabled); - st->abr_count += 1.0; - } - - } else { - /* VAD only */ - int modeid; - if (st->relative_quality<2.0) - modeid=1; - else - modeid=st->submodeSelect; - /*speex_encoder_ctl(state, SPEEX_SET_MODE, &mode);*/ - st->submodeID=modeid; - - } - /*fprintf (stderr, "%f %f\n", ratio, low_qual);*/ - } -#endif /* #ifndef DISABLE_VBR */ - - if (st->encode_submode) - { - speex_bits_pack(bits, 1, 1); - if (dtx) - speex_bits_pack(bits, 0, SB_SUBMODE_BITS); - else - speex_bits_pack(bits, st->submodeID, SB_SUBMODE_BITS); - } - - /* If null mode (no transmission), just set a couple things to zero*/ - if (dtx || st->submodes[st->submodeID] == NULL) - { - for (i=0;iframe_size;i++) - high[i]=VERY_SMALL; - - for (i=0;ilpcSize;i++) - st->mem_sw[i]=0; - st->first=1; - - /* Final signal synthesis from excitation */ - iir_mem16(high, st->interp_qlpc, high, st->frame_size, st->lpcSize, st->mem_sp, stack); - - if (dtx) - return 0; - else - return 1; - } - - - /* LSP quantization */ - SUBMODE(lsp_quant)(lsp, qlsp, st->lpcSize, bits); - - if (st->first) - { - for (i=0;ilpcSize;i++) - st->old_lsp[i] = lsp[i]; - for (i=0;ilpcSize;i++) - st->old_qlsp[i] = qlsp[i]; - } - - ALLOC(mem, st->lpcSize, spx_mem_t); - ALLOC(syn_resp, st->subframeSize, spx_word16_t); - ALLOC(innov, st->subframeSize, spx_sig_t); - ALLOC(target, st->subframeSize, spx_word16_t); - - for (sub=0;subnbSubframes;sub++) - { - VARDECL(spx_word16_t *exc); - VARDECL(spx_word16_t *res); - VARDECL(spx_word16_t *sw); - spx_word16_t *sp; - spx_word16_t filter_ratio; /*Q7*/ - int offset; - spx_word32_t rl, rh; /*Q13*/ - spx_word16_t eh=0; - - offset = st->subframeSize*sub; - sp=high+offset; - ALLOC(exc, st->subframeSize, spx_word16_t); - ALLOC(res, st->subframeSize, spx_word16_t); - ALLOC(sw, st->subframeSize, spx_word16_t); - - /* LSP interpolation (quantized and unquantized) */ - lsp_interpolate(st->old_lsp, lsp, interp_lsp, st->lpcSize, sub, st->nbSubframes); - lsp_interpolate(st->old_qlsp, qlsp, interp_qlsp, st->lpcSize, sub, st->nbSubframes); - - lsp_enforce_margin(interp_lsp, st->lpcSize, LSP_MARGIN); - lsp_enforce_margin(interp_qlsp, st->lpcSize, LSP_MARGIN); - - lsp_to_lpc(interp_lsp, interp_lpc, st->lpcSize,stack); - lsp_to_lpc(interp_qlsp, st->interp_qlpc, st->lpcSize, stack); - - bw_lpc(st->gamma1, interp_lpc, bw_lpc1, st->lpcSize); - bw_lpc(st->gamma2, interp_lpc, bw_lpc2, st->lpcSize); - - /* Compute mid-band (4000 Hz for wideband) response of low-band and high-band - filters */ - st->pi_gain[sub]=LPC_SCALING; - rh = LPC_SCALING; - for (i=0;ilpcSize;i+=2) - { - rh += st->interp_qlpc[i+1] - st->interp_qlpc[i]; - st->pi_gain[sub] += st->interp_qlpc[i] + st->interp_qlpc[i+1]; - } - - rl = low_pi_gain[sub]; -#ifdef FIXED_POINT - filter_ratio=EXTRACT16(SATURATE(PDIV32(SHL32(ADD32(rl,82),7),ADD32(82,rh)),32767)); -#else - filter_ratio=(rl+.01)/(rh+.01); -#endif - - /* Compute "real excitation" */ - fir_mem16(sp, st->interp_qlpc, exc, st->subframeSize, st->lpcSize, st->mem_sp2, stack); - /* Compute energy of low-band and high-band excitation */ - - eh = compute_rms16(exc, st->subframeSize); - - if (!SUBMODE(innovation_quant)) {/* 1 for spectral folding excitation, 0 for stochastic */ - spx_word32_t g; /*Q7*/ - spx_word16_t el; /*Q0*/ - el = low_innov_rms[sub]; - - /* Gain to use if we want to use the low-band excitation for high-band */ - g=PDIV32(MULT16_16(filter_ratio,eh),EXTEND32(ADD16(1,el))); - -#if 0 - { - char *tmp_stack=stack; - float *tmp_sig; - float g2; - ALLOC(tmp_sig, st->subframeSize, spx_sig_t); - for (i=0;ilpcSize;i++) - mem[i]=st->mem_sp[i]; - iir_mem2(st->low_innov+offset, st->interp_qlpc, tmp_sig, st->subframeSize, st->lpcSize, mem); - g2 = compute_rms(sp, st->subframeSize)/(.01+compute_rms(tmp_sig, st->subframeSize)); - /*fprintf (stderr, "gains: %f %f\n", g, g2);*/ - g = g2; - stack = tmp_stack; - } -#endif - - /*print_vec(&g, 1, "gain factor");*/ - /* Gain quantization */ - { - int quant = scal_quant(g, fold_quant_bound, 32); - /*speex_warning_int("tata", quant);*/ - if (quant<0) - quant=0; - if (quant>31) - quant=31; - speex_bits_pack(bits, quant, 5); - } - if (st->innov_rms_save) - { - st->innov_rms_save[sub] = eh; - } - st->exc_rms[sub] = eh; - } else { - spx_word16_t gc; /*Q7*/ - spx_word32_t scale; /*Q14*/ - spx_word16_t el; /*Q0*/ - el = low_exc_rms[sub]; /*Q0*/ - - gc = PDIV32_16(MULT16_16(filter_ratio,1+eh),1+el); - - /* This is a kludge that cleans up a historical bug */ - if (st->subframeSize==80) - gc = MULT16_16_P15(QCONST16(0.70711f,15),gc); - /*printf ("%f %f %f %f\n", el, eh, filter_ratio, gc);*/ - { - int qgc = scal_quant(gc, gc_quant_bound, 16); - speex_bits_pack(bits, qgc, 4); - gc = MULT16_16_Q15(QCONST16(0.87360,15),gc_quant_bound[qgc]); - } - if (st->subframeSize==80) - gc = MULT16_16_P14(QCONST16(1.4142f,14), gc); - - scale = SHL32(MULT16_16(PDIV32_16(SHL32(EXTEND32(gc),SIG_SHIFT-6),filter_ratio),(1+el)),6); - - compute_impulse_response(st->interp_qlpc, bw_lpc1, bw_lpc2, syn_resp, st->subframeSize, st->lpcSize, stack); - - - /* Reset excitation */ - for (i=0;isubframeSize;i++) - res[i]=VERY_SMALL; - - /* Compute zero response (ringing) of A(z/g1) / ( A(z/g2) * Aq(z) ) */ - for (i=0;ilpcSize;i++) - mem[i]=st->mem_sp[i]; - iir_mem16(res, st->interp_qlpc, res, st->subframeSize, st->lpcSize, mem, stack); - - for (i=0;ilpcSize;i++) - mem[i]=st->mem_sw[i]; - filter_mem16(res, bw_lpc1, bw_lpc2, res, st->subframeSize, st->lpcSize, mem, stack); - - /* Compute weighted signal */ - for (i=0;ilpcSize;i++) - mem[i]=st->mem_sw[i]; - filter_mem16(sp, bw_lpc1, bw_lpc2, sw, st->subframeSize, st->lpcSize, mem, stack); - - /* Compute target signal */ - for (i=0;isubframeSize;i++) - target[i]=SUB16(sw[i],res[i]); - - signal_div(target, target, scale, st->subframeSize); - - /* Reset excitation */ - SPEEX_MEMSET(innov, 0, st->subframeSize); - - /*print_vec(target, st->subframeSize, "\ntarget");*/ - SUBMODE(innovation_quant)(target, st->interp_qlpc, bw_lpc1, bw_lpc2, - SUBMODE(innovation_params), st->lpcSize, st->subframeSize, - innov, syn_resp, bits, stack, st->complexity, SUBMODE(double_codebook)); - /*print_vec(target, st->subframeSize, "after");*/ - - signal_mul(innov, innov, scale, st->subframeSize); - - if (SUBMODE(double_codebook)) { - char *tmp_stack=stack; - VARDECL(spx_sig_t *innov2); - ALLOC(innov2, st->subframeSize, spx_sig_t); - SPEEX_MEMSET(innov2, 0, st->subframeSize); - for (i=0;isubframeSize;i++) - target[i]=MULT16_16_P13(QCONST16(2.5f,13), target[i]); - - SUBMODE(innovation_quant)(target, st->interp_qlpc, bw_lpc1, bw_lpc2, - SUBMODE(innovation_params), st->lpcSize, st->subframeSize, - innov2, syn_resp, bits, stack, st->complexity, 0); - signal_mul(innov2, innov2, MULT16_32_P15(QCONST16(0.4f,15),scale), st->subframeSize); - - for (i=0;isubframeSize;i++) - innov[i] = ADD32(innov[i],innov2[i]); - stack = tmp_stack; - } - for (i=0;isubframeSize;i++) - exc[i] = PSHR32(innov[i],SIG_SHIFT); - - if (st->innov_rms_save) - { - st->innov_rms_save[sub] = MULT16_16_Q15(QCONST16(.70711f, 15), compute_rms(innov, st->subframeSize)); - } - st->exc_rms[sub] = compute_rms16(exc, st->subframeSize); - - - } - - - /*Keep the previous memory*/ - for (i=0;ilpcSize;i++) - mem[i]=st->mem_sp[i]; - /* Final signal synthesis from excitation */ - iir_mem16(exc, st->interp_qlpc, sp, st->subframeSize, st->lpcSize, st->mem_sp, stack); - - /* Compute weighted signal again, from synthesized speech (not sure it's the right thing) */ - filter_mem16(sp, bw_lpc1, bw_lpc2, sw, st->subframeSize, st->lpcSize, st->mem_sw, stack); - } - - for (i=0;ilpcSize;i++) - st->old_lsp[i] = lsp[i]; - for (i=0;ilpcSize;i++) - st->old_qlsp[i] = qlsp[i]; - - st->first=0; - - return 1; -} -#endif /* SPEEX_DISABLE_ENCODER */ - - - -static SBDecState global_decstate_wb IBSS_ATTR; -/* Do not include this for voice codec, files will never be UWB */ -#ifndef ROCKBOX_VOICE_CODEC -static SBDecState global_decstate_uwb IBSS_ATTR; -#endif - -void *sb_decoder_init(const SpeexMode *m) -{ - spx_int32_t tmp; - SBDecState *st; - const SpeexSBMode *mode; -/* - st = (SBDecState*)speex_alloc(sizeof(SBDecState)); - if (!st) - return NULL; -*/ -#ifndef ROCKBOX_VOICE_CODEC - if (m->modeID == SPEEX_MODEID_UWB) - st = &global_decstate_uwb; - else -#endif - st = &global_decstate_wb; - memset(st, 0, sizeof(*st)); - st->mode = m; - mode=(const SpeexSBMode*)m->mode; - st->encode_submode = 1; - - st->st_low = speex_decoder_init(mode->nb_mode); -#if defined(VAR_ARRAYS) || defined (USE_ALLOCA) - st->stack = NULL; -#else - /*st->stack = (char*)speex_alloc_scratch(SB_DEC_STACK);*/ - speex_decoder_ctl(st->st_low, SPEEX_GET_STACK, &st->stack); -#endif - - st->full_frame_size = 2*mode->frameSize; - st->frame_size = mode->frameSize; - st->subframeSize = mode->subframeSize; - st->nbSubframes = mode->frameSize/mode->subframeSize; - st->lpcSize=mode->lpcSize; - speex_decoder_ctl(st->st_low, SPEEX_GET_SAMPLING_RATE, &st->sampling_rate); - st->sampling_rate*=2; - tmp=1; - speex_decoder_ctl(st->st_low, SPEEX_SET_WIDEBAND, &tmp); - - st->submodes=mode->submodes; - st->submodeID=mode->defaultSubmode; - - st->first=1; - - /* st->g0_mem = (spx_word32_t*)speex_alloc((QMF_ORDER)*sizeof(spx_word32_t)); */ - /* st->g1_mem = (spx_word32_t*)speex_alloc((QMF_ORDER)*sizeof(spx_word32_t)); */ - - /* st->excBuf = (spx_word16_t*)speex_alloc((st->subframeSize)*sizeof(spx_word16_t)); */ - - /* st->old_qlsp = (spx_lsp_t*)speex_alloc((st->lpcSize)*sizeof(spx_lsp_t)); */ - /* st->interp_qlpc = (spx_coef_t*)speex_alloc(st->lpcSize*sizeof(spx_coef_t)); */ - - /* st->pi_gain = (spx_word32_t*)speex_alloc((st->nbSubframes)*sizeof(spx_word32_t)); */ - /*st->exc_rms = (spx_word16_t*)speex_alloc((st->nbSubframes)*sizeof(spx_word16_t)); */ - /* st->mem_sp = (spx_mem_t*)speex_alloc((2*st->lpcSize)*sizeof(spx_mem_t)); */ - - st->innov_save = NULL; - - - st->lpc_enh_enabled=0; - st->seed = 1000; - -#ifdef ENABLE_VALGRIND - VALGRIND_MAKE_READABLE(st, (st->stack-(char*)st)); -#endif - return st; -} - -void sb_decoder_destroy(void *state) -{ - SBDecState *st; - st = (SBDecState*)state; - speex_decoder_destroy(st->st_low); -#if !(defined(VAR_ARRAYS) || defined (USE_ALLOCA)) - /*speex_free_scratch(st->stack);*/ -#endif -/* - speex_free(st->g0_mem); - speex_free(st->g1_mem); - speex_free(st->excBuf); - speex_free(st->old_qlsp); - speex_free(st->interp_qlpc); - speex_free(st->pi_gain); - speex_free(st->exc_rms); - speex_free(st->mem_sp); - - speex_free(state); -*/ -} - -#ifndef ROCKBOX_VOICE_CODEC -static void sb_decode_lost(SBDecState *st, spx_word16_t *out, int dtx, char *stack) -{ - int i; - int saved_modeid=0; - - if (dtx) - { - saved_modeid=st->submodeID; - st->submodeID=1; - } else { - bw_lpc(QCONST16(0.99f,15), st->interp_qlpc, st->interp_qlpc, st->lpcSize); - } - - st->first=1; - - - /* Final signal synthesis from excitation */ - if (!dtx) - { - st->last_ener = MULT16_16_Q15(QCONST16(.9f,15),st->last_ener); - } - for (i=0;iframe_size;i++) - out[i+st->frame_size] = speex_rand(st->last_ener, &st->seed); - - iir_mem16(out+st->frame_size, st->interp_qlpc, out+st->frame_size, st->frame_size, st->lpcSize, - st->mem_sp, stack); - - - /* Reconstruct the original */ - qmf_synth(out, out+st->frame_size, h0, out, st->full_frame_size, QMF_ORDER, st->g0_mem, st->g1_mem, stack); - if (dtx) - { - st->submodeID=saved_modeid; - } - - return; -} -#endif - -int sb_decode(void *state, SpeexBits *bits, void *vout) -{ - int i, sub; - SBDecState *st; - int wideband; - int ret; - char *stack; - VARDECL(spx_word32_t *low_pi_gain); - VARDECL(spx_word16_t *low_exc_rms); - VARDECL(spx_coef_t *ak); - VARDECL(spx_lsp_t *qlsp); - VARDECL(spx_lsp_t *interp_qlsp); - spx_int32_t dtx; - const SpeexSBMode *mode; - spx_word16_t *out = (spx_word16_t*)vout; - spx_word16_t *low_innov_alias; - spx_word32_t exc_ener_sum = 0; - - st = (SBDecState*)state; - stack=st->stack; - mode = (const SpeexSBMode*)(st->mode->mode); - - low_innov_alias = out+st->frame_size; - speex_decoder_ctl(st->st_low, SPEEX_SET_INNOVATION_SAVE, low_innov_alias); - /* Decode the low-band */ - ret = speex_decode_native(st->st_low, bits, out); - - speex_decoder_ctl(st->st_low, SPEEX_GET_DTX_STATUS, &dtx); - - /* If error decoding the narrowband part, propagate error */ - if (ret!=0) - { - return ret; - } - -#ifndef ROCKBOX_VOICE_CODEC - if (!bits) - { - sb_decode_lost(st, out, dtx, stack); - return 0; - } -#endif - - if (st->encode_submode) - { - - /*Check "wideband bit"*/ - if (speex_bits_remaining(bits)>0) - wideband = speex_bits_peek(bits); - else - wideband = 0; - if (wideband) - { - /*Regular wideband frame, read the submode*/ - wideband = speex_bits_unpack_unsigned(bits, 1); - st->submodeID = speex_bits_unpack_unsigned(bits, SB_SUBMODE_BITS); - } else - { - /*Was a narrowband frame, set "null submode"*/ - st->submodeID = 0; - } - if (st->submodeID != 0 && st->submodes[st->submodeID] == NULL) - { - speex_notify("Invalid mode encountered. The stream is corrupted."); - return -2; - } - } - - /* If null mode (no transmission), just set a couple things to zero*/ - if (st->submodes[st->submodeID] == NULL) - { -#ifndef ROCKBOX_VOICE_CODEC - if (dtx) - { - sb_decode_lost(st, out, 1, stack); - return 0; - } -#endif - - for (i=0;iframe_size;i++) - out[st->frame_size+i]=VERY_SMALL; - - st->first=1; - - /* Final signal synthesis from excitation */ - iir_mem16(out+st->frame_size, st->interp_qlpc, out+st->frame_size, st->frame_size, st->lpcSize, st->mem_sp, stack); - - qmf_synth(out, out+st->frame_size, h0, out, st->full_frame_size, QMF_ORDER, st->g0_mem, st->g1_mem, stack); - - return 0; - - } - - ALLOC(low_pi_gain, st->nbSubframes, spx_word32_t); - ALLOC(low_exc_rms, st->nbSubframes, spx_word16_t); - speex_decoder_ctl(st->st_low, SPEEX_GET_PI_GAIN, low_pi_gain); - speex_decoder_ctl(st->st_low, SPEEX_GET_EXC, low_exc_rms); - - ALLOC(qlsp, st->lpcSize, spx_lsp_t); - ALLOC(interp_qlsp, st->lpcSize, spx_lsp_t); - SUBMODE(lsp_unquant)(qlsp, st->lpcSize, bits); - - if (st->first) - { - for (i=0;ilpcSize;i++) - st->old_qlsp[i] = qlsp[i]; - } - - ALLOC(ak, st->lpcSize, spx_coef_t); - - for (sub=0;subnbSubframes;sub++) - { - VARDECL(spx_word32_t *exc); - spx_word16_t *innov_save=NULL; - spx_word16_t *sp; - spx_word16_t filter_ratio; - spx_word16_t el=0; - int offset; - spx_word32_t rl=0,rh=0; - - offset = st->subframeSize*sub; - sp=out+st->frame_size+offset; - ALLOC(exc, st->subframeSize, spx_word32_t); - /* Pointer for saving innovation */ - if (st->innov_save) - { - innov_save = st->innov_save+2*offset; - SPEEX_MEMSET(innov_save, 0, 2*st->subframeSize); - } - - /* LSP interpolation */ - lsp_interpolate(st->old_qlsp, qlsp, interp_qlsp, st->lpcSize, sub, st->nbSubframes); - - lsp_enforce_margin(interp_qlsp, st->lpcSize, LSP_MARGIN); - - /* LSP to LPC */ - lsp_to_lpc(interp_qlsp, ak, st->lpcSize, stack); - - /* Calculate reponse ratio between the low and high filter in the middle - of the band (4000 Hz) */ - - st->pi_gain[sub]=LPC_SCALING; - rh = LPC_SCALING; - for (i=0;ilpcSize;i+=2) - { - rh += ak[i+1] - ak[i]; - st->pi_gain[sub] += ak[i] + ak[i+1]; - } - - rl = low_pi_gain[sub]; -#ifdef FIXED_POINT - filter_ratio=EXTRACT16(SATURATE(PDIV32(SHL32(ADD32(rl,82),7),ADD32(82,rh)),32767)); -#else - filter_ratio=(rl+.01)/(rh+.01); -#endif - - SPEEX_MEMSET(exc, 0, st->subframeSize); - if (!SUBMODE(innovation_unquant)) - { - spx_word32_t g; - int quant; - - quant = speex_bits_unpack_unsigned(bits, 5); - g= spx_exp(MULT16_16(QCONST16(.125f,11),(quant-10))); - - g = PDIV32(g, filter_ratio); - - for (i=0;isubframeSize;i+=2) - { - exc[i]=SHL32(MULT16_32_P15(MULT16_16_Q15(mode->folding_gain,low_innov_alias[offset+i]),SHL32(g,6)),SIG_SHIFT); - exc[i+1]=NEG32(SHL32(MULT16_32_P15(MULT16_16_Q15(mode->folding_gain,low_innov_alias[offset+i+1]),SHL32(g,6)),SIG_SHIFT)); - } - - } else { - spx_word16_t gc; - spx_word32_t scale; - int qgc = speex_bits_unpack_unsigned(bits, 4); - - el = low_exc_rms[sub]; - gc = MULT16_16_Q15(QCONST16(0.87360,15),gc_quant_bound[qgc]); - - if (st->subframeSize==80) - gc = MULT16_16_P14(QCONST16(1.4142f,14),gc); - - scale = SHL32(PDIV32(SHL32(MULT16_16(gc, el),3), filter_ratio),SIG_SHIFT-3); - SUBMODE(innovation_unquant)(exc, SUBMODE(innovation_params), st->subframeSize, - bits, stack, &st->seed); - - signal_mul(exc,exc,scale,st->subframeSize); - - if (SUBMODE(double_codebook)) { - char *tmp_stack=stack; - VARDECL(spx_sig_t *innov2); - ALLOC(innov2, st->subframeSize, spx_sig_t); - SPEEX_MEMSET(innov2, 0, st->subframeSize); - SUBMODE(innovation_unquant)(innov2, SUBMODE(innovation_params), st->subframeSize, - bits, stack, &st->seed); - signal_mul(innov2, innov2, MULT16_32_P15(QCONST16(0.4f,15),scale), st->subframeSize); - for (i=0;isubframeSize;i++) - exc[i] = ADD32(exc[i],innov2[i]); - stack = tmp_stack; - } - - } - - if (st->innov_save) - { - for (i=0;isubframeSize;i++) - innov_save[2*i]=EXTRACT16(PSHR32(exc[i],SIG_SHIFT)); - } - - iir_mem16(st->excBuf, st->interp_qlpc, sp, st->subframeSize, st->lpcSize, - st->mem_sp, stack); - for (i=0;isubframeSize;i++) - st->excBuf[i]=EXTRACT16(PSHR32(exc[i],SIG_SHIFT)); - for (i=0;ilpcSize;i++) - st->interp_qlpc[i] = ak[i]; - st->exc_rms[sub] = compute_rms16(st->excBuf, st->subframeSize); - exc_ener_sum = ADD32(exc_ener_sum, DIV32(MULT16_16(st->exc_rms[sub],st->exc_rms[sub]), st->nbSubframes)); - } - st->last_ener = spx_sqrt(exc_ener_sum); - - qmf_synth(out, out+st->frame_size, h0, out, st->full_frame_size, QMF_ORDER, st->g0_mem, st->g1_mem, stack); - for (i=0;ilpcSize;i++) - st->old_qlsp[i] = qlsp[i]; - - st->first=0; - - return 0; -} - -#ifndef SPEEX_DISABLE_ENCODER -int sb_encoder_ctl(void *state, int request, void *ptr) -{ - SBEncState *st; - st=(SBEncState*)state; - switch(request) - { - case SPEEX_GET_FRAME_SIZE: - (*(spx_int32_t*)ptr) = st->full_frame_size; - break; - case SPEEX_SET_HIGH_MODE: - st->submodeSelect = st->submodeID = (*(spx_int32_t*)ptr); - break; - case SPEEX_SET_LOW_MODE: - speex_encoder_ctl(st->st_low, SPEEX_SET_LOW_MODE, ptr); - break; - case SPEEX_SET_DTX: - speex_encoder_ctl(st->st_low, SPEEX_SET_DTX, ptr); - break; - case SPEEX_GET_DTX: - speex_encoder_ctl(st->st_low, SPEEX_GET_DTX, ptr); - break; - case SPEEX_GET_LOW_MODE: - speex_encoder_ctl(st->st_low, SPEEX_GET_LOW_MODE, ptr); - break; - case SPEEX_SET_MODE: - speex_encoder_ctl(st, SPEEX_SET_QUALITY, ptr); - break; -#ifndef DISABLE_VBR - case SPEEX_SET_VBR: - st->vbr_enabled = (*(spx_int32_t*)ptr); - speex_encoder_ctl(st->st_low, SPEEX_SET_VBR, ptr); - break; - case SPEEX_GET_VBR: - (*(spx_int32_t*)ptr) = st->vbr_enabled; - break; - case SPEEX_SET_VAD: - st->vad_enabled = (*(spx_int32_t*)ptr); - speex_encoder_ctl(st->st_low, SPEEX_SET_VAD, ptr); - break; - case SPEEX_GET_VAD: - (*(spx_int32_t*)ptr) = st->vad_enabled; - break; -#endif /* #ifndef DISABLE_VBR */ -#if !defined(DISABLE_VBR) && !defined(DISABLE_FLOAT_API) - case SPEEX_SET_VBR_QUALITY: - { - spx_int32_t q; - float qual = (*(float*)ptr)+.6; - st->vbr_quality = (*(float*)ptr); - if (qual>10) - qual=10; - q=(int)floor(.5+*(float*)ptr); - if (q>10) - q=10; - speex_encoder_ctl(st->st_low, SPEEX_SET_VBR_QUALITY, &qual); - speex_encoder_ctl(state, SPEEX_SET_QUALITY, &q); - break; - } - case SPEEX_GET_VBR_QUALITY: - (*(float*)ptr) = st->vbr_quality; - break; -#endif /* #if !defined(DISABLE_VBR) && !defined(DISABLE_FLOAT_API) */ -#ifndef DISABLE_VBR - case SPEEX_SET_ABR: - st->abr_enabled = (*(spx_int32_t*)ptr); - st->vbr_enabled = st->abr_enabled!=0; - speex_encoder_ctl(st->st_low, SPEEX_SET_VBR, &st->vbr_enabled); - if (st->vbr_enabled) - { - spx_int32_t i=10, rate, target; - float vbr_qual; - target = (*(spx_int32_t*)ptr); - while (i>=0) - { - speex_encoder_ctl(st, SPEEX_SET_QUALITY, &i); - speex_encoder_ctl(st, SPEEX_GET_BITRATE, &rate); - if (rate <= target) - break; - i--; - } - vbr_qual=i; - if (vbr_qual<0) - vbr_qual=0; - speex_encoder_ctl(st, SPEEX_SET_VBR_QUALITY, &vbr_qual); - st->abr_count=0; - st->abr_drift=0; - st->abr_drift2=0; - } - - break; - case SPEEX_GET_ABR: - (*(spx_int32_t*)ptr) = st->abr_enabled; - break; -#endif /* #ifndef DISABLE_VBR */ - - case SPEEX_SET_QUALITY: - { - spx_int32_t nb_qual; - int quality = (*(spx_int32_t*)ptr); - if (quality < 0) - quality = 0; - if (quality > 10) - quality = 10; - st->submodeSelect = st->submodeID = ((const SpeexSBMode*)(st->mode->mode))->quality_map[quality]; - nb_qual = ((const SpeexSBMode*)(st->mode->mode))->low_quality_map[quality]; - speex_encoder_ctl(st->st_low, SPEEX_SET_MODE, &nb_qual); - } - break; - case SPEEX_SET_COMPLEXITY: - speex_encoder_ctl(st->st_low, SPEEX_SET_COMPLEXITY, ptr); - st->complexity = (*(spx_int32_t*)ptr); - if (st->complexity<1) - st->complexity=1; - break; - case SPEEX_GET_COMPLEXITY: - (*(spx_int32_t*)ptr) = st->complexity; - break; - case SPEEX_SET_BITRATE: - { - spx_int32_t i=10; - spx_int32_t rate, target; - target = (*(spx_int32_t*)ptr); - while (i>=0) - { - speex_encoder_ctl(st, SPEEX_SET_QUALITY, &i); - speex_encoder_ctl(st, SPEEX_GET_BITRATE, &rate); - if (rate <= target) - break; - i--; - } - } - break; - case SPEEX_GET_BITRATE: - speex_encoder_ctl(st->st_low, request, ptr); - /*fprintf (stderr, "before: %d\n", (*(int*)ptr));*/ - if (st->submodes[st->submodeID]) - (*(spx_int32_t*)ptr) += st->sampling_rate*SUBMODE(bits_per_frame)/st->full_frame_size; - else - (*(spx_int32_t*)ptr) += st->sampling_rate*(SB_SUBMODE_BITS+1)/st->full_frame_size; - /*fprintf (stderr, "after: %d\n", (*(int*)ptr));*/ - break; - case SPEEX_SET_SAMPLING_RATE: - { - spx_int32_t tmp=(*(spx_int32_t*)ptr); - st->sampling_rate = tmp; - tmp>>=1; - speex_encoder_ctl(st->st_low, SPEEX_SET_SAMPLING_RATE, &tmp); - } - break; - case SPEEX_GET_SAMPLING_RATE: - (*(spx_int32_t*)ptr)=st->sampling_rate; - break; - case SPEEX_RESET_STATE: - { - int i; - st->first = 1; - for (i=0;ilpcSize;i++) - st->old_lsp[i]= DIV32(MULT16_16(QCONST16(3.1415927f, LSP_SHIFT), i+1), st->lpcSize+1); - for (i=0;ilpcSize;i++) - st->mem_sw[i]=st->mem_sp[i]=st->mem_sp2[i]=0; - for (i=0;ih0_mem[i]=st->h1_mem[i]=0; - } - break; - case SPEEX_SET_SUBMODE_ENCODING: - st->encode_submode = (*(spx_int32_t*)ptr); - speex_encoder_ctl(st->st_low, SPEEX_SET_SUBMODE_ENCODING, ptr); - break; - case SPEEX_GET_SUBMODE_ENCODING: - (*(spx_int32_t*)ptr) = st->encode_submode; - break; - case SPEEX_GET_LOOKAHEAD: - speex_encoder_ctl(st->st_low, SPEEX_GET_LOOKAHEAD, ptr); - (*(spx_int32_t*)ptr) = 2*(*(spx_int32_t*)ptr) + QMF_ORDER - 1; - break; - case SPEEX_SET_PLC_TUNING: - speex_encoder_ctl(st->st_low, SPEEX_SET_PLC_TUNING, ptr); - break; - case SPEEX_GET_PLC_TUNING: - speex_encoder_ctl(st->st_low, SPEEX_GET_PLC_TUNING, ptr); - break; -#ifndef DISABLE_VBR - case SPEEX_SET_VBR_MAX_BITRATE: - { - st->vbr_max = (*(spx_int32_t*)ptr); - if (SPEEX_SET_VBR_MAX_BITRATE<1) - { - speex_encoder_ctl(st->st_low, SPEEX_SET_VBR_MAX_BITRATE, &st->vbr_max); - st->vbr_max_high = 17600; - } else { - spx_int32_t low_rate; - if (st->vbr_max >= 42200) - { - st->vbr_max_high = 17600; - } else if (st->vbr_max >= 27800) - { - st->vbr_max_high = 9600; - } else if (st->vbr_max > 20600) - { - st->vbr_max_high = 5600; - } else { - st->vbr_max_high = 1800; - } - if (st->subframeSize==80) - st->vbr_max_high = 1800; - low_rate = st->vbr_max - st->vbr_max_high; - speex_encoder_ctl(st->st_low, SPEEX_SET_VBR_MAX_BITRATE, &low_rate); - } - } - break; - case SPEEX_GET_VBR_MAX_BITRATE: - (*(spx_int32_t*)ptr) = st->vbr_max; - break; -#endif /* #ifndef DISABLE_VBR */ - case SPEEX_SET_HIGHPASS: - speex_encoder_ctl(st->st_low, SPEEX_SET_HIGHPASS, ptr); - break; - case SPEEX_GET_HIGHPASS: - speex_encoder_ctl(st->st_low, SPEEX_GET_HIGHPASS, ptr); - break; - - - /* This is all internal stuff past this point */ - case SPEEX_GET_PI_GAIN: - { - int i; - spx_word32_t *g = (spx_word32_t*)ptr; - for (i=0;inbSubframes;i++) - g[i]=st->pi_gain[i]; - } - break; - case SPEEX_GET_EXC: - { - int i; - for (i=0;inbSubframes;i++) - ((spx_word16_t*)ptr)[i] = st->exc_rms[i]; - } - break; -#ifndef DISABLE_VBR - case SPEEX_GET_RELATIVE_QUALITY: - (*(float*)ptr)=st->relative_quality; - break; -#endif /* #ifndef DISABLE_VBR */ - case SPEEX_SET_INNOVATION_SAVE: - st->innov_rms_save = (spx_word16_t*)ptr; - break; - case SPEEX_SET_WIDEBAND: - speex_encoder_ctl(st->st_low, SPEEX_SET_WIDEBAND, ptr); - break; - case SPEEX_GET_STACK: - *((char**)ptr) = st->stack; - break; - default: - speex_warning_int("Unknown nb_ctl request: ", request); - return -1; - } - return 0; -} -#endif /* SPEEX_DISABLE_ENCODER */ - -int sb_decoder_ctl(void *state, int request, void *ptr) -{ - SBDecState *st; - st=(SBDecState*)state; - switch(request) - { - case SPEEX_SET_HIGH_MODE: - st->submodeID = (*(spx_int32_t*)ptr); - break; - case SPEEX_SET_LOW_MODE: - speex_decoder_ctl(st->st_low, SPEEX_SET_LOW_MODE, ptr); - break; - case SPEEX_GET_LOW_MODE: - speex_decoder_ctl(st->st_low, SPEEX_GET_LOW_MODE, ptr); - break; - case SPEEX_GET_FRAME_SIZE: - (*(spx_int32_t*)ptr) = st->full_frame_size; - break; - case SPEEX_SET_ENH: - speex_decoder_ctl(st->st_low, request, ptr); - st->lpc_enh_enabled = *((spx_int32_t*)ptr); - break; - case SPEEX_GET_ENH: - *((spx_int32_t*)ptr) = st->lpc_enh_enabled; - break; - case SPEEX_SET_MODE: - case SPEEX_SET_QUALITY: - { - spx_int32_t nb_qual; - int quality = (*(spx_int32_t*)ptr); - if (quality < 0) - quality = 0; - if (quality > 10) - quality = 10; - st->submodeID = ((const SpeexSBMode*)(st->mode->mode))->quality_map[quality]; - nb_qual = ((const SpeexSBMode*)(st->mode->mode))->low_quality_map[quality]; - speex_decoder_ctl(st->st_low, SPEEX_SET_MODE, &nb_qual); - } - break; - case SPEEX_GET_BITRATE: - speex_decoder_ctl(st->st_low, request, ptr); - if (st->submodes[st->submodeID]) - (*(spx_int32_t*)ptr) += st->sampling_rate*SUBMODE(bits_per_frame)/st->full_frame_size; - else - (*(spx_int32_t*)ptr) += st->sampling_rate*(SB_SUBMODE_BITS+1)/st->full_frame_size; - break; - case SPEEX_SET_SAMPLING_RATE: - { - spx_int32_t tmp=(*(spx_int32_t*)ptr); - st->sampling_rate = tmp; - tmp>>=1; - speex_decoder_ctl(st->st_low, SPEEX_SET_SAMPLING_RATE, &tmp); - } - break; - case SPEEX_GET_SAMPLING_RATE: - (*(spx_int32_t*)ptr)=st->sampling_rate; - break; - case SPEEX_SET_HANDLER: - speex_decoder_ctl(st->st_low, SPEEX_SET_HANDLER, ptr); - break; - case SPEEX_SET_USER_HANDLER: - speex_decoder_ctl(st->st_low, SPEEX_SET_USER_HANDLER, ptr); - break; - case SPEEX_RESET_STATE: - { - int i; - for (i=0;i<2*st->lpcSize;i++) - st->mem_sp[i]=0; - for (i=0;ig0_mem[i]=st->g1_mem[i]=0; - st->last_ener=0; - } - break; - case SPEEX_SET_SUBMODE_ENCODING: - st->encode_submode = (*(spx_int32_t*)ptr); - speex_decoder_ctl(st->st_low, SPEEX_SET_SUBMODE_ENCODING, ptr); - break; - case SPEEX_GET_SUBMODE_ENCODING: - (*(spx_int32_t*)ptr) = st->encode_submode; - break; - case SPEEX_GET_LOOKAHEAD: - speex_decoder_ctl(st->st_low, SPEEX_GET_LOOKAHEAD, ptr); - (*(spx_int32_t*)ptr) = 2*(*(spx_int32_t*)ptr); - break; - case SPEEX_SET_HIGHPASS: - speex_decoder_ctl(st->st_low, SPEEX_SET_HIGHPASS, ptr); - break; - case SPEEX_GET_HIGHPASS: - speex_decoder_ctl(st->st_low, SPEEX_GET_HIGHPASS, ptr); - break; - case SPEEX_GET_ACTIVITY: - speex_decoder_ctl(st->st_low, SPEEX_GET_ACTIVITY, ptr); - break; - case SPEEX_GET_PI_GAIN: - { - int i; - spx_word32_t *g = (spx_word32_t*)ptr; - for (i=0;inbSubframes;i++) - g[i]=st->pi_gain[i]; - } - break; - case SPEEX_GET_EXC: - { - int i; - for (i=0;inbSubframes;i++) - ((spx_word16_t*)ptr)[i] = st->exc_rms[i]; - } - break; - case SPEEX_GET_DTX_STATUS: - speex_decoder_ctl(st->st_low, SPEEX_GET_DTX_STATUS, ptr); - break; - case SPEEX_SET_INNOVATION_SAVE: - st->innov_save = (spx_word16_t*)ptr; - break; - case SPEEX_SET_WIDEBAND: - speex_decoder_ctl(st->st_low, SPEEX_SET_WIDEBAND, ptr); - break; - case SPEEX_GET_STACK: - *((char**)ptr) = st->stack; - break; - default: - speex_warning_int("Unknown nb_ctl request: ", request); - return -1; - } - return 0; -} - -#endif - diff --git a/apps/codecs/libspeex/sb_celp.h b/apps/codecs/libspeex/sb_celp.h deleted file mode 100644 index 5a65d1ff8d..0000000000 --- a/apps/codecs/libspeex/sb_celp.h +++ /dev/null @@ -1,160 +0,0 @@ -/* Copyright (C) 2002-2006 Jean-Marc Valin */ -/** - @file sb_celp.h - @brief Sub-band CELP mode used for wideband encoding -*/ -/* - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of the Xiph.org Foundation nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*/ - -#ifndef SB_CELP_H -#define SB_CELP_H - -#include "modes.h" -#include "speex/speex_bits.h" -#include "nb_celp.h" - -/**Structure representing the full state of the sub-band encoder*/ -typedef struct SBEncState { - const SpeexMode *mode; /**< Pointer to the mode (containing for vtable info) */ - void *st_low; /**< State of the low-band (narrowband) encoder */ - int full_frame_size; /**< Length of full-band frames*/ - int frame_size; /**< Length of high-band frames*/ - int subframeSize; /**< Length of high-band sub-frames*/ - int nbSubframes; /**< Number of high-band sub-frames*/ - int windowSize; /**< Length of high-band LPC window*/ - int lpcSize; /**< Order of high-band LPC analysis */ - int first; /**< First frame? */ - spx_word16_t lpc_floor; /**< Controls LPC analysis noise floor */ - spx_word16_t gamma1; /**< Perceptual weighting coef 1 */ - spx_word16_t gamma2; /**< Perceptual weighting coef 2 */ - - char *stack; /**< Temporary allocation stack */ - spx_word16_t *high; /**< High-band signal (buffer) */ - spx_word16_t *h0_mem, *h1_mem; - - const spx_word16_t *window; /**< LPC analysis window */ - const spx_word16_t *lagWindow; /**< Auto-correlation window */ - spx_lsp_t *old_lsp; /**< LSPs of previous frame */ - spx_lsp_t *old_qlsp; /**< Quantized LSPs of previous frame */ - spx_coef_t *interp_qlpc; /**< Interpolated quantized LPCs for current sub-frame */ - - spx_mem_t *mem_sp; /**< Synthesis signal memory */ - spx_mem_t *mem_sp2; - spx_mem_t *mem_sw; /**< Perceptual signal memory */ - spx_word32_t *pi_gain; - spx_word16_t *exc_rms; - spx_word16_t *innov_rms_save; /**< If non-NULL, innovation is copied here */ - -#ifndef DISABLE_VBR - float vbr_quality; /**< Quality setting for VBR encoding */ - int vbr_enabled; /**< 1 for enabling VBR, 0 otherwise */ - spx_int32_t vbr_max; /**< Max bit-rate allowed in VBR mode (total) */ - spx_int32_t vbr_max_high; /**< Max bit-rate allowed in VBR mode for the high-band */ - spx_int32_t abr_enabled; /**< ABR setting (in bps), 0 if off */ - float abr_drift; - float abr_drift2; - float abr_count; - int vad_enabled; /**< 1 for enabling VAD, 0 otherwise */ - float relative_quality; -#endif /* #ifndef DISABLE_VBR */ - - int encode_submode; - const SpeexSubmode * const *submodes; - int submodeID; - int submodeSelect; - int complexity; - spx_int32_t sampling_rate; - -} SBEncState; - - -/**Structure representing the full state of the sub-band decoder*/ -typedef struct SBDecState { - const SpeexMode *mode; /**< Pointer to the mode (containing for vtable info) */ - void *st_low; /**< State of the low-band (narrowband) encoder */ - int full_frame_size; - int frame_size; - int subframeSize; - int nbSubframes; - int lpcSize; - int first; - spx_int32_t sampling_rate; - int lpc_enh_enabled; - - char *stack; - spx_word16_t g0_mem[64], g1_mem[64]; - -/* Voice codec files will be WB mode, which has sub frame size of 40 */ -#ifndef ROCKBOX_VOICE_CODEC - spx_word16_t excBuf[80]; -#else - spx_word16_t excBuf[40]; -#endif - spx_lsp_t old_qlsp[8]; - spx_coef_t interp_qlpc[8]; - - spx_mem_t mem_sp[16]; - spx_word32_t pi_gain[4]; - spx_word16_t exc_rms[4]; - spx_word16_t *innov_save; /** If non-NULL, innovation is copied here */ - - spx_word16_t last_ener; - spx_int32_t seed; - - int encode_submode; - const SpeexSubmode * const *submodes; - int submodeID; -} SBDecState; - - -/**Initializes encoder state*/ -void *sb_encoder_init(const SpeexMode *m); - -/**De-allocates encoder state resources*/ -void sb_encoder_destroy(void *state); - -/**Encodes one frame*/ -int sb_encode(void *state, void *in, SpeexBits *bits); - - -/**Initializes decoder state*/ -void *sb_decoder_init(const SpeexMode *m); - -/**De-allocates decoder state resources*/ -void sb_decoder_destroy(void *state); - -/**Decodes one frame*/ -int sb_decode(void *state, SpeexBits *bits, void *out); - -int sb_encoder_ctl(void *state, int request, void *ptr); - -int sb_decoder_ctl(void *state, int request, void *ptr); - -#endif diff --git a/apps/codecs/libspeex/smallft.c b/apps/codecs/libspeex/smallft.c deleted file mode 100644 index 6e3a927b5f..0000000000 --- a/apps/codecs/libspeex/smallft.c +++ /dev/null @@ -1,1261 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2001 * - * by the XIPHOPHORUS Company http://www.xiph.org/ * - * * - ******************************************************************** - - function: *unnormalized* fft transform - last mod: $Id$ - - ********************************************************************/ - -/* FFT implementation from OggSquish, minus cosine transforms, - * minus all but radix 2/4 case. In Vorbis we only need this - * cut-down version. - * - * To do more than just power-of-two sized vectors, see the full - * version I wrote for NetLib. - * - * Note that the packing is a little strange; rather than the FFT r/i - * packing following R_0, I_n, R_1, I_1, R_2, I_2 ... R_n-1, I_n-1, - * it follows R_0, R_1, I_1, R_2, I_2 ... R_n-1, I_n-1, I_n like the - * FORTRAN version - */ - -#ifdef HAVE_CONFIG_H -#include "config-speex.h" -#endif - -#include -#include "smallft.h" -#include "arch.h" -#include "os_support.h" - -static void drfti1(int n, float *wa, int *ifac){ - static int ntryh[4] = { 4,2,3,5 }; - static float tpi = 6.28318530717958648f; - float arg,argh,argld,fi; - int ntry=0,i,j=-1; - int k1, l1, l2, ib; - int ld, ii, ip, is, nq, nr; - int ido, ipm, nfm1; - int nl=n; - int nf=0; - - L101: - j++; - if (j < 4) - ntry=ntryh[j]; - else - ntry+=2; - - L104: - nq=nl/ntry; - nr=nl-ntry*nq; - if (nr!=0) goto L101; - - nf++; - ifac[nf+1]=ntry; - nl=nq; - if(ntry!=2)goto L107; - if(nf==1)goto L107; - - for (i=1;i>1; - ipp2=ip; - idp2=ido; - nbd=(ido-1)>>1; - t0=l1*ido; - t10=ip*ido; - - if(ido==1)goto L119; - for(ik=0;ikl1){ - for(j=1;j>1; - ipp2=ip; - ipph=(ip+1)>>1; - if(idol1)goto L139; - - is= -ido-1; - t1=0; - for(j=1;jn==1)return; - drftf1(l->n,data,l->trigcache,l->trigcache+l->n,l->splitcache); -} - -void spx_drft_backward(struct drft_lookup *l,float *data){ - if (l->n==1)return; - drftb1(l->n,data,l->trigcache,l->trigcache+l->n,l->splitcache); -} - -void spx_drft_init(struct drft_lookup *l,int n) -{ - l->n=n; - l->trigcache=(float*)speex_alloc(3*n*sizeof(*l->trigcache)); - l->splitcache=(int*)speex_alloc(32*sizeof(*l->splitcache)); - fdrffti(n, l->trigcache, l->splitcache); -} - -void spx_drft_clear(struct drft_lookup *l) -{ - if(l) - { - if(l->trigcache) - speex_free(l->trigcache); - if(l->splitcache) - speex_free(l->splitcache); - } -} diff --git a/apps/codecs/libspeex/smallft.h b/apps/codecs/libspeex/smallft.h deleted file mode 100644 index 4ef9e58c7d..0000000000 --- a/apps/codecs/libspeex/smallft.h +++ /dev/null @@ -1,46 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2001 * - * by the XIPHOPHORUS Company http://www.xiph.org/ * - * * - ******************************************************************** - - function: fft transform - last mod: $Id$ - - ********************************************************************/ -/** - @file smallft.h - @brief Discrete Rotational Fourier Transform (DRFT) -*/ - -#ifndef _V_SMFT_H_ -#define _V_SMFT_H_ - - -#ifdef __cplusplus -extern "C" { -#endif - -/** Discrete Rotational Fourier Transform lookup */ -struct drft_lookup{ - int n; - float *trigcache; - int *splitcache; -}; - -extern void spx_drft_forward(struct drft_lookup *l,float *data); -extern void spx_drft_backward(struct drft_lookup *l,float *data); -extern void spx_drft_init(struct drft_lookup *l,int n); -extern void spx_drft_clear(struct drft_lookup *l); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/apps/codecs/libspeex/speex.c b/apps/codecs/libspeex/speex.c deleted file mode 100644 index 0dcfb3f7f6..0000000000 --- a/apps/codecs/libspeex/speex.c +++ /dev/null @@ -1,252 +0,0 @@ -/* Copyright (C) 2002 Jean-Marc Valin - File: speex.c - - Basic Speex functions - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of the Xiph.org Foundation nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*/ - -#ifdef HAVE_CONFIG_H -#include "config-speex.h" -#endif - -#include "modes.h" -#include -#include "os_support.h" - -#ifndef NULL -#define NULL 0 -#endif - -#define MAX_IN_SAMPLES 640 - -#ifndef SPEEX_DISABLE_ENCODER -void *speex_encoder_init(const SpeexMode *mode) -{ - return mode->enc_init(mode); -} -#endif - -void *speex_decoder_init(const SpeexMode *mode) -{ - return mode->dec_init(mode); -} - -#ifndef SPEEX_DISABLE_ENCODER -void speex_encoder_destroy(void *state) -{ - (*((SpeexMode**)state))->enc_destroy(state); -} -#endif - -void speex_decoder_destroy(void *state) -{ - (*((SpeexMode**)state))->dec_destroy(state); -} - -#ifndef SPEEX_DISABLE_ENCODER -int speex_encode_native(void *state, spx_word16_t *in, SpeexBits *bits) -{ - return (*((SpeexMode**)state))->enc(state, in, bits); -} -#endif - -int speex_decode_native(void *state, SpeexBits *bits, spx_word16_t *out) -{ - return (*((SpeexMode**)state))->dec(state, bits, out); -} - - - -#ifdef FIXED_POINT - -#ifndef SPEEX_DISABLE_ENCODER -#ifndef DISABLE_FLOAT_API -int speex_encode(void *state, float *in, SpeexBits *bits) -{ - int i; - spx_int32_t N; - spx_int16_t short_in[MAX_IN_SAMPLES]; - speex_encoder_ctl(state, SPEEX_GET_FRAME_SIZE, &N); - for (i=0;i32767.f) - short_in[i] = 32767; - else if (in[i]<-32768.f) - short_in[i] = -32768; - else - short_in[i] = (spx_int16_t)floor(.5+in[i]); - } - return (*((SpeexMode**)state))->enc(state, short_in, bits); -} -#endif /* #ifndef DISABLE_FLOAT_API */ - -int speex_encode_int(void *state, spx_int16_t *in, SpeexBits *bits) -{ - SpeexMode *mode; - mode = *(SpeexMode**)state; - return (mode)->enc(state, in, bits); -} -#endif /* SPEEX_DISABLE_ENCODER */ - -#ifndef DISABLE_FLOAT_API -int speex_decode(void *state, SpeexBits *bits, float *out) -{ - int i, ret; - spx_int32_t N; - spx_int16_t short_out[MAX_IN_SAMPLES]; - speex_decoder_ctl(state, SPEEX_GET_FRAME_SIZE, &N); - ret = (*((SpeexMode**)state))->dec(state, bits, short_out); - for (i=0;idec(state, bits, out); -} - -#else - -int speex_encode(void *state, float *in, SpeexBits *bits) -{ - return (*((SpeexMode**)state))->enc(state, in, bits); -} - -int speex_encode_int(void *state, spx_int16_t *in, SpeexBits *bits) -{ - int i; - spx_int32_t N; - float float_in[MAX_IN_SAMPLES]; - speex_encoder_ctl(state, SPEEX_GET_FRAME_SIZE, &N); - for (i=0;ienc(state, float_in, bits); -} - -int speex_decode(void *state, SpeexBits *bits, float *out) -{ - return (*((SpeexMode**)state))->dec(state, bits, out); -} - -int speex_decode_int(void *state, SpeexBits *bits, spx_int16_t *out) -{ - int i; - spx_int32_t N; - float float_out[MAX_IN_SAMPLES]; - int ret; - speex_decoder_ctl(state, SPEEX_GET_FRAME_SIZE, &N); - ret = (*((SpeexMode**)state))->dec(state, bits, float_out); - for (i=0;i32767.f) - out[i] = 32767; - else if (float_out[i]<-32768.f) - out[i] = -32768; - else - out[i] = (spx_int16_t)floor(.5+float_out[i]); - } - return ret; -} -#endif - -#ifndef SPEEX_DISABLE_ENCODER -int speex_encoder_ctl(void *state, int request, void *ptr) -{ - return (*((SpeexMode**)state))->enc_ctl(state, request, ptr); -} -#endif - -int speex_decoder_ctl(void *state, int request, void *ptr) -{ - return (*((SpeexMode**)state))->dec_ctl(state, request, ptr); -} - -int nb_mode_query(const void *mode, int request, void *ptr) -{ - const SpeexNBMode *m = (const SpeexNBMode*)mode; - - switch (request) - { - case SPEEX_MODE_FRAME_SIZE: - *((int*)ptr)=m->frameSize; - break; - case SPEEX_SUBMODE_BITS_PER_FRAME: - if (*((int*)ptr)==0) - *((int*)ptr) = NB_SUBMODE_BITS+1; - else if (m->submodes[*((int*)ptr)]==NULL) - *((int*)ptr) = -1; - else - *((int*)ptr) = m->submodes[*((int*)ptr)]->bits_per_frame; - break; - default: - speex_warning_int("Unknown nb_mode_query request: ", request); - return -1; - } - return 0; -} - - - -int speex_lib_ctl(int request, void *ptr) -{ - switch (request) - { - case SPEEX_LIB_GET_MAJOR_VERSION: - *((int*)ptr) = SPEEX_MAJOR_VERSION; - break; - case SPEEX_LIB_GET_MINOR_VERSION: - *((int*)ptr) = SPEEX_MINOR_VERSION; - break; - case SPEEX_LIB_GET_MICRO_VERSION: - *((int*)ptr) = SPEEX_MICRO_VERSION; - break; - case SPEEX_LIB_GET_EXTRA_VERSION: - *((const char**)ptr) = SPEEX_EXTRA_VERSION; - break; - case SPEEX_LIB_GET_VERSION_STRING: - *((const char**)ptr) = SPEEX_VERSION; - break; - /*case SPEEX_LIB_SET_ALLOC_FUNC: - break; - case SPEEX_LIB_GET_ALLOC_FUNC: - break; - case SPEEX_LIB_SET_FREE_FUNC: - break; - case SPEEX_LIB_GET_FREE_FUNC: - break;*/ - default: - speex_warning_int("Unknown wb_mode_query request: ", request); - return -1; - } - return 0; -} diff --git a/apps/codecs/libspeex/speex/ogg.h b/apps/codecs/libspeex/speex/ogg.h deleted file mode 100644 index 8898b99582..0000000000 --- a/apps/codecs/libspeex/speex/ogg.h +++ /dev/null @@ -1,216 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2002 * - * by the Xiph.Org Foundation http://www.xiph.org/ * - * * - ******************************************************************** - - function: toplevel libogg include - last mod: $Id$ - - ********************************************************************/ -#ifndef _OGG_H -#define _OGG_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include "codeclib.h" - -typedef short spx_ogg_int16_t; -typedef unsigned short spx_ogg_uint16_t; -typedef int spx_ogg_int32_t; -typedef unsigned int spx_ogg_uint32_t; -typedef long long spx_ogg_int64_t; - - -#define _spx_ogg_malloc codec_malloc -#define _spx_ogg_calloc codec_calloc -#define _spx_ogg_realloc codec_realloc -#define _spx_ogg_free codec_free - - -typedef struct { - long endbyte; - int endbit; - - unsigned char *buffer; - unsigned char *ptr; - long storage; -} oggpack_buffer; - -/* spx_ogg_page is used to encapsulate the data in one Ogg bitstream page *****/ - -typedef struct { - unsigned char *header; - long header_len; - unsigned char *body; - long body_len; -} spx_ogg_page; - -/* spx_ogg_stream_state contains the current encode/decode state of a logical - Ogg bitstream **********************************************************/ - -typedef struct { - unsigned char *body_data; /* bytes from packet bodies */ - long body_storage; /* storage elements allocated */ - long body_fill; /* elements stored; fill mark */ - long body_returned; /* elements of fill returned */ - - - int *lacing_vals; /* The values that will go to the segment table */ - spx_ogg_int64_t *granule_vals; /* granulepos values for headers. Not compact - this way, but it is simple coupled to the - lacing fifo */ - long lacing_storage; - long lacing_fill; - long lacing_packet; - long lacing_returned; - - unsigned char header[282]; /* working space for header encode */ - int header_fill; - - int e_o_s; /* set when we have buffered the last packet in the - logical bitstream */ - int b_o_s; /* set after we've written the initial page - of a logical bitstream */ - long serialno; - long pageno; - spx_ogg_int64_t packetno; /* sequence number for decode; the framing - knows where there's a hole in the data, - but we need coupling so that the codec - (which is in a seperate abstraction - layer) also knows about the gap */ - spx_ogg_int64_t granulepos; - -} spx_ogg_stream_state; - -/* spx_ogg_packet is used to encapsulate the data and metadata belonging - to a single raw Ogg/Vorbis packet *************************************/ - -typedef struct { - unsigned char *packet; - long bytes; - long b_o_s; - long e_o_s; - - spx_ogg_int64_t granulepos; - - spx_ogg_int64_t packetno; /* sequence number for decode; the framing - knows where there's a hole in the data, - but we need coupling so that the codec - (which is in a seperate abstraction - layer) also knows about the gap */ -} spx_ogg_packet; - -typedef struct { - unsigned char *data; - int storage; - int fill; - int returned; - - int unsynced; - int headerbytes; - int bodybytes; -} spx_ogg_sync_state; - -/* Ogg BITSTREAM PRIMITIVES: bitstream ************************/ - -extern void oggpack_writeinit(oggpack_buffer *b); -extern void oggpack_writetrunc(oggpack_buffer *b,long bits); -extern void oggpack_writealign(oggpack_buffer *b); -extern void oggpack_writecopy(oggpack_buffer *b,void *source,long bits); -extern void oggpack_reset(oggpack_buffer *b); -extern void oggpack_writeclear(oggpack_buffer *b); -extern void oggpack_readinit(oggpack_buffer *b,unsigned char *buf,int bytes); -extern void oggpack_write(oggpack_buffer *b,unsigned long value,int bits); -extern long oggpack_look(oggpack_buffer *b,int bits); -extern long oggpack_look1(oggpack_buffer *b); -extern void oggpack_adv(oggpack_buffer *b,int bits); -extern void oggpack_adv1(oggpack_buffer *b); -extern long oggpack_read(oggpack_buffer *b,int bits); -extern long oggpack_read1(oggpack_buffer *b); -extern long oggpack_bytes(oggpack_buffer *b); -extern long oggpack_bits(oggpack_buffer *b); -extern unsigned char *oggpack_get_buffer(oggpack_buffer *b); - -extern void oggpackB_writeinit(oggpack_buffer *b); -extern void oggpackB_writetrunc(oggpack_buffer *b,long bits); -extern void oggpackB_writealign(oggpack_buffer *b); -extern void oggpackB_writecopy(oggpack_buffer *b,void *source,long bits); -extern void oggpackB_reset(oggpack_buffer *b); -extern void oggpackB_writeclear(oggpack_buffer *b); -extern void oggpackB_readinit(oggpack_buffer *b,unsigned char *buf,int bytes); -extern void oggpackB_write(oggpack_buffer *b,unsigned long value,int bits); -extern long oggpackB_look(oggpack_buffer *b,int bits); -extern long oggpackB_look1(oggpack_buffer *b); -extern void oggpackB_adv(oggpack_buffer *b,int bits); -extern void oggpackB_adv1(oggpack_buffer *b); -extern long oggpackB_read(oggpack_buffer *b,int bits); -extern long oggpackB_read1(oggpack_buffer *b); -extern long oggpackB_bytes(oggpack_buffer *b); -extern long oggpackB_bits(oggpack_buffer *b); -extern unsigned char *oggpackB_get_buffer(oggpack_buffer *b); - -/* Ogg BITSTREAM PRIMITIVES: encoding **************************/ - -extern int spx_ogg_stream_packetin(spx_ogg_stream_state *os, spx_ogg_packet *op); -extern int spx_ogg_stream_pageout(spx_ogg_stream_state *os, spx_ogg_page *og); -extern int spx_ogg_stream_flush(spx_ogg_stream_state *os, spx_ogg_page *og); - -/* Ogg BITSTREAM PRIMITIVES: decoding **************************/ - -extern int spx_ogg_sync_init(spx_ogg_sync_state *oy); -extern int spx_ogg_sync_clear(spx_ogg_sync_state *oy); -extern int spx_ogg_sync_reset(spx_ogg_sync_state *oy); -extern int spx_ogg_sync_destroy(spx_ogg_sync_state *oy); - -extern void spx_ogg_alloc_buffer(spx_ogg_sync_state *oy, long size); -extern char *spx_ogg_sync_buffer(spx_ogg_sync_state *oy, long size); -extern int spx_ogg_sync_wrote(spx_ogg_sync_state *oy, long bytes); -extern long spx_ogg_sync_pageseek(spx_ogg_sync_state *oy,spx_ogg_page *og); -extern int spx_ogg_sync_pageout(spx_ogg_sync_state *oy, spx_ogg_page *og); -extern int spx_ogg_stream_pagein(spx_ogg_stream_state *os, spx_ogg_page *og); -extern int spx_ogg_stream_packetout(spx_ogg_stream_state *os,spx_ogg_packet *op); -extern int spx_ogg_stream_packetpeek(spx_ogg_stream_state *os,spx_ogg_packet *op); - -/* Ogg BITSTREAM PRIMITIVES: general ***************************/ - -extern int spx_ogg_stream_init(spx_ogg_stream_state *os,int serialno); -extern int spx_ogg_stream_clear(spx_ogg_stream_state *os); -extern int spx_ogg_stream_reset(spx_ogg_stream_state *os); -extern int spx_ogg_stream_reset_serialno(spx_ogg_stream_state *os,int serialno); -extern int spx_ogg_stream_destroy(spx_ogg_stream_state *os); -extern int spx_ogg_stream_eos(spx_ogg_stream_state *os); - -extern void spx_ogg_page_checksum_set(spx_ogg_page *og); - -extern int spx_ogg_page_version(spx_ogg_page *og); -extern int spx_ogg_page_continued(spx_ogg_page *og); -extern int spx_ogg_page_bos(spx_ogg_page *og); -extern int spx_ogg_page_eos(spx_ogg_page *og); -extern spx_ogg_int64_t spx_ogg_page_granulepos(spx_ogg_page *og); -extern int spx_ogg_page_serialno(spx_ogg_page *og); -extern long spx_ogg_page_pageno(spx_ogg_page *og); -extern int spx_ogg_page_packets(spx_ogg_page *og); - -extern void spx_ogg_packet_clear(spx_ogg_packet *op); - - -#ifdef __cplusplus -} -#endif - -#endif /* _OGG_H */ - - - - - - diff --git a/apps/codecs/libspeex/speex/speex.h b/apps/codecs/libspeex/speex/speex.h deleted file mode 100644 index 086d492670..0000000000 --- a/apps/codecs/libspeex/speex/speex.h +++ /dev/null @@ -1,428 +0,0 @@ -/* Copyright (C) 2002-2006 Jean-Marc Valin*/ -/** - @file speex.h - @brief Describes the different modes of the codec -*/ -/* - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of the Xiph.org Foundation nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*/ - -#ifndef SPEEX_H -#define SPEEX_H -/** @defgroup Codec Speex encoder and decoder - * This is the Speex codec itself. - * @{ - */ - -#include "speex_bits.h" -#include "speex_types.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* Values allowed for *ctl() requests */ - -/** Set enhancement on/off (decoder only) */ -#define SPEEX_SET_ENH 0 -/** Get enhancement state (decoder only) */ -#define SPEEX_GET_ENH 1 - -/*Would be SPEEX_SET_FRAME_SIZE, but it's (currently) invalid*/ -/** Obtain frame size used by encoder/decoder */ -#define SPEEX_GET_FRAME_SIZE 3 - -/** Set quality value */ -#define SPEEX_SET_QUALITY 4 -/** Get current quality setting */ -/* #define SPEEX_GET_QUALITY 5 -- Doesn't make much sense, does it? */ - -/** Set sub-mode to use */ -#define SPEEX_SET_MODE 6 -/** Get current sub-mode in use */ -#define SPEEX_GET_MODE 7 - -/** Set low-band sub-mode to use (wideband only)*/ -#define SPEEX_SET_LOW_MODE 8 -/** Get current low-band mode in use (wideband only)*/ -#define SPEEX_GET_LOW_MODE 9 - -/** Set high-band sub-mode to use (wideband only)*/ -#define SPEEX_SET_HIGH_MODE 10 -/** Get current high-band mode in use (wideband only)*/ -#define SPEEX_GET_HIGH_MODE 11 - -/** Set VBR on (1) or off (0) */ -#define SPEEX_SET_VBR 12 -/** Get VBR status (1 for on, 0 for off) */ -#define SPEEX_GET_VBR 13 - -/** Set quality value for VBR encoding (0-10) */ -#define SPEEX_SET_VBR_QUALITY 14 -/** Get current quality value for VBR encoding (0-10) */ -#define SPEEX_GET_VBR_QUALITY 15 - -/** Set complexity of the encoder (0-10) */ -#define SPEEX_SET_COMPLEXITY 16 -/** Get current complexity of the encoder (0-10) */ -#define SPEEX_GET_COMPLEXITY 17 - -/** Set bit-rate used by the encoder (or lower) */ -#define SPEEX_SET_BITRATE 18 -/** Get current bit-rate used by the encoder or decoder */ -#define SPEEX_GET_BITRATE 19 - -/** Define a handler function for in-band Speex request*/ -#define SPEEX_SET_HANDLER 20 - -/** Define a handler function for in-band user-defined request*/ -#define SPEEX_SET_USER_HANDLER 22 - -/** Set sampling rate used in bit-rate computation */ -#define SPEEX_SET_SAMPLING_RATE 24 -/** Get sampling rate used in bit-rate computation */ -#define SPEEX_GET_SAMPLING_RATE 25 - -/** Reset the encoder/decoder memories to zero*/ -#define SPEEX_RESET_STATE 26 - -/** Get VBR info (mostly used internally) */ -#define SPEEX_GET_RELATIVE_QUALITY 29 - -/** Set VAD status (1 for on, 0 for off) */ -#define SPEEX_SET_VAD 30 - -/** Get VAD status (1 for on, 0 for off) */ -#define SPEEX_GET_VAD 31 - -/** Set Average Bit-Rate (ABR) to n bits per seconds */ -#define SPEEX_SET_ABR 32 -/** Get Average Bit-Rate (ABR) setting (in bps) */ -#define SPEEX_GET_ABR 33 - -/** Set DTX status (1 for on, 0 for off) */ -#define SPEEX_SET_DTX 34 -/** Get DTX status (1 for on, 0 for off) */ -#define SPEEX_GET_DTX 35 - -/** Set submode encoding in each frame (1 for yes, 0 for no, setting to no breaks the standard) */ -#define SPEEX_SET_SUBMODE_ENCODING 36 -/** Get submode encoding in each frame */ -#define SPEEX_GET_SUBMODE_ENCODING 37 - -/*#define SPEEX_SET_LOOKAHEAD 38*/ -/** Returns the lookahead used by Speex */ -#define SPEEX_GET_LOOKAHEAD 39 - -/** Sets tuning for packet-loss concealment (expected loss rate) */ -#define SPEEX_SET_PLC_TUNING 40 -/** Gets tuning for PLC */ -#define SPEEX_GET_PLC_TUNING 41 - -/** Sets the max bit-rate allowed in VBR mode */ -#define SPEEX_SET_VBR_MAX_BITRATE 42 -/** Gets the max bit-rate allowed in VBR mode */ -#define SPEEX_GET_VBR_MAX_BITRATE 43 - -/** Turn on/off input/output high-pass filtering */ -#define SPEEX_SET_HIGHPASS 44 -/** Get status of input/output high-pass filtering */ -#define SPEEX_GET_HIGHPASS 45 - -/** Get "activity level" of the last decoded frame, i.e. - how much damage we cause if we remove the frame */ -#define SPEEX_GET_ACTIVITY 47 - - -/* Preserving compatibility:*/ -/** Equivalent to SPEEX_SET_ENH */ -#define SPEEX_SET_PF 0 -/** Equivalent to SPEEX_GET_ENH */ -#define SPEEX_GET_PF 1 - - - - -/* Values allowed for mode queries */ -/** Query the frame size of a mode */ -#define SPEEX_MODE_FRAME_SIZE 0 - -/** Query the size of an encoded frame for a particular sub-mode */ -#define SPEEX_SUBMODE_BITS_PER_FRAME 1 - - - -/** Get major Speex version */ -#define SPEEX_LIB_GET_MAJOR_VERSION 1 -/** Get minor Speex version */ -#define SPEEX_LIB_GET_MINOR_VERSION 3 -/** Get micro Speex version */ -#define SPEEX_LIB_GET_MICRO_VERSION 5 -/** Get extra Speex version */ -#define SPEEX_LIB_GET_EXTRA_VERSION 7 -/** Get Speex version string */ -#define SPEEX_LIB_GET_VERSION_STRING 9 - -/*#define SPEEX_LIB_SET_ALLOC_FUNC 10 -#define SPEEX_LIB_GET_ALLOC_FUNC 11 -#define SPEEX_LIB_SET_FREE_FUNC 12 -#define SPEEX_LIB_GET_FREE_FUNC 13 - -#define SPEEX_LIB_SET_WARNING_FUNC 14 -#define SPEEX_LIB_GET_WARNING_FUNC 15 -#define SPEEX_LIB_SET_ERROR_FUNC 16 -#define SPEEX_LIB_GET_ERROR_FUNC 17 -*/ - -/** Number of defined modes in Speex */ -#define SPEEX_NB_MODES 3 - -/** modeID for the defined narrowband mode */ -#define SPEEX_MODEID_NB 0 - -/** modeID for the defined wideband mode */ -#define SPEEX_MODEID_WB 1 - -/** modeID for the defined ultra-wideband mode */ -#define SPEEX_MODEID_UWB 2 - -struct SpeexMode; - - -/* Prototypes for mode function pointers */ - -/** Encoder state initialization function */ -typedef void *(*encoder_init_func)(const struct SpeexMode *mode); - -/** Encoder state destruction function */ -typedef void (*encoder_destroy_func)(void *st); - -/** Main encoding function */ -typedef int (*encode_func)(void *state, void *in, SpeexBits *bits); - -/** Function for controlling the encoder options */ -typedef int (*encoder_ctl_func)(void *state, int request, void *ptr); - -/** Decoder state initialization function */ -typedef void *(*decoder_init_func)(const struct SpeexMode *mode); - -/** Decoder state destruction function */ -typedef void (*decoder_destroy_func)(void *st); - -/** Main decoding function */ -typedef int (*decode_func)(void *state, SpeexBits *bits, void *out); - -/** Function for controlling the decoder options */ -typedef int (*decoder_ctl_func)(void *state, int request, void *ptr); - - -/** Query function for a mode */ -typedef int (*mode_query_func)(const void *mode, int request, void *ptr); - -/** Struct defining a Speex mode */ -typedef struct SpeexMode { - /** Pointer to the low-level mode data */ - const void *mode; - - /** Pointer to the mode query function */ - mode_query_func query; - - /** The name of the mode (you should not rely on this to identify the mode)*/ - const char *modeName; - - /**ID of the mode*/ - int modeID; - - /**Version number of the bitstream (incremented every time we break - bitstream compatibility*/ - int bitstream_version; - -#ifndef SPEEX_DISABLE_ENCODER - /** Pointer to encoder initialization function */ - encoder_init_func enc_init; - - /** Pointer to encoder destruction function */ - encoder_destroy_func enc_destroy; - - /** Pointer to frame encoding function */ - encode_func enc; -#endif - - /** Pointer to decoder initialization function */ - decoder_init_func dec_init; - - /** Pointer to decoder destruction function */ - decoder_destroy_func dec_destroy; - - /** Pointer to frame decoding function */ - decode_func dec; - -#ifndef SPEEX_DISABLE_ENCODER - /** ioctl-like requests for encoder */ - encoder_ctl_func enc_ctl; -#endif - - /** ioctl-like requests for decoder */ - decoder_ctl_func dec_ctl; - -} SpeexMode; - -/** - * Returns a handle to a newly created Speex encoder state structure. For now, - * the "mode" argument can be &nb_mode or &wb_mode . In the future, more modes - * may be added. Note that for now if you have more than one channels to - * encode, you need one state per channel. - * - * @param mode The mode to use (either speex_nb_mode or speex_wb.mode) - * @return A newly created encoder state or NULL if state allocation fails - */ -void *speex_encoder_init(const SpeexMode *mode); - -/** Frees all resources associated to an existing Speex encoder state. - * @param state Encoder state to be destroyed */ -void speex_encoder_destroy(void *state); - -/** Uses an existing encoder state to encode one frame of speech pointed to by - "in". The encoded bit-stream is saved in "bits". - @param state Encoder state - @param in Frame that will be encoded with a +-2^15 range. This data MAY be - overwritten by the encoder and should be considered uninitialised - after the call. - @param bits Bit-stream where the data will be written - @return 0 if frame needs not be transmitted (DTX only), 1 otherwise - */ -int speex_encode(void *state, float *in, SpeexBits *bits); - -/** Uses an existing encoder state to encode one frame of speech pointed to by - "in". The encoded bit-stream is saved in "bits". - @param state Encoder state - @param in Frame that will be encoded with a +-2^15 range - @param bits Bit-stream where the data will be written - @return 0 if frame needs not be transmitted (DTX only), 1 otherwise - */ -int speex_encode_int(void *state, spx_int16_t *in, SpeexBits *bits); - -/** Used like the ioctl function to control the encoder parameters - * - * @param state Encoder state - * @param request ioctl-type request (one of the SPEEX_* macros) - * @param ptr Data exchanged to-from function - * @return 0 if no error, -1 if request in unknown, -2 for invalid parameter - */ -int speex_encoder_ctl(void *state, int request, void *ptr); - - -/** Returns a handle to a newly created decoder state structure. For now, - * the mode argument can be &nb_mode or &wb_mode . In the future, more modes - * may be added. Note that for now if you have more than one channels to - * decode, you need one state per channel. - * - * @param mode Speex mode (one of speex_nb_mode or speex_wb_mode) - * @return A newly created decoder state or NULL if state allocation fails - */ -void *speex_decoder_init(const SpeexMode *mode); - -/** Frees all resources associated to an existing decoder state. - * - * @param state State to be destroyed - */ -void speex_decoder_destroy(void *state); - -/** Uses an existing decoder state to decode one frame of speech from - * bit-stream bits. The output speech is saved written to out. - * - * @param state Decoder state - * @param bits Bit-stream from which to decode the frame (NULL if the packet was lost) - * @param out Where to write the decoded frame - * @return return status (0 for no error, -1 for end of stream, -2 corrupt stream) - */ -int speex_decode(void *state, SpeexBits *bits, float *out); - -/** Uses an existing decoder state to decode one frame of speech from - * bit-stream bits. The output speech is saved written to out. - * - * @param state Decoder state - * @param bits Bit-stream from which to decode the frame (NULL if the packet was lost) - * @param out Where to write the decoded frame - * @return return status (0 for no error, -1 for end of stream, -2 corrupt stream) - */ -int speex_decode_int(void *state, SpeexBits *bits, spx_int16_t *out); - -/** Used like the ioctl function to control the encoder parameters - * - * @param state Decoder state - * @param request ioctl-type request (one of the SPEEX_* macros) - * @param ptr Data exchanged to-from function - * @return 0 if no error, -1 if request in unknown, -2 for invalid parameter - */ -int speex_decoder_ctl(void *state, int request, void *ptr); - - -/** Query function for mode information - * - * @param mode Speex mode - * @param request ioctl-type request (one of the SPEEX_* macros) - * @param ptr Data exchanged to-from function - * @return 0 if no error, -1 if request in unknown, -2 for invalid parameter - */ -int speex_mode_query(const SpeexMode *mode, int request, void *ptr); - -/** Functions for controlling the behavior of libspeex - * @param request ioctl-type request (one of the SPEEX_LIB_* macros) - * @param ptr Data exchanged to-from function - * @return 0 if no error, -1 if request in unknown, -2 for invalid parameter - */ -int speex_lib_ctl(int request, void *ptr); - -/** Default narrowband mode */ -extern const SpeexMode speex_nb_mode; - -/** Default wideband mode */ -extern const SpeexMode speex_wb_mode; - -/** Default "ultra-wideband" mode */ -extern const SpeexMode speex_uwb_mode; - -/** List of all modes available */ -extern const SpeexMode * const speex_mode_list[SPEEX_NB_MODES]; - -/** Obtain one of the modes available */ -const SpeexMode * speex_lib_get_mode (int mode); - -#ifndef WIN32 -/* We actually override the function in the narrowband case so that we can avoid linking in the wideband stuff */ -#define speex_lib_get_mode(mode) ((mode)==SPEEX_MODEID_NB ? &speex_nb_mode : speex_lib_get_mode (mode)) -#endif - -#ifdef __cplusplus -} -#endif - -/** @}*/ -#endif diff --git a/apps/codecs/libspeex/speex/speex_bits.h b/apps/codecs/libspeex/speex/speex_bits.h deleted file mode 100644 index fee2893380..0000000000 --- a/apps/codecs/libspeex/speex/speex_bits.h +++ /dev/null @@ -1,184 +0,0 @@ -/* Copyright (C) 2002 Jean-Marc Valin */ -/** - @file speex_bits.h - @brief Handles bit packing/unpacking -*/ -/* - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of the Xiph.org Foundation nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*/ - -#ifndef BITS_H -#define BITS_H -/** @defgroup SpeexBits SpeexBits: Bit-stream manipulations - * This is the structure that holds the bit-stream when encoding or decoding - * with Speex. It allows some manipulations as well. - * @{ - */ - -#ifdef __cplusplus -extern "C" { -#endif - -/** Bit-packing data structure representing (part of) a bit-stream. */ -typedef struct SpeexBits { - char *chars; /**< "raw" data */ - int nbBits; /**< Total number of bits stored in the stream*/ - int charPtr; /**< Position of the byte "cursor" */ - int bitPtr; /**< Position of the bit "cursor" within the current char */ - int owner; /**< Does the struct "own" the "raw" buffer (member "chars") */ - int overflow;/**< Set to one if we try to read past the valid data */ - int buf_size;/**< Allocated size for buffer */ - int reserved1; /**< Reserved for future use */ - void *reserved2; /**< Reserved for future use */ -} SpeexBits; - -/** Initializes and allocates resources for a SpeexBits struct */ -void speex_bits_init(SpeexBits *bits); - -/** Initializes SpeexBits struct using a pre-allocated buffer*/ -/* Rockbox: unused -void speex_bits_init_buffer(SpeexBits *bits, void *buff, int buf_size); -*/ - -/** Sets the bits in a SpeexBits struct to use data from an existing buffer (for decoding without copying data) */ -void speex_bits_set_bit_buffer(SpeexBits *bits, void *buff, int buf_size); - -/** Frees all resources associated to a SpeexBits struct. Right now this does nothing since no resources are allocated, but this could change in the future.*/ -void speex_bits_destroy(SpeexBits *bits); - -/** Resets bits to initial value (just after initialization, erasing content)*/ -void speex_bits_reset(SpeexBits *bits); - -/** Rewind the bit-stream to the beginning (ready for read) without erasing the content */ -/* Rockbox: unused -void speex_bits_rewind(SpeexBits *bits); -*/ - -/** Initializes the bit-stream from the data in an area of memory */ -void speex_bits_read_from(SpeexBits *bits, char *bytes, int len); - -/** Append bytes to the bit-stream - * - * @param bits Bit-stream to operate on - * @param bytes pointer to the bytes what will be appended - * @param len Number of bytes of append - */ -void speex_bits_read_whole_bytes(SpeexBits *bits, char *bytes, int len); - -/** Write the content of a bit-stream to an area of memory - * - * @param bits Bit-stream to operate on - * @param bytes Memory location where to write the bits - * @param max_len Maximum number of bytes to write (i.e. size of the "bytes" buffer) - * @return Number of bytes written to the "bytes" buffer -*/ -int speex_bits_write(SpeexBits *bits, char *bytes, int max_len); - -/** Like speex_bits_write, but writes only the complete bytes in the stream. Also removes the written bytes from the stream */ -int speex_bits_write_whole_bytes(SpeexBits *bits, char *bytes, int max_len); - -/** Append bits to the bit-stream - * @param bits Bit-stream to operate on - * @param data Value to append as integer - * @param nbBits number of bits to consider in "data" - */ -void speex_bits_pack(SpeexBits *bits, int data, int nbBits); - -/** Interpret the next bits in the bit-stream as a signed integer - * - * @param bits Bit-stream to operate on - * @param nbBits Number of bits to interpret - * @return A signed integer represented by the bits read - */ -/* Rockbox: unused -int speex_bits_unpack_signed(SpeexBits *bits, int nbBits); -*/ - -/** Interpret the next bits in the bit-stream as an unsigned integer - * - * @param bits Bit-stream to operate on - * @param nbBits Number of bits to interpret - * @return An unsigned integer represented by the bits read - */ -unsigned int speex_bits_unpack_unsigned(SpeexBits *bits, int nbBits); - -/** Returns the number of bytes in the bit-stream, including the last one even if it is not "full" - * - * @param bits Bit-stream to operate on - * @return Number of bytes in the stream - */ -/* Rockbox: unused -int speex_bits_nbytes(SpeexBits *bits); -*/ - -/** Same as speex_bits_unpack_unsigned, but without modifying the cursor position - * - * @param bits Bit-stream to operate on - * @param nbBits Number of bits to look for - * @return Value of the bits peeked, interpreted as unsigned - */ -/* Rockbox: unused -unsigned int speex_bits_peek_unsigned(SpeexBits *bits, int nbBits); -*/ - -/** Get the value of the next bit in the stream, without modifying the - * "cursor" position - * - * @param bits Bit-stream to operate on - * @return Value of the bit peeked (one bit only) - */ -int speex_bits_peek(SpeexBits *bits); - -/** Advances the position of the "bit cursor" in the stream - * - * @param bits Bit-stream to operate on - * @param n Number of bits to advance - */ -void speex_bits_advance(SpeexBits *bits, int n); - -/** Returns the number of bits remaining to be read in a stream - * - * @param bits Bit-stream to operate on - * @return Number of bits that can still be read from the stream - */ -int speex_bits_remaining(SpeexBits *bits); - -/** Insert a terminator so that the data can be sent as a packet while auto-detecting - * the number of frames in each packet - * - * @param bits Bit-stream to operate on - */ -void speex_bits_insert_terminator(SpeexBits *bits); - -#ifdef __cplusplus -} -#endif - -/* @} */ -#endif diff --git a/apps/codecs/libspeex/speex/speex_callbacks.h b/apps/codecs/libspeex/speex/speex_callbacks.h deleted file mode 100644 index 6f450b3a3a..0000000000 --- a/apps/codecs/libspeex/speex/speex_callbacks.h +++ /dev/null @@ -1,134 +0,0 @@ -/* Copyright (C) 2002 Jean-Marc Valin*/ -/** - @file speex_callbacks.h - @brief Describes callback handling and in-band signalling -*/ -/* - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of the Xiph.org Foundation nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*/ - -#ifndef SPEEX_CALLBACKS_H -#define SPEEX_CALLBACKS_H -/** @defgroup SpeexCallbacks Various definitions for Speex callbacks supported by the decoder. - * @{ - */ - -#include "speex.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** Total number of callbacks */ -#define SPEEX_MAX_CALLBACKS 16 - -/* Describes all the in-band requests */ - -/*These are 1-bit requests*/ -/** Request for perceptual enhancement (1 for on, 0 for off) */ -#define SPEEX_INBAND_ENH_REQUEST 0 -/** Reserved */ -#define SPEEX_INBAND_RESERVED1 1 - -/*These are 4-bit requests*/ -/** Request for a mode change */ -#define SPEEX_INBAND_MODE_REQUEST 2 -/** Request for a low mode change */ -#define SPEEX_INBAND_LOW_MODE_REQUEST 3 -/** Request for a high mode change */ -#define SPEEX_INBAND_HIGH_MODE_REQUEST 4 -/** Request for VBR (1 on, 0 off) */ -#define SPEEX_INBAND_VBR_QUALITY_REQUEST 5 -/** Request to be sent acknowledge */ -#define SPEEX_INBAND_ACKNOWLEDGE_REQUEST 6 -/** Request for VBR (1 for on, 0 for off) */ -#define SPEEX_INBAND_VBR_REQUEST 7 - -/*These are 8-bit requests*/ -/** Send a character in-band */ -#define SPEEX_INBAND_CHAR 8 -/** Intensity stereo information */ -#define SPEEX_INBAND_STEREO 9 - -/*These are 16-bit requests*/ -/** Transmit max bit-rate allowed */ -#define SPEEX_INBAND_MAX_BITRATE 10 - -/*These are 32-bit requests*/ -/** Acknowledge packet reception */ -#define SPEEX_INBAND_ACKNOWLEDGE 12 - -/** Callback function type */ -typedef int (*speex_callback_func)(SpeexBits *bits, void *state, void *data); - -/** Callback information */ -typedef struct SpeexCallback { - int callback_id; /**< ID associated to the callback */ - speex_callback_func func; /**< Callback handler function */ - void *data; /**< Data that will be sent to the handler */ - void *reserved1; /**< Reserved for future use */ - int reserved2; /**< Reserved for future use */ -} SpeexCallback; - -/** Handle in-band request */ -int speex_inband_handler(SpeexBits *bits, SpeexCallback *callback_list, void *state); - -/** Standard handler for mode request (change mode, no questions asked) */ -int speex_std_mode_request_handler(SpeexBits *bits, void *state, void *data); - -/** Standard handler for high mode request (change high mode, no questions asked) */ -int speex_std_high_mode_request_handler(SpeexBits *bits, void *state, void *data); - -/** Standard handler for in-band characters (write to stderr) */ -int speex_std_char_handler(SpeexBits *bits, void *state, void *data); - -/** Default handler for user-defined requests: in this case, just ignore */ -int speex_default_user_handler(SpeexBits *bits, void *state, void *data); - - - -/** Standard handler for low mode request (change low mode, no questions asked) */ -int speex_std_low_mode_request_handler(SpeexBits *bits, void *state, void *data); - -/** Standard handler for VBR request (Set VBR, no questions asked) */ -int speex_std_vbr_request_handler(SpeexBits *bits, void *state, void *data); - -/** Standard handler for enhancer request (Turn enhancer on/off, no questions asked) */ -int speex_std_enh_request_handler(SpeexBits *bits, void *state, void *data); - -/** Standard handler for VBR quality request (Set VBR quality, no questions asked) */ -int speex_std_vbr_quality_request_handler(SpeexBits *bits, void *state, void *data); - - -#ifdef __cplusplus -} -#endif - -/** @} */ -#endif diff --git a/apps/codecs/libspeex/speex/speex_config_types.h b/apps/codecs/libspeex/speex/speex_config_types.h deleted file mode 100644 index ef328d48c1..0000000000 --- a/apps/codecs/libspeex/speex/speex_config_types.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef __SPEEX_TYPES_H__ -#define __SPEEX_TYPES_H__ - -#include "inttypes.h" -#define spx_int16_t int16_t -#define spx_uint16_t uint16_t -#define spx_int32_t int32_t -#define spx_uint32_t uint32_t -#define spx_int64_t int64_t -#define spx_uint64_t uint64_t - -#endif - diff --git a/apps/codecs/libspeex/speex/speex_echo.h b/apps/codecs/libspeex/speex/speex_echo.h deleted file mode 100644 index 6fcb0c00d7..0000000000 --- a/apps/codecs/libspeex/speex/speex_echo.h +++ /dev/null @@ -1,123 +0,0 @@ -/* Copyright (C) Jean-Marc Valin */ -/** - @file speex_echo.h - @brief Echo cancellation -*/ -/* - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are - met: - - 1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - 3. The name of the author may not be used to endorse or promote products - derived from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, - INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef SPEEX_ECHO_H -#define SPEEX_ECHO_H -/** @defgroup SpeexEchoState SpeexEchoState: Acoustic echo canceller - * This is the acoustic echo canceller module. - * @{ - */ -#include "speex_types.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** Obtain frame size used by the AEC */ -#define SPEEX_ECHO_GET_FRAME_SIZE 3 - -/** Set sampling rate */ -#define SPEEX_ECHO_SET_SAMPLING_RATE 24 -/** Get sampling rate */ -#define SPEEX_ECHO_GET_SAMPLING_RATE 25 - -/** Internal echo canceller state. Should never be accessed directly. */ -struct SpeexEchoState_; - -/** @class SpeexEchoState - * This holds the state of the echo canceller. You need one per channel. -*/ - -/** Internal echo canceller state. Should never be accessed directly. */ -typedef struct SpeexEchoState_ SpeexEchoState; - -/** Creates a new echo canceller state - * @param frame_size Number of samples to process at one time (should correspond to 10-20 ms) - * @param filter_length Number of samples of echo to cancel (should generally correspond to 100-500 ms) - * @return Newly-created echo canceller state - */ -SpeexEchoState *speex_echo_state_init(int frame_size, int filter_length); - -/** Destroys an echo canceller state - * @param st Echo canceller state -*/ -void speex_echo_state_destroy(SpeexEchoState *st); - -/** Performs echo cancellation a frame, based on the audio sent to the speaker (no delay is added - * to playback in this form) - * - * @param st Echo canceller state - * @param rec Signal from the microphone (near end + far end echo) - * @param play Signal played to the speaker (received from far end) - * @param out Returns near-end signal with echo removed - */ -void speex_echo_cancellation(SpeexEchoState *st, const spx_int16_t *rec, const spx_int16_t *play, spx_int16_t *out); - -/** Performs echo cancellation a frame (deprecated) */ -void speex_echo_cancel(SpeexEchoState *st, const spx_int16_t *rec, const spx_int16_t *play, spx_int16_t *out, spx_int32_t *Yout); - -/** Perform echo cancellation using internal playback buffer, which is delayed by two frames - * to account for the delay introduced by most soundcards (but it could be off!) - * @param st Echo canceller state - * @param rec Signal from the microphone (near end + far end echo) - * @param out Returns near-end signal with echo removed -*/ -void speex_echo_capture(SpeexEchoState *st, const spx_int16_t *rec, spx_int16_t *out); - -/** Let the echo canceller know that a frame was just queued to the soundcard - * @param st Echo canceller state - * @param play Signal played to the speaker (received from far end) -*/ -void speex_echo_playback(SpeexEchoState *st, const spx_int16_t *play); - -/** Reset the echo canceller to its original state - * @param st Echo canceller state - */ -void speex_echo_state_reset(SpeexEchoState *st); - -/** Used like the ioctl function to control the echo canceller parameters - * - * @param st Echo canceller state - * @param request ioctl-type request (one of the SPEEX_ECHO_* macros) - * @param ptr Data exchanged to-from function - * @return 0 if no error, -1 if request in unknown - */ -int speex_echo_ctl(SpeexEchoState *st, int request, void *ptr); - -#ifdef __cplusplus -} -#endif - - -/** @}*/ -#endif diff --git a/apps/codecs/libspeex/speex/speex_header.h b/apps/codecs/libspeex/speex/speex_header.h deleted file mode 100644 index 2b60003fe9..0000000000 --- a/apps/codecs/libspeex/speex/speex_header.h +++ /dev/null @@ -1,91 +0,0 @@ -/* Copyright (C) 2002 Jean-Marc Valin */ -/** - @file speex_header.h - @brief Describes the Speex header -*/ -/* - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of the Xiph.org Foundation nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*/ - - -#ifndef SPEEX_HEADER_H -#define SPEEX_HEADER_H -/** @defgroup SpeexHeader SpeexHeader: Makes it easy to write/parse an Ogg/Speex header - * This is the Speex header for the Ogg encapsulation. You don't need that if you just use RTP. - * @{ - */ - -#include "speex_types.h" - -#ifdef __cplusplus -extern "C" { -#endif - -struct SpeexMode; - -/** Length of the Speex header identifier */ -#define SPEEX_HEADER_STRING_LENGTH 8 - -/** Maximum number of characters for encoding the Speex version number in the header */ -#define SPEEX_HEADER_VERSION_LENGTH 20 - -/** Speex header info for file-based formats */ -typedef struct SpeexHeader { - char speex_string[SPEEX_HEADER_STRING_LENGTH]; /**< Identifies a Speex bit-stream, always set to "Speex " */ - char speex_version[SPEEX_HEADER_VERSION_LENGTH]; /**< Speex version */ - spx_int32_t speex_version_id; /**< Version for Speex (for checking compatibility) */ - spx_int32_t header_size; /**< Total size of the header ( sizeof(SpeexHeader) ) */ - spx_int32_t rate; /**< Sampling rate used */ - spx_int32_t mode; /**< Mode used (0 for narrowband, 1 for wideband) */ - spx_int32_t mode_bitstream_version; /**< Version ID of the bit-stream */ - spx_int32_t nb_channels; /**< Number of channels encoded */ - spx_int32_t bitrate; /**< Bit-rate used */ - spx_int32_t frame_size; /**< Size of frames */ - spx_int32_t vbr; /**< 1 for a VBR encoding, 0 otherwise */ - spx_int32_t frames_per_packet; /**< Number of frames stored per Ogg packet */ - spx_int32_t extra_headers; /**< Number of additional headers after the comments */ - spx_int32_t reserved1; /**< Reserved for future use, must be zero */ - spx_int32_t reserved2; /**< Reserved for future use, must be zero */ -} SpeexHeader; - -/** Initializes a SpeexHeader using basic information */ -void speex_init_header(SpeexHeader *header, int rate, int nb_channels, const struct SpeexMode *m); - -/** Creates the header packet from the header itself (mostly involves endianness conversion) */ -char *speex_header_to_packet(SpeexHeader *header, int *size); - -/** Creates a SpeexHeader from a packet */ -SpeexHeader *speex_packet_to_header(char *packet, int size); - -#ifdef __cplusplus -} -#endif - -/** @} */ -#endif diff --git a/apps/codecs/libspeex/speex/speex_jitter.h b/apps/codecs/libspeex/speex/speex_jitter.h deleted file mode 100644 index 03bac15636..0000000000 --- a/apps/codecs/libspeex/speex/speex_jitter.h +++ /dev/null @@ -1,197 +0,0 @@ -/* Copyright (C) 2002 Jean-Marc Valin */ -/** - @file speex_jitter.h - @brief Adaptive jitter buffer for Speex -*/ -/* - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of the Xiph.org Foundation nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*/ - -#ifndef SPEEX_JITTER_H -#define SPEEX_JITTER_H -/** @defgroup JitterBuffer JitterBuffer: Adaptive jitter buffer - * This is the jitter buffer that reorders UDP/RTP packets and adjusts the buffer size - * to maintain good quality and low latency. - * @{ - */ - -#include "speex_types.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** Generic adaptive jitter buffer state */ -struct JitterBuffer_; - -/** Generic adaptive jitter buffer state */ -typedef struct JitterBuffer_ JitterBuffer; - -/** Definition of an incoming packet */ -typedef struct _JitterBufferPacket JitterBufferPacket; - -/** Definition of an incoming packet */ -struct _JitterBufferPacket { - char *data; /**< Data bytes contained in the packet */ - spx_uint32_t len; /**< Length of the packet in bytes */ - spx_uint32_t timestamp; /**< Timestamp for the packet */ - spx_uint32_t span; /**< Time covered by the packet (same units as timestamp) */ - spx_uint16_t sequence; /**< RTP Sequence number if available (0 otherwise) */ - spx_uint32_t user_data; /**< Put whatever data you like here (it's ignored by the jitter buffer) */ -}; - -/** Packet has been retrieved */ -#define JITTER_BUFFER_OK 0 -/** Packet is lost or is late */ -#define JITTER_BUFFER_MISSING 1 -/** A "fake" packet is meant to be inserted here to increase buffering */ -#define JITTER_BUFFER_INSERTION 2 -/** There was an error in the jitter buffer */ -#define JITTER_BUFFER_INTERNAL_ERROR -1 -/** Invalid argument */ -#define JITTER_BUFFER_BAD_ARGUMENT -2 - - -/** Set minimum amount of extra buffering required (margin) */ -#define JITTER_BUFFER_SET_MARGIN 0 -/** Get minimum amount of extra buffering required (margin) */ -#define JITTER_BUFFER_GET_MARGIN 1 -/* JITTER_BUFFER_SET_AVAILABLE_COUNT wouldn't make sense */ - -/** Get the amount of available packets currently buffered */ -#define JITTER_BUFFER_GET_AVAILABLE_COUNT 3 -/** Included because of an early misspelling (will remove in next release) */ -#define JITTER_BUFFER_GET_AVALIABLE_COUNT 3 - -/** Assign a function to destroy unused packet. When setting that, the jitter - buffer no longer copies packet data. */ -#define JITTER_BUFFER_SET_DESTROY_CALLBACK 4 -/** */ -#define JITTER_BUFFER_GET_DESTROY_CALLBACK 5 - -/** Tell the jitter buffer to only adjust the delay in multiples of the step parameter provided */ -#define JITTER_BUFFER_SET_DELAY_STEP 6 -/** */ -#define JITTER_BUFFER_GET_DELAY_STEP 7 - -/** Tell the jitter buffer to only do concealment in multiples of the size parameter provided */ -#define JITTER_BUFFER_SET_CONCEALMENT_SIZE 8 -#define JITTER_BUFFER_GET_CONCEALMENT_SIZE 9 - -/** Absolute max amount of loss that can be tolerated regardless of the delay. Typical loss - should be half of that or less. */ -#define JITTER_BUFFER_SET_MAX_LATE_RATE 10 -#define JITTER_BUFFER_GET_MAX_LATE_RATE 11 - -/** Equivalent cost of one percent late packet in timestamp units */ -#define JITTER_BUFFER_SET_LATE_COST 12 -#define JITTER_BUFFER_GET_LATE_COST 13 - - -/** Initialises jitter buffer - * - * @param step_size Starting value for the size of concleanment packets and delay - adjustment steps. Can be changed at any time using JITTER_BUFFER_SET_DELAY_STEP - and JITTER_BUFFER_GET_CONCEALMENT_SIZE. - * @return Newly created jitter buffer state - */ -JitterBuffer *jitter_buffer_init(int step_size); - -/** Restores jitter buffer to its original state - * - * @param jitter Jitter buffer state - */ -void jitter_buffer_reset(JitterBuffer *jitter); - -/** Destroys jitter buffer - * - * @param jitter Jitter buffer state - */ -void jitter_buffer_destroy(JitterBuffer *jitter); - -/** Put one packet into the jitter buffer - * - * @param jitter Jitter buffer state - * @param packet Incoming packet -*/ -void jitter_buffer_put(JitterBuffer *jitter, const JitterBufferPacket *packet); - -/** Get one packet from the jitter buffer - * - * @param jitter Jitter buffer state - * @param packet Returned packet - * @param desired_span Number of samples (or units) we wish to get from the buffer (no guarantee) - * @param current_timestamp Timestamp for the returned packet -*/ -int jitter_buffer_get(JitterBuffer *jitter, JitterBufferPacket *packet, spx_int32_t desired_span, spx_int32_t *start_offset); - -/** Used right after jitter_buffer_get() to obtain another packet that would have the same timestamp. - * This is mainly useful for media where a single "frame" can be split into several packets. - * - * @param jitter Jitter buffer state - * @param packet Returned packet - */ -int jitter_buffer_get_another(JitterBuffer *jitter, JitterBufferPacket *packet); - -/** Get pointer timestamp of jitter buffer - * - * @param jitter Jitter buffer state -*/ -int jitter_buffer_get_pointer_timestamp(JitterBuffer *jitter); - -/** Advance by one tick - * - * @param jitter Jitter buffer state -*/ -void jitter_buffer_tick(JitterBuffer *jitter); - -/** Telling the jitter buffer about the remaining data in the application buffer - * @param jitter Jitter buffer state - * @param rem Amount of data buffered by the application (timestamp units) - */ -void jitter_buffer_remaining_span(JitterBuffer *jitter, spx_uint32_t rem); - -/** Used like the ioctl function to control the jitter buffer parameters - * - * @param jitter Jitter buffer state - * @param request ioctl-type request (one of the JITTER_BUFFER_* macros) - * @param ptr Data exchanged to-from function - * @return 0 if no error, -1 if request in unknown -*/ -int jitter_buffer_ctl(JitterBuffer *jitter, int request, void *ptr); - -int jitter_buffer_update_delay(JitterBuffer *jitter, JitterBufferPacket *packet, spx_int32_t *start_offset); - -/* @} */ - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/apps/codecs/libspeex/speex/speex_preprocess.h b/apps/codecs/libspeex/speex/speex_preprocess.h deleted file mode 100644 index 273efaff79..0000000000 --- a/apps/codecs/libspeex/speex/speex_preprocess.h +++ /dev/null @@ -1,190 +0,0 @@ -/* Copyright (C) 2003 Epic Games - Written by Jean-Marc Valin */ -/** - * @file speex_preprocess.h - * @brief Speex preprocessor. The preprocess can do noise suppression, - * residual echo suppression (after using the echo canceller), automatic - * gain control (AGC) and voice activity detection (VAD). -*/ -/* - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are - met: - - 1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - 3. The name of the author may not be used to endorse or promote products - derived from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, - INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef SPEEX_PREPROCESS_H -#define SPEEX_PREPROCESS_H -/** @defgroup SpeexPreprocessState SpeexPreprocessState: The Speex preprocessor - * This is the Speex preprocessor. The preprocess can do noise suppression, - * residual echo suppression (after using the echo canceller), automatic - * gain control (AGC) and voice activity detection (VAD). - * @{ - */ - -#include "speex_types.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** State of the preprocessor (one per channel). Should never be accessed directly. */ -struct SpeexPreprocessState_; - -/** State of the preprocessor (one per channel). Should never be accessed directly. */ -typedef struct SpeexPreprocessState_ SpeexPreprocessState; - - -/** Creates a new preprocessing state. You MUST create one state per channel processed. - * @param frame_size Number of samples to process at one time (should correspond to 10-20 ms). Must be - * the same value as that used for the echo canceller for residual echo cancellation to work. - * @param sampling_rate Sampling rate used for the input. - * @return Newly created preprocessor state -*/ -SpeexPreprocessState *speex_preprocess_state_init(int frame_size, int sampling_rate); - -/** Destroys a preprocessor state - * @param st Preprocessor state to destroy -*/ -void speex_preprocess_state_destroy(SpeexPreprocessState *st); - -/** Preprocess a frame - * @param st Preprocessor state - * @param x Audio sample vector (in and out). Must be same size as specified in speex_preprocess_state_init(). - * @return Bool value for voice activity (1 for speech, 0 for noise/silence), ONLY if VAD turned on. -*/ -int speex_preprocess_run(SpeexPreprocessState *st, spx_int16_t *x); - -/** Preprocess a frame (deprecated, use speex_preprocess_run() instead)*/ -int speex_preprocess(SpeexPreprocessState *st, spx_int16_t *x, spx_int32_t *echo); - -/** Update preprocessor state, but do not compute the output - * @param st Preprocessor state - * @param x Audio sample vector (in only). Must be same size as specified in speex_preprocess_state_init(). -*/ -void speex_preprocess_estimate_update(SpeexPreprocessState *st, spx_int16_t *x); - -/** Used like the ioctl function to control the preprocessor parameters - * @param st Preprocessor state - * @param request ioctl-type request (one of the SPEEX_PREPROCESS_* macros) - * @param ptr Data exchanged to-from function - * @return 0 if no error, -1 if request in unknown -*/ -int speex_preprocess_ctl(SpeexPreprocessState *st, int request, void *ptr); - - - -/** Set preprocessor denoiser state */ -#define SPEEX_PREPROCESS_SET_DENOISE 0 -/** Get preprocessor denoiser state */ -#define SPEEX_PREPROCESS_GET_DENOISE 1 - -/** Set preprocessor Automatic Gain Control state */ -#define SPEEX_PREPROCESS_SET_AGC 2 -/** Get preprocessor Automatic Gain Control state */ -#define SPEEX_PREPROCESS_GET_AGC 3 - -/** Set preprocessor Voice Activity Detection state */ -#define SPEEX_PREPROCESS_SET_VAD 4 -/** Get preprocessor Voice Activity Detection state */ -#define SPEEX_PREPROCESS_GET_VAD 5 - -/** Set preprocessor Automatic Gain Control level */ -#define SPEEX_PREPROCESS_SET_AGC_LEVEL 6 -/** Get preprocessor Automatic Gain Control level */ -#define SPEEX_PREPROCESS_GET_AGC_LEVEL 7 - -/** Set preprocessor dereverb state */ -#define SPEEX_PREPROCESS_SET_DEREVERB 8 -/** Get preprocessor dereverb state */ -#define SPEEX_PREPROCESS_GET_DEREVERB 9 - -/** Set preprocessor dereverb level */ -#define SPEEX_PREPROCESS_SET_DEREVERB_LEVEL 10 -/** Get preprocessor dereverb level */ -#define SPEEX_PREPROCESS_GET_DEREVERB_LEVEL 11 - -/** Set preprocessor dereverb decay */ -#define SPEEX_PREPROCESS_SET_DEREVERB_DECAY 12 -/** Get preprocessor dereverb decay */ -#define SPEEX_PREPROCESS_GET_DEREVERB_DECAY 13 - -/** Set probability required for the VAD to go from silence to voice */ -#define SPEEX_PREPROCESS_SET_PROB_START 14 -/** Get probability required for the VAD to go from silence to voice */ -#define SPEEX_PREPROCESS_GET_PROB_START 15 - -/** Set probability required for the VAD to stay in the voice state (integer percent) */ -#define SPEEX_PREPROCESS_SET_PROB_CONTINUE 16 -/** Get probability required for the VAD to stay in the voice state (integer percent) */ -#define SPEEX_PREPROCESS_GET_PROB_CONTINUE 17 - -/** Set maximum attenuation of the noise in dB (negative number) */ -#define SPEEX_PREPROCESS_SET_NOISE_SUPPRESS 18 -/** Get maximum attenuation of the noise in dB (negative number) */ -#define SPEEX_PREPROCESS_GET_NOISE_SUPPRESS 19 - -/** Set maximum attenuation of the residual echo in dB (negative number) */ -#define SPEEX_PREPROCESS_SET_ECHO_SUPPRESS 20 -/** Get maximum attenuation of the residual echo in dB (negative number) */ -#define SPEEX_PREPROCESS_GET_ECHO_SUPPRESS 21 - -/** Set maximum attenuation of the residual echo in dB when near end is active (negative number) */ -#define SPEEX_PREPROCESS_SET_ECHO_SUPPRESS_ACTIVE 22 -/** Get maximum attenuation of the residual echo in dB when near end is active (negative number) */ -#define SPEEX_PREPROCESS_GET_ECHO_SUPPRESS_ACTIVE 23 - -/** Set the corresponding echo canceller state so that residual echo suppression can be performed (NULL for no residual echo suppression) */ -#define SPEEX_PREPROCESS_SET_ECHO_STATE 24 -/** Get the corresponding echo canceller state */ -#define SPEEX_PREPROCESS_GET_ECHO_STATE 25 - -/** Set maximal gain increase in dB/second (int32) */ -#define SPEEX_PREPROCESS_SET_AGC_INCREMENT 26 - -/** Get maximal gain increase in dB/second (int32) */ -#define SPEEX_PREPROCESS_GET_AGC_INCREMENT 27 - -/** Set maximal gain decrease in dB/second (int32) */ -#define SPEEX_PREPROCESS_SET_AGC_DECREMENT 28 - -/** Get maximal gain decrease in dB/second (int32) */ -#define SPEEX_PREPROCESS_GET_AGC_DECREMENT 29 - -/** Set maximal gain in dB (int32) */ -#define SPEEX_PREPROCESS_SET_AGC_MAX_GAIN 30 - -/** Get maximal gain in dB (int32) */ -#define SPEEX_PREPROCESS_GET_AGC_MAX_GAIN 31 - -/* Can't set loudness */ -/** Get loudness */ -#define SPEEX_PREPROCESS_GET_AGC_LOUDNESS 33 - -#ifdef __cplusplus -} -#endif - -/** @}*/ -#endif diff --git a/apps/codecs/libspeex/speex/speex_resampler.h b/apps/codecs/libspeex/speex/speex_resampler.h deleted file mode 100644 index c44fbcd0d1..0000000000 --- a/apps/codecs/libspeex/speex/speex_resampler.h +++ /dev/null @@ -1,328 +0,0 @@ -/* Copyright (C) 2007 Jean-Marc Valin - - File: speex_resampler.h - Resampling code - - The design goals of this code are: - - Very fast algorithm - - Low memory requirement - - Good *perceptual* quality (and not best SNR) - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are - met: - - 1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - 3. The name of the author may not be used to endorse or promote products - derived from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, - INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. -*/ - - -#ifndef SPEEX_RESAMPLER_H -#define SPEEX_RESAMPLER_H - -#ifdef OUTSIDE_SPEEX - -/********* WARNING: MENTAL SANITY ENDS HERE *************/ - -/* If the resampler is defined outside of Speex, we change the symbol names so that - there won't be any clash if linking with Speex later on. */ - -/* #define RANDOM_PREFIX your software name here */ -#ifndef RANDOM_PREFIX -#error "Please define RANDOM_PREFIX (above) to something specific to your project to prevent symbol name clashes" -#endif - -#define CAT_PREFIX2(a,b) a ## b -#define CAT_PREFIX(a,b) CAT_PREFIX2(a, b) - -#define speex_resampler_init CAT_PREFIX(RANDOM_PREFIX,_resampler_init) -#define speex_resampler_init_frac CAT_PREFIX(RANDOM_PREFIX,_resampler_init_frac) -#define speex_resampler_destroy CAT_PREFIX(RANDOM_PREFIX,_resampler_destroy) -#define speex_resampler_process_float CAT_PREFIX(RANDOM_PREFIX,_resampler_process_float) -#define speex_resampler_process_int CAT_PREFIX(RANDOM_PREFIX,_resampler_process_int) -#define speex_resampler_process_interleaved_float CAT_PREFIX(RANDOM_PREFIX,_resampler_process_interleaved_float) -#define speex_resampler_process_interleaved_int CAT_PREFIX(RANDOM_PREFIX,_resampler_process_interleaved_int) -#define speex_resampler_set_rate CAT_PREFIX(RANDOM_PREFIX,_resampler_set_rate) -#define speex_resampler_get_rate CAT_PREFIX(RANDOM_PREFIX,_resampler_get_rate) -#define speex_resampler_set_rate_frac CAT_PREFIX(RANDOM_PREFIX,_resampler_set_rate_frac) -#define speex_resampler_get_ratio CAT_PREFIX(RANDOM_PREFIX,_resampler_get_ratio) -#define speex_resampler_set_quality CAT_PREFIX(RANDOM_PREFIX,_resampler_set_quality) -#define speex_resampler_get_quality CAT_PREFIX(RANDOM_PREFIX,_resampler_get_quality) -#define speex_resampler_set_input_stride CAT_PREFIX(RANDOM_PREFIX,_resampler_set_input_stride) -#define speex_resampler_get_input_stride CAT_PREFIX(RANDOM_PREFIX,_resampler_get_input_stride) -#define speex_resampler_set_output_stride CAT_PREFIX(RANDOM_PREFIX,_resampler_set_output_stride) -#define speex_resampler_get_output_stride CAT_PREFIX(RANDOM_PREFIX,_resampler_get_output_stride) -#define speex_resampler_skip_zeros CAT_PREFIX(RANDOM_PREFIX,_resampler_skip_zeros) -#define speex_resampler_reset_mem CAT_PREFIX(RANDOM_PREFIX,_resampler_reset_mem) -#define speex_resampler_strerror CAT_PREFIX(RANDOM_PREFIX,_resampler_strerror) - -#define spx_int16_t short -#define spx_int32_t int -#define spx_uint16_t unsigned short -#define spx_uint32_t unsigned int - -#else /* OUTSIDE_SPEEX */ - -#include "speex/speex_types.h" - -#endif /* OUTSIDE_SPEEX */ - -#ifdef __cplusplus -extern "C" { -#endif - -#define SPEEX_RESAMPLER_QUALITY_MAX 10 -#define SPEEX_RESAMPLER_QUALITY_MIN 0 -#define SPEEX_RESAMPLER_QUALITY_DEFAULT 4 -#define SPEEX_RESAMPLER_QUALITY_VOIP 3 -#define SPEEX_RESAMPLER_QUALITY_DESKTOP 5 - -enum { - RESAMPLER_ERR_SUCCESS = 0, - RESAMPLER_ERR_ALLOC_FAILED = 1, - RESAMPLER_ERR_BAD_STATE = 2, - RESAMPLER_ERR_INVALID_ARG = 3, - RESAMPLER_ERR_PTR_OVERLAP = 4, - - RESAMPLER_ERR_MAX_ERROR -}; - -struct SpeexResamplerState_; -typedef struct SpeexResamplerState_ SpeexResamplerState; - -/** Create a new resampler with integer input and output rates. - * @param nb_channels Number of channels to be processed - * @param in_rate Input sampling rate (integer number of Hz). - * @param out_rate Output sampling rate (integer number of Hz). - * @param quality Resampling quality between 0 and 10, where 0 has poor quality - * and 10 has very high quality. - * @return Newly created resampler state - * @retval NULL Error: not enough memory - */ -SpeexResamplerState *speex_resampler_init(spx_uint32_t nb_channels, - spx_uint32_t in_rate, - spx_uint32_t out_rate, - int quality, - int *err); - -/** Create a new resampler with fractional input/output rates. The sampling - * rate ratio is an arbitrary rational number with both the numerator and - * denominator being 32-bit integers. - * @param nb_channels Number of channels to be processed - * @param ratio_num Numerator of the sampling rate ratio - * @param ratio_den Denominator of the sampling rate ratio - * @param in_rate Input sampling rate rounded to the nearest integer (in Hz). - * @param out_rate Output sampling rate rounded to the nearest integer (in Hz). - * @param quality Resampling quality between 0 and 10, where 0 has poor quality - * and 10 has very high quality. - * @return Newly created resampler state - * @retval NULL Error: not enough memory - */ -SpeexResamplerState *speex_resampler_init_frac(spx_uint32_t nb_channels, - spx_uint32_t ratio_num, - spx_uint32_t ratio_den, - spx_uint32_t in_rate, - spx_uint32_t out_rate, - int quality, - int *err); - -/** Destroy a resampler state. - * @param st Resampler state - */ -void speex_resampler_destroy(SpeexResamplerState *st); - -/** Resample a float array. The input and output buffers must *not* overlap. - * @param st Resampler state - * @param channel_index Index of the channel to process for the multi-channel - * base (0 otherwise) - * @param in Input buffer - * @param in_len Number of input samples in the input buffer. Returns the - * number of samples processed - * @param out Output buffer - * @param out_len Size of the output buffer. Returns the number of samples written - */ -int speex_resampler_process_float(SpeexResamplerState *st, - spx_uint32_t channel_index, - const float *in, - spx_uint32_t *in_len, - float *out, - spx_uint32_t *out_len); - -/** Resample an int array. The input and output buffers must *not* overlap. - * @param st Resampler state - * @param channel_index Index of the channel to process for the multi-channel - * base (0 otherwise) - * @param in Input buffer - * @param in_len Number of input samples in the input buffer. Returns the number - * of samples processed - * @param out Output buffer - * @param out_len Size of the output buffer. Returns the number of samples written - */ -int speex_resampler_process_int(SpeexResamplerState *st, - spx_uint32_t channel_index, - const spx_int16_t *in, - spx_uint32_t *in_len, - spx_int16_t *out, - spx_uint32_t *out_len); - -/** Resample an interleaved float array. The input and output buffers must *not* overlap. - * @param st Resampler state - * @param in Input buffer - * @param in_len Number of input samples in the input buffer. Returns the number - * of samples processed. This is all per-channel. - * @param out Output buffer - * @param out_len Size of the output buffer. Returns the number of samples written. - * This is all per-channel. - */ -int speex_resampler_process_interleaved_float(SpeexResamplerState *st, - const float *in, - spx_uint32_t *in_len, - float *out, - spx_uint32_t *out_len); - -/** Resample an interleaved int array. The input and output buffers must *not* overlap. - * @param st Resampler state - * @param in Input buffer - * @param in_len Number of input samples in the input buffer. Returns the number - * of samples processed. This is all per-channel. - * @param out Output buffer - * @param out_len Size of the output buffer. Returns the number of samples written. - * This is all per-channel. - */ -int speex_resampler_process_interleaved_int(SpeexResamplerState *st, - const spx_int16_t *in, - spx_uint32_t *in_len, - spx_int16_t *out, - spx_uint32_t *out_len); - -/** Set (change) the input/output sampling rates (integer value). - * @param st Resampler state - * @param in_rate Input sampling rate (integer number of Hz). - * @param out_rate Output sampling rate (integer number of Hz). - */ -int speex_resampler_set_rate(SpeexResamplerState *st, - spx_uint32_t in_rate, - spx_uint32_t out_rate); - -/** Get the current input/output sampling rates (integer value). - * @param st Resampler state - * @param in_rate Input sampling rate (integer number of Hz) copied. - * @param out_rate Output sampling rate (integer number of Hz) copied. - */ -void speex_resampler_get_rate(SpeexResamplerState *st, - spx_uint32_t *in_rate, - spx_uint32_t *out_rate); - -/** Set (change) the input/output sampling rates and resampling ratio - * (fractional values in Hz supported). - * @param st Resampler state - * @param ratio_num Numerator of the sampling rate ratio - * @param ratio_den Denominator of the sampling rate ratio - * @param in_rate Input sampling rate rounded to the nearest integer (in Hz). - * @param out_rate Output sampling rate rounded to the nearest integer (in Hz). - */ -int speex_resampler_set_rate_frac(SpeexResamplerState *st, - spx_uint32_t ratio_num, - spx_uint32_t ratio_den, - spx_uint32_t in_rate, - spx_uint32_t out_rate); - -/** Get the current resampling ratio. This will be reduced to the least - * common denominator. - * @param st Resampler state - * @param ratio_num Numerator of the sampling rate ratio copied - * @param ratio_den Denominator of the sampling rate ratio copied - */ -void speex_resampler_get_ratio(SpeexResamplerState *st, - spx_uint32_t *ratio_num, - spx_uint32_t *ratio_den); - -/** Set (change) the conversion quality. - * @param st Resampler state - * @param quality Resampling quality between 0 and 10, where 0 has poor - * quality and 10 has very high quality. - */ -int speex_resampler_set_quality(SpeexResamplerState *st, - int quality); - -/** Get the conversion quality. - * @param st Resampler state - * @param quality Resampling quality between 0 and 10, where 0 has poor - * quality and 10 has very high quality. - */ -void speex_resampler_get_quality(SpeexResamplerState *st, - int *quality); - -/** Set (change) the input stride. - * @param st Resampler state - * @param stride Input stride - */ -void speex_resampler_set_input_stride(SpeexResamplerState *st, - spx_uint32_t stride); - -/** Get the input stride. - * @param st Resampler state - * @param stride Input stride copied - */ -void speex_resampler_get_input_stride(SpeexResamplerState *st, - spx_uint32_t *stride); - -/** Set (change) the output stride. - * @param st Resampler state - * @param stride Output stride - */ -void speex_resampler_set_output_stride(SpeexResamplerState *st, - spx_uint32_t stride); - -/** Get the output stride. - * @param st Resampler state copied - * @param stride Output stride - */ -void speex_resampler_get_output_stride(SpeexResamplerState *st, - spx_uint32_t *stride); - -/** Make sure that the first samples to go out of the resamplers don't have - * leading zeros. This is only useful before starting to use a newly created - * resampler. It is recommended to use that when resampling an audio file, as - * it will generate a file with the same length. For real-time processing, - * it is probably easier not to use this call (so that the output duration - * is the same for the first frame). - * @param st Resampler state - */ -int speex_resampler_skip_zeros(SpeexResamplerState *st); - -/** Reset a resampler so a new (unrelated) stream can be processed. - * @param st Resampler state - */ -int speex_resampler_reset_mem(SpeexResamplerState *st); - -/** Returns the English meaning for an error code - * @param err Error code - * @return English string - */ -const char *speex_resampler_strerror(int err); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/apps/codecs/libspeex/speex/speex_stereo.h b/apps/codecs/libspeex/speex/speex_stereo.h deleted file mode 100644 index 67e2a8d4e0..0000000000 --- a/apps/codecs/libspeex/speex/speex_stereo.h +++ /dev/null @@ -1,91 +0,0 @@ -/* Copyright (C) 2002 Jean-Marc Valin*/ -/** - @file speex_stereo.h - @brief Describes the handling for intensity stereo -*/ -/* - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of the Xiph.org Foundation nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef STEREO_H -#define STEREO_H -/** @defgroup SpeexStereoState SpeexStereoState: Handling Speex stereo files - * This describes the Speex intensity stereo encoding/decoding - * @{ - */ - -#include "speex_types.h" -#include "speex_bits.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** If you access any of these fields directly, I'll personally come and bite you */ -typedef struct SpeexStereoState { - float balance; /**< Left/right balance info */ - float e_ratio; /**< Ratio of energies: E(left+right)/[E(left)+E(right)] */ - float smooth_left; /**< Smoothed left channel gain */ - float smooth_right; /**< Smoothed right channel gain */ - float reserved1; /**< Reserved for future use */ - float reserved2; /**< Reserved for future use */ -} SpeexStereoState; - -/** Deprecated. Use speex_stereo_state_init() instead. */ -#define SPEEX_STEREO_STATE_INIT {1,.5,1,1,0,0} - -/** Initialise/create a stereo stereo state */ -SpeexStereoState *speex_stereo_state_init(void); - -/** Reset/re-initialise an already allocated stereo state */ -void speex_stereo_state_reset(SpeexStereoState *stereo); - -/** Destroy a stereo stereo state */ -void speex_stereo_state_destroy(SpeexStereoState *stereo); - -/** Transforms a stereo frame into a mono frame and stores intensity stereo info in 'bits' */ -void speex_encode_stereo(float *data, int frame_size, SpeexBits *bits); - -/** Transforms a stereo frame into a mono frame and stores intensity stereo info in 'bits' */ -void speex_encode_stereo_int(spx_int16_t *data, int frame_size, SpeexBits *bits); - -/** Transforms a mono frame into a stereo frame using intensity stereo info */ -void speex_decode_stereo(float *data, int frame_size, SpeexStereoState *stereo); - -/** Transforms a mono frame into a stereo frame using intensity stereo info */ -void speex_decode_stereo_int(spx_int16_t *data, int frame_size, SpeexStereoState *stereo); - -/** Callback handler for intensity stereo info */ -int speex_std_stereo_request_handler(SpeexBits *bits, void *state, void *data); - -#ifdef __cplusplus -} -#endif - -/** @} */ -#endif diff --git a/apps/codecs/libspeex/speex/speex_types.h b/apps/codecs/libspeex/speex/speex_types.h deleted file mode 100644 index a2ff1d6b53..0000000000 --- a/apps/codecs/libspeex/speex/speex_types.h +++ /dev/null @@ -1,126 +0,0 @@ -/* speex_types.h taken from libogg */ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2002 * - * by the Xiph.Org Foundation http://www.xiph.org/ * - * * - ******************************************************************** - - function: #ifdef jail to whip a few platforms into the UNIX ideal. - last mod: $Id$ - - ********************************************************************/ -/** - @file speex_types.h - @brief Speex types -*/ -#ifndef _SPEEX_TYPES_H -#define _SPEEX_TYPES_H - -#if defined(_WIN32) - -# if defined(__CYGWIN__) -# include <_G_config.h> - typedef _G_int32_t spx_int32_t; - typedef _G_uint32_t spx_uint32_t; - typedef _G_int16_t spx_int16_t; - typedef _G_uint16_t spx_uint16_t; -# elif defined(__MINGW32__) - typedef short spx_int16_t; - typedef unsigned short spx_uint16_t; - typedef int spx_int32_t; - typedef unsigned int spx_uint32_t; -# elif defined(__MWERKS__) - typedef int spx_int32_t; - typedef unsigned int spx_uint32_t; - typedef short spx_int16_t; - typedef unsigned short spx_uint16_t; -# else - /* MSVC/Borland */ - typedef __int32 spx_int32_t; - typedef unsigned __int32 spx_uint32_t; - typedef __int16 spx_int16_t; - typedef unsigned __int16 spx_uint16_t; -# endif - -#elif defined(__MACOS__) - -# include - typedef SInt16 spx_int16_t; - typedef UInt16 spx_uint16_t; - typedef SInt32 spx_int32_t; - typedef UInt32 spx_uint32_t; - -#elif defined(__MACOSX__) /* MacOS X Framework build */ - -# include - typedef int16_t spx_int16_t; - typedef u_int16_t spx_uint16_t; - typedef int32_t spx_int32_t; - typedef u_int32_t spx_uint32_t; - -#elif defined(__BEOS__) - - /* Be */ -# include - typedef int16_t spx_int16_t; - typedef u_int16_t spx_uint16_t; - typedef int32_t spx_int32_t; - typedef u_int32_t spx_uint32_t; - -#elif defined (__EMX__) - - /* OS/2 GCC */ - typedef short spx_int16_t; - typedef unsigned short spx_uint16_t; - typedef int spx_int32_t; - typedef unsigned int spx_uint32_t; - -#elif defined (DJGPP) - - /* DJGPP */ - typedef short spx_int16_t; - typedef int spx_int32_t; - typedef unsigned int spx_uint32_t; - -#elif defined(R5900) - - /* PS2 EE */ - typedef int spx_int32_t; - typedef unsigned spx_uint32_t; - typedef short spx_int16_t; - -#elif defined(__SYMBIAN32__) - - /* Symbian GCC */ - typedef signed short spx_int16_t; - typedef unsigned short spx_uint16_t; - typedef signed int spx_int32_t; - typedef unsigned int spx_uint32_t; - -#elif defined(CONFIG_TI_C54X) || defined (CONFIG_TI_C55X) - - typedef short spx_int16_t; - typedef unsigned short spx_uint16_t; - typedef long spx_int32_t; - typedef unsigned long spx_uint32_t; - -#elif defined(CONFIG_TI_C6X) - - typedef short spx_int16_t; - typedef unsigned short spx_uint16_t; - typedef int spx_int32_t; - typedef unsigned int spx_uint32_t; - -#else - -# include "speex_config_types.h" - -#endif - -#endif /* _SPEEX_TYPES_H */ diff --git a/apps/codecs/libspeex/speex_callbacks.c b/apps/codecs/libspeex/speex_callbacks.c deleted file mode 100644 index f1de038488..0000000000 --- a/apps/codecs/libspeex/speex_callbacks.c +++ /dev/null @@ -1,160 +0,0 @@ -/* Copyright (C) 2002 Jean-Marc Valin - File speex_callbacks.c - Callback handling and in-band signalling - - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of the Xiph.org Foundation nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*/ - -#ifdef HAVE_CONFIG_H -#include "config-speex.h" -#endif - -#include "speex/speex_callbacks.h" -#include "arch.h" -#include "os_support.h" - -int speex_inband_handler(SpeexBits *bits, SpeexCallback *callback_list, void *state) -{ - int id; - SpeexCallback *callback; - /*speex_bits_advance(bits, 5);*/ - id=speex_bits_unpack_unsigned(bits, 4); - callback = callback_list+id; - - if (callback->func) - { - return callback->func(bits, state, callback->data); - } else - /*If callback is not registered, skip the right number of bits*/ - { - int adv; - if (id<2) - adv = 1; - else if (id<8) - adv = 4; - else if (id<10) - adv = 8; - else if (id<12) - adv = 16; - else if (id<14) - adv = 32; - else - adv = 64; - speex_bits_advance(bits, adv); - } - return 0; -} - -#if 0 -/* Rockbox: unused */ -int speex_std_mode_request_handler(SpeexBits *bits, void *state, void *data) -{ - (void)state; - spx_int32_t m; - m = speex_bits_unpack_unsigned(bits, 4); - speex_encoder_ctl(data, SPEEX_SET_MODE, &m); - return 0; -} - -int speex_std_low_mode_request_handler(SpeexBits *bits, void *state, void *data) -{ - (void)state; - spx_int32_t m; - m = speex_bits_unpack_unsigned(bits, 4); - speex_encoder_ctl(data, SPEEX_SET_LOW_MODE, &m); - return 0; -} - -int speex_std_high_mode_request_handler(SpeexBits *bits, void *state, void *data) -{ - (void)state; - spx_int32_t m; - m = speex_bits_unpack_unsigned(bits, 4); - speex_encoder_ctl(data, SPEEX_SET_HIGH_MODE, &m); - return 0; -} -#endif - -#ifndef DISABLE_VBR -int speex_std_vbr_request_handler(SpeexBits *bits, void *state, void *data) -{ - (void)state; - spx_int32_t vbr; - vbr = speex_bits_unpack_unsigned(bits, 1); - speex_encoder_ctl(data, SPEEX_SET_VBR, &vbr); - return 0; -} -#endif /* #ifndef DISABLE_VBR */ - -#if 0 -/* Rockbox: unused */ -int speex_std_enh_request_handler(SpeexBits *bits, void *state, void *data) -{ - (void)state; - spx_int32_t enh; - enh = speex_bits_unpack_unsigned(bits, 1); - speex_decoder_ctl(data, SPEEX_SET_ENH, &enh); - return 0; -} -#endif - -#ifndef DISABLE_VBR -int speex_std_vbr_quality_request_handler(SpeexBits *bits, void *state, void *data) -{ - (void)state; - float qual; - qual = speex_bits_unpack_unsigned(bits, 4); - speex_encoder_ctl(data, SPEEX_SET_VBR_QUALITY, &qual); - return 0; -} -#endif /* #ifndef DISABLE_VBR */ - -#if 0 -/* Rockbox: unused */ -int speex_std_char_handler(SpeexBits *bits, void *state, void *data) -{ - (void)state; - unsigned char ch; - ch = speex_bits_unpack_unsigned(bits, 8); - _speex_putc(ch, data); - /*printf("speex_std_char_handler ch=%x\n", ch);*/ - return 0; -} -#endif - -/* Default handler for user callbacks: skip it */ -int speex_default_user_handler(SpeexBits *bits, void *state, void *data) -{ - (void)state; - (void)data; - int req_size = speex_bits_unpack_unsigned(bits, 4); - speex_bits_advance(bits, 5+8*req_size); - return 0; -} diff --git a/apps/codecs/libspeex/speex_header.c b/apps/codecs/libspeex/speex_header.c deleted file mode 100644 index b0e98b7c9c..0000000000 --- a/apps/codecs/libspeex/speex_header.c +++ /dev/null @@ -1,188 +0,0 @@ -/* Copyright (C) 2002 Jean-Marc Valin - File: speex_header.c - Describes the Speex header - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of the Xiph.org Foundation nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*/ - -#ifdef HAVE_CONFIG_H -#include "config-speex.h" -#endif - -#include "arch.h" -#include "speex/speex_header.h" -#include "speex/speex.h" -#include "os_support.h" - -#ifndef NULL -#define NULL 0 -#endif - -/** Convert little endian */ -static inline spx_int32_t le_int(spx_int32_t i) -{ -#ifdef ROCKBOX - return letoh32(i); -#elif !defined(__LITTLE_ENDIAN__) && ( defined(WORDS_BIGENDIAN) || defined(__BIG_ENDIAN__) ) - spx_uint32_t ui, ret; - ui = i; - ret = ui>>24; - ret |= (ui>>8)&0x0000ff00; - ret |= (ui<<8)&0x00ff0000; - ret |= (ui<<24); - return ret; -#else - return i; -#endif -} - -#define ENDIAN_SWITCH(x) {x=le_int(x);} - - -/* -typedef struct SpeexHeader { - char speex_string[8]; - char speex_version[SPEEX_HEADER_VERSION_LENGTH]; - int speex_version_id; - int header_size; - int rate; - int mode; - int mode_bitstream_version; - int nb_channels; - int bitrate; - int frame_size; - int vbr; - int frames_per_packet; - int extra_headers; - int reserved1; - int reserved2; -} SpeexHeader; -*/ - -#ifndef SPEEX_DISABLE_ENCODER -void speex_init_header(SpeexHeader *header, int rate, int nb_channels, const SpeexMode *m) -{ - int i; - const char *h="Speex "; - /* - strncpy(header->speex_string, "Speex ", 8); - strncpy(header->speex_version, SPEEX_VERSION, SPEEX_HEADER_VERSION_LENGTH-1); - header->speex_version[SPEEX_HEADER_VERSION_LENGTH-1]=0; - */ - for (i=0;i<8;i++) - header->speex_string[i]=h[i]; - for (i=0;ispeex_version[i]=SPEEX_VERSION[i]; - for (;ispeex_version[i]=0; - - header->speex_version_id = 1; - header->header_size = sizeof(SpeexHeader); - - header->rate = rate; - header->mode = m->modeID; - header->mode_bitstream_version = m->bitstream_version; - if (m->modeID<0) - speex_warning("This mode is meant to be used alone"); - header->nb_channels = nb_channels; - header->bitrate = -1; - speex_mode_query(m, SPEEX_MODE_FRAME_SIZE, &header->frame_size); - header->vbr = 0; - - header->frames_per_packet = 0; - header->extra_headers = 0; - header->reserved1 = 0; - header->reserved2 = 0; -} - -char *speex_header_to_packet(SpeexHeader *header, int *size) -{ - SpeexHeader *le_header; - le_header = (SpeexHeader*)speex_alloc(sizeof(SpeexHeader)); - - SPEEX_COPY(le_header, header, 1); - - /*Make sure everything is now little-endian*/ - ENDIAN_SWITCH(le_header->speex_version_id); - ENDIAN_SWITCH(le_header->header_size); - ENDIAN_SWITCH(le_header->rate); - ENDIAN_SWITCH(le_header->mode); - ENDIAN_SWITCH(le_header->mode_bitstream_version); - ENDIAN_SWITCH(le_header->nb_channels); - ENDIAN_SWITCH(le_header->bitrate); - ENDIAN_SWITCH(le_header->frame_size); - ENDIAN_SWITCH(le_header->vbr); - ENDIAN_SWITCH(le_header->frames_per_packet); - ENDIAN_SWITCH(le_header->extra_headers); - - *size = sizeof(SpeexHeader); - return (char *)le_header; -} -#endif /* SPEEX_DISABLE_ENCODER */ - -static SpeexHeader global_le_header; /* Avoid malloc */ -SpeexHeader *speex_packet_to_header(char *packet, int size) -{ - int i; - SpeexHeader *le_header = &global_le_header; - const char *h = "Speex "; - for (i=0;i<8;i++) - if (packet[i]!=h[i]) - { - speex_notify("This doesn't look like a Speex file"); - return NULL; - } - - /*FIXME: Do we allow larger headers?*/ - if (size < (int)sizeof(SpeexHeader)) - { - speex_notify("Speex header too small"); - return NULL; - } - - /* le_header = (SpeexHeader*)speex_alloc(sizeof(SpeexHeader)); */ - - SPEEX_COPY(le_header, (SpeexHeader*)packet, 1); - - /*Make sure everything is converted correctly from little-endian*/ - ENDIAN_SWITCH(le_header->speex_version_id); - ENDIAN_SWITCH(le_header->header_size); - ENDIAN_SWITCH(le_header->rate); - ENDIAN_SWITCH(le_header->mode); - ENDIAN_SWITCH(le_header->mode_bitstream_version); - ENDIAN_SWITCH(le_header->nb_channels); - ENDIAN_SWITCH(le_header->bitrate); - ENDIAN_SWITCH(le_header->frame_size); - ENDIAN_SWITCH(le_header->vbr); - ENDIAN_SWITCH(le_header->frames_per_packet); - ENDIAN_SWITCH(le_header->extra_headers); - - return le_header; - -} diff --git a/apps/codecs/libspeex/stack_alloc.h b/apps/codecs/libspeex/stack_alloc.h deleted file mode 100644 index f06f2f6f7f..0000000000 --- a/apps/codecs/libspeex/stack_alloc.h +++ /dev/null @@ -1,130 +0,0 @@ -/* Copyright (C) 2002 Jean-Marc Valin */ -/** - @file stack_alloc.h - @brief Temporary memory allocation on stack -*/ -/* - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of the Xiph.org Foundation nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef STACK_ALLOC_H -#define STACK_ALLOC_H - -#include "config-speex.h" - -#ifdef USE_ALLOCA -# ifdef WIN32 -# include -# else -# ifdef HAVE_ALLOCA_H -# include -# else -# include -# endif -# endif -#endif - -/** - * @def ALIGN(stack, size) - * - * Aligns the stack to a 'size' boundary - * - * @param stack Stack - * @param size New size boundary - */ - -/** - * @def PUSH(stack, size, type) - * - * Allocates 'size' elements of type 'type' on the stack - * - * @param stack Stack - * @param size Number of elements - * @param type Type of element - */ - -/** - * @def PUSHS(stack, type) - * - * Allocates a struct stack - * - * @param stack Stack - * @param type Struct type - */ - -/** - * @def VARDECL(var) - * - * Declare variable on stack - * - * @param var Variable to declare - */ - -/** - * @def ALLOC(var, size, type) - * - * Allocate 'size' elements of 'type' on stack - * - * @param var Name of variable to allocate - * @param size Number of elements - * @param type Type of element - */ - -#ifdef ENABLE_VALGRIND - -#include - -#define ALIGN(stack, size) ((stack) += ((size) - (long)(stack)) & ((size) - 1)) - -#define PUSH(stack, size, type) (VALGRIND_MAKE_NOACCESS(stack, 1000),ALIGN((stack),sizeof(type)),VALGRIND_MAKE_WRITABLE(stack, ((size)*sizeof(type))),(stack)+=((size)*sizeof(type)),(type*)((stack)-((size)*sizeof(type)))) - -#define PUSHS(stack, type) (VALGRIND_MAKE_NOACCESS(stack, 1000),ALIGN((stack),sizeof(long)),VALGRIND_MAKE_WRITABLE(stack, (sizeof(type))),(stack)+=(sizeof(type)),(type*)((stack)-(sizeof(type)))) - -#else - -#define ALIGN(stack, size) ((stack) += ((size) - (long)(stack)) & ((size) - 1)) - -#define PUSH(stack, size, type) (ALIGN((stack),sizeof(type)),(stack)+=((size)*sizeof(type)),(type*)((stack)-((size)*sizeof(type)))) - -#define PUSHS(stack, type) (ALIGN((stack),sizeof(long)),(stack)+=(sizeof(type)),(type*)((stack)-(sizeof(type)))) - -#endif - -#if defined(VAR_ARRAYS) -#define VARDECL(var) -#define ALLOC(var, size, type) type var[size] -#elif defined(USE_ALLOCA) -#define VARDECL(var) var -#define ALLOC(var, size, type) var = alloca(sizeof(type)*(size)) -#else -#define VARDECL(var) var -#define ALLOC(var, size, type) var = PUSH(stack, size, type) -#endif - - -#endif diff --git a/apps/codecs/libspeex/stereo.c b/apps/codecs/libspeex/stereo.c deleted file mode 100644 index 652d2a6e90..0000000000 --- a/apps/codecs/libspeex/stereo.c +++ /dev/null @@ -1,302 +0,0 @@ -/* Copyright (C) 2002 Jean-Marc Valin - File: stereo.c - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of the Xiph.org Foundation nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifdef HAVE_CONFIG_H -#include "config-speex.h" -#endif - -#include "speex/speex_stereo.h" -#include "speex/speex_callbacks.h" -#include "math_approx.h" -#include "vq.h" -#include -#include "os_support.h" - -typedef struct RealSpeexStereoState { - spx_word32_t balance; /**< Left/right balance info */ - spx_word32_t e_ratio; /**< Ratio of energies: E(left+right)/[E(left)+E(right)] */ - spx_word32_t smooth_left; /**< Smoothed left channel gain */ - spx_word32_t smooth_right; /**< Smoothed right channel gain */ - spx_uint32_t reserved1; /**< Reserved for future use */ - spx_int32_t reserved2; /**< Reserved for future use */ -} RealSpeexStereoState; - - -/*float e_ratio_quant[4] = {1, 1.26, 1.587, 2};*/ -#ifndef FIXED_POINT -static const float e_ratio_quant[4] = {.25f, .315f, .397f, .5f}; -static const float e_ratio_quant_bounds[3] = {0.2825f, 0.356f, 0.4485f}; -#else -static const spx_word16_t e_ratio_quant[4] = {8192, 10332, 13009, 16384}; -static const spx_word16_t e_ratio_quant_bounds[3] = {9257, 11665, 14696}; -static const spx_word16_t balance_bounds[31] = {18, 23, 30, 38, 49, 63, 81, 104, - 134, 172, 221, 284, 364, 468, 600, 771, - 990, 1271, 1632, 2096, 2691, 3455, 4436, 5696, - 7314, 9392, 12059, 15484, 19882, 25529, 32766}; -#endif - -/* This is an ugly compatibility hack that properly resets the stereo state - In case it it compiled in fixed-point, but initialised with the deprecated - floating point static initialiser */ -#ifdef FIXED_POINT -#define COMPATIBILITY_HACK(s) do {if ((s)->reserved1 != 0xdeadbeef) speex_stereo_state_reset((SpeexStereoState*)s); } while (0); -#else -#define COMPATIBILITY_HACK(s) -#endif - -static SpeexStereoState global_stereo_state; -SpeexStereoState *speex_stereo_state_init() -{ - /* SpeexStereoState *stereo = speex_alloc(sizeof(SpeexStereoState)); */ - SpeexStereoState *stereo = &global_stereo_state; - speex_stereo_state_reset(stereo); - return stereo; -} - -void speex_stereo_state_reset(SpeexStereoState *_stereo) -{ - RealSpeexStereoState *stereo = (RealSpeexStereoState*)_stereo; -#ifdef FIXED_POINT - stereo->balance = 65536; - stereo->e_ratio = 16384; - stereo->smooth_left = 16384; - stereo->smooth_right = 16384; - stereo->reserved1 = 0xdeadbeef; - stereo->reserved2 = 0; -#else - stereo->balance = 1.0f; - stereo->e_ratio = .5f; - stereo->smooth_left = 1.f; - stereo->smooth_right = 1.f; - stereo->reserved1 = 0; - stereo->reserved2 = 0; -#endif -} - -void speex_stereo_state_destroy(SpeexStereoState *stereo) -{ - (void)stereo; - /* speex_free(stereo); */ -} - -#ifndef SPEEX_DISABLE_ENCODER -#ifndef DISABLE_FLOAT_API -void speex_encode_stereo(float *data, int frame_size, SpeexBits *bits) -{ - int i, tmp; - float e_left=0, e_right=0, e_tot=0; - float balance, e_ratio; - for (i=0;i0) - speex_bits_pack(bits, 0, 1); - else - speex_bits_pack(bits, 1, 1); - balance=floor(.5+fabs(balance)); - if (balance>30) - balance=31; - - speex_bits_pack(bits, (int)balance, 5); - - /* FIXME: this is a hack */ - tmp=scal_quant(e_ratio*Q15_ONE, e_ratio_quant_bounds, 4); - speex_bits_pack(bits, tmp, 2); -} -#endif /* #ifndef DISABLE_FLOAT_API */ - -void speex_encode_stereo_int(spx_int16_t *data, int frame_size, SpeexBits *bits) -{ - int i, tmp; - spx_word32_t e_left=0, e_right=0, e_tot=0; - spx_word32_t balance, e_ratio; - spx_word32_t largest, smallest; - int balance_id; -#ifdef FIXED_POINT - int shift; -#endif - - /* In band marker */ - speex_bits_pack(bits, 14, 5); - /* Stereo marker */ - speex_bits_pack(bits, SPEEX_INBAND_STEREO, 4); - - for (i=0;i e_right) - { - speex_bits_pack(bits, 0, 1); - largest = e_left; - smallest = e_right; - } else { - speex_bits_pack(bits, 1, 1); - largest = e_right; - smallest = e_left; - } - - /* Balance quantization */ -#ifdef FIXED_POINT - shift = spx_ilog2(largest)-15; - largest = VSHR32(largest, shift-4); - smallest = VSHR32(smallest, shift); - balance = DIV32(largest, ADD32(smallest, 1)); - if (balance > 32767) - balance = 32767; - balance_id = scal_quant(EXTRACT16(balance), balance_bounds, 32); -#else - balance=(largest+1.)/(smallest+1.); - balance=4*log(balance); - balance_id=floor(.5+fabs(balance)); - if (balance_id>30) - balance_id=31; -#endif - - speex_bits_pack(bits, balance_id, 5); - - /* "coherence" quantisation */ -#ifdef FIXED_POINT - shift = spx_ilog2(e_tot); - e_tot = VSHR32(e_tot, shift-25); - e_left = VSHR32(e_left, shift-10); - e_right = VSHR32(e_right, shift-10); - e_ratio = DIV32(e_tot, e_left+e_right+1); -#else - e_ratio = e_tot/(1.+e_left+e_right); -#endif - - tmp=scal_quant(EXTRACT16(e_ratio), e_ratio_quant_bounds, 4); - /*fprintf (stderr, "%d %d %d %d\n", largest, smallest, balance_id, e_ratio);*/ - speex_bits_pack(bits, tmp, 2); -} -#endif /* SPEEX_DISABLE_ENCODER */ - -#ifndef DISABLE_FLOAT_API -void speex_decode_stereo(float *data, int frame_size, SpeexStereoState *_stereo) -{ - int i; - spx_word32_t balance; - spx_word16_t e_left, e_right, e_ratio; - RealSpeexStereoState *stereo = (RealSpeexStereoState*)_stereo; - - COMPATIBILITY_HACK(stereo); - - balance=stereo->balance; - e_ratio=stereo->e_ratio; - - /* These two are Q14, with max value just below 2. */ - e_right = DIV32(QCONST32(1., 22), spx_sqrt(MULT16_32_Q15(e_ratio, ADD32(QCONST32(1., 16), balance)))); - e_left = SHR32(MULT16_16(spx_sqrt(balance), e_right), 8); - - for (i=frame_size-1;i>=0;i--) - { - spx_word16_t tmp=data[i]; - stereo->smooth_left = EXTRACT16(PSHR32(MAC16_16(MULT16_16(stereo->smooth_left, QCONST16(0.98, 15)), e_left, QCONST16(0.02, 15)), 15)); - stereo->smooth_right = EXTRACT16(PSHR32(MAC16_16(MULT16_16(stereo->smooth_right, QCONST16(0.98, 15)), e_right, QCONST16(0.02, 15)), 15)); - data[2*i] = (float)MULT16_16_P14(stereo->smooth_left, tmp); - data[2*i+1] = (float)MULT16_16_P14(stereo->smooth_right, tmp); - } -} -#endif /* #ifndef DISABLE_FLOAT_API */ - -void speex_decode_stereo_int(spx_int16_t *data, int frame_size, SpeexStereoState *_stereo) -{ - int i; - spx_word32_t balance; - spx_word16_t e_left, e_right, e_ratio; - RealSpeexStereoState *stereo = (RealSpeexStereoState*)_stereo; - - /* COMPATIBILITY_HACK(stereo); */ - - balance=stereo->balance; - e_ratio=stereo->e_ratio; - - /* These two are Q14, with max value just below 2. */ - e_right = DIV32(QCONST32(1., 22), spx_sqrt(MULT16_32_Q15(e_ratio, ADD32(QCONST32(1., 16), balance)))); - e_left = SHR32(MULT16_16(spx_sqrt(balance), e_right), 8); - - for (i=frame_size-1;i>=0;i--) - { - spx_int16_t tmp=data[i]; - stereo->smooth_left = EXTRACT16(PSHR32(MAC16_16(MULT16_16(stereo->smooth_left, QCONST16(0.98, 15)), e_left, QCONST16(0.02, 15)), 15)); - stereo->smooth_right = EXTRACT16(PSHR32(MAC16_16(MULT16_16(stereo->smooth_right, QCONST16(0.98, 15)), e_right, QCONST16(0.02, 15)), 15)); - data[2*i] = (spx_int16_t)MULT16_16_P14(stereo->smooth_left, tmp); - data[2*i+1] = (spx_int16_t)MULT16_16_P14(stereo->smooth_right, tmp); - } -} - -int speex_std_stereo_request_handler(SpeexBits *bits, void *state, void *data) -{ - (void)state; - RealSpeexStereoState *stereo; - spx_word16_t sign=1, dexp; - int tmp; - - stereo = (RealSpeexStereoState*)data; - - /* COMPATIBILITY_HACK(stereo); */ - - if (speex_bits_unpack_unsigned(bits, 1)) - sign=-1; - dexp = speex_bits_unpack_unsigned(bits, 5); -#ifndef FIXED_POINT - stereo->balance = exp(sign*.25*dexp); -#else - stereo->balance = spx_exp(MULT16_16(sign, SHL16(dexp, 9))); -#endif - tmp = speex_bits_unpack_unsigned(bits, 2); - stereo->e_ratio = e_ratio_quant[tmp]; - - return 0; -} diff --git a/apps/codecs/libspeex/vbr.c b/apps/codecs/libspeex/vbr.c deleted file mode 100644 index 32b33bc10e..0000000000 --- a/apps/codecs/libspeex/vbr.c +++ /dev/null @@ -1,275 +0,0 @@ -/* Copyright (C) 2002 Jean-Marc Valin - File: vbr.c - - VBR-related routines - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of the Xiph.org Foundation nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*/ - -#ifdef HAVE_CONFIG_H -#include "config-speex.h" -#endif - -#include "vbr.h" -#include - - -#define sqr(x) ((x)*(x)) - -#define MIN_ENERGY 6000 -#define NOISE_POW .3 - -#ifndef DISABLE_VBR - -const float vbr_nb_thresh[9][11]={ - {-1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f}, /* CNG */ - { 4.0f, 2.5f, 2.0f, 1.2f, 0.5f, 0.0f, -0.5f, -0.7f, -0.8f, -0.9f, -1.0f}, /* 2 kbps */ - {10.0f, 6.5f, 5.2f, 4.5f, 3.9f, 3.5f, 3.0f, 2.5f, 2.3f, 1.8f, 1.0f}, /* 6 kbps */ - {11.0f, 8.8f, 7.5f, 6.5f, 5.0f, 3.9f, 3.9f, 3.9f, 3.5f, 3.0f, 1.0f}, /* 8 kbps */ - {11.0f, 11.0f, 9.9f, 8.5f, 7.0f, 6.0f, 4.5f, 4.0f, 4.0f, 4.0f, 2.0f}, /* 11 kbps */ - {11.0f, 11.0f, 11.0f, 11.0f, 9.5f, 8.5f, 8.0f, 7.0f, 6.0f, 5.0f, 3.0f}, /* 15 kbps */ - {11.0f, 11.0f, 11.0f, 11.0f, 11.0f, 11.0f, 9.5f, 8.5f, 7.0f, 6.0f, 5.0f}, /* 18 kbps */ - {11.0f, 11.0f, 11.0f, 11.0f, 11.0f, 11.0f, 11.0f, 11.0f, 9.8f, 9.5f, 7.5f}, /* 24 kbps */ - { 7.0f, 4.5f, 3.7f, 3.0f, 2.5f, 2.0f, 1.8f, 1.5f, 1.0f, 0.0f, 0.0f} /* 4 kbps */ -}; - - -const float vbr_hb_thresh[5][11]={ - {-1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f}, /* silence */ - {-1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f}, /* 2 kbps */ - {11.0f, 11.0f, 9.5f, 8.5f, 7.5f, 6.0f, 5.0f, 3.9f, 3.0f, 2.0f, 1.0f}, /* 6 kbps */ - {11.0f, 11.0f, 11.0f, 11.0f, 11.0f, 9.5f, 8.7f, 7.8f, 7.0f, 6.5f, 4.0f}, /* 10 kbps */ - {11.0f, 11.0f, 11.0f, 11.0f, 11.0f, 11.0f, 11.0f, 11.0f, 9.8f, 7.5f, 5.5f} /* 18 kbps */ -}; - -const float vbr_uhb_thresh[2][11]={ - {-1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f}, /* silence */ - { 3.9f, 2.5f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, -1.0f} /* 2 kbps */ -}; - -void vbr_init(VBRState *vbr) -{ - int i; - - vbr->average_energy=0; - vbr->last_energy=1; - vbr->accum_sum=0; - vbr->energy_alpha=.1; - vbr->soft_pitch=0; - vbr->last_pitch_coef=0; - vbr->last_quality=0; - - vbr->noise_accum = .05*pow(MIN_ENERGY, NOISE_POW); - vbr->noise_accum_count=.05; - vbr->noise_level=vbr->noise_accum/vbr->noise_accum_count; - vbr->consec_noise=0; - - - for (i=0;ilast_log_energy[i] = log(MIN_ENERGY); -} - - -/* - This function should analyse the signal and decide how critical the - coding error will be perceptually. The following factors should be - taken into account: - - -Attacks (positive energy derivative) should be coded with more bits - - -Stationary voiced segments should receive more bits - - -Segments with (very) low absolute energy should receive less bits (maybe - only shaped noise?) - - -DTX for near-zero energy? - - -Stationary fricative segments should have less bits - - -Temporal masking: when energy slope is decreasing, decrease the bit-rate - - -Decrease bit-rate for males (low pitch)? - - -(wideband only) less bits in the high-band when signal is very - non-stationary (harder to notice high-frequency noise)??? - -*/ - -float vbr_analysis(VBRState *vbr, spx_word16_t *sig, int len, int pitch, float pitch_coef) -{ - int i; - float ener=0, ener1=0, ener2=0; - float qual=7; - int va; - float log_energy; - float non_st=0; - float voicing; - float pow_ener; - - for (i=0;i>1;i++) - ener1 += ((float)sig[i])*sig[i]; - - for (i=len>>1;ilast_log_energy[i]); - non_st = non_st/(30*VBR_MEMORY_SIZE); - if (non_st>1) - non_st=1; - - voicing = 3*(pitch_coef-.4)*fabs(pitch_coef-.4); - vbr->average_energy = (1-vbr->energy_alpha)*vbr->average_energy + vbr->energy_alpha*ener; - vbr->noise_level=vbr->noise_accum/vbr->noise_accum_count; - pow_ener = pow(ener,NOISE_POW); - if (vbr->noise_accum_count<.06 && ener>MIN_ENERGY) - vbr->noise_accum = .05*pow_ener; - - if ((voicing<.3 && non_st < .2 && pow_ener < 1.2*vbr->noise_level) - || (voicing<.3 && non_st < .05 && pow_ener < 1.5*vbr->noise_level) - || (voicing<.4 && non_st < .05 && pow_ener < 1.2*vbr->noise_level) - || (voicing<0 && non_st < .05)) - { - float tmp; - va = 0; - vbr->consec_noise++; - if (pow_ener > 3*vbr->noise_level) - tmp = 3*vbr->noise_level; - else - tmp = pow_ener; - if (vbr->consec_noise>=4) - { - vbr->noise_accum = .95*vbr->noise_accum + .05*tmp; - vbr->noise_accum_count = .95*vbr->noise_accum_count + .05; - } - } else { - va = 1; - vbr->consec_noise=0; - } - - if (pow_ener < vbr->noise_level && ener>MIN_ENERGY) - { - vbr->noise_accum = .95*vbr->noise_accum + .05*pow_ener; - vbr->noise_accum_count = .95*vbr->noise_accum_count + .05; - } - - /* Checking for very low absolute energy */ - if (ener < 30000) - { - qual -= .7; - if (ener < 10000) - qual-=.7; - if (ener < 3000) - qual-=.7; - } else { - float short_diff, long_diff; - short_diff = log((ener+1)/(1+vbr->last_energy)); - long_diff = log((ener+1)/(1+vbr->average_energy)); - /*fprintf (stderr, "%f %f\n", short_diff, long_diff);*/ - - if (long_diff<-5) - long_diff=-5; - if (long_diff>2) - long_diff=2; - - if (long_diff>0) - qual += .6*long_diff; - if (long_diff<0) - qual += .5*long_diff; - if (short_diff>0) - { - if (short_diff>5) - short_diff=5; - qual += .5*short_diff; - } - /* Checking for energy increases */ - if (ener2 > 1.6*ener1) - qual += .5; - } - vbr->last_energy = ener; - vbr->soft_pitch = .6*vbr->soft_pitch + .4*pitch_coef; - qual += 2.2*((pitch_coef-.4) + (vbr->soft_pitch-.4)); - - if (qual < vbr->last_quality) - qual = .5*qual + .5*vbr->last_quality; - if (qual<4) - qual=4; - if (qual>10) - qual=10; - - /* - if (vbr->consec_noise>=2) - qual-=1.3; - if (vbr->consec_noise>=5) - qual-=1.3; - if (vbr->consec_noise>=12) - qual-=1.3; - */ - if (vbr->consec_noise>=3) - qual=4; - - if (vbr->consec_noise) - qual -= 1.0 * (log(3.0 + vbr->consec_noise)-log(3)); - if (qual<0) - qual=0; - - if (ener<60000) - { - if (vbr->consec_noise>2) - qual-=0.5*(log(3.0 + vbr->consec_noise)-log(3)); - if (ener<10000&&vbr->consec_noise>2) - qual-=0.5*(log(3.0 + vbr->consec_noise)-log(3)); - if (qual<0) - qual=0; - qual += .3*log(.0001+ener/60000.0); - } - if (qual<-1) - qual=-1; - - /*printf ("%f %f %f %f %d\n", qual, voicing, non_st, pow_ener/(.01+vbr->noise_level), va);*/ - - vbr->last_pitch_coef = pitch_coef; - vbr->last_quality = qual; - - for (i=VBR_MEMORY_SIZE-1;i>0;i--) - vbr->last_log_energy[i] = vbr->last_log_energy[i-1]; - vbr->last_log_energy[0] = log_energy; - - /*printf ("VBR: %f %f %f %d %f\n", (float)(log_energy-log(vbr->average_energy+MIN_ENERGY)), non_st, voicing, va, vbr->noise_level);*/ - - return qual; -} - -void vbr_destroy(VBRState *vbr) -{ -} - -#endif /* #ifndef DISABLE_VBR */ diff --git a/apps/codecs/libspeex/vbr.h b/apps/codecs/libspeex/vbr.h deleted file mode 100644 index ff1e3e46f2..0000000000 --- a/apps/codecs/libspeex/vbr.h +++ /dev/null @@ -1,70 +0,0 @@ -/* Copyright (C) 2002 Jean-Marc Valin */ -/** - @file vbr.h - @brief Variable Bit-Rate (VBR) related routines -*/ -/* - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of the Xiph.org Foundation nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*/ - - -#ifndef VBR_H -#define VBR_H - -#include "arch.h" - -#define VBR_MEMORY_SIZE 5 - -extern const float vbr_nb_thresh[9][11]; -extern const float vbr_hb_thresh[5][11]; -extern const float vbr_uhb_thresh[2][11]; - -/** VBR state. */ -typedef struct VBRState { - float energy_alpha; - float average_energy; - float last_energy; - float last_log_energy[VBR_MEMORY_SIZE]; - float accum_sum; - float last_pitch_coef; - float soft_pitch; - float last_quality; - float noise_level; - float noise_accum; - float noise_accum_count; - int consec_noise; -} VBRState; - -void vbr_init(VBRState *vbr); - -float vbr_analysis(VBRState *vbr, spx_word16_t *sig, int len, int pitch, float pitch_coef); - -void vbr_destroy(VBRState *vbr); - -#endif diff --git a/apps/codecs/libspeex/vorbis_psy.c b/apps/codecs/libspeex/vorbis_psy.c deleted file mode 100644 index 2032bf63e2..0000000000 --- a/apps/codecs/libspeex/vorbis_psy.c +++ /dev/null @@ -1,508 +0,0 @@ -/* Copyright (C) 2005 Jean-Marc Valin, CSIRO, Christopher Montgomery - File: vorbis_psy.c - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of the Xiph.org Foundation nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifdef HAVE_CONFIG_H -#include "config-speex.h" -#endif - -#ifdef VORBIS_PSYCHO - -#include "arch.h" -#include "smallft.h" -#include "lpc.h" -#include "vorbis_psy.h" - -#include -#include -#include - -/* psychoacoustic setup ********************************************/ - -static VorbisPsyInfo example_tuning = { - - .5,.5, - 3,3,25, - - /*63 125 250 500 1k 2k 4k 8k 16k*/ - // vorbis mode 4 style - //{-32,-32,-32,-32,-28,-24,-22,-20,-20, -20, -20, -8, -6, -6, -6, -6, -6}, - { -4, -6, -6, -6, -6, -6, -6, -6, -8, -8,-10,-10, -8, -6, -4, -4, -2}, - - { - 0, 1, 2, 3, 4, 5, 5, 5, /* 7dB */ - 6, 6, 6, 5, 4, 4, 4, 4, /* 15dB */ - 4, 4, 5, 5, 5, 6, 6, 6, /* 23dB */ - 7, 7, 7, 8, 8, 8, 9, 10, /* 31dB */ - 11,12,13,14,15,16,17, 18, /* 39dB */ - } - -}; - - - -/* there was no great place to put this.... */ -#include -static void _analysis_output(char *base,int i,float *v,int n,int bark,int dB){ - int j; - FILE *of; - char buffer[80]; - - sprintf(buffer,"%s_%d.m",base,i); - of=fopen(buffer,"w"); - - if(!of)perror("failed to open data dump file"); - - for(j=0;j> 16; - if( lo>=0 ) break; - hi = b[i] & 0xffff; - - tN = N[hi] + N[-lo]; - tX = X[hi] - X[-lo]; - tXX = XX[hi] + XX[-lo]; - tY = Y[hi] + Y[-lo]; - tXY = XY[hi] - XY[-lo]; - - A = tY * tXX - tX * tXY; - B = tN * tXY - tX * tY; - D = tN * tXX - tX * tX; - R = (A + x * B) / D; - if (R < 0.f) - R = 0.f; - - noise[i] = R - offset; - } - - for ( ;; i++, x += 1.f) { - - lo = b[i] >> 16; - hi = b[i] & 0xffff; - if(hi>=n)break; - - tN = N[hi] - N[lo]; - tX = X[hi] - X[lo]; - tXX = XX[hi] - XX[lo]; - tY = Y[hi] - Y[lo]; - tXY = XY[hi] - XY[lo]; - - A = tY * tXX - tX * tXY; - B = tN * tXY - tX * tY; - D = tN * tXX - tX * tX; - R = (A + x * B) / D; - if (R < 0.f) R = 0.f; - - noise[i] = R - offset; - } - for ( ; i < n; i++, x += 1.f) { - - R = (A + x * B) / D; - if (R < 0.f) R = 0.f; - - noise[i] = R - offset; - } - - if (fixed <= 0) return; - - for (i = 0, x = 0.f;; i++, x += 1.f) { - hi = i + fixed / 2; - lo = hi - fixed; - if(lo>=0)break; - - tN = N[hi] + N[-lo]; - tX = X[hi] - X[-lo]; - tXX = XX[hi] + XX[-lo]; - tY = Y[hi] + Y[-lo]; - tXY = XY[hi] - XY[-lo]; - - - A = tY * tXX - tX * tXY; - B = tN * tXY - tX * tY; - D = tN * tXX - tX * tX; - R = (A + x * B) / D; - - if (R - offset < noise[i]) noise[i] = R - offset; - } - for ( ;; i++, x += 1.f) { - - hi = i + fixed / 2; - lo = hi - fixed; - if(hi>=n)break; - - tN = N[hi] - N[lo]; - tX = X[hi] - X[lo]; - tXX = XX[hi] - XX[lo]; - tY = Y[hi] - Y[lo]; - tXY = XY[hi] - XY[lo]; - - A = tY * tXX - tX * tXY; - B = tN * tXY - tX * tY; - D = tN * tXX - tX * tX; - R = (A + x * B) / D; - - if (R - offset < noise[i]) noise[i] = R - offset; - } - for ( ; i < n; i++, x += 1.f) { - R = (A + x * B) / D; - if (R - offset < noise[i]) noise[i] = R - offset; - } -} - -static void _vp_noisemask(VorbisPsy *p, - float *logfreq, - float *logmask){ - - int i,n=p->n/2; - float *work=alloca(n*sizeof(*work)); - - bark_noise_hybridmp(n,p->bark,logfreq,logmask, - 140.,-1); - - for(i=0;ibark,work,logmask,0., - p->vi->noisewindowfixed); - - for(i=0;i=NOISE_COMPAND_LEVELS)dB=NOISE_COMPAND_LEVELS-1; - if(dB<0)dB=0; - logmask[i]= work[i]+p->vi->noisecompand[dB]+p->noiseoffset[i]; - } - -} - -VorbisPsy *vorbis_psy_init(int rate, int n) -{ - long i,j,lo=-99,hi=1; - VorbisPsy *p = speex_alloc(sizeof(VorbisPsy)); - memset(p,0,sizeof(*p)); - - p->n = n; - spx_drft_init(&p->lookup, n); - p->bark = speex_alloc(n*sizeof(*p->bark)); - p->rate=rate; - p->vi = &example_tuning; - - /* BH4 window */ - p->window = speex_alloc(sizeof(*p->window)*n); - float a0 = .35875f; - float a1 = .48829f; - float a2 = .14128f; - float a3 = .01168f; - for(i=0;iwindow[i] = //a0 - a1*cos(2.*M_PI/n*(i+.5)) + a2*cos(4.*M_PI/n*(i+.5)) - a3*cos(6.*M_PI/n*(i+.5)); - sin((i+.5)/n * M_PI)*sin((i+.5)/n * M_PI); - /* bark scale lookups */ - for(i=0;ivi->noisewindowlominvi->noisewindowlo);lo++); - - for(;hi<=n && (hivi->noisewindowhimin || - toBARK(rate/(2*n)*hi)<(bark+p->vi->noisewindowhi));hi++); - - p->bark[i]=((lo-1)<<16)+(hi-1); - - } - - /* set up rolling noise median */ - p->noiseoffset=speex_alloc(n*sizeof(*p->noiseoffset)); - - for(i=0;i=P_BANDS-1)halfoc=P_BANDS-1; - inthalfoc=(int)halfoc; - del=halfoc-inthalfoc; - - p->noiseoffset[i]= - p->vi->noiseoff[inthalfoc]*(1.-del) + - p->vi->noiseoff[inthalfoc+1]*del; - - } -#if 0 - _analysis_output_always("noiseoff0",ls,p->noiseoffset,n,1,0,0); -#endif - - return p; -} - -void vorbis_psy_destroy(VorbisPsy *p) -{ - if(p){ - spx_drft_clear(&p->lookup); - if(p->bark) - speex_free(p->bark); - if(p->noiseoffset) - speex_free(p->noiseoffset); - if(p->window) - speex_free(p->window); - memset(p,0,sizeof(*p)); - speex_free(p); - } -} - -void compute_curve(VorbisPsy *psy, float *audio, float *curve) -{ - int i; - float work[psy->n]; - - float scale=4.f/psy->n; - float scale_dB; - - scale_dB=todB(scale); - - /* window the PCM data; use a BH4 window, not vorbis */ - for(i=0;in;i++) - work[i]=audio[i] * psy->window[i]; - - { - static int seq=0; - - //_analysis_output("win",seq,work,psy->n,0,0); - - seq++; - } - - /* FFT yields more accurate tonal estimation (not phase sensitive) */ - spx_drft_forward(&psy->lookup,work); - - /* magnitudes */ - work[0]=scale_dB+todB(work[0]); - for(i=1;in-1;i+=2){ - float temp = work[i]*work[i] + work[i+1]*work[i+1]; - work[(i+1)>>1] = scale_dB+.5f * todB(temp); - } - - /* derive a noise curve */ - _vp_noisemask(psy,work,curve); -#define SIDEL 12 - for (i=0;in>>1)-i-1]=curve[(psy->n>>1)-SIDEH]; - } - for(i=0;i<((psy->n)>>1);i++) - curve[i] = fromdB(1.2*curve[i]+.2*i); - //curve[i] = fromdB(0.8*curve[i]+.35*i); - //curve[i] = fromdB(0.9*curve[i])*pow(1.0*i+45,1.3); -} - -/* Transform a masking curve (power spectrum) into a pole-zero filter */ -void curve_to_lpc(VorbisPsy *psy, float *curve, float *awk1, float *awk2, int ord) -{ - int i; - float ac[psy->n]; - float tmp; - int len = psy->n >> 1; - for (i=0;i<2*len;i++) - ac[i] = 0; - for (i=1;ilookup, ac); - _spx_lpc(awk1, ac, ord); - tmp = 1.; - for (i=0;ilookup, ac); - /* Compute (power) response of awk1 (all zero) */ - ac[0] *= ac[0]; - for (i=1;ilookup, ac); - _spx_lpc(awk2, ac, ord); - tmp = 1; - for (i=0;i -#include - -#define ORDER 10 -#define CURVE_SIZE 24 - -int main() -{ - int i; - float curve[CURVE_SIZE]; - float awk1[ORDER], awk2[ORDER]; - for (i=0;i1e-13?log((x)*(x))*4.34294480f:-30) -#define fromdB(x) (exp((x)*.11512925f)) - -/* The bark scale equations are approximations, since the original - table was somewhat hand rolled. The below are chosen to have the - best possible fit to the rolled tables, thus their somewhat odd - appearance (these are more accurate and over a longer range than - the oft-quoted bark equations found in the texts I have). The - approximations are valid from 0 - 30kHz (nyquist) or so. - - all f in Hz, z in Bark */ - -#define toBARK(n) (13.1f*atan(.00074f*(n))+2.24f*atan((n)*(n)*1.85e-8f)+1e-4f*(n)) -#define fromBARK(z) (102.f*(z)-2.f*pow(z,2.f)+.4f*pow(z,3.f)+pow(1.46f,z)-1.f) - -/* Frequency to octave. We arbitrarily declare 63.5 Hz to be octave - 0.0 */ - -#define toOC(n) (log(n)*1.442695f-5.965784f) -#define fromOC(o) (exp(((o)+5.965784f)*.693147f)) - - -typedef struct { - - float noisewindowlo; - float noisewindowhi; - int noisewindowlomin; - int noisewindowhimin; - int noisewindowfixed; - float noiseoff[P_BANDS]; - float noisecompand[NOISE_COMPAND_LEVELS]; - -} VorbisPsyInfo; - - - -typedef struct { - int n; - int rate; - struct drft_lookup lookup; - VorbisPsyInfo *vi; - - float *window; - float *noiseoffset; - long *bark; - -} VorbisPsy; - - -VorbisPsy *vorbis_psy_init(int rate, int size); -void vorbis_psy_destroy(VorbisPsy *psy); -void compute_curve(VorbisPsy *psy, float *audio, float *curve); -void curve_to_lpc(VorbisPsy *psy, float *curve, float *awk1, float *awk2, int ord); - -#endif -#endif diff --git a/apps/codecs/libspeex/vq.c b/apps/codecs/libspeex/vq.c deleted file mode 100644 index fff470a588..0000000000 --- a/apps/codecs/libspeex/vq.c +++ /dev/null @@ -1,147 +0,0 @@ -/* Copyright (C) 2002 Jean-Marc Valin - File: vq.c - Vector quantization - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of the Xiph.org Foundation nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifdef HAVE_CONFIG_H -#include "config-speex.h" -#endif - -#include "vq.h" -#include "stack_alloc.h" -#include "arch.h" - -#ifdef _USE_SSE -#include -#include "vq_sse.h" -#elif defined(SHORTCUTS) && (defined(ARM4_ASM) || defined(ARM5E_ASM)) -#include "vq_arm4.h" -#elif defined(BFIN_ASM) -#include "vq_bfin.h" -#endif - - -int scal_quant(spx_word16_t in, const spx_word16_t *boundary, int entries) -{ - int i=0; - while (iboundary[0]) - { - boundary++; - i++; - } - return i; -} - -int scal_quant32(spx_word32_t in, const spx_word32_t *boundary, int entries) -{ - int i=0; - while (iboundary[0]) - { - boundary++; - i++; - } - return i; -} - - -#ifndef OVERRIDE_VQ_NBEST -/*Finds the indices of the n-best entries in a codebook*/ -void vq_nbest(spx_word16_t *in, const spx_word16_t *codebook, int len, int entries, spx_word32_t *E, int N, int *nbest, spx_word32_t *best_dist, char *stack) -{ - int i,j,k,used; - used = 0; - for (i=0;i= 1) && (k > used || dist < best_dist[k-1]); k--) - { - best_dist[k]=best_dist[k-1]; - nbest[k] = nbest[k-1]; - } - best_dist[k]=dist; - nbest[k]=i; - used++; - } - } -} -#endif - - - - -#ifndef OVERRIDE_VQ_NBEST_SIGN -/*Finds the indices of the n-best entries in a codebook with sign*/ -void vq_nbest_sign(spx_word16_t *in, const spx_word16_t *codebook, int len, int entries, spx_word32_t *E, int N, int *nbest, spx_word32_t *best_dist, char *stack) -{ - int i,j,k, sign, used; - used=0; - for (i=0;i0) - { - sign=0; - dist=-dist; - } else - { - sign=1; - } -#ifdef FIXED_POINT - dist = ADD32(dist,SHR32(E[i],1)); -#else - dist = ADD32(dist,.5f*E[i]); -#endif - if (i= 1) && (k > used || dist < best_dist[k-1]); k--) - { - best_dist[k]=best_dist[k-1]; - nbest[k] = nbest[k-1]; - } - best_dist[k]=dist; - nbest[k]=i; - used++; - if (sign) - nbest[k]+=entries; - } - } -} -#endif diff --git a/apps/codecs/libspeex/vq.h b/apps/codecs/libspeex/vq.h deleted file mode 100644 index 5a4ced249c..0000000000 --- a/apps/codecs/libspeex/vq.h +++ /dev/null @@ -1,54 +0,0 @@ -/* Copyright (C) 2002 Jean-Marc Valin */ -/** - @file vq.h - @brief Vector quantization -*/ -/* - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of the Xiph.org Foundation nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef VQ_H -#define VQ_H - -#include "arch.h" - -int scal_quant(spx_word16_t in, const spx_word16_t *boundary, int entries); -int scal_quant32(spx_word32_t in, const spx_word32_t *boundary, int entries); - -#ifdef _USE_SSE -#include -void vq_nbest(spx_word16_t *in, const __m128 *codebook, int len, int entries, __m128 *E, int N, int *nbest, spx_word32_t *best_dist, char *stack); - -void vq_nbest_sign(spx_word16_t *in, const __m128 *codebook, int len, int entries, __m128 *E, int N, int *nbest, spx_word32_t *best_dist, char *stack); -#else -void vq_nbest(spx_word16_t *in, const spx_word16_t *codebook, int len, int entries, spx_word32_t *E, int N, int *nbest, spx_word32_t *best_dist, char *stack); - -void vq_nbest_sign(spx_word16_t *in, const spx_word16_t *codebook, int len, int entries, spx_word32_t *E, int N, int *nbest, spx_word32_t *best_dist, char *stack); -#endif - -#endif diff --git a/apps/codecs/libspeex/vq_arm4.h b/apps/codecs/libspeex/vq_arm4.h deleted file mode 100644 index d2697e5784..0000000000 --- a/apps/codecs/libspeex/vq_arm4.h +++ /dev/null @@ -1,115 +0,0 @@ -/* Copyright (C) 2004 Jean-Marc Valin */ -/** - @file vq_arm4.h - @brief ARM4-optimized vq routine -*/ -/* - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of the Xiph.org Foundation nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#define OVERRIDE_VQ_NBEST -void vq_nbest(spx_word16_t *in, const spx_word16_t *codebook, int len, int entries, spx_word32_t *E, int N, int *nbest, spx_word32_t *best_dist, char *stack) -{ - int i,j; - for (i=0;i>= 1;\n\t" - "A0 = %0;\n\t" - "R0.L = W[%1++%7] || R1.L = W[I0++];\n\t" - "LOOP vq_loop%= LC1 = %5;\n\t" - "LOOP_BEGIN vq_loop%=;\n\t" - "%0 = (A0 -= R0.L*R1.L) (IS) || R0.L = W[%1++%7] || R1.L = W[I0++];\n\t" - "LOOP_END vq_loop%=;\n\t" - "%0 = (A0 -= R0.L*R1.L) (IS);\n\t" - "cc = %0 < %2;\n\t" - "if cc %2 = %0;\n\t" - "if cc %3 = R2;\n\t" - "R2 += 1;\n\t" - "LOOP_END entries_loop%=;\n\t" - : "=&D" (dist), "=&a" (codebook), "=&d" (best_dist[0]), "=&d" (nbest[0]), "=&a" (E) - : "a" (len-1), "a" (in), "a" (2), "d" (entries), "d" (len<<1), "1" (codebook), "4" (E), "2" (best_dist[0]), "3" (nbest[0]) - : "R0", "R1", "R2", "I0", "L0", "B0", "A0", "cc", "memory" - ); - } - } else { - int i,k,used; - used = 0; - for (i=0;i>= 1;\n\t" - "A0 = %0;\n\t" - "I0 = %3;\n\t" - "L0 = 0;\n\t" - "R0.L = W[%1++%4] || R1.L = W[I0++];\n\t" - "LOOP vq_loop%= LC0 = %2;\n\t" - "LOOP_BEGIN vq_loop%=;\n\t" - "%0 = (A0 -= R0.L*R1.L) (IS) || R0.L = W[%1++%4] || R1.L = W[I0++];\n\t" - "LOOP_END vq_loop%=;\n\t" - "%0 = (A0 -= R0.L*R1.L) (IS);\n\t" - : "=D" (dist), "=a" (codebook) - : "a" (len-1), "a" (in), "a" (2), "1" (codebook), "0" (E[i]) - : "R0", "R1", "I0", "L0", "A0" - ); - if (i= 1) && (k > used || dist < best_dist[k-1]); k--) - { - best_dist[k]=best_dist[k-1]; - nbest[k] = nbest[k-1]; - } - best_dist[k]=dist; - nbest[k]=i; - used++; - } - } - } -} diff --git a/apps/codecs/libspeex/vq_sse.h b/apps/codecs/libspeex/vq_sse.h deleted file mode 100644 index 00a42ce354..0000000000 --- a/apps/codecs/libspeex/vq_sse.h +++ /dev/null @@ -1,120 +0,0 @@ -/* Copyright (C) 2004 Jean-Marc Valin */ -/** - @file vq_sse.h - @brief SSE-optimized vq routine -*/ -/* - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of the Xiph.org Foundation nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#define OVERRIDE_VQ_NBEST -void vq_nbest(spx_word16_t *_in, const __m128 *codebook, int len, int entries, __m128 *E, int N, int *nbest, spx_word32_t *best_dist, char *stack) -{ - int i,j,k,used; - VARDECL(float *dist); - VARDECL(__m128 *in); - __m128 half; - used = 0; - ALLOC(dist, entries, float); - half = _mm_set_ps1(.5f); - ALLOC(in, len, __m128); - for (i=0;i>2;i++) - { - __m128 d = _mm_mul_ps(E[i], half); - for (j=0;j= 1) && (k > used || dist[i] < best_dist[k-1]); k--) - { - best_dist[k]=best_dist[k-1]; - nbest[k] = nbest[k-1]; - } - best_dist[k]=dist[i]; - nbest[k]=i; - used++; - } - } -} - - - - -#define OVERRIDE_VQ_NBEST_SIGN -void vq_nbest_sign(spx_word16_t *_in, const __m128 *codebook, int len, int entries, __m128 *E, int N, int *nbest, spx_word32_t *best_dist, char *stack) -{ - int i,j,k,used; - VARDECL(float *dist); - VARDECL(__m128 *in); - __m128 half; - used = 0; - ALLOC(dist, entries, float); - half = _mm_set_ps1(.5f); - ALLOC(in, len, __m128); - for (i=0;i>2;i++) - { - __m128 d = _mm_setzero_ps(); - for (j=0;j0) - { - sign=0; - dist[i]=-dist[i]; - } else - { - sign=1; - } - dist[i] += .5f*((float*)E)[i]; - if (i= 1) && (k > used || dist[i] < best_dist[k-1]); k--) - { - best_dist[k]=best_dist[k-1]; - nbest[k] = nbest[k-1]; - } - best_dist[k]=dist[i]; - nbest[k]=i; - used++; - if (sign) - nbest[k]+=entries; - } - } -} diff --git a/apps/codecs/libspeex/window.c b/apps/codecs/libspeex/window.c deleted file mode 100644 index 84ed4916cf..0000000000 --- a/apps/codecs/libspeex/window.c +++ /dev/null @@ -1,102 +0,0 @@ -/* Copyright (C) 2006 Jean-Marc Valin - File: window.c - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of the Xiph.org Foundation nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifdef HAVE_CONFIG_H -#include "config-speex.h" -#endif - -#include "arch.h" - -#ifdef FIXED_POINT -const spx_word16_t lag_window[11] ICONST_ATTR = { - 16384, 16337, 16199, 15970, 15656, 15260, 14790, 14254, 13659, 13015, 12330 -}; - -const spx_word16_t lpc_window[200] ICONST_ATTR = { -1310, 1313, 1321, 1333, 1352, 1375, 1403, 1436, -1475, 1518, 1567, 1621, 1679, 1743, 1811, 1884, -1962, 2044, 2132, 2224, 2320, 2421, 2526, 2636, -2750, 2868, 2990, 3116, 3246, 3380, 3518, 3659, -3804, 3952, 4104, 4259, 4417, 4578, 4742, 4909, -5079, 5251, 5425, 5602, 5781, 5963, 6146, 6331, -6518, 6706, 6896, 7087, 7280, 7473, 7668, 7863, -8059, 8256, 8452, 8650, 8847, 9044, 9241, 9438, -9635, 9831, 10026, 10220, 10414, 10606, 10797, 10987, -11176, 11363, 11548, 11731, 11912, 12091, 12268, 12443, -12615, 12785, 12952, 13116, 13277, 13435, 13590, 13742, -13890, 14035, 14176, 14314, 14448, 14578, 14704, 14826, -14944, 15058, 15168, 15273, 15374, 15470, 15562, 15649, -15732, 15810, 15883, 15951, 16015, 16073, 16127, 16175, -16219, 16257, 16291, 16319, 16342, 16360, 16373, 16381, -16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384, -16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384, -16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384, -16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384, -16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384, -16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384, -16384, 16384, 16384, 16361, 16294, 16183, 16028, 15830, -15588, 15304, 14979, 14613, 14207, 13763, 13282, 12766, -12215, 11631, 11016, 10373, 9702, 9007, 8289, 7551, -6797, 6028, 5251, 4470, 3695, 2943, 2248, 1696 -}; -#else -const spx_word16_t lag_window[11] = { - 1.00000, 0.99716, 0.98869, 0.97474, 0.95554, 0.93140, 0.90273, 0.86998, 0.83367, 0.79434, 0.75258 -}; - -const spx_word16_t lpc_window[200] = { - 0.080000f, 0.080158f, 0.080630f, 0.081418f, 0.082520f, 0.083935f, 0.085663f, 0.087703f, - 0.090052f, 0.092710f, 0.095674f, 0.098943f, 0.102514f, 0.106385f, 0.110553f, 0.115015f, - 0.119769f, 0.124811f, 0.130137f, 0.135744f, 0.141628f, 0.147786f, 0.154212f, 0.160902f, - 0.167852f, 0.175057f, 0.182513f, 0.190213f, 0.198153f, 0.206328f, 0.214731f, 0.223357f, - 0.232200f, 0.241254f, 0.250513f, 0.259970f, 0.269619f, 0.279453f, 0.289466f, 0.299651f, - 0.310000f, 0.320507f, 0.331164f, 0.341965f, 0.352901f, 0.363966f, 0.375151f, 0.386449f, - 0.397852f, 0.409353f, 0.420943f, 0.432615f, 0.444361f, 0.456172f, 0.468040f, 0.479958f, - 0.491917f, 0.503909f, 0.515925f, 0.527959f, 0.540000f, 0.552041f, 0.564075f, 0.576091f, - 0.588083f, 0.600042f, 0.611960f, 0.623828f, 0.635639f, 0.647385f, 0.659057f, 0.670647f, - 0.682148f, 0.693551f, 0.704849f, 0.716034f, 0.727099f, 0.738035f, 0.748836f, 0.759493f, - 0.770000f, 0.780349f, 0.790534f, 0.800547f, 0.810381f, 0.820030f, 0.829487f, 0.838746f, - 0.847800f, 0.856643f, 0.865269f, 0.873672f, 0.881847f, 0.889787f, 0.897487f, 0.904943f, - 0.912148f, 0.919098f, 0.925788f, 0.932214f, 0.938372f, 0.944256f, 0.949863f, 0.955189f, - 0.960231f, 0.964985f, 0.969447f, 0.973615f, 0.977486f, 0.981057f, 0.984326f, 0.987290f, - 0.989948f, 0.992297f, 0.994337f, 0.996065f, 0.997480f, 0.998582f, 0.999370f, 0.999842f, - 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, - 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, - 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, - 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, - 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, - 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, - 1.000000f, 1.000000f, 1.000000f, 0.998640f, 0.994566f, 0.987787f, 0.978324f, 0.966203f, - 0.951458f, 0.934131f, 0.914270f, 0.891931f, 0.867179f, 0.840084f, 0.810723f, 0.779182f, - 0.745551f, 0.709930f, 0.672424f, 0.633148f, 0.592223f, 0.549781f, 0.505964f, 0.460932f, - 0.414863f, 0.367968f, 0.320511f, 0.272858f, 0.225569f, 0.179655f, 0.137254f, 0.103524f -}; -#endif diff --git a/apps/codecs/libtremor/CHANGELOG b/apps/codecs/libtremor/CHANGELOG deleted file mode 100644 index 53f23351e2..0000000000 --- a/apps/codecs/libtremor/CHANGELOG +++ /dev/null @@ -1,19 +0,0 @@ -*** 20020517: 1.0.2 *** - - Playback bugfix to floor1; mode mistakenly used for sizing instead - of blockflag - -*** 20020515: 1.0.1 *** - - Added complete API documentation to source tarball. No code - changes. - -*** 20020412: 1.0.1 *** - - Fixed a clipping bug that affected ARM processors; negative - overflows were being properly clipped, but then clobbered to - positive by the positive overflow chec (asm_arm.h:CLIP_TO_15) - -*** 20020403: 1.0.0 *** - - Initial version \ No newline at end of file diff --git a/apps/codecs/libtremor/COPYING b/apps/codecs/libtremor/COPYING deleted file mode 100644 index 6111c6c5a6..0000000000 --- a/apps/codecs/libtremor/COPYING +++ /dev/null @@ -1,28 +0,0 @@ -Copyright (c) 2002, Xiph.org Foundation - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - -- Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - -- Redistributions in binary form must reproduce the above copyright -notice, this list of conditions and the following disclaimer in the -documentation and/or other materials provided with the distribution. - -- Neither the name of the Xiph.org Foundation nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION -OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/apps/codecs/libtremor/README b/apps/codecs/libtremor/README deleted file mode 100644 index 1321175322..0000000000 --- a/apps/codecs/libtremor/README +++ /dev/null @@ -1,46 +0,0 @@ -This README covers the Ogg Vorbis 'Tremor' integer playback codec -source as of date 2002 09 02, version 1.0.0. - - ****** - -The C source in this package will build on any ANSI C compiler and -function completely and properly on any platform. The included build -system assumes GNU build system and make tools (m4, automake, -autoconf, libtool and gmake). GCC is not required, although GCC is -the most tested compiler. To build using GNU tools, type in the -source directory: - -./autogen.sh -make - -Currently, the source implements playback in pure C on all platforms -except ARM, where a [currently] small amount of assembly (see -asm_arm.h) is used to implement 64 bit math operations and fast LSP -computation. If building on ARM without the benefit of GNU build -system tools, be sure that '_ARM_ASSEM_' is #defined by the build -system if this assembly is desired, else the resulting library will -use whatever 64 bit math builtins the compiler implements. - -No math library is required by this source. No floating point -operations are used at any point in either setup or decode. This -decoder library will properly decode any past, current or future -Vorbis I file or stream. - - ******** - -The build system produces a static and [when supported by the OS] -dynamic library named 'libvorbisidec'. This library exposes an API -nearly identical to the BSD reference library's 'libvorbisfile', -including all the features familiar to users of vorbisfile. This API -is similar enough that the proper header file to include is named -'ivorbisfile.h' [included in the source build directory]. Lower level -libvorbis-style headers and structures are in 'ivorbiscodec.h' -[included in the source build directory]. A simple example program, -ivorbisfile_example.c, can be built with 'make example'. - - ******** - -Detailed Tremor API Documentation begins at doc/index.html - -Monty -xiph.org diff --git a/apps/codecs/libtremor/README.rockbox b/apps/codecs/libtremor/README.rockbox deleted file mode 100644 index a4e141f6b3..0000000000 --- a/apps/codecs/libtremor/README.rockbox +++ /dev/null @@ -1,17 +0,0 @@ -Library: Tremor-1.1.2 (Released 2002-05-17) -Imported: 2005-02-16 by Marcoen Hirschberg - -This directory contains a local version of Tremor for use by Rockbox -for software decoding of Ogg Vorbis files. - -LICENSING INFORMATION - -Tremor is distributed under Xiph.Org's BSD-like license - see the file COPYING -in this directory for details. - -IMPORT DETAILS - -The base version first imported into Rockbox was the SVN version of -Tremor-1.0.2 which was checked out on 2005-02-16. - -The autoconf/automake files were removed, as well as the doc and debian directories. diff --git a/apps/codecs/libtremor/SOURCES b/apps/codecs/libtremor/SOURCES deleted file mode 100644 index c622699599..0000000000 --- a/apps/codecs/libtremor/SOURCES +++ /dev/null @@ -1,16 +0,0 @@ -bitwise.c -block.c -codebook.c -floor0.c -floor1.c -framing.c -info.c -mapping0.c -registry.c -res012.c -sharedbook.c -synthesis.c -vorbisfile.c -window.c -ctype.c -oggmalloc.c diff --git a/apps/codecs/libtremor/asm_arm.h b/apps/codecs/libtremor/asm_arm.h deleted file mode 100644 index 42834a2581..0000000000 --- a/apps/codecs/libtremor/asm_arm.h +++ /dev/null @@ -1,190 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * - * * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * - * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * - * * - ******************************************************************** - - function: arm7 and later wide math functions - - ********************************************************************/ - -#ifdef _ARM_ASSEM_ -#if ARM_ARCH < 6 -#define INCL_OPTIMIZED_VECTOR_FMUL_WINDOW -static inline void ff_vector_fmul_window_c(ogg_int32_t *dst, const ogg_int32_t *src0, - const ogg_int32_t *src1, const ogg_int32_t *win, int len) -{ - /* len is always a power of 2 and always >= 16 so this is unrolled 2 times*/ - ogg_int32_t *dst0 = dst, *dst1 = dst + 2*len; - const ogg_int32_t *win0 = win, *win1 = win + 2*len; - src1 += len; - asm volatile ("cmp %[len], #0\n\t" - "b 1f\n\t" - "0:\n\t" - "ldr r0, [%[src0]], #4\n\t" - "ldr r1, [%[src1], #-4]!\n\t" - "ldr r2, [%[win0]], #4\n\t" - "ldr r3, [%[win1], #-4]!\n\t" - "smull r4, r5, r0, r2\n\t" - "smlal r4, r5, r1, r3\n\t" - "rsb r2, r2, #0\n\t" - "lsl r5, r5, #1\n\t" - "str r5, [%[dst1], #-4]!\n\t" - "smull r4, r5, r0, r3\n\t" - "smlal r4, r5, r1, r2\n\t" - "ldr r0, [%[src0]], #4\n\t" - "ldr r1, [%[src1], #-4]!\n\t" - "lsl r5, r5, #1\n\t" - "str r5, [%[dst0]], #4\n\t" - - "ldr r2, [%[win0]], #4\n\t" - "ldr r3, [%[win1], #-4]!\n\t" - "smull r4, r5, r0, r2\n\t" - "smlal r4, r5, r1, r3\n\t" - "rsb r2, r2, #0\n\t" - "lsl r5, r5, #1\n\t" - "str r5, [%[dst1], #-4]!\n\t" - "smull r4, r5, r0, r3\n\t" - "smlal r4, r5, r1, r2\n\t" - "subs %[len], %[len], #2\n\t" - "lsl r5, r5, #1\n\t" - "str r5, [%[dst0]], #4\n\t" - "1:\n\t" - "bgt 0b\n\t" - : [dst0] "+r" (dst0), [dst1] "+r" (dst1), - [src0] "+r" (src0), [src1] "+r" (src1), - [win0] "+r" (win0), [win1] "+r" (win1), - [len] "+r" (len) - :: "r0", "r1", "r2", "r3", "r4", "r5", "cc", "memory"); -} -#endif -#ifndef _V_LSP_MATH_ASM -#define _V_LSP_MATH_ASM - -static inline void lsp_loop_asm(ogg_uint32_t *qip,ogg_uint32_t *pip, - ogg_int32_t *qexpp, - ogg_int32_t *ilsp,ogg_int32_t wi, - ogg_int32_t m){ - - ogg_uint32_t qi=*qip,pi=*pip; - ogg_int32_t qexp=*qexpp; - - asm("mov r0,%3;" - "movs r1,%5,asr#1;" - "add r0,r0,r1,lsl#3;" - "beq 2f;\n" - "1:" - - "ldmdb r0!,{r1,r3};" - "subs r1,r1,%4;" //ilsp[j]-wi - "rsbmi r1,r1,#0;" //labs(ilsp[j]-wi) - "umull %0,r2,r1,%0;" //qi*=labs(ilsp[j]-wi) - - "subs r1,r3,%4;" //ilsp[j+1]-wi - "rsbmi r1,r1,#0;" //labs(ilsp[j+1]-wi) - "umull %1,r3,r1,%1;" //pi*=labs(ilsp[j+1]-wi) - - "cmn r2,r3;" // shift down 16? - "beq 0f;" - "add %2,%2,#16;" - "mov %0,%0,lsr #16;" - "orr %0,%0,r2,lsl #16;" - "mov %1,%1,lsr #16;" - "orr %1,%1,r3,lsl #16;" - "0:" - "cmp r0,%3;\n" - "bhi 1b;\n" - - "2:" - // odd filter assymetry - "ands r0,%5,#1;\n" - "beq 3f;\n" - "add r0,%3,%5,lsl#2;\n" - - "ldr r1,[r0,#-4];\n" - "mov r0,#0x4000;\n" - - "subs r1,r1,%4;\n" //ilsp[j]-wi - "rsbmi r1,r1,#0;\n" //labs(ilsp[j]-wi) - "umull %0,r2,r1,%0;\n" //qi*=labs(ilsp[j]-wi) - "umull %1,r3,r0,%1;\n" //pi*=labs(ilsp[j+1]-wi) - - "cmn r2,r3;\n" // shift down 16? - "beq 3f;\n" - "add %2,%2,#16;\n" - "mov %0,%0,lsr #16;\n" - "orr %0,%0,r2,lsl #16;\n" - "mov %1,%1,lsr #16;\n" - "orr %1,%1,r3,lsl #16;\n" - - //qi=(pi>>shift)*labs(ilsp[j]-wi); - //pi=(qi>>shift)*labs(ilsp[j+1]-wi); - //qexp+=shift; - - //} - - /* normalize to max 16 sig figs */ - "3:" - "mov r2,#0;" - "orr r1,%0,%1;" - "tst r1,#0xff000000;" - "addne r2,r2,#8;" - "movne r1,r1,lsr #8;" - "tst r1,#0x00f00000;" - "addne r2,r2,#4;" - "movne r1,r1,lsr #4;" - "tst r1,#0x000c0000;" - "addne r2,r2,#2;" - "movne r1,r1,lsr #2;" - "tst r1,#0x00020000;" - "addne r2,r2,#1;" - "movne r1,r1,lsr #1;" - "tst r1,#0x00010000;" - "addne r2,r2,#1;" - "mov %0,%0,lsr r2;" - "mov %1,%1,lsr r2;" - "add %2,%2,r2;" - - : "+r"(qi),"+r"(pi),"+r"(qexp) - : "r"(ilsp),"r"(wi),"r"(m) - : "r0","r1","r2","r3","cc"); - - *qip=qi; - *pip=pi; - *qexpp=qexp; -} - -static inline void lsp_norm_asm(ogg_uint32_t *qip,ogg_int32_t *qexpp){ - - ogg_uint32_t qi=*qip; - ogg_int32_t qexp=*qexpp; - - asm("tst %0,#0x0000ff00;" - "moveq %0,%0,lsl #8;" - "subeq %1,%1,#8;" - "tst %0,#0x0000f000;" - "moveq %0,%0,lsl #4;" - "subeq %1,%1,#4;" - "tst %0,#0x0000c000;" - "moveq %0,%0,lsl #2;" - "subeq %1,%1,#2;" - "tst %0,#0x00008000;" - "moveq %0,%0,lsl #1;" - "subeq %1,%1,#1;" - : "+r"(qi),"+r"(qexp) - : - : "cc"); - *qip=qi; - *qexpp=qexp; -} - -#endif -#endif - diff --git a/apps/codecs/libtremor/asm_mcf5249.h b/apps/codecs/libtremor/asm_mcf5249.h deleted file mode 100644 index 38aa117d84..0000000000 --- a/apps/codecs/libtremor/asm_mcf5249.h +++ /dev/null @@ -1,85 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * - * Copyright (C) 2005 by Pedro Vasconcelos - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ -/* asm routines for wide math on the MCF5249 */ - -#include "os_types.h" - -#if defined(CPU_COLDFIRE) - -#ifndef _V_WIDE_MATH -#define _V_WIDE_MATH - -#define INCL_OPTIMIZED_VECTOR_FMUL_WINDOW -static inline void ff_vector_fmul_window_c(ogg_int32_t *dst, const ogg_int32_t *src0, - const ogg_int32_t *src1, const ogg_int32_t *win, int len) -{ - /* len is always a power of 2 and always >= 16 so this is unrolled 4 times*/ - ogg_int32_t *dst0 = dst, *dst1 = dst + 2*len; - const ogg_int32_t *win0 = win, *win1 = win + 2*len; - src1 += len; - asm volatile ("move.l (%[src0])+, %%d0\n\t" - "move.l -(%[win1]), %%d3\n\t" - "tst.l %[len]\n\t" - "bra.s 1f\n\t" - "0:\n\t" - "mac.l %%d0, %%d3, (%[win0])+, %%d2, %%acc0\n\t" - "mac.l %%d0, %%d2, -(%[src1]), %%d1, %%acc1\n\t" - "msac.l %%d1, %%d2, (%[src0])+, %%d0, %%acc0\n\t" - "mac.l %%d1, %%d3, -(%[win1]), %%d3, %%acc1\n\t" - "mac.l %%d0, %%d3, (%[win0])+, %%d2, %%acc2\n\t" - "mac.l %%d0, %%d2, -(%[src1]), %%d1, %%acc3\n\t" - "msac.l %%d1, %%d2, (%[src0])+, %%d0, %%acc2\n\t" - "mac.l %%d1, %%d3, -(%[win1]), %%d3, %%acc3\n\t" - "movclr.l %%acc0, %%d1\n\t" - "movclr.l %%acc2, %%d2\n\t" - "subq.l #8, %[dst1]\n\t" - "movclr.l %%acc1, %%d5\n\t" - "movclr.l %%acc3, %%d4\n\t" - "movem.l %%d4-%%d5, (%[dst1])\n\t" - "mac.l %%d0, %%d3, (%[win0])+, %%d5, %%acc0\n\t" - "mac.l %%d0, %%d5, -(%[src1]), %%d4, %%acc1\n\t" - "msac.l %%d4, %%d5, (%[src0])+, %%d0, %%acc0\n\t" - "mac.l %%d4, %%d3, -(%[win1]), %%d3, %%acc1\n\t" - "mac.l %%d0, %%d3, (%[win0])+, %%d5, %%acc2\n\t" - "mac.l %%d0, %%d5, -(%[src1]), %%d4, %%acc3\n\t" - "msac.l %%d4, %%d5, (%[src0])+, %%d0, %%acc2\n\t" /* will read one past end of src0 */ - "mac.l %%d4, %%d3, -(%[win1]), %%d3, %%acc3\n\t" /* will read one into win0 */ - "movclr.l %%acc0, %%d4\n\t" - "movclr.l %%acc2, %%d5\n\t" - "movem.l %%d1-%%d2/%%d4-%%d5, (%[dst0])\n\t" - "lea (16, %[dst0]), %[dst0]\n\t" - "subq.l #8, %[dst1]\n\t" - "movclr.l %%acc1, %%d2\n\t" - "movclr.l %%acc3, %%d1\n\t" - "movem.l %%d1-%%d2, (%[dst1])\n\t" - "subq.l #4, %[len]\n\t" - "1:\n\t" - "bgt.s 0b\n\t" - : [dst0] "+a" (dst0), [dst1] "+a" (dst1), - [src0] "+a" (src0), [src1] "+a" (src1), - [win0] "+a" (win0), [win1] "+a" (win1), - [len] "+d" (len) - :: "d0", "d1", "d2", "d3", "d4", "d5", "cc", "memory" ); -} - -#define MB() - -#endif -#endif diff --git a/apps/codecs/libtremor/backends.h b/apps/codecs/libtremor/backends.h deleted file mode 100644 index e27f1f2b80..0000000000 --- a/apps/codecs/libtremor/backends.h +++ /dev/null @@ -1,133 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * - * * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * - * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * - * * - ******************************************************************** - - function: backend and mapping structures - - ********************************************************************/ - -/* this is exposed up here because we need it for static modes. - Lookups for each backend aren't exposed because there's no reason - to do so */ - -#ifndef _vorbis_backend_h_ -#define _vorbis_backend_h_ - -#include "codec_internal.h" - -/* this would all be simpler/shorter with templates, but.... */ -/* Transform backend generic *************************************/ - -/* only mdct right now. Flesh it out more if we ever transcend mdct - in the transform domain */ - -/* Floor backend generic *****************************************/ -typedef struct{ - vorbis_info_floor *(*unpack)(vorbis_info *,oggpack_buffer *); - vorbis_look_floor *(*look) (vorbis_dsp_state *,vorbis_info_mode *, - vorbis_info_floor *); - void (*free_info) (vorbis_info_floor *); - void (*free_look) (vorbis_look_floor *); - void *(*inverse1) (struct vorbis_block *,vorbis_look_floor *); - int (*inverse2) (struct vorbis_block *,vorbis_look_floor *, - void *buffer,ogg_int32_t *); -} vorbis_func_floor; - -typedef struct{ - int order; - long rate; - long barkmap; - - int ampbits; - int ampdB; - - int numbooks; /* <= 16 */ - int books[16]; - -} vorbis_info_floor0; - -#define VIF_POSIT 63 -#define VIF_CLASS 16 -#define VIF_PARTS 31 -typedef struct{ - int partitions; /* 0 to 31 */ - int partitionclass[VIF_PARTS]; /* 0 to 15 */ - - int class_dim[VIF_CLASS]; /* 1 to 8 */ - int class_subs[VIF_CLASS]; /* 0,1,2,3 (bits: 1< -#include -#include -#include "ogg.h" - -#define BUFFER_INCREMENT 256 - -const unsigned long mask[] ICONST_ATTR = -{0x00000000,0x00000001,0x00000003,0x00000007,0x0000000f, - 0x0000001f,0x0000003f,0x0000007f,0x000000ff,0x000001ff, - 0x000003ff,0x000007ff,0x00000fff,0x00001fff,0x00003fff, - 0x00007fff,0x0000ffff,0x0001ffff,0x0003ffff,0x0007ffff, - 0x000fffff,0x001fffff,0x003fffff,0x007fffff,0x00ffffff, - 0x01ffffff,0x03ffffff,0x07ffffff,0x0fffffff,0x1fffffff, - 0x3fffffff,0x7fffffff,0xffffffff }; - -#if 0 -static const unsigned int mask8B[]= -{0x00,0x80,0xc0,0xe0,0xf0,0xf8,0xfc,0xfe,0xff}; - -void oggpack_writeinit(oggpack_buffer *b){ - memset(b,0,sizeof(*b)); - b->ptr=b->buffer=_ogg_malloc(BUFFER_INCREMENT); - b->buffer[0]='\0'; - b->storage=BUFFER_INCREMENT; -} - -void oggpackB_writeinit(oggpack_buffer *b){ - oggpack_writeinit(b); -} - -int oggpack_writecheck(oggpack_buffer *b){ - if(!b->ptr || !b->storage)return -1; - return 0; -} - -int oggpackB_writecheck(oggpack_buffer *b){ - return oggpack_writecheck(b); -} - -void oggpack_writetrunc(oggpack_buffer *b,long bits){ - long bytes=bits>>3; - if(b->ptr){ - bits-=bytes*8; - b->ptr=b->buffer+bytes; - b->endbit=bits; - b->endbyte=bytes; - *b->ptr&=mask[bits]; - } -} - -void oggpackB_writetrunc(oggpack_buffer *b,long bits){ - long bytes=bits>>3; - if(b->ptr){ - bits-=bytes*8; - b->ptr=b->buffer+bytes; - b->endbit=bits; - b->endbyte=bytes; - *b->ptr&=mask8B[bits]; - } -} - -/* Takes only up to 32 bits. */ -void oggpack_write(oggpack_buffer *b,unsigned long value,int bits){ - if(bits<0 || bits>32) goto err; - if(b->endbyte>=b->storage-4){ - void *ret; - if(!b->ptr)return; - if(b->storage>LONG_MAX-BUFFER_INCREMENT) goto err; - ret=_ogg_realloc(b->buffer,b->storage+BUFFER_INCREMENT); - if(!ret) goto err; - b->buffer=ret; - b->storage+=BUFFER_INCREMENT; - b->ptr=b->buffer+b->endbyte; - } - - value&=mask[bits]; - bits+=b->endbit; - - b->ptr[0]|=value<endbit; - - if(bits>=8){ - b->ptr[1]=(unsigned char)(value>>(8-b->endbit)); - if(bits>=16){ - b->ptr[2]=(unsigned char)(value>>(16-b->endbit)); - if(bits>=24){ - b->ptr[3]=(unsigned char)(value>>(24-b->endbit)); - if(bits>=32){ - if(b->endbit) - b->ptr[4]=(unsigned char)(value>>(32-b->endbit)); - else - b->ptr[4]=0; - } - } - } - } - - b->endbyte+=bits/8; - b->ptr+=bits/8; - b->endbit=bits&7; - return; - err: - oggpack_writeclear(b); -} - -/* Takes only up to 32 bits. */ -void oggpackB_write(oggpack_buffer *b,unsigned long value,int bits){ - if(bits<0 || bits>32) goto err; - if(b->endbyte>=b->storage-4){ - void *ret; - if(!b->ptr)return; - if(b->storage>LONG_MAX-BUFFER_INCREMENT) goto err; - ret=_ogg_realloc(b->buffer,b->storage+BUFFER_INCREMENT); - if(!ret) goto err; - b->buffer=ret; - b->storage+=BUFFER_INCREMENT; - b->ptr=b->buffer+b->endbyte; - } - - value=(value&mask[bits])<<(32-bits); - bits+=b->endbit; - - b->ptr[0]|=value>>(24+b->endbit); - - if(bits>=8){ - b->ptr[1]=(unsigned char)(value>>(16+b->endbit)); - if(bits>=16){ - b->ptr[2]=(unsigned char)(value>>(8+b->endbit)); - if(bits>=24){ - b->ptr[3]=(unsigned char)(value>>(b->endbit)); - if(bits>=32){ - if(b->endbit) - b->ptr[4]=(unsigned char)(value<<(8-b->endbit)); - else - b->ptr[4]=0; - } - } - } - } - - b->endbyte+=bits/8; - b->ptr+=bits/8; - b->endbit=bits&7; - return; - err: - oggpack_writeclear(b); -} - -void oggpack_writealign(oggpack_buffer *b){ - int bits=8-b->endbit; - if(bits<8) - oggpack_write(b,0,bits); -} - -void oggpackB_writealign(oggpack_buffer *b){ - int bits=8-b->endbit; - if(bits<8) - oggpackB_write(b,0,bits); -} - -static void oggpack_writecopy_helper(oggpack_buffer *b, - void *source, - long bits, - void (*w)(oggpack_buffer *, - unsigned long, - int), - int msb){ - unsigned char *ptr=(unsigned char *)source; - - long bytes=bits/8; - bits-=bytes*8; - - if(b->endbit){ - int i; - /* unaligned copy. Do it the hard way. */ - for(i=0;iendbyte+bytes+1>=b->storage){ - void *ret; - if(!b->ptr) goto err; - if(b->endbyte+bytes+BUFFER_INCREMENT>b->storage) goto err; - b->storage=b->endbyte+bytes+BUFFER_INCREMENT; - ret=_ogg_realloc(b->buffer,b->storage); - if(!ret) goto err; - b->buffer=ret; - b->ptr=b->buffer+b->endbyte; - } - - memmove(b->ptr,source,bytes); - b->ptr+=bytes; - b->endbyte+=bytes; - *b->ptr=0; - - } - if(bits){ - if(msb) - w(b,(unsigned long)(ptr[bytes]>>(8-bits)),bits); - else - w(b,(unsigned long)(ptr[bytes]),bits); - } - return; - err: - oggpack_writeclear(b); -} - -void oggpack_writecopy(oggpack_buffer *b,void *source,long bits){ - oggpack_writecopy_helper(b,source,bits,oggpack_write,0); -} - -void oggpackB_writecopy(oggpack_buffer *b,void *source,long bits){ - oggpack_writecopy_helper(b,source,bits,oggpackB_write,1); -} - -void oggpack_reset(oggpack_buffer *b){ - if(!b->ptr)return; - b->ptr=b->buffer; - b->buffer[0]=0; - b->endbit=b->endbyte=0; -} - -void oggpackB_reset(oggpack_buffer *b){ - oggpack_reset(b); -} - -void oggpack_writeclear(oggpack_buffer *b){ - if(b->buffer)_ogg_free(b->buffer); - memset(b,0,sizeof(*b)); -} - -void oggpackB_writeclear(oggpack_buffer *b){ - oggpack_writeclear(b); -} -#endif -void oggpack_readinit(oggpack_buffer *b,unsigned char *buf,int bytes){ - memset(b,0,sizeof(*b)); - b->buffer=b->ptr=buf; - b->storage=bytes; -} -#if 0 -void oggpackB_readinit(oggpack_buffer *b,unsigned char *buf,int bytes){ - oggpack_readinit(b,buf,bytes); -} -#endif -/* Read in bits without advancing the bitptr; bits <= 32 */ -/* moved to ogg.h for inlining */ -#if 0 -long oggpack_look(oggpack_buffer *b,int bits){ - unsigned long ret; - unsigned long m; - - if(bits<0 || bits>32) return -1; - m=mask[bits]; - bits+=b->endbit; - - if(b->endbyte >= b->storage-4){ - /* not the main path */ - if(b->endbyte > b->storage-((bits+7)>>3)) return -1; - /* special case to avoid reading b->ptr[0], which might be past the end of - the buffer; also skips some useless accounting */ - else if(!bits)return(0L); - } - - ret=b->ptr[0]>>b->endbit; - if(bits>8){ - ret|=b->ptr[1]<<(8-b->endbit); - if(bits>16){ - ret|=b->ptr[2]<<(16-b->endbit); - if(bits>24){ - ret|=b->ptr[3]<<(24-b->endbit); - if(bits>32 && b->endbit) - ret|=b->ptr[4]<<(32-b->endbit); - } - } - } - return(m&ret); -} -#endif - -#if 0 -/* Read in bits without advancing the bitptr; bits <= 32 */ -long oggpackB_look(oggpack_buffer *b,int bits){ - unsigned long ret; - int m=32-bits; - - if(m<0 || m>32) return -1; - bits+=b->endbit; - - if(b->endbyte >= b->storage-4){ - /* not the main path */ - if(b->endbyte > b->storage-((bits+7)>>3)) return -1; - /* special case to avoid reading b->ptr[0], which might be past the end of - the buffer; also skips some useless accounting */ - else if(!bits)return(0L); - } - - ret=b->ptr[0]<<(24+b->endbit); - if(bits>8){ - ret|=b->ptr[1]<<(16+b->endbit); - if(bits>16){ - ret|=b->ptr[2]<<(8+b->endbit); - if(bits>24){ - ret|=b->ptr[3]<<(b->endbit); - if(bits>32 && b->endbit) - ret|=b->ptr[4]>>(8-b->endbit); - } - } - } - return ((ret&0xffffffff)>>(m>>1))>>((m+1)>>1); -} - -long oggpack_look1(oggpack_buffer *b){ - if(b->endbyte>=b->storage)return(-1); - return((b->ptr[0]>>b->endbit)&1); -} - -long oggpackB_look1(oggpack_buffer *b){ - if(b->endbyte>=b->storage)return(-1); - return((b->ptr[0]>>(7-b->endbit))&1); -} -#endif -/* moved to ogg.h for inlining -void oggpack_adv(oggpack_buffer *b,int bits){ - bits+=b->endbit; - - if(b->endbyte > b->storage-((bits+7)>>3)) goto overflow; - - b->ptr+=bits/8; - b->endbyte+=bits/8; - b->endbit=bits&7; - return; - - overflow: - b->ptr=NULL; - b->endbyte=b->storage; - b->endbit=1; -} -*/ -#if 0 -void oggpackB_adv(oggpack_buffer *b,int bits){ - oggpack_adv(b,bits); -} - -void oggpack_adv1(oggpack_buffer *b){ - if(++(b->endbit)>7){ - b->endbit=0; - b->ptr++; - b->endbyte++; - } -} - -void oggpackB_adv1(oggpack_buffer *b){ - oggpack_adv1(b); -} -#endif -/* bits <= 32 */ -long oggpack_read(oggpack_buffer *b,int bits) ICODE_ATTR_TREMOR_NOT_MDCT; -long oggpack_read(oggpack_buffer *b,int bits){ - long ret; - unsigned long m; - - if(bits<0 || bits>32) goto err; - m=mask[bits]; - bits+=b->endbit; - - if(b->endbyte >= b->storage-4){ - /* not the main path */ - if(b->endbyte > b->storage-((bits+7)>>3)) goto overflow; - /* special case to avoid reading b->ptr[0], which might be past the end of - the buffer; also skips some useless accounting */ - else if(!bits)return(0L); - } - - ret=b->ptr[0]>>b->endbit; - if(bits>8){ - ret|=b->ptr[1]<<(8-b->endbit); - if(bits>16){ - ret|=b->ptr[2]<<(16-b->endbit); - if(bits>24){ - ret|=b->ptr[3]<<(24-b->endbit); - if(bits>32 && b->endbit){ - ret|=b->ptr[4]<<(32-b->endbit); - } - } - } - } - ret&=m; - b->ptr+=bits/8; - b->endbyte+=bits/8; - b->endbit=bits&7; - return ret; - - overflow: - err: - b->ptr=NULL; - b->endbyte=b->storage; - b->endbit=1; - return -1L; -} -#if 0 -/* bits <= 32 */ -long oggpackB_read(oggpack_buffer *b,int bits){ - long ret; - long m=32-bits; - - if(m<0 || m>32) goto err; - bits+=b->endbit; - - if(b->endbyte+4>=b->storage){ - /* not the main path */ - if(b->endbyte > b->storage-((bits+7)>>3)) goto overflow; - /* special case to avoid reading b->ptr[0], which might be past the end of - the buffer; also skips some useless accounting */ - else if(!bits)return(0L); - } - - ret=b->ptr[0]<<(24+b->endbit); - if(bits>8){ - ret|=b->ptr[1]<<(16+b->endbit); - if(bits>16){ - ret|=b->ptr[2]<<(8+b->endbit); - if(bits>24){ - ret|=b->ptr[3]<<(b->endbit); - if(bits>32 && b->endbit) - ret|=b->ptr[4]>>(8-b->endbit); - } - } - } - ret=((ret&0xffffffffUL)>>(m>>1))>>((m+1)>>1); - - b->ptr+=bits/8; - b->endbyte+=bits/8; - b->endbit=bits&7; - return ret; - - overflow: - err: - b->ptr=NULL; - b->endbyte=b->storage; - b->endbit=1; - return -1L; -} - -long oggpack_read1(oggpack_buffer *b){ - long ret; - - if(b->endbyte >= b->storage) goto overflow; - ret=(b->ptr[0]>>b->endbit)&1; - - b->endbit++; - if(b->endbit>7){ - b->endbit=0; - b->ptr++; - b->endbyte++; - } - return ret; - - overflow: - b->ptr=NULL; - b->endbyte=b->storage; - b->endbit=1; - return -1L; -} - -long oggpackB_read1(oggpack_buffer *b){ - long ret; - - if(b->endbyte >= b->storage) goto overflow; - ret=(b->ptr[0]>>(7-b->endbit))&1; - - b->endbit++; - if(b->endbit>7){ - b->endbit=0; - b->ptr++; - b->endbyte++; - } - return ret; - - overflow: - b->ptr=NULL; - b->endbyte=b->storage; - b->endbit=1; - return -1L; -} -#endif -/* moved to ogg.h for inlining -long oggpack_bytes(oggpack_buffer *b){ - return(b->endbyte+(b->endbit+7)/8); -} -*/ -#if 0 -long oggpack_bits(oggpack_buffer *b){ - return(b->endbyte*8+b->endbit); -} - -long oggpackB_bytes(oggpack_buffer *b){ - return oggpack_bytes(b); -} - -long oggpackB_bits(oggpack_buffer *b){ - return oggpack_bits(b); -} - -unsigned char *oggpack_get_buffer(oggpack_buffer *b){ - return(b->buffer); -} - -unsigned char *oggpackB_get_buffer(oggpack_buffer *b){ - return oggpack_get_buffer(b); -} -#endif -/* Self test of the bitwise routines; everything else is based on - them, so they damned well better be solid. */ - -#ifdef _V_SELFTEST -#include - -static int ilog(unsigned int v){ - int ret=0; - while(v){ - ret++; - v>>=1; - } - return(ret); -} - -oggpack_buffer o; -oggpack_buffer r; - -void report(char *in){ - fprintf(stderr,"%s",in); - exit(1); -} - -void cliptest(unsigned long *b,int vals,int bits,int *comp,int compsize){ - long bytes,i; - unsigned char *buffer; - - oggpack_reset(&o); - for(i=0;i -#include -#include "ogg.h" -#include "ivorbiscodec.h" -#include "codec_internal.h" - -#include "window.h" -#include "registry.h" -#include "misc.h" -#include "ffmpeg_stuff.h" -//#include - -static int ilog(unsigned int v){ - int ret=0; - if(v)--v; - while(v){ - ret++; - v>>=1; - } - return(ret); -} - -static ogg_int32_t* _pcmbp[CHANNELS] IBSS_ATTR; -static ogg_int32_t* _pcmret[CHANNELS] IBSS_ATTR; -/* save original pointers returned by malloc so we can free it easily */ -static ogg_int32_t* malloc_pointers[3] = {NULL}; - -/* pcm accumulator examples (not exhaustive): - - <-------------- lW ----------------> - <--------------- W ----------------> -: .....|..... _______________ | -: .''' | '''_--- | |\ | -:.....''' |_____--- '''......| | \_______| -:.................|__________________|_______|__|______| - |<------ Sl ------>| > Sr < |endW - |beginSl |endSl | |endSr - |beginW |endlW |beginSr - - - |< lW >| - <--------------- W ----------------> - | | .. ______________ | - | | ' `/ | ---_ | - |___.'___/`. | ---_____| - |_______|__|_______|_________________| - | >|Sl|< |<------ Sr ----->|endW - | | |endSl |beginSr |endSr - |beginW | |endlW - mult[0] |beginSl mult[n] - - <-------------- lW -----------------> - |<--W-->| -: .............. ___ | | -: .''' |`/ \ | | -:.....''' |/`....\|...| -:.........................|___|___|___| - |Sl |Sr |endW - | | |endSr - | |beginSr - | |endSl - |beginSl - |beginW -*/ - -/* block abstraction setup *********************************************/ - -#ifndef WORD_ALIGN -#define WORD_ALIGN 8 -#endif - -int vorbis_block_init(vorbis_dsp_state *v, vorbis_block *vb){ - memset(vb,0,sizeof(*vb)); - vb->vd=v; - vb->localalloc=0; - vb->localstore=NULL; - - return(0); -} - -void *_vorbis_block_alloc(vorbis_block *vb,long bytes){ - bytes=(bytes+(WORD_ALIGN-1)) & ~(WORD_ALIGN-1); - if(bytes+vb->localtop>vb->localalloc){ - /* can't just _ogg_realloc... there are outstanding pointers */ - if(vb->localstore){ - struct alloc_chain *link=(struct alloc_chain *)_ogg_malloc(sizeof(*link)); - vb->totaluse+=vb->localtop; - link->next=vb->reap; - link->ptr=vb->localstore; - vb->reap=link; - } - /* highly conservative */ - vb->localalloc=bytes; - vb->localstore=_ogg_malloc(vb->localalloc); - vb->localtop=0; - } - { - void *ret=(void *)(((char *)vb->localstore)+vb->localtop); - vb->localtop+=bytes; - return ret; - } -} - -/* reap the chain, pull the ripcord */ -void _vorbis_block_ripcord(vorbis_block *vb){ - /* reap the chain */ - struct alloc_chain *reap=vb->reap; - while(reap){ - struct alloc_chain *next=reap->next; - _ogg_free(reap->ptr); - memset(reap,0,sizeof(*reap)); - _ogg_free(reap); - reap=next; - } - /* consolidate storage */ - if(vb->totaluse){ - vb->localstore=_ogg_realloc(vb->localstore,vb->totaluse+vb->localalloc); - vb->localalloc+=vb->totaluse; - vb->totaluse=0; - } - - /* pull the ripcord */ - vb->localtop=0; - vb->reap=NULL; -} - -int vorbis_block_clear(vorbis_block *vb){ - _vorbis_block_ripcord(vb); - if(vb->localstore)_ogg_free(vb->localstore); - - memset(vb,0,sizeof(*vb)); - return(0); -} - -static int _vds_init(vorbis_dsp_state *v,vorbis_info *vi){ - int i; - long b_size[2]; - - codec_setup_info *ci=(codec_setup_info *)vi->codec_setup; - private_state *b=NULL; - - if(ci==NULL) return 1; - - memset(v,0,sizeof(*v)); - b=(private_state *)(v->backend_state=_ogg_calloc(1,sizeof(*b))); - - v->vi=vi; - b->modebits=ilog(ci->modes); - -#ifdef TREMOR_USE_IRAM - /* allocate IRAM buffer for the PCM data generated by synthesis */ - iram_malloc_init(); - - v->floors = iram_malloc(vi->channels*ci->blocksizes[1]/2*sizeof(ogg_int32_t)); - v->residues[0] = iram_malloc(vi->channels*ci->blocksizes[1]/2*sizeof(ogg_int32_t)); - /* if we can get away with it, put a double buffer into IRAM too, so that - overlap-add runs iram-to-iram and we avoid needing to memcpy */ - v->residues[1] = iram_malloc(vi->channels*ci->blocksizes[1]/2*sizeof(ogg_int32_t)); - if (v->residues[1] == NULL) - v->saved = iram_malloc(vi->channels*ci->blocksizes[1]/4*sizeof(ogg_int32_t)); - -#endif - - if (v->residues[0] == NULL) { - malloc_pointers[0] = _ogg_malloc(vi->channels*ci->blocksizes[1]/2*sizeof(ogg_int32_t)); - v->residues[0] = malloc_pointers[0]; - } - - if (v->residues[1] == NULL && v->saved == NULL) { - malloc_pointers[1] = _ogg_malloc(vi->channels*ci->blocksizes[1]/2*sizeof(ogg_int32_t)); - v->residues[1] = malloc_pointers[1]; - } - - if (v->floors == NULL) { - malloc_pointers[2] = _ogg_malloc(vi->channels*ci->blocksizes[1]/2*sizeof(ogg_int32_t)); - v->floors = malloc_pointers[2]; - } - - /* needed for the first overlap/add */ - if (v->saved) { - memset(v->saved, 0, vi->channels*ci->blocksizes[1]/4*sizeof(ogg_int32_t)); - for (i = 0; i < vi->channels; i++) - v->saved_ptr[i] = v->saved + i*ci->blocksizes[1]/4; - } else { - memset(v->residues[1], 0, vi->channels*ci->blocksizes[1]/2*sizeof(ogg_int32_t)); - for (i = 0; i < vi->channels; i++) - v->saved_ptr[i] = v->residues[1] + i*ci->blocksizes[1]/2; - } - - /* Vorbis I uses only window type 0 */ - b_size[0]=ci->blocksizes[0]/2; - b_size[1]=ci->blocksizes[1]/2; - b->window[0]=_vorbis_window(0,b_size[0]); - b->window[1]=_vorbis_window(0,b_size[1]); - -#ifdef TREMOR_USE_IRAM - /* allocate IRAM buffer for window tables too, if sufficient iram available */ - /* give preference to the larger window over the smaller window - (on the assumption that both windows are equally likely used) */ - LOOKUP_TNC *iramposw; - for(i=1; i>=0; i--){ - iramposw=iram_malloc(b_size[i]*sizeof(LOOKUP_TNC)); - if(iramposw!=NULL) { - memcpy(iramposw, b->window[i], b_size[i]*sizeof(LOOKUP_TNC)); - b->window[i]=iramposw; - } - } -#endif - - /* finish the codebooks */ - if(!ci->fullbooks){ - ci->fullbooks=(codebook *)_ogg_calloc(ci->books,sizeof(*ci->fullbooks)); - for(i=0;ibooks;i++){ - if(ci->book_param[i]==NULL) - goto abort_books; - if(vorbis_book_init_decode(ci->fullbooks+i,ci->book_param[i])) - goto abort_books; - /* decode codebooks are now standalone after init */ - vorbis_staticbook_destroy(ci->book_param[i]); - ci->book_param[i]=NULL; - } - } - - v->pcm_storage=ci->blocksizes[1]; - v->pcmret=_pcmret; - v->pcmb=_pcmbp; - - _pcmbp[0]=NULL; - _pcmbp[1]=NULL; - - /* all 1 (large block) or 0 (small block) */ - /* explicitly set for the sake of clarity */ - v->lW=0; /* previous window size */ - v->W=0; /* current window size */ - - /* initialize all the mapping/backend lookups */ - b->mode=(vorbis_look_mapping **)_ogg_calloc(ci->modes,sizeof(*b->mode)); - for(i=0;imodes;i++){ - int mapnum=ci->mode_param[i]->mapping; - int maptype=ci->map_type[mapnum]; - b->mode[i]=_mapping_P[maptype]->look(v,ci->mode_param[i], - ci->map_param[mapnum]); - } - - return(0); -abort_books: - for(i=0;ibooks;i++){ - if(ci->book_param[i]!=NULL){ - vorbis_staticbook_destroy(ci->book_param[i]); - ci->book_param[i]=NULL; - } - } - vorbis_dsp_clear(v); - return -1; -} - -int vorbis_synthesis_restart(vorbis_dsp_state *v){ - vorbis_info *vi=v->vi; - codec_setup_info *ci; - - if(!v->backend_state)return -1; - if(!vi)return -1; - ci=vi->codec_setup; - if(!ci)return -1; - - v->pcm_current=0; - - v->pcm_returned=-1; - v->granulepos=-1; - v->sequence=-1; - ((private_state *)(v->backend_state))->sample_count=-1; - - return(0); -} - -int vorbis_synthesis_init(vorbis_dsp_state *v,vorbis_info *vi){ - if(_vds_init(v,vi))return 1; - vorbis_synthesis_restart(v); - - return 0; -} - -void vorbis_dsp_clear(vorbis_dsp_state *v){ - int i; - if(v){ - vorbis_info *vi=v->vi; - codec_setup_info *ci=(codec_setup_info *)(vi?vi->codec_setup:NULL); - private_state *b=(private_state *)v->backend_state; - - if(vi != NULL) - { - /* pcm buffer came from oggmalloc rather than iram */ - for(i=0;i<3;i++) - if(malloc_pointers[i]) { - _ogg_free(malloc_pointers[i]); - malloc_pointers[i] = NULL; - } - } - - /* free mode lookups; these are actually vorbis_look_mapping structs */ - if(ci){ - for(i=0;imodes;i++){ - int mapnum=ci->mode_param[i]->mapping; - int maptype=ci->map_type[mapnum]; - if(b && b->mode)_mapping_P[maptype]->free_look(b->mode[i]); - } - } - - if(b){ - if(b->mode)_ogg_free(b->mode); - _ogg_free(b); - } - - memset(v,0,sizeof(*v)); - } -} - -/* Unlike in analysis, the window is only partially applied for each - block. The time domain envelope is not yet handled at the point of - calling (as it relies on the previous block). */ - -int vorbis_synthesis_blockin(vorbis_dsp_state *v,vorbis_block *vb) - ICODE_ATTR; -int vorbis_synthesis_blockin(vorbis_dsp_state *v,vorbis_block *vb){ - vorbis_info *vi=v->vi; - codec_setup_info *ci=(codec_setup_info *)vi->codec_setup; - private_state *b=v->backend_state; - - if(v->pcm_current>v->pcm_returned && v->pcm_returned!=-1)return(OV_EINVAL); - - v->lW=v->W; - v->W=vb->W; - v->nW=-1; - - if((v->sequence==-1)|| - (v->sequence+1 != vb->sequence)){ - v->granulepos=-1; /* out of sequence; lose count */ - b->sample_count=-1; - } - - v->sequence=vb->sequence; - int n=ci->blocksizes[v->W]/2; - int ln=ci->blocksizes[v->lW]/2; - - if(LIKELY(vb->pcmend != 0)){ /* no pcm to process if vorbis_synthesis_trackonly - was called on block */ - window_overlap_add(ci->blocksizes[v->W], ci->blocksizes[v->lW], - ci->blocksizes[0], ci->blocksizes[1], vi->channels, - b->window[v->W & v->lW], v); - /* deal with initial packet state; we do this using the explicit - pcm_returned==-1 flag otherwise we're sensitive to first block - being short or long */ - - if(v->pcm_returned==-1){ - v->pcm_returned=0; - v->pcm_current=0; - }else{ - v->pcm_returned=0; - v->pcm_current=(n+ln)/2; - } - } - - /* track the frame number... This is for convenience, but also - making sure our last packet doesn't end with added padding. If - the last packet is partial, the number of samples we'll have to - return will be past the vb->granulepos. - - This is not foolproof! It will be confused if we begin - decoding at the last page after a seek or hole. In that case, - we don't have a starting point to judge where the last frame - is. For this reason, vorbisfile will always try to make sure - it reads the last two marked pages in proper sequence */ - - if(b->sample_count==-1){ - b->sample_count=0; - }else{ - b->sample_count+=(n+ln)/2; - } - - if(v->granulepos==-1){ - if(vb->granulepos!=-1){ /* only set if we have a position to set to */ - - v->granulepos=vb->granulepos; - - /* is this a short page? */ - if(b->sample_count>v->granulepos){ - /* corner case; if this is both the first and last audio page, - then spec says the end is cut, not beginning */ - if(vb->eofflag){ - /* trim the end */ - /* no preceeding granulepos; assume we started at zero (we'd - have to in a short single-page stream) */ - /* granulepos could be -1 due to a seek, but that would result - in a long coun`t, not short count */ - - v->pcm_current-=(b->sample_count-v->granulepos); - }else{ - /* trim the beginning */ - v->pcm_returned+=(b->sample_count-v->granulepos); - if(v->pcm_returned>v->pcm_current) - v->pcm_returned=v->pcm_current; - } - - } - - } - }else{ - v->granulepos+=(n+ln)/2; - if(vb->granulepos!=-1 && v->granulepos!=vb->granulepos){ - - if(v->granulepos>vb->granulepos){ - long extra=v->granulepos-vb->granulepos; - - if(extra) - if(vb->eofflag){ - /* partial last frame. Strip the extra samples off */ - v->pcm_current-=extra; - } /* else {Shouldn't happen *unless* the bitstream is out of - spec. Either way, believe the bitstream } */ - } /* else {Shouldn't happen *unless* the bitstream is out of - spec. Either way, believe the bitstream } */ - v->granulepos=vb->granulepos; - } - } - - /* Update, cleanup */ - - if(vb->eofflag)v->eofflag=1; - return(0); -} - -/* pcm==NULL indicates we just want the pending samples, no more */ -int vorbis_synthesis_pcmout(vorbis_dsp_state *v,ogg_int32_t ***pcm) ICODE_ATTR; -int vorbis_synthesis_pcmout(vorbis_dsp_state *v,ogg_int32_t ***pcm){ - vorbis_info *vi=v->vi; - if(v->pcm_returned>-1 && v->pcm_returnedpcm_current){ - if(pcm){ - int i; - for(i=0;ichannels;i++) - v->pcmret[i]=v->pcmb[i]+v->pcm_returned; - *pcm=v->pcmret; - } - return(v->pcm_current-v->pcm_returned); - } - return 0; -} - -int vorbis_synthesis_read(vorbis_dsp_state *v,int bytes){ - if(bytes && v->pcm_returned+bytes>v->pcm_current)return(OV_EINVAL); - v->pcm_returned+=bytes; - return(0); -} - diff --git a/apps/codecs/libtremor/codebook.c b/apps/codecs/libtremor/codebook.c deleted file mode 100644 index 7087f0a323..0000000000 --- a/apps/codecs/libtremor/codebook.c +++ /dev/null @@ -1,587 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * - * * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * - * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * - * * - ******************************************************************** - - function: basic codebook pack/unpack/code/decode operations - - ********************************************************************/ - -#include "config-tremor.h" -#include -#include -#include "ogg.h" -#include "ivorbiscodec.h" -#include "codebook.h" -#include "misc.h" -#include "os.h" - -/* unpacks a codebook from the packet buffer into the codebook struct, - readies the codebook auxiliary structures for decode *************/ -static_codebook *vorbis_staticbook_unpack(oggpack_buffer *opb){ - long i,j; - static_codebook *s=_ogg_calloc(1,sizeof(*s)); - - /* make sure alignment is correct */ - if(oggpack_read(opb,24)!=0x564342)goto _eofout; - - /* first the basic parameters */ - s->dim=oggpack_read(opb,16); - s->entries=oggpack_read(opb,24); - if(s->entries==-1)goto _eofout; - - if(_ilog(s->dim)+_ilog(s->entries)>24)goto _eofout; - - /* codeword ordering.... length ordered or unordered? */ - switch((int)oggpack_read(opb,1)){ - case 0:{ - long unused; - /* allocated but unused entries? */ - unused=oggpack_read(opb,1); - if((s->entries*(unused?1:5)+7)>>3>opb->storage-oggpack_bytes(opb)) - goto _eofout; - /* unordered */ - s->lengthlist=(long *)_ogg_malloc(sizeof(*s->lengthlist)*s->entries); - - /* allocated but unused entries? */ - if(unused){ - /* yes, unused entries */ - - for(i=0;ientries;i++){ - if(oggpack_read(opb,1)){ - long num=oggpack_read(opb,5); - if(num==-1)goto _eofout; - s->lengthlist[i]=num+1; - }else - s->lengthlist[i]=0; - } - }else{ - /* all entries used; no tagging */ - for(i=0;ientries;i++){ - long num=oggpack_read(opb,5); - if(num==-1)goto _eofout; - s->lengthlist[i]=num+1; - } - } - - break; - } - case 1: - /* ordered */ - { - long length=oggpack_read(opb,5)+1; - if(length==0)goto _eofout; - s->lengthlist=(long *)_ogg_malloc(sizeof(*s->lengthlist)*s->entries); - - for(i=0;ientries;){ - long num=oggpack_read(opb,_ilog(s->entries-i)); - if(num==-1)goto _eofout; - if(length>32 || num>s->entries-i || - (num>0 && (num-1)>>(length>>1)>>((length+1)>>1))>0){ - goto _errout; - } - for(j=0;jlengthlist[i]=length; - length++; - } - } - break; - default: - /* EOF */ - goto _eofout; - } - - /* Do we have a mapping to unpack? */ - switch((s->maptype=oggpack_read(opb,4))){ - case 0: - /* no mapping */ - break; - case 1: case 2: - /* implicitly populated value mapping */ - /* explicitly populated value mapping */ - - s->q_min=oggpack_read(opb,32); - s->q_delta=oggpack_read(opb,32); - s->q_quant=oggpack_read(opb,4)+1; - s->q_sequencep=oggpack_read(opb,1); - if(s->q_sequencep==-1)goto _eofout; - - { - int quantvals=0; - switch(s->maptype){ - case 1: - quantvals=(s->dim==0?0:_book_maptype1_quantvals(s)); - break; - case 2: - quantvals=s->entries*s->dim; - break; - } - - /* quantized values */ - if((quantvals*s->q_quant+7)>>3>opb->storage-oggpack_bytes(opb)) - goto _eofout; - s->quantlist=(long *)_ogg_malloc(sizeof(*s->quantlist)*quantvals); - for(i=0;iquantlist[i]=oggpack_read(opb,s->q_quant); - - if(quantvals&&s->quantlist[quantvals-1]==-1)goto _eofout; - } - break; - default: - goto _errout; - } - - /* all set */ - return(s); - - _errout: - _eofout: - vorbis_staticbook_destroy(s); - return(NULL); -} - -/* the 'eliminate the decode tree' optimization actually requires the - codewords to be MSb first, not LSb. This is an annoying inelegancy - (and one of the first places where carefully thought out design - turned out to be wrong; Vorbis II and future Ogg codecs should go - to an MSb bitpacker), but not actually the huge hit it appears to - be. The first-stage decode table catches most words so that - bitreverse is not in the main execution path. */ - -static inline ogg_uint32_t bitreverse(register ogg_uint32_t x) -{ - unsigned tmp, ret; -#ifdef _ARM_ASSEM_ -#if ARM_ARCH >= 6 - unsigned mask = 0x0f0f0f0f; -#else - unsigned mask = 0x00ff00ff; -#endif - asm ( -#if ARM_ARCH >= 6 - "rev %[r], %[x] \n" /* swap halfwords and bytes */ - "and %[t], %[m], %[r] \n" /* Sequence is one instruction */ - "eor %[r], %[t], %[r] \n" /* longer than on <= ARMv5, but */ - "mov %[t], %[t], lsl #4 \n" /* interlock free */ - "orr %[r], %[t], %[r], lsr #4\n" /* nibbles swapped */ - "eor %[m], %[m], %[m], lsl #2\n" /* mask = 0x33333333 */ - "and %[t], %[m], %[r] \n" - "eor %[r], %[t], %[r] \n" - "mov %[t], %[t], lsl #2 \n" - "orr %[r], %[t], %[r], lsr #2\n" /* dibits swapped */ - "eor %[m], %[m], %[m], lsl #1\n" /* mask = 0x55555555 */ - "and %[t], %[m], %[r] \n" - "eor %[r], %[t], %[r] \n" - "mov %[t], %[t], lsl #1 \n" - "orr %[r], %[t], %[r], lsr #1\n" /* bits swapped */ -#else /* ARM_ARCH <= 5 */ - "mov %[r], %[x], ror #16 \n" /* swap halfwords */ - "and %[t], %[m], %[r], lsr #8\n" - "eor %[r], %[r], %[t], lsl #8\n" - "orr %[r], %[t], %[r], lsl #8\n" /* bytes swapped */ - "eor %[m], %[m], %[m], lsl #4\n" /* mask = 0x0f0f0f0f */ - "and %[t], %[m], %[r], lsr #4\n" - "eor %[r], %[r], %[t], lsl #4\n" - "orr %[r], %[t], %[r], lsl #4\n" /* nibbles swapped */ - "eor %[m], %[m], %[m], lsl #2\n" /* mask = 0x33333333 */ - "and %[t], %[m], %[r], lsr #2\n" - "eor %[r], %[r], %[t], lsl #2\n" - "orr %[r], %[t], %[r], lsl #2\n" /* dibits swapped */ - "eor %[m], %[m], %[m], lsl #1\n" /* mask = 0x55555555 */ - "and %[t], %[m], %[r], lsr #1\n" - "eor %[r], %[r], %[t], lsl #1\n" - "orr %[r], %[t], %[r], lsl #1\n" /* bits swapped */ -#endif /* ARM_ARCH */ - : /* outputs */ - [m]"+r"(mask), - [r]"=r"(ret), - [t]"=r"(tmp) - : /* inputs */ - [x]"r"(x) - ); -#else /* !_ARM_ASSEM_ */ - - ret = (x>>16) | (x<<16); - tmp = ret & 0x00ff00ff; - ret ^= tmp; - ret = (ret >> 8) | (tmp << 8); /* bytes swapped */ - tmp = ret & 0x0f0f0f0f; - ret ^= tmp; - ret = (ret >> 4) | (tmp << 4); /* 4-bit units swapped */ - tmp = ret & 0x33333333; - ret ^= tmp; - ret = (ret >> 2) | (tmp << 2); /* 2-bit units swapped */ - tmp = ret & 0x55555555; - ret ^= tmp; - ret = (ret >> 1) | (tmp << 1); /* done */ -#endif /* !_ARM_ASSEM_ */ - return ret; -} - -static inline long bisect_codelist(long lo, long hi, ogg_uint32_t cache, - const ogg_uint32_t *codelist) -{ - ogg_uint32_t testword=bitreverse(cache); - long p; - while(LIKELY(p = (hi-lo) >> 1) > 0){ - if(codelist[lo+p] > testword) - hi -= p; - else - lo += p; - } - return lo; -} - -STIN long decode_packed_entry_number(codebook *book, - oggpack_buffer *b){ - int read=book->dec_maxlength; - long lo,hi; - long lok = oggpack_look(b,book->dec_firsttablen); - - if (LIKELY(lok >= 0)) { - ogg_int32_t entry = book->dec_firsttable[lok]; - if(UNLIKELY(entry < 0)){ - lo=(entry>>15)&0x7fff; - hi=book->used_entries-(entry&0x7fff); - }else{ - oggpack_adv(b, book->dec_codelengths[entry-1]); - return(entry-1); - } - }else{ - lo=0; - hi=book->used_entries; - } - - lok = oggpack_look(b, read); - - while(lok<0 && read>1) - lok = oggpack_look(b, --read); - - if(lok<0){ - oggpack_adv(b,1); /* force eop */ - return -1; - } - - /* bisect search for the codeword in the ordered list */ - { - lo = bisect_codelist(lo, hi, lok, book->codelist); - - if(book->dec_codelengths[lo]<=read){ - oggpack_adv(b, book->dec_codelengths[lo]); - return(lo); - } - } - - oggpack_adv(b, read+1); - return(-1); -} - -static long decode_packed_block(codebook *book, oggpack_buffer *b, - long *buf, int n){ - long *bufptr = buf; - long *bufend = buf + n; - - while (bufptrendbyte < b->storage - 8) { - ogg_uint32_t *ptr; - unsigned long bit, bitend; - unsigned long adr; - ogg_uint32_t cache = 0; - int cachesize = 0; - const unsigned int cachemask = (1<dec_firsttablen)-1; - const int book_dec_maxlength = book->dec_maxlength; - const ogg_uint32_t *book_dec_firsttable = book->dec_firsttable; - const long book_used_entries = book->used_entries; - const ogg_uint32_t *book_codelist = book->codelist; - const char *book_dec_codelengths = book->dec_codelengths; - - adr = (unsigned long)b->ptr; - bit = (adr&3)*8+b->endbit; - ptr = (ogg_uint32_t*)(adr&~3); - bitend = ((adr&3)+(b->storage-b->endbyte))*8; - while (bufptr=bitend) - break; - bit-=cachesize; - cache = letoh32(ptr[bit>>5]); - if (bit&31) { - cache >>= (bit&31); - cache |= letoh32(ptr[(bit>>5)+1]) << (32-(bit&31)); - } - cachesize=32; - bit+=32; - } - - ogg_int32_t entry = book_dec_firsttable[cache&cachemask]; - if(UNLIKELY(entry < 0)){ - const long lo = (entry>>15)&0x7fff, hi = book_used_entries-(entry&0x7fff); - entry = bisect_codelist(lo, hi, cache, book_codelist); - }else - entry--; - - *bufptr++ = entry; - int l = book_dec_codelengths[entry]; - cachesize -= l; - cache >>= l; - } - - adr=(unsigned long)b->ptr; - bit-=(adr&3)*8+cachesize; - b->endbyte+=bit/8; - b->ptr+=bit/8; - b->endbit=bit&7; - } else { - long r = decode_packed_entry_number(book, b); - if (r == -1) return bufptr-buf; - *bufptr++ = r; - } - } - return n; -} - -/* Decode side is specced and easier, because we don't need to find - matches using different criteria; we simply read and map. There are - two things we need to do 'depending': - - We may need to support interleave. We don't really, but it's - convenient to do it here rather than rebuild the vector later. - - Cascades may be additive or multiplicitive; this is not inherent in - the codebook, but set in the code using the codebook. Like - interleaving, it's easiest to do it here. - addmul==0 -> declarative (set the value) - addmul==1 -> additive - addmul==2 -> multiplicitive */ - -/* returns the [original, not compacted] entry number or -1 on eof *********/ -long vorbis_book_decode(codebook *book, oggpack_buffer *b){ - if(book->used_entries>0){ - long packed_entry=decode_packed_entry_number(book,b); - if(packed_entry>=0) - return(book->dec_index[packed_entry]); - } - - /* if there's no dec_index, the codebook unpacking isn't collapsed */ - return(-1); -} - -/* returns 0 on OK or -1 on eof *************************************/ -/* decode vector / dim granularity gaurding is done in the upper layer */ -long vorbis_book_decodevs_add(codebook *book,ogg_int32_t *a, - oggpack_buffer *b,int n,int point){ - if(book->used_entries>0){ - int step=n/book->dim; - long *entry = (long *)alloca(sizeof(*entry)*step); - ogg_int32_t **t = (ogg_int32_t **)alloca(sizeof(*t)*step); - int i,j,o; - int shift=point-book->binarypoint; - - if(shift>=0){ - for (i = 0; i < step; i++) { - entry[i]=decode_packed_entry_number(book,b); - if(entry[i]==-1)return(-1); - t[i] = book->valuelist+entry[i]*book->dim; - } - for(i=0,o=0;idim;i++,o+=step) - for (j=0;j>shift; - }else{ - for (i = 0; i < step; i++) { - entry[i]=decode_packed_entry_number(book,b); - if(entry[i]==-1)return(-1); - t[i] = book->valuelist+entry[i]*book->dim; - } - for(i=0,o=0;idim;i++,o+=step) - for (j=0;jused_entries>0){ - int i,j,entry; - ogg_int32_t *t; - int shift=point-book->binarypoint; - - if(shift>=0){ - for(i=0;ivaluelist+entry*book->dim; - for (j=0;jdim;) - a[i++]+=t[j++]>>shift; - } - }else{ - shift = -shift; - for(i=0;ivaluelist+entry*book->dim; - for (j=0;jdim;) - a[i++]+=t[j++]< internally rather than in the upper layer (called only by - floor0) */ -long vorbis_book_decodev_set(codebook *book,ogg_int32_t *a, - oggpack_buffer *b,int n,int point){ - if(book->used_entries>0){ - int i,j,entry; - ogg_int32_t *t; - int shift=point-book->binarypoint; - - if(shift>=0){ - - for(i=0;ivaluelist+entry*book->dim; - for (j=0;idim;){ - a[i++]=t[j++]>>shift; - } - } - }else{ - shift = -shift; - for(i=0;ivaluelist+entry*book->dim; - for (j=0;idim;){ - a[i++]=t[j++]<binarypoint; - long entries[32]; - ogg_int32_t *p0 = &(a[0][offset]); - ogg_int32_t *p1 = &(a[1][offset]); - const unsigned long dim = book->dim; - const ogg_int32_t * const vlist = book->valuelist; - - if(shift>=0){ - while(n>0){ - chunk=32; - if (16*dim>n) - chunk=(n*2-1)/dim + 1; - read = decode_packed_block(book,b,entries,chunk); - for(k=0;k>shift; - *p1++ += *t++>>shift; - }while(t0){ - chunk=32; - if (16*dim>n) - chunk=(n*2-1)/dim + 1; - read = decode_packed_block(book,b,entries,chunk); - for(k=0;kused_entries>0)){ - long i,j,k,chunk,read; - int chptr=0; - int shift=point-book->binarypoint; - long entries[32]; - - if (!(book->dim&1) && ch==2) - return vorbis_book_decodevv_add_2ch_even(book,a,offset,b,n,point); - - if(shift>=0){ - - for(i=offset;idim>(offset+n-i)*ch) - chunk=((offset+n-i)*ch+book->dim-1)/book->dim; - read = decode_packed_block(book,b,entries,chunk); - for(k=0;kvaluelist+entries[k]*book->dim; - for (j=0;jdim;j++){ - a[chptr++][i]+=t[j]>>shift; - if(chptr==ch){ - chptr=0; - i++; - } - } - } - if (readdim>(offset+n-i)*ch) - chunk=((offset+n-i)*ch+book->dim-1)/book->dim; - read = decode_packed_block(book,b,entries,chunk); - for(k=0;kvaluelist+entries[k]*book->dim; - for (j=0;jdim;j++){ - a[chptr++][i]+=t[j]<value mapping to be done. - - If encode-side mapping must be done (and thus the entry needs to be - hunted), the auxiliary encode pointer will point to a decision - tree. This is true of both VQ and huffman, but is mostly useful - with VQ. - -*/ - -typedef struct static_codebook{ - long dim; /* codebook dimensions (elements per vector) */ - long entries; /* codebook entries */ - long *lengthlist; /* codeword lengths in bits */ - - /* mapping ***************************************************************/ - int maptype; /* 0=none - 1=implicitly populated values from map column - 2=listed arbitrary values */ - - /* The below does a linear, single monotonic sequence mapping. */ - long q_min; /* packed 32 bit float; quant value 0 maps to minval */ - long q_delta; /* packed 32 bit float; val 1 - val 0 == delta */ - int q_quant; /* bits: 0 < quant <= 16 */ - int q_sequencep; /* bitflag */ - - long *quantlist; /* map == 1: (int)(entries^(1/dim)) element column map - map == 2: list of dim*entries quantized entry vals - */ -} static_codebook; - -typedef struct codebook{ - long dim; /* codebook dimensions (elements per vector) */ - long entries; /* codebook entries */ - long used_entries; /* populated codebook entries */ - - /* the below are ordered by bitreversed codeword and only used - entries are populated */ - int binarypoint; - ogg_int32_t *valuelist; /* list of dim*entries actual entry values */ - ogg_uint32_t *codelist; /* list of bitstream codewords for each entry */ - - int *dec_index; - char *dec_codelengths; - ogg_uint32_t *dec_firsttable; - int dec_firsttablen; - int dec_maxlength; - - long q_min; /* packed 32 bit float; quant value 0 maps to minval */ - long q_delta; /* packed 32 bit float; val 1 - val 0 == delta */ - -} codebook; - -extern void vorbis_staticbook_destroy(static_codebook *b); -extern int vorbis_book_init_decode(codebook *dest,const static_codebook *source); - -extern void vorbis_book_clear(codebook *b); -extern long _book_maptype1_quantvals(const static_codebook *b); - -extern static_codebook *vorbis_staticbook_unpack(oggpack_buffer *b); - -extern long vorbis_book_decode(codebook *book, oggpack_buffer *b); -extern long vorbis_book_decodevs_add(codebook *book, ogg_int32_t *a, - oggpack_buffer *b,int n,int point); -extern long vorbis_book_decodev_set(codebook *book, ogg_int32_t *a, - oggpack_buffer *b,int n,int point); -extern long vorbis_book_decodev_add(codebook *book, ogg_int32_t *a, - oggpack_buffer *b,int n,int point); -extern long vorbis_book_decodevv_add(codebook *book, ogg_int32_t **a, - long off,int ch, - oggpack_buffer *b,int n,int point); - -extern int _ilog(unsigned int v); - - -#endif diff --git a/apps/codecs/libtremor/codec_internal.h b/apps/codecs/libtremor/codec_internal.h deleted file mode 100644 index 3cbd7cde89..0000000000 --- a/apps/codecs/libtremor/codec_internal.h +++ /dev/null @@ -1,93 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * - * * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * - * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * - * * - ******************************************************************** - - function: libvorbis codec headers - - ********************************************************************/ - -#ifndef _V_CODECI_H_ -#define _V_CODECI_H_ - -#include "codebook.h" - -typedef void vorbis_look_mapping; -typedef void vorbis_look_floor; -typedef void vorbis_look_residue; -typedef void vorbis_look_transform; - -/* mode ************************************************************/ -typedef struct { - int blockflag; - int windowtype; - int transformtype; - int mapping; -} vorbis_info_mode; - -typedef void vorbis_info_floor; -typedef void vorbis_info_residue; -typedef void vorbis_info_mapping; - -typedef struct private_state { - /* local lookup storage */ - const void *window[2]; - - /* backend lookups are tied to the mode, not the backend or naked mapping */ - int modebits; - vorbis_look_mapping **mode; - - ogg_int64_t sample_count; - -} private_state; - -/* codec_setup_info contains all the setup information specific to the - specific compression/decompression mode in progress (eg, - psychoacoustic settings, channel setup, options, codebook - etc). -*********************************************************************/ - -typedef struct codec_setup_info { - - /* Vorbis supports only short and long blocks, but allows the - encoder to choose the sizes */ - - int blocksizes_nbits[2]; - long blocksizes[2]; /* = 1<= 0) { - err += ady - adx; - y += sy; - buf[x] = MULT31_SHIFT15(buf[x],lookup[y]); - x++; - } - buf[x] = MULT31_SHIFT15(buf[x],lookup[y]); - } - if (x <= 0) { - if (err + ady >= 0) - y += sy; - buf[x] = MULT31_SHIFT15(buf[x],lookup[y]); - } -} - -static inline void render_line(int x0, int y0, int x1, int y1, - const ogg_int32_t *lookup, ogg_int32_t *buf) -{ - int dy = y1 - y0; - int adx = x1 - x0; - int ady = abs(dy); - int sy = dy < 0 ? -1 : 1; - buf[x0] = MULT31_SHIFT15(buf[x0],lookup[y0]); - if (ady*2 <= adx) { // optimized common case - render_line_unrolled(x0, y0, x1, sy, ady, adx, lookup, buf); - } else { - int base = dy / adx; - int x = x0; - int y = y0; - int err = -adx; - ady -= abs(base) * adx; - while (++x < x1) { - y += base; - err += ady; - if (err >= 0) { - err -= adx; - y += sy; - } - buf[x] = MULT31_SHIFT15(buf[x],lookup[y]); - } - } -} - -#ifndef INCL_OPTIMIZED_VECTOR_FMUL_WINDOW -#define INCL_OPTIMIZED_VECTOR_FMUL_WINDOW -static inline void ff_vector_fmul_window_c(ogg_int32_t *dst, const ogg_int32_t *src0, - const ogg_int32_t *src1, const ogg_int32_t *win, int len){ - int i,j; - dst += len; - win += len; - src0+= len; - for(i=-len, j=len-1; i<0; i++, j--) { - ogg_int32_t s0 = src0[i]; - ogg_int32_t s1 = src1[j]; - ogg_int32_t wi = win[i]; - ogg_int32_t wj = win[j]; - XNPROD31(s0, s1, wj, wi, &dst[i], &dst[j]); - /* - dst[i] = MULT31(s0,wj) - MULT31(s1,wi); - dst[j] = MULT31(s0,wi) + MULT31(s1,wj); - */ - } -} -#endif - -static inline void copy_normalize(ogg_int32_t *dst, ogg_int32_t *src, int len) -{ - memcpy(dst, src, len * sizeof(ogg_int32_t)); -} - -static inline void window_overlap_add(unsigned int blocksize, unsigned int lastblock, - unsigned int bs0, unsigned int bs1, int ch, - const ogg_int32_t *win, vorbis_dsp_state *v) -{ - unsigned retlen = (blocksize + lastblock) / 4; - int j; - for (j = 0; j < ch; j++) { - ogg_int32_t *residue = v->residues[v->ri] + j * blocksize / 2; - ogg_int32_t *saved = v->saved_ptr[j]; - ogg_int32_t *ret = v->floors + j * retlen; - ogg_int32_t *buf = residue; - - if (v->W == v->lW) { - ff_vector_fmul_window_c(ret, saved, buf, win, blocksize / 4); - } else if (v->W > v->lW) { - ff_vector_fmul_window_c(ret, saved, buf, win, bs0 / 4); - copy_normalize(ret+bs0/2, buf+bs0/4, (bs1-bs0)/4); - } else { - copy_normalize(ret, saved, (bs1 - bs0) / 4); - ff_vector_fmul_window_c(ret + (bs1 - bs0) / 4, saved + (bs1 - bs0) / 4, buf, win, bs0 / 4); - } - if (v->residues[1] == NULL) { - memcpy(saved, buf + blocksize / 4, blocksize / 4 * sizeof(ogg_int32_t)); - v->saved_ptr[j] = v->saved + j * bs1 / 4; - } else { - v->saved_ptr[j] = buf + blocksize / 4; - } - - v->pcmb[j] = ret; - } - - if (v->residues[1] != NULL) { - v->ri ^= 1; - } -} diff --git a/apps/codecs/libtremor/floor0.c b/apps/codecs/libtremor/floor0.c deleted file mode 100644 index cd0a9f89f6..0000000000 --- a/apps/codecs/libtremor/floor0.c +++ /dev/null @@ -1,444 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * - * * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * - * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * - * * - ******************************************************************** - - function: floor backend 0 implementation - - ********************************************************************/ - -#include "config-tremor.h" -#include -#include -#include "ogg.h" -#include "ivorbiscodec.h" -#include "codec_internal.h" -#include "registry.h" -#include "codebook.h" -#include "misc.h" -#include "os.h" - -#define LSP_FRACBITS 14 - -typedef struct { - long n; - int ln; - int m; - int *linearmap; - - vorbis_info_floor0 *vi; - ogg_int32_t *lsp_look; - -} vorbis_look_floor0; - -/*************** LSP decode ********************/ - -#include "lsp_lookup.h" - -/* interpolated 1./sqrt(p) where .5 <= a < 1. (.100000... to .111111...) in - 16.16 format - returns in m.8 format */ - -static const long ADJUST_SQRT2[2] ={8192,5792}; -static inline ogg_int32_t vorbis_invsqlook_i(long a,long e){ - long i=(a&0x7fff)>>(INVSQ_LOOKUP_I_SHIFT-1); - long d=a&INVSQ_LOOKUP_I_MASK; /* 0.10 */ - long val=INVSQ_LOOKUP_I[i]- /* 1.16 */ - ((INVSQ_LOOKUP_IDel[i]*d)>>INVSQ_LOOKUP_I_SHIFT); /* result 1.16 */ - val*=ADJUST_SQRT2[e&1]; - e=(e>>1)+21; - return(val>>e); -} - -/* interpolated lookup based fromdB function, domain -140dB to 0dB only */ -/* a is in n.12 format */ -static inline ogg_int32_t vorbis_fromdBlook_i(long a){ - int i=(-a)>>(12-FROMdB2_SHIFT); - if(i<0) return 0x7fffffff; - if(i>=(FROMdB_LOOKUP_SZ<>FROMdB_SHIFT] * FROMdB2_LOOKUP[i&FROMdB2_MASK]; -} - -/* interpolated lookup based cos function, domain 0 to PI only */ -/* a is in 0.16 format, where 0==0, 2^^16-1==PI, return 0.14 */ -static inline ogg_int32_t vorbis_coslook_i(long a){ - int i=a>>COS_LOOKUP_I_SHIFT; - int d=a&COS_LOOKUP_I_MASK; - return COS_LOOKUP_I[i]- ((d*(COS_LOOKUP_I[i]-COS_LOOKUP_I[i+1]))>> - COS_LOOKUP_I_SHIFT); -} - -/* interpolated lookup based cos function */ -/* a is in 0.16 format, where 0==0, 2^^16==PI, return .LSP_FRACBITS */ -static inline ogg_int32_t vorbis_coslook2_i(long a){ - a=a&0x1ffff; - - if(a>0x10000)a=0x20000-a; - { - int i=a>>COS_LOOKUP_I_SHIFT; - int d=a&COS_LOOKUP_I_MASK; - a=((COS_LOOKUP_I[i]<> - (COS_LOOKUP_I_SHIFT-LSP_FRACBITS+14); - } - - return(a); -} - -static const int barklook[28] ={ - 0,100,200,301, 405,516,635,766, - 912,1077,1263,1476, 1720,2003,2333,2721, - 3184,3742,4428,5285, 6376,7791,9662,12181, - 15624,20397,27087,36554 -}; - -/* used in init only; interpolate the long way */ -static inline ogg_int32_t toBARK(int n){ - int i; - for(i=0;i<27;i++) - if(n>=barklook[i] && n>10)*0x517d)>>14; -#endif - - /* safeguard against a malicious stream */ - if(val<0 || (val>>COS_LOOKUP_I_SHIFT)>=COS_LOOKUP_I_SZ){ - memset(curve,0,sizeof(*curve)*n); - return; - } - - ilsp[i]=vorbis_coslook_i(val); - } - - i=0; - while(i>16); - qi=((qi*qi)>>16); - - if(m&1){ - qexp= qexp*2-28*((m+1)>>1)+m; - pi*=(1<<14)-((wi*wi)>>14); - qi+=pi>>14; - }else{ - qexp= qexp*2-13*m; - - pi*=(1<<14)-wi; - qi*=(1<<14)+wi; - - qi=(qi+pi)>>14; - } - - if(qi&0xffff0000){ /* checks for 1.xxxxxxxxxxxxxxxx */ - qi>>=1; qexp++; - }else - lsp_norm_asm(&qi,&qexp); - -#else - - j=1; - if(m>1){ - qi*=labs(ilsp[0]-wi); - pi*=labs(ilsp[1]-wi); - - for(j+=2;j>25])) - if(!(shift=MLOOP_2[(pi|qi)>>19])) - shift=MLOOP_3[(pi|qi)>>16]; - qi=(qi>>shift)*labs(ilsp[j-1]-wi); - pi=(pi>>shift)*labs(ilsp[j]-wi); - qexp+=shift; - } - } - if(!(shift=MLOOP_1[(pi|qi)>>25])) - if(!(shift=MLOOP_2[(pi|qi)>>19])) - shift=MLOOP_3[(pi|qi)>>16]; - - /* pi,qi normalized collectively, both tracked using qexp */ - - if(m&1){ - /* odd order filter; slightly assymetric */ - /* the last coefficient */ - qi=(qi>>shift)*labs(ilsp[j-1]-wi); - pi=(pi>>shift)<<14; - qexp+=shift; - - if(!(shift=MLOOP_1[(pi|qi)>>25])) - if(!(shift=MLOOP_2[(pi|qi)>>19])) - shift=MLOOP_3[(pi|qi)>>16]; - - pi>>=shift; - qi>>=shift; - qexp+=shift-14*((m+1)>>1); - - pi=((pi*pi)>>16); - qi=((qi*qi)>>16); - qexp=qexp*2+m; - - pi*=(1<<14)-((wi*wi)>>14); - qi+=pi>>14; - - }else{ - /* even order filter; still symmetric */ - - /* p*=p(1-w), q*=q(1+w), let normalization drift because it isn't - worth tracking step by step */ - - pi>>=shift; - qi>>=shift; - qexp+=shift-7*m; - - pi=((pi*pi)>>16); - qi=((qi*qi)>>16); - qexp=qexp*2+m; - - pi*=(1<<14)-wi; - qi*=(1<<14)+wi; - qi=(qi+pi)>>14; - - } - - - /* we've let the normalization drift because it wasn't important; - however, for the lookup, things must be normalized again. We - need at most one right shift or a number of left shifts */ - - if(qi&0xffff0000){ /* checks for 1.xxxxxxxxxxxxxxxx */ - qi>>=1; qexp++; - }else - while(qi && !(qi&0x8000)){ /* checks for 0.0xxxxxxxxxxxxxxx or less*/ - qi<<=1; qexp--; - } - -#endif - - amp=vorbis_fromdBlook_i(ampi* /* n.4 */ - vorbis_invsqlook_i(qi,qexp)- - /* m.8, m+n<=8 */ - ampoffseti); /* 8.12[0] */ - -#ifdef _LOW_ACCURACY_ - amp>>=9; -#endif - curve[i]= MULT31_SHIFT15(curve[i],amp); - while(map[++i]==k) curve[i]= MULT31_SHIFT15(curve[i],amp); - } -} - -/*************** vorbis decode glue ************/ - -static void floor0_free_info(vorbis_info_floor *i){ - vorbis_info_floor0 *info=(vorbis_info_floor0 *)i; - if(info){ - memset(info,0,sizeof(*info)); - _ogg_free(info); - } -} - -static void floor0_free_look(vorbis_look_floor *i){ - vorbis_look_floor0 *look=(vorbis_look_floor0 *)i; - if(look){ - - if(look->linearmap)_ogg_free(look->linearmap); - if(look->lsp_look)_ogg_free(look->lsp_look); - memset(look,0,sizeof(*look)); - _ogg_free(look); - } -} - -static vorbis_info_floor *floor0_unpack (vorbis_info *vi,oggpack_buffer *opb){ - codec_setup_info *ci=(codec_setup_info *)vi->codec_setup; - int j; - - vorbis_info_floor0 *info=(vorbis_info_floor0 *)_ogg_malloc(sizeof(*info)); - info->order=oggpack_read(opb,8); - info->rate=oggpack_read(opb,16); - info->barkmap=oggpack_read(opb,16); - info->ampbits=oggpack_read(opb,6); - info->ampdB=oggpack_read(opb,8); - info->numbooks=oggpack_read(opb,4)+1; - - if(info->order<1)goto err_out; - if(info->rate<1)goto err_out; - if(info->barkmap<1)goto err_out; - if(info->numbooks<1)goto err_out; - - for(j=0;jnumbooks;j++){ - info->books[j]=oggpack_read(opb,8); - if(info->books[j]<0 || info->books[j]>=ci->books)goto err_out; - if(ci->book_param[info->books[j]]->maptype==0)goto err_out; - if(ci->book_param[info->books[j]]->dim<1)goto err_out; - } - return(info); - - err_out: - floor0_free_info(info); - return(NULL); -} - -/* initialize Bark scale and normalization lookups. We could do this - with static tables, but Vorbis allows a number of possible - combinations, so it's best to do it computationally. - - The below is authoritative in terms of defining scale mapping. - Note that the scale depends on the sampling rate as well as the - linear block and mapping sizes */ - -static vorbis_look_floor *floor0_look (vorbis_dsp_state *vd,vorbis_info_mode *mi, - vorbis_info_floor *i){ - int j; - // ogg_int32_t scale; - vorbis_info *vi=vd->vi; - codec_setup_info *ci=(codec_setup_info *)vi->codec_setup; - vorbis_info_floor0 *info=(vorbis_info_floor0 *)i; - vorbis_look_floor0 *look=(vorbis_look_floor0 *)_ogg_calloc(1,sizeof(*look)); - look->m=info->order; - look->n=ci->blocksizes[mi->blockflag]/2; - look->ln=info->barkmap; - look->vi=info; - - /* the mapping from a linear scale to a smaller bark scale is - straightforward. We do *not* make sure that the linear mapping - does not skip bark-scale bins; the decoder simply skips them and - the encoder may do what it wishes in filling them. They're - necessary in some mapping combinations to keep the scale spacing - accurate */ - look->linearmap=(int *)_ogg_malloc((look->n+1)*sizeof(*look->linearmap)); - for(j=0;jn;j++){ - - int val=(look->ln* - ((toBARK(info->rate/2*j/look->n)<<11)/toBARK(info->rate/2)))>>11; - - if(val>=look->ln)val=look->ln-1; /* guard against the approximation */ - look->linearmap[j]=val; - } - look->linearmap[j]=-1; - - look->lsp_look=(ogg_int32_t *)_ogg_malloc(look->ln*sizeof(*look->lsp_look)); - for(j=0;jln;j++) - look->lsp_look[j]=vorbis_coslook2_i(0x10000*j/look->ln); - - return look; -} - -static void *floor0_inverse1(vorbis_block *vb,vorbis_look_floor *i){ - vorbis_look_floor0 *look=(vorbis_look_floor0 *)i; - vorbis_info_floor0 *info=look->vi; - int j,k; - - int ampraw=oggpack_read(&vb->opb,info->ampbits); - if(ampraw>0){ /* also handles the -1 out of data case */ - long maxval=(1<ampbits)-1; - int amp=((ampraw*info->ampdB)<<4)/maxval; - int booknum=oggpack_read(&vb->opb,_ilog(info->numbooks)); - - if(booknum!=-1 && booknumnumbooks){ /* be paranoid */ - codec_setup_info *ci=(codec_setup_info *)vb->vd->vi->codec_setup; - codebook *b=ci->fullbooks+info->books[booknum]; - ogg_int32_t last=0; - ogg_int32_t *lsp=(ogg_int32_t *)_vorbis_block_alloc(vb,sizeof(*lsp)*(look->m+1)); - - if(vorbis_book_decodev_set(b,lsp,&vb->opb,look->m,-24)==-1)goto eop; - for(j=0;jm;){ - for(k=0;jm && kdim;k++,j++)lsp[j]+=last; - last=lsp[j-1]; - } - - lsp[look->m]=amp; - return(lsp); - } - } - eop: - return(NULL); -} - -static int floor0_inverse2(vorbis_block *vb,vorbis_look_floor *i, - void *memo,ogg_int32_t *out){ - vorbis_look_floor0 *look=(vorbis_look_floor0 *)i; - vorbis_info_floor0 *info=look->vi; - (void)vb; - - if(memo){ - ogg_int32_t *lsp=(ogg_int32_t *)memo; - ogg_int32_t amp=lsp[look->m]; - - /* take the coefficients back to a spectral envelope curve */ - vorbis_lsp_to_curve(out,look->linearmap,look->n,look->ln, - lsp,look->m,amp,info->ampdB,look->lsp_look); - return(1); - } - memset(out,0,sizeof(*out)*look->n); - return(0); -} - -/* export hooks */ -const vorbis_func_floor floor0_exportbundle ICONST_ATTR ={ - &floor0_unpack,&floor0_look,&floor0_free_info, - &floor0_free_look,&floor0_inverse1,&floor0_inverse2 -}; - - diff --git a/apps/codecs/libtremor/floor1.c b/apps/codecs/libtremor/floor1.c deleted file mode 100644 index d2268db121..0000000000 --- a/apps/codecs/libtremor/floor1.c +++ /dev/null @@ -1,426 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * - * * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * - * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * - * * - ******************************************************************** - - function: floor backend 1 implementation - - ********************************************************************/ - -#include "config-tremor.h" -#include -#include -#include "ogg.h" -#include "ivorbiscodec.h" -#include "codec_internal.h" -#include "registry.h" -#include "codebook.h" -#include "misc.h" -#include "ffmpeg_stuff.h" - -#define floor1_rangedB 140 /* floor 1 fixed at -140dB to 0dB range */ - -typedef struct { - int forward_index[VIF_POSIT+2]; - - int hineighbor[VIF_POSIT]; - int loneighbor[VIF_POSIT]; - int posts; - - int n; - int quant_q; - vorbis_info_floor1 *vi; - -} vorbis_look_floor1; - -/***********************************************/ - -static void floor1_free_info(vorbis_info_floor *i){ - vorbis_info_floor1 *info=(vorbis_info_floor1 *)i; - if(info){ - //memset(info,0,sizeof(*info)); - _ogg_free(info); - } -} - -static void floor1_free_look(vorbis_look_floor *i){ - vorbis_look_floor1 *look=(vorbis_look_floor1 *)i; - if(look){ - //memset(look,0,sizeof(*look)); - _ogg_free(look); - } -} - -static inline int ilog(register unsigned int v){ - register int ret=0; - while(v){ - ret++; - v>>=1; - } - return(ret); -} - -static int icomp(const void *a,const void *b){ - return(**(int **)a-**(int **)b); -} - -static vorbis_info_floor *floor1_unpack (vorbis_info *vi,oggpack_buffer *opb){ - codec_setup_info *ci=(codec_setup_info *)vi->codec_setup; - int j,k,count=0,maxclass=-1,rangebits; - - vorbis_info_floor1 *info=(vorbis_info_floor1 *)_ogg_calloc(1,sizeof(*info)); - /* read partitions */ - info->partitions=oggpack_read(opb,5); /* only 0 to 31 legal */ - for(j=0;jpartitions;j++){ - info->partitionclass[j]=oggpack_read(opb,4); /* only 0 to 15 legal */ - if(info->partitionclass[j]<0)goto err_out; - if(maxclasspartitionclass[j])maxclass=info->partitionclass[j]; - } - - /* read partition classes */ - for(j=0;jclass_dim[j]=oggpack_read(opb,3)+1; /* 1 to 8 */ - info->class_subs[j]=oggpack_read(opb,2); /* 0,1,2,3 bits */ - if(info->class_subs[j]<0) - goto err_out; - if(info->class_subs[j])info->class_book[j]=oggpack_read(opb,8); - if(info->class_book[j]<0 || info->class_book[j]>=ci->books) - goto err_out; - for(k=0;k<(1<class_subs[j]);k++){ - info->class_subbook[j][k]=oggpack_read(opb,8)-1; - if(info->class_subbook[j][k]<-1 || info->class_subbook[j][k]>=ci->books) - goto err_out; - } - } - - /* read the post list */ - info->mult=oggpack_read(opb,2)+1; /* only 1,2,3,4 legal now */ - rangebits=oggpack_read(opb,4); - if(rangebits<0)goto err_out; - - for(j=0,k=0;jpartitions;j++){ - count+=info->class_dim[info->partitionclass[j]]; - for(;kpostlist[k+2]=oggpack_read(opb,rangebits); - if(t<0 || t>=(1<postlist[0]=0; - info->postlist[1]=1<postlist+j; - qsort(sortpointer,count+2,sizeof(*sortpointer),icomp); - - for(j=1;jvi=info; - look->n=info->postlist[1]; - - /* we drop each position value in-between already decoded values, - and use linear interpolation to predict each new value past the - edges. The positions are read in the order of the position - list... we precompute the bounding positions in the lookup. Of - course, the neighbors can change (if a position is declined), but - this is an initial mapping */ - - for(i=0;ipartitions;i++)n+=info->class_dim[info->partitionclass[i]]; - n+=2; - look->posts=n; - - /* also store a sorted position index */ - for(i=0;ipostlist+i; - qsort(sortpointer,n,sizeof(*sortpointer),icomp); - - /* points from sort order back to range number */ - for(i=0;iforward_index[i]=sortpointer[i]-info->postlist; - - /* quantize values to multiplier spec */ - switch(info->mult){ - case 1: /* 1024 -> 256 */ - look->quant_q=256; - break; - case 2: /* 1024 -> 128 */ - look->quant_q=128; - break; - case 3: /* 1024 -> 86 */ - look->quant_q=86; - break; - case 4: /* 1024 -> 64 */ - look->quant_q=64; - break; - } - - /* discover our neighbors for decode where we don't use fit flags - (that would push the neighbors outward) */ - for(i=0;in; - int currentx=info->postlist[i+2]; - for(j=0;jpostlist[j]; - if(x>lx && xcurrentx){ - hi=j; - hx=x; - } - } - look->loneighbor[i]=lo; - look->hineighbor[i]=hi; - } - - return(look); -} - -static int render_point(int x0,int x1,int y0,int y1,int x){ - y0&=0x7fff; /* mask off flag */ - y1&=0x7fff; - return y0+((y1-y0)*(x-x0))/(x1-x0); -} - -#ifdef _LOW_ACCURACY_ -# define XdB(n) ((((n)>>8)+1)>>1) -#else -# define XdB(n) (n) -#endif - -/* keep the floor lookup table in fast IRAM */ -static const ogg_int32_t FLOOR_fromdB_LOOKUP[256] ICONST_ATTR = { - XdB(0x000000e5), XdB(0x000000f4), XdB(0x00000103), XdB(0x00000114), - XdB(0x00000126), XdB(0x00000139), XdB(0x0000014e), XdB(0x00000163), - XdB(0x0000017a), XdB(0x00000193), XdB(0x000001ad), XdB(0x000001c9), - XdB(0x000001e7), XdB(0x00000206), XdB(0x00000228), XdB(0x0000024c), - XdB(0x00000272), XdB(0x0000029b), XdB(0x000002c6), XdB(0x000002f4), - XdB(0x00000326), XdB(0x0000035a), XdB(0x00000392), XdB(0x000003cd), - XdB(0x0000040c), XdB(0x00000450), XdB(0x00000497), XdB(0x000004e4), - XdB(0x00000535), XdB(0x0000058c), XdB(0x000005e8), XdB(0x0000064a), - XdB(0x000006b3), XdB(0x00000722), XdB(0x00000799), XdB(0x00000818), - XdB(0x0000089e), XdB(0x0000092e), XdB(0x000009c6), XdB(0x00000a69), - XdB(0x00000b16), XdB(0x00000bcf), XdB(0x00000c93), XdB(0x00000d64), - XdB(0x00000e43), XdB(0x00000f30), XdB(0x0000102d), XdB(0x0000113a), - XdB(0x00001258), XdB(0x0000138a), XdB(0x000014cf), XdB(0x00001629), - XdB(0x0000179a), XdB(0x00001922), XdB(0x00001ac4), XdB(0x00001c82), - XdB(0x00001e5c), XdB(0x00002055), XdB(0x0000226f), XdB(0x000024ac), - XdB(0x0000270e), XdB(0x00002997), XdB(0x00002c4b), XdB(0x00002f2c), - XdB(0x0000323d), XdB(0x00003581), XdB(0x000038fb), XdB(0x00003caf), - XdB(0x000040a0), XdB(0x000044d3), XdB(0x0000494c), XdB(0x00004e10), - XdB(0x00005323), XdB(0x0000588a), XdB(0x00005e4b), XdB(0x0000646b), - XdB(0x00006af2), XdB(0x000071e5), XdB(0x0000794c), XdB(0x0000812e), - XdB(0x00008993), XdB(0x00009283), XdB(0x00009c09), XdB(0x0000a62d), - XdB(0x0000b0f9), XdB(0x0000bc79), XdB(0x0000c8b9), XdB(0x0000d5c4), - XdB(0x0000e3a9), XdB(0x0000f274), XdB(0x00010235), XdB(0x000112fd), - XdB(0x000124dc), XdB(0x000137e4), XdB(0x00014c29), XdB(0x000161bf), - XdB(0x000178bc), XdB(0x00019137), XdB(0x0001ab4a), XdB(0x0001c70e), - XdB(0x0001e4a1), XdB(0x0002041f), XdB(0x000225aa), XdB(0x00024962), - XdB(0x00026f6d), XdB(0x000297f0), XdB(0x0002c316), XdB(0x0002f109), - XdB(0x000321f9), XdB(0x00035616), XdB(0x00038d97), XdB(0x0003c8b4), - XdB(0x000407a7), XdB(0x00044ab2), XdB(0x00049218), XdB(0x0004de23), - XdB(0x00052f1e), XdB(0x0005855c), XdB(0x0005e135), XdB(0x00064306), - XdB(0x0006ab33), XdB(0x00071a24), XdB(0x0007904b), XdB(0x00080e20), - XdB(0x00089422), XdB(0x000922da), XdB(0x0009bad8), XdB(0x000a5cb6), - XdB(0x000b091a), XdB(0x000bc0b1), XdB(0x000c8436), XdB(0x000d5471), - XdB(0x000e3233), XdB(0x000f1e5f), XdB(0x001019e4), XdB(0x001125c1), - XdB(0x00124306), XdB(0x001372d5), XdB(0x0014b663), XdB(0x00160ef7), - XdB(0x00177df0), XdB(0x001904c1), XdB(0x001aa4f9), XdB(0x001c603d), - XdB(0x001e384f), XdB(0x00202f0f), XdB(0x0022467a), XdB(0x002480b1), - XdB(0x0026dff7), XdB(0x002966b3), XdB(0x002c1776), XdB(0x002ef4fc), - XdB(0x0032022d), XdB(0x00354222), XdB(0x0038b828), XdB(0x003c67c2), - XdB(0x004054ae), XdB(0x004482e8), XdB(0x0048f6af), XdB(0x004db488), - XdB(0x0052c142), XdB(0x005821ff), XdB(0x005ddc33), XdB(0x0063f5b0), - XdB(0x006a74a7), XdB(0x00715faf), XdB(0x0078bdce), XdB(0x0080967f), - XdB(0x0088f1ba), XdB(0x0091d7f9), XdB(0x009b5247), XdB(0x00a56a41), - XdB(0x00b02a27), XdB(0x00bb9ce2), XdB(0x00c7ce12), XdB(0x00d4ca17), - XdB(0x00e29e20), XdB(0x00f15835), XdB(0x0101074b), XdB(0x0111bb4e), - XdB(0x01238531), XdB(0x01367704), XdB(0x014aa402), XdB(0x016020a7), - XdB(0x017702c3), XdB(0x018f6190), XdB(0x01a955cb), XdB(0x01c4f9cf), - XdB(0x01e269a8), XdB(0x0201c33b), XdB(0x0223265a), XdB(0x0246b4ea), - XdB(0x026c9302), XdB(0x0294e716), XdB(0x02bfda13), XdB(0x02ed9793), - XdB(0x031e4e09), XdB(0x03522ee4), XdB(0x03896ed0), XdB(0x03c445e2), - XdB(0x0402efd6), XdB(0x0445ac4b), XdB(0x048cbefc), XdB(0x04d87013), - XdB(0x05290c67), XdB(0x057ee5ca), XdB(0x05da5364), XdB(0x063bb204), - XdB(0x06a36485), XdB(0x0711d42b), XdB(0x0787710e), XdB(0x0804b299), - XdB(0x088a17ef), XdB(0x0918287e), XdB(0x09af747c), XdB(0x0a50957e), - XdB(0x0afc2f19), XdB(0x0bb2ef7f), XdB(0x0c759034), XdB(0x0d44d6ca), - XdB(0x0e2195bc), XdB(0x0f0cad0d), XdB(0x10070b62), XdB(0x1111aeea), - XdB(0x122da66c), XdB(0x135c120f), XdB(0x149e24d9), XdB(0x15f525b1), - XdB(0x176270e3), XdB(0x18e7794b), XdB(0x1a85c9ae), XdB(0x1c3f06d1), - XdB(0x1e14f07d), XdB(0x200963d7), XdB(0x221e5ccd), XdB(0x2455f870), - XdB(0x26b2770b), XdB(0x29363e2b), XdB(0x2be3db5c), XdB(0x2ebe06b6), - XdB(0x31c7a55b), XdB(0x3503ccd4), XdB(0x3875c5aa), XdB(0x3c210f44), - XdB(0x4009632b), XdB(0x4432b8cf), XdB(0x48a149bc), XdB(0x4d59959e), - XdB(0x52606733), XdB(0x57bad899), XdB(0x5d6e593a), XdB(0x6380b298), - XdB(0x69f80e9a), XdB(0x70dafda8), XdB(0x78307d76), XdB(0x7fffffff), -}; - -static void *floor1_inverse1(vorbis_block *vb,vorbis_look_floor *in) - ICODE_ATTR_TREMOR_NOT_MDCT; -static void *floor1_inverse1(vorbis_block *vb,vorbis_look_floor *in){ - vorbis_look_floor1 *look=(vorbis_look_floor1 *)in; - vorbis_info_floor1 *info=look->vi; - codec_setup_info *ci=(codec_setup_info *)vb->vd->vi->codec_setup; - int i,j,k; - codebook *books=ci->fullbooks; - - /* unpack wrapped/predicted values from stream */ - if(oggpack_read(&vb->opb,1)==1){ - int *fit_value=(int *)_vorbis_block_alloc(vb,(look->posts)*sizeof(*fit_value)); - int ilg = ilog(look->quant_q-1); - fit_value[0]=oggpack_read(&vb->opb,ilg); - fit_value[1]=oggpack_read(&vb->opb,ilg); - - /* partition by partition */ - /* partition by partition */ - for(i=0,j=2;ipartitions;i++){ - int classv=info->partitionclass[i]; - int cdim=info->class_dim[classv]; - int csubbits=info->class_subs[classv]; - int csub=1<class_book[classv],&vb->opb); - - if(cval==-1)goto eop; - } - - for(k=0;kclass_subbook[classv][cval&(csub-1)]; - cval>>=csubbits; - if(book>=0){ - if((fit_value[j+k]=vorbis_book_decode(books+book,&vb->opb))==-1) - goto eop; - }else{ - fit_value[j+k]=0; - } - } - j+=cdim; - } - - /* unwrap positive values and reconsitute via linear interpolation */ - for(i=2;iposts;i++){ - int predicted=render_point(info->postlist[look->loneighbor[i-2]], - info->postlist[look->hineighbor[i-2]], - fit_value[look->loneighbor[i-2]], - fit_value[look->hineighbor[i-2]], - info->postlist[i]); - int hiroom=look->quant_q-predicted; - int loroom=predicted; - int room=(hiroom=room){ - if(hiroom>loroom){ - val = val-loroom; - }else{ - val = -1-(val-hiroom); - } - }else{ - if(val&1){ - val= -((val+1)>>1); - }else{ - val>>=1; - } - } - - fit_value[i]=(val+predicted)&0x7fff;; - fit_value[look->loneighbor[i-2]]&=0x7fff; - fit_value[look->hineighbor[i-2]]&=0x7fff; - - }else{ - fit_value[i]=predicted|0x8000; - } - } - - return(fit_value); - } - eop: - return(NULL); -} - -static int floor1_inverse2(vorbis_block *vb,vorbis_look_floor *in,void *memo, - ogg_int32_t *out) ICODE_ATTR_TREMOR_NOT_MDCT; -static int floor1_inverse2(vorbis_block *vb,vorbis_look_floor *in,void *memo, - ogg_int32_t *out){ - vorbis_look_floor1 *look=(vorbis_look_floor1 *)in; - vorbis_info_floor1 *info=look->vi; - - codec_setup_info *ci=(codec_setup_info *)vb->vd->vi->codec_setup; - int n=ci->blocksizes[vb->W]/2; - int j; - - if(memo){ - /* render the lines */ - int *fit_value=(int *)memo; - int hx=0; - int lx=0; - int ly=fit_value[0]*info->mult; - /* guard lookup against out-of-range values */ - ly=(ly<0?0:ly>255?255:ly); - - for(j=1;jposts;j++){ - int current=look->forward_index[j]; - int hy=fit_value[current]&0x7fff; - if(hy==fit_value[current]){ - - hx=info->postlist[current]; - hy*=info->mult; - /* guard lookup against out-of-range values */ - hy=(hy<0?0:hy>255?255:hy); - - render_line(lx, ly, hx, hy, FLOOR_fromdB_LOOKUP, out); - - lx=hx; - ly=hy; - } - } - for(j=hx;j -#include -#include "ogg.h" - -/* A complete description of Ogg framing exists in docs/framing.html */ - -static int ogg_page_version(const ogg_page *og){ - return((int)(og->header[4])); -} - -int ogg_page_continued(const ogg_page *og){ - return((int)(og->header[5]&0x01)); -} - -int ogg_page_bos(const ogg_page *og){ - return((int)(og->header[5]&0x02)); -} - -int ogg_page_eos(const ogg_page *og){ - return((int)(og->header[5]&0x04)); -} - -ogg_int64_t ogg_page_granulepos(const ogg_page *og){ - unsigned char *page=og->header; - ogg_int64_t granulepos=page[13]&(0xff); - granulepos= (granulepos<<8)|(page[12]&0xff); - granulepos= (granulepos<<8)|(page[11]&0xff); - granulepos= (granulepos<<8)|(page[10]&0xff); - granulepos= (granulepos<<8)|(page[9]&0xff); - granulepos= (granulepos<<8)|(page[8]&0xff); - granulepos= (granulepos<<8)|(page[7]&0xff); - granulepos= (granulepos<<8)|(page[6]&0xff); - return(granulepos); -} - -ogg_uint32_t ogg_page_serialno(const ogg_page *og){ - return(og->header[14] | - (og->header[15]<<8) | - (og->header[16]<<16) | - (og->header[17]<<24)); -} - -static long ogg_page_pageno(const ogg_page *og){ - return(og->header[18] | - (og->header[19]<<8) | - (og->header[20]<<16) | - (og->header[21]<<24)); -} - - - -/* returns the number of packets that are completed on this page (if - the leading packet is begun on a previous page, but ends on this - page, it's counted */ - -/* NOTE: -If a page consists of a packet begun on a previous page, and a new -packet begun (but not completed) on this page, the return will be: - ogg_page_packets(page) ==1, - ogg_page_continued(page) !=0 - -If a page happens to be a single packet that was begun on a -previous page, and spans to the next page (in the case of a three or -more page packet), the return will be: - ogg_page_packets(page) ==0, - ogg_page_continued(page) !=0 -*/ -/* -int ogg_page_packets(const ogg_page *og){ - int i,n=og->header[26],count=0; - for(i=0;iheader[27+i]<255)count++; - return(count); -} -*/ - -#if 0 -/* helper to initialize lookup for direct-table CRC (illustrative; we - use the static init below) */ - -static ogg_uint32_t _ogg_crc_entry(unsigned long index){ - int i; - unsigned long r; - - r = index << 24; - for (i=0; i<8; i++) - if (r & 0x80000000UL) - r = (r << 1) ^ 0x04c11db7; /* The same as the ethernet generator - polynomial, although we use an - unreflected alg and an init/final - of 0, not 0xffffffff */ - else - r<<=1; - return (r & 0xffffffffUL); -} -#endif - -static const ogg_uint32_t crc_lookup[256] ICONST_ATTR = { - 0x00000000,0x04c11db7,0x09823b6e,0x0d4326d9, - 0x130476dc,0x17c56b6b,0x1a864db2,0x1e475005, - 0x2608edb8,0x22c9f00f,0x2f8ad6d6,0x2b4bcb61, - 0x350c9b64,0x31cd86d3,0x3c8ea00a,0x384fbdbd, - 0x4c11db70,0x48d0c6c7,0x4593e01e,0x4152fda9, - 0x5f15adac,0x5bd4b01b,0x569796c2,0x52568b75, - 0x6a1936c8,0x6ed82b7f,0x639b0da6,0x675a1011, - 0x791d4014,0x7ddc5da3,0x709f7b7a,0x745e66cd, - 0x9823b6e0,0x9ce2ab57,0x91a18d8e,0x95609039, - 0x8b27c03c,0x8fe6dd8b,0x82a5fb52,0x8664e6e5, - 0xbe2b5b58,0xbaea46ef,0xb7a96036,0xb3687d81, - 0xad2f2d84,0xa9ee3033,0xa4ad16ea,0xa06c0b5d, - 0xd4326d90,0xd0f37027,0xddb056fe,0xd9714b49, - 0xc7361b4c,0xc3f706fb,0xceb42022,0xca753d95, - 0xf23a8028,0xf6fb9d9f,0xfbb8bb46,0xff79a6f1, - 0xe13ef6f4,0xe5ffeb43,0xe8bccd9a,0xec7dd02d, - 0x34867077,0x30476dc0,0x3d044b19,0x39c556ae, - 0x278206ab,0x23431b1c,0x2e003dc5,0x2ac12072, - 0x128e9dcf,0x164f8078,0x1b0ca6a1,0x1fcdbb16, - 0x018aeb13,0x054bf6a4,0x0808d07d,0x0cc9cdca, - 0x7897ab07,0x7c56b6b0,0x71159069,0x75d48dde, - 0x6b93dddb,0x6f52c06c,0x6211e6b5,0x66d0fb02, - 0x5e9f46bf,0x5a5e5b08,0x571d7dd1,0x53dc6066, - 0x4d9b3063,0x495a2dd4,0x44190b0d,0x40d816ba, - 0xaca5c697,0xa864db20,0xa527fdf9,0xa1e6e04e, - 0xbfa1b04b,0xbb60adfc,0xb6238b25,0xb2e29692, - 0x8aad2b2f,0x8e6c3698,0x832f1041,0x87ee0df6, - 0x99a95df3,0x9d684044,0x902b669d,0x94ea7b2a, - 0xe0b41de7,0xe4750050,0xe9362689,0xedf73b3e, - 0xf3b06b3b,0xf771768c,0xfa325055,0xfef34de2, - 0xc6bcf05f,0xc27dede8,0xcf3ecb31,0xcbffd686, - 0xd5b88683,0xd1799b34,0xdc3abded,0xd8fba05a, - 0x690ce0ee,0x6dcdfd59,0x608edb80,0x644fc637, - 0x7a089632,0x7ec98b85,0x738aad5c,0x774bb0eb, - 0x4f040d56,0x4bc510e1,0x46863638,0x42472b8f, - 0x5c007b8a,0x58c1663d,0x558240e4,0x51435d53, - 0x251d3b9e,0x21dc2629,0x2c9f00f0,0x285e1d47, - 0x36194d42,0x32d850f5,0x3f9b762c,0x3b5a6b9b, - 0x0315d626,0x07d4cb91,0x0a97ed48,0x0e56f0ff, - 0x1011a0fa,0x14d0bd4d,0x19939b94,0x1d528623, - 0xf12f560e,0xf5ee4bb9,0xf8ad6d60,0xfc6c70d7, - 0xe22b20d2,0xe6ea3d65,0xeba91bbc,0xef68060b, - 0xd727bbb6,0xd3e6a601,0xdea580d8,0xda649d6f, - 0xc423cd6a,0xc0e2d0dd,0xcda1f604,0xc960ebb3, - 0xbd3e8d7e,0xb9ff90c9,0xb4bcb610,0xb07daba7, - 0xae3afba2,0xaafbe615,0xa7b8c0cc,0xa379dd7b, - 0x9b3660c6,0x9ff77d71,0x92b45ba8,0x9675461f, - 0x8832161a,0x8cf30bad,0x81b02d74,0x857130c3, - 0x5d8a9099,0x594b8d2e,0x5408abf7,0x50c9b640, - 0x4e8ee645,0x4a4ffbf2,0x470cdd2b,0x43cdc09c, - 0x7b827d21,0x7f436096,0x7200464f,0x76c15bf8, - 0x68860bfd,0x6c47164a,0x61043093,0x65c52d24, - 0x119b4be9,0x155a565e,0x18197087,0x1cd86d30, - 0x029f3d35,0x065e2082,0x0b1d065b,0x0fdc1bec, - 0x3793a651,0x3352bbe6,0x3e119d3f,0x3ad08088, - 0x2497d08d,0x2056cd3a,0x2d15ebe3,0x29d4f654, - 0xc5a92679,0xc1683bce,0xcc2b1d17,0xc8ea00a0, - 0xd6ad50a5,0xd26c4d12,0xdf2f6bcb,0xdbee767c, - 0xe3a1cbc1,0xe760d676,0xea23f0af,0xeee2ed18, - 0xf0a5bd1d,0xf464a0aa,0xf9278673,0xfde69bc4, - 0x89b8fd09,0x8d79e0be,0x803ac667,0x84fbdbd0, - 0x9abc8bd5,0x9e7d9662,0x933eb0bb,0x97ffad0c, - 0xafb010b1,0xab710d06,0xa6322bdf,0xa2f33668, - 0xbcb4666d,0xb8757bda,0xb5365d03,0xb1f740b4}; - -/* init the encode/decode logical stream state */ - -int ogg_stream_init(ogg_stream_state *os,int serialno){ - if(os){ - memset(os,0,sizeof(*os)); - os->body_storage=16*1024; - os->lacing_storage=1024; - - os->body_data=_ogg_malloc(os->body_storage*sizeof(*os->body_data)); - os->lacing_vals=_ogg_malloc(os->lacing_storage*sizeof(*os->lacing_vals)); - os->granule_vals=_ogg_malloc(os->lacing_storage*sizeof(*os->granule_vals)); - - if(!os->body_data || !os->lacing_vals || !os->granule_vals){ - ogg_stream_clear(os); - return -1; - } - - os->serialno=serialno; - - return(0); - } - return(-1); -} - -/* async/delayed error detection for the ogg_stream_state */ -static int ogg_stream_check(ogg_stream_state *os){ - if(!os || !os->body_data) return -1; - return 0; -} - -/* _clear does not free os, only the non-flat storage within */ -int ogg_stream_clear(ogg_stream_state *os){ - if(os){ - if(os->body_data)_ogg_free(os->body_data); - if(os->lacing_vals)_ogg_free(os->lacing_vals); - if(os->granule_vals)_ogg_free(os->granule_vals); - - memset(os,0,sizeof(*os)); - } - return(0); -} -/* -int ogg_stream_destroy(ogg_stream_state *os){ - if(os){ - ogg_stream_clear(os); - _ogg_free(os); - } - return(0); -} -*/ -/* Helpers for ogg_stream_encode; this keeps the structure and - what's happening fairly clear */ - -int _os_body_expand(ogg_stream_state *os,int needed){ - if(os->body_storage<=os->body_fill+needed){ - void *ret; - ret=_ogg_realloc(os->body_data,(os->body_storage+needed+1024)* - sizeof(*os->body_data)); - if(!ret){ - ogg_stream_clear(os); - return -1; - } - os->body_storage+=(needed+1024); - os->body_data=ret; - } - return 0; -} - -static int _os_lacing_expand(ogg_stream_state *os,int needed){ - if(os->lacing_storage<=os->lacing_fill+needed){ - void *ret; - ret=_ogg_realloc(os->lacing_vals,(os->lacing_storage+needed+32)* - sizeof(*os->lacing_vals)); - if(!ret){ - ogg_stream_clear(os); - return -1; - } - os->lacing_vals=ret; - ret=_ogg_realloc(os->granule_vals,(os->lacing_storage+needed+32)* - sizeof(*os->granule_vals)); - if(!ret){ - ogg_stream_clear(os); - return -1; - } - os->granule_vals=ret; - os->lacing_storage+=(needed+32); - } - return 0; -} - -/* checksum the page */ -/* Direct table CRC; note that this will be faster in the future if we - perform the checksum simultaneously with other copies */ - -static void ogg_page_checksum_set(ogg_page *og){ - if(og){ - ogg_uint32_t crc_reg=0; - int i; - - /* safety; needed for API behavior, but not framing code */ - og->header[22]=0; - og->header[23]=0; - og->header[24]=0; - og->header[25]=0; - - for(i=0;iheader_len;i++) - crc_reg=(crc_reg<<8)^crc_lookup[((crc_reg >> 24)&0xff)^og->header[i]]; - for(i=0;ibody_len;i++) - crc_reg=(crc_reg<<8)^crc_lookup[((crc_reg >> 24)&0xff)^og->body[i]]; - - og->header[22]=(unsigned char)(crc_reg&0xff); - og->header[23]=(unsigned char)((crc_reg>>8)&0xff); - og->header[24]=(unsigned char)((crc_reg>>16)&0xff); - og->header[25]=(unsigned char)((crc_reg>>24)&0xff); - } -} - -#if 0 -/* submit data to the internal buffer of the framing engine */ -int ogg_stream_iovecin(ogg_stream_state *os, ogg_iovec_t *iov, int count, - long e_o_s, ogg_int64_t granulepos){ - - int bytes = 0, lacing_vals, i; - - if(ogg_stream_check(os)) return -1; - if(!iov) return 0; - - for (i = 0; i < count; ++i) bytes += (int)iov[i].iov_len; - lacing_vals=bytes/255+1; - - if(os->body_returned){ - /* advance packet data according to the body_returned pointer. We - had to keep it around to return a pointer into the buffer last - call */ - - os->body_fill-=os->body_returned; - if(os->body_fill) - memmove(os->body_data,os->body_data+os->body_returned, - os->body_fill); - os->body_returned=0; - } - - /* make sure we have the buffer storage */ - if(_os_body_expand(os,bytes) || _os_lacing_expand(os,lacing_vals)) - return -1; - - /* Copy in the submitted packet. Yes, the copy is a waste; this is - the liability of overly clean abstraction for the time being. It - will actually be fairly easy to eliminate the extra copy in the - future */ - - for (i = 0; i < count; ++i) { - memcpy(os->body_data+os->body_fill, iov[i].iov_base, iov[i].iov_len); - os->body_fill += (int)iov[i].iov_len; - } - - /* Store lacing vals for this packet */ - for(i=0;ilacing_vals[os->lacing_fill+i]=255; - os->granule_vals[os->lacing_fill+i]=os->granulepos; - } - os->lacing_vals[os->lacing_fill+i]=bytes%255; - os->granulepos=os->granule_vals[os->lacing_fill+i]=granulepos; - - /* flag the first segment as the beginning of the packet */ - os->lacing_vals[os->lacing_fill]|= 0x100; - - os->lacing_fill+=lacing_vals; - - /* for the sake of completeness */ - os->packetno++; - - if(e_o_s)os->e_o_s=1; - - return(0); -} - -int ogg_stream_packetin(ogg_stream_state *os,ogg_packet *op){ - ogg_iovec_t iov; - iov.iov_base = op->packet; - iov.iov_len = op->bytes; - return ogg_stream_iovecin(os, &iov, 1, op->e_o_s, op->granulepos); -} - - -/* Conditionally flush a page; force==0 will only flush nominal-size - pages, force==1 forces us to flush a page regardless of page size - so long as there's any data available at all. */ -static int ogg_stream_flush_i(ogg_stream_state *os,ogg_page *og, int force, int nfill){ - int i; - int vals=0; - int maxvals=(os->lacing_fill>255?255:os->lacing_fill); - int bytes=0; - long acc=0; - ogg_int64_t granule_pos=-1; - - if(ogg_stream_check(os)) return(0); - if(maxvals==0) return(0); - - /* construct a page */ - /* decide how many segments to include */ - - /* If this is the initial header case, the first page must only include - the initial header packet */ - if(os->b_o_s==0){ /* 'initial header page' case */ - granule_pos=0; - for(vals=0;valslacing_vals[vals]&0x0ff)<255){ - vals++; - break; - } - } - }else{ - - /* The extra packets_done, packet_just_done logic here attempts to do two things: - 1) Don't unneccessarily span pages. - 2) Unless necessary, don't flush pages if there are less than four packets on - them; this expands page size to reduce unneccessary overhead if incoming packets - are large. - These are not necessary behaviors, just 'always better than naive flushing' - without requiring an application to explicitly request a specific optimized - behavior. We'll want an explicit behavior setup pathway eventually as well. */ - - int packets_done=0; - int packet_just_done=0; - for(vals=0;valsnfill && packet_just_done>=4){ - force=1; - break; - } - acc+=os->lacing_vals[vals]&0x0ff; - if((os->lacing_vals[vals]&0xff)<255){ - granule_pos=os->granule_vals[vals]; - packet_just_done=++packets_done; - }else - packet_just_done=0; - } - if(vals==255)force=1; - } - - if(!force) return(0); - - /* construct the header in temp storage */ - memcpy(os->header,"OggS",4); - - /* stream structure version */ - os->header[4]=0x00; - - /* continued packet flag? */ - os->header[5]=0x00; - if((os->lacing_vals[0]&0x100)==0)os->header[5]|=0x01; - /* first page flag? */ - if(os->b_o_s==0)os->header[5]|=0x02; - /* last page flag? */ - if(os->e_o_s && os->lacing_fill==vals)os->header[5]|=0x04; - os->b_o_s=1; - - /* 64 bits of PCM position */ - for(i=6;i<14;i++){ - os->header[i]=(unsigned char)(granule_pos&0xff); - granule_pos>>=8; - } - - /* 32 bits of stream serial number */ - { - long serialno=os->serialno; - for(i=14;i<18;i++){ - os->header[i]=(unsigned char)(serialno&0xff); - serialno>>=8; - } - } - - /* 32 bits of page counter (we have both counter and page header - because this val can roll over) */ - if(os->pageno==-1)os->pageno=0; /* because someone called - stream_reset; this would be a - strange thing to do in an - encode stream, but it has - plausible uses */ - { - long pageno=os->pageno++; - for(i=18;i<22;i++){ - os->header[i]=(unsigned char)(pageno&0xff); - pageno>>=8; - } - } - - /* zero for computation; filled in later */ - os->header[22]=0; - os->header[23]=0; - os->header[24]=0; - os->header[25]=0; - - /* segment table */ - os->header[26]=(unsigned char)(vals&0xff); - for(i=0;iheader[i+27]=(unsigned char)(os->lacing_vals[i]&0xff); - - /* set pointers in the ogg_page struct */ - og->header=os->header; - og->header_len=os->header_fill=vals+27; - og->body=os->body_data+os->body_returned; - og->body_len=bytes; - - /* advance the lacing data and set the body_returned pointer */ - - os->lacing_fill-=vals; - memmove(os->lacing_vals,os->lacing_vals+vals,os->lacing_fill*sizeof(*os->lacing_vals)); - memmove(os->granule_vals,os->granule_vals+vals,os->lacing_fill*sizeof(*os->granule_vals)); - os->body_returned+=bytes; - - /* calculate the checksum */ - - ogg_page_checksum_set(og); - - /* done */ - return(1); -} - -/* This will flush remaining packets into a page (returning nonzero), - even if there is not enough data to trigger a flush normally - (undersized page). If there are no packets or partial packets to - flush, ogg_stream_flush returns 0. Note that ogg_stream_flush will - try to flush a normal sized page like ogg_stream_pageout; a call to - ogg_stream_flush does not guarantee that all packets have flushed. - Only a return value of 0 from ogg_stream_flush indicates all packet - data is flushed into pages. - - since ogg_stream_flush will flush the last page in a stream even if - it's undersized, you almost certainly want to use ogg_stream_pageout - (and *not* ogg_stream_flush) unless you specifically need to flush - an page regardless of size in the middle of a stream. */ - -int ogg_stream_flush(ogg_stream_state *os,ogg_page *og){ - return ogg_stream_flush_i(os,og,1,4096); -} - -/* This constructs pages from buffered packet segments. The pointers -returned are to static buffers; do not free. The returned buffers are -good only until the next call (using the same ogg_stream_state) */ - -int ogg_stream_pageout(ogg_stream_state *os, ogg_page *og){ - int force=0; - if(ogg_stream_check(os)) return 0; - - if((os->e_o_s&&os->lacing_fill) || /* 'were done, now flush' case */ - (os->lacing_fill&&!os->b_o_s)) /* 'initial header page' case */ - force=1; - - return(ogg_stream_flush_i(os,og,force,4096)); -} - -/* Like the above, but an argument is provided to adjust the nominal -page size for applications which are smart enough to provide their -own delay based flushing */ - -int ogg_stream_pageout_fill(ogg_stream_state *os, ogg_page *og, int nfill){ - int force=0; - if(ogg_stream_check(os)) return 0; - - if((os->e_o_s&&os->lacing_fill) || /* 'were done, now flush' case */ - (os->lacing_fill&&!os->b_o_s)) /* 'initial header page' case */ - force=1; - - return(ogg_stream_flush_i(os,og,force,nfill)); -} - -int ogg_stream_eos(ogg_stream_state *os){ - if(ogg_stream_check(os)) return 1; - return os->e_o_s; -} -#endif -/* DECODING PRIMITIVES: packet streaming layer **********************/ - -/* This has two layers to place more of the multi-serialno and paging - control in the application's hands. First, we expose a data buffer - using ogg_sync_buffer(). The app either copies into the - buffer, or passes it directly to read(), etc. We then call - ogg_sync_wrote() to tell how many bytes we just added. - - Pages are returned (pointers into the buffer in ogg_sync_state) - by ogg_sync_pageout(). The page is then submitted to - ogg_stream_pagein() along with the appropriate - ogg_stream_state* (ie, matching serialno). We then get raw - packets out calling ogg_stream_packetout() with a - ogg_stream_state. */ - -/* initialize the struct to a known state */ -int ogg_sync_init(ogg_sync_state *oy){ - if(oy){ - oy->storage = -1; /* used as a readiness flag */ - memset(oy,0,sizeof(*oy)); - } - return(0); -} - -/* clear non-flat storage within */ -int ogg_sync_clear(ogg_sync_state *oy){ - if(oy){ - if(oy->data)_ogg_free(oy->data); - memset(oy,0,sizeof(*oy)); - } - return(0); -} - -/* -int ogg_sync_destroy(ogg_sync_state *oy){ - if(oy){ - ogg_sync_clear(oy); - _ogg_free(oy); - } - return(0); -} -*/ -static int ogg_sync_check(ogg_sync_state *oy){ - if(oy->storage<0) return -1; - return 0; -} - -char *ogg_sync_buffer(ogg_sync_state *oy, long size){ - if(ogg_sync_check(oy)) return NULL; - - /* first, clear out any space that has been previously returned */ - if(oy->returned){ - oy->fill-=oy->returned; - if(oy->fill>0) - memmove(oy->data,oy->data+oy->returned,oy->fill); - oy->returned=0; - } - - if(size>oy->storage-oy->fill){ - /* We need to extend the internal buffer */ - long newsize=size+oy->fill+4096; /* an extra page to be nice */ - void *ret; - - if(oy->data) - ret=_ogg_realloc(oy->data,newsize); - else - ret=_ogg_malloc(newsize); - if(!ret){ - ogg_sync_clear(oy); - return NULL; - } - oy->data=ret; - oy->storage=newsize; - } - - /* expose a segment at least as large as requested at the fill mark */ - return((char *)oy->data+oy->fill); -} - -int ogg_sync_wrote(ogg_sync_state *oy, long bytes){ - if(ogg_sync_check(oy))return -1; - if(oy->fill+bytes>oy->storage)return -1; - oy->fill+=bytes; - return(0); -} - -/* sync the stream. This is meant to be useful for finding page - boundaries. - - return values for this: - -n) skipped n bytes - 0) page not ready; more data (no bytes skipped) - n) page synced at current location; page length n bytes - -*/ - -long ogg_sync_pageseek(ogg_sync_state *oy,ogg_page *og){ - unsigned char *page=oy->data+oy->returned; - unsigned char *next; - long bytes=oy->fill-oy->returned; - - if(ogg_sync_check(oy))return 0; - - if(oy->headerbytes==0){ - int headerbytes,i; - if(bytes<27)return(0); /* not enough for a header */ - - /* verify capture pattern */ - if(memcmp(page,"OggS",4))goto sync_fail; - - headerbytes=page[26]+27; - if(bytesbodybytes+=page[27+i]; - oy->headerbytes=headerbytes; - } - - if(oy->bodybytes+oy->headerbytes>bytes)return(0); - - /* The whole test page is buffered. Verify the checksum */ - { - /* Grab the checksum bytes, set the header field to zero */ - char chksum[4]; - ogg_page log; - - memcpy(chksum,page+22,4); - memset(page+22,0,4); - - /* set up a temp page struct and recompute the checksum */ - log.header=page; - log.header_len=oy->headerbytes; - log.body=page+oy->headerbytes; - log.body_len=oy->bodybytes; - ogg_page_checksum_set(&log); - - /* Compare */ - if(memcmp(chksum,page+22,4)){ - /* D'oh. Mismatch! Corrupt page (or miscapture and not a page - at all) */ - /* replace the computed checksum with the one actually read in */ - memcpy(page+22,chksum,4); - - /* Bad checksum. Lose sync */ - goto sync_fail; - } - } - - /* yes, have a whole page all ready to go */ - { - unsigned char *page=oy->data+oy->returned; - long bytes; - - if(og){ - og->header=page; - og->header_len=oy->headerbytes; - og->body=page+oy->headerbytes; - og->body_len=oy->bodybytes; - } - - oy->unsynced=0; - oy->returned+=(bytes=oy->headerbytes+oy->bodybytes); - oy->headerbytes=0; - oy->bodybytes=0; - return(bytes); - } - - sync_fail: - - oy->headerbytes=0; - oy->bodybytes=0; - - /* search for possible capture */ - next=memchr(page+1,'O',bytes-1); - if(!next) - next=oy->data+oy->fill; - - oy->returned=(int)(next-oy->data); - return((long)-(next-page)); -} - -/* sync the stream and get a page. Keep trying until we find a page. - Suppress 'sync errors' after reporting the first. - - return values: - -1) recapture (hole in data) - 0) need more data - 1) page returned - - Returns pointers into buffered data; invalidated by next call to - _stream, _clear, _init, or _buffer */ - -#if 0 -int ogg_sync_pageout(ogg_sync_state *oy, ogg_page *og){ - - if(ogg_sync_check(oy))return 0; - - /* all we need to do is verify a page at the head of the stream - buffer. If it doesn't verify, we look for the next potential - frame */ - - for(;;){ - long ret=ogg_sync_pageseek(oy,og); - if(ret>0){ - /* have a page */ - return(1); - } - if(ret==0){ - /* need more data */ - return(0); - } - - /* head did not start a synced page... skipped some bytes */ - if(!oy->unsynced){ - oy->unsynced=1; - return(-1); - } - - /* loop. keep looking */ - - } -} -#endif -/* add the incoming page to the stream state; we decompose the page - into packet segments here as well. */ - -int ogg_stream_pagein(ogg_stream_state *os, ogg_page *og, bool copy_body){ - unsigned char *header=og->header; - unsigned char *body=og->body; - long bodysize=og->body_len; - int segptr=0; - - int version=ogg_page_version(og); - int continued=ogg_page_continued(og); - int bos=ogg_page_bos(og); - int eos=ogg_page_eos(og); - ogg_int64_t granulepos=ogg_page_granulepos(og); - ogg_uint32_t serialno=ogg_page_serialno(og); - long pageno=ogg_page_pageno(og); - int segments=header[26]; - - if(ogg_stream_check(os)) return -1; - - /* clean up 'returned data' */ - { - long lr=os->lacing_returned; - long br=os->body_returned; - - /* body data */ - if(br){ - os->body_fill-=br; - if(os->body_fill) - memmove(os->body_data,os->body_data+br,os->body_fill); - os->body_returned=0; - } - - if(lr){ - /* segment table */ - if(os->lacing_fill-lr){ - memmove(os->lacing_vals,os->lacing_vals+lr, - (os->lacing_fill-lr)*sizeof(*os->lacing_vals)); - memmove(os->granule_vals,os->granule_vals+lr, - (os->lacing_fill-lr)*sizeof(*os->granule_vals)); - } - os->lacing_fill-=lr; - os->lacing_packet-=lr; - os->lacing_returned=0; - } - } - - /* check the serial number */ - if(serialno!=os->serialno)return(-1); - if(version>0)return(-1); - - if(_os_lacing_expand(os,segments+1)) return -1; - - /* are we in sequence? */ - if(pageno!=os->pageno){ - int i; - - /* unroll previous partial packet (if any) */ - for(i=os->lacing_packet;ilacing_fill;i++) - os->body_fill-=os->lacing_vals[i]&0xff; - os->lacing_fill=os->lacing_packet; - - /* make a note of dropped data in segment table */ - if(os->pageno!=-1){ - os->lacing_vals[os->lacing_fill++]=0x400; - os->lacing_packet++; - } - } - - /* are we a 'continued packet' page? If so, we may need to skip - some segments */ - if(continued){ - if(os->lacing_fill<1 || - os->lacing_vals[os->lacing_fill-1]==0x400){ - bos=0; - for(;segptrbody_data+os->body_fill,body,bodysize); - } - os->body_fill+=bodysize; - } - - { - int saved=-1; - while(segptrlacing_vals[os->lacing_fill]=val; - os->granule_vals[os->lacing_fill]=-1; - - if(bos){ - os->lacing_vals[os->lacing_fill]|=0x100; - bos=0; - } - - if(val<255)saved=os->lacing_fill; - - os->lacing_fill++; - segptr++; - - if(val<255)os->lacing_packet=os->lacing_fill; - } - - /* set the granulepos on the last granuleval of the last full packet */ - if(saved!=-1){ - os->granule_vals[saved]=granulepos; - } - - } - - if(eos){ - os->e_o_s=1; - if(os->lacing_fill>0) - os->lacing_vals[os->lacing_fill-1]|=0x200; - } - - os->pageno=pageno+1; - - return(0); -} - -/* clear things to an initial state. Good to call, eg, before seeking */ -int ogg_sync_reset(ogg_sync_state *oy){ - if(ogg_sync_check(oy))return -1; - - oy->fill=0; - oy->returned=0; - oy->unsynced=0; - oy->headerbytes=0; - oy->bodybytes=0; - return(0); -} - -int ogg_stream_reset(ogg_stream_state *os){ - if(ogg_stream_check(os)) return -1; - - os->body_fill=0; - os->body_returned=0; - - os->lacing_fill=0; - os->lacing_packet=0; - os->lacing_returned=0; - -/* os->header_fill=0; */ - - os->e_o_s=0; - os->b_o_s=0; - os->pageno=-1; - os->packetno=0; - os->granulepos=0; - - return(0); -} - -int ogg_stream_reset_serialno(ogg_stream_state *os,int serialno){ - if(ogg_stream_check(os)) return -1; - ogg_stream_reset(os); - os->serialno=serialno; - return(0); -} - -static int _packetout(ogg_stream_state *os,ogg_packet *op,int adv) - ICODE_ATTR_TREMOR_NOT_MDCT; -static int _packetout(ogg_stream_state *os,ogg_packet *op,int adv){ - - /* The last part of decode. We have the stream broken into packet - segments. Now we need to group them into packets (or return the - out of sync markers) */ - - int ptr=os->lacing_returned; - - if(os->lacing_packet<=ptr)return(0); - - if(os->lacing_vals[ptr]&0x400){ - /* we need to tell the codec there's a gap; it might need to - handle previous packet dependencies. */ - os->lacing_returned++; - os->packetno++; - return(-1); - } - - if(!op && !adv)return(1); /* just using peek as an inexpensive way - to ask if there's a whole packet - waiting */ - - /* Gather the whole packet. We'll have no holes or a partial packet */ - { - int size=os->lacing_vals[ptr]&0xff; - long bytes=size; - int eos=os->lacing_vals[ptr]&0x200; /* last packet of the stream? */ - int bos=os->lacing_vals[ptr]&0x100; /* first packet of the stream? */ - - while(size==255){ - int val=os->lacing_vals[++ptr]; - size=val&0xff; - if(val&0x200)eos=0x200; - bytes+=size; - } - - if(op){ - op->e_o_s=eos; - op->b_o_s=bos; - op->packet=os->body_data+os->body_returned; - op->packetno=os->packetno; - op->granulepos=os->granule_vals[ptr]; - op->bytes=bytes; - } - - if(adv){ - os->body_returned+=bytes; - os->lacing_returned=ptr+1; - os->packetno++; - } - } - return(1); -} - -int ogg_stream_packetout(ogg_stream_state *os,ogg_packet *op) - ICODE_ATTR_TREMOR_NOT_MDCT; -int ogg_stream_packetout(ogg_stream_state *os,ogg_packet *op){ - if(ogg_stream_check(os)) return 0; - return _packetout(os,op,1); -} - -int ogg_stream_packetpeek(ogg_stream_state *os,ogg_packet *op) - ICODE_ATTR_TREMOR_NOT_MDCT; -int ogg_stream_packetpeek(ogg_stream_state *os,ogg_packet *op){ - if(ogg_stream_check(os)) return 0; - return _packetout(os,op,0); -} - -/* -void ogg_packet_clear(ogg_packet *op) { - _ogg_free(op->packet); - memset(op, 0, sizeof(*op)); -} -*/ -#ifdef _V_SELFTEST -#include - -ogg_stream_state os_en, os_de; -ogg_sync_state oy; - -void checkpacket(ogg_packet *op,long len, int no, long pos){ - long j; - static int sequence=0; - static int lastno=0; - - if(op->bytes!=len){ - fprintf(stderr,"incorrect packet length (%ld != %ld)!\n",op->bytes,len); - exit(1); - } - if(op->granulepos!=pos){ - fprintf(stderr,"incorrect packet granpos (%ld != %ld)!\n",(long)op->granulepos,pos); - exit(1); - } - - /* packet number just follows sequence/gap; adjust the input number - for that */ - if(no==0){ - sequence=0; - }else{ - sequence++; - if(no>lastno+1) - sequence++; - } - lastno=no; - if(op->packetno!=sequence){ - fprintf(stderr,"incorrect packet sequence %ld != %d\n", - (long)(op->packetno),sequence); - exit(1); - } - - /* Test data */ - for(j=0;jbytes;j++) - if(op->packet[j]!=((j+no)&0xff)){ - fprintf(stderr,"body data mismatch (1) at pos %ld: %x!=%lx!\n\n", - j,op->packet[j],(j+no)&0xff); - exit(1); - } -} - -void check_page(unsigned char *data,const int *header,ogg_page *og){ - long j; - /* Test data */ - for(j=0;jbody_len;j++) - if(og->body[j]!=data[j]){ - fprintf(stderr,"body data mismatch (2) at pos %ld: %x!=%x!\n\n", - j,data[j],og->body[j]); - exit(1); - } - - /* Test header */ - for(j=0;jheader_len;j++){ - if(og->header[j]!=header[j]){ - fprintf(stderr,"header content mismatch at pos %ld:\n",j); - for(j=0;jheader[j]); - fprintf(stderr,"\n"); - exit(1); - } - } - if(og->header_len!=header[26]+27){ - fprintf(stderr,"header length incorrect! (%ld!=%d)\n", - og->header_len,header[26]+27); - exit(1); - } -} - -void print_header(ogg_page *og){ - int j; - fprintf(stderr,"\nHEADER:\n"); - fprintf(stderr," capture: %c %c %c %c version: %d flags: %x\n", - og->header[0],og->header[1],og->header[2],og->header[3], - (int)og->header[4],(int)og->header[5]); - - fprintf(stderr," granulepos: %d serialno: %d pageno: %ld\n", - (og->header[9]<<24)|(og->header[8]<<16)| - (og->header[7]<<8)|og->header[6], - (og->header[17]<<24)|(og->header[16]<<16)| - (og->header[15]<<8)|og->header[14], - ((long)(og->header[21])<<24)|(og->header[20]<<16)| - (og->header[19]<<8)|og->header[18]); - - fprintf(stderr," checksum: %02x:%02x:%02x:%02x\n segments: %d (", - (int)og->header[22],(int)og->header[23], - (int)og->header[24],(int)og->header[25], - (int)og->header[26]); - - for(j=27;jheader_len;j++) - fprintf(stderr,"%d ",(int)og->header[j]); - fprintf(stderr,")\n\n"); -} - -void copy_page(ogg_page *og){ - unsigned char *temp=_ogg_malloc(og->header_len); - memcpy(temp,og->header,og->header_len); - og->header=temp; - - temp=_ogg_malloc(og->body_len); - memcpy(temp,og->body,og->body_len); - og->body=temp; -} - -void free_page(ogg_page *og){ - _ogg_free (og->header); - _ogg_free (og->body); -} - -void error(void){ - fprintf(stderr,"error!\n"); - exit(1); -} - -/* 17 only */ -const int head1_0[] = {0x4f,0x67,0x67,0x53,0,0x06, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x01,0x02,0x03,0x04,0,0,0,0, - 0x15,0xed,0xec,0x91, - 1, - 17}; - -/* 17, 254, 255, 256, 500, 510, 600 byte, pad */ -const int head1_1[] = {0x4f,0x67,0x67,0x53,0,0x02, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x01,0x02,0x03,0x04,0,0,0,0, - 0x59,0x10,0x6c,0x2c, - 1, - 17}; -const int head2_1[] = {0x4f,0x67,0x67,0x53,0,0x04, - 0x07,0x18,0x00,0x00,0x00,0x00,0x00,0x00, - 0x01,0x02,0x03,0x04,1,0,0,0, - 0x89,0x33,0x85,0xce, - 13, - 254,255,0,255,1,255,245,255,255,0, - 255,255,90}; - -/* nil packets; beginning,middle,end */ -const int head1_2[] = {0x4f,0x67,0x67,0x53,0,0x02, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x01,0x02,0x03,0x04,0,0,0,0, - 0xff,0x7b,0x23,0x17, - 1, - 0}; -const int head2_2[] = {0x4f,0x67,0x67,0x53,0,0x04, - 0x07,0x28,0x00,0x00,0x00,0x00,0x00,0x00, - 0x01,0x02,0x03,0x04,1,0,0,0, - 0x5c,0x3f,0x66,0xcb, - 17, - 17,254,255,0,0,255,1,0,255,245,255,255,0, - 255,255,90,0}; - -/* large initial packet */ -const int head1_3[] = {0x4f,0x67,0x67,0x53,0,0x02, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x01,0x02,0x03,0x04,0,0,0,0, - 0x01,0x27,0x31,0xaa, - 18, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255,255,10}; - -const int head2_3[] = {0x4f,0x67,0x67,0x53,0,0x04, - 0x07,0x08,0x00,0x00,0x00,0x00,0x00,0x00, - 0x01,0x02,0x03,0x04,1,0,0,0, - 0x7f,0x4e,0x8a,0xd2, - 4, - 255,4,255,0}; - - -/* continuing packet test */ -const int head1_4[] = {0x4f,0x67,0x67,0x53,0,0x02, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x01,0x02,0x03,0x04,0,0,0,0, - 0xff,0x7b,0x23,0x17, - 1, - 0}; - -const int head2_4[] = {0x4f,0x67,0x67,0x53,0,0x00, - 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, - 0x01,0x02,0x03,0x04,1,0,0,0, - 0xf8,0x3c,0x19,0x79, - 255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255}; - -const int head3_4[] = {0x4f,0x67,0x67,0x53,0,0x05, - 0x07,0x0c,0x00,0x00,0x00,0x00,0x00,0x00, - 0x01,0x02,0x03,0x04,2,0,0,0, - 0x38,0xe6,0xb6,0x28, - 6, - 255,220,255,4,255,0}; - - -/* spill expansion test */ -const int head1_4b[] = {0x4f,0x67,0x67,0x53,0,0x02, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x01,0x02,0x03,0x04,0,0,0,0, - 0xff,0x7b,0x23,0x17, - 1, - 0}; - -const int head2_4b[] = {0x4f,0x67,0x67,0x53,0,0x00, - 0x07,0x10,0x00,0x00,0x00,0x00,0x00,0x00, - 0x01,0x02,0x03,0x04,1,0,0,0, - 0xce,0x8f,0x17,0x1a, - 23, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255,255,10,255,4,255,0,0}; - - -const int head3_4b[] = {0x4f,0x67,0x67,0x53,0,0x04, - 0x07,0x14,0x00,0x00,0x00,0x00,0x00,0x00, - 0x01,0x02,0x03,0x04,2,0,0,0, - 0x9b,0xb2,0x50,0xa1, - 1, - 0}; - -/* page with the 255 segment limit */ -const int head1_5[] = {0x4f,0x67,0x67,0x53,0,0x02, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x01,0x02,0x03,0x04,0,0,0,0, - 0xff,0x7b,0x23,0x17, - 1, - 0}; - -const int head2_5[] = {0x4f,0x67,0x67,0x53,0,0x00, - 0x07,0xfc,0x03,0x00,0x00,0x00,0x00,0x00, - 0x01,0x02,0x03,0x04,1,0,0,0, - 0xed,0x2a,0x2e,0xa7, - 255, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10}; - -const int head3_5[] = {0x4f,0x67,0x67,0x53,0,0x04, - 0x07,0x00,0x04,0x00,0x00,0x00,0x00,0x00, - 0x01,0x02,0x03,0x04,2,0,0,0, - 0x6c,0x3b,0x82,0x3d, - 1, - 50}; - - -/* packet that overspans over an entire page */ -const int head1_6[] = {0x4f,0x67,0x67,0x53,0,0x02, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x01,0x02,0x03,0x04,0,0,0,0, - 0xff,0x7b,0x23,0x17, - 1, - 0}; - -const int head2_6[] = {0x4f,0x67,0x67,0x53,0,0x00, - 0x07,0x04,0x00,0x00,0x00,0x00,0x00,0x00, - 0x01,0x02,0x03,0x04,1,0,0,0, - 0x68,0x22,0x7c,0x3d, - 255, - 100, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255}; - -const int head3_6[] = {0x4f,0x67,0x67,0x53,0,0x01, - 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, - 0x01,0x02,0x03,0x04,2,0,0,0, - 0xf4,0x87,0xba,0xf3, - 255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255}; - -const int head4_6[] = {0x4f,0x67,0x67,0x53,0,0x05, - 0x07,0x10,0x00,0x00,0x00,0x00,0x00,0x00, - 0x01,0x02,0x03,0x04,3,0,0,0, - 0xf7,0x2f,0x6c,0x60, - 5, - 254,255,4,255,0}; - -/* packet that overspans over an entire page */ -const int head1_7[] = {0x4f,0x67,0x67,0x53,0,0x02, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x01,0x02,0x03,0x04,0,0,0,0, - 0xff,0x7b,0x23,0x17, - 1, - 0}; - -const int head2_7[] = {0x4f,0x67,0x67,0x53,0,0x00, - 0x07,0x04,0x00,0x00,0x00,0x00,0x00,0x00, - 0x01,0x02,0x03,0x04,1,0,0,0, - 0x68,0x22,0x7c,0x3d, - 255, - 100, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255}; - -const int head3_7[] = {0x4f,0x67,0x67,0x53,0,0x05, - 0x07,0x08,0x00,0x00,0x00,0x00,0x00,0x00, - 0x01,0x02,0x03,0x04,2,0,0,0, - 0xd4,0xe0,0x60,0xe5, - 1, - 0}; - -void test_pack(const int *pl, const int **headers, int byteskip, - int pageskip, int packetskip){ - unsigned char *data=_ogg_malloc(1024*1024); /* for scripted test cases only */ - long inptr=0; - long outptr=0; - long deptr=0; - long depacket=0; - long granule_pos=7,pageno=0; - int i,j,packets,pageout=pageskip; - int eosflag=0; - int bosflag=0; - - int byteskipcount=0; - - ogg_stream_reset(&os_en); - ogg_stream_reset(&os_de); - ogg_sync_reset(&oy); - - for(packets=0;packetsbyteskip){ - memcpy(next,og.header,byteskipcount-byteskip); - next+=byteskipcount-byteskip; - byteskipcount=byteskip; - } - - byteskipcount+=og.body_len; - if(byteskipcount>byteskip){ - memcpy(next,og.body,byteskipcount-byteskip); - next+=byteskipcount-byteskip; - byteskipcount=byteskip; - } - - ogg_sync_wrote(&oy,next-buf); - - while(1){ - int ret=ogg_sync_pageout(&oy,&og_de); - if(ret==0)break; - if(ret<0)continue; - /* got a page. Happy happy. Verify that it's good. */ - - fprintf(stderr,"(%d), ",pageout); - - check_page(data+deptr,headers[pageout],&og_de); - deptr+=og_de.body_len; - pageout++; - - /* submit it to deconstitution */ - ogg_stream_pagein(&os_de,&og_de); - - /* packets out? */ - while(ogg_stream_packetpeek(&os_de,&op_de2)>0){ - ogg_stream_packetpeek(&os_de,NULL); - ogg_stream_packetout(&os_de,&op_de); /* just catching them all */ - - /* verify peek and out match */ - if(memcmp(&op_de,&op_de2,sizeof(op_de))){ - fprintf(stderr,"packetout != packetpeek! pos=%ld\n", - depacket); - exit(1); - } - - /* verify the packet! */ - /* check data */ - if(memcmp(data+depacket,op_de.packet,op_de.bytes)){ - fprintf(stderr,"packet data mismatch in decode! pos=%ld\n", - depacket); - exit(1); - } - /* check bos flag */ - if(bosflag==0 && op_de.b_o_s==0){ - fprintf(stderr,"b_o_s flag not set on packet!\n"); - exit(1); - } - if(bosflag && op_de.b_o_s){ - fprintf(stderr,"b_o_s flag incorrectly set on packet!\n"); - exit(1); - } - bosflag=1; - depacket+=op_de.bytes; - - /* check eos flag */ - if(eosflag){ - fprintf(stderr,"Multiple decoded packets with eos flag!\n"); - exit(1); - } - - if(op_de.e_o_s)eosflag=1; - - /* check granulepos flag */ - if(op_de.granulepos!=-1){ - fprintf(stderr," granule:%ld ",(long)op_de.granulepos); - } - } - } - } - } - } - } - _ogg_free(data); - if(headers[pageno]!=NULL){ - fprintf(stderr,"did not write last page!\n"); - exit(1); - } - if(headers[pageout]!=NULL){ - fprintf(stderr,"did not decode last page!\n"); - exit(1); - } - if(inptr!=outptr){ - fprintf(stderr,"encoded page data incomplete!\n"); - exit(1); - } - if(inptr!=deptr){ - fprintf(stderr,"decoded page data incomplete!\n"); - exit(1); - } - if(inptr!=depacket){ - fprintf(stderr,"decoded packet data incomplete!\n"); - exit(1); - } - if(!eosflag){ - fprintf(stderr,"Never got a packet with EOS set!\n"); - exit(1); - } - fprintf(stderr,"ok.\n"); -} - -int main(void){ - - ogg_stream_init(&os_en,0x04030201); - ogg_stream_init(&os_de,0x04030201); - ogg_sync_init(&oy); - - /* Exercise each code path in the framing code. Also verify that - the checksums are working. */ - - { - /* 17 only */ - const int packets[]={17, -1}; - const int *headret[]={head1_0,NULL}; - - fprintf(stderr,"testing single page encoding... "); - test_pack(packets,headret,0,0,0); - } - - { - /* 17, 254, 255, 256, 500, 510, 600 byte, pad */ - const int packets[]={17, 254, 255, 256, 500, 510, 600, -1}; - const int *headret[]={head1_1,head2_1,NULL}; - - fprintf(stderr,"testing basic page encoding... "); - test_pack(packets,headret,0,0,0); - } - - { - /* nil packets; beginning,middle,end */ - const int packets[]={0,17, 254, 255, 0, 256, 0, 500, 510, 600, 0, -1}; - const int *headret[]={head1_2,head2_2,NULL}; - - fprintf(stderr,"testing basic nil packets... "); - test_pack(packets,headret,0,0,0); - } - - { - /* large initial packet */ - const int packets[]={4345,259,255,-1}; - const int *headret[]={head1_3,head2_3,NULL}; - - fprintf(stderr,"testing initial-packet lacing > 4k... "); - test_pack(packets,headret,0,0,0); - } - - { - /* continuing packet test; with page spill expansion, we have to - overflow the lacing table. */ - const int packets[]={0,65500,259,255,-1}; - const int *headret[]={head1_4,head2_4,head3_4,NULL}; - - fprintf(stderr,"testing single packet page span... "); - test_pack(packets,headret,0,0,0); - } - - { - /* spill expand packet test */ - const int packets[]={0,4345,259,255,0,0,-1}; - const int *headret[]={head1_4b,head2_4b,head3_4b,NULL}; - - fprintf(stderr,"testing page spill expansion... "); - test_pack(packets,headret,0,0,0); - } - - /* page with the 255 segment limit */ - { - - const int packets[]={0,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,50,-1}; - const int *headret[]={head1_5,head2_5,head3_5,NULL}; - - fprintf(stderr,"testing max packet segments... "); - test_pack(packets,headret,0,0,0); - } - - { - /* packet that overspans over an entire page */ - const int packets[]={0,100,130049,259,255,-1}; - const int *headret[]={head1_6,head2_6,head3_6,head4_6,NULL}; - - fprintf(stderr,"testing very large packets... "); - test_pack(packets,headret,0,0,0); - } - - { - /* test for the libogg 1.1.1 resync in large continuation bug - found by Josh Coalson) */ - const int packets[]={0,100,130049,259,255,-1}; - const int *headret[]={head1_6,head2_6,head3_6,head4_6,NULL}; - - fprintf(stderr,"testing continuation resync in very large packets... "); - test_pack(packets,headret,100,2,3); - } - - { - /* term only page. why not? */ - const int packets[]={0,100,64770,-1}; - const int *headret[]={head1_7,head2_7,head3_7,NULL}; - - fprintf(stderr,"testing zero data page (1 nil packet)... "); - test_pack(packets,headret,0,0,0); - } - - - - { - /* build a bunch of pages for testing */ - unsigned char *data=_ogg_malloc(1024*1024); - int pl[]={0, 1,1,98,4079, 1,1,2954,2057, 76,34,912,0,234,1000,1000, 1000,300,-1}; - int inptr=0,i,j; - ogg_page og[5]; - - ogg_stream_reset(&os_en); - - for(i=0;pl[i]!=-1;i++){ - ogg_packet op; - int len=pl[i]; - - op.packet=data+inptr; - op.bytes=len; - op.e_o_s=(pl[i+1]<0?1:0); - op.granulepos=(i+1)*1000; - - for(j=0;j0)error(); - - /* Test fractional page inputs: incomplete fixed header */ - memcpy(ogg_sync_buffer(&oy,og[1].header_len),og[1].header+3, - 20); - ogg_sync_wrote(&oy,20); - if(ogg_sync_pageout(&oy,&og_de)>0)error(); - - /* Test fractional page inputs: incomplete header */ - memcpy(ogg_sync_buffer(&oy,og[1].header_len),og[1].header+23, - 5); - ogg_sync_wrote(&oy,5); - if(ogg_sync_pageout(&oy,&og_de)>0)error(); - - /* Test fractional page inputs: incomplete body */ - - memcpy(ogg_sync_buffer(&oy,og[1].header_len),og[1].header+28, - og[1].header_len-28); - ogg_sync_wrote(&oy,og[1].header_len-28); - if(ogg_sync_pageout(&oy,&og_de)>0)error(); - - memcpy(ogg_sync_buffer(&oy,og[1].body_len),og[1].body,1000); - ogg_sync_wrote(&oy,1000); - if(ogg_sync_pageout(&oy,&og_de)>0)error(); - - memcpy(ogg_sync_buffer(&oy,og[1].body_len),og[1].body+1000, - og[1].body_len-1000); - ogg_sync_wrote(&oy,og[1].body_len-1000); - if(ogg_sync_pageout(&oy,&og_de)<=0)error(); - - fprintf(stderr,"ok.\n"); - } - - /* Test fractional page inputs: page + incomplete capture */ - { - ogg_page og_de; - fprintf(stderr,"Testing sync on 1+partial inputs... "); - ogg_sync_reset(&oy); - - memcpy(ogg_sync_buffer(&oy,og[1].header_len),og[1].header, - og[1].header_len); - ogg_sync_wrote(&oy,og[1].header_len); - - memcpy(ogg_sync_buffer(&oy,og[1].body_len),og[1].body, - og[1].body_len); - ogg_sync_wrote(&oy,og[1].body_len); - - memcpy(ogg_sync_buffer(&oy,og[1].header_len),og[1].header, - 20); - ogg_sync_wrote(&oy,20); - if(ogg_sync_pageout(&oy,&og_de)<=0)error(); - if(ogg_sync_pageout(&oy,&og_de)>0)error(); - - memcpy(ogg_sync_buffer(&oy,og[1].header_len),og[1].header+20, - og[1].header_len-20); - ogg_sync_wrote(&oy,og[1].header_len-20); - memcpy(ogg_sync_buffer(&oy,og[1].body_len),og[1].body, - og[1].body_len); - ogg_sync_wrote(&oy,og[1].body_len); - if(ogg_sync_pageout(&oy,&og_de)<=0)error(); - - fprintf(stderr,"ok.\n"); - } - - /* Test recapture: garbage + page */ - { - ogg_page og_de; - fprintf(stderr,"Testing search for capture... "); - ogg_sync_reset(&oy); - - /* 'garbage' */ - memcpy(ogg_sync_buffer(&oy,og[1].body_len),og[1].body, - og[1].body_len); - ogg_sync_wrote(&oy,og[1].body_len); - - memcpy(ogg_sync_buffer(&oy,og[1].header_len),og[1].header, - og[1].header_len); - ogg_sync_wrote(&oy,og[1].header_len); - - memcpy(ogg_sync_buffer(&oy,og[1].body_len),og[1].body, - og[1].body_len); - ogg_sync_wrote(&oy,og[1].body_len); - - memcpy(ogg_sync_buffer(&oy,og[2].header_len),og[2].header, - 20); - ogg_sync_wrote(&oy,20); - if(ogg_sync_pageout(&oy,&og_de)>0)error(); - if(ogg_sync_pageout(&oy,&og_de)<=0)error(); - if(ogg_sync_pageout(&oy,&og_de)>0)error(); - - memcpy(ogg_sync_buffer(&oy,og[2].header_len),og[2].header+20, - og[2].header_len-20); - ogg_sync_wrote(&oy,og[2].header_len-20); - memcpy(ogg_sync_buffer(&oy,og[2].body_len),og[2].body, - og[2].body_len); - ogg_sync_wrote(&oy,og[2].body_len); - if(ogg_sync_pageout(&oy,&og_de)<=0)error(); - - fprintf(stderr,"ok.\n"); - } - - /* Test recapture: page + garbage + page */ - { - ogg_page og_de; - fprintf(stderr,"Testing recapture... "); - ogg_sync_reset(&oy); - - memcpy(ogg_sync_buffer(&oy,og[1].header_len),og[1].header, - og[1].header_len); - ogg_sync_wrote(&oy,og[1].header_len); - - memcpy(ogg_sync_buffer(&oy,og[1].body_len),og[1].body, - og[1].body_len); - ogg_sync_wrote(&oy,og[1].body_len); - - memcpy(ogg_sync_buffer(&oy,og[2].header_len),og[2].header, - og[2].header_len); - ogg_sync_wrote(&oy,og[2].header_len); - - memcpy(ogg_sync_buffer(&oy,og[2].header_len),og[2].header, - og[2].header_len); - ogg_sync_wrote(&oy,og[2].header_len); - - if(ogg_sync_pageout(&oy,&og_de)<=0)error(); - - memcpy(ogg_sync_buffer(&oy,og[2].body_len),og[2].body, - og[2].body_len-5); - ogg_sync_wrote(&oy,og[2].body_len-5); - - memcpy(ogg_sync_buffer(&oy,og[3].header_len),og[3].header, - og[3].header_len); - ogg_sync_wrote(&oy,og[3].header_len); - - memcpy(ogg_sync_buffer(&oy,og[3].body_len),og[3].body, - og[3].body_len); - ogg_sync_wrote(&oy,og[3].body_len); - - if(ogg_sync_pageout(&oy,&og_de)>0)error(); - if(ogg_sync_pageout(&oy,&og_de)<=0)error(); - - fprintf(stderr,"ok.\n"); - } - - /* Free page data that was previously copied */ - { - for(i=0;i<5;i++){ - free_page(&og[i]); - } - } - } - - return(0); -} - -#endif - - - - diff --git a/apps/codecs/libtremor/info.c b/apps/codecs/libtremor/info.c deleted file mode 100644 index d922711e34..0000000000 --- a/apps/codecs/libtremor/info.c +++ /dev/null @@ -1,330 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * - * * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2003 * - * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * - * * - ******************************************************************** - - function: maintain the info structure, info <-> header packets - - ********************************************************************/ - -/* general handling of the header and the vorbis_info structure (and - substructures) */ - -#include "config-tremor.h" -#include -#include -#include "ogg.h" -#include "ivorbiscodec.h" -#include "codec_internal.h" -#include "codebook.h" -#include "registry.h" -#include "window.h" -#include "misc.h" -#include "os.h" - -/* helpers */ -static void _v_readstring(oggpack_buffer *o,char *buf,int bytes){ - while(bytes--){ - *buf++=oggpack_read(o,8); - } -} - -/* -void vorbis_comment_init(vorbis_comment *vc){ - memset(vc,0,sizeof(*vc)); -} - -void vorbis_comment_clear(vorbis_comment *vc){ - if(vc){ - long i; - if(vc->user_comments){ - for(i=0;icomments;i++) - if(vc->user_comments[i])_ogg_free(vc->user_comments[i]); - _ogg_free(vc->user_comments); - } - if(vc->comment_lengths)_ogg_free(vc->comment_lengths); - if(vc->vendor)_ogg_free(vc->vendor); - memset(vc,0,sizeof(*vc)); - } -} -*/ - -/* blocksize 0 is guaranteed to be short, 1 is guarantted to be long. - They may be equal, but short will never ge greater than long */ -int vorbis_info_blocksize(vorbis_info *vi,int zo){ - codec_setup_info *ci = (codec_setup_info *)vi->codec_setup; - return ci ? ci->blocksizes[zo] : -1; -} - -/* used by synthesis, which has a full, alloced vi */ -void vorbis_info_init(vorbis_info *vi){ - memset(vi,0,sizeof(*vi)); - vi->codec_setup=(codec_setup_info *)_ogg_calloc(1,sizeof(codec_setup_info)); -} - -void vorbis_info_clear(vorbis_info *vi){ - codec_setup_info *ci=(codec_setup_info *)vi->codec_setup; - int i; - - if(ci){ - - for(i=0;imodes;i++) - if(ci->mode_param[i])_ogg_free(ci->mode_param[i]); - - for(i=0;imaps;i++) /* unpack does the range checking */ - if(ci->map_param[i]) - _mapping_P[ci->map_type[i]]->free_info(ci->map_param[i]); - - for(i=0;ifloors;i++) /* unpack does the range checking */ - if(ci->floor_param[i]) - _floor_P[ci->floor_type[i]]->free_info(ci->floor_param[i]); - - for(i=0;iresidues;i++) /* unpack does the range checking */ - if(ci->residue_param[i]) - _residue_P[ci->residue_type[i]]->free_info(ci->residue_param[i]); - - for(i=0;ibooks;i++){ - if(ci->book_param[i]){ - /* knows if the book was not alloced */ - vorbis_staticbook_destroy(ci->book_param[i]); - } - if(ci->fullbooks) - vorbis_book_clear(ci->fullbooks+i); - } - if(ci->fullbooks) - _ogg_free(ci->fullbooks); - - _ogg_free(ci); - } - - memset(vi,0,sizeof(*vi)); -} - -/* Header packing/unpacking ********************************************/ - -static int _vorbis_unpack_info(vorbis_info *vi,oggpack_buffer *opb){ - codec_setup_info *ci=(codec_setup_info *)vi->codec_setup; - if(!ci)return(OV_EFAULT); - - vi->version=oggpack_read(opb,32); - if(vi->version!=0)return(OV_EVERSION); - - vi->channels=oggpack_read(opb,8); - vi->rate=oggpack_read(opb,32); - - vi->bitrate_upper=oggpack_read(opb,32); - vi->bitrate_nominal=oggpack_read(opb,32); - vi->bitrate_lower=oggpack_read(opb,32); - - ci->blocksizes_nbits[0]=oggpack_read(opb,4); - ci->blocksizes_nbits[1]=oggpack_read(opb,4); - ci->blocksizes[0]=1<<(ci->blocksizes_nbits[0]); - ci->blocksizes[1]=1<<(ci->blocksizes_nbits[1]); - - if(vi->rate<1)goto err_out; - if(vi->channels<1)goto err_out; - if(ci->blocksizes[0]<64)goto err_out; - if(ci->blocksizes[1]blocksizes[0])goto err_out; - if(ci->blocksizes[1]>8192)goto err_out; - - if(oggpack_read(opb,1)!=1)goto err_out; /* EOP check */ - - return(0); - err_out: - vorbis_info_clear(vi); - return(OV_EBADHEADER); -} - -#if 0 -static int _vorbis_unpack_comment(vorbis_comment *vc,oggpack_buffer *opb){ - int vendorlen; - vendorlen=oggpack_read(opb,32); - if(vendorlen<0)goto err_out; - if(vendorlen>opb->storage-oggpack_bytes(opb))goto err_out; - vc->vendor=(char *)_ogg_calloc(vendorlen+1,1); - if(vc->vendor==NULL)goto err_out; - _v_readstring(opb,vc->vendor,vendorlen); - vc->comments=0; - /* ROCKBOX: the meat of this function was deleted as we don't need it */ - return(0); - err_out: - vorbis_comment_clear(vc); - return(OV_EBADHEADER); -} -#endif - -/* all of the real encoding details are here. The modes, books, - everything */ -static int _vorbis_unpack_books(vorbis_info *vi,oggpack_buffer *opb){ - codec_setup_info *ci=(codec_setup_info *)vi->codec_setup; - int i; - if(!ci)return(OV_EFAULT); - - /* codebooks */ - ci->books=oggpack_read(opb,8)+1; - if(ci->books<=0)goto err_out; - for(i=0;ibooks;i++){ - ci->book_param[i]=vorbis_staticbook_unpack(opb); - if(!ci->book_param[i])goto err_out; - } - - /* time backend settings */ - ci->times=oggpack_read(opb,6)+1; - if(ci->times<=0)goto err_out; - for(i=0;itimes;i++){ - ci->time_type[i]=oggpack_read(opb,16); - if(ci->time_type[i]<0 || ci->time_type[i]>=VI_TIMEB)goto err_out; - /* ci->time_param[i]=_time_P[ci->time_type[i]]->unpack(vi,opb); - Vorbis I has no time backend */ - /*if(!ci->time_param[i])goto err_out;*/ - } - - /* floor backend settings */ - ci->floors=oggpack_read(opb,6)+1; - if(ci->floors<=0)goto err_out; - for(i=0;ifloors;i++){ - ci->floor_type[i]=oggpack_read(opb,16); - if(ci->floor_type[i]<0 || ci->floor_type[i]>=VI_FLOORB)goto err_out; - ci->floor_param[i]=_floor_P[ci->floor_type[i]]->unpack(vi,opb); - if(!ci->floor_param[i])goto err_out; - } - - /* residue backend settings */ - ci->residues=oggpack_read(opb,6)+1; - if(ci->residues<=0)goto err_out; - for(i=0;iresidues;i++){ - ci->residue_type[i]=oggpack_read(opb,16); - if(ci->residue_type[i]<0 || ci->residue_type[i]>=VI_RESB)goto err_out; - ci->residue_param[i]=_residue_P[ci->residue_type[i]]->unpack(vi,opb); - if(!ci->residue_param[i])goto err_out; - } - - /* map backend settings */ - ci->maps=oggpack_read(opb,6)+1; - if(ci->maps<=0)goto err_out; - for(i=0;imaps;i++){ - ci->map_type[i]=oggpack_read(opb,16); - if(ci->map_type[i]<0 || ci->map_type[i]>=VI_MAPB)goto err_out; - ci->map_param[i]=_mapping_P[ci->map_type[i]]->unpack(vi,opb); - if(!ci->map_param[i])goto err_out; - } - - /* mode settings */ - ci->modes=oggpack_read(opb,6)+1; - if(ci->modes<=0)goto err_out; - for(i=0;imodes;i++){ - ci->mode_param[i]=(vorbis_info_mode *)_ogg_calloc(1,sizeof(*ci->mode_param[i])); - ci->mode_param[i]->blockflag=oggpack_read(opb,1); - ci->mode_param[i]->windowtype=oggpack_read(opb,16); - ci->mode_param[i]->transformtype=oggpack_read(opb,16); - ci->mode_param[i]->mapping=oggpack_read(opb,8); - - if(ci->mode_param[i]->windowtype>=VI_WINDOWB)goto err_out; - if(ci->mode_param[i]->transformtype>=VI_WINDOWB)goto err_out; - if(ci->mode_param[i]->mapping>=ci->maps)goto err_out; - if(ci->mode_param[i]->mapping<0)goto err_out; - } - - if(oggpack_read(opb,1)!=1)goto err_out; /* top level EOP check */ - - return(0); - err_out: - vorbis_info_clear(vi); - return(OV_EBADHEADER); -} - -/* Is this packet a vorbis ID header? */ -int vorbis_synthesis_idheader(ogg_packet *op){ - oggpack_buffer opb; - char buffer[6]; - - if(op){ - oggpack_readinit(&opb,op->packet,op->bytes); - - if(!op->b_o_s) - return(0); /* Not the initial packet */ - - if(oggpack_read(&opb,8) != 1) - return 0; /* not an ID header */ - - memset(buffer,0,6); - _v_readstring(&opb,buffer,6); - if(memcmp(buffer,"vorbis",6)) - return 0; /* not vorbis */ - - return 1; - } - - return 0; -} - -/* The Vorbis header is in three packets; the initial small packet in - the first page that identifies basic parameters, a second packet - with bitstream comments and a third packet that holds the - codebook. */ - -int vorbis_synthesis_headerin(vorbis_info *vi,ogg_packet *op){ - oggpack_buffer opb; - - if(op){ - oggpack_readinit(&opb,op->packet,op->bytes); - - /* Which of the three types of header is this? */ - /* Also verify header-ness, vorbis */ - { - char buffer[6]; - int packtype=oggpack_read(&opb,8); - memset(buffer,0,6); - _v_readstring(&opb,buffer,6); - if(memcmp(buffer,"vorbis",6)){ - /* not a vorbis header */ - return(OV_ENOTVORBIS); - } - switch(packtype){ - case 0x01: /* least significant *bit* is read first */ - if(!op->b_o_s){ - /* Not the initial packet */ - return(OV_EBADHEADER); - } - if(vi->rate!=0){ - /* previously initialized info header */ - return(OV_EBADHEADER); - } - - return(_vorbis_unpack_info(vi,&opb)); - - case 0x03: /* least significant *bit* is read first */ - if(vi->rate==0){ - /* um... we didn't get the initial header */ - return(OV_EBADHEADER); - } - - /*return(_vorbis_unpack_comment(vc,&opb));*/ - return 0; - - case 0x05: /* least significant *bit* is read first */ - if(vi->rate==0 /*|| vc->vendor==NULL*/){ - /* um... we didn;t get the initial header or comments yet */ - return(OV_EBADHEADER); - } - - return(_vorbis_unpack_books(vi,&opb)); - - default: - /* Not a valid vorbis header type */ - return(OV_EBADHEADER); - break; - } - } - } - return(OV_EBADHEADER); -} - diff --git a/apps/codecs/libtremor/ivorbiscodec.h b/apps/codecs/libtremor/ivorbiscodec.h deleted file mode 100644 index 4fb041603d..0000000000 --- a/apps/codecs/libtremor/ivorbiscodec.h +++ /dev/null @@ -1,204 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * - * * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * - * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * - * * - ******************************************************************** - - function: libvorbis codec headers - - ********************************************************************/ - -#ifndef _vorbis_codec_h_ -#define _vorbis_codec_h_ - -#ifdef __cplusplus -extern "C" -{ -#endif /* __cplusplus */ - -#include "ogg.h" -//#include - -typedef struct vorbis_info{ - int version; - int channels; - long rate; - - /* The below bitrate declarations are *hints*. - Combinations of the three values carry the following implications: - - all three set to the same value: - implies a fixed rate bitstream - only nominal set: - implies a VBR stream that averages the nominal bitrate. No hard - upper/lower limit - upper and or lower set: - implies a VBR bitstream that obeys the bitrate limits. nominal - may also be set to give a nominal rate. - none set: - the coder does not care to speculate. - */ - - long bitrate_upper; - long bitrate_nominal; - long bitrate_lower; - - void *codec_setup; -} vorbis_info; - -/* vorbis_dsp_state buffers the current vorbis audio - analysis/synthesis state. The DSP state belongs to a specific - logical bitstream ****************************************************/ -typedef struct vorbis_dsp_state{ - vorbis_info *vi; - - ogg_int32_t *residues[2]; - ogg_int32_t *floors; - ogg_int32_t *saved; - ogg_int32_t *saved_ptr[CHANNELS]; - - int ri; - - ogg_int32_t **pcmb; - ogg_int32_t **pcmret; - int pcm_storage; - int pcm_current; - int pcm_returned; - - int eofflag; - - long lW; - long W; - long nW; - - ogg_int64_t granulepos; - ogg_int64_t sequence; - - void *backend_state; -} vorbis_dsp_state; - -typedef struct vorbis_block{ - /* necessary stream state for linking to the framing abstraction */ - oggpack_buffer opb; - - long lW; - long W; - long nW; - int pcmend; - int mode; - - int eofflag; - ogg_int64_t granulepos; - ogg_int64_t sequence; - vorbis_dsp_state *vd; /* For read-only access of configuration */ - - /* local storage to avoid remallocing; it's up to the mapping to - structure it */ - void *localstore; - long localtop; - long localalloc; - long totaluse; - struct alloc_chain *reap; -} vorbis_block; - -/* vorbis_block is a single block of data to be processed as part of -the analysis/synthesis stream; it belongs to a specific logical -bitstream, but is independant from other vorbis_blocks belonging to -that logical bitstream. *************************************************/ - -struct alloc_chain{ - void *ptr; - struct alloc_chain *next; -}; - -/* vorbis_info contains all the setup information specific to the - specific compression/decompression mode in progress (eg, - psychoacoustic settings, channel setup, options, codebook - etc). vorbis_info and substructures are in backends.h. -*********************************************************************/ - -/* the comments are not part of vorbis_info so that vorbis_info can be - static storage */ -typedef struct vorbis_comment{ - /* unlimited user comment fields. libvorbis writes 'libvorbis' - whatever vendor is set to in encode */ - char **user_comments; - int *comment_lengths; - int comments; - char *vendor; - -} vorbis_comment; - - -/* libvorbis encodes in two abstraction layers; first we perform DSP - and produce a packet (see docs/analysis.txt). The packet is then - coded into a framed OggSquish bitstream by the second layer (see - docs/framing.txt). Decode is the reverse process; we sync/frame - the bitstream and extract individual packets, then decode the - packet back into PCM audio. - - The extra framing/packetizing is used in streaming formats, such as - files. Over the net (such as with UDP), the framing and - packetization aren't necessary as they're provided by the transport - and the streaming layer is not used */ - -/* Vorbis PRIMITIVES: general ***************************************/ - -extern void vorbis_info_init(vorbis_info *vi); -extern void vorbis_info_clear(vorbis_info *vi); -extern int vorbis_info_blocksize(vorbis_info *vi,int zo); -/* -extern void vorbis_comment_init(vorbis_comment *vc); -extern void vorbis_comment_add(vorbis_comment *vc, char *comment); -extern void vorbis_comment_add_tag(vorbis_comment *vc, - char *tag, char *contents); -extern void vorbis_comment_clear(vorbis_comment *vc); -*/ -extern int vorbis_block_init(vorbis_dsp_state *v, vorbis_block *vb); -extern int vorbis_block_clear(vorbis_block *vb); -extern void vorbis_dsp_clear(vorbis_dsp_state *v); - -/* Vorbis PRIMITIVES: synthesis layer *******************************/ -extern int vorbis_synthesis_idheader(ogg_packet *op); -extern int vorbis_synthesis_headerin(vorbis_info *vi,ogg_packet *op); - -extern int vorbis_synthesis_init(vorbis_dsp_state *v,vorbis_info *vi); -extern int vorbis_synthesis_restart(vorbis_dsp_state *v); -extern int vorbis_synthesis(vorbis_block *vb,ogg_packet *op); -extern int vorbis_synthesis_trackonly(vorbis_block *vb,ogg_packet *op); -extern int vorbis_synthesis_blockin(vorbis_dsp_state *v,vorbis_block *vb); -extern int vorbis_synthesis_pcmout(vorbis_dsp_state *v,ogg_int32_t ***pcm); -extern int vorbis_synthesis_read(vorbis_dsp_state *v,int samples); -extern long vorbis_packet_blocksize(vorbis_info *vi,ogg_packet *op); - -/* Vorbis ERRORS and return codes ***********************************/ - -#define OV_FALSE -1 -#define OV_EOF -2 -#define OV_HOLE -3 - -#define OV_EREAD -128 -#define OV_EFAULT -129 -#define OV_EIMPL -130 -#define OV_EINVAL -131 -#define OV_ENOTVORBIS -132 -#define OV_EBADHEADER -133 -#define OV_EVERSION -134 -#define OV_ENOTAUDIO -135 -#define OV_EBADPACKET -136 -#define OV_EBADLINK -137 -#define OV_ENOSEEK -138 - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif - diff --git a/apps/codecs/libtremor/ivorbisfile.h b/apps/codecs/libtremor/ivorbisfile.h deleted file mode 100644 index 076783514e..0000000000 --- a/apps/codecs/libtremor/ivorbisfile.h +++ /dev/null @@ -1,131 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * - * * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * - * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * - * * - ******************************************************************** - - function: stdio-based convenience library for opening/seeking/decoding - - ********************************************************************/ - -#ifndef _OV_FILE_H_ -#define _OV_FILE_H_ - -#ifdef __cplusplus -extern "C" -{ -#endif /* __cplusplus */ - -#include -#include "ivorbiscodec.h" - - -#define CHUNKSIZE 1024 -/* The function prototypes for the callbacks are basically the same as for - * the stdio functions fread, fseek, fclose, ftell. - * The one difference is that the FILE * arguments have been replaced with - * a void * - this is to be used as a pointer to whatever internal data these - * functions might need. In the stdio case, it's just a FILE * cast to a void * - * - * If you use other functions, check the docs for these functions and return - * the right values. For seek_func(), you *MUST* return -1 if the stream is - * unseekable - */ -typedef struct { - size_t (*read_func) (void *ptr, size_t size, size_t nmemb, void *datasource); - int (*seek_func) (void *datasource, ogg_int64_t offset, int whence); - int (*close_func) (void *datasource); - long (*tell_func) (void *datasource); -} ov_callbacks; - -#define NOTOPEN 0 -#define PARTOPEN 1 -#define OPENED 2 -#define STREAMSET 3 -#define INITSET 4 - -typedef struct OggVorbis_File { - void *datasource; /* Pointer to a FILE *, etc. */ - int seekable; - ogg_int64_t offset; - ogg_int64_t end; - ogg_sync_state oy; - - /* If the FILE handle isn't seekable (eg, a pipe), only the current - stream appears */ - int links; - ogg_int64_t *offsets; - ogg_int64_t *dataoffsets; - ogg_uint32_t *serialnos; - ogg_int64_t *pcmlengths; - vorbis_info *vi; -/* vorbis_comment *vc; */ - - /* Decoding working state local storage */ - ogg_int64_t pcm_offset; - int ready_state; - ogg_uint32_t current_serialno; - int current_link; - - ogg_int64_t bittrack; - ogg_int64_t samptrack; - - ogg_stream_state os; /* take physical pages, weld into a logical - stream of packets */ - vorbis_dsp_state vd; /* central working state for the packet->PCM decoder */ - vorbis_block vb; /* local working space for packet->PCM decode */ - - ov_callbacks callbacks; - -} OggVorbis_File; - -extern int ov_clear(OggVorbis_File *vf); -extern int ov_open_callbacks(void *datasource, OggVorbis_File *vf, - const char *initial, long ibytes, ov_callbacks callbacks); - -extern int ov_test_callbacks(void *datasource, OggVorbis_File *vf, - const char *initial, long ibytes, ov_callbacks callbacks); -extern int ov_test_open(OggVorbis_File *vf); - -extern long ov_bitrate(OggVorbis_File *vf,int i); -extern long ov_bitrate_instant(OggVorbis_File *vf); -extern long ov_streams(OggVorbis_File *vf); -extern long ov_seekable(OggVorbis_File *vf); -extern long ov_serialnumber(OggVorbis_File *vf,int i); - -extern ogg_int64_t ov_raw_total(OggVorbis_File *vf,int i); -extern ogg_int64_t ov_pcm_total(OggVorbis_File *vf,int i); -extern ogg_int64_t ov_time_total(OggVorbis_File *vf,int i); - -extern int ov_raw_seek(OggVorbis_File *vf,ogg_int64_t pos); -extern int ov_pcm_seek(OggVorbis_File *vf,ogg_int64_t pos); -extern int ov_pcm_seek_page(OggVorbis_File *vf,ogg_int64_t pos); -extern int ov_time_seek(OggVorbis_File *vf,ogg_int64_t pos); -extern int ov_time_seek_page(OggVorbis_File *vf,ogg_int64_t pos); - -extern ogg_int64_t ov_raw_tell(OggVorbis_File *vf); -extern ogg_int64_t ov_pcm_tell(OggVorbis_File *vf); -extern ogg_int64_t ov_time_tell(OggVorbis_File *vf); - -extern vorbis_info *ov_info(OggVorbis_File *vf,int link); -extern vorbis_comment *ov_comment(OggVorbis_File *vf,int link); - -extern long ov_read(OggVorbis_File *vf,char *buffer,int length, - int *bitstream); -extern long ov_read_fixed(OggVorbis_File *vf,ogg_int32_t ***pcm_channels, - int length,int *bitstream); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif - - diff --git a/apps/codecs/libtremor/libtremor.make b/apps/codecs/libtremor/libtremor.make deleted file mode 100644 index 586c703346..0000000000 --- a/apps/codecs/libtremor/libtremor.make +++ /dev/null @@ -1,18 +0,0 @@ -# __________ __ ___. -# Open \______ \ ____ ____ | | _\_ |__ _______ ___ -# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / -# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < -# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ -# \/ \/ \/ \/ \/ -# $Id$ -# - -# libtremor -TREMORLIB := $(CODECDIR)/libtremor.a -TREMORLIB_SRC := $(call preprocess, $(APPSDIR)/codecs/libtremor/SOURCES) -TREMORLIB_OBJ := $(call c2obj, $(TREMORLIB_SRC)) -OTHER_SRC += $(TREMORLIB_SRC) - -$(TREMORLIB): $(TREMORLIB_OBJ) - $(SILENT)$(shell rm -f $@) - $(call PRINTS,AR $(@F))$(AR) rcs $@ $^ >/dev/null diff --git a/apps/codecs/libtremor/lsp_lookup.h b/apps/codecs/libtremor/lsp_lookup.h deleted file mode 100644 index d996677ca1..0000000000 --- a/apps/codecs/libtremor/lsp_lookup.h +++ /dev/null @@ -1,132 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * - * * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * - * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * - * * - ******************************************************************** - - function: lookup data - - ********************************************************************/ - -#ifndef _V_LOOKUP_DATA_H_ -#define _V_LOOKUP_DATA_H_ - -#include "os_types.h" - -#define FROMdB_LOOKUP_SZ 35 -#define FROMdB2_LOOKUP_SZ 32 -#define FROMdB_SHIFT 5 -#define FROMdB2_SHIFT 3 -#define FROMdB2_MASK 31 - -static const ogg_int32_t FROMdB_LOOKUP[FROMdB_LOOKUP_SZ] ={ - 0x003fffff, 0x0028619b, 0x00197a96, 0x0010137a, - 0x000a24b0, 0x00066666, 0x000409c3, 0x00028c42, - 0x00019b8c, 0x000103ab, 0x0000a3d7, 0x00006760, - 0x0000413a, 0x00002928, 0x000019f8, 0x00001062, - 0x00000a56, 0x00000686, 0x0000041e, 0x00000299, - 0x000001a3, 0x00000109, 0x000000a7, 0x00000069, - 0x00000042, 0x0000002a, 0x0000001a, 0x00000011, - 0x0000000b, 0x00000007, 0x00000004, 0x00000003, - 0x00000002, 0x00000001, 0x00000001}; - -static const ogg_int32_t FROMdB2_LOOKUP[FROMdB2_LOOKUP_SZ] ={ - 0x000001fc, 0x000001f5, 0x000001ee, 0x000001e7, - 0x000001e0, 0x000001d9, 0x000001d2, 0x000001cc, - 0x000001c5, 0x000001bf, 0x000001b8, 0x000001b2, - 0x000001ac, 0x000001a6, 0x000001a0, 0x0000019a, - 0x00000194, 0x0000018e, 0x00000188, 0x00000183, - 0x0000017d, 0x00000178, 0x00000172, 0x0000016d, - 0x00000168, 0x00000163, 0x0000015e, 0x00000159, - 0x00000154, 0x0000014f, 0x0000014a, 0x00000145, -}; - -#define INVSQ_LOOKUP_I_SHIFT 10 -#define INVSQ_LOOKUP_I_MASK 1023 -static const long INVSQ_LOOKUP_I[64+1] ={ - 92682, 91966, 91267, 90583, - 89915, 89261, 88621, 87995, - 87381, 86781, 86192, 85616, - 85051, 84497, 83953, 83420, - 82897, 82384, 81880, 81385, - 80899, 80422, 79953, 79492, - 79039, 78594, 78156, 77726, - 77302, 76885, 76475, 76072, - 75674, 75283, 74898, 74519, - 74146, 73778, 73415, 73058, - 72706, 72359, 72016, 71679, - 71347, 71019, 70695, 70376, - 70061, 69750, 69444, 69141, - 68842, 68548, 68256, 67969, - 67685, 67405, 67128, 66855, - 66585, 66318, 66054, 65794, - 65536, -}; - -static const long INVSQ_LOOKUP_IDel[64] ={ - 716, 699, 684, 668, - 654, 640, 626, 614, - 600, 589, 576, 565, - 554, 544, 533, 523, - 513, 504, 495, 486, - 477, 469, 461, 453, - 445, 438, 430, 424, - 417, 410, 403, 398, - 391, 385, 379, 373, - 368, 363, 357, 352, - 347, 343, 337, 332, - 328, 324, 319, 315, - 311, 306, 303, 299, - 294, 292, 287, 284, - 280, 277, 273, 270, - 267, 264, 260, 258, -}; - -#define COS_LOOKUP_I_SHIFT 9 -#define COS_LOOKUP_I_MASK 511 -#define COS_LOOKUP_I_SZ 128 -static const ogg_int32_t COS_LOOKUP_I[COS_LOOKUP_I_SZ+1] ={ - 16384, 16379, 16364, 16340, - 16305, 16261, 16207, 16143, - 16069, 15986, 15893, 15791, - 15679, 15557, 15426, 15286, - 15137, 14978, 14811, 14635, - 14449, 14256, 14053, 13842, - 13623, 13395, 13160, 12916, - 12665, 12406, 12140, 11866, - 11585, 11297, 11003, 10702, - 10394, 10080, 9760, 9434, - 9102, 8765, 8423, 8076, - 7723, 7366, 7005, 6639, - 6270, 5897, 5520, 5139, - 4756, 4370, 3981, 3590, - 3196, 2801, 2404, 2006, - 1606, 1205, 804, 402, - 0, -401, -803, -1204, - -1605, -2005, -2403, -2800, - -3195, -3589, -3980, -4369, - -4755, -5138, -5519, -5896, - -6269, -6638, -7004, -7365, - -7722, -8075, -8422, -8764, - -9101, -9433, -9759, -10079, - -10393, -10701, -11002, -11296, - -11584, -11865, -12139, -12405, - -12664, -12915, -13159, -13394, - -13622, -13841, -14052, -14255, - -14448, -14634, -14810, -14977, - -15136, -15285, -15425, -15556, - -15678, -15790, -15892, -15985, - -16068, -16142, -16206, -16260, - -16304, -16339, -16363, -16378, - -16383, -}; - -#endif - diff --git a/apps/codecs/libtremor/mapping0.c b/apps/codecs/libtremor/mapping0.c deleted file mode 100644 index 084d5e076d..0000000000 --- a/apps/codecs/libtremor/mapping0.c +++ /dev/null @@ -1,416 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * - * * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * - * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * - * * - ******************************************************************** - - function: channel mapping 0 implementation - - ********************************************************************/ - -#include "config-tremor.h" -#include -#include -#include -#include "ogg.h" -#include "ivorbiscodec.h" -#include "codeclib.h" -#include "codec_internal.h" -#include "codebook.h" -#include "window.h" -#include "registry.h" -#include "misc.h" -#include - -/* simplistic, wasteful way of doing this (unique lookup for each - mode/submapping); there should be a central repository for - identical lookups. That will require minor work, so I'm putting it - off as low priority. - - Why a lookup for each backend in a given mode? Because the - blocksize is set by the mode, and low backend lookups may require - parameters from other areas of the mode/mapping */ - -typedef struct { - vorbis_info_mode *mode; - vorbis_info_mapping0 *map; - - vorbis_look_floor **floor_look; - - vorbis_look_residue **residue_look; - - vorbis_func_floor **floor_func; - vorbis_func_residue **residue_func; - - int ch; - long lastframe; /* if a different mode is called, we need to - invalidate decay */ -} vorbis_look_mapping0; - -static void mapping0_free_info(vorbis_info_mapping *i){ - vorbis_info_mapping0 *info=(vorbis_info_mapping0 *)i; - if(info){ - memset(info,0,sizeof(*info)); - _ogg_free(info); - } -} - -static void mapping0_free_look(vorbis_look_mapping *look){ - int i; - vorbis_look_mapping0 *l=(vorbis_look_mapping0 *)look; - if(l){ - - for(i=0;imap->submaps;i++){ - l->floor_func[i]->free_look(l->floor_look[i]); - l->residue_func[i]->free_look(l->residue_look[i]); - } - - _ogg_free(l->floor_func); - _ogg_free(l->residue_func); - _ogg_free(l->floor_look); - _ogg_free(l->residue_look); - memset(l,0,sizeof(*l)); - _ogg_free(l); - } -} - -static vorbis_look_mapping *mapping0_look(vorbis_dsp_state *vd,vorbis_info_mode *vm, - vorbis_info_mapping *m){ - int i; - vorbis_info *vi=vd->vi; - codec_setup_info *ci=(codec_setup_info *)vi->codec_setup; - vorbis_look_mapping0 *look=(vorbis_look_mapping0 *)_ogg_calloc(1,sizeof(*look)); - vorbis_info_mapping0 *info=look->map=(vorbis_info_mapping0 *)m; - look->mode=vm; - - look->floor_look=(vorbis_look_floor **)_ogg_calloc(info->submaps,sizeof(*look->floor_look)); - - look->residue_look=(vorbis_look_residue **)_ogg_calloc(info->submaps,sizeof(*look->residue_look)); - - look->floor_func=(vorbis_func_floor **)_ogg_calloc(info->submaps,sizeof(*look->floor_func)); - look->residue_func=(vorbis_func_residue **)_ogg_calloc(info->submaps,sizeof(*look->residue_func)); - - for(i=0;isubmaps;i++){ - int floornum=info->floorsubmap[i]; - int resnum=info->residuesubmap[i]; - - look->floor_func[i]=_floor_P[ci->floor_type[floornum]]; - look->floor_look[i]=look->floor_func[i]-> - look(vd,vm,ci->floor_param[floornum]); - look->residue_func[i]=_residue_P[ci->residue_type[resnum]]; - look->residue_look[i]=look->residue_func[i]-> - look(vd,vm,ci->residue_param[resnum]); - - } - - look->ch=vi->channels; - - return(look); -} - -static int ilog(unsigned int v){ - int ret=0; - if(v)--v; - while(v){ - ret++; - v>>=1; - } - return(ret); -} - - -/* also responsible for range checking */ -static vorbis_info_mapping *mapping0_unpack(vorbis_info *vi,oggpack_buffer *opb){ - int i,b; - vorbis_info_mapping0 *info=(vorbis_info_mapping0 *)_ogg_calloc(1,sizeof(*info)); - codec_setup_info *ci=(codec_setup_info *)vi->codec_setup; - memset(info,0,sizeof(*info)); - - b=oggpack_read(opb,1); - if(b<0)goto err_out; - if(b){ - info->submaps=oggpack_read(opb,4)+1; - if(info->submaps<=0)goto err_out; - }else - info->submaps=1; - - b=oggpack_read(opb,1); - if(b<0)goto err_out; - if(b){ - info->coupling_steps=oggpack_read(opb,8)+1; - if(info->coupling_steps<=0)goto err_out; - for(i=0;icoupling_steps;i++){ - int testM=oggpack_read(opb,ilog(vi->channels)); - info->coupling_mag[i]=testM; - int testA=oggpack_read(opb,ilog(vi->channels)); - info->coupling_ang[i]=testA; - - if(testM<0 || - testA<0 || - testM==testA || - testM>=vi->channels || - testA>=vi->channels) goto err_out; - } - - } - - if(oggpack_read(opb,2)!=0)goto err_out; /* 2,3:reserved */ - - if(info->submaps>1){ - for(i=0;ichannels;i++){ - info->chmuxlist[i]=oggpack_read(opb,4); - if(info->chmuxlist[i]>=info->submaps || info->chmuxlist[i]<0)goto err_out; - } - } - for(i=0;isubmaps;i++){ - int temp=oggpack_read(opb,8); - if(temp>=ci->times)goto err_out; - info->floorsubmap[i]=oggpack_read(opb,8); - if(info->floorsubmap[i]>=ci->floors || info->floorsubmap[i]<0)goto err_out; - info->residuesubmap[i]=oggpack_read(opb,8); - if(info->residuesubmap[i]>=ci->residues || info->residuesubmap[i]<0) - goto err_out; - } - - return info; - - err_out: - mapping0_free_info(info); - return(NULL); -} - -#ifdef _ARM_ASSEM_ -#define MAGANG( _mag, _ang )\ -{\ - register int temp;\ - asm( "mov %[temp], %[ang]\n\t"\ - "cmp %[mag], #0\n\t"\ - "rsble %[temp], %[temp], #0\n\t"\ - "cmp %[ang], #0\n\t"\ - "subgt %[ang], %[mag], %[temp]\n\t"\ - "movle %[ang], %[mag]\n\t"\ - "addle %[mag], %[mag], %[temp]\n\t"\ - : [mag] "+r" ( ( _mag ) ), [ang] "+r" ( ( _ang ) ), [temp] "=&r" (temp)\ - :\ - : "cc" );\ -} - -static inline void channel_couple(ogg_int32_t *pcmM, ogg_int32_t *pcmA, int n) -{ - ogg_int32_t * const pcmMend = pcmM + n/2; - while(LIKELY(pcmM < pcmMend)) - { - register int M0 asm("r2"),M1 asm("r3"),M2 asm("r4"),M3 asm("r5"); - register int A0 asm("r6"),A1 asm("r7"),A2 asm("r8"),A3 asm("r9"); - asm volatile( "ldmia %[pcmM], {%[M0], %[M1], %[M2], %[M3]}\n\t" - "ldmia %[pcmA], {%[A0], %[A1], %[A2], %[A3]}\n\t" - : [M0] "=r" (M0), [M1] "=r" (M1), [M2] "=r" (M2), [M3] "=r" (M3), - [A0] "=r" (A0), [A1] "=r" (A1), [A2] "=r" (A2), [A3] "=r" (A3) - : [pcmM] "r" (pcmM), [pcmA] "r" (pcmA) - : "memory" ); - MAGANG( M0, A0 ); - MAGANG( M1, A1 ); - MAGANG( M2, A2 ); - MAGANG( M3, A3 ); - asm volatile( "stmia %[pcmM]!, {%[M0], %[M1], %[M2], %[M3]}\n\t" - "stmia %[pcmA]!, {%[A0], %[A1], %[A2], %[A3]}\n\t" - : [pcmM] "+r" (pcmM), [pcmA] "+r" (pcmA) - : [M0] "r" (M0), [M1] "r" (M1), [M2] "r" (M2), [M3] "r" (M3), - [A0] "r" (A0), [A1] "r" (A1), [A2] "r" (A2), [A3] "r" (A3) - : "memory" ); - } -} - -#elif defined CPU_COLDFIRE - -#define MAGANG( _mag, _ang, _off )\ -{\ - asm volatile( "tst.l %[mag]\n\t"\ - "bgt.s 1f\n\t"\ - "neg.l %[ang]\n\t" /* neg sets cc so we might as well jump */ \ - "ble.s 2f\n\t"\ - ".word 0x51fb\n\t" /* trapf.l, shadow next 2 insns */ \ - /* if we didn't jump, the next test will */ \ - /* false anyway */ \ - "1:\n\t"\ - "tst.l %[ang]\n\t"\ - "bgt.s 2f\n\t"\ - "add.l %[mag], %[ang]\n\t"\ - "move.l %[ang], (" #_off ", %[pcmM])\n\t"\ - ".word 0x51fa\n\t" /* trapf.w, shadow next insn */ \ - "2:\n\t"\ - "sub.l %[ang], %[mag]\n\t"\ - "move.l %[mag], (%[pcmA])+\n\t"\ - : [mag] "+r" ( ( _mag ) ), [ang] "+d" ( ( _ang ) ),\ - [pcmA] "+a" (pcmA)\ - : [pcmM] "a" (pcmM)\ - : "cc", "memory" );\ -} -static inline void channel_couple(ogg_int32_t *pcmM, ogg_int32_t *pcmA, unsigned int n) -{ - ogg_int32_t * const pcmMend = pcmM + n/2; - while(LIKELY(pcmM < pcmMend)) - { - register int M0 asm("a2"),M1 asm("a3"),M2 asm("a4"),M3 asm("a5"); - register int A0 asm("d2"),A1 asm("d3"),A2 asm("d4"),A3 asm("d5"); - asm volatile( "movem.l (%[pcmM]), %[M0]-%[M3]\n\t" - "movem.l (%[pcmA]), %[A0]-%[A3]\n\t" - : [M0] "=r" (M0), [M1] "=r" (M1), [M2] "=r" (M2), [M3] "=r" (M3), - [A0] "=r" (A0), [A1] "=r" (A1), [A2] "=r" (A2), [A3] "=r" (A3) - : [pcmM] "a" (pcmM), [pcmA] "a" (pcmA) ); - - /* use offsets instead of autoinc since the store to pcmM is conditional */ - MAGANG( M0, A0, 0 ); - MAGANG( M1, A1, 4 ); - MAGANG( M2, A2, 8 ); - MAGANG( M3, A3, 12 ); - - asm volatile( "lea.l (4*4, %[pcmM]), %[pcmM]\n\t" - : [pcmM] "+a" (pcmM)); - } -} -#else -static inline void channel_couple(ogg_int32_t *pcmM, ogg_int32_t *pcmA, int n) -{ - int j; - for(j=0;j0) - _ang = ang; - else - _ang = -ang; - - if(ang>0) - pcmA[j]=mag-_ang; - else{ - pcmA[j]=mag; - pcmM[j]=mag+_ang; - } - - } -} -#endif - -static int mapping0_inverse(vorbis_block *vb,vorbis_look_mapping *l){ - vorbis_dsp_state *vd=vb->vd; - vorbis_info *vi=vd->vi; - codec_setup_info *ci=(codec_setup_info *)vi->codec_setup; - vorbis_look_mapping0 *look=(vorbis_look_mapping0 *)l; - vorbis_info_mapping0 *info=look->map; - - int i,j; - long n=vb->pcmend=ci->blocksizes[vb->W]; - - /* bounded mapping arrays instead of using alloca(); - avoids memory leak; we can only deal with stereo anyway */ - ogg_int32_t *pcmbundle[CHANNELS]; - int zerobundle[CHANNELS]; - int nonzero[CHANNELS]; - void *floormemo[CHANNELS]; - - /* time domain information decode (note that applying the - information would have to happen later; we'll probably add a - function entry to the harness for that later */ - /* NOT IMPLEMENTED */ - - /* recover the spectral envelope; store it in the PCM vector for now */ - for(i=0;ichannels;i++){ - int submap=info->chmuxlist[i]; - floormemo[i]=look->floor_func[submap]-> - inverse1(vb,look->floor_look[submap]); - if(floormemo[i]) - nonzero[i]=1; - else - nonzero[i]=0; - memset(vd->floors + i * ci->blocksizes[vb->W]/2,0,sizeof(ogg_int32_t)*n/2); - } - - /* channel coupling can 'dirty' the nonzero listing */ - for(i=0;icoupling_steps;i++){ - if(nonzero[info->coupling_mag[i]] || - nonzero[info->coupling_ang[i]]){ - nonzero[info->coupling_mag[i]]=1; - nonzero[info->coupling_ang[i]]=1; - } - } - - /* recover the residue into our working vectors */ - for(i=0;isubmaps;i++){ - int ch_in_bundle=0; - for(j=0;jchannels;j++){ - if(info->chmuxlist[j]==i){ - if(nonzero[j]) - zerobundle[ch_in_bundle]=1; - else - zerobundle[ch_in_bundle]=0; - pcmbundle[ch_in_bundle++] = vd->floors + j * ci->blocksizes[vb->W]/2; - } - } - - look->residue_func[i]->inverse(vb,look->residue_look[i], - pcmbundle,zerobundle,ch_in_bundle); - } - - //for(j=0;jchannels;j++) - //_analysis_output("coupled",seq+j,vb->pcm[j],-8,n/2,0,0); - - - /* channel coupling */ - for(i=info->coupling_steps-1;i>=0;i--){ - ogg_int32_t *pcmM = vd->floors + info->coupling_mag[i] * ci->blocksizes[vb->W]/2; - ogg_int32_t *pcmA = vd->floors + info->coupling_ang[i] * ci->blocksizes[vb->W]/2; - channel_couple(pcmM,pcmA,n); - } - - //for(j=0;jchannels;j++) - //_analysis_output("residue",seq+j,vb->pcm[j],-8,n/2,0,0); - - //for(j=0;jchannels;j++) - //_analysis_output("mdct",seq+j,vb->pcm[j],-24,n/2,0,1); - - /* transform the PCM data; takes PCM vector, vb; modifies PCM vector */ - /* only MDCT right now.... */ - for(i=0;ichannels;i++){ - ogg_int32_t *pcm = vd->floors + i*ci->blocksizes[vb->W]/2; - int submap=info->chmuxlist[i]; - - if(nonzero[i]) { - /* compute and apply spectral envelope */ - look->floor_func[submap]-> - inverse2(vb,look->floor_look[submap],floormemo[i],pcm); - - ff_imdct_half(ci->blocksizes_nbits[vb->W], - (int32_t*)vd->residues[vd->ri] + i*ci->blocksizes[vb->W]/2, - (int32_t*)&vd->floors[i*ci->blocksizes[vb->W]/2]); - } - else - memset(vd->residues[vd->ri] + i*ci->blocksizes[vb->W]/2, 0, sizeof(ogg_int32_t)*n/2); - } - - //for(j=0;jchannels;j++) - //_analysis_output("imdct",seq+j,vb->pcm[j],-24,n,0,0); - - //for(j=0;jchannels;j++) - //_analysis_output("window",seq+j,vb->pcm[j],-24,n,0,0); - - //seq+=vi->channels; - /* all done! */ - return(0); -} - -/* export hooks */ -const vorbis_func_mapping mapping0_exportbundle ICONST_ATTR ={ - &mapping0_unpack, - &mapping0_look, - &mapping0_free_info, - &mapping0_free_look, - &mapping0_inverse -}; - diff --git a/apps/codecs/libtremor/misc.h b/apps/codecs/libtremor/misc.h deleted file mode 100644 index 592a60ffd8..0000000000 --- a/apps/codecs/libtremor/misc.h +++ /dev/null @@ -1,276 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * - * * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * - * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * - * * - ******************************************************************** - - function: miscellaneous math and prototypes - - ********************************************************************/ - -#include "config-tremor.h" - -#ifndef _V_RANDOM_H_ -#define _V_RANDOM_H_ -#include "ivorbiscodec.h" -#include "os_types.h" - -#include "codeclib_misc.h" - -#include "asm_arm.h" -#include "asm_mcf5249.h" - -/* Some prototypes that were not defined elsewhere */ -void *_vorbis_block_alloc(vorbis_block *vb,long bytes); -void _vorbis_block_ripcord(vorbis_block *vb); -extern int _ilog(unsigned int v); - -#ifndef _V_WIDE_MATH -#define _V_WIDE_MATH - -#ifndef _LOW_ACCURACY_ -/* 64 bit multiply */ -/* #include */ -#if 0 -#if BYTE_ORDER==LITTLE_ENDIAN -union magic { - struct { - ogg_int32_t lo; - ogg_int32_t hi; - } halves; - ogg_int64_t whole; -}; -#elif BYTE_ORDER==BIG_ENDIAN -union magic { - struct { - ogg_int32_t hi; - ogg_int32_t lo; - } halves; - ogg_int64_t whole; -}; -#endif - -static inline ogg_int32_t MULT32(ogg_int32_t x, ogg_int32_t y) { - union magic magic; - magic.whole = (ogg_int64_t)x * y; - return magic.halves.hi; -} -static inline ogg_int32_t MULT31(ogg_int32_t x, ogg_int32_t y) { - return MULT32(x,y)<<1; -} - -static inline ogg_int32_t MULT31_SHIFT15(ogg_int32_t x, ogg_int32_t y) { - union magic magic; - magic.whole = (ogg_int64_t)x * y; - return ((ogg_uint32_t)(magic.halves.lo)>>15) | ((magic.halves.hi)<<17); -} -#endif -#else -/* 32 bit multiply, more portable but less accurate */ - -/* - * Note: Precision is biased towards the first argument therefore ordering - * is important. Shift values were chosen for the best sound quality after - * many listening tests. - */ - -/* - * For MULT32 and MULT31: The second argument is always a lookup table - * value already preshifted from 31 to 8 bits. We therefore take the - * opportunity to save on text space and use unsigned char for those - * tables in this case. - */ - -static inline ogg_int32_t MULT32(ogg_int32_t x, ogg_int32_t y) { - return (x >> 9) * y; /* y preshifted >>23 */ -} - -static inline ogg_int32_t MULT31(ogg_int32_t x, ogg_int32_t y) { - return (x >> 8) * y; /* y preshifted >>23 */ -} - -static inline ogg_int32_t MULT31_SHIFT15(ogg_int32_t x, ogg_int32_t y) { - return (x >> 6) * y; /* y preshifted >>9 */ -} -#endif - -/* - * This should be used as a memory barrier, forcing all cached values in - * registers to wr writen back to memory. Might or might not be beneficial - * depending on the architecture and compiler. - */ -#define MB() - -/* - * The XPROD functions are meant to optimize the cross products found all - * over the place in mdct.c by forcing memory operation ordering to avoid - * unnecessary register reloads as soon as memory is being written to. - * However this is only beneficial on CPUs with a sane number of general - * purpose registers which exclude the Intel x86. On Intel, better let the - * compiler actually reload registers directly from original memory by using - * macros. - */ - -/* replaced XPROD32 with a macro to avoid memory reference - _x, _y are the results (must be l-values) */ -/* -#define XPROD32(_a, _b, _t, _v, _x, _y) \ - { (_x)=MULT32(_a,_t)+MULT32(_b,_v); \ - (_y)=MULT32(_b,_t)-MULT32(_a,_v); } -*/ - -#ifdef __i386__ - -#define XPROD31(_a, _b, _t, _v, _x, _y) \ - { *(_x)=MULT31(_a,_t)+MULT31(_b,_v); \ - *(_y)=MULT31(_b,_t)-MULT31(_a,_v); } -#define XNPROD31(_a, _b, _t, _v, _x, _y) \ - { *(_x)=MULT31(_a,_t)-MULT31(_b,_v); \ - *(_y)=MULT31(_b,_t)+MULT31(_a,_v); } - -#else -/* -static inline void XPROD31(ogg_int32_t a, ogg_int32_t b, - ogg_int32_t t, ogg_int32_t v, - ogg_int32_t *x, ogg_int32_t *y) -{ - *x = MULT31(a, t) + MULT31(b, v); - *y = MULT31(b, t) - MULT31(a, v); -} - -static inline void XNPROD31(ogg_int32_t a, ogg_int32_t b, - ogg_int32_t t, ogg_int32_t v, - ogg_int32_t *x, ogg_int32_t *y) -{ - *x = MULT31(a, t) - MULT31(b, v); - *y = MULT31(b, t) + MULT31(a, v); -} -*/ -#endif - -#if 0 -#ifndef _V_VECT_OPS -#define _V_VECT_OPS - -/* generic misc.h has symmetrical versions of vect_add_right_left - and vect_add_left_right (since symmetrical versions of - vect_mult_fw and vect_mult_bw i.e. both use MULT31) */ -static inline -void vect_add_right_left(ogg_int32_t *x, const ogg_int32_t *y, int n) -{ - while (n>0) { - *x++ += *y++; - n--; - } -} - -static inline -void vect_add_left_right(ogg_int32_t *x, const ogg_int32_t *y, int n) -{ - vect_add_right_left(x,y,n); -} - -static inline -void ogg_vect_mult_fw(ogg_int32_t *data, LOOKUP_T *window, int n) -{ - while(n>0) { - *data = MULT31(*data, *window); - data++; - window++; - n--; - } -} - -static inline -void ogg_vect_mult_bw(ogg_int32_t *data, LOOKUP_T *window, int n) -{ - while(n>0) { - *data = MULT31(*data, *window); - data++; - window--; - n--; - } -} - -/* generic memcpy is probably optimal */ -static inline void vect_copy(ogg_int32_t *x, const ogg_int32_t *y, int n) -{ - memcpy(x,y,n*sizeof(ogg_int32_t)); -} -#endif - -static inline ogg_int32_t VFLOAT_MULT(ogg_int32_t a,ogg_int32_t ap, - ogg_int32_t b,ogg_int32_t bp, - ogg_int32_t *p){ - if(a && b){ -#ifndef _LOW_ACCURACY_ - *p=ap+bp+32; - return MULT32(a,b); -#else - *p=ap+bp+31; - return (a>>15)*(b>>16); -#endif - }else - return 0; -} -#endif -#endif -static inline ogg_int32_t VFLOAT_MULTI(ogg_int32_t a,ogg_int32_t ap, - ogg_int32_t i, - ogg_int32_t *p){ - - int ip=_ilog(abs(i))-31; - return VFLOAT_MULT(a,ap,i<<-ip,ip,p); -} -#if 0 -static inline ogg_int32_t VFLOAT_ADD(ogg_int32_t a,ogg_int32_t ap, - ogg_int32_t b,ogg_int32_t bp, - ogg_int32_t *p){ - - if(!a){ - *p=bp; - return b; - }else if(!b){ - *p=ap; - return a; - } - - /* yes, this can leak a bit. */ - if(ap>bp){ - int shift=ap-bp+1; - *p=ap+1; - a>>=1; - if(shift<32){ - b=(b+(1<<(shift-1)))>>shift; - }else{ - b=0; - } - }else{ - int shift=bp-ap+1; - *p=bp+1; - b>>=1; - if(shift<32){ - a=(a+(1<<(shift-1)))>>shift; - }else{ - a=0; - } - } - - a+=b; - if((a&0xc0000000)==0xc0000000 || - (a&0xc0000000)==0){ - a<<=1; - (*p)--; - } - return(a); -} -#endif -#endif - diff --git a/apps/codecs/libtremor/ogg.h b/apps/codecs/libtremor/ogg.h deleted file mode 100644 index d3af919b85..0000000000 --- a/apps/codecs/libtremor/ogg.h +++ /dev/null @@ -1,282 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * - * by the Xiph.Org Foundation http://www.xiph.org/ * - * * - ******************************************************************** - - function: toplevel libogg include - last mod: $Id$ - - ********************************************************************/ -#ifndef _OGG_H -#define _OGG_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include "os_types.h" - -extern const unsigned long mask[] ICONST_ATTR; - -typedef struct { - void *iov_base; - size_t iov_len; -} ogg_iovec_t; - -typedef struct { - long endbyte; - int endbit; - - unsigned char *buffer; - unsigned char *ptr; - long storage; -} oggpack_buffer; - -/* ogg_page is used to encapsulate the data in one Ogg bitstream page *****/ - -typedef struct { - unsigned char *header; - long header_len; - unsigned char *body; - long body_len; -} ogg_page; - -/* ogg_stream_state contains the current encode/decode state of a logical - Ogg bitstream **********************************************************/ - -typedef struct { - unsigned char *body_data; /* bytes from packet bodies */ - long body_storage; /* storage elements allocated */ - long body_fill; /* elements stored; fill mark */ - long body_returned; /* elements of fill returned */ - - - int *lacing_vals; /* The values that will go to the segment table */ - ogg_int64_t *granule_vals; /* granulepos values for headers. Not compact - this way, but it is simple coupled to the - lacing fifo */ - long lacing_storage; - long lacing_fill; - long lacing_packet; - long lacing_returned; - -#if 0 - unsigned char header[282]; /* working space for header encode */ - int header_fill; -#endif - int e_o_s; /* set when we have buffered the last packet in the - logical bitstream */ - int b_o_s; /* set after we've written the initial page - of a logical bitstream */ - ogg_uint32_t serialno; - long pageno; - ogg_int64_t packetno; /* sequence number for decode; the framing - knows where there's a hole in the data, - but we need coupling so that the codec - (which is in a separate abstraction - layer) also knows about the gap */ - ogg_int64_t granulepos; - -} ogg_stream_state; - -/* ogg_packet is used to encapsulate the data and metadata belonging - to a single raw Ogg/Vorbis packet *************************************/ - -typedef struct { - unsigned char *packet; - long bytes; - long b_o_s; - long e_o_s; - - ogg_int64_t granulepos; - - ogg_int64_t packetno; /* sequence number for decode; the framing - knows where there's a hole in the data, - but we need coupling so that the codec - (which is in a separate abstraction - layer) also knows about the gap */ -} ogg_packet; - -typedef struct { - unsigned char *data; - int storage; - int fill; - int returned; - - int unsynced; - int headerbytes; - int bodybytes; -} ogg_sync_state; - -/* Ogg BITSTREAM PRIMITIVES: bitstream ************************/ -/* -extern void oggpack_writeinit(oggpack_buffer *b); -extern int oggpack_writecheck(oggpack_buffer *b); -extern void oggpack_writetrunc(oggpack_buffer *b,long bits); -extern void oggpack_writealign(oggpack_buffer *b); -extern void oggpack_writecopy(oggpack_buffer *b,void *source,long bits); -extern void oggpack_reset(oggpack_buffer *b); -extern void oggpack_writeclear(oggpack_buffer *b); */ -extern void oggpack_readinit(oggpack_buffer *b,unsigned char *buf,int bytes); -/* -extern void oggpack_write(oggpack_buffer *b,unsigned long value,int bits); -extern long oggpack_look(oggpack_buffer *b,int bits); -*/ - -static inline long oggpack_look(oggpack_buffer *b,int bits){ - unsigned long ret; - unsigned long m; - - if(bits<0 || bits>32) return -1; - m=mask[bits]; - bits+=b->endbit; - - if(b->endbyte >= b->storage-4){ - /* not the main path */ - if(b->endbyte > b->storage-((bits+7)>>3)) return -1; - /* special case to avoid reading b->ptr[0], which might be past the end of - the buffer; also skips some useless accounting */ - else if(!bits)return(0L); - } - - ret=b->ptr[0]>>b->endbit; - if(bits>8){ - ret|=b->ptr[1]<<(8-b->endbit); - if(bits>16){ - ret|=b->ptr[2]<<(16-b->endbit); - if(bits>24){ - ret|=b->ptr[3]<<(24-b->endbit); - if(bits>32 && b->endbit) - ret|=b->ptr[4]<<(32-b->endbit); - } - } - } - return(m&ret); -} -/* -extern long oggpack_look1(oggpack_buffer *b); -extern void oggpack_adv(oggpack_buffer *b,int bits); -*/ - -static inline void oggpack_adv(oggpack_buffer *b, unsigned int bits){ - bits+=b->endbit; - - if(b->endbyte > b->storage-(int)((bits+7)>>3)) goto overflow; - - b->ptr+=bits/8; - b->endbyte+=bits/8; - b->endbit=bits&7; - return; - - overflow: - b->ptr=NULL; - b->endbyte=b->storage; - b->endbit=1; -} - -/* -extern void oggpack_adv1(oggpack_buffer *b); -*/ -extern long oggpack_read(oggpack_buffer *b,int bits); -/* -extern long oggpack_read1(oggpack_buffer *b); -extern long oggpack_bytes(oggpack_buffer *b); -*/ -static inline long oggpack_bytes(oggpack_buffer *b){ - return(b->endbyte+(b->endbit+7)/8); -} -#if 0 -extern long oggpack_bits(oggpack_buffer *b); -extern unsigned char *oggpack_get_buffer(oggpack_buffer *b); - -extern void oggpackB_writeinit(oggpack_buffer *b); -extern int oggpackB_writecheck(oggpack_buffer *b); -extern void oggpackB_writetrunc(oggpack_buffer *b,long bits); -extern void oggpackB_writealign(oggpack_buffer *b); -extern void oggpackB_writecopy(oggpack_buffer *b,void *source,long bits); -extern void oggpackB_reset(oggpack_buffer *b); -extern void oggpackB_writeclear(oggpack_buffer *b); -extern void oggpackB_readinit(oggpack_buffer *b,unsigned char *buf,int bytes); -extern void oggpackB_write(oggpack_buffer *b,unsigned long value,int bits); -extern long oggpackB_look(oggpack_buffer *b,int bits); -extern long oggpackB_look1(oggpack_buffer *b); -extern void oggpackB_adv(oggpack_buffer *b,int bits); -extern void oggpackB_adv1(oggpack_buffer *b); -extern long oggpackB_read(oggpack_buffer *b,int bits); -extern long oggpackB_read1(oggpack_buffer *b); -extern long oggpackB_bytes(oggpack_buffer *b); -extern long oggpackB_bits(oggpack_buffer *b); -extern unsigned char *oggpackB_get_buffer(oggpack_buffer *b); -# endif -/* Ogg BITSTREAM PRIMITIVES: encoding **************************/ -#if 0 -extern int ogg_stream_packetin(ogg_stream_state *os, ogg_packet *op); -extern int ogg_stream_iovecin(ogg_stream_state *os, ogg_iovec_t *iov, - int count, long e_o_s, ogg_int64_t granulepos); -extern int ogg_stream_pageout(ogg_stream_state *os, ogg_page *og); -extern int ogg_stream_pageout_fill(ogg_stream_state *os, ogg_page *og, int nfill); -extern int ogg_stream_flush(ogg_stream_state *os, ogg_page *og); -#endif -/* Ogg BITSTREAM PRIMITIVES: decoding **************************/ - -extern int _os_body_expand(ogg_stream_state *os,int needed); - -extern int ogg_sync_init(ogg_sync_state *oy); -extern int ogg_sync_clear(ogg_sync_state *oy); -extern int ogg_sync_reset(ogg_sync_state *oy); -/* -extern int ogg_sync_destroy(ogg_sync_state *oy); -extern int ogg_sync_check(ogg_sync_state *oy); -*/ - -extern char *ogg_sync_buffer(ogg_sync_state *oy, long size); -extern int ogg_sync_wrote(ogg_sync_state *oy, long bytes); -extern long ogg_sync_pageseek(ogg_sync_state *oy,ogg_page *og); -/* -extern int ogg_sync_pageout(ogg_sync_state *oy, ogg_page *og); -*/ -extern int ogg_stream_pagein(ogg_stream_state *os, ogg_page *og, bool copy_body); -extern int ogg_stream_packetout(ogg_stream_state *os,ogg_packet *op); -extern int ogg_stream_packetpeek(ogg_stream_state *os,ogg_packet *op); - -/* Ogg BITSTREAM PRIMITIVES: general ***************************/ - -extern int ogg_stream_init(ogg_stream_state *os,int serialno); -extern int ogg_stream_clear(ogg_stream_state *os); -extern int ogg_stream_reset(ogg_stream_state *os); -extern int ogg_stream_reset_serialno(ogg_stream_state *os,int serialno); -/* -extern int ogg_stream_destroy(ogg_stream_state *os); -extern int ogg_stream_check(ogg_stream_state *os); -*/ -extern int ogg_stream_eos(ogg_stream_state *os); - -/* -extern void ogg_page_checksum_set(ogg_page *og); -extern int ogg_page_version(const ogg_page *og); -*/ -extern int ogg_page_continued(const ogg_page *og); -extern int ogg_page_bos(const ogg_page *og); -extern int ogg_page_eos(const ogg_page *og); -extern ogg_int64_t ogg_page_granulepos(const ogg_page *og); -extern ogg_uint32_t ogg_page_serialno(const ogg_page *og); -/* -extern long ogg_page_pageno(const ogg_page *og); -extern int ogg_page_packets(const ogg_page *og); - -extern void ogg_packet_clear(ogg_packet *op); -*/ - -#ifdef __cplusplus -} -#endif - -#endif /* _OGG_H */ diff --git a/apps/codecs/libtremor/oggmalloc.c b/apps/codecs/libtremor/oggmalloc.c deleted file mode 100644 index 783e0f7240..0000000000 --- a/apps/codecs/libtremor/oggmalloc.c +++ /dev/null @@ -1,86 +0,0 @@ -#include "os_types.h" -#include - -#if defined(CPU_ARM) || defined(CPU_COLDFIRE) || defined(CPU_MIPS) -#include -extern jmp_buf rb_jump_buf; -#define LONGJMP(x) longjmp(rb_jump_buf, x) -#elif defined(SIMULATOR) -#define LONGJMP(x) do { DEBUGF("Vorbis: allocation failed!\n"); return NULL; } while (false) -#else -#define LONGJMP(x) return NULL -#endif - -void ogg_malloc_init(void) -{ - size_t bufsize; - void* buf = ci->codec_get_buffer(&bufsize); - init_memory_pool(bufsize, buf); -} - -void ogg_malloc_destroy() -{ - size_t bufsize; - void* buf = ci->codec_get_buffer(&bufsize); - destroy_memory_pool(buf); -} - -void *ogg_malloc(size_t size) -{ - void* x = tlsf_malloc(size); - - if (x == NULL) - LONGJMP(1); - - return x; -} - -void *ogg_calloc(size_t nmemb, size_t size) -{ - void *x = tlsf_calloc(nmemb, size); - - if (x == NULL) - LONGJMP(1); - - return x; -} - -void *ogg_realloc(void *ptr, size_t size) -{ - void *x = tlsf_realloc(ptr, size); - - if (x == NULL) - LONGJMP(1); - - return x; -} - -void ogg_free(void* ptr) -{ - tlsf_free(ptr); -} - -#ifdef TREMOR_USE_IRAM -/* Allocate IRAM buffer */ -static unsigned char iram_buff[IRAM_IBSS_SIZE] IBSS_ATTR MEM_ALIGN_ATTR; -static size_t iram_remain; - -void iram_malloc_init(void){ - iram_remain=IRAM_IBSS_SIZE; -} - -void *iram_malloc(size_t size){ - void* x; - - /* always ensure alignment to CACHEALIGN_SIZE byte */ - size = (size + (CACHEALIGN_SIZE-1)) & ~(CACHEALIGN_SIZE-1); - - if(size>iram_remain) - return NULL; - - x = &iram_buff[IRAM_IBSS_SIZE-iram_remain]; - iram_remain-=size; - - return x; -} -#endif diff --git a/apps/codecs/libtremor/os.h b/apps/codecs/libtremor/os.h deleted file mode 100644 index bafcaedb62..0000000000 --- a/apps/codecs/libtremor/os.h +++ /dev/null @@ -1,62 +0,0 @@ -#ifndef _OS_H -#define _OS_H -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * - * * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * - * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * - * * - ******************************************************************** - - function: #ifdef jail to whip a few platforms into the UNIX ideal. - - ********************************************************************/ - -#include -#include "os_types.h" - -#ifndef _V_IFDEFJAIL_H_ -# define _V_IFDEFJAIL_H_ - -# ifdef __GNUC__ -# define STIN static inline -# elif defined(_WIN32) -# define STIN static __inline__ -# endif -#else -# define STIN static inline -#endif - -#ifndef M_PI -# define M_PI (3.1415926536f) -#endif - -#ifdef _WIN32 -# include -# define rint(x) (floor((x)+0.5f)) -# define NO_FLOAT_MATH_LIB -# define FAST_HYPOT(a, b) sqrt((a)*(a) + (b)*(b)) -#endif - -#ifdef HAVE_ALLOCA_H -# include -#endif - -#ifdef USE_MEMORY_H -# include -#endif - -#ifndef min -# define min(x,y) ((x)>(y)?(y):(x)) -#endif - -#ifndef max -# define max(x,y) ((x)<(y)?(y):(x)) -#endif - -#endif /* _OS_H */ diff --git a/apps/codecs/libtremor/os_types.h b/apps/codecs/libtremor/os_types.h deleted file mode 100644 index b5bd0b713a..0000000000 --- a/apps/codecs/libtremor/os_types.h +++ /dev/null @@ -1,58 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * - * * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * - * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * - * * - ******************************************************************** - - function: #ifdef jail to whip a few platforms into the UNIX ideal. - - ********************************************************************/ -#include "config-tremor.h" - -#ifndef _OS_TYPES_H -#define _OS_TYPES_H - -#include -#include -#include - -#ifdef _LOW_ACCURACY_ -# define X(n) (((((n)>>22)+1)>>1) - ((((n)>>22)+1)>>9)) -# define LOOKUP_T const unsigned char -# define LOOKUP_TNC unsigned char -#else -# define X(n) (n) -# define LOOKUP_T const ogg_int32_t -# define LOOKUP_TNC ogg_int32_t -#endif - -/* make it easy on the folks that want to compile the libs with a - different malloc than stdlib */ - -#define _ogg_malloc ogg_malloc -#define _ogg_calloc ogg_calloc -#define _ogg_realloc ogg_realloc -#define _ogg_free ogg_free - -void ogg_malloc_init(void); -void ogg_malloc_destroy(void); -void *ogg_malloc(size_t size); -void *ogg_calloc(size_t nmemb, size_t size); -void *ogg_realloc(void *ptr, size_t size); -void ogg_free(void *ptr); -void iram_malloc_init(void); -void *iram_malloc(size_t size); - - typedef int16_t ogg_int16_t; - typedef int32_t ogg_int32_t; - typedef uint32_t ogg_uint32_t; - typedef int64_t ogg_int64_t; - -#endif /* _OS_TYPES_H */ diff --git a/apps/codecs/libtremor/registry.c b/apps/codecs/libtremor/registry.c deleted file mode 100644 index b1592628a1..0000000000 --- a/apps/codecs/libtremor/registry.c +++ /dev/null @@ -1,50 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * - * * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * - * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * - * * - ******************************************************************** - - function: registry for floor, res backends and channel mappings - - ********************************************************************/ - -#include "ivorbiscodec.h" -#include "codec_internal.h" -#include "registry.h" -#include "misc.h" - - -/* seems like major overkill now; the backend numbers will grow into - the infrastructure soon enough */ - -extern vorbis_func_floor floor0_exportbundle; -extern vorbis_func_floor floor1_exportbundle; -extern vorbis_func_residue residue0_exportbundle; -extern vorbis_func_residue residue1_exportbundle; -extern vorbis_func_residue residue2_exportbundle; -extern vorbis_func_mapping mapping0_exportbundle; - -vorbis_func_floor *_floor_P[] ICONST_ATTR = { - &floor0_exportbundle, - &floor1_exportbundle, -}; - -vorbis_func_residue *_residue_P[] ICONST_ATTR = { - &residue0_exportbundle, - &residue1_exportbundle, - &residue2_exportbundle, -}; - -vorbis_func_mapping *_mapping_P[] ICONST_ATTR = { - &mapping0_exportbundle, -}; - - - diff --git a/apps/codecs/libtremor/registry.h b/apps/codecs/libtremor/registry.h deleted file mode 100644 index 2bc8068f69..0000000000 --- a/apps/codecs/libtremor/registry.h +++ /dev/null @@ -1,40 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * - * * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * - * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * - * * - ******************************************************************** - - function: registry for time, floor, res backends and channel mappings - - ********************************************************************/ - -#ifndef _V_REG_H_ -#define _V_REG_H_ - -#define VI_TRANSFORMB 1 -#define VI_WINDOWB 1 -#define VI_TIMEB 1 -#define VI_FLOORB 2 -#define VI_RESB 3 -#define VI_MAPB 1 - -#include "backends.h" - -#if defined(_WIN32) && defined(VORBISDLL_IMPORT) -# define EXTERN __declspec(dllimport) extern -#else -# define EXTERN extern -#endif - -EXTERN vorbis_func_floor *_floor_P[]; -EXTERN vorbis_func_residue *_residue_P[]; -EXTERN vorbis_func_mapping *_mapping_P[]; - -#endif diff --git a/apps/codecs/libtremor/res012.c b/apps/codecs/libtremor/res012.c deleted file mode 100644 index e4ff440a6d..0000000000 --- a/apps/codecs/libtremor/res012.c +++ /dev/null @@ -1,374 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * - * * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * - * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * - * * - ******************************************************************** - - function: residue backend 0, 1 and 2 implementation - - ********************************************************************/ - -#include "config-tremor.h" -#include -#include -#include "ogg.h" -#include "ivorbiscodec.h" -#include "codec_internal.h" -#include "registry.h" -#include "codebook.h" -#include "misc.h" -#include "os.h" - -typedef struct { - vorbis_info_residue0 *info; - int map; - - int parts; - int stages; - codebook *fullbooks; - codebook *phrasebook; - codebook ***partbooks; - - int partvals; - int **decodemap; - -} vorbis_look_residue0; - -static void res0_free_info(vorbis_info_residue *i){ - vorbis_info_residue0 *info=(vorbis_info_residue0 *)i; - if(info){ - memset(info,0,sizeof(*info)); - _ogg_free(info); - } -} - -static void res0_free_look(vorbis_look_residue *i){ - int j; - if(i){ - - vorbis_look_residue0 *look=(vorbis_look_residue0 *)i; - - for(j=0;jparts;j++) - if(look->partbooks[j])_ogg_free(look->partbooks[j]); - _ogg_free(look->partbooks); - for(j=0;jpartvals;j++) - _ogg_free(look->decodemap[j]); - _ogg_free(look->decodemap); - - memset(look,0,sizeof(*look)); - _ogg_free(look); - } -} - -static int ilog(unsigned int v){ - int ret=0; - while(v){ - ret++; - v>>=1; - } - return(ret); -} - -static int icount(unsigned int v){ - int ret=0; - while(v){ - ret+=v&1; - v>>=1; - } - return(ret); -} - -/* vorbis_info is for range checking */ -static vorbis_info_residue *res0_unpack(vorbis_info *vi,oggpack_buffer *opb){ - int j,acc=0; - vorbis_info_residue0 *info=(vorbis_info_residue0 *)_ogg_calloc(1,sizeof(*info)); - codec_setup_info *ci=(codec_setup_info *)vi->codec_setup; - - info->begin=oggpack_read(opb,24); - info->end=oggpack_read(opb,24); - info->grouping=oggpack_read(opb,24)+1; - info->partitions=oggpack_read(opb,6)+1; - info->groupbook=oggpack_read(opb,8); - - /* check for premature EOP */ - if(info->groupbook<0)goto errout; - - for(j=0;jpartitions;j++){ - int cascade=oggpack_read(opb,3); - int cflag=oggpack_read(opb,1); - if(cflag<0) goto errout; - if(cflag){ - int c=oggpack_read(opb,5); - if(c<0) goto errout; - cascade|=(c<<3); - } - info->secondstages[j]=cascade; - - acc+=icount(cascade); - } - for(j=0;jbooklist[j]=book; - } - - if(info->groupbook>=ci->books)goto errout; - for(j=0;jbooklist[j]>=ci->books)goto errout; - if(ci->book_param[info->booklist[j]]->maptype==0)goto errout; - } - - /* verify the phrasebook is not specifying an impossible or - inconsistent partitioning scheme. */ - /* modify the phrasebook ranging check from r16327; an early beta - encoder had a bug where it used an oversized phrasebook by - accident. These files should continue to be playable, but don't - allow an exploit */ - { - int entries = ci->book_param[info->groupbook]->entries; - int dim = ci->book_param[info->groupbook]->dim; - int partvals = 1; - if (dim<1) goto errout; - while(dim>0){ - partvals *= info->partitions; - if(partvals > entries) goto errout; - dim--; - } - info->partvals = partvals; - } - - return(info); - errout: - res0_free_info(info); - return(NULL); -} - -static vorbis_look_residue *res0_look(vorbis_dsp_state *vd,vorbis_info_mode *vm, - vorbis_info_residue *vr){ - vorbis_info_residue0 *info=(vorbis_info_residue0 *)vr; - vorbis_look_residue0 *look=(vorbis_look_residue0 *)_ogg_calloc(1,sizeof(*look)); - codec_setup_info *ci=(codec_setup_info *)vd->vi->codec_setup; - - int j,k,acc=0; - int dim; - int maxstage=0; - look->info=info; - look->map=vm->mapping; - - look->parts=info->partitions; - look->fullbooks=ci->fullbooks; - look->phrasebook=ci->fullbooks+info->groupbook; - dim=look->phrasebook->dim; - - look->partbooks=(codebook ***)_ogg_calloc(look->parts,sizeof(*look->partbooks)); - - for(j=0;jparts;j++){ - int stages=ilog(info->secondstages[j]); - if(stages){ - if(stages>maxstage)maxstage=stages; - look->partbooks[j]=(codebook **)_ogg_calloc(stages,sizeof(*look->partbooks[j])); - for(k=0;ksecondstages[j]&(1<partbooks[j][k]=ci->fullbooks+info->booklist[acc++]; -#ifdef TRAIN_RES - look->training_data[k][j]=calloc(look->partbooks[j][k]->entries, - sizeof(***look->training_data)); -#endif - } - } - } - - look->partvals=look->parts; - for(j=1;jpartvals*=look->parts; - look->stages=maxstage; - look->decodemap=(int **)_ogg_malloc(look->partvals*sizeof(*look->decodemap)); - for(j=0;jpartvals;j++){ - long val=j; - long mult=look->partvals/look->parts; - look->decodemap[j]=(int *)_ogg_malloc(dim*sizeof(*look->decodemap[j])); - for(k=0;kparts; - look->decodemap[j][k]=deco; - } - } - - return(look); -} - -/* a truncated packet here just means 'stop working'; it's not an error */ -static int _01inverse(vorbis_block *vb,vorbis_look_residue *vl, - ogg_int32_t **in,int ch, - long (*decodepart)(codebook *, ogg_int32_t *, - oggpack_buffer *,int,int)){ - - long i,j,k,l,s; - vorbis_look_residue0 *look=(vorbis_look_residue0 *)vl; - vorbis_info_residue0 *info=look->info; - - /* move all this setup out later */ - int samples_per_partition=info->grouping; - int partitions_per_word=look->phrasebook->dim; - int max=vb->pcmend>>1; - int end=(info->endend:max); - int n=end-info->begin; - - if(n>0){ - int partvals=n/samples_per_partition; - int partwords=(partvals+partitions_per_word-1)/partitions_per_word; - int ***partword=(int ***)alloca(ch*sizeof(*partword)); - - for(j=0;jstages;s++){ - - /* each loop decodes on partition codeword containing - partitions_pre_word partitions */ - for(i=0,l=0;iphrasebook,&vb->opb); - if(temp==-1 || temp>=info->partvals)goto eopbreak; - partword[j][l]=look->decodemap[temp]; - if(partword[j][l]==NULL)goto errout; - } - } - - /* now we decode residual values for the partitions */ - for(k=0;kbegin+i*samples_per_partition; - if(info->secondstages[partword[j][l][k]]&(1<partbooks[partword[j][l][k]][s]; - if(stagebook){ - if(decodepart(stagebook,in[j]+offset,&vb->opb, - samples_per_partition,-8)==-1)goto eopbreak; - } - } - } - } - } - } - errout: - eopbreak: - return(0); -} - -static int res0_inverse(vorbis_block *vb,vorbis_look_residue *vl, - ogg_int32_t **in,int *nonzero,int ch){ - int i,used=0; - for(i=0;iinfo; - - /* move all this setup out later */ - int samples_per_partition=info->grouping; - int partitions_per_word=look->phrasebook->dim; - int max=(vb->pcmend*ch)>>1; - int end=(info->endend:max); - int n=end-info->begin; - - if(n>0){ - - int partvals=n/samples_per_partition; - int partwords=(partvals+partitions_per_word-1)/partitions_per_word; - int **partword=(int **)_vorbis_block_alloc(vb,partwords*sizeof(*partword)); - int beginoff=info->begin/ch; - - for(i=0;istages;s++){ - for(i=0,l=0;iphrasebook,&vb->opb); - if(temp==-1 || temp>=info->partvals)goto eopbreak; - partword[l]=look->decodemap[temp]; - if(partword[l]==NULL)goto errout; - } - - /* now we decode residual values for the partitions */ - for(k=0;ksecondstages[partword[l][k]]&(1<partbooks[partword[l][k]][s]; - if(stagebook){ - if(vorbis_book_decodevv_add(stagebook,in, - i*samples_per_partition+beginoff,ch, - &vb->opb, - samples_per_partition,-8)==-1) - goto eopbreak; - } - } - } - } - } - errout: - eopbreak: - return(0); -} - - -const vorbis_func_residue residue0_exportbundle ICONST_ATTR ={ - &res0_unpack, - &res0_look, - &res0_free_info, - &res0_free_look, - &res0_inverse -}; - -const vorbis_func_residue residue1_exportbundle ICONST_ATTR ={ - &res0_unpack, - &res0_look, - &res0_free_info, - &res0_free_look, - &res1_inverse -}; - -const vorbis_func_residue residue2_exportbundle ICONST_ATTR ={ - &res0_unpack, - &res0_look, - &res0_free_info, - &res0_free_look, - &res2_inverse -}; diff --git a/apps/codecs/libtremor/sharedbook.c b/apps/codecs/libtremor/sharedbook.c deleted file mode 100644 index 8b046217c7..0000000000 --- a/apps/codecs/libtremor/sharedbook.c +++ /dev/null @@ -1,460 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * - * * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * - * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * - * * - ******************************************************************** - - function: basic shared codebook operations - - ********************************************************************/ - -#include "config-tremor.h" -#include -#include -#include "ogg.h" -#include "os.h" -#include "misc.h" -#include "ivorbiscodec.h" -#include "codebook.h" - -/**** pack/unpack helpers ******************************************/ -int _ilog(unsigned int v){ - int ret=0; - while(v){ - ret++; - v>>=1; - } - return(ret); -} - -/* 32 bit float (not IEEE; nonnormalized mantissa + - biased exponent) : neeeeeee eeemmmmm mmmmmmmm mmmmmmmm - Why not IEEE? It's just not that important here. */ - -#define VQ_FEXP 10 -#define VQ_FMAN 21 -#define VQ_FEXP_BIAS 768 /* bias toward values smaller than 1. */ - -static ogg_int32_t _float32_unpack(long val,int *point){ - long mant=val&0x1fffff; - int sign=val&0x80000000; - long exp =(val&0x7fe00000L)>>VQ_FMAN; - - exp-=(VQ_FMAN-1)+VQ_FEXP_BIAS; - - if(mant){ - while(!(mant&0x40000000)){ - mant<<=1; - exp-=1; - } - - if(sign)mant= -mant; - }else{ - sign=0; - exp=-9999; - } - - *point=exp; - return mant; -} - -/* given a list of word lengths, generate a list of codewords. Works - for length ordered or unordered, always assigns the lowest valued - codewords first. Extended to handle unused entries (length 0) */ -static ogg_uint32_t *_make_words(long *l,long n,long sparsecount){ - long i,j,count=0; - ogg_uint32_t marker[33]; - ogg_uint32_t *r=(ogg_uint32_t *)_ogg_malloc((sparsecount?sparsecount:n)*sizeof(*r)); - memset(marker,0,sizeof(marker)); - - for(i=0;i0){ - ogg_uint32_t entry=marker[length]; - - /* when we claim a node for an entry, we also claim the nodes - below it (pruning off the imagined tree that may have dangled - from it) as well as blocking the use of any nodes directly - above for leaves */ - - /* update ourself */ - if(length<32 && (entry>>length)){ - /* error condition; the lengths must specify an overpopulated tree */ - _ogg_free(r); - return(NULL); - } - r[count++]=entry; - - /* Look to see if the next shorter marker points to the node - above. if so, update it and repeat. */ - { - for(j=length;j>0;j--){ - - if(marker[j]&1){ - /* have to jump branches */ - if(j==1) - marker[1]++; - else - marker[j]=marker[j-1]<<1; - break; /* invariant says next upper marker would already - have been moved if it was on the same path */ - } - marker[j]++; - } - } - - /* prune the tree; the implicit invariant says all the longer - markers were dangling from our just-taken node. Dangle them - from our *new* node. */ - for(j=length+1;j<33;j++) - if((marker[j]>>1) == entry){ - entry=marker[j]; - marker[j]=marker[j-1]<<1; - }else - break; - }else - if(sparsecount==0)count++; - } - - /* sanity check the huffman tree; an underpopulated tree must be - rejected. The only exception is the one-node pseudo-nil tree, - which appears to be underpopulated because the tree doesn't - really exist; there's only one possible 'codeword' or zero bits, - but the above tree-gen code doesn't mark that. */ - if(sparsecount != 1){ - for(i=1;i<33;i++) - if(marker[i] & (0xffffffffUL>>(32-i))){ - _ogg_free(r); - return(NULL); - } - } - - /* bitreverse the words because our bitwise packer/unpacker is LSb - endian */ - for(i=0,count=0;i>j)&1; - } - - if(sparsecount){ - if(l[i]) - r[count++]=temp; - }else - r[count++]=temp; - } - - return(r); -} - -/* there might be a straightforward one-line way to do the below - that's portable and totally safe against roundoff, but I haven't - thought of it. Therefore, we opt on the side of caution */ -long _book_maptype1_quantvals(const static_codebook *b){ - /* get us a starting hint, we'll polish it below */ - int bits=_ilog(b->entries); - int vals=b->entries>>((bits-1)*(b->dim-1)/b->dim); - - while(1){ - long acc=1; - long acc1=1; - int i; - for(i=0;idim;i++){ - acc*=vals; - acc1*=vals+1; - } - if(acc<=b->entries && acc1>b->entries){ - return(vals); - }else{ - if(acc>b->entries){ - vals--; - }else{ - vals++; - } - } - } -} - -/* different than what _book_unquantize does for mainline: - we repack the book in a fixed point format that shares the same - binary point. Upon first use, we can shift point if needed */ - -/* we need to deal with two map types: in map type 1, the values are - generated algorithmically (each column of the vector counts through - the values in the quant vector). in map type 2, all the values came - in in an explicit list. Both value lists must be unpacked */ - -static ogg_int32_t *_book_unquantize(const static_codebook *b,int n, - int *sparsemap,int *maxpoint){ - long j,k,count=0; - if(b->maptype==1 || b->maptype==2){ - int quantvals; - int minpoint,delpoint; - ogg_int32_t mindel=_float32_unpack(b->q_min,&minpoint); - ogg_int32_t delta=_float32_unpack(b->q_delta,&delpoint); - ogg_int32_t *r=(ogg_int32_t *)_ogg_calloc(n*b->dim,sizeof(*r)); - int *rp=(int *)_ogg_calloc(n*b->dim,sizeof(*rp)); - - *maxpoint=minpoint; - - /* maptype 1 and 2 both use a quantized value vector, but - different sizes */ - switch(b->maptype){ - case 1: - /* most of the time, entries%dimensions == 0, but we need to be - well defined. We define that the possible vales at each - scalar is values == entries/dim. If entries%dim != 0, we'll - have 'too few' values (values*dimentries;j++){ - if((sparsemap && b->lengthlist[j]) || !sparsemap){ - ogg_int32_t last=0; - int lastpoint=0; - int indexdiv=1; - for(k=0;kdim;k++){ - int index= (j/indexdiv)%quantvals; - ogg_int32_t point=0; - int val=VFLOAT_MULTI(delta,delpoint, - abs(b->quantlist[index]),&point); - - val=VFLOAT_ADD(mindel,minpoint,val,point,&point); - val=VFLOAT_ADD(last,lastpoint,val,point,&point); - - if(b->q_sequencep){ - last=val; - lastpoint=point; - } - - if(sparsemap){ - r[sparsemap[count]*b->dim+k]=val; - rp[sparsemap[count]*b->dim+k]=point; - }else{ - r[count*b->dim+k]=val; - rp[count*b->dim+k]=point; - } - if(*maxpointentries;j++){ - if((sparsemap && b->lengthlist[j]) || !sparsemap){ - ogg_int32_t last=0; - int lastpoint=0; - - for(k=0;kdim;k++){ - ogg_int32_t point=0; - int val=VFLOAT_MULTI(delta,delpoint, - abs(b->quantlist[j*b->dim+k]),&point); - - val=VFLOAT_ADD(mindel,minpoint,val,point,&point); - val=VFLOAT_ADD(last,lastpoint,val,point,&point); - - if(b->q_sequencep){ - last=val; - lastpoint=point; - } - - if(sparsemap){ - r[sparsemap[count]*b->dim+k]=val; - rp[sparsemap[count]*b->dim+k]=point; - }else{ - r[count*b->dim+k]=val; - rp[count*b->dim+k]=point; - } - if(*maxpointdim;j++) - if(rp[j]<*maxpoint) - r[j]>>=*maxpoint-rp[j]; - - _ogg_free(rp); - return(r); - } - return(NULL); -} - -void vorbis_staticbook_destroy(static_codebook *b){ - if(b->quantlist)_ogg_free(b->quantlist); - if(b->lengthlist)_ogg_free(b->lengthlist); - memset(b,0,sizeof(*b)); - _ogg_free(b); -} - -void vorbis_book_clear(codebook *b){ - /* static book is not cleared; we're likely called on the lookup and - the static codebook belongs to the info struct */ - if(b->valuelist)_ogg_free(b->valuelist); - if(b->codelist)_ogg_free(b->codelist); - - if(b->dec_index)_ogg_free(b->dec_index); - if(b->dec_codelengths)_ogg_free(b->dec_codelengths); - if(b->dec_firsttable)_ogg_free(b->dec_firsttable); - - memset(b,0,sizeof(*b)); -} - -static ogg_uint32_t bitreverse(ogg_uint32_t x){ - x= ((x>>16)&0x0000ffffUL) | ((x<<16)&0xffff0000UL); - x= ((x>> 8)&0x00ff00ffUL) | ((x<< 8)&0xff00ff00UL); - x= ((x>> 4)&0x0f0f0f0fUL) | ((x<< 4)&0xf0f0f0f0UL); - x= ((x>> 2)&0x33333333UL) | ((x<< 2)&0xccccccccUL); - return((x>> 1)&0x55555555UL) | ((x<< 1)&0xaaaaaaaaUL); -} - -static int sort32a(const void *a,const void *b){ - return (**(ogg_uint32_t **)a>**(ogg_uint32_t **)b)- - (**(ogg_uint32_t **)a<**(ogg_uint32_t **)b); -} - -/* decode codebook arrangement is more heavily optimized than encode */ -int vorbis_book_init_decode(codebook *c,const static_codebook *s){ - int i,j,n=0,tabn; - int *sortindex; - memset(c,0,sizeof(*c)); - - /* count actually used entries */ - for(i=0;ientries;i++) - if(s->lengthlist[i]>0) - n++; - - c->entries=s->entries; - c->used_entries=n; - c->dim=s->dim; - - if(n>0){ - /* two different remappings go on here. - - First, we collapse the likely sparse codebook down only to - actually represented values/words. This collapsing needs to be - indexed as map-valueless books are used to encode original entry - positions as integers. - - Second, we reorder all vectors, including the entry index above, - by sorted bitreversed codeword to allow treeless decode. */ - - /* perform sort */ - ogg_uint32_t *codes=_make_words(s->lengthlist,s->entries,c->used_entries); - ogg_uint32_t **codep=(ogg_uint32_t **)_ogg_malloc(sizeof(*codep)*n); - - if(codes==NULL||codep==NULL){ - _ogg_free(codep); - _ogg_free(codes); - goto err_out; - } - - for(i=0;icodelist=(ogg_uint32_t *)_ogg_malloc(n*sizeof(*c->codelist)); - /* the index is a reverse index */ - for(i=0;icodelist[sortindex[i]]=codes[i]; - _ogg_free(codep); - _ogg_free(codes); - - - - c->valuelist=_book_unquantize(s,n,sortindex,&c->binarypoint); - c->dec_index=(int *)_ogg_malloc(n*sizeof(*c->dec_index)); - - for(n=0,i=0;ientries;i++) - if(s->lengthlist[i]>0) - c->dec_index[sortindex[n++]]=i; - - c->dec_codelengths=(char *)_ogg_malloc(n*sizeof(*c->dec_codelengths)); - for(n=0,i=0;ientries;i++) - if(s->lengthlist[i]>0) - c->dec_codelengths[sortindex[n++]]=s->lengthlist[i]; - - _ogg_free(sortindex); -/* Use a larger cache size when we have a large codec buffer, helps decoding - speed especially on targets with slow memory and high bitrate files */ -#if CODEC_SIZE < 0x100000 - c->dec_firsttablen=_ilog(c->used_entries)-4; /* this is magic */ -#else - c->dec_firsttablen=_ilog(c->used_entries)+1; /* this is magic */ -#endif - if(c->dec_firsttablen<5)c->dec_firsttablen=5; - if(c->dec_firsttablen>8)c->dec_firsttablen=8; - - tabn=1<dec_firsttablen; - c->dec_firsttable=(ogg_uint32_t *)_ogg_calloc(tabn,sizeof(*c->dec_firsttable)); - c->dec_maxlength=0; - - for(i=0;idec_maxlengthdec_codelengths[i]) - c->dec_maxlength=c->dec_codelengths[i]; - if(c->dec_codelengths[i]<=c->dec_firsttablen){ - ogg_uint32_t orig=bitreverse(c->codelist[i]); - for(j=0;j<(1<<(c->dec_firsttablen-c->dec_codelengths[i]));j++) - c->dec_firsttable[orig|(j<dec_codelengths[i])]=i+1; - } - } - - /* now fill in 'unused' entries in the firsttable with hi/lo search - hints for the non-direct-hits */ - { - ogg_uint32_t mask=0xfffffffeUL<<(31-c->dec_firsttablen); - long lo=0,hi=0; - - for(i=0;idec_firsttablen); - if(c->dec_firsttable[bitreverse(word)]==0){ - while((lo+1)codelist[lo+1]<=word)lo++; - while( hi=(c->codelist[hi]&mask))hi++; - - /* we only actually have 15 bits per hint to play with here. - In order to overflow gracefully (nothing breaks, efficiency - just drops), encode as the difference from the extremes. */ - { - unsigned long loval=lo; - unsigned long hival=n-hi; - - if(loval>0x7fff)loval=0x7fff; - if(hival>0x7fff)hival=0x7fff; - c->dec_firsttable[bitreverse(word)]= - 0x80000000UL | (loval<<15) | hival; - } - } - } - } - } - - return(0); - err_out: - vorbis_book_clear(c); - return(-1); -} - diff --git a/apps/codecs/libtremor/synthesis.c b/apps/codecs/libtremor/synthesis.c deleted file mode 100644 index d1ef99ae37..0000000000 --- a/apps/codecs/libtremor/synthesis.c +++ /dev/null @@ -1,129 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * - * * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2003 * - * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * - * * - ******************************************************************** - - function: single-block PCM synthesis - last mod: $Id$ - - ********************************************************************/ - -#include -#include "ogg.h" -#include "ivorbiscodec.h" -#include "codec_internal.h" -#include "registry.h" -#include "misc.h" -#include "os.h" - - -static inline int _vorbis_synthesis1(vorbis_block *vb,ogg_packet *op,int decodep){ - vorbis_dsp_state *vd= vb ? vb->vd : 0; - private_state *b= vd ? (private_state *)vd->backend_state: 0; - vorbis_info *vi= vd ? vd->vi : 0; - codec_setup_info *ci= vi ? (codec_setup_info *)vi->codec_setup : 0; - oggpack_buffer *opb=vb ? &vb->opb : 0; - int type,mode; - - if (!vd || !b || !vi || !ci || !opb) { - return OV_EBADPACKET; - } - - /* first things first. Make sure decode is ready */ - _vorbis_block_ripcord(vb); - oggpack_readinit(opb,op->packet,op->bytes); - - /* Check the packet type */ - if(oggpack_read(opb,1)!=0){ - /* Oops. This is not an audio data packet */ - return(OV_ENOTAUDIO); - } - - /* read our mode and pre/post windowsize */ - mode=oggpack_read(opb,b->modebits); - if(mode==-1)return(OV_EBADPACKET); - - vb->mode=mode; - if(!ci->mode_param[mode]){ - return(OV_EBADPACKET); - } - - vb->W=ci->mode_param[mode]->blockflag; - if(vb->W){ - vb->lW=oggpack_read(opb,1); - vb->nW=oggpack_read(opb,1); - if(vb->nW==-1) return(OV_EBADPACKET); - }else{ - vb->lW=0; - vb->nW=0; - } - - /* more setup */ - vb->granulepos=op->granulepos; - vb->sequence=op->packetno-3; /* first block is third packet */ - vb->eofflag=op->e_o_s; - - if(decodep && vi->channels<=CHANNELS) - { - /* set pcm end point */ - vb->pcmend=ci->blocksizes[vb->W]; - - /* unpack_header enforces range checking */ - type=ci->map_type[ci->mode_param[mode]->mapping]; - return(_mapping_P[type]->inverse(vb,b->mode[mode])); - }else{ - /* no pcm */ - vb->pcmend=0; - return(0); - } -} - -int vorbis_synthesis(vorbis_block *vb,ogg_packet *op) - ICODE_ATTR_TREMOR_NOT_MDCT; -int vorbis_synthesis(vorbis_block *vb,ogg_packet *op){ - return _vorbis_synthesis1(vb,op,1); -} - -/* used to track pcm position without actually performing decode. - Useful for sequential 'fast forward' */ -int vorbis_synthesis_trackonly(vorbis_block *vb,ogg_packet *op){ - return _vorbis_synthesis1(vb,op,0); -} - -long vorbis_packet_blocksize(vorbis_info *vi,ogg_packet *op){ - codec_setup_info *ci=(codec_setup_info *)vi->codec_setup; - oggpack_buffer opb; - int mode; - - oggpack_readinit(&opb,op->packet,op->bytes); - - /* Check the packet type */ - if(oggpack_read(&opb,1)!=0){ - /* Oops. This is not an audio data packet */ - return(OV_ENOTAUDIO); - } - - { - int modebits=0; - int v=ci->modes; - while(v>1){ - modebits++; - v>>=1; - } - - /* read our mode and pre/post windowsize */ - mode=oggpack_read(&opb,modebits); - } - if(mode==-1)return(OV_EBADPACKET); - return(ci->blocksizes[ci->mode_param[mode]->blockflag]); -} - - diff --git a/apps/codecs/libtremor/vorbisfile.c b/apps/codecs/libtremor/vorbisfile.c deleted file mode 100644 index 271e5a09e3..0000000000 --- a/apps/codecs/libtremor/vorbisfile.c +++ /dev/null @@ -1,1671 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * - * * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2003 * - * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * - * * - ******************************************************************** - - function: stdio-based convenience library for opening/seeking/decoding - last mod: $Id$ - - ********************************************************************/ - -#include "config-tremor.h" -#include -#include -#include -#include -#include "system.h" - -#include "ivorbiscodec.h" -#include "ivorbisfile.h" - -#include "os.h" -#include "misc.h" - -/* A 'chained bitstream' is a Vorbis bitstream that contains more than - one logical bitstream arranged end to end (the only form of Ogg - multiplexing allowed in a Vorbis bitstream; grouping [parallel - multiplexing] is not allowed in Vorbis) */ - -/* A Vorbis file can be played beginning to end (streamed) without - worrying ahead of time about chaining (see decoder_example.c). If - we have the whole file, however, and want random access - (seeking/scrubbing) or desire to know the total length/time of a - file, we need to account for the possibility of chaining. */ - -/* We can handle things a number of ways; we can determine the entire - bitstream structure right off the bat, or find pieces on demand. - This example determines and caches structure for the entire - bitstream, but builds a virtual decoder on the fly when moving - between links in the chain. */ - -/* There are also different ways to implement seeking. Enough - information exists in an Ogg bitstream to seek to - sample-granularity positions in the output. Or, one can seek by - picking some portion of the stream roughly in the desired area if - we only want coarse navigation through the stream. */ - -/************************************************************************* - * Many, many internal helpers. The intention is not to be confusing; - * rampant duplication and monolithic function implementation would be - * harder to understand anyway. The high level functions are last. Begin - * grokking near the end of the file */ - - -/* read a little more data from the file/pipe into the ogg_sync framer */ -static long _get_data(OggVorbis_File *vf){ - if(!(vf->callbacks.read_func))return(-1); - if(vf->datasource){ - char *buffer=ogg_sync_buffer(&vf->oy,CHUNKSIZE); - long bytes=(vf->callbacks.read_func)(buffer,1,CHUNKSIZE,vf->datasource); - if(bytes>0)ogg_sync_wrote(&vf->oy,bytes); - return(bytes); - }else - return(0); -} - -/* save a tiny smidge of verbosity to make the code more readable */ -static int _seek_helper(OggVorbis_File *vf,ogg_int64_t offset){ - if(vf->datasource){ - if(!(vf->callbacks.seek_func)|| - (vf->callbacks.seek_func)(vf->datasource, offset, SEEK_SET) == -1) - return OV_EREAD; - vf->offset=offset; - ogg_sync_reset(&vf->oy); - }else{ - /* shouldn't happen unless someone writes a broken callback */ - return OV_EFAULT; - } - return 0; -} - -/* The read/seek functions track absolute position within the stream */ - -/* from the head of the stream, get the next page. boundary specifies - if the function is allowed to fetch more data from the stream (and - how much) or only use internally buffered data. - - boundary: -1) unbounded search - 0) read no additional data; use cached only - n) search for a new page beginning for n bytes - - return: <0) did not find a page (OV_FALSE, OV_EOF, OV_EREAD) - n) found a page at absolute offset n */ - -static ogg_int64_t _get_next_page(OggVorbis_File *vf,ogg_page *og, - ogg_int64_t boundary){ - if(boundary>0)boundary+=vf->offset; - while(1){ - long more; - - if(boundary>0 && vf->offset>=boundary)return(OV_FALSE); - more=ogg_sync_pageseek(&vf->oy,og); - - if(more<0){ - /* skipped n bytes */ - vf->offset-=more; - }else{ - if(more==0){ - /* send more paramedics */ - if(!boundary)return(OV_FALSE); - { - long ret=_get_data(vf); - if(ret==0)return(OV_EOF); - if(ret<0)return(OV_EREAD); - } - }else{ - /* got a page. Return the offset at the page beginning, - advance the internal offset past the page end */ - ogg_int64_t ret=vf->offset; - vf->offset+=more; - return(ret); - - } - } - } -} - -/* This is a nasty hack to work around the huge allocations we get from - huge comment packets, usually due to embedded album art */ -static int ogg_stream_discard_packet(OggVorbis_File *vf,ogg_page *og, - ogg_int64_t boundary){ - int ret; - while((ret = ogg_stream_packetout(&vf->os, NULL)) == 0) { - if(_get_next_page(vf, og, boundary)<0) - break; - ogg_stream_pagein(&vf->os,og,false); - } - if (ret < 0) - return -1; - /* We might be pretending to have filled in more of the buffer than there is - actual space, in this case the body storage must be expanded before we - start writing to it */ - if (vf->os.body_fill < og->body_len || vf->os.body_storage < vf->os.body_fill) - if(_os_body_expand(&vf->os, vf->os.body_fill - vf->os.body_storage + og->body_len)) - return -1; - memcpy(vf->os.body_data+vf->os.body_fill-og->body_len, og->body, og->body_len); - return 1; -} - -/* find the latest page beginning before the current stream cursor - position. Much dirtier than the above as Ogg doesn't have any - backward search linkage. no 'readp' as it will certainly have to - read. */ -/* returns offset or OV_EREAD, OV_FAULT */ -static ogg_int64_t _get_prev_page(OggVorbis_File *vf,ogg_page *og){ - ogg_int64_t begin=vf->offset; - ogg_int64_t end=begin; - ogg_int64_t ret; - ogg_int64_t offset=-1; - - while(offset==-1){ - begin-=CHUNKSIZE; - if(begin<0) - begin=0; - - ret=_seek_helper(vf,begin); - if(ret)return(ret); - - while(vf->offsetoffset); - if(ret==OV_EREAD)return(OV_EREAD); - if(ret<0){ - break; - }else{ - offset=ret; - } - } - } - - /* In a fully compliant, non-multiplexed stream, we'll still be - holding the last page. In multiplexed (or noncompliant streams), - we will probably have to re-read the last page we saw */ - if(og->header_len==0){ - ret=_seek_helper(vf,offset); - if(ret)return(ret); - - ret=_get_next_page(vf,og,CHUNKSIZE); - if(ret<0) - /* this shouldn't be possible */ - return(OV_EFAULT); - } - - return(offset); -} - -static void _add_serialno(ogg_page *og,ogg_uint32_t **serialno_list, int *n){ - long s = ogg_page_serialno(og); - (*n)++; - - if(*serialno_list){ - *serialno_list = _ogg_realloc(*serialno_list, sizeof(**serialno_list)*(*n)); - }else{ - *serialno_list = _ogg_malloc(sizeof(**serialno_list)); - } - - (*serialno_list)[(*n)-1] = s; -} - -/* returns nonzero if found */ -static int _lookup_serialno(ogg_uint32_t s, ogg_uint32_t *serialno_list, int n){ - if(serialno_list){ - while(n--){ - if(*serialno_list == (ogg_uint32_t) s) return 1; - serialno_list++; - } - } - return 0; -} - -static int _lookup_page_serialno(ogg_page *og, ogg_uint32_t *serialno_list, int n){ - ogg_uint32_t s = ogg_page_serialno(og); - return _lookup_serialno(s,serialno_list,n); -} - -/* performs the same search as _get_prev_page, but prefers pages of - the specified serial number. If a page of the specified serialno is - spotted during the seek-back-and-read-forward, it will return the - info of last page of the matching serial number instead of the very - last page. If no page of the specified serialno is seen, it will - return the info of last page and alter *serialno. */ -static ogg_int64_t _get_prev_page_serial(OggVorbis_File *vf, - ogg_uint32_t *serial_list, int serial_n, - int *serialno, ogg_int64_t *granpos){ - ogg_page og; - ogg_int64_t begin=vf->offset; - ogg_int64_t end=begin; - ogg_int64_t ret; - - ogg_int64_t prefoffset=-1; - ogg_int64_t offset=-1; - ogg_int64_t ret_serialno=-1; - ogg_int64_t ret_gran=-1; - - while(offset==-1){ - begin-=CHUNKSIZE; - if(begin<0) - begin=0; - - ret=_seek_helper(vf,begin); - if(ret)return(ret); - - while(vf->offsetoffset); - if(ret==OV_EREAD)return(OV_EREAD); - if(ret<0){ - break; - }else{ - ret_serialno=ogg_page_serialno(&og); - ret_gran=ogg_page_granulepos(&og); - offset=ret; - - if((ogg_uint32_t)ret_serialno == (ogg_uint32_t)*serialno){ - prefoffset=ret; - *granpos=ret_gran; - } - - if(!_lookup_serialno((ogg_uint32_t)ret_serialno,serial_list,serial_n)){ - /* we fell off the end of the link, which means we seeked - back too far and shouldn't have been looking in that link - to begin with. If we found the preferred serial number, - forget that we saw it. */ - prefoffset=-1; - } - } - } - } - - /* we're not interested in the page... just the serialno and granpos. */ - if(prefoffset>=0)return(prefoffset); - - *serialno = ret_serialno; - *granpos = ret_gran; - return(offset); - -} - -/* uses the local ogg_stream storage in vf; this is important for - non-streaming input sources */ -static int _fetch_headers(OggVorbis_File *vf,vorbis_info *vi, - ogg_uint32_t **serialno_list, int *serialno_n, - ogg_page *og_ptr){ - ogg_page og; - ogg_packet op; - int i,ret; - int allbos=0; - - if(!og_ptr){ - ogg_int64_t llret=_get_next_page(vf,&og,CHUNKSIZE); - if(llret==OV_EREAD)return(OV_EREAD); - if(llret<0)return(OV_ENOTVORBIS); - og_ptr=&og; - } - - vorbis_info_init(vi); -/* vorbis_comment_init(vc); */ - vf->ready_state=OPENED; - - /* extract the serialnos of all BOS pages + the first set of vorbis - headers we see in the link */ - - while(ogg_page_bos(og_ptr)){ - if(serialno_list){ - if(_lookup_page_serialno(og_ptr,*serialno_list,*serialno_n)){ - /* a dupe serialnumber in an initial header packet set == invalid stream */ - if(*serialno_list)_ogg_free(*serialno_list); - *serialno_list=0; - *serialno_n=0; - ret=OV_EBADHEADER; - goto bail_header; - } - - _add_serialno(og_ptr,serialno_list,serialno_n); - } - - if(vf->ready_stateos,ogg_page_serialno(og_ptr)); - ogg_stream_pagein(&vf->os,og_ptr,true); - - if(ogg_stream_packetout(&vf->os,&op) > 0 && - vorbis_synthesis_idheader(&op)){ - /* vorbis header; continue setup */ - vf->ready_state=STREAMSET; - if((ret=vorbis_synthesis_headerin(vi,&op))){ - ret=OV_EBADHEADER; - goto bail_header; - } - } - } - - /* get next page */ - { - ogg_int64_t llret=_get_next_page(vf,og_ptr,CHUNKSIZE); - if(llret==OV_EREAD){ - ret=OV_EREAD; - goto bail_header; - } - if(llret<0){ - ret=OV_ENOTVORBIS; - goto bail_header; - } - - /* if this page also belongs to our vorbis stream, submit it and break */ - if(vf->ready_state==STREAMSET && - vf->os.serialno == ogg_page_serialno(og_ptr)){ - ogg_stream_pagein(&vf->os,og_ptr,true); - break; - } - } - } - - if(vf->ready_state!=STREAMSET){ - ret = OV_ENOTVORBIS; - goto bail_header; - } - - while(1){ - - i=0; - /* discard comment packet */ - if(ogg_stream_discard_packet(vf,og_ptr,CHUNKSIZE) < 0){ - ret=OV_EBADHEADER; - goto bail_header; - } - i++; - - while(i<2){ /* get a page loop */ - - while(i<2){ /* get a packet loop */ - int result=ogg_stream_packetout(&vf->os,&op); - if(result==0)break; - if(result==-1){ - ret=OV_EBADHEADER; - goto bail_header; - } - - if((ret=vorbis_synthesis_headerin(vi,&op))) - goto bail_header; - - i++; - } - - while(i<2){ - if(_get_next_page(vf,og_ptr,CHUNKSIZE)<0){ - ret=OV_EBADHEADER; - goto bail_header; - } - - /* if this page belongs to the correct stream, go parse it */ - if(vf->os.serialno == ogg_page_serialno(og_ptr)){ - ogg_stream_pagein(&vf->os,og_ptr,true); - break; - } - - /* if we never see the final vorbis headers before the link - ends, abort */ - if(ogg_page_bos(og_ptr)){ - if(allbos){ - ret = OV_EBADHEADER; - goto bail_header; - }else - allbos=1; - } - - /* otherwise, keep looking */ - } - } - - return 0; - } - - bail_header: - vorbis_info_clear(vi); -/* vorbis_comment_clear(vc); */ - vf->ready_state=OPENED; - - return ret; -} - -/* Starting from current cursor position, get initial PCM offset of - next page. Consumes the page in the process without decoding - audio, however this is only called during stream parsing upon - seekable open. */ -static ogg_int64_t _initial_pcmoffset(OggVorbis_File *vf, vorbis_info *vi){ - ogg_page og; - ogg_int64_t accumulated=0; - long lastblock=-1; - int result; - ogg_uint32_t serialno = vf->os.serialno; - - while(1){ - ogg_packet op; - if(_get_next_page(vf,&og,-1)<0) - break; /* should not be possible unless the file is truncated/mangled */ - - if(ogg_page_bos(&og)) break; - if(ogg_page_serialno(&og)!= serialno) continue; - - /* count blocksizes of all frames in the page */ - ogg_stream_pagein(&vf->os,&og,true); - while((result=ogg_stream_packetout(&vf->os,&op))){ - if(result>0){ /* ignore holes */ - long thisblock=vorbis_packet_blocksize(vi,&op); - if(lastblock!=-1) - accumulated+=(lastblock+thisblock)>>2; - lastblock=thisblock; - } - } - - if(ogg_page_granulepos(&og)!=-1){ - /* pcm offset of last packet on the first audio page */ - accumulated= ogg_page_granulepos(&og)-accumulated; - break; - } - } - - /* less than zero? This is a stream with samples trimmed off - the beginning, a normal occurrence; set the offset to zero */ - if(accumulated<0)accumulated=0; - - return accumulated; -} - -/* finds each bitstream link one at a time using a bisection search - (has to begin by knowing the offset of the lb's initial page). - Recurses for each link so it can alloc the link storage after - finding them all, then unroll and fill the cache at the same time */ -static int _bisect_forward_serialno(OggVorbis_File *vf, - ogg_int64_t begin, - ogg_int64_t searched, - ogg_int64_t end, - ogg_int64_t endgran, - int endserial, - ogg_uint32_t *currentno_list, - int currentnos, - long m){ - ogg_int64_t pcmoffset; - ogg_int64_t dataoffset=searched; - ogg_int64_t endsearched=end; - ogg_int64_t next=end; - ogg_int64_t searchgran=-1; - ogg_page og; - ogg_int64_t ret,last; - int serialno = vf->os.serialno; - - /* invariants: - we have the headers and serialnos for the link beginning at 'begin' - we have the offset and granpos of the last page in the file (potentially - not a page we care about) - */ - - /* Is the last page in our list of current serialnumbers? */ - if(_lookup_serialno(endserial,currentno_list,currentnos)){ - - /* last page is in the starting serialno list, so we've bisected - down to (or just started with) a single link. Now we need to - find the last vorbis page belonging to the first vorbis stream - for this link. */ - - while(endserial != serialno){ - endserial = serialno; - vf->offset=_get_prev_page_serial(vf,currentno_list,currentnos,&endserial,&endgran); - } - - vf->links=m+1; - if(vf->offsets)_ogg_free(vf->offsets); - if(vf->serialnos)_ogg_free(vf->serialnos); - if(vf->dataoffsets)_ogg_free(vf->dataoffsets); - - vf->offsets=_ogg_malloc((vf->links+1)*sizeof(*vf->offsets)); - vf->vi=_ogg_realloc(vf->vi,vf->links*sizeof(*vf->vi)); -/* vf->vc=_ogg_realloc(vf->vc,vf->links*sizeof(*vf->vc));*/ - vf->serialnos=_ogg_malloc(vf->links*sizeof(*vf->serialnos)); - vf->dataoffsets=_ogg_malloc(vf->links*sizeof(*vf->dataoffsets)); - vf->pcmlengths=_ogg_malloc(vf->links*2*sizeof(*vf->pcmlengths)); - - vf->offsets[m+1]=end; - vf->offsets[m]=begin; - vf->pcmlengths[m*2+1]=endgran; - - }else{ - - ogg_uint32_t *next_serialno_list=NULL; - int next_serialnos=0; - vorbis_info vi; -/* vorbis_comment vc; */ - - /* the below guards against garbage seperating the last and - first pages of two links. */ - while(searchedoffset){ - ret=_seek_helper(vf,bisect); - if(ret)return(ret); - } - - last=_get_next_page(vf,&og,-1); - if(last==OV_EREAD)return(OV_EREAD); - if(last<0 || !_lookup_page_serialno(&og,currentno_list,currentnos)){ - endsearched=bisect; - if(last>=0)next=last; - }else{ - searched=vf->offset; - } - } - - /* Bisection point found */ - - /* for the time being, fetch end PCM offset the simple way */ - { - int testserial = serialno+1; - vf->offset = next; - while(testserial != serialno){ - testserial = serialno; - vf->offset=_get_prev_page_serial(vf,currentno_list,currentnos,&testserial,&searchgran); - } - } - - if(vf->offset!=next){ - ret=_seek_helper(vf,next); - if(ret)return(ret); - } - - ret=_fetch_headers(vf,&vi,&next_serialno_list,&next_serialnos,NULL); - if(ret)return(ret); - serialno = vf->os.serialno; - dataoffset = vf->offset; - - /* this will consume a page, however the next bistection always - starts with a raw seek */ - pcmoffset = _initial_pcmoffset(vf,&vi); - - ret=_bisect_forward_serialno(vf,next,vf->offset,end,endgran,endserial, - next_serialno_list,next_serialnos,m+1); - if(ret)return(ret); - - if(next_serialno_list)_ogg_free(next_serialno_list); - - vf->offsets[m+1]=next; - vf->serialnos[m+1]=serialno; - vf->dataoffsets[m+1]=dataoffset; - - vf->vi[m+1]=vi; -/* vf->vc[m+1]=vc; */ - - vf->pcmlengths[m*2+1]=searchgran; - vf->pcmlengths[m*2+2]=pcmoffset; - vf->pcmlengths[m*2+3]-=pcmoffset; - - } - return(0); -} - -static int _make_decode_ready(OggVorbis_File *vf){ - if(vf->ready_state>STREAMSET)return 0; - if(vf->ready_stateseekable){ - if(vorbis_synthesis_init(&vf->vd,vf->vi+vf->current_link)) - return OV_EBADLINK; - }else{ - if(vorbis_synthesis_init(&vf->vd,vf->vi)) - return OV_EBADLINK; - } - vorbis_block_init(&vf->vd,&vf->vb); - vf->ready_state=INITSET; - vf->bittrack=0; - vf->samptrack=0; - return 0; -} - -static int _open_seekable2(OggVorbis_File *vf){ - ogg_int64_t dataoffset=vf->dataoffsets[0],end,endgran=-1; - int endserial=vf->os.serialno; - int serialno=vf->os.serialno; - - /* we're partially open and have a first link header state in - storage in vf */ - - /* fetch initial PCM offset */ - ogg_int64_t pcmoffset = _initial_pcmoffset(vf,vf->vi); - - /* we can seek, so set out learning all about this file */ - if(vf->callbacks.seek_func && vf->callbacks.tell_func){ - (vf->callbacks.seek_func)(vf->datasource,0,SEEK_END); - vf->offset=vf->end=(vf->callbacks.tell_func)(vf->datasource); - }else{ - vf->offset=vf->end=-1; - } - - /* If seek_func is implemented, tell_func must also be implemented */ - if(vf->end==-1) return(OV_EINVAL); - - /* Get the offset of the last page of the physical bitstream, or, if - we're lucky the last vorbis page of this link as most OggVorbis - files will contain a single logical bitstream */ - end=_get_prev_page_serial(vf,vf->serialnos+2,vf->serialnos[1],&endserial,&endgran); - if(end<0)return(end); - - /* now determine bitstream structure recursively */ - if(_bisect_forward_serialno(vf,0,dataoffset,vf->offset,endgran,endserial, - vf->serialnos+2,vf->serialnos[1],0)<0)return(OV_EREAD); - - vf->offsets[0]=0; - vf->serialnos[0]=serialno; - vf->dataoffsets[0]=dataoffset; - vf->pcmlengths[0]=pcmoffset; - vf->pcmlengths[1]-=pcmoffset; - - return(ov_raw_seek(vf,dataoffset)); -} - -/* clear out the current logical bitstream decoder */ -static void _decode_clear(OggVorbis_File *vf){ - vorbis_dsp_clear(&vf->vd); - vorbis_block_clear(&vf->vb); - vf->ready_state=OPENED; -} - -/* fetch and process a packet. Handles the case where we're at a - bitstream boundary and dumps the decoding machine. If the decoding - machine is unloaded, it loads it. It also keeps pcm_offset up to - date (seek and read both use this. seek uses a special hack with - readp). - - return: <0) error, OV_HOLE (lost packet) or OV_EOF - 0) need more data (only if readp==0) - 1) got a packet -*/ - -static int _fetch_and_process_packet(OggVorbis_File *vf, - ogg_packet *op_in, - int readp, - int spanp){ - ogg_page og; - - /* handle one packet. Try to fetch it from current stream state */ - /* extract packets from page */ - while(1){ - - if(vf->ready_state==STREAMSET){ - int ret=_make_decode_ready(vf); - if(ret<0)return ret; - } - - /* process a packet if we can. If the machine isn't loaded, - neither is a page */ - if(vf->ready_state==INITSET){ - while(1) { - ogg_packet op; - ogg_packet *op_ptr=(op_in?op_in:&op); - int result=ogg_stream_packetout(&vf->os,op_ptr); - ogg_int64_t granulepos; - - op_in=NULL; - if(result==-1)return(OV_HOLE); /* hole in the data. */ - if(result>0){ - /* got a packet. process it */ - granulepos=op_ptr->granulepos; - if(!vorbis_synthesis(&vf->vb,op_ptr)){ /* lazy check for lazy - header handling. The - header packets aren't - audio, so if/when we - submit them, - vorbis_synthesis will - reject them */ - - /* suck in the synthesis data and track bitrate */ - { - int oldsamples=vorbis_synthesis_pcmout(&vf->vd,NULL); - /* for proper use of libvorbis within libvorbisfile, - oldsamples will always be zero. */ - if(oldsamples)return(OV_EFAULT); - - vorbis_synthesis_blockin(&vf->vd,&vf->vb); - vf->samptrack+=vorbis_synthesis_pcmout(&vf->vd,NULL)-oldsamples; - vf->bittrack+=op_ptr->bytes*8; - } - - /* update the pcm offset. */ - if(granulepos!=-1 && !op_ptr->e_o_s){ - int link=(vf->seekable?vf->current_link:0); - int i,samples; - - /* this packet has a pcm_offset on it (the last packet - completed on a page carries the offset) After processing - (above), we know the pcm position of the *last* sample - ready to be returned. Find the offset of the *first* - - As an aside, this trick is inaccurate if we begin - reading anew right at the last page; the end-of-stream - granulepos declares the last frame in the stream, and the - last packet of the last page may be a partial frame. - So, we need a previous granulepos from an in-sequence page - to have a reference point. Thus the !op_ptr->e_o_s clause - above */ - - if(vf->seekable && link>0) - granulepos-=vf->pcmlengths[link*2]; - if(granulepos<0)granulepos=0; /* actually, this - shouldn't be possible - here unless the stream - is very broken */ - - samples=vorbis_synthesis_pcmout(&vf->vd,NULL); - - granulepos-=samples; - for(i=0;ipcmlengths[i*2+1]; - vf->pcm_offset=granulepos; - } - return(1); - } - } - else - break; - } - } - - if(vf->ready_state>=OPENED){ - ogg_int64_t ret; - - while(1){ - /* the loop is not strictly necessary, but there's no sense in - doing the extra checks of the larger loop for the common - case in a multiplexed bistream where the page is simply - part of a different logical bitstream; keep reading until - we get one with the correct serialno */ - - if(!readp)return(0); - if((ret=_get_next_page(vf,&og,-1))<0){ - return(OV_EOF); /* eof. leave unitialized */ - } - - /* bitrate tracking; add the header's bytes here, the body bytes - are done by packet above */ - vf->bittrack+=og.header_len*8; - - if(vf->ready_state==INITSET){ - if(vf->current_serialno!=ogg_page_serialno(&og)){ - - /* two possibilities: - 1) our decoding just traversed a bitstream boundary - 2) another stream is multiplexed into this logical section */ - - if(ogg_page_bos(&og)){ - /* boundary case */ - if(!spanp) - return(OV_EOF); - - _decode_clear(vf); - - if(!vf->seekable){ - vorbis_info_clear(vf->vi); -/* vorbis_comment_clear(vf->vc); */ - } - break; - - }else - continue; /* possibility #2 */ - } - } - - break; - } - } - - /* Do we need to load a new machine before submitting the page? */ - /* This is different in the seekable and non-seekable cases. - - In the seekable case, we already have all the header - information loaded and cached; we just initialize the machine - with it and continue on our merry way. - - In the non-seekable (streaming) case, we'll only be at a - boundary if we just left the previous logical bitstream and - we're now nominally at the header of the next bitstream - */ - - if(vf->ready_state!=INITSET){ - int link; - - if(vf->ready_stateseekable){ - ogg_uint32_t serialno = ogg_page_serialno(&og); - - /* match the serialno to bitstream section. We use this rather than - offset positions to avoid problems near logical bitstream - boundaries */ - - for(link=0;linklinks;link++) - if(vf->serialnos[link]==serialno)break; - - if(link==vf->links) continue; /* not the desired Vorbis - bitstream section; keep - trying */ - - vf->current_serialno=serialno; - vf->current_link=link; - - ogg_stream_reset_serialno(&vf->os,vf->current_serialno); - vf->ready_state=STREAMSET; - - }else{ - /* we're streaming */ - /* fetch the three header packets, build the info struct */ - - int ret=_fetch_headers(vf,vf->vi,NULL,NULL,&og); - if(ret)return(ret); - vf->current_serialno=vf->os.serialno; - vf->current_link++; - link=0; - } - } - } - - /* the buffered page is the data we want, and we're ready for it; - add it to the stream state */ - ogg_stream_pagein(&vf->os,&og,true); - - } -} - -static int _ov_open1(void *f,OggVorbis_File *vf,const char *initial, - long ibytes, ov_callbacks callbacks){ - int offsettest=((f && callbacks.seek_func)?callbacks.seek_func(f,0,SEEK_CUR):-1); - ogg_uint32_t *serialno_list=NULL; - int serialno_list_size=0; - int ret; - - memset(vf,0,sizeof(*vf)); - vf->datasource=f; - vf->callbacks = callbacks; - - /* init the framing state */ - ogg_sync_init(&vf->oy); - - /* perhaps some data was previously read into a buffer for testing - against other stream types. Allow initialization from this - previously read data (especially as we may be reading from a - non-seekable stream) */ - if(initial){ - char *buffer=ogg_sync_buffer(&vf->oy,ibytes); - memcpy(buffer,initial,ibytes); - ogg_sync_wrote(&vf->oy,ibytes); - } - - /* can we seek? Stevens suggests the seek test was portable */ - if(offsettest!=-1)vf->seekable=1; - - /* No seeking yet; Set up a 'single' (current) logical bitstream - entry for partial open */ - vf->links=1; - vf->vi=_ogg_calloc(vf->links,sizeof(*vf->vi)); -/* vf->vc=_ogg_calloc(vf->links,sizeof(*vf->vc)); */ - ogg_stream_init(&vf->os,-1); /* fill in the serialno later */ - - /* Fetch all BOS pages, store the vorbis header and all seen serial - numbers, load subsequent vorbis setup headers */ - if((ret=_fetch_headers(vf,vf->vi,&serialno_list,&serialno_list_size,NULL))<0){ - vf->datasource=NULL; - ov_clear(vf); - }else{ - /* serial number list for first link needs to be held somewhere - for second stage of seekable stream open; this saves having to - seek/reread first link's serialnumber data then. */ - vf->serialnos=_ogg_calloc(serialno_list_size+2,sizeof(*vf->serialnos)); - vf->serialnos[0]=vf->current_serialno=vf->os.serialno; - vf->serialnos[1]=serialno_list_size; - memcpy(vf->serialnos+2,serialno_list,serialno_list_size*sizeof(*vf->serialnos)); - - vf->offsets=_ogg_calloc(1,sizeof(*vf->offsets)); - vf->dataoffsets=_ogg_calloc(1,sizeof(*vf->dataoffsets)); - vf->offsets[0]=0; - vf->dataoffsets[0]=vf->offset; - - vf->ready_state=PARTOPEN; - } - if(serialno_list)_ogg_free(serialno_list); - return(ret); -} - -static int _ov_open2(OggVorbis_File *vf){ - if(vf->ready_state != PARTOPEN) return OV_EINVAL; - vf->ready_state=OPENED; - if(vf->seekable){ - int ret=_open_seekable2(vf); - if(ret){ - vf->datasource=NULL; - ov_clear(vf); - } - return(ret); - }else - vf->ready_state=STREAMSET; - - return 0; -} - - -/* clear out the OggVorbis_File struct */ -int ov_clear(OggVorbis_File *vf){ - if(vf){ - vorbis_block_clear(&vf->vb); - vorbis_dsp_clear(&vf->vd); - ogg_stream_clear(&vf->os); - - if(vf->vi && vf->links){ - int i; - for(i=0;ilinks;i++){ - vorbis_info_clear(vf->vi+i); -/* vorbis_comment_clear(vf->vc+i); */ - } - _ogg_free(vf->vi); -/* _ogg_free(vf->vc); */ - } - if(vf->dataoffsets)_ogg_free(vf->dataoffsets); - if(vf->pcmlengths)_ogg_free(vf->pcmlengths); - if(vf->serialnos)_ogg_free(vf->serialnos); - if(vf->offsets)_ogg_free(vf->offsets); - ogg_sync_clear(&vf->oy); - if(vf->datasource && vf->callbacks.close_func) - (vf->callbacks.close_func)(vf->datasource); - memset(vf,0,sizeof(*vf)); - } -#ifdef DEBUG_LEAKS - _VDBG_dump(); -#endif - return(0); -} - -/* inspects the OggVorbis file and finds/documents all the logical - bitstreams contained in it. Tries to be tolerant of logical - bitstream sections that are truncated/woogie. - - return: -1) error - 0) OK -*/ - -int ov_open_callbacks(void *f,OggVorbis_File *vf, - const char *initial,long ibytes,ov_callbacks callbacks){ - #if defined(CPU_COLDFIRE) - /* this seems to be the closest we get to an init function, let's init emac - here. rounding is disabled because of MULT31_SHIFT15, which will be - inaccurate with rounding in its current incarnation */ - coldfire_set_macsr(EMAC_FRACTIONAL | EMAC_SATURATE); - #endif - int ret=_ov_open1(f,vf,initial,ibytes,callbacks); - if(ret)return ret; - return _ov_open2(vf); -} - -/* returns: total PCM length (samples) of content if i==-1 PCM length - (samples) of that logical bitstream for i==0 to n - OV_EINVAL if the stream is not seekable (we can't know the - length) or only partially open -*/ -ogg_int64_t ov_pcm_total(OggVorbis_File *vf,int i){ - if(vf->ready_stateseekable || i>=vf->links)return(OV_EINVAL); - if(i<0){ - ogg_int64_t acc=0; - int i; - for(i=0;ilinks;i++) - acc+=ov_pcm_total(vf,i); - return(acc); - }else{ - return(vf->pcmlengths[i*2+1]); - } -} - -/* returns: total milliseconds of content if i==-1 - milliseconds in that logical bitstream for i==0 to n - OV_EINVAL if the stream is not seekable (we can't know the - length) or only partially open -*/ -ogg_int64_t ov_time_total(OggVorbis_File *vf,int i){ - if(vf->ready_stateseekable || i>=vf->links)return(OV_EINVAL); - if(i<0){ - ogg_int64_t acc=0; - int i; - for(i=0;ilinks;i++) - acc+=ov_time_total(vf,i); - return(acc); - }else{ - return(((ogg_int64_t)vf->pcmlengths[i*2+1])*1000/vf->vi[i].rate); - } -} - -/* seek to an offset relative to the *compressed* data. This also - scans packets to update the PCM cursor. It will cross a logical - bitstream boundary, but only if it can't get any packets out of the - tail of the bitstream we seek to (so no surprises). - - returns zero on success, nonzero on failure */ - -int ov_raw_seek(OggVorbis_File *vf,ogg_int64_t pos){ - ogg_stream_state work_os; - int ret; - - if(vf->ready_stateseekable) - return(OV_ENOSEEK); /* don't dump machine if we can't seek */ - - if(pos<0 || pos>vf->end)return(OV_EINVAL); - - /* is the seek position outside our current link [if any]? */ - if(vf->ready_state>=STREAMSET){ - if(posoffsets[vf->current_link] || pos>=vf->offsets[vf->current_link+1]) - _decode_clear(vf); /* clear out stream state */ - } - - /* don't yet clear out decoding machine (if it's initialized), in - the case we're in the same link. Restart the decode lapping, and - let _fetch_and_process_packet deal with a potential bitstream - boundary */ - vf->pcm_offset=-1; - ogg_stream_reset_serialno(&vf->os, - vf->current_serialno); /* must set serialno */ - vorbis_synthesis_restart(&vf->vd); - - ret=_seek_helper(vf,pos); - if(ret)goto seek_error; - - /* we need to make sure the pcm_offset is set, but we don't want to - advance the raw cursor past good packets just to get to the first - with a granulepos. That's not equivalent behavior to beginning - decoding as immediately after the seek position as possible. - - So, a hack. We use two stream states; a local scratch state and - the shared vf->os stream state. We use the local state to - scan, and the shared state as a buffer for later decode. - - Unfortuantely, on the last page we still advance to last packet - because the granulepos on the last page is not necessarily on a - packet boundary, and we need to make sure the granpos is - correct. - */ - - { - ogg_page og; - ogg_packet op; - int lastblock=0; - int accblock=0; - int thisblock=0; - int lastflag=0; - int firstflag=0; - ogg_int64_t pagepos=-1; - - ogg_stream_init(&work_os,vf->current_serialno); /* get the memory ready */ - ogg_stream_reset(&work_os); /* eliminate the spurious OV_HOLE - return from not necessarily - starting from the beginning */ - - while(1){ - if(vf->ready_state>=STREAMSET){ - /* snarf/scan a packet if we can */ - int result=ogg_stream_packetout(&work_os,&op); - - if(result>0){ - - if(vf->vi[vf->current_link].codec_setup){ - thisblock=vorbis_packet_blocksize(vf->vi+vf->current_link,&op); - if(thisblock<0){ - ogg_stream_packetout(&vf->os,NULL); - thisblock=0; - }else{ - - /* We can't get a guaranteed correct pcm position out of the - last page in a stream because it might have a 'short' - granpos, which can only be detected in the presence of a - preceding page. However, if the last page is also the first - page, the granpos rules of a first page take precedence. Not - only that, but for first==last, the EOS page must be treated - as if its a normal first page for the stream to open/play. */ - if(lastflag && !firstflag) - ogg_stream_packetout(&vf->os,NULL); - else - if(lastblock)accblock+=(lastblock+thisblock)>>2; - } - - if(op.granulepos!=-1){ - int i,link=vf->current_link; - ogg_int64_t granulepos=op.granulepos-vf->pcmlengths[link*2]; - if(granulepos<0)granulepos=0; - - for(i=0;ipcmlengths[i*2+1]; - vf->pcm_offset=granulepos-accblock; - if(vf->pcm_offset<0)vf->pcm_offset=0; - break; - } - lastblock=thisblock; - continue; - }else - ogg_stream_packetout(&vf->os,NULL); - } - } - - if(!lastblock){ - pagepos=_get_next_page(vf,&og,-1); - if(pagepos<0){ - vf->pcm_offset=ov_pcm_total(vf,-1); - break; - } - }else{ - /* huh? Bogus stream with packets but no granulepos */ - vf->pcm_offset=-1; - break; - } - - /* has our decoding just traversed a bitstream boundary? */ - if(vf->ready_state>=STREAMSET){ - if(vf->current_serialno!=ogg_page_serialno(&og)){ - - /* two possibilities: - 1) our decoding just traversed a bitstream boundary - 2) another stream is multiplexed into this logical section? */ - - if(ogg_page_bos(&og)){ - /* we traversed */ - _decode_clear(vf); /* clear out stream state */ - ogg_stream_clear(&work_os); - } /* else, do nothing; next loop will scoop another page */ - } - } - - if(vf->ready_statelinks;link++) - if(vf->serialnos[link]==serialno)break; - - if(link==vf->links) continue; /* not the desired Vorbis - bitstream section; keep - trying */ - vf->current_link=link; - vf->current_serialno=serialno; - ogg_stream_reset_serialno(&vf->os,serialno); - ogg_stream_reset_serialno(&work_os,serialno); - vf->ready_state=STREAMSET; - firstflag=(pagepos<=vf->dataoffsets[link]); - } - - ogg_stream_pagein(&vf->os,&og,true); - ogg_stream_pagein(&work_os,&og,true); - lastflag=ogg_page_eos(&og); - - } - } - - ogg_stream_clear(&work_os); - vf->bittrack=0; - vf->samptrack=0; - return(0); - - seek_error: - /* dump the machine so we're in a known state */ - vf->pcm_offset=-1; - ogg_stream_clear(&work_os); - _decode_clear(vf); - return OV_EBADLINK; -} - -/* rescales the number x from the range of [0,from] to [0,to] - x is in the range [0,from] - from, to are in the range [1, 1<<62-1] */ -ogg_int64_t rescale64(ogg_int64_t x, ogg_int64_t from, ogg_int64_t to){ - ogg_int64_t frac=0; - ogg_int64_t ret=0; - int i; - if(x >= from) return to; - if(x <= 0) return 0; - - for(i=0;i<64;i++){ - if(x>=from){ - frac|=1; - x-=from; - } - x<<=1; - frac<<=1; - } - - for(i=0;i<64;i++){ - if(frac & 1){ - ret+=to; - } - frac>>=1; - ret>>=1; - } - - return ret; -} - -/* Page granularity seek (faster than sample granularity because we - don't do the last bit of decode to find a specific sample). - - Seek to the last [granule marked] page preceding the specified pos - location, such that decoding past the returned point will quickly - arrive at the requested position. */ -int ov_pcm_seek_page(OggVorbis_File *vf,ogg_int64_t pos){ - int link=-1; - ogg_int64_t result=0; - ogg_int64_t total=ov_pcm_total(vf,-1); - - if(vf->ready_stateseekable)return(OV_ENOSEEK); - - if(pos<0 || pos>total)return(OV_EINVAL); - - /* which bitstream section does this pcm offset occur in? */ - for(link=vf->links-1;link>=0;link--){ - total-=vf->pcmlengths[link*2+1]; - if(pos>=total)break; - } - - /* search within the logical bitstream for the page with the highest - pcm_pos preceding (or equal to) pos. There is a danger here; - missing pages or incorrect frame number information in the - bitstream could make our task impossible. Account for that (it - would be an error condition) */ - - /* new search algorithm by HB (Nicholas Vinen) */ - { - ogg_int64_t end=vf->offsets[link+1]; - ogg_int64_t begin=vf->offsets[link]; - ogg_int64_t begintime = vf->pcmlengths[link*2]; - ogg_int64_t endtime = vf->pcmlengths[link*2+1]+begintime; - ogg_int64_t target=pos-total+begintime; - ogg_int64_t best=begin; - - ogg_page og; - while(beginoffset){ - result=_seek_helper(vf,bisect); - if(result) goto seek_error; - } - - while(beginoffset); - if(result==OV_EREAD) goto seek_error; - if(result<0){ - if(bisect<=begin+1) - end=begin; /* found it */ - else{ - if(bisect==0) goto seek_error; - bisect-=CHUNKSIZE; - if(bisect<=begin)bisect=begin+1; - result=_seek_helper(vf,bisect); - if(result) goto seek_error; - } - }else{ - ogg_int64_t granulepos; - - if(ogg_page_serialno(&og)!=vf->serialnos[link]) - continue; - - granulepos=ogg_page_granulepos(&og); - if(granulepos==-1)continue; - - if(granuleposoffset; /* raw offset of next page */ - begintime=granulepos; - - if(target-begintime>44100)break; - bisect=begin; /* *not* begin + 1 */ - }else{ - if(bisect<=begin+1) - end=begin; /* found it */ - else{ - if(end==vf->offset){ /* we're pretty close - we'd be stuck in */ - end=result; - bisect-=CHUNKSIZE; /* an endless loop otherwise. */ - if(bisect<=begin)bisect=begin+1; - result=_seek_helper(vf,bisect); - if(result) goto seek_error; - }else{ - end=bisect; - endtime=granulepos; - break; - } - } - } - } - } - } - - /* found our page. seek to it, update pcm offset. Easier case than - raw_seek, don't keep packets preceding granulepos. */ - { - ogg_page og; - ogg_packet op; - - /* seek */ - result=_seek_helper(vf,best); - vf->pcm_offset=-1; - if(result) goto seek_error; - result=_get_next_page(vf,&og,-1); - if(result<0) goto seek_error; - - if(link!=vf->current_link){ - /* Different link; dump entire decode machine */ - _decode_clear(vf); - - vf->current_link=link; - vf->current_serialno=vf->serialnos[link]; - vf->ready_state=STREAMSET; - - }else{ - vorbis_synthesis_restart(&vf->vd); - } - - ogg_stream_reset_serialno(&vf->os,vf->current_serialno); - ogg_stream_pagein(&vf->os,&og,true); - - /* pull out all but last packet; the one with granulepos */ - while(1){ - result=ogg_stream_packetpeek(&vf->os,&op); - if(result==0){ - /* !!! the packet finishing this page originated on a - preceding page. Keep fetching previous pages until we - get one with a granulepos or without the 'continued' flag - set. Then just use raw_seek for simplicity. */ - - result=_seek_helper(vf,best); - if(result<0) goto seek_error; - - while(1){ - result=_get_prev_page(vf,&og); - if(result<0) goto seek_error; - if(ogg_page_serialno(&og)==vf->current_serialno && - (ogg_page_granulepos(&og)>-1 || - !ogg_page_continued(&og))){ - return ov_raw_seek(vf,result); - } - vf->offset=result; - } - } - if(result<0){ - result = OV_EBADPACKET; - goto seek_error; - } - if(op.granulepos!=-1){ - vf->pcm_offset=op.granulepos-vf->pcmlengths[vf->current_link*2]; - if(vf->pcm_offset<0)vf->pcm_offset=0; - vf->pcm_offset+=total; - break; - }else - result=ogg_stream_packetout(&vf->os,NULL); - } - } - } - - /* verify result */ - if(vf->pcm_offset>pos || pos>ov_pcm_total(vf,-1)){ - result=OV_EFAULT; - goto seek_error; - } - vf->bittrack=0; - vf->samptrack=0; - return(0); - - seek_error: - /* dump machine so we're in a known state */ - vf->pcm_offset=-1; - _decode_clear(vf); - return (int)result; -} - -/* seek to a sample offset relative to the decompressed pcm stream - returns zero on success, nonzero on failure */ - -int ov_pcm_seek(OggVorbis_File *vf,ogg_int64_t pos){ - int thisblock,lastblock=0; - int ret=ov_pcm_seek_page(vf,pos); - if(ret<0)return(ret); - if((ret=_make_decode_ready(vf)))return ret; - - /* discard leading packets we don't need for the lapping of the - position we want; don't decode them */ - - while(1){ - ogg_packet op; - ogg_page og; - - int ret=ogg_stream_packetpeek(&vf->os,&op); - if(ret>0){ - thisblock=vorbis_packet_blocksize(vf->vi+vf->current_link,&op); - if(thisblock<0){ - ogg_stream_packetout(&vf->os,NULL); - continue; /* non audio packet */ - } - if(lastblock)vf->pcm_offset+=(lastblock+thisblock)>>2; - - if(vf->pcm_offset+((thisblock+ - vorbis_info_blocksize(vf->vi,1))>>2)>=pos)break; - - /* remove the packet from packet queue and track its granulepos */ - ogg_stream_packetout(&vf->os,NULL); - vorbis_synthesis_trackonly(&vf->vb,&op); /* set up a vb with - only tracking, no - pcm_decode */ - vorbis_synthesis_blockin(&vf->vd,&vf->vb); - - /* end of logical stream case is hard, especially with exact - length positioning. */ - - if(op.granulepos>-1){ - int i; - /* always believe the stream markers */ - vf->pcm_offset=op.granulepos-vf->pcmlengths[vf->current_link*2]; - if(vf->pcm_offset<0)vf->pcm_offset=0; - for(i=0;icurrent_link;i++) - vf->pcm_offset+=vf->pcmlengths[i*2+1]; - } - - lastblock=thisblock; - - }else{ - if(ret<0 && ret!=OV_HOLE)break; - - /* suck in a new page */ - if(_get_next_page(vf,&og,-1)<0)break; - if(ogg_page_bos(&og))_decode_clear(vf); - - if(vf->ready_statelinks;link++) - if(vf->serialnos[link]==(ogg_uint32_t) serialno)break; - if(link==vf->links) continue; - vf->current_link=link; - - vf->ready_state=STREAMSET; - vf->current_serialno=ogg_page_serialno(&og); - ogg_stream_reset_serialno(&vf->os,serialno); - ret=_make_decode_ready(vf); - if(ret)return ret; - lastblock=0; - } - - ogg_stream_pagein(&vf->os,&og,true); - } - } - - vf->bittrack=0; - vf->samptrack=0; - /* discard samples until we reach the desired position. Crossing a - logical bitstream boundary with abandon is OK. */ - while(vf->pcm_offsetpcm_offset; - long samples=vorbis_synthesis_pcmout(&vf->vd,NULL); - - if(samples>target)samples=target; - vorbis_synthesis_read(&vf->vd,samples); - vf->pcm_offset+=samples; - - if(samplespcm_offset=ov_pcm_total(vf,-1); /* eof */ - } - return 0; -} - -/* seek to a playback time relative to the decompressed pcm stream - returns zero on success, nonzero on failure */ -int ov_time_seek(OggVorbis_File *vf,ogg_int64_t milliseconds){ - /* translate time to PCM position and call ov_pcm_seek */ - - int link=-1; - ogg_int64_t pcm_total=0; - ogg_int64_t time_total=0; - - if(vf->ready_stateseekable)return(OV_ENOSEEK); - if(milliseconds<0)return(OV_EINVAL); - - /* which bitstream section does this time offset occur in? */ - for(link=0;linklinks;link++){ - ogg_int64_t addsec = ov_time_total(vf,link); - if(millisecondspcmlengths[link*2+1]; - } - - if(link==vf->links)return(OV_EINVAL); - - /* enough information to convert time offset to pcm offset */ - { - ogg_int64_t target=pcm_total+(milliseconds-time_total)*vf->vi[link].rate/1000; - return(ov_pcm_seek(vf,target)); - } -} - -/* tell the current stream offset cursor. Note that seek followed by - tell will likely not give the set offset due to caching */ -ogg_int64_t ov_raw_tell(OggVorbis_File *vf){ - if(vf->ready_stateoffset); -} - -/* return time offset (milliseconds) of next PCM sample to be read */ -ogg_int64_t ov_time_tell(OggVorbis_File *vf){ - int link=0; - ogg_int64_t pcm_total=0; - ogg_int64_t time_total=0; - - if(vf->ready_stateseekable){ - pcm_total=ov_pcm_total(vf,-1); - time_total=ov_time_total(vf,-1); - - /* which bitstream section does this time offset occur in? */ - for(link=vf->links-1;link>=0;link--){ - pcm_total-=vf->pcmlengths[link*2+1]; - time_total-=ov_time_total(vf,link); - if(vf->pcm_offset>=pcm_total)break; - } - } - - return(time_total+(1000*vf->pcm_offset-pcm_total)/vf->vi[link].rate); -} - -/* link: -1) return the vorbis_info struct for the bitstream section - currently being decoded - 0-n) to request information for a specific bitstream section - - In the case of a non-seekable bitstream, any call returns the - current bitstream. NULL in the case that the machine is not - initialized */ - -vorbis_info *ov_info(OggVorbis_File *vf,int link){ - if(vf->seekable){ - if(link<0) - if(vf->ready_state>=STREAMSET) - return vf->vi+vf->current_link; - else - return vf->vi; - else - if(link>=vf->links) - return NULL; - else - return vf->vi+link; - }else{ - return vf->vi; - } -} - -/* input values: pcm_channels) a float vector per channel of output - length) the sample length being read by the app - - return values: <0) error/hole in data (OV_HOLE), partial open (OV_EINVAL) - 0) EOF - n) number of samples of PCM actually returned. The - below works on a packet-by-packet basis, so the - return length is not related to the 'length' passed - in, just guaranteed to fit. - - *section) set to the logical bitstream number */ - -long ov_read_fixed(OggVorbis_File *vf,ogg_int32_t ***pcm_channels,int length, - int *bitstream){ - if(vf->ready_stateready_state==INITSET){ - ogg_int32_t **pcm; - long samples=vorbis_synthesis_pcmout(&vf->vd,&pcm); - if(samples){ - if(pcm_channels)*pcm_channels=pcm; - if(samples>length)samples=length; - vorbis_synthesis_read(&vf->vd,samples); - vf->pcm_offset+=samples; - if(bitstream)*bitstream=vf->current_link; - return samples; - - } - } - - /* suck in another packet */ - { - int ret=_fetch_and_process_packet(vf,NULL,1,1); - if(ret==OV_EOF) - return(0); - if(ret<=0) - return(ret); - } - } -} - diff --git a/apps/codecs/libtremor/window.c b/apps/codecs/libtremor/window.c deleted file mode 100644 index 3bc947f0e5..0000000000 --- a/apps/codecs/libtremor/window.c +++ /dev/null @@ -1,82 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * - * * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * - * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * - * * - ******************************************************************** - - function: window functions - - ********************************************************************/ - -#include "config-tremor.h" -#include -#include -#include "os.h" -#include "misc.h" -#include "window.h" -#include "window_lookup.h" - -const void *_vorbis_window(int type, int left){ - - switch(type){ - case 0: - - switch(left){ - case 32: - return vwin64; - case 64: - return vwin128; - case 128: - return vwin256; - case 256: - return vwin512; - case 512: - return vwin1024; - case 1024: - return vwin2048; - case 2048: - return vwin4096; - case 4096: - return vwin8192; - default: - return(0); - } - break; - default: - return(0); - } -} -#if 0 -void _vorbis_apply_window(ogg_int32_t *d,const void *window_p[2], - long *blocksizes, - int lW,int W,int nW){ - LOOKUP_T *window[2]={window_p[0],window_p[1]}; - long n=blocksizes[W]; - long ln=blocksizes[lW]; - long rn=blocksizes[nW]; - - long leftbegin=n/4-ln/4; - long leftend=leftbegin+ln/2; - - long rightbegin=n/2+n/4-rn/4; - long rightend=rightbegin+rn/2; - - /* Following memset is not required - we are careful to only overlap/add the - regions that geniunely overlap in the window region, and the portions - outside that region are not added (so don't need to be zerod). see block.c - memset((void *)&d[0], 0, sizeof(ogg_int32_t)*leftbegin); */ - - ogg_vect_mult_fw(&d[leftbegin], &window[lW][0], leftend-leftbegin); - ogg_vect_mult_bw(&d[rightbegin], &window[nW][rn/2-1], rightend-rightbegin); - - /* Again - memset not needed - memset((void *)&d[rightend], 0, sizeof(ogg_int32_t)*(n-rightend)); */ -} -#endif diff --git a/apps/codecs/libtremor/window.h b/apps/codecs/libtremor/window.h deleted file mode 100644 index 166d0b8e9c..0000000000 --- a/apps/codecs/libtremor/window.h +++ /dev/null @@ -1,27 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * - * * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * - * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * - * * - ******************************************************************** - - function: window functions - - ********************************************************************/ - -#ifndef _V_WINDOW_ -#define _V_WINDOW_ - -extern const void *_vorbis_window(int type,int left); -/*extern void _vorbis_apply_window(ogg_int32_t *d,const void *window[2], - long *blocksizes, - int lW,int W,int nW);*/ - - -#endif diff --git a/apps/codecs/libtremor/window_lookup.h b/apps/codecs/libtremor/window_lookup.h deleted file mode 100644 index 5363b81042..0000000000 --- a/apps/codecs/libtremor/window_lookup.h +++ /dev/null @@ -1,2087 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * - * * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * - * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * - * * - ******************************************************************** - - function: window lookup tables - - ********************************************************************/ - - -#include "os_types.h" - -/* libvorbis currently only use the window sizes 256 and 2048, so only put - * them in fast IRAM. - */ -static LOOKUP_T vwin64[32] = { - X(0x001f0003), X(0x01168c98), X(0x030333c8), X(0x05dfe3a4), - X(0x09a49562), X(0x0e45df18), X(0x13b47ef2), X(0x19dcf676), - X(0x20a74d83), X(0x27f7137c), X(0x2fabb05a), X(0x37a1105a), - X(0x3fb0ab28), X(0x47b2dcd1), X(0x4f807bc6), X(0x56f48e70), - X(0x5dedfc79), X(0x64511653), X(0x6a08cfff), X(0x6f079328), - X(0x734796f4), X(0x76cab7f2), X(0x7999d6e8), X(0x7bc3cf9f), - X(0x7d5c20c1), X(0x7e7961df), X(0x7f33a567), X(0x7fa2e1d0), - X(0x7fdd78a5), X(0x7ff6ec6d), X(0x7ffed0e9), X(0x7ffffc3f), -}; - -static LOOKUP_T vwin128[64] = { - X(0x0007c04d), X(0x0045bb89), X(0x00c18b87), X(0x017ae294), - X(0x02714a4e), X(0x03a4217a), X(0x05129952), X(0x06bbb24f), - X(0x089e38a1), X(0x0ab8c073), X(0x0d09a228), X(0x0f8ef6bd), - X(0x12469488), X(0x152e0c7a), X(0x1842a81c), X(0x1b81686d), - X(0x1ee705d9), X(0x226ff15d), X(0x26185705), X(0x29dc21cc), - X(0x2db700fe), X(0x31a46f08), X(0x359fb9c1), X(0x39a40c0c), - X(0x3dac78b6), X(0x41b40674), X(0x45b5bcb0), X(0x49acb109), - X(0x4d94152b), X(0x516744bd), X(0x5521d320), X(0x58bf98a5), - X(0x5c3cbef4), X(0x5f95cc5d), X(0x62c7add7), X(0x65cfbf64), - X(0x68abd2ba), X(0x6b5a3405), X(0x6dd9acab), X(0x7029840d), - X(0x72497e38), X(0x7439d8ac), X(0x75fb4532), X(0x778ee30a), - X(0x78f6367e), X(0x7a331f1a), X(0x7b47cccd), X(0x7c36b416), - X(0x7d028192), X(0x7dae0d18), X(0x7e3c4caa), X(0x7eb04763), - X(0x7f0d08a7), X(0x7f5593b7), X(0x7f8cd7d5), X(0x7fb5a513), - X(0x7fd2a1fc), X(0x7fe64212), X(0x7ff2bd4c), X(0x7ffa0890), - X(0x7ffdcf39), X(0x7fff6dac), X(0x7fffed01), X(0x7fffffc4), -}; - -static LOOKUP_T vwin256[128] = { - X(0x0001f018), X(0x00117066), X(0x00306e9e), X(0x005ee5f1), - X(0x009ccf26), X(0x00ea208b), X(0x0146cdea), X(0x01b2c87f), - X(0x022dfedf), X(0x02b85ced), X(0x0351cbbd), X(0x03fa317f), - X(0x04b17167), X(0x05776b90), X(0x064bfcdc), X(0x072efedd), - X(0x082047b4), X(0x091fa9f1), X(0x0a2cf477), X(0x0b47f25d), - X(0x0c706ad2), X(0x0da620ff), X(0x0ee8d3ef), X(0x10383e75), - X(0x11941716), X(0x12fc0ff6), X(0x146fd6c8), X(0x15ef14c2), - X(0x17796e8e), X(0x190e844f), X(0x1aadf196), X(0x1c574d6e), - X(0x1e0a2a62), X(0x1fc61688), X(0x218a9b9c), X(0x23573f12), - X(0x252b823d), X(0x2706e269), X(0x28e8d913), X(0x2ad0dc0e), - X(0x2cbe5dc1), X(0x2eb0cd60), X(0x30a79733), X(0x32a224d5), - X(0x349fdd8b), X(0x36a02690), X(0x38a2636f), X(0x3aa5f65e), - X(0x3caa409e), X(0x3eaea2df), X(0x40b27da6), X(0x42b531b8), - X(0x44b62086), X(0x46b4ac99), X(0x48b03a05), X(0x4aa82ed5), - X(0x4c9bf37d), X(0x4e8af349), X(0x50749ccb), X(0x52586246), - X(0x5435ba1c), X(0x560c1f31), X(0x57db1152), X(0x59a21591), - X(0x5b60b6a3), X(0x5d168535), X(0x5ec31839), X(0x60660d36), - X(0x61ff0886), X(0x638db595), X(0x6511c717), X(0x668af734), - X(0x67f907b0), X(0x695bc207), X(0x6ab2f787), X(0x6bfe815a), - X(0x6d3e4090), X(0x6e721e16), X(0x6f9a0ab5), X(0x70b5fef8), - X(0x71c5fb16), X(0x72ca06cd), X(0x73c2313d), X(0x74ae90b2), - X(0x758f4275), X(0x76646a85), X(0x772e335c), X(0x77eccda0), - X(0x78a06fd7), X(0x79495613), X(0x79e7c19c), X(0x7a7bf894), - X(0x7b064596), X(0x7b86f757), X(0x7bfe6044), X(0x7c6cd615), - X(0x7cd2b16e), X(0x7d304d71), X(0x7d860756), X(0x7dd43e06), - X(0x7e1b51ad), X(0x7e5ba355), X(0x7e95947e), X(0x7ec986bb), - X(0x7ef7db4a), X(0x7f20f2b9), X(0x7f452c7f), X(0x7f64e6a7), - X(0x7f807d71), X(0x7f984aff), X(0x7faca700), X(0x7fbde662), - X(0x7fcc5b04), X(0x7fd85372), X(0x7fe21a99), X(0x7fe9f791), - X(0x7ff02d58), X(0x7ff4fa9e), X(0x7ff89990), X(0x7ffb3faa), - X(0x7ffd1d8b), X(0x7ffe5ecc), X(0x7fff29e0), X(0x7fff9ff3), - X(0x7fffdcd2), X(0x7ffff6d6), X(0x7ffffed0), X(0x7ffffffc), -}; - -static LOOKUP_T vwin512[256] = { - X(0x00007c06), X(0x00045c32), X(0x000c1c62), X(0x0017bc4c), - X(0x00273b7a), X(0x003a9955), X(0x0051d51c), X(0x006cede7), - X(0x008be2a9), X(0x00aeb22a), X(0x00d55b0d), X(0x00ffdbcc), - X(0x012e32b6), X(0x01605df5), X(0x01965b85), X(0x01d02939), - X(0x020dc4ba), X(0x024f2b83), X(0x02945ae6), X(0x02dd5004), - X(0x032a07d3), X(0x037a7f19), X(0x03ceb26e), X(0x04269e37), - X(0x04823eab), X(0x04e18fcc), X(0x05448d6d), X(0x05ab3329), - X(0x06157c68), X(0x0683645e), X(0x06f4e607), X(0x0769fc25), - X(0x07e2a146), X(0x085ecfbc), X(0x08de819f), X(0x0961b0cc), - X(0x09e856e3), X(0x0a726d46), X(0x0affed1d), X(0x0b90cf4c), - X(0x0c250c79), X(0x0cbc9d0b), X(0x0d577926), X(0x0df598aa), - X(0x0e96f337), X(0x0f3b8026), X(0x0fe3368f), X(0x108e0d42), - X(0x113bfaca), X(0x11ecf56b), X(0x12a0f324), X(0x1357e9ac), - X(0x1411ce70), X(0x14ce9698), X(0x158e3702), X(0x1650a444), - X(0x1715d2aa), X(0x17ddb638), X(0x18a842aa), X(0x19756b72), - X(0x1a4523b9), X(0x1b175e62), X(0x1bec0e04), X(0x1cc324f0), - X(0x1d9c9532), X(0x1e78508a), X(0x1f564876), X(0x20366e2e), - X(0x2118b2a2), X(0x21fd0681), X(0x22e35a37), X(0x23cb9dee), - X(0x24b5c18e), X(0x25a1b4c0), X(0x268f66f1), X(0x277ec74e), - X(0x286fc4cc), X(0x29624e23), X(0x2a5651d7), X(0x2b4bbe34), - X(0x2c428150), X(0x2d3a8913), X(0x2e33c332), X(0x2f2e1d35), - X(0x30298478), X(0x3125e62d), X(0x32232f61), X(0x33214cfc), - X(0x34202bc2), X(0x351fb85a), X(0x361fdf4f), X(0x37208d10), - X(0x3821adf7), X(0x39232e49), X(0x3a24fa3c), X(0x3b26fdf6), - X(0x3c292593), X(0x3d2b5d29), X(0x3e2d90c8), X(0x3f2fac7f), - X(0x40319c5f), X(0x41334c81), X(0x4234a905), X(0x43359e16), - X(0x443617f3), X(0x453602eb), X(0x46354b65), X(0x4733dde1), - X(0x4831a6ff), X(0x492e937f), X(0x4a2a9045), X(0x4b258a5f), - X(0x4c1f6f06), X(0x4d182ba2), X(0x4e0fadce), X(0x4f05e35b), - X(0x4ffaba53), X(0x50ee20fd), X(0x51e005e1), X(0x52d057ca), - X(0x53bf05ca), X(0x54abff3b), X(0x559733c7), X(0x56809365), - X(0x57680e62), X(0x584d955d), X(0x59311952), X(0x5a128b96), - X(0x5af1dddd), X(0x5bcf023a), X(0x5ca9eb27), X(0x5d828b81), - X(0x5e58d68d), X(0x5f2cbffc), X(0x5ffe3be9), X(0x60cd3edf), - X(0x6199bdda), X(0x6263ae45), X(0x632b0602), X(0x63efbb66), - X(0x64b1c53f), X(0x65711ad0), X(0x662db3d7), X(0x66e7888d), - X(0x679e91a5), X(0x6852c84e), X(0x69042635), X(0x69b2a582), - X(0x6a5e40dd), X(0x6b06f36c), X(0x6bacb8d2), X(0x6c4f8d30), - X(0x6cef6d26), X(0x6d8c55d4), X(0x6e2644d4), X(0x6ebd3840), - X(0x6f512ead), X(0x6fe2272e), X(0x7070214f), X(0x70fb1d17), - X(0x71831b06), X(0x72081c16), X(0x728a21b5), X(0x73092dc8), - X(0x738542a6), X(0x73fe631b), X(0x74749261), X(0x74e7d421), - X(0x75582c72), X(0x75c59fd5), X(0x76303333), X(0x7697ebdd), - X(0x76fccf85), X(0x775ee443), X(0x77be308a), X(0x781abb2e), - X(0x78748b59), X(0x78cba88e), X(0x79201aa7), X(0x7971e9cd), - X(0x79c11e79), X(0x7a0dc170), X(0x7a57dbc2), X(0x7a9f76c1), - X(0x7ae49c07), X(0x7b27556b), X(0x7b67ad02), X(0x7ba5ad1b), - X(0x7be1603a), X(0x7c1ad118), X(0x7c520a9e), X(0x7c8717e1), - X(0x7cba0421), X(0x7ceadac3), X(0x7d19a74f), X(0x7d46756e), - X(0x7d7150e5), X(0x7d9a4592), X(0x7dc15f69), X(0x7de6aa71), - X(0x7e0a32c0), X(0x7e2c0479), X(0x7e4c2bc7), X(0x7e6ab4db), - X(0x7e87abe9), X(0x7ea31d24), X(0x7ebd14be), X(0x7ed59edd), - X(0x7eecc7a3), X(0x7f029b21), X(0x7f17255a), X(0x7f2a723f), - X(0x7f3c8daa), X(0x7f4d835d), X(0x7f5d5f00), X(0x7f6c2c1b), - X(0x7f79f617), X(0x7f86c83a), X(0x7f92ada2), X(0x7f9db146), - X(0x7fa7ddf3), X(0x7fb13e46), X(0x7fb9dcb0), X(0x7fc1c36c), - X(0x7fc8fc83), X(0x7fcf91c7), X(0x7fd58cd2), X(0x7fdaf702), - X(0x7fdfd979), X(0x7fe43d1c), X(0x7fe82a8b), X(0x7febaa29), - X(0x7feec412), X(0x7ff1801c), X(0x7ff3e5d6), X(0x7ff5fc86), - X(0x7ff7cb29), X(0x7ff9586f), X(0x7ffaaaba), X(0x7ffbc81e), - X(0x7ffcb660), X(0x7ffd7af3), X(0x7ffe1afa), X(0x7ffe9b42), - X(0x7fff0047), X(0x7fff4e2f), X(0x7fff88c9), X(0x7fffb390), - X(0x7fffd1a6), X(0x7fffe5d7), X(0x7ffff296), X(0x7ffff9fd), - X(0x7ffffdcd), X(0x7fffff6d), X(0x7fffffed), X(0x7fffffff), -}; - -static LOOKUP_T vwin1024[512] = { - X(0x00001f02), X(0x0001170e), X(0x00030724), X(0x0005ef40), - X(0x0009cf59), X(0x000ea767), X(0x0014775e), X(0x001b3f2e), - X(0x0022fec8), X(0x002bb618), X(0x00356508), X(0x00400b81), - X(0x004ba968), X(0x00583ea0), X(0x0065cb0a), X(0x00744e84), - X(0x0083c8ea), X(0x00943a14), X(0x00a5a1da), X(0x00b80010), - X(0x00cb5488), X(0x00df9f10), X(0x00f4df76), X(0x010b1584), - X(0x01224101), X(0x013a61b2), X(0x01537759), X(0x016d81b6), - X(0x01888087), X(0x01a47385), X(0x01c15a69), X(0x01df34e6), - X(0x01fe02b1), X(0x021dc377), X(0x023e76e7), X(0x02601ca9), - X(0x0282b466), X(0x02a63dc1), X(0x02cab85d), X(0x02f023d6), - X(0x03167fcb), X(0x033dcbd3), X(0x03660783), X(0x038f3270), - X(0x03b94c29), X(0x03e4543a), X(0x04104a2e), X(0x043d2d8b), - X(0x046afdd5), X(0x0499ba8c), X(0x04c9632d), X(0x04f9f734), - X(0x052b7615), X(0x055ddf46), X(0x05913237), X(0x05c56e53), - X(0x05fa9306), X(0x06309fb6), X(0x066793c5), X(0x069f6e93), - X(0x06d82f7c), X(0x0711d5d9), X(0x074c60fe), X(0x0787d03d), - X(0x07c422e4), X(0x0801583e), X(0x083f6f91), X(0x087e681f), - X(0x08be4129), X(0x08fef9ea), X(0x0940919a), X(0x0983076d), - X(0x09c65a92), X(0x0a0a8a38), X(0x0a4f9585), X(0x0a957b9f), - X(0x0adc3ba7), X(0x0b23d4b9), X(0x0b6c45ee), X(0x0bb58e5a), - X(0x0bffad0f), X(0x0c4aa11a), X(0x0c966982), X(0x0ce3054d), - X(0x0d30737b), X(0x0d7eb308), X(0x0dcdc2eb), X(0x0e1da21a), - X(0x0e6e4f83), X(0x0ebfca11), X(0x0f1210ad), X(0x0f652238), - X(0x0fb8fd91), X(0x100da192), X(0x10630d11), X(0x10b93ee0), - X(0x111035cb), X(0x1167f09a), X(0x11c06e13), X(0x1219acf5), - X(0x1273abfb), X(0x12ce69db), X(0x1329e54a), X(0x13861cf3), - X(0x13e30f80), X(0x1440bb97), X(0x149f1fd8), X(0x14fe3ade), - X(0x155e0b40), X(0x15be8f92), X(0x161fc662), X(0x1681ae38), - X(0x16e4459b), X(0x17478b0b), X(0x17ab7d03), X(0x181019fb), - X(0x18756067), X(0x18db4eb3), X(0x1941e34a), X(0x19a91c92), - X(0x1a10f8ea), X(0x1a7976af), X(0x1ae29439), X(0x1b4c4fda), - X(0x1bb6a7e2), X(0x1c219a9a), X(0x1c8d2649), X(0x1cf9492e), - X(0x1d660188), X(0x1dd34d8e), X(0x1e412b74), X(0x1eaf996a), - X(0x1f1e959b), X(0x1f8e1e2f), X(0x1ffe3146), X(0x206ecd01), - X(0x20dfef78), X(0x215196c2), X(0x21c3c0f0), X(0x22366c10), - X(0x22a9962a), X(0x231d3d45), X(0x23915f60), X(0x2405fa7a), - X(0x247b0c8c), X(0x24f09389), X(0x25668d65), X(0x25dcf80c), - X(0x2653d167), X(0x26cb175e), X(0x2742c7d0), X(0x27bae09e), - X(0x28335fa2), X(0x28ac42b3), X(0x292587a5), X(0x299f2c48), - X(0x2a192e69), X(0x2a938bd1), X(0x2b0e4247), X(0x2b894f8d), - X(0x2c04b164), X(0x2c806588), X(0x2cfc69b2), X(0x2d78bb9a), - X(0x2df558f4), X(0x2e723f6f), X(0x2eef6cbb), X(0x2f6cde83), - X(0x2fea9270), X(0x30688627), X(0x30e6b74e), X(0x31652385), - X(0x31e3c86b), X(0x3262a39e), X(0x32e1b2b8), X(0x3360f352), - X(0x33e06303), X(0x345fff5e), X(0x34dfc5f8), X(0x355fb462), - X(0x35dfc82a), X(0x365ffee0), X(0x36e0560f), X(0x3760cb43), - X(0x37e15c05), X(0x386205df), X(0x38e2c657), X(0x39639af5), - X(0x39e4813e), X(0x3a6576b6), X(0x3ae678e3), X(0x3b678547), - X(0x3be89965), X(0x3c69b2c1), X(0x3ceacedc), X(0x3d6beb37), - X(0x3ded0557), X(0x3e6e1abb), X(0x3eef28e6), X(0x3f702d5a), - X(0x3ff1259a), X(0x40720f29), X(0x40f2e789), X(0x4173ac3f), - X(0x41f45ad0), X(0x4274f0c2), X(0x42f56b9a), X(0x4375c8e0), - X(0x43f6061d), X(0x447620db), X(0x44f616a5), X(0x4575e509), - X(0x45f58994), X(0x467501d6), X(0x46f44b62), X(0x477363cb), - X(0x47f248a6), X(0x4870f78e), X(0x48ef6e1a), X(0x496da9e8), - X(0x49eba897), X(0x4a6967c8), X(0x4ae6e521), X(0x4b641e47), - X(0x4be110e5), X(0x4c5dbaa7), X(0x4cda193f), X(0x4d562a5f), - X(0x4dd1ebbd), X(0x4e4d5b15), X(0x4ec87623), X(0x4f433aa9), - X(0x4fbda66c), X(0x5037b734), X(0x50b16acf), X(0x512abf0e), - X(0x51a3b1c5), X(0x521c40ce), X(0x52946a06), X(0x530c2b50), - X(0x53838292), X(0x53fa6db8), X(0x5470eab3), X(0x54e6f776), - X(0x555c91fc), X(0x55d1b844), X(0x56466851), X(0x56baa02f), - X(0x572e5deb), X(0x57a19f98), X(0x58146352), X(0x5886a737), - X(0x58f8696d), X(0x5969a81c), X(0x59da6177), X(0x5a4a93b4), - X(0x5aba3d0f), X(0x5b295bcb), X(0x5b97ee30), X(0x5c05f28d), - X(0x5c736738), X(0x5ce04a8d), X(0x5d4c9aed), X(0x5db856c1), - X(0x5e237c78), X(0x5e8e0a89), X(0x5ef7ff6f), X(0x5f6159b0), - X(0x5fca17d4), X(0x6032386e), X(0x6099ba15), X(0x61009b69), - X(0x6166db11), X(0x61cc77b9), X(0x62317017), X(0x6295c2e7), - X(0x62f96eec), X(0x635c72f1), X(0x63becdc8), X(0x64207e4b), - X(0x6481835a), X(0x64e1dbde), X(0x654186c8), X(0x65a0830e), - X(0x65fecfb1), X(0x665c6bb7), X(0x66b95630), X(0x67158e30), - X(0x677112d7), X(0x67cbe34b), X(0x6825feb9), X(0x687f6456), - X(0x68d81361), X(0x69300b1e), X(0x69874ada), X(0x69ddd1ea), - X(0x6a339fab), X(0x6a88b382), X(0x6add0cdb), X(0x6b30ab2a), - X(0x6b838dec), X(0x6bd5b4a6), X(0x6c271ee2), X(0x6c77cc36), - X(0x6cc7bc3d), X(0x6d16ee9b), X(0x6d6562fb), X(0x6db31911), - X(0x6e001099), X(0x6e4c4955), X(0x6e97c311), X(0x6ee27d9f), - X(0x6f2c78d9), X(0x6f75b4a2), X(0x6fbe30e4), X(0x7005ed91), - X(0x704ceaa1), X(0x70932816), X(0x70d8a5f8), X(0x711d6457), - X(0x7161634b), X(0x71a4a2f3), X(0x71e72375), X(0x7228e500), - X(0x7269e7c8), X(0x72aa2c0a), X(0x72e9b209), X(0x73287a12), - X(0x73668476), X(0x73a3d18f), X(0x73e061bc), X(0x741c3566), - X(0x74574cfa), X(0x7491a8ee), X(0x74cb49be), X(0x75042fec), - X(0x753c5c03), X(0x7573ce92), X(0x75aa882f), X(0x75e08979), - X(0x7615d313), X(0x764a65a7), X(0x767e41e5), X(0x76b16884), - X(0x76e3da40), X(0x771597dc), X(0x7746a221), X(0x7776f9dd), - X(0x77a69fe6), X(0x77d59514), X(0x7803da49), X(0x7831706a), - X(0x785e5861), X(0x788a9320), X(0x78b6219c), X(0x78e104cf), - X(0x790b3dbb), X(0x7934cd64), X(0x795db4d5), X(0x7985f51d), - X(0x79ad8f50), X(0x79d48486), X(0x79fad5de), X(0x7a208478), - X(0x7a45917b), X(0x7a69fe12), X(0x7a8dcb6c), X(0x7ab0fabb), - X(0x7ad38d36), X(0x7af5841a), X(0x7b16e0a3), X(0x7b37a416), - X(0x7b57cfb8), X(0x7b7764d4), X(0x7b9664b6), X(0x7bb4d0b0), - X(0x7bd2aa14), X(0x7beff23b), X(0x7c0caa7f), X(0x7c28d43c), - X(0x7c4470d2), X(0x7c5f81a5), X(0x7c7a081a), X(0x7c940598), - X(0x7cad7b8b), X(0x7cc66b5e), X(0x7cded680), X(0x7cf6be64), - X(0x7d0e247b), X(0x7d250a3c), X(0x7d3b711c), X(0x7d515a95), - X(0x7d66c822), X(0x7d7bbb3c), X(0x7d903563), X(0x7da43814), - X(0x7db7c4d0), X(0x7dcadd16), X(0x7ddd826a), X(0x7defb64d), - X(0x7e017a44), X(0x7e12cfd3), X(0x7e23b87f), X(0x7e3435cc), - X(0x7e444943), X(0x7e53f467), X(0x7e6338c0), X(0x7e7217d5), - X(0x7e80932b), X(0x7e8eac49), X(0x7e9c64b7), X(0x7ea9bdf8), - X(0x7eb6b994), X(0x7ec35910), X(0x7ecf9def), X(0x7edb89b6), - X(0x7ee71de9), X(0x7ef25c09), X(0x7efd4598), X(0x7f07dc16), - X(0x7f122103), X(0x7f1c15dc), X(0x7f25bc1f), X(0x7f2f1547), - X(0x7f3822cd), X(0x7f40e62b), X(0x7f4960d6), X(0x7f519443), - X(0x7f5981e7), X(0x7f612b31), X(0x7f689191), X(0x7f6fb674), - X(0x7f769b45), X(0x7f7d416c), X(0x7f83aa51), X(0x7f89d757), - X(0x7f8fc9df), X(0x7f958348), X(0x7f9b04ef), X(0x7fa0502e), - X(0x7fa56659), X(0x7faa48c7), X(0x7faef8c7), X(0x7fb377a7), - X(0x7fb7c6b3), X(0x7fbbe732), X(0x7fbfda67), X(0x7fc3a196), - X(0x7fc73dfa), X(0x7fcab0ce), X(0x7fcdfb4a), X(0x7fd11ea0), - X(0x7fd41c00), X(0x7fd6f496), X(0x7fd9a989), X(0x7fdc3bff), - X(0x7fdead17), X(0x7fe0fdee), X(0x7fe32f9d), X(0x7fe54337), - X(0x7fe739ce), X(0x7fe9146c), X(0x7fead41b), X(0x7fec79dd), - X(0x7fee06b2), X(0x7fef7b94), X(0x7ff0d97b), X(0x7ff22158), - X(0x7ff35417), X(0x7ff472a3), X(0x7ff57de0), X(0x7ff676ac), - X(0x7ff75de3), X(0x7ff8345a), X(0x7ff8fae4), X(0x7ff9b24b), - X(0x7ffa5b58), X(0x7ffaf6cd), X(0x7ffb8568), X(0x7ffc07e2), - X(0x7ffc7eed), X(0x7ffceb38), X(0x7ffd4d6d), X(0x7ffda631), - X(0x7ffdf621), X(0x7ffe3dd8), X(0x7ffe7dea), X(0x7ffeb6e7), - X(0x7ffee959), X(0x7fff15c4), X(0x7fff3ca9), X(0x7fff5e80), - X(0x7fff7bc0), X(0x7fff94d6), X(0x7fffaa2d), X(0x7fffbc29), - X(0x7fffcb29), X(0x7fffd786), X(0x7fffe195), X(0x7fffe9a3), - X(0x7fffeffa), X(0x7ffff4dd), X(0x7ffff889), X(0x7ffffb37), - X(0x7ffffd1a), X(0x7ffffe5d), X(0x7fffff29), X(0x7fffffa0), - X(0x7fffffdd), X(0x7ffffff7), X(0x7fffffff), X(0x7fffffff), -}; - -static LOOKUP_T vwin2048[1024] = { - X(0x000007c0), X(0x000045c4), X(0x0000c1ca), X(0x00017bd3), - X(0x000273de), X(0x0003a9eb), X(0x00051df9), X(0x0006d007), - X(0x0008c014), X(0x000aee1e), X(0x000d5a25), X(0x00100428), - X(0x0012ec23), X(0x00161216), X(0x001975fe), X(0x001d17da), - X(0x0020f7a8), X(0x00251564), X(0x0029710c), X(0x002e0a9e), - X(0x0032e217), X(0x0037f773), X(0x003d4ab0), X(0x0042dbca), - X(0x0048aabe), X(0x004eb788), X(0x00550224), X(0x005b8a8f), - X(0x006250c5), X(0x006954c1), X(0x0070967e), X(0x007815f9), - X(0x007fd32c), X(0x0087ce13), X(0x009006a9), X(0x00987ce9), - X(0x00a130cc), X(0x00aa224f), X(0x00b3516b), X(0x00bcbe1a), - X(0x00c66856), X(0x00d0501a), X(0x00da755f), X(0x00e4d81f), - X(0x00ef7853), X(0x00fa55f4), X(0x010570fc), X(0x0110c963), - X(0x011c5f22), X(0x01283232), X(0x0134428c), X(0x01409027), - X(0x014d1afb), X(0x0159e302), X(0x0166e831), X(0x01742a82), - X(0x0181a9ec), X(0x018f6665), X(0x019d5fe5), X(0x01ab9663), - X(0x01ba09d6), X(0x01c8ba34), X(0x01d7a775), X(0x01e6d18d), - X(0x01f63873), X(0x0205dc1e), X(0x0215bc82), X(0x0225d997), - X(0x02363350), X(0x0246c9a3), X(0x02579c86), X(0x0268abed), - X(0x0279f7cc), X(0x028b801a), X(0x029d44c9), X(0x02af45ce), - X(0x02c1831d), X(0x02d3fcaa), X(0x02e6b269), X(0x02f9a44c), - X(0x030cd248), X(0x03203c4f), X(0x0333e255), X(0x0347c44b), - X(0x035be225), X(0x03703bd5), X(0x0384d14d), X(0x0399a280), - X(0x03aeaf5e), X(0x03c3f7d9), X(0x03d97be4), X(0x03ef3b6e), - X(0x0405366a), X(0x041b6cc8), X(0x0431de78), X(0x04488b6c), - X(0x045f7393), X(0x047696dd), X(0x048df53b), X(0x04a58e9b), - X(0x04bd62ee), X(0x04d57223), X(0x04edbc28), X(0x050640ed), - X(0x051f0060), X(0x0537fa70), X(0x05512f0a), X(0x056a9e1e), - X(0x05844798), X(0x059e2b67), X(0x05b84978), X(0x05d2a1b8), - X(0x05ed3414), X(0x06080079), X(0x062306d3), X(0x063e470f), - X(0x0659c119), X(0x067574dd), X(0x06916247), X(0x06ad8941), - X(0x06c9e9b8), X(0x06e68397), X(0x070356c8), X(0x07206336), - X(0x073da8cb), X(0x075b2772), X(0x0778df15), X(0x0796cf9c), - X(0x07b4f8f3), X(0x07d35b01), X(0x07f1f5b1), X(0x0810c8eb), - X(0x082fd497), X(0x084f189e), X(0x086e94e9), X(0x088e495e), - X(0x08ae35e6), X(0x08ce5a68), X(0x08eeb6cc), X(0x090f4af8), - X(0x093016d3), X(0x09511a44), X(0x09725530), X(0x0993c77f), - X(0x09b57115), X(0x09d751d8), X(0x09f969ae), X(0x0a1bb87c), - X(0x0a3e3e26), X(0x0a60fa91), X(0x0a83eda2), X(0x0aa7173c), - X(0x0aca7743), X(0x0aee0d9b), X(0x0b11da28), X(0x0b35dccc), - X(0x0b5a156a), X(0x0b7e83e5), X(0x0ba3281f), X(0x0bc801fa), - X(0x0bed1159), X(0x0c12561c), X(0x0c37d025), X(0x0c5d7f55), - X(0x0c83638d), X(0x0ca97cae), X(0x0ccfca97), X(0x0cf64d2a), - X(0x0d1d0444), X(0x0d43efc7), X(0x0d6b0f92), X(0x0d926383), - X(0x0db9eb79), X(0x0de1a752), X(0x0e0996ee), X(0x0e31ba29), - X(0x0e5a10e2), X(0x0e829af6), X(0x0eab5841), X(0x0ed448a2), - X(0x0efd6bf4), X(0x0f26c214), X(0x0f504ade), X(0x0f7a062e), - X(0x0fa3f3df), X(0x0fce13cd), X(0x0ff865d2), X(0x1022e9ca), - X(0x104d9f8e), X(0x107886f9), X(0x10a39fe5), X(0x10ceea2c), - X(0x10fa65a6), X(0x1126122d), X(0x1151ef9a), X(0x117dfdc5), - X(0x11aa3c87), X(0x11d6abb6), X(0x12034b2c), X(0x12301ac0), - X(0x125d1a48), X(0x128a499b), X(0x12b7a891), X(0x12e536ff), - X(0x1312f4bb), X(0x1340e19c), X(0x136efd75), X(0x139d481e), - X(0x13cbc16a), X(0x13fa692f), X(0x14293f40), X(0x14584371), - X(0x14877597), X(0x14b6d585), X(0x14e6630d), X(0x15161e04), - X(0x1546063b), X(0x15761b85), X(0x15a65db3), X(0x15d6cc99), - X(0x16076806), X(0x16382fcd), X(0x166923bf), X(0x169a43ab), - X(0x16cb8f62), X(0x16fd06b5), X(0x172ea973), X(0x1760776b), - X(0x1792706e), X(0x17c49449), X(0x17f6e2cb), X(0x18295bc3), - X(0x185bfeff), X(0x188ecc4c), X(0x18c1c379), X(0x18f4e452), - X(0x19282ea4), X(0x195ba23c), X(0x198f3ee6), X(0x19c3046e), - X(0x19f6f2a1), X(0x1a2b094a), X(0x1a5f4833), X(0x1a93af28), - X(0x1ac83df3), X(0x1afcf460), X(0x1b31d237), X(0x1b66d744), - X(0x1b9c034e), X(0x1bd15621), X(0x1c06cf84), X(0x1c3c6f40), - X(0x1c72351e), X(0x1ca820e6), X(0x1cde3260), X(0x1d146953), - X(0x1d4ac587), X(0x1d8146c3), X(0x1db7eccd), X(0x1deeb76c), - X(0x1e25a667), X(0x1e5cb982), X(0x1e93f085), X(0x1ecb4b33), - X(0x1f02c953), X(0x1f3a6aaa), X(0x1f722efb), X(0x1faa160b), - X(0x1fe21f9e), X(0x201a4b79), X(0x2052995d), X(0x208b0910), - X(0x20c39a53), X(0x20fc4cea), X(0x21352097), X(0x216e151c), - X(0x21a72a3a), X(0x21e05fb5), X(0x2219b54d), X(0x22532ac3), - X(0x228cbfd8), X(0x22c6744d), X(0x230047e2), X(0x233a3a58), - X(0x23744b6d), X(0x23ae7ae3), X(0x23e8c878), X(0x242333ec), - X(0x245dbcfd), X(0x24986369), X(0x24d326f1), X(0x250e0750), - X(0x25490446), X(0x25841d90), X(0x25bf52ec), X(0x25faa417), - X(0x263610cd), X(0x267198cc), X(0x26ad3bcf), X(0x26e8f994), - X(0x2724d1d6), X(0x2760c451), X(0x279cd0c0), X(0x27d8f6e0), - X(0x2815366a), X(0x28518f1b), X(0x288e00ac), X(0x28ca8ad8), - X(0x29072d5a), X(0x2943e7eb), X(0x2980ba45), X(0x29bda422), - X(0x29faa53c), X(0x2a37bd4a), X(0x2a74ec07), X(0x2ab2312b), - X(0x2aef8c6f), X(0x2b2cfd8b), X(0x2b6a8437), X(0x2ba8202c), - X(0x2be5d120), X(0x2c2396cc), X(0x2c6170e7), X(0x2c9f5f29), - X(0x2cdd6147), X(0x2d1b76fa), X(0x2d599ff7), X(0x2d97dbf5), - X(0x2dd62aab), X(0x2e148bcf), X(0x2e52ff16), X(0x2e918436), - X(0x2ed01ae5), X(0x2f0ec2d9), X(0x2f4d7bc6), X(0x2f8c4562), - X(0x2fcb1f62), X(0x300a097a), X(0x3049035f), X(0x30880cc6), - X(0x30c72563), X(0x31064cea), X(0x3145830f), X(0x3184c786), - X(0x31c41a03), X(0x32037a39), X(0x3242e7dc), X(0x3282629f), - X(0x32c1ea36), X(0x33017e53), X(0x33411ea9), X(0x3380caec), - X(0x33c082ce), X(0x34004602), X(0x34401439), X(0x347fed27), - X(0x34bfd07e), X(0x34ffbdf0), X(0x353fb52e), X(0x357fb5ec), - X(0x35bfbfda), X(0x35ffd2aa), X(0x363fee0f), X(0x368011b9), - X(0x36c03d5a), X(0x370070a4), X(0x3740ab48), X(0x3780ecf7), - X(0x37c13562), X(0x3801843a), X(0x3841d931), X(0x388233f7), - X(0x38c2943d), X(0x3902f9b4), X(0x3943640d), X(0x3983d2f8), - X(0x39c44626), X(0x3a04bd48), X(0x3a45380e), X(0x3a85b62a), - X(0x3ac6374a), X(0x3b06bb20), X(0x3b47415c), X(0x3b87c9ae), - X(0x3bc853c7), X(0x3c08df57), X(0x3c496c0f), X(0x3c89f99f), - X(0x3cca87b6), X(0x3d0b1605), X(0x3d4ba43d), X(0x3d8c320e), - X(0x3dccbf27), X(0x3e0d4b3a), X(0x3e4dd5f6), X(0x3e8e5f0c), - X(0x3ecee62b), X(0x3f0f6b05), X(0x3f4fed49), X(0x3f906ca8), - X(0x3fd0e8d2), X(0x40116177), X(0x4051d648), X(0x409246f6), - X(0x40d2b330), X(0x41131aa7), X(0x41537d0c), X(0x4193da10), - X(0x41d43162), X(0x421482b4), X(0x4254cdb7), X(0x4295121b), - X(0x42d54f91), X(0x431585ca), X(0x4355b477), X(0x4395db49), - X(0x43d5f9f1), X(0x44161021), X(0x44561d8a), X(0x449621dd), - X(0x44d61ccc), X(0x45160e08), X(0x4555f544), X(0x4595d230), - X(0x45d5a47f), X(0x46156be3), X(0x4655280e), X(0x4694d8b2), - X(0x46d47d82), X(0x4714162f), X(0x4753a26d), X(0x479321ef), - X(0x47d29466), X(0x4811f987), X(0x48515104), X(0x48909a91), - X(0x48cfd5e1), X(0x490f02a7), X(0x494e2098), X(0x498d2f66), - X(0x49cc2ec7), X(0x4a0b1e6f), X(0x4a49fe11), X(0x4a88cd62), - X(0x4ac78c18), X(0x4b0639e6), X(0x4b44d683), X(0x4b8361a2), - X(0x4bc1dafa), X(0x4c004241), X(0x4c3e972c), X(0x4c7cd970), - X(0x4cbb08c5), X(0x4cf924e1), X(0x4d372d7a), X(0x4d752247), - X(0x4db30300), X(0x4df0cf5a), X(0x4e2e870f), X(0x4e6c29d6), - X(0x4ea9b766), X(0x4ee72f78), X(0x4f2491c4), X(0x4f61de02), - X(0x4f9f13ec), X(0x4fdc333b), X(0x50193ba8), X(0x50562ced), - X(0x509306c3), X(0x50cfc8e5), X(0x510c730d), X(0x514904f6), - X(0x51857e5a), X(0x51c1def5), X(0x51fe2682), X(0x523a54bc), - X(0x52766961), X(0x52b2642c), X(0x52ee44d9), X(0x532a0b26), - X(0x5365b6d0), X(0x53a14793), X(0x53dcbd2f), X(0x54181760), - X(0x545355e5), X(0x548e787d), X(0x54c97ee6), X(0x550468e1), - X(0x553f362c), X(0x5579e687), X(0x55b479b3), X(0x55eeef70), - X(0x5629477f), X(0x566381a1), X(0x569d9d97), X(0x56d79b24), - X(0x57117a0a), X(0x574b3a0a), X(0x5784dae9), X(0x57be5c69), - X(0x57f7be4d), X(0x5831005a), X(0x586a2254), X(0x58a32400), - X(0x58dc0522), X(0x5914c57f), X(0x594d64de), X(0x5985e305), - X(0x59be3fba), X(0x59f67ac3), X(0x5a2e93e9), X(0x5a668af2), - X(0x5a9e5fa6), X(0x5ad611ce), X(0x5b0da133), X(0x5b450d9d), - X(0x5b7c56d7), X(0x5bb37ca9), X(0x5bea7ede), X(0x5c215d41), - X(0x5c58179d), X(0x5c8eadbe), X(0x5cc51f6f), X(0x5cfb6c7c), - X(0x5d3194b2), X(0x5d6797de), X(0x5d9d75cf), X(0x5dd32e51), - X(0x5e08c132), X(0x5e3e2e43), X(0x5e737551), X(0x5ea8962d), - X(0x5edd90a7), X(0x5f12648e), X(0x5f4711b4), X(0x5f7b97ea), - X(0x5faff702), X(0x5fe42ece), X(0x60183f20), X(0x604c27cc), - X(0x607fe8a6), X(0x60b38180), X(0x60e6f22f), X(0x611a3a89), - X(0x614d5a62), X(0x61805190), X(0x61b31fe9), X(0x61e5c545), - X(0x62184179), X(0x624a945d), X(0x627cbdca), X(0x62aebd98), - X(0x62e0939f), X(0x63123fba), X(0x6343c1c1), X(0x6375198f), - X(0x63a646ff), X(0x63d749ec), X(0x64082232), X(0x6438cfad), - X(0x64695238), X(0x6499a9b3), X(0x64c9d5f9), X(0x64f9d6ea), - X(0x6529ac63), X(0x65595643), X(0x6588d46a), X(0x65b826b8), - X(0x65e74d0e), X(0x6616474b), X(0x66451552), X(0x6673b704), - X(0x66a22c44), X(0x66d074f4), X(0x66fe90f8), X(0x672c8033), - X(0x675a428a), X(0x6787d7e1), X(0x67b5401f), X(0x67e27b27), - X(0x680f88e1), X(0x683c6934), X(0x68691c05), X(0x6895a13e), - X(0x68c1f8c7), X(0x68ee2287), X(0x691a1e68), X(0x6945ec54), - X(0x69718c35), X(0x699cfdf5), X(0x69c8417f), X(0x69f356c0), - X(0x6a1e3da3), X(0x6a48f615), X(0x6a738002), X(0x6a9ddb5a), - X(0x6ac80808), X(0x6af205fd), X(0x6b1bd526), X(0x6b457575), - X(0x6b6ee6d8), X(0x6b982940), X(0x6bc13c9f), X(0x6bea20e5), - X(0x6c12d605), X(0x6c3b5bf1), X(0x6c63b29c), X(0x6c8bd9fb), - X(0x6cb3d200), X(0x6cdb9aa0), X(0x6d0333d0), X(0x6d2a9d86), - X(0x6d51d7b7), X(0x6d78e25a), X(0x6d9fbd67), X(0x6dc668d3), - X(0x6dece498), X(0x6e1330ad), X(0x6e394d0c), X(0x6e5f39ae), - X(0x6e84f68d), X(0x6eaa83a2), X(0x6ecfe0ea), X(0x6ef50e5e), - X(0x6f1a0bfc), X(0x6f3ed9bf), X(0x6f6377a4), X(0x6f87e5a8), - X(0x6fac23c9), X(0x6fd03206), X(0x6ff4105c), X(0x7017becc), - X(0x703b3d54), X(0x705e8bf5), X(0x7081aaaf), X(0x70a49984), - X(0x70c75874), X(0x70e9e783), X(0x710c46b2), X(0x712e7605), - X(0x7150757f), X(0x71724523), X(0x7193e4f6), X(0x71b554fd), - X(0x71d6953e), X(0x71f7a5bd), X(0x72188681), X(0x72393792), - X(0x7259b8f5), X(0x727a0ab2), X(0x729a2cd2), X(0x72ba1f5d), - X(0x72d9e25c), X(0x72f975d8), X(0x7318d9db), X(0x73380e6f), - X(0x735713a0), X(0x7375e978), X(0x73949003), X(0x73b3074c), - X(0x73d14f61), X(0x73ef684f), X(0x740d5222), X(0x742b0ce9), - X(0x744898b1), X(0x7465f589), X(0x74832381), X(0x74a022a8), - X(0x74bcf30e), X(0x74d994c3), X(0x74f607d8), X(0x75124c5f), - X(0x752e6268), X(0x754a4a05), X(0x7566034b), X(0x75818e4a), - X(0x759ceb16), X(0x75b819c4), X(0x75d31a66), X(0x75eded12), - X(0x760891dc), X(0x762308da), X(0x763d5221), X(0x76576dc8), - X(0x76715be4), X(0x768b1c8c), X(0x76a4afd9), X(0x76be15e0), - X(0x76d74ebb), X(0x76f05a82), X(0x7709394d), X(0x7721eb35), - X(0x773a7054), X(0x7752c8c4), X(0x776af49f), X(0x7782f400), - X(0x779ac701), X(0x77b26dbd), X(0x77c9e851), X(0x77e136d8), - X(0x77f8596f), X(0x780f5032), X(0x78261b3f), X(0x783cbab2), - X(0x78532eaa), X(0x78697745), X(0x787f94a0), X(0x789586db), - X(0x78ab4e15), X(0x78c0ea6d), X(0x78d65c03), X(0x78eba2f7), - X(0x7900bf68), X(0x7915b179), X(0x792a7949), X(0x793f16fb), - X(0x79538aaf), X(0x7967d488), X(0x797bf4a8), X(0x798feb31), - X(0x79a3b846), X(0x79b75c0a), X(0x79cad6a1), X(0x79de282e), - X(0x79f150d5), X(0x7a0450bb), X(0x7a172803), X(0x7a29d6d3), - X(0x7a3c5d50), X(0x7a4ebb9f), X(0x7a60f1e6), X(0x7a73004a), - X(0x7a84e6f2), X(0x7a96a604), X(0x7aa83da7), X(0x7ab9ae01), - X(0x7acaf73a), X(0x7adc1979), X(0x7aed14e6), X(0x7afde9a8), - X(0x7b0e97e8), X(0x7b1f1fcd), X(0x7b2f8182), X(0x7b3fbd2d), - X(0x7b4fd2f9), X(0x7b5fc30f), X(0x7b6f8d98), X(0x7b7f32bd), - X(0x7b8eb2a9), X(0x7b9e0d85), X(0x7bad437d), X(0x7bbc54b9), - X(0x7bcb4166), X(0x7bda09ae), X(0x7be8adbc), X(0x7bf72dbc), - X(0x7c0589d8), X(0x7c13c23d), X(0x7c21d716), X(0x7c2fc88f), - X(0x7c3d96d5), X(0x7c4b4214), X(0x7c58ca78), X(0x7c66302d), - X(0x7c737362), X(0x7c809443), X(0x7c8d92fc), X(0x7c9a6fbc), - X(0x7ca72aaf), X(0x7cb3c404), X(0x7cc03be8), X(0x7ccc9288), - X(0x7cd8c814), X(0x7ce4dcb9), X(0x7cf0d0a5), X(0x7cfca406), - X(0x7d08570c), X(0x7d13e9e5), X(0x7d1f5cbf), X(0x7d2aafca), - X(0x7d35e335), X(0x7d40f72e), X(0x7d4bebe4), X(0x7d56c188), - X(0x7d617848), X(0x7d6c1054), X(0x7d7689db), X(0x7d80e50e), - X(0x7d8b221b), X(0x7d954133), X(0x7d9f4286), X(0x7da92643), - X(0x7db2ec9b), X(0x7dbc95bd), X(0x7dc621da), X(0x7dcf9123), - X(0x7dd8e3c6), X(0x7de219f6), X(0x7deb33e2), X(0x7df431ba), - X(0x7dfd13af), X(0x7e05d9f2), X(0x7e0e84b4), X(0x7e171424), - X(0x7e1f8874), X(0x7e27e1d4), X(0x7e302074), X(0x7e384487), - X(0x7e404e3c), X(0x7e483dc4), X(0x7e501350), X(0x7e57cf11), - X(0x7e5f7138), X(0x7e66f9f4), X(0x7e6e6979), X(0x7e75bff5), - X(0x7e7cfd9a), X(0x7e842298), X(0x7e8b2f22), X(0x7e922366), - X(0x7e98ff97), X(0x7e9fc3e4), X(0x7ea6707f), X(0x7ead0598), - X(0x7eb38360), X(0x7eb9ea07), X(0x7ec039bf), X(0x7ec672b7), - X(0x7ecc9521), X(0x7ed2a12c), X(0x7ed8970a), X(0x7ede76ea), - X(0x7ee440fd), X(0x7ee9f573), X(0x7eef947d), X(0x7ef51e4b), - X(0x7efa930d), X(0x7efff2f2), X(0x7f053e2b), X(0x7f0a74e8), - X(0x7f0f9758), X(0x7f14a5ac), X(0x7f19a013), X(0x7f1e86bc), - X(0x7f2359d8), X(0x7f281995), X(0x7f2cc623), X(0x7f315fb1), - X(0x7f35e66e), X(0x7f3a5a8a), X(0x7f3ebc33), X(0x7f430b98), - X(0x7f4748e7), X(0x7f4b7450), X(0x7f4f8e01), X(0x7f539629), - X(0x7f578cf5), X(0x7f5b7293), X(0x7f5f4732), X(0x7f630b00), - X(0x7f66be2b), X(0x7f6a60df), X(0x7f6df34b), X(0x7f71759b), - X(0x7f74e7fe), X(0x7f784aa0), X(0x7f7b9daf), X(0x7f7ee156), - X(0x7f8215c3), X(0x7f853b22), X(0x7f88519f), X(0x7f8b5967), - X(0x7f8e52a6), X(0x7f913d87), X(0x7f941a36), X(0x7f96e8df), - X(0x7f99a9ad), X(0x7f9c5ccb), X(0x7f9f0265), X(0x7fa19aa5), - X(0x7fa425b5), X(0x7fa6a3c1), X(0x7fa914f3), X(0x7fab7974), - X(0x7fadd16f), X(0x7fb01d0d), X(0x7fb25c78), X(0x7fb48fd9), - X(0x7fb6b75a), X(0x7fb8d323), X(0x7fbae35d), X(0x7fbce831), - X(0x7fbee1c7), X(0x7fc0d047), X(0x7fc2b3d9), X(0x7fc48ca5), - X(0x7fc65ad3), X(0x7fc81e88), X(0x7fc9d7ee), X(0x7fcb872a), - X(0x7fcd2c63), X(0x7fcec7bf), X(0x7fd05966), X(0x7fd1e17c), - X(0x7fd36027), X(0x7fd4d58d), X(0x7fd641d3), X(0x7fd7a51e), - X(0x7fd8ff94), X(0x7fda5157), X(0x7fdb9a8e), X(0x7fdcdb5b), - X(0x7fde13e2), X(0x7fdf4448), X(0x7fe06caf), X(0x7fe18d3b), - X(0x7fe2a60e), X(0x7fe3b74b), X(0x7fe4c114), X(0x7fe5c38b), - X(0x7fe6bed2), X(0x7fe7b30a), X(0x7fe8a055), X(0x7fe986d4), - X(0x7fea66a7), X(0x7feb3ff0), X(0x7fec12cd), X(0x7fecdf5f), - X(0x7feda5c5), X(0x7fee6620), X(0x7fef208d), X(0x7fefd52c), - X(0x7ff0841c), X(0x7ff12d7a), X(0x7ff1d164), X(0x7ff26ff9), - X(0x7ff30955), X(0x7ff39d96), X(0x7ff42cd9), X(0x7ff4b739), - X(0x7ff53cd4), X(0x7ff5bdc5), X(0x7ff63a28), X(0x7ff6b217), - X(0x7ff725af), X(0x7ff7950a), X(0x7ff80043), X(0x7ff86773), - X(0x7ff8cab4), X(0x7ff92a21), X(0x7ff985d1), X(0x7ff9dddf), - X(0x7ffa3262), X(0x7ffa8374), X(0x7ffad12c), X(0x7ffb1ba1), - X(0x7ffb62ec), X(0x7ffba723), X(0x7ffbe85c), X(0x7ffc26b0), - X(0x7ffc6233), X(0x7ffc9afb), X(0x7ffcd11e), X(0x7ffd04b1), - X(0x7ffd35c9), X(0x7ffd647b), X(0x7ffd90da), X(0x7ffdbafa), - X(0x7ffde2f0), X(0x7ffe08ce), X(0x7ffe2ca7), X(0x7ffe4e8e), - X(0x7ffe6e95), X(0x7ffe8cce), X(0x7ffea94a), X(0x7ffec41b), - X(0x7ffedd52), X(0x7ffef4ff), X(0x7fff0b33), X(0x7fff1ffd), - X(0x7fff336e), X(0x7fff4593), X(0x7fff567d), X(0x7fff663a), - X(0x7fff74d8), X(0x7fff8265), X(0x7fff8eee), X(0x7fff9a81), - X(0x7fffa52b), X(0x7fffaef8), X(0x7fffb7f5), X(0x7fffc02d), - X(0x7fffc7ab), X(0x7fffce7c), X(0x7fffd4a9), X(0x7fffda3e), - X(0x7fffdf44), X(0x7fffe3c6), X(0x7fffe7cc), X(0x7fffeb60), - X(0x7fffee8a), X(0x7ffff153), X(0x7ffff3c4), X(0x7ffff5e3), - X(0x7ffff7b8), X(0x7ffff94b), X(0x7ffffaa1), X(0x7ffffbc1), - X(0x7ffffcb2), X(0x7ffffd78), X(0x7ffffe19), X(0x7ffffe9a), - X(0x7ffffeff), X(0x7fffff4e), X(0x7fffff89), X(0x7fffffb3), - X(0x7fffffd2), X(0x7fffffe6), X(0x7ffffff3), X(0x7ffffffa), - X(0x7ffffffe), X(0x7fffffff), X(0x7fffffff), X(0x7fffffff), -}; - -static LOOKUP_T vwin4096[2048] = { - X(0x000001f0), X(0x00001171), X(0x00003072), X(0x00005ef5), - X(0x00009cf8), X(0x0000ea7c), X(0x00014780), X(0x0001b405), - X(0x0002300b), X(0x0002bb91), X(0x00035698), X(0x0004011e), - X(0x0004bb25), X(0x000584ac), X(0x00065db3), X(0x0007463a), - X(0x00083e41), X(0x000945c7), X(0x000a5ccc), X(0x000b8350), - X(0x000cb954), X(0x000dfed7), X(0x000f53d8), X(0x0010b857), - X(0x00122c55), X(0x0013afd1), X(0x001542ca), X(0x0016e541), - X(0x00189735), X(0x001a58a7), X(0x001c2995), X(0x001e09ff), - X(0x001ff9e6), X(0x0021f948), X(0x00240826), X(0x00262680), - X(0x00285454), X(0x002a91a3), X(0x002cde6c), X(0x002f3aaf), - X(0x0031a66b), X(0x003421a0), X(0x0036ac4f), X(0x00394675), - X(0x003bf014), X(0x003ea92a), X(0x004171b7), X(0x004449bb), - X(0x00473135), X(0x004a2824), X(0x004d2e8a), X(0x00504463), - X(0x005369b2), X(0x00569e74), X(0x0059e2aa), X(0x005d3652), - X(0x0060996d), X(0x00640bf9), X(0x00678df7), X(0x006b1f66), - X(0x006ec045), X(0x00727093), X(0x00763051), X(0x0079ff7d), - X(0x007dde16), X(0x0081cc1d), X(0x0085c991), X(0x0089d671), - X(0x008df2bc), X(0x00921e71), X(0x00965991), X(0x009aa41a), - X(0x009efe0c), X(0x00a36766), X(0x00a7e028), X(0x00ac6850), - X(0x00b0ffde), X(0x00b5a6d1), X(0x00ba5d28), X(0x00bf22e4), - X(0x00c3f802), X(0x00c8dc83), X(0x00cdd065), X(0x00d2d3a8), - X(0x00d7e64a), X(0x00dd084c), X(0x00e239ac), X(0x00e77a69), - X(0x00ecca83), X(0x00f229f9), X(0x00f798ca), X(0x00fd16f5), - X(0x0102a479), X(0x01084155), X(0x010ded89), X(0x0113a913), - X(0x011973f3), X(0x011f4e27), X(0x012537af), X(0x012b308a), - X(0x013138b7), X(0x01375035), X(0x013d7702), X(0x0143ad1f), - X(0x0149f289), X(0x01504741), X(0x0156ab44), X(0x015d1e92), - X(0x0163a12a), X(0x016a330b), X(0x0170d433), X(0x017784a3), - X(0x017e4458), X(0x01851351), X(0x018bf18e), X(0x0192df0d), - X(0x0199dbcd), X(0x01a0e7cd), X(0x01a8030c), X(0x01af2d89), - X(0x01b66743), X(0x01bdb038), X(0x01c50867), X(0x01cc6fd0), - X(0x01d3e670), X(0x01db6c47), X(0x01e30153), X(0x01eaa593), - X(0x01f25907), X(0x01fa1bac), X(0x0201ed81), X(0x0209ce86), - X(0x0211beb8), X(0x0219be17), X(0x0221cca2), X(0x0229ea56), - X(0x02321733), X(0x023a5337), X(0x02429e60), X(0x024af8af), - X(0x02536220), X(0x025bdab3), X(0x02646267), X(0x026cf93a), - X(0x02759f2a), X(0x027e5436), X(0x0287185d), X(0x028feb9d), - X(0x0298cdf4), X(0x02a1bf62), X(0x02aabfe5), X(0x02b3cf7b), - X(0x02bcee23), X(0x02c61bdb), X(0x02cf58a2), X(0x02d8a475), - X(0x02e1ff55), X(0x02eb693e), X(0x02f4e230), X(0x02fe6a29), - X(0x03080127), X(0x0311a729), X(0x031b5c2d), X(0x03252031), - X(0x032ef334), X(0x0338d534), X(0x0342c630), X(0x034cc625), - X(0x0356d512), X(0x0360f2f6), X(0x036b1fce), X(0x03755b99), - X(0x037fa655), X(0x038a0001), X(0x0394689a), X(0x039ee020), - X(0x03a9668f), X(0x03b3fbe6), X(0x03bea024), X(0x03c95347), - X(0x03d4154d), X(0x03dee633), X(0x03e9c5f9), X(0x03f4b49b), - X(0x03ffb219), X(0x040abe71), X(0x0415d9a0), X(0x042103a5), - X(0x042c3c7d), X(0x04378428), X(0x0442daa2), X(0x044e3fea), - X(0x0459b3fd), X(0x046536db), X(0x0470c880), X(0x047c68eb), - X(0x0488181a), X(0x0493d60b), X(0x049fa2bc), X(0x04ab7e2a), - X(0x04b76854), X(0x04c36137), X(0x04cf68d1), X(0x04db7f21), - X(0x04e7a424), X(0x04f3d7d8), X(0x05001a3b), X(0x050c6b4a), - X(0x0518cb04), X(0x05253966), X(0x0531b66e), X(0x053e421a), - X(0x054adc68), X(0x05578555), X(0x05643cdf), X(0x05710304), - X(0x057dd7c1), X(0x058abb15), X(0x0597acfd), X(0x05a4ad76), - X(0x05b1bc7f), X(0x05beda14), X(0x05cc0635), X(0x05d940dd), - X(0x05e68a0b), X(0x05f3e1bd), X(0x060147f0), X(0x060ebca1), - X(0x061c3fcf), X(0x0629d176), X(0x06377194), X(0x06452027), - X(0x0652dd2c), X(0x0660a8a2), X(0x066e8284), X(0x067c6ad1), - X(0x068a6186), X(0x069866a1), X(0x06a67a1e), X(0x06b49bfc), - X(0x06c2cc38), X(0x06d10acf), X(0x06df57bf), X(0x06edb304), - X(0x06fc1c9d), X(0x070a9487), X(0x07191abe), X(0x0727af40), - X(0x0736520b), X(0x0745031c), X(0x0753c270), X(0x07629004), - X(0x07716bd6), X(0x078055e2), X(0x078f4e26), X(0x079e549f), - X(0x07ad694b), X(0x07bc8c26), X(0x07cbbd2e), X(0x07dafc5f), - X(0x07ea49b7), X(0x07f9a533), X(0x08090ed1), X(0x0818868c), - X(0x08280c62), X(0x0837a051), X(0x08474255), X(0x0856f26b), - X(0x0866b091), X(0x08767cc3), X(0x088656fe), X(0x08963f3f), - X(0x08a63584), X(0x08b639c8), X(0x08c64c0a), X(0x08d66c45), - X(0x08e69a77), X(0x08f6d69d), X(0x090720b3), X(0x091778b7), - X(0x0927dea5), X(0x0938527a), X(0x0948d433), X(0x095963cc), - X(0x096a0143), X(0x097aac94), X(0x098b65bb), X(0x099c2cb6), - X(0x09ad0182), X(0x09bde41a), X(0x09ced47d), X(0x09dfd2a5), - X(0x09f0de90), X(0x0a01f83b), X(0x0a131fa3), X(0x0a2454c3), - X(0x0a359798), X(0x0a46e820), X(0x0a584656), X(0x0a69b237), - X(0x0a7b2bc0), X(0x0a8cb2ec), X(0x0a9e47ba), X(0x0aafea24), - X(0x0ac19a29), X(0x0ad357c3), X(0x0ae522ef), X(0x0af6fbab), - X(0x0b08e1f1), X(0x0b1ad5c0), X(0x0b2cd712), X(0x0b3ee5e5), - X(0x0b510234), X(0x0b632bfd), X(0x0b75633b), X(0x0b87a7eb), - X(0x0b99fa08), X(0x0bac5990), X(0x0bbec67e), X(0x0bd140cf), - X(0x0be3c87e), X(0x0bf65d89), X(0x0c08ffeb), X(0x0c1bafa1), - X(0x0c2e6ca6), X(0x0c4136f6), X(0x0c540e8f), X(0x0c66f36c), - X(0x0c79e588), X(0x0c8ce4e1), X(0x0c9ff172), X(0x0cb30b37), - X(0x0cc6322c), X(0x0cd9664d), X(0x0ceca797), X(0x0cfff605), - X(0x0d135193), X(0x0d26ba3d), X(0x0d3a2fff), X(0x0d4db2d5), - X(0x0d6142ba), X(0x0d74dfac), X(0x0d8889a5), X(0x0d9c40a1), - X(0x0db0049d), X(0x0dc3d593), X(0x0dd7b380), X(0x0deb9e60), - X(0x0dff962f), X(0x0e139ae7), X(0x0e27ac85), X(0x0e3bcb05), - X(0x0e4ff662), X(0x0e642e98), X(0x0e7873a2), X(0x0e8cc57d), - X(0x0ea12423), X(0x0eb58f91), X(0x0eca07c2), X(0x0ede8cb1), - X(0x0ef31e5b), X(0x0f07bcba), X(0x0f1c67cb), X(0x0f311f88), - X(0x0f45e3ee), X(0x0f5ab4f7), X(0x0f6f92a0), X(0x0f847ce3), - X(0x0f9973bc), X(0x0fae7726), X(0x0fc3871e), X(0x0fd8a39d), - X(0x0fedcca1), X(0x10030223), X(0x1018441f), X(0x102d9291), - X(0x1042ed74), X(0x105854c3), X(0x106dc879), X(0x10834892), - X(0x1098d508), X(0x10ae6dd8), X(0x10c412fc), X(0x10d9c46f), - X(0x10ef822d), X(0x11054c30), X(0x111b2274), X(0x113104f5), - X(0x1146f3ac), X(0x115cee95), X(0x1172f5ab), X(0x118908e9), - X(0x119f284a), X(0x11b553ca), X(0x11cb8b62), X(0x11e1cf0f), - X(0x11f81ecb), X(0x120e7a90), X(0x1224e25a), X(0x123b5624), - X(0x1251d5e9), X(0x126861a3), X(0x127ef94e), X(0x12959ce3), - X(0x12ac4c5f), X(0x12c307bb), X(0x12d9cef2), X(0x12f0a200), - X(0x130780df), X(0x131e6b8a), X(0x133561fa), X(0x134c642c), - X(0x1363721a), X(0x137a8bbe), X(0x1391b113), X(0x13a8e214), - X(0x13c01eba), X(0x13d76702), X(0x13eebae5), X(0x14061a5e), - X(0x141d8567), X(0x1434fbfb), X(0x144c7e14), X(0x14640bae), - X(0x147ba4c1), X(0x14934949), X(0x14aaf941), X(0x14c2b4a2), - X(0x14da7b67), X(0x14f24d8a), X(0x150a2b06), X(0x152213d5), - X(0x153a07f1), X(0x15520755), X(0x156a11fb), X(0x158227dd), - X(0x159a48f5), X(0x15b2753d), X(0x15caacb1), X(0x15e2ef49), - X(0x15fb3d01), X(0x161395d2), X(0x162bf9b6), X(0x164468a8), - X(0x165ce2a1), X(0x1675679c), X(0x168df793), X(0x16a69280), - X(0x16bf385c), X(0x16d7e922), X(0x16f0a4cc), X(0x17096b54), - X(0x17223cb4), X(0x173b18e5), X(0x1753ffe2), X(0x176cf1a5), - X(0x1785ee27), X(0x179ef562), X(0x17b80750), X(0x17d123eb), - X(0x17ea4b2d), X(0x18037d10), X(0x181cb98d), X(0x1836009e), - X(0x184f523c), X(0x1868ae63), X(0x1882150a), X(0x189b862c), - X(0x18b501c4), X(0x18ce87c9), X(0x18e81836), X(0x1901b305), - X(0x191b582f), X(0x193507ad), X(0x194ec17a), X(0x1968858f), - X(0x198253e5), X(0x199c2c75), X(0x19b60f3a), X(0x19cffc2d), - X(0x19e9f347), X(0x1a03f482), X(0x1a1dffd7), X(0x1a381540), - X(0x1a5234b5), X(0x1a6c5e31), X(0x1a8691ac), X(0x1aa0cf21), - X(0x1abb1687), X(0x1ad567da), X(0x1aefc311), X(0x1b0a2826), - X(0x1b249712), X(0x1b3f0fd0), X(0x1b599257), X(0x1b741ea1), - X(0x1b8eb4a7), X(0x1ba95462), X(0x1bc3fdcd), X(0x1bdeb0de), - X(0x1bf96d91), X(0x1c1433dd), X(0x1c2f03bc), X(0x1c49dd27), - X(0x1c64c017), X(0x1c7fac85), X(0x1c9aa269), X(0x1cb5a1be), - X(0x1cd0aa7c), X(0x1cebbc9c), X(0x1d06d816), X(0x1d21fce4), - X(0x1d3d2aff), X(0x1d586260), X(0x1d73a2fe), X(0x1d8eecd4), - X(0x1daa3fda), X(0x1dc59c09), X(0x1de1015a), X(0x1dfc6fc5), - X(0x1e17e743), X(0x1e3367cd), X(0x1e4ef15b), X(0x1e6a83e7), - X(0x1e861f6a), X(0x1ea1c3da), X(0x1ebd7133), X(0x1ed9276b), - X(0x1ef4e67c), X(0x1f10ae5e), X(0x1f2c7f0a), X(0x1f485879), - X(0x1f643aa2), X(0x1f80257f), X(0x1f9c1908), X(0x1fb81536), - X(0x1fd41a00), X(0x1ff02761), X(0x200c3d4f), X(0x20285bc3), - X(0x204482b7), X(0x2060b221), X(0x207ce9fb), X(0x20992a3e), - X(0x20b572e0), X(0x20d1c3dc), X(0x20ee1d28), X(0x210a7ebe), - X(0x2126e895), X(0x21435aa6), X(0x215fd4ea), X(0x217c5757), - X(0x2198e1e8), X(0x21b57493), X(0x21d20f51), X(0x21eeb21b), - X(0x220b5ce7), X(0x22280fb0), X(0x2244ca6c), X(0x22618d13), - X(0x227e579f), X(0x229b2a06), X(0x22b80442), X(0x22d4e649), - X(0x22f1d015), X(0x230ec19d), X(0x232bbad9), X(0x2348bbc1), - X(0x2365c44c), X(0x2382d474), X(0x239fec30), X(0x23bd0b78), - X(0x23da3244), X(0x23f7608b), X(0x24149646), X(0x2431d36c), - X(0x244f17f5), X(0x246c63da), X(0x2489b711), X(0x24a71193), - X(0x24c47358), X(0x24e1dc57), X(0x24ff4c88), X(0x251cc3e2), - X(0x253a425e), X(0x2557c7f4), X(0x2575549a), X(0x2592e848), - X(0x25b082f7), X(0x25ce249e), X(0x25ebcd34), X(0x26097cb2), - X(0x2627330e), X(0x2644f040), X(0x2662b441), X(0x26807f07), - X(0x269e5089), X(0x26bc28c1), X(0x26da07a4), X(0x26f7ed2b), - X(0x2715d94d), X(0x2733cc02), X(0x2751c540), X(0x276fc500), - X(0x278dcb39), X(0x27abd7e2), X(0x27c9eaf3), X(0x27e80463), - X(0x28062429), X(0x28244a3e), X(0x28427697), X(0x2860a92d), - X(0x287ee1f7), X(0x289d20eb), X(0x28bb6603), X(0x28d9b134), - X(0x28f80275), X(0x291659c0), X(0x2934b709), X(0x29531a49), - X(0x29718378), X(0x298ff28b), X(0x29ae677b), X(0x29cce23e), - X(0x29eb62cb), X(0x2a09e91b), X(0x2a287523), X(0x2a4706dc), - X(0x2a659e3c), X(0x2a843b39), X(0x2aa2ddcd), X(0x2ac185ec), - X(0x2ae0338f), X(0x2afee6ad), X(0x2b1d9f3c), X(0x2b3c5d33), - X(0x2b5b208b), X(0x2b79e939), X(0x2b98b734), X(0x2bb78a74), - X(0x2bd662ef), X(0x2bf5409d), X(0x2c142374), X(0x2c330b6b), - X(0x2c51f87a), X(0x2c70ea97), X(0x2c8fe1b9), X(0x2caeddd6), - X(0x2ccddee7), X(0x2cece4e1), X(0x2d0befbb), X(0x2d2aff6d), - X(0x2d4a13ec), X(0x2d692d31), X(0x2d884b32), X(0x2da76de4), - X(0x2dc69540), X(0x2de5c13d), X(0x2e04f1d0), X(0x2e2426f0), - X(0x2e436095), X(0x2e629eb4), X(0x2e81e146), X(0x2ea1283f), - X(0x2ec07398), X(0x2edfc347), X(0x2eff1742), X(0x2f1e6f80), - X(0x2f3dcbf8), X(0x2f5d2ca0), X(0x2f7c916f), X(0x2f9bfa5c), - X(0x2fbb675d), X(0x2fdad869), X(0x2ffa4d76), X(0x3019c67b), - X(0x3039436f), X(0x3058c448), X(0x307848fc), X(0x3097d183), - X(0x30b75dd3), X(0x30d6ede2), X(0x30f681a6), X(0x31161917), - X(0x3135b42b), X(0x315552d8), X(0x3174f514), X(0x31949ad7), - X(0x31b44417), X(0x31d3f0ca), X(0x31f3a0e6), X(0x32135462), - X(0x32330b35), X(0x3252c555), X(0x327282b7), X(0x32924354), - X(0x32b20720), X(0x32d1ce13), X(0x32f19823), X(0x33116546), - X(0x33313573), X(0x3351089f), X(0x3370dec2), X(0x3390b7d1), - X(0x33b093c3), X(0x33d0728f), X(0x33f05429), X(0x3410388a), - X(0x34301fa7), X(0x34500977), X(0x346ff5ef), X(0x348fe506), - X(0x34afd6b3), X(0x34cfcaeb), X(0x34efc1a5), X(0x350fbad7), - X(0x352fb678), X(0x354fb47d), X(0x356fb4dd), X(0x358fb78e), - X(0x35afbc86), X(0x35cfc3bc), X(0x35efcd25), X(0x360fd8b8), - X(0x362fe66c), X(0x364ff636), X(0x3670080c), X(0x36901be5), - X(0x36b031b7), X(0x36d04978), X(0x36f0631e), X(0x37107ea0), - X(0x37309bf3), X(0x3750bb0e), X(0x3770dbe6), X(0x3790fe73), - X(0x37b122aa), X(0x37d14881), X(0x37f16fee), X(0x381198e8), - X(0x3831c365), X(0x3851ef5a), X(0x38721cbe), X(0x38924b87), - X(0x38b27bac), X(0x38d2ad21), X(0x38f2dfde), X(0x391313d8), - X(0x39334906), X(0x39537f5d), X(0x3973b6d4), X(0x3993ef60), - X(0x39b428f9), X(0x39d46393), X(0x39f49f25), X(0x3a14dba6), - X(0x3a35190a), X(0x3a555748), X(0x3a759657), X(0x3a95d62c), - X(0x3ab616be), X(0x3ad65801), X(0x3af699ed), X(0x3b16dc78), - X(0x3b371f97), X(0x3b576341), X(0x3b77a76c), X(0x3b97ec0d), - X(0x3bb8311b), X(0x3bd8768b), X(0x3bf8bc55), X(0x3c19026d), - X(0x3c3948ca), X(0x3c598f62), X(0x3c79d62b), X(0x3c9a1d1b), - X(0x3cba6428), X(0x3cdaab48), X(0x3cfaf271), X(0x3d1b3999), - X(0x3d3b80b6), X(0x3d5bc7be), X(0x3d7c0ea8), X(0x3d9c5569), - X(0x3dbc9bf7), X(0x3ddce248), X(0x3dfd2852), X(0x3e1d6e0c), - X(0x3e3db36c), X(0x3e5df866), X(0x3e7e3cf2), X(0x3e9e8106), - X(0x3ebec497), X(0x3edf079b), X(0x3eff4a09), X(0x3f1f8bd7), - X(0x3f3fccfa), X(0x3f600d69), X(0x3f804d1a), X(0x3fa08c02), - X(0x3fc0ca19), X(0x3fe10753), X(0x400143a7), X(0x40217f0a), - X(0x4041b974), X(0x4061f2da), X(0x40822b32), X(0x40a26272), - X(0x40c29891), X(0x40e2cd83), X(0x41030140), X(0x412333bd), - X(0x414364f1), X(0x416394d2), X(0x4183c355), X(0x41a3f070), - X(0x41c41c1b), X(0x41e4464a), X(0x42046ef4), X(0x42249610), - X(0x4244bb92), X(0x4264df72), X(0x428501a5), X(0x42a52222), - X(0x42c540de), X(0x42e55dd0), X(0x430578ed), X(0x4325922d), - X(0x4345a985), X(0x4365beeb), X(0x4385d255), X(0x43a5e3ba), - X(0x43c5f30f), X(0x43e6004b), X(0x44060b65), X(0x44261451), - X(0x44461b07), X(0x44661f7c), X(0x448621a7), X(0x44a6217d), - X(0x44c61ef6), X(0x44e61a07), X(0x450612a6), X(0x452608ca), - X(0x4545fc69), X(0x4565ed79), X(0x4585dbf1), X(0x45a5c7c6), - X(0x45c5b0ef), X(0x45e59761), X(0x46057b15), X(0x46255bfe), - X(0x46453a15), X(0x4665154f), X(0x4684eda2), X(0x46a4c305), - X(0x46c4956e), X(0x46e464d3), X(0x4704312b), X(0x4723fa6c), - X(0x4743c08d), X(0x47638382), X(0x47834344), X(0x47a2ffc9), - X(0x47c2b906), X(0x47e26ef2), X(0x48022183), X(0x4821d0b1), - X(0x48417c71), X(0x486124b9), X(0x4880c981), X(0x48a06abe), - X(0x48c00867), X(0x48dfa272), X(0x48ff38d6), X(0x491ecb8a), - X(0x493e5a84), X(0x495de5b9), X(0x497d6d22), X(0x499cf0b4), - X(0x49bc7066), X(0x49dbec2e), X(0x49fb6402), X(0x4a1ad7db), - X(0x4a3a47ad), X(0x4a59b370), X(0x4a791b1a), X(0x4a987ea1), - X(0x4ab7ddfd), X(0x4ad73924), X(0x4af6900c), X(0x4b15e2ad), - X(0x4b3530fc), X(0x4b547af1), X(0x4b73c082), X(0x4b9301a6), - X(0x4bb23e53), X(0x4bd17681), X(0x4bf0aa25), X(0x4c0fd937), - X(0x4c2f03ae), X(0x4c4e297f), X(0x4c6d4aa3), X(0x4c8c670f), - X(0x4cab7eba), X(0x4cca919c), X(0x4ce99fab), X(0x4d08a8de), - X(0x4d27ad2c), X(0x4d46ac8b), X(0x4d65a6f3), X(0x4d849c5a), - X(0x4da38cb7), X(0x4dc27802), X(0x4de15e31), X(0x4e003f3a), - X(0x4e1f1b16), X(0x4e3df1ba), X(0x4e5cc31e), X(0x4e7b8f3a), - X(0x4e9a5603), X(0x4eb91771), X(0x4ed7d37b), X(0x4ef68a18), - X(0x4f153b3f), X(0x4f33e6e7), X(0x4f528d08), X(0x4f712d97), - X(0x4f8fc88e), X(0x4fae5de1), X(0x4fcced8a), X(0x4feb777f), - X(0x5009fbb6), X(0x50287a28), X(0x5046f2cc), X(0x50656598), - X(0x5083d284), X(0x50a23988), X(0x50c09a9a), X(0x50def5b1), - X(0x50fd4ac7), X(0x511b99d0), X(0x5139e2c5), X(0x5158259e), - X(0x51766251), X(0x519498d6), X(0x51b2c925), X(0x51d0f334), - X(0x51ef16fb), X(0x520d3473), X(0x522b4b91), X(0x52495c4e), - X(0x526766a2), X(0x52856a83), X(0x52a367e9), X(0x52c15ecd), - X(0x52df4f24), X(0x52fd38e8), X(0x531b1c10), X(0x5338f892), - X(0x5356ce68), X(0x53749d89), X(0x539265eb), X(0x53b02788), - X(0x53cde257), X(0x53eb964f), X(0x54094369), X(0x5426e99c), - X(0x544488df), X(0x5462212c), X(0x547fb279), X(0x549d3cbe), - X(0x54babff4), X(0x54d83c12), X(0x54f5b110), X(0x55131ee7), - X(0x5530858d), X(0x554de4fc), X(0x556b3d2a), X(0x55888e11), - X(0x55a5d7a8), X(0x55c319e7), X(0x55e054c7), X(0x55fd883f), - X(0x561ab447), X(0x5637d8d8), X(0x5654f5ea), X(0x56720b75), - X(0x568f1971), X(0x56ac1fd7), X(0x56c91e9e), X(0x56e615c0), - X(0x57030534), X(0x571fecf2), X(0x573cccf3), X(0x5759a530), - X(0x577675a0), X(0x57933e3c), X(0x57affefd), X(0x57ccb7db), - X(0x57e968ce), X(0x580611cf), X(0x5822b2d6), X(0x583f4bdd), - X(0x585bdcdb), X(0x587865c9), X(0x5894e69f), X(0x58b15f57), - X(0x58cdcfe9), X(0x58ea384e), X(0x5906987d), X(0x5922f071), - X(0x593f4022), X(0x595b8788), X(0x5977c69c), X(0x5993fd57), - X(0x59b02bb2), X(0x59cc51a6), X(0x59e86f2c), X(0x5a04843c), - X(0x5a2090d0), X(0x5a3c94e0), X(0x5a589065), X(0x5a748359), - X(0x5a906db4), X(0x5aac4f70), X(0x5ac82884), X(0x5ae3f8ec), - X(0x5affc09f), X(0x5b1b7f97), X(0x5b3735cd), X(0x5b52e33a), - X(0x5b6e87d8), X(0x5b8a239f), X(0x5ba5b689), X(0x5bc1408f), - X(0x5bdcc1aa), X(0x5bf839d5), X(0x5c13a907), X(0x5c2f0f3b), - X(0x5c4a6c6a), X(0x5c65c08d), X(0x5c810b9e), X(0x5c9c4d97), - X(0x5cb78670), X(0x5cd2b623), X(0x5ceddcaa), X(0x5d08f9ff), - X(0x5d240e1b), X(0x5d3f18f8), X(0x5d5a1a8f), X(0x5d7512da), - X(0x5d9001d3), X(0x5daae773), X(0x5dc5c3b5), X(0x5de09692), - X(0x5dfb6004), X(0x5e162004), X(0x5e30d68d), X(0x5e4b8399), - X(0x5e662721), X(0x5e80c11f), X(0x5e9b518e), X(0x5eb5d867), - X(0x5ed055a4), X(0x5eeac940), X(0x5f053334), X(0x5f1f937b), - X(0x5f39ea0f), X(0x5f5436ea), X(0x5f6e7a06), X(0x5f88b35d), - X(0x5fa2e2e9), X(0x5fbd08a6), X(0x5fd7248d), X(0x5ff13698), - X(0x600b3ec2), X(0x60253d05), X(0x603f315b), X(0x60591bc0), - X(0x6072fc2d), X(0x608cd29e), X(0x60a69f0b), X(0x60c06171), - X(0x60da19ca), X(0x60f3c80f), X(0x610d6c3d), X(0x6127064d), - X(0x6140963a), X(0x615a1bff), X(0x61739797), X(0x618d08fc), - X(0x61a67029), X(0x61bfcd1a), X(0x61d91fc8), X(0x61f2682f), - X(0x620ba64a), X(0x6224da13), X(0x623e0386), X(0x6257229d), - X(0x62703754), X(0x628941a6), X(0x62a2418e), X(0x62bb3706), - X(0x62d4220a), X(0x62ed0296), X(0x6305d8a3), X(0x631ea42f), - X(0x63376533), X(0x63501bab), X(0x6368c793), X(0x638168e5), - X(0x6399ff9e), X(0x63b28bb8), X(0x63cb0d2f), X(0x63e383ff), - X(0x63fbf022), X(0x64145195), X(0x642ca853), X(0x6444f457), - X(0x645d359e), X(0x64756c22), X(0x648d97e0), X(0x64a5b8d3), - X(0x64bdcef6), X(0x64d5da47), X(0x64eddabf), X(0x6505d05c), - X(0x651dbb19), X(0x65359af2), X(0x654d6fe3), X(0x656539e7), - X(0x657cf8fb), X(0x6594ad1b), X(0x65ac5643), X(0x65c3f46e), - X(0x65db8799), X(0x65f30fc0), X(0x660a8ce0), X(0x6621fef3), - X(0x663965f7), X(0x6650c1e7), X(0x666812c1), X(0x667f5880), - X(0x66969320), X(0x66adc29e), X(0x66c4e6f7), X(0x66dc0026), - X(0x66f30e28), X(0x670a10fa), X(0x67210898), X(0x6737f4ff), - X(0x674ed62b), X(0x6765ac19), X(0x677c76c5), X(0x6793362c), - X(0x67a9ea4b), X(0x67c0931f), X(0x67d730a3), X(0x67edc2d6), - X(0x680449b3), X(0x681ac538), X(0x68313562), X(0x68479a2d), - X(0x685df396), X(0x6874419b), X(0x688a8438), X(0x68a0bb6a), - X(0x68b6e72e), X(0x68cd0782), X(0x68e31c63), X(0x68f925cd), - X(0x690f23be), X(0x69251633), X(0x693afd29), X(0x6950d89e), - X(0x6966a88f), X(0x697c6cf8), X(0x699225d9), X(0x69a7d32d), - X(0x69bd74f3), X(0x69d30b27), X(0x69e895c8), X(0x69fe14d2), - X(0x6a138844), X(0x6a28f01b), X(0x6a3e4c54), X(0x6a539ced), - X(0x6a68e1e4), X(0x6a7e1b37), X(0x6a9348e3), X(0x6aa86ae6), - X(0x6abd813d), X(0x6ad28be7), X(0x6ae78ae2), X(0x6afc7e2b), - X(0x6b1165c0), X(0x6b26419f), X(0x6b3b11c7), X(0x6b4fd634), - X(0x6b648ee6), X(0x6b793bda), X(0x6b8ddd0e), X(0x6ba27281), - X(0x6bb6fc31), X(0x6bcb7a1b), X(0x6bdfec3e), X(0x6bf45299), - X(0x6c08ad29), X(0x6c1cfbed), X(0x6c313ee4), X(0x6c45760a), - X(0x6c59a160), X(0x6c6dc0e4), X(0x6c81d493), X(0x6c95dc6d), - X(0x6ca9d86f), X(0x6cbdc899), X(0x6cd1acea), X(0x6ce5855f), - X(0x6cf951f7), X(0x6d0d12b1), X(0x6d20c78c), X(0x6d347087), - X(0x6d480da0), X(0x6d5b9ed6), X(0x6d6f2427), X(0x6d829d94), - X(0x6d960b1a), X(0x6da96cb9), X(0x6dbcc270), X(0x6dd00c3c), - X(0x6de34a1f), X(0x6df67c16), X(0x6e09a221), X(0x6e1cbc3f), - X(0x6e2fca6e), X(0x6e42ccaf), X(0x6e55c300), X(0x6e68ad60), - X(0x6e7b8bd0), X(0x6e8e5e4d), X(0x6ea124d8), X(0x6eb3df70), - X(0x6ec68e13), X(0x6ed930c3), X(0x6eebc77d), X(0x6efe5242), - X(0x6f10d111), X(0x6f2343e9), X(0x6f35aacb), X(0x6f4805b5), - X(0x6f5a54a8), X(0x6f6c97a2), X(0x6f7ecea4), X(0x6f90f9ae), - X(0x6fa318be), X(0x6fb52bd6), X(0x6fc732f4), X(0x6fd92e19), - X(0x6feb1d44), X(0x6ffd0076), X(0x700ed7ad), X(0x7020a2eb), - X(0x7032622f), X(0x7044157a), X(0x7055bcca), X(0x70675821), - X(0x7078e77e), X(0x708a6ae2), X(0x709be24c), X(0x70ad4dbd), - X(0x70bead36), X(0x70d000b5), X(0x70e1483d), X(0x70f283cc), - X(0x7103b363), X(0x7114d704), X(0x7125eead), X(0x7136fa60), - X(0x7147fa1c), X(0x7158ede4), X(0x7169d5b6), X(0x717ab193), - X(0x718b817d), X(0x719c4573), X(0x71acfd76), X(0x71bda988), - X(0x71ce49a8), X(0x71deddd7), X(0x71ef6617), X(0x71ffe267), - X(0x721052ca), X(0x7220b73e), X(0x72310fc6), X(0x72415c62), - X(0x72519d14), X(0x7261d1db), X(0x7271faba), X(0x728217b1), - X(0x729228c0), X(0x72a22dea), X(0x72b22730), X(0x72c21491), - X(0x72d1f611), X(0x72e1cbaf), X(0x72f1956c), X(0x7301534c), - X(0x7311054d), X(0x7320ab72), X(0x733045bc), X(0x733fd42d), - X(0x734f56c5), X(0x735ecd86), X(0x736e3872), X(0x737d9789), - X(0x738ceacf), X(0x739c3243), X(0x73ab6de7), X(0x73ba9dbe), - X(0x73c9c1c8), X(0x73d8da08), X(0x73e7e67f), X(0x73f6e72e), - X(0x7405dc17), X(0x7414c53c), X(0x7423a29f), X(0x74327442), - X(0x74413a26), X(0x744ff44d), X(0x745ea2b9), X(0x746d456c), - X(0x747bdc68), X(0x748a67ae), X(0x7498e741), X(0x74a75b23), - X(0x74b5c356), X(0x74c41fdb), X(0x74d270b6), X(0x74e0b5e7), - X(0x74eeef71), X(0x74fd1d57), X(0x750b3f9a), X(0x7519563c), - X(0x75276140), X(0x753560a8), X(0x75435477), X(0x75513cae), - X(0x755f1951), X(0x756cea60), X(0x757aafdf), X(0x758869d1), - X(0x75961837), X(0x75a3bb14), X(0x75b1526a), X(0x75bede3c), - X(0x75cc5e8d), X(0x75d9d35f), X(0x75e73cb5), X(0x75f49a91), - X(0x7601ecf6), X(0x760f33e6), X(0x761c6f65), X(0x76299f74), - X(0x7636c417), X(0x7643dd51), X(0x7650eb24), X(0x765ded93), - X(0x766ae4a0), X(0x7677d050), X(0x7684b0a4), X(0x7691859f), - X(0x769e4f45), X(0x76ab0d98), X(0x76b7c09c), X(0x76c46852), - X(0x76d104bf), X(0x76dd95e6), X(0x76ea1bc9), X(0x76f6966b), - X(0x770305d0), X(0x770f69fb), X(0x771bc2ef), X(0x772810af), - X(0x7734533e), X(0x77408aa0), X(0x774cb6d7), X(0x7758d7e8), - X(0x7764edd5), X(0x7770f8a2), X(0x777cf852), X(0x7788ece8), - X(0x7794d668), X(0x77a0b4d5), X(0x77ac8833), X(0x77b85085), - X(0x77c40dce), X(0x77cfc013), X(0x77db6756), X(0x77e7039b), - X(0x77f294e6), X(0x77fe1b3b), X(0x7809969c), X(0x7815070e), - X(0x78206c93), X(0x782bc731), X(0x783716ea), X(0x78425bc3), - X(0x784d95be), X(0x7858c4e1), X(0x7863e92d), X(0x786f02a8), - X(0x787a1156), X(0x78851539), X(0x78900e56), X(0x789afcb1), - X(0x78a5e04d), X(0x78b0b92f), X(0x78bb875b), X(0x78c64ad4), - X(0x78d1039e), X(0x78dbb1be), X(0x78e65537), X(0x78f0ee0e), - X(0x78fb7c46), X(0x7905ffe4), X(0x791078ec), X(0x791ae762), - X(0x79254b4a), X(0x792fa4a7), X(0x7939f380), X(0x794437d7), - X(0x794e71b0), X(0x7958a111), X(0x7962c5fd), X(0x796ce078), - X(0x7976f087), X(0x7980f62f), X(0x798af173), X(0x7994e258), - X(0x799ec8e2), X(0x79a8a515), X(0x79b276f7), X(0x79bc3e8b), - X(0x79c5fbd6), X(0x79cfaedc), X(0x79d957a2), X(0x79e2f62c), - X(0x79ec8a7f), X(0x79f6149f), X(0x79ff9492), X(0x7a090a5a), - X(0x7a1275fe), X(0x7a1bd781), X(0x7a252ee9), X(0x7a2e7c39), - X(0x7a37bf77), X(0x7a40f8a7), X(0x7a4a27ce), X(0x7a534cf0), - X(0x7a5c6813), X(0x7a65793b), X(0x7a6e806d), X(0x7a777dad), - X(0x7a807100), X(0x7a895a6b), X(0x7a9239f4), X(0x7a9b0f9e), - X(0x7aa3db6f), X(0x7aac9d6b), X(0x7ab55597), X(0x7abe03f9), - X(0x7ac6a895), X(0x7acf4370), X(0x7ad7d48f), X(0x7ae05bf6), - X(0x7ae8d9ac), X(0x7af14db5), X(0x7af9b815), X(0x7b0218d2), - X(0x7b0a6ff2), X(0x7b12bd78), X(0x7b1b016a), X(0x7b233bce), - X(0x7b2b6ca7), X(0x7b3393fc), X(0x7b3bb1d1), X(0x7b43c62c), - X(0x7b4bd111), X(0x7b53d286), X(0x7b5bca90), X(0x7b63b935), - X(0x7b6b9e78), X(0x7b737a61), X(0x7b7b4cf3), X(0x7b831634), - X(0x7b8ad629), X(0x7b928cd8), X(0x7b9a3a45), X(0x7ba1de77), - X(0x7ba97972), X(0x7bb10b3c), X(0x7bb893d9), X(0x7bc01350), - X(0x7bc789a6), X(0x7bcef6e0), X(0x7bd65b03), X(0x7bddb616), - X(0x7be5081c), X(0x7bec511c), X(0x7bf3911b), X(0x7bfac81f), - X(0x7c01f62c), X(0x7c091b49), X(0x7c10377b), X(0x7c174ac7), - X(0x7c1e5532), X(0x7c2556c4), X(0x7c2c4f80), X(0x7c333f6c), - X(0x7c3a268e), X(0x7c4104ec), X(0x7c47da8a), X(0x7c4ea76f), - X(0x7c556ba1), X(0x7c5c2724), X(0x7c62d9fe), X(0x7c698435), - X(0x7c7025cf), X(0x7c76bed0), X(0x7c7d4f40), X(0x7c83d723), - X(0x7c8a567f), X(0x7c90cd5a), X(0x7c973bb9), X(0x7c9da1a2), - X(0x7ca3ff1b), X(0x7caa542a), X(0x7cb0a0d3), X(0x7cb6e51e), - X(0x7cbd210f), X(0x7cc354ac), X(0x7cc97ffc), X(0x7ccfa304), - X(0x7cd5bdc9), X(0x7cdbd051), X(0x7ce1daa3), X(0x7ce7dcc3), - X(0x7cedd6b8), X(0x7cf3c888), X(0x7cf9b238), X(0x7cff93cf), - X(0x7d056d51), X(0x7d0b3ec5), X(0x7d110830), X(0x7d16c99a), - X(0x7d1c8306), X(0x7d22347c), X(0x7d27de00), X(0x7d2d7f9a), - X(0x7d33194f), X(0x7d38ab24), X(0x7d3e351f), X(0x7d43b748), - X(0x7d4931a2), X(0x7d4ea435), X(0x7d540f06), X(0x7d59721b), - X(0x7d5ecd7b), X(0x7d64212a), X(0x7d696d2f), X(0x7d6eb190), - X(0x7d73ee53), X(0x7d79237e), X(0x7d7e5117), X(0x7d837723), - X(0x7d8895a9), X(0x7d8dacae), X(0x7d92bc3a), X(0x7d97c451), - X(0x7d9cc4f9), X(0x7da1be39), X(0x7da6b017), X(0x7dab9a99), - X(0x7db07dc4), X(0x7db5599e), X(0x7dba2e2f), X(0x7dbefb7b), - X(0x7dc3c189), X(0x7dc8805e), X(0x7dcd3802), X(0x7dd1e879), - X(0x7dd691ca), X(0x7ddb33fb), X(0x7ddfcf12), X(0x7de46315), - X(0x7de8f00a), X(0x7ded75f8), X(0x7df1f4e3), X(0x7df66cd3), - X(0x7dfaddcd), X(0x7dff47d7), X(0x7e03aaf8), X(0x7e080735), - X(0x7e0c5c95), X(0x7e10ab1e), X(0x7e14f2d5), X(0x7e1933c1), - X(0x7e1d6de8), X(0x7e21a150), X(0x7e25cdff), X(0x7e29f3fc), - X(0x7e2e134c), X(0x7e322bf5), X(0x7e363dfd), X(0x7e3a496b), - X(0x7e3e4e45), X(0x7e424c90), X(0x7e464454), X(0x7e4a3595), - X(0x7e4e205a), X(0x7e5204aa), X(0x7e55e289), X(0x7e59b9ff), - X(0x7e5d8b12), X(0x7e6155c7), X(0x7e651a24), X(0x7e68d831), - X(0x7e6c8ff2), X(0x7e70416e), X(0x7e73ecac), X(0x7e7791b0), - X(0x7e7b3082), X(0x7e7ec927), X(0x7e825ba6), X(0x7e85e804), - X(0x7e896e48), X(0x7e8cee77), X(0x7e906899), X(0x7e93dcb2), - X(0x7e974aca), X(0x7e9ab2e5), X(0x7e9e150b), X(0x7ea17141), - X(0x7ea4c78e), X(0x7ea817f7), X(0x7eab6283), X(0x7eaea737), - X(0x7eb1e61a), X(0x7eb51f33), X(0x7eb85285), X(0x7ebb8019), - X(0x7ebea7f4), X(0x7ec1ca1d), X(0x7ec4e698), X(0x7ec7fd6d), - X(0x7ecb0ea1), X(0x7ece1a3a), X(0x7ed1203f), X(0x7ed420b6), - X(0x7ed71ba4), X(0x7eda110f), X(0x7edd00ff), X(0x7edfeb78), - X(0x7ee2d081), X(0x7ee5b01f), X(0x7ee88a5a), X(0x7eeb5f36), - X(0x7eee2eba), X(0x7ef0f8ed), X(0x7ef3bdd3), X(0x7ef67d73), - X(0x7ef937d3), X(0x7efbecf9), X(0x7efe9ceb), X(0x7f0147ae), - X(0x7f03ed4a), X(0x7f068dc4), X(0x7f092922), X(0x7f0bbf69), - X(0x7f0e50a1), X(0x7f10dcce), X(0x7f1363f7), X(0x7f15e622), - X(0x7f186355), X(0x7f1adb95), X(0x7f1d4ee9), X(0x7f1fbd57), - X(0x7f2226e4), X(0x7f248b96), X(0x7f26eb74), X(0x7f294683), - X(0x7f2b9cc9), X(0x7f2dee4d), X(0x7f303b13), X(0x7f328322), - X(0x7f34c680), X(0x7f370533), X(0x7f393f40), X(0x7f3b74ad), - X(0x7f3da581), X(0x7f3fd1c1), X(0x7f41f972), X(0x7f441c9c), - X(0x7f463b43), X(0x7f48556d), X(0x7f4a6b21), X(0x7f4c7c64), - X(0x7f4e893c), X(0x7f5091ae), X(0x7f5295c1), X(0x7f54957a), - X(0x7f5690e0), X(0x7f5887f7), X(0x7f5a7ac5), X(0x7f5c6951), - X(0x7f5e53a0), X(0x7f6039b8), X(0x7f621b9e), X(0x7f63f958), - X(0x7f65d2ed), X(0x7f67a861), X(0x7f6979ba), X(0x7f6b46ff), - X(0x7f6d1034), X(0x7f6ed560), X(0x7f709687), X(0x7f7253b1), - X(0x7f740ce1), X(0x7f75c21f), X(0x7f777370), X(0x7f7920d8), - X(0x7f7aca5f), X(0x7f7c7008), X(0x7f7e11db), X(0x7f7fafdd), - X(0x7f814a13), X(0x7f82e082), X(0x7f847331), X(0x7f860224), - X(0x7f878d62), X(0x7f8914f0), X(0x7f8a98d4), X(0x7f8c1912), - X(0x7f8d95b0), X(0x7f8f0eb5), X(0x7f908425), X(0x7f91f605), - X(0x7f93645c), X(0x7f94cf2f), X(0x7f963683), X(0x7f979a5d), - X(0x7f98fac4), X(0x7f9a57bb), X(0x7f9bb14a), X(0x7f9d0775), - X(0x7f9e5a41), X(0x7f9fa9b4), X(0x7fa0f5d3), X(0x7fa23ea4), - X(0x7fa3842b), X(0x7fa4c66f), X(0x7fa60575), X(0x7fa74141), - X(0x7fa879d9), X(0x7fa9af42), X(0x7faae182), X(0x7fac109e), - X(0x7fad3c9a), X(0x7fae657d), X(0x7faf8b4c), X(0x7fb0ae0b), - X(0x7fb1cdc0), X(0x7fb2ea70), X(0x7fb40420), X(0x7fb51ad5), - X(0x7fb62e95), X(0x7fb73f64), X(0x7fb84d48), X(0x7fb95846), - X(0x7fba6062), X(0x7fbb65a2), X(0x7fbc680c), X(0x7fbd67a3), - X(0x7fbe646d), X(0x7fbf5e70), X(0x7fc055af), X(0x7fc14a31), - X(0x7fc23bf9), X(0x7fc32b0d), X(0x7fc41773), X(0x7fc5012e), - X(0x7fc5e844), X(0x7fc6ccba), X(0x7fc7ae94), X(0x7fc88dd8), - X(0x7fc96a8a), X(0x7fca44af), X(0x7fcb1c4c), X(0x7fcbf167), - X(0x7fccc403), X(0x7fcd9425), X(0x7fce61d3), X(0x7fcf2d11), - X(0x7fcff5e3), X(0x7fd0bc4f), X(0x7fd1805a), X(0x7fd24207), - X(0x7fd3015c), X(0x7fd3be5d), X(0x7fd47910), X(0x7fd53178), - X(0x7fd5e79b), X(0x7fd69b7c), X(0x7fd74d21), X(0x7fd7fc8e), - X(0x7fd8a9c8), X(0x7fd954d4), X(0x7fd9fdb5), X(0x7fdaa471), - X(0x7fdb490b), X(0x7fdbeb89), X(0x7fdc8bef), X(0x7fdd2a42), - X(0x7fddc685), X(0x7fde60be), X(0x7fdef8f0), X(0x7fdf8f20), - X(0x7fe02353), X(0x7fe0b58d), X(0x7fe145d3), X(0x7fe1d428), - X(0x7fe26091), X(0x7fe2eb12), X(0x7fe373b0), X(0x7fe3fa6f), - X(0x7fe47f53), X(0x7fe50260), X(0x7fe5839b), X(0x7fe60308), - X(0x7fe680ab), X(0x7fe6fc88), X(0x7fe776a4), X(0x7fe7ef02), - X(0x7fe865a7), X(0x7fe8da97), X(0x7fe94dd6), X(0x7fe9bf68), - X(0x7fea2f51), X(0x7fea9d95), X(0x7feb0a39), X(0x7feb7540), - X(0x7febdeae), X(0x7fec4687), X(0x7fecaccf), X(0x7fed118b), - X(0x7fed74be), X(0x7fedd66c), X(0x7fee3698), X(0x7fee9548), - X(0x7feef27e), X(0x7fef4e3f), X(0x7fefa88e), X(0x7ff0016f), - X(0x7ff058e7), X(0x7ff0aef8), X(0x7ff103a6), X(0x7ff156f6), - X(0x7ff1a8eb), X(0x7ff1f988), X(0x7ff248d2), X(0x7ff296cc), - X(0x7ff2e37a), X(0x7ff32edf), X(0x7ff378ff), X(0x7ff3c1de), - X(0x7ff4097e), X(0x7ff44fe5), X(0x7ff49515), X(0x7ff4d911), - X(0x7ff51bde), X(0x7ff55d7f), X(0x7ff59df7), X(0x7ff5dd4a), - X(0x7ff61b7b), X(0x7ff6588d), X(0x7ff69485), X(0x7ff6cf65), - X(0x7ff70930), X(0x7ff741eb), X(0x7ff77998), X(0x7ff7b03b), - X(0x7ff7e5d7), X(0x7ff81a6f), X(0x7ff84e06), X(0x7ff880a1), - X(0x7ff8b241), X(0x7ff8e2ea), X(0x7ff912a0), X(0x7ff94165), - X(0x7ff96f3d), X(0x7ff99c2b), X(0x7ff9c831), X(0x7ff9f354), - X(0x7ffa1d95), X(0x7ffa46f9), X(0x7ffa6f81), X(0x7ffa9731), - X(0x7ffabe0d), X(0x7ffae416), X(0x7ffb0951), X(0x7ffb2dbf), - X(0x7ffb5164), X(0x7ffb7442), X(0x7ffb965d), X(0x7ffbb7b8), - X(0x7ffbd854), X(0x7ffbf836), X(0x7ffc175f), X(0x7ffc35d3), - X(0x7ffc5394), X(0x7ffc70a5), X(0x7ffc8d09), X(0x7ffca8c2), - X(0x7ffcc3d4), X(0x7ffcde3f), X(0x7ffcf809), X(0x7ffd1132), - X(0x7ffd29be), X(0x7ffd41ae), X(0x7ffd5907), X(0x7ffd6fc9), - X(0x7ffd85f9), X(0x7ffd9b97), X(0x7ffdb0a7), X(0x7ffdc52b), - X(0x7ffdd926), X(0x7ffdec99), X(0x7ffdff88), X(0x7ffe11f4), - X(0x7ffe23e0), X(0x7ffe354f), X(0x7ffe4642), X(0x7ffe56bc), - X(0x7ffe66bf), X(0x7ffe764e), X(0x7ffe856a), X(0x7ffe9416), - X(0x7ffea254), X(0x7ffeb026), X(0x7ffebd8e), X(0x7ffeca8f), - X(0x7ffed72a), X(0x7ffee362), X(0x7ffeef38), X(0x7ffefaaf), - X(0x7fff05c9), X(0x7fff1087), X(0x7fff1aec), X(0x7fff24f9), - X(0x7fff2eb1), X(0x7fff3816), X(0x7fff4128), X(0x7fff49eb), - X(0x7fff5260), X(0x7fff5a88), X(0x7fff6266), X(0x7fff69fc), - X(0x7fff714b), X(0x7fff7854), X(0x7fff7f1a), X(0x7fff859f), - X(0x7fff8be3), X(0x7fff91ea), X(0x7fff97b3), X(0x7fff9d41), - X(0x7fffa296), X(0x7fffa7b3), X(0x7fffac99), X(0x7fffb14b), - X(0x7fffb5c9), X(0x7fffba15), X(0x7fffbe31), X(0x7fffc21d), - X(0x7fffc5dc), X(0x7fffc96f), X(0x7fffccd8), X(0x7fffd016), - X(0x7fffd32d), X(0x7fffd61c), X(0x7fffd8e7), X(0x7fffdb8d), - X(0x7fffde0f), X(0x7fffe071), X(0x7fffe2b1), X(0x7fffe4d2), - X(0x7fffe6d5), X(0x7fffe8bb), X(0x7fffea85), X(0x7fffec34), - X(0x7fffedc9), X(0x7fffef45), X(0x7ffff0aa), X(0x7ffff1f7), - X(0x7ffff330), X(0x7ffff453), X(0x7ffff562), X(0x7ffff65f), - X(0x7ffff749), X(0x7ffff823), X(0x7ffff8ec), X(0x7ffff9a6), - X(0x7ffffa51), X(0x7ffffaee), X(0x7ffffb7e), X(0x7ffffc02), - X(0x7ffffc7a), X(0x7ffffce7), X(0x7ffffd4a), X(0x7ffffda3), - X(0x7ffffdf4), X(0x7ffffe3c), X(0x7ffffe7c), X(0x7ffffeb6), - X(0x7ffffee8), X(0x7fffff15), X(0x7fffff3c), X(0x7fffff5e), - X(0x7fffff7b), X(0x7fffff95), X(0x7fffffaa), X(0x7fffffbc), - X(0x7fffffcb), X(0x7fffffd7), X(0x7fffffe2), X(0x7fffffea), - X(0x7ffffff0), X(0x7ffffff5), X(0x7ffffff9), X(0x7ffffffb), - X(0x7ffffffd), X(0x7ffffffe), X(0x7fffffff), X(0x7fffffff), - X(0x7fffffff), X(0x7fffffff), X(0x7fffffff), X(0x7fffffff), -}; - -static LOOKUP_T vwin8192[4096] = { - X(0x0000007c), X(0x0000045c), X(0x00000c1d), X(0x000017bd), - X(0x0000273e), X(0x00003a9f), X(0x000051e0), X(0x00006d02), - X(0x00008c03), X(0x0000aee5), X(0x0000d5a7), X(0x00010049), - X(0x00012ecb), X(0x0001612d), X(0x00019770), X(0x0001d193), - X(0x00020f96), X(0x00025178), X(0x0002973c), X(0x0002e0df), - X(0x00032e62), X(0x00037fc5), X(0x0003d509), X(0x00042e2c), - X(0x00048b30), X(0x0004ec13), X(0x000550d7), X(0x0005b97a), - X(0x000625fe), X(0x00069661), X(0x00070aa4), X(0x000782c8), - X(0x0007fecb), X(0x00087eae), X(0x00090271), X(0x00098a14), - X(0x000a1597), X(0x000aa4f9), X(0x000b383b), X(0x000bcf5d), - X(0x000c6a5f), X(0x000d0941), X(0x000dac02), X(0x000e52a3), - X(0x000efd23), X(0x000fab84), X(0x00105dc3), X(0x001113e3), - X(0x0011cde2), X(0x00128bc0), X(0x00134d7e), X(0x0014131b), - X(0x0014dc98), X(0x0015a9f4), X(0x00167b30), X(0x0017504a), - X(0x00182945), X(0x0019061e), X(0x0019e6d7), X(0x001acb6f), - X(0x001bb3e6), X(0x001ca03c), X(0x001d9071), X(0x001e8485), - X(0x001f7c79), X(0x0020784b), X(0x002177fc), X(0x00227b8c), - X(0x002382fb), X(0x00248e49), X(0x00259d76), X(0x0026b081), - X(0x0027c76b), X(0x0028e234), X(0x002a00dc), X(0x002b2361), - X(0x002c49c6), X(0x002d7409), X(0x002ea22a), X(0x002fd42a), - X(0x00310a08), X(0x003243c5), X(0x00338160), X(0x0034c2d9), - X(0x00360830), X(0x00375165), X(0x00389e78), X(0x0039ef6a), - X(0x003b4439), X(0x003c9ce6), X(0x003df971), X(0x003f59da), - X(0x0040be20), X(0x00422645), X(0x00439247), X(0x00450226), - X(0x004675e3), X(0x0047ed7e), X(0x004968f5), X(0x004ae84b), - X(0x004c6b7d), X(0x004df28d), X(0x004f7d7a), X(0x00510c44), - X(0x00529eeb), X(0x00543570), X(0x0055cfd1), X(0x00576e0f), - X(0x00591029), X(0x005ab621), X(0x005c5ff5), X(0x005e0da6), - X(0x005fbf33), X(0x0061749d), X(0x00632de4), X(0x0064eb06), - X(0x0066ac05), X(0x006870e0), X(0x006a3998), X(0x006c062b), - X(0x006dd69b), X(0x006faae6), X(0x0071830d), X(0x00735f10), - X(0x00753eef), X(0x007722a9), X(0x00790a3f), X(0x007af5b1), - X(0x007ce4fe), X(0x007ed826), X(0x0080cf29), X(0x0082ca08), - X(0x0084c8c2), X(0x0086cb57), X(0x0088d1c7), X(0x008adc11), - X(0x008cea37), X(0x008efc37), X(0x00911212), X(0x00932bc7), - X(0x00954957), X(0x00976ac2), X(0x00999006), X(0x009bb925), - X(0x009de61e), X(0x00a016f1), X(0x00a24b9e), X(0x00a48425), - X(0x00a6c086), X(0x00a900c0), X(0x00ab44d4), X(0x00ad8cc2), - X(0x00afd889), X(0x00b22829), X(0x00b47ba2), X(0x00b6d2f5), - X(0x00b92e21), X(0x00bb8d26), X(0x00bdf004), X(0x00c056ba), - X(0x00c2c149), X(0x00c52fb1), X(0x00c7a1f1), X(0x00ca180a), - X(0x00cc91fb), X(0x00cf0fc5), X(0x00d19166), X(0x00d416df), - X(0x00d6a031), X(0x00d92d5a), X(0x00dbbe5b), X(0x00de5333), - X(0x00e0ebe3), X(0x00e3886b), X(0x00e628c9), X(0x00e8ccff), - X(0x00eb750c), X(0x00ee20f0), X(0x00f0d0ab), X(0x00f3843d), - X(0x00f63ba5), X(0x00f8f6e4), X(0x00fbb5fa), X(0x00fe78e5), - X(0x01013fa7), X(0x01040a3f), X(0x0106d8ae), X(0x0109aaf2), - X(0x010c810c), X(0x010f5afb), X(0x011238c0), X(0x01151a5b), - X(0x0117ffcb), X(0x011ae910), X(0x011dd62a), X(0x0120c719), - X(0x0123bbdd), X(0x0126b476), X(0x0129b0e4), X(0x012cb126), - X(0x012fb53c), X(0x0132bd27), X(0x0135c8e6), X(0x0138d879), - X(0x013bebdf), X(0x013f031a), X(0x01421e28), X(0x01453d0a), - X(0x01485fbf), X(0x014b8648), X(0x014eb0a4), X(0x0151ded2), - X(0x015510d4), X(0x015846a8), X(0x015b8050), X(0x015ebdc9), - X(0x0161ff15), X(0x01654434), X(0x01688d24), X(0x016bd9e6), - X(0x016f2a7b), X(0x01727ee1), X(0x0175d718), X(0x01793321), - X(0x017c92fc), X(0x017ff6a7), X(0x01835e24), X(0x0186c972), - X(0x018a3890), X(0x018dab7f), X(0x0191223f), X(0x01949ccf), - X(0x01981b2f), X(0x019b9d5f), X(0x019f235f), X(0x01a2ad2f), - X(0x01a63acf), X(0x01a9cc3e), X(0x01ad617c), X(0x01b0fa8a), - X(0x01b49767), X(0x01b83813), X(0x01bbdc8d), X(0x01bf84d6), - X(0x01c330ee), X(0x01c6e0d4), X(0x01ca9488), X(0x01ce4c0b), - X(0x01d2075b), X(0x01d5c679), X(0x01d98964), X(0x01dd501d), - X(0x01e11aa3), X(0x01e4e8f6), X(0x01e8bb17), X(0x01ec9104), - X(0x01f06abd), X(0x01f44844), X(0x01f82996), X(0x01fc0eb5), - X(0x01fff7a0), X(0x0203e456), X(0x0207d4d9), X(0x020bc926), - X(0x020fc140), X(0x0213bd24), X(0x0217bcd4), X(0x021bc04e), - X(0x021fc793), X(0x0223d2a3), X(0x0227e17d), X(0x022bf421), - X(0x02300a90), X(0x023424c8), X(0x023842ca), X(0x023c6495), - X(0x02408a2a), X(0x0244b389), X(0x0248e0b0), X(0x024d11a0), - X(0x02514659), X(0x02557eda), X(0x0259bb24), X(0x025dfb35), - X(0x02623f0f), X(0x026686b1), X(0x026ad21a), X(0x026f214b), - X(0x02737443), X(0x0277cb02), X(0x027c2588), X(0x028083d5), - X(0x0284e5e9), X(0x02894bc2), X(0x028db562), X(0x029222c8), - X(0x029693f4), X(0x029b08e6), X(0x029f819d), X(0x02a3fe19), - X(0x02a87e5b), X(0x02ad0261), X(0x02b18a2c), X(0x02b615bb), - X(0x02baa50f), X(0x02bf3827), X(0x02c3cf03), X(0x02c869a3), - X(0x02cd0807), X(0x02d1aa2d), X(0x02d65017), X(0x02daf9c4), - X(0x02dfa734), X(0x02e45866), X(0x02e90d5b), X(0x02edc612), - X(0x02f2828b), X(0x02f742c6), X(0x02fc06c3), X(0x0300ce80), - X(0x030599ff), X(0x030a6940), X(0x030f3c40), X(0x03141302), - X(0x0318ed84), X(0x031dcbc6), X(0x0322adc8), X(0x0327938a), - X(0x032c7d0c), X(0x03316a4c), X(0x03365b4d), X(0x033b500c), - X(0x03404889), X(0x034544c6), X(0x034a44c0), X(0x034f4879), - X(0x03544ff0), X(0x03595b24), X(0x035e6a16), X(0x03637cc5), - X(0x03689331), X(0x036dad5a), X(0x0372cb40), X(0x0377ece2), - X(0x037d1240), X(0x03823b5a), X(0x03876830), X(0x038c98c1), - X(0x0391cd0e), X(0x03970516), X(0x039c40d8), X(0x03a18055), - X(0x03a6c38d), X(0x03ac0a7f), X(0x03b1552b), X(0x03b6a390), - X(0x03bbf5af), X(0x03c14b88), X(0x03c6a519), X(0x03cc0263), - X(0x03d16366), X(0x03d6c821), X(0x03dc3094), X(0x03e19cc0), - X(0x03e70ca2), X(0x03ec803d), X(0x03f1f78e), X(0x03f77296), - X(0x03fcf155), X(0x040273cb), X(0x0407f9f7), X(0x040d83d9), - X(0x04131170), X(0x0418a2bd), X(0x041e37c0), X(0x0423d077), - X(0x04296ce4), X(0x042f0d04), X(0x0434b0da), X(0x043a5863), - X(0x044003a0), X(0x0445b290), X(0x044b6534), X(0x04511b8b), - X(0x0456d595), X(0x045c9352), X(0x046254c1), X(0x046819e1), - X(0x046de2b4), X(0x0473af39), X(0x04797f6e), X(0x047f5355), - X(0x04852aec), X(0x048b0635), X(0x0490e52d), X(0x0496c7d6), - X(0x049cae2e), X(0x04a29836), X(0x04a885ed), X(0x04ae7753), - X(0x04b46c68), X(0x04ba652b), X(0x04c0619d), X(0x04c661bc), - X(0x04cc658a), X(0x04d26d04), X(0x04d8782c), X(0x04de8701), - X(0x04e49983), X(0x04eaafb0), X(0x04f0c98a), X(0x04f6e710), - X(0x04fd0842), X(0x05032d1e), X(0x050955a6), X(0x050f81d8), - X(0x0515b1b5), X(0x051be53d), X(0x05221c6e), X(0x05285748), - X(0x052e95cd), X(0x0534d7fa), X(0x053b1dd0), X(0x0541674e), - X(0x0547b475), X(0x054e0544), X(0x055459bb), X(0x055ab1d9), - X(0x05610d9e), X(0x05676d0a), X(0x056dd01c), X(0x057436d5), - X(0x057aa134), X(0x05810f38), X(0x058780e2), X(0x058df631), - X(0x05946f25), X(0x059aebbe), X(0x05a16bfa), X(0x05a7efdb), - X(0x05ae775f), X(0x05b50287), X(0x05bb9152), X(0x05c223c0), - X(0x05c8b9d0), X(0x05cf5382), X(0x05d5f0d6), X(0x05dc91cc), - X(0x05e33663), X(0x05e9de9c), X(0x05f08a75), X(0x05f739ee), - X(0x05fded07), X(0x0604a3c0), X(0x060b5e19), X(0x06121c11), - X(0x0618dda8), X(0x061fa2dd), X(0x06266bb1), X(0x062d3822), - X(0x06340831), X(0x063adbde), X(0x0641b328), X(0x06488e0e), - X(0x064f6c91), X(0x06564eaf), X(0x065d346a), X(0x06641dc0), - X(0x066b0ab1), X(0x0671fb3d), X(0x0678ef64), X(0x067fe724), - X(0x0686e27f), X(0x068de173), X(0x0694e400), X(0x069bea27), - X(0x06a2f3e6), X(0x06aa013d), X(0x06b1122c), X(0x06b826b3), - X(0x06bf3ed1), X(0x06c65a86), X(0x06cd79d1), X(0x06d49cb3), - X(0x06dbc32b), X(0x06e2ed38), X(0x06ea1adb), X(0x06f14c13), - X(0x06f880df), X(0x06ffb940), X(0x0706f535), X(0x070e34bd), - X(0x071577d9), X(0x071cbe88), X(0x072408c9), X(0x072b569d), - X(0x0732a802), X(0x0739fcf9), X(0x07415582), X(0x0748b19b), - X(0x07501145), X(0x0757747f), X(0x075edb49), X(0x076645a3), - X(0x076db38c), X(0x07752503), X(0x077c9a09), X(0x0784129e), - X(0x078b8ec0), X(0x07930e70), X(0x079a91ac), X(0x07a21876), - X(0x07a9a2cc), X(0x07b130ad), X(0x07b8c21b), X(0x07c05714), - X(0x07c7ef98), X(0x07cf8ba6), X(0x07d72b3f), X(0x07dece62), - X(0x07e6750e), X(0x07ee1f43), X(0x07f5cd01), X(0x07fd7e48), - X(0x08053316), X(0x080ceb6d), X(0x0814a74a), X(0x081c66af), - X(0x0824299a), X(0x082bf00c), X(0x0833ba03), X(0x083b8780), - X(0x08435882), X(0x084b2d09), X(0x08530514), X(0x085ae0a3), - X(0x0862bfb6), X(0x086aa24c), X(0x08728865), X(0x087a7201), - X(0x08825f1e), X(0x088a4fbe), X(0x089243de), X(0x089a3b80), - X(0x08a236a2), X(0x08aa3545), X(0x08b23767), X(0x08ba3d09), - X(0x08c2462a), X(0x08ca52c9), X(0x08d262e7), X(0x08da7682), - X(0x08e28d9c), X(0x08eaa832), X(0x08f2c645), X(0x08fae7d4), - X(0x09030cdf), X(0x090b3566), X(0x09136168), X(0x091b90e5), - X(0x0923c3dc), X(0x092bfa4d), X(0x09343437), X(0x093c719b), - X(0x0944b277), X(0x094cf6cc), X(0x09553e99), X(0x095d89dd), - X(0x0965d899), X(0x096e2acb), X(0x09768073), X(0x097ed991), - X(0x09873625), X(0x098f962e), X(0x0997f9ac), X(0x09a0609e), - X(0x09a8cb04), X(0x09b138dd), X(0x09b9aa29), X(0x09c21ee8), - X(0x09ca9719), X(0x09d312bc), X(0x09db91d0), X(0x09e41456), - X(0x09ec9a4b), X(0x09f523b1), X(0x09fdb087), X(0x0a0640cc), - X(0x0a0ed47f), X(0x0a176ba2), X(0x0a200632), X(0x0a28a42f), - X(0x0a31459a), X(0x0a39ea72), X(0x0a4292b5), X(0x0a4b3e65), - X(0x0a53ed80), X(0x0a5ca006), X(0x0a6555f7), X(0x0a6e0f51), - X(0x0a76cc16), X(0x0a7f8c44), X(0x0a884fda), X(0x0a9116d9), - X(0x0a99e140), X(0x0aa2af0e), X(0x0aab8043), X(0x0ab454df), - X(0x0abd2ce1), X(0x0ac60849), X(0x0acee716), X(0x0ad7c948), - X(0x0ae0aedf), X(0x0ae997d9), X(0x0af28437), X(0x0afb73f7), - X(0x0b04671b), X(0x0b0d5da0), X(0x0b165788), X(0x0b1f54d0), - X(0x0b285579), X(0x0b315983), X(0x0b3a60ec), X(0x0b436bb5), - X(0x0b4c79dd), X(0x0b558b63), X(0x0b5ea048), X(0x0b67b88a), - X(0x0b70d429), X(0x0b79f324), X(0x0b83157c), X(0x0b8c3b30), - X(0x0b95643f), X(0x0b9e90a8), X(0x0ba7c06c), X(0x0bb0f38a), - X(0x0bba2a01), X(0x0bc363d1), X(0x0bcca0f9), X(0x0bd5e17a), - X(0x0bdf2552), X(0x0be86c81), X(0x0bf1b706), X(0x0bfb04e2), - X(0x0c045613), X(0x0c0daa99), X(0x0c170274), X(0x0c205da3), - X(0x0c29bc25), X(0x0c331dfb), X(0x0c3c8323), X(0x0c45eb9e), - X(0x0c4f576a), X(0x0c58c688), X(0x0c6238f6), X(0x0c6baeb5), - X(0x0c7527c3), X(0x0c7ea421), X(0x0c8823cd), X(0x0c91a6c8), - X(0x0c9b2d10), X(0x0ca4b6a6), X(0x0cae4389), X(0x0cb7d3b8), - X(0x0cc16732), X(0x0ccafdf8), X(0x0cd49809), X(0x0cde3564), - X(0x0ce7d609), X(0x0cf179f7), X(0x0cfb212e), X(0x0d04cbad), - X(0x0d0e7974), X(0x0d182a83), X(0x0d21ded8), X(0x0d2b9673), - X(0x0d355154), X(0x0d3f0f7b), X(0x0d48d0e6), X(0x0d529595), - X(0x0d5c5d88), X(0x0d6628be), X(0x0d6ff737), X(0x0d79c8f2), - X(0x0d839dee), X(0x0d8d762c), X(0x0d9751aa), X(0x0da13068), - X(0x0dab1266), X(0x0db4f7a3), X(0x0dbee01e), X(0x0dc8cbd8), - X(0x0dd2bace), X(0x0ddcad02), X(0x0de6a272), X(0x0df09b1e), - X(0x0dfa9705), X(0x0e049627), X(0x0e0e9883), X(0x0e189e19), - X(0x0e22a6e8), X(0x0e2cb2f0), X(0x0e36c230), X(0x0e40d4a8), - X(0x0e4aea56), X(0x0e55033b), X(0x0e5f1f56), X(0x0e693ea7), - X(0x0e73612c), X(0x0e7d86e5), X(0x0e87afd3), X(0x0e91dbf3), - X(0x0e9c0b47), X(0x0ea63dcc), X(0x0eb07383), X(0x0ebaac6b), - X(0x0ec4e883), X(0x0ecf27cc), X(0x0ed96a44), X(0x0ee3afea), - X(0x0eedf8bf), X(0x0ef844c2), X(0x0f0293f2), X(0x0f0ce64e), - X(0x0f173bd6), X(0x0f21948a), X(0x0f2bf069), X(0x0f364f72), - X(0x0f40b1a5), X(0x0f4b1701), X(0x0f557f86), X(0x0f5feb32), - X(0x0f6a5a07), X(0x0f74cc02), X(0x0f7f4124), X(0x0f89b96b), - X(0x0f9434d8), X(0x0f9eb369), X(0x0fa9351e), X(0x0fb3b9f7), - X(0x0fbe41f3), X(0x0fc8cd11), X(0x0fd35b51), X(0x0fddecb2), - X(0x0fe88134), X(0x0ff318d6), X(0x0ffdb397), X(0x10085177), - X(0x1012f275), X(0x101d9691), X(0x10283dca), X(0x1032e81f), - X(0x103d9591), X(0x1048461e), X(0x1052f9c5), X(0x105db087), - X(0x10686a62), X(0x10732756), X(0x107de763), X(0x1088aa87), - X(0x109370c2), X(0x109e3a14), X(0x10a9067c), X(0x10b3d5f9), - X(0x10bea88b), X(0x10c97e31), X(0x10d456eb), X(0x10df32b8), - X(0x10ea1197), X(0x10f4f387), X(0x10ffd889), X(0x110ac09b), - X(0x1115abbe), X(0x112099ef), X(0x112b8b2f), X(0x11367f7d), - X(0x114176d9), X(0x114c7141), X(0x11576eb6), X(0x11626f36), - X(0x116d72c1), X(0x11787957), X(0x118382f6), X(0x118e8f9e), - X(0x11999f4f), X(0x11a4b208), X(0x11afc7c7), X(0x11bae08e), - X(0x11c5fc5a), X(0x11d11b2c), X(0x11dc3d02), X(0x11e761dd), - X(0x11f289ba), X(0x11fdb49b), X(0x1208e27e), X(0x12141362), - X(0x121f4748), X(0x122a7e2d), X(0x1235b812), X(0x1240f4f6), - X(0x124c34d9), X(0x125777b9), X(0x1262bd96), X(0x126e0670), - X(0x12795245), X(0x1284a115), X(0x128ff2e0), X(0x129b47a5), - X(0x12a69f63), X(0x12b1fa19), X(0x12bd57c7), X(0x12c8b86c), - X(0x12d41c08), X(0x12df829a), X(0x12eaec21), X(0x12f6589d), - X(0x1301c80c), X(0x130d3a6f), X(0x1318afc4), X(0x1324280b), - X(0x132fa344), X(0x133b216d), X(0x1346a286), X(0x1352268e), - X(0x135dad85), X(0x1369376a), X(0x1374c43c), X(0x138053fb), - X(0x138be6a5), X(0x13977c3b), X(0x13a314bc), X(0x13aeb026), - X(0x13ba4e79), X(0x13c5efb5), X(0x13d193d9), X(0x13dd3ae4), - X(0x13e8e4d6), X(0x13f491ad), X(0x1400416a), X(0x140bf40b), - X(0x1417a98f), X(0x142361f7), X(0x142f1d41), X(0x143adb6d), - X(0x14469c7a), X(0x14526067), X(0x145e2734), X(0x1469f0df), - X(0x1475bd69), X(0x14818cd0), X(0x148d5f15), X(0x14993435), - X(0x14a50c31), X(0x14b0e708), X(0x14bcc4b8), X(0x14c8a542), - X(0x14d488a5), X(0x14e06edf), X(0x14ec57f1), X(0x14f843d9), - X(0x15043297), X(0x1510242b), X(0x151c1892), X(0x15280fcd), - X(0x153409dc), X(0x154006bc), X(0x154c066e), X(0x155808f1), - X(0x15640e44), X(0x15701666), X(0x157c2157), X(0x15882f16), - X(0x15943fa2), X(0x15a052fb), X(0x15ac691f), X(0x15b8820f), - X(0x15c49dc8), X(0x15d0bc4c), X(0x15dcdd98), X(0x15e901ad), - X(0x15f52888), X(0x1601522b), X(0x160d7e93), X(0x1619adc1), - X(0x1625dfb3), X(0x16321469), X(0x163e4be2), X(0x164a861d), - X(0x1656c31a), X(0x166302d8), X(0x166f4555), X(0x167b8a92), - X(0x1687d28e), X(0x16941d47), X(0x16a06abe), X(0x16acbaf0), - X(0x16b90ddf), X(0x16c56388), X(0x16d1bbeb), X(0x16de1708), - X(0x16ea74dd), X(0x16f6d56a), X(0x170338ae), X(0x170f9ea8), - X(0x171c0758), X(0x172872bd), X(0x1734e0d6), X(0x174151a2), - X(0x174dc520), X(0x175a3b51), X(0x1766b432), X(0x17732fc4), - X(0x177fae05), X(0x178c2ef4), X(0x1798b292), X(0x17a538dd), - X(0x17b1c1d4), X(0x17be4d77), X(0x17cadbc5), X(0x17d76cbc), - X(0x17e4005e), X(0x17f096a7), X(0x17fd2f98), X(0x1809cb31), - X(0x1816696f), X(0x18230a53), X(0x182faddc), X(0x183c5408), - X(0x1848fcd8), X(0x1855a849), X(0x1862565d), X(0x186f0711), - X(0x187bba64), X(0x18887057), X(0x189528e9), X(0x18a1e418), - X(0x18aea1e3), X(0x18bb624b), X(0x18c8254e), X(0x18d4eaeb), - X(0x18e1b321), X(0x18ee7df1), X(0x18fb4b58), X(0x19081b57), - X(0x1914edec), X(0x1921c317), X(0x192e9ad6), X(0x193b7529), - X(0x19485210), X(0x19553189), X(0x19621393), X(0x196ef82e), - X(0x197bdf59), X(0x1988c913), X(0x1995b55c), X(0x19a2a432), - X(0x19af9595), X(0x19bc8983), X(0x19c97ffd), X(0x19d67900), - X(0x19e3748e), X(0x19f072a3), X(0x19fd7341), X(0x1a0a7665), - X(0x1a177c10), X(0x1a248440), X(0x1a318ef4), X(0x1a3e9c2c), - X(0x1a4babe7), X(0x1a58be24), X(0x1a65d2e2), X(0x1a72ea20), - X(0x1a8003de), X(0x1a8d201a), X(0x1a9a3ed5), X(0x1aa7600c), - X(0x1ab483bf), X(0x1ac1a9ee), X(0x1aced297), X(0x1adbfdba), - X(0x1ae92b56), X(0x1af65b69), X(0x1b038df4), X(0x1b10c2f5), - X(0x1b1dfa6b), X(0x1b2b3456), X(0x1b3870b5), X(0x1b45af87), - X(0x1b52f0ca), X(0x1b60347f), X(0x1b6d7aa4), X(0x1b7ac339), - X(0x1b880e3c), X(0x1b955bad), X(0x1ba2ab8b), X(0x1baffdd5), - X(0x1bbd528a), X(0x1bcaa9a9), X(0x1bd80332), X(0x1be55f24), - X(0x1bf2bd7d), X(0x1c001e3d), X(0x1c0d8164), X(0x1c1ae6ef), - X(0x1c284edf), X(0x1c35b932), X(0x1c4325e7), X(0x1c5094fe), - X(0x1c5e0677), X(0x1c6b7a4f), X(0x1c78f086), X(0x1c86691b), - X(0x1c93e40d), X(0x1ca1615c), X(0x1caee107), X(0x1cbc630c), - X(0x1cc9e76b), X(0x1cd76e23), X(0x1ce4f733), X(0x1cf2829a), - X(0x1d001057), X(0x1d0da06a), X(0x1d1b32d1), X(0x1d28c78c), - X(0x1d365e9a), X(0x1d43f7f9), X(0x1d5193a9), X(0x1d5f31aa), - X(0x1d6cd1f9), X(0x1d7a7497), X(0x1d881982), X(0x1d95c0ba), - X(0x1da36a3d), X(0x1db1160a), X(0x1dbec422), X(0x1dcc7482), - X(0x1dda272b), X(0x1de7dc1a), X(0x1df59350), X(0x1e034ccb), - X(0x1e11088a), X(0x1e1ec68c), X(0x1e2c86d1), X(0x1e3a4958), - X(0x1e480e20), X(0x1e55d527), X(0x1e639e6d), X(0x1e7169f1), - X(0x1e7f37b2), X(0x1e8d07b0), X(0x1e9ad9e8), X(0x1ea8ae5b), - X(0x1eb68507), X(0x1ec45dec), X(0x1ed23908), X(0x1ee0165b), - X(0x1eedf5e4), X(0x1efbd7a1), X(0x1f09bb92), X(0x1f17a1b6), - X(0x1f258a0d), X(0x1f337494), X(0x1f41614b), X(0x1f4f5032), - X(0x1f5d4147), X(0x1f6b3489), X(0x1f7929f7), X(0x1f872192), - X(0x1f951b56), X(0x1fa31744), X(0x1fb1155b), X(0x1fbf159a), - X(0x1fcd17ff), X(0x1fdb1c8b), X(0x1fe9233b), X(0x1ff72c0f), - X(0x20053706), X(0x20134420), X(0x2021535a), X(0x202f64b4), - X(0x203d782e), X(0x204b8dc6), X(0x2059a57c), X(0x2067bf4e), - X(0x2075db3b), X(0x2083f943), X(0x20921964), X(0x20a03b9e), - X(0x20ae5fef), X(0x20bc8657), X(0x20caaed5), X(0x20d8d967), - X(0x20e7060e), X(0x20f534c7), X(0x21036592), X(0x2111986e), - X(0x211fcd59), X(0x212e0454), X(0x213c3d5d), X(0x214a7873), - X(0x2158b594), X(0x2166f4c1), X(0x217535f8), X(0x21837938), - X(0x2191be81), X(0x21a005d0), X(0x21ae4f26), X(0x21bc9a81), - X(0x21cae7e0), X(0x21d93743), X(0x21e788a8), X(0x21f5dc0e), - X(0x22043174), X(0x221288da), X(0x2220e23e), X(0x222f3da0), - X(0x223d9afe), X(0x224bfa58), X(0x225a5bac), X(0x2268bef9), - X(0x2277243f), X(0x22858b7d), X(0x2293f4b0), X(0x22a25fda), - X(0x22b0ccf8), X(0x22bf3c09), X(0x22cdad0d), X(0x22dc2002), - X(0x22ea94e8), X(0x22f90bbe), X(0x23078482), X(0x2315ff33), - X(0x23247bd1), X(0x2332fa5b), X(0x23417acf), X(0x234ffd2c), - X(0x235e8173), X(0x236d07a0), X(0x237b8fb4), X(0x238a19ae), - X(0x2398a58c), X(0x23a7334d), X(0x23b5c2f1), X(0x23c45477), - X(0x23d2e7dd), X(0x23e17d22), X(0x23f01446), X(0x23fead47), - X(0x240d4825), X(0x241be4dd), X(0x242a8371), X(0x243923dd), - X(0x2447c622), X(0x24566a3e), X(0x24651031), X(0x2473b7f8), - X(0x24826194), X(0x24910d03), X(0x249fba44), X(0x24ae6957), - X(0x24bd1a39), X(0x24cbccea), X(0x24da816a), X(0x24e937b7), - X(0x24f7efcf), X(0x2506a9b3), X(0x25156560), X(0x252422d6), - X(0x2532e215), X(0x2541a31a), X(0x255065e4), X(0x255f2a74), - X(0x256df0c7), X(0x257cb8dd), X(0x258b82b4), X(0x259a4e4c), - X(0x25a91ba4), X(0x25b7eaba), X(0x25c6bb8e), X(0x25d58e1e), - X(0x25e46269), X(0x25f3386e), X(0x2602102d), X(0x2610e9a4), - X(0x261fc4d3), X(0x262ea1b7), X(0x263d8050), X(0x264c609e), - X(0x265b429e), X(0x266a2650), X(0x26790bb3), X(0x2687f2c6), - X(0x2696db88), X(0x26a5c5f7), X(0x26b4b213), X(0x26c39fda), - X(0x26d28f4c), X(0x26e18067), X(0x26f0732b), X(0x26ff6796), - X(0x270e5da7), X(0x271d555d), X(0x272c4eb7), X(0x273b49b5), - X(0x274a4654), X(0x27594495), X(0x27684475), X(0x277745f4), - X(0x27864910), X(0x27954dc9), X(0x27a4541e), X(0x27b35c0d), - X(0x27c26596), X(0x27d170b7), X(0x27e07d6f), X(0x27ef8bbd), - X(0x27fe9ba0), X(0x280dad18), X(0x281cc022), X(0x282bd4be), - X(0x283aeaeb), X(0x284a02a7), X(0x28591bf2), X(0x286836cb), - X(0x28775330), X(0x28867120), X(0x2895909b), X(0x28a4b19e), - X(0x28b3d42a), X(0x28c2f83d), X(0x28d21dd5), X(0x28e144f3), - X(0x28f06d94), X(0x28ff97b8), X(0x290ec35d), X(0x291df082), - X(0x292d1f27), X(0x293c4f4a), X(0x294b80eb), X(0x295ab407), - X(0x2969e89e), X(0x29791eaf), X(0x29885639), X(0x29978f3b), - X(0x29a6c9b3), X(0x29b605a0), X(0x29c54302), X(0x29d481d7), - X(0x29e3c21e), X(0x29f303d6), X(0x2a0246fd), X(0x2a118b94), - X(0x2a20d198), X(0x2a301909), X(0x2a3f61e6), X(0x2a4eac2c), - X(0x2a5df7dc), X(0x2a6d44f4), X(0x2a7c9374), X(0x2a8be359), - X(0x2a9b34a2), X(0x2aaa8750), X(0x2ab9db60), X(0x2ac930d1), - X(0x2ad887a3), X(0x2ae7dfd3), X(0x2af73962), X(0x2b06944e), - X(0x2b15f096), X(0x2b254e38), X(0x2b34ad34), X(0x2b440d89), - X(0x2b536f34), X(0x2b62d236), X(0x2b72368d), X(0x2b819c38), - X(0x2b910336), X(0x2ba06b86), X(0x2bafd526), X(0x2bbf4015), - X(0x2bceac53), X(0x2bde19de), X(0x2bed88b5), X(0x2bfcf8d7), - X(0x2c0c6a43), X(0x2c1bdcf7), X(0x2c2b50f3), X(0x2c3ac635), - X(0x2c4a3cbd), X(0x2c59b488), X(0x2c692d97), X(0x2c78a7e7), - X(0x2c882378), X(0x2c97a049), X(0x2ca71e58), X(0x2cb69da4), - X(0x2cc61e2c), X(0x2cd59ff0), X(0x2ce522ed), X(0x2cf4a723), - X(0x2d042c90), X(0x2d13b334), X(0x2d233b0d), X(0x2d32c41a), - X(0x2d424e5a), X(0x2d51d9cc), X(0x2d61666e), X(0x2d70f440), - X(0x2d808340), X(0x2d90136e), X(0x2d9fa4c7), X(0x2daf374c), - X(0x2dbecafa), X(0x2dce5fd1), X(0x2dddf5cf), X(0x2ded8cf4), - X(0x2dfd253d), X(0x2e0cbeab), X(0x2e1c593b), X(0x2e2bf4ed), - X(0x2e3b91c0), X(0x2e4b2fb1), X(0x2e5acec1), X(0x2e6a6eee), - X(0x2e7a1037), X(0x2e89b29b), X(0x2e995618), X(0x2ea8faad), - X(0x2eb8a05a), X(0x2ec8471c), X(0x2ed7eef4), X(0x2ee797df), - X(0x2ef741dc), X(0x2f06eceb), X(0x2f16990a), X(0x2f264639), - X(0x2f35f475), X(0x2f45a3bd), X(0x2f555412), X(0x2f650570), - X(0x2f74b7d8), X(0x2f846b48), X(0x2f941fbe), X(0x2fa3d53a), - X(0x2fb38bbb), X(0x2fc3433f), X(0x2fd2fbc5), X(0x2fe2b54c), - X(0x2ff26fd3), X(0x30022b58), X(0x3011e7db), X(0x3021a55a), - X(0x303163d4), X(0x30412348), X(0x3050e3b5), X(0x3060a519), - X(0x30706773), X(0x30802ac3), X(0x308fef06), X(0x309fb43d), - X(0x30af7a65), X(0x30bf417d), X(0x30cf0985), X(0x30ded27a), - X(0x30ee9c5d), X(0x30fe672b), X(0x310e32e3), X(0x311dff85), - X(0x312dcd0f), X(0x313d9b80), X(0x314d6ad7), X(0x315d3b12), - X(0x316d0c30), X(0x317cde31), X(0x318cb113), X(0x319c84d4), - X(0x31ac5974), X(0x31bc2ef1), X(0x31cc054b), X(0x31dbdc7f), - X(0x31ebb48e), X(0x31fb8d74), X(0x320b6733), X(0x321b41c7), - X(0x322b1d31), X(0x323af96e), X(0x324ad67e), X(0x325ab45f), - X(0x326a9311), X(0x327a7291), X(0x328a52e0), X(0x329a33fb), - X(0x32aa15e1), X(0x32b9f892), X(0x32c9dc0c), X(0x32d9c04d), - X(0x32e9a555), X(0x32f98b22), X(0x330971b4), X(0x33195909), - X(0x3329411f), X(0x333929f6), X(0x3349138c), X(0x3358fde1), - X(0x3368e8f2), X(0x3378d4c0), X(0x3388c147), X(0x3398ae89), - X(0x33a89c82), X(0x33b88b32), X(0x33c87a98), X(0x33d86ab2), - X(0x33e85b80), X(0x33f84d00), X(0x34083f30), X(0x34183210), - X(0x3428259f), X(0x343819db), X(0x34480ec3), X(0x34580455), - X(0x3467fa92), X(0x3477f176), X(0x3487e902), X(0x3497e134), - X(0x34a7da0a), X(0x34b7d384), X(0x34c7cda0), X(0x34d7c85e), - X(0x34e7c3bb), X(0x34f7bfb7), X(0x3507bc50), X(0x3517b985), - X(0x3527b756), X(0x3537b5c0), X(0x3547b4c3), X(0x3557b45d), - X(0x3567b48d), X(0x3577b552), X(0x3587b6aa), X(0x3597b895), - X(0x35a7bb12), X(0x35b7be1e), X(0x35c7c1b9), X(0x35d7c5e1), - X(0x35e7ca96), X(0x35f7cfd6), X(0x3607d5a0), X(0x3617dbf3), - X(0x3627e2cd), X(0x3637ea2d), X(0x3647f212), X(0x3657fa7b), - X(0x36680366), X(0x36780cd2), X(0x368816bf), X(0x3698212b), - X(0x36a82c14), X(0x36b83779), X(0x36c8435a), X(0x36d84fb4), - X(0x36e85c88), X(0x36f869d2), X(0x37087793), X(0x371885c9), - X(0x37289473), X(0x3738a38f), X(0x3748b31d), X(0x3758c31a), - X(0x3768d387), X(0x3778e461), X(0x3788f5a7), X(0x37990759), - X(0x37a91975), X(0x37b92bf9), X(0x37c93ee4), X(0x37d95236), - X(0x37e965ed), X(0x37f97a08), X(0x38098e85), X(0x3819a363), - X(0x3829b8a2), X(0x3839ce3f), X(0x3849e43a), X(0x3859fa91), - X(0x386a1143), X(0x387a284f), X(0x388a3fb4), X(0x389a5770), - X(0x38aa6f83), X(0x38ba87ea), X(0x38caa0a5), X(0x38dab9b2), - X(0x38ead311), X(0x38faecbf), X(0x390b06bc), X(0x391b2107), - X(0x392b3b9e), X(0x393b5680), X(0x394b71ac), X(0x395b8d20), - X(0x396ba8dc), X(0x397bc4dd), X(0x398be124), X(0x399bfdae), - X(0x39ac1a7a), X(0x39bc3788), X(0x39cc54d5), X(0x39dc7261), - X(0x39ec902a), X(0x39fcae2f), X(0x3a0ccc70), X(0x3a1ceaea), - X(0x3a2d099c), X(0x3a3d2885), X(0x3a4d47a5), X(0x3a5d66f9), - X(0x3a6d8680), X(0x3a7da63a), X(0x3a8dc625), X(0x3a9de63f), - X(0x3aae0688), X(0x3abe26fe), X(0x3ace47a0), X(0x3ade686d), - X(0x3aee8963), X(0x3afeaa82), X(0x3b0ecbc7), X(0x3b1eed32), - X(0x3b2f0ec2), X(0x3b3f3075), X(0x3b4f524a), X(0x3b5f7440), - X(0x3b6f9656), X(0x3b7fb889), X(0x3b8fdada), X(0x3b9ffd46), - X(0x3bb01fce), X(0x3bc0426e), X(0x3bd06526), X(0x3be087f6), - X(0x3bf0aada), X(0x3c00cdd4), X(0x3c10f0e0), X(0x3c2113fe), - X(0x3c31372d), X(0x3c415a6b), X(0x3c517db7), X(0x3c61a110), - X(0x3c71c475), X(0x3c81e7e4), X(0x3c920b5c), X(0x3ca22edc), - X(0x3cb25262), X(0x3cc275ee), X(0x3cd2997e), X(0x3ce2bd11), - X(0x3cf2e0a6), X(0x3d03043b), X(0x3d1327cf), X(0x3d234b61), - X(0x3d336ef0), X(0x3d43927a), X(0x3d53b5ff), X(0x3d63d97c), - X(0x3d73fcf1), X(0x3d84205c), X(0x3d9443bd), X(0x3da46711), - X(0x3db48a58), X(0x3dc4ad91), X(0x3dd4d0ba), X(0x3de4f3d1), - X(0x3df516d7), X(0x3e0539c9), X(0x3e155ca6), X(0x3e257f6d), - X(0x3e35a21d), X(0x3e45c4b4), X(0x3e55e731), X(0x3e660994), - X(0x3e762bda), X(0x3e864e03), X(0x3e96700d), X(0x3ea691f7), - X(0x3eb6b3bf), X(0x3ec6d565), X(0x3ed6f6e8), X(0x3ee71845), - X(0x3ef7397c), X(0x3f075a8c), X(0x3f177b73), X(0x3f279c30), - X(0x3f37bcc2), X(0x3f47dd27), X(0x3f57fd5f), X(0x3f681d68), - X(0x3f783d40), X(0x3f885ce7), X(0x3f987c5c), X(0x3fa89b9c), - X(0x3fb8baa7), X(0x3fc8d97c), X(0x3fd8f819), X(0x3fe9167e), - X(0x3ff934a8), X(0x40095296), X(0x40197049), X(0x40298dbd), - X(0x4039aaf2), X(0x4049c7e7), X(0x4059e49a), X(0x406a010a), - X(0x407a1d36), X(0x408a391d), X(0x409a54bd), X(0x40aa7015), - X(0x40ba8b25), X(0x40caa5ea), X(0x40dac063), X(0x40eada90), - X(0x40faf46e), X(0x410b0dfe), X(0x411b273d), X(0x412b402a), - X(0x413b58c4), X(0x414b710a), X(0x415b88fa), X(0x416ba093), - X(0x417bb7d5), X(0x418bcebe), X(0x419be54c), X(0x41abfb7e), - X(0x41bc1153), X(0x41cc26ca), X(0x41dc3be2), X(0x41ec5099), - X(0x41fc64ef), X(0x420c78e1), X(0x421c8c6f), X(0x422c9f97), - X(0x423cb258), X(0x424cc4b2), X(0x425cd6a2), X(0x426ce827), - X(0x427cf941), X(0x428d09ee), X(0x429d1a2c), X(0x42ad29fb), - X(0x42bd3959), X(0x42cd4846), X(0x42dd56bf), X(0x42ed64c3), - X(0x42fd7252), X(0x430d7f6a), X(0x431d8c0a), X(0x432d9831), - X(0x433da3dd), X(0x434daf0d), X(0x435db9c0), X(0x436dc3f5), - X(0x437dcdab), X(0x438dd6df), X(0x439ddf92), X(0x43ade7c1), - X(0x43bdef6c), X(0x43cdf691), X(0x43ddfd2f), X(0x43ee0345), - X(0x43fe08d2), X(0x440e0dd4), X(0x441e124b), X(0x442e1634), - X(0x443e198f), X(0x444e1c5a), X(0x445e1e95), X(0x446e203e), - X(0x447e2153), X(0x448e21d5), X(0x449e21c0), X(0x44ae2115), - X(0x44be1fd1), X(0x44ce1df4), X(0x44de1b7d), X(0x44ee186a), - X(0x44fe14ba), X(0x450e106b), X(0x451e0b7e), X(0x452e05ef), - X(0x453dffbf), X(0x454df8eb), X(0x455df173), X(0x456de956), - X(0x457de092), X(0x458dd726), X(0x459dcd10), X(0x45adc251), - X(0x45bdb6e5), X(0x45cdaacd), X(0x45dd9e06), X(0x45ed9091), - X(0x45fd826a), X(0x460d7392), X(0x461d6407), X(0x462d53c8), - X(0x463d42d4), X(0x464d3129), X(0x465d1ec6), X(0x466d0baa), - X(0x467cf7d3), X(0x468ce342), X(0x469ccdf3), X(0x46acb7e7), - X(0x46bca11c), X(0x46cc8990), X(0x46dc7143), X(0x46ec5833), - X(0x46fc3e5f), X(0x470c23c6), X(0x471c0867), X(0x472bec40), - X(0x473bcf50), X(0x474bb196), X(0x475b9311), X(0x476b73c0), - X(0x477b53a1), X(0x478b32b4), X(0x479b10f6), X(0x47aaee67), - X(0x47bacb06), X(0x47caa6d1), X(0x47da81c7), X(0x47ea5be7), - X(0x47fa3530), X(0x480a0da1), X(0x4819e537), X(0x4829bbf3), - X(0x483991d3), X(0x484966d6), X(0x48593afb), X(0x48690e3f), - X(0x4878e0a3), X(0x4888b225), X(0x489882c4), X(0x48a8527e), - X(0x48b82153), X(0x48c7ef41), X(0x48d7bc47), X(0x48e78863), - X(0x48f75396), X(0x49071ddc), X(0x4916e736), X(0x4926afa2), - X(0x4936771f), X(0x49463dac), X(0x49560347), X(0x4965c7ef), - X(0x49758ba4), X(0x49854e63), X(0x4995102c), X(0x49a4d0fe), - X(0x49b490d7), X(0x49c44fb6), X(0x49d40d9a), X(0x49e3ca82), - X(0x49f3866c), X(0x4a034159), X(0x4a12fb45), X(0x4a22b430), - X(0x4a326c19), X(0x4a4222ff), X(0x4a51d8e1), X(0x4a618dbd), - X(0x4a714192), X(0x4a80f45f), X(0x4a90a623), X(0x4aa056dd), - X(0x4ab0068b), X(0x4abfb52c), X(0x4acf62c0), X(0x4adf0f44), - X(0x4aeebab9), X(0x4afe651c), X(0x4b0e0e6c), X(0x4b1db6a9), - X(0x4b2d5dd1), X(0x4b3d03e2), X(0x4b4ca8dd), X(0x4b5c4cbf), - X(0x4b6bef88), X(0x4b7b9136), X(0x4b8b31c8), X(0x4b9ad13d), - X(0x4baa6f93), X(0x4bba0ccb), X(0x4bc9a8e2), X(0x4bd943d7), - X(0x4be8dda9), X(0x4bf87658), X(0x4c080de1), X(0x4c17a444), - X(0x4c27397f), X(0x4c36cd92), X(0x4c46607b), X(0x4c55f239), - X(0x4c6582cb), X(0x4c75122f), X(0x4c84a065), X(0x4c942d6c), - X(0x4ca3b942), X(0x4cb343e6), X(0x4cc2cd57), X(0x4cd25594), - X(0x4ce1dc9c), X(0x4cf1626d), X(0x4d00e707), X(0x4d106a68), - X(0x4d1fec8f), X(0x4d2f6d7a), X(0x4d3eed2a), X(0x4d4e6b9d), - X(0x4d5de8d1), X(0x4d6d64c5), X(0x4d7cdf79), X(0x4d8c58eb), - X(0x4d9bd11a), X(0x4dab4804), X(0x4dbabdaa), X(0x4dca3209), - X(0x4dd9a520), X(0x4de916ef), X(0x4df88774), X(0x4e07f6ae), - X(0x4e17649c), X(0x4e26d13c), X(0x4e363c8f), X(0x4e45a692), - X(0x4e550f44), X(0x4e6476a4), X(0x4e73dcb2), X(0x4e83416c), - X(0x4e92a4d1), X(0x4ea206df), X(0x4eb16796), X(0x4ec0c6f5), - X(0x4ed024fa), X(0x4edf81a5), X(0x4eeedcf3), X(0x4efe36e5), - X(0x4f0d8f79), X(0x4f1ce6ad), X(0x4f2c3c82), X(0x4f3b90f4), - X(0x4f4ae405), X(0x4f5a35b1), X(0x4f6985fa), X(0x4f78d4dc), - X(0x4f882257), X(0x4f976e6a), X(0x4fa6b914), X(0x4fb60254), - X(0x4fc54a28), X(0x4fd49090), X(0x4fe3d58b), X(0x4ff31917), - X(0x50025b33), X(0x50119bde), X(0x5020db17), X(0x503018dd), - X(0x503f552f), X(0x504e900b), X(0x505dc971), X(0x506d0160), - X(0x507c37d7), X(0x508b6cd3), X(0x509aa055), X(0x50a9d25b), - X(0x50b902e4), X(0x50c831ef), X(0x50d75f7b), X(0x50e68b87), - X(0x50f5b612), X(0x5104df1a), X(0x5114069f), X(0x51232ca0), - X(0x5132511a), X(0x5141740f), X(0x5150957b), X(0x515fb55f), - X(0x516ed3b8), X(0x517df087), X(0x518d0bca), X(0x519c257f), - X(0x51ab3da7), X(0x51ba543f), X(0x51c96947), X(0x51d87cbd), - X(0x51e78ea1), X(0x51f69ef1), X(0x5205adad), X(0x5214bad3), - X(0x5223c662), X(0x5232d05a), X(0x5241d8b9), X(0x5250df7d), - X(0x525fe4a7), X(0x526ee835), X(0x527dea26), X(0x528cea78), - X(0x529be92c), X(0x52aae63f), X(0x52b9e1b0), X(0x52c8db80), - X(0x52d7d3ac), X(0x52e6ca33), X(0x52f5bf15), X(0x5304b251), - X(0x5313a3e5), X(0x532293d0), X(0x53318212), X(0x53406ea8), - X(0x534f5993), X(0x535e42d2), X(0x536d2a62), X(0x537c1043), - X(0x538af475), X(0x5399d6f6), X(0x53a8b7c4), X(0x53b796e0), - X(0x53c67447), X(0x53d54ffa), X(0x53e429f6), X(0x53f3023b), - X(0x5401d8c8), X(0x5410ad9c), X(0x541f80b5), X(0x542e5213), - X(0x543d21b5), X(0x544bef9a), X(0x545abbc0), X(0x54698627), - X(0x54784ece), X(0x548715b3), X(0x5495dad6), X(0x54a49e35), - X(0x54b35fd0), X(0x54c21fa6), X(0x54d0ddb5), X(0x54df99fd), - X(0x54ee547c), X(0x54fd0d32), X(0x550bc41d), X(0x551a793d), - X(0x55292c91), X(0x5537de16), X(0x55468dce), X(0x55553bb6), - X(0x5563e7cd), X(0x55729213), X(0x55813a87), X(0x558fe127), - X(0x559e85f2), X(0x55ad28e9), X(0x55bbca08), X(0x55ca6950), - X(0x55d906c0), X(0x55e7a257), X(0x55f63c13), X(0x5604d3f4), - X(0x561369f8), X(0x5621fe1f), X(0x56309067), X(0x563f20d1), - X(0x564daf5a), X(0x565c3c02), X(0x566ac6c7), X(0x56794faa), - X(0x5687d6a8), X(0x56965bc1), X(0x56a4def4), X(0x56b36040), - X(0x56c1dfa4), X(0x56d05d1f), X(0x56ded8af), X(0x56ed5255), - X(0x56fbca0f), X(0x570a3fdc), X(0x5718b3bc), X(0x572725ac), - X(0x573595ad), X(0x574403bd), X(0x57526fdb), X(0x5760da07), - X(0x576f423f), X(0x577da883), X(0x578c0cd1), X(0x579a6f29), - X(0x57a8cf8a), X(0x57b72df2), X(0x57c58a61), X(0x57d3e4d6), - X(0x57e23d50), X(0x57f093cd), X(0x57fee84e), X(0x580d3ad1), - X(0x581b8b54), X(0x5829d9d8), X(0x5838265c), X(0x584670dd), - X(0x5854b95c), X(0x5862ffd8), X(0x5871444f), X(0x587f86c1), - X(0x588dc72c), X(0x589c0591), X(0x58aa41ed), X(0x58b87c40), - X(0x58c6b489), X(0x58d4eac7), X(0x58e31ef9), X(0x58f1511f), - X(0x58ff8137), X(0x590daf40), X(0x591bdb3a), X(0x592a0524), - X(0x59382cfc), X(0x594652c2), X(0x59547675), X(0x59629815), - X(0x5970b79f), X(0x597ed513), X(0x598cf071), X(0x599b09b7), - X(0x59a920e5), X(0x59b735f9), X(0x59c548f4), X(0x59d359d2), - X(0x59e16895), X(0x59ef753b), X(0x59fd7fc4), X(0x5a0b882d), - X(0x5a198e77), X(0x5a2792a0), X(0x5a3594a9), X(0x5a43948e), - X(0x5a519251), X(0x5a5f8df0), X(0x5a6d876a), X(0x5a7b7ebe), - X(0x5a8973ec), X(0x5a9766f2), X(0x5aa557d0), X(0x5ab34685), - X(0x5ac1330f), X(0x5acf1d6f), X(0x5add05a3), X(0x5aeaebaa), - X(0x5af8cf84), X(0x5b06b12f), X(0x5b1490ab), X(0x5b226df7), - X(0x5b304912), X(0x5b3e21fc), X(0x5b4bf8b2), X(0x5b59cd35), - X(0x5b679f84), X(0x5b756f9e), X(0x5b833d82), X(0x5b91092e), - X(0x5b9ed2a3), X(0x5bac99e0), X(0x5bba5ee3), X(0x5bc821ac), - X(0x5bd5e23a), X(0x5be3a08c), X(0x5bf15ca1), X(0x5bff1679), - X(0x5c0cce12), X(0x5c1a836c), X(0x5c283686), X(0x5c35e760), - X(0x5c4395f7), X(0x5c51424c), X(0x5c5eec5e), X(0x5c6c942b), - X(0x5c7a39b4), X(0x5c87dcf7), X(0x5c957df3), X(0x5ca31ca8), - X(0x5cb0b915), X(0x5cbe5338), X(0x5ccbeb12), X(0x5cd980a1), - X(0x5ce713e5), X(0x5cf4a4dd), X(0x5d023387), X(0x5d0fbfe4), - X(0x5d1d49f2), X(0x5d2ad1b1), X(0x5d38571f), X(0x5d45da3c), - X(0x5d535b08), X(0x5d60d981), X(0x5d6e55a7), X(0x5d7bcf78), - X(0x5d8946f5), X(0x5d96bc1c), X(0x5da42eec), X(0x5db19f65), - X(0x5dbf0d86), X(0x5dcc794e), X(0x5dd9e2bd), X(0x5de749d1), - X(0x5df4ae8a), X(0x5e0210e7), X(0x5e0f70e7), X(0x5e1cce8a), - X(0x5e2a29ce), X(0x5e3782b4), X(0x5e44d93a), X(0x5e522d5f), - X(0x5e5f7f23), X(0x5e6cce85), X(0x5e7a1b85), X(0x5e876620), - X(0x5e94ae58), X(0x5ea1f42a), X(0x5eaf3797), X(0x5ebc789d), - X(0x5ec9b73c), X(0x5ed6f372), X(0x5ee42d41), X(0x5ef164a5), - X(0x5efe999f), X(0x5f0bcc2f), X(0x5f18fc52), X(0x5f262a09), - X(0x5f335553), X(0x5f407e2f), X(0x5f4da49d), X(0x5f5ac89b), - X(0x5f67ea29), X(0x5f750946), X(0x5f8225f2), X(0x5f8f402b), - X(0x5f9c57f2), X(0x5fa96d44), X(0x5fb68023), X(0x5fc3908c), - X(0x5fd09e7f), X(0x5fdda9fc), X(0x5feab302), X(0x5ff7b990), - X(0x6004bda5), X(0x6011bf40), X(0x601ebe62), X(0x602bbb09), - X(0x6038b534), X(0x6045ace4), X(0x6052a216), X(0x605f94cb), - X(0x606c8502), X(0x607972b9), X(0x60865df2), X(0x609346aa), - X(0x60a02ce1), X(0x60ad1096), X(0x60b9f1c9), X(0x60c6d079), - X(0x60d3aca5), X(0x60e0864d), X(0x60ed5d70), X(0x60fa320d), - X(0x61070424), X(0x6113d3b4), X(0x6120a0bc), X(0x612d6b3c), - X(0x613a3332), X(0x6146f89f), X(0x6153bb82), X(0x61607bd9), - X(0x616d39a5), X(0x6179f4e5), X(0x6186ad98), X(0x619363bd), - X(0x61a01753), X(0x61acc85b), X(0x61b976d3), X(0x61c622bc), - X(0x61d2cc13), X(0x61df72d8), X(0x61ec170c), X(0x61f8b8ad), - X(0x620557ba), X(0x6211f434), X(0x621e8e18), X(0x622b2568), - X(0x6237ba21), X(0x62444c44), X(0x6250dbd0), X(0x625d68c4), - X(0x6269f320), X(0x62767ae2), X(0x6283000b), X(0x628f829a), - X(0x629c028e), X(0x62a87fe6), X(0x62b4faa2), X(0x62c172c2), - X(0x62cde844), X(0x62da5b29), X(0x62e6cb6e), X(0x62f33915), - X(0x62ffa41c), X(0x630c0c83), X(0x63187248), X(0x6324d56d), - X(0x633135ef), X(0x633d93ce), X(0x6349ef0b), X(0x635647a3), - X(0x63629d97), X(0x636ef0e6), X(0x637b418f), X(0x63878f92), - X(0x6393daef), X(0x63a023a4), X(0x63ac69b1), X(0x63b8ad15), - X(0x63c4edd1), X(0x63d12be3), X(0x63dd674b), X(0x63e9a008), - X(0x63f5d61a), X(0x64020980), X(0x640e3a39), X(0x641a6846), - X(0x642693a5), X(0x6432bc56), X(0x643ee258), X(0x644b05ab), - X(0x6457264e), X(0x64634441), X(0x646f5f83), X(0x647b7814), - X(0x64878df3), X(0x6493a120), X(0x649fb199), X(0x64abbf5f), - X(0x64b7ca71), X(0x64c3d2ce), X(0x64cfd877), X(0x64dbdb69), - X(0x64e7dba6), X(0x64f3d92b), X(0x64ffd3fa), X(0x650bcc11), - X(0x6517c16f), X(0x6523b415), X(0x652fa402), X(0x653b9134), - X(0x65477bad), X(0x6553636a), X(0x655f486d), X(0x656b2ab3), - X(0x65770a3d), X(0x6582e70a), X(0x658ec11a), X(0x659a986d), - X(0x65a66d00), X(0x65b23ed5), X(0x65be0deb), X(0x65c9da41), - X(0x65d5a3d7), X(0x65e16aac), X(0x65ed2ebf), X(0x65f8f011), - X(0x6604aea1), X(0x66106a6e), X(0x661c2377), X(0x6627d9be), - X(0x66338d40), X(0x663f3dfd), X(0x664aebf5), X(0x66569728), - X(0x66623f95), X(0x666de53b), X(0x6679881b), X(0x66852833), - X(0x6690c583), X(0x669c600b), X(0x66a7f7ca), X(0x66b38cc0), - X(0x66bf1eec), X(0x66caae4f), X(0x66d63ae6), X(0x66e1c4b3), - X(0x66ed4bb4), X(0x66f8cfea), X(0x67045153), X(0x670fcfef), - X(0x671b4bbe), X(0x6726c4bf), X(0x67323af3), X(0x673dae58), - X(0x67491eee), X(0x67548cb5), X(0x675ff7ab), X(0x676b5fd2), - X(0x6776c528), X(0x678227ad), X(0x678d8761), X(0x6798e443), - X(0x67a43e52), X(0x67af958f), X(0x67bae9f9), X(0x67c63b8f), - X(0x67d18a52), X(0x67dcd640), X(0x67e81f59), X(0x67f3659d), - X(0x67fea90c), X(0x6809e9a5), X(0x68152768), X(0x68206254), - X(0x682b9a68), X(0x6836cfa6), X(0x6842020b), X(0x684d3199), - X(0x68585e4d), X(0x68638829), X(0x686eaf2b), X(0x6879d354), - X(0x6884f4a2), X(0x68901316), X(0x689b2eb0), X(0x68a6476d), - X(0x68b15d50), X(0x68bc7056), X(0x68c78080), X(0x68d28dcd), - X(0x68dd983e), X(0x68e89fd0), X(0x68f3a486), X(0x68fea65d), - X(0x6909a555), X(0x6914a16f), X(0x691f9aa9), X(0x692a9104), - X(0x69358480), X(0x6940751b), X(0x694b62d5), X(0x69564daf), - X(0x696135a7), X(0x696c1abe), X(0x6976fcf3), X(0x6981dc46), - X(0x698cb8b6), X(0x69979243), X(0x69a268ed), X(0x69ad3cb4), - X(0x69b80d97), X(0x69c2db96), X(0x69cda6b0), X(0x69d86ee5), - X(0x69e33436), X(0x69edf6a1), X(0x69f8b626), X(0x6a0372c5), - X(0x6a0e2c7e), X(0x6a18e350), X(0x6a23973c), X(0x6a2e4840), - X(0x6a38f65d), X(0x6a43a191), X(0x6a4e49de), X(0x6a58ef42), - X(0x6a6391be), X(0x6a6e3151), X(0x6a78cdfa), X(0x6a8367ba), - X(0x6a8dfe90), X(0x6a98927c), X(0x6aa3237d), X(0x6aadb194), - X(0x6ab83cc0), X(0x6ac2c500), X(0x6acd4a55), X(0x6ad7ccbf), - X(0x6ae24c3c), X(0x6aecc8cd), X(0x6af74271), X(0x6b01b929), - X(0x6b0c2cf4), X(0x6b169dd1), X(0x6b210bc1), X(0x6b2b76c2), - X(0x6b35ded6), X(0x6b4043fc), X(0x6b4aa632), X(0x6b55057a), - X(0x6b5f61d3), X(0x6b69bb3d), X(0x6b7411b7), X(0x6b7e6541), - X(0x6b88b5db), X(0x6b930385), X(0x6b9d4e3f), X(0x6ba79607), - X(0x6bb1dadf), X(0x6bbc1cc6), X(0x6bc65bbb), X(0x6bd097bf), - X(0x6bdad0d0), X(0x6be506f0), X(0x6bef3a1d), X(0x6bf96a58), - X(0x6c0397a0), X(0x6c0dc1f5), X(0x6c17e957), X(0x6c220dc6), - X(0x6c2c2f41), X(0x6c364dc9), X(0x6c40695c), X(0x6c4a81fc), - X(0x6c5497a7), X(0x6c5eaa5d), X(0x6c68ba1f), X(0x6c72c6eb), - X(0x6c7cd0c3), X(0x6c86d7a6), X(0x6c90db92), X(0x6c9adc8a), - X(0x6ca4da8b), X(0x6caed596), X(0x6cb8cdab), X(0x6cc2c2ca), - X(0x6cccb4f2), X(0x6cd6a424), X(0x6ce0905e), X(0x6cea79a1), - X(0x6cf45fee), X(0x6cfe4342), X(0x6d0823a0), X(0x6d120105), - X(0x6d1bdb73), X(0x6d25b2e8), X(0x6d2f8765), X(0x6d3958ea), - X(0x6d432777), X(0x6d4cf30a), X(0x6d56bba5), X(0x6d608147), - X(0x6d6a43f0), X(0x6d7403a0), X(0x6d7dc056), X(0x6d877a13), - X(0x6d9130d6), X(0x6d9ae4a0), X(0x6da4956f), X(0x6dae4345), - X(0x6db7ee20), X(0x6dc19601), X(0x6dcb3ae7), X(0x6dd4dcd3), - X(0x6dde7bc4), X(0x6de817bb), X(0x6df1b0b6), X(0x6dfb46b7), - X(0x6e04d9bc), X(0x6e0e69c7), X(0x6e17f6d5), X(0x6e2180e9), - X(0x6e2b0801), X(0x6e348c1d), X(0x6e3e0d3d), X(0x6e478b62), - X(0x6e51068a), X(0x6e5a7eb7), X(0x6e63f3e7), X(0x6e6d661b), - X(0x6e76d552), X(0x6e80418e), X(0x6e89aacc), X(0x6e93110f), - X(0x6e9c7454), X(0x6ea5d49d), X(0x6eaf31e9), X(0x6eb88c37), - X(0x6ec1e389), X(0x6ecb37de), X(0x6ed48936), X(0x6eddd790), - X(0x6ee722ee), X(0x6ef06b4d), X(0x6ef9b0b0), X(0x6f02f315), - X(0x6f0c327c), X(0x6f156ee6), X(0x6f1ea852), X(0x6f27dec1), - X(0x6f311232), X(0x6f3a42a5), X(0x6f43701a), X(0x6f4c9a91), - X(0x6f55c20a), X(0x6f5ee686), X(0x6f680803), X(0x6f712682), - X(0x6f7a4203), X(0x6f835a86), X(0x6f8c700b), X(0x6f958291), - X(0x6f9e921a), X(0x6fa79ea4), X(0x6fb0a830), X(0x6fb9aebd), - X(0x6fc2b24c), X(0x6fcbb2dd), X(0x6fd4b06f), X(0x6fddab03), - X(0x6fe6a299), X(0x6fef9730), X(0x6ff888c9), X(0x70017763), - X(0x700a62ff), X(0x70134b9c), X(0x701c313b), X(0x702513dc), - X(0x702df37e), X(0x7036d021), X(0x703fa9c6), X(0x7048806d), - X(0x70515415), X(0x705a24bf), X(0x7062f26b), X(0x706bbd17), - X(0x707484c6), X(0x707d4976), X(0x70860b28), X(0x708ec9dc), - X(0x70978591), X(0x70a03e48), X(0x70a8f400), X(0x70b1a6bb), - X(0x70ba5677), X(0x70c30335), X(0x70cbacf5), X(0x70d453b6), - X(0x70dcf77a), X(0x70e59840), X(0x70ee3607), X(0x70f6d0d1), - X(0x70ff689d), X(0x7107fd6b), X(0x71108f3b), X(0x71191e0d), - X(0x7121a9e2), X(0x712a32b9), X(0x7132b892), X(0x713b3b6e), - X(0x7143bb4c), X(0x714c382d), X(0x7154b211), X(0x715d28f7), - X(0x71659ce0), X(0x716e0dcc), X(0x71767bbb), X(0x717ee6ac), - X(0x71874ea1), X(0x718fb399), X(0x71981594), X(0x71a07493), - X(0x71a8d094), X(0x71b1299a), X(0x71b97fa2), X(0x71c1d2af), - X(0x71ca22bf), X(0x71d26fd2), X(0x71dab9ea), X(0x71e30106), - X(0x71eb4526), X(0x71f3864a), X(0x71fbc472), X(0x7203ff9e), - X(0x720c37cf), X(0x72146d05), X(0x721c9f3f), X(0x7224ce7e), - X(0x722cfac2), X(0x7235240b), X(0x723d4a59), X(0x72456dad), - X(0x724d8e05), X(0x7255ab63), X(0x725dc5c7), X(0x7265dd31), - X(0x726df1a0), X(0x72760315), X(0x727e1191), X(0x72861d12), - X(0x728e259a), X(0x72962b28), X(0x729e2dbd), X(0x72a62d59), - X(0x72ae29fc), X(0x72b623a5), X(0x72be1a56), X(0x72c60e0e), - X(0x72cdfece), X(0x72d5ec95), X(0x72ddd764), X(0x72e5bf3b), - X(0x72eda41a), X(0x72f58601), X(0x72fd64f1), X(0x730540e9), - X(0x730d19e9), X(0x7314eff3), X(0x731cc305), X(0x73249321), - X(0x732c6046), X(0x73342a75), X(0x733bf1ad), X(0x7343b5ef), - X(0x734b773b), X(0x73533591), X(0x735af0f2), X(0x7362a95d), - X(0x736a5ed3), X(0x73721153), X(0x7379c0df), X(0x73816d76), - X(0x73891719), X(0x7390bdc7), X(0x73986181), X(0x73a00247), - X(0x73a7a01a), X(0x73af3af8), X(0x73b6d2e4), X(0x73be67dc), - X(0x73c5f9e1), X(0x73cd88f3), X(0x73d51513), X(0x73dc9e40), - X(0x73e4247c), X(0x73eba7c5), X(0x73f3281c), X(0x73faa582), - X(0x74021ff7), X(0x7409977b), X(0x74110c0d), X(0x74187daf), - X(0x741fec61), X(0x74275822), X(0x742ec0f3), X(0x743626d5), - X(0x743d89c7), X(0x7444e9c9), X(0x744c46dd), X(0x7453a101), - X(0x745af837), X(0x74624c7f), X(0x74699dd8), X(0x7470ec44), - X(0x747837c2), X(0x747f8052), X(0x7486c5f5), X(0x748e08ac), - X(0x74954875), X(0x749c8552), X(0x74a3bf43), X(0x74aaf648), - X(0x74b22a62), X(0x74b95b90), X(0x74c089d2), X(0x74c7b52a), - X(0x74cedd97), X(0x74d6031a), X(0x74dd25b2), X(0x74e44561), - X(0x74eb6226), X(0x74f27c02), X(0x74f992f5), X(0x7500a6ff), - X(0x7507b820), X(0x750ec659), X(0x7515d1aa), X(0x751cda14), - X(0x7523df96), X(0x752ae231), X(0x7531e1e5), X(0x7538deb2), - X(0x753fd89a), X(0x7546cf9b), X(0x754dc3b7), X(0x7554b4ed), - X(0x755ba33e), X(0x75628eaa), X(0x75697732), X(0x75705cd5), - X(0x75773f95), X(0x757e1f71), X(0x7584fc6a), X(0x758bd67f), - X(0x7592adb2), X(0x75998203), X(0x75a05371), X(0x75a721fe), - X(0x75adeda9), X(0x75b4b673), X(0x75bb7c5c), X(0x75c23f65), - X(0x75c8ff8d), X(0x75cfbcd6), X(0x75d6773f), X(0x75dd2ec8), - X(0x75e3e373), X(0x75ea953f), X(0x75f1442d), X(0x75f7f03d), - X(0x75fe996f), X(0x76053fc5), X(0x760be33d), X(0x761283d8), - X(0x76192197), X(0x761fbc7b), X(0x76265482), X(0x762ce9af), - X(0x76337c01), X(0x763a0b78), X(0x76409814), X(0x764721d7), - X(0x764da8c1), X(0x76542cd1), X(0x765aae08), X(0x76612c67), - X(0x7667a7ee), X(0x766e209d), X(0x76749675), X(0x767b0975), - X(0x7681799f), X(0x7687e6f3), X(0x768e5170), X(0x7694b918), - X(0x769b1deb), X(0x76a17fe9), X(0x76a7df13), X(0x76ae3b68), - X(0x76b494ea), X(0x76baeb98), X(0x76c13f74), X(0x76c7907c), - X(0x76cddeb3), X(0x76d42a18), X(0x76da72ab), X(0x76e0b86d), - X(0x76e6fb5e), X(0x76ed3b7f), X(0x76f378d0), X(0x76f9b352), - X(0x76ffeb05), X(0x77061fe8), X(0x770c51fe), X(0x77128145), - X(0x7718adbf), X(0x771ed76c), X(0x7724fe4c), X(0x772b225f), - X(0x773143a7), X(0x77376223), X(0x773d7dd3), X(0x774396ba), - X(0x7749acd5), X(0x774fc027), X(0x7755d0af), X(0x775bde6f), - X(0x7761e965), X(0x7767f193), X(0x776df6fa), X(0x7773f998), - X(0x7779f970), X(0x777ff681), X(0x7785f0cd), X(0x778be852), - X(0x7791dd12), X(0x7797cf0d), X(0x779dbe43), X(0x77a3aab6), - X(0x77a99465), X(0x77af7b50), X(0x77b55f79), X(0x77bb40e0), - X(0x77c11f85), X(0x77c6fb68), X(0x77ccd48a), X(0x77d2aaec), - X(0x77d87e8d), X(0x77de4f6f), X(0x77e41d92), X(0x77e9e8f5), - X(0x77efb19b), X(0x77f57782), X(0x77fb3aad), X(0x7800fb1a), - X(0x7806b8ca), X(0x780c73bf), X(0x78122bf7), X(0x7817e175), - X(0x781d9438), X(0x78234440), X(0x7828f18f), X(0x782e9c25), - X(0x78344401), X(0x7839e925), X(0x783f8b92), X(0x78452b46), - X(0x784ac844), X(0x7850628b), X(0x7855fa1c), X(0x785b8ef8), - X(0x7861211e), X(0x7866b090), X(0x786c3d4d), X(0x7871c757), - X(0x78774ead), X(0x787cd351), X(0x78825543), X(0x7887d483), - X(0x788d5111), X(0x7892caef), X(0x7898421c), X(0x789db69a), - X(0x78a32868), X(0x78a89787), X(0x78ae03f8), X(0x78b36dbb), - X(0x78b8d4d1), X(0x78be393a), X(0x78c39af6), X(0x78c8fa06), - X(0x78ce566c), X(0x78d3b026), X(0x78d90736), X(0x78de5b9c), - X(0x78e3ad58), X(0x78e8fc6c), X(0x78ee48d7), X(0x78f3929b), - X(0x78f8d9b7), X(0x78fe1e2c), X(0x79035ffb), X(0x79089f24), - X(0x790ddba8), X(0x79131587), X(0x79184cc2), X(0x791d8159), - X(0x7922b34d), X(0x7927e29e), X(0x792d0f4d), X(0x7932395a), - X(0x793760c6), X(0x793c8591), X(0x7941a7bd), X(0x7946c749), - X(0x794be435), X(0x7950fe84), X(0x79561634), X(0x795b2b47), - X(0x79603dbc), X(0x79654d96), X(0x796a5ad4), X(0x796f6576), - X(0x79746d7e), X(0x797972eb), X(0x797e75bf), X(0x798375f9), - X(0x7988739b), X(0x798d6ea5), X(0x79926717), X(0x79975cf2), - X(0x799c5037), X(0x79a140e6), X(0x79a62f00), X(0x79ab1a85), - X(0x79b00376), X(0x79b4e9d3), X(0x79b9cd9d), X(0x79beaed4), - X(0x79c38d79), X(0x79c8698d), X(0x79cd4310), X(0x79d21a03), - X(0x79d6ee66), X(0x79dbc03a), X(0x79e08f7f), X(0x79e55c36), - X(0x79ea265f), X(0x79eeedfc), X(0x79f3b30c), X(0x79f87590), - X(0x79fd3589), X(0x7a01f2f7), X(0x7a06addc), X(0x7a0b6636), - X(0x7a101c08), X(0x7a14cf52), X(0x7a198013), X(0x7a1e2e4d), - X(0x7a22da01), X(0x7a27832f), X(0x7a2c29d7), X(0x7a30cdfa), - X(0x7a356f99), X(0x7a3a0eb4), X(0x7a3eab4c), X(0x7a434561), - X(0x7a47dcf5), X(0x7a4c7207), X(0x7a510498), X(0x7a5594a9), - X(0x7a5a223a), X(0x7a5ead4d), X(0x7a6335e0), X(0x7a67bbf6), - X(0x7a6c3f8f), X(0x7a70c0ab), X(0x7a753f4b), X(0x7a79bb6f), - X(0x7a7e3519), X(0x7a82ac48), X(0x7a8720fe), X(0x7a8b933b), - X(0x7a9002ff), X(0x7a94704b), X(0x7a98db20), X(0x7a9d437e), - X(0x7aa1a967), X(0x7aa60cd9), X(0x7aaa6dd7), X(0x7aaecc61), - X(0x7ab32877), X(0x7ab7821b), X(0x7abbd94b), X(0x7ac02e0a), - X(0x7ac48058), X(0x7ac8d035), X(0x7acd1da3), X(0x7ad168a1), - X(0x7ad5b130), X(0x7ad9f751), X(0x7ade3b05), X(0x7ae27c4c), - X(0x7ae6bb27), X(0x7aeaf796), X(0x7aef319a), X(0x7af36934), - X(0x7af79e64), X(0x7afbd12c), X(0x7b00018a), X(0x7b042f81), - X(0x7b085b10), X(0x7b0c8439), X(0x7b10aafc), X(0x7b14cf5a), - X(0x7b18f153), X(0x7b1d10e8), X(0x7b212e1a), X(0x7b2548e9), - X(0x7b296155), X(0x7b2d7761), X(0x7b318b0b), X(0x7b359c55), - X(0x7b39ab3f), X(0x7b3db7cb), X(0x7b41c1f8), X(0x7b45c9c8), - X(0x7b49cf3b), X(0x7b4dd251), X(0x7b51d30b), X(0x7b55d16b), - X(0x7b59cd70), X(0x7b5dc71b), X(0x7b61be6d), X(0x7b65b366), - X(0x7b69a608), X(0x7b6d9653), X(0x7b718447), X(0x7b756fe5), - X(0x7b79592e), X(0x7b7d4022), X(0x7b8124c3), X(0x7b850710), - X(0x7b88e70a), X(0x7b8cc4b3), X(0x7b90a00a), X(0x7b947911), - X(0x7b984fc8), X(0x7b9c242f), X(0x7b9ff648), X(0x7ba3c612), - X(0x7ba79390), X(0x7bab5ec1), X(0x7baf27a5), X(0x7bb2ee3f), - X(0x7bb6b28e), X(0x7bba7493), X(0x7bbe344e), X(0x7bc1f1c1), - X(0x7bc5acec), X(0x7bc965cf), X(0x7bcd1c6c), X(0x7bd0d0c3), - X(0x7bd482d4), X(0x7bd832a1), X(0x7bdbe02a), X(0x7bdf8b70), - X(0x7be33473), X(0x7be6db34), X(0x7bea7fb4), X(0x7bee21f4), - X(0x7bf1c1f3), X(0x7bf55fb3), X(0x7bf8fb35), X(0x7bfc9479), - X(0x7c002b7f), X(0x7c03c04a), X(0x7c0752d8), X(0x7c0ae32b), - X(0x7c0e7144), X(0x7c11fd23), X(0x7c1586c9), X(0x7c190e36), - X(0x7c1c936c), X(0x7c20166b), X(0x7c239733), X(0x7c2715c6), - X(0x7c2a9224), X(0x7c2e0c4e), X(0x7c318444), X(0x7c34fa07), - X(0x7c386d98), X(0x7c3bdef8), X(0x7c3f4e26), X(0x7c42bb25), - X(0x7c4625f4), X(0x7c498e95), X(0x7c4cf507), X(0x7c50594c), - X(0x7c53bb65), X(0x7c571b51), X(0x7c5a7913), X(0x7c5dd4aa), - X(0x7c612e17), X(0x7c64855b), X(0x7c67da76), X(0x7c6b2d6a), - X(0x7c6e7e37), X(0x7c71ccdd), X(0x7c75195e), X(0x7c7863ba), - X(0x7c7babf1), X(0x7c7ef206), X(0x7c8235f7), X(0x7c8577c6), - X(0x7c88b774), X(0x7c8bf502), X(0x7c8f306f), X(0x7c9269bd), - X(0x7c95a0ec), X(0x7c98d5fe), X(0x7c9c08f2), X(0x7c9f39cb), - X(0x7ca26887), X(0x7ca59528), X(0x7ca8bfb0), X(0x7cabe81d), - X(0x7caf0e72), X(0x7cb232af), X(0x7cb554d4), X(0x7cb874e2), - X(0x7cbb92db), X(0x7cbeaebe), X(0x7cc1c88d), X(0x7cc4e047), - X(0x7cc7f5ef), X(0x7ccb0984), X(0x7cce1b08), X(0x7cd12a7b), - X(0x7cd437dd), X(0x7cd74330), X(0x7cda4c74), X(0x7cdd53aa), - X(0x7ce058d3), X(0x7ce35bef), X(0x7ce65cff), X(0x7ce95c04), - X(0x7cec58ff), X(0x7cef53f0), X(0x7cf24cd7), X(0x7cf543b7), - X(0x7cf8388f), X(0x7cfb2b60), X(0x7cfe1c2b), X(0x7d010af1), - X(0x7d03f7b2), X(0x7d06e26f), X(0x7d09cb29), X(0x7d0cb1e0), - X(0x7d0f9696), X(0x7d12794b), X(0x7d1559ff), X(0x7d1838b4), - X(0x7d1b156a), X(0x7d1df022), X(0x7d20c8dd), X(0x7d239f9b), - X(0x7d26745e), X(0x7d294725), X(0x7d2c17f1), X(0x7d2ee6c4), - X(0x7d31b39f), X(0x7d347e81), X(0x7d37476b), X(0x7d3a0e5f), - X(0x7d3cd35d), X(0x7d3f9665), X(0x7d425779), X(0x7d451699), - X(0x7d47d3c6), X(0x7d4a8f01), X(0x7d4d484b), X(0x7d4fffa3), - X(0x7d52b50c), X(0x7d556885), X(0x7d581a0f), X(0x7d5ac9ac), - X(0x7d5d775c), X(0x7d60231f), X(0x7d62ccf6), X(0x7d6574e3), - X(0x7d681ae6), X(0x7d6abeff), X(0x7d6d612f), X(0x7d700178), - X(0x7d729fd9), X(0x7d753c54), X(0x7d77d6e9), X(0x7d7a6f9a), - X(0x7d7d0666), X(0x7d7f9b4f), X(0x7d822e55), X(0x7d84bf79), - X(0x7d874ebc), X(0x7d89dc1e), X(0x7d8c67a1), X(0x7d8ef144), - X(0x7d91790a), X(0x7d93fef2), X(0x7d9682fd), X(0x7d99052d), - X(0x7d9b8581), X(0x7d9e03fb), X(0x7da0809b), X(0x7da2fb62), - X(0x7da57451), X(0x7da7eb68), X(0x7daa60a8), X(0x7dacd413), - X(0x7daf45a9), X(0x7db1b56a), X(0x7db42357), X(0x7db68f71), - X(0x7db8f9b9), X(0x7dbb6230), X(0x7dbdc8d6), X(0x7dc02dac), - X(0x7dc290b3), X(0x7dc4f1eb), X(0x7dc75156), X(0x7dc9aef4), - X(0x7dcc0ac5), X(0x7dce64cc), X(0x7dd0bd07), X(0x7dd31379), - X(0x7dd56821), X(0x7dd7bb01), X(0x7dda0c1a), X(0x7ddc5b6b), - X(0x7ddea8f7), X(0x7de0f4bd), X(0x7de33ebe), X(0x7de586fc), - X(0x7de7cd76), X(0x7dea122e), X(0x7dec5525), X(0x7dee965a), - X(0x7df0d5d0), X(0x7df31386), X(0x7df54f7e), X(0x7df789b8), - X(0x7df9c235), X(0x7dfbf8f5), X(0x7dfe2dfa), X(0x7e006145), - X(0x7e0292d5), X(0x7e04c2ac), X(0x7e06f0cb), X(0x7e091d32), - X(0x7e0b47e1), X(0x7e0d70db), X(0x7e0f981f), X(0x7e11bdaf), - X(0x7e13e18a), X(0x7e1603b3), X(0x7e182429), X(0x7e1a42ed), - X(0x7e1c6001), X(0x7e1e7b64), X(0x7e209518), X(0x7e22ad1d), - X(0x7e24c375), X(0x7e26d81f), X(0x7e28eb1d), X(0x7e2afc70), - X(0x7e2d0c17), X(0x7e2f1a15), X(0x7e31266a), X(0x7e333115), - X(0x7e353a1a), X(0x7e374177), X(0x7e39472e), X(0x7e3b4b3f), - X(0x7e3d4dac), X(0x7e3f4e75), X(0x7e414d9a), X(0x7e434b1e), - X(0x7e4546ff), X(0x7e474140), X(0x7e4939e0), X(0x7e4b30e2), - X(0x7e4d2644), X(0x7e4f1a09), X(0x7e510c30), X(0x7e52fcbc), - X(0x7e54ebab), X(0x7e56d900), X(0x7e58c4bb), X(0x7e5aaedd), - X(0x7e5c9766), X(0x7e5e7e57), X(0x7e6063b2), X(0x7e624776), - X(0x7e6429a5), X(0x7e660a3f), X(0x7e67e945), X(0x7e69c6b8), - X(0x7e6ba299), X(0x7e6d7ce7), X(0x7e6f55a5), X(0x7e712cd3), - X(0x7e730272), X(0x7e74d682), X(0x7e76a904), X(0x7e7879f9), - X(0x7e7a4962), X(0x7e7c173f), X(0x7e7de392), X(0x7e7fae5a), - X(0x7e817799), X(0x7e833f50), X(0x7e85057f), X(0x7e86ca27), - X(0x7e888d49), X(0x7e8a4ee5), X(0x7e8c0efd), X(0x7e8dcd91), - X(0x7e8f8aa1), X(0x7e914630), X(0x7e93003c), X(0x7e94b8c8), - X(0x7e966fd4), X(0x7e982560), X(0x7e99d96e), X(0x7e9b8bfe), - X(0x7e9d3d10), X(0x7e9eeca7), X(0x7ea09ac2), X(0x7ea24762), - X(0x7ea3f288), X(0x7ea59c35), X(0x7ea7446a), X(0x7ea8eb27), - X(0x7eaa906c), X(0x7eac343c), X(0x7eadd696), X(0x7eaf777b), - X(0x7eb116ed), X(0x7eb2b4eb), X(0x7eb45177), X(0x7eb5ec91), - X(0x7eb7863b), X(0x7eb91e74), X(0x7ebab53e), X(0x7ebc4a99), - X(0x7ebdde87), X(0x7ebf7107), X(0x7ec1021b), X(0x7ec291c3), - X(0x7ec42001), X(0x7ec5acd5), X(0x7ec7383f), X(0x7ec8c241), - X(0x7eca4adb), X(0x7ecbd20d), X(0x7ecd57da), X(0x7ecedc41), - X(0x7ed05f44), X(0x7ed1e0e2), X(0x7ed3611d), X(0x7ed4dff6), - X(0x7ed65d6d), X(0x7ed7d983), X(0x7ed95438), X(0x7edacd8f), - X(0x7edc4586), X(0x7eddbc20), X(0x7edf315c), X(0x7ee0a53c), - X(0x7ee217c1), X(0x7ee388ea), X(0x7ee4f8b9), X(0x7ee6672f), - X(0x7ee7d44c), X(0x7ee94012), X(0x7eeaaa80), X(0x7eec1397), - X(0x7eed7b59), X(0x7eeee1c6), X(0x7ef046df), X(0x7ef1aaa5), - X(0x7ef30d18), X(0x7ef46e39), X(0x7ef5ce09), X(0x7ef72c88), - X(0x7ef889b8), X(0x7ef9e599), X(0x7efb402c), X(0x7efc9972), - X(0x7efdf16b), X(0x7eff4818), X(0x7f009d79), X(0x7f01f191), - X(0x7f03445f), X(0x7f0495e4), X(0x7f05e620), X(0x7f073516), - X(0x7f0882c5), X(0x7f09cf2d), X(0x7f0b1a51), X(0x7f0c6430), - X(0x7f0daccc), X(0x7f0ef425), X(0x7f103a3b), X(0x7f117f11), - X(0x7f12c2a5), X(0x7f1404fa), X(0x7f15460f), X(0x7f1685e6), - X(0x7f17c47f), X(0x7f1901db), X(0x7f1a3dfb), X(0x7f1b78e0), - X(0x7f1cb28a), X(0x7f1deafa), X(0x7f1f2231), X(0x7f20582f), - X(0x7f218cf5), X(0x7f22c085), X(0x7f23f2de), X(0x7f252401), - X(0x7f2653f0), X(0x7f2782ab), X(0x7f28b032), X(0x7f29dc87), - X(0x7f2b07aa), X(0x7f2c319c), X(0x7f2d5a5e), X(0x7f2e81f0), - X(0x7f2fa853), X(0x7f30cd88), X(0x7f31f18f), X(0x7f33146a), - X(0x7f343619), X(0x7f35569c), X(0x7f3675f6), X(0x7f379425), - X(0x7f38b12c), X(0x7f39cd0a), X(0x7f3ae7c0), X(0x7f3c0150), - X(0x7f3d19ba), X(0x7f3e30fe), X(0x7f3f471e), X(0x7f405c1a), - X(0x7f416ff3), X(0x7f4282a9), X(0x7f43943e), X(0x7f44a4b2), - X(0x7f45b405), X(0x7f46c239), X(0x7f47cf4e), X(0x7f48db45), - X(0x7f49e61f), X(0x7f4aefdc), X(0x7f4bf87e), X(0x7f4d0004), - X(0x7f4e0670), X(0x7f4f0bc2), X(0x7f500ffb), X(0x7f51131c), - X(0x7f521525), X(0x7f531618), X(0x7f5415f4), X(0x7f5514bb), - X(0x7f56126e), X(0x7f570f0c), X(0x7f580a98), X(0x7f590511), - X(0x7f59fe78), X(0x7f5af6ce), X(0x7f5bee14), X(0x7f5ce44a), - X(0x7f5dd972), X(0x7f5ecd8b), X(0x7f5fc097), X(0x7f60b296), - X(0x7f61a389), X(0x7f629370), X(0x7f63824e), X(0x7f647021), - X(0x7f655ceb), X(0x7f6648ad), X(0x7f673367), X(0x7f681d19), - X(0x7f6905c6), X(0x7f69ed6d), X(0x7f6ad40f), X(0x7f6bb9ad), - X(0x7f6c9e48), X(0x7f6d81e0), X(0x7f6e6475), X(0x7f6f460a), - X(0x7f70269d), X(0x7f710631), X(0x7f71e4c6), X(0x7f72c25c), - X(0x7f739ef4), X(0x7f747a8f), X(0x7f75552e), X(0x7f762ed1), - X(0x7f770779), X(0x7f77df27), X(0x7f78b5db), X(0x7f798b97), - X(0x7f7a605a), X(0x7f7b3425), X(0x7f7c06fa), X(0x7f7cd8d9), - X(0x7f7da9c2), X(0x7f7e79b7), X(0x7f7f48b8), X(0x7f8016c5), - X(0x7f80e3e0), X(0x7f81b009), X(0x7f827b40), X(0x7f834588), - X(0x7f840edf), X(0x7f84d747), X(0x7f859ec1), X(0x7f86654d), - X(0x7f872aec), X(0x7f87ef9e), X(0x7f88b365), X(0x7f897641), - X(0x7f8a3832), X(0x7f8af93a), X(0x7f8bb959), X(0x7f8c7890), - X(0x7f8d36df), X(0x7f8df448), X(0x7f8eb0ca), X(0x7f8f6c67), - X(0x7f90271e), X(0x7f90e0f2), X(0x7f9199e2), X(0x7f9251f0), - X(0x7f93091b), X(0x7f93bf65), X(0x7f9474ce), X(0x7f952958), - X(0x7f95dd01), X(0x7f968fcd), X(0x7f9741ba), X(0x7f97f2ca), - X(0x7f98a2fd), X(0x7f995254), X(0x7f9a00d0), X(0x7f9aae71), - X(0x7f9b5b38), X(0x7f9c0726), X(0x7f9cb23b), X(0x7f9d5c78), - X(0x7f9e05de), X(0x7f9eae6e), X(0x7f9f5627), X(0x7f9ffd0b), - X(0x7fa0a31b), X(0x7fa14856), X(0x7fa1ecbf), X(0x7fa29054), - X(0x7fa33318), X(0x7fa3d50b), X(0x7fa4762c), X(0x7fa5167e), - X(0x7fa5b601), X(0x7fa654b5), X(0x7fa6f29b), X(0x7fa78fb3), - X(0x7fa82bff), X(0x7fa8c77f), X(0x7fa96234), X(0x7fa9fc1e), - X(0x7faa953e), X(0x7fab2d94), X(0x7fabc522), X(0x7fac5be8), - X(0x7facf1e6), X(0x7fad871d), X(0x7fae1b8f), X(0x7faeaf3b), - X(0x7faf4222), X(0x7fafd445), X(0x7fb065a4), X(0x7fb0f641), - X(0x7fb1861b), X(0x7fb21534), X(0x7fb2a38c), X(0x7fb33124), - X(0x7fb3bdfb), X(0x7fb44a14), X(0x7fb4d56f), X(0x7fb5600c), - X(0x7fb5e9ec), X(0x7fb6730f), X(0x7fb6fb76), X(0x7fb78323), - X(0x7fb80a15), X(0x7fb8904d), X(0x7fb915cc), X(0x7fb99a92), - X(0x7fba1ea0), X(0x7fbaa1f7), X(0x7fbb2497), X(0x7fbba681), - X(0x7fbc27b5), X(0x7fbca835), X(0x7fbd2801), X(0x7fbda719), - X(0x7fbe257e), X(0x7fbea331), X(0x7fbf2032), X(0x7fbf9c82), - X(0x7fc01821), X(0x7fc09311), X(0x7fc10d52), X(0x7fc186e4), - X(0x7fc1ffc8), X(0x7fc277ff), X(0x7fc2ef89), X(0x7fc36667), - X(0x7fc3dc9a), X(0x7fc45221), X(0x7fc4c6ff), X(0x7fc53b33), - X(0x7fc5aebe), X(0x7fc621a0), X(0x7fc693db), X(0x7fc7056f), - X(0x7fc7765c), X(0x7fc7e6a3), X(0x7fc85645), X(0x7fc8c542), - X(0x7fc9339b), X(0x7fc9a150), X(0x7fca0e63), X(0x7fca7ad3), - X(0x7fcae6a2), X(0x7fcb51cf), X(0x7fcbbc5c), X(0x7fcc2649), - X(0x7fcc8f97), X(0x7fccf846), X(0x7fcd6058), X(0x7fcdc7cb), - X(0x7fce2ea2), X(0x7fce94dd), X(0x7fcefa7b), X(0x7fcf5f7f), - X(0x7fcfc3e8), X(0x7fd027b7), X(0x7fd08aed), X(0x7fd0ed8b), - X(0x7fd14f90), X(0x7fd1b0fd), X(0x7fd211d4), X(0x7fd27214), - X(0x7fd2d1bf), X(0x7fd330d4), X(0x7fd38f55), X(0x7fd3ed41), - X(0x7fd44a9a), X(0x7fd4a761), X(0x7fd50395), X(0x7fd55f37), - X(0x7fd5ba48), X(0x7fd614c9), X(0x7fd66eba), X(0x7fd6c81b), - X(0x7fd720ed), X(0x7fd77932), X(0x7fd7d0e8), X(0x7fd82812), - X(0x7fd87eae), X(0x7fd8d4bf), X(0x7fd92a45), X(0x7fd97f40), - X(0x7fd9d3b0), X(0x7fda2797), X(0x7fda7af5), X(0x7fdacdca), - X(0x7fdb2018), X(0x7fdb71dd), X(0x7fdbc31c), X(0x7fdc13d5), - X(0x7fdc6408), X(0x7fdcb3b6), X(0x7fdd02df), X(0x7fdd5184), - X(0x7fdd9fa5), X(0x7fdded44), X(0x7fde3a60), X(0x7fde86fb), - X(0x7fded314), X(0x7fdf1eac), X(0x7fdf69c4), X(0x7fdfb45d), - X(0x7fdffe76), X(0x7fe04811), X(0x7fe0912e), X(0x7fe0d9ce), - X(0x7fe121f0), X(0x7fe16996), X(0x7fe1b0c1), X(0x7fe1f770), - X(0x7fe23da4), X(0x7fe2835f), X(0x7fe2c89f), X(0x7fe30d67), - X(0x7fe351b5), X(0x7fe3958c), X(0x7fe3d8ec), X(0x7fe41bd4), - X(0x7fe45e46), X(0x7fe4a042), X(0x7fe4e1c8), X(0x7fe522da), - X(0x7fe56378), X(0x7fe5a3a1), X(0x7fe5e358), X(0x7fe6229b), - X(0x7fe6616d), X(0x7fe69fcc), X(0x7fe6ddbb), X(0x7fe71b39), - X(0x7fe75847), X(0x7fe794e5), X(0x7fe7d114), X(0x7fe80cd5), - X(0x7fe84827), X(0x7fe8830c), X(0x7fe8bd84), X(0x7fe8f78f), - X(0x7fe9312f), X(0x7fe96a62), X(0x7fe9a32b), X(0x7fe9db8a), - X(0x7fea137e), X(0x7fea4b09), X(0x7fea822b), X(0x7feab8e5), - X(0x7feaef37), X(0x7feb2521), X(0x7feb5aa4), X(0x7feb8fc1), - X(0x7febc478), X(0x7febf8ca), X(0x7fec2cb6), X(0x7fec603e), - X(0x7fec9363), X(0x7fecc623), X(0x7fecf881), X(0x7fed2a7c), - X(0x7fed5c16), X(0x7fed8d4e), X(0x7fedbe24), X(0x7fedee9b), - X(0x7fee1eb1), X(0x7fee4e68), X(0x7fee7dc0), X(0x7feeacb9), - X(0x7feedb54), X(0x7fef0991), X(0x7fef3771), X(0x7fef64f5), - X(0x7fef921d), X(0x7fefbee8), X(0x7fefeb59), X(0x7ff0176f), - X(0x7ff0432a), X(0x7ff06e8c), X(0x7ff09995), X(0x7ff0c444), - X(0x7ff0ee9c), X(0x7ff1189b), X(0x7ff14243), X(0x7ff16b94), - X(0x7ff1948e), X(0x7ff1bd32), X(0x7ff1e581), X(0x7ff20d7b), - X(0x7ff2351f), X(0x7ff25c70), X(0x7ff2836d), X(0x7ff2aa17), - X(0x7ff2d06d), X(0x7ff2f672), X(0x7ff31c24), X(0x7ff34185), - X(0x7ff36695), X(0x7ff38b55), X(0x7ff3afc4), X(0x7ff3d3e4), - X(0x7ff3f7b4), X(0x7ff41b35), X(0x7ff43e69), X(0x7ff4614e), - X(0x7ff483e6), X(0x7ff4a631), X(0x7ff4c82f), X(0x7ff4e9e1), - X(0x7ff50b47), X(0x7ff52c62), X(0x7ff54d33), X(0x7ff56db9), - X(0x7ff58df5), X(0x7ff5ade7), X(0x7ff5cd90), X(0x7ff5ecf1), - X(0x7ff60c09), X(0x7ff62ada), X(0x7ff64963), X(0x7ff667a5), - X(0x7ff685a1), X(0x7ff6a357), X(0x7ff6c0c7), X(0x7ff6ddf1), - X(0x7ff6fad7), X(0x7ff71778), X(0x7ff733d6), X(0x7ff74fef), - X(0x7ff76bc6), X(0x7ff78759), X(0x7ff7a2ab), X(0x7ff7bdba), - X(0x7ff7d888), X(0x7ff7f315), X(0x7ff80d61), X(0x7ff8276c), - X(0x7ff84138), X(0x7ff85ac4), X(0x7ff87412), X(0x7ff88d20), - X(0x7ff8a5f0), X(0x7ff8be82), X(0x7ff8d6d7), X(0x7ff8eeef), - X(0x7ff906c9), X(0x7ff91e68), X(0x7ff935cb), X(0x7ff94cf2), - X(0x7ff963dd), X(0x7ff97a8f), X(0x7ff99105), X(0x7ff9a742), - X(0x7ff9bd45), X(0x7ff9d30f), X(0x7ff9e8a0), X(0x7ff9fdf9), - X(0x7ffa131a), X(0x7ffa2803), X(0x7ffa3cb4), X(0x7ffa512f), - X(0x7ffa6573), X(0x7ffa7981), X(0x7ffa8d59), X(0x7ffaa0fc), - X(0x7ffab46a), X(0x7ffac7a3), X(0x7ffadaa8), X(0x7ffaed78), - X(0x7ffb0015), X(0x7ffb127f), X(0x7ffb24b6), X(0x7ffb36bb), - X(0x7ffb488d), X(0x7ffb5a2e), X(0x7ffb6b9d), X(0x7ffb7cdb), - X(0x7ffb8de9), X(0x7ffb9ec6), X(0x7ffbaf73), X(0x7ffbbff1), - X(0x7ffbd03f), X(0x7ffbe05e), X(0x7ffbf04f), X(0x7ffc0012), - X(0x7ffc0fa6), X(0x7ffc1f0d), X(0x7ffc2e47), X(0x7ffc3d54), - X(0x7ffc4c35), X(0x7ffc5ae9), X(0x7ffc6971), X(0x7ffc77ce), - X(0x7ffc8600), X(0x7ffc9407), X(0x7ffca1e4), X(0x7ffcaf96), - X(0x7ffcbd1f), X(0x7ffcca7e), X(0x7ffcd7b4), X(0x7ffce4c1), - X(0x7ffcf1a5), X(0x7ffcfe62), X(0x7ffd0af6), X(0x7ffd1763), - X(0x7ffd23a9), X(0x7ffd2fc8), X(0x7ffd3bc1), X(0x7ffd4793), - X(0x7ffd533f), X(0x7ffd5ec5), X(0x7ffd6a27), X(0x7ffd7563), - X(0x7ffd807a), X(0x7ffd8b6e), X(0x7ffd963d), X(0x7ffda0e8), - X(0x7ffdab70), X(0x7ffdb5d5), X(0x7ffdc017), X(0x7ffdca36), - X(0x7ffdd434), X(0x7ffdde0f), X(0x7ffde7c9), X(0x7ffdf161), - X(0x7ffdfad8), X(0x7ffe042f), X(0x7ffe0d65), X(0x7ffe167b), - X(0x7ffe1f71), X(0x7ffe2848), X(0x7ffe30ff), X(0x7ffe3997), - X(0x7ffe4211), X(0x7ffe4a6c), X(0x7ffe52a9), X(0x7ffe5ac8), - X(0x7ffe62c9), X(0x7ffe6aae), X(0x7ffe7275), X(0x7ffe7a1f), - X(0x7ffe81ad), X(0x7ffe891f), X(0x7ffe9075), X(0x7ffe97b0), - X(0x7ffe9ece), X(0x7ffea5d2), X(0x7ffeacbb), X(0x7ffeb38a), - X(0x7ffeba3e), X(0x7ffec0d8), X(0x7ffec758), X(0x7ffecdbf), - X(0x7ffed40d), X(0x7ffeda41), X(0x7ffee05d), X(0x7ffee660), - X(0x7ffeec4b), X(0x7ffef21f), X(0x7ffef7da), X(0x7ffefd7e), - X(0x7fff030b), X(0x7fff0881), X(0x7fff0de0), X(0x7fff1328), - X(0x7fff185b), X(0x7fff1d77), X(0x7fff227e), X(0x7fff276f), - X(0x7fff2c4b), X(0x7fff3112), X(0x7fff35c4), X(0x7fff3a62), - X(0x7fff3eeb), X(0x7fff4360), X(0x7fff47c2), X(0x7fff4c0f), - X(0x7fff504a), X(0x7fff5471), X(0x7fff5885), X(0x7fff5c87), - X(0x7fff6076), X(0x7fff6452), X(0x7fff681d), X(0x7fff6bd6), - X(0x7fff6f7d), X(0x7fff7313), X(0x7fff7698), X(0x7fff7a0c), - X(0x7fff7d6f), X(0x7fff80c2), X(0x7fff8404), X(0x7fff8736), - X(0x7fff8a58), X(0x7fff8d6b), X(0x7fff906e), X(0x7fff9362), - X(0x7fff9646), X(0x7fff991c), X(0x7fff9be3), X(0x7fff9e9c), - X(0x7fffa146), X(0x7fffa3e2), X(0x7fffa671), X(0x7fffa8f1), - X(0x7fffab65), X(0x7fffadca), X(0x7fffb023), X(0x7fffb26f), - X(0x7fffb4ae), X(0x7fffb6e0), X(0x7fffb906), X(0x7fffbb20), - X(0x7fffbd2e), X(0x7fffbf30), X(0x7fffc126), X(0x7fffc311), - X(0x7fffc4f1), X(0x7fffc6c5), X(0x7fffc88f), X(0x7fffca4d), - X(0x7fffcc01), X(0x7fffcdab), X(0x7fffcf4a), X(0x7fffd0e0), - X(0x7fffd26b), X(0x7fffd3ec), X(0x7fffd564), X(0x7fffd6d2), - X(0x7fffd838), X(0x7fffd993), X(0x7fffdae6), X(0x7fffdc31), - X(0x7fffdd72), X(0x7fffdeab), X(0x7fffdfdb), X(0x7fffe104), - X(0x7fffe224), X(0x7fffe33c), X(0x7fffe44d), X(0x7fffe556), - X(0x7fffe657), X(0x7fffe751), X(0x7fffe844), X(0x7fffe930), - X(0x7fffea15), X(0x7fffeaf3), X(0x7fffebca), X(0x7fffec9b), - X(0x7fffed66), X(0x7fffee2a), X(0x7fffeee8), X(0x7fffefa0), - X(0x7ffff053), X(0x7ffff0ff), X(0x7ffff1a6), X(0x7ffff247), - X(0x7ffff2e4), X(0x7ffff37a), X(0x7ffff40c), X(0x7ffff499), - X(0x7ffff520), X(0x7ffff5a3), X(0x7ffff621), X(0x7ffff69b), - X(0x7ffff710), X(0x7ffff781), X(0x7ffff7ee), X(0x7ffff857), - X(0x7ffff8bb), X(0x7ffff91c), X(0x7ffff979), X(0x7ffff9d2), - X(0x7ffffa27), X(0x7ffffa79), X(0x7ffffac8), X(0x7ffffb13), - X(0x7ffffb5b), X(0x7ffffba0), X(0x7ffffbe2), X(0x7ffffc21), - X(0x7ffffc5d), X(0x7ffffc96), X(0x7ffffccd), X(0x7ffffd01), - X(0x7ffffd32), X(0x7ffffd61), X(0x7ffffd8e), X(0x7ffffdb8), - X(0x7ffffde0), X(0x7ffffe07), X(0x7ffffe2b), X(0x7ffffe4d), - X(0x7ffffe6d), X(0x7ffffe8b), X(0x7ffffea8), X(0x7ffffec3), - X(0x7ffffedc), X(0x7ffffef4), X(0x7fffff0a), X(0x7fffff1f), - X(0x7fffff33), X(0x7fffff45), X(0x7fffff56), X(0x7fffff66), - X(0x7fffff75), X(0x7fffff82), X(0x7fffff8f), X(0x7fffff9a), - X(0x7fffffa5), X(0x7fffffaf), X(0x7fffffb8), X(0x7fffffc0), - X(0x7fffffc8), X(0x7fffffce), X(0x7fffffd5), X(0x7fffffda), - X(0x7fffffdf), X(0x7fffffe4), X(0x7fffffe8), X(0x7fffffeb), - X(0x7fffffef), X(0x7ffffff1), X(0x7ffffff4), X(0x7ffffff6), - X(0x7ffffff8), X(0x7ffffff9), X(0x7ffffffb), X(0x7ffffffc), - X(0x7ffffffd), X(0x7ffffffd), X(0x7ffffffe), X(0x7fffffff), - X(0x7fffffff), X(0x7fffffff), X(0x7fffffff), X(0x7fffffff), - X(0x7fffffff), X(0x7fffffff), X(0x7fffffff), X(0x7fffffff), - X(0x7fffffff), X(0x7fffffff), X(0x7fffffff), X(0x7fffffff), -}; - diff --git a/apps/codecs/libtta/README b/apps/codecs/libtta/README deleted file mode 100644 index 8b1a1b23c0..0000000000 --- a/apps/codecs/libtta/README +++ /dev/null @@ -1,72 +0,0 @@ -TTA Hardware Players Library -============================ - -Version 1.2, (c) 2004 Alexander Djourik. All rights reserved. - -* Introduction - -This library provides to decode a multichannel 8,16 and 24 -bits TTA audio files. TTA is a lossless audio format. Being -"lossless" means that no data/quality is lost in the compression -- when uncompressed, the data will be identical to the original. -The compression ratios of TTA depend on the type of music file -being compressed, but the compression size will generally range -between 30% - 70% of the original. - -TTA format supports both of ID3v1/v2 tags. Detailed format -description is available at http://www.true-audio.com. - -The decoder process has a minimal system requirements and does -not required to create a big additional memory pools. As the -TTA algorithms has a same system requirements both for decoding -and for encoding processes - the TTA recorder can be easily -realized also. - -* Changes - - 14/04/2004 1.0 Initial release - 16/04/2004 1.1 Code optimization - Code clean-up - 29/10/2004 1.2 ID3 tags support - Code clean-up - -* To Do - - - TTA recorder functions. - -* Developers - - Alexander Djourik - Pavel Zhilin - -* Copying - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - -1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. -2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. -3. Neither the name of the True Audio Software nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -* See also - -Please visit the TTA homepage at http://tta.sourceforge.net for the -latest in news and downloads. diff --git a/apps/codecs/libtta/README.rockbox b/apps/codecs/libtta/README.rockbox deleted file mode 100644 index 549aa4e097..0000000000 --- a/apps/codecs/libtta/README.rockbox +++ /dev/null @@ -1,33 +0,0 @@ -Library: True Audio -Imported by : Yoshihisa Uchida -Import date : 2010-03-05 -Baseed by : TTA library version 1.2 for hardware players (ttalib-hwplayer-1.2.tgz) - from http://true-audio.com/Free_Downloads - -This directory contains a decoder version of True Auido. - -LICENSING INFORMATION - -True Audio license is described in the README file or each source file in this directory. - -Limitation - - - Decoding is not real time on some targets. - - Max duration is 4095 seconds (about 1 hours 8 minutes). - -IMPORT DETAILS - -The .[ch] files from ttalib-hwplayer-1.2.tgz were imported into Rockbox. -But the following files do not include. - Makefile - tta.vcproj - samples/* - - -When source files import in Rockbox, I changed below. - -all files - - TAB => 4 spaces. - - // style comments changes to /* */ style. - -Moreover, I modify to optimize the decoding speed. diff --git a/apps/codecs/libtta/SOURCES b/apps/codecs/libtta/SOURCES deleted file mode 100644 index 0a8f1171eb..0000000000 --- a/apps/codecs/libtta/SOURCES +++ /dev/null @@ -1,7 +0,0 @@ -ttadec.c -#ifdef CPU_ARM -filter_arm.S -#endif -#ifdef CPU_COLDFIRE -filter_coldfire.S -#endif diff --git a/apps/codecs/libtta/filter.h b/apps/codecs/libtta/filter.h deleted file mode 100644 index 228757b9a0..0000000000 --- a/apps/codecs/libtta/filter.h +++ /dev/null @@ -1,136 +0,0 @@ -/* - * filter.h - * - * Description: TTAv1 filter functions - * Developed by: Alexander Djourik - * Pavel Zhilin - * - * Copyright (c) 2004 True Audio Software. All rights reserved. - * - */ - -/* - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the True Audio Software nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef FILTER_H -#define FILTER_H - -///////// Filter Settings ////////// -static int flt_set[3] = {10, 9, 10}; - -#if defined(CPU_ARM) || defined(CPU_COLDFIRE) -int hybrid_filter(fltst *fs, int *in); /* implements in filter_arm.S */ - -#else - -static inline void -memshl (register int *pA) { - register int *pB = pA + 16; - - *pA++ = *pB++; - *pA++ = *pB++; - *pA++ = *pB++; - *pA++ = *pB++; - *pA++ = *pB++; - *pA++ = *pB++; - *pA++ = *pB++; - *pA = *pB; -} - -static inline void -hybrid_filter (fltst *fs, int *in) { - register int *pA = fs->dl + fs->index; - register int *pB = fs->qm; - register int *pM = fs->dx + fs->index; - register int sum = fs->round; - - if (!fs->error) { - sum += *pA++ * *pB++; - sum += *pA++ * *pB++; - sum += *pA++ * *pB++; - sum += *pA++ * *pB++; - sum += *pA++ * *pB++; - sum += *pA++ * *pB++; - sum += *pA++ * *pB++; - sum += *pA * *pB; - pM += 8; - } else if (fs->error < 0) { - sum += *pA++ * (*pB++ -= *pM++); - sum += *pA++ * (*pB++ -= *pM++); - sum += *pA++ * (*pB++ -= *pM++); - sum += *pA++ * (*pB++ -= *pM++); - sum += *pA++ * (*pB++ -= *pM++); - sum += *pA++ * (*pB++ -= *pM++); - sum += *pA++ * (*pB++ -= *pM++); - sum += *pA * (*pB -= *pM++); - } else { - sum += *pA++ * (*pB++ += *pM++); - sum += *pA++ * (*pB++ += *pM++); - sum += *pA++ * (*pB++ += *pM++); - sum += *pA++ * (*pB++ += *pM++); - sum += *pA++ * (*pB++ += *pM++); - sum += *pA++ * (*pB++ += *pM++); - sum += *pA++ * (*pB++ += *pM++); - sum += *pA * (*pB += *pM++); - } - - pB = pA++; - fs->error = *in; - *in += (sum >> fs->shift); - *pA = *in; - - *pM-- = ((*pB-- >> 30) | 1) << 2; - *pM-- = ((*pB-- >> 30) | 1) << 1; - *pM-- = ((*pB-- >> 30) | 1) << 1; - *pM = ((*pB >> 30) | 1); - - *(pA-1) = *(pA-0) - *(pA-1); - *(pA-2) = *(pA-1) - *(pA-2); - *(pA-3) = *(pA-2) - *(pA-3); - - /* - * Rockbox speciffic - * in order to make speed up, memshl() is executed at the rate once every 16 times. - */ - if (++fs->index == 16) - { - memshl (fs->dl); - memshl (fs->dx); - fs->index = 0; - } -} -#endif - -static inline void -filter_init (fltst *fs, int shift) { - ci->memset (fs, 0, sizeof(fltst)); - fs->shift = shift; - fs->round = 1 << (shift - 1); - fs->index = 0; -} - -#endif /* FILTER_H */ diff --git a/apps/codecs/libtta/filter_arm.S b/apps/codecs/libtta/filter_arm.S deleted file mode 100644 index f3959b83ca..0000000000 --- a/apps/codecs/libtta/filter_arm.S +++ /dev/null @@ -1,198 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2010 Yoshihisa Uchida - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ - -#include "config.h" - -/* - * The following are assembler optimised version of - * void hybrid_filter(fltst *fs, int *in) - */ - -#ifdef USE_IRAM - .section .icode, "ax", %progbits -#else - .text -#endif - .align - .global hybrid_filter - .type hybrid_filter, %function - -hybrid_filter: - @ input: r0 = fs, r1 = in - stmdb sp!, {r4 - r12, lr} - - @ get fs members - @ r2 pA := fs->dl + fs->index - @ r3 pM := fs->dx + fs->index - @ r4 pB := fs->qm - @ r5 fs->index - @ r6 fs->error - @ lr sum := fs->round - - ldmia r0, {r5, r6, lr} @ r5 = fs->index - @ r6 = fs->error - @ lr = fs->round - add r2, r0, #148 @ r2 = fs->dl - add r3, r0, #52 @ r3 = fs->dx - add r4, r0, #20 @ r4 = fs->qm - add r2, r2, r5 @ r2 = (unsigned char*)fs->dl + fs->index - add r3, r3, r5 @ r3 = (unsigned char*)fs->dx + fs->index - - cmp r6, #0 - bmi .hf_negative - bne .hf_positive - - @ case fs->error == 0 - - add r3, r3, #32 - ldmia r4!, {r5, r6, r7, r8 } - ldmia r2!, {r9, r10, r11, r12} - mla lr, r5, r9, lr - mla lr, r6, r10, lr - mla lr, r7, r11, lr - mla lr, r8, r12, lr - ldmia r4!, {r5, r6, r7, r8 } - b .hf2 - -.hf_negative: - @ case fs->error < 0 - - ldmia r4, {r5, r6, r7, r8 } - ldmia r3!, {r9, r10, r11, r12} - sub r5, r5, r9 - sub r6, r6, r10 - sub r7, r7, r11 - sub r8, r8, r12 - stmia r4!, {r5, r6, r7, r8 } @ update fs->qm[0], ..., fs->qm[3] - ldmia r2!, {r9, r10, r11, r12} - mla lr, r5, r9, lr - mla lr, r6, r10, lr - mla lr, r7, r11, lr - mla lr, r8, r12, lr - ldmia r4, {r5, r6, r7, r8 } - ldmia r3!, {r9, r10, r11, r12} - sub r5, r5, r9 - sub r6, r6, r10 - sub r7, r7, r11 - sub r8, r8, r12 - stmia r4!, {r5, r6, r7, r8 } @ update fs->qm[4], ..., fs->qm[7] - b .hf2 - -.hf_positive: - @ case fs->error > 0 - - ldmia r4, {r5, r6, r7, r8 } - ldmia r3!, {r9, r10, r11, r12} - add r5, r5, r9 - add r6, r6, r10 - add r7, r7, r11 - add r8, r8, r12 - stmia r4!, {r5, r6, r7, r8 } @ update fs->qm[0], ..., fs->qm[3] - ldmia r2!, {r9, r10, r11, r12} - mla lr, r5, r9, lr - mla lr, r6, r10, lr - mla lr, r7, r11, lr - mla lr, r8, r12, lr - ldmia r4, {r5, r6, r7, r8 } - ldmia r3!, {r9, r10, r11, r12} - add r5, r5, r9 - add r6, r6, r10 - add r7, r7, r11 - add r8, r8, r12 - stmia r4!, {r5, r6, r7, r8 } @ update fs->qm[4], ..., fs->qm[7] - -.hf2: - ldmia r2!, {r9, r10, r11, r12} - mla lr, r5, r9, lr - mla lr, r6, r10, lr - mla lr, r7, r11, lr - mla lr, r8, r12, lr - - @ fs->error = *in; - @ *in += (sum >> fs->shift) - @ *pA = *in - - ldr r5, [r1] @ r5 = *in - ldr r6, [r0, #12] @ r6 = fs->shift - add lr, r5, lr, asr r6 - str lr, [r1] @ *in += (sum >> fs->shift) - - @ update fs->index - - ldr r1, [r0] @ r1 = fs->index - add r1, r1, #4 - ands r1, r1, #63 @ set Z flag (after this, CPSR must keep !!) - stmia r0, {r1, r5} @ fs->index = (fs->index + 4) & 63 - @ fs->error = (original) *in - - @ change *pM, *(pM-1), *(pM-2), *(pM-3) - @ r9 = *(pA-4), r5 = *(pM-3) - @ r10 = *(pA-3), r6 = *(pM-2) - @ r11 = *(pA-2), r7 = *(pM-1) - @ r12 = *(pA-1), r8 = *(pM-0) - @ lr = *(pA-0) - - mov r4, #1 - orr r5, r4, r9, asr #30 - orr r6, r4, r10, asr #30 - orr r7, r4, r11, asr #30 - orr r8, r4, r12, asr #30 - mov r6, r6, lsl #1 - mov r7, r7, lsl #1 - mov r8, r8, lsl #2 - - @ change *(pA-1), *(pA-2), *(pA-3) - sub r12, lr, r12 - sub r11, r12, r11 - sub r10, r11, r10 - - @ set to the memory: *pA, *(pA-1), *(pA-2), *(pA-3), *pM, *(pM-1), *(pM-2), *(pM-3) - stmneda r2, {r10, r11, r12, lr} - stmneda r3, {r5, r6, r7, r8} - ldmpc cond=ne regs=r4-r12 @ hybrid_filter end (when fs->index != 0) - -.hf_memshl: - @ memshl (fs->dl) - @ r9 = fs->dl[16 + 3] - @ r10 = fs->dl[16 + 4] - @ r11 = fs->dl[16 + 5] - @ r12 = fs->dl[16 + 6] - @ lr = fs->dl[16 + 7] - - add r2, r0, #212 @ r2 = fs->dl + 16 - ldmia r2, {r1, r3, r4} - sub r2, r2, #64 @ r2 = fs->dl - stmia r2, {r1, r3, r4, r9 - r12, lr} - - @ memshl (fs->dx) - @ r5 = fs->dx[16 + 4] - @ r6 = fs->dx[16 + 5] - @ r7 = fs->dx[16 + 6] - @ r8 = fs->dx[16 + 7] - - add r9, r0, #116 @ r9 = fs->dx + 16 - ldmia r9, {r1, r2, r3, r4} - sub r9, r9, #64 @ r9 = fs->dx - stmia r9, {r1 - r8} - ldmpc regs=r4-r12 @ hybrid_filter end (when fs->index == 0) - -hybrid_filter_end: - .size hybrid_filter, hybrid_filter_end - hybrid_filter diff --git a/apps/codecs/libtta/filter_coldfire.S b/apps/codecs/libtta/filter_coldfire.S deleted file mode 100644 index 3950eb52e6..0000000000 --- a/apps/codecs/libtta/filter_coldfire.S +++ /dev/null @@ -1,164 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2010 Nils Wallménius - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ - -#include "config.h" - -/* - * The following is an assembler optimised version of - * void hybrid_filter(fltst *fs, int *in) - */ - -#if defined(USE_IRAM) - .section .icode -#else - .text -#endif - .align 2 - .global hybrid_filter - .type hybrid_filter, @function - -hybrid_filter: - lea.l (-8*4, %sp), %sp - movem.l %d2-%d7/%a2-%a3, (%sp) | save some registers - move.l (8*4+4, %sp), %a0 | a0 = fs - movem.l (%a0), %d4-%d5 | d4 = fs->index, d5 = fs->error - - lea.l (%a0, %d4.l*4), %a2 - lea.l (148, %a2), %a1 | a1 = fs->dl + fs->index (*pA) - lea.l (52, %a2), %a2 | a2 = fs->dx + fs->index (*pM) - - move.l (%a1)+, %a3 | load one value from *pA (needed in every case) - movem.l (20, %a0), %d0-%d3 | load 4 values from *pB - - tst.l %d5 - blt .hf_negative - bgt .hf_positive - - | fs->error == 0 - mac.l %d0, %a3, (%a1)+, %a3, %acc0 - mac.l %d1, %a3, (%a1)+, %a3, %acc0 - mac.l %d2, %a3, (%a1)+, %a3, %acc0 - mac.l %d3, %a3, (%a1)+, %d4, %acc0 - movem.l (4*4+20, %a0), %d0-%d3 | load 4 values from *pB - bra 0f - - .hf_negative: | fs->error < 0 - movem.l (%a2), %d4-%d7 | load 4 values from *pM - sub.l %d4, %d0 - sub.l %d5, %d1 - sub.l %d6, %d2 - sub.l %d7, %d3 - movem.l %d0-%d3, (20, %a0) - mac.l %d0, %a3, (%a1)+, %a3, %acc0 - mac.l %d1, %a3, (%a1)+, %a3, %acc0 - mac.l %d2, %a3, (%a1)+, %a3, %acc0 - mac.l %d3, %a3, (%a1)+, %d4, %acc0 - - movem.l (4*4+20, %a0), %d0-%d3 | load 4 values from *pB - movem.l (4*4, %a2), %d5-%d7/%a3 | load 4 values from *pM - sub.l %d5, %d0 - sub.l %d6, %d1 - sub.l %d7, %d2 - sub.l %a3, %d3 - movem.l %d0-%d3, (4*4+20, %a0) - bra 0f - - .hf_positive: | fs->error > 0 - movem.l (%a2), %d4-%d7 | load 4 values from *pM - add.l %d4, %d0 - add.l %d5, %d1 - add.l %d6, %d2 - add.l %d7, %d3 - movem.l %d0-%d3, (20, %a0) - mac.l %d0, %a3, (%a1)+, %a3, %acc0 - mac.l %d1, %a3, (%a1)+, %a3, %acc0 - mac.l %d2, %a3, (%a1)+, %a3, %acc0 - mac.l %d3, %a3, (%a1)+, %d4, %acc0 - - movem.l (4*4+20, %a0), %d0-%d3 | load 4 values from *pB - movem.l (4*4, %a2), %d5-%d7/%a3 | load 4 values from *pM - add.l %d5, %d0 - add.l %d6, %d1 - add.l %d7, %d2 - add.l %a3, %d3 - movem.l %d0-%d3, (4*4+20, %a0) - - 0: - - mac.l %d0, %d4, (%a1)+, %d5, %acc0 | common macro block - mac.l %d1, %d5, (%a1)+, %d6, %acc0 - mac.l %d2, %d6, (%a1), %d7, %acc0 - mac.l %d3, %d7, %acc0 - - move.l (8*4+8, %sp), %a3 | a3 = in - move.l (%a3), %d3 - move.l %d3, (4, %a0) | fs->error = *in - movclr.l %acc0, %d0 | d0 = sum - movem.l (8, %a0), %d1-%d2 - add.l %d1, %d0 | sum += fs->round - asr.l %d2, %d0 | sum >>= fs->shift - - add.l %d0, %d3 - move.l %d3, (%a3) | *in += (sum >> fs->shift) - - move.l %d3, ( 1*4, %a1) - sub.l %d7, %d3 - move.l %d3, ( 0*4, %a1) - sub.l %d6, %d3 - move.l %d3, (-1*4, %a1) - sub.l %d5, %d3 - move.l %d3, (-2*4, %a1) - - moveq #30,%d0 - asr.l %d0,%d7 - asr.l %d0,%d6 - asr.l %d0,%d5 - asr.l %d0,%d4 - - moveq #1,%d0 - or.l %d0,%d7 - or.l %d0,%d6 - or.l %d0,%d5 - or.l %d0,%d4 - - lsl.l #2,%d7 - lsl.l #1,%d6 - lsl.l #1,%d5 - movem.l %d4-%d7, (8*4-3*4,%a2) | store to *pM - - move.l (%a0), %d0 - addq.l #1, %d0 - cmp.l #16, %d0 | ++fs->index == 16 ? - bne 1f - - movem.l (16*4+148, %a0), %d0-%d7 - movem.l %d0-%d7, (148, %a0) - movem.l (16*4+52, %a0), %d0-%d7 - movem.l %d0-%d7, (52, %a0) - clr.l %d0 | fs->index = 0 - 1: - - move.l %d0, (%a0) - - movem.l (%sp), %d2-%d7/%a2-%a3 | restore stacked regs - lea.l (8*4, %sp), %sp - rts - diff --git a/apps/codecs/libtta/libtta.make b/apps/codecs/libtta/libtta.make deleted file mode 100644 index f8b7c650b2..0000000000 --- a/apps/codecs/libtta/libtta.make +++ /dev/null @@ -1,18 +0,0 @@ -# __________ __ ___. -# Open \______ \ ____ ____ | | _\_ |__ _______ ___ -# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / -# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < -# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ -# \/ \/ \/ \/ \/ -# $Id$ -# - -# libtta -TTALIB := $(CODECDIR)/libtta.a -TTALIB_SRC := $(call preprocess, $(APPSDIR)/codecs/libtta/SOURCES) -TTALIB_OBJ := $(call c2obj, $(TTALIB_SRC)) -OTHER_SRC += $(TTALIB_SRC) - -$(TTALIB): $(TTALIB_OBJ) - $(SILENT)$(shell rm -f $@) - $(call PRINTS,AR $(@F))$(AR) rcs $@ $^ >/dev/null diff --git a/apps/codecs/libtta/ttadec.c b/apps/codecs/libtta/ttadec.c deleted file mode 100644 index 06ca431084..0000000000 --- a/apps/codecs/libtta/ttadec.c +++ /dev/null @@ -1,582 +0,0 @@ -/* - * ttadec.c - * - * Description: TTAv1 decoder library for HW players - * Developed by: Alexander Djourik - * Pavel Zhilin - * - * Copyright (c) 2004 True Audio Software. All rights reserved. - * - */ - -/* - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the True Audio Software nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include "codeclib.h" - -#include "ttalib.h" -#include "ttadec.h" -#include "filter.h" - -/******************* static variables and structures *******************/ - -static unsigned char isobuffers[ISO_BUFFERS_SIZE + 4] IBSS_ATTR; -static unsigned char * const iso_buffers_end ICONST_ATTR = isobuffers + ISO_BUFFERS_SIZE; -static unsigned int pcm_buffer_size IBSS_ATTR; - -static decoder tta[MAX_NCH] IBSS_ATTR; /* decoder state */ -/* Rockbox speciffic: cache is defined in get_samples() (non static value) */ -/* static int cache[MAX_NCH]; // decoder cache */ - -static tta_info *ttainfo IBSS_ATTR; /* currently playing file info */ - -static unsigned int fframes IBSS_ATTR; /* number of frames in file */ -static unsigned int framelen IBSS_ATTR; /* the frame length in samples */ -static unsigned int lastlen IBSS_ATTR; /* the length of the last frame in samples */ -static unsigned int data_pos IBSS_ATTR; /* currently playing frame index */ -static unsigned int data_cur IBSS_ATTR; /* the playing position in frame */ - -static int maxvalue IBSS_ATTR; /* output data max value */ - -/* Rockbox speciffic: seek_table is static size */ -static unsigned int seek_table[MAX_SEEK_TABLE_SIZE]; /* the playing position table */ -static unsigned int st_state; /* seek table status */ - -static unsigned int frame_crc32 IBSS_ATTR; -static unsigned int bit_count IBSS_ATTR; -static unsigned int bit_cache IBSS_ATTR; -static unsigned char *bitpos IBSS_ATTR; - -/* Rockbox speciffic: deletes read_id3_tags(). */ -/* static int read_id3_tags (tta_info *info); */ - -/********************* rockbox helper functions *************************/ - -/* emulate stdio functions */ -static size_t tta_fread(void *ptr, size_t size, size_t nobj) -{ - size_t read_size; - unsigned char *buffer = ci->request_buffer(&read_size, size * nobj); - - if (read_size > 0) - { - ci->memcpy(ptr, buffer, read_size); - ci->advance_buffer(read_size); - } - return read_size; -} - -static int tta_fseek(long offset, int origin) -{ - switch (origin) - { - case SEEK_CUR: - ci->advance_buffer(offset); - break; - case SEEK_SET: - ci->seek_buffer(offset); - break; - case SEEK_END: - ci->seek_buffer(offset + ci->id3->filesize); - break; - default: - return -1; - } - return 0; -} - -/************************* crc32 functions *****************************/ - -#define UPDATE_CRC32(x, crc) crc = \ - (((crc>>8) & 0x00FFFFFF) ^ crc32_table[(crc^x) & 0xFF]) - -static unsigned int -crc32 (unsigned char *buffer, unsigned int len) { - unsigned int i; - unsigned int crc = 0xFFFFFFFF; - - for (i = 0; i < len; i++) UPDATE_CRC32(buffer[i], crc); - - return (crc ^ 0xFFFFFFFF); -} - -/************************* bit operations ******************************/ - -#define GET_BINARY(value, bits) \ - while (bit_count < bits) { \ - if (bitpos == iso_buffers_end) { \ - if (!tta_fread(isobuffers, 1, ISO_BUFFERS_SIZE)) { \ - ttainfo->STATE = READ_ERROR; \ - return -1; \ - } \ - bitpos = isobuffers; \ - } \ - UPDATE_CRC32(*bitpos, frame_crc32); \ - bit_cache |= *bitpos << bit_count; \ - bit_count += 8; \ - bitpos++; \ - } \ - value = bit_cache & bit_mask[bits]; \ - bit_cache >>= bits; \ - bit_count -= bits; \ - bit_cache &= bit_mask[bit_count]; - -#define GET_UNARY(value) \ - value = 0; \ - while (!(bit_cache ^ bit_mask[bit_count])) { \ - if (bitpos == iso_buffers_end) { \ - if (!tta_fread(isobuffers, 1, ISO_BUFFERS_SIZE)) { \ - ttainfo->STATE = READ_ERROR; \ - return -1; \ - } \ - bitpos = isobuffers; \ - } \ - value += bit_count; \ - bit_cache = *bitpos++; \ - UPDATE_CRC32(bit_cache, frame_crc32); \ - bit_count = 8; \ - } \ - while (bit_cache & 1) { \ - value++; \ - bit_cache >>= 1; \ - bit_count--; \ - } \ - bit_cache >>= 1; \ - bit_count--; - -/************************* rice operations ******************************/ - -static inline int update_rice(int value, adapt *rice, int depth, - const unsigned int *shift_table) -{ - if (depth > 0) - { - rice->sum1 += value - (rice->sum1 >> 4); - if (rice->k1 > 0 && rice->sum1 < shift_table[rice->k1]) - rice->k1--; - else if (rice->sum1 > shift_table[rice->k1 + 1]) - rice->k1++; - value += *(shift_table + rice->k0 - 4); - } - rice->sum0 += value - (rice->sum0 >> 4); - if (rice->k0 > 0 && rice->sum0 < shift_table[rice->k0]) - rice->k0--; - else if (rice->sum0 > shift_table[rice->k0 + 1]) - rice->k0++; - - return DEC(value); -} - -/************************* buffer functions ******************************/ - -static void init_buffer_read(void) { - frame_crc32 = 0xFFFFFFFFUL; - bit_count = bit_cache = 0; - bitpos = iso_buffers_end; -} - -static int done_buffer_read(void) { - unsigned int crc32, rbytes; - - frame_crc32 ^= 0xFFFFFFFFUL; - rbytes = iso_buffers_end - bitpos; - - if (rbytes < sizeof(int)) { - ci->memcpy(isobuffers, bitpos, 4); - if (!tta_fread(isobuffers + rbytes, 1, ISO_BUFFERS_SIZE - rbytes)) - return -1; - bitpos = isobuffers; - } - - ci->memcpy(&crc32, bitpos, 4); - crc32 = ENDSWAP_INT32(crc32); - bitpos += sizeof(int); - - if (crc32 != frame_crc32) return -1; - - bit_cache = bit_count = 0; - frame_crc32 = 0xFFFFFFFFUL; - - return 0; -} - -/************************* decoder functions ****************************/ - -/* rockbox: not used -const char *get_error_str (int error) { - switch (error) { - case NO_ERROR: return "No errors found"; - case OPEN_ERROR: return "Can't open file"; - case FORMAT_ERROR: return "Not supported file format"; - case FILE_ERROR: return "File is corrupted"; - case READ_ERROR: return "Can't read from file"; - case MEMORY_ERROR: return "Insufficient memory available"; - default: return "Unknown error code"; - } -} */ - -int set_tta_info (tta_info *info) -{ - unsigned int checksum; - unsigned int datasize; - unsigned int origsize; - tta_hdr ttahdr; - - /* clear the memory */ - ci->memset (info, 0, sizeof(tta_info)); - - /* skip id3v2 tags */ - tta_fseek(ci->id3->id3v2len, SEEK_SET); - - /* read TTA header */ - if (tta_fread (&ttahdr, 1, sizeof (ttahdr)) == 0) { - info->STATE = READ_ERROR; - return -1; - } - - /* check for TTA3 signature */ - if (ENDSWAP_INT32(ttahdr.TTAid) != TTA1_SIGN) { - DEBUGF("ID error: %x\n", ENDSWAP_INT32(ttahdr.TTAid)); - info->STATE = FORMAT_ERROR; - return -1; - } - - ttahdr.CRC32 = ENDSWAP_INT32(ttahdr.CRC32); - checksum = crc32((unsigned char *) &ttahdr, - sizeof(tta_hdr) - sizeof(int)); - if (checksum != ttahdr.CRC32) { - DEBUGF("CRC error: %x != %x\n", ttahdr.CRC32, checksum); - info->STATE = FILE_ERROR; - return -1; - } - - ttahdr.AudioFormat = ENDSWAP_INT16(ttahdr.AudioFormat); - ttahdr.NumChannels = ENDSWAP_INT16(ttahdr.NumChannels); - ttahdr.BitsPerSample = ENDSWAP_INT16(ttahdr.BitsPerSample); - ttahdr.SampleRate = ENDSWAP_INT32(ttahdr.SampleRate); - ttahdr.DataLength = ENDSWAP_INT32(ttahdr.DataLength); - - /* check for player supported formats */ - if (ttahdr.AudioFormat != WAVE_FORMAT_PCM || - ttahdr.NumChannels > MAX_NCH || - ttahdr.BitsPerSample > MAX_BPS ||( - ttahdr.SampleRate != 16000 && - ttahdr.SampleRate != 22050 && - ttahdr.SampleRate != 24000 && - ttahdr.SampleRate != 32000 && - ttahdr.SampleRate != 44100 && - ttahdr.SampleRate != 48000 && - ttahdr.SampleRate != 64000 && - ttahdr.SampleRate != 88200 && - ttahdr.SampleRate != 96000)) { - info->STATE = FORMAT_ERROR; - DEBUGF("illegal audio format: %d channels: %d samplerate: %d\n", - ttahdr.AudioFormat, ttahdr.NumChannels, ttahdr.SampleRate); - return -1; - } - - /* fill the File Info */ - info->NCH = ttahdr.NumChannels; - info->BPS = ttahdr.BitsPerSample; - info->BSIZE = (ttahdr.BitsPerSample + 7)/8; - info->FORMAT = ttahdr.AudioFormat; - info->SAMPLERATE = ttahdr.SampleRate; - info->DATALENGTH = ttahdr.DataLength; - info->FRAMELEN = (int) MULTIPLY_FRAME_TIME(ttahdr.SampleRate); - info->LENGTH = ttahdr.DataLength / ttahdr.SampleRate; - info->DATAPOS = ci->id3->id3v2len; - info->FILESIZE = ci->id3->filesize; - - datasize = info->FILESIZE - info->DATAPOS; - origsize = info->DATALENGTH * info->BSIZE * info->NCH; - - /* info->COMPRESS = (double) datasize / origsize; */ - info->BITRATE = (int) ((uint64_t) datasize * info->SAMPLERATE * info->NCH * info->BPS - / (origsize * 1000LL)); - - return 0; -} - -static void rice_init(adapt *rice, unsigned int k0, unsigned int k1) { - rice->k0 = k0; - rice->k1 = k1; - rice->sum0 = shift_16[k0]; - rice->sum1 = shift_16[k1]; -} - -static void decoder_init(decoder *tta, int nch, int byte_size) { - int shift = flt_set[byte_size - 1]; - int i; - - for (i = 0; i < nch; i++) { - filter_init(&tta[i].fst, shift); - rice_init(&tta[i].rice, 10, 10); - tta[i].last = 0; - } -} - -static void seek_table_init (unsigned int *seek_table, - unsigned int len, unsigned int data_offset) { - unsigned int *st, frame_len; - - for (st = seek_table; st < (seek_table + len); st++) { - frame_len = ENDSWAP_INT32(*st); - *st = data_offset; - data_offset += frame_len; - } -} - -int set_position (unsigned int pos, enum tta_seek_type type) -{ - unsigned int i; - unsigned int seek_pos; - - if (type == TTA_SEEK_TIME) - { - if (pos >= fframes) - pos = fframes -1; - } - else - { - pos -= ttainfo->DATAPOS; - for (i = 1; i < fframes; i++) - { - if (seek_table[i] > pos) - break; - } - pos = i - 1; - } - if (!st_state) { - ttainfo->STATE = FILE_ERROR; - return -1; - } - seek_pos = ttainfo->DATAPOS + seek_table[data_pos = pos]; - if (tta_fseek(seek_pos, SEEK_SET) < 0) { - ttainfo->STATE = READ_ERROR; - return -1; - } - - data_cur = 0; - framelen = 0; - - /* init bit reader */ - init_buffer_read(); - return data_pos * ttainfo->FRAMELEN; -} - -int player_init (tta_info *info) { - unsigned int checksum; - unsigned int data_offset; - unsigned int st_size; - -#ifdef CPU_COLDFIRE - coldfire_set_macsr(0); /* signed integer mode */ -#endif - - ttainfo = info; - - framelen = 0; - data_pos = 0; - data_cur = 0; - - lastlen = ttainfo->DATALENGTH % ttainfo->FRAMELEN; - fframes = ttainfo->DATALENGTH / ttainfo->FRAMELEN + (lastlen ? 1 : 0); - st_size = (fframes + 1) * sizeof(int); - - /* - * Rockbox speciffic - * playable tta file is to MAX_SEEK_TABLE_SIZE frames - * about 1:08:15 (frequency 44.1 kHz) - */ - if (fframes > MAX_SEEK_TABLE_SIZE) - { - LOGF("frame is too many: %d > %d", fframes, MAX_SEEK_TABLE_SIZE); - return -1; - } - - /* read seek table */ - if (!tta_fread(seek_table, st_size, 1)) { - ttainfo->STATE = READ_ERROR; - return -1; - } - - checksum = crc32((unsigned char *) seek_table, st_size - sizeof(int)); - st_state = (checksum == ENDSWAP_INT32(seek_table[fframes])); - data_offset = sizeof(tta_hdr) + st_size; - - /* init seek table */ - seek_table_init(seek_table, fframes, data_offset); - - /* init bit reader */ - init_buffer_read(); - - /* - * Rockbox speciffic - * because pcm data is int32_t, does not multiply ttainfo->BSIZE. - */ - pcm_buffer_size = PCM_BUFFER_LENGTH * ttainfo->NCH; - maxvalue = (1UL << ttainfo->BPS) - 1; - - return 0; -} - -/* - * Rockbox specffic - * because the seek table is static size buffer, player_stop() is nooperation function. - */ -void player_stop (void) { -/* - if (seek_table) { - free(seek_table); - seek_table = NULL; - } -*/ -} - -/* - * Rockbox speciffic - * with the optimization, the decoding logic is modify a little. - */ -int get_samples (int32_t *buffer) { - unsigned int k, depth, unary, binary; - int32_t *p = buffer; - decoder *dec = tta; - int value, res; - int cur_pos = pcm_buffer_size; - int pcm_shift_bits = TTA_OUTPUT_DEPTH - ttainfo->BPS; - int pr_bits = (ttainfo->BSIZE == 1)? 4 : 5; - int cache = 0; /* decoder cache */ - - fltst *fst; - adapt *rice; - - for (res = 0; --cur_pos >= 0;) { - fst = &dec->fst; - rice = &dec->rice; - - if (data_cur == framelen) { - if (data_pos == fframes) break; - if (framelen && done_buffer_read()) { - if (set_position(data_pos, TTA_SEEK_TIME) < 0) return -1; - if (res) break; - } - - if (data_pos == fframes - 1 && lastlen) - framelen = lastlen; - else framelen = ttainfo->FRAMELEN; - - decoder_init(tta, ttainfo->NCH, ttainfo->BSIZE); - data_pos++; data_cur = 0; - } - - /* decode Rice unsigned */ - GET_UNARY(unary); - - switch (unary) { - case 0: depth = 0; k = rice->k0; break; - default: - depth = 1; k = rice->k1; - unary--; - } - - if (k) { - GET_BINARY(binary, k); - value = (unary << k) + binary; - } else value = unary; - - value = update_rice(value, rice, depth, shift_16); - - /* Rockbox specific: the following logic move to update_rice() */ -#if 0 - if (depth > 0) - { - rice->sum1 += value - (rice->sum1 >> 4); - if (rice->k1 > 0 && rice->sum1 < shift_16[rice->k1]) - rice->k1--; - else if (rice->sum1 > shift_16[rice->k1 + 1]) - rice->k1++; - value += bit_shift[rice->k0]; - } - rice->sum0 += value - (rice->sum0 >> 4); - if (rice->k0 > 0 && rice->sum0 < shift_16[rice->k0]) - rice->k0--; - else if (rice->sum0 > shift_16[rice->k0 + 1]) - rice->k0++; - - value = DEC(value); -#endif - - /* decompress stage 1: adaptive hybrid filter */ - hybrid_filter(fst, &value); - - /* decompress stage 2: fixed order 1 prediction */ - value += PREDICTOR1(dec->last, pr_bits); - dec->last = value; - - /* check for errors */ - if (abs(value) > maxvalue) { - unsigned int tail = - pcm_buffer_size / (ttainfo->BSIZE * ttainfo->NCH) - res; - ci->memset(buffer, 0, pcm_buffer_size * sizeof(int32_t)); - data_cur += tail; res += tail; - break; - } - - /* Rockbox speciffic: Rockbox supports max 2channels */ - if (ttainfo->NCH == 1) - { - *p++ = value << pcm_shift_bits; - data_cur++; - res++; - } - else - { - if (dec == tta) - { - cache = value; - dec++; - } - else - { - value += cache / 2; - cache = value - cache; - dec = tta; - *p++ = cache << pcm_shift_bits; - *p++ = value << pcm_shift_bits; - data_cur++; - res++; - } - } - } - - return res; -} - -/* Rockbox speciffic: id3 tags functions delete. */ - -/* eof */ diff --git a/apps/codecs/libtta/ttadec.h b/apps/codecs/libtta/ttadec.h deleted file mode 100644 index c185e5c858..0000000000 --- a/apps/codecs/libtta/ttadec.h +++ /dev/null @@ -1,203 +0,0 @@ -/* - * ttadec.h - * - * Description: TTAv1 decoder definitions and prototypes - * Developed by: Alexander Djourik - * Pavel Zhilin - * - * Copyright (c) 2004 True Audio Software. All rights reserved. - * - */ - -/* - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the True Audio Software nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef TTADEC_H_ -#define TTADEC_H_ - -#define __ATTRIBUTE_PACKED__ __attribute__((packed)) - -#define TTA1_SIGN 0x31415454 -#define MAX_ORDER 8 - -#ifndef WAVE_FORMAT_PCM -#define WAVE_FORMAT_PCM 1 -#endif - -typedef unsigned long long uint64; - -static const unsigned int crc32_table[256] ICONST_ATTR = { - 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, - 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, - 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, - 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, - 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, - 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, - 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, - 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5, - 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, - 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, - 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, - 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, - 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, - 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f, - 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, - 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, - 0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a, - 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433, - 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, - 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01, - 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, - 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, - 0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c, - 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, - 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, - 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, - 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, - 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, - 0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086, - 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, - 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, - 0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, - 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, - 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, - 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, - 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, - 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, - 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7, - 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, - 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, - 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, - 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, - 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, - 0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79, - 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, - 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, - 0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, - 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, - 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, - 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713, - 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, - 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, - 0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e, - 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, - 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, - 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, - 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, - 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, - 0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0, - 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, - 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, - 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf, - 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, - 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d -}; - -static const unsigned int bit_mask[] ICONST_ATTR = { - 0x00000000, 0x00000001, 0x00000003, 0x00000007, - 0x0000000f, 0x0000001f, 0x0000003f, 0x0000007f, - 0x000000ff, 0x000001ff, 0x000003ff, 0x000007ff, - 0x00000fff, 0x00001fff, 0x00003fff, 0x00007fff, - 0x0000ffff, 0x0001ffff, 0x0003ffff, 0x0007ffff, - 0x000fffff, 0x001fffff, 0x003fffff, 0x007fffff, - 0x00ffffff, 0x01ffffff, 0x03ffffff, 0x07ffffff, - 0x0fffffff, 0x1fffffff, 0x3fffffff, 0x7fffffff, - 0xffffffff -}; - -static const unsigned int bit_shift[] ICONST_ATTR = { - 0x00000001, 0x00000002, 0x00000004, 0x00000008, - 0x00000010, 0x00000020, 0x00000040, 0x00000080, - 0x00000100, 0x00000200, 0x00000400, 0x00000800, - 0x00001000, 0x00002000, 0x00004000, 0x00008000, - 0x00010000, 0x00020000, 0x00040000, 0x00080000, - 0x00100000, 0x00200000, 0x00400000, 0x00800000, - 0x01000000, 0x02000000, 0x04000000, 0x08000000, - 0x10000000, 0x20000000, 0x40000000, 0x80000000, - 0x80000000, 0x80000000, 0x80000000, 0x80000000, - 0x80000000, 0x80000000, 0x80000000, 0x80000000 -}; - -static const unsigned int * const shift_16 ICONST_ATTR = bit_shift + 4; - -typedef unsigned char byte; - -#ifndef ROCKBOX_LITTLE_ENDIAN -#define ENDSWAP_INT16(x) (((((x)>>8)&0xFF)|(((x)&0xFF)<<8))) -#define ENDSWAP_INT32(x) (((((x)>>24)&0xFF)|(((x)>>8)&0xFF00)|(((x)&0xFF00)<<8)|(((x)&0xFF)<<24))) -#define WRITE_BUFFER(x, bsize, out) { \ - if (bsize > 2) *out++ = (byte)(*x >> 16)); \ - if (bsize > 1) *out++ = (byte)(*x >> 8); \ - *out++ = (byte) *x; } -#else -#define ENDSWAP_INT16(x) (x) -#define ENDSWAP_INT32(x) (x) -#define WRITE_BUFFER(x, bsize, out) { \ - *out++ = (byte) *x; \ - if (bsize > 1) *out++ = (byte)(*x >> 8); \ - if (bsize > 2) *out++ = (byte)(*x >> 16); } -#endif - -#define PREDICTOR1(x, k) ((int)((((uint64)x << k) - x) >> k)) -#define DEC(x) (((x)&1)?(((x)+1)>>1):(-(x)>>1)) - -typedef struct { - unsigned int TTAid; - unsigned short AudioFormat; - unsigned short NumChannels; - unsigned short BitsPerSample; - unsigned int SampleRate; - unsigned int DataLength; - unsigned int CRC32; -} __ATTRIBUTE_PACKED__ tta_hdr; - -typedef struct { - unsigned int k0; - unsigned int k1; - unsigned int sum0; - unsigned int sum1; -} adapt; - -typedef struct { - int index; /* Rockbox speciffic */ - int error; - int round; - int shift; - int mutex; - int qm[MAX_ORDER]; - int dx[MAX_ORDER * 3]; /* original: dx[MAX_ORDER + 1] */ - int dl[MAX_ORDER * 3]; /* original: dx[MAX_ORDER + 1] */ -} fltst; - -typedef struct { - fltst fst; - adapt rice; - int last; -} decoder; - -/* Rockbox speciffic: about id3 tags definitions delete. */ -#endif /* TTADEC_H_ */ diff --git a/apps/codecs/libtta/ttalib.h b/apps/codecs/libtta/ttalib.h deleted file mode 100644 index 45da71813a..0000000000 --- a/apps/codecs/libtta/ttalib.h +++ /dev/null @@ -1,157 +0,0 @@ -/* - * ttalib.h - * - * Description: TTAv1 player library prototypes - * Developed by: Alexander Djourik - * Pavel Zhilin - * - * Copyright (c) 2004 True Audio Software. All rights reserved. - * - */ - -/* - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the True Audio Software nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef TTALIB_H_ -#define TTALIB_H_ - -#define MAX_BPS 24 /* Max supported Bit resolution */ -#define MAX_NCH 2 /* Max supported number of channels (Rockbox changes: 8 -> 2) */ - -#ifndef MAXLINE -#define MAX_LINE 1024 -#endif - -/* decoded pcm sample depth (sample 28bit + sign 1bit) */ -#define TTA_OUTPUT_DEPTH 29 - -/* return codes */ -#define NO_ERROR 0 /* No errors found */ -#define OPEN_ERROR 1 /* Can't open file */ -#define FORMAT_ERROR 2 /* Unknown TTA format version */ -#define PLAYER_ERROR 3 /* Not supported file format */ -#define FILE_ERROR 4 /* File is corrupted */ -#define READ_ERROR 5 /* Can't read from file */ -#define MEMORY_ERROR 6 /* Insufficient memory available */ - -/* Rockbox speciffic: does not use FRAME_TIME */ -/* #define FRAME_TIME 1.04489795918367346939 */ -#define MULTIPLY_FRAME_TIME(x) (256 * (x) / 245) /* = FRAME_TIME * x */ -#define SEEK_STEP (int)MULTIPLY_FRAME_TIME(1000) /* (FRAME_TIME * 1000) */ - -#define ISO_BUFFER_LENGTH (1024*32) -#define ISO_NBUFFERS (8) -#define ISO_BUFFERS_SIZE (4096) /* (ISO_BUFFER_LENGTH*ISO_NBUFFERS) */ -#define PCM_BUFFER_LENGTH (4608) -#define MAX_SEEK_TABLE_SIZE (4096) - -typedef struct { - /* FILE *HANDLE; // file handle (Rockbox does not use) */ - unsigned int FILESIZE; /* compressed size */ - unsigned short NCH; /* number of channels */ - unsigned short BPS; /* bits per sample */ - unsigned short BSIZE; /* byte size */ - unsigned short FORMAT; /* audio format */ - unsigned int SAMPLERATE; /* samplerate (sps) */ - unsigned int DATALENGTH; /* data length in samples */ - unsigned int FRAMELEN; /* frame length */ - unsigned int LENGTH; /* playback time (sec) */ - unsigned int STATE; /* return code */ - unsigned int DATAPOS; /* size of ID3v2 header */ - unsigned int BITRATE; /* average bitrate (kbps) */ - /* double COMPRESS; // compression ratio (Rockbox does not use) */ - /* id3_info ID3; // ID3 information (Rockbox does not use) */ -} tta_info; - -enum tta_seek_type -{ - TTA_SEEK_TIME, - TTA_SEEK_POS, -}; - -/*********************** Library functions *************************/ -/* Rockbox speciffic: open_tta_file() does not use */ - -/* Rockbox speciffic: It is used in place of open_tta_file(). */ -int set_tta_info( // FUNCTION: set tta file info structure - tta_info *info); // file info structure -/* - * RETURN VALUE - * This function returns 0 if success. Otherwise, -1 is returned - * and the variable STATE of the currently using info structure - * is set to indicate the error. - * - */ - -/* Rockbox speciffic: close_tta_file() does not use */ - -/* Rockbox speciffic: set_position() change arguments and return value. */ -/* - * FUNCTION: sets playback position - * pos: seek position - * seek_time_ms / SEEK_STEP (when type is TTA_SEEK_TIME) - * file position (when type is TTA_SEEK_POS) - */ -int set_position ( - unsigned int pos, - enum tta_seek_type type); - -/* - * RETURN VALUE - * This function returns the seeked data position (>= 0) if success. Otherwise, -1 is returned - * and the variable STATE of the currently using info structure - * is set to indicate the error. - * - */ - -int player_init ( // FUNCTION: initializes TTA player - tta_info *info); // file info structure -/* - * RETURN VALUE - * This function returns 0 if success. Otherwise, -1 is returned - * and the variable STATE of the currently using info structure - * is set to indicate the error. - * - */ - -void player_stop (void); // FUNCTION: destroys memory pools - -/* Rockbox speciffic: unsigned char -> int32_t */ -int get_samples ( // FUNCTION: decode PCM_BUFFER_LENGTH samples - int32_t *buffer) ICODE_ATTR; // into the current PCM buffer position - -/* - * RETURN VALUE - * This function returns the number of samples successfully decoded. - * Otherwise, -1 is returned and the variable STATE of the currently - * using info structure is set to indicate the error. - * - */ - -const char *get_error_str (int error); // FUNCTION: get error description - -#endif /* TTALIB_H_ */ diff --git a/apps/codecs/libwavpack/LICENSE b/apps/codecs/libwavpack/LICENSE deleted file mode 100644 index 3ee485817d..0000000000 --- a/apps/codecs/libwavpack/LICENSE +++ /dev/null @@ -1,25 +0,0 @@ - Copyright (c) 1998 - 2004 Conifer Software - All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - * Neither the name of Conifer Software nor the names of its contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/apps/codecs/libwavpack/README b/apps/codecs/libwavpack/README deleted file mode 100644 index b373235e1c..0000000000 --- a/apps/codecs/libwavpack/README +++ /dev/null @@ -1,52 +0,0 @@ -//////////////////////////////////////////////////////////////////////////// -// **** WAVPACK **** // -// Hybrid Lossless Wavefile Compressor // -// Copyright (c) 1998 - 2004 Conifer Software. // -// All Rights Reserved. // -// Distributed under the BSD Software License (see license.txt) // -//////////////////////////////////////////////////////////////////////////// - -This package contains a tiny version of the WavPack 4.0 decoder that might -be used in a "resource limited" CPU environment or form the basis for a -hardware decoding implementation. It is packaged with a demo command-line -program that accepts a WavPack audio file on stdin and outputs a RIFF wav -file to stdout. The program is standard C, and a win32 executable is -included which was compiled under MS Visual C++ 6.0 using this command: - -cl /O1 /DWIN32 wvfilter.c wputils.c unpack.c float.c metadata.c words.c bits.c - -WavPack data is read with a stream reading callback. No direct seeking is -provided for, but it is possible to start decoding anywhere in a WavPack -stream. In this case, WavPack will be able to provide the sample-accurate -position when it synchs with the data and begins decoding. - -For demonstration purposes this uses a single static copy of the -WavpackContext structure, so obviously it cannot be used for more than one -file at a time. Also, this decoder will not handle "correction" files, plays -only the first two channels of multi-channel files, and is limited in -resolution in some large integer or floating point files (but always -provides at least 24 bits of resolution). It also will not accept WavPack -files from before version 4.0. - -To make this code viable on the greatest number of hardware platforms, the -following are true: - - speed is about 4x realtime on an AMD K6 300 MHz - ("high" mode 16/44 stereo; normal mode is about twice that fast) - - no floating-point math required; just 32b * 32b = 32b int multiply - - large data areas are static and less than 4K total - executable code and tables are less than 32K - no malloc / free usage - -To maintain compatibility on various platforms, the following conventions -are used: - - a "short" must be 16-bits - a "long" must be 32-bits - an "int" must be at least 16-bits, but may be larger - a "char" must default to signed - - -Questions or comments should be directed to david@wavpack.com diff --git a/apps/codecs/libwavpack/README.rockbox b/apps/codecs/libwavpack/README.rockbox deleted file mode 100644 index a74b0c511c..0000000000 --- a/apps/codecs/libwavpack/README.rockbox +++ /dev/null @@ -1,15 +0,0 @@ -Library: wavpack - Release 4.1 - September 14, 2004 -Imported: 2005-02-25 by Christian Gmeiner - - -This directory contains a "tiny" decoder version of wavpack for version 4.x. - -LICENSING INFORMATION - -wavpack is released under the BSD License as described -in the LICENSE file in this directory. - - -IMPORT DETAILS - -Excluded is wvfilter.c, because it is only a test programm. diff --git a/apps/codecs/libwavpack/SOURCES b/apps/codecs/libwavpack/SOURCES deleted file mode 100644 index b2518e59e0..0000000000 --- a/apps/codecs/libwavpack/SOURCES +++ /dev/null @@ -1,15 +0,0 @@ -bits.c -float.c -metadata.c -unpack.c -pack.c -words.c -wputils.c -#if defined(CPU_COLDFIRE) -coldfire.S -#endif -#if defined(CPU_ARM) -arm.S -arml.S -#endif - diff --git a/apps/codecs/libwavpack/arm.S b/apps/codecs/libwavpack/arm.S deleted file mode 100644 index 32de1df7de..0000000000 --- a/apps/codecs/libwavpack/arm.S +++ /dev/null @@ -1,477 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2006 by David Bryant - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ - -/* This is an assembly optimized version of the following WavPack function: - * - * void decorr_stereo_pass_cont_arm (struct decorr_pass *dpp, - * long *buffer, long sample_count); - * - * It performs a single pass of stereo decorrelation on the provided buffer. - * Note that this version of the function requires that the 8 previous stereo - * samples are visible and correct. In other words, it ignores the "samples_*" - * fields in the decorr_pass structure and gets the history data directly - * from the buffer. It does, however, return the appropriate history samples - * to the decorr_pass structure before returning. - * - * This is written to work on a ARM7TDMI processor. This version only uses the - * 32-bit multiply-accumulate instruction and so will overflow with 24-bit - * WavPack files. - */ - -#include "config.h" - - .text - .align - .global decorr_stereo_pass_cont_arm - -/* - * on entry: - * - * r0 = struct decorr_pass *dpp - * r1 = long *buffer - * r2 = long sample_count - */ - -decorr_stereo_pass_cont_arm: - - stmfd sp!, {r4 - r8, r10, r11, lr} - mov r5, r0 @ r5 = dpp - mov r11, #512 @ r11 = 512 for rounding - ldrsh r6, [r0, #2] @ r6 = dpp->delta - ldrsh r4, [r0, #4] @ r4 = dpp->weight_A - ldrsh r0, [r0, #6] @ r0 = dpp->weight_B - cmp r2, #0 @ exit if no samples to process - beq common_exit - - add r7, r1, r2, asl #3 @ r7 = buffer ending position - ldrsh r2, [r5, #0] @ r2 = dpp->term - cmp r2, #0 - bmi minus_term - - ldr lr, [r1, #-16] @ load 2 sample history from buffer - ldr r10, [r1, #-12] @ for terms 2, 17, and 18 - ldr r8, [r1, #-8] - ldr r3, [r1, #-4] - cmp r2, #17 - beq term_17_loop - cmp r2, #18 - beq term_18_loop - cmp r2, #2 - beq term_2_loop - b term_default_loop @ else handle default (1-8, except 2) - -minus_term: - mov r10, #1024 @ r10 = -1024 for weight clipping - rsb r10, r10, #0 @ (only used for negative terms) - cmn r2, #1 - beq term_minus_1 - cmn r2, #2 - beq term_minus_2 - cmn r2, #3 - beq term_minus_3 - b common_exit - -/* - ****************************************************************************** - * Loop to handle term = 17 condition - * - * r0 = dpp->weight_B r8 = previous left sample - * r1 = bptr r9 = - * r2 = current sample r10 = second previous left sample - * r3 = previous right sample r11 = 512 (for rounding) - * r4 = dpp->weight_A ip = current decorrelation value - * r5 = dpp sp = - * r6 = dpp->delta lr = second previous right sample - * r7 = eptr pc = - ******************************************************************************* - */ - -term_17_loop: - rsbs ip, lr, r8, asl #1 @ decorr value = (2 * prev) - 2nd prev - mov lr, r8 @ previous becomes 2nd previous - ldr r2, [r1], #4 @ get sample & update pointer - mla r8, ip, r4, r11 @ mult decorr value by weight, round, - add r8, r2, r8, asr #10 @ shift, and add to new sample - strne r8, [r1, #-4] @ if change possible, store sample back - cmpne r2, #0 - beq .L325 - teq ip, r2 @ update weight based on signs - submi r4, r4, r6 - addpl r4, r4, r6 - -.L325: rsbs ip, r10, r3, asl #1 @ do same thing for right channel - mov r10, r3 - ldr r2, [r1], #4 - mla r3, ip, r0, r11 - add r3, r2, r3, asr #10 - strne r3, [r1, #-4] - cmpne r2, #0 - beq .L329 - teq ip, r2 - submi r0, r0, r6 - addpl r0, r0, r6 - -.L329: cmp r7, r1 @ loop back if more samples to do - bhi term_17_loop - b store_1718 @ common exit for terms 17 & 18 - -/* - ****************************************************************************** - * Loop to handle term = 18 condition - * - * r0 = dpp->weight_B r8 = previous left sample - * r1 = bptr r9 = - * r2 = current sample r10 = second previous left sample - * r3 = previous right sample r11 = 512 (for rounding) - * r4 = dpp->weight_A ip = decorrelation value - * r5 = dpp sp = - * r6 = dpp->delta lr = second previous right sample - * r7 = eptr pc = - ******************************************************************************* - */ - -term_18_loop: - sub ip, r8, lr @ decorr value = - mov lr, r8 @ ((3 * prev) - 2nd prev) >> 1 - adds ip, r8, ip, asr #1 - ldr r2, [r1], #4 @ get sample & update pointer - mla r8, ip, r4, r11 @ mult decorr value by weight, round, - add r8, r2, r8, asr #10 @ shift, and add to new sample - strne r8, [r1, #-4] @ if change possible, store sample back - cmpne r2, #0 - beq .L337 - teq ip, r2 @ update weight based on signs - submi r4, r4, r6 - addpl r4, r4, r6 - -.L337: sub ip, r3, r10 @ do same thing for right channel - mov r10, r3 - adds ip, r3, ip, asr #1 - ldr r2, [r1], #4 - mla r3, ip, r0, r11 - add r3, r2, r3, asr #10 - strne r3, [r1, #-4] - cmpne r2, #0 - beq .L341 - teq ip, r2 - submi r0, r0, r6 - addpl r0, r0, r6 - -.L341: cmp r7, r1 @ loop back if more samples to do - bhi term_18_loop - -/* common exit for terms 17 & 18 */ - -store_1718: - str r3, [r5, #40] @ store sample history into struct - str r8, [r5, #8] - str r10, [r5, #44] - str lr, [r5, #12] - b common_exit @ and return - -/* - ****************************************************************************** - * Loop to handle term = 2 condition - * (note that this case can be handled by the default term handler (1-8), but - * this special case is faster because it doesn't have to read memory twice) - * - * r0 = dpp->weight_B r8 = previous left sample - * r1 = bptr r9 = - * r2 = current sample r10 = second previous left sample - * r3 = previous right sample r11 = 512 (for rounding) - * r4 = dpp->weight_A ip = decorrelation value - * r5 = dpp sp = - * r6 = dpp->delta lr = second previous right sample - * r7 = eptr pc = - ******************************************************************************* - */ - -term_2_loop: - movs ip, lr @ get decorrelation value & test - mov lr, r8 @ previous becomes 2nd previous - ldr r2, [r1], #4 @ get sample & update pointer - mla r8, ip, r4, r11 @ mult decorr value by weight, round, - add r8, r2, r8, asr #10 @ shift, and add to new sample - strne r8, [r1, #-4] @ if change possible, store sample back - cmpne r2, #0 - beq .L225 - teq ip, r2 @ update weight based on signs - submi r4, r4, r6 - addpl r4, r4, r6 - -.L225: movs ip, r10 @ do same thing for right channel - mov r10, r3 - ldr r2, [r1], #4 - mla r3, ip, r0, r11 - add r3, r2, r3, asr #10 - strne r3, [r1, #-4] - cmpne r2, #0 - beq .L229 - teq ip, r2 - submi r0, r0, r6 - addpl r0, r0, r6 - -.L229: cmp r7, r1 @ loop back if more samples to do - bhi term_2_loop - b default_term_exit @ this exit updates all dpp->samples - -/* - ****************************************************************************** - * Loop to handle default term condition - * - * r0 = dpp->weight_B r8 = result accumulator - * r1 = bptr r9 = - * r2 = dpp->term r10 = - * r3 = decorrelation value r11 = 512 (for rounding) - * r4 = dpp->weight_A ip = current sample - * r5 = dpp sp = - * r6 = dpp->delta lr = - * r7 = eptr pc = - ******************************************************************************* - */ - -term_default_loop: - ldr ip, [r1] @ get original sample - ldr r3, [r1, -r2, asl #3] @ get decorrelation value based on term - mla r8, r3, r4, r11 @ mult decorr value by weight, round, - add r8, ip, r8, asr #10 @ shift and add to new sample - str r8, [r1], #4 @ store update sample - cmp r3, #0 - cmpne ip, #0 - beq .L350 - teq ip, r3 @ update weight based on signs - submi r4, r4, r6 - addpl r4, r4, r6 - -.L350: ldr ip, [r1] @ do the same thing for right channel - ldr r3, [r1, -r2, asl #3] - mla r8, r3, r0, r11 - add r8, ip, r8, asr #10 - str r8, [r1], #4 - cmp r3, #0 - cmpne ip, #0 - beq .L354 - teq ip, r3 - submi r0, r0, r6 - addpl r0, r0, r6 - -.L354: cmp r7, r1 @ loop back if more samples to do - bhi term_default_loop - -/* - * This exit is used by terms 1-8 to store the previous 8 samples into the decorr - * structure (even if they are not all used for the given term) - */ - -default_term_exit: - ldrsh r3, [r5, #0] - sub ip, r3, #1 - mov lr, #7 - -.L358: and r3, ip, #7 - add r3, r5, r3, asl #2 - ldr r2, [r1, #-4] - str r2, [r3, #40] - ldr r2, [r1, #-8]! - str r2, [r3, #8] - sub ip, ip, #1 - sub lr, lr, #1 - cmn lr, #1 - bne .L358 - b common_exit - -/* - ****************************************************************************** - * Loop to handle term = -1 condition - * - * r0 = dpp->weight_B r8 = - * r1 = bptr r9 = - * r2 = intermediate result r10 = -1024 (for clipping) - * r3 = previous right sample r11 = 512 (for rounding) - * r4 = dpp->weight_A ip = current sample - * r5 = dpp sp = - * r6 = dpp->delta lr = updated left sample - * r7 = eptr pc = - ******************************************************************************* - */ - -term_minus_1: - ldr r3, [r1, #-4] - -term_minus_1_loop: - ldr ip, [r1] @ for left channel the decorrelation value - mla r2, r3, r4, r11 @ is the previous right sample (in r3) - add lr, ip, r2, asr #10 - str lr, [r1], #8 - cmp r3, #0 - cmpne ip, #0 - beq .L361 - teq ip, r3 @ update weight based on signs - submi r4, r4, r6 - addpl r4, r4, r6 - cmp r4, #1024 - movgt r4, #1024 - cmp r4, r10 - movlt r4, r10 - -.L361: ldr r2, [r1, #-4] @ for right channel the decorrelation value - mla r3, lr, r0, r11 @ is the just updated right sample (in lr) - add r3, r2, r3, asr #10 - str r3, [r1, #-4] - cmp lr, #0 - cmpne r2, #0 - beq .L369 - teq r2, lr - submi r0, r0, r6 - addpl r0, r0, r6 - cmp r0, #1024 @ then clip weight to +/-1024 - movgt r0, #1024 - cmp r0, r10 - movlt r0, r10 - -.L369: cmp r7, r1 @ loop back if more samples to do - bhi term_minus_1_loop - - str r3, [r5, #8] @ else store right sample and exit - b common_exit - -/* - ****************************************************************************** - * Loop to handle term = -2 condition - * (note that the channels are processed in the reverse order here) - * - * r0 = dpp->weight_B r8 = - * r1 = bptr r9 = - * r2 = intermediate result r10 = -1024 (for clipping) - * r3 = previous left sample r11 = 512 (for rounding) - * r4 = dpp->weight_A ip = current sample - * r5 = dpp sp = - * r6 = dpp->delta lr = updated right sample - * r7 = eptr pc = - ******************************************************************************* - */ - -term_minus_2: - ldr r3, [r1, #-8] - -term_minus_2_loop: - ldr ip, [r1, #4] @ for right channel the decorrelation value - mla r2, r3, r0, r11 @ is the previous left sample (in r3) - add lr, ip, r2, asr #10 - str lr, [r1, #4] - cmp r3, #0 - cmpne ip, #0 - beq .L380 - teq ip, r3 @ update weight based on signs - submi r0, r0, r6 - addpl r0, r0, r6 - cmp r0, #1024 @ then clip weight to +/-1024 - movgt r0, #1024 - cmp r0, r10 - movlt r0, r10 - -.L380: ldr r2, [r1, #0] @ for left channel the decorrelation value - mla r3, lr, r4, r11 @ is the just updated left sample (in lr) - add r3, r2, r3, asr #10 - str r3, [r1], #8 - cmp lr, #0 - cmpne r2, #0 - beq .L388 - teq r2, lr - submi r4, r4, r6 - addpl r4, r4, r6 - cmp r4, #1024 - movgt r4, #1024 - cmp r4, r10 - movlt r4, r10 - -.L388: cmp r7, r1 @ loop back if more samples to do - bhi term_minus_2_loop - - str r3, [r5, #40] @ else store left channel and exit - b common_exit - -/* - ****************************************************************************** - * Loop to handle term = -3 condition - * - * r0 = dpp->weight_B r8 = previous left sample - * r1 = bptr r9 = - * r2 = current left sample r10 = -1024 (for clipping) - * r3 = previous right sample r11 = 512 (for rounding) - * r4 = dpp->weight_A ip = intermediate result - * r5 = dpp sp = - * r6 = dpp->delta lr = - * r7 = eptr pc = - ******************************************************************************* - */ - -term_minus_3: - ldr r3, [r1, #-4] @ load previous samples - ldr r8, [r1, #-8] - -term_minus_3_loop: - ldr ip, [r1] - mla r2, r3, r4, r11 - add r2, ip, r2, asr #10 - str r2, [r1], #4 - cmp r3, #0 - cmpne ip, #0 - beq .L399 - teq ip, r3 @ update weight based on signs - submi r4, r4, r6 - addpl r4, r4, r6 - cmp r4, #1024 @ then clip weight to +/-1024 - movgt r4, #1024 - cmp r4, r10 - movlt r4, r10 - -.L399: movs ip, r8 @ ip = previous left we use now - mov r8, r2 @ r8 = current left we use next time - ldr r2, [r1], #4 - mla r3, ip, r0, r11 - add r3, r2, r3, asr #10 - strne r3, [r1, #-4] - cmpne r2, #0 - beq .L407 - teq ip, r2 - submi r0, r0, r6 - addpl r0, r0, r6 - cmp r0, #1024 - movgt r0, #1024 - cmp r0, r10 - movlt r0, r10 - -.L407: cmp r7, r1 @ loop back if more samples to do - bhi term_minus_3_loop - - str r3, [r5, #8] @ else store previous samples & exit - str r8, [r5, #40] - -/* - * Before finally exiting we must store weights back for next time - */ - -common_exit: - strh r4, [r5, #4] - strh r0, [r5, #6] - ldmpc regs="r4-r8, r10-r11" - diff --git a/apps/codecs/libwavpack/arml.S b/apps/codecs/libwavpack/arml.S deleted file mode 100644 index 60818aa1e6..0000000000 --- a/apps/codecs/libwavpack/arml.S +++ /dev/null @@ -1,506 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2006 by David Bryant - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ - -/* This is an assembly optimized version of the following WavPack function: - * - * void decorr_stereo_pass_cont_arml (struct decorr_pass *dpp, - * long *buffer, long sample_count); - * - * It performs a single pass of stereo decorrelation on the provided buffer. - * Note that this version of the function requires that the 8 previous stereo - * samples are visible and correct. In other words, it ignores the "samples_*" - * fields in the decorr_pass structure and gets the history data directly - * from the buffer. It does, however, return the appropriate history samples - * to the decorr_pass structure before returning. - * - * This is written to work on a ARM7TDMI processor. This version uses the - * 64-bit multiply-accumulate instruction and so can be used with all - * WavPack files. However, for optimum performance with 16-bit WavPack - * files, there is a faster version that only uses the 32-bit MLA - * instruction. - */ - -#include "config.h" - - .text - .align - .global decorr_stereo_pass_cont_arml - -/* - * on entry: - * - * r0 = struct decorr_pass *dpp - * r1 = long *buffer - * r2 = long sample_count - */ - -decorr_stereo_pass_cont_arml: - - stmfd sp!, {r4 - r8, r10, r11, lr} - mov r5, r0 @ r5 = dpp - mov r11, #512 @ r11 = 512 for rounding - ldrsh r6, [r0, #2] @ r6 = dpp->delta - ldrsh r4, [r0, #4] @ r4 = dpp->weight_A - ldrsh r0, [r0, #6] @ r0 = dpp->weight_B - cmp r2, #0 @ exit if no samples to process - beq common_exit - - mov r0, r0, asl #18 @ for 64-bit math we use weights << 18 - mov r4, r4, asl #18 - mov r6, r6, asl #18 - add r7, r1, r2, asl #3 @ r7 = buffer ending position - ldrsh r2, [r5, #0] @ r2 = dpp->term - cmp r2, #0 - blt minus_term - - ldr lr, [r1, #-16] @ load 2 sample history from buffer - ldr r10, [r1, #-12] @ for terms 2, 17, and 18 - ldr r8, [r1, #-8] - ldr r3, [r1, #-4] - - cmp r2, #18 - beq term_18_loop - mov lr, lr, asl #4 - mov r10, r10, asl #4 - cmp r2, #2 - beq term_2_loop - cmp r2, #17 - beq term_17_loop - b term_default_loop - -minus_term: - mov r10, #(1024 << 18) @ r10 = -1024 << 18 for weight clipping - rsb r10, r10, #0 @ (only used for negative terms) - cmn r2, #1 - beq term_minus_1 - cmn r2, #2 - beq term_minus_2 - cmn r2, #3 - beq term_minus_3 - b common_exit - -/* - ****************************************************************************** - * Loop to handle term = 17 condition - * - * r0 = dpp->weight_B r8 = previous left sample - * r1 = bptr r9 = - * r2 = current sample r10 = second previous left sample << 4 - * r3 = previous right sample r11 = lo accumulator (for rounding) - * r4 = dpp->weight_A ip = current decorrelation value - * r5 = dpp sp = - * r6 = dpp->delta lr = second previous right sample << 4 - * r7 = eptr pc = - ******************************************************************************* - */ - -term_17_loop: - rsbs ip, lr, r8, asl #5 @ decorr value = (2 * prev) - 2nd prev - mov lr, r8, asl #4 @ previous becomes 2nd previous - ldr r2, [r1], #4 @ get sample & update pointer - mov r11, #0x80000000 - mov r8, r2 - smlalne r11, r8, r4, ip - strne r8, [r1, #-4] @ if change possible, store sample back - cmpne r2, #0 - beq .L325 - teq ip, r2 @ update weight based on signs - submi r4, r4, r6 - addpl r4, r4, r6 - -.L325: rsbs ip, r10, r3, asl #5 @ do same thing for right channel - mov r10, r3, asl #4 - ldr r2, [r1], #4 - mov r11, #0x80000000 - mov r3, r2 - smlalne r11, r3, r0, ip - strne r3, [r1, #-4] - cmpne r2, #0 - beq .L329 - teq ip, r2 - submi r0, r0, r6 - addpl r0, r0, r6 - -.L329: cmp r7, r1 @ loop back if more samples to do - bhi term_17_loop - mov lr, lr, asr #4 - mov r10, r10, asr #4 - b store_1718 @ common exit for terms 17 & 18 - -/* - ****************************************************************************** - * Loop to handle term = 18 condition - * - * r0 = dpp->weight_B r8 = previous left sample - * r1 = bptr r9 = - * r2 = current sample r10 = second previous left sample - * r3 = previous right sample r11 = lo accumulator (for rounding) - * r4 = dpp->weight_A ip = decorrelation value - * r5 = dpp sp = - * r6 = dpp->delta lr = second previous right sample - * r7 = eptr pc = - ******************************************************************************* - */ - -term_18_loop: - rsb ip, lr, r8 @ decorr value = - mov lr, r8 @ ((3 * prev) - 2nd prev) >> 1 - add ip, lr, ip, asr #1 - movs ip, ip, asl #4 - ldr r2, [r1], #4 @ get sample & update pointer - mov r11, #0x80000000 - mov r8, r2 - smlalne r11, r8, r4, ip - strne r8, [r1, #-4] @ if change possible, store sample back - cmpne r2, #0 - beq .L337 - teq ip, r2 @ update weight based on signs - submi r4, r4, r6 - addpl r4, r4, r6 - -.L337: rsb ip, r10, r3 @ do same thing for right channel - mov r10, r3 - add ip, r10, ip, asr #1 - movs ip, ip, asl #4 - ldr r2, [r1], #4 - mov r11, #0x80000000 - mov r3, r2 - smlalne r11, r3, r0, ip - strne r3, [r1, #-4] - cmpne r2, #0 - beq .L341 - teq ip, r2 - submi r0, r0, r6 - addpl r0, r0, r6 - -.L341: cmp r7, r1 @ loop back if more samples to do - bhi term_18_loop - -/* common exit for terms 17 & 18 */ - -store_1718: - str r3, [r5, #40] @ store sample history into struct - str r8, [r5, #8] - str r10, [r5, #44] - str lr, [r5, #12] - b common_exit @ and return - -/* - ****************************************************************************** - * Loop to handle term = 2 condition - * (note that this case can be handled by the default term handler (1-8), but - * this special case is faster because it doesn't have to read memory twice) - * - * r0 = dpp->weight_B r8 = previous left sample - * r1 = bptr r9 = - * r2 = current sample r10 = second previous left sample << 4 - * r3 = previous right sample r11 = lo accumulator (for rounding) - * r4 = dpp->weight_A ip = decorrelation value - * r5 = dpp sp = - * r6 = dpp->delta lr = second previous right sample << 4 - * r7 = eptr pc = - ******************************************************************************* - */ - -term_2_loop: - movs ip, lr @ get decorrelation value & test - ldr r2, [r1], #4 @ get sample & update pointer - mov lr, r8, asl #4 @ previous becomes 2nd previous - mov r11, #0x80000000 - mov r8, r2 - smlalne r11, r8, r4, ip - strne r8, [r1, #-4] @ if change possible, store sample back - cmpne r2, #0 - beq .L225 - teq ip, r2 @ update weight based on signs - submi r4, r4, r6 - addpl r4, r4, r6 - -.L225: movs ip, r10 @ do same thing for right channel - ldr r2, [r1], #4 - mov r10, r3, asl #4 - mov r11, #0x80000000 - mov r3, r2 - smlalne r11, r3, r0, ip - strne r3, [r1, #-4] - cmpne r2, #0 - beq .L229 - teq ip, r2 - submi r0, r0, r6 - addpl r0, r0, r6 - -.L229: cmp r7, r1 @ loop back if more samples to do - bhi term_2_loop - - b default_term_exit @ this exit updates all dpp->samples - -/* - ****************************************************************************** - * Loop to handle default term condition - * - * r0 = dpp->weight_B r8 = result accumulator - * r1 = bptr r9 = - * r2 = dpp->term r10 = - * r3 = decorrelation value r11 = lo accumulator (for rounding) - * r4 = dpp->weight_A ip = current sample - * r5 = dpp sp = - * r6 = dpp->delta lr = - * r7 = eptr pc = - ******************************************************************************* - */ - -term_default_loop: - ldr r3, [r1, -r2, asl #3] @ get decorrelation value based on term - ldr ip, [r1], #4 @ get original sample and bump ptr - movs r3, r3, asl #4 - mov r11, #0x80000000 - mov r8, ip - smlalne r11, r8, r4, r3 - strne r8, [r1, #-4] @ if possibly changed, store updated sample - cmpne ip, #0 - beq .L350 - teq ip, r3 @ update weight based on signs - submi r4, r4, r6 - addpl r4, r4, r6 - -.L350: ldr r3, [r1, -r2, asl #3] @ do the same thing for right channel - ldr ip, [r1], #4 - movs r3, r3, asl #4 - mov r11, #0x80000000 - mov r8, ip - smlalne r11, r8, r0, r3 - strne r8, [r1, #-4] - cmpne ip, #0 - beq .L354 - teq ip, r3 - submi r0, r0, r6 - addpl r0, r0, r6 - -.L354: cmp r7, r1 @ loop back if more samples to do - bhi term_default_loop - -/* - * This exit is used by terms 1-8 to store the previous 8 samples into the decorr - * structure (even if they are not all used for the given term) - */ - -default_term_exit: - ldrsh r3, [r5, #0] - sub ip, r3, #1 - mov lr, #7 - -.L358: and r3, ip, #7 - add r3, r5, r3, asl #2 - ldr r2, [r1, #-4] - str r2, [r3, #40] - ldr r2, [r1, #-8]! - str r2, [r3, #8] - sub ip, ip, #1 - sub lr, lr, #1 - cmn lr, #1 - bne .L358 - b common_exit - -/* - ****************************************************************************** - * Loop to handle term = -1 condition - * - * r0 = dpp->weight_B r8 = - * r1 = bptr r9 = - * r2 = intermediate result r10 = -1024 (for clipping) - * r3 = previous right sample r11 = lo accumulator (for rounding) - * r4 = dpp->weight_A ip = current sample - * r5 = dpp sp = - * r6 = dpp->delta lr = updated left sample - * r7 = eptr pc = - ******************************************************************************* - */ - -term_minus_1: - ldr r3, [r1, #-4] - -term_minus_1_loop: - ldr ip, [r1], #8 @ for left channel the decorrelation value - movs r3, r3, asl #4 @ is the previous right sample (in r3) - mov r11, #0x80000000 - mov lr, ip - smlalne r11, lr, r4, r3 - strne lr, [r1, #-8] - cmpne ip, #0 - beq .L361 - teq ip, r3 @ update weight based on signs - submi r4, r4, r6 - addpl r4, r4, r6 - cmp r4, #(1024 << 18) - movgt r4, #(1024 << 18) - cmp r4, r10 - movlt r4, r10 - -.L361: ldr r2, [r1, #-4] @ for right channel the decorrelation value - movs lr, lr, asl #4 - mov r11, #0x80000000 - mov r3, r2 - smlalne r11, r3, r0, lr - strne r3, [r1, #-4] - cmpne r2, #0 - beq .L369 - teq r2, lr - submi r0, r0, r6 - addpl r0, r0, r6 - cmp r0, #(1024 << 18) @ then clip weight to +/-1024 - movgt r0, #(1024 << 18) - cmp r0, r10 - movlt r0, r10 - -.L369: cmp r7, r1 @ loop back if more samples to do - bhi term_minus_1_loop - - str r3, [r5, #8] @ else store right sample and exit - b common_exit - -/* - ****************************************************************************** - * Loop to handle term = -2 condition - * (note that the channels are processed in the reverse order here) - * - * r0 = dpp->weight_B r8 = - * r1 = bptr r9 = - * r2 = intermediate result r10 = -1024 (for clipping) - * r3 = previous left sample r11 = lo accumulator (for rounding) - * r4 = dpp->weight_A ip = current sample - * r5 = dpp sp = - * r6 = dpp->delta lr = updated right sample - * r7 = eptr pc = - ******************************************************************************* - */ - -term_minus_2: - ldr r3, [r1, #-8] - -term_minus_2_loop: - ldr ip, [r1, #4] @ for right channel the decorrelation value - movs r3, r3, asl #4 @ is the previous left sample (in r3) - mov r11, #0x80000000 - mov lr, ip - smlalne r11, lr, r0, r3 - strne lr, [r1, #4] - cmpne ip, #0 - beq .L380 - teq ip, r3 @ update weight based on signs - submi r0, r0, r6 - addpl r0, r0, r6 - cmp r0, #(1024 << 18) @ then clip weight to +/-1024 - movgt r0, #(1024 << 18) - cmp r0, r10 - movlt r0, r10 - -.L380: ldr r2, [r1], #8 @ for left channel the decorrelation value - movs lr, lr, asl #4 - mov r11, #0x80000000 - mov r3, r2 - smlalne r11, r3, r4, lr - strne r3, [r1, #-8] - cmpne r2, #0 - beq .L388 - teq r2, lr - submi r4, r4, r6 - addpl r4, r4, r6 - cmp r4, #(1024 << 18) - movgt r4, #(1024 << 18) - cmp r4, r10 - movlt r4, r10 - -.L388: cmp r7, r1 @ loop back if more samples to do - bhi term_minus_2_loop - - str r3, [r5, #40] @ else store left channel and exit - b common_exit - -/* - ****************************************************************************** - * Loop to handle term = -3 condition - * - * r0 = dpp->weight_B r8 = previous left sample - * r1 = bptr r9 = - * r2 = current left sample r10 = -1024 (for clipping) - * r3 = previous right sample r11 = lo accumulator (for rounding) - * r4 = dpp->weight_A ip = intermediate result - * r5 = dpp sp = - * r6 = dpp->delta lr = - * r7 = eptr pc = - ******************************************************************************* - */ - -term_minus_3: - ldr r3, [r1, #-4] @ load previous samples - ldr r8, [r1, #-8] - -term_minus_3_loop: - ldr ip, [r1], #4 - movs r3, r3, asl #4 - mov r11, #0x80000000 - mov r2, ip - smlalne r11, r2, r4, r3 - strne r2, [r1, #-4] - cmpne ip, #0 - beq .L399 - teq ip, r3 @ update weight based on signs - submi r4, r4, r6 - addpl r4, r4, r6 - cmp r4, #(1024 << 18) @ then clip weight to +/-1024 - movgt r4, #(1024 << 18) - cmp r4, r10 - movlt r4, r10 - -.L399: movs ip, r8, asl #4 @ ip = previous left we use now - mov r8, r2 @ r8 = current left we use next time - ldr r2, [r1], #4 - mov r11, #0x80000000 - mov r3, r2 - smlalne r11, r3, r0, ip - strne r3, [r1, #-4] - cmpne r2, #0 - beq .L407 - teq ip, r2 - submi r0, r0, r6 - addpl r0, r0, r6 - cmp r0, #(1024 << 18) - movgt r0, #(1024 << 18) - cmp r0, r10 - movlt r0, r10 - -.L407: cmp r7, r1 @ loop back if more samples to do - bhi term_minus_3_loop - - str r3, [r5, #8] @ else store previous samples & exit - str r8, [r5, #40] - -/* - * Before finally exiting we must store weights back for next time - */ - -common_exit: - mov r0, r0, asr #18 @ restore weights to real magnitude - mov r4, r4, asr #18 - strh r4, [r5, #4] - strh r0, [r5, #6] - ldmpc regs="r4-r8, r10-r11" - diff --git a/apps/codecs/libwavpack/bits.c b/apps/codecs/libwavpack/bits.c deleted file mode 100644 index 0f0e79c292..0000000000 --- a/apps/codecs/libwavpack/bits.c +++ /dev/null @@ -1,170 +0,0 @@ -//////////////////////////////////////////////////////////////////////////// -// **** WAVPACK **** // -// Hybrid Lossless Wavefile Compressor // -// Copyright (c) 1998 - 2004 Conifer Software. // -// All Rights Reserved. // -// Distributed under the BSD Software License (see license.txt) // -//////////////////////////////////////////////////////////////////////////// - -// bits.c - -// This module provides utilities to support the BitStream structure which is -// used to read and write all WavPack audio data streams. It also contains a -// wrapper for the stream I/O functions and a set of functions dealing with -// endian-ness, both for enhancing portability. Finally, a debug wrapper for -// the malloc() system is provided. - -#include "wavpack.h" -#include "system.h" - -#include - -////////////////////////// Bitstream functions //////////////////////////////// - -// Open the specified BitStream and associate with the specified buffer. - -static void bs_read (Bitstream *bs); - -void bs_open_read (Bitstream *bs, uchar *buffer_start, uchar *buffer_end, read_stream file, uint32_t file_bytes) -{ - CLEAR (*bs); - bs->buf = buffer_start; - bs->end = buffer_end; - - if (file) { - bs->ptr = bs->end - 1; - bs->file_bytes = file_bytes; - bs->file = file; - } - else - bs->ptr = bs->buf - 1; - - bs->wrap = bs_read; -} - -// This function is only called from the getbit() and getbits() macros when -// the BitStream has been exhausted and more data is required. Sinve these -// bistreams no longer access files, this function simple sets an error and -// resets the buffer. - -static void bs_read (Bitstream *bs) -{ - if (bs->file && bs->file_bytes) { - uint32_t bytes_read, bytes_to_read = bs->end - bs->buf; - - if (bytes_to_read > bs->file_bytes) - bytes_to_read = bs->file_bytes; - - bytes_read = bs->file (bs->buf, bytes_to_read); - - if (bytes_read) { - bs->end = bs->buf + bytes_read; - bs->file_bytes -= bytes_read; - } - else { - memset (bs->buf, -1, bs->end - bs->buf); - bs->error = 1; - } - } - else - bs->error = 1; - - if (bs->error) - memset (bs->buf, -1, bs->end - bs->buf); - - bs->ptr = bs->buf; -} - -// Open the specified BitStream using the specified buffer pointers. It is -// assumed that enough buffer space has been allocated for all data that will -// be written, otherwise an error will be generated. - -static void bs_write (Bitstream *bs); - -void bs_open_write (Bitstream *bs, uchar *buffer_start, uchar *buffer_end) -{ - bs->error = bs->sr = bs->bc = 0; - bs->ptr = bs->buf = buffer_start; - bs->end = buffer_end; - bs->wrap = bs_write; -} - -// This function is only called from the putbit() and putbits() macros when -// the buffer is full, which is now flagged as an error. - -static void bs_write (Bitstream *bs) -{ - bs->ptr = bs->buf; - bs->error = 1; -} - -// This function forces a flushing write of the specified BitStream, and -// returns the total number of bytes written into the buffer. - -uint32_t bs_close_write (Bitstream *bs) -{ - uint32_t bytes_written; - - if (bs->error) - return (uint32_t) -1; - - while (bs->bc || ((bs->ptr - bs->buf) & 1)) putbit_1 (bs); - bytes_written = bs->ptr - bs->buf; - CLEAR (*bs); - return bytes_written; -} - -/////////////////////// Endian Correction Routines //////////////////////////// - -void little_endian_to_native (void *data, char *format) -{ - uchar *cp = (uchar *) data; - - while (*format) { - switch (*format) { - case 'L': - *(long *)cp = letoh32(*(long *)cp); - cp += 4; - break; - - case 'S': - *(short *)cp = letoh16(*(short *)cp); - cp += 2; - break; - - default: - if (*format >= '0' && *format <= '9') - cp += *format - '0'; - - break; - } - - format++; - } -} - -void native_to_little_endian (void *data, char *format) -{ - uchar *cp = (uchar *) data; - - while (*format) { - switch (*format) { - case 'L': - *(long *)cp = htole32(*(long *)cp); - cp += 4; - break; - - case 'S': - *(short *)cp = htole16(*(short *)cp); - cp += 2; - break; - - default: - if (*format >= '0' && *format <= '9') - cp += *format - '0'; - break; - } - - format++; - } -} diff --git a/apps/codecs/libwavpack/coldfire.S b/apps/codecs/libwavpack/coldfire.S deleted file mode 100644 index 884a0ac90f..0000000000 --- a/apps/codecs/libwavpack/coldfire.S +++ /dev/null @@ -1,537 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2005 by David Bryant - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ - -/* This is an assembly optimized version of the following WavPack function: - * - * void decorr_stereo_pass_cont_mcf5249 (struct decorr_pass *dpp, - * long *buffer, long sample_count); - * - * It performs a single pass of stereo decorrelation on the provided buffer. - * Note that this version of the function requires that the 8 previous stereo - * samples are visible and correct. In other words, it ignores the "samples_*" - * fields in the decorr_pass structure and gets the history data directly - * from the buffer. It does, however, return the appropriate history samples - * to the decorr_pass structure before returning. - * - * This is written to work on a MCF5249 processor, or any processor based on - * the ColdFire V2 core with an EMAC unit. The EMAC is perfectly suited for - * the "apply_weight" function of WavPack decorrelation because it provides - * the requires 40-bit product. The fractional rounding mode of the EMAC is not - * configurable and uses "round to even" while WavPack uses "round to larger", - * so the rounding has to be done manually. - */ - - .text - .align 2 - .global decorr_stereo_pass_cont_mcf5249 - -decorr_stereo_pass_cont_mcf5249: - - lea (-44, %sp), %sp - movem.l %d2-%d7/%a2-%a6, (%sp) - move.l 44+4(%sp), %a2 | a2 = dpp-> - move.l 44+8(%sp), %a1 | a1 = bptr - move.w 2(%a2), %a3 | a3 = dpp->delta - move.w 4(%a2), %d3 | d3 = dpp->weight_A (sign extended) - ext.l %d3 - move.w 6(%a2), %d4 | d4 = dpp->weight_B (sign extended) - ext.l %d4 - move.l 44+12(%sp), %d0 | d0 = sample_count - jbeq return_only | if zero, nothing to do - - lsl.l #3, %d0 | d5 = bptr + (sample_count * 8) - move.l %d0, %d5 - add.l %a1, %d5 - - moveq.l #17, %d0 | left shift weights & delta 17 places - asl.l %d0, %d3 - asl.l %d0, %d4 - move.l %a3, %d1 - asl.l %d0, %d1 - move.l %d1, %a3 - - moveq.l #0x20, %d6 - move.l %d6, %macsr | set fractional mode for MAC - move.l #0x800000, %accext01 | acc1 = 0x00 0000 80 (for rounding) - - move.l #1024<<17, %d6 | d6 & d7 are weight clipping limits - move.l #-1024<<17, %d7 | (only used by negative terms) - - move.w (%a2), %d0 | d0 = term - ext.l %d0 - cmp.l #17, %d0 - jbeq term_17 | term = 17 - cmp.l #18, %d0 - jbeq term_18 | term = 18 - addq.l #1, %d0 - jbeq term_minus_1 | term = -1 - addq.l #1, %d0 - jbeq term_minus_2 | term = -2 - addq.l #1, %d0 - jbeq term_minus_3 | term = -3 - jbra term_default | default term = 1 - 8 - -|------------------------------------------------------------------------------ -| Loop to handle term = 17 condition -| -| a0 = d0 = (2 * bptr [-1]) - bptr [-2] -| a1 = bptr d1 = initial bptr [0] -| a2 = dpp-> d2 = updated bptr [0] -| a3 = dpp->delta << 17 d3 = dpp->weight_A << 17 -| a4 = d4 = dpp->weight_B << 17 -| a5 = d5 = eptr -| macsr = 0x20 acc1 = 0x00 0000 80 -|------------------------------------------------------------------------------ - -term_17: - move.l -8(%a1), %d0 | d0 = 2 * bptr [-1] - bptr [-2] - add.l %d0, %d0 - sub.l -16(%a1), %d0 - beq .L251 | if zero, skip calculation - move.l %acc1, %acc0 - asl.l #4, %d0 | acc0 = acc1 + (d0 << 4) * weight_A - mac.l %d0, %d3, %acc0 - move.l (%a1), %d1 - beq .L255 - eor.l %d1, %d0 | else compare signs - bge .L256 | if same, add delta to weight - sub.l %a3, %d3 | else subtract delta from weight - sub.l %a3, %d3 | subtract again instead of branch -.L256: add.l %a3, %d3 | add delta to weight - -.L255: move.l %acc0, %d2 | d2 = rounded product - add.l %d1, %d2 | update bptr [0] and store - move.l %d2, (%a1)+ - -.L253: move.l -8(%a1), %d0 | d0 = 2 * bptr [-1] - bptr [-2] - add.l %d0, %d0 - sub.l -16(%a1), %d0 - beq .L257 | if zero, skip calculations - move.l %acc1, %acc0 - asl.l #4, %d0 | acc0 = acc1 + (d0 << 4) * weight_B - mac.l %d0, %d4, %acc0 - move.l (%a1), %d1 - beq .L254 - eor.l %d1, %d0 | else compare signs - bge .L259 | if same, add delta to weight - sub.l %a3, %d4 | else subtract delta from weight - sub.l %a3, %d4 | subtract again instead of branch -.L259: add.l %a3, %d4 | add delta to weight - -.L254: move.l %acc0, %d2 | d2 = rounded product - add.l %d1, %d2 | update bptr [0] and store - move.l %d2, (%a1)+ - -.L252: cmp.l %a1, %d5 | loop if bptr < eptr - jbhi term_17 - bra term_17_18_finish | exit through common path - -.L251: addq.l #4, %a1 | update point and jump back into loop - bra .L253 - -.L257: addq.l #4, %a1 | update point and jump back into loop - bra .L252 - -|------------------------------------------------------------------------------ -| Loop to handle term = 18 condition -| -| a0 = d0 = ((3 * bptr [-1]) - bptr [-2]) >> 1 -| a1 = bptr d1 = initial bptr [0] -| a2 = dpp-> d2 = updated bptr [0] -| a3 = dpp->delta << 17 d3 = dpp->weight_A << 17 -| a4 = d4 = dpp->weight_B << 17 -| a5 = d5 = eptr -| macsr = 0x20 acc1 = 0x00 0000 80 -|------------------------------------------------------------------------------ - -term_18: - move.l -8(%a1), %a0 | d0 = (3 * bptr [-1] - bptr [-2]) >> 1 - lea (%a0,%a0.l*2), %a0 - move.l %a0, %d0 - sub.l -16(%a1), %d0 - asr.l #1, %d0 - beq .L260 - move.l %acc1, %acc0 - asl.l #4, %d0 | acc0 = acc1 + (d0 << 4) * weight_A - mac.l %d0, %d3, %acc0 - move.l (%a1), %d1 - beq .L266 - eor.l %d1, %d0 | else compare signs - bge .L267 | if same, add delta to weight - sub.l %a3, %d3 | else subtract delta from weight - sub.l %a3, %d3 | subtract again instead of branch -.L267: add.l %a3, %d3 | add delta to weight - -.L266: move.l %acc0, %d2 | d2 = rounded product - add.l %d1, %d2 | add applied weight to bptr [0], store - move.l %d2, (%a1)+ - -.L268: move.l -8(%a1), %a0 | d0 = (3 * bptr [-1] - bptr [-2]) >> 1 - lea (%a0,%a0.l*2), %a0 - move.l %a0, %d0 - sub.l -16(%a1), %d0 - asr.l #1, %d0 - beq .L261 - move.l %acc1, %acc0 - asl.l #4, %d0 | acc0 = acc1 + (d0 << 4) * weight_B - mac.l %d0, %d4, %acc0 - move.l (%a1), %d1 - beq .L265 - eor.l %d1, %d0 | else compare signs - bge .L270 | if same, add delta to weight - sub.l %a3, %d4 | else subtract delta from weight - sub.l %a3, %d4 | subtract again instead of branch -.L270: add.l %a3, %d4 | add delta to weight - -.L265: move.l %acc0, %d2 | d2 = rounded product - add.l %d1, %d2 | add applied weight to bptr [0], store - move.l %d2, (%a1)+ - -.L269: cmp.l %a1, %d5 | loop if bptr < eptr - jbhi term_18 - bra term_17_18_finish | exit through common path - -.L260: addq.l #4, %a1 | bump pointer and jump back into loop - bra .L268 - -.L261: addq.l #4, %a1 | bump pointer and jump back into loop - bra .L269 - -term_17_18_finish: - move.l -4(%a1), 40(%a2) | restore dpp->samples_A [0-1], B [0-1] - move.l -8(%a1), 8(%a2) - move.l -12(%a1), 44(%a2) - move.l -16(%a1), 12(%a2) - jbra finish_up - -|------------------------------------------------------------------------------ -| Loop to handle default terms (i.e. 1 - 8) -| -| a0 = tptr d0 = tptr [0] -| a1 = bptr d1 = initial bptr [0] -| a2 = dpp-> d2 = updated bptr [0] -| a3 = dpp->delta << 17 d3 = dpp->weight_A << 17 -| a4 = d4 = dpp->weight_B << 17 -| a5 = d5 = eptr -| macsr = 0x20 acc1 = 0x00 0000 80 -|------------------------------------------------------------------------------ - -term_default: - move.w (%a2), %d0 | a0 = a1 - (dpp->term * 8) - ext.l %d0 - lsl.l #3, %d0 - move.l %a1, %a0 - sub.l %d0, %a0 - -term_default_loop: - move.l (%a0)+, %d0 | d0 = tptr [0], skip ahead if zero - beq .L271 - move.l %acc1, %acc0 - asl.l #4, %d0 | acc0 = acc1 + (d0 << 4) * weight_A - mac.l %d0, %d3, %acc0 - move.l (%a1), %d1 - beq .L277 - eor.l %d1, %d0 | else compare signs - bge .L278 | if same, add delta to weight - sub.l %a3, %d3 | else subtract delta from weight - sub.l %a3, %d3 | subtract again instead of branch -.L278: add.l %a3, %d3 | add delta to weight - -.L277: move.l %acc0, %d2 | d2 = rounded product - add.l %d1, %d2 | add applied weight to bptr [0], store - move.l %d2, (%a1)+ - -.L275: move.l (%a0)+, %d0 | d0 = tptr [0], skip ahead if zero - beq .L272 - move.l %acc1, %acc0 - asl.l #4, %d0 | acc0 = acc1 + (d0 << 4) * weight_B - mac.l %d0, %d4, %acc0 - move.l (%a1), %d1 - beq .L276 - eor.l %d1, %d0 | else compare signs - bge .L281 | if same, add delta to weight - sub.l %a3, %d4 | else subtract delta from weight - sub.l %a3, %d4 | subtract again instead of branch -.L281: add.l %a3, %d4 | add delta to weight - -.L276: move.l %acc0, %d2 | d2 = rounded product - add.l %d1, %d2 | add applied weight to bptr [0], store - move.l %d2, (%a1)+ - -.L274: cmp.l %a1, %d5 | loop back if bptr < eptr - jbhi term_default_loop - move.w (%a2), %d0 | d0 = term - 1 - moveq.l #8, %d1 | d1 = loop counter - -.L323: subq.l #1, %d0 | back up & mask index - and.l #7, %d0 - move.l -(%a1), 40(%a2,%d0.l*4) | store dpp->samples_B [d0] - move.l -(%a1), 8(%a2,%d0.l*4) | store dpp->samples_A [d0] - subq.l #1, %d1 | loop on count - jbne .L323 - jbra finish_up - -.L271: addq.l #4, %a1 | bump pointer and jump back into loop - bra .L275 - -.L272: addq.l #4, %a1 | bump pointer and jump back into loop - bra .L274 - - -|------------------------------------------------------------------------------ -| Loop to handle term = -1 condition -| -| a0 = d0 = decorrelation sample -| a1 = bptr d1 = initial bptr [0] -| a2 = dpp-> d2 = updated bptr [0] -| a3 = dpp->delta << 17 d3 = dpp->weight_A << 17 -| a4 = d4 = dpp->weight_B << 17 -| a5 = d5 = eptr -| a6 = d6 = 1024 << 17 -| a7 = d7 = -1024 << 17 -| macsr = 0x20 acc1 = 0x00 0000 80 -|------------------------------------------------------------------------------ - -term_minus_1: - move.l -4(%a1), %d0 | d0 = bptr [-1] - beq .L402 - move.l %acc1, %acc0 - asl.l #4, %d0 | acc0 = acc1 + ((d0 << 4) * weight_A) - mac.l %d0, %d3, %acc0 - move.l (%a1), %d1 - beq .L405 - eor.l %d1, %d0 | else compare signs - bge .L404 | if same, add delta to weight - sub.l %a3, %d3 | else subtract delta from weight - cmp.l %d7, %d3 | check for negative clip limit - bge .L405 - move.l %d7, %d3 - bra .L405 - -.L404: add.l %a3, %d3 | add delta to weight - cmp.l %d6, %d3 | check for positive clip limit - ble .L405 - move.l %d6, %d3 - -.L405: move.l %acc0, %d0 | d2 = rounded product - add.l %d1, %d0 | add applied weight to bptr [0], store - move.l %d0, (%a1)+ - beq .L401 - -.L410: move.l %acc1, %acc0 - asl.l #4, %d0 | acc0 = acc1 + ((d0 << 4) * weight_B) - mac.l %d0, %d4, %acc0 - move.l (%a1), %d1 - beq .L403 - eor.l %d1, %d0 | else compare signs - bge .L407 | if same, add delta to weight - sub.l %a3, %d4 | else subtract delta from weight - cmp.l %d7, %d4 | check for negative clip limit - bge .L403 - move.l %d7, %d4 - bra .L403 - -.L407: add.l %a3, %d4 | add delta to weight - cmp.l %d6, %d4 | check for positive clip limit - ble .L403 - move.l %d6, %d4 - -.L403: move.l %acc0, %d2 | d2 = rounded product - add.l %d1, %d2 | add applied weight to bptr [1], store - move.l %d2, (%a1)+ - -.L411: cmp.l %a1, %d5 | loop back if bptr < eptr - jbhi term_minus_1 - move.l -4(%a1), 8(%a2) | dpp->samples_A [0] = bptr [-1] - jbra finish_up - -.L402: move.l (%a1)+, %d0 - bne .L410 - -.L401: addq.l #4, %a1 - bra .L411 - - -|------------------------------------------------------------------------------ -| Loop to handle term = -2 condition -| -| a0 = d0 = decorrelation sample -| a1 = bptr d1 = initial bptr [0] -| a2 = dpp-> d2 = updated bptr [0] -| a3 = dpp->delta << 17 d3 = dpp->weight_A << 17 -| a4 = d4 = dpp->weight_B << 17 -| a5 = d5 = eptr -| a6 = d6 = 1024 << 17 -| a7 = d7 = -1024 << 17 -| macsr = 0x20 acc1 = 0x00 0000 80 -|------------------------------------------------------------------------------ - -term_minus_2: - move.l -8(%a1), %d0 | d0 = bptr [-2] - beq .L511 - move.l %acc1, %acc0 - asl.l #4, %d0 | acc0 = acc1 + ((d0 << 4) * weight_B) - mac.l %d0, %d4, %acc0 - move.l 4(%a1), %d1 - beq .L505 - eor.l %d1, %d0 | else compare signs - bge .L504 | if same, add delta to weight - sub.l %a3, %d4 | else subtract delta from weight - cmp.l %d7, %d4 | ckeck for negative clip limit - bge .L505 - move.l %d7, %d4 - bra .L505 - -.L504: add.l %a3, %d4 | add delta to weight - cmp.l %d6, %d4 | check for positive clip limit - ble .L505 - move.l %d6, %d4 - -.L505: move.l %acc0, %d0 | d2 = rounded product - add.l %d1, %d0 | add applied weight to bptr [0], store - move.l %d0, 4(%a1) - beq .L512 - -.L510: move.l %acc1, %acc0 - asl.l #4, %d0 | acc0 = acc1 + ((d0 << 4) * weight_A) - mac.l %d0, %d3, %acc0 - move.l (%a1), %d1 - beq .L503 - eor.l %d1, %d0 | else compare signs - bge .L507 | if same, add delta to weight - sub.l %a3, %d3 | else subtract delta from weight - cmp.l %d7, %d3 | check for negative clip limit - bge .L503 - move.l %d7, %d3 - bra .L503 - -.L507: add.l %a3, %d3 | add delta to weight - cmp.l %d6, %d3 | check for negative clip limit - ble .L503 - move.l %d6, %d3 - -.L503: move.l %acc0, %d2 | d2 = rounded product - add.l %d1, %d2 | add applied weight to bptr [1], store - move.l %d2, (%a1) - -.L512: addq.l #8, %a1 - cmp.l %a1, %d5 | loop if bptr < eptr - jbhi term_minus_2 - move.l -8(%a1), 40(%a2) | dpp->samples_B [0] = bptr [-4] - jbra finish_up - -.L511: move.l 4(%a1), %d0 - beq .L512 - bra .L510 - - -|------------------------------------------------------------------------------ -| Loop to handle term = -3 condition -| -| a0 = d0 = decorrelation sample -| a1 = bptr d1 = initial bptr [0] -| a2 = dpp-> d2 = updated bptr [0] -| a3 = dpp->delta << 17 d3 = dpp->weight_A << 17 -| a4 = d4 = dpp->weight_B << 17 -| a5 = d5 = eptr -| a6 = d6 = 1024 << 17 -| a7 = d7 = -1024 << 17 -| macsr = 0x20 acc1 = 0x00 0000 80 -|------------------------------------------------------------------------------ - -term_minus_3: - move.l -4(%a1), %d0 | d0 = bptr [-1] - beq .L301 - move.l %acc1, %acc0 - asl.l #4, %d0 | acc0 = acc1 + ((d0 << 4) * weight_A) - mac.l %d0, %d3, %acc0 - move.l (%a1), %d1 - beq .L320 - eor.l %d1, %d0 | else compare signs - bge .L319 | if same, add delta to weight - sub.l %a3, %d3 | else subtract delta from weight - cmp.l %d7, %d3 | check for negative clip limit - bge .L320 - move.l %d7, %d3 - bra .L320 - -.L319: add.l %a3, %d3 | add delta to weight - cmp.l %d6, %d3 | check for positive clip limit - ble .L320 - move.l %d6, %d3 - -.L320: move.l %acc0, %d2 | d2 = rounded product - add.l %d1, %d2 | add applied weight to bptr [0], store - move.l %d2, (%a1)+ - -.L330: move.l -12(%a1), %d0 | d0 = bptr [-2] - beq .L302 - move.l %acc1, %acc0 - asl.l #4, %d0 | acc0 = acc1 + ((d0 << 4) * weight_B) - mac.l %d0, %d4, %acc0 - move.l (%a1), %d1 - beq .L318 - eor.l %d1, %d0 | else compare signs - bge .L322 | if same, add delta to weight - sub.l %a3, %d4 | else subtract delta from weight - cmp.l %d7, %d4 | check for negative clip limit - bge .L318 - move.l %d7, %d4 - bra .L318 - -.L322: add.l %a3, %d4 | add delta to weight - cmp.l %d6, %d4 | check for positive clip limit - ble .L318 - move.l %d6, %d4 - -.L318: move.l %acc0, %d2 | d2 = rounded product - add.l %d1, %d2 | add applied weight to bptr [1], store - move.l %d2, (%a1)+ - -.L331: cmp.l %a1, %d5 | bptr, eptr - jbhi term_minus_3 - move.l -4(%a1), 8(%a2) | dpp->samples_A [0] = bptr [-1] - move.l -8(%a1), 40(%a2) | dpp->samples_B [0] = bptr [-2] - jbra finish_up - -.L301: addq.l #4, %a1 - bra .L330 - -.L302: addq.l #4, %a1 - bra .L331 - -| finish and return - -finish_up: - moveq.l #17, %d0 - asr.l %d0, %d3 - asr.l %d0, %d4 - move.w %d3, 4(%a2) | weight_A, dpp->weight_A - move.w %d4, 6(%a2) | weight_B, dpp->weight_B - - clr.l %d0 | clear up EMAC - move.l %d0, %acc0 - move.l %d0, %acc1 - -return_only: - movem.l (%sp), %d2-%d7/%a2-%a6 - lea (44,%sp), %sp - rts diff --git a/apps/codecs/libwavpack/float.c b/apps/codecs/libwavpack/float.c deleted file mode 100644 index 6e5c4e4f61..0000000000 --- a/apps/codecs/libwavpack/float.c +++ /dev/null @@ -1,47 +0,0 @@ -//////////////////////////////////////////////////////////////////////////// -// **** WAVPACK **** // -// Hybrid Lossless Wavefile Compressor // -// Copyright (c) 1998 - 2004 Conifer Software. // -// All Rights Reserved. // -// Distributed under the BSD Software License (see license.txt) // -//////////////////////////////////////////////////////////////////////////// - -// float.c - -#include "wavpack.h" - -int read_float_info (WavpackStream *wps, WavpackMetadata *wpmd) -{ - int bytecnt = wpmd->byte_length; - char *byteptr = wpmd->data; - - if (bytecnt != 4) - return FALSE; - - wps->float_flags = *byteptr++; - wps->float_shift = *byteptr++; - wps->float_max_exp = *byteptr++; - wps->float_norm_exp = *byteptr; - return TRUE; -} - -/* This function converts WavPack floating point data into standard Rockbox - * 28-bit integers. It is assumed that clipping will be taken care of later. - */ - -void float_values (WavpackStream *wps, int32_t *values, int32_t num_values) -{ - int shift = wps->float_max_exp - wps->float_norm_exp + wps->float_shift + 5; - - if (shift > 32) - shift = 32; - else if (shift < -32) - shift = -32; - - if (shift > 0) - while (num_values--) - *values++ <<= shift; - else if (shift < 0) - while (num_values--) - *values++ >>= -shift; -} diff --git a/apps/codecs/libwavpack/libwavpack.make b/apps/codecs/libwavpack/libwavpack.make deleted file mode 100644 index a2e5377418..0000000000 --- a/apps/codecs/libwavpack/libwavpack.make +++ /dev/null @@ -1,18 +0,0 @@ -# __________ __ ___. -# Open \______ \ ____ ____ | | _\_ |__ _______ ___ -# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / -# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < -# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ -# \/ \/ \/ \/ \/ -# $Id$ -# - -# libwavpack -WAVPACKLIB := $(CODECDIR)/libwavpack.a -WAVPACKLIB_SRC := $(call preprocess, $(APPSDIR)/codecs/libwavpack/SOURCES) -WAVPACKLIB_OBJ := $(call c2obj, $(WAVPACKLIB_SRC)) -OTHER_SRC += $(WAVPACKLIB_SRC) - -$(WAVPACKLIB): $(WAVPACKLIB_OBJ) - $(SILENT)$(shell rm -f $@) - $(call PRINTS,AR $(@F))$(AR) rcs $@ $^ >/dev/null diff --git a/apps/codecs/libwavpack/make.bat b/apps/codecs/libwavpack/make.bat deleted file mode 100644 index 0ca72d7e55..0000000000 --- a/apps/codecs/libwavpack/make.bat +++ /dev/null @@ -1 +0,0 @@ -cl /O1 /DWIN32 wvfilter.c wputils.c unpack.c float.c metadata.c words.c bits.c diff --git a/apps/codecs/libwavpack/metadata.c b/apps/codecs/libwavpack/metadata.c deleted file mode 100644 index 4dce10100f..0000000000 --- a/apps/codecs/libwavpack/metadata.c +++ /dev/null @@ -1,171 +0,0 @@ -//////////////////////////////////////////////////////////////////////////// -// **** WAVPACK **** // -// Hybrid Lossless Wavefile Compressor // -// Copyright (c) 1998 - 2003 Conifer Software. // -// All Rights Reserved. // -// Distributed under the BSD Software License (see license.txt) // -//////////////////////////////////////////////////////////////////////////// - -// metadata.c - -// This module handles the metadata structure introduced in WavPack 4.0 - -#include "wavpack.h" - -#include - -int read_metadata_buff (WavpackContext *wpc, WavpackMetadata *wpmd) -{ - uint32_t bytes_to_read; - uchar tchar; - - if (wpc->stream.block_bytes_left < 2 || !wpc->infile (&wpmd->id, 1) || !wpc->infile (&tchar, 1)) - return FALSE; - - wpmd->byte_length = tchar << 1; - wpc->stream.block_bytes_left -= 2; - - if (wpmd->id & ID_LARGE) { - wpmd->id &= ~ID_LARGE; - - if (wpc->stream.block_bytes_left < 2 || !wpc->infile (&tchar, 1)) - return FALSE; - - wpmd->byte_length += (int32_t) tchar << 9; - - if (!wpc->infile (&tchar, 1)) - return FALSE; - - wpmd->byte_length += (int32_t) tchar << 17; - wpc->stream.block_bytes_left -= 2; - } - - if ((wpc->stream.block_bytes_left -= wpmd->byte_length) < 0) - return FALSE; - - if (wpmd->id & ID_ODD_SIZE) { - wpmd->id &= ~ID_ODD_SIZE; - wpmd->byte_length--; - } - - if (!wpmd->byte_length || wpmd->id == ID_WV_BITSTREAM) { - wpmd->data = NULL; - return TRUE; - } - - bytes_to_read = wpmd->byte_length + (wpmd->byte_length & 1); - - if (bytes_to_read > sizeof (wpc->read_buffer)) { - wpmd->data = NULL; - - while (bytes_to_read > sizeof (wpc->read_buffer)) - if (wpc->infile (wpc->read_buffer, sizeof (wpc->read_buffer)) == sizeof (wpc->read_buffer)) - bytes_to_read -= sizeof (wpc->read_buffer); - else - return FALSE; - } - else - wpmd->data = wpc->read_buffer; - - if (bytes_to_read && wpc->infile (wpc->read_buffer, bytes_to_read) != (int32_t) bytes_to_read) { - wpmd->data = NULL; - return FALSE; - } - - return TRUE; -} - -int process_metadata (WavpackContext *wpc, WavpackMetadata *wpmd) -{ - WavpackStream *wps = &wpc->stream; - - switch (wpmd->id) { - case ID_DUMMY: - return TRUE; - - case ID_DECORR_TERMS: - return read_decorr_terms (wps, wpmd); - - case ID_DECORR_WEIGHTS: - return read_decorr_weights (wps, wpmd); - - case ID_DECORR_SAMPLES: - return read_decorr_samples (wps, wpmd); - - case ID_ENTROPY_VARS: - return read_entropy_vars (wps, wpmd); - - case ID_HYBRID_PROFILE: - return read_hybrid_profile (wps, wpmd); - - case ID_FLOAT_INFO: - return read_float_info (wps, wpmd); - - case ID_INT32_INFO: - return read_int32_info (wps, wpmd); - - case ID_CHANNEL_INFO: - return read_channel_info (wpc, wpmd); - - case ID_SAMPLE_RATE: - return read_sample_rate (wpc, wpmd); - - case ID_CONFIG_BLOCK: - return read_config_info (wpc, wpmd); - - case ID_WV_BITSTREAM: - return init_wv_bitstream (wpc, wpmd); - - case ID_SHAPING_WEIGHTS: - case ID_WVC_BITSTREAM: - case ID_WVX_BITSTREAM: - return TRUE; - - default: - return (wpmd->id & ID_OPTIONAL_DATA) ? TRUE : FALSE; - } -} - -int copy_metadata (WavpackMetadata *wpmd, uchar *buffer_start, uchar *buffer_end) -{ - uint32_t mdsize = wpmd->byte_length + (wpmd->byte_length & 1); - WavpackHeader *wphdr = (WavpackHeader *) buffer_start; - - if (wpmd->byte_length & 1) - ((char *) wpmd->data) [wpmd->byte_length] = 0; - - mdsize += (wpmd->byte_length > 510) ? 4 : 2; - buffer_start += wphdr->ckSize + 8; - - if (buffer_start + mdsize >= buffer_end) - return FALSE; - - buffer_start [0] = wpmd->id | (wpmd->byte_length & 1 ? ID_ODD_SIZE : 0); - buffer_start [1] = (wpmd->byte_length + 1) >> 1; - - if (wpmd->byte_length > 510) { - buffer_start [0] |= ID_LARGE; - buffer_start [2] = (wpmd->byte_length + 1) >> 9; - buffer_start [3] = (wpmd->byte_length + 1) >> 17; - } - - if (wpmd->data && wpmd->byte_length) { - if (wpmd->byte_length > 510) { - buffer_start [0] |= ID_LARGE; - buffer_start [2] = (wpmd->byte_length + 1) >> 9; - buffer_start [3] = (wpmd->byte_length + 1) >> 17; - memcpy (buffer_start + 4, wpmd->data, mdsize - 4); - } - else - memcpy (buffer_start + 2, wpmd->data, mdsize - 2); - } - - wphdr->ckSize += mdsize; - return TRUE; -} - -void free_metadata (WavpackMetadata *wpmd) -{ - wpmd->data = NULL; -} - diff --git a/apps/codecs/libwavpack/pack.c b/apps/codecs/libwavpack/pack.c deleted file mode 100644 index a46d05fe14..0000000000 --- a/apps/codecs/libwavpack/pack.c +++ /dev/null @@ -1,470 +0,0 @@ -//////////////////////////////////////////////////////////////////////////// -// **** WAVPACK **** // -// Hybrid Lossless Wavefile Compressor // -// Copyright (c) 1998 - 2005 Conifer Software. // -// All Rights Reserved. // -// Distributed under the BSD Software License (see license.txt) // -//////////////////////////////////////////////////////////////////////////// - -// pack.c - -// This module actually handles the compression of the audio data, except for -// the entropy coding which is handled by the words? modules. For efficiency, -// the conversion is isolated to tight loops that handle an entire buffer. - -#include "wavpack.h" - -#include - -// This flag provides faster encoding speed at the expense of more code. The -// improvement applies to 16-bit stereo lossless only. - -//////////////////////////////// local tables /////////////////////////////// - -// These two tables specify the characteristics of the decorrelation filters. -// Each term represents one layer of the sequential filter, where positive -// values indicate the relative sample involved from the same channel (1=prev), -// 17 & 18 are special functions using the previous 2 samples, and negative -// values indicate cross channel decorrelation (in stereo only). - -static const signed char default_terms [] = { 18,18,2,3,-2,0 }; -static const signed char high_terms [] = { 18,18,2,3,-2,18,2,4,7,5,3,6,0 }; -static const signed char fast_terms [] = { 17,17,0 }; - -///////////////////////////// executable code //////////////////////////////// - -// This function initializes everything required to pack WavPack bitstreams -// and must be called BEFORE any other function in this module. - -void pack_init (WavpackContext *wpc) -{ - WavpackStream *wps = &wpc->stream; - uint32_t flags = wps->wphdr.flags; - struct decorr_pass *dpp; - const signed char *term_string; - int ti; - - wps->sample_index = 0; - CLEAR (wps->decorr_passes); - - if (wpc->config.flags & CONFIG_HIGH_FLAG) - term_string = high_terms; - else if (wpc->config.flags & CONFIG_FAST_FLAG) - term_string = fast_terms; - else - term_string = default_terms; - - for (dpp = wps->decorr_passes, ti = 0; term_string [ti]; ti++) - if (term_string [ti] >= 0 || (flags & CROSS_DECORR)) { - dpp->term = term_string [ti]; - dpp++->delta = 2; - } - else if (!(flags & MONO_FLAG)) { - dpp->term = -3; - dpp++->delta = 2; - } - - wps->num_terms = dpp - wps->decorr_passes; - init_words (wps); -} - -// Allocate room for and copy the decorrelation terms from the decorr_passes -// array into the specified metadata structure. Both the actual term id and -// the delta are packed into single characters. - -static void write_decorr_terms (WavpackStream *wps, WavpackMetadata *wpmd) -{ - int tcount = wps->num_terms; - struct decorr_pass *dpp; - char *byteptr; - - byteptr = wpmd->data = wpmd->temp_data; - wpmd->id = ID_DECORR_TERMS; - - for (dpp = wps->decorr_passes; tcount--; ++dpp) - *byteptr++ = ((dpp->term + 5) & 0x1f) | ((dpp->delta << 5) & 0xe0); - - wpmd->byte_length = byteptr - (char *) wpmd->data; -} - -// Allocate room for and copy the decorrelation term weights from the -// decorr_passes array into the specified metadata structure. The weights -// range +/-1024, but are rounded and truncated to fit in signed chars for -// metadata storage. Weights are separate for the two channels - -static void write_decorr_weights (WavpackStream *wps, WavpackMetadata *wpmd) -{ - int tcount = wps->num_terms; - struct decorr_pass *dpp; - signed char *byteptr; - - byteptr = wpmd->data = wpmd->temp_data; - wpmd->id = ID_DECORR_WEIGHTS; - - for (dpp = wps->decorr_passes; tcount--; ++dpp) { - dpp->weight_A = restore_weight (*byteptr++ = store_weight (dpp->weight_A)); - - if (!(wps->wphdr.flags & MONO_FLAG)) - dpp->weight_B = restore_weight (*byteptr++ = store_weight (dpp->weight_B)); - } - - wpmd->byte_length = byteptr - (signed char *) wpmd->data; -} - -// Allocate room for and copy the decorrelation samples from the decorr_passes -// array into the specified metadata structure. The samples are signed 32-bit -// values, but are converted to signed log2 values for storage in metadata. -// Values are stored for both channels and are specified from the first term -// with unspecified samples set to zero. The number of samples stored varies -// with the actual term value, so those must obviously be specified before -// these in the metadata list. Any number of terms can have their samples -// specified from no terms to all the terms, however I have found that -// sending more than the first term's samples is a waste. The "wcount" -// variable can be set to the number of terms to have their samples stored. - -static void write_decorr_samples (WavpackStream *wps, WavpackMetadata *wpmd) -{ - int tcount = wps->num_terms, wcount = 1, temp; - struct decorr_pass *dpp; - uchar *byteptr; - - byteptr = wpmd->data = wpmd->temp_data; - wpmd->id = ID_DECORR_SAMPLES; - - for (dpp = wps->decorr_passes; tcount--; ++dpp) - if (wcount) { - if (dpp->term > MAX_TERM) { - dpp->samples_A [0] = exp2s (temp = log2s (dpp->samples_A [0])); - *byteptr++ = temp; - *byteptr++ = temp >> 8; - dpp->samples_A [1] = exp2s (temp = log2s (dpp->samples_A [1])); - *byteptr++ = temp; - *byteptr++ = temp >> 8; - - if (!(wps->wphdr.flags & MONO_FLAG)) { - dpp->samples_B [0] = exp2s (temp = log2s (dpp->samples_B [0])); - *byteptr++ = temp; - *byteptr++ = temp >> 8; - dpp->samples_B [1] = exp2s (temp = log2s (dpp->samples_B [1])); - *byteptr++ = temp; - *byteptr++ = temp >> 8; - } - } - else if (dpp->term < 0) { - dpp->samples_A [0] = exp2s (temp = log2s (dpp->samples_A [0])); - *byteptr++ = temp; - *byteptr++ = temp >> 8; - dpp->samples_B [0] = exp2s (temp = log2s (dpp->samples_B [0])); - *byteptr++ = temp; - *byteptr++ = temp >> 8; - } - else { - int m = 0, cnt = dpp->term; - - while (cnt--) { - dpp->samples_A [m] = exp2s (temp = log2s (dpp->samples_A [m])); - *byteptr++ = temp; - *byteptr++ = temp >> 8; - - if (!(wps->wphdr.flags & MONO_FLAG)) { - dpp->samples_B [m] = exp2s (temp = log2s (dpp->samples_B [m])); - *byteptr++ = temp; - *byteptr++ = temp >> 8; - } - - m++; - } - } - - wcount--; - } - else { - CLEAR (dpp->samples_A); - CLEAR (dpp->samples_B); - } - - wpmd->byte_length = byteptr - (uchar *) wpmd->data; -} - -// Allocate room for and copy the configuration information into the specified -// metadata structure. Currently, we just store the upper 3 bytes of -// config.flags and only in the first block of audio data. Note that this is -// for informational purposes not required for playback or decoding (like -// whether high or fast mode was specified). - -static void write_config_info (WavpackContext *wpc, WavpackMetadata *wpmd) -{ - char *byteptr; - - byteptr = wpmd->data = wpmd->temp_data; - wpmd->id = ID_CONFIG_BLOCK; - *byteptr++ = (char) (wpc->config.flags >> 8); - *byteptr++ = (char) (wpc->config.flags >> 16); - *byteptr++ = (char) (wpc->config.flags >> 24); - wpmd->byte_length = byteptr - (char *) wpmd->data; -} - -// Pack an entire block of samples (either mono or stereo) into a completed -// WavPack block. It is assumed that there is sufficient space for the -// completed block at "wps->blockbuff" and that "wps->blockend" points to the -// end of the available space. A return value of FALSE indicates an error. -// Any unsent metadata is transmitted first, then required metadata for this -// block is sent, and finally the compressed integer data is sent. If a "wpx" -// stream is required for floating point data or large integer data, then this -// must be handled outside this function. To find out how much data was written -// the caller must look at the ckSize field of the written WavpackHeader, NOT -// the one in the WavpackStream. - -int pack_start_block (WavpackContext *wpc) -{ - WavpackStream *wps = &wpc->stream; - WavpackMetadata wpmd; - - memcpy (wps->blockbuff, &wps->wphdr, sizeof (WavpackHeader)); - - ((WavpackHeader *) wps->blockbuff)->ckSize = sizeof (WavpackHeader) - 8; - ((WavpackHeader *) wps->blockbuff)->block_index = wps->sample_index; - ((WavpackHeader *) wps->blockbuff)->block_samples = 0; - ((WavpackHeader *) wps->blockbuff)->crc = 0xffffffff; - - if (wpc->wrapper_bytes) { - wpmd.id = ID_RIFF_HEADER; - wpmd.byte_length = wpc->wrapper_bytes; - wpmd.data = wpc->wrapper_data; - copy_metadata (&wpmd, wps->blockbuff, wps->blockend); - free_metadata (&wpmd); - wpc->wrapper_data = NULL; - wpc->wrapper_bytes = 0; - } - - write_decorr_terms (wps, &wpmd); - copy_metadata (&wpmd, wps->blockbuff, wps->blockend); - free_metadata (&wpmd); - - write_decorr_weights (wps, &wpmd); - copy_metadata (&wpmd, wps->blockbuff, wps->blockend); - free_metadata (&wpmd); - - write_decorr_samples (wps, &wpmd); - copy_metadata (&wpmd, wps->blockbuff, wps->blockend); - free_metadata (&wpmd); - - write_entropy_vars (wps, &wpmd); - copy_metadata (&wpmd, wps->blockbuff, wps->blockend); - free_metadata (&wpmd); - - if ((wps->wphdr.flags & INITIAL_BLOCK) && !wps->sample_index) { - write_config_info (wpc, &wpmd); - copy_metadata (&wpmd, wps->blockbuff, wps->blockend); - free_metadata (&wpmd); - } - - bs_open_write (&wps->wvbits, wps->blockbuff + ((WavpackHeader *) wps->blockbuff)->ckSize + 12, wps->blockend); - - return TRUE; -} - -static void decorr_stereo_pass (struct decorr_pass *dpp, int32_t *bptr, int32_t *eptr, int m); -static void decorr_stereo_pass_18 (struct decorr_pass *dpp, int32_t *bptr, int32_t *eptr); -static void decorr_stereo_pass_17 (struct decorr_pass *dpp, int32_t *bptr, int32_t *eptr); -static void decorr_stereo_pass_m2 (struct decorr_pass *dpp, int32_t *bptr, int32_t *eptr); - -int pack_samples (WavpackContext *wpc, int32_t *buffer, uint32_t sample_count) -{ - WavpackStream *wps = &wpc->stream; - uint32_t flags = wps->wphdr.flags; - struct decorr_pass *dpp; - int32_t *bptr, *eptr; - int tcount, m; - uint32_t crc; - - if (!sample_count) - return TRUE; - - eptr = buffer + sample_count * ((flags & MONO_FLAG) ? 1 : 2); - m = ((WavpackHeader *) wps->blockbuff)->block_samples & (MAX_TERM - 1); - crc = ((WavpackHeader *) wps->blockbuff)->crc; - - /////////////////////// handle lossless mono mode ///////////////////////// - - if (!(flags & HYBRID_FLAG) && (flags & MONO_FLAG)) - for (bptr = buffer; bptr < eptr;) { - int32_t code; - - crc = crc * 3 + (code = *bptr); - - for (tcount = wps->num_terms, dpp = wps->decorr_passes; tcount--; dpp++) { - int32_t sam; - - if (dpp->term > MAX_TERM) { - if (dpp->term & 1) - sam = 2 * dpp->samples_A [0] - dpp->samples_A [1]; - else - sam = (3 * dpp->samples_A [0] - dpp->samples_A [1]) >> 1; - - dpp->samples_A [1] = dpp->samples_A [0]; - dpp->samples_A [0] = code; - } - else { - sam = dpp->samples_A [m]; - dpp->samples_A [(m + dpp->term) & (MAX_TERM - 1)] = code; - } - - code -= apply_weight_i (dpp->weight_A, sam); - update_weight (dpp->weight_A, 2, sam, code); - } - - m = (m + 1) & (MAX_TERM - 1); - *bptr++ = code; - } - - //////////////////// handle the lossless stereo mode ////////////////////// - - else if (!(flags & HYBRID_FLAG) && !(flags & MONO_FLAG)) { - if (flags & JOINT_STEREO) - for (bptr = buffer; bptr < eptr; bptr += 2) { - crc = crc * 9 + (bptr [0] * 3) + bptr [1]; - bptr [1] += ((bptr [0] -= bptr [1]) >> 1); - } - else - for (bptr = buffer; bptr < eptr; bptr += 2) - crc = crc * 9 + (bptr [0] * 3) + bptr [1]; - - for (tcount = wps->num_terms, dpp = wps->decorr_passes; tcount-- ; dpp++) { - if (dpp->term == 17) - decorr_stereo_pass_17 (dpp, buffer, eptr); - else if (dpp->term == 18) - decorr_stereo_pass_18 (dpp, buffer, eptr); - else if (dpp->term >= 1 && dpp->term <= 7) - decorr_stereo_pass (dpp, buffer, eptr, m); - else if (dpp->term == -2) - decorr_stereo_pass_m2 (dpp, buffer, eptr); - } - } - - send_words (buffer, sample_count, flags, &wps->w, &wps->wvbits); - ((WavpackHeader *) wps->blockbuff)->crc = crc; - ((WavpackHeader *) wps->blockbuff)->block_samples += sample_count; - wps->sample_index += sample_count; - - return TRUE; -} - -static void decorr_stereo_pass (struct decorr_pass *dpp, int32_t *bptr, int32_t *eptr, int m) -{ - int k = (m + dpp->term) & (MAX_TERM - 1); - int32_t sam; - - while (bptr < eptr) { - dpp->samples_A [k] = bptr [0]; - bptr [0] -= apply_weight_i (dpp->weight_A, (sam = dpp->samples_A [m])); - update_weight (dpp->weight_A, 2, sam, bptr [0]); - bptr++; - dpp->samples_B [k] = bptr [0]; - bptr [0] -= apply_weight_i (dpp->weight_B, (sam = dpp->samples_B [m])); - update_weight (dpp->weight_B, 2, sam, bptr [0]); - bptr++; - m = (m + 1) & (MAX_TERM - 1); - k = (k + 1) & (MAX_TERM - 1); - } -} - -static void decorr_stereo_pass_18 (struct decorr_pass *dpp, int32_t *bptr, int32_t *eptr) -{ - int32_t sam; - - while (bptr < eptr) { - sam = (3 * dpp->samples_A [0] - dpp->samples_A [1]) >> 1; - dpp->samples_A [1] = dpp->samples_A [0]; - dpp->samples_A [0] = bptr [0]; - bptr [0] -= apply_weight_i (dpp->weight_A, sam); - update_weight (dpp->weight_A, 2, sam, bptr [0]); - bptr++; - sam = (3 * dpp->samples_B [0] - dpp->samples_B [1]) >> 1; - dpp->samples_B [1] = dpp->samples_B [0]; - dpp->samples_B [0] = bptr [0]; - bptr [0] -= apply_weight_i (dpp->weight_B, sam); - update_weight (dpp->weight_B, 2, sam, bptr [0]); - bptr++; - } -} - -static void decorr_stereo_pass_m2 (struct decorr_pass *dpp, int32_t *bptr, int32_t *eptr) -{ - int32_t sam_A, sam_B; - - for (; bptr < eptr; bptr += 2) { - sam_A = bptr [1]; - sam_B = dpp->samples_B [0]; - dpp->samples_B [0] = bptr [0]; - bptr [0] -= apply_weight_i (dpp->weight_A, sam_A); - update_weight_clip (dpp->weight_A, 2, sam_A, bptr [0]); - bptr [1] -= apply_weight_i (dpp->weight_B, sam_B); - update_weight_clip (dpp->weight_B, 2, sam_B, bptr [1]); - } -} - -static void decorr_stereo_pass_17 (struct decorr_pass *dpp, int32_t *bptr, int32_t *eptr) -{ - int32_t sam; - - while (bptr < eptr) { - sam = 2 * dpp->samples_A [0] - dpp->samples_A [1]; - dpp->samples_A [1] = dpp->samples_A [0]; - dpp->samples_A [0] = bptr [0]; - bptr [0] -= apply_weight_i (dpp->weight_A, sam); - update_weight (dpp->weight_A, 2, sam, bptr [0]); - bptr++; - sam = 2 * dpp->samples_B [0] - dpp->samples_B [1]; - dpp->samples_B [1] = dpp->samples_B [0]; - dpp->samples_B [0] = bptr [0]; - bptr [0] -= apply_weight_i (dpp->weight_B, sam); - update_weight (dpp->weight_B, 2, sam, bptr [0]); - bptr++; - } -} - -int pack_finish_block (WavpackContext *wpc) -{ - WavpackStream *wps = &wpc->stream; - struct decorr_pass *dpp; - uint32_t data_count; - int tcount, m; - - m = ((WavpackHeader *) wps->blockbuff)->block_samples & (MAX_TERM - 1); - - if (m) - for (tcount = wps->num_terms, dpp = wps->decorr_passes; tcount--; dpp++) - if (dpp->term > 0 && dpp->term <= MAX_TERM) { - int32_t temp_A [MAX_TERM], temp_B [MAX_TERM]; - int k; - - memcpy (temp_A, dpp->samples_A, sizeof (dpp->samples_A)); - memcpy (temp_B, dpp->samples_B, sizeof (dpp->samples_B)); - - for (k = 0; k < MAX_TERM; k++) { - dpp->samples_A [k] = temp_A [m]; - dpp->samples_B [k] = temp_B [m]; - m = (m + 1) & (MAX_TERM - 1); - } - } - - flush_word (&wps->w, &wps->wvbits); - data_count = bs_close_write (&wps->wvbits); - - if (data_count) { - if (data_count != (uint32_t) -1) { - uchar *cptr = wps->blockbuff + ((WavpackHeader *) wps->blockbuff)->ckSize + 8; - - *cptr++ = ID_WV_BITSTREAM | ID_LARGE; - *cptr++ = data_count >> 1; - *cptr++ = data_count >> 9; - *cptr++ = data_count >> 17; - ((WavpackHeader *) wps->blockbuff)->ckSize += data_count + 4; - } - else - return FALSE; - } - - return TRUE; -} diff --git a/apps/codecs/libwavpack/unpack.c b/apps/codecs/libwavpack/unpack.c deleted file mode 100644 index 69252f24ad..0000000000 --- a/apps/codecs/libwavpack/unpack.c +++ /dev/null @@ -1,780 +0,0 @@ -//////////////////////////////////////////////////////////////////////////// -// **** WAVPACK **** // -// Hybrid Lossless Wavefile Compressor // -// Copyright (c) 1998 - 2004 Conifer Software. // -// All Rights Reserved. // -// Distributed under the BSD Software License (see license.txt) // -//////////////////////////////////////////////////////////////////////////// - -// unpack.c - -// This module actually handles the decompression of the audio data, except -// for the entropy decoding which is handled by the words.c module. For -// maximum efficiency, the conversion is isolated to tight loops that handle -// an entire buffer. - -#include "wavpack.h" - -#include -#include - -static void strcpy_loc (char *dst, char *src) { while ((*dst++ = *src++) != 0); } - -#define LOSSY_MUTE - -///////////////////////////// executable code //////////////////////////////// - -// This function initializes everything required to unpack a WavPack block -// and must be called before unpack_samples() is called to obtain audio data. -// It is assumed that the WavpackHeader has been read into the wps->wphdr -// (in the current WavpackStream). This is where all the metadata blocks are -// scanned up to the one containing the audio bitstream. - -int unpack_init (WavpackContext *wpc) -{ - WavpackStream *wps = &wpc->stream; - WavpackMetadata wpmd; - - if (wps->wphdr.block_samples && wps->wphdr.block_index != (uint32_t) -1) - wps->sample_index = wps->wphdr.block_index; - - wps->mute_error = FALSE; - wps->crc = 0xffffffff; - CLEAR (wps->wvbits); - CLEAR (wps->decorr_passes); - CLEAR (wps->w); - - while (read_metadata_buff (wpc, &wpmd)) { - if (!process_metadata (wpc, &wpmd)) { - strcpy_loc (wpc->error_message, "invalid metadata!"); - return FALSE; - } - - if (wpmd.id == ID_WV_BITSTREAM) - break; - } - - if (wps->wphdr.block_samples && !bs_is_open (&wps->wvbits)) { - strcpy_loc (wpc->error_message, "invalid WavPack file!"); - return FALSE; - } - - if (wps->wphdr.block_samples) { - if ((wps->wphdr.flags & INT32_DATA) && wps->int32_sent_bits) - wpc->lossy_blocks = TRUE; - - if ((wps->wphdr.flags & FLOAT_DATA) && - wps->float_flags & (FLOAT_EXCEPTIONS | FLOAT_ZEROS_SENT | FLOAT_SHIFT_SENT | FLOAT_SHIFT_SAME)) - wpc->lossy_blocks = TRUE; - } - - return TRUE; -} - -// This function initialzes the main bitstream for audio samples, which must -// be in the "wv" file. - -int init_wv_bitstream (WavpackContext *wpc, WavpackMetadata *wpmd) -{ - WavpackStream *wps = &wpc->stream; - - if (wpmd->data) - bs_open_read (&wps->wvbits, wpmd->data, (unsigned char *) wpmd->data + wpmd->byte_length, NULL, 0); - else if (wpmd->byte_length) - bs_open_read (&wps->wvbits, wpc->read_buffer, wpc->read_buffer + sizeof (wpc->read_buffer), - wpc->infile, wpmd->byte_length + (wpmd->byte_length & 1)); - - return TRUE; -} - -// Read decorrelation terms from specified metadata block into the -// decorr_passes array. The terms range from -3 to 8, plus 17 & 18; -// other values are reserved and generate errors for now. The delta -// ranges from 0 to 7 with all values valid. Note that the terms are -// stored in the opposite order in the decorr_passes array compared -// to packing. - -int read_decorr_terms (WavpackStream *wps, WavpackMetadata *wpmd) -{ - int termcnt = wpmd->byte_length; - uchar *byteptr = wpmd->data; - struct decorr_pass *dpp; - - if (termcnt > MAX_NTERMS) - return FALSE; - - wps->num_terms = termcnt; - - for (dpp = wps->decorr_passes + termcnt - 1; termcnt--; dpp--) { - dpp->term = (int)(*byteptr & 0x1f) - 5; - dpp->delta = (*byteptr++ >> 5) & 0x7; - - if (!dpp->term || dpp->term < -3 || (dpp->term > MAX_TERM && dpp->term < 17) || dpp->term > 18) - return FALSE; - } - - return TRUE; -} - -// Read decorrelation weights from specified metadata block into the -// decorr_passes array. The weights range +/-1024, but are rounded and -// truncated to fit in signed chars for metadata storage. Weights are -// separate for the two channels and are specified from the "last" term -// (first during encode). Unspecified weights are set to zero. - -int read_decorr_weights (WavpackStream *wps, WavpackMetadata *wpmd) -{ - int termcnt = wpmd->byte_length, tcount; - signed char *byteptr = wpmd->data; - struct decorr_pass *dpp; - - if (!(wps->wphdr.flags & MONO_DATA)) - termcnt /= 2; - - if (termcnt > wps->num_terms) - return FALSE; - - for (tcount = wps->num_terms, dpp = wps->decorr_passes; tcount--; dpp++) - dpp->weight_A = dpp->weight_B = 0; - - while (--dpp >= wps->decorr_passes && termcnt--) { - dpp->weight_A = restore_weight (*byteptr++); - - if (!(wps->wphdr.flags & MONO_DATA)) - dpp->weight_B = restore_weight (*byteptr++); - } - - return TRUE; -} - -// Read decorrelation samples from specified metadata block into the -// decorr_passes array. The samples are signed 32-bit values, but are -// converted to signed log2 values for storage in metadata. Values are -// stored for both channels and are specified from the "last" term -// (first during encode) with unspecified samples set to zero. The -// number of samples stored varies with the actual term value, so -// those must obviously come first in the metadata. - -int read_decorr_samples (WavpackStream *wps, WavpackMetadata *wpmd) -{ - uchar *byteptr = wpmd->data; - uchar *endptr = byteptr + wpmd->byte_length; - struct decorr_pass *dpp; - int tcount; - - for (tcount = wps->num_terms, dpp = wps->decorr_passes; tcount--; dpp++) { - CLEAR (dpp->samples_A); - CLEAR (dpp->samples_B); - } - - if (wps->wphdr.version == 0x402 && (wps->wphdr.flags & HYBRID_FLAG)) { - byteptr += 2; - - if (!(wps->wphdr.flags & MONO_DATA)) - byteptr += 2; - } - - while (dpp-- > wps->decorr_passes && byteptr < endptr) - if (dpp->term > MAX_TERM) { - dpp->samples_A [0] = exp2s ((short)(byteptr [0] + (byteptr [1] << 8))); - dpp->samples_A [1] = exp2s ((short)(byteptr [2] + (byteptr [3] << 8))); - byteptr += 4; - - if (!(wps->wphdr.flags & MONO_DATA)) { - dpp->samples_B [0] = exp2s ((short)(byteptr [0] + (byteptr [1] << 8))); - dpp->samples_B [1] = exp2s ((short)(byteptr [2] + (byteptr [3] << 8))); - byteptr += 4; - } - } - else if (dpp->term < 0) { - dpp->samples_A [0] = exp2s ((short)(byteptr [0] + (byteptr [1] << 8))); - dpp->samples_B [0] = exp2s ((short)(byteptr [2] + (byteptr [3] << 8))); - byteptr += 4; - } - else { - int m = 0, cnt = dpp->term; - - while (cnt--) { - dpp->samples_A [m] = exp2s ((short)(byteptr [0] + (byteptr [1] << 8))); - byteptr += 2; - - if (!(wps->wphdr.flags & MONO_DATA)) { - dpp->samples_B [m] = exp2s ((short)(byteptr [0] + (byteptr [1] << 8))); - byteptr += 2; - } - - m++; - } - } - - return byteptr == endptr; -} - -// Read the int32 data from the specified metadata into the specified stream. -// This data is used for integer data that has more than 24 bits of magnitude -// or, in some cases, used to eliminate redundant bits from any audio stream. - -int read_int32_info (WavpackStream *wps, WavpackMetadata *wpmd) -{ - int bytecnt = wpmd->byte_length; - char *byteptr = wpmd->data; - - if (bytecnt != 4) - return FALSE; - - wps->int32_sent_bits = *byteptr++; - wps->int32_zeros = *byteptr++; - wps->int32_ones = *byteptr++; - wps->int32_dups = *byteptr; - return TRUE; -} - -// Read multichannel information from metadata. The first byte is the total -// number of channels and the following bytes represent the channel_mask -// as described for Microsoft WAVEFORMATEX. - -int read_channel_info (WavpackContext *wpc, WavpackMetadata *wpmd) -{ - int bytecnt = wpmd->byte_length, shift = 0; - char *byteptr = wpmd->data; - uint32_t mask = 0; - - if (!bytecnt || bytecnt > 5) - return FALSE; - - wpc->config.num_channels = *byteptr++; - - while (--bytecnt) { - mask |= (uint32_t) *byteptr++ << shift; - shift += 8; - } - - wpc->config.channel_mask = mask; - return TRUE; -} - -// Read configuration information from metadata. - -int read_config_info (WavpackContext *wpc, WavpackMetadata *wpmd) -{ - int bytecnt = wpmd->byte_length; - uchar *byteptr = wpmd->data; - - if (bytecnt >= 3) { - wpc->config.flags &= 0xff; - wpc->config.flags |= (int32_t) *byteptr++ << 8; - wpc->config.flags |= (int32_t) *byteptr++ << 16; - wpc->config.flags |= (int32_t) *byteptr << 24; - } - - return TRUE; -} - -// Read non-standard sampling rate from metadata. - -int read_sample_rate (WavpackContext *wpc, WavpackMetadata *wpmd) -{ - int bytecnt = wpmd->byte_length; - uchar *byteptr = wpmd->data; - - if (bytecnt == 3) { - wpc->config.sample_rate = (int32_t) *byteptr++; - wpc->config.sample_rate |= (int32_t) *byteptr++ << 8; - wpc->config.sample_rate |= (int32_t) *byteptr++ << 16; - } - - return TRUE; -} - -// This monster actually unpacks the WavPack bitstream(s) into the specified -// buffer as 32-bit integers or floats (depending on orignal data). Lossy -// samples will be clipped to their original limits (i.e. 8-bit samples are -// clipped to -128/+127) but are still returned in int32_ts. It is up to the -// caller to potentially reformat this for the final output including any -// multichannel distribution, block alignment or endian compensation. The -// function unpack_init() must have been called and the entire WavPack block -// must still be visible (although wps->blockbuff will not be accessed again). -// For maximum clarity, the function is broken up into segments that handle -// various modes. This makes for a few extra infrequent flag checks, but -// makes the code easier to follow because the nesting does not become so -// deep. For maximum efficiency, the conversion is isolated to tight loops -// that handle an entire buffer. The function returns the total number of -// samples unpacked, which can be less than the number requested if an error -// occurs or the end of the block is reached. - -#if defined(CPU_COLDFIRE) -extern void decorr_stereo_pass_cont_mcf5249 (struct decorr_pass *dpp, int32_t *buffer, int32_t sample_count); -#elif defined(CPU_ARM) -extern void decorr_stereo_pass_cont_arm (struct decorr_pass *dpp, int32_t *buffer, int32_t sample_count); -extern void decorr_stereo_pass_cont_arml (struct decorr_pass *dpp, int32_t *buffer, int32_t sample_count); -#else -static void decorr_stereo_pass_cont (struct decorr_pass *dpp, int32_t *buffer, int32_t sample_count); -#endif - -static void decorr_mono_pass (struct decorr_pass *dpp, int32_t *buffer, int32_t sample_count); -static void decorr_stereo_pass (struct decorr_pass *dpp, int32_t *buffer, int32_t sample_count); -static void fixup_samples (WavpackStream *wps, int32_t *buffer, uint32_t sample_count); - -int32_t unpack_samples (WavpackContext *wpc, int32_t *buffer, uint32_t sample_count) -{ - WavpackStream *wps = &wpc->stream; - uint32_t flags = wps->wphdr.flags, crc = wps->crc, i; - int32_t mute_limit = (1L << ((flags & MAG_MASK) >> MAG_LSB)) + 2; - struct decorr_pass *dpp; - int32_t *bptr, *eptr; - int tcount; - - if (wps->sample_index + sample_count > wps->wphdr.block_index + wps->wphdr.block_samples) - sample_count = wps->wphdr.block_index + wps->wphdr.block_samples - wps->sample_index; - - if (wps->mute_error) { - memset (buffer, 0, sample_count * (flags & MONO_FLAG ? 4 : 8)); - wps->sample_index += sample_count; - return sample_count; - } - - if (flags & HYBRID_FLAG) - mute_limit *= 2; - - ///////////////////// handle version 4 mono data ///////////////////////// - - if (flags & MONO_DATA) { - eptr = buffer + sample_count; - i = get_words (buffer, sample_count, flags, &wps->w, &wps->wvbits); - - for (tcount = wps->num_terms, dpp = wps->decorr_passes; tcount--; dpp++) - decorr_mono_pass (dpp, buffer, sample_count); - - for (bptr = buffer; bptr < eptr; ++bptr) { - if (labs (bptr [0]) > mute_limit) { - i = bptr - buffer; - break; - } - - crc = crc * 3 + bptr [0]; - } - } - - //////////////////// handle version 4 stereo data //////////////////////// - - else { - eptr = buffer + (sample_count * 2); - i = get_words (buffer, sample_count, flags, &wps->w, &wps->wvbits); - - if (sample_count < 16) - for (tcount = wps->num_terms, dpp = wps->decorr_passes; tcount--; dpp++) - decorr_stereo_pass (dpp, buffer, sample_count); - else - for (tcount = wps->num_terms, dpp = wps->decorr_passes; tcount--; dpp++) { - decorr_stereo_pass (dpp, buffer, 8); -#if defined(CPU_COLDFIRE) - decorr_stereo_pass_cont_mcf5249 (dpp, buffer + 16, sample_count - 8); -#elif defined(CPU_ARM) - if (((flags & MAG_MASK) >> MAG_LSB) > 15) - decorr_stereo_pass_cont_arml (dpp, buffer + 16, sample_count - 8); - else - decorr_stereo_pass_cont_arm (dpp, buffer + 16, sample_count - 8); -#else - decorr_stereo_pass_cont (dpp, buffer + 16, sample_count - 8); -#endif - } - - if (flags & JOINT_STEREO) - for (bptr = buffer; bptr < eptr; bptr += 2) { - bptr [0] += (bptr [1] -= (bptr [0] >> 1)); - - if (labs (bptr [0]) > mute_limit || labs (bptr [1]) > mute_limit) { - i = (bptr - buffer) / 2; - break; - } - - crc = (crc * 3 + bptr [0]) * 3 + bptr [1]; - } - else - for (bptr = buffer; bptr < eptr; bptr += 2) { - if (labs (bptr [0]) > mute_limit || labs (bptr [1]) > mute_limit) { - i = (bptr - buffer) / 2; - break; - } - - crc = (crc * 3 + bptr [0]) * 3 + bptr [1]; - } - } - - if (i != sample_count) { - memset (buffer, 0, sample_count * (flags & MONO_FLAG ? 4 : 8)); - wps->mute_error = TRUE; - i = sample_count; - } - - fixup_samples (wps, buffer, i); - - if (flags & FALSE_STEREO) { - int32_t *dptr = buffer + i * 2; - int32_t *sptr = buffer + i; - int32_t c = i; - - while (c--) { - *--dptr = *--sptr; - *--dptr = *sptr; - } - } - - wps->sample_index += i; - wps->crc = crc; - - return i; -} - -static void decorr_stereo_pass (struct decorr_pass *dpp, int32_t *buffer, int32_t sample_count) -{ - int32_t delta = dpp->delta, weight_A = dpp->weight_A, weight_B = dpp->weight_B; - int32_t *bptr, *eptr = buffer + (sample_count * 2), sam_A, sam_B; - int m, k; - - switch (dpp->term) { - - case 17: - for (bptr = buffer; bptr < eptr; bptr += 2) { - sam_A = 2 * dpp->samples_A [0] - dpp->samples_A [1]; - dpp->samples_A [1] = dpp->samples_A [0]; - dpp->samples_A [0] = apply_weight (weight_A, sam_A) + bptr [0]; - update_weight (weight_A, delta, sam_A, bptr [0]); - bptr [0] = dpp->samples_A [0]; - - sam_A = 2 * dpp->samples_B [0] - dpp->samples_B [1]; - dpp->samples_B [1] = dpp->samples_B [0]; - dpp->samples_B [0] = apply_weight (weight_B, sam_A) + bptr [1]; - update_weight (weight_B, delta, sam_A, bptr [1]); - bptr [1] = dpp->samples_B [0]; - } - - break; - - case 18: - for (bptr = buffer; bptr < eptr; bptr += 2) { - sam_A = (3 * dpp->samples_A [0] - dpp->samples_A [1]) >> 1; - dpp->samples_A [1] = dpp->samples_A [0]; - dpp->samples_A [0] = apply_weight (weight_A, sam_A) + bptr [0]; - update_weight (weight_A, delta, sam_A, bptr [0]); - bptr [0] = dpp->samples_A [0]; - - sam_A = (3 * dpp->samples_B [0] - dpp->samples_B [1]) >> 1; - dpp->samples_B [1] = dpp->samples_B [0]; - dpp->samples_B [0] = apply_weight (weight_B, sam_A) + bptr [1]; - update_weight (weight_B, delta, sam_A, bptr [1]); - bptr [1] = dpp->samples_B [0]; - } - - break; - - default: - for (m = 0, k = dpp->term & (MAX_TERM - 1), bptr = buffer; bptr < eptr; bptr += 2) { - sam_A = dpp->samples_A [m]; - dpp->samples_A [k] = apply_weight (weight_A, sam_A) + bptr [0]; - update_weight (weight_A, delta, sam_A, bptr [0]); - bptr [0] = dpp->samples_A [k]; - - sam_A = dpp->samples_B [m]; - dpp->samples_B [k] = apply_weight (weight_B, sam_A) + bptr [1]; - update_weight (weight_B, delta, sam_A, bptr [1]); - bptr [1] = dpp->samples_B [k]; - - m = (m + 1) & (MAX_TERM - 1); - k = (k + 1) & (MAX_TERM - 1); - } - - if (m) { - int32_t temp_samples [MAX_TERM]; - - memcpy (temp_samples, dpp->samples_A, sizeof (dpp->samples_A)); - - for (k = 0; k < MAX_TERM; k++, m++) - dpp->samples_A [k] = temp_samples [m & (MAX_TERM - 1)]; - - memcpy (temp_samples, dpp->samples_B, sizeof (dpp->samples_B)); - - for (k = 0; k < MAX_TERM; k++, m++) - dpp->samples_B [k] = temp_samples [m & (MAX_TERM - 1)]; - } - - break; - - case -1: - for (bptr = buffer; bptr < eptr; bptr += 2) { - sam_A = bptr [0] + apply_weight (weight_A, dpp->samples_A [0]); - update_weight_clip (weight_A, delta, dpp->samples_A [0], bptr [0]); - bptr [0] = sam_A; - dpp->samples_A [0] = bptr [1] + apply_weight (weight_B, sam_A); - update_weight_clip (weight_B, delta, sam_A, bptr [1]); - bptr [1] = dpp->samples_A [0]; - } - - break; - - case -2: - for (bptr = buffer; bptr < eptr; bptr += 2) { - sam_B = bptr [1] + apply_weight (weight_B, dpp->samples_B [0]); - update_weight_clip (weight_B, delta, dpp->samples_B [0], bptr [1]); - bptr [1] = sam_B; - dpp->samples_B [0] = bptr [0] + apply_weight (weight_A, sam_B); - update_weight_clip (weight_A, delta, sam_B, bptr [0]); - bptr [0] = dpp->samples_B [0]; - } - - break; - - case -3: - for (bptr = buffer; bptr < eptr; bptr += 2) { - sam_A = bptr [0] + apply_weight (weight_A, dpp->samples_A [0]); - update_weight_clip (weight_A, delta, dpp->samples_A [0], bptr [0]); - sam_B = bptr [1] + apply_weight (weight_B, dpp->samples_B [0]); - update_weight_clip (weight_B, delta, dpp->samples_B [0], bptr [1]); - bptr [0] = dpp->samples_B [0] = sam_A; - bptr [1] = dpp->samples_A [0] = sam_B; - } - - break; - } - - dpp->weight_A = weight_A; - dpp->weight_B = weight_B; -} - -#if (!defined(CPU_COLDFIRE) && !defined(CPU_ARM)) - -static void decorr_stereo_pass_cont (struct decorr_pass *dpp, int32_t *buffer, int32_t sample_count) -{ - int32_t delta = dpp->delta, weight_A = dpp->weight_A, weight_B = dpp->weight_B; - int32_t *bptr, *tptr, *eptr = buffer + (sample_count * 2), sam_A, sam_B; - int k, i; - - switch (dpp->term) { - - case 17: - for (bptr = buffer; bptr < eptr; bptr += 2) { - sam_A = 2 * bptr [-2] - bptr [-4]; - bptr [0] = apply_weight (weight_A, sam_A) + (sam_B = bptr [0]); - update_weight (weight_A, delta, sam_A, sam_B); - - sam_A = 2 * bptr [-1] - bptr [-3]; - bptr [1] = apply_weight (weight_B, sam_A) + (sam_B = bptr [1]); - update_weight (weight_B, delta, sam_A, sam_B); - } - - dpp->samples_B [0] = bptr [-1]; - dpp->samples_A [0] = bptr [-2]; - dpp->samples_B [1] = bptr [-3]; - dpp->samples_A [1] = bptr [-4]; - break; - - case 18: - for (bptr = buffer; bptr < eptr; bptr += 2) { - sam_A = (3 * bptr [-2] - bptr [-4]) >> 1; - bptr [0] = apply_weight (weight_A, sam_A) + (sam_B = bptr [0]); - update_weight (weight_A, delta, sam_A, sam_B); - - sam_A = (3 * bptr [-1] - bptr [-3]) >> 1; - bptr [1] = apply_weight (weight_B, sam_A) + (sam_B = bptr [1]); - update_weight (weight_B, delta, sam_A, sam_B); - } - - dpp->samples_B [0] = bptr [-1]; - dpp->samples_A [0] = bptr [-2]; - dpp->samples_B [1] = bptr [-3]; - dpp->samples_A [1] = bptr [-4]; - break; - - default: - for (bptr = buffer, tptr = buffer - (dpp->term * 2); bptr < eptr; bptr += 2, tptr += 2) { - bptr [0] = apply_weight (weight_A, tptr [0]) + (sam_A = bptr [0]); - update_weight (weight_A, delta, tptr [0], sam_A); - - bptr [1] = apply_weight (weight_B, tptr [1]) + (sam_A = bptr [1]); - update_weight (weight_B, delta, tptr [1], sam_A); - } - - for (k = dpp->term - 1, i = 8; i--; k--) { - dpp->samples_B [k & (MAX_TERM - 1)] = *--bptr; - dpp->samples_A [k & (MAX_TERM - 1)] = *--bptr; - } - - break; - - case -1: - for (bptr = buffer; bptr < eptr; bptr += 2) { - bptr [0] = apply_weight (weight_A, bptr [-1]) + (sam_A = bptr [0]); - update_weight_clip (weight_A, delta, bptr [-1], sam_A); - bptr [1] = apply_weight (weight_B, bptr [0]) + (sam_A = bptr [1]); - update_weight_clip (weight_B, delta, bptr [0], sam_A); - } - - dpp->samples_A [0] = bptr [-1]; - break; - - case -2: - for (bptr = buffer; bptr < eptr; bptr += 2) { - bptr [1] = apply_weight (weight_B, bptr [-2]) + (sam_A = bptr [1]); - update_weight_clip (weight_B, delta, bptr [-2], sam_A); - bptr [0] = apply_weight (weight_A, bptr [1]) + (sam_A = bptr [0]); - update_weight_clip (weight_A, delta, bptr [1], sam_A); - } - - dpp->samples_B [0] = bptr [-2]; - break; - - case -3: - for (bptr = buffer; bptr < eptr; bptr += 2) { - bptr [0] = apply_weight (weight_A, bptr [-1]) + (sam_A = bptr [0]); - update_weight_clip (weight_A, delta, bptr [-1], sam_A); - bptr [1] = apply_weight (weight_B, bptr [-2]) + (sam_A = bptr [1]); - update_weight_clip (weight_B, delta, bptr [-2], sam_A); - } - - dpp->samples_A [0] = bptr [-1]; - dpp->samples_B [0] = bptr [-2]; - break; - } - - dpp->weight_A = weight_A; - dpp->weight_B = weight_B; -} - -#endif - -static void decorr_mono_pass (struct decorr_pass *dpp, int32_t *buffer, int32_t sample_count) -{ - int32_t delta = dpp->delta, weight_A = dpp->weight_A; - int32_t *bptr, *eptr = buffer + sample_count, sam_A; - int m, k; - - switch (dpp->term) { - - case 17: - for (bptr = buffer; bptr < eptr; bptr++) { - sam_A = 2 * dpp->samples_A [0] - dpp->samples_A [1]; - dpp->samples_A [1] = dpp->samples_A [0]; - dpp->samples_A [0] = apply_weight (weight_A, sam_A) + bptr [0]; - update_weight (weight_A, delta, sam_A, bptr [0]); - bptr [0] = dpp->samples_A [0]; - } - - break; - - case 18: - for (bptr = buffer; bptr < eptr; bptr++) { - sam_A = (3 * dpp->samples_A [0] - dpp->samples_A [1]) >> 1; - dpp->samples_A [1] = dpp->samples_A [0]; - dpp->samples_A [0] = apply_weight (weight_A, sam_A) + bptr [0]; - update_weight (weight_A, delta, sam_A, bptr [0]); - bptr [0] = dpp->samples_A [0]; - } - - break; - - default: - for (m = 0, k = dpp->term & (MAX_TERM - 1), bptr = buffer; bptr < eptr; bptr++) { - sam_A = dpp->samples_A [m]; - dpp->samples_A [k] = apply_weight (weight_A, sam_A) + bptr [0]; - update_weight (weight_A, delta, sam_A, bptr [0]); - bptr [0] = dpp->samples_A [k]; - m = (m + 1) & (MAX_TERM - 1); - k = (k + 1) & (MAX_TERM - 1); - } - - if (m) { - int32_t temp_samples [MAX_TERM]; - - memcpy (temp_samples, dpp->samples_A, sizeof (dpp->samples_A)); - - for (k = 0; k < MAX_TERM; k++, m++) - dpp->samples_A [k] = temp_samples [m & (MAX_TERM - 1)]; - } - - break; - } - - dpp->weight_A = weight_A; -} - - -// This is a helper function for unpack_samples() that applies several final -// operations. First, if the data is 32-bit float data, then that conversion -// is done in the float.c module (whether lossy or lossless) and we return. -// Otherwise, if the extended integer data applies, then that operation is -// executed first. If the unpacked data is lossy (and not corrected) then -// it is clipped and shifted in a single operation. Otherwise, if it's -// lossless then the last step is to apply the final shift (if any). - -// This function has been modified for RockBox to return all integer samples -// as 28-bits, and clipping (for lossy mode) has been eliminated because this -// now happens in the dsp module. - -static void fixup_samples (WavpackStream *wps, int32_t *buffer, uint32_t sample_count) -{ - uint32_t flags = wps->wphdr.flags; - int shift = (flags & SHIFT_MASK) >> SHIFT_LSB; - - shift += 21 - (flags & BYTES_STORED) * 8; // this provides RockBox with 28-bit (+sign) - - if (flags & FLOAT_DATA) { - float_values (wps, buffer, (flags & MONO_DATA) ? sample_count : sample_count * 2); - return; - } - - if (flags & INT32_DATA) { - uint32_t count = (flags & MONO_DATA) ? sample_count : sample_count * 2; - int sent_bits = wps->int32_sent_bits, zeros = wps->int32_zeros; - int ones = wps->int32_ones, dups = wps->int32_dups; - int32_t *dptr = buffer; - - if (!(flags & HYBRID_FLAG) && !sent_bits && (zeros + ones + dups)) - while (count--) { - if (zeros) - *dptr <<= zeros; - else if (ones) - *dptr = ((*dptr + 1) << ones) - 1; - else if (dups) - *dptr = ((*dptr + (*dptr & 1)) << dups) - (*dptr & 1); - - dptr++; - } - else - shift += zeros + sent_bits + ones + dups; - } - - if (shift > 0) { - if (!(flags & MONO_DATA)) - sample_count *= 2; - - while (sample_count--) - *buffer++ <<= shift; - } - else if (shift < 0) { - shift = -shift; - - if (!(flags & MONO_DATA)) - sample_count *= 2; - - while (sample_count--) - *buffer++ >>= shift; - } -} - -// This function checks the crc value(s) for an unpacked block, returning the -// number of actual crc errors detected for the block. The block must be -// completely unpacked before this test is valid. For losslessly unpacked -// blocks of float or extended integer data the extended crc is also checked. -// Note that WavPack's crc is not a CCITT approved polynomial algorithm, but -// is a much simpler method that is virtually as robust for real world data. - -int check_crc_error (WavpackContext *wpc) -{ - WavpackStream *wps = &wpc->stream; - int result = 0; - - if (wps->crc != wps->wphdr.crc) - ++result; - - return result; -} diff --git a/apps/codecs/libwavpack/wavpack.h b/apps/codecs/libwavpack/wavpack.h deleted file mode 100644 index b15a176f33..0000000000 --- a/apps/codecs/libwavpack/wavpack.h +++ /dev/null @@ -1,447 +0,0 @@ -//////////////////////////////////////////////////////////////////////////// -// **** WAVPACK **** // -// Hybrid Lossless Wavefile Compressor // -// Copyright (c) 1998 - 2004 Conifer Software. // -// All Rights Reserved. // -// Distributed under the BSD Software License (see license.txt) // -//////////////////////////////////////////////////////////////////////////// - -// wavpack.h -#ifdef CODEC -#include "codeclib.h" -#endif -#include - -// This header file contains all the definitions required by WavPack. - -typedef unsigned char uchar; -typedef unsigned short ushort; -#if 0 // unused and causing compiler errrors -typedef unsigned int uint; -#endif - -#include - -#define FALSE 0 -#define TRUE 1 - -////////////////////////////// WavPack Header ///////////////////////////////// - -// Note that this is the ONLY structure that is written to (or read from) -// WavPack 4.0 files, and is the preamble to every block in both the .wv -// and .wvc files. - -typedef struct { - char ckID [4]; - uint32_t ckSize; - short version; - uchar track_no, index_no; - uint32_t total_samples, block_index, block_samples, flags, crc; -} WavpackHeader; - -#define WavpackHeaderFormat "4LS2LLLLL" - -// or-values for "flags" - -#define BYTES_STORED 3 // 1-4 bytes/sample -#define MONO_FLAG 4 // not stereo -#define HYBRID_FLAG 8 // hybrid mode -#define JOINT_STEREO 0x10 // joint stereo -#define CROSS_DECORR 0x20 // no-delay cross decorrelation -#define HYBRID_SHAPE 0x40 // noise shape (hybrid mode only) -#define FLOAT_DATA 0x80 // ieee 32-bit floating point data - -#define INT32_DATA 0x100 // special extended int handling -#define HYBRID_BITRATE 0x200 // bitrate noise (hybrid mode only) -#define HYBRID_BALANCE 0x400 // balance noise (hybrid stereo mode only) - -#define INITIAL_BLOCK 0x800 // initial block of multichannel segment -#define FINAL_BLOCK 0x1000 // final block of multichannel segment - -#define SHIFT_LSB 13 -#define SHIFT_MASK (0x1fL << SHIFT_LSB) - -#define MAG_LSB 18 -#define MAG_MASK (0x1fL << MAG_LSB) - -#define SRATE_LSB 23 -#define SRATE_MASK (0xfL << SRATE_LSB) - -#define FALSE_STEREO 0x40000000 // block is stereo, but data is mono - -#define IGNORED_FLAGS 0x18000000 // reserved, but ignore if encountered -#define NEW_SHAPING 0x20000000 // use IIR filter for negative shaping -#define UNKNOWN_FLAGS 0x80000000 // also reserved, but refuse decode if - // encountered - -#define MONO_DATA (MONO_FLAG | FALSE_STEREO) - -#define MIN_STREAM_VERS 0x402 // lowest stream version we'll decode -#define MAX_STREAM_VERS 0x410 // highest stream version we'll decode -#define CUR_STREAM_VERS 0x403 // stream version we are writing now - -//////////////////////////// WavPack Metadata ///////////////////////////////// - -// This is an internal representation of metadata. - -typedef struct { - uchar temp_data [64]; - int32_t byte_length; - void *data; - uchar id; -} WavpackMetadata; - -#define ID_OPTIONAL_DATA 0x20 -#define ID_ODD_SIZE 0x40 -#define ID_LARGE 0x80 - -#define ID_DUMMY 0x0 -#define ID_ENCODER_INFO 0x1 -#define ID_DECORR_TERMS 0x2 -#define ID_DECORR_WEIGHTS 0x3 -#define ID_DECORR_SAMPLES 0x4 -#define ID_ENTROPY_VARS 0x5 -#define ID_HYBRID_PROFILE 0x6 -#define ID_SHAPING_WEIGHTS 0x7 -#define ID_FLOAT_INFO 0x8 -#define ID_INT32_INFO 0x9 -#define ID_WV_BITSTREAM 0xa -#define ID_WVC_BITSTREAM 0xb -#define ID_WVX_BITSTREAM 0xc -#define ID_CHANNEL_INFO 0xd - -#define ID_RIFF_HEADER (ID_OPTIONAL_DATA | 0x1) -#define ID_RIFF_TRAILER (ID_OPTIONAL_DATA | 0x2) -#define ID_REPLAY_GAIN (ID_OPTIONAL_DATA | 0x3) -#define ID_CUESHEET (ID_OPTIONAL_DATA | 0x4) -#define ID_CONFIG_BLOCK (ID_OPTIONAL_DATA | 0x5) -#define ID_MD5_CHECKSUM (ID_OPTIONAL_DATA | 0x6) -#define ID_SAMPLE_RATE (ID_OPTIONAL_DATA | 0x7) - -///////////////////////// WavPack Configuration /////////////////////////////// - -// This internal structure is used during encode to provide configuration to -// the encoding engine and during decoding to provide fle information back to -// the higher level functions. Not all fields are used in both modes. - -typedef struct { - int bits_per_sample, bytes_per_sample; - int flags, num_channels, float_norm_exp; - uint32_t sample_rate, channel_mask; -} WavpackConfig; - -#define CONFIG_BYTES_STORED 3 // 1-4 bytes/sample -#define CONFIG_MONO_FLAG 4 // not stereo -#define CONFIG_HYBRID_FLAG 8 // hybrid mode -#define CONFIG_JOINT_STEREO 0x10 // joint stereo -#define CONFIG_CROSS_DECORR 0x20 // no-delay cross decorrelation -#define CONFIG_HYBRID_SHAPE 0x40 // noise shape (hybrid mode only) -#define CONFIG_FLOAT_DATA 0x80 // ieee 32-bit floating point data - -#define CONFIG_ADOBE_MODE 0x100 // "adobe" mode for 32-bit floats -#define CONFIG_FAST_FLAG 0x200 // fast mode -#define CONFIG_VERY_FAST_FLAG 0x400 // double fast -#define CONFIG_HIGH_FLAG 0x800 // high quality mode -#define CONFIG_VERY_HIGH_FLAG 0x1000 // double high (not used yet) -#define CONFIG_BITRATE_KBPS 0x2000 // bitrate is kbps, not bits / sample -#define CONFIG_AUTO_SHAPING 0x4000 // automatic noise shaping -#define CONFIG_SHAPE_OVERRIDE 0x8000 // shaping mode specified -#define CONFIG_JOINT_OVERRIDE 0x10000 // joint-stereo mode specified -#define CONFIG_COPY_TIME 0x20000 // copy file-time from source -#define CONFIG_CREATE_EXE 0x40000 // create executable (not yet) -#define CONFIG_CREATE_WVC 0x80000 // create correction file -#define CONFIG_OPTIMIZE_WVC 0x100000 // maximize bybrid compression -#define CONFIG_QUALITY_MODE 0x200000 // psychoacoustic quality mode -#define CONFIG_RAW_FLAG 0x400000 // raw mode (not implemented yet) -#define CONFIG_CALC_NOISE 0x800000 // calc noise in hybrid mode -#define CONFIG_LOSSY_MODE 0x1000000 // obsolete (for information) -#define CONFIG_EXTRA_MODE 0x2000000 // extra processing mode -#define CONFIG_SKIP_WVX 0x4000000 // no wvx stream w/ floats & big ints -#define CONFIG_MD5_CHECKSUM 0x8000000 // compute & store MD5 signature -#define CONFIG_QUIET_MODE 0x10000000 // don't report progress % - -//////////////////////////////// WavPack Stream /////////////////////////////// - -// This internal structure contains everything required to handle a WavPack -// "stream", which is defined as a stereo or mono stream of audio samples. For -// multichannel audio several of these would be required. Each stream contains -// pointers to hold a complete allocated block of WavPack data, although it's -// possible to decode WavPack blocks without buffering an entire block. - -typedef int32_t (*read_stream)(void *, int32_t); - -typedef struct bs { - uchar *buf, *end, *ptr; - void (*wrap)(struct bs *bs); - uint32_t file_bytes, sr; - int error, bc; - read_stream file; -} Bitstream; - -#define MAX_NTERMS 16 -#define MAX_TERM 8 - -struct decorr_pass { - short term, delta, weight_A, weight_B; - int32_t samples_A [MAX_TERM], samples_B [MAX_TERM]; -}; - -struct entropy_data { - uint32_t median [3], slow_level, error_limit; -}; - -struct words_data { - uint32_t bitrate_delta [2], bitrate_acc [2]; - uint32_t pend_data, holding_one, zeros_acc; - int holding_zero, pend_count; - struct entropy_data c [2]; -}; - -typedef struct { - WavpackHeader wphdr; - Bitstream wvbits; - - struct words_data w; - - int num_terms, mute_error; - uint32_t sample_index, crc; - int32_t block_bytes_left; - - uchar int32_sent_bits, int32_zeros, int32_ones, int32_dups; - uchar float_flags, float_shift, float_max_exp, float_norm_exp; - uchar *blockbuff, *blockend; - - struct decorr_pass decorr_passes [MAX_NTERMS]; - -} WavpackStream; - -// flags for float_flags: - -#define FLOAT_SHIFT_ONES 1 // bits left-shifted into float = '1' -#define FLOAT_SHIFT_SAME 2 // bits left-shifted into float are the same -#define FLOAT_SHIFT_SENT 4 // bits shifted into float are sent literally -#define FLOAT_ZEROS_SENT 8 // "zeros" are not all real zeros -#define FLOAT_NEG_ZEROS 0x10 // contains negative zeros -#define FLOAT_EXCEPTIONS 0x20 // contains exceptions (inf, nan, etc.) - -/////////////////////////////// WavPack Context /////////////////////////////// - -// This internal structure holds everything required to encode or decode WavPack -// files. It is recommended that direct access to this structure be minimized -// and the provided utilities used instead. - -typedef struct { - WavpackStream stream; - WavpackConfig config; - - uchar *wrapper_data; - int wrapper_bytes; - - uchar read_buffer [1024]; - char error_message [80]; - - read_stream infile; - uint32_t total_samples, crc_errors, first_flags; - int open_flags, norm_offset, reduced_channels, lossy_blocks; - -} WavpackContext; - -//////////////////////// function prototypes and macros ////////////////////// - -#define CLEAR(destin) memset (&destin, 0, sizeof (destin)); - -// bits.c - -void bs_open_read (Bitstream *bs, uchar *buffer_start, uchar *buffer_end, read_stream file, uint32_t file_bytes); -void bs_open_write (Bitstream *bs, uchar *buffer_start, uchar *buffer_end); -uint32_t bs_close_write (Bitstream *bs); - -#define bs_is_open(bs) ((bs)->ptr != NULL) - -#define getbit(bs) ( \ - (((bs)->bc) ? \ - ((bs)->bc--, (bs)->sr & 1) : \ - (((++((bs)->ptr) != (bs)->end) ? (void) 0 : (bs)->wrap (bs)), (bs)->bc = 7, ((bs)->sr = *((bs)->ptr)) & 1) \ - ) ? \ - ((bs)->sr >>= 1, 1) : \ - ((bs)->sr >>= 1, 0) \ -) - -#define getbits(value, nbits, bs) { \ - while ((nbits) > (bs)->bc) { \ - if (++((bs)->ptr) == (bs)->end) (bs)->wrap (bs); \ - (bs)->sr |= (int32_t)*((bs)->ptr) << (bs)->bc; \ - (bs)->bc += 8; \ - } \ - *(value) = (bs)->sr; \ - if ((bs)->bc > 32) { \ - (bs)->bc -= (nbits); \ - (bs)->sr = *((bs)->ptr) >> (8 - (bs)->bc); \ - } \ - else { \ - (bs)->bc -= (nbits); \ - (bs)->sr >>= (nbits); \ - } \ -} - -#define putbit(bit, bs) { if (bit) (bs)->sr |= (1 << (bs)->bc); \ - if (++((bs)->bc) == 8) { \ - *((bs)->ptr) = (bs)->sr; \ - (bs)->sr = (bs)->bc = 0; \ - if (++((bs)->ptr) == (bs)->end) (bs)->wrap (bs); \ - }} - -#define putbit_0(bs) { \ - if (++((bs)->bc) == 8) { \ - *((bs)->ptr) = (bs)->sr; \ - (bs)->sr = (bs)->bc = 0; \ - if (++((bs)->ptr) == (bs)->end) (bs)->wrap (bs); \ - }} - -#define putbit_1(bs) { (bs)->sr |= (1 << (bs)->bc); \ - if (++((bs)->bc) == 8) { \ - *((bs)->ptr) = (bs)->sr; \ - (bs)->sr = (bs)->bc = 0; \ - if (++((bs)->ptr) == (bs)->end) (bs)->wrap (bs); \ - }} - -#define putbits(value, nbits, bs) { \ - (bs)->sr |= (int32_t)(value) << (bs)->bc; \ - if (((bs)->bc += (nbits)) >= 8) \ - do { \ - *((bs)->ptr) = (bs)->sr; \ - (bs)->sr >>= 8; \ - if (++((bs)->ptr) == (bs)->end) (bs)->wrap (bs); \ - } while (((bs)->bc -= 8) >= 8); \ -} - -void little_endian_to_native (void *data, char *format); -void native_to_little_endian (void *data, char *format); - -// These macros implement the weight application and update operations -// that are at the heart of the decorrelation loops. Note that when there -// are several alternative versions of the same macro (marked with PERFCOND) -// then the versions are functionally equivalent with respect to WavPack -// decoding and the user should choose the one that provides the best -// performance. This may be easier to check when NOT using the assembly -// language optimizations. - -#if 1 // PERFCOND -#define apply_weight_i(weight, sample) ((weight * sample + 512) >> 10) -#else -#define apply_weight_i(weight, sample) ((((weight * sample) >> 8) + 2) >> 2) -#endif - -#define apply_weight_f(weight, sample) (((((sample & 0xffff) * weight) >> 9) + \ - (((sample & ~0xffff) >> 9) * weight) + 1) >> 1) - -#if 1 // PERFCOND -#define apply_weight(weight, sample) (sample != (short) sample ? \ - apply_weight_f (weight, sample) : apply_weight_i (weight, sample)) -#else -#define apply_weight(weight, sample) ((int32_t)((weight * (int64_t) sample + 512) >> 10)) -#endif - -#if 0 // PERFCOND -#define update_weight(weight, delta, source, result) \ - if (source && result) { int32_t s = (int32_t) (source ^ result) >> 31; weight = (delta ^ s) + (weight - s); } -#elif 1 -#define update_weight(weight, delta, source, result) \ - if (source && result) weight += (((source ^ result) >> 30) | 1) * delta -#else -#define update_weight(weight, delta, source, result) \ - if (source && result) (source ^ result) < 0 ? (weight -= delta) : (weight += delta) -#endif - -#define update_weight_clip(weight, delta, source, result) \ - if (source && result && ((source ^ result) < 0 ? (weight -= delta) < -1024 : (weight += delta) > 1024)) \ - weight = weight < 0 ? -1024 : 1024 - -// unpack.c - -int unpack_init (WavpackContext *wpc); -int init_wv_bitstream (WavpackContext *wpc, WavpackMetadata *wpmd); -int read_decorr_terms (WavpackStream *wps, WavpackMetadata *wpmd); -int read_decorr_weights (WavpackStream *wps, WavpackMetadata *wpmd); -int read_decorr_samples (WavpackStream *wps, WavpackMetadata *wpmd); -int read_float_info (WavpackStream *wps, WavpackMetadata *wpmd); -int read_int32_info (WavpackStream *wps, WavpackMetadata *wpmd); -int read_channel_info (WavpackContext *wpc, WavpackMetadata *wpmd); -int read_config_info (WavpackContext *wpc, WavpackMetadata *wpmd); -int read_sample_rate (WavpackContext *wpc, WavpackMetadata *wpmd); -int32_t unpack_samples (WavpackContext *wpc, int32_t *buffer, uint32_t sample_count); -int check_crc_error (WavpackContext *wpc); - -// pack.c - -void pack_init (WavpackContext *wpc); -int pack_start_block (WavpackContext *wpc); -int pack_samples (WavpackContext *wpc, int32_t *buffer, uint32_t sample_count); -int pack_finish_block (WavpackContext *wpc); - -// metadata.c stuff - -int read_metadata_buff (WavpackContext *wpc, WavpackMetadata *wpmd); -int process_metadata (WavpackContext *wpc, WavpackMetadata *wpmd); -int copy_metadata (WavpackMetadata *wpmd, uchar *buffer_start, uchar *buffer_end); -void free_metadata (WavpackMetadata *wpmd); - -// words.c stuff - -void init_words (WavpackStream *wps); -int read_entropy_vars (WavpackStream *wps, WavpackMetadata *wpmd); -void write_entropy_vars (WavpackStream *wps, WavpackMetadata *wpmd); -int read_hybrid_profile (WavpackStream *wps, WavpackMetadata *wpmd); -int32_t get_words (int32_t *buffer, int nsamples, uint32_t flags, - struct words_data *w, Bitstream *bs); -void send_word_lossless (int32_t value, int chan, - struct words_data *w, Bitstream *bs); -void send_words (int32_t *buffer, int nsamples, uint32_t flags, - struct words_data *w, Bitstream *bs); -void flush_word (struct words_data *w, Bitstream *bs); -int log2s (int32_t value); -int32_t exp2s (int log); -signed char store_weight (int weight); -int restore_weight (signed char weight); - -#define WORD_EOF (1L << 31) - -// float.c - -int read_float_info (WavpackStream *wps, WavpackMetadata *wpmd); -void float_values (WavpackStream *wps, int32_t *values, int32_t num_values); -void float_normalize (int32_t *values, int32_t num_values, int delta_exp); - -// wputils.c - -WavpackContext *WavpackOpenFileInput (read_stream infile, char *error); - -int WavpackGetMode (WavpackContext *wpc); - -#define MODE_WVC 0x1 -#define MODE_LOSSLESS 0x2 -#define MODE_HYBRID 0x4 -#define MODE_FLOAT 0x8 -#define MODE_VALID_TAG 0x10 -#define MODE_HIGH 0x20 -#define MODE_FAST 0x40 - -uint32_t WavpackUnpackSamples (WavpackContext *wpc, int32_t *buffer, uint32_t samples); -uint32_t WavpackGetNumSamples (WavpackContext *wpc); -uint32_t WavpackGetSampleIndex (WavpackContext *wpc); -int WavpackGetNumErrors (WavpackContext *wpc); -int WavpackLossyBlocks (WavpackContext *wpc); -uint32_t WavpackGetSampleRate (WavpackContext *wpc); -int WavpackGetBitsPerSample (WavpackContext *wpc); -int WavpackGetBytesPerSample (WavpackContext *wpc); -int WavpackGetNumChannels (WavpackContext *wpc); -int WavpackGetReducedChannels (WavpackContext *wpc); -WavpackContext *WavpackOpenFileOutput (void); -int WavpackSetConfiguration (WavpackContext *wpc, WavpackConfig *config, uint32_t total_samples); -void WavpackAddWrapper (WavpackContext *wpc, void *data, uint32_t bcount); -int WavpackStartBlock (WavpackContext *wpc, uchar *begin, uchar *end); -int WavpackPackSamples (WavpackContext *wpc, int32_t *sample_buffer, uint32_t sample_count); -uint32_t WavpackFinishBlock (WavpackContext *wpc); -void WavpackUpdateNumSamples (WavpackContext *wpc, void *first_block); -void *WavpackGetWrapperLocation (void *first_block); - diff --git a/apps/codecs/libwavpack/words.c b/apps/codecs/libwavpack/words.c deleted file mode 100644 index 3d9e753e4b..0000000000 --- a/apps/codecs/libwavpack/words.c +++ /dev/null @@ -1,786 +0,0 @@ -//////////////////////////////////////////////////////////////////////////// -// **** WAVPACK **** // -// Hybrid Lossless Wavefile Compressor // -// Copyright (c) 1998 - 2004 Conifer Software. // -// All Rights Reserved. // -//////////////////////////////////////////////////////////////////////////// - -// words.c - -// This module provides entropy word encoding and decoding functions using -// a variation on the Rice method. This was introduced in version 3.93 -// because it allows splitting the data into a "lossy" stream and a -// "correction" stream in a very efficient manner and is therefore ideal -// for the "hybrid" mode. For 4.0, the efficiency of this method was -// significantly improved by moving away from the normal Rice restriction of -// using powers of two for the modulus divisions and now the method can be -// used for both hybrid and pure lossless encoding. - -// Samples are divided by median probabilities at 5/7 (71.43%), 10/49 (20.41%), -// and 20/343 (5.83%). Each zone has 3.5 times fewer samples than the -// previous. Using standard Rice coding on this data would result in 1.4 -// bits per sample average (not counting sign bit). However, there is a -// very simple encoding that is over 99% efficient with this data and -// results in about 1.22 bits per sample. - -#include "wavpack.h" - -#include - -//////////////////////////////// local macros ///////////////////////////////// - -#define LIMIT_ONES 16 // maximum consecutive 1s sent for "div" data - -// these control the time constant "slow_level" which is used for hybrid mode -// that controls bitrate as a function of residual level (HYBRID_BITRATE). -#define SLS 8 -#define SLO ((1 << (SLS - 1))) - -// these control the time constant of the 3 median level breakpoints -#define DIV0 128 // 5/7 of samples -#define DIV1 64 // 10/49 of samples -#define DIV2 32 // 20/343 of samples - -// this macro retrieves the specified median breakpoint (without frac; min = 1) -#define GET_MED(med) (((c->median [med]) >> 4) + 1) - -// These macros update the specified median breakpoints. Note that the median -// is incremented when the sample is higher than the median, else decremented. -// They are designed so that the median will never drop below 1 and the value -// is essentially stationary if there are 2 increments for every 5 decrements. - -#define INC_MED0() (c->median [0] += ((c->median [0] + DIV0) / DIV0) * 5) -#define DEC_MED0() (c->median [0] -= ((c->median [0] + (DIV0-2)) / DIV0) * 2) -#define INC_MED1() (c->median [1] += ((c->median [1] + DIV1) / DIV1) * 5) -#define DEC_MED1() (c->median [1] -= ((c->median [1] + (DIV1-2)) / DIV1) * 2) -#define INC_MED2() (c->median [2] += ((c->median [2] + DIV2) / DIV2) * 5) -#define DEC_MED2() (c->median [2] -= ((c->median [2] + (DIV2-2)) / DIV2) * 2) - -#define count_bits(av) ( \ - (av) < (1 << 8) ? nbits_table [av] : \ - ( \ - (av) < (1L << 16) ? nbits_table [(av) >> 8] + 8 : \ - ((av) < (1L << 24) ? nbits_table [(av) >> 16] + 16 : nbits_table [(av) >> 24] + 24) \ - ) \ -) - -///////////////////////////// local table storage //////////////////////////// - -static const char nbits_table [] ICONST_ATTR = { - 0, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, // 0 - 15 - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, // 16 - 31 - 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, // 32 - 47 - 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, // 48 - 63 - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 64 - 79 - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 80 - 95 - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 96 - 111 - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 112 - 127 - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, // 128 - 143 - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, // 144 - 159 - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, // 160 - 175 - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, // 176 - 191 - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, // 192 - 207 - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, // 208 - 223 - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, // 224 - 239 - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 // 240 - 255 -}; - -static const uchar log2_table [] = { - 0x00, 0x01, 0x03, 0x04, 0x06, 0x07, 0x09, 0x0a, 0x0b, 0x0d, 0x0e, 0x10, 0x11, 0x12, 0x14, 0x15, - 0x16, 0x18, 0x19, 0x1a, 0x1c, 0x1d, 0x1e, 0x20, 0x21, 0x22, 0x24, 0x25, 0x26, 0x28, 0x29, 0x2a, - 0x2c, 0x2d, 0x2e, 0x2f, 0x31, 0x32, 0x33, 0x34, 0x36, 0x37, 0x38, 0x39, 0x3b, 0x3c, 0x3d, 0x3e, - 0x3f, 0x41, 0x42, 0x43, 0x44, 0x45, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4d, 0x4e, 0x4f, 0x50, 0x51, - 0x52, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5c, 0x5d, 0x5e, 0x5f, 0x60, 0x61, 0x62, 0x63, - 0x64, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x74, 0x75, - 0x76, 0x77, 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, - 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, - 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, - 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, 0xb0, 0xb1, 0xb2, 0xb2, - 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, 0xc0, 0xc0, - 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xcb, 0xcb, 0xcc, 0xcd, 0xce, - 0xcf, 0xd0, 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd8, 0xd9, 0xda, 0xdb, - 0xdc, 0xdc, 0xdd, 0xde, 0xdf, 0xe0, 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe4, 0xe5, 0xe6, 0xe7, 0xe7, - 0xe8, 0xe9, 0xea, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xee, 0xef, 0xf0, 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, - 0xf4, 0xf5, 0xf6, 0xf7, 0xf7, 0xf8, 0xf9, 0xf9, 0xfa, 0xfb, 0xfc, 0xfc, 0xfd, 0xfe, 0xff, 0xff -}; - -static const uchar exp2_table [] ICONST_ATTR = { - 0x00, 0x01, 0x01, 0x02, 0x03, 0x03, 0x04, 0x05, 0x06, 0x06, 0x07, 0x08, 0x08, 0x09, 0x0a, 0x0b, - 0x0b, 0x0c, 0x0d, 0x0e, 0x0e, 0x0f, 0x10, 0x10, 0x11, 0x12, 0x13, 0x13, 0x14, 0x15, 0x16, 0x16, - 0x17, 0x18, 0x19, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1d, 0x1e, 0x1f, 0x20, 0x20, 0x21, 0x22, 0x23, - 0x24, 0x24, 0x25, 0x26, 0x27, 0x28, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, - 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3a, 0x3b, 0x3c, 0x3d, - 0x3e, 0x3f, 0x40, 0x41, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x48, 0x49, 0x4a, 0x4b, - 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, - 0x5b, 0x5c, 0x5d, 0x5e, 0x5e, 0x5f, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, - 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, - 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x87, 0x88, 0x89, 0x8a, - 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, 0x90, 0x91, 0x92, 0x93, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b, - 0x9c, 0x9d, 0x9f, 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, - 0xaf, 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xbc, 0xbd, 0xbe, 0xbf, 0xc0, - 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc8, 0xc9, 0xca, 0xcb, 0xcd, 0xce, 0xcf, 0xd0, 0xd2, 0xd3, 0xd4, - 0xd6, 0xd7, 0xd8, 0xd9, 0xdb, 0xdc, 0xdd, 0xde, 0xe0, 0xe1, 0xe2, 0xe4, 0xe5, 0xe6, 0xe8, 0xe9, - 0xea, 0xec, 0xed, 0xee, 0xf0, 0xf1, 0xf2, 0xf4, 0xf5, 0xf6, 0xf8, 0xf9, 0xfa, 0xfc, 0xfd, 0xff -}; - -static const char ones_count_table [] ICONST_ATTR = { - 0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5, - 0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,6, - 0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5, - 0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,7, - 0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5, - 0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,6, - 0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5, - 0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,8 -}; - -///////////////////////////// executable code //////////////////////////////// - -void init_words (WavpackStream *wps) -{ - CLEAR (wps->w); -} - -static int mylog2 (uint32_t avalue); - -// Read the median log2 values from the specifed metadata structure, convert -// them back to 32-bit unsigned values and store them. If length is not -// exactly correct then we flag and return an error. - -int read_entropy_vars (WavpackStream *wps, WavpackMetadata *wpmd) -{ - uchar *byteptr = wpmd->data; - - if (wpmd->byte_length != ((wps->wphdr.flags & MONO_DATA) ? 6 : 12)) - return FALSE; - - wps->w.c [0].median [0] = exp2s (byteptr [0] + (byteptr [1] << 8)); - wps->w.c [0].median [1] = exp2s (byteptr [2] + (byteptr [3] << 8)); - wps->w.c [0].median [2] = exp2s (byteptr [4] + (byteptr [5] << 8)); - - if (!(wps->wphdr.flags & MONO_DATA)) { - wps->w.c [1].median [0] = exp2s (byteptr [6] + (byteptr [7] << 8)); - wps->w.c [1].median [1] = exp2s (byteptr [8] + (byteptr [9] << 8)); - wps->w.c [1].median [2] = exp2s (byteptr [10] + (byteptr [11] << 8)); - } - - return TRUE; -} - -// Allocates the correct space in the metadata structure and writes the -// current median values to it. Values are converted from 32-bit unsigned -// to our internal 16-bit mylog2 values, and read_entropy_vars () is called -// to read the values back because we must compensate for the loss through -// the log function. - -void write_entropy_vars (WavpackStream *wps, WavpackMetadata *wpmd) -{ - uchar *byteptr; - int temp; - - byteptr = wpmd->data = wpmd->temp_data; - wpmd->id = ID_ENTROPY_VARS; - - *byteptr++ = temp = mylog2 (wps->w.c [0].median [0]); - *byteptr++ = temp >> 8; - *byteptr++ = temp = mylog2 (wps->w.c [0].median [1]); - *byteptr++ = temp >> 8; - *byteptr++ = temp = mylog2 (wps->w.c [0].median [2]); - *byteptr++ = temp >> 8; - - if (!(wps->wphdr.flags & MONO_FLAG)) { - *byteptr++ = temp = mylog2 (wps->w.c [1].median [0]); - *byteptr++ = temp >> 8; - *byteptr++ = temp = mylog2 (wps->w.c [1].median [1]); - *byteptr++ = temp >> 8; - *byteptr++ = temp = mylog2 (wps->w.c [1].median [2]); - *byteptr++ = temp >> 8; - } - - wpmd->byte_length = byteptr - (uchar *) wpmd->data; - read_entropy_vars (wps, wpmd); -} - -// Read the hybrid related values from the specifed metadata structure, convert -// them back to their internal formats and store them. The extended profile -// stuff is not implemented yet, so return an error if we get more data than -// we know what to do with. - -int read_hybrid_profile (WavpackStream *wps, WavpackMetadata *wpmd) -{ - uchar *byteptr = wpmd->data; - uchar *endptr = byteptr + wpmd->byte_length; - - if (wps->wphdr.flags & HYBRID_BITRATE) { - wps->w.c [0].slow_level = exp2s (byteptr [0] + (byteptr [1] << 8)); - byteptr += 2; - - if (!(wps->wphdr.flags & MONO_DATA)) { - wps->w.c [1].slow_level = exp2s (byteptr [0] + (byteptr [1] << 8)); - byteptr += 2; - } - } - - wps->w.bitrate_acc [0] = (int32_t)(byteptr [0] + (byteptr [1] << 8)) << 16; - byteptr += 2; - - if (!(wps->wphdr.flags & MONO_DATA)) { - wps->w.bitrate_acc [1] = (int32_t)(byteptr [0] + (byteptr [1] << 8)) << 16; - byteptr += 2; - } - - if (byteptr < endptr) { - wps->w.bitrate_delta [0] = exp2s ((short)(byteptr [0] + (byteptr [1] << 8))); - byteptr += 2; - - if (!(wps->wphdr.flags & MONO_DATA)) { - wps->w.bitrate_delta [1] = exp2s ((short)(byteptr [0] + (byteptr [1] << 8))); - byteptr += 2; - } - - if (byteptr < endptr) - return FALSE; - } - else - wps->w.bitrate_delta [0] = wps->w.bitrate_delta [1] = 0; - - return TRUE; -} - -// This function is called during both encoding and decoding of hybrid data to -// update the "error_limit" variable which determines the maximum sample error -// allowed in the main bitstream. In the HYBRID_BITRATE mode (which is the only -// currently implemented) this is calculated from the slow_level values and the -// bitrate accumulators. Note that the bitrate accumulators can be changing. - -static void update_error_limit (struct words_data *w, uint32_t flags) -{ - int bitrate_0 = (w->bitrate_acc [0] += w->bitrate_delta [0]) >> 16; - - if (flags & MONO_DATA) { - if (flags & HYBRID_BITRATE) { - int slow_log_0 = (w->c [0].slow_level + SLO) >> SLS; - - if (slow_log_0 - bitrate_0 > -0x100) - w->c [0].error_limit = exp2s (slow_log_0 - bitrate_0 + 0x100); - else - w->c [0].error_limit = 0; - } - else - w->c [0].error_limit = exp2s (bitrate_0); - } - else { - int bitrate_1 = (w->bitrate_acc [1] += w->bitrate_delta [1]) >> 16; - - if (flags & HYBRID_BITRATE) { - int slow_log_0 = (w->c [0].slow_level + SLO) >> SLS; - int slow_log_1 = (w->c [1].slow_level + SLO) >> SLS; - - if (flags & HYBRID_BALANCE) { - int balance = (slow_log_1 - slow_log_0 + bitrate_1 + 1) >> 1; - - if (balance > bitrate_0) { - bitrate_1 = bitrate_0 * 2; - bitrate_0 = 0; - } - else if (-balance > bitrate_0) { - bitrate_0 = bitrate_0 * 2; - bitrate_1 = 0; - } - else { - bitrate_1 = bitrate_0 + balance; - bitrate_0 = bitrate_0 - balance; - } - } - - if (slow_log_0 - bitrate_0 > -0x100) - w->c [0].error_limit = exp2s (slow_log_0 - bitrate_0 + 0x100); - else - w->c [0].error_limit = 0; - - if (slow_log_1 - bitrate_1 > -0x100) - w->c [1].error_limit = exp2s (slow_log_1 - bitrate_1 + 0x100); - else - w->c [1].error_limit = 0; - } - else { - w->c [0].error_limit = exp2s (bitrate_0); - w->c [1].error_limit = exp2s (bitrate_1); - } - } -} - -static uint32_t read_code (Bitstream *bs, uint32_t maxcode); - -// Read the next word from the bitstream "wvbits" and return the value. This -// function can be used for hybrid or lossless streams, but since an -// optimized version is available for lossless this function would normally -// be used for hybrid only. If a hybrid lossless stream is being read then -// the "correction" offset is written at the specified pointer. A return value -// of WORD_EOF indicates that the end of the bitstream was reached (all 1s) or -// some other error occurred. - -int32_t get_words (int32_t *buffer, int nsamples, uint32_t flags, - struct words_data *w, Bitstream *bs) -{ - register struct entropy_data *c = w->c; - int csamples; - - if (!(flags & MONO_DATA)) - nsamples *= 2; - - for (csamples = 0; csamples < nsamples; ++csamples) { - uint32_t ones_count, low, mid, high; - - if (!(flags & MONO_DATA)) - c = w->c + (csamples & 1); - - if (!(w->c [0].median [0] & ~1) && !w->holding_zero && !w->holding_one && !(w->c [1].median [0] & ~1)) { - uint32_t mask; - int cbits; - - if (w->zeros_acc) { - if (--w->zeros_acc) { - c->slow_level -= (c->slow_level + SLO) >> SLS; - *buffer++ = 0; - continue; - } - } - else { - for (cbits = 0; cbits < 33 && getbit (bs); ++cbits); - - if (cbits == 33) - break; - - if (cbits < 2) - w->zeros_acc = cbits; - else { - for (mask = 1, w->zeros_acc = 0; --cbits; mask <<= 1) - if (getbit (bs)) - w->zeros_acc |= mask; - - w->zeros_acc |= mask; - } - - if (w->zeros_acc) { - c->slow_level -= (c->slow_level + SLO) >> SLS; - CLEAR (w->c [0].median); - CLEAR (w->c [1].median); - *buffer++ = 0; - continue; - } - } - } - - if (w->holding_zero) - ones_count = w->holding_zero = 0; - else { - int next8; - - if (bs->bc < 8) { - if (++(bs->ptr) == bs->end) - bs->wrap (bs); - - next8 = (bs->sr |= *(bs->ptr) << bs->bc) & 0xff; - bs->bc += 8; - } - else - next8 = bs->sr & 0xff; - - if (next8 == 0xff) { - bs->bc -= 8; - bs->sr >>= 8; - - for (ones_count = 8; ones_count < (LIMIT_ONES + 1) && getbit (bs); ++ones_count); - - if (ones_count == (LIMIT_ONES + 1)) - break; - - if (ones_count == LIMIT_ONES) { - uint32_t mask; - int cbits; - - for (cbits = 0; cbits < 33 && getbit (bs); ++cbits); - - if (cbits == 33) - break; - - if (cbits < 2) - ones_count = cbits; - else { - for (mask = 1, ones_count = 0; --cbits; mask <<= 1) - if (getbit (bs)) - ones_count |= mask; - - ones_count |= mask; - } - - ones_count += LIMIT_ONES; - } - } - else { - bs->bc -= (ones_count = ones_count_table [next8]) + 1; - bs->sr >>= ones_count + 1; - } - - if (w->holding_one) { - w->holding_one = ones_count & 1; - ones_count = (ones_count >> 1) + 1; - } - else { - w->holding_one = ones_count & 1; - ones_count >>= 1; - } - - w->holding_zero = ~w->holding_one & 1; - } - - if ((flags & HYBRID_FLAG) && ((flags & MONO_DATA) || !(csamples & 1))) - update_error_limit (w, flags); - - if (ones_count == 0) { - low = 0; - high = GET_MED (0) - 1; - DEC_MED0 (); - } - else { - low = GET_MED (0); - INC_MED0 (); - - if (ones_count == 1) { - high = low + GET_MED (1) - 1; - DEC_MED1 (); - } - else { - low += GET_MED (1); - INC_MED1 (); - - if (ones_count == 2) { - high = low + GET_MED (2) - 1; - DEC_MED2 (); - } - else { - low += (ones_count - 2) * GET_MED (2); - high = low + GET_MED (2) - 1; - INC_MED2 (); - } - } - } - - mid = (high + low + 1) >> 1; - - if (!c->error_limit) - mid = read_code (bs, high - low) + low; - else while (high - low > c->error_limit) { - if (getbit (bs)) - mid = (high + (low = mid) + 1) >> 1; - else - mid = ((high = mid - 1) + low + 1) >> 1; - } - - *buffer++ = getbit (bs) ? ~mid : mid; - - if (flags & HYBRID_BITRATE) - c->slow_level = c->slow_level - ((c->slow_level + SLO) >> SLS) + mylog2 (mid); - } - - return (flags & MONO_DATA) ? csamples : (csamples / 2); -} - -// Read a single unsigned value from the specified bitstream with a value -// from 0 to maxcode. If there are exactly a power of two number of possible -// codes then this will read a fixed number of bits; otherwise it reads the -// minimum number of bits and then determines whether another bit is needed -// to define the code. - -static uint32_t read_code (Bitstream *bs, uint32_t maxcode) -{ - int bitcount = count_bits (maxcode); - uint32_t extras = (1L << bitcount) - maxcode - 1, code; - - if (!bitcount) - return 0; - - getbits (&code, bitcount - 1, bs); - code &= (1L << (bitcount - 1)) - 1; - - if (code >= extras) { - code = (code << 1) - extras; - - if (getbit (bs)) - ++code; - } - - return code; -} - -void send_words (int32_t *buffer, int nsamples, uint32_t flags, - struct words_data *w, Bitstream *bs) -{ - register struct entropy_data *c = w->c; - - if (!(flags & MONO_FLAG)) - nsamples *= 2; - - while (nsamples--) { - int32_t value = *buffer++; - int sign = (value < 0) ? 1 : 0; - uint32_t ones_count, low, high; - - if (!(flags & MONO_FLAG)) - c = w->c + (~nsamples & 1); - - if (!(w->c [0].median [0] & ~1) && !w->holding_zero && !(w->c [1].median [0] & ~1)) { - if (w->zeros_acc) { - if (value) - flush_word (w, bs); - else { - w->zeros_acc++; - continue; - } - } - else if (value) { - putbit_0 (bs); - } - else { - CLEAR (w->c [0].median); - CLEAR (w->c [1].median); - w->zeros_acc = 1; - continue; - } - } - - if (sign) - value = ~value; - - if ((uint32_t) value < GET_MED (0)) { - ones_count = low = 0; - high = GET_MED (0) - 1; - DEC_MED0 (); - } - else { - low = GET_MED (0); - INC_MED0 (); - - if (value - low < GET_MED (1)) { - ones_count = 1; - high = low + GET_MED (1) - 1; - DEC_MED1 (); - } - else { - low += GET_MED (1); - INC_MED1 (); - - if (value - low < GET_MED (2)) { - ones_count = 2; - high = low + GET_MED (2) - 1; - DEC_MED2 (); - } - else { - ones_count = 2 + (value - low) / GET_MED (2); - low += (ones_count - 2) * GET_MED (2); - high = low + GET_MED (2) - 1; - INC_MED2 (); - } - } - } - - if (w->holding_zero) { - if (ones_count) - w->holding_one++; - - flush_word (w, bs); - - if (ones_count) { - w->holding_zero = 1; - ones_count--; - } - else - w->holding_zero = 0; - } - else - w->holding_zero = 1; - - w->holding_one = ones_count * 2; - - if (high != low) { - uint32_t maxcode = high - low, code = value - low; - int bitcount = count_bits (maxcode); - uint32_t extras = (1L << bitcount) - maxcode - 1; - - if (code < extras) { - w->pend_data |= code << w->pend_count; - w->pend_count += bitcount - 1; - } - else { - w->pend_data |= ((code + extras) >> 1) << w->pend_count; - w->pend_count += bitcount - 1; - w->pend_data |= ((code + extras) & 1) << w->pend_count++; - } - } - - w->pend_data |= ((int32_t) sign << w->pend_count++); - - if (!w->holding_zero) - flush_word (w, bs); - } -} - -// Used by send_word() and send_word_lossless() to actually send most the -// accumulated data onto the bitstream. This is also called directly from -// clients when all words have been sent. - -void flush_word (struct words_data *w, Bitstream *bs) -{ - int cbits; - - if (w->zeros_acc) { - cbits = count_bits (w->zeros_acc); - - while (cbits--) { - putbit_1 (bs); - } - - putbit_0 (bs); - - while (w->zeros_acc > 1) { - putbit (w->zeros_acc & 1, bs); - w->zeros_acc >>= 1; - } - - w->zeros_acc = 0; - } - - if (w->holding_one) { - if (w->holding_one >= LIMIT_ONES) { - putbits ((1L << LIMIT_ONES) - 1, LIMIT_ONES + 1, bs); - w->holding_one -= LIMIT_ONES; - cbits = count_bits (w->holding_one); - - while (cbits--) { - putbit_1 (bs); - } - - putbit_0 (bs); - - while (w->holding_one > 1) { - putbit (w->holding_one & 1, bs); - w->holding_one >>= 1; - } - - w->holding_zero = 0; - } - else - putbits ((1L << w->holding_one) - 1, w->holding_one, bs); - - w->holding_one = 0; - } - - if (w->holding_zero) { - putbit_0 (bs); - w->holding_zero = 0; - } - - if (w->pend_count) { - - while (w->pend_count > 24) { - putbit (w->pend_data & 1, bs); - w->pend_data >>= 1; - w->pend_count--; - } - - putbits (w->pend_data, w->pend_count, bs); - w->pend_data = w->pend_count = 0; - } -} - -// The concept of a base 2 logarithm is used in many parts of WavPack. It is -// a way of sufficiently accurately representing 32-bit signed and unsigned -// values storing only 16 bits (actually fewer). It is also used in the hybrid -// mode for quickly comparing the relative magnitude of large values (i.e. -// division) and providing smooth exponentials using only addition. - -// These are not strict logarithms in that they become linear around zero and -// can therefore represent both zero and negative values. They have 8 bits -// of precision and in "roundtrip" conversions the total error never exceeds 1 -// part in 225 except for the cases of +/-115 and +/-195 (which error by 1). - - -// This function returns the log2 for the specified 32-bit unsigned value. -// The maximum value allowed is about 0xff800000 and returns 8447. - -static int mylog2 (uint32_t avalue) -{ - int dbits; - - if ((avalue += avalue >> 9) < (1 << 8)) { - dbits = nbits_table [avalue]; - return (dbits << 8) + log2_table [(avalue << (9 - dbits)) & 0xff]; - } - else { - if (avalue < (1L << 16)) - dbits = nbits_table [avalue >> 8] + 8; - else if (avalue < (1L << 24)) - dbits = nbits_table [avalue >> 16] + 16; - else - dbits = nbits_table [avalue >> 24] + 24; - - return (dbits << 8) + log2_table [(avalue >> (dbits - 9)) & 0xff]; - } -} - -// This function returns the log2 for the specified 32-bit signed value. -// All input values are valid and the return values are in the range of -// +/- 8192. - -int log2s (int32_t value) -{ - return (value < 0) ? -mylog2 (-value) : mylog2 (value); -} - -// This function returns the original integer represented by the supplied -// logarithm (at least within the provided accuracy). The log is signed, -// but since a full 32-bit value is returned this can be used for unsigned -// conversions as well (i.e. the input range is -8192 to +8447). - -int32_t exp2s (int log) -{ - uint32_t value; - - if (log < 0) - return -exp2s (-log); - - value = exp2_table [log & 0xff] | 0x100; - - if ((log >>= 8) <= 9) - return value >> (9 - log); - else - return value << (log - 9); -} - -// These two functions convert internal weights (which are normally +/-1024) -// to and from an 8-bit signed character version for storage in metadata. The -// weights are clipped here in the case that they are outside that range. - -signed char store_weight (int weight) -{ - if (weight > 1024) - weight = 1024; - else if (weight < -1024) - weight = -1024; - - if (weight > 0) - weight -= (weight + 64) >> 7; - - return (weight + 4) >> 3; -} - -int restore_weight (signed char weight) -{ - int result; - - if ((result = (int) weight << 3) > 0) - result += (result + 64) >> 7; - - return result; -} diff --git a/apps/codecs/libwavpack/wputils.c b/apps/codecs/libwavpack/wputils.c deleted file mode 100644 index b0ccd3ba83..0000000000 --- a/apps/codecs/libwavpack/wputils.c +++ /dev/null @@ -1,555 +0,0 @@ -//////////////////////////////////////////////////////////////////////////// -// **** WAVPACK **** // -// Hybrid Lossless Wavefile Compressor // -// Copyright (c) 1998 - 2004 Conifer Software. // -// All Rights Reserved. // -// Distributed under the BSD Software License (see license.txt) // -//////////////////////////////////////////////////////////////////////////// - -// wputils.c - -// This module provides a high-level interface for decoding WavPack 4.0 audio -// streams and files. WavPack data is read with a stream reading callback. No -// direct seeking is provided for, but it is possible to start decoding -// anywhere in a WavPack stream. In this case, WavPack will be able to provide -// the sample-accurate position when it synchs with the data and begins -// decoding. - -#include "wavpack.h" - -#include - -static void strcpy_loc (char *dst, char *src) { while ((*dst++ = *src++) != 0); } - -///////////////////////////// local table storage //////////////////////////// - -const uint32_t sample_rates [] = { 6000, 8000, 9600, 11025, 12000, 16000, 22050, - 24000, 32000, 44100, 48000, 64000, 88200, 96000, 192000 }; - -///////////////////////////// executable code //////////////////////////////// - -static uint32_t read_next_header (read_stream infile, WavpackHeader *wphdr); - -// This function reads data from the specified stream in search of a valid -// WavPack 4.0 audio block. If this fails in 1 megabyte (or an invalid or -// unsupported WavPack block is encountered) then an appropriate message is -// copied to "error" and NULL is returned, otherwise a pointer to a -// WavpackContext structure is returned (which is used to call all other -// functions in this module). This can be initiated at the beginning of a -// WavPack file, or anywhere inside a WavPack file. To determine the exact -// position within the file use WavpackGetSampleIndex(). For demonstration -// purposes this uses a single static copy of the WavpackContext structure, -// so obviously it cannot be used for more than one file at a time. Also, -// this function will not handle "correction" files, plays only the first -// two channels of multi-channel files, and is limited in resolution in some -// large integer or floating point files (but always provides at least 24 bits -// of resolution). - -static WavpackContext wpc IBSS_ATTR; - -WavpackContext *WavpackOpenFileInput (read_stream infile, char *error) -{ - WavpackStream *wps = &wpc.stream; - uint32_t bcount; - - CLEAR (wpc); - wpc.infile = infile; - wpc.total_samples = (uint32_t) -1; - wpc.norm_offset = 0; - wpc.open_flags = 0; - - // open the source file for reading and store the size - - while (!wps->wphdr.block_samples) { - - bcount = read_next_header (wpc.infile, &wps->wphdr); - - if (bcount == (uint32_t) -1) { - strcpy_loc (error, "invalid WavPack file!"); - return NULL; - } - - wps->block_bytes_left = wps->wphdr.ckSize - 24; - - if ((wps->wphdr.flags & UNKNOWN_FLAGS) || wps->wphdr.version < MIN_STREAM_VERS || - wps->wphdr.version > MAX_STREAM_VERS) { - strcpy_loc (error, "invalid WavPack file!"); - return NULL; - } - - if (wps->wphdr.block_samples && wps->wphdr.total_samples != (uint32_t) -1) - wpc.total_samples = wps->wphdr.total_samples; - - if (!unpack_init (&wpc)) { - strcpy_loc (error, wpc.error_message [0] ? wpc.error_message : - "invalid WavPack file!"); - - return NULL; - } - } - - wpc.config.flags &= ~0xff; - wpc.config.flags |= wps->wphdr.flags & 0xff; - wpc.config.bytes_per_sample = (wps->wphdr.flags & BYTES_STORED) + 1; - wpc.config.float_norm_exp = wps->float_norm_exp; - - wpc.config.bits_per_sample = (wpc.config.bytes_per_sample * 8) - - ((wps->wphdr.flags & SHIFT_MASK) >> SHIFT_LSB); - - if (!wpc.config.sample_rate) { - if (!wps || !wps->wphdr.block_samples || (wps->wphdr.flags & SRATE_MASK) == SRATE_MASK) - wpc.config.sample_rate = 44100; - else - wpc.config.sample_rate = sample_rates [(wps->wphdr.flags & SRATE_MASK) >> SRATE_LSB]; - } - - if (!wpc.config.num_channels) { - wpc.config.num_channels = (wps->wphdr.flags & MONO_FLAG) ? 1 : 2; - wpc.config.channel_mask = 0x5 - wpc.config.num_channels; - } - - if (!(wps->wphdr.flags & FINAL_BLOCK)) - wpc.reduced_channels = (wps->wphdr.flags & MONO_FLAG) ? 1 : 2; - - return &wpc; -} - -// This function obtains general information about an open file and returns -// a mask with the following bit values: - -// MODE_LOSSLESS: file is lossless (pure lossless only) -// MODE_HYBRID: file is hybrid mode (lossy part only) -// MODE_FLOAT: audio data is 32-bit ieee floating point -// MODE_HIGH: file was created in "high" mode (information only) -// MODE_FAST: file was created in "fast" mode (information only) - -int WavpackGetMode (WavpackContext *wpc) -{ - int mode = 0; - - if (wpc) { - if (wpc->config.flags & CONFIG_HYBRID_FLAG) - mode |= MODE_HYBRID; - else if (!(wpc->config.flags & CONFIG_LOSSY_MODE)) - mode |= MODE_LOSSLESS; - - if (wpc->lossy_blocks) - mode &= ~MODE_LOSSLESS; - - if (wpc->config.flags & CONFIG_FLOAT_DATA) - mode |= MODE_FLOAT; - - if (wpc->config.flags & CONFIG_HIGH_FLAG) - mode |= MODE_HIGH; - - if (wpc->config.flags & CONFIG_FAST_FLAG) - mode |= MODE_FAST; - } - - return mode; -} - -// Unpack the specified number of samples from the current file position. -// Note that "samples" here refers to "complete" samples, which would be -// 2 int32_t's for stereo files. The audio data is returned right-justified in -// 32-bit int32_t's in the endian mode native to the executing processor. So, -// if the original data was 16-bit, then the values returned would be -// +/-32k. Floating point data can also be returned if the source was -// floating point data (and this is normalized to +/-1.0). The actual number -// of samples unpacked is returned, which should be equal to the number -// requested unless the end of fle is encountered or an error occurs. - -uint32_t WavpackUnpackSamples (WavpackContext *wpc, int32_t *buffer, uint32_t samples) -{ - WavpackStream *wps = &wpc->stream; - uint32_t bcount, samples_unpacked = 0, samples_to_unpack; - int num_channels = wpc->config.num_channels; - - while (samples) { - if (!wps->wphdr.block_samples || !(wps->wphdr.flags & INITIAL_BLOCK) || - wps->sample_index >= wps->wphdr.block_index + wps->wphdr.block_samples) { - bcount = read_next_header (wpc->infile, &wps->wphdr); - - if (bcount == (uint32_t) -1) - break; - - wps->block_bytes_left = wps->wphdr.ckSize - 24; - - if (wps->wphdr.version < MIN_STREAM_VERS || wps->wphdr.version > MAX_STREAM_VERS) { - strcpy_loc (wpc->error_message, "invalid WavPack file!"); - break; - } - - if (!wps->wphdr.block_samples || wps->sample_index == wps->wphdr.block_index) - if (!unpack_init (wpc)) - break; - } - - if (!wps->wphdr.block_samples || !(wps->wphdr.flags & INITIAL_BLOCK) || - wps->sample_index >= wps->wphdr.block_index + wps->wphdr.block_samples) - continue; - - if (wps->sample_index < wps->wphdr.block_index) { - samples_to_unpack = wps->wphdr.block_index - wps->sample_index; - - if (samples_to_unpack > samples) - samples_to_unpack = samples; - - wps->sample_index += samples_to_unpack; - samples_unpacked += samples_to_unpack; - samples -= samples_to_unpack; - - if (wpc->reduced_channels) - samples_to_unpack *= wpc->reduced_channels; - else - samples_to_unpack *= num_channels; - - while (samples_to_unpack--) - *buffer++ = 0; - - continue; - } - - samples_to_unpack = wps->wphdr.block_index + wps->wphdr.block_samples - wps->sample_index; - - if (samples_to_unpack > samples) - samples_to_unpack = samples; - - unpack_samples (wpc, buffer, samples_to_unpack); - - if (wpc->reduced_channels) - buffer += samples_to_unpack * wpc->reduced_channels; - else - buffer += samples_to_unpack * num_channels; - - samples_unpacked += samples_to_unpack; - samples -= samples_to_unpack; - - if (wps->sample_index == wps->wphdr.block_index + wps->wphdr.block_samples) { - if (check_crc_error (wpc)) - wpc->crc_errors++; - } - - if (wps->sample_index == wpc->total_samples) - break; - } - - return samples_unpacked; -} - -// Get total number of samples contained in the WavPack file, or -1 if unknown - -uint32_t WavpackGetNumSamples (WavpackContext *wpc) -{ - return wpc ? wpc->total_samples : (uint32_t) -1; -} - -// Get the current sample index position, or -1 if unknown - -uint32_t WavpackGetSampleIndex (WavpackContext *wpc) -{ - if (wpc) - return wpc->stream.sample_index; - - return (uint32_t) -1; -} - -// Get the number of errors encountered so far - -int WavpackGetNumErrors (WavpackContext *wpc) -{ - return wpc ? wpc->crc_errors : 0; -} - -// return TRUE if any uncorrected lossy blocks were actually written or read - -int WavpackLossyBlocks (WavpackContext *wpc) -{ - return wpc ? wpc->lossy_blocks : 0; -} - -// Returns the sample rate of the specified WavPack file - -uint32_t WavpackGetSampleRate (WavpackContext *wpc) -{ - return wpc ? wpc->config.sample_rate : 44100; -} - -// Returns the number of channels of the specified WavPack file. Note that -// this is the actual number of channels contained in the file, but this -// version can only decode the first two. - -int WavpackGetNumChannels (WavpackContext *wpc) -{ - return wpc ? wpc->config.num_channels : 2; -} - -// Returns the actual number of valid bits per sample contained in the -// original file, which may or may not be a multiple of 8. Floating data -// always has 32 bits, integers may be from 1 to 32 bits each. When this -// value is not a multiple of 8, then the "extra" bits are located in the -// LSBs of the results. That is, values are right justified when unpacked -// into int32_t's, but are left justified in the number of bytes used by the -// original data. - -int WavpackGetBitsPerSample (WavpackContext *wpc) -{ - return wpc ? wpc->config.bits_per_sample : 16; -} - -// Returns the number of bytes used for each sample (1 to 4) in the original -// file. This is required information for the user of this module because the -// audio data is returned in the LOWER bytes of the int32_t buffer and must be -// left-shifted 8, 16, or 24 bits if normalized int32_t's are required. - -int WavpackGetBytesPerSample (WavpackContext *wpc) -{ - return wpc ? wpc->config.bytes_per_sample : 2; -} - -// This function will return the actual number of channels decoded from the -// file (which may or may not be less than the actual number of channels, but -// will always be 1 or 2). Normally, this will be the front left and right -// channels of a multi-channel file. - -int WavpackGetReducedChannels (WavpackContext *wpc) -{ - if (wpc) - return wpc->reduced_channels ? wpc->reduced_channels : wpc->config.num_channels; - else - return 2; -} - -// Read from current file position until a valid 32-byte WavPack 4.0 header is -// found and read into the specified pointer. The number of bytes skipped is -// returned. If no WavPack header is found within 1 meg, then a -1 is returned -// to indicate the error. No additional bytes are read past the header and it -// is returned in the processor's native endian mode. Seeking is not required. - -static uint32_t read_next_header (read_stream infile, WavpackHeader *wphdr) -{ - char buffer [sizeof (*wphdr)], *sp = buffer + sizeof (*wphdr), *ep = sp; - uint32_t bytes_skipped = 0; - int bleft; - - while (1) { - if (sp < ep) { - bleft = ep - sp; - memcpy (buffer, sp, bleft); - } - else - bleft = 0; - - if (infile (buffer + bleft, sizeof (*wphdr) - bleft) != (int32_t) sizeof (*wphdr) - bleft) - return -1; - - sp = buffer; - - if (*sp++ == 'w' && *sp == 'v' && *++sp == 'p' && *++sp == 'k' && - !(*++sp & 1) && sp [2] < 16 && !sp [3] && sp [5] == 4 && - sp [4] >= (MIN_STREAM_VERS & 0xff) && sp [4] <= (MAX_STREAM_VERS & 0xff)) { - memcpy (wphdr, buffer, sizeof (*wphdr)); - little_endian_to_native (wphdr, WavpackHeaderFormat); - return bytes_skipped; - } - - while (sp < ep && *sp != 'w') - sp++; - - if ((bytes_skipped += sp - buffer) > 1024 * 1024) - return -1; - } -} - -// Open context for writing WavPack files. The returned context pointer is used -// in all following calls to the library. A return value of NULL indicates -// that memory could not be allocated for the context. - -WavpackContext *WavpackOpenFileOutput (void) -{ - CLEAR (wpc); - return &wpc; -} - -// Set configuration for writing WavPack files. This must be done before -// sending any actual samples, however it is okay to send wrapper or other -// metadata before calling this. The "config" structure contains the following -// required information: - -// config->bytes_per_sample see WavpackGetBytesPerSample() for info -// config->bits_per_sample see WavpackGetBitsPerSample() for info -// config->num_channels self evident -// config->sample_rate self evident - -// In addition, the following fields and flags may be set: - -// config->flags: -// -------------- -// o CONFIG_HYBRID_FLAG select hybrid mode (must set bitrate) -// o CONFIG_JOINT_STEREO select joint stereo (must set override also) -// o CONFIG_JOINT_OVERRIDE override default joint stereo selection -// o CONFIG_HYBRID_SHAPE select hybrid noise shaping (set override & -// shaping_weight != 0.0) -// o CONFIG_SHAPE_OVERRIDE override default hybrid noise shaping -// (set CONFIG_HYBRID_SHAPE and shaping_weight) -// o CONFIG_FAST_FLAG "fast" compression mode -// o CONFIG_HIGH_FLAG "high" compression mode -// o CONFIG_BITRATE_KBPS hybrid bitrate is kbps, not bits / sample - -// config->bitrate hybrid bitrate in either bits/sample or kbps -// config->shaping_weight hybrid noise shaping coefficient override -// config->float_norm_exp select floating-point data (127 for +/-1.0) - -// If the number of samples to be written is known then it should be passed -// here. If the duration is not known then pass -1. In the case that the size -// is not known (or the writing is terminated early) then it is suggested that -// the application retrieve the first block written and let the library update -// the total samples indication. A function is provided to do this update and -// it should be done to the "correction" file also. If this cannot be done -// (because a pipe is being used, for instance) then a valid WavPack will still -// be created, but when applications want to access that file they will have -// to seek all the way to the end to determine the actual duration. Also, if -// a RIFF header has been included then it should be updated as well or the -// WavPack file will not be directly unpackable to a valid wav file (although -// it will still be usable by itself). A return of FALSE indicates an error. - -int WavpackSetConfiguration (WavpackContext *wpc, WavpackConfig *config, uint32_t total_samples) -{ - WavpackStream *wps = &wpc->stream; - uint32_t flags = (config->bytes_per_sample - 1), shift = 0; - int num_chans = config->num_channels; - int i; - - if ((wpc->config.flags & CONFIG_HYBRID_FLAG) || - wpc->config.float_norm_exp || - num_chans < 1 || num_chans > 2) - return FALSE; - - wpc->total_samples = total_samples; - wpc->config.sample_rate = config->sample_rate; - wpc->config.num_channels = config->num_channels; - wpc->config.bits_per_sample = config->bits_per_sample; - wpc->config.bytes_per_sample = config->bytes_per_sample; - wpc->config.flags = config->flags; - - shift = (config->bytes_per_sample * 8) - config->bits_per_sample; - - for (i = 0; i < 15; ++i) - if (wpc->config.sample_rate == sample_rates [i]) - break; - - flags |= i << SRATE_LSB; - flags |= shift << SHIFT_LSB; - flags |= CROSS_DECORR; - - if (!(config->flags & CONFIG_JOINT_OVERRIDE) || (config->flags & CONFIG_JOINT_STEREO)) - flags |= JOINT_STEREO; - - flags |= INITIAL_BLOCK | FINAL_BLOCK; - - if (num_chans == 1) { - flags &= ~(JOINT_STEREO | CROSS_DECORR | HYBRID_BALANCE); - flags |= MONO_FLAG; - } - - flags &= ~MAG_MASK; - flags += (1 << MAG_LSB) * ((flags & BYTES_STORED) * 8 + 7); - - memcpy (wps->wphdr.ckID, "wvpk", 4); - wps->wphdr.ckSize = sizeof (WavpackHeader) - 8; - wps->wphdr.total_samples = wpc->total_samples; - wps->wphdr.version = CUR_STREAM_VERS; - wps->wphdr.flags = flags; - - pack_init (wpc); - return TRUE; -} - -// Add wrapper (currently RIFF only) to WavPack blocks. This should be called -// before sending any audio samples. If the exact contents of the RIFF header -// are not known because, for example, the file duration is uncertain or -// trailing chunks are possible, simply write a "dummy" header of the correct -// length. When all data has been written it will be possible to read the -// first block written and update the header directly. An example of this can -// be found in the Audition filter. - -void WavpackAddWrapper (WavpackContext *wpc, void *data, uint32_t bcount) -{ - wpc->wrapper_data = data; - wpc->wrapper_bytes = bcount; -} - -// Start a WavPack block to be stored in the specified buffer. This must be -// called before calling WavpackPackSamples(). Note that writing CANNOT wrap -// in the buffer; the entire output block must fit in the buffer. - -int WavpackStartBlock (WavpackContext *wpc, uchar *begin, uchar *end) -{ - wpc->stream.blockbuff = begin; - wpc->stream.blockend = end; - return pack_start_block (wpc); -} - -// Pack the specified samples. Samples must be stored in int32_ts in the native -// endian format of the executing processor. The number of samples specified -// indicates composite samples (sometimes called "frames"). So, the actual -// number of data points would be this "sample_count" times the number of -// channels. The caller must decide how many samples to place in each -// WavPack block (1/2 second is common), but this function may be called as -// many times as desired to build the final block (and performs the actual -// compression during the call). A return of FALSE indicates an error. - -int WavpackPackSamples (WavpackContext *wpc, int32_t *sample_buffer, uint32_t sample_count) -{ - if (!sample_count || pack_samples (wpc, sample_buffer, sample_count)) - return TRUE; - - strcpy_loc (wpc->error_message, "output buffer overflowed!"); - return FALSE; -} - -// Finish the WavPack block being built, returning the total size of the -// block in bytes. Note that the possible conversion of the WavPack header to -// little-endian takes place here. - -uint32_t WavpackFinishBlock (WavpackContext *wpc) -{ - WavpackStream *wps = &wpc->stream; - uint32_t bcount; - - pack_finish_block (wpc); - bcount = ((WavpackHeader *) wps->blockbuff)->ckSize + 8; - native_to_little_endian ((WavpackHeader *) wps->blockbuff, WavpackHeaderFormat); - - return bcount; -} - -// Given the pointer to the first block written (to either a .wv or .wvc file), -// update the block with the actual number of samples written. This should -// be done if WavpackSetConfiguration() was called with an incorrect number -// of samples (or -1). It is the responsibility of the application to read and -// rewrite the block. An example of this can be found in the Audition filter. - -void WavpackUpdateNumSamples (WavpackContext *wpc, void *first_block) -{ - little_endian_to_native (wpc, WavpackHeaderFormat); - ((WavpackHeader *) first_block)->total_samples = WavpackGetSampleIndex (wpc); - native_to_little_endian (wpc, WavpackHeaderFormat); -} - -// Given the pointer to the first block written to a WavPack file, this -// function returns the location of the stored RIFF header that was originally -// written with WavpackAddWrapper(). This would normally be used to update -// the wav header to indicate that a different number of samples was actually -// written or if additional RIFF chunks are written at the end of the file. -// It is the responsibility of the application to read and rewrite the block. -// An example of this can be found in the Audition filter. - -void *WavpackGetWrapperLocation (void *first_block) -{ - if (((uchar *) first_block) [32] == ID_RIFF_HEADER) - return ((uchar *) first_block) + 34; - else - return NULL; -} - diff --git a/apps/codecs/libwma/SOURCES b/apps/codecs/libwma/SOURCES deleted file mode 100644 index 14cf0c8922..0000000000 --- a/apps/codecs/libwma/SOURCES +++ /dev/null @@ -1,3 +0,0 @@ -wmadeci.c -wmafixed.c -../lib/ffmpeg_bitstream.c diff --git a/apps/codecs/libwma/libwma.make b/apps/codecs/libwma/libwma.make deleted file mode 100644 index 71c4cdc626..0000000000 --- a/apps/codecs/libwma/libwma.make +++ /dev/null @@ -1,18 +0,0 @@ -# __________ __ ___. -# Open \______ \ ____ ____ | | _\_ |__ _______ ___ -# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / -# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < -# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ -# \/ \/ \/ \/ \/ -# $Id$ -# - -# libwma -WMALIB := $(CODECDIR)/libwma.a -WMALIB_SRC := $(call preprocess, $(APPSDIR)/codecs/libwma/SOURCES) -WMALIB_OBJ := $(call c2obj, $(WMALIB_SRC)) -OTHER_SRC += $(WMALIB_SRC) - -$(WMALIB): $(WMALIB_OBJ) - $(SILENT)$(shell rm -f $@) - $(call PRINTS,AR $(@F))$(AR) rcs $@ $^ >/dev/null diff --git a/apps/codecs/libwma/types.h b/apps/codecs/libwma/types.h deleted file mode 100644 index 8a5e2a992e..0000000000 --- a/apps/codecs/libwma/types.h +++ /dev/null @@ -1,5 +0,0 @@ -#include - -#define fixed32 int32_t -#define fixed64 int64_t - diff --git a/apps/codecs/libwma/wmadata.h b/apps/codecs/libwma/wmadata.h deleted file mode 100644 index 07a55df19a..0000000000 --- a/apps/codecs/libwma/wmadata.h +++ /dev/null @@ -1,2609 +0,0 @@ -/* - * WMA compatible decoder - * copyright (c) 2002 The FFmpeg Project - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/** - * @file wmadata.h - * Various WMA tables. - */ - -static const uint16_t wma_critical_freqs[25] = { - 100, 200, 300, 400, 510, 630, 770, 920, - 1080, 1270, 1480, 1720, 2000, 2320, 2700, 3150, - 3700, 4400, 5300, 6400, 7700, 9500, 12000, 15500, - 24500, -}; - -/* first value is number of bands */ -static const uint8_t exponent_band_22050[3][25] = { - { 10, 4, 8, 4, 8, 8, 12, 20, 24, 24, 16, }, - { 14, 4, 8, 8, 4, 12, 12, 16, 24, 16, 20, 24, 32, 40, 36, }, - { 23, 4, 4, 4, 8, 4, 4, 8, 8, 8, 8, 8, 12, 12, 16, 16, 24, 24, 32, 44, 48, 60, 84, 72, }, -}; - -static const uint8_t exponent_band_32000[3][25] = { - { 11, 4, 4, 8, 4, 4, 12, 16, 24, 20, 28, 4, }, - { 15, 4, 8, 4, 4, 8, 8, 16, 20, 12, 20, 20, 28, 40, 56, 8, }, - { 16, 8, 4, 8, 8, 12, 16, 20, 24, 40, 32, 32, 44, 56, 80, 112, 16, }, -}; - -static const uint8_t exponent_band_44100[3][25] = { - { 12, 4, 4, 4, 4, 4, 8, 8, 8, 12, 16, 20, 36, }, - { 15, 4, 8, 4, 8, 8, 4, 8, 8, 12, 12, 12, 24, 28, 40, 76, }, - { 17, 4, 8, 8, 4, 12, 12, 8, 8, 24, 16, 20, 24, 32, 40, 60, 80, 152, }, -}; - -static const uint16_t hgain_huffcodes[37] = { - 0x00003, 0x002e7, 0x00001, 0x005cd, 0x0005d, 0x005c9, 0x0005e, 0x00003, - 0x00016, 0x0000b, 0x00001, 0x00006, 0x00001, 0x00006, 0x00004, 0x00005, - 0x00004, 0x00007, 0x00003, 0x00007, 0x00004, 0x0000a, 0x0000a, 0x00002, - 0x00003, 0x00000, 0x00005, 0x00002, 0x0005f, 0x00004, 0x00003, 0x00002, - 0x005c8, 0x000b8, 0x005ca, 0x005cb, 0x005cc, -}; - -static const uint8_t hgain_huffbits[37] = { - 10, 12, 10, 13, 9, 13, 9, 8, - 7, 5, 5, 4, 4, 3, 3, 3, - 4, 3, 4, 4, 5, 5, 6, 8, - 7, 10, 8, 10, 9, 8, 9, 9, - 13, 10, 13, 13, 13, -}; - -static const fixed32 lsp_codebook[NB_LSP_COEFS][16] = { -{0x1fcc2,0x1fabd,0x1f8c7,0x1f66d,0x1f34c,0x1eef1,0x1e83e,0x1dca6,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0}, -{0x1f8fc,0x1f5f9,0x1f328,0x1f025,0x1ecd8,0x1e8fc,0x1e46f,0x1df1b,0x1d87c,0x1d047,0x1c6b5,0x1bb8f,0x1add8,0x19c0e,0x18220,0x154ca}, -{0x1e6ae,0x1dd65,0x1d58e,0x1cd3b,0x1c439,0x1ba69,0x1af5e,0x1a32c,0x195c4,0x18498,0x16fd2,0x156ea,0x13de4,0x11f63,0xf7ae,0xbd90}, -{0x1c4fa,0x1ada0,0x19976,0x1891d,0x17986,0x1697f,0x15858,0x145fd,0x1316b,0x11900,0xfcfa,0xdf55,0xbe63,0x9902,0x6e83,0x2e05}, -{0x16f2d,0x15205,0x135f3,0x11b14,0x10170,0xe743,0xcdec,0xb504,0x9ab2,0x7f86,0x6296,0x4565,0x24e2,0x90,0xffffd52f,0xffffa172}, -{0xffbc,0xd786,0xb521,0x943e,0x7876,0x5ea3,0x44ad,0x2bf0,0x1274,0xfffff829,0xfffe9981,0xffffbfab,0xffffa0bb,0xffff7d3f,0xffff59e3,0xffff3269}, -{0x43e1,0x102a,0xffffe94a,0xffffc9fa,0xffffb076,0xffff9a6b,0xffff871c,0xffff7555,0xffff62b4,0xffff4f81,0xffff3bf4,0xffff25f7,0xffff0c0f,0xfffeef53,0xfffecb7e,0xfffe9fb3}, -{0xffff75ea,0xffff4325,0xffff1da2,0xfffefd23,0xfffeddb9,0xfffebb51,0xfffe945f,0xfffe6131,0xfffee5fe,0xfffed5ba,0xfffec442,0xfffeb224,0xfffe9f95,0xfffe880e,0xfffe6c7a,0xfffe54c1}, -{0xffff9d2e,0xffff709e,0xffff5489,0xffff3d5e,0xffff295b,0xffff1761,0xffff06a2,0xfffef68a,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0}, -{0xfffe7045,0xfffe572f,0xfffe45ea,0xfffe38af,0xfffe2d8f,0xfffe2347,0xfffe18df,0xfffe0d42,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0} -}; - -static const uint32_t scale_huffcodes[121] = { - 0x3ffe8, 0x3ffe6, 0x3ffe7, 0x3ffe5, 0x7fff5, 0x7fff1, 0x7ffed, 0x7fff6, - 0x7ffee, 0x7ffef, 0x7fff0, 0x7fffc, 0x7fffd, 0x7ffff, 0x7fffe, 0x7fff7, - 0x7fff8, 0x7fffb, 0x7fff9, 0x3ffe4, 0x7fffa, 0x3ffe3, 0x1ffef, 0x1fff0, - 0x0fff5, 0x1ffee, 0x0fff2, 0x0fff3, 0x0fff4, 0x0fff1, 0x07ff6, 0x07ff7, - 0x03ff9, 0x03ff5, 0x03ff7, 0x03ff3, 0x03ff6, 0x03ff2, 0x01ff7, 0x01ff5, - 0x00ff9, 0x00ff7, 0x00ff6, 0x007f9, 0x00ff4, 0x007f8, 0x003f9, 0x003f7, - 0x003f5, 0x001f8, 0x001f7, 0x000fa, 0x000f8, 0x000f6, 0x00079, 0x0003a, - 0x00038, 0x0001a, 0x0000b, 0x00004, 0x00000, 0x0000a, 0x0000c, 0x0001b, - 0x00039, 0x0003b, 0x00078, 0x0007a, 0x000f7, 0x000f9, 0x001f6, 0x001f9, - 0x003f4, 0x003f6, 0x003f8, 0x007f5, 0x007f4, 0x007f6, 0x007f7, 0x00ff5, - 0x00ff8, 0x01ff4, 0x01ff6, 0x01ff8, 0x03ff8, 0x03ff4, 0x0fff0, 0x07ff4, - 0x0fff6, 0x07ff5, 0x3ffe2, 0x7ffd9, 0x7ffda, 0x7ffdb, 0x7ffdc, 0x7ffdd, - 0x7ffde, 0x7ffd8, 0x7ffd2, 0x7ffd3, 0x7ffd4, 0x7ffd5, 0x7ffd6, 0x7fff2, - 0x7ffdf, 0x7ffe7, 0x7ffe8, 0x7ffe9, 0x7ffea, 0x7ffeb, 0x7ffe6, 0x7ffe0, - 0x7ffe1, 0x7ffe2, 0x7ffe3, 0x7ffe4, 0x7ffe5, 0x7ffd7, 0x7ffec, 0x7fff4, - 0x7fff3, -}; - -static const uint8_t scale_huffbits[121] = { - 18, 18, 18, 18, 19, 19, 19, 19, - 19, 19, 19, 19, 19, 19, 19, 19, - 19, 19, 19, 18, 19, 18, 17, 17, - 16, 17, 16, 16, 16, 16, 15, 15, - 14, 14, 14, 14, 14, 14, 13, 13, - 12, 12, 12, 11, 12, 11, 10, 10, - 10, 9, 9, 8, 8, 8, 7, 6, - 6, 5, 4, 3, 1, 4, 4, 5, - 6, 6, 7, 7, 8, 8, 9, 9, - 10, 10, 10, 11, 11, 11, 11, 12, - 12, 13, 13, 13, 14, 14, 16, 15, - 16, 15, 18, 19, 19, 19, 19, 19, - 19, 19, 19, 19, 19, 19, 19, 19, - 19, 19, 19, 19, 19, 19, 19, 19, - 19, 19, 19, 19, 19, 19, 19, 19, - 19, -}; - -static const uint32_t coef0_huffcodes[666] = { - 0x00258, 0x0003d, 0x00000, 0x00005, 0x00008, 0x00008, 0x0000c, 0x0001b, - 0x0001f, 0x00015, 0x00024, 0x00032, 0x0003a, 0x00026, 0x0002c, 0x0002f, - 0x0004a, 0x0004d, 0x00061, 0x00070, 0x00073, 0x00048, 0x00052, 0x0005a, - 0x0005d, 0x0006e, 0x00099, 0x0009e, 0x000c1, 0x000ce, 0x000e4, 0x000f0, - 0x00093, 0x0009e, 0x000a2, 0x000a1, 0x000b8, 0x000d2, 0x000d3, 0x0012e, - 0x00130, 0x000de, 0x0012d, 0x0019b, 0x001e4, 0x00139, 0x0013a, 0x0013f, - 0x0014f, 0x0016d, 0x001a2, 0x0027c, 0x0027e, 0x00332, 0x0033c, 0x0033f, - 0x0038b, 0x00396, 0x003c5, 0x00270, 0x0027c, 0x0025a, 0x00395, 0x00248, - 0x004bd, 0x004fb, 0x00662, 0x00661, 0x0071b, 0x004e6, 0x004ff, 0x00666, - 0x0071c, 0x0071a, 0x0071f, 0x00794, 0x00536, 0x004e2, 0x0078e, 0x004ee, - 0x00518, 0x00535, 0x004fb, 0x0078d, 0x00530, 0x00680, 0x0068f, 0x005cb, - 0x00965, 0x006a6, 0x00967, 0x0097f, 0x00682, 0x006ae, 0x00cd0, 0x00e28, - 0x00f13, 0x00f1f, 0x009f5, 0x00cd3, 0x00f11, 0x00926, 0x00964, 0x00f32, - 0x00f12, 0x00f30, 0x00966, 0x00d0b, 0x00a68, 0x00b91, 0x009c7, 0x00b73, - 0x012fa, 0x0131d, 0x013f9, 0x01ca0, 0x0199c, 0x01c7a, 0x0198c, 0x01248, - 0x01c74, 0x01c64, 0x0139e, 0x012fd, 0x00a77, 0x012fc, 0x01c7b, 0x012ca, - 0x014cc, 0x014d2, 0x014e3, 0x014dc, 0x012dc, 0x03344, 0x02598, 0x0263c, - 0x0333b, 0x025e6, 0x01a1c, 0x01e3c, 0x014e2, 0x033d4, 0x01a11, 0x03349, - 0x03cce, 0x014e1, 0x01a34, 0x0273e, 0x02627, 0x0273f, 0x038ee, 0x03971, - 0x03c67, 0x03c61, 0x0333d, 0x038c2, 0x0263f, 0x038cd, 0x02638, 0x02e41, - 0x0351f, 0x03348, 0x03c66, 0x03562, 0x02989, 0x027d5, 0x0333c, 0x02e4f, - 0x0343b, 0x02ddf, 0x04bc8, 0x029c0, 0x02e57, 0x04c72, 0x025b7, 0x03547, - 0x03540, 0x029d3, 0x04c45, 0x025bb, 0x06600, 0x04c73, 0x04bce, 0x0357b, - 0x029a6, 0x029d2, 0x0263e, 0x0298a, 0x07183, 0x06602, 0x07958, 0x04b66, - 0x0537d, 0x05375, 0x04fe9, 0x04b67, 0x0799f, 0x04bc9, 0x051fe, 0x06a3b, - 0x05bb6, 0x04fa8, 0x0728f, 0x05376, 0x0492c, 0x0537e, 0x0795a, 0x06a3c, - 0x0e515, 0x07887, 0x0683a, 0x051f9, 0x051fd, 0x0cc6a, 0x06a8a, 0x0cc6d, - 0x05bb3, 0x0683b, 0x051fc, 0x05378, 0x0728e, 0x07886, 0x05bb7, 0x0f2a4, - 0x0795b, 0x0683c, 0x09fc1, 0x0683d, 0x0b752, 0x09678, 0x0a3e8, 0x06ac7, - 0x051f0, 0x0b759, 0x06af3, 0x04b6b, 0x0f2a0, 0x0f2ad, 0x096c3, 0x0e518, - 0x0b75c, 0x0d458, 0x0cc6b, 0x0537c, 0x067aa, 0x04fea, 0x0343a, 0x0cc71, - 0x0967f, 0x09fc4, 0x096c2, 0x0e516, 0x0f2a1, 0x0d45c, 0x0d45d, 0x0d45e, - 0x12fb9, 0x0967e, 0x1982f, 0x09883, 0x096c4, 0x0b753, 0x12fb8, 0x0f2a8, - 0x1ca21, 0x096c5, 0x0e51a, 0x1ca27, 0x12f3c, 0x0d471, 0x0f2aa, 0x0b75b, - 0x12fbb, 0x0f2a9, 0x0f2ac, 0x0d45a, 0x0b74f, 0x096c8, 0x16e91, 0x096ca, - 0x12fbf, 0x0d0a7, 0x13103, 0x0d516, 0x16e99, 0x12cbd, 0x0a3ea, 0x19829, - 0x0b755, 0x29ba7, 0x1ca28, 0x29ba5, 0x16e93, 0x1982c, 0x19828, 0x25994, - 0x0a3eb, 0x1ca29, 0x16e90, 0x1ca25, 0x1982d, 0x1ca26, 0x16e9b, 0x0b756, - 0x0967c, 0x25997, 0x0b75f, 0x198d3, 0x0b757, 0x19a2a, 0x0d45b, 0x0e517, - 0x1ca24, 0x1ca23, 0x1ca22, 0x0b758, 0x16e97, 0x0cd14, 0x13100, 0x00007, - 0x0003b, 0x0006b, 0x00097, 0x00138, 0x00125, 0x00173, 0x00258, 0x00335, - 0x0028e, 0x004c6, 0x00715, 0x00729, 0x004ef, 0x00519, 0x004ed, 0x00532, - 0x0068c, 0x00686, 0x00978, 0x00e5d, 0x00e31, 0x009f4, 0x00b92, 0x012f8, - 0x00d06, 0x00a67, 0x00d44, 0x00a76, 0x00d59, 0x012cd, 0x01c78, 0x01c75, - 0x0199f, 0x0198f, 0x01c67, 0x014c6, 0x01c79, 0x01c76, 0x00b94, 0x00d1b, - 0x01e32, 0x01e31, 0x01ab0, 0x01a05, 0x01aa1, 0x0333a, 0x025e5, 0x02626, - 0x03541, 0x03544, 0x03421, 0x03546, 0x02e55, 0x02e56, 0x0492d, 0x02dde, - 0x0299b, 0x02ddc, 0x0357a, 0x0249c, 0x0668b, 0x1c77f, 0x1ca20, 0x0d45f, - 0x09886, 0x16e9a, 0x0f2a7, 0x0b751, 0x0a3ee, 0x0cf59, 0x0cf57, 0x0b754, - 0x0d0a6, 0x16e98, 0x0b760, 0x06ac6, 0x0a3f0, 0x12fbe, 0x13104, 0x0f2a5, - 0x0a3ef, 0x0d472, 0x12cba, 0x1982e, 0x16e9c, 0x1c77e, 0x198d0, 0x13105, - 0x16e92, 0x0b75d, 0x0d459, 0x0001a, 0x000c0, 0x0016c, 0x003cd, 0x00350, - 0x0067b, 0x0051e, 0x006a9, 0x009f4, 0x00b72, 0x00d09, 0x01249, 0x01e3d, - 0x01ca1, 0x01a1f, 0x01721, 0x01a8a, 0x016e8, 0x03347, 0x01a35, 0x0249d, - 0x0299a, 0x02596, 0x02e4e, 0x0298b, 0x07182, 0x04c46, 0x025ba, 0x02e40, - 0x027d6, 0x04fe8, 0x06607, 0x05310, 0x09884, 0x072e1, 0x06a3d, 0x04b6a, - 0x04c7a, 0x06603, 0x04c7b, 0x03428, 0x06605, 0x09664, 0x09fc0, 0x071de, - 0x06601, 0x05bb2, 0x09885, 0x0a3e2, 0x1c61f, 0x12cbb, 0x0b750, 0x0cf58, - 0x0967d, 0x25995, 0x668ad, 0x0b75a, 0x09fc2, 0x0537f, 0x0b75e, 0x13fae, - 0x12fbc, 0x00031, 0x001c4, 0x004c5, 0x005b8, 0x00cf4, 0x0096f, 0x00d46, - 0x01e57, 0x01a04, 0x02625, 0x03346, 0x028f9, 0x04c47, 0x072e0, 0x04b69, - 0x03420, 0x07957, 0x06639, 0x0799e, 0x07959, 0x07881, 0x04b68, 0x09fc3, - 0x09fd6, 0x0cc70, 0x0a3f1, 0x12cbe, 0x0e30e, 0x0e51b, 0x06af2, 0x12cbc, - 0x1c77d, 0x0f2ab, 0x12fbd, 0x1aa2f, 0x0a3ec, 0x0d473, 0x05377, 0x0a3e9, - 0x1982b, 0x0e300, 0x12f3f, 0x0cf5f, 0x096c0, 0x38c3c, 0x16e94, 0x16e95, - 0x12f3d, 0x29ba4, 0x29ba6, 0x1c77c, 0x6a8ba, 0x3545c, 0x33457, 0x668ac, - 0x6a8bb, 0x16e9d, 0x0e519, 0x25996, 0x12f3e, 0x00036, 0x0033e, 0x006ad, - 0x00d03, 0x012c8, 0x0124a, 0x03c42, 0x03ccd, 0x06606, 0x07880, 0x06852, - 0x06a3a, 0x05bb4, 0x0f2a2, 0x09fc7, 0x12cb9, 0x0cc6c, 0x0a6e8, 0x096c1, - 0x0004a, 0x00355, 0x012f9, 0x014e8, 0x01abe, 0x025b6, 0x0492e, 0x09fc6, - 0x051ff, 0x0cc6f, 0x096cb, 0x0d071, 0x198d1, 0x12cb8, 0x38c3d, 0x13faf, - 0x096c9, 0x0009d, 0x00539, 0x012ce, 0x0341f, 0x029c1, 0x04b33, 0x0a3e3, - 0x0d070, 0x16e96, 0x0b763, 0x000a0, 0x009ce, 0x038cc, 0x0343d, 0x051fa, - 0x09888, 0x12fba, 0x000df, 0x00a75, 0x029a7, 0x09fc5, 0x0e301, 0x0967b, - 0x001e7, 0x012c9, 0x051fb, 0x09889, 0x0f2a6, 0x0016f, 0x01cb9, 0x0cf5a, - 0x12cbf, 0x09679, 0x00272, 0x01a15, 0x0967a, 0x003cb, 0x025f6, 0x0b762, - 0x0028d, 0x03c60, 0x0cf5e, 0x00352, 0x03ccc, 0x0072f, 0x07186, 0x004ec, - 0x05379, 0x0068e, 0x09887, 0x006a7, 0x06af1, 0x00e29, 0x0cf5b, 0x00f31, - 0x0d470, 0x009c6, 0x013fb, 0x13102, 0x019a5, 0x13101, 0x01983, 0x01c65, - 0x0124f, 0x014c7, 0x01726, 0x01abf, 0x03304, 0x02624, 0x03c41, 0x027d7, - 0x02ddd, 0x02e54, 0x0343c, 0x06604, 0x07181, 0x0663a, 0x04fa9, 0x0663b, - 0x05311, 0x0537a, 0x06839, 0x05bb5, 0x0492f, 0x06af0, 0x096c7, 0x0cc6e, - 0x0537b, 0x0cf5c, 0x0cf56, 0x198d2, 0x0cf5d, 0x0a3ed, 0x0f2a3, 0x1982a, - 0x0b761, 0x096c6, -}; - -static const uint8_t coef0_huffbits[666] = { - 11, 6, 2, 3, 4, 5, 5, 5, - 5, 6, 6, 6, 6, 7, 7, 7, - 7, 7, 7, 7, 7, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, - 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 11, 11, 11, 10, 11, - 11, 11, 11, 11, 11, 11, 11, 11, - 11, 11, 11, 11, 12, 12, 11, 12, - 12, 12, 12, 11, 12, 12, 12, 12, - 12, 12, 12, 12, 12, 12, 12, 12, - 12, 12, 12, 12, 12, 13, 13, 12, - 12, 12, 13, 13, 13, 13, 13, 13, - 13, 13, 13, 13, 13, 13, 13, 14, - 13, 13, 13, 13, 13, 13, 13, 14, - 14, 14, 14, 14, 14, 14, 14, 14, - 14, 14, 14, 13, 14, 14, 14, 14, - 14, 14, 14, 14, 14, 14, 14, 14, - 14, 14, 14, 14, 14, 14, 14, 15, - 15, 14, 14, 15, 15, 15, 14, 15, - 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 14, 15, 15, 15, 15, 16, - 16, 16, 15, 16, 15, 15, 16, 16, - 16, 16, 15, 16, 16, 16, 15, 16, - 16, 15, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 15, 15, 16, 16, - 15, 16, 16, 16, 17, 17, 17, 16, - 16, 17, 16, 16, 16, 16, 17, 16, - 17, 17, 16, 16, 15, 15, 15, 16, - 17, 16, 17, 16, 16, 17, 17, 17, - 17, 17, 17, 16, 17, 17, 17, 16, - 17, 17, 16, 17, 17, 17, 16, 17, - 17, 16, 16, 17, 17, 17, 18, 17, - 17, 17, 17, 17, 18, 18, 17, 17, - 17, 19, 17, 19, 18, 17, 17, 18, - 17, 17, 18, 17, 17, 17, 18, 17, - 17, 18, 17, 17, 17, 17, 17, 16, - 17, 17, 17, 17, 18, 16, 17, 4, - 6, 8, 9, 9, 10, 10, 10, 10, - 11, 11, 11, 11, 12, 12, 12, 12, - 12, 12, 12, 12, 12, 13, 13, 13, - 13, 13, 13, 13, 13, 13, 13, 13, - 13, 13, 13, 14, 13, 13, 13, 13, - 13, 13, 14, 14, 14, 14, 14, 14, - 15, 15, 15, 15, 15, 15, 16, 15, - 15, 15, 15, 15, 15, 17, 17, 17, - 16, 18, 16, 17, 17, 16, 16, 17, - 17, 18, 17, 16, 17, 17, 17, 16, - 17, 17, 18, 17, 18, 17, 17, 17, - 18, 17, 17, 5, 8, 10, 10, 11, - 11, 12, 12, 12, 13, 13, 14, 13, - 13, 14, 14, 14, 14, 14, 14, 15, - 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 16, 16, 15, 16, 16, - 15, 15, 15, 15, 15, 16, 16, 15, - 15, 16, 16, 17, 17, 18, 17, 16, - 17, 18, 19, 17, 16, 16, 17, 17, - 17, 6, 9, 11, 12, 12, 13, 13, - 13, 14, 14, 14, 15, 15, 15, 16, - 15, 15, 15, 15, 15, 15, 16, 16, - 16, 16, 17, 18, 16, 16, 16, 18, - 17, 16, 17, 18, 17, 17, 16, 17, - 17, 16, 17, 16, 17, 18, 18, 18, - 17, 19, 19, 17, 20, 19, 18, 19, - 20, 18, 16, 18, 17, 7, 10, 12, - 13, 13, 14, 14, 14, 15, 15, 16, - 16, 16, 16, 16, 18, 16, 17, 17, - 8, 11, 13, 14, 14, 15, 16, 16, - 16, 16, 17, 17, 17, 18, 18, 17, - 17, 8, 12, 14, 15, 15, 15, 17, - 17, 18, 17, 9, 12, 14, 15, 16, - 16, 17, 9, 13, 15, 16, 16, 17, - 9, 13, 16, 16, 16, 10, 13, 16, - 18, 17, 10, 14, 17, 10, 14, 17, - 11, 14, 16, 11, 14, 11, 15, 12, - 16, 12, 16, 12, 16, 12, 16, 12, - 17, 13, 13, 17, 13, 17, 13, 13, - 14, 14, 14, 14, 14, 14, 14, 15, - 15, 15, 15, 15, 15, 15, 16, 15, - 16, 16, 16, 16, 16, 16, 17, 16, - 16, 16, 16, 17, 16, 17, 16, 17, - 17, 17, -}; - -static const uint32_t coef1_huffcodes[555] = { - 0x00115, 0x00002, 0x00001, 0x00000, 0x0000d, 0x00007, 0x00013, 0x0001d, - 0x00008, 0x0000c, 0x00023, 0x0002b, 0x0003f, 0x00017, 0x0001b, 0x00043, - 0x00049, 0x00050, 0x00055, 0x00054, 0x00067, 0x00064, 0x0007b, 0x0002d, - 0x00028, 0x0002a, 0x00085, 0x00089, 0x0002b, 0x00035, 0x00090, 0x00091, - 0x00094, 0x00088, 0x000c1, 0x000c6, 0x000f2, 0x000e3, 0x000c5, 0x000e2, - 0x00036, 0x000f0, 0x000a7, 0x000cd, 0x000fb, 0x00059, 0x00116, 0x00103, - 0x00108, 0x0012b, 0x0012d, 0x00188, 0x0012e, 0x0014c, 0x001c3, 0x00187, - 0x001e7, 0x0006f, 0x00094, 0x00069, 0x001e6, 0x001ca, 0x00147, 0x00195, - 0x000a7, 0x00213, 0x00209, 0x00303, 0x00295, 0x00289, 0x0028c, 0x0028d, - 0x00312, 0x00330, 0x0029b, 0x00308, 0x00328, 0x0029a, 0x0025e, 0x003c5, - 0x00384, 0x0039f, 0x00397, 0x00296, 0x0032e, 0x00332, 0x003c6, 0x003e6, - 0x0012d, 0x000d1, 0x00402, 0x000dd, 0x00161, 0x0012b, 0x00127, 0x0045d, - 0x00601, 0x004ab, 0x0045f, 0x00410, 0x004bf, 0x00528, 0x0045c, 0x00424, - 0x00400, 0x00511, 0x00618, 0x0073d, 0x0063a, 0x00614, 0x0073c, 0x007c0, - 0x007cf, 0x00802, 0x00966, 0x00964, 0x00951, 0x008a0, 0x00346, 0x00803, - 0x00a52, 0x0024a, 0x007c1, 0x0063f, 0x00126, 0x00406, 0x00789, 0x008a2, - 0x00960, 0x00967, 0x00c05, 0x00c70, 0x00c79, 0x00a5d, 0x00c26, 0x00c4d, - 0x00372, 0x008a5, 0x00c08, 0x002c5, 0x00f11, 0x00cc4, 0x00f8e, 0x00e16, - 0x00496, 0x00e77, 0x00f9c, 0x00c25, 0x00f1e, 0x00c27, 0x00f1f, 0x00e17, - 0x00ccd, 0x00355, 0x00c09, 0x00c78, 0x00f90, 0x00521, 0x00357, 0x00356, - 0x0068e, 0x00f9d, 0x00c04, 0x00e58, 0x00a20, 0x00a2c, 0x00c4c, 0x0052f, - 0x00f8d, 0x01178, 0x01053, 0x01097, 0x0180f, 0x0180d, 0x012fb, 0x012aa, - 0x0202a, 0x00a40, 0x018ed, 0x01ceb, 0x01455, 0x018e3, 0x012a1, 0x00354, - 0x00353, 0x00f1c, 0x00c7b, 0x00c37, 0x0101d, 0x012cb, 0x01142, 0x0197d, - 0x01095, 0x01e3b, 0x0186b, 0x00588, 0x01c2a, 0x014b8, 0x01e3a, 0x018ec, - 0x01f46, 0x012fa, 0x00a53, 0x01ce8, 0x00a55, 0x01c29, 0x0117b, 0x01052, - 0x012a0, 0x00589, 0x00950, 0x01c2b, 0x00a50, 0x0208b, 0x0180e, 0x02027, - 0x02556, 0x01e20, 0x006e7, 0x01c28, 0x0197a, 0x00684, 0x020a2, 0x01f22, - 0x03018, 0x039cf, 0x03e25, 0x02557, 0x0294c, 0x028a6, 0x00d11, 0x028a9, - 0x02979, 0x00d46, 0x00a56, 0x039ce, 0x030cc, 0x0329a, 0x0149d, 0x0510f, - 0x0451c, 0x02028, 0x03299, 0x01ced, 0x014b9, 0x00f85, 0x00c7a, 0x01800, - 0x00341, 0x012ca, 0x039c8, 0x0329d, 0x00d0d, 0x03e20, 0x05144, 0x00d45, - 0x030d0, 0x0186d, 0x030d5, 0x00d0f, 0x00d40, 0x04114, 0x020a1, 0x0297f, - 0x03e24, 0x032f1, 0x04047, 0x030d4, 0x028a8, 0x00d0e, 0x0451d, 0x04044, - 0x0297e, 0x04042, 0x030d2, 0x030cf, 0x03e21, 0x03e26, 0x028a5, 0x0451a, - 0x00d48, 0x01a16, 0x00d44, 0x04518, 0x0149b, 0x039ca, 0x01498, 0x0403d, - 0x0451b, 0x0149c, 0x032f3, 0x030cb, 0x08073, 0x03e22, 0x0529a, 0x020aa, - 0x039cc, 0x0738a, 0x06530, 0x07389, 0x06193, 0x08071, 0x04043, 0x030ce, - 0x05147, 0x07388, 0x05145, 0x08072, 0x04521, 0x00d47, 0x0297c, 0x030cd, - 0x030ca, 0x0000b, 0x0000c, 0x00083, 0x000e4, 0x00048, 0x00102, 0x001cc, - 0x001f5, 0x00097, 0x0020b, 0x00124, 0x00453, 0x00627, 0x00639, 0x00605, - 0x00517, 0x001b8, 0x00663, 0x00667, 0x007c3, 0x00823, 0x00961, 0x00963, - 0x00e5a, 0x00e59, 0x00a2b, 0x00cbf, 0x00292, 0x00a2d, 0x007d0, 0x00953, - 0x00cc5, 0x00f84, 0x004ab, 0x014a7, 0x0068a, 0x0117a, 0x0052e, 0x01442, - 0x0052c, 0x00c77, 0x00f8f, 0x004aa, 0x01094, 0x01801, 0x012c4, 0x0297b, - 0x00952, 0x01f19, 0x006a5, 0x01149, 0x012c5, 0x01803, 0x022f2, 0x0329b, - 0x04520, 0x0149e, 0x00d13, 0x01f16, 0x01ce9, 0x0101c, 0x006e6, 0x039c9, - 0x06191, 0x07c8e, 0x06192, 0x0ca63, 0x039cd, 0x06190, 0x06884, 0x06885, - 0x07382, 0x00d49, 0x00d41, 0x0450c, 0x0149a, 0x030d1, 0x08077, 0x03e23, - 0x01a15, 0x0e701, 0x0e702, 0x08079, 0x0822a, 0x0a218, 0x07887, 0x0403f, - 0x0520b, 0x0529b, 0x0e700, 0x04519, 0x00007, 0x000e0, 0x000d0, 0x0039b, - 0x003e5, 0x00163, 0x0063e, 0x007c9, 0x00806, 0x00954, 0x01044, 0x01f44, - 0x0197c, 0x01f45, 0x00a51, 0x01f47, 0x00951, 0x0052d, 0x02291, 0x0092f, - 0x00a54, 0x00d12, 0x0297d, 0x00d0c, 0x01499, 0x0329e, 0x032f0, 0x02025, - 0x039c6, 0x00a57, 0x03e46, 0x00d42, 0x0738b, 0x05146, 0x04046, 0x08078, - 0x0510e, 0x07886, 0x02904, 0x04156, 0x04157, 0x06032, 0x030d3, 0x08bce, - 0x04040, 0x0403e, 0x0a414, 0x10457, 0x08075, 0x06887, 0x07c8f, 0x039c7, - 0x07387, 0x08070, 0x08bcf, 0x1482a, 0x10456, 0x1482b, 0x01a17, 0x06886, - 0x0450d, 0x00013, 0x0006b, 0x00615, 0x0080b, 0x0082b, 0x00952, 0x00e5b, - 0x018e2, 0x0186c, 0x01f18, 0x0329f, 0x00d43, 0x03e29, 0x05140, 0x05141, - 0x0ca62, 0x06033, 0x03c42, 0x03e28, 0x0450f, 0x0a21a, 0x07384, 0x0a219, - 0x0e703, 0x0a21b, 0x01a14, 0x07383, 0x045e6, 0x0007a, 0x0012c, 0x00ccc, - 0x0068f, 0x01802, 0x00a52, 0x00953, 0x04045, 0x01a20, 0x0451f, 0x000a4, - 0x00735, 0x01cec, 0x02029, 0x020a3, 0x0451e, 0x00069, 0x00c24, 0x02024, - 0x032f2, 0x05142, 0x00196, 0x00523, 0x000a6, 0x0197b, 0x0030b, 0x0092e, - 0x003e9, 0x03e27, 0x00160, 0x05143, 0x00652, 0x04041, 0x00734, 0x028a7, - 0x0080f, 0x01483, 0x0097c, 0x00340, 0x0068b, 0x00522, 0x01054, 0x01096, - 0x01f17, 0x0202b, 0x01cea, 0x020a0, 0x02978, 0x02026, 0x0297a, 0x039cb, - 0x03e2b, 0x0149f, 0x0329c, 0x07385, 0x08074, 0x0450e, 0x03e2a, 0x05149, - 0x08076, 0x07386, 0x05148, -}; - -static const uint8_t coef1_huffbits[555] = { - 9, 5, 2, 4, 4, 5, 5, 5, - 6, 6, 6, 6, 6, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 8, - 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, - 9, 8, 8, 8, 8, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, - 9, 10, 10, 10, 9, 9, 9, 9, - 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10, - 11, 11, 11, 11, 11, 11, 11, 11, - 11, 11, 11, 11, 11, 11, 11, 11, - 11, 11, 11, 11, 11, 11, 11, 11, - 11, 12, 12, 12, 12, 12, 12, 12, - 12, 12, 11, 11, 11, 11, 11, 12, - 12, 12, 12, 12, 12, 12, 12, 12, - 13, 12, 12, 12, 12, 12, 12, 12, - 13, 12, 12, 12, 12, 12, 12, 12, - 12, 13, 12, 12, 12, 13, 13, 13, - 13, 12, 12, 12, 12, 12, 12, 13, - 12, 13, 13, 13, 13, 13, 13, 13, - 14, 14, 13, 13, 13, 13, 13, 13, - 13, 12, 12, 12, 13, 13, 13, 13, - 13, 13, 13, 13, 13, 13, 13, 13, - 13, 13, 14, 13, 14, 13, 13, 13, - 13, 13, 14, 13, 14, 14, 13, 14, - 14, 13, 14, 13, 13, 14, 14, 13, - 14, 14, 14, 14, 14, 14, 14, 14, - 14, 15, 14, 14, 14, 14, 15, 15, - 15, 14, 14, 13, 13, 12, 12, 13, - 13, 13, 14, 14, 15, 14, 15, 15, - 14, 13, 14, 15, 15, 15, 14, 14, - 14, 14, 15, 14, 14, 15, 15, 15, - 14, 15, 14, 14, 14, 14, 14, 15, - 15, 16, 15, 15, 15, 14, 15, 15, - 15, 15, 14, 14, 16, 14, 15, 14, - 14, 15, 15, 15, 15, 16, 15, 14, - 15, 15, 15, 16, 15, 15, 14, 14, - 14, 4, 7, 8, 8, 9, 9, 9, - 9, 10, 10, 11, 11, 11, 11, 11, - 11, 12, 11, 11, 11, 12, 12, 12, - 12, 12, 12, 12, 12, 12, 11, 12, - 12, 12, 13, 13, 13, 13, 13, 13, - 13, 12, 12, 13, 13, 13, 13, 14, - 14, 13, 14, 13, 13, 13, 14, 14, - 15, 15, 14, 13, 13, 13, 14, 14, - 15, 15, 15, 16, 14, 15, 17, 17, - 15, 15, 15, 15, 15, 14, 16, 14, - 16, 16, 16, 16, 16, 16, 15, 15, - 17, 15, 16, 15, 6, 8, 10, 10, - 10, 11, 11, 11, 12, 12, 13, 13, - 13, 13, 14, 13, 14, 13, 14, 14, - 14, 14, 14, 15, 15, 14, 14, 14, - 14, 14, 14, 15, 15, 15, 15, 16, - 15, 15, 16, 15, 15, 15, 14, 16, - 15, 15, 18, 17, 16, 17, 15, 14, - 15, 16, 16, 19, 17, 19, 16, 17, - 15, 7, 10, 11, 12, 12, 12, 12, - 13, 13, 13, 14, 15, 14, 15, 15, - 16, 15, 14, 14, 15, 16, 15, 16, - 16, 16, 16, 15, 15, 7, 11, 12, - 13, 13, 14, 14, 15, 15, 15, 8, - 11, 13, 14, 14, 15, 9, 12, 14, - 14, 15, 9, 13, 10, 13, 10, 14, - 10, 14, 11, 15, 11, 15, 11, 14, - 12, 15, 12, 13, 13, 13, 13, 13, - 13, 14, 13, 14, 14, 14, 14, 14, - 14, 15, 14, 15, 16, 15, 14, 15, - 16, 15, 15, -}; - -static const uint32_t coef2_huffcodes[1336] = { - 0x003e6, 0x000f6, 0x00000, 0x00002, 0x00006, 0x0000f, 0x0001b, 0x00028, - 0x00039, 0x0003f, 0x0006b, 0x00076, 0x000b7, 0x000e8, 0x000ef, 0x00169, - 0x001a7, 0x001d4, 0x001dc, 0x002c4, 0x00349, 0x00355, 0x00391, 0x003dc, - 0x00581, 0x005b2, 0x00698, 0x0070c, 0x00755, 0x0073a, 0x00774, 0x007cf, - 0x00b0a, 0x00b66, 0x00d2e, 0x00d5e, 0x00e1b, 0x00eac, 0x00e5a, 0x00f7e, - 0x00fa1, 0x0163e, 0x01a37, 0x01a52, 0x01c39, 0x01ab3, 0x01d5f, 0x01cb6, - 0x01f52, 0x01dd9, 0x02c04, 0x02c2e, 0x02c2d, 0x02c23, 0x03467, 0x034a3, - 0x0351b, 0x03501, 0x03a5d, 0x0351c, 0x03875, 0x03dea, 0x0397b, 0x039db, - 0x03df1, 0x039d8, 0x03bb4, 0x0580a, 0x0584d, 0x05842, 0x05b13, 0x058ea, - 0x0697d, 0x06a06, 0x068cc, 0x06ac7, 0x06a96, 0x072f4, 0x07543, 0x072b4, - 0x07d20, 0x0b003, 0x073b5, 0x07be6, 0x0d180, 0x07bd1, 0x07cb8, 0x07d06, - 0x07d25, 0x0d2f2, 0x0d19a, 0x0d334, 0x0e1dc, 0x0d529, 0x0d584, 0x0e1d2, - 0x0e5e3, 0x0eec4, 0x0e564, 0x0fa49, 0x16001, 0x0eedc, 0x0f7fa, 0x1a32c, - 0x16131, 0x16003, 0x0f9c8, 0x1ef80, 0x1d2a0, 0x1aa4b, 0x0f7ce, 0x1abfe, - 0x1aa50, 0x1a458, 0x1a816, 0x1cae4, 0x1d2fe, 0x1d52e, 0x1aa4c, 0x2c245, - 0x1d2a1, 0x1a35d, 0x1ca1b, 0x1d5d8, 0x1f531, 0x1ca1c, 0x1f389, 0x1f4af, - 0x3a5e7, 0x351fb, 0x2c24b, 0x34bce, 0x2c24d, 0x2c249, 0x2c24a, 0x72dfc, - 0x357ef, 0x35002, 0x3a5e6, 0x39431, 0x5843b, 0x34a77, 0x58431, 0x3a5f3, - 0x3a5dd, 0x3e5e5, 0x356bd, 0x3976e, 0x6a3d2, 0x3500d, 0x694c4, 0x580bd, - 0x3e5e8, 0x74b95, 0x34a6e, 0x3977c, 0x39432, 0x5b0d2, 0x6a3d8, 0x580b8, - 0x5b0cb, 0x5b0d7, 0x72dee, 0x72ded, 0x72dec, 0x74b9c, 0x3977f, 0x72dea, - 0x74b9e, 0x7be7d, 0x580bf, 0x5b0d5, 0x7cba8, 0x74b91, 0x3e5dd, 0xb6171, - 0xd46b3, 0xd46b9, 0x7cba1, 0x74b9f, 0x72de1, 0xe59f5, 0x3e5eb, 0x00004, - 0x00015, 0x00038, 0x00075, 0x000e8, 0x001d3, 0x00347, 0x0039c, 0x00690, - 0x0074a, 0x00b60, 0x00e93, 0x00f74, 0x0163d, 0x01a5a, 0x01d24, 0x01cbe, - 0x01f4b, 0x03468, 0x03562, 0x03947, 0x03e82, 0x05804, 0x05b12, 0x05803, - 0x0696d, 0x06a9e, 0x0697c, 0x06978, 0x06afb, 0x074b2, 0x072f5, 0x073c0, - 0x07541, 0x06944, 0x074b7, 0x070d3, 0x07ba9, 0x0b0b1, 0x0d1af, 0x0e1dd, - 0x0e5e2, 0x0e1a3, 0x0eec3, 0x1612f, 0x0e961, 0x0eeda, 0x0e78e, 0x0fa48, - 0x1612c, 0x0e511, 0x0e565, 0x0e953, 0x1aa4a, 0x0e59d, 0x1d52c, 0x1a811, - 0x1cae7, 0x1abfc, 0x1d52d, 0x1cacf, 0x1cf05, 0x2c254, 0x34a72, 0x1f4ac, - 0x3976b, 0x34a71, 0x2c6d9, 0x2d873, 0x34a6a, 0x357e7, 0x3464c, 0x3e5f5, - 0x58433, 0x1f53a, 0x3500a, 0x357ea, 0x34a73, 0x3942f, 0x357e5, 0x39775, - 0x694cd, 0x39772, 0x7cba5, 0x6a3ef, 0x35483, 0x74b98, 0x5b0c1, 0x39770, - 0x3a5d7, 0x39433, 0x39434, 0x694ce, 0x580be, 0x3e5ff, 0x6a3ec, 0xb616f, - 0xd46b1, 0x6a3d1, 0x72de5, 0x74b6e, 0x72de9, 0x3e700, 0xd46b6, 0x6a3e9, - 0x74b69, 0xe5675, 0xd46b8, 0x7cbaa, 0x3a5d1, 0x0000c, 0x0003c, 0x000eb, - 0x001f1, 0x003a4, 0x006a8, 0x007d5, 0x00d43, 0x00e77, 0x016c5, 0x01cb1, - 0x02c5d, 0x03a55, 0x03a56, 0x03e51, 0x03bb5, 0x05b0a, 0x06a9f, 0x074b8, - 0x07d28, 0x0d187, 0x0d40e, 0x0d52e, 0x0d425, 0x0eae3, 0x0e1d3, 0x1612e, - 0x0e59e, 0x0eec2, 0x0e578, 0x0e51a, 0x0e579, 0x0e515, 0x0e960, 0x0d183, - 0x0d220, 0x0d2cb, 0x0e512, 0x16c3e, 0x16002, 0x16c42, 0x1cae9, 0x3461a, - 0x1d2fa, 0x1a308, 0x1a849, 0x1cf07, 0x1f38f, 0x34b65, 0x2c253, 0x1ef9e, - 0x1cbc3, 0x1cbc1, 0x2c255, 0x1f384, 0x58435, 0x2c5cd, 0x3a5f7, 0x2c252, - 0x3959c, 0x2c6d8, 0x3a5d3, 0x6ad78, 0x6a3f2, 0x7cba9, 0xb6176, 0x72deb, - 0x39764, 0x3e5f6, 0x3a5d8, 0x74a8c, 0x6a3e6, 0x694d1, 0x6ad79, 0x1a4592, - 0xe59fb, 0x7cbb3, 0x5b0cd, 0x00017, 0x000b5, 0x002c3, 0x005b7, 0x00b1c, - 0x00e5c, 0x0163f, 0x01ab2, 0x01efa, 0x0348a, 0x0396e, 0x058da, 0x06963, - 0x06a30, 0x072cd, 0x073cf, 0x07ce7, 0x0d2ca, 0x0d2d8, 0x0e764, 0x0e794, - 0x16008, 0x16167, 0x1617e, 0x1aa49, 0x1a30b, 0x1a813, 0x2c6da, 0x1a580, - 0x1cbc2, 0x0f9ca, 0x1617f, 0x1d2fe, 0x0f7fc, 0x16c40, 0x0e513, 0x0eec5, - 0x0f7c3, 0x1d508, 0x1a81e, 0x1d2fd, 0x39430, 0x35486, 0x3e5fd, 0x2c24c, - 0x2c75a, 0x34a74, 0x3a5f4, 0x3464d, 0x694ca, 0x3a5f1, 0x1d509, 0x1d5c0, - 0x34648, 0x3464e, 0x6a3d5, 0x6a3e8, 0x6a3e7, 0x5b0c3, 0x2c248, 0x1f38a, - 0x3a5f2, 0x6a3e5, 0x00029, 0x00168, 0x0058c, 0x00b67, 0x00f9d, 0x01c3d, - 0x01cbf, 0x02c20, 0x0351d, 0x03df6, 0x06af9, 0x072b5, 0x0b1d7, 0x0b0b2, - 0x0d40a, 0x0d52b, 0x0e952, 0x0e797, 0x163c3, 0x1c3a0, 0x1f386, 0x1ca21, - 0x34655, 0x2c247, 0x1f53b, 0x2c250, 0x2c24f, 0x1f385, 0x1ef5d, 0x1cf15, - 0x1caea, 0x1ab0a, 0x1cf19, 0x1f53d, 0x1d5c2, 0x1d2fb, 0x1ef58, 0x34a78, - 0x357ec, 0x1f533, 0x3a5e1, 0x694d2, 0x58482, 0x3a5ee, 0x2c6dc, 0x357eb, - 0x5b0c4, 0x39778, 0x6a3e1, 0x7cbb4, 0x3a5e1, 0x74b68, 0x3a5ef, 0x3a5d2, - 0x39424, 0x72de2, 0xe59f6, 0xe59f7, 0x3e702, 0x3e5ec, 0x1f38b, 0x0003b, - 0x001f0, 0x00777, 0x00fa8, 0x01cb2, 0x02d84, 0x03a57, 0x03dd6, 0x06917, - 0x06a11, 0x07d07, 0x0eae2, 0x0e796, 0x0f9c9, 0x0f7fb, 0x16166, 0x16160, - 0x1ab1b, 0x1abfa, 0x2d87b, 0x1d2f7, 0x39768, 0x1f38c, 0x34653, 0x34651, - 0x6a3d9, 0x35001, 0x3abbd, 0x38742, 0x39426, 0x34a76, 0x3a5ec, 0x34a75, - 0x35000, 0x35488, 0x1cf10, 0x2c6db, 0x357ed, 0x357e8, 0x357e9, 0x3a5f0, - 0x694c2, 0xb6178, 0x72df5, 0x39425, 0x3942b, 0x74b6d, 0x74b6f, 0xb6177, - 0xb6179, 0x74b6a, 0xb6172, 0x58487, 0x3e5ee, 0x3e5ed, 0x72df2, 0x72df4, - 0x7cbae, 0x6a3ca, 0x70e86, 0x34bcf, 0x6a3c8, 0x00059, 0x00384, 0x00d5b, - 0x01c38, 0x03560, 0x0395b, 0x0584e, 0x06964, 0x073cd, 0x0b1e7, 0x0e798, - 0x0e78d, 0x0fa43, 0x1a848, 0x1a32f, 0x1aa4e, 0x3464a, 0x1f4ab, 0x1f38d, - 0x3a5eb, 0x3a5d4, 0x3548a, 0x6a3c7, 0x5b0d0, 0x6a3c5, 0x7cbb0, 0x694cb, - 0x3a5e5, 0x3e5e2, 0x3942c, 0x2d872, 0x1f4ae, 0x3a5d5, 0x694d3, 0x58481, - 0x35009, 0x39774, 0x58432, 0xb616c, 0x5b0db, 0x3548b, 0xb6174, 0x1d5d95, - 0xb004c, 0x7cbb2, 0x3a5e5, 0x74a8f, 0xe59f9, 0x72df6, 0xe59fd, 0x7cbad, - 0xd427d, 0x72cff, 0x3977a, 0x5b0d9, 0xb616d, 0xb616b, 0x1a4593, 0x7cbaf, - 0x5b0da, 0x00071, 0x003eb, 0x01603, 0x02c6c, 0x03961, 0x068c8, 0x06a31, - 0x072bd, 0x0d2c2, 0x0e51b, 0x0e5e6, 0x1abfb, 0x1d2ff, 0x1cae5, 0x1ef5c, - 0x1ef5e, 0x1cf13, 0x34a6d, 0x3976d, 0xb616a, 0x3e5f2, 0x6a3c4, 0xb6169, - 0x3e5dc, 0x580b9, 0x74b99, 0x75764, 0x58434, 0x3a5d9, 0x6945a, 0x69459, - 0x3548c, 0x3a5e9, 0x69457, 0x72df1, 0x6945e, 0x6a35e, 0x3e701, 0xb6168, - 0x5b0dd, 0x3a5de, 0x6a3c2, 0xd4278, 0x6a3cc, 0x72dfd, 0xb6165, 0x16009a, - 0x7cbb1, 0xd427c, 0xb6162, 0xe765e, 0x1cecbe, 0x7cbb6, 0x69454, 0xb6160, - 0xd427a, 0x1d5d96, 0xb1d6d, 0xe59f4, 0x72de8, 0x3a5db, 0x0007a, 0x006ae, - 0x01c3c, 0x03aba, 0x058e9, 0x072cc, 0x0d2dd, 0x0d22d, 0x0eec1, 0x0eedb, - 0x1d2a2, 0x1ef5b, 0x357e2, 0x3abbf, 0x1d2f9, 0x35004, 0x3a5dc, 0x351fc, - 0x3976c, 0x6a3c6, 0x6a3cb, 0x3e5ea, 0xe59f3, 0x6a3ce, 0x69452, 0xe59f0, - 0x74b90, 0xd4279, 0xd427b, 0x7cbb5, 0x5b0c5, 0x3a5e3, 0x3a5e2, 0x000d0, - 0x00775, 0x01efe, 0x03dd5, 0x0728c, 0x07cb9, 0x0e1a2, 0x0ea85, 0x0eed8, - 0x1a30a, 0x1aa4f, 0x3a5df, 0x35008, 0x3a5e0, 0x3e5f4, 0x3e5f7, 0xb1d6c, - 0x5843e, 0x34a70, 0x72df8, 0x74b6b, 0xd427f, 0x72df0, 0x5b0bf, 0x5b0c0, - 0xd46b0, 0x72def, 0xe59f8, 0x162e64, 0xb1d6f, 0x3a5e0, 0x39427, 0x69166, - 0x6a3e2, 0x6a3e3, 0x74a8d, 0xd427e, 0x1d5d97, 0xd46b4, 0x5b0d8, 0x6a3d3, - 0x000e0, 0x00b63, 0x034cc, 0x06a33, 0x073c9, 0x0e1a0, 0x0f7fd, 0x0f9cc, - 0x1617d, 0x1caeb, 0x1f4a9, 0x3abb3, 0x69450, 0x39420, 0x39777, 0x3e5e0, - 0x6a3d4, 0x6a3ed, 0xb6166, 0xe59f1, 0xb1d6e, 0xe5676, 0x6a3ea, 0xe5674, - 0xb6163, 0xd46b7, 0x7cba6, 0xd46ba, 0x1d5d94, 0xb6164, 0x6a3f1, 0x7cba2, - 0x69451, 0x72dfa, 0xd46bb, 0x72df7, 0x74b94, 0x1cecbf, 0xe59fa, 0x16009b, - 0x6a3e4, 0x000e6, 0x00e94, 0x03876, 0x070ef, 0x0d52a, 0x16015, 0x16014, - 0x1abf9, 0x1cf17, 0x34a79, 0x34650, 0x3e705, 0x6a3d0, 0x58430, 0x74b9d, - 0x7be7e, 0x5b0be, 0x39773, 0x6a3de, 0x000fb, 0x00f7b, 0x03dd7, 0x07bd0, - 0x0e59c, 0x0f9cd, 0x1cf18, 0x1d2ff, 0x34a7a, 0x39429, 0x3500c, 0x72de0, - 0x69456, 0x7be7c, 0xd46b5, 0xd46b2, 0x6a3dd, 0x001a2, 0x0163b, 0x06913, - 0x0b016, 0x0fa42, 0x1a32d, 0x1cf06, 0x34a7c, 0x34a7d, 0xb6161, 0x35481, - 0x3e5fa, 0x7cba0, 0x7be7f, 0x7cba3, 0x7cba7, 0x5b0d3, 0x72de6, 0x6a3dc, - 0x001a9, 0x01ab4, 0x06a34, 0x0d46a, 0x16130, 0x1ef5f, 0x1f532, 0x1f536, - 0x3942e, 0x58436, 0x6a3db, 0x6945b, 0x001c9, 0x01ca0, 0x0728b, 0x0eed9, - 0x1f539, 0x1ca1d, 0x39765, 0x39766, 0x58439, 0x6945d, 0x39767, 0x001d3, - 0x01f2c, 0x07bfc, 0x16161, 0x34652, 0x3a5ed, 0x3548d, 0x58438, 0x6a3da, - 0x002c1, 0x02c5e, 0x0d335, 0x1ab1a, 0x2d874, 0x35006, 0x35484, 0x5b0cc, - 0x74b9a, 0x72df3, 0x6a3d6, 0x002da, 0x034b3, 0x0d5ae, 0x1caee, 0x2d871, - 0x357e3, 0x74b97, 0x72df9, 0x580ba, 0x5b0d4, 0x0034d, 0x0354e, 0x0f750, - 0x1cbc0, 0x3a5e7, 0x3a5e4, 0x00385, 0x03a58, 0x16c41, 0x2c5cf, 0x3e5e1, - 0x74b6c, 0xe5677, 0x6a3df, 0x00390, 0x03e50, 0x163c2, 0x2d876, 0x35482, - 0x5b0d6, 0x5843a, 0x0039f, 0x0585e, 0x1a583, 0x3500f, 0x74b93, 0x39771, - 0x003e4, 0x06912, 0x16c43, 0x357e1, 0x0058a, 0x0696f, 0x1f538, 0x5b0c9, - 0x6a3cf, 0x005b6, 0x06af8, 0x1f534, 0x58483, 0x6a3e0, 0x00695, 0x07d02, - 0x1cae8, 0x58485, 0x006a2, 0x0754a, 0x357ee, 0x3977b, 0x00748, 0x074b2, - 0x34a7b, 0x00729, 0x0b1e0, 0x34649, 0x3e5e3, 0x0073d, 0x0d2c4, 0x3e5e6, - 0x007bb, 0x0b099, 0x39762, 0x5b0ce, 0x6945f, 0x007d1, 0x0d5ab, 0x39779, - 0x007d3, 0x0d52f, 0x39763, 0x6945c, 0x00b1a, 0x0d2c5, 0x35489, 0x00d23, - 0x0eaed, 0x3e5f8, 0x00d32, 0x16016, 0x3e5fb, 0x00d41, 0x0e768, 0x3a5ed, - 0x00e1f, 0x16017, 0x58027, 0x00ead, 0x0fa07, 0x69455, 0x00e54, 0x1612b, - 0x00e55, 0x1a581, 0x00f78, 0x1a32b, 0x580bc, 0x6a3ee, 0x00f79, 0x1abfd, - 0x00f95, 0x1ab18, 0x6a3f0, 0x01637, 0x1aa4d, 0x0162d, 0x1f53c, 0x6a3f3, - 0x01a31, 0x1a810, 0x39769, 0x01a50, 0x1caef, 0x01a36, 0x1a32e, 0x01a67, - 0x1f38e, 0x01a85, 0x1ef59, 0x01aa6, 0x1ef83, 0x01d51, 0x2c012, 0x01d53, - 0x2d879, 0x01d5e, 0x35005, 0x01cba, 0x1cf04, 0x69453, 0x01d2d, 0x351ff, - 0x01f2d, 0x2d86f, 0x01f29, 0x35007, 0x02c22, 0x351fa, 0x02c03, 0x3a5ec, - 0x02c5f, 0x3a5eb, 0x02c58, 0x34a6b, 0x03469, 0x356be, 0x02c59, 0x34a6c, - 0x0346a, 0x3a5ea, 0x034bd, 0x034bf, 0x356bf, 0x0386a, 0x03ab9, 0x5843f, - 0x0386b, 0x3a5f5, 0x03a4b, 0x39421, 0x03aa4, 0x3a5e9, 0x03a5a, 0x03960, - 0x3977e, 0x03de9, 0x03958, 0x03df7, 0x039e1, 0x3e5e4, 0x0395f, 0x69458, - 0x03e91, 0x03df2, 0x39428, 0x058f2, 0x03e80, 0x6a3c3, 0x03e93, 0x694c0, - 0x058b8, 0x5b0ca, 0x0584f, 0x694c1, 0x058f1, 0x068d6, 0x06a10, 0x06ac3, - 0x06a32, 0x070d2, 0x06911, 0x074b1, 0x07494, 0x06ad4, 0x06ad6, 0x072b8, - 0x06afa, 0x074b3, 0x07540, 0x073ce, 0x0b005, 0x074b3, 0x07495, 0x074b9, - 0x0d336, 0x07bff, 0x07763, 0x073c8, 0x07d29, 0x0b622, 0x0d221, 0x0d181, - 0x0b1d1, 0x074b8, 0x0b1d0, 0x0d19b, 0x0d2c3, 0x0b172, 0x0d2dc, 0x0b623, - 0x0d5aa, 0x0d426, 0x0d182, 0x0e795, 0x0e1d1, 0x0d337, 0x0e96c, 0x0e5e4, - 0x0e514, 0x0eaee, 0x16000, 0x0e767, 0x0e1a1, 0x0e78f, 0x16004, 0x0f7c2, - 0x0e799, 0x0e5e7, 0x0e566, 0x0e769, 0x0f751, 0x0eede, 0x0fa06, 0x16005, - 0x0fa9f, 0x1a5e6, 0x0e766, 0x1636f, 0x0eedd, 0x0eec0, 0x1a309, 0x1ceca, - 0x163cd, 0x0f9cb, 0x0eedf, 0x1a582, 0x1612d, 0x0e5e5, 0x1abf8, 0x1a30c, - 0x1ca1f, 0x163cc, 0x1a35c, 0x1ca1e, 0x1aa51, 0x163ac, 0x1a84e, 0x1a53f, - 0x1cf16, 0x1d2fc, 0x1a5b3, 0x1ab19, 0x1a81f, 0x1d5c3, 0x16c3f, 0x1d5c1, - 0x1d2fc, 0x1f4aa, 0x1a812, 0x1f535, 0x1cf12, 0x1a817, 0x1617c, 0x1ab0b, - 0x1d2f8, 0x1ef82, 0x2d87a, 0x1d52f, 0x1f530, 0x1aa48, 0x35487, 0x1d2fd, - 0x1f4ad, 0x1cf11, 0x3461b, 0x35485, 0x1ca20, 0x1caed, 0x1cae6, 0x1abff, - 0x3464f, 0x34a6f, 0x1ef81, 0x3464b, 0x39d96, 0x1f383, 0x1f537, 0x1cf14, - 0x2c5ce, 0x3500e, 0x2c251, 0x1caec, 0x1f387, 0x34654, 0x357e4, 0x2d878, - 0x3500b, 0x35480, 0x3a5e8, 0x3548e, 0x34b64, 0x1f4a8, 0x35003, 0x3e5df, - 0x2d870, 0x357e6, 0x3e5f0, 0x1ef5a, 0x3a5ea, 0x1f388, 0x3e703, 0x2c24e, - 0x3a5e2, 0x351fd, 0x2c6dd, 0x3e704, 0x351fe, 0x2d875, 0x5b0c7, 0x3976a, - 0x3a5e6, 0x39423, 0x58480, 0x2c246, 0x3a5e3, 0x2d877, 0x3e5f1, 0x3abbe, - 0x58489, 0x3e5f9, 0x357e0, 0x3abbc, 0x5b0c6, 0x69167, 0x69165, 0x3e5e9, - 0x39422, 0x3976f, 0x3977d, 0x3e5de, 0x6a3c9, 0x58b98, 0x3a5f6, 0x3a5d0, - 0x58486, 0x6a3c1, 0x3e5fc, 0x5b0dc, 0x3548f, 0x3942d, 0x694c9, 0x58484, - 0x3a5e8, 0x74b9b, 0x74b96, 0x694d0, 0x58488, 0x3a5e4, 0x3942a, 0x72ec2, - 0x39776, 0x5b0d1, 0x5b0cf, 0x3a5d6, 0xe59fc, 0x5b0c8, 0x3e5e7, 0x7cbb7, - 0x70e87, 0x7cbab, 0x5b0c2, 0x694c3, 0x74a8e, 0x3e5f3, 0x6a3cd, 0x72dfe, - 0x73b2e, 0x72ec0, 0x694c5, 0x58437, 0x694c8, 0x72dff, 0x39435, 0x5843d, - 0x6a3d7, 0x72ec1, 0xd22c8, 0x694cf, 0xb6173, 0x3e5fe, 0x580bb, 0xe59f2, - 0xb616e, 0xb6175, 0x3a5da, 0x5b0bd, 0x694cc, 0x5843c, 0x694c7, 0x74b92, - 0x72ec3, 0x694c6, 0xb6170, 0x7cbac, 0xb1733, 0x7cba4, 0xb6167, 0x72de7, - 0x72de4, 0x6a3c0, 0x3e5ef, 0x162e65, 0x72de3, 0x72dfb, 0x6a35f, 0x6a3eb, -}; - -static const uint8_t coef2_huffbits[1336] = { - 11, 9, 2, 3, 4, 4, 5, 6, - 6, 7, 7, 8, 8, 8, 9, 9, - 9, 9, 10, 10, 10, 10, 11, 11, - 11, 11, 11, 11, 11, 12, 12, 12, - 12, 12, 12, 12, 12, 12, 13, 13, - 13, 13, 13, 13, 13, 13, 13, 14, - 14, 14, 14, 14, 14, 14, 14, 14, - 14, 14, 14, 14, 14, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 16, 15, 16, - 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, - 17, 17, 17, 17, 17, 17, 17, 17, - 17, 17, 17, 18, 17, 17, 17, 17, - 17, 17, 17, 18, 18, 17, 17, 18, - 17, 17, 18, 17, 18, 18, 18, 18, - 19, 18, 18, 18, 18, 18, 18, 20, - 18, 18, 18, 19, 19, 18, 19, 18, - 19, 19, 18, 19, 19, 18, 19, 19, - 19, 19, 18, 19, 19, 19, 19, 19, - 19, 19, 20, 20, 20, 19, 19, 20, - 19, 20, 19, 19, 20, 19, 19, 20, - 20, 20, 20, 19, 20, 21, 19, 3, - 5, 7, 8, 9, 9, 10, 11, 11, - 12, 12, 12, 13, 13, 13, 13, 14, - 14, 14, 14, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 16, 16, - 15, 15, 15, 15, 16, 16, 16, 16, - 17, 16, 17, 17, 16, 17, 17, 17, - 17, 17, 17, 16, 17, 17, 17, 17, - 18, 17, 17, 18, 18, 18, 18, 18, - 19, 18, 18, 18, 18, 18, 18, 19, - 19, 18, 18, 18, 18, 19, 18, 19, - 19, 19, 20, 19, 18, 19, 19, 19, - 19, 19, 19, 19, 19, 19, 19, 20, - 20, 19, 20, 19, 20, 19, 20, 19, - 19, 21, 20, 20, 19, 4, 7, 8, - 10, 11, 11, 12, 12, 13, 13, 14, - 14, 14, 14, 15, 15, 15, 15, 15, - 16, 16, 16, 16, 16, 16, 16, 17, - 17, 17, 17, 17, 17, 17, 16, 16, - 16, 16, 17, 17, 17, 17, 18, 18, - 18, 17, 17, 18, 18, 18, 18, 18, - 18, 18, 18, 18, 19, 18, 18, 18, - 19, 18, 19, 19, 19, 20, 20, 20, - 19, 19, 19, 19, 19, 19, 19, 21, - 21, 20, 19, 5, 8, 10, 11, 12, - 13, 13, 13, 14, 14, 15, 15, 15, - 15, 16, 16, 16, 16, 16, 17, 17, - 17, 17, 17, 17, 17, 17, 18, 17, - 18, 17, 17, 17, 17, 17, 17, 17, - 17, 17, 17, 17, 19, 18, 19, 18, - 18, 18, 18, 18, 19, 18, 17, 17, - 18, 18, 19, 19, 19, 19, 18, 18, - 18, 19, 6, 9, 11, 12, 13, 13, - 14, 14, 14, 15, 15, 16, 16, 16, - 16, 16, 16, 17, 17, 17, 18, 18, - 18, 18, 18, 18, 18, 18, 18, 18, - 18, 17, 18, 18, 17, 18, 18, 18, - 18, 18, 18, 19, 19, 18, 18, 18, - 19, 19, 19, 20, 19, 19, 18, 19, - 19, 20, 21, 21, 19, 19, 18, 6, - 10, 12, 13, 14, 14, 14, 15, 15, - 15, 16, 16, 17, 17, 17, 17, 17, - 17, 17, 18, 18, 19, 18, 18, 18, - 19, 18, 18, 18, 19, 18, 18, 18, - 18, 18, 18, 18, 18, 18, 18, 18, - 19, 20, 20, 19, 19, 19, 19, 20, - 20, 19, 20, 19, 19, 19, 20, 20, - 20, 19, 19, 18, 19, 7, 10, 12, - 13, 14, 15, 15, 15, 16, 16, 17, - 17, 17, 17, 17, 17, 18, 18, 18, - 18, 19, 18, 19, 19, 19, 20, 19, - 18, 19, 19, 18, 18, 19, 19, 19, - 18, 19, 19, 20, 19, 18, 20, 21, - 20, 20, 19, 19, 21, 20, 21, 20, - 20, 20, 19, 19, 20, 20, 21, 20, - 19, 7, 11, 13, 14, 15, 15, 15, - 16, 16, 17, 17, 17, 17, 18, 18, - 18, 18, 18, 19, 20, 19, 19, 20, - 19, 19, 19, 19, 19, 19, 19, 19, - 18, 18, 19, 20, 19, 19, 19, 20, - 19, 19, 19, 20, 19, 20, 20, 21, - 20, 20, 20, 21, 22, 20, 19, 20, - 20, 21, 20, 21, 20, 19, 8, 11, - 13, 14, 15, 16, 16, 16, 17, 17, - 17, 18, 18, 18, 18, 18, 19, 18, - 19, 19, 19, 19, 21, 19, 19, 21, - 19, 20, 20, 20, 19, 18, 18, 8, - 12, 14, 15, 16, 16, 16, 16, 17, - 17, 17, 19, 18, 18, 19, 19, 20, - 19, 18, 20, 19, 20, 20, 19, 19, - 20, 20, 21, 21, 20, 19, 19, 19, - 19, 19, 19, 20, 21, 20, 19, 19, - 8, 12, 14, 15, 16, 16, 17, 17, - 17, 18, 18, 18, 19, 19, 19, 19, - 19, 19, 20, 21, 20, 21, 19, 21, - 20, 20, 20, 20, 21, 20, 19, 20, - 19, 20, 20, 20, 19, 22, 21, 21, - 19, 9, 12, 14, 15, 16, 17, 17, - 17, 18, 18, 18, 19, 19, 19, 19, - 20, 19, 19, 19, 9, 13, 15, 16, - 17, 17, 18, 18, 18, 19, 18, 20, - 19, 20, 20, 20, 19, 9, 13, 15, - 16, 17, 17, 18, 18, 18, 20, 18, - 19, 20, 20, 20, 20, 19, 20, 19, - 9, 13, 15, 16, 17, 18, 18, 18, - 19, 19, 19, 19, 10, 14, 16, 17, - 18, 18, 19, 19, 19, 19, 19, 10, - 14, 16, 17, 18, 18, 18, 19, 19, - 10, 14, 16, 17, 18, 18, 18, 19, - 19, 20, 19, 10, 14, 16, 18, 18, - 18, 19, 20, 19, 19, 10, 14, 17, - 18, 18, 18, 10, 15, 17, 18, 19, - 19, 21, 19, 11, 15, 17, 18, 18, - 19, 19, 11, 15, 17, 18, 19, 19, - 11, 15, 17, 18, 11, 15, 18, 19, - 19, 11, 15, 18, 19, 19, 11, 16, - 18, 19, 11, 15, 18, 19, 11, 16, - 18, 12, 16, 18, 19, 12, 16, 19, - 12, 16, 19, 19, 19, 12, 16, 19, - 12, 16, 19, 19, 12, 16, 18, 12, - 16, 19, 12, 17, 19, 12, 17, 19, - 12, 17, 19, 12, 17, 19, 13, 17, - 13, 17, 13, 17, 19, 19, 13, 17, - 13, 17, 19, 13, 17, 13, 18, 19, - 13, 17, 19, 13, 18, 13, 17, 13, - 18, 13, 18, 13, 18, 13, 18, 13, - 18, 13, 18, 14, 18, 19, 14, 18, - 14, 18, 14, 18, 14, 18, 14, 19, - 14, 19, 14, 18, 14, 18, 14, 18, - 14, 19, 14, 14, 18, 14, 14, 19, - 14, 18, 14, 19, 14, 19, 14, 15, - 19, 15, 15, 15, 15, 19, 15, 19, - 15, 15, 19, 15, 15, 19, 15, 19, - 15, 19, 15, 19, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 16, - 15, 15, 15, 16, 16, 16, 15, 16, - 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 17, 16, 16, 16, 17, - 17, 16, 17, 17, 16, 17, 17, 17, - 17, 17, 17, 17, 17, 17, 17, 17, - 17, 17, 17, 17, 17, 17, 17, 18, - 17, 17, 17, 17, 17, 17, 17, 17, - 18, 17, 17, 18, 17, 17, 17, 17, - 18, 18, 17, 17, 17, 17, 17, 17, - 17, 18, 17, 18, 18, 17, 17, 17, - 18, 18, 18, 17, 18, 17, 18, 18, - 18, 18, 18, 18, 18, 18, 18, 17, - 18, 18, 18, 18, 19, 18, 18, 18, - 18, 18, 18, 18, 18, 18, 18, 18, - 18, 18, 18, 18, 18, 18, 18, 19, - 18, 18, 19, 18, 18, 18, 19, 18, - 19, 18, 18, 19, 18, 18, 19, 19, - 19, 19, 19, 18, 19, 18, 19, 18, - 19, 19, 18, 18, 19, 19, 19, 19, - 19, 19, 19, 19, 19, 19, 18, 19, - 19, 19, 19, 19, 18, 19, 19, 19, - 19, 19, 19, 19, 19, 19, 19, 20, - 19, 19, 19, 19, 21, 19, 19, 20, - 19, 20, 19, 19, 19, 19, 19, 20, - 20, 20, 19, 19, 19, 20, 19, 19, - 19, 20, 20, 19, 20, 19, 19, 21, - 20, 20, 19, 19, 19, 19, 19, 19, - 20, 19, 20, 20, 20, 20, 20, 20, - 20, 19, 19, 21, 20, 20, 19, 19, -}; - -static const uint32_t coef3_huffcodes[1072] = { - 0x001b2, 0x00069, 0x00000, 0x00004, 0x00006, 0x0000e, 0x00014, 0x00019, - 0x00016, 0x0002b, 0x00030, 0x0003d, 0x0003c, 0x0005a, 0x0005f, 0x0006d, - 0x0007e, 0x0005f, 0x0007f, 0x000b6, 0x000bc, 0x000d8, 0x000f2, 0x000fe, - 0x000bc, 0x000fc, 0x00161, 0x0016e, 0x00174, 0x00176, 0x001a2, 0x001e3, - 0x001f3, 0x00174, 0x0017a, 0x001ea, 0x002a8, 0x002c4, 0x002e6, 0x00314, - 0x00346, 0x00367, 0x003e9, 0x002e5, 0x002ee, 0x003d6, 0x00555, 0x00554, - 0x00557, 0x005c3, 0x005d6, 0x006e0, 0x0062f, 0x006e2, 0x00799, 0x00789, - 0x007fa, 0x005ce, 0x007fe, 0x005ec, 0x007cc, 0x007af, 0x00aa7, 0x00b19, - 0x00b94, 0x00b85, 0x00b9f, 0x00c48, 0x00c45, 0x00dd8, 0x00c4c, 0x00c4b, - 0x00d99, 0x00d1f, 0x00dc2, 0x00f95, 0x00fa2, 0x00bb5, 0x00b9f, 0x00f5d, - 0x00bbf, 0x00f47, 0x0154a, 0x00fd5, 0x00f45, 0x00f7f, 0x0160d, 0x01889, - 0x01757, 0x01722, 0x018b3, 0x0172d, 0x01a39, 0x01a18, 0x01bb3, 0x01b30, - 0x01e63, 0x0173c, 0x01b35, 0x01723, 0x01e80, 0x01fee, 0x01761, 0x01ffc, - 0x01f7f, 0x02c7c, 0x01fa1, 0x0177b, 0x01755, 0x0175a, 0x01fa6, 0x02eab, - 0x0310a, 0x02c69, 0x03669, 0x03127, 0x03103, 0x02e43, 0x03662, 0x03165, - 0x03124, 0x0313b, 0x03111, 0x03668, 0x0343b, 0x03c52, 0x03efc, 0x02e6c, - 0x03fda, 0x03ef8, 0x02e7b, 0x03ee2, 0x03cc5, 0x03d72, 0x058c0, 0x03df8, - 0x02ea9, 0x03e7e, 0x0556d, 0x05c82, 0x03d71, 0x03e7b, 0x03c42, 0x058d7, - 0x03f4e, 0x06200, 0x03d70, 0x05cb2, 0x05c96, 0x05cb0, 0x03f45, 0x05cb1, - 0x02e6d, 0x03110, 0x02f68, 0x05c90, 0x07ca6, 0x07c88, 0x06204, 0x062c8, - 0x078a6, 0x07986, 0x079d5, 0x0b1ad, 0x07989, 0x0b079, 0x05cdd, 0x0aad4, - 0x05de8, 0x07dcd, 0x07987, 0x05d67, 0x05d99, 0x0b91d, 0x07cf1, 0x05d9b, - 0x079d7, 0x0b07b, 0x05c85, 0x05d9a, 0x07dcc, 0x07ebf, 0x07dce, 0x07dfb, - 0x07ec0, 0x07d1a, 0x07a07, 0x05c84, 0x0c471, 0x07cf2, 0x0baef, 0x0b9d2, - 0x05deb, 0x07bd6, 0x0b845, 0x05d98, 0x0b91a, 0x0bae8, 0x0c4e0, 0x0dc31, - 0x0f93d, 0x0bbce, 0x0d1d2, 0x0f7a9, 0x0d9b9, 0x0bbcb, 0x0b900, 0x0aad7, - 0x0babd, 0x0c4e1, 0x0f46f, 0x0c588, 0x0c58b, 0x160e6, 0x0bbcf, 0x0bac3, - 0x0f945, 0x0f7a3, 0x0d1c1, 0x0fb8e, 0x0f7a4, 0x0fb8c, 0x0f40c, 0x0c473, - 0x0fd72, 0x0bbcd, 0x0fffa, 0x0f940, 0x0bbc9, 0x0f7a8, 0x1a1ed, 0x0bbc5, - 0x1f26f, 0x163fd, 0x160c7, 0x1a1f5, 0x0f947, 0x163fc, 0x154b3, 0x0fff6, - 0x163f6, 0x160e9, 0x1a1f0, 0x0bab9, 0x0baba, 0x17086, 0x0b903, 0x0fd75, - 0x0f308, 0x176f3, 0x163ff, 0x0fd7d, 0x1bb78, 0x163fb, 0x188db, 0x1a1f7, - 0x154b2, 0x172fd, 0x163f4, 0x1bb73, 0x172ff, 0x0babc, 0x0f97d, 0x1a1f3, - 0x1bb6d, 0x1ffd5, 0x1a1f4, 0x1f272, 0x17380, 0x17382, 0x1ffe7, 0x0bac8, - 0x0bbc4, 0x188d3, 0x160e0, 0x0fd7b, 0x1725f, 0x172f5, 0x1bb79, 0x1fad9, - 0x1f269, 0x188d0, 0x0bac4, 0x0bac5, 0x31185, 0x188d2, 0x188cc, 0x31187, - 0x3e7fe, 0x188d1, 0x1bb6c, 0x1f268, 0x1fad2, 0x1ffd9, 0x1a1ea, 0x1bb68, - 0x1facb, 0x3fdb2, 0x1e81a, 0x188ce, 0x172fb, 0x1a1ef, 0x1face, 0x1bb70, - 0x0bac1, 0x1bb6b, 0x172f8, 0x1bb66, 0x1ffdf, 0x1bb6a, 0x1ffd7, 0x1f266, - 0x176f8, 0x37653, 0x1fa7e, 0x31182, 0x1fac8, 0x2c7e3, 0x370ee, 0x176ec, - 0x176e9, 0x2e4bc, 0x160c5, 0x3765a, 0x3ce9c, 0x17373, 0x176e8, 0x188d4, - 0x176f1, 0x176ef, 0x37659, 0x1bb7c, 0x1ffde, 0x176f2, 0x3118b, 0x2c7d4, - 0x37651, 0x5ce9f, 0x37650, 0x31191, 0x3f4f6, 0x3f4f5, 0x7a06c, 0x1fac1, - 0x5c97b, 0x2c7e0, 0x79d3a, 0x3e7fd, 0x2c7df, 0x3f4f0, 0x7a06d, 0x376c1, - 0x79d3b, 0x00004, 0x00014, 0x00059, 0x000ab, 0x000b8, 0x00177, 0x001f5, - 0x001f2, 0x00315, 0x003fc, 0x005bd, 0x0062d, 0x006e8, 0x007dd, 0x00b04, - 0x007cd, 0x00b1e, 0x00d1e, 0x00f15, 0x00f3b, 0x00f41, 0x01548, 0x018b0, - 0x0173b, 0x01884, 0x01a1c, 0x01bb4, 0x01f25, 0x017b5, 0x0176d, 0x01ef8, - 0x02e73, 0x03107, 0x03125, 0x03105, 0x02e49, 0x03ce8, 0x03ef9, 0x03e5e, - 0x02e72, 0x03471, 0x03fd9, 0x0623f, 0x078a0, 0x06867, 0x05cb3, 0x06272, - 0x068ec, 0x06e9a, 0x079d4, 0x06e98, 0x0b1aa, 0x06e1a, 0x07985, 0x068ee, - 0x06e9b, 0x05c88, 0x0b1ac, 0x07dfa, 0x05d65, 0x07cf0, 0x07cbf, 0x0c475, - 0x160eb, 0x1bb7e, 0x0f7a6, 0x1fedd, 0x160e3, 0x0fffb, 0x0fb8d, 0x0fff9, - 0x0d1c0, 0x0c58c, 0x1a1e9, 0x0bab8, 0x0f5cf, 0x0fff5, 0x376c5, 0x1a1ec, - 0x160ed, 0x1fede, 0x1fac9, 0x1a1eb, 0x1f224, 0x176ee, 0x0fd79, 0x17080, - 0x17387, 0x1bb7a, 0x1ffe9, 0x176f7, 0x17385, 0x17781, 0x2c7d5, 0x17785, - 0x1ffe3, 0x163f5, 0x1fac2, 0x3e7f9, 0x3118d, 0x3fdb1, 0x1ffe2, 0x1f226, - 0x3118a, 0x2c7d9, 0x31190, 0x3118c, 0x3f4f3, 0x1bb7f, 0x1bb72, 0x31184, - 0xb92f4, 0x3e7fb, 0x6e1d9, 0x1faca, 0x62300, 0x3fdb8, 0x3d037, 0x3e7fc, - 0x62301, 0x3f4f2, 0x1f26a, 0x0000e, 0x00063, 0x000f8, 0x001ee, 0x00377, - 0x003f7, 0x006e3, 0x005cc, 0x00b05, 0x00dd2, 0x00fd4, 0x0172e, 0x0172a, - 0x01e23, 0x01f2d, 0x01763, 0x01769, 0x0176c, 0x02e75, 0x03104, 0x02ec1, - 0x03e58, 0x0583f, 0x03f62, 0x03f44, 0x058c5, 0x0623c, 0x05cf4, 0x07bd7, - 0x05d9d, 0x0aad2, 0x05d66, 0x0b1a9, 0x0b078, 0x07cfe, 0x0b918, 0x0c46f, - 0x0b919, 0x0b847, 0x06e1b, 0x0b84b, 0x0aad8, 0x0fd74, 0x172f4, 0x17081, - 0x0f97c, 0x1f273, 0x0f7a0, 0x0fd7c, 0x172f7, 0x0fd7a, 0x1bb77, 0x172fe, - 0x1f270, 0x0fd73, 0x1bb7b, 0x1a1bc, 0x1bb7d, 0x0bbc3, 0x172f6, 0x0baeb, - 0x0fb8f, 0x3f4f4, 0x3fdb4, 0x376c8, 0x3e7fa, 0x1ffd0, 0x62303, 0xb92f5, - 0x1f261, 0x31189, 0x3fdb5, 0x2c7db, 0x376c9, 0x1fad6, 0x1fad1, 0x00015, - 0x000f0, 0x002e0, 0x0058e, 0x005d7, 0x00c4d, 0x00fa1, 0x00bdb, 0x01756, - 0x01f70, 0x02c19, 0x0313c, 0x0370f, 0x03cc0, 0x02ea8, 0x058c6, 0x058c7, - 0x02eb7, 0x058d0, 0x07d18, 0x0aa58, 0x0b848, 0x05d9e, 0x05d6c, 0x0b84c, - 0x0c589, 0x0b901, 0x163f8, 0x0bac9, 0x0b9c5, 0x0f93c, 0x188d8, 0x0bbc7, - 0x160ec, 0x0fd6f, 0x188d9, 0x160ea, 0x0f7a7, 0x0f944, 0x0baab, 0x0dc3a, - 0x188cf, 0x176fb, 0x2c7d8, 0x2c7d7, 0x1bb75, 0x5ce9e, 0x62302, 0x370ed, - 0x176f4, 0x1ffd1, 0x370ef, 0x3f4f8, 0x376c7, 0x1ffe1, 0x376c6, 0x176ff, - 0x6e1d8, 0x176f6, 0x17087, 0x0f5cd, 0x00035, 0x001a0, 0x0058b, 0x00aac, - 0x00b9a, 0x0175f, 0x01e22, 0x01e8c, 0x01fb2, 0x0310b, 0x058d1, 0x0552e, - 0x05c27, 0x0686e, 0x07ca7, 0x0c474, 0x0dc33, 0x07bf2, 0x05de9, 0x07a35, - 0x0baaa, 0x0b9eb, 0x0fb95, 0x0b9b8, 0x17381, 0x1f262, 0x188cd, 0x17088, - 0x172fa, 0x0f7a2, 0x1fad3, 0x0bac0, 0x3765c, 0x1fedf, 0x1f225, 0x1fad4, - 0x2c7da, 0x5ce9d, 0x3e7f8, 0x1e203, 0x188d7, 0x00054, 0x002c0, 0x007a1, - 0x00f78, 0x01b36, 0x01fa3, 0x0313a, 0x03436, 0x0343a, 0x07d1d, 0x07bd8, - 0x05cdf, 0x0b846, 0x0b189, 0x0d9b8, 0x0fff8, 0x0d9be, 0x0c58a, 0x05dea, - 0x0d1d3, 0x160e4, 0x1f26b, 0x188da, 0x1e202, 0x2c7d2, 0x163fe, 0x31193, - 0x17782, 0x376c2, 0x2c7d1, 0x3fdb0, 0x3765d, 0x2c7d0, 0x1fad0, 0x1e201, - 0x188dd, 0x2c7e2, 0x37657, 0x37655, 0x376c4, 0x376c0, 0x176ea, 0x0006f, - 0x003cf, 0x00dd5, 0x01f23, 0x02c61, 0x02ed0, 0x05d54, 0x0552d, 0x07883, - 0x0b1a8, 0x0b91c, 0x0babf, 0x0b902, 0x0f7aa, 0x0f7a5, 0x1a1e8, 0x1ffd6, - 0x0babe, 0x1a1bf, 0x163f3, 0x1ffd8, 0x1fad7, 0x1f275, 0x1ffdc, 0x0007d, - 0x005bc, 0x01549, 0x02a99, 0x03def, 0x06273, 0x079d6, 0x07d1b, 0x0aad3, - 0x0d0fc, 0x2c7dd, 0x188d6, 0x0bac2, 0x2c7e1, 0x1bb76, 0x1a1bd, 0x31186, - 0x0fd78, 0x1a1be, 0x31183, 0x3fdb6, 0x3f4f1, 0x37652, 0x1fad5, 0x3f4f9, - 0x3e7ff, 0x5ce9c, 0x3765b, 0x31188, 0x17372, 0x000bd, 0x0078b, 0x01f21, - 0x03c43, 0x03ded, 0x0aad6, 0x07ec1, 0x0f942, 0x05c86, 0x17089, 0x0babb, - 0x1ffe8, 0x2c7de, 0x1f26e, 0x1fac4, 0x3f4f7, 0x37656, 0x1fa7d, 0x376c3, - 0x3fdb3, 0x3118f, 0x1fac6, 0x000f8, 0x007ed, 0x01efd, 0x03e7a, 0x05c91, - 0x0aad9, 0x0baec, 0x0dc32, 0x0f46e, 0x1e200, 0x176fa, 0x3765e, 0x3fdb7, - 0x2c7d6, 0x3fdb9, 0x37654, 0x37658, 0x3118e, 0x1ffdb, 0x000f6, 0x00c43, - 0x03106, 0x068ef, 0x0b84d, 0x0b188, 0x0bbcc, 0x1f264, 0x1bb69, 0x17386, - 0x1fac0, 0x00171, 0x00f39, 0x03e41, 0x068ed, 0x0d9bc, 0x0f7a1, 0x1bb67, - 0x1ffdd, 0x176f9, 0x001b9, 0x00f7d, 0x03f63, 0x0d0fd, 0x0b9ea, 0x188dc, - 0x1fac3, 0x1a1f2, 0x31192, 0x1ffe4, 0x001f6, 0x01754, 0x06865, 0x0f309, - 0x160e5, 0x176f5, 0x3765f, 0x1facc, 0x001e9, 0x01a1a, 0x06201, 0x0f105, - 0x176f0, 0x002df, 0x01756, 0x05d6d, 0x163fa, 0x176ed, 0x00342, 0x02e40, - 0x0d0ff, 0x17082, 0x003cd, 0x02a98, 0x0fffc, 0x2c7dc, 0x1fa7f, 0x003fe, - 0x03764, 0x0fffd, 0x176fc, 0x1fac5, 0x002f7, 0x02ed1, 0x0fb97, 0x0058a, - 0x02edc, 0x0bbc8, 0x005d4, 0x0623d, 0x160e8, 0x0062e, 0x05830, 0x163f9, - 0x006eb, 0x06205, 0x1f274, 0x007de, 0x062c9, 0x1f265, 0x005c9, 0x05cde, - 0x1ffd3, 0x005d4, 0x07988, 0x007ce, 0x0b849, 0x00b1b, 0x05c89, 0x1fac7, - 0x00b93, 0x05c83, 0x00b9e, 0x0f14f, 0x00c4a, 0x0b9c7, 0x00dd4, 0x0c470, - 0x1f271, 0x00f38, 0x0fb96, 0x176eb, 0x00fa0, 0x163f7, 0x00bb2, 0x0b91b, - 0x00bbe, 0x0f102, 0x00f44, 0x0f946, 0x1facd, 0x00f79, 0x0d9bd, 0x0154d, - 0x0bbc6, 0x00fd2, 0x160e7, 0x0172b, 0x188cb, 0x0175e, 0x0fd76, 0x0175c, - 0x1bb71, 0x0189f, 0x1a1ee, 0x01f24, 0x1a1f6, 0x01ba7, 0x0bbca, 0x01f7d, - 0x0ffff, 0x01f2e, 0x1bb65, 0x01bb5, 0x172f9, 0x01fef, 0x1f26c, 0x01f3e, - 0x0fd77, 0x01762, 0x1bb6e, 0x01ef9, 0x172fc, 0x01fa0, 0x02ab7, 0x02e4a, - 0x1f267, 0x01fb3, 0x1ffda, 0x02e42, 0x03101, 0x17780, 0x0313d, 0x03475, - 0x17784, 0x03126, 0x1facf, 0x03c51, 0x17783, 0x03e40, 0x1ffe5, 0x03663, - 0x1ffe0, 0x03e8f, 0x1f26d, 0x0343c, 0x03cc1, 0x176fd, 0x03e45, 0x02ec0, - 0x03f61, 0x03dee, 0x03fd8, 0x0583e, 0x02e45, 0x03e59, 0x03d02, 0x05ce8, - 0x05568, 0x176fe, 0x02f69, 0x1fad8, 0x058c1, 0x05c83, 0x1ffe6, 0x06271, - 0x06e1c, 0x062c7, 0x068e1, 0x0552f, 0x06864, 0x06866, 0x06e99, 0x05cbc, - 0x07ca5, 0x078a1, 0x05c82, 0x07dcf, 0x0623b, 0x0623e, 0x068e8, 0x07a36, - 0x05d9c, 0x0b077, 0x07cf3, 0x07a34, 0x07ca4, 0x07d19, 0x079d2, 0x07d1c, - 0x07bd9, 0x0b84a, 0x0fb94, 0x0aad5, 0x0dc30, 0x07bf3, 0x0baee, 0x0b07a, - 0x0c472, 0x0b91e, 0x0d9ba, 0x05d9f, 0x0d0fe, 0x0b9c6, 0x05c87, 0x0f14e, - 0x0baed, 0x0b92e, 0x0f103, 0x0b9c4, 0x0fb91, 0x0d9bb, 0x0b1ab, 0x0c58d, - 0x0fffe, 0x0f93b, 0x0f941, 0x0baea, 0x0b91f, 0x0f5cc, 0x0d9bf, 0x0f943, - 0x0f104, 0x1f260, 0x0fb92, 0x0f93f, 0x0f3a6, 0x0bac7, 0x0f7ab, 0x0bac6, - 0x17383, 0x0fd6d, 0x0bae9, 0x0fd6e, 0x1e74f, 0x188ca, 0x1f227, 0x0fb93, - 0x0fb90, 0x0fff7, 0x17085, 0x17083, 0x160e1, 0x17084, 0x0f93e, 0x160e2, - 0x160c6, 0x1a1f1, 0x1bb6f, 0x17384, 0x0fd70, 0x1f263, 0x188d5, 0x173a6, - 0x0f5ce, 0x163f2, 0x0fd71, 0x1ffd2, 0x160c4, 0x1ffd4, 0x2c7d3, 0x1bb74, -}; - -static const uint8_t coef3_huffbits[1072] = { - 9, 7, 2, 3, 4, 4, 5, 5, - 6, 6, 6, 6, 7, 7, 7, 7, - 7, 8, 8, 8, 8, 8, 8, 8, - 9, 9, 9, 9, 9, 9, 9, 9, - 9, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 11, 11, 11, 11, 11, - 11, 11, 11, 11, 11, 11, 11, 11, - 11, 12, 11, 12, 12, 12, 12, 12, - 12, 12, 12, 12, 12, 12, 12, 12, - 12, 12, 12, 12, 12, 13, 13, 13, - 13, 13, 13, 13, 13, 13, 13, 13, - 13, 13, 13, 13, 13, 13, 13, 13, - 13, 14, 13, 14, 14, 13, 14, 13, - 13, 14, 14, 14, 14, 14, 14, 14, - 14, 14, 14, 14, 14, 14, 14, 14, - 14, 14, 14, 14, 14, 14, 14, 15, - 14, 14, 15, 14, 14, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 14, 15, - 15, 15, 15, 15, 15, 15, 15, 15, - 15, 14, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 16, 15, 16, 16, 16, - 16, 15, 15, 16, 16, 16, 16, 16, - 15, 16, 16, 16, 15, 16, 15, 15, - 16, 15, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, - 16, 17, 16, 17, 16, 17, 17, 16, - 17, 16, 17, 16, 16, 17, 17, 17, - 16, 17, 16, 16, 17, 16, 17, 16, - 17, 17, 16, 16, 17, 17, 17, 17, - 17, 17, 17, 17, 16, 17, 17, 16, - 17, 17, 17, 17, 17, 17, 17, 17, - 16, 18, 17, 17, 17, 17, 17, 17, - 17, 17, 17, 17, 17, 17, 16, 17, - 17, 17, 17, 17, 17, 17, 17, 17, - 17, 17, 17, 17, 17, 17, 17, 18, - 17, 17, 17, 17, 18, 17, 17, 18, - 19, 17, 17, 17, 18, 17, 17, 17, - 18, 18, 18, 17, 17, 17, 18, 17, - 17, 17, 17, 17, 17, 17, 17, 17, - 18, 18, 18, 18, 18, 18, 18, 18, - 18, 18, 17, 18, 18, 18, 18, 17, - 18, 18, 18, 17, 17, 18, 18, 18, - 18, 19, 18, 18, 19, 19, 20, 18, - 19, 18, 19, 19, 18, 19, 20, 18, - 19, 4, 6, 7, 8, 9, 9, 9, - 10, 10, 10, 11, 11, 11, 11, 12, - 12, 12, 12, 12, 12, 13, 13, 13, - 13, 13, 13, 13, 13, 14, 14, 14, - 14, 14, 14, 14, 14, 14, 14, 14, - 14, 14, 14, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 16, 15, 15, 15, - 15, 16, 16, 15, 16, 16, 15, 16, - 17, 17, 17, 17, 17, 16, 16, 16, - 16, 16, 17, 17, 17, 16, 18, 17, - 17, 17, 18, 17, 17, 18, 17, 17, - 17, 17, 17, 18, 17, 18, 18, 18, - 17, 17, 18, 19, 18, 18, 17, 17, - 18, 18, 18, 18, 19, 17, 17, 18, - 20, 19, 19, 18, 19, 18, 19, 19, - 19, 19, 17, 5, 7, 9, 10, 10, - 11, 11, 12, 12, 12, 13, 13, 13, - 13, 13, 14, 14, 14, 14, 14, 15, - 14, 15, 15, 15, 15, 15, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 15, 16, 16, 17, 17, 17, - 16, 17, 17, 17, 17, 17, 17, 17, - 17, 17, 17, 17, 17, 17, 17, 16, - 16, 19, 18, 18, 19, 17, 19, 20, - 17, 18, 18, 18, 18, 18, 18, 6, - 8, 10, 11, 12, 12, 12, 13, 13, - 13, 14, 14, 14, 14, 15, 15, 15, - 15, 15, 15, 16, 16, 16, 16, 16, - 16, 17, 17, 17, 16, 16, 17, 17, - 17, 17, 17, 17, 17, 16, 16, 16, - 17, 18, 18, 18, 17, 19, 19, 18, - 18, 17, 18, 19, 18, 17, 18, 18, - 19, 18, 17, 17, 6, 9, 11, 12, - 13, 13, 13, 14, 14, 14, 15, 15, - 15, 15, 15, 16, 16, 16, 16, 16, - 16, 17, 16, 17, 17, 17, 17, 17, - 17, 17, 18, 17, 18, 17, 17, 18, - 18, 19, 19, 17, 17, 7, 10, 12, - 13, 13, 14, 14, 14, 14, 15, 16, - 16, 16, 16, 16, 16, 16, 16, 16, - 16, 17, 17, 17, 17, 18, 17, 18, - 18, 18, 18, 18, 18, 18, 18, 17, - 17, 18, 18, 18, 18, 18, 18, 7, - 10, 12, 13, 14, 15, 15, 15, 15, - 16, 16, 17, 17, 17, 17, 17, 17, - 17, 17, 17, 17, 18, 17, 17, 8, - 11, 13, 14, 15, 15, 15, 15, 16, - 16, 18, 17, 17, 18, 17, 17, 18, - 17, 17, 18, 18, 19, 18, 18, 19, - 19, 19, 18, 18, 18, 8, 11, 13, - 14, 15, 16, 16, 16, 16, 17, 17, - 17, 18, 17, 18, 19, 18, 18, 18, - 18, 18, 18, 8, 12, 14, 15, 15, - 16, 16, 16, 17, 17, 18, 18, 18, - 18, 18, 18, 18, 18, 17, 9, 12, - 14, 15, 16, 16, 17, 17, 17, 17, - 18, 9, 12, 14, 15, 16, 17, 17, - 17, 18, 9, 13, 15, 16, 17, 17, - 18, 17, 18, 17, 9, 13, 15, 16, - 17, 18, 18, 18, 10, 13, 15, 16, - 18, 10, 14, 16, 17, 18, 10, 14, - 16, 17, 10, 14, 16, 18, 18, 10, - 14, 16, 18, 18, 11, 15, 16, 11, - 15, 17, 11, 15, 17, 11, 15, 17, - 11, 15, 17, 11, 15, 17, 12, 16, - 17, 12, 15, 12, 16, 12, 16, 18, - 12, 16, 12, 16, 12, 16, 12, 16, - 17, 12, 16, 18, 12, 17, 13, 16, - 13, 16, 13, 16, 18, 13, 16, 13, - 17, 13, 17, 13, 17, 13, 17, 13, - 17, 13, 17, 13, 17, 13, 17, 13, - 16, 13, 17, 13, 17, 13, 17, 14, - 17, 14, 17, 14, 17, 14, 14, 14, - 17, 14, 17, 14, 14, 18, 14, 14, - 18, 14, 18, 14, 18, 14, 17, 14, - 17, 14, 17, 14, 14, 18, 14, 15, - 15, 15, 14, 15, 15, 14, 15, 15, - 15, 18, 15, 18, 15, 15, 17, 15, - 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 16, 15, 15, 15, 15, 16, - 16, 16, 16, 16, 15, 15, 15, 15, - 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 17, 16, 16, - 16, 17, 16, 16, 16, 17, 17, 17, - 17, 17, 16, 17, 17, 17, 17, 16, - 16, 16, 17, 17, 17, 17, 16, 17, - 17, 17, 17, 17, 17, 17, 17, 17, - 17, 17, 17, 17, 17, 17, 18, 17, -}; - -static const uint32_t coef4_huffcodes[476] = { - 0x00f01, 0x0001e, 0x00000, 0x00004, 0x00006, 0x0000d, 0x0000a, 0x00017, - 0x0001d, 0x00017, 0x0002c, 0x00031, 0x00039, 0x0003e, 0x00039, 0x0005a, - 0x00066, 0x00070, 0x0007b, 0x00070, 0x00077, 0x000af, 0x000c9, 0x000f2, - 0x000f4, 0x000b2, 0x000e3, 0x0015b, 0x0015d, 0x00181, 0x0019d, 0x001e3, - 0x001c5, 0x002b5, 0x002db, 0x00338, 0x003c3, 0x003cc, 0x003f0, 0x002cd, - 0x003fa, 0x003a1, 0x005b4, 0x00657, 0x007ab, 0x0074d, 0x0074c, 0x00ac1, - 0x00ac5, 0x0076b, 0x00ca8, 0x00f04, 0x00f00, 0x00fe3, 0x00f3c, 0x00f10, - 0x00f39, 0x00fe6, 0x00e26, 0x00e90, 0x016c5, 0x01827, 0x01954, 0x015c5, - 0x01958, 0x01f8a, 0x01c4a, 0x02b0f, 0x02b41, 0x02b0e, 0x033c6, 0x03050, - 0x01c4f, 0x02d88, 0x0305c, 0x03c18, 0x02b4f, 0x02cc2, 0x03a47, 0x05680, - 0x0569d, 0x06442, 0x06443, 0x06446, 0x0656e, 0x06444, 0x07120, 0x0748a, - 0x0c1ba, 0x07e22, 0x07aa6, 0x07f25, 0x07aa7, 0x07e20, 0x0c11b, 0x0c118, - 0x07aa5, 0x0ad0a, 0x0f389, 0x19ebb, 0x0caad, 0x0fe42, 0x0fe40, 0x16c34, - 0x2b4e5, 0x33d65, 0x16c30, 0x1e7ae, 0x1e25c, 0x18370, 0x1e703, 0x19eba, - 0x16c37, 0x0e234, 0x16c6e, 0x00004, 0x0002a, 0x00061, 0x00075, 0x000cb, - 0x000ff, 0x00190, 0x001eb, 0x001d1, 0x002b9, 0x00307, 0x00339, 0x0033f, - 0x003fb, 0x003b4, 0x0060c, 0x00679, 0x00645, 0x0067d, 0x0078a, 0x007e3, - 0x00749, 0x00ac4, 0x00ad2, 0x00ae3, 0x00c10, 0x00c16, 0x00ad1, 0x00cf4, - 0x00fe2, 0x01586, 0x00e9d, 0x019f1, 0x01664, 0x01e26, 0x01d38, 0x02b4d, - 0x033c5, 0x01fc2, 0x01fc3, 0x01d28, 0x03c1d, 0x0598e, 0x0f094, 0x07aa4, - 0x0ad38, 0x0ac0c, 0x0c11a, 0x079ea, 0x0c881, 0x0fe44, 0x0b635, 0x0ac0d, - 0x0b61e, 0x05987, 0x07121, 0x0f382, 0x0f387, 0x0e237, 0x0fe47, 0x0f383, - 0x0f091, 0x0f385, 0x0e233, 0x182ee, 0x19eb8, 0x1663e, 0x0f093, 0x00014, - 0x00058, 0x00159, 0x00167, 0x00300, 0x003d4, 0x005b5, 0x0079d, 0x0076a, - 0x00b67, 0x00b60, 0x00f05, 0x00cf0, 0x00f17, 0x00e95, 0x01822, 0x01913, - 0x016c2, 0x0182f, 0x01959, 0x01fcb, 0x01e27, 0x01c40, 0x033c7, 0x01e7b, - 0x01c49, 0x02d89, 0x01e23, 0x01660, 0x03f12, 0x02cc6, 0x033e1, 0x05b34, - 0x0609a, 0x06569, 0x07488, 0x07e21, 0x0cf5f, 0x0712c, 0x0389d, 0x067cf, - 0x07f28, 0x1663f, 0x33d67, 0x1663d, 0x1e25d, 0x3c1ab, 0x15c44, 0x16c36, - 0x0001f, 0x000ec, 0x00323, 0x005b2, 0x0079f, 0x00ac2, 0x00f16, 0x00e9e, - 0x01956, 0x01e0f, 0x019ea, 0x01666, 0x02b89, 0x02b02, 0x02d8c, 0x03c1b, - 0x03c19, 0x032b5, 0x03f9c, 0x02ccf, 0x03897, 0x05b35, 0x0ad02, 0x07f29, - 0x06441, 0x03884, 0x07888, 0x0784e, 0x06568, 0x0c1bb, 0x05986, 0x067cc, - 0x0fe49, 0x0fe48, 0x0c1bc, 0x0fe41, 0x18371, 0x1663c, 0x0e231, 0x0711e, - 0x0ad09, 0x0f092, 0x0002d, 0x001db, 0x00781, 0x00c1a, 0x00f55, 0x01580, - 0x01ea8, 0x02d9b, 0x032af, 0x03f16, 0x03c1c, 0x07834, 0x03c45, 0x0389c, - 0x067ce, 0x06445, 0x0c1b9, 0x07889, 0x07f3a, 0x0784f, 0x07f2b, 0x0ad0b, - 0x0f090, 0x0c11d, 0x0e94e, 0x0711f, 0x0e9f1, 0x0f38e, 0x079e9, 0x0ad03, - 0x0f09b, 0x0caae, 0x0fe46, 0x2b4e6, 0x0e9f0, 0x19eb6, 0x67ac1, 0x67ac0, - 0x33d66, 0x0f388, 0x00071, 0x003a0, 0x00ca9, 0x01829, 0x01d39, 0x02b43, - 0x02cc4, 0x06554, 0x0f09a, 0x0b61f, 0x067cd, 0x0711c, 0x0b636, 0x07f2a, - 0x0b634, 0x0c11f, 0x0cf5e, 0x0b61d, 0x0f06b, 0x0caab, 0x0c1be, 0x0e94c, - 0x0f099, 0x182ed, 0x0e94f, 0x0c119, 0x0e232, 0x2b4e4, 0x0f38a, 0x19eb4, - 0x1e25f, 0x0e94d, 0x000b7, 0x00785, 0x016cc, 0x03051, 0x033c4, 0x0656f, - 0x03891, 0x0711d, 0x0caaf, 0x0f097, 0x07489, 0x0f098, 0x0c880, 0x0caaa, - 0x0f386, 0x19eb7, 0x16c6f, 0x0f384, 0x182e8, 0x182e9, 0x0e230, 0x1e700, - 0x33d62, 0x33d63, 0x33d64, 0x16c33, 0x0e216, 0x000fd, 0x00c15, 0x01665, - 0x03c4a, 0x07f3b, 0x07896, 0x0c11c, 0x0e215, 0x16c32, 0x0f38b, 0x0f38d, - 0x182ea, 0x1e701, 0x712df, 0x15c46, 0x00194, 0x00fe0, 0x03f13, 0x0748b, - 0x0f096, 0x0cf80, 0x1e25e, 0xe25bd, 0x33d61, 0x16c31, 0x001f9, 0x01912, - 0x05710, 0x0f3d0, 0x0c1bf, 0x00301, 0x01e24, 0x0ad08, 0x003cd, 0x01c41, - 0x0c1bd, 0x00563, 0x03a52, 0x0f3d1, 0x00570, 0x02cce, 0x0e217, 0x0067b, - 0x0655d, 0x0074b, 0x06447, 0x00c12, 0x074fb, 0x00f08, 0x0b61c, 0x00e22, - 0x0fe43, 0x016c7, 0x01836, 0x019f2, 0x01c43, 0x01d3f, 0x01fcf, 0x02b4c, - 0x0304c, 0x032b6, 0x03a46, 0x05607, 0x03f17, 0x02cc5, 0x0609b, 0x0655c, - 0x07e23, 0x067c1, 0x07f26, 0x07f27, 0x0f095, 0x0e9f3, 0x0cf81, 0x0c11e, - 0x0caac, 0x0f38f, 0x0e9f2, 0x074fa, 0x0e236, 0x0fe45, 0x1c428, 0x0e235, - 0x182ef, 0x19eb5, 0x0f3d6, 0x182ec, 0x16c35, 0x0f38c, 0x2b4e7, 0x15c47, - 0xe25bc, 0x1e702, 0x1c4b6, 0x0e25a, 0x3c1aa, 0x15c45, 0x1c429, 0x19eb9, - 0x1e7af, 0x182eb, 0x1e0d4, 0x3896e, -}; - -static const uint8_t coef4_huffbits[476] = { - 12, 6, 2, 3, 4, 4, 5, 5, - 5, 6, 6, 6, 6, 6, 7, 7, - 7, 7, 7, 8, 8, 8, 8, 8, - 8, 9, 9, 9, 9, 9, 9, 9, - 10, 10, 10, 10, 10, 10, 10, 11, - 10, 11, 11, 11, 11, 12, 12, 12, - 12, 12, 12, 12, 12, 12, 12, 12, - 12, 12, 13, 13, 13, 13, 13, 13, - 13, 13, 14, 14, 14, 14, 14, 14, - 14, 14, 14, 14, 14, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 16, 16, - 16, 15, 15, 15, 15, 15, 16, 16, - 15, 16, 16, 17, 16, 16, 16, 17, - 18, 18, 17, 17, 17, 17, 17, 17, - 17, 17, 17, 4, 6, 7, 8, 8, - 8, 9, 9, 10, 10, 10, 10, 10, - 10, 11, 11, 11, 11, 11, 11, 11, - 12, 12, 12, 12, 12, 12, 12, 12, - 12, 13, 13, 13, 14, 13, 14, 14, - 14, 13, 13, 14, 14, 16, 16, 15, - 16, 16, 16, 15, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 17, 16, 16, - 16, 16, 17, 17, 17, 18, 16, 5, - 8, 9, 10, 10, 10, 11, 11, 12, - 12, 12, 12, 12, 12, 13, 13, 13, - 13, 13, 13, 13, 13, 14, 14, 13, - 14, 14, 13, 14, 14, 15, 14, 15, - 15, 15, 16, 15, 16, 16, 15, 15, - 15, 18, 18, 18, 17, 18, 17, 17, - 6, 9, 10, 11, 11, 12, 12, 13, - 13, 13, 13, 14, 14, 14, 14, 14, - 14, 14, 14, 15, 15, 15, 16, 15, - 15, 15, 15, 15, 15, 16, 16, 15, - 16, 16, 16, 16, 17, 18, 17, 16, - 16, 16, 7, 10, 11, 12, 12, 13, - 13, 14, 14, 14, 14, 15, 14, 15, - 15, 15, 16, 15, 15, 15, 15, 16, - 16, 16, 17, 16, 17, 16, 15, 16, - 16, 16, 16, 18, 17, 17, 19, 19, - 18, 16, 7, 11, 12, 13, 14, 14, - 15, 15, 16, 16, 15, 16, 16, 15, - 16, 16, 16, 16, 16, 16, 16, 17, - 16, 17, 17, 16, 17, 18, 16, 17, - 17, 17, 8, 11, 13, 14, 14, 15, - 15, 16, 16, 16, 16, 16, 16, 16, - 16, 17, 17, 16, 17, 17, 17, 17, - 18, 18, 18, 17, 17, 8, 12, 14, - 14, 15, 15, 16, 17, 17, 16, 16, - 17, 17, 20, 17, 9, 12, 14, 16, - 16, 16, 17, 21, 18, 17, 9, 13, - 15, 16, 16, 10, 13, 16, 10, 14, - 16, 11, 15, 16, 11, 15, 17, 11, - 15, 12, 15, 12, 16, 12, 16, 13, - 16, 13, 13, 13, 14, 14, 13, 14, - 14, 14, 15, 15, 14, 15, 15, 15, - 15, 15, 15, 15, 16, 17, 16, 16, - 16, 16, 17, 16, 17, 16, 18, 17, - 17, 17, 16, 17, 17, 16, 18, 17, - 21, 17, 18, 17, 18, 17, 18, 17, - 17, 17, 17, 19, -}; - -static const uint32_t coef5_huffcodes[435] = { - 0x00347, 0x0000b, 0x00001, 0x00001, 0x0000c, 0x00004, 0x00010, 0x00015, - 0x0001f, 0x0000b, 0x00023, 0x00026, 0x00029, 0x00035, 0x00037, 0x00001, - 0x00015, 0x0001a, 0x0001d, 0x0001c, 0x0001e, 0x0004e, 0x00049, 0x00051, - 0x00078, 0x00004, 0x00000, 0x00008, 0x0000d, 0x0007b, 0x00005, 0x00032, - 0x00095, 0x00091, 0x00096, 0x000a1, 0x000d9, 0x00003, 0x00019, 0x00061, - 0x00066, 0x00060, 0x00017, 0x0000e, 0x00063, 0x001a0, 0x001b7, 0x001e6, - 0x001e7, 0x001b6, 0x00018, 0x001e8, 0x00038, 0x00031, 0x00005, 0x0003d, - 0x00027, 0x001ea, 0x0001a, 0x000c5, 0x000f9, 0x000ff, 0x000db, 0x00250, - 0x000fc, 0x0025c, 0x00008, 0x00075, 0x003d7, 0x003d3, 0x001b0, 0x0007c, - 0x003ca, 0x00036, 0x00189, 0x004a6, 0x004a2, 0x004fb, 0x000c0, 0x0007f, - 0x0009a, 0x00311, 0x0006e, 0x0009b, 0x0068c, 0x006c0, 0x00484, 0x00012, - 0x000c3, 0x0094f, 0x00979, 0x009f9, 0x00d09, 0x00da6, 0x00da8, 0x00901, - 0x000c1, 0x00373, 0x00d08, 0x009fa, 0x00d8b, 0x00d85, 0x00d86, 0x000df, - 0x006e2, 0x000ce, 0x00f24, 0x009fe, 0x001f7, 0x007c1, 0x000cf, 0x009fc, - 0x009ff, 0x00d89, 0x00da9, 0x009fd, 0x001f8, 0x01a36, 0x0128c, 0x0129d, - 0x01a37, 0x00196, 0x003ea, 0x00f8b, 0x00d93, 0x01e45, 0x01e58, 0x01e4b, - 0x01e59, 0x013f1, 0x00309, 0x00265, 0x00308, 0x0243a, 0x027e1, 0x00f89, - 0x00324, 0x03cbc, 0x03c86, 0x03695, 0x0243c, 0x0243b, 0x0243e, 0x01e4a, - 0x003a5, 0x03468, 0x03428, 0x03c84, 0x027e0, 0x025e2, 0x01880, 0x00197, - 0x00325, 0x03cb7, 0x0791e, 0x007ec, 0x06c75, 0x004c8, 0x04bc7, 0x004c6, - 0x00983, 0x0481e, 0x01b53, 0x0251b, 0x01b58, 0x00984, 0x04fa8, 0x03cbb, - 0x00f8a, 0x00322, 0x0346a, 0x0243d, 0x00326, 0x03469, 0x0481f, 0x0481d, - 0x00746, 0x09032, 0x01b50, 0x01d13, 0x0d8e4, 0x0481b, 0x06c74, 0x0796b, - 0x07969, 0x00985, 0x0d8e3, 0x00986, 0x00fa2, 0x01301, 0x06c7c, 0x00987, - 0x03cb8, 0x0f4af, 0x00e88, 0x1b1c0, 0x00fce, 0x033eb, 0x03f6a, 0x03f69, - 0x00fcf, 0x0791f, 0x004c9, 0x04871, 0x00fcd, 0x00982, 0x00fcc, 0x00fa3, - 0x01d12, 0x0796c, 0x01b47, 0x00321, 0x0796a, 0x0d8e2, 0x04872, 0x04873, - 0x0000e, 0x00014, 0x0000a, 0x000a0, 0x00012, 0x0007d, 0x001a2, 0x0003b, - 0x0025f, 0x000dd, 0x0027c, 0x00343, 0x00368, 0x0036b, 0x0003e, 0x001fa, - 0x00485, 0x001b3, 0x0007f, 0x001b1, 0x0019e, 0x004ba, 0x007ad, 0x00339, - 0x00066, 0x007a4, 0x00793, 0x006c6, 0x0007e, 0x000f1, 0x00372, 0x009fb, - 0x00d83, 0x00d8a, 0x00947, 0x009f4, 0x001d0, 0x01b09, 0x01b4b, 0x007ec, - 0x003e1, 0x000ca, 0x003ec, 0x02539, 0x04fa9, 0x01b57, 0x03429, 0x03d2a, - 0x00d97, 0x003a7, 0x00dc0, 0x00d96, 0x00dc1, 0x007eb, 0x03cba, 0x00c43, - 0x00c41, 0x01b52, 0x007ef, 0x00323, 0x03cb9, 0x03c83, 0x007d0, 0x007ed, - 0x06c7f, 0x09033, 0x03f6c, 0x36383, 0x1e95d, 0x06c78, 0x00747, 0x01b51, - 0x00022, 0x00016, 0x00039, 0x00252, 0x00079, 0x00486, 0x00338, 0x00369, - 0x00d88, 0x00026, 0x00d87, 0x00f4b, 0x00d82, 0x00027, 0x001e1, 0x01a15, - 0x007c7, 0x012f0, 0x001e0, 0x006d0, 0x01a16, 0x01e44, 0x01e5f, 0x03690, - 0x00d90, 0x00c42, 0x00daf, 0x00d92, 0x00f80, 0x00cfb, 0x0342f, 0x0487f, - 0x01b46, 0x07968, 0x00d95, 0x00d91, 0x01b55, 0x03f68, 0x04bc6, 0x03cbd, - 0x00f81, 0x00320, 0x00069, 0x000fe, 0x006d5, 0x0033f, 0x000de, 0x007c6, - 0x01e40, 0x00d94, 0x00f88, 0x03c8e, 0x03694, 0x00dae, 0x00dad, 0x00267, - 0x003a6, 0x00327, 0x0487e, 0x007ee, 0x00749, 0x004c7, 0x03692, 0x01b56, - 0x00fd1, 0x07a56, 0x06c77, 0x09031, 0x00748, 0x06c7a, 0x0796d, 0x033ea, - 0x06c76, 0x00fd0, 0x36382, 0x1e417, 0x00745, 0x04faf, 0x0d8e1, 0x03f6b, - 0x1e95c, 0x04fad, 0x0009e, 0x004bd, 0x0067c, 0x01b08, 0x003eb, 0x01b45, - 0x03691, 0x0d8e5, 0x07904, 0x00981, 0x007ea, 0x019f4, 0x06c7d, 0x04fab, - 0x04fac, 0x06c7e, 0x01300, 0x06c7b, 0x0006f, 0x003f7, 0x03c85, 0x004c4, - 0x0001e, 0x006e1, 0x03693, 0x01b44, 0x00241, 0x01e46, 0x0019d, 0x00266, - 0x004bb, 0x02538, 0x007ac, 0x01b54, 0x00902, 0x04870, 0x00da7, 0x00900, - 0x00185, 0x06c79, 0x006e3, 0x003e9, 0x01e94, 0x003ed, 0x003f2, 0x0342e, - 0x0346b, 0x0251a, 0x004c5, 0x01881, 0x0481c, 0x01b59, 0x03c87, 0x04fae, - 0x007e9, 0x03f6d, 0x0f20a, 0x09030, 0x04faa, 0x0d8e6, 0x03f6f, 0x0481a, - 0x03f6e, 0x1e416, 0x0d8e7, -}; - -static const uint8_t coef5_huffbits[435] = { - 10, 4, 2, 4, 4, 5, 5, 5, - 5, 6, 6, 6, 6, 6, 6, 7, - 7, 7, 7, 7, 7, 7, 7, 7, - 7, 8, 8, 8, 8, 7, 8, 8, - 8, 8, 8, 8, 8, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 10, 9, 10, 10, 10, 10, - 10, 9, 10, 10, 10, 10, 10, 10, - 10, 10, 11, 11, 10, 10, 11, 11, - 10, 11, 11, 11, 11, 11, 12, 12, - 12, 12, 12, 12, 11, 11, 11, 12, - 12, 12, 12, 12, 12, 12, 12, 12, - 12, 12, 12, 12, 12, 12, 12, 13, - 13, 13, 12, 12, 13, 13, 13, 12, - 12, 12, 12, 12, 13, 13, 13, 13, - 13, 14, 14, 14, 14, 13, 13, 13, - 13, 13, 14, 14, 14, 14, 14, 14, - 15, 14, 14, 14, 14, 14, 14, 13, - 14, 14, 14, 14, 14, 14, 15, 14, - 15, 14, 15, 15, 15, 15, 15, 15, - 16, 15, 15, 14, 15, 16, 15, 14, - 14, 15, 14, 14, 15, 14, 15, 15, - 15, 16, 15, 17, 16, 15, 15, 15, - 15, 16, 16, 16, 16, 17, 15, 16, - 14, 16, 16, 17, 16, 16, 16, 16, - 16, 15, 15, 15, 16, 16, 16, 16, - 17, 15, 15, 15, 15, 16, 15, 15, - 4, 7, 8, 8, 9, 9, 9, 10, - 10, 10, 10, 10, 10, 10, 11, 11, - 11, 11, 11, 11, 11, 11, 11, 12, - 12, 11, 11, 11, 12, 12, 12, 12, - 12, 12, 12, 12, 13, 13, 13, 13, - 12, 13, 14, 14, 15, 15, 14, 14, - 14, 14, 14, 14, 14, 15, 14, 14, - 14, 15, 15, 15, 14, 14, 15, 15, - 15, 16, 16, 18, 17, 15, 15, 15, - 6, 9, 10, 10, 11, 11, 12, 12, - 12, 13, 12, 12, 12, 13, 13, 13, - 13, 13, 13, 13, 13, 13, 13, 14, - 14, 14, 14, 14, 14, 14, 14, 15, - 15, 15, 14, 14, 15, 16, 15, 14, - 14, 15, 7, 10, 11, 12, 13, 13, - 13, 14, 14, 14, 14, 14, 14, 14, - 14, 15, 15, 15, 15, 15, 14, 15, - 16, 15, 15, 16, 15, 15, 15, 16, - 15, 16, 18, 17, 15, 15, 16, 16, - 17, 15, 8, 11, 13, 13, 14, 15, - 14, 16, 15, 16, 15, 15, 15, 15, - 15, 15, 17, 15, 9, 12, 14, 15, - 10, 13, 14, 15, 10, 13, 11, 14, - 11, 14, 11, 15, 12, 15, 12, 12, - 13, 15, 13, 14, 13, 14, 14, 14, - 14, 14, 15, 15, 15, 15, 14, 15, - 15, 16, 16, 16, 15, 16, 16, 15, - 16, 17, 16, -}; - -static const uint16_t levels0[60] = { -317, 92, 62, 60, 19, 17, 10, 7, - 6, 5, 5, 3, 3, 3, 2, 2, - 2, 2, 2, 2, 2, 1, 2, 2, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, -}; - -static const uint16_t levels1[40] = { -311, 91, 61, 28, 10, 6, 5, 2, - 2, 2, 2, 2, 2, 2, 2, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, -}; - -static const uint16_t levels2[340] = { -181,110, 78, 63, 61, 62, 60, 61, - 33, 41, 41, 19, 17, 19, 12, 11, - 9, 11, 10, 6, 8, 7, 6, 4, - 5, 5, 4, 4, 3, 4, 3, 5, - 3, 4, 3, 3, 3, 3, 3, 3, - 2, 2, 4, 2, 3, 2, 3, 3, - 2, 2, 2, 2, 2, 2, 2, 2, - 3, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 1, 2, 1, 2, 2, - 2, 2, 1, 2, 1, 1, 1, 2, - 2, 1, 2, 1, 2, 2, 2, 2, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, -}; - -static const uint16_t levels3[180] = { -351,122, 76, 61, 41, 42, 24, 30, - 22, 19, 11, 9, 10, 8, 5, 5, - 4, 5, 5, 3, 3, 3, 3, 3, - 3, 3, 2, 2, 3, 2, 2, 2, - 3, 3, 2, 2, 2, 3, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 1, 1, - 2, 2, 1, 2, 1, 2, 2, 2, - 2, 2, 2, 1, 2, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 2, - 2, 1, 2, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, -}; - -static const uint16_t levels4[70] = { -113, 68, 49, 42, 40, 32, 27, 15, - 10, 5, 3, 3, 3, 3, 2, 2, - 2, 2, 2, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, -}; - -static const uint16_t levels5[40] = { -214, 72, 42, 40, 18, 4, 4, 2, - 2, 2, 2, 2, 1, 1, 2, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, -}; - -static const CoefVLCTable coef_vlcs[6] = { - { - sizeof(coef0_huffbits), coef0_huffcodes, coef0_huffbits, levels0, - }, - { - sizeof(coef1_huffbits), coef1_huffcodes, coef1_huffbits, levels1, - }, - { - sizeof(coef2_huffbits), coef2_huffcodes, coef2_huffbits, levels2, - }, - { - sizeof(coef3_huffbits), coef3_huffcodes, coef3_huffbits, levels3, - }, - { - sizeof(coef4_huffbits), coef4_huffcodes, coef4_huffbits, levels4, - }, - { - sizeof(coef5_huffbits), coef5_huffcodes, coef5_huffbits, levels5, - }, -}; - -/*table of the values of 10^(index*.05)*/ -const fixed64 pow_table[] ICONST_ATTR_WMA_XL_IRAM = - { 0x199a, 0x1cb9, 0x203a, 0x2429, 0x2893, 0x2d86, 0x3314, 0x3950, 0x404e, - 0x4827, 0x50f4, 0x5ad5, 0x65ea, 0x725a, 0x804e, 0x8ff6, 0xa186, 0xb53c, - 0xcb59, 0xe429, 0x10000LL,0x11f3dLL,0x14249LL,0x1699cLL,0x195bcLL, - 0x1c73dLL,0x1fec9LL,0x23d1dLL,0x2830bLL,0x2d182LL, 0x3298bLL,0x38c53LL, - 0x3fb28LL,0x47783LL,0x5030aLL,0x59f98LL,0x64f40LL,0x71457LL,0x7f17bLL, - 0x8e99aLL,0xa0000LL,0xb385eLL,0xc96d9LL,0xe2019LL,0xfd954LL,0x11c865LL, - 0x13f3dfLL,0x166320LL,0x191e6eLL,0x1c2f10LL,0x1f9f6eLL,0x237b39LL, - 0x27cf8bLL,0x2cab1aLL,0x321e65LL,0x383bf0LL,0x3f1882LL,0x46cb6aLL, - 0x4f6eceLL,0x592006LL,0x640000LL,0x7033acLL,0x7de47eLL,0x8d40f6LL, - 0x9e7d44LL,0xb1d3f4LL,0xc786b7LL,0xdfdf43LL,0xfb304bLL,0x119d69aLL, - 0x13c3a4eLL,0x162d03aLL,0x18e1b70LL,0x1beaf00LL,0x1f52feeLL, - 0x2325760LL,0x276f514LL,0x2c3f220LL,0x31a5408LL,0x37b403cLL,0x3e80000LL, - 0x46204b8LL,0x4eaece8LL,0x58489a0LL,0x630e4a8LL,0x6f24788LL,0x7cb4328LL, - 0x8beb8a0LL,0x9cfe2f0LL,0xb026200LL,0xc5a4710LL,0xddc2240LL,0xf8d1260LL, - 0x1172d600LL,0x1393df60LL,0x15f769c0LL,0x18a592c0LL,0x1ba77540LL, - 0x1f074840LL,0x22d08280LL,0x27100000LL,0x2bd42f40LL,0x312d4100LL, - 0x372d6000LL,0x3de8ee80LL,0x4576cb80LL,0x4df09f80LL,0x57733600LL, - 0x621edd80LL,0x6e17d480LL,0x7b86c700LL,0x8a995700LL,0x9b82b800LL, - 0xae7c5c00LL,0xc3c6b900LL,0xdbaa2200LL,0xf677bc00LL,0x1148a9400LL, - 0x13648d200LL,0x15c251800LL,0x186a00000LL,0x1b649d800LL,0x1ebc48a00LL, - 0x227c5c000LL,0x26b195000LL,0x2b6a3f000LL,0x30b663c00LL,0x36a801c00LL, - 0x3d534a400LL,0x44cee4800LL,0x4d343c800LL,0x569fd6000LL,0x6131b2800LL, - 0x6d0db9800LL,0x7a5c33800LL,0x894a55000LL,0x9a0ad6000LL,0xacd69d000LL, - 0xc1ed84000LL,0xd9972f000LL,0xf42400000LL,0x111ee28000LL,0x1335ad6000LL, - 0x158db98000LL,0x182efd4000LL,0x1b22676000LL,0x1e71fe6000LL, - 0x2229014000LL,0x26540e8000LL,0x2b014f0000LL,0x3040a5c000LL, - 0x3623e60000LL,0x3cbf0fc000LL,0x4428940000LL,0x4c79a08000LL, - 0x55ce758000LL,0x6046c58000LL,0x6c06220000LL,0x7934728000LL, - 0x87fe7d0000LL,0x9896800000LL,0xab34d90000LL,0xc018c60000LL, - 0xd7893f0000LL,0xf1d5e40000LL,0x10f580a0000LL,0x13073f00000LL, - 0x1559a0c0000LL,0x17f48900000LL,0x1ae0d160000LL,0x1e286780000LL, - 0x21d66fc0000LL,0x25f769c0000LL,0x2a995c80000LL,0x2fcc0440000LL, - 0x35a10940000LL,0x3c2c3b80000LL,0x4383d500000LL,0x4bc0c780000LL, - 0x54ff0e80000LL,0x5f5e1000000LL,0x6b010780000LL,0x780f7c00000LL, - 0x86b5c800000LL,0x9725ae00000LL,0xa9970600000LL,0xbe487500000LL, - 0xd5804700000LL,0xef8d5a00000LL,0x10cc82e00000LL,0x12d940c00000LL, - 0x152605c00000LL,0x17baa2200000LL,0x1a9fd9c00000LL,0x1ddf82a00000LL, - 0x2184a5c00000LL,0x259ba5400000LL,0x2a3265400000LL,0x2f587cc00000LL, - 0x351f69000000LL,0x3b9aca000000LL,0x42e0a4800000LL,0x4b09ad800000LL, - 0x54319d000000LL,0x5e778d000000LL,0x69fe64000000LL,0x76ed49800000LL, - 0x85702c000000LL,0x95b858000000LL,0xa7fd1c000000LL,0xbc7c87000000LL, - 0xd37c3a000000LL,0xed4a55000000LL,0x10a3e82000000LL,0x12abb1a000000LL, - 0x14f2e7a000000LL,0x1781474000000LL,0x1a5f7f4000000LL,0x1d974de000000LL, - 0x2133a18000000LL - }; - -/* 10^(index/16). We'll need to accomidate negative indicies too. - The algorithm sort of implies that there should be 128 values starting at -60, - however this has not been confirmed. More values may be needed. -*/ -const fixed32 pow_10_to_yover16[] ICONST_ATTR= -{ - /*60 negative indicies (-60 to -1)*/ - 0xc, 0xd, 0x10, 0x12, 0x15, 0x18, 0x1c, 0x20, 0x25, 0x2b, 0x31, 0x39, 0x42, - 0x4c, 0x57, 0x65, 0x75, 0x87, 0x9b, 0xb3, 0xcf, 0xef, 0x114, 0x13f, 0x171, - 0x1aa, 0x1eb, 0x238, 0x28f, 0x2f5, 0x36a, 0x3f1, 0x48d, 0x542, 0x612, 0x703, - 0x818, 0x959, 0xacc, 0xc77, 0xe65, 0x10a0, 0x1333, 0x162b, 0x199a, 0x1d90, - 0x2223, 0x276c, 0x2d86, 0x3492, 0x3cb5, 0x461b, 0x50f4, 0x5d7c, 0x6bf4, - 0x7caa, 0x8ff6, 0xa63e, 0xbff9, 0xddb0, - /*non-negative indicies (0-68)*/ - 0x10000, 0x127a0, 0x15562, 0x18a39, 0x1c73d, 0x20db4, 0x25f12, 0x2bd09, - 0x3298b, 0x3a6d9, 0x4378b, 0x4dea3, 0x59f98, 0x67e6b, 0x77fbb, 0x8a8de, - 0xa0000, 0xb8c3e, 0xd55d1, 0xf6636, 0x11c865, 0x148906, 0x17b6b7, 0x1b625b, - 0x1f9f6e, 0x248475, 0x2a2b6e, 0x30b25e, 0x383bf0, 0x40f02b, 0x4afd4b, - 0x5698b0, 0x640000, 0x737a6b, 0x855a26, 0x99fe1e, 0xb1d3f4, 0xcd5a3e, - 0xed232b, 0x111d78b, 0x13c3a4f, 0x16d2c94, 0x1a5b24e, 0x1e6f7b0, 0x2325761, - 0x28961b3, 0x2ede4eb, 0x361f6de, 0x3e80000, 0x482c830, 0x535857d, 0x603ed31, - 0x6f24787, 0x8058668, 0x9435fab, 0xab26b6d, 0xc5a4715, 0xe43bdc4, - 0x1078f70c, 0x1305acdd, 0x15f769cb, 0x195dd0fa, 0x1d4af12d, 0x21d3a4ab, - 0x27100000, 0x2d1bd1e1, 0x341736de, 0x3c2743e8, 0x4576cb4a -}; - -const fixed32 pow_a_table[] ICONST_ATTR_WMA_XL_IRAM = -{ - 0x1004,0x1008,0x100c,0x1010,0x1014,0x1018,0x101c,0x1021,0x1025,0x1029,0x102d, - 0x1031,0x1036,0x103a,0x103e,0x1043,0x1047,0x104b,0x1050,0x1054,0x1059,0x105d, - 0x1062,0x1066,0x106b,0x106f,0x1074,0x1078,0x107d,0x1082,0x1086,0x108b,0x1090, - 0x1095,0x1099,0x109e,0x10a3,0x10a8,0x10ad,0x10b2,0x10b7,0x10bc,0x10c1,0x10c6, - 0x10cb,0x10d0,0x10d5,0x10da,0x10df,0x10e5,0x10ea,0x10ef,0x10f5,0x10fa,0x10ff, - 0x1105,0x110a,0x1110,0x1115,0x111b,0x1120,0x1126,0x112c,0x1131,0x1137,0x113d, - 0x1143,0x1149,0x114f,0x1155,0x115a,0x1161,0x1167,0x116d,0x1173,0x1179,0x117f, - 0x1186,0x118c,0x1192,0x1199,0x119f,0x11a6,0x11ac,0x11b3,0x11b9,0x11c0,0x11c7, - 0x11ce,0x11d4,0x11db,0x11e2,0x11e9,0x11f0,0x11f8,0x11ff,0x1206,0x120d,0x1215, - 0x121c,0x1223,0x122b,0x1233,0x123a,0x1242,0x124a,0x1251,0x1259,0x1261,0x1269, - 0x1271,0x127a,0x1282,0x128a,0x1293,0x129b,0x12a4,0x12ac,0x12b5,0x12be,0x12c7, - 0x12d0,0x12d9,0x12e2,0x12eb,0x12f4,0x12fe,0x1307 -}; - - -/* 32.32 unsigned fixed format */ -/* This is a table of exponent values for an IEEE SP float. Theres never anything less then about index 115 - * making the size of this table fairly ridiculous. - */ - - -const fixed64 lsp_pow_e_table[] ICONST_ATTR_WMA_XL_IRAM = -{ - 0xb504f30000000000LL, 0x9837f00000000000LL, 0x8000000000000000LL, 0x6ba27e8000000000LL, 0x5a82798000000000LL, - 0x4c1bf80000000000LL, 0x4000000000000000LL, 0x35d13f4000000000LL, 0x2d413cc000000000LL, 0x260dfc0000000000LL, - 0x2000000000000000LL, 0x1ae89fa000000000LL, 0x16a09e6000000000LL, 0x1306fe0000000000LL, 0x1000000000000000LL, - 0xd744fd000000000LL, 0xb504f3000000000LL, 0x9837f0000000000LL, 0x800000000000000LL, 0x6ba27e800000000LL, - 0x5a8279800000000LL, 0x4c1bf8000000000LL, 0x400000000000000LL, 0x35d13f400000000LL, 0x2d413cc00000000LL, - 0x260dfc000000000LL, 0x200000000000000LL, 0x1ae89fa00000000LL, 0x16a09e600000000LL, 0x1306fe000000000LL, - 0x100000000000000LL, 0xd744fd00000000LL, 0xb504f300000000LL, 0x9837f000000000LL, 0x80000000000000LL, - 0x6ba27e80000000LL, 0x5a827980000000LL, 0x4c1bf800000000LL, 0x40000000000000LL, 0x35d13f40000000LL, - 0x2d413cc0000000LL, 0x260dfc00000000LL, 0x20000000000000LL, 0x1ae89fa0000000LL, 0x16a09e60000000LL, - 0x1306fe00000000LL, 0x10000000000000LL, 0xd744fd0000000LL, 0xb504f30000000LL, 0x9837f00000000LL, - 0x8000000000000LL, 0x6ba27e8000000LL, 0x5a82798000000LL, 0x4c1bf80000000LL, 0x4000000000000LL, - 0x35d13f4000000LL, 0x2d413cc000000LL, 0x260dfc0000000LL, 0x2000000000000LL, 0x1ae89fa000000LL, - 0x16a09e6000000LL, 0x1306fe0000000LL, 0x1000000000000LL, 0xd744fd000000LL, 0xb504f3000000LL, - 0x9837f0000000LL, 0x800000000000LL, 0x6ba27e800000LL, 0x5a8279800000LL, 0x4c1bf8000000LL, - 0x400000000000LL, 0x35d13f400000LL, 0x2d413cc00000LL, 0x260dfc000000LL, 0x200000000000LL, - 0x1ae89fa00000LL, 0x16a09e600000LL, 0x1306fe000000LL, 0x100000000000LL, 0xd744fd00000LL, - 0xb504f300000LL, 0x9837f000000LL, 0x80000000000LL, 0x6ba27e80000LL, 0x5a827980000LL, - 0x4c1bf800000LL, 0x40000000000LL, 0x35d13f40000LL, 0x2d413cc0000LL, 0x260dfc00000LL, - 0x20000000000LL, 0x1ae89fa0000LL, 0x16a09e60000LL, 0x1306fe00000LL, 0x10000000000LL, - 0xd744fd0000LL, 0xb504f30000LL, 0x9837f00000LL, 0x8000000000LL, 0x6ba27e8000LL, - 0x5a82798000LL, 0x4c1bf80000LL, 0x4000000000LL, 0x35d13f4000LL, 0x2d413cc000LL, - 0x260dfc0000LL, 0x2000000000LL, 0x1ae89fa000LL, 0x16a09e6000LL, 0x1306fe0000LL, - 0x1000000000LL, 0xd744fd000LL, 0xb504f3000LL, 0x9837f0000LL, 0x800000000LL, - 0x6ba27e800LL, 0x5a8279800LL, 0x4c1bf8000LL, 0x400000000LL, 0x35d13f400LL, - 0x2d413cc00LL, 0x260dfc000LL, 0x200000000LL, 0x1ae89fa00LL, 0x16a09e600LL, - 0x1306fe000LL, 0x100000000LL, 0xd744fd00LL, 0xb504f300LL, 0x9837f000LL, - 0x80000000LL, 0x6ba27e80LL, 0x5a827980LL, 0x4c1bf800LL, 0x40000000LL, - 0x35d13f40LL, 0x2d413cc0LL, 0x260dfc00LL, 0x20000000LL, 0x1ae89fa0LL, - 0x16a09e60LL, 0x1306fe00LL, 0x10000000LL, 0xd744fd0LL, 0xb504f30LL, - 0x9837f00LL, 0x8000000LL, 0x6ba27e8LL, 0x5a82798LL, 0x4c1bf80LL, - 0x4000000LL, 0x35d13f4LL, 0x2d413ccLL, 0x260dfc0LL, 0x2000000LL, - 0x1ae89faLL, 0x16a09e6LL, 0x1306fe0LL, 0x1000000LL, 0xd744fdLL, - 0xb504f3LL, 0x9837f0LL, 0x800000LL, 0x6ba27eLL, 0x5a8279LL, - 0x4c1bf8LL, 0x400000LL, 0x35d13fLL, 0x2d413cLL, 0x260dfcLL, - 0x200000LL, 0x1ae89fLL, 0x16a09eLL, 0x1306feLL, 0x100000LL, - 0xd744fLL, 0xb504fLL, 0x9837fLL, 0x80000LL, 0x6ba27LL, - 0x5a827LL, 0x4c1bfLL, 0x40000LL, 0x35d13LL, 0x2d413LL, - 0x260dfLL, 0x20000LL, 0x1ae89LL, 0x16a09LL, 0x1306fLL, - 0x10000LL, 0xd744LL, 0xb504LL, 0x9837LL, 0x8000LL, - 0x6ba2LL, 0x5a82LL, 0x4c1bLL, 0x4000LL, 0x35d1LL, - 0x2d41LL, 0x260dLL, 0x2000LL, 0x1ae8LL, 0x16a0LL, - 0x1306LL, 0x1000LL, 0xd74LL, 0xb50LL, 0x983LL, - 0x800LL, 0x6baLL, 0x5a8LL, 0x4c1LL, 0x400LL, - 0x35dLL, 0x2d4LL, 0x260LL, 0x200LL, 0x1aeLL, - 0x16aLL, 0x130LL, 0x100LL, 0xd7LL, 0xb5LL, - 0x98LL, 0x80LL, 0x6bLL, 0x5aLL, 0x4cLL, - 0x40LL, 0x35LL, 0x2dLL, 0x26LL, 0x20LL, - 0x1aLL, 0x16LL, 0x13LL, 0x10LL, 0xdLL, - 0xbLL, 0x9LL, 0x8LL, 0x6LL, 0x5LL, - 0x4LL, 0x4LL, 0x3LL, 0x2LL, 0x2LL, - 0x2LL, 0x1LL, 0x1LL, 0x1LL, 0x1LL, - 0x0LL -}; - -/* table of exp noise values multiplied by 16 in order to reduce rounding error */ -fixed32 noisetable_exp[] = -{ - 0x5, 0xfffffa2e, 0xc2c, 0xb47, 0xffffaebe, 0xfffffa63, 0xfffff7ff, 0x16bd, - 0xffffe704, 0xffffe34e, 0x71ee, 0x396e, 0xffff8bfd, 0x3b4, 0x562f, 0xffffc362, - 0x5327, 0xffffae19, 0x6cb4, 0x26b0, 0x87c4, 0x21dc, 0x8017, 0x1db0, - 0xffffe49e, 0xffffb162, 0xffffc808, 0xffffafea, 0xfffffe80, 0xfffffeb8, 0xffff8b6e, 0xffffc7a1, - 0x3f46, 0x5e8, 0x374f, 0xffff8fba, 0x87fd, 0x21e7, 0xffff9198, 0x78a0, - 0x7f7c, 0x864f, 0xffffca94, 0x42a7, 0xfffffcd6, 0xffffb916, 0x247a, 0x5679, - 0x8d9f, 0xffffb350, 0xffff9592, 0xffffcf73, 0x552d, 0xffffeb8c, 0x8622, 0xffff8091, - 0x238, 0x3ee8, 0x5c2f, 0x6e25, 0xffffe5cb, 0x86a1, 0xffffa8ca, 0xfe2, - 0x5dac, 0x2da2, 0x5ad1, 0xffffa94f, 0x729, 0xfffffdc0, 0xffff825c, 0x8bcd, - 0xffff7d05, 0xffff7d9e, 0xffffb5b6, 0x58a3, 0xffff8a3f, 0xffffd9c0, 0xffff8142, 0x596f, - 0x78aa, 0x2694, 0x78f5, 0xffff8a84, 0x43b3, 0x498a, 0xffffdfe5, 0xffffbba9, - 0xffff7228, 0xffff72c9, 0xfffff174, 0xffff9a76, 0x64d5, 0x221c, 0x88dd, 0xffffd319, - 0xfffffe14, 0xfffff99f, 0xffff8ba4, 0x6e34, 0x6cc, 0x3208, 0xfffffb14, 0x6670, - 0xffffd5ff, 0xffffa502, 0x641d, 0xffff75b6, 0xec2, 0xffffedf2, 0xffffb925, 0xffffe271, - 0xffffb727, 0xffff7450, 0xfffff421, 0x89e7, 0xfffff635, 0xffffa841, 0xffffda00, 0xffffc94e, - 0xef9, 0x28cc, 0xffffd477, 0xffff82b9, 0x2a7, 0xffff7540, 0x24c2, 0x4349, - 0xffffdf34, 0xdf7, 0x323d, 0xffffbce7, 0x29c5, 0x4700, 0x10b0, 0x1eb6, - 0x1172, 0x84be, 0xffffcee4, 0xffffe7bd, 0x1166, 0xffff7df0, 0xffffe115, 0x2383, - 0x23a0, 0x784a, 0x6f8e, 0xffff9043, 0x2b66, 0xffffc79e, 0xffff8966, 0xffffbfac, - 0x5fb1, 0xffffb183, 0x3602, 0x3d19, 0xffff7df4, 0x3ffe, 0xffffc919, 0x5ac7, - 0xffffa3e8, 0xfffff2ea, 0x47b9, 0xffffe344, 0x12f0, 0xffffc4e8, 0xfffff3fc, 0xffffcacd, - 0xffffd23b, 0x893a, 0x5e82, 0xffff8d36, 0x50e0, 0x49a6, 0x29dd, 0x16fa, - 0x451d, 0x8315, 0xffffe455, 0x749, 0x8624, 0x2fe5, 0x3ab5, 0xffffb4f1, - 0x72d, 0xffffccdf, 0x2b05, 0xffffa816, 0xffff9570, 0xffffd2e7, 0xffffa6ac, 0x2fc2, - 0xae4, 0x4c93, 0xfffffce1, 0xffffdb9f, 0x8102, 0x6bb1, 0xffffd5bf, 0xffff80e0, - 0xffffd70e, 0x568f, 0xc12, 0xffff9823, 0x700c, 0xffffa1aa, 0xffffa86c, 0xffffd303, - 0xffffbe7a, 0x38c9, 0xffff9f18, 0xffffcd7a, 0xffff8d75, 0x6955, 0xffffe70a, 0xffffbf49, - 0xffffc423, 0x31f, 0xffffe44a, 0x118a, 0xffffebfa, 0xffffedec, 0xffffee42, 0xffffd865, - 0xffff9b30, 0xffff8759, 0xffff827c, 0xffffbc26, 0xfffffb02, 0xffff8bee, 0xffffe6c2, 0x72f3, - 0xffffc2c9, 0xffff74ff, 0x2434, 0x1eb4, 0x11c9, 0x61c1, 0xffffa964, 0x89a3, - 0x6a43, 0x3d7f, 0xffffd09f, 0x14d8, 0x37bc, 0xfffffc31, 0xffffdb03, 0xfffff4e1, - 0x5547, 0xffffdc87, 0xffff929a, 0x73cc, 0x246f, 0x194e, 0xffffb4ce, 0x86b5, - 0x2f57, 0x7f05, 0x252b, 0xffff9b05, 0x5b7a, 0x164, 0x57cf, 0x7f86, - 0x5421, 0xffffa478, 0xffffbbda, 0x1b3c, 0xfffff4cb, 0xffffda7e, 0x5d8e, 0x1957, - 0xffffb3a7, 0x1979, 0xffff8ddd, 0xffffd7b9, 0xfffff028, 0xffff8c90, 0x476a, 0x6be6, - 0x419e, 0xfffffd2d, 0x8294, 0xffffc931, 0xffffe1ab, 0xffffdd4f, 0x46f0, 0x1930, - 0x4e5e, 0x8429, 0xffffde0a, 0xffff8e69, 0x2972, 0x387f, 0x3dd8, 0xffffbcc6, - 0x121b, 0x6d3d, 0x1fa4, 0xffffa3ea, 0xffffbbef, 0xffffcbd2, 0xffffbe04, 0xffffb424, - 0xffff7533, 0x70cd, 0x2370, 0x4822, 0xffff756e, 0xffffbe8c, 0x4131, 0x1ead, - 0x47de, 0xffffed53, 0xffff917e, 0x5f93, 0xffffe264, 0xffffde05, 0xffff9dc3, 0xffffc1d9, - 0xffff9b25, 0x3ade, 0xfffff9b7, 0xffffac80, 0x239e, 0xffffb980, 0xffffc9a4, 0x788c, - 0xffffbb6d, 0x3bb7, 0x6483, 0xffffeac0, 0x25ea, 0xffffbdfc, 0x333d, 0x8c0d, - 0x6d9a, 0xffffafe8, 0xffff8a74, 0x6067, 0xffff8642, 0x1a64, 0xfffff921, 0x3f3b, - 0xae4, 0x5112, 0x43a4, 0x1573, 0xffffc977, 0xffffa3b4, 0x21be, 0xffff96df, - 0xfffff035, 0x473b, 0xffff8d26, 0xb75, 0xffffecdc, 0x4455, 0x47d5, 0xffff7581, - 0xeca, 0xffffb3fe, 0xffff9f6a, 0xffffea15, 0xffffb9c3, 0x5516, 0xffffb654, 0x7f91, - 0x80b, 0xffff96b7, 0x2b60, 0x36b7, 0xffffc581, 0x285b, 0xffffa002, 0xffffc7e5, - 0x4965, 0xffff94d4, 0xffff764b, 0x1cd2, 0x5599, 0xffffd272, 0xffffcbfb, 0xffffae6d, - 0xffffd496, 0x3183, 0xffffe4f5, 0xffffa59f, 0x43df, 0x4569, 0xffffb185, 0x1d56, - 0xffff933a, 0xffff7a2c, 0x38d0, 0xffffb815, 0x5203, 0xfffffd89, 0xffff93ea, 0xffffa4dd, - 0x1f13, 0xffffad7d, 0xffffff4f, 0xffffe13c, 0xffffd60a, 0x8c88, 0x8276, 0xffffeaaf, - 0xffff8a66, 0xffff7888, 0xffff91e9, 0x8bdf, 0xdcf, 0xfffff282, 0xffffe91b, 0x1eb1, - 0x6fc, 0xffff81f6, 0x1617, 0xffffad02, 0xffffafaf, 0x60d5, 0x6f2b, 0x4e8b, - 0x2347, 0x3257, 0x29cf, 0x86c4, 0x75b3, 0x7745, 0xfffffcc7, 0x49cd, - 0x558f, 0xffff7c7a, 0x52e1, 0xffff7626, 0x7690, 0xffffb357, 0xffff7dbf, 0xffffa1ee, - 0xffffa874, 0xffff846f, 0xffffab72, 0x5cef, 0xffffb0cf, 0xffff8c24, 0xffff8e10, 0xffffe200, - 0x2a45, 0xfffff883, 0x5155, 0x37c9, 0xad6, 0x1ed9, 0x79e2, 0x1f4c, - 0x45f8, 0x48ec, 0xffffa331, 0x34a1, 0xffffc7b0, 0x2eb5, 0x5dc, 0x4cdd, - 0x4e5c, 0xffffa7c7, 0x3b08, 0x2776, 0x2e1a, 0x788d, 0x162b, 0x1fa7, - 0x466c, 0x5ca2, 0xfffff3ac, 0xffffa62f, 0xfffffd4c, 0x5f48, 0x779, 0x2a5e, - 0xffffe14e, 0x196, 0xffffaba1, 0x404c, 0xffffdc5b, 0x238f, 0x274, 0xffffa5c6, - 0xffff9e2b, 0x6201, 0xfffff195, 0xfffff3b0, 0x2285, 0xffffc7f0, 0xffffdff4, 0xffffc43d, - 0xffffac57, 0xffffb7a6, 0xffffe88c, 0xffffd3ac, 0xffffbb5c, 0x2cbd, 0x44d6, 0x5e30, - 0xffffeb53, 0x6d8b, 0xffff7f8b, 0xffff99a3, 0xffff7a4e, 0xffffbc82, 0x6a49, 0xfffff220, - 0xffffeaca, 0x4146, 0x8d72, 0xffffdcb7, 0xffffe2f3, 0xfffff736, 0x557f, 0x13fd, - 0x66a, 0x5d9, 0x29ee, 0xffffda1e, 0xd38, 0xffffe70f, 0xffffbbd7, 0xffffe1ee, - 0x4a0d, 0x502e, 0xffff8c37, 0xffffaccc, 0xffffdd0b, 0xffff7401, 0x3a89, 0x73b4, - 0x71b7, 0x5b43, 0xffff9baf, 0x4d76, 0x25f, 0x7f97, 0xffffcb71, 0x6b4c, - 0xffffe999, 0x3fd5, 0xffffd40b, 0x3f0d, 0xffffc17b, 0x3de9, 0x87f7, 0x6446, - 0x5be, 0xffffd88a, 0x7d05, 0xfffffe16, 0x467e, 0x1454, 0xffffca4e, 0xffffa047, - 0xffff92ac, 0xffffddc9, 0x72a9, 0xffffc902, 0x3605, 0xe47, 0x280c, 0x7662, - 0x609d, 0xffffae0a, 0x78e0, 0xffffa02a, 0x1c87, 0xfffff91b, 0xffff7792, 0xffff745e, - 0xffff8097, 0xffff8583, 0xffffe7e4, 0x61a5, 0x36a8, 0x7fe7, 0xffffaecc, 0xffff90f7, - 0x5ad9, 0x7e2f, 0xffffffca, 0x75c7, 0x7134, 0xffffd7fe, 0x3c22, 0x314c, - 0x7c97, 0x2068, 0xffff7926, 0x3e7c, 0x6926, 0x67f9, 0x3e28, 0x7c65, - 0x76b9, 0x25cf, 0x1039, 0xffffdf97, 0x8779, 0xffffe8fd, 0xffff9f74, 0x770a, - 0x8a50, 0xffffd241, 0xffffddee, 0x5aab, 0xffffc97f, 0x4572, 0x3276, 0xffffe7ec, - 0xffff8cc2, 0x6331, 0xfffffedf, 0x3b86, 0x3038, 0xffffd628, 0x2645, 0xffff737c, - 0x72fe, 0xffff8474, 0x23fb, 0x78f, 0x194c, 0x95a, 0xffff91d0, 0xffff8014, - 0x56e9, 0x2efe, 0xffffae5b, 0x614, 0xffffca3d, 0xffffd77e, 0x73e1, 0x35f7, - 0x71f3, 0xffff9279, 0xffffe6f3, 0x404b, 0x548d, 0x32a3, 0xc11, 0x637a, - 0xffff7605, 0x2ba8, 0xffff8f35, 0x8157, 0x423f, 0xffff9711, 0xffffb980, 0xffffb4b1, - 0x3494, 0xffffc9dd, 0x6c43, 0x563f, 0x52c, 0xffff9680, 0x8b7a, 0xffffcf49, - 0xffffa40b, 0x6daf, 0xffff840e, 0x29cd, 0xffffbf5c, 0x68b7, 0xffffedf3, 0xffffe329, - 0xfffff634, 0x8619, 0x33bc, 0x28b4, 0x5ed8, 0xffffcfbb, 0x883a, 0xfffffdf6, - 0xffffb980, 0x7bac, 0xfffffd6d, 0x418f, 0x4a25, 0xffffbed3, 0x4272, 0xffffef42, - 0x800f, 0x78e3, 0x82c8, 0x24e1, 0xffffcfa3, 0xffffb385, 0x86b, 0x645b, - 0x38aa, 0x6a22, 0xffffc21b, 0x60f0, 0x9b6, 0x912, 0x7621, 0xffff94cc, - 0xffffd5c9, 0xfffffdb5, 0xffffd93a, 0x2a11, 0xffff8b3d, 0xffffc0d2, 0xffffa00f, 0xffffe965, - 0xfffffa0f, 0xffffbfa9, 0x5e78, 0xffff925b, 0xffffeac8, 0xffffd5af, 0xffffba37, 0x395a, - 0xffffdc75, 0xfffffdf2, 0xffff7c7b, 0xffff89a3, 0x3766, 0xffffe8a9, 0x7118, 0x399e, - 0xffff7ff5, 0xffffac9a, 0xffff7d74, 0xffffa5d2, 0x4c27, 0x787f, 0x586, 0x7ce4, - 0xffffb38e, 0xffffb93d, 0x240d, 0x5a90, 0xffffb448, 0xffff8e29, 0xffffbc06, 0x3bf3, - 0xffffda90, 0xffffb78d, 0xffffc747, 0xffffa5c0, 0xffffe2dd, 0x7fbd, 0x8946, 0xffff8d50, - 0x2451, 0x18f9, 0xffffc1d4, 0xffffb689, 0xffffc37b, 0xffffbe2f, 0xffffbe9e, 0x8117, - 0x7050, 0xfffff504, 0x2b9, 0x464f, 0x298d, 0x2367, 0xffffe8c3, 0x79f1, - 0x4e38, 0x5cc8, 0x2928, 0xffffb486, 0x7cd6, 0xffffdbd9, 0xfffff110, 0xffffeff7, - 0x19b8, 0xffffeb99, 0xffff847c, 0xffff7612, 0xffffd542, 0x2966, 0xffff8ce2, 0x38fe, - 0xffffdeaa, 0x5238, 0x67c4, 0xffffa5e7, 0x4e6d, 0xffffd82e, 0x5973, 0x351b, - 0x74e8, 0xffffafcd, 0x66dd, 0x20e4, 0x609d, 0xffffade3, 0x509f, 0xffffa21f, - 0x2cce, 0x54c2, 0x1953, 0x85ce, 0x6bee, 0x3222, 0x6ff6, 0x3773, - 0x5a64, 0xffffe40f, 0xffffc6df, 0x3556, 0x80a9, 0xffff76c5, 0x495b, 0x1ae4, - 0xffffca33, 0x31f2, 0x833e, 0x89c3, 0x5f43, 0xffffbee7, 0x3ab2, 0x87af, - 0x4c74, 0xffff810b, 0xffffbed0, 0x6795, 0xffff785c, 0xffffbc0b, 0x520e, 0x4348, - 0xe03, 0x4541, 0x2557, 0xffff9110, 0x4044, 0x1947, 0x4dab, 0xcbe, - 0x3f72, 0x4507, 0xffffa362, 0xffffc20b, 0x6c1b, 0x27c7, 0xffff9bf2, 0x6506, - 0xffff89cc, 0x5c3e, 0x4509, 0x409a, 0xffff98db, 0x1674, 0xffff9324, 0x7328, - 0xffff99cf, 0xcd8, 0x730a, 0x14b9, 0x672d, 0xffffd620, 0x1dd8, 0x3bec, - 0xffff94b6, 0xffffb689, 0x7dfd, 0x3ffd, 0xffff9cb6, 0x3560, 0xffffbaf8, 0xffff8604, - 0x8795, 0xffff7aec, 0x66a5, 0x6a0b, 0x564b, 0xffff8d00, 0xffffed20, 0x11b8, - 0xffffdc27, 0x595d, 0xffffddf0, 0xfffffc70, 0xffffd5bf, 0x6714, 0xffffaf69, 0xdb2, - 0x3786, 0xffffbf9d, 0x7ca7, 0x5a53, 0xffff7c6a, 0xffff8465, 0xffffe4c6, 0xffffa238, - 0xffff7f9b, 0x6887, 0x3838, 0x7115, 0x5bce, 0xeae, 0x47c, 0xffffd54a, - 0xffffb9d5, 0x6183, 0x9c3, 0xbd5, 0xffffe217, 0x8237, 0x51d7, 0x52fe, - 0x6424, 0xffffb192, 0xffff7ebb, 0xffffd373, 0xffff9cf7, 0x390b, 0xffffa473, 0x8953, - 0xffff90c9, 0x594a, 0xc6e, 0x32ba, 0xffffae73, 0x86c7, 0xffffd7a0, 0xffffa82e, - 0x8d66, 0xffffabcf, 0xffff84d0, 0x3a84, 0xffffe8bd, 0x4948, 0x3f2a, 0xfffff4e5, - 0xffffb0bd, 0x4961, 0xffffd95b, 0xffffd96c, 0xffffce34, 0x57ff, 0xffffdf08, 0x2330, - 0xffffa8c7, 0x24cb, 0x740a, 0xffffdbcf, 0xffffad36, 0x306f, 0xffffa30b, 0xffffc488, - 0xffff8022, 0x464a, 0x6f00, 0xffffb419, 0xffff8450, 0x2ddb, 0x2731, 0x63fd, - 0x2946, 0x5c28, 0xffffb064, 0xffffb277, 0x1e0f, 0x6d71, 0xffff7ff3, 0xfffffb02, - 0xf2a, 0xffffd69c, 0x638, 0xffffe8ff, 0xffffbd7e, 0xffffb26f, 0xffffe153, 0xffff9879, - 0xffff849c, 0x1f73, 0xffff9b21, 0x2bb1, 0xffffa95b, 0xffffd582, 0xffffdbfa, 0xd2c, - 0xffffa86f, 0x2ab3, 0xffff9d78, 0x1074, 0xffffbcb5, 0x3990, 0xffffe869, 0xffffb422, - 0x2dc8, 0xffffca25, 0xffffcfe8, 0xaf1, 0xffff82c8, 0x36a, 0x2f4e, 0xfffffdcd, - 0x77fa, 0xffffad4f, 0xffffa54a, 0x50b9, 0x6eab, 0x5178, 0x8982, 0xffffe4dd, - 0xffff9a82, 0x45a2, 0x784e, 0xffffbd6e, 0x5019, 0xffffcc5c, 0x8009, 0x5d96, - 0xffffac8d, 0xffff8ec9, 0x4c, 0x4222, 0xfffffa7f, 0x3227, 0x67ea, 0xffffe679, - 0x3dc8, 0xffffb5b5, 0x1424, 0x3e4a, 0xfffff175, 0xffffaf4b, 0x4657, 0x1374, - 0xffff7233, 0x7190, 0x332, 0xaf0, 0x68c0, 0xffff85ad, 0xffffd0af, 0x2b1, - 0xffff8d54, 0x1f99, 0xffffe8d5, 0xffffc30b, 0x2877, 0xffff9d40, 0xffff8852, 0xffffb01a, - 0x4b32, 0x3279, 0xffff9099, 0x5f4f, 0xffffe08c, 0xffff9fe0, 0xffff9ecc, 0xfffff557, - 0xfffffc25, 0xffffa719, 0xffff920a, 0x62ac, 0xfffff11d, 0x152d, 0xfffff5d6, 0x5223, - 0xfffff438, 0xffff73f3, 0x34e1, 0x49a9, 0x6a73, 0x2ad3, 0x1f51, 0x824, - 0x1bc9, 0x5170, 0x552d, 0x52b5, 0xfffff12a, 0xffffec44, 0x7924, 0x5294, - 0xb63, 0x822f, 0xffff9afd, 0x7e29, 0x2d91, 0x42ad, 0xfffff589, 0xfffff6e9, - 0x2792, 0x4269, 0xffff9639, 0xffff726f, 0x4074, 0xffffa179, 0x8a6b, 0xffffb431, - 0x850f, 0xffff903f, 0x6b22, 0x738, 0x16a0, 0xffff917f, 0x8a5a, 0xb61, - 0xffffcce6, 0x6369, 0xffffb671, 0x66c0, 0x68e6, 0x41aa, 0x2fc3, 0x2382, - 0xffffabd5, 0x62c, 0x5041, 0xffff9903, 0x846b, 0x86f6, 0x8111, 0x15c, - 0x62ed, 0xfffff411, 0x517c, 0xffffbb6d, 0x8256, 0x141e, 0xfffffd31, 0x8777, - 0xffffabbe, 0x4eb5, 0xffffbae4, 0x75a2, 0x2bfc, 0xffff799f, 0x26bd, 0x2296, - 0x7b36, 0xffffddc6, 0x7517, 0x155a, 0x16b1, 0x25b4, 0xfffff8ce, 0x54e9, - 0xffffeb3c, 0x7e5e, 0xffffa981, 0xfffffdbb, 0x87f7, 0xfffff4fe, 0x5657, 0x2add, - 0x5113, 0x7bff, 0xffffbcec, 0x37fb, 0x59a3, 0xffffd989, 0xffff9ac8, 0xffff8e9e, - 0x5ea9, 0x1bbf, 0x8ca1, 0xffff7365, 0x4d65, 0x874c, 0x4119, 0x63ee, - 0xffff91ea, 0x8074, 0x8a3c, 0xffff74b0, 0xffffb940, 0x3c7a, 0x50f, 0xffffe11e, - 0x6c76, 0x5731, 0xf34, 0xffff8ace, 0xffffdb12, 0x4cb2, 0xffffa624, 0x8999, - 0xffff94e3, 0x469e, 0x4101, 0xffffe271, 0x850d, 0xffff95cf, 0xffff93fa, 0x3357, - 0x8fe, 0xffff9b75, 0xffffbd9b, 0x6a34, 0x1db7, 0xb19, 0xffffee5f, 0xffffc9c1, - 0x763, 0xffff9c09, 0x26a7, 0xffffb6c5, 0xf48, 0xe3e, 0x854f, 0xfffffa24, - 0xffffb689, 0x34bc, 0xffff7a74, 0xffff7240, 0x5849, 0xfffffa7f, 0xffffbd17, 0x17e4, - 0x8e6, 0xfffff805, 0xffffd6d6, 0xffffecd0, 0xffff8b9c, 0xffffed0b, 0x198e, 0x5422, - 0x8549, 0x8dc7, 0xffffb649, 0x1cb6, 0x5ba9, 0xffffc4f6, 0x7b31, 0xffff8611, - 0x62a9, 0xc49, 0xffff7b22, 0xffffd5f0, 0xffff9fce, 0x3f16, 0xffff72a8, 0xffff9a53, - 0xffffa401, 0xffff9f41, 0x53b8, 0xffffca3e, 0x86a2, 0xffffa27c, 0xffffb022, 0x7c4, - 0x3425, 0x344e, 0xffffcb0a, 0x6d47, 0x63b3, 0x677c, 0x4077, 0x72b, - 0x5a90, 0x4348, 0xffff8b9d, 0xffffbcef, 0xffff8e3f, 0x58fa, 0xffffe0a8, 0xffffaf0c, - 0x4698, 0x3da0, 0xffffd44c, 0xffffe85d, 0x455f, 0x5746, 0x5168, 0xfffff3ad, - 0xffffd7bb, 0x56b0, 0xffff7845, 0xffff8d1d, 0x8fa, 0xffffe8c1, 0xffffb00f, 0x6f65, - 0xffffb97c, 0x83b9, 0x4e67, 0x5e2a, 0x787f, 0x8d66, 0x397e, 0x7e75, - 0x4789, 0x7be7, 0x8a38, 0x7ce2, 0xffff9005, 0x3391, 0x873d, 0x5ade, - 0x71e5, 0xffffb84e, 0x4718, 0x438, 0x8700, 0xffffdf0d, 0xfffffed4, 0x88, - 0xfffff494, 0xffffab9a, 0x6c68, 0xffffece3, 0xffff9e05, 0x5590, 0xffffeda6, 0x491d, - 0x7376, 0x6e88, 0x75df, 0xffffd5a8, 0x88b7, 0xffffe707, 0x356d, 0xffff9881, - 0xffffef0f, 0xffffa40f, 0xffff8f5e, 0x3b0f, 0x3da, 0xfffff8d1, 0x6809, 0x83dd, - 0x876d, 0x3c44, 0xffffe878, 0x3faf, 0x78f, 0xffff7a85, 0xffffc78b, 0xffffd711, - 0xffff9d6b, 0x79c8, 0xd65, 0xffffe3e3, 0x478, 0x7129, 0xffff7dda, 0xffffab18, - 0xffffcd44, 0xffff7cfc, 0x723a, 0x5c3, 0x3737, 0x3451, 0x650a, 0xffffa327, - 0xfd9, 0xffff7bae, 0x1f5b, 0x2978, 0x8c99, 0x4cd4, 0xffffb3d6, 0x4036, - 0x2a0e, 0x35ea, 0x50b, 0xffff9518, 0xffff85c1, 0xffffcdc6, 0xffffdc56, 0xffff8d75, - 0xffff90f3, 0x11cb, 0xffffa7dd, 0xffff884c, 0xffffc35a, 0xffffc3cf, 0xffffad4a, 0xffffc75a, - 0xffffa170, 0x8adb, 0x7441, 0xffffe8d1, 0x42b4, 0xffffe1ad, 0xffffdd4a, 0xffff98bf, - 0x4cc2, 0xffff8b07, 0x334c, 0x5e4d, 0xffffb14a, 0xffff9c04, 0xffffb744, 0xffffa616, - 0x187d, 0x495a, 0xffffb1c3, 0x524d, 0xffffc04b, 0x6110, 0x6dff, 0x55b8, - 0x8de1, 0x3394, 0x886f, 0xc21, 0xffff995f, 0xd71, 0xffff90e8, 0xffff983a, - 0xffff92d8, 0xffffcce2, 0xffff90e7, 0xffff94ff, 0x4e0b, 0xffff9334, 0xffffeacb, 0xffff8f75, - 0x48aa, 0x7631, 0xfffffbf9, 0xffffd3e0, 0x6850, 0xffffa651, 0xffff8745, 0xffffe780, - 0xfffff596, 0xfffffed5, 0x3b41, 0x55cd, 0x5a08, 0xffffa0cf, 0xffff75a0, 0xe58, - 0xffffff64, 0x6763, 0xffff8c5f, 0x69b7, 0x453b, 0xffffba78, 0x7554, 0x4fba, - 0x6031, 0x1ed6, 0x30a2, 0x3c52, 0xfffffc1a, 0xffffecfe, 0xffffa280, 0xffff9d76, - 0xffffa66c, 0xffff8dc0, 0xffffaa2b, 0xffffbc38, 0x1cd9, 0xfffff3fa, 0x7078, 0xfffffecb, - 0x800e, 0xfffffa73, 0xffff9a9f, 0xffffb5c5, 0xffffda01, 0x68c8, 0x7787, 0xffffe959, - 0xffffc008, 0x357a, 0x37fb, 0xffff9b65, 0x4df5, 0x8ad5, 0x53aa, 0xffffcc5a, - 0xffff74a9, 0xffffed23, 0x4c8e, 0xffffbd47, 0xb95, 0x774c, 0x5109, 0xffffd8ef, - 0x4095, 0xffffad7a, 0x8a82, 0x2d80, 0xffff8d9a, 0xd43, 0x6bf9, 0x223, - 0x3eed, 0xffffc475, 0x3854, 0xffffa438, 0x1ac0, 0x990, 0x50f8, 0xfffffce9, - 0xffff72ab, 0x41f2, 0x845e, 0xffffef06, 0x7241, 0xffffcf1a, 0x7888, 0x5bf5, - 0xffffc6a5, 0xffffdbe1, 0x1573, 0x65ba, 0x1f5a, 0xffff9e88, 0xffffef80, 0x580c, - 0xffff8254, 0x5da1, 0xffff7a42, 0x220e, 0xffff7947, 0xffff7a6b, 0xffffaa90, 0x7b4, - 0xfffff0e5, 0xf4, 0xd7c, 0x3754, 0xffffa34c, 0x4314, 0x4e93, 0x5f33, - 0xffffd600, 0x150b, 0xffff867a, 0x5eee, 0x54fd, 0x630d, 0xfffff8e2, 0xffffdd08, - 0xffffdd29, 0xffff7350, 0xffffbc1a, 0x1429, 0xffffda45, 0x3e79, 0xffffca86, 0x1523, - 0x620c, 0xa9e, 0xfffffdb9, 0xffffb00f, 0xffff82bf, 0xfffffb63, 0xffff78de, 0x25ad, - 0x54ac, 0x3831, 0x66b6, 0x696e, 0x4e31, 0xffff81c0, 0xffff854a, 0xa8e, - 0x8ce6, 0x52dd, 0xffffa6c6, 0xffffe575, 0xffff9907, 0xffff9743, 0x2156, 0xffff8199, - 0x76ea, 0x7361, 0x8d23, 0xfffffa98, 0xfffffb0d, 0xffffa7b3, 0x12e3, 0x4239, - 0x4aeb, 0x7461, 0xe02, 0x987, 0x68b5, 0xfffffc95, 0x7ac, 0x7238, - 0xfffff148, 0xfffff26d, 0x58f4, 0x50b3, 0xffff869d, 0xffff8582, 0x5d94, 0x30fd, - 0x1e62, 0x83ab, 0xfffffa33, 0xffffb49d, 0x18e9, 0x4781, 0x6d8, 0x7bab, - 0x1aef, 0x2ca6, 0x81a9, 0x2f34, 0x248d, 0xffff9a23, 0xffffdd8a, 0xffffd9a2, - 0xfffffba7, 0x754, 0xffffdbe5, 0x28cc, 0xffff9659, 0x2219, 0x6bea, 0xffffe7ad, - 0xffff856e, 0xffffd3c1, 0x14ff, 0x350, 0x42f3, 0xffffd69d, 0xffffb4b5, 0xffffccd7, - 0x6500, 0x2fb6, 0xffff95b5, 0xffffe293, 0x5baa, 0xffffc45a, 0xffffda2f, 0xffff8de6, - 0xffff87ec, 0x5f0e, 0xffffca76, 0xffffac52, 0xfffff9a4, 0xffff9e0d, 0x771a, 0xd62, - 0x32f3, 0x8367, 0xffff982d, 0x240a, 0x20d, 0xfffff430, 0xffffba8d, 0xffffb810, - 0xffffcfd1, 0x8044, 0xffffcba1, 0xffff9772, 0xffffee63, 0xfffffd51, 0xfffff324, 0x101e, - 0xffffe7c7, 0xfffffb15, 0xffffc5eb, 0x8585, 0x427, 0xffffcdbf, 0xffffcc26, 0x21fb, - 0xffff7c96, 0xffff7705, 0xffffb428, 0xffffa3f8, 0x3906, 0x5787, 0xffffd8af, 0xffffd7d1, - 0xffff77d7, 0x5504, 0xffff73a1, 0x116e, 0x32d8, 0x16f2, 0x5c09, 0xfffff98c, - 0x7350, 0x6462, 0xffffada1, 0x3f1b, 0x6378, 0xffff81e0, 0x2dd3, 0xfffff52a, - 0x8142, 0x89e0, 0xffff9fc6, 0xffff7bf1, 0xffffd116, 0xffffebf0, 0xd84, 0x1669, - 0xffff9bca, 0x5050, 0x6f8a, 0x2c50, 0x8590, 0x32fd, 0x6abf, 0x6af0, - 0xffffa4de, 0x2042, 0xffff9f0b, 0x726, 0xffffcb98, 0x12a1, 0x497b, 0xffffa677, - 0xfffff6f1, 0x2433, 0xffffebc9, 0xffffd8cd, 0x2939, 0x2438, 0xffff79b3, 0xffff9226, - 0xffff9ca1, 0x4884, 0x6fe7, 0x2f89, 0x812a, 0xffffa72e, 0xffffb33c, 0xffff815e, - 0xffff8866, 0x3b83, 0xfffff5b5, 0x3fb2, 0x8221, 0xffffd486, 0x2665, 0xffffa540, - 0x5ce5, 0x893c, 0x4b34, 0x1b5d, 0xffff8b00, 0x8b56, 0xffffb3ab, 0xfffff0d7, - 0x353f, 0x63ce, 0xffff9b0b, 0xffff9689, 0xfffffe5a, 0x50c5, 0x3f3d, 0x1917, - 0x3045, 0xffffdb17, 0x2f69, 0x7ecc, 0xffff7f93, 0xffffa392, 0x9ed, 0xffff94dc, - 0x11e, 0xffffdcb5, 0xffff934b, 0xfffff44a, 0xffffd194, 0xffffe03b, 0x5841, 0xffffd49a, - 0x26f3, 0xfffffc5a, 0x8d0e, 0x6441, 0x2fc5, 0xffffed7a, 0xffffe739, 0xffffd2ff, - 0xffffb541, 0xffff8f9e, 0x807, 0xffff8e7d, 0xffff85b9, 0xffff8fc7, 0x778a, 0x8451, - 0xffffa75f, 0xffffe5b1, 0x2aeb, 0x7fe6, 0xffffc2b3, 0x8534, 0x268a, 0x6711, - 0xffff8cf8, 0xffffd800, 0xffff7913, 0x7c1b, 0x4e76, 0xffffde5d, 0x1545, 0xfffff355, - 0xffffc1bb, 0x398c, 0xffff798a, 0xffffdc27, 0x40ed, 0xfffff8fc, 0xfffff918, 0x7ef5, - 0x5182, 0x8369, 0x47af, 0xffffd6d5, 0xffff7e09, 0xffffa12e, 0x5363, 0xffffce2c, - 0xffffdc79, 0xfffff095, 0xffff7760, 0x4905, 0xffffd192, 0xffff9ca8, 0x39dc, 0xffffd67b, - 0x680, 0xffffb5a4, 0xffffd7d7, 0xffffb5a5, 0x7fcd, 0x7305, 0xffff8e3b, 0x179d, - 0xffffebf4, 0xffffad3c, 0xffff791f, 0xffffb513, 0x7d2e, 0x361f, 0x1a0f, 0xffffd336, - 0xffff7531, 0xffff73ec, 0x8acc, 0x85bf, 0xffff8a29, 0xd3c, 0x392, 0x4482, - 0x7272, 0xffff8403, 0x7d3e, 0xfffff055, 0x6ae2, 0xffffc5b3, 0x74ac, 0x30f6, - 0xfffff4bd, 0x19ba, 0xffffc488, 0xffffeec2, 0x877, 0xa9d, 0xfc1, 0x57a0, - 0x4879, 0x175a, 0xffffa0c0, 0x533, 0x8765, 0x2d23, 0x7ae9, 0x1d9e, - 0x16b2, 0x58c4, 0xffffe64f, 0xffff79ba, 0x68cd, 0x5c30, 0xffffb8e0, 0xffffc5d1, - 0xfffff04f, 0x5fec, 0x19ca, 0xffff8c02, 0x15ab, 0x8897, 0xffffebeb, 0x70d7, - 0x1662, 0x8c83, 0x8bc8, 0x21c8, 0xffffa728, 0x6513, 0xffff92f4, 0xffffadb2, - 0x7a29, 0xffffe450, 0x2136, 0xffffc6db, 0x26e, 0x8221, 0x3097, 0x5883, - 0xffffa134, 0x8284, 0xffffa6d9, 0x1c76, 0xffff8524, 0x164e, 0xffffa415, 0xffff841e, - 0x309d, 0xffffd4e1, 0xffff99a3, 0x4e11, 0xffff90a2, 0x51bf, 0xffffec39, 0xffff9073, - 0xe4e, 0xffff7a6a, 0x26b0, 0x64e4, 0x1a95, 0xffffeed3, 0x8049, 0x67b0, - 0x23e0, 0xffffb836, 0xf72, 0x2c0f, 0xffffacff, 0xffffa183, 0x87b8, 0xffff7e3a, - 0xffffef41, 0xffff796e, 0xfffffd33, 0x4c73, 0xffffd590, 0xffffdfac, 0xfffff5fb, 0xffff9594, - 0xffffba62, 0xffffa2d2, 0x496a, 0x1501, 0xffff9a7a, 0xffffc542, 0xffff8a89, 0xffffdda6, - 0xffff7f5e, 0xffffbf34, 0xffffe1e1, 0xffffb26c, 0xffffe9c3, 0x67cc, 0xffffb506, 0x6416, - 0x454, 0x3724, 0xffff9c3d, 0x2f27, 0x45cb, 0x670f, 0xffff7969, 0xffffdc9e, - 0xffff87e1, 0x1948, 0xfffffe4e, 0x1fdd, 0xffffe119, 0x5c64, 0xffffc383, 0x1062, - 0x6828, 0x6dd8, 0x2238, 0x12d5, 0xffffd611, 0xffff8739, 0x137a, 0x52c6, - 0x441c, 0xffffc74c, 0xffffee23, 0x583a, 0xffffd369, 0x3c68, 0xffff99a0, 0xffffb914, - 0xffffbe62, 0xffffcd86, 0x1438, 0xffffe64d, 0x53da, 0x2358, 0x89f6, 0x6e04, - 0x459f, 0xffffb2a5, 0xffffdaf4, 0xfffface2, 0x6673, 0xfffff8df, 0x594d, 0xffffeedd, - 0xffffa520, 0xffff8687, 0x70b0, 0x5dba, 0xffffe645, 0x3bbc, 0xffff8028, 0xffffea28, - 0xffffc7ba, 0x36ca, 0x7c40, 0x34ce, 0xffff7a62, 0x10bf, 0x5ee1, 0xffff98ab, - 0x10be, 0x3b49, 0x8c53, 0x8386, 0xffff7a09, 0xffff7a77, 0xffff7acd, 0x2cc4, - 0xffff93aa, 0x574, 0xffffc3ed, 0x2586, 0xffffeca4, 0x750e, 0xffffb075, 0x6308, - 0x67ac, 0xffffc8a3, 0x49c1, 0xfffff006, 0x89c9, 0x4f36, 0x3909, 0xffffd5d0, - 0xffffe4c1, 0xffff7a19, 0xffff8552, 0x7a2b, 0xffff9d63, 0x88e9, 0xfffffde4, 0x190a, - 0xffff826f, 0xffffecd9, 0x1983, 0xffffe551, 0xffff92e2, 0x2c5c, 0xffffd03c, 0x4adf, - 0x6865, 0xffff7e20, 0xffffea03, 0x841d, 0x4e37, 0x3d59, 0x3171, 0x673a, - 0x1afc, 0xffffa098, 0xffffde36, 0xfffffbbd, 0x47a5, 0x65be, 0x3738, 0x2beb, - 0x3e11, 0x6cff, 0x8da8, 0x22a6, 0xffffdf4a, 0x1151, 0xffffc349, 0x3485, - 0xffffee00, 0xffff864e, 0x865, 0x5989, 0x4145, 0xffff8999, 0xffff835e, 0xffffc2ad, - 0x2f00, 0xffffdc98, 0x7dfe, 0xffffc2fe, 0x1234, 0xfffff5da, 0xffffd55c, 0x119e, - 0xffff7dc3, 0xffffb27e, 0x7aae, 0xffff7b34, 0xffffde8e, 0x797, 0xffffab7e, 0xffffe6ce, - 0x7685, 0x600f, 0x7285, 0x6045, 0xffffe2f4, 0x69e7, 0xffffdfd8, 0x14a, - 0xffffda78, 0xffffabc0, 0x89c3, 0xffffbeac, 0xc37, 0x6df4, 0xffffe0d2, 0xffffc632, - 0xffffa62e, 0xffff8d46, 0xffff78fa, 0x3003, 0xfffff74e, 0x42a9, 0xffffe8d6, 0xffff7863, - 0x6a8e, 0xffff8696, 0x1844, 0xffffa06f, 0xd36, 0xffffd8d8, 0xffffe27c, 0x387e, - 0x30fb, 0xfffff762, 0x808a, 0x2d5b, 0x6717, 0xffffff14, 0x845b, 0xffff9586, - 0x68b, 0xffffe56f, 0xffff96b9, 0x6295, 0xffffb26c, 0x2a02, 0xfffffd8b, 0x6b98, - 0xffff8ca4, 0x501a, 0x5f44, 0xffffa9ac, 0xffffa063, 0xffff9030, 0xffff80d2, 0xffffcd8c, - 0x4c8c, 0xffffc0f8, 0x397, 0x819c, 0x767c, 0x7d99, 0xfffff123, 0x1b50, - 0x2c29, 0xffffd70f, 0xffffcca8, 0xffffa017, 0xfffff2b7, 0xffff74f0, 0xffffa9ed, 0x233b, - 0x1516, 0xffffbb9f, 0xffff97bc, 0x23c4, 0xfffff299, 0x7db1, 0xa52, 0xffff9161, - 0xffff8541, 0xffff75a7, 0xe20, 0x7dd3, 0xffffcc27, 0xffff9e5e, 0xffffe9ee, 0xb6e, - 0xffffe271, 0xffffe9e6, 0x6d72, 0xfffffd38, 0xffffa167, 0x6246, 0x83b, 0xffffa571, - 0xaeb, 0xffff8759, 0xffffa37f, 0xffffea7c, 0x6061, 0x8b6c, 0xffffb904, 0xffff88ea, - 0xffffa8f7, 0xffffd266, 0xffffa1bf, 0x343a, 0x6f9c, 0xffffd56b, 0x37ef, 0xffff8566, - 0x4eb7, 0xffffd9b3, 0xffffd22e, 0x8af7, 0x1d78, 0xfffff575, 0x391e, 0x4836, - 0xffffeaf1, 0xffff89a2, 0x6ac6, 0x611f, 0x8458, 0x2af6, 0x588f, 0x8e5, - 0x8bf6, 0xffffac56, 0x35d8, 0x6e0, 0x371b, 0xffff7743, 0xffffc693, 0x146c, - 0xffff80e3, 0xffffb207, 0xffffe58c, 0xffff8e50, 0xffffb07b, 0xfffff121, 0xffff9b54, 0x5dd4, - 0x700d, 0xffffe8a8, 0xffffdc38, 0xffffe745, 0x3734, 0x1db6, 0xffff8353, 0xffff7e3b, - 0x8eb, 0x6019, 0x2c5c, 0xffff8bd0, 0x8a7f, 0x7bc1, 0xfffff710, 0x4002, - 0x3650, 0xffffce4a, 0xffff7cce, 0xb70, 0x359a, 0x3013, 0x362, 0xffffa441, - 0x5b8e, 0xfffffe99, 0xffff7813, 0x7fdf, 0xffff8fc1, 0x5912, 0xffff8122, 0xfffff92a, - 0xffff8c22, 0x46a0, 0x5d05, 0xffffc4c0, 0xffffbc37, 0xffff9f62, 0x3103, 0xfffffb57, - 0xffffdf3b, 0xffffbde0, 0xffffe2fd, 0xffffcb24, 0x7291, 0xffffc112, 0x305d, 0x60f4, - 0xffffc8ae, 0xffff7574, 0xffffe0d9, 0xe58, 0xfffffeba, 0x66e, 0xffff8463, 0x8643, - 0xffffa427, 0x405e, 0xffffa5f5, 0xffffcb8f, 0xffffb04c, 0xffff79aa, 0x1a22, 0xffff896c, - 0xffff7d81, 0x7bda, 0x6989, 0x3996, 0x870e, 0x3a69, 0x3b4a, 0xffff9e08, - 0x2c97, 0x7ebd, 0xffffbf71, 0x1973, 0xffffdf6b, 0xffffbad9, 0x196a, 0x81e8, - 0x1c4, 0x61c5, 0x76e9, 0x25c5, 0x5131, 0xffff9e6e, 0xffff9637, 0xffff7d1a, - 0x5111, 0xffffff97, 0xffff8424, 0xffffbf3b, 0xffffb4f9, 0x2eaf, 0x7b44, 0x409e, - 0xffffe706, 0x1099, 0x328c, 0x401c, 0x2e7, 0x5b34, 0xffffd2f2, 0xffff9853, - 0xffff7804, 0xfffff344, 0xfffff283, 0x8ce9, 0xffff8fc2, 0xfffff155, 0xffffe2fe, 0xffff9d35, - 0x846f, 0xffffe3cf, 0x53f2, 0x67e4, 0xffffb405, 0xffff9c2a, 0x69a7, 0xfffff279, - 0xffffcd7b, 0xffffe05c, 0x5f40, 0x7110, 0x5c7d, 0xffffc8b4, 0xffffb97c, 0xfffffd3e, - 0x6b8f, 0xffffa8f4, 0xffffe8d7, 0xffffee7e, 0xa4e, 0xffff8a06, 0x4499, 0x65, - 0xffff9c0e, 0xffffdb63, 0xffff9123, 0x1fdb, 0x424a, 0xffffecca, 0xffffbde3, 0xb4, - 0xffffd7b7, 0xffffbb82, 0xffffa8bb, 0xffffcf0c, 0x1c1, 0xffff87e5, 0xfffff7cc, 0xffffc4dd, - 0xfffff3f1, 0x86c6, 0x3063, 0xffffbf8c, 0x2ddf, 0x7a9, 0x3d41, 0xfffff150, - 0xffff9224, 0xffffe905, 0xffffbd32, 0x76c2, 0x4021, 0xffff86cd, 0xffff895a, 0xffffd092, - 0x3b93, 0xffffbf5b, 0xffffe7f1, 0x44e, 0x7e09, 0x514f, 0xffffdae2, 0xffff8ae4, - 0xffffd626, 0x8cf6, 0xffffc1e5, 0xffff8d3e, 0xffffc16c, 0x5b5, 0xffff8d48, 0x264a, - 0x6750, 0x5f3f, 0x442e, 0xfffff88b, 0xffffe7d2, 0x73ce, 0xffffffac, 0x3302, - 0x5125, 0x590c, 0xffffe068, 0xffffb765, 0x473d, 0xffffd9cc, 0x9ae, 0x3ae0, - 0xffffdd98, 0x4346, 0xbe1, 0x506e, 0xffffe5dd, 0xffff8b4d, 0x6ac3, 0x89a1, - 0x229b, 0xffffa8bf, 0xffffb463, 0xffffb8aa, 0xffffb1bb, 0xffff8205, 0x76ba, 0x1117, - 0xffffae9e, 0xddf, 0xffffaf93, 0x1661, 0x490b, 0xffff798e, 0x4d5f, 0xffffbca8, - 0x13c4, 0x814a, 0x8340, 0xfffffe42, 0xffffc27f, 0xb42, 0xffffbeae, 0x39a3, - 0x5caa, 0xffffd38d, 0x2dba, 0xfffffe91, 0x5451, 0x768d, 0x827a, 0xffffbf93, - 0x5ff2, 0xffffeaa2, 0xffffb0fc, 0x677a, 0xffff758a, 0xffffbcc6, 0xffff9166, 0xffff9b70, - 0xffffa468, 0x36bf, 0xffffbf31, 0x2f3d, 0xffffd890, 0xfffff4af, 0x3b4b, 0xffffc047, - 0xffff98b3, 0xffffea02, 0xffff9ed7, 0x45b0, 0x8c73, 0xffffa371, 0xfffff4fa, 0xffffe309, - 0x3fce, 0x3020, 0x7e45, 0x40bb, 0x506c, 0x63a1, 0x52cd, 0xffff7a93, - 0x3108, 0xffffbf0a, 0xffffe87a, 0xffff782f, 0xffffcb8e, 0x3e37, 0x619a, 0xfffff75a, - 0xffffeb8a, 0x621f, 0xffff87fb, 0x594b, 0x70ee, 0x519c, 0xfffffa39, 0x540b, - 0xffff9ea8, 0x5321, 0xffff9ba2, 0xffff8804, 0x1049, 0x6249, 0xffffc186, 0x6915, - 0x45ba, 0xffffc569, 0x1275, 0x1141, 0xffff7d0c, 0xfffff6a0, 0xc88, 0xffffd0cf, - 0x5493, 0xffffca10, 0x8ba5, 0x5479, 0x56a5, 0xffff72c4, 0xffffc49a, 0x1f28, - 0x26e2, 0x1842, 0x5690, 0xffff8ee0, 0xffff7d53, 0x1896, 0xffffbaf2, 0x724a, - 0xffffc881, 0x2913, 0xffff8e93, 0x1318, 0x288c, 0xffff985d, 0x70ef, 0xffffaa46, - 0x114b, 0x5357, 0x36e9, 0xffff8651, 0xffffb4bb, 0xffffd3a5, 0xffffe071, 0xffffbc9d, - 0x6d70, 0xffff93f4, 0xffff939a, 0xffffbf01, 0xffff9dd5, 0x3632, 0x22dd, 0x290a, - 0xfffff94e, 0xfffffd3f, 0x240b, 0x1dd7, 0xfffff422, 0xffffedb5, 0xffffae3f, 0x3131, - 0xffffb91a, 0xff0, 0xffffa875, 0xffffc56b, 0x7819, 0x2174, 0xfffffc53, 0xfffff477, - 0x6134, 0x4655, 0x94, 0xffffd1ee, 0xffff7e80, 0xffff82ef, 0xffffff54, 0x7000, - 0x1e7c, 0xffffc0d0, 0x84a4, 0x5a2, 0xffff7ba9, 0xffffd915, 0xffff757e, 0x2b2b, - 0x2182, 0xffff9958, 0x3d0d, 0xffffe4af, 0x5c62, 0x7512, 0x4e8, 0xffffa6ed, - 0x2f28, 0xffff8ff9, 0x1a0f, 0xffffd103, 0xffff85f6, 0x69f7, 0xffffb04f, 0x41fe, - 0xffffbc7e, 0x427b, 0xffffa03e, 0xffffee6f, 0xffff9910, 0xffffa897, 0xffff7e20, 0xffffc977, - 0x266c, 0xffffd8e3, 0x3c0a, 0x22b0, 0xffff92ff, 0x1b5d, 0x24f4, 0x3bb7, - 0x425b, 0xffff90a5, 0xffffb687, 0x156d, 0x58ef, 0x1b16, 0xffffd3e1, 0x582, - 0xffffb1b1, 0x691d, 0xfffff853, 0x4c0a, 0x4887, 0xfffffa27, 0xffffbdae, 0xffff8d31, - 0xfffffdb2, 0xffffd009, 0x6287, 0xfffff1ff, 0xffffa748, 0xffffccdf, 0xffffa977, 0x16dd, - 0x281e, 0x8047, 0x66a, 0x2c5a, 0xffff86b5, 0x854a, 0x2a5a, 0x70dd, - 0xfffffeb6, 0x873f, 0xffffdd1a, 0xffffaa65, 0xffff8ca8, 0xffff83da, 0x67c9, 0x4745, - 0x1b41, 0xffffebf0, 0xffff740b, 0x30d7, 0x2afa, 0xffff761e, 0x5539, 0x23e9, - 0xffffabd8, 0xffff931a, 0x408b, 0xfffff2cb, 0x67dc, 0xffff7807, 0xffff964a, 0x5288, - 0xffffc66d, 0x2366, 0x148e, 0x38cb, 0x157f, 0xffff8346, 0xffffb678, 0xffffc4f2, - 0x1549, 0xffffcdb8, 0xffffc5b7, 0xffffd59b, 0xffffd217, 0x6f4e, 0xffffb9ba, 0x8263, - 0xfffff2df, 0xffffd860, 0xffffd9d7, 0xffff9597, 0xffffec05, 0xffff81f3, 0x8be0, 0xffffe4a7, - 0xffff85a4, 0x2fc4, 0x86e9, 0x701, 0x61d3, 0x69ff, 0xffff7563, 0xffff76ce, - 0xffffc010, 0x822f, 0xffff7b66, 0x5e31, 0xffffc663, 0xfffff119, 0x15f0, 0x85d0, - 0x28f1, 0x3fd6, 0xffffa127, 0xffff9166, 0xffffb044, 0x2e04, 0x322c, 0xffffb132, - 0xfffff73e, 0xffffb6b0, 0x3ea8, 0xffffac4d, 0x4a5b, 0xffffa5e8, 0xffff7697, 0x16e, - 0x49ca, 0x1272, 0x4a93, 0x44ce, 0x53e2, 0xfffff35b, 0xffff778a, 0xffffd189, - 0xffffb7e4, 0x90c, 0xffff8795, 0xffff96e2, 0x73ed, 0x3b2c, 0x5db2, 0xffff761f, - 0xffffdc8b, 0x4a06, 0xffffa033, 0xfc9, 0xffffe5e2, 0x7fed, 0xffffca3a, 0x218d, - 0xffffcb3d, 0x2af8, 0xffffb770, 0x8b27, 0xffffcd03, 0x8615, 0xffff7dd4, 0xffff7494, - 0x7f51, 0xffffdf3d, 0xffffbc52, 0xffffa686, 0xffffe0e6, 0xffffd409, 0xffffcd88, 0x5d0f, - 0x6c9c, 0x77ed, 0x69e2, 0x30b8, 0xffff894c, 0xffffe9c1, 0xffffa2b0, 0xffffff92, - 0xffffeecb, 0xffff7486, 0xfffff3a4, 0x4b1a, 0x15cf, 0xffffd171, 0xffffce83, 0xffffb1f3, - 0x2d8f, 0xffffa1a2, 0xffff90d0, 0x10a2, 0x4e89, 0xffff730e, 0xffffb689, 0x8bf3, - 0xffffc917, 0x3a3c, 0x28c6, 0x7a05, 0xffffc793, 0xffff944b, 0xffff8c4f, 0x13b6, - 0x6540, 0x3b3c, 0x1b68, 0xa31, 0xfffffce2, 0xffffa0f0, 0x4d63, 0xa6, - 0x290, 0xffff7f48, 0xffffb06c, 0x5986, 0xffffe2e9, 0xffffe281, 0x6fd1, 0xffff9467, - 0xffffa53c, 0xffffda9c, 0xfffffb90, 0x8a9b, 0x55f2, 0x646f, 0x517f, 0xa33, - 0x1a6, 0xffff8fda, 0xffff890b, 0xffff81f3, 0xffffaac7, 0xffffd83a, 0x7f, 0x2782, - 0x6083, 0xfffff711, 0xffffe8c7, 0x5553, 0x55b7, 0x4d1, 0x56e4, 0xffff8f89, - 0xffffbab6, 0xfffff28b, 0x232b, 0x5139, 0xbe4, 0x3b5e, 0xffffa73f, 0xffffdf16, - 0xcce, 0x5e29, 0xca2, 0xffffd78f, 0xffff861d, 0xffff8ef5, 0x63a9, 0x3d30, - 0xffffb006, 0xffffa007, 0x4596, 0x2801, 0x4936, 0x2816, 0x3f0a, 0xffff92c9, - 0x145, 0x4f85, 0x2c8, 0xc72, 0x36a8, 0xffff81cf, 0xffffeffc, 0xffffde3f, - 0xffffd5f2, 0x5692, 0x60d4, 0x4861, 0x339d, 0x6449, 0xffffdd43, 0xffff8c56, - 0xffffeb4d, 0xffff98b3, 0xfffff4cf, 0x455a, 0xffffb995, 0xffffce66, 0x1dce, 0x1f3e, - 0xffff92ea, 0xfffff303, 0x5783, 0x4aae, 0x29e6, 0xc20, 0x78b9, 0xffff878d, - 0x637, 0xffffb102, 0xffff7e5e, 0x6193, 0x5e68, 0xffffd7d8, 0x654c, 0xffffe71d, - 0xfffff721, 0x339e, 0xffff7e57, 0x5529, 0xfffffcf2, 0xffffe584, 0x26cf, 0xffffce2b, - 0xffffff6b, 0x6600, 0xffffe4e1, 0xffffb27a, 0xffff7760, 0xffff8f2d, 0xffffb0b8, 0xffffc68b, - 0x6907, 0x1110, 0xffffef9b, 0x27, 0xb8d, 0x2872, 0xffffc27e, 0x1bfd, - 0x123a, 0xffffdb77, 0xffffa828, 0x4f0a, 0x6fd6, 0xffff7358, 0xffffafee, 0xffffc050, - 0xffffc121, 0x2dc7, 0xffffe42c, 0x8dbf, 0x2698, 0x7efd, 0xffff98d6, 0xffff9eea, - 0xffffec08, 0x16a3, 0xd9f, 0x6ccb, 0xffff7e32, 0xffff7561, 0x6907, 0x651b, - 0xffff9d8d, 0xffff826f, 0x5a7e, 0x7a70, 0xffff9108, 0x54c, 0x84d0, 0x4a6e, - 0xffffc829, 0x5726, 0xffff9518, 0xffffeb06, 0xdcf, 0x143d, 0x385a, 0xffff8005, - 0xfffff2a7, 0xffffcd4e, 0xffff8b6d, 0xffffec7a, 0x536b, 0xffff8148, 0xffff7ff7, 0x3098, - 0x6fd7, 0x6a8c, 0xffff83fd, 0x52ca, 0x8cc1, 0x251c, 0x3fd6, 0xffffd96c, - 0x26de, 0x710, 0xffff9146, 0xffff9808, 0xffff790a, 0x46c7, 0xffff9cf3, 0x290d, - 0xffffe6b9, 0xffff9078, 0xffff75f7, 0x678a, 0xfffff708, 0x26f2, 0xfffff7aa, 0x583f, - 0x2e8f, 0xffffb64c, 0xffffc0bc, 0xffffa35b, 0x264a, 0xffffc82c, 0xcfc, 0x7d89, - 0x11e0, 0xffffce25, 0xffff9499, 0xffff7aa5, 0xe3c, 0xac7, 0x81c5, 0x7159, - 0x8c01, 0xb5c, 0xfffffc6c, 0xffffa6c9, 0x8249, 0x7524, 0xffff735e, 0xffffce06, - 0x10c7, 0x6334, 0xffff7b8d, 0xffffa314, 0xffffce5d, 0x4f8f, 0x3a7e, 0x277f, - 0x17b8, 0x8cd8, 0xffff9909, 0xffffc891, 0x5de9, 0xffffc012, 0x54d6, 0xffff8015, - 0xffff90d5, 0x15d, 0x703e, 0x3236, 0xffffdd2d, 0xffffca7a, 0x43c6, 0xb61, - 0x6fd2, 0x336c, 0xffff9509, 0xffffa109, 0x17f4, 0x18a4, 0x38d9, 0x6b5e, - 0xffffe932, 0x1fee, 0xffffd6a5, 0xffffeb7f, 0x5284, 0x1655, 0x15c9, 0x1fc6, - 0x6cd5, 0xffffa187, 0x60f5, 0x7248, 0xffff814d, 0xd14, 0x884e, 0xffff8616, - 0xffffab6c, 0x8c75, 0x1005, 0x57fc, 0xffff9c74, 0x84f, 0xffffb6a1, 0xffffd988, - 0xffff7530, 0x782, 0xffffa7be, 0xffff9cf5, 0x1497, 0xffffd560, 0xffffe680, 0xffffdf92, - 0x2ead, 0x8694, 0xffff9c30, 0x3b22, 0xa82, 0x1f5d, 0xffffba52, 0x5743, - 0xffffb4ee, 0xffffd01e, 0x119a, 0xffff7eff, 0x86da, 0x3771, 0xffffbc56, 0xffff89e1, - 0x483, 0xffffdbd8, 0xffffc090, 0x225, 0xac3, 0x4c86, 0x26f7, 0xfffff1fa, - 0xffff76a6, 0x2bb6, 0x6553, 0xffffb0ba, 0x1b0e, 0x4f6f, 0xffffc8f3, 0x787f, - 0x8416, 0x392, 0x18cd, 0xffff8c51, 0xffffb50d, 0xfffff2e8, 0x74bb, 0xffffc84a, - 0xffffca8d, 0xffff8508, 0xfffff79a, 0x5867, 0xffffbde9, 0xffffc76c, 0x5966, 0xffffa1a3, - 0x3ef6, 0xffffaf76, 0xffffb2a6, 0x62b4, 0xffffaf21, 0x1f61, 0xffff8de2, 0x6ae4, - 0x1711, 0x2848, 0xffffc6e4, 0xfffff285, 0xffffce37, 0xfffff33d, 0x10fa, 0x14a2, - 0x8c4b, 0x56d5, 0x6170, 0x2ce9, 0x10d8, 0x350e, 0x3e1e, 0xffffa4e0, - 0x5090, 0x8035, 0x43bb, 0xffffc129, 0x1cdb, 0x7cf4, 0x5897, 0xffffe38a, - 0xfffffda4, 0xffff8f8f, 0x1711, 0x73fe, 0x641b, 0x24f7, 0x53da, 0x3e9d, - 0xffffdd78, 0xffff857b, 0x34e7, 0x7881, 0xffffecc8, 0x80b8, 0xffffd388, 0xffffe600, - 0xffffea29, 0xffffecc9, 0xffff8b09, 0xfffffb67, 0xffffa4ea, 0x6e11, 0x631b, 0x332, - 0xffffcdfd, 0x1236, 0xaf1, 0x720, 0x2ab7, 0xffffa89c, 0xffffeab4, 0x65c1, - 0xffffff40, 0x203b, 0x2c2, 0x4c30, 0xffff94df, 0xffffe58b, 0x71fa, 0xffff8350, - 0xffff888f, 0x33d, 0xffffa878, 0x3d07, 0x199c, 0x644b, 0x5d3d, 0x2c5, - 0x783b, 0x855d, 0xfffffe0f, 0x29cf, 0x4bcf, 0x2631, 0xfffff8a4, 0xffffdd94, - 0x1d61, 0xfffffafc, 0xffff7e05, 0x24a0, 0xffff8a5a, 0x262a, 0x5c5b, 0x229f, - 0xffffe6a8, 0xffffcde6, 0xffffa684, 0x178, 0x37cf, 0x534, 0x190a, 0x86d9, - 0xffffd70b, 0xdf9, 0x8a0d, 0x7218, 0xfffff793, 0x420e, 0xffffa733, 0x811f, - 0xffffa1b0, 0x8cfc, 0xffffb39f, 0xffffb277, 0x8c8d, 0x188, 0x4b59, 0x660c, - 0xffffc5c1, 0xffffc2c9, 0xffffe996, 0x2fd7, 0x1650, 0x6209, 0xffffa6a9, 0x4c28, - 0x7291, 0x587e, 0x4ef5, 0xffffaa02, 0xffffb81c, 0xc34, 0xffff79d4, 0xbe0, - 0x6bc9, 0x49c7, 0xffffb6eb, 0x120a, 0x455f, 0xffffa242, 0x19e1, 0x5b62, - 0x5cec, 0xffff8be5, 0xfffff857, 0xffffc764, 0xa02, 0xffff8856, 0x702c, 0xffff7b18, - 0xffff85d1, 0xdb3, 0x6296, 0x3ef2, 0x55a0, 0xffffe47a, 0x3213, 0xffffdcb1, - 0x2a00, 0x2c6d, 0xfffff530, 0x77d2, 0xfffff051, 0xffff82cc, 0xffffe0f7, 0x603e, - 0xffffcdcf, 0x3ee8, 0xffff9788, 0x4ee3, 0xffff8a08, 0x44d7, 0xffffae63, 0xffffa7bc, - 0x151e, 0x5de1, 0xffffe129, 0x7ec1, 0xffff82e1, 0x7a8a, 0xffff7c0f, 0x866a, - 0x1c48, 0x63fd, 0xfffffdf7, 0x681d, 0xffffeb26, 0x6d6c, 0xfffff7b5, 0x63e, - 0xffffcbab, 0xffffedcd, 0xffffe5d6, 0x4967, 0x834b, 0x28eb, 0x6365, 0x7e4b, - 0xffffd7aa, 0xffff759e, 0x5cad, 0x22f6, 0xffffa019, 0xffff7a60, 0xffffb158, 0xffff9830, - 0xffff88fa, 0x5381, 0xffff9edf, 0xffffb70e, 0xffffb5e0, 0x28b9, 0xffffd778, 0x4aa9, - 0x1029, 0x4de8, 0x85a, 0xffffa5af, 0xffff9598, 0x694a, 0x442f, 0xffffc325, - 0x1646, 0x40b4, 0x51b0, 0x50c4, 0xfffff810, 0x6afc, 0x1611, 0x7c33, - 0x2c36, 0xffffadd9, 0xffffff75, 0xffffa472, 0x2a6f, 0x1ea3, 0x5389, 0x42ec, - 0xffff7734, 0x10df, 0x7e19, 0xffffbe25, 0x45dc, 0x52d1, 0xffff7b84, 0xfffff9d9, - 0x202c, 0x6f8c, 0xffff96b0, 0x4581, 0x13a9, 0x7c2c, 0x2c73, 0x456a, - 0xffff90d7, 0xffff918e, 0x4daf, 0xffff883f, 0x292d, 0xffffd140, 0x4599, 0x7022, - 0x6e51, 0x6fd8, 0xffffcc81, 0x55a, 0xffffb012, 0xffff8234, 0xffff8e12, 0xffff866e, - 0xffff82ab, 0x3a12, 0x77f1, 0xffff8e5c, 0xffffb9db, 0x8114, 0xffffb4d1, 0xffffaa27, - 0xffffef2b, 0x512b, 0xfffff599, 0x2614, 0xffffec61, 0x2e53, 0xffffe14a, 0x8762, - 0x15ea, 0xffffa04a, 0xa9c, 0x3db3, 0xffff9da7, 0x1ba7, 0x6f1, 0x7046, - 0x40d8, 0x2807, 0xfffff498, 0x4003, 0xb8b, 0x80d9, 0xffffc968, 0xffffb091, - 0x6a11, 0x575d, 0xffffbd30, 0x59b7, 0xffffec68, 0x3bc3, 0xffff9852, 0x8d97, - 0x3bdd, 0xffff7b05, 0x3a08, 0x796a, 0xffffde73, 0x23d7, 0xffff937c, 0xffff8364, - 0x2c86, 0xfffff529, 0xffffb941, 0x4f9f, 0x300a, 0xffffb69a, 0xffff8ae2, 0xffff76f4, - 0x6281, 0xffff7a7f, 0xffff8cae, 0x6a9b, 0xffffc3e3, 0x6b24, 0x1a7f, 0xffffbbaa, - 0xffff9898, 0xfffff100, 0xffff9a77, 0xfffffeb5, 0x8062, 0x26f6, 0x72a6, 0x82a8, - 0xffff8d48, 0xffffad0b, 0xffff78ed, 0x39d9, 0xffff8cbd, 0xffffe4fb, 0xffff73d3, 0xffff8749, - 0xffff7787, 0x186d, 0xffff8a66, 0xffffd430, 0x675d, 0x6208, 0x1e0a, 0xffffd207, - 0x7627, 0x272d, 0xffffe162, 0xffff7f78, 0xffff97cd, 0xffffe52f, 0xffff9648, 0xffffbde7, - 0x4a2, 0xffffab13, 0x408e, 0xffffaf5a, 0xfffffccf, 0xffffcaee, 0x3ce9, 0xffff9f86, - 0xffffbdf6, 0x6f7d, 0x1ac0, 0xffff7d8f, 0xffffb5f4, 0x15d5, 0xffffb317, 0xffff8d69, - 0xffffd179, 0xffff9256, 0xffffaed4, 0xfffffd69, 0xffffe67c, 0x8a5d, 0xffffb985, 0x7bd5, - 0x1eaa, 0xffff7ea6, 0x7a6, 0xffffcc73, 0x45fe, 0xffff9312, 0xffff8963, 0xffffcd75, - 0x3534, 0x29af, 0xffffa890, 0xffff81d1, 0x3c3a, 0xffffcbc4, 0x43ba, 0x320c, - 0x70c6, 0x2ec5, 0x189d, 0xffff768f, 0xfffffcf4, 0x3ea8, 0x8212, 0xffffabef, - 0xffffc162, 0x22d4, 0x5755, 0xffffc5a0, 0x87f4, 0xffffb7da, 0xffffa9f3, 0x6eb4, - 0x1abc, 0x5caf, 0x3043, 0x4be4, 0x557b, 0x18e5, 0x2499, 0x7f, - 0xffffcd2d, 0xffffd93e, 0x3af4, 0xffff8c49, 0xffffc5a9, 0xffffb1ba, 0xffff9c0c, 0x18ba, - 0x2cbe, 0xffff8efc, 0xffffa34b, 0x3b05, 0x49d, 0xffffe7b4, 0xffffd9de, 0xfffff909, - 0x5f8, 0x3651, 0xffff7d02, 0x5eda, 0xffffb6f3, 0xffffaa6d, 0x201e, 0xffffc0d0, - 0xd3c, 0x11dd, 0x8c01, 0xfffff81f, 0x84fb, 0xffffe312, 0x7cdc, 0x6d33, - 0xffff8b40, 0x79af, 0xfffff0d5, 0xffffe4ee, 0x73a8, 0x20e6, 0xffff927f, 0x8592, - 0xffffb092, 0x5012, 0x76b, 0xffffa971, 0x8ba1, 0xffffb512, 0x22f3, 0x8ae3, - 0x4217, 0x70e6, 0xffff8854, 0xffffa794, 0x69dd, 0xffffea58, 0x30f6, 0xffffa42d, - 0xffff9908, 0x5e1e, 0x2fd4, 0x329, 0x775a, 0xffff95b2, 0xffffa71e, 0xde7, - 0x2e22, 0x776e, 0x16d4, 0xffff8616, 0xffffb167, 0xffff85b5, 0x57da, 0x72eb, - 0xffffbaf7, 0xffffc299, 0x59ef, 0xfae, 0x1907, 0x4adb, 0x7242, 0x5bd3, - 0x189e, 0x5ad4, 0xffff8e3c, 0xffffedaa, 0xbe0, 0xffffffdc, 0xd45, 0x2ef8, - 0xffff7cd2, 0xffffaddd, 0x685a, 0x832e, 0xffffcf75, 0xffffd4dd, 0xbd6, 0x149f, - 0x3cdb, 0x7691, 0xffffc1e2, 0xffffa1c4, 0x7548, 0xffffa014, 0xffffe53b, 0xfffff6f1, - 0xffffeecb, 0xffffa681, 0xffffafc8, 0x6811, 0x875b, 0x1578, 0xffffdcbe, 0xffff8206, - 0x483f, 0xffff7c5c, 0xffffbf83, 0x2b71, 0x7789, 0xffff733b, 0xffffe5d4, 0x5b88, - 0x7751, 0xffffc109, 0x4a86, 0x7284, 0x67d8, 0x28d4, 0xffffa41e, 0xffff7baf, - 0x761d, 0xffffff5a, 0x3e9e, 0x4e25, 0x2a7a, 0xfffff846, 0xffff873f, 0x43a9, - 0xffffeeea, 0xffff840b, 0x716f, 0xffffacf0, 0x5da3, 0xffffb902, 0xffffaf05, 0x4b57, - 0x73da, 0xffff956d, 0x4cf1, 0x7716, 0x33dd, 0x464, 0xffffeb6c, 0x4007, - 0xfffff3b4, 0x1fe3, 0x721, 0xffffe758, 0xffffabb3, 0x19d8, 0xffffbc97, 0xffff751d, - 0x7cc7, 0xffffb5e3, 0xffff8625, 0x8590, 0xffff8fb2, 0x168b, 0x8a88, 0x5368, - 0x7a0a, 0xffffff50, 0xffff7c26, 0x2c26, 0x5a95, 0xffffd991, 0x19e2, 0xffff7a6d, - 0x3e4b, 0x2e49, 0x4b7a, 0xffffcaf0, 0xffffff91, 0x1fc2, 0x4ed5, 0xfffff2a5, - 0xffffcc85, 0x52ac, 0xffffcef3, 0x13ae, 0xffff7590, 0x4c03, 0x860a, 0x1715, - 0xfffff3b6, 0x3e42, 0xec, 0x5e30, 0x7f7b, 0xffff8325, 0xffffcc59, 0x3c5a, - 0x1730, 0xffff84b9, 0x543c, 0xffffc431, 0x210c, 0xffffff67, 0x3247, 0x78fa, - 0x6646, 0xffffb35a, 0xffffebe6, 0x74d8, 0xffff7d83, 0x696b, 0x2502, 0xffff898c, - 0xffffa4a3, 0xffffe1a7, 0xffffd2c6, 0xfffff1db, 0x8425, 0x4794, 0xfffff992, 0x5bec, - 0xffff999e, 0x4e2, 0xffffa80f, 0xffffee33, 0x6505, 0xfffffe03, 0xffffb529, 0x14ad, - 0xffff8511, 0xffffd437, 0xffffd6f4, 0xffffa716, 0x6fbe, 0xffffb2c5, 0x28fb, 0x9a7, - 0xffff72d3, 0xffffe490, 0x7ad4, 0x534e, 0x883e, 0x69a3, 0xffff9ebc, 0x36c1, - 0x3ac1, 0x8cc2, 0x4363, 0xffff980d, 0x42a1, 0xffff94ce, 0x7fa5, 0x59d0, - 0x2d35, 0xffffaddc, 0xffffc82e, 0x679d, 0xffffff04, 0xfffff390, 0x75c1, 0xfffff28e, - 0xffff8261, 0x7609, 0x6cc6, 0xffffeb00, 0xffffcdb1, 0xffff97c2, 0x2ec8, 0x7a4d, - 0x5a53, 0x4a2b, 0xfffff160, 0xffff7c7e, 0x8af1, 0xffffa8aa, 0x8a2, 0xffffd8c4, - 0x15e7, 0xffffa490, 0x35bb, 0x3846, 0x8b8f, 0xfffff39f, 0x115f, 0x26ed, - 0x3580, 0xffffdd48, 0xffff763b, 0xffffa8ec, 0xc2d, 0x7e4, 0x73c, 0xffffec28, - 0xffffb1ff, 0xffffd69c, 0xecc, 0xffff8a47, 0x1570, 0x5278, 0x7478, 0xffffa96c, - 0x87f7, 0x6c6d, 0xffff9c2a, 0x3e44, 0x4451, 0xffffe66f, 0x77a7, 0xffffa196, - 0xfffff4c8, 0x4d8, 0xffffda98, 0xffffb107, 0xffffe5f6, 0xffffd073, 0xfffffb60, 0xffffd970, - 0x7134, 0x1b66, 0xfffffed6, 0xfffffffb, 0x2f5d, 0xffffc33f, 0xffffb63a, 0x17aa, - 0xffffb6c7, 0xffffb5dd, 0x9a7, 0xffffb6ee, 0xffffce02, 0x4f50, 0xefc, 0xffffe4de, - 0xffff9e9b, 0xffffd397, 0xffffabfb, 0x771d, 0x7313, 0xffff8f5d, 0xbc, 0xffffa767, - 0xffff7a43, 0x1a04, 0x7e99, 0x5029, 0x2c61, 0xffffcf61, 0x6e6f, 0xffff8786, - 0x832e, 0xfffff079, 0x76f0, 0x6720, 0xb72, 0xffffc9bb, 0xffffb384, 0x8b40, - 0x4f6f, 0xffff9c0e, 0xffff7248, 0x8721, 0xffffb61c, 0x3264, 0x4af3, 0x26fa, - 0xffff78cb, 0x3f99, 0x519b, 0x3d38, 0xffff9e3c, 0x6363, 0xfffff082, 0x61, - 0x80e3, 0x882c, 0x1ad9, 0xfffff42c, 0xffffe5d7, 0xffff78aa, 0x7f81, 0x6333, - 0xe4b, 0x99, 0xfffff37c, 0xffffd8b0, 0x5f1f, 0xffffa399, 0x2fe4, 0x413f, - 0x2fb, 0x2d48, 0xffff9550, 0xffffd960, 0x8c72, 0xffff83f3, 0x3d50, 0x85ec, - 0xffffb965, 0x1cdd, 0xffff8626, 0xffffa6c0, 0xffffa058, 0xffffb314, 0x77c1, 0xffffa6dc, - 0x73d6, 0xffffbbbb, 0xfffffbf9, 0xffffcf13, 0xffffd10c, 0x8c3e, 0x5f5c, 0x4af5, - 0xffffd141, 0xffffd407, 0xffffc119, 0xffff86b0, 0xffffb16c, 0xfffff4f1, 0x404a, 0x6bab, - 0xffff9021, 0xffffd5f5, 0xffff87b0, 0xfffffb85, 0xffffbc33, 0x3ef, 0x16dd, 0xfffffc0a, - 0x346, 0xf7b, 0xffffb212, 0xffffe5b9, 0x1c45, 0x5a37, 0xffff8f95, 0xffffccda, - 0x11d2, 0xffff74a0, 0x52c1, 0xfffff70b, 0xffff90dd, 0x5ab1, 0x3ecb, 0x70d0, - 0x8ac4, 0xedb, 0x1091, 0xffff874d, 0xffffdce4, 0x4603, 0x157f, 0x4db, - 0xffffb596, 0x5604, 0xffff7a31, 0xffffe7e6, 0x3bc2, 0x1ec0, 0x861, 0xffffbb57, - 0xfffff94b, 0xffff9fb4, 0xffffea52, 0xfffff479, 0xffff9909, 0xffffa95f, 0xffffa074, 0x8889, - 0x198b, 0x56f4, 0x3423, 0x8241, 0xffffe3ff, 0xffff881a, 0x4e97, 0xffffcf1b, - 0xffffa603, 0x3957, 0xfffff6d5, 0xfffff0b2, 0x8464, 0x1f13, 0xffffe04e, 0x3ed2, - 0x1636, 0x19df, 0xffff9d9c, 0xffffb4af, 0xffff764e, 0x787f, 0x42a6, 0xffffda01, - 0x5a29, 0x8d78, 0x5fae, 0xffffe92e, 0xfffff130, 0x7c51, 0xffffbf50, 0xffffb867, - 0x2ddf, 0xffffb349, 0xffffd0e9, 0x6b0b, 0x6d50, 0xffffd468, 0xffffa3b0, 0xffff97d8, - 0x1960, 0xffffdbbb, 0xffffa4af, 0xffffbd37, 0x2ef3, 0x2437, 0xffffd17e, 0x13e5, - 0x54e0, 0xffffc59f, 0x22bb, 0xffff780f, 0x6239, 0xffff7d96, 0xffffda9d, 0x6e34, - 0xfffface6, 0x295a, 0x2719, 0xffffda03, 0xffffabc0, 0x23a3, 0x1cf2, 0xffffaa50, - 0xfffff1aa, 0x6565, 0x75b1, 0xffffc795, 0xffffb3d6, 0xffffac07, 0xffff8ab8, 0xffffe135, - 0x6be2, 0xffff9a21, 0x66be, 0x1ede, 0xffff9b45, 0xffffddb2, 0x19d9, 0xffff9a42, - 0x1470, 0xfffffd5c, 0x1e7e, 0x6407, 0x6ab4, 0x9cd, 0x1ce7, 0x7246, - 0xffffcc0e, 0x334a, 0x8d32, 0xffffdd26, 0xffff876d, 0x5f42, 0xffffce4d, 0x746f, - 0x23a2, 0xffffbddd, 0x1b98, 0xffffc9e3, 0xffff921c, 0xffffb30e, 0x3477, 0xffffa587, - 0x4067, 0x18a0, 0x361e, 0xffd, 0xffff880f, 0xffffef9a, 0xffffce51, 0x3ed, - 0x139b, 0x4957, 0xffffc1b0, 0x5718, 0x4e72, 0x898c, 0x1e76, 0xfffffc63, - 0x5a7e, 0x3388, 0xffff8b15, 0x8c3, 0x42ed, 0xffff9b9a, 0x1fff, 0xfffff544, - 0x66a4, 0xffff7c9f, 0xf3d, 0x8823, 0xffffab00, 0x8d96, 0xffff9a08, 0x16d3, - 0x55a3, 0xffffc3a3, 0x5f6e, 0xffffa6c2, 0xffff982e, 0xffffe233, 0x3b85, 0x4b3b, - 0xfffff53f, 0x31d2, 0x58f0, 0x8345, 0xffffb052, 0x8516, 0x1013, 0x3e91, - 0xffffdf3d, 0xffffb256, 0xffff8937, 0x7307, 0x6544, 0xffff9898, 0x26fc, 0x7aaa, - 0x5d8c, 0x45c4, 0x8168, 0xffffe0d2, 0xffffa15f, 0xffff8c32, 0x23e2, 0x2f6d, - 0x4e73, 0x5b19, 0xfffff7a0, 0x1530, 0x8a57, 0x5994, 0x7668, 0x8658, - 0x7810, 0x5ae5, 0xffffdd59, 0xffffe2e3, 0x6ade, 0xffff84ab, 0x2286, 0x3324, - 0x34d6, 0x6fa3, 0xffff9c8c, 0x1649, 0xffff9152, 0xffffde80, 0x140c, 0xffffe31f, - 0xffffab3a, 0x85b6, 0x870d, 0x21cd, 0x33ee, 0xffff8aa8, 0xffffcb20, 0x584, - 0xffffcdb5, 0x4b6c, 0x4b54, 0x559c, 0xffffc9b9, 0xffffc227, 0xffff93ec, 0xffffaf9c, - 0x2314, 0x4cd1, 0xffff9b8a, 0xffffa7f7, 0xffffe946, 0x6412, 0x8698, 0xfffff049, - 0xffffe24f, 0xffffbc02, 0xfffff5dc, 0x248b, 0xffffa1a1, 0xfffff591, 0x17f8, 0x7c7f, - 0x2a38, 0xffffc4b7, 0x50f4, 0x4567, 0xffffe9b3, 0x1139, 0xffffdc63, 0xffffaf43, - 0xffff921e, 0x38b5, 0x6f7c, 0x7e35, 0x4cb7, 0xffffdbdb, 0xfffffc86, 0x14e0, - 0xffffb500, 0xffff8fd7, 0xffffc44e, 0xffffe8ae, 0x615, 0x73de, 0x513c, 0xffff8c2d, - 0xffffa65e, 0x733b, 0xffffaa1a, 0xffff9823, 0x390f, 0x81e5, 0x6388, 0x2547, - 0x618c, 0xffffc2b5, 0xfe5, 0x61cf, 0xffff8162, 0xffff8c51, 0x8872, 0x5eae, - 0x5a61, 0xffffab35, 0xffff790b, 0xffff894f, 0xffff7e7f, 0x2ef3, 0xffffa954, 0xffff94a3, - 0xffffec89, 0xffffe3e7, 0x886c, 0xffff9f5c, 0x6429, 0x5828, 0xffffb33b, 0x38d4, - 0x3fb6, 0xffffe5df, 0x5e4, 0xffffa316, 0xffffdea1, 0xffffefe5, 0xbb0, 0xf7c, - 0xfffff415, 0x7f2, 0xfffff4ab, 0x8d31, 0xffffb9b1, 0xffffbbdd, 0xffffc868, 0xfffff245, - 0xffff91ae, 0x62db, 0xffffd076, 0xffffc4c5, 0x5575, 0x43af, 0xffffe6f3, 0x7cc1, - 0x6c8b, 0xffffb56c, 0xffffe101, 0xfffffe07, 0xffff8a88, 0xffff9931, 0xfffff933, 0xffffd4bd, - 0x355e, 0xffffd3df, 0x1e2d, 0x5b90, 0x6ce5, 0xffffff81, 0x5d0e, 0x514b, - 0xffffa086, 0x1caf, 0x300d, 0xffffc1e2, 0x357c, 0x2820, 0x4be, 0xffff9c0b, - 0x2e68, 0xffffb03b, 0x8ab1, 0x2aed, 0x3cc8, 0xffffa250, 0xffffca57, 0xffff8fe0, - 0xffffbc0e, 0xffffa87c, 0x3681, 0xffffff03, 0x6f96, 0xfffff6e8, 0x3818, 0xffff91eb, - 0x460a, 0xffffc57c, 0x23bf, 0xffffa010, 0x6ae0, 0x38fa, 0x6c95, 0xffffe509, - 0x2594, 0xffff892e, 0xffffd6fd, 0x4dbf, 0xffff7bca, 0x595b, 0x5265, 0xffff722c, - 0xffff9bbe, 0x6f1b, 0xffffa0d6, 0xffffb61d, 0xfffff32c, 0xac6, 0xffff8448, 0x37b3, - 0xffffb59c, 0x6132, 0xffff820a, 0xffffb87e, 0x7e80, 0xffffddb7, 0xffff84db, 0xffff868b, - 0x1498, 0x5ece, 0x4761, 0xffffbe71, 0xffff7b6f, 0x2492, 0x6b0e, 0xfffffcba, - 0xa45, 0xd5d, 0x361d, 0xf45, 0x82fe, 0xffffd7cf, 0xffffc64e, 0xffff8ad6, - 0xffffb43b, 0xfffff00e, 0xffff7b5b, 0xffff9858, 0x3756, 0xffffe97b, 0x6167, 0x52b9, - 0xfffffc14, 0x4bf6, 0x2c11, 0x5c7b, 0x75fc, 0xfffff1b7, 0x47f4, 0xffffc8ca, - 0x5fbc, 0xc3f, 0xffff9e06, 0xffffb109, 0xffff791e, 0x6661, 0x8942, 0xffff92b4, - 0xd4f, 0x15a8, 0x625d, 0x3878, 0xffff9a70, 0x636b, 0xffffad1a, 0xfffffc36, - 0x1abe, 0xfffff303, 0x4b0a, 0xffffe7cc, 0xffff904c, 0xffffe288, 0x5acd, 0xfffff71e, - 0x3252, 0xce1, 0x2db2, 0xffffc97a, 0xfffff8e7, 0xffffbb28, 0x7a7d, 0x6ed5, - 0xffffae7d, 0x8dbe, 0xffff744e, 0xffff8e03, 0x6cb, 0x86a7, 0xffffdc22, 0xffffd8fb, - 0xffffd18d, 0x4626, 0x8c87, 0xffffc3ae, 0xffffb882, 0x689a, 0x3791, 0xffffc0a0, - 0x7223, 0x3c, 0x8fe, 0xffff9ecf, 0xffffd89a, 0xffff7e2d, 0xffffa145, 0x56e7, - 0xfffffb34, 0x480c, 0xffffb7b6, 0x4d54, 0xffffc5f6, 0xffffde25, 0x4d3e, 0x7302, - 0xffffdb67, 0x4fb7, 0xfffffb02, 0x8765, 0xffffab7b, 0xda7, 0xffffb04f, 0xffffc9e5, - 0x15b6, 0x2718, 0xffffc98c, 0xffffe2eb, 0x8011, 0x8b74, 0x7aa7, 0xa1a, - 0x5d48, 0xffff9ffa, 0x1d7, 0xffffef63, 0xffff9746, 0x7c5b, 0xffff816e, 0x6c68, - 0x156f, 0x85b8, 0x16bc, 0xffffc689, 0xffff8006, 0xffffe2ec, 0xfffff102, 0xffffeb7d, - 0x8956, 0xfffff640, 0x4713, 0x7bad, 0x41bb, 0xffff9f79, 0x3691, 0xffff7b9d, - 0x7ca6, 0x5c98, 0x81e4, 0xffff9084, 0x7825, 0x543a, 0xffff8b4b, 0xffffd2f9, - 0xffff7f0a, 0xffff7655, 0x665e, 0xffffd3df, 0xffff8b05, 0x2da3, 0x2c10, 0x4dcf, - 0x23e0, 0x4e27, 0x5fb6, 0x82f3, 0xffffe5cb, 0x6d98, 0xffff9691, 0xa4a, - 0x3f51, 0x2573, 0x894c, 0xffff8107, 0x5091, 0xffffe034, 0x83db, 0x2029, - 0xffff8d63, 0x6ee6, 0xffff92d2, 0xfffffe7e, 0x5f72, 0x6704, 0xffffd1f6, 0x4d40, - 0xffffb1f6, 0x2766, 0x4b84, 0x7e47, 0x728a, 0x51f7, 0xffff9a48, 0x1149, - 0xffffc964, 0x456f, 0xffffa797, 0x6112, 0xffff7e4c, 0xffffea92, 0x8a8b, 0xffffc9bf, - 0xffffbc0c, 0x6591, 0xffffd69c, 0xffffe54f, 0xffff7adb, 0x581b, 0xffffad1f, 0xffff9607, - 0x3e51, 0xffffe644, 0x80a4, 0x272e, 0xffffd8d5, 0x4c15, 0x639a, 0x7345, - 0xffff7d10, 0x1f97, 0xffffe213, 0xffffcd19, 0xffffb907, 0x7196, 0x348c, 0xffffcd02, - 0xffffc4b0, 0xfffff3d3, 0x56d5, 0xffff7712, 0x2415, 0x19c9, 0xffffaa34, 0x5be0, - 0xffffbe3d, 0x3edb, 0xffff7ba6, 0xffff8704, 0xffff9b22, 0xffff7398, 0x1ad2, 0x2b12, - 0xfffffa9e, 0x82a0, 0x289f, 0x20c1, 0xffffa302, 0xffff8bac, 0x5528, 0x5b36, - 0xffff9f0e, 0x300, 0x76ab, 0xe31, 0x54dc, 0x14c2, 0xfffff3f7, 0xffff9727, - 0xffffb8a1, 0xfffffd6c, 0x668c, 0x12ce, 0x5e2b, 0x837f, 0x79d9, 0xffff9f2c, - 0xffffe8c0, 0x5569, 0xffffa931, 0xffff9828, 0x5447, 0xe70, 0xffffc612, 0xffffbdc8, - 0xffff8100, 0xffff948f, 0xffffd762, 0x165, 0x7caf, 0xffffe5ba, 0xffffd76a, 0x1b3f, - 0xffffbace, 0x75b9, 0x266, 0x3be3, 0xffffb139, 0xffffdf94, 0x2528, 0xffff85e5, - 0x63ec, 0xffffea79, 0x784, 0x12c5, 0xffffcf6d, 0xffff941e, 0xffffd6c0, 0xffffe17c, - 0xffffde73, 0x317d, 0xffff7430, 0x2eea, 0x2d4d, 0xffff7937, 0xfffffb7c, 0xffff802d, - 0xffff902a, 0xfffff7d6, 0xffffbdb7, 0xffffdf44, 0xffffd10a, 0xffffc6a9, 0x36fe, 0xffffc98c, - 0xffff732c, 0xffffe42e, 0xffffd1e4, 0x6c5e, 0xffffa8ab, 0x7624, 0xffffdd12, 0xffffaf68, - 0x4d98, 0x5f15, 0x865d, 0xffff8d23, 0x5266, 0x276c, 0x295e, 0x1d29, - 0x5e0b, 0x772f, 0x2942, 0x459e, 0xffffe4eb, 0xffff73dd, 0xffffd004, 0xffff886f, - 0xffffcaf9, 0x18e0, 0xc66, 0xffffd08d, 0xffff7a9f, 0xffffd290, 0x88d8, 0xffff7c4b, - 0xffff86dd, 0xe4c, 0x15ef, 0xffff99f5, 0xffffde0e, 0x44db, 0x6855, 0x29de, - 0x3458, 0xffffc7a8, 0xffffdc32, 0xffffb3ec, 0x6e1b, 0xffff8dfd, 0x86a6, 0x685d, - 0xffffee8d, 0xffff92e9, 0xffffc182, 0xfffff271, 0x39d5, 0xffff86a2, 0xffff7472, 0xffffecba, - 0xffffd44d, 0xffff7fef, 0xffffd860, 0xffffeb6d, 0x3822, 0xffff91b2, 0xffffe1ea, 0x657f, - 0xffff98be, 0x7c56, 0xffffe379, 0x1286, 0xfffff440, 0xffffefd4, 0xffffc00c, 0xffffef9d, - 0xffffbb0a, 0xffffe423, 0x717a, 0xffff8177, 0xffffc56c, 0xffff87c0, 0x389, 0xffffbd6f, - 0x6a85, 0x6072, 0xffff8991, 0x6768, 0xffffb310, 0x55a0, 0x3566, 0xffffa763, - 0x6ad8, 0xffffecf0, 0x6e47, 0x460f, 0xffff74c3, 0xffffa827, 0xffff8ed2, 0x63a8, - 0x6785, 0xffff9ab6, 0x8721, 0xffffb48d, 0xffff8e1d, 0x1b24, 0x4cad, 0x32a8, - 0xffffa063, 0x3cc6, 0x3f51, 0x27c7, 0x32e2, 0xffff9cf7, 0xffffeca9, 0x6a39, - 0x58fa, 0x305d, 0xffffb237, 0xffff8301, 0x2b29, 0x4d40, 0xbfb, 0xffffea6f, - 0x15a1, 0xffffcc4f, 0xffffc735, 0xffffdaca, 0x26e5, 0xffff9e2f, 0xffffc05a, 0xffff8cf2, - 0x7a37, 0x4531, 0xfffffa02, 0xffffb210, 0x8633, 0x4f0f, 0x754, 0xffffed54, - 0xffff8740, 0x59d2, 0xffff767e, 0xffff855a, 0x3d85, 0x71b9, 0x72cd, 0x4d3b, - 0x78a1, 0xffffa6c1, 0x6c3e, 0xffff9317, 0x2926, 0x119a, 0x44d2, 0xffffb033, - 0xffff935e, 0xffffc224, 0x4ba1, 0xffffdba2, 0xffffb9b7, 0x17e4, 0xffff8b75, 0x2f37, - 0xffff73b2, 0xffffcc5c, 0xffff88bc, 0x213a, 0x47b0, 0x13d5, 0x3ca1, 0x51a7, - 0x2e56, 0xffffc38a, 0x7f7a, 0xffffe80b, 0xffff8832, 0x7270, 0xffff8f10, 0xffff7ca1, - 0x6c56, 0x8390, 0xffffb0bf, 0xffff9200, 0x6bbb, 0x46c8, 0xfffff4db, 0x2ab3, - 0xffffa2c1, 0x7288, 0xfffff4a6, 0x5ec3, 0x7c3, 0xffff81af, 0x3cc2, 0x28f7, - 0x4a58, 0xfffff026, 0x7ff0, 0xfffffc62, 0xffff9148, 0xd8f, 0x185, 0x59f4, - 0x1caa, 0x39dd, 0x3787, 0x4a31, 0xffffed74, 0x4336, 0xffffa9ea, 0x4646, - 0xffffd6f7, 0x175a, 0xffffe833, 0xffff95e8, 0xffff79ef, 0x7509, 0x68b8, 0x5445, - 0xffffe6a9, 0x49e4, 0xee4, 0x5e83, 0xffff9812, 0xffff9b80, 0xffffcd5b, 0xffff905e, - 0x6959, 0x38cf, 0xffffbce0, 0x758b, 0x3d88, 0xffffc47d, 0xffff86ca, 0x1c6a, - 0x10f2, 0x2934, 0xffffeb47, 0xffffa621, 0xfffff453, 0x8822, 0xffffd84d, 0x88a8, - 0xffff7738, 0x2211, 0x278b, 0xffffb4fd, 0x4a25, 0x24a1, 0xffff9982, 0x4316, - 0x1f4, 0xffffec51, 0xffffaf4d, 0xfffff10f, 0x452d, 0xffffed98, 0xffff89e2, 0xffff9770, - 0xffff7393, 0x2e9a, 0xffffa805, 0x870c, 0xffffb79d, 0xffffdcb9, 0x190f, 0xffffaf36, - 0xffffae0b, 0x35a8, 0xffffcb81, 0x49b6, 0x5b81, 0xffffad9f, 0x4b00, 0x59f6, - 0xbcf, 0x2bf6, 0xffff83b9, 0x56a, 0x478b, 0xfffff9a6, 0xffffefb1, 0xd52, - 0xffff977e, 0xfffffde7, 0x2281, 0x486b, 0xffff7a45, 0x38, 0xffffa31e, 0x545b, - 0x5f67, 0x759e, 0x7227, 0x4710, 0xffffda15, 0xffffde83, 0xffffb16f, 0x445a, - 0xffffb2a9, 0xffffe77a, 0x8ff, 0x136f, 0xffffaa07, 0xffff739c, 0x16f8, 0xffffd05a, - 0x1bc1, 0xffffbd49, 0x6534, 0xffff8187, 0x30d6, 0xffff7c5a, 0x8038, 0xffffc927, - 0x81d3, 0x6e7, 0x7d71, 0x5eed, 0x2dbc, 0x7779, 0x49d9, 0xffffa59c, - 0xffff7c2e, 0xffff7a46, 0x1461, 0xffffcbc6, 0x47cd, 0x6df4, 0xffff9c8b, 0xffffba56, - 0xffffc1aa, 0xffffe2c4, 0xffffb8b3, 0x354f, 0xffffba6f, 0x7e32, 0x88d2, 0x1dda, - 0x65c3, 0xffff7a23, 0xffffa941, 0x772d, 0xffffa8e4, 0x6cac, 0x6006, 0xffff8cc0, - 0x2c22, 0xffff8f93, 0xffffd510, 0x4ac1, 0xffffcac2, 0xffffbfc5, 0xffff772e, 0xffffd90e, - 0xffffc04b, 0x1858, 0xffffdb53, 0x4730, 0xffff87ca, 0xfffff776, 0xb2b, 0x5f04, - 0xffff7deb, 0xffffafc4, 0x273c, 0xffffa9ad, 0x2f96, 0x1df3, 0xffff99ab, 0x3ccb, - 0x8cb2, 0x69c, 0xffffb855, 0xffffa904, 0x8a40, 0x1b30, 0xffffbfe7, 0x8a23, - 0x70f8, 0x57da, 0xffff75fe, 0x2214, 0x2be1, 0xffff990b, 0xffff9394, 0xffffe908, - 0xffffb2c4, 0xffffa067, 0xfffff7c6, 0xffff97cd, 0xffff7498, 0x3af8, 0x1241, 0x10e3, - 0xffffa621, 0xfffff296, 0x698e, 0xffffa28b, 0xffff9084, 0x12cf, 0xffffb1f9, 0x4359, - 0x336c, 0xffffcf1e, 0xffffa763, 0x80bf, 0x4019, 0x47d5, 0xffffec7a, 0xffff83f6, - 0xffffd75a, 0xffffb050, 0xffff9104, 0xfffffb14, 0xffffd821, 0xffff8b8d, 0xffffb3fd, 0xffffebb6, - 0x124e, 0xffffd263, 0xffff7eab, 0xb78, 0xffffb115, 0xffffa4e5, 0xffffe296, 0x1f8, - 0xffffdd28, 0x3378, 0xffff9498, 0x3617, 0xffffb7c3, 0xffffe507, 0xffffe6ae, 0x47b2, - 0x18a5, 0xffff77c3, 0xffffa734, 0xffffc105, 0xffff8925, 0x7add, 0xfffffab0, 0xffffe3ec, - 0x39d4, 0x74ba, 0x56ea, 0xffffebec, 0xffff8e36, 0x3b63, 0x931, 0xfffff745, - 0x81c5, 0x368d, 0xffffbca4, 0xffff80b1, 0xffffe01f, 0xfffff52c, 0xffffacf4, 0x486f, - 0xffffc5e0, 0xfffffaae, 0x10d4, 0x5ea8, 0x4832, 0x38b4, 0x6894, 0x6002, - 0xffffdf3b, 0xffffa4a1, 0xffffe890, 0xffffb7b1, 0x3fee, 0x3c88, 0x1b52, 0xffff8883, - 0x1f6c, 0xfffff5ac, 0xffffc0cb, 0xac9, 0xcd4, 0x14f7, 0xffffa823, 0x21e2, - 0xffff8831, 0x5526, 0xffffc6a1, 0x4551, 0xffffa492, 0xffff9837, 0xffffa222, 0xffffde9d, - 0x1efc, 0xffffec4e, 0xffffd75b, 0x3268, 0xffffc8d6, 0xffff7a3f, 0x4c9b, 0xffff86a0, - 0x45e3, 0xffffddfb, 0xffff806b, 0x7aef, 0xffffcfa4, 0x30ef, 0x7f2b, 0xffffa3bf, - 0x46d7, 0xfffff316, 0x3720, 0x6dd9, 0xffffdb02, 0xffffbc61, 0xffffdd72, 0x81b9, - 0x1bf4, 0xffffb670, 0xffffcd6c, 0x37d8, 0xffffbd23, 0x4df6, 0xfffff2eb, 0xfffff687, - 0x8b59, 0xffff909b, 0x34cd, 0xffffc786, 0x143b, 0x8570, 0xffffc38e, 0x965, - 0xffffd3a1, 0xffffac12, 0xffffbb63, 0xffffe93f, 0x12d2, 0xffffe053, 0x3b2b, 0x4bcd, - 0x52f2, 0xfffff538, 0xffffb301, 0xf71, 0xffffb774, 0xffffd5ba, 0xffffbe11, 0x1121, - 0xffffa83d, 0x1a5a, 0x1ce, 0x8a49, 0xffffccb0, 0x82d2, 0xffffb440, 0xffff8a82, - 0xffff91fe, 0xffff8bad, 0x3e1d, 0x5005, 0xffffb167, 0xffff8f02, 0x1a0b, 0xffffc6d1, - 0x6303, 0xffffb2fe, 0xffffae6b, 0x507c, 0xffff907f, 0xffffeecd, 0xffff801b, 0x7b03, - 0xffffe69a, 0xffff8454, 0xffff8110, 0x2195, 0x60df, 0xffffe944, 0xffff7ac8, 0x21d, - 0x798, 0xffffed4d, 0xffff78b9, 0x36fa, 0xffff7616, 0xffffbf0e, 0x32c0, 0xffffcc92, - 0x294d, 0x819b, 0x2413, 0xffffaa63, 0x7ae7, 0xffff72bb, 0x6505, 0xfffff0e8, - 0x7b0f, 0xffff7b00, 0xffff8a4b, 0xffff8f23, 0x2336, 0xffffe49d, 0xffff9a9c, 0x478d, - 0xffffc085, 0x6059, 0xffffd216, 0xffff9e9b, 0x5e49, 0xffff7f3e, 0x6038, 0x6ad9, - 0xffffc10b, 0xffffd364, 0xffff7ecc, 0x6fef, 0xffff7809, 0xffffc298, 0x835f, 0xffffb70d, - 0xffffbc76, 0xffffc2fa, 0x1779, 0x247d, 0xffffdbe8, 0xffffb8de, 0xffffb96f, 0xffff81ff, - 0xffffbea1, 0xffffa830, 0xffff7fcd, 0xfffff310, 0x51fe, 0x65dd, 0xffff9f9f, 0xffffc799, - 0xffff8390, 0xffffd9da, 0xffffbb03, 0xffffb886, 0x6e67, 0x5799, 0x677b, 0x45ad, - 0xffff934b, 0x70b5, 0x44d0, 0x2f7e, 0xffff7568, 0x15b2, 0xffffbb0d, 0x7bf6, - 0x2605, 0x2b90, 0x4916, 0xffff9cd0, 0xffffaef8, 0xffffe9ab, 0x7fbe, 0xffffac1a, - 0x846, 0xffffc2d1, 0xffffbfba, 0x7699, 0xffffbfb5, 0xffffdef6, 0xffffbfed, 0x2d29, - 0xffffee6e, 0xffffb0c7, 0x8879, 0x8584, 0x3415, 0xffffc2e9, 0xffffc15a, 0xffffa8c4, - 0x3d0c, 0x31ab, 0xffffc3e1, 0xffff8bd4, 0x2ce5, 0x409c, 0x4243, 0xfffff9ce, - 0xffffecff, 0x27c6, 0xffffcddf, 0x6137, 0xffff96f2, 0xffff8d64, 0xffff9537, 0x8566, - 0xffffdf03, 0x6ef9, 0x7ada, 0x1413, 0x46e4, 0xfd7, 0x2c50, 0x7295, - 0xffff8827, 0x8938, 0x3392, 0xffffe413, 0x6e09, 0xffff811b, 0xffffba76, 0xffffc622, - 0x4554, 0xffffba5e, 0x6476, 0xffffb6f3, 0x2589, 0xffffcb99, 0x121a, 0x7e6d, - 0xffffd01a, 0x5bb5, 0xfffff271, 0x5031, 0x528d, 0x63f7, 0x7e28, 0xffffec61, - 0x18e, 0x1915, 0xffffaa49, 0xfffffd82, 0x6e94, 0x80c3, 0xfffff9b9, 0xffff9231, - 0x2b46, 0xffffb3c1, 0x8ef, 0x220e, 0xffffa349, 0x3649, 0x8397, 0xffff981d, - 0x6ad9, 0xffffaee7, 0x1fa9, 0xffffab33, 0x1e07, 0x7698, 0x7732, 0xffffe853, - 0xffff7232, 0x4f9f, 0xffffcbbf, 0xffff7feb, 0x68ce, 0xffffbdf9, 0x17d4, 0x2ee8, - 0x12c4, 0x8112, 0xffffb67d, 0x4914, 0xffffd9a2, 0xffff9e22, 0x74c8, 0xffffd9d8, - 0x5ed2, 0xc27, 0x3957, 0x39ca, 0xffffae61, 0x4edd, 0x15d8, 0x50b9, - 0x5077, 0xffff9787, 0x421a, 0xffff7ec0, 0xffffb93c, 0xffff922c, 0x867f, 0x855c, - 0xffff91fc, 0xffff8bc5, 0xffff8a93, 0x3e3f, 0xffff7c92, 0x772f, 0xffffaedc, 0x474e, - 0xffffb582, 0x135b, 0xffffb468, 0xfffff11d, 0x6298, 0x43bd, 0xffff9698, 0x43e1, - 0xffffc5a7, 0xfffffed5, 0xffffd9be, 0x4176, 0x322d, 0x6eef, 0xffffbdda, 0xffffce75, - 0xffff990d, 0x1857, 0xffffe0bc, 0x639e, 0xffffb5de, 0xfffffa1b, 0x70c8, 0x3404, - 0xffffd256, 0xffffd016, 0x7b8b, 0x69ad, 0x843c, 0xffffe02d, 0xffff7409, 0x4bc2, - 0xffffa87d, 0xffff7408, 0xffffd4d3, 0x27a2, 0xffff74a7, 0xffffc225, 0xffffc7a1, 0xffffcaa1, - 0x3a52, 0x2fe3, 0x36c3, 0x4f3c, 0xffffb5b5, 0x1ec0, 0xffffac64, 0x5f2c, - 0x1f24, 0xffff9dbf, 0x482e, 0x384b, 0xffffb6ca, 0x1acf, 0x66d6, 0x2652, - 0xffffd61d, 0xffff88fc, 0xffff7bed, 0x1862, 0xffffcf25, 0xffffb8e2, 0xffff9823, 0x526f, - 0xffff8e92, 0x6309, 0x4888, 0xffffe6f9, 0x631, 0xffffd94a, 0x1cd3, 0xffffa01b, - 0x43d8, 0x2793, 0x6557, 0x794b, 0x1383, 0x269, 0x1240, 0xffffe15c, - 0x69c5, 0xffffe7b1, 0x8d62, 0x2ecc, 0x7ab3, 0xffff7c8a, 0xffff7d9c, 0x7270, - 0x5c06, 0x7667, 0x1006, 0x7c60, 0x53af, 0xffff8990, 0x4bf4, 0x7183, - 0x2675, 0x30f1, 0x2478, 0x6124, 0xffff8265, 0x116e, 0xffffab22, 0xffffda7e, - 0xffff8517, 0x89fc, 0xffff7a6e, 0xffffb9f7, 0xffffd29e, 0xffffa22b, 0x461, 0xffff8708, - 0x1bcb, 0x7e6d, 0xffffc54a, 0x5d4d, 0x88a1, 0xffffdf3b, 0x1d91, 0x12b6, - 0xffffeb16, 0xffffe8ea, 0x30f0, 0xffff7427, 0xffff7d09, 0xfffff64e, 0xffff8896, 0xffffa354, - 0xfffff72e, 0xffff81d9, 0xffff996c, 0xffff74a4, 0xffffc3cf, 0xfffff2d2, 0xffffbf2c, 0xffff741d, - 0xffffd89c, 0xffffc38a, 0xffffde7d, 0x5f1c, 0xffffb1bb, 0xffffa21f, 0xffffb38e, 0x8236, - 0xfffff3ed, 0xffffce5d, 0x585e, 0xffffbe23, 0xffff8372, 0xffffaf4d, 0x3fcf, 0x3927, - 0x5dda, 0xffffa074, 0xf76, 0x6969, 0x4196, 0x875e, 0xffffb681, 0x35bc, - 0xffffbf70, 0x15af, 0xfffff405, 0x8b2a, 0x6d4c, 0x218d, 0x89bc, 0xffff9efe, - 0xffffc56b, 0xffff942b, 0xffff8aa0, 0x4739, 0x6f8f, 0xffff8a85, 0x6c68, 0xffff958c, - 0xffff9507, 0xffff9771, 0x3fb7, 0xffff8354, 0x6186, 0xffff90d7, 0x1520, 0xffffe018, - 0x3b58, 0x411d, 0xffffdc5f, 0x1ecd, 0xc86, 0xffffa92a, 0xffffeaa6, 0x73a, - 0x3def, 0x58de, 0x4933, 0x675d, 0x5e3, 0x25e2, 0x3eb, 0x714d, - 0xa3a, 0xffff8420, 0xffffcb78, 0xffff887a, 0xffff7747, 0xffffff76, 0x280b, 0x2abd, - 0xffffbdcd, 0x7dc1, 0xffffac20, 0xffffc30a, 0xffff7238, 0x27f3, 0xffffce4b, 0x398d, - 0x4244, 0x3750, 0xffffc875, 0xffffc657, 0xffff9c8c, 0x3779, 0x55ce, 0x49d2, - 0xfffff9b4, 0xffffd3a7, 0xffffade9, 0x3b41, 0x681f, 0xffff8812, 0xffff7a5a, 0xffffc989, - 0x49e6, 0x3783, 0xffffb5f4, 0x70ba, 0xffffbf48, 0x8933, 0x3314, 0x2047, - 0x111e, 0xffffd1e0, 0xffffea38, 0xffff779e, 0xffffabe9, 0xffffe109, 0xffff9c1c, 0x3fdd, - 0x157b, 0x2726, 0x480, 0xffff7635, 0xffffb05d, 0xffff82de, 0xcec, 0xfffff7d9, - 0xffffb171, 0x45f9, 0x8a9f, 0x1d04, 0x1b06, 0x80b, 0x39a9, 0xfffff58c, - 0x274c, 0x1abd, 0xffff7ae0, 0xffffc2a1, 0xffffce98, 0xffff9427, 0xffffa278, 0xffff8c58, - 0x31d6, 0x6f95, 0xef0, 0xffffd311, 0xffff95a0, 0x7c0b, 0xffffaf59, 0x934, - 0x73b3, 0xffff98df, 0xffffa574, 0x6069, 0xffffead8, 0x671f, 0x5c9f, 0x4354, - 0x23dc, 0x1c3f, 0xffffbc97, 0x22d2, 0xffffdd4e, 0x1239, 0x3af3, 0xffffefad, - 0x6121, 0xffffd1e6, 0x66da, 0xffffcc0a, 0x63ea, 0xfffffc17, 0xffffc2d6, 0xffffa0f2, - 0xffffc2d3, 0xffffa772, 0x4b13, 0xffffcfba, 0xffffee11, 0x6561, 0x38cc, 0xffffabbe, - 0xffffe3f2, 0x4c6b, 0xfffff7ef, 0x6373, 0xffffeed8, 0x34cf, 0x59d9, 0x2699, - 0xffffd7fa, 0xfffffa92, 0xffffac49, 0x62d7, 0x6daa, 0x4ab3, 0xffffaf00, 0xffffce18, - 0xffff7e6c, 0x118, 0x72fe, 0xffff874a, 0x645, 0x2d6f, 0xffffa91f, 0x7443, - 0xffff82ca, 0x553f, 0xffffb391, 0xffff83c6, 0x581a, 0x4124, 0x4d68, 0x5981, - 0x40c2, 0xffff925c, 0x10e3, 0xffff957f, 0x7b13, 0xffff9008, 0x3563, 0xffffb7d3, - 0xffff8c80, 0x8508, 0x8a7e, 0xffffd76b, 0x5321, 0x39bb, 0xffffe271, 0xffffa6fa, - 0x758e, 0x3092, 0xffffd014, 0x2666, 0xffff745f, 0xffffb06f, 0xffff861c, 0xffffe4c9, - 0x306f, 0xffffc98f, 0xffff950b, 0x2139, 0x7698, 0xffff9796, 0x1df5, 0xfffff0f9, - 0x112c, 0x467a, 0x211b, 0x4469, 0x168f, 0x38b7, 0x2007, 0x2908, - 0x24, 0x280e, 0x5051, 0xffffb28f, 0x4c68, 0x836a, 0xffffea37, 0xffff9080, - 0xffff95e1, 0xffffe897, 0xffffcabd, 0xffff87dc, 0x88c2, 0x4507, 0xffff8a98, 0x405f, - 0x52c8, 0xffffc450, 0x204a, 0xffff8690, 0xffffec68, 0x28a5, 0xffffdb3c, 0xffffa42c, - 0x13e2, 0xffffb958, 0x595d, 0x4eae, 0xffff8001, 0xffff7f70, 0x4a8c, 0x748b, - 0xffffb9ea, 0xffff87ba, 0x4a61, 0xa72, 0xfffffc5b, 0xffff9428, 0xfffff71c, 0xffffa0d7, - 0xffffd5c7, 0xffffcd3f, 0xffff77eb, 0xfffff986, 0xffff92c6, 0x57a0, 0xffffe759, 0x815c, - 0xffff8cb3, 0xffffcdc4, 0x6a3f, 0x1a8, 0xffff7840, 0x60bd, 0xffffb606, 0xffff8946, - 0xffffebc2, 0xffffaae5, 0xffffce9d, 0xffffca7c, 0xffff761c, 0x3ffb, 0xffffc9e6, 0xffff94b5, - 0xffff7888, 0x63fc, 0xffff8da1, 0xffffd969, 0x21b0, 0x47be, 0x39e9, 0xffffee2b, - 0xffffbc45, 0x82a2, 0x243d, 0x75bc, 0xffff88cf, 0x8c54, 0xffffb154, 0xffffa214, - 0xffffb8bb, 0x8a04, 0xffff87de, 0x8cd6, 0xffffd8d3, 0xffffc81e, 0xffffdf1c, 0xffffb674, - 0x5782, 0xffffa361, 0xffffcd7b, 0xffffe9d7, 0xffff9bbf, 0xffffcae9, 0xffffeab3, 0xffffd75e, - 0xfffffab2, 0xd68, 0x8288, 0x5177, 0x5f43, 0xffffeebd, 0xffffc78f, 0xffff72d2, - 0x812, 0x752a, 0xffffc8ce, 0xfffff6d2, 0xdb9, 0x6b64, 0x3527, 0xfffff063, - 0x79be, 0x6579, 0xffffe19c, 0x226f, 0xffff9529, 0x1eb8, 0x8747, 0x41e2, - 0xffffde27, 0x46e7, 0x86bf, 0xffffa714, 0xffff93c7, 0xffffe02a, 0xffffc1e6, 0x36de, - 0xffffc76e, 0x43ed, 0x65a, 0x6cf4, 0x57f3, 0x4916, 0xffffecae, 0x7ca7, - 0x5c09, 0x48f0, 0xffffb23e, 0xffffaecc, 0xffffa88b, 0xffff7d10, 0x87c4, 0x669f, - 0x56c2, 0x43d, 0x8c6b, 0xfffff478, 0x87cb, 0xffffd0f4, 0xffffa7a1, 0x25e7, - 0x5a3d, 0x1df, 0xfffff384, 0x3438, 0x1ce8, 0x800, 0xffff8048, 0xffffad8a, - 0xffff9d72, 0xffff73f5, 0x818d, 0x420a, 0xffffae9d, 0xffffc332, 0xffffbe39, 0xffffce52, - 0x5b09, 0xffff8635, 0x1157, 0xffffb3d7, 0x33d1, 0xffff8149, 0xffffbe1d, 0xffffff1d, - 0xe7c, 0xa66, 0xffff8167, 0x191d, 0x1beb, 0xffff82ec, 0xffffa8a3, 0xffff78af, - 0x52ca, 0xffff7862, 0x7c41, 0x8b97, 0xffffbe29, 0xffffcaac, 0x7279, 0x893c, - 0x3b70, 0x7947, 0xffffed3c, 0xffffe6e8, 0x3dcb, 0x1d01, 0x88cf, 0xffffb5ae, - 0xffffa7ef, 0xffffece8, 0xfffffb0a, 0x1c20, 0x3691, 0x4f, 0x40aa, 0xffffebe0, - 0x5fa0, 0x38, 0x44dd, 0xffff8ab5, 0x2c13, 0xffffd8b8, 0xffff9f3d, 0x8815, - 0x8683, 0x6a60, 0x1a12, 0xffffa788, 0x5215, 0xffffcc46, 0xffff75bd, 0xffff8c9d, - 0x2871, 0xffff889e, 0xffff9608, 0x8d91, 0x8c85, 0xffffc2ee, 0x458b, 0x48e7, - 0x1d47, 0xffffe974, 0xffffa020, 0xffffe1fd, 0x6f80, 0x8264, 0x885, 0x4317, - 0xffffd135, 0x89c9, 0xffffb412, 0xffff7b42, 0x5b21, 0x5a98, 0xffffbc39, 0x16c0, - 0xffff7c6e, 0x286b, 0x1996, 0xffffd5e6, 0x5fb3, 0xffff950f, 0xe62, 0x215d, - 0x2328, 0xffff7dc1, 0xffffacb9, 0x1483, 0x3da9, 0x74e7, 0x410e, 0x8253, - 0x4216, 0x1ff1, 0x4d3a, 0x3771, 0x817a, 0xffff73f2, 0x624e, 0xffffff16, - 0x3dc5, 0x1384, 0x377c, 0xf2, 0x4bf2, 0xffff74f7, 0x3060, 0x728d, - 0x2aee, 0x7273, 0xffff8fbf, 0x1106, 0xffff89df, 0xffffc920, 0x3582, 0x25fd, - 0xffffce73, 0xffffe0f1, 0x6219, 0xffffadc3, 0xfe9, 0xffff837f, 0xffff9048, 0x781f, - 0xffffb93b, 0x189f, 0xfffffb71, 0x16d2, 0xf5e, 0xffffb0bf, 0x62f8, 0x51e2, - 0x2c58, 0x5d59, 0xffffc837, 0x161a, 0xffffa164, 0x39c, 0x10a3, 0xffff79f8, - 0xfffffd31, 0xffffb4e3, 0xffffc92d, 0x6f16, 0xffffab27, 0xfffff0ba, 0x1be7, 0xffffb0a9, - 0xffffe906, 0x3a70, 0xffffaf42, 0x8b55, 0xffffa625, 0xffffca7e, 0xffff7fdb, 0x4078, - 0x5d41, 0x7798, 0xfffff767, 0xffff964e, 0xffffd7df, 0xffffa537, 0x3b4a, 0x35d0, - 0x5ba2, 0xffffd3b1, 0xffffb2e2, 0xffffd0e7, 0x3602, 0x72f1, 0xffff8dcc, 0xffff7ade, - 0xffffb1ee, 0xffffafa9, 0xffffdad2, 0xffffea6a, 0x6667, 0xffff941e, 0xfffff259, 0xfffff365, - 0x15be, 0x1280, 0xfffffcab, 0x8bb6, 0xffffbf10, 0xffffb64d, 0x408f, 0xfffff18a, - 0xffff9956, 0xffffa946, 0x71e3, 0xffffe7e8, 0xffff7ddc, 0xfffff570, 0x1c0f, 0xffffc10d, - 0x6e81, 0x367d, 0x2846, 0x635e, 0xffff74fc, 0x4b36, 0xfffff47b, 0x8b6b, - 0x7d7, 0xffffeb07, 0xfffff577, 0xffffb507, 0x42a5, 0x733c, 0xffffe9a2, 0xffffe885, - 0xfffff77a, 0xd37, 0x5f47, 0xffffc515, 0xfffffd88, 0xffffeb05, 0xffffcb7f, 0xffffa183, - 0x63df, 0x896f, 0x7fd9, 0x5f5, 0xffffc008, 0x29ac, 0x360e, 0x259d, - 0x7d1, 0xfffff226, 0x3d55, 0xffffabfd, 0x54b4, 0x3085, 0x59a1, 0x8a1e, - 0xffff85f4, 0xffffef3e, 0x49e5, 0xffffe51a, 0xfffffe96, 0xffffdea7, 0x328a, 0xffffa638, - 0x4ced, 0xffffb2d8, 0xffffec06, 0x854b, 0x46a, 0xfffff0e7, 0x8922, 0x8266, - 0x280a, 0x68a6, 0x5210, 0x6a2, 0x4142, 0xffffca2d, 0xffff9e3b, 0x5dd5, - 0xffffe648, 0xffffaac4, 0x22d9, 0xfffff89e, 0x4059, 0xffffab1f, 0xffffd230, 0xffff8d23, - 0x6cf, 0x6067, 0xffffed0e, 0xffff74f8, 0x58ee, 0xffff964e, 0xffffe204, 0x5e81, - 0xffff9d1e, 0xffffa77a, 0xffffef8a, 0xffff8f01, 0xffff7694, 0x6c0b, 0x7293, 0x72b2, - 0xffffa48b, 0xffffeb04, 0x1953, 0x1d, 0xffff888f, 0xffff7b0a, 0xffffa134, 0x7fe3, - 0xffffacc2, 0x471, 0x999, 0x4397, 0xfffff6a0, 0x7af2, 0xffffaac9, 0xffffe255, - 0x1170, 0xffffaaec, 0x2b92, 0xffff96a5, 0xffffd8b4, 0x3e4a, 0x44b0, 0xffffefdf, - 0xffffc299, 0xffff7360, 0xffff7ec4, 0x4be8, 0x2e91, 0xffffc8dc, 0xffffb89a, 0xffff8894, - 0xffff9818, 0xffffb4a1, 0x669, 0x892, 0x8c52, 0xffffe05d, 0x6fc3, 0xffff861c, - 0x19f4, 0x876d, 0x2260, 0xffff873f, 0x363e, 0xfffff093, 0x1434, 0x840b, - 0x648b, 0xffff8ebb, 0x1a62, 0x604e, 0x5874, 0x4304, 0x6f7e, 0xffff8c56, - 0x603b, 0xffffbaa1, 0xffffe654, 0xffff7ea9, 0xffff9791, 0xffffc749, 0xffffa7d9, 0x11e6, - 0xffffa58d, 0x6995, 0x4a1c, 0x362e, 0xffff9be4, 0x8266, 0x304, 0xffffbe5c, - 0xffffb4e6, 0xffffa022, 0xffff821f, 0x1170, 0xffff8639, 0xffffcbf0, 0x2364, 0x6c9a, - 0xffff8726, 0xffff9417, 0xffffea48, 0xffffb072, 0x5f33, 0x4896, 0xffff7762, 0x65e9, - 0xfffffd0a, 0x57f, 0x3b2c, 0xffff751d, 0xffff8c1f, 0xffffef92, 0x7117, 0xffffed28, - 0x8b9f, 0x764b, 0xfffff95d, 0xffff8346, 0xffffada7, 0xffffcd90, 0xffffa794, 0x22f6, - 0x5821, 0x2a57, 0xffff7575, 0xffffc0a9, 0xffffc11c, 0xffff954c, 0x921, 0xffffb22e, - 0x6fa4, 0x5f18, 0xffffcc0d, 0xffffd4eb, 0xffff8fd0, 0xffffd740, 0xffffc4d2, 0x5b17, - 0x7391, 0xffffdc3a, 0xffff923d, 0x4572, 0xffffaf19, 0xffffc9fb, 0xd70, 0x4c5d, - 0xffffb57d, 0x7eda, 0x60ce, 0x3db6, 0x6478, 0xffff81ca, 0xffff8e3f, 0xffffae43, - 0x8aad, 0xffff76a0, 0x2d2d, 0xffffc6ed, 0x89c4, 0xfffff0bd, 0xfffff634, 0xffff86cc, - 0x8934, 0x5c28, 0xfffff07a, 0xffffc810, 0xffffc4d5, 0xffff931a, 0x6cc1, 0xffff820d, - 0x4ad9, 0xffffe2ec, 0x5400, 0xffffce27, 0xffffa35b, 0xfffffa9a, 0xffffc984, 0x29db, - 0x198b, 0xb84, 0xffff7987, 0x43fc, 0x475f, 0x432d, 0xffffe7cc, 0xffff9245, - 0xffffef67, 0x60c2, 0xffffa260, 0x3a6a, 0x6739, 0x6685, 0x1b66, 0xa0, - 0xffff76b4, 0x2f5f, 0x8857, 0xffffa00d, 0xffff8549, 0x203e, 0x841f, 0x28a6, - 0x4193, 0xffffa1d6, 0x798f, 0x5d16, 0x279b, 0x9b1, 0xffffd61c, 0xffff9bce, - 0x3ecd, 0xffffc062, 0xffffac02, 0xffffac45, 0x150e, 0x7e22, 0xffffc92e, 0xffffe529, - 0x60da, 0x3950, 0x3d86, 0x1575, 0x182f, 0x7ee7, 0xffff8da9, 0x1a01, - 0x2e85, 0x7cd5, 0xffff8cc0, 0xffff730f, 0xffff8fe1, 0xffffeb15, 0x3bb7, 0x2d60, - 0xfffffaa0, 0xffffbd0f, 0x33b2, 0xffffd0be, 0xffffc2df, 0xffff7f81, 0x6400, 0xffffd43b, - 0xffffc823, 0x418c, 0xd2f, 0xffffa895, 0x8c3c, 0xffffbaeb, 0x7f05, 0xffffa145, - 0x660d, 0xffffa464, 0xfffff7ba, 0x8a12, 0x5b5a, 0xffffc222, 0xffff999e, 0xffffe91a, - 0x1bd9, 0xffffb0f5, 0x8202, 0x7319, 0xffff877a, 0xffff97b7, 0xffffc451, 0xffffa669, - 0x34b1, 0xffffbcda, 0xffffb333, 0x76fa, 0x4fb3, 0x1bfa, 0x8822, 0xffffcd78, - 0xffff7440, 0xfffffb6c, 0xffffb200, 0x4f19, 0x33ed, 0xffffb977, 0x26b, 0xfffff89d, - 0xffffa1de, 0x61ec, 0x1d9c, 0xffff76c0, 0xffffb7c1, 0xfffff027, 0x700c, 0xffff841a, - 0xfffffd62, 0xffff8baf, 0x4562, 0x7eab, 0x2ac8, 0xffffca3d, 0x6a8c, 0xffffc5c5, - 0xffff76cf, 0x454e, 0x44b2, 0x2e49, 0x551c, 0x4b86, 0x734c, 0xffff9db0, - 0x1d8, 0xffff9219, 0xffffe716, 0xffff7e4f, 0xffffcad7, 0x208, 0xffffa001, 0xffffe587, - 0xffffeed7, 0xffffc27b, 0xffffc41d, 0x4531, 0x7ee, 0xffff755f, 0xa10, 0x1d02, - 0xffff75fe, 0xffff9543, 0x237f, 0xffffabf2, 0xd2, 0xae9, 0x2785, 0xffff85c8, - 0xffff9b84, 0xffffc2d6, 0xffffe149, 0x28ae, 0xffff75f9, 0xffff9667, 0x5647, 0x76e9, - 0xfffff7f3, 0xffffa9ae, 0xffffc163, 0xffff8412, 0xfaf, 0x1cde, 0xffff888f, 0xffff7e2f, - 0xffffd400, 0xffff8602, 0x37de, 0xffffb80c, 0xffffd2e9, 0x11ba, 0xffffb448, 0xffff9253, - 0x603a, 0x71c9, 0x4d23, 0x48c7, 0xffffc84d, 0xffffe1fb, 0x47db, 0x1877, - 0x45af, 0xfffff561, 0xffffd599, 0x7c57, 0xffff8cd4, 0xffffbc8b, 0x61db, 0x37a0, - 0x1544, 0xffffca6a, 0x8d85, 0x768f, 0xffff897a, 0xffff923c, 0xffffecde, 0xfffff499, - 0x100c, 0x5097, 0x8dd1, 0x1d2c, 0xffffd766, 0x31a3, 0xffff9f7e, 0x31e8, - 0x2744, 0x8dad, 0xffffd73e, 0x33ab, 0x3fed, 0xfffff38c, 0xffffe07f, 0x7827, - 0xfffffc55, 0x6531, 0x526b, 0x2399, 0x3c8c, 0x4633, 0xffffaafa, 0x11da, - 0xfffffca9, 0xffff7c90, 0x4499, 0x3445, 0x12c4, 0x2210, 0xffffe1e1, 0x431b, - 0x45da, 0xffff72cf, 0xffffdae7, 0x6ee7, 0xffffb843, 0x7930, 0xfffffc7c, 0xffffda3e, - 0xffff89d1, 0x8d06, 0xe73, 0xffff82c9, 0xffffeeb8, 0xffffc7dc, 0x3e13, 0xffff9f2f, - 0xffff7e2a, 0xffff7eaf, 0x6cb0, 0x5077, 0xc26, 0xffff9fcb, 0xffff7e45, 0x1bc3, - 0x6cd7, 0x800e, 0x333f, 0xffffef38, 0x3294, 0x38c5, 0xffff9860, 0x7fe2, - 0x1846, 0xffffc870, 0x8798, 0xffffa794, 0x3433, 0x70a5, 0xffffe031, 0xffffbd5a, - 0x626c, 0xfffff816, 0x7b1, 0x83fc, 0xffff9362, 0x306, 0x7587, 0xffffdb69, - 0xffff89e4, 0x1da2, 0x5532, 0xfffffd49, 0xffffba57, 0xffff8941, 0xc84, 0x6b89, - 0xffffecd4, 0x2578, 0x8a3e, 0xffffbd94, 0xffff8bc6, 0x7a73, 0x5cfc, 0xffffa543, - 0x4605, 0xffffbde5, 0x8cfe, 0x150b, 0xffffd23e, 0xffffa042, 0xffff7b69, 0xfffff168, - 0x1c44, 0xffff72f5, 0xfffff3c2, 0xfffff9ed, 0xffffeca1, 0x2d48, 0xffff9bce, 0x272b, - 0xffffc260, 0xffff929d, 0x3cb9, 0x5c11, 0x5d4, 0xffff8ad7, 0x6aa9, 0xfffffb80, - 0x572b, 0x2cbd, 0x5e8a, 0xffffb586, 0xfffff8e7, 0x6f5b, 0x28ce, 0x11a, - 0x71f5, 0xfffff744, 0x1be2, 0xffff95cd, 0x6cef, 0xffffc7f6, 0x1ac3, 0x8c96, - 0xffff760f, 0xffffa1ba, 0x370, 0x3277, 0xffff817a, 0xffffcee6, 0x195e, 0xffff7ccb, - 0xffffca7b, 0xffff9d90, 0x540e, 0x6725, 0xffff75a3, 0x48a5, 0xffffada6, 0xfffffdad, - 0x32e4, 0x1e1e, 0xffffe0eb, 0xffffed3c, 0xfd, 0xffff9fbf, 0x4878, 0x8dbc, - 0x3ef3, 0xfffffcd0, 0x80e5, 0x77b5, 0x8b4b, 0x7003, 0xffffb759, 0x8938, - 0x4a57, 0xca9, 0x6783, 0x27ee, 0x2c7a, 0xffff8bf7, 0xffffe754, 0x2a23, - 0x60ea, 0xffffc6bc, 0xffffb024, 0x34b2, 0xffffe44f, 0x2f16, 0x3df3, 0x883c, - 0x3eb1, 0xffff81dd, 0x5e00, 0x7ae1, 0x62bc, 0xffffcb8d, 0xffffd0eb, 0x457f, - 0x6bb3, 0x72a2, 0xffffb521, 0xffff7d69, 0xffffd032, 0x4d2, 0xffff9dcb, 0xfffffd7d, - 0x44d, 0x3c01, 0x34ed, 0xfffff07f, 0x74a6, 0x894, 0x524d, 0xdb3, - 0xcb3, 0xffff9661, 0xffff9d9a, 0xffffdae6, 0xffffd8df, 0xffffe241, 0x14a9, 0xffff79ad, - 0x1d71, 0x17e9, 0xffffcee6, 0x58cc, 0xffffa52b, 0x7b08, 0xec7, 0x5a66, - 0xffff7f3c, 0xffffc522, 0x210d, 0x109c, 0x162d, 0x4654, 0xfffffee4, 0x1b68, - 0x7e7b, 0xffffb804, 0xffff9c77, 0xffffa259, 0xfffffcdc, 0xffffb126, 0x6f3e, 0x597e, - 0xffff8c8b, 0xffffb09a, 0x4d39, 0x8bc3, 0x1208, 0x63f, 0x7e6a, 0x3bb1, - 0x8dd9, 0x4cac, 0xffff803c, 0xffff9d29, 0xffffa2d6, 0x1a9a, 0x16fe, 0xffffc6c9, - 0x6ff1, 0xffffb441, 0xffffbdc5, 0xfcd, 0xffffe445, 0xffffa0f3, 0xffffef93, 0xffffdd4e, - 0x3fe8, 0x40a2, 0xffffeac0, 0x6f7d, 0xffff83d1, 0x459e, 0x6eee, 0x7da, - 0xffff9f26, 0xffff9da6, 0xffffb81c, 0x25c8, 0x32a6, 0x2351, 0xffff7450, 0xffff90f0, - 0x16ee, 0xffffa868, 0xffffa2cb, 0xffff79fc, 0xfffffe99, 0x6a31, 0x1a59, 0xffffbca9, - 0xffff8d29, 0xffffc840, 0xffffd7e8, 0xffff9128, 0xfffff92c, 0xffffd49d, 0xffffa0a4, 0x7533, - 0x748, 0x4245, 0x34bc, 0x366c, 0xffffc838, 0x3265, 0x8226, 0x4aca, - 0xffffe761, 0x19e, 0x46bb, 0xffffdafa, 0xffffdd98, 0xffffc1b8, 0x7aa8, 0xffffc744, - 0xffff7766, 0xffffeb0c, 0x675b, 0x573, 0x5b52, 0xffffd638, 0x49a1, 0x5235, - 0xffffcd48, 0xffff8960, 0xffff8468, 0xffffc6b1, 0xfffff7c1, 0x6995, 0x5eb4, 0xffffc196, - 0xffff7779, 0x6104, 0xffff8f5b, 0x2928, 0x6cf0, 0x1b93, 0xffffbdd9, 0x1ca5, - 0x81b, 0x64c3, 0xfffff230, 0xffffc185, 0xffffd191, 0xffff858e, 0x6eb8, 0xffffd904, - 0x89ca, 0xffff8102, 0xffffc709, 0x39e2, 0x5bde, 0x1e9e, 0xffffb9c8, 0x81c2, - 0xffffb753, 0xffff9bba, 0xfe5, 0xffffaabf, 0xffff82e0, 0xffffcc44, 0x22e0, 0x1053, - 0x6b07, 0x2522, 0x6316, 0x5ddf, 0xfffff8fe, 0xffff896b, 0x8a7d, 0xffff9398, - 0xffffa42f, 0x4f57, 0x71a, 0xffffef95, 0xffffb170, 0x12e9, 0xffff8147, 0xffffdc5c, - 0xffff9d76, 0x2a39, 0x2a4a, 0x2d76, 0xffffa31c, 0xffffafcf, 0xffffb76e, 0x617c, - 0xa00, 0xffff878f, 0xffff737a, 0x6f54, 0x7516, 0xffffbc9a, 0x39c8, 0x5bbe, - 0x4d20, 0x32b6, 0xffff8d2f, 0xffffcee7, 0x46ef, 0x3bdb, 0xffffc557, 0xffffe1a6, - 0xffff7a54, 0x6572, 0xffff9a6d, 0x7b59, 0x3be8, 0xffffd635, 0x1acd, 0xffffe77a, - 0xffffa8c9, 0x531c, 0xffff8a3a, 0xfffff65d, 0xb96, 0x49b8, 0x735b, 0x791, - 0x682b, 0xfffff0f6, 0x179e, 0xfffff2ef, 0x3992, 0xffffc2d8, 0xffffb85c, 0xffff9e2d, - 0xffffdc7a, 0x1202, 0xffff761e, 0xffffae43, 0xffffddc9, 0xffff8377, 0xffffd6dc, 0x124, - 0x493d, 0x2f55, 0xfffff8c8, 0x5f25, 0xfffff800, 0xffff738a, 0x3465, 0x1089, - 0x4ea3, 0xffff83ec, 0x4f50, 0xffffaac4, 0x1c54, 0x58c5, 0xffffe6ab, 0xffff8a2e, - 0x74b2, 0x6032, 0xfffff56b, 0x836c, 0xffff8f09, 0x8316, 0xffffeb3e, 0x257c, - 0xffffd7c8, 0x671f, 0x4eab, 0x1220, 0xffff7c40, 0x3c05, 0xffffd400, 0x841, - 0xffff7c1a, 0x5119, 0x371c, 0xffffb126, 0xffffa46d, 0xffff8f00, 0xfffffed8, 0x6db7, - 0x1608, 0xffff7c99, 0x72a6, 0x7cad, 0xffff7831, 0x810d, 0x79d5, 0x1b55, - 0xffffd273, 0x5d84, 0x5983, 0xffffff4a, 0x5005, 0x69bf, 0xffffe75f, 0xffffd029, - 0xffffe1e8, 0xffff9e76, 0xff2, 0xfffff4d4, 0xffffe108, 0xffffb618, 0xffffed8b, 0xd27, - 0x94d, 0x52ff, 0x8634, 0xffffa360, 0xffffffe3, 0xffffb0d8, 0xffffaaee, 0xfffff959, - 0xffffbdaf, 0xffffc563, 0x2506, 0x4a98, 0xfffff9bb, 0x4ad2, 0x25f4, 0xffff9987, - 0x5bf9, 0x8d03, 0x58d7, 0xffff988b, 0xffffe7b6, 0x1aeb, 0xffffdd88, 0xffffd037, - 0xffff9db8, 0xffff77f7, 0x693, 0x8863, 0xffff9329, 0xffffb19f, 0x5447, 0x2606, - 0x77dd, 0xffffbd47, 0xfffffb00, 0x4c00, 0xffff9169, 0x7d2a, 0x8548, 0xffffe574, - 0x44b, 0xffffe68c, 0xffff9738, 0x4689, 0x27f6, 0x5a2c, 0x37a7, 0x529d, - 0xffff7c73, 0x76f2, 0x242f, 0x8134, 0x30a8, 0x3ab2, 0xfffffe83, 0x3bd5, - 0xffffc9ed, 0xffff7be3, 0x6356, 0xffffab4b, 0x6d2d, 0xffffb6dc, 0x1d24, 0x6908, - 0x6aa6, 0x4fe3, 0xffffe221, 0xffff8985, 0x3389, 0x6062, 0x8700, 0x4834, - 0x8cba, 0x842c, 0x15dd, 0x86ac, 0xffffa5c2, 0x375c, 0xffffc3e1, 0x2517, - 0x2a44, 0xffffa391, 0xffffec55, 0xffff7bec, 0xffffb1e1, 0x5156, 0x7b17, 0xd57, - 0x962, 0x4e52, 0x3b2e, 0xffffab67, 0xffffda44, 0x69e8, 0xffff78ec, 0xffffd084, - 0xffff8488, 0x773a, 0x6c60, 0xffffa9c9, 0x6d4a, 0xfffffe96, 0xffffe0e0, 0x1bef, - 0xffffde02, 0xaae, 0xffff9a10, 0x557, 0x4da9, 0x867c, 0x1741, 0x42f8, - 0xffffd09b, 0xffffd2d1, 0xffffe212, 0xfffff266, 0x45ed, 0xffffe717, 0x6837, 0x76c1, - 0xfffffef7, 0x5baf, 0xffffbee3, 0xffff830d, 0xffffb4fa, 0x372b, 0xffffb440, 0xffff8e7e, - 0xffffa00d, 0xffffbb90, 0xffff92d7, 0xffffa723, 0xffffe18b, 0xfffffbe0, 0xffffdf88, 0xffff76d1, - 0xffffd2af, 0x3a01, 0x8c46, 0xfffff48e, 0xffff8ada, 0xffffb3f4, 0x46ba, 0xffffa696, - 0x4a04, 0x8cf1, 0x362f, 0xffffc320, 0x73d2, 0xffffa00f, 0xfffff6ad, 0x7269, - 0x695e, 0x4812, 0x3b16, 0x6442, 0xffffa02b, 0xffffc2c0, 0xffffe410, 0xffffb923, - 0x6012, 0xffffdcd3, 0xffffbdfe, 0xffff97be, 0x6ad6, 0xffffe081, 0xffff97e9, 0xffff8adf, - 0xd9e, 0xffff7e8f, 0xffffc9c6, 0x6a7e, 0x53b9, 0xffff7fb5, 0x8314, 0xffff81f5, - 0x1d86, 0x3e5d, 0xfffffd9d, 0x201e, 0xffffde6d, 0x2055, 0x7317, 0x167c, - 0xffffcfa0, 0xffff9bbc, 0xffffa8e0, 0x2d83, 0x5a8d, 0xffffb0bd, 0x3926, 0x669f, - 0x4b9e, 0x6345, 0x2c7, 0xffff91c9, 0xffff745a, 0x5091, 0x56a3, 0x6e45, - 0x31ac, 0xffff9847, 0xffffbb04, 0x617c, 0x1374, 0x8dd7, 0xffffe142, 0xffffeb42, - 0x9d4, 0xffff8b2d, 0x84fc, 0x3b6, 0x604a, 0xffffd453, 0xffffd691, 0xffff7927, - 0xc47, 0x169d, 0x70bb, 0x10d4, 0x6b25, 0xffff8965, 0xffffc874, 0xffff7571, - 0x2165, 0xffffbb50, 0xffff7623, 0xffffab6f, 0xfffff47a, 0xffffb87b, 0x14d1, 0xffffff82, - 0xffffe1b8, 0xf6b, 0xffff74f4, 0xffffefb6, 0xffff88c0, 0x2eec, 0xffffade2, 0xffffdcd2, - 0xffffb1cc, 0x334f, 0xffffc569, 0xffff8414, 0x8070, 0x7bfa, 0x8992, 0xffffcc6d, - 0xffffa65a, 0x251f, 0x8bbf, 0x2463, 0xffff74d2, 0xfffff0cf, 0xffffde9a, 0x4f4a, - 0xffff8446, 0xffffa4e2, 0x808a, 0xfffffadd, 0x723e, 0xffffd82d, 0x1f14, 0x8c71, - 0xffffdc75, 0x6c3c, 0x4435, 0x472f, 0xffff7252, 0x22e5, 0x19c0, 0x88aa, - 0xffffd423, 0xffff8758, 0x2758, 0xffffd33d, 0xffffe1bb, 0x83b3, 0x8535, 0xaa5, - 0x7864, 0x6b59, 0x2ab7, 0x7e5b, 0x6df6, 0x6f3e, 0xffff908a, 0xffffb6d4, - 0x4eca, 0xffffa83f, 0xffffff3f, 0xffff7a6a, 0xffff74aa, 0x37e9, 0xffff8a5e, 0xfffff391, - 0xffffc4c1, 0x36fb, 0x21e2, 0x623d, 0xffff7306, 0xfffff202, 0x39cb, 0xffffcd47, - 0x13b6, 0x630e, 0xffffa3e6, 0xffffeb86, 0x5eb8, 0xffff73c0, 0xfffffa42, 0x49fb, - 0xffffed95, 0x718f, 0xffff7e6a, 0x1914, 0xffffa5e9, 0x8cf1, 0x2ae3, 0xfffff9e8, - 0xffffec23, 0x697d, 0x5ab9, 0x77f0, 0xfffff222, 0x5ff0, 0xffffa34d, 0x82bc, - 0x5950, 0x13c1, 0x5a9b, 0x570c, 0x4992, 0x405c, 0x3ecd, 0xfffff886, - 0x1362, 0x1704, 0xffff87b3, 0xffffe31c, 0x7e6c, 0x27e7, 0x355a, 0xffff84c4, - 0xffffe078, 0xffffc000, 0xffffd37a, 0x2690, 0x130d, 0xffffd22b, 0xffffa6c1, 0x12dd, - 0x36db, 0x5507, 0xffff8c14, 0xffffb616, 0x71ab, 0xffffd884, 0xffff7ed4, 0x1871, - 0x212a, 0xffff8acf, 0x353, 0x3bca, 0x7cfc, 0xffff7a5d, 0x5990, 0x4bb, - 0xffff7606, 0x6328, 0x386, 0xffffd02b, 0xffffe3b6, 0xfffff0bb, 0x4b6f, 0x8dc, - 0xfffff3ea, 0x169c, 0x3ed8, 0xffffa125, 0x3c69, 0xfffffedb, 0x6c9b, 0x17de, - 0xffffb5f8, 0xef6, 0xfffffbc6, 0xffff82b9, 0xffff7a4e, 0x6193, 0x6994, 0xffffe6b5, - 0xffffdb01, 0x5c14, 0x68a8, 0x26a4, 0xffffb021, 0x7bcc, 0xffff9f05, 0x814, - 0x162c, 0xffffb3e7, 0x2c53, 0xffffc8e1, 0x6920, 0xffff7254, 0x6d49, 0xffffb4c2, - 0xffffcaca, 0xffffe1cd, 0xffffd576, 0xffffbad8, 0xffffc4db, 0xffff7f6b, 0x758b, 0x1f19, - 0x4407, 0x3b61, 0xffffa2ea, 0xfffff403, 0x26b, 0x6789, 0x5ca7, 0x3b3, - 0x458b, 0xffffd823, 0xffff83b7, 0x2dc6, 0xffffbd8d, 0xffff7964, 0x77a3, 0x18bd, - 0x7ada, 0xffffc92e, 0x32e2, 0xffffe36a, 0xffff79db, 0x6ca2, 0xffffafdb, 0xffffba78, - 0x23cb, 0xffffc5ad, 0xffffe3f4, 0x89d5, 0x86ee, 0x13ca, 0xfffff25b, 0x3ebb, - 0x680d, 0x628a, 0xffffce21, 0x44c, 0xffff7532, 0xffff72a6, 0xffff88d5, 0x8599, - 0xffffe7cf, 0xffffbeed, 0xffffbcf5, 0x675c, 0x481d, 0x6ac3, 0xffffc0ae, 0x4ce4, - 0x46ef, 0x2b3f, 0x47fd, 0x35f4, 0xc48, 0x3038, 0x7b9b, 0x302d, - 0xffff85f4, 0x6652, 0xffff7f44, 0xffffec9b, 0xffffedd2, 0x2863, 0x2faa, 0x8cf1, - 0xffffc4e8, 0xcb3, 0xffff925c, 0xffffc9c0, 0xffffad2f, 0x5eb1, 0x5697, 0x66bd, - 0xffff8080, 0xffff98b1, 0x2955, 0xffffcdbd, 0xffffd6d8, 0xffff84a6, 0xffffe29c, 0xffff9edd, - 0x391f, 0x625c, 0xffff8094, 0xffffbad3, 0xffff8b97, 0x7d06, 0xffffadce, 0x1036, - 0xffffcbd0, 0x3027, 0xfffff405, 0x3104, 0xffffd411, 0x614d, 0x426b, 0x410, - 0x3524, 0xffffddf3, 0x3c3b, 0x7663, 0x4d40, 0x7c3e, 0xffffa330, 0xffffbd4a, - 0xffffce53, 0x989, 0xffffddc9, 0xffff92ed, 0x4449, 0xffffa2d2, 0xfffff261, 0x5c84, - 0xfffff447, 0xfffff6c6, 0x4520, 0xffffa40d, 0xffffd253, 0xffffbf75, 0xffffaeea, 0x8c96, - 0xffff7c66, 0xffffc745, 0x572b, 0x5167, 0xffffdc8a, 0x46cc, 0x5b66, 0xffffd61c, - 0x3fc6, 0x7a63, 0xffffc4d8, 0xffffe8b4, 0xffffdc6a, 0x6f63, 0xffffd716, 0xffffbb46, - 0x7426, 0xffff7dde, 0x26f1, 0xffffcd18, 0x1776, 0x4d89, 0x20c5, 0x6457, - 0x371c, 0xffff8c94, 0xffff72e4, 0x7cc, 0x835b, 0xffffb776, 0xffff93e1, 0xffff83cd, - 0x7241, 0xffffcfc4, 0xffffbda6, 0x63f0, 0xffffaa19, 0x7cf5, 0xffff8f8d, 0x1942, - 0xffff87ae, 0x4e6d, 0xffff78d5, 0x6e8c, 0x3539, 0xffffc063, 0x73c, 0x76dc, - 0xfffff8ff, 0xffffb5a1, 0x19bf, 0xffff7694, 0xf15, 0xfffff136, 0xffff82b9, 0xffffcc83, - 0xffff88a4, 0xffffc7e0, 0xffff7256, 0xffffe068, 0x25b4, 0xffffed48, 0xffff8d7d, 0x5f8c, - 0x1892, 0xffffd1e5, 0xffff7417, 0x7ecc, 0xfffffb74, 0x8c0c, 0x4758, 0xffffc7d7, - 0xffffe764, 0xfffffe29, 0xffff88fa, 0xffffe66d, 0xffffdeb4, 0x2f2d, 0x646b, 0xffffce8c, - 0x3769, 0x3912, 0xffffe6fb, 0xffffc166, 0xffffce02, 0x4dc7, 0x80b5, 0xffffc70d, - 0xffffc36a, 0x30ea, 0x7441, 0x5fe4, 0xffff7812, 0xffffe92e, 0xffffcc86, 0xffffe27b, - 0x49e2, 0x71c0, 0xffffab47, 0xffff9c51, 0x7377, 0xfffffc50, 0x7be0, 0x13e0, - 0xffffe5f2, 0x2db1, 0x2610, 0xffff8258, 0xffff978f, 0x282b, 0x395, 0x1031, - 0xffffb66c, 0xffff749b, 0xffffbf6f, 0xffffa7e1, 0x12f1, 0xffffcfa7, 0xfffff7fd, 0x6a21, - 0x8a4d, 0x4ff5, 0x71be, 0x8096, 0x5502, 0x4f40, 0x81c5, 0x5a75, - 0xffff8d39, 0x1bc0, 0xffff7827, 0xa59, 0xffff9929, 0x8db3, 0x5df1, 0xfffff7b2, - 0x420a, 0x6544, 0x6509, 0x7451, 0x1e7f, 0x4f76, 0x315a, 0x3620, - 0x5091, 0x4403, 0xffffd3e4, 0x5c0c, 0x80c2, 0x36c4, 0x5107, 0xffff943d, - 0x6452, 0xffffad40, 0xffff9b98, 0x58ab, 0x27b3, 0xffff8be9, 0xffffa656, 0xffffa5f8, - 0xffffbd22, 0xffff73fd, 0x2758, 0xffffa764, 0x62ed, 0xffff90c5, 0x1e51, 0xffff897b, - 0xffff82b3, 0x2d25, 0x76ad, 0xffff7f02, 0xfffffa89, 0x2d4f, 0x2ab, 0x5685, - 0x8ce1, 0xfffff7de, 0x5522, 0xffffbc64, 0xffff9e79, 0xffffef8b, 0xffff84f0, 0xffff933c, - 0x102e, 0x8bc, 0x5a44, 0xfffffe4f, 0xffffaed9, 0x7aee, 0xffffa2ae, 0x12e0, - 0x7c7b, 0x3a66, 0xffffb1f5, 0xffffa575, 0x3bf3, 0xffffe14f, 0xffffedca, 0xfffffb3d, - 0xffff8279, 0x296b, 0x8bc7, 0xc1b, 0xffffea63, 0x65cd, 0xffffa851, 0x878f, - 0xe37, 0x501a, 0x581c, 0x16c3, 0x6279, 0xffff9e12, 0xfffffc2c, 0x7d4c, - 0x4c95, 0xffffced3, 0xffff8b07, 0xffff87b0, 0xffffa928, 0x6ce2, 0xffff8bc1, 0xffff7fab, - 0x5249, 0xffffbf8f, 0x8074, 0x1ab9, 0xffffe2ed, 0xffffebbb, 0xfffffd25, 0x474f, - 0xffffe439, 0xffffe258, 0xffffb947, 0xfffffa1b, 0xffff90ea, 0x8134, 0x6eed, 0xffffc392, - 0xffff934a, 0xffffb921, 0xd9a, 0x6581, 0x37f2, 0xffffe672, 0xffffafd9, 0x30eb, - 0xffffa08e, 0xffffa39d, 0xffff9657, 0x26d0, 0xffffb97f, 0x5df, 0xffff9257, 0x3a34, - 0xfffffd43, 0xffffc367, 0x8bf0, 0x186, 0x1692, 0x5420, 0x7d2c, 0x83dd, - 0x4ad1, 0xfffffc05, 0x67a4, 0x7b06, 0xffffacd2, 0x7c2, 0x4f9a, 0x586a, - 0xffffdacd, 0xfffff2e4, 0xffffa666, 0xffffa2f2, 0xffffdd98, 0x50ec, 0xffffec94, 0xffffe01d, - 0xffffe6a5, 0x2b32, 0xffff9128, 0xffffba30, 0xffff82ba, 0xffffe9fc, 0xffffe738, 0x20fa, - 0x3c1b, 0xffffce2f, 0x533, 0x8bdf, 0x79be, 0xffff86e9, 0x82cf, 0xffffab3e, - 0x591d, 0xfffffeb2, 0xffff7424, 0x8932, 0xffffe0f9, 0xffff9d92, 0xffff7b20, 0x2495, - 0x879d, 0x85a3, 0x6f1f, 0x1cf2, 0x1220, 0x65c2, 0xffffc751, 0xffffa10f, - 0xffffa5df, 0xffffd1fd, 0xffffac41, 0xffff73d2, 0xffffc38e, 0xffffa17a, 0xffff9f58, 0x6600, - 0xffff95d8, 0x8400, 0x38dc, 0xffff9844, 0xffff9378, 0x5fdc, 0x3ed8, 0xb4b, - 0xffffb1fd, 0xffff72a1, 0x6313, 0x3acb, 0xffffd03c, 0xffffe6bb, 0x59f7, 0x5a17, - 0x20c2, 0xffffddc9, 0x60e0, 0xffffb1ff, 0x7867, 0xffffad34, 0x8cb0, 0xffff89ed, - 0xffff9cf1, 0x57ed, 0x186b, 0x85bb, 0x1ed9, 0xffffd073, 0x755, 0x39d, - 0xffffe507, 0x5144, 0x3bdd, 0xffff748f, 0x5a22, 0x2f8c, 0xffffe210, 0xffff8285, - 0x2ffa, 0x17c1, 0x11b5, 0xffffa5ff, 0x3950, 0x6b7f, 0xffffc962, 0xfffff345, - 0x80c6, 0xffffbb45, 0xffffac73, 0xffff941e, 0xffff9774, 0xffffe733, 0x35cb, 0xffffb0e4, - 0x8a90, 0x296d, 0xffffea99, 0xffffb292, 0x3778, 0xffffff27, 0x3422, 0x2bd4, - 0xffffb0ac, 0xffffda12, 0x3f00, 0x36ed, 0x38ec, 0xffff9a13, 0xffff9d40, 0x5ec5, - 0x5a1b, 0x5a7d, 0xffffccab, 0xfffffcd1, 0xffffa33b, 0xffff9848, 0x31d8, 0x2224, - 0x2eb0, 0xffffa658, 0xffff9e76, 0xffffd97a, 0x65a8, 0xffff8029, 0xf42, 0x2c21 -}; - diff --git a/apps/codecs/libwma/wmadec.h b/apps/codecs/libwma/wmadec.h deleted file mode 100644 index 76429dede1..0000000000 --- a/apps/codecs/libwma/wmadec.h +++ /dev/null @@ -1,181 +0,0 @@ -/* - * WMA compatible decoder - * Copyright (c) 2002 The FFmpeg Project. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef _WMADEC_H -#define _WMADEC_H - -#include -#include "ffmpeg_get_bits.h" -#include "types.h" - -//#define TRACE -/* size of blocks */ -#define BLOCK_MIN_BITS 7 -#define BLOCK_MAX_BITS 11 -#define BLOCK_MAX_SIZE (1 << BLOCK_MAX_BITS) - -#define BLOCK_NB_SIZES (BLOCK_MAX_BITS - BLOCK_MIN_BITS + 1) - -/* XXX: find exact max size */ -#define HIGH_BAND_MAX_SIZE 16 - -#define NB_LSP_COEFS 10 - -/* XXX: is it a suitable value ? */ -#define MAX_CODED_SUPERFRAME_SIZE 16384 - -#define M_PI 3.14159265358979323846 - -#define M_PI_F 0x3243f // in fixed 32 format -#define TWO_M_PI_F 0x6487f //in fixed 32 - -#define MAX_CHANNELS 2 - -#define NOISE_TAB_SIZE 8192 - -#define LSP_POW_BITS 7 - - -#if (CONFIG_CPU == PP5022) || (CONFIG_CPU == PP5024) || (CONFIG_CPU == MCF5250) -/* PP5022/24 and MCF5250 have 128KB of IRAM. 80KB are allocated for codecs */ -#define IBSS_ATTR_WMA_LARGE_IRAM IBSS_ATTR -#define IBSS_ATTR_WMA_XL_IRAM -#define ICONST_ATTR_WMA_XL_IRAM - -#elif defined(CPU_S5L870X) -/* S5L870x has even more IRAM. Use it. */ -#define IBSS_ATTR_WMA_LARGE_IRAM IBSS_ATTR -#define IBSS_ATTR_WMA_XL_IRAM IBSS_ATTR -#define ICONST_ATTR_WMA_XL_IRAM ICONST_ATTR - -#else -/* other PP's and MCF5249 have 96KB of IRAM */ -#define IBSS_ATTR_WMA_LARGE_IRAM -#define IBSS_ATTR_WMA_XL_IRAM -#define ICONST_ATTR_WMA_XL_IRAM - -#endif - - -#define VLCBITS 7 /*7 is the lowest without glitching*/ -#define VLCMAX ((22+VLCBITS-1)/VLCBITS) - -#define EXPVLCBITS 7 -#define EXPMAX ((19+EXPVLCBITS-1)/EXPVLCBITS) - -#define HGAINVLCBITS 9 -#define HGAINMAX ((13+HGAINVLCBITS-1)/HGAINVLCBITS) - - -typedef struct CoefVLCTable -{ - int n; /* total number of codes */ - const uint32_t *huffcodes; /* VLC bit values */ - const uint8_t *huffbits; /* VLC bit size */ - const uint16_t *levels; /* table to build run/level tables */ -} -CoefVLCTable; - -typedef struct WMADecodeContext -{ - GetBitContext gb; - - int nb_block_sizes; /* number of block sizes */ - - int sample_rate; - int nb_channels; - int bit_rate; - int version; /* 1 = 0x160 (WMAV1), 2 = 0x161 (WMAV2) */ - int block_align; - int use_bit_reservoir; - int use_variable_block_len; - int use_exp_vlc; /* exponent coding: 0 = lsp, 1 = vlc + delta */ - int use_noise_coding; /* true if perceptual noise is added */ - int byte_offset_bits; - VLC exp_vlc; - int exponent_sizes[BLOCK_NB_SIZES]; - uint16_t exponent_bands[BLOCK_NB_SIZES][25]; - int high_band_start[BLOCK_NB_SIZES]; /* index of first coef in high band */ - int coefs_start; /* first coded coef */ - int coefs_end[BLOCK_NB_SIZES]; /* max number of coded coefficients */ - int exponent_high_sizes[BLOCK_NB_SIZES]; - int exponent_high_bands[BLOCK_NB_SIZES][HIGH_BAND_MAX_SIZE]; - VLC hgain_vlc; - - /* coded values in high bands */ - int high_band_coded[MAX_CHANNELS][HIGH_BAND_MAX_SIZE]; - int high_band_values[MAX_CHANNELS][HIGH_BAND_MAX_SIZE]; - - /* there are two possible tables for spectral coefficients */ - VLC coef_vlc[2]; - uint16_t *run_table[2]; - uint16_t *level_table[2]; - /* frame info */ - int frame_len; /* frame length in samples */ - int frame_len_bits; /* frame_len = 1 << frame_len_bits */ - - /* block info */ - int reset_block_lengths; - int block_len_bits; /* log2 of current block length */ - int next_block_len_bits; /* log2 of next block length */ - int prev_block_len_bits; /* log2 of prev block length */ - int block_len; /* block length in samples */ - int block_num; /* block number in current frame */ - int block_pos; /* current position in frame */ - uint8_t ms_stereo; /* true if mid/side stereo mode */ - uint8_t channel_coded[MAX_CHANNELS]; /* true if channel is coded */ - int exponents_bsize[MAX_CHANNELS]; // log2 ratio frame/exp. length - fixed32 exponents[MAX_CHANNELS][BLOCK_MAX_SIZE] MEM_ALIGN_ATTR; - fixed32 max_exponent[MAX_CHANNELS]; - int16_t coefs1[MAX_CHANNELS][BLOCK_MAX_SIZE]; - fixed32 (*coefs)[MAX_CHANNELS][BLOCK_MAX_SIZE]; - fixed32 *windows[BLOCK_NB_SIZES]; - /* output buffer for one frame and the last for IMDCT windowing */ - fixed32 (*frame_out)[MAX_CHANNELS][BLOCK_MAX_SIZE*2]; - - /* last frame info */ - uint8_t last_superframe[MAX_CODED_SUPERFRAME_SIZE + 4] MEM_ALIGN_ATTR; /* padding added */ - int last_bitoffset; - int last_superframe_len; - fixed32 *noise_table; - int noise_index; - fixed32 noise_mult; /* XXX: suppress that and integrate it in the noise array */ - /* lsp_to_curve tables */ - fixed32 lsp_cos_table[BLOCK_MAX_SIZE] MEM_ALIGN_ATTR; - void *lsp_pow_m_table1; - void *lsp_pow_m_table2; - - /* State of current superframe decoding */ - int bit_offset; - int nb_frames; - int current_frame; - -#ifdef TRACE - - int frame_count; -#endif -} -WMADecodeContext; - -int wma_decode_init(WMADecodeContext* s, asf_waveformatex_t *wfx); -int wma_decode_superframe_init(WMADecodeContext* s, - const uint8_t *buf, int buf_size); -int wma_decode_superframe_frame(WMADecodeContext* s, - const uint8_t *buf, int buf_size); -#endif diff --git a/apps/codecs/libwma/wmadeci.c b/apps/codecs/libwma/wmadeci.c deleted file mode 100644 index d7a836dd97..0000000000 --- a/apps/codecs/libwma/wmadeci.c +++ /dev/null @@ -1,1445 +0,0 @@ -/* - * WMA compatible decoder - * Copyright (c) 2002 The FFmpeg Project. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/** - * @file wmadec.c - * WMA compatible decoder. - */ - -#include -#include -#include -#include "wmadec.h" -#include "wmafixed.h" -#include "wmadata.h" - -static void wma_lsp_to_curve_init(WMADecodeContext *s, int frame_len); - -/*declarations of statically allocated variables used to remove malloc calls*/ - -static fixed32 coefsarray[MAX_CHANNELS][BLOCK_MAX_SIZE] IBSS_ATTR MEM_ALIGN_ATTR; -/*decode and window into IRAM on targets with at least 80KB of codec IRAM*/ -static fixed32 frame_out_buf[MAX_CHANNELS][BLOCK_MAX_SIZE * 2] IBSS_ATTR_WMA_LARGE_IRAM MEM_ALIGN_ATTR; - -/*MDCT reconstruction windows*/ -static fixed32 stat0[2048] IBSS_ATTR_WMA_XL_IRAM MEM_ALIGN_ATTR; -static fixed32 stat1[1024] IBSS_ATTR_WMA_XL_IRAM MEM_ALIGN_ATTR; -static fixed32 stat2[ 512] IBSS_ATTR_WMA_XL_IRAM MEM_ALIGN_ATTR; -static fixed32 stat3[ 256] IBSS_ATTR_WMA_XL_IRAM MEM_ALIGN_ATTR; -static fixed32 stat4[ 128] IBSS_ATTR_WMA_XL_IRAM MEM_ALIGN_ATTR; - -/*VLC lookup tables*/ -static uint16_t *runtabarray[2]; -static uint16_t *levtabarray[2]; - -static uint16_t runtab_big[1336] MEM_ALIGN_ATTR; -static uint16_t runtab_small[1072] MEM_ALIGN_ATTR; -static uint16_t levtab_big[1336] MEM_ALIGN_ATTR; -static uint16_t levtab_small[1072] MEM_ALIGN_ATTR; - -#define VLCBUF1SIZE 4598 -#define VLCBUF2SIZE 3574 -#define VLCBUF3SIZE 360 -#define VLCBUF4SIZE 540 - -/*putting these in IRAM actually makes PP slower*/ - -static VLC_TYPE vlcbuf1[VLCBUF1SIZE][2] IBSS_ATTR_WMA_XL_IRAM MEM_ALIGN_ATTR; -static VLC_TYPE vlcbuf2[VLCBUF2SIZE][2] MEM_ALIGN_ATTR; -/* This buffer gets reused for lsp tables */ -static VLC_TYPE vlcbuf3[VLCBUF3SIZE][2] MEM_ALIGN_ATTR; -static VLC_TYPE vlcbuf4[VLCBUF4SIZE][2] MEM_ALIGN_ATTR; - - - - -/** - * Apply MDCT window and add into output. - * - * We ensure that when the windows overlap their squared sum - * is always 1 (MDCT reconstruction rule). - * - * The Vorbis I spec has a great diagram explaining this process. - * See section 1.3.2.3 of http://xiph.org/vorbis/doc/Vorbis_I_spec.html - */ - static void wma_window(WMADecodeContext *s, fixed32 *in, fixed32 *out) - { - //float *in = s->output; - int block_len, bsize, n; - - /* left part */ - - /* previous block was larger, so we'll use the size of the current - * block to set the window size*/ - if (s->block_len_bits <= s->prev_block_len_bits) { - block_len = s->block_len; - bsize = s->frame_len_bits - s->block_len_bits; - - vector_fmul_add_add(out, in, s->windows[bsize], block_len); - - } else { - /*previous block was smaller or the same size, so use it's size to set the window length*/ - block_len = 1 << s->prev_block_len_bits; - /*find the middle of the two overlapped blocks, this will be the first overlapped sample*/ - n = (s->block_len - block_len) / 2; - bsize = s->frame_len_bits - s->prev_block_len_bits; - - vector_fmul_add_add(out+n, in+n, s->windows[bsize], block_len); - - memcpy(out+n+block_len, in+n+block_len, n*sizeof(fixed32)); - } - /* Advance to the end of the current block and prepare to window it for the next block. - * Since the window function needs to be reversed, we do it backwards starting with the - * last sample and moving towards the first - */ - out += s->block_len; - in += s->block_len; - - /* right part */ - if (s->block_len_bits <= s->next_block_len_bits) { - block_len = s->block_len; - bsize = s->frame_len_bits - s->block_len_bits; - - vector_fmul_reverse(out, in, s->windows[bsize], block_len); - - } else { - block_len = 1 << s->next_block_len_bits; - n = (s->block_len - block_len) / 2; - bsize = s->frame_len_bits - s->next_block_len_bits; - - memcpy(out, in, n*sizeof(fixed32)); - - vector_fmul_reverse(out+n, in+n, s->windows[bsize], block_len); - - memset(out+n+block_len, 0, n*sizeof(fixed32)); - } - } - - - - -/* XXX: use same run/length optimization as mpeg decoders */ -static void init_coef_vlc(VLC *vlc, - uint16_t **prun_table, uint16_t **plevel_table, - const CoefVLCTable *vlc_table, int tab) -{ - int n = vlc_table->n; - const uint8_t *table_bits = vlc_table->huffbits; - const uint32_t *table_codes = vlc_table->huffcodes; - const uint16_t *levels_table = vlc_table->levels; - uint16_t *run_table, *level_table; - const uint16_t *p; - int i, l, j, level; - - - init_vlc(vlc, VLCBITS, n, table_bits, 1, 1, table_codes, 4, 4, INIT_VLC_USE_NEW_STATIC); - - run_table = runtabarray[tab]; - level_table= levtabarray[tab]; - - p = levels_table; - i = 2; - level = 1; - while (i < n) - { - l = *p++; - for(j=0;jmono*/ - s->channel_coded[0]=0; - s->channel_coded[1]=0; - s->ms_stereo=0; - - s->sample_rate = wfx->rate; - s->nb_channels = wfx->channels; - s->bit_rate = wfx->bitrate; - s->block_align = wfx->blockalign; - - s->coefs = &coefsarray; - s->frame_out = &frame_out_buf; - - if (wfx->codec_id == ASF_CODEC_ID_WMAV1) { - s->version = 1; - } else if (wfx->codec_id == ASF_CODEC_ID_WMAV2 ) { - s->version = 2; - } else { - /*one of those other wma flavors that don't have GPLed decoders */ - return -1; - } - - /* extract flag infos */ - flags2 = 0; - extradata = wfx->data; - if (s->version == 1 && wfx->datalen >= 4) { - flags2 = extradata[2] | (extradata[3] << 8); - }else if (s->version == 2 && wfx->datalen >= 6){ - flags2 = extradata[4] | (extradata[5] << 8); - } - s->use_exp_vlc = flags2 & 0x0001; - s->use_bit_reservoir = flags2 & 0x0002; - s->use_variable_block_len = flags2 & 0x0004; - - /* compute MDCT block size */ - if (s->sample_rate <= 16000){ - s->frame_len_bits = 9; - }else if (s->sample_rate <= 22050 || - (s->sample_rate <= 32000 && s->version == 1)){ - s->frame_len_bits = 10; - }else{ - s->frame_len_bits = 11; - } - s->frame_len = 1 << s->frame_len_bits; - if (s-> use_variable_block_len) - { - int nb_max, nb; - nb = ((flags2 >> 3) & 3) + 1; - if ((s->bit_rate / s->nb_channels) >= 32000) - { - nb += 2; - } - nb_max = s->frame_len_bits - BLOCK_MIN_BITS; //max is 11-7 - if (nb > nb_max) - nb = nb_max; - s->nb_block_sizes = nb + 1; - } - else - { - s->nb_block_sizes = 1; - } - - /* init rate dependant parameters */ - s->use_noise_coding = 1; - high_freq = itofix64(s->sample_rate) >> 1; - - - /* if version 2, then the rates are normalized */ - sample_rate1 = s->sample_rate; - if (s->version == 2) - { - if (sample_rate1 >= 44100) - sample_rate1 = 44100; - else if (sample_rate1 >= 22050) - sample_rate1 = 22050; - else if (sample_rate1 >= 16000) - sample_rate1 = 16000; - else if (sample_rate1 >= 11025) - sample_rate1 = 11025; - else if (sample_rate1 >= 8000) - sample_rate1 = 8000; - } - - fixed64 tmp = itofix64(s->bit_rate); - fixed64 tmp2 = itofix64(s->nb_channels * s->sample_rate); - bps = fixdiv64(tmp, tmp2); - fixed64 tim = bps * s->frame_len; - fixed64 tmpi = fixdiv64(tim,itofix64(8)); - s->byte_offset_bits = av_log2(fixtoi64(tmpi+0x8000)) + 2; - - /* compute high frequency value and choose if noise coding should - be activated */ - bps1 = bps; - if (s->nb_channels == 2) - bps1 = fixmul32(bps,0x1999a); - if (sample_rate1 == 44100) - { - if (bps1 >= 0x9c29) - s->use_noise_coding = 0; - else - high_freq = fixmul32(high_freq,0x6666); - } - else if (sample_rate1 == 22050) - { - if (bps1 >= 0x128f6) - s->use_noise_coding = 0; - else if (bps1 >= 0xb852) - high_freq = fixmul32(high_freq,0xb333); - else - high_freq = fixmul32(high_freq,0x999a); - } - else if (sample_rate1 == 16000) - { - if (bps > 0x8000) - high_freq = fixmul32(high_freq,0x8000); - else - high_freq = fixmul32(high_freq,0x4ccd); - } - else if (sample_rate1 == 11025) - { - high_freq = fixmul32(high_freq,0xb333); - } - else if (sample_rate1 == 8000) - { - if (bps <= 0xa000) - { - high_freq = fixmul32(high_freq,0x8000); - } - else if (bps > 0xc000) - { - s->use_noise_coding = 0; - } - else - { - high_freq = fixmul32(high_freq,0xa666); - } - } - else - { - if (bps >= 0xcccd) - { - high_freq = fixmul32(high_freq,0xc000); - } - else if (bps >= 0x999a) - { - high_freq = fixmul32(high_freq,0x999a); - } - else - { - high_freq = fixmul32(high_freq,0x8000); - } - } - - /* compute the scale factor band sizes for each MDCT block size */ - { - int a, b, pos, lpos, k, block_len, i, j, n; - const uint8_t *table; - - if (s->version == 1) - { - s->coefs_start = 3; - } - else - { - s->coefs_start = 0; - } - for(k = 0; k < s->nb_block_sizes; ++k) - { - block_len = s->frame_len >> k; - - if (s->version == 1) - { - lpos = 0; - for(i=0;i<25;++i) - { - a = wma_critical_freqs[i]; - b = s->sample_rate; - pos = ((block_len * 2 * a) + (b >> 1)) / b; - if (pos > block_len) - pos = block_len; - s->exponent_bands[0][i] = pos - lpos; - if (pos >= block_len) - { - ++i; - break; - } - lpos = pos; - } - s->exponent_sizes[0] = i; - } - else - { - /* hardcoded tables */ - table = NULL; - a = s->frame_len_bits - BLOCK_MIN_BITS - k; - if (a < 3) - { - if (s->sample_rate >= 44100) - table = exponent_band_44100[a]; - else if (s->sample_rate >= 32000) - table = exponent_band_32000[a]; - else if (s->sample_rate >= 22050) - table = exponent_band_22050[a]; - } - if (table) - { - n = *table++; - for(i=0;iexponent_bands[k][i] = table[i]; - s->exponent_sizes[k] = n; - } - else - { - j = 0; - lpos = 0; - for(i=0;i<25;++i) - { - a = wma_critical_freqs[i]; - b = s->sample_rate; - pos = ((block_len * 2 * a) + (b << 1)) / (4 * b); - pos <<= 2; - if (pos > block_len) - pos = block_len; - if (pos > lpos) - s->exponent_bands[k][j++] = pos - lpos; - if (pos >= block_len) - break; - lpos = pos; - } - s->exponent_sizes[k] = j; - } - } - - /* max number of coefs */ - s->coefs_end[k] = (s->frame_len - ((s->frame_len * 9) / 100)) >> k; - /* high freq computation */ - - fixed32 tmp1 = high_freq*2; /* high_freq is a fixed32!*/ - fixed32 tmp2=itofix32(s->sample_rate>>1); - s->high_band_start[k] = fixtoi32( fixdiv32(tmp1, tmp2) * (block_len>>1) +0x8000); - - /* - s->high_band_start[k] = (int)((block_len * 2 * high_freq) / - s->sample_rate + 0.5);*/ - - n = s->exponent_sizes[k]; - j = 0; - pos = 0; - for(i=0;iexponent_bands[k][i]; - end = pos; - if (start < s->high_band_start[k]) - start = s->high_band_start[k]; - if (end > s->coefs_end[k]) - end = s->coefs_end[k]; - if (end > start) - s->exponent_high_bands[k][j++] = end - start; - } - s->exponent_high_sizes[k] = j; - } - } - - /* ffmpeg uses malloc to only allocate as many window sizes as needed. - * However, we're really only interested in the worst case memory usage. - * In the worst case you can have 5 window sizes, 128 doubling up 2048 - * Smaller windows are handled differently. - * Since we don't have malloc, just statically allocate this - */ - fixed32 *temp[5]; - temp[0] = stat0; - temp[1] = stat1; - temp[2] = stat2; - temp[3] = stat3; - temp[4] = stat4; - - /* init MDCT windows : simple sinus window */ - for(i = 0; i < s->nb_block_sizes; i++) - { - int n, j; - fixed32 alpha; - n = 1 << (s->frame_len_bits - i); - window = temp[i]; - - /* this calculates 0.5/(2*n) */ - alpha = (1<<15)>>(s->frame_len_bits - i+1); - for(j=0;jwindows[i] = window; - - } - - s->reset_block_lengths = 1; - - if (s->use_noise_coding) - { - /* init the noise generator */ - if (s->use_exp_vlc) - { - s->noise_mult = 0x51f; - s->noise_table = noisetable_exp; - } - else - { - s->noise_mult = 0xa3d; - /* LSP values are simply 2x the EXP values */ - for (i=0;inoise_table = noisetable_exp; - } -#if 0 -/* We use a lookup table computered in advance, so no need to do this*/ - { - unsigned int seed; - fixed32 norm; - seed = 1; - norm = 0; // PJJ: near as makes any diff to 0! - for (i=0;inoise_table[i] = itofix32((int)seed) * norm; - } - } -#endif - - s->hgain_vlc.table = vlcbuf4; - s->hgain_vlc.table_allocated = VLCBUF4SIZE; - init_vlc(&s->hgain_vlc, HGAINVLCBITS, sizeof(hgain_huffbits), - hgain_huffbits, 1, 1, - hgain_huffcodes, 2, 2, INIT_VLC_USE_NEW_STATIC); - } - - if (s->use_exp_vlc) - { - - s->exp_vlc.table = vlcbuf3; - s->exp_vlc.table_allocated = VLCBUF3SIZE; - - init_vlc(&s->exp_vlc, EXPVLCBITS, sizeof(scale_huffbits), - scale_huffbits, 1, 1, - scale_huffcodes, 4, 4, INIT_VLC_USE_NEW_STATIC); - } - else - { - wma_lsp_to_curve_init(s, s->frame_len); - } - - /* choose the VLC tables for the coefficients */ - coef_vlc_table = 2; - if (s->sample_rate >= 32000) - { - if (bps1 < 0xb852) - coef_vlc_table = 0; - else if (bps1 < 0x128f6) - coef_vlc_table = 1; - } - - /* since the coef2 table is the biggest and that has index 2 in coef_vlcs - it's safe to always assign like this */ - runtabarray[0] = runtab_big; runtabarray[1] = runtab_small; - levtabarray[0] = levtab_big; levtabarray[1] = levtab_small; - - s->coef_vlc[0].table = vlcbuf1; - s->coef_vlc[0].table_allocated = VLCBUF1SIZE; - s->coef_vlc[1].table = vlcbuf2; - s->coef_vlc[1].table_allocated = VLCBUF2SIZE; - - - init_coef_vlc(&s->coef_vlc[0], &s->run_table[0], &s->level_table[0], - &coef_vlcs[coef_vlc_table * 2], 0); - init_coef_vlc(&s->coef_vlc[1], &s->run_table[1], &s->level_table[1], - &coef_vlcs[coef_vlc_table * 2 + 1], 1); - - s->last_superframe_len = 0; - s->last_bitoffset = 0; - - return 0; -} - - -/* compute x^-0.25 with an exponent and mantissa table. We use linear - interpolation to reduce the mantissa table size at a small speed - expense (linear interpolation approximately doubles the number of - bits of precision). */ -static inline fixed32 pow_m1_4(WMADecodeContext *s, fixed32 x) -{ - union { - float f; - unsigned int v; - } u, t; - unsigned int e, m; - fixed32 a, b; - - u.f = fixtof64(x); - e = u.v >> 23; - m = (u.v >> (23 - LSP_POW_BITS)) & ((1 << LSP_POW_BITS) - 1); - /* build interpolation scale: 1 <= t < 2. */ - t.v = ((u.v << LSP_POW_BITS) & ((1 << 23) - 1)) | (127 << 23); - a = ((fixed32*)s->lsp_pow_m_table1)[m]; - b = ((fixed32*)s->lsp_pow_m_table2)[m]; - - /* lsp_pow_e_table contains 32.32 format */ - /* TODO: Since we're unlikely have value that cover the whole - * IEEE754 range, we probably don't need to have all possible exponents */ - - return (lsp_pow_e_table[e] * (a + fixmul32(b, ftofix32(t.f))) >>32); -} - -static void wma_lsp_to_curve_init(WMADecodeContext *s, int frame_len) -{ - fixed32 wdel, a, b, temp2; - int i; - - wdel = fixdiv32(itofix32(1), itofix32(frame_len)); - for (i=0; ilsp_cos_table[i] = temp2>>3; - - } - /* NOTE: these two tables are needed to avoid two operations in - pow_m1_4 */ - b = itofix32(1); - int ix = 0; - - s->lsp_pow_m_table1 = &vlcbuf3[0]; - s->lsp_pow_m_table2 = &vlcbuf3[1<=0;i--) - { - a = pow_a_table[ix++]<<4; - ((fixed32*)s->lsp_pow_m_table1)[i] = 2 * a - b; - ((fixed32*)s->lsp_pow_m_table2)[i] = b - a; - b = a; - } - -} - -/* NOTE: We use the same code as Vorbis here */ -/* XXX: optimize it further with SSE/3Dnow */ -static void wma_lsp_to_curve(WMADecodeContext *s, - fixed32 *out, - fixed32 *val_max_ptr, - int n, - fixed32 *lsp) -{ - int i, j; - fixed32 p, q, w, v, val_max, temp2; - - val_max = 0; - for(i=0;ilsp_cos_table[i]; - - for (j=1;j>9; /* p/q end up as 16.16 */ - v = pow_m1_4(s, v); - if (v > val_max) - val_max = v; - out[i] = v; - } - - *val_max_ptr = val_max; -} - -/* decode exponents coded with LSP coefficients (same idea as Vorbis) - * only used for low bitrate (< 16kbps) files - */ -static void decode_exp_lsp(WMADecodeContext *s, int ch) -{ - fixed32 lsp_coefs[NB_LSP_COEFS]; - int val, i; - - for (i = 0; i < NB_LSP_COEFS; ++i) - { - if (i == 0 || i >= 8) - val = get_bits(&s->gb, 3); - else - val = get_bits(&s->gb, 4); - lsp_coefs[i] = lsp_codebook[i][val]; - } - - wma_lsp_to_curve(s, - s->exponents[ch], - &s->max_exponent[ch], - s->block_len, - lsp_coefs); -} - -/* decode exponents coded with VLC codes - used for bitrate >= 32kbps*/ -static int decode_exp_vlc(WMADecodeContext *s, int ch) -{ - int last_exp, n, code; - const uint16_t *ptr, *band_ptr; - fixed32 v, max_scale; - fixed32 *q,*q_end; - - /*accommodate the 60 negative indices */ - const fixed32 *pow_10_to_yover16_ptr = &pow_10_to_yover16[61]; - - band_ptr = s->exponent_bands[s->frame_len_bits - s->block_len_bits]; - ptr = band_ptr; - q = s->exponents[ch]; - q_end = q + s->block_len; - max_scale = 0; - - - if (s->version == 1) //wmav1 only - { - last_exp = get_bits(&s->gb, 5) + 10; - - v = pow_10_to_yover16_ptr[last_exp]; - max_scale = v; - n = *ptr++; - switch (n & 3) do { - case 0: *q++ = v; - case 3: *q++ = v; - case 2: *q++ = v; - case 1: *q++ = v; - } while ((n -= 4) > 0); - } else { - last_exp = 36; - } - - while (q < q_end) - { - code = get_vlc2(&s->gb, s->exp_vlc.table, EXPVLCBITS, EXPMAX); - if (code < 0) - { - return -1; - } - /* NOTE: this offset is the same as MPEG4 AAC ! */ - last_exp += code - 60; - - v = pow_10_to_yover16_ptr[last_exp]; - if (v > max_scale) - { - max_scale = v; - } - n = *ptr++; - switch (n & 3) do { - case 0: *q++ = v; - case 3: *q++ = v; - case 2: *q++ = v; - case 1: *q++ = v; - } while ((n -= 4) > 0); - } - - s->max_exponent[ch] = max_scale; - return 0; -} - -/* return 0 if OK. return 1 if last block of frame. return -1 if - unrecorrable error. */ -static int wma_decode_block(WMADecodeContext *s) -{ - int n, v, a, ch, code, bsize; - int coef_nb_bits, total_gain; - int nb_coefs[MAX_CHANNELS]; - fixed32 mdct_norm; - - /*DEBUGF("***decode_block: %d (%d samples of %d in frame)\n", s->block_num, s->block_len, s->frame_len);*/ - - /* compute current block length */ - if (s->use_variable_block_len) - { - n = av_log2(s->nb_block_sizes - 1) + 1; - - if (s->reset_block_lengths) - { - s->reset_block_lengths = 0; - v = get_bits(&s->gb, n); - if (v >= s->nb_block_sizes) - { - return -2; - } - s->prev_block_len_bits = s->frame_len_bits - v; - v = get_bits(&s->gb, n); - if (v >= s->nb_block_sizes) - { - return -3; - } - s->block_len_bits = s->frame_len_bits - v; - } - else - { - /* update block lengths */ - s->prev_block_len_bits = s->block_len_bits; - s->block_len_bits = s->next_block_len_bits; - } - v = get_bits(&s->gb, n); - - if (v >= s->nb_block_sizes) - { - // rb->splash(HZ*4, "v was %d", v); //5, 7 - return -4; //this is it - } - else{ - //rb->splash(HZ, "passed v block (%d)!", v); - } - s->next_block_len_bits = s->frame_len_bits - v; - } - else - { - /* fixed block len */ - s->next_block_len_bits = s->frame_len_bits; - s->prev_block_len_bits = s->frame_len_bits; - s->block_len_bits = s->frame_len_bits; - } - /* now check if the block length is coherent with the frame length */ - s->block_len = 1 << s->block_len_bits; - - if ((s->block_pos + s->block_len) > s->frame_len) - { - return -5; //oddly 32k sample from tracker fails here - } - - if (s->nb_channels == 2) - { - s->ms_stereo = get_bits1(&s->gb); - } - v = 0; - for (ch = 0; ch < s->nb_channels; ++ch) - { - a = get_bits1(&s->gb); - s->channel_coded[ch] = a; - v |= a; - } - /* if no channel coded, no need to go further */ - /* XXX: fix potential framing problems */ - if (!v) - { - goto next; - } - - bsize = s->frame_len_bits - s->block_len_bits; - - /* read total gain and extract corresponding number of bits for - coef escape coding */ - total_gain = 1; - for(;;) - { - a = get_bits(&s->gb, 7); - total_gain += a; - if (a != 127) - { - break; - } - } - - if (total_gain < 15) - coef_nb_bits = 13; - else if (total_gain < 32) - coef_nb_bits = 12; - else if (total_gain < 40) - coef_nb_bits = 11; - else if (total_gain < 45) - coef_nb_bits = 10; - else - coef_nb_bits = 9; - - /* compute number of coefficients */ - n = s->coefs_end[bsize] - s->coefs_start; - - for(ch = 0; ch < s->nb_channels; ++ch) - { - nb_coefs[ch] = n; - } - /* complex coding */ - if (s->use_noise_coding) - { - - for(ch = 0; ch < s->nb_channels; ++ch) - { - if (s->channel_coded[ch]) - { - int i, n, a; - n = s->exponent_high_sizes[bsize]; - for(i=0;igb); - s->high_band_coded[ch][i] = a; - /* if noise coding, the coefficients are not transmitted */ - if (a) - nb_coefs[ch] -= s->exponent_high_bands[bsize][i]; - } - } - } - for(ch = 0; ch < s->nb_channels; ++ch) - { - if (s->channel_coded[ch]) - { - int i, n, val, code; - - n = s->exponent_high_sizes[bsize]; - val = (int)0x80000000; - for(i=0;ihigh_band_coded[ch][i]) - { - if (val == (int)0x80000000) - { - val = get_bits(&s->gb, 7) - 19; - } - else - { - //code = get_vlc(&s->gb, &s->hgain_vlc); - code = get_vlc2(&s->gb, s->hgain_vlc.table, HGAINVLCBITS, HGAINMAX); - if (code < 0) - { - return -6; - } - val += code - 18; - } - s->high_band_values[ch][i] = val; - } - } - } - } - } - - /* exponents can be reused in short blocks. */ - if ((s->block_len_bits == s->frame_len_bits) || get_bits1(&s->gb)) - { - for(ch = 0; ch < s->nb_channels; ++ch) - { - if (s->channel_coded[ch]) - { - if (s->use_exp_vlc) - { - if (decode_exp_vlc(s, ch) < 0) - { - return -7; - } - } - else - { - decode_exp_lsp(s, ch); - } - s->exponents_bsize[ch] = bsize; - } - } - } - - /* parse spectral coefficients : just RLE encoding */ - for(ch = 0; ch < s->nb_channels; ++ch) - { - if (s->channel_coded[ch]) - { - VLC *coef_vlc; - int level, run, sign, tindex; - int16_t *ptr, *eptr; - const int16_t *level_table, *run_table; - - /* special VLC tables are used for ms stereo because - there is potentially less energy there */ - tindex = (ch == 1 && s->ms_stereo); - coef_vlc = &s->coef_vlc[tindex]; - run_table = s->run_table[tindex]; - level_table = s->level_table[tindex]; - /* XXX: optimize */ - ptr = &s->coefs1[ch][0]; - eptr = ptr + nb_coefs[ch]; - memset(ptr, 0, s->block_len * sizeof(int16_t)); - - for(;;) - { - code = get_vlc2(&s->gb, coef_vlc->table, VLCBITS, VLCMAX); - - if (code < 0) - { - return -8; - } - if (code == 1) - { - /* EOB */ - break; - } - else if (code == 0) - { - /* escape */ - level = get_bits(&s->gb, coef_nb_bits); - /* NOTE: this is rather suboptimal. reading - block_len_bits would be better */ - run = get_bits(&s->gb, s->frame_len_bits); - } - else - { - /* normal code */ - run = run_table[code]; - level = level_table[code]; - } - sign = get_bits1(&s->gb); - if (!sign) - level = -level; - ptr += run; - if (ptr >= eptr) - { - break; - } - *ptr++ = level; - - - /* NOTE: EOB can be omitted */ - if (ptr >= eptr) - break; - } - } - if (s->version == 1 && s->nb_channels >= 2) - { - align_get_bits(&s->gb); - } - } - - { - int n4 = s->block_len >> 1; - - - mdct_norm = 0x10000>>(s->block_len_bits-1); - - if (s->version == 1) - { - mdct_norm *= fixtoi32(fixsqrt32(itofix32(n4))); - } - } - - - /* finally compute the MDCT coefficients */ - for(ch = 0; ch < s->nb_channels; ++ch) - { - if (s->channel_coded[ch]) - { - int16_t *coefs1; - fixed32 *exponents; - fixed32 *coefs, atemp; - fixed64 mult; - fixed64 mult1; - fixed32 noise, temp1, temp2, mult2; - int i, j, n, n1, last_high_band, esize; - fixed32 exp_power[HIGH_BAND_MAX_SIZE]; - - //total_gain, coefs1, mdctnorm are lossless - - coefs1 = s->coefs1[ch]; - exponents = s->exponents[ch]; - esize = s->exponents_bsize[ch]; - coefs = (*(s->coefs))[ch]; - n=0; - - /* - * The calculation of coefs has a shift right by 2 built in. This - * prepares samples for the Tremor IMDCT which uses a slightly - * different fixed format then the ffmpeg one. If the old ffmpeg - * imdct is used, each shift storing into coefs should be reduced - * by 1. - * See SVN logs for details. - */ - - - if (s->use_noise_coding) - { - /*This case is only used for low bitrates (typically less then 32kbps)*/ - - /*TODO: mult should be converted to 32 bit to speed up noise coding*/ - - mult = fixdiv64(pow_table[total_gain+20],Fixed32To64(s->max_exponent[ch])); - mult = mult* mdct_norm; - mult1 = mult; - - /* very low freqs : noise */ - for(i = 0;i < s->coefs_start; ++i) - { - *coefs++ = fixmul32( (fixmul32(s->noise_table[s->noise_index], - exponents[i<>esize])>>4),Fixed32From64(mult1)) >>2; - s->noise_index = (s->noise_index + 1) & (NOISE_TAB_SIZE - 1); - } - - n1 = s->exponent_high_sizes[bsize]; - - /* compute power of high bands */ - exponents = s->exponents[ch] +(s->high_band_start[bsize]<exponent_high_bands[s->frame_len_bits - - s->block_len_bits][j]; - if (s->high_band_coded[ch][j]) - { - fixed32 e2, v; - e2 = 0; - for(i = 0;i < n; ++i) - { - /*v is normalized later on so its fixed format is irrelevant*/ - v = exponents[i<>esize]>>4; - e2 += fixmul32(v, v)>>3; - } - exp_power[j] = e2/n; /*n is an int...*/ - last_high_band = j; - } - exponents += n<exponents[ch] + (s->coefs_start<high_band_start[bsize] - - s->coefs_start; - } - else - { - n = s->exponent_high_bands[s->frame_len_bits - - s->block_len_bits][j]; - } - if (j >= 0 && s->high_band_coded[ch][j]) - { - /* use noise with specified power */ - fixed32 tmp = fixdiv32(exp_power[j],exp_power[last_high_band]); - - /*mult1 is 48.16, pow_table is 48.16*/ - mult1 = fixmul32(fixsqrt32(tmp), - pow_table[s->high_band_values[ch][j]+20]) >> 16; - - /*this step has a fairly high degree of error for some reason*/ - mult1 = fixdiv64(mult1,fixmul32(s->max_exponent[ch],s->noise_mult)); - mult1 = mult1*mdct_norm>>PRECISION; - for(i = 0;i < n; ++i) - { - noise = s->noise_table[s->noise_index]; - s->noise_index = (s->noise_index + 1) & (NOISE_TAB_SIZE - 1); - *coefs++ = fixmul32((fixmul32(exponents[i<>esize],noise)>>4), - Fixed32From64(mult1)) >>2; - - } - exponents += n<noise_table[s->noise_index]; - s->noise_index = (s->noise_index + 1) & (NOISE_TAB_SIZE - 1); - - /*don't forget to renormalize the noise*/ - temp1 = (((int32_t)*coefs1++)<<16) + (noise>>4); - temp2 = fixmul32(exponents[i<>esize], mult>>18); - *coefs++ = fixmul32(temp1, temp2); - } - exponents += n<block_len - s->coefs_end[bsize]; - mult2 = fixmul32(mult>>16,exponents[((-1<>esize]) ; - for (i = 0; i < n; ++i) - { - /*renormalize the noise product and then reduce to 14.18 precison*/ - *coefs++ = fixmul32(s->noise_table[s->noise_index],mult2) >>6; - - s->noise_index = (s->noise_index + 1) & (NOISE_TAB_SIZE - 1); - } - } - else - { - /*Noise coding not used, simply convert from exp to fixed representation*/ - - fixed32 mult3 = (fixed32)(fixdiv64(pow_table[total_gain+20], - Fixed32To64(s->max_exponent[ch]))); - mult3 = fixmul32(mult3, mdct_norm); - - /*zero the first 3 coefficients for WMA V1, does nothing otherwise*/ - for(i=0; icoefs_start; i++) - *coefs++=0; - - n = nb_coefs[ch]; - - /* XXX: optimize more, unrolling this loop in asm - might be a good idea */ - - for(i = 0;i < n; ++i) - { - /*ffmpeg imdct needs 15.17, while tremor 14.18*/ - atemp = (coefs1[i] * mult3)>>2; - *coefs++=fixmul32(atemp,exponents[i<>esize]); - } - n = s->block_len - s->coefs_end[bsize]; - memset(coefs, 0, n*sizeof(fixed32)); - } - } - } - - - - if (s->ms_stereo && s->channel_coded[1]) - { - fixed32 a, b; - int i; - fixed32 (*coefs)[MAX_CHANNELS][BLOCK_MAX_SIZE] = (s->coefs); - - /* nominal case for ms stereo: we do it before mdct */ - /* no need to optimize this case because it should almost - never happen */ - if (!s->channel_coded[0]) - { - memset((*(s->coefs))[0], 0, sizeof(fixed32) * s->block_len); - s->channel_coded[0] = 1; - } - - for(i = 0; i < s->block_len; ++i) - { - a = (*coefs)[0][i]; - b = (*coefs)[1][i]; - (*coefs)[0][i] = a + b; - (*coefs)[1][i] = a - b; - } - } - - for(ch = 0; ch < s->nb_channels; ++ch) - { - /* BLOCK_MAX_SIZE is 2048 (samples) and MAX_CHANNELS is 2. */ - static uint32_t scratch_buf[BLOCK_MAX_SIZE * MAX_CHANNELS] IBSS_ATTR MEM_ALIGN_ATTR; - if (s->channel_coded[ch]) - { - int n4, index; - - n4 = s->block_len >>1; - - ff_imdct_calc((s->frame_len_bits - bsize + 1), - scratch_buf, - (*(s->coefs))[ch]); - - /* add in the frame */ - index = (s->frame_len / 2) + s->block_pos - n4; - wma_window(s, scratch_buf, &((*s->frame_out)[ch][index])); - - - - /* specific fast case for ms-stereo : add to second - channel if it is not coded */ - if (s->ms_stereo && !s->channel_coded[1]) - { - wma_window(s, scratch_buf, &((*s->frame_out)[1][index])); - } - } - } -next: - /* update block number */ - ++s->block_num; - s->block_pos += s->block_len; - if (s->block_pos >= s->frame_len) - { - return 1; - } - else - { - return 0; - } -} - -/* decode a frame of frame_len samples */ -static int wma_decode_frame(WMADecodeContext *s) -{ - int ret; - - /* read each block */ - s->block_num = 0; - s->block_pos = 0; - - - for(;;) - { - ret = wma_decode_block(s); - if (ret < 0) - { - - DEBUGF("wma_decode_block failed with code %d\n", ret); - return -1; - } - if (ret) - { - break; - } - } - - return 0; -} - -/* Initialise the superframe decoding */ - -int wma_decode_superframe_init(WMADecodeContext* s, - const uint8_t *buf, /*input*/ - int buf_size) -{ - if (buf_size==0) - { - s->last_superframe_len = 0; - return 0; - } - - s->current_frame = 0; - - init_get_bits(&s->gb, buf, buf_size*8); - - if (s->use_bit_reservoir) - { - /* read super frame header */ - skip_bits(&s->gb, 4); /* super frame index */ - s->nb_frames = get_bits(&s->gb, 4); - - if (s->last_superframe_len == 0) - s->nb_frames --; - else if (s->nb_frames == 0) - s->nb_frames++; - - s->bit_offset = get_bits(&s->gb, s->byte_offset_bits + 3); - } else { - s->nb_frames = 1; - } - - return 1; -} - - -/* Decode a single frame in the current superframe - return -1 if - there was a decoding error, or the number of samples decoded. -*/ - -int wma_decode_superframe_frame(WMADecodeContext* s, - const uint8_t *buf, /*input*/ - int buf_size) -{ - int pos, len, ch; - uint8_t *q; - int done = 0; - - for(ch = 0; ch < s->nb_channels; ch++) - memmove(&((*s->frame_out)[ch][0]), - &((*s->frame_out)[ch][s->frame_len]), - s->frame_len * sizeof(fixed32)); - - if ((s->use_bit_reservoir) && (s->current_frame == 0)) - { - if (s->last_superframe_len > 0) - { - /* add s->bit_offset bits to last frame */ - if ((s->last_superframe_len + ((s->bit_offset + 7) >> 3)) > - MAX_CODED_SUPERFRAME_SIZE) - { - DEBUGF("superframe size too large error\n"); - goto fail; - } - q = s->last_superframe + s->last_superframe_len; - len = s->bit_offset; - while (len > 7) - { - *q++ = (get_bits)(&s->gb, 8); - len -= 8; - } - if (len > 0) - { - *q++ = (get_bits)(&s->gb, len) << (8 - len); - } - - /* XXX: s->bit_offset bits into last frame */ - init_get_bits(&s->gb, s->last_superframe, MAX_CODED_SUPERFRAME_SIZE*8); - /* skip unused bits */ - if (s->last_bitoffset > 0) - skip_bits(&s->gb, s->last_bitoffset); - - /* this frame is stored in the last superframe and in the - current one */ - if (wma_decode_frame(s) < 0) - { - goto fail; - } - done = 1; - } - - /* read each frame starting from s->bit_offset */ - pos = s->bit_offset + 4 + 4 + s->byte_offset_bits + 3; - init_get_bits(&s->gb, buf + (pos >> 3), (MAX_CODED_SUPERFRAME_SIZE - (pos >> 3))*8); - len = pos & 7; - if (len > 0) - skip_bits(&s->gb, len); - - s->reset_block_lengths = 1; - } - - /* If we haven't decoded a frame yet, do it now */ - if (!done) - { - if (wma_decode_frame(s) < 0) - { - goto fail; - } - } - - s->current_frame++; - - if ((s->use_bit_reservoir) && (s->current_frame == s->nb_frames)) - { - /* we copy the end of the frame in the last frame buffer */ - pos = get_bits_count(&s->gb) + ((s->bit_offset + 4 + 4 + s->byte_offset_bits + 3) & ~7); - s->last_bitoffset = pos & 7; - pos >>= 3; - len = buf_size - pos; - if (len > MAX_CODED_SUPERFRAME_SIZE || len < 0) - { - DEBUGF("superframe size too large error after decoding\n"); - goto fail; - } - s->last_superframe_len = len; - memcpy(s->last_superframe, buf + pos, len); - } - - return s->frame_len; - -fail: - /* when error, we reset the bit reservoir */ - - s->last_superframe_len = 0; - return -1; -} - diff --git a/apps/codecs/libwma/wmafixed.c b/apps/codecs/libwma/wmafixed.c deleted file mode 100644 index bdf87a548b..0000000000 --- a/apps/codecs/libwma/wmafixed.c +++ /dev/null @@ -1,223 +0,0 @@ -/**************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * - * Copyright (C) 2007 Michael Giacomelli - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ - -#include "wmadec.h" -#include "wmafixed.h" -#include - -fixed64 IntTo64(int x){ - fixed64 res = 0; - unsigned char *p = (unsigned char *)&res; - -#ifdef ROCKBOX_BIG_ENDIAN - p[5] = x & 0xff; - p[4] = (x & 0xff00)>>8; - p[3] = (x & 0xff0000)>>16; - p[2] = (x & 0xff000000)>>24; -#else - p[2] = x & 0xff; - p[3] = (x & 0xff00)>>8; - p[4] = (x & 0xff0000)>>16; - p[5] = (x & 0xff000000)>>24; -#endif - return res; -} - -int IntFrom64(fixed64 x) -{ - int res = 0; - unsigned char *p = (unsigned char *)&x; - -#ifdef ROCKBOX_BIG_ENDIAN - res = p[5] | (p[4]<<8) | (p[3]<<16) | (p[2]<<24); -#else - res = p[2] | (p[3]<<8) | (p[4]<<16) | (p[5]<<24); -#endif - return res; -} - -fixed32 Fixed32From64(fixed64 x) -{ - return x & 0xFFFFFFFF; -} - -fixed64 Fixed32To64(fixed32 x) -{ - return (fixed64)x; -} - -/* - Not performance senstitive code here - -*/ - -fixed32 fixdiv32(fixed32 x, fixed32 y) -{ - fixed64 temp; - - if(x == 0) - return 0; - if(y == 0) - return 0x7fffffff; - temp = x; - temp <<= PRECISION; - return (fixed32)(temp / y); -} - -fixed64 fixdiv64(fixed64 x, fixed64 y) -{ - fixed64 temp; - - if(x == 0) - return 0; - if(y == 0) - return 0x07ffffffffffffffLL; - temp = x; - temp <<= PRECISION64; - return (fixed64)(temp / y); -} - - fixed32 fixsqrt32(fixed32 x) -{ - - unsigned long r = 0, s, v = (unsigned long)x; - -#define STEP(k) s = r + (1 << k * 2); r >>= 1; \ - if (s <= v) { v -= s; r |= (1 << k * 2); } - - STEP(15); - STEP(14); - STEP(13); - STEP(12); - STEP(11); - STEP(10); - STEP(9); - STEP(8); - STEP(7); - STEP(6); - STEP(5); - STEP(4); - STEP(3); - STEP(2); - STEP(1); - STEP(0); - - return (fixed32)(r << (PRECISION / 2)); -} - - - static const long cordic_circular_gain = 0xb2458939; /* 0.607252929 */ - - /* Table of values of atan(2^-i) in 0.32 format fractions of pi where pi = 0xffffffff / 2 */ - static const unsigned long atan_table[] = { - 0x1fffffff, /* +0.785398163 (or pi/4) */ - 0x12e4051d, /* +0.463647609 */ - 0x09fb385b, /* +0.244978663 */ - 0x051111d4, /* +0.124354995 */ - 0x028b0d43, /* +0.062418810 */ - 0x0145d7e1, /* +0.031239833 */ - 0x00a2f61e, /* +0.015623729 */ - 0x00517c55, /* +0.007812341 */ - 0x0028be53, /* +0.003906230 */ - 0x00145f2e, /* +0.001953123 */ - 0x000a2f98, /* +0.000976562 */ - 0x000517cc, /* +0.000488281 */ - 0x00028be6, /* +0.000244141 */ - 0x000145f3, /* +0.000122070 */ - 0x0000a2f9, /* +0.000061035 */ - 0x0000517c, /* +0.000030518 */ - 0x000028be, /* +0.000015259 */ - 0x0000145f, /* +0.000007629 */ - 0x00000a2f, /* +0.000003815 */ - 0x00000517, /* +0.000001907 */ - 0x0000028b, /* +0.000000954 */ - 0x00000145, /* +0.000000477 */ - 0x000000a2, /* +0.000000238 */ - 0x00000051, /* +0.000000119 */ - 0x00000028, /* +0.000000060 */ - 0x00000014, /* +0.000000030 */ - 0x0000000a, /* +0.000000015 */ - 0x00000005, /* +0.000000007 */ - 0x00000002, /* +0.000000004 */ - 0x00000001, /* +0.000000002 */ - 0x00000000, /* +0.000000001 */ - 0x00000000, /* +0.000000000 */ - }; - - /** - * Implements sin and cos using CORDIC rotation. - * - * @param phase has range from 0 to 0xffffffff, representing 0 and - * 2*pi respectively. - * @param cos return address for cos - * @return sin of phase, value is a signed value from LONG_MIN to LONG_MAX, - * representing -1 and 1 respectively. - * - * Gives at least 24 bits precision (last 2-8 bits or so are probably off) - */ - - long fsincos(unsigned long phase, fixed32 *cos) - { - int32_t x, x1, y, y1; - unsigned long z, z1; - int i; - - /* Setup initial vector */ - x = cordic_circular_gain; - y = 0; - z = phase; - - /* The phase has to be somewhere between 0..pi for this to work right */ - if (z < 0xffffffff / 4) { - /* z in first quadrant, z += pi/2 to correct */ - x = -x; - z += 0xffffffff / 4; - } else if (z < 3 * (0xffffffff / 4)) { - /* z in third quadrant, z -= pi/2 to correct */ - z -= 0xffffffff / 4; - } else { - /* z in fourth quadrant, z -= 3pi/2 to correct */ - x = -x; - z -= 3 * (0xffffffff / 4); - } - - /* Each iteration adds roughly 1-bit of extra precision */ - for (i = 0; i < 31; i++) { - x1 = x >> i; - y1 = y >> i; - z1 = atan_table[i]; - - /* Decided which direction to rotate vector. Pivot point is pi/2 */ - if (z >= 0xffffffff / 4) { - x -= y1; - y += x1; - z -= z1; - } else { - x += y1; - y -= x1; - z += z1; - } - } - - if (cos) - *cos = x; - - return y; - } diff --git a/apps/codecs/libwma/wmafixed.h b/apps/codecs/libwma/wmafixed.h deleted file mode 100644 index 4225f165c9..0000000000 --- a/apps/codecs/libwma/wmafixed.h +++ /dev/null @@ -1,237 +0,0 @@ -/**************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * - * Copyright (C) 2007 Michael Giacomelli - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ - -/* fixed precision code. We use a combination of Sign 15.16 and Sign.31 - precision here. - - The WMA decoder does not always follow this convention, and occasionally - renormalizes values to other formats in order to maximize precision. - However, only the two precisions above are provided in this file. - -*/ - -#include "types.h" - -#define PRECISION 16 -#define PRECISION64 16 - - -#define fixtof64(x) (float)((float)(x) / (float)(1 << PRECISION64)) //does not work on int64_t! -#define ftofix32(x) ((fixed32)((x) * (float)(1 << PRECISION) + ((x) < 0 ? -0.5 : 0.5))) -#define itofix64(x) (IntTo64(x)) -#define itofix32(x) ((x) << PRECISION) -#define fixtoi32(x) ((x) >> PRECISION) -#define fixtoi64(x) (IntFrom64(x)) - - -/*fixed functions*/ - -fixed64 IntTo64(int x); -int IntFrom64(fixed64 x); -fixed32 Fixed32From64(fixed64 x); -fixed64 Fixed32To64(fixed32 x); -fixed32 fixdiv32(fixed32 x, fixed32 y); -fixed64 fixdiv64(fixed64 x, fixed64 y); -fixed32 fixsqrt32(fixed32 x); -/* Inverse gain of circular cordic rotation in s0.31 format. */ -long fsincos(unsigned long phase, fixed32 *cos); - - -#ifdef CPU_ARM - -/*Sign-15.16 format */ -#define fixmul32(x, y) \ - ({ int32_t __hi; \ - uint32_t __lo; \ - int32_t __result; \ - asm ("smull %0, %1, %3, %4\n\t" \ - "movs %0, %0, lsr %5\n\t" \ - "adc %2, %0, %1, lsl %6" \ - : "=&r" (__lo), "=&r" (__hi), "=r" (__result) \ - : "%r" (x), "r" (y), \ - "M" (PRECISION), "M" (32 - PRECISION) \ - : "cc"); \ - __result; \ - }) - -#elif defined(CPU_COLDFIRE) - -static inline int32_t fixmul32(int32_t x, int32_t y) -{ -#if PRECISION != 16 -#warning Coldfire fixmul32() only works for PRECISION == 16 -#endif - int32_t t1; - asm ( - "mac.l %[x], %[y], %%acc0 \n" // multiply - "mulu.l %[y], %[x] \n" // get lower half, avoid emac stall - "movclr.l %%acc0, %[t1] \n" // get higher half - "lsr.l #1, %[t1] \n" - "move.w %[t1], %[x] \n" - "swap %[x] \n" - : [t1] "=&d" (t1), [x] "+d" (x) - : [y] "d" (y) - ); - return x; -} - -#else - -static inline fixed32 fixmul32(fixed32 x, fixed32 y) -{ - fixed64 temp; - temp = x; - temp *= y; - - temp >>= PRECISION; - - return (fixed32)temp; -} - -#endif - - -/* - * Helper functions for wma_window. - * - * - */ - -#ifdef CPU_ARM -static inline void vector_fmul_add_add(fixed32 *dst, const fixed32 *data, - const fixed32 *window, int n) -{ - /* Block sizes are always power of two */ - asm volatile ( - "0:" - "ldmia %[d]!, {r0, r1};" - "ldmia %[w]!, {r4, r5};" - /* consume the first data and window value so we can use those - * registers again */ - "smull r8, r9, r0, r4;" - "ldmia %[dst], {r0, r4};" - "add r0, r0, r9, lsl #1;" /* *dst=*dst+(r9<<1)*/ - "smull r8, r9, r1, r5;" - "add r1, r4, r9, lsl #1;" - "stmia %[dst]!, {r0, r1};" - "subs %[n], %[n], #2;" - "bne 0b;" - : [d] "+r" (data), [w] "+r" (window), [dst] "+r" (dst), [n] "+r" (n) - : : "r0", "r1", "r4", "r5", "r8", "r9", "memory", "cc"); -} - -static inline void vector_fmul_reverse(fixed32 *dst, const fixed32 *src0, const fixed32 *src1, - int len) -{ - /* Block sizes are always power of two */ - asm volatile ( - "add %[s1], %[s1], %[n], lsl #2;" - "0:" - "ldmia %[s0]!, {r0, r1};" - "ldmdb %[s1]!, {r4, r5};" - "smull r8, r9, r0, r5;" - "mov r0, r9, lsl #1;" - "smull r8, r9, r1, r4;" - "mov r1, r9, lsl #1;" - "stmia %[dst]!, {r0, r1};" - "subs %[n], %[n], #2;" - "bne 0b;" - : [s0] "+r" (src0), [s1] "+r" (src1), [dst] "+r" (dst), [n] "+r" (len) - : : "r0", "r1", "r4", "r5", "r8", "r9", "memory", "cc"); -} - -#elif defined(CPU_COLDFIRE) - -static inline void vector_fmul_add_add(fixed32 *dst, const fixed32 *data, - const fixed32 *window, int n) -{ - /* Block sizes are always power of two. Smallest block is always way bigger - * than four too.*/ - asm volatile ( - "0:" - "movem.l (%[d]), %%d0-%%d3;" - "movem.l (%[w]), %%d4-%%d5/%%a0-%%a1;" - "mac.l %%d0, %%d4, %%acc0;" - "mac.l %%d1, %%d5, %%acc1;" - "mac.l %%d2, %%a0, %%acc2;" - "mac.l %%d3, %%a1, %%acc3;" - "lea.l (16, %[d]), %[d];" - "lea.l (16, %[w]), %[w];" - "movclr.l %%acc0, %%d0;" - "movclr.l %%acc1, %%d1;" - "movclr.l %%acc2, %%d2;" - "movclr.l %%acc3, %%d3;" - "movem.l (%[dst]), %%d4-%%d5/%%a0-%%a1;" - "add.l %%d4, %%d0;" - "add.l %%d5, %%d1;" - "add.l %%a0, %%d2;" - "add.l %%a1, %%d3;" - "movem.l %%d0-%%d3, (%[dst]);" - "lea.l (16, %[dst]), %[dst];" - "subq.l #4, %[n];" - "jne 0b;" - : [d] "+a" (data), [w] "+a" (window), [dst] "+a" (dst), [n] "+d" (n) - : : "d0", "d1", "d2", "d3", "d4", "d5", "a0", "a1", "memory", "cc"); -} - -static inline void vector_fmul_reverse(fixed32 *dst, const fixed32 *src0, const fixed32 *src1, - int len) -{ - /* Block sizes are always power of two. Smallest block is always way bigger - * than four too.*/ - asm volatile ( - "lea.l (-16, %[s1], %[n]*4), %[s1];" - "0:" - "movem.l (%[s0]), %%d0-%%d3;" - "movem.l (%[s1]), %%d4-%%d5/%%a0-%%a1;" - "mac.l %%d0, %%a1, %%acc0;" - "mac.l %%d1, %%a0, %%acc1;" - "mac.l %%d2, %%d5, %%acc2;" - "mac.l %%d3, %%d4, %%acc3;" - "lea.l (16, %[s0]), %[s0];" - "lea.l (-16, %[s1]), %[s1];" - "movclr.l %%acc0, %%d0;" - "movclr.l %%acc1, %%d1;" - "movclr.l %%acc2, %%d2;" - "movclr.l %%acc3, %%d3;" - "movem.l %%d0-%%d3, (%[dst]);" - "lea.l (16, %[dst]), %[dst];" - "subq.l #4, %[n];" - "jne 0b;" - : [s0] "+a" (src0), [s1] "+a" (src1), [dst] "+a" (dst), [n] "+d" (len) - : : "d0", "d1", "d2", "d3", "d4", "d5", "a0", "a1", "memory", "cc"); -} - -#else - -static inline void vector_fmul_add_add(fixed32 *dst, const fixed32 *src0, const fixed32 *src1, int len){ - int i; - for(i=0; i ) \___| < | \_\ ( <_> > < < -# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ -# \/ \/ \/ \/ \/ -# $Id$ -# - -# libwmapro -WMAPROLIB := $(CODECDIR)/libwmapro.a -WMAPROLIB_SRC := $(call preprocess, $(APPSDIR)/codecs/libwmapro/SOURCES) -WMAPROLIB_OBJ := $(call c2obj, $(WMAPROLIB_SRC)) -OTHER_SRC += $(WMAPROLIB_SRC) - -$(WMAPROLIB): $(WMAPROLIB_OBJ) - $(SILENT)$(shell rm -f $@) - $(call PRINTS,AR $(@F))$(AR) rcs $@ $^ >/dev/null diff --git a/apps/codecs/libwmapro/mdct_tables.c b/apps/codecs/libwmapro/mdct_tables.c deleted file mode 100644 index bec3c37ee7..0000000000 --- a/apps/codecs/libwmapro/mdct_tables.c +++ /dev/null @@ -1,3391 +0,0 @@ -#include "wmaprodec.h" -#include - -/* Tables for fixed-point trig tables for windowing and mdct */ - -/* Windowing trig tables in s.31 format */ -const int32_t sine_4096[] = { - 0xFFF9B782, 0xFFED2685, 0xFFE09587, 0xFFD4048A, 0xFFC7738D, 0xFFBAE291, - 0xFFAE5196, 0xFFA1C09B, 0xFF952FA1, 0xFF889EA8, 0xFF7C0DB1, 0xFF6F7CBB, - 0xFF62EBC5, 0xFF565AD3, 0xFF49C9E1, 0xFF3D38F0, 0xFF30A803, 0xFF241716, - 0xFF17862C, 0xFF0AF545, 0xFEFE645F, 0xFEF1D37C, 0xFEE5429B, 0xFED8B1BD, - 0xFECC20E4, 0xFEBF900C, 0xFEB2FF37, 0xFEA66E65, 0xFE99DD96, 0xFE8D4CCB, - 0xFE80BC06, 0xFE742B42, 0xFE679A82, 0xFE5B09C6, 0xFE4E790E, 0xFE41E85A, - 0xFE3557AD, 0xFE28C702, 0xFE1C365B, 0xFE0FA5B9, 0xFE03151C, 0xFDF68484, - 0xFDE9F3F3, 0xFDDD6363, 0xFDD0D2DC, 0xFDC4425A, 0xFDB7B1DB, 0xFDAB2164, - 0xFD9E90F0, 0xFD920085, 0xFD85701D, 0xFD78DFBE, 0xFD6C4F66, 0xFD5FBF10, - 0xFD532EC5, 0xFD469E7C, 0xFD3A0E3E, 0xFD2D7E07, 0xFD20EDD2, 0xFD145DA9, - 0xFD07CD83, 0xFCFB3D68, 0xFCEEAD51, 0xFCE21D46, 0xFCD58D42, 0xFCC8FD41, - 0xFCBC6D4D, 0xFCAFDD5D, 0xFCA34D79, 0xFC96BD9D, 0xFC8A2DC6, 0xFC7D9DFB, - 0xFC710E35, 0xFC647E7C, 0xFC57EEC8, 0xFC4B5F20, 0xFC3ECF82, 0xFC323FE9, - 0xFC25B05D, 0xFC1920D7, 0xFC0C915F, 0xFC0001F0, 0xFBF37287, 0xFBE6E329, - 0xFBDA53DC, 0xFBCDC491, 0xFBC13551, 0xFBB4A624, 0xFBA816F8, 0xFB9B87D8, - 0xFB8EF8C3, 0xFB8269C0, 0xFB75DAC1, 0xFB694BCC, 0xFB5CBCEB, 0xFB502E0E, - 0xFB439F3C, 0xFB371076, 0xFB2A81C3, 0xFB1DF315, 0xFB116472, 0xFB04D5E4, - 0xFAF8475A, 0xFAEBB8DC, 0xFADF2A73, 0xFAD29C0F, 0xFAC60DB7, 0xFAB97F6C, - 0xFAACF137, 0xFAA06306, 0xFA93D4E3, 0xFA8746D5, 0xFA7AB8CC, 0xFA6E2AD1, - 0xFA619CE4, 0xFA550F0D, 0xFA48813C, 0xFA3BF379, 0xFA2F65CC, 0xFA22D825, - 0xFA164A8D, 0xFA09BD04, 0xF9FD2F91, 0xF9F0A225, 0xF9E414C8, 0xF9D78782, - 0xF9CAFA43, 0xF9BE6D14, 0xF9B1DFFC, 0xF9A552EB, 0xF998C5EB, 0xF98C38FA, - 0xF97FAC21, 0xF9731F50, 0xF966928F, 0xF95A05E6, 0xF94D7946, 0xF940ECB6, - 0xF9346037, 0xF927D3D1, 0xF91B4774, 0xF90EBB28, 0xF9022EF4, 0xF8F5A2CA, - 0xF8E916B2, 0xF8DC8AAB, 0xF8CFFEBD, 0xF8C372DA, 0xF8B6E708, 0xF8AA5B50, - 0xF89DCFA2, 0xF8914407, 0xF884B885, 0xF8782D0F, 0xF86BA1AA, 0xF85F1659, - 0xF8528B22, 0xF845FFF6, 0xF83974DE, 0xF82CE9E0, 0xF8205EEE, 0xF813D40F, - 0xF8074944, 0xF7FABE95, 0xF7EE33F1, 0xF7E1A961, 0xF7D51EE5, 0xF7C8947E, - 0xF7BC0A3A, 0xF7AF7FFB, 0xF7A2F5D1, 0xF7966BBB, 0xF789E1BA, 0xF77D57CE, - 0xF770CDF7, 0xF7644445, 0xF757BA98, 0xF74B3100, 0xF73EA77E, 0xF7321E12, - 0xF72594BB, 0xF7190B7B, 0xF70C8260, 0xF6FFF94B, 0xF6F3704C, 0xF6E6E764, - 0xF6DA5E92, 0xF6CDD5D7, 0xF6C14D43, 0xF6B4C4B5, 0xF6A83C3E, 0xF69BB3DE, - 0xF68F2B96, 0xF682A365, 0xF6761B4B, 0xF6699358, 0xF65D0B6E, 0xF650839B, - 0xF643FBE0, 0xF637743D, 0xF62AECB2, 0xF61E6540, 0xF611DDF5, 0xF60556B4, - 0xF5F8CF8B, 0xF5EC487A, 0xF5DFC183, 0xF5D33AA4, 0xF5C6B3DF, 0xF5BA2D43, - 0xF5ADA6B0, 0xF5A12037, 0xF59499D7, 0xF5881391, 0xF57B8D65, 0xF56F0753, - 0xF562816B, 0xF555FB8D, 0xF54975C9, 0xF53CF020, 0xF5306A91, 0xF523E51D, - 0xF5175FC4, 0xF50ADA96, 0xF4FE5572, 0xF4F1D06A, 0xF4E54B7D, 0xF4D8C6AC, - 0xF4CC41F6, 0xF4BFBD5C, 0xF4B338ED, 0xF4A6B48B, 0xF49A3044, 0xF48DAC1A, - 0xF481280B, 0xF474A41A, 0xF4682054, 0xF45B9C9B, 0xF44F18FF, 0xF4429580, - 0xF436121E, 0xF4298ED9, 0xF41D0BB1, 0xF41088B6, 0xF40405C9, 0xF3F782F9, - 0xF3EB0047, 0xF3DE7DB3, 0xF3D1FB3D, 0xF3C578E5, 0xF3B8F6BB, 0xF3AC749F, - 0xF39FF2A2, 0xF39370C3, 0xF386EF03, 0xF37A6D62, 0xF36DEBE0, 0xF3616A8C, - 0xF354E948, 0xF3486823, 0xF33BE71E, 0xF32F6638, 0xF322E571, 0xF31664CA, - 0xF309E453, 0xF2FD63ED, 0xF2F0E3A6, 0xF2E4637F, 0xF2D7E379, 0xF2CB6393, - 0xF2BEE3CE, 0xF2B2643A, 0xF2A5E4B6, 0xF2996553, 0xF28CE612, 0xF28066F1, - 0xF273E7F2, 0xF2676924, 0xF25AEA68, 0xF24E6BCE, 0xF241ED55, 0xF2356EFE, - 0xF228F0C9, 0xF21C72B7, 0xF20FF4D6, 0xF2037708, 0xF1F6F95D, 0xF1EA7BD4, - 0xF1DDFE6E, 0xF1D1812B, 0xF1C5040B, 0xF1B8871D, 0xF1AC0A43, 0xF19F8D8D, - 0xF19310FA, 0xF186948A, 0xF17A183F, 0xF16D9C17, 0xF1612023, 0xF154A443, - 0xF1482887, 0xF13BACF0, 0xF12F317D, 0xF122B62F, 0xF1163B05, 0xF109C010, - 0xF0FD4530, 0xF0F0CA75, 0xF0E44FDF, 0xF0D7D56F, 0xF0CB5B24, 0xF0BEE0FE, - 0xF0B2670E, 0xF0A5ED34, 0xF0997380, 0xF08CF9F1, 0xF0808089, 0xF0740747, - 0xF0678E2C, 0xF05B1546, 0xF04E9C78, 0xF04223D0, 0xF035AB4F, 0xF02932F5, - 0xF01CBAC2, 0xF01042C6, 0xF003CAE2, 0xEFF75325, 0xEFEADB90, 0xEFDE6422, - 0xEFD1ECDC, 0xEFC575BE, 0xEFB8FEC8, 0xEFAC87FB, 0xEFA01155, 0xEF939AD8, - 0xEF8724A3, 0xEF7AAE77, 0xEF6E3874, 0xEF61C29A, 0xEF554CE9, 0xEF48D761, - 0xEF3C6202, 0xEF2FECCC, 0xEF2377C0, 0xEF1702DE, 0xEF0A8E25, 0xEEFE1996, - 0xEEF1A531, 0xEEE53116, 0xEED8BD06, 0xEECC491F, 0xEEBFD563, 0xEEB361D2, - 0xEEA6EE6C, 0xEE9A7B30, 0xEE8E081F, 0xEE819539, 0xEE75227E, 0xEE68AFEF, - 0xEE5C3D8B, 0xEE4FCB53, 0xEE435946, 0xEE36E784, 0xEE2A75CF, 0xEE1E0446, - 0xEE1192E9, 0xEE0521B8, 0xEDF8B0B4, 0xEDEC3FDC, 0xEDDFCF31, 0xEDD35EB2, - 0xEDC6EE60, 0xEDBA7E3C, 0xEDAE0E44, 0xEDA19E79, 0xED952EDC, 0xED88BF8C, - 0xED7C504A, 0xED6FE135, 0xED63724F, 0xED570396, 0xED4A950B, 0xED3E26AF, - 0xED31B880, 0xED254A80, 0xED18DCAF, 0xED0C6F0C, 0xED000198, 0xECF39453, - 0xECE7273D, 0xECDABA76, 0xECCE4DBE, 0xECC1E136, 0xECB574DD, 0xECA908B4, - 0xEC9C9CBA, 0xEC9030F0, 0xEC83C557, 0xEC7759ED, 0xEC6AEEB3, 0xEC5E83AA, - 0xEC5218D1, 0xEC45AE29, 0xEC3943D1, 0xEC2CD98B, 0xEC206F75, 0xEC140590, - 0xEC079BDD, 0xEBFB325A, 0xEBEEC909, 0xEBE25FEA, 0xEBD5F6FC, 0xEBC98E40, - 0xEBBD25B6, 0xEBB0BD5E, 0xEBA45538, 0xEB97ED44, 0xEB8B85A2, 0xEB7F1E13, - 0xEB72B6B7, 0xEB664F8D, 0xEB59E896, 0xEB4D81D2, 0xEB411B41, 0xEB34B4E4, - 0xEB284EB9, 0xEB1BE8C2, 0xEB0F82FF, 0xEB031D6F, 0xEAF6B813, 0xEAEA52EB, - 0xEADDEE17, 0xEAD18957, 0xEAC524CB, 0xEAB8C074, 0xEAAC5C51, 0xEA9FF863, - 0xEA9394AA, 0xEA873126, 0xEA7ACDD6, 0xEA6E6ABC, 0xEA6207D6, 0xEA55A527, - 0xEA4942AC, 0xEA3CE087, 0xEA307E78, 0xEA241C9E, 0xEA17BAFB, 0xEA0B598E, - 0xE9FEF857, 0xE9F29756, 0xE9E6368B, 0xE9D9D5F7, 0xE9CD759A, 0xE9C11574, - 0xE9B4B584, 0xE9A855CC, 0xE99BF64A, 0xE98F971F, 0xE983380D, 0xE976D931, - 0xE96A7A8D, 0xE95E1C21, 0xE951BDED, 0xE9455FF1, 0xE939022D, 0xE92CA4A1, - 0xE920474D, 0xE913EA32, 0xE9078D50, 0xE8FB30A6, 0xE8EED434, 0xE8E2781C, - 0xE8D61C1C, 0xE8C9C056, 0xE8BD64CA, 0xE8B10976, 0xE8A4AE5C, 0xE898537C, - 0xE88BF8D6, 0xE87F9E69, 0xE8734436, 0xE866EA3E, 0xE85A9080, 0xE84E36FC, - 0xE841DDD2, 0xE83584C3, 0xE8292BEF, 0xE81CD355, 0xE8107AF7, 0xE80422D3, - 0xE7F7CAEB, 0xE7EB733E, 0xE7DF1BCD, 0xE7D2C497, 0xE7C66D9C, 0xE7BA16DE, - 0xE7ADC05B, 0xE7A16A15, 0xE795142A, 0xE788BE5B, 0xE77C68C9, 0xE7701374, - 0xE763BE5B, 0xE757697F, 0xE74B14E0, 0xE73EC07E, 0xE7326C58, 0xE7261871, - 0xE719C4C6, 0xE70D7159, 0xE7011E29, 0xE6F4CB37, 0xE6E878A2, 0xE6DC262C, - 0xE6CFD3F4, 0xE6C381F9, 0xE6B7303E, 0xE6AADEC0, 0xE69E8D81, 0xE6923C81, - 0xE685EBBF, 0xE6799B3D, 0xE66D4AF9, 0xE660FAF4, 0xE654AB2F, 0xE6485BA9, - 0xE63C0C81, 0xE62FBD7A, 0xE6236EB3, 0xE617202B, 0xE60AD1E4, 0xE5FE83DC, - 0xE5F23615, 0xE5E5E88E, 0xE5D99B47, 0xE5CD4E41, 0xE5C1017B, 0xE5B4B4F6, - 0xE5A868B2, 0xE59C1CCF, 0xE58FD10D, 0xE583858C, 0xE5773A4D, 0xE56AEF4F, - 0xE55EA493, 0xE5525A19, 0xE5460FE0, 0xE539C5EA, 0xE52D7C35, 0xE52132C2, - 0xE514E992, 0xE508A0A5, 0xE4FC57F9, 0xE4F00FB0, 0xE4E3C78A, 0xE4D77FA8, - 0xE4CB3808, 0xE4BEF0AB, 0xE4B2A992, 0xE4A662BB, 0xE49A1C29, 0xE48DD5DA, - 0xE4818FCE, 0xE4754A07, 0xE4690483, 0xE45CBF44, 0xE4507A49, 0xE44435B1, - 0xE437F13F, 0xE42BAD11, 0xE41F6927, 0xE4132583, 0xE406E223, 0xE3FA9F09, - 0xE3EE5C33, 0xE3E219A3, 0xE3D5D758, 0xE3C99553, 0xE3BD5393, 0xE3B11219, - 0xE3A4D104, 0xE3989016, 0xE38C4F6E, 0xE3800F0C, 0xE373CEF1, 0xE3678F1C, - 0xE35B4F8D, 0xE34F1045, 0xE342D144, 0xE336928A, 0xE32A5417, 0xE31E15EB, - 0xE311D806, 0xE3059A69, 0xE2F95D32, 0xE2ED2024, 0xE2E0E35D, 0xE2D4A6DF, - 0xE2C86AA8, 0xE2BC2EB9, 0xE2AFF313, 0xE2A3B7B5, 0xE2977C9F, 0xE28B41D2, - 0xE27F074E, 0xE272CD13, 0xE2669320, 0xE25A5976, 0xE24E2035, 0xE241E71E, - 0xE235AE50, 0xE22975CC, 0xE21D3D91, 0xE21105A0, 0xE204CDF9, 0xE1F8969C, - 0xE1EC5F89, 0xE1E028C0, 0xE1D3F242, 0xE1C7BC0E, 0xE1BB8624, 0xE1AF50A5, - 0xE1A31B51, 0xE196E648, 0xE18AB18A, 0xE17E7D17, 0xE17248EF, 0xE1661513, - 0xE159E182, 0xE14DAE3D, 0xE1417B44, 0xE1354896, 0xE1291635, 0xE11CE41F, - 0xE110B256, 0xE10480F8, 0xE0F84FC8, 0xE0EC1EE4, 0xE0DFEE4D, 0xE0D3BE03, - 0xE0C78E05, 0xE0BB5E55, 0xE0AF2EF1, 0xE0A2FFDB, 0xE096D113, 0xE08AA298, - 0xE07E746A, 0xE072468A, 0xE06618F9, 0xE059EBD4, 0xE04DBEDE, 0xE0419236, - 0xE03565DD, 0xE02939D2, 0xE01D0E16, 0xE010E2A8, 0xE004B789, 0xDFF88CB9, - 0xDFEC6238, 0xDFE03807, 0xDFD40E24, 0xDFC7E491, 0xDFBBBB4D, 0xDFAF9259, - 0xDFA369B5, 0xDF974161, 0xDF8B195C, 0xDF7EF1A8, 0xDF72CA44, 0xDF66A36E, - 0xDF5A7CAB, 0xDF4E5638, 0xDF423015, 0xDF360A44, 0xDF29E4C4, 0xDF1DBF94, - 0xDF119AB6, 0xDF057629, 0xDEF951ED, 0xDEED2E03, 0xDEE10A6A, 0xDED4E723, - 0xDEC8C42E, 0xDEBCA18B, 0xDEB07F3A, 0xDEA45D3B, 0xDE983B8F, 0xDE8C1A35, - 0xDE7FF92D, 0xDE73D878, 0xDE67B816, 0xDE5B9807, 0xDE4F784B, 0xDE4358E2, - 0xDE3739CC, 0xDE2B1B09, 0xDE1EFC9A, 0xDE12DEBD, 0xDE06C0F5, 0xDDFAA381, - 0xDDEE8661, 0xDDE26995, 0xDDD64D1D, 0xDDCA30FA, 0xDDBE152B, 0xDDB1F9B1, - 0xDDA5DE8B, 0xDD99C3BA, 0xDD8DA93D, 0xDD818F16, 0xDD757544, 0xDD695BC7, - 0xDD5D42A0, 0xDD5129CE, 0xDD451151, 0xDD38F92B, 0xDD2CE15A, 0xDD20C9DF, - 0xDD14B2BA, 0xDD089BEB, 0xDCFC8572, 0xDCF06F50, 0xDCE45984, 0xDCD8440F, - 0xDCCC2F2E, 0xDCC01A67, 0xDCB405F7, 0xDCA7F1DD, 0xDC9BDE1B, 0xDC8FCAB0, - 0xDC83B79D, 0xDC77A4E1, 0xDC6B927D, 0xDC5F8070, 0xDC536EBC, 0xDC475D5F, - 0xDC3B4C5B, 0xDC2F3BAF, 0xDC232B5B, 0xDC171B60, 0xDC0B0BBE, 0xDBFEFC74, - 0xDBF2ED83, 0xDBE6DEEB, 0xDBDAD0AC, 0xDBCEC2C6, 0xDBC2B539, 0xDBB6A806, - 0xDBAA9B2D, 0xDB9E8EAD, 0xDB928287, 0xDB8676BA, 0xDB7A6B85, 0xDB6E606D, - 0xDB6255AF, 0xDB564B4C, 0xDB4A4143, 0xDB3E3794, 0xDB322E40, 0xDB262547, - 0xDB1A1CA9, 0xDB0E1466, 0xDB020C7E, 0xDAF604F1, 0xDAE9FDC0, 0xDADDF6EA, - 0xDAD1F070, 0xDAC5EA52, 0xDAB9E48F, 0xDAADDF29, 0xDAA1DA1E, 0xDA95D570, - 0xDA89D11E, 0xDA7DCD29, 0xDA71C990, 0xDA65C653, 0xDA59C374, 0xDA4DC0F1, - 0xDA41BECB, 0xDA35BD40, 0xDA29BBD5, 0xDA1DBAC7, 0xDA11BA17, 0xDA05B9C4, - 0xD9F9B9CF, 0xD9EDBA37, 0xD9E1BAFE, 0xD9D5BC23, 0xD9C9BDA6, 0xD9BDBF87, - 0xD9B1C1C6, 0xD9A5C464, 0xD999C761, 0xD98DCABC, 0xD981CE77, 0xD975D290, - 0xD969D708, 0xD95DDBE0, 0xD951E117, 0xD945E6AD, 0xD939ECA3, 0xD92DF2F9, - 0xD921F9AE, 0xD91600C3, 0xD90A0839, 0xD8FE100E, 0xD8F21881, 0xD8E62117, - 0xD8DA2A0D, 0xD8CE3364, 0xD8C23D1C, 0xD8B64735, 0xD8AA51AE, 0xD89E5C89, - 0xD89267C5, 0xD8867362, 0xD87A7F60, 0xD86E8BC0, 0xD8629882, 0xD856A5A5, - 0xD84AB32A, 0xD83EC112, 0xD832CF5B, 0xD826DE06, 0xD81AED14, 0xD80EFC84, - 0xD8030C57, 0xD7F71C8D, 0xD7EB2D25, 0xD7DF3E20, 0xD7D34F7E, 0xD7C76140, - 0xD7BB7364, 0xD7AF85EC, 0xD7A39914, 0xD797AC63, 0xD78BC016, 0xD77FD42C, - 0xD773E8A7, 0xD767FD85, 0xD75C12C8, 0xD750286F, 0xD7443E7A, 0xD73854EA, - 0xD72C6BBE, 0xD72082F7, 0xD7149A95, 0xD708B298, 0xD6FCCB00, 0xD6F0E3CE, - 0xD6E4FD00, 0xD6D91698, 0xD6CD3096, 0xD6C14AF9, 0xD6B565C2, 0xD6A980F0, - 0xD69D9C85, 0xD691B880, 0xD685D4E1, 0xD679F1A9, 0xD66E0ED7, 0xD6622CA8, - 0xD6564AA3, 0xD64A6905, 0xD63E87CE, 0xD632A6FE, 0xD626C695, 0xD61AE693, - 0xD60F06F9, 0xD60327C6, 0xD5F748FB, 0xD5EB6A98, 0xD5DF8C9C, 0xD5D3AF08, - 0xD5C7D1DD, 0xD5BBF519, 0xD5B018BE, 0xD5A43CCB, 0xD5986141, 0xD58C861F, - 0xD580AB66, 0xD574D116, 0xD568F72F, 0xD55D1DB1, 0xD551449C, 0xD5456BF1, - 0xD53993AF, 0xD52DBBD6, 0xD521E468, 0xD5160D9F, 0xD50A3704, 0xD4FE60D2, - 0xD4F28B0B, 0xD4E6B5AF, 0xD4DAE0BC, 0xD4CF0C34, 0xD4C33817, 0xD4B76464, - 0xD4AB911C, 0xD49FBE3F, 0xD493EBCD, 0xD48819C6, 0xD47C482A, 0xD47076FA, - 0xD464A635, 0xD458D5DC, 0xD44D05EE, 0xD441366D, 0xD4356757, 0xD42998AD, - 0xD41DCA70, 0xD411FC9E, 0xD4062F3A, 0xD3FA6241, 0xD3EE95B6, 0xD3E2C997, - 0xD3D6FE21, 0xD3CB32DB, 0xD3BF6803, 0xD3B39D98, 0xD3A7D39B, 0xD39C0A0B, - 0xD39040E8, 0xD3847833, 0xD378AFEC, 0xD36CE812, 0xD36120A7, 0xD35559A9, - 0xD349931A, 0xD33DCCFA, 0xD3320747, 0xD3264203, 0xD31A7D2E, 0xD30EB8C8, - 0xD302F4D0, 0xD2F73148, 0xD2EB6E2F, 0xD2DFAB85, 0xD2D3E94A, 0xD2C8277F, - 0xD2BC6623, 0xD2B0A537, 0xD2A4E4BB, 0xD29924EA, 0xD28D654E, 0xD281A622, - 0xD275E766, 0xD26A291A, 0xD25E6B3F, 0xD252ADD4, 0xD246F0DB, 0xD23B3452, - 0xD22F783A, 0xD223BC93, 0xD218015D, 0xD20C4698, 0xD2008C45, 0xD1F4D263, - 0xD1E918F3, 0xD1DD5FF5, 0xD1D1A768, 0xD1C5EF4E, 0xD1BA37A5, 0xD1AE806F, - 0xD1A2C9AB, 0xD1971359, 0xD18B5D7A, 0xD17FA80E, 0xD173F314, 0xD1683E8D, - 0xD15C8A79, 0xD150D714, 0xD14523E6, 0xD139712C, 0xD12DBEE5, 0xD1220D11, - 0xD1165BB1, 0xD10AAAC5, 0xD0FEFA4D, 0xD0F34A49, 0xD0E79AB9, 0xD0DBEB9D, - 0xD0D03CF5, 0xD0C48EC2, 0xD0B8E103, 0xD0AD33B9, 0xD0A186E4, 0xD095DA84, - 0xD08A2E98, 0xD07E8322, 0xD072D821, 0xD0672D95, 0xD05B837F, 0xD04FD9DE, - 0xD04430B3, 0xD03887FE, 0xD02CDFBF, 0xD02137F5, 0xD01590DD, 0xD009EA00, - 0xCFFE439A, 0xCFF29DA9, 0xCFE6F830, 0xCFDB532D, 0xCFCFAEA1, 0xCFC40A8B, - 0xCFB866ED, 0xCFACC3C6, 0xCFA12116, 0xCF957EDD, 0xCF89DD1C, 0xCF7E3BD3, - 0xCF729B01, 0xCF66FAA7, 0xCF5B5AC5, 0xCF4FBB5A, 0xCF441C68, 0xCF387DEF, - 0xCF2CDFED, 0xCF214264, 0xCF15A554, 0xCF0A08BC, 0xCEFE6C9E, 0xCEF2D0F8, - 0xCEE735CB, 0xCEDB9B17, 0xCED00118, 0xCEC46757, 0xCEB8CE0F, 0xCEAD3541, - 0xCEA19CED, 0xCE960512, 0xCE8A6DB1, 0xCE7ED6CB, 0xCE73405E, 0xCE67AA6C, - 0xCE5C14F4, 0xCE507FF7, 0xCE44EB74, 0xCE39576C, 0xCE2DC3DF, 0xCE2230CD, - 0xCE169E36, 0xCE0B0C1A, 0xCDFF7A79, 0xCDF3E953, 0xCDE858A9, 0xCDDCC87B, - 0xCDD138C8, 0xCDC5A992, 0xCDBA1AD7, 0xCDAE8C98, 0xCDA2FED5, 0xCD9771C9, - 0xCD8BE4FF, 0xCD8058B2, 0xCD74CCE1, 0xCD69418D, 0xCD5DB6B5, 0xCD522C5B, - 0xCD46A27D, 0xCD3B191D, 0xCD2F903A, 0xCD2407D4, 0xCD187FEC, 0xCD0CF882, - 0xCD017195, 0xCCF5EB26, 0xCCEA6535, 0xCCDEDFC2, 0xCCD35ACD, 0xCCC7D656, - 0xCCBC525E, 0xCCB0CEE4, 0xCCA54BE9, 0xCC99C96D, 0xCC8E476F, 0xCC82C5F1, - 0xCC7744F1, 0xCC6BC470, 0xCC6044AA, 0xCC54C528, 0xCC494626, 0xCC3DC7A3, - 0xCC3249A0, 0xCC26CC1D, 0xCC1B4F19, 0xCC0FD296, 0xCC045693, 0xCBF8DB10, - 0xCBED600E, 0xCBE1E58C, 0xCBD66B8B, 0xCBCAF20A, 0xCBBF790A, 0xCBB4008B, - 0xCBA8888D, 0xCB9D1111, 0xCB919A15, 0xCB86239B, 0xCB7AADA2, 0xCB6F382B, - 0xCB63C336, 0xCB584EC3, 0xCB4CDAD1, 0xCB416761, 0xCB35F474, 0xCB2A8209, - 0xCB1F105A, 0xCB139EF4, 0xCB082E10, 0xCAFCBDAF, 0xCAF14DD1, 0xCAE5DE76, - 0xCADA6F9D, 0xCACF0148, 0xCAC39376, 0xCAB82628, 0xCAACB95D, 0xCAA14D15, - 0xCA95E151, 0xCA8A7611, 0xCA7F0B55, 0xCA73A11D, 0xCA683769, 0xCA5CCE39, - 0xCA51658E, 0xCA45FD67, 0xCA3A95C4, 0xCA2F2EA7, 0xCA23C80E, 0xCA1861FA, - 0xCA0CFC6B, 0xCA019761, 0xC9F632DC, 0xC9EACF17, 0xC9DF6B9D, 0xC9D408A8, - 0xC9C8A63A, 0xC9BD4451, 0xC9B1E2EE, 0xC9A68211, 0xC99B21BA, 0xC98FC1E9, - 0xC984629E, 0xC97903DA, 0xC96DA59D, 0xC96247E6, 0xC956EAB6, 0xC94B8E0D, - 0xC94031EB, 0xC934D650, 0xC9297B3C, 0xC91E20AF, 0xC912C6AA, 0xC9076D2C, - 0xC8FC1436, 0xC8F0BBC8, 0xC8E563E2, 0xC8DA0C83, 0xC8CEB5AD, 0xC8C35F5F, - 0xC8B80999, 0xC8ACB495, 0xC8A15FE0, 0xC8960BB4, 0xC88AB810, 0xC87F64F5, - 0xC8741263, 0xC868C05B, 0xC85D6EDB, 0xC8521DE5, 0xC846CD78, 0xC83B7D94, - 0xC8302E3A, 0xC824DF6A, 0xC8199124, 0xC80E4367, 0xC802F635, 0xC7F7A98D, - 0xC7EC5D6F, 0xC7E111DB, 0xC7D5C6D2, 0xC7CA7C53, 0xC7BF325F, 0xC7B3E8F6, - 0xC7A8A018, 0xC79D57C5, 0xC7920FFD, 0xC786C8C0, 0xC77B8248, 0xC7703C22, - 0xC764F688, 0xC759B179, 0xC74E6CF6, 0xC74328FF, 0xC737E594, 0xC72CA2B5, - 0xC7216062, 0xC7161E9C, 0xC70ADD62, 0xC6FF9CB4, 0xC6F45C93, 0xC6E91CFF, - 0xC6DDDDF8, 0xC6D29F7E, 0xC6C76190, 0xC6BC2430, 0xC6B0E75E, 0xC6A5AB18, - 0xC69A6F61, 0xC68F3436, 0xC683F99A, 0xC678BF8B, 0xC66D860B, 0xC6624D18, - 0xC65714B4, 0xC64BDD17, 0xC640A5CF, 0xC6356F16, 0xC62A38EB, 0xC61F034F, - 0xC613CE42, 0xC60899C3, 0xC5FD65D4, 0xC5F23274, 0xC5E6FFA3, 0xC5DBCD62, - 0xC5D09BB0, 0xC5C56A8D, 0xC5BA39FA, 0xC5AF09F7, 0xC5A3DA84, 0xC598ABA1, - 0xC58D7D4E, 0xC5824F8B, 0xC5772258, 0xC56BF5B6, 0xC560C9A5, 0xC5559E24, - 0xC54A7334, 0xC53F48D5, 0xC5341F06, 0xC528F5C9, 0xC51DCD1D, 0xC512A53B, - 0xC5077DB2, 0xC4FC56BA, 0xC4F13053, 0xC4E60A7F, 0xC4DAE53C, 0xC4CFC08B, - 0xC4C49C6D, 0xC4B978E0, 0xC4AE55E6, 0xC4A3337E, 0xC49811A8, 0xC48CF065, - 0xC481CFB5, 0xC476AF98, 0xC46B900D, 0xC4607116, 0xC45552B1, 0xC44A34E0, - 0xC43F17A2, 0xC433FAF8, 0xC428DEE1, 0xC41DC35E, 0xC412A86E, 0xC4078E12, - 0xC3FC744B, 0xC3F15B17, 0xC3E642B0, 0xC3DB2AA5, 0xC3D0132F, 0xC3C4FC4C, - 0xC3B9E5FF, 0xC3AED046, 0xC3A3BB22, 0xC398A693, 0xC38D9299, 0xC3827F34, - 0xC3776C64, 0xC36C5A2A, 0xC3614885, 0xC3563776, 0xC34B26FC, 0xC3401719, - 0xC33507CB, 0xC329F913, 0xC31EEAF1, 0xC313DD66, 0xC308D070, 0xC2FDC412, - 0xC2F2B849, 0xC2E7AD18, 0xC2DCA27D, 0xC2D19879, 0xC2C68F0C, 0xC2BB8636, - 0xC2B07E2F, 0xC2A57687, 0xC29A6F77, 0xC28F68FF, 0xC284631E, 0xC2795DD4, - 0xC26E5923, 0xC2635509, 0xC2585187, 0xC24D4E9E, 0xC2424C4C, 0xC2374A94, - 0xC22C4973, 0xC22148EB, 0xC21648FC, 0xC20B49A5, 0xC2004AE8, 0xC1F54CC3, - 0xC1EA4F37, 0xC1DF5245, 0xC1D455EC, 0xC1C95A2C, 0xC1BE5F06, 0xC1B36479, - 0xC1A86A87, 0xC19D712E, 0xC192786E, 0xC1878049, 0xC17C88BE, 0xC17191CE, - 0xC1669B77, 0xC15BA5BC, 0xC150B09A, 0xC145BC14, 0xC13AC828, 0xC12FD4D7, - 0xC124E221, 0xC119F006, 0xC10EFE86, 0xC1040DA2, 0xC0F91D59, 0xC0EE2E1B, - 0xC0E33F09, 0xC0D85093, 0xC0CD62B8, 0xC0C2757A, 0xC0B788D8, 0xC0AC9CD1, - 0xC0A1B167, 0xC096C69A, 0xC08BDC69, 0xC080F2D4, 0xC07609DC, 0xC06B2181, - 0xC06039C3, 0xC05552A2, 0xC04A6C1D, 0xC03F8636, 0xC034A0ED, 0xC029BC40, - 0xC01ED832, 0xC013F4C1, 0xC00911ED, 0xBFFE2FB8, 0xBFF34E20, 0xBFE86D26, - 0xBFDD8CCB, 0xBFD2AD0E, 0xBFC7CDEF, 0xBFBCEF6E, 0xBFB2118C, 0xBFA73449, - 0xBF9C57A5, 0xBF917B9F, 0xBF86A039, 0xBF7BC571, 0xBF70EB49, 0xBF6611C0, - 0xBF5B38D6, 0xBF50608C, 0xBF4588E2, 0xBF3AB1D7, 0xBF2FDB6C, 0xBF2505A1, - 0xBF1A3076, 0xBF0F5BEB, 0xBF048800, 0xBEF9B4B6, 0xBEEEE20C, 0xBEE41003, - 0xBED93E9A, 0xBECE6DD2, 0xBEC39DAB, 0xBEB8CE25, 0xBEADFF40, 0xBEA330FC, - 0xBE9863C8, 0xBE8D96C6, 0xBE82CA67, 0xBE77FEA9, 0xBE6D338C, 0xBE626911, - 0xBE579F39, 0xBE4CD602, 0xBE420D6D, 0xBE37457B, 0xBE2C7E2B, 0xBE21B77D, - 0xBE16F172, 0xBE0C2C09, 0xBE016744, 0xBDF6A321, 0xBDEBDFA1, 0xBDE11CC4, - 0xBDD65A8A, 0xBDCB98F3, 0xBDC0D800, 0xBDB617B0, 0xBDAB5804, 0xBDA098FB, - 0xBD95DA97, 0xBD8B1CD6, 0xBD805FB9, 0xBD75A340, 0xBD6AE76B, 0xBD602C3B, - 0xBD5571AF, 0xBD4AB7C7, 0xBD3FFE84, 0xBD3545E6, 0xBD2A8DED, 0xBD1FD698, - 0xBD151FE9, 0xBD0A69DE, 0xBCFFB479, 0xBCF4FFB9, 0xBCEA4B9F, 0xBCDF982A, - 0xBCD4E55B, 0xBCCA3331, 0xBCBF81AE, 0xBCB4D0D0, 0xBCAA2098, 0xBC9F7107, - 0xBC94C21B, 0xBC8A13D6, 0xBC7F6638, 0xBC74B940, 0xBC6A0CEE, 0xBC5F6144, - 0xBC54B6AD, 0xBC4A0C50, 0xBC3F629B, 0xBC34B98C, 0xBC2A1125, 0xBC1F6965, - 0xBC14C24D, 0xBC0A1BDC, 0xBBFF7613, 0xBBF4D0F1, 0xBBEA2C78, 0xBBDF88A7, - 0xBBD4E57D, 0xBBCA42FC, 0xBBBFA123, 0xBBB4FFF3, 0xBBAA5F6B, 0xBB9FBF8C, - 0xBB952055, 0xBB8A81C8, 0xBB7FE3E3, 0xBB7546A7, 0xBB6AAA14, 0xBB600E2B, - 0xBB5572EB, 0xBB4AD854, 0xBB403E67, 0xBB35A523, 0xBB2B0C89, 0xBB207499, - 0xBB15DD53, 0xBB0B46B7, 0xBB00B0C5, 0xBAF61B7E, 0xBAEB86E0, 0xBAE0F2EE, - 0xBAD65FA5, 0xBACBCD08, 0xBAC13B15, 0xBAB6A9CD, 0xBAAC1930, 0xBAA1893E, - 0xBA96F9F7, 0xBA8C6B5B, 0xBA81DD6B, 0xBA775026, 0xBA6CC38D, 0xBA6237A0, - 0xBA57AC5E, 0xBA4D21C8, 0xBA4297DE, 0xBA380EA1, 0xBA2D860F, 0xBA22FE2A, - 0xBA1876F1, 0xBA0DF0CF, 0xBA036AEF, 0xB9F8E5BC, 0xB9EE6136, 0xB9E3DD5C, - 0xB9D95A30, 0xB9CED7B0, 0xB9C455DE, 0xB9B9D4B9, 0xB9AF5441, 0xB9A4D477, - 0xB99A555B, 0xB98FD6EC, 0xB985592B, 0xB97ADC18, 0xB9705FB3, 0xB965E3FC, - 0xB95B68F3, 0xB950EE99, 0xB94674EC, 0xB93BFBEF, 0xB93183A0, 0xB9270C00, - 0xB91C950E, 0xB9121ECC, 0xB907A938, 0xB8FD3454, 0xB8F2C01F, 0xB8E84C99, - 0xB8DDD9C2, 0xB8D3679B, 0xB8C8F624, 0xB8BE855C, 0xB8B41545, 0xB8A9A5DD, - 0xB89F3725, 0xB894C91D, 0xB88A5BC6, 0xB87FEF1E, 0xB8758328, 0xB86B17E1, - 0xB860AD4C, 0xB8564367, 0xB84BDA33, 0xB84171B0, 0xB83709DE, 0xB82CA2BD, - 0xB8223C4D, 0xB817D68E, 0xB80D7181, 0xB8030D26, 0xB7F8A97C, 0xB7EE4684, - 0xB7E3E43D, 0xB7D982A9, 0xB7CF2230, 0xB7C4C200, 0xB7BA6282, 0xB7B003B6, - 0xB7A5A59D, 0xB79B4836, 0xB790EB82, 0xB7868F80, 0xB77C3432, 0xB771D996, - 0xB7677FAD, 0xB75D2678, 0xB752CDF5, 0xB7487626, 0xB73E1F0B, 0xB733C8A3, - 0xB72972EE, 0xB71F1DEE, 0xB714C9A1, 0xB70A7608, 0xB7002323, 0xB6F5D0F2, - 0xB6EB7F75, 0xB6E12EAD, 0xB6D6DE99, 0xB6CC8F3A, 0xB6C2408F, 0xB6B7F299, - 0xB6ADA558, 0xB6A358CB, 0xB6990CF4, 0xB68EC1D2, 0xB6847765, 0xB67A2DAD, - 0xB66FE4AB, 0xB6659C5E, 0xB65B54C7, 0xB6510DE6, 0xB646C7BA, 0xB63C8245, - 0xB6323D85, 0xB627F97B, 0xB61DB628, 0xB613738B, 0xB60931A4, 0xB5FEF074, - 0xB5F4AFFA, 0xB5EA7038, 0xB5E0312C, 0xB5D5F2D6, 0xB5CBB538, 0xB5C17851, - 0xB5B73C21, 0xB5AD00A9, 0xB5A2C5E7, 0xB5988C46, 0xB58E52F4, 0xB5841A59, - 0xB579E276, 0xB56FAB4B, 0xB56574D9, 0xB55B3F1E, 0xB5510A1B, 0xB546D5D1, - 0xB53CA23F, 0xB5326F65, 0xB5283D45, 0xB51E0BDC, 0xB513DB2D, 0xB509AB36, - 0xB4FF7BF9, 0xB4F54D74, 0xB4EB1FA9, 0xB4E0F296, 0xB4D6C63E, 0xB4CC9A9E, - 0xB4C26FB8, 0xB4B8458C, 0xB4AE1C1A, 0xB4A3F361, 0xB499CB63, 0xB48FA41E, - 0xB4857D94, 0xB47B57C3, 0xB47132AE, 0xB4670E52, 0xB45CEAB1, 0xB452C7CB, - 0xB448A59F, 0xB43E842F, 0xB4346379, 0xB42A437E, 0xB420243E, 0xB41605BA, - 0xB40BE7F1, 0xB401CAE3, 0xB3F7AE91, 0xB3ED92FA, 0xB3E3781F, 0xB3D95E00, - 0xB3CF449D, 0xB3C52BF6, 0xB3BB140A, 0xB3B0FCDB, 0xB3A6E669, 0xB39CD0B2, - 0xB392BBB9, 0xB388A77B, 0xB37E93FB, 0xB3748137, 0xB36A6F97, 0xB3605E4D, - 0xB3564DC0, 0xB34C3DF0, 0xB3422EDD, 0xB3382088, 0xB32E12F1, 0xB3240616, - 0xB319F9FA, 0xB30FEE9B, 0xB305E3FA, 0xB2FBDA17, 0xB2F1D0F2, 0xB2E7C88B, - 0xB2DDC0E3, 0xB2D3B9F8, 0xB2C9B3CC, 0xB2BFAE5F, 0xB2B5A9B0, 0xB2ABA5C0, - 0xB2A1A28F, 0xB297A01D, 0xB28D9E69, 0xB2839D75, 0xB2799D40, 0xB26F9DCA, - 0xB2659F14, 0xB25BA11D, 0xB251A3E5, 0xB247A76E, 0xB23DABB6, 0xB233B0BE, - 0xB229B686, 0xB21FBD0E, 0xB215C456, 0xB20BCC5E, 0xB201D527, 0xB1F7DEB0, - 0xB1EDE8FA, 0xB1E3F404, 0xB1D9FFCF, 0xB1D00C5B, 0xB1C619A8, 0xB1BC27B6, - 0xB1B23685, 0xB1A84615, 0xB19E5666, 0xB1946779, 0xB18A794D, 0xB1808BE3, - 0xB1769F3B, 0xB16CB354, 0xB162C830, 0xB158DDCD, 0xB14EF491, 0xB1450BB3, - 0xB13B2396, 0xB1313C3C, 0xB12755A5, 0xB11D6FD0, 0xB1138ABE, 0xB109A66E, - 0xB0FFC2E1, 0xB0F5E018, 0xB0EBFE11, 0xB0E21CCD, 0xB0D83C4D, 0xB0CE5C90, - 0xB0C47D96, 0xB0BA9F60, 0xB0B0C1ED, 0xB0A6E53E, 0xB09D0953, 0xB0932E2C, - 0xB08953C8, 0xB07F7A29, 0xB075A14E, 0xB06BC937, 0xB061F1E5, 0xB0581B57, - 0xB04E458D, 0xB0447088, 0xB03A9C48, 0xB030C8CD, 0xB026F617, 0xB01D2425, - 0xB01352F9, 0xB0098292, 0xAFFFB2F1, 0xAFF5E414, 0xAFEC15FD, 0xAFE248AC, - 0xAFD87C21, 0xAFCEB05B, 0xAFC4E55B, 0xAFBB1B21, 0xAFB151AD, 0xAFA788FF, - 0xAF9DC118, 0xAF93F9F7, 0xAF8A339C, 0xAF806E08, 0xAF76A93A, 0xAF6CE533, - 0xAF6321F3, 0xAF595F7A, 0xAF4F9DC8, 0xAF45DCDD, 0xAF3C1CB9, 0xAF325DC0, - 0xAF289F2B, 0xAF1EE15D, 0xAF152457, 0xAF0B6818, 0xAF01ACA2, 0xAEF7F1F3, - 0xAEEE380C, 0xAEE47EED, 0xAEDAC696, 0xAED10F07, 0xAEC75841, 0xAEBDA243, - 0xAEB3ED0E, 0xAEAA38A1, 0xAEA084FD, 0xAE96D221, 0xAE8D200F, 0xAE836EC5, - 0xAE79BE45, 0xAE700E8E, 0xAE665FA0, 0xAE5CB17B, 0xAE530420, 0xAE49578E, - 0xAE3FABC6, 0xAE3600C7, 0xAE2C5693, 0xAE22AD28, 0xAE190487, 0xAE0F5CB1, - 0xAE05B5A4, 0xADFC0F62, 0xADF269EA, 0xADE8C53D, 0xADDF215A, 0xADD57E42, - 0xADCBDBF5, 0xADC23A72, 0xADB899BB, 0xADAEF9CE, 0xADA55AAC, 0xAD9BBC56, - 0xAD921ECB, 0xAD88820B, 0xAD7EE617, 0xAD754AEF, 0xAD6BB092, 0xAD621701, - 0xAD587E3B, 0xAD4EE642, 0xAD454F15, 0xAD3BB8B3, 0xAD32231E, 0xAD288E56, - 0xAD1EFABB, 0xAD15678B, 0xAD0BD528, 0xAD024392, 0xACF8B2C8, 0xACEF22CB, - 0xACE5939B, 0xACDC0538, 0xACD277A2, 0xACC8EADA, 0xACBF5EDF, 0xACB5D3B1, - 0xACAC4951, 0xACA2BFBE, 0xAC9936F9, 0xAC8FAF02, 0xAC8627D9, 0xAC7CA17D, - 0xAC731BF0, 0xAC699731, 0xAC601340, 0xAC56901D, 0xAC4D0DC9, 0xAC438C44, - 0xAC3A0B8D, 0xAC308BA5, 0xAC270C8B, 0xAC1D8E41, 0xAC1410C5, 0xAC0A9418, - 0xAC01183B, 0xABF79D2D, 0xABEE22EE, 0xABE4A97F, 0xABDB30DF, 0xABD1B90F, - 0xABC8420E, 0xABBECBDE, 0xABB5567D, 0xABABE1EC, 0xABA26E2B, 0xAB98FB3B, - 0xAB8F891A, 0xAB8617CA, 0xAB7CA74B, 0xAB73379C, 0xAB69C8BE, 0xAB605AB0, - 0xAB56ED73, 0xAB4D8107, 0xAB44156C, 0xAB3AAAA2, 0xAB3140A9, 0xAB27D782, - 0xAB1E6F2C, 0xAB150807, 0xAB0BA153, 0xAB023B72, 0xAAF8D662, 0xAAEF7224, - 0xAAE60EB8, 0xAADCAC1D, 0xAAD34A55, 0xAAC9E95F, 0xAAC0893C, 0xAAB729EA, - 0xAAADCB6B, 0xAAA46DBF, 0xAA9B10E5, 0xAA91B4DE, 0xAA8859A9, 0xAA7EFF48, - 0xAA75A5BA, 0xAA6C4CFE, 0xAA62F516, 0xAA599E01, 0xAA5047BF, 0xAA46F251, - 0xAA3D9DB6, 0xAA3449EF, 0xAA2AF6FC, 0xAA21A4DC, 0xAA185390, 0xAA0F0318, - 0xAA05B374, 0xA9FC64A5, 0xA9F316A9, 0xA9E9C982, 0xA9E07D30, 0xA9D731B2, - 0xA9CDE708, 0xA9C49D33, 0xA9BB5433, 0xA9B20C08, 0xA9A8C4B1, 0xA99F7E30, - 0xA9963884, 0xA98CF3AD, 0xA983AFAB, 0xA97A6C7F, 0xA9712A28, 0xA967E8A7, - 0xA95EA7FC, 0xA9556826, 0xA94C2926, 0xA942EAFC, 0xA939ADA8, 0xA930712A, - 0xA9273583, 0xA91DFAB1, 0xA914C114, 0xA90B87F0, 0xA9024FA2, 0xA8F9182A, - 0xA8EFE18A, 0xA8E6ABC0, 0xA8DD76CD, 0xA8D442B1, 0xA8CB0F6C, 0xA8C1DCFF, - 0xA8B8AB68, 0xA8AF7AA9, 0xA8A64AC2, 0xA89D1BB2, 0xA893ED79, 0xA88AC018, - 0xA881938F, 0xA87867DE, 0xA86F3D05, 0xA8661304, 0xA85CE9DB, 0xA853C18B, - 0xA84A9A13, 0xA8417373, 0xA8384DAB, 0xA82F28BC, 0xA82604A6, 0xA81CE169, - 0xA813BF04, 0xA80A9D79, 0xA8017CC6, 0xA7F85CED, 0xA7EF3DED, 0xA7E61FC6, - 0xA7DD0278, 0xA7D3E604, 0xA7CACA6A, 0xA7C1AFA9, 0xA7B895C2, 0xA7AF7CB4, - 0xA7A66481, 0xA79D4D28, 0xA79436A8, 0xA78B2103, 0xA7820C38, 0xA778F848, - 0xA76FE532, 0xA766D2F6, 0xA75DC195, 0xA754B10F, 0xA74BA163, 0xA7429293, - 0xA739849D, 0xA7307782, 0xA7276B9F, 0xA71E603B, 0xA71555B2, 0xA70C4C04, - 0xA7034332, 0xA6FA3B3C, 0xA6F13421, 0xA6E82DE2, 0xA6DF287E, 0xA6D623F7, - 0xA6CD204B, 0xA6C41D7C, 0xA6BB1B89, 0xA6B21A72, 0xA6A91A38, 0xA6A01AD9, - 0xA6971C58, 0xA68E1EB3, 0xA68521EB, 0xA67C25FF, 0xA6732AF1, 0xA66A30BF, - 0xA661376A, 0xA6583EF3, 0xA64F4759, 0xA646509C, 0xA63D5ABC, 0xA63465BA, - 0xA62B7196, 0xA6227E4F, 0xA6198BE6, 0xA6109A5A, 0xA607A9AD, 0xA5FEB9DE, - 0xA5F5CAEC, 0xA5ECDCD9, 0xA5E3EFA4, 0xA5DB034E, 0xA5D217D5, 0xA5C92D3C, - 0xA5C04381, 0xA5B75AA4, 0xA5AE72A7, 0xA5A58B88, 0xA59CA548, 0xA593BFE7, - 0xA58ADB66, 0xA581F7C3, 0xA5791500, 0xA570331C, 0xA5675218, 0xA55E71F3, - 0xA55592AE, 0xA54CB448, 0xA543D6C3, 0xA53AFA77, 0xA5321EB1, 0xA52943CB, - 0xA52069C6, 0xA51790A0, 0xA50EB85B, 0xA505E0F6, 0xA4FD0A72, 0xA4F434CE, - 0xA4EB600B, 0xA4E28C29, 0xA4D9B927, 0xA4D0E707, 0xA4C815C7, 0xA4BF4569, - 0xA4B675EB, 0xA4ADA74F, 0xA4A4D994, 0xA49C0CBB, 0xA49340C3, 0xA48A75AC, - 0xA481AB78, 0xA478E225, 0xA47019B4, 0xA4675225, 0xA45E8B77, 0xA455C5AC, - 0xA44D00C3, 0xA4443CBD, 0xA43B7999, 0xA432B757, 0xA429F5F7, 0xA421357B, - 0xA41875E1, 0xA40FB729, 0xA406F955, 0xA3FE3C63, 0xA3F58055, 0xA3ECC529, - 0xA3E40AE1, 0xA3DB517C, 0xA3D298FB, 0xA3C9E15D, 0xA3C12AA2, 0xA3B874CB, - 0xA3AFBFD8, 0xA3A70BC8, 0xA39E589C, 0xA395A655, 0xA38CF4F1, 0xA3844471, - 0xA37B94D6, 0xA372E61F, 0xA36A384C, 0xA3618B5E, 0xA358DFAC, 0xA3503487, - 0xA3478A47, 0xA33EE0EB, 0xA3363874, 0xA32D90E2, 0xA324EA35, 0xA31C446E, - 0xA3139F8B, 0xA30AFB8E, 0xA3025876, 0xA2F9B643, 0xA2F114F6, 0xA2E8748F, - 0xA2DFD50D, 0xA2D73671, 0xA2CE98BB, 0xA2C5FBEB, 0xA2BD6001, 0xA2B4C4FD, - 0xA2AC2AE0, 0xA2A391A8, 0xA29AF957, 0xA29261ED, 0xA289CB68, 0xA28135CB, - 0xA278A114, 0xA2700D44, 0xA2677A5B, 0xA25EE859, 0xA256573D, 0xA24DC709, - 0xA24537BC, 0xA23CA957, 0xA2341BD8, 0xA22B8F42, 0xA2230392, 0xA21A78CA, - 0xA211EEEA, 0xA20965F2, 0xA200DDE2, 0xA1F856B9, 0xA1EFD079, 0xA1E74B20, - 0xA1DEC6B0, 0xA1D64328, 0xA1CDC088, 0xA1C53ED1, 0xA1BCBE02, 0xA1B43E1C, - 0xA1ABBF1F, 0xA1A3410A, 0xA19AC3DE, 0xA192479B, 0xA189CC41, 0xA1815226, - 0xA178D89F, 0xA1706000, 0xA167E84B, 0xA15F717F, 0xA156FB9D, 0xA14E86A4, - 0xA1461295, 0xA13D9F6F, 0xA1352D34, 0xA12CBBE2, 0xA1244B7A, 0xA11BDBFD, - 0xA1136D69, 0xA10AFFC0, 0xA1029301, 0xA0FA272C, 0xA0F1BC42, 0xA0E95242, - 0xA0E0E92D, 0xA0D88103, 0xA0D019C3, 0xA0C7B36F, 0xA0BF4E05, 0xA0B6E986, - 0xA0AE85F3, 0xA0A6234A, 0xA09DC18D, 0xA09560BC, 0xA08D00D5, 0xA084A1DA, - 0xA07C43CB, 0xA073E6A8, 0xA06B8A70, 0xA0632F24, 0xA05AD4C4, 0xA0527B50, - 0xA04A22C8, 0xA041CB2C, 0xA039747C, 0xA0311EB9, 0xA028C9E2, 0xA02075F8, - 0xA01822FA, 0xA00FD0E9, 0xA0077FC4, 0x9FFF2F8D, 0x9FF6E042, 0x9FEE91E4, - 0x9FE64473, 0x9FDDF7F0, 0x9FD5AC59, 0x9FCD61B0, 0x9FC517F4, 0x9FBCCF26, - 0x9FB48799, 0x9FAC40A6, 0x9FA3FAA0, 0x9F9BB588, 0x9F93715E, 0x9F8B2E22, - 0x9F82EBD4, 0x9F7AAA74, 0x9F726A02, 0x9F6A2A7F, 0x9F61EBE9, 0x9F59AE42, - 0x9F51718A, 0x9F4935C0, 0x9F40FAE5, 0x9F38C0F8, 0x9F3087FA, 0x9F284FEC, - 0x9F2018CC, 0x9F17E29B, 0x9F0FAD59, 0x9F077906, 0x9EFF45A3, 0x9EF7132F, - 0x9EEEE1AA, 0x9EE6B115, 0x9EDE8170, 0x9ED652BA, 0x9ECE24F4, 0x9EC5F81E, - 0x9EBDCC37, 0x9EB5A141, 0x9EAD773B, 0x9EA54E24, 0x9E9D25FE, 0x9E94FEC9, - 0x9E8CD883, 0x9E84B32E, 0x9E7C8ECA, 0x9E746B56, 0x9E6C48D3, 0x9E642741, - 0x9E5C06A0, 0x9E53E6EF, 0x9E4BC82F, 0x9E43AA61, 0x9E3B8D84, 0x9E337198, - 0x9E2B569D, 0x9E233C94, 0x9E1B237C, 0x9E130B55, 0x9E0AF421, 0x9E02DDDE, - 0x9DFAC88C, 0x9DF2B47F, 0x9DEAA112, 0x9DE28E96, 0x9DDA7D0D, 0x9DD26C76, - 0x9DCA5CD1, 0x9DC24E1E, 0x9DBA405E, 0x9DB23390, 0x9DAA27B5, 0x9DA21CCC, - 0x9D9A12D6, 0x9D9209D3, 0x9D8A01C3, 0x9D81FAA6, 0x9D79F47B, 0x9D71EF44, - 0x9D69EB00, 0x9D61E7AF, 0x9D59E552, 0x9D51E3E8, 0x9D49E372, 0x9D41E3EF, - 0x9D39E55F, 0x9D31E7C4, 0x9D29EB1C, 0x9D21EF68, 0x9D19F4A8, 0x9D11FADC, - 0x9D0A0204, 0x9D020A21, 0x9CFA1331, 0x9CF21D36, 0x9CEA282F, 0x9CE2341D, - 0x9CDA4100, 0x9CD24ED7, 0x9CCA5DA2, 0x9CC26D63, 0x9CBA7E18, 0x9CB28FC2, - 0x9CAAA262, 0x9CA2B5F6, 0x9C9ACA80, 0x9C92DFFF, 0x9C8AF673, 0x9C830DDC, - 0x9C7B263C, 0x9C733F90, 0x9C6B59DA, 0x9C63751A, 0x9C5B9150, 0x9C53AE7C, - 0x9C4BCC9D, 0x9C43EC05, 0x9C3C0C13, 0x9C342D16, 0x9C2C4F10, 0x9C247201, - 0x9C1C95E7, 0x9C14BAC5, 0x9C0CE098, 0x9C050763, 0x9BFD2F24, 0x9BF557DB, - 0x9BED818A, 0x9BE5AC30, 0x9BDDD7CC, 0x9BD60460, 0x9BCE31EA, 0x9BC6606C, - 0x9BBE8FE6, 0x9BB6C056, 0x9BAEF1BE, 0x9BA7241E, 0x9B9F5775, 0x9B978BC4, - 0x9B8FC10B, 0x9B87F749, 0x9B802E80, 0x9B7866AE, 0x9B709FD4, 0x9B68D9F3, - 0x9B61150A, 0x9B595119, 0x9B518E20, 0x9B49CC20, 0x9B420B18, 0x9B3A4B09, - 0x9B328BF2, 0x9B2ACDD4, 0x9B2310AF, 0x9B1B5483, 0x9B139950, 0x9B0BDF16, - 0x9B0425D5, 0x9AFC6D8D, 0x9AF4B63E, 0x9AECFFE9, 0x9AE54A8D, 0x9ADD962A, - 0x9AD5E2C1, 0x9ACE3052, 0x9AC67EDC, 0x9ABECE61, 0x9AB71EDF, 0x9AAF7056, - 0x9AA7C2C8, 0x9AA01634, 0x9A986AE8, 0x9A90C049, 0x9A8916A3, 0x9A816DF8, - 0x9A79C647, 0x9A721F91, 0x9A6A79D5, 0x9A62D514, 0x9A5B314E, 0x9A538E83, - 0x9A4BECB2, 0x9A444BDC, 0x9A3CAC02, 0x9A350D22, 0x9A2D6F3E, 0x9A25D255, - 0x9A1E3667, 0x9A169B74, 0x9A0F017D, 0x9A076882, 0x99FFD082, 0x99F8397E, - 0x99F0A375, 0x99E90E69, 0x99E17A58, 0x99D9E743, 0x99D2552B, 0x99CAC40E, - 0x99C333EE, 0x99BBA4CA, 0x99B416A2, 0x99AC8976, 0x99A4FD48, 0x999D7215, - 0x9995E7DF, 0x998E5EA6, 0x9986D66A, 0x997F4F2B, 0x9977C8E8, 0x997043A3, - 0x9968BF5A, 0x99613C0F, 0x9959B9C1, 0x99523870, 0x994AB81D, 0x994338C7, - 0x993BBA6E, 0x99343D13, 0x992CC0B6, 0x99254556, 0x991DCAF4, 0x99165190, - 0x990ED92A, 0x990761C2, 0x98FFEB58, 0x98F87638, 0x98F101CB, 0x98E98E5B, - 0x98E21BEA, 0x98DAAA78, 0x98D33A04, 0x98CBCA8E, 0x98C45C17, 0x98BCEE9F, - 0x98B58226, 0x98AE16AB, 0x98A6AC30, 0x989F42B3, 0x9897DA36, 0x989072B7, - 0x98890C38, 0x9881A6B9, 0x987A4238, 0x9872DEB7, 0x986B7C36, 0x98641AB4, - 0x985CBA31, 0x98555AAF, 0x984DFC2C, 0x98469EA9, 0x983F4226, 0x9837E6A3, - 0x98308C20, 0x9829329D, 0x9821DA1B, 0x981A8299, 0x98132C17, 0x980BD695, - 0x98048214, 0x97FD2E94, 0x97F5DC14, 0x97EE8A95, 0x97E73A17, 0x97DFEA99, - 0x97D89C1D, 0x97D14EA1, 0x97CA0226, 0x97C2B6AD, 0x97BB6C35, 0x97B422BE, - 0x97ACDA49, 0x97A592D4, 0x979E4C62, 0x979706F1, 0x978FC281, 0x97887F13, - 0x97813CA7, 0x9779FB3D, 0x9772BAD5, 0x976B7B6F, 0x97643D54, 0x975CFFF2, - 0x9755C392, 0x974E8834, 0x97474DD9, 0x97401480, 0x9738DC29, 0x9731A4D5, - 0x972A6E84, 0x97233935, 0x971C04E9, 0x9714D1A0, 0x970D9F59, 0x97066E16, - 0x96FF3DD6, 0x96F80E98, 0x96F0E05E, 0x96E9B327, 0x96E286F4, 0x96DB5BC3, - 0x96D43196, 0x96CD086D, 0x96C5E047, 0x96BEB925, 0x96B79307, 0x96B06DEC, - 0x96A949D5, 0x96A226C3, 0x969B04B4, 0x9693E3A9, 0x968CC3A2, 0x9685A49F, - 0x967E86A1, 0x967769A7, 0x96704DB2, 0x966932C1, 0x966218D4, 0x965AFFEC, - 0x9653E809, 0x964CD12A, 0x9645BB51, 0x963EA67C, 0x963792AC, 0x96307FE1, - 0x96296E1B, 0x96225D5A, 0x961B4D9F, 0x96143EE9, 0x960D3138, 0x9606248C, - 0x95FF18E6, 0x95F80E46, 0x95F104AB, 0x95E9FC16, 0x95E2F487, 0x95DBEE45, - 0x95D4E8C1, 0x95CDE444, 0x95C6E0CC, 0x95BFDE5A, 0x95B8DCEF, 0x95B1DC8A, - 0x95AADD2B, 0x95A3DED2, 0x959CE180, 0x9595E535, 0x958EE9F0, 0x9587EFB1, - 0x9580F67A, 0x9579FE49, 0x9573071F, 0x956C10FC, 0x95651BE0, 0x955E27CB, - 0x955734BC, 0x955042B6, 0x954951B6, 0x954261BE, 0x953B72CD, 0x953484E3, - 0x952D9801, 0x9526AC27, 0x951FC154, 0x9518D789, 0x9511EEC6, 0x950B070A, - 0x95042057, 0x94FD3AAB, 0x94F65608, 0x94EF726C, 0x94E88FD9, 0x94E1AE4E, - 0x94DACDCB, 0x94D3EE51, 0x94CD0FDF, 0x94C63276, 0x94BF5615, 0x94B87ABD, - 0x94B1A06D, 0x94AAC727, 0x94A3EEE9, 0x949D17B4, 0x94964188, 0x948F6C65, - 0x9488984B, 0x9481C53A, 0x947AF333, 0x94742235, 0x946D5240, 0x9466839A, - 0x945FB5B8, 0x9458E8E0, 0x94521D11, 0x944B524C, 0x9444884B, 0x943DBF9A, - 0x9436F7F2, 0x94303155, 0x94296BC1, 0x9422A738, 0x941BE3B8, 0x94152143, - 0x940E5FD8, 0x94079F78, 0x9400E021, 0x93FA21D6, 0x93F36495, 0x93ECA85E, - 0x93E5ED32, 0x93DF3311, 0x93D879FB, 0x93D1C1EF, 0x93CB0AEF, 0x93C454F9, - 0x93BDA00F, 0x93B6EC2F, 0x93B0395B, 0x93A9881B, 0x93A2D75D, 0x939C27AB, - 0x93957904, 0x938ECB68, 0x93881ED9, 0x93817354, 0x937AC8DC, 0x93741F6F, - 0x936D770E, 0x9366CFB9, 0x93602970, 0x93598433, 0x9352E003, 0x934C3CDE, - 0x93459AC5, 0x933EF9B9, 0x933859B9, 0x9331BAC6, 0x932B1CDE, 0x93248004, - 0x931DE436, 0x93174975, 0x9310AFC0, 0x930A1718, 0x93037F7E, 0x92FCE8F0, - 0x92F6536F, 0x92EFBEFB, 0x92E92B94, 0x92E2993A, 0x92DC07EE, 0x92D577AE, - 0x92CEE87D, 0x92C85A58, 0x92C1CD41, 0x92BB4138, 0x92B4B63C, 0x92AE2C4E, - 0x92A7A36E, 0x92A11B9B, 0x929A94D7, 0x92940F20, 0x928D8A77, 0x928706DC, - 0x92808450, 0x927A02D1, 0x92738261, 0x926D02FF, 0x926684AC, 0x92600767, - 0x92598B30, 0x92531008, 0x924C95EF, 0x92461CE4, 0x923FA4E8, 0x92392DFB, - 0x9232B81C, 0x922C434D, 0x9225CF8D, 0x921F5CDB, 0x9218EB39, 0x92127AA6, - 0x920C0B22, 0x92059CAD, 0x91FF2F48, 0x91F8C2F3, 0x91F257AC, 0x91EBED76, - 0x91E5844E, 0x91DF1C37, 0x91D8B52F, 0x91D24F37, 0x91CBEA4F, 0x91C58677, - 0x91BF23AF, 0x91B8C1F7, 0x91B2614F, 0x91AC01B7, 0x91A5A32F, 0x919F45B8, - 0x9198E951, 0x91928DFA, 0x918C33B4, 0x9185DA7F, 0x917F825A, 0x91792B45, - 0x9172D542, 0x916C804F, 0x91662C6D, 0x915FD99C, 0x915987DC, 0x9153372C, - 0x914CE78E, 0x91469901, 0x91404B86, 0x9139FF1B, 0x9133B3C2, 0x912D697A, - 0x91272044, 0x9120D81F, 0x911A910C, 0x91144B0B, 0x910E061B, 0x9107C23C, - 0x91017F70, 0x90FB3DB6, 0x90F4FD0D, 0x90EEBD77, 0x90E87F71, 0x90E241FF, - 0x90DC059E, 0x90D5CA50, 0x90CF9014, 0x90C956EB, 0x90C31ED4, 0x90BCE7CF, - 0x90B6B1DD, 0x90B07CFE, 0x90AA4931, 0x90A41677, 0x909DE4D0, 0x9097B43B, - 0x909184BA, 0x908B564B, 0x908528EF, 0x907EFCA7, 0x9078D171, 0x9072A74F, - 0x906C7E40, 0x90665644, 0x90602F5C, 0x905A0987, 0x9053E4C5, 0x904DC118, - 0x90479E7D, 0x90417CF7, 0x903B5C84, 0x90353D25, 0x902F1ED9, 0x902901A2, - 0x9022E57E, 0x901CCA6F, 0x9016B074, 0x9010978C, 0x900A7FB9, 0x900468FA, - 0x8FFE5350, 0x8FF83EBA, 0x8FF22B38, 0x8FEC18CB, 0x8FE60772, 0x8FDFF72E, - 0x8FD9E7FF, 0x8FD3D9E4, 0x8FCDCCDE, 0x8FC7C0ED, 0x8FC1B611, 0x8FBBAC4A, - 0x8FB5A397, 0x8FAF9BFA, 0x8FA99572, 0x8FA38FFF, 0x8F9D8BA2, 0x8F978859, - 0x8F918626, 0x8F8B8509, 0x8F858501, 0x8F7F860E, 0x8F798831, 0x8F738B6A, - 0x8F6D8FB8, 0x8F67951D, 0x8F619B96, 0x8F5BA326, 0x8F55ABCC, 0x8F4FB588, - 0x8F49C05A, 0x8F43CC42, 0x8F3DD940, 0x8F37E754, 0x8F31F67F, 0x8F2C06C0, - 0x8F261817, 0x8F202A85, 0x8F1A3E09, 0x8F1452A4, 0x8F0E6855, 0x8F087F1E, - 0x8F0296FC, 0x8EFCAFF2, 0x8EF6C9FF, 0x8EF0E522, 0x8EEB015D, 0x8EE51EAE, - 0x8EDF3D16, 0x8ED95C96, 0x8ED37D2D, 0x8ECD9EDB, 0x8EC7C1A0, 0x8EC1E57D, - 0x8EBC0A71, 0x8EB6307D, 0x8EB057A0, 0x8EAA7FDB, 0x8EA4A92D, 0x8E9ED397, - 0x8E98FF19, 0x8E932BB3, 0x8E8D5964, 0x8E87882E, 0x8E81B80F, 0x8E7BE909, - 0x8E761B1A, 0x8E704E44, 0x8E6A8286, 0x8E64B7E0, 0x8E5EEE52, 0x8E5925DD, - 0x8E535EF6, 0x8E4D98B2, 0x8E47D386, 0x8E420F73, 0x8E3C4C78, 0x8E368A96, - 0x8E30C9CD, 0x8E2B0A1D, 0x8E254B86, 0x8E1F8E07, 0x8E19D1A2, 0x8E141655, - 0x8E0E5C22, 0x8E08A308, 0x8E02EB06, 0x8DFD341F, 0x8DF77E50, 0x8DF1C99B, - 0x8DEC15FF, 0x8DE6637D, 0x8DE0B215, 0x8DDB01C6, 0x8DD55290, 0x8DCFA474, - 0x8DC9F772, 0x8DC44B8A, 0x8DBEA0BC, 0x8DB8F708, 0x8DB34E6D, 0x8DADA6ED, - 0x8DA80086, 0x8DA25B3A, 0x8D9CB708, 0x8D9713F0, 0x8D9171F3, 0x8D8BD110, - 0x8D863147, 0x8D809299, 0x8D7AF505, 0x8D75588C, 0x8D6FBD2D, 0x8D6A22EA, - 0x8D6489C0, 0x8D5EF1B2, 0x8D595ABE, 0x8D53C4E6, 0x8D4E3028, 0x8D489C85, - 0x8D4309FE, 0x8D3D7891, 0x8D37E840, 0x8D32590A, 0x8D2CCAEF, 0x8D273DEF, - 0x8D21B20B, 0x8D1C2742, 0x8D169D95, 0x8D111503, 0x8D0B8D8D, 0x8D060733, - 0x8D0081F4, 0x8CFAFDD1, 0x8CF57ACA, 0x8CEFF8DE, 0x8CEA780F, 0x8CE4F85B, - 0x8CDF79C4, 0x8CD9FC48, 0x8CD47FE9, 0x8CCF04A6, 0x8CC98A7F, 0x8CC41174, - 0x8CBE9986, 0x8CB922B4, 0x8CB3ACFE, 0x8CAE3865, 0x8CA8C4E9, 0x8CA35289, - 0x8C9DE145, 0x8C98711F, 0x8C930215, 0x8C8D9428, 0x8C882758, 0x8C82BBA5, - 0x8C7D510E, 0x8C77E795, 0x8C727F39, 0x8C6D17FA, 0x8C67B1D8, 0x8C624CD3, - 0x8C5CE8EC, 0x8C578622, 0x8C522475, 0x8C4CC3E6, 0x8C476474, 0x8C42061F, - 0x8C3CA8E9, 0x8C374CD0, 0x8C31F1D4, 0x8C2C97F7, 0x8C273F37, 0x8C21E795, - 0x8C1C9111, 0x8C173BAA, 0x8C11E762, 0x8C0C9438, 0x8C07422C, 0x8C01F13E, - 0x8BFCA16F, 0x8BF752BD, 0x8BF20596, 0x8BECB921, 0x8BE76DCB, 0x8BE22393, - 0x8BDCDA79, 0x8BD7927E, 0x8BD24BA2, 0x8BCD05E4, 0x8BC7C145, 0x8BC27DC5, - 0x8BBD3B64, 0x8BB7FA21, 0x8BB2B9FE, 0x8BAD7AF9, 0x8BA83D14, 0x8BA3004D, - 0x8B9DC4A6, 0x8B988A1D, 0x8B9350B4, 0x8B8E186B, 0x8B88E140, 0x8B83AB35, - 0x8B7E7649, 0x8B79427D, 0x8B740FD0, 0x8B6EDE43, 0x8B69ADD6, 0x8B647E88, - 0x8B5F505A, 0x8B5A234C, 0x8B54F75D, 0x8B4FCC8E, 0x8B4AA2E0, 0x8B457A51, - 0x8B4052E2, 0x8B3B2C93, 0x8B360765, 0x8B30E357, 0x8B2BC068, 0x8B269E9A, - 0x8B217DED, 0x8B1C5E60, 0x8B173FF3, 0x8B1222A6, 0x8B0D067B, 0x8B07EB6F, - 0x8B02D185, 0x8AFDB8BB, 0x8AF8A111, 0x8AF38A89, 0x8AEE7521, 0x8AE960DA, - 0x8AE44DB4, 0x8ADF3BAF, 0x8ADA2ACB, 0x8AD51B08, 0x8AD00C66, 0x8ACAFEE6, - 0x8AC5F286, 0x8AC0E748, 0x8ABBDD2B, 0x8AB6D42F, 0x8AB1CC55, 0x8AACC59C, - 0x8AA7C005, 0x8AA2BB8F, 0x8A9DB83B, 0x8A98B609, 0x8A93B4F8, 0x8A8EB509, - 0x8A89B63B, 0x8A84B890, 0x8A7FBC06, 0x8A7AC09E, 0x8A75C659, 0x8A70CD35, - 0x8A6BD533, 0x8A66DE54, 0x8A61E896, 0x8A5CF3FB, 0x8A580082, 0x8A530E2C, - 0x8A4E1CF7, 0x8A492CE5, 0x8A443DF6, 0x8A3F5029, 0x8A3A637F, 0x8A3577F7, - 0x8A308D92, 0x8A2BA44F, 0x8A26BC30, 0x8A21D533, 0x8A1CEF59, 0x8A180AA2, - 0x8A13270D, 0x8A0E449C, 0x8A09634E, 0x8A048322, 0x89FFA41A, 0x89FAC635, - 0x89F5E974, 0x89F10DD5, 0x89EC335A, 0x89E75A02, 0x89E281CD, 0x89DDAABC, - 0x89D8D4CF, 0x89D40005, 0x89CF2C5E, 0x89CA5A3E, 0x89C588DF, 0x89C0B8A3, - 0x89BBE98B, 0x89B71B97, 0x89B24EC7, 0x89AD831B, 0x89A8B893, 0x89A3EF2F, - 0x899F26EF, 0x899A5FD2, 0x899599DA, 0x8990D507, 0x898C1157, 0x89874ECC, - 0x89828D65, 0x897DCD22, 0x89790E04, 0x8974500A, 0x896F9335, 0x896AD784, - 0x89661CF8, 0x89616391, 0x895CAB4E, 0x8957F430, 0x89533E37, 0x894E8962, - 0x8949D5B3, 0x89452328, 0x894071C2, 0x893BC182, 0x89371266, 0x8932646F, - 0x892DB79E, 0x89290BF2, 0x8924616B, 0x891FB809, 0x891B0FCC, 0x891668B5, - 0x8911C2C4, 0x890D1DF7, 0x89087A51, 0x8903D7D0, 0x88FF3674, 0x88FA963E, - 0x88F5F72E, 0x88F15943, 0x88ECBC7E, 0x88E820DF, 0x88E38666, 0x88DEED13, - 0x88DA54E6, 0x88D5BDDE, 0x88D127FD, 0x88CC9342, 0x88C7FFAD, 0x88C36D3E, - 0x88BEDBF5, 0x88BA4BD2, 0x88B5BCD6, 0x88B12F00, 0x88ACA251, 0x88A816C8, - 0x88A38C65, 0x889F0329, 0x889A7B14, 0x8895F425, 0x88916E5C, 0x888CE9BB, - 0x88886640, 0x8883E3EC, 0x887F62BF, 0x887AE2B8, 0x887663D9, 0x8871E620, - 0x886D698F, 0x8868EE24, 0x886473E1, 0x885FFAC5, 0x885B82CF, 0x88570C01, - 0x8852965B, 0x884E21DB, 0x8849AE83, 0x88453C53, 0x8840CB49, 0x883C5B68, - 0x8837ECAD, 0x88337F1B, 0x882F12AF, 0x882AA76C, 0x88263D50, 0x8821D45C, - 0x881D6C90, 0x881905EB, 0x8814A06E, 0x88103C1A, 0x880BD8ED, 0x880776E8, - 0x8803160B, 0x87FEB656, 0x87FA57CA, 0x87F5FA65, 0x87F19E29, 0x87ED4315, - 0x87E8E929, 0x87E49065, 0x87E038CA, 0x87DBE257, 0x87D78D0D, 0x87D33943, - 0x87CEE64A, 0x87CA9479, 0x87C643D0, 0x87C1F451, 0x87BDA5FA, 0x87B958CB, - 0x87B50CC6, 0x87B0C1E9, 0x87AC7836, 0x87A82FAB, 0x87A3E849, 0x879FA210, - 0x879B5D00, 0x87971919, 0x8792D65B, 0x878E94C6, 0x878A545B, 0x87861519, - 0x8781D700, 0x877D9A10, 0x87795E4A, 0x877523AD, 0x8770EA39, 0x876CB1EF, - 0x87687ACF, 0x876444D8, 0x8760100A, 0x875BDC66, 0x8757A9EC, 0x8753789C, - 0x874F4875, 0x874B1978, 0x8746EBA5, 0x8742BEFC, 0x873E937D, 0x873A6928, - 0x87363FFD, 0x873217FB, 0x872DF124, 0x8729CB77, 0x8725A6F4, 0x8721839B, - 0x871D616D, 0x87194069, 0x8715208F, 0x871101DF, 0x870CE45A, 0x8708C800, - 0x8704ACCF, 0x870092CA, 0x86FC79EE, 0x86F8623E, 0x86F44BB8, 0x86F0365D, - 0x86EC222C, 0x86E80F26, 0x86E3FD4B, 0x86DFEC9B, 0x86DBDD16, 0x86D7CEBB, - 0x86D3C18C, 0x86CFB587, 0x86CBAAAE, 0x86C7A0FF, 0x86C3987C, 0x86BF9124, - 0x86BB8AF7, 0x86B785F5, 0x86B3821F, 0x86AF7F73, 0x86AB7DF4, 0x86A77D9F, - 0x86A37E76, 0x869F8078, 0x869B83A6, 0x869787FF, 0x86938D84, 0x868F9435, - 0x868B9C11, 0x8687A519, 0x8683AF4C, 0x867FBAAC, 0x867BC737, 0x8677D4EE, - 0x8673E3D1, 0x866FF3DF, 0x866C051A, 0x86681781, 0x86642B13, 0x86603FD2, - 0x865C55BD, 0x86586CD4, 0x86548517, 0x86509E86, 0x864CB922, 0x8648D4EA, - 0x8644F1DE, 0x86410FFE, 0x863D2F4B, 0x86394FC5, 0x8635716B, 0x8631943D, - 0x862DB83C, 0x8629DD67, 0x862603BF, 0x86222B44, 0x861E53F6, 0x861A7DD4, - 0x8616A92D, 0x8612D565, 0x860F02C9, 0x860B315A, 0x86076119, 0x86039204, - 0x85FFC41C, 0x85FBF762, 0x85F82BD4, 0x85F46173, 0x85F09840, 0x85ECD03A, - 0x85E90961, 0x85E543B5, 0x85E17F36, 0x85DDBBE5, 0x85D9F9C2, 0x85D638CB, - 0x85D27902, 0x85CEBA67, 0x85CAFCF8, 0x85C740B8, 0x85C385A5, 0x85BFCBC0, - 0x85BC1308, 0x85B85B7E, 0x85B4A522, 0x85B0EFF3, 0x85AD3BF2, 0x85A98920, - 0x85A5D77A, 0x85A22703, 0x859E77BA, 0x859AC99F, 0x85971CB1, 0x859370F2, - 0x858FC661, 0x858C1CFE, 0x858874C9, 0x8584CDC2, 0x858127EA, 0x857D833F, - 0x8579DFC3, 0x85763D76, 0x85729C56, 0x856EFC66, 0x856B5DA3, 0x8567C00F, - 0x856423A9, 0x85608872, 0x855CEE6A, 0x85595590, 0x8555BDE5, 0x85522768, - 0x854E921A, 0x854AFDFB, 0x85476B0B, 0x8543D949, 0x854048B6, 0x853CB952, - 0x85392B1D, 0x85359E17, 0x85321240, 0x852E8798, 0x852AFE1F, 0x852775D5, - 0x8523EEBA, 0x852068CF, 0x851CE412, 0x85196085, 0x8515DE27, 0x85125CF8, - 0x850EDCF9, 0x850B5E29, 0x8507E088, 0x85046417, 0x8500E8D5, 0x84FD6EC3, - 0x84F9F5E0, 0x84F67E2C, 0x84F307A9, 0x84EF9255, 0x84EC1E30, 0x84E8AB3C, - 0x84E53976, 0x84E1C8E1, 0x84DE597C, 0x84DAEB46, 0x84D77E40, 0x84D4126A, - 0x84D0A7C4, 0x84CD3E4E, 0x84C9D608, 0x84C66EF2, 0x84C3090C, 0x84BFA456, - 0x84BC40D0, 0x84B8DE7A, 0x84B57D55, 0x84B21D60, 0x84AEBE9A, 0x84AB6106, - 0x84A804A1, 0x84A4A96D, 0x84A14F69, 0x849DF696, 0x849A9EF3, 0x84974880, - 0x8493F33E, 0x84909F2D, 0x848D4C90, 0x8489FADF, 0x8486AA60, 0x84835B11, - 0x84800CF2, 0x847CC005, 0x84797448, 0x847629BC, 0x8472E060, 0x846F9836, - 0x846C513C, 0x84690B74, 0x8465C6DC, 0x84628375, 0x845F4140, 0x845C003B, - 0x8458C067, 0x845581C5, 0x84524453, 0x844F0813, 0x844BCD04, 0x84489327, - 0x84455A7A, 0x844222FF, 0x843EECB5, 0x843BB79C, 0x843883B5, 0x84355100, - 0x84321F7B, 0x842EEF28, 0x842BC007, 0x84289217, 0x84256559, 0x842239CD, - 0x841F0F72, 0x841BE648, 0x8418BE51, 0x8415978B, 0x841271F7, 0x840F4D94, - 0x840C2A64, 0x84090865, 0x8405E798, 0x8402C7FD, 0x83FFA994, 0x83FC8C5D, - 0x83F97058, 0x83F65585, 0x83F33BE4, 0x83F02375, 0x83ED0C38, 0x83E9F62E, - 0x83E6E155, 0x83E3CDAF, 0x83E0BB3B, 0x83DDA9F9, 0x83DA99EA, 0x83D78B0D, - 0x83D47D62, 0x83D170E9, 0x83CE65A3, 0x83CB5B90, 0x83C852AF, 0x83C54B00, - 0x83C24484, 0x83BF3F3A, 0x83BC3B23, 0x83B9383F, 0x83B6368D, 0x83B3360E, - 0x83B036C2, 0x83AD38A8, 0x83AA3BC2, 0x83A7400E, 0x83A4458C, 0x83A14C3E, - 0x839E5422, 0x839B5D3A, 0x83986784, 0x83957301, 0x83927FB2, 0x838F8D95, - 0x838C9CAB, 0x8389ACF4, 0x8386BE71, 0x8383D121, 0x8380E503, 0x837DFA19, - 0x837B1062, 0x837827DF, 0x8375408E, 0x83725A71, 0x836F7588, 0x836C91D1, - 0x8369AF4E, 0x8366CDFF, 0x8363EDE3, 0x83610EFA, 0x835E3145, 0x835B54C3, - 0x83587975, 0x83559F5A, 0x8352C674, 0x834FEEC0, 0x834D1841, 0x834A42F5, - 0x83476EDC, 0x83449BF8, 0x8341CA47, 0x833EF9CA, 0x833C2ABA, 0x83395CA5, - 0x83368FC3, 0x8333C416, 0x8330F99C, 0x832E3056, 0x832B6844, 0x8328A167, - 0x8325DBBD, 0x83231747, 0x83205406, 0x831D91F8, 0x831AD11F, 0x8318117A, - 0x83155309, 0x831295CC, 0x830FD9C4, 0x830D1EF0, 0x830A6550, 0x8307ACE4, - 0x8304F5AD, 0x83023FAA, 0x82FF8ADC, 0x82FCD742, 0x82FA24DC, 0x82F773AB, - 0x82F4C3AF, 0x82F214E7, 0x82EF6753, 0x82ECBAF4, 0x82EA0FCA, 0x82E765D4, - 0x82E4BD13, 0x82E21587, 0x82DF6F30, 0x82DCCA0D, 0x82DA261F, 0x82D78365, - 0x82D4E1E1, 0x82D24191, 0x82CFA277, 0x82CD0491, 0x82CA67E0, 0x82C7CC64, - 0x82C5321D, 0x82C2990B, 0x82C0012E, 0x82BD6A86, 0x82BAD513, 0x82B840D5, - 0x82B5ADCD, 0x82B31BF9, 0x82B08B5B, 0x82ADFBF2, 0x82AB6DBE, 0x82A8E0BF, - 0x82A654F6, 0x82A3CA62, 0x82A14103, 0x829EB8D9, 0x829C31E5, 0x8299AC26, - 0x8297279D, 0x8294A449, 0x8292222B, 0x828FA142, 0x828D218E, 0x828AA311, - 0x828825C8, 0x8285A9B6, 0x82832ED8, 0x8280B531, 0x827E3CBF, 0x827BC583, - 0x82794F7C, 0x8276DAAC, 0x82746711, 0x8271F4AB, 0x826F837C, 0x826D1382, - 0x826AA4BF, 0x82683731, 0x8265CAD9, 0x82635FB6, 0x8260F5CA, 0x825E8D14, - 0x825C2594, 0x8259BF4A, 0x82575A35, 0x8254F657, 0x825293AF, 0x8250323D, - 0x824DD201, 0x824B72FC, 0x8249152C, 0x8246B893, 0x82445D30, 0x82420303, - 0x823FAA0C, 0x823D524C, 0x823AFBC2, 0x8238A66E, 0x82365251, 0x8233FF6A, - 0x8231ADB9, 0x822F5D3F, 0x822D0DFB, 0x822ABFEE, 0x82287317, 0x822627A5, - 0x8223DD3C, 0x82219408, 0x821F4C0B, 0x821D0545, 0x821ABFB6, 0x82187B5D, - 0x8216383B, 0x8213F64F, 0x8211B59A, 0x820F761C, 0x820D37D5, 0x820AFAC4, - 0x8208BEEA, 0x82068447, 0x82044ADB, 0x820212A5, 0x81FFDBA7, 0x81FDA5DF, - 0x81FB714F, 0x81F93DF5, 0x81F70BD2, 0x81F4DAE6, 0x81F2AB32, 0x81F07CB4, - 0x81EE4F6D, 0x81EC235D, 0x81E9F885, 0x81E7CEE3, 0x81E5A679, 0x81E37F46, - 0x81E1594A, 0x81DF3485, 0x81DD10F7, 0x81DAEEA1, 0x81D8CD82, 0x81D6AD9A, - 0x81D48EE9, 0x81D27170, 0x81D0552E, 0x81CE3A24, 0x81CC2050, 0x81CA07B5, - 0x81C7F050, 0x81C5DA23, 0x81C3C52E, 0x81C1B170, 0x81BF9EE9, 0x81BD8D9A, - 0x81BB7D83, 0x81B96EA3, 0x81B760FA, 0x81B5548A, 0x81B34950, 0x81B13F4F, - 0x81AF3685, 0x81AD2EF3, 0x81AB2898, 0x81A92376, 0x81A71F8A, 0x81A51CD7, - 0x81A31B5C, 0x81A11B18, 0x819F1C0C, 0x819D1E38, 0x819B219C, 0x81992637, - 0x81972C0B, 0x81953316, 0x81933B59, 0x819144D5, 0x818F4F88, 0x818D5B73, - 0x818B6896, 0x818976F2, 0x81878685, 0x81859750, 0x8183A954, 0x8181BC8F, - 0x817FD103, 0x817DE6AE, 0x817BFD92, 0x817A15AE, 0x81782F02, 0x8176498F, - 0x81746554, 0x81728250, 0x8170A086, 0x816EBFF3, 0x816CE099, 0x816B0277, - 0x8169258D, 0x816749DC, 0x81656F63, 0x81639622, 0x8161BE1A, 0x815FE74A, - 0x815E11B3, 0x815C3D54, 0x815A6A2E, 0x81589840, 0x8156C78B, 0x8154F80E, - 0x815329CA, 0x81515CBE, 0x814F90EB, 0x814DC650, 0x814BFCEE, 0x814A34C5, - 0x81486DD4, 0x8146A840, 0x8144E3C1, 0x8143207A, 0x81415E6C, 0x813F9D97, - 0x813DDDFA, 0x813C1F97, 0x813A626C, 0x8138A679, 0x8136EBC0, 0x81353240, - 0x813379F8, 0x8131C2E9, 0x81300D13, 0x812E5876, 0x812CA512, 0x812AF2E7, - 0x812941F5, 0x8127923B, 0x8125E3BB, 0x81243674, 0x81228A65, 0x8120DF90, - 0x811F35F4, 0x811D8D91, 0x811BE667, 0x811A4076, 0x81189BBE, 0x8116F83F, - 0x811555F9, 0x8113B4ED, 0x8112151A, 0x81107680, 0x810ED91F, 0x810D3CF7, - 0x810BA209, 0x810A0853, 0x81086FD7, 0x8106D895, 0x8105428B, 0x8103ADBB, - 0x81021A25, 0x810087C7, 0x80FEF6A3, 0x80FD66B9, 0x80FBD807, 0x80FA4A90, - 0x80F8BE51, 0x80F7334C, 0x80F5A981, 0x80F420EE, 0x80F29996, 0x80F11377, - 0x80EF8E91, 0x80EE0AE5, 0x80EC8872, 0x80EB0739, 0x80E9873A, 0x80E80874, - 0x80E68AE8, 0x80E50E95, 0x80E3937C, 0x80E2199D, 0x80E0A0F7, 0x80DF298B, - 0x80DDB358, 0x80DC3E5F, 0x80DACAA0, 0x80D9581B, 0x80D7E6D0, 0x80D676BE, - 0x80D507E6, 0x80D39A47, 0x80D22DE3, 0x80D0C2B8, 0x80CF58C7, 0x80CDF010, - 0x80CC8893, 0x80CB2250, 0x80C9BD46, 0x80C85977, 0x80C6F6E1, 0x80C59585, - 0x80C43563, 0x80C2D67B, 0x80C178CD, 0x80C01C59, 0x80BEC11F, 0x80BD671F, - 0x80BC0E59, 0x80BAB6CD, 0x80B9607B, 0x80B80B63, 0x80B6B785, 0x80B564E2, - 0x80B41378, 0x80B2C348, 0x80B17453, 0x80B02697, 0x80AEDA16, 0x80AD8ECF, - 0x80AC44C2, 0x80AAFBEF, 0x80A9B456, 0x80A86DF8, 0x80A728D4, 0x80A5E4EA, - 0x80A4A23A, 0x80A360C4, 0x80A22089, 0x80A0E1A1, 0x809FA3DA, 0x809E674E, - 0x809D2BFC, 0x809BF1E4, 0x809AB906, 0x80998163, 0x80984AFA, 0x809715CB, - 0x8095E1D7, 0x8094AF1D, 0x80937D9E, 0x80924D59, 0x80911E4E, 0x808FF07E, - 0x808EC3E8, 0x808D988D, 0x808C6E6C, 0x808B4586, 0x808A1DDA, 0x8088F769, - 0x8087D232, 0x8086AE36, 0x80858B74, 0x808469ED, 0x808349A0, 0x80822A8E, - 0x80810CB6, 0x807FF019, 0x807ED4B7, 0x807DBA8F, 0x807CA1A2, 0x807B89F0, - 0x807A7378, 0x80795E3B, 0x80784A38, 0x80773770, 0x807625E3, 0x80751590, - 0x80740679, 0x8072F89B, 0x8071EBF9, 0x8070E091, 0x806FD664, 0x806ECD72, - 0x806DC5BB, 0x806CBF3E, 0x806BB9FC, 0x806AB5F5, 0x8069B329, 0x8068B198, - 0x8067B141, 0x8066B225, 0x8065B444, 0x8064B79E, 0x8063BC33, 0x8062C202, - 0x8061C90D, 0x8060D152, 0x805FDAD3, 0x805EE58E, 0x805DF184, 0x805CFEB5, - 0x805C0D21, 0x805B1CC8, 0x805A2DA9, 0x80593FC6, 0x8058531E, 0x805767B1, - 0x80567D7F, 0x80559487, 0x8054ACCB, 0x8053C64A, 0x8052E104, 0x8051FCF8, - 0x80511A28, 0x80503893, 0x804F5839, 0x804E791A, 0x804D9B36, 0x804CBE8D, - 0x804BE31F, 0x804B08ED, 0x804A2FF5, 0x80495839, 0x804881B8, 0x8047AC71, - 0x8046D866, 0x80460596, 0x80453402, 0x804463A8, 0x8043948A, 0x8042C6A6, - 0x8041F9FE, 0x80412E92, 0x80406460, 0x803F9B69, 0x803ED3AE, 0x803E0D2E, - 0x803D47E9, 0x803C83E0, 0x803BC112, 0x803AFF7F, 0x803A3F27, 0x8039800A, - 0x8038C229, 0x80380583, 0x80374A18, 0x80368FE9, 0x8035D704, 0x80351F4B, - 0x803468CD, 0x8033B38B, 0x8032FF84, 0x80324CB9, 0x80319B28, 0x8030EAD4, - 0x80303BBA, 0x802F8DDC, 0x802EE139, 0x802E35D2, 0x802D8BA6, 0x802CE2B5, - 0x802C3B00, 0x802B9486, 0x802AEF48, 0x802A4B45, 0x8029A87D, 0x802906F1, - 0x802866A0, 0x8027C78B, 0x802729B1, 0x80268D13, 0x8025F1B0, 0x80255789, - 0x8024BE9D, 0x802426EC, 0x80239077, 0x8022FB3E, 0x80226740, 0x8021D47D, - 0x802142F6, 0x8020B2AB, 0x8020239B, 0x801F95C6, 0x801F092D, 0x801E7DD0, - 0x801DF3AE, 0x801D6AC7, 0x801CE31D, 0x801C5CAD, 0x801BD77A, 0x801B5381, - 0x801AD0C5, 0x801A4F44, 0x8019CEFE, 0x80194FF5, 0x8018D226, 0x80185594, - 0x8017DA3D, 0x80176021, 0x8016E741, 0x80166F9D, 0x8015F934, 0x80158407, - 0x80151016, 0x80149D60, 0x80142BE6, 0x8013BBA7, 0x80134CA4, 0x8012DEDD, - 0x80127252, 0x80120702, 0x80119CED, 0x80113415, 0x8010CC78, 0x80106616, - 0x801000F1, 0x800F9D07, 0x800F3A58, 0x800ED8E6, 0x800E78AF, 0x800E19B4, - 0x800DBBF4, 0x800D5F70, 0x800D0428, 0x800CAA1C, 0x800C514B, 0x800BF9B6, - 0x800BA35D, 0x800B4E3F, 0x800AFA5D, 0x800AA7B7, 0x800A564D, 0x800A061E, - 0x8009B72B, 0x80096974, 0x80091CF8, 0x8008D1B9, 0x800887B5, 0x80083EEC, - 0x8007F760, 0x8007B10F, 0x80076BFA, 0x80072821, 0x8006E584, 0x8006A422, - 0x800663FC, 0x80062512, 0x8005E763, 0x8005AAF1, 0x80056FBA, 0x800535BF, - 0x8004FCFF, 0x8004C57C, 0x80048F34, 0x80045A28, 0x80042658, 0x8003F3C4, - 0x8003C26F, 0x80039252, 0x80036371, 0x800335CC, 0x80030962, 0x8002DE35, - 0x8002B443, 0x80028B8D, 0x80026412, 0x80023DD4, 0x800218D1, 0x8001F50A, - 0x8001D27F, 0x8001B130, 0x8001911C, 0x80017245, 0x800154A9, 0x80013849, - 0x80011D25, 0x8001033D, 0x8000EA90, 0x8000D31F, 0x8000BCEA, 0x8000A7F1, - 0x80009434, 0x800081B3, 0x8000706D, 0x80006063, 0x80005195, 0x80004403, - 0x800037AD, 0x80002C92, 0x800022B4, 0x80001A11, 0x800012AA, 0x80000C7F, - 0x8000078F, 0x800003DC, 0x80000164, 0x80000028 -}; - -const int32_t sine_2048[] ICONST_ATTR_WMAPRO_WIN_VS_TMP = { - 0xFFF36F03, 0xFFDA4D09, 0xFFC12B0F, 0xFFA80918, 0xFF8EE725, 0xFF75C536, - 0xFF5CA34B, 0xFF438168, 0xFF2A5F8C, 0xFF113DB7, 0xFEF81BEE, 0xFEDEFA2D, - 0xFEC5D876, 0xFEACB6CE, 0xFE939531, 0xFE7A73A2, 0xFE615224, 0xFE4830B4, - 0xFE2F0F55, 0xFE15EE0A, 0xFDFCCCD0, 0xFDE3ABAA, 0xFDCA8A98, 0xFDB1699D, - 0xFD9848BC, 0xFD7F27EF, 0xFD66073A, 0xFD4CE69F, 0xFD33C61F, 0xFD1AA5BB, - 0xFD018577, 0xFCE8654C, 0xFCCF4541, 0xFCB62554, 0xFC9D0588, 0xFC83E5DE, - 0xFC6AC65A, 0xFC51A6F5, 0xFC3887B4, 0xFC1F6899, 0xFC0649A4, 0xFBED2AD7, - 0xFBD40C35, 0xFBBAEDB5, 0xFBA1CF67, 0xFB88B144, 0xFB6F9345, 0xFB56757B, - 0xFB3D57D7, 0xFB243A6A, 0xFB0B1D25, 0xFAF20019, 0xFAD8E33F, 0xFABFC690, - 0xFAA6AA1D, 0xFA8D8DD6, 0xFA7471CD, 0xFA5B55FB, 0xFA423A59, 0xFA291EF7, - 0xFA1003C7, 0xF9F6E8D9, 0xF9DDCE1F, 0xF9C4B3AA, 0xF9AB9972, 0xF9927F70, - 0xF97965B6, 0xF9604C34, 0xF94732FC, 0xF92E1A06, 0xF915014C, 0xF8FBE8DD, - 0xF8E2D0AC, 0xF8C9B8C9, 0xF8B0A126, 0xF89789D2, 0xF87E72C8, 0xF8655BFF, - 0xF84C458A, 0xF8332F59, 0xF81A197C, 0xF80103EE, 0xF7E7EEA7, 0xF7CED9AF, - 0xF7B5C518, 0xF79CB0C3, 0xF7839CC1, 0xF76A8923, 0xF75175C9, 0xF73862C5, - 0xF71F5018, 0xF7063DD2, 0xF6ED2BD5, 0xF6D41A32, 0xF6BB08F9, 0xF6A1F80B, - 0xF688E77A, 0xF66FD747, 0xF656C781, 0xF63DB80B, 0xF624A8F6, 0xF60B9A51, - 0xF5F28BFF, 0xF5D97E11, 0xF5C07096, 0xF5A76370, 0xF58E56B1, 0xF5754A59, - 0xF55C3E78, 0xF54332F1, 0xF52A27D4, 0xF5111D31, 0xF4F812EB, 0xF4DF0911, - 0xF4C5FFA6, 0xF4ACF6B9, 0xF493EE2B, 0xF47AE60F, 0xF461DE74, 0xF448D73C, - 0xF42FD078, 0xF416CA28, 0xF3FDC45D, 0xF3E4BEFA, 0xF3CBBA0D, 0xF3B2B5A9, - 0xF399B1AF, 0xF380AE2F, 0xF367AB3A, 0xF34EA8B2, 0xF335A6A7, 0xF31CA51A, - 0xF303A41C, 0xF2EAA38E, 0xF2D1A382, 0xF2B8A408, 0xF29FA500, 0xF286A67D, - 0xF26DA87F, 0xF254AB17, 0xF23BAE25, 0xF222B1BC, 0xF209B5EB, 0xF1F0BA94, - 0xF1D7BFC8, 0xF1BEC588, 0xF1A5CBE4, 0xF18CD2BE, 0xF173DA26, 0xF15AE22E, - 0xF141EAB7, 0xF128F3D1, 0xF10FFD8E, 0xF0F707CE, 0xF0DE12A2, 0xF0C51E0C, - 0xF0AC2A1C, 0xF09336B4, 0xF07A43E3, 0xF06151BC, 0xF048601F, 0xF02F6F1D, - 0xF0167EB8, 0xEFFD8EFF, 0xEFE49FD4, 0xEFCBB148, 0xEFB2C35C, 0xEF99D612, - 0xEF80E988, 0xEF67FD82, 0xEF4F121F, 0xEF362762, 0xEF1D3D4A, 0xEF0453D8, - 0xEEEB6B0F, 0xEED2830D, 0xEEB99B95, 0xEEA0B4C8, 0xEE87CEA7, 0xEE6EE931, - 0xEE560469, 0xEE3D2050, 0xEE243D05, 0xEE0B5A4B, 0xEDF27842, 0xEDD996EC, - 0xEDC0B648, 0xEDA7D659, 0xED8EF73E, 0xED7618BA, 0xED5D3AED, 0xED445DD7, - 0xED2B817B, 0xED12A5D8, 0xECF9CAF0, 0xECE0F0E3, 0xECC81774, 0xECAF3EC2, - 0xEC9666CF, 0xEC7D8F9C, 0xEC64B929, 0xEC4BE377, 0xEC330EA8, 0xEC1A3A7C, - 0xEC016715, 0xEBE89473, 0xEBCFC298, 0xEBB6F184, 0xEB9E2138, 0xEB8551D4, - 0xEB6C831B, 0xEB53B52E, 0xEB3AE80C, 0xEB221BB7, 0xEB095031, 0xEAF08579, - 0xEAD7BBB0, 0xEABEF299, 0xEAA62A54, 0xEA8D62E1, 0xEA749C42, 0xEA5BD678, - 0xEA431183, 0xEA2A4D84, 0xEA118A3E, 0xE9F8C7CF, 0xE9E0063B, 0xE9C74580, - 0xE9AE85A1, 0xE995C69E, 0xE97D0898, 0xE9644B50, 0xE94B8EE8, 0xE932D360, - 0xE91A18B9, 0xE9015EF3, 0xE8E8A631, 0xE8CFEE32, 0xE8B73719, 0xE89E80E5, - 0xE885CB98, 0xE86D1733, 0xE85463B6, 0xE83BB143, 0xE822FF9A, 0xE80A4EDE, - 0xE7F19F0D, 0xE7D8F02A, 0xE7C04236, 0xE7A79530, 0xE78EE93B, 0xE7763E17, - 0xE75D93E6, 0xE744EAA7, 0xE72C425D, 0xE7139B08, 0xE6FAF4A8, 0xE6E24F5F, - 0xE6C9AAEF, 0xE6B10777, 0xE69864F9, 0xE67FC376, 0xE66722EF, 0xE64E8364, - 0xE635E4F6, 0xE61D4767, 0xE604AAD8, 0xE5EC0F49, 0xE5D374BC, 0xE5BADB31, - 0xE5A242A9, 0xE589AB45, 0xE57114C6, 0xE5587F4E, 0xE53FEADD, 0xE5275773, - 0xE50EC513, 0xE4F633DC, 0xE4DDA391, 0xE4C51451, 0xE4AC861E, 0xE493F8F9, - 0xE47B6CE2, 0xE462E1DB, 0xE44A5804, 0xE431CF1F, 0xE419474D, 0xE400C08D, - 0xE3E83AE3, 0xE3CFB64D, 0xE3B732CE, 0xE39EB085, 0xE3862F34, 0xE36DAEFD, - 0xE3552FE0, 0xE33CB1DE, 0xE32434F8, 0xE30BB92F, 0xE2F33EA2, 0xE2DAC515, - 0xE2C24CA8, 0xE2A9D55B, 0xE2915F30, 0xE278EA27, 0xE2607642, 0xE24803A0, - 0xE22F9205, 0xE217218F, 0xE1FEB241, 0xE1E6441B, 0xE1CDD71E, 0xE1B56B4C, - 0xE19D00C3, 0xE1849747, 0xE16C2EF8, 0xE153C7D6, 0xE13B61E4, 0xE122FD21, - 0xE10A998E, 0xE0F2374C, 0xE0D9D61E, 0xE0C17623, 0xE0A9175D, 0xE090B9CC, - 0xE0785D71, 0xE060026C, 0xE047A880, 0xE02F4FCE, 0xE016F855, 0xDFFEA217, - 0xDFE64D16, 0xDFCDF951, 0xDFB5A6C9, 0xDF9D5581, 0xDF850578, 0xDF6CB6B0, - 0xDF546967, 0xDF3C1D23, 0xDF23D222, 0xDF0B8865, 0xDEF33FEE, 0xDEDAF8BD, - 0xDEC2B2D2, 0xDEAA6E30, 0xDE922AD7, 0xDE79E8C8, 0xDE61A804, 0xDE49688C, - 0xDE312A60, 0xDE18EDC0, 0xDE00B230, 0xDDE877F1, 0xDDD03F01, 0xDDB80763, - 0xDD9FD118, 0xDD879C1F, 0xDD6F687B, 0xDD57362C, 0xDD3F0533, 0xDD26D591, - 0xDD0EA747, 0xDCF67A56, 0xDCDE4EBF, 0xDCC624C0, 0xDCADFBDF, 0xDC95D45B, - 0xDC7DAE34, 0xDC65896C, 0xDC4D6603, 0xDC3543FA, 0xDC1D2353, 0xDC05040E, - 0xDBECE62C, 0xDBD4C9AE, 0xDBBCAE95, 0xDBA494E1, 0xDB8C7C95, 0xDB7465EE, - 0xDB5C5072, 0xDB443C60, 0xDB2C29B8, 0xDB14187C, 0xDAFC08AC, 0xDAE3FA4A, - 0xDACBED56, 0xDAB3E1D1, 0xDA9BD7BC, 0xDA83CF18, 0xDA6BC7E6, 0xDA53C227, - 0xDA3BBDDC, 0xDA23BB42, 0xDA0BB9E1, 0xD9F3B9F7, 0xD9DBBB85, 0xD9C3BE8A, - 0xD9ABC309, 0xD993C903, 0xD97BD077, 0xD963D968, 0xD94BE3D6, 0xD933EFC2, - 0xD91BFD2D, 0xD9040C17, 0xD8EC1CC0, 0xD8D42EAD, 0xD8BC421C, 0xD8A4570F, - 0xD88C6D87, 0xD8748584, 0xD85C9F07, 0xD844BA12, 0xD82CD6A4, 0xD814F4C0, - 0xD7FD1466, 0xD7E53596, 0xD7CD5853, 0xD7B57C9C, 0xD79DA2AF, 0xD785CA15, - 0xD76DF309, 0xD7561D8F, 0xD73E49A5, 0xD726774E, 0xD70EA68A, 0xD6F6D75A, - 0xD6DF09BF, 0xD6C73DBA, 0xD6AF734C, 0xD697AA76, 0xD67FE338, 0xD6681D94, - 0xD65059C7, 0xD6389759, 0xD620D687, 0xD6091753, 0xD5F159BC, 0xD5D99DC5, - 0xD5C1E36E, 0xD5AA2AB7, 0xD59273A3, 0xD57ABE31, 0xD5630A63, 0xD54B5839, - 0xD533A7B5, 0xD51BF914, 0xD5044BDE, 0xD4ECA050, 0xD4D4F66B, 0xD4BD4E30, - 0xD4A5A7A0, 0xD48E02BC, 0xD4765F85, 0xD45EBDFB, 0xD4471E20, 0xD42F7FF5, - 0xD417E37A, 0xD40048B0, 0xD3E8AF98, 0xD3D11870, 0xD3B982C0, 0xD3A1EEC5, - 0xD38A5C80, 0xD372CBF1, 0xD35B3D1A, 0xD343AFFC, 0xD32C2497, 0xD3149AED, - 0xD2FD12FE, 0xD2E58CCC, 0xD2CE0856, 0xD2B6859F, 0xD29F04A6, 0xD28785AA, - 0xD2700832, 0xD2588C7C, 0xD2411288, 0xD2299A58, 0xD21223EC, 0xD1FAAF46, - 0xD1E33C66, 0xD1CBCB4D, 0xD1B45BFC, 0xD19CEE74, 0xD18582B6, 0xD16E18C2, - 0xD156B0D6, 0xD13F4A7A, 0xD127E5EC, 0xD110832D, 0xD0F9223C, 0xD0E1C31C, - 0xD0CA65CD, 0xD0B30A50, 0xD09BB0A5, 0xD08458CF, 0xD06D02CD, 0xD055AEA0, - 0xD03E5C4A, 0xD0270BCB, 0xD00FBD60, 0xCFF87093, 0xCFE1259F, 0xCFC9DC87, - 0xCFB2954B, 0xCF9B4FEB, 0xCF840C68, 0xCF6CCAC5, 0xCF558B01, 0xCF3E4D1D, - 0xCF27111A, 0xCF0FD6F9, 0xCEF89EBC, 0xCEE16862, 0xCECA3428, 0xCEB30199, - 0xCE9BD0F0, 0xCE84A22F, 0xCE6D7556, 0xCE564A66, 0xCE3F2161, 0xCE27FA47, - 0xCE10D518, 0xCDF9B1D7, 0xCDE29083, 0xCDCB711D, 0xCDB453A8, 0xCD9D3822, - 0xCD861EC9, 0xCD6F0727, 0xCD57F178, 0xCD40DDBE, 0xCD29CBF8, 0xCD12BC27, - 0xCCFBAE4E, 0xCCE4A26C, 0xCCCD9882, 0xCCB69091, 0xCC9F8A9B, 0xCC8886A0, - 0xCC7184A1, 0xCC5A84D9, 0xCC4386D4, 0xCC2C8ACE, 0xCC1590C8, 0xCBFE98C2, - 0xCBE7A2BD, 0xCBD0AEBA, 0xCBB9BCBB, 0xCBA2CCBF, 0xCB8BDEC8, 0xCB74F2D7, - 0xCB5E08EC, 0xCB472109, 0xCB303B2E, 0xCB195797, 0xCB0275CF, 0xCAEB9613, - 0xCAD4B862, 0xCABDDCBF, 0xCAA70328, 0xCA902BA1, 0xCA795628, 0xCA6282C0, - 0xCA4BB16A, 0xCA34E225, 0xCA1E14F3, 0xCA0749D5, 0xC9F080CC, 0xC9D9BA12, - 0xC9C2F534, 0xC9AC326E, 0xC99571C0, 0xC97EB32C, 0xC967F6B1, 0xC9513C51, - 0xC93A840C, 0xC923CDE5, 0xC90D19DA, 0xC8F667EE, 0xC8DFB822, 0xC8C90A75, - 0xC8B25F23, 0xC89BB5B9, 0xC8850E72, 0xC86E694E, 0xC857C64F, 0xC8412575, - 0xC82A86C1, 0xC813EA34, 0xC7FD4FD0, 0xC7E6B794, 0xC7D02181, 0xC7B98D9A, - 0xC7A2FBDD, 0xC78C6C4D, 0xC775DF24, 0xC75F53EF, 0xC748CAE9, 0xC7324413, - 0xC71BBF6D, 0xC7053CF9, 0xC6EEBCB8, 0xC6D83EA9, 0xC6C1C2CF, 0xC6AB4929, - 0xC694D1BA, 0xC67E5C81, 0xC667E980, 0xC65178B7, 0xC63B0A60, 0xC6249E0B, - 0xC60E33F1, 0xC5F7CC12, 0xC5E16670, 0xC5CB030C, 0xC5B4A1E7, 0xC59E4300, - 0xC587E65A, 0xC5718BF5, 0xC55B33D2, 0xC544DDF2, 0xC52E8A55, 0xC5183936, - 0xC501EA23, 0xC4EB9D57, 0xC4D552D1, 0xC4BF0A94, 0xC4A8C49F, 0xC49280F4, - 0xC47C3F94, 0xC466007F, 0xC44FC3B6, 0xC439893A, 0xC423510D, 0xC40D1B2E, - 0xC3F6E79F, 0xC3E0B698, 0xC3CA87AB, 0xC3B45B10, 0xC39E30C8, 0xC38808D4, - 0xC371E335, 0xC35BBFEB, 0xC3459EF8, 0xC32F805C, 0xC3196419, 0xC3034A2E, - 0xC2ED329E, 0xC2D71D68, 0xC2C10A8E, 0xC2AAFA48, 0xC294EC28, 0xC27EE066, - 0xC268D703, 0xC252CFFF, 0xC23CCB5D, 0xC226C91C, 0xC210C93D, 0xC1FACBC2, - 0xC1E4D0AB, 0xC1CED7F9, 0xC1B8E1AD, 0xC1A2EDC7, 0xC18CFC49, 0xC1770D33, - 0xC1612086, 0xC14B3644, 0xC1354E6C, 0xC11F6900, 0xC1098601, 0xC0F3A5DE, - 0xC0DDC7BA, 0xC0C7EC06, 0xC0B212C1, 0xC09C3BED, 0xC086678B, 0xC070959B, - 0xC05AC61F, 0xC044F916, 0xC02F2E83, 0xC0196665, 0xC003A0BF, 0xBFEDDD8F, - 0xBFD81CD8, 0xBFC25E9B, 0xBFACA2D7, 0xBF96E98E, 0xBF8132C1, 0xBF6B7E71, - 0xBF55CC9D, 0xBF401D48, 0xBF2A7072, 0xBF14C61C, 0xBEFF1E47, 0xBEE978F3, - 0xBED3D622, 0xBEBE35D4, 0xBEA8980A, 0xBE92FD33, 0xBE7D6473, 0xBE67CE3B, - 0xBE523A89, 0xBE3CA960, 0xBE271AC0, 0xBE118EA9, 0xBDFC051E, 0xBDE67E1E, - 0xBDD0F9AA, 0xBDBB77C4, 0xBDA5F86B, 0xBD907BA2, 0xBD7B0168, 0xBD6589BE, - 0xBD5014A6, 0xBD3AA221, 0xBD25322E, 0xBD0FC4CF, 0xBCFA5A05, 0xBCE4F1D0, - 0xBCCF8C31, 0xBCBA292A, 0xBCA4C8BB, 0xBC8F6AE4, 0xBC7A0FA7, 0xBC64B704, - 0xBC4F616A, 0xBC3A0DFE, 0xBC24BD30, 0xBC0F6EFF, 0xBBFA236D, 0xBBE4DA7A, - 0xBBCF9428, 0xBBBA5076, 0xBBA50F66, 0xBB8FD0F9, 0xBB7A9530, 0xBB655C0A, - 0xBB50258A, 0xBB3AF1B0, 0xBB25C07C, 0xBB1091F0, 0xBAFB660C, 0xBAE63CD2, - 0xBAD11641, 0xBABBF25B, 0xBAA6D121, 0xBA91B294, 0xBA7C96B3, 0xBA677D81, - 0xBA5266FE, 0xBA3D532A, 0xBA284207, 0xBA133395, 0xB9FE2840, 0xB9E91F33, - 0xB9D418DA, 0xB9BF1536, 0xB9AA1447, 0xB995160E, 0xB9801A8C, 0xB96B21C2, - 0xB9562BB0, 0xB9413858, 0xB92C47BA, 0xB91759D7, 0xB9026EB0, 0xB8ED8646, - 0xB8D8A099, 0xB8C3BDAA, 0xB8AEDD7B, 0xB89A000B, 0xB885255C, 0xB8704D6F, - 0xB85B7843, 0xB846A5DB, 0xB831D637, 0xB81D0957, 0xB8083F3D, 0xB7F377E9, - 0xB7DEB35D, 0xB7C9F202, 0xB7B53306, 0xB7A076D3, 0xB78BBD6B, 0xB77706CD, - 0xB76252FC, 0xB74DA1F7, 0xB738F3C0, 0xB7244857, 0xB70F9FBE, 0xB6FAF9F4, - 0xB6E656FB, 0xB6D1B6D3, 0xB6BD197D, 0xB6A87EFB, 0xB693E74C, 0xB67F5273, - 0xB66AC06E, 0xB6563140, 0xB641A4E9, 0xB62D1B69, 0xB61894C3, 0xB60410F5, - 0xB5EF9002, 0xB5DB11EA, 0xB5C696AE, 0xB5B21E4E, 0xB59DA934, 0xB589368F, - 0xB574C6CA, 0xB56059E4, 0xB54BEFDF, 0xB53788BB, 0xB5232479, 0xB50EC31A, - 0xB4FA649F, 0xB4E60908, 0xB4D1B057, 0xB4BD5A8B, 0xB4A907A6, 0xB494B7A9, - 0xB4806A94, 0xB46C2068, 0xB457D927, 0xB44394D0, 0xB42F5364, 0xB41B14E5, - 0xB406D952, 0xB3F2A0AE, 0xB3DE6AF8, 0xB3CA3832, 0xB3B6085B, 0xB3A1DB76, - 0xB38DB182, 0xB3798A81, 0xB36566DA, 0xB35145C0, 0xB33D279B, 0xB3290C6C, - 0xB314F433, 0xB300DEF1, 0xB2ECCCA7, 0xB2D8BD56, 0xB2C4B0FE, 0xB2B0A7A0, - 0xB29CA13E, 0xB2889DD7, 0xB2749D6D, 0xB260A000, 0xB24CA592, 0xB238AE22, - 0xB224B9B2, 0xB210C842, 0xB1FCD9D3, 0xB1E8EE67, 0xB1D505FD, 0xB1C12097, - 0xB1AD3E35, 0xB1995ED7, 0xB1858280, 0xB171A92F, 0xB15DD2E6, 0xB14A000A, - 0xB1362FD1, 0xB12262A2, 0xB10E987D, 0xB0FAD164, 0xB0E70D57, 0xB0D34C56, - 0xB0BF8E62, 0xB0ABD37D, 0xB0981BA7, 0xB08466E0, 0xB070B52A, 0xB05D0685, - 0xB0495AF2, 0xB035B272, 0xB0220D05, 0xB00E6AAD, 0xAFFACB6A, 0xAFE72F3C, - 0xAFD39625, 0xAFC00025, 0xAFAC6D3E, 0xAF98DD6F, 0xAF8550B9, 0xAF71C71E, - 0xAF5E409E, 0xAF4ABD3A, 0xAF373CF2, 0xAF23C02B, 0xAF10461F, 0xAEFCCF31, - 0xAEE95B63, 0xAED5EAB5, 0xAEC27D29, 0xAEAF12BE, 0xAE9BAB76, 0xAE884751, - 0xAE74E650, 0xAE618874, 0xAE4E2DBE, 0xAE3AD62D, 0xAE2781C4, 0xAE143083, - 0xAE00E26A, 0xADED977A, 0xADDA4FB5, 0xADC70B1A, 0xADB3C9AB, 0xADA08B68, - 0xAD8D5052, 0xAD7A186A, 0xAD66E3B0, 0xAD53B225, 0xAD4083CB, 0xAD2D58A1, - 0xAD1A310A, 0xAD070C43, 0xACF3EAB0, 0xACE0CC50, 0xACCDB124, 0xACBA992E, - 0xACA7846E, 0xAC9472E4, 0xAC816491, 0xAC6E5977, 0xAC5B5195, 0xAC484CED, - 0xAC354B7F, 0xAC224D4C, 0xAC0F5255, 0xABFC5A9A, 0xABE9661D, 0xABD674DD, - 0xABC386DC, 0xABB09C1A, 0xAB9DB499, 0xAB8AD058, 0xAB77EF59, 0xAB65119D, - 0xAB523723, 0xAB3F5FED, 0xAB2C8BFB, 0xAB19BBAF, 0xAB06EE48, 0xAAF42429, - 0xAAE15D50, 0xAACE99C0, 0xAABBD979, 0xAAA91C7B, 0xAA9662C7, 0xAA83AC5E, - 0xAA70F941, 0xAA5E4971, 0xAA4B9CEE, 0xAA38F3B8, 0xAA264DD1, 0xAA13AB3A, - 0xAA010BF2, 0xA9EE6FFB, 0xA9DBD756, 0xA9C94203, 0xA9B6B003, 0xA9A42156, - 0xA99195FE, 0xA97F0DFB, 0xA96C894D, 0xA95A07F6, 0xA94789F6, 0xA9350F4E, - 0xA92297FF, 0xA9102467, 0xA8FDB3CB, 0xA8EB468A, 0xA8D8DCA4, 0xA8C6761A, - 0xA8B412EE, 0xA8A1B31F, 0xA88F56AE, 0xA87CFD9C, 0xA86AA7EA, 0xA8585598, - 0xA84606A8, 0xA833BB19, 0xA82172ED, 0xA80F2E24, 0xA7FCECBF, 0xA7EAAEBE, - 0xA7D87423, 0xA7C63CEE, 0xA7B40920, 0xA7A1D8B9, 0xA78FABBB, 0xA77D8225, - 0xA76B5BF9, 0xA7593937, 0xA74719E0, 0xA734FDF4, 0xA722E5D2, 0xA710D0C0, - 0xA6FEBF1B, 0xA6ECB0E6, 0xA6DAA61F, 0xA6C89EC8, 0xA6B69AE2, 0xA6A49A6D, - 0xA6929D6A, 0xA680A3D9, 0xA66EADBC, 0xA65CBB13, 0xA64ACBDF, 0xA638E020, - 0xA626F7D7, 0xA6151304, 0xA60331AA, 0xA5F153C7, 0xA5DF795D, 0xA5CDA26D, - 0xA5BBCEF7, 0xA5A9FEFC, 0xA598327C, 0xA5866979, 0xA574A3F2, 0xA562E1EA, - 0xA551235F, 0xA53F6854, 0xA52DB122, 0xA51BFD17, 0xA50A4C8D, 0xA4F89F84, - 0xA4E6F5FE, 0xA4D54FFB, 0xA4C3AD7C, 0xA4B20E81, 0xA4A0730B, 0xA48EDB1B, - 0xA47D46B2, 0xA46BB5D0, 0xA45A2876, 0xA4489EA4, 0xA437185B, 0xA425959D, - 0xA4141669, 0xA4029AC0, 0xA3F122A3, 0xA3DFAE12, 0xA3CE3D0F, 0xA3BCCF9A, - 0xA3AB65B3, 0xA399FF5C, 0xA3889C95, 0xA3773D5E, 0xA365E1B8, 0xA35489FD, - 0xA343357C, 0xA331E48F, 0xA3209735, 0xA30F4D70, 0xA2FE0740, 0xA2ECC4A6, - 0xA2DB85A3, 0xA2CA4A37, 0xA2B91263, 0xA2A7DE27, 0xA296AD85, 0xA285807D, - 0xA274570F, 0xA263313D, 0xA2520F06, 0xA240F06D, 0xA22FD570, 0xA21EBE11, - 0xA20DAA51, 0xA1FC9A30, 0xA1EB8DAF, 0xA1DA84CF, 0xA1C97F90, 0xA1B87DF2, - 0xA1A77FF7, 0xA196859F, 0xA1858F42, 0xA1749C32, 0xA163ACC8, 0xA152C103, - 0xA141D8E5, 0xA130F46E, 0xA120139E, 0xA10F3677, 0xA0FE5CF9, 0xA0ED8725, - 0xA0DCB4FB, 0xA0CBE67C, 0xA0BB1BA8, 0xA0AA5481, 0xA0999107, 0xA088D13A, - 0xA078151C, 0xA0675CAC, 0xA056A7EC, 0xA045F6DC, 0xA035497D, 0xA0249FD0, - 0xA013F9D4, 0xA003578B, 0x9FF2B8F5, 0x9FE21E14, 0x9FD186E7, 0x9FC0F36F, - 0x9FB06402, 0x9F9FD7F7, 0x9F8F4FA3, 0x9F7ECB06, 0x9F6E4A23, 0x9F5DCCF8, - 0x9F4D5387, 0x9F3CDDD1, 0x9F2C6BD5, 0x9F1BFD95, 0x9F0B9312, 0x9EFB2C4B, - 0x9EEAC942, 0x9EDA69F7, 0x9ECA0E6B, 0x9EB9B69E, 0x9EA96291, 0x9E991245, - 0x9E88C5BB, 0x9E787CF2, 0x9E6837EC, 0x9E57F6A9, 0x9E47B92A, 0x9E377F70, - 0x9E27497A, 0x9E17174A, 0x9E06E8E1, 0x9DF6BE91, 0x9DE697B6, 0x9DD674A3, - 0x9DC65559, 0x9DB639D8, 0x9DA62222, 0x9D960E36, 0x9D85FE16, 0x9D75F1C1, - 0x9D65E939, 0x9D55E47F, 0x9D45E392, 0x9D35E673, 0x9D25ED23, 0x9D15F7A4, - 0x9D0605F4, 0x9CF61815, 0x9CE62E08, 0x9CD647CC, 0x9CC66564, 0x9CB686CF, - 0x9CA6AC0D, 0x9C96D521, 0x9C870209, 0x9C7732C7, 0x9C67675C, 0x9C579FC7, - 0x9C47DC0A, 0x9C381C76, 0x9C28606A, 0x9C18A837, 0x9C08F3DF, 0x9BF94361, - 0x9BE996BE, 0x9BD9EDF7, 0x9BCA490D, 0x9BBAA7FF, 0x9BAB0ACF, 0x9B9B717E, - 0x9B8BDC0B, 0x9B7C4A78, 0x9B6CBCC5, 0x9B5D32F2, 0x9B4DAD01, 0x9B3E2AF1, - 0x9B2EACC4, 0x9B1F327A, 0x9B0FBC14, 0x9B004992, 0x9AF0DAF4, 0x9AE1703C, - 0x9AD2096B, 0x9AC2A67F, 0x9AB3477B, 0x9AA3EC5F, 0x9A949579, 0x9A85422E, - 0x9A75F2CD, 0x9A66A755, 0x9A575FC9, 0x9A481C28, 0x9A38DC72, 0x9A29A0AA, - 0x9A1A68CE, 0x9A0B34E0, 0x99FC04E0, 0x99ECD8D0, 0x99DDB0AE, 0x99CE8C7D, - 0x99BF6C3C, 0x99B04FED, 0x99A1378F, 0x99922323, 0x998312AB, 0x99740626, - 0x9964FD95, 0x9955F8F9, 0x9946F852, 0x9937FBA1, 0x992902E6, 0x991A0E23, - 0x990B1D57, 0x98FC30CF, 0x98ED47F3, 0x98DE6311, 0x98CF8229, 0x98C0A53B, - 0x98B1CC49, 0x98A2F752, 0x98942657, 0x98855959, 0x98769058, 0x9867CB55, - 0x98590A50, 0x984A4D4B, 0x983B9445, 0x982CDF3F, 0x981E2E3A, 0x980F8136, - 0x9800D834, 0x97F23334, 0x97E39238, 0x97D4F53F, 0x97C65C4A, 0x97B7C759, - 0x97A9366E, 0x979AA989, 0x978C20AA, 0x977D9BD2, 0x976F1B02, 0x97609E83, - 0x975225C3, 0x9743B10C, 0x9735405F, 0x9726D3BC, 0x97186B24, 0x970A0697, - 0x96FBA617, 0x96ED49A2, 0x96DEF13B, 0x96D09CE1, 0x96C24C96, 0x96B40059, - 0x96A5B82B, 0x9697740E, 0x96893400, 0x967AF804, 0x966CC019, 0x965E8C40, - 0x96505C79, 0x964230C5, 0x96340926, 0x9625E59A, 0x9617C623, 0x9609AAC1, - 0x95FB9375, 0x95ED8040, 0x95DF7169, 0x95D16662, 0x95C35F72, 0x95B55C9C, - 0x95A75DDE, 0x9599633A, 0x958B6CB0, 0x957D7A41, 0x956F8BEC, 0x9561A1B4, - 0x9553BB98, 0x9545D999, 0x9537FBB7, 0x952A21F3, 0x951C4C4E, 0x950E7AC7, - 0x9500AD60, 0x94F2E419, 0x94E51EF3, 0x94D75DED, 0x94C9A10A, 0x94BBE848, - 0x94AE33A9, 0x94A0832D, 0x9492D6D5, 0x94852EA2, 0x94778A93, 0x9469EAA9, - 0x945C4F2B, 0x944EB78D, 0x94412416, 0x943394C7, 0x942609A0, 0x941882A1, - 0x940AFFCB, 0x93FD811F, 0x93F0069D, 0x93E29045, 0x93D51E18, 0x93C7B017, - 0x93BA4642, 0x93ACE09A, 0x939F7F1E, 0x939221D1, 0x9384C8B1, 0x937773C0, - 0x936A22FF, 0x935CD66D, 0x934F8E0B, 0x934249DA, 0x933509DA, 0x9327CE0C, - 0x931A9671, 0x930D6308, 0x930033D2, 0x92F308D0, 0x92E5E202, 0x92D8BF69, - 0x92CBA106, 0x92BE86D8, 0x92B170E1, 0x92A45F20, 0x92975197, 0x928A4846, - 0x927D432D, 0x9270424C, 0x926345A5, 0x92564D38, 0x92495906, 0x923C6991, - 0x922F7DD5, 0x92229654, 0x9215B30F, 0x9208D407, 0x91FBF93D, 0x91EF22B0, - 0x91E25062, 0x91D58252, 0x91C8B882, 0x91BBF2F2, 0x91AF31A2, 0x91A27492, - 0x9195BBC4, 0x91890738, 0x917C56EE, 0x916FAAE7, 0x91630323, 0x91565FA2, - 0x9149C066, 0x913D256E, 0x91308EBC, 0x9123FC50, 0x91176E29, 0x910AE449, - 0x90FE5EB0, 0x90F1DD5F, 0x90E56056, 0x90D8E796, 0x90CC731E, 0x90C002F0, - 0x90B3970C, 0x90A72F73, 0x909ACC24, 0x908E6D21, 0x9082126A, 0x9075BBFF, - 0x906969E1, 0x905D1C10, 0x9050D28E, 0x90448D59, 0x90384C73, 0x902C0FDD, - 0x901FD796, 0x9013A39F, 0x900773F9, 0x8FFB48A4, 0x8FEF21A1, 0x8FE2FEF0, - 0x8FD6E091, 0x8FCAC685, 0x8FBEB0CD, 0x8FB29F69, 0x8FA69259, 0x8F9A899E, - 0x8F8E85B2, 0x8F8285A2, 0x8F7689E8, 0x8F6A9285, 0x8F5E9F78, 0x8F52B0C4, - 0x8F46C668, 0x8F3AE064, 0x8F2EFEB9, 0x8F232167, 0x8F174870, 0x8F0B73D3, - 0x8EFFA391, 0x8EF3D7AA, 0x8EE8101E, 0x8EDC4CEF, 0x8ED08E1D, 0x8EC4D3A8, - 0x8EB91D90, 0x8EAD6BD6, 0x8EA1BE7B, 0x8E96157E, 0x8E8A70E1, 0x8E7ED0A4, - 0x8E7334C7, 0x8E679D4B, 0x8E5C0A30, 0x8E507B76, 0x8E44F11F, 0x8E396B2A, - 0x8E2DE997, 0x8E226C69, 0x8E16F39E, 0x8E0B7F37, 0x8E000F35, 0x8DF4A398, - 0x8DE93C61, 0x8DDDD990, 0x8DD27B25, 0x8DC72121, 0x8DBBCB85, 0x8DB07A50, - 0x8DA52D83, 0x8D99E520, 0x8D8EA125, 0x8D836193, 0x8D78266C, 0x8D6CEFAF, - 0x8D61BD5D, 0x8D568F76, 0x8D4B65FB, 0x8D4040EB, 0x8D352049, 0x8D2A0413, - 0x8D1EECBC, 0x8D13D961, 0x8D08CA75, 0x8CFDBFF7, 0x8CF2B9E8, 0x8CE7B849, - 0x8CDCBB1A, 0x8CD1C25B, 0x8CC6CE0D, 0x8CBBDE31, 0x8CB0F2C6, 0x8CA60BCC, - 0x8C9B2946, 0x8C904B32, 0x8C857192, 0x8C7A9C65, 0x8C6FCBAD, 0x8C64FF69, - 0x8C5A379A, 0x8C4F7440, 0x8C44B55D, 0x8C39FAEF, 0x8C2F44F8, 0x8C249378, - 0x8C19E670, 0x8C0F3DE0, 0x8C0499C8, 0x8BF9FA28, 0x8BEF5F02, 0x8BE4C855, - 0x8BDA3622, 0x8BCFA86A, 0x8BC51F2C, 0x8BBA9A69, 0x8BB01A22, 0x8BA59E57, - 0x8B9B2708, 0x8B90B436, 0x8B8645E2, 0x8B7BDC0A, 0x8B7176B1, 0x8B6715D6, - 0x8B5CB97A, 0x8B52619D, 0x8B480E40, 0x8B3DBF62, 0x8B337505, 0x8B292F29, - 0x8B1EEDCE, 0x8B14B0F4, 0x8B0A789D, 0x8B0044C8, 0x8AF61575, 0x8AEBEAA6, - 0x8AE1C45A, 0x8AD7A2F9, 0x8ACD85B5, 0x8AC36CF6, 0x8AB958BC, 0x8AAF4908, - 0x8AA53DD9, 0x8A9B3731, 0x8A91350F, 0x8A873774, 0x8A7D3E61, 0x8A7349D5, - 0x8A6959D2, 0x8A5F6E57, 0x8A558765, 0x8A4BA4FC, 0x8A41C71E, 0x8A37EDC9, - 0x8A2E18FE, 0x8A2448BF, 0x8A1A7D0B, 0x8A10B5E2, 0x8A06F345, 0x89FD3535, - 0x89F37BB1, 0x89E9C6BB, 0x89E01652, 0x89D66A77, 0x89CCC32A, 0x89C3206B, - 0x89B9823C, 0x89AFE89C, 0x89A6538C, 0x899CC30B, 0x8993371B, 0x8989AFBC, - 0x89802CEF, 0x8976AEB2, 0x896D3508, 0x8963BFF0, 0x895A4F6A, 0x8950E378, - 0x89477C19, 0x893E194E, 0x8934BB16, 0x892B6174, 0x89220C66, 0x8918BBED, - 0x890F700A, 0x890628BC, 0x88FCE605, 0x88F3A7E5, 0x88EA6E5B, 0x88E13969, - 0x88D8090E, 0x88CEDD4C, 0x88C5B67F, 0x88BC93ED, 0x88B375F5, 0x88AA5C96, - 0x88A147D1, 0x889837A5, 0x888F2C15, 0x8886251F, 0x887D22C5, 0x88742505, - 0x886B2BE2, 0x8862375B, 0x88594771, 0x88505C24, 0x88477573, 0x883E9361, - 0x8835B5EC, 0x882CDD16, 0x882408DE, 0x881B3945, 0x88126E4C, 0x8809A7F2, - 0x8800E638, 0x87F8291F, 0x87EF70A6, 0x87E6BCCE, 0x87DE0D98, 0x87D56303, - 0x87CCBD10, 0x87C41BC0, 0x87BB7F12, 0x87B2E707, 0x87AA539F, 0x87A1C4DC, - 0x87993ABC, 0x8790B540, 0x87883469, 0x877FB837, 0x877740AB, 0x876ECDC4, - 0x87665F83, 0x875DF5E8, 0x875590F4, 0x874D30A7, 0x8744D501, 0x873C7E03, - 0x87342BAC, 0x872BDDFE, 0x872394F8, 0x871B509C, 0x871310E8, 0x870AD5DE, - 0x87029F7D, 0x86FA6DC7, 0x86F240BB, 0x86EA18AD, 0x86E1F4F7, 0x86D9D5EC, - 0x86D1BB8D, 0x86C9A5DA, 0x86C194D4, 0x86B9887A, 0x86B180CC, 0x86A97DCD, - 0x86A17F7A, 0x869985D6, 0x869190E0, 0x8689A098, 0x8681B4FF, 0x8679CE15, - 0x8671EBDB, 0x866A0E50, 0x86623575, 0x865A614B, 0x865291D1, 0x864AC708, - 0x864300F0, 0x863B3F8A, 0x863382D5, 0x862BCAD3, 0x86241783, 0x861C68E6, - 0x8614BEFC, 0x860D19C5, 0x86057942, 0x85FDDD73, 0x85F64657, 0x85EEB3F1, - 0x85E7263F, 0x85DF9D42, 0x85D818FA, 0x85D09968, 0x85C91E8C, 0x85C1A867, - 0x85BA36F7, 0x85B2CA3F, 0x85AB623E, 0x85A3FEF4, 0x859CA061, 0x85954687, - 0x858DF164, 0x8586A0FB, 0x857F554A, 0x85780E52, 0x8570CC13, 0x85698E8E, - 0x856255C3, 0x855B21B2, 0x8553F25C, 0x854CC7C0, 0x8545A228, 0x853E8103, - 0x85376499, 0x85304CEA, 0x852939F8, 0x85222BC3, 0x851B224A, 0x85141D8D, - 0x850D1D8E, 0x8506224D, 0x84FF2BC9, 0x84F83A03, 0x84F14CFC, 0x84EA64B3, - 0x84E38129, 0x84DCA25E, 0x84D5C852, 0x84CEF306, 0x84C8227A, 0x84C156AD, - 0x84BA8FA2, 0x84B3CD57, 0x84AD0FCC, 0x84A65703, 0x849FA2FC, 0x8498F3B6, - 0x84924932, 0x848BA370, 0x84850270, 0x847E6634, 0x8477CEBA, 0x84713C04, - 0x846AAE11, 0x846424E1, 0x845DA076, 0x845720CF, 0x8450A5EC, 0x844A2FCE, - 0x8443BE75, 0x843D51E2, 0x8436EA14, 0x8430870B, 0x842A28C9, 0x8423CF4C, - 0x841D7A97, 0x84172AA7, 0x8410DF7F, 0x840A991E, 0x84045785, 0x83FE1AB3, - 0x83F7E2A9, 0x83F1AF67, 0x83EB80ED, 0x83E5573D, 0x83DF3293, 0x83D91274, - 0x83D2F71E, 0x83CCE092, 0x83C6CED0, 0x83C0C1D8, 0x83BAB9AA, 0x83B4B646, - 0x83AEB7AD, 0x83A8BDE0, 0x83A2C8DD, 0x839CD8A6, 0x8396ED3A, 0x8391069B, - 0x838B24C7, 0x838547C0, 0x837F6F86, 0x83799C18, 0x8373CD77, 0x836E03A4, - 0x83683E9D, 0x83627E65, 0x835CC2FB, 0x83570C5E, 0x83515A90, 0x834BAD91, - 0x83460560, 0x834061FF, 0x833AC36C, 0x833529A9, 0x832F94B6, 0x832A0493, - 0x8324793F, 0x831EF2BC, 0x8319710A, 0x8313F428, 0x830E7C17, 0x830908D8, - 0x83039A69, 0x82FE30CD, 0x82F8CC02, 0x82F36C09, 0x82EE10E2, 0x82E8BA8D, - 0x82E3690C, 0x82DE1C5D, 0x82D8D481, 0x82D39178, 0x82CE5343, 0x82C919E1, - 0x82C3E553, 0x82BEB599, 0x82B98AB3, 0x82B464A2, 0x82AF4366, 0x82AA2732, - 0x82A50F9F, 0x829FFCE1, 0x829AEEF9, 0x8295E5E6, 0x8290E1A9, 0x828BE242, - 0x8286E7B1, 0x8281F1F7, 0x827D0113, 0x82781506, 0x82732DD0, 0x826E4B71, - 0x82696DEA, 0x82649539, 0x825FC161, 0x825AF260, 0x82562838, 0x825162E8, - 0x824CA270, 0x8247E6D1, 0x8243300A, 0x823E7E1D, 0x8239D109, 0x823528CE, - 0x8230856D, 0x822BE6E5, 0x82274D37, 0x8222B864, 0x821E286A, 0x82199D4B, - 0x82151707, 0x8210959D, 0x820C190F, 0x8207A15B, 0x82032E83, 0x81FEC086, - 0x81FA5764, 0x81F5F31F, 0x81F193B6, 0x81ED3928, 0x81E8E377, 0x81E492A3, - 0x81E046AB, 0x81DBFF8F, 0x81D7BD51, 0x81D37FF0, 0x81CF476C, 0x81CB13C6, - 0x81C6E4FD, 0x81C2BB13, 0x81BE9606, 0x81BA75D7, 0x81B65A86, 0x81B24414, - 0x81AE32AA, 0x81AA25F5, 0x81A61E1E, 0x81A21B27, 0x819E1D0F, 0x819A23D7, - 0x81962F7D, 0x81924004, 0x818E556A, 0x818A6FB1, 0x81868ED7, 0x8182B2DE, - 0x817EDBC5, 0x817B098D, 0x81773C35, 0x817373BE, 0x816FB028, 0x816BF174, - 0x816837A0, 0x816482AE, 0x8160D29E, 0x815D276F, 0x81598123, 0x8155DFB8, - 0x8152432F, 0x814EAB89, 0x814B18C5, 0x81478AE3, 0x814401E5, 0x81407DC9, - 0x813CFE90, 0x8139843A, 0x81360EC7, 0x81329E38, 0x812F328C, 0x812BCBC4, - 0x812869E0, 0x81250CDF, 0x8121B4C3, 0x811E618A, 0x811B1336, 0x8117C9C7, - 0x8114853B, 0x81114595, 0x810E0AD3, 0x810AD4F6, 0x8107A3FF, 0x810477EC, - 0x810150BF, 0x80FE2E77, 0x80FB1114, 0x80F7F898, 0x80F4E501, 0x80F1D650, - 0x80EECC84, 0x80EBC7BE, 0x80E8C7BF, 0x80E5CCA6, 0x80E2D674, 0x80DFE528, - 0x80DCF8C3, 0x80DA1145, 0x80D72EAE, 0x80D450FE, 0x80D17835, 0x80CEA453, - 0x80CBD558, 0x80C90B45, 0x80C6461A, 0x80C385D6, 0x80C0CA7A, 0x80BE1406, - 0x80BB627A, 0x80B8B5D6, 0x80B60E1A, 0x80B36B46, 0x80B0CD5B, 0x80AE3458, - 0x80ABA03E, 0x80A9110D, 0x80A686C4, 0x80A40165, 0x80A180EE, 0x809F0560, - 0x809C8EBC, 0x809A1D01, 0x8097B02F, 0x80954847, 0x8092E548, 0x80908733, - 0x808E2E08, 0x808BD9C6, 0x80898A6F, 0x80874001, 0x8084FA7D, 0x8082B9E4, - 0x80807E35, 0x807E4771, 0x807C1596, 0x8079E8A7, 0x8077C0A2, 0x80759D87, - 0x80737F58, 0x80716613, 0x806F51B9, 0x806D424B, 0x806B37C7, 0x8069322F, - 0x80673182, 0x806535C0, 0x80633EFD, 0x80614D12, 0x805F6013, 0x805D77FF, - 0x805B94D6, 0x8059B69A, 0x8057DD49, 0x805608E5, 0x8054396C, 0x80526EE0, - 0x8050A93F, 0x804EE88B, 0x804D2CC3, 0x804B75E7, 0x8049C3F8, 0x804816F6, - 0x80466EDF, 0x8044CBB6, 0x80432D79, 0x80419429, 0x803FFFC5, 0x803E704F, - 0x803CE5C5, 0x803B6028, 0x8039DF79, 0x803863B6, 0x8036ECE1, 0x80357AF8, - 0x80340DFE, 0x8032A5F0, 0x803142D0, 0x802FE49D, 0x802E8B57, 0x802D36FF, - 0x802BE795, 0x802A9D18, 0x80295789, 0x802816E8, 0x8026DB35, 0x8025A46F, - 0x80247297, 0x802345AD, 0x80221DB1, 0x8020FAA3, 0x801FDC83, 0x801EC351, - 0x801DAF0E, 0x801C9FB8, 0x801B9551, 0x801A8FD8, 0x80198F4D, 0x801893B1, - 0x80179D02, 0x8016AB43, 0x8015BE7B, 0x8014D698, 0x8013F3A4, 0x8013159E, - 0x80123C86, 0x8011685E, 0x80109924, 0x800FCED8, 0x800F097C, 0x800E490E, - 0x800D8D8E, 0x800CD6FE, 0x800C255D, 0x800B78AA, 0x800AD0E6, 0x800A2E11, - 0x8009902B, 0x8008F734, 0x8008632C, 0x8007D413, 0x800749E9, 0x8006C4AE, - 0x80064462, 0x8005C905, 0x80055297, 0x8004E118, 0x80047489, 0x80040CE8, - 0x8003AA37, 0x80034C75, 0x8002F3A2, 0x80029FBE, 0x800250CA, 0x800206C5, - 0x8001C1AF, 0x80018188, 0x80014650, 0x80011008, 0x8000DEAF, 0x8000B246, - 0x80008ACB, 0x80006840, 0x80004AA4, 0x800031F8, 0x80001E3B, 0x80000F6D, - 0x8000058E, 0x8000009F -}; - -const int32_t sine_1024[] = { - 0xFFE6DE06, 0xFFB49A13, 0xFF82562D, 0xFF501259, 0xFF1DCEA1, 0xFEEB8B0C, - 0xFEB947A0, 0xFE870468, 0xFE54C16A, 0xFE227EAD, 0xFDF03C3D, 0xFDBDFA1A, - 0xFD8BB850, 0xFD5976EC, 0xFD2735EC, 0xFCF4F55C, 0xFCC2B548, 0xFC9075B1, - 0xFC5E36A1, 0xFC2BF824, 0xFBF9BA3B, 0xFBC77CF0, 0xFB95404C, 0xFB630456, - 0xFB30C91F, 0xFAFE8E9D, 0xFACC54E1, 0xFA9A1BF3, 0xFA67E3D9, 0xFA35AC9C, - 0xFA03764C, 0xF9D140E1, 0xF99F0C69, 0xF96CD8ED, 0xF93AA675, 0xF9087508, - 0xF8D644B6, 0xF8A41577, 0xF871E75A, 0xF83FBA68, 0xF80D8EA7, 0xF7DB6421, - 0xF7A93AE4, 0xF77712E0, 0xF744EC3D, 0xF712C6F2, 0xF6E0A2F8, 0xF6AE8077, - 0xF67C5F55, 0xF64A3FBA, 0xF618218F, 0xF5E604FC, 0xF5B3E9F6, 0xF581D078, - 0xF54FB8A7, 0xF51DA26D, 0xF4EB8DF0, 0xF4B97B29, 0xF4876A0F, 0xF4555ACA, - 0xF4234D41, 0xF3F1419D, 0xF3BF37C4, 0xF38D2FE0, 0xF35B29E6, 0xF32925D0, - 0xF2F723C5, 0xF2C523AD, 0xF29325AE, 0xF26129C2, 0xF22F2FDF, 0xF1FD382E, - 0xF1CB4296, 0xF1994F3F, 0xF1675E10, 0xF1356F32, 0xF103829B, 0xF0D19845, - 0xF09FB055, 0xF06DCAB5, 0xF03BE78B, 0xF00A06CF, 0xEFD8287A, 0xEFA64CA3, - 0xEF747371, 0xEF429CAC, 0xEF10C87C, 0xEEDEF709, 0xEEAD2819, 0xEE7B5BD6, - 0xEE499247, 0xEE17CB92, 0xEDE60781, 0xEDB4463A, 0xED8287E5, 0xED50CC4B, - 0xED1F1392, 0xECED5DC2, 0xECBBAB03, 0xEC89FB1D, 0xEC584E38, 0xEC26A47A, - 0xEBF4FDAC, 0xEBC359F5, 0xEB91B97C, 0xEB601C0B, 0xEB2E81C8, 0xEAFCEABB, - 0xEACB570B, 0xEA99C680, 0xEA683942, 0xEA36AF79, 0xEA0528EB, 0xE9D3A5C2, - 0xE9A22604, 0xE970A9D8, 0xE93F3108, 0xE90DBBBA, 0xE8DC4A15, 0xE8AADBE2, - 0xE8797148, 0xE8480A50, 0xE816A71F, 0xE7E5477E, 0xE7B3EB95, 0xE782938B, - 0xE7513F28, 0xE71FEE94, 0xE6EEA1F4, 0xE6BD5914, 0xE68C1418, 0xE65AD30A, - 0xE629960F, 0xE5F85CF0, 0xE5C727D6, 0xE595F6E6, 0xE564C9E9, 0xE533A107, - 0xE5027C47, 0xE4D15BCF, 0xE4A03F6A, 0xE46F273D, 0xE43E136F, 0xE40D03CA, - 0xE3DBF875, 0xE3AAF177, 0xE379EEF6, 0xE348F0BC, 0xE317F6F0, 0xE2E701B8, - 0xE2B610DD, 0xE2852487, 0xE2543CDC, 0xE22359A5, 0xE1F27B09, 0xE1C1A110, - 0xE190CBDF, 0xE15FFB41, 0xE12F2F5C, 0xE0FE6857, 0xE0CDA5FA, 0xE09CE86D, - 0xE06C2FB8, 0xE03B7C00, 0xE00ACD0F, 0xDFDA230B, 0xDFA97DFD, 0xDF78DDEC, - 0xDF48431C, 0xDF17AD1B, 0xDEE71C2C, 0xDEB69058, 0xDE8609A7, 0xDE55881E, - 0xDE250BC7, 0xDDF494E6, 0xDDC42308, 0xDD93B671, 0xDD634F29, 0xDD32ED37, - 0xDD0290A4, 0xDCD23975, 0xDCA1E7F1, 0xDC719BA4, 0xDC4154D2, 0xDC111384, - 0xDBE0D7C0, 0xDBB0A18E, 0xDB807133, 0xDB50463C, 0xDB2020ED, 0xDAF0014D, - 0xDABFE765, 0xDA8FD33B, 0xDA5FC4D8, 0xDA2FBC7F, 0xD9FFB9BD, 0xD9CFBCD8, - 0xD99FC5D7, 0xD96FD4C0, 0xD93FE99C, 0xD9100472, 0xD8E02586, 0xD8B04C65, - 0xD8807955, 0xD850AC5C, 0xD820E581, 0xD7F124CD, 0xD7C16A46, 0xD791B630, - 0xD762081A, 0xD7326047, 0xD702BEC0, 0xD6D3238A, 0xD6A38EAE, 0xD6740033, - 0xD644785D, 0xD614F6B9, 0xD5E57B8D, 0xD5B606DE, 0xD58698B6, 0xD557311A, - 0xD527D012, 0xD4F875E2, 0xD4C92218, 0xD499D4F8, 0xD46A8E8A, 0xD43B4ED4, - 0xD40C15DE, 0xD3DCE3B0, 0xD3ADB88C, 0xD37E9401, 0xD34F7654, 0xD3205F8B, - 0xD2F14FAD, 0xD2C246C3, 0xD293450E, 0xD2644A1E, 0xD2355638, 0xD2066961, - 0xD1D783A0, 0xD1A8A4FF, 0xD179CD82, 0xD14AFD6E, 0xD11C3453, 0xD0ED7272, - 0xD0BEB7D4, 0xD090047F, 0xD061587C, 0xD032B3D0, 0xD00416BE, 0xCFD580D8, - 0xCFA6F25F, 0xCF786B5B, 0xCF49EBD2, 0xCF1B73CD, 0xCEED0352, 0xCEBE9AA4, - 0xCE903952, 0xCE61DFA1, 0xCE338D96, 0xCE05433A, 0xCDD70092, 0xCDA8C5A7, - 0xCD7A92BA, 0xCD4C675C, 0xCD1E43D1, 0xCCF0281E, 0xCCC2144A, 0xCC94085E, - 0xCC660460, 0xCC380891, 0xCC0A1485, 0xCBDC287B, 0xCBAE447C, 0xCB80688F, - 0xCB5294BA, 0xCB24C93F, 0xCAF705B0, 0xCAC94A4F, 0xCA9B9723, 0xCA6DEC32, - 0xCA404985, 0xCA12AF21, 0xC9E51D49, 0xC9B7938E, 0xC98A1233, 0xC95C993D, - 0xC92F28B5, 0xC901C0A0, 0xC8D46107, 0xC8A70A2A, 0xC879BB9B, 0xC84C759D, - 0xC81F3836, 0xC7F2036C, 0xC7C4D748, 0xC797B3D0, 0xC76A9944, 0xC73D8738, - 0xC7107DED, 0xC6E37D6A, 0xC6B685B5, 0xC68996D6, 0xC65CB0D4, 0xC62FD3EE, - 0xC602FFBA, 0xC5D63477, 0xC5A9722C, 0xC57CB8E0, 0xC550089A, 0xC5236161, - 0xC4F6C374, 0xC4CA2E6A, 0xC49DA281, 0xC4711FC0, 0xC444A62F, 0xC41835D3, - 0xC3EBCEB5, 0xC3BF7113, 0xC3931C83, 0xC366D145, 0xC33A8F5F, 0xC30E56D8, - 0xC2E227B7, 0xC2B6023C, 0xC289E5FB, 0xC25DD335, 0xC231C9F0, 0xC205CA33, - 0xC1D9D405, 0xC1ADE76D, 0xC1820471, 0xC1562B18, 0xC12A5B68, 0xC0FE956A, - 0xC0D2D992, 0xC0A72709, 0xC07B7E45, 0xC04FDF4C, 0xC0244A25, 0xBFF8BED8, - 0xBFCD3D6A, 0xBFA1C5E3, 0xBF765849, 0xBF4AF4A3, 0xBF1F9AF7, 0xBEF44B4D, - 0xBEC905AB, 0xBE9DCA85, 0xBE729906, 0xBE4771A3, 0xBE1C5463, 0xBDF1414C, - 0xBDC63865, 0xBD9B39B4, 0xBD704541, 0xBD455B11, 0xBD1A7B2C, 0xBCEFA597, - 0xBCC4DA5B, 0xBC9A197C, 0xBC6F6302, 0xBC44B760, 0xBC1A15C4, 0xBBEF7EA0, - 0xBBC4F1FB, 0xBB9A6FDB, 0xBB6FF848, 0xBB458B48, 0xBB1B28E1, 0xBAF0D11A, - 0xBAC683F9, 0xBA9C4185, 0xBA7209C4, 0xBA47DCBE, 0xBA1DBA78, 0xB9F3A363, - 0xB9C996B1, 0xB99F94D3, 0xB9759DD0, 0xB94BB1AD, 0xB921D071, 0xB8F7FA23, - 0xB8CE2ECA, 0xB8A46E6B, 0xB87AB90D, 0xB8510EB7, 0xB8276F6E, 0xB7FDDB3B, - 0xB7D45221, 0xB7AAD493, 0xB78161C3, 0xB757FA20, 0xB72E9DB2, 0xB7054C7F, - 0xB6DC068C, 0xB6B2CBE2, 0xB6899C85, 0xB660787C, 0xB6375FCE, 0xB60E5281, - 0xB5E5509B, 0xB5BC5A22, 0xB5936F86, 0xB56A8FFB, 0xB541BBF1, 0xB518F36D, - 0xB4F03677, 0xB4C78514, 0xB49EDF4B, 0xB4764521, 0xB44DB69E, 0xB42533C7, - 0xB3FCBCA2, 0xB3D45137, 0xB3ABF18B, 0xB3839DA3, 0xB35B55EF, 0xB33319A5, - 0xB30AE933, 0xB2E2C49F, 0xB2BAABF0, 0xB2929F2B, 0xB26A9E57, 0xB242A97A, - 0xB21AC09A, 0xB1F2E3BD, 0xB1CB12E9, 0xB1A34E25, 0xB17B9577, 0xB153E8E4, - 0xB12C48D8, 0xB104B48F, 0xB0DD2C75, 0xB0B5B08E, 0xB08E40E1, 0xB066DD75, - 0xB03F8650, 0xB0183B77, 0xAFF0FCF0, 0xAFC9CAC2, 0xAFA2A4F3, 0xAF7B8B88, - 0xAF547E88, 0xAF2D7E5C, 0xAF068A44, 0xAEDFA2A8, 0xAEB8C78F, 0xAE91F8FF, - 0xAE6B36FD, 0xAE448191, 0xAE1DD8BE, 0xADF73C8D, 0xADD0AD02, 0xADAA2A24, - 0xAD83B3F8, 0xAD5D4A85, 0xAD36EDCF, 0xAD109E40, 0xACEA5B19, 0xACC424C3, - 0xAC9DFB42, 0xAC77DE9D, 0xAC51CEDA, 0xAC2BCBFE, 0xAC05D610, 0xABDFED15, - 0xABBA1113, 0xAB944211, 0xAB6E8013, 0xAB48CB1F, 0xAB23233D, 0xAAFD88D0, - 0xAAD7FB1F, 0xAAB27A90, 0xAA8D0729, 0xAA67A0F0, 0xAA4247E9, 0xAA1CFC1B, - 0xA9F7BD8D, 0xA9D28C42, 0xA9AD6842, 0xA9885191, 0xA9634837, 0xA93E4C37, - 0xA9195DF7, 0xA8F47CBF, 0xA8CFA8F4, 0xA8AAE29A, 0xA88629B9, 0xA8617E55, - 0xA83CE074, 0xA818501C, 0xA7F3CD52, 0xA7CF581C, 0xA7AAF080, 0xA7869682, - 0xA7624A2A, 0xA73E0B7D, 0xA719DADB, 0xA6F5B793, 0xA6D1A206, 0xA6AD9A39, - 0xA689A033, 0xA665B3F9, 0xA641D590, 0xA61E04FF, 0xA5FA4249, 0xA5D68D76, - 0xA5B2E68A, 0xA58F4D8B, 0xA56BC27E, 0xA548456A, 0xA524D6AD, 0xA5017598, - 0xA4DE228C, 0xA4BADD8E, 0xA497A6A3, 0xA4747DD0, 0xA451631C, 0xA42E568B, - 0xA40B5823, 0xA3E867E9, 0xA3C585E3, 0xA3A2B216, 0xA37FEC87, 0xA35D353C, - 0xA33A8C93, 0xA317F1E0, 0xA2F56580, 0xA2D2E77A, 0xA2B077D2, 0xA28E168E, - 0xA26BC3B3, 0xA2497F46, 0xA227494D, 0xA20521CD, 0xA1E308CB, 0xA1C0FE4D, - 0xA19F0257, 0xA17D1545, 0xA15B3671, 0xA1396634, 0xA117A496, 0xA0F5F19A, - 0xA0D44D46, 0xA0B2B79F, 0xA09130AB, 0xA06FB86E, 0xA04E4EEE, 0xA02CF430, - 0xA00BA839, 0x9FEA6B0E, 0x9FC93CB4, 0x9FA81D85, 0x9F870CDE, 0x9F660B16, - 0x9F451835, 0x9F24343E, 0x9F035F37, 0x9EE29925, 0x9EC1E20C, 0x9EA139F3, - 0x9E80A0DE, 0x9E6016D2, 0x9E3F9BD4, 0x9E1F2FE9, 0x9DFED317, 0x9DDE85B3, - 0x9DBE471F, 0x9D9E17B3, 0x9D7DF772, 0x9D5DE662, 0x9D3DE489, 0x9D1DF1EA, - 0x9CFE0E8A, 0x9CDE3A70, 0x9CBE759F, 0x9C9EC01C, 0x9C7F19ED, 0x9C5F8316, - 0x9C3FFBED, 0x9C2083D5, 0x9C011B24, 0x9BE1C1DF, 0x9BC2780A, 0x9BA33DAB, - 0x9B8412C6, 0x9B64F75F, 0x9B45EB7D, 0x9B26EF23, 0x9B080256, 0x9AE9251C, - 0x9ACA5778, 0x9AAB9970, 0x9A8CEB57, 0x9A6E4C94, 0x9A4FBD7B, 0x9A313E10, - 0x9A12CE59, 0x99F46E5A, 0x99D61E17, 0x99B7DD96, 0x9999ACDB, 0x997B8BEA, - 0x995D7AC8, 0x993F797B, 0x99218806, 0x9903A66D, 0x98E5D503, 0x98C81333, - 0x98AA614E, 0x988CBF58, 0x986F2D56, 0x9851AB4D, 0x98343942, 0x9816D738, - 0x97F98534, 0x97DC433B, 0x97BF1151, 0x97A1EF7B, 0x9784DDBD, 0x9767DC66, - 0x974AEAE6, 0x972E098C, 0x9711385C, 0x96F4775B, 0x96D7C68C, 0x96BB25F6, - 0x969E959B, 0x96821580, 0x9665A5AA, 0x9649461D, 0x962CF6DD, 0x9610B7EF, - 0x95F48958, 0x95D86B62, 0x95BC5D84, 0x95A06009, 0x958472F5, 0x9568964D, - 0x954CCA15, 0x95310E51, 0x95156307, 0x94F9C839, 0x94DE3DEC, 0x94C2C424, - 0x94A75AE7, 0x948C0237, 0x9470BA19, 0x945582D7, 0x943A5BEA, 0x941F459B, - 0x94043FF0, 0x93E94AEB, 0x93CE6692, 0x93B392E8, 0x9398CFF2, 0x937E1DB3, - 0x93637C30, 0x9348EB6C, 0x932E6B6D, 0x9313FC36, 0x92F99DCA, 0x92DF502F, - 0x92C51368, 0x92AAE77A, 0x9290CC67, 0x9276C235, 0x925CC8E8, 0x9242E106, - 0x9229098D, 0x920F4304, 0x91F58D6F, 0x91DBE8D2, 0x91C25532, 0x91A8D292, - 0x918F60F6, 0x91760062, 0x915CB0DA, 0x91437262, 0x912A44FD, 0x911128B0, - 0x90F81D7F, 0x90DF236D, 0x90C63A7E, 0x90AD62B6, 0x90949C19, 0x907BE6AB, - 0x9063426F, 0x904AAF69, 0x90322D9E, 0x9019BD11, 0x90015DC5, 0x8FE90FBE, - 0x8FD0D301, 0x8FB8A790, 0x8FA08D71, 0x8F88851F, 0x8F708DAB, 0x8F58A793, - 0x8F40D2DB, 0x8F290F85, 0x8F115D96, 0x8EF9BD12, 0x8EE22DFB, 0x8ECAB057, - 0x8EB34427, 0x8E9BE971, 0x8E84A037, 0x8E6D687D, 0x8E564247, 0x8E3F2D98, - 0x8E282A74, 0x8E1138DE, 0x8DFA58DA, 0x8DE38A6C, 0x8DCCCD96, 0x8DB6225D, - 0x8D9F88C4, 0x8D8900CF, 0x8D728A80, 0x8D5C25DC, 0x8D45D2E6, 0x8D2F91A0, - 0x8D196281, 0x8D0344A8, 0x8CED388B, 0x8CD73E2D, 0x8CC15591, 0x8CAB7EBB, - 0x8C95B9AE, 0x8C80066D, 0x8C6A64FC, 0x8C54D55E, 0x8C3F5797, 0x8C29EBA9, - 0x8C149199, 0x8BFF4969, 0x8BEA131C, 0x8BD4EEB7, 0x8BBFDC3B, 0x8BAADBAD, - 0x8B95ED10, 0x8B811066, 0x8B6C45B4, 0x8B578CFC, 0x8B42E641, 0x8B2E5187, - 0x8B19CED1, 0x8B055E22, 0x8AF0FF7D, 0x8ADCB2E5, 0x8AC878C5, 0x8AB45051, - 0x8AA039F4, 0x8A8C35B1, 0x8A78438A, 0x8A646383, 0x8A50959F, 0x8A3CD9E2, - 0x8A29304D, 0x8A1598E5, 0x8A0213AC, 0x89EEA0A4, 0x89DB3FD2, 0x89C7F139, - 0x89B4B4DA, 0x89A18AB9, 0x898E72DA, 0x897B6D3E, 0x896879EA, 0x895598DF, - 0x8942CA21, 0x89300DB2, 0x891D6397, 0x890ACBD0, 0x88F84662, 0x88E5D34F, - 0x88D3729A, 0x88C124A3, 0x88AEE8B2, 0x889CBF28, 0x888AA807, 0x8878A352, - 0x8866B10B, 0x8854D137, 0x884303D6, 0x883148ED, 0x881FA07E, 0x880E0A8B, - 0x87FC8717, 0x87EB1626, 0x87D9B7B9, 0x87C86BD3, 0x87B73278, 0x87A60BA9, - 0x8794F769, 0x8783F5BC, 0x877306A3, 0x87622A21, 0x87516039, 0x8740A8ED, - 0x87300440, 0x871F7235, 0x870EF2CE, 0x86FE860D, 0x86EE2C49, 0x86DDE4DC, - 0x86CDB01E, 0x86BD8E11, 0x86AD7EB7, 0x869D8212, 0x868D9826, 0x867DC0F4, - 0x866DFC7F, 0x865E4ACA, 0x864EABD6, 0x863F1FA7, 0x862FA63E, 0x86203F9E, - 0x8610EBCA, 0x8601AAC4, 0x85F27C8E, 0x85E3612A, 0x85D4589B, 0x85C562E3, - 0x85B68004, 0x85A7B002, 0x8598F2DD, 0x858A4899, 0x857BB137, 0x856D2CBA, - 0x855EBB24, 0x85505C77, 0x854210FE, 0x8533D82A, 0x8525B246, 0x85179F54, - 0x85099F56, 0x84FBB24F, 0x84EDD840, 0x84E0112B, 0x84D25D14, 0x84C4BBFC, - 0x84B72DE4, 0x84A9B2D0, 0x849C4AC0, 0x848EF5B8, 0x8481B3BA, 0x847484C6, - 0x846768E0, 0x845A600A, 0x844D6A45, 0x84408793, 0x8433B7F7, 0x8426FB72, - 0x841A5206, 0x840DBBB6, 0x84013883, 0x83F4C86F, 0x83E86B7C, 0x83DC21EA, - 0x83CFEB3F, 0x83C3C7BB, 0x83B7B75F, 0x83ABBA2D, 0x839FD028, 0x8393F951, - 0x838835AA, 0x837C8535, 0x8370E7F4, 0x83655DE8, 0x8359E713, 0x834E8377, - 0x83433316, 0x8337F5F1, 0x832CCC0A, 0x8321B564, 0x8316B1FF, 0x830BC1DD, - 0x8300E501, 0x82F61B6B, 0x82EB651D, 0x82E0C21A, 0x82D63262, 0x82CBB5F7, - 0x82C14CDC, 0x82B6F710, 0x82ACB497, 0x82A285A5, 0x829869D5, 0x828E615B, - 0x82846C39, 0x827A8A72, 0x8270BC06, 0x826700F7, 0x825D5946, 0x8253C4F5, - 0x824A4405, 0x8240D679, 0x82377C50, 0x822E358E, 0x82250232, 0x821BE240, - 0x8212D5B7, 0x8209DC99, 0x8200F6E9, 0x81F824A6, 0x81EF65D3, 0x81E6BA71, - 0x81DE2281, 0x81D59E05, 0x81CD2CFE, 0x81C4CF6C, 0x81BC8552, 0x81B44EB1, - 0x81AC2BB3, 0x81A41C07, 0x819C1FD7, 0x81943725, 0x818C61F2, 0x8184A03E, - 0x817CF20D, 0x8175575D, 0x816DD032, 0x81665C8B, 0x815EFC6A, 0x8157AFD1, - 0x815076C0, 0x81495138, 0x81423F3A, 0x813B40C8, 0x813455E3, 0x812D7E8C, - 0x8126BAC3, 0x81200A8A, 0x81196DE2, 0x8112E4CC, 0x810C6F48, 0x81060D59, - 0x80FFBEFE, 0x80F98439, 0x80F35D0B, 0x80ED4994, 0x80E74996, 0x80E15D31, - 0x80DB8468, 0x80D5BF39, 0x80D00DA7, 0x80CA6FB2, 0x80C4E55B, 0x80BF6EA3, - 0x80BA0B8B, 0x80B4BC13, 0x80AF803D, 0x80AA5808, 0x80A54377, 0x80A0428A, - 0x809B5541, 0x80967B9E, 0x8091B5A0, 0x808D034A, 0x8088649A, 0x8083D994, - 0x807F6236, 0x807AFE81, 0x8076AE77, 0x80727218, 0x806E4965, 0x806A345E, - 0x80663303, 0x8062456A, 0x805E6B6B, 0x805AA51B, 0x8056F27A, 0x80535388, - 0x804FC848, 0x804C50B8, 0x8048ECD9, 0x80459CAD, 0x80426033, 0x803F376C, - 0x803C2259, 0x803920FA, 0x8036334F, 0x80335959, 0x80309318, 0x802DE08E, - 0x802B41B9, 0x8028B69B, 0x80263F34, 0x8023DB84, 0x80218B8C, 0x801F4F4D, - 0x801D26C5, 0x801B11F7, 0x801910E1, 0x80172385, 0x801549EC, 0x80138403, - 0x8011D1D4, 0x80103360, 0x800EA8A7, 0x800D31A8, 0x800BCE65, 0x800A7EDE, - 0x80094312, 0x80081B02, 0x800706AD, 0x80060616, 0x8005193A, 0x8004401B, - 0x80037AB8, 0x8002C912, 0x80022B29, 0x8001A0FD, 0x80012A8E, 0x8000C7DC, - 0x800078E8, 0x80003DB0, 0x80001636, 0x80000279 -}; - -const int32_t sine_512[] = { - 0xFFCDBC0C, 0xFF693440, 0xFF04ACD1, 0xFEA025FE, 0xFE3BA003, 0xFDD71B21, - 0xFD72978F, 0xFD0E1595, 0xFCA9956C, 0xFC45174E, 0xFBE09B85, 0xFB7C223F, - 0xFB17ABC2, 0xFAB33854, 0xFA4EC823, 0xF9EA5B74, 0xF985F28F, 0xF9218DA0, - 0xF8BD2CEF, 0xF858D0BF, 0xF7F47940, 0xF79026B8, 0xF72BD964, 0xF6C79182, - 0xF6634F60, 0xF5FF131C, 0xF59ADD04, 0xF536AD55, 0xF4D2844E, 0xF46E622B, - 0xF40A473C, 0xF3A6339D, 0xF342279C, 0xF2DE2378, 0xF27A276D, 0xF21633BA, - 0xF1B248AC, 0xF14E6661, 0xF0EA8D26, 0xF086BD38, 0xF022F6D7, 0xEFBF3A3E, - 0xEF5B87BC, 0xEEF7DF5E, 0xEE9441A2, 0xEE30AEA4, 0xEDCD2684, 0xED69A9BC, - 0xED06384C, 0xECA2D2B1, 0xEC3F78E7, 0xEBDC2B6D, 0xEB78EA5E, 0xEB15B5DA, - 0xEAB28E5C, 0xEA4F73E3, 0xE9EC66EA, 0xE989678F, 0xE92675F0, 0xE8C39289, - 0xE860BD57, 0xE7FDF6D8, 0xE79B3F08, 0xE7389663, 0xE6D5FD08, 0xE6737313, - 0xE610F900, 0xE5AE8ECC, 0xE54C34F4, 0xE4E9EB95, 0xE487B2CC, 0xE4258B13, - 0xE3C3746A, 0xE3616F4C, 0xE2FF7BB5, 0xE29D9A21, 0xE23BCAAE, 0xE1DA0D78, - 0xE17862F9, 0xE116CB31, 0xE0B54699, 0xE053D54F, 0xDFF2776F, 0xDF912D55, - 0xDF2FF77A, 0xDECED59F, 0xDE6DC83D, 0xDE0CCFCE, 0xDDABEC13, 0xDD4B1D85, - 0xDCEA645F, 0xDC89C11C, 0xDC29337A, 0xDBC8BBF4, 0xDB685B03, 0xDB081067, - 0xDAA7DC98, 0xDA47BFD3, 0xD9E7BA8F, 0xD987CC8E, 0xD927F647, 0xD8C83834, - 0xD8689215, 0xD8090462, 0xD7A98F92, 0xD74A3368, 0xD6EAF05A, 0xD68BC6A4, - 0xD62CB6BD, 0xD5CDC065, 0xD56EE416, 0xD5102244, 0xD4B17AB2, 0xD452EDD8, - 0xD3F47BEE, 0xD396256B, 0xD337EA13, 0xD2D9CA59, 0xD27BC6B6, 0xD21DDEEA, - 0xD1C0136B, 0xD1626475, 0xD104D27B, 0xD0A75D40, 0xD04A053A, 0xCFECCADE, - 0xCF8FADEE, 0xCF32AEDF, 0xCED5CE26, 0xCE790B85, 0xCE1C6772, 0xCDBFE225, - 0xCD637C11, 0xCD0734FC, 0xCCAB0D57, 0xCC4F0597, 0xCBF31D7F, 0xCB975583, - 0xCB3BADDB, 0xCAE026F9, 0xCA84C0A3, 0xCA297B4A, 0xC9CE5760, 0xC97354AB, - 0xC918739C, 0xC8BDB46B, 0xC863178A, 0xC8089CBD, 0xC7AE4476, 0xC7540F26, - 0xC6F9FC92, 0xC6A00D2B, 0xC6464161, 0xC5EC98FA, 0xC5931465, 0xC539B3DB, - 0xC4E077CB, 0xC4875FFB, 0xC42E6CDA, 0xC3D59ED7, 0xC37CF5B9, 0xC32471EF, - 0xC2CC13AF, 0xC273DB68, 0xC21BC8E0, 0xC1C3DC86, 0xC16C168F, 0xC1147733, - 0xC0BCFF15, 0xC065AD8E, 0xC00E8343, 0xBFB7806A, 0xBF60A537, 0xBF09F1E2, - 0xBEB3669E, 0xBE5D0411, 0xBE06C992, 0xBDB0B7C6, 0xBD5ACEE0, 0xBD050F17, - 0xBCAF789F, 0xBC5A0BAD, 0xBC04C8E2, 0xBBAFAF9A, 0xBB5AC075, 0xBB05FBA9, - 0xBAB16169, 0xBA5CF1E9, 0xBA08ADCA, 0xB9B49467, 0xB960A662, 0xB90CE3EC, - 0xB8B94D3B, 0xB865E281, 0xB812A3F2, 0xB7BF922B, 0xB76CAC8B, 0xB719F3B1, - 0xB6C767CE, 0xB6750916, 0xB622D7BB, 0xB5D0D3F0, 0xB57EFE51, 0xB52D563E, - 0xB4DBDC53, 0xB48A90C2, 0xB43973BC, 0xB3E88575, 0xB397C61E, 0xB347364F, - 0xB2F6D56D, 0xB2A6A410, 0xB256A269, 0xB206D0AB, 0xB1B72F05, 0xB167BDAA, - 0xB1187D2E, 0xB0C96CFA, 0xB07A8DA3, 0xB02BDF59, 0xAFDD624E, 0xAF8F16B1, - 0xAF40FCB2, 0xAEF314E6, 0xAEA55EB6, 0xAE57DAB4, 0xAE0A8911, 0xADBD69FD, - 0xAD707DA7, 0xAD23C43E, 0xACD73E54, 0xAC8AEB53, 0xAC3ECBCF, 0xABF2DFF4, - 0xABA727F2, 0xAB5BA3F7, 0xAB105493, 0xAAC53933, 0xAA7A5266, 0xAA2FA05B, - 0xA9E5233E, 0xA99ADB3F, 0xA950C88B, 0xA906EBAE, 0xA8BD4418, 0xA873D257, - 0xA82A9696, 0xA7E19104, 0xA798C1CD, 0xA750291E, 0xA707C780, 0xA6BF9C67, - 0xA677A85C, 0xA62FEB8C, 0xA5E86623, 0xA5A1184C, 0xA55A0235, 0xA5132462, - 0xA4CC7E4B, 0xA4861076, 0xA43FDB0E, 0xA3F9DE40, 0xA3B41A35, 0xA36E8F19, - 0xA3293D6F, 0xA2E424B1, 0xA29F4563, 0xA25A9FAE, 0xA21633BD, 0xA1D201BB, - 0xA18E09D1, 0xA14A4C7F, 0xA106C943, 0xA0C3809D, 0xA08072B5, 0xA03D9FB7, - 0x9FFB07CA, 0x9FB8AB6C, 0x9F768A1D, 0x9F34A45B, 0x9EF2FA4F, 0x9EB18C20, - 0x9E7059F7, 0x9E2F63FC, 0x9DEEAAAA, 0x9DAE2D84, 0x9D6DED04, 0x9D2DE951, - 0x9CEE2294, 0x9CAE98F3, 0x9C6F4C97, 0x9C303DF5, 0x9BF16C94, 0x9BB2D8EB, - 0x9B748322, 0x9B366B5E, 0x9AF891C6, 0x9ABAF680, 0x9A7D9A00, 0x9A407BD0, - 0x9A039C62, 0x99C6FBDE, 0x998A9A69, 0x994E7827, 0x9912953E, 0x98D6F21E, - 0x989B8E55, 0x98606A53, 0x9825863C, 0x97EAE236, 0x97B07E63, 0x97765AE9, - 0x973C7834, 0x9702D5D5, 0x96C9743A, 0x96905385, 0x965773DA, 0x961ED55C, - 0x95E6782E, 0x95AE5CBA, 0x95768293, 0x953EEA24, 0x95079390, 0x94D07EF7, - 0x9499AC7D, 0x94631C88, 0x942CCEAF, 0x93F6C359, 0x93C0FAA7, 0x938B74BB, - 0x935631B6, 0x932131B8, 0x92EC74E3, 0x92B7FB56, 0x9283C532, 0x924FD298, - 0x921C242A, 0x91E8B901, 0x91B591C2, 0x9182AE8B, 0x91500F7C, 0x911DB4B3, - 0x90EB9E52, 0x90B9CC75, 0x90883F3C, 0x9056F6C5, 0x9025F32F, 0x8FF53499, - 0x8FC4BB1F, 0x8F94875A, 0x8F649874, 0x8F34EF03, 0x8F058B26, 0x8ED66CFA, - 0x8EA7949D, 0x8E79022A, 0x8E4AB5BE, 0x8E1CAF77, 0x8DEEEF70, 0x8DC175C6, - 0x8D944295, 0x8D6755F9, 0x8D3AB00D, 0x8D0E515D, 0x8CE23924, 0x8CB667ED, - 0x8C8ADDD4, 0x8C5F9AF3, 0x8C349F65, 0x8C09EB45, 0x8BDF7EAC, 0x8BB559B6, - 0x8B8B7C7C, 0x8B61E718, 0x8B3899A4, 0x8B0F9438, 0x8AE6D6EF, 0x8ABE6249, - 0x8A96358F, 0x8A6E5142, 0x8A46B57C, 0x8A1F6253, 0x89F857E2, 0x89D1963E, - 0x89AB1D82, 0x8984EDC3, 0x895F071B, 0x8939699F, 0x89141569, 0x88EF0A8D, - 0x88CA4924, 0x88A5D1A0, 0x8881A35E, 0x885DBED3, 0x883A2413, 0x8816D335, - 0x87F3CC4E, 0x87D10F75, 0x87AE9CBF, 0x878C7440, 0x876A960F, 0x8749023F, - 0x8727B8E6, 0x8706BA18, 0x86E6063D, 0x86C59CC1, 0x86A57E0E, 0x8685AA35, - 0x8666214C, 0x8646E366, 0x8627F095, 0x860948ED, 0x85EAEC81, 0x85CCDB64, - 0x85AF15A7, 0x85919B5F, 0x85746C9B, 0x85578970, 0x853AF236, 0x851EA66F, - 0x8502A673, 0x84E6F256, 0x84CB8A28, 0x84B06DF9, 0x84959DDB, 0x847B19DE, - 0x8460E213, 0x8446F689, 0x842D5751, 0x8414047A, 0x83FAFE15, 0x83E24430, - 0x83C9D718, 0x83B1B660, 0x8399E257, 0x83825B09, 0x836B2087, 0x835432DE, - 0x833D921C, 0x83273E4F, 0x83113786, 0x82FB7DCD, 0x82E61132, 0x82D0F1C3, - 0x82BC1F8C, 0x82A79ACE, 0x8293632D, 0x827F78EA, 0x826BDC12, 0x82588CB1, - 0x82458AD3, 0x8232D682, 0x82206FCC, 0x820E56BB, 0x81FC8B5A, 0x81EB0DB4, - 0x81D9DDD5, 0x81C8FBC6, 0x81B86793, 0x81A8216E, 0x8198290E, 0x81887EA8, - 0x81792245, 0x816A13EE, 0x815B53AD, 0x814CE18A, 0x813EBD90, 0x8130E7C6, - 0x81236034, 0x811626E4, 0x81093BDE, 0x80FC9F29, 0x80F050CD, 0x80E450F0, - 0x80D89F5D, 0x80CD3C39, 0x80C2278B, 0x80B7615B, 0x80ACE9AE, 0x80A2C08C, - 0x8098E5FB, 0x808F5A00, 0x80861CA2, 0x807D2DE6, 0x80748DD2, 0x806C3C6C, - 0x806439CB, 0x805C85CD, 0x8055208B, 0x804E0A09, 0x8047424D, 0x8040C959, - 0x803A9F33, 0x8034C3DD, 0x802F375C, 0x8029F9B3, 0x80250AE5, 0x80206AF5, - 0x801C19E7, 0x801817BC, 0x80146480, 0x80110023, 0x800DEAB0, 0x800B242A, - 0x8008AC92, 0x800683EA, 0x8004AA33, 0x80031F6E, 0x8001E39C, 0x8000F6BE, - 0x800058D4, 0x800009DF -}; - -const int32_t sine_256[] ICONST_ATTR_WMAPRO_WIN_VS_TMP = { - 0xFF9B781E, 0xFED26950, 0xFE095D6B, 0xFD40565E, 0xFC775617, 0xFBAE5E8D, - 0xFAE571A2, 0xFA1C9157, 0xF953BF94, 0xF88AFE40, 0xF7C24F61, 0xF6F9B4C9, - 0xF6313075, 0xF568C463, 0xF4A07264, 0xF3D83C74, 0xF3102493, 0xF2482C8D, - 0xF1805660, 0xF0B8A409, 0xEFF11756, 0xEF29B241, 0xEE6276B8, 0xED9B66A5, - 0xECD48414, 0xEC0DD0B0, 0xEB474E83, 0xEA80FF77, 0xE9BAE575, 0xE8F50266, - 0xE82F5851, 0xE769E8E0, 0xE6A4B619, 0xE5DFC1E2, 0xE51B0E22, 0xE4569CBE, - 0xE3926FB9, 0xE2CE88BA, 0xE20AE9C3, 0xE14794B7, 0xE0848B77, 0xDFC1CFE5, - 0xDEFF6401, 0xDE3D494C, 0xDD7B8223, 0xDCBA1024, 0xDBF8F4F0, 0xDB3832DF, - 0xDA77CB50, 0xD9B7C09B, 0xD8F8141D, 0xD838C82A, 0xD779DE5D, 0xD6BB5850, - 0xD5FD3854, 0xD53F7FC3, 0xD48230EB, 0xD3C54D62, 0xD308D6BE, 0xD24CCF4A, - 0xD191385B, 0xD0D6143A, 0xD01B643D, 0xCF612AA7, 0xCEA76907, 0xCDEE20EF, - 0xCD35549C, 0xCC7D0561, 0xCBC5357A, 0xCB0DE672, 0xCA5719D3, 0xC9A0D1D4, - 0xC8EB0FC4, 0xC835D5D6, 0xC7812556, 0xC6CD0075, 0xC61968B6, 0xC5665F9C, - 0xC4B3E751, 0xC402011C, 0xC350AF27, 0xC29FF2EC, 0xC1EFCDEA, 0xC140420A, - 0xC091516E, 0xBFE2FCE5, 0xBF35468E, 0xBE883082, 0xBDDBBB92, 0xBD2FE9D5, - 0xBC84BCF2, 0xBBDA36FD, 0xBB3058C1, 0xBA87244E, 0xB9DE9BB0, 0xB936BFB2, - 0xB88F925B, 0xB7E9154A, 0xB7434A82, 0xB69E32C9, 0xB5F9D020, 0xB5562485, - 0xB4B330BC, 0xB410F6BE, 0xB36F7882, 0xB2CEB6CB, 0xB22EB38A, 0xB18F704B, - 0xB0F0EEFC, 0xB0533059, 0xAFB6364E, 0xAF1A02C1, 0xAE7E966C, 0xADE3F332, - 0xAD4A1A92, 0xACB10E67, 0xAC18CF69, 0xAB815F71, 0xAAEAC054, 0xAA54F2C6, - 0xA9BFF898, 0xA92BD33C, 0xA898847A, 0xA8060D04, 0xA7746EA1, 0xA6E3AB14, - 0xA653C30A, 0xA5C4B842, 0xA5368C78, 0xA4A94055, 0xA41CD591, 0xA3914D86, - 0xA306A9E5, 0xA27CEB53, 0xA1F4137C, 0xA16C2408, 0xA0E51D9A, 0xA05F01D6, - 0x9FD9D207, 0x9F558FC8, 0x9ED23BB9, 0x9E4FD771, 0x9DCE6485, 0x9D4DE38E, - 0x9CCE561E, 0x9C4FBD6E, 0x9BD21B06, 0x9B556F7D, 0x9AD9BC57, 0x9A5F0312, - 0x99E54441, 0x996C815F, 0x98F4BBE2, 0x987DF458, 0x98082C35, 0x97936499, - 0x971F9EEF, 0x96ACDBC0, 0x963B1C73, 0x95CA6267, 0x955AAE23, 0x94EC0102, - 0x947E5C15, 0x9411C0B1, 0x93A62F56, 0x933BA954, 0x92D22FB1, 0x9269C372, - 0x9202661A, 0x919C17A3, 0x9136D98D, 0x90D2ACD1, 0x906F9266, 0x900D8B42, - 0x8FAC9856, 0x8F4CBB0B, 0x8EEDF358, 0x8E9042A4, 0x8E33A9D4, 0x8DD829CE, - 0x8D7DC372, 0x8D2477A1, 0x8CCC47A6, 0x8C75337A, 0x8C1F3C65, 0x8BCA633B, - 0x8B76A8CE, 0x8B240DEB, 0x8AD293C7, 0x8A823A59, 0x8A3302D2, 0x89E4EDF5, - 0x8997FC81, 0x894C2F36, 0x890186CE, 0x88B8045E, 0x886FA7E0, 0x88287266, - 0x87E2649F, 0x879D7F37, 0x8759C2D9, 0x8717302D, 0x86D5C827, 0x86958AC5, - 0x865678F8, 0x8618935B, 0x85DBDA87, 0x85A04F13, 0x8565F192, 0x852CC2DA, - 0x84F4C2E8, 0x84BDF28F, 0x84885258, 0x8453E2C5, 0x8420A459, 0x83EE9791, - 0x83BDBD27, 0x838E1518, 0x835FA016, 0x83325E96, 0x83065106, 0x82DB77D4, - 0x82B1D369, 0x8289645F, 0x82622AB2, 0x823C26F8, 0x8217598E, 0x81F3C2CF, - 0x81D16313, 0x81B03AAE, 0x81904A1B, 0x81719157, 0x815410D7, 0x8137C8E4, - 0x811CB9C4, 0x8102E3B9, 0x80EA4722, 0x80D2E3FC, 0x80BCBAA3, 0x80A7CB4B, - 0x8094162A, 0x80819B6F, 0x80705B49, 0x806055F5, 0x80518B72, 0x8043FBFA, - 0x8037A7AE, 0x802C8EAD, 0x8022B111, 0x801A0EF5, 0x8012A874, 0x800C7D90, - 0x80078E60, 0x8003DAF2, 0x8001634E, 0x8000277B -}; - -const int32_t sine_128[] ICONST_ATTR = { - 0xFF36F079, 0xFDA4D929, 0xFC12D91C, 0xFA80FFCF, 0xF8EF5CBC, 0xF75DFF6C, - 0xF5CCF73F, 0xF43C53CB, 0xF2AC2474, 0xF11C7895, 0xEF8D5FC8, 0xEDFEE931, - 0xEC71244A, 0xEAE4208A, 0xE957ED00, 0xE7CC9912, 0xE642341D, 0xE4B8CD16, - 0xE3307348, 0xE1A935F1, 0xE02323EA, 0xDE9E4C5B, 0xDD1ABE41, 0xDB98888E, - 0xDA17BA63, 0xD898621B, 0xD71A8EBA, 0xD59E4EF9, 0xD423B181, 0xD2AAC4EB, - 0xD13397FA, 0xCFBE38AD, 0xCE4AB5A6, 0xCCD91D38, 0xCB697DA1, 0xC9FBE50E, - 0xC89061D1, 0xC727017A, 0xC5BFD232, 0xC45AE1D1, 0xC2F83E1B, 0xC197F4BB, - 0xC03A137E, 0xBEDEA73A, 0xBD85BE33, 0xBC2F6544, 0xBADBA934, 0xB98A97F6, - 0xB83C3DB0, 0xB6F0A81D, 0xB5A7E331, 0xB461FC6A, 0xB31EFFF0, 0xB1DEF9D2, - 0xB0A1F730, 0xAF68037B, 0xAE312B94, 0xACFD7B13, 0xABCCFD75, 0xAA9FBF37, - 0xA975CB39, 0xA84F2DB4, 0xA72BF147, 0xA60C21E8, 0xA4EFCA51, 0xA3D6F51F, - 0xA2C1ADDA, 0xA1AFFE80, 0xA0A1F24E, 0x9F979356, 0x9E90EB88, 0x9D8E05AD, - 0x9C8EEB1A, 0x9B93A649, 0x9A9C4048, 0x99A8C33F, 0x98B93843, 0x97CDA844, - 0x96E61CED, 0x96029E99, 0x9523369D, 0x9447ED4D, 0x9370CADA, 0x929DD7D5, - 0x91CF1CE2, 0x9104A0F4, 0x903E6C5C, 0x8F7C873A, 0x8EBEF810, 0x8E05C6AA, - 0x8D50FA2B, 0x8CA099FB, 0x8BF4AC06, 0x8B4D375E, 0x8AAA42E0, 0x8A0BD402, - 0x8971F14B, 0x88DCA0A9, 0x884BE838, 0x87BFCCD4, 0x87385443, 0x86B5840D, - 0x86376099, 0x85BDEF18, 0x85493481, 0x84D934C0, 0x846DF472, 0x840777B8, - 0x83A5C2C5, 0x8348D8DF, 0x82F0BDDB, 0x829D7552, 0x824F0211, 0x82056753, - 0x81C0A7F0, 0x8180C6B5, 0x8145C5C8, 0x810FA798, 0x80DE6E59, 0x80B21BB4, - 0x808AB17D, 0x8068313B, 0x804A9C52, 0x8031F3C2, 0x801E3892, 0x800F6B8C, - 0x80058D30, 0x80009DEA -}; - -const int32_t *sine_windows[6] = { - sine_128, sine_256, sine_512, sine_1024, sine_2048, sine_4096 -}; - - -/* mdct trig table. - the table should be in s.31 format, but in wma pro, all the tables are scaled - down to preserve energy in the signal, so this downscaling is equivalent to - having the tables in ~s15.16 instead. */ -/* rockbox: not used -const int32_t sincos_lookup_wmap[8064] = { - 0x0000011C, 0x00016A09, 0x000009FE, 0x000169E6, - 0x000012DF, 0x0001698B, 0x00001BBD, 0x000168F9, - 0x00002497, 0x0001682F, 0x00002D6B, 0x0001672D, - 0x00003638, 0x000165F4, 0x00003EFD, 0x00016484, - 0x000047B8, 0x000162DD, 0x00005068, 0x000160FF, - 0x0000590B, 0x00015EEA, 0x000061A1, 0x00015CA0, - 0x00006A28, 0x00015A20, 0x0000729E, 0x0001576A, - 0x00007B03, 0x0001547F, 0x00008354, 0x00015160, - 0x00008B92, 0x00014E0D, 0x000093BA, 0x00014A87, - 0x00009BCB, 0x000146CD, 0x0000A3C4, 0x000142E1, - 0x0000ABA4, 0x00013EC3, 0x0000B369, 0x00013A74, - 0x0000BB13, 0x000135F5, 0x0000C2A0, 0x00013146, - 0x0000CA0F, 0x00012C67, 0x0000D15F, 0x0001275B, - 0x0000D88E, 0x00012221, 0x0000DF9C, 0x00011CBA, - 0x0000E688, 0x00011727, 0x0000ED50, 0x00011169, - 0x0000F3F3, 0x00010B81, 0x0000FA71, 0x00010570, - 0x000100C8, 0x0000FF36, 0x000106F8, 0x0000F8D5, - 0x00010CFF, 0x0000F24E, 0x000112DC, 0x0000EBA1, - 0x00011890, 0x0000E4D0, 0x00011E18, 0x0000DDDC, - 0x00012373, 0x0000D6C5, 0x000128A2, 0x0000CF8E, - 0x00012DA3, 0x0000C836, 0x00013276, 0x0000C0C0, - 0x00013719, 0x0000B92B, 0x00013B8D, 0x0000B17B, - 0x00013FCF, 0x0000A9AE, 0x000143E1, 0x0000A1C8, - 0x000147C0, 0x000099C9, 0x00014B6D, 0x000091B2, - 0x00014EE7, 0x00008984, 0x0001522D, 0x00008142, - 0x0001553F, 0x000078EB, 0x0001581C, 0x00007082, - 0x00015AC5, 0x00006807, 0x00015D38, 0x00005F7D, - 0x00015F75, 0x000056E3, 0x0001617B, 0x00004E3D, - 0x0001634C, 0x0000458A, 0x000164E5, 0x00003CCC, - 0x00016648, 0x00003405, 0x00016773, 0x00002B36, - 0x00016867, 0x00002261, 0x00016923, 0x00001986, - 0x000169A7, 0x000010A7, 0x000169F4, 0x000007C6, - 0x00000064, 0x0000FFFF, 0x00000388, 0x0000FFF9, - 0x000006AC, 0x0000FFE9, 0x000009D0, 0x0000FFCF, - 0x00000CF4, 0x0000FFAC, 0x00001017, 0x0000FF7E, - 0x00001339, 0x0000FF46, 0x0000165A, 0x0000FF05, - 0x0000197B, 0x0000FEBA, 0x00001C9B, 0x0000FE65, - 0x00001FBA, 0x0000FE06, 0x000022D7, 0x0000FD9E, - 0x000025F3, 0x0000FD2B, 0x0000290E, 0x0000FCAF, - 0x00002C27, 0x0000FC29, 0x00002F3E, 0x0000FB9A, - 0x00003254, 0x0000FB01, 0x00003567, 0x0000FA5E, - 0x00003879, 0x0000F9B1, 0x00003B88, 0x0000F8FB, - 0x00003E95, 0x0000F83B, 0x000041A0, 0x0000F772, - 0x000044A8, 0x0000F69F, 0x000047AD, 0x0000F5C2, - 0x00004AB0, 0x0000F4DC, 0x00004DB0, 0x0000F3ED, - 0x000050AC, 0x0000F2F4, 0x000053A6, 0x0000F1F2, - 0x0000569D, 0x0000F0E7, 0x00005990, 0x0000EFD2, - 0x00005C7F, 0x0000EEB4, 0x00005F6B, 0x0000ED8D, - 0x00006254, 0x0000EC5C, 0x00006539, 0x0000EB23, - 0x00006819, 0x0000E9E0, 0x00006AF6, 0x0000E895, - 0x00006DCF, 0x0000E740, 0x000070A3, 0x0000E5E3, - 0x00007373, 0x0000E47D, 0x0000763F, 0x0000E30D, - 0x00007906, 0x0000E196, 0x00007BC8, 0x0000E015, - 0x00007E86, 0x0000DE8C, 0x0000813E, 0x0000DCFA, - 0x000083F2, 0x0000DB60, 0x000086A1, 0x0000D9BD, - 0x0000894A, 0x0000D812, 0x00008BEE, 0x0000D65F, - 0x00008E8D, 0x0000D4A3, 0x00009126, 0x0000D2DF, - 0x000093BA, 0x0000D113, 0x00009648, 0x0000CF3F, - 0x000098D0, 0x0000CD63, 0x00009B52, 0x0000CB7F, - 0x00009DCF, 0x0000C993, 0x0000A045, 0x0000C79F, - 0x0000A2B5, 0x0000C5A4, 0x0000A51F, 0x0000C3A1, - 0x0000A782, 0x0000C196, 0x0000A9DF, 0x0000BF84, - 0x0000AC35, 0x0000BD6B, 0x0000AE85, 0x0000BB4A, - 0x0000B0CE, 0x0000B922, 0x0000B310, 0x0000B6F3, - 0x0000B54B, 0x0000B4BD, 0x0000B780, 0x0000B280, - 0x0000B9AD, 0x0000B03C, 0x0000BBD3, 0x0000ADF2, - 0x0000BDF2, 0x0000ABA0, 0x0000C009, 0x0000A948, - 0x0000C21A, 0x0000A6EA, 0x0000C422, 0x0000A485, - 0x0000C623, 0x0000A219, 0x0000C81D, 0x00009FA8, - 0x0000CA0E, 0x00009D30, 0x0000CBF8, 0x00009AB2, - 0x0000CDDA, 0x0000982E, 0x0000CFB4, 0x000095A5, - 0x0000D187, 0x00009315, 0x0000D351, 0x00009080, - 0x0000D512, 0x00008DE6, 0x0000D6CC, 0x00008B46, - 0x0000D87E, 0x000088A0, 0x0000DA27, 0x000085F5, - 0x0000DBC7, 0x00008345, 0x0000DD5F, 0x00008090, - 0x0000DEEF, 0x00007DD7, 0x0000E076, 0x00007B18, - 0x0000E1F4, 0x00007854, 0x0000E36A, 0x0000758C, - 0x0000E4D7, 0x000072BF, 0x0000E63B, 0x00006FEE, - 0x0000E796, 0x00006D19, 0x0000E8E9, 0x00006A3F, - 0x0000EA32, 0x00006761, 0x0000EB72, 0x00006480, - 0x0000ECA9, 0x0000619A, 0x0000EDD7, 0x00005EB1, - 0x0000EEFC, 0x00005BC4, 0x0000F018, 0x000058D3, - 0x0000F12A, 0x000055DF, 0x0000F233, 0x000052E8, - 0x0000F333, 0x00004FED, 0x0000F42A, 0x00004CF0, - 0x0000F517, 0x000049EF, 0x0000F5FA, 0x000046EC, - 0x0000F6D4, 0x000043E6, 0x0000F7A5, 0x000040DD, - 0x0000F86C, 0x00003DD2, 0x0000F929, 0x00003AC4, - 0x0000F9DD, 0x000037B4, 0x0000FA87, 0x000034A2, - 0x0000FB28, 0x0000318E, 0x0000FBBF, 0x00002E78, - 0x0000FC4C, 0x00002B61, 0x0000FCCF, 0x00002847, - 0x0000FD49, 0x0000252C, 0x0000FDB9, 0x00002210, - 0x0000FE1F, 0x00001EF2, 0x0000FE7B, 0x00001BD3, - 0x0000FECE, 0x000018B3, 0x0000FF16, 0x00001592, - 0x0000FF55, 0x00001270, 0x0000FF8A, 0x00000F4E, - 0x0000FFB5, 0x00000C2B, 0x0000FFD7, 0x00000907, - 0x0000FFEE, 0x000005E3, 0x0000FFFC, 0x000002BF, - 0x00000023, 0x0000B504, 0x0000013F, 0x0000B503, - 0x0000025C, 0x0000B501, 0x00000378, 0x0000B4FC, - 0x00000494, 0x0000B4F6, 0x000005B1, 0x0000B4EE, - 0x000006CD, 0x0000B4E4, 0x000007E9, 0x0000B4D8, - 0x00000905, 0x0000B4CB, 0x00000A21, 0x0000B4BC, - 0x00000B3D, 0x0000B4AB, 0x00000C58, 0x0000B499, - 0x00000D74, 0x0000B484, 0x00000E8F, 0x0000B46E, - 0x00000FAB, 0x0000B457, 0x000010C6, 0x0000B43D, - 0x000011E1, 0x0000B422, 0x000012FC, 0x0000B405, - 0x00001417, 0x0000B3E6, 0x00001531, 0x0000B3C6, - 0x0000164B, 0x0000B3A4, 0x00001765, 0x0000B380, - 0x0000187F, 0x0000B35A, 0x00001999, 0x0000B333, - 0x00001AB2, 0x0000B30A, 0x00001BCB, 0x0000B2DF, - 0x00001CE4, 0x0000B2B2, 0x00001DFD, 0x0000B284, - 0x00001F15, 0x0000B254, 0x0000202D, 0x0000B222, - 0x00002145, 0x0000B1EF, 0x0000225C, 0x0000B1BA, - 0x00002373, 0x0000B183, 0x0000248A, 0x0000B14B, - 0x000025A0, 0x0000B110, 0x000026B6, 0x0000B0D4, - 0x000027CC, 0x0000B097, 0x000028E1, 0x0000B057, - 0x000029F6, 0x0000B016, 0x00002B0A, 0x0000AFD3, - 0x00002C1E, 0x0000AF8F, 0x00002D31, 0x0000AF49, - 0x00002E45, 0x0000AF01, 0x00002F57, 0x0000AEB8, - 0x00003069, 0x0000AE6C, 0x0000317B, 0x0000AE1F, - 0x0000328D, 0x0000ADD1, 0x0000339D, 0x0000AD81, - 0x000034AE, 0x0000AD2F, 0x000035BD, 0x0000ACDB, - 0x000036CD, 0x0000AC86, 0x000037DB, 0x0000AC2F, - 0x000038EA, 0x0000ABD6, 0x000039F7, 0x0000AB7C, - 0x00003B04, 0x0000AB20, 0x00003C11, 0x0000AAC3, - 0x00003D1D, 0x0000AA64, 0x00003E28, 0x0000AA03, - 0x00003F33, 0x0000A9A0, 0x0000403D, 0x0000A93C, - 0x00004147, 0x0000A8D6, 0x0000424F, 0x0000A86F, - 0x00004358, 0x0000A806, 0x0000445F, 0x0000A79C, - 0x00004566, 0x0000A72F, 0x0000466D, 0x0000A6C2, - 0x00004772, 0x0000A652, 0x00004877, 0x0000A5E1, - 0x0000497B, 0x0000A56E, 0x00004A7F, 0x0000A4FA, - 0x00004B82, 0x0000A484, 0x00004C84, 0x0000A40D, - 0x00004D85, 0x0000A394, 0x00004E86, 0x0000A319, - 0x00004F85, 0x0000A29D, 0x00005084, 0x0000A220, - 0x00005183, 0x0000A1A0, 0x00005280, 0x0000A120, - 0x0000537D, 0x0000A09D, 0x00005479, 0x0000A019, - 0x00005574, 0x00009F94, 0x0000566E, 0x00009F0D, - 0x00005767, 0x00009E84, 0x00005860, 0x00009DFA, - 0x00005958, 0x00009D6F, 0x00005A4F, 0x00009CE2, - 0x00005B45, 0x00009C53, 0x00005C3A, 0x00009BC3, - 0x00005D2E, 0x00009B31, 0x00005E21, 0x00009A9E, - 0x00005F14, 0x00009A09, 0x00006005, 0x00009973, - 0x000060F6, 0x000098DC, 0x000061E5, 0x00009843, - 0x000062D4, 0x000097A8, 0x000063C2, 0x0000970C, - 0x000064AF, 0x0000966F, 0x0000659B, 0x000095D0, - 0x00006685, 0x00009530, 0x0000676F, 0x0000948E, - 0x00006858, 0x000093EB, 0x00006940, 0x00009346, - 0x00006A27, 0x000092A0, 0x00006B0D, 0x000091F9, - 0x00006BF1, 0x00009150, 0x00006CD5, 0x000090A5, - 0x00006DB8, 0x00008FFA, 0x00006E99, 0x00008F4D, - 0x00006F7A, 0x00008E9E, 0x00007059, 0x00008DEF, - 0x00007138, 0x00008D3D, 0x00007215, 0x00008C8B, - 0x000072F1, 0x00008BD7, 0x000073CC, 0x00008B22, - 0x000074A6, 0x00008A6B, 0x0000757F, 0x000089B3, - 0x00007657, 0x000088FA, 0x0000772E, 0x00008840, - 0x00007803, 0x00008784, 0x000078D7, 0x000086C6, - 0x000079AB, 0x00008608, 0x00007A7C, 0x00008548, - 0x00007B4D, 0x00008487, 0x00007C1D, 0x000083C5, - 0x00007CEB, 0x00008301, 0x00007DB8, 0x0000823C, - 0x00007E84, 0x00008176, 0x00007F4F, 0x000080AF, - 0x00008019, 0x00007FE6, 0x000080E1, 0x00007F1D, - 0x000081A8, 0x00007E51, 0x0000826E, 0x00007D85, - 0x00008332, 0x00007CB8, 0x000083F6, 0x00007BE9, - 0x000084B8, 0x00007B19, 0x00008578, 0x00007A48, - 0x00008638, 0x00007976, 0x000086F6, 0x000078A2, - 0x000087B3, 0x000077CE, 0x0000886E, 0x000076F8, - 0x00008928, 0x00007621, 0x000089E1, 0x00007549, - 0x00008A99, 0x00007470, 0x00008B4F, 0x00007396, - 0x00008C04, 0x000072BA, 0x00008CB8, 0x000071DE, - 0x00008D6A, 0x00007100, 0x00008E1B, 0x00007022, - 0x00008ECA, 0x00006F42, 0x00008F78, 0x00006E61, - 0x00009025, 0x00006D7F, 0x000090D0, 0x00006C9C, - 0x0000917A, 0x00006BB8, 0x00009223, 0x00006AD3, - 0x000092CA, 0x000069ED, 0x0000936F, 0x00006906, - 0x00009414, 0x0000681E, 0x000094B6, 0x00006735, - 0x00009558, 0x0000664B, 0x000095F8, 0x00006560, - 0x00009696, 0x00006474, 0x00009733, 0x00006387, - 0x000097CF, 0x00006299, 0x00009869, 0x000061AA, - 0x00009902, 0x000060BA, 0x00009999, 0x00005FC9, - 0x00009A2F, 0x00005ED7, 0x00009AC3, 0x00005DE5, - 0x00009B56, 0x00005CF1, 0x00009BE7, 0x00005BFD, - 0x00009C77, 0x00005B07, 0x00009D05, 0x00005A11, - 0x00009D92, 0x0000591A, 0x00009E1D, 0x00005822, - 0x00009EA7, 0x00005729, 0x00009F2F, 0x00005630, - 0x00009FB5, 0x00005535, 0x0000A03A, 0x0000543A, - 0x0000A0BE, 0x0000533E, 0x0000A140, 0x00005241, - 0x0000A1C0, 0x00005143, 0x0000A23F, 0x00005045, - 0x0000A2BD, 0x00004F45, 0x0000A338, 0x00004E45, - 0x0000A3B2, 0x00004D45, 0x0000A42B, 0x00004C43, - 0x0000A4A2, 0x00004B41, 0x0000A517, 0x00004A3E, - 0x0000A58B, 0x0000493A, 0x0000A5FD, 0x00004836, - 0x0000A66E, 0x00004731, 0x0000A6DD, 0x0000462B, - 0x0000A74B, 0x00004525, 0x0000A7B6, 0x0000441D, - 0x0000A821, 0x00004316, 0x0000A889, 0x0000420D, - 0x0000A8F0, 0x00004104, 0x0000A955, 0x00003FFB, - 0x0000A9B9, 0x00003EF0, 0x0000AA1B, 0x00003DE5, - 0x0000AA7C, 0x00003CDA, 0x0000AADA, 0x00003BCE, - 0x0000AB37, 0x00003AC1, 0x0000AB93, 0x000039B4, - 0x0000ABED, 0x000038A6, 0x0000AC45, 0x00003798, - 0x0000AC9B, 0x00003689, 0x0000ACF0, 0x00003579, - 0x0000AD43, 0x0000346A, 0x0000AD95, 0x00003359, - 0x0000ADE5, 0x00003248, 0x0000AE33, 0x00003137, - 0x0000AE7F, 0x00003025, 0x0000AECA, 0x00002F13, - 0x0000AF13, 0x00002E00, 0x0000AF5B, 0x00002CED, - 0x0000AFA0, 0x00002BD9, 0x0000AFE4, 0x00002AC5, - 0x0000B027, 0x000029B0, 0x0000B067, 0x0000289B, - 0x0000B0A6, 0x00002786, 0x0000B0E3, 0x00002671, - 0x0000B11F, 0x0000255A, 0x0000B159, 0x00002444, - 0x0000B191, 0x0000232D, 0x0000B1C7, 0x00002216, - 0x0000B1FC, 0x000020FF, 0x0000B22F, 0x00001FE7, - 0x0000B260, 0x00001ECF, 0x0000B290, 0x00001DB7, - 0x0000B2BE, 0x00001C9E, 0x0000B2EA, 0x00001B85, - 0x0000B314, 0x00001A6C, 0x0000B33D, 0x00001953, - 0x0000B364, 0x00001839, 0x0000B389, 0x0000171F, - 0x0000B3AC, 0x00001605, 0x0000B3CE, 0x000014EB, - 0x0000B3EE, 0x000013D0, 0x0000B40C, 0x000012B5, - 0x0000B429, 0x0000119A, 0x0000B444, 0x0000107F, - 0x0000B45D, 0x00000F64, 0x0000B474, 0x00000E49, - 0x0000B489, 0x00000D2D, 0x0000B49D, 0x00000C11, - 0x0000B4AF, 0x00000AF6, 0x0000B4C0, 0x000009DA, - 0x0000B4CE, 0x000008BE, 0x0000B4DB, 0x000007A2, - 0x0000B4E6, 0x00000686, 0x0000B4F0, 0x00000569, - 0x0000B4F7, 0x0000044D, 0x0000B4FD, 0x00000331, - 0x0000B501, 0x00000215, 0x0000B504, 0x000000F8, - 0x0000000C, 0x00007FFF, 0x00000071, 0x00007FFF, - 0x000000D5, 0x00007FFF, 0x0000013A, 0x00007FFE, - 0x0000019E, 0x00007FFD, 0x00000203, 0x00007FFB, - 0x00000267, 0x00007FFA, 0x000002CC, 0x00007FF8, - 0x00000330, 0x00007FF5, 0x00000395, 0x00007FF3, - 0x000003F9, 0x00007FF0, 0x0000045E, 0x00007FEC, - 0x000004C2, 0x00007FE9, 0x00000527, 0x00007FE5, - 0x0000058B, 0x00007FE1, 0x000005EF, 0x00007FDC, - 0x00000654, 0x00007FD7, 0x000006B8, 0x00007FD2, - 0x0000071D, 0x00007FCD, 0x00000781, 0x00007FC7, - 0x000007E5, 0x00007FC1, 0x0000084A, 0x00007FBB, - 0x000008AE, 0x00007FB4, 0x00000912, 0x00007FAD, - 0x00000977, 0x00007FA6, 0x000009DB, 0x00007F9E, - 0x00000A3F, 0x00007F96, 0x00000AA3, 0x00007F8E, - 0x00000B07, 0x00007F86, 0x00000B6C, 0x00007F7D, - 0x00000BD0, 0x00007F74, 0x00000C34, 0x00007F6A, - 0x00000C98, 0x00007F60, 0x00000CFC, 0x00007F56, - 0x00000D60, 0x00007F4C, 0x00000DC4, 0x00007F41, - 0x00000E28, 0x00007F36, 0x00000E8C, 0x00007F2B, - 0x00000EF0, 0x00007F20, 0x00000F53, 0x00007F14, - 0x00000FB7, 0x00007F08, 0x0000101B, 0x00007EFB, - 0x0000107F, 0x00007EEE, 0x000010E2, 0x00007EE1, - 0x00001146, 0x00007ED4, 0x000011A9, 0x00007EC6, - 0x0000120D, 0x00007EB8, 0x00001271, 0x00007EAA, - 0x000012D4, 0x00007E9B, 0x00001337, 0x00007E8C, - 0x0000139B, 0x00007E7D, 0x000013FE, 0x00007E6D, - 0x00001461, 0x00007E5D, 0x000014C5, 0x00007E4D, - 0x00001528, 0x00007E3D, 0x0000158B, 0x00007E2C, - 0x000015EE, 0x00007E1B, 0x00001651, 0x00007E0A, - 0x000016B4, 0x00007DF8, 0x00001717, 0x00007DE6, - 0x0000177A, 0x00007DD4, 0x000017DD, 0x00007DC1, - 0x0000183F, 0x00007DAE, 0x000018A2, 0x00007D9B, - 0x00001905, 0x00007D87, 0x00001967, 0x00007D74, - 0x000019CA, 0x00007D60, 0x00001A2C, 0x00007D4B, - 0x00001A8E, 0x00007D36, 0x00001AF1, 0x00007D21, - 0x00001B53, 0x00007D0C, 0x00001BB5, 0x00007CF6, - 0x00001C17, 0x00007CE1, 0x00001C79, 0x00007CCA, - 0x00001CDB, 0x00007CB4, 0x00001D3D, 0x00007C9D, - 0x00001D9F, 0x00007C86, 0x00001E01, 0x00007C6E, - 0x00001E62, 0x00007C57, 0x00001EC4, 0x00007C3F, - 0x00001F26, 0x00007C26, 0x00001F87, 0x00007C0E, - 0x00001FE9, 0x00007BF5, 0x0000204A, 0x00007BDC, - 0x000020AB, 0x00007BC2, 0x0000210C, 0x00007BA8, - 0x0000216D, 0x00007B8E, 0x000021CE, 0x00007B74, - 0x0000222F, 0x00007B59, 0x00002290, 0x00007B3E, - 0x000022F1, 0x00007B23, 0x00002352, 0x00007B07, - 0x000023B2, 0x00007AEB, 0x00002413, 0x00007ACF, - 0x00002473, 0x00007AB3, 0x000024D3, 0x00007A96, - 0x00002534, 0x00007A79, 0x00002594, 0x00007A5C, - 0x000025F4, 0x00007A3E, 0x00002654, 0x00007A20, - 0x000026B4, 0x00007A02, 0x00002713, 0x000079E3, - 0x00002773, 0x000079C4, 0x000027D3, 0x000079A5, - 0x00002832, 0x00007986, 0x00002892, 0x00007966, - 0x000028F1, 0x00007946, 0x00002950, 0x00007926, - 0x000029AF, 0x00007905, 0x00002A0E, 0x000078E4, - 0x00002A6D, 0x000078C3, 0x00002ACC, 0x000078A2, - 0x00002B2B, 0x00007880, 0x00002B89, 0x0000785E, - 0x00002BE8, 0x0000783B, 0x00002C46, 0x00007819, - 0x00002CA4, 0x000077F6, 0x00002D02, 0x000077D3, - 0x00002D60, 0x000077AF, 0x00002DBE, 0x0000778B, - 0x00002E1C, 0x00007767, 0x00002E7A, 0x00007743, - 0x00002ED8, 0x0000771E, 0x00002F35, 0x000076F9, - 0x00002F92, 0x000076D4, 0x00002FF0, 0x000076AF, - 0x0000304D, 0x00007689, 0x000030AA, 0x00007663, - 0x00003107, 0x0000763C, 0x00003164, 0x00007616, - 0x000031C0, 0x000075EF, 0x0000321D, 0x000075C8, - 0x00003279, 0x000075A0, 0x000032D6, 0x00007578, - 0x00003332, 0x00007550, 0x0000338E, 0x00007528, - 0x000033EA, 0x000074FF, 0x00003446, 0x000074D6, - 0x000034A1, 0x000074AD, 0x000034FD, 0x00007484, - 0x00003558, 0x0000745A, 0x000035B4, 0x00007430, - 0x0000360F, 0x00007406, 0x0000366A, 0x000073DB, - 0x000036C5, 0x000073B0, 0x00003720, 0x00007385, - 0x0000377A, 0x00007359, 0x000037D5, 0x0000732E, - 0x0000382F, 0x00007302, 0x0000388A, 0x000072D5, - 0x000038E4, 0x000072A9, 0x0000393E, 0x0000727C, - 0x00003998, 0x0000724F, 0x000039F1, 0x00007222, - 0x00003A4B, 0x000071F4, 0x00003AA4, 0x000071C6, - 0x00003AFE, 0x00007198, 0x00003B57, 0x00007169, - 0x00003BB0, 0x0000713B, 0x00003C09, 0x0000710C, - 0x00003C61, 0x000070DC, 0x00003CBA, 0x000070AD, - 0x00003D12, 0x0000707D, 0x00003D6B, 0x0000704D, - 0x00003DC3, 0x0000701D, 0x00003E1B, 0x00006FEC, - 0x00003E73, 0x00006FBB, 0x00003ECA, 0x00006F8A, - 0x00003F22, 0x00006F58, 0x00003F79, 0x00006F27, - 0x00003FD0, 0x00006EF5, 0x00004027, 0x00006EC2, - 0x0000407E, 0x00006E90, 0x000040D5, 0x00006E5D, - 0x0000412C, 0x00006E2A, 0x00004182, 0x00006DF7, - 0x000041D8, 0x00006DC3, 0x0000422F, 0x00006D8F, - 0x00004284, 0x00006D5B, 0x000042DA, 0x00006D27, - 0x00004330, 0x00006CF2, 0x00004385, 0x00006CBD, - 0x000043DB, 0x00006C88, 0x00004430, 0x00006C53, - 0x00004485, 0x00006C1D, 0x000044DA, 0x00006BE7, - 0x0000452E, 0x00006BB1, 0x00004583, 0x00006B7A, - 0x000045D7, 0x00006B44, 0x0000462B, 0x00006B0D, - 0x0000467F, 0x00006AD5, 0x000046D3, 0x00006A9E, - 0x00004727, 0x00006A66, 0x0000477A, 0x00006A2E, - 0x000047CE, 0x000069F6, 0x00004821, 0x000069BD, - 0x00004874, 0x00006985, 0x000048C7, 0x0000694B, - 0x00004919, 0x00006912, 0x0000496C, 0x000068D9, - 0x000049BE, 0x0000689F, 0x00004A10, 0x00006865, - 0x00004A62, 0x0000682B, 0x00004AB4, 0x000067F0, - 0x00004B05, 0x000067B5, 0x00004B56, 0x0000677A, - 0x00004BA8, 0x0000673F, 0x00004BF9, 0x00006703, - 0x00004C49, 0x000066C8, 0x00004C9A, 0x0000668B, - 0x00004CEB, 0x0000664F, 0x00004D3B, 0x00006613, - 0x00004D8B, 0x000065D6, 0x00004DDB, 0x00006599, - 0x00004E2A, 0x0000655C, 0x00004E7A, 0x0000651E, - 0x00004EC9, 0x000064E0, 0x00004F18, 0x000064A2, - 0x00004F67, 0x00006464, 0x00004FB6, 0x00006426, - 0x00005005, 0x000063E7, 0x00005053, 0x000063A8, - 0x000050A1, 0x00006369, 0x000050EF, 0x00006329, - 0x0000513D, 0x000062EA, 0x0000518B, 0x000062AA, - 0x000051D8, 0x00006269, 0x00005225, 0x00006229, - 0x00005272, 0x000061E8, 0x000052BF, 0x000061A8, - 0x0000530C, 0x00006166, 0x00005358, 0x00006125, - 0x000053A4, 0x000060E4, 0x000053F0, 0x000060A2, - 0x0000543C, 0x00006060, 0x00005488, 0x0000601D, - 0x000054D3, 0x00005FDB, 0x0000551E, 0x00005F98, - 0x00005569, 0x00005F55, 0x000055B4, 0x00005F12, - 0x000055FE, 0x00005ECF, 0x00005649, 0x00005E8B, - 0x00005693, 0x00005E47, 0x000056DD, 0x00005E03, - 0x00005727, 0x00005DBF, 0x00005770, 0x00005D7A, - 0x000057B9, 0x00005D35, 0x00005803, 0x00005CF0, - 0x0000584B, 0x00005CAB, 0x00005894, 0x00005C66, - 0x000058DD, 0x00005C20, 0x00005925, 0x00005BDA, - 0x0000596D, 0x00005B94, 0x000059B5, 0x00005B4D, - 0x000059FC, 0x00005B07, 0x00005A44, 0x00005AC0, - 0x00005A8B, 0x00005A79, 0x00005AD2, 0x00005A32, - 0x00005B19, 0x000059EA, 0x00005B5F, 0x000059A3, - 0x00005BA5, 0x0000595B, 0x00005BEB, 0x00005913, - 0x00005C31, 0x000058CB, 0x00005C77, 0x00005882, - 0x00005CBC, 0x00005839, 0x00005D01, 0x000057F0, - 0x00005D46, 0x000057A7, 0x00005D8B, 0x0000575E, - 0x00005DD0, 0x00005714, 0x00005E14, 0x000056CA, - 0x00005E58, 0x00005680, 0x00005E9C, 0x00005636, - 0x00005EDF, 0x000055EC, 0x00005F23, 0x000055A1, - 0x00005F66, 0x00005556, 0x00005FA9, 0x0000550B, - 0x00005FEC, 0x000054C0, 0x0000602E, 0x00005475, - 0x00006070, 0x00005429, 0x000060B2, 0x000053DD, - 0x000060F4, 0x00005391, 0x00006135, 0x00005345, - 0x00006177, 0x000052F8, 0x000061B8, 0x000052AC, - 0x000061F9, 0x0000525F, 0x00006239, 0x00005212, - 0x0000627A, 0x000051C5, 0x000062BA, 0x00005177, - 0x000062F9, 0x0000512A, 0x00006339, 0x000050DC, - 0x00006378, 0x0000508E, 0x000063B8, 0x00005040, - 0x000063F7, 0x00004FF1, 0x00006435, 0x00004FA2, - 0x00006474, 0x00004F54, 0x000064B2, 0x00004F05, - 0x000064F0, 0x00004EB6, 0x0000652D, 0x00004E66, - 0x0000656B, 0x00004E17, 0x000065A8, 0x00004DC7, - 0x000065E5, 0x00004D77, 0x00006622, 0x00004D27, - 0x0000665E, 0x00004CD6, 0x0000669B, 0x00004C86, - 0x000066D6, 0x00004C35, 0x00006712, 0x00004BE4, - 0x0000674E, 0x00004B93, 0x00006789, 0x00004B42, - 0x000067C4, 0x00004AF1, 0x000067FF, 0x00004A9F, - 0x00006839, 0x00004A4D, 0x00006873, 0x000049FB, - 0x000068AD, 0x000049A9, 0x000068E7, 0x00004957, - 0x00006921, 0x00004905, 0x0000695A, 0x000048B2, - 0x00006993, 0x0000485F, 0x000069CB, 0x0000480C, - 0x00006A04, 0x000047B9, 0x00006A3C, 0x00004766, - 0x00006A74, 0x00004712, 0x00006AAC, 0x000046BE, - 0x00006AE3, 0x0000466A, 0x00006B1A, 0x00004616, - 0x00006B51, 0x000045C2, 0x00006B88, 0x0000456E, - 0x00006BBE, 0x00004519, 0x00006BF5, 0x000044C5, - 0x00006C2A, 0x00004470, 0x00006C60, 0x0000441B, - 0x00006C95, 0x000043C5, 0x00006CCA, 0x00004370, - 0x00006CFF, 0x0000431B, 0x00006D34, 0x000042C5, - 0x00006D68, 0x0000426F, 0x00006D9C, 0x00004219, - 0x00006DD0, 0x000041C3, 0x00006E04, 0x0000416D, - 0x00006E37, 0x00004116, 0x00006E6A, 0x000040BF, - 0x00006E9C, 0x00004069, 0x00006ECF, 0x00004012, - 0x00006F01, 0x00003FBB, 0x00006F33, 0x00003F63, - 0x00006F65, 0x00003F0C, 0x00006F96, 0x00003EB4, - 0x00006FC7, 0x00003E5D, 0x00006FF8, 0x00003E05, - 0x00007029, 0x00003DAD, 0x00007059, 0x00003D55, - 0x00007089, 0x00003CFC, 0x000070B9, 0x00003CA4, - 0x000070E8, 0x00003C4B, 0x00007117, 0x00003BF2, - 0x00007146, 0x00003B99, 0x00007175, 0x00003B40, - 0x000071A3, 0x00003AE7, 0x000071D2, 0x00003A8E, - 0x000071FF, 0x00003A34, 0x0000722D, 0x000039DB, - 0x0000725A, 0x00003981, 0x00007287, 0x00003927, - 0x000072B4, 0x000038CD, 0x000072E1, 0x00003873, - 0x0000730D, 0x00003819, 0x00007339, 0x000037BE, - 0x00007364, 0x00003764, 0x00007390, 0x00003709, - 0x000073BB, 0x000036AE, 0x000073E6, 0x00003653, - 0x00007410, 0x000035F8, 0x0000743A, 0x0000359D, - 0x00007464, 0x00003542, 0x0000748E, 0x000034E6, - 0x000074B7, 0x0000348B, 0x000074E1, 0x0000342F, - 0x00007509, 0x000033D3, 0x00007532, 0x00003377, - 0x0000755A, 0x0000331B, 0x00007582, 0x000032BF, - 0x000075AA, 0x00003262, 0x000075D1, 0x00003206, - 0x000075F9, 0x000031A9, 0x0000761F, 0x0000314C, - 0x00007646, 0x000030F0, 0x0000766C, 0x00003093, - 0x00007692, 0x00003036, 0x000076B8, 0x00002FD8, - 0x000076DD, 0x00002F7B, 0x00007703, 0x00002F1E, - 0x00007727, 0x00002EC0, 0x0000774C, 0x00002E63, - 0x00007770, 0x00002E05, 0x00007794, 0x00002DA7, - 0x000077B8, 0x00002D49, 0x000077DB, 0x00002CEB, - 0x000077FF, 0x00002C8D, 0x00007821, 0x00002C2E, - 0x00007844, 0x00002BD0, 0x00007866, 0x00002B71, - 0x00007888, 0x00002B13, 0x000078AA, 0x00002AB4, - 0x000078CB, 0x00002A55, 0x000078EC, 0x000029F6, - 0x0000790D, 0x00002997, 0x0000792E, 0x00002938, - 0x0000794E, 0x000028D9, 0x0000796E, 0x0000287A, - 0x0000798E, 0x0000281A, 0x000079AD, 0x000027BB, - 0x000079CC, 0x0000275B, 0x000079EB, 0x000026FB, - 0x00007A09, 0x0000269C, 0x00007A27, 0x0000263C, - 0x00007A45, 0x000025DC, 0x00007A63, 0x0000257C, - 0x00007A80, 0x0000251C, 0x00007A9D, 0x000024BB, - 0x00007ABA, 0x0000245B, 0x00007AD6, 0x000023FA, - 0x00007AF2, 0x0000239A, 0x00007B0E, 0x00002339, - 0x00007B2A, 0x000022D9, 0x00007B45, 0x00002278, - 0x00007B60, 0x00002217, 0x00007B7A, 0x000021B6, - 0x00007B95, 0x00002155, 0x00007BAF, 0x000020F4, - 0x00007BC9, 0x00002093, 0x00007BE2, 0x00002032, - 0x00007BFB, 0x00001FD0, 0x00007C14, 0x00001F6F, - 0x00007C2D, 0x00001F0D, 0x00007C45, 0x00001EAC, - 0x00007C5D, 0x00001E4A, 0x00007C74, 0x00001DE8, - 0x00007C8C, 0x00001D87, 0x00007CA3, 0x00001D25, - 0x00007CB9, 0x00001CC3, 0x00007CD0, 0x00001C61, - 0x00007CE6, 0x00001BFF, 0x00007CFC, 0x00001B9D, - 0x00007D11, 0x00001B3A, 0x00007D27, 0x00001AD8, - 0x00007D3C, 0x00001A76, 0x00007D50, 0x00001A13, - 0x00007D65, 0x000019B1, 0x00007D79, 0x0000194E, - 0x00007D8C, 0x000018EC, 0x00007DA0, 0x00001889, - 0x00007DB3, 0x00001827, 0x00007DC6, 0x000017C4, - 0x00007DD8, 0x00001761, 0x00007DEA, 0x000016FE, - 0x00007DFC, 0x0000169B, 0x00007E0E, 0x00001638, - 0x00007E1F, 0x000015D5, 0x00007E30, 0x00001572, - 0x00007E41, 0x0000150F, 0x00007E51, 0x000014AC, - 0x00007E61, 0x00001449, 0x00007E71, 0x000013E5, - 0x00007E81, 0x00001382, 0x00007E90, 0x0000131F, - 0x00007E9F, 0x000012BB, 0x00007EAD, 0x00001258, - 0x00007EBB, 0x000011F4, 0x00007EC9, 0x00001191, - 0x00007ED7, 0x0000112D, 0x00007EE4, 0x000010C9, - 0x00007EF1, 0x00001066, 0x00007EFE, 0x00001002, - 0x00007F0B, 0x00000F9E, 0x00007F17, 0x00000F3A, - 0x00007F23, 0x00000ED7, 0x00007F2E, 0x00000E73, - 0x00007F39, 0x00000E0F, 0x00007F44, 0x00000DAB, - 0x00007F4F, 0x00000D47, 0x00007F59, 0x00000CE3, - 0x00007F63, 0x00000C7F, 0x00007F6D, 0x00000C1B, - 0x00007F76, 0x00000BB7, 0x00007F7F, 0x00000B53, - 0x00007F88, 0x00000AEE, 0x00007F90, 0x00000A8A, - 0x00007F98, 0x00000A26, 0x00007FA0, 0x000009C2, - 0x00007FA8, 0x0000095E, 0x00007FAF, 0x000008F9, - 0x00007FB6, 0x00000895, 0x00007FBC, 0x00000831, - 0x00007FC3, 0x000007CC, 0x00007FC9, 0x00000768, - 0x00007FCE, 0x00000704, 0x00007FD4, 0x0000069F, - 0x00007FD9, 0x0000063B, 0x00007FDD, 0x000005D6, - 0x00007FE2, 0x00000572, 0x00007FE6, 0x0000050D, - 0x00007FEA, 0x000004A9, 0x00007FED, 0x00000445, - 0x00007FF0, 0x000003E0, 0x00007FF3, 0x0000037C, - 0x00007FF6, 0x00000317, 0x00007FF8, 0x000002B3, - 0x00007FFA, 0x0000024E, 0x00007FFC, 0x000001EA, - 0x00007FFD, 0x00000185, 0x00007FFE, 0x00000121, - 0x00007FFF, 0x000000BC, 0x00007FFF, 0x00000057, - 0x00000004, 0x00005A82, 0x00000027, 0x00005A82, - 0x0000004B, 0x00005A82, 0x0000006F, 0x00005A82, - 0x00000092, 0x00005A82, 0x000000B6, 0x00005A81, - 0x000000D9, 0x00005A81, 0x000000FD, 0x00005A81, - 0x00000120, 0x00005A80, 0x00000144, 0x00005A80, - 0x00000167, 0x00005A7F, 0x0000018B, 0x00005A7F, - 0x000001AE, 0x00005A7E, 0x000001D2, 0x00005A7D, - 0x000001F6, 0x00005A7D, 0x00000219, 0x00005A7C, - 0x0000023D, 0x00005A7B, 0x00000260, 0x00005A7A, - 0x00000284, 0x00005A79, 0x000002A7, 0x00005A78, - 0x000002CB, 0x00005A77, 0x000002EE, 0x00005A76, - 0x00000312, 0x00005A75, 0x00000335, 0x00005A73, - 0x00000359, 0x00005A72, 0x0000037C, 0x00005A71, - 0x000003A0, 0x00005A6F, 0x000003C3, 0x00005A6E, - 0x000003E7, 0x00005A6C, 0x0000040A, 0x00005A6B, - 0x0000042E, 0x00005A69, 0x00000451, 0x00005A68, - 0x00000475, 0x00005A66, 0x00000498, 0x00005A64, - 0x000004BC, 0x00005A62, 0x000004DF, 0x00005A60, - 0x00000503, 0x00005A5E, 0x00000526, 0x00005A5C, - 0x0000054A, 0x00005A5A, 0x0000056D, 0x00005A58, - 0x00000591, 0x00005A56, 0x000005B4, 0x00005A54, - 0x000005D8, 0x00005A52, 0x000005FB, 0x00005A4F, - 0x0000061F, 0x00005A4D, 0x00000642, 0x00005A4A, - 0x00000666, 0x00005A48, 0x00000689, 0x00005A45, - 0x000006AC, 0x00005A43, 0x000006D0, 0x00005A40, - 0x000006F3, 0x00005A3E, 0x00000717, 0x00005A3B, - 0x0000073A, 0x00005A38, 0x0000075E, 0x00005A35, - 0x00000781, 0x00005A32, 0x000007A4, 0x00005A2F, - 0x000007C8, 0x00005A2C, 0x000007EB, 0x00005A29, - 0x0000080F, 0x00005A26, 0x00000832, 0x00005A23, - 0x00000855, 0x00005A1F, 0x00000879, 0x00005A1C, - 0x0000089C, 0x00005A19, 0x000008C0, 0x00005A15, - 0x000008E3, 0x00005A12, 0x00000906, 0x00005A0E, - 0x0000092A, 0x00005A0B, 0x0000094D, 0x00005A07, - 0x00000970, 0x00005A04, 0x00000994, 0x00005A00, - 0x000009B7, 0x000059FC, 0x000009DA, 0x000059F8, - 0x000009FE, 0x000059F4, 0x00000A21, 0x000059F0, - 0x00000A44, 0x000059EC, 0x00000A68, 0x000059E8, - 0x00000A8B, 0x000059E4, 0x00000AAE, 0x000059E0, - 0x00000AD2, 0x000059DC, 0x00000AF5, 0x000059D8, - 0x00000B18, 0x000059D3, 0x00000B3B, 0x000059CF, - 0x00000B5F, 0x000059CA, 0x00000B82, 0x000059C6, - 0x00000BA5, 0x000059C1, 0x00000BC9, 0x000059BD, - 0x00000BEC, 0x000059B8, 0x00000C0F, 0x000059B3, - 0x00000C32, 0x000059AF, 0x00000C55, 0x000059AA, - 0x00000C79, 0x000059A5, 0x00000C9C, 0x000059A0, - 0x00000CBF, 0x0000599B, 0x00000CE2, 0x00005996, - 0x00000D05, 0x00005991, 0x00000D29, 0x0000598C, - 0x00000D4C, 0x00005987, 0x00000D6F, 0x00005981, - 0x00000D92, 0x0000597C, 0x00000DB5, 0x00005977, - 0x00000DD8, 0x00005971, 0x00000DFB, 0x0000596C, - 0x00000E1F, 0x00005966, 0x00000E42, 0x00005961, - 0x00000E65, 0x0000595B, 0x00000E88, 0x00005955, - 0x00000EAB, 0x00005950, 0x00000ECE, 0x0000594A, - 0x00000EF1, 0x00005944, 0x00000F14, 0x0000593E, - 0x00000F37, 0x00005938, 0x00000F5A, 0x00005932, - 0x00000F7D, 0x0000592C, 0x00000FA0, 0x00005926, - 0x00000FC3, 0x00005920, 0x00000FE6, 0x0000591A, - 0x00001009, 0x00005913, 0x0000102C, 0x0000590D, - 0x0000104F, 0x00005907, 0x00001072, 0x00005900, - 0x00001095, 0x000058FA, 0x000010B8, 0x000058F3, - 0x000010DB, 0x000058ED, 0x000010FE, 0x000058E6, - 0x00001121, 0x000058DF, 0x00001144, 0x000058D8, - 0x00001166, 0x000058D2, 0x00001189, 0x000058CB, - 0x000011AC, 0x000058C4, 0x000011CF, 0x000058BD, - 0x000011F2, 0x000058B6, 0x00001215, 0x000058AF, - 0x00001238, 0x000058A8, 0x0000125A, 0x000058A1, - 0x0000127D, 0x00005899, 0x000012A0, 0x00005892, - 0x000012C3, 0x0000588B, 0x000012E5, 0x00005883, - 0x00001308, 0x0000587C, 0x0000132B, 0x00005874, - 0x0000134E, 0x0000586D, 0x00001370, 0x00005865, - 0x00001393, 0x0000585D, 0x000013B6, 0x00005856, - 0x000013D9, 0x0000584E, 0x000013FB, 0x00005846, - 0x0000141E, 0x0000583E, 0x00001440, 0x00005836, - 0x00001463, 0x0000582E, 0x00001486, 0x00005826, - 0x000014A8, 0x0000581E, 0x000014CB, 0x00005816, - 0x000014EE, 0x0000580E, 0x00001510, 0x00005806, - 0x00001533, 0x000057FD, 0x00001555, 0x000057F5, - 0x00001578, 0x000057ED, 0x0000159A, 0x000057E4, - 0x000015BD, 0x000057DC, 0x000015DF, 0x000057D3, - 0x00001602, 0x000057CB, 0x00001624, 0x000057C2, - 0x00001647, 0x000057B9, 0x00001669, 0x000057B0, - 0x0000168C, 0x000057A8, 0x000016AE, 0x0000579F, - 0x000016D0, 0x00005796, 0x000016F3, 0x0000578D, - 0x00001715, 0x00005784, 0x00001738, 0x0000577B, - 0x0000175A, 0x00005771, 0x0000177C, 0x00005768, - 0x0000179F, 0x0000575F, 0x000017C1, 0x00005756, - 0x000017E3, 0x0000574C, 0x00001805, 0x00005743, - 0x00001828, 0x00005739, 0x0000184A, 0x00005730, - 0x0000186C, 0x00005726, 0x0000188E, 0x0000571D, - 0x000018B1, 0x00005713, 0x000018D3, 0x00005709, - 0x000018F5, 0x00005700, 0x00001917, 0x000056F6, - 0x00001939, 0x000056EC, 0x0000195B, 0x000056E2, - 0x0000197D, 0x000056D8, 0x000019A0, 0x000056CE, - 0x000019C2, 0x000056C4, 0x000019E4, 0x000056BA, - 0x00001A06, 0x000056B0, 0x00001A28, 0x000056A5, - 0x00001A4A, 0x0000569B, 0x00001A6C, 0x00005691, - 0x00001A8E, 0x00005686, 0x00001AB0, 0x0000567C, - 0x00001AD2, 0x00005671, 0x00001AF4, 0x00005667, - 0x00001B16, 0x0000565C, 0x00001B37, 0x00005651, - 0x00001B59, 0x00005647, 0x00001B7B, 0x0000563C, - 0x00001B9D, 0x00005631, 0x00001BBF, 0x00005626, - 0x00001BE1, 0x0000561B, 0x00001C03, 0x00005610, - 0x00001C24, 0x00005605, 0x00001C46, 0x000055FA, - 0x00001C68, 0x000055EF, 0x00001C8A, 0x000055E4, - 0x00001CAB, 0x000055D9, 0x00001CCD, 0x000055CD, - 0x00001CEF, 0x000055C2, 0x00001D10, 0x000055B7, - 0x00001D32, 0x000055AB, 0x00001D54, 0x000055A0, - 0x00001D75, 0x00005594, 0x00001D97, 0x00005589, - 0x00001DB8, 0x0000557D, 0x00001DDA, 0x00005571, - 0x00001DFC, 0x00005566, 0x00001E1D, 0x0000555A, - 0x00001E3F, 0x0000554E, 0x00001E60, 0x00005542, - 0x00001E82, 0x00005536, 0x00001EA3, 0x0000552A, - 0x00001EC4, 0x0000551E, 0x00001EE6, 0x00005512, - 0x00001F07, 0x00005506, 0x00001F29, 0x000054F9, - 0x00001F4A, 0x000054ED, 0x00001F6B, 0x000054E1, - 0x00001F8D, 0x000054D5, 0x00001FAE, 0x000054C8, - 0x00001FCF, 0x000054BC, 0x00001FF1, 0x000054AF, - 0x00002012, 0x000054A3, 0x00002033, 0x00005496, - 0x00002054, 0x00005489, 0x00002075, 0x0000547D, - 0x00002097, 0x00005470, 0x000020B8, 0x00005463, - 0x000020D9, 0x00005456, 0x000020FA, 0x00005449, - 0x0000211B, 0x0000543C, 0x0000213C, 0x0000542F, - 0x0000215D, 0x00005422, 0x0000217E, 0x00005415, - 0x0000219F, 0x00005408, 0x000021C0, 0x000053FB, - 0x000021E1, 0x000053ED, 0x00002202, 0x000053E0, - 0x00002223, 0x000053D3, 0x00002244, 0x000053C5, - 0x00002265, 0x000053B8, 0x00002286, 0x000053AA, - 0x000022A7, 0x0000539D, 0x000022C7, 0x0000538F, - 0x000022E8, 0x00005381, 0x00002309, 0x00005373, - 0x0000232A, 0x00005366, 0x0000234A, 0x00005358, - 0x0000236B, 0x0000534A, 0x0000238C, 0x0000533C, - 0x000023AD, 0x0000532E, 0x000023CD, 0x00005320, - 0x000023EE, 0x00005312, 0x0000240E, 0x00005304, - 0x0000242F, 0x000052F6, 0x00002450, 0x000052E7, - 0x00002470, 0x000052D9, 0x00002491, 0x000052CB, - 0x000024B1, 0x000052BC, 0x000024D2, 0x000052AE, - 0x000024F2, 0x0000529F, 0x00002513, 0x00005291, - 0x00002533, 0x00005282, 0x00002553, 0x00005274, - 0x00002574, 0x00005265, 0x00002594, 0x00005256, - 0x000025B4, 0x00005248, 0x000025D5, 0x00005239, - 0x000025F5, 0x0000522A, 0x00002615, 0x0000521B, - 0x00002635, 0x0000520C, 0x00002656, 0x000051FD, - 0x00002676, 0x000051EE, 0x00002696, 0x000051DF, - 0x000026B6, 0x000051CF, 0x000026D6, 0x000051C0, - 0x000026F6, 0x000051B1, 0x00002716, 0x000051A2, - 0x00002736, 0x00005192, 0x00002757, 0x00005183, - 0x00002777, 0x00005173, 0x00002796, 0x00005164, - 0x000027B6, 0x00005154, 0x000027D6, 0x00005145, - 0x000027F6, 0x00005135, 0x00002816, 0x00005125, - 0x00002836, 0x00005115, 0x00002856, 0x00005106, - 0x00002876, 0x000050F6, 0x00002895, 0x000050E6, - 0x000028B5, 0x000050D6, 0x000028D5, 0x000050C6, - 0x000028F5, 0x000050B6, 0x00002914, 0x000050A6, - 0x00002934, 0x00005096, 0x00002954, 0x00005085, - 0x00002973, 0x00005075, 0x00002993, 0x00005065, - 0x000029B2, 0x00005054, 0x000029D2, 0x00005044, - 0x000029F1, 0x00005034, 0x00002A11, 0x00005023, - 0x00002A30, 0x00005013, 0x00002A50, 0x00005002, - 0x00002A6F, 0x00004FF1, 0x00002A8F, 0x00004FE1, - 0x00002AAE, 0x00004FD0, 0x00002ACD, 0x00004FBF, - 0x00002AED, 0x00004FAE, 0x00002B0C, 0x00004F9D, - 0x00002B2B, 0x00004F8D, 0x00002B4A, 0x00004F7C, - 0x00002B69, 0x00004F6B, 0x00002B89, 0x00004F59, - 0x00002BA8, 0x00004F48, 0x00002BC7, 0x00004F37, - 0x00002BE6, 0x00004F26, 0x00002C05, 0x00004F15, - 0x00002C24, 0x00004F03, 0x00002C43, 0x00004EF2, - 0x00002C62, 0x00004EE1, 0x00002C81, 0x00004ECF, - 0x00002CA0, 0x00004EBE, 0x00002CBF, 0x00004EAC, - 0x00002CDE, 0x00004E9A, 0x00002CFD, 0x00004E89, - 0x00002D1C, 0x00004E77, 0x00002D3A, 0x00004E65, - 0x00002D59, 0x00004E54, 0x00002D78, 0x00004E42, - 0x00002D97, 0x00004E30, 0x00002DB5, 0x00004E1E, - 0x00002DD4, 0x00004E0C, 0x00002DF3, 0x00004DFA, - 0x00002E11, 0x00004DE8, 0x00002E30, 0x00004DD6, - 0x00002E4E, 0x00004DC4, 0x00002E6D, 0x00004DB1, - 0x00002E8B, 0x00004D9F, 0x00002EAA, 0x00004D8D, - 0x00002EC8, 0x00004D7B, 0x00002EE7, 0x00004D68, - 0x00002F05, 0x00004D56, 0x00002F23, 0x00004D43, - 0x00002F42, 0x00004D31, 0x00002F60, 0x00004D1E, - 0x00002F7E, 0x00004D0B, 0x00002F9D, 0x00004CF9, - 0x00002FBB, 0x00004CE6, 0x00002FD9, 0x00004CD3, - 0x00002FF7, 0x00004CC0, 0x00003015, 0x00004CAE, - 0x00003033, 0x00004C9B, 0x00003051, 0x00004C88, - 0x0000306F, 0x00004C75, 0x0000308D, 0x00004C62, - 0x000030AB, 0x00004C4F, 0x000030C9, 0x00004C3C, - 0x000030E7, 0x00004C28, 0x00003105, 0x00004C15, - 0x00003123, 0x00004C02, 0x00003141, 0x00004BEF, - 0x0000315F, 0x00004BDB, 0x0000317C, 0x00004BC8, - 0x0000319A, 0x00004BB4, 0x000031B8, 0x00004BA1, - 0x000031D6, 0x00004B8D, 0x000031F3, 0x00004B7A, - 0x00003211, 0x00004B66, 0x0000322E, 0x00004B52, - 0x0000324C, 0x00004B3F, 0x0000326A, 0x00004B2B, - 0x00003287, 0x00004B17, 0x000032A5, 0x00004B03, - 0x000032C2, 0x00004AEF, 0x000032DF, 0x00004ADB, - 0x000032FD, 0x00004AC7, 0x0000331A, 0x00004AB3, - 0x00003337, 0x00004A9F, 0x00003355, 0x00004A8B, - 0x00003372, 0x00004A77, 0x0000338F, 0x00004A63, - 0x000033AC, 0x00004A4E, 0x000033CA, 0x00004A3A, - 0x000033E7, 0x00004A26, 0x00003404, 0x00004A11, - 0x00003421, 0x000049FD, 0x0000343E, 0x000049E8, - 0x0000345B, 0x000049D4, 0x00003478, 0x000049BF, - 0x00003495, 0x000049AB, 0x000034B2, 0x00004996, - 0x000034CF, 0x00004981, 0x000034EB, 0x0000496C, - 0x00003508, 0x00004958, 0x00003525, 0x00004943, - 0x00003542, 0x0000492E, 0x0000355F, 0x00004919, - 0x0000357B, 0x00004904, 0x00003598, 0x000048EF, - 0x000035B5, 0x000048DA, 0x000035D1, 0x000048C5, - 0x000035EE, 0x000048B0, 0x0000360A, 0x0000489A, - 0x00003627, 0x00004885, 0x00003643, 0x00004870, - 0x00003660, 0x0000485A, 0x0000367C, 0x00004845, - 0x00003698, 0x00004830, 0x000036B5, 0x0000481A, - 0x000036D1, 0x00004805, 0x000036ED, 0x000047EF, - 0x0000370A, 0x000047DA, 0x00003726, 0x000047C4, - 0x00003742, 0x000047AE, 0x0000375E, 0x00004799, - 0x0000377A, 0x00004783, 0x00003796, 0x0000476D, - 0x000037B2, 0x00004757, 0x000037CE, 0x00004741, - 0x000037EA, 0x0000472B, 0x00003806, 0x00004715, - 0x00003822, 0x000046FF, 0x0000383E, 0x000046E9, - 0x0000385A, 0x000046D3, 0x00003875, 0x000046BD, - 0x00003891, 0x000046A7, 0x000038AD, 0x00004691, - 0x000038C9, 0x0000467A, 0x000038E4, 0x00004664, - 0x00003900, 0x0000464E, 0x0000391C, 0x00004637, - 0x00003937, 0x00004621, 0x00003953, 0x0000460A, - 0x0000396E, 0x000045F4, 0x0000398A, 0x000045DD, - 0x000039A5, 0x000045C7, 0x000039C0, 0x000045B0, - 0x000039DC, 0x00004599, 0x000039F7, 0x00004582, - 0x00003A12, 0x0000456C, 0x00003A2E, 0x00004555, - 0x00003A49, 0x0000453E, 0x00003A64, 0x00004527, - 0x00003A7F, 0x00004510, 0x00003A9A, 0x000044F9, - 0x00003AB5, 0x000044E2, 0x00003AD0, 0x000044CB, - 0x00003AEB, 0x000044B4, 0x00003B06, 0x0000449D, - 0x00003B21, 0x00004485, 0x00003B3C, 0x0000446E, - 0x00003B57, 0x00004457, 0x00003B72, 0x00004440, - 0x00003B8D, 0x00004428, 0x00003BA7, 0x00004411, - 0x00003BC2, 0x000043F9, 0x00003BDD, 0x000043E2, - 0x00003BF7, 0x000043CA, 0x00003C12, 0x000043B3, - 0x00003C2C, 0x0000439B, 0x00003C47, 0x00004384, - 0x00003C62, 0x0000436C, 0x00003C7C, 0x00004354, - 0x00003C96, 0x0000433C, 0x00003CB1, 0x00004325, - 0x00003CCB, 0x0000430D, 0x00003CE5, 0x000042F5, - 0x00003D00, 0x000042DD, 0x00003D1A, 0x000042C5, - 0x00003D34, 0x000042AD, 0x00003D4E, 0x00004295, - 0x00003D68, 0x0000427D, 0x00003D83, 0x00004265, - 0x00003D9D, 0x0000424C, 0x00003DB7, 0x00004234, - 0x00003DD1, 0x0000421C, 0x00003DEB, 0x00004204, - 0x00003E04, 0x000041EB, 0x00003E1E, 0x000041D3, - 0x00003E38, 0x000041BB, 0x00003E52, 0x000041A2, - 0x00003E6C, 0x0000418A, 0x00003E85, 0x00004171, - 0x00003E9F, 0x00004158, 0x00003EB9, 0x00004140, - 0x00003ED2, 0x00004127, 0x00003EEC, 0x0000410F, - 0x00003F05, 0x000040F6, 0x00003F1F, 0x000040DD, - 0x00003F38, 0x000040C4, 0x00003F52, 0x000040AB, - 0x00003F6B, 0x00004092, 0x00003F85, 0x0000407A, - 0x00003F9E, 0x00004061, 0x00003FB7, 0x00004048, - 0x00003FD0, 0x0000402F, 0x00003FE9, 0x00004015, - 0x00004003, 0x00003FFC, 0x0000401C, 0x00003FE3, - 0x00004035, 0x00003FCA, 0x0000404E, 0x00003FB1, - 0x00004067, 0x00003F98, 0x00004080, 0x00003F7E, - 0x00004099, 0x00003F65, 0x000040B2, 0x00003F4B, - 0x000040CA, 0x00003F32, 0x000040E3, 0x00003F19, - 0x000040FC, 0x00003EFF, 0x00004115, 0x00003EE6, - 0x0000412D, 0x00003ECC, 0x00004146, 0x00003EB2, - 0x0000415F, 0x00003E99, 0x00004177, 0x00003E7F, - 0x00004190, 0x00003E65, 0x000041A8, 0x00003E4B, - 0x000041C1, 0x00003E32, 0x000041D9, 0x00003E18, - 0x000041F1, 0x00003DFE, 0x0000420A, 0x00003DE4, - 0x00004222, 0x00003DCA, 0x0000423A, 0x00003DB0, - 0x00004252, 0x00003D96, 0x0000426B, 0x00003D7C, - 0x00004283, 0x00003D62, 0x0000429B, 0x00003D48, - 0x000042B3, 0x00003D2E, 0x000042CB, 0x00003D13, - 0x000042E3, 0x00003CF9, 0x000042FB, 0x00003CDF, - 0x00004313, 0x00003CC5, 0x0000432B, 0x00003CAA, - 0x00004342, 0x00003C90, 0x0000435A, 0x00003C75, - 0x00004372, 0x00003C5B, 0x00004389, 0x00003C40, - 0x000043A1, 0x00003C26, 0x000043B9, 0x00003C0B, - 0x000043D0, 0x00003BF1, 0x000043E8, 0x00003BD6, - 0x000043FF, 0x00003BBB, 0x00004417, 0x00003BA1, - 0x0000442E, 0x00003B86, 0x00004445, 0x00003B6B, - 0x0000445D, 0x00003B50, 0x00004474, 0x00003B35, - 0x0000448B, 0x00003B1A, 0x000044A2, 0x00003B00, - 0x000044BA, 0x00003AE5, 0x000044D1, 0x00003ACA, - 0x000044E8, 0x00003AAF, 0x000044FF, 0x00003A93, - 0x00004516, 0x00003A78, 0x0000452D, 0x00003A5D, - 0x00004544, 0x00003A42, 0x0000455B, 0x00003A27, - 0x00004571, 0x00003A0C, 0x00004588, 0x000039F0, - 0x0000459F, 0x000039D5, 0x000045B6, 0x000039BA, - 0x000045CC, 0x0000399E, 0x000045E3, 0x00003983, - 0x000045F9, 0x00003967, 0x00004610, 0x0000394C, - 0x00004626, 0x00003930, 0x0000463D, 0x00003915, - 0x00004653, 0x000038F9, 0x0000466A, 0x000038DD, - 0x00004680, 0x000038C2, 0x00004696, 0x000038A6, - 0x000046AC, 0x0000388A, 0x000046C3, 0x0000386F, - 0x000046D9, 0x00003853, 0x000046EF, 0x00003837, - 0x00004705, 0x0000381B, 0x0000471B, 0x000037FF, - 0x00004731, 0x000037E3, 0x00004747, 0x000037C7, - 0x0000475D, 0x000037AB, 0x00004772, 0x0000378F, - 0x00004788, 0x00003773, 0x0000479E, 0x00003757, - 0x000047B4, 0x0000373B, 0x000047C9, 0x0000371F, - 0x000047DF, 0x00003702, 0x000047F5, 0x000036E6, - 0x0000480A, 0x000036CA, 0x00004820, 0x000036AE, - 0x00004835, 0x00003691, 0x0000484A, 0x00003675, - 0x00004860, 0x00003659, 0x00004875, 0x0000363C, - 0x0000488A, 0x00003620, 0x000048A0, 0x00003603, - 0x000048B5, 0x000035E7, 0x000048CA, 0x000035CA, - 0x000048DF, 0x000035AD, 0x000048F4, 0x00003591, - 0x00004909, 0x00003574, 0x0000491E, 0x00003557, - 0x00004933, 0x0000353B, 0x00004948, 0x0000351E, - 0x0000495D, 0x00003501, 0x00004972, 0x000034E4, - 0x00004986, 0x000034C7, 0x0000499B, 0x000034AB, - 0x000049B0, 0x0000348E, 0x000049C4, 0x00003471, - 0x000049D9, 0x00003454, 0x000049ED, 0x00003437, - 0x00004A02, 0x0000341A, 0x00004A16, 0x000033FD, - 0x00004A2B, 0x000033DF, 0x00004A3F, 0x000033C2, - 0x00004A53, 0x000033A5, 0x00004A68, 0x00003388, - 0x00004A7C, 0x0000336B, 0x00004A90, 0x0000334D, - 0x00004AA4, 0x00003330, 0x00004AB8, 0x00003313, - 0x00004ACC, 0x000032F5, 0x00004AE0, 0x000032D8, - 0x00004AF4, 0x000032BB, 0x00004B08, 0x0000329D, - 0x00004B1C, 0x00003280, 0x00004B30, 0x00003262, - 0x00004B44, 0x00003245, 0x00004B57, 0x00003227, - 0x00004B6B, 0x00003209, 0x00004B7F, 0x000031EC, - 0x00004B92, 0x000031CE, 0x00004BA6, 0x000031B0, - 0x00004BB9, 0x00003193, 0x00004BCD, 0x00003175, - 0x00004BE0, 0x00003157, 0x00004BF3, 0x00003139, - 0x00004C07, 0x0000311C, 0x00004C1A, 0x000030FE, - 0x00004C2D, 0x000030E0, 0x00004C40, 0x000030C2, - 0x00004C53, 0x000030A4, 0x00004C67, 0x00003086, - 0x00004C7A, 0x00003068, 0x00004C8D, 0x0000304A, - 0x00004C9F, 0x0000302C, 0x00004CB2, 0x0000300E, - 0x00004CC5, 0x00002FF0, 0x00004CD8, 0x00002FD1, - 0x00004CEB, 0x00002FB3, 0x00004CFD, 0x00002F95, - 0x00004D10, 0x00002F77, 0x00004D23, 0x00002F58, - 0x00004D35, 0x00002F3A, 0x00004D48, 0x00002F1C, - 0x00004D5A, 0x00002EFD, 0x00004D6D, 0x00002EDF, - 0x00004D7F, 0x00002EC1, 0x00004D91, 0x00002EA2, - 0x00004DA4, 0x00002E84, 0x00004DB6, 0x00002E65, - 0x00004DC8, 0x00002E47, 0x00004DDA, 0x00002E28, - 0x00004DEC, 0x00002E0A, 0x00004DFF, 0x00002DEB, - 0x00004E11, 0x00002DCC, 0x00004E22, 0x00002DAE, - 0x00004E34, 0x00002D8F, 0x00004E46, 0x00002D70, - 0x00004E58, 0x00002D51, 0x00004E6A, 0x00002D33, - 0x00004E7C, 0x00002D14, 0x00004E8D, 0x00002CF5, - 0x00004E9F, 0x00002CD6, 0x00004EB0, 0x00002CB7, - 0x00004EC2, 0x00002C98, 0x00004ED4, 0x00002C79, - 0x00004EE5, 0x00002C5A, 0x00004EF6, 0x00002C3B, - 0x00004F08, 0x00002C1C, 0x00004F19, 0x00002BFD, - 0x00004F2A, 0x00002BDE, 0x00004F3B, 0x00002BBF, - 0x00004F4D, 0x00002BA0, 0x00004F5E, 0x00002B81, - 0x00004F6F, 0x00002B62, 0x00004F80, 0x00002B42, - 0x00004F91, 0x00002B23, 0x00004FA2, 0x00002B04, - 0x00004FB3, 0x00002AE5, 0x00004FC3, 0x00002AC5, - 0x00004FD4, 0x00002AA6, 0x00004FE5, 0x00002A87, - 0x00004FF6, 0x00002A67, 0x00005006, 0x00002A48, - 0x00005017, 0x00002A28, 0x00005027, 0x00002A09, - 0x00005038, 0x000029EA, 0x00005048, 0x000029CA, - 0x00005059, 0x000029AA, 0x00005069, 0x0000298B, - 0x00005079, 0x0000296B, 0x00005089, 0x0000294C, - 0x0000509A, 0x0000292C, 0x000050AA, 0x0000290C, - 0x000050BA, 0x000028ED, 0x000050CA, 0x000028CD, - 0x000050DA, 0x000028AD, 0x000050EA, 0x0000288D, - 0x000050FA, 0x0000286E, 0x0000510A, 0x0000284E, - 0x00005119, 0x0000282E, 0x00005129, 0x0000280E, - 0x00005139, 0x000027EE, 0x00005149, 0x000027CE, - 0x00005158, 0x000027AE, 0x00005168, 0x0000278E, - 0x00005177, 0x0000276F, 0x00005187, 0x0000274F, - 0x00005196, 0x0000272E, 0x000051A5, 0x0000270E, - 0x000051B5, 0x000026EE, 0x000051C4, 0x000026CE, - 0x000051D3, 0x000026AE, 0x000051E2, 0x0000268E, - 0x000051F2, 0x0000266E, 0x00005201, 0x0000264E, - 0x00005210, 0x0000262D, 0x0000521F, 0x0000260D, - 0x0000522E, 0x000025ED, 0x0000523C, 0x000025CD, - 0x0000524B, 0x000025AC, 0x0000525A, 0x0000258C, - 0x00005269, 0x0000256C, 0x00005277, 0x0000254B, - 0x00005286, 0x0000252B, 0x00005295, 0x0000250A, - 0x000052A3, 0x000024EA, 0x000052B2, 0x000024CA, - 0x000052C0, 0x000024A9, 0x000052CE, 0x00002489, - 0x000052DD, 0x00002468, 0x000052EB, 0x00002447, - 0x000052F9, 0x00002427, 0x00005307, 0x00002406, - 0x00005315, 0x000023E6, 0x00005324, 0x000023C5, - 0x00005332, 0x000023A4, 0x00005340, 0x00002384, - 0x0000534D, 0x00002363, 0x0000535B, 0x00002342, - 0x00005369, 0x00002322, 0x00005377, 0x00002301, - 0x00005385, 0x000022E0, 0x00005392, 0x000022BF, - 0x000053A0, 0x0000229E, 0x000053AD, 0x0000227E, - 0x000053BB, 0x0000225D, 0x000053C8, 0x0000223C, - 0x000053D6, 0x0000221B, 0x000053E3, 0x000021FA, - 0x000053F1, 0x000021D9, 0x000053FE, 0x000021B8, - 0x0000540B, 0x00002197, 0x00005418, 0x00002176, - 0x00005425, 0x00002155, 0x00005432, 0x00002134, - 0x0000543F, 0x00002113, 0x0000544C, 0x000020F2, - 0x00005459, 0x000020D1, 0x00005466, 0x000020AF, - 0x00005473, 0x0000208E, 0x00005480, 0x0000206D, - 0x0000548C, 0x0000204C, 0x00005499, 0x0000202B, - 0x000054A6, 0x00002009, 0x000054B2, 0x00001FE8, - 0x000054BF, 0x00001FC7, 0x000054CB, 0x00001FA6, - 0x000054D8, 0x00001F84, 0x000054E4, 0x00001F63, - 0x000054F0, 0x00001F42, 0x000054FD, 0x00001F20, - 0x00005509, 0x00001EFF, 0x00005515, 0x00001EDE, - 0x00005521, 0x00001EBC, 0x0000552D, 0x00001E9B, - 0x00005539, 0x00001E79, 0x00005545, 0x00001E58, - 0x00005551, 0x00001E36, 0x0000555D, 0x00001E15, - 0x00005568, 0x00001DF3, 0x00005574, 0x00001DD2, - 0x00005580, 0x00001DB0, 0x0000558C, 0x00001D8E, - 0x00005597, 0x00001D6D, 0x000055A3, 0x00001D4B, - 0x000055AE, 0x00001D2A, 0x000055BA, 0x00001D08, - 0x000055C5, 0x00001CE6, 0x000055D0, 0x00001CC5, - 0x000055DC, 0x00001CA3, 0x000055E7, 0x00001C81, - 0x000055F2, 0x00001C5F, 0x000055FD, 0x00001C3E, - 0x00005608, 0x00001C1C, 0x00005613, 0x00001BFA, - 0x0000561E, 0x00001BD8, 0x00005629, 0x00001BB6, - 0x00005634, 0x00001B95, 0x0000563F, 0x00001B73, - 0x00005649, 0x00001B51, 0x00005654, 0x00001B2F, - 0x0000565F, 0x00001B0D, 0x00005669, 0x00001AEB, - 0x00005674, 0x00001AC9, 0x0000567E, 0x00001AA7, - 0x00005689, 0x00001A85, 0x00005693, 0x00001A63, - 0x0000569E, 0x00001A41, 0x000056A8, 0x00001A1F, - 0x000056B2, 0x000019FD, 0x000056BC, 0x000019DB, - 0x000056C6, 0x000019B9, 0x000056D0, 0x00001997, - 0x000056DA, 0x00001975, 0x000056E4, 0x00001953, - 0x000056EE, 0x00001931, 0x000056F8, 0x0000190F, - 0x00005702, 0x000018EC, 0x0000570C, 0x000018CA, - 0x00005716, 0x000018A8, 0x0000571F, 0x00001886, - 0x00005729, 0x00001864, 0x00005732, 0x00001841, - 0x0000573C, 0x0000181F, 0x00005745, 0x000017FD, - 0x0000574F, 0x000017DB, 0x00005758, 0x000017B8, - 0x00005761, 0x00001796, 0x0000576B, 0x00001774, - 0x00005774, 0x00001751, 0x0000577D, 0x0000172F, - 0x00005786, 0x0000170D, 0x0000578F, 0x000016EA, - 0x00005798, 0x000016C8, 0x000057A1, 0x000016A5, - 0x000057AA, 0x00001683, 0x000057B3, 0x00001661, - 0x000057BB, 0x0000163E, 0x000057C4, 0x0000161C, - 0x000057CD, 0x000015F9, 0x000057D5, 0x000015D7, - 0x000057DE, 0x000015B4, 0x000057E6, 0x00001592, - 0x000057EF, 0x0000156F, 0x000057F7, 0x0000154D, - 0x000057FF, 0x0000152A, 0x00005808, 0x00001507, - 0x00005810, 0x000014E5, 0x00005818, 0x000014C2, - 0x00005820, 0x000014A0, 0x00005828, 0x0000147D, - 0x00005830, 0x0000145A, 0x00005838, 0x00001438, - 0x00005840, 0x00001415, 0x00005848, 0x000013F3, - 0x00005850, 0x000013D0, 0x00005858, 0x000013AD, - 0x0000585F, 0x0000138A, 0x00005867, 0x00001368, - 0x0000586F, 0x00001345, 0x00005876, 0x00001322, - 0x0000587E, 0x00001300, 0x00005885, 0x000012DD, - 0x0000588C, 0x000012BA, 0x00005894, 0x00001297, - 0x0000589B, 0x00001274, 0x000058A2, 0x00001252, - 0x000058A9, 0x0000122F, 0x000058B1, 0x0000120C, - 0x000058B8, 0x000011E9, 0x000058BF, 0x000011C6, - 0x000058C6, 0x000011A3, 0x000058CD, 0x00001181, - 0x000058D3, 0x0000115E, 0x000058DA, 0x0000113B, - 0x000058E1, 0x00001118, 0x000058E8, 0x000010F5, - 0x000058EE, 0x000010D2, 0x000058F5, 0x000010AF, - 0x000058FB, 0x0000108C, 0x00005902, 0x00001069, - 0x00005908, 0x00001046, 0x0000590F, 0x00001023, - 0x00005915, 0x00001000, 0x0000591B, 0x00000FDD, - 0x00005921, 0x00000FBA, 0x00005928, 0x00000F97, - 0x0000592E, 0x00000F74, 0x00005934, 0x00000F51, - 0x0000593A, 0x00000F2E, 0x00005940, 0x00000F0B, - 0x00005945, 0x00000EE8, 0x0000594B, 0x00000EC5, - 0x00005951, 0x00000EA2, 0x00005957, 0x00000E7F, - 0x0000595C, 0x00000E5C, 0x00005962, 0x00000E39, - 0x00005968, 0x00000E16, 0x0000596D, 0x00000DF3, - 0x00005973, 0x00000DCF, 0x00005978, 0x00000DAC, - 0x0000597D, 0x00000D89, 0x00005983, 0x00000D66, - 0x00005988, 0x00000D43, 0x0000598D, 0x00000D20, - 0x00005992, 0x00000CFD, 0x00005997, 0x00000CD9, - 0x0000599C, 0x00000CB6, 0x000059A1, 0x00000C93, - 0x000059A6, 0x00000C70, 0x000059AB, 0x00000C4D, - 0x000059B0, 0x00000C29, 0x000059B5, 0x00000C06, - 0x000059B9, 0x00000BE3, 0x000059BE, 0x00000BC0, - 0x000059C2, 0x00000B9C, 0x000059C7, 0x00000B79, - 0x000059CB, 0x00000B56, 0x000059D0, 0x00000B33, - 0x000059D4, 0x00000B0F, 0x000059D9, 0x00000AEC, - 0x000059DD, 0x00000AC9, 0x000059E1, 0x00000AA6, - 0x000059E5, 0x00000A82, 0x000059E9, 0x00000A5F, - 0x000059ED, 0x00000A3C, 0x000059F1, 0x00000A18, - 0x000059F5, 0x000009F5, 0x000059F9, 0x000009D2, - 0x000059FD, 0x000009AE, 0x00005A01, 0x0000098B, - 0x00005A04, 0x00000968, 0x00005A08, 0x00000944, - 0x00005A0C, 0x00000921, 0x00005A0F, 0x000008FE, - 0x00005A13, 0x000008DA, 0x00005A16, 0x000008B7, - 0x00005A1A, 0x00000893, 0x00005A1D, 0x00000870, - 0x00005A20, 0x0000084D, 0x00005A24, 0x00000829, - 0x00005A27, 0x00000806, 0x00005A2A, 0x000007E2, - 0x00005A2D, 0x000007BF, 0x00005A30, 0x0000079C, - 0x00005A33, 0x00000778, 0x00005A36, 0x00000755, - 0x00005A39, 0x00000731, 0x00005A3B, 0x0000070E, - 0x00005A3E, 0x000006EA, 0x00005A41, 0x000006C7, - 0x00005A44, 0x000006A4, 0x00005A46, 0x00000680, - 0x00005A49, 0x0000065D, 0x00005A4B, 0x00000639, - 0x00005A4E, 0x00000616, 0x00005A50, 0x000005F2, - 0x00005A52, 0x000005CF, 0x00005A54, 0x000005AB, - 0x00005A57, 0x00000588, 0x00005A59, 0x00000564, - 0x00005A5B, 0x00000541, 0x00005A5D, 0x0000051D, - 0x00005A5F, 0x000004FA, 0x00005A61, 0x000004D6, - 0x00005A63, 0x000004B3, 0x00005A65, 0x0000048F, - 0x00005A66, 0x0000046C, 0x00005A68, 0x00000448, - 0x00005A6A, 0x00000425, 0x00005A6B, 0x00000401, - 0x00005A6D, 0x000003DE, 0x00005A6E, 0x000003BA, - 0x00005A70, 0x00000397, 0x00005A71, 0x00000373, - 0x00005A72, 0x00000350, 0x00005A74, 0x0000032C, - 0x00005A75, 0x00000309, 0x00005A76, 0x000002E5, - 0x00005A77, 0x000002C2, 0x00005A78, 0x0000029E, - 0x00005A79, 0x0000027B, 0x00005A7A, 0x00000257, - 0x00005A7B, 0x00000234, 0x00005A7C, 0x00000210, - 0x00005A7D, 0x000001ED, 0x00005A7D, 0x000001C9, - 0x00005A7E, 0x000001A6, 0x00005A7F, 0x00000182, - 0x00005A7F, 0x0000015E, 0x00005A80, 0x0000013B, - 0x00005A80, 0x00000117, 0x00005A81, 0x000000F4, - 0x00005A81, 0x000000D0, 0x00005A81, 0x000000AD, - 0x00005A82, 0x00000089, 0x00005A82, 0x00000066, - 0x00005A82, 0x00000042, 0x00005A82, 0x0000001F, - 0x00000001, 0x00004000, 0x0000000E, 0x00003FFF, - 0x0000001A, 0x00003FFF, 0x00000027, 0x00003FFF, - 0x00000033, 0x00003FFF, 0x00000040, 0x00003FFF, - 0x0000004C, 0x00003FFF, 0x00000059, 0x00003FFF, - 0x00000066, 0x00003FFF, 0x00000072, 0x00003FFF, - 0x0000007F, 0x00003FFF, 0x0000008B, 0x00003FFF, - 0x00000098, 0x00003FFF, 0x000000A4, 0x00003FFF, - 0x000000B1, 0x00003FFF, 0x000000BE, 0x00003FFE, - 0x000000CA, 0x00003FFE, 0x000000D7, 0x00003FFE, - 0x000000E3, 0x00003FFE, 0x000000F0, 0x00003FFE, - 0x000000FC, 0x00003FFE, 0x00000109, 0x00003FFD, - 0x00000116, 0x00003FFD, 0x00000122, 0x00003FFD, - 0x0000012F, 0x00003FFD, 0x0000013B, 0x00003FFC, - 0x00000148, 0x00003FFC, 0x00000154, 0x00003FFC, - 0x00000161, 0x00003FFC, 0x0000016D, 0x00003FFB, - 0x0000017A, 0x00003FFB, 0x00000187, 0x00003FFB, - 0x00000193, 0x00003FFB, 0x000001A0, 0x00003FFA, - 0x000001AC, 0x00003FFA, 0x000001B9, 0x00003FFA, - 0x000001C5, 0x00003FF9, 0x000001D2, 0x00003FF9, - 0x000001DF, 0x00003FF8, 0x000001EB, 0x00003FF8, - 0x000001F8, 0x00003FF8, 0x00000204, 0x00003FF7, - 0x00000211, 0x00003FF7, 0x0000021D, 0x00003FF7, - 0x0000022A, 0x00003FF6, 0x00000236, 0x00003FF6, - 0x00000243, 0x00003FF5, 0x00000250, 0x00003FF5, - 0x0000025C, 0x00003FF4, 0x00000269, 0x00003FF4, - 0x00000275, 0x00003FF3, 0x00000282, 0x00003FF3, - 0x0000028E, 0x00003FF2, 0x0000029B, 0x00003FF2, - 0x000002A7, 0x00003FF1, 0x000002B4, 0x00003FF1, - 0x000002C1, 0x00003FF0, 0x000002CD, 0x00003FF0, - 0x000002DA, 0x00003FEF, 0x000002E6, 0x00003FEF, - 0x000002F3, 0x00003FEE, 0x000002FF, 0x00003FED, - 0x0000030C, 0x00003FED, 0x00000318, 0x00003FEC, - 0x00000325, 0x00003FEC, 0x00000332, 0x00003FEB, - 0x0000033E, 0x00003FEA, 0x0000034B, 0x00003FEA, - 0x00000357, 0x00003FE9, 0x00000364, 0x00003FE8, - 0x00000370, 0x00003FE8, 0x0000037D, 0x00003FE7, - 0x00000389, 0x00003FE6, 0x00000396, 0x00003FE6, - 0x000003A2, 0x00003FE5, 0x000003AF, 0x00003FE4, - 0x000003BC, 0x00003FE4, 0x000003C8, 0x00003FE3, - 0x000003D5, 0x00003FE2, 0x000003E1, 0x00003FE1, - 0x000003EE, 0x00003FE1, 0x000003FA, 0x00003FE0, - 0x00000407, 0x00003FDF, 0x00000413, 0x00003FDE, - 0x00000420, 0x00003FDD, 0x0000042C, 0x00003FDD, - 0x00000439, 0x00003FDC, 0x00000446, 0x00003FDB, - 0x00000452, 0x00003FDA, 0x0000045F, 0x00003FD9, - 0x0000046B, 0x00003FD8, 0x00000478, 0x00003FD7, - 0x00000484, 0x00003FD7, 0x00000491, 0x00003FD6, - 0x0000049D, 0x00003FD5, 0x000004AA, 0x00003FD4, - 0x000004B6, 0x00003FD3, 0x000004C3, 0x00003FD2, - 0x000004CF, 0x00003FD1, 0x000004DC, 0x00003FD0, - 0x000004E8, 0x00003FCF, 0x000004F5, 0x00003FCE, - 0x00000502, 0x00003FCD, 0x0000050E, 0x00003FCC, - 0x0000051B, 0x00003FCB, 0x00000527, 0x00003FCA, - 0x00000534, 0x00003FC9, 0x00000540, 0x00003FC8, - 0x0000054D, 0x00003FC7, 0x00000559, 0x00003FC6, - 0x00000566, 0x00003FC5, 0x00000572, 0x00003FC4, - 0x0000057F, 0x00003FC3, 0x0000058B, 0x00003FC2, - 0x00000598, 0x00003FC1, 0x000005A4, 0x00003FC0, - 0x000005B1, 0x00003FBF, 0x000005BD, 0x00003FBD, - 0x000005CA, 0x00003FBC, 0x000005D6, 0x00003FBB, - 0x000005E3, 0x00003FBA, 0x000005EF, 0x00003FB9, - 0x000005FC, 0x00003FB8, 0x00000608, 0x00003FB6, - 0x00000615, 0x00003FB5, 0x00000621, 0x00003FB4, - 0x0000062E, 0x00003FB3, 0x0000063A, 0x00003FB2, - 0x00000647, 0x00003FB0, 0x00000653, 0x00003FAF, - 0x00000660, 0x00003FAE, 0x0000066C, 0x00003FAD, - 0x00000679, 0x00003FAB, 0x00000685, 0x00003FAA, - 0x00000692, 0x00003FA9, 0x0000069E, 0x00003FA8, - 0x000006AB, 0x00003FA6, 0x000006B7, 0x00003FA5, - 0x000006C4, 0x00003FA4, 0x000006D0, 0x00003FA2, - 0x000006DD, 0x00003FA1, 0x000006E9, 0x00003FA0, - 0x000006F6, 0x00003F9E, 0x00000702, 0x00003F9D, - 0x0000070F, 0x00003F9B, 0x0000071B, 0x00003F9A, - 0x00000728, 0x00003F99, 0x00000734, 0x00003F97, - 0x00000741, 0x00003F96, 0x0000074D, 0x00003F94, - 0x0000075A, 0x00003F93, 0x00000766, 0x00003F92, - 0x00000773, 0x00003F90, 0x0000077F, 0x00003F8F, - 0x0000078C, 0x00003F8D, 0x00000798, 0x00003F8C, - 0x000007A5, 0x00003F8A, 0x000007B1, 0x00003F89, - 0x000007BE, 0x00003F87, 0x000007CA, 0x00003F86, - 0x000007D7, 0x00003F84, 0x000007E3, 0x00003F83, - 0x000007F0, 0x00003F81, 0x000007FC, 0x00003F7F, - 0x00000809, 0x00003F7E, 0x00000815, 0x00003F7C, - 0x00000821, 0x00003F7B, 0x0000082E, 0x00003F79, - 0x0000083A, 0x00003F77, 0x00000847, 0x00003F76, - 0x00000853, 0x00003F74, 0x00000860, 0x00003F73, - 0x0000086C, 0x00003F71, 0x00000879, 0x00003F6F, - 0x00000885, 0x00003F6E, 0x00000892, 0x00003F6C, - 0x0000089E, 0x00003F6A, 0x000008AA, 0x00003F69, - 0x000008B7, 0x00003F67, 0x000008C3, 0x00003F65, - 0x000008D0, 0x00003F63, 0x000008DC, 0x00003F62, - 0x000008E9, 0x00003F60, 0x000008F5, 0x00003F5E, - 0x00000902, 0x00003F5C, 0x0000090E, 0x00003F5B, - 0x0000091A, 0x00003F59, 0x00000927, 0x00003F57, - 0x00000933, 0x00003F55, 0x00000940, 0x00003F53, - 0x0000094C, 0x00003F52, 0x00000959, 0x00003F50, - 0x00000965, 0x00003F4E, 0x00000972, 0x00003F4C, - 0x0000097E, 0x00003F4A, 0x0000098A, 0x00003F48, - 0x00000997, 0x00003F46, 0x000009A3, 0x00003F45, - 0x000009B0, 0x00003F43, 0x000009BC, 0x00003F41, - 0x000009C8, 0x00003F3F, 0x000009D5, 0x00003F3D, - 0x000009E1, 0x00003F3B, 0x000009EE, 0x00003F39, - 0x000009FA, 0x00003F37, 0x00000A07, 0x00003F35, - 0x00000A13, 0x00003F33, 0x00000A1F, 0x00003F31, - 0x00000A2C, 0x00003F2F, 0x00000A38, 0x00003F2D, - 0x00000A45, 0x00003F2B, 0x00000A51, 0x00003F29, - 0x00000A5D, 0x00003F27, 0x00000A6A, 0x00003F25, - 0x00000A76, 0x00003F23, 0x00000A83, 0x00003F21, - 0x00000A8F, 0x00003F1F, 0x00000A9B, 0x00003F1D, - 0x00000AA8, 0x00003F1B, 0x00000AB4, 0x00003F19, - 0x00000AC1, 0x00003F17, 0x00000ACD, 0x00003F14, - 0x00000AD9, 0x00003F12, 0x00000AE6, 0x00003F10, - 0x00000AF2, 0x00003F0E, 0x00000AFE, 0x00003F0C, - 0x00000B0B, 0x00003F0A, 0x00000B17, 0x00003F08, - 0x00000B24, 0x00003F05, 0x00000B30, 0x00003F03, - 0x00000B3C, 0x00003F01, 0x00000B49, 0x00003EFF, - 0x00000B55, 0x00003EFD, 0x00000B61, 0x00003EFA, - 0x00000B6E, 0x00003EF8, 0x00000B7A, 0x00003EF6, - 0x00000B87, 0x00003EF4, 0x00000B93, 0x00003EF1, - 0x00000B9F, 0x00003EEF, 0x00000BAC, 0x00003EED, - 0x00000BB8, 0x00003EEA, 0x00000BC4, 0x00003EE8, - 0x00000BD1, 0x00003EE6, 0x00000BDD, 0x00003EE3, - 0x00000BE9, 0x00003EE1, 0x00000BF6, 0x00003EDF, - 0x00000C02, 0x00003EDC, 0x00000C0E, 0x00003EDA, - 0x00000C1B, 0x00003ED8, 0x00000C27, 0x00003ED5, - 0x00000C33, 0x00003ED3, 0x00000C40, 0x00003ED1, - 0x00000C4C, 0x00003ECE, 0x00000C58, 0x00003ECC, - 0x00000C65, 0x00003EC9, 0x00000C71, 0x00003EC7, - 0x00000C7D, 0x00003EC4, 0x00000C8A, 0x00003EC2, - 0x00000C96, 0x00003EBF, 0x00000CA2, 0x00003EBD, - 0x00000CAF, 0x00003EBA, 0x00000CBB, 0x00003EB8, - 0x00000CC7, 0x00003EB5, 0x00000CD4, 0x00003EB3, - 0x00000CE0, 0x00003EB0, 0x00000CEC, 0x00003EAE, - 0x00000CF9, 0x00003EAB, 0x00000D05, 0x00003EA9, - 0x00000D11, 0x00003EA6, 0x00000D1D, 0x00003EA4, - 0x00000D2A, 0x00003EA1, 0x00000D36, 0x00003E9F, - 0x00000D42, 0x00003E9C, 0x00000D4F, 0x00003E99, - 0x00000D5B, 0x00003E97, 0x00000D67, 0x00003E94, - 0x00000D74, 0x00003E91, 0x00000D80, 0x00003E8F, - 0x00000D8C, 0x00003E8C, 0x00000D98, 0x00003E89, - 0x00000DA5, 0x00003E87, 0x00000DB1, 0x00003E84, - 0x00000DBD, 0x00003E81, 0x00000DC9, 0x00003E7F, - 0x00000DD6, 0x00003E7C, 0x00000DE2, 0x00003E79, - 0x00000DEE, 0x00003E77, 0x00000DFB, 0x00003E74, - 0x00000E07, 0x00003E71, 0x00000E13, 0x00003E6E, - 0x00000E1F, 0x00003E6C, 0x00000E2C, 0x00003E69, - 0x00000E38, 0x00003E66, 0x00000E44, 0x00003E63, - 0x00000E50, 0x00003E60, 0x00000E5D, 0x00003E5E, - 0x00000E69, 0x00003E5B, 0x00000E75, 0x00003E58, - 0x00000E81, 0x00003E55, 0x00000E8E, 0x00003E52, - 0x00000E9A, 0x00003E4F, 0x00000EA6, 0x00003E4C, - 0x00000EB2, 0x00003E4A, 0x00000EBE, 0x00003E47, - 0x00000ECB, 0x00003E44, 0x00000ED7, 0x00003E41, - 0x00000EE3, 0x00003E3E, 0x00000EEF, 0x00003E3B, - 0x00000EFC, 0x00003E38, 0x00000F08, 0x00003E35, - 0x00000F14, 0x00003E32, 0x00000F20, 0x00003E2F, - 0x00000F2C, 0x00003E2C, 0x00000F39, 0x00003E29, - 0x00000F45, 0x00003E26, 0x00000F51, 0x00003E23, - 0x00000F5D, 0x00003E20, 0x00000F69, 0x00003E1D, - 0x00000F76, 0x00003E1A, 0x00000F82, 0x00003E17, - 0x00000F8E, 0x00003E14, 0x00000F9A, 0x00003E11, - 0x00000FA6, 0x00003E0E, 0x00000FB3, 0x00003E0B, - 0x00000FBF, 0x00003E08, 0x00000FCB, 0x00003E05, - 0x00000FD7, 0x00003E02, 0x00000FE3, 0x00003DFF, - 0x00000FEF, 0x00003DFB, 0x00000FFC, 0x00003DF8, - 0x00001008, 0x00003DF5, 0x00001014, 0x00003DF2, - 0x00001020, 0x00003DEF, 0x0000102C, 0x00003DEC, - 0x00001038, 0x00003DE8, 0x00001045, 0x00003DE5, - 0x00001051, 0x00003DE2, 0x0000105D, 0x00003DDF, - 0x00001069, 0x00003DDC, 0x00001075, 0x00003DD8, - 0x00001081, 0x00003DD5, 0x0000108D, 0x00003DD2, - 0x0000109A, 0x00003DCF, 0x000010A6, 0x00003DCB, - 0x000010B2, 0x00003DC8, 0x000010BE, 0x00003DC5, - 0x000010CA, 0x00003DC2, 0x000010D6, 0x00003DBE, - 0x000010E2, 0x00003DBB, 0x000010EE, 0x00003DB8, - 0x000010FB, 0x00003DB4, 0x00001107, 0x00003DB1, - 0x00001113, 0x00003DAE, 0x0000111F, 0x00003DAA, - 0x0000112B, 0x00003DA7, 0x00001137, 0x00003DA3, - 0x00001143, 0x00003DA0, 0x0000114F, 0x00003D9D, - 0x0000115B, 0x00003D99, 0x00001168, 0x00003D96, - 0x00001174, 0x00003D92, 0x00001180, 0x00003D8F, - 0x0000118C, 0x00003D8C, 0x00001198, 0x00003D88, - 0x000011A4, 0x00003D85, 0x000011B0, 0x00003D81, - 0x000011BC, 0x00003D7E, 0x000011C8, 0x00003D7A, - 0x000011D4, 0x00003D77, 0x000011E0, 0x00003D73, - 0x000011EC, 0x00003D70, 0x000011F8, 0x00003D6C, - 0x00001205, 0x00003D69, 0x00001211, 0x00003D65, - 0x0000121D, 0x00003D62, 0x00001229, 0x00003D5E, - 0x00001235, 0x00003D5A, 0x00001241, 0x00003D57, - 0x0000124D, 0x00003D53, 0x00001259, 0x00003D50, - 0x00001265, 0x00003D4C, 0x00001271, 0x00003D48, - 0x0000127D, 0x00003D45, 0x00001289, 0x00003D41, - 0x00001295, 0x00003D3E, 0x000012A1, 0x00003D3A, - 0x000012AD, 0x00003D36, 0x000012B9, 0x00003D33, - 0x000012C5, 0x00003D2F, 0x000012D1, 0x00003D2B, - 0x000012DD, 0x00003D27, 0x000012E9, 0x00003D24, - 0x000012F5, 0x00003D20, 0x00001301, 0x00003D1C, - 0x0000130D, 0x00003D19, 0x00001319, 0x00003D15, - 0x00001325, 0x00003D11, 0x00001331, 0x00003D0D, - 0x0000133D, 0x00003D0A, 0x00001349, 0x00003D06, - 0x00001355, 0x00003D02, 0x00001361, 0x00003CFE, - 0x0000136D, 0x00003CFA, 0x00001379, 0x00003CF7, - 0x00001385, 0x00003CF3, 0x00001391, 0x00003CEF, - 0x0000139D, 0x00003CEB, 0x000013A9, 0x00003CE7, - 0x000013B5, 0x00003CE3, 0x000013C1, 0x00003CDF, - 0x000013CD, 0x00003CDC, 0x000013D9, 0x00003CD8, - 0x000013E5, 0x00003CD4, 0x000013F1, 0x00003CD0, - 0x000013FC, 0x00003CCC, 0x00001408, 0x00003CC8, - 0x00001414, 0x00003CC4, 0x00001420, 0x00003CC0, - 0x0000142C, 0x00003CBC, 0x00001438, 0x00003CB8, - 0x00001444, 0x00003CB4, 0x00001450, 0x00003CB0, - 0x0000145C, 0x00003CAC, 0x00001468, 0x00003CA8, - 0x00001474, 0x00003CA4, 0x00001480, 0x00003CA0, - 0x0000148C, 0x00003C9C, 0x00001497, 0x00003C98, - 0x000014A3, 0x00003C94, 0x000014AF, 0x00003C90, - 0x000014BB, 0x00003C8C, 0x000014C7, 0x00003C88, - 0x000014D3, 0x00003C84, 0x000014DF, 0x00003C80, - 0x000014EB, 0x00003C7C, 0x000014F7, 0x00003C78, - 0x00001502, 0x00003C73, 0x0000150E, 0x00003C6F, - 0x0000151A, 0x00003C6B, 0x00001526, 0x00003C67, - 0x00001532, 0x00003C63, 0x0000153E, 0x00003C5F, - 0x0000154A, 0x00003C5A, 0x00001555, 0x00003C56, - 0x00001561, 0x00003C52, 0x0000156D, 0x00003C4E, - 0x00001579, 0x00003C4A, 0x00001585, 0x00003C45, - 0x00001591, 0x00003C41, 0x0000159C, 0x00003C3D, - 0x000015A8, 0x00003C39, 0x000015B4, 0x00003C34, - 0x000015C0, 0x00003C30, 0x000015CC, 0x00003C2C, - 0x000015D8, 0x00003C28, 0x000015E3, 0x00003C23, - 0x000015EF, 0x00003C1F, 0x000015FB, 0x00003C1B, - 0x00001607, 0x00003C16, 0x00001613, 0x00003C12, - 0x0000161E, 0x00003C0E, 0x0000162A, 0x00003C09, - 0x00001636, 0x00003C05, 0x00001642, 0x00003C01, - 0x0000164D, 0x00003BFC, 0x00001659, 0x00003BF8, - 0x00001665, 0x00003BF4, 0x00001671, 0x00003BEF, - 0x0000167D, 0x00003BEB, 0x00001688, 0x00003BE6, - 0x00001694, 0x00003BE2, 0x000016A0, 0x00003BDD, - 0x000016AC, 0x00003BD9, 0x000016B7, 0x00003BD5, - 0x000016C3, 0x00003BD0, 0x000016CF, 0x00003BCC, - 0x000016DB, 0x00003BC7, 0x000016E6, 0x00003BC3, - 0x000016F2, 0x00003BBE, 0x000016FE, 0x00003BBA, - 0x00001709, 0x00003BB5, 0x00001715, 0x00003BB1, - 0x00001721, 0x00003BAC, 0x0000172D, 0x00003BA7, - 0x00001738, 0x00003BA3, 0x00001744, 0x00003B9E, - 0x00001750, 0x00003B9A, 0x0000175B, 0x00003B95, - 0x00001767, 0x00003B91, 0x00001773, 0x00003B8C, - 0x0000177F, 0x00003B87, 0x0000178A, 0x00003B83, - 0x00001796, 0x00003B7E, 0x000017A2, 0x00003B7A, - 0x000017AD, 0x00003B75, 0x000017B9, 0x00003B70, - 0x000017C5, 0x00003B6C, 0x000017D0, 0x00003B67, - 0x000017DC, 0x00003B62, 0x000017E8, 0x00003B5E, - 0x000017F3, 0x00003B59, 0x000017FF, 0x00003B54, - 0x0000180B, 0x00003B4F, 0x00001816, 0x00003B4B, - 0x00001822, 0x00003B46, 0x0000182D, 0x00003B41, - 0x00001839, 0x00003B3C, 0x00001845, 0x00003B38, - 0x00001850, 0x00003B33, 0x0000185C, 0x00003B2E, - 0x00001868, 0x00003B29, 0x00001873, 0x00003B25, - 0x0000187F, 0x00003B20, 0x0000188A, 0x00003B1B, - 0x00001896, 0x00003B16, 0x000018A2, 0x00003B11, - 0x000018AD, 0x00003B0C, 0x000018B9, 0x00003B08, - 0x000018C4, 0x00003B03, 0x000018D0, 0x00003AFE, - 0x000018DC, 0x00003AF9, 0x000018E7, 0x00003AF4, - 0x000018F3, 0x00003AEF, 0x000018FE, 0x00003AEA, - 0x0000190A, 0x00003AE5, 0x00001915, 0x00003AE0, - 0x00001921, 0x00003ADC, 0x0000192D, 0x00003AD7, - 0x00001938, 0x00003AD2, 0x00001944, 0x00003ACD, - 0x0000194F, 0x00003AC8, 0x0000195B, 0x00003AC3, - 0x00001966, 0x00003ABE, 0x00001972, 0x00003AB9, - 0x0000197D, 0x00003AB4, 0x00001989, 0x00003AAF, - 0x00001994, 0x00003AAA, 0x000019A0, 0x00003AA5, - 0x000019AB, 0x00003AA0, 0x000019B7, 0x00003A9B, - 0x000019C2, 0x00003A96, 0x000019CE, 0x00003A91, - 0x000019D9, 0x00003A8B, 0x000019E5, 0x00003A86, - 0x000019F0, 0x00003A81, 0x000019FC, 0x00003A7C, - 0x00001A07, 0x00003A77, 0x00001A13, 0x00003A72, - 0x00001A1E, 0x00003A6D, 0x00001A2A, 0x00003A68, - 0x00001A35, 0x00003A63, 0x00001A41, 0x00003A5D, - 0x00001A4C, 0x00003A58, 0x00001A58, 0x00003A53, - 0x00001A63, 0x00003A4E, 0x00001A6F, 0x00003A49, - 0x00001A7A, 0x00003A44, 0x00001A85, 0x00003A3E, - 0x00001A91, 0x00003A39, 0x00001A9C, 0x00003A34, - 0x00001AA8, 0x00003A2F, 0x00001AB3, 0x00003A29, - 0x00001ABF, 0x00003A24, 0x00001ACA, 0x00003A1F, - 0x00001AD5, 0x00003A1A, 0x00001AE1, 0x00003A14, - 0x00001AEC, 0x00003A0F, 0x00001AF8, 0x00003A0A, - 0x00001B03, 0x00003A05, 0x00001B0E, 0x000039FF, - 0x00001B1A, 0x000039FA, 0x00001B25, 0x000039F5, - 0x00001B31, 0x000039EF, 0x00001B3C, 0x000039EA, - 0x00001B47, 0x000039E5, 0x00001B53, 0x000039DF, - 0x00001B5E, 0x000039DA, 0x00001B69, 0x000039D4, - 0x00001B75, 0x000039CF, 0x00001B80, 0x000039CA, - 0x00001B8B, 0x000039C4, 0x00001B97, 0x000039BF, - 0x00001BA2, 0x000039B9, 0x00001BAD, 0x000039B4, - 0x00001BB9, 0x000039AF, 0x00001BC4, 0x000039A9, - 0x00001BCF, 0x000039A4, 0x00001BDB, 0x0000399E, - 0x00001BE6, 0x00003999, 0x00001BF1, 0x00003993, - 0x00001BFD, 0x0000398E, 0x00001C08, 0x00003988, - 0x00001C13, 0x00003983, 0x00001C1E, 0x0000397D, - 0x00001C2A, 0x00003978, 0x00001C35, 0x00003972, - 0x00001C40, 0x0000396D, 0x00001C4C, 0x00003967, - 0x00001C57, 0x00003961, 0x00001C62, 0x0000395C, - 0x00001C6D, 0x00003956, 0x00001C79, 0x00003951, - 0x00001C84, 0x0000394B, 0x00001C8F, 0x00003946, - 0x00001C9A, 0x00003940, 0x00001CA6, 0x0000393A, - 0x00001CB1, 0x00003935, 0x00001CBC, 0x0000392F, - 0x00001CC7, 0x00003929, 0x00001CD3, 0x00003924, - 0x00001CDE, 0x0000391E, 0x00001CE9, 0x00003918, - 0x00001CF4, 0x00003913, 0x00001CFF, 0x0000390D, - 0x00001D0B, 0x00003907, 0x00001D16, 0x00003902, - 0x00001D21, 0x000038FC, 0x00001D2C, 0x000038F6, - 0x00001D37, 0x000038F0, 0x00001D43, 0x000038EB, - 0x00001D4E, 0x000038E5, 0x00001D59, 0x000038DF, - 0x00001D64, 0x000038D9, 0x00001D6F, 0x000038D4, - 0x00001D7A, 0x000038CE, 0x00001D86, 0x000038C8, - 0x00001D91, 0x000038C2, 0x00001D9C, 0x000038BC, - 0x00001DA7, 0x000038B7, 0x00001DB2, 0x000038B1, - 0x00001DBD, 0x000038AB, 0x00001DC8, 0x000038A5, - 0x00001DD3, 0x0000389F, 0x00001DDF, 0x00003899, - 0x00001DEA, 0x00003894, 0x00001DF5, 0x0000388E, - 0x00001E00, 0x00003888, 0x00001E0B, 0x00003882, - 0x00001E16, 0x0000387C, 0x00001E21, 0x00003876, - 0x00001E2C, 0x00003870, 0x00001E37, 0x0000386A, - 0x00001E42, 0x00003864, 0x00001E4D, 0x0000385E, - 0x00001E59, 0x00003858, 0x00001E64, 0x00003852, - 0x00001E6F, 0x0000384C, 0x00001E7A, 0x00003846, - 0x00001E85, 0x00003840, 0x00001E90, 0x0000383A, - 0x00001E9B, 0x00003834, 0x00001EA6, 0x0000382E, - 0x00001EB1, 0x00003828, 0x00001EBC, 0x00003822, - 0x00001EC7, 0x0000381C, 0x00001ED2, 0x00003816, - 0x00001EDD, 0x00003810, 0x00001EE8, 0x0000380A, - 0x00001EF3, 0x00003804, 0x00001EFE, 0x000037FE, - 0x00001F09, 0x000037F8, 0x00001F14, 0x000037F2, - 0x00001F1F, 0x000037EC, 0x00001F2A, 0x000037E6, - 0x00001F35, 0x000037E0, 0x00001F40, 0x000037D9, - 0x00001F4B, 0x000037D3, 0x00001F56, 0x000037CD, - 0x00001F61, 0x000037C7, 0x00001F6C, 0x000037C1, - 0x00001F77, 0x000037BB, 0x00001F82, 0x000037B4, - 0x00001F8D, 0x000037AE, 0x00001F97, 0x000037A8, - 0x00001FA2, 0x000037A2, 0x00001FAD, 0x0000379C, - 0x00001FB8, 0x00003795, 0x00001FC3, 0x0000378F, - 0x00001FCE, 0x00003789, 0x00001FD9, 0x00003783, - 0x00001FE4, 0x0000377C, 0x00001FEF, 0x00003776, - 0x00001FFA, 0x00003770, 0x00002004, 0x0000376A, - 0x0000200F, 0x00003763, 0x0000201A, 0x0000375D, - 0x00002025, 0x00003757, 0x00002030, 0x00003750, - 0x0000203B, 0x0000374A, 0x00002046, 0x00003744, - 0x00002051, 0x0000373D, 0x0000205B, 0x00003737, - 0x00002066, 0x00003731, 0x00002071, 0x0000372A, - 0x0000207C, 0x00003724, 0x00002087, 0x0000371E, - 0x00002092, 0x00003717, 0x0000209C, 0x00003711, - 0x000020A7, 0x0000370A, 0x000020B2, 0x00003704, - 0x000020BD, 0x000036FD, 0x000020C8, 0x000036F7, - 0x000020D2, 0x000036F1, 0x000020DD, 0x000036EA, - 0x000020E8, 0x000036E4, 0x000020F3, 0x000036DD, - 0x000020FD, 0x000036D7, 0x00002108, 0x000036D0, - 0x00002113, 0x000036CA, 0x0000211E, 0x000036C3, - 0x00002128, 0x000036BD, 0x00002133, 0x000036B6, - 0x0000213E, 0x000036B0, 0x00002149, 0x000036A9, - 0x00002153, 0x000036A3, 0x0000215E, 0x0000369C, - 0x00002169, 0x00003696, 0x00002174, 0x0000368F, - 0x0000217E, 0x00003688, 0x00002189, 0x00003682, - 0x00002194, 0x0000367B, 0x0000219E, 0x00003675, - 0x000021A9, 0x0000366E, 0x000021B4, 0x00003667, - 0x000021BE, 0x00003661, 0x000021C9, 0x0000365A, - 0x000021D4, 0x00003654, 0x000021DE, 0x0000364D, - 0x000021E9, 0x00003646, 0x000021F4, 0x00003640, - 0x000021FE, 0x00003639, 0x00002209, 0x00003632, - 0x00002214, 0x0000362C, 0x0000221E, 0x00003625, - 0x00002229, 0x0000361E, 0x00002234, 0x00003617, - 0x0000223E, 0x00003611, 0x00002249, 0x0000360A, - 0x00002253, 0x00003603, 0x0000225E, 0x000035FD, - 0x00002269, 0x000035F6, 0x00002273, 0x000035EF, - 0x0000227E, 0x000035E8, 0x00002288, 0x000035E1, - 0x00002293, 0x000035DB, 0x0000229E, 0x000035D4, - 0x000022A8, 0x000035CD, 0x000022B3, 0x000035C6, - 0x000022BD, 0x000035BF, 0x000022C8, 0x000035B9, - 0x000022D2, 0x000035B2, 0x000022DD, 0x000035AB, - 0x000022E7, 0x000035A4, 0x000022F2, 0x0000359D, - 0x000022FC, 0x00003596, 0x00002307, 0x00003590, - 0x00002312, 0x00003589, 0x0000231C, 0x00003582, - 0x00002327, 0x0000357B, 0x00002331, 0x00003574, - 0x0000233C, 0x0000356D, 0x00002346, 0x00003566, - 0x00002350, 0x0000355F, 0x0000235B, 0x00003558, - 0x00002365, 0x00003551, 0x00002370, 0x0000354A, - 0x0000237A, 0x00003543, 0x00002385, 0x0000353C, - 0x0000238F, 0x00003535, 0x0000239A, 0x0000352E, - 0x000023A4, 0x00003527, 0x000023AF, 0x00003520, - 0x000023B9, 0x00003519, 0x000023C3, 0x00003512, - 0x000023CE, 0x0000350B, 0x000023D8, 0x00003504, - 0x000023E3, 0x000034FD, 0x000023ED, 0x000034F6, - 0x000023F7, 0x000034EF, 0x00002402, 0x000034E8, - 0x0000240C, 0x000034E1, 0x00002417, 0x000034DA, - 0x00002421, 0x000034D3, 0x0000242B, 0x000034CC, - 0x00002436, 0x000034C5, 0x00002440, 0x000034BE, - 0x0000244A, 0x000034B6, 0x00002455, 0x000034AF, - 0x0000245F, 0x000034A8, 0x00002469, 0x000034A1, - 0x00002474, 0x0000349A, 0x0000247E, 0x00003493, - 0x00002488, 0x0000348C, 0x00002493, 0x00003484, - 0x0000249D, 0x0000347D, 0x000024A7, 0x00003476, - 0x000024B2, 0x0000346F, 0x000024BC, 0x00003468, - 0x000024C6, 0x00003460, 0x000024D1, 0x00003459, - 0x000024DB, 0x00003452, 0x000024E5, 0x0000344B, - 0x000024EF, 0x00003443, 0x000024FA, 0x0000343C, - 0x00002504, 0x00003435, 0x0000250E, 0x0000342E, - 0x00002518, 0x00003426, 0x00002523, 0x0000341F, - 0x0000252D, 0x00003418, 0x00002537, 0x00003410, - 0x00002541, 0x00003409, 0x0000254B, 0x00003402, - 0x00002556, 0x000033FA, 0x00002560, 0x000033F3, - 0x0000256A, 0x000033EC, 0x00002574, 0x000033E4, - 0x0000257E, 0x000033DD, 0x00002589, 0x000033D6, - 0x00002593, 0x000033CE, 0x0000259D, 0x000033C7, - 0x000025A7, 0x000033C0, 0x000025B1, 0x000033B8, - 0x000025BB, 0x000033B1, 0x000025C6, 0x000033A9, - 0x000025D0, 0x000033A2, 0x000025DA, 0x0000339B, - 0x000025E4, 0x00003393, 0x000025EE, 0x0000338C, - 0x000025F8, 0x00003384, 0x00002602, 0x0000337D, - 0x0000260D, 0x00003375, 0x00002617, 0x0000336E, - 0x00002621, 0x00003366, 0x0000262B, 0x0000335F, - 0x00002635, 0x00003357, 0x0000263F, 0x00003350, - 0x00002649, 0x00003348, 0x00002653, 0x00003341, - 0x0000265D, 0x00003339, 0x00002667, 0x00003332, - 0x00002671, 0x0000332A, 0x0000267B, 0x00003323, - 0x00002685, 0x0000331B, 0x0000268F, 0x00003313, - 0x00002699, 0x0000330C, 0x000026A3, 0x00003304, - 0x000026AD, 0x000032FD, 0x000026B7, 0x000032F5, - 0x000026C1, 0x000032EE, 0x000026CB, 0x000032E6, - 0x000026D5, 0x000032DE, 0x000026DF, 0x000032D7, - 0x000026E9, 0x000032CF, 0x000026F3, 0x000032C7, - 0x000026FD, 0x000032C0, 0x00002707, 0x000032B8, - 0x00002711, 0x000032B0, 0x0000271B, 0x000032A9, - 0x00002725, 0x000032A1, 0x0000272F, 0x00003299, - 0x00002739, 0x00003292, 0x00002743, 0x0000328A, - 0x0000274D, 0x00003282, 0x00002757, 0x0000327B, - 0x00002761, 0x00003273, 0x0000276B, 0x0000326B, - 0x00002774, 0x00003263, 0x0000277E, 0x0000325C, - 0x00002788, 0x00003254, 0x00002792, 0x0000324C, - 0x0000279C, 0x00003244, 0x000027A6, 0x0000323C, - 0x000027B0, 0x00003235, 0x000027BA, 0x0000322D, - 0x000027C3, 0x00003225, 0x000027CD, 0x0000321D, - 0x000027D7, 0x00003215, 0x000027E1, 0x0000320E, - 0x000027EB, 0x00003206, 0x000027F5, 0x000031FE, - 0x000027FE, 0x000031F6, 0x00002808, 0x000031EE, - 0x00002812, 0x000031E6, 0x0000281C, 0x000031DF, - 0x00002826, 0x000031D7, 0x0000282F, 0x000031CF, - 0x00002839, 0x000031C7, 0x00002843, 0x000031BF, - 0x0000284D, 0x000031B7, 0x00002856, 0x000031AF, - 0x00002860, 0x000031A7, 0x0000286A, 0x0000319F, - 0x00002874, 0x00003197, 0x0000287D, 0x0000318F, - 0x00002887, 0x00003187, 0x00002891, 0x0000317F, - 0x0000289B, 0x00003178, 0x000028A4, 0x00003170, - 0x000028AE, 0x00003168, 0x000028B8, 0x00003160, - 0x000028C1, 0x00003158, 0x000028CB, 0x00003150, - 0x000028D5, 0x00003148, 0x000028DE, 0x00003140, - 0x000028E8, 0x00003137, 0x000028F2, 0x0000312F, - 0x000028FB, 0x00003127, 0x00002905, 0x0000311F, - 0x0000290F, 0x00003117, 0x00002918, 0x0000310F, - 0x00002922, 0x00003107, 0x0000292C, 0x000030FF, - 0x00002935, 0x000030F7, 0x0000293F, 0x000030EF, - 0x00002948, 0x000030E7, 0x00002952, 0x000030DF, - 0x0000295C, 0x000030D7, 0x00002965, 0x000030CE, - 0x0000296F, 0x000030C6, 0x00002978, 0x000030BE, - 0x00002982, 0x000030B6, 0x0000298C, 0x000030AE, - 0x00002995, 0x000030A6, 0x0000299F, 0x0000309E, - 0x000029A8, 0x00003095, 0x000029B2, 0x0000308D, - 0x000029BB, 0x00003085, 0x000029C5, 0x0000307D, - 0x000029CE, 0x00003075, 0x000029D8, 0x0000306C, - 0x000029E1, 0x00003064, 0x000029EB, 0x0000305C, - 0x000029F4, 0x00003054, 0x000029FE, 0x0000304B, - 0x00002A07, 0x00003043, 0x00002A11, 0x0000303B, - 0x00002A1A, 0x00003033, 0x00002A24, 0x0000302A, - 0x00002A2D, 0x00003022, 0x00002A37, 0x0000301A, - 0x00002A40, 0x00003012, 0x00002A49, 0x00003009, - 0x00002A53, 0x00003001, 0x00002A5C, 0x00002FF9, - 0x00002A66, 0x00002FF0, 0x00002A6F, 0x00002FE8, - 0x00002A79, 0x00002FE0, 0x00002A82, 0x00002FD7, - 0x00002A8B, 0x00002FCF, 0x00002A95, 0x00002FC7, - 0x00002A9E, 0x00002FBE, 0x00002AA7, 0x00002FB6, - 0x00002AB1, 0x00002FAD, 0x00002ABA, 0x00002FA5, - 0x00002AC4, 0x00002F9D, 0x00002ACD, 0x00002F94, - 0x00002AD6, 0x00002F8C, 0x00002AE0, 0x00002F83, - 0x00002AE9, 0x00002F7B, 0x00002AF2, 0x00002F73, - 0x00002AFB, 0x00002F6A, 0x00002B05, 0x00002F62, - 0x00002B0E, 0x00002F59, 0x00002B17, 0x00002F51, - 0x00002B21, 0x00002F48, 0x00002B2A, 0x00002F40, - 0x00002B33, 0x00002F37, 0x00002B3C, 0x00002F2F, - 0x00002B46, 0x00002F26, 0x00002B4F, 0x00002F1E, - 0x00002B58, 0x00002F15, 0x00002B62, 0x00002F0D, - 0x00002B6B, 0x00002F04, 0x00002B74, 0x00002EFC, - 0x00002B7D, 0x00002EF3, 0x00002B86, 0x00002EEB, - 0x00002B90, 0x00002EE2, 0x00002B99, 0x00002EDA, - 0x00002BA2, 0x00002ED1, 0x00002BAB, 0x00002EC9, - 0x00002BB4, 0x00002EC0, 0x00002BBE, 0x00002EB7, - 0x00002BC7, 0x00002EAF, 0x00002BD0, 0x00002EA6, - 0x00002BD9, 0x00002E9E, 0x00002BE2, 0x00002E95, - 0x00002BEB, 0x00002E8C, 0x00002BF4, 0x00002E84, - 0x00002BFE, 0x00002E7B, 0x00002C07, 0x00002E72, - 0x00002C10, 0x00002E6A, 0x00002C19, 0x00002E61, - 0x00002C22, 0x00002E58, 0x00002C2B, 0x00002E50, - 0x00002C34, 0x00002E47, 0x00002C3D, 0x00002E3E, - 0x00002C46, 0x00002E36, 0x00002C4F, 0x00002E2D, - 0x00002C59, 0x00002E24, 0x00002C62, 0x00002E1C, - 0x00002C6B, 0x00002E13, 0x00002C74, 0x00002E0A, - 0x00002C7D, 0x00002E01, 0x00002C86, 0x00002DF9, - 0x00002C8F, 0x00002DF0, 0x00002C98, 0x00002DE7, - 0x00002CA1, 0x00002DDE, 0x00002CAA, 0x00002DD6, - 0x00002CB3, 0x00002DCD, 0x00002CBC, 0x00002DC4, - 0x00002CC5, 0x00002DBB, 0x00002CCE, 0x00002DB3, - 0x00002CD7, 0x00002DAA, 0x00002CE0, 0x00002DA1, - 0x00002CE9, 0x00002D98, 0x00002CF2, 0x00002D8F, - 0x00002CFB, 0x00002D87, 0x00002D03, 0x00002D7E, - 0x00002D0C, 0x00002D75, 0x00002D15, 0x00002D6C, - 0x00002D1E, 0x00002D63, 0x00002D27, 0x00002D5A, - 0x00002D30, 0x00002D51, 0x00002D39, 0x00002D49, - 0x00002D42, 0x00002D40, 0x00002D4B, 0x00002D37, - 0x00002D54, 0x00002D2E, 0x00002D5C, 0x00002D25, - 0x00002D65, 0x00002D1C, 0x00002D6E, 0x00002D13, - 0x00002D77, 0x00002D0A, 0x00002D80, 0x00002D01, - 0x00002D89, 0x00002CF8, 0x00002D92, 0x00002CEF, - 0x00002D9A, 0x00002CE6, 0x00002DA3, 0x00002CDD, - 0x00002DAC, 0x00002CD4, 0x00002DB5, 0x00002CCC, - 0x00002DBE, 0x00002CC3, 0x00002DC6, 0x00002CBA, - 0x00002DCF, 0x00002CB1, 0x00002DD8, 0x00002CA8, - 0x00002DE1, 0x00002C9F, 0x00002DE9, 0x00002C96, - 0x00002DF2, 0x00002C8D, 0x00002DFB, 0x00002C84, - 0x00002E04, 0x00002C7A, 0x00002E0C, 0x00002C71, - 0x00002E15, 0x00002C68, 0x00002E1E, 0x00002C5F, - 0x00002E27, 0x00002C56, 0x00002E2F, 0x00002C4D, - 0x00002E38, 0x00002C44, 0x00002E41, 0x00002C3B, - 0x00002E49, 0x00002C32, 0x00002E52, 0x00002C29, - 0x00002E5B, 0x00002C20, 0x00002E63, 0x00002C17, - 0x00002E6C, 0x00002C0E, 0x00002E75, 0x00002C04, - 0x00002E7D, 0x00002BFB, 0x00002E86, 0x00002BF2, - 0x00002E8F, 0x00002BE9, 0x00002E97, 0x00002BE0, - 0x00002EA0, 0x00002BD7, 0x00002EA8, 0x00002BCE, - 0x00002EB1, 0x00002BC4, 0x00002EBA, 0x00002BBB, - 0x00002EC2, 0x00002BB2, 0x00002ECB, 0x00002BA9, - 0x00002ED3, 0x00002BA0, 0x00002EDC, 0x00002B97, - 0x00002EE4, 0x00002B8D, 0x00002EED, 0x00002B84, - 0x00002EF5, 0x00002B7B, 0x00002EFE, 0x00002B72, - 0x00002F07, 0x00002B68, 0x00002F0F, 0x00002B5F, - 0x00002F18, 0x00002B56, 0x00002F20, 0x00002B4D, - 0x00002F29, 0x00002B43, 0x00002F31, 0x00002B3A, - 0x00002F3A, 0x00002B31, 0x00002F42, 0x00002B28, - 0x00002F4A, 0x00002B1E, 0x00002F53, 0x00002B15, - 0x00002F5B, 0x00002B0C, 0x00002F64, 0x00002B02, - 0x00002F6C, 0x00002AF9, 0x00002F75, 0x00002AF0, - 0x00002F7D, 0x00002AE7, 0x00002F86, 0x00002ADD, - 0x00002F8E, 0x00002AD4, 0x00002F96, 0x00002ACB, - 0x00002F9F, 0x00002AC1, 0x00002FA7, 0x00002AB8, - 0x00002FB0, 0x00002AAE, 0x00002FB8, 0x00002AA5, - 0x00002FC0, 0x00002A9C, 0x00002FC9, 0x00002A92, - 0x00002FD1, 0x00002A89, 0x00002FD9, 0x00002A80, - 0x00002FE2, 0x00002A76, 0x00002FEA, 0x00002A6D, - 0x00002FF2, 0x00002A63, 0x00002FFB, 0x00002A5A, - 0x00003003, 0x00002A51, 0x0000300B, 0x00002A47, - 0x00003014, 0x00002A3E, 0x0000301C, 0x00002A34, - 0x00003024, 0x00002A2B, 0x0000302C, 0x00002A21, - 0x00003035, 0x00002A18, 0x0000303D, 0x00002A0E, - 0x00003045, 0x00002A05, 0x0000304E, 0x000029FB, - 0x00003056, 0x000029F2, 0x0000305E, 0x000029E8, - 0x00003066, 0x000029DF, 0x0000306E, 0x000029D5, - 0x00003077, 0x000029CC, 0x0000307F, 0x000029C2, - 0x00003087, 0x000029B9, 0x0000308F, 0x000029AF, - 0x00003097, 0x000029A6, 0x000030A0, 0x0000299C, - 0x000030A8, 0x00002993, 0x000030B0, 0x00002989, - 0x000030B8, 0x00002980, 0x000030C0, 0x00002976, - 0x000030C8, 0x0000296C, 0x000030D0, 0x00002963, - 0x000030D9, 0x00002959, 0x000030E1, 0x00002950, - 0x000030E9, 0x00002946, 0x000030F1, 0x0000293C, - 0x000030F9, 0x00002933, 0x00003101, 0x00002929, - 0x00003109, 0x00002920, 0x00003111, 0x00002916, - 0x00003119, 0x0000290C, 0x00003121, 0x00002903, - 0x00003129, 0x000028F9, 0x00003131, 0x000028EF, - 0x00003139, 0x000028E6, 0x00003142, 0x000028DC, - 0x0000314A, 0x000028D2, 0x00003152, 0x000028C9, - 0x0000315A, 0x000028BF, 0x00003162, 0x000028B5, - 0x0000316A, 0x000028AC, 0x00003172, 0x000028A2, - 0x0000317A, 0x00002898, 0x00003181, 0x0000288E, - 0x00003189, 0x00002885, 0x00003191, 0x0000287B, - 0x00003199, 0x00002871, 0x000031A1, 0x00002868, - 0x000031A9, 0x0000285E, 0x000031B1, 0x00002854, - 0x000031B9, 0x0000284A, 0x000031C1, 0x00002841, - 0x000031C9, 0x00002837, 0x000031D1, 0x0000282D, - 0x000031D9, 0x00002823, 0x000031E0, 0x00002819, - 0x000031E8, 0x00002810, 0x000031F0, 0x00002806, - 0x000031F8, 0x000027FC, 0x00003200, 0x000027F2, - 0x00003208, 0x000027E8, 0x00003210, 0x000027DF, - 0x00003217, 0x000027D5, 0x0000321F, 0x000027CB, - 0x00003227, 0x000027C1, 0x0000322F, 0x000027B7, - 0x00003237, 0x000027AD, 0x0000323E, 0x000027A3, - 0x00003246, 0x0000279A, 0x0000324E, 0x00002790, - 0x00003256, 0x00002786, 0x0000325E, 0x0000277C, - 0x00003265, 0x00002772, 0x0000326D, 0x00002768, - 0x00003275, 0x0000275E, 0x0000327C, 0x00002754, - 0x00003284, 0x0000274A, 0x0000328C, 0x00002740, - 0x00003294, 0x00002737, 0x0000329B, 0x0000272D, - 0x000032A3, 0x00002723, 0x000032AB, 0x00002719, - 0x000032B2, 0x0000270F, 0x000032BA, 0x00002705, - 0x000032C2, 0x000026FB, 0x000032C9, 0x000026F1, - 0x000032D1, 0x000026E7, 0x000032D9, 0x000026DD, - 0x000032E0, 0x000026D3, 0x000032E8, 0x000026C9, - 0x000032EF, 0x000026BF, 0x000032F7, 0x000026B5, - 0x000032FF, 0x000026AB, 0x00003306, 0x000026A1, - 0x0000330E, 0x00002697, 0x00003315, 0x0000268D, - 0x0000331D, 0x00002683, 0x00003325, 0x00002679, - 0x0000332C, 0x0000266F, 0x00003334, 0x00002665, - 0x0000333B, 0x0000265B, 0x00003343, 0x00002651, - 0x0000334A, 0x00002647, 0x00003352, 0x0000263C, - 0x00003359, 0x00002632, 0x00003361, 0x00002628, - 0x00003368, 0x0000261E, 0x00003370, 0x00002614, - 0x00003377, 0x0000260A, 0x0000337F, 0x00002600, - 0x00003386, 0x000025F6, 0x0000338E, 0x000025EC, - 0x00003395, 0x000025E2, 0x0000339C, 0x000025D7, - 0x000033A4, 0x000025CD, 0x000033AB, 0x000025C3, - 0x000033B3, 0x000025B9, 0x000033BA, 0x000025AF, - 0x000033C1, 0x000025A5, 0x000033C9, 0x0000259A, - 0x000033D0, 0x00002590, 0x000033D8, 0x00002586, - 0x000033DF, 0x0000257C, 0x000033E6, 0x00002572, - 0x000033EE, 0x00002568, 0x000033F5, 0x0000255D, - 0x000033FC, 0x00002553, 0x00003404, 0x00002549, - 0x0000340B, 0x0000253F, 0x00003412, 0x00002535, - 0x0000341A, 0x0000252A, 0x00003421, 0x00002520, - 0x00003428, 0x00002516, 0x0000342F, 0x0000250C, - 0x00003437, 0x00002501, 0x0000343E, 0x000024F7, - 0x00003445, 0x000024ED, 0x0000344C, 0x000024E3, - 0x00003454, 0x000024D8, 0x0000345B, 0x000024CE, - 0x00003462, 0x000024C4, 0x00003469, 0x000024B9, - 0x00003471, 0x000024AF, 0x00003478, 0x000024A5, - 0x0000347F, 0x0000249B, 0x00003486, 0x00002490, - 0x0000348D, 0x00002486, 0x00003495, 0x0000247C, - 0x0000349C, 0x00002471, 0x000034A3, 0x00002467, - 0x000034AA, 0x0000245D, 0x000034B1, 0x00002452, - 0x000034B8, 0x00002448, 0x000034BF, 0x0000243E, - 0x000034C6, 0x00002433, 0x000034CE, 0x00002429, - 0x000034D5, 0x0000241E, 0x000034DC, 0x00002414, - 0x000034E3, 0x0000240A, 0x000034EA, 0x000023FF, - 0x000034F1, 0x000023F5, 0x000034F8, 0x000023EA, - 0x000034FF, 0x000023E0, 0x00003506, 0x000023D6, - 0x0000350D, 0x000023CB, 0x00003514, 0x000023C1, - 0x0000351B, 0x000023B6, 0x00003522, 0x000023AC, - 0x00003529, 0x000023A2, 0x00003530, 0x00002397, - 0x00003537, 0x0000238D, 0x0000353E, 0x00002382, - 0x00003545, 0x00002378, 0x0000354C, 0x0000236D, - 0x00003553, 0x00002363, 0x0000355A, 0x00002358, - 0x00003561, 0x0000234E, 0x00003568, 0x00002343, - 0x0000356F, 0x00002339, 0x00003576, 0x0000232E, - 0x0000357D, 0x00002324, 0x00003583, 0x00002319, - 0x0000358A, 0x0000230F, 0x00003591, 0x00002304, - 0x00003598, 0x000022FA, 0x0000359F, 0x000022EF, - 0x000035A6, 0x000022E5, 0x000035AD, 0x000022DA, - 0x000035B4, 0x000022D0, 0x000035BA, 0x000022C5, - 0x000035C1, 0x000022BB, 0x000035C8, 0x000022B0, - 0x000035CF, 0x000022A5, 0x000035D6, 0x0000229B, - 0x000035DC, 0x00002290, 0x000035E3, 0x00002286, - 0x000035EA, 0x0000227B, 0x000035F1, 0x00002271, - 0x000035F7, 0x00002266, 0x000035FE, 0x0000225B, - 0x00003605, 0x00002251, 0x0000360C, 0x00002246, - 0x00003612, 0x0000223C, 0x00003619, 0x00002231, - 0x00003620, 0x00002226, 0x00003627, 0x0000221C, - 0x0000362D, 0x00002211, 0x00003634, 0x00002206, - 0x0000363B, 0x000021FC, 0x00003641, 0x000021F1, - 0x00003648, 0x000021E6, 0x0000364F, 0x000021DC, - 0x00003655, 0x000021D1, 0x0000365C, 0x000021C6, - 0x00003662, 0x000021BC, 0x00003669, 0x000021B1, - 0x00003670, 0x000021A6, 0x00003676, 0x0000219C, - 0x0000367D, 0x00002191, 0x00003684, 0x00002186, - 0x0000368A, 0x0000217C, 0x00003691, 0x00002171, - 0x00003697, 0x00002166, 0x0000369E, 0x0000215B, - 0x000036A4, 0x00002151, 0x000036AB, 0x00002146, - 0x000036B1, 0x0000213B, 0x000036B8, 0x00002131, - 0x000036BE, 0x00002126, 0x000036C5, 0x0000211B, - 0x000036CB, 0x00002110, 0x000036D2, 0x00002106, - 0x000036D8, 0x000020FB, 0x000036DF, 0x000020F0, - 0x000036E5, 0x000020E5, 0x000036EC, 0x000020DA, - 0x000036F2, 0x000020D0, 0x000036F9, 0x000020C5, - 0x000036FF, 0x000020BA, 0x00003706, 0x000020AF, - 0x0000370C, 0x000020A4, 0x00003712, 0x0000209A, - 0x00003719, 0x0000208F, 0x0000371F, 0x00002084, - 0x00003726, 0x00002079, 0x0000372C, 0x0000206E, - 0x00003732, 0x00002064, 0x00003739, 0x00002059, - 0x0000373F, 0x0000204E, 0x00003745, 0x00002043, - 0x0000374C, 0x00002038, 0x00003752, 0x0000202D, - 0x00003758, 0x00002022, 0x0000375F, 0x00002018, - 0x00003765, 0x0000200D, 0x0000376B, 0x00002002, - 0x00003771, 0x00001FF7, 0x00003778, 0x00001FEC, - 0x0000377E, 0x00001FE1, 0x00003784, 0x00001FD6, - 0x0000378A, 0x00001FCB, 0x00003791, 0x00001FC0, - 0x00003797, 0x00001FB5, 0x0000379D, 0x00001FAB, - 0x000037A3, 0x00001FA0, 0x000037AA, 0x00001F95, - 0x000037B0, 0x00001F8A, 0x000037B6, 0x00001F7F, - 0x000037BC, 0x00001F74, 0x000037C2, 0x00001F69, - 0x000037C8, 0x00001F5E, 0x000037CF, 0x00001F53, - 0x000037D5, 0x00001F48, 0x000037DB, 0x00001F3D, - 0x000037E1, 0x00001F32, 0x000037E7, 0x00001F27, - 0x000037ED, 0x00001F1C, 0x000037F3, 0x00001F11, - 0x000037F9, 0x00001F06, 0x00003800, 0x00001EFB, - 0x00003806, 0x00001EF0, 0x0000380C, 0x00001EE5, - 0x00003812, 0x00001EDA, 0x00003818, 0x00001ECF, - 0x0000381E, 0x00001EC4, 0x00003824, 0x00001EB9, - 0x0000382A, 0x00001EAE, 0x00003830, 0x00001EA3, - 0x00003836, 0x00001E98, 0x0000383C, 0x00001E8D, - 0x00003842, 0x00001E82, 0x00003848, 0x00001E77, - 0x0000384E, 0x00001E6C, 0x00003854, 0x00001E61, - 0x0000385A, 0x00001E56, 0x00003860, 0x00001E4B, - 0x00003866, 0x00001E40, 0x0000386C, 0x00001E35, - 0x00003872, 0x00001E29, 0x00003878, 0x00001E1E, - 0x0000387D, 0x00001E13, 0x00003883, 0x00001E08, - 0x00003889, 0x00001DFD, 0x0000388F, 0x00001DF2, - 0x00003895, 0x00001DE7, 0x0000389B, 0x00001DDC, - 0x000038A1, 0x00001DD1, 0x000038A7, 0x00001DC6, - 0x000038AC, 0x00001DBA, 0x000038B2, 0x00001DAF, - 0x000038B8, 0x00001DA4, 0x000038BE, 0x00001D99, - 0x000038C4, 0x00001D8E, 0x000038CA, 0x00001D83, - 0x000038CF, 0x00001D78, 0x000038D5, 0x00001D6C, - 0x000038DB, 0x00001D61, 0x000038E1, 0x00001D56, - 0x000038E6, 0x00001D4B, 0x000038EC, 0x00001D40, - 0x000038F2, 0x00001D35, 0x000038F8, 0x00001D29, - 0x000038FD, 0x00001D1E, 0x00003903, 0x00001D13, - 0x00003909, 0x00001D08, 0x0000390E, 0x00001CFD, - 0x00003914, 0x00001CF1, 0x0000391A, 0x00001CE6, - 0x0000391F, 0x00001CDB, 0x00003925, 0x00001CD0, - 0x0000392B, 0x00001CC5, 0x00003930, 0x00001CB9, - 0x00003936, 0x00001CAE, 0x0000393C, 0x00001CA3, - 0x00003941, 0x00001C98, 0x00003947, 0x00001C8C, - 0x0000394D, 0x00001C81, 0x00003952, 0x00001C76, - 0x00003958, 0x00001C6B, 0x0000395D, 0x00001C5F, - 0x00003963, 0x00001C54, 0x00003968, 0x00001C49, - 0x0000396E, 0x00001C3E, 0x00003974, 0x00001C32, - 0x00003979, 0x00001C27, 0x0000397F, 0x00001C1C, - 0x00003984, 0x00001C10, 0x0000398A, 0x00001C05, - 0x0000398F, 0x00001BFA, 0x00003995, 0x00001BEE, - 0x0000399A, 0x00001BE3, 0x000039A0, 0x00001BD8, - 0x000039A5, 0x00001BCD, 0x000039AA, 0x00001BC1, - 0x000039B0, 0x00001BB6, 0x000039B5, 0x00001BAB, - 0x000039BB, 0x00001B9F, 0x000039C0, 0x00001B94, - 0x000039C6, 0x00001B89, 0x000039CB, 0x00001B7D, - 0x000039D0, 0x00001B72, 0x000039D6, 0x00001B67, - 0x000039DB, 0x00001B5B, 0x000039E0, 0x00001B50, - 0x000039E6, 0x00001B44, 0x000039EB, 0x00001B39, - 0x000039F1, 0x00001B2E, 0x000039F6, 0x00001B22, - 0x000039FB, 0x00001B17, 0x00003A01, 0x00001B0C, - 0x00003A06, 0x00001B00, 0x00003A0B, 0x00001AF5, - 0x00003A10, 0x00001AE9, 0x00003A16, 0x00001ADE, - 0x00003A1B, 0x00001AD3, 0x00003A20, 0x00001AC7, - 0x00003A25, 0x00001ABC, 0x00003A2B, 0x00001AB0, - 0x00003A30, 0x00001AA5, 0x00003A35, 0x00001A99, - 0x00003A3A, 0x00001A8E, 0x00003A40, 0x00001A83, - 0x00003A45, 0x00001A77, 0x00003A4A, 0x00001A6C, - 0x00003A4F, 0x00001A60, 0x00003A54, 0x00001A55, - 0x00003A5A, 0x00001A49, 0x00003A5F, 0x00001A3E, - 0x00003A64, 0x00001A32, 0x00003A69, 0x00001A27, - 0x00003A6E, 0x00001A1B, 0x00003A73, 0x00001A10, - 0x00003A78, 0x00001A05, 0x00003A7D, 0x000019F9, - 0x00003A83, 0x000019EE, 0x00003A88, 0x000019E2, - 0x00003A8D, 0x000019D7, 0x00003A92, 0x000019CB, - 0x00003A97, 0x000019C0, 0x00003A9C, 0x000019B4, - 0x00003AA1, 0x000019A9, 0x00003AA6, 0x0000199D, - 0x00003AAB, 0x00001992, 0x00003AB0, 0x00001986, - 0x00003AB5, 0x0000197A, 0x00003ABA, 0x0000196F, - 0x00003ABF, 0x00001963, 0x00003AC4, 0x00001958, - 0x00003AC9, 0x0000194C, 0x00003ACE, 0x00001941, - 0x00003AD3, 0x00001935, 0x00003AD8, 0x0000192A, - 0x00003ADD, 0x0000191E, 0x00003AE2, 0x00001913, - 0x00003AE7, 0x00001907, 0x00003AEC, 0x000018FB, - 0x00003AF0, 0x000018F0, 0x00003AF5, 0x000018E4, - 0x00003AFA, 0x000018D9, 0x00003AFF, 0x000018CD, - 0x00003B04, 0x000018C2, 0x00003B09, 0x000018B6, - 0x00003B0E, 0x000018AA, 0x00003B12, 0x0000189F, - 0x00003B17, 0x00001893, 0x00003B1C, 0x00001888, - 0x00003B21, 0x0000187C, 0x00003B26, 0x00001870, - 0x00003B2B, 0x00001865, 0x00003B2F, 0x00001859, - 0x00003B34, 0x0000184D, 0x00003B39, 0x00001842, - 0x00003B3E, 0x00001836, 0x00003B42, 0x0000182B, - 0x00003B47, 0x0000181F, 0x00003B4C, 0x00001813, - 0x00003B51, 0x00001808, 0x00003B55, 0x000017FC, - 0x00003B5A, 0x000017F0, 0x00003B5F, 0x000017E5, - 0x00003B63, 0x000017D9, 0x00003B68, 0x000017CD, - 0x00003B6D, 0x000017C2, 0x00003B71, 0x000017B6, - 0x00003B76, 0x000017AA, 0x00003B7B, 0x0000179F, - 0x00003B7F, 0x00001793, 0x00003B84, 0x00001787, - 0x00003B89, 0x0000177C, 0x00003B8D, 0x00001770, - 0x00003B92, 0x00001764, 0x00003B96, 0x00001759, - 0x00003B9B, 0x0000174D, 0x00003BA0, 0x00001741, - 0x00003BA4, 0x00001735, 0x00003BA9, 0x0000172A, - 0x00003BAD, 0x0000171E, 0x00003BB2, 0x00001712, - 0x00003BB6, 0x00001707, 0x00003BBB, 0x000016FB, - 0x00003BBF, 0x000016EF, 0x00003BC4, 0x000016E3, - 0x00003BC8, 0x000016D8, 0x00003BCD, 0x000016CC, - 0x00003BD1, 0x000016C0, 0x00003BD6, 0x000016B4, - 0x00003BDA, 0x000016A9, 0x00003BDF, 0x0000169D, - 0x00003BE3, 0x00001691, 0x00003BE7, 0x00001685, - 0x00003BEC, 0x0000167A, 0x00003BF0, 0x0000166E, - 0x00003BF5, 0x00001662, 0x00003BF9, 0x00001656, - 0x00003BFD, 0x0000164B, 0x00003C02, 0x0000163F, - 0x00003C06, 0x00001633, 0x00003C0B, 0x00001627, - 0x00003C0F, 0x0000161B, 0x00003C13, 0x00001610, - 0x00003C18, 0x00001604, 0x00003C1C, 0x000015F8, - 0x00003C20, 0x000015EC, 0x00003C24, 0x000015E0, - 0x00003C29, 0x000015D5, 0x00003C2D, 0x000015C9, - 0x00003C31, 0x000015BD, 0x00003C36, 0x000015B1, - 0x00003C3A, 0x000015A5, 0x00003C3E, 0x00001599, - 0x00003C42, 0x0000158E, 0x00003C47, 0x00001582, - 0x00003C4B, 0x00001576, 0x00003C4F, 0x0000156A, - 0x00003C53, 0x0000155E, 0x00003C57, 0x00001552, - 0x00003C5C, 0x00001547, 0x00003C60, 0x0000153B, - 0x00003C64, 0x0000152F, 0x00003C68, 0x00001523, - 0x00003C6C, 0x00001517, 0x00003C70, 0x0000150B, - 0x00003C74, 0x000014FF, 0x00003C79, 0x000014F4, - 0x00003C7D, 0x000014E8, 0x00003C81, 0x000014DC, - 0x00003C85, 0x000014D0, 0x00003C89, 0x000014C4, - 0x00003C8D, 0x000014B8, 0x00003C91, 0x000014AC, - 0x00003C95, 0x000014A0, 0x00003C99, 0x00001494, - 0x00003C9D, 0x00001489, 0x00003CA1, 0x0000147D, - 0x00003CA5, 0x00001471, 0x00003CA9, 0x00001465, - 0x00003CAD, 0x00001459, 0x00003CB1, 0x0000144D, - 0x00003CB5, 0x00001441, 0x00003CB9, 0x00001435, - 0x00003CBD, 0x00001429, 0x00003CC1, 0x0000141D, - 0x00003CC5, 0x00001411, 0x00003CC9, 0x00001405, - 0x00003CCD, 0x000013F9, 0x00003CD1, 0x000013EE, - 0x00003CD5, 0x000013E2, 0x00003CD9, 0x000013D6, - 0x00003CDD, 0x000013CA, 0x00003CE0, 0x000013BE, - 0x00003CE4, 0x000013B2, 0x00003CE8, 0x000013A6, - 0x00003CEC, 0x0000139A, 0x00003CF0, 0x0000138E, - 0x00003CF4, 0x00001382, 0x00003CF8, 0x00001376, - 0x00003CFB, 0x0000136A, 0x00003CFF, 0x0000135E, - 0x00003D03, 0x00001352, 0x00003D07, 0x00001346, - 0x00003D0B, 0x0000133A, 0x00003D0E, 0x0000132E, - 0x00003D12, 0x00001322, 0x00003D16, 0x00001316, - 0x00003D1A, 0x0000130A, 0x00003D1D, 0x000012FE, - 0x00003D21, 0x000012F2, 0x00003D25, 0x000012E6, - 0x00003D28, 0x000012DA, 0x00003D2C, 0x000012CE, - 0x00003D30, 0x000012C2, 0x00003D33, 0x000012B6, - 0x00003D37, 0x000012AA, 0x00003D3B, 0x0000129E, - 0x00003D3E, 0x00001292, 0x00003D42, 0x00001286, - 0x00003D46, 0x0000127A, 0x00003D49, 0x0000126E, - 0x00003D4D, 0x00001262, 0x00003D51, 0x00001256, - 0x00003D54, 0x0000124A, 0x00003D58, 0x0000123E, - 0x00003D5B, 0x00001232, 0x00003D5F, 0x00001226, - 0x00003D62, 0x0000121A, 0x00003D66, 0x0000120E, - 0x00003D6A, 0x00001202, 0x00003D6D, 0x000011F5, - 0x00003D71, 0x000011E9, 0x00003D74, 0x000011DD, - 0x00003D78, 0x000011D1, 0x00003D7B, 0x000011C5, - 0x00003D7F, 0x000011B9, 0x00003D82, 0x000011AD, - 0x00003D86, 0x000011A1, 0x00003D89, 0x00001195, - 0x00003D8C, 0x00001189, 0x00003D90, 0x0000117D, - 0x00003D93, 0x00001171, 0x00003D97, 0x00001165, - 0x00003D9A, 0x00001158, 0x00003D9E, 0x0000114C, - 0x00003DA1, 0x00001140, 0x00003DA4, 0x00001134, - 0x00003DA8, 0x00001128, 0x00003DAB, 0x0000111C, - 0x00003DAE, 0x00001110, 0x00003DB2, 0x00001104, - 0x00003DB5, 0x000010F8, 0x00003DB8, 0x000010EB, - 0x00003DBC, 0x000010DF, 0x00003DBF, 0x000010D3, - 0x00003DC2, 0x000010C7, 0x00003DC6, 0x000010BB, - 0x00003DC9, 0x000010AF, 0x00003DCC, 0x000010A3, - 0x00003DCF, 0x00001097, 0x00003DD3, 0x0000108A, - 0x00003DD6, 0x0000107E, 0x00003DD9, 0x00001072, - 0x00003DDC, 0x00001066, 0x00003DE0, 0x0000105A, - 0x00003DE3, 0x0000104E, 0x00003DE6, 0x00001042, - 0x00003DE9, 0x00001035, 0x00003DEC, 0x00001029, - 0x00003DF0, 0x0000101D, 0x00003DF3, 0x00001011, - 0x00003DF6, 0x00001005, 0x00003DF9, 0x00000FF9, - 0x00003DFC, 0x00000FEC, 0x00003DFF, 0x00000FE0, - 0x00003E02, 0x00000FD4, 0x00003E05, 0x00000FC8, - 0x00003E09, 0x00000FBC, 0x00003E0C, 0x00000FB0, - 0x00003E0F, 0x00000FA3, 0x00003E12, 0x00000F97, - 0x00003E15, 0x00000F8B, 0x00003E18, 0x00000F7F, - 0x00003E1B, 0x00000F73, 0x00003E1E, 0x00000F66, - 0x00003E21, 0x00000F5A, 0x00003E24, 0x00000F4E, - 0x00003E27, 0x00000F42, 0x00003E2A, 0x00000F36, - 0x00003E2D, 0x00000F29, 0x00003E30, 0x00000F1D, - 0x00003E33, 0x00000F11, 0x00003E36, 0x00000F05, - 0x00003E39, 0x00000EF9, 0x00003E3C, 0x00000EEC, - 0x00003E3F, 0x00000EE0, 0x00003E42, 0x00000ED4, - 0x00003E45, 0x00000EC8, 0x00003E47, 0x00000EBB, - 0x00003E4A, 0x00000EAF, 0x00003E4D, 0x00000EA3, - 0x00003E50, 0x00000E97, 0x00003E53, 0x00000E8A, - 0x00003E56, 0x00000E7E, 0x00003E59, 0x00000E72, - 0x00003E5B, 0x00000E66, 0x00003E5E, 0x00000E59, - 0x00003E61, 0x00000E4D, 0x00003E64, 0x00000E41, - 0x00003E67, 0x00000E35, 0x00003E69, 0x00000E28, - 0x00003E6C, 0x00000E1C, 0x00003E6F, 0x00000E10, - 0x00003E72, 0x00000E04, 0x00003E74, 0x00000DF7, - 0x00003E77, 0x00000DEB, 0x00003E7A, 0x00000DDF, - 0x00003E7D, 0x00000DD3, 0x00003E7F, 0x00000DC6, - 0x00003E82, 0x00000DBA, 0x00003E85, 0x00000DAE, - 0x00003E87, 0x00000DA2, 0x00003E8A, 0x00000D95, - 0x00003E8D, 0x00000D89, 0x00003E8F, 0x00000D7D, - 0x00003E92, 0x00000D70, 0x00003E95, 0x00000D64, - 0x00003E97, 0x00000D58, 0x00003E9A, 0x00000D4C, - 0x00003E9D, 0x00000D3F, 0x00003E9F, 0x00000D33, - 0x00003EA2, 0x00000D27, 0x00003EA4, 0x00000D1A, - 0x00003EA7, 0x00000D0E, 0x00003EA9, 0x00000D02, - 0x00003EAC, 0x00000CF5, 0x00003EAF, 0x00000CE9, - 0x00003EB1, 0x00000CDD, 0x00003EB4, 0x00000CD1, - 0x00003EB6, 0x00000CC4, 0x00003EB9, 0x00000CB8, - 0x00003EBB, 0x00000CAC, 0x00003EBE, 0x00000C9F, - 0x00003EC0, 0x00000C93, 0x00003EC3, 0x00000C87, - 0x00003EC5, 0x00000C7A, 0x00003EC7, 0x00000C6E, - 0x00003ECA, 0x00000C62, 0x00003ECC, 0x00000C55, - 0x00003ECF, 0x00000C49, 0x00003ED1, 0x00000C3D, - 0x00003ED4, 0x00000C30, 0x00003ED6, 0x00000C24, - 0x00003ED8, 0x00000C18, 0x00003EDB, 0x00000C0B, - 0x00003EDD, 0x00000BFF, 0x00003EDF, 0x00000BF3, - 0x00003EE2, 0x00000BE6, 0x00003EE4, 0x00000BDA, - 0x00003EE6, 0x00000BCE, 0x00003EE9, 0x00000BC1, - 0x00003EEB, 0x00000BB5, 0x00003EED, 0x00000BA9, - 0x00003EF0, 0x00000B9C, 0x00003EF2, 0x00000B90, - 0x00003EF4, 0x00000B83, 0x00003EF6, 0x00000B77, - 0x00003EF9, 0x00000B6B, 0x00003EFB, 0x00000B5E, - 0x00003EFD, 0x00000B52, 0x00003EFF, 0x00000B46, - 0x00003F02, 0x00000B39, 0x00003F04, 0x00000B2D, - 0x00003F06, 0x00000B21, 0x00003F08, 0x00000B14, - 0x00003F0A, 0x00000B08, 0x00003F0C, 0x00000AFB, - 0x00003F0F, 0x00000AEF, 0x00003F11, 0x00000AE3, - 0x00003F13, 0x00000AD6, 0x00003F15, 0x00000ACA, - 0x00003F17, 0x00000ABD, 0x00003F19, 0x00000AB1, - 0x00003F1B, 0x00000AA5, 0x00003F1D, 0x00000A98, - 0x00003F1F, 0x00000A8C, 0x00003F21, 0x00000A7F, - 0x00003F24, 0x00000A73, 0x00003F26, 0x00000A67, - 0x00003F28, 0x00000A5A, 0x00003F2A, 0x00000A4E, - 0x00003F2C, 0x00000A41, 0x00003F2E, 0x00000A35, - 0x00003F30, 0x00000A29, 0x00003F32, 0x00000A1C, - 0x00003F34, 0x00000A10, 0x00003F36, 0x00000A03, - 0x00003F38, 0x000009F7, 0x00003F3A, 0x000009EB, - 0x00003F3B, 0x000009DE, 0x00003F3D, 0x000009D2, - 0x00003F3F, 0x000009C5, 0x00003F41, 0x000009B9, - 0x00003F43, 0x000009AD, 0x00003F45, 0x000009A0, - 0x00003F47, 0x00000994, 0x00003F49, 0x00000987, - 0x00003F4B, 0x0000097B, 0x00003F4D, 0x0000096E, - 0x00003F4E, 0x00000962, 0x00003F50, 0x00000956, - 0x00003F52, 0x00000949, 0x00003F54, 0x0000093D, - 0x00003F56, 0x00000930, 0x00003F57, 0x00000924, - 0x00003F59, 0x00000917, 0x00003F5B, 0x0000090B, - 0x00003F5D, 0x000008FE, 0x00003F5F, 0x000008F2, - 0x00003F60, 0x000008E6, 0x00003F62, 0x000008D9, - 0x00003F64, 0x000008CD, 0x00003F66, 0x000008C0, - 0x00003F67, 0x000008B4, 0x00003F69, 0x000008A7, - 0x00003F6B, 0x0000089B, 0x00003F6C, 0x0000088E, - 0x00003F6E, 0x00000882, 0x00003F70, 0x00000876, - 0x00003F71, 0x00000869, 0x00003F73, 0x0000085D, - 0x00003F75, 0x00000850, 0x00003F76, 0x00000844, - 0x00003F78, 0x00000837, 0x00003F79, 0x0000082B, - 0x00003F7B, 0x0000081E, 0x00003F7D, 0x00000812, - 0x00003F7E, 0x00000805, 0x00003F80, 0x000007F9, - 0x00003F81, 0x000007EC, 0x00003F83, 0x000007E0, - 0x00003F84, 0x000007D4, 0x00003F86, 0x000007C7, - 0x00003F88, 0x000007BB, 0x00003F89, 0x000007AE, - 0x00003F8B, 0x000007A2, 0x00003F8C, 0x00000795, - 0x00003F8E, 0x00000789, 0x00003F8F, 0x0000077C, - 0x00003F90, 0x00000770, 0x00003F92, 0x00000763, - 0x00003F93, 0x00000757, 0x00003F95, 0x0000074A, - 0x00003F96, 0x0000073E, 0x00003F98, 0x00000731, - 0x00003F99, 0x00000725, 0x00003F9A, 0x00000718, - 0x00003F9C, 0x0000070C, 0x00003F9D, 0x000006FF, - 0x00003F9F, 0x000006F3, 0x00003FA0, 0x000006E6, - 0x00003FA1, 0x000006DA, 0x00003FA3, 0x000006CD, - 0x00003FA4, 0x000006C1, 0x00003FA5, 0x000006B4, - 0x00003FA7, 0x000006A8, 0x00003FA8, 0x0000069B, - 0x00003FA9, 0x0000068F, 0x00003FAA, 0x00000682, - 0x00003FAC, 0x00000676, 0x00003FAD, 0x00000669, - 0x00003FAE, 0x0000065D, 0x00003FB0, 0x00000650, - 0x00003FB1, 0x00000644, 0x00003FB2, 0x00000637, - 0x00003FB3, 0x0000062B, 0x00003FB4, 0x0000061E, - 0x00003FB6, 0x00000612, 0x00003FB7, 0x00000605, - 0x00003FB8, 0x000005F9, 0x00003FB9, 0x000005EC, - 0x00003FBA, 0x000005E0, 0x00003FBB, 0x000005D3, - 0x00003FBD, 0x000005C7, 0x00003FBE, 0x000005BA, - 0x00003FBF, 0x000005AE, 0x00003FC0, 0x000005A1, - 0x00003FC1, 0x00000595, 0x00003FC2, 0x00000588, - 0x00003FC3, 0x0000057C, 0x00003FC4, 0x0000056F, - 0x00003FC5, 0x00000563, 0x00003FC6, 0x00000556, - 0x00003FC7, 0x0000054A, 0x00003FC8, 0x0000053D, - 0x00003FCA, 0x00000531, 0x00003FCB, 0x00000524, - 0x00003FCC, 0x00000517, 0x00003FCD, 0x0000050B, - 0x00003FCE, 0x000004FE, 0x00003FCE, 0x000004F2, - 0x00003FCF, 0x000004E5, 0x00003FD0, 0x000004D9, - 0x00003FD1, 0x000004CC, 0x00003FD2, 0x000004C0, - 0x00003FD3, 0x000004B3, 0x00003FD4, 0x000004A7, - 0x00003FD5, 0x0000049A, 0x00003FD6, 0x0000048E, - 0x00003FD7, 0x00000481, 0x00003FD8, 0x00000475, - 0x00003FD9, 0x00000468, 0x00003FD9, 0x0000045B, - 0x00003FDA, 0x0000044F, 0x00003FDB, 0x00000442, - 0x00003FDC, 0x00000436, 0x00003FDD, 0x00000429, - 0x00003FDE, 0x0000041D, 0x00003FDE, 0x00000410, - 0x00003FDF, 0x00000404, 0x00003FE0, 0x000003F7, - 0x00003FE1, 0x000003EB, 0x00003FE2, 0x000003DE, - 0x00003FE2, 0x000003D2, 0x00003FE3, 0x000003C5, - 0x00003FE4, 0x000003B8, 0x00003FE4, 0x000003AC, - 0x00003FE5, 0x0000039F, 0x00003FE6, 0x00000393, - 0x00003FE7, 0x00000386, 0x00003FE7, 0x0000037A, - 0x00003FE8, 0x0000036D, 0x00003FE9, 0x00000361, - 0x00003FE9, 0x00000354, 0x00003FEA, 0x00000348, - 0x00003FEB, 0x0000033B, 0x00003FEB, 0x0000032E, - 0x00003FEC, 0x00000322, 0x00003FEC, 0x00000315, - 0x00003FED, 0x00000309, 0x00003FEE, 0x000002FC, - 0x00003FEE, 0x000002F0, 0x00003FEF, 0x000002E3, - 0x00003FEF, 0x000002D7, 0x00003FF0, 0x000002CA, - 0x00003FF0, 0x000002BD, 0x00003FF1, 0x000002B1, - 0x00003FF2, 0x000002A4, 0x00003FF2, 0x00000298, - 0x00003FF3, 0x0000028B, 0x00003FF3, 0x0000027F, - 0x00003FF4, 0x00000272, 0x00003FF4, 0x00000266, - 0x00003FF4, 0x00000259, 0x00003FF5, 0x0000024C, - 0x00003FF5, 0x00000240, 0x00003FF6, 0x00000233, - 0x00003FF6, 0x00000227, 0x00003FF7, 0x0000021A, - 0x00003FF7, 0x0000020E, 0x00003FF7, 0x00000201, - 0x00003FF8, 0x000001F5, 0x00003FF8, 0x000001E8, - 0x00003FF9, 0x000001DB, 0x00003FF9, 0x000001CF, - 0x00003FF9, 0x000001C2, 0x00003FFA, 0x000001B6, - 0x00003FFA, 0x000001A9, 0x00003FFA, 0x0000019D, - 0x00003FFB, 0x00000190, 0x00003FFB, 0x00000183, - 0x00003FFB, 0x00000177, 0x00003FFB, 0x0000016A, - 0x00003FFC, 0x0000015E, 0x00003FFC, 0x00000151, - 0x00003FFC, 0x00000145, 0x00003FFD, 0x00000138, - 0x00003FFD, 0x0000012C, 0x00003FFD, 0x0000011F, - 0x00003FFD, 0x00000112, 0x00003FFD, 0x00000106, - 0x00003FFE -}; -*/ diff --git a/apps/codecs/libwmapro/mdct_tables.h b/apps/codecs/libwmapro/mdct_tables.h deleted file mode 100644 index 5e54868b01..0000000000 --- a/apps/codecs/libwmapro/mdct_tables.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef _MDCT_TABLES_H_ -#define _MDCT_TABLES_H_ -#include - -extern const int32_t *sine_windows[6]; -/* rockbox: not used -extern const int32_t sincos_lookup_wmap[8064]; -*/ -#endif /* _MDCT_TABLES_H_ */ - diff --git a/apps/codecs/libwmapro/quant.h b/apps/codecs/libwmapro/quant.h deleted file mode 100644 index 3500615fde..0000000000 --- a/apps/codecs/libwmapro/quant.h +++ /dev/null @@ -1,53 +0,0 @@ -#ifndef _QUANT_H_ -#define _QUANT_H_ - -#include - -/* This table contains unscaled integer casts of the floating point inverse - * quantization factors used by wma pro. The formula for calculating the - * floating point value is : - * quant = pow(10.0, exp/20) - * 'exp' is an integer value which I have exmerimentally found to fall in the - * range (50,170). */ -const int32_t quant_tab[121] = { - 0x0000013C, 0x00000163, 0x0000018E, 0x000001BF, - 0x000001F5, 0x00000232, 0x00000277, 0x000002C4, - 0x0000031A, 0x0000037B, 0x000003E8, 0x00000462, - 0x000004EB, 0x00000585, 0x00000631, 0x000006F2, - 0x000007CB, 0x000008BF, 0x000009D0, 0x00000B02, - 0x00000C5A, 0x00000DDC, 0x00000F8D, 0x00001173, - 0x00001394, 0x000015F7, 0x000018A6, 0x00001BA7, - 0x00001F07, 0x000022D1, 0x00002710, 0x00002BD4, - 0x0000312D, 0x0000372D, 0x00003DE9, 0x00004577, - 0x00004DF1, 0x00005773, 0x0000621F, 0x00006E18, - 0x00007B87, 0x00008A99, 0x00009B83, 0x0000AE7C, - 0x0000C3C7, 0x0000DBAA, 0x0000F678, 0x0001148B, - 0x00013649, 0x00015C25, 0x000186A0, 0x0001B64A, - 0x0001EBC5, 0x000227C6, 0x00026B19, 0x0002B6A4, - 0x00030B66, 0x00036A80, 0x0003D535, 0x00044CEE, - 0x0004D344, 0x000569FD, 0x0006131B, 0x0006D0DC, - 0x0007A5C3, 0x000894A5, 0x0009A0AD, 0x000ACD6A, - 0x000C1ED8, 0x000D9973, 0x000F4240, 0x00111EE2, - 0x001335AD, 0x00158DBA, 0x00182EFD, 0x001B2267, - 0x001E71FE, 0x00222901, 0x0026540E, 0x002B014F, - 0x003040A6, 0x003623E6, 0x003CBF10, 0x00442894, - 0x004C79A0, 0x0055CE75, 0x006046C5, 0x006C0622, - 0x00793472, 0x0087FE7D, 0x00989680, 0x00AB34D9, - 0x00C018C6, 0x00D7893F, 0x00F1D5E4, 0x010F580A, - 0x013073EF, 0x01559A0B, 0x017F4890, 0x01AE0D15, - 0x01E28679, 0x021D66FB, 0x025F769D, 0x02A995C7, - 0x02FCC043, 0x035A1095, 0x03C2C3B6, 0x04383D52, - 0x04BC0C77, 0x054FF0E6, 0x05F5E100, 0x06B01075, - 0x0780F7BD, 0x086B5C7A, 0x09725AE7, 0x0A997065, - 0x0BE48757, 0x0D580472, 0x0EF8D5A3, 0x10CC82D5, - 0x12D940B6 -}; - -#define EXP_MIN 50 -#define EXP_MAX 170 - -/* return the correct value of quant based on exp */ -#define QUANT(exp) quant_tab[exp - EXP_MIN] - - -#endif /* _QUANT_H_ */ diff --git a/apps/codecs/libwmapro/wma.c b/apps/codecs/libwmapro/wma.c deleted file mode 100644 index 83cec89a4c..0000000000 --- a/apps/codecs/libwmapro/wma.c +++ /dev/null @@ -1,164 +0,0 @@ -/* - * WMA compatible codec - * Copyright (c) 2002-2007 The FFmpeg Project - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "wma.h" -#include "codeclib.h" /* needed for av_log2() */ - -/** - *@brief Get the samples per frame for this stream. - *@param sample_rate output sample_rate - *@param version wma version - *@param decode_flags codec compression features - *@return log2 of the number of output samples per frame - */ -int ff_wma_get_frame_len_bits(int sample_rate, int version, - unsigned int decode_flags) -{ - - int frame_len_bits; - - if (sample_rate <= 16000) { - frame_len_bits = 9; - } else if (sample_rate <= 22050 || - (sample_rate <= 32000 && version == 1)) { - frame_len_bits = 10; - } else if (sample_rate <= 48000) { - frame_len_bits = 11; - } else if (sample_rate <= 96000) { - frame_len_bits = 12; - } else { - frame_len_bits = 13; - } - - if (version == 3) { - int tmp = decode_flags & 0x6; - if (tmp == 0x2) { - ++frame_len_bits; - } else if (tmp == 0x4) { - --frame_len_bits; - } else if (tmp == 0x6) { - frame_len_bits -= 2; - } - } - - return frame_len_bits; -} - -/** - * Decode an uncompressed coefficient. - * @param s codec context - * @return the decoded coefficient - */ -unsigned int ff_wma_get_large_val(GetBitContext* gb) -{ - /** consumes up to 34 bits */ - int n_bits = 8; - /** decode length */ - if (get_bits1(gb)) { - n_bits += 8; - if (get_bits1(gb)) { - n_bits += 8; - if (get_bits1(gb)) { - n_bits += 7; - } - } - } - return get_bits_long(gb, n_bits); -} - -/** - * Decode run level compressed coefficients. - * @param avctx codec context - * @param gb bitstream reader context - * @param vlc vlc table for get_vlc2 - * @param level_table level codes - * @param run_table run codes - * @param version 0 for wma1,2 1 for wmapro - * @param ptr output buffer - * @param offset offset in the output buffer - * @param num_coefs number of input coefficents - * @param block_len input buffer length (2^n) - * @param frame_len_bits number of bits for escaped run codes - * @param coef_nb_bits number of bits for escaped level codes - * @return 0 on success, -1 otherwise - */ -#define av_log(...) -int ff_wma_run_level_decode(GetBitContext* gb, - VLC *vlc, - const int32_t *level_table, const uint16_t *run_table, - int version, int32_t *ptr, int offset, - int num_coefs, int block_len, int frame_len_bits, - int coef_nb_bits) -{ - int32_t code, level, sign; - const unsigned int coef_mask = block_len - 1; - /* Rockbox: To be able to use rockbox' optimized mdct we need to pre-shift - * the values by >>(nbits-3). */ - const int nbits = av_log2(block_len)+1; - const int shift = WMAPRO_FRACT-(nbits-3); - for (; offset < num_coefs; offset++) { - code = get_vlc2(gb, vlc->table, VLCBITS, VLCMAX); - if (code > 1) { - /** normal code */ - offset += run_table[code]; - sign = !get_bits1(gb); - /* Rockbox: To be able to use rockbox' optimized mdct we need - * invert the sign. */ - ptr[offset & coef_mask] = sign ? level_table[code] : -level_table[code]; - ptr[offset & coef_mask] <<= shift; - } else if (code == 1) { - /** EOB */ - break; - } else { - /** escape */ - if (!version) { - level = get_bits(gb, coef_nb_bits); - /** NOTE: this is rather suboptimal. reading - block_len_bits would be better */ - offset += get_bits(gb, frame_len_bits); - } else { - level = ff_wma_get_large_val(gb); - /** escape decode */ - if (get_bits1(gb)) { - if (get_bits1(gb)) { - if (get_bits1(gb)) { - av_log(avctx,AV_LOG_ERROR, - "broken escape sequence\n"); - return -1; - } else - offset += get_bits(gb, frame_len_bits) + 4; - } else - offset += get_bits(gb, 2) + 1; - } - } - sign = !get_bits1(gb); - ptr[offset & coef_mask] = sign ? level : -level; - ptr[offset & coef_mask] <<= shift; - } - } - /** NOTE: EOB can be omitted */ - if (offset > num_coefs) { - av_log(avctx, AV_LOG_ERROR, "overflow in spectral RLE, ignoring\n"); - return -1; - } - - return 0; -} diff --git a/apps/codecs/libwmapro/wma.h b/apps/codecs/libwmapro/wma.h deleted file mode 100644 index 6fa7b94724..0000000000 --- a/apps/codecs/libwmapro/wma.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - * WMA compatible codec - * Copyright (c) 2002-2007 The FFmpeg Project - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef AVCODEC_WMA_H -#define AVCODEC_WMA_H - -#include "ffmpeg_get_bits.h" -#include "ffmpeg_put_bits.h" - -#define WMAPRO_FRACT (17) -#define WMAPRO_DSP_SAMPLE_DEPTH (WMAPRO_FRACT + 8) - -/* size of blocks */ -#define BLOCK_MIN_BITS 7 -#define BLOCK_MAX_BITS 11 -#define BLOCK_MAX_SIZE (1 << BLOCK_MAX_BITS) - -#define BLOCK_NB_SIZES (BLOCK_MAX_BITS - BLOCK_MIN_BITS + 1) - -/* XXX: find exact max size */ -#define HIGH_BAND_MAX_SIZE 16 - -#define NB_LSP_COEFS 10 - -/* XXX: is it a suitable value ? */ -#define MAX_CODED_SUPERFRAME_SIZE 16384 - -#define MAX_CHANNELS 2 - -#define NOISE_TAB_SIZE 8192 - -#define LSP_POW_BITS 7 - -//FIXME should be in wmadec -#define VLCBITS 9 -#define VLCMAX ((22+VLCBITS-1)/VLCBITS) - -typedef struct CoefVLCTable { - int n; ///< total number of codes - int max_level; - const uint32_t *huffcodes; ///< VLC bit values - const uint8_t *huffbits; ///< VLC bit size - const uint16_t *levels; ///< table to build run/level tables -} CoefVLCTable; - - -int ff_wma_get_frame_len_bits(int sample_rate, int version, - unsigned int decode_flags); -unsigned int ff_wma_get_large_val(GetBitContext* gb); -int ff_wma_run_level_decode(GetBitContext* gb, - VLC *vlc, - const int32_t *level_table, const uint16_t *run_table, - int version, int32_t *ptr, int offset, - int num_coefs, int block_len, int frame_len_bits, - int coef_nb_bits); - -#endif /* AVCODEC_WMA_H */ diff --git a/apps/codecs/libwmapro/wmapro_math.h b/apps/codecs/libwmapro/wmapro_math.h deleted file mode 100644 index c78d6b627f..0000000000 --- a/apps/codecs/libwmapro/wmapro_math.h +++ /dev/null @@ -1,250 +0,0 @@ -#ifndef _WMAPRO_MATH_H_ -#define _WMAPRO_MATH_H_ - -#include - -/* rockbox: not used -#define fixtof16(x) (float)((float)(x) / (float)(1 << 16)) -#define fixtof31(x) (float)((float)(x) / (float)(1 << 31)) -#define ftofix16(x) ((int32_t)((x) * (float)(1 << 16) + ((x) < 0 ? -0.5:0.5))) -#define ftofix31(x) ((int32_t)((x) * (float)(1 << 31) + ((x) < 0 ? -0.5:0.5))) -*/ - -#if defined(CPU_ARM) - /* Calculates: result = (X*Y)>>Z */ - #define fixmulshift(X,Y,Z) \ - ({ \ - int32_t lo; \ - int32_t hi; \ - asm volatile ( \ - "smull %[lo], %[hi], %[x], %[y] \n\t" /* multiply */ \ - "mov %[lo], %[lo], lsr %[shr] \n\t" /* lo >>= Z */ \ - "orr %[lo], %[lo], %[hi], lsl %[shl]" /* lo |= (hi << (32-Z)) */ \ - : [lo]"=&r"(lo), [hi]"=&r"(hi) \ - : [x]"r"(X), [y]"r"(Y), [shr]"r"(Z), [shl]"r"(32-Z)); \ - lo; \ - }) - - /* Calculates: result = (X*Y)>>16 */ - #define fixmul16(X,Y) \ - ({ \ - int32_t lo; \ - int32_t hi; \ - asm volatile ( \ - "smull %[lo], %[hi], %[x], %[y] \n\t" /* multiply */ \ - "mov %[lo], %[lo], lsr #16 \n\t" /* lo >>= 16 */ \ - "orr %[lo], %[lo], %[hi], lsl #16" /* lo |= (hi << 16) */ \ - : [lo]"=&r"(lo), [hi]"=&r"(hi) \ - : [x]"r"(X), [y]"r"(Y)); \ - lo; \ - }) - - /* Calculates: result = (X*Y)>>24 */ - #define fixmul24(X,Y) \ - ({ \ - int32_t lo; \ - int32_t hi; \ - asm volatile ( \ - "smull %[lo], %[hi], %[x], %[y] \n\t" /* multiply */ \ - "mov %[lo], %[lo], lsr #24 \n\t" /* lo >>= 24 */ \ - "orr %[lo], %[lo], %[hi], lsl #8" /* lo |= (hi << 8) */ \ - : [lo]"=&r"(lo), [hi]"=&r"(hi) \ - : [x]"r"(X), [y]"r"(Y)); \ - lo; \ - }) - - /* Calculates: result = (X*Y)>>31, loose 1 bit precision */ - #define fixmul31(X,Y) \ - ({ \ - int32_t lo; \ - int32_t hi; \ - asm volatile ( \ - "smull %[lo], %[hi], %[x], %[y] \n\t" /* multiply */ \ - "mov %[hi], %[hi], lsl #1" /* hi <<= 1 */ \ - : [lo]"=&r"(lo), [hi]"=&r"(hi) \ - : [x]"r"(X), [y]"r"(Y)); \ - hi; \ - }) -#elif defined(CPU_COLDFIRE) - /* Calculates: result = (X*Y)>>Z */ - #define fixmulshift(X,Y,Z) \ - ({ \ - int32_t t1; \ - int32_t t2; \ - asm volatile ( \ - "mac.l %[x],%[y],%%acc0\n\t" /* multiply */ \ - "mulu.l %[y],%[x] \n\t" /* get lower half, avoid emac stall */ \ - "movclr.l %%acc0,%[t1] \n\t" /* get higher half */ \ - "moveq.l #31,%[t2] \n\t" \ - "sub.l %[sh],%[t2] \n\t" /* t2 = 31 - shift */ \ - "ble.s 1f \n\t" \ - "asl.l %[t2],%[t1] \n\t" /* hi <<= 31 - shift */ \ - "lsr.l %[sh],%[x] \n\t" /* (unsigned)lo >>= shift */ \ - "or.l %[x],%[t1] \n\t" /* combine result */ \ - "bra.s 2f \n\t" \ - "1: \n\t" \ - "neg.l %[t2] \n\t" /* t2 = shift - 31 */ \ - "asr.l %[t2],%[t1] \n\t" /* hi >>= t2 */ \ - "2: \n" \ - : [t1]"=&d"(t1), [t2]"=&d"(t2) \ - : [x] "d"((X)), [y] "d"((Y)), [sh]"d"((Z))); \ - t1; \ - }) - - /* Calculates: result = (X*Y)>>16 */ - #define fixmul16(X,Y) \ - ({ \ - int32_t t, x = (X); \ - asm volatile ( \ - "mac.l %[x],%[y],%%acc0\n\t" /* multiply */ \ - "mulu.l %[y],%[x] \n\t" /* get lower half, avoid emac stall */ \ - "movclr.l %%acc0,%[t] \n\t" /* get higher half */ \ - "lsr.l #1,%[t] \n\t" /* hi >>= 1 to compensate emac shift */ \ - "move.w %[t],%[x] \n\t" /* combine halfwords */\ - "swap %[x] \n\t" \ - : [t]"=&d"(t), [x] "+d" (x) \ - : [y] "d" ((Y))); \ - x; \ - }) - - /* Calculates: result = (X*Y)>>31 (may lose msb to overflow) */ - #define fixmul31(X,Y) \ - ({ \ - int32_t t; \ - asm volatile ( \ - "mac.l %[x], %[y], %%acc0\n\t" /* multiply */ \ - "movclr.l %%acc0, %[t]\n\t" /* get higher half as result */ \ - : [t] "=d" (t) \ - : [x] "r" ((X)), [y] "r" ((Y))); \ - t; \ - }) -#else - static inline int32_t fixmulshift(int32_t x, int32_t y, int shamt) - { - int64_t temp; - temp = x; - temp *= y; - - temp >>= shamt; - - return (int32_t)temp; - } - - static inline int32_t fixmul31(int32_t x, int32_t y) - { - int64_t temp; - temp = x; - temp *= y; - - temp >>= 31; - - return (int32_t)temp; - } - - static inline int32_t fixmul24(int32_t x, int32_t y) - { - int64_t temp; - temp = x; - temp *= y; - - temp >>= 24; - - return (int32_t)temp; - } - - static inline int32_t fixmul16(int32_t x, int32_t y) - { - int64_t temp; - temp = x; - temp *= y; - - temp >>= 16; - - return (int32_t)temp; - } -#endif /* CPU_COLDFIRE, CPU_ARM */ - -#if defined(CPU_COLDFIRE) - #define VECT_MUL_WIN_KERNEL(i, j, s0, s1, wi, wj) \ - asm volatile ( \ - "mac.l %[s0], %[wj], %%acc0 \n\t" \ - "msac.l %[s1], %[wi], %%acc0 \n\t" \ - "mac.l %[s0], %[wi], %%acc1 \n\t" \ - "mac.l %[s1], %[wj], %%acc1 \n\t" \ - "movclr.l %%acc0, %[s0] \n\t" \ - "move.l %[s0], (%[dst_i]) \n\t" \ - "movclr.l %%acc1, %[s0] \n\t" \ - "move.l %[s0], (%[dst_j]) \n\t" \ - : [s0] "+r" (s0) /* register is clobbered so specify it as an input */ \ - : [dst_i] "a" (&dst[i]), [dst_j] "a" (&dst[j]), \ - [s1] "r" (s1), [wi] "r" (wi), [wj] "r" (wj) \ - : "cc", "memory"); -#else - #define VECT_MUL_WIN_KERNEL(i, j, s0, s1, wi, wj) \ - dst[i] = fixmul31(wj, s0) - fixmul31(wi, s1); \ - dst[j] = fixmul31(wi, s0) + fixmul31(wj, s1); -#endif /* CPU_COLDFIRE */ - -static inline void vector_fixmul_window(int32_t *dst, const int32_t *src0, - const int32_t *src1, const int32_t *win, - int len) -{ - int i, j; - dst += len; - win += len; - src0+= len; - for(i=-len, j=len-1; i<0; i++, j--) { - int32_t s0 = src0[i]; /* s0 = src0[ 0 ... len-1] */ - int32_t s1 = src1[j]; /* s1 = src1[2*len-1 ... len] */ - int32_t wi = -win[i]; /* wi = -win[ 0 ... len-1] */ - int32_t wj = -win[j]; /* wj = -win[2*len-1 ... len] */ - VECT_MUL_WIN_KERNEL(i, j, s0, s1, wi, wj); - } -} - -#if defined(CPU_ARM) - #define VECT_MUL_SCALAR_KERNEL(dst, src, mul) \ - asm volatile ( \ - "ldmia %[src]!, {r1-r4} \n\t" \ - "smull r0, r5, r1, %[mul] \n\t" \ - "mov r0, r0, lsr #16 \n\t" \ - "orr r0, r0, r5, lsl #16\n\t" \ - "smull r1, r5, r2, %[mul] \n\t" \ - "mov r1, r1, lsr #16 \n\t" \ - "orr r1, r1, r5, lsl #16\n\t" \ - "smull r2, r5, r3, %[mul] \n\t" \ - "mov r2, r2, lsr #16 \n\t" \ - "orr r2, r2, r5, lsl #16\n\t" \ - "smull r3, r5, r4, %[mul] \n\t" \ - "mov r3, r3, lsr #16 \n\t" \ - "orr r3, r3, r5, lsl #16\n\t" \ - "stmia %[dst]!, {r0-r3} \n" \ - : [dst]"+r"(dst), [src]"+r"(src) \ - : [mul]"r"(mul) \ - : "r0", "r1", "r2", "r3", "r4", "r5", "memory"); -#else - #define VECT_MUL_SCALAR_KERNEL(dst, src, mul) \ - dst[i ] = fixmul16(src[i ], mul); \ - dst[i+1] = fixmul16(src[i+1], mul); \ - dst[i+2] = fixmul16(src[i+2], mul); \ - dst[i+3] = fixmul16(src[i+3], mul); -#endif /* CPU_ARM, CPU_COLDFIRE */ - -static inline void vector_fixmul_scalar(int32_t *dst, const int32_t *src, - int32_t mul, int len) -{ - /* len is _always_ a multiple of 4, because len is the difference of sfb's - * which themselves are always a multiple of 4. */ - int i; - for (i=0; i amax) return amax; - else return a; -} -#endif /* _WMAPRO_MATH_H_ */ diff --git a/apps/codecs/libwmapro/wmaprodata.h b/apps/codecs/libwmapro/wmaprodata.h deleted file mode 100644 index 94762f7dbf..0000000000 --- a/apps/codecs/libwmapro/wmaprodata.h +++ /dev/null @@ -1,615 +0,0 @@ -/* - * WMA 9/3/PRO compatible decoder - * Copyright (c) 2007 Baptiste Coudurier, Benjamin Larsson, Ulion - * Copyright (c) 2008 - 2009 Sascha Sommer - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/** - * @file libavcodec/wmaprodata.h - * @brief tables for wmapro decoding - */ - -#ifndef AVCODEC_WMAPRODATA_H -#define AVCODEC_WMAPRODATA_H - -#include -#include - -/* rockbox: not used -const int32_t fixed_sin64[33] = { - 0x00000000, 0xF9B82685, 0xF3742CA3, 0xED37EF92, 0xE70747C5, 0xE0E60686, - 0xDAD7F3A3, 0xD4E0CB16, 0xCF043AB4, 0xC945DFED, 0xC3A94591, 0xBE31E19C, - 0xB8E3131A, 0xB3C0200D, 0xAECC336D, 0xAA0A5B2F, 0xA57D8667, 0xA1288377, - 0x9D0DFE55, 0x99307EE1, 0x9592675D, 0x9235F2ED, 0x8F1D343B, 0x8C4A1430, - 0x89BE50C4, 0x877B7BED, 0x8582FAA6, 0x83D60413, 0x8275A0C1, 0x8162AA05, - 0x809DC972, 0x80277873, 0x80000001, -}; -*/ -/** - * @brief frequencies to divide the frequency spectrum into scale factor bands - */ -static const uint16_t critical_freq[] = { - 100, 200, 300, 400, 510, 630, 770, - 920, 1080, 1270, 1480, 1720, 2000, 2320, - 2700, 3150, 3700, 4400, 5300, 6400, 7700, - 9500, 12000, 15500, 20675, 28575, 41375, 63875, -}; - -/** - * @name Huffman tables for DPCM-coded scale factors - * @{ - */ -#define HUFF_SCALE_SIZE 121 -#define HUFF_SCALE_MAXBITS 19 -static const uint16_t scale_huffcodes[HUFF_SCALE_SIZE] = { - 0xE639, 0xE6C2, 0xE6C1, 0xE6C0, 0xE63F, 0xE63E, 0xE63D, 0xE63C, - 0xE63B, 0xE63A, 0xE638, 0xE637, 0xE636, 0xE635, 0xE634, 0xE632, - 0xE633, 0xE620, 0x737B, 0xE610, 0xE611, 0xE612, 0xE613, 0xE614, - 0xE615, 0xE616, 0xE617, 0xE618, 0xE619, 0xE61A, 0xE61B, 0xE61C, - 0xE61D, 0xE61E, 0xE61F, 0xE6C3, 0xE621, 0xE622, 0xE623, 0xE624, - 0xE625, 0xE626, 0xE627, 0xE628, 0xE629, 0xE62A, 0xE62B, 0xE62C, - 0xE62D, 0xE62E, 0xE62F, 0xE630, 0xE631, 0x1CDF, 0x0E60, 0x0399, - 0x00E7, 0x001D, 0x0000, 0x0001, 0x0001, 0x0001, 0x0002, 0x0006, - 0x0002, 0x0007, 0x0006, 0x000F, 0x0038, 0x0072, 0x039A, 0xE6C4, - 0xE6C5, 0xE6C6, 0xE6C7, 0xE6C8, 0xE6C9, 0xE6CA, 0xE6CB, 0xE6CC, - 0xE6CD, 0xE6CE, 0xE6CF, 0xE6D0, 0xE6D1, 0xE6D2, 0xE6D3, 0xE6D4, - 0xE6D5, 0xE6D6, 0xE6D7, 0xE6D8, 0xE6D9, 0xE6DA, 0xE6DB, 0xE6DC, - 0xE6DD, 0xE6DE, 0xE6DF, 0xE6E0, 0xE6E1, 0xE6E2, 0xE6E3, 0xE6E4, - 0xE6E5, 0xE6E6, 0xE6E7, 0xE6E8, 0xE6E9, 0xE6EA, 0xE6EB, 0xE6EC, - 0xE6ED, 0xE6EE, 0xE6EF, 0xE6F0, 0xE6F1, 0xE6F2, 0xE6F3, 0xE6F4, - 0xE6F5, -}; - -static const uint8_t scale_huffbits[HUFF_SCALE_SIZE] = { - 19, 19, 19, 19, 19, 19, 19, 19, - 19, 19, 19, 19, 19, 19, 19, 19, - 19, 19, 18, 19, 19, 19, 19, 19, - 19, 19, 19, 19, 19, 19, 19, 19, - 19, 19, 19, 19, 19, 19, 19, 19, - 19, 19, 19, 19, 19, 19, 19, 19, - 19, 19, 19, 19, 19, 16, 15, 13, - 11, 8, 5, 2, 1, 3, 5, 6, - 6, 7, 7, 7, 9, 10, 13, 19, - 19, 19, 19, 19, 19, 19, 19, 19, - 19, 19, 19, 19, 19, 19, 19, 19, - 19, 19, 19, 19, 19, 19, 19, 19, - 19, 19, 19, 19, 19, 19, 19, 19, - 19, 19, 19, 19, 19, 19, 19, 19, - 19, 19, 19, 19, 19, 19, 19, 19, - 19, -}; -/** @} */ - - -/** - * @name Huffman, run and level tables for runlevel-coded scale factors - * @{ - */ -#define HUFF_SCALE_RL_SIZE 120 -#define HUFF_SCALE_RL_MAXBITS 21 -static const uint32_t scale_rl_huffcodes[HUFF_SCALE_RL_SIZE] = { - 0x00010C, 0x000001, 0x10FE2A, 0x000003, 0x000003, 0x000001, 0x000013, - 0x000020, 0x000029, 0x000014, 0x000016, 0x000045, 0x000049, 0x00002F, - 0x000042, 0x00008E, 0x00008F, 0x000129, 0x000009, 0x00000D, 0x0004AC, - 0x00002C, 0x000561, 0x0002E6, 0x00087C, 0x0002E2, 0x00095C, 0x000018, - 0x000001, 0x000016, 0x000044, 0x00002A, 0x000007, 0x000159, 0x000143, - 0x000128, 0x00015A, 0x00012D, 0x00002B, 0x0000A0, 0x000142, 0x00012A, - 0x0002EF, 0x0004AF, 0x00087D, 0x004AE9, 0x0043F9, 0x000067, 0x000199, - 0x002B05, 0x001583, 0x0021FE, 0x10FE2C, 0x000004, 0x00002E, 0x00010D, - 0x00000A, 0x000244, 0x000017, 0x000245, 0x000011, 0x00010E, 0x00012C, - 0x00002A, 0x00002F, 0x000121, 0x000046, 0x00087E, 0x0000BA, 0x000032, - 0x0087F0, 0x0056DC, 0x0002EC, 0x0043FA, 0x002B6F, 0x004AE8, 0x0002B7, - 0x10FE2B, 0x000001, 0x000051, 0x000010, 0x0002EE, 0x000B9C, 0x002576, - 0x000198, 0x0056DD, 0x0000CD, 0x000AC0, 0x000170, 0x004AEF, 0x00002D, - 0x0004AD, 0x0021FF, 0x0005CF, 0x002B04, 0x10FE29, 0x10FE28, 0x0002ED, - 0x002E74, 0x021FC4, 0x004AEE, 0x010FE3, 0x087F17, 0x000000, 0x000097, - 0x0002E3, 0x000ADA, 0x002575, 0x00173B, 0x0043FB, 0x002E75, 0x10FE2D, - 0x0015B6, 0x00056C, 0x000057, 0x000123, 0x000120, 0x00021E, 0x000172, - 0x0002B1, -}; - -static const uint8_t scale_rl_huffbits[HUFF_SCALE_RL_SIZE] = { - 9, 2, 21, 2, 4, 5, 5, - 6, 6, 7, 7, 7, 7, 6, - 7, 8, 8, 9, 10, 10, 11, - 12, 11, 12, 12, 12, 12, 11, - 4, 5, 7, 8, 9, 9, 9, - 9, 9, 9, 8, 8, 9, 9, - 12, 11, 12, 15, 15, 13, 15, - 14, 13, 14, 21, 5, 6, 9, - 10, 10, 11, 10, 11, 9, 9, - 6, 8, 9, 7, 12, 10, 12, - 16, 15, 12, 15, 14, 15, 10, - 21, 6, 7, 11, 12, 14, 14, - 15, 15, 14, 12, 11, 15, 12, - 11, 14, 13, 14, 21, 21, 12, - 16, 18, 15, 17, 20, 7, 8, - 12, 12, 14, 15, 15, 16, 21, - 13, 11, 7, 9, 9, 10, 11, - 10, -}; - - -static const uint8_t scale_rl_run[HUFF_SCALE_RL_SIZE] = { - 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, - 16, 17, 18, 19, 20, 21, 22, 23, 24, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, - 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 0, 1, 2, 3, - 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, - 23, 24, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, - 17, 18, 19, 20, 21, 22, 23, 24, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, - 0, 1, 0, 1, 0, 1, -}; - -static const uint8_t scale_rl_level[HUFF_SCALE_RL_SIZE] = { - 0, 0, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, - 7, 7, 8, 8, 9, 9, -}; -/** @} */ - - -/** - * @name Huffman, run and level codes for runlevel-coded coefficients - * @{ - */ -#define HUFF_COEF0_SIZE 272 -#define HUFF_COEF0_MAXBITS 21 -static const uint32_t coef0_huffcodes[HUFF_COEF0_SIZE] = { - 0x00004A, 0x00002B, 0x000000, 0x000003, 0x000006, 0x000009, 0x00000F, - 0x000010, 0x000016, 0x000011, 0x000016, 0x000028, 0x00002F, 0x000026, - 0x000029, 0x000045, 0x000055, 0x00005D, 0x000042, 0x00004E, 0x000051, - 0x00005E, 0x00008D, 0x0000A8, 0x0000AD, 0x000080, 0x000096, 0x00009F, - 0x0000AA, 0x0000BE, 0x00011C, 0x000153, 0x000158, 0x000170, 0x000104, - 0x00010D, 0x000105, 0x000103, 0x00012F, 0x000177, 0x000175, 0x000157, - 0x000174, 0x000225, 0x00023B, 0x00020D, 0x00021F, 0x000281, 0x00027B, - 0x000282, 0x0002AC, 0x0002FD, 0x00044F, 0x000478, 0x00044D, 0x0002EC, - 0x00044E, 0x000564, 0x000409, 0x00040B, 0x000501, 0x000545, 0x0004F3, - 0x000541, 0x00043B, 0x0004F1, 0x0004F4, 0x0008FD, 0x000A94, 0x000811, - 0x000B88, 0x000B91, 0x000B93, 0x0008EA, 0x000899, 0x000B8A, 0x000972, - 0x0009E5, 0x000A8F, 0x000A84, 0x000A8E, 0x000A00, 0x000830, 0x0008E8, - 0x000B95, 0x000871, 0x00083A, 0x000814, 0x000873, 0x000BFE, 0x001728, - 0x001595, 0x001712, 0x00102A, 0x001021, 0x001729, 0x00152E, 0x0013C3, - 0x001721, 0x001597, 0x00151B, 0x0010F2, 0x001403, 0x001703, 0x001503, - 0x001708, 0x0013C1, 0x00170E, 0x00170C, 0x0010E1, 0x0011EA, 0x001020, - 0x001500, 0x0017FA, 0x001704, 0x001705, 0x0017F0, 0x0017FB, 0x0021E6, - 0x002B2D, 0x0020C6, 0x002B29, 0x002E4A, 0x0023AC, 0x001519, 0x0023F3, - 0x002B2C, 0x0021C0, 0x0017FE, 0x0023D7, 0x0017F9, 0x0012E7, 0x0013C0, - 0x002261, 0x0023D3, 0x002057, 0x002056, 0x0021D2, 0x0020C7, 0x0023D2, - 0x0020EC, 0x0044C0, 0x002FE2, 0x00475B, 0x002A03, 0x002FE3, 0x0021E2, - 0x0021D0, 0x002A31, 0x002E13, 0x002E05, 0x0047E5, 0x00000E, 0x000024, - 0x000088, 0x0000B9, 0x00010C, 0x000224, 0x0002B3, 0x000283, 0x0002ED, - 0x00047B, 0x00041E, 0x00043D, 0x0004F5, 0x0005FD, 0x000A92, 0x000B96, - 0x000838, 0x000971, 0x000B83, 0x000B80, 0x000BF9, 0x0011D3, 0x0011E8, - 0x0011D7, 0x001527, 0x0011F8, 0x001073, 0x0010F0, 0x0010E4, 0x0017F8, - 0x001062, 0x001402, 0x0017E3, 0x00151A, 0x001077, 0x00152B, 0x00170D, - 0x0021D3, 0x002E41, 0x0013C2, 0x000029, 0x0000A9, 0x00025D, 0x000419, - 0x000544, 0x000B8B, 0x0009E4, 0x0011D2, 0x001526, 0x001724, 0x0012E6, - 0x00150B, 0x0017FF, 0x002E26, 0x002E4B, 0x002B28, 0x0021E3, 0x002A14, - 0x00475A, 0x002E12, 0x000057, 0x00023E, 0x000A90, 0x000BF0, 0x001072, - 0x001502, 0x0023D6, 0x0020ED, 0x002A30, 0x0044C7, 0x00008C, 0x00047F, - 0x00152A, 0x002262, 0x002E04, 0x0000A1, 0x0005F9, 0x000173, 0x000875, - 0x000171, 0x00152D, 0x0002E3, 0x0017E2, 0x0002AD, 0x0021C1, 0x000479, - 0x0021E7, 0x00041F, 0x005C4E, 0x000543, 0x005C4F, 0x000A91, 0x00898D, - 0x000B97, 0x008746, 0x000970, 0x008745, 0x000B85, 0x00A856, 0x00152F, - 0x010E8E, 0x0010E5, 0x00A857, 0x00170F, 0x021D11, 0x002A58, 0x010E8F, - 0x002E40, 0x021D13, 0x002A59, 0x043A25, 0x002A02, 0x043A21, 0x0044C1, - 0x087448, 0x0047E4, 0x043A20, 0x00542A, 0x087449, 0x00898C, -}; - -static const uint8_t coef0_huffbits[HUFF_COEF0_SIZE] = { - 8, 7, 2, 3, 3, 4, 4, - 5, 5, 6, 6, 6, 6, 7, - 7, 7, 7, 7, 8, 8, 8, - 8, 8, 8, 8, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 10, - 10, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 11, 11, 11, 11, - 11, 11, 11, 11, 11, 11, 11, - 11, 11, 12, 12, 12, 12, 12, - 12, 12, 12, 12, 12, 12, 13, - 12, 12, 12, 12, 12, 12, 13, - 13, 13, 13, 13, 13, 13, 12, - 12, 13, 13, 13, 13, 13, 13, - 13, 13, 14, 14, 13, 13, 14, - 13, 13, 14, 14, 14, 14, 14, - 14, 14, 14, 14, 14, 13, 14, - 14, 14, 14, 14, 14, 14, 15, - 14, 15, 14, 14, 14, 14, 14, - 14, 15, 14, 14, 14, 14, 14, - 14, 14, 15, 15, 15, 15, 14, - 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 4, 7, - 8, 9, 10, 10, 10, 11, 11, - 11, 12, 12, 12, 12, 12, 12, - 13, 13, 13, 13, 13, 13, 13, - 13, 13, 13, 14, 14, 14, 14, - 14, 14, 14, 14, 14, 13, 14, - 15, 14, 14, 6, 9, 11, 12, - 12, 12, 13, 13, 13, 13, 14, - 14, 14, 14, 14, 14, 15, 15, - 15, 15, 7, 10, 12, 13, 14, - 14, 14, 15, 15, 15, 8, 11, - 13, 14, 15, 9, 12, 9, 13, - 10, 13, 10, 14, 11, 15, 11, - 15, 12, 15, 12, 15, 12, 16, - 12, 17, 13, 17, 13, 17, 13, - 18, 14, 17, 14, 19, 14, 18, - 14, 19, 14, 20, 15, 20, 15, - 21, 15, 20, 16, 21, 16, -}; - - -#define HUFF_COEF1_SIZE 244 -#define HUFF_COEF1_MAXBITS 22 -static const uint32_t coef1_huffcodes[HUFF_COEF1_SIZE] = { - 0x0001E2, 0x00007F, 0x000000, 0x000002, 0x000008, 0x00000E, 0x000019, - 0x00002F, 0x000037, 0x000060, 0x00006C, 0x000095, 0x0000C6, 0x0000F0, - 0x00012E, 0x000189, 0x0001A5, 0x0001F8, 0x000253, 0x00030A, 0x000344, - 0x00034D, 0x0003F2, 0x0004BD, 0x0005D7, 0x00062A, 0x00068B, 0x000693, - 0x000797, 0x00097D, 0x000BAB, 0x000C52, 0x000C5E, 0x000D21, 0x000D20, - 0x000F1A, 0x000FCE, 0x000FD1, 0x0012F1, 0x001759, 0x0018AC, 0x0018A7, - 0x0018BF, 0x001A2B, 0x001E52, 0x001E50, 0x001E31, 0x001FB8, 0x0025E6, - 0x0025E7, 0x002EB4, 0x002EB7, 0x003169, 0x00315B, 0x00317C, 0x00316C, - 0x0034CA, 0x00348D, 0x003F40, 0x003CA2, 0x003F76, 0x004BC3, 0x004BE5, - 0x003F73, 0x004BF8, 0x004BF9, 0x006131, 0x00628B, 0x006289, 0x0062DA, - 0x00628A, 0x0062D4, 0x006997, 0x0062B4, 0x006918, 0x00794D, 0x007E7B, - 0x007E87, 0x007EEA, 0x00794E, 0x00699D, 0x007967, 0x00699F, 0x0062DB, - 0x007E7A, 0x007EEB, 0x00BAC0, 0x0097C9, 0x00C537, 0x00C5AB, 0x00D233, - 0x00D338, 0x00BAC1, 0x00D23D, 0x012F91, 0x00D339, 0x00FDC8, 0x00D23C, - 0x00FDDC, 0x00FDC9, 0x00FDDD, 0x00D33C, 0x000003, 0x000016, 0x00003E, - 0x0000C3, 0x0001A1, 0x000347, 0x00062E, 0x000BAA, 0x000F2D, 0x001A2A, - 0x001E58, 0x00309B, 0x003CA3, 0x005D6A, 0x00629A, 0x006996, 0x00794F, - 0x007EE5, 0x00BAD7, 0x00C5AA, 0x00C5F4, 0x00FDDF, 0x00FDDE, 0x018A20, - 0x018A6D, 0x01A67B, 0x01A464, 0x025F21, 0x01F9E2, 0x01F9E3, 0x00000A, - 0x00003D, 0x000128, 0x0003C7, 0x000C24, 0x0018A3, 0x002EB1, 0x003CB2, - 0x00691F, 0x007E79, 0x000013, 0x0000BB, 0x00034E, 0x000D14, 0x0025FD, - 0x004BE7, 0x000024, 0x000188, 0x0007EF, 0x000035, 0x000308, 0x0012F2, - 0x00005C, 0x0003F6, 0x0025E0, 0x00006D, 0x000698, 0x000096, 0x000C25, - 0x0000C7, 0x000F1B, 0x0000F3, 0x0012FF, 0x000174, 0x001A66, 0x0001A0, - 0x003099, 0x0001E4, 0x00316B, 0x000252, 0x003F31, 0x00030B, 0x004BE6, - 0x000346, 0x0062FB, 0x00034F, 0x007966, 0x0003F5, 0x007E86, 0x0005D4, - 0x00C511, 0x00062C, 0x00C5F5, 0x000692, 0x00F299, 0x000795, 0x00F298, - 0x0007E9, 0x018A21, 0x00097E, 0x0175AD, 0x000C27, 0x01A67A, 0x000C57, - 0x02EB59, 0x000D22, 0x0314D9, 0x000F19, 0x03F3C2, 0x000FCD, 0x0348CB, - 0x0012F8, 0x04BE41, 0x0018A0, 0x03F3C1, 0x0018A1, 0x04BE40, 0x0018B7, - 0x0629B0, 0x001A64, 0x0D2329, 0x001E30, 0x03F3C3, 0x001F9F, 0x0BAD62, - 0x001F99, 0x0FCF00, 0x00309A, 0x0629B1, 0x002EB6, 0x175AC3, 0x00314C, - 0x069195, 0x003168, 0x0BAD63, 0x00348E, 0x175AC1, 0x003F30, 0x07E781, - 0x003F41, 0x0D2328, 0x003F42, 0x1F9E03, 0x004BC2, 0x175AC2, 0x003F74, - 0x175AC0, 0x005D61, 0x3F3C05, 0x006130, 0x3F3C04, 0x0062B5, -}; - -static const uint8_t coef1_huffbits[HUFF_COEF1_SIZE] = { - 9, 7, 2, 3, 4, 4, 5, - 6, 6, 7, 7, 8, 8, 8, - 9, 9, 9, 9, 10, 10, 10, - 10, 10, 11, 11, 11, 11, 11, - 11, 12, 12, 12, 12, 12, 12, - 12, 12, 12, 13, 13, 13, 13, - 13, 13, 13, 13, 13, 13, 14, - 14, 14, 14, 14, 14, 14, 14, - 14, 14, 14, 14, 14, 15, 15, - 14, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, - 15, 15, 16, 16, 16, 16, 16, - 16, 16, 16, 17, 16, 16, 16, - 16, 16, 16, 16, 3, 5, 6, - 8, 9, 10, 11, 12, 12, 13, - 13, 14, 14, 15, 15, 15, 15, - 15, 16, 16, 16, 16, 16, 17, - 17, 17, 17, 18, 17, 17, 4, - 6, 9, 10, 12, 13, 14, 14, - 15, 15, 5, 8, 10, 12, 14, - 15, 6, 9, 11, 6, 10, 13, - 7, 10, 14, 7, 11, 8, 12, - 8, 12, 8, 13, 9, 13, 9, - 14, 9, 14, 10, 14, 10, 15, - 10, 15, 10, 15, 10, 15, 11, - 16, 11, 16, 11, 16, 11, 16, - 11, 17, 12, 17, 12, 17, 12, - 18, 12, 18, 12, 18, 12, 18, - 13, 19, 13, 18, 13, 19, 13, - 19, 13, 20, 13, 18, 13, 20, - 13, 20, 14, 19, 14, 21, 14, - 19, 14, 20, 14, 21, 14, 19, - 14, 20, 14, 21, 15, 21, 14, - 21, 15, 22, 15, 22, 15, -}; - - -static const uint16_t coef0_run[HUFF_COEF0_SIZE] = { - 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, - 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, - 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, - 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, - 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, - 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, - 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, - 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, - 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, - 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, - 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 0, 1, - 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, - 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, - 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 0, 1, 2, 3, - 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, - 18, 19, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, - 2, 3, 4, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, - 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, - 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, - 1, 0, 1, 0, 1, 0, -}; - -static const int32_t coef0_level[HUFF_COEF0_SIZE] = { - 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, - 5, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, - 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, - 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, - 25, 26, 26, 27, 27, 28, -}; - - -static const uint16_t coef1_run[HUFF_COEF1_SIZE] = { - 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, - 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, - 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, - 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, - 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, - 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 0, 1, 2, 3, 4, 5, - 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, - 24, 25, 26, 27, 28, 29, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, - 2, 3, 4, 5, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 0, 1, 0, - 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, - 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, - 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, - 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, - 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, -}; - -static const int32_t coef1_level[HUFF_COEF1_SIZE] = { - 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, - 4, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 9, 9, 10, - 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, - 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, - 28, 29, 29, 30, 30, 31, 31, 32, 32, 33, 33, 34, 34, 35, 35, 36, 36, 37, - 37, 38, 38, 39, 39, 40, 40, 41, 41, 42, 42, 43, 43, 44, 44, 45, 45, 46, - 46, 47, 47, 48, 48, 49, 49, 50, 51, 52, -}; -/** @} */ - - -/** - * @name Huffman and vector lookup tables for vector-coded coefficients - * @{ - */ -#define HUFF_VEC4_SIZE 127 -#define HUFF_VEC4_MAXBITS 14 -static const uint16_t vec4_huffcodes[HUFF_VEC4_SIZE] = { - 0x0019, 0x0027, 0x00F2, 0x03BA, 0x0930, 0x1267, 0x0031, 0x0030, - 0x0097, 0x0221, 0x058B, 0x0124, 0x00EB, 0x01D4, 0x03D8, 0x0584, - 0x0364, 0x045F, 0x0F66, 0x0931, 0x24CD, 0x002F, 0x0039, 0x00E8, - 0x02C3, 0x078A, 0x0037, 0x0029, 0x0084, 0x01B1, 0x00ED, 0x0086, - 0x00F9, 0x03AB, 0x01EB, 0x08BC, 0x011E, 0x00F3, 0x0220, 0x058A, - 0x00EC, 0x008E, 0x012B, 0x01EA, 0x0119, 0x04B0, 0x04B1, 0x03B8, - 0x0691, 0x0365, 0x01ED, 0x049A, 0x0EA9, 0x0EA8, 0x08BD, 0x24CC, - 0x0026, 0x0035, 0x00DB, 0x02C4, 0x07B2, 0x0038, 0x002B, 0x007F, - 0x01B3, 0x00F4, 0x0091, 0x0116, 0x03BB, 0x0215, 0x0932, 0x002D, - 0x002A, 0x008A, 0x01DE, 0x0028, 0x0020, 0x005C, 0x0090, 0x0068, - 0x01EE, 0x00E9, 0x008D, 0x012A, 0x0087, 0x005D, 0x0118, 0x0349, - 0x01EF, 0x01E3, 0x08B9, 0x00F0, 0x00D3, 0x0214, 0x049B, 0x00DA, - 0x0089, 0x0125, 0x0217, 0x012D, 0x0690, 0x0094, 0x007D, 0x011F, - 0x007E, 0x0059, 0x0127, 0x01A5, 0x0111, 0x00F8, 0x045D, 0x03B9, - 0x0259, 0x0580, 0x02C1, 0x01DF, 0x0585, 0x0216, 0x0163, 0x01B0, - 0x03C4, 0x08B8, 0x078B, 0x0755, 0x0581, 0x0F67, 0x0000, -}; - -static const uint8_t vec4_huffbits[HUFF_VEC4_SIZE] = { - 5, 6, 8, 10, 12, 13, 6, 6, - 8, 10, 11, 9, 8, 9, 10, 11, - 10, 11, 12, 12, 14, 6, 6, 8, - 10, 11, 6, 6, 8, 9, 8, 8, - 8, 10, 9, 12, 9, 8, 10, 11, - 8, 8, 9, 9, 9, 11, 11, 10, - 11, 10, 9, 11, 12, 12, 12, 14, - 6, 6, 8, 10, 11, 6, 6, 7, - 9, 8, 8, 9, 10, 10, 12, 6, - 6, 8, 9, 6, 6, 7, 8, 7, - 9, 8, 8, 9, 8, 7, 9, 10, - 9, 9, 12, 8, 8, 10, 11, 8, - 8, 9, 10, 9, 11, 8, 7, 9, - 7, 7, 9, 9, 9, 8, 11, 10, - 10, 11, 10, 9, 11, 10, 9, 9, - 10, 12, 11, 11, 11, 12, 1, -}; - - -#define HUFF_VEC2_SIZE 137 -#define HUFF_VEC2_MAXBITS 12 -static const uint16_t vec2_huffcodes[HUFF_VEC2_SIZE] = { - 0x055, 0x01C, 0x01A, 0x02B, 0x028, 0x067, 0x08B, 0x039, - 0x170, 0x10D, 0x2A5, 0x047, 0x464, 0x697, 0x523, 0x8CB, - 0x01B, 0x00E, 0x000, 0x010, 0x012, 0x036, 0x048, 0x04C, - 0x0C2, 0x09B, 0x171, 0x03B, 0x224, 0x34A, 0x2D6, 0x019, - 0x00F, 0x002, 0x014, 0x017, 0x006, 0x05D, 0x054, 0x0C7, - 0x0B4, 0x192, 0x10E, 0x233, 0x043, 0x02C, 0x00F, 0x013, - 0x006, 0x02F, 0x02C, 0x068, 0x077, 0x0DF, 0x111, 0x1A4, - 0x16A, 0x2A4, 0x027, 0x011, 0x018, 0x02D, 0x00F, 0x04A, - 0x040, 0x097, 0x01F, 0x11B, 0x022, 0x16D, 0x066, 0x035, - 0x005, 0x02B, 0x049, 0x009, 0x075, 0x0CB, 0x0AA, 0x187, - 0x106, 0x08A, 0x047, 0x060, 0x06E, 0x01D, 0x074, 0x0C4, - 0x01E, 0x118, 0x1A7, 0x038, 0x042, 0x053, 0x076, 0x0A8, - 0x0CA, 0x082, 0x110, 0x18D, 0x12D, 0x0B9, 0x0C8, 0x0DE, - 0x01C, 0x0AB, 0x113, 0x18C, 0x10F, 0x09A, 0x0A5, 0x0B7, - 0x11A, 0x186, 0x1A6, 0x259, 0x153, 0x18A, 0x193, 0x020, - 0x10C, 0x046, 0x03A, 0x107, 0x149, 0x16C, 0x2D7, 0x225, - 0x258, 0x316, 0x696, 0x317, 0x042, 0x522, 0x290, 0x8CA, - 0x001, -}; - -static const uint8_t vec2_huffbits[HUFF_VEC2_SIZE] = { - 7, 6, 6, 6, 7, 7, 8, 9, - 9, 10, 10, 11, 11, 11, 12, 12, - 6, 4, 5, 5, 6, 6, 7, 8, - 8, 9, 9, 10, 10, 10, 11, 6, - 4, 5, 5, 6, 7, 7, 8, 8, - 9, 9, 10, 10, 11, 6, 5, 5, - 6, 6, 7, 7, 8, 8, 9, 9, - 10, 10, 7, 6, 6, 6, 7, 7, - 8, 8, 9, 9, 10, 10, 7, 6, - 7, 7, 7, 8, 8, 8, 9, 9, - 10, 8, 7, 7, 7, 8, 8, 8, - 9, 9, 9, 9, 8, 8, 8, 8, - 8, 9, 9, 9, 9, 8, 8, 8, - 9, 9, 9, 9, 10, 9, 9, 9, - 9, 9, 9, 10, 9, 9, 9, 10, - 10, 11, 10, 10, 10, 10, 11, 10, - 10, 10, 11, 10, 11, 12, 11, 12, - 3, -}; - - -#define HUFF_VEC1_SIZE 101 -#define HUFF_VEC1_MAXBITS 11 -static const uint16_t vec1_huffcodes[HUFF_VEC1_SIZE] = { - 0x01A, 0x003, 0x017, 0x010, 0x00C, 0x009, 0x005, 0x000, - 0x00D, 0x00A, 0x009, 0x00C, 0x00F, 0x002, 0x004, 0x007, - 0x00B, 0x00F, 0x01C, 0x006, 0x010, 0x015, 0x01C, 0x022, - 0x03B, 0x00E, 0x019, 0x023, 0x034, 0x036, 0x03A, 0x047, - 0x008, 0x00A, 0x01E, 0x031, 0x037, 0x050, 0x053, 0x06B, - 0x06F, 0x08C, 0x0E8, 0x0EA, 0x0EB, 0x016, 0x03E, 0x03F, - 0x06C, 0x089, 0x08A, 0x0A3, 0x0A4, 0x0D4, 0x0DD, 0x0EC, - 0x0EE, 0x11A, 0x1D2, 0x024, 0x025, 0x02E, 0x027, 0x0C2, - 0x0C0, 0x0DA, 0x0DB, 0x111, 0x144, 0x116, 0x14A, 0x145, - 0x1B8, 0x1AB, 0x1DA, 0x1DE, 0x1DB, 0x1DF, 0x236, 0x237, - 0x3A6, 0x3A7, 0x04D, 0x04C, 0x05E, 0x05F, 0x183, 0x182, - 0x186, 0x221, 0x187, 0x220, 0x22E, 0x22F, 0x296, 0x354, - 0x297, 0x355, 0x372, 0x373, 0x016, -}; - -static const uint8_t vec1_huffbits[HUFF_VEC1_SIZE] = { - 7, 6, 5, 5, 5, 5, 5, 5, - 4, 4, 4, 4, 4, 5, 5, 5, - 5, 5, 5, 6, 6, 6, 6, 6, - 6, 7, 7, 7, 7, 7, 7, 7, - 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 11, 11, 11, 11, 11, 11, - 11, 11, 11, 11, 11, 11, 11, 11, - 11, 11, 11, 11, 5, -}; - - -static const uint16_t symbol_to_vec4[HUFF_VEC4_SIZE] = { - 0, 1, 2, 3, 4, 5, 16, 17, 18, 19, - 20, 32, 33, 34, 35, 48, 49, 50, 64, 65, - 80, 256, 257, 258, 259, 260, 272, 273, 274, 275, - 288, 289, 290, 304, 305, 320, 512, 513, 514, 515, - 528, 529, 530, 544, 545, 560, 768, 769, 770, 784, - 785, 800, 1024, 1025, 1040, 1280, 4096, 4097, 4098, 4099, - 4100, 4112, 4113, 4114, 4115, 4128, 4129, 4130, 4144, 4145, - 4160, 4352, 4353, 4354, 4355, 4368, 4369, 4370, 4384, 4385, - 4400, 4608, 4609, 4610, 4624, 4625, 4640, 4864, 4865, 4880, - 5120, 8192, 8193, 8194, 8195, 8208, 8209, 8210, 8224, 8225, - 8240, 8448, 8449, 8450, 8464, 8465, 8480, 8704, 8705, 8720, - 8960, 12288, 12289, 12290, 12304, 12305, 12320, 12544, 12545, 12560, - 12800, 16384, 16385, 16400, 16640, 20480, 0, -}; - - -static const uint8_t symbol_to_vec2[HUFF_VEC2_SIZE] = { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, - 30, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, - 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 64, 65, - 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 80, 81, 82, 83, 84, - 85, 86, 87, 88, 89, 90, 96, 97, 98, 99, 100, 101, 102, 103, 104, - 105, 112, 113, 114, 115, 116, 117, 118, 119, 120, 128, 129, 130, 131, 132, - 133, 134, 135, 144, 145, 146, 147, 148, 149, 150, 160, 161, 162, 163, 164, - 165, 176, 177, 178, 179, 180, 192, 193, 194, 195, 208, 209, 210, 224, 225, - 240, 0, -}; -/** @} */ - - -/** - * @brief decorrelation matrix for multichannel streams - **/ -/* rockbox: not used -static const float default_decorrelation_matrices[] = { - 1.000000, 0.707031, -0.707031, 0.707031, 0.707031, 0.578125, 0.707031, - 0.410156, 0.578125, -0.707031, 0.410156, 0.578125, 0.000000, -0.816406, - 0.500000, 0.652344, 0.500000, 0.269531, 0.500000, 0.269531, -0.500000, - -0.652344, 0.500000, -0.269531, -0.500000, 0.652344, 0.500000, -0.652344, - 0.500000, -0.269531, 0.445312, 0.601562, 0.511719, 0.371094, 0.195312, - 0.445312, 0.371094, -0.195312, -0.601562, -0.511719, 0.445312, 0.000000, - -0.632812, 0.000000, 0.632812, 0.445312, -0.371094, -0.195312, 0.601562, - -0.511719, 0.445312, -0.601562, 0.511719, -0.371094, 0.195312, 0.410156, - 0.558594, 0.500000, 0.410156, 0.289062, 0.148438, 0.410156, 0.410156, - 0.000000, -0.410156, -0.578125, -0.410156, 0.410156, 0.148438, -0.500000, - -0.410156, 0.289062, 0.558594, 0.410156, -0.148438, -0.500000, 0.410156, - 0.289062, -0.558594, 0.410156, -0.410156, 0.000000, 0.410156, -0.578125, - 0.410156, 0.410156, -0.558594, 0.500000, -0.410156, 0.289062, -0.148438, -}; -*/ -/** - * @brief default decorrelation matrix offsets - */ -/* rockbox: not used -static const float * const default_decorrelation[] = { - NULL, - &default_decorrelation_matrices[0], - &default_decorrelation_matrices[1], - &default_decorrelation_matrices[5], - &default_decorrelation_matrices[14], - &default_decorrelation_matrices[30], - &default_decorrelation_matrices[55] -}; -*/ -#endif /* AVCODEC_WMAPRODATA_H */ diff --git a/apps/codecs/libwmapro/wmaprodec.c b/apps/codecs/libwmapro/wmaprodec.c deleted file mode 100644 index 9d42c6de0f..0000000000 --- a/apps/codecs/libwmapro/wmaprodec.c +++ /dev/null @@ -1,1626 +0,0 @@ -/* - * Wmapro compatible decoder - * Copyright (c) 2007 Baptiste Coudurier, Benjamin Larsson, Ulion - * Copyright (c) 2008 - 2009 Sascha Sommer, Benjamin Larsson - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/** - * @file libavcodec/wmaprodec.c - * @brief wmapro decoder implementation - * Wmapro is an MDCT based codec comparable to wma standard or AAC. - * The decoding therefore consists of the following steps: - * - bitstream decoding - * - reconstruction of per-channel data - * - rescaling and inverse quantization - * - IMDCT - * - windowing and overlapp-add - * - * The compressed wmapro bitstream is split into individual packets. - * Every such packet contains one or more wma frames. - * The compressed frames may have a variable length and frames may - * cross packet boundaries. - * Common to all wmapro frames is the number of samples that are stored in - * a frame. - * The number of samples and a few other decode flags are stored - * as extradata that has to be passed to the decoder. - * - * The wmapro frames themselves are again split into a variable number of - * subframes. Every subframe contains the data for 2^N time domain samples - * where N varies between 7 and 12. - * - * Example wmapro bitstream (in samples): - * - * || packet 0 || packet 1 || packet 2 packets - * --------------------------------------------------- - * || frame 0 || frame 1 || frame 2 || frames - * --------------------------------------------------- - * || | | || | | | || || subframes of channel 0 - * --------------------------------------------------- - * || | | || | | | || || subframes of channel 1 - * --------------------------------------------------- - * - * The frame layouts for the individual channels of a wma frame does not need - * to be the same. - * - * However, if the offsets and lengths of several subframes of a frame are the - * same, the subframes of the channels can be grouped. - * Every group may then use special coding techniques like M/S stereo coding - * to improve the compression ratio. These channel transformations do not - * need to be applied to a whole subframe. Instead, they can also work on - * individual scale factor bands (see below). - * The coefficients that carry the audio signal in the frequency domain - * are transmitted as huffman-coded vectors with 4, 2 and 1 elements. - * In addition to that, the encoder can switch to a runlevel coding scheme - * by transmitting subframe_length / 128 zero coefficients. - * - * Before the audio signal can be converted to the time domain, the - * coefficients have to be rescaled and inverse quantized. - * A subframe is therefore split into several scale factor bands that get - * scaled individually. - * Scale factors are submitted for every frame but they might be shared - * between the subframes of a channel. Scale factors are initially DPCM-coded. - * Once scale factors are shared, the differences are transmitted as runlevel - * codes. - * Every subframe length and offset combination in the frame layout shares a - * common quantization factor that can be adjusted for every channel by a - * modifier. - * After the inverse quantization, the coefficients get processed by an IMDCT. - * The resulting values are then windowed with a sine window and the first half - * of the values are added to the second half of the output from the previous - * subframe in order to reconstruct the output samples. - */ - -#include "ffmpeg_get_bits.h" -#include "ffmpeg_put_bits.h" -#include "wmaprodata.h" -#include "wma.h" -#include "wmaprodec.h" -//#include "wmapro_mdct.h" -#include "mdct_tables.h" -#include "quant.h" -#include "wmapro_math.h" -#include "codecs.h" -#include "codeclib.h" -#include "../libasf/asf.h" - -/* Uncomment the following line to enable some debug output */ -//#define WMAPRO_DUMP_CTX_EN - -#undef DEBUGF -#ifdef WMAPRO_DUMP_CTX_EN -# define DEBUGF printf -#else -# define DEBUGF(...) -#endif - -/* Some defines to make it compile */ -#define AVERROR_INVALIDDATA -1 -#define AVERROR_PATCHWELCOME -2 -#define av_log_ask_for_sample(...) - -/* Taken from avcodec.h */ -#define FF_INPUT_BUFFER_PADDING_SIZE 8 - -/* Taken from libavutil/mem.h */ -#define DECLARE_ALIGNED(n,t,v) t __attribute__ ((aligned (n))) v - -/* Taken from libavutil/common.h */ -#define FFMIN(a,b) ((a) > (b) ? (b) : (a)) -#define FFMAX(a,b) ((a) > (b) ? (a) : (b)) - -/* Define some multiple used constants */ -#define SQRT2_FRACT16 0x00016A0A /* 0x00016A0A = (sqrt(2)*(1<<16)) */ -#define COS_PI4_FRACT16 0x0000B505 /* 0x0000B505 = (cos(pi/4)<<16) */ -#define ONE_FRACT16 0x00010000 /* 0x00010000 = (1<<16) */ - -/* Enable multichannel for large-memory targets only */ -#if (MEMORYSIZE > 2) -#define WMAPRO_MAX_CHANNELS 8 ///< max number of handled channels -#else -#define WMAPRO_MAX_CHANNELS 2 ///< max number of handled channels -#endif - -/* Current decoder limitations */ -#define MAX_SUBFRAMES 32 ///< max number of subframes per channel -#define MAX_BANDS 29 ///< max number of scale factor bands -#define MAX_FRAMESIZE 32768 ///< maximum compressed frame size - -#define WMAPRO_BLOCK_MAX_BITS 12 ///< log2 of max block size -#define WMAPRO_BLOCK_MAX_SIZE (1 << WMAPRO_BLOCK_MAX_BITS) ///< maximum block size -#define WMAPRO_BLOCK_SIZES (WMAPRO_BLOCK_MAX_BITS - BLOCK_MIN_BITS + 1) ///< possible block sizes -#define WMAPRO_OUT_BUF_SIZE (WMAPRO_BLOCK_MAX_SIZE + WMAPRO_BLOCK_MAX_SIZE / 2) - - -#define VLCBITS 9 -#define SCALEVLCBITS 8 -#define VEC4MAXDEPTH ((HUFF_VEC4_MAXBITS+VLCBITS-1)/VLCBITS) -#define VEC2MAXDEPTH ((HUFF_VEC2_MAXBITS+VLCBITS-1)/VLCBITS) -#define VEC1MAXDEPTH ((HUFF_VEC1_MAXBITS+VLCBITS-1)/VLCBITS) -#define SCALEMAXDEPTH ((HUFF_SCALE_MAXBITS+SCALEVLCBITS-1)/SCALEVLCBITS) -#define SCALERLMAXDEPTH ((HUFF_SCALE_RL_MAXBITS+VLCBITS-1)/VLCBITS) - -static VLC sf_vlc; ///< scale factor DPCM vlc -static VLC sf_rl_vlc; ///< scale factor run length vlc -static VLC vec4_vlc; ///< 4 coefficients per symbol -static VLC vec2_vlc; ///< 2 coefficients per symbol -static VLC vec1_vlc; ///< 1 coefficient per symbol -static VLC coef_vlc[2]; ///< coefficient run length vlc codes -//static float sin64[33]; ///< sinus table for decorrelation - -/* Global defined arrays to allow IRAM usage for some models. */ -static int32_t g_tmp[WMAPRO_BLOCK_MAX_SIZE] IBSS_ATTR_WMAPRO_LARGE_IRAM; -static int32_t g_out_ch0[WMAPRO_OUT_BUF_SIZE] IBSS_ATTR; -static int32_t g_out_ch1[WMAPRO_OUT_BUF_SIZE] IBSS_ATTR_WMAPRO_LARGE_IRAM; -#if (WMAPRO_MAX_CHANNELS > 2) - static int32_t g_out_multichannel[WMAPRO_MAX_CHANNELS-2][WMAPRO_OUT_BUF_SIZE]; -#endif - -/** - * @brief frame specific decoder context for a single channel - */ -typedef struct { - int16_t prev_block_len; ///< length of the previous block - uint8_t transmit_coefs; - uint8_t num_subframes; - uint16_t subframe_len[MAX_SUBFRAMES]; ///< subframe length in samples - uint16_t subframe_offset[MAX_SUBFRAMES]; ///< subframe positions in the current frame - uint8_t cur_subframe; ///< current subframe number - uint16_t decoded_samples; ///< number of already processed samples - uint8_t grouped; ///< channel is part of a group - int quant_step; ///< quantization step for the current subframe - int8_t reuse_sf; ///< share scale factors between subframes - int8_t scale_factor_step; ///< scaling step for the current subframe - int max_scale_factor; ///< maximum scale factor for the current subframe - int saved_scale_factors[2][MAX_BANDS]; ///< resampled and (previously) transmitted scale factor values - int8_t scale_factor_idx; ///< index for the transmitted scale factor values (used for resampling) - int* scale_factors; ///< pointer to the scale factor values used for decoding - uint8_t table_idx; ///< index in sf_offsets for the scale factor reference block - int32_t* coeffs; ///< pointer to the subframe decode buffer - int32_t* out; ///< output buffer -} WMAProChannelCtx; - -/** - * @brief channel group for channel transformations - */ -typedef struct { - uint8_t num_channels; ///< number of channels in the group - int8_t transform; ///< transform on / off - int8_t transform_band[MAX_BANDS]; ///< controls if the transform is enabled for a certain band - //float decorrelation_matrix[WMAPRO_MAX_CHANNELS*WMAPRO_MAX_CHANNELS]; - int32_t* channel_data[WMAPRO_MAX_CHANNELS]; ///< transformation coefficients - int32_t fixdecorrelation_matrix[WMAPRO_MAX_CHANNELS*WMAPRO_MAX_CHANNELS]; -} WMAProChannelGrp; - -/** - * @brief main decoder context - */ -typedef struct WMAProDecodeCtx { - /* generic decoder variables */ - uint8_t frame_data[MAX_FRAMESIZE + - FF_INPUT_BUFFER_PADDING_SIZE];///< compressed frame data - PutBitContext pb; ///< context for filling the frame_data buffer - int32_t* tmp; ///< IMDCT input buffer - - /* frame size dependent frame information (set during initialization) */ - uint32_t decode_flags; ///< used compression features - uint8_t len_prefix; ///< frame is prefixed with its length - uint8_t dynamic_range_compression; ///< frame contains DRC data - uint8_t bits_per_sample; ///< integer audio sample size for the unscaled IMDCT output (used to scale to [-1.0, 1.0]) - uint16_t samples_per_frame; ///< number of samples to output - uint16_t log2_frame_size; - int8_t num_channels; ///< number of channels in the stream (same as AVCodecContext.num_channels) - int8_t lfe_channel; ///< lfe channel index - uint8_t max_num_subframes; - uint8_t subframe_len_bits; ///< number of bits used for the subframe length - uint8_t max_subframe_len_bit; ///< flag indicating that the subframe is of maximum size when the first subframe length bit is 1 - uint16_t min_samples_per_subframe; - int8_t num_sfb[WMAPRO_BLOCK_SIZES]; ///< scale factor bands per block size - int16_t sfb_offsets[WMAPRO_BLOCK_SIZES][MAX_BANDS]; ///< scale factor band offsets (multiples of 4) - int8_t sf_offsets[WMAPRO_BLOCK_SIZES][WMAPRO_BLOCK_SIZES][MAX_BANDS]; ///< scale factor resample matrix - int16_t subwoofer_cutoffs[WMAPRO_BLOCK_SIZES]; ///< subwoofer cutoff values - - /* packet decode state */ - GetBitContext pgb; ///< bitstream reader context for the packet - uint8_t packet_offset; ///< frame offset in the packet - uint8_t packet_sequence_number; ///< current packet number - int num_saved_bits; ///< saved number of bits - int frame_offset; ///< frame offset in the bit reservoir - int subframe_offset; ///< subframe offset in the bit reservoir - uint8_t packet_loss; ///< set in case of bitstream error - uint8_t packet_done; ///< set when a packet is fully decoded - - /* frame decode state */ - uint32_t frame_num; ///< current frame number - GetBitContext gb; ///< bitstream reader context - int buf_bit_size; ///< buffer size in bits - int32_t samples; - int32_t* samples_end; ///< maximum samplebuffer pointer - uint8_t drc_gain; ///< gain for the DRC tool - int8_t skip_frame; ///< skip output step - int8_t parsed_all_subframes; ///< all subframes decoded? - - /* subframe/block decode state */ - int16_t subframe_len; ///< current subframe length - int8_t channels_for_cur_subframe; ///< number of channels that contain the subframe - int8_t channel_indexes_for_cur_subframe[WMAPRO_MAX_CHANNELS]; - int8_t num_bands; ///< number of scale factor bands - int16_t* cur_sfb_offsets; ///< sfb offsets for the current block - uint8_t table_idx; ///< index for the num_sfb, sfb_offsets, sf_offsets and subwoofer_cutoffs tables - int8_t esc_len; ///< length of escaped coefficients - - uint8_t num_chgroups; ///< number of channel groups - WMAProChannelGrp chgroup[WMAPRO_MAX_CHANNELS]; ///< channel group information - - WMAProChannelCtx channel[WMAPRO_MAX_CHANNELS]; ///< per channel data -} WMAProDecodeCtx; - -/* static decode context, to avoid malloc */ -static WMAProDecodeCtx globWMAProDecCtx; - -/** - *@brief helper function to print the most important members of the context - *@param s context - */ -#ifdef WMAPRO_DUMP_CTX_EN -static void dump_context(WMAProDecodeCtx *s) -{ -#define PRINT(a, b) printf(" %s = %d\n", a, b); -#define PRINT_HEX(a, b) printf(" %s = %x\n", a, b); - - PRINT("ed sample bit depth", s->bits_per_sample); - PRINT_HEX("ed decode flags", s->decode_flags); - PRINT("samples per frame", s->samples_per_frame); - PRINT("log2 frame size", s->log2_frame_size); - PRINT("max num subframes", s->max_num_subframes); - PRINT("len prefix", s->len_prefix); - PRINT("num channels", s->num_channels); -} -#endif - -/** - *@brief Initialize the decoder. - *@param avctx codec context - *@return 0 on success, -1 otherwise - */ -int decode_init(asf_waveformatex_t *wfx) -{ - memset(&globWMAProDecCtx, 0, sizeof(WMAProDecodeCtx)); - WMAProDecodeCtx *s = &globWMAProDecCtx; - uint8_t *edata_ptr = wfx->data; - unsigned int channel_mask; - int i; - int log2_max_num_subframes; - int num_possible_block_sizes; - - /* Use globally defined array. Allows IRAM usage for models with large IRAM. */ - s->tmp = g_tmp; - - /* Use globally defined arrays. Allows IRAM usage for up to 2 channels. */ - s->channel[0].out = g_out_ch0; - s->channel[1].out = g_out_ch1; -#if (WMAPRO_MAX_CHANNELS > 2) - for (i=2; ichannel[i].out = g_out_multichannel[i-2]; -#endif - -#if defined(CPU_COLDFIRE) - coldfire_set_macsr(EMAC_FRACTIONAL | EMAC_SATURATE); -#endif - - init_put_bits(&s->pb, s->frame_data, MAX_FRAMESIZE); - - if (wfx->datalen >= 18) { - s->decode_flags = AV_RL16(edata_ptr+14); - channel_mask = AV_RL32(edata_ptr+2); - s->bits_per_sample = AV_RL16(edata_ptr); - /** dump the extradata */ - for (i = 0; i < wfx->datalen; i++) - DEBUGF("[%x] ", wfx->data[i]); - DEBUGF("\n"); - - } else { - DEBUGF("Unknown extradata size\n"); - return AVERROR_INVALIDDATA; - } - - /** generic init */ - s->log2_frame_size = av_log2(wfx->blockalign) + 4; - - /** frame info */ - s->skip_frame = 1; /** skip first frame */ - s->packet_loss = 1; - s->len_prefix = (s->decode_flags & 0x40); - - if (!s->len_prefix) { - DEBUGF("no length prefix\n"); - return AVERROR_INVALIDDATA; - } - - /** get frame len */ - s->samples_per_frame = 1 << ff_wma_get_frame_len_bits(wfx->rate, - 3, s->decode_flags); - - /** init previous block len */ - for (i = 0; i < wfx->channels; i++) - s->channel[i].prev_block_len = s->samples_per_frame; - - /** subframe info */ - log2_max_num_subframes = ((s->decode_flags & 0x38) >> 3); - s->max_num_subframes = 1 << log2_max_num_subframes; - if (s->max_num_subframes == 16) - s->max_subframe_len_bit = 1; - s->subframe_len_bits = av_log2(log2_max_num_subframes) + 1; - - num_possible_block_sizes = log2_max_num_subframes + 1; - s->min_samples_per_subframe = s->samples_per_frame / s->max_num_subframes; - s->dynamic_range_compression = (s->decode_flags & 0x80); - - if (s->max_num_subframes > MAX_SUBFRAMES) { - DEBUGF("invalid number of subframes %i\n", - s->max_num_subframes); - return AVERROR_INVALIDDATA; - } - - s->num_channels = wfx->channels; - - /** extract lfe channel position */ - s->lfe_channel = -1; - - if (channel_mask & 8) { - unsigned int mask; - for (mask = 1; mask < 16; mask <<= 1) { - if (channel_mask & mask) - ++s->lfe_channel; - } - } - - if (s->num_channels < 0) { - DEBUGF("invalid number of channels %d\n", s->num_channels); - return AVERROR_INVALIDDATA; - } else if (s->num_channels > WMAPRO_MAX_CHANNELS) { - DEBUGF("unsupported number of channels\n"); - return AVERROR_PATCHWELCOME; - } - - INIT_VLC_STATIC(&sf_vlc, SCALEVLCBITS, HUFF_SCALE_SIZE, - scale_huffbits, 1, 1, - scale_huffcodes, 2, 2, 616, IBSS_ATTR_WMAPRO_VLC_TABLES); - - INIT_VLC_STATIC(&sf_rl_vlc, VLCBITS, HUFF_SCALE_RL_SIZE, - scale_rl_huffbits, 1, 1, - scale_rl_huffcodes, 4, 4, 1406, IBSS_ATTR_WMAPRO_VLC_TABLES); - - INIT_VLC_STATIC(&coef_vlc[0], VLCBITS, HUFF_COEF0_SIZE, - coef0_huffbits, 1, 1, - coef0_huffcodes, 4, 4, 2108, IBSS_ATTR_WMAPRO_VLC_TABLES); - - INIT_VLC_STATIC(&coef_vlc[1], VLCBITS, HUFF_COEF1_SIZE, - coef1_huffbits, 1, 1, - coef1_huffcodes, 4, 4, 3912, IBSS_ATTR_WMAPRO_VLC_TABLES); - - INIT_VLC_STATIC(&vec4_vlc, VLCBITS, HUFF_VEC4_SIZE, - vec4_huffbits, 1, 1, - vec4_huffcodes, 2, 2, 604, IBSS_ATTR_WMAPRO_VLC_TABLES); - - INIT_VLC_STATIC(&vec2_vlc, VLCBITS, HUFF_VEC2_SIZE, - vec2_huffbits, 1, 1, - vec2_huffcodes, 2, 2, 562, IBSS_ATTR_WMAPRO_VLC_TABLES); - - INIT_VLC_STATIC(&vec1_vlc, VLCBITS, HUFF_VEC1_SIZE, - vec1_huffbits, 1, 1, - vec1_huffcodes, 2, 2, 562, IBSS_ATTR_WMAPRO_VLC_TABLES); - - /** calculate number of scale factor bands and their offsets - for every possible block size */ - for (i = 0; i < num_possible_block_sizes; i++) { - int subframe_len = s->samples_per_frame >> i; - int x; - int band = 1; - - s->sfb_offsets[i][0] = 0; - - for (x = 0; x < MAX_BANDS-1 && s->sfb_offsets[i][band - 1] < subframe_len; x++) { - int offset = (subframe_len * 2 * critical_freq[x]) - / wfx->rate + 2; - offset &= ~3; - if (offset > s->sfb_offsets[i][band - 1]) - s->sfb_offsets[i][band++] = offset; - } - s->sfb_offsets[i][band - 1] = subframe_len; - s->num_sfb[i] = band - 1; - } - - - /** Scale factors can be shared between blocks of different size - as every block has a different scale factor band layout. - The matrix sf_offsets is needed to find the correct scale factor. - */ - - for (i = 0; i < num_possible_block_sizes; i++) { - int b; - for (b = 0; b < s->num_sfb[i]; b++) { - int x; - int offset = ((s->sfb_offsets[i][b] - + s->sfb_offsets[i][b + 1] - 1) << i) >> 1; - for (x = 0; x < num_possible_block_sizes; x++) { - int v = 0; - while (s->sfb_offsets[x][v + 1] << x < offset) - ++v; - s->sf_offsets[i][x][b] = v; - } - } - } - - /** calculate subwoofer cutoff values */ - for (i = 0; i < num_possible_block_sizes; i++) { - int block_size = s->samples_per_frame >> i; - int cutoff = (440*block_size + 3 * (wfx->rate >> 1) - 1) - / wfx->rate; - s->subwoofer_cutoffs[i] = av_clip(cutoff, 4, block_size); - } - -#if 0 - /** calculate sine values for the decorrelation matrix */ - for (i = 0; i < 33; i++) - sin64[i] = sin(i*M_PI / 64.0); -#endif - -#ifdef WMAPRO_DUMP_CTX_EN - dump_context(s); -#endif - return 0; -} - -/** - *@brief Decode the subframe length. - *@param s context - *@param offset sample offset in the frame - *@return decoded subframe length on success, < 0 in case of an error - */ -static int decode_subframe_length(WMAProDecodeCtx *s, int offset) -{ - int frame_len_shift = 0; - int subframe_len; - - /** no need to read from the bitstream when only one length is possible */ - if (offset == s->samples_per_frame - s->min_samples_per_subframe) - return s->min_samples_per_subframe; - - /** 1 bit indicates if the subframe is of maximum length */ - if (s->max_subframe_len_bit) { - if (get_bits1(&s->gb)) - frame_len_shift = 1 + get_bits(&s->gb, s->subframe_len_bits-1); - } else - frame_len_shift = get_bits(&s->gb, s->subframe_len_bits); - - subframe_len = s->samples_per_frame >> frame_len_shift; - - /** sanity check the length */ - if (subframe_len < s->min_samples_per_subframe || - subframe_len > s->samples_per_frame) { - DEBUGF("broken frame: subframe_len %i\n", - subframe_len); - return AVERROR_INVALIDDATA; - } - return subframe_len; -} - -/** - *@brief Decode how the data in the frame is split into subframes. - * Every WMA frame contains the encoded data for a fixed number of - * samples per channel. The data for every channel might be split - * into several subframes. This function will reconstruct the list of - * subframes for every channel. - * - * If the subframes are not evenly split, the algorithm estimates the - * channels with the lowest number of total samples. - * Afterwards, for each of these channels a bit is read from the - * bitstream that indicates if the channel contains a subframe with the - * next subframe size that is going to be read from the bitstream or not. - * If a channel contains such a subframe, the subframe size gets added to - * the channel's subframe list. - * The algorithm repeats these steps until the frame is properly divided - * between the individual channels. - * - *@param s context - *@return 0 on success, < 0 in case of an error - */ -static int decode_tilehdr(WMAProDecodeCtx *s) -{ - uint16_t num_samples[WMAPRO_MAX_CHANNELS]; /** sum of samples for all currently known subframes of a channel */ - uint8_t contains_subframe[WMAPRO_MAX_CHANNELS]; /** flag indicating if a channel contains the current subframe */ - int channels_for_cur_subframe = s->num_channels; /** number of channels that contain the current subframe */ - int fixed_channel_layout = 0; /** flag indicating that all channels use the same subframe offsets and sizes */ - int min_channel_len = 0; /** smallest sum of samples (channels with this length will be processed first) */ - int c; - - /* Should never consume more than 3073 bits (256 iterations for the - * while loop when always the minimum amount of 128 samples is substracted - * from missing samples in the 8 channel case). - * 1 + BLOCK_MAX_SIZE * MAX_CHANNELS / BLOCK_MIN_SIZE * (MAX_CHANNELS + 4) - */ - - /** reset tiling information */ - for (c = 0; c < s->num_channels; c++) - s->channel[c].num_subframes = 0; - - memset(num_samples, 0, sizeof(num_samples)); - - if (s->max_num_subframes == 1 || get_bits1(&s->gb)) - fixed_channel_layout = 1; - - /** loop until the frame data is split between the subframes */ - do { - int subframe_len; - - /** check which channels contain the subframe */ - for (c = 0; c < s->num_channels; c++) { - if (num_samples[c] == min_channel_len) { - if (fixed_channel_layout || channels_for_cur_subframe == 1 || - (min_channel_len == s->samples_per_frame - s->min_samples_per_subframe)) - contains_subframe[c] = 1; - else - contains_subframe[c] = get_bits1(&s->gb); - } else - contains_subframe[c] = 0; - } - - /** get subframe length, subframe_len == 0 is not allowed */ - if ((subframe_len = decode_subframe_length(s, min_channel_len)) <= 0) - return AVERROR_INVALIDDATA; - - /** add subframes to the individual channels and find new min_channel_len */ - min_channel_len += subframe_len; - for (c = 0; c < s->num_channels; c++) { - WMAProChannelCtx* chan = &s->channel[c]; - - if (contains_subframe[c]) { - if (chan->num_subframes >= MAX_SUBFRAMES) { - DEBUGF("broken frame: num subframes > 31\n"); - return AVERROR_INVALIDDATA; - } - chan->subframe_len[chan->num_subframes] = subframe_len; - num_samples[c] += subframe_len; - ++chan->num_subframes; - if (num_samples[c] > s->samples_per_frame) { - DEBUGF("broken frame: " - "channel len > samples_per_frame\n"); - return AVERROR_INVALIDDATA; - } - } else if (num_samples[c] <= min_channel_len) { - if (num_samples[c] < min_channel_len) { - channels_for_cur_subframe = 0; - min_channel_len = num_samples[c]; - } - ++channels_for_cur_subframe; - } - } - } while (min_channel_len < s->samples_per_frame); - - for (c = 0; c < s->num_channels; c++) { - int i; - int offset = 0; - for (i = 0; i < s->channel[c].num_subframes; i++) { - DEBUGF("frame[%i] channel[%i] subframe[%i]" - " len %i\n", s->frame_num, c, i, - s->channel[c].subframe_len[i]); - s->channel[c].subframe_offset[i] = offset; - offset += s->channel[c].subframe_len[i]; - } - } - - return 0; -} - -#if 0 -/** - *@brief Calculate a decorrelation matrix from the bitstream parameters. - *@param s codec context - *@param chgroup channel group for which the matrix needs to be calculated - */ -static void decode_decorrelation_matrix(WMAProDecodeCtx *s, - WMAProChannelGrp *chgroup) -{ - int i; - int offset = 0; - int8_t rotation_offset[WMAPRO_MAX_CHANNELS * WMAPRO_MAX_CHANNELS]; - memset(chgroup->decorrelation_matrix, 0, s->num_channels * - s->num_channels * sizeof(*chgroup->decorrelation_matrix)); - - for (i = 0; i < chgroup->num_channels * (chgroup->num_channels - 1) >> 1; i++) - rotation_offset[i] = get_bits(&s->gb, 6); - - for (i = 0; i < chgroup->num_channels; i++) { - chgroup->decorrelation_matrix[chgroup->num_channels * i + i] = - get_bits1(&s->gb) ? 1.0 : -1.0; - - if(chgroup->decorrelation_matrix[chgroup->num_channels * i + i] > 0) - chgroup->fixdecorrelation_matrix[chgroup->num_channels * i + i] = ONE_FRACT16; - else - chgroup->fixdecorrelation_matrix[chgroup->num_channels * i + i] = -ONE_FRACT16; - } - - for (i = 1; i < chgroup->num_channels; i++) { - int x; - for (x = 0; x < i; x++) { - int y; - for (y = 0; y < i + 1; y++) { - float v1 = chgroup->decorrelation_matrix[x * chgroup->num_channels + y]; - float v2 = chgroup->decorrelation_matrix[i * chgroup->num_channels + y]; - int32_t f1 = chgroup->fixdecorrelation_matrix[x * chgroup->num_channels + y]; - int32_t f2 = chgroup->fixdecorrelation_matrix[i * chgroup->num_channels + y]; - int n = rotation_offset[offset + x]; - float sinv; - float cosv; - int32_t fixsinv; - int32_t fixcosv; - - if (n < 32) { - sinv = sin64[n]; - cosv = sin64[32 - n]; - fixsinv = fixed_sin64[n]; - fixcosv = fixed_sin64[32-n]; - } else { - sinv = sin64[64 - n]; - cosv = -sin64[n - 32]; - fixsinv = fixed_sin64[64-n]; - fixcosv = -fixed_sin64[n-32]; - } - - chgroup->decorrelation_matrix[y + x * chgroup->num_channels] = - (v1 * sinv) - (v2 * cosv); - chgroup->decorrelation_matrix[y + i * chgroup->num_channels] = - (v1 * cosv) + (v2 * sinv); - chgroup->fixdecorrelation_matrix[y + x * chgroup->num_channels] = - fixmul31(f1, fixsinv) - fixmul31(f2, fixcosv); - chgroup->fixdecorrelation_matrix[y + i * chgroup->num_channels] = - fixmul31(f1, fixcosv) + fixmul31(f2, fixsinv); - - } - } - offset += i; - } -} -#endif - -/** - *@brief Decode channel transformation parameters - *@param s codec context - *@return 0 in case of success, < 0 in case of bitstream errors - */ -static int decode_channel_transform(WMAProDecodeCtx* s) -{ - int i; - /* should never consume more than 1921 bits for the 8 channel case - * 1 + MAX_CHANNELS * (MAX_CHANNELS + 2 + 3 * MAX_CHANNELS * MAX_CHANNELS - * + MAX_CHANNELS + MAX_BANDS + 1) - */ - - /** in the one channel case channel transforms are pointless */ - s->num_chgroups = 0; - if (s->num_channels > 1) { - int remaining_channels = s->channels_for_cur_subframe; - - if (get_bits1(&s->gb)) { - DEBUGF("unsupported channel transform bit\n"); - return AVERROR_INVALIDDATA; - } - - for (s->num_chgroups = 0; remaining_channels && - s->num_chgroups < s->channels_for_cur_subframe; s->num_chgroups++) { - WMAProChannelGrp* chgroup = &s->chgroup[s->num_chgroups]; - int32_t** channel_data = chgroup->channel_data; - chgroup->num_channels = 0; - chgroup->transform = 0; - - /** decode channel mask */ - if (remaining_channels > 2) { - for (i = 0; i < s->channels_for_cur_subframe; i++) { - int channel_idx = s->channel_indexes_for_cur_subframe[i]; - if (!s->channel[channel_idx].grouped - && get_bits1(&s->gb)) { - ++chgroup->num_channels; - s->channel[channel_idx].grouped = 1; - *channel_data++ = s->channel[channel_idx].coeffs; - } - } - } else { - chgroup->num_channels = remaining_channels; - for (i = 0; i < s->channels_for_cur_subframe; i++) { - int channel_idx = s->channel_indexes_for_cur_subframe[i]; - if (!s->channel[channel_idx].grouped) - *channel_data++ = s->channel[channel_idx].coeffs; - s->channel[channel_idx].grouped = 1; - } - } - - /** decode transform type */ - if (chgroup->num_channels == 2) { - if (get_bits1(&s->gb)) { - if (get_bits1(&s->gb)) { - DEBUGF("unsupported channel transform type\n"); - } - } else { - chgroup->transform = 1; - if (s->num_channels == 2) { - chgroup->fixdecorrelation_matrix[0] = ONE_FRACT16; - chgroup->fixdecorrelation_matrix[1] = -ONE_FRACT16; - chgroup->fixdecorrelation_matrix[2] = ONE_FRACT16; - chgroup->fixdecorrelation_matrix[3] = ONE_FRACT16; - } else { - /** cos(pi/4) */ - chgroup->fixdecorrelation_matrix[0] = COS_PI4_FRACT16; - chgroup->fixdecorrelation_matrix[1] = -COS_PI4_FRACT16; - chgroup->fixdecorrelation_matrix[2] = COS_PI4_FRACT16; - chgroup->fixdecorrelation_matrix[3] = COS_PI4_FRACT16; - } - } - } else if (chgroup->num_channels > 2) { - DEBUGF("in wmaprodec.c: Multichannel streams still not supported\n"); - return -1; -#if 0 - if (get_bits1(&s->gb)) { - chgroup->transform = 1; - if (get_bits1(&s->gb)) { - decode_decorrelation_matrix(s, chgroup); - } else { - /** FIXME: more than 6 coupled channels not supported */ - if (chgroup->num_channels > 6) { - av_log_ask_for_sample(s->avctx, - "coupled channels > 6\n"); - } else { - memcpy(chgroup->decorrelation_matrix, - default_decorrelation[chgroup->num_channels], - chgroup->num_channels * chgroup->num_channels * - sizeof(*chgroup->decorrelation_matrix)); - } - } - } -#endif - } - - /** decode transform on / off */ - if (chgroup->transform) { - if (!get_bits1(&s->gb)) { - int i; - /** transform can be enabled for individual bands */ - for (i = 0; i < s->num_bands; i++) { - chgroup->transform_band[i] = get_bits1(&s->gb); - } - } else { - memset(chgroup->transform_band, 1, s->num_bands); - } - } - remaining_channels -= chgroup->num_channels; - } - } - return 0; -} - -/** - *@brief Extract the coefficients from the bitstream. - *@param s codec context - *@param c current channel number - *@return 0 on success, < 0 in case of bitstream errors - */ -static int decode_coeffs(WMAProDecodeCtx *s, int c) -{ - int vlctable; - VLC* vlc; - WMAProChannelCtx* ci = &s->channel[c]; - int rl_mode = 0; - int cur_coeff = 0; - int num_zeros = 0; - const uint16_t* run; - const int32_t* level; - - DEBUGF("decode coefficients for channel %i\n", c); - - vlctable = get_bits1(&s->gb); - vlc = &coef_vlc[vlctable]; - - if (vlctable) { - run = coef1_run; - level = coef1_level; - } else { - run = coef0_run; - level = coef0_level; - } - - /** decode vector coefficients (consumes up to 167 bits per iteration for - 4 vector coded large values) */ - while (!rl_mode && cur_coeff + 3 < s->subframe_len) { - int32_t vals[4]; - int i; - unsigned int idx; - - idx = get_vlc2(&s->gb, vec4_vlc.table, VLCBITS, VEC4MAXDEPTH); - - if (idx == HUFF_VEC4_SIZE - 1) { - for (i = 0; i < 4; i += 2) { - idx = get_vlc2(&s->gb, vec2_vlc.table, VLCBITS, VEC2MAXDEPTH); - if (idx == HUFF_VEC2_SIZE - 1) { - int v0, v1; - v0 = get_vlc2(&s->gb, vec1_vlc.table, VLCBITS, VEC1MAXDEPTH); - if (v0 == HUFF_VEC1_SIZE - 1) - v0 += ff_wma_get_large_val(&s->gb); - v1 = get_vlc2(&s->gb, vec1_vlc.table, VLCBITS, VEC1MAXDEPTH); - if (v1 == HUFF_VEC1_SIZE - 1) - v1 += ff_wma_get_large_val(&s->gb); - - vals[i ] = v0; - vals[i+1] = v1; - } else { - vals[i ] = symbol_to_vec2[idx] >> 4; - vals[i+1] = symbol_to_vec2[idx] & 0xF; - } - } - } else { - vals[0] = (symbol_to_vec4[idx] >> 12); - vals[1] = (symbol_to_vec4[idx] >> 8) & 0xF; - vals[2] = (symbol_to_vec4[idx] >> 4) & 0xF; - vals[3] = (symbol_to_vec4[idx] ) & 0xF; - } - - /* Rockbox: To be able to use rockbox' optimized mdct we need to - * pre-shift the values by >>(nbits-3). */ - const int nbits = av_log2(s->subframe_len)+1; - const int shift = WMAPRO_FRACT-(nbits-3); - - /** decode sign */ - for (i = 0; i < 4; i++) { - if (vals[i]) { - int sign = get_bits1(&s->gb) - 1; - /* Rockbox: To be able to use rockbox' optimized mdct we need - * invert the sign. */ - ci->coeffs[cur_coeff] = (sign == -1)? vals[i]<coeffs[cur_coeff] = 0; - /** switch to run level mode when subframe_len / 128 zeros - were found in a row */ - rl_mode |= (++num_zeros > s->subframe_len >> 8); - } - ++cur_coeff; - } - } - - /** decode run level coded coefficients */ - if (rl_mode) { - memset(&ci->coeffs[cur_coeff], 0, - sizeof(*ci->coeffs) * (s->subframe_len - cur_coeff)); - - if (ff_wma_run_level_decode(&s->gb, vlc, - level, run, 1, ci->coeffs, - cur_coeff, s->subframe_len, - s->subframe_len, s->esc_len, 0)) - return AVERROR_INVALIDDATA; - - } - return 0; -} - -/** - *@brief Extract scale factors from the bitstream. - *@param s codec context - *@return 0 on success, < 0 in case of bitstream errors - */ -static int decode_scale_factors(WMAProDecodeCtx* s) -{ - int i; - - /** should never consume more than 5344 bits - * MAX_CHANNELS * (1 + MAX_BANDS * 23) - */ - - for (i = 0; i < s->channels_for_cur_subframe; i++) { - int c = s->channel_indexes_for_cur_subframe[i]; - int* sf; - int* sf_end; - s->channel[c].scale_factors = s->channel[c].saved_scale_factors[!s->channel[c].scale_factor_idx]; - sf_end = s->channel[c].scale_factors + s->num_bands; - - /** resample scale factors for the new block size - * as the scale factors might need to be resampled several times - * before some new values are transmitted, a backup of the last - * transmitted scale factors is kept in saved_scale_factors - */ - if (s->channel[c].reuse_sf) { - const int8_t* sf_offsets = s->sf_offsets[s->table_idx][s->channel[c].table_idx]; - int b; - for (b = 0; b < s->num_bands; b++) - s->channel[c].scale_factors[b] = - s->channel[c].saved_scale_factors[s->channel[c].scale_factor_idx][*sf_offsets++]; - } - - if (!s->channel[c].cur_subframe || get_bits1(&s->gb)) { - - if (!s->channel[c].reuse_sf) { - int val; - /** decode DPCM coded scale factors */ - s->channel[c].scale_factor_step = get_bits(&s->gb, 2) + 1; - val = 45 / s->channel[c].scale_factor_step; - for (sf = s->channel[c].scale_factors; sf < sf_end; sf++) { - val += get_vlc2(&s->gb, sf_vlc.table, SCALEVLCBITS, SCALEMAXDEPTH) - 60; - *sf = val; - } - } else { - int i; - /** run level decode differences to the resampled factors */ - for (i = 0; i < s->num_bands; i++) { - int idx; - int skip; - int val; - int sign; - - idx = get_vlc2(&s->gb, sf_rl_vlc.table, VLCBITS, SCALERLMAXDEPTH); - - if (!idx) { - uint32_t code = get_bits(&s->gb, 14); - val = code >> 6; - sign = (code & 1) - 1; - skip = (code & 0x3f) >> 1; - } else if (idx == 1) { - break; - } else { - skip = scale_rl_run[idx]; - val = scale_rl_level[idx]; - sign = get_bits1(&s->gb)-1; - } - - i += skip; - if (i >= s->num_bands) { - DEBUGF("invalid scale factor coding\n"); - return AVERROR_INVALIDDATA; - } - s->channel[c].scale_factors[i] += (val ^ sign) - sign; - } - } - - /** swap buffers */ - s->channel[c].scale_factor_idx = !s->channel[c].scale_factor_idx; - s->channel[c].table_idx = s->table_idx; - s->channel[c].reuse_sf = 1; - } - - /** calculate new scale factor maximum */ - s->channel[c].max_scale_factor = s->channel[c].scale_factors[0]; - for (sf = s->channel[c].scale_factors + 1; sf < sf_end; sf++) { - s->channel[c].max_scale_factor = - FFMAX(s->channel[c].max_scale_factor, *sf); - } - - } - return 0; -} - -/** - *@brief Reconstruct the individual channel data. - *@param s codec context - */ -static void inverse_channel_transform(WMAProDecodeCtx *s) -{ - int i; - - for (i = 0; i < s->num_chgroups; i++) { - if (s->chgroup[i].transform) { - const int num_channels = s->chgroup[i].num_channels; - int32_t data[WMAPRO_MAX_CHANNELS]; - int32_t** ch_data = s->chgroup[i].channel_data; - int32_t** ch_end = ch_data + num_channels; - const int8_t* tb = s->chgroup[i].transform_band; - int16_t* sfb; - - /** multichannel decorrelation */ - for (sfb = s->cur_sfb_offsets; - sfb < s->cur_sfb_offsets + s->num_bands; sfb++) { - int y; - if (*tb++ == 1) { - /** multiply values with the decorrelation_matrix */ - for (y = sfb[0]; y < FFMIN(sfb[1], s->subframe_len); y++) { - const int32_t* mat = s->chgroup[i].fixdecorrelation_matrix; - const int32_t* data_end = data + num_channels; - int32_t* data_ptr = data; - int32_t** ch; - - for (ch = ch_data; ch < ch_end; ch++) - *data_ptr++ = (*ch)[y]; - - for (ch = ch_data; ch < ch_end; ch++) { - int32_t sum = 0; - data_ptr = data; - - while (data_ptr < data_end) - sum += fixmul16(*mat++, *data_ptr++); - - (*ch)[y] = sum; - } - } - } else if (s->num_channels == 2) { - - /* Scale with sqrt(2) */ - int len = FFMIN(sfb[1], s->subframe_len) - sfb[0]; - vector_fixmul_scalar(ch_data[0] + sfb[0], - ch_data[0] + sfb[0], - SQRT2_FRACT16, len); - vector_fixmul_scalar(ch_data[1] + sfb[0], - ch_data[1] + sfb[0], - SQRT2_FRACT16, len); - - } - } - } - } -} - -/** - *@brief Apply sine window and reconstruct the output buffer. - *@param s codec context - */ -static void wmapro_window(WMAProDecodeCtx *s) -{ - int i; - - for (i = 0; i < s->channels_for_cur_subframe; i++) { - int c = s->channel_indexes_for_cur_subframe[i]; - const int32_t* window; - int winlen = s->channel[c].prev_block_len; - int32_t *xstart= s->channel[c].coeffs - (winlen >> 1); - - if (s->subframe_len < winlen) { - xstart += (winlen - s->subframe_len) >> 1; - winlen = s->subframe_len; - } - - window = sine_windows[av_log2(winlen) - BLOCK_MIN_BITS]; - - winlen >>= 1; - - vector_fixmul_window(xstart, xstart, xstart + winlen, - window, winlen); - - s->channel[c].prev_block_len = s->subframe_len; - - } -} - -/** - *@brief Decode a single subframe (block). - *@param s codec context - *@return 0 on success, < 0 when decoding failed - */ -static int decode_subframe(WMAProDecodeCtx *s) -{ - int offset = s->samples_per_frame; - int subframe_len = s->samples_per_frame; - int i; - int total_samples = s->samples_per_frame * s->num_channels; - int transmit_coeffs = 0; - int cur_subwoofer_cutoff; - - s->subframe_offset = get_bits_count(&s->gb); - - /** reset channel context and find the next block offset and size - == the next block of the channel with the smallest number of - decoded samples - */ - for (i = 0; i < s->num_channels; i++) { - s->channel[i].grouped = 0; - if (offset > s->channel[i].decoded_samples) { - offset = s->channel[i].decoded_samples; - subframe_len = - s->channel[i].subframe_len[s->channel[i].cur_subframe]; - } - } - - DEBUGF("processing subframe with offset %i len %i\n", offset, subframe_len); - - /** get a list of all channels that contain the estimated block */ - s->channels_for_cur_subframe = 0; - for (i = 0; i < s->num_channels; i++) { - const int cur_subframe = s->channel[i].cur_subframe; - /** substract already processed samples */ - total_samples -= s->channel[i].decoded_samples; - - /** and count if there are multiple subframes that match our profile */ - if (offset == s->channel[i].decoded_samples && - subframe_len == s->channel[i].subframe_len[cur_subframe]) { - total_samples -= s->channel[i].subframe_len[cur_subframe]; - s->channel[i].decoded_samples += - s->channel[i].subframe_len[cur_subframe]; - s->channel_indexes_for_cur_subframe[s->channels_for_cur_subframe] = i; - ++s->channels_for_cur_subframe; - } - } - - /** check if the frame will be complete after processing the - estimated block */ - if (!total_samples) - s->parsed_all_subframes = 1; - - - DEBUGF("subframe is part of %i channels\n", s->channels_for_cur_subframe); - - /** calculate number of scale factor bands and their offsets */ - s->table_idx = av_log2(s->samples_per_frame/subframe_len); - s->num_bands = s->num_sfb[s->table_idx]; - s->cur_sfb_offsets = s->sfb_offsets[s->table_idx]; - cur_subwoofer_cutoff = s->subwoofer_cutoffs[s->table_idx]; - - /** configure the decoder for the current subframe */ - for (i = 0; i < s->channels_for_cur_subframe; i++) { - int c = s->channel_indexes_for_cur_subframe[i]; - - s->channel[c].coeffs = &s->channel[c].out[(s->samples_per_frame >> 1) - + offset]; - } - - s->subframe_len = subframe_len; - s->esc_len = av_log2(s->subframe_len - 1) + 1; - - /** skip extended header if any */ - if (get_bits1(&s->gb)) { - int num_fill_bits; - if (!(num_fill_bits = get_bits(&s->gb, 2))) { - int len = get_bits(&s->gb, 4); - num_fill_bits = get_bits(&s->gb, len) + 1; - } - - if (num_fill_bits >= 0) { - if (get_bits_count(&s->gb) + num_fill_bits > s->num_saved_bits) { - DEBUGF("invalid number of fill bits\n"); - return AVERROR_INVALIDDATA; - } - - skip_bits_long(&s->gb, num_fill_bits); - } - } - - /** no idea for what the following bit is used */ - if (get_bits1(&s->gb)) { - DEBUGF("reserved bit set\n"); - return AVERROR_INVALIDDATA; - } - - if (decode_channel_transform(s) < 0) - return AVERROR_INVALIDDATA; - - for (i = 0; i < s->channels_for_cur_subframe; i++) { - int c = s->channel_indexes_for_cur_subframe[i]; - if ((s->channel[c].transmit_coefs = get_bits1(&s->gb))) - transmit_coeffs = 1; - } - - if (transmit_coeffs) { - int step; - int quant_step = 90 * s->bits_per_sample >> 4; - if ((get_bits1(&s->gb))) { - /** FIXME: might change run level mode decision */ - DEBUGF("unsupported quant step coding\n"); - return AVERROR_INVALIDDATA; - } - /** decode quantization step */ - step = get_sbits(&s->gb, 6); - quant_step += step; - if (step == -32 || step == 31) { - const int sign = (step == 31) - 1; - int quant = 0; - while (get_bits_count(&s->gb) + 5 < s->num_saved_bits && - (step = get_bits(&s->gb, 5)) == 31) { - quant += 31; - } - quant_step += ((quant + step) ^ sign) - sign; - } - if (quant_step < 0) { - DEBUGF("negative quant step\n"); - } - - /** decode quantization step modifiers for every channel */ - - if (s->channels_for_cur_subframe == 1) { - s->channel[s->channel_indexes_for_cur_subframe[0]].quant_step = quant_step; - } else { - int modifier_len = get_bits(&s->gb, 3); - for (i = 0; i < s->channels_for_cur_subframe; i++) { - int c = s->channel_indexes_for_cur_subframe[i]; - s->channel[c].quant_step = quant_step; - if (get_bits1(&s->gb)) { - if (modifier_len) { - s->channel[c].quant_step += get_bits(&s->gb, modifier_len) + 1; - } else - ++s->channel[c].quant_step; - } - } - } - - /** decode scale factors */ - if (decode_scale_factors(s) < 0) - return AVERROR_INVALIDDATA; - } - - DEBUGF("BITSTREAM: subframe header length was %i\n", - get_bits_count(&s->gb) - s->subframe_offset); - - /** parse coefficients */ - for (i = 0; i < s->channels_for_cur_subframe; i++) { - int c = s->channel_indexes_for_cur_subframe[i]; - if (s->channel[c].transmit_coefs && - get_bits_count(&s->gb) < s->num_saved_bits) { - decode_coeffs(s, c); - } else { - memset(s->channel[c].coeffs, 0, - sizeof(*s->channel[c].coeffs) * subframe_len); - } - } - - DEBUGF("BITSTREAM: subframe length was %i\n", - get_bits_count(&s->gb) - s->subframe_offset); - - if (transmit_coeffs) { - int nbits = av_log2(subframe_len)+1; - /** reconstruct the per channel data */ - inverse_channel_transform(s); - for (i = 0; i < s->channels_for_cur_subframe; i++) { - int c = s->channel_indexes_for_cur_subframe[i]; - const int* sf = s->channel[c].scale_factors; - int b; - - if (c == s->lfe_channel) - memset(&s->tmp[cur_subwoofer_cutoff], 0, sizeof(*s->tmp) * - (subframe_len - cur_subwoofer_cutoff)); - - /** inverse quantization and rescaling */ - for (b = 0; b < s->num_bands; b++) { - const int end = FFMIN(s->cur_sfb_offsets[b+1], s->subframe_len); - const int exp = s->channel[c].quant_step - - (s->channel[c].max_scale_factor - *sf++) * - s->channel[c].scale_factor_step; - - if(exp < EXP_MIN || exp > EXP_MAX) { - DEBUGF("in wmaprodec.c : unhandled value for exp (%d), please report sample.\n", exp); - return -1; - } - const int32_t quant = QUANT(exp); - int start = s->cur_sfb_offsets[b]; - - vector_fixmul_scalar(s->tmp+start, - s->channel[c].coeffs + start, - quant, end-start); - - - } - - /** apply imdct (ff_imdct_half == DCTIV with reverse) */ - ff_imdct_half(nbits,s->channel[c].coeffs, s->tmp); - - } - } - - /** window and overlapp-add */ - wmapro_window(s); - - /** handled one subframe */ - for (i = 0; i < s->channels_for_cur_subframe; i++) { - int c = s->channel_indexes_for_cur_subframe[i]; - if (s->channel[c].cur_subframe >= s->channel[c].num_subframes) { - DEBUGF("broken subframe\n"); - return AVERROR_INVALIDDATA; - } - ++s->channel[c].cur_subframe; - } - - return 0; -} - -/** - *@brief Decode one WMA frame. - *@param s codec context - *@return 0 if the trailer bit indicates that this is the last frame, - * 1 if there are additional frames - */ -static int decode_frame(WMAProDecodeCtx *s) -{ - GetBitContext* gb = &s->gb; - int more_frames = 0; - int len = 0; - int i; - - -#if 0 - /** check for potential output buffer overflow */ - /* Rockbox : No need to check that anymore since we work directly on the - buffers in the WMAProDecCtx */ - if (s->num_channels * s->samples_per_frame > s->samples_end - s->samples) { - /** return an error if no frame could be decoded at all */ - DEBUGF("not enough space for the output samples\n"); - s->packet_loss = 1; - return 0; - } -#endif - - /** get frame length */ - if (s->len_prefix) - len = get_bits(gb, s->log2_frame_size); - - DEBUGF("decoding frame with length %x\n", len); - - /** decode tile information */ - if (decode_tilehdr(s)) { - s->packet_loss = 1; - return 0; - } - - /** read postproc transform */ - if (s->num_channels > 1 && get_bits1(gb)) { - DEBUGF("Unsupported postproc transform found\n"); - s->packet_loss = 1; - return 0; - } - - /** read drc info */ - if (s->dynamic_range_compression) { - s->drc_gain = get_bits(gb, 8); - DEBUGF("drc_gain %i\n", s->drc_gain); - } - - /** no idea what these are for, might be the number of samples - that need to be skipped at the beginning or end of a stream */ - if (get_bits1(gb)) { - /** usually true for the first frame */ - if (get_bits1(gb)) { - get_bits(gb, av_log2(s->samples_per_frame * 2)); - DEBUGF("start skip\n"); - } - /** sometimes true for the last frame */ - if (get_bits1(gb)) { - get_bits(gb, av_log2(s->samples_per_frame * 2)); - DEBUGF("end skip\n"); - } - } - - DEBUGF("BITSTREAM: frame header length was %i\n", - get_bits_count(gb) - s->frame_offset); - - /** reset subframe states */ - s->parsed_all_subframes = 0; - for (i = 0; i < s->num_channels; i++) { - s->channel[i].decoded_samples = 0; - s->channel[i].cur_subframe = 0; - s->channel[i].reuse_sf = 0; - } - - /** decode all subframes */ - while (!s->parsed_all_subframes) { - if (decode_subframe(s) < 0) { - s->packet_loss = 1; - return 0; - } - } - - if (s->skip_frame) { - s->skip_frame = 0; - } else - s->samples += s->num_channels * s->samples_per_frame; - - if (len != (get_bits_count(gb) - s->frame_offset) + 2) { - /** FIXME: not sure if this is always an error */ - DEBUGF("frame[%i] would have to skip %i bits\n", - (int)s->frame_num, len - (get_bits_count(gb) - s->frame_offset) - 1); - s->packet_loss = 1; - return 0; - } - - /** skip the rest of the frame data */ - skip_bits_long(gb, len - (get_bits_count(gb) - s->frame_offset) - 1); - - /** decode trailer bit */ - more_frames = get_bits1(gb); - - ++s->frame_num; - return more_frames; -} - -/** - *@brief Calculate remaining input buffer length. - *@param s codec context - *@param gb bitstream reader context - *@return remaining size in bits - */ -static int remaining_bits(WMAProDecodeCtx *s, GetBitContext *gb) -{ - return s->buf_bit_size - get_bits_count(gb); -} - -/** - *@brief Fill the bit reservoir with a (partial) frame. - *@param s codec context - *@param gb bitstream reader context - *@param len length of the partial frame - *@param append decides wether to reset the buffer or not - */ -static void save_bits(WMAProDecodeCtx *s, GetBitContext* gb, int len, - int append) -{ - int buflen; - - /** when the frame data does not need to be concatenated, the input buffer - is resetted and additional bits from the previous frame are copyed - and skipped later so that a fast byte copy is possible */ - - if (!append) { - s->frame_offset = get_bits_count(gb) & 7; - s->num_saved_bits = s->frame_offset; - init_put_bits(&s->pb, s->frame_data, MAX_FRAMESIZE); - } - - buflen = (s->num_saved_bits + len + 8) >> 3; - - if (len <= 0 || buflen > MAX_FRAMESIZE) { - DEBUGF("input buffer too small\n"); - s->packet_loss = 1; - return; - } - - s->num_saved_bits += len; - if (!append) { - ff_copy_bits(&s->pb, gb->buffer + (get_bits_count(gb) >> 3), - s->num_saved_bits); - } else { - int align = 8 - (get_bits_count(gb) & 7); - align = FFMIN(align, len); - put_bits(&s->pb, align, get_bits(gb, align)); - len -= align; - ff_copy_bits(&s->pb, gb->buffer + (get_bits_count(gb) >> 3), len); - } - skip_bits_long(gb, len); - - { - PutBitContext tmp = s->pb; - flush_put_bits(&tmp); - } - - init_get_bits(&s->gb, s->frame_data, s->num_saved_bits); - skip_bits(&s->gb, s->frame_offset); -} - -/** - *@brief Decode a single WMA packet. - *@param avctx codec context - *@param data the output buffer - *@param data_size number of bytes that were written to the output buffer - *@param avpkt input packet - *@return number of bytes that were read from the input buffer - */ -int decode_packet(asf_waveformatex_t *wfx, int32_t *dec[2], int *data_size, - void* pktdata, int size) -{ - WMAProDecodeCtx *s = &globWMAProDecCtx; - GetBitContext* gb = &s->pgb; - const uint8_t* buf = pktdata; - int buf_size = size; - int num_bits_prev_frame; - int packet_sequence_number;\ - int i; - - /** reuse second half of the IMDCT output for the next frame */ - /* NOTE : Relies on the WMAProDecCtx being static */ - for(i = 0; i < s->num_channels; i++) - memcpy(&s->channel[i].out[0], - &s->channel[i].out[s->samples_per_frame], - s->samples_per_frame * sizeof(*s->channel[i].out) >> 1); - - - s->samples = 0; - *data_size = 0; - - if (s->packet_done || s->packet_loss) { - s->packet_done = 0; - s->buf_bit_size = buf_size << 3; - - /** sanity check for the buffer length */ - if (buf_size < wfx->blockalign) - return 0; - - buf_size = wfx->blockalign; - - /** parse packet header */ - init_get_bits(gb, buf, s->buf_bit_size); - packet_sequence_number = get_bits(gb, 4); - skip_bits(gb, 2); - - /** get number of bits that need to be added to the previous frame */ - num_bits_prev_frame = get_bits(gb, s->log2_frame_size); - DEBUGF("packet[%d]: nbpf %x\n", s->frame_num, - num_bits_prev_frame); - - /** check for packet loss */ - if (!s->packet_loss && - ((s->packet_sequence_number + 1) & 0xF) != packet_sequence_number) { - s->packet_loss = 1; - DEBUGF("Packet loss detected! seq %x vs %x\n", - s->packet_sequence_number, packet_sequence_number); - } - s->packet_sequence_number = packet_sequence_number; - - if (num_bits_prev_frame > 0) { - /** append the previous frame data to the remaining data from the - previous packet to create a full frame */ - save_bits(s, gb, num_bits_prev_frame, 1); - DEBUGF("accumulated %x bits of frame data\n", - s->num_saved_bits - s->frame_offset); - - /** decode the cross packet frame if it is valid */ - if (!s->packet_loss) - decode_frame(s); - } else if (s->num_saved_bits - s->frame_offset) { - DEBUGF("ignoring %x previously saved bits\n", - s->num_saved_bits - s->frame_offset); - } - - s->packet_loss = 0; - - } else { - int frame_size; - s->buf_bit_size = size << 3; - init_get_bits(gb, pktdata, s->buf_bit_size); - skip_bits(gb, s->packet_offset); - if (remaining_bits(s, gb) > s->log2_frame_size && - (frame_size = show_bits(gb, s->log2_frame_size)) && - frame_size <= remaining_bits(s, gb)) { - save_bits(s, gb, frame_size, 0); - s->packet_done = !decode_frame(s); - } else - s->packet_done = 1; - } - - if (s->packet_done && !s->packet_loss && - remaining_bits(s, gb) > 0) { - /** save the rest of the data so that it can be decoded - with the next packet */ - save_bits(s, gb, remaining_bits(s, gb), 0); - } - - dec[0] = s->channel[0].out; - dec[1] = s->channel[1].out; - - *data_size = s->samples; - s->packet_offset = get_bits_count(gb) & 7; - - s->frame_num++; - return (s->packet_loss) ? AVERROR_INVALIDDATA : get_bits_count(gb) >> 3; -} - -#if 0 -/** - *@brief wmapro decoder - */ -AVCodec wmapro_decoder = { - "wmapro", - AVMEDIA_TYPE_AUDIO, - CODEC_ID_WMAPRO, - sizeof(WMAProDecodeCtx), - decode_init, - NULL, - decode_end, - decode_packet, - .capabilities = CODEC_CAP_SUBFRAMES, - .flush= flush, - .long_name = NULL_IF_CONFIG_SMALL("Windows Media Audio 9 Professional"), -}; -#endif diff --git a/apps/codecs/libwmapro/wmaprodec.h b/apps/codecs/libwmapro/wmaprodec.h deleted file mode 100644 index d8398fc9f1..0000000000 --- a/apps/codecs/libwmapro/wmaprodec.h +++ /dev/null @@ -1,44 +0,0 @@ -#include "codeclib.h" -#include "wma.h" -#include "../libasf/asf.h" - -#if (CONFIG_CPU == MCF5250) -/* Enough IRAM but performance suffers with ICODE_ATTR. */ -#define IBSS_ATTR_WMAPRO_LARGE_IRAM IBSS_ATTR -#define ICODE_ATTR_WMAPRO_LARGE_IRAM -#define ICONST_ATTR_WMAPRO_LARGE_IRAM ICONST_ATTR -#define IBSS_ATTR_WMAPRO_VLC_TABLES -#define ICONST_ATTR_WMAPRO_WIN_VS_TMP - -#elif (CONFIG_CPU == PP5022) || (CONFIG_CPU == PP5024) -/* Enough IRAM to move additional data and code to it. */ -#define IBSS_ATTR_WMAPRO_LARGE_IRAM IBSS_ATTR -#define ICODE_ATTR_WMAPRO_LARGE_IRAM ICODE_ATTR -#define ICONST_ATTR_WMAPRO_LARGE_IRAM ICONST_ATTR -#define IBSS_ATTR_WMAPRO_VLC_TABLES -#define ICONST_ATTR_WMAPRO_WIN_VS_TMP - -#elif defined(CPU_S5L870X) -/* Enough IRAM to move additional data and code to it. */ -#define IBSS_ATTR_WMAPRO_LARGE_IRAM IBSS_ATTR -#define ICODE_ATTR_WMAPRO_LARGE_IRAM ICODE_ATTR -#define ICONST_ATTR_WMAPRO_LARGE_IRAM ICONST_ATTR -#define IBSS_ATTR_WMAPRO_VLC_TABLES IBSS_ATTR -#define ICONST_ATTR_WMAPRO_WIN_VS_TMP ICONST_ATTR - -#else -/* Not enough IRAM available. */ -#define IBSS_ATTR_WMAPRO_LARGE_IRAM -#define ICODE_ATTR_WMAPRO_LARGE_IRAM -#define ICONST_ATTR_WMAPRO_LARGE_IRAM -#define IBSS_ATTR_WMAPRO_VLC_TABLES -/* Models with large IRAM put tmp to IRAM rather than window coefficients as - * this is the fastest option. On models with smaller IRAM the 2nd-best option - * is to move the window coefficients to IRAM. */ -#define ICONST_ATTR_WMAPRO_WIN_VS_TMP ICONST_ATTR - -#endif - -int decode_init(asf_waveformatex_t *wfx); -int decode_packet(asf_waveformatex_t *wfx, - int32_t *dec[2], int *data_size, void* pktdata, int size); diff --git a/apps/codecs/libwmavoice/Makefile b/apps/codecs/libwmavoice/Makefile deleted file mode 100644 index 2bd7b94f9b..0000000000 --- a/apps/codecs/libwmavoice/Makefile +++ /dev/null @@ -1,64 +0,0 @@ -CC = gcc -o -INC = -I. -OUTPUT = wmavoice -STD = c99 -LIBS = -lm -CFLAGS = -Wall -ggdb -std=$(STD) $(INC) - -SOURCES = \ -acelp_filters.c\ -acelp_vectors.c\ -avfft.c\ -bitstream.c\ -celp_filters.c\ -celp_math.c\ -dct.c\ -fft.c\ -lsp.c\ -mdct.c\ -rdft.c\ -utils.c\ -wmavoice.c\ -libavutil/log.c\ -libavutil/lzo.c\ -libavutil/mem.c\ -libavutil/mathematics.c - -HEADERS = \ -acelp_vectors.h\ -celp_math.h\ -get_bits.h\ -wmavoice_data.h\ -avcodec.h\ -fft.h\ -acelp_filters.h\ -celp_filters.h\ -put_bits.h\ -lsp.h\ -internal.h\ -avfft.h\ -mathops.h\ -mdct_tablegen.h\ -dct32.c\ -libavutil/avutil.h\ -libavutil/attributes.h\ -libavutil/lzo.h\ -libavutil/mem.h\ -libavutil/log.h\ -libavutil/internal.h\ -libavutil/common.h\ -libavutil/intreadwrite.h\ -libavutil/bswap.h\ -libavutil/mathematics.h - -OBJECTS = $(SOURCES:.c=.o) - -all:$(OUTPUT) - -$(OUTPUT):$(SOURCES) $(HEADERS) - $(CC) $@ $(CFLAGS) $(SOURCES) $(LIBS) - @echo "Done." - -clean: - rm -f *.o $(OUTPUT) *~ - diff --git a/apps/codecs/libwmavoice/README.rockbox b/apps/codecs/libwmavoice/README.rockbox deleted file mode 100644 index 8115619bf0..0000000000 --- a/apps/codecs/libwmavoice/README.rockbox +++ /dev/null @@ -1,26 +0,0 @@ -Library: libwmavoice -Imported: 2010-08-07 by Mohamed Tarek - -This set of files form the files needed from ffmpeg's libavcodec and libavutil -to build a standalone wma voice decoder. - -LICENSING INFORMATION - -ffmpeg is licensed under the Lesser GNU General Public License and the file -wmavoice.c is copyright (c) 2009 Ronald S. Bultje. - -IMPORT DETAILS - -Based on ffmpeg svn r24734 dated 7 August 2010. - -As of 7 August 2010, libwmavoice contains just the files from ffmpeg with -minimum modifications to compile standalone. - -COMPILING - -the decoder can be compiled by issuing the "make" command from witin the -libwmavoice directory in any unix-line environment. - -To test the decoder in the rockbox simulator, cd to libwmavoice directory then -execute the following command to enable building wma voice: -patch -p 0 < wmavoice_mainbuild.patch diff --git a/apps/codecs/libwmavoice/SOURCES b/apps/codecs/libwmavoice/SOURCES deleted file mode 100644 index c98821c42a..0000000000 --- a/apps/codecs/libwmavoice/SOURCES +++ /dev/null @@ -1,17 +0,0 @@ -acelp_filters.c -acelp_vectors.c -avfft.c -bitstream.c -celp_filters.c -celp_math.c -dct.c -fft.c -lsp.c -mdct.c -rdft.c -utils.c -wmavoice.c -libavutil/log.c -libavutil/lzo.c -libavutil/mem.c -libavutil/mathematics.c diff --git a/apps/codecs/libwmavoice/acelp_filters.c b/apps/codecs/libwmavoice/acelp_filters.c deleted file mode 100644 index c48c0e72ce..0000000000 --- a/apps/codecs/libwmavoice/acelp_filters.c +++ /dev/null @@ -1,145 +0,0 @@ -/* - * various filters for ACELP-based codecs - * - * Copyright (c) 2008 Vladimir Voroshilov - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include - -#include "avcodec.h" -#include "acelp_filters.h" - -const int16_t ff_acelp_interp_filter[61] = { /* (0.15) */ - 29443, 28346, 25207, 20449, 14701, 8693, - 3143, -1352, -4402, -5865, -5850, -4673, - -2783, -672, 1211, 2536, 3130, 2991, - 2259, 1170, 0, -1001, -1652, -1868, - -1666, -1147, -464, 218, 756, 1060, - 1099, 904, 550, 135, -245, -514, - -634, -602, -451, -231, 0, 191, - 308, 340, 296, 198, 78, -36, - -120, -163, -165, -132, -79, -19, - 34, 73, 91, 89, 70, 38, - 0, -}; - -void ff_acelp_interpolate(int16_t* out, const int16_t* in, - const int16_t* filter_coeffs, int precision, - int frac_pos, int filter_length, int length) -{ - int n, i; - - //assert(frac_pos >= 0 && frac_pos < precision); - - for (n = 0; n < length; n++) { - int idx = 0; - int v = 0x4000; - - for (i = 0; i < filter_length;) { - - /* The reference G.729 and AMR fixed point code performs clipping after - each of the two following accumulations. - Since clipping affects only the synthetic OVERFLOW test without - causing an int type overflow, it was moved outside the loop. */ - - /* R(x):=ac_v[-k+x] - v += R(n-i)*ff_acelp_interp_filter(t+6i) - v += R(n+i+1)*ff_acelp_interp_filter(6-t+6i) */ - - v += in[n + i] * filter_coeffs[idx + frac_pos]; - idx += precision; - i++; - v += in[n - i] * filter_coeffs[idx - frac_pos]; - } - if (av_clip_int16(v >> 15) != (v >> 15)) - av_log(NULL, AV_LOG_WARNING, "overflow that would need cliping in ff_acelp_interpolate()\n"); - out[n] = v >> 15; - } -} - -void ff_acelp_interpolatef(float *out, const float *in, - const float *filter_coeffs, int precision, - int frac_pos, int filter_length, int length) -{ - int n, i; - - for (n = 0; n < length; n++) { - int idx = 0; - float v = 0; - - for (i = 0; i < filter_length;) { - v += in[n + i] * filter_coeffs[idx + frac_pos]; - idx += precision; - i++; - v += in[n - i] * filter_coeffs[idx - frac_pos]; - } - out[n] = v; - } -} - - -void ff_acelp_high_pass_filter(int16_t* out, int hpf_f[2], - const int16_t* in, int length) -{ - int i; - int tmp; - - for (i = 0; i < length; i++) { - tmp = (hpf_f[0]* 15836LL) >> 13; - tmp += (hpf_f[1]* -7667LL) >> 13; - tmp += 7699 * (in[i] - 2*in[i-1] + in[i-2]); - - /* With "+0x800" rounding, clipping is needed - for ALGTHM and SPEECH tests. */ - out[i] = av_clip_int16((tmp + 0x800) >> 12); - - hpf_f[1] = hpf_f[0]; - hpf_f[0] = tmp; - } -} - -void ff_acelp_apply_order_2_transfer_function(float *out, const float *in, - const float zero_coeffs[2], - const float pole_coeffs[2], - float gain, float mem[2], int n) -{ - int i; - float tmp; - - for (i = 0; i < n; i++) { - tmp = gain * in[i] - pole_coeffs[0] * mem[0] - pole_coeffs[1] * mem[1]; - out[i] = tmp + zero_coeffs[0] * mem[0] + zero_coeffs[1] * mem[1]; - - mem[1] = mem[0]; - mem[0] = tmp; - } -} - -void ff_tilt_compensation(float *mem, float tilt, float *samples, int size) -{ - float new_tilt_mem = samples[size - 1]; - int i; - - for (i = size - 1; i > 0; i--) - samples[i] -= tilt * samples[i - 1]; - - samples[0] -= tilt * *mem; - *mem = new_tilt_mem; -} - diff --git a/apps/codecs/libwmavoice/acelp_filters.h b/apps/codecs/libwmavoice/acelp_filters.h deleted file mode 100644 index 0b1ccf4e71..0000000000 --- a/apps/codecs/libwmavoice/acelp_filters.h +++ /dev/null @@ -1,120 +0,0 @@ -/* - * various filters for ACELP-based codecs - * - * Copyright (c) 2008 Vladimir Voroshilov - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef AVCODEC_ACELP_FILTERS_H -#define AVCODEC_ACELP_FILTERS_H - -#include - -/** - * low-pass Finite Impulse Response filter coefficients. - * - * Hamming windowed sinc filter with cutoff freq 3/40 of the sampling freq, - * the coefficients are scaled by 2^15. - * This array only contains the right half of the filter. - * This filter is likely identical to the one used in G.729, though this - * could not be determined from the original comments with certainity. - */ -extern const int16_t ff_acelp_interp_filter[61]; - -/** - * Generic FIR interpolation routine. - * @param[out] out buffer for interpolated data - * @param in input data - * @param filter_coeffs interpolation filter coefficients (0.15) - * @param precision sub sample factor, that is the precision of the position - * @param frac_pos fractional part of position [0..precision-1] - * @param filter_length filter length - * @param length length of output - * - * filter_coeffs contains coefficients of the right half of the symmetric - * interpolation filter. filter_coeffs[0] should the central (unpaired) coefficient. - * See ff_acelp_interp_filter for an example. - * - */ -void ff_acelp_interpolate(int16_t* out, const int16_t* in, - const int16_t* filter_coeffs, int precision, - int frac_pos, int filter_length, int length); - -/** - * Floating point version of ff_acelp_interpolate() - */ -void ff_acelp_interpolatef(float *out, const float *in, - const float *filter_coeffs, int precision, - int frac_pos, int filter_length, int length); - - -/** - * high-pass filtering and upscaling (4.2.5 of G.729). - * @param[out] out output buffer for filtered speech data - * @param[in,out] hpf_f past filtered data from previous (2 items long) - * frames (-0x20000000 <= (14.13) < 0x20000000) - * @param in speech data to process - * @param length input data size - * - * out[i] = 0.93980581 * in[i] - 1.8795834 * in[i-1] + 0.93980581 * in[i-2] + - * 1.9330735 * out[i-1] - 0.93589199 * out[i-2] - * - * The filter has a cut-off frequency of 1/80 of the sampling freq - * - * @note Two items before the top of the out buffer must contain two items from the - * tail of the previous subframe. - * - * @remark It is safe to pass the same array in in and out parameters. - * - * @remark AMR uses mostly the same filter (cut-off frequency 60Hz, same formula, - * but constants differs in 5th sign after comma). Fortunately in - * fixed-point all coefficients are the same as in G.729. Thus this - * routine can be used for the fixed-point AMR decoder, too. - */ -void ff_acelp_high_pass_filter(int16_t* out, int hpf_f[2], - const int16_t* in, int length); - -/** - * Apply an order 2 rational transfer function in-place. - * - * @param out output buffer for filtered speech samples - * @param in input buffer containing speech data (may be the same as out) - * @param zero_coeffs z^-1 and z^-2 coefficients of the numerator - * @param pole_coeffs z^-1 and z^-2 coefficients of the denominator - * @param gain scale factor for final output - * @param mem intermediate values used by filter (should be 0 initially) - * @param n number of samples - */ -void ff_acelp_apply_order_2_transfer_function(float *out, const float *in, - const float zero_coeffs[2], - const float pole_coeffs[2], - float gain, - float mem[2], int n); - -/** - * Apply tilt compensation filter, 1 - tilt * z-1. - * - * @param mem pointer to the filter's state (one single float) - * @param tilt tilt factor - * @param samples array where the filter is applied - * @param size the size of the samples array - */ -void ff_tilt_compensation(float *mem, float tilt, float *samples, int size); - - -#endif /* AVCODEC_ACELP_FILTERS_H */ diff --git a/apps/codecs/libwmavoice/acelp_vectors.c b/apps/codecs/libwmavoice/acelp_vectors.c deleted file mode 100644 index e41e5facb6..0000000000 --- a/apps/codecs/libwmavoice/acelp_vectors.c +++ /dev/null @@ -1,270 +0,0 @@ -/* - * adaptive and fixed codebook vector operations for ACELP-based codecs - * - * Copyright (c) 2008 Vladimir Voroshilov - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include -#include "avcodec.h" -#include "acelp_vectors.h" -#include "celp_math.h" - -const uint8_t ff_fc_2pulses_9bits_track1[16] = -{ - 1, 3, - 6, 8, - 11, 13, - 16, 18, - 21, 23, - 26, 28, - 31, 33, - 36, 38 -}; -const uint8_t ff_fc_2pulses_9bits_track1_gray[16] = -{ - 1, 3, - 8, 6, - 18, 16, - 11, 13, - 38, 36, - 31, 33, - 21, 23, - 28, 26, -}; - -const uint8_t ff_fc_2pulses_9bits_track2_gray[32] = -{ - 0, 2, - 5, 4, - 12, 10, - 7, 9, - 25, 24, - 20, 22, - 14, 15, - 19, 17, - 36, 31, - 21, 26, - 1, 6, - 16, 11, - 27, 29, - 32, 30, - 39, 37, - 34, 35, -}; - -const uint8_t ff_fc_4pulses_8bits_tracks_13[16] = -{ - 0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, -}; - -const uint8_t ff_fc_4pulses_8bits_track_4[32] = -{ - 3, 4, - 8, 9, - 13, 14, - 18, 19, - 23, 24, - 28, 29, - 33, 34, - 38, 39, - 43, 44, - 48, 49, - 53, 54, - 58, 59, - 63, 64, - 68, 69, - 73, 74, - 78, 79, -}; - -#if 0 -static uint8_t gray_decode[32] = -{ - 0, 1, 3, 2, 7, 6, 4, 5, - 15, 14, 12, 13, 8, 9, 11, 10, - 31, 30, 28, 29, 24, 25, 27, 26, - 16, 17, 19, 18, 23, 22, 20, 21 -}; -#endif - -const float ff_pow_0_7[10] = { - 0.700000, 0.490000, 0.343000, 0.240100, 0.168070, - 0.117649, 0.082354, 0.057648, 0.040354, 0.028248 -}; - -const float ff_pow_0_75[10] = { - 0.750000, 0.562500, 0.421875, 0.316406, 0.237305, - 0.177979, 0.133484, 0.100113, 0.075085, 0.056314 -}; - -const float ff_pow_0_55[10] = { - 0.550000, 0.302500, 0.166375, 0.091506, 0.050328, - 0.027681, 0.015224, 0.008373, 0.004605, 0.002533 -}; - -const float ff_b60_sinc[61] = { - 0.898529 , 0.865051 , 0.769257 , 0.624054 , 0.448639 , 0.265289 , - 0.0959167 , -0.0412598 , -0.134338 , -0.178986 , -0.178528 , -0.142609 , --0.0849304 , -0.0205078 , 0.0369568 , 0.0773926 , 0.0955200 , 0.0912781 , - 0.0689392 , 0.0357056 , 0. , -0.0305481 , -0.0504150 , -0.0570068 , --0.0508423 , -0.0350037 , -0.0141602 , 0.00665283, 0.0230713 , 0.0323486 , - 0.0335388 , 0.0275879 , 0.0167847 , 0.00411987, -0.00747681, -0.0156860 , --0.0193481 , -0.0183716 , -0.0137634 , -0.00704956, 0. , 0.00582886 , - 0.00939941, 0.0103760 , 0.00903320, 0.00604248, 0.00238037, -0.00109863 , --0.00366211, -0.00497437, -0.00503540, -0.00402832, -0.00241089, -0.000579834, - 0.00103760, 0.00222778, 0.00277710, 0.00271606, 0.00213623, 0.00115967 , - 0. -}; - -void ff_acelp_fc_pulse_per_track( - int16_t* fc_v, - const uint8_t *tab1, - const uint8_t *tab2, - int pulse_indexes, - int pulse_signs, - int pulse_count, - int bits) -{ - int mask = (1 << bits) - 1; - int i; - - for(i=0; i>= bits; - pulse_signs >>= 1; - } - - fc_v[tab2[pulse_indexes]] += (pulse_signs & 1) ? 8191 : -8192; -} - -void ff_decode_10_pulses_35bits(const int16_t *fixed_index, - AMRFixed *fixed_sparse, - const uint8_t *gray_decode, - int half_pulse_count, int bits) -{ - int i; - int mask = (1 << bits) - 1; - - fixed_sparse->no_repeat_mask = 0; - fixed_sparse->n = 2 * half_pulse_count; - for (i = 0; i < half_pulse_count; i++) { - const int pos1 = gray_decode[fixed_index[2*i+1] & mask] + i; - const int pos2 = gray_decode[fixed_index[2*i ] & mask] + i; - const float sign = (fixed_index[2*i+1] & (1 << bits)) ? -1.0 : 1.0; - fixed_sparse->x[2*i+1] = pos1; - fixed_sparse->x[2*i ] = pos2; - fixed_sparse->y[2*i+1] = sign; - fixed_sparse->y[2*i ] = pos2 < pos1 ? -sign : sign; - } -} - -void ff_acelp_weighted_vector_sum( - int16_t* out, - const int16_t *in_a, - const int16_t *in_b, - int16_t weight_coeff_a, - int16_t weight_coeff_b, - int16_t rounder, - int shift, - int length) -{ - int i; - - // Clipping required here; breaks OVERFLOW test. - for(i=0; i> shift); -} - -void ff_weighted_vector_sumf(float *out, const float *in_a, const float *in_b, - float weight_coeff_a, float weight_coeff_b, int length) -{ - int i; - - for(i=0; in; i++) { - int x = in->x[i], repeats = !((in->no_repeat_mask >> i) & 1); - float y = in->y[i] * scale; - - do { - out[x] += y; - y *= in->pitch_fac; - x += in->pitch_lag; - } while (x < size && repeats); - } -} - -void ff_clear_fixed_vector(float *out, const AMRFixed *in, int size) -{ - int i; - - for (i=0; i < in->n; i++) { - int x = in->x[i], repeats = !((in->no_repeat_mask >> i) & 1); - - do { - out[x] = 0.0; - x += in->pitch_lag; - } while (x < size && repeats); - } -} diff --git a/apps/codecs/libwmavoice/acelp_vectors.h b/apps/codecs/libwmavoice/acelp_vectors.h deleted file mode 100644 index f3bc781446..0000000000 --- a/apps/codecs/libwmavoice/acelp_vectors.h +++ /dev/null @@ -1,264 +0,0 @@ -/* - * adaptive and fixed codebook vector operations for ACELP-based codecs - * - * Copyright (c) 2008 Vladimir Voroshilov - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef AVCODEC_ACELP_VECTORS_H -#define AVCODEC_ACELP_VECTORS_H - -#include - -/** Sparse representation for the algebraic codebook (fixed) vector */ -typedef struct { - int n; - int x[10]; - float y[10]; - int no_repeat_mask; - int pitch_lag; - float pitch_fac; -} AMRFixed; - -/** - * Track|Pulse| Positions - * ------------------------------------------------------------------------- - * 1 | 0 | 0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75 - * ------------------------------------------------------------------------- - * 2 | 1 | 1, 6, 11, 16, 21, 26, 31, 36, 41, 46, 51, 56, 61, 66, 71, 76 - * ------------------------------------------------------------------------- - * 3 | 2 | 2, 7, 12, 17, 22, 27, 32, 37, 42, 47, 52, 57, 62, 67, 72, 77 - * ------------------------------------------------------------------------- - * - * Table contains only first the pulse indexes. - * - * Used in G.729 @@8k, G.729 @@4.4k, AMR @@7.95k, AMR @@7.40k - */ -extern const uint8_t ff_fc_4pulses_8bits_tracks_13[16]; - -/** - * Track|Pulse| Positions - * ------------------------------------------------------------------------- - * 4 | 3 | 3, 8, 13, 18, 23, 28, 33, 38, 43, 48, 53, 58, 63, 68, 73, 78 - * | | 4, 9, 14, 19, 24, 29, 34, 39, 44, 49, 54, 59, 64, 69, 74, 79 - * ------------------------------------------------------------------------- - * - * @remark Track in the table should be read top-to-bottom, left-to-right. - * - * Used in G.729 @@8k, G.729 @@4.4k, AMR @@7.95k, AMR @@7.40k - */ -extern const uint8_t ff_fc_4pulses_8bits_track_4[32]; - -/** - * Track|Pulse| Positions - * ----------------------------------------- - * 1 | 0 | 1, 6, 11, 16, 21, 26, 31, 36 - * | | 3, 8, 13, 18, 23, 28, 33, 38 - * ----------------------------------------- - * - * @remark Track in the table should be read top-to-bottom, left-to-right. - * - * @note (EE) Reference G.729D code also uses gray decoding for each - * pulse index before looking up the value in the table. - * - * Used in G.729 @@6.4k (with gray coding), AMR @@5.9k (without gray coding) - */ -extern const uint8_t ff_fc_2pulses_9bits_track1[16]; -extern const uint8_t ff_fc_2pulses_9bits_track1_gray[16]; - -/** - * Track|Pulse| Positions - * ----------------------------------------- - * 2 | 1 | 0, 7, 14, 20, 27, 34, 1, 21 - * | | 2, 9, 15, 22, 29, 35, 6, 26 - * | | 4,10, 17, 24, 30, 37, 11, 31 - * | | 5,12, 19, 25, 32, 39, 16, 36 - * ----------------------------------------- - * - * @remark Track in the table should be read top-to-bottom, left-to-right. - * - * @note (EE.1) This table (from the reference code) does not comply with - * the specification. - * The specification contains the following table: - * - * Track|Pulse| Positions - * ----------------------------------------- - * 2 | 1 | 0, 5, 10, 15, 20, 25, 30, 35 - * | | 1, 6, 11, 16, 21, 26, 31, 36 - * | | 2, 7, 12, 17, 22, 27, 32, 37 - * | | 4, 9, 14, 19, 24, 29, 34, 39 - * - * ----------------------------------------- - * - * @note (EE.2) Reference G.729D code also uses gray decoding for each - * pulse index before looking up the value in the table. - * - * Used in G.729 @@6.4k (with gray coding) - */ -extern const uint8_t ff_fc_2pulses_9bits_track2_gray[32]; - -/** - * b60 hamming windowed sinc function coefficients - */ -extern const float ff_b60_sinc[61]; - -/** - * Table of pow(0.7,n) - */ -extern const float ff_pow_0_7[10]; - -/** - * Table of pow(0.75,n) - */ -extern const float ff_pow_0_75[10]; - -/** - * Table of pow(0.55,n) - */ -extern const float ff_pow_0_55[10]; - -/** - * Decode fixed-codebook vector (3.8 and D.5.8 of G.729, 5.7.1 of AMR). - * @param[out] fc_v decoded fixed codebook vector (2.13) - * @param tab1 table used for first pulse_count pulses - * @param tab2 table used for last pulse - * @param pulse_indexes fixed codebook indexes - * @param pulse_signs signs of the excitation pulses (0 bit value - * means negative sign) - * @param bits number of bits per one pulse index - * @param pulse_count number of pulses decoded using first table - * @param bits length of one pulse index in bits - * - * Used in G.729 @@8k, G.729 @@4.4k, G.729 @@6.4k, AMR @@7.95k, AMR @@7.40k - */ -void ff_acelp_fc_pulse_per_track(int16_t* fc_v, - const uint8_t *tab1, - const uint8_t *tab2, - int pulse_indexes, - int pulse_signs, - int pulse_count, - int bits); - -/** - * Decode the algebraic codebook index to pulse positions and signs and - * construct the algebraic codebook vector for MODE_12k2. - * - * @note: The positions and signs are explicitly coded in MODE_12k2. - * - * @param fixed_index positions of the ten pulses - * @param fixed_sparse pointer to the algebraic codebook vector - * @param gray_decode gray decoding table - * @param half_pulse_count number of couples of pulses - * @param bits length of one pulse index in bits - */ -void ff_decode_10_pulses_35bits(const int16_t *fixed_index, - AMRFixed *fixed_sparse, - const uint8_t *gray_decode, - int half_pulse_count, int bits); - - -/** - * weighted sum of two vectors with rounding. - * @param[out] out result of addition - * @param in_a first vector - * @param in_b second vector - * @param weight_coeff_a first vector weight coefficient - * @param weight_coeff_a second vector weight coefficient - * @param rounder this value will be added to the sum of the two vectors - * @param shift result will be shifted to right by this value - * @param length vectors length - * - * @note It is safe to pass the same buffer for out and in_a or in_b. - * - * out[i] = (in_a[i]*weight_a + in_b[i]*weight_b + rounder) >> shift - */ -void ff_acelp_weighted_vector_sum(int16_t* out, - const int16_t *in_a, - const int16_t *in_b, - int16_t weight_coeff_a, - int16_t weight_coeff_b, - int16_t rounder, - int shift, - int length); - -/** - * float implementation of weighted sum of two vectors. - * @param[out] out result of addition - * @param in_a first vector - * @param in_b second vector - * @param weight_coeff_a first vector weight coefficient - * @param weight_coeff_a second vector weight coefficient - * @param length vectors length - * - * @note It is safe to pass the same buffer for out and in_a or in_b. - */ -void ff_weighted_vector_sumf(float *out, const float *in_a, const float *in_b, - float weight_coeff_a, float weight_coeff_b, - int length); - -/** - * Adaptive gain control (as used in AMR postfiltering) - * - * @param out output buffer for filtered speech data - * @param in the input speech buffer (may be the same as out) - * @param speech_energ input energy - * @param size the input buffer size - * @param alpha exponential filter factor - * @param gain_mem a pointer to the filter memory (single float of size) - */ -void ff_adaptive_gain_control(float *out, const float *in, float speech_energ, - int size, float alpha, float *gain_mem); - -/** - * Set the sum of squares of a signal by scaling - * - * @param out output samples - * @param in input samples - * @param sum_of_squares new sum of squares - * @param n number of samples - * - * @note If the input is zero (or its energy underflows), the output is zero. - * This is the behavior of AGC in the AMR reference decoder. The QCELP - * reference decoder seems to have undefined behavior. - * - * TIA/EIA/IS-733 2.4.8.3-2/3/4/5, 2.4.8.6 - * 3GPP TS 26.090 6.1 (6) - */ -void ff_scale_vector_to_given_sum_of_squares(float *out, const float *in, - float sum_of_squares, const int n); - -/** - * Add fixed vector to an array from a sparse representation - * - * @param out fixed vector with pitch sharpening - * @param in sparse fixed vector - * @param scale number to multiply the fixed vector by - * @param size the output vector size - */ -void ff_set_fixed_vector(float *out, const AMRFixed *in, float scale, int size); - -/** - * Clear array values set by set_fixed_vector - * - * @param out fixed vector to be cleared - * @param in sparse fixed vector - * @param size the output vector size - */ -void ff_clear_fixed_vector(float *out, const AMRFixed *in, int size); - -#endif /* AVCODEC_ACELP_VECTORS_H */ diff --git a/apps/codecs/libwmavoice/avcodec.h b/apps/codecs/libwmavoice/avcodec.h deleted file mode 100644 index db08ab3c5f..0000000000 --- a/apps/codecs/libwmavoice/avcodec.h +++ /dev/null @@ -1,4044 +0,0 @@ -/* - * copyright (c) 2001 Fabrice Bellard - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef AVCODEC_AVCODEC_H -#define AVCODEC_AVCODEC_H - -/** - * @file - * external API header - */ - -#include -#include "libavutil/avutil.h" - -#define LIBAVCODEC_VERSION_MAJOR 52 -#define LIBAVCODEC_VERSION_MINOR 84 -#define LIBAVCODEC_VERSION_MICRO 3 - -#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ - LIBAVCODEC_VERSION_MINOR, \ - LIBAVCODEC_VERSION_MICRO) -#define LIBAVCODEC_VERSION AV_VERSION(LIBAVCODEC_VERSION_MAJOR, \ - LIBAVCODEC_VERSION_MINOR, \ - LIBAVCODEC_VERSION_MICRO) -#define LIBAVCODEC_BUILD LIBAVCODEC_VERSION_INT - -#define LIBAVCODEC_IDENT "Lavc" AV_STRINGIFY(LIBAVCODEC_VERSION) - -#define AV_NOPTS_VALUE INT64_C(0x8000000000000000) -#define AV_TIME_BASE 1000000 -#define AV_TIME_BASE_Q (AVRational){1, AV_TIME_BASE} - -/** - * Identify the syntax and semantics of the bitstream. - * The principle is roughly: - * Two decoders with the same ID can decode the same streams. - * Two encoders with the same ID can encode compatible streams. - * There may be slight deviations from the principle due to implementation - * details. - * - * If you add a codec ID to this list, add it so that - * 1. no value of a existing codec ID changes (that would break ABI), - * 2. it is as close as possible to similar codecs. - */ -enum CodecID { - CODEC_ID_NONE, - - /* video codecs */ - CODEC_ID_MPEG1VIDEO, - CODEC_ID_MPEG2VIDEO, ///< preferred ID for MPEG-1/2 video decoding - CODEC_ID_MPEG2VIDEO_XVMC, - CODEC_ID_H261, - CODEC_ID_H263, - CODEC_ID_RV10, - CODEC_ID_RV20, - CODEC_ID_MJPEG, - CODEC_ID_MJPEGB, - CODEC_ID_LJPEG, - CODEC_ID_SP5X, - CODEC_ID_JPEGLS, - CODEC_ID_MPEG4, - CODEC_ID_RAWVIDEO, - CODEC_ID_MSMPEG4V1, - CODEC_ID_MSMPEG4V2, - CODEC_ID_MSMPEG4V3, - CODEC_ID_WMV1, - CODEC_ID_WMV2, - CODEC_ID_H263P, - CODEC_ID_H263I, - CODEC_ID_FLV1, - CODEC_ID_SVQ1, - CODEC_ID_SVQ3, - CODEC_ID_DVVIDEO, - CODEC_ID_HUFFYUV, - CODEC_ID_CYUV, - CODEC_ID_H264, - CODEC_ID_INDEO3, - CODEC_ID_VP3, - CODEC_ID_THEORA, - CODEC_ID_ASV1, - CODEC_ID_ASV2, - CODEC_ID_FFV1, - CODEC_ID_4XM, - CODEC_ID_VCR1, - CODEC_ID_CLJR, - CODEC_ID_MDEC, - CODEC_ID_ROQ, - CODEC_ID_INTERPLAY_VIDEO, - CODEC_ID_XAN_WC3, - CODEC_ID_XAN_WC4, - CODEC_ID_RPZA, - CODEC_ID_CINEPAK, - CODEC_ID_WS_VQA, - CODEC_ID_MSRLE, - CODEC_ID_MSVIDEO1, - CODEC_ID_IDCIN, - CODEC_ID_8BPS, - CODEC_ID_SMC, - CODEC_ID_FLIC, - CODEC_ID_TRUEMOTION1, - CODEC_ID_VMDVIDEO, - CODEC_ID_MSZH, - CODEC_ID_ZLIB, - CODEC_ID_QTRLE, - CODEC_ID_SNOW, - CODEC_ID_TSCC, - CODEC_ID_ULTI, - CODEC_ID_QDRAW, - CODEC_ID_VIXL, - CODEC_ID_QPEG, -#if LIBAVCODEC_VERSION_MAJOR < 53 - CODEC_ID_XVID, -#endif - CODEC_ID_PNG, - CODEC_ID_PPM, - CODEC_ID_PBM, - CODEC_ID_PGM, - CODEC_ID_PGMYUV, - CODEC_ID_PAM, - CODEC_ID_FFVHUFF, - CODEC_ID_RV30, - CODEC_ID_RV40, - CODEC_ID_VC1, - CODEC_ID_WMV3, - CODEC_ID_LOCO, - CODEC_ID_WNV1, - CODEC_ID_AASC, - CODEC_ID_INDEO2, - CODEC_ID_FRAPS, - CODEC_ID_TRUEMOTION2, - CODEC_ID_BMP, - CODEC_ID_CSCD, - CODEC_ID_MMVIDEO, - CODEC_ID_ZMBV, - CODEC_ID_AVS, - CODEC_ID_SMACKVIDEO, - CODEC_ID_NUV, - CODEC_ID_KMVC, - CODEC_ID_FLASHSV, - CODEC_ID_CAVS, - CODEC_ID_JPEG2000, - CODEC_ID_VMNC, - CODEC_ID_VP5, - CODEC_ID_VP6, - CODEC_ID_VP6F, - CODEC_ID_TARGA, - CODEC_ID_DSICINVIDEO, - CODEC_ID_TIERTEXSEQVIDEO, - CODEC_ID_TIFF, - CODEC_ID_GIF, - CODEC_ID_FFH264, - CODEC_ID_DXA, - CODEC_ID_DNXHD, - CODEC_ID_THP, - CODEC_ID_SGI, - CODEC_ID_C93, - CODEC_ID_BETHSOFTVID, - CODEC_ID_PTX, - CODEC_ID_TXD, - CODEC_ID_VP6A, - CODEC_ID_AMV, - CODEC_ID_VB, - CODEC_ID_PCX, - CODEC_ID_SUNRAST, - CODEC_ID_INDEO4, - CODEC_ID_INDEO5, - CODEC_ID_MIMIC, - CODEC_ID_RL2, - CODEC_ID_8SVX_EXP, - CODEC_ID_8SVX_FIB, - CODEC_ID_ESCAPE124, - CODEC_ID_DIRAC, - CODEC_ID_BFI, - CODEC_ID_CMV, - CODEC_ID_MOTIONPIXELS, - CODEC_ID_TGV, - CODEC_ID_TGQ, - CODEC_ID_TQI, - CODEC_ID_AURA, - CODEC_ID_AURA2, - CODEC_ID_V210X, - CODEC_ID_TMV, - CODEC_ID_V210, - CODEC_ID_DPX, - CODEC_ID_MAD, - CODEC_ID_FRWU, - CODEC_ID_FLASHSV2, - CODEC_ID_CDGRAPHICS, - CODEC_ID_R210, - CODEC_ID_ANM, - CODEC_ID_BINKVIDEO, - CODEC_ID_IFF_ILBM, - CODEC_ID_IFF_BYTERUN1, - CODEC_ID_KGV1, - CODEC_ID_YOP, - CODEC_ID_VP8, - CODEC_ID_PICTOR, - CODEC_ID_ANSI, - - /* various PCM "codecs" */ - CODEC_ID_PCM_S16LE= 0x10000, - CODEC_ID_PCM_S16BE, - CODEC_ID_PCM_U16LE, - CODEC_ID_PCM_U16BE, - CODEC_ID_PCM_S8, - CODEC_ID_PCM_U8, - CODEC_ID_PCM_MULAW, - CODEC_ID_PCM_ALAW, - CODEC_ID_PCM_S32LE, - CODEC_ID_PCM_S32BE, - CODEC_ID_PCM_U32LE, - CODEC_ID_PCM_U32BE, - CODEC_ID_PCM_S24LE, - CODEC_ID_PCM_S24BE, - CODEC_ID_PCM_U24LE, - CODEC_ID_PCM_U24BE, - CODEC_ID_PCM_S24DAUD, - CODEC_ID_PCM_ZORK, - CODEC_ID_PCM_S16LE_PLANAR, - CODEC_ID_PCM_DVD, - CODEC_ID_PCM_F32BE, - CODEC_ID_PCM_F32LE, - CODEC_ID_PCM_F64BE, - CODEC_ID_PCM_F64LE, - CODEC_ID_PCM_BLURAY, - - /* various ADPCM codecs */ - CODEC_ID_ADPCM_IMA_QT= 0x11000, - CODEC_ID_ADPCM_IMA_WAV, - CODEC_ID_ADPCM_IMA_DK3, - CODEC_ID_ADPCM_IMA_DK4, - CODEC_ID_ADPCM_IMA_WS, - CODEC_ID_ADPCM_IMA_SMJPEG, - CODEC_ID_ADPCM_MS, - CODEC_ID_ADPCM_4XM, - CODEC_ID_ADPCM_XA, - CODEC_ID_ADPCM_ADX, - CODEC_ID_ADPCM_EA, - CODEC_ID_ADPCM_G726, - CODEC_ID_ADPCM_CT, - CODEC_ID_ADPCM_SWF, - CODEC_ID_ADPCM_YAMAHA, - CODEC_ID_ADPCM_SBPRO_4, - CODEC_ID_ADPCM_SBPRO_3, - CODEC_ID_ADPCM_SBPRO_2, - CODEC_ID_ADPCM_THP, - CODEC_ID_ADPCM_IMA_AMV, - CODEC_ID_ADPCM_EA_R1, - CODEC_ID_ADPCM_EA_R3, - CODEC_ID_ADPCM_EA_R2, - CODEC_ID_ADPCM_IMA_EA_SEAD, - CODEC_ID_ADPCM_IMA_EA_EACS, - CODEC_ID_ADPCM_EA_XAS, - CODEC_ID_ADPCM_EA_MAXIS_XA, - CODEC_ID_ADPCM_IMA_ISS, - - /* AMR */ - CODEC_ID_AMR_NB= 0x12000, - CODEC_ID_AMR_WB, - - /* RealAudio codecs*/ - CODEC_ID_RA_144= 0x13000, - CODEC_ID_RA_288, - - /* various DPCM codecs */ - CODEC_ID_ROQ_DPCM= 0x14000, - CODEC_ID_INTERPLAY_DPCM, - CODEC_ID_XAN_DPCM, - CODEC_ID_SOL_DPCM, - - /* audio codecs */ - CODEC_ID_MP2= 0x15000, - CODEC_ID_MP3, ///< preferred ID for decoding MPEG audio layer 1, 2 or 3 - CODEC_ID_AAC, - CODEC_ID_AC3, - CODEC_ID_DTS, - CODEC_ID_VORBIS, - CODEC_ID_DVAUDIO, - CODEC_ID_WMAV1, - CODEC_ID_WMAV2, - CODEC_ID_MACE3, - CODEC_ID_MACE6, - CODEC_ID_VMDAUDIO, - CODEC_ID_SONIC, - CODEC_ID_SONIC_LS, - CODEC_ID_FLAC, - CODEC_ID_MP3ADU, - CODEC_ID_MP3ON4, - CODEC_ID_SHORTEN, - CODEC_ID_ALAC, - CODEC_ID_WESTWOOD_SND1, - CODEC_ID_GSM, ///< as in Berlin toast format - CODEC_ID_QDM2, - CODEC_ID_COOK, - CODEC_ID_TRUESPEECH, - CODEC_ID_TTA, - CODEC_ID_SMACKAUDIO, - CODEC_ID_QCELP, - CODEC_ID_WAVPACK, - CODEC_ID_DSICINAUDIO, - CODEC_ID_IMC, - CODEC_ID_MUSEPACK7, - CODEC_ID_MLP, - CODEC_ID_GSM_MS, /* as found in WAV */ - CODEC_ID_ATRAC3, - CODEC_ID_VOXWARE, - CODEC_ID_APE, - CODEC_ID_NELLYMOSER, - CODEC_ID_MUSEPACK8, - CODEC_ID_SPEEX, - CODEC_ID_WMAVOICE, - CODEC_ID_WMAPRO, - CODEC_ID_WMALOSSLESS, - CODEC_ID_ATRAC3P, - CODEC_ID_EAC3, - CODEC_ID_SIPR, - CODEC_ID_MP1, - CODEC_ID_TWINVQ, - CODEC_ID_TRUEHD, - CODEC_ID_MP4ALS, - CODEC_ID_ATRAC1, - CODEC_ID_BINKAUDIO_RDFT, - CODEC_ID_BINKAUDIO_DCT, - - /* subtitle codecs */ - CODEC_ID_DVD_SUBTITLE= 0x17000, - CODEC_ID_DVB_SUBTITLE, - CODEC_ID_TEXT, ///< raw UTF-8 text - CODEC_ID_XSUB, - CODEC_ID_SSA, - CODEC_ID_MOV_TEXT, - CODEC_ID_HDMV_PGS_SUBTITLE, - CODEC_ID_DVB_TELETEXT, - CODEC_ID_SRT, - - /* other specific kind of codecs (generally used for attachments) */ - CODEC_ID_TTF= 0x18000, - - CODEC_ID_PROBE= 0x19000, ///< codec_id is not known (like CODEC_ID_NONE) but lavf should attempt to identify it - - CODEC_ID_MPEG2TS= 0x20000, /**< _FAKE_ codec to indicate a raw MPEG-2 TS - * stream (only used by libavformat) */ -}; - -#if LIBAVCODEC_VERSION_MAJOR < 53 -#define CodecType AVMediaType - -#define CODEC_TYPE_UNKNOWN AVMEDIA_TYPE_UNKNOWN -#define CODEC_TYPE_VIDEO AVMEDIA_TYPE_VIDEO -#define CODEC_TYPE_AUDIO AVMEDIA_TYPE_AUDIO -#define CODEC_TYPE_DATA AVMEDIA_TYPE_DATA -#define CODEC_TYPE_SUBTITLE AVMEDIA_TYPE_SUBTITLE -#define CODEC_TYPE_ATTACHMENT AVMEDIA_TYPE_ATTACHMENT -#define CODEC_TYPE_NB AVMEDIA_TYPE_NB -#endif - -/** - * all in native-endian format - */ -enum SampleFormat { - SAMPLE_FMT_NONE = -1, - SAMPLE_FMT_U8, ///< unsigned 8 bits - SAMPLE_FMT_S16, ///< signed 16 bits - SAMPLE_FMT_S32, ///< signed 32 bits - SAMPLE_FMT_FLT, ///< float - SAMPLE_FMT_DBL, ///< double - SAMPLE_FMT_NB ///< Number of sample formats. DO NOT USE if dynamically linking to libavcodec -}; - -/* Audio channel masks */ -#define CH_FRONT_LEFT 0x00000001 -#define CH_FRONT_RIGHT 0x00000002 -#define CH_FRONT_CENTER 0x00000004 -#define CH_LOW_FREQUENCY 0x00000008 -#define CH_BACK_LEFT 0x00000010 -#define CH_BACK_RIGHT 0x00000020 -#define CH_FRONT_LEFT_OF_CENTER 0x00000040 -#define CH_FRONT_RIGHT_OF_CENTER 0x00000080 -#define CH_BACK_CENTER 0x00000100 -#define CH_SIDE_LEFT 0x00000200 -#define CH_SIDE_RIGHT 0x00000400 -#define CH_TOP_CENTER 0x00000800 -#define CH_TOP_FRONT_LEFT 0x00001000 -#define CH_TOP_FRONT_CENTER 0x00002000 -#define CH_TOP_FRONT_RIGHT 0x00004000 -#define CH_TOP_BACK_LEFT 0x00008000 -#define CH_TOP_BACK_CENTER 0x00010000 -#define CH_TOP_BACK_RIGHT 0x00020000 -#define CH_STEREO_LEFT 0x20000000 ///< Stereo downmix. -#define CH_STEREO_RIGHT 0x40000000 ///< See CH_STEREO_LEFT. - -/** Channel mask value used for AVCodecContext.request_channel_layout - to indicate that the user requests the channel order of the decoder output - to be the native codec channel order. */ -#define CH_LAYOUT_NATIVE 0x8000000000000000LL - -/* Audio channel convenience macros */ -#define CH_LAYOUT_MONO (CH_FRONT_CENTER) -#define CH_LAYOUT_STEREO (CH_FRONT_LEFT|CH_FRONT_RIGHT) -#define CH_LAYOUT_2_1 (CH_LAYOUT_STEREO|CH_BACK_CENTER) -#define CH_LAYOUT_SURROUND (CH_LAYOUT_STEREO|CH_FRONT_CENTER) -#define CH_LAYOUT_4POINT0 (CH_LAYOUT_SURROUND|CH_BACK_CENTER) -#define CH_LAYOUT_2_2 (CH_LAYOUT_STEREO|CH_SIDE_LEFT|CH_SIDE_RIGHT) -#define CH_LAYOUT_QUAD (CH_LAYOUT_STEREO|CH_BACK_LEFT|CH_BACK_RIGHT) -#define CH_LAYOUT_5POINT0 (CH_LAYOUT_SURROUND|CH_SIDE_LEFT|CH_SIDE_RIGHT) -#define CH_LAYOUT_5POINT1 (CH_LAYOUT_5POINT0|CH_LOW_FREQUENCY) -#define CH_LAYOUT_5POINT0_BACK (CH_LAYOUT_SURROUND|CH_BACK_LEFT|CH_BACK_RIGHT) -#define CH_LAYOUT_5POINT1_BACK (CH_LAYOUT_5POINT0_BACK|CH_LOW_FREQUENCY) -#define CH_LAYOUT_7POINT0 (CH_LAYOUT_5POINT0|CH_BACK_LEFT|CH_BACK_RIGHT) -#define CH_LAYOUT_7POINT1 (CH_LAYOUT_5POINT1|CH_BACK_LEFT|CH_BACK_RIGHT) -#define CH_LAYOUT_7POINT1_WIDE (CH_LAYOUT_5POINT1_BACK|\ - CH_FRONT_LEFT_OF_CENTER|CH_FRONT_RIGHT_OF_CENTER) -#define CH_LAYOUT_STEREO_DOWNMIX (CH_STEREO_LEFT|CH_STEREO_RIGHT) - -/* in bytes */ -#define AVCODEC_MAX_AUDIO_FRAME_SIZE 192000 // 1 second of 48khz 32bit audio - -/** - * Required number of additionally allocated bytes at the end of the input bitstream for decoding. - * This is mainly needed because some optimized bitstream readers read - * 32 or 64 bit at once and could read over the end.
- * Note: If the first 23 bits of the additional bytes are not 0, then damaged - * MPEG bitstreams could cause overread and segfault. - */ -#define FF_INPUT_BUFFER_PADDING_SIZE 8 - -/** - * minimum encoding buffer size - * Used to avoid some checks during header writing. - */ -#define FF_MIN_BUFFER_SIZE 16384 - - -/** - * motion estimation type. - */ -enum Motion_Est_ID { - ME_ZERO = 1, ///< no search, that is use 0,0 vector whenever one is needed - ME_FULL, - ME_LOG, - ME_PHODS, - ME_EPZS, ///< enhanced predictive zonal search - ME_X1, ///< reserved for experiments - ME_HEX, ///< hexagon based search - ME_UMH, ///< uneven multi-hexagon search - ME_ITER, ///< iterative search - ME_TESA, ///< transformed exhaustive search algorithm -}; - -enum AVDiscard{ - /* We leave some space between them for extensions (drop some - * keyframes for intra-only or drop just some bidir frames). */ - AVDISCARD_NONE =-16, ///< discard nothing - AVDISCARD_DEFAULT= 0, ///< discard useless packets like 0 size packets in avi - AVDISCARD_NONREF = 8, ///< discard all non reference - AVDISCARD_BIDIR = 16, ///< discard all bidirectional frames - AVDISCARD_NONKEY = 32, ///< discard all frames except keyframes - AVDISCARD_ALL = 48, ///< discard all -}; - -enum AVColorPrimaries{ - AVCOL_PRI_BT709 =1, ///< also ITU-R BT1361 / IEC 61966-2-4 / SMPTE RP177 Annex B - AVCOL_PRI_UNSPECIFIED=2, - AVCOL_PRI_BT470M =4, - AVCOL_PRI_BT470BG =5, ///< also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM - AVCOL_PRI_SMPTE170M =6, ///< also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC - AVCOL_PRI_SMPTE240M =7, ///< functionally identical to above - AVCOL_PRI_FILM =8, - AVCOL_PRI_NB , ///< Not part of ABI -}; - -enum AVColorTransferCharacteristic{ - AVCOL_TRC_BT709 =1, ///< also ITU-R BT1361 - AVCOL_TRC_UNSPECIFIED=2, - AVCOL_TRC_GAMMA22 =4, ///< also ITU-R BT470M / ITU-R BT1700 625 PAL & SECAM - AVCOL_TRC_GAMMA28 =5, ///< also ITU-R BT470BG - AVCOL_TRC_NB , ///< Not part of ABI -}; - -enum AVColorSpace{ - AVCOL_SPC_RGB =0, - AVCOL_SPC_BT709 =1, ///< also ITU-R BT1361 / IEC 61966-2-4 xvYCC709 / SMPTE RP177 Annex B - AVCOL_SPC_UNSPECIFIED=2, - AVCOL_SPC_FCC =4, - AVCOL_SPC_BT470BG =5, ///< also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM / IEC 61966-2-4 xvYCC601 - AVCOL_SPC_SMPTE170M =6, ///< also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC / functionally identical to above - AVCOL_SPC_SMPTE240M =7, - AVCOL_SPC_NB , ///< Not part of ABI -}; - -enum AVColorRange{ - AVCOL_RANGE_UNSPECIFIED=0, - AVCOL_RANGE_MPEG =1, ///< the normal 219*2^(n-8) "MPEG" YUV ranges - AVCOL_RANGE_JPEG =2, ///< the normal 2^n-1 "JPEG" YUV ranges - AVCOL_RANGE_NB , ///< Not part of ABI -}; - -/** - * X X 3 4 X X are luma samples, - * 1 2 1-6 are possible chroma positions - * X X 5 6 X 0 is undefined/unknown position - */ -enum AVChromaLocation{ - AVCHROMA_LOC_UNSPECIFIED=0, - AVCHROMA_LOC_LEFT =1, ///< mpeg2/4, h264 default - AVCHROMA_LOC_CENTER =2, ///< mpeg1, jpeg, h263 - AVCHROMA_LOC_TOPLEFT =3, ///< DV - AVCHROMA_LOC_TOP =4, - AVCHROMA_LOC_BOTTOMLEFT =5, - AVCHROMA_LOC_BOTTOM =6, - AVCHROMA_LOC_NB , ///< Not part of ABI -}; - -/** - * LPC analysis type - */ -enum AVLPCType { - AV_LPC_TYPE_DEFAULT = -1, ///< use the codec default LPC type - AV_LPC_TYPE_NONE = 0, ///< do not use LPC prediction or use all zero coefficients - AV_LPC_TYPE_FIXED = 1, ///< fixed LPC coefficients - AV_LPC_TYPE_LEVINSON = 2, ///< Levinson-Durbin recursion - AV_LPC_TYPE_CHOLESKY = 3, ///< Cholesky factorization - AV_LPC_TYPE_NB , ///< Not part of ABI -}; - -typedef struct RcOverride{ - int start_frame; - int end_frame; - int qscale; // If this is 0 then quality_factor will be used instead. - float quality_factor; -} RcOverride; - -#define FF_MAX_B_FRAMES 16 - -/* encoding support - These flags can be passed in AVCodecContext.flags before initialization. - Note: Not everything is supported yet. -*/ - -#define CODEC_FLAG_QSCALE 0x0002 ///< Use fixed qscale. -#define CODEC_FLAG_4MV 0x0004 ///< 4 MV per MB allowed / advanced prediction for H.263. -#define CODEC_FLAG_QPEL 0x0010 ///< Use qpel MC. -#define CODEC_FLAG_GMC 0x0020 ///< Use GMC. -#define CODEC_FLAG_MV0 0x0040 ///< Always try a MB with MV=<0,0>. -#define CODEC_FLAG_PART 0x0080 ///< Use data partitioning. -/** - * The parent program guarantees that the input for B-frames containing - * streams is not written to for at least s->max_b_frames+1 frames, if - * this is not set the input will be copied. - */ -#define CODEC_FLAG_INPUT_PRESERVED 0x0100 -#define CODEC_FLAG_PASS1 0x0200 ///< Use internal 2pass ratecontrol in first pass mode. -#define CODEC_FLAG_PASS2 0x0400 ///< Use internal 2pass ratecontrol in second pass mode. -#define CODEC_FLAG_EXTERN_HUFF 0x1000 ///< Use external Huffman table (for MJPEG). -#define CODEC_FLAG_GRAY 0x2000 ///< Only decode/encode grayscale. -#define CODEC_FLAG_EMU_EDGE 0x4000 ///< Don't draw edges. -#define CODEC_FLAG_PSNR 0x8000 ///< error[?] variables will be set during encoding. -#define CODEC_FLAG_TRUNCATED 0x00010000 /** Input bitstream might be truncated at a random - location instead of only at frame boundaries. */ -#define CODEC_FLAG_NORMALIZE_AQP 0x00020000 ///< Normalize adaptive quantization. -#define CODEC_FLAG_INTERLACED_DCT 0x00040000 ///< Use interlaced DCT. -#define CODEC_FLAG_LOW_DELAY 0x00080000 ///< Force low delay. -#define CODEC_FLAG_ALT_SCAN 0x00100000 ///< Use alternate scan. -#define CODEC_FLAG_GLOBAL_HEADER 0x00400000 ///< Place global headers in extradata instead of every keyframe. -#define CODEC_FLAG_BITEXACT 0x00800000 ///< Use only bitexact stuff (except (I)DCT). -/* Fx : Flag for h263+ extra options */ -#define CODEC_FLAG_AC_PRED 0x01000000 ///< H.263 advanced intra coding / MPEG-4 AC prediction -#define CODEC_FLAG_H263P_UMV 0x02000000 ///< unlimited motion vector -#define CODEC_FLAG_CBP_RD 0x04000000 ///< Use rate distortion optimization for cbp. -#define CODEC_FLAG_QP_RD 0x08000000 ///< Use rate distortion optimization for qp selectioon. -#define CODEC_FLAG_H263P_AIV 0x00000008 ///< H.263 alternative inter VLC -#define CODEC_FLAG_OBMC 0x00000001 ///< OBMC -#define CODEC_FLAG_LOOP_FILTER 0x00000800 ///< loop filter -#define CODEC_FLAG_H263P_SLICE_STRUCT 0x10000000 -#define CODEC_FLAG_INTERLACED_ME 0x20000000 ///< interlaced motion estimation -#define CODEC_FLAG_SVCD_SCAN_OFFSET 0x40000000 ///< Will reserve space for SVCD scan offset user data. -#define CODEC_FLAG_CLOSED_GOP 0x80000000 -#define CODEC_FLAG2_FAST 0x00000001 ///< Allow non spec compliant speedup tricks. -#define CODEC_FLAG2_STRICT_GOP 0x00000002 ///< Strictly enforce GOP size. -#define CODEC_FLAG2_NO_OUTPUT 0x00000004 ///< Skip bitstream encoding. -#define CODEC_FLAG2_LOCAL_HEADER 0x00000008 ///< Place global headers at every keyframe instead of in extradata. -#define CODEC_FLAG2_BPYRAMID 0x00000010 ///< H.264 allow B-frames to be used as references. -#define CODEC_FLAG2_WPRED 0x00000020 ///< H.264 weighted biprediction for B-frames -#define CODEC_FLAG2_MIXED_REFS 0x00000040 ///< H.264 one reference per partition, as opposed to one reference per macroblock -#define CODEC_FLAG2_8X8DCT 0x00000080 ///< H.264 high profile 8x8 transform -#define CODEC_FLAG2_FASTPSKIP 0x00000100 ///< H.264 fast pskip -#define CODEC_FLAG2_AUD 0x00000200 ///< H.264 access unit delimiters -#define CODEC_FLAG2_BRDO 0x00000400 ///< B-frame rate-distortion optimization -#define CODEC_FLAG2_INTRA_VLC 0x00000800 ///< Use MPEG-2 intra VLC table. -#define CODEC_FLAG2_MEMC_ONLY 0x00001000 ///< Only do ME/MC (I frames -> ref, P frame -> ME+MC). -#define CODEC_FLAG2_DROP_FRAME_TIMECODE 0x00002000 ///< timecode is in drop frame format. -#define CODEC_FLAG2_SKIP_RD 0x00004000 ///< RD optimal MB level residual skipping -#define CODEC_FLAG2_CHUNKS 0x00008000 ///< Input bitstream might be truncated at a packet boundaries instead of only at frame boundaries. -#define CODEC_FLAG2_NON_LINEAR_QUANT 0x00010000 ///< Use MPEG-2 nonlinear quantizer. -#define CODEC_FLAG2_BIT_RESERVOIR 0x00020000 ///< Use a bit reservoir when encoding if possible -#define CODEC_FLAG2_MBTREE 0x00040000 ///< Use macroblock tree ratecontrol (x264 only) -#define CODEC_FLAG2_PSY 0x00080000 ///< Use psycho visual optimizations. -#define CODEC_FLAG2_SSIM 0x00100000 ///< Compute SSIM during encoding, error[] values are undefined. -#define CODEC_FLAG2_INTRA_REFRESH 0x00200000 ///< Use periodic insertion of intra blocks instead of keyframes. - -/* Unsupported options : - * Syntax Arithmetic coding (SAC) - * Reference Picture Selection - * Independent Segment Decoding */ -/* /Fx */ -/* codec capabilities */ - -#define CODEC_CAP_DRAW_HORIZ_BAND 0x0001 ///< Decoder can use draw_horiz_band callback. -/** - * Codec uses get_buffer() for allocating buffers and supports custom allocators. - * If not set, it might not use get_buffer() at all or use operations that - * assume the buffer was allocated by avcodec_default_get_buffer. - */ -#define CODEC_CAP_DR1 0x0002 -/* If 'parse_only' field is true, then avcodec_parse_frame() can be used. */ -#define CODEC_CAP_PARSE_ONLY 0x0004 -#define CODEC_CAP_TRUNCATED 0x0008 -/* Codec can export data for HW decoding (XvMC). */ -#define CODEC_CAP_HWACCEL 0x0010 -/** - * Codec has a nonzero delay and needs to be fed with NULL at the end to get the delayed data. - * If this is not set, the codec is guaranteed to never be fed with NULL data. - */ -#define CODEC_CAP_DELAY 0x0020 -/** - * Codec can be fed a final frame with a smaller size. - * This can be used to prevent truncation of the last audio samples. - */ -#define CODEC_CAP_SMALL_LAST_FRAME 0x0040 -/** - * Codec can export data for HW decoding (VDPAU). - */ -#define CODEC_CAP_HWACCEL_VDPAU 0x0080 -/** - * Codec can output multiple frames per AVPacket - * Normally demuxers return one frame at a time, demuxers which do not do - * are connected to a parser to split what they return into proper frames. - * This flag is reserved to the very rare category of codecs which have a - * bitstream that cannot be split into frames without timeconsuming - * operations like full decoding. Demuxers carring such bitstreams thus - * may return multiple frames in a packet. This has many disadvantages like - * prohibiting stream copy in many cases thus it should only be considered - * as a last resort. - */ -#define CODEC_CAP_SUBFRAMES 0x0100 -/** - * Codec is experimental and is thus avoided in favor of non experimental - * encoders - */ -#define CODEC_CAP_EXPERIMENTAL 0x0200 - -//The following defines may change, don't expect compatibility if you use them. -#define MB_TYPE_INTRA4x4 0x0001 -#define MB_TYPE_INTRA16x16 0x0002 //FIXME H.264-specific -#define MB_TYPE_INTRA_PCM 0x0004 //FIXME H.264-specific -#define MB_TYPE_16x16 0x0008 -#define MB_TYPE_16x8 0x0010 -#define MB_TYPE_8x16 0x0020 -#define MB_TYPE_8x8 0x0040 -#define MB_TYPE_INTERLACED 0x0080 -#define MB_TYPE_DIRECT2 0x0100 //FIXME -#define MB_TYPE_ACPRED 0x0200 -#define MB_TYPE_GMC 0x0400 -#define MB_TYPE_SKIP 0x0800 -#define MB_TYPE_P0L0 0x1000 -#define MB_TYPE_P1L0 0x2000 -#define MB_TYPE_P0L1 0x4000 -#define MB_TYPE_P1L1 0x8000 -#define MB_TYPE_L0 (MB_TYPE_P0L0 | MB_TYPE_P1L0) -#define MB_TYPE_L1 (MB_TYPE_P0L1 | MB_TYPE_P1L1) -#define MB_TYPE_L0L1 (MB_TYPE_L0 | MB_TYPE_L1) -#define MB_TYPE_QUANT 0x00010000 -#define MB_TYPE_CBP 0x00020000 -//Note bits 24-31 are reserved for codec specific use (h264 ref0, mpeg1 0mv, ...) - -/** - * Pan Scan area. - * This specifies the area which should be displayed. - * Note there may be multiple such areas for one frame. - */ -typedef struct AVPanScan{ - /** - * id - * - encoding: Set by user. - * - decoding: Set by libavcodec. - */ - int id; - - /** - * width and height in 1/16 pel - * - encoding: Set by user. - * - decoding: Set by libavcodec. - */ - int width; - int height; - - /** - * position of the top left corner in 1/16 pel for up to 3 fields/frames - * - encoding: Set by user. - * - decoding: Set by libavcodec. - */ - int16_t position[3][2]; -}AVPanScan; - -#define FF_COMMON_FRAME \ - /**\ - * pointer to the picture planes.\ - * This might be different from the first allocated byte\ - * - encoding: \ - * - decoding: \ - */\ - uint8_t *data[4];\ - int linesize[4];\ - /**\ - * pointer to the first allocated byte of the picture. Can be used in get_buffer/release_buffer.\ - * This isn't used by libavcodec unless the default get/release_buffer() is used.\ - * - encoding: \ - * - decoding: \ - */\ - uint8_t *base[4];\ - /**\ - * 1 -> keyframe, 0-> not\ - * - encoding: Set by libavcodec.\ - * - decoding: Set by libavcodec.\ - */\ - int key_frame;\ -\ - /**\ - * Picture type of the frame, see ?_TYPE below.\ - * - encoding: Set by libavcodec. for coded_picture (and set by user for input).\ - * - decoding: Set by libavcodec.\ - */\ - int pict_type;\ -\ - /**\ - * presentation timestamp in time_base units (time when frame should be shown to user)\ - * If AV_NOPTS_VALUE then frame_rate = 1/time_base will be assumed.\ - * - encoding: MUST be set by user.\ - * - decoding: Set by libavcodec.\ - */\ - int64_t pts;\ -\ - /**\ - * picture number in bitstream order\ - * - encoding: set by\ - * - decoding: Set by libavcodec.\ - */\ - int coded_picture_number;\ - /**\ - * picture number in display order\ - * - encoding: set by\ - * - decoding: Set by libavcodec.\ - */\ - int display_picture_number;\ -\ - /**\ - * quality (between 1 (good) and FF_LAMBDA_MAX (bad)) \ - * - encoding: Set by libavcodec. for coded_picture (and set by user for input).\ - * - decoding: Set by libavcodec.\ - */\ - int quality; \ -\ - /**\ - * buffer age (1->was last buffer and dint change, 2->..., ...).\ - * Set to INT_MAX if the buffer has not been used yet.\ - * - encoding: unused\ - * - decoding: MUST be set by get_buffer().\ - */\ - int age;\ -\ - /**\ - * is this picture used as reference\ - * The values for this are the same as the MpegEncContext.picture_structure\ - * variable, that is 1->top field, 2->bottom field, 3->frame/both fields.\ - * Set to 4 for delayed, non-reference frames.\ - * - encoding: unused\ - * - decoding: Set by libavcodec. (before get_buffer() call)).\ - */\ - int reference;\ -\ - /**\ - * QP table\ - * - encoding: unused\ - * - decoding: Set by libavcodec.\ - */\ - int8_t *qscale_table;\ - /**\ - * QP store stride\ - * - encoding: unused\ - * - decoding: Set by libavcodec.\ - */\ - int qstride;\ -\ - /**\ - * mbskip_table[mb]>=1 if MB didn't change\ - * stride= mb_width = (width+15)>>4\ - * - encoding: unused\ - * - decoding: Set by libavcodec.\ - */\ - uint8_t *mbskip_table;\ -\ - /**\ - * motion vector table\ - * @code\ - * example:\ - * int mv_sample_log2= 4 - motion_subsample_log2;\ - * int mb_width= (width+15)>>4;\ - * int mv_stride= (mb_width << mv_sample_log2) + 1;\ - * motion_val[direction][x + y*mv_stride][0->mv_x, 1->mv_y];\ - * @endcode\ - * - encoding: Set by user.\ - * - decoding: Set by libavcodec.\ - */\ - int16_t (*motion_val[2])[2];\ -\ - /**\ - * macroblock type table\ - * mb_type_base + mb_width + 2\ - * - encoding: Set by user.\ - * - decoding: Set by libavcodec.\ - */\ - uint32_t *mb_type;\ -\ - /**\ - * log2 of the size of the block which a single vector in motion_val represents: \ - * (4->16x16, 3->8x8, 2-> 4x4, 1-> 2x2)\ - * - encoding: unused\ - * - decoding: Set by libavcodec.\ - */\ - uint8_t motion_subsample_log2;\ -\ - /**\ - * for some private data of the user\ - * - encoding: unused\ - * - decoding: Set by user.\ - */\ - void *opaque;\ -\ - /**\ - * error\ - * - encoding: Set by libavcodec. if flags&CODEC_FLAG_PSNR.\ - * - decoding: unused\ - */\ - uint64_t error[4];\ -\ - /**\ - * type of the buffer (to keep track of who has to deallocate data[*])\ - * - encoding: Set by the one who allocates it.\ - * - decoding: Set by the one who allocates it.\ - * Note: User allocated (direct rendering) & internal buffers cannot coexist currently.\ - */\ - int type;\ - \ - /**\ - * When decoding, this signals how much the picture must be delayed.\ - * extra_delay = repeat_pict / (2*fps)\ - * - encoding: unused\ - * - decoding: Set by libavcodec.\ - */\ - int repeat_pict;\ - \ - /**\ - * \ - */\ - int qscale_type;\ - \ - /**\ - * The content of the picture is interlaced.\ - * - encoding: Set by user.\ - * - decoding: Set by libavcodec. (default 0)\ - */\ - int interlaced_frame;\ - \ - /**\ - * If the content is interlaced, is top field displayed first.\ - * - encoding: Set by user.\ - * - decoding: Set by libavcodec.\ - */\ - int top_field_first;\ - \ - /**\ - * Pan scan.\ - * - encoding: Set by user.\ - * - decoding: Set by libavcodec.\ - */\ - AVPanScan *pan_scan;\ - \ - /**\ - * Tell user application that palette has changed from previous frame.\ - * - encoding: ??? (no palette-enabled encoder yet)\ - * - decoding: Set by libavcodec. (default 0).\ - */\ - int palette_has_changed;\ - \ - /**\ - * codec suggestion on buffer type if != 0\ - * - encoding: unused\ - * - decoding: Set by libavcodec. (before get_buffer() call)).\ - */\ - int buffer_hints;\ -\ - /**\ - * DCT coefficients\ - * - encoding: unused\ - * - decoding: Set by libavcodec.\ - */\ - short *dct_coeff;\ -\ - /**\ - * motion reference frame index\ - * the order in which these are stored can depend on the codec.\ - * - encoding: Set by user.\ - * - decoding: Set by libavcodec.\ - */\ - int8_t *ref_index[2];\ -\ - /**\ - * reordered opaque 64bit number (generally a PTS) from AVCodecContext.reordered_opaque\ - * output in AVFrame.reordered_opaque\ - * - encoding: unused\ - * - decoding: Read by user.\ - */\ - int64_t reordered_opaque;\ -\ - /**\ - * hardware accelerator private data (FFmpeg allocated)\ - * - encoding: unused\ - * - decoding: Set by libavcodec\ - */\ - void *hwaccel_picture_private;\ - - -#define FF_QSCALE_TYPE_MPEG1 0 -#define FF_QSCALE_TYPE_MPEG2 1 -#define FF_QSCALE_TYPE_H264 2 -#define FF_QSCALE_TYPE_VP56 3 - -#define FF_BUFFER_TYPE_INTERNAL 1 -#define FF_BUFFER_TYPE_USER 2 ///< direct rendering buffers (image is (de)allocated by user) -#define FF_BUFFER_TYPE_SHARED 4 ///< Buffer from somewhere else; don't deallocate image (data/base), all other tables are not shared. -#define FF_BUFFER_TYPE_COPY 8 ///< Just a (modified) copy of some other buffer, don't deallocate anything. - - -#define FF_I_TYPE 1 ///< Intra -#define FF_P_TYPE 2 ///< Predicted -#define FF_B_TYPE 3 ///< Bi-dir predicted -#define FF_S_TYPE 4 ///< S(GMC)-VOP MPEG4 -#define FF_SI_TYPE 5 ///< Switching Intra -#define FF_SP_TYPE 6 ///< Switching Predicted -#define FF_BI_TYPE 7 - -#define FF_BUFFER_HINTS_VALID 0x01 // Buffer hints value is meaningful (if 0 ignore). -#define FF_BUFFER_HINTS_READABLE 0x02 // Codec will read from buffer. -#define FF_BUFFER_HINTS_PRESERVE 0x04 // User must not alter buffer content. -#define FF_BUFFER_HINTS_REUSABLE 0x08 // Codec will reuse the buffer (update). - -typedef struct AVPacket { - /** - * Presentation timestamp in AVStream->time_base units; the time at which - * the decompressed packet will be presented to the user. - * Can be AV_NOPTS_VALUE if it is not stored in the file. - * pts MUST be larger or equal to dts as presentation cannot happen before - * decompression, unless one wants to view hex dumps. Some formats misuse - * the terms dts and pts/cts to mean something different. Such timestamps - * must be converted to true pts/dts before they are stored in AVPacket. - */ - int64_t pts; - /** - * Decompression timestamp in AVStream->time_base units; the time at which - * the packet is decompressed. - * Can be AV_NOPTS_VALUE if it is not stored in the file. - */ - int64_t dts; - uint8_t *data; - int size; - int stream_index; - int flags; - /** - * Duration of this packet in AVStream->time_base units, 0 if unknown. - * Equals next_pts - this_pts in presentation order. - */ - int duration; - void (*destruct)(struct AVPacket *); - void *priv; - int64_t pos; ///< byte position in stream, -1 if unknown - - /** - * Time difference in AVStream->time_base units from the pts of this - * packet to the point at which the output from the decoder has converged - * independent from the availability of previous frames. That is, the - * frames are virtually identical no matter if decoding started from - * the very first frame or from this keyframe. - * Is AV_NOPTS_VALUE if unknown. - * This field is not the display duration of the current packet. - * This field has no meaning if the packet does not have AV_PKT_FLAG_KEY - * set. - * - * The purpose of this field is to allow seeking in streams that have no - * keyframes in the conventional sense. It corresponds to the - * recovery point SEI in H.264 and match_time_delta in NUT. It is also - * essential for some types of subtitle streams to ensure that all - * subtitles are correctly displayed after seeking. - */ - int64_t convergence_duration; -} AVPacket; -#define AV_PKT_FLAG_KEY 0x0001 -#if LIBAVCODEC_VERSION_MAJOR < 53 -#define PKT_FLAG_KEY AV_PKT_FLAG_KEY -#endif - -/** - * Audio Video Frame. - * New fields can be added to the end of FF_COMMON_FRAME with minor version - * bumps. - * Removal, reordering and changes to existing fields require a major - * version bump. No fields should be added into AVFrame before or after - * FF_COMMON_FRAME! - * sizeof(AVFrame) must not be used outside libav*. - */ -typedef struct AVFrame { - FF_COMMON_FRAME -} AVFrame; - -/** - * main external API structure. - * New fields can be added to the end with minor version bumps. - * Removal, reordering and changes to existing fields require a major - * version bump. - * sizeof(AVCodecContext) must not be used outside libav*. - */ -typedef struct AVCodecContext { - /** - * information on struct for av_log - * - set by avcodec_alloc_context - */ - const AVClass *av_class; - /** - * the average bitrate - * - encoding: Set by user; unused for constant quantizer encoding. - * - decoding: Set by libavcodec. 0 or some bitrate if this info is available in the stream. - */ - int bit_rate; - - /** - * number of bits the bitstream is allowed to diverge from the reference. - * the reference can be CBR (for CBR pass1) or VBR (for pass2) - * - encoding: Set by user; unused for constant quantizer encoding. - * - decoding: unused - */ - int bit_rate_tolerance; - - /** - * CODEC_FLAG_*. - * - encoding: Set by user. - * - decoding: Set by user. - */ - int flags; - - /** - * Some codecs need additional format info. It is stored here. - * If any muxer uses this then ALL demuxers/parsers AND encoders for the - * specific codec MUST set it correctly otherwise stream copy breaks. - * In general use of this field by muxers is not recommanded. - * - encoding: Set by libavcodec. - * - decoding: Set by libavcodec. (FIXME: Is this OK?) - */ - int sub_id; - - /** - * Motion estimation algorithm used for video coding. - * 1 (zero), 2 (full), 3 (log), 4 (phods), 5 (epzs), 6 (x1), 7 (hex), - * 8 (umh), 9 (iter), 10 (tesa) [7, 8, 10 are x264 specific, 9 is snow specific] - * - encoding: MUST be set by user. - * - decoding: unused - */ - int me_method; - - /** - * some codecs need / can use extradata like Huffman tables. - * mjpeg: Huffman tables - * rv10: additional flags - * mpeg4: global headers (they can be in the bitstream or here) - * The allocated memory should be FF_INPUT_BUFFER_PADDING_SIZE bytes larger - * than extradata_size to avoid prolems if it is read with the bitstream reader. - * The bytewise contents of extradata must not depend on the architecture or CPU endianness. - * - encoding: Set/allocated/freed by libavcodec. - * - decoding: Set/allocated/freed by user. - */ - uint8_t *extradata; - int extradata_size; - - /** - * This is the fundamental unit of time (in seconds) in terms - * of which frame timestamps are represented. For fixed-fps content, - * timebase should be 1/framerate and timestamp increments should be - * identically 1. - * - encoding: MUST be set by user. - * - decoding: Set by libavcodec. - */ - //AVRational time_base; - - /* video only */ - /** - * picture width / height. - * - encoding: MUST be set by user. - * - decoding: Set by libavcodec. - * Note: For compatibility it is possible to set this instead of - * coded_width/height before decoding. - */ - int width, height; - -#define FF_ASPECT_EXTENDED 15 - - /** - * the number of pictures in a group of pictures, or 0 for intra_only - * - encoding: Set by user. - * - decoding: unused - */ - int gop_size; - - /** - * Pixel format, see PIX_FMT_xxx. - * May be set by the demuxer if known from headers. - * May be overriden by the decoder if it knows better. - * - encoding: Set by user. - * - decoding: Set by user if known, overridden by libavcodec if known - */ - //enum PixelFormat pix_fmt; - - /** - * Frame rate emulation. If not zero, the lower layer (i.e. format handler) - * has to read frames at native frame rate. - * - encoding: Set by user. - * - decoding: unused - */ - int rate_emu; - - /** - * If non NULL, 'draw_horiz_band' is called by the libavcodec - * decoder to draw a horizontal band. It improves cache usage. Not - * all codecs can do that. You must check the codec capabilities - * beforehand. - * The function is also used by hardware acceleration APIs. - * It is called at least once during frame decoding to pass - * the data needed for hardware render. - * In that mode instead of pixel data, AVFrame points to - * a structure specific to the acceleration API. The application - * reads the structure and can change some fields to indicate progress - * or mark state. - * - encoding: unused - * - decoding: Set by user. - * @param height the height of the slice - * @param y the y position of the slice - * @param type 1->top field, 2->bottom field, 3->frame - * @param offset offset into the AVFrame.data from which the slice should be read - */ - void (*draw_horiz_band)(struct AVCodecContext *s, - const AVFrame *src, int offset[4], - int y, int type, int height); - - /* audio only */ - int sample_rate; ///< samples per second - int channels; ///< number of audio channels - - /** - * audio sample format - * - encoding: Set by user. - * - decoding: Set by libavcodec. - */ - enum SampleFormat sample_fmt; ///< sample format - - /* The following data should not be initialized. */ - /** - * Samples per packet, initialized when calling 'init'. - */ - int frame_size; - int frame_number; ///< audio or video frame number -#if LIBAVCODEC_VERSION_MAJOR < 53 - int real_pict_num; ///< Returns the real picture number of previous encoded frame. -#endif - - /** - * Number of frames the decoded output will be delayed relative to - * the encoded input. - * - encoding: Set by libavcodec. - * - decoding: unused - */ - int delay; - - /* - encoding parameters */ - float qcompress; ///< amount of qscale change between easy & hard scenes (0.0-1.0) - float qblur; ///< amount of qscale smoothing over time (0.0-1.0) - - /** - * minimum quantizer - * - encoding: Set by user. - * - decoding: unused - */ - int qmin; - - /** - * maximum quantizer - * - encoding: Set by user. - * - decoding: unused - */ - int qmax; - - /** - * maximum quantizer difference between frames - * - encoding: Set by user. - * - decoding: unused - */ - int max_qdiff; - - /** - * maximum number of B-frames between non-B-frames - * Note: The output will be delayed by max_b_frames+1 relative to the input. - * - encoding: Set by user. - * - decoding: unused - */ - int max_b_frames; - - /** - * qscale factor between IP and B-frames - * If > 0 then the last P-frame quantizer will be used (q= lastp_q*factor+offset). - * If < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset). - * - encoding: Set by user. - * - decoding: unused - */ - float b_quant_factor; - - /** obsolete FIXME remove */ - int rc_strategy; -#define FF_RC_STRATEGY_XVID 1 - - int b_frame_strategy; - - /** - * hurry up amount - * - encoding: unused - * - decoding: Set by user. 1-> Skip B-frames, 2-> Skip IDCT/dequant too, 5-> Skip everything except header - * @deprecated Deprecated in favor of skip_idct and skip_frame. - */ - int hurry_up; - - struct AVCodec *codec; - - void *priv_data; - - int rtp_payload_size; /* The size of the RTP payload: the coder will */ - /* do its best to deliver a chunk with size */ - /* below rtp_payload_size, the chunk will start */ - /* with a start code on some codecs like H.263. */ - /* This doesn't take account of any particular */ - /* headers inside the transmitted RTP payload. */ - - - /* The RTP callback: This function is called */ - /* every time the encoder has a packet to send. */ - /* It depends on the encoder if the data starts */ - /* with a Start Code (it should). H.263 does. */ - /* mb_nb contains the number of macroblocks */ - /* encoded in the RTP payload. */ - void (*rtp_callback)(struct AVCodecContext *avctx, void *data, int size, int mb_nb); - - /* statistics, used for 2-pass encoding */ - int mv_bits; - int header_bits; - int i_tex_bits; - int p_tex_bits; - int i_count; - int p_count; - int skip_count; - int misc_bits; - - /** - * number of bits used for the previously encoded frame - * - encoding: Set by libavcodec. - * - decoding: unused - */ - int frame_bits; - - /** - * Private data of the user, can be used to carry app specific stuff. - * - encoding: Set by user. - * - decoding: Set by user. - */ - void *opaque; - - char codec_name[32]; - enum AVMediaType codec_type; /* see AVMEDIA_TYPE_xxx */ - enum CodecID codec_id; /* see CODEC_ID_xxx */ - - /** - * fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A'). - * This is used to work around some encoder bugs. - * A demuxer should set this to what is stored in the field used to identify the codec. - * If there are multiple such fields in a container then the demuxer should choose the one - * which maximizes the information about the used codec. - * If the codec tag field in a container is larger then 32 bits then the demuxer should - * remap the longer ID to 32 bits with a table or other structure. Alternatively a new - * extra_codec_tag + size could be added but for this a clear advantage must be demonstrated - * first. - * - encoding: Set by user, if not then the default based on codec_id will be used. - * - decoding: Set by user, will be converted to uppercase by libavcodec during init. - */ - unsigned int codec_tag; - - /** - * Work around bugs in encoders which sometimes cannot be detected automatically. - * - encoding: Set by user - * - decoding: Set by user - */ - int workaround_bugs; -#define FF_BUG_AUTODETECT 1 ///< autodetection -#define FF_BUG_OLD_MSMPEG4 2 -#define FF_BUG_XVID_ILACE 4 -#define FF_BUG_UMP4 8 -#define FF_BUG_NO_PADDING 16 -#define FF_BUG_AMV 32 -#define FF_BUG_AC_VLC 0 ///< Will be removed, libavcodec can now handle these non-compliant files by default. -#define FF_BUG_QPEL_CHROMA 64 -#define FF_BUG_STD_QPEL 128 -#define FF_BUG_QPEL_CHROMA2 256 -#define FF_BUG_DIRECT_BLOCKSIZE 512 -#define FF_BUG_EDGE 1024 -#define FF_BUG_HPEL_CHROMA 2048 -#define FF_BUG_DC_CLIP 4096 -#define FF_BUG_MS 8192 ///< Work around various bugs in Microsoft's broken decoders. -#define FF_BUG_TRUNCATED 16384 -//#define FF_BUG_FAKE_SCALABILITY 16 //Autodetection should work 100%. - - /** - * luma single coefficient elimination threshold - * - encoding: Set by user. - * - decoding: unused - */ - int luma_elim_threshold; - - /** - * chroma single coeff elimination threshold - * - encoding: Set by user. - * - decoding: unused - */ - int chroma_elim_threshold; - - /** - * strictly follow the standard (MPEG4, ...). - * - encoding: Set by user. - * - decoding: Set by user. - * Setting this to STRICT or higher means the encoder and decoder will - * generally do stupid things, whereas setting it to unofficial or lower - * will mean the encoder might produce output that is not supported by all - * spec-compliant decoders. Decoders don't differentiate between normal, - * unofficial and experimental (that is, they always try to decode things - * when they can) unless they are explicitly asked to behave stupidly - * (=strictly conform to the specs) - */ - int strict_std_compliance; -#define FF_COMPLIANCE_VERY_STRICT 2 ///< Strictly conform to an older more strict version of the spec or reference software. -#define FF_COMPLIANCE_STRICT 1 ///< Strictly conform to all the things in the spec no matter what consequences. -#define FF_COMPLIANCE_NORMAL 0 -#if LIBAVCODEC_VERSION_MAJOR < 53 -#define FF_COMPLIANCE_INOFFICIAL -1 ///< Allow inofficial extensions (deprecated - use FF_COMPLIANCE_UNOFFICIAL instead). -#endif -#define FF_COMPLIANCE_UNOFFICIAL -1 ///< Allow unofficial extensions -#define FF_COMPLIANCE_EXPERIMENTAL -2 ///< Allow nonstandardized experimental things. - - /** - * qscale offset between IP and B-frames - * - encoding: Set by user. - * - decoding: unused - */ - float b_quant_offset; - - /** - * Error recognization; higher values will detect more errors but may - * misdetect some more or less valid parts as errors. - * - encoding: unused - * - decoding: Set by user. - */ - int error_recognition; -#define FF_ER_CAREFUL 1 -#define FF_ER_COMPLIANT 2 -#define FF_ER_AGGRESSIVE 3 -#define FF_ER_VERY_AGGRESSIVE 4 - - /** - * Called at the beginning of each frame to get a buffer for it. - * If pic.reference is set then the frame will be read later by libavcodec. - * avcodec_align_dimensions2() should be used to find the required width and - * height, as they normally need to be rounded up to the next multiple of 16. - * if CODEC_CAP_DR1 is not set then get_buffer() must call - * avcodec_default_get_buffer() instead of providing buffers allocated by - * some other means. - * - encoding: unused - * - decoding: Set by libavcodec, user can override. - */ - int (*get_buffer)(struct AVCodecContext *c, AVFrame *pic); - - /** - * Called to release buffers which were allocated with get_buffer. - * A released buffer can be reused in get_buffer(). - * pic.data[*] must be set to NULL. - * - encoding: unused - * - decoding: Set by libavcodec, user can override. - */ - void (*release_buffer)(struct AVCodecContext *c, AVFrame *pic); - - /** - * Size of the frame reordering buffer in the decoder. - * For MPEG-2 it is 1 IPB or 0 low delay IP. - * - encoding: Set by libavcodec. - * - decoding: Set by libavcodec. - */ - int has_b_frames; - - /** - * number of bytes per packet if constant and known or 0 - * Used by some WAV based audio codecs. - */ - int block_align; - - int parse_only; /* - decoding only: If true, only parsing is done - (function avcodec_parse_frame()). The frame - data is returned. Only MPEG codecs support this now. */ - - /** - * 0-> h263 quant 1-> mpeg quant - * - encoding: Set by user. - * - decoding: unused - */ - int mpeg_quant; - - /** - * pass1 encoding statistics output buffer - * - encoding: Set by libavcodec. - * - decoding: unused - */ - char *stats_out; - - /** - * pass2 encoding statistics input buffer - * Concatenated stuff from stats_out of pass1 should be placed here. - * - encoding: Allocated/set/freed by user. - * - decoding: unused - */ - char *stats_in; - - /** - * ratecontrol qmin qmax limiting method - * 0-> clipping, 1-> use a nice continous function to limit qscale wthin qmin/qmax. - * - encoding: Set by user. - * - decoding: unused - */ - float rc_qsquish; - - float rc_qmod_amp; - int rc_qmod_freq; - - /** - * ratecontrol override, see RcOverride - * - encoding: Allocated/set/freed by user. - * - decoding: unused - */ - RcOverride *rc_override; - int rc_override_count; - - /** - * rate control equation - * - encoding: Set by user - * - decoding: unused - */ - const char *rc_eq; - - /** - * maximum bitrate - * - encoding: Set by user. - * - decoding: unused - */ - int rc_max_rate; - - /** - * minimum bitrate - * - encoding: Set by user. - * - decoding: unused - */ - int rc_min_rate; - - /** - * decoder bitstream buffer size - * - encoding: Set by user. - * - decoding: unused - */ - int rc_buffer_size; - float rc_buffer_aggressivity; - - /** - * qscale factor between P and I-frames - * If > 0 then the last p frame quantizer will be used (q= lastp_q*factor+offset). - * If < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset). - * - encoding: Set by user. - * - decoding: unused - */ - float i_quant_factor; - - /** - * qscale offset between P and I-frames - * - encoding: Set by user. - * - decoding: unused - */ - float i_quant_offset; - - /** - * initial complexity for pass1 ratecontrol - * - encoding: Set by user. - * - decoding: unused - */ - float rc_initial_cplx; - - /** - * DCT algorithm, see FF_DCT_* below - * - encoding: Set by user. - * - decoding: unused - */ - int dct_algo; -#define FF_DCT_AUTO 0 -#define FF_DCT_FASTINT 1 -#define FF_DCT_INT 2 -#define FF_DCT_MMX 3 -#define FF_DCT_MLIB 4 -#define FF_DCT_ALTIVEC 5 -#define FF_DCT_FAAN 6 - - /** - * luminance masking (0-> disabled) - * - encoding: Set by user. - * - decoding: unused - */ - float lumi_masking; - - /** - * temporary complexity masking (0-> disabled) - * - encoding: Set by user. - * - decoding: unused - */ - float temporal_cplx_masking; - - /** - * spatial complexity masking (0-> disabled) - * - encoding: Set by user. - * - decoding: unused - */ - float spatial_cplx_masking; - - /** - * p block masking (0-> disabled) - * - encoding: Set by user. - * - decoding: unused - */ - float p_masking; - - /** - * darkness masking (0-> disabled) - * - encoding: Set by user. - * - decoding: unused - */ - float dark_masking; - - /** - * IDCT algorithm, see FF_IDCT_* below. - * - encoding: Set by user. - * - decoding: Set by user. - */ - int idct_algo; -#define FF_IDCT_AUTO 0 -#define FF_IDCT_INT 1 -#define FF_IDCT_SIMPLE 2 -#define FF_IDCT_SIMPLEMMX 3 -#define FF_IDCT_LIBMPEG2MMX 4 -#define FF_IDCT_PS2 5 -#define FF_IDCT_MLIB 6 -#define FF_IDCT_ARM 7 -#define FF_IDCT_ALTIVEC 8 -#define FF_IDCT_SH4 9 -#define FF_IDCT_SIMPLEARM 10 -#define FF_IDCT_H264 11 -#define FF_IDCT_VP3 12 -#define FF_IDCT_IPP 13 -#define FF_IDCT_XVIDMMX 14 -#define FF_IDCT_CAVS 15 -#define FF_IDCT_SIMPLEARMV5TE 16 -#define FF_IDCT_SIMPLEARMV6 17 -#define FF_IDCT_SIMPLEVIS 18 -#define FF_IDCT_WMV2 19 -#define FF_IDCT_FAAN 20 -#define FF_IDCT_EA 21 -#define FF_IDCT_SIMPLENEON 22 -#define FF_IDCT_SIMPLEALPHA 23 -#define FF_IDCT_BINK 24 - - /** - * slice count - * - encoding: Set by libavcodec. - * - decoding: Set by user (or 0). - */ - int slice_count; - /** - * slice offsets in the frame in bytes - * - encoding: Set/allocated by libavcodec. - * - decoding: Set/allocated by user (or NULL). - */ - int *slice_offset; - - /** - * error concealment flags - * - encoding: unused - * - decoding: Set by user. - */ - int error_concealment; -#define FF_EC_GUESS_MVS 1 -#define FF_EC_DEBLOCK 2 - - /** - * dsp_mask could be add used to disable unwanted CPU features - * CPU features (i.e. MMX, SSE. ...) - * - * With the FORCE flag you may instead enable given CPU features. - * (Dangerous: Usable in case of misdetection, improper usage however will - * result into program crash.) - */ - unsigned dsp_mask; -#define FF_MM_FORCE 0x80000000 /* Force usage of selected flags (OR) */ - /* lower 16 bits - CPU features */ -#define FF_MM_MMX 0x0001 ///< standard MMX -#define FF_MM_3DNOW 0x0004 ///< AMD 3DNOW -#if LIBAVCODEC_VERSION_MAJOR < 53 -#define FF_MM_MMXEXT 0x0002 ///< SSE integer functions or AMD MMX ext -#endif -#define FF_MM_MMX2 0x0002 ///< SSE integer functions or AMD MMX ext -#define FF_MM_SSE 0x0008 ///< SSE functions -#define FF_MM_SSE2 0x0010 ///< PIV SSE2 functions -#define FF_MM_SSE2SLOW 0x40000000 ///< SSE2 supported, but usually not faster - ///< than regular MMX/SSE (e.g. Core1) -#define FF_MM_3DNOWEXT 0x0020 ///< AMD 3DNowExt -#define FF_MM_SSE3 0x0040 ///< Prescott SSE3 functions -#define FF_MM_SSE3SLOW 0x20000000 ///< SSE3 supported, but usually not faster - ///< than regular MMX/SSE (e.g. Core1) -#define FF_MM_SSSE3 0x0080 ///< Conroe SSSE3 functions -#define FF_MM_SSE4 0x0100 ///< Penryn SSE4.1 functions -#define FF_MM_SSE42 0x0200 ///< Nehalem SSE4.2 functions -#define FF_MM_IWMMXT 0x0100 ///< XScale IWMMXT -#define FF_MM_ALTIVEC 0x0001 ///< standard AltiVec - - /** - * bits per sample/pixel from the demuxer (needed for huffyuv). - * - encoding: Set by libavcodec. - * - decoding: Set by user. - */ - int bits_per_coded_sample; - - /** - * prediction method (needed for huffyuv) - * - encoding: Set by user. - * - decoding: unused - */ - int prediction_method; -#define FF_PRED_LEFT 0 -#define FF_PRED_PLANE 1 -#define FF_PRED_MEDIAN 2 - - /** - * sample aspect ratio (0 if unknown) - * That is the width of a pixel divided by the height of the pixel. - * Numerator and denominator must be relatively prime and smaller than 256 for some video standards. - * - encoding: Set by user. - * - decoding: Set by libavcodec. - */ - //AVRational sample_aspect_ratio; - - /** - * the picture in the bitstream - * - encoding: Set by libavcodec. - * - decoding: Set by libavcodec. - */ - AVFrame *coded_frame; - - /** - * debug - * - encoding: Set by user. - * - decoding: Set by user. - */ - int debug; -#define FF_DEBUG_PICT_INFO 1 -#define FF_DEBUG_RC 2 -#define FF_DEBUG_BITSTREAM 4 -#define FF_DEBUG_MB_TYPE 8 -#define FF_DEBUG_QP 16 -#define FF_DEBUG_MV 32 -#define FF_DEBUG_DCT_COEFF 0x00000040 -#define FF_DEBUG_SKIP 0x00000080 -#define FF_DEBUG_STARTCODE 0x00000100 -#define FF_DEBUG_PTS 0x00000200 -#define FF_DEBUG_ER 0x00000400 -#define FF_DEBUG_MMCO 0x00000800 -#define FF_DEBUG_BUGS 0x00001000 -#define FF_DEBUG_VIS_QP 0x00002000 -#define FF_DEBUG_VIS_MB_TYPE 0x00004000 -#define FF_DEBUG_BUFFERS 0x00008000 - - /** - * debug - * - encoding: Set by user. - * - decoding: Set by user. - */ - int debug_mv; -#define FF_DEBUG_VIS_MV_P_FOR 0x00000001 //visualize forward predicted MVs of P frames -#define FF_DEBUG_VIS_MV_B_FOR 0x00000002 //visualize forward predicted MVs of B frames -#define FF_DEBUG_VIS_MV_B_BACK 0x00000004 //visualize backward predicted MVs of B frames - - /** - * error - * - encoding: Set by libavcodec if flags&CODEC_FLAG_PSNR. - * - decoding: unused - */ - uint64_t error[4]; - - /** - * minimum MB quantizer - * - encoding: unused - * - decoding: unused - */ - int mb_qmin; - - /** - * maximum MB quantizer - * - encoding: unused - * - decoding: unused - */ - int mb_qmax; - - /** - * motion estimation comparison function - * - encoding: Set by user. - * - decoding: unused - */ - int me_cmp; - /** - * subpixel motion estimation comparison function - * - encoding: Set by user. - * - decoding: unused - */ - int me_sub_cmp; - /** - * macroblock comparison function (not supported yet) - * - encoding: Set by user. - * - decoding: unused - */ - int mb_cmp; - /** - * interlaced DCT comparison function - * - encoding: Set by user. - * - decoding: unused - */ - int ildct_cmp; -#define FF_CMP_SAD 0 -#define FF_CMP_SSE 1 -#define FF_CMP_SATD 2 -#define FF_CMP_DCT 3 -#define FF_CMP_PSNR 4 -#define FF_CMP_BIT 5 -#define FF_CMP_RD 6 -#define FF_CMP_ZERO 7 -#define FF_CMP_VSAD 8 -#define FF_CMP_VSSE 9 -#define FF_CMP_NSSE 10 -#define FF_CMP_W53 11 -#define FF_CMP_W97 12 -#define FF_CMP_DCTMAX 13 -#define FF_CMP_DCT264 14 -#define FF_CMP_CHROMA 256 - - /** - * ME diamond size & shape - * - encoding: Set by user. - * - decoding: unused - */ - int dia_size; - - /** - * amount of previous MV predictors (2a+1 x 2a+1 square) - * - encoding: Set by user. - * - decoding: unused - */ - int last_predictor_count; - - /** - * prepass for motion estimation - * - encoding: Set by user. - * - decoding: unused - */ - int pre_me; - - /** - * motion estimation prepass comparison function - * - encoding: Set by user. - * - decoding: unused - */ - int me_pre_cmp; - - /** - * ME prepass diamond size & shape - * - encoding: Set by user. - * - decoding: unused - */ - int pre_dia_size; - - /** - * subpel ME quality - * - encoding: Set by user. - * - decoding: unused - */ - int me_subpel_quality; - - /** - * callback to negotiate the pixelFormat - * @param fmt is the list of formats which are supported by the codec, - * it is terminated by -1 as 0 is a valid format, the formats are ordered by quality. - * The first is always the native one. - * @return the chosen format - * - encoding: unused - * - decoding: Set by user, if not set the native format will be chosen. - */ - enum PixelFormat (*get_format)(struct AVCodecContext *s, const enum PixelFormat * fmt); - - /** - * DTG active format information (additional aspect ratio - * information only used in DVB MPEG-2 transport streams) - * 0 if not set. - * - * - encoding: unused - * - decoding: Set by decoder. - */ - int dtg_active_format; -#define FF_DTG_AFD_SAME 8 -#define FF_DTG_AFD_4_3 9 -#define FF_DTG_AFD_16_9 10 -#define FF_DTG_AFD_14_9 11 -#define FF_DTG_AFD_4_3_SP_14_9 13 -#define FF_DTG_AFD_16_9_SP_14_9 14 -#define FF_DTG_AFD_SP_4_3 15 - - /** - * maximum motion estimation search range in subpel units - * If 0 then no limit. - * - * - encoding: Set by user. - * - decoding: unused - */ - int me_range; - - /** - * intra quantizer bias - * - encoding: Set by user. - * - decoding: unused - */ - int intra_quant_bias; -#define FF_DEFAULT_QUANT_BIAS 999999 - - /** - * inter quantizer bias - * - encoding: Set by user. - * - decoding: unused - */ - int inter_quant_bias; - - /** - * color table ID - * - encoding: unused - * - decoding: Which clrtable should be used for 8bit RGB images. - * Tables have to be stored somewhere. FIXME - */ - int color_table_id; - - /** - * internal_buffer count - * Don't touch, used by libavcodec default_get_buffer(). - */ - int internal_buffer_count; - - /** - * internal_buffers - * Don't touch, used by libavcodec default_get_buffer(). - */ - void *internal_buffer; - -#define FF_LAMBDA_SHIFT 7 -#define FF_LAMBDA_SCALE (1< ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A'). - * This is used to work around some encoder bugs. - * - encoding: unused - * - decoding: Set by user, will be converted to uppercase by libavcodec during init. - */ - unsigned int stream_codec_tag; - - /** - * scene change detection threshold - * 0 is default, larger means fewer detected scene changes. - * - encoding: Set by user. - * - decoding: unused - */ - int scenechange_threshold; - - /** - * minimum Lagrange multipler - * - encoding: Set by user. - * - decoding: unused - */ - int lmin; - - /** - * maximum Lagrange multipler - * - encoding: Set by user. - * - decoding: unused - */ - int lmax; - - /** - * palette control structure - * - encoding: ??? (no palette-enabled encoder yet) - * - decoding: Set by user. - */ - struct AVPaletteControl *palctrl; - - /** - * noise reduction strength - * - encoding: Set by user. - * - decoding: unused - */ - int noise_reduction; - - /** - * Called at the beginning of a frame to get cr buffer for it. - * Buffer type (size, hints) must be the same. libavcodec won't check it. - * libavcodec will pass previous buffer in pic, function should return - * same buffer or new buffer with old frame "painted" into it. - * If pic.data[0] == NULL must behave like get_buffer(). - * if CODEC_CAP_DR1 is not set then reget_buffer() must call - * avcodec_default_reget_buffer() instead of providing buffers allocated by - * some other means. - * - encoding: unused - * - decoding: Set by libavcodec, user can override. - */ - int (*reget_buffer)(struct AVCodecContext *c, AVFrame *pic); - - /** - * Number of bits which should be loaded into the rc buffer before decoding starts. - * - encoding: Set by user. - * - decoding: unused - */ - int rc_initial_buffer_occupancy; - - /** - * - * - encoding: Set by user. - * - decoding: unused - */ - int inter_threshold; - - /** - * CODEC_FLAG2_* - * - encoding: Set by user. - * - decoding: Set by user. - */ - int flags2; - - /** - * Simulates errors in the bitstream to test error concealment. - * - encoding: Set by user. - * - decoding: unused - */ - int error_rate; - - /** - * MP3 antialias algorithm, see FF_AA_* below. - * - encoding: unused - * - decoding: Set by user. - */ - int antialias_algo; -#define FF_AA_AUTO 0 -#define FF_AA_FASTINT 1 //not implemented yet -#define FF_AA_INT 2 -#define FF_AA_FLOAT 3 - /** - * quantizer noise shaping - * - encoding: Set by user. - * - decoding: unused - */ - int quantizer_noise_shaping; - - /** - * thread count - * is used to decide how many independent tasks should be passed to execute() - * - encoding: Set by user. - * - decoding: Set by user. - */ - int thread_count; - - /** - * The codec may call this to execute several independent things. - * It will return only after finishing all tasks. - * The user may replace this with some multithreaded implementation, - * the default implementation will execute the parts serially. - * @param count the number of things to execute - * - encoding: Set by libavcodec, user can override. - * - decoding: Set by libavcodec, user can override. - */ - int (*execute)(struct AVCodecContext *c, int (*func)(struct AVCodecContext *c2, void *arg), void *arg2, int *ret, int count, int size); - - /** - * thread opaque - * Can be used by execute() to store some per AVCodecContext stuff. - * - encoding: set by execute() - * - decoding: set by execute() - */ - void *thread_opaque; - - /** - * Motion estimation threshold below which no motion estimation is - * performed, but instead the user specified motion vectors are used. - * - * - encoding: Set by user. - * - decoding: unused - */ - int me_threshold; - - /** - * Macroblock threshold below which the user specified macroblock types will be used. - * - encoding: Set by user. - * - decoding: unused - */ - int mb_threshold; - - /** - * precision of the intra DC coefficient - 8 - * - encoding: Set by user. - * - decoding: unused - */ - int intra_dc_precision; - - /** - * noise vs. sse weight for the nsse comparsion function - * - encoding: Set by user. - * - decoding: unused - */ - int nsse_weight; - - /** - * Number of macroblock rows at the top which are skipped. - * - encoding: unused - * - decoding: Set by user. - */ - int skip_top; - - /** - * Number of macroblock rows at the bottom which are skipped. - * - encoding: unused - * - decoding: Set by user. - */ - int skip_bottom; - - /** - * profile - * - encoding: Set by user. - * - decoding: Set by libavcodec. - */ - int profile; -#define FF_PROFILE_UNKNOWN -99 - -#define FF_PROFILE_AAC_MAIN 0 -#define FF_PROFILE_AAC_LOW 1 -#define FF_PROFILE_AAC_SSR 2 -#define FF_PROFILE_AAC_LTP 3 - -#define FF_PROFILE_H264_BASELINE 66 -#define FF_PROFILE_H264_MAIN 77 -#define FF_PROFILE_H264_EXTENDED 88 -#define FF_PROFILE_H264_HIGH 100 -#define FF_PROFILE_H264_HIGH_10 110 -#define FF_PROFILE_H264_HIGH_422 122 -#define FF_PROFILE_H264_HIGH_444 244 -#define FF_PROFILE_H264_CAVLC_444 44 - - /** - * level - * - encoding: Set by user. - * - decoding: Set by libavcodec. - */ - int level; -#define FF_LEVEL_UNKNOWN -99 - - /** - * low resolution decoding, 1-> 1/2 size, 2->1/4 size - * - encoding: unused - * - decoding: Set by user. - */ - int lowres; - - /** - * Bitstream width / height, may be different from width/height if lowres - * or other things are used. - * - encoding: unused - * - decoding: Set by user before init if known. Codec should override / dynamically change if needed. - */ - int coded_width, coded_height; - - /** - * frame skip threshold - * - encoding: Set by user. - * - decoding: unused - */ - int frame_skip_threshold; - - /** - * frame skip factor - * - encoding: Set by user. - * - decoding: unused - */ - int frame_skip_factor; - - /** - * frame skip exponent - * - encoding: Set by user. - * - decoding: unused - */ - int frame_skip_exp; - - /** - * frame skip comparison function - * - encoding: Set by user. - * - decoding: unused - */ - int frame_skip_cmp; - - /** - * Border processing masking, raises the quantizer for mbs on the borders - * of the picture. - * - encoding: Set by user. - * - decoding: unused - */ - float border_masking; - - /** - * minimum MB lagrange multipler - * - encoding: Set by user. - * - decoding: unused - */ - int mb_lmin; - - /** - * maximum MB lagrange multipler - * - encoding: Set by user. - * - decoding: unused - */ - int mb_lmax; - - /** - * - * - encoding: Set by user. - * - decoding: unused - */ - int me_penalty_compensation; - - /** - * - * - encoding: unused - * - decoding: Set by user. - */ - enum AVDiscard skip_loop_filter; - - /** - * - * - encoding: unused - * - decoding: Set by user. - */ - enum AVDiscard skip_idct; - - /** - * - * - encoding: unused - * - decoding: Set by user. - */ - enum AVDiscard skip_frame; - - /** - * - * - encoding: Set by user. - * - decoding: unused - */ - int bidir_refine; - - /** - * - * - encoding: Set by user. - * - decoding: unused - */ - int brd_scale; - - /** - * constant rate factor - quality-based VBR - values ~correspond to qps - * - encoding: Set by user. - * - decoding: unused - */ - float crf; - - /** - * constant quantization parameter rate control method - * - encoding: Set by user. - * - decoding: unused - */ - int cqp; - - /** - * minimum GOP size - * - encoding: Set by user. - * - decoding: unused - */ - int keyint_min; - - /** - * number of reference frames - * - encoding: Set by user. - * - decoding: Set by lavc. - */ - int refs; - - /** - * chroma qp offset from luma - * - encoding: Set by user. - * - decoding: unused - */ - int chromaoffset; - - /** - * Influences how often B-frames are used. - * - encoding: Set by user. - * - decoding: unused - */ - int bframebias; - - /** - * trellis RD quantization - * - encoding: Set by user. - * - decoding: unused - */ - int trellis; - - /** - * Reduce fluctuations in qp (before curve compression). - * - encoding: Set by user. - * - decoding: unused - */ - float complexityblur; - - /** - * in-loop deblocking filter alphac0 parameter - * alpha is in the range -6...6 - * - encoding: Set by user. - * - decoding: unused - */ - int deblockalpha; - - /** - * in-loop deblocking filter beta parameter - * beta is in the range -6...6 - * - encoding: Set by user. - * - decoding: unused - */ - int deblockbeta; - - /** - * macroblock subpartition sizes to consider - p8x8, p4x4, b8x8, i8x8, i4x4 - * - encoding: Set by user. - * - decoding: unused - */ - int partitions; -#define X264_PART_I4X4 0x001 /* Analyze i4x4 */ -#define X264_PART_I8X8 0x002 /* Analyze i8x8 (requires 8x8 transform) */ -#define X264_PART_P8X8 0x010 /* Analyze p16x8, p8x16 and p8x8 */ -#define X264_PART_P4X4 0x020 /* Analyze p8x4, p4x8, p4x4 */ -#define X264_PART_B8X8 0x100 /* Analyze b16x8, b8x16 and b8x8 */ - - /** - * direct MV prediction mode - 0 (none), 1 (spatial), 2 (temporal), 3 (auto) - * - encoding: Set by user. - * - decoding: unused - */ - int directpred; - - /** - * Audio cutoff bandwidth (0 means "automatic") - * - encoding: Set by user. - * - decoding: unused - */ - int cutoff; - - /** - * Multiplied by qscale for each frame and added to scene_change_score. - * - encoding: Set by user. - * - decoding: unused - */ - int scenechange_factor; - - /** - * - * Note: Value depends upon the compare function used for fullpel ME. - * - encoding: Set by user. - * - decoding: unused - */ - int mv0_threshold; - - /** - * Adjusts sensitivity of b_frame_strategy 1. - * - encoding: Set by user. - * - decoding: unused - */ - int b_sensitivity; - - /** - * - encoding: Set by user. - * - decoding: unused - */ - int compression_level; -#define FF_COMPRESSION_DEFAULT -1 - -#if LIBAVCODEC_VERSION_MAJOR < 53 - /** - * Sets whether to use LPC mode - used by FLAC encoder. - * - encoding: Set by user. - * - decoding: unused - * @deprecated Deprecated in favor of lpc_type and lpc_passes. - */ - int use_lpc; -#endif - - /** - * LPC coefficient precision - used by FLAC encoder - * - encoding: Set by user. - * - decoding: unused - */ - int lpc_coeff_precision; - - /** - * - encoding: Set by user. - * - decoding: unused - */ - int min_prediction_order; - - /** - * - encoding: Set by user. - * - decoding: unused - */ - int max_prediction_order; - - /** - * search method for selecting prediction order - * - encoding: Set by user. - * - decoding: unused - */ - int prediction_order_method; - - /** - * - encoding: Set by user. - * - decoding: unused - */ - int min_partition_order; - - /** - * - encoding: Set by user. - * - decoding: unused - */ - int max_partition_order; - - /** - * GOP timecode frame start number, in non drop frame format - * - encoding: Set by user. - * - decoding: unused - */ - int64_t timecode_frame_start; - -#if LIBAVCODEC_VERSION_MAJOR < 53 - /** - * Decoder should decode to this many channels if it can (0 for default) - * - encoding: unused - * - decoding: Set by user. - * @deprecated Deprecated in favor of request_channel_layout. - */ - int request_channels; -#endif - - /** - * Percentage of dynamic range compression to be applied by the decoder. - * The default value is 1.0, corresponding to full compression. - * - encoding: unused - * - decoding: Set by user. - */ - float drc_scale; - - /** - * opaque 64bit number (generally a PTS) that will be reordered and - * output in AVFrame.reordered_opaque - * - encoding: unused - * - decoding: Set by user. - */ - int64_t reordered_opaque; - - /** - * Bits per sample/pixel of internal libavcodec pixel/sample format. - * This field is applicable only when sample_fmt is SAMPLE_FMT_S32. - * - encoding: set by user. - * - decoding: set by libavcodec. - */ - int bits_per_raw_sample; - - /** - * Audio channel layout. - * - encoding: set by user. - * - decoding: set by libavcodec. - */ - int64_t channel_layout; - - /** - * Request decoder to use this channel layout if it can (0 for default) - * - encoding: unused - * - decoding: Set by user. - */ - int64_t request_channel_layout; - - /** - * Ratecontrol attempt to use, at maximum, of what can be used without an underflow. - * - encoding: Set by user. - * - decoding: unused. - */ - float rc_max_available_vbv_use; - - /** - * Ratecontrol attempt to use, at least, times the amount needed to prevent a vbv overflow. - * - encoding: Set by user. - * - decoding: unused. - */ - float rc_min_vbv_overflow_use; - - /** - * Hardware accelerator in use - * - encoding: unused. - * - decoding: Set by libavcodec - */ - struct AVHWAccel *hwaccel; - - /** - * For some codecs, the time base is closer to the field rate than the frame rate. - * Most notably, H.264 and MPEG-2 specify time_base as half of frame duration - * if no telecine is used ... - * - * Set to time_base ticks per frame. Default 1, e.g., H.264/MPEG-2 set it to 2. - */ - int ticks_per_frame; - - /** - * Hardware accelerator context. - * For some hardware accelerators, a global context needs to be - * provided by the user. In that case, this holds display-dependent - * data FFmpeg cannot instantiate itself. Please refer to the - * FFmpeg HW accelerator documentation to know how to fill this - * is. e.g. for VA API, this is a struct vaapi_context. - * - encoding: unused - * - decoding: Set by user - */ - void *hwaccel_context; - - /** - * Chromaticity coordinates of the source primaries. - * - encoding: Set by user - * - decoding: Set by libavcodec - */ - enum AVColorPrimaries color_primaries; - - /** - * Color Transfer Characteristic. - * - encoding: Set by user - * - decoding: Set by libavcodec - */ - enum AVColorTransferCharacteristic color_trc; - - /** - * YUV colorspace type. - * - encoding: Set by user - * - decoding: Set by libavcodec - */ - enum AVColorSpace colorspace; - - /** - * MPEG vs JPEG YUV range. - * - encoding: Set by user - * - decoding: Set by libavcodec - */ - enum AVColorRange color_range; - - /** - * This defines the location of chroma samples. - * - encoding: Set by user - * - decoding: Set by libavcodec - */ - enum AVChromaLocation chroma_sample_location; - - /** - * The codec may call this to execute several independent things. - * It will return only after finishing all tasks. - * The user may replace this with some multithreaded implementation, - * the default implementation will execute the parts serially. - * Also see avcodec_thread_init and e.g. the --enable-pthread configure option. - * @param c context passed also to func - * @param count the number of things to execute - * @param arg2 argument passed unchanged to func - * @param ret return values of executed functions, must have space for "count" values. May be NULL. - * @param func function that will be called count times, with jobnr from 0 to count-1. - * threadnr will be in the range 0 to c->thread_count-1 < MAX_THREADS and so that no - * two instances of func executing at the same time will have the same threadnr. - * @return always 0 currently, but code should handle a future improvement where when any call to func - * returns < 0 no further calls to func may be done and < 0 is returned. - * - encoding: Set by libavcodec, user can override. - * - decoding: Set by libavcodec, user can override. - */ - int (*execute2)(struct AVCodecContext *c, int (*func)(struct AVCodecContext *c2, void *arg, int jobnr, int threadnr), void *arg2, int *ret, int count); - - /** - * explicit P-frame weighted prediction analysis method - * 0: off - * 1: fast blind weighting (one reference duplicate with -1 offset) - * 2: smart weighting (full fade detection analysis) - * - encoding: Set by user. - * - decoding: unused - */ - int weighted_p_pred; - - /** - * AQ mode - * 0: Disabled - * 1: Variance AQ (complexity mask) - * 2: Auto-variance AQ (experimental) - * - encoding: Set by user - * - decoding: unused - */ - int aq_mode; - - /** - * AQ strength - * Reduces blocking and blurring in flat and textured areas. - * - encoding: Set by user - * - decoding: unused - */ - float aq_strength; - - /** - * PSY RD - * Strength of psychovisual optimization - * - encoding: Set by user - * - decoding: unused - */ - float psy_rd; - - /** - * PSY trellis - * Strength of psychovisual optimization - * - encoding: Set by user - * - decoding: unused - */ - float psy_trellis; - - /** - * RC lookahead - * Number of frames for frametype and ratecontrol lookahead - * - encoding: Set by user - * - decoding: unused - */ - int rc_lookahead; - - /** - * Constant rate factor maximum - * With CRF encoding mode and VBV restrictions enabled, prevents quality from being worse - * than crf_max, even if doing so would violate VBV restrictions. - * - encoding: Set by user. - * - decoding: unused - */ - float crf_max; - - int log_level_offset; - - /** - * Determines which LPC analysis algorithm to use. - * - encoding: Set by user - * - decoding: unused - */ - enum AVLPCType lpc_type; - - /** - * Number of passes to use for Cholesky factorization during LPC analysis - * - encoding: Set by user - * - decoding: unused - */ - int lpc_passes; -} AVCodecContext; - -/** - * AVCodec. - */ -typedef struct AVCodec { - /** - * Name of the codec implementation. - * The name is globally unique among encoders and among decoders (but an - * encoder and a decoder can share the same name). - * This is the primary way to find a codec from the user perspective. - */ - const char *name; - enum AVMediaType type; - enum CodecID id; - int priv_data_size; - int (*init)(AVCodecContext *); - int (*encode)(AVCodecContext *, uint8_t *buf, int buf_size, void *data); - int (*close)(AVCodecContext *); - int (*decode)(AVCodecContext *, void *outdata, int *outdata_size, AVPacket *avpkt); - /** - * Codec capabilities. - * see CODEC_CAP_* - */ - int capabilities; - struct AVCodec *next; - /** - * Flush buffers. - * Will be called when seeking - */ - void (*flush)(AVCodecContext *); - //const AVRational *supported_framerates; ///< array of supported framerates, or NULL if any, array is terminated by {0,0} - //const enum PixelFormat *pix_fmts; ///< array of supported pixel formats, or NULL if unknown, array is terminated by -1 - /** - * Descriptive name for the codec, meant to be more human readable than name. - * You should use the NULL_IF_CONFIG_SMALL() macro to define it. - */ - const char *long_name; - const int *supported_samplerates; ///< array of supported audio samplerates, or NULL if unknown, array is terminated by 0 - const enum SampleFormat *sample_fmts; ///< array of supported sample formats, or NULL if unknown, array is terminated by -1 - const int64_t *channel_layouts; ///< array of support channel layouts, or NULL if unknown. array is terminated by 0 - uint8_t max_lowres; ///< maximum value for lowres supported by the decoder -} AVCodec; - -/** - * AVHWAccel. - */ -typedef struct AVHWAccel { - /** - * Name of the hardware accelerated codec. - * The name is globally unique among encoders and among decoders (but an - * encoder and a decoder can share the same name). - */ - const char *name; - - /** - * Type of codec implemented by the hardware accelerator. - * - * See AVMEDIA_TYPE_xxx - */ - enum AVMediaType type; - - /** - * Codec implemented by the hardware accelerator. - * - * See CODEC_ID_xxx - */ - enum CodecID id; - - /** - * Supported pixel format. - * - * Only hardware accelerated formats are supported here. - */ - //enum PixelFormat pix_fmt; - - /** - * Hardware accelerated codec capabilities. - * see FF_HWACCEL_CODEC_CAP_* - */ - int capabilities; - - struct AVHWAccel *next; - - /** - * Called at the beginning of each frame or field picture. - * - * Meaningful frame information (codec specific) is guaranteed to - * be parsed at this point. This function is mandatory. - * - * Note that buf can be NULL along with buf_size set to 0. - * Otherwise, this means the whole frame is available at this point. - * - * @param avctx the codec context - * @param buf the frame data buffer base - * @param buf_size the size of the frame in bytes - * @return zero if successful, a negative value otherwise - */ - int (*start_frame)(AVCodecContext *avctx, const uint8_t *buf, uint32_t buf_size); - - /** - * Callback for each slice. - * - * Meaningful slice information (codec specific) is guaranteed to - * be parsed at this point. This function is mandatory. - * - * @param avctx the codec context - * @param buf the slice data buffer base - * @param buf_size the size of the slice in bytes - * @return zero if successful, a negative value otherwise - */ - int (*decode_slice)(AVCodecContext *avctx, const uint8_t *buf, uint32_t buf_size); - - /** - * Called at the end of each frame or field picture. - * - * The whole picture is parsed at this point and can now be sent - * to the hardware accelerator. This function is mandatory. - * - * @param avctx the codec context - * @return zero if successful, a negative value otherwise - */ - int (*end_frame)(AVCodecContext *avctx); - - /** - * Size of HW accelerator private data. - * - * Private data is allocated with av_mallocz() before - * AVCodecContext.get_buffer() and deallocated after - * AVCodecContext.release_buffer(). - */ - int priv_data_size; -} AVHWAccel; - -/** - * four components are given, that's all. - * the last component is alpha - */ -typedef struct AVPicture { - uint8_t *data[4]; - int linesize[4]; ///< number of bytes per line -} AVPicture; - -#if LIBAVCODEC_VERSION_MAJOR < 53 -/** - * AVPaletteControl - * This structure defines a method for communicating palette changes - * between and demuxer and a decoder. - * - * @deprecated Use AVPacket to send palette changes instead. - * This is totally broken. - */ -#define AVPALETTE_SIZE 1024 -#define AVPALETTE_COUNT 256 -typedef struct AVPaletteControl { - - /* Demuxer sets this to 1 to indicate the palette has changed; - * decoder resets to 0. */ - int palette_changed; - - /* 4-byte ARGB palette entries, stored in native byte order; note that - * the individual palette components should be on a 8-bit scale; if - * the palette data comes from an IBM VGA native format, the component - * data is probably 6 bits in size and needs to be scaled. */ - unsigned int palette[AVPALETTE_COUNT]; - -} AVPaletteControl attribute_deprecated; -#endif - -enum AVSubtitleType { - SUBTITLE_NONE, - - SUBTITLE_BITMAP, ///< A bitmap, pict will be set - - /** - * Plain text, the text field must be set by the decoder and is - * authoritative. ass and pict fields may contain approximations. - */ - SUBTITLE_TEXT, - - /** - * Formatted text, the ass field must be set by the decoder and is - * authoritative. pict and text fields may contain approximations. - */ - SUBTITLE_ASS, -}; - -typedef struct AVSubtitleRect { - int x; ///< top left corner of pict, undefined when pict is not set - int y; ///< top left corner of pict, undefined when pict is not set - int w; ///< width of pict, undefined when pict is not set - int h; ///< height of pict, undefined when pict is not set - int nb_colors; ///< number of colors in pict, undefined when pict is not set - - /** - * data+linesize for the bitmap of this subtitle. - * can be set for text/ass as well once they where rendered - */ - AVPicture pict; - enum AVSubtitleType type; - - char *text; ///< 0 terminated plain UTF-8 text - - /** - * 0 terminated ASS/SSA compatible event line. - * The pressentation of this is unaffected by the other values in this - * struct. - */ - char *ass; -} AVSubtitleRect; - -typedef struct AVSubtitle { - uint16_t format; /* 0 = graphics */ - uint32_t start_display_time; /* relative to packet pts, in ms */ - uint32_t end_display_time; /* relative to packet pts, in ms */ - unsigned num_rects; - AVSubtitleRect **rects; - int64_t pts; ///< Same as packet pts, in AV_TIME_BASE -} AVSubtitle; - -/* packet functions */ - -/** - * @deprecated use NULL instead - */ -attribute_deprecated void av_destruct_packet_nofree(AVPacket *pkt); - -/** - * Default packet destructor. - */ -void av_destruct_packet(AVPacket *pkt); - -/** - * Initialize optional fields of a packet with default values. - * - * @param pkt packet - */ -void av_init_packet(AVPacket *pkt); - -/** - * Allocate the payload of a packet and initialize its fields with - * default values. - * - * @param pkt packet - * @param size wanted payload size - * @return 0 if OK, AVERROR_xxx otherwise - */ -int av_new_packet(AVPacket *pkt, int size); - -/** - * Reduce packet size, correctly zeroing padding - * - * @param pkt packet - * @param size new size - */ -void av_shrink_packet(AVPacket *pkt, int size); - -/** - * @warning This is a hack - the packet memory allocation stuff is broken. The - * packet is allocated if it was not really allocated. - */ -int av_dup_packet(AVPacket *pkt); - -/** - * Free a packet. - * - * @param pkt packet to free - */ -void av_free_packet(AVPacket *pkt); - -/* resample.c */ - -struct ReSampleContext; -struct AVResampleContext; - -typedef struct ReSampleContext ReSampleContext; - -#if LIBAVCODEC_VERSION_MAJOR < 53 -/** - * @deprecated Use av_audio_resample_init() instead. - */ -attribute_deprecated ReSampleContext *audio_resample_init(int output_channels, int input_channels, - int output_rate, int input_rate); -#endif -/** - * Initialize audio resampling context - * - * @param output_channels number of output channels - * @param input_channels number of input channels - * @param output_rate output sample rate - * @param input_rate input sample rate - * @param sample_fmt_out requested output sample format - * @param sample_fmt_in input sample format - * @param filter_length length of each FIR filter in the filterbank relative to the cutoff freq - * @param log2_phase_count log2 of the number of entries in the polyphase filterbank - * @param linear If 1 then the used FIR filter will be linearly interpolated - between the 2 closest, if 0 the closest will be used - * @param cutoff cutoff frequency, 1.0 corresponds to half the output sampling rate - * @return allocated ReSampleContext, NULL if error occured - */ -ReSampleContext *av_audio_resample_init(int output_channels, int input_channels, - int output_rate, int input_rate, - enum SampleFormat sample_fmt_out, - enum SampleFormat sample_fmt_in, - int filter_length, int log2_phase_count, - int linear, double cutoff); - -int audio_resample(ReSampleContext *s, short *output, short *input, int nb_samples); -void audio_resample_close(ReSampleContext *s); - - -/** - * Initialize an audio resampler. - * Note, if either rate is not an integer then simply scale both rates up so they are. - * @param filter_length length of each FIR filter in the filterbank relative to the cutoff freq - * @param log2_phase_count log2 of the number of entries in the polyphase filterbank - * @param linear If 1 then the used FIR filter will be linearly interpolated - between the 2 closest, if 0 the closest will be used - * @param cutoff cutoff frequency, 1.0 corresponds to half the output sampling rate - */ -struct AVResampleContext *av_resample_init(int out_rate, int in_rate, int filter_length, int log2_phase_count, int linear, double cutoff); - -/** - * Resample an array of samples using a previously configured context. - * @param src an array of unconsumed samples - * @param consumed the number of samples of src which have been consumed are returned here - * @param src_size the number of unconsumed samples available - * @param dst_size the amount of space in samples available in dst - * @param update_ctx If this is 0 then the context will not be modified, that way several channels can be resampled with the same context. - * @return the number of samples written in dst or -1 if an error occurred - */ -int av_resample(struct AVResampleContext *c, short *dst, short *src, int *consumed, int src_size, int dst_size, int update_ctx); - - -/** - * Compensate samplerate/timestamp drift. The compensation is done by changing - * the resampler parameters, so no audible clicks or similar distortions occur - * @param compensation_distance distance in output samples over which the compensation should be performed - * @param sample_delta number of output samples which should be output less - * - * example: av_resample_compensate(c, 10, 500) - * here instead of 510 samples only 500 samples would be output - * - * note, due to rounding the actual compensation might be slightly different, - * especially if the compensation_distance is large and the in_rate used during init is small - */ -void av_resample_compensate(struct AVResampleContext *c, int sample_delta, int compensation_distance); -void av_resample_close(struct AVResampleContext *c); - -/** - * Allocate memory for a picture. Call avpicture_free to free it. - * - * @param picture the picture to be filled in - * @param pix_fmt the format of the picture - * @param width the width of the picture - * @param height the height of the picture - * @return zero if successful, a negative value if not - */ -int avpicture_alloc(AVPicture *picture, enum PixelFormat pix_fmt, int width, int height); - -/** - * Free a picture previously allocated by avpicture_alloc(). - * - * @param picture the AVPicture to be freed - */ -void avpicture_free(AVPicture *picture); - -/** - * Fill in the AVPicture fields. - * The fields of the given AVPicture are filled in by using the 'ptr' address - * which points to the image data buffer. Depending on the specified picture - * format, one or multiple image data pointers and line sizes will be set. - * If a planar format is specified, several pointers will be set pointing to - * the different picture planes and the line sizes of the different planes - * will be stored in the lines_sizes array. - * Call with ptr == NULL to get the required size for the ptr buffer. - * - * @param picture AVPicture whose fields are to be filled in - * @param ptr Buffer which will contain or contains the actual image data - * @param pix_fmt The format in which the picture data is stored. - * @param width the width of the image in pixels - * @param height the height of the image in pixels - * @return size of the image data in bytes - */ -int avpicture_fill(AVPicture *picture, uint8_t *ptr, - enum PixelFormat pix_fmt, int width, int height); -int avpicture_layout(const AVPicture* src, enum PixelFormat pix_fmt, int width, int height, - unsigned char *dest, int dest_size); - -/** - * Calculate the size in bytes that a picture of the given width and height - * would occupy if stored in the given picture format. - * Note that this returns the size of a compact representation as generated - * by avpicture_layout, which can be smaller than the size required for e.g. - * avpicture_fill. - * - * @param pix_fmt the given picture format - * @param width the width of the image - * @param height the height of the image - * @return Image data size in bytes or -1 on error (e.g. too large dimensions). - */ -int avpicture_get_size(enum PixelFormat pix_fmt, int width, int height); -void avcodec_get_chroma_sub_sample(enum PixelFormat pix_fmt, int *h_shift, int *v_shift); -const char *avcodec_get_pix_fmt_name(enum PixelFormat pix_fmt); -void avcodec_set_dimensions(AVCodecContext *s, int width, int height); - -#if LIBAVCODEC_VERSION_MAJOR < 53 -/** - * Return the pixel format corresponding to the name name. - * - * If there is no pixel format with name name, then look for a - * pixel format with the name corresponding to the native endian - * format of name. - * For example in a little-endian system, first look for "gray16", - * then for "gray16le". - * - * Finally if no pixel format has been found, return PIX_FMT_NONE. - * - * @deprecated Deprecated in favor of av_get_pix_fmt(). - */ -attribute_deprecated enum PixelFormat avcodec_get_pix_fmt(const char* name); -#endif - -/** - * Return a value representing the fourCC code associated to the - * pixel format pix_fmt, or 0 if no associated fourCC code can be - * found. - */ -unsigned int avcodec_pix_fmt_to_codec_tag(enum PixelFormat pix_fmt); - -/** - * Put a string representing the codec tag codec_tag in buf. - * - * @param buf_size size in bytes of buf - * @return the length of the string that would have been generated if - * enough space had been available, excluding the trailing null - */ -size_t av_get_codec_tag_string(char *buf, size_t buf_size, unsigned int codec_tag); - -#define FF_LOSS_RESOLUTION 0x0001 /**< loss due to resolution change */ -#define FF_LOSS_DEPTH 0x0002 /**< loss due to color depth change */ -#define FF_LOSS_COLORSPACE 0x0004 /**< loss due to color space conversion */ -#define FF_LOSS_ALPHA 0x0008 /**< loss of alpha bits */ -#define FF_LOSS_COLORQUANT 0x0010 /**< loss due to color quantization */ -#define FF_LOSS_CHROMA 0x0020 /**< loss of chroma (e.g. RGB to gray conversion) */ - -/** - * Compute what kind of losses will occur when converting from one specific - * pixel format to another. - * When converting from one pixel format to another, information loss may occur. - * For example, when converting from RGB24 to GRAY, the color information will - * be lost. Similarly, other losses occur when converting from some formats to - * other formats. These losses can involve loss of chroma, but also loss of - * resolution, loss of color depth, loss due to the color space conversion, loss - * of the alpha bits or loss due to color quantization. - * avcodec_get_fix_fmt_loss() informs you about the various types of losses - * which will occur when converting from one pixel format to another. - * - * @param[in] dst_pix_fmt destination pixel format - * @param[in] src_pix_fmt source pixel format - * @param[in] has_alpha Whether the source pixel format alpha channel is used. - * @return Combination of flags informing you what kind of losses will occur. - */ -int avcodec_get_pix_fmt_loss(enum PixelFormat dst_pix_fmt, enum PixelFormat src_pix_fmt, - int has_alpha); - -/** - * Find the best pixel format to convert to given a certain source pixel - * format. When converting from one pixel format to another, information loss - * may occur. For example, when converting from RGB24 to GRAY, the color - * information will be lost. Similarly, other losses occur when converting from - * some formats to other formats. avcodec_find_best_pix_fmt() searches which of - * the given pixel formats should be used to suffer the least amount of loss. - * The pixel formats from which it chooses one, are determined by the - * pix_fmt_mask parameter. - * - * @code - * src_pix_fmt = PIX_FMT_YUV420P; - * pix_fmt_mask = (1 << PIX_FMT_YUV422P) || (1 << PIX_FMT_RGB24); - * dst_pix_fmt = avcodec_find_best_pix_fmt(pix_fmt_mask, src_pix_fmt, alpha, &loss); - * @endcode - * - * @param[in] pix_fmt_mask bitmask determining which pixel format to choose from - * @param[in] src_pix_fmt source pixel format - * @param[in] has_alpha Whether the source pixel format alpha channel is used. - * @param[out] loss_ptr Combination of flags informing you what kind of losses will occur. - * @return The best pixel format to convert to or -1 if none was found. - */ -enum PixelFormat avcodec_find_best_pix_fmt(int64_t pix_fmt_mask, enum PixelFormat src_pix_fmt, - int has_alpha, int *loss_ptr); - - -/** - * Print in buf the string corresponding to the pixel format with - * number pix_fmt, or an header if pix_fmt is negative. - * - * @param[in] buf the buffer where to write the string - * @param[in] buf_size the size of buf - * @param[in] pix_fmt the number of the pixel format to print the corresponding info string, or - * a negative value to print the corresponding header. - * Meaningful values for obtaining a pixel format info vary from 0 to PIX_FMT_NB -1. - */ -void avcodec_pix_fmt_string (char *buf, int buf_size, enum PixelFormat pix_fmt); - -#define FF_ALPHA_TRANSP 0x0001 /* image has some totally transparent pixels */ -#define FF_ALPHA_SEMI_TRANSP 0x0002 /* image has some transparent pixels */ - -/** - * Tell if an image really has transparent alpha values. - * @return ored mask of FF_ALPHA_xxx constants - */ -int img_get_alpha_info(const AVPicture *src, - enum PixelFormat pix_fmt, int width, int height); - -/* deinterlace a picture */ -/* deinterlace - if not supported return -1 */ -int avpicture_deinterlace(AVPicture *dst, const AVPicture *src, - enum PixelFormat pix_fmt, int width, int height); - -/* external high level API */ - -/** - * If c is NULL, returns the first registered codec, - * if c is non-NULL, returns the next registered codec after c, - * or NULL if c is the last one. - */ -AVCodec *av_codec_next(AVCodec *c); - -/** - * Return the LIBAVCODEC_VERSION_INT constant. - */ -unsigned avcodec_version(void); - -/** - * Return the libavcodec build-time configuration. - */ -const char *avcodec_configuration(void); - -/** - * Return the libavcodec license. - */ -const char *avcodec_license(void); - -/** - * Initialize libavcodec. - * - * @warning This function must be called before any other libavcodec - * function. - */ -void avcodec_init(void); - -#if LIBAVCODEC_VERSION_MAJOR < 53 -/** - * @deprecated Deprecated in favor of avcodec_register(). - */ -attribute_deprecated void register_avcodec(AVCodec *codec); -#endif - -/** - * Register the codec codec and initialize libavcodec. - * - * @see avcodec_init() - */ -void avcodec_register(AVCodec *codec); - -/** - * Find a registered encoder with a matching codec ID. - * - * @param id CodecID of the requested encoder - * @return An encoder if one was found, NULL otherwise. - */ -AVCodec *avcodec_find_encoder(enum CodecID id); - -/** - * Find a registered encoder with the specified name. - * - * @param name name of the requested encoder - * @return An encoder if one was found, NULL otherwise. - */ -AVCodec *avcodec_find_encoder_by_name(const char *name); - -/** - * Find a registered decoder with a matching codec ID. - * - * @param id CodecID of the requested decoder - * @return A decoder if one was found, NULL otherwise. - */ -AVCodec *avcodec_find_decoder(enum CodecID id); - -/** - * Find a registered decoder with the specified name. - * - * @param name name of the requested decoder - * @return A decoder if one was found, NULL otherwise. - */ -AVCodec *avcodec_find_decoder_by_name(const char *name); -void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode); - -/** - * Set the fields of the given AVCodecContext to default values. - * - * @param s The AVCodecContext of which the fields should be set to default values. - */ -void avcodec_get_context_defaults(AVCodecContext *s); - -/** THIS FUNCTION IS NOT YET PART OF THE PUBLIC API! - * we WILL change its arguments and name a few times! */ -void avcodec_get_context_defaults2(AVCodecContext *s, enum AVMediaType); - -/** - * Allocate an AVCodecContext and set its fields to default values. The - * resulting struct can be deallocated by simply calling av_free(). - * - * @return An AVCodecContext filled with default values or NULL on failure. - * @see avcodec_get_context_defaults - */ -AVCodecContext *avcodec_alloc_context(void); - -/** THIS FUNCTION IS NOT YET PART OF THE PUBLIC API! - * we WILL change its arguments and name a few times! */ -AVCodecContext *avcodec_alloc_context2(enum AVMediaType); - -/** - * Copy the settings of the source AVCodecContext into the destination - * AVCodecContext. The resulting destination codec context will be - * unopened, i.e. you are required to call avcodec_open() before you - * can use this AVCodecContext to decode/encode video/audio data. - * - * @param dest target codec context, should be initialized with - * avcodec_alloc_context(), but otherwise uninitialized - * @param src source codec context - * @return AVERROR() on error (e.g. memory allocation error), 0 on success - */ -int avcodec_copy_context(AVCodecContext *dest, const AVCodecContext *src); - -/** - * Set the fields of the given AVFrame to default values. - * - * @param pic The AVFrame of which the fields should be set to default values. - */ -void avcodec_get_frame_defaults(AVFrame *pic); - -/** - * Allocate an AVFrame and set its fields to default values. The resulting - * struct can be deallocated by simply calling av_free(). - * - * @return An AVFrame filled with default values or NULL on failure. - * @see avcodec_get_frame_defaults - */ -AVFrame *avcodec_alloc_frame(void); - -int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic); -void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic); -int avcodec_default_reget_buffer(AVCodecContext *s, AVFrame *pic); - -/** - * Return the amount of padding in pixels which the get_buffer callback must - * provide around the edge of the image for codecs which do not have the - * CODEC_FLAG_EMU_EDGE flag. - * - * @return Required padding in pixels. - */ -unsigned avcodec_get_edge_width(void); -/** - * Modify width and height values so that they will result in a memory - * buffer that is acceptable for the codec if you do not use any horizontal - * padding. - * - * May only be used if a codec with CODEC_CAP_DR1 has been opened. - * If CODEC_FLAG_EMU_EDGE is not set, the dimensions must have been increased - * according to avcodec_get_edge_width() before. - */ -void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height); -/** - * Modify width and height values so that they will result in a memory - * buffer that is acceptable for the codec if you also ensure that all - * line sizes are a multiple of the respective linesize_align[i]. - * - * May only be used if a codec with CODEC_CAP_DR1 has been opened. - * If CODEC_FLAG_EMU_EDGE is not set, the dimensions must have been increased - * according to avcodec_get_edge_width() before. - */ -void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height, - int linesize_align[4]); - -#if LIBAVCODEC_VERSION_MAJOR < 53 -/** - * @deprecated Deprecated in favor of av_check_image_size(). - */ -attribute_deprecated -int avcodec_check_dimensions(void *av_log_ctx, unsigned int w, unsigned int h); -#endif - -enum PixelFormat avcodec_default_get_format(struct AVCodecContext *s, const enum PixelFormat * fmt); - -int avcodec_thread_init(AVCodecContext *s, int thread_count); -void avcodec_thread_free(AVCodecContext *s); -int avcodec_default_execute(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2),void *arg, int *ret, int count, int size); -int avcodec_default_execute2(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2, int, int),void *arg, int *ret, int count); -//FIXME func typedef - -/** - * Initialize the AVCodecContext to use the given AVCodec. Prior to using this - * function the context has to be allocated. - * - * The functions avcodec_find_decoder_by_name(), avcodec_find_encoder_by_name(), - * avcodec_find_decoder() and avcodec_find_encoder() provide an easy way for - * retrieving a codec. - * - * @warning This function is not thread safe! - * - * @code - * avcodec_register_all(); - * codec = avcodec_find_decoder(CODEC_ID_H264); - * if (!codec) - * exit(1); - * - * context = avcodec_alloc_context(); - * - * if (avcodec_open(context, codec) < 0) - * exit(1); - * @endcode - * - * @param avctx The context which will be set up to use the given codec. - * @param codec The codec to use within the context. - * @return zero on success, a negative value on error - * @see avcodec_alloc_context, avcodec_find_decoder, avcodec_find_encoder - */ -int avcodec_open(AVCodecContext *avctx, AVCodec *codec); - -#if LIBAVCODEC_VERSION_MAJOR < 53 -/** - * Decode an audio frame from buf into samples. - * Wrapper function which calls avcodec_decode_audio3. - * - * @deprecated Use avcodec_decode_audio3 instead. - * @param avctx the codec context - * @param[out] samples the output buffer - * @param[in,out] frame_size_ptr the output buffer size in bytes - * @param[in] buf the input buffer - * @param[in] buf_size the input buffer size in bytes - * @return On error a negative value is returned, otherwise the number of bytes - * used or zero if no frame could be decompressed. - */ -attribute_deprecated int avcodec_decode_audio2(AVCodecContext *avctx, int16_t *samples, - int *frame_size_ptr, - const uint8_t *buf, int buf_size); -#endif - -/** - * Decode the audio frame of size avpkt->size from avpkt->data into samples. - * Some decoders may support multiple frames in a single AVPacket, such - * decoders would then just decode the first frame. In this case, - * avcodec_decode_audio3 has to be called again with an AVPacket that contains - * the remaining data in order to decode the second frame etc. - * If no frame - * could be outputted, frame_size_ptr is zero. Otherwise, it is the - * decompressed frame size in bytes. - * - * @warning You must set frame_size_ptr to the allocated size of the - * output buffer before calling avcodec_decode_audio3(). - * - * @warning The input buffer must be FF_INPUT_BUFFER_PADDING_SIZE larger than - * the actual read bytes because some optimized bitstream readers read 32 or 64 - * bits at once and could read over the end. - * - * @warning The end of the input buffer avpkt->data should be set to 0 to ensure that - * no overreading happens for damaged MPEG streams. - * - * @note You might have to align the input buffer avpkt->data and output buffer - * samples. The alignment requirements depend on the CPU: On some CPUs it isn't - * necessary at all, on others it won't work at all if not aligned and on others - * it will work but it will have an impact on performance. - * - * In practice, avpkt->data should have 4 byte alignment at minimum and - * samples should be 16 byte aligned unless the CPU doesn't need it - * (AltiVec and SSE do). - * - * @param avctx the codec context - * @param[out] samples the output buffer, sample type in avctx->sample_fmt - * @param[in,out] frame_size_ptr the output buffer size in bytes - * @param[in] avpkt The input AVPacket containing the input buffer. - * You can create such packet with av_init_packet() and by then setting - * data and size, some decoders might in addition need other fields. - * All decoders are designed to use the least fields possible though. - * @return On error a negative value is returned, otherwise the number of bytes - * used or zero if no frame data was decompressed (used) from the input AVPacket. - */ -int avcodec_decode_audio3(AVCodecContext *avctx, int16_t *samples, - int *frame_size_ptr, - AVPacket *avpkt); - -#if LIBAVCODEC_VERSION_MAJOR < 53 -/** - * Decode a video frame from buf into picture. - * Wrapper function which calls avcodec_decode_video2. - * - * @deprecated Use avcodec_decode_video2 instead. - * @param avctx the codec context - * @param[out] picture The AVFrame in which the decoded video frame will be stored. - * @param[in] buf the input buffer - * @param[in] buf_size the size of the input buffer in bytes - * @param[in,out] got_picture_ptr Zero if no frame could be decompressed, otherwise, it is nonzero. - * @return On error a negative value is returned, otherwise the number of bytes - * used or zero if no frame could be decompressed. - */ -attribute_deprecated int avcodec_decode_video(AVCodecContext *avctx, AVFrame *picture, - int *got_picture_ptr, - const uint8_t *buf, int buf_size); -#endif - -/** - * Decode the video frame of size avpkt->size from avpkt->data into picture. - * Some decoders may support multiple frames in a single AVPacket, such - * decoders would then just decode the first frame. - * - * @warning The input buffer must be FF_INPUT_BUFFER_PADDING_SIZE larger than - * the actual read bytes because some optimized bitstream readers read 32 or 64 - * bits at once and could read over the end. - * - * @warning The end of the input buffer buf should be set to 0 to ensure that - * no overreading happens for damaged MPEG streams. - * - * @note You might have to align the input buffer avpkt->data. - * The alignment requirements depend on the CPU: on some CPUs it isn't - * necessary at all, on others it won't work at all if not aligned and on others - * it will work but it will have an impact on performance. - * - * In practice, avpkt->data should have 4 byte alignment at minimum. - * - * @note Some codecs have a delay between input and output, these need to be - * fed with avpkt->data=NULL, avpkt->size=0 at the end to return the remaining frames. - * - * @param avctx the codec context - * @param[out] picture The AVFrame in which the decoded video frame will be stored. - * Use avcodec_alloc_frame to get an AVFrame, the codec will - * allocate memory for the actual bitmap. - * with default get/release_buffer(), the decoder frees/reuses the bitmap as it sees fit. - * with overridden get/release_buffer() (needs CODEC_CAP_DR1) the user decides into what buffer the decoder - * decodes and the decoder tells the user once it does not need the data anymore, - * the user app can at this point free/reuse/keep the memory as it sees fit. - * - * @param[in] avpkt The input AVpacket containing the input buffer. - * You can create such packet with av_init_packet() and by then setting - * data and size, some decoders might in addition need other fields like - * flags&AV_PKT_FLAG_KEY. All decoders are designed to use the least - * fields possible. - * @param[in,out] got_picture_ptr Zero if no frame could be decompressed, otherwise, it is nonzero. - * @return On error a negative value is returned, otherwise the number of bytes - * used or zero if no frame could be decompressed. - */ -int avcodec_decode_video2(AVCodecContext *avctx, AVFrame *picture, - int *got_picture_ptr, - AVPacket *avpkt); - -#if LIBAVCODEC_VERSION_MAJOR < 53 -/* Decode a subtitle message. Return -1 if error, otherwise return the - * number of bytes used. If no subtitle could be decompressed, - * got_sub_ptr is zero. Otherwise, the subtitle is stored in *sub. */ -attribute_deprecated int avcodec_decode_subtitle(AVCodecContext *avctx, AVSubtitle *sub, - int *got_sub_ptr, - const uint8_t *buf, int buf_size); -#endif - -/** - * Decode a subtitle message. - * Return a negative value on error, otherwise return the number of bytes used. - * If no subtitle could be decompressed, got_sub_ptr is zero. - * Otherwise, the subtitle is stored in *sub. - * Note that CODEC_CAP_DR1 is not available for subtitle codecs. This is for - * simplicity, because the performance difference is expect to be negligible - * and reusing a get_buffer written for video codecs would probably perform badly - * due to a potentially very different allocation pattern. - * - * @param avctx the codec context - * @param[out] sub The AVSubtitle in which the decoded subtitle will be stored, must be - freed with avsubtitle_free if *got_sub_ptr is set. - * @param[in,out] got_sub_ptr Zero if no subtitle could be decompressed, otherwise, it is nonzero. - * @param[in] avpkt The input AVPacket containing the input buffer. - */ -int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub, - int *got_sub_ptr, - AVPacket *avpkt); - -/** - * Frees all allocated data in the given subtitle struct. - * - * @param sub AVSubtitle to free. - */ -void avsubtitle_free(AVSubtitle *sub); - -int avcodec_parse_frame(AVCodecContext *avctx, uint8_t **pdata, - int *data_size_ptr, - uint8_t *buf, int buf_size); - -/** - * Encode an audio frame from samples into buf. - * - * @note The output buffer should be at least FF_MIN_BUFFER_SIZE bytes large. - * However, for PCM audio the user will know how much space is needed - * because it depends on the value passed in buf_size as described - * below. In that case a lower value can be used. - * - * @param avctx the codec context - * @param[out] buf the output buffer - * @param[in] buf_size the output buffer size - * @param[in] samples the input buffer containing the samples - * The number of samples read from this buffer is frame_size*channels, - * both of which are defined in avctx. - * For PCM audio the number of samples read from samples is equal to - * buf_size * input_sample_size / output_sample_size. - * @return On error a negative value is returned, on success zero or the number - * of bytes used to encode the data read from the input buffer. - */ -int avcodec_encode_audio(AVCodecContext *avctx, uint8_t *buf, int buf_size, - const short *samples); - -/** - * Encode a video frame from pict into buf. - * The input picture should be - * stored using a specific format, namely avctx.pix_fmt. - * - * @param avctx the codec context - * @param[out] buf the output buffer for the bitstream of encoded frame - * @param[in] buf_size the size of the output buffer in bytes - * @param[in] pict the input picture to encode - * @return On error a negative value is returned, on success zero or the number - * of bytes used from the output buffer. - */ -int avcodec_encode_video(AVCodecContext *avctx, uint8_t *buf, int buf_size, - const AVFrame *pict); -int avcodec_encode_subtitle(AVCodecContext *avctx, uint8_t *buf, int buf_size, - const AVSubtitle *sub); - -int avcodec_close(AVCodecContext *avctx); - -/** - * Register all the codecs, parsers and bitstream filters which were enabled at - * configuration time. If you do not call this function you can select exactly - * which formats you want to support, by using the individual registration - * functions. - * - * @see avcodec_register - * @see av_register_codec_parser - * @see av_register_bitstream_filter - */ -void avcodec_register_all(void); - -/** - * Flush buffers, should be called when seeking or when switching to a different stream. - */ -void avcodec_flush_buffers(AVCodecContext *avctx); - -void avcodec_default_free_buffers(AVCodecContext *s); - -/* misc useful functions */ - -/** - * Return a single letter to describe the given picture type pict_type. - * - * @param[in] pict_type the picture type - * @return A single character representing the picture type. - */ -char av_get_pict_type_char(int pict_type); - -/** - * Return codec bits per sample. - * - * @param[in] codec_id the codec - * @return Number of bits per sample or zero if unknown for the given codec. - */ -int av_get_bits_per_sample(enum CodecID codec_id); - -/** - * Return sample format bits per sample. - * - * @param[in] sample_fmt the sample format - * @return Number of bits per sample or zero if unknown for the given sample format. - */ -int av_get_bits_per_sample_format(enum SampleFormat sample_fmt); - -/* frame parsing */ -typedef struct AVCodecParserContext { - void *priv_data; - struct AVCodecParser *parser; - int64_t frame_offset; /* offset of the current frame */ - int64_t cur_offset; /* current offset - (incremented by each av_parser_parse()) */ - int64_t next_frame_offset; /* offset of the next frame */ - /* video info */ - int pict_type; /* XXX: Put it back in AVCodecContext. */ - /** - * This field is used for proper frame duration computation in lavf. - * It signals, how much longer the frame duration of the current frame - * is compared to normal frame duration. - * - * frame_duration = (1 + repeat_pict) * time_base - * - * It is used by codecs like H.264 to display telecined material. - */ - int repeat_pict; /* XXX: Put it back in AVCodecContext. */ - int64_t pts; /* pts of the current frame */ - int64_t dts; /* dts of the current frame */ - - /* private data */ - int64_t last_pts; - int64_t last_dts; - int fetch_timestamp; - -#define AV_PARSER_PTS_NB 4 - int cur_frame_start_index; - int64_t cur_frame_offset[AV_PARSER_PTS_NB]; - int64_t cur_frame_pts[AV_PARSER_PTS_NB]; - int64_t cur_frame_dts[AV_PARSER_PTS_NB]; - - int flags; -#define PARSER_FLAG_COMPLETE_FRAMES 0x0001 -#define PARSER_FLAG_ONCE 0x0002 - - int64_t offset; ///< byte offset from starting packet start - int64_t cur_frame_end[AV_PARSER_PTS_NB]; - - /*! - * Set by parser to 1 for key frames and 0 for non-key frames. - * It is initialized to -1, so if the parser doesn't set this flag, - * old-style fallback using FF_I_TYPE picture type as key frames - * will be used. - */ - int key_frame; - - /** - * Time difference in stream time base units from the pts of this - * packet to the point at which the output from the decoder has converged - * independent from the availability of previous frames. That is, the - * frames are virtually identical no matter if decoding started from - * the very first frame or from this keyframe. - * Is AV_NOPTS_VALUE if unknown. - * This field is not the display duration of the current frame. - * This field has no meaning if the packet does not have AV_PKT_FLAG_KEY - * set. - * - * The purpose of this field is to allow seeking in streams that have no - * keyframes in the conventional sense. It corresponds to the - * recovery point SEI in H.264 and match_time_delta in NUT. It is also - * essential for some types of subtitle streams to ensure that all - * subtitles are correctly displayed after seeking. - */ - int64_t convergence_duration; - - // Timestamp generation support: - /** - * Synchronization point for start of timestamp generation. - * - * Set to >0 for sync point, 0 for no sync point and <0 for undefined - * (default). - * - * For example, this corresponds to presence of H.264 buffering period - * SEI message. - */ - int dts_sync_point; - - /** - * Offset of the current timestamp against last timestamp sync point in - * units of AVCodecContext.time_base. - * - * Set to INT_MIN when dts_sync_point unused. Otherwise, it must - * contain a valid timestamp offset. - * - * Note that the timestamp of sync point has usually a nonzero - * dts_ref_dts_delta, which refers to the previous sync point. Offset of - * the next frame after timestamp sync point will be usually 1. - * - * For example, this corresponds to H.264 cpb_removal_delay. - */ - int dts_ref_dts_delta; - - /** - * Presentation delay of current frame in units of AVCodecContext.time_base. - * - * Set to INT_MIN when dts_sync_point unused. Otherwise, it must - * contain valid non-negative timestamp delta (presentation time of a frame - * must not lie in the past). - * - * This delay represents the difference between decoding and presentation - * time of the frame. - * - * For example, this corresponds to H.264 dpb_output_delay. - */ - int pts_dts_delta; - - /** - * Position of the packet in file. - * - * Analogous to cur_frame_pts/dts - */ - int64_t cur_frame_pos[AV_PARSER_PTS_NB]; - - /** - * Byte position of currently parsed frame in stream. - */ - int64_t pos; - - /** - * Previous frame byte position. - */ - int64_t last_pos; -} AVCodecParserContext; - -typedef struct AVCodecParser { - int codec_ids[5]; /* several codec IDs are permitted */ - int priv_data_size; - int (*parser_init)(AVCodecParserContext *s); - int (*parser_parse)(AVCodecParserContext *s, - AVCodecContext *avctx, - const uint8_t **poutbuf, int *poutbuf_size, - const uint8_t *buf, int buf_size); - void (*parser_close)(AVCodecParserContext *s); - int (*split)(AVCodecContext *avctx, const uint8_t *buf, int buf_size); - struct AVCodecParser *next; -} AVCodecParser; - -AVCodecParser *av_parser_next(AVCodecParser *c); - -void av_register_codec_parser(AVCodecParser *parser); -AVCodecParserContext *av_parser_init(int codec_id); - -#if LIBAVCODEC_VERSION_MAJOR < 53 -attribute_deprecated -int av_parser_parse(AVCodecParserContext *s, - AVCodecContext *avctx, - uint8_t **poutbuf, int *poutbuf_size, - const uint8_t *buf, int buf_size, - int64_t pts, int64_t dts); -#endif - -/** - * Parse a packet. - * - * @param s parser context. - * @param avctx codec context. - * @param poutbuf set to pointer to parsed buffer or NULL if not yet finished. - * @param poutbuf_size set to size of parsed buffer or zero if not yet finished. - * @param buf input buffer. - * @param buf_size input length, to signal EOF, this should be 0 (so that the last frame can be output). - * @param pts input presentation timestamp. - * @param dts input decoding timestamp. - * @param pos input byte position in stream. - * @return the number of bytes of the input bitstream used. - * - * Example: - * @code - * while(in_len){ - * len = av_parser_parse2(myparser, AVCodecContext, &data, &size, - * in_data, in_len, - * pts, dts, pos); - * in_data += len; - * in_len -= len; - * - * if(size) - * decode_frame(data, size); - * } - * @endcode - */ -int av_parser_parse2(AVCodecParserContext *s, - AVCodecContext *avctx, - uint8_t **poutbuf, int *poutbuf_size, - const uint8_t *buf, int buf_size, - int64_t pts, int64_t dts, - int64_t pos); - -int av_parser_change(AVCodecParserContext *s, - AVCodecContext *avctx, - uint8_t **poutbuf, int *poutbuf_size, - const uint8_t *buf, int buf_size, int keyframe); -void av_parser_close(AVCodecParserContext *s); - - -typedef struct AVBitStreamFilterContext { - void *priv_data; - struct AVBitStreamFilter *filter; - AVCodecParserContext *parser; - struct AVBitStreamFilterContext *next; -} AVBitStreamFilterContext; - - -typedef struct AVBitStreamFilter { - const char *name; - int priv_data_size; - int (*filter)(AVBitStreamFilterContext *bsfc, - AVCodecContext *avctx, const char *args, - uint8_t **poutbuf, int *poutbuf_size, - const uint8_t *buf, int buf_size, int keyframe); - void (*close)(AVBitStreamFilterContext *bsfc); - struct AVBitStreamFilter *next; -} AVBitStreamFilter; - -void av_register_bitstream_filter(AVBitStreamFilter *bsf); -AVBitStreamFilterContext *av_bitstream_filter_init(const char *name); -int av_bitstream_filter_filter(AVBitStreamFilterContext *bsfc, - AVCodecContext *avctx, const char *args, - uint8_t **poutbuf, int *poutbuf_size, - const uint8_t *buf, int buf_size, int keyframe); -void av_bitstream_filter_close(AVBitStreamFilterContext *bsf); - -AVBitStreamFilter *av_bitstream_filter_next(AVBitStreamFilter *f); - -/* memory */ - -/** - * Reallocate the given block if it is not large enough, otherwise do nothing. - * - * @see av_realloc - */ -void *av_fast_realloc(void *ptr, unsigned int *size, unsigned int min_size); - -/** - * Allocate a buffer, reusing the given one if large enough. - * - * Contrary to av_fast_realloc the current buffer contents might not be - * preserved and on error the old buffer is freed, thus no special - * handling to avoid memleaks is necessary. - * - * @param ptr pointer to pointer to already allocated buffer, overwritten with pointer to new buffer - * @param size size of the buffer *ptr points to - * @param min_size minimum size of *ptr buffer after returning, *ptr will be NULL and - * *size 0 if an error occurred. - */ -void av_fast_malloc(void *ptr, unsigned int *size, unsigned int min_size); - -/** - * Copy image 'src' to 'dst'. - */ -void av_picture_copy(AVPicture *dst, const AVPicture *src, - enum PixelFormat pix_fmt, int width, int height); - -/** - * Crop image top and left side. - */ -int av_picture_crop(AVPicture *dst, const AVPicture *src, - enum PixelFormat pix_fmt, int top_band, int left_band); - -/** - * Pad image. - */ -int av_picture_pad(AVPicture *dst, const AVPicture *src, int height, int width, enum PixelFormat pix_fmt, - int padtop, int padbottom, int padleft, int padright, int *color); - -/** - * Encode extradata length to a buffer. Used by xiph codecs. - * - * @param s buffer to write to; must be at least (v/255+1) bytes long - * @param v size of extradata in bytes - * @return number of bytes written to the buffer. - */ -unsigned int av_xiphlacing(unsigned char *s, unsigned int v); - -#if LIBAVCODEC_VERSION_MAJOR < 53 -/** - * Parse str and put in width_ptr and height_ptr the detected values. - * - * @deprecated Deprecated in favor of av_parse_video_size(). - */ -attribute_deprecated int av_parse_video_frame_size(int *width_ptr, int *height_ptr, const char *str); - -/** - * Parse str and store the detected values in *frame_rate. - * - * @deprecated Deprecated in favor of av_parse_video_rate(). - */ -//attribute_deprecated int av_parse_video_frame_rate(AVRational *frame_rate, const char *str); -#endif - -/** - * Logs a generic warning message about a missing feature. This function is - * intended to be used internally by FFmpeg (libavcodec, libavformat, etc.) - * only, and would normally not be used by applications. - * @param[in] avc a pointer to an arbitrary struct of which the first field is - * a pointer to an AVClass struct - * @param[in] feature string containing the name of the missing feature - * @param[in] want_sample indicates if samples are wanted which exhibit this feature. - * If want_sample is non-zero, additional verbage will be added to the log - * message which tells the user how to report samples to the development - * mailing list. - */ -void av_log_missing_feature(void *avc, const char *feature, int want_sample); - -/** - * Log a generic warning message asking for a sample. This function is - * intended to be used internally by FFmpeg (libavcodec, libavformat, etc.) - * only, and would normally not be used by applications. - * @param[in] avc a pointer to an arbitrary struct of which the first field is - * a pointer to an AVClass struct - * @param[in] msg string containing an optional message, or NULL if no message - */ -void av_log_ask_for_sample(void *avc, const char *msg); - -/** - * Register the hardware accelerator hwaccel. - */ -void av_register_hwaccel(AVHWAccel *hwaccel); - -/** - * If hwaccel is NULL, returns the first registered hardware accelerator, - * if hwaccel is non-NULL, returns the next registered hardware accelerator - * after hwaccel, or NULL if hwaccel is the last one. - */ -AVHWAccel *av_hwaccel_next(AVHWAccel *hwaccel); - - -/** - * Lock operation used by lockmgr - */ -enum AVLockOp { - AV_LOCK_CREATE, ///< Create a mutex - AV_LOCK_OBTAIN, ///< Lock the mutex - AV_LOCK_RELEASE, ///< Unlock the mutex - AV_LOCK_DESTROY, ///< Free mutex resources -}; - -/** - * Register a user provided lock manager supporting the operations - * specified by AVLockOp. mutex points to a (void *) where the - * lockmgr should store/get a pointer to a user allocated mutex. It's - * NULL upon AV_LOCK_CREATE and != NULL for all other ops. - * - * @param cb User defined callback. Note: FFmpeg may invoke calls to this - * callback during the call to av_lockmgr_register(). - * Thus, the application must be prepared to handle that. - * If cb is set to NULL the lockmgr will be unregistered. - * Also note that during unregistration the previously registered - * lockmgr callback may also be invoked. - */ -int av_lockmgr_register(int (*cb)(void **mutex, enum AVLockOp op)); - -#endif /* AVCODEC_AVCODEC_H */ diff --git a/apps/codecs/libwmavoice/avfft.c b/apps/codecs/libwmavoice/avfft.c deleted file mode 100644 index 7d5d08390f..0000000000 --- a/apps/codecs/libwmavoice/avfft.c +++ /dev/null @@ -1,142 +0,0 @@ -/* - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "libavutil/mem.h" -#include "avfft.h" -#include "fft.h" - -/* FFT */ - -FFTContext *av_fft_init(int nbits, int inverse) -{ - FFTContext *s = av_malloc(sizeof(*s)); - - if (s && ff_fft_init(s, nbits, inverse)) - av_freep(&s); - - return s; -} - -void av_fft_permute(FFTContext *s, FFTComplex *z) -{ - s->fft_permute(s, z); -} - -void av_fft_calc(FFTContext *s, FFTComplex *z) -{ - s->fft_calc(s, z); -} - -void av_fft_end(FFTContext *s) -{ - if (s) { - ff_fft_end(s); - av_free(s); - } -} - -#if CONFIG_MDCT - -FFTContext *av_mdct_init(int nbits, int inverse, double scale) -{ - FFTContext *s = av_malloc(sizeof(*s)); - - if (s && ff_mdct_init(s, nbits, inverse, scale)) - av_freep(&s); - - return s; -} - -void av_imdct_calc(FFTContext *s, FFTSample *output, const FFTSample *input) -{ - s->imdct_calc(s, output, input); -} - -void av_imdct_half(FFTContext *s, FFTSample *output, const FFTSample *input) -{ - s->imdct_half(s, output, input); -} - -void av_mdct_calc(FFTContext *s, FFTSample *output, const FFTSample *input) -{ - s->mdct_calc(s, output, input); -} - -void av_mdct_end(FFTContext *s) -{ - if (s) { - ff_mdct_end(s); - av_free(s); - } -} - -#endif /* CONFIG_MDCT */ - -#if CONFIG_RDFT - -RDFTContext *av_rdft_init(int nbits, enum RDFTransformType trans) -{ - RDFTContext *s = av_malloc(sizeof(*s)); - - if (s && ff_rdft_init(s, nbits, trans)) - av_freep(&s); - - return s; -} - -void av_rdft_calc(RDFTContext *s, FFTSample *data) -{ - ff_rdft_calc(s, data); -} - -void av_rdft_end(RDFTContext *s) -{ - if (s) { - ff_rdft_end(s); - av_free(s); - } -} - -#endif /* CONFIG_RDFT */ - -#if CONFIG_DCT - -DCTContext *av_dct_init(int nbits, enum DCTTransformType inverse) -{ - DCTContext *s = av_malloc(sizeof(*s)); - - if (s && ff_dct_init(s, nbits, inverse)) - av_freep(&s); - - return s; -} - -void av_dct_calc(DCTContext *s, FFTSample *data) -{ - ff_dct_calc(s, data); -} - -void av_dct_end(DCTContext *s) -{ - if (s) { - ff_dct_end(s); - av_free(s); - } -} - -#endif /* CONFIG_DCT */ diff --git a/apps/codecs/libwmavoice/avfft.h b/apps/codecs/libwmavoice/avfft.h deleted file mode 100644 index be2d9c7e10..0000000000 --- a/apps/codecs/libwmavoice/avfft.h +++ /dev/null @@ -1,99 +0,0 @@ -/* - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef AVCODEC_AVFFT_H -#define AVCODEC_AVFFT_H - -typedef float FFTSample; - -typedef struct FFTComplex { - FFTSample re, im; -} FFTComplex; - -typedef struct FFTContext FFTContext; - -/** - * Set up a complex FFT. - * @param nbits log2 of the length of the input array - * @param inverse if 0 perform the forward transform, if 1 perform the inverse - */ -FFTContext *av_fft_init(int nbits, int inverse); - -/** - * Do the permutation needed BEFORE calling ff_fft_calc(). - */ -void av_fft_permute(FFTContext *s, FFTComplex *z); - -/** - * Do a complex FFT with the parameters defined in av_fft_init(). The - * input data must be permuted before. No 1.0/sqrt(n) normalization is done. - */ -void av_fft_calc(FFTContext *s, FFTComplex *z); - -void av_fft_end(FFTContext *s); - -FFTContext *av_mdct_init(int nbits, int inverse, double scale); -void av_imdct_calc(FFTContext *s, FFTSample *output, const FFTSample *input); -void av_imdct_half(FFTContext *s, FFTSample *output, const FFTSample *input); -void av_mdct_calc(FFTContext *s, FFTSample *output, const FFTSample *input); -void av_mdct_end(FFTContext *s); - -/* Real Discrete Fourier Transform */ - -enum RDFTransformType { - DFT_R2C, - IDFT_C2R, - IDFT_R2C, - DFT_C2R, -}; - -typedef struct RDFTContext RDFTContext; - -/** - * Set up a real FFT. - * @param nbits log2 of the length of the input array - * @param trans the type of transform - */ -RDFTContext *av_rdft_init(int nbits, enum RDFTransformType trans); -void av_rdft_calc(RDFTContext *s, FFTSample *data); -void av_rdft_end(RDFTContext *s); - -/* Discrete Cosine Transform */ - -typedef struct DCTContext DCTContext; - -enum DCTTransformType { - DCT_II = 0, - DCT_III, - DCT_I, - DST_I, -}; - -/** - * Set up DCT. - * @param nbits size of the input array: - * (1 << nbits) for DCT-II, DCT-III and DST-I - * (1 << nbits) + 1 for DCT-I - * - * @note the first element of the input of DST-I is ignored - */ -DCTContext *av_dct_init(int nbits, enum DCTTransformType type); -void av_dct_calc(DCTContext *s, FFTSample *data); -void av_dct_end (DCTContext *s); - -#endif /* AVCODEC_AVFFT_H */ diff --git a/apps/codecs/libwmavoice/bitstream.c b/apps/codecs/libwmavoice/bitstream.c deleted file mode 100644 index d408f66650..0000000000 --- a/apps/codecs/libwmavoice/bitstream.c +++ /dev/null @@ -1,341 +0,0 @@ -/* - * Common bit i/o utils - * Copyright (c) 2000, 2001 Fabrice Bellard - * Copyright (c) 2002-2004 Michael Niedermayer - * Copyright (c) 2010 Loren Merritt - * - * alternative bitstream reader & writer by Michael Niedermayer - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/** - * @file - * bitstream api. - */ - -#include "avcodec.h" -#include "get_bits.h" -#include "put_bits.h" - -const uint8_t ff_log2_run[32]={ - 0, 0, 0, 0, 1, 1, 1, 1, - 2, 2, 2, 2, 3, 3, 3, 3, - 4, 4, 5, 5, 6, 6, 7, 7, - 8, 9,10,11,12,13,14,15 -}; - -void align_put_bits(PutBitContext *s) -{ -#ifdef ALT_BITSTREAM_WRITER - put_bits(s,( - s->index) & 7,0); -#else - put_bits(s,s->bit_left & 7,0); -#endif -} - -void ff_put_string(PutBitContext *pb, const char *string, int terminate_string) -{ - while(*string){ - put_bits(pb, 8, *string); - string++; - } - if(terminate_string) - put_bits(pb, 8, 0); -} - -void ff_copy_bits(PutBitContext *pb, const uint8_t *src, int length) -{ - int words= length>>4; - int bits= length&15; - int i; - - if(length==0) return; - - if(/*CONFIG_SMALL ||*/ words < 16 || put_bits_count(pb)&7){ - for(i=0; i>(16-bits)); -} - -/* VLC decoding */ - -//#define DEBUG_VLC - -#define GET_DATA(v, table, i, wrap, size) \ -{\ - const uint8_t *ptr = (const uint8_t *)table + i * wrap;\ - switch(size) {\ - case 1:\ - v = *(const uint8_t *)ptr;\ - break;\ - case 2:\ - v = *(const uint16_t *)ptr;\ - break;\ - default:\ - v = *(const uint32_t *)ptr;\ - break;\ - }\ -} - - -static int alloc_table(VLC *vlc, int size, int use_static) -{ - int index; - index = vlc->table_size; - vlc->table_size += size; - if (vlc->table_size > vlc->table_allocated) { - if(use_static) - abort(); //cant do anything, init_vlc() is used with too little memory - vlc->table_allocated += (1 << vlc->bits); - vlc->table = av_realloc(vlc->table, - sizeof(VLC_TYPE) * 2 * vlc->table_allocated); - if (!vlc->table) - return -1; - } - return index; -} - -static av_always_inline uint32_t bitswap_32(uint32_t x) { - return av_reverse[x&0xFF]<<24 - | av_reverse[(x>>8)&0xFF]<<16 - | av_reverse[(x>>16)&0xFF]<<8 - | av_reverse[x>>24]; -} - -typedef struct { - uint8_t bits; - uint16_t symbol; - /** codeword, with the first bit-to-be-read in the msb - * (even if intended for a little-endian bitstream reader) */ - uint32_t code; -} VLCcode; - -static int compare_vlcspec(const void *a, const void *b) -{ - const VLCcode *sa=a, *sb=b; - return (sa->code >> 1) - (sb->code >> 1); -} - -/** - * Build VLC decoding tables suitable for use with get_vlc(). - * - * @param vlc the context to be initted - * - * @param table_nb_bits max length of vlc codes to store directly in this table - * (Longer codes are delegated to subtables.) - * - * @param nb_codes number of elements in codes[] - * - * @param codes descriptions of the vlc codes - * These must be ordered such that codes going into the same subtable are contiguous. - * Sorting by VLCcode.code is sufficient, though not necessary. - */ -static int build_table(VLC *vlc, int table_nb_bits, int nb_codes, - VLCcode *codes, int flags) -{ - int table_size, table_index, index, code_prefix, symbol, subtable_bits; - int i, j, k, n, nb, inc; - uint32_t code; - VLC_TYPE (*table)[2]; - - table_size = 1 << table_nb_bits; - table_index = alloc_table(vlc, table_size, flags & INIT_VLC_USE_NEW_STATIC); -#ifdef DEBUG_VLC - av_log(NULL,AV_LOG_DEBUG,"new table index=%d size=%d\n", - table_index, table_size); -#endif - if (table_index < 0) - return -1; - table = &vlc->table[table_index]; - - for (i = 0; i < table_size; i++) { - table[i][1] = 0; //bits - table[i][0] = -1; //codes - } - - /* first pass: map codes and compute auxillary table sizes */ - for (i = 0; i < nb_codes; i++) { - n = codes[i].bits; - code = codes[i].code; - symbol = codes[i].symbol; -#if defined(DEBUG_VLC) && 0 - av_log(NULL,AV_LOG_DEBUG,"i=%d n=%d code=0x%x\n", i, n, code); -#endif - if (n <= table_nb_bits) { - /* no need to add another table */ - j = code >> (32 - table_nb_bits); - nb = 1 << (table_nb_bits - n); - inc = 1; - if (flags & INIT_VLC_LE) { - j = bitswap_32(code); - inc = 1 << n; - } - for (k = 0; k < nb; k++) { -#ifdef DEBUG_VLC - av_log(NULL, AV_LOG_DEBUG, "%4x: code=%d n=%d\n", - j, i, n); -#endif - if (table[j][1] /*bits*/ != 0) { - av_log(NULL, AV_LOG_ERROR, "incorrect codes\n"); - return -1; - } - table[j][1] = n; //bits - table[j][0] = symbol; - j += inc; - } - } else { - /* fill auxiliary table recursively */ - n -= table_nb_bits; - code_prefix = code >> (32 - table_nb_bits); - subtable_bits = n; - codes[i].bits = n; - codes[i].code = code << table_nb_bits; - for (k = i+1; k < nb_codes; k++) { - n = codes[k].bits - table_nb_bits; - if (n <= 0) - break; - code = codes[k].code; - if (code >> (32 - table_nb_bits) != code_prefix) - break; - codes[k].bits = n; - codes[k].code = code << table_nb_bits; - subtable_bits = FFMAX(subtable_bits, n); - } - subtable_bits = FFMIN(subtable_bits, table_nb_bits); - j = (flags & INIT_VLC_LE) ? bitswap_32(code_prefix) >> (32 - table_nb_bits) : code_prefix; - table[j][1] = -subtable_bits; -#ifdef DEBUG_VLC - av_log(NULL,AV_LOG_DEBUG,"%4x: n=%d (subtable)\n", - j, codes[i].bits + table_nb_bits); -#endif - index = build_table(vlc, subtable_bits, k-i, codes+i, flags); - if (index < 0) - return -1; - /* note: realloc has been done, so reload tables */ - table = &vlc->table[table_index]; - table[j][0] = index; //code - i = k-1; - } - } - return table_index; -} - - -/* Build VLC decoding tables suitable for use with get_vlc(). - - 'nb_bits' set thee decoding table size (2^nb_bits) entries. The - bigger it is, the faster is the decoding. But it should not be too - big to save memory and L1 cache. '9' is a good compromise. - - 'nb_codes' : number of vlcs codes - - 'bits' : table which gives the size (in bits) of each vlc code. - - 'codes' : table which gives the bit pattern of of each vlc code. - - 'symbols' : table which gives the values to be returned from get_vlc(). - - 'xxx_wrap' : give the number of bytes between each entry of the - 'bits' or 'codes' tables. - - 'xxx_size' : gives the number of bytes of each entry of the 'bits' - or 'codes' tables. - - 'wrap' and 'size' allows to use any memory configuration and types - (byte/word/long) to store the 'bits', 'codes', and 'symbols' tables. - - 'use_static' should be set to 1 for tables, which should be freed - with av_free_static(), 0 if free_vlc() will be used. -*/ -int init_vlc_sparse(VLC *vlc, int nb_bits, int nb_codes, - const void *bits, int bits_wrap, int bits_size, - const void *codes, int codes_wrap, int codes_size, - const void *symbols, int symbols_wrap, int symbols_size, - int flags) -{ - VLCcode *buf; - int i, j, ret; - - vlc->bits = nb_bits; - if(flags & INIT_VLC_USE_NEW_STATIC){ - if(vlc->table_size && vlc->table_size == vlc->table_allocated){ - return 0; - }else if(vlc->table_size){ - abort(); // fatal error, we are called on a partially initialized table - } - }else { - vlc->table = NULL; - vlc->table_allocated = 0; - vlc->table_size = 0; - } - -#ifdef DEBUG_VLC - av_log(NULL,AV_LOG_DEBUG,"build table nb_codes=%d\n", nb_codes); -#endif - - buf = av_malloc((nb_codes+1)*sizeof(VLCcode)); - - assert(symbols_size <= 2 || !symbols); - j = 0; -#define COPY(condition)\ - for (i = 0; i < nb_codes; i++) {\ - GET_DATA(buf[j].bits, bits, i, bits_wrap, bits_size);\ - if (!(condition))\ - continue;\ - GET_DATA(buf[j].code, codes, i, codes_wrap, codes_size);\ - if (flags & INIT_VLC_LE)\ - buf[j].code = bitswap_32(buf[j].code);\ - else\ - buf[j].code <<= 32 - buf[j].bits;\ - if (symbols)\ - GET_DATA(buf[j].symbol, symbols, i, symbols_wrap, symbols_size)\ - else\ - buf[j].symbol = i;\ - j++;\ - } - COPY(buf[j].bits > nb_bits); - // qsort is the slowest part of init_vlc, and could probably be improved or avoided - qsort(buf, j, sizeof(VLCcode), compare_vlcspec); - COPY(buf[j].bits && buf[j].bits <= nb_bits); - nb_codes = j; - - ret = build_table(vlc, nb_bits, nb_codes, buf, flags); - - av_free(buf); - if (ret < 0) { - av_freep(&vlc->table); - return -1; - } - if((flags & INIT_VLC_USE_NEW_STATIC) && vlc->table_size != vlc->table_allocated) - av_log(NULL, AV_LOG_ERROR, "needed %d had %d\n", vlc->table_size, vlc->table_allocated); - return 0; -} - - -void free_vlc(VLC *vlc) -{ - av_freep(&vlc->table); -} - diff --git a/apps/codecs/libwmavoice/celp_filters.c b/apps/codecs/libwmavoice/celp_filters.c deleted file mode 100644 index 26a62eed14..0000000000 --- a/apps/codecs/libwmavoice/celp_filters.c +++ /dev/null @@ -1,210 +0,0 @@ -/* - * various filters for ACELP-based codecs - * - * Copyright (c) 2008 Vladimir Voroshilov - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include - -#include "avcodec.h" -#include "celp_filters.h" - -void ff_celp_convolve_circ(int16_t* fc_out, const int16_t* fc_in, - const int16_t* filter, int len) -{ - int i, k; - - memset(fc_out, 0, len * sizeof(int16_t)); - - /* Since there are few pulses over an entire subframe (i.e. almost - all fc_in[i] are zero) it is faster to loop over fc_in first. */ - for (i = 0; i < len; i++) { - if (fc_in[i]) { - for (k = 0; k < i; k++) - fc_out[k] += (fc_in[i] * filter[len + k - i]) >> 15; - - for (k = i; k < len; k++) - fc_out[k] += (fc_in[i] * filter[ k - i]) >> 15; - } - } -} - -void ff_celp_circ_addf(float *out, const float *in, - const float *lagged, int lag, float fac, int n) -{ - int k; - for (k = 0; k < lag; k++) - out[k] = in[k] + fac * lagged[n + k - lag]; - for (; k < n; k++) - out[k] = in[k] + fac * lagged[ k - lag]; -} - -int ff_celp_lp_synthesis_filter(int16_t *out, const int16_t *filter_coeffs, - const int16_t *in, int buffer_length, - int filter_length, int stop_on_overflow, - int rounder) -{ - int i,n; - - for (n = 0; n < buffer_length; n++) { - int sum = rounder; - for (i = 1; i <= filter_length; i++) - sum -= filter_coeffs[i-1] * out[n-i]; - - sum = (sum >> 12) + in[n]; - - if (sum + 0x8000 > 0xFFFFU) { - if (stop_on_overflow) - return 1; - sum = (sum >> 31) ^ 32767; - } - out[n] = sum; - } - - return 0; -} - -void ff_celp_lp_synthesis_filterf(float *out, const float *filter_coeffs, - const float* in, int buffer_length, - int filter_length) -{ - int i,n; - -#if 0 // Unoptimized code path for improved readability - for (n = 0; n < buffer_length; n++) { - out[n] = in[n]; - for (i = 1; i <= filter_length; i++) - out[n] -= filter_coeffs[i-1] * out[n-i]; - } -#else - float out0, out1, out2, out3; - float old_out0, old_out1, old_out2, old_out3; - float a,b,c; - - a = filter_coeffs[0]; - b = filter_coeffs[1]; - c = filter_coeffs[2]; - b -= filter_coeffs[0] * filter_coeffs[0]; - c -= filter_coeffs[1] * filter_coeffs[0]; - c -= filter_coeffs[0] * b; - - old_out0 = out[-4]; - old_out1 = out[-3]; - old_out2 = out[-2]; - old_out3 = out[-1]; - for (n = 0; n <= buffer_length - 4; n+=4) { - float tmp0,tmp1,tmp2,tmp3; - float val; - - out0 = in[0]; - out1 = in[1]; - out2 = in[2]; - out3 = in[3]; - - out0 -= filter_coeffs[2] * old_out1; - out1 -= filter_coeffs[2] * old_out2; - out2 -= filter_coeffs[2] * old_out3; - - out0 -= filter_coeffs[1] * old_out2; - out1 -= filter_coeffs[1] * old_out3; - - out0 -= filter_coeffs[0] * old_out3; - - val = filter_coeffs[3]; - - out0 -= val * old_out0; - out1 -= val * old_out1; - out2 -= val * old_out2; - out3 -= val * old_out3; - - old_out3 = out[-5]; - - for (i = 5; i <= filter_length; i += 2) { - val = filter_coeffs[i-1]; - - out0 -= val * old_out3; - out1 -= val * old_out0; - out2 -= val * old_out1; - out3 -= val * old_out2; - - old_out2 = out[-i-1]; - - val = filter_coeffs[i]; - - out0 -= val * old_out2; - out1 -= val * old_out3; - out2 -= val * old_out0; - out3 -= val * old_out1; - - FFSWAP(float, old_out0, old_out2); - old_out1 = old_out3; - old_out3 = out[-i-2]; - } - - tmp0 = out0; - tmp1 = out1; - tmp2 = out2; - tmp3 = out3; - - out3 -= a * tmp2; - out2 -= a * tmp1; - out1 -= a * tmp0; - - out3 -= b * tmp1; - out2 -= b * tmp0; - - out3 -= c * tmp0; - - - out[0] = out0; - out[1] = out1; - out[2] = out2; - out[3] = out3; - - old_out0 = out0; - old_out1 = out1; - old_out2 = out2; - old_out3 = out3; - - out += 4; - in += 4; - } - - out -= n; - in -= n; - for (; n < buffer_length; n++) { - out[n] = in[n]; - for (i = 1; i <= filter_length; i++) - out[n] -= filter_coeffs[i-1] * out[n-i]; - } -#endif -} - -void ff_celp_lp_zero_synthesis_filterf(float *out, const float *filter_coeffs, - const float *in, int buffer_length, - int filter_length) -{ - int i,n; - - for (n = 0; n < buffer_length; n++) { - out[n] = in[n]; - for (i = 1; i <= filter_length; i++) - out[n] += filter_coeffs[i-1] * in[n-i]; - } -} diff --git a/apps/codecs/libwmavoice/celp_filters.h b/apps/codecs/libwmavoice/celp_filters.h deleted file mode 100644 index 145e3d3346..0000000000 --- a/apps/codecs/libwmavoice/celp_filters.h +++ /dev/null @@ -1,119 +0,0 @@ -/* - * various filters for CELP-based codecs - * - * Copyright (c) 2008 Vladimir Voroshilov - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef AVCODEC_CELP_FILTERS_H -#define AVCODEC_CELP_FILTERS_H - -#include - -/** - * Circularly convolve fixed vector with a phase dispersion impulse - * response filter (D.6.2 of G.729 and 6.1.5 of AMR). - * @param fc_out vector with filter applied - * @param fc_in source vector - * @param filter phase filter coefficients - * - * fc_out[n] = sum(i,0,len-1){ fc_in[i] * filter[(len + n - i)%len] } - * - * \note fc_in and fc_out should not overlap! - */ -void ff_celp_convolve_circ(int16_t *fc_out, const int16_t *fc_in, - const int16_t *filter, int len); - -/** - * Add an array to a rotated array. - * - * out[k] = in[k] + fac * lagged[k-lag] with wrap-around - * - * @param out result vector - * @param in samples to be added unfiltered - * @param lagged samples to be rotated, multiplied and added - * @param lag lagged vector delay in the range [0, n] - * @param fac scalefactor for lagged samples - * @param n number of samples - */ -void ff_celp_circ_addf(float *out, const float *in, - const float *lagged, int lag, float fac, int n); - -/** - * LP synthesis filter. - * @param[out] out pointer to output buffer - * @param filter_coeffs filter coefficients (-0x8000 <= (3.12) < 0x8000) - * @param in input signal - * @param buffer_length amount of data to process - * @param filter_length filter length (10 for 10th order LP filter) - * @param stop_on_overflow 1 - return immediately if overflow occurs - * 0 - ignore overflows - * @param rounder the amount to add for rounding (usually 0x800 or 0xfff) - * - * @return 1 if overflow occurred, 0 - otherwise - * - * @note Output buffer must contain filter_length samples of past - * speech data before pointer. - * - * Routine applies 1/A(z) filter to given speech data. - */ -int ff_celp_lp_synthesis_filter(int16_t *out, const int16_t *filter_coeffs, - const int16_t *in, int buffer_length, - int filter_length, int stop_on_overflow, - int rounder); - -/** - * LP synthesis filter. - * @param[out] out pointer to output buffer - * - the array out[-filter_length, -1] must - * contain the previous result of this filter - * @param filter_coeffs filter coefficients. - * @param in input signal - * @param buffer_length amount of data to process - * @param filter_length filter length (10 for 10th order LP filter). Must be - * greater than 4 and even. - * - * @note Output buffer must contain filter_length samples of past - * speech data before pointer. - * - * Routine applies 1/A(z) filter to given speech data. - */ -void ff_celp_lp_synthesis_filterf(float *out, const float *filter_coeffs, - const float *in, int buffer_length, - int filter_length); - -/** - * LP zero synthesis filter. - * @param[out] out pointer to output buffer - * @param filter_coeffs filter coefficients. - * @param in input signal - * - the array in[-filter_length, -1] must - * contain the previous input of this filter - * @param buffer_length amount of data to process - * @param filter_length filter length (10 for 10th order LP filter) - * - * @note Output buffer must contain filter_length samples of past - * speech data before pointer. - * - * Routine applies A(z) filter to given speech data. - */ -void ff_celp_lp_zero_synthesis_filterf(float *out, const float *filter_coeffs, - const float *in, int buffer_length, - int filter_length); - -#endif /* AVCODEC_CELP_FILTERS_H */ diff --git a/apps/codecs/libwmavoice/celp_math.c b/apps/codecs/libwmavoice/celp_math.c deleted file mode 100644 index 09111da819..0000000000 --- a/apps/codecs/libwmavoice/celp_math.c +++ /dev/null @@ -1,208 +0,0 @@ -/* - * Various fixed-point math operations - * - * Copyright (c) 2008 Vladimir Voroshilov - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include -#include -#include - -#include "avcodec.h" -#include "celp_math.h" - -#ifdef G729_BITEXACT -/** - * Cosine table: base_cos[i] = (1<<15) * cos(i*PI/64) - */ -static const int16_t base_cos[64] = -{ - 32767, 32729, 32610, 32413, 32138, 31786, 31357, 30853, - 30274, 29622, 28899, 28106, 27246, 26320, 25330, 24279, - 23170, 22006, 20788, 19520, 18205, 16846, 15447, 14010, - 12540, 11039, 9512, 7962, 6393, 4808, 3212, 1608, - 0, -1608, -3212, -4808, -6393, -7962, -9512, -11039, - -12540, -14010, -15447, -16846, -18205, -19520, -20788, -22006, - -23170, -24279, -25330, -26320, -27246, -28106, -28899, -29622, - -30274, -30853, -31357, -31786, -32138, -32413, -32610, -32729 -}; - -/** - * Slope used to compute cos(x) - * - * cos(ind*64+offset) = base_cos[ind]+offset*slope_cos[ind] - * values multiplied by 1<<19 - */ -static const int16_t slope_cos[64] = -{ - -632, -1893, -3150, -4399, -5638, -6863, -8072, -9261, - -10428, -11570, -12684, -13767, -14817, -15832, -16808, -17744, - -18637, -19486, -20287, -21039, -21741, -22390, -22986, -23526, - -24009, -24435, -24801, -25108, -25354, -25540, -25664, -25726, - -25726, -25664, -25540, -25354, -25108, -24801, -24435, -24009, - -23526, -22986, -22390, -21741, -21039, -20287, -19486, -18637, - -17744, -16808, -15832, -14817, -13767, -12684, -11570, -10428, - -9261, -8072, -6863, -5638, -4399, -3150, -1893, -632 -}; - -/** - * Table used to compute exp2(x) - * - * tab_exp2[i] = (1<<14) * exp2(i/32) = 2^(i/32) i=0..32 - */ -static const uint16_t tab_exp2[33] = -{ - 16384, 16743, 17109, 17484, 17867, 18258, 18658, 19066, 19484, 19911, - 20347, 20792, 21247, 21713, 22188, 22674, 23170, 23678, 24196, 24726, - 25268, 25821, 26386, 26964, 27554, 28158, 28774, 29405, 30048, 30706, - 31379, 32066, 32767 -}; - -int16_t ff_cos(uint16_t arg) -{ - uint8_t offset= arg; - uint8_t ind = arg >> 8; - - assert(arg < 0x4000); - - return FFMAX(base_cos[ind] + ((slope_cos[ind] * offset) >> 12), -0x8000); -} - -int ff_exp2(uint16_t power) -{ - uint16_t frac_x0; - uint16_t frac_dx; - int result; - - assert(power <= 0x7fff); - - frac_x0 = power >> 10; - frac_dx = (power & 0x03ff) << 5; - - result = tab_exp2[frac_x0] << 15; - result += frac_dx * (tab_exp2[frac_x0+1] - tab_exp2[frac_x0]); - - return result >> 10; -} - -#else // G729_BITEXACT - -/** - * Cosine table: base_cos[i] = (1<<15) * cos(i*PI/64) - */ -static const int16_t tab_cos[65] = -{ - 32767, 32738, 32617, 32421, 32145, 31793, 31364, 30860, - 30280, 29629, 28905, 28113, 27252, 26326, 25336, 24285, - 23176, 22011, 20793, 19525, 18210, 16851, 15451, 14014, - 12543, 11043, 9515, 7965, 6395, 4810, 3214, 1609, - 1, -1607, -3211, -4808, -6393, -7962, -9513, -11040, - -12541, -14012, -15449, -16848, -18207, -19523, -20791, -22009, - -23174, -24283, -25334, -26324, -27250, -28111, -28904, -29627, - -30279, -30858, -31363, -31792, -32144, -32419, -32616, -32736, -32768, -}; - -static const uint16_t exp2a[]= -{ - 0, 1435, 2901, 4400, 5931, 7496, 9096, 10730, - 12400, 14106, 15850, 17632, 19454, 21315, 23216, 25160, - 27146, 29175, 31249, 33368, 35534, 37747, 40009, 42320, - 44682, 47095, 49562, 52082, 54657, 57289, 59979, 62727, -}; - -static const uint16_t exp2b[]= -{ - 3, 712, 1424, 2134, 2845, 3557, 4270, 4982, - 5696, 6409, 7124, 7839, 8554, 9270, 9986, 10704, - 11421, 12138, 12857, 13576, 14295, 15014, 15734, 16455, - 17176, 17898, 18620, 19343, 20066, 20790, 21514, 22238, -}; - -int16_t ff_cos(uint16_t arg) -{ - uint8_t offset= arg; - uint8_t ind = arg >> 8; - - assert(arg <= 0x3fff); - - return tab_cos[ind] + (offset * (tab_cos[ind+1] - tab_cos[ind]) >> 8); -} - -int ff_exp2(uint16_t power) -{ - unsigned int result= exp2a[power>>10] + 0x10000; - - assert(power <= 0x7fff); - - result= (result<<3) + ((result*exp2b[(power>>5)&31])>>17); - return result + ((result*(power&31)*89)>>22); -} - -#endif // else G729_BITEXACT - -/** - * Table used to compute log2(x) - * - * tab_log2[i] = (1<<15) * log2(1 + i/32), i=0..32 - */ -static const uint16_t tab_log2[33] = -{ -#ifdef G729_BITEXACT - 0, 1455, 2866, 4236, 5568, 6863, 8124, 9352, - 10549, 11716, 12855, 13967, 15054, 16117, 17156, 18172, - 19167, 20142, 21097, 22033, 22951, 23852, 24735, 25603, - 26455, 27291, 28113, 28922, 29716, 30497, 31266, 32023, 32767, -#else - 4, 1459, 2870, 4240, 5572, 6867, 8127, 9355, - 10552, 11719, 12858, 13971, 15057, 16120, 17158, 18175, - 19170, 20145, 21100, 22036, 22954, 23854, 24738, 25605, - 26457, 27294, 28116, 28924, 29719, 30500, 31269, 32025, 32769, -#endif -}; - -int ff_log2(uint32_t value) -{ - uint8_t power_int; - uint8_t frac_x0; - uint16_t frac_dx; - - // Stripping zeros from beginning - power_int = av_log2(value); - value <<= (31 - power_int); - - // b31 is always non-zero now - frac_x0 = (value & 0x7c000000) >> 26; // b26-b31 and [32..63] -> [0..31] - frac_dx = (value & 0x03fff800) >> 11; - - value = tab_log2[frac_x0]; - value += (frac_dx * (tab_log2[frac_x0+1] - tab_log2[frac_x0])) >> 15; - - return (power_int << 15) + value; -} - -float ff_dot_productf(const float* a, const float* b, int length) -{ - float sum = 0; - int i; - - for(i=0; i - -/** - * fixed-point implementation of cosine in [0; PI) domain. - * @param arg fixed-point cosine argument, 0 <= arg < 0x4000 - * - * @return value of (1<<15) * cos(arg * PI / (1<<14)), -0x8000 <= result <= 0x7fff - */ -int16_t ff_cos(uint16_t arg); - -/** - * fixed-point implementation of exp2(x) in [0; 1] domain. - * @param power argument to exp2, 0 <= power <= 0x7fff - * - * @return value of (1<<20) * exp2(power / (1<<15)) - * 0x8000c <= result <= 0xfffea - */ -int ff_exp2(uint16_t power); - -/** - * Calculate log2(x). - * @param value function argument, 0 < value <= 7fff ffff - * - * @return value of (1<<15) * log2(value) - */ -int ff_log2(uint32_t value); - -/** - * Shift value left or right depending on sign of offset parameter. - * @param value value to shift - * @param offset shift offset - * - * @return value << offset, if offset>=0; value >> -offset - otherwise - */ -static inline int bidir_sal(int value, int offset) -{ - if(offset < 0) return value >> -offset; - else return value << offset; -} - -/** - * returns the dot product. - * @param a input data array - * @param b input data array - * @param length number of elements - * - * @return dot product = sum of elementwise products - */ -float ff_dot_productf(const float* a, const float* b, int length); - -#endif /* AVCODEC_CELP_MATH_H */ diff --git a/apps/codecs/libwmavoice/dct.c b/apps/codecs/libwmavoice/dct.c deleted file mode 100644 index 95aef5af6c..0000000000 --- a/apps/codecs/libwmavoice/dct.c +++ /dev/null @@ -1,226 +0,0 @@ -/* - * (I)DCT Transforms - * Copyright (c) 2009 Peter Ross - * Copyright (c) 2010 Alex Converse - * Copyright (c) 2010 Vitor Sessak - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/** - * @file - * (Inverse) Discrete Cosine Transforms. These are also known as the - * type II and type III DCTs respectively. - */ - -#include -#include "libavutil/mathematics.h" -#include "fft.h" -//#include "x86/fft.h" - -#define DCT32_FLOAT -#include "dct32.c" - -/* sin((M_PI * x / (2*n)) */ -#define SIN(s,n,x) (s->costab[(n) - (x)]) - -/* cos((M_PI * x / (2*n)) */ -#define COS(s,n,x) (s->costab[x]) - -static void ff_dst_calc_I_c(DCTContext *ctx, FFTSample *data) -{ - int n = 1 << ctx->nbits; - int i; - - data[0] = 0; - for(i = 1; i < n/2; i++) { - float tmp1 = data[i ]; - float tmp2 = data[n - i]; - float s = SIN(ctx, n, 2*i); - - s *= tmp1 + tmp2; - tmp1 = (tmp1 - tmp2) * 0.5f; - data[i ] = s + tmp1; - data[n - i] = s - tmp1; - } - - data[n/2] *= 2; - ff_rdft_calc(&ctx->rdft, data); - - data[0] *= 0.5f; - - for(i = 1; i < n-2; i += 2) { - data[i + 1] += data[i - 1]; - data[i ] = -data[i + 2]; - } - - data[n-1] = 0; -} - -static void ff_dct_calc_I_c(DCTContext *ctx, FFTSample *data) -{ - int n = 1 << ctx->nbits; - int i; - float next = -0.5f * (data[0] - data[n]); - - for(i = 0; i < n/2; i++) { - float tmp1 = data[i ]; - float tmp2 = data[n - i]; - float s = SIN(ctx, n, 2*i); - float c = COS(ctx, n, 2*i); - - c *= tmp1 - tmp2; - s *= tmp1 - tmp2; - - next += c; - - tmp1 = (tmp1 + tmp2) * 0.5f; - data[i ] = tmp1 - s; - data[n - i] = tmp1 + s; - } - - ff_rdft_calc(&ctx->rdft, data); - data[n] = data[1]; - data[1] = next; - - for(i = 3; i <= n; i += 2) - data[i] = data[i - 2] - data[i]; -} - -static void ff_dct_calc_III_c(DCTContext *ctx, FFTSample *data) -{ - int n = 1 << ctx->nbits; - int i; - - float next = data[n - 1]; - float inv_n = 1.0f / n; - - for (i = n - 2; i >= 2; i -= 2) { - float val1 = data[i ]; - float val2 = data[i - 1] - data[i + 1]; - float c = COS(ctx, n, i); - float s = SIN(ctx, n, i); - - data[i ] = c * val1 + s * val2; - data[i + 1] = s * val1 - c * val2; - } - - data[1] = 2 * next; - - ff_rdft_calc(&ctx->rdft, data); - - for (i = 0; i < n / 2; i++) { - float tmp1 = data[i ] * inv_n; - float tmp2 = data[n - i - 1] * inv_n; - float csc = ctx->csc2[i] * (tmp1 - tmp2); - - tmp1 += tmp2; - data[i ] = tmp1 + csc; - data[n - i - 1] = tmp1 - csc; - } -} - -static void ff_dct_calc_II_c(DCTContext *ctx, FFTSample *data) -{ - int n = 1 << ctx->nbits; - int i; - float next; - - for (i=0; i < n/2; i++) { - float tmp1 = data[i ]; - float tmp2 = data[n - i - 1]; - float s = SIN(ctx, n, 2*i + 1); - - s *= tmp1 - tmp2; - tmp1 = (tmp1 + tmp2) * 0.5f; - - data[i ] = tmp1 + s; - data[n-i-1] = tmp1 - s; - } - - ff_rdft_calc(&ctx->rdft, data); - - next = data[1] * 0.5; - data[1] *= -1; - - for (i = n - 2; i >= 0; i -= 2) { - float inr = data[i ]; - float ini = data[i + 1]; - float c = COS(ctx, n, i); - float s = SIN(ctx, n, i); - - data[i ] = c * inr + s * ini; - - data[i+1] = next; - - next += s * inr - c * ini; - } -} - -static void dct32_func(DCTContext *ctx, FFTSample *data) -{ - ctx->dct32(data, data); -} - -void ff_dct_calc(DCTContext *s, FFTSample *data) -{ - s->dct_calc(s, data); -} - -av_cold int ff_dct_init(DCTContext *s, int nbits, enum DCTTransformType inverse) -{ - int n = 1 << nbits; - int i; - - s->nbits = nbits; - s->inverse = inverse; - - ff_init_ff_cos_tabs(nbits+2); - - s->costab = ff_cos_tabs[nbits+2]; - - s->csc2 = av_malloc(n/2 * sizeof(FFTSample)); - - if (ff_rdft_init(&s->rdft, nbits, inverse == DCT_III) < 0) { - av_free(s->csc2); - return -1; - } - - for (i = 0; i < n/2; i++) - s->csc2[i] = 0.5 / sin((M_PI / (2*n) * (2*i + 1))); - - switch(inverse) { - case DCT_I : s->dct_calc = ff_dct_calc_I_c; break; - case DCT_II : s->dct_calc = ff_dct_calc_II_c ; break; - case DCT_III: s->dct_calc = ff_dct_calc_III_c; break; - case DST_I : s->dct_calc = ff_dst_calc_I_c; break; - } - - if (inverse == DCT_II && nbits == 5) - s->dct_calc = dct32_func; - - s->dct32 = dct32; - //if (HAVE_MMX) ff_dct_init_mmx(s); - - return 0; -} - -av_cold void ff_dct_end(DCTContext *s) -{ - ff_rdft_end(&s->rdft); - av_free(s->csc2); -} diff --git a/apps/codecs/libwmavoice/dct32.c b/apps/codecs/libwmavoice/dct32.c deleted file mode 100644 index 4e843ee832..0000000000 --- a/apps/codecs/libwmavoice/dct32.c +++ /dev/null @@ -1,267 +0,0 @@ -/* - * Template for the Discrete Cosine Transform for 32 samples - * Copyright (c) 2001, 2002 Fabrice Bellard - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifdef DCT32_FLOAT -# define FIXHR(x) ((float)(x)) -# define MULH3(x, y, s) ((s)*(y)*(x)) -# define INTFLOAT float -#endif - - -/* tab[i][j] = 1.0 / (2.0 * cos(pi*(2*k+1) / 2^(6 - j))) */ - -/* cos(i*pi/64) */ - -#define COS0_0 FIXHR(0.50060299823519630134/2) -#define COS0_1 FIXHR(0.50547095989754365998/2) -#define COS0_2 FIXHR(0.51544730992262454697/2) -#define COS0_3 FIXHR(0.53104259108978417447/2) -#define COS0_4 FIXHR(0.55310389603444452782/2) -#define COS0_5 FIXHR(0.58293496820613387367/2) -#define COS0_6 FIXHR(0.62250412303566481615/2) -#define COS0_7 FIXHR(0.67480834145500574602/2) -#define COS0_8 FIXHR(0.74453627100229844977/2) -#define COS0_9 FIXHR(0.83934964541552703873/2) -#define COS0_10 FIXHR(0.97256823786196069369/2) -#define COS0_11 FIXHR(1.16943993343288495515/4) -#define COS0_12 FIXHR(1.48416461631416627724/4) -#define COS0_13 FIXHR(2.05778100995341155085/8) -#define COS0_14 FIXHR(3.40760841846871878570/8) -#define COS0_15 FIXHR(10.19000812354805681150/32) - -#define COS1_0 FIXHR(0.50241928618815570551/2) -#define COS1_1 FIXHR(0.52249861493968888062/2) -#define COS1_2 FIXHR(0.56694403481635770368/2) -#define COS1_3 FIXHR(0.64682178335999012954/2) -#define COS1_4 FIXHR(0.78815462345125022473/2) -#define COS1_5 FIXHR(1.06067768599034747134/4) -#define COS1_6 FIXHR(1.72244709823833392782/4) -#define COS1_7 FIXHR(5.10114861868916385802/16) - -#define COS2_0 FIXHR(0.50979557910415916894/2) -#define COS2_1 FIXHR(0.60134488693504528054/2) -#define COS2_2 FIXHR(0.89997622313641570463/2) -#define COS2_3 FIXHR(2.56291544774150617881/8) - -#define COS3_0 FIXHR(0.54119610014619698439/2) -#define COS3_1 FIXHR(1.30656296487637652785/4) - -#define COS4_0 FIXHR(0.70710678118654752439/2) - -/* butterfly operator */ -#define BF(a, b, c, s)\ -{\ - tmp0 = val##a + val##b;\ - tmp1 = val##a - val##b;\ - val##a = tmp0;\ - val##b = MULH3(tmp1, c, 1<<(s));\ -} - -#define BF0(a, b, c, s)\ -{\ - tmp0 = tab[a] + tab[b];\ - tmp1 = tab[a] - tab[b];\ - val##a = tmp0;\ - val##b = MULH3(tmp1, c, 1<<(s));\ -} - -#define BF1(a, b, c, d)\ -{\ - BF(a, b, COS4_0, 1);\ - BF(c, d,-COS4_0, 1);\ - val##c += val##d;\ -} - -#define BF2(a, b, c, d)\ -{\ - BF(a, b, COS4_0, 1);\ - BF(c, d,-COS4_0, 1);\ - val##c += val##d;\ - val##a += val##c;\ - val##c += val##b;\ - val##b += val##d;\ -} - -#define ADD(a, b) val##a += val##b - -/* DCT32 without 1/sqrt(2) coef zero scaling. */ -static void dct32(INTFLOAT *out, const INTFLOAT *tab) -{ - INTFLOAT tmp0, tmp1; - - INTFLOAT val0 , val1 , val2 , val3 , val4 , val5 , val6 , val7 , - val8 , val9 , val10, val11, val12, val13, val14, val15, - val16, val17, val18, val19, val20, val21, val22, val23, - val24, val25, val26, val27, val28, val29, val30, val31; - - /* pass 1 */ - BF0( 0, 31, COS0_0 , 1); - BF0(15, 16, COS0_15, 5); - /* pass 2 */ - BF( 0, 15, COS1_0 , 1); - BF(16, 31,-COS1_0 , 1); - /* pass 1 */ - BF0( 7, 24, COS0_7 , 1); - BF0( 8, 23, COS0_8 , 1); - /* pass 2 */ - BF( 7, 8, COS1_7 , 4); - BF(23, 24,-COS1_7 , 4); - /* pass 3 */ - BF( 0, 7, COS2_0 , 1); - BF( 8, 15,-COS2_0 , 1); - BF(16, 23, COS2_0 , 1); - BF(24, 31,-COS2_0 , 1); - /* pass 1 */ - BF0( 3, 28, COS0_3 , 1); - BF0(12, 19, COS0_12, 2); - /* pass 2 */ - BF( 3, 12, COS1_3 , 1); - BF(19, 28,-COS1_3 , 1); - /* pass 1 */ - BF0( 4, 27, COS0_4 , 1); - BF0(11, 20, COS0_11, 2); - /* pass 2 */ - BF( 4, 11, COS1_4 , 1); - BF(20, 27,-COS1_4 , 1); - /* pass 3 */ - BF( 3, 4, COS2_3 , 3); - BF(11, 12,-COS2_3 , 3); - BF(19, 20, COS2_3 , 3); - BF(27, 28,-COS2_3 , 3); - /* pass 4 */ - BF( 0, 3, COS3_0 , 1); - BF( 4, 7,-COS3_0 , 1); - BF( 8, 11, COS3_0 , 1); - BF(12, 15,-COS3_0 , 1); - BF(16, 19, COS3_0 , 1); - BF(20, 23,-COS3_0 , 1); - BF(24, 27, COS3_0 , 1); - BF(28, 31,-COS3_0 , 1); - - - - /* pass 1 */ - BF0( 1, 30, COS0_1 , 1); - BF0(14, 17, COS0_14, 3); - /* pass 2 */ - BF( 1, 14, COS1_1 , 1); - BF(17, 30,-COS1_1 , 1); - /* pass 1 */ - BF0( 6, 25, COS0_6 , 1); - BF0( 9, 22, COS0_9 , 1); - /* pass 2 */ - BF( 6, 9, COS1_6 , 2); - BF(22, 25,-COS1_6 , 2); - /* pass 3 */ - BF( 1, 6, COS2_1 , 1); - BF( 9, 14,-COS2_1 , 1); - BF(17, 22, COS2_1 , 1); - BF(25, 30,-COS2_1 , 1); - - /* pass 1 */ - BF0( 2, 29, COS0_2 , 1); - BF0(13, 18, COS0_13, 3); - /* pass 2 */ - BF( 2, 13, COS1_2 , 1); - BF(18, 29,-COS1_2 , 1); - /* pass 1 */ - BF0( 5, 26, COS0_5 , 1); - BF0(10, 21, COS0_10, 1); - /* pass 2 */ - BF( 5, 10, COS1_5 , 2); - BF(21, 26,-COS1_5 , 2); - /* pass 3 */ - BF( 2, 5, COS2_2 , 1); - BF(10, 13,-COS2_2 , 1); - BF(18, 21, COS2_2 , 1); - BF(26, 29,-COS2_2 , 1); - /* pass 4 */ - BF( 1, 2, COS3_1 , 2); - BF( 5, 6,-COS3_1 , 2); - BF( 9, 10, COS3_1 , 2); - BF(13, 14,-COS3_1 , 2); - BF(17, 18, COS3_1 , 2); - BF(21, 22,-COS3_1 , 2); - BF(25, 26, COS3_1 , 2); - BF(29, 30,-COS3_1 , 2); - - /* pass 5 */ - BF1( 0, 1, 2, 3); - BF2( 4, 5, 6, 7); - BF1( 8, 9, 10, 11); - BF2(12, 13, 14, 15); - BF1(16, 17, 18, 19); - BF2(20, 21, 22, 23); - BF1(24, 25, 26, 27); - BF2(28, 29, 30, 31); - - /* pass 6 */ - - ADD( 8, 12); - ADD(12, 10); - ADD(10, 14); - ADD(14, 9); - ADD( 9, 13); - ADD(13, 11); - ADD(11, 15); - - out[ 0] = val0; - out[16] = val1; - out[ 8] = val2; - out[24] = val3; - out[ 4] = val4; - out[20] = val5; - out[12] = val6; - out[28] = val7; - out[ 2] = val8; - out[18] = val9; - out[10] = val10; - out[26] = val11; - out[ 6] = val12; - out[22] = val13; - out[14] = val14; - out[30] = val15; - - ADD(24, 28); - ADD(28, 26); - ADD(26, 30); - ADD(30, 25); - ADD(25, 29); - ADD(29, 27); - ADD(27, 31); - - out[ 1] = val16 + val24; - out[17] = val17 + val25; - out[ 9] = val18 + val26; - out[25] = val19 + val27; - out[ 5] = val20 + val28; - out[21] = val21 + val29; - out[13] = val22 + val30; - out[29] = val23 + val31; - out[ 3] = val24 + val20; - out[19] = val25 + val21; - out[11] = val26 + val22; - out[27] = val27 + val23; - out[ 7] = val28 + val18; - out[23] = val29 + val19; - out[15] = val30 + val17; - out[31] = val31; -} diff --git a/apps/codecs/libwmavoice/fft.c b/apps/codecs/libwmavoice/fft.c deleted file mode 100644 index a030534a26..0000000000 --- a/apps/codecs/libwmavoice/fft.c +++ /dev/null @@ -1,298 +0,0 @@ -/* - * FFT/IFFT transforms - * Copyright (c) 2008 Loren Merritt - * Copyright (c) 2002 Fabrice Bellard - * Partly based on libdjbfft by D. J. Bernstein - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/** - * @file - * FFT/IFFT transforms. - */ - -#include -#include -#include "libavutil/mathematics.h" -#include "fft.h" - -/* cos(2*pi*x/n) for 0<=x<=n/4, followed by its reverse */ -#if !CONFIG_HARDCODED_TABLES -COSTABLE(16); -COSTABLE(32); -COSTABLE(64); -COSTABLE(128); -COSTABLE(256); -COSTABLE(512); -COSTABLE(1024); -COSTABLE(2048); -COSTABLE(4096); -COSTABLE(8192); -COSTABLE(16384); -COSTABLE(32768); -COSTABLE(65536); -#endif -COSTABLE_CONST FFTSample * const ff_cos_tabs[] = { - NULL, NULL, NULL, NULL, - ff_cos_16, ff_cos_32, ff_cos_64, ff_cos_128, ff_cos_256, ff_cos_512, ff_cos_1024, - ff_cos_2048, ff_cos_4096, ff_cos_8192, ff_cos_16384, ff_cos_32768, ff_cos_65536, -}; - -static int split_radix_permutation(int i, int n, int inverse) -{ - int m; - if(n <= 2) return i&1; - m = n >> 1; - if(!(i&m)) return split_radix_permutation(i, m, inverse)*2; - m >>= 1; - if(inverse == !(i&m)) return split_radix_permutation(i, m, inverse)*4 + 1; - else return split_radix_permutation(i, m, inverse)*4 - 1; -} - -av_cold void ff_init_ff_cos_tabs(int index) -{ -#if !CONFIG_HARDCODED_TABLES - int i; - int m = 1< 16) - goto fail; - s->nbits = nbits; - n = 1 << nbits; - - s->revtab = av_malloc(n * sizeof(uint16_t)); - if (!s->revtab) - goto fail; - s->tmp_buf = av_malloc(n * sizeof(FFTComplex)); - if (!s->tmp_buf) - goto fail; - s->inverse = inverse; - - s->fft_permute = ff_fft_permute_c; - s->fft_calc = ff_fft_calc_c; -#if CONFIG_MDCT - s->imdct_calc = ff_imdct_calc_c; - s->imdct_half = ff_imdct_half_c; - s->mdct_calc = ff_mdct_calc_c; -#endif - -#if 0 - if (ARCH_ARM) ff_fft_init_arm(s); - if (HAVE_ALTIVEC) ff_fft_init_altivec(s); - if (HAVE_MMX) ff_fft_init_mmx(s); -#endif - - for(j=4; j<=nbits; j++) { - ff_init_ff_cos_tabs(j); - } - for(i=0; irevtab[-split_radix_permutation(i, n, s->inverse) & (n-1)] = i; - - return 0; - fail: - av_freep(&s->revtab); - av_freep(&s->tmp_buf); - return -1; -} - -void ff_fft_permute_c(FFTContext *s, FFTComplex *z) -{ - int j, np; - const uint16_t *revtab = s->revtab; - np = 1 << s->nbits; - /* TODO: handle split-radix permute in a more optimal way, probably in-place */ - for(j=0;jtmp_buf[revtab[j]] = z[j]; - memcpy(z, s->tmp_buf, np * sizeof(FFTComplex)); -} - -av_cold void ff_fft_end(FFTContext *s) -{ - av_freep(&s->revtab); - av_freep(&s->tmp_buf); -} - -#define sqrthalf (float)M_SQRT1_2 - -#define BF(x,y,a,b) {\ - x = a - b;\ - y = a + b;\ -} - -#define BUTTERFLIES(a0,a1,a2,a3) {\ - BF(t3, t5, t5, t1);\ - BF(a2.re, a0.re, a0.re, t5);\ - BF(a3.im, a1.im, a1.im, t3);\ - BF(t4, t6, t2, t6);\ - BF(a3.re, a1.re, a1.re, t4);\ - BF(a2.im, a0.im, a0.im, t6);\ -} - -// force loading all the inputs before storing any. -// this is slightly slower for small data, but avoids store->load aliasing -// for addresses separated by large powers of 2. -#define BUTTERFLIES_BIG(a0,a1,a2,a3) {\ - FFTSample r0=a0.re, i0=a0.im, r1=a1.re, i1=a1.im;\ - BF(t3, t5, t5, t1);\ - BF(a2.re, a0.re, r0, t5);\ - BF(a3.im, a1.im, i1, t3);\ - BF(t4, t6, t2, t6);\ - BF(a3.re, a1.re, r1, t4);\ - BF(a2.im, a0.im, i0, t6);\ -} - -#define TRANSFORM(a0,a1,a2,a3,wre,wim) {\ - t1 = a2.re * wre + a2.im * wim;\ - t2 = a2.im * wre - a2.re * wim;\ - t5 = a3.re * wre - a3.im * wim;\ - t6 = a3.im * wre + a3.re * wim;\ - BUTTERFLIES(a0,a1,a2,a3)\ -} - -#define TRANSFORM_ZERO(a0,a1,a2,a3) {\ - t1 = a2.re;\ - t2 = a2.im;\ - t5 = a3.re;\ - t6 = a3.im;\ - BUTTERFLIES(a0,a1,a2,a3)\ -} - -/* z[0...8n-1], w[1...2n-1] */ -#define PASS(name)\ -static void name(FFTComplex *z, const FFTSample *wre, unsigned int n)\ -{\ - FFTSample t1, t2, t3, t4, t5, t6;\ - int o1 = 2*n;\ - int o2 = 4*n;\ - int o3 = 6*n;\ - const FFTSample *wim = wre+o1;\ - n--;\ -\ - TRANSFORM_ZERO(z[0],z[o1],z[o2],z[o3]);\ - TRANSFORM(z[1],z[o1+1],z[o2+1],z[o3+1],wre[1],wim[-1]);\ - do {\ - z += 2;\ - wre += 2;\ - wim -= 2;\ - TRANSFORM(z[0],z[o1],z[o2],z[o3],wre[0],wim[0]);\ - TRANSFORM(z[1],z[o1+1],z[o2+1],z[o3+1],wre[1],wim[-1]);\ - } while(--n);\ -} - -PASS(pass) -#undef BUTTERFLIES -#define BUTTERFLIES BUTTERFLIES_BIG -PASS(pass_big) - -#define DECL_FFT(n,n2,n4)\ -static void fft##n(FFTComplex *z)\ -{\ - fft##n2(z);\ - fft##n4(z+n4*2);\ - fft##n4(z+n4*3);\ - pass(z,ff_cos_##n,n4/2);\ -} - -static void fft4(FFTComplex *z) -{ - FFTSample t1, t2, t3, t4, t5, t6, t7, t8; - - BF(t3, t1, z[0].re, z[1].re); - BF(t8, t6, z[3].re, z[2].re); - BF(z[2].re, z[0].re, t1, t6); - BF(t4, t2, z[0].im, z[1].im); - BF(t7, t5, z[2].im, z[3].im); - BF(z[3].im, z[1].im, t4, t8); - BF(z[3].re, z[1].re, t3, t7); - BF(z[2].im, z[0].im, t2, t5); -} - -static void fft8(FFTComplex *z) -{ - FFTSample t1, t2, t3, t4, t5, t6, t7, t8; - - fft4(z); - - BF(t1, z[5].re, z[4].re, -z[5].re); - BF(t2, z[5].im, z[4].im, -z[5].im); - BF(t3, z[7].re, z[6].re, -z[7].re); - BF(t4, z[7].im, z[6].im, -z[7].im); - BF(t8, t1, t3, t1); - BF(t7, t2, t2, t4); - BF(z[4].re, z[0].re, z[0].re, t1); - BF(z[4].im, z[0].im, z[0].im, t2); - BF(z[6].re, z[2].re, z[2].re, t7); - BF(z[6].im, z[2].im, z[2].im, t8); - - TRANSFORM(z[1],z[3],z[5],z[7],sqrthalf,sqrthalf); -} - -#if !CONFIG_SMALL -static void fft16(FFTComplex *z) -{ - FFTSample t1, t2, t3, t4, t5, t6; - - fft8(z); - fft4(z+8); - fft4(z+12); - - TRANSFORM_ZERO(z[0],z[4],z[8],z[12]); - TRANSFORM(z[2],z[6],z[10],z[14],sqrthalf,sqrthalf); - TRANSFORM(z[1],z[5],z[9],z[13],ff_cos_16[1],ff_cos_16[3]); - TRANSFORM(z[3],z[7],z[11],z[15],ff_cos_16[3],ff_cos_16[1]); -} -#else -DECL_FFT(16,8,4) -#endif -DECL_FFT(32,16,8) -DECL_FFT(64,32,16) -DECL_FFT(128,64,32) -DECL_FFT(256,128,64) -DECL_FFT(512,256,128) -#if !CONFIG_SMALL -#define pass pass_big -#endif -DECL_FFT(1024,512,256) -DECL_FFT(2048,1024,512) -DECL_FFT(4096,2048,1024) -DECL_FFT(8192,4096,2048) -DECL_FFT(16384,8192,4096) -DECL_FFT(32768,16384,8192) -DECL_FFT(65536,32768,16384) - -static void (* const fft_dispatch[])(FFTComplex*) = { - fft4, fft8, fft16, fft32, fft64, fft128, fft256, fft512, fft1024, - fft2048, fft4096, fft8192, fft16384, fft32768, fft65536, -}; - -void ff_fft_calc_c(FFTContext *s, FFTComplex *z) -{ - fft_dispatch[s->nbits-2](z); -} - diff --git a/apps/codecs/libwmavoice/fft.h b/apps/codecs/libwmavoice/fft.h deleted file mode 100644 index 2c54b56658..0000000000 --- a/apps/codecs/libwmavoice/fft.h +++ /dev/null @@ -1,244 +0,0 @@ -/* - * Copyright (c) 2000, 2001, 2002 Fabrice Bellard - * Copyright (c) 2002-2004 Michael Niedermayer - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef AVCODEC_FFT_H -#define AVCODEC_FFT_H - -#include -//#include "config.h" -#include "libavutil/mem.h" -#include "avfft.h" - -/* FFT computation */ - -struct FFTContext { - int nbits; - int inverse; - uint16_t *revtab; - FFTComplex *tmp_buf; - int mdct_size; /* size of MDCT (i.e. number of input data * 2) */ - int mdct_bits; /* n = 2^nbits */ - /* pre/post rotation tables */ - FFTSample *tcos; - FFTSample *tsin; - void (*fft_permute)(struct FFTContext *s, FFTComplex *z); - void (*fft_calc)(struct FFTContext *s, FFTComplex *z); - void (*imdct_calc)(struct FFTContext *s, FFTSample *output, const FFTSample *input); - void (*imdct_half)(struct FFTContext *s, FFTSample *output, const FFTSample *input); - void (*mdct_calc)(struct FFTContext *s, FFTSample *output, const FFTSample *input); - int permutation; -#define FF_MDCT_PERM_NONE 0 -#define FF_MDCT_PERM_INTERLEAVE 1 -}; - -#if CONFIG_HARDCODED_TABLES -#define COSTABLE_CONST const -#define SINTABLE_CONST const -#define SINETABLE_CONST const -#else -#define COSTABLE_CONST -#define SINTABLE_CONST -#define SINETABLE_CONST -#endif - -#define COSTABLE(size) \ - COSTABLE_CONST DECLARE_ALIGNED(16, FFTSample, ff_cos_##size)[size/2] -#define SINTABLE(size) \ - SINTABLE_CONST DECLARE_ALIGNED(16, FFTSample, ff_sin_##size)[size/2] -#define SINETABLE(size) \ - SINETABLE_CONST DECLARE_ALIGNED(16, float, ff_sine_##size)[size] -extern COSTABLE(16); -extern COSTABLE(32); -extern COSTABLE(64); -extern COSTABLE(128); -extern COSTABLE(256); -extern COSTABLE(512); -extern COSTABLE(1024); -extern COSTABLE(2048); -extern COSTABLE(4096); -extern COSTABLE(8192); -extern COSTABLE(16384); -extern COSTABLE(32768); -extern COSTABLE(65536); -extern COSTABLE_CONST FFTSample* const ff_cos_tabs[17]; - -/** - * Initialize the cosine table in ff_cos_tabs[index] - * \param index index in ff_cos_tabs array of the table to initialize - */ -void ff_init_ff_cos_tabs(int index); - -extern SINTABLE(16); -extern SINTABLE(32); -extern SINTABLE(64); -extern SINTABLE(128); -extern SINTABLE(256); -extern SINTABLE(512); -extern SINTABLE(1024); -extern SINTABLE(2048); -extern SINTABLE(4096); -extern SINTABLE(8192); -extern SINTABLE(16384); -extern SINTABLE(32768); -extern SINTABLE(65536); - -/** - * Set up a complex FFT. - * @param nbits log2 of the length of the input array - * @param inverse if 0 perform the forward transform, if 1 perform the inverse - */ -int ff_fft_init(FFTContext *s, int nbits, int inverse); -void ff_fft_permute_c(FFTContext *s, FFTComplex *z); -void ff_fft_calc_c(FFTContext *s, FFTComplex *z); - -void ff_fft_init_altivec(FFTContext *s); -void ff_fft_init_mmx(FFTContext *s); -void ff_fft_init_arm(FFTContext *s); -void ff_dct_init_mmx(DCTContext *s); - -/** - * Do the permutation needed BEFORE calling ff_fft_calc(). - */ -static inline void ff_fft_permute(FFTContext *s, FFTComplex *z) -{ - s->fft_permute(s, z); -} -/** - * Do a complex FFT with the parameters defined in ff_fft_init(). The - * input data must be permuted before. No 1.0/sqrt(n) normalization is done. - */ -static inline void ff_fft_calc(FFTContext *s, FFTComplex *z) -{ - s->fft_calc(s, z); -} -void ff_fft_end(FFTContext *s); - -/* MDCT computation */ - -static inline void ff_imdct_calc(FFTContext *s, FFTSample *output, const FFTSample *input) -{ - s->imdct_calc(s, output, input); -} -static inline void ff_imdct_half(FFTContext *s, FFTSample *output, const FFTSample *input) -{ - s->imdct_half(s, output, input); -} - -static inline void ff_mdct_calc(FFTContext *s, FFTSample *output, - const FFTSample *input) -{ - s->mdct_calc(s, output, input); -} - -/** - * Maximum window size for ff_kbd_window_init. - */ -#define FF_KBD_WINDOW_MAX 1024 - -/** - * Generate a Kaiser-Bessel Derived Window. - * @param window pointer to half window - * @param alpha determines window shape - * @param n size of half window, max FF_KBD_WINDOW_MAX - */ -void ff_kbd_window_init(float *window, float alpha, int n); - -/** - * Generate a sine window. - * @param window pointer to half window - * @param n size of half window - */ -void ff_sine_window_init(float *window, int n); - -/** - * initialize the specified entry of ff_sine_windows - */ -void ff_init_ff_sine_windows(int index); -extern SINETABLE( 32); -extern SINETABLE( 64); -extern SINETABLE( 128); -extern SINETABLE( 256); -extern SINETABLE( 512); -extern SINETABLE(1024); -extern SINETABLE(2048); -extern SINETABLE(4096); -extern SINETABLE_CONST float * const ff_sine_windows[13]; - -int ff_mdct_init(FFTContext *s, int nbits, int inverse, double scale); -void ff_imdct_calc_c(FFTContext *s, FFTSample *output, const FFTSample *input); -void ff_imdct_half_c(FFTContext *s, FFTSample *output, const FFTSample *input); -void ff_mdct_calc_c(FFTContext *s, FFTSample *output, const FFTSample *input); -void ff_mdct_end(FFTContext *s); - -/* Real Discrete Fourier Transform */ - -struct RDFTContext { - int nbits; - int inverse; - int sign_convention; - - /* pre/post rotation tables */ - const FFTSample *tcos; - SINTABLE_CONST FFTSample *tsin; - FFTContext fft; - void (*rdft_calc)(struct RDFTContext *s, FFTSample *z); -}; - -/** - * Set up a real FFT. - * @param nbits log2 of the length of the input array - * @param trans the type of transform - */ -int ff_rdft_init(RDFTContext *s, int nbits, enum RDFTransformType trans); -void ff_rdft_end(RDFTContext *s); - -void ff_rdft_init_arm(RDFTContext *s); - -static av_always_inline void ff_rdft_calc(RDFTContext *s, FFTSample *data) -{ - s->rdft_calc(s, data); -} - -/* Discrete Cosine Transform */ - -struct DCTContext { - int nbits; - int inverse; - RDFTContext rdft; - const float *costab; - FFTSample *csc2; - void (*dct_calc)(struct DCTContext *s, FFTSample *data); - void (*dct32)(FFTSample *out, const FFTSample *in); -}; - -/** - * Set up DCT. - * @param nbits size of the input array: - * (1 << nbits) for DCT-II, DCT-III and DST-I - * (1 << nbits) + 1 for DCT-I - * - * @note the first element of the input of DST-I is ignored - */ -int ff_dct_init(DCTContext *s, int nbits, enum DCTTransformType type); -void ff_dct_calc(DCTContext *s, FFTSample *data); -void ff_dct_end (DCTContext *s); - -#endif /* AVCODEC_FFT_H */ diff --git a/apps/codecs/libwmavoice/get_bits.h b/apps/codecs/libwmavoice/get_bits.h deleted file mode 100644 index f4b3646e69..0000000000 --- a/apps/codecs/libwmavoice/get_bits.h +++ /dev/null @@ -1,691 +0,0 @@ -/* - * copyright (c) 2004 Michael Niedermayer - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/** - * @file - * bitstream reader API header. - */ - -#ifndef AVCODEC_GET_BITS_H -#define AVCODEC_GET_BITS_H - -#include -#include -#include -#include "libavutil/bswap.h" -#include "libavutil/common.h" -#include "libavutil/intreadwrite.h" -#include "libavutil/log.h" -#include "mathops.h" - -#if defined(ALT_BITSTREAM_READER_LE) && !defined(ALT_BITSTREAM_READER) -# define ALT_BITSTREAM_READER -#endif - -#if !defined(LIBMPEG2_BITSTREAM_READER) && !defined(A32_BITSTREAM_READER) && !defined(ALT_BITSTREAM_READER) -# if ARCH_ARM && !HAVE_FAST_UNALIGNED -# define A32_BITSTREAM_READER -# else -# define ALT_BITSTREAM_READER -//#define LIBMPEG2_BITSTREAM_READER -//#define A32_BITSTREAM_READER -# endif -#endif - -/* bit input */ -/* buffer, buffer_end and size_in_bits must be present and used by every reader */ -typedef struct GetBitContext { - const uint8_t *buffer, *buffer_end; -#ifdef ALT_BITSTREAM_READER - int index; -#elif defined LIBMPEG2_BITSTREAM_READER - uint8_t *buffer_ptr; - uint32_t cache; - int bit_count; -#elif defined A32_BITSTREAM_READER - uint32_t *buffer_ptr; - uint32_t cache0; - uint32_t cache1; - int bit_count; -#endif - int size_in_bits; -} GetBitContext; - -#define VLC_TYPE int16_t - -typedef struct VLC { - int bits; - VLC_TYPE (*table)[2]; ///< code, bits - int table_size, table_allocated; -} VLC; - -typedef struct RL_VLC_ELEM { - int16_t level; - int8_t len; - uint8_t run; -} RL_VLC_ELEM; - -/* Bitstream reader API docs: -name - arbitrary name which is used as prefix for the internal variables - -gb - getbitcontext - -OPEN_READER(name, gb) - loads gb into local variables - -CLOSE_READER(name, gb) - stores local vars in gb - -UPDATE_CACHE(name, gb) - refills the internal cache from the bitstream - after this call at least MIN_CACHE_BITS will be available, - -GET_CACHE(name, gb) - will output the contents of the internal cache, next bit is MSB of 32 or 64 bit (FIXME 64bit) - -SHOW_UBITS(name, gb, num) - will return the next num bits - -SHOW_SBITS(name, gb, num) - will return the next num bits and do sign extension - -SKIP_BITS(name, gb, num) - will skip over the next num bits - note, this is equivalent to SKIP_CACHE; SKIP_COUNTER - -SKIP_CACHE(name, gb, num) - will remove the next num bits from the cache (note SKIP_COUNTER MUST be called before UPDATE_CACHE / CLOSE_READER) - -SKIP_COUNTER(name, gb, num) - will increment the internal bit counter (see SKIP_CACHE & SKIP_BITS) - -LAST_SKIP_CACHE(name, gb, num) - will remove the next num bits from the cache if it is needed for UPDATE_CACHE otherwise it will do nothing - -LAST_SKIP_BITS(name, gb, num) - is equivalent to LAST_SKIP_CACHE; SKIP_COUNTER - -for examples see get_bits, show_bits, skip_bits, get_vlc -*/ - -#ifdef ALT_BITSTREAM_READER -# define MIN_CACHE_BITS 25 - -# define OPEN_READER(name, gb)\ - unsigned int name##_index= (gb)->index;\ - int name##_cache= 0;\ - -# define CLOSE_READER(name, gb)\ - (gb)->index= name##_index;\ - -# ifdef ALT_BITSTREAM_READER_LE -# define UPDATE_CACHE(name, gb)\ - name##_cache= AV_RL32( ((const uint8_t *)(gb)->buffer)+(name##_index>>3) ) >> (name##_index&0x07);\ - -# define SKIP_CACHE(name, gb, num)\ - name##_cache >>= (num); -# else -# define UPDATE_CACHE(name, gb)\ - name##_cache= AV_RB32( ((const uint8_t *)(gb)->buffer)+(name##_index>>3) ) << (name##_index&0x07);\ - -# define SKIP_CACHE(name, gb, num)\ - name##_cache <<= (num); -# endif - -// FIXME name? -# define SKIP_COUNTER(name, gb, num)\ - name##_index += (num);\ - -# define SKIP_BITS(name, gb, num)\ - {\ - SKIP_CACHE(name, gb, num)\ - SKIP_COUNTER(name, gb, num)\ - }\ - -# define LAST_SKIP_BITS(name, gb, num) SKIP_COUNTER(name, gb, num) -# define LAST_SKIP_CACHE(name, gb, num) ; - -# ifdef ALT_BITSTREAM_READER_LE -# define SHOW_UBITS(name, gb, num)\ - zero_extend(name##_cache, num) - -# define SHOW_SBITS(name, gb, num)\ - sign_extend(name##_cache, num) -# else -# define SHOW_UBITS(name, gb, num)\ - NEG_USR32(name##_cache, num) - -# define SHOW_SBITS(name, gb, num)\ - NEG_SSR32(name##_cache, num) -# endif - -# define GET_CACHE(name, gb)\ - ((uint32_t)name##_cache) - -static inline int get_bits_count(const GetBitContext *s){ - return s->index; -} - -static inline void skip_bits_long(GetBitContext *s, int n){ - s->index += n; -} - -#elif defined LIBMPEG2_BITSTREAM_READER -//libmpeg2 like reader - -# define MIN_CACHE_BITS 17 - -# define OPEN_READER(name, gb)\ - int name##_bit_count=(gb)->bit_count;\ - int name##_cache= (gb)->cache;\ - uint8_t * name##_buffer_ptr=(gb)->buffer_ptr;\ - -# define CLOSE_READER(name, gb)\ - (gb)->bit_count= name##_bit_count;\ - (gb)->cache= name##_cache;\ - (gb)->buffer_ptr= name##_buffer_ptr;\ - -# define UPDATE_CACHE(name, gb)\ - if(name##_bit_count >= 0){\ - name##_cache+= AV_RB16(name##_buffer_ptr) << name##_bit_count; \ - name##_buffer_ptr+=2;\ - name##_bit_count-= 16;\ - }\ - -# define SKIP_CACHE(name, gb, num)\ - name##_cache <<= (num);\ - -# define SKIP_COUNTER(name, gb, num)\ - name##_bit_count += (num);\ - -# define SKIP_BITS(name, gb, num)\ - {\ - SKIP_CACHE(name, gb, num)\ - SKIP_COUNTER(name, gb, num)\ - }\ - -# define LAST_SKIP_BITS(name, gb, num) SKIP_BITS(name, gb, num) -# define LAST_SKIP_CACHE(name, gb, num) SKIP_CACHE(name, gb, num) - -# define SHOW_UBITS(name, gb, num)\ - NEG_USR32(name##_cache, num) - -# define SHOW_SBITS(name, gb, num)\ - NEG_SSR32(name##_cache, num) - -# define GET_CACHE(name, gb)\ - ((uint32_t)name##_cache) - -static inline int get_bits_count(const GetBitContext *s){ - return (s->buffer_ptr - s->buffer)*8 - 16 + s->bit_count; -} - -static inline void skip_bits_long(GetBitContext *s, int n){ - OPEN_READER(re, s) - re_bit_count += n; - re_buffer_ptr += 2*(re_bit_count>>4); - re_bit_count &= 15; - re_cache = ((re_buffer_ptr[-2]<<8) + re_buffer_ptr[-1]) << (16+re_bit_count); - UPDATE_CACHE(re, s) - CLOSE_READER(re, s) -} - -#elif defined A32_BITSTREAM_READER - -# define MIN_CACHE_BITS 32 - -# define OPEN_READER(name, gb)\ - int name##_bit_count=(gb)->bit_count;\ - uint32_t name##_cache0= (gb)->cache0;\ - uint32_t name##_cache1= (gb)->cache1;\ - uint32_t * name##_buffer_ptr=(gb)->buffer_ptr;\ - -# define CLOSE_READER(name, gb)\ - (gb)->bit_count= name##_bit_count;\ - (gb)->cache0= name##_cache0;\ - (gb)->cache1= name##_cache1;\ - (gb)->buffer_ptr= name##_buffer_ptr;\ - -# define UPDATE_CACHE(name, gb)\ - if(name##_bit_count > 0){\ - const uint32_t next= av_be2ne32( *name##_buffer_ptr );\ - name##_cache0 |= NEG_USR32(next,name##_bit_count);\ - name##_cache1 |= next<buffer_ptr - s->buffer)*8 - 32 + s->bit_count; -} - -static inline void skip_bits_long(GetBitContext *s, int n){ - OPEN_READER(re, s) - re_bit_count += n; - re_buffer_ptr += re_bit_count>>5; - re_bit_count &= 31; - re_cache0 = av_be2ne32( re_buffer_ptr[-1] ) << re_bit_count; - re_cache1 = 0; - UPDATE_CACHE(re, s) - CLOSE_READER(re, s) -} - -#endif - -/** - * read mpeg1 dc style vlc (sign bit + mantisse with no MSB). - * if MSB not set it is negative - * @param n length in bits - * @author BERO - */ -static inline int get_xbits(GetBitContext *s, int n){ - register int sign; - register int32_t cache; - OPEN_READER(re, s) - UPDATE_CACHE(re, s) - cache = GET_CACHE(re,s); - sign=(~cache)>>31; - LAST_SKIP_BITS(re, s, n) - CLOSE_READER(re, s) - return (NEG_USR32(sign ^ cache, n) ^ sign) - sign; -} - -static inline int get_sbits(GetBitContext *s, int n){ - register int tmp; - OPEN_READER(re, s) - UPDATE_CACHE(re, s) - tmp= SHOW_SBITS(re, s, n); - LAST_SKIP_BITS(re, s, n) - CLOSE_READER(re, s) - return tmp; -} - -/** - * reads 1-17 bits. - * Note, the alt bitstream reader can read up to 25 bits, but the libmpeg2 reader can't - */ -static inline unsigned int get_bits(GetBitContext *s, int n){ - register int tmp; - OPEN_READER(re, s) - UPDATE_CACHE(re, s) - tmp= SHOW_UBITS(re, s, n); - LAST_SKIP_BITS(re, s, n) - CLOSE_READER(re, s) - return tmp; -} - -/** - * shows 1-17 bits. - * Note, the alt bitstream reader can read up to 25 bits, but the libmpeg2 reader can't - */ -static inline unsigned int show_bits(GetBitContext *s, int n){ - register int tmp; - OPEN_READER(re, s) - UPDATE_CACHE(re, s) - tmp= SHOW_UBITS(re, s, n); -// CLOSE_READER(re, s) - return tmp; -} - -static inline void skip_bits(GetBitContext *s, int n){ - //Note gcc seems to optimize this to s->index+=n for the ALT_READER :)) - OPEN_READER(re, s) - UPDATE_CACHE(re, s) - LAST_SKIP_BITS(re, s, n) - CLOSE_READER(re, s) -} - -static inline unsigned int get_bits1(GetBitContext *s){ -#ifdef ALT_BITSTREAM_READER - unsigned int index= s->index; - uint8_t result= s->buffer[ index>>3 ]; -#ifdef ALT_BITSTREAM_READER_LE - result>>= (index&0x07); - result&= 1; -#else - result<<= (index&0x07); - result>>= 8 - 1; -#endif - index++; - s->index= index; - - return result; -#else - return get_bits(s, 1); -#endif -} - -static inline unsigned int show_bits1(GetBitContext *s){ - return show_bits(s, 1); -} - -static inline void skip_bits1(GetBitContext *s){ - skip_bits(s, 1); -} - -/** - * reads 0-32 bits. - */ -static inline unsigned int get_bits_long(GetBitContext *s, int n){ - if(n<=MIN_CACHE_BITS) return get_bits(s, n); - else{ -#ifdef ALT_BITSTREAM_READER_LE - int ret= get_bits(s, 16); - return ret | (get_bits(s, n-16) << 16); -#else - int ret= get_bits(s, 16) << (n-16); - return ret | get_bits(s, n-16); -#endif - } -} - -/** - * reads 0-32 bits as a signed integer. - */ -static inline int get_sbits_long(GetBitContext *s, int n) { - return sign_extend(get_bits_long(s, n), n); -} - -/** - * shows 0-32 bits. - */ -static inline unsigned int show_bits_long(GetBitContext *s, int n){ - if(n<=MIN_CACHE_BITS) return show_bits(s, n); - else{ - GetBitContext gb= *s; - return get_bits_long(&gb, n); - } -} - -static inline int check_marker(GetBitContext *s, const char *msg) -{ - int bit= get_bits1(s); - if(!bit) - av_log(NULL, AV_LOG_INFO, "Marker bit missing %s\n", msg); - - return bit; -} - -/** - * init GetBitContext. - * @param buffer bitstream buffer, must be FF_INPUT_BUFFER_PADDING_SIZE bytes larger then the actual read bits - * because some optimized bitstream readers read 32 or 64 bit at once and could read over the end - * @param bit_size the size of the buffer in bits - * - * While GetBitContext stores the buffer size, for performance reasons you are - * responsible for checking for the buffer end yourself (take advantage of the padding)! - */ -static inline void init_get_bits(GetBitContext *s, - const uint8_t *buffer, int bit_size) -{ - int buffer_size= (bit_size+7)>>3; - if(buffer_size < 0 || bit_size < 0) { - buffer_size = bit_size = 0; - buffer = NULL; - } - - s->buffer= buffer; - s->size_in_bits= bit_size; - s->buffer_end= buffer + buffer_size; -#ifdef ALT_BITSTREAM_READER - s->index=0; -#elif defined LIBMPEG2_BITSTREAM_READER - s->buffer_ptr = (uint8_t*)((intptr_t)buffer&(~1)); - s->bit_count = 16 + 8*((intptr_t)buffer&1); - skip_bits_long(s, 0); -#elif defined A32_BITSTREAM_READER - s->buffer_ptr = (uint32_t*)((intptr_t)buffer&(~3)); - s->bit_count = 32 + 8*((intptr_t)buffer&3); - skip_bits_long(s, 0); -#endif -} - -static inline void align_get_bits(GetBitContext *s) -{ - int n= (-get_bits_count(s)) & 7; - if(n) skip_bits(s, n); -} - -#define init_vlc(vlc, nb_bits, nb_codes,\ - bits, bits_wrap, bits_size,\ - codes, codes_wrap, codes_size,\ - flags)\ - init_vlc_sparse(vlc, nb_bits, nb_codes,\ - bits, bits_wrap, bits_size,\ - codes, codes_wrap, codes_size,\ - NULL, 0, 0, flags) - -int init_vlc_sparse(VLC *vlc, int nb_bits, int nb_codes, - const void *bits, int bits_wrap, int bits_size, - const void *codes, int codes_wrap, int codes_size, - const void *symbols, int symbols_wrap, int symbols_size, - int flags); -#define INIT_VLC_LE 2 -#define INIT_VLC_USE_NEW_STATIC 4 -void free_vlc(VLC *vlc); - -#define INIT_VLC_STATIC(vlc, bits, a,b,c,d,e,f,g, static_size)\ -{\ - static VLC_TYPE table[static_size][2];\ - (vlc)->table= table;\ - (vlc)->table_allocated= static_size;\ - init_vlc(vlc, bits, a,b,c,d,e,f,g, INIT_VLC_USE_NEW_STATIC);\ -} - - -/** - * - * If the vlc code is invalid and max_depth=1, then no bits will be removed. - * If the vlc code is invalid and max_depth>1, then the number of bits removed - * is undefined. - */ -#define GET_VLC(code, name, gb, table, bits, max_depth)\ -{\ - int n, nb_bits;\ - unsigned int index;\ -\ - index= SHOW_UBITS(name, gb, bits);\ - code = table[index][0];\ - n = table[index][1];\ -\ - if(max_depth > 1 && n < 0){\ - LAST_SKIP_BITS(name, gb, bits)\ - UPDATE_CACHE(name, gb)\ -\ - nb_bits = -n;\ -\ - index= SHOW_UBITS(name, gb, nb_bits) + code;\ - code = table[index][0];\ - n = table[index][1];\ - if(max_depth > 2 && n < 0){\ - LAST_SKIP_BITS(name, gb, nb_bits)\ - UPDATE_CACHE(name, gb)\ -\ - nb_bits = -n;\ -\ - index= SHOW_UBITS(name, gb, nb_bits) + code;\ - code = table[index][0];\ - n = table[index][1];\ - }\ - }\ - SKIP_BITS(name, gb, n)\ -} - -#define GET_RL_VLC(level, run, name, gb, table, bits, max_depth, need_update)\ -{\ - int n, nb_bits;\ - unsigned int index;\ -\ - index= SHOW_UBITS(name, gb, bits);\ - level = table[index].level;\ - n = table[index].len;\ -\ - if(max_depth > 1 && n < 0){\ - SKIP_BITS(name, gb, bits)\ - if(need_update){\ - UPDATE_CACHE(name, gb)\ - }\ -\ - nb_bits = -n;\ -\ - index= SHOW_UBITS(name, gb, nb_bits) + level;\ - level = table[index].level;\ - n = table[index].len;\ - }\ - run= table[index].run;\ - SKIP_BITS(name, gb, n)\ -} - - -/** - * parses a vlc code, faster then get_vlc() - * @param bits is the number of bits which will be read at once, must be - * identical to nb_bits in init_vlc() - * @param max_depth is the number of times bits bits must be read to completely - * read the longest vlc code - * = (max_vlc_length + bits - 1) / bits - */ -static av_always_inline int get_vlc2(GetBitContext *s, VLC_TYPE (*table)[2], - int bits, int max_depth) -{ - int code; - - OPEN_READER(re, s) - UPDATE_CACHE(re, s) - - GET_VLC(code, re, s, table, bits, max_depth) - - CLOSE_READER(re, s) - return code; -} - -//#define TRACE - -#ifdef TRACE -static inline void print_bin(int bits, int n){ - int i; - - for(i=n-1; i>=0; i--){ - av_log(NULL, AV_LOG_DEBUG, "%d", (bits>>i)&1); - } - for(i=n; i<24; i++) - av_log(NULL, AV_LOG_DEBUG, " "); -} - -static inline int get_bits_trace(GetBitContext *s, int n, char *file, const char *func, int line){ - int r= get_bits(s, n); - - print_bin(r, n); - av_log(NULL, AV_LOG_DEBUG, "%5d %2d %3d bit @%5d in %s %s:%d\n", r, n, r, get_bits_count(s)-n, file, func, line); - return r; -} -static inline int get_vlc_trace(GetBitContext *s, VLC_TYPE (*table)[2], int bits, int max_depth, char *file, const char *func, int line){ - int show= show_bits(s, 24); - int pos= get_bits_count(s); - int r= get_vlc2(s, table, bits, max_depth); - int len= get_bits_count(s) - pos; - int bits2= show>>(24-len); - - print_bin(bits2, len); - - av_log(NULL, AV_LOG_DEBUG, "%5d %2d %3d vlc @%5d in %s %s:%d\n", bits2, len, r, pos, file, func, line); - return r; -} -static inline int get_xbits_trace(GetBitContext *s, int n, char *file, const char *func, int line){ - int show= show_bits(s, n); - int r= get_xbits(s, n); - - print_bin(show, n); - av_log(NULL, AV_LOG_DEBUG, "%5d %2d %3d xbt @%5d in %s %s:%d\n", show, n, r, get_bits_count(s)-n, file, func, line); - return r; -} - -#define get_bits(s, n) get_bits_trace(s, n, __FILE__, __PRETTY_FUNCTION__, __LINE__) -#define get_bits1(s) get_bits_trace(s, 1, __FILE__, __PRETTY_FUNCTION__, __LINE__) -#define get_xbits(s, n) get_xbits_trace(s, n, __FILE__, __PRETTY_FUNCTION__, __LINE__) -#define get_vlc(s, vlc) get_vlc_trace(s, (vlc)->table, (vlc)->bits, 3, __FILE__, __PRETTY_FUNCTION__, __LINE__) -#define get_vlc2(s, tab, bits, max) get_vlc_trace(s, tab, bits, max, __FILE__, __PRETTY_FUNCTION__, __LINE__) - -#define tprintf(p, ...) av_log(p, AV_LOG_DEBUG, __VA_ARGS__) - -#else //TRACE -#define tprintf(p, ...) {} -#endif - -static inline int decode012(GetBitContext *gb){ - int n; - n = get_bits1(gb); - if (n == 0) - return 0; - else - return get_bits1(gb) + 1; -} - -static inline int decode210(GetBitContext *gb){ - if (get_bits1(gb)) - return 0; - else - return 2 - get_bits1(gb); -} - -static inline int get_bits_left(GetBitContext *gb) -{ - return gb->size_in_bits - get_bits_count(gb); -} - -#endif /* AVCODEC_GET_BITS_H */ diff --git a/apps/codecs/libwmavoice/internal.h b/apps/codecs/libwmavoice/internal.h deleted file mode 100644 index 24aca6b28b..0000000000 --- a/apps/codecs/libwmavoice/internal.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/** - * @file - * common internal api header. - */ - -#ifndef AVCODEC_INTERNAL_H -#define AVCODEC_INTERNAL_H - -#include -#include "avcodec.h" - -/** - * Determine whether pix_fmt is a hardware accelerated format. - */ -int ff_is_hwaccel_pix_fmt(enum PixelFormat pix_fmt); - -/** - * Return the hardware accelerated codec for codec codec_id and - * pixel format pix_fmt. - * - * @param codec_id the codec to match - * @param pix_fmt the pixel format to match - * @return the hardware accelerated codec, or NULL if none was found. - */ -AVHWAccel *ff_find_hwaccel(enum CodecID codec_id, enum PixelFormat pix_fmt); - -/** - * Return the index into tab at which {a,b} match elements {[0],[1]} of tab. - * If there is no such matching pair then size is returned. - */ -int ff_match_2uint16(const uint16_t (*tab)[2], int size, int a, int b); - -unsigned int ff_toupper4(unsigned int x); - -#endif /* AVCODEC_INTERNAL_H */ diff --git a/apps/codecs/libwmavoice/libavutil/attributes.h b/apps/codecs/libwmavoice/libavutil/attributes.h deleted file mode 100644 index a95bb02e89..0000000000 --- a/apps/codecs/libwmavoice/libavutil/attributes.h +++ /dev/null @@ -1,121 +0,0 @@ -/* - * copyright (c) 2006 Michael Niedermayer - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/** - * @file - * Macro definitions for various function/variable attributes - */ - -#ifndef AVUTIL_ATTRIBUTES_H -#define AVUTIL_ATTRIBUTES_H - -#ifdef __GNUC__ -# define AV_GCC_VERSION_AT_LEAST(x,y) (__GNUC__ > x || __GNUC__ == x && __GNUC_MINOR__ >= y) -#else -# define AV_GCC_VERSION_AT_LEAST(x,y) 0 -#endif - -#ifndef av_always_inline -#if AV_GCC_VERSION_AT_LEAST(3,1) -# define av_always_inline __attribute__((always_inline)) inline -#else -# define av_always_inline inline -#endif -#endif - -#ifndef av_noinline -#if AV_GCC_VERSION_AT_LEAST(3,1) -# define av_noinline __attribute__((noinline)) -#else -# define av_noinline -#endif -#endif - -#ifndef av_pure -#if AV_GCC_VERSION_AT_LEAST(3,1) -# define av_pure __attribute__((pure)) -#else -# define av_pure -#endif -#endif - -#ifndef av_const -#if AV_GCC_VERSION_AT_LEAST(2,6) -# define av_const __attribute__((const)) -#else -# define av_const -#endif -#endif - -#ifndef av_cold -#if (!defined(__ICC) || __ICC > 1110) && AV_GCC_VERSION_AT_LEAST(4,3) -# define av_cold __attribute__((cold)) -#else -# define av_cold -#endif -#endif - -#ifndef av_flatten -#if (!defined(__ICC) || __ICC > 1110) && AV_GCC_VERSION_AT_LEAST(4,1) -# define av_flatten __attribute__((flatten)) -#else -# define av_flatten -#endif -#endif - -#ifndef attribute_deprecated -#if AV_GCC_VERSION_AT_LEAST(3,1) -# define attribute_deprecated __attribute__((deprecated)) -#else -# define attribute_deprecated -#endif -#endif - -#ifndef av_unused -#if defined(__GNUC__) -# define av_unused __attribute__((unused)) -#else -# define av_unused -#endif -#endif - -#ifndef av_alias -#if (!defined(__ICC) || __ICC > 1110) && AV_GCC_VERSION_AT_LEAST(3,3) -# define av_alias __attribute__((may_alias)) -#else -# define av_alias -#endif -#endif - -#ifndef av_uninit -#if defined(__GNUC__) && !defined(__ICC) -# define av_uninit(x) x=x -#else -# define av_uninit(x) x -#endif -#endif - -#ifdef __GNUC__ -# define av_builtin_constant_p __builtin_constant_p -#else -# define av_builtin_constant_p(x) 0 -#endif - -#endif /* AVUTIL_ATTRIBUTES_H */ diff --git a/apps/codecs/libwmavoice/libavutil/avutil.h b/apps/codecs/libwmavoice/libavutil/avutil.h deleted file mode 100644 index 457829ac7f..0000000000 --- a/apps/codecs/libwmavoice/libavutil/avutil.h +++ /dev/null @@ -1,89 +0,0 @@ -/* - * copyright (c) 2006 Michael Niedermayer - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef AVUTIL_AVUTIL_H -#define AVUTIL_AVUTIL_H - -/** - * @file - * external API header - */ - - -#define AV_STRINGIFY(s) AV_TOSTRING(s) -#define AV_TOSTRING(s) #s - -#define AV_GLUE(a, b) a ## b -#define AV_JOIN(a, b) AV_GLUE(a, b) - -#define AV_PRAGMA(s) _Pragma(#s) - -#define AV_VERSION_INT(a, b, c) (a<<16 | b<<8 | c) -#define AV_VERSION_DOT(a, b, c) a ##.## b ##.## c -#define AV_VERSION(a, b, c) AV_VERSION_DOT(a, b, c) - -#define LIBAVUTIL_VERSION_MAJOR 50 -#define LIBAVUTIL_VERSION_MINOR 23 -#define LIBAVUTIL_VERSION_MICRO 0 - -#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ - LIBAVUTIL_VERSION_MINOR, \ - LIBAVUTIL_VERSION_MICRO) -#define LIBAVUTIL_VERSION AV_VERSION(LIBAVUTIL_VERSION_MAJOR, \ - LIBAVUTIL_VERSION_MINOR, \ - LIBAVUTIL_VERSION_MICRO) -#define LIBAVUTIL_BUILD LIBAVUTIL_VERSION_INT - -#define LIBAVUTIL_IDENT "Lavu" AV_STRINGIFY(LIBAVUTIL_VERSION) - -/** - * Return the LIBAVUTIL_VERSION_INT constant. - */ -unsigned avutil_version(void); - -/** - * Return the libavutil build-time configuration. - */ -const char *avutil_configuration(void); - -/** - * Return the libavutil license. - */ -const char *avutil_license(void); - -enum AVMediaType { - AVMEDIA_TYPE_UNKNOWN = -1, - AVMEDIA_TYPE_VIDEO, - AVMEDIA_TYPE_AUDIO, - AVMEDIA_TYPE_DATA, - AVMEDIA_TYPE_SUBTITLE, - AVMEDIA_TYPE_ATTACHMENT, - AVMEDIA_TYPE_NB -}; - -#include "common.h" -//#include "error.h" -#include "mathematics.h" -//#include "rational.h" -//#include "intfloat_readwrite.h" -#include "log.h" -//#include "pixfmt.h" - -#endif /* AVUTIL_AVUTIL_H */ diff --git a/apps/codecs/libwmavoice/libavutil/bswap.h b/apps/codecs/libwmavoice/libavutil/bswap.h deleted file mode 100644 index 303bcf3532..0000000000 --- a/apps/codecs/libwmavoice/libavutil/bswap.h +++ /dev/null @@ -1,124 +0,0 @@ -/* - * copyright (c) 2006 Michael Niedermayer - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/** - * @file - * byte swapping routines - */ - -#ifndef AVUTIL_BSWAP_H -#define AVUTIL_BSWAP_H - -#include -#include "libavutil/avconfig.h" -#include "attributes.h" - -#ifdef HAVE_AV_CONFIG_H - -#include "config.h" - -#if ARCH_ARM -# include "arm/bswap.h" -#elif ARCH_AVR32 -# include "avr32/bswap.h" -#elif ARCH_BFIN -# include "bfin/bswap.h" -#elif ARCH_SH4 -# include "sh4/bswap.h" -#elif ARCH_X86 -# include "x86/bswap.h" -#endif - -#endif /* HAVE_AV_CONFIG_H */ - -#define AV_BSWAP16C(x) (((x) << 8 & 0xff00) | ((x) >> 8 & 0x00ff)) -#define AV_BSWAP32C(x) (AV_BSWAP16C(x) << 16 | AV_BSWAP16C((x) >> 16)) -#define AV_BSWAP64C(x) (AV_BSWAP32C(x) << 32 | AV_BSWAP32C((x) >> 32)) - -#define AV_BSWAPC(s, x) AV_BSWAP##s##C(x) - -#ifndef av_bswap16 -static av_always_inline av_const uint16_t av_bswap16(uint16_t x) -{ - x= (x>>8) | (x<<8); - return x; -} -#endif - -#ifndef av_bswap32 -static av_always_inline av_const uint32_t av_bswap32(uint32_t x) -{ - x= ((x<<8)&0xFF00FF00) | ((x>>8)&0x00FF00FF); - x= (x>>16) | (x<<16); - return x; -} -#endif - -#ifndef av_bswap64 -static inline uint64_t av_const av_bswap64(uint64_t x) -{ -#if 0 - x= ((x<< 8)&0xFF00FF00FF00FF00ULL) | ((x>> 8)&0x00FF00FF00FF00FFULL); - x= ((x<<16)&0xFFFF0000FFFF0000ULL) | ((x>>16)&0x0000FFFF0000FFFFULL); - return (x>>32) | (x<<32); -#else - union { - uint64_t ll; - uint32_t l[2]; - } w, r; - w.ll = x; - r.l[0] = av_bswap32 (w.l[1]); - r.l[1] = av_bswap32 (w.l[0]); - return r.ll; -#endif -} -#endif - -// be2ne ... big-endian to native-endian -// le2ne ... little-endian to native-endian - -#if AV_HAVE_BIGENDIAN -#define av_be2ne16(x) (x) -#define av_be2ne32(x) (x) -#define av_be2ne64(x) (x) -#define av_le2ne16(x) av_bswap16(x) -#define av_le2ne32(x) av_bswap32(x) -#define av_le2ne64(x) av_bswap64(x) -#define AV_BE2NEC(s, x) (x) -#define AV_LE2NEC(s, x) AV_BSWAPC(s, x) -#else -#define av_be2ne16(x) av_bswap16(x) -#define av_be2ne32(x) av_bswap32(x) -#define av_be2ne64(x) av_bswap64(x) -#define av_le2ne16(x) (x) -#define av_le2ne32(x) (x) -#define av_le2ne64(x) (x) -#define AV_BE2NEC(s, x) AV_BSWAPC(s, x) -#define AV_LE2NEC(s, x) (x) -#endif - -#define AV_BE2NE16C(x) AV_BE2NEC(16, x) -#define AV_BE2NE32C(x) AV_BE2NEC(32, x) -#define AV_BE2NE64C(x) AV_BE2NEC(64, x) -#define AV_LE2NE16C(x) AV_LE2NEC(16, x) -#define AV_LE2NE32C(x) AV_LE2NEC(32, x) -#define AV_LE2NE64C(x) AV_LE2NEC(64, x) - -#endif /* AVUTIL_BSWAP_H */ diff --git a/apps/codecs/libwmavoice/libavutil/common.h b/apps/codecs/libwmavoice/libavutil/common.h deleted file mode 100644 index f9c03db559..0000000000 --- a/apps/codecs/libwmavoice/libavutil/common.h +++ /dev/null @@ -1,346 +0,0 @@ -/* - * copyright (c) 2006 Michael Niedermayer - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/** - * @file - * common internal and external API header - */ - -#ifndef AVUTIL_COMMON_H -#define AVUTIL_COMMON_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include "attributes.h" - -//rounded division & shift -#define RSHIFT(a,b) ((a) > 0 ? ((a) + ((1<<(b))>>1))>>(b) : ((a) + ((1<<(b))>>1)-1)>>(b)) -/* assume b>0 */ -#define ROUNDED_DIV(a,b) (((a)>0 ? (a) + ((b)>>1) : (a) - ((b)>>1))/(b)) -#define FFABS(a) ((a) >= 0 ? (a) : (-(a))) -#define FFSIGN(a) ((a) > 0 ? 1 : -1) - -#define FFMAX(a,b) ((a) > (b) ? (a) : (b)) -#define FFMAX3(a,b,c) FFMAX(FFMAX(a,b),c) -#define FFMIN(a,b) ((a) > (b) ? (b) : (a)) -#define FFMIN3(a,b,c) FFMIN(FFMIN(a,b),c) - -#define FFSWAP(type,a,b) do{type SWAP_tmp= b; b= a; a= SWAP_tmp;}while(0) -#define FF_ARRAY_ELEMS(a) (sizeof(a) / sizeof((a)[0])) -#define FFALIGN(x, a) (((x)+(a)-1)&~((a)-1)) - -/* misc math functions */ -extern const uint8_t ff_log2_tab[256]; - -extern const uint8_t av_reverse[256]; - -static inline av_const int av_log2_c(unsigned int v) -{ - int n = 0; - if (v & 0xffff0000) { - v >>= 16; - n += 16; - } - if (v & 0xff00) { - v >>= 8; - n += 8; - } - n += ff_log2_tab[v]; - - return n; -} - -static inline av_const int av_log2_16bit_c(unsigned int v) -{ - int n = 0; - if (v & 0xff00) { - v >>= 8; - n += 8; - } - n += ff_log2_tab[v]; - - return n; -} - -#ifdef HAVE_AV_CONFIG_H -# include "config.h" -# include "intmath.h" -#endif - -/* Pull in unguarded fallback defines at the end of this file. */ -#include "common.h" - -/** - * Clip a signed integer value into the amin-amax range. - * @param a value to clip - * @param amin minimum value of the clip range - * @param amax maximum value of the clip range - * @return clipped value - */ -static inline av_const int av_clip_c(int a, int amin, int amax) -{ - if (a < amin) return amin; - else if (a > amax) return amax; - else return a; -} - -/** - * Clip a signed integer value into the 0-255 range. - * @param a value to clip - * @return clipped value - */ -static inline av_const uint8_t av_clip_uint8_c(int a) -{ - if (a&(~0xFF)) return (-a)>>31; - else return a; -} - -/** - * Clip a signed integer value into the -128,127 range. - * @param a value to clip - * @return clipped value - */ -static inline av_const int8_t av_clip_int8_c(int a) -{ - if ((a+0x80) & ~0xFF) return (a>>31) ^ 0x7F; - else return a; -} - -/** - * Clip a signed integer value into the 0-65535 range. - * @param a value to clip - * @return clipped value - */ -static inline av_const uint16_t av_clip_uint16_c(int a) -{ - if (a&(~0xFFFF)) return (-a)>>31; - else return a; -} - -/** - * Clip a signed integer value into the -32768,32767 range. - * @param a value to clip - * @return clipped value - */ -static inline av_const int16_t av_clip_int16_c(int a) -{ - if ((a+0x8000) & ~0xFFFF) return (a>>31) ^ 0x7FFF; - else return a; -} - -/** - * Clip a signed 64-bit integer value into the -2147483648,2147483647 range. - * @param a value to clip - * @return clipped value - */ -static inline av_const int32_t av_clipl_int32_c(int64_t a) -{ - if ((a+0x80000000u) & ~UINT64_C(0xFFFFFFFF)) return (a>>63) ^ 0x7FFFFFFF; - else return a; -} - -/** - * Clip a float value into the amin-amax range. - * @param a value to clip - * @param amin minimum value of the clip range - * @param amax maximum value of the clip range - * @return clipped value - */ -static inline av_const float av_clipf_c(float a, float amin, float amax) -{ - if (a < amin) return amin; - else if (a > amax) return amax; - else return a; -} - -/** Compute ceil(log2(x)). - * @param x value used to compute ceil(log2(x)) - * @return computed ceiling of log2(x) - */ -static inline av_const int av_ceil_log2_c(int x) -{ - return av_log2((x - 1) << 1); -} - -#define MKTAG(a,b,c,d) ((a) | ((b) << 8) | ((c) << 16) | ((d) << 24)) -#define MKBETAG(a,b,c,d) ((d) | ((c) << 8) | ((b) << 16) | ((a) << 24)) - -/** - * Convert a UTF-8 character (up to 4 bytes) to its 32-bit UCS-4 encoded form. - * - * @param val Output value, must be an lvalue of type uint32_t. - * @param GET_BYTE Expression reading one byte from the input. - * Evaluated up to 7 times (4 for the currently - * assigned Unicode range). With a memory buffer - * input, this could be *ptr++. - * @param ERROR Expression to be evaluated on invalid input, - * typically a goto statement. - */ -#define GET_UTF8(val, GET_BYTE, ERROR)\ - val= GET_BYTE;\ - {\ - int ones= 7 - av_log2(val ^ 255);\ - if(ones==1)\ - ERROR\ - val&= 127>>ones;\ - while(--ones > 0){\ - int tmp= GET_BYTE - 128;\ - if(tmp>>6)\ - ERROR\ - val= (val<<6) + tmp;\ - }\ - } - -/** - * Convert a UTF-16 character (2 or 4 bytes) to its 32-bit UCS-4 encoded form. - * - * @param val Output value, must be an lvalue of type uint32_t. - * @param GET_16BIT Expression returning two bytes of UTF-16 data converted - * to native byte order. Evaluated one or two times. - * @param ERROR Expression to be evaluated on invalid input, - * typically a goto statement. - */ -#define GET_UTF16(val, GET_16BIT, ERROR)\ - val = GET_16BIT;\ - {\ - unsigned int hi = val - 0xD800;\ - if (hi < 0x800) {\ - val = GET_16BIT - 0xDC00;\ - if (val > 0x3FFU || hi > 0x3FFU)\ - ERROR\ - val += (hi<<10) + 0x10000;\ - }\ - }\ - -/*! - * \def PUT_UTF8(val, tmp, PUT_BYTE) - * Convert a 32-bit Unicode character to its UTF-8 encoded form (up to 4 bytes long). - * \param val is an input-only argument and should be of type uint32_t. It holds - * a UCS-4 encoded Unicode character that is to be converted to UTF-8. If - * val is given as a function it is executed only once. - * \param tmp is a temporary variable and should be of type uint8_t. It - * represents an intermediate value during conversion that is to be - * output by PUT_BYTE. - * \param PUT_BYTE writes the converted UTF-8 bytes to any proper destination. - * It could be a function or a statement, and uses tmp as the input byte. - * For example, PUT_BYTE could be "*output++ = tmp;" PUT_BYTE will be - * executed up to 4 times for values in the valid UTF-8 range and up to - * 7 times in the general case, depending on the length of the converted - * Unicode character. - */ -#define PUT_UTF8(val, tmp, PUT_BYTE)\ - {\ - int bytes, shift;\ - uint32_t in = val;\ - if (in < 0x80) {\ - tmp = in;\ - PUT_BYTE\ - } else {\ - bytes = (av_log2(in) + 4) / 5;\ - shift = (bytes - 1) * 6;\ - tmp = (256 - (256 >> bytes)) | (in >> shift);\ - PUT_BYTE\ - while (shift >= 6) {\ - shift -= 6;\ - tmp = 0x80 | ((in >> shift) & 0x3f);\ - PUT_BYTE\ - }\ - }\ - } - -/*! - * \def PUT_UTF16(val, tmp, PUT_16BIT) - * Convert a 32-bit Unicode character to its UTF-16 encoded form (2 or 4 bytes). - * \param val is an input-only argument and should be of type uint32_t. It holds - * a UCS-4 encoded Unicode character that is to be converted to UTF-16. If - * val is given as a function it is executed only once. - * \param tmp is a temporary variable and should be of type uint16_t. It - * represents an intermediate value during conversion that is to be - * output by PUT_16BIT. - * \param PUT_16BIT writes the converted UTF-16 data to any proper destination - * in desired endianness. It could be a function or a statement, and uses tmp - * as the input byte. For example, PUT_BYTE could be "*output++ = tmp;" - * PUT_BYTE will be executed 1 or 2 times depending on input character. - */ -#define PUT_UTF16(val, tmp, PUT_16BIT)\ - {\ - uint32_t in = val;\ - if (in < 0x10000) {\ - tmp = in;\ - PUT_16BIT\ - } else {\ - tmp = 0xD800 | ((in - 0x10000) >> 10);\ - PUT_16BIT\ - tmp = 0xDC00 | ((in - 0x10000) & 0x3FF);\ - PUT_16BIT\ - }\ - }\ - - - -#include "mem.h" - -#ifdef HAVE_AV_CONFIG_H -# include "internal.h" -#endif /* HAVE_AV_CONFIG_H */ - -#endif /* AVUTIL_COMMON_H */ - -/* - * The following definitions are outside the multiple inclusion guard - * to ensure they are immediately available in intmath.h. - */ - -#ifndef av_log2 -# define av_log2 av_log2_c -#endif -#ifndef av_log2_16bit -# define av_log2_16bit av_log2_16bit_c -#endif -#ifndef av_ceil_log2 -# define av_ceil_log2 av_ceil_log2_c -#endif -#ifndef av_clip -# define av_clip av_clip_c -#endif -#ifndef av_clip_uint8 -# define av_clip_uint8 av_clip_uint8_c -#endif -#ifndef av_clip_int8 -# define av_clip_int8 av_clip_int8_c -#endif -#ifndef av_clip_uint16 -# define av_clip_uint16 av_clip_uint16_c -#endif -#ifndef av_clip_int16 -# define av_clip_int16 av_clip_int16_c -#endif -#ifndef av_clipl_int32 -# define av_clipl_int32 av_clipl_int32_c -#endif -#ifndef av_clipf -# define av_clipf av_clipf_c -#endif diff --git a/apps/codecs/libwmavoice/libavutil/internal.h b/apps/codecs/libwmavoice/libavutil/internal.h deleted file mode 100644 index 53d2b94c50..0000000000 --- a/apps/codecs/libwmavoice/libavutil/internal.h +++ /dev/null @@ -1,234 +0,0 @@ -/* - * copyright (c) 2006 Michael Niedermayer - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/** - * @file - * common internal API header - */ - -#ifndef AVUTIL_INTERNAL_H -#define AVUTIL_INTERNAL_H - -#if !defined(DEBUG) && !defined(NDEBUG) -# define NDEBUG -#endif - -#include -#include -#include -#include -#include "config.h" -#include "attributes.h" -#include "timer.h" - -#ifndef attribute_align_arg -#if ARCH_X86_32 && (!defined(__ICC) || __ICC > 1110) && AV_GCC_VERSION_AT_LEAST(4,2) -# define attribute_align_arg __attribute__((force_align_arg_pointer)) -#else -# define attribute_align_arg -#endif -#endif - - -/** - * Mark a variable as used and prevent the compiler from optimizing it away. - * This is useful for asm that accesses varibles in ways that the compiler does not - * understand - */ -#ifndef attribute_used -#if AV_GCC_VERSION_AT_LEAST(3,1) -# define attribute_used __attribute__((used)) -#else -# define attribute_used -#endif -#endif - -#ifndef INT16_MIN -#define INT16_MIN (-0x7fff - 1) -#endif - -#ifndef INT16_MAX -#define INT16_MAX 0x7fff -#endif - -#ifndef INT32_MIN -#define INT32_MIN (-0x7fffffff - 1) -#endif - -#ifndef INT32_MAX -#define INT32_MAX 0x7fffffff -#endif - -#ifndef UINT32_MAX -#define UINT32_MAX 0xffffffff -#endif - -#ifndef INT64_MIN -#define INT64_MIN (-0x7fffffffffffffffLL - 1) -#endif - -#ifndef INT64_MAX -#define INT64_MAX INT64_C(9223372036854775807) -#endif - -#ifndef UINT64_MAX -#define UINT64_MAX UINT64_C(0xFFFFFFFFFFFFFFFF) -#endif - -#ifndef INT_BIT -# define INT_BIT (CHAR_BIT * sizeof(int)) -#endif - -#ifndef offsetof -# define offsetof(T, F) ((unsigned int)((char *)&((T *)0)->F)) -#endif - -/* Use to export labels from asm. */ -#define LABEL_MANGLE(a) EXTERN_PREFIX #a - -// Use rip-relative addressing if compiling PIC code on x86-64. -#if ARCH_X86_64 && defined(PIC) -# define LOCAL_MANGLE(a) #a "(%%rip)" -#else -# define LOCAL_MANGLE(a) #a -#endif - -#define MANGLE(a) EXTERN_PREFIX LOCAL_MANGLE(a) - -/* debug stuff */ - -/* dprintf macros */ -#ifdef DEBUG -# define dprintf(pctx, ...) av_log(pctx, AV_LOG_DEBUG, __VA_ARGS__) -#else -# define dprintf(pctx, ...) -#endif - -#define av_abort() do { av_log(NULL, AV_LOG_ERROR, "Abort at %s:%d\n", __FILE__, __LINE__); abort(); } while (0) - -/* math */ - -#if ARCH_X86 -#define MASK_ABS(mask, level)\ - __asm__ volatile(\ - "cltd \n\t"\ - "xorl %1, %0 \n\t"\ - "subl %1, %0 \n\t"\ - : "+a" (level), "=&d" (mask)\ - ); -#else -#define MASK_ABS(mask, level)\ - mask = level >> 31;\ - level = (level ^ mask) - mask; -#endif - -/* avoid usage of dangerous/inappropriate system functions */ -#undef malloc -#define malloc please_use_av_malloc -#undef free -#define free please_use_av_free -#undef realloc -#define realloc please_use_av_realloc -#undef time -#define time time_is_forbidden_due_to_security_issues -#undef rand -#define rand rand_is_forbidden_due_to_state_trashing_use_av_lfg_get -#undef srand -#define srand srand_is_forbidden_due_to_state_trashing_use_av_lfg_init -#undef random -#define random random_is_forbidden_due_to_state_trashing_use_av_lfg_get -#undef sprintf -#define sprintf sprintf_is_forbidden_due_to_security_issues_use_snprintf -#undef strcat -#define strcat strcat_is_forbidden_due_to_security_issues_use_av_strlcat -#undef exit -#define exit exit_is_forbidden -#ifndef LIBAVFORMAT_BUILD -#undef printf -#define printf please_use_av_log_instead_of_printf -#undef fprintf -#define fprintf please_use_av_log_instead_of_fprintf -#undef puts -#define puts please_use_av_log_instead_of_puts -#undef perror -#define perror please_use_av_log_instead_of_perror -#endif - -#define FF_ALLOC_OR_GOTO(ctx, p, size, label)\ -{\ - p = av_malloc(size);\ - if (p == NULL && (size) != 0) {\ - av_log(ctx, AV_LOG_ERROR, "Cannot allocate memory.\n");\ - goto label;\ - }\ -} - -#define FF_ALLOCZ_OR_GOTO(ctx, p, size, label)\ -{\ - p = av_mallocz(size);\ - if (p == NULL && (size) != 0) {\ - av_log(ctx, AV_LOG_ERROR, "Cannot allocate memory.\n");\ - goto label;\ - }\ -} - -#include "libm.h" - -/** - * Return NULL if CONFIG_SMALL is true, otherwise the argument - * without modification. Used to disable the definition of strings - * (for example AVCodec long_names). - */ -#if CONFIG_SMALL -# define NULL_IF_CONFIG_SMALL(x) NULL -#else -# define NULL_IF_CONFIG_SMALL(x) x -#endif - - -/** - * Define a function with only the non-default version specified. - * - * On systems with ELF shared libraries, all symbols exported from - * FFmpeg libraries are tagged with the name and major version of the - * library to which they belong. If a function is moved from one - * library to another, a wrapper must be retained in the original - * location to preserve binary compatibility. - * - * Functions defined with this macro will never be used to resolve - * symbols by the build-time linker. - * - * @param type return type of function - * @param name name of function - * @param args argument list of function - * @param ver version tag to assign function - */ -#if HAVE_SYMVER_ASM_LABEL -# define FF_SYMVER(type, name, args, ver) \ - type ff_##name args __asm__ (EXTERN_PREFIX #name "@" ver); \ - type ff_##name args -#elif HAVE_SYMVER_GNU_ASM -# define FF_SYMVER(type, name, args, ver) \ - __asm__ (".symver ff_" #name "," EXTERN_PREFIX #name "@" ver); \ - type ff_##name args; \ - type ff_##name args -#endif - -#endif /* AVUTIL_INTERNAL_H */ diff --git a/apps/codecs/libwmavoice/libavutil/intreadwrite.h b/apps/codecs/libwmavoice/libavutil/intreadwrite.h deleted file mode 100644 index 1849a64661..0000000000 --- a/apps/codecs/libwmavoice/libavutil/intreadwrite.h +++ /dev/null @@ -1,522 +0,0 @@ -/* - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef AVUTIL_INTREADWRITE_H -#define AVUTIL_INTREADWRITE_H - -#include -#include "libavutil/avconfig.h" -#include "attributes.h" -#include "bswap.h" - -typedef union { - uint64_t u64; - uint32_t u32[2]; - uint16_t u16[4]; - uint8_t u8 [8]; - double f64; - float f32[2]; -} av_alias av_alias64; - -typedef union { - uint32_t u32; - uint16_t u16[2]; - uint8_t u8 [4]; - float f32; -} av_alias av_alias32; - -typedef union { - uint16_t u16; - uint8_t u8 [2]; -} av_alias av_alias16; - -/* - * Arch-specific headers can provide any combination of - * AV_[RW][BLN](16|24|32|64) and AV_(COPY|SWAP|ZERO)(64|128) macros. - * Preprocessor symbols must be defined, even if these are implemented - * as inline functions. - */ - -#ifdef HAVE_AV_CONFIG_H - -#include "config.h" - -#if ARCH_ARM -# include "arm/intreadwrite.h" -#elif ARCH_AVR32 -# include "avr32/intreadwrite.h" -#elif ARCH_MIPS -# include "mips/intreadwrite.h" -#elif ARCH_PPC -# include "ppc/intreadwrite.h" -#elif ARCH_TOMI -# include "tomi/intreadwrite.h" -#elif ARCH_X86 -# include "x86/intreadwrite.h" -#endif - -#endif /* HAVE_AV_CONFIG_H */ - -/* - * Map AV_RNXX <-> AV_R[BL]XX for all variants provided by per-arch headers. - */ - -#if AV_HAVE_BIGENDIAN - -# if defined(AV_RN16) && !defined(AV_RB16) -# define AV_RB16(p) AV_RN16(p) -# elif !defined(AV_RN16) && defined(AV_RB16) -# define AV_RN16(p) AV_RB16(p) -# endif - -# if defined(AV_WN16) && !defined(AV_WB16) -# define AV_WB16(p, v) AV_WN16(p, v) -# elif !defined(AV_WN16) && defined(AV_WB16) -# define AV_WN16(p, v) AV_WB16(p, v) -# endif - -# if defined(AV_RN24) && !defined(AV_RB24) -# define AV_RB24(p) AV_RN24(p) -# elif !defined(AV_RN24) && defined(AV_RB24) -# define AV_RN24(p) AV_RB24(p) -# endif - -# if defined(AV_WN24) && !defined(AV_WB24) -# define AV_WB24(p, v) AV_WN24(p, v) -# elif !defined(AV_WN24) && defined(AV_WB24) -# define AV_WN24(p, v) AV_WB24(p, v) -# endif - -# if defined(AV_RN32) && !defined(AV_RB32) -# define AV_RB32(p) AV_RN32(p) -# elif !defined(AV_RN32) && defined(AV_RB32) -# define AV_RN32(p) AV_RB32(p) -# endif - -# if defined(AV_WN32) && !defined(AV_WB32) -# define AV_WB32(p, v) AV_WN32(p, v) -# elif !defined(AV_WN32) && defined(AV_WB32) -# define AV_WN32(p, v) AV_WB32(p, v) -# endif - -# if defined(AV_RN64) && !defined(AV_RB64) -# define AV_RB64(p) AV_RN64(p) -# elif !defined(AV_RN64) && defined(AV_RB64) -# define AV_RN64(p) AV_RB64(p) -# endif - -# if defined(AV_WN64) && !defined(AV_WB64) -# define AV_WB64(p, v) AV_WN64(p, v) -# elif !defined(AV_WN64) && defined(AV_WB64) -# define AV_WN64(p, v) AV_WB64(p, v) -# endif - -#else /* AV_HAVE_BIGENDIAN */ - -# if defined(AV_RN16) && !defined(AV_RL16) -# define AV_RL16(p) AV_RN16(p) -# elif !defined(AV_RN16) && defined(AV_RL16) -# define AV_RN16(p) AV_RL16(p) -# endif - -# if defined(AV_WN16) && !defined(AV_WL16) -# define AV_WL16(p, v) AV_WN16(p, v) -# elif !defined(AV_WN16) && defined(AV_WL16) -# define AV_WN16(p, v) AV_WL16(p, v) -# endif - -# if defined(AV_RN24) && !defined(AV_RL24) -# define AV_RL24(p) AV_RN24(p) -# elif !defined(AV_RN24) && defined(AV_RL24) -# define AV_RN24(p) AV_RL24(p) -# endif - -# if defined(AV_WN24) && !defined(AV_WL24) -# define AV_WL24(p, v) AV_WN24(p, v) -# elif !defined(AV_WN24) && defined(AV_WL24) -# define AV_WN24(p, v) AV_WL24(p, v) -# endif - -# if defined(AV_RN32) && !defined(AV_RL32) -# define AV_RL32(p) AV_RN32(p) -# elif !defined(AV_RN32) && defined(AV_RL32) -# define AV_RN32(p) AV_RL32(p) -# endif - -# if defined(AV_WN32) && !defined(AV_WL32) -# define AV_WL32(p, v) AV_WN32(p, v) -# elif !defined(AV_WN32) && defined(AV_WL32) -# define AV_WN32(p, v) AV_WL32(p, v) -# endif - -# if defined(AV_RN64) && !defined(AV_RL64) -# define AV_RL64(p) AV_RN64(p) -# elif !defined(AV_RN64) && defined(AV_RL64) -# define AV_RN64(p) AV_RL64(p) -# endif - -# if defined(AV_WN64) && !defined(AV_WL64) -# define AV_WL64(p, v) AV_WN64(p, v) -# elif !defined(AV_WN64) && defined(AV_WL64) -# define AV_WN64(p, v) AV_WL64(p, v) -# endif - -#endif /* !AV_HAVE_BIGENDIAN */ - -/* - * Define AV_[RW]N helper macros to simplify definitions not provided - * by per-arch headers. - */ - -#if defined(__GNUC__) && !defined(__TI_COMPILER_VERSION__) - -union unaligned_64 { uint64_t l; } __attribute__((packed)) av_alias; -union unaligned_32 { uint32_t l; } __attribute__((packed)) av_alias; -union unaligned_16 { uint16_t l; } __attribute__((packed)) av_alias; - -# define AV_RN(s, p) (((const union unaligned_##s *) (p))->l) -# define AV_WN(s, p, v) ((((union unaligned_##s *) (p))->l) = (v)) - -#elif defined(__DECC) - -# define AV_RN(s, p) (*((const __unaligned uint##s##_t*)(p))) -# define AV_WN(s, p, v) (*((__unaligned uint##s##_t*)(p)) = (v)) - -#elif AV_HAVE_FAST_UNALIGNED - -# define AV_RN(s, p) (((const av_alias##s*)(p))->u##s) -# define AV_WN(s, p, v) (((av_alias##s*)(p))->u##s = (v)) - -#else - -#ifndef AV_RB16 -# define AV_RB16(x) \ - ((((const uint8_t*)(x))[0] << 8) | \ - ((const uint8_t*)(x))[1]) -#endif -#ifndef AV_WB16 -# define AV_WB16(p, d) do { \ - ((uint8_t*)(p))[1] = (d); \ - ((uint8_t*)(p))[0] = (d)>>8; \ - } while(0) -#endif - -#ifndef AV_RL16 -# define AV_RL16(x) \ - ((((const uint8_t*)(x))[1] << 8) | \ - ((const uint8_t*)(x))[0]) -#endif -#ifndef AV_WL16 -# define AV_WL16(p, d) do { \ - ((uint8_t*)(p))[0] = (d); \ - ((uint8_t*)(p))[1] = (d)>>8; \ - } while(0) -#endif - -#ifndef AV_RB32 -# define AV_RB32(x) \ - ((((const uint8_t*)(x))[0] << 24) | \ - (((const uint8_t*)(x))[1] << 16) | \ - (((const uint8_t*)(x))[2] << 8) | \ - ((const uint8_t*)(x))[3]) -#endif -#ifndef AV_WB32 -# define AV_WB32(p, d) do { \ - ((uint8_t*)(p))[3] = (d); \ - ((uint8_t*)(p))[2] = (d)>>8; \ - ((uint8_t*)(p))[1] = (d)>>16; \ - ((uint8_t*)(p))[0] = (d)>>24; \ - } while(0) -#endif - -#ifndef AV_RL32 -# define AV_RL32(x) \ - ((((const uint8_t*)(x))[3] << 24) | \ - (((const uint8_t*)(x))[2] << 16) | \ - (((const uint8_t*)(x))[1] << 8) | \ - ((const uint8_t*)(x))[0]) -#endif -#ifndef AV_WL32 -# define AV_WL32(p, d) do { \ - ((uint8_t*)(p))[0] = (d); \ - ((uint8_t*)(p))[1] = (d)>>8; \ - ((uint8_t*)(p))[2] = (d)>>16; \ - ((uint8_t*)(p))[3] = (d)>>24; \ - } while(0) -#endif - -#ifndef AV_RB64 -# define AV_RB64(x) \ - (((uint64_t)((const uint8_t*)(x))[0] << 56) | \ - ((uint64_t)((const uint8_t*)(x))[1] << 48) | \ - ((uint64_t)((const uint8_t*)(x))[2] << 40) | \ - ((uint64_t)((const uint8_t*)(x))[3] << 32) | \ - ((uint64_t)((const uint8_t*)(x))[4] << 24) | \ - ((uint64_t)((const uint8_t*)(x))[5] << 16) | \ - ((uint64_t)((const uint8_t*)(x))[6] << 8) | \ - (uint64_t)((const uint8_t*)(x))[7]) -#endif -#ifndef AV_WB64 -# define AV_WB64(p, d) do { \ - ((uint8_t*)(p))[7] = (d); \ - ((uint8_t*)(p))[6] = (d)>>8; \ - ((uint8_t*)(p))[5] = (d)>>16; \ - ((uint8_t*)(p))[4] = (d)>>24; \ - ((uint8_t*)(p))[3] = (d)>>32; \ - ((uint8_t*)(p))[2] = (d)>>40; \ - ((uint8_t*)(p))[1] = (d)>>48; \ - ((uint8_t*)(p))[0] = (d)>>56; \ - } while(0) -#endif - -#ifndef AV_RL64 -# define AV_RL64(x) \ - (((uint64_t)((const uint8_t*)(x))[7] << 56) | \ - ((uint64_t)((const uint8_t*)(x))[6] << 48) | \ - ((uint64_t)((const uint8_t*)(x))[5] << 40) | \ - ((uint64_t)((const uint8_t*)(x))[4] << 32) | \ - ((uint64_t)((const uint8_t*)(x))[3] << 24) | \ - ((uint64_t)((const uint8_t*)(x))[2] << 16) | \ - ((uint64_t)((const uint8_t*)(x))[1] << 8) | \ - (uint64_t)((const uint8_t*)(x))[0]) -#endif -#ifndef AV_WL64 -# define AV_WL64(p, d) do { \ - ((uint8_t*)(p))[0] = (d); \ - ((uint8_t*)(p))[1] = (d)>>8; \ - ((uint8_t*)(p))[2] = (d)>>16; \ - ((uint8_t*)(p))[3] = (d)>>24; \ - ((uint8_t*)(p))[4] = (d)>>32; \ - ((uint8_t*)(p))[5] = (d)>>40; \ - ((uint8_t*)(p))[6] = (d)>>48; \ - ((uint8_t*)(p))[7] = (d)>>56; \ - } while(0) -#endif - -#if AV_HAVE_BIGENDIAN -# define AV_RN(s, p) AV_RB##s(p) -# define AV_WN(s, p, v) AV_WB##s(p, v) -#else -# define AV_RN(s, p) AV_RL##s(p) -# define AV_WN(s, p, v) AV_WL##s(p, v) -#endif - -#endif /* HAVE_FAST_UNALIGNED */ - -#ifndef AV_RN16 -# define AV_RN16(p) AV_RN(16, p) -#endif - -#ifndef AV_RN32 -# define AV_RN32(p) AV_RN(32, p) -#endif - -#ifndef AV_RN64 -# define AV_RN64(p) AV_RN(64, p) -#endif - -#ifndef AV_WN16 -# define AV_WN16(p, v) AV_WN(16, p, v) -#endif - -#ifndef AV_WN32 -# define AV_WN32(p, v) AV_WN(32, p, v) -#endif - -#ifndef AV_WN64 -# define AV_WN64(p, v) AV_WN(64, p, v) -#endif - -#if AV_HAVE_BIGENDIAN -# define AV_RB(s, p) AV_RN##s(p) -# define AV_WB(s, p, v) AV_WN##s(p, v) -# define AV_RL(s, p) av_bswap##s(AV_RN##s(p)) -# define AV_WL(s, p, v) AV_WN##s(p, av_bswap##s(v)) -#else -# define AV_RB(s, p) av_bswap##s(AV_RN##s(p)) -# define AV_WB(s, p, v) AV_WN##s(p, av_bswap##s(v)) -# define AV_RL(s, p) AV_RN##s(p) -# define AV_WL(s, p, v) AV_WN##s(p, v) -#endif - -#define AV_RB8(x) (((const uint8_t*)(x))[0]) -#define AV_WB8(p, d) do { ((uint8_t*)(p))[0] = (d); } while(0) - -#define AV_RL8(x) AV_RB8(x) -#define AV_WL8(p, d) AV_WB8(p, d) - -#ifndef AV_RB16 -# define AV_RB16(p) AV_RB(16, p) -#endif -#ifndef AV_WB16 -# define AV_WB16(p, v) AV_WB(16, p, v) -#endif - -#ifndef AV_RL16 -# define AV_RL16(p) AV_RL(16, p) -#endif -#ifndef AV_WL16 -# define AV_WL16(p, v) AV_WL(16, p, v) -#endif - -#ifndef AV_RB32 -# define AV_RB32(p) AV_RB(32, p) -#endif -#ifndef AV_WB32 -# define AV_WB32(p, v) AV_WB(32, p, v) -#endif - -#ifndef AV_RL32 -# define AV_RL32(p) AV_RL(32, p) -#endif -#ifndef AV_WL32 -# define AV_WL32(p, v) AV_WL(32, p, v) -#endif - -#ifndef AV_RB64 -# define AV_RB64(p) AV_RB(64, p) -#endif -#ifndef AV_WB64 -# define AV_WB64(p, v) AV_WB(64, p, v) -#endif - -#ifndef AV_RL64 -# define AV_RL64(p) AV_RL(64, p) -#endif -#ifndef AV_WL64 -# define AV_WL64(p, v) AV_WL(64, p, v) -#endif - -#ifndef AV_RB24 -# define AV_RB24(x) \ - ((((const uint8_t*)(x))[0] << 16) | \ - (((const uint8_t*)(x))[1] << 8) | \ - ((const uint8_t*)(x))[2]) -#endif -#ifndef AV_WB24 -# define AV_WB24(p, d) do { \ - ((uint8_t*)(p))[2] = (d); \ - ((uint8_t*)(p))[1] = (d)>>8; \ - ((uint8_t*)(p))[0] = (d)>>16; \ - } while(0) -#endif - -#ifndef AV_RL24 -# define AV_RL24(x) \ - ((((const uint8_t*)(x))[2] << 16) | \ - (((const uint8_t*)(x))[1] << 8) | \ - ((const uint8_t*)(x))[0]) -#endif -#ifndef AV_WL24 -# define AV_WL24(p, d) do { \ - ((uint8_t*)(p))[0] = (d); \ - ((uint8_t*)(p))[1] = (d)>>8; \ - ((uint8_t*)(p))[2] = (d)>>16; \ - } while(0) -#endif - -/* - * The AV_[RW]NA macros access naturally aligned data - * in a type-safe way. - */ - -#define AV_RNA(s, p) (((const av_alias##s*)(p))->u##s) -#define AV_WNA(s, p, v) (((av_alias##s*)(p))->u##s = (v)) - -#ifndef AV_RN16A -# define AV_RN16A(p) AV_RNA(16, p) -#endif - -#ifndef AV_RN32A -# define AV_RN32A(p) AV_RNA(32, p) -#endif - -#ifndef AV_RN64A -# define AV_RN64A(p) AV_RNA(64, p) -#endif - -#ifndef AV_WN16A -# define AV_WN16A(p, v) AV_WNA(16, p, v) -#endif - -#ifndef AV_WN32A -# define AV_WN32A(p, v) AV_WNA(32, p, v) -#endif - -#ifndef AV_WN64A -# define AV_WN64A(p, v) AV_WNA(64, p, v) -#endif - -/* Parameters for AV_COPY*, AV_SWAP*, AV_ZERO* must be - * naturally aligned. They may be implemented using MMX, - * so emms_c() must be called before using any float code - * afterwards. - */ - -#define AV_COPY(n, d, s) \ - (((av_alias##n*)(d))->u##n = ((const av_alias##n*)(s))->u##n) - -#ifndef AV_COPY16 -# define AV_COPY16(d, s) AV_COPY(16, d, s) -#endif - -#ifndef AV_COPY32 -# define AV_COPY32(d, s) AV_COPY(32, d, s) -#endif - -#ifndef AV_COPY64 -# define AV_COPY64(d, s) AV_COPY(64, d, s) -#endif - -#ifndef AV_COPY128 -# define AV_COPY128(d, s) \ - do { \ - AV_COPY64(d, s); \ - AV_COPY64((char*)(d)+8, (char*)(s)+8); \ - } while(0) -#endif - -#define AV_SWAP(n, a, b) FFSWAP(av_alias##n, *(av_alias##n*)(a), *(av_alias##n*)(b)) - -#ifndef AV_SWAP64 -# define AV_SWAP64(a, b) AV_SWAP(64, a, b) -#endif - -#define AV_ZERO(n, d) (((av_alias##n*)(d))->u##n = 0) - -#ifndef AV_ZERO16 -# define AV_ZERO16(d) AV_ZERO(16, d) -#endif - -#ifndef AV_ZERO32 -# define AV_ZERO32(d) AV_ZERO(32, d) -#endif - -#ifndef AV_ZERO64 -# define AV_ZERO64(d) AV_ZERO(64, d) -#endif - -#ifndef AV_ZERO128 -# define AV_ZERO128(d) \ - do { \ - AV_ZERO64(d); \ - AV_ZERO64((char*)(d)+8); \ - } while(0) -#endif - -#endif /* AVUTIL_INTREADWRITE_H */ diff --git a/apps/codecs/libwmavoice/libavutil/log.c b/apps/codecs/libwmavoice/libavutil/log.c deleted file mode 100644 index 2e225b3b50..0000000000 --- a/apps/codecs/libwmavoice/libavutil/log.c +++ /dev/null @@ -1,150 +0,0 @@ -/* - * log functions - * Copyright (c) 2003 Michel Bardiaux - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/** - * @file - * logging functions - */ - -#include -#include -#include "avutil.h" -#include "log.h" - -#if LIBAVUTIL_VERSION_MAJOR > 50 -static -#endif -int av_log_level = AV_LOG_INFO; - -#if defined(_WIN32) && !defined(__MINGW32CE__) -#include -static const uint8_t color[] = {12,12,12,14,7,7,7}; -static int16_t background, attr_orig; -static HANDLE con; -#define set_color(x) SetConsoleTextAttribute(con, background | color[x]) -#define reset_color() SetConsoleTextAttribute(con, attr_orig) -#else -static const uint8_t color[]={0x41,0x41,0x11,0x03,9,9,9}; -#define set_color(x) fprintf(stderr, "\033[%d;3%dm", color[x]>>4, color[x]&15) -#define reset_color() fprintf(stderr, "\033[0m") -#endif -static int use_color=-1; - -#undef fprintf -static void colored_fputs(int level, const char *str){ - if(use_color<0){ -#if defined(_WIN32) && !defined(__MINGW32CE__) - CONSOLE_SCREEN_BUFFER_INFO con_info; - con = GetStdHandle(STD_ERROR_HANDLE); - use_color = (con != INVALID_HANDLE_VALUE) && !getenv("NO_COLOR"); - if (use_color) { - GetConsoleScreenBufferInfo(con, &con_info); - attr_orig = con_info.wAttributes; - background = attr_orig & 0xF0; - } -#elif HAVE_ISATTY - use_color= getenv("TERM") && !getenv("NO_COLOR") && isatty(2); -#else - use_color= 0; -#endif - } - - if(use_color){ - set_color(level); - } - fputs(str, stderr); - if(use_color){ - reset_color(); - } -} - -const char* av_default_item_name(void* ptr){ - return (*(AVClass**)ptr)->class_name; -} - -void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl) -{ - static int print_prefix=1; - static int count; - static char line[1024], prev[1024]; - AVClass* avc= ptr ? *(AVClass**)ptr : NULL; - if(level>av_log_level) - return; - line[0]=0; -#undef fprintf - if(print_prefix && avc) { - if(avc->version >= (50<<16 | 15<<8 | 3) && avc->parent_log_context_offset){ - AVClass** parent= *(AVClass***)(((uint8_t*)ptr) + avc->parent_log_context_offset); - if(parent && *parent){ - snprintf(line, sizeof(line), "[%s @ %p] ", (*parent)->item_name(parent), parent); - } - } - snprintf(line + strlen(line), sizeof(line) - strlen(line), "[%s @ %p] ", avc->item_name(ptr), ptr); - } - - vsnprintf(line + strlen(line), sizeof(line) - strlen(line), fmt, vl); - - print_prefix= line[strlen(line)-1] == '\n'; - if(print_prefix && !strcmp(line, prev)){ - count++; - fprintf(stderr, " Last message repeated %d times\r", count); - return; - } - if(count>0){ - fprintf(stderr, " Last message repeated %d times\n", count); - count=0; - } - colored_fputs(av_clip(level>>3, 0, 6), line); - strcpy(prev, line); -} - -static void (*av_log_callback)(void*, int, const char*, va_list) = av_log_default_callback; - -void av_log(void* avcl, int level, const char *fmt, ...) -{ - AVClass* avc= avcl ? *(AVClass**)avcl : NULL; - va_list vl; - va_start(vl, fmt); - if(avc && avc->version >= (50<<16 | 15<<8 | 2) && avc->log_level_offset_offset && level>=AV_LOG_FATAL) - level += *(int*)(((uint8_t*)avcl) + avc->log_level_offset_offset); - av_vlog(avcl, level, fmt, vl); - va_end(vl); -} - -void av_vlog(void* avcl, int level, const char *fmt, va_list vl) -{ - av_log_callback(avcl, level, fmt, vl); -} - -int av_log_get_level(void) -{ - return av_log_level; -} - -void av_log_set_level(int level) -{ - av_log_level = level; -} - -void av_log_set_callback(void (*callback)(void*, int, const char*, va_list)) -{ - av_log_callback = callback; -} diff --git a/apps/codecs/libwmavoice/libavutil/log.h b/apps/codecs/libwmavoice/libavutil/log.h deleted file mode 100644 index 831c26eae6..0000000000 --- a/apps/codecs/libwmavoice/libavutil/log.h +++ /dev/null @@ -1,138 +0,0 @@ -/* - * copyright (c) 2006 Michael Niedermayer - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef AVUTIL_LOG_H -#define AVUTIL_LOG_H - -#include -#include "avutil.h" - -/** - * Describe the class of an AVClass context structure. That is an - * arbitrary struct of which the first field is a pointer to an - * AVClass struct (e.g. AVCodecContext, AVFormatContext etc.). - */ -typedef struct { - /** - * The name of the class; usually it is the same name as the - * context structure type to which the AVClass is associated. - */ - const char* class_name; - - /** - * A pointer to a function which returns the name of a context - * instance ctx associated with the class. - */ - const char* (*item_name)(void* ctx); - - /** - * a pointer to the first option specified in the class if any or NULL - * - * @see av_set_default_options() - */ - const struct AVOption *option; - - /** - * LIBAVUTIL_VERSION with which this structure was created. - * This is used to allow fields to be added without requiring major - * version bumps everywhere. - */ - - int version; - - /** - * Offset in the structure where log_level_offset is stored. - * 0 means there is no such variable - */ - int log_level_offset_offset; - - /** - * Offset in the structure where a pointer to the parent context for loging is stored. - * for example a decoder that uses eval.c could pass its AVCodecContext to eval as such - * parent context. And a av_log() implementation could then display the parent context - * can be NULL of course - */ - int parent_log_context_offset; -} AVClass; - -/* av_log API */ - -#define AV_LOG_QUIET -8 - -/** - * Something went really wrong and we will crash now. - */ -#define AV_LOG_PANIC 0 - -/** - * Something went wrong and recovery is not possible. - * For example, no header was found for a format which depends - * on headers or an illegal combination of parameters is used. - */ -#define AV_LOG_FATAL 8 - -/** - * Something went wrong and cannot losslessly be recovered. - * However, not all future data is affected. - */ -#define AV_LOG_ERROR 16 - -/** - * Something somehow does not look correct. This may or may not - * lead to problems. An example would be the use of '-vstrict -2'. - */ -#define AV_LOG_WARNING 24 - -#define AV_LOG_INFO 32 -#define AV_LOG_VERBOSE 40 - -/** - * Stuff which is only useful for libav* developers. - */ -#define AV_LOG_DEBUG 48 - -/** - * Send the specified message to the log if the level is less than or equal - * to the current av_log_level. By default, all logging messages are sent to - * stderr. This behavior can be altered by setting a different av_vlog callback - * function. - * - * @param avcl A pointer to an arbitrary struct of which the first field is a - * pointer to an AVClass struct. - * @param level The importance level of the message, lower values signifying - * higher importance. - * @param fmt The format string (printf-compatible) that specifies how - * subsequent arguments are converted to output. - * @see av_vlog - */ -#ifdef __GNUC__ -void av_log(void *avcl, int level, const char *fmt, ...) __attribute__ ((__format__ (__printf__, 3, 4))); -#else -void av_log(void *avcl, int level, const char *fmt, ...); -#endif - -void av_vlog(void *avcl, int level, const char *fmt, va_list); -int av_log_get_level(void); -void av_log_set_level(int); -void av_log_set_callback(void (*)(void*, int, const char*, va_list)); -void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl); -const char* av_default_item_name(void* ctx); - -#endif /* AVUTIL_LOG_H */ diff --git a/apps/codecs/libwmavoice/libavutil/lzo.c b/apps/codecs/libwmavoice/libavutil/lzo.c deleted file mode 100644 index 7f07cc2ee5..0000000000 --- a/apps/codecs/libwmavoice/libavutil/lzo.c +++ /dev/null @@ -1,280 +0,0 @@ -/* - * LZO 1x decompression - * Copyright (c) 2006 Reimar Doeffinger - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "avutil.h" -#include "common.h" -//! Avoid e.g. MPlayers fast_memcpy, it slows things down here. -#undef memcpy -#include -#include "lzo.h" - -//! Define if we may write up to 12 bytes beyond the output buffer. -#define OUTBUF_PADDED 1 -//! Define if we may read up to 8 bytes beyond the input buffer. -#define INBUF_PADDED 1 -typedef struct LZOContext { - const uint8_t *in, *in_end; - uint8_t *out_start, *out, *out_end; - int error; -} LZOContext; - -/** - * \brief Reads one byte from the input buffer, avoiding an overrun. - * \return byte read - */ -static inline int get_byte(LZOContext *c) { - if (c->in < c->in_end) - return *c->in++; - c->error |= AV_LZO_INPUT_DEPLETED; - return 1; -} - -#ifdef INBUF_PADDED -#define GETB(c) (*(c).in++) -#else -#define GETB(c) get_byte(&(c)) -#endif - -/** - * \brief Decodes a length value in the coding used by lzo. - * \param x previous byte value - * \param mask bits used from x - * \return decoded length value - */ -static inline int get_len(LZOContext *c, int x, int mask) { - int cnt = x & mask; - if (!cnt) { - while (!(x = get_byte(c))) cnt += 255; - cnt += mask + x; - } - return cnt; -} - -//#define UNALIGNED_LOADSTORE -#define BUILTIN_MEMCPY -#ifdef UNALIGNED_LOADSTORE -#define COPY2(d, s) *(uint16_t *)(d) = *(uint16_t *)(s); -#define COPY4(d, s) *(uint32_t *)(d) = *(uint32_t *)(s); -#elif defined(BUILTIN_MEMCPY) -#define COPY2(d, s) memcpy(d, s, 2); -#define COPY4(d, s) memcpy(d, s, 4); -#else -#define COPY2(d, s) (d)[0] = (s)[0]; (d)[1] = (s)[1]; -#define COPY4(d, s) (d)[0] = (s)[0]; (d)[1] = (s)[1]; (d)[2] = (s)[2]; (d)[3] = (s)[3]; -#endif - -/** - * \brief Copies bytes from input to output buffer with checking. - * \param cnt number of bytes to copy, must be >= 0 - */ -static inline void copy(LZOContext *c, int cnt) { - register const uint8_t *src = c->in; - register uint8_t *dst = c->out; - if (cnt > c->in_end - src) { - cnt = FFMAX(c->in_end - src, 0); - c->error |= AV_LZO_INPUT_DEPLETED; - } - if (cnt > c->out_end - dst) { - cnt = FFMAX(c->out_end - dst, 0); - c->error |= AV_LZO_OUTPUT_FULL; - } -#if defined(INBUF_PADDED) && defined(OUTBUF_PADDED) - COPY4(dst, src); - src += 4; - dst += 4; - cnt -= 4; - if (cnt > 0) -#endif - memcpy(dst, src, cnt); - c->in = src + cnt; - c->out = dst + cnt; -} - -static inline void memcpy_backptr(uint8_t *dst, int back, int cnt); - -/** - * \brief Copies previously decoded bytes to current position. - * \param back how many bytes back we start - * \param cnt number of bytes to copy, must be >= 0 - * - * cnt > back is valid, this will copy the bytes we just copied, - * thus creating a repeating pattern with a period length of back. - */ -static inline void copy_backptr(LZOContext *c, int back, int cnt) { - register const uint8_t *src = &c->out[-back]; - register uint8_t *dst = c->out; - if (src < c->out_start || src > dst) { - c->error |= AV_LZO_INVALID_BACKPTR; - return; - } - if (cnt > c->out_end - dst) { - cnt = FFMAX(c->out_end - dst, 0); - c->error |= AV_LZO_OUTPUT_FULL; - } - memcpy_backptr(dst, back, cnt); - c->out = dst + cnt; -} - -static inline void memcpy_backptr(uint8_t *dst, int back, int cnt) { - const uint8_t *src = &dst[-back]; - if (back == 1) { - memset(dst, *src, cnt); - } else { -#ifdef OUTBUF_PADDED - COPY2(dst, src); - COPY2(dst + 2, src + 2); - src += 4; - dst += 4; - cnt -= 4; - if (cnt > 0) { - COPY2(dst, src); - COPY2(dst + 2, src + 2); - COPY2(dst + 4, src + 4); - COPY2(dst + 6, src + 6); - src += 8; - dst += 8; - cnt -= 8; - } -#endif - if (cnt > 0) { - int blocklen = back; - while (cnt > blocklen) { - memcpy(dst, src, blocklen); - dst += blocklen; - cnt -= blocklen; - blocklen <<= 1; - } - memcpy(dst, src, cnt); - } - } -} - -void av_memcpy_backptr(uint8_t *dst, int back, int cnt) { - memcpy_backptr(dst, back, cnt); -} - -int av_lzo1x_decode(void *out, int *outlen, const void *in, int *inlen) { - int state= 0; - int x; - LZOContext c; - c.in = in; - c.in_end = (const uint8_t *)in + *inlen; - c.out = c.out_start = out; - c.out_end = (uint8_t *)out + * outlen; - c.error = 0; - x = GETB(c); - if (x > 17) { - copy(&c, x - 17); - x = GETB(c); - if (x < 16) c.error |= AV_LZO_ERROR; - } - if (c.in > c.in_end) - c.error |= AV_LZO_INPUT_DEPLETED; - while (!c.error) { - int cnt, back; - if (x > 15) { - if (x > 63) { - cnt = (x >> 5) - 1; - back = (GETB(c) << 3) + ((x >> 2) & 7) + 1; - } else if (x > 31) { - cnt = get_len(&c, x, 31); - x = GETB(c); - back = (GETB(c) << 6) + (x >> 2) + 1; - } else { - cnt = get_len(&c, x, 7); - back = (1 << 14) + ((x & 8) << 11); - x = GETB(c); - back += (GETB(c) << 6) + (x >> 2); - if (back == (1 << 14)) { - if (cnt != 1) - c.error |= AV_LZO_ERROR; - break; - } - } - } else if(!state){ - cnt = get_len(&c, x, 15); - copy(&c, cnt + 3); - x = GETB(c); - if (x > 15) - continue; - cnt = 1; - back = (1 << 11) + (GETB(c) << 2) + (x >> 2) + 1; - } else { - cnt = 0; - back = (GETB(c) << 2) + (x >> 2) + 1; - } - copy_backptr(&c, back, cnt + 2); - state= - cnt = x & 3; - copy(&c, cnt); - x = GETB(c); - } - *inlen = c.in_end - c.in; - if (c.in > c.in_end) - *inlen = 0; - *outlen = c.out_end - c.out; - return c.error; -} - -#ifdef TEST -#include -#include -#include "log.h" -#define MAXSZ (10*1024*1024) - -/* Define one of these to 1 if you wish to benchmark liblzo - * instead of our native implementation. */ -#define BENCHMARK_LIBLZO_SAFE 0 -#define BENCHMARK_LIBLZO_UNSAFE 0 - -int main(int argc, char *argv[]) { - FILE *in = fopen(argv[1], "rb"); - uint8_t *orig = av_malloc(MAXSZ + 16); - uint8_t *comp = av_malloc(2*MAXSZ + 16); - uint8_t *decomp = av_malloc(MAXSZ + 16); - size_t s = fread(orig, 1, MAXSZ, in); - lzo_uint clen = 0; - long tmp[LZO1X_MEM_COMPRESS]; - int inlen, outlen; - int i; - av_log_set_level(AV_LOG_DEBUG); - lzo1x_999_compress(orig, s, comp, &clen, tmp); - for (i = 0; i < 300; i++) { -START_TIMER - inlen = clen; outlen = MAXSZ; -#if BENCHMARK_LIBLZO_SAFE - if (lzo1x_decompress_safe(comp, inlen, decomp, &outlen, NULL)) -#elif BENCHMARK_LIBLZO_UNSAFE - if (lzo1x_decompress(comp, inlen, decomp, &outlen, NULL)) -#else - if (av_lzo1x_decode(decomp, &outlen, comp, &inlen)) -#endif - av_log(NULL, AV_LOG_ERROR, "decompression error\n"); -STOP_TIMER("lzod") - } - if (memcmp(orig, decomp, s)) - av_log(NULL, AV_LOG_ERROR, "decompression incorrect\n"); - else - av_log(NULL, AV_LOG_ERROR, "decompression OK\n"); - fclose(in); - return 0; -} -#endif diff --git a/apps/codecs/libwmavoice/libavutil/lzo.h b/apps/codecs/libwmavoice/libavutil/lzo.h deleted file mode 100644 index 6788054bff..0000000000 --- a/apps/codecs/libwmavoice/libavutil/lzo.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - * LZO 1x decompression - * copyright (c) 2006 Reimar Doeffinger - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef AVUTIL_LZO_H -#define AVUTIL_LZO_H - -#include - -/** \defgroup errflags Error flags returned by av_lzo1x_decode - * \{ */ -//! end of the input buffer reached before decoding finished -#define AV_LZO_INPUT_DEPLETED 1 -//! decoded data did not fit into output buffer -#define AV_LZO_OUTPUT_FULL 2 -//! a reference to previously decoded data was wrong -#define AV_LZO_INVALID_BACKPTR 4 -//! a non-specific error in the compressed bitstream -#define AV_LZO_ERROR 8 -/** \} */ - -#define AV_LZO_INPUT_PADDING 8 -#define AV_LZO_OUTPUT_PADDING 12 - -/** - * \brief Decodes LZO 1x compressed data. - * \param out output buffer - * \param outlen size of output buffer, number of bytes left are returned here - * \param in input buffer - * \param inlen size of input buffer, number of bytes left are returned here - * \return 0 on success, otherwise a combination of the error flags above - * - * Make sure all buffers are appropriately padded, in must provide - * AV_LZO_INPUT_PADDING, out must provide AV_LZO_OUTPUT_PADDING additional bytes. - */ -int av_lzo1x_decode(void *out, int *outlen, const void *in, int *inlen); - -/** - * \brief deliberately overlapping memcpy implementation - * \param dst destination buffer; must be padded with 12 additional bytes - * \param back how many bytes back we start (the initial size of the overlapping window) - * \param cnt number of bytes to copy, must be >= 0 - * - * cnt > back is valid, this will copy the bytes we just copied, - * thus creating a repeating pattern with a period length of back. - */ -void av_memcpy_backptr(uint8_t *dst, int back, int cnt); - -#endif /* AVUTIL_LZO_H */ diff --git a/apps/codecs/libwmavoice/libavutil/mathematics.c b/apps/codecs/libwmavoice/libavutil/mathematics.c deleted file mode 100644 index c4fbe3b7bc..0000000000 --- a/apps/codecs/libwmavoice/libavutil/mathematics.c +++ /dev/null @@ -1,183 +0,0 @@ -/* - * Copyright (c) 2005 Michael Niedermayer - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/** - * @file - * miscellaneous math routines and tables - */ - -#include -#include -#include -#include "mathematics.h" - -const uint8_t ff_sqrt_tab[256]={ - 0, 16, 23, 28, 32, 36, 40, 43, 46, 48, 51, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 77, 79, 80, 82, 84, 85, 87, 88, 90, - 91, 92, 94, 95, 96, 98, 99,100,102,103,104,105,107,108,109,110,111,112,114,115,116,117,118,119,120,121,122,123,124,125,126,127, -128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,144,145,146,147,148,149,150,151,151,152,153,154,155,156,156, -157,158,159,160,160,161,162,163,164,164,165,166,167,168,168,169,170,171,171,172,173,174,174,175,176,176,177,178,179,179,180,181, -182,182,183,184,184,185,186,186,187,188,188,189,190,190,191,192,192,193,194,194,195,196,196,197,198,198,199,200,200,201,202,202, -203,204,204,205,205,206,207,207,208,208,209,210,210,211,212,212,213,213,214,215,215,216,216,217,218,218,219,219,220,220,221,222, -222,223,223,224,224,225,226,226,227,227,228,228,229,230,230,231,231,232,232,233,233,234,235,235,236,236,237,237,238,238,239,239, -240,240,241,242,242,243,243,244,244,245,245,246,246,247,247,248,248,249,249,250,250,251,251,252,252,253,253,254,254,255,255,255 -}; - -const uint8_t ff_log2_tab[256]={ - 0,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, - 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, - 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, - 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7 -}; - -const uint8_t av_reverse[256]={ -0x00,0x80,0x40,0xC0,0x20,0xA0,0x60,0xE0,0x10,0x90,0x50,0xD0,0x30,0xB0,0x70,0xF0, -0x08,0x88,0x48,0xC8,0x28,0xA8,0x68,0xE8,0x18,0x98,0x58,0xD8,0x38,0xB8,0x78,0xF8, -0x04,0x84,0x44,0xC4,0x24,0xA4,0x64,0xE4,0x14,0x94,0x54,0xD4,0x34,0xB4,0x74,0xF4, -0x0C,0x8C,0x4C,0xCC,0x2C,0xAC,0x6C,0xEC,0x1C,0x9C,0x5C,0xDC,0x3C,0xBC,0x7C,0xFC, -0x02,0x82,0x42,0xC2,0x22,0xA2,0x62,0xE2,0x12,0x92,0x52,0xD2,0x32,0xB2,0x72,0xF2, -0x0A,0x8A,0x4A,0xCA,0x2A,0xAA,0x6A,0xEA,0x1A,0x9A,0x5A,0xDA,0x3A,0xBA,0x7A,0xFA, -0x06,0x86,0x46,0xC6,0x26,0xA6,0x66,0xE6,0x16,0x96,0x56,0xD6,0x36,0xB6,0x76,0xF6, -0x0E,0x8E,0x4E,0xCE,0x2E,0xAE,0x6E,0xEE,0x1E,0x9E,0x5E,0xDE,0x3E,0xBE,0x7E,0xFE, -0x01,0x81,0x41,0xC1,0x21,0xA1,0x61,0xE1,0x11,0x91,0x51,0xD1,0x31,0xB1,0x71,0xF1, -0x09,0x89,0x49,0xC9,0x29,0xA9,0x69,0xE9,0x19,0x99,0x59,0xD9,0x39,0xB9,0x79,0xF9, -0x05,0x85,0x45,0xC5,0x25,0xA5,0x65,0xE5,0x15,0x95,0x55,0xD5,0x35,0xB5,0x75,0xF5, -0x0D,0x8D,0x4D,0xCD,0x2D,0xAD,0x6D,0xED,0x1D,0x9D,0x5D,0xDD,0x3D,0xBD,0x7D,0xFD, -0x03,0x83,0x43,0xC3,0x23,0xA3,0x63,0xE3,0x13,0x93,0x53,0xD3,0x33,0xB3,0x73,0xF3, -0x0B,0x8B,0x4B,0xCB,0x2B,0xAB,0x6B,0xEB,0x1B,0x9B,0x5B,0xDB,0x3B,0xBB,0x7B,0xFB, -0x07,0x87,0x47,0xC7,0x27,0xA7,0x67,0xE7,0x17,0x97,0x57,0xD7,0x37,0xB7,0x77,0xF7, -0x0F,0x8F,0x4F,0xCF,0x2F,0xAF,0x6F,0xEF,0x1F,0x9F,0x5F,0xDF,0x3F,0xBF,0x7F,0xFF, -}; - -int64_t av_gcd(int64_t a, int64_t b){ - if(b) return av_gcd(b, a%b); - else return a; -} - -int64_t av_rescale_rnd(int64_t a, int64_t b, int64_t c, enum AVRounding rnd){ - int64_t r=0; - assert(c > 0); - assert(b >=0); - assert((unsigned)rnd<=5 && rnd!=4); - - if(a<0 && a != INT64_MIN) return -av_rescale_rnd(-a, b, c, rnd ^ ((rnd>>1)&1)); - - if(rnd==AV_ROUND_NEAR_INF) r= c/2; - else if(rnd&1) r= c-1; - - if(b<=INT_MAX && c<=INT_MAX){ - if(a<=INT_MAX) - return (a * b + r)/c; - else - return a/c*b + (a%c*b + r)/c; - }else{ -#if 1 - uint64_t a0= a&0xFFFFFFFF; - uint64_t a1= a>>32; - uint64_t b0= b&0xFFFFFFFF; - uint64_t b1= b>>32; - uint64_t t1= a0*b1 + a1*b0; - uint64_t t1a= t1<<32; - int i; - - a0 = a0*b0 + t1a; - a1 = a1*b1 + (t1>>32) + (a0=0; i--){ -// int o= a1 & 0x8000000000000000ULL; - a1+= a1 + ((a0>>i)&1); - t1+=t1; - if(/*o || */c <= a1){ - a1 -= c; - t1++; - } - } - return t1; - } -#else - AVInteger ai; - ai= av_mul_i(av_int2i(a), av_int2i(b)); - ai= av_add_i(ai, av_int2i(r)); - - return av_i2int(av_div_i(ai, av_int2i(c))); - } -#endif -} - -int64_t av_rescale(int64_t a, int64_t b, int64_t c){ - return av_rescale_rnd(a, b, c, AV_ROUND_NEAR_INF); -} - -#if 0 -int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq){ - int64_t b= bq.num * (int64_t)cq.den; - int64_t c= cq.num * (int64_t)bq.den; - return av_rescale_rnd(a, b, c, AV_ROUND_NEAR_INF); -} - -int av_compare_ts(int64_t ts_a, AVRational tb_a, int64_t ts_b, AVRational tb_b){ - int64_t a= tb_a.num * (int64_t)tb_b.den; - int64_t b= tb_b.num * (int64_t)tb_a.den; - if (av_rescale_rnd(ts_a, a, b, AV_ROUND_DOWN) < ts_b) return -1; - if (av_rescale_rnd(ts_b, b, a, AV_ROUND_DOWN) < ts_a) return 1; - return 0; -} -#endif - -int64_t av_compare_mod(uint64_t a, uint64_t b, uint64_t mod){ - int64_t c= (a-b) & (mod-1); - if(c > (mod>>1)) - c-= mod; - return c; -} - -#ifdef TEST -#include "integer.h" -#undef printf -int main(void){ - int64_t a,b,c,d,e; - - for(a=7; a<(1LL<<62); a+=a/3+1){ - for(b=3; b<(1LL<<62); b+=b/4+1){ - for(c=9; c<(1LL<<62); c+=(c*2)/5+3){ - int64_t r= c/2; - AVInteger ai; - ai= av_mul_i(av_int2i(a), av_int2i(b)); - ai= av_add_i(ai, av_int2i(r)); - - d= av_i2int(av_div_i(ai, av_int2i(c))); - - e= av_rescale(a,b,c); - - if((double)a * (double)b / (double)c > (1LL<<63)) - continue; - - if(d!=e) printf("%"PRId64"*%"PRId64"/%"PRId64"= %"PRId64"=%"PRId64"\n", a, b, c, d, e); - } - } - } - return 0; -} -#endif diff --git a/apps/codecs/libwmavoice/libavutil/mathematics.h b/apps/codecs/libwmavoice/libavutil/mathematics.h deleted file mode 100644 index e07d4fe807..0000000000 --- a/apps/codecs/libwmavoice/libavutil/mathematics.h +++ /dev/null @@ -1,112 +0,0 @@ -/* - * copyright (c) 2005 Michael Niedermayer - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef AVUTIL_MATHEMATICS_H -#define AVUTIL_MATHEMATICS_H - -#include -#include -#include "attributes.h" -//#include "rational.h" - -#ifndef M_E -#define M_E 2.7182818284590452354 /* e */ -#endif -#ifndef M_LN2 -#define M_LN2 0.69314718055994530942 /* log_e 2 */ -#endif -#ifndef M_LN10 -#define M_LN10 2.30258509299404568402 /* log_e 10 */ -#endif -#ifndef M_LOG2_10 -#define M_LOG2_10 3.32192809488736234787 /* log_2 10 */ -#endif -#ifndef M_PHI -#define M_PHI 1.61803398874989484820 /* phi / golden ratio */ -#endif -#ifndef M_PI -#define M_PI 3.14159265358979323846 /* pi */ -#endif -#ifndef M_SQRT1_2 -#define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */ -#endif -#ifndef M_SQRT2 -#define M_SQRT2 1.41421356237309504880 /* sqrt(2) */ -#endif -#ifndef NAN -#define NAN (0.0/0.0) -#endif -#ifndef INFINITY -#define INFINITY (1.0/0.0) -#endif - -enum AVRounding { - AV_ROUND_ZERO = 0, ///< Round toward zero. - AV_ROUND_INF = 1, ///< Round away from zero. - AV_ROUND_DOWN = 2, ///< Round toward -infinity. - AV_ROUND_UP = 3, ///< Round toward +infinity. - AV_ROUND_NEAR_INF = 5, ///< Round to nearest and halfway cases away from zero. -}; - -/** - * Return the greatest common divisor of a and b. - * If both a and b are 0 or either or both are <0 then behavior is - * undefined. - */ -int64_t av_const av_gcd(int64_t a, int64_t b); - -/** - * Rescale a 64-bit integer with rounding to nearest. - * A simple a*b/c isn't possible as it can overflow. - */ -int64_t av_rescale(int64_t a, int64_t b, int64_t c) av_const; - -/** - * Rescale a 64-bit integer with specified rounding. - * A simple a*b/c isn't possible as it can overflow. - */ -int64_t av_rescale_rnd(int64_t a, int64_t b, int64_t c, enum AVRounding) av_const; - -/** - * Rescale a 64-bit integer by 2 rational numbers. - */ -//int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq) av_const; - -/** - * Compare 2 timestamps each in its own timebases. - * The result of the function is undefined if one of the timestamps - * is outside the int64_t range when represented in the others timebase. - * @return -1 if ts_a is before ts_b, 1 if ts_a is after ts_b or 0 if they represent the same position - */ -//int av_compare_ts(int64_t ts_a, AVRational tb_a, int64_t ts_b, AVRational tb_b); - -/** - * Compare 2 integers modulo mod. - * That is we compare integers a and b for which only the least - * significant log2(mod) bits are known. - * - * @param mod must be a power of 2 - * @return a negative value if a is smaller than b - * a positive value if a is greater than b - * 0 if a equals b - */ -int64_t av_compare_mod(uint64_t a, uint64_t b, uint64_t mod); - -#endif /* AVUTIL_MATHEMATICS_H */ diff --git a/apps/codecs/libwmavoice/libavutil/mem.c b/apps/codecs/libwmavoice/libavutil/mem.c deleted file mode 100644 index a9a3283775..0000000000 --- a/apps/codecs/libwmavoice/libavutil/mem.c +++ /dev/null @@ -1,176 +0,0 @@ -/* - * default memory allocator for libavutil - * Copyright (c) 2002 Fabrice Bellard - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/** - * @file - * default memory allocator for libavutil - */ - -//#include "config.h" - -#include -#include -#include -#if HAVE_MALLOC_H -#include -#endif - -#include "avutil.h" -#include "mem.h" - -/* here we can use OS-dependent allocation functions */ -#undef free -#undef malloc -#undef realloc - -#ifdef MALLOC_PREFIX - -#define malloc AV_JOIN(MALLOC_PREFIX, malloc) -#define memalign AV_JOIN(MALLOC_PREFIX, memalign) -#define posix_memalign AV_JOIN(MALLOC_PREFIX, posix_memalign) -#define realloc AV_JOIN(MALLOC_PREFIX, realloc) -#define free AV_JOIN(MALLOC_PREFIX, free) - -void *malloc(size_t size); -void *memalign(size_t align, size_t size); -int posix_memalign(void **ptr, size_t align, size_t size); -void *realloc(void *ptr, size_t size); -void free(void *ptr); - -#endif /* MALLOC_PREFIX */ - -/* You can redefine av_malloc and av_free in your project to use your - memory allocator. You do not need to suppress this file because the - linker will do it automatically. */ - -void *av_malloc(unsigned int size) -{ - void *ptr = NULL; -#if CONFIG_MEMALIGN_HACK - long diff; -#endif - - /* let's disallow possible ambiguous cases */ - if(size > (INT_MAX-16) ) - return NULL; - -#if CONFIG_MEMALIGN_HACK - ptr = malloc(size+16); - if(!ptr) - return ptr; - diff= ((-(long)ptr - 1)&15) + 1; - ptr = (char*)ptr + diff; - ((char*)ptr)[-1]= diff; -#elif HAVE_POSIX_MEMALIGN - if (posix_memalign(&ptr,16,size)) - ptr = NULL; -#elif HAVE_MEMALIGN - ptr = memalign(16,size); - /* Why 64? - Indeed, we should align it: - on 4 for 386 - on 16 for 486 - on 32 for 586, PPro - K6-III - on 64 for K7 (maybe for P3 too). - Because L1 and L2 caches are aligned on those values. - But I don't want to code such logic here! - */ - /* Why 16? - Because some CPUs need alignment, for example SSE2 on P4, & most RISC CPUs - it will just trigger an exception and the unaligned load will be done in the - exception handler or it will just segfault (SSE2 on P4). - Why not larger? Because I did not see a difference in benchmarks ... - */ - /* benchmarks with P3 - memalign(64)+1 3071,3051,3032 - memalign(64)+2 3051,3032,3041 - memalign(64)+4 2911,2896,2915 - memalign(64)+8 2545,2554,2550 - memalign(64)+16 2543,2572,2563 - memalign(64)+32 2546,2545,2571 - memalign(64)+64 2570,2533,2558 - - BTW, malloc seems to do 8-byte alignment by default here. - */ -#else - ptr = malloc(size); -#endif - return ptr; -} - -void *av_realloc(void *ptr, unsigned int size) -{ -#if CONFIG_MEMALIGN_HACK - int diff; -#endif - - /* let's disallow possible ambiguous cases */ - if(size > (INT_MAX-16) ) - return NULL; - -#if CONFIG_MEMALIGN_HACK - //FIXME this isn't aligned correctly, though it probably isn't needed - if(!ptr) return av_malloc(size); - diff= ((char*)ptr)[-1]; - return (char*)realloc((char*)ptr - diff, size + diff) + diff; -#else - return realloc(ptr, size); -#endif -} - -void av_free(void *ptr) -{ - /* XXX: this test should not be needed on most libcs */ - if (ptr) -#if CONFIG_MEMALIGN_HACK - free((char*)ptr - ((char*)ptr)[-1]); -#else - free(ptr); -#endif -} - -void av_freep(void *arg) -{ - void **ptr= (void**)arg; - av_free(*ptr); - *ptr = NULL; -} - -void *av_mallocz(unsigned int size) -{ - void *ptr = av_malloc(size); - if (ptr) - memset(ptr, 0, size); - return ptr; -} - -char *av_strdup(const char *s) -{ - char *ptr= NULL; - if(s){ - int len = strlen(s) + 1; - ptr = av_malloc(len); - if (ptr) - memcpy(ptr, s, len); - } - return ptr; -} - diff --git a/apps/codecs/libwmavoice/libavutil/mem.h b/apps/codecs/libwmavoice/libavutil/mem.h deleted file mode 100644 index c5ec2ab3c3..0000000000 --- a/apps/codecs/libwmavoice/libavutil/mem.h +++ /dev/null @@ -1,126 +0,0 @@ -/* - * copyright (c) 2006 Michael Niedermayer - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/** - * @file - * memory handling functions - */ - -#ifndef AVUTIL_MEM_H -#define AVUTIL_MEM_H - -#include "attributes.h" -#include "avutil.h" - -#if defined(__ICC) && _ICC < 1200 || defined(__SUNPRO_C) - #define DECLARE_ALIGNED(n,t,v) t __attribute__ ((aligned (n))) v - #define DECLARE_ASM_CONST(n,t,v) const t __attribute__ ((aligned (n))) v -#elif defined(__TI_COMPILER_VERSION__) - #define DECLARE_ALIGNED(n,t,v) \ - AV_PRAGMA(DATA_ALIGN(v,n)) \ - t __attribute__((aligned(n))) v - #define DECLARE_ASM_CONST(n,t,v) \ - AV_PRAGMA(DATA_ALIGN(v,n)) \ - static const t __attribute__((aligned(n))) v -#elif defined(__GNUC__) - #define DECLARE_ALIGNED(n,t,v) t __attribute__ ((aligned (n))) v - #define DECLARE_ASM_CONST(n,t,v) static const t attribute_used __attribute__ ((aligned (n))) v -#elif defined(_MSC_VER) - #define DECLARE_ALIGNED(n,t,v) __declspec(align(n)) t v - #define DECLARE_ASM_CONST(n,t,v) __declspec(align(n)) static const t v -#else - #define DECLARE_ALIGNED(n,t,v) t v - #define DECLARE_ASM_CONST(n,t,v) static const t v -#endif - -#if AV_GCC_VERSION_AT_LEAST(3,1) - #define av_malloc_attrib __attribute__((__malloc__)) -#else - #define av_malloc_attrib -#endif - -#if (!defined(__ICC) || __ICC > 1110) && AV_GCC_VERSION_AT_LEAST(4,3) - #define av_alloc_size(n) __attribute__((alloc_size(n))) -#else - #define av_alloc_size(n) -#endif - -/** - * Allocate a block of size bytes with alignment suitable for all - * memory accesses (including vectors if available on the CPU). - * @param size Size in bytes for the memory block to be allocated. - * @return Pointer to the allocated block, NULL if the block cannot - * be allocated. - * @see av_mallocz() - */ -void *av_malloc(unsigned int size) av_malloc_attrib av_alloc_size(1); - -/** - * Allocate or reallocate a block of memory. - * If ptr is NULL and size > 0, allocate a new block. If - * size is zero, free the memory block pointed to by ptr. - * @param size Size in bytes for the memory block to be allocated or - * reallocated. - * @param ptr Pointer to a memory block already allocated with - * av_malloc(z)() or av_realloc() or NULL. - * @return Pointer to a newly reallocated block or NULL if the block - * cannot be reallocated or the function is used to free the memory block. - * @see av_fast_realloc() - */ -void *av_realloc(void *ptr, unsigned int size) av_alloc_size(2); - -/** - * Free a memory block which has been allocated with av_malloc(z)() or - * av_realloc(). - * @param ptr Pointer to the memory block which should be freed. - * @note ptr = NULL is explicitly allowed. - * @note It is recommended that you use av_freep() instead. - * @see av_freep() - */ -void av_free(void *ptr); - -/** - * Allocate a block of size bytes with alignment suitable for all - * memory accesses (including vectors if available on the CPU) and - * zero all the bytes of the block. - * @param size Size in bytes for the memory block to be allocated. - * @return Pointer to the allocated block, NULL if it cannot be allocated. - * @see av_malloc() - */ -void *av_mallocz(unsigned int size) av_malloc_attrib av_alloc_size(1); - -/** - * Duplicate the string s. - * @param s string to be duplicated - * @return Pointer to a newly allocated string containing a - * copy of s or NULL if the string cannot be allocated. - */ -char *av_strdup(const char *s) av_malloc_attrib; - -/** - * Free a memory block which has been allocated with av_malloc(z)() or - * av_realloc() and set the pointer pointing to it to NULL. - * @param ptr Pointer to the pointer to the memory block which should - * be freed. - * @see av_free() - */ -void av_freep(void *ptr); - -#endif /* AVUTIL_MEM_H */ diff --git a/apps/codecs/libwmavoice/libwmavoice.make b/apps/codecs/libwmavoice/libwmavoice.make deleted file mode 100644 index b35756c64a..0000000000 --- a/apps/codecs/libwmavoice/libwmavoice.make +++ /dev/null @@ -1,37 +0,0 @@ -# __________ __ ___. -# Open \______ \ ____ ____ | | _\_ |__ _______ ___ -# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / -# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < -# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ -# \/ \/ \/ \/ \/ -# $Id: libwmavoice.make 27586 2010-07-27 06:48:15Z nls $ -# - -# libwmavoice -WMAVOICELIB := $(CODECDIR)/libwmavoice.a -WMAVOICELIB_SRC := $(call preprocess, $(APPSDIR)/codecs/libwmavoice/SOURCES) -WMAVOICELIB_OBJ := $(call c2obj, $(WMAVOICELIB_SRC)) -OTHER_SRC += $(WMAVOICELIB_SRC) - -$(WMAVOICELIB): $(WMAVOICELIB_OBJ) - $(SILENT)$(shell rm -f $@) - $(call PRINTS,AR $(@F))$(AR) rcs $@ $^ >/dev/null - -WMAVOICEFLAGS = -I$(APPSDIR)/codecs/libwmavoice $(filter-out -O%,$(CODECFLAGS)) - -ifeq ($(ARCH),arch_m68k) - WMAVOICEFLAGS += -O2 -else - WMAVOICEFLAGS += -O1 -endif - -ifeq ($(APP_TYPE),sdl-sim) -# wmavoice needs libm in the simulator -$(CODECDIR)/wmavoice.codec: $(CODECDIR)/wmavoice.o - $(call PRINTS,LD $(@F))$(CC) $(CODECFLAGS) -o $(CODECDIR)/wmavoice.elf \ - $(filter %.o, $^) \ - $(filter %.a, $+) \ - -lgcc -lm $(CODECLDFLAGS) - $(SILENT)cp $(CODECDIR)/wmavoice.elf $@ -endif - diff --git a/apps/codecs/libwmavoice/lsp.c b/apps/codecs/libwmavoice/lsp.c deleted file mode 100644 index 4dba9c1df9..0000000000 --- a/apps/codecs/libwmavoice/lsp.c +++ /dev/null @@ -1,174 +0,0 @@ -/* - * LSP routines for ACELP-based codecs - * - * Copyright (c) 2007 Reynaldo H. Verdejo Pinochet (QCELP decoder) - * Copyright (c) 2008 Vladimir Voroshilov - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include - -#include "avcodec.h" -#define FRAC_BITS 14 -#include "mathops.h" -#include "lsp.h" -#include "celp_math.h" - -void ff_acelp_reorder_lsf(int16_t* lsfq, int lsfq_min_distance, int lsfq_min, int lsfq_max, int lp_order) -{ - int i, j; - - /* sort lsfq in ascending order. float bubble agorithm, - O(n) if data already sorted, O(n^2) - otherwise */ - for(i=0; i=0 && lsfq[j] > lsfq[j+1]; j--) - FFSWAP(int16_t, lsfq[j], lsfq[j+1]); - - for(i=0; i> 15); // divide by PI and (0,13) -> (0,14) -} - -/** - * \brief decodes polynomial coefficients from LSP - * \param f [out] decoded polynomial coefficients (-0x20000000 <= (3.22) <= 0x1fffffff) - * \param lsp LSP coefficients (-0x8000 <= (0.15) <= 0x7fff) - */ -static void lsp2poly(int* f, const int16_t* lsp, int lp_half_order) -{ - int i, j; - - f[0] = 0x400000; // 1.0 in (3.22) - f[1] = -lsp[0] << 8; // *2 and (0.15) -> (3.22) - - for(i=2; i<=lp_half_order; i++) - { - f[i] = f[i-2]; - for(j=i; j>1; j--) - f[j] -= MULL(f[j-1], lsp[2*i-2], FRAC_BITS) - f[j-2]; - - f[1] -= lsp[2*i-2] << 8; - } -} - -void ff_acelp_lsp2lpc(int16_t* lp, const int16_t* lsp, int lp_half_order) -{ - int i; - int f1[MAX_LP_HALF_ORDER+1]; // (3.22) - int f2[MAX_LP_HALF_ORDER+1]; // (3.22) - - lsp2poly(f1, lsp , lp_half_order); - lsp2poly(f2, lsp+1, lp_half_order); - - /* 3.2.6 of G.729, Equations 25 and 26*/ - lp[0] = 4096; - for(i=1; i> 11; // divide by 2 and (3.22) -> (3.12) - lp[(lp_half_order << 1) + 1 - i] = (ff1 - ff2) >> 11; // divide by 2 and (3.22) -> (3.12) - } -} - -void ff_acelp_lp_decode(int16_t* lp_1st, int16_t* lp_2nd, const int16_t* lsp_2nd, const int16_t* lsp_prev, int lp_order) -{ - int16_t lsp_1st[MAX_LP_ORDER]; // (0.15) - int i; - - /* LSP values for first subframe (3.2.5 of G.729, Equation 24)*/ - for(i=0; i> 1) + (lsp_prev[i] >> 1); -#else - lsp_1st[i] = (lsp_2nd[i] + lsp_prev[i]) >> 1; -#endif - - ff_acelp_lsp2lpc(lp_1st, lsp_1st, lp_order >> 1); - - /* LSP values for second subframe (3.2.5 of G.729)*/ - ff_acelp_lsp2lpc(lp_2nd, lsp_2nd, lp_order >> 1); -} - -void ff_lsp2polyf(const double *lsp, double *f, int lp_half_order) -{ - int i, j; - - f[0] = 1.0; - f[1] = -2 * lsp[0]; - lsp -= 2; - for(i=2; i<=lp_half_order; i++) - { - double val = -2 * lsp[2*i]; - f[i] = val * f[i-1] + 2*f[i-2]; - for(j=i-1; j>1; j--) - f[j] += f[j-1] * val + f[j-2]; - f[1] += val; - } -} - -void ff_acelp_lspd2lpc(const double *lsp, float *lpc, int lp_half_order) -{ - double pa[MAX_LP_HALF_ORDER+1], qa[MAX_LP_HALF_ORDER+1]; - float *lpc2 = lpc + (lp_half_order << 1) - 1; - - //assert(lp_half_order <= MAX_LP_HALF_ORDER); - - ff_lsp2polyf(lsp, pa, lp_half_order); - ff_lsp2polyf(lsp + 1, qa, lp_half_order); - - while (lp_half_order--) { - double paf = pa[lp_half_order+1] + pa[lp_half_order]; - double qaf = qa[lp_half_order+1] - qa[lp_half_order]; - - lpc [ lp_half_order] = 0.5*(paf+qaf); - lpc2[-lp_half_order] = 0.5*(paf-qaf); - } -} - -void ff_sort_nearly_sorted_floats(float *vals, int len) -{ - int i,j; - - for (i = 0; i < len - 1; i++) - for (j = i; j >= 0 && vals[j] > vals[j+1]; j--) - FFSWAP(float, vals[j], vals[j+1]); -} diff --git a/apps/codecs/libwmavoice/lsp.h b/apps/codecs/libwmavoice/lsp.h deleted file mode 100644 index 5ee5c277bc..0000000000 --- a/apps/codecs/libwmavoice/lsp.h +++ /dev/null @@ -1,120 +0,0 @@ -/* - * LSP computing for ACELP-based codecs - * - * Copyright (c) 2008 Vladimir Voroshilov - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef AVCODEC_LSP_H -#define AVCODEC_LSP_H - -#include - -/** - (I.F) means fixed-point value with F fractional and I integer bits -*/ - -/** - * \brief ensure a minimum distance between LSFs - * \param[in,out] lsfq LSF to check and adjust - * \param lsfq_min_distance minimum distance between LSFs - * \param lsfq_min minimum allowed LSF value - * \param lsfq_max maximum allowed LSF value - * \param lp_order LP filter order - */ -void ff_acelp_reorder_lsf(int16_t* lsfq, int lsfq_min_distance, int lsfq_min, int lsfq_max, int lp_order); - -/** - * Adjust the quantized LSFs so they are increasing and not too close. - * - * This step is not mentioned in the AMR spec but is in the reference C decoder. - * Omitting this step creates audible distortion on the sinusoidal sweep - * test vectors in 3GPP TS 26.074. - * - * @param[in,out] lsf LSFs in Hertz - * @param min_spacing minimum distance between two consecutive lsf values - * @param size size of the lsf vector - */ -void ff_set_min_dist_lsf(float *lsf, double min_spacing, int size); - -/** - * \brief Convert LSF to LSP - * \param[out] lsp LSP coefficients (-0x8000 <= (0.15) < 0x8000) - * \param lsf normalized LSF coefficients (0 <= (2.13) < 0x2000 * PI) - * \param lp_order LP filter order - * - * \remark It is safe to pass the same array into the lsf and lsp parameters. - */ -void ff_acelp_lsf2lsp(int16_t *lsp, const int16_t *lsf, int lp_order); - -/** - * \brief LSP to LP conversion (3.2.6 of G.729) - * \param[out] lp decoded LP coefficients (-0x8000 <= (3.12) < 0x8000) - * \param lsp LSP coefficients (-0x8000 <= (0.15) < 0x8000) - * \param lp_half_order LP filter order, divided by 2 - */ -void ff_acelp_lsp2lpc(int16_t* lp, const int16_t* lsp, int lp_half_order); - -/** - * \brief Interpolate LSP for the first subframe and convert LSP -> LP for both subframes (3.2.5 and 3.2.6 of G.729) - * \param[out] lp_1st decoded LP coefficients for first subframe (-0x8000 <= (3.12) < 0x8000) - * \param[out] lp_2nd decoded LP coefficients for second subframe (-0x8000 <= (3.12) < 0x8000) - * \param lsp_2nd LSP coefficients of the second subframe (-0x8000 <= (0.15) < 0x8000) - * \param lsp_prev LSP coefficients from the second subframe of the previous frame (-0x8000 <= (0.15) < 0x8000) - * \param lp_order LP filter order - */ -void ff_acelp_lp_decode(int16_t* lp_1st, int16_t* lp_2nd, const int16_t* lsp_2nd, const int16_t* lsp_prev, int lp_order); - - -#define MAX_LP_HALF_ORDER 8 -#define MAX_LP_ORDER (2*MAX_LP_HALF_ORDER) - -/** - * Reconstruct LPC coefficients from the line spectral pair frequencies. - * - * @param lsp line spectral pairs in cosine domain - * @param lpc linear predictive coding coefficients - * @param lp_half_order half the number of the amount of LPCs to be - * reconstructed, need to be smaller or equal to MAX_LP_HALF_ORDER - * - * @note buffers should have a minimux size of 2*lp_half_order elements. - * - * TIA/EIA/IS-733 2.4.3.3.5 - */ -void ff_acelp_lspd2lpc(const double *lsp, float *lpc, int lp_half_order); - -/** - * Sort values in ascending order. - * - * @note O(n) if data already sorted, O(n^2) - otherwise - */ -void ff_sort_nearly_sorted_floats(float *vals, int len); - -/** - * Compute the Pa / (1 + z(-1)) or Qa / (1 - z(-1)) coefficients - * needed for LSP to LPC conversion. - * We only need to calculate the 6 first elements of the polynomial. - * - * @param lsp line spectral pairs in cosine domain - * @param[out] f polynomial input/output as a vector - * - * TIA/EIA/IS-733 2.4.3.3.5-1/2 - */ -void ff_lsp2polyf(const double *lsp, double *f, int lp_half_order); - -#endif /* AVCODEC_LSP_H */ diff --git a/apps/codecs/libwmavoice/mathops.h b/apps/codecs/libwmavoice/mathops.h deleted file mode 100644 index 4d88ed14c9..0000000000 --- a/apps/codecs/libwmavoice/mathops.h +++ /dev/null @@ -1,182 +0,0 @@ -/* - * simple math operations - * Copyright (c) 2001, 2002 Fabrice Bellard - * Copyright (c) 2006 Michael Niedermayer et al - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ -#ifndef AVCODEC_MATHOPS_H -#define AVCODEC_MATHOPS_H - -#include "libavutil/common.h" - -#if ARCH_ARM -# include "arm/mathops.h" -#elif ARCH_AVR32 -# include "avr32/mathops.h" -#elif ARCH_BFIN -# include "bfin/mathops.h" -#elif ARCH_MIPS -# include "mips/mathops.h" -#elif ARCH_PPC -# include "ppc/mathops.h" -#elif ARCH_X86 -# include "x86/mathops.h" -#endif - -/* generic implementation */ - -#ifndef MULL -# define MULL(a,b,s) (((int64_t)(a) * (int64_t)(b)) >> (s)) -#endif - -#ifndef MULH -//gcc 3.4 creates an incredibly bloated mess out of this -//# define MULH(a,b) (((int64_t)(a) * (int64_t)(b))>>32) - -static av_always_inline int MULH(int a, int b){ - return ((int64_t)(a) * (int64_t)(b))>>32; -} -#endif - -#ifndef UMULH -static av_always_inline unsigned UMULH(unsigned a, unsigned b){ - return ((uint64_t)(a) * (uint64_t)(b))>>32; -} -#endif - -#ifndef MUL64 -# define MUL64(a,b) ((int64_t)(a) * (int64_t)(b)) -#endif - -#ifndef MAC64 -# define MAC64(d, a, b) ((d) += MUL64(a, b)) -#endif - -#ifndef MLS64 -# define MLS64(d, a, b) ((d) -= MUL64(a, b)) -#endif - -/* signed 16x16 -> 32 multiply add accumulate */ -#ifndef MAC16 -# define MAC16(rt, ra, rb) rt += (ra) * (rb) -#endif - -/* signed 16x16 -> 32 multiply */ -#ifndef MUL16 -# define MUL16(ra, rb) ((ra) * (rb)) -#endif - -#ifndef MLS16 -# define MLS16(rt, ra, rb) ((rt) -= (ra) * (rb)) -#endif - -/* median of 3 */ -#ifndef mid_pred -#define mid_pred mid_pred -static inline av_const int mid_pred(int a, int b, int c) -{ -#if 0 - int t= (a-b)&((a-b)>>31); - a-=t; - b+=t; - b-= (b-c)&((b-c)>>31); - b+= (a-b)&((a-b)>>31); - - return b; -#else - if(a>b){ - if(c>b){ - if(c>a) b=a; - else b=c; - } - }else{ - if(b>c){ - if(c>a) b=c; - else b=a; - } - } - return b; -#endif -} -#endif - -#ifndef sign_extend -static inline av_const int sign_extend(int val, unsigned bits) -{ - return (val << ((8 * sizeof(int)) - bits)) >> ((8 * sizeof(int)) - bits); -} -#endif - -#ifndef zero_extend -static inline av_const unsigned zero_extend(unsigned val, unsigned bits) -{ - return (val << ((8 * sizeof(int)) - bits)) >> ((8 * sizeof(int)) - bits); -} -#endif - -#ifndef COPY3_IF_LT -#define COPY3_IF_LT(x, y, a, b, c, d)\ -if ((y) < (x)) {\ - (x) = (y);\ - (a) = (b);\ - (c) = (d);\ -} -#endif - -#ifndef NEG_SSR32 -# define NEG_SSR32(a,s) ((( int32_t)(a))>>(32-(s))) -#endif - -#ifndef NEG_USR32 -# define NEG_USR32(a,s) (((uint32_t)(a))>>(32-(s))) -#endif - -#if HAVE_BIGENDIAN -# ifndef PACK_2U8 -# define PACK_2U8(a,b) (((a) << 8) | (b)) -# endif -# ifndef PACK_4U8 -# define PACK_4U8(a,b,c,d) (((a) << 24) | ((b) << 16) | ((c) << 8) | (d)) -# endif -# ifndef PACK_2U16 -# define PACK_2U16(a,b) (((a) << 16) | (b)) -# endif -#else -# ifndef PACK_2U8 -# define PACK_2U8(a,b) (((b) << 8) | (a)) -# endif -# ifndef PACK_4U2 -# define PACK_4U8(a,b,c,d) (((d) << 24) | ((c) << 16) | ((b) << 8) | (a)) -# endif -# ifndef PACK_2U16 -# define PACK_2U16(a,b) (((b) << 16) | (a)) -# endif -#endif - -#ifndef PACK_2S8 -# define PACK_2S8(a,b) PACK_2U8((a)&255, (b)&255) -#endif -#ifndef PACK_4S8 -# define PACK_4S8(a,b,c,d) PACK_4U8((a)&255, (b)&255, (c)&255, (d)&255) -#endif -#ifndef PACK_2S16 -# define PACK_2S16(a,b) PACK_2U16((a)&0xffff, (b)&0xffff) -#endif - -#endif /* AVCODEC_MATHOPS_H */ - diff --git a/apps/codecs/libwmavoice/mdct.c b/apps/codecs/libwmavoice/mdct.c deleted file mode 100644 index 58bff3517b..0000000000 --- a/apps/codecs/libwmavoice/mdct.c +++ /dev/null @@ -1,234 +0,0 @@ -/* - * MDCT/IMDCT transforms - * Copyright (c) 2002 Fabrice Bellard - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include -#include -#include "libavutil/common.h" -#include "libavutil/mathematics.h" -#include "fft.h" - -/** - * @file - * MDCT/IMDCT transforms. - */ - -// Generate a Kaiser-Bessel Derived Window. -#define BESSEL_I0_ITER 50 // default: 50 iterations of Bessel I0 approximation -av_cold void ff_kbd_window_init(float *window, float alpha, int n) -{ - int i, j; - double sum = 0.0, bessel, tmp; - double local_window[FF_KBD_WINDOW_MAX]; - double alpha2 = (alpha * M_PI / n) * (alpha * M_PI / n); - - //assert(n <= FF_KBD_WINDOW_MAX); - - for (i = 0; i < n; i++) { - tmp = i * (n - i) * alpha2; - bessel = 1.0; - for (j = BESSEL_I0_ITER; j > 0; j--) - bessel = bessel * tmp / (j * j) + 1; - sum += bessel; - local_window[i] = sum; - } - - sum++; - for (i = 0; i < n; i++) - window[i] = sqrt(local_window[i] / sum); -} - -#include "mdct_tablegen.h" - -/** - * init MDCT or IMDCT computation. - */ -av_cold int ff_mdct_init(FFTContext *s, int nbits, int inverse, double scale) -{ - int n, n4, i; - double alpha, theta; - int tstep; - - memset(s, 0, sizeof(*s)); - n = 1 << nbits; - s->mdct_bits = nbits; - s->mdct_size = n; - n4 = n >> 2; - s->permutation = FF_MDCT_PERM_NONE; - - if (ff_fft_init(s, s->mdct_bits - 2, inverse) < 0) - goto fail; - - s->tcos = av_malloc(n/2 * sizeof(FFTSample)); - if (!s->tcos) - goto fail; - - switch (s->permutation) { - case FF_MDCT_PERM_NONE: - s->tsin = s->tcos + n4; - tstep = 1; - break; - case FF_MDCT_PERM_INTERLEAVE: - s->tsin = s->tcos + 1; - tstep = 2; - break; - default: - goto fail; - } - - theta = 1.0 / 8.0 + (scale < 0 ? n4 : 0); - scale = sqrt(fabs(scale)); - for(i=0;itcos[i*tstep] = -cos(alpha) * scale; - s->tsin[i*tstep] = -sin(alpha) * scale; - } - return 0; - fail: - ff_mdct_end(s); - return -1; -} - -/* complex multiplication: p = a * b */ -#define CMUL(pre, pim, are, aim, bre, bim) \ -{\ - FFTSample _are = (are);\ - FFTSample _aim = (aim);\ - FFTSample _bre = (bre);\ - FFTSample _bim = (bim);\ - (pre) = _are * _bre - _aim * _bim;\ - (pim) = _are * _bim + _aim * _bre;\ -} - -/** - * Compute the middle half of the inverse MDCT of size N = 2^nbits, - * thus excluding the parts that can be derived by symmetry - * @param output N/2 samples - * @param input N/2 samples - */ -void ff_imdct_half_c(FFTContext *s, FFTSample *output, const FFTSample *input) -{ - int k, n8, n4, n2, n, j; - const uint16_t *revtab = s->revtab; - const FFTSample *tcos = s->tcos; - const FFTSample *tsin = s->tsin; - const FFTSample *in1, *in2; - FFTComplex *z = (FFTComplex *)output; - - n = 1 << s->mdct_bits; - n2 = n >> 1; - n4 = n >> 2; - n8 = n >> 3; - - /* pre rotation */ - in1 = input; - in2 = input + n2 - 1; - for(k = 0; k < n4; k++) { - j=revtab[k]; - CMUL(z[j].re, z[j].im, *in2, *in1, tcos[k], tsin[k]); - in1 += 2; - in2 -= 2; - } - ff_fft_calc(s, z); - - /* post rotation + reordering */ - for(k = 0; k < n8; k++) { - FFTSample r0, i0, r1, i1; - CMUL(r0, i1, z[n8-k-1].im, z[n8-k-1].re, tsin[n8-k-1], tcos[n8-k-1]); - CMUL(r1, i0, z[n8+k ].im, z[n8+k ].re, tsin[n8+k ], tcos[n8+k ]); - z[n8-k-1].re = r0; - z[n8-k-1].im = i0; - z[n8+k ].re = r1; - z[n8+k ].im = i1; - } -} - -/** - * Compute inverse MDCT of size N = 2^nbits - * @param output N samples - * @param input N/2 samples - */ -void ff_imdct_calc_c(FFTContext *s, FFTSample *output, const FFTSample *input) -{ - int k; - int n = 1 << s->mdct_bits; - int n2 = n >> 1; - int n4 = n >> 2; - - ff_imdct_half_c(s, output+n4, input); - - for(k = 0; k < n4; k++) { - output[k] = -output[n2-k-1]; - output[n-k-1] = output[n2+k]; - } -} - -/** - * Compute MDCT of size N = 2^nbits - * @param input N samples - * @param out N/2 samples - */ -void ff_mdct_calc_c(FFTContext *s, FFTSample *out, const FFTSample *input) -{ - int i, j, n, n8, n4, n2, n3; - FFTSample re, im; - const uint16_t *revtab = s->revtab; - const FFTSample *tcos = s->tcos; - const FFTSample *tsin = s->tsin; - FFTComplex *x = (FFTComplex *)out; - - n = 1 << s->mdct_bits; - n2 = n >> 1; - n4 = n >> 2; - n8 = n >> 3; - n3 = 3 * n4; - - /* pre rotation */ - for(i=0;itcos); - ff_fft_end(s); -} diff --git a/apps/codecs/libwmavoice/mdct_tablegen.h b/apps/codecs/libwmavoice/mdct_tablegen.h deleted file mode 100644 index 51a0094221..0000000000 --- a/apps/codecs/libwmavoice/mdct_tablegen.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Header file for hardcoded MDCT tables - * - * Copyright (c) 2009 Reimar Döffinger - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include -// do not use libavutil/libm.h since this is compiled both -// for the host and the target and config.h is only valid for the target -#include -#include "libavutil/attributes.h" - -#if !CONFIG_HARDCODED_TABLES -SINETABLE( 32); -SINETABLE( 64); -SINETABLE( 128); -SINETABLE( 256); -SINETABLE( 512); -SINETABLE(1024); -SINETABLE(2048); -SINETABLE(4096); -#else -#include "libavcodec/mdct_tables.h" -#endif - -SINETABLE_CONST float * const ff_sine_windows[] = { - NULL, NULL, NULL, NULL, NULL, // unused - ff_sine_32 , ff_sine_64 , - ff_sine_128, ff_sine_256, ff_sine_512, ff_sine_1024, ff_sine_2048, ff_sine_4096 -}; - -// Generate a sine window. -av_cold void ff_sine_window_init(float *window, int n) { - int i; - for(i = 0; i < n; i++) - window[i] = sinf((i + 0.5) * (M_PI / (2.0 * n))); -} - -av_cold void ff_init_ff_sine_windows(int index) { - assert(index >= 0 && index < FF_ARRAY_ELEMS(ff_sine_windows)); -#if !CONFIG_HARDCODED_TABLES - ff_sine_window_init(ff_sine_windows[index], 1 << index); -#endif -} diff --git a/apps/codecs/libwmavoice/put_bits.h b/apps/codecs/libwmavoice/put_bits.h deleted file mode 100644 index d301d0afcc..0000000000 --- a/apps/codecs/libwmavoice/put_bits.h +++ /dev/null @@ -1,343 +0,0 @@ -/* - * copyright (c) 2004 Michael Niedermayer - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/** - * @file - * bitstream writer API - */ - -#ifndef AVCODEC_PUT_BITS_H -#define AVCODEC_PUT_BITS_H - -#include -#include -#include -#include "libavutil/bswap.h" -#include "libavutil/common.h" -#include "libavutil/intreadwrite.h" -#include "libavutil/log.h" -#include "mathops.h" - -//#define ALT_BITSTREAM_WRITER -//#define ALIGNED_BITSTREAM_WRITER - -/* buf and buf_end must be present and used by every alternative writer. */ -typedef struct PutBitContext { -#ifdef ALT_BITSTREAM_WRITER - uint8_t *buf, *buf_end; - int index; -#else - uint32_t bit_buf; - int bit_left; - uint8_t *buf, *buf_ptr, *buf_end; -#endif - int size_in_bits; -} PutBitContext; - -/** - * Initialize the PutBitContext s. - * - * @param buffer the buffer where to put bits - * @param buffer_size the size in bytes of buffer - */ -static inline void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size) -{ - if(buffer_size < 0) { - buffer_size = 0; - buffer = NULL; - } - - s->size_in_bits= 8*buffer_size; - s->buf = buffer; - s->buf_end = s->buf + buffer_size; -#ifdef ALT_BITSTREAM_WRITER - s->index=0; - ((uint32_t*)(s->buf))[0]=0; -// memset(buffer, 0, buffer_size); -#else - s->buf_ptr = s->buf; - s->bit_left=32; - s->bit_buf=0; -#endif -} - -/** - * @return the total number of bits written to the bitstream. - */ -static inline int put_bits_count(PutBitContext *s) -{ -#ifdef ALT_BITSTREAM_WRITER - return s->index; -#else - return (s->buf_ptr - s->buf) * 8 + 32 - s->bit_left; -#endif -} - -/** - * Pad the end of the output stream with zeros. - */ -static inline void flush_put_bits(PutBitContext *s) -{ -#ifdef ALT_BITSTREAM_WRITER - align_put_bits(s); -#else -#ifndef BITSTREAM_WRITER_LE - s->bit_buf<<= s->bit_left; -#endif - while (s->bit_left < 32) { - /* XXX: should test end of buffer */ -#ifdef BITSTREAM_WRITER_LE - *s->buf_ptr++=s->bit_buf; - s->bit_buf>>=8; -#else - *s->buf_ptr++=s->bit_buf >> 24; - s->bit_buf<<=8; -#endif - s->bit_left+=8; - } - s->bit_left=32; - s->bit_buf=0; -#endif -} - -#if defined(ALT_BITSTREAM_WRITER) || defined(BITSTREAM_WRITER_LE) -#define align_put_bits align_put_bits_unsupported_here -#define ff_put_string ff_put_string_unsupported_here -#define ff_copy_bits ff_copy_bits_unsupported_here -#else -/** - * Pad the bitstream with zeros up to the next byte boundary. - */ -void align_put_bits(PutBitContext *s); - -/** - * Put the string string in the bitstream. - * - * @param terminate_string 0-terminates the written string if value is 1 - */ -void ff_put_string(PutBitContext *pb, const char *string, int terminate_string); - -/** - * Copy the content of src to the bitstream. - * - * @param length the number of bits of src to copy - */ -void ff_copy_bits(PutBitContext *pb, const uint8_t *src, int length); -#endif - -/** - * Write up to 31 bits into a bitstream. - * Use put_bits32 to write 32 bits. - */ -static inline void put_bits(PutBitContext *s, int n, unsigned int value) -#ifndef ALT_BITSTREAM_WRITER -{ - unsigned int bit_buf; - int bit_left; - - // printf("put_bits=%d %x\n", n, value); - assert(n <= 31 && value < (1U << n)); - - bit_buf = s->bit_buf; - bit_left = s->bit_left; - - // printf("n=%d value=%x cnt=%d buf=%x\n", n, value, bit_cnt, bit_buf); - /* XXX: optimize */ -#ifdef BITSTREAM_WRITER_LE - bit_buf |= value << (32 - bit_left); - if (n >= bit_left) { -#if !HAVE_FAST_UNALIGNED - if (3 & (intptr_t) s->buf_ptr) { - AV_WL32(s->buf_ptr, bit_buf); - } else -#endif - *(uint32_t *)s->buf_ptr = av_le2ne32(bit_buf); - s->buf_ptr+=4; - bit_buf = (bit_left==32)?0:value >> bit_left; - bit_left+=32; - } - bit_left-=n; -#else - if (n < bit_left) { - bit_buf = (bit_buf<> (n - bit_left); -#if !HAVE_FAST_UNALIGNED - if (3 & (intptr_t) s->buf_ptr) { - AV_WB32(s->buf_ptr, bit_buf); - } else -#endif - *(uint32_t *)s->buf_ptr = av_be2ne32(bit_buf); - //printf("bitbuf = %08x\n", bit_buf); - s->buf_ptr+=4; - bit_left+=32 - n; - bit_buf = value; - } -#endif - - s->bit_buf = bit_buf; - s->bit_left = bit_left; -} -#else /* ALT_BITSTREAM_WRITER defined */ -{ -# ifdef ALIGNED_BITSTREAM_WRITER -# if ARCH_X86 - __asm__ volatile( - "movl %0, %%ecx \n\t" - "xorl %%eax, %%eax \n\t" - "shrdl %%cl, %1, %%eax \n\t" - "shrl %%cl, %1 \n\t" - "movl %0, %%ecx \n\t" - "shrl $3, %%ecx \n\t" - "andl $0xFFFFFFFC, %%ecx \n\t" - "bswapl %1 \n\t" - "orl %1, (%2, %%ecx) \n\t" - "bswapl %%eax \n\t" - "addl %3, %0 \n\t" - "movl %%eax, 4(%2, %%ecx) \n\t" - : "=&r" (s->index), "=&r" (value) - : "r" (s->buf), "r" (n), "0" (s->index), "1" (value<<(-n)) - : "%eax", "%ecx" - ); -# else - int index= s->index; - uint32_t *ptr= ((uint32_t *)s->buf)+(index>>5); - - value<<= 32-n; - - ptr[0] |= av_be2ne32(value>>(index&31)); - ptr[1] = av_be2ne32(value<<(32-(index&31))); -//if(n>24) printf("%d %d\n", n, value); - index+= n; - s->index= index; -# endif -# else //ALIGNED_BITSTREAM_WRITER -# if ARCH_X86 - __asm__ volatile( - "movl $7, %%ecx \n\t" - "andl %0, %%ecx \n\t" - "addl %3, %%ecx \n\t" - "negl %%ecx \n\t" - "shll %%cl, %1 \n\t" - "bswapl %1 \n\t" - "movl %0, %%ecx \n\t" - "shrl $3, %%ecx \n\t" - "orl %1, (%%ecx, %2) \n\t" - "addl %3, %0 \n\t" - "movl $0, 4(%%ecx, %2) \n\t" - : "=&r" (s->index), "=&r" (value) - : "r" (s->buf), "r" (n), "0" (s->index), "1" (value) - : "%ecx" - ); -# else - int index= s->index; - uint32_t *ptr= (uint32_t*)(((uint8_t *)s->buf)+(index>>3)); - - ptr[0] |= av_be2ne32(value<<(32-n-(index&7) )); - ptr[1] = 0; -//if(n>24) printf("%d %d\n", n, value); - index+= n; - s->index= index; -# endif -# endif //!ALIGNED_BITSTREAM_WRITER -} -#endif - -static inline void put_sbits(PutBitContext *pb, int n, int32_t value) -{ - assert(n >= 0 && n <= 31); - - put_bits(pb, n, value & ((1<> 16; -#ifdef BITSTREAM_WRITER_LE - put_bits(s, 16, lo); - put_bits(s, 16, hi); -#else - put_bits(s, 16, hi); - put_bits(s, 16, lo); -#endif -} - -/** - * Return the pointer to the byte where the bitstream writer will put - * the next bit. - */ -static inline uint8_t* put_bits_ptr(PutBitContext *s) -{ -#ifdef ALT_BITSTREAM_WRITER - return s->buf + (s->index>>3); -#else - return s->buf_ptr; -#endif -} - -/** - * Skip the given number of bytes. - * PutBitContext must be flushed & aligned to a byte boundary before calling this. - */ -static inline void skip_put_bytes(PutBitContext *s, int n) -{ - assert((put_bits_count(s)&7)==0); -#ifdef ALT_BITSTREAM_WRITER - FIXME may need some cleaning of the buffer - s->index += n<<3; -#else - assert(s->bit_left==32); - s->buf_ptr += n; -#endif -} - -/** - * Skip the given number of bits. - * Must only be used if the actual values in the bitstream do not matter. - * If n is 0 the behavior is undefined. - */ -static inline void skip_put_bits(PutBitContext *s, int n) -{ -#ifdef ALT_BITSTREAM_WRITER - s->index += n; -#else - s->bit_left -= n; - s->buf_ptr-= 4*(s->bit_left>>5); - s->bit_left &= 31; -#endif -} - -/** - * Change the end of the buffer. - * - * @param size the new size in bytes of the buffer where to put bits - */ -static inline void set_put_bits_buffer_size(PutBitContext *s, int size) -{ - s->buf_end= s->buf + size; -} - -#endif /* AVCODEC_PUT_BITS_H */ diff --git a/apps/codecs/libwmavoice/rdft.c b/apps/codecs/libwmavoice/rdft.c deleted file mode 100644 index bc44f5aef2..0000000000 --- a/apps/codecs/libwmavoice/rdft.c +++ /dev/null @@ -1,133 +0,0 @@ -/* - * (I)RDFT transforms - * Copyright (c) 2009 Alex Converse - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ -#include -#include -#include "libavutil/mathematics.h" -#include "fft.h" - -/** - * @file - * (Inverse) Real Discrete Fourier Transforms. - */ - -/* sin(2*pi*x/n) for 0<=xnbits; - const float k1 = 0.5; - const float k2 = 0.5 - s->inverse; - const FFTSample *tcos = s->tcos; - const FFTSample *tsin = s->tsin; - - if (!s->inverse) { - ff_fft_permute(&s->fft, (FFTComplex*)data); - ff_fft_calc(&s->fft, (FFTComplex*)data); - } - /* i=0 is a special case because of packing, the DC term is real, so we - are going to throw the N/2 term (also real) in with it. */ - ev.re = data[0]; - data[0] = ev.re+data[1]; - data[1] = ev.re-data[1]; - for (i = 1; i < (n>>2); i++) { - i1 = 2*i; - i2 = n-i1; - /* Separate even and odd FFTs */ - ev.re = k1*(data[i1 ]+data[i2 ]); - od.im = -k2*(data[i1 ]-data[i2 ]); - ev.im = k1*(data[i1+1]-data[i2+1]); - od.re = k2*(data[i1+1]+data[i2+1]); - /* Apply twiddle factors to the odd FFT and add to the even FFT */ - data[i1 ] = ev.re + od.re*tcos[i] - od.im*tsin[i]; - data[i1+1] = ev.im + od.im*tcos[i] + od.re*tsin[i]; - data[i2 ] = ev.re - od.re*tcos[i] + od.im*tsin[i]; - data[i2+1] = -ev.im + od.im*tcos[i] + od.re*tsin[i]; - } - data[2*i+1]=s->sign_convention*data[2*i+1]; - if (s->inverse) { - data[0] *= k1; - data[1] *= k1; - ff_fft_permute(&s->fft, (FFTComplex*)data); - ff_fft_calc(&s->fft, (FFTComplex*)data); - } -} - -av_cold int ff_rdft_init(RDFTContext *s, int nbits, enum RDFTransformType trans) -{ - int n = 1 << nbits; - int i; - const double theta = (trans == DFT_R2C || trans == DFT_C2R ? -1 : 1)*2*M_PI/n; - - s->nbits = nbits; - s->inverse = trans == IDFT_C2R || trans == DFT_C2R; - s->sign_convention = trans == IDFT_R2C || trans == DFT_C2R ? 1 : -1; - - if (nbits < 4 || nbits > 16) - return -1; - - if (ff_fft_init(&s->fft, nbits-1, trans == IDFT_C2R || trans == IDFT_R2C) < 0) - return -1; - - ff_init_ff_cos_tabs(nbits); - s->tcos = ff_cos_tabs[nbits]; - s->tsin = ff_sin_tabs[nbits]+(trans == DFT_R2C || trans == DFT_C2R)*(n>>2); -#if !CONFIG_HARDCODED_TABLES - for (i = 0; i < (n>>2); i++) { - s->tsin[i] = sin(i*theta); - } -#endif - s->rdft_calc = ff_rdft_calc_c; - - //if (ARCH_ARM) ff_rdft_init_arm(s); - - return 0; -} - -av_cold void ff_rdft_end(RDFTContext *s) -{ - ff_fft_end(&s->fft); -} diff --git a/apps/codecs/libwmavoice/utils.c b/apps/codecs/libwmavoice/utils.c deleted file mode 100644 index ad098f4636..0000000000 --- a/apps/codecs/libwmavoice/utils.c +++ /dev/null @@ -1,1188 +0,0 @@ -/* - * utils for libavcodec - * Copyright (c) 2001 Fabrice Bellard - * Copyright (c) 2002-2004 Michael Niedermayer - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/** - * @file - * utils. - */ - -//#include "libavutil/avstring.h" -//#include "libavutil/integer.h" -//#include "libavutil/crc.h" -//#include "libavutil/pixdesc.h" -//#include "libavcore/imgutils.h" -#include "avcodec.h" -//#include "dsputil.h" -//#include "opt.h" -//#include "imgconvert.h" -//#include "audioconvert.h" -#include "internal.h" -#include -#include -#include -#include - -#if 0 -static int volatile entangled_thread_counter=0; -int (*ff_lockmgr_cb)(void **mutex, enum AVLockOp op); -static void *codec_mutex; - -void *av_fast_realloc(void *ptr, unsigned int *size, unsigned int min_size) -{ - if(min_size < *size) - return ptr; - - *size= FFMAX(17*min_size/16 + 32, min_size); - - ptr= av_realloc(ptr, *size); - if(!ptr) //we could set this to the unmodified min_size but this is safer if the user lost the ptr and uses NULL now - *size= 0; - - return ptr; -} - -void av_fast_malloc(void *ptr, unsigned int *size, unsigned int min_size) -{ - void **p = ptr; - if (min_size < *size) - return; - *size= FFMAX(17*min_size/16 + 32, min_size); - av_free(*p); - *p = av_malloc(*size); - if (!*p) *size = 0; -} - -/* encoder management */ -static AVCodec *first_avcodec = NULL; - -AVCodec *av_codec_next(AVCodec *c){ - if(c) return c->next; - else return first_avcodec; -} - -void avcodec_register(AVCodec *codec) -{ - AVCodec **p; - avcodec_init(); - p = &first_avcodec; - while (*p != NULL) p = &(*p)->next; - *p = codec; - codec->next = NULL; -} - -#if LIBAVCODEC_VERSION_MAJOR < 53 -void register_avcodec(AVCodec *codec) -{ - avcodec_register(codec); -} -#endif - -unsigned avcodec_get_edge_width(void) -{ - return EDGE_WIDTH; -} - -void avcodec_set_dimensions(AVCodecContext *s, int width, int height){ - s->coded_width = width; - s->coded_height= height; - s->width = -((-width )>>s->lowres); - s->height= -((-height)>>s->lowres); -} - -typedef struct InternalBuffer{ - int last_pic_num; - uint8_t *base[4]; - uint8_t *data[4]; - int linesize[4]; - int width, height; - enum PixelFormat pix_fmt; -}InternalBuffer; - -#define INTERNAL_BUFFER_SIZE 32 - -void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height, int linesize_align[4]){ - int w_align= 1; - int h_align= 1; - - switch(s->pix_fmt){ - case PIX_FMT_YUV420P: - case PIX_FMT_YUYV422: - case PIX_FMT_UYVY422: - case PIX_FMT_YUV422P: - case PIX_FMT_YUV440P: - case PIX_FMT_YUV444P: - case PIX_FMT_GRAY8: - case PIX_FMT_GRAY16BE: - case PIX_FMT_GRAY16LE: - case PIX_FMT_YUVJ420P: - case PIX_FMT_YUVJ422P: - case PIX_FMT_YUVJ440P: - case PIX_FMT_YUVJ444P: - case PIX_FMT_YUVA420P: - w_align= 16; //FIXME check for non mpeg style codecs and use less alignment - h_align= 16; - if(s->codec_id == CODEC_ID_MPEG2VIDEO || s->codec_id == CODEC_ID_MJPEG || s->codec_id == CODEC_ID_AMV || s->codec_id == CODEC_ID_THP) - h_align= 32; // interlaced is rounded up to 2 MBs - break; - case PIX_FMT_YUV411P: - case PIX_FMT_UYYVYY411: - w_align=32; - h_align=8; - break; - case PIX_FMT_YUV410P: - if(s->codec_id == CODEC_ID_SVQ1){ - w_align=64; - h_align=64; - } - case PIX_FMT_RGB555: - if(s->codec_id == CODEC_ID_RPZA){ - w_align=4; - h_align=4; - } - case PIX_FMT_PAL8: - case PIX_FMT_BGR8: - case PIX_FMT_RGB8: - if(s->codec_id == CODEC_ID_SMC){ - w_align=4; - h_align=4; - } - break; - case PIX_FMT_BGR24: - if((s->codec_id == CODEC_ID_MSZH) || (s->codec_id == CODEC_ID_ZLIB)){ - w_align=4; - h_align=4; - } - break; - default: - w_align= 1; - h_align= 1; - break; - } - - *width = FFALIGN(*width , w_align); - *height= FFALIGN(*height, h_align); - if(s->codec_id == CODEC_ID_H264) - *height+=2; // some of the optimized chroma MC reads one line too much - - linesize_align[0] = - linesize_align[1] = - linesize_align[2] = - linesize_align[3] = STRIDE_ALIGN; -//STRIDE_ALIGN is 8 for SSE* but this does not work for SVQ1 chroma planes -//we could change STRIDE_ALIGN to 16 for x86/sse but it would increase the -//picture size unneccessarily in some cases. The solution here is not -//pretty and better ideas are welcome! -#if HAVE_MMX - if(s->codec_id == CODEC_ID_SVQ1 || s->codec_id == CODEC_ID_VP5 || - s->codec_id == CODEC_ID_VP6 || s->codec_id == CODEC_ID_VP6F || - s->codec_id == CODEC_ID_VP6A) { - linesize_align[0] = - linesize_align[1] = - linesize_align[2] = 16; - } -#endif -} - -void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height){ - int chroma_shift = av_pix_fmt_descriptors[s->pix_fmt].log2_chroma_w; - int linesize_align[4]; - int align; - avcodec_align_dimensions2(s, width, height, linesize_align); - align = FFMAX(linesize_align[0], linesize_align[3]); - linesize_align[1] <<= chroma_shift; - linesize_align[2] <<= chroma_shift; - align = FFMAX3(align, linesize_align[1], linesize_align[2]); - *width=FFALIGN(*width, align); -} - -#if LIBAVCODEC_VERSION_MAJOR < 53 -int avcodec_check_dimensions(void *av_log_ctx, unsigned int w, unsigned int h){ - return av_check_image_size(w, h, 0, av_log_ctx); -} -#endif - -int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic){ - int i; - int w= s->width; - int h= s->height; - InternalBuffer *buf; - int *picture_number; - - if(pic->data[0]!=NULL) { - av_log(s, AV_LOG_ERROR, "pic->data[0]!=NULL in avcodec_default_get_buffer\n"); - return -1; - } - if(s->internal_buffer_count >= INTERNAL_BUFFER_SIZE) { - av_log(s, AV_LOG_ERROR, "internal_buffer_count overflow (missing release_buffer?)\n"); - return -1; - } - - if(av_check_image_size(w, h, 0, s)) - return -1; - - if(s->internal_buffer==NULL){ - s->internal_buffer= av_mallocz((INTERNAL_BUFFER_SIZE+1)*sizeof(InternalBuffer)); - } -#if 0 - s->internal_buffer= av_fast_realloc( - s->internal_buffer, - &s->internal_buffer_size, - sizeof(InternalBuffer)*FFMAX(99, s->internal_buffer_count+1)/*FIXME*/ - ); -#endif - - buf= &((InternalBuffer*)s->internal_buffer)[s->internal_buffer_count]; - picture_number= &(((InternalBuffer*)s->internal_buffer)[INTERNAL_BUFFER_SIZE]).last_pic_num; //FIXME ugly hack - (*picture_number)++; - - if(buf->base[0] && (buf->width != w || buf->height != h || buf->pix_fmt != s->pix_fmt)){ - for(i=0; i<4; i++){ - av_freep(&buf->base[i]); - buf->data[i]= NULL; - } - } - - if(buf->base[0]){ - pic->age= *picture_number - buf->last_pic_num; - buf->last_pic_num= *picture_number; - }else{ - int h_chroma_shift, v_chroma_shift; - int size[4] = {0}; - int tmpsize; - int unaligned; - AVPicture picture; - int stride_align[4]; - - avcodec_get_chroma_sub_sample(s->pix_fmt, &h_chroma_shift, &v_chroma_shift); - - avcodec_align_dimensions2(s, &w, &h, stride_align); - - if(!(s->flags&CODEC_FLAG_EMU_EDGE)){ - w+= EDGE_WIDTH*2; - h+= EDGE_WIDTH*2; - } - - do { - // NOTE: do not align linesizes individually, this breaks e.g. assumptions - // that linesize[0] == 2*linesize[1] in the MPEG-encoder for 4:2:2 - av_fill_image_linesizes(picture.linesize, s->pix_fmt, w); - // increase alignment of w for next try (rhs gives the lowest bit set in w) - w += w & ~(w-1); - - unaligned = 0; - for (i=0; i<4; i++){ - unaligned |= picture.linesize[i] % stride_align[i]; - } - } while (unaligned); - - tmpsize = av_fill_image_pointers(picture.data, s->pix_fmt, h, NULL, picture.linesize); - if (tmpsize < 0) - return -1; - - for (i=0; i<3 && picture.data[i+1]; i++) - size[i] = picture.data[i+1] - picture.data[i]; - size[i] = tmpsize - (picture.data[i] - picture.data[0]); - - buf->last_pic_num= -256*256*256*64; - memset(buf->base, 0, sizeof(buf->base)); - memset(buf->data, 0, sizeof(buf->data)); - - for(i=0; i<4 && size[i]; i++){ - const int h_shift= i==0 ? 0 : h_chroma_shift; - const int v_shift= i==0 ? 0 : v_chroma_shift; - - buf->linesize[i]= picture.linesize[i]; - - buf->base[i]= av_malloc(size[i]+16); //FIXME 16 - if(buf->base[i]==NULL) return -1; - memset(buf->base[i], 128, size[i]); - - // no edge if EDGE EMU or not planar YUV - if((s->flags&CODEC_FLAG_EMU_EDGE) || !size[2]) - buf->data[i] = buf->base[i]; - else - buf->data[i] = buf->base[i] + FFALIGN((buf->linesize[i]*EDGE_WIDTH>>v_shift) + (EDGE_WIDTH>>h_shift), stride_align[i]); - } - if(size[1] && !size[2]) - ff_set_systematic_pal((uint32_t*)buf->data[1], s->pix_fmt); - buf->width = s->width; - buf->height = s->height; - buf->pix_fmt= s->pix_fmt; - pic->age= 256*256*256*64; - } - pic->type= FF_BUFFER_TYPE_INTERNAL; - - for(i=0; i<4; i++){ - pic->base[i]= buf->base[i]; - pic->data[i]= buf->data[i]; - pic->linesize[i]= buf->linesize[i]; - } - s->internal_buffer_count++; - - pic->reordered_opaque= s->reordered_opaque; - - if(s->debug&FF_DEBUG_BUFFERS) - av_log(s, AV_LOG_DEBUG, "default_get_buffer called on pic %p, %d buffers used\n", pic, s->internal_buffer_count); - - return 0; -} - -void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic){ - int i; - InternalBuffer *buf, *last; - - assert(pic->type==FF_BUFFER_TYPE_INTERNAL); - assert(s->internal_buffer_count); - - buf = NULL; /* avoids warning */ - for(i=0; iinternal_buffer_count; i++){ //just 3-5 checks so is not worth to optimize - buf= &((InternalBuffer*)s->internal_buffer)[i]; - if(buf->data[0] == pic->data[0]) - break; - } - assert(i < s->internal_buffer_count); - s->internal_buffer_count--; - last = &((InternalBuffer*)s->internal_buffer)[s->internal_buffer_count]; - - FFSWAP(InternalBuffer, *buf, *last); - - for(i=0; i<4; i++){ - pic->data[i]=NULL; -// pic->base[i]=NULL; - } -//printf("R%X\n", pic->opaque); - - if(s->debug&FF_DEBUG_BUFFERS) - av_log(s, AV_LOG_DEBUG, "default_release_buffer called on pic %p, %d buffers used\n", pic, s->internal_buffer_count); -} - -int avcodec_default_reget_buffer(AVCodecContext *s, AVFrame *pic){ - AVFrame temp_pic; - int i; - - /* If no picture return a new buffer */ - if(pic->data[0] == NULL) { - /* We will copy from buffer, so must be readable */ - pic->buffer_hints |= FF_BUFFER_HINTS_READABLE; - return s->get_buffer(s, pic); - } - - /* If internal buffer type return the same buffer */ - if(pic->type == FF_BUFFER_TYPE_INTERNAL) { - pic->reordered_opaque= s->reordered_opaque; - return 0; - } - - /* - * Not internal type and reget_buffer not overridden, emulate cr buffer - */ - temp_pic = *pic; - for(i = 0; i < 4; i++) - pic->data[i] = pic->base[i] = NULL; - pic->opaque = NULL; - /* Allocate new frame */ - if (s->get_buffer(s, pic)) - return -1; - /* Copy image data from old buffer to new buffer */ - av_picture_copy((AVPicture*)pic, (AVPicture*)&temp_pic, s->pix_fmt, s->width, - s->height); - s->release_buffer(s, &temp_pic); // Release old frame - return 0; -} - -int avcodec_default_execute(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2),void *arg, int *ret, int count, int size){ - int i; - - for(i=0; ipts= AV_NOPTS_VALUE; - pic->key_frame= 1; -} - -AVFrame *avcodec_alloc_frame(void){ - AVFrame *pic= av_malloc(sizeof(AVFrame)); - - if(pic==NULL) return NULL; - - avcodec_get_frame_defaults(pic); - - return pic; -} - -int attribute_align_arg avcodec_open(AVCodecContext *avctx, AVCodec *codec) -{ - int ret= -1; - - /* If there is a user-supplied mutex locking routine, call it. */ - if (ff_lockmgr_cb) { - if ((*ff_lockmgr_cb)(&codec_mutex, AV_LOCK_OBTAIN)) - return -1; - } - - entangled_thread_counter++; - if(entangled_thread_counter != 1){ - av_log(avctx, AV_LOG_ERROR, "insufficient thread locking around avcodec_open/close()\n"); - goto end; - } - - if(avctx->codec || !codec) - goto end; - - if (codec->priv_data_size > 0) { - avctx->priv_data = av_mallocz(codec->priv_data_size); - if (!avctx->priv_data) { - ret = AVERROR(ENOMEM); - goto end; - } - } else { - avctx->priv_data = NULL; - } - - if(avctx->coded_width && avctx->coded_height) - avcodec_set_dimensions(avctx, avctx->coded_width, avctx->coded_height); - else if(avctx->width && avctx->height) - avcodec_set_dimensions(avctx, avctx->width, avctx->height); - -#define SANE_NB_CHANNELS 128U - if (((avctx->coded_width || avctx->coded_height) - && av_check_image_size(avctx->coded_width, avctx->coded_height, 0, avctx)) - || avctx->channels > SANE_NB_CHANNELS) { - ret = AVERROR(EINVAL); - goto free_and_end; - } - - avctx->codec = codec; - if ((avctx->codec_type == AVMEDIA_TYPE_UNKNOWN || avctx->codec_type == codec->type) && - avctx->codec_id == CODEC_ID_NONE) { - avctx->codec_type = codec->type; - avctx->codec_id = codec->id; - } - if(avctx->codec_id != codec->id || avctx->codec_type != codec->type){ - av_log(avctx, AV_LOG_ERROR, "codec type or id mismatches\n"); - goto free_and_end; - } - avctx->frame_number = 0; - if(avctx->codec->init){ - if(avctx->codec_type == AVMEDIA_TYPE_VIDEO && - avctx->codec->max_lowres < avctx->lowres){ - av_log(avctx, AV_LOG_ERROR, "The maximum value for lowres supported by the decoder is %d\n", - avctx->codec->max_lowres); - goto free_and_end; - } - - ret = avctx->codec->init(avctx); - if (ret < 0) { - goto free_and_end; - } - } - ret=0; -end: - entangled_thread_counter--; - - /* Release any user-supplied mutex. */ - if (ff_lockmgr_cb) { - (*ff_lockmgr_cb)(&codec_mutex, AV_LOCK_RELEASE); - } - return ret; -free_and_end: - av_freep(&avctx->priv_data); - avctx->codec= NULL; - goto end; -} - -int attribute_align_arg avcodec_encode_audio(AVCodecContext *avctx, uint8_t *buf, int buf_size, - const short *samples) -{ - if(buf_size < FF_MIN_BUFFER_SIZE && 0){ - av_log(avctx, AV_LOG_ERROR, "buffer smaller than minimum size\n"); - return -1; - } - if((avctx->codec->capabilities & CODEC_CAP_DELAY) || samples){ - int ret = avctx->codec->encode(avctx, buf, buf_size, samples); - avctx->frame_number++; - return ret; - }else - return 0; -} - -int attribute_align_arg avcodec_encode_video(AVCodecContext *avctx, uint8_t *buf, int buf_size, - const AVFrame *pict) -{ - if(buf_size < FF_MIN_BUFFER_SIZE){ - av_log(avctx, AV_LOG_ERROR, "buffer smaller than minimum size\n"); - return -1; - } - if(av_check_image_size(avctx->width, avctx->height, 0, avctx)) - return -1; - if((avctx->codec->capabilities & CODEC_CAP_DELAY) || pict){ - int ret = avctx->codec->encode(avctx, buf, buf_size, pict); - avctx->frame_number++; - emms_c(); //needed to avoid an emms_c() call before every return; - - return ret; - }else - return 0; -} - -int avcodec_encode_subtitle(AVCodecContext *avctx, uint8_t *buf, int buf_size, - const AVSubtitle *sub) -{ - int ret; - if(sub->start_display_time) { - av_log(avctx, AV_LOG_ERROR, "start_display_time must be 0.\n"); - return -1; - } - if(sub->num_rects == 0 || !sub->rects) - return -1; - ret = avctx->codec->encode(avctx, buf, buf_size, sub); - avctx->frame_number++; - return ret; -} - -#if LIBAVCODEC_VERSION_MAJOR < 53 -int attribute_align_arg avcodec_decode_video(AVCodecContext *avctx, AVFrame *picture, - int *got_picture_ptr, - const uint8_t *buf, int buf_size) -{ - AVPacket avpkt; - av_init_packet(&avpkt); - avpkt.data = buf; - avpkt.size = buf_size; - // HACK for CorePNG to decode as normal PNG by default - avpkt.flags = AV_PKT_FLAG_KEY; - - return avcodec_decode_video2(avctx, picture, got_picture_ptr, &avpkt); -} -#endif - -int attribute_align_arg avcodec_decode_video2(AVCodecContext *avctx, AVFrame *picture, - int *got_picture_ptr, - AVPacket *avpkt) -{ - int ret; - - *got_picture_ptr= 0; - if((avctx->coded_width||avctx->coded_height) && av_check_image_size(avctx->coded_width, avctx->coded_height, 0, avctx)) - return -1; - if((avctx->codec->capabilities & CODEC_CAP_DELAY) || avpkt->size){ - ret = avctx->codec->decode(avctx, picture, got_picture_ptr, - avpkt); - - emms_c(); //needed to avoid an emms_c() call before every return; - - if (*got_picture_ptr) - avctx->frame_number++; - }else - ret= 0; - - return ret; -} - -#if LIBAVCODEC_VERSION_MAJOR < 53 -int attribute_align_arg avcodec_decode_audio2(AVCodecContext *avctx, int16_t *samples, - int *frame_size_ptr, - const uint8_t *buf, int buf_size) -{ - AVPacket avpkt; - av_init_packet(&avpkt); - avpkt.data = buf; - avpkt.size = buf_size; - - return avcodec_decode_audio3(avctx, samples, frame_size_ptr, &avpkt); -} -#endif - -int attribute_align_arg avcodec_decode_audio3(AVCodecContext *avctx, int16_t *samples, - int *frame_size_ptr, - AVPacket *avpkt) -{ - int ret; - - if((avctx->codec->capabilities & CODEC_CAP_DELAY) || avpkt->size){ - //FIXME remove the check below _after_ ensuring that all audio check that the available space is enough - if(*frame_size_ptr < AVCODEC_MAX_AUDIO_FRAME_SIZE){ - av_log(avctx, AV_LOG_ERROR, "buffer smaller than AVCODEC_MAX_AUDIO_FRAME_SIZE\n"); - return -1; - } - if(*frame_size_ptr < FF_MIN_BUFFER_SIZE || - *frame_size_ptr < avctx->channels * avctx->frame_size * sizeof(int16_t)){ - av_log(avctx, AV_LOG_ERROR, "buffer %d too small\n", *frame_size_ptr); - return -1; - } - - ret = avctx->codec->decode(avctx, samples, frame_size_ptr, avpkt); - avctx->frame_number++; - }else{ - ret= 0; - *frame_size_ptr=0; - } - return ret; -} - -#if LIBAVCODEC_VERSION_MAJOR < 53 -int avcodec_decode_subtitle(AVCodecContext *avctx, AVSubtitle *sub, - int *got_sub_ptr, - const uint8_t *buf, int buf_size) -{ - AVPacket avpkt; - av_init_packet(&avpkt); - avpkt.data = buf; - avpkt.size = buf_size; - - return avcodec_decode_subtitle2(avctx, sub, got_sub_ptr, &avpkt); -} -#endif - -int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub, - int *got_sub_ptr, - AVPacket *avpkt) -{ - int ret; - - *got_sub_ptr = 0; - ret = avctx->codec->decode(avctx, sub, got_sub_ptr, avpkt); - if (*got_sub_ptr) - avctx->frame_number++; - return ret; -} - -void avsubtitle_free(AVSubtitle *sub) -{ - int i; - - for (i = 0; i < sub->num_rects; i++) - { - av_freep(&sub->rects[i]->pict.data[0]); - av_freep(&sub->rects[i]->pict.data[1]); - av_freep(&sub->rects[i]->pict.data[2]); - av_freep(&sub->rects[i]->pict.data[3]); - av_freep(&sub->rects[i]->text); - av_freep(&sub->rects[i]->ass); - av_freep(&sub->rects[i]); - } - - av_freep(&sub->rects); - - memset(sub, 0, sizeof(AVSubtitle)); -} - -av_cold int avcodec_close(AVCodecContext *avctx) -{ - /* If there is a user-supplied mutex locking routine, call it. */ - if (ff_lockmgr_cb) { - if ((*ff_lockmgr_cb)(&codec_mutex, AV_LOCK_OBTAIN)) - return -1; - } - - entangled_thread_counter++; - if(entangled_thread_counter != 1){ - av_log(avctx, AV_LOG_ERROR, "insufficient thread locking around avcodec_open/close()\n"); - entangled_thread_counter--; - return -1; - } - - if (HAVE_THREADS && avctx->thread_opaque) - avcodec_thread_free(avctx); - if (avctx->codec && avctx->codec->close) - avctx->codec->close(avctx); - avcodec_default_free_buffers(avctx); - avctx->coded_frame = NULL; - av_freep(&avctx->priv_data); - if(avctx->codec && avctx->codec->encode) - av_freep(&avctx->extradata); - avctx->codec = NULL; - entangled_thread_counter--; - - /* Release any user-supplied mutex. */ - if (ff_lockmgr_cb) { - (*ff_lockmgr_cb)(&codec_mutex, AV_LOCK_RELEASE); - } - return 0; -} - -AVCodec *avcodec_find_encoder(enum CodecID id) -{ - AVCodec *p, *experimental=NULL; - p = first_avcodec; - while (p) { - if (p->encode != NULL && p->id == id) { - if (p->capabilities & CODEC_CAP_EXPERIMENTAL && !experimental) { - experimental = p; - } else - return p; - } - p = p->next; - } - return experimental; -} - -AVCodec *avcodec_find_encoder_by_name(const char *name) -{ - AVCodec *p; - if (!name) - return NULL; - p = first_avcodec; - while (p) { - if (p->encode != NULL && strcmp(name,p->name) == 0) - return p; - p = p->next; - } - return NULL; -} - -AVCodec *avcodec_find_decoder(enum CodecID id) -{ - AVCodec *p; - p = first_avcodec; - while (p) { - if (p->decode != NULL && p->id == id) - return p; - p = p->next; - } - return NULL; -} - -AVCodec *avcodec_find_decoder_by_name(const char *name) -{ - AVCodec *p; - if (!name) - return NULL; - p = first_avcodec; - while (p) { - if (p->decode != NULL && strcmp(name,p->name) == 0) - return p; - p = p->next; - } - return NULL; -} - -static int get_bit_rate(AVCodecContext *ctx) -{ - int bit_rate; - int bits_per_sample; - - switch(ctx->codec_type) { - case AVMEDIA_TYPE_VIDEO: - case AVMEDIA_TYPE_DATA: - case AVMEDIA_TYPE_SUBTITLE: - case AVMEDIA_TYPE_ATTACHMENT: - bit_rate = ctx->bit_rate; - break; - case AVMEDIA_TYPE_AUDIO: - bits_per_sample = av_get_bits_per_sample(ctx->codec_id); - bit_rate = bits_per_sample ? ctx->sample_rate * ctx->channels * bits_per_sample : ctx->bit_rate; - break; - default: - bit_rate = 0; - break; - } - return bit_rate; -} - -size_t av_get_codec_tag_string(char *buf, size_t buf_size, unsigned int codec_tag) -{ - int i, len, ret = 0; - - for (i = 0; i < 4; i++) { - len = snprintf(buf, buf_size, - isprint(codec_tag&0xFF) ? "%c" : "[%d]", codec_tag&0xFF); - buf += len; - buf_size = buf_size > len ? buf_size - len : 0; - ret += len; - codec_tag>>=8; - } - return ret; -} - -void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode) -{ - const char *codec_name; - AVCodec *p; - char buf1[32]; - int bitrate; - AVRational display_aspect_ratio; - - if (encode) - p = avcodec_find_encoder(enc->codec_id); - else - p = avcodec_find_decoder(enc->codec_id); - - if (p) { - codec_name = p->name; - } else if (enc->codec_id == CODEC_ID_MPEG2TS) { - /* fake mpeg2 transport stream codec (currently not - registered) */ - codec_name = "mpeg2ts"; - } else if (enc->codec_name[0] != '\0') { - codec_name = enc->codec_name; - } else { - /* output avi tags */ - char tag_buf[32]; - av_get_codec_tag_string(tag_buf, sizeof(tag_buf), enc->codec_tag); - snprintf(buf1, sizeof(buf1), "%s / 0x%04X", tag_buf, enc->codec_tag); - codec_name = buf1; - } - - switch(enc->codec_type) { - case AVMEDIA_TYPE_VIDEO: - snprintf(buf, buf_size, - "Video: %s%s", - codec_name, enc->mb_decision ? " (hq)" : ""); - if (enc->pix_fmt != PIX_FMT_NONE) { - snprintf(buf + strlen(buf), buf_size - strlen(buf), - ", %s", - avcodec_get_pix_fmt_name(enc->pix_fmt)); - } - if (enc->width) { - snprintf(buf + strlen(buf), buf_size - strlen(buf), - ", %dx%d", - enc->width, enc->height); - if (enc->sample_aspect_ratio.num) { - av_reduce(&display_aspect_ratio.num, &display_aspect_ratio.den, - enc->width*enc->sample_aspect_ratio.num, - enc->height*enc->sample_aspect_ratio.den, - 1024*1024); - snprintf(buf + strlen(buf), buf_size - strlen(buf), - " [PAR %d:%d DAR %d:%d]", - enc->sample_aspect_ratio.num, enc->sample_aspect_ratio.den, - display_aspect_ratio.num, display_aspect_ratio.den); - } - if(av_log_get_level() >= AV_LOG_DEBUG){ - int g= av_gcd(enc->time_base.num, enc->time_base.den); - snprintf(buf + strlen(buf), buf_size - strlen(buf), - ", %d/%d", - enc->time_base.num/g, enc->time_base.den/g); - } - } - if (encode) { - snprintf(buf + strlen(buf), buf_size - strlen(buf), - ", q=%d-%d", enc->qmin, enc->qmax); - } - break; - case AVMEDIA_TYPE_AUDIO: - snprintf(buf, buf_size, - "Audio: %s", - codec_name); - if (enc->sample_rate) { - snprintf(buf + strlen(buf), buf_size - strlen(buf), - ", %d Hz", enc->sample_rate); - } - av_strlcat(buf, ", ", buf_size); - avcodec_get_channel_layout_string(buf + strlen(buf), buf_size - strlen(buf), enc->channels, enc->channel_layout); - if (enc->sample_fmt != SAMPLE_FMT_NONE) { - snprintf(buf + strlen(buf), buf_size - strlen(buf), - ", %s", avcodec_get_sample_fmt_name(enc->sample_fmt)); - } - break; - case AVMEDIA_TYPE_DATA: - snprintf(buf, buf_size, "Data: %s", codec_name); - break; - case AVMEDIA_TYPE_SUBTITLE: - snprintf(buf, buf_size, "Subtitle: %s", codec_name); - break; - case AVMEDIA_TYPE_ATTACHMENT: - snprintf(buf, buf_size, "Attachment: %s", codec_name); - break; - default: - snprintf(buf, buf_size, "Invalid Codec type %d", enc->codec_type); - return; - } - if (encode) { - if (enc->flags & CODEC_FLAG_PASS1) - snprintf(buf + strlen(buf), buf_size - strlen(buf), - ", pass 1"); - if (enc->flags & CODEC_FLAG_PASS2) - snprintf(buf + strlen(buf), buf_size - strlen(buf), - ", pass 2"); - } - bitrate = get_bit_rate(enc); - if (bitrate != 0) { - snprintf(buf + strlen(buf), buf_size - strlen(buf), - ", %d kb/s", bitrate / 1000); - } -} - -unsigned avcodec_version( void ) -{ - return LIBAVCODEC_VERSION_INT; -} - -const char *avcodec_configuration(void) -{ - return FFMPEG_CONFIGURATION; -} - -const char *avcodec_license(void) -{ -#define LICENSE_PREFIX "libavcodec license: " - return LICENSE_PREFIX FFMPEG_LICENSE + sizeof(LICENSE_PREFIX) - 1; -} - -void avcodec_init(void) -{ - static int initialized = 0; - - if (initialized != 0) - return; - initialized = 1; - - dsputil_static_init(); -} - -void avcodec_flush_buffers(AVCodecContext *avctx) -{ - if(avctx->codec->flush) - avctx->codec->flush(avctx); -} - -void avcodec_default_free_buffers(AVCodecContext *s){ - int i, j; - - if(s->internal_buffer==NULL) return; - - if (s->internal_buffer_count) - av_log(s, AV_LOG_WARNING, "Found %i unreleased buffers!\n", s->internal_buffer_count); - for(i=0; iinternal_buffer)[i]; - for(j=0; j<4; j++){ - av_freep(&buf->base[j]); - buf->data[j]= NULL; - } - } - av_freep(&s->internal_buffer); - - s->internal_buffer_count=0; -} - -char av_get_pict_type_char(int pict_type){ - switch(pict_type){ - case FF_I_TYPE: return 'I'; - case FF_P_TYPE: return 'P'; - case FF_B_TYPE: return 'B'; - case FF_S_TYPE: return 'S'; - case FF_SI_TYPE:return 'i'; - case FF_SP_TYPE:return 'p'; - case FF_BI_TYPE:return 'b'; - default: return '?'; - } -} - -int av_get_bits_per_sample(enum CodecID codec_id){ - switch(codec_id){ - case CODEC_ID_ADPCM_SBPRO_2: - return 2; - case CODEC_ID_ADPCM_SBPRO_3: - return 3; - case CODEC_ID_ADPCM_SBPRO_4: - case CODEC_ID_ADPCM_CT: - case CODEC_ID_ADPCM_IMA_WAV: - case CODEC_ID_ADPCM_MS: - case CODEC_ID_ADPCM_YAMAHA: - return 4; - case CODEC_ID_PCM_ALAW: - case CODEC_ID_PCM_MULAW: - case CODEC_ID_PCM_S8: - case CODEC_ID_PCM_U8: - case CODEC_ID_PCM_ZORK: - return 8; - case CODEC_ID_PCM_S16BE: - case CODEC_ID_PCM_S16LE: - case CODEC_ID_PCM_S16LE_PLANAR: - case CODEC_ID_PCM_U16BE: - case CODEC_ID_PCM_U16LE: - return 16; - case CODEC_ID_PCM_S24DAUD: - case CODEC_ID_PCM_S24BE: - case CODEC_ID_PCM_S24LE: - case CODEC_ID_PCM_U24BE: - case CODEC_ID_PCM_U24LE: - return 24; - case CODEC_ID_PCM_S32BE: - case CODEC_ID_PCM_S32LE: - case CODEC_ID_PCM_U32BE: - case CODEC_ID_PCM_U32LE: - case CODEC_ID_PCM_F32BE: - case CODEC_ID_PCM_F32LE: - return 32; - case CODEC_ID_PCM_F64BE: - case CODEC_ID_PCM_F64LE: - return 64; - default: - return 0; - } -} - -int av_get_bits_per_sample_format(enum SampleFormat sample_fmt) { - switch (sample_fmt) { - case SAMPLE_FMT_U8: - return 8; - case SAMPLE_FMT_S16: - return 16; - case SAMPLE_FMT_S32: - case SAMPLE_FMT_FLT: - return 32; - case SAMPLE_FMT_DBL: - return 64; - default: - return 0; - } -} - -#if !HAVE_THREADS -int avcodec_thread_init(AVCodecContext *s, int thread_count){ - s->thread_count = thread_count; - return -1; -} -#endif - -unsigned int av_xiphlacing(unsigned char *s, unsigned int v) -{ - unsigned int n = 0; - - while(v >= 0xff) { - *s++ = 0xff; - v -= 0xff; - n++; - } - *s = v; - n++; - return n; -} - -#if LIBAVCODEC_VERSION_MAJOR < 53 -#include "libavcore/parseutils.h" - -int av_parse_video_frame_size(int *width_ptr, int *height_ptr, const char *str) -{ - return av_parse_video_size(width_ptr, height_ptr, str); -} - -int av_parse_video_frame_rate(AVRational *frame_rate, const char *arg) -{ - return av_parse_video_rate(frame_rate, arg); -} -#endif - -int ff_match_2uint16(const uint16_t (*tab)[2], int size, int a, int b){ - int i; - for(i=0; inext; - *p = hwaccel; - hwaccel->next = NULL; -} - -AVHWAccel *av_hwaccel_next(AVHWAccel *hwaccel) -{ - return hwaccel ? hwaccel->next : first_hwaccel; -} - -AVHWAccel *ff_find_hwaccel(enum CodecID codec_id, enum PixelFormat pix_fmt) -{ - AVHWAccel *hwaccel=NULL; - - while((hwaccel= av_hwaccel_next(hwaccel))){ - if ( hwaccel->id == codec_id - && hwaccel->pix_fmt == pix_fmt) - return hwaccel; - } - return NULL; -} - -int av_lockmgr_register(int (*cb)(void **mutex, enum AVLockOp op)) -{ - if (ff_lockmgr_cb) { - if (ff_lockmgr_cb(&codec_mutex, AV_LOCK_DESTROY)) - return -1; - } - - ff_lockmgr_cb = cb; - - if (ff_lockmgr_cb) { - if (ff_lockmgr_cb(&codec_mutex, AV_LOCK_CREATE)) - return -1; - } - return 0; -} - -unsigned int ff_toupper4(unsigned int x) -{ - return toupper( x &0xFF) - + (toupper((x>>8 )&0xFF)<<8 ) - + (toupper((x>>16)&0xFF)<<16) - + (toupper((x>>24)&0xFF)<<24); -} -#endif diff --git a/apps/codecs/libwmavoice/wmavoice.c b/apps/codecs/libwmavoice/wmavoice.c deleted file mode 100644 index 4d31334c36..0000000000 --- a/apps/codecs/libwmavoice/wmavoice.c +++ /dev/null @@ -1,2060 +0,0 @@ -/* - * Windows Media Audio Voice decoder. - * Copyright (c) 2009 Ronald S. Bultje - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/** - * @file - * @brief Windows Media Audio Voice compatible decoder - * @author Ronald S. Bultje - */ - -#include -#include "wmavoice.h" -#include "get_bits.h" -#include "put_bits.h" -#include "wmavoice_data.h" -#include "celp_math.h" -#include "celp_filters.h" -#include "acelp_vectors.h" -#include "acelp_filters.h" -#include "lsp.h" -#include "libavutil/lzo.h" -#include "avfft.h" -#include "fft.h" - -#define MAX_BLOCKS 8 ///< maximum number of blocks per frame -#define MAX_LSPS 16 ///< maximum filter order -#define MAX_LSPS_ALIGN16 16 ///< same as #MAX_LSPS; needs to be multiple - ///< of 16 for ASM input buffer alignment -#define MAX_FRAMES 3 ///< maximum number of frames per superframe -#define MAX_FRAMESIZE 160 ///< maximum number of samples per frame -#define MAX_SIGNAL_HISTORY 416 ///< maximum excitation signal history -#define MAX_SFRAMESIZE (MAX_FRAMESIZE * MAX_FRAMES) - ///< maximum number of samples per superframe -#define SFRAME_CACHE_MAXSIZE 256 ///< maximum cache size for frame data that - ///< was split over two packets -#define VLC_NBITS 6 ///< number of bits to read per VLC iteration - -/** - * Frame type VLC coding. - */ -static VLC frame_type_vlc; - -/** - * Adaptive codebook types. - */ -enum { - ACB_TYPE_NONE = 0, ///< no adaptive codebook (only hardcoded fixed) - ACB_TYPE_ASYMMETRIC = 1, ///< adaptive codebook with per-frame pitch, which - ///< we interpolate to get a per-sample pitch. - ///< Signal is generated using an asymmetric sinc - ///< window function - ///< @note see #wmavoice_ipol1_coeffs - ACB_TYPE_HAMMING = 2 ///< Per-block pitch with signal generation using - ///< a Hamming sinc window function - ///< @note see #wmavoice_ipol2_coeffs -}; - -/** - * Fixed codebook types. - */ -enum { - FCB_TYPE_SILENCE = 0, ///< comfort noise during silence - ///< generated from a hardcoded (fixed) codebook - ///< with per-frame (low) gain values - FCB_TYPE_HARDCODED = 1, ///< hardcoded (fixed) codebook with per-block - ///< gain values - FCB_TYPE_AW_PULSES = 2, ///< Pitch-adaptive window (AW) pulse signals, - ///< used in particular for low-bitrate streams - FCB_TYPE_EXC_PULSES = 3, ///< Innovation (fixed) codebook pulse sets in - ///< combinations of either single pulses or - ///< pulse pairs -}; - -/** - * Description of frame types. - */ -static const struct frame_type_desc { - uint8_t n_blocks; ///< amount of blocks per frame (each block - ///< (contains 160/#n_blocks samples) - uint8_t log_n_blocks; ///< log2(#n_blocks) - uint8_t acb_type; ///< Adaptive codebook type (ACB_TYPE_*) - uint8_t fcb_type; ///< Fixed codebook type (FCB_TYPE_*) - uint8_t dbl_pulses; ///< how many pulse vectors have pulse pairs - ///< (rather than just one single pulse) - ///< only if #fcb_type == #FCB_TYPE_EXC_PULSES - uint16_t frame_size; ///< the amount of bits that make up the block - ///< data (per frame) -} frame_descs[17] = { - { 1, 0, ACB_TYPE_NONE, FCB_TYPE_SILENCE, 0, 0 }, - { 2, 1, ACB_TYPE_NONE, FCB_TYPE_HARDCODED, 0, 28 }, - { 2, 1, ACB_TYPE_ASYMMETRIC, FCB_TYPE_AW_PULSES, 0, 46 }, - { 2, 1, ACB_TYPE_ASYMMETRIC, FCB_TYPE_EXC_PULSES, 2, 80 }, - { 2, 1, ACB_TYPE_ASYMMETRIC, FCB_TYPE_EXC_PULSES, 5, 104 }, - { 4, 2, ACB_TYPE_ASYMMETRIC, FCB_TYPE_EXC_PULSES, 0, 108 }, - { 4, 2, ACB_TYPE_ASYMMETRIC, FCB_TYPE_EXC_PULSES, 2, 132 }, - { 4, 2, ACB_TYPE_ASYMMETRIC, FCB_TYPE_EXC_PULSES, 5, 168 }, - { 2, 1, ACB_TYPE_HAMMING, FCB_TYPE_EXC_PULSES, 0, 64 }, - { 2, 1, ACB_TYPE_HAMMING, FCB_TYPE_EXC_PULSES, 2, 80 }, - { 2, 1, ACB_TYPE_HAMMING, FCB_TYPE_EXC_PULSES, 5, 104 }, - { 4, 2, ACB_TYPE_HAMMING, FCB_TYPE_EXC_PULSES, 0, 108 }, - { 4, 2, ACB_TYPE_HAMMING, FCB_TYPE_EXC_PULSES, 2, 132 }, - { 4, 2, ACB_TYPE_HAMMING, FCB_TYPE_EXC_PULSES, 5, 168 }, - { 8, 3, ACB_TYPE_HAMMING, FCB_TYPE_EXC_PULSES, 0, 176 }, - { 8, 3, ACB_TYPE_HAMMING, FCB_TYPE_EXC_PULSES, 2, 208 }, - { 8, 3, ACB_TYPE_HAMMING, FCB_TYPE_EXC_PULSES, 5, 256 } -}; - -/** - * WMA Voice decoding context. - */ -typedef struct { - /** - * @defgroup struct_global Global values - * Global values, specified in the stream header / extradata or used - * all over. - * @{ - */ - GetBitContext gb; ///< packet bitreader. During decoder init, - ///< it contains the extradata from the - ///< demuxer. During decoding, it contains - ///< packet data. - int8_t vbm_tree[25]; ///< converts VLC codes to frame type - - int spillover_bitsize; ///< number of bits used to specify - ///< #spillover_nbits in the packet header - ///< = ceil(log2(ctx->block_align << 3)) - int history_nsamples; ///< number of samples in history for signal - ///< prediction (through ACB) - - /* postfilter specific values */ - int do_apf; ///< whether to apply the averaged - ///< projection filter (APF) - int denoise_strength; ///< strength of denoising in Wiener filter - ///< [0-11] - int denoise_tilt_corr; ///< Whether to apply tilt correction to the - ///< Wiener filter coefficients (postfilter) - int dc_level; ///< Predicted amount of DC noise, based - ///< on which a DC removal filter is used - - int lsps; ///< number of LSPs per frame [10 or 16] - int lsp_q_mode; ///< defines quantizer defaults [0, 1] - int lsp_def_mode; ///< defines different sets of LSP defaults - ///< [0, 1] - int frame_lsp_bitsize; ///< size (in bits) of LSPs, when encoded - ///< per-frame (independent coding) - int sframe_lsp_bitsize; ///< size (in bits) of LSPs, when encoded - ///< per superframe (residual coding) - - int min_pitch_val; ///< base value for pitch parsing code - int max_pitch_val; ///< max value + 1 for pitch parsing - int pitch_nbits; ///< number of bits used to specify the - ///< pitch value in the frame header - int block_pitch_nbits; ///< number of bits used to specify the - ///< first block's pitch value - int block_pitch_range; ///< range of the block pitch - int block_delta_pitch_nbits; ///< number of bits used to specify the - ///< delta pitch between this and the last - ///< block's pitch value, used in all but - ///< first block - int block_delta_pitch_hrange; ///< 1/2 range of the delta (full range is - ///< from -this to +this-1) - uint16_t block_conv_table[4]; ///< boundaries for block pitch unit/scale - ///< conversion - - /** - * @} - * @defgroup struct_packet Packet values - * Packet values, specified in the packet header or related to a packet. - * A packet is considered to be a single unit of data provided to this - * decoder by the demuxer. - * @{ - */ - int spillover_nbits; ///< number of bits of the previous packet's - ///< last superframe preceeding this - ///< packet's first full superframe (useful - ///< for re-synchronization also) - int has_residual_lsps; ///< if set, superframes contain one set of - ///< LSPs that cover all frames, encoded as - ///< independent and residual LSPs; if not - ///< set, each frame contains its own, fully - ///< independent, LSPs - int skip_bits_next; ///< number of bits to skip at the next call - ///< to #wmavoice_decode_packet() (since - ///< they're part of the previous superframe) - - uint8_t sframe_cache[SFRAME_CACHE_MAXSIZE + FF_INPUT_BUFFER_PADDING_SIZE]; - ///< cache for superframe data split over - ///< multiple packets - int sframe_cache_size; ///< set to >0 if we have data from an - ///< (incomplete) superframe from a previous - ///< packet that spilled over in the current - ///< packet; specifies the amount of bits in - ///< #sframe_cache - PutBitContext pb; ///< bitstream writer for #sframe_cache - - /** - * @} - * @defgroup struct_frame Frame and superframe values - * Superframe and frame data - these can change from frame to frame, - * although some of them do in that case serve as a cache / history for - * the next frame or superframe. - * @{ - */ - double prev_lsps[MAX_LSPS]; ///< LSPs of the last frame of the previous - ///< superframe - int last_pitch_val; ///< pitch value of the previous frame - int last_acb_type; ///< frame type [0-2] of the previous frame - int pitch_diff_sh16; ///< ((cur_pitch_val - #last_pitch_val) - ///< << 16) / #MAX_FRAMESIZE - float silence_gain; ///< set for use in blocks if #ACB_TYPE_NONE - - int aw_idx_is_ext; ///< whether the AW index was encoded in - ///< 8 bits (instead of 6) - int aw_pulse_range; ///< the range over which #aw_pulse_set1() - ///< can apply the pulse, relative to the - ///< value in aw_first_pulse_off. The exact - ///< position of the first AW-pulse is within - ///< [pulse_off, pulse_off + this], and - ///< depends on bitstream values; [16 or 24] - int aw_n_pulses[2]; ///< number of AW-pulses in each block; note - ///< that this number can be negative (in - ///< which case it basically means "zero") - int aw_first_pulse_off[2]; ///< index of first sample to which to - ///< apply AW-pulses, or -0xff if unset - int aw_next_pulse_off_cache; ///< the position (relative to start of the - ///< second block) at which pulses should - ///< start to be positioned, serves as a - ///< cache for pitch-adaptive window pulses - ///< between blocks - - int frame_cntr; ///< current frame index [0 - 0xFFFE]; is - ///< only used for comfort noise in #pRNG() - float gain_pred_err[6]; ///< cache for gain prediction - float excitation_history[MAX_SIGNAL_HISTORY]; - ///< cache of the signal of previous - ///< superframes, used as a history for - ///< signal generation - float synth_history[MAX_LSPS]; ///< see #excitation_history - /** - * @} - * @defgroup post_filter Postfilter values - * Varibales used for postfilter implementation, mostly history for - * smoothing and so on, and context variables for FFT/iFFT. - * @{ - */ - RDFTContext rdft, irdft; ///< contexts for FFT-calculation in the - ///< postfilter (for denoise filter) - DCTContext dct, dst; ///< contexts for phase shift (in Hilbert - ///< transform, part of postfilter) - float sin[511], cos[511]; ///< 8-bit cosine/sine windows over [-pi,pi] - ///< range - float postfilter_agc; ///< gain control memory, used in - ///< #adaptive_gain_control() - float dcf_mem[2]; ///< DC filter history - float zero_exc_pf[MAX_SIGNAL_HISTORY + MAX_SFRAMESIZE]; - ///< zero filter output (i.e. excitation) - ///< by postfilter - float denoise_filter_cache[MAX_FRAMESIZE]; - int denoise_filter_cache_size; ///< samples in #denoise_filter_cache - DECLARE_ALIGNED(16, float, tilted_lpcs_pf)[0x80]; - ///< aligned buffer for LPC tilting - DECLARE_ALIGNED(16, float, denoise_coeffs_pf)[0x80]; - ///< aligned buffer for denoise coefficients - DECLARE_ALIGNED(16, float, synth_filter_out_buf)[0x80 + MAX_LSPS_ALIGN16]; - ///< aligned buffer for postfilter speech - ///< synthesis - /** - * @} - */ -} WMAVoiceContext; - -/* global decode context */ -static WMAVoiceContext globWMAVoiceCtx; - - -/** - * Set up the variable bit mode (VBM) tree from container extradata. - * @param gb bit I/O context. - * The bit context (s->gb) should be loaded with byte 23-46 of the - * container extradata (i.e. the ones containing the VBM tree). - * @param vbm_tree pointer to array to which the decoded VBM tree will be - * written. - * @return 0 on success, <0 on error. - */ -static av_cold int decode_vbmtree(GetBitContext *gb, int8_t vbm_tree[25]) -{ - static const uint8_t bits[] = { - 2, 2, 2, 4, 4, 4, - 6, 6, 6, 8, 8, 8, - 10, 10, 10, 12, 12, 12, - 14, 14, 14, 14 - }; - static const uint16_t codes[] = { - 0x0000, 0x0001, 0x0002, // 00/01/10 - 0x000c, 0x000d, 0x000e, // 11+00/01/10 - 0x003c, 0x003d, 0x003e, // 1111+00/01/10 - 0x00fc, 0x00fd, 0x00fe, // 111111+00/01/10 - 0x03fc, 0x03fd, 0x03fe, // 11111111+00/01/10 - 0x0ffc, 0x0ffd, 0x0ffe, // 1111111111+00/01/10 - 0x3ffc, 0x3ffd, 0x3ffe, 0x3fff // 111111111111+xx - }; - int cntr[8], n, res; - - memset(vbm_tree, 0xff, sizeof(int8_t) * 25); - memset(cntr, 0, sizeof(cntr)); - for (n = 0; n < 17; n++) { - res = get_bits(gb, 3); - if (cntr[res] > 3) // should be >= 3 + (res == 7)) - return -1; - vbm_tree[res * 3 + cntr[res]++] = n; - } - INIT_VLC_STATIC(&frame_type_vlc, VLC_NBITS, sizeof(bits), - bits, 1, 1, codes, 2, 2, 132); - return 0; -} - -/** - * Set up decoder with parameters from demuxer (extradata etc.). - */ -av_cold int wmavoice_decode_init(AVCodecContext *ctx) -{ - int n, flags, pitch_range, lsp16_flag; - ctx->priv_data = &globWMAVoiceCtx; - WMAVoiceContext *s = ctx->priv_data; - - /** - * Extradata layout: - * - byte 0-18: WMAPro-in-WMAVoice extradata (see wmaprodec.c), - * - byte 19-22: flags field (annoyingly in LE; see below for known - * values), - * - byte 23-46: variable bitmode tree (really just 17 * 3 bits, - * rest is 0). - */ - if (ctx->extradata_size != 46) { - av_log(ctx, AV_LOG_ERROR, - "Invalid extradata size %d (should be 46)\n", - ctx->extradata_size); - return -1; - } - flags = AV_RL32(ctx->extradata + 18); - s->spillover_bitsize = 3 + av_ceil_log2(ctx->block_align); - s->do_apf = flags & 0x1; - if (s->do_apf) { - ff_rdft_init(&s->rdft, 7, DFT_R2C); - ff_rdft_init(&s->irdft, 7, IDFT_C2R); - ff_dct_init(&s->dct, 6, DCT_I); - ff_dct_init(&s->dst, 6, DST_I); - - ff_sine_window_init(s->cos, 256); - memcpy(&s->sin[255], s->cos, 256 * sizeof(s->cos[0])); - for (n = 0; n < 255; n++) { - s->sin[n] = -s->sin[510 - n]; - s->cos[510 - n] = s->cos[n]; - } - } - s->denoise_strength = (flags >> 2) & 0xF; - if (s->denoise_strength >= 12) { - av_log(ctx, AV_LOG_ERROR, - "Invalid denoise filter strength %d (max=11)\n", - s->denoise_strength); - return -1; - } - s->denoise_tilt_corr = !!(flags & 0x40); - s->dc_level = (flags >> 7) & 0xF; - s->lsp_q_mode = !!(flags & 0x2000); - s->lsp_def_mode = !!(flags & 0x4000); - lsp16_flag = flags & 0x1000; - if (lsp16_flag) { - s->lsps = 16; - s->frame_lsp_bitsize = 34; - s->sframe_lsp_bitsize = 60; - } else { - s->lsps = 10; - s->frame_lsp_bitsize = 24; - s->sframe_lsp_bitsize = 48; - } - for (n = 0; n < s->lsps; n++) - s->prev_lsps[n] = M_PI * (n + 1.0) / (s->lsps + 1.0); - - init_get_bits(&s->gb, ctx->extradata + 22, (ctx->extradata_size - 22) << 3); - if (decode_vbmtree(&s->gb, s->vbm_tree) < 0) { - av_log(ctx, AV_LOG_ERROR, "Invalid VBM tree; broken extradata?\n"); - return -1; - } - - s->min_pitch_val = ((ctx->sample_rate << 8) / 400 + 50) >> 8; - s->max_pitch_val = ((ctx->sample_rate << 8) * 37 / 2000 + 50) >> 8; - pitch_range = s->max_pitch_val - s->min_pitch_val; - s->pitch_nbits = av_ceil_log2(pitch_range); - s->last_pitch_val = 40; - s->last_acb_type = ACB_TYPE_NONE; - s->history_nsamples = s->max_pitch_val + 8; - - if (s->min_pitch_val < 1 || s->history_nsamples > MAX_SIGNAL_HISTORY) { - int min_sr = ((((1 << 8) - 50) * 400) + 0xFF) >> 8, - max_sr = ((((MAX_SIGNAL_HISTORY - 8) << 8) + 205) * 2000 / 37) >> 8; - - av_log(ctx, AV_LOG_ERROR, - "Unsupported samplerate %d (min=%d, max=%d)\n", - ctx->sample_rate, min_sr, max_sr); // 322-22097 Hz - - return -1; - } - - s->block_conv_table[0] = s->min_pitch_val; - s->block_conv_table[1] = (pitch_range * 25) >> 6; - s->block_conv_table[2] = (pitch_range * 44) >> 6; - s->block_conv_table[3] = s->max_pitch_val - 1; - s->block_delta_pitch_hrange = (pitch_range >> 3) & ~0xF; - s->block_delta_pitch_nbits = 1 + av_ceil_log2(s->block_delta_pitch_hrange); - s->block_pitch_range = s->block_conv_table[2] + - s->block_conv_table[3] + 1 + - 2 * (s->block_conv_table[1] - 2 * s->min_pitch_val); - s->block_pitch_nbits = av_ceil_log2(s->block_pitch_range); - - ctx->sample_fmt = SAMPLE_FMT_FLT; - - return 0; -} - -/** - * @defgroup postfilter Postfilter functions - * Postfilter functions (gain control, wiener denoise filter, DC filter, - * kalman smoothening, plus surrounding code to wrap it) - * @{ - */ -/** - * Adaptive gain control (as used in postfilter). - * - * Identical to #ff_adaptive_gain_control() in acelp_vectors.c, except - * that the energy here is calculated using sum(abs(...)), whereas the - * other codecs (e.g. AMR-NB, SIPRO) use sqrt(dotproduct(...)). - * - * @param out output buffer for filtered samples - * @param in input buffer containing the samples as they are after the - * postfilter steps so far - * @param speech_synth input buffer containing speech synth before postfilter - * @param size input buffer size - * @param alpha exponential filter factor - * @param gain_mem pointer to filter memory (single float) - */ -static void adaptive_gain_control(float *out, const float *in, - const float *speech_synth, - int size, float alpha, float *gain_mem) -{ - int i; - float speech_energy = 0.0, postfilter_energy = 0.0, gain_scale_factor; - float mem = *gain_mem; - - for (i = 0; i < size; i++) { - speech_energy += fabsf(speech_synth[i]); - postfilter_energy += fabsf(in[i]); - } - gain_scale_factor = (1.0 - alpha) * speech_energy / postfilter_energy; - - for (i = 0; i < size; i++) { - mem = alpha * mem + gain_scale_factor; - out[i] = in[i] * mem; - } - - *gain_mem = mem; -} - -/** - * Kalman smoothing function. - * - * This function looks back pitch +/- 3 samples back into history to find - * the best fitting curve (that one giving the optimal gain of the two - * signals, i.e. the highest dot product between the two), and then - * uses that signal history to smoothen the output of the speech synthesis - * filter. - * - * @param s WMA Voice decoding context - * @param pitch pitch of the speech signal - * @param in input speech signal - * @param out output pointer for smoothened signal - * @param size input/output buffer size - * - * @returns -1 if no smoothening took place, e.g. because no optimal - * fit could be found, or 0 on success. - */ -static int kalman_smoothen(WMAVoiceContext *s, int pitch, - const float *in, float *out, int size) -{ - int n; - float optimal_gain = 0, dot; - const float *ptr = &in[-FFMAX(s->min_pitch_val, pitch - 3)], - *end = &in[-FFMIN(s->max_pitch_val, pitch + 3)], - *best_hist_ptr; - - /* find best fitting point in history */ - do { - dot = ff_dot_productf(in, ptr, size); - if (dot > optimal_gain) { - optimal_gain = dot; - best_hist_ptr = ptr; - } - } while (--ptr >= end); - - if (optimal_gain <= 0) - return -1; - dot = ff_dot_productf(best_hist_ptr, best_hist_ptr, size); - if (dot <= 0) // would be 1.0 - return -1; - - if (optimal_gain <= dot) { - dot = dot / (dot + 0.6 * optimal_gain); // 0.625-1.000 - } else - dot = 0.625; - - /* actual smoothing */ - for (n = 0; n < size; n++) - out[n] = best_hist_ptr[n] + dot * (in[n] - best_hist_ptr[n]); - - return 0; -} - -/** - * Get the tilt factor of a formant filter from its transfer function - * @see #tilt_factor() in amrnbdec.c, which does essentially the same, - * but somehow (??) it does a speech synthesis filter in the - * middle, which is missing here - * - * @param lpcs LPC coefficients - * @param n_lpcs Size of LPC buffer - * @returns the tilt factor - */ -static float tilt_factor(const float *lpcs, int n_lpcs) -{ - float rh0, rh1; - - rh0 = 1.0 + ff_dot_productf(lpcs, lpcs, n_lpcs); - rh1 = lpcs[0] + ff_dot_productf(lpcs, &lpcs[1], n_lpcs - 1); - - return rh1 / rh0; -} - -/** - * Derive denoise filter coefficients (in real domain) from the LPCs. - */ -static void calc_input_response(WMAVoiceContext *s, float *lpcs, - int fcb_type, float *coeffs, int remainder) -{ - float last_coeff, min = 15.0, max = -15.0; - float irange, angle_mul, gain_mul, range, sq; - int n, idx; - - /* Create frequency power spectrum of speech input (i.e. RDFT of LPCs) */ - ff_rdft_calc(&s->rdft, lpcs); -#define log_range(var, assign) do { \ - float tmp = log10f(assign); var = tmp; \ - max = FFMAX(max, tmp); min = FFMIN(min, tmp); \ - } while (0) - log_range(last_coeff, lpcs[1] * lpcs[1]); - for (n = 1; n < 64; n++) - log_range(lpcs[n], lpcs[n * 2] * lpcs[n * 2] + - lpcs[n * 2 + 1] * lpcs[n * 2 + 1]); - log_range(lpcs[0], lpcs[0] * lpcs[0]); -#undef log_range - range = max - min; - lpcs[64] = last_coeff; - - /* Now, use this spectrum to pick out these frequencies with higher - * (relative) power/energy (which we then take to be "not noise"), - * and set up a table (still in lpc[]) of (relative) gains per frequency. - * These frequencies will be maintained, while others ("noise") will be - * decreased in the filter output. */ - irange = 64.0 / range; // so irange*(max-value) is in the range [0, 63] - gain_mul = range * (fcb_type == FCB_TYPE_HARDCODED ? (5.0 / 13.0) : - (5.0 / 14.7)); - angle_mul = gain_mul * (8.0 * M_LN10 / M_PI); - for (n = 0; n <= 64; n++) { - float pwr; - - idx = FFMAX(0, lrint((max - lpcs[n]) * irange) - 1); - pwr = wmavoice_denoise_power_table[s->denoise_strength][idx]; - lpcs[n] = angle_mul * pwr; - - /* 70.57 =~ 1/log10(1.0331663) */ - idx = (pwr * gain_mul - 0.0295) * 70.570526123; - if (idx > 127) { // fallback if index falls outside table range - coeffs[n] = wmavoice_energy_table[127] * - powf(1.0331663, idx - 127); - } else - coeffs[n] = wmavoice_energy_table[FFMAX(0, idx)]; - } - - /* calculate the Hilbert transform of the gains, which we do (since this - * is a sinus input) by doing a phase shift (in theory, H(sin())=cos()). - * Hilbert_Transform(RDFT(x)) = Laplace_Transform(x), which calculates the - * "moment" of the LPCs in this filter. */ - ff_dct_calc(&s->dct, lpcs); - ff_dct_calc(&s->dst, lpcs); - - /* Split out the coefficient indexes into phase/magnitude pairs */ - idx = 255 + av_clip(lpcs[64], -255, 255); - coeffs[0] = coeffs[0] * s->cos[idx]; - idx = 255 + av_clip(lpcs[64] - 2 * lpcs[63], -255, 255); - last_coeff = coeffs[64] * s->cos[idx]; - for (n = 63;; n--) { - idx = 255 + av_clip(-lpcs[64] - 2 * lpcs[n - 1], -255, 255); - coeffs[n * 2 + 1] = coeffs[n] * s->sin[idx]; - coeffs[n * 2] = coeffs[n] * s->cos[idx]; - - if (!--n) break; - - idx = 255 + av_clip( lpcs[64] - 2 * lpcs[n - 1], -255, 255); - coeffs[n * 2 + 1] = coeffs[n] * s->sin[idx]; - coeffs[n * 2] = coeffs[n] * s->cos[idx]; - } - coeffs[1] = last_coeff; - - /* move into real domain */ - ff_rdft_calc(&s->irdft, coeffs); - - /* tilt correction and normalize scale */ - memset(&coeffs[remainder], 0, sizeof(coeffs[0]) * (128 - remainder)); - if (s->denoise_tilt_corr) { - float tilt_mem = 0; - - coeffs[remainder - 1] = 0; - ff_tilt_compensation(&tilt_mem, - -1.8 * tilt_factor(coeffs, remainder - 1), - coeffs, remainder); - } - sq = (1.0 / 64.0) * sqrtf(1 / ff_dot_productf(coeffs, coeffs, remainder)); - for (n = 0; n < remainder; n++) - coeffs[n] *= sq; -} - -/** - * This function applies a Wiener filter on the (noisy) speech signal as - * a means to denoise it. - * - * - take RDFT of LPCs to get the power spectrum of the noise + speech; - * - using this power spectrum, calculate (for each frequency) the Wiener - * filter gain, which depends on the frequency power and desired level - * of noise subtraction (when set too high, this leads to artifacts) - * We can do this symmetrically over the X-axis (so 0-4kHz is the inverse - * of 4-8kHz); - * - by doing a phase shift, calculate the Hilbert transform of this array - * of per-frequency filter-gains to get the filtering coefficients; - * - smoothen/normalize/de-tilt these filter coefficients as desired; - * - take RDFT of noisy sound, apply the coefficients and take its IRDFT - * to get the denoised speech signal; - * - the leftover (i.e. output of the IRDFT on denoised speech data beyond - * the frame boundary) are saved and applied to subsequent frames by an - * overlap-add method (otherwise you get clicking-artifacts). - * - * @param s WMA Voice decoding context - * @param fcb_type Frame (codebook) type - * @param synth_pf input: the noisy speech signal, output: denoised speech - * data; should be 16-byte aligned (for ASM purposes) - * @param size size of the speech data - * @param lpcs LPCs used to synthesize this frame's speech data - */ -static void wiener_denoise(WMAVoiceContext *s, int fcb_type, - float *synth_pf, int size, - const float *lpcs) -{ - int remainder, lim, n; - - if (fcb_type != FCB_TYPE_SILENCE) { - float *tilted_lpcs = s->tilted_lpcs_pf, - *coeffs = s->denoise_coeffs_pf, tilt_mem = 0; - - tilted_lpcs[0] = 1.0; - memcpy(&tilted_lpcs[1], lpcs, sizeof(lpcs[0]) * s->lsps); - memset(&tilted_lpcs[s->lsps + 1], 0, - sizeof(tilted_lpcs[0]) * (128 - s->lsps - 1)); - ff_tilt_compensation(&tilt_mem, 0.7 * tilt_factor(lpcs, s->lsps), - tilted_lpcs, s->lsps + 2); - - /* The IRDFT output (127 samples for 7-bit filter) beyond the frame - * size is applied to the next frame. All input beyond this is zero, - * and thus all output beyond this will go towards zero, hence we can - * limit to min(size-1, 127-size) as a performance consideration. */ - remainder = FFMIN(127 - size, size - 1); - calc_input_response(s, tilted_lpcs, fcb_type, coeffs, remainder); - - /* apply coefficients (in frequency spectrum domain), i.e. complex - * number multiplication */ - memset(&synth_pf[size], 0, sizeof(synth_pf[0]) * (128 - size)); - ff_rdft_calc(&s->rdft, synth_pf); - ff_rdft_calc(&s->rdft, coeffs); - synth_pf[0] *= coeffs[0]; - synth_pf[1] *= coeffs[1]; - for (n = 1; n < 64; n++) { - float v1 = synth_pf[n * 2], v2 = synth_pf[n * 2 + 1]; - synth_pf[n * 2] = v1 * coeffs[n * 2] - v2 * coeffs[n * 2 + 1]; - synth_pf[n * 2 + 1] = v2 * coeffs[n * 2] + v1 * coeffs[n * 2 + 1]; - } - ff_rdft_calc(&s->irdft, synth_pf); - } - - /* merge filter output with the history of previous runs */ - if (s->denoise_filter_cache_size) { - lim = FFMIN(s->denoise_filter_cache_size, size); - for (n = 0; n < lim; n++) - synth_pf[n] += s->denoise_filter_cache[n]; - s->denoise_filter_cache_size -= lim; - memmove(s->denoise_filter_cache, &s->denoise_filter_cache[size], - sizeof(s->denoise_filter_cache[0]) * s->denoise_filter_cache_size); - } - - /* move remainder of filter output into a cache for future runs */ - if (fcb_type != FCB_TYPE_SILENCE) { - lim = FFMIN(remainder, s->denoise_filter_cache_size); - for (n = 0; n < lim; n++) - s->denoise_filter_cache[n] += synth_pf[size + n]; - if (lim < remainder) { - memcpy(&s->denoise_filter_cache[lim], &synth_pf[size + lim], - sizeof(s->denoise_filter_cache[0]) * (remainder - lim)); - s->denoise_filter_cache_size = remainder; - } - } -} - -/** - * Averaging projection filter, the postfilter used in WMAVoice. - * - * This uses the following steps: - * - A zero-synthesis filter (generate excitation from synth signal) - * - Kalman smoothing on excitation, based on pitch - * - Re-synthesized smoothened output - * - Iterative Wiener denoise filter - * - Adaptive gain filter - * - DC filter - * - * @param s WMAVoice decoding context - * @param synth Speech synthesis output (before postfilter) - * @param samples Output buffer for filtered samples - * @param size Buffer size of synth & samples - * @param lpcs Generated LPCs used for speech synthesis - * @param zero_exc_pf destination for zero synthesis filter (16-byte aligned) - * @param fcb_type Frame type (silence, hardcoded, AW-pulses or FCB-pulses) - * @param pitch Pitch of the input signal - */ -static void postfilter(WMAVoiceContext *s, const float *synth, - float *samples, int size, - const float *lpcs, float *zero_exc_pf, - int fcb_type, int pitch) -{ - float synth_filter_in_buf[MAX_FRAMESIZE / 2], - *synth_pf = &s->synth_filter_out_buf[MAX_LSPS_ALIGN16], - *synth_filter_in = zero_exc_pf; - - assert(size <= MAX_FRAMESIZE / 2); - - /* generate excitation from input signal */ - ff_celp_lp_zero_synthesis_filterf(zero_exc_pf, lpcs, synth, size, s->lsps); - - if (fcb_type >= FCB_TYPE_AW_PULSES && - !kalman_smoothen(s, pitch, zero_exc_pf, synth_filter_in_buf, size)) - synth_filter_in = synth_filter_in_buf; - - /* re-synthesize speech after smoothening, and keep history */ - ff_celp_lp_synthesis_filterf(synth_pf, lpcs, - synth_filter_in, size, s->lsps); - memcpy(&synth_pf[-s->lsps], &synth_pf[size - s->lsps], - sizeof(synth_pf[0]) * s->lsps); - - wiener_denoise(s, fcb_type, synth_pf, size, lpcs); - - adaptive_gain_control(samples, synth_pf, synth, size, 0.99, - &s->postfilter_agc); - - if (s->dc_level > 8) { - /* remove ultra-low frequency DC noise / highpass filter; - * coefficients are identical to those used in SIPR decoding, - * and very closely resemble those used in AMR-NB decoding. */ - ff_acelp_apply_order_2_transfer_function(samples, samples, - (const float[2]) { -1.99997, 1.0 }, - (const float[2]) { -1.9330735188, 0.93589198496 }, - 0.93980580475, s->dcf_mem, size); - } -} -/** - * @} - */ - -/** - * Dequantize LSPs - * @param lsps output pointer to the array that will hold the LSPs - * @param num number of LSPs to be dequantized - * @param values quantized values, contains n_stages values - * @param sizes range (i.e. max value) of each quantized value - * @param n_stages number of dequantization runs - * @param table dequantization table to be used - * @param mul_q LSF multiplier - * @param base_q base (lowest) LSF values - */ -static void dequant_lsps(double *lsps, int num, - const uint16_t *values, - const uint16_t *sizes, - int n_stages, const uint8_t *table, - const double *mul_q, - const double *base_q) -{ - int n, m; - - memset(lsps, 0, num * sizeof(*lsps)); - for (n = 0; n < n_stages; n++) { - const uint8_t *t_off = &table[values[n] * num]; - double base = base_q[n], mul = mul_q[n]; - - for (m = 0; m < num; m++) - lsps[m] += base + mul * t_off[m]; - - table += sizes[n] * num; - } -} - -/** - * @defgroup lsp_dequant LSP dequantization routines - * LSP dequantization routines, for 10/16LSPs and independent/residual coding. - * @note we assume enough bits are available, caller should check. - * lsp10i() consumes 24 bits; lsp10r() consumes an additional 24 bits; - * lsp16i() consumes 34 bits; lsp16r() consumes an additional 26 bits. - * @{ - */ -/** - * Parse 10 independently-coded LSPs. - */ -static void dequant_lsp10i(GetBitContext *gb, double *lsps) -{ - static const uint16_t vec_sizes[4] = { 256, 64, 32, 32 }; - static const double mul_lsf[4] = { - 5.2187144800e-3, 1.4626986422e-3, - 9.6179549166e-4, 1.1325736225e-3 - }; - static const double base_lsf[4] = { - M_PI * -2.15522e-1, M_PI * -6.1646e-2, - M_PI * -3.3486e-2, M_PI * -5.7408e-2 - }; - uint16_t v[4]; - - v[0] = get_bits(gb, 8); - v[1] = get_bits(gb, 6); - v[2] = get_bits(gb, 5); - v[3] = get_bits(gb, 5); - - dequant_lsps(lsps, 10, v, vec_sizes, 4, wmavoice_dq_lsp10i, - mul_lsf, base_lsf); -} - -/** - * Parse 10 independently-coded LSPs, and then derive the tables to - * generate LSPs for the other frames from them (residual coding). - */ -static void dequant_lsp10r(GetBitContext *gb, - double *i_lsps, const double *old, - double *a1, double *a2, int q_mode) -{ - static const uint16_t vec_sizes[3] = { 128, 64, 64 }; - static const double mul_lsf[3] = { - 2.5807601174e-3, 1.2354460219e-3, 1.1763821673e-3 - }; - static const double base_lsf[3] = { - M_PI * -1.07448e-1, M_PI * -5.2706e-2, M_PI * -5.1634e-2 - }; - const float (*ipol_tab)[2][10] = q_mode ? - wmavoice_lsp10_intercoeff_b : wmavoice_lsp10_intercoeff_a; - uint16_t interpol, v[3]; - int n; - - dequant_lsp10i(gb, i_lsps); - - interpol = get_bits(gb, 5); - v[0] = get_bits(gb, 7); - v[1] = get_bits(gb, 6); - v[2] = get_bits(gb, 6); - - for (n = 0; n < 10; n++) { - double delta = old[n] - i_lsps[n]; - a1[n] = ipol_tab[interpol][0][n] * delta + i_lsps[n]; - a1[10 + n] = ipol_tab[interpol][1][n] * delta + i_lsps[n]; - } - - dequant_lsps(a2, 20, v, vec_sizes, 3, wmavoice_dq_lsp10r, - mul_lsf, base_lsf); -} - -/** - * Parse 16 independently-coded LSPs. - */ -static void dequant_lsp16i(GetBitContext *gb, double *lsps) -{ - static const uint16_t vec_sizes[5] = { 256, 64, 128, 64, 128 }; - static const double mul_lsf[5] = { - 3.3439586280e-3, 6.9908173703e-4, - 3.3216608306e-3, 1.0334960326e-3, - 3.1899104283e-3 - }; - static const double base_lsf[5] = { - M_PI * -1.27576e-1, M_PI * -2.4292e-2, - M_PI * -1.28094e-1, M_PI * -3.2128e-2, - M_PI * -1.29816e-1 - }; - uint16_t v[5]; - - v[0] = get_bits(gb, 8); - v[1] = get_bits(gb, 6); - v[2] = get_bits(gb, 7); - v[3] = get_bits(gb, 6); - v[4] = get_bits(gb, 7); - - dequant_lsps( lsps, 5, v, vec_sizes, 2, - wmavoice_dq_lsp16i1, mul_lsf, base_lsf); - dequant_lsps(&lsps[5], 5, &v[2], &vec_sizes[2], 2, - wmavoice_dq_lsp16i2, &mul_lsf[2], &base_lsf[2]); - dequant_lsps(&lsps[10], 6, &v[4], &vec_sizes[4], 1, - wmavoice_dq_lsp16i3, &mul_lsf[4], &base_lsf[4]); -} - -/** - * Parse 16 independently-coded LSPs, and then derive the tables to - * generate LSPs for the other frames from them (residual coding). - */ -static void dequant_lsp16r(GetBitContext *gb, - double *i_lsps, const double *old, - double *a1, double *a2, int q_mode) -{ - static const uint16_t vec_sizes[3] = { 128, 128, 128 }; - static const double mul_lsf[3] = { - 1.2232979501e-3, 1.4062241527e-3, 1.6114744851e-3 - }; - static const double base_lsf[3] = { - M_PI * -5.5830e-2, M_PI * -5.2908e-2, M_PI * -5.4776e-2 - }; - const float (*ipol_tab)[2][16] = q_mode ? - wmavoice_lsp16_intercoeff_b : wmavoice_lsp16_intercoeff_a; - uint16_t interpol, v[3]; - int n; - - dequant_lsp16i(gb, i_lsps); - - interpol = get_bits(gb, 5); - v[0] = get_bits(gb, 7); - v[1] = get_bits(gb, 7); - v[2] = get_bits(gb, 7); - - for (n = 0; n < 16; n++) { - double delta = old[n] - i_lsps[n]; - a1[n] = ipol_tab[interpol][0][n] * delta + i_lsps[n]; - a1[16 + n] = ipol_tab[interpol][1][n] * delta + i_lsps[n]; - } - - dequant_lsps( a2, 10, v, vec_sizes, 1, - wmavoice_dq_lsp16r1, mul_lsf, base_lsf); - dequant_lsps(&a2[10], 10, &v[1], &vec_sizes[1], 1, - wmavoice_dq_lsp16r2, &mul_lsf[1], &base_lsf[1]); - dequant_lsps(&a2[20], 12, &v[2], &vec_sizes[2], 1, - wmavoice_dq_lsp16r3, &mul_lsf[2], &base_lsf[2]); -} - -/** - * @} - * @defgroup aw Pitch-adaptive window coding functions - * The next few functions are for pitch-adaptive window coding. - * @{ - */ -/** - * Parse the offset of the first pitch-adaptive window pulses, and - * the distribution of pulses between the two blocks in this frame. - * @param s WMA Voice decoding context private data - * @param gb bit I/O context - * @param pitch pitch for each block in this frame - */ -static void aw_parse_coords(WMAVoiceContext *s, GetBitContext *gb, - const int *pitch) -{ - static const int16_t start_offset[94] = { - -11, -9, -7, -5, -3, -1, 1, 3, 5, 7, 9, 11, - 13, 15, 18, 17, 19, 20, 21, 22, 23, 24, 25, 26, - 27, 28, 29, 30, 31, 32, 33, 35, 37, 39, 41, 43, - 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, - 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, - 93, 95, 97, 99, 101, 103, 105, 107, 109, 111, 113, 115, - 117, 119, 121, 123, 125, 127, 129, 131, 133, 135, 137, 139, - 141, 143, 145, 147, 149, 151, 153, 155, 157, 159 - }; - int bits, offset; - - /* position of pulse */ - s->aw_idx_is_ext = 0; - if ((bits = get_bits(gb, 6)) >= 54) { - s->aw_idx_is_ext = 1; - bits += (bits - 54) * 3 + get_bits(gb, 2); - } - - /* for a repeated pulse at pulse_off with a pitch_lag of pitch[], count - * the distribution of the pulses in each block contained in this frame. */ - s->aw_pulse_range = FFMIN(pitch[0], pitch[1]) > 32 ? 24 : 16; - for (offset = start_offset[bits]; offset < 0; offset += pitch[0]) ; - s->aw_n_pulses[0] = (pitch[0] - 1 + MAX_FRAMESIZE / 2 - offset) / pitch[0]; - s->aw_first_pulse_off[0] = offset - s->aw_pulse_range / 2; - offset += s->aw_n_pulses[0] * pitch[0]; - s->aw_n_pulses[1] = (pitch[1] - 1 + MAX_FRAMESIZE - offset) / pitch[1]; - s->aw_first_pulse_off[1] = offset - (MAX_FRAMESIZE + s->aw_pulse_range) / 2; - - /* if continuing from a position before the block, reset position to - * start of block (when corrected for the range over which it can be - * spread in aw_pulse_set1()). */ - if (start_offset[bits] < MAX_FRAMESIZE / 2) { - while (s->aw_first_pulse_off[1] - pitch[1] + s->aw_pulse_range > 0) - s->aw_first_pulse_off[1] -= pitch[1]; - if (start_offset[bits] < 0) - while (s->aw_first_pulse_off[0] - pitch[0] + s->aw_pulse_range > 0) - s->aw_first_pulse_off[0] -= pitch[0]; - } -} - -/** - * Apply second set of pitch-adaptive window pulses. - * @param s WMA Voice decoding context private data - * @param gb bit I/O context - * @param block_idx block index in frame [0, 1] - * @param fcb structure containing fixed codebook vector info - */ -static void aw_pulse_set2(WMAVoiceContext *s, GetBitContext *gb, - int block_idx, AMRFixed *fcb) -{ - uint16_t use_mask[7]; // only 5 are used, rest is padding - /* in this function, idx is the index in the 80-bit (+ padding) use_mask - * bit-array. Since use_mask consists of 16-bit values, the lower 4 bits - * of idx are the position of the bit within a particular item in the - * array (0 being the most significant bit, and 15 being the least - * significant bit), and the remainder (>> 4) is the index in the - * use_mask[]-array. This is faster and uses less memory than using a - * 80-byte/80-int array. */ - int pulse_off = s->aw_first_pulse_off[block_idx], - pulse_start, n, idx, range, aidx, start_off = 0; - - /* set offset of first pulse to within this block */ - if (s->aw_n_pulses[block_idx] > 0) - while (pulse_off + s->aw_pulse_range < 1) - pulse_off += fcb->pitch_lag; - - /* find range per pulse */ - if (s->aw_n_pulses[0] > 0) { - if (block_idx == 0) { - range = 32; - } else /* block_idx = 1 */ { - range = 8; - if (s->aw_n_pulses[block_idx] > 0) - pulse_off = s->aw_next_pulse_off_cache; - } - } else - range = 16; - pulse_start = s->aw_n_pulses[block_idx] > 0 ? pulse_off - range / 2 : 0; - - /* aw_pulse_set1() already applies pulses around pulse_off (to be exactly, - * in the range of [pulse_off, pulse_off + s->aw_pulse_range], and thus - * we exclude that range from being pulsed again in this function. */ - memset( use_mask, -1, 5 * sizeof(use_mask[0])); - memset(&use_mask[5], 0, 2 * sizeof(use_mask[0])); - if (s->aw_n_pulses[block_idx] > 0) - for (idx = pulse_off; idx < MAX_FRAMESIZE / 2; idx += fcb->pitch_lag) { - int excl_range = s->aw_pulse_range; // always 16 or 24 - uint16_t *use_mask_ptr = &use_mask[idx >> 4]; - int first_sh = 16 - (idx & 15); - *use_mask_ptr++ &= 0xFFFF << first_sh; - excl_range -= first_sh; - if (excl_range >= 16) { - *use_mask_ptr++ = 0; - *use_mask_ptr &= 0xFFFF >> (excl_range - 16); - } else - *use_mask_ptr &= 0xFFFF >> excl_range; - } - - /* find the 'aidx'th offset that is not excluded */ - aidx = get_bits(gb, s->aw_n_pulses[0] > 0 ? 5 - 2 * block_idx : 4); - for (n = 0; n <= aidx; pulse_start++) { - for (idx = pulse_start; idx < 0; idx += fcb->pitch_lag) ; - if (idx >= MAX_FRAMESIZE / 2) { // find from zero - if (use_mask[0]) idx = 0x0F; - else if (use_mask[1]) idx = 0x1F; - else if (use_mask[2]) idx = 0x2F; - else if (use_mask[3]) idx = 0x3F; - else if (use_mask[4]) idx = 0x4F; - else return; - idx -= av_log2_16bit(use_mask[idx >> 4]); - } - if (use_mask[idx >> 4] & (0x8000 >> (idx & 15))) { - use_mask[idx >> 4] &= ~(0x8000 >> (idx & 15)); - n++; - start_off = idx; - } - } - - fcb->x[fcb->n] = start_off; - fcb->y[fcb->n] = get_bits1(gb) ? -1.0 : 1.0; - fcb->n++; - - /* set offset for next block, relative to start of that block */ - n = (MAX_FRAMESIZE / 2 - start_off) % fcb->pitch_lag; - s->aw_next_pulse_off_cache = n ? fcb->pitch_lag - n : 0; -} - -/** - * Apply first set of pitch-adaptive window pulses. - * @param s WMA Voice decoding context private data - * @param gb bit I/O context - * @param block_idx block index in frame [0, 1] - * @param fcb storage location for fixed codebook pulse info - */ -static void aw_pulse_set1(WMAVoiceContext *s, GetBitContext *gb, - int block_idx, AMRFixed *fcb) -{ - int val = get_bits(gb, 12 - 2 * (s->aw_idx_is_ext && !block_idx)); - float v; - - if (s->aw_n_pulses[block_idx] > 0) { - int n, v_mask, i_mask, sh, n_pulses; - - if (s->aw_pulse_range == 24) { // 3 pulses, 1:sign + 3:index each - n_pulses = 3; - v_mask = 8; - i_mask = 7; - sh = 4; - } else { // 4 pulses, 1:sign + 2:index each - n_pulses = 4; - v_mask = 4; - i_mask = 3; - sh = 3; - } - - for (n = n_pulses - 1; n >= 0; n--, val >>= sh) { - fcb->y[fcb->n] = (val & v_mask) ? -1.0 : 1.0; - fcb->x[fcb->n] = (val & i_mask) * n_pulses + n + - s->aw_first_pulse_off[block_idx]; - while (fcb->x[fcb->n] < 0) - fcb->x[fcb->n] += fcb->pitch_lag; - if (fcb->x[fcb->n] < MAX_FRAMESIZE / 2) - fcb->n++; - } - } else { - int num2 = (val & 0x1FF) >> 1, delta, idx; - - if (num2 < 1 * 79) { delta = 1; idx = num2 + 1; } - else if (num2 < 2 * 78) { delta = 3; idx = num2 + 1 - 1 * 77; } - else if (num2 < 3 * 77) { delta = 5; idx = num2 + 1 - 2 * 76; } - else { delta = 7; idx = num2 + 1 - 3 * 75; } - v = (val & 0x200) ? -1.0 : 1.0; - - fcb->no_repeat_mask |= 3 << fcb->n; - fcb->x[fcb->n] = idx - delta; - fcb->y[fcb->n] = v; - fcb->x[fcb->n + 1] = idx; - fcb->y[fcb->n + 1] = (val & 1) ? -v : v; - fcb->n += 2; - } -} - -/** - * @} - * - * Generate a random number from frame_cntr and block_idx, which will lief - * in the range [0, 1000 - block_size] (so it can be used as an index in a - * table of size 1000 of which you want to read block_size entries). - * - * @param frame_cntr current frame number - * @param block_num current block index - * @param block_size amount of entries we want to read from a table - * that has 1000 entries - * @return a (non-)random number in the [0, 1000 - block_size] range. - */ -static int pRNG(int frame_cntr, int block_num, int block_size) -{ - /* array to simplify the calculation of z: - * y = (x % 9) * 5 + 6; - * z = (49995 * x) / y; - * Since y only has 9 values, we can remove the division by using a - * LUT and using FASTDIV-style divisions. For each of the 9 values - * of y, we can rewrite z as: - * z = x * (49995 / y) + x * ((49995 % y) / y) - * In this table, each col represents one possible value of y, the - * first number is 49995 / y, and the second is the FASTDIV variant - * of 49995 % y / y. */ - static const unsigned int div_tbl[9][2] = { - { 8332, 3 * 715827883U }, // y = 6 - { 4545, 0 * 390451573U }, // y = 11 - { 3124, 11 * 268435456U }, // y = 16 - { 2380, 15 * 204522253U }, // y = 21 - { 1922, 23 * 165191050U }, // y = 26 - { 1612, 23 * 138547333U }, // y = 31 - { 1388, 27 * 119304648U }, // y = 36 - { 1219, 16 * 104755300U }, // y = 41 - { 1086, 39 * 93368855U } // y = 46 - }; - unsigned int z, y, x = MUL16(block_num, 1877) + frame_cntr; - if (x >= 0xFFFF) x -= 0xFFFF; // max value of x is 8*1877+0xFFFE=0x13AA6, - // so this is effectively a modulo (%) - y = x - 9 * MULH(477218589, x); // x % 9 - z = (uint16_t) (x * div_tbl[y][0] + UMULH(x, div_tbl[y][1])); - // z = x * 49995 / (y * 5 + 6) - return z % (1000 - block_size); -} - -/** - * Parse hardcoded signal for a single block. - * @note see #synth_block(). - */ -static void synth_block_hardcoded(WMAVoiceContext *s, GetBitContext *gb, - int block_idx, int size, - const struct frame_type_desc *frame_desc, - float *excitation) -{ - float gain; - int n, r_idx; - - assert(size <= MAX_FRAMESIZE); - - /* Set the offset from which we start reading wmavoice_std_codebook */ - if (frame_desc->fcb_type == FCB_TYPE_SILENCE) { - r_idx = pRNG(s->frame_cntr, block_idx, size); - gain = s->silence_gain; - } else /* FCB_TYPE_HARDCODED */ { - r_idx = get_bits(gb, 8); - gain = wmavoice_gain_universal[get_bits(gb, 6)]; - } - - /* Clear gain prediction parameters */ - memset(s->gain_pred_err, 0, sizeof(s->gain_pred_err)); - - /* Apply gain to hardcoded codebook and use that as excitation signal */ - for (n = 0; n < size; n++) - excitation[n] = wmavoice_std_codebook[r_idx + n] * gain; -} - -/** - * Parse FCB/ACB signal for a single block. - * @note see #synth_block(). - */ -static void synth_block_fcb_acb(WMAVoiceContext *s, GetBitContext *gb, - int block_idx, int size, - int block_pitch_sh2, - const struct frame_type_desc *frame_desc, - float *excitation) -{ - static const float gain_coeff[6] = { - 0.8169, -0.06545, 0.1726, 0.0185, -0.0359, 0.0458 - }; - float pulses[MAX_FRAMESIZE / 2], pred_err, acb_gain, fcb_gain; - int n, idx, gain_weight; - AMRFixed fcb; - - assert(size <= MAX_FRAMESIZE / 2); - memset(pulses, 0, sizeof(*pulses) * size); - - fcb.pitch_lag = block_pitch_sh2 >> 2; - fcb.pitch_fac = 1.0; - fcb.no_repeat_mask = 0; - fcb.n = 0; - - /* For the other frame types, this is where we apply the innovation - * (fixed) codebook pulses of the speech signal. */ - if (frame_desc->fcb_type == FCB_TYPE_AW_PULSES) { - aw_pulse_set1(s, gb, block_idx, &fcb); - aw_pulse_set2(s, gb, block_idx, &fcb); - } else /* FCB_TYPE_EXC_PULSES */ { - int offset_nbits = 5 - frame_desc->log_n_blocks; - - fcb.no_repeat_mask = -1; - /* similar to ff_decode_10_pulses_35bits(), but with single pulses - * (instead of double) for a subset of pulses */ - for (n = 0; n < 5; n++) { - float sign; - int pos1, pos2; - - sign = get_bits1(gb) ? 1.0 : -1.0; - pos1 = get_bits(gb, offset_nbits); - fcb.x[fcb.n] = n + 5 * pos1; - fcb.y[fcb.n++] = sign; - if (n < frame_desc->dbl_pulses) { - pos2 = get_bits(gb, offset_nbits); - fcb.x[fcb.n] = n + 5 * pos2; - fcb.y[fcb.n++] = (pos1 < pos2) ? -sign : sign; - } - } - } - ff_set_fixed_vector(pulses, &fcb, 1.0, size); - - /* Calculate gain for adaptive & fixed codebook signal. - * see ff_amr_set_fixed_gain(). */ - idx = get_bits(gb, 7); - fcb_gain = expf(ff_dot_productf(s->gain_pred_err, gain_coeff, 6) - - 5.2409161640 + wmavoice_gain_codebook_fcb[idx]); - acb_gain = wmavoice_gain_codebook_acb[idx]; - pred_err = av_clipf(wmavoice_gain_codebook_fcb[idx], - -2.9957322736 /* log(0.05) */, - 1.6094379124 /* log(5.0) */); - - gain_weight = 8 >> frame_desc->log_n_blocks; - memmove(&s->gain_pred_err[gain_weight], s->gain_pred_err, - sizeof(*s->gain_pred_err) * (6 - gain_weight)); - for (n = 0; n < gain_weight; n++) - s->gain_pred_err[n] = pred_err; - - /* Calculation of adaptive codebook */ - if (frame_desc->acb_type == ACB_TYPE_ASYMMETRIC) { - int len; - for (n = 0; n < size; n += len) { - int next_idx_sh16; - int abs_idx = block_idx * size + n; - int pitch_sh16 = (s->last_pitch_val << 16) + - s->pitch_diff_sh16 * abs_idx; - int pitch = (pitch_sh16 + 0x6FFF) >> 16; - int idx_sh16 = ((pitch << 16) - pitch_sh16) * 8 + 0x58000; - idx = idx_sh16 >> 16; - if (s->pitch_diff_sh16) { - if (s->pitch_diff_sh16 > 0) { - next_idx_sh16 = (idx_sh16) &~ 0xFFFF; - } else - next_idx_sh16 = (idx_sh16 + 0x10000) &~ 0xFFFF; - len = av_clip((idx_sh16 - next_idx_sh16) / s->pitch_diff_sh16 / 8, - 1, size - n); - } else - len = size; - - ff_acelp_interpolatef(&excitation[n], &excitation[n - pitch], - wmavoice_ipol1_coeffs, 17, - idx, 9, len); - } - } else /* ACB_TYPE_HAMMING */ { - int block_pitch = block_pitch_sh2 >> 2; - idx = block_pitch_sh2 & 3; - if (idx) { - ff_acelp_interpolatef(excitation, &excitation[-block_pitch], - wmavoice_ipol2_coeffs, 4, - idx, 8, size); - } else - av_memcpy_backptr((uint8_t *) excitation, sizeof(float) * block_pitch, - sizeof(float) * size); - } - - /* Interpolate ACB/FCB and use as excitation signal */ - ff_weighted_vector_sumf(excitation, excitation, pulses, - acb_gain, fcb_gain, size); -} - -/** - * Parse data in a single block. - * @note we assume enough bits are available, caller should check. - * - * @param s WMA Voice decoding context private data - * @param gb bit I/O context - * @param block_idx index of the to-be-read block - * @param size amount of samples to be read in this block - * @param block_pitch_sh2 pitch for this block << 2 - * @param lsps LSPs for (the end of) this frame - * @param prev_lsps LSPs for the last frame - * @param frame_desc frame type descriptor - * @param excitation target memory for the ACB+FCB interpolated signal - * @param synth target memory for the speech synthesis filter output - * @return 0 on success, <0 on error. - */ -static void synth_block(WMAVoiceContext *s, GetBitContext *gb, - int block_idx, int size, - int block_pitch_sh2, - const double *lsps, const double *prev_lsps, - const struct frame_type_desc *frame_desc, - float *excitation, float *synth) -{ - double i_lsps[MAX_LSPS]; - float lpcs[MAX_LSPS]; - float fac; - int n; - - if (frame_desc->acb_type == ACB_TYPE_NONE) - synth_block_hardcoded(s, gb, block_idx, size, frame_desc, excitation); - else - synth_block_fcb_acb(s, gb, block_idx, size, block_pitch_sh2, - frame_desc, excitation); - - /* convert interpolated LSPs to LPCs */ - fac = (block_idx + 0.5) / frame_desc->n_blocks; - for (n = 0; n < s->lsps; n++) // LSF -> LSP - i_lsps[n] = cos(prev_lsps[n] + fac * (lsps[n] - prev_lsps[n])); - ff_acelp_lspd2lpc(i_lsps, lpcs, s->lsps >> 1); - - /* Speech synthesis */ - ff_celp_lp_synthesis_filterf(synth, lpcs, excitation, size, s->lsps); -} - -/** - * Synthesize output samples for a single frame. - * @note we assume enough bits are available, caller should check. - * - * @param ctx WMA Voice decoder context - * @param gb bit I/O context (s->gb or one for cross-packet superframes) - * @param frame_idx Frame number within superframe [0-2] - * @param samples pointer to output sample buffer, has space for at least 160 - * samples - * @param lsps LSP array - * @param prev_lsps array of previous frame's LSPs - * @param excitation target buffer for excitation signal - * @param synth target buffer for synthesized speech data - * @return 0 on success, <0 on error. - */ -static int synth_frame(AVCodecContext *ctx, GetBitContext *gb, int frame_idx, - float *samples, - const double *lsps, const double *prev_lsps, - float *excitation, float *synth) -{ - WMAVoiceContext *s = ctx->priv_data; - int n, n_blocks_x2, log_n_blocks_x2, cur_pitch_val; - int pitch[MAX_BLOCKS], last_block_pitch; - - /* Parse frame type ("frame header"), see frame_descs */ - int bd_idx = s->vbm_tree[get_vlc2(gb, frame_type_vlc.table, 6, 3)], - block_nsamples = MAX_FRAMESIZE / frame_descs[bd_idx].n_blocks; - - if (bd_idx < 0) { - av_log(ctx, AV_LOG_ERROR, - "Invalid frame type VLC code, skipping\n"); - return -1; - } - - /* Pitch calculation for ACB_TYPE_ASYMMETRIC ("pitch-per-frame") */ - if (frame_descs[bd_idx].acb_type == ACB_TYPE_ASYMMETRIC) { - /* Pitch is provided per frame, which is interpreted as the pitch of - * the last sample of the last block of this frame. We can interpolate - * the pitch of other blocks (and even pitch-per-sample) by gradually - * incrementing/decrementing prev_frame_pitch to cur_pitch_val. */ - n_blocks_x2 = frame_descs[bd_idx].n_blocks << 1; - log_n_blocks_x2 = frame_descs[bd_idx].log_n_blocks + 1; - cur_pitch_val = s->min_pitch_val + get_bits(gb, s->pitch_nbits); - cur_pitch_val = FFMIN(cur_pitch_val, s->max_pitch_val - 1); - if (s->last_acb_type == ACB_TYPE_NONE || - 20 * abs(cur_pitch_val - s->last_pitch_val) > - (cur_pitch_val + s->last_pitch_val)) - s->last_pitch_val = cur_pitch_val; - - /* pitch per block */ - for (n = 0; n < frame_descs[bd_idx].n_blocks; n++) { - int fac = n * 2 + 1; - - pitch[n] = (MUL16(fac, cur_pitch_val) + - MUL16((n_blocks_x2 - fac), s->last_pitch_val) + - frame_descs[bd_idx].n_blocks) >> log_n_blocks_x2; - } - - /* "pitch-diff-per-sample" for calculation of pitch per sample */ - s->pitch_diff_sh16 = - ((cur_pitch_val - s->last_pitch_val) << 16) / MAX_FRAMESIZE; - } - - /* Global gain (if silence) and pitch-adaptive window coordinates */ - switch (frame_descs[bd_idx].fcb_type) { - case FCB_TYPE_SILENCE: - s->silence_gain = wmavoice_gain_silence[get_bits(gb, 8)]; - break; - case FCB_TYPE_AW_PULSES: - aw_parse_coords(s, gb, pitch); - break; - } - - for (n = 0; n < frame_descs[bd_idx].n_blocks; n++) { - int bl_pitch_sh2; - - /* Pitch calculation for ACB_TYPE_HAMMING ("pitch-per-block") */ - switch (frame_descs[bd_idx].acb_type) { - case ACB_TYPE_HAMMING: { - /* Pitch is given per block. Per-block pitches are encoded as an - * absolute value for the first block, and then delta values - * relative to this value) for all subsequent blocks. The scale of - * this pitch value is semi-logaritmic compared to its use in the - * decoder, so we convert it to normal scale also. */ - int block_pitch, - t1 = (s->block_conv_table[1] - s->block_conv_table[0]) << 2, - t2 = (s->block_conv_table[2] - s->block_conv_table[1]) << 1, - t3 = s->block_conv_table[3] - s->block_conv_table[2] + 1; - - if (n == 0) { - block_pitch = get_bits(gb, s->block_pitch_nbits); - } else - block_pitch = last_block_pitch - s->block_delta_pitch_hrange + - get_bits(gb, s->block_delta_pitch_nbits); - /* Convert last_ so that any next delta is within _range */ - last_block_pitch = av_clip(block_pitch, - s->block_delta_pitch_hrange, - s->block_pitch_range - - s->block_delta_pitch_hrange); - - /* Convert semi-log-style scale back to normal scale */ - if (block_pitch < t1) { - bl_pitch_sh2 = (s->block_conv_table[0] << 2) + block_pitch; - } else { - block_pitch -= t1; - if (block_pitch < t2) { - bl_pitch_sh2 = - (s->block_conv_table[1] << 2) + (block_pitch << 1); - } else { - block_pitch -= t2; - if (block_pitch < t3) { - bl_pitch_sh2 = - (s->block_conv_table[2] + block_pitch) << 2; - } else - bl_pitch_sh2 = s->block_conv_table[3] << 2; - } - } - pitch[n] = bl_pitch_sh2 >> 2; - break; - } - - case ACB_TYPE_ASYMMETRIC: { - bl_pitch_sh2 = pitch[n] << 2; - break; - } - - default: // ACB_TYPE_NONE has no pitch - bl_pitch_sh2 = 0; - break; - } - - synth_block(s, gb, n, block_nsamples, bl_pitch_sh2, - lsps, prev_lsps, &frame_descs[bd_idx], - &excitation[n * block_nsamples], - &synth[n * block_nsamples]); - } - - /* Averaging projection filter, if applicable. Else, just copy samples - * from synthesis buffer */ - if (s->do_apf) { - double i_lsps[MAX_LSPS]; - float lpcs[MAX_LSPS]; - - for (n = 0; n < s->lsps; n++) // LSF -> LSP - i_lsps[n] = cos(0.5 * (prev_lsps[n] + lsps[n])); - ff_acelp_lspd2lpc(i_lsps, lpcs, s->lsps >> 1); - postfilter(s, synth, samples, 80, lpcs, - &s->zero_exc_pf[s->history_nsamples + MAX_FRAMESIZE * frame_idx], - frame_descs[bd_idx].fcb_type, pitch[0]); - - for (n = 0; n < s->lsps; n++) // LSF -> LSP - i_lsps[n] = cos(lsps[n]); - ff_acelp_lspd2lpc(i_lsps, lpcs, s->lsps >> 1); - postfilter(s, &synth[80], &samples[80], 80, lpcs, - &s->zero_exc_pf[s->history_nsamples + MAX_FRAMESIZE * frame_idx + 80], - frame_descs[bd_idx].fcb_type, pitch[0]); - } else - memcpy(samples, synth, 160 * sizeof(synth[0])); - - /* Cache values for next frame */ - s->frame_cntr++; - if (s->frame_cntr >= 0xFFFF) s->frame_cntr -= 0xFFFF; // i.e. modulo (%) - s->last_acb_type = frame_descs[bd_idx].acb_type; - switch (frame_descs[bd_idx].acb_type) { - case ACB_TYPE_NONE: - s->last_pitch_val = 0; - break; - case ACB_TYPE_ASYMMETRIC: - s->last_pitch_val = cur_pitch_val; - break; - case ACB_TYPE_HAMMING: - s->last_pitch_val = pitch[frame_descs[bd_idx].n_blocks - 1]; - break; - } - - return 0; -} - -/** - * Ensure minimum value for first item, maximum value for last value, - * proper spacing between each value and proper ordering. - * - * @param lsps array of LSPs - * @param num size of LSP array - * - * @note basically a double version of #ff_acelp_reorder_lsf(), might be - * useful to put in a generic location later on. Parts are also - * present in #ff_set_min_dist_lsf() + #ff_sort_nearly_sorted_floats(), - * which is in float. - */ -static void stabilize_lsps(double *lsps, int num) -{ - int n, m, l; - - /* set minimum value for first, maximum value for last and minimum - * spacing between LSF values. - * Very similar to ff_set_min_dist_lsf(), but in double. */ - lsps[0] = FFMAX(lsps[0], 0.0015 * M_PI); - for (n = 1; n < num; n++) - lsps[n] = FFMAX(lsps[n], lsps[n - 1] + 0.0125 * M_PI); - lsps[num - 1] = FFMIN(lsps[num - 1], 0.9985 * M_PI); - - /* reorder (looks like one-time / non-recursed bubblesort). - * Very similar to ff_sort_nearly_sorted_floats(), but in double. */ - for (n = 1; n < num; n++) { - if (lsps[n] < lsps[n - 1]) { - for (m = 1; m < num; m++) { - double tmp = lsps[m]; - for (l = m - 1; l >= 0; l--) { - if (lsps[l] <= tmp) break; - lsps[l + 1] = lsps[l]; - } - lsps[l + 1] = tmp; - } - break; - } - } -} - -/** - * Test if there's enough bits to read 1 superframe. - * - * @param orig_gb bit I/O context used for reading. This function - * does not modify the state of the bitreader; it - * only uses it to copy the current stream position - * @param s WMA Voice decoding context private data - * @return -1 if unsupported, 1 on not enough bits or 0 if OK. - */ -static int check_bits_for_superframe(GetBitContext *orig_gb, - WMAVoiceContext *s) -{ - GetBitContext s_gb, *gb = &s_gb; - int n, need_bits, bd_idx; - const struct frame_type_desc *frame_desc; - - /* initialize a copy */ - init_get_bits(gb, orig_gb->buffer, orig_gb->size_in_bits); - skip_bits_long(gb, get_bits_count(orig_gb)); - assert(get_bits_left(gb) == get_bits_left(orig_gb)); - - /* superframe header */ - if (get_bits_left(gb) < 14) - return 1; - if (!get_bits1(gb)) - return -1; // WMAPro-in-WMAVoice superframe - if (get_bits1(gb)) skip_bits(gb, 12); // number of samples in superframe - if (s->has_residual_lsps) { // residual LSPs (for all frames) - if (get_bits_left(gb) < s->sframe_lsp_bitsize) - return 1; - skip_bits_long(gb, s->sframe_lsp_bitsize); - } - - /* frames */ - for (n = 0; n < MAX_FRAMES; n++) { - int aw_idx_is_ext = 0; - - if (!s->has_residual_lsps) { // independent LSPs (per-frame) - if (get_bits_left(gb) < s->frame_lsp_bitsize) return 1; - skip_bits_long(gb, s->frame_lsp_bitsize); - } - bd_idx = s->vbm_tree[get_vlc2(gb, frame_type_vlc.table, 6, 3)]; - if (bd_idx < 0) - return -1; // invalid frame type VLC code - frame_desc = &frame_descs[bd_idx]; - if (frame_desc->acb_type == ACB_TYPE_ASYMMETRIC) { - if (get_bits_left(gb) < s->pitch_nbits) - return 1; - skip_bits_long(gb, s->pitch_nbits); - } - if (frame_desc->fcb_type == FCB_TYPE_SILENCE) { - skip_bits(gb, 8); - } else if (frame_desc->fcb_type == FCB_TYPE_AW_PULSES) { - int tmp = get_bits(gb, 6); - if (tmp >= 0x36) { - skip_bits(gb, 2); - aw_idx_is_ext = 1; - } - } - - /* blocks */ - if (frame_desc->acb_type == ACB_TYPE_HAMMING) { - need_bits = s->block_pitch_nbits + - (frame_desc->n_blocks - 1) * s->block_delta_pitch_nbits; - } else if (frame_desc->fcb_type == FCB_TYPE_AW_PULSES) { - need_bits = 2 * !aw_idx_is_ext; - } else - need_bits = 0; - need_bits += frame_desc->frame_size; - if (get_bits_left(gb) < need_bits) - return 1; - skip_bits_long(gb, need_bits); - } - - return 0; -} - -/** - * Synthesize output samples for a single superframe. If we have any data - * cached in s->sframe_cache, that will be used instead of whatever is loaded - * in s->gb. - * - * WMA Voice superframes contain 3 frames, each containing 160 audio samples, - * to give a total of 480 samples per frame. See #synth_frame() for frame - * parsing. In addition to 3 frames, superframes can also contain the LSPs - * (if these are globally specified for all frames (residually); they can - * also be specified individually per-frame. See the s->has_residual_lsps - * option), and can specify the number of samples encoded in this superframe - * (if less than 480), usually used to prevent blanks at track boundaries. - * - * @param ctx WMA Voice decoder context - * @param samples pointer to output buffer for voice samples - * @param data_size pointer containing the size of #samples on input, and the - * amount of #samples filled on output - * @return 0 on success, <0 on error or 1 if there was not enough data to - * fully parse the superframe - */ -static int synth_superframe(AVCodecContext *ctx, - float *samples, int *data_size) -{ - WMAVoiceContext *s = ctx->priv_data; - GetBitContext *gb = &s->gb, s_gb; - int n, res, n_samples = 480; - double lsps[MAX_FRAMES][MAX_LSPS]; - const double *mean_lsf = s->lsps == 16 ? - wmavoice_mean_lsf16[s->lsp_def_mode] : wmavoice_mean_lsf10[s->lsp_def_mode]; - float excitation[MAX_SIGNAL_HISTORY + MAX_SFRAMESIZE + 12]; - float synth[MAX_LSPS + MAX_SFRAMESIZE]; - - memcpy(synth, s->synth_history, - s->lsps * sizeof(*synth)); - memcpy(excitation, s->excitation_history, - s->history_nsamples * sizeof(*excitation)); - - if (s->sframe_cache_size > 0) { - gb = &s_gb; - init_get_bits(gb, s->sframe_cache, s->sframe_cache_size); - s->sframe_cache_size = 0; - } - - if ((res = check_bits_for_superframe(gb, s)) == 1) return 1; - - /* First bit is speech/music bit, it differentiates between WMAVoice - * speech samples (the actual codec) and WMAVoice music samples, which - * are really WMAPro-in-WMAVoice-superframes. I've never seen those in - * the wild yet. */ - if (!get_bits1(gb)) { - av_log_missing_feature(ctx, "WMAPro-in-WMAVoice support", 1); - return ERROR_WMAPRO_IN_WMAVOICE; - } - - /* (optional) nr. of samples in superframe; always <= 480 and >= 0 */ - if (get_bits1(gb)) { - if ((n_samples = get_bits(gb, 12)) > 480) { - av_log(ctx, AV_LOG_ERROR, - "Superframe encodes >480 samples (%d), not allowed\n", - n_samples); - return -1; - } - } - /* Parse LSPs, if global for the superframe (can also be per-frame). */ - if (s->has_residual_lsps) { - double prev_lsps[MAX_LSPS], a1[MAX_LSPS * 2], a2[MAX_LSPS * 2]; - - for (n = 0; n < s->lsps; n++) - prev_lsps[n] = s->prev_lsps[n] - mean_lsf[n]; - - if (s->lsps == 10) { - dequant_lsp10r(gb, lsps[2], prev_lsps, a1, a2, s->lsp_q_mode); - } else /* s->lsps == 16 */ - dequant_lsp16r(gb, lsps[2], prev_lsps, a1, a2, s->lsp_q_mode); - - for (n = 0; n < s->lsps; n++) { - lsps[0][n] = mean_lsf[n] + (a1[n] - a2[n * 2]); - lsps[1][n] = mean_lsf[n] + (a1[s->lsps + n] - a2[n * 2 + 1]); - lsps[2][n] += mean_lsf[n]; - } - for (n = 0; n < 3; n++) - stabilize_lsps(lsps[n], s->lsps); - } - - /* Parse frames, optionally preceeded by per-frame (independent) LSPs. */ - for (n = 0; n < 3; n++) { - if (!s->has_residual_lsps) { - int m; - - if (s->lsps == 10) { - dequant_lsp10i(gb, lsps[n]); - } else /* s->lsps == 16 */ - dequant_lsp16i(gb, lsps[n]); - - for (m = 0; m < s->lsps; m++) - lsps[n][m] += mean_lsf[m]; - stabilize_lsps(lsps[n], s->lsps); - } - - if ((res = synth_frame(ctx, gb, n, - &samples[n * MAX_FRAMESIZE], - lsps[n], n == 0 ? s->prev_lsps : lsps[n - 1], - &excitation[s->history_nsamples + n * MAX_FRAMESIZE], - &synth[s->lsps + n * MAX_FRAMESIZE]))) - return res; - } - - /* Statistics? FIXME - we don't check for length, a slight overrun - * will be caught by internal buffer padding, and anything else - * will be skipped, not read. */ - if (get_bits1(gb)) { - res = get_bits(gb, 4); - skip_bits(gb, 10 * (res + 1)); - } - - /* Specify nr. of output samples */ - *data_size = n_samples * sizeof(float); - - /* Update history */ - memcpy(s->prev_lsps, lsps[2], - s->lsps * sizeof(*s->prev_lsps)); - memcpy(s->synth_history, &synth[MAX_SFRAMESIZE], - s->lsps * sizeof(*synth)); - memcpy(s->excitation_history, &excitation[MAX_SFRAMESIZE], - s->history_nsamples * sizeof(*excitation)); - if (s->do_apf) - memmove(s->zero_exc_pf, &s->zero_exc_pf[MAX_SFRAMESIZE], - s->history_nsamples * sizeof(*s->zero_exc_pf)); - - return 0; -} - -/** - * Parse the packet header at the start of each packet (input data to this - * decoder). - * - * @param s WMA Voice decoding context private data - * @return 1 if not enough bits were available, or 0 on success. - */ -static int parse_packet_header(WMAVoiceContext *s) -{ - GetBitContext *gb = &s->gb; - unsigned int res; - - if (get_bits_left(gb) < 11) - return 1; - skip_bits(gb, 4); // packet sequence number - s->has_residual_lsps = get_bits1(gb); - do { - res = get_bits(gb, 6); // number of superframes per packet - // (minus first one if there is spillover) - if (get_bits_left(gb) < 6 * (res == 0x3F) + s->spillover_bitsize) - return 1; - } while (res == 0x3F); - s->spillover_nbits = get_bits(gb, s->spillover_bitsize); - - return 0; -} - -/** - * Copy (unaligned) bits from gb/data/size to pb. - * - * @param pb target buffer to copy bits into - * @param data source buffer to copy bits from - * @param size size of the source data, in bytes - * @param gb bit I/O context specifying the current position in the source. - * data. This function might use this to align the bit position to - * a whole-byte boundary before calling #ff_copy_bits() on aligned - * source data - * @param nbits the amount of bits to copy from source to target - * - * @note after calling this function, the current position in the input bit - * I/O context is undefined. - */ -static void copy_bits(PutBitContext *pb, - const uint8_t *data, int size, - GetBitContext *gb, int nbits) -{ - int rmn_bytes, rmn_bits; - - rmn_bits = rmn_bytes = get_bits_left(gb); - if (rmn_bits < nbits) - return; - rmn_bits &= 7; rmn_bytes >>= 3; - if ((rmn_bits = FFMIN(rmn_bits, nbits)) > 0) - put_bits(pb, rmn_bits, get_bits(gb, rmn_bits)); - ff_copy_bits(pb, data + size - rmn_bytes, - FFMIN(nbits - rmn_bits, rmn_bytes << 3)); -} - -/** - * Packet decoding: a packet is anything that the (ASF) demuxer contains, - * and we expect that the demuxer / application provides it to us as such - * (else you'll probably get garbage as output). Every packet has a size of - * ctx->block_align bytes, starts with a packet header (see - * #parse_packet_header()), and then a series of superframes. Superframe - * boundaries may exceed packets, i.e. superframes can split data over - * multiple (two) packets. - * - * For more information about frames, see #synth_superframe(). - */ -int wmavoice_decode_packet(AVCodecContext *ctx, void *data, - int *data_size, AVPacket *avpkt) -{ - WMAVoiceContext *s = ctx->priv_data; - GetBitContext *gb = &s->gb; - int size, res, pos; - - if (*data_size < 480 * sizeof(float)) { - av_log(ctx, AV_LOG_ERROR, - "Output buffer too small (%d given - %zu needed)\n", - *data_size, 480 * sizeof(float)); - return -1; - } - *data_size = 0; - - /* Packets are sometimes a multiple of ctx->block_align, with a packet - * header at each ctx->block_align bytes. However, FFmpeg's ASF demuxer - * feeds us ASF packets, which may concatenate multiple "codec" packets - * in a single "muxer" packet, so we artificially emulate that by - * capping the packet size at ctx->block_align. */ - for (size = avpkt->size; size > ctx->block_align; size -= ctx->block_align); - if (!size) - return 0; - init_get_bits(&s->gb, avpkt->data, size << 3); - - /* size == ctx->block_align is used to indicate whether we are dealing with - * a new packet or a packet of which we already read the packet header - * previously. */ - if (size == ctx->block_align) { // new packet header - if ((res = parse_packet_header(s)) < 0) - return res; - - /* If the packet header specifies a s->spillover_nbits, then we want - * to push out all data of the previous packet (+ spillover) before - * continuing to parse new superframes in the current packet. */ - if (s->spillover_nbits > 0) { - if (s->sframe_cache_size > 0) { - int cnt = get_bits_count(gb); - copy_bits(&s->pb, avpkt->data, size, gb, s->spillover_nbits); - flush_put_bits(&s->pb); - s->sframe_cache_size += s->spillover_nbits; - if ((res = synth_superframe(ctx, data, data_size)) == 0 && - *data_size > 0) { - /* convert the float values to int32 for rockbox */ - int i; - int32_t *iptr = data; - float *fptr = data; - for(i = 0; i < *data_size/sizeof(float); i++) - { - fptr[i] *= (float)(INT32_MAX); - iptr[i] = (int32_t)fptr[i]; - } - cnt += s->spillover_nbits; - s->skip_bits_next = cnt & 7; - return cnt >> 3; - } else - skip_bits_long (gb, s->spillover_nbits - cnt + - get_bits_count(gb)); // resync - } else - skip_bits_long(gb, s->spillover_nbits); // resync - } - } else if (s->skip_bits_next) - skip_bits(gb, s->skip_bits_next); - - /* Try parsing superframes in current packet */ - s->sframe_cache_size = 0; - s->skip_bits_next = 0; - pos = get_bits_left(gb); - if ((res = synth_superframe(ctx, data, data_size)) < 0) { - return res; - } else if (*data_size > 0) { - int cnt = get_bits_count(gb); - s->skip_bits_next = cnt & 7; - /* convert the float values to int32 for rockbox */ - int i; - int32_t *iptr = data; - float *fptr = data; - for(i = 0; i < *data_size/sizeof(float); i++) - { - fptr[i] *= (float)(INT32_MAX); - iptr[i] = (int32_t)fptr[i]; - } - return cnt >> 3; - } else if ((s->sframe_cache_size = pos) > 0) { - /* rewind bit reader to start of last (incomplete) superframe... */ - init_get_bits(gb, avpkt->data, size << 3); - skip_bits_long(gb, (size << 3) - pos); - //assert(get_bits_left(gb) == pos); - - /* ...and cache it for spillover in next packet */ - init_put_bits(&s->pb, s->sframe_cache, SFRAME_CACHE_MAXSIZE); - copy_bits(&s->pb, avpkt->data, size, gb, s->sframe_cache_size); - // FIXME bad - just copy bytes as whole and add use the - // skip_bits_next field - } - - return size; -} - -static av_cold int wmavoice_decode_end(AVCodecContext *ctx) -{ - WMAVoiceContext *s = ctx->priv_data; - - if (s->do_apf) { - ff_rdft_end(&s->rdft); - ff_rdft_end(&s->irdft); - ff_dct_end(&s->dct); - ff_dct_end(&s->dst); - } - - return 0; -} - -static av_cold void wmavoice_flush(AVCodecContext *ctx) -{ - WMAVoiceContext *s = ctx->priv_data; - int n; - - s->postfilter_agc = 0; - s->sframe_cache_size = 0; - s->skip_bits_next = 0; - for (n = 0; n < s->lsps; n++) - s->prev_lsps[n] = M_PI * (n + 1.0) / (s->lsps + 1.0); - memset(s->excitation_history, 0, - sizeof(*s->excitation_history) * MAX_SIGNAL_HISTORY); - memset(s->synth_history, 0, - sizeof(*s->synth_history) * MAX_LSPS); - memset(s->gain_pred_err, 0, - sizeof(s->gain_pred_err)); - - if (s->do_apf) { - memset(&s->synth_filter_out_buf[MAX_LSPS_ALIGN16 - s->lsps], 0, - sizeof(*s->synth_filter_out_buf) * s->lsps); - memset(s->dcf_mem, 0, - sizeof(*s->dcf_mem) * 2); - memset(s->zero_exc_pf, 0, - sizeof(*s->zero_exc_pf) * s->history_nsamples); - memset(s->denoise_filter_cache, 0, sizeof(s->denoise_filter_cache)); - } -} -#if 0 -AVCodec wmavoice_decoder = { - "wmavoice", - AVMEDIA_TYPE_AUDIO, - CODEC_ID_WMAVOICE, - sizeof(WMAVoiceContext), - wmavoice_decode_init, - NULL, - wmavoice_decode_end, - wmavoice_decode_packet, - CODEC_CAP_SUBFRAMES, - .flush = wmavoice_flush, - .long_name = NULL_IF_CONFIG_SMALL("Windows Media Audio Voice"), -}; -#endif - -int main(void) -{ - return 0; -} diff --git a/apps/codecs/libwmavoice/wmavoice.h b/apps/codecs/libwmavoice/wmavoice.h deleted file mode 100644 index 33ec72b4e2..0000000000 --- a/apps/codecs/libwmavoice/wmavoice.h +++ /dev/null @@ -1,7 +0,0 @@ -#include "avcodec.h" - -#define ERROR_WMAPRO_IN_WMAVOICE -0x162 - -av_cold int wmavoice_decode_init(AVCodecContext *ctx); -int wmavoice_decode_packet(AVCodecContext *ctx, void *data, - int *data_size, AVPacket *avpkt); diff --git a/apps/codecs/libwmavoice/wmavoice_data.h b/apps/codecs/libwmavoice/wmavoice_data.h deleted file mode 100644 index cbf65b043e..0000000000 --- a/apps/codecs/libwmavoice/wmavoice_data.h +++ /dev/null @@ -1,3259 +0,0 @@ -/* - * Windows Media Voice (WMAVoice) tables. - * Copyright (c) 2009 Ronald S. Bultje - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/** - * @file - * @brief Windows Media Voice (WMAVoice) tables - * @author Ronald S. Bultje - */ - -#ifndef AVCODEC_WMAVOICE_DATA_H -#define AVCODEC_WMAVOICE_DATA_H - -#include - -static const uint8_t wmavoice_dq_lsp10i[0xf00] = { - 125, 109, 84, 55, 34, 51, 109, 112, 118, 132, - 122, 102, 78, 80, 132, 119, 132, 132, 125, 131, - 109, 91, 131, 131, 136, 136, 137, 137, 140, 145, - 140, 143, 117, 136, 122, 106, 109, 91, 115, 119, - 133, 117, 103, 80, 55, 117, 123, 102, 93, 80, - 139, 116, 70, 39, 95, 89, 103, 113, 112, 122, - 135, 244, 229, 215, 199, 181, 163, 150, 146, 144, - 143, 173, 171, 154, 155, 154, 151, 148, 145, 143, - 132, 138, 116, 85, 117, 94, 108, 117, 107, 116, - 132, 118, 123, 119, 88, 67, 49, 95, 84, 95, - 121, 103, 74, 70, 179, 164, 141, 126, 107, 112, - 119, 95, 103, 149, 139, 148, 144, 147, 148, 141, - 151, 133, 142, 129, 111, 131, 108, 128, 122, 108, - 121, 96, 115, 138, 116, 93, 105, 115, 115, 123, - 129, 106, 136, 180, 147, 130, 108, 141, 131, 118, - 136, 155, 176, 156, 135, 129, 140, 146, 142, 134, - 141, 130, 109, 80, 52, 38, 18, 47, 118, 134, - 155, 141, 100, 78, 72, 89, 79, 96, 92, 98, - 133, 111, 83, 91, 72, 58, 105, 115, 112, 120, - 145, 127, 135, 113, 113, 105, 105, 85, 69, 61, - 115, 96, 116, 145, 159, 170, 175, 175, 168, 155, - 140, 120, 84, 52, 80, 145, 125, 127, 116, 126, - 128, 108, 101, 198, 227, 200, 178, 159, 147, 148, - 121, 88, 46, 109, 124, 126, 126, 137, 147, 147, - 129, 107, 164, 148, 127, 117, 134, 120, 111, 116, - 120, 103, 98, 73, 66, 61, 70, 115, 116, 125, - 126, 100, 77, 188, 162, 140, 114, 128, 139, 123, - 145, 165, 164, 134, 109, 100, 108, 118, 127, 130, - 156, 182, 190, 173, 167, 165, 162, 157, 152, 147, - 150, 164, 179, 183, 173, 155, 140, 136, 134, 135, - 122, 92, 69, 140, 132, 118, 108, 128, 138, 132, - 123, 127, 148, 137, 150, 149, 139, 127, 124, 130, - 136, 138, 112, 70, 41, 37, 132, 140, 129, 125, - 130, 111, 78, 33, 51, 161, 141, 136, 120, 122, - 126, 110, 87, 106, 85, 68, 48, 81, 112, 113, - 135, 125, 98, 85, 102, 80, 100, 87, 86, 116, - 142, 133, 110, 66, 48, 152, 139, 135, 136, 123, - 128, 116, 89, 102, 128, 99, 83, 61, 105, 124, - 120, 94, 73, 83, 78, 100, 122, 124, 128, 132, - 144, 137, 116, 102, 75, 144, 136, 127, 140, 127, - 154, 144, 118, 99, 90, 90, 89, 75, 68, 83, - 123, 103, 89, 198, 180, 154, 138, 122, 136, 120, - 138, 118, 121, 136, 110, 105, 85, 111, 101, 104, - 121, 126, 139, 115, 99, 101, 107, 110, 123, 126, - 127, 115, 88, 109, 164, 134, 138, 138, 120, 121, - 130, 202, 195, 202, 199, 201, 181, 164, 159, 148, - 120, 116, 194, 199, 186, 171, 154, 142, 137, 133, - 137, 129, 112, 149, 134, 112, 149, 138, 120, 134, - 119, 102, 107, 83, 79, 114, 119, 127, 128, 128, - 144, 148, 165, 155, 161, 150, 135, 122, 116, 115, - 120, 99, 80, 120, 123, 124, 111, 89, 70, 108, - 118, 95, 66, 53, 105, 126, 125, 105, 83, 111, - 129, 197, 191, 197, 206, 213, 216, 208, 196, 169, - 133, 109, 127, 164, 134, 121, 99, 92, 82, 71, - 131, 121, 93, 91, 136, 105, 115, 140, 120, 110, - 150, 164, 139, 108, 87, 81, 93, 92, 104, 116, - 133, 114, 125, 126, 111, 136, 110, 156, 147, 133, - 113, 94, 118, 120, 115, 125, 124, 126, 127, 134, - 116, 131, 161, 158, 166, 157, 150, 150, 144, 141, - 125, 185, 169, 142, 140, 143, 139, 131, 134, 138, - 179, 188, 170, 150, 134, 140, 144, 133, 127, 127, - 150, 177, 204, 184, 192, 194, 190, 193, 177, 158, - 114, 113, 138, 116, 137, 135, 132, 131, 127, 134, - 120, 147, 163, 135, 133, 137, 136, 136, 133, 135, - 137, 120, 95, 73, 46, 48, 111, 97, 97, 123, - 139, 130, 109, 76, 52, 72, 61, 61, 125, 127, - 132, 119, 119, 90, 66, 41, 64, 156, 143, 129, - 131, 106, 58, 25, 99, 115, 122, 136, 129, 132, - 134, 123, 97, 53, 27, 114, 125, 114, 120, 123, - 122, 107, 93, 57, 47, 133, 128, 138, 141, 131, - 145, 132, 122, 110, 79, 57, 30, 73, 153, 144, - 150, 132, 85, 59, 133, 125, 130, 115, 100, 96, - 148, 127, 111, 86, 61, 38, 110, 121, 108, 99, - 157, 143, 105, 77, 116, 118, 115, 131, 122, 122, - 133, 119, 134, 108, 86, 61, 129, 165, 143, 127, - 125, 105, 89, 111, 97, 85, 113, 99, 98, 117, - 149, 131, 101, 106, 88, 95, 79, 119, 123, 120, - 125, 109, 81, 100, 201, 183, 156, 138, 115, 116, - 141, 119, 129, 105, 76, 60, 110, 99, 92, 82, - 150, 156, 129, 95, 69, 115, 115, 113, 134, 125, - 118, 97, 67, 96, 203, 197, 171, 151, 133, 125, - 143, 131, 120, 134, 105, 80, 51, 60, 139, 134, - 129, 160, 223, 219, 219, 212, 197, 173, 157, 146, - 132, 112, 164, 144, 119, 102, 92, 76, 73, 94, - 132, 112, 124, 114, 93, 92, 83, 73, 69, 99, - 129, 103, 188, 163, 142, 132, 127, 101, 82, 59, - 140, 141, 111, 74, 46, 105, 113, 99, 127, 122, - 125, 94, 63, 112, 116, 101, 81, 120, 136, 134, - 133, 190, 224, 193, 179, 158, 146, 143, 140, 136, - 152, 161, 132, 120, 112, 94, 114, 102, 92, 116, - 129, 194, 196, 202, 211, 212, 210, 190, 169, 152, - 166, 166, 145, 111, 91, 132, 133, 128, 136, 130, - 118, 94, 72, 74, 92, 86, 89, 92, 106, 123, - 126, 100, 86, 137, 117, 92, 76, 104, 106, 114, - 133, 109, 204, 192, 166, 148, 138, 128, 111, 81, - 118, 99, 79, 146, 169, 141, 123, 102, 131, 120, - 127, 105, 136, 204, 170, 154, 131, 145, 135, 119, - 117, 95, 64, 83, 141, 136, 118, 96, 99, 126, - 115, 93, 98, 102, 95, 105, 106, 114, 119, 128, - 131, 121, 98, 139, 149, 119, 109, 86, 105, 129, - 134, 119, 104, 169, 185, 155, 141, 122, 107, 127, - 136, 115, 85, 108, 87, 126, 102, 128, 136, 129, - 125, 99, 126, 158, 133, 139, 132, 113, 91, 107, - 141, 122, 128, 161, 130, 127, 105, 120, 118, 106, - 122, 140, 161, 168, 187, 184, 176, 158, 144, 140, - 127, 111, 89, 130, 132, 105, 134, 121, 100, 122, - 129, 110, 128, 115, 129, 116, 132, 118, 114, 119, - 138, 133, 132, 188, 183, 159, 161, 147, 134, 140, - 132, 113, 84, 167, 147, 132, 124, 109, 133, 121, - 132, 128, 116, 121, 98, 101, 145, 129, 128, 129, - 124, 112, 152, 158, 136, 161, 139, 165, 158, 142, - 139, 138, 110, 127, 148, 117, 126, 118, 101, 116, - 155, 168, 154, 128, 120, 152, 150, 141, 140, 135, - 127, 111, 109, 134, 104, 133, 110, 112, 132, 114, - 111, 87, 68, 89, 107, 121, 121, 126, 126, 129, - 120, 148, 169, 163, 173, 178, 185, 188, 178, 163, - 122, 97, 86, 117, 101, 138, 118, 142, 155, 139, - 125, 114, 131, 138, 153, 149, 163, 150, 143, 141, - 157, 161, 138, 152, 134, 121, 122, 109, 110, 124, - 151, 171, 196, 168, 145, 139, 147, 151, 146, 139, - 134, 169, 179, 170, 175, 178, 177, 173, 165, 154, - 120, 151, 118, 107, 125, 129, 133, 133, 136, 139, - 119, 141, 159, 151, 160, 165, 168, 169, 162, 152, - 115, 111, 119, 94, 117, 121, 127, 127, 132, 136, - 134, 153, 147, 142, 142, 147, 159, 159, 154, 147, - 110, 106, 139, 135, 143, 142, 147, 146, 147, 147, - 115, 133, 151, 133, 141, 142, 151, 152, 147, 144, - 115, 132, 144, 131, 125, 126, 128, 130, 131, 136, - 138, 118, 96, 71, 48, 26, 43, 130, 125, 125, - 134, 122, 98, 54, 28, 84, 77, 73, 109, 125, - 133, 112, 67, 48, 141, 129, 126, 113, 112, 118, - 143, 123, 89, 54, 71, 73, 75, 131, 123, 123, - 126, 109, 81, 31, 15, 94, 110, 109, 119, 128, - 132, 122, 97, 92, 73, 50, 27, 22, 104, 133, - 133, 119, 94, 48, 34, 168, 160, 154, 151, 130, - 147, 133, 90, 54, 71, 123, 106, 105, 93, 117, - 143, 132, 107, 69, 45, 78, 178, 169, 150, 139, - 138, 123, 116, 96, 69, 49, 32, 113, 103, 112, - 154, 151, 125, 79, 60, 152, 160, 154, 155, 137, - 142, 151, 124, 88, 66, 59, 94, 87, 95, 119, - 166, 154, 122, 92, 138, 132, 124, 114, 97, 97, - 122, 99, 98, 219, 191, 176, 165, 159, 153, 131, - 130, 119, 91, 51, 24, 41, 144, 156, 147, 139, - 139, 122, 81, 65, 124, 111, 104, 90, 94, 98, - 138, 120, 112, 91, 63, 65, 89, 75, 78, 106, - 126, 107, 91, 85, 69, 95, 90, 84, 108, 120, - 155, 139, 100, 78, 120, 110, 109, 91, 77, 73, - 144, 130, 135, 112, 88, 65, 62, 142, 129, 126, - 170, 154, 150, 131, 121, 116, 100, 92, 83, 86, - 131, 122, 98, 107, 102, 75, 54, 38, 117, 130, - 146, 139, 117, 107, 86, 66, 44, 30, 97, 128, - 129, 116, 100, 59, 108, 127, 119, 139, 129, 129, - 124, 106, 79, 49, 154, 190, 166, 152, 133, 123, - 141, 149, 123, 89, 61, 70, 143, 132, 125, 126, - 136, 113, 177, 166, 141, 123, 109, 108, 105, 93, - 137, 117, 147, 123, 99, 85, 109, 98, 91, 75, - 129, 121, 102, 78, 53, 90, 149, 136, 134, 135, - 144, 136, 126, 90, 114, 152, 137, 152, 138, 128, - 133, 115, 107, 129, 99, 78, 60, 129, 125, 118, - 147, 141, 119, 124, 110, 91, 79, 64, 106, 117, - 134, 111, 164, 143, 123, 113, 116, 95, 76, 56, - 147, 159, 140, 109, 83, 84, 140, 135, 127, 129, - 123, 104, 116, 99, 91, 87, 80, 110, 113, 121, - 124, 106, 174, 174, 152, 141, 132, 134, 126, 124, - 140, 190, 240, 215, 212, 189, 173, 158, 144, 137, - 123, 97, 79, 102, 110, 111, 90, 75, 126, 124, - 134, 121, 104, 145, 127, 100, 77, 65, 120, 118, - 123, 106, 87, 41, 68, 119, 106, 115, 109, 119, - 137, 232, 241, 225, 217, 202, 183, 169, 156, 145, - 161, 146, 127, 110, 97, 107, 88, 114, 108, 106, - 141, 244, 216, 192, 172, 163, 148, 143, 144, 144, - 128, 127, 109, 89, 77, 68, 124, 120, 121, 125, - 125, 94, 48, 71, 116, 113, 104, 120, 142, 137, - 133, 129, 115, 82, 68, 120, 99, 133, 134, 124, - 130, 106, 108, 160, 130, 111, 89, 129, 124, 119, - 134, 120, 149, 143, 116, 95, 87, 142, 132, 122, - 126, 114, 108, 107, 80, 141, 133, 123, 137, 124, - 117, 95, 69, 43, 62, 98, 114, 116, 112, 120, - 122, 99, 87, 164, 145, 123, 99, 95, 118, 105, - 126, 101, 102, 120, 113, 110, 92, 139, 134, 126, - 148, 194, 241, 219, 221, 215, 200, 193, 174, 151, - 127, 104, 122, 136, 113, 106, 110, 95, 78, 106, - 131, 163, 217, 199, 194, 175, 164, 155, 142, 138, - 139, 124, 88, 57, 161, 161, 145, 139, 124, 116, - 127, 110, 91, 98, 126, 104, 113, 98, 94, 94, - 145, 138, 114, 90, 75, 130, 117, 107, 99, 90, - 119, 98, 86, 101, 148, 133, 103, 83, 124, 131, - 143, 168, 169, 133, 110, 117, 139, 149, 147, 137, - 124, 106, 80, 138, 194, 163, 142, 119, 106, 130, - 136, 125, 105, 114, 87, 113, 101, 89, 108, 102, - 114, 90, 53, 46, 105, 116, 126, 122, 118, 122, - 124, 102, 92, 195, 167, 160, 144, 154, 154, 132, - 118, 97, 88, 72, 98, 120, 112, 98, 79, 117, - 114, 107, 185, 191, 191, 188, 175, 165, 153, 143, - 119, 97, 90, 89, 120, 151, 136, 113, 99, 112, - 141, 121, 144, 122, 125, 113, 133, 111, 92, 69, - 120, 98, 78, 109, 151, 145, 157, 157, 151, 143, - 130, 110, 120, 188, 159, 141, 119, 112, 109, 98, - 126, 112, 83, 110, 169, 139, 127, 105, 93, 123, - 141, 145, 117, 106, 91, 78, 123, 107, 101, 125, - 117, 95, 71, 147, 176, 153, 148, 133, 135, 127, - 124, 106, 79, 64, 115, 96, 108, 115, 106, 105, - 127, 115, 90, 98, 105, 81, 144, 135, 117, 125, - 126, 104, 98, 165, 138, 136, 112, 149, 148, 131, - 119, 144, 186, 185, 204, 202, 209, 200, 182, 161, - 123, 153, 190, 189, 199, 194, 191, 176, 157, 147, - 121, 103, 119, 98, 100, 120, 106, 97, 95, 126, - 137, 130, 102, 117, 117, 92, 126, 114, 101, 118, - 131, 219, 190, 167, 153, 151, 144, 140, 142, 143, - 114, 102, 151, 152, 132, 120, 112, 120, 127, 131, - 138, 122, 91, 143, 118, 120, 114, 104, 124, 117, - 148, 142, 117, 126, 97, 125, 108, 116, 142, 125, - 126, 106, 91, 169, 208, 178, 158, 138, 127, 135, - 133, 126, 101, 83, 147, 130, 125, 117, 114, 117, - 120, 103, 94, 149, 136, 129, 139, 118, 133, 133, - 147, 152, 126, 132, 119, 97, 132, 129, 114, 126, - 112, 107, 148, 125, 112, 114, 124, 125, 129, 135, - 139, 121, 157, 151, 131, 140, 118, 147, 136, 121, - 115, 105, 159, 167, 185, 191, 196, 190, 176, 160, - 124, 106, 104, 122, 130, 114, 152, 144, 134, 136, - 136, 152, 159, 153, 131, 114, 116, 126, 129, 129, - 124, 109, 87, 131, 107, 115, 130, 107, 144, 131, - 126, 162, 176, 175, 180, 176, 160, 141, 134, 134, - 136, 127, 108, 161, 162, 133, 141, 124, 112, 128, - 130, 115, 110, 140, 107, 155, 134, 131, 156, 137, - 122, 106, 116, 127, 118, 161, 150, 170, 167, 152, - 139, 177, 203, 176, 155, 139, 130, 128, 129, 132, - 137, 119, 125, 103, 110, 123, 107, 120, 108, 101, - 113, 107, 160, 154, 160, 166, 169, 176, 168, 156, - 115, 90, 65, 115, 115, 104, 120, 112, 109, 124, - 131, 123, 100, 109, 185, 158, 141, 132, 116, 119, - 139, 130, 119, 156, 124, 138, 127, 116, 141, 128, - 133, 118, 115, 180, 149, 151, 135, 130, 147, 129, - 117, 90, 80, 119, 124, 128, 132, 130, 128, 135, - 112, 97, 142, 161, 167, 165, 154, 142, 136, 135, - 118, 141, 193, 172, 157, 152, 148, 145, 146, 141, - 125, 147, 165, 166, 149, 133, 123, 122, 128, 131, - 128, 193, 177, 174, 182, 186, 197, 193, 191, 173, - 124, 144, 162, 133, 113, 113, 123, 128, 129, 130, - 117, 98, 121, 122, 137, 132, 110, 97, 111, 130, - 128, 176, 151, 125, 126, 134, 130, 121, 127, 130, - 122, 151, 142, 111, 106, 121, 126, 126, 130, 134, - 148, 167, 186, 153, 129, 122, 124, 128, 130, 128, - 148, 172, 206, 178, 171, 182, 169, 180, 172, 156, - 133, 164, 174, 160, 155, 163, 163, 172, 169, 158, - 132, 150, 147, 142, 152, 140, 140, 140, 134, 135, - 137, 158, 167, 172, 163, 153, 169, 158, 146, 147, - 150, 161, 162, 172, 153, 133, 140, 144, 136, 135, - 109, 84, 101, 120, 129, 134, 133, 136, 137, 143, - 112, 114, 157, 147, 141, 136, 135, 133, 135, 138, - 121, 154, 161, 150, 149, 154, 151, 144, 146, 144, - 111, 117, 125, 125, 130, 131, 135, 137, 143, 148, - 121, 141, 146, 131, 138, 126, 118, 111, 119, 130, - 120, 135, 145, 121, 140, 134, 138, 137, 131, 134, - 115, 137, 132, 137, 139, 138, 138, 139, 145, 149, - 131, 149, 147, 133, 132, 126, 131, 134, 130, 133, - 110, 98, 84, 141, 107, 169, 169, 123, 125, 126, - 118, 210, 98, 126, 132, 138, 128, 139, 156, 157, - 140, 142, 129, 95, 192, 178, 182, 186, 183, 159, - 135, 134, 144, 124, 100, 228, 203, 161, 122, 104, - 139, 159, 134, 161, 121, 126, 192, 152, 218, 180, - 132, 132, 119, 99, 96, 97, 80, 53, 134, 143, - 102, 114, 133, 114, 127, 83, 77, 126, 85, 107, - 110, 114, 194, 186, 139, 116, 147, 104, 129, 138, - 126, 133, 109, 144, 115, 45, 130, 97, 159, 155, - 157, 162, 189, 185, 168, 163, 151, 151, 142, 135, - 144, 147, 120, 74, 192, 186, 149, 118, 71, 84, - 143, 156, 133, 178, 168, 107, 119, 149, 105, 112, - 182, 184, 158, 118, 118, 148, 128, 177, 171, 152, - 139, 135, 126, 209, 171, 150, 123, 100, 190, 158, - 166, 97, 136, 123, 136, 139, 128, 138, 126, 121, - 132, 131, 128, 95, 60, 168, 127, 140, 208, 161, - 109, 102, 119, 162, 150, 137, 107, 200, 156, 136, - 136, 128, 103, 95, 74, 91, 220, 173, 152, 138, - 139, 129, 140, 136, 122, 82, 180, 115, 53, 90, - 121, 107, 99, 148, 116, 139, 100, 63, 191, 155, - 130, 129, 163, 155, 98, 175, 95, 151, 127, 107, - 124, 124, 116, 88, 71, 164, 148, 96, 57, 89, - 125, 117, 77, 63, 162, 144, 113, 109, 137, 134, - 134, 130, 149, 174, 158, 158, 130, 81, 28, 67, - 142, 139, 129, 100, 194, 134, 68, 175, 131, 103, - 136, 132, 122, 96, 119, 82, 115, 249, 215, 168, - 125, 139, 199, 96, 146, 123, 136, 179, 142, 137, - 181, 166, 106, 86, 122, 106, 123, 131, 106, 119, - 129, 189, 188, 147, 126, 110, 101, 114, 147, 136, - 132, 106, 72, 175, 148, 99, 130, 153, 125, 136, - 123, 119, 147, 170, 157, 126, 209, 188, 158, 152, - 101, 89, 142, 131, 161, 150, 148, 124, 89, 119, - 141, 137, 131, 103, 81, 85, 64, 175, 129, 121, - 137, 144, 142, 145, 119, 205, 148, 80, 165, 138, - 143, 137, 167, 165, 148, 149, 110, 234, 217, 170, - 167, 152, 75, 140, 155, 155, 175, 129, 136, 134, - 136, 152, 161, 131, 140, 121, 91, 79, 255, 209, - 132, 147, 120, 114, 177, 128, 110, 61, 89, 131, - 125, 127, 93, 87, 167, 115, 186, 162, 107, 106, - 134, 162, 151, 100, 79, 67, 151, 116, 130, 142, - 162, 153, 155, 143, 122, 85, 202, 187, 135, 125, - 158, 155, 103, 129, 74, 149, 130, 98, 129, 126, - 148, 152, 153, 133, 118, 94, 80, 70, 47, 90, - 124, 118, 143, 184, 158, 126, 70, 82, 111, 113, - 126, 135, 175, 141, 203, 166, 123, 123, 134, 133, - 113, 111, 128, 76, 128, 177, 151, 178, 134, 125, - 120, 120, 193, 106, 98, 134, 101, 86, 101, 114, - 136, 127, 134, 196, 86, 105, 145, 128, 119, 137, - 138, 126, 230, 161, 141, 128, 129, 136, 88, 83, - 103, 118, 178, 123, 89, 101, 161, 173, 165, 147, - 130, 123, 171, 158, 131, 81, 50, 177, 162, 136, - 125, 115, 82, 173, 195, 168, 130, 112, 112, 121, - 152, 148, 167, 87, 82, 161, 142, 147, 98, 89, - 168, 138, 97, 157, 132, 114, 74, 126, 161, 141, - 135, 123, 68, 137, 124, 118, 112, 92, 65, 96, - 191, 181, 161, 151, 141, 145, 129, 102, 97, 111, - 144, 128, 55, 128, 115, 155, 129, 184, 167, 147, - 131, 141, 125, 33, 127, 111, 127, 131, 125, 130, - 137, 130, 121, 195, 172, 177, 176, 149, 98, 97, - 126, 106, 168, 159, 144, 185, 156, 151, 182, 158, - 123, 93, 110, 116, 98, 99, 125, 136, 139, 148, - 79, 112, 149, 128, 147, 136, 118, 105, 166, 152, - 117, 115, 92, 128, 148, 132, 170, 143, 226, 190, - 122, 192, 165, 121, 143, 144, 174, 124, 113, 124, - 122, 135, 34, 93, 118, 111, 111, 136, 123, 116, - 99, 195, 139, 99, 114, 102, 96, 108, 111, 112, - 113, 129, 172, 137, 105, 139, 154, 86, 113, 108, - 132, 79, 63, 120, 93, 162, 90, 103, 94, 95, - 117, 127, 104, 100, 142, 129, 93, 27, 196, 153, - 113, 91, 101, 90, 84, 68, 138, 38, 118, 148, - 87, 103, 125, 109, 96, 152, 100, 56, 31, 62, - 176, 129, 124, 115, 103, 92, 100, 121, 130, 125, - 128, 71, 82, 71, 152, 85, 107, 116, 138, 133, - 103, 116, 139, 144, 72, 37, 118, 141, 109, 95, - 86, 92, 121, 167, 156, 104, 92, 91, 122, 114, - 89, 61, 172, 128, 95, 103, 84, 101, 88, 84, - 116, 125, 108, 62, 74, 108, 160, 143, 189, 164, - 91, 115, 144, 43, 116, 79, 106, 108, 74, 83, - 87, 90, 61, 71, 76, 76, 95, 130, 89, 94, - 114, 107, 101, 145, 161, 147, 143, 163, 147, 129, - 101, 73, 111, 108, 93, 104, 186, 141, 99, 89, - 112, 126, 111, 113, 152, 41, 159, 115, 131, 124, - 117, 101, 115, 130, 124, 87, 59, 177, 63, 85, - 109, 116, 103, 68, 145, 132, 29, 119, 96, 89, - 117, 90, 181, 103, 101, 111, 97, 96, 199, 171, - 113, 120, 93, 119, 101, 64, 56, 55, 63, 90, - 105, 101, 86, 45, 136, 179, 142, 102, 115, 114, - 113, 108, 121, 84, 23, 125, 76, 102, 119, 107, - 120, 104, 73, 177, 83, 114, 128, 85, 152, 126, - 137, 115, 149, 109, 163, 133, 110, 98, 54, 61, - 95, 111, 135, 103, 88, 164, 115, 187, 122, 98, - 129, 132, 95, 86, 71, 119, 146, 111, 38, 67, - 102, 100, 66, 148, 137, 103, 145, 95, 35, 85, - 44, 136, 102, 111, 108, 115, 136, 105, 120, 110, - 108, 147, 112, 169, 116, 146, 81, 120, 94, 84, - 93, 97, 90, 119, 102, 91, 48, 147, 204, 151, - 148, 160, 144, 131, 144, 175, 158, 133, 212, 163, - 172, 152, 151, 112, 148, 151, 145, 179, 160, 124, - 164, 164, 167, 161, 141, 120, 131, 141, 198, 177, - 169, 156, 146, 156, 124, 185, 164, 195, 181, 193, - 201, 147, 148, 168, 165, 159, 162, 148, 150, 148, - 146, 157, 158, 149, 164, 129, 160, 214, 174, 166, - 154, 176, 146, 141, 155, 140, 140, 169, 106, 155, - 166, 162, 134, 193, 157, 155, 146, 196, 171, 107, - 177, 174, 163, 155, 147, 203, 162, 146, 150, 83, - 157, 170, 180, 178, 159, 157, 151, 117, 115, 183, - 170, 180, 174, 150, 177, 173, 136, 181, 196, 184, - 164, 168, 165, 148, 175, 168, 209, 189, 159, 114, - 157, 158, 141, 168, 170, 139, 175, 128, 151, 39, - 128, 154, 159, 161, 148, 180, 131, 165, 159, 131, - 163, 150, 174, 178, 178, 198, 172, 138, 184, 191, - 143, 164, 161, 163, 210, 171, 155, 168, 150, 116, - 182, 170, 145, 152, 141, 139, 191, 149, 160, 202, - 145, 169, 145, 181, 148, 183, 197, 165, 146, 171, - 161, 153, 157, 170, 164, 149, 183, 167, 246, 235, - 162, 144, 170, 152, 173, 150, 113, 135, 156, 154, - 158, 148, 178, 159, 161, 114, 180, 156, 116, 163, - 164, 161, 122, 164, 164, 183, 135, 135, 144, 182, - 160, 147, 163, 152, 169, 185, 159, 177, 99, 211, - 168, 167, 215, 170, 150, 157, 154, 176, 154, 143, - 163, 117, 178, 160, 163, 165, 164, 166, 174, 136, - 159, 169, 152, 123, 199, 149, 169, 140, 159, 208, - 155, 161, 186, 122, 134, 167, 171, 145, 148, 176, - 148, 137, 114, 160, 166, 153, 162, 156, 164, 172, - 155, 148, 155, 182, 114, 150, 157, 154, 140, 159, - 166, 160, 169, 206, 182, 145, 157, 165, 147, 202, - 131, 154, 193, 162, 162, 149, 167, 157, 191, 188, - 149, 205, 147, 166, 150, 150, 159, 153, 171, 160 -}; - -static const uint8_t wmavoice_dq_lsp16i1[0x640] = { - 142, 121, 141, 112, 99, 119, 92, 122, 183, 155, - 122, 98, 75, 78, 85, 101, 108, 134, 128, 123, - 115, 90, 79, 58, 73, 127, 106, 60, 97, 107, - 141, 163, 130, 123, 136, 156, 201, 189, 204, 206, - 140, 116, 69, 60, 117, 123, 106, 124, 91, 63, - 150, 144, 110, 80, 63, 112, 80, 70, 76, 63, - 114, 86, 147, 165, 137, 125, 120, 140, 115, 101, - 101, 99, 166, 158, 158, 104, 126, 131, 134, 143, - 121, 102, 73, 36, 83, 132, 113, 76, 38, 20, - 132, 111, 78, 73, 51, 131, 108, 131, 105, 80, - 148, 138, 101, 65, 47, 115, 86, 50, 124, 129, - 116, 89, 85, 87, 64, 111, 74, 39, 115, 113, - 112, 83, 75, 122, 127, 114, 91, 106, 125, 130, - 131, 108, 79, 136, 112, 110, 147, 164, 144, 124, - 121, 236, 218, 190, 168, 106, 101, 160, 172, 191, - 113, 138, 102, 91, 109, 100, 71, 85, 112, 119, - 121, 96, 51, 64, 126, 135, 114, 76, 34, 104, - 145, 127, 90, 56, 131, 142, 131, 92, 123, 102, - 128, 105, 63, 24, 95, 115, 87, 49, 156, 174, - 123, 105, 88, 58, 55, 141, 119, 99, 75, 81, - 137, 117, 114, 80, 56, 119, 91, 106, 166, 135, - 114, 84, 38, 93, 116, 129, 103, 97, 87, 97, - 115, 184, 193, 173, 157, 117, 88, 114, 151, 121, - 126, 111, 75, 129, 133, 130, 107, 71, 115, 92, - 128, 108, 120, 100, 97, 111, 80, 119, 122, 91, - 114, 94, 149, 129, 136, 114, 88, 132, 110, 85, - 116, 99, 101, 71, 71, 110, 140, 142, 131, 110, - 122, 98, 83, 127, 100, 106, 130, 123, 114, 103, - 113, 87, 140, 116, 113, 140, 161, 171, 145, 129, - 115, 178, 158, 161, 160, 118, 195, 209, 221, 228, - 99, 83, 140, 134, 140, 127, 186, 168, 187, 187, - 107, 114, 100, 111, 111, 104, 130, 131, 116, 128, - 128, 104, 64, 18, 49, 126, 107, 69, 56, 153, - 154, 142, 110, 113, 89, 120, 93, 73, 190, 172, - 119, 96, 57, 21, 60, 126, 122, 81, 99, 117, - 159, 141, 108, 88, 120, 144, 125, 89, 44, 94, - 147, 131, 93, 81, 61, 133, 113, 85, 47, 62, - 123, 121, 87, 53, 90, 120, 94, 76, 70, 48, - 125, 103, 93, 64, 35, 140, 129, 88, 47, 30, - 127, 104, 58, 51, 103, 124, 100, 102, 76, 47, - 115, 87, 54, 46, 77, 182, 218, 174, 163, 145, - 140, 126, 89, 105, 82, 125, 119, 101, 69, 58, - 125, 107, 172, 145, 128, 138, 113, 109, 92, 90, - 117, 93, 83, 93, 132, 125, 102, 67, 148, 161, - 131, 110, 96, 99, 74, 119, 92, 54, 84, 81, - 110, 152, 120, 106, 131, 108, 74, 68, 99, 107, - 121, 97, 120, 101, 78, 132, 110, 127, 164, 134, - 111, 159, 204, 189, 178, 158, 183, 146, 144, 137, - 123, 106, 136, 108, 135, 117, 91, 163, 135, 113, - 119, 177, 134, 122, 121, 132, 109, 157, 131, 113, - 115, 87, 87, 100, 92, 120, 95, 59, 146, 139, - 129, 101, 135, 122, 101, 119, 100, 112, 88, 99, - 118, 90, 123, 125, 107, 121, 98, 73, 104, 80, - 112, 79, 86, 122, 96, 104, 81, 107, 90, 93, - 112, 150, 140, 109, 115, 113, 86, 73, 76, 112, - 130, 111, 101, 112, 84, 123, 97, 63, 134, 115, - 109, 77, 128, 141, 119, 125, 101, 108, 147, 119, - 134, 149, 150, 127, 115, 136, 244, 220, 210, 189, - 105, 138, 171, 156, 174, 117, 162, 133, 146, 141, - 115, 93, 119, 98, 122, 114, 106, 154, 145, 162, - 107, 131, 189, 165, 152, 101, 107, 129, 114, 139, - 116, 186, 186, 161, 180, 100, 89, 137, 116, 116, - 106, 130, 194, 196, 207, 110, 156, 157, 138, 149, - 102, 93, 159, 138, 120, 109, 132, 105, 122, 135, - 148, 128, 85, 76, 102, 168, 154, 141, 117, 100, - 125, 106, 62, 101, 146, 124, 102, 65, 25, 15, - 120, 94, 46, 21, 94, 149, 128, 115, 85, 92, - 119, 93, 70, 52, 30, 162, 151, 123, 91, 80, - 126, 112, 84, 47, 33, 138, 114, 73, 60, 87, - 126, 211, 174, 158, 143, 129, 106, 65, 31, 133, - 119, 95, 52, 99, 173, 123, 96, 119, 206, 178, - 127, 104, 60, 61, 67, 152, 136, 104, 63, 83, - 133, 130, 92, 64, 45, 120, 96, 53, 30, 130, - 128, 103, 74, 59, 35, 135, 114, 77, 30, 57, - 108, 130, 123, 90, 87, 143, 125, 93, 54, 60, - 133, 118, 79, 87, 95, 115, 89, 111, 88, 65, - 124, 102, 70, 40, 47, 148, 131, 123, 130, 104, - 127, 109, 87, 56, 121, 147, 123, 121, 107, 85, - 178, 237, 200, 193, 170, 139, 118, 100, 75, 110, - 133, 121, 81, 73, 68, 120, 195, 157, 141, 131, - 127, 102, 107, 88, 60, 136, 113, 100, 69, 45, - 128, 105, 93, 77, 67, 131, 116, 149, 184, 156, - 115, 85, 35, 45, 112, 128, 108, 68, 73, 111, - 118, 93, 187, 162, 139, 136, 115, 84, 57, 37, - 131, 133, 125, 98, 85, 138, 115, 92, 86, 61, - 116, 96, 70, 52, 110, 115, 109, 135, 104, 88, - 136, 159, 122, 109, 115, 122, 110, 98, 70, 95, - 112, 81, 68, 85, 90, 124, 101, 87, 56, 89, - 109, 82, 98, 100, 115, 124, 102, 76, 88, 63, - 111, 78, 42, 78, 102, 110, 71, 64, 131, 111, - 125, 104, 107, 87, 123, 129, 131, 99, 85, 68, - 147, 137, 102, 99, 75, 120, 155, 142, 109, 91, - 132, 109, 131, 141, 113, 136, 119, 94, 152, 128, - 127, 102, 79, 159, 134, 111, 78, 98, 109, 80, - 115, 86, 51, 63, 103, 116, 86, 170, 149, 123, - 135, 178, 159, 125, 114, 113, 189, 226, 203, 202, - 140, 117, 116, 94, 70, 128, 103, 94, 174, 149, - 118, 98, 83, 84, 106, 115, 157, 120, 94, 95, - 131, 112, 75, 96, 74, 121, 97, 144, 117, 95, - 120, 90, 140, 138, 110, 119, 93, 55, 92, 114, - 114, 87, 151, 125, 100, 111, 82, 83, 160, 139, - 114, 86, 56, 90, 138, 104, 109, 101, 77, 118, - 140, 142, 143, 148, 126, 121, 102, 129, 107, 111, - 113, 79, 58, 111, 91, 120, 94, 63, 115, 98, - 121, 94, 99, 97, 78, 120, 92, 68, 173, 148, - 122, 114, 109, 87, 82, 132, 229, 192, 176, 155, - 137, 116, 123, 97, 115, 132, 115, 86, 120, 95, - 135, 116, 101, 136, 108, 109, 74, 100, 125, 115, - 112, 158, 144, 124, 134, 114, 83, 73, 147, 120, - 120, 104, 150, 122, 116, 110, 104, 192, 183, 174, - 134, 112, 116, 120, 93, 121, 101, 93, 110, 90, - 121, 93, 147, 152, 122, 115, 153, 171, 161, 142, - 123, 95, 116, 114, 93, 113, 89, 96, 77, 93, - 113, 174, 180, 143, 138, 116, 86, 100, 135, 106, - 103, 121, 149, 115, 103, 121, 95, 82, 149, 121, - 117, 92, 93, 111, 114, 123, 209, 196, 193, 183, - 125, 102, 107, 130, 104, 115, 91, 113, 103, 99, - 114, 86, 68, 108, 110, 111, 159, 162, 125, 113, - 125, 235, 234, 225, 214, 99, 74, 118, 121, 127, - 104, 123, 158, 128, 127, 113, 96, 116, 136, 158, - 100, 80, 138, 155, 166, 118, 143, 115, 125, 114, - 119, 137, 133, 136, 139, 151, 188, 172, 174, 173, - 138, 161, 158, 158, 155, 121, 198, 194, 211, 202, - 100, 90, 112, 110, 122, 100, 91, 122, 128, 135, - 101, 109, 127, 101, 114, 105, 126, 160, 147, 143, - 109, 138, 142, 158, 163, 113, 174, 185, 188, 206, - 112, 154, 166, 176, 183, 101, 108, 140, 140, 143, - 106, 135, 130, 137, 126, 103, 114, 115, 128, 126, - 107, 86, 21, 115, 75, 117, 139, 97, 65, 105, - 64, 191, 101, 106, 139, 107, 98, 218, 132, 104, - 73, 136, 165, 84, 118, 150, 111, 58, 130, 107, - 99, 136, 132, 56, 52, 102, 136, 69, 78, 163, - 85, 173, 148, 138, 85, 69, 106, 128, 133, 155, - 104, 91, 149, 56, 104, 103, 101, 172, 96, 57, - 104, 97, 125, 197, 166, 107, 169, 47, 120, 103, - 150, 89, 99, 139, 162, 101, 69, 137, 158, 126, - 191, 173, 127, 79, 155, 51, 131, 112, 86, 74, - 135, 61, 114, 81, 125, 117, 112, 72, 175, 72, - 127, 123, 142, 132, 78, 116, 158, 111, 121, 143, - 108, 102, 89, 20, 194, 81, 99, 107, 65, 150, - 103, 78, 91, 69, 96, 104, 116, 116, 103, 105, - 107, 117, 110, 130, 28, 88, 103, 62, 72, 85, - 125, 126, 141, 126, 178, 121, 102, 57, 46, 124, - 97, 91, 89, 138, 95, 98, 143, 99, 169, 123, - 140, 119, 113, 82, 140, 118, 112, 91, 92, 241, - 134, 89, 95, 112, 78, 167, 140, 145, 121, 100, - 109, 205, 144, 91, 100, 113, 103, 142, 175, 95, - 117, 121, 35, 121, 127, 159, 129, 85, 64, 75, - 116, 98, 103, 127, 129, 66, 68, 110, 96, 86, - 79, 100, 156, 133, 92, 135, 96, 164, 132, 121, - 93, 163, 134, 91, 208, 104, 77, 126, 116, 58, - 136, 118, 132, 81, 61, 73, 115, 66, 129, 123, - 111, 85, 42, 178, 134, 108, 132, 159, 45, 157, - 105, 164, 100, 94, 60, 96, 57, 154, 105, 102, - 103, 114, 96, 12, 91, 119, 115, 67, 92, 64, - 94, 61, 106, 106, 165, 105, 94, 98, 68, 30, - 146, 130, 107, 173, 140, 102, 90, 163, 106, 184, - 100, 53, 68, 131, 92, 105, 111, 68, 153, 186, - 101, 82, 48, 99, 147, 122, 136, 176, 96, 96, - 104, 132, 167, 149, 136, 138, 144, 97, 120, 92 -}; - -static const uint8_t wmavoice_dq_lsp16i2[0x3c0] = { - 23, 12, 107, 119, 110, 205, 214, 212, 208, 201, - 102, 95, 69, 117, 107, 118, 123, 118, 123, 121, - 82, 58, 83, 95, 84, 139, 145, 153, 161, 169, - 102, 100, 138, 121, 101, 129, 130, 138, 150, 139, - 76, 104, 86, 112, 133, 113, 91, 63, 73, 129, - 199, 193, 182, 181, 172, 119, 101, 83, 94, 76, - 161, 157, 152, 157, 158, 110, 90, 121, 96, 79, - 124, 107, 114, 88, 73, 152, 137, 121, 107, 99, - 57, 50, 100, 81, 74, 115, 96, 72, 49, 69, - 83, 68, 40, 53, 103, 36, 131, 107, 84, 64, - 236, 245, 242, 231, 213, 95, 109, 88, 69, 110, - 228, 221, 204, 182, 170, 129, 110, 97, 118, 104, - 98, 76, 98, 75, 61, 93, 77, 113, 91, 72, - 116, 94, 106, 134, 118, 177, 188, 169, 162, 153, - 163, 149, 131, 131, 132, 177, 163, 173, 168, 158, - 113, 131, 107, 113, 100, 132, 143, 131, 134, 142, - 45, 36, 121, 113, 102, 43, 95, 84, 67, 56, - 76, 82, 68, 48, 33, 55, 58, 59, 43, 65, - 66, 85, 66, 81, 94, 102, 82, 54, 33, 94, - 113, 111, 89, 60, 34, 138, 120, 101, 101, 86, - 88, 73, 55, 114, 115, 92, 74, 93, 77, 123, - 90, 117, 99, 79, 59, 97, 75, 97, 122, 104, - 233, 237, 227, 208, 190, 209, 230, 233, 240, 241, - 195, 197, 188, 167, 147, 204, 185, 168, 162, 157, - 142, 124, 119, 123, 106, 117, 110, 81, 121, 123, - 74, 116, 124, 119, 120, 178, 168, 146, 132, 125, - 102, 104, 105, 110, 114, 104, 82, 78, 100, 86, - 120, 102, 105, 93, 143, 127, 108, 128, 106, 88, - 177, 189, 203, 207, 215, 101, 131, 119, 95, 73, - 149, 139, 135, 147, 153, 160, 167, 165, 174, 177, - 120, 109, 134, 140, 145, 131, 130, 142, 139, 161, - 143, 158, 148, 145, 145, 123, 142, 132, 116, 102, - 40, 23, 79, 82, 84, 26, 83, 141, 130, 122, - 65, 46, 43, 89, 86, 28, 75, 80, 79, 98, - 84, 65, 47, 26, 44, 49, 112, 101, 100, 94, - 88, 76, 75, 48, 82, 104, 100, 75, 45, 15, - 99, 83, 63, 34, 30, 66, 55, 94, 118, 113, - 122, 106, 91, 68, 60, 135, 122, 104, 77, 59, - 82, 102, 84, 62, 46, 92, 74, 55, 82, 71, - 145, 134, 118, 93, 75, 79, 62, 83, 65, 55, - 91, 94, 64, 70, 98, 89, 117, 110, 87, 97, - 210, 223, 225, 223, 213, 83, 103, 86, 101, 85, - 126, 106, 81, 79, 105, 216, 219, 217, 199, 179, - 86, 78, 115, 138, 135, 102, 84, 87, 59, 46, - 219, 206, 184, 167, 158, 201, 188, 165, 145, 135, - 87, 113, 142, 152, 155, 190, 170, 153, 149, 146, - 205, 208, 201, 185, 167, 84, 73, 124, 104, 96, - 76, 88, 99, 74, 80, 110, 125, 122, 99, 112, - 108, 84, 70, 130, 137, 161, 152, 136, 119, 105, - 110, 91, 101, 74, 96, 111, 101, 93, 153, 149, - 133, 124, 102, 97, 120, 101, 93, 75, 81, 64, - 111, 94, 107, 79, 58, 188, 206, 215, 221, 232, - 163, 175, 165, 150, 136, 103, 106, 123, 133, 132, - 168, 184, 191, 183, 170, 110, 117, 90, 98, 93, - 104, 87, 122, 98, 127, 129, 110, 127, 113, 125, - 134, 118, 102, 140, 132, 186, 199, 202, 198, 188, - 149, 147, 175, 185, 186, 117, 93, 99, 112, 93, - 107, 138, 138, 129, 128, 96, 129, 104, 118, 134, - 145, 136, 115, 121, 129, 138, 155, 148, 134, 120, - 170, 151, 150, 145, 138, 168, 173, 185, 194, 200, - 144, 159, 172, 168, 156, 121, 121, 138, 173, 168, - 126, 111, 140, 139, 117, 149, 133, 142, 137, 130, - 143, 139, 158, 158, 146, 119, 128, 121, 132, 145, - 122, 136, 159, 153, 141, 133, 133, 130, 129, 126, - 120, 76, 50, 149, 109, 92, 155, 118, 90, 66, - 132, 117, 87, 156, 117, 119, 102, 44, 83, 91, - 109, 73, 106, 84, 29, 55, 130, 112, 81, 241, - 75, 40, 91, 89, 67, 112, 90, 149, 81, 72, - 128, 90, 71, 28, 160, 73, 157, 123, 143, 108, - 63, 88, 70, 81, 97, 75, 111, 149, 113, 96, - 78, 104, 83, 179, 95, 105, 106, 65, 130, 66, - 51, 118, 92, 53, 68, 105, 75, 176, 151, 115, - 94, 75, 68, 95, 220, 103, 125, 105, 43, 95, - 39, 114, 65, 145, 135, 33, 142, 138, 103, 52, - 82, 85, 117, 110, 67, 102, 74, 42, 62, 118, - 144, 121, 82, 57, 102, 67, 75, 44, 129, 96, - 75, 63, 88, 48, 116, 135, 94, 85, 102, 66, - 122, 77, 105, 122, 152, 120, 56, 90, 83, 100, - 90, 128, 63, 80, 103, 126, 117, 103, 80, 193, - 42, 73, 117, 93, 91, 95, 128, 100, 128, 162, - 70, 120, 126, 73, 123, 99, 99, 91, 75, 135, - 81, 125, 111, 77, 13, 94, 78, 85, 187, 157, - 11, 143, 109, 99, 119, 53, 141, 82, 122, 68, - 132, 89, 136, 119, 88, 75, 49, 174, 119, 70, - 138, 121, 108, 78, 52, 104, 90, 96, 93, 93, - 114, 90, 78, 46, 58, 62, 114, 69, 44, 162, - 103, 58, 98, 141, 83, 137, 95, 119, 73, 111, - 81, 46, 126, 111, 123, 107, 117, 122, 121, 54, - 106, 104, 59, 110, 148, 97, 155, 97, 83, 133, - 97, 71, 57, 91, 58, 52, 79, 127, 152, 109, - 96, 92, 145, 107, 149, 102, 61, 125, 61, 170, - 56, 89, 77, 106, 38, 147, 96, 77, 105, 123, - 85, 83, 117, 63, 69, 126, 133, 93, 107, 92, - 77, 115, 95, 111, 103, 61, 87, 103, 98, 155, - 94, 111, 80, 78, 54, 117, 128, 130, 99, 109, - 106, 99, 113, 133, 115, 89, 65, 74, 112, 127 -}; - -static const uint8_t wmavoice_dq_lsp16i3[0x300] = { - 70, 100, 121, 129, 132, 132, 201, 188, 165, 145, 144, 136, - 112, 127, 116, 125, 130, 129, 124, 135, 135, 146, 129, 128, - 162, 158, 144, 151, 135, 129, 103, 86, 111, 113, 112, 122, - 90, 139, 129, 117, 126, 129, 142, 145, 167, 147, 124, 124, - 230, 209, 189, 175, 156, 141, 64, 80, 86, 108, 121, 129, - 44, 79, 115, 113, 115, 128, 133, 106, 79, 109, 125, 127, - 171, 156, 132, 109, 103, 115, 106, 70, 93, 145, 141, 128, - 148, 125, 122, 107, 110, 117, 146, 145, 128, 110, 98, 111, - 237, 212, 185, 156, 139, 133, 84, 55, 26, 77, 114, 127, - 172, 170, 171, 168, 162, 143, 82, 82, 76, 70, 104, 126, - 17, 95, 109, 111, 120, 132, 81, 74, 57, 126, 141, 131, - 110, 127, 162, 148, 129, 123, 177, 172, 155, 151, 145, 134, - 144, 123, 90, 66, 109, 130, 82, 127, 103, 123, 132, 131, - 127, 97, 97, 142, 140, 128, 159, 134, 136, 123, 113, 117, - 131, 140, 154, 169, 158, 134, 96, 109, 150, 122, 105, 120, - 120, 150, 152, 122, 119, 125, 123, 126, 124, 107, 100, 113, - 248, 233, 216, 189, 160, 142, 58, 24, 13, 77, 111, 127, - 183, 189, 182, 157, 140, 131, 96, 83, 59, 43, 73, 119, - 222, 196, 171, 146, 129, 128, 32, 13, 53, 101, 114, 127, - 119, 101, 70, 70, 110, 127, 77, 86, 161, 148, 130, 118, - 199, 183, 170, 167, 156, 141, 30, 115, 142, 133, 131, 130, - 101, 103, 181, 176, 152, 126, 66, 44, 73, 94, 111, 128, - 150, 122, 100, 101, 104, 118, 61, 110, 87, 76, 93, 125, - 190, 170, 150, 134, 135, 129, 112, 89, 63, 123, 141, 132, - 175, 154, 136, 142, 140, 132, 117, 143, 129, 128, 136, 132, - 168, 142, 112, 113, 128, 128, 155, 169, 159, 144, 139, 131, - 61, 136, 144, 124, 112, 123, 86, 81, 104, 121, 129, 130, - 160, 127, 118, 150, 151, 134, 126, 115, 121, 132, 134, 131, - 137, 148, 144, 139, 140, 134, 106, 102, 105, 90, 87, 113, - 134, 129, 128, 121, 121, 123, 153, 151, 129, 139, 142, 134, - 150, 142, 141, 148, 149, 141, 100, 121, 133, 147, 150, 134, - 163, 158, 147, 132, 141, 132, 142, 127, 141, 136, 136, 132, - 232, 218, 205, 189, 169, 146, 243, 224, 201, 171, 147, 138, - 224, 196, 169, 162, 154, 140, 51, 20, 59, 111, 121, 128, - 203, 197, 193, 177, 162, 145, 75, 40, 47, 122, 130, 129, - 102, 77, 47, 83, 121, 129, 111, 108, 84, 56, 63, 114, - 211, 181, 154, 137, 126, 125, 213, 198, 186, 162, 144, 138, - 41, 45, 90, 110, 118, 130, 83, 63, 130, 164, 153, 128, - 195, 167, 142, 123, 113, 119, 19, 42, 105, 113, 120, 132, - 50, 63, 49, 64, 112, 128, 114, 90, 132, 171, 162, 134, - 129, 128, 107, 83, 74, 110, 50, 116, 109, 120, 128, 132, - 94, 59, 73, 111, 117, 126, 197, 170, 166, 153, 138, 132, - 65, 48, 109, 133, 131, 128, 170, 163, 172, 158, 138, 130, - 66, 126, 147, 160, 151, 132, 42, 129, 117, 95, 91, 120, - 97, 165, 164, 142, 133, 125, 163, 142, 114, 88, 97, 122, - 104, 77, 142, 143, 128, 120, 136, 160, 188, 169, 149, 130, - 113, 83, 85, 102, 114, 125, 164, 169, 142, 120, 122, 124, - 98, 152, 132, 105, 92, 117, 42, 71, 125, 155, 151, 137, - 94, 105, 81, 107, 118, 126, 84, 56, 123, 117, 108, 122, - 174, 179, 166, 137, 118, 121, 130, 103, 147, 152, 134, 124, - 148, 127, 94, 117, 144, 134, 129, 106, 102, 95, 106, 118, - 147, 157, 153, 125, 103, 117, 155, 128, 113, 132, 120, 122, - 181, 151, 136, 126, 122, 122, 110, 111, 109, 108, 120, 124, - 97, 130, 103, 89, 107, 124, 179, 158, 158, 142, 131, 128, - 142, 111, 115, 122, 126, 125, 145, 145, 134, 115, 129, 128, - 130, 139, 112, 99, 121, 125, 79, 104, 119, 102, 105, 123, - 116, 121, 136, 125, 126, 127, 124, 100, 122, 119, 111, 119, - 159, 140, 139, 128, 138, 131, 105, 100, 116, 128, 135, 132, - 159, 142, 156, 147, 140, 134, 130, 150, 129, 126, 114, 120, - 138, 124, 146, 131, 109, 119, 93, 115, 125, 131, 125, 129, - 125, 121, 101, 119, 114, 120, 163, 154, 151, 153, 153, 139, - 166, 153, 150, 133, 119, 121, 159, 151, 128, 130, 122, 123, - 147, 154, 144, 133, 128, 127, 129, 131, 134, 140, 148, 138, - 138, 136, 120, 131, 135, 131, 150, 140, 137, 144, 129, 129 -}; - -static const uint8_t wmavoice_dq_lsp10r[0x1400] = { - 128, 128, 129, 129, 130, 130, 131, 130, 129, 129, - 134, 133, 127, 125, 136, 135, 135, 134, 173, 172, - 133, 139, 136, 165, 133, 176, 137, 159, 135, 152, - 147, 161, 147, 152, 149, 156, 146, 146, 140, 136, - 134, 135, 136, 140, 139, 155, 123, 133, 132, 142, - 132, 148, 143, 177, 124, 143, 123, 136, 126, 134, - 126, 125, 125, 124, 129, 128, 123, 123, 133, 133, - 116, 116, 121, 121, 121, 120, 129, 128, 131, 131, - 132, 133, 132, 129, 138, 124, 138, 124, 132, 100, - 135, 94, 149, 111, 152, 115, 150, 128, 141, 133, - 129, 129, 130, 129, 147, 145, 136, 137, 120, 122, - 120, 122, 127, 129, 104, 108, 113, 115, 124, 124, - 140, 139, 147, 145, 132, 130, 184, 177, 201, 196, - 170, 171, 160, 161, 145, 147, 137, 145, 131, 131, - 130, 130, 130, 130, 130, 130, 132, 134, 131, 132, - 131, 133, 141, 144, 142, 149, 84, 93, 103, 104, - 139, 139, 142, 140, 147, 147, 172, 165, 122, 121, - 98, 100, 101, 106, 112, 117, 122, 124, 124, 124, - 134, 133, 133, 133, 146, 142, 147, 145, 156, 156, - 143, 146, 119, 124, 129, 132, 151, 149, 136, 135, - 147, 148, 181, 180, 199, 188, 190, 173, 166, 161, - 147, 142, 153, 149, 154, 146, 150, 146, 138, 134, - 131, 135, 96, 136, 48, 138, 56, 131, 63, 124, - 85, 128, 103, 132, 117, 134, 120, 132, 125, 129, - 131, 130, 129, 128, 129, 128, 163, 168, 117, 120, - 121, 121, 136, 138, 131, 132, 135, 136, 131, 133, - 133, 133, 133, 134, 117, 118, 105, 109, 142, 151, - 144, 159, 131, 138, 121, 126, 123, 123, 121, 124, - 131, 131, 129, 129, 141, 140, 142, 134, 87, 90, - 109, 109, 130, 127, 139, 143, 133, 131, 127, 126, - 134, 135, 134, 136, 97, 98, 130, 132, 134, 137, - 115, 119, 125, 130, 107, 109, 119, 118, 126, 127, - 134, 135, 127, 132, 172, 203, 160, 196, 152, 179, - 152, 172, 148, 168, 153, 172, 145, 156, 137, 140, - 102, 116, 42, 56, 74, 61, 82, 70, 86, 78, - 101, 97, 104, 100, 115, 108, 116, 108, 123, 118, - 149, 143, 166, 129, 168, 96, 142, 95, 135, 98, - 117, 86, 116, 93, 121, 108, 119, 107, 121, 117, - 135, 135, 127, 138, 72, 132, 99, 136, 112, 147, - 120, 152, 136, 155, 138, 146, 140, 142, 134, 139, - 163, 145, 192, 130, 147, 124, 147, 125, 133, 125, - 127, 124, 128, 123, 129, 122, 130, 122, 130, 125, - 130, 137, 135, 180, 124, 133, 130, 129, 132, 133, - 124, 124, 131, 130, 132, 136, 126, 124, 127, 125, - 132, 132, 133, 133, 144, 140, 143, 142, 137, 135, - 143, 138, 152, 149, 221, 219, 158, 161, 143, 141, - 130, 129, 140, 135, 170, 145, 193, 156, 186, 152, - 167, 139, 151, 131, 142, 127, 134, 120, 131, 125, - 135, 133, 141, 125, 199, 109, 137, 126, 134, 123, - 130, 129, 132, 123, 128, 125, 122, 126, 125, 125, - 130, 128, 91, 89, 138, 135, 139, 134, 133, 129, - 132, 130, 125, 128, 136, 135, 129, 127, 126, 126, - 132, 131, 133, 131, 128, 120, 132, 126, 126, 119, - 134, 130, 131, 123, 104, 95, 140, 141, 136, 137, - 133, 133, 133, 134, 117, 98, 74, 49, 112, 111, - 123, 122, 126, 127, 131, 131, 127, 126, 128, 129, - 130, 131, 124, 127, 101, 107, 108, 109, 115, 115, - 100, 99, 130, 128, 134, 136, 125, 127, 128, 130, - 136, 137, 145, 150, 149, 164, 136, 151, 114, 111, - 124, 125, 143, 150, 162, 174, 158, 169, 136, 137, - 131, 131, 131, 131, 132, 133, 111, 110, 122, 121, - 136, 136, 134, 133, 131, 132, 127, 127, 125, 125, - 128, 129, 129, 130, 125, 127, 140, 140, 148, 149, - 133, 136, 146, 153, 110, 118, 127, 129, 128, 129, - 131, 133, 127, 131, 140, 161, 167, 224, 131, 139, - 136, 143, 135, 139, 138, 143, 149, 155, 141, 143, - 134, 132, 120, 111, 83, 83, 121, 126, 102, 107, - 112, 115, 97, 104, 120, 115, 129, 123, 122, 122, - 134, 135, 122, 131, 102, 124, 114, 119, 93, 103, - 78, 79, 67, 72, 66, 73, 78, 82, 103, 102, - 144, 135, 165, 139, 165, 129, 160, 126, 153, 127, - 161, 134, 160, 142, 160, 143, 148, 140, 138, 135, - 138, 95, 147, 54, 143, 78, 140, 112, 142, 113, - 140, 121, 135, 117, 135, 122, 136, 131, 131, 132, - 147, 159, 140, 156, 127, 81, 142, 128, 146, 127, - 144, 125, 146, 128, 149, 130, 144, 135, 133, 128, - 130, 131, 131, 131, 134, 139, 126, 134, 141, 154, - 168, 205, 153, 176, 148, 163, 147, 158, 141, 143, - 131, 135, 126, 146, 108, 157, 107, 156, 119, 146, - 100, 138, 104, 125, 119, 134, 101, 122, 113, 122, - 95, 133, 52, 140, 83, 136, 110, 133, 114, 131, - 123, 131, 133, 131, 138, 135, 132, 132, 127, 127, - 129, 128, 124, 122, 128, 126, 145, 170, 143, 172, - 141, 163, 143, 176, 138, 164, 139, 155, 135, 145, - 135, 136, 136, 127, 132, 76, 128, 76, 127, 63, - 125, 66, 123, 67, 120, 71, 124, 92, 122, 111, - 133, 133, 135, 136, 139, 140, 147, 147, 150, 144, - 156, 147, 150, 145, 154, 146, 120, 123, 123, 124, - 137, 133, 170, 141, 124, 124, 135, 134, 134, 135, - 132, 132, 129, 129, 130, 130, 136, 136, 130, 132, - 147, 159, 135, 158, 115, 146, 120, 148, 117, 136, - 115, 137, 113, 132, 133, 142, 140, 144, 132, 134, - 134, 135, 134, 137, 137, 147, 162, 178, 136, 147, - 134, 144, 123, 132, 111, 113, 113, 113, 124, 124, - 132, 131, 126, 126, 117, 114, 100, 95, 130, 125, - 157, 145, 164, 156, 163, 158, 145, 145, 133, 134, - 134, 134, 127, 126, 113, 102, 136, 130, 124, 122, - 143, 145, 127, 131, 135, 143, 133, 137, 132, 132, - 92, 94, 122, 125, 128, 129, 131, 130, 134, 135, - 132, 128, 129, 127, 132, 132, 131, 129, 127, 127, - 129, 129, 132, 131, 139, 131, 137, 132, 216, 178, - 146, 134, 147, 137, 151, 142, 148, 139, 144, 138, - 128, 127, 129, 129, 123, 131, 71, 91, 126, 128, - 130, 134, 117, 123, 125, 125, 135, 140, 129, 132, - 132, 132, 133, 134, 124, 130, 127, 133, 133, 138, - 142, 149, 135, 141, 145, 149, 154, 164, 135, 138, - 135, 135, 141, 142, 138, 137, 116, 96, 105, 86, - 127, 118, 128, 120, 124, 117, 125, 117, 125, 121, - 131, 131, 132, 134, 144, 145, 112, 112, 121, 123, - 113, 116, 121, 123, 139, 138, 128, 128, 131, 131, - 134, 132, 132, 132, 125, 128, 127, 130, 125, 131, - 120, 128, 90, 119, 68, 98, 99, 112, 115, 124, - 135, 135, 134, 134, 128, 129, 137, 137, 137, 138, - 110, 114, 129, 130, 144, 145, 123, 125, 129, 129, - 132, 133, 129, 130, 168, 187, 140, 149, 137, 144, - 129, 130, 129, 134, 133, 138, 118, 118, 122, 120, - 131, 130, 129, 128, 133, 133, 125, 125, 124, 123, - 181, 179, 129, 129, 131, 127, 139, 136, 130, 128, - 133, 133, 132, 132, 121, 120, 122, 119, 132, 129, - 129, 125, 107, 96, 136, 137, 150, 146, 135, 134, - 131, 131, 130, 130, 126, 123, 126, 123, 128, 125, - 130, 123, 134, 127, 183, 159, 143, 135, 137, 134, - 129, 129, 128, 128, 134, 133, 139, 138, 133, 132, - 129, 127, 154, 151, 150, 144, 146, 146, 141, 142, - 132, 132, 131, 131, 130, 130, 132, 133, 114, 115, - 132, 132, 122, 122, 132, 131, 115, 117, 120, 120, - 129, 129, 130, 130, 130, 129, 130, 131, 129, 131, - 130, 130, 129, 129, 133, 132, 143, 144, 91, 91, - 137, 136, 118, 107, 60, 45, 56, 49, 57, 52, - 60, 56, 71, 75, 77, 80, 92, 97, 106, 106, - 112, 131, 58, 121, 19, 65, 84, 101, 108, 122, - 121, 127, 112, 117, 106, 112, 117, 124, 126, 127, - 130, 129, 138, 133, 166, 155, 192, 179, 192, 177, - 208, 191, 204, 192, 186, 179, 163, 163, 138, 142, - 134, 134, 144, 142, 243, 236, 148, 146, 141, 137, - 145, 141, 151, 144, 147, 143, 135, 139, 134, 133, - 134, 128, 138, 88, 142, 10, 127, 76, 130, 96, - 129, 102, 128, 108, 123, 111, 127, 119, 127, 124, - 136, 136, 139, 139, 142, 140, 246, 241, 158, 167, - 143, 145, 146, 149, 143, 145, 148, 152, 133, 134, - 139, 135, 135, 136, 99, 137, 95, 133, 75, 138, - 67, 135, 73, 128, 83, 132, 96, 126, 115, 127, - 130, 132, 137, 136, 140, 135, 134, 130, 137, 131, - 159, 151, 215, 197, 181, 170, 160, 149, 150, 143, - 145, 148, 186, 207, 141, 147, 135, 137, 122, 122, - 126, 125, 128, 126, 127, 127, 134, 126, 131, 123, - 133, 133, 126, 122, 128, 122, 99, 93, 59, 60, - 82, 82, 106, 107, 119, 123, 124, 128, 128, 129, - 134, 137, 133, 139, 133, 136, 141, 132, 139, 122, - 142, 97, 130, 81, 128, 89, 129, 101, 125, 112, - 137, 140, 129, 148, 101, 159, 118, 180, 122, 178, - 120, 178, 116, 168, 118, 153, 127, 151, 126, 136, - 132, 134, 125, 126, 118, 105, 156, 124, 180, 132, - 163, 124, 148, 121, 131, 112, 127, 115, 125, 122, - 129, 131, 128, 129, 136, 134, 142, 141, 165, 158, - 203, 182, 141, 136, 132, 130, 135, 135, 130, 130, - 133, 133, 132, 132, 127, 126, 106, 105, 112, 110, - 106, 105, 80, 84, 100, 101, 122, 125, 126, 128, - 101, 109, 46, 59, 114, 112, 119, 119, 126, 121, - 129, 124, 128, 125, 125, 122, 123, 120, 125, 122, - 135, 134, 121, 134, 56, 139, 131, 145, 135, 138, - 136, 139, 126, 130, 122, 132, 126, 129, 124, 129, - 153, 169, 146, 179, 138, 139, 151, 143, 148, 138, - 153, 137, 142, 129, 144, 126, 140, 128, 133, 126, - 136, 134, 154, 149, 173, 157, 152, 144, 149, 141, - 137, 136, 127, 121, 123, 121, 121, 126, 120, 123, - 157, 143, 166, 135, 120, 122, 112, 118, 102, 118, - 111, 124, 134, 131, 141, 138, 135, 134, 126, 129, - 140, 123, 152, 76, 131, 116, 138, 136, 126, 134, - 130, 142, 126, 136, 120, 132, 126, 128, 124, 127, - 131, 138, 80, 147, 126, 138, 130, 140, 129, 134, - 133, 135, 131, 132, 126, 127, 127, 125, 125, 123, - 132, 132, 130, 132, 123, 130, 102, 102, 107, 110, - 116, 127, 132, 152, 142, 160, 143, 151, 142, 146, - 132, 132, 132, 132, 125, 126, 132, 140, 158, 199, - 135, 149, 134, 140, 135, 131, 129, 120, 127, 121, - 129, 130, 122, 123, 125, 124, 138, 138, 138, 135, - 140, 141, 101, 94, 105, 98, 121, 122, 127, 128, - 126, 127, 119, 121, 133, 156, 132, 159, 130, 148, - 137, 164, 127, 138, 130, 137, 135, 140, 126, 126, - 128, 129, 129, 129, 126, 124, 130, 128, 143, 138, - 149, 143, 185, 170, 129, 127, 138, 133, 138, 135, - 132, 134, 137, 144, 139, 183, 131, 145, 127, 128, - 128, 127, 128, 122, 129, 125, 145, 139, 135, 131, - 132, 133, 132, 130, 152, 96, 159, 85, 150, 105, - 154, 115, 143, 120, 138, 126, 134, 124, 130, 126, - 128, 127, 121, 123, 122, 123, 116, 125, 84, 87, - 133, 135, 129, 131, 123, 126, 133, 135, 131, 130, - 136, 134, 129, 119, 79, 63, 116, 116, 136, 133, - 133, 130, 140, 143, 127, 127, 124, 125, 127, 128, - 128, 126, 124, 120, 139, 128, 153, 134, 151, 134, - 174, 145, 159, 136, 165, 144, 171, 149, 143, 135, - 134, 134, 133, 133, 121, 119, 177, 162, 166, 154, - 127, 130, 132, 132, 136, 137, 142, 143, 138, 137, - 167, 151, 162, 142, 128, 136, 142, 148, 128, 143, - 145, 153, 140, 149, 132, 141, 128, 139, 127, 133, - 156, 169, 131, 129, 126, 120, 127, 125, 129, 120, - 131, 126, 126, 123, 124, 121, 122, 121, 123, 123, - 138, 140, 149, 156, 145, 152, 105, 102, 131, 126, - 151, 146, 147, 139, 144, 137, 143, 133, 135, 130, - 132, 130, 131, 129, 126, 130, 126, 129, 110, 135, - 115, 139, 108, 146, 105, 147, 121, 134, 124, 133, - 137, 137, 135, 134, 143, 142, 146, 146, 120, 121, - 139, 137, 133, 129, 149, 145, 139, 133, 130, 127, - 134, 134, 134, 134, 125, 124, 117, 119, 120, 113, - 84, 80, 122, 125, 108, 112, 97, 102, 118, 120, - 124, 123, 115, 116, 110, 111, 98, 97, 127, 124, - 129, 127, 120, 117, 114, 109, 106, 104, 116, 116, - 138, 138, 139, 141, 142, 146, 127, 125, 133, 130, - 134, 128, 134, 127, 116, 91, 105, 84, 114, 106, - 128, 128, 126, 126, 131, 137, 126, 129, 133, 139, - 134, 145, 132, 143, 150, 192, 131, 142, 138, 141, - 132, 130, 132, 130, 149, 138, 196, 152, 137, 125, - 134, 125, 139, 128, 133, 125, 141, 134, 134, 135, - 134, 135, 134, 135, 131, 130, 136, 133, 110, 106, - 142, 144, 153, 162, 131, 129, 134, 132, 131, 130, - 126, 125, 132, 130, 168, 153, 126, 124, 130, 126, - 140, 135, 140, 134, 138, 133, 145, 137, 135, 134, - 130, 130, 132, 131, 133, 132, 129, 129, 125, 128, - 128, 130, 133, 139, 143, 152, 193, 215, 152, 160, - 130, 131, 129, 131, 130, 131, 135, 136, 136, 141, - 83, 81, 121, 120, 136, 130, 150, 145, 147, 145, - 134, 133, 135, 133, 146, 142, 135, 131, 127, 128, - 134, 135, 93, 102, 126, 132, 131, 133, 127, 129, - 124, 125, 120, 122, 103, 106, 128, 129, 139, 138, - 127, 128, 134, 134, 143, 138, 139, 134, 135, 133, - 131, 130, 133, 131, 139, 134, 138, 136, 166, 156, - 119, 116, 121, 122, 126, 124, 116, 117, 123, 124, - 131, 131, 129, 129, 130, 128, 141, 138, 135, 132, - 154, 145, 137, 129, 131, 125, 146, 137, 138, 135, - 131, 131, 131, 132, 129, 130, 134, 138, 111, 116, - 113, 118, 123, 125, 122, 124, 143, 147, 138, 140, - 116, 113, 114, 112, 130, 126, 117, 115, 127, 126, - 139, 137, 141, 139, 131, 132, 143, 144, 139, 140, - 130, 130, 129, 128, 136, 134, 119, 117, 152, 143, - 155, 143, 120, 119, 142, 139, 124, 130, 126, 128, - 112, 110, 112, 109, 136, 132, 125, 118, 121, 115, - 103, 101, 109, 100, 125, 120, 121, 117, 122, 121, - 128, 128, 127, 127, 124, 124, 128, 127, 131, 129, - 142, 138, 147, 141, 115, 108, 113, 109, 122, 119, - 136, 133, 150, 139, 142, 131, 119, 111, 151, 137, - 121, 116, 146, 134, 137, 129, 121, 123, 127, 129, - 130, 130, 130, 130, 136, 137, 126, 126, 136, 136, - 133, 133, 139, 139, 142, 143, 119, 120, 134, 134, - 132, 132, 133, 133, 135, 138, 129, 131, 133, 134, - 135, 138, 126, 130, 117, 118, 131, 132, 135, 135, - 129, 129, 128, 128, 126, 129, 127, 129, 123, 125, - 115, 117, 156, 157, 127, 131, 129, 129, 128, 129, - 129, 130, 131, 131, 126, 127, 135, 134, 136, 135, - 140, 136, 117, 113, 132, 128, 104, 97, 109, 106, - 131, 131, 131, 131, 121, 123, 124, 125, 126, 127, - 127, 127, 135, 135, 128, 128, 130, 130, 141, 140, - 129, 129, 129, 129, 129, 127, 127, 125, 149, 146, - 125, 123, 134, 133, 134, 132, 152, 150, 138, 138, - 128, 128, 126, 125, 132, 133, 141, 143, 136, 136, - 126, 127, 126, 127, 129, 131, 128, 129, 135, 134, - 176, 139, 192, 135, 145, 122, 149, 117, 155, 134, - 169, 133, 157, 139, 142, 136, 151, 152, 142, 147, - 166, 174, 103, 107, 141, 134, 140, 136, 144, 135, - 147, 135, 156, 131, 153, 127, 133, 126, 130, 124, - 127, 130, 123, 124, 114, 105, 195, 193, 156, 157, - 165, 158, 126, 122, 149, 141, 174, 173, 152, 147, - 136, 139, 131, 138, 163, 169, 103, 124, 80, 102, - 153, 186, 121, 151, 134, 161, 156, 190, 141, 151, - 121, 123, 124, 127, 119, 127, 133, 134, 157, 156, - 81, 69, 136, 134, 160, 169, 118, 114, 135, 128, - 114, 116, 97, 97, 117, 122, 152, 161, 115, 121, - 106, 122, 135, 137, 111, 113, 125, 135, 141, 145, - 143, 146, 143, 150, 132, 136, 142, 150, 151, 167, - 101, 107, 155, 173, 112, 124, 105, 100, 128, 126, - 127, 130, 133, 134, 142, 121, 131, 116, 176, 145, - 161, 120, 209, 150, 196, 133, 147, 115, 149, 130, - 144, 145, 144, 145, 120, 119, 163, 160, 117, 118, - 123, 117, 154, 119, 193, 98, 149, 101, 137, 116, - 133, 135, 140, 143, 144, 156, 131, 146, 186, 201, - 140, 139, 123, 125, 158, 169, 157, 166, 142, 143, - 130, 131, 132, 132, 128, 128, 141, 142, 147, 149, - 145, 148, 137, 139, 129, 129, 107, 108, 157, 157, - 120, 121, 119, 119, 140, 132, 137, 131, 118, 113, - 143, 136, 134, 135, 164, 158, 133, 125, 127, 124, - 148, 122, 197, 130, 173, 145, 110, 139, 123, 165, - 83, 158, 90, 167, 93, 142, 136, 169, 134, 152, - 130, 126, 154, 138, 227, 150, 156, 114, 147, 114, - 142, 109, 135, 110, 166, 135, 176, 150, 152, 142, - 132, 132, 136, 136, 130, 135, 143, 152, 136, 144, - 152, 160, 177, 185, 112, 112, 165, 166, 160, 161, - 145, 145, 138, 139, 116, 118, 127, 131, 66, 80, - 132, 142, 119, 127, 101, 108, 120, 130, 126, 130, - 135, 135, 142, 139, 153, 137, 55, 30, 142, 139, - 139, 143, 135, 133, 129, 133, 109, 108, 129, 129, - 136, 135, 134, 131, 129, 132, 132, 134, 135, 149, - 79, 206, 123, 137, 135, 143, 130, 140, 131, 134, - 100, 99, 165, 164, 142, 123, 148, 133, 133, 122, - 142, 133, 138, 125, 119, 111, 129, 123, 137, 130, - 131, 132, 123, 129, 174, 185, 196, 181, 127, 111, - 156, 141, 132, 114, 129, 106, 132, 107, 126, 117, - 134, 140, 131, 136, 119, 146, 92, 246, 128, 132, - 125, 129, 132, 140, 128, 141, 126, 145, 137, 142, - 130, 130, 110, 115, 124, 139, 127, 151, 118, 152, - 98, 146, 36, 108, 126, 158, 112, 146, 112, 130, - 138, 136, 145, 138, 153, 145, 116, 125, 90, 103, - 137, 138, 189, 185, 141, 151, 86, 93, 111, 111, - 133, 171, 125, 209, 140, 132, 130, 134, 129, 101, - 142, 120, 142, 132, 135, 126, 141, 140, 140, 134, - 128, 123, 131, 123, 138, 118, 163, 133, 240, 197, - 176, 151, 126, 123, 81, 94, 109, 118, 124, 133, - 135, 133, 137, 134, 154, 135, 140, 155, 69, 190, - 119, 149, 141, 151, 142, 123, 135, 125, 129, 130, - 127, 125, 132, 127, 107, 80, 123, 103, 145, 131, - 133, 107, 140, 103, 135, 106, 170, 145, 159, 143, - 136, 137, 127, 130, 105, 119, 129, 134, 141, 151, - 116, 127, 119, 140, 75, 119, 152, 162, 149, 152, - 72, 138, 9, 143, 118, 160, 126, 134, 141, 147, - 135, 131, 129, 129, 135, 129, 136, 126, 133, 125, - 137, 135, 146, 141, 145, 139, 141, 140, 133, 130, - 213, 208, 139, 130, 139, 136, 117, 117, 126, 125, - 133, 130, 138, 131, 141, 100, 145, 93, 159, 121, - 144, 132, 117, 160, 102, 187, 99, 162, 117, 144, - 132, 132, 134, 134, 140, 141, 127, 126, 128, 131, - 116, 116, 121, 127, 119, 126, 114, 114, 99, 100, - 141, 144, 148, 159, 179, 224, 95, 131, 100, 125, - 87, 110, 112, 132, 134, 147, 111, 125, 122, 122, - 137, 140, 141, 129, 169, 12, 144, 132, 133, 144, - 141, 146, 137, 147, 136, 122, 133, 130, 131, 128, - 141, 142, 128, 139, 15, 69, 160, 159, 142, 130, - 137, 126, 159, 141, 145, 143, 128, 125, 134, 128, - 131, 130, 127, 127, 114, 104, 119, 98, 83, 68, - 139, 120, 173, 142, 199, 154, 191, 153, 158, 145, - 128, 130, 127, 127, 148, 150, 110, 99, 119, 109, - 120, 113, 163, 154, 110, 90, 138, 129, 149, 144, - 131, 134, 124, 142, 76, 217, 130, 129, 140, 138, - 133, 135, 145, 150, 136, 138, 127, 130, 130, 134, - 144, 119, 178, 70, 143, 130, 115, 136, 139, 138, - 129, 109, 136, 116, 147, 122, 126, 112, 126, 123, - 132, 139, 128, 144, 107, 156, 75, 163, 120, 164, - 151, 136, 151, 99, 160, 112, 159, 126, 143, 126, - 140, 138, 137, 135, 152, 108, 251, 85, 138, 116, - 137, 118, 141, 119, 136, 121, 150, 134, 138, 131, - 137, 137, 143, 144, 150, 153, 148, 154, 152, 151, - 117, 104, 124, 96, 93, 67, 146, 138, 149, 148, - 149, 153, 172, 193, 108, 114, 125, 128, 145, 165, - 149, 160, 121, 130, 115, 120, 110, 112, 121, 118, - 145, 146, 141, 142, 127, 127, 103, 95, 138, 143, - 114, 126, 109, 115, 143, 136, 153, 149, 144, 142, - 140, 138, 150, 144, 128, 116, 142, 136, 135, 122, - 93, 88, 164, 163, 141, 142, 171, 182, 154, 160, - 124, 125, 122, 123, 158, 155, 111, 97, 138, 130, - 157, 134, 101, 65, 129, 118, 121, 114, 124, 119, - 131, 133, 125, 129, 136, 147, 135, 152, 131, 133, - 110, 115, 118, 114, 161, 159, 233, 218, 172, 166, - 140, 107, 125, 0, 140, 103, 140, 115, 125, 113, - 132, 135, 128, 133, 138, 146, 131, 145, 127, 133, - 131, 131, 122, 122, 135, 132, 126, 124, 132, 133, - 164, 167, 121, 127, 117, 120, 167, 162, 145, 143, - 135, 134, 136, 134, 156, 146, 195, 177, 127, 139, - 108, 140, 141, 173, 141, 178, 131, 155, 129, 141, - 134, 134, 119, 114, 184, 184, 127, 126, 147, 151, - 130, 140, 146, 159, 134, 145, 131, 136, 137, 142, - 135, 137, 128, 136, 83, 108, 97, 98, 152, 119, - 207, 144, 142, 121, 144, 129, 131, 127, 130, 132, - 124, 125, 108, 107, 94, 116, 81, 114, 139, 173, - 131, 158, 145, 177, 141, 163, 136, 140, 143, 144, - 135, 141, 132, 136, 134, 142, 142, 136, 173, 50, - 143, 106, 142, 127, 134, 139, 127, 133, 125, 125, - 129, 130, 131, 133, 132, 148, 110, 138, 113, 135, - 138, 175, 108, 151, 55, 119, 51, 100, 93, 116, - 121, 121, 146, 151, 99, 120, 127, 137, 107, 122, - 125, 139, 110, 132, 135, 156, 141, 156, 148, 157, - 137, 137, 141, 140, 139, 137, 130, 128, 138, 136, - 132, 134, 115, 110, 177, 179, 81, 86, 100, 98, - 84, 83, 121, 121, 148, 157, 127, 133, 146, 156, - 127, 136, 143, 151, 135, 139, 138, 142, 136, 136, - 201, 164, 151, 129, 123, 136, 147, 148, 127, 142, - 128, 143, 101, 126, 119, 133, 114, 131, 116, 126, - 132, 133, 140, 140, 126, 125, 156, 153, 142, 129, - 140, 130, 77, 69, 134, 132, 146, 148, 135, 136, - 133, 132, 123, 116, 116, 103, 150, 135, 144, 127, - 130, 117, 136, 122, 122, 106, 48, 38, 81, 78, - 145, 146, 135, 136, 123, 122, 126, 133, 133, 138, - 145, 145, 144, 150, 160, 181, 142, 139, 150, 150, - 136, 136, 139, 139, 133, 133, 139, 135, 134, 129, - 140, 137, 153, 145, 132, 131, 151, 144, 68, 66, - 137, 137, 139, 139, 146, 146, 142, 139, 129, 128, - 131, 129, 133, 132, 135, 134, 135, 134, 201, 200, - 137, 136, 146, 143, 155, 153, 157, 158, 131, 138, - 140, 139, 143, 144, 128, 123, 216, 192, 159, 150, - 137, 138, 136, 142, 145, 148, 126, 162, 140, 170, - 186, 95, 131, 140, 143, 148, 133, 128, 130, 133, - 141, 139, 153, 150, 122, 122, 134, 144, 124, 130, - 159, 166, 133, 139, 151, 150, 138, 139, 131, 134, - 121, 121, 131, 129, 148, 180, 121, 135, 118, 131, - 124, 148, 119, 119, 129, 126, 150, 156, 155, 160, - 40, 154, 115, 157, 133, 129, 140, 133, 143, 133, - 143, 132, 144, 130, 141, 131, 134, 130, 137, 133, - 134, 136, 141, 140, 145, 137, 152, 124, 183, 91, - 118, 154, 123, 158, 136, 134, 140, 142, 138, 142, - 138, 135, 131, 131, 138, 129, 121, 128, 146, 219, - 124, 123, 125, 135, 120, 126, 127, 141, 133, 136, - 127, 124, 120, 107, 152, 125, 149, 108, 158, 144, - 196, 185, 174, 164, 151, 149, 138, 131, 140, 137, - 149, 148, 144, 145, 143, 145, 140, 143, 141, 147, - 112, 125, 113, 113, 149, 155, 143, 149, 146, 151, - 138, 138, 141, 138, 144, 129, 134, 125, 143, 140, - 153, 154, 142, 123, 162, 42, 154, 106, 153, 130, - 153, 153, 137, 137, 144, 144, 142, 140, 165, 151, - 161, 140, 144, 134, 156, 124, 167, 143, 166, 155, - 132, 132, 137, 138, 137, 132, 124, 127, 140, 144, - 134, 140, 162, 180, 127, 131, 152, 169, 145, 156, - 133, 134, 131, 133, 130, 132, 147, 149, 125, 117, - 127, 118, 159, 155, 147, 142, 122, 117, 145, 144, - 138, 137, 130, 133, 113, 149, 168, 224, 166, 201, - 129, 151, 147, 154, 136, 135, 140, 136, 152, 141, - 120, 112, 140, 127, 161, 100, 132, 115, 118, 125, - 115, 133, 115, 157, 144, 146, 114, 135, 127, 139, - 138, 141, 135, 135, 137, 136, 147, 142, 143, 144, - 139, 152, 142, 136, 147, 143, 177, 39, 125, 71, - 147, 143, 66, 88, 132, 158, 123, 126, 116, 135, - 119, 124, 128, 135, 133, 140, 137, 126, 137, 130, - 155, 38, 149, 103, 130, 135, 139, 143, 127, 137, - 135, 141, 138, 148, 131, 148, 136, 147, 132, 139, - 136, 140, 115, 129, 115, 151, 136, 160, 87, 131, - 157, 176, 150, 164, 140, 141, 135, 119, 137, 133, - 141, 140, 140, 139, 134, 134, 142, 144, 131, 132, - 131, 134, 131, 132, 116, 114, 129, 133, 205, 207, - 130, 133, 160, 170, 137, 127, 124, 112, 158, 146, - 155, 137, 134, 136, 137, 142, 177, 184, 149, 152, - 135, 134, 133, 132, 135, 129, 144, 136, 139, 134, - 161, 155, 126, 109, 215, 186, 177, 153, 160, 149, - 139, 139, 136, 140, 140, 142, 186, 71, 129, 144, - 131, 165, 142, 152, 140, 151, 141, 143, 137, 139, - 144, 138, 150, 135, 133, 126, 136, 143, 99, 152, - 139, 131, 190, 118, 122, 147, 134, 155, 136, 143, - 138, 135, 137, 132, 147, 144, 150, 144, 138, 134, - 129, 133, 130, 138, 56, 175, 129, 166, 147, 165, - 140, 138, 144, 137, 141, 133, 150, 139, 129, 135, - 40, 83, 126, 130, 110, 120, 100, 110, 126, 128, - 141, 142, 217, 175, 172, 151, 146, 153, 125, 132, - 128, 137, 141, 141, 145, 145, 140, 133, 132, 131, - 129, 144, 128, 177, 133, 195, 147, 120, 138, 131, - 161, 114, 166, 134, 162, 118, 161, 115, 155, 129, - 137, 136, 141, 129, 141, 132, 55, 168, 121, 126, - 136, 139, 120, 133, 149, 147, 132, 141, 131, 136, - 147, 150, 151, 132, 101, 31, 117, 101, 129, 132, - 122, 138, 128, 137, 140, 170, 131, 143, 131, 134, - 149, 192, 122, 158, 136, 146, 133, 166, 143, 141, - 141, 136, 141, 129, 125, 155, 140, 138, 137, 131, - 111, 112, 131, 132, 120, 127, 149, 148, 151, 141, - 156, 148, 133, 129, 127, 124, 144, 137, 142, 139, - 134, 133, 141, 138, 133, 135, 124, 96, 226, 152, - 116, 108, 128, 105, 155, 130, 153, 138, 144, 139, - 142, 141, 137, 135, 142, 143, 156, 162, 136, 89, - 188, 145, 181, 152, 138, 146, 146, 154, 145, 149, - 152, 133, 158, 133, 42, 153, 117, 144, 149, 139, - 125, 139, 134, 128, 150, 128, 143, 125, 135, 132, - 143, 141, 143, 141, 164, 173, 141, 142, 156, 155, - 154, 154, 169, 170, 77, 80, 112, 105, 135, 134, - 126, 143, 120, 172, 111, 144, 120, 154, 107, 153, - 95, 134, 104, 134, 128, 116, 163, 131, 151, 136, - 135, 133, 142, 143, 152, 204, 149, 112, 156, 128, - 150, 126, 127, 129, 139, 175, 143, 141, 138, 135, - 168, 148, 152, 105, 164, 121, 134, 122, 119, 109, - 122, 148, 136, 143, 153, 132, 158, 148, 149, 150, - 133, 131, 142, 141, 150, 149, 156, 173, 138, 155, - 129, 144, 111, 107, 130, 129, 96, 89, 106, 104, - 135, 135, 144, 146, 131, 153, 134, 154, 146, 166, - 117, 138, 163, 187, 190, 216, 149, 156, 149, 152, - 142, 142, 153, 154, 109, 145, 40, 102, 116, 126, - 137, 139, 149, 157, 108, 124, 139, 146, 142, 147, - 130, 126, 120, 111, 172, 146, 169, 136, 150, 135, - 126, 96, 159, 143, 150, 122, 162, 129, 156, 142, - 135, 142, 144, 138, 222, 109, 137, 145, 144, 142, - 141, 143, 138, 136, 124, 150, 133, 144, 137, 145, - 141, 144, 139, 144, 134, 154, 114, 136, 145, 173, - 151, 215, 110, 115, 127, 134, 145, 150, 145, 144, - 144, 142, 139, 131, 147, 132, 141, 119, 143, 106, - 165, 41, 147, 129, 129, 144, 138, 135, 138, 140, - 128, 150, 89, 163, 154, 115, 141, 127, 132, 145, - 135, 157, 143, 145, 140, 141, 127, 135, 127, 129, - 142, 147, 116, 147, 104, 162, 153, 143, 146, 130, - 144, 110, 133, 123, 130, 137, 118, 198, 126, 152, - 154, 146, 139, 127, 147, 112, 207, 151, 156, 136, - 162, 137, 108, 121, 130, 135, 125, 131, 131, 134, - 134, 134, 141, 144, 107, 143, 137, 144, 124, 136, - 115, 147, 130, 157, 119, 167, 71, 144, 97, 128, - 134, 138, 132, 133, 138, 138, 146, 146, 147, 131, - 141, 138, 185, 65, 145, 123, 139, 130, 142, 128, - 139, 136, 157, 147, 124, 119, 164, 148, 170, 154, - 133, 130, 157, 148, 140, 141, 130, 135, 134, 137, - 136, 137, 143, 144, 144, 144, 178, 186, 71, 73, - 120, 118, 127, 124, 152, 151, 155, 146, 141, 138, - 142, 143, 139, 143, 133, 134, 139, 140, 138, 135, - 146, 141, 78, 198, 129, 139, 141, 141, 134, 141, - 137, 136, 120, 120, 124, 118, 143, 148, 148, 152, - 131, 143, 129, 137, 152, 158, 157, 160, 175, 178, - 137, 139, 131, 133, 146, 152, 121, 147, 142, 143, - 129, 136, 149, 145, 197, 114, 103, 141, 124, 140, - 141, 140, 129, 129, 127, 130, 131, 124, 123, 117, - 150, 139, 120, 109, 119, 120, 163, 163, 117, 121, - 139, 139, 136, 136, 94, 74, 150, 145, 126, 127, - 147, 150, 158, 162, 84, 74, 136, 129, 140, 132, - 136, 135, 146, 145, 124, 116, 129, 120, 130, 129, - 130, 109, 122, 111, 160, 141, 135, 113, 131, 121, - 136, 135, 135, 135, 147, 147, 140, 140, 144, 145, - 139, 142, 131, 137, 145, 145, 143, 153, 48, 49, - 145, 143, 151, 147, 158, 146, 135, 124, 124, 116, - 159, 140, 131, 126, 123, 120, 103, 117, 113, 119, - 148, 146, 128, 124, 123, 126, 123, 120, 158, 141, - 148, 137, 146, 143, 125, 143, 89, 107, 116, 123, - 149, 147, 141, 139, 149, 153, 118, 121, 139, 138, - 105, 119, 168, 147, 139, 141, 143, 138, 133, 130, - 126, 126, 143, 142, 146, 144, 124, 123, 143, 145, - 149, 148, 147, 141, 151, 143, 118, 113, 175, 171 -}; - -static const uint8_t wmavoice_dq_lsp16r1[0x500] = { - 147, 145, 193, 168, 188, 156, 141, 145, 141, 139, - 148, 149, 148, 149, 153, 157, 144, 144, 152, 152, - 141, 145, 153, 143, 243, 134, 151, 133, 166, 135, - 150, 149, 135, 132, 32, 39, 110, 111, 109, 114, - 126, 127, 147, 146, 177, 169, 162, 156, 210, 187, - 141, 147, 95, 150, 127, 155, 108, 133, 139, 148, - 138, 138, 140, 140, 147, 146, 134, 130, 136, 134, - 147, 146, 142, 150, 62, 174, 126, 151, 122, 156, - 154, 156, 179, 184, 115, 107, 105, 99, 127, 124, - 146, 131, 140, 44, 132, 125, 156, 146, 153, 153, - 136, 137, 145, 144, 141, 139, 158, 152, 138, 132, - 145, 145, 147, 145, 146, 141, 144, 140, 110, 97, - 140, 141, 143, 142, 130, 123, 127, 117, 126, 120, - 147, 146, 161, 155, 169, 135, 122, 117, 166, 155, - 144, 144, 142, 142, 125, 122, 137, 128, 194, 172, - 127, 85, 148, 143, 153, 141, 147, 147, 140, 143, - 118, 140, 0, 69, 51, 60, 111, 123, 137, 135, - 146, 146, 164, 165, 207, 214, 145, 143, 149, 147, - 178, 168, 197, 170, 134, 154, 148, 159, 115, 140, - 103, 118, 13, 38, 139, 138, 135, 138, 140, 141, - 144, 144, 140, 140, 150, 150, 156, 157, 164, 171, - 143, 143, 140, 142, 118, 120, 172, 172, 160, 163, - 146, 147, 150, 151, 176, 176, 230, 237, 153, 153, - 168, 156, 173, 149, 164, 148, 162, 146, 178, 158, - 147, 145, 143, 145, 111, 126, 111, 130, 89, 118, - 153, 158, 122, 120, 142, 125, 124, 105, 148, 138, - 145, 144, 156, 151, 193, 154, 146, 147, 119, 135, - 142, 141, 145, 145, 152, 147, 142, 141, 146, 146, - 139, 138, 154, 154, 148, 150, 147, 149, 144, 145, - 134, 134, 141, 140, 135, 134, 145, 147, 160, 163, - 144, 145, 149, 146, 115, 67, 127, 119, 141, 135, - 145, 141, 130, 124, 143, 144, 151, 165, 141, 144, - 154, 152, 160, 136, 115, 82, 64, 71, 64, 65, - 143, 143, 151, 149, 240, 251, 165, 173, 173, 179, - 148, 134, 156, 55, 160, 105, 133, 91, 129, 96, - 149, 149, 145, 144, 160, 154, 171, 159, 140, 142, - 154, 163, 178, 244, 147, 140, 153, 150, 137, 121, - 145, 144, 145, 146, 138, 139, 149, 152, 189, 198, - 148, 148, 156, 158, 168, 182, 165, 182, 172, 201, - 143, 142, 99, 92, 152, 152, 143, 143, 127, 127, - 165, 148, 173, 124, 113, 122, 134, 142, 127, 142, - 124, 126, 137, 137, 131, 132, 144, 142, 141, 138, - 172, 176, 138, 111, 152, 136, 167, 154, 156, 137, - 140, 150, 78, 145, 158, 157, 161, 154, 155, 147, - 153, 164, 156, 191, 129, 109, 153, 146, 153, 141, - 138, 137, 141, 138, 115, 94, 144, 141, 155, 147, - 144, 142, 144, 137, 168, 113, 141, 134, 145, 137, - 146, 144, 150, 148, 140, 155, 103, 178, 137, 149, - 145, 147, 148, 153, 175, 201, 138, 146, 110, 108, - 143, 146, 124, 134, 124, 127, 164, 158, 127, 135, - 145, 146, 150, 150, 145, 147, 95, 80, 150, 151, - 149, 149, 162, 162, 144, 152, 170, 169, 145, 154, - 145, 149, 143, 146, 142, 145, 152, 146, 160, 98, - 141, 141, 153, 153, 140, 137, 131, 131, 145, 146, - 133, 132, 127, 124, 158, 150, 173, 164, 178, 167, - 146, 146, 154, 155, 117, 127, 143, 147, 147, 156, - 142, 143, 144, 145, 146, 152, 170, 199, 151, 165, - 146, 147, 139, 140, 147, 149, 132, 134, 147, 149, - 138, 139, 142, 143, 162, 188, 145, 149, 160, 164, - 150, 150, 139, 139, 143, 142, 146, 146, 137, 138, - 142, 142, 141, 140, 152, 153, 164, 171, 110, 112, - 139, 139, 143, 143, 138, 138, 142, 142, 143, 143, - 137, 140, 142, 142, 145, 141, 149, 141, 182, 135, - 146, 146, 150, 150, 144, 145, 150, 151, 135, 137, - 137, 145, 51, 62, 68, 54, 69, 57, 62, 41, - 137, 139, 139, 144, 135, 150, 225, 232, 208, 197, - 136, 135, 141, 143, 145, 150, 160, 169, 213, 247, - 142, 137, 72, 54, 110, 107, 105, 107, 127, 130, - 145, 143, 169, 155, 219, 174, 195, 164, 183, 157, - 155, 157, 239, 232, 169, 164, 170, 172, 156, 159, - 142, 143, 136, 144, 59, 100, 139, 142, 130, 138, - 147, 146, 150, 161, 128, 235, 143, 155, 146, 167, - 154, 149, 128, 151, 42, 149, 55, 136, 59, 127, - 128, 126, 74, 92, 143, 153, 140, 150, 166, 176, - 146, 152, 150, 145, 140, 100, 140, 105, 124, 59, - 195, 191, 146, 148, 144, 136, 136, 133, 129, 122, - 133, 148, 40, 147, 102, 140, 123, 148, 118, 136, - 143, 143, 150, 148, 184, 153, 160, 147, 166, 149, - 58, 68, 127, 135, 141, 145, 143, 147, 150, 151, - 140, 143, 137, 137, 120, 114, 71, 65, 125, 123, - 153, 148, 215, 159, 136, 135, 150, 146, 150, 150, - 148, 138, 166, 94, 150, 145, 145, 139, 147, 145, - 146, 147, 150, 139, 171, 63, 158, 142, 153, 133, - 147, 148, 143, 143, 76, 72, 155, 159, 164, 176, - 149, 149, 173, 195, 145, 165, 138, 144, 150, 167, - 180, 169, 146, 151, 146, 166, 147, 166, 149, 171, - 157, 156, 168, 166, 147, 149, 121, 122, 116, 124, - 145, 145, 147, 148, 172, 189, 168, 180, 144, 146, - 139, 145, 141, 150, 115, 172, 141, 146, 143, 148, - 145, 145, 142, 143, 145, 147, 138, 143, 58, 73, - 141, 142, 146, 145, 163, 149, 218, 161, 147, 132, - 152, 147, 146, 147, 140, 150, 141, 152, 89, 150, - 78, 134, 135, 137, 139, 142, 140, 137, 137, 130, - 144, 144, 152, 151, 145, 140, 181, 170, 191, 168, - 164, 166, 136, 148, 112, 124, 139, 144, 146, 149, - 142, 151, 113, 182, 137, 150, 143, 156, 138, 147, - 154, 156, 108, 102, 118, 119, 133, 139, 113, 111, - 145, 144, 150, 147, 175, 151, 104, 106, 116, 114, - 143, 144, 151, 157, 151, 191, 135, 113, 138, 123, - 146, 146, 155, 157, 106, 145, 132, 127, 140, 125, - 161, 165, 146, 150, 151, 154, 139, 140, 142, 143, - 144, 148, 145, 149, 147, 138, 168, 104, 146, 136, - 138, 140, 91, 108, 111, 110, 145, 140, 158, 154, - 130, 112, 122, 118, 136, 135, 119, 118, 141, 140, - 147, 146, 146, 145, 138, 138, 182, 188, 132, 132, - 144, 144, 156, 155, 168, 172, 123, 128, 144, 151, - 142, 140, 145, 145, 137, 144, 141, 152, 128, 188, - 149, 149, 160, 161, 160, 160, 166, 163, 130, 107, - 143, 143, 142, 142, 149, 149, 132, 132, 170, 174, - 148, 148, 154, 153, 118, 111, 157, 155, 114, 109, - 140, 139, 138, 137, 205, 187, 137, 133, 147, 144, - 144, 145, 147, 149, 105, 125, 108, 117, 155, 162, - 146, 146, 162, 157, 144, 122, 154, 143, 161, 139, - 141, 142, 130, 131, 144, 144, 142, 141, 144, 142, - 132, 132, 141, 141, 150, 151, 139, 141, 151, 153, - 142, 142, 154, 154, 150, 150, 148, 148, 166, 165, - 143, 142, 144, 144, 132, 132, 142, 144, 130, 128, - 142, 142, 143, 143, 153, 153, 147, 142, 129, 125, - 142, 141, 143, 142, 143, 147, 105, 122, 135, 140, - 141, 140, 140, 140, 151, 151, 156, 155, 146, 146, - 133, 134, 140, 142, 142, 145, 141, 146, 112, 133, - 142, 142, 145, 145, 137, 138, 155, 157, 149, 150, - 144, 144, 139, 138, 130, 128, 132, 131, 147, 147, - 139, 140, 142, 143, 115, 121, 141, 143, 137, 141, - 146, 146, 150, 150, 145, 144, 133, 133, 133, 135, - 143, 144, 144, 144, 166, 167, 139, 142, 139, 140, - 150, 149, 138, 138, 142, 140, 148, 147, 160, 155, - 146, 146, 147, 147, 138, 137, 143, 142, 151, 150 -}; - -static const uint8_t wmavoice_dq_lsp16r2[0x500] = { - 98, 98, 119, 121, 109, 112, 128, 135, 115, 121, - 159, 113, 113, 106, 127, 114, 101, 102, 105, 111, - 161, 162, 137, 138, 161, 159, 152, 150, 150, 148, - 128, 79, 131, 102, 142, 120, 133, 119, 130, 117, - 121, 115, 142, 133, 186, 155, 179, 144, 169, 135, - 107, 103, 106, 106, 122, 122, 111, 112, 112, 115, - 127, 123, 118, 115, 128, 125, 123, 119, 115, 109, - 124, 130, 117, 126, 121, 133, 84, 144, 99, 114, - 122, 125, 123, 131, 124, 135, 176, 200, 158, 176, - 68, 74, 86, 87, 117, 115, 119, 116, 135, 128, - 115, 116, 102, 104, 119, 123, 133, 148, 102, 109, - 71, 121, 106, 117, 107, 127, 106, 122, 100, 110, - 117, 115, 129, 128, 87, 84, 116, 116, 151, 157, - 116, 128, 110, 117, 119, 134, 100, 114, 120, 129, - 142, 141, 146, 151, 94, 91, 114, 114, 118, 118, - 114, 112, 112, 109, 115, 112, 123, 123, 147, 148, - 110, 164, 106, 152, 110, 158, 106, 151, 105, 135, - 85, 51, 71, 27, 71, 34, 74, 45, 85, 53, - 145, 134, 140, 130, 136, 134, 118, 122, 118, 126, - 117, 84, 121, 81, 106, 80, 109, 106, 121, 127, - 95, 94, 112, 110, 90, 94, 109, 107, 114, 109, - 117, 118, 118, 123, 107, 107, 86, 93, 29, 31, - 125, 112, 104, 60, 121, 111, 127, 116, 133, 130, - 118, 117, 148, 145, 122, 126, 124, 127, 90, 91, - 113, 110, 119, 118, 152, 147, 115, 112, 132, 131, - 129, 140, 98, 112, 73, 85, 109, 115, 122, 126, - 123, 122, 122, 122, 126, 125, 137, 140, 203, 210, - 164, 176, 114, 114, 125, 122, 119, 112, 125, 120, - 124, 122, 118, 115, 95, 96, 141, 144, 132, 131, - 127, 130, 132, 134, 116, 114, 122, 123, 137, 134, - 111, 111, 112, 116, 106, 118, 77, 101, 104, 115, - 111, 111, 125, 126, 118, 121, 113, 115, 113, 113, - 171, 170, 202, 199, 221, 206, 199, 184, 177, 167, - 73, 90, 61, 93, 43, 74, 51, 71, 51, 72, - 130, 130, 140, 137, 134, 132, 164, 160, 118, 111, - 123, 136, 133, 154, 130, 158, 106, 110, 110, 114, - 97, 97, 91, 94, 70, 69, 125, 123, 141, 140, - 119, 100, 116, 77, 111, 67, 105, 52, 95, 34, - 100, 122, 90, 124, 68, 120, 43, 117, 50, 112, - 130, 129, 192, 188, 123, 118, 124, 117, 121, 115, - 122, 111, 129, 111, 157, 85, 125, 109, 125, 119, - 143, 152, 119, 128, 114, 116, 129, 136, 148, 157, - 119, 117, 115, 115, 150, 148, 163, 154, 109, 102, - 120, 126, 73, 119, 106, 121, 102, 122, 96, 113, - 84, 83, 117, 115, 122, 117, 154, 143, 159, 142, - 118, 122, 114, 117, 115, 122, 114, 130, 99, 156, - 123, 120, 122, 116, 100, 81, 99, 91, 121, 112, - 139, 131, 164, 142, 132, 119, 145, 133, 157, 141, - 112, 109, 118, 116, 142, 134, 108, 110, 96, 99, - 111, 110, 113, 112, 111, 104, 98, 94, 131, 131, - 115, 114, 121, 118, 120, 115, 173, 148, 123, 117, - 121, 124, 122, 124, 140, 146, 78, 82, 96, 93, - 86, 90, 124, 125, 121, 123, 105, 106, 134, 135, - 107, 109, 132, 141, 100, 95, 113, 114, 102, 105, - 113, 130, 98, 145, 116, 115, 124, 117, 115, 105, - 120, 123, 89, 87, 109, 108, 102, 101, 117, 117, - 113, 122, 132, 138, 77, 116, 86, 99, 118, 126, - 123, 120, 117, 111, 124, 119, 129, 118, 63, 58, - 141, 135, 108, 106, 109, 111, 108, 110, 135, 138, - 117, 114, 134, 127, 139, 129, 138, 130, 126, 122, - 121, 118, 124, 121, 133, 130, 98, 85, 130, 123, - 147, 129, 118, 112, 148, 130, 136, 123, 148, 131, - 113, 112, 123, 118, 123, 115, 147, 95, 117, 110, - 118, 119, 112, 113, 112, 113, 119, 119, 120, 120, - 158, 133, 198, 145, 188, 129, 197, 137, 195, 133, - 132, 140, 140, 139, 158, 156, 223, 217, 233, 233, - 48, 56, 34, 37, 82, 84, 102, 102, 108, 110, - 120, 142, 136, 169, 146, 195, 136, 186, 140, 182, - 196, 186, 158, 155, 142, 134, 132, 125, 120, 119, - 97, 105, 72, 75, 82, 85, 81, 84, 107, 109, - 67, 121, 43, 119, 69, 124, 87, 129, 88, 128, - 53, 57, 93, 98, 91, 94, 93, 98, 104, 104, - 124, 123, 133, 133, 182, 181, 119, 121, 114, 116, - 128, 105, 134, 112, 131, 72, 119, 59, 111, 84, - 132, 142, 145, 180, 124, 132, 131, 143, 122, 134, - 88, 85, 103, 103, 136, 140, 131, 143, 114, 132, - 116, 57, 113, 57, 121, 76, 126, 80, 118, 86, - 127, 112, 127, 97, 131, 100, 149, 91, 163, 86, - 122, 119, 128, 121, 128, 116, 142, 127, 173, 139, - 162, 116, 166, 107, 149, 103, 152, 107, 141, 108, - 114, 113, 118, 116, 56, 43, 90, 90, 105, 105, - 132, 134, 110, 107, 106, 105, 82, 84, 84, 84, - 102, 106, 79, 89, 99, 99, 127, 129, 114, 118, - 139, 157, 116, 123, 116, 123, 87, 89, 110, 113, - 119, 126, 97, 97, 155, 163, 142, 153, 143, 146, - 117, 114, 66, 67, 125, 126, 127, 128, 114, 113, - 111, 114, 127, 133, 123, 132, 143, 162, 133, 148, - 105, 108, 114, 114, 110, 109, 57, 48, 109, 106, - 113, 130, 104, 131, 88, 139, 102, 169, 100, 172, - 129, 114, 150, 97, 114, 112, 117, 119, 109, 116, - 92, 107, 96, 116, 90, 125, 101, 122, 125, 140, - 125, 133, 122, 129, 136, 153, 125, 135, 131, 139, - 84, 71, 129, 123, 135, 120, 114, 103, 112, 101, - 108, 121, 115, 156, 106, 123, 116, 131, 127, 139, - 137, 147, 109, 117, 119, 126, 135, 144, 117, 119, - 120, 127, 76, 105, 111, 116, 120, 125, 141, 138, - 107, 104, 162, 155, 135, 130, 127, 123, 127, 121, - 102, 104, 84, 87, 112, 115, 97, 102, 78, 82, - 119, 118, 120, 123, 91, 105, 114, 119, 119, 126, - 130, 126, 134, 126, 158, 134, 133, 99, 116, 100, - 125, 122, 145, 143, 126, 117, 98, 96, 121, 120, - 152, 148, 131, 126, 130, 129, 126, 119, 87, 87, - 131, 131, 139, 137, 101, 102, 104, 105, 86, 83, - 92, 89, 111, 105, 121, 115, 137, 124, 96, 84, - 100, 96, 122, 119, 107, 108, 93, 96, 79, 82, - 128, 123, 108, 106, 123, 120, 150, 150, 143, 140, - 121, 120, 97, 99, 79, 80, 116, 116, 88, 90, - 128, 131, 101, 97, 140, 140, 117, 116, 116, 118, - 137, 135, 100, 91, 115, 112, 134, 121, 107, 99, - 120, 122, 122, 125, 124, 126, 136, 141, 89, 95, - 103, 119, 103, 116, 122, 139, 125, 137, 152, 170, - 121, 122, 124, 124, 98, 97, 137, 140, 96, 92, - 115, 113, 136, 136, 128, 132, 122, 124, 151, 158, - 100, 107, 121, 131, 131, 158, 119, 130, 113, 114, - 114, 109, 148, 130, 103, 95, 127, 116, 137, 120, - 103, 108, 97, 97, 133, 128, 113, 109, 136, 128, - 125, 124, 118, 118, 122, 121, 101, 99, 157, 152, - 138, 134, 124, 115, 113, 101, 123, 112, 124, 110, - 116, 113, 128, 121, 119, 110, 124, 113, 128, 67, - 114, 118, 114, 123, 109, 121, 102, 123, 56, 116, - 117, 111, 112, 99, 124, 114, 112, 79, 114, 88, - 112, 113, 115, 117, 126, 127, 130, 132, 123, 122, - 111, 104, 111, 102, 112, 102, 129, 118, 129, 115, - 123, 124, 130, 133, 114, 117, 125, 127, 112, 117, - 124, 125, 119, 120, 117, 116, 105, 104, 110, 110, - 125, 124, 118, 116, 124, 123, 124, 121, 133, 132, - 111, 111, 124, 124, 120, 119, 116, 116, 134, 130, - 114, 116, 112, 113, 109, 111, 116, 118, 95, 98 -}; - -static const uint8_t wmavoice_dq_lsp16r3[0x600] = { - 84, 82, 95, 94, 125, 131, 98, 102, 94, 93, 104, 104, - 127, 113, 87, 77, 125, 114, 109, 94, 94, 91, 106, 105, - 168, 125, 163, 120, 128, 100, 119, 99, 108, 97, 108, 106, - 86, 85, 128, 125, 79, 73, 103, 102, 123, 123, 116, 117, - 84, 76, 135, 131, 133, 133, 129, 130, 125, 123, 115, 114, - 94, 97, 79, 81, 115, 115, 94, 93, 128, 127, 126, 125, - 124, 111, 105, 114, 104, 117, 109, 110, 124, 125, 118, 117, - 107, 110, 106, 110, 93, 93, 149, 148, 118, 119, 111, 110, - 147, 157, 143, 156, 134, 136, 118, 121, 106, 107, 105, 105, - 114, 83, 114, 46, 106, 53, 110, 83, 107, 94, 105, 103, - 92, 90, 109, 106, 172, 160, 114, 110, 109, 110, 110, 109, - 90, 98, 98, 109, 102, 98, 97, 92, 100, 100, 101, 102, - 123, 117, 124, 98, 82, 80, 117, 115, 112, 110, 109, 108, - 107, 111, 100, 115, 105, 120, 104, 105, 83, 82, 95, 96, - 109, 120, 72, 71, 97, 104, 69, 74, 99, 102, 118, 117, - 137, 133, 142, 135, 105, 110, 121, 121, 125, 122, 114, 112, - 151, 186, 115, 132, 103, 111, 100, 104, 99, 101, 104, 105, - 18, 38, 56, 65, 76, 83, 85, 91, 101, 103, 108, 110, - 144, 135, 126, 121, 115, 113, 79, 80, 118, 117, 117, 117, - 117, 124, 115, 115, 126, 113, 130, 116, 112, 106, 108, 105, - 77, 76, 76, 80, 109, 109, 125, 129, 130, 133, 116, 118, - 96, 86, 109, 99, 102, 69, 84, 69, 107, 103, 114, 113, - 78, 118, 82, 114, 84, 129, 69, 112, 78, 98, 96, 103, - 89, 137, 96, 111, 105, 97, 93, 93, 101, 105, 105, 105, - 141, 123, 102, 93, 91, 79, 87, 81, 102, 99, 109, 108, - 94, 92, 124, 123, 130, 134, 100, 107, 71, 75, 92, 91, - 94, 104, 107, 83, 106, 101, 113, 114, 122, 122, 114, 114, - 118, 124, 103, 106, 95, 116, 90, 93, 107, 104, 109, 107, - 116, 118, 76, 72, 88, 88, 132, 132, 140, 141, 116, 116, - 90, 81, 111, 95, 139, 97, 123, 96, 112, 100, 110, 108, - 112, 116, 133, 140, 112, 120, 80, 85, 55, 55, 85, 84, - 125, 94, 111, 104, 116, 103, 112, 86, 93, 84, 99, 98, - 180, 179, 197, 197, 169, 163, 149, 146, 130, 124, 116, 115, - 76, 47, 36, 11, 43, 28, 66, 53, 82, 80, 102, 99, - 119, 123, 176, 201, 113, 120, 112, 111, 103, 105, 106, 110, - 145, 114, 112, 89, 120, 93, 123, 104, 131, 123, 113, 111, - 97, 109, 82, 106, 75, 104, 103, 115, 120, 124, 111, 114, - 114, 111, 113, 105, 34, 33, 63, 63, 105, 106, 122, 122, - 51, 41, 96, 92, 125, 125, 118, 118, 118, 119, 113, 113, - 111, 180, 108, 178, 107, 171, 110, 160, 105, 136, 102, 117, - 76, 79, 90, 92, 80, 88, 88, 93, 123, 124, 122, 122, - 131, 128, 123, 122, 151, 158, 108, 107, 129, 128, 119, 119, - 97, 99, 114, 120, 121, 125, 151, 157, 82, 89, 95, 96, - 128, 94, 130, 95, 149, 113, 149, 120, 127, 115, 113, 109, - 167, 171, 83, 80, 84, 79, 106, 106, 112, 110, 107, 108, - 130, 139, 81, 88, 107, 106, 112, 112, 119, 118, 114, 112, - 108, 105, 100, 98, 120, 116, 122, 117, 38, 37, 72, 73, - 118, 125, 110, 120, 114, 126, 135, 142, 139, 142, 118, 119, - 119, 119, 156, 145, 78, 75, 94, 94, 112, 110, 113, 113, - 101, 108, 98, 104, 103, 109, 117, 118, 167, 167, 132, 132, - 116, 108, 118, 111, 149, 136, 85, 74, 95, 92, 113, 112, - 74, 69, 104, 107, 96, 100, 117, 121, 103, 105, 103, 103, - 110, 106, 111, 101, 82, 72, 96, 92, 132, 130, 120, 121, - 116, 113, 138, 139, 104, 103, 131, 131, 68, 69, 92, 92, - 97, 97, 146, 151, 122, 132, 97, 95, 117, 116, 115, 116, - 139, 134, 110, 110, 124, 129, 100, 110, 86, 91, 100, 102, - 116, 136, 88, 90, 137, 139, 103, 114, 114, 117, 111, 110, - 82, 83, 104, 102, 97, 99, 97, 97, 58, 56, 84, 84, - 83, 122, 76, 105, 112, 126, 120, 134, 112, 120, 108, 110, - 114, 128, 73, 90, 72, 76, 98, 100, 95, 96, 101, 102, - 101, 108, 118, 126, 94, 102, 81, 83, 138, 140, 131, 130, - 88, 100, 112, 124, 105, 106, 122, 123, 121, 121, 114, 114, - 76, 108, 73, 83, 93, 95, 110, 111, 98, 99, 103, 103, - 105, 112, 98, 108, 114, 95, 117, 98, 120, 116, 116, 115, - 231, 238, 150, 146, 124, 126, 115, 122, 117, 121, 112, 112, - 74, 73, 72, 74, 60, 61, 62, 61, 85, 85, 101, 101, - 67, 69, 50, 51, 83, 83, 110, 110, 118, 113, 112, 111, - 199, 124, 184, 115, 176, 117, 165, 120, 138, 115, 116, 114, - 52, 116, 36, 107, 49, 99, 72, 106, 91, 107, 104, 105, - 140, 138, 141, 135, 154, 147, 166, 159, 139, 136, 116, 115, - 130, 119, 180, 157, 183, 149, 136, 121, 119, 114, 111, 110, - 104, 129, 113, 154, 111, 148, 108, 132, 105, 117, 106, 111, - 114, 35, 99, 65, 113, 94, 110, 98, 111, 107, 107, 106, - 106, 110, 128, 135, 162, 175, 143, 155, 115, 116, 109, 109, - 168, 155, 112, 109, 125, 125, 126, 122, 126, 124, 111, 112, - 128, 96, 160, 77, 151, 77, 121, 80, 114, 94, 107, 103, - 97, 104, 101, 116, 56, 79, 74, 83, 92, 95, 104, 106, - 63, 68, 76, 77, 110, 107, 96, 90, 85, 83, 97, 96, - 116, 110, 46, 42, 103, 100, 122, 120, 102, 101, 104, 104, - 106, 101, 109, 98, 96, 61, 67, 35, 72, 61, 96, 93, - 88, 80, 81, 76, 113, 110, 144, 143, 88, 89, 93, 94, - 95, 96, 100, 101, 136, 132, 166, 160, 148, 147, 115, 116, - 80, 78, 130, 129, 120, 108, 91, 85, 95, 91, 104, 102, - 151, 147, 106, 109, 110, 110, 64, 69, 68, 67, 96, 96, - 90, 166, 97, 128, 99, 120, 104, 121, 109, 118, 105, 109, - 122, 138, 110, 143, 75, 97, 83, 94, 89, 94, 102, 103, - 136, 142, 103, 110, 83, 89, 99, 101, 138, 138, 120, 122, - 168, 88, 105, 90, 109, 107, 110, 111, 106, 105, 103, 102, - 68, 72, 102, 104, 92, 102, 65, 75, 89, 94, 106, 106, - 83, 74, 93, 85, 73, 66, 106, 102, 100, 92, 99, 97, - 93, 99, 101, 96, 116, 112, 125, 120, 88, 88, 96, 96, - 44, 98, 93, 115, 104, 116, 103, 107, 112, 113, 107, 107, - 93, 83, 105, 99, 93, 84, 127, 125, 141, 143, 117, 118, - 106, 103, 126, 121, 137, 123, 123, 114, 147, 142, 127, 123, - 103, 110, 89, 91, 121, 124, 66, 71, 68, 69, 96, 97, - 114, 105, 68, 65, 69, 67, 96, 94, 131, 130, 123, 121, - 111, 104, 130, 121, 95, 95, 72, 74, 88, 88, 105, 104, - 135, 124, 110, 98, 114, 111, 159, 158, 111, 113, 104, 106, - 103, 108, 94, 107, 55, 57, 115, 118, 121, 122, 111, 111, - 97, 99, 106, 111, 119, 126, 59, 62, 111, 112, 124, 125, - 86, 93, 100, 110, 118, 145, 113, 132, 120, 125, 112, 112, - 101, 115, 78, 149, 81, 114, 111, 121, 108, 112, 107, 108, - 104, 104, 94, 96, 84, 83, 135, 132, 71, 69, 88, 86, - 100, 98, 62, 60, 81, 80, 90, 89, 63, 66, 89, 90, - 123, 116, 108, 99, 90, 86, 91, 92, 65, 65, 88, 88, - 84, 79, 115, 109, 123, 111, 99, 99, 134, 136, 121, 123, - 127, 137, 84, 88, 104, 107, 128, 130, 74, 69, 89, 89, - 118, 112, 143, 132, 141, 131, 113, 113, 99, 102, 104, 105, - 117, 115, 100, 99, 131, 126, 90, 88, 145, 144, 128, 127, - 112, 114, 131, 133, 85, 84, 118, 119, 151, 152, 117, 117, - 110, 105, 162, 140, 116, 107, 140, 134, 124, 122, 113, 113, - 107, 110, 124, 133, 98, 103, 99, 107, 109, 113, 112, 112, - 115, 105, 82, 77, 125, 122, 133, 132, 118, 120, 113, 113, - 101, 88, 84, 80, 97, 99, 91, 91, 94, 94, 101, 100, - 121, 86, 139, 108, 106, 93, 103, 99, 112, 108, 108, 107, - 113, 83, 105, 102, 125, 125, 114, 115, 110, 112, 108, 109, - 93, 112, 113, 121, 125, 131, 101, 101, 107, 109, 111, 111, - 98, 102, 117, 126, 80, 84, 107, 109, 83, 84, 96, 97, - 132, 136, 112, 118, 94, 93, 121, 118, 99, 98, 102, 103, - 122, 127, 128, 133, 118, 104, 102, 88, 100, 94, 104, 102, - 115, 116, 102, 105, 140, 142, 135, 130, 90, 88, 100, 101, - 94, 86, 112, 112, 89, 121, 92, 101, 109, 108, 110, 112, - 99, 93, 129, 114, 109, 99, 131, 119, 102, 97, 103, 103, - 103, 116, 124, 101, 115, 95, 105, 101, 94, 91, 100, 100, - 113, 90, 94, 86, 92, 92, 117, 111, 106, 103, 106, 105, - 115, 99, 110, 91, 107, 104, 81, 90, 108, 113, 112, 113, - 113, 114, 93, 101, 101, 102, 101, 126, 93, 103, 104, 105, - 117, 106, 124, 107, 104, 119, 108, 133, 104, 111, 104, 106 -}; - -static const float wmavoice_lsp10_intercoeff_a[32][2][10] = { - { { 0.5108627081, 0.0480548441, -1.5099149644, 0.6736935377, - 0.7536551058, 0.7651474178, 0.8510628343, 0.6667704582, - 0.7576012611, 0.7091397047 }, - { 0.1351471841, -0.1965375543, -1.6313457787, 0.3218626380, - 0.4132472873, 0.4663473070, 0.5805781186, 0.3962165117, - 0.4818550050, 0.4907165468 } }, - { { 0.8556320667, 0.7774704993, -0.0175759494, -0.1882298589, - 0.1892164350, 0.4850396216, 0.6270319819, 0.6327089071, - 0.6513319910, 0.6075088978 }, - { 0.4374088347, 0.3505934179, -0.0762144327, -0.2830760479, - -0.0626451969, 0.1500318050, 0.2602472305, 0.2781780064, - 0.3167395592, 0.3596626520 } }, - { { 0.1899779737, 0.0650856197, 0.1699010432, 0.9122628570, - 0.9097705483, 0.7433397174, 0.6304935217, 0.5164704025, - 0.4174703658, 0.5215242505 }, - { 0.0704856217, 0.0169009864, 0.0188394487, 0.5587704182, - 0.5194473267, 0.3539164960, 0.2426626086, 0.1721164286, - 0.1371548772, 0.2594856918 } }, - { { 0.8858859241, 0.9100474715, 0.8921859264, 0.9332397878, - 1.0225475132, 1.0555013716, 1.0983552337, 1.1290244758, - 1.0363244414, 0.9277705550 }, - { 0.4810934663, 0.5782935023, 0.6835935414, 0.7650781870, - 0.9018090069, 0.9996321201, 1.0219936669, 1.0474705994, - 0.9109474719, 0.7774704993 } }, - { { 0.4359549880, 0.2275702953, 0.0993548632, 0.1763395071, - 0.1055856347, 0.1018471718, 0.1170087159, 0.1221317947, - 0.1834010482, 0.2988780141 }, - { 0.1573702693, 0.1041317880, 0.0506856143, 0.0781702399, - 0.0058932900, -0.0026913285, -0.0031067133, 0.0070702136, - 0.0116394460, 0.0566394627 } }, - { { 0.8528628349, 0.8028782010, 0.4680088460, 0.9055474699, - 1.3742399514, 1.1093629301, 0.4122780561, 0.4003703594, - 0.6360319853, 0.6415704489 }, - { 0.4252934456, 0.3823703527, 0.1676856577, 0.5241550207, - 1.1995706558, 0.9088013172, 0.1224087179, 0.0730471611, - 0.3071857095, 0.3772472739 } }, - { { 0.5508781075, 0.2829549313, -0.0022067130, 0.1042702496, - 1.0318244398, 1.3258476257, 1.3550630212, 0.9931936562, - 0.7195243239, 0.6807550788 }, - { 0.2679318488, 0.0960317850, -0.1357529163, -0.1291759908, - 0.6451012194, 0.9968628883, 0.9510321021, 0.6608166099, - 0.3799472749, 0.3735780418 } }, - { { 0.9967244267, 1.0255244374, 0.9800398052, 0.7939474285, - 0.8288397491, 0.8390166759, 0.8660166860, 0.9247936308, - 0.9127474725, 0.8684397638 }, - { 0.7921474278, 0.9416859448, 0.8547320664, 0.5348165631, - 0.6231550574, 0.6703012288, 0.6987550855, 0.8147858977, - 0.7406397164, 0.6496012211 } }, - { { 0.1439394951, -0.3193529844, -0.2024914026, -0.1854606271, - 0.0877240896, 0.1617318094, 0.3087087870, 0.3777318895, - 0.3910242021, 0.4797780812 }, - { -0.0157067180, -0.1778452396, -0.1554836929, -0.1759760082, - -0.0607759655, -0.0161221027, 0.0393317640, 0.0758856237, - 0.1163856387, 0.1947548985 } }, - { { 1.1021629274, 0.9958244264, 0.4658626914, 0.3089164793, - 0.3740626574, 0.2962472439, 0.3170857131, 0.2420395315, - 0.2649549246, 0.2936857045 }, - { 0.4700857699, 0.1809087396, 0.0311625302, 0.0106009841, - 0.0311625302, 0.0266625285, 0.0221625268, 0.0156548321, - 0.0551163852, 0.1010164022 } }, - { { 0.2925087810, 0.3418011069, 0.7339243293, 0.7322627902, - 0.7288704813, 0.7924935818, 0.7724166512, 0.7819012702, - 0.8325782120, 0.7954705060 }, - { 0.0559471548, -0.0456144214, -0.0462374985, -0.1005144417, - -0.0511528850, -0.0455451906, -0.0044220984, 0.0451471508, - 0.1232394874, 0.2085318267 } }, - { { 0.2230702937, -0.9052532017, 1.2441552877, 1.0825706124, - 0.9088705480, 0.8797243834, 0.8648397624, 0.8091089725, - 0.7633474171, 0.7468704879 }, - { -0.2030452490, -1.4167303145, 1.3542322516, 0.8369397521, - 0.6148473620, 0.5560704172, 0.5450627208, 0.4978473186, - 0.4200319052, 0.4904396236 } }, - { { 0.6088242829, 0.5965704322, 0.6547242999, 0.8554936051, - -0.2989298999, 0.2404472232, 0.3573780358, 0.7499166429, - 0.7691628039, 0.6824858487 }, - { 0.2582395375, 0.2721549273, 0.3462318778, 0.4820626974, - -0.4780299664, -0.0712990463, 0.0200163722, 0.4246703684, - 0.4660011530, 0.4172626734 } }, - { { 1.1749937236, 1.0773090720, 1.0566782951, 1.0249013603, - 0.9947167337, 0.9626628757, 0.9562244117, 0.9072782397, - 0.7654243410, 0.6448935270 }, - { 1.1595552564, 0.9340013266, 0.3959395885, 0.3693549633, - 0.3915780485, 0.3104395568, 0.3499011099, 0.2236933708, - 0.1638087332, 0.1811856627 } }, - { { 0.9572628736, 0.9389859438, 0.6619243026, 0.6849089265, - 0.7276935577, 0.7839781940, 0.7987243533, 0.7748397291, - 0.7101089358, 0.7277627885 }, - { 0.5809935033, 0.5575934947, 0.3544703424, 0.3636780381, - 0.3736472726, 0.4486242235, 0.4684934616, 0.4481396079, - 0.3456780314, 0.4478626847 } }, - { { 0.1259394884, 1.3096476197, 1.0794552267, 1.0009475052, - 0.9061013162, 0.9216782451, 0.8954397738, 0.9160013199, - 0.8575012982, 0.7479089499 }, - { -0.3689222336, 1.5293861628, 0.7323320210, 0.4102703631, - 0.3825780451, 0.2828164697, 0.2644010782, 0.2455010712, - 0.2482010722, 0.2335241437 } }, - { { 0.5380704105, 0.1600702703, -0.0657605827, -0.2390452623, - -0.3885837793, -0.4150299430, -0.3001760542, -0.1451683044, - 0.1312010288, 0.2798395455 }, - { 0.2074933648, 0.0560163856, -0.0956682861, -0.2893068194, - -0.3889991641, -0.3918376267, -0.3550068438, -0.2649375796, - -0.0554451942, 0.1167317927 } }, - { { 0.6092396677, 0.5101011693, 0.4012011290, 0.5416011810, - 0.5715781152, 0.6476627588, 0.6988243163, 0.7306012511, - 0.7531704903, 0.6534781456 }, - { 0.2060395181, 0.1409625709, 0.1024702489, 0.1834010482, - 0.1946856678, 0.2547779977, 0.3134857118, 0.3283011019, - 0.3837549686, 0.3501780331 } }, - { { 0.4516011477, 0.5351627171, 0.8068243563, 0.7049858570, - 0.7165473998, 0.6005858183, 0.4870473146, 0.2500010729, - 0.3132087886, 0.4462703764 }, - { 0.1053087115, 0.1348702610, 0.4457857609, 0.3499703407, - 0.3537780344, 0.2628780007, 0.1665087342, 0.0200856030, - 0.0329625309, 0.1525241137 } }, - { { 0.7058166265, 0.7305320203, 1.1684860289, 1.4524707496, - 1.3212091625, 1.2613245249, 1.1712552607, 1.1154552400, - 1.0487167537, 0.9153782427 }, - { 0.2286087573, 0.2851703167, 1.2016475797, 1.5154707730, - 1.2726091444, 1.1459167898, 0.9801090360, 0.9296397865, - 0.8490551412, 0.6772243083 } }, - { { 0.6686396897, 0.5728935003, 0.4734780788, 0.6970243156, - 0.5852165818, -0.0762836635, -0.2054683268, -0.1380375326, - 0.1282933354, 0.3467164934 }, - { 0.2925087810, 0.2344933748, 0.1677548885, 0.2747856975, - 0.2097087502, -0.2795452774, -0.3761222363, -0.3183837533, - -0.0834836662, 0.1482318044 } }, - { { 0.6559704542, 0.7737320364, 0.9867551923, 0.9912551939, - 0.9508936405, 0.9114320874, 0.8336859047, 0.7905551195, - 0.7672935724, 0.7532397211 }, - { 0.1843702793, 0.2565087676, 0.7571858764, 0.7545551062, - 0.6793704629, 0.5981627405, 0.5078165531, 0.4282011390, - 0.3948318958, 0.4502165318 } }, - { { 0.4430857599, 0.6102781296, 0.8485012949, 0.8573628366, - 0.9078320861, 0.9979705811, 1.0411013663, 1.0524552166, - 1.0194321275, 0.9023628533 }, - { 0.0070009828, 0.0084548295, 0.1613856554, 0.3484472632, - 0.4385857582, 0.5895088911, 0.6367935240, 0.6736935377, - 0.7026320100, 0.5924165845 } }, - { { 1.0532859862, 1.1059706211, 1.1311013997, 1.1250783205, - 1.0425552130, 0.9993551970, 0.9673013389, 0.9386397898, - 0.8836013079, 0.8336859047 }, - { 0.9791398048, 1.1481321752, 1.1275706291, 1.0082167387, - 0.8809705377, 0.8031551242, 0.7287320197, 0.6496704519, - 0.5211088657, 0.4734088480 } }, - { { -0.0251221061, -0.0443682671, 0.1282241046, 0.3850703537, - 0.4252934456, 0.4547857642, 0.4690473080, 0.4873242378, - 0.6001012027, 0.5882627368 }, - { -0.0562759638, -0.0246374905, 0.0070009828, 0.0971394777, - 0.1232394874, 0.1278779507, 0.1302317977, 0.1462241113, - 0.2073549032, 0.2446010709 } }, - { { 1.1749244928, 1.1155937016, 0.9236167073, 0.6288319826, - 0.6515396833, 0.5391781032, 0.5398011804, 0.4997165501, - 0.4066703618, 0.3998857439 }, - { 0.9403013289, 0.7346166372, 0.1841625869, 0.1319625676, - 0.1395087242, 0.0857856274, 0.0952702463, 0.0860625505, - 0.0829471648, 0.1132010221 } }, - { { 0.9047167003, 0.9840551913, 0.9933321178, 0.9360090196, - 0.9164859354, 0.9213320911, 0.8701705337, 0.8815936148, - 0.8414397538, 0.8188012838 }, - { 0.0961010158, -0.0147374868, 0.0202240646, 0.1002548635, - 0.1407548785, 0.1837472022, 0.1858241260, 0.2064549029, - 0.2228626013, 0.2859318554 } }, - { { 0.4034165144, 0.1918472052, 2.1959402561, 0.4763165414, - 0.6577012241, 0.7036704719, 0.6626858413, 0.7650089562, - 0.7702704966, 0.6543781459 }, - { 0.0940933228, -0.1222529113, 2.3491480052, 0.1385394931, - 0.3052472472, 0.3665857315, 0.3350857198, 0.4722319245, - 0.4313857555, 0.3846549690 } }, - { { 0.8215012848, 0.8613782227, 1.0399936736, 1.4082322717, - 0.4075011313, 0.4091626704, 0.5230473280, 0.6101396680, - 0.7510243356, 0.7237474024 }, - { 0.4810934663, 0.5670088828, 0.9207782447, 1.3007860780, - 0.0453548431, 0.0858548582, 0.1803548932, 0.2790087759, - 0.3974626660, 0.4581780732 } }, - { { 1.5921784937, 1.4987169206, 1.1321398616, 0.8235089779, - 0.6888550818, 0.6621319950, 0.6192089021, 0.6533396840, - 0.7196627855, 0.6549319923 }, - { 1.5911400318, 1.4768399894, 0.9358705580, 0.4674549997, - 0.3522549570, 0.3144549429, 0.2985318601, 0.3559241891, - 0.4061857462, 0.3958703578 } }, - { { 0.7975474298, 0.8712782264, 0.8974474669, 0.3008164763, - 0.5562088788, 0.6655935347, 0.8921166956, 1.0918475389, - 0.9544936419, 0.8554936051 }, - { 0.3769703507, 0.4930703938, 0.6619243026, -0.0382759571, - 0.1766856611, 0.3015780151, 0.5952550471, 0.8903859258, - 0.7395320237, 0.6205935180 } }, - { { 0.2206472158, 2.4467634261, 1.2920629978, 1.0239321291, - 0.9014628530, 0.8552166820, 0.8219859004, 0.9005628526, - 0.7614781857, 0.7763628066 }, - { -0.2722068131, 2.8967635930, 1.3039706945, 0.7695089579, - 0.6132550538, 0.5701242685, 0.5737935007, 0.6533396840, - 0.5422934890, 0.5150857866 } }, -}; - -static const float wmavoice_lsp10_intercoeff_b[32][2][10] = { - { { 0.4881048799, -0.1998192370, -0.3872502148, 0.0109423101, - 0.0406953394, 0.1788437665, 0.1673750877, 0.3409781158, - 0.4061202109, 0.5221177042 }, - { 0.1492218077, -0.1372330189, -0.2683691680, -0.0621950924, - -0.0624572337, -0.0068177581, -0.0076041818, 0.0680235624, - 0.1055752933, 0.1199930608 } }, - { { 0.7934338748, 0.0012430847, 0.4239458144, 0.5521328747, - 0.6497149467, 0.6423749924, 0.7170197070, 0.7169541717, - 0.7778364718, 0.8397018015 }, - { 0.2768190503, -0.0491535664, -0.0325731337, 0.0261465013, - 0.0469867289, 0.0649434030, 0.0781815350, 0.1031504869, - 0.1194687784, 0.2451654971 } }, - { { 0.7212139666, 0.1658677757, 0.0101558864, 0.5636015534, - 1.3175852597, 1.1911676526, 1.1266809106, 0.8230558336, - 0.8604109585, 0.8094900250 }, - { 0.3658815324, 0.0816549063, -0.2092563212, 0.1946377754, - 1.0856558084, 0.9491457641, 0.8461242616, 0.5193652213, - 0.5975488424, 0.5293265879 } }, - { { 0.9507186115, 0.9078585207, 0.8773190677, 0.8677509129, - 0.8024122119, 0.8127667904, 0.8246286809, 0.8779088855, - 0.9454102516, 0.9863698184 }, - { 0.6883807778, 0.6900191605, 0.7059442401, 0.6552854478, - 0.5843107104, 0.5553441048, 0.5887671113, 0.6494528055, - 0.7725936472, 0.7792782485 } }, - { { 0.2399882078, 0.1938513517, 0.4441962242, 0.4475385249, - 0.3055235147, 0.1745184362, 0.1174371839, 0.0679580271, - 0.0782470703, 0.1695377529 }, - { 0.0170370936, 0.0253600776, 0.2072205544, 0.1907711923, - 0.1096384823, 0.0327000320, -0.0134368241, -0.0461389422, - -0.0372916758, -0.0243156850 } }, - { { 0.5457104146, 0.3774812818, 0.5235594809, 0.2994287312, - 0.2394639254, 0.5731041729, 0.9971176088, 1.1646913886, - 0.9028123021, 0.7777709365 }, - { 0.2288472056, 0.1181580722, 0.2074171603, 0.0355180502, - -0.0024924278, 0.2596487999, 0.7474936247, 0.9103488624, - 0.5927647650, 0.4772915542 } }, - { { 0.6541713476, 0.6412608922, 0.7625012100, 0.7826205492, - 0.4839106202, 0.3311478198, 0.4577620327, 0.8572652638, - 0.9442306161, 0.8282986581 }, - { 0.2852075696, 0.2614837885, 0.4221763611, 0.4314823747, - 0.1434547007, 0.0435788929, 0.1397191882, 0.5525916219, - 0.6752081811, 0.5487250388 } }, - { { 0.6742251515, 1.0610800683, 1.0500701368, 0.9570100009, - 0.9325653315, 0.9243078828, 0.9148707986, 0.8317720294, - 0.7696445584, 0.6784849465 }, - { 0.2283884585, 0.9739181101, 0.5336519182, 0.4974764287, - 0.3998288214, 0.3674543798, 0.2719694376, 0.2608939707, - 0.2087934017, 0.1675716937 } }, - { { 0.3736146986, -1.5457833707, 0.9216864705, 0.7959242165, - 0.7358283401, 0.7233110964, 0.7271121442, 0.6852350831, - 0.6891672015, 0.6589554250 }, - { 0.1246460676, -1.7167649865, 0.7037160397, 0.4803061783, - 0.4694928527, 0.4654951990, 0.5208069980, 0.5305717587, - 0.5288023055, 0.5278192759 } }, - { { 1.0116009116, 0.9882703424, 0.8393741250, 0.8889843524, - 0.8934407532, 0.8906227350, 0.9222107530, 0.8973073363, - 0.9257496595, 0.9306648076 }, - { 0.5097970665, -0.0106843412, 0.1419473886, 0.2804890275, - 0.3719763160, 0.3694859743, 0.4640534222, 0.5034401417, - 0.5592106879, 0.6652468145 } }, - { { 0.9718209803, 0.7615181804, 0.2172474563, 0.4920369983, - 0.4310891628, 0.5038333535, 0.4668059051, 0.5339140594, - 0.4453758597, 0.4050061107 }, - { 0.6543679535, 0.1205173433, -0.0050483048, 0.1580035388, - 0.1308719218, 0.1700620353, 0.1740596890, 0.2179683447, - 0.1967349052, 0.1703897119 } }, - { { 0.7663022578, 0.4025157690, 1.3811545074, 1.1642981768, - 1.0709758997, 0.9812580645, 1.0092416406, 0.9089070857, - 0.7776398659, 0.8189926445 }, - { 0.3471384346, 0.0602248609, 1.3968829811, 1.0841484964, - 0.8940305710, 0.7313719392, 0.7345176339, 0.5304406881, - 0.4076275229, 0.4535677731 } }, - { { 0.1300854981, 0.1323136985, 0.7564064264, 0.7335346043, - 0.7924508452, 0.6039057672, 0.6896914840, 0.3694859743, - 0.2825861573, 0.3179096878 }, - { -0.0208423138, -0.0530856848, 0.3449102342, 0.3819376826, - 0.4466865659, 0.2807511687, 0.3842969537, 0.1144880950, - 0.0617321730, 0.0767397583 } }, - { { 0.7559476793, 0.8462553322, 0.6452585459, 1.1308751702, - 1.0606868565, 0.9498666525, 0.7425129414, 0.6221901178, - 0.6574481130, 0.6976212561 }, - { 0.3420922160, 0.4310236275, 0.2800958157, 0.9317133725, - 0.8210897744, 0.6144569516, 0.3227593005, 0.2464762032, - 0.2769501209, 0.3521846533 } }, - { { 0.7609938979, 0.6943444908, 1.1490939856, 0.4350868165, - 0.6101971567, 0.6246149242, 0.7370079756, 0.6522052884, - 0.6966382265, 0.7565374970 }, - { 0.3939306438, 0.3449102342, 0.9874839187, 0.0910919905, - 0.2804234922, 0.2888775468, 0.4060546756, 0.3284608722, - 0.3483836055, 0.4819445610 } }, - { { 0.7828826904, 1.1833034158, 1.9916158915, 0.8667678833, - 0.9218830764, 0.8856420517, 0.9373494089, 0.7415299118, - 0.7450032830, 0.7074515522 }, - { 0.4685098231, 1.1713104546, 1.9853245020, 0.6206828058, - 0.6664264500, 0.6033814847, 0.6089519858, 0.3784643114, - 0.4212588668, 0.3441893458 } }, - { { 0.4671335816, 0.4177199602, 0.0804097354, -0.1836975515, - -0.1802241802, -0.0775958896, -0.0250365734, 0.0884050429, - 0.2136430144, 0.3472039700 }, - { 0.1187478900, 0.1122598946, -0.0381436348, -0.2284581661, - -0.2302276194, -0.1738672554, -0.1350048184, -0.0547896028, - 0.0000634491, 0.0545888245 } }, - { { 0.5545576811, 0.4791920781, 0.8204999566, 0.8462553322, - 0.9212277234, 0.8946203887, 0.9659883380, 0.9137566984, - 0.9225384295, 0.9207034409 }, - { 0.1176993251, -0.0429277122, -0.0330318809, 0.0566859543, - 0.0983008742, 0.1593797803, 0.1732077301, 0.2320584357, - 0.2739354968, 0.3753186166 } }, - { { 0.7157745361, 0.6367389560, -1.2036890686, 0.7107283175, - 0.6885118484, 0.7332724631, 0.7436270416, 0.7113181353, - 0.5935511887, 0.6023984551 }, - { 0.3664058149, 0.3280676603, -1.3082178831, 0.3909815550, - 0.3641776145, 0.3926854730, 0.3898674548, 0.4086760879, - 0.3127979338, 0.3949792087 } }, - { { 1.0267395675, 1.0621941686, 1.0415505469, 0.9971176088, - 0.9764739871, 0.9904330075, 0.9591071308, 0.9338760376, - 0.9026156962, 0.9073997736 }, - { 0.9855833948, 1.0548542142, 0.9787021875, 0.8573307991, - 0.8360973597, 0.8193203211, 0.7386463583, 0.7038471103, - 0.6333966553, 0.6434235573 } }, - { { 0.6235008240, 0.7635497749, 0.8094900250, 0.7227212787, - -0.0610809922, -0.1357912421, -0.2359291911, 0.0800165236, - 0.3972729445, 0.5078965425 }, - { 0.2983146310, 0.4983939230, 0.4145742655, 0.3284608722, - -0.3203386664, -0.3495018780, -0.4734291434, -0.1808139980, - 0.1211071610, 0.2001427412 } }, - { { 0.8925887942, 0.8804647624, 0.6153089106, 0.6760601401, - 0.7887153327, 1.0065546930, 1.0829033256, 1.0347348750, - 0.9800128937, 0.9125770628 }, - { 0.5955827832, 0.6195687056, 0.2924164534, 0.3553958833, - 0.5417127609, 0.8713553548, 0.9977729619, 0.8817754686, - 0.7645328045, 0.6604627371 } }, - { { 1.1581378579, 1.0359145105, 0.7731179297, 0.6839243770, - 0.6839899123, 0.6664264500, 0.6910677254, 0.6579068601, - 0.6779606640, 0.6243527830 }, - { 1.1508634388, 0.8400294781, 0.2358594835, 0.2542749047, - 0.2484422624, 0.2620736063, 0.2676441073, 0.2713796198, - 0.3068997562, 0.3223005533 } }, - { { 0.1376220584, 1.2572927773, 0.8593623936, 0.6218624413, - 0.5128116906, 0.5393534899, 0.4436064065, 0.4334484339, - 0.4494390488, 0.4002220333 }, - { -0.1159995794, 1.2433337569, 0.4805027843, 0.2632532418, - 0.1769432425, 0.1868390739, 0.1555131972, 0.1530228555, - 0.1490252018, 0.1559064090 } }, - { { 0.1817273200, -0.0085216761, 0.0739872754, 0.1808098257, - 0.2770811915, 0.3344901204, 0.4292541742, 0.5404020548, - 0.5780193210, 0.5707449019 }, - { -0.0035409927, -0.0188107193, -0.0057691932, 0.0132360458, - 0.0560961366, 0.0534747243, 0.1002013981, 0.1737320125, - 0.1706518531, 0.1637706459 } }, - { { 0.9648087025, 1.0030813217, 0.9501943290, 0.8381944895, - 0.7545059025, 0.7621735334, 0.7121700943, 0.7328792512, - 0.7534573376, 0.7414643764 }, - { 0.1872322857, -0.0081939995, 0.0663851798, 0.0963348150, - 0.0509188473, 0.0565548837, 0.0471833348, 0.0809340179, - 0.1049199402, 0.1751082540 } }, - { { 0.6792713702, 0.9521603882, 0.5296542645, 0.3657504618, - 0.3905883431, 0.3121425807, 0.2726903260, 0.3156159520, - 0.2859284580, 0.3179096878 }, - { 0.2307477295, 0.3771536052, 0.0743804872, 0.0260154307, - 0.0477731526, 0.0391880274, 0.0228042006, 0.0572757721, - 0.0337485969, 0.0492149293 } }, - { { 0.8649328947, 0.9505875409, 1.0443030298, 1.1704584956, - 1.2709241211, 1.3232212961, 1.2477901578, 1.1513877213, - 1.0346038043, 0.9695272446 }, - { 0.4620873630, 0.5685822368, 0.8975039423, 1.0476453304, - 1.2278674245, 1.2290470600, 1.1962138712, 1.0051129162, - 0.8706344664, 0.7477557659 } }, - { { 0.4188340604, 0.6011532843, 0.4726385474, 0.6389671564, - 0.6753392518, 0.7842589319, 0.6147846282, 0.6708828509, - 0.6406055391, 0.5398777723 }, - { 0.1012499630, 0.2312064767, 0.1773364544, 0.2800302804, - 0.3348177969, 0.4343003929, 0.2822584808, 0.3293128312, - 0.3024433553, 0.2401848137 } }, - { { 0.5049474537, 0.7943513691, 0.9536021650, 0.9407572448, - 0.9823721647, 0.9747045338, 1.0145500004, 0.9629737139, - 0.9526191354, 0.9283710718 }, - { 0.0566204190, 0.0973178446, 0.5812305510, 0.5687133074, - 0.6834000945, 0.6616423726, 0.7611905038, 0.6683925092, - 0.6463071108, 0.6118355393 } }, - { { 0.8969141245, 0.9359731674, 0.8756151497, 0.8419300020, - 0.8353109360, 0.6807131469, 0.3358008265, 0.3386188447, - 0.3524467945, 0.4495045841 }, - { 0.5298508704, 0.4606455863, 0.4934132397, 0.4415748119, - 0.4015327394, 0.2052544951, -0.0329663455, -0.0154684186, - 0.0418094397, 0.1631152928 } }, - { { 0.6345762908, 2.5209445655, 1.0373562872, 0.9166402519, - 0.8865595460, 0.8907538056, 0.8522190452, 0.7290782034, - 0.7385808229, 0.6345107555 }, - { 0.2641707361, 2.5696372986, 0.8539884984, 0.6532538533, - 0.6087553799, 0.5851626694, 0.5276226699, 0.4330552220, - 0.3971418738, 0.3599833548 } }, -}; - -static const float wmavoice_lsp16_intercoeff_a[32][2][16] = { - { { 0.5337238312, 0.4810695648, -0.3766536713, -0.1204767227, - -0.0898437500, -0.0070896149, 0.1134738922, 0.1337728500, - 0.3739156723, 0.3849058151, 0.4220180511, 0.5404901505, - 0.5224876404, 0.5502910614, 0.5313453674, 0.4405946732 }, - { 0.1775283813, 0.1679325104, -0.2702789307, -0.1359367371, - -0.1452455521, -0.0888595581, -0.0256662369, -0.0023736954, - 0.1074047089, 0.1431636810, 0.1357412338, 0.2045526505, - 0.2686481476, 0.3404531479, 0.3209333420, 0.1493968964 } }, - { { 0.7402400970, 0.0838251114, 0.6486282349, 0.6145095825, - 0.7331047058, 0.7183008194, 0.7436847687, 0.7627944946, - 0.7653779984, 0.7795667648, 0.8399305344, 0.8393154144, - 0.8219690323, 0.7474164963, 0.6681070328, 0.6490793228 }, - { 0.2850513458, -0.0544128418, -0.0300130844, 0.0204677582, - 0.0328931808, 0.0589332581, 0.0796422958, 0.1187639236, - 0.1320505142, 0.1539077759, 0.2189874649, 0.2865276337, - 0.2973947525, 0.2614307404, 0.2416648865, 0.2428951263 } }, - { { 0.6129922867, 0.7300701141, 0.2073822021, 0.5005893707, - 0.5713691711, 0.5374965668, 0.6293134689, 0.5639057159, - 0.7402811050, 0.6982889175, 0.4668397903, 0.6698703766, - 0.8758535385, 0.8678569794, 0.8678569794, 0.7810840607 }, - { 0.2986249924, 0.3269615173, 0.0096416473, 0.1800708771, - 0.2474060059, 0.2203407288, 0.3007984161, 0.2674179077, - 0.4424810410, 0.4046306610, 0.2063980103, 0.4230022430, - 0.6222190857, 0.6574449539, 0.6776618958, 0.6604385376 } }, - { { 0.7258052826, 0.5073966980, -0.3947381973, 0.5254812241, - 1.0561246872, 0.9706230164, 0.9727144241, 0.9185838699, - 0.8184833527, 0.9093980789, 0.8645353317, 0.7870302200, - 0.6347675323, 0.5123996735, 0.2846002579, 0.3252801895 }, - { 0.4306297302, 0.2182903290, -0.4902458191, 0.1783485413, - 0.7783365250, 0.7152252197, 0.7404451370, 0.6012639999, - 0.5421304703, 0.6619558334, 0.6316919327, 0.5596818924, - 0.3952398300, 0.3567333221, 0.1505041122, 0.1290159225 } }, - { { 0.3077287674, 0.2543363571, 0.2834520340, 0.5282287598, - 0.5350360870, 0.4943971634, 0.4521999359, 0.3086309433, - 0.2372770309, 0.0819387436, -0.1385612488, -0.0848407745, - -0.0380916595, 0.1192150116, 0.3228197098, 0.3012905121 }, - { 0.0567188263, 0.0196886063, 0.0682420731, 0.2102527618, - 0.2452325821, 0.2060699463, 0.1620273590, 0.0784120560, - 0.0418329239, -0.0508041382, -0.2193880081, -0.1644783020, - -0.1361827850, -0.0307512283, 0.1486587524, 0.2356367111 } }, - { { 0.4387903214, 0.5723943710, 0.6147556305, 0.9973602295, - 1.1645498276, 1.1898927689, 1.0326681137, 0.6939010620, - 0.6064310074, 0.4686441422, 0.4646663666, 0.4895582199, - 0.5654230118, 0.6004848480, 0.6179132462, 0.6439123154 }, - { 0.1324195862, 0.2426080704, 0.3132238388, 0.7359752655, - 0.9749288559, 0.9535636902, 0.8105278015, 0.4118890762, - 0.3013315201, 0.2006158829, 0.2331352234, 0.2535161972, - 0.3375005722, 0.4103307724, 0.4102897644, 0.4529380798 } }, - { { 0.7335557938, 0.9203472137, 0.4852113724, 0.8646993637, - 0.7304391861, 0.7503690720, 0.6289854050, 0.6900463104, - 0.6421079636, 0.5184278488, 0.4444904327, 0.2660236359, - 0.2143125534, 0.2406396866, 0.4836940765, 0.5597229004 }, - { 0.3689947128, 0.4967346191, 0.1176567078, 0.5127687454, - 0.3235168457, 0.3426265717, 0.2417469025, 0.3310623169, - 0.2629890442, 0.2130823135, 0.1329116821, 0.0468769073, - -0.0081968307, 0.0146446228, 0.2440433502, 0.3408632278 } }, - { { 0.9425325394, 0.9597969055, 0.6160678864, 0.7050962448, - 0.8063859940, 0.9063224792, 0.9890356064, 1.0038805008, - 1.0338163376, 0.9453620911, 0.9634056091, 0.8068370819, - 0.6859455109, 0.8909034729, 0.9990415573, 1.0122871399 }, - { 0.6895952225, 0.6451835632, 0.3169965744, 0.4268569946, - 0.5666122437, 0.7722673416, 0.8845882416, 0.9061584473, - 0.9550399780, 0.8118810654, 0.8601064682, 0.6129922867, - 0.5069866180, 0.7065315247, 0.7862920761, 0.7766551971 } }, - { { 0.5641517639, -0.0941905975, 0.0412998199, 0.1810550690, - 0.3459482193, 0.4213209152, 0.4401025772, 0.5397109985, - 0.5607891083, 0.6348905563, 0.6861915588, 0.7280607224, - 0.7267074585, 0.6447324753, 0.5948257446, 0.5475025177 }, - { 0.1906919479, -0.0519113541, -0.0608100891, -0.0018815994, - 0.0383062363, 0.0362558365, 0.0529870987, 0.0692672729, - 0.0953073502, 0.1327886581, 0.1390628815, 0.1904459000, - 0.2362518311, 0.2063980103, 0.2311668396, 0.2291574478 } }, - { { 0.9901428223, 0.9589767456, 0.9012374878, 0.8017930984, - 0.8929538727, 0.8512077332, 0.8790111542, 0.8832759857, - 0.8949632645, 0.9159183502, 0.9293279648, 0.9152622223, - 0.9247350693, 0.8753614426, 0.8730239868, 0.8066730499 }, - { 0.4230432510, -0.0464572906, 0.0182533264, 0.1159753799, - 0.2349395752, 0.2740612030, 0.2987070084, 0.3620643616, - 0.3923282623, 0.4694643021, 0.5202322006, 0.5356512070, - 0.5564012527, 0.5362663269, 0.4791831970, 0.5046901703 } }, - { { 0.9785375595, 0.8820457458, 0.3965110779, 0.4790191650, - 0.3907699585, 0.4195575714, 0.2938270569, 0.4091415405, - 0.3659191132, 0.4030723572, 0.4168510437, 0.5030908585, - 0.5023117065, 0.5511522293, 0.5354051590, 0.5563192368 }, - { 0.6592903137, 0.2933759689, 0.0562677383, 0.1286878586, - 0.0758285522, 0.1192560196, 0.0508956909, 0.1175336838, - 0.0684061050, 0.0988750458, 0.0923957825, 0.1819572449, - 0.1965150833, 0.2257537842, 0.3049812317, 0.2993221283 } }, - { { 0.7120265961, 0.7847747803, 0.6065950394, 0.7235908508, - 0.6740531921, 0.6535081863, 0.3734235764, 0.4788551331, - 0.4410867691, 0.6927528381, 1.0758495331, 1.1148891449, - 1.0708875656, 0.8896322250, 0.6401805878, 0.5057153702 }, - { 0.4210338593, 0.4763126373, 0.3229017258, 0.4079113007, - 0.3922462463, 0.3529195786, 0.1258993149, 0.2168960571, - 0.2207508087, 0.4605655670, 0.8759355545, 0.9526205063, - 0.8843832016, 0.7001342773, 0.4503545761, 0.3484086990 } }, - { { 0.5254402161, 0.5349540710, 0.7036199570, 0.6240234375, - 0.6464548111, 0.7537727356, 0.8311548233, 0.7334327698, - 0.3484907150, 0.1846637726, 0.0894021988, 0.3977823257, - 0.7672233582, 0.9224796295, 0.8818407059, 0.7453250885 }, - { 0.2587652206, 0.2524499893, 0.4135704041, 0.3129367828, - 0.3403711319, 0.4473199844, 0.5330266953, 0.4227561951, - 0.1080198288, -0.0044651031, -0.0727024078, 0.1583776474, - 0.5302381516, 0.7313823700, 0.6735610962, 0.5630855560 } }, - { { 0.7936325073, 0.8551034927, 0.9755849838, 0.8953323364, - 0.9345769882, 0.7202281952, 0.8388233185, 0.7941656113, - 0.7550849915, 0.7894906998, 0.8590402603, 0.7813711166, - 0.8483371735, 0.8652324677, 0.8586711884, 0.9584846497 }, - { 0.4781579971, 0.4731960297, 0.8289403915, 0.6175031662, - 0.7262973785, 0.3638277054, 0.5544328690, 0.4761896133, - 0.4388723373, 0.5021476746, 0.5630445480, 0.4562187195, - 0.5190429688, 0.5937595367, 0.6121721268, 0.6973457336 } }, - { { 1.0724458694, 1.0449705124, 0.8594503403, 0.7604160309, - 0.7837905884, 0.8136444092, 0.7623023987, 0.6098756790, - 0.6432561874, 0.6395244598, 0.6853713989, 0.7401580811, - 0.7399530411, 0.7652549744, 0.7675104141, 0.7393789291 }, - { 0.9382266998, 0.8419809341, 0.3087539673, 0.3620233536, - 0.3547649384, 0.4241094589, 0.2857894897, 0.2123851776, - 0.2355957031, 0.2794332504, 0.3219995499, 0.3898267746, - 0.3937635422, 0.4058198929, 0.4228382111, 0.4181222916 } }, - { { 1.0275421143, 1.0940570831, 1.0164289474, 0.9097671509, - 0.9400720596, 0.8976287842, 0.9175586700, 0.8900833130, - 0.9154262543, 0.9492578506, 1.0011329651, 1.0361537933, - 1.0359487534, 0.9320344925, 0.8974237442, 0.8811845779 }, - { 1.0046186447, 1.0860195160, 0.9442958832, 0.7473344803, - 0.7876043320, 0.7410602570, 0.7422084808, 0.6844692230, - 0.7256412506, 0.8455486298, 0.8969316483, 0.9362173080, - 0.9092340469, 0.8227071762, 0.7481546402, 0.7088689804 } }, - { { 0.2205047607, -0.0129537582, 0.0972347260, 0.1154832840, - 0.0951843262, 0.1532516479, 0.1288108826, 0.1749858856, - 0.1591157913, 0.2134923935, 0.2477340698, 0.2634811401, - 0.3032999039, 0.3272485733, 0.3170785904, 0.3172016144 }, - { 0.0032854080, -0.0446119308, 0.0284643173, 0.0155467987, - -0.0063104630, 0.0226001740, 0.0086984634, 0.0262088776, - 0.0173921585, 0.0360507965, 0.0366659164, 0.0215339661, - 0.0412178040, 0.1047391891, 0.1258172989, 0.0609836578 } }, - { { 0.1495609283, 0.3275766373, 0.8598194122, 0.6847562790, - 0.7550849915, 0.5662431717, 0.6930398941, 0.7526245117, - 0.7300291061, 0.7284708023, 0.6608896255, 0.5224056244, - 0.4273900986, 0.5757160187, 0.4625749588, 0.5123586655 }, - { -0.0352210999, -0.0428895950, 0.3110914230, 0.2699604034, - 0.3307752609, 0.2059469223, 0.2332172394, 0.3204412460, - 0.2846412659, 0.3354911804, 0.2448635101, 0.1514062881, - 0.1062564850, 0.2613077164, 0.2123441696, 0.3000602722 } }, - { { 0.6218910217, 0.6033554077, 0.4551525116, 0.3161764145, - 0.2864866257, 0.6195125580, 0.7577505112, 1.0062179565, - 0.8485012054, 0.6777849197, 0.7455301285, 0.3630485535, - 0.2327661514, 0.5563192368, 0.4448595047, 0.3806819916 }, - { 0.2624969482, 0.2679510117, 0.1839666367, 0.0335903168, - 0.0294075012, 0.2902593613, 0.4959144592, 0.7905979156, - 0.5748548508, 0.3753919601, 0.4855394363, 0.1089630127, - 0.0362968445, 0.3632535934, 0.2681150436, 0.2735691071 } }, - { { 0.7064495087, 0.4431781769, 0.7628355026, 0.7271585464, - 0.7812070847, 0.7806739807, 0.8909854889, 0.8958654404, - 0.9126787186, 0.9038209915, 0.9246120453, 0.9624624252, - 0.9732475281, 0.7420034409, 0.5060844421, 0.5189199448 }, - { 0.3457021713, -0.0149221420, 0.3174476624, 0.3580865860, - 0.4243965149, 0.4275541306, 0.5887155533, 0.6478490829, - 0.6320610046, 0.6627349854, 0.6868886948, 0.7396659851, - 0.7551259995, 0.5275316238, 0.3075237274, 0.3806819916 } }, - { { 0.4376831055, 0.4904603958, 0.6262788773, 0.5901098251, - 0.4176712036, 0.0221490860, -0.1612796783, -0.2236118317, - -0.1087894440, -0.0022506714, 0.1051902771, 0.3307752609, - 0.4167690277, 0.4997692108, 0.4645843506, 0.5228567123 }, - { 0.1228237152, 0.1671123505, 0.2931299210, 0.2549924850, - 0.1435737610, -0.1124801636, -0.2181987762, -0.2723293304, - -0.1573429108, -0.0837745667, -0.0325555801, 0.1024427414, - 0.1938495636, 0.2825498581, 0.2247285843, 0.2879629135 } }, - { { 0.6100807190, 0.7900238037, 0.9581155777, 0.8999662399, - 0.9277286530, 0.9720993042, 0.9966220856, 0.9630365372, - 0.9571723938, 0.8992280960, 0.8370189667, 0.7417984009, - 0.7174396515, 0.6122951508, 0.6746683121, 0.7030458450 }, - { 0.0859165192, 0.0914115906, 0.6077432632, 0.5471334457, - 0.5943746567, 0.6805324554, 0.6680250168, 0.6033554077, - 0.6302976608, 0.4874258041, 0.3647298813, 0.2770137787, - 0.2544183731, 0.2608156204, 0.3331537247, 0.4950942993 } }, - { { 0.4051227570, 1.1022176743, 0.8262338638, 0.6573219299, - 0.5948667526, 0.5426225662, 0.4987850189, 0.4370269775, - 0.4421119690, 0.3837165833, 0.3728494644, 0.3706760406, - 0.4169740677, 0.3559951782, 0.2994041443, 0.3896217346 }, - { 0.0716867447, 0.9253911972, 0.2780799866, 0.2460117340, - 0.1675224304, 0.1527595520, 0.1278266907, 0.1226596832, - 0.1165084839, 0.0982189178, 0.0952253342, 0.1113414764, - 0.1498889923, 0.0940361023, 0.0802984238, 0.1560811996 } }, - { { 0.7024717331, 0.7363853455, 0.9629545212, 0.9635286331, - 1.0819597244, 1.1529855728, 1.2984409332, 1.2693252563, - 1.2848672867, 1.2877378464, 1.2133083344, 1.0696573257, - 1.0864706039, 0.9851808548, 0.8312368393, 0.8047866821 }, - { 0.3001422882, 0.2273120880, 0.6279602051, 0.6936140060, - 0.8097076416, 0.9440498352, 1.1028738022, 1.1766471863, - 1.1199741364, 1.1608181000, 1.0665817261, 0.8872537613, - 0.9082908630, 0.7602519989, 0.6542053223, 0.7317514420 } }, - { { 0.0643463135, -0.6808919907, 0.2889881134, 0.6142225266, - 0.6356697083, 0.6825828552, 0.6259508133, 0.4945611954, - 0.5866651535, 0.6357517242, 0.5208883286, 0.4207878113, - 0.5125637054, 0.3758020401, 0.5424175262, 0.6172571182 }, - { -0.0636806488, -0.7585611343, 0.0850553513, 0.2996912003, - 0.3620643616, 0.4444084167, 0.4597454071, 0.3120756149, - 0.4016780853, 0.5026807785, 0.4111919403, 0.3183498383, - 0.3666572571, 0.1829824448, 0.3269205093, 0.4095926285 } }, - { { 0.9277286530, 0.9651279449, 0.9602069855, 0.9327726364, - 0.9208393097, 0.8868436813, 0.9011554718, 0.8569488525, - 0.9015245438, 0.8969726562, 0.9367094040, 0.9445009232, - 0.8617057800, 0.8215589523, 0.8333692551, 0.7939195633 }, - { 0.1719102859, 0.1142530441, 0.1245460510, 0.1646108627, - 0.1408672333, 0.0949792862, 0.0271930695, 0.0265779495, - -0.0064334869, -0.0109033585, 0.0152187347, 0.0252656937, - 0.0166950226, 0.0736141205, 0.1205682755, 0.1895437241 } }, - { { 0.5964250565, 0.6065130234, 0.7228116989, 0.7348270416, - 0.0718097687, 0.2369899750, 0.2456426620, 0.4961194992, - 0.6410417557, 0.6765956879, 0.6771287918, 0.7285938263, - 0.6706905365, 0.5105543137, 0.5068635941, 0.5430326462 }, - { 0.2782440186, 0.2620048523, 0.4424400330, 0.4124631882, - -0.1158838272, 0.0186223984, 0.0059919357, 0.1853609085, - 0.3568563461, 0.3791646957, 0.4100847244, 0.4654865265, - 0.4614677429, 0.3209743500, 0.3199081421, 0.3836755753 } }, - { { 0.8051557541, 0.8506336212, 0.9544658661, 0.5584516525, - 0.5874032974, 0.5727224350, 0.6177902222, 0.7659521103, - 0.9526205063, 1.0424280167, 1.0705595016, 1.0042905807, - 0.6005258560, 0.3886785507, 0.4739751816, 0.6542463303 }, - { 0.4775428772, 0.5541868210, 0.7128057480, 0.2146816254, - 0.2502765656, 0.2488822937, 0.3009214401, 0.4667987823, - 0.6929988861, 0.8599834442, 0.8784780502, 0.7463912964, - 0.3217535019, 0.1274986267, 0.2767267227, 0.5119485855 } }, - { { 0.5978193283, 0.5092830658, 1.0738401413, 0.7688636780, - 0.8214769363, 0.7682075500, 0.4970626831, 0.2783260345, - 0.2652854919, 0.3625154495, 0.5700569153, 0.5044031143, - 0.4003248215, 0.5162544250, 0.5727634430, 0.5538587570 }, - { 0.2752094269, 0.1747808456, 0.8557186127, 0.4280872345, - 0.5143680573, 0.4139804840, 0.1810960770, 0.0109539032, - 0.0317039490, 0.0842351913, 0.3129367828, 0.2614717484, - 0.1564092636, 0.2352676392, 0.3249931335, 0.3505821228 } }, - { { 0.7093610764, 0.7587757111, 1.8517618179, 1.0092525482, - 0.8078622818, 0.8792982101, 0.8210668564, 0.8600654602, - 0.6913585663, 0.6436662674, 0.6216859818, 0.6123771667, - 0.5940465927, 0.5910940170, 0.6505966187, 0.5801038742 }, - { 0.3370904922, 0.4681930542, 1.9236078262, 0.8053607941, - 0.5321245193, 0.6342344284, 0.5054693222, 0.5788326263, - 0.4400615692, 0.4086904526, 0.3924102783, 0.4220180511, - 0.3835115433, 0.4230432510, 0.5190839767, 0.3990535736 } }, - { { 0.6277141571, 1.1122236252, 1.0259838104, 0.9486427307, - 0.9184608459, 0.9059944153, 0.9080038071, 0.8282022476, - 0.8440313339, 0.7887935638, 0.7468013763, 0.6746683121, - 0.6319379807, 0.6246795654, 0.7263793945, 0.7349090576 }, - { 0.2427721024, 1.0851583481, 0.6180362701, 0.5837125778, - 0.4324750900, 0.4684801102, 0.3745307922, 0.3027257919, - 0.3646888733, 0.2409267426, 0.2158298492, 0.2052907944, - 0.2100887299, 0.2276401520, 0.3409452438, 0.4045896530 } }, - { { 0.8391513824, 0.8713426590, 1.1366233826, 1.1440868378, - 1.1443738937, 1.0877418518, 1.0516138077, 1.0099496841, - 0.9216184616, 0.8990640640, 0.9001302719, 0.8993101120, - 0.8055248260, 0.8150796890, 0.7272815704, 0.7196130753 }, - { 0.4634771347, 0.5807189941, 1.1287908554, 1.1066875458, - 1.0765056610, 0.9287538528, 0.8956193924, 0.8026132584, - 0.6725769043, 0.5856809616, 0.5527515411, 0.5183868408, - 0.4529380798, 0.5074377060, 0.4632720947, 0.5554990768 } }, -}; - -static const float wmavoice_lsp16_intercoeff_b[32][2][16] = { - { { 0.5431776047, -0.1212130189, -0.2471650839, 0.0683670044, - 0.1418520808, 0.2518971562, 0.3708084226, 0.4141484499, - 0.5712364912, 0.5852659345, 0.5670641661, 0.6401320100, - 0.6447737217, 0.6726239920, 0.4994724989, 0.5574678183 }, - { 0.2040718794, -0.1271064281, -0.2266163826, -0.0406349897, - -0.0145058036, 0.0283126831, 0.0851084590, 0.0913147926, - 0.1307432652, 0.1926501393, 0.2310355306, 0.2828245163, - 0.3171940446, 0.4424681067, 0.2960716486, 0.3510941863 } }, - { { 0.8073900938, 0.0403081179, 0.5392660499, 0.6928597689, - 0.6499369740, 0.7328097820, 0.7755761147, 0.7766191959, - 0.8820225596, 0.8423333168, 0.8898978233, 0.8488525748, - 0.8654375672, 0.6728326082, 0.6169234514, 0.6755967736 }, - { 0.3653843999, -0.0846008658, -0.0224332213, 0.1120721102, - 0.1020585299, 0.1741876006, 0.2129902244, 0.2160151601, - 0.3619422317, 0.4185815454, 0.5455245376, 0.5363975763, - 0.5429168344, 0.3505726457, 0.3296067119, 0.3620986938 } }, - { { 0.1843576431, 0.0179861784, 0.3122915626, 0.3600125313, - 0.2466817498, 0.2172668576, 0.1975526214, 0.1177569032, - 0.1196866035, 0.0849519968, 0.0962694287, 0.1591672301, - 0.2300446033, 0.3082756996, 0.4047607183, 0.3925045133 }, - { -0.0275964737, -0.0794897676, 0.1168181300, 0.1591150761, - 0.0915755630, 0.0460972190, 0.0562151074, 0.0084419847, - -0.0095511675, -0.0408957601, -0.0376100540, -0.0166962743, - 0.0656028390, 0.1226072311, 0.2293144464, 0.2142419219 } }, - { { 0.4781936407, -1.2478972673, 0.4884679914, 0.7755239606, - 0.6785174012, 0.6590117812, 0.6177057624, 0.6427918673, - 0.5402048230, 0.5512614846, 0.6424267888, 0.4229103327, - 0.5106334686, 0.5136062503, 0.4490395188, 0.4753251672 }, - { 0.2852236032, -1.3815159798, 0.1904075146, 0.4874770641, - 0.4593138695, 0.4182686210, 0.4174863100, 0.4604612589, - 0.4089330435, 0.3891666532, 0.4700576067, 0.2383370996, - 0.2801646590, 0.3398289084, 0.2766703367, 0.3374298215 } }, - { { 0.5925153494, 0.3858809471, 1.0754098296, 0.5752002001, - 0.5516265631, 0.4853909016, 0.4719351530, 0.5018194318, - 0.3037382960, 0.5154316425, 0.8809794784, 0.7755761147, - 0.5941321254, 0.3974069953, 0.5925675035, 0.6097261906 }, - { 0.3008176684, 0.0706617832, 0.8484353423, 0.2574254870, - 0.2815728188, 0.1930673718, 0.2523665428, 0.2691601515, - 0.1271967888, 0.2653007507, 0.6473292708, 0.5275835395, - 0.3928174376, 0.2405275702, 0.4008491635, 0.4556109309 } }, - { { 0.7339050174, 0.4290645123, 0.6859754324, 0.6349166036, - 0.8034263849, 0.8509387374, 0.8591269255, 1.1049811840, - 1.3928194642, 1.3423343301, 1.0849018693, 0.8943830729, - 0.8579795361, 0.6920774579, 0.5613272190, 0.4303162098 }, - { 0.4534726143, 0.0901674032, 0.3465046287, 0.3470261693, - 0.5217422843, 0.5874564052, 0.6014336944, 0.9161834717, - 1.2823571563, 1.2193550467, 0.8868207335, 0.6514494419, - 0.6249030232, 0.4453887343, 0.3665317893, 0.2242033482 } }, - { { 0.4293252826, 0.3303368688, 0.6181751490, 0.9884168506, - 0.9915460944, 0.7939864993, 0.3019129038, 0.2443348169, - 0.4543070793, 0.5617444515, 0.4895110726, 0.6600027084, - 0.6290231943, 0.5580936670, 0.5459417701, 0.4647378922 }, - { 0.1409133077, -0.0050137639, 0.2551307082, 0.6764833927, - 0.7112701535, 0.4648943543, 0.0301380754, -0.0235806108, - 0.1018499136, 0.2422486544, 0.2406318784, 0.4000146985, - 0.3713299632, 0.3259559274, 0.3820737004, 0.2888743877 } }, - { { 0.7733334899, 0.8321111202, 1.3098945022, 1.0331128836, - 1.0380675197, 0.9479974508, 0.9740223289, 0.9442945123, - 0.8926619887, 0.8719046712, 0.8640815616, 0.8404036164, - 0.8359183669, 0.7675965428, 0.6895219088, 0.7266034484 }, - { 0.3655408621, 0.4643206596, 1.2171645761, 0.8341451287, - 0.8387868404, 0.6713201404, 0.6814901829, 0.6294404268, - 0.5172048807, 0.5205948949, 0.5408828259, 0.5298783183, - 0.5781729817, 0.5000983477, 0.4727174640, 0.4326109886 } }, - { { 0.8902629018, 0.4598354101, 0.6392975450, 0.4483093619, - 0.6220867038, 0.6323089004, 0.7063676715, 0.3717993498, - 0.6718416810, 0.7876758575, 0.2807383537, 0.3118221760, - 0.6703813672, 0.7662405372, 0.7122610807, 0.7851724625 }, - { 0.6301705837, 0.1221378446, 0.3532846570, 0.1412783861, - 0.3471826315, 0.3435318470, 0.4466925859, 0.1390357614, - 0.4092981219, 0.5406742096, 0.0690450072, 0.0829179883, - 0.4625995755, 0.5700891018, 0.5542864203, 0.6545265317 } }, - { { -0.1100520492, 0.3803526163, 0.8075987101, 0.6903563738, - 0.8012359142, 0.7835035324, 0.8195941448, 0.8381088376, - 0.8033220768, 0.7511680126, 0.6393496990, 0.6096218824, - 0.6934856176, 0.6690253615, 0.6401841640, 0.5600233674 }, - { -0.1776958704, -0.0293175578, 0.1520742774, 0.1746048331, - 0.2222214937, 0.3052507639, 0.2977927327, 0.3797789216, - 0.3395681381, 0.2976884246, 0.2516885400, 0.2403711081, - 0.3567789793, 0.3302847147, 0.3368039727, 0.3310148716 } }, - { { 0.5587195158, 0.4676063657, 0.1392965317, -0.0990996957, - -0.0816280842, -0.1146416068, -0.0116894841, 0.0521992445, - 0.1626615524, 0.2923687100, 0.4029874802, 0.4528989196, - 0.4694839120, 0.5058352947, 0.5369191170, 0.5105291605 }, - { 0.2193530202, 0.1211469173, 0.0179861784, -0.2022604346, - -0.1409794092, -0.2121175528, -0.1152674556, -0.0594626069, - -0.0122110248, 0.0274260640, 0.1414870024, 0.2044369578, - 0.2167974710, 0.2615978122, 0.3348221183, 0.3707562685 } }, - { { 0.5948622823, 0.7065241337, 0.9414781928, 0.9340723157, - 0.8835350275, 0.9730835557, 0.8503650427, 0.8902629018, - 0.8746688366, 0.6910865307, 0.6404449344, 0.6976057887, - 0.5916287303, 0.6022160053, 0.7729684114, 0.6096740365 }, - { 0.1262058616, 0.1300652623, 0.6594290137, 0.6535877585, - 0.5639349222, 0.6982316375, 0.4828875065, 0.5577285886, - 0.4591052532, 0.2964367270, 0.2695252299, 0.3324751854, - 0.2860580683, 0.2902825475, 0.4623388052, 0.3369604349 } }, - { { 0.8821268678, 0.8539636731, 0.2898653150, 0.7478301525, - 0.5109463930, 0.8577187657, 0.4884679914, 0.7846509218, - 0.7684310079, 0.7032384276, 0.6691296697, 0.8593355417, - 0.9383489490, 0.9808023572, 0.6804992557, 0.6403927803 }, - { 0.5590324402, 0.4209806323, 0.0259135962, 0.4318808317, - 0.2104346752, 0.5453680754, 0.1783599257, 0.4467447400, - 0.4352708459, 0.4089330435, 0.3994410038, 0.5984609127, - 0.6872792840, 0.7321317792, 0.4408513308, 0.4542027712 } }, - { { 0.6371070743, 0.6311093569, 0.7152860165, 0.6929640770, - 0.2292101383, 0.3234525323, 0.9644259810, 0.9881039262, - 0.8722697496, 0.4370440841, 0.4051779509, 0.4944135547, - 0.5392660499, 0.5969484448, 0.4268740416, 0.4990552664 }, - { 0.4233797193, 0.3647063971, 0.4345406890, 0.4180078506, - -0.0006328225, 0.0586141944, 0.7620160580, 0.8152132034, - 0.6707985997, 0.2095480561, 0.2178405523, 0.2776612639, - 0.3142212629, 0.3808741570, 0.2676998377, 0.2804775834 } }, - { { 0.4509170651, 0.9490405321, 0.8557890654, 0.8271043301, - 0.6915559173, 0.7321839333, 0.6257896423, 0.6274064183, - 0.5238284469, 0.5194996595, 0.4116972089, 0.3382642865, - 0.3755022883, 0.4867990613, 0.5686287880, 0.5106856227 }, - { 0.0989292860, 0.6244857907, 0.4700576067, 0.3905226588, - 0.2630059719, 0.3009741306, 0.2150763869, 0.2067838907, - 0.1533781290, 0.1815934777, 0.1023714542, 0.0373874903, - 0.0897501707, 0.1849313378, 0.2852757573, 0.2625887394 } }, - { { 0.9954054952, 0.9554033279, 0.8237664700, 0.9780903459, - 0.7261862159, 0.7884581685, 0.7933084965, 0.7393290401, - 0.8783196211, 1.0409359932, 1.0217954516, 0.9159227014, - 0.8698185086, 0.7057939768, 0.7662926912, 0.7339571714 }, - { 0.7913266420, 0.6739278436, 0.5061482191, 0.7058982849, - 0.3480692506, 0.4338105321, 0.4428853393, 0.3758152127, - 0.5962182879, 0.7925261855, 0.7968549728, 0.6629754901, - 0.6325175166, 0.4598354101, 0.5310778618, 0.5518873334 } }, - { { 0.4638512731, 0.0604917407, 0.1897295117, 0.3403504491, - 0.4708399177, 0.5241413713, 0.6061275601, 0.6446694136, - 0.7313494682, 0.7208143473, 0.6268848777, 0.6081094146, - 0.4913364649, 0.3529717326, 0.4954566360, 0.5767126679 }, - { 0.1353849769, -0.0274400115, 0.0002537966, 0.0272174478, - 0.0555371046, 0.0652899146, 0.1010676026, 0.1073260903, - 0.1568724513, 0.2207611799, 0.1434167027, 0.2262373567, - 0.1177047491, 0.0162650943, 0.2529402375, 0.4087765813 } }, - { { 0.9700064659, 0.9917025566, 0.9159227014, 0.9309430718, - 0.8991290927, 0.9314124584, 0.9059612751, 0.9473194480, - 0.9604622722, 0.9377752542, 0.9197821021, 0.8869771957, - 0.8506779671, 0.8594920039, 0.8320589662, 0.8739908338 }, - { 0.2892394662, 0.0551198721, 0.0892807841, 0.1158793569, - 0.0905846357, 0.0738953352, 0.0395258069, 0.0240360498, - 0.0477139950, 0.0751470327, 0.1171310544, 0.1555164456, - 0.1384620667, 0.1818542480, 0.2104868293, 0.1288135648 } }, - { { 0.4101847410, 0.3326316476, 0.4666675925, 0.5077128410, - 0.5892296433, 0.4272912741, 0.0603352785, -0.8668596745, - -1.1103670001, -0.0900248885, 0.1626615524, 0.1487885714, - 0.4130010605, 0.5119373202, 0.5820323825, 0.5486016273 }, - { 0.0383262634, 0.1300652623, 0.2295230627, 0.2706204653, - 0.3722165823, 0.1698066592, -0.0934670568, -0.8677462935, - -1.0724509954, -0.2164463401, -0.0056917667, -0.0301520228, - 0.1299088001, 0.2579991817, 0.3482257128, 0.2469425201 } }, - { { 0.6031547785, 0.5515222549, 0.4292209744, 0.5027582049, - 0.8167778254, 1.0925685167, 0.9878953099, 0.7019345760, - 0.2509583831, 0.2475162148, 0.5660732388, 0.5145971775, - 0.4824181199, 0.5970005989, 0.5996604562, 0.5384315848 }, - { 0.3677313328, 0.2650399804, 0.1585935354, 0.2213348746, - 0.5566333532, 0.8425940871, 0.7604514360, 0.4523773789, - 0.0681062341, 0.0737388730, 0.3169854283, 0.2868403792, - 0.2661873698, 0.3635068536, 0.4300554395, 0.3743027449 } }, - { { 0.5017672777, 0.6634970307, 0.6869142056, 0.7066284418, - 0.5669598579, 0.0621085167, 0.0634645224, 0.2321307659, - 0.8322675824, 0.9855483770, 0.8296598792, 0.6140028238, - 0.5462546945, 0.6730412245, 0.6856103539, 0.5975221395 }, - { 0.2680649161, 0.3324230313, 0.3688787222, 0.3886451125, - 0.2774004936, -0.1695076823, -0.1353467703, 0.0159000158, - 0.5895425677, 0.7586781979, 0.5639870763, 0.3687744141, - 0.3401418328, 0.4477356672, 0.4782979488, 0.4034568667 } }, - { { 0.8838479519, 0.9025712609, 0.7326533198, 0.8124490380, - 0.8956347704, 1.1007045507, 1.2731780410, 1.2029786706, - 1.0839109421, 0.9664078355, 0.7356782556, 0.6942157745, - 0.6917645335, 0.6383587718, 0.6503020525, 0.5989302993 }, - { 0.5576764345, 0.4596789479, 0.3790487647, 0.5514179468, - 0.7333834767, 0.9612445831, 1.1976589561, 1.1094664335, - 0.8868207335, 0.6789346337, 0.4643206596, 0.4029353261, - 0.4384522438, 0.3871847987, 0.4326109886, 0.3691916466 } }, - { { 0.8520861268, 0.8413423896, 0.7238392830, 0.9103943706, - 0.7072542906, 0.6479029655, 0.4557673931, 0.1908247471, - -0.0569070578, -0.1013423204, 0.2517406940, 0.4854952097, - 0.5820845366, 0.5886037946, 0.6177579165, 0.6226603985 }, - { 0.6160889864, 0.4592095613, 0.4752208591, 0.6685559750, - 0.4326109886, 0.4077335000, 0.2314006090, 0.0173603296, - -0.2208272815, -0.3014574647, 0.0321199298, 0.2559130192, - 0.3603254557, 0.3466089368, 0.4072119594, 0.4776199460 } }, - { { 0.7083495259, 0.9001721740, 0.6795083284, 1.2743254304, - 1.3672639728, 1.2563322783, 0.8557369113, 0.8287732601, - 0.7942472696, 0.8006622195, 0.7034991980, 0.5479236245, - 0.6391932368, 0.6248508692, 0.5495925546, 0.4719351530 }, - { 0.4000146985, 0.6493632793, 0.4583229423, 1.1484255195, - 1.2521599531, 1.1232351065, 0.6150459051, 0.5347808003, - 0.4726653099, 0.5269576907, 0.4278128147, 0.2745841742, - 0.3868718743, 0.4183729291, 0.3474434018, 0.3150035739 } }, - { { 0.9070043564, 0.7648323774, 0.4281778932, 0.5475063920, - 0.4134704471, 0.4706834555, 0.4549329281, 0.4648422003, - 0.4572798610, 0.4823138118, 0.4666154385, 0.4841913581, - 0.4018922448, 0.4297946692, 0.4646857381, 0.6091003418 }, - { 0.4925360084, 0.2065231204, 0.0948612690, 0.1716842055, - 0.0992422104, 0.1332988143, 0.1255800128, 0.1257364750, - 0.0955392718, 0.1118634939, 0.1372103691, 0.1525958180, - 0.0902717113, 0.1591672301, 0.2335910797, 0.3767018318 } }, - { { 0.3185500503, 0.8677845001, 0.7776622772, 0.8160476685, - 0.8624126315, 0.8057211637, 0.8852561116, 0.8471314907, - 0.9145145416, 0.8945916891, 0.8638729453, 0.8531292081, - 0.7425104380, 0.6215651631, 0.6501455903, 0.6341864467 }, - { -0.0499705672, 0.0687842369, 0.3051464558, 0.3368039727, - 0.4942049384, 0.3823344707, 0.5683158636, 0.5044271350, - 0.6278236508, 0.5777035952, 0.5745221972, 0.5502184033, - 0.4244228005, 0.3163595796, 0.3525545001, 0.3582914472 } }, - { { 0.3200625181, 0.9415303469, 0.6067534089, 0.3568832874, - 0.1600538492, 0.2938811779, 0.2037589550, 0.3017564416, - 0.2572168708, 0.4796018004, 0.6938506961, 0.6847758889, - 0.7232134342, 0.6111343503, 0.5159531832, 0.4856516719 }, - { 0.0680540800, 0.6285016537, 0.2514277697, 0.0790064335, - -0.0687981844, 0.0521992445, -0.0055874586, 0.0537117124, - 0.0188206434, 0.1883213520, 0.4493002892, 0.4300554395, - 0.4750122428, 0.3658016324, 0.3119786382, 0.2818335891 } }, - { { 0.6864969730, 1.0815640092, 0.9838794470, 0.8845259547, - 0.9438772798, 0.8888025880, 0.8178730607, 0.8581881523, - 0.7128347754, 0.7120524645, 0.7345308661, 0.7945601940, - 0.7854853868, 0.8261655569, 0.6941114664, 0.6646444201 }, - { 0.2847542167, 0.9535257816, 0.6691818237, 0.5026538968, - 0.5945493579, 0.4125838280, 0.3886451125, 0.3740941286, - 0.2453778982, 0.2928902507, 0.3219922185, 0.4065861106, - 0.3838469386, 0.4289602041, 0.3910441995, 0.3821780086 } }, - { { 1.1335094571, 1.0390062928, 0.7019867301, 0.6203134656, - 0.6951545477, 0.4863818288, 0.6171320677, 0.6247465611, - 0.5907421112, 0.6711115241, 0.7322882414, 0.7042293549, - 0.5635698438, 0.6174449921, 0.6727283001, 0.6431047916 }, - { 1.0146503448, 0.7762541175, 0.2200310230, 0.2459515929, - 0.2703596950, 0.1376276016, 0.2522100806, 0.2622758150, - 0.2389107943, 0.2956544161, 0.3799875379, 0.3653843999, - 0.2561216354, 0.2842326760, 0.4034568667, 0.3700782657 } }, - { { 0.6342907548, 0.9627570510, 0.5214815140, -0.0226939917, - 0.5616401434, 0.7231091261, 0.7417802811, 0.9092991352, - 0.9739701748, 0.7804785967, 0.6771092415, 0.6352295280, - 0.4660417438, 0.5869870186, 0.6692339778, 0.5986173749 }, - { 0.3988673091, 0.6997441053, 0.2316613793, -0.2566571236, - 0.2685343027, 0.4484136701, 0.4490395188, 0.6886874437, - 0.7703085542, 0.5847443938, 0.4539941549, 0.4098196626, - 0.2579991817, 0.3376384377, 0.4754816294, 0.5095382333 } }, - { { 0.4443456531, 2.0296727419, 0.6569256186, 0.6439914107, - 0.6436263323, 0.5507399440, 0.6095175743, 0.6066491008, - 0.5347808003, 0.2529402375, 0.4443978071, 0.7000570297, - 0.8259569407, 0.5927761197, 0.5078171492, 0.4418422580 }, - { 0.2430831194, 1.9133691788, 0.3723730445, 0.3764410615, - 0.3874977231, 0.3212099075, 0.3832210898, 0.4474227428, - 0.3644977808, 0.0814055204, 0.2752621770, 0.4647378922, - 0.6619845629, 0.4304205179, 0.3143777251, 0.2705683112 } }, - { { 0.9740744829, 1.0730628967, 0.9743352532, 0.9098728299, - 0.9453375936, 0.9661470652, 0.9270836711, 0.9643738270, - 0.9989519715, 0.9627048969, 0.9348546267, 0.9865393043, - 0.9399657249, 0.9752218723, 0.8440544009, 0.8819182515 }, - { 0.9258319736, 1.0357205868, 0.8463491797, 0.8108844161, - 0.8391519189, 0.8566235304, 0.8305986524, 0.8880724311, - 0.9181653261, 0.8670021892, 0.8305986524, 0.8995984793, - 0.8300249577, 0.8711223602, 0.7195626497, 0.8138571978 } }, -}; - -static const double wmavoice_mean_lsf10[2][10] = { - { 0.2235394066, 0.4097484909, 0.7025292732, 1.1077160169, - 1.3939179044, 1.6741291716, 1.9552949226, 2.2199793918, - 2.5103400247, 2.7829212906 }, - { 0.1493683393, 0.3714357373, 0.7702730245, 1.0609411394, - 1.3270362536, 1.5806033119, 1.8398507524, 2.1116740248, - 2.3823505771, 2.6865718527 } -}; - -static const double wmavoice_mean_lsf16[2][16] = { - { 0.0999206754, 0.2345933590, 0.4621011210, 0.6772546160, - 0.8346396060, 1.0067495130, 1.1571691668, 1.3292508688, - 1.4941465650, 1.6600755584, 1.8461284908, 2.0529487333, - 2.2690810112, 2.4949894820, 2.7172752965, 2.9164840903 }, - { 0.0918298402, 0.2475621892, 0.4782937721, 0.6284774045, - 0.7861951264, 0.9303736000, 1.0940441024, 1.2521029300, - 1.4434732098, 1.6551410742, 1.8917962963, 2.0967280403, - 2.2981430375, 2.4826173497, 2.6827972461, 2.8811350800 } -}; - -static const float wmavoice_std_codebook[1000] = { - -0.185013, -0.150405, -0.707267, -0.284100, 0.882898, - -0.788627, 0.061005, 0.374431, 0.053843, -0.909826, - 0.543602, 0.219326, 0.285698, 0.154709, -0.455005, - 0.426276, -0.868852, -0.952324, -0.550001, 0.813814, - -0.352815, 0.242122, 0.820495, -0.189574, -0.449538, - 0.499132, -0.247783, 0.598159, 0.732040, -0.564406, - -0.631788, -0.452973, 0.285189, -0.339055, 0.262927, - 0.168087, -0.127682, -0.676067, -0.457481, 0.926161, - -0.585893, -0.913880, 0.145487, 0.699804, 0.240829, - 0.690482, 0.126081, 0.371977, 0.738158, 0.576080, - 0.185791, -0.614657, -0.181799, 0.006285, 0.195768, - 0.368663, -0.494583, 0.947985, -0.033178, -0.762543, - -0.616421, 0.335034, -0.215516, 0.668769, 0.995979, - -0.952588, -0.163144, -0.131704, -0.628655, 0.379374, - -0.205543, -0.214549, 0.465494, 0.939944, -0.514744, - -0.293676, 0.630426, 0.611336, -0.921699, 0.368584, - 0.187416, 0.264092, 0.753927, -0.994382, -0.729623, - -0.050304, 0.374280, -0.224205, -0.102319, -0.658897, - 0.013252, 0.281260, 0.676137, 0.797736, -0.049971, - 0.672115, 0.845148, 0.786885, -0.459588, -0.783507, - 0.166259, 0.334869, 0.001944, -0.368247, 0.274813, - 0.487200, 0.338077, -0.094761, 0.098536, 0.416378, - -0.726176, -0.714048, -0.319530, -0.972249, -0.708430, - -0.049153, -0.022553, 0.665850, 0.726642, 0.875127, - -0.993047, -0.260106, 0.156387, 0.683090, -0.462370, - -0.893584, 0.355205, -0.617222, 0.893301, 0.895617, - -0.400729, 0.059559, 0.230486, 0.601215, 0.691313, - -0.494701, 0.088415, 0.029390, 0.410539, -0.813049, - -0.554232, 0.684362, -0.527097, 0.126238, 0.712113, - -0.235528, -0.922915, -0.310440, -0.569678, 0.803727, - -0.435313, -0.562725, -0.456380, 0.721075, -0.879635, - 0.081250, 0.827491, 0.475570, 0.464029, 0.720792, - 0.371187, -0.936700, -0.219649, -0.398327, 0.664515, - -0.528336, 0.106972, -0.247070, 0.501053, -0.482490, - -0.060119, 0.946821, -0.798127, 0.412784, 0.073058, - 0.913986, -0.822744, 0.150143, -0.396453, -0.392421, - -0.046130, 0.168234, 0.044854, 0.497490, -0.110691, - 0.165219, -0.421259, -0.283200, -0.359212, -0.957231, - -0.562409, -0.988025, -0.893931, 0.217942, -0.386352, - 0.770585, 0.689606, 0.720620, -0.476485, 0.190659, - -0.761870, 0.463395, 0.137480, -0.559997, -0.123821, - -0.789461, -0.646011, 0.053435, 0.360682, -0.042464, - 0.661014, -0.685448, -0.874230, -0.294133, 0.812042, - 0.015078, 0.871086, -0.609218, 0.731878, -0.488126, - -0.566448, -0.830530, -0.476150, -0.460379, 0.387412, - 0.137497, -0.689794, 0.077018, -0.141883, -0.166280, - -0.732322, 0.096247, -0.702884, 0.405158, 0.536250, - 0.173295, 0.615696, 0.890239, -0.773270, -0.023622, - -0.152226, 0.887744, 0.290930, -0.026456, -0.406389, - 0.102972, 0.988622, -0.535303, 0.493754, 0.720500, - -0.023428, 0.927306, 0.889970, 0.500421, -0.533073, - 0.277382, -0.362081, -0.222867, -0.645599, 0.496035, - 0.610853, -0.377922, -0.407718, 0.907969, -0.972764, - -0.871468, 0.081264, 0.642933, -0.981230, 0.307994, - -0.380689, -0.133456, 0.195738, 0.910241, 0.840088, - 0.789349, 0.013213, 0.828710, -0.745954, -0.493033, - 0.549210, 0.230618, -0.565727, 0.439180, -0.268961, - -0.098800, -0.283438, 0.368958, 0.678333, 0.070963, - -0.135007, 0.289186, 0.693041, 0.457275, 0.197155, - 0.720277, 0.585807, -0.721581, 0.363210, 0.604577, - 0.586413, 0.982521, -0.528878, -0.217849, 0.892762, - -0.688791, -0.428500, -0.094025, -0.860081, -0.174454, - 0.412942, 0.689129, -0.943836, 0.847215, 0.128309, - -0.212797, -0.251585, 0.844871, -0.843839, -0.573252, - -0.084167, 0.021154, 0.715935, -0.391126, -0.521570, - -0.086910, -0.670848, -0.935763, 0.191509, 0.692361, - 0.668814, -0.222078, 0.674882, -0.860064, 0.560073, - 0.567644, -0.548855, -0.868427, -0.526382, -0.408936, - -0.042881, 0.886560, -0.719807, 0.013283, 0.733775, - 0.408502, 0.800487, -0.517810, 0.253372, 0.956648, - -0.091062, -0.830794, -0.022198, -0.375127, -0.221920, - 0.456232, 0.537963, 0.107232, 0.520469, -0.270529, - -0.200406, 0.189284, 0.507393, -0.525524, 0.329220, - 0.067466, -0.957881, 0.780365, 0.199039, -0.484262, - -0.628570, -0.843843, -0.597703, -0.348377, 0.169441, - -0.863928, -0.939875, -0.030073, -0.381738, 0.313497, - -0.073425, 0.527200, 0.482703, 0.904377, -0.847927, - -0.739217, 0.360609, 0.690035, 0.368015, -0.118921, - -0.580493, -0.832391, -0.929638, 0.926900, -0.357915, - 0.399582, -0.005634, -0.315796, 0.179947, -0.806596, - 0.393360, 0.732931, -0.415833, -0.724526, 0.957347, - -0.892887, 0.475366, 0.173583, -0.418554, -0.302536, - 0.627315, 0.782000, 0.497542, 0.139082, 0.570111, - 0.732375, -0.454643, 0.302218, -0.019505, 0.881778, - -0.057606, 0.273041, 0.414170, -0.503501, -0.079602, - -0.083941, 0.007178, -0.171925, 0.506856, 0.520953, - 0.631684, -0.099784, 0.253885, -0.784149, 0.175691, - 0.211231, -0.677036, -0.348943, -0.615186, -0.095591, - 0.348521, -0.987871, -0.313590, -0.153938, 0.151210, - -0.743479, -0.421562, 0.696567, 0.558739, 0.558933, - 0.578346, -0.498867, -0.168026, -0.007485, -0.002368, - 0.752372, 0.908575, -0.995190, -0.419553, 0.415430, - 0.525763, -0.787869, -0.684353, -0.220353, -0.572018, - 0.491337, 0.990879, -0.249054, -0.857606, -0.624307, - 0.655355, 0.490915, -0.612178, -0.658235, -0.663023, - 0.539032, -0.401714, -0.084585, 0.235599, -0.842975, - -0.525653, -0.186055, -0.341841, 0.306321, 0.806460, - 0.655791, 0.058693, 0.715035, 0.660601, 0.639140, - 0.130465, 0.186363, 0.851271, 0.446112, 0.966011, - -0.720746, -0.062551, 0.956890, 0.030200, 0.079843, - -0.667418, -0.314445, -0.429243, -0.279596, 0.027320, - -0.092266, -0.740564, 0.625606, 0.823149, 0.495035, - 0.782632, -0.702504, -0.691020, -0.559209, 0.603818, - -0.884560, -0.903419, -0.337489, 0.830475, 0.757182, - -0.698349, -0.039060, -0.056455, -0.847078, -0.592948, - -0.090444, -0.567824, 0.344501, -0.133554, 0.462375, - -0.575656, 0.199028, -0.852070, -0.004899, 0.919432, - 0.175251, 0.902835, -0.821132, -0.199143, 0.725984, - 0.673903, -0.416511, -0.976519, 0.982883, 0.024279, - 0.627298, -0.901677, 0.120861, -0.710191, 0.928798, - -0.121958, -0.408540, -0.110261, 0.821588, -0.255618, - 0.296790, -0.268856, 0.176557, -0.358709, 0.597589, - -0.361067, 0.065635, -0.203382, -0.213137, -0.939264, - -0.283951, 0.962113, 0.963571, -0.105083, -0.237030, - 0.689556, -0.431180, 0.346459, 0.713037, -0.448297, - -0.629262, 0.340335, -0.349973, 0.491599, 0.630144, - -0.421175, -0.630359, -0.778396, 0.468564, -0.808771, - -0.034014, -0.234646, -0.077627, -0.857457, 0.406645, - -0.480038, -0.218524, -0.527720, 0.316580, 0.568338, - -0.466984, -0.967371, 0.530452, -0.503413, -0.072454, - -0.706578, -0.813857, 0.496366, 0.639881, 0.899179, - -0.951931, -0.989381, 0.239514, -0.301904, 0.502218, - -0.130341, 0.276921, 0.871860, 0.091262, -0.254515, - -0.936911, -0.942752, 0.510839, -0.014539, -0.800209, - -0.082516, 0.505423, -0.018733, 0.389763, -0.177997, - -0.450395, 0.922779, -0.145368, -0.919943, -0.580634, - 0.782178, -0.626521, -0.394491, 0.278545, -0.986640, - -0.495312, 0.326614, -0.976021, 0.744203, -0.975290, - 0.526197, -0.386139, 0.301631, 0.398057, 0.705124, - -0.952884, 0.461146, 0.762372, 0.557954, -0.553393, - 0.962163, -0.524562, 0.952030, -0.056570, 0.865202, - -0.225967, 0.493035, 0.787981, 0.628665, 0.573093, - -0.792653, 0.410844, 0.946571, -0.187144, -0.310612, - 0.959931, 0.317544, -0.983998, 0.983911, 0.061747, - -0.959287, 0.510108, 0.675608, 0.342344, -0.091835, - 0.380731, 0.389460, -0.630689, 0.143103, -0.052586, - -0.184083, 0.105266, 0.422852, -0.232052, -0.951303, - 0.288054, 0.541981, 0.541732, 0.076035, 0.170646, - 0.114825, 0.283382, -0.418510, 0.061396, -0.903763, - 0.270879, 0.021327, 0.413782, 0.286881, 0.005238, - -0.524472, 0.327594, -0.484654, -0.848864, -0.330063, - 0.423511, 0.531868, -0.940603, 0.792822, -0.325029, - 0.006811, -0.391261, 0.780237, -0.570337, 0.376687, - 0.828934, 0.717717, -0.081333, 0.370666, -0.206248, - -0.910686, -0.514510, -0.922867, -0.329196, 0.546886, - -0.826629, 0.941683, -0.431786, 0.587152, 0.228564, - 0.573452, -0.937320, -0.443843, -0.911202, -0.786184, - 0.226094, 0.512309, 0.745684, 0.285491, 0.305131, - -0.579345, -0.707698, 0.913870, -0.799108, -0.278035, - 0.290556, -0.970174, -0.560318, -0.790776, 0.400492, - 0.233434, -0.701462, 0.885982, 0.310567, -0.030658, - 0.432868, 0.483938, -0.088976, -0.998918, 0.071090, - -0.860412, 0.574534, 0.133770, -0.304255, 0.663332, - 0.347586, 0.921839, 0.175641, 0.093270, 0.207330, - -0.519228, 0.513925, 0.499633, -0.605358, 0.714817, - -0.778402, 0.685198, 0.744643, -0.338720, 0.894422, - 0.145135, 0.894714, -0.807041, 0.031117, 0.205281, - 0.162301, -0.536015, -0.310781, -0.926675, -0.534932, - 0.760308, -0.787088, -0.960398, -0.105922, -0.091343, - 0.702934, -0.758336, -0.169504, -0.121425, 0.334935, - -0.962173, 0.359347, -0.151140, 0.537460, 0.753989, - -0.436323, 0.759058, 0.439187, -0.691680, -0.579662, - 0.333608, 0.453454, -0.684948, 0.526567, -0.515429, - 0.520333, -0.311132, -0.051443, -0.790448, -0.237807, - 0.413625, 0.969861, -0.024895, 0.453226, -0.136061, - 0.883762, 0.156160, 0.105603, -0.285741, -0.965264, - -0.559462, -0.247914, 0.394083, 0.289398, -0.710455, - 0.148072, 0.853074, -0.951397, -0.412742, -0.838606, - -0.531059, 0.920866, 0.614848, -0.216007, 0.447434, - -0.900580, -0.695673, -0.863698, 0.047977, -0.486121, - -0.101505, -0.538399, -0.516261, 0.873600, 0.914828, - 0.347678, 0.757362, 0.070988, -0.546718, -0.528380, - 0.105724, -0.106180, 0.223706, -0.500194, -0.816782, - 0.513251, 0.647878, -0.963708, 0.561854, -0.764864, - -0.802314, -0.969205, -0.843997, 0.812534, -0.185212, - 0.603436, 0.911954, 0.119114, 0.739738, -0.040069, - 0.632993, -0.361767, 0.421532, -0.883268, -0.488168, - 0.336360, 0.464411, -0.730806, -0.592652, 0.917693, - -0.259186, 0.513071, -0.188487, 0.964520, -0.987122, - -0.005270, 0.477771, 0.660756, 0.031023, 0.039625, - 0.895892, 0.228709, 0.070419, -0.948105, 0.041243, - 0.885207, 0.655331, -0.046803, 0.004321, 0.395069, - 0.913128, -0.362686, -0.966698, 0.334661, -0.245954, - -0.454865, -0.328980, -0.781543, -0.185671, 0.078368, - -0.863850, 0.555143, -0.408560, -0.052338, 0.519663, - -0.395683, 0.942393, -0.002565, -0.734927, -0.026585, - -0.962941, -0.839035, -0.797876, 0.107479, -0.787140, - 0.243367, -0.007314, 0.868191, -0.803435, 0.997007, - 0.263261, -0.890307, -0.365679, 0.296563, 0.444354, - 0.388367, 0.841698, -0.884626, 0.606824, -0.343973, - 0.193743, 0.742974, -0.788830, 0.785182, -0.309364, - 0.730833, -0.610500, -0.366971, -0.271732, -0.345427, - 0.606444, -0.234673, -0.184462, 0.808568, 0.872806, - 0.028398, 0.051936, -0.134508, -0.103410, 0.248500, - -0.137501, -0.840150, 0.358194, 0.496819, 0.456413, - -0.197453, -0.114814, 0.298111, -0.082078, -0.507990, - 0.954138, -0.888336, -0.765016, -0.834692, 0.896847, - -0.074380, 0.896141, -0.713654, 0.558649, -0.375591, - -0.059081, 0.165093, 0.389736, 0.756458, -0.026339, - 0.262542, -0.215144, -0.974403, -0.871966, 0.681446 -}; - -static const float wmavoice_gain_silence[256] = { - 0.0000188351, 0.0000249147, 0.0000294447, 0.0000365973, - 0.0000423193, 0.0000464916, 0.0000498295, 0.0000525713, - 0.0000550747, 0.0000574589, 0.0000596046, 0.0000615120, - 0.0000634193, 0.0000649691, 0.0000665188, 0.0000679493, - 0.0000692606, 0.0000704527, 0.0000716448, 0.0000728369, - 0.0000737906, 0.0000747442, 0.0000755787, 0.0000762939, - 0.0000770092, 0.0000778437, 0.0000785589, 0.0000792742, - 0.0000799894, 0.0000807047, 0.0000814199, 0.0000822544, - 0.0000829697, 0.0000838041, 0.0000845194, 0.0000854731, - 0.0000865459, 0.0000876188, 0.0000889301, 0.0000904799, - 0.0000923872, 0.0000950098, 0.0000988245, 0.0001032352, - 0.0001088381, 0.0001147985, 0.0001225471, 0.0001319647, - 0.0001431704, 0.0001568794, 0.0001744032, 0.0001952648, - 0.0002206564, 0.0002535582, 0.0002965927, 0.0003464222, - 0.0004109144, 0.0004891157, 0.0005909204, 0.0007261038, - 0.0008867979, 0.0010721684, 0.0012696981, 0.0015079975, - 0.0017461777, 0.0019979477, 0.0022052526, 0.0023679733, - 0.0025173426, 0.0026556253, 0.0027927160, 0.0029264688, - 0.0030447245, 0.0031807423, 0.0033060312, 0.0034313202, - 0.0035454035, 0.0036598444, 0.0037686825, 0.0038731098, - 0.0039769411, 0.0040702820, 0.0041661263, 0.0042562485, - 0.0043400526, 0.0044249296, 0.0045082569, 0.0045900345, - 0.0046693087, 0.0047430992, 0.0048171282, 0.0048881769, - 0.0049589872, 0.0050252676, 0.0050880909, 0.0051497221, - 0.0052082539, 0.0052671432, 0.0053246021, 0.0053800344, - 0.0054348707, 0.0054861307, 0.0055367947, 0.0055862665, - 0.0056355000, 0.0056805611, 0.0057252645, 0.0057705641, - 0.0058110952, 0.0058538914, 0.0058966875, 0.0059366226, - 0.0059723854, 0.0060091019, 0.0060437918, 0.0060794353, - 0.0061159134, 0.0061485767, 0.0061824322, 0.0062153339, - 0.0062497854, 0.0062820911, 0.0063197613, 0.0063550472, - 0.0063927174, 0.0064336061, 0.0064769983, 0.0065194368, - 0.0065603256, 0.0066006184, 0.0066410303, 0.0066826344, - 0.0067234039, 0.0067654848, 0.0068060160, 0.0068466663, - 0.0068866014, 0.0069231987, 0.0069609880, 0.0069983006, - 0.0070366859, 0.0070750713, 0.0071122646, 0.0071535110, - 0.0071973801, 0.0072410107, 0.0072846413, 0.0073343515, - 0.0073832273, 0.0074360371, 0.0074878931, 0.0075426102, - 0.0076007843, 0.0076560974, 0.0077134371, 0.0077683926, - 0.0078265667, 0.0078855753, 0.0079488754, 0.0080170631, - 0.0080827475, 0.0081528425, 0.0082212687, 0.0082877874, - 0.0083510876, 0.0084129572, 0.0084775686, 0.0085455179, - 0.0086110830, 0.0086781979, 0.0087503195, 0.0088242292, - 0.0089002848, 0.0089734793, 0.0090423822, 0.0091133118, - 0.0091816187, 0.0092473030, 0.0093164444, 0.0093911886, - 0.0094678402, 0.0095427036, 0.0096175671, 0.0096931458, - 0.0097666979, 0.0098397732, 0.0099166632, 0.0099946260, - 0.0100749731, 0.0101612806, 0.0102528334, 0.0103493929, - 0.0104434490, 0.0105448961, 0.0106583834, 0.0107737780, - 0.0108981133, 0.0110142231, 0.0111318827, 0.0112472773, - 0.0113576651, 0.0114786625, 0.0116028786, 0.0117331743, - 0.0118676424, 0.0120122433, 0.0121580362, 0.0123010874, - 0.0124633312, 0.0126402378, 0.0128232241, 0.0130140781, - 0.0132108927, 0.0134289265, 0.0136625767, 0.0138912201, - 0.0141364336, 0.0144006014, 0.0146615505, 0.0149335861, - 0.0152134895, 0.0155050755, 0.0158376694, 0.0162067413, - 0.0165973902, 0.0169926882, 0.0174319744, 0.0179271698, - 0.0184448957, 0.0190744400, 0.0197248459, 0.0204203129, - 0.0212460756, 0.0221523046, 0.0231562853, 0.0243031979, - 0.0256397724, 0.0271918774, 0.0289602280, 0.0310072899, - 0.0333702564, 0.0363805294, 0.0401413441, 0.0443998575, - 0.0498176813, 0.0562580824, 0.0640066862, 0.0732775927, - 0.0836604834, 0.0962959528, 0.1122496128, 0.1335854530, - 0.1608980894, 0.1990102530, 0.2616490126, 0.3926030397 -}; - -static const float wmavoice_gain_universal[64] = { - 0.0000000000, 0.0000000000, 0.0000015497, 0.0000015497, - 0.0000095367, 0.0000164509, 0.0000379086, 0.0000494719, - 0.0000799894, 0.0001058578, 0.0001349449, 0.0001627207, - 0.0001972914, 0.0002325773, 0.0002671480, 0.0003106594, - 0.0003589392, 0.0004127026, 0.0004582405, 0.0005071163, - 0.0005759001, 0.0006588697, 0.0007554293, 0.0008602142, - 0.0009772778, 0.0011068583, 0.0012603998, 0.0013889074, - 0.0015437603, 0.0016924143, 0.0018980503, 0.0021264553, - 0.0023632050, 0.0025693178, 0.0028522015, 0.0031896830, - 0.0034654140, 0.0037885904, 0.0041683912, 0.0046081543, - 0.0050576925, 0.0055632591, 0.0061818361, 0.0068151951, - 0.0073953867, 0.0081818104, 0.0091186762, 0.0102789402, - 0.0119919777, 0.0134155750, 0.0154829025, 0.0173798800, - 0.0199711323, 0.0229473114, 0.0268185139, 0.0319474936, - 0.0393068790, 0.0460114479, 0.0523469448, 0.0637906790, - 0.0845471621, 0.1105458736, 0.1499300003, 0.2219169140 -}; - -static const float wmavoice_gain_codebook_acb[128] = { - 0.05, 0.14, 0.16, 0.05, 0.17, 0.25, 0.07, 0.21, - 0.12, 0.22, 0.23, 0.13, 0.24, 0.32, 0.14, 0.29, - 0.31, 0.41, 0.43, 0.32, 0.43, 0.51, 0.34, 0.48, - 0.38, 0.47, 0.49, 0.38, 0.49, 0.57, 0.40, 0.54, - 0.49, 0.59, 0.61, 0.50, 0.61, 0.69, 0.52, 0.66, - 0.56, 0.65, 0.67, 0.56, 0.67, 0.75, 0.58, 0.72, - 0.65, 0.74, 0.76, 0.65, 0.76, 0.84, 0.67, 0.81, - 0.71, 0.80, 0.82, 0.71, 0.82, 0.90, 0.73, 0.87, - 0.81, 0.90, 0.92, 0.81, 0.93, 1.01, 0.83, 0.97, - 0.87, 0.96, 0.98, 0.87, 0.98, 1.06, 0.89, 1.03, - 0.92, 1.02, 1.04, 0.93, 1.04, 1.12, 0.95, 1.09, - 0.93, 1.02, 1.04, 0.93, 1.04, 1.12, 0.95, 1.09, - 0.94, 1.04, 1.05, 0.10, 1.06, 1.14, 0.96, 1.11, - 0.98, 1.08, 1.10, 0.99, 1.10, 1.18, 1.01, 1.15, - 1.06, 1.15, 1.17, 1.06, 1.17, 1.25, 1.08, 1.22, - 1.16, 1.25, 1.27, 1.16, 1.28, 1.36, 1.18, 1.32 -}; - -static const float wmavoice_gain_codebook_fcb[128] = { - -0.8439700703 /* log(0.430) */, -0.6143360001 /* log(0.541) */, - -0.1531511795 /* log(0.858) */, -0.0998203353 /* log(0.905) */, - 0.3213585988 /* log(1.379) */, 0.3777512695 /* log(1.459) */, - 0.7158866675 /* log(2.046) */, 1.2700414043 /* log(3.561) */, - -1.6873994539 /* log(0.185) */, -1.2173958247 /* log(0.296) */, - -0.4893903430 /* log(0.613) */, -0.4155154440 /* log(0.660) */, - 0.1257512053 /* log(1.134) */, 0.1947440768 /* log(1.215) */, - 0.5883420662 /* log(1.801) */, 1.1987592373 /* log(3.316) */, - -1.3586791941 /* log(0.257) */, -0.9996723408 /* log(0.368) */, - -0.3768776513 /* log(0.686) */, -0.3119747650 /* log(0.732) */, - 0.1881379421 /* log(1.207) */, 0.2523139286 /* log(1.287) */, - 0.6280751838 /* log(1.874) */, 1.2202397768 /* log(3.388) */, - -0.7381445465 /* log(0.478) */, -0.5310283311 /* log(0.588) */, - -0.0987159729 /* log(0.906) */, -0.0491902442 /* log(0.952) */, - 0.3555743385 /* log(1.427) */, 0.4101209196 /* log(1.507) */, - 0.7390761124 /* log(2.094) */, 1.2831536022 /* log(3.608) */, - -0.2497442331 /* log(0.779) */, -0.1165338163 /* log(0.890) */, - 0.1881379421 /* log(1.207) */, 0.2255406759 /* log(1.253) */, - 0.5469646704 /* log(1.728) */, 0.5922212620 /* log(1.808) */, - 0.8733832309 /* log(2.395) */, 1.3632815868 /* log(3.909) */, - -1.3903023825 /* log(0.249) */, -1.0216512475 /* log(0.360) */, - -0.3900840061 /* log(0.677) */, -0.3229638866 /* log(0.724) */, - 0.1806534997 /* log(1.198) */, 0.2460785226 /* log(1.279) */, - 0.6232610531 /* log(1.865) */, 1.2178757095 /* log(3.380) */, - -0.6033064766 /* log(0.547) */, -0.4185503477 /* log(0.658) */, - -0.0253178080 /* log(0.975) */, 0.0217614918 /* log(1.022) */, - 0.4027948796 /* log(1.496) */, 0.4555243080 /* log(1.577) */, - 0.7714961470 /* log(2.163) */, 1.3023691262 /* log(3.678) */, - -1.1056369036 /* log(0.331) */, -0.8164453969 /* log(0.442) */, - -0.2757535016 /* log(0.759) */, -0.2156715365 /* log(0.806) */, - 0.2468600779 /* log(1.280) */, 0.3082197237 /* log(1.361) */, - 0.6662897264 /* log(1.947) */, 1.2418464568 /* log(3.462) */, - -0.5395680926 /* log(0.583) */, -0.3652833185 /* log(0.694) */, - 0.0109399400 /* log(1.011) */, 0.0554347069 /* log(1.057) */, - 0.4265740713 /* log(1.532) */, 0.4774756441 /* log(1.612) */, - 0.7880027116 /* log(2.199) */, 1.3118401752 /* log(3.713) */, - -0.9571127264 /* log(0.384) */, -0.7031975164 /* log(0.495) */, - -0.2082549388 /* log(0.812) */, -0.1519863570 /* log(0.859) */, - 0.2874320412 /* log(1.333) */, 0.3464225675 /* log(1.414) */, - 0.6931471806 /* log(2.000) */, 1.2570395253 /* log(3.515) */, - -0.2420715612 /* log(0.785) */, -0.1098148660 /* log(0.896) */, - 0.1930966300 /* log(1.213) */, 0.2311117210 /* log(1.260) */, - 0.5504308784 /* log(1.734) */, 0.5960854677 /* log(1.815) */, - 0.8758853172 /* log(2.401) */, 1.3650707247 /* log(3.916) */, - 0.6564831962 /* log(1.928) */, 0.7124594916 /* log(2.039) */, - 0.8569652658 /* log(2.356) */, 0.8767179568 /* log(2.403) */, - 1.0567480846 /* log(2.877) */, 1.0841752409 /* log(2.957) */, - 1.2652560327 /* log(3.544) */, 1.6211688353 /* log(5.059) */, - -1.5417792640 /* log(0.214) */, -1.1239300967 /* log(0.325) */, - -0.4431669753 /* log(0.642) */, -5.2983173665 /* log(0.005) */, - 0.1510028735 /* log(1.163) */, 0.2183319943 /* log(1.244) */, - 0.6043159669 /* log(1.830) */, 1.2074666936 /* log(3.345) */, - -0.5124936809 /* log(0.599) */, -0.3424903089 /* log(0.710) */, - 0.0266419309 /* log(1.027) */, 0.0713899961 /* log(1.074) */, - 0.4369637752 /* log(1.548) */, 0.4879663296 /* log(1.629) */, - 0.7952524035 /* log(2.215) */, 1.3164082337 /* log(3.730) */, - -0.8867319296 /* log(0.412) */, -0.6481738149 /* log(0.523) */, - -0.1743533871 /* log(0.840) */, -0.1199102967 /* log(0.887) */, - 0.3089542077 /* log(1.362) */, 0.3660310389 /* log(1.442) */, - 0.7075430608 /* log(2.029) */, 1.2649738259 /* log(3.543) */, - -0.0943106795 /* log(0.910) */, 0.0207825392 /* log(1.021) */, - 0.2911759617 /* log(1.338) */, 0.3249778572 /* log(1.384) */, - 0.6200387087 /* log(1.859) */, 0.6621723763 /* log(1.939) */, - 0.9266370239 /* log(2.526) */, 1.3962446920 /* log(4.040) */ -}; - -static const float wmavoice_ipol1_coeffs[17*9] = { - 0, - 0.6308171151, 0.7613050340, 0.8632577061, 0.9280143976, - 0.9499985575, 0.9273047447, 0.8618999123, 0.7594153284, - -0.1791058179, -0.1351341452, -0.0589959878, 0.0472882274, - 0.1784339990, 0.3262237605, 0.4801855979, 0.6285545824, - 0, - -0.1921342459, -0.1786532696, -0.1341681625, -0.0575229186, - 0.0492091286, 0.1806929555, 0.3286687729, 0.4826357064, - 0.0807464118, 0.0506337392, 0.0080115446, -0.0428523305, - -0.0958572026, -0.1436148431, -0.1782128509, -0.1921164688, - 0, - 0.0960653644, 0.0803771760, 0.0500416081, 0.0072485465, - -0.0437018941, -0.0966834794, -0.1442930843, -0.1786170151, - -0.0391932014, -0.0189622506, 0.0070230183, 0.0356589290, - 0.0630142610, 0.0847979258, 0.0969368290, 0.0961942221, - 0, - -0.0515680681, -0.0389267015, -0.0185848991, 0.0074699190, - 0.0361179407, 0.0634181346, 0.0850781347, 0.0970333587, - 0.0178811825, 0.0048708571, -0.0108041526, -0.0271167825, - -0.0416534986, -0.0519338618, -0.0557823736, -0.0517020743, - 0, - 0.0267091128, 0.0177022810, 0.0046363524, -0.0110662053, - -0.0273700613, -0.0418578978, -0.0520511451, -0.0557823028, - -0.0069270437, 0.0008217385, 0.0097293532, 0.0185749526, - 0.0259542684, 0.0304777338, 0.0309953480, 0.0268154419, - 0, - -0.0125539196, -0.0068173436, 0.0009580161, 0.0098749646, - 0.0187084037, 0.0260526291, 0.0305201071, 0.0309665180, - 0.0019149571, -0.0022503408, -0.0068592466, -0.0112465904, - -0.0146595868, -0.0163685936, -0.0157934162, -0.0126258885, - 0, - 0.0050976076, 0.0018546581, -0.0023221741, -0.0069331308, - -0.0113109085, -0.0147021576, -0.0163786146, -0.0157635096, - -0.0001162733, 0.0019313511, 0.0040823850, 0.0060192454, - 0.0073876535, 0.0078486321, 0.0071403184, 0.0051400312, - 0, - -0.0017920607, -0.0000857157, 0.0019657183, 0.0041159806, - 0.0060465694, 0.0074030068, 0.0078470460, 0.0071185785, - -0.0004100171, -0.0015364708, -0.0025490071, -0.0033188616, - -0.0037196307, -0.0036417283, -0.0030119629, -0.0018155784, - 0, - 0.0006907531, -0.0004282868, -0.0015539061, -0.0025635813, - -0.0033285026, -0.0037224069, -0.0036361245, -0.0029972247, - 0, 0, 0, 0, 0, 0, 0, 0 -}; - -/** - * Hamming-window sinc function (num = 32, x = [ 0, 31 ]): - * (0.54 + 0.46 * cos(2 * M_PI * x / (num - 1))) * - * sin(x * M_PI / 4) / (x * M_PI / 4) - */ -static const float wmavoice_ipol2_coeffs[32] = { - 1, 0.8563459515, 0.5888634918, 0.2648358640, - 0, -0.1360490318, -0.1434589471, -0.0758505310, - 0, 0.0410402636, 0.0412485781, 0.0200064587, - 0, -0.0081391358, -0.0068223253, -0.0029313546, - 0, 0.0025864919, 0.0053062555, 0.0055688801, - 0, -0.0104795941, -0.0187493577, -0.0160592399, - 0, 0.0212381664, 0.0331059131, 0.0251942366, - 0, -0.0273968070, -0.0392575669, -0.0276240534 -}; - -/** - * LUT for 1.071575641632 * pow(1.0331663, n - 127) - */ -static const float wmavoice_energy_table[128] = { - 0.0169982178, 0.0175619858, 0.0181444519, 0.0187462362, - 0.0193679795, 0.0200103437, 0.0206740128, 0.0213596933, - 0.0220681153, 0.0228000330, 0.0235562258, 0.0243374986, - 0.0251446834, 0.0259786395, 0.0268402549, 0.0277304468, - 0.0286501631, 0.0296003830, 0.0305821182, 0.0315964139, - 0.0326443501, 0.0337270424, 0.0348456436, 0.0360013446, - 0.0371953760, 0.0384290090, 0.0397035571, 0.0410203772, - 0.0423808713, 0.0437864880, 0.0452387238, 0.0467391249, - 0.0482892887, 0.0498908657, 0.0515455612, 0.0532551367, - 0.0550214125, 0.0568462692, 0.0587316496, 0.0606795611, - 0.0626920777, 0.0647713419, 0.0669195677, 0.0691390421, - 0.0714321284, 0.0738012678, 0.0762489827, 0.0787778794, - 0.0813906502, 0.0840900769, 0.0868790336, 0.0897604897, - 0.0927375130, 0.0958132732, 0.0989910450, 0.1022742117, - 0.1056662688, 0.1091708280, 0.1127916204, 0.1165325012, - 0.1203974531, 0.1243905911, 0.1285161668, 0.1327785725, - 0.1371823465, 0.1417321773, 0.1464329093, 0.1512895470, - 0.1563072616, 0.1614913951, 0.1668474671, 0.1723811803, - 0.1780984262, 0.1840052921, 0.1901080668, 0.1964132480, - 0.2029275487, 0.2096579046, 0.2166114816, 0.2237956830, - 0.2312181577, 0.2388868085, 0.2468098001, 0.2549955679, - 0.2634528274, 0.2721905830, 0.2812181375, 0.2905451026, - 0.3001814086, 0.3101373153, 0.3204234225, 0.3310506819, - 0.3420304081, 0.3533742912, 0.3650944090, 0.3772032397, - 0.3897136755, 0.4026390362, 0.4159930832, 0.4297900346, - 0.4440445799, 0.4587718956, 0.4739876619, 0.4897080789, - 0.5059498840, 0.5227303696, 0.5400674019, 0.5579794393, - 0.5764855528, 0.5956054456, 0.6153594745, 0.6357686714, - 0.6568547659, 0.6786402082, 0.7011481929, 0.7244026842, - 0.7484284410, 0.7732510432, 0.7988969192, 0.8253933741, - 0.8527686184, 0.8810517982, 0.9102730265, 0.9404634147, - 0.9716551065, 1.0038813113, 1.0371763400, 1.0715756416 -}; - -/** - * LUT for f(x,y) = pow((y + 6.9) / 64, 0.025 * (x + 1)). - */ -static const float wmavoice_denoise_power_table[12][64] = { - { 0.9458379339, 0.9490436287, 0.9518757236, 0.9544130754, - 0.9567118717, 0.9588135761, 0.9607496688, 0.9625446194, - 0.9642178285, 0.9657849396, 0.9672587526, 0.9686498743, - 0.9699671937, 0.9712182343, 0.9724094211, 0.9735462842, - 0.9746336187, 0.9756756090, 0.9766759291, 0.9776378218, - 0.9785641645, 0.9794575217, 0.9803201890, 0.9811542296, - 0.9819615045, 0.9827436985, 0.9835023412, 0.9842388263, - 0.9849544265, 0.9856503078, 0.9863275406, 0.9869871101, - 0.9876299254, 0.9882568267, 0.9888685922, 0.9894659445, - 0.9900495551, 0.9906200497, 0.9911780119, 0.9917239872, - 0.9922584859, 0.9927819864, 0.9932949377, 0.9937977618, - 0.9942908555, 0.9947745929, 0.9952493267, 0.9957153901, - 0.9961730980, 0.9966227482, 0.9970646231, 0.9974989903, - 0.9979261037, 0.9983462046, 0.9987595223, 0.9991662752, - 0.9995666709, 0.9999609077, 1.0003491745, 1.0007316515, - 1.0011085110, 1.0014799178, 1.0018460292, 1.0022069960 }, - { 0.8946093973, 0.9006838092, 0.9060673931, 0.9109043185, - 0.9152976055, 0.9193234737, 0.9230399260, 0.9264921443, - 0.9297160207, 0.9327405496, 0.9355894944, 0.9382825789, - 0.9408363568, 0.9432648587, 0.9455800822, 0.9477923675, - 0.9499106907, 0.9519428941, 0.9538958704, 0.9557757107, - 0.9575878241, 0.9593370368, 0.9610276730, 0.9626636222, - 0.9642483964, 0.9657851769, 0.9672768552, 0.9687260672, - 0.9701352224, 0.9715065293, 0.9728420173, 0.9741435556, - 0.9754128696, 0.9766515555, 0.9778610927, 0.9790428553, - 0.9801981216, 0.9813280829, 0.9824338513, 0.9835164667, - 0.9845769028, 0.9856160726, 0.9866348334, 0.9876339913, - 0.9886143053, 0.9895764906, 0.9905212223, 0.9914491381, - 0.9923608411, 0.9932569022, 0.9941378627, 0.9950042356, - 0.9958565084, 0.9966951442, 0.9975205834, 0.9983332454, - 0.9991335296, 0.9999218170, 1.0006984708, 1.0014638383, - 1.0022182509, 1.0029620257, 1.0036954662, 1.0044188628 }, - { 0.8461555040, 0.8547882305, 0.8624635555, 0.8693789920, - 0.8756760853, 0.8814598273, 0.8868103032, 0.8917900284, - 0.8964487626, 0.9008267754, 0.9049571273, 0.9088673021, - 0.9125804007, 0.9161160306, 0.9194909803, 0.9227197376, - 0.9258148939, 0.9287874629, 0.9316471355, 0.9344024839, - 0.9370611291, 0.9396298766, 0.9421148300, 0.9445214846, - 0.9468548060, 0.9491192967, 0.9513190517, 0.9534578074, - 0.9555389816, 0.9575657096, 0.9595408742, 0.9614671327, - 0.9633469396, 0.9651825670, 0.9669761222, 0.9687295635, - 0.9704447142, 0.9721232742, 0.9737668316, 0.9753768718, - 0.9769547868, 0.9785018824, 0.9800193854, 0.9815084500, - 0.9829701633, 0.9844055505, 0.9858155796, 0.9872011653, - 0.9885631734, 0.9899024236, 0.9912196934, 0.9925157203, - 0.9937912053, 0.9950468143, 0.9962831814, 0.9975009102, - 0.9987005760, 0.9998827277, 1.0010478892, 1.0021965608, - 1.0033292209, 1.0044463270, 1.0055483173, 1.0066356112 }, - { 0.8003259737, 0.8112313241, 0.8209581209, 0.8297466775, - 0.8377697066, 0.8451556492, 0.8520027051, 0.8583876935, - 0.8643718792, 0.8700049328, 0.8753277020, 0.8803741979, - 0.8851730502, 0.8897485937, 0.8941216918, 0.8983103719, - 0.9023303202, 0.9061952736, 0.9099173316, 0.9135072091, - 0.9169744409, 0.9203275502, 0.9235741882, 0.9267212496, - 0.9297749699, 0.9327410079, 0.9356245146, 0.9384301933, - 0.9411623497, 0.9438249364, 0.9464215906, 0.9489556668, - 0.9514302661, 0.9538482608, 0.9562123167, 0.9585249126, - 0.9607883576, 0.9630048062, 0.9651762722, 0.9673046403, - 0.9693916775, 0.9714390425, 0.9734482944, 0.9754209007, - 0.9773582446, 0.9792616307, 0.9811322918, 0.9829713934, - 0.9847800389, 0.9865592739, 0.9883100900, 0.9900334289, - 0.9917301853, 0.9934012104, 0.9950473143, 0.9966692689, - 0.9982678100, 0.9998436400, 1.0013974295, 1.0029298194, - 1.0044414224, 1.0059328250, 1.0074045889, 1.0088572520 }, - { 0.7569786654, 0.7698939195, 0.7814501054, 0.7919210783, - 0.8015042240, 0.8103467104, 0.8185613167, 0.8262364557, - 0.8334427763, 0.8402376615, 0.8466683811, 0.8527743561, - 0.8585888194, 0.8641400582, 0.8694523567, 0.8745467247, - 0.8794414652, 0.8841526254, 0.8886943552, 0.8930791981, - 0.8973183276, 0.9014217415, 0.9053984227, 0.9092564737, - 0.9130032283, 0.9166453478, 0.9201889007, 0.9236394320, - 0.9270020224, 0.9302813390, 0.9334816797, 0.9366070112, - 0.9396610028, 0.9426470554, 0.9455683275, 0.9484277579, - 0.9512280860, 0.9539718690, 0.9566614986, 0.9592992147, - 0.9618871182, 0.9644271823, 0.9669212630, 0.9693711079, - 0.9717783651, 0.9741445900, 0.9764712529, 0.9787597445, - 0.9810113822, 0.9832274148, 0.9854090274, 0.9875573457, - 0.9896734398, 0.9917583281, 0.9938129803, 0.9958383209, - 0.9978352315, 0.9998045539, 1.0017470919, 1.0036636145, - 1.0055548568, 1.0074215229, 1.0092642871, 1.0110837959 }, - { 0.7159791370, 0.7306629191, 0.7438433845, 0.7558198318, - 0.7668086064, 0.7769714272, 0.7864325139, 0.7952894548, - 0.8036203840, 0.8114888792, 0.8189474022, 0.8260397728, - 0.8328029877, 0.8392685815, 0.8454636629, 0.8514117142, - 0.8571332177, 0.8626461513, 0.8679663850, 0.8731080020, - 0.8780835596, 0.8829043049, 0.8875803529, 0.8921208349, - 0.8965340237, 0.9008274393, 0.9050079382, 0.9090817905, - 0.9130547454, 0.9169320882, 0.9207186893, 0.9244190474, - 0.9280373261, 0.9315773876, 0.9350428208, 0.9384369673, - 0.9417629433, 0.9450236603, 0.9482218422, 0.9513600421, - 0.9544406555, 0.9574659338, 0.9604379957, 0.9633588374, - 0.9662303420, 0.9690542879, 0.9718323569, 0.9745661408, - 0.9772571477, 0.9799068082, 0.9825164805, 0.9850874551, - 0.9876209597, 0.9901181627, 0.9925801775, 0.9950080658, - 0.9974028405, 0.9997654692, 1.0020968764, 1.0043979464, - 1.0066695255, 1.0089124239, 1.0111274185, 1.0133152537 }, - { 0.6772002277, 0.6934309881, 0.7080464599, 0.7213643301, - 0.7336148970, 0.7449707526, 0.7555647772, 0.7655015856, - 0.7748651015, 0.7837237382, 0.7921340426, 0.8001433220, - 0.8077915768, 0.8151129499, 0.8221368310, 0.8288887107, - 0.8353908496, 0.8416628090, 0.8477218755, 0.8535834053, - 0.8592611049, 0.8647672624, 0.8701129393, 0.8753081305, - 0.8803618988, 0.8852824894, 0.8900774261, 0.8947535945, - 0.8993173131, 0.9037743949, 0.9081302004, 0.9123896841, - 0.9165574352, 0.9206377129, 0.9246344779, 0.9285514202, - 0.9323919830, 0.9361593853, 0.9398566405, 0.9434865742, - 0.9470518396, 0.9505549317, 0.9539981992, 0.9573838564, - 0.9607139933, 0.9639905847, 0.9672154989, 0.9703905051, - 0.9735172803, 0.9765974162, 0.9796324243, 0.9826237418, - 0.9855727362, 0.9884807098, 0.9913489039, 0.9941785028, - 0.9969706369, 0.9997263861, 1.0024467831, 1.0051328157, - 1.0077854297, 1.0104055314, 1.0129939892, 1.0155516364 }, - { 0.6405216642, 0.6580962612, 0.6739722363, 0.6884795488, - 0.7018580813, 0.7142880714, 0.7259086094, 0.7368294324, - 0.7471387455, 0.7569085832, 0.7661985859, 0.7750587283, - 0.7835313288, 0.7916525600, 0.7994535998, 0.8069615243, - 0.8142000068, 0.8211898738, 0.8279495504, 0.8344954211, - 0.8408421252, 0.8470027997, 0.8529892811, 0.8588122744, - 0.8644814947, 0.8700057878, 0.8753932324, 0.8806512276, - 0.8857865684, 0.8908055105, 0.8957138271, 0.9005168576, - 0.9052195513, 0.9098265046, 0.9143419945, 0.9187700080, - 0.9231142680, 0.9273782568, 0.9315652364, 0.9356782672, - 0.9397202245, 0.9436938133, 0.9476015819, 0.9514459336, - 0.9552291382, 0.9589533414, 0.9626205741, 0.9662327603, - 0.9697917251, 0.9732992008, 0.9767568340, 0.9801661903, - 0.9835287605, 0.9868459649, 0.9901191578, 0.9933496315, - 0.9965386205, 0.9996873045, 1.0027968119, 1.0058682226, - 1.0089025710, 1.0119008485, 1.0148640056, 1.0177929548 }, - { 0.6058296875, 0.6245620637, 0.6415378101, 0.6570938835, - 0.6714759586, 0.6848691001, 0.6974164561, 0.7092312055, - 0.7204044988, 0.7310109103, 0.7411122884, 0.7507605397, - 0.7599996842, 0.7688674015, 0.7773962122, 0.7856143935, - 0.7935466990, 0.8012149303, 0.8086383963, 0.8158342858, - 0.8228179717, 0.8296032631, 0.8362026133, 0.8426272954, - 0.8488875492, 0.8549927056, 0.8609512936, 0.8667711307, - 0.8724594015, 0.8780227256, 0.8834672161, 0.8887985309, - 0.8940219180, 0.8991422543, 0.9041640810, 0.9090916337, - 0.9139288704, 0.9186794948, 0.9233469789, 0.9279345818, - 0.9324453671, 0.9368822185, 0.9412478543, 0.9455448393, - 0.9497755970, 0.9539424198, 0.9580474782, 0.9620928299, - 0.9660804271, 0.9700121244, 0.9738896845, 0.9777147851, - 0.9814890239, 0.9852139236, 0.9888909370, 0.9925214512, - 0.9961067913, 0.9996482244, 1.0031469629, 1.0066041676, - 1.0100209506, 1.0133983785, 1.0167374742, 1.0200392198 }, - { 0.5730166999, 0.5927366473, 0.6106642672, 0.6271389942, - 0.6424090212, 0.6566617910, 0.6700426292, 0.6826666808, - 0.6946268614, 0.7059993279, 0.7168473476, 0.7272241023, - 0.7371747608, 0.7467380401, 0.7559474006, 0.7648319736, - 0.7734172908, 0.7817258650, 0.7897776570, 0.7975904541, - 0.8051801811, 0.8125611560, 0.8197463039, 0.8267473349, - 0.8335748949, 0.8402386937, 0.8467476129, 0.8531098003, - 0.8593327495, 0.8654233698, 0.8713880464, 0.8772326935, - 0.8829628002, 0.8885834710, 0.8940994619, 0.8995152120, - 0.9048348715, 0.9100623268, 0.9152012229, 0.9202549833, - 0.9252268281, 0.9301197899, 0.9349367288, 0.9396803449, - 0.9443531909, 0.9489576823, 0.9534961076, 0.9579706374, - 0.9623833320, 0.9667361492, 0.9710309512, 0.9752695109, - 0.9794535174, 0.9835845813, 0.9876642399, 0.9916939614, - 0.9956751493, 0.9996091459, 1.0034972362, 1.0073406510, - 1.0111405700, 1.0148981248, 1.0186144013, 1.0222904422 }, - { 0.5419809316, 0.5625329386, 0.5812764912, 0.5985496562, - 0.6146003370, 0.6296162401, 0.6437432340, 0.6570971404, - 0.6697716039, 0.6818435182, 0.6933768712, 0.7044255353, - 0.7150353340, 0.7252456009, 0.7350903742, 0.7445993259, - 0.7537984929, 0.7627108595, 0.7713568269, 0.7797545943, - 0.7879204712, 0.7958691361, 0.8036138516, 0.8111666444, - 0.8185384580, 0.8257392814, 0.8327782597, 0.8396637886, - 0.8464035955, 0.8530048108, 0.8594740287, 0.8658173611, - 0.8720404845, 0.8781486812, 0.8841468762, 0.8900396688, - 0.8958313620, 0.9015259874, 0.9071273286, 0.9126389413, - 0.9180641715, 0.9234061727, 0.9286679198, 0.9338522236, - 0.9389617420, 0.9439989920, 0.9489663591, 0.9538661069, - 0.9587003852, 0.9634712378, 0.9681806094, 0.9728303524, - 0.9774222323, 0.9819579336, 0.9864390644, 0.9908671615, - 0.9952436943, 0.9995700689, 1.0038476318, 1.0080776733, - 1.0122614305, 1.0164000906, 1.0204947932, 1.0245466331 }, - { 0.5126261246, 0.5338683013, 0.5533029807, 0.5712636181, - 0.5879954388, 0.6036845987, 0.6184760989, 0.6324853169, - 0.6458057215, 0.6585142011, 0.6706748475, 0.6823417062, - 0.6935608163, 0.7043717519, 0.7148088052, 0.7249019070, - 0.7346773529, 0.7441583823, 0.7533656456, 0.7623175831, - 0.7710307376, 0.7795200117, 0.7877988829, 0.7958795841, - 0.8037732557, 0.8114900754, 0.8190393682, 0.8264297018, - 0.8336689680, 0.8407644543, 0.8477229049, 0.8545505751, - 0.8612532786, 0.8678364291, 0.8743050768, 0.8806639416, - 0.8869174414, 0.8930697184, 0.8991246621, 0.9050859297, - 0.9109569648, 0.9167410144, 0.9224411436, 0.9280602496, - 0.9336010737, 0.9390662129, 0.9444581300, 0.9497791628, - 0.9550315328, 0.9602173528, 0.9653386345, 0.9703972943, - 0.9753951600, 0.9803339761, 0.9852154088, 0.9900410510, - 0.9948124263, 0.9995309934, 1.0041981497, 1.0088152348, - 1.0133835335, 1.0179042791, 1.0223786564, 1.0268078035 }, -}; - -#endif /* AVCODEC_WMAVOICE_DATA_H */ diff --git a/apps/codecs/libwmavoice/wmavoice_mainbuild.patch b/apps/codecs/libwmavoice/wmavoice_mainbuild.patch deleted file mode 100644 index cf349299bd..0000000000 --- a/apps/codecs/libwmavoice/wmavoice_mainbuild.patch +++ /dev/null @@ -1,32 +0,0 @@ -Index: ../codecs.make -=================================================================== ---- ../codecs.make (revision 27762) -+++ ../codecs.make (working copy) -@@ -38,6 +38,7 @@ - include $(APPSDIR)/codecs/libwavpack/libwavpack.make - include $(APPSDIR)/codecs/libwma/libwma.make - include $(APPSDIR)/codecs/libwmapro/libwmapro.make -+include $(APPSDIR)/codecs/libwmavoice/libwmavoice.make - include $(APPSDIR)/codecs/libcook/libcook.make - include $(APPSDIR)/codecs/librm/librm.make - include $(APPSDIR)/codecs/libatrac/libatrac.make -@@ -79,6 +80,7 @@ - $(CODECDIR)/ape.codec : $(CODECDIR)/libdemac.a - $(CODECDIR)/wma.codec : $(CODECDIR)/libwma.a $(CODECDIR)/libasf.a - $(CODECDIR)/wmapro.codec : $(CODECDIR)/libwmapro.a $(CODECDIR)/libasf.a -+$(CODECDIR)/wmavoice.codec : $(CODECDIR)/libwmavoice.a $(CODECDIR)/libasf.a - $(CODECDIR)/wavpack_enc.codec: $(CODECDIR)/libwavpack.a - $(CODECDIR)/asap.codec : $(CODECDIR)/libasap.a - $(CODECDIR)/cook.codec : $(CODECDIR)/libcook.a $(CODECDIR)/librm.a -Index: ../SOURCES -=================================================================== ---- ../SOURCES (revision 27762) -+++ ../SOURCES (working copy) -@@ -33,6 +33,7 @@ - wav64.c - tta.c - wmapro.c -+wmavoice.c - - #ifdef HAVE_RECORDING - diff --git a/apps/codecs/mod.c b/apps/codecs/mod.c deleted file mode 100644 index 5bd64994f1..0000000000 --- a/apps/codecs/mod.c +++ /dev/null @@ -1,1353 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * MOD Codec for rockbox - * - * Written from scratch by Rainer Sinsch - * exclusivly for Rockbox in February 2008 - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ - - /************** - * This version supports large files directly from internal memory management. - * There is a drawback however: It may happen that a song is not completely - * loaded when the internal rockbox-ringbuffer (approx. 28MB) is filled up - * As a workaround make sure you don't have directories with mods larger - * than a total of 28MB - *************/ - -#include "debug.h" -#include "codeclib.h" -#include - -#include -#include -#include -#include - - -CODEC_HEADER - -#define CHUNK_SIZE (1024*2) - - -/* This codec supports MOD Files: - * - */ - -static int32_t samples[CHUNK_SIZE] IBSS_ATTR; /* The sample buffer */ - -/* Instrument Data */ -struct s_instrument { - /* Sample name / description */ - /*char description[22];*/ - - /* Sample length in bytes */ - unsigned short length; - - /* Sample finetuning (-8 - +7) */ - signed char finetune; - - /* Sample volume (0 - 64) */ - signed char volume; - - /* Sample Repeat Position */ - unsigned short repeatoffset; - - /* Sample Repeat Length */ - unsigned short repeatlength; - - /* Offset to sample data */ - unsigned int sampledataoffset; -}; - -/* Song Data */ -struct s_song { - /* Song name / title description */ - /*char szTitle[20];*/ - - /* No. of channels in song */ - unsigned char noofchannels; - - /* No. of instruments used (either 15 or 31) */ - unsigned char noofinstruments; - - /* How many patterns are beeing played? */ - unsigned char songlength; - - /* Where to jump after the song end? */ - unsigned char songendjumpposition; - - /* Pointer to the Pattern Order Table */ - unsigned char *patternordertable; - - /* Pointer to the pattern data */ - void *patterndata; - - /* Pointer to the sample buffer */ - signed char *sampledata; - - /* Instrument data */ - struct s_instrument instrument[31]; -}; - -struct s_modchannel { - /* Current Volume */ - signed char volume; - - /* Current Offset to period in PeriodTable of notebeeing played - (can be temporarily negative) */ - short periodtableoffset; - - /* Current Period beeing played */ - short period; - - /* Current effect */ - unsigned char effect; - - /* Current parameters of effect */ - unsigned char effectparameter; - - /* Current Instrument beeing played */ - unsigned char instrument; - - /* Current Vibrato Speed */ - unsigned char vibratospeed; - - /* Current Vibrato Depth */ - unsigned char vibratodepth; - - /* Current Position for Vibrato in SinTable */ - unsigned char vibratosinpos; - - /* Current Tremolo Speed */ - unsigned char tremolospeed; - - /* Current Tremolo Depth */ - unsigned char tremolodepth; - - /* Current Position for Tremolo in SinTable */ - unsigned char tremolosinpos; - - /* Current Speed of Effect "Slide Note up" */ - unsigned char slideupspeed; - - /* Current Speed of Effect "Slide Note down" */ - unsigned char slidedownspeed; - - /* Current Speed of the "Slide to Note" effect */ - unsigned char slidetonotespeed; - - /* Current Period of the "Slide to Note" effect */ - unsigned short slidetonoteperiod; -}; - -struct s_modplayer { - /* Ticks per Line */ - unsigned char ticksperline; - - /* Beats per Minute */ - unsigned char bpm; - - /* Position of the Song in the Pattern Table (0-127) */ - unsigned char patterntableposition; - - /* Current Line (may be temporarily < 0) */ - signed char currentline; - - /* Current Tick */ - signed char currenttick; - - /* How many samples are required to calculate for each tick? */ - unsigned int samplespertick; - - /* Information about the channels */ - struct s_modchannel modchannel[8]; - - /* The Amiga Period Table */ - unsigned short *periodtable; - - /* The sinus table [-255,255] */ - signed short *sintable; - - /* Is the glissando effect enabled? */ - bool glissandoenabled; - - /* Is the Amiga Filter enabled? */ - bool amigafilterenabled; - - /* The pattern-line where the loop is carried out (set with e6 command) */ - unsigned char loopstartline; - - /* Number of times to loop */ - unsigned char looptimes; -}; - -struct s_channel { - /* Panning (0 = left, 16 = right) */ - unsigned char panning; - - /* Sample frequency of the channel */ - unsigned short frequency; - - /* Position of the sample currently played */ - unsigned int samplepos; - - /* Fractual Position of the sample currently player */ - unsigned int samplefractpos; - - /* Loop Sample */ - bool loopsample; - - /* Loop Position Start */ - unsigned int loopstart; - - /* Loop Position End */ - unsigned int loopend; - - /* Is The channel beeing played? */ - bool channelactive; - - /* The Volume (0..64) */ - signed char volume; - - /* The last sampledata beeing played (required for interpolation) */ - signed short lastsampledata; -}; - -struct s_mixer { - /* The channels */ - struct s_channel channel[32]; -}; - -struct s_song modsong IDATA_ATTR; /* The Song */ -struct s_modplayer modplayer IDATA_ATTR; /* The Module Player */ -struct s_mixer mixer IDATA_ATTR; - -/* The Amiga Period Table (+1 because we use index 0 for period 0 = no new note) */ -static unsigned short s_periodtable[37*8+1] IDATA_ATTR = - { 0, 907, 900, 893, 887, 881, 874, 868, - 862, 856, 849, 843, 837, 831, 825, 819, - 813, 808, 802, 796, 790, 785, 779, 773, - 768, 762, 757, 751, 746, 740, 735, 730, - 725, 719, 714, 709, 704, 699, 694, 689, - 684, 679, 674, 669, 664, 660, 655, 650, - 645, 641, 636, 632, 627, 623, 618, 614, - 609, 605, 600, 596, 592, 588, 583, 579, - 575, 571, 567, 563, 559, 555, 551, 547, - 543, 539, 535, 531, 527, 523, 520, 516, - 512, 509, 505, 501, 498, 494, 490, 487, - 483, 480, 477, 473, 470, 466, 463, 460, - 456, 453, 450, 446, 443, 440, 437, 434, - 431, 428, 424, 421, 418, 415, 412, 409, - 406, 404, 401, 398, 395, 392, 389, 386, - 384, 381, 378, 375, 373, 370, 367, 365, - 362, 359, 357, 354, 352, 349, 347, 344, - 342, 339, 337, 334, 332, 330, 327, 325, - 322, 320, 318, 316, 313, 311, 309, 307, - 304, 302, 300, 298, 296, 294, 291, 289, - 287, 285, 283, 281, 279, 277, 275, 273, - 271, 269, 267, 265, 263, 261, 260, 258, - 256, 254, 252, 250, 249, 247, 245, 243, - 241, 240, 238, 236, 235, 233, 231, 230, - 228, 226, 225, 223, 221, 220, 218, 217, - 215, 214, 212, 210, 209, 207, 206, 204, - 203, 202, 200, 199, 197, 196, 194, 193, - 192, 190, 189, 187, 186, 185, 183, 182, - 181, 179, 178, 177, 176, 174, 173, 172, - 171, 169, 168, 167, 166, 165, 163, 162, - 161, 160, 159, 158, 156, 155, 154, 153, - 152, 151, 150, 149, 148, 147, 145, 144, - 143, 142, 141, 140, 139, 138, 137, 136, - 135, 134, 133, 132, 131, 130, 130, 129, - 128, 127, 126, 125, 124, 123, 122, 121, - 120, 120, 119, 118, 117, 116, 115, 115, - 114, 113, 112, 111, 110, 110, 109, 108, - 107}; - -/* The sin table */ -static signed short s_sintable[0x40] IDATA_ATTR = - { 0, 25, 49, 74, 97, 120, 141, 162, - 180, 197, 212, 225, 235, 244, 250, 254, - 255, 254, 250, 244, 235, 225, 212, 197, - 180, 161, 141, 120, 97, 73, 49, 24, - 0, -25, -50, -74, -98, -120, -142, -162, - -180, -197, -212, -225, -236, -244, -250, -254, - -255, -254, -250, -244, -235, -224, -211, -197, - -180, -161, -141, -119, -97, -73, -49, -24}; - -const unsigned short mixingrate = 44100; - -STATICIRAM void mixer_playsample(int channel, int instrument) ICODE_ATTR; -void mixer_playsample(int channel, int instrument) -{ - struct s_channel *p_channel = &mixer.channel[channel]; - struct s_instrument *p_instrument = &modsong.instrument[instrument]; - - p_channel->channelactive = true; - p_channel->samplepos = p_instrument->sampledataoffset; - p_channel->samplefractpos = 0; - p_channel->loopsample = (p_instrument->repeatlength > 2); - if (p_channel->loopsample) { - p_channel->loopstart = p_instrument->repeatoffset + - p_instrument->sampledataoffset; - p_channel->loopend = p_channel->loopstart + - p_instrument->repeatlength; - } - else p_channel->loopend = p_instrument->length + - p_instrument->sampledataoffset; - - /* Remember the instrument */ - modplayer.modchannel[channel].instrument = instrument; -} - -static inline void mixer_stopsample(int channel) -{ - mixer.channel[channel].channelactive = false; -} - -static inline void mixer_continuesample(int channel) -{ - mixer.channel[channel].channelactive = true; -} - -static inline void mixer_setvolume(int channel, int volume) -{ - mixer.channel[channel].volume = volume; -} - -static inline void mixer_setpanning(int channel, int panning) -{ - mixer.channel[channel].panning = panning; -} - -static inline void mixer_setamigaperiod(int channel, int amigaperiod) -{ - /* Just to make sure we don't devide by zero - * amigaperiod shouldn't 0 anyway - if it is the case - * then something terribly went wrong */ - if (amigaperiod == 0) - return; - - mixer.channel[channel].frequency = 3579546 / amigaperiod; -} - -/* Initialize the MOD Player with default values and precalc tables */ -STATICIRAM void initmodplayer(void) ICODE_ATTR; -void initmodplayer(void) -{ - unsigned int c; -#if 0 - /* As the calculation of periodtable and sintable uses float and double - * rockbox uses two predefined tables. This reduces the codesize by - * several KB. */ - - unsigned int i; - /* Calculate Amiga Period Values - * Start with Period 907 (= C-1 with Finetune -8) and work upwards */ - double f = 907.0f; - /* Index 0 stands for no note (and therefore no period) */ - modplayer.periodtable[0] = 0; - for (i=1;i<297;i++) - { - modplayer.periodtable[i] = (unsigned short) f; - f /= 1.0072464122237039; /* = pow(2.0f, 1.0f/(12.0f*8.0f)); */ - } - - /* - * This is a more accurate but also time more consuming approach - * to calculate the amiga period table - * Commented out for speed purposes - const int finetuning = 8; - const int octaves = 3; - for (int halftone=0;halftone<=finetuning*octaves*12+7;halftone++) - { - float e = pow(2.0f, halftone/(12.0f*8.0f)); - float f = 906.55f/e; - modplayer.periodtable[halfetone+1] = (int)(f+0.5f); - } - */ - - /* Calculate Protracker Vibrato sine table - * The routine makes use of the Harmonical Oscillator Approach - * for calculating sine tables - * (see http://membres.lycos.fr/amycoders/tutorials/sintables.html) - * The routine presented here calculates a complete sine wave - * with 64 values in range [-255,255] - */ - float a, b, d, dd; - - d = 0.09817475f; /* = 2*PI/64 */ - dd = d*d; - a = 0; - b = d; - - for (i=0;i<0x40;i++) - { - modplayer.sintable[i] = (int)(255*a); - - a = a+b; - b = b-dd*a; - } -#else - /* Point to the predefined tables */ - modplayer.periodtable = s_periodtable; - modplayer.sintable = s_sintable; -#endif - /* Set Default Player Values */ - modplayer.currentline = 0; - modplayer.currenttick = 0; - modplayer.patterntableposition = 0; - modplayer.bpm = 125; - modplayer.ticksperline = 6; - modplayer.glissandoenabled = false; /* Disable glissando */ - modplayer.amigafilterenabled = false; /* Disable the Amiga Filter */ - - /* Default Panning Values */ - int panningvalues[8] = {4,12,12,4,4,12,12,4}; - for (c=0;c<8;c++) - { - /* Set Default Panning */ - mixer_setpanning(c, panningvalues[c]); - /* Reset channels in the MOD Player */ - memset(&modplayer.modchannel[c], 0, sizeof(struct s_modchannel)); - /* Don't play anything */ - mixer.channel[c].channelactive = false; - } - -} - -/* Load the MOD File from memory */ -STATICIRAM bool loadmod(void *modfile) ICODE_ATTR; -bool loadmod(void *modfile) -{ - int i; - unsigned char *periodsconverted; - - /* We don't support PowerPacker 2.0 Files */ - if (memcmp((char*) modfile, "PP20", 4) == 0) return false; - - /* Get the File Format Tag */ - char *fileformattag = (char*)modfile + 1080; - - /* Find out how many channels and instruments are used */ - if (memcmp(fileformattag, "2CHN", 4) == 0) - {modsong.noofchannels = 2; modsong.noofinstruments = 31;} - else if (memcmp(fileformattag, "M.K.", 4) == 0) - {modsong.noofchannels = 4; modsong.noofinstruments = 31;} - else if (memcmp(fileformattag, "M!K!", 4) == 0) - {modsong.noofchannels = 4; modsong.noofinstruments = 31;} - else if (memcmp(fileformattag, "4CHN", 4) == 0) - {modsong.noofchannels = 4; modsong.noofinstruments = 31;} - else if (memcmp(fileformattag, "FLT4", 4) == 0) - {modsong.noofchannels = 4; modsong.noofinstruments = 31;} - else if (memcmp(fileformattag, "6CHN", 4) == 0) - {modsong.noofchannels = 6; modsong.noofinstruments = 31;} - else if (memcmp(fileformattag, "8CHN", 4) == 0) - {modsong.noofchannels = 8; modsong.noofinstruments = 31;} - else if (memcmp(fileformattag, "OKTA", 4) == 0) - {modsong.noofchannels = 8; modsong.noofinstruments = 31;} - else if (memcmp(fileformattag, "CD81", 4) == 0) - {modsong.noofchannels = 8; modsong.noofinstruments = 31;} - else { - /* The file has no format tag, so most likely soundtracker */ - modsong.noofchannels = 4; - modsong.noofinstruments = 15; - } - - /* Get the Song title - * Skipped here - * strncpy(modsong.szTitle, (char*)pMODFile, 20); */ - - /* Get the Instrument information */ - for (i=0;idescription, (char*)p, 22); */ - p += 22; - instrument->length = (((p[0])<<8) + p[1]) << 1; p+=2; - instrument->finetune = *p++ & 0x0f; - /* Treat finetuning as signed nibble */ - if (instrument->finetune > 7) instrument->finetune -= 16; - instrument->volume = *p++; - instrument->repeatoffset = (((p[0])<<8) + p[1]) << 1; p+= 2; - instrument->repeatlength = (((p[0])<<8) + p[1]) << 1; - } - - /* Get the pattern information */ - unsigned char *p = (unsigned char *)modfile + 20 + - modsong.noofinstruments*30; - modsong.songlength = *p++; - modsong.songendjumpposition = *p++; - modsong.patternordertable = p; - - /* Find out how many patterns are used within this song */ - int maxpatterns = 0; - for (i=0;i<128;i++) - if (modsong.patternordertable[i] > maxpatterns) - maxpatterns = modsong.patternordertable[i]; - maxpatterns++; - - /* use 'restartposition' (historically set to 127) which is not used here - as a marker that periods have already been converted */ - - periodsconverted = (char*)modfile + 20 + modsong.noofinstruments*30 + 1; - - /* Get the pattern data; ST doesn't have fileformattag, so 4 bytes less */ - modsong.patterndata = periodsconverted + - (modsong.noofinstruments==15 ? 129 : 133); - - /* Convert the period values in the mod file to offsets - * in our periodtable (but only, if we haven't done this yet) */ - p = (unsigned char *) modsong.patterndata; - if (*periodsconverted != 0xfe) - { - int note, note2, channel; - for (note=0;note> 8) | (p[0] & 0xf0); - p[1] = periodoffset & 0xff; - p += 4; - } - /* Remember that we already converted the periods, - * in case the file gets reloaded by rewinding - * with 0xfe (arbitary magic value > 127) */ - *periodsconverted = 0xfe; - } - - /* Get the samples - * Calculation: The Samples come after the pattern data - * We know that there are nMaxPatterns and each pattern requires - * 4 bytes per note and per channel. - * And of course there are always lines in each channel */ - modsong.sampledata = (signed char*) modsong.patterndata + - maxpatterns*4*modsong.noofchannels*64; - int sampledataoffset = 0; - for (i=0;i> 7 is used in the original protracker source code */ - mixer_setamigaperiod(channel, p_modchannel->period+ - ((p_modchannel->vibratodepth * - modplayer.sintable[p_modchannel->vibratosinpos])>>7)); - - /* Foward in Sine Table */ - p_modchannel->vibratosinpos += p_modchannel->vibratospeed; - p_modchannel->vibratosinpos &= 0x3f; -} - -/* Apply tremolo to channel - * (same as vibrato, but only apply on volume instead of pitch) */ -STATICIRAM void tremolo(int channel) ICODE_ATTR; -void tremolo(int channel) -{ - struct s_modchannel *p_modchannel = &modplayer.modchannel[channel]; - - /* Apply Tremolo - * >> 6 is used in the original protracker source code */ - int volume = (p_modchannel->volume * - modplayer.sintable[p_modchannel->tremolosinpos])>>6; - if (volume > 64) volume = 64; - else if (volume < 0) volume = 0; - mixer_setvolume(channel, volume); - - /* Foward in Sine Table */ - p_modchannel->tremolosinpos += p_modchannel->tremolosinpos; - p_modchannel->tremolosinpos &= 0x3f; -} - -/* Apply Slide to Note effect to channel */ -STATICIRAM void slidetonote(int channel) ICODE_ATTR; -void slidetonote(int channel) -{ - struct s_modchannel *p_modchannel = &modplayer.modchannel[channel]; - - /* If there hasn't been any slide-to note set up, then return */ - if (p_modchannel->slidetonoteperiod == 0) return; - - /* Slide note up */ - if (p_modchannel->slidetonoteperiod > p_modchannel->period) - { - p_modchannel->period += p_modchannel->slidetonotespeed; - if (p_modchannel->period > p_modchannel->slidetonoteperiod) - p_modchannel->period = p_modchannel->slidetonoteperiod; - } - /* Slide note down */ - else if (p_modchannel->slidetonoteperiod < p_modchannel->period) - { - p_modchannel->period -= p_modchannel->slidetonotespeed; - if (p_modchannel->period < p_modchannel->slidetonoteperiod) - p_modchannel->period = p_modchannel->slidetonoteperiod; - } - mixer_setamigaperiod(channel, p_modchannel->period); -} - -/* Apply Slide to Note effect on channel, - * but this time with glissando enabled */ -STATICIRAM void slidetonoteglissando(int channel) ICODE_ATTR; -void slidetonoteglissando(int channel) -{ - struct s_modchannel *p_modchannel = &modplayer.modchannel[channel]; - - /* Slide note up */ - if (p_modchannel->slidetonoteperiod > p_modchannel->period) - { - p_modchannel->period = - modplayer.periodtable[p_modchannel->periodtableoffset+=8]; - if (p_modchannel->period > p_modchannel->slidetonoteperiod) - p_modchannel->period = p_modchannel->slidetonoteperiod; - } - /* Slide note down */ - else - { - p_modchannel->period = - modplayer.periodtable[p_modchannel->periodtableoffset-=8]; - if (p_modchannel->period < p_modchannel->slidetonoteperiod) - p_modchannel->period = p_modchannel->slidetonoteperiod; - } - mixer_setamigaperiod(channel, p_modchannel->period); -} - -/* Apply Volume Slide */ -STATICIRAM void volumeslide(int channel, int effectx, int effecty) ICODE_ATTR; -void volumeslide(int channel, int effectx, int effecty) -{ - struct s_modchannel *p_modchannel = &modplayer.modchannel[channel]; - - /* If both X and Y Parameters are non-zero, then the y value is ignored */ - if (effectx > 0) { - p_modchannel->volume += effectx; - if (p_modchannel->volume > 64) p_modchannel->volume = 64; - } - else { - p_modchannel->volume -= effecty; - if (p_modchannel->volume < 0) p_modchannel->volume = 0; - } - - mixer_setvolume(channel, p_modchannel->volume); -} - -/* Play the current line (at tick 0) */ -STATICIRAM void playline(int pattern, int line) ICODE_ATTR; -void playline(int pattern, int line) -{ - int c; - - /* Get pointer to the current pattern */ - unsigned char *p_line = (unsigned char*)modsong.patterndata; - p_line += pattern*64*4*modsong.noofchannels; - p_line += line*4*modsong.noofchannels; - - /* Only allow one Patternbreak Commando per Line */ - bool patternbreakdone = false; - - for (c=0;c> 4); - short periodtableoffset = ((p_note[0] & 0x0f) << 8) | p_note[1]; - - p_modchannel->effect = p_note[2] & 0x0f; - p_modchannel->effectparameter = p_note[3]; - - /* Remember Instrument and set Volume if new Instrument triggered */ - if (samplenumber > 0) - { - /* And trigger new sample, if new instrument was set */ - if (samplenumber-1 != p_modchannel->instrument) - { - /* Advance the new sample to the same offset - * the old sample was beeing played */ - int oldsampleoffset = mixer.channel[c].samplepos - - modsong.instrument[ - p_modchannel->instrument].sampledataoffset; - mixer_playsample(c, samplenumber-1); - mixer.channel[c].samplepos += oldsampleoffset; - } - - /* Remember last played instrument on channel */ - p_modchannel->instrument = samplenumber-1; - - /* Set Volume to standard instrument volume, - * if not overwritten by volume effect */ - if (p_modchannel->effect != 0x0c) - { - p_modchannel->volume = modsong.instrument[ - p_modchannel->instrument].volume; - mixer_setvolume(c, p_modchannel->volume); - } - } - /* Trigger new sample if note available */ - if (periodtableoffset > 0) - { - /* Restart instrument only when new sample triggered */ - if (samplenumber != 0) - mixer_playsample(c, (samplenumber > 0) ? - samplenumber-1 : p_modchannel->instrument); - - /* Set the new amiga period - * (but only, if there is no slide to note effect) */ - if ((p_modchannel->effect != 0x3) && - (p_modchannel->effect != 0x5)) - { - /* Apply finetuning to sample */ - p_modchannel->periodtableoffset = periodtableoffset + - modsong.instrument[p_modchannel->instrument].finetune; - p_modchannel->period = modplayer.periodtable[ - p_modchannel->periodtableoffset]; - mixer_setamigaperiod(c, p_modchannel->period); - /* When a new note is played without slide to note setup, - * then disable slide to note */ - modplayer.modchannel[c].slidetonoteperiod = - p_modchannel->period; - } - } - int effectx = p_modchannel->effectparameter>>4; - int effecty = p_modchannel->effectparameter&0x0f; - - switch (p_modchannel->effect) - { - /* Effect 0: Arpeggio */ - case 0x00: - /* Set the base period on tick 0 */ - if (p_modchannel->effectparameter > 0) - mixer_setamigaperiod(c, - modplayer.periodtable[ - p_modchannel->periodtableoffset]); - break; - /* Slide up (Portamento up) */ - case 0x01: - if (p_modchannel->effectparameter > 0) - p_modchannel->slideupspeed = - p_modchannel->effectparameter; - break; - - /* Slide down (Portamento down) */ - case 0x02: - if (p_modchannel->effectparameter > 0) - p_modchannel->slidedownspeed = - p_modchannel->effectparameter; - break; - - /* Slide to Note */ - case 0x03: - if (p_modchannel->effectparameter > 0) - p_modchannel->slidetonotespeed = - p_modchannel->effectparameter; - /* Get the slide to note directly from the pattern buffer */ - if (periodtableoffset > 0) - p_modchannel->slidetonoteperiod = - modplayer.periodtable[periodtableoffset + - modsong.instrument[ - p_modchannel->instrument].finetune]; - /* If glissando is enabled apply the effect directly here */ - if (modplayer.glissandoenabled) - slidetonoteglissando(c); - break; - - /* Set Vibrato */ - case 0x04: - if (effectx > 0) p_modchannel->vibratospeed = effectx; - if (effecty > 0) p_modchannel->vibratodepth = effecty; - break; - - /* Effect 0x06: Slide to note */ - case 0x05: - /* Get the slide to note directly from the pattern buffer */ - if (periodtableoffset > 0) - p_modchannel->slidetonoteperiod = - modplayer.periodtable[periodtableoffset + - modsong.instrument[ - p_modchannel->instrument].finetune]; - break; - - /* Effect 0x06 is "Continue Effects" */ - /* It is not processed on tick 0 */ - case 0x06: - break; - - /* Set Tremolo */ - case 0x07: - if (effectx > 0) p_modchannel->tremolodepth = effectx; - if (effecty > 0) p_modchannel->tremolospeed = effecty; - break; - - /* Set fine panning */ - case 0x08: - /* Internal panning goes from 0..15 - * Scale the fine panning value to that range */ - mixer.channel[c].panning = p_modchannel->effectparameter>>4; - break; - - /* Set Sample Offset */ - case 0x09: - { - struct s_instrument *p_instrument = - &modsong.instrument[p_modchannel->instrument]; - int sampleoffset = p_instrument->sampledataoffset; - if (sampleoffset > p_instrument->length) - sampleoffset = p_instrument->length; - /* Forward the new offset to the mixer */ - mixer.channel[c].samplepos = - p_instrument->sampledataoffset + - (p_modchannel->effectparameter<<8); - mixer.channel[c].samplefractpos = 0; - break; - } - - /* Effect 0x0a (Volume slide) is not processed on tick 0 */ - - /* Position Jump */ - case 0x0b: - modplayer.currentline = -1; - modplayer.patterntableposition = (effectx<<4)+effecty; - break; - - /* Set Volume */ - case 0x0c: - p_modchannel->volume = p_modchannel->effectparameter; - mixer_setvolume(c, p_modchannel->volume); - break; - - /* Pattern break */ - case 0x0d: - modplayer.currentline = effectx*10 + effecty - 1; - if (!patternbreakdone) - { - patternbreakdone = true; - modplayer.patterntableposition++; - } - break; - - /* Extended Effects */ - case 0x0e: - switch (effectx) - { - /* Set Filter */ - case 0x0: - modplayer.amigafilterenabled = (effecty == 0); - break; - /* Fineslide up */ - case 0x1: - mixer_setamigaperiod(c, p_modchannel->period -= - effecty); - if (p_modchannel->period < - modplayer.periodtable[37*8]) p_modchannel->period = 100; - /* Find out the new offset in the period table */ - if (p_modchannel->periodtableoffset < 36*8) - while (modplayer.periodtable[ - p_modchannel->periodtableoffset+8] >= p_modchannel->period) - p_modchannel->periodtableoffset+=8; - break; - /* Fineslide down */ - case 0x2: - mixer_setamigaperiod(c, - p_modchannel->period += effecty); - if (p_modchannel->periodtableoffset > 8) - while (modplayer.periodtable[ - p_modchannel->periodtableoffset-8] - <= p_modchannel->period) - p_modchannel->periodtableoffset-=8; - break; - /* Set glissando on/off */ - case 0x3: - modplayer.glissandoenabled = (effecty > 0); - break; - /* Set Vibrato waveform */ - case 0x4: - /* Currently not implemented */ - break; - /* Set Finetune value */ - case 0x5: - /* Treat as signed nibble */ - if (effecty > 7) effecty -= 16; - - p_modchannel->periodtableoffset += - effecty - - modsong.instrument[ - p_modchannel->instrument].finetune; - p_modchannel->period = - modplayer.periodtable[ - p_modchannel->periodtableoffset]; - modsong.instrument[ - p_modchannel->instrument].finetune = effecty; - break; - /* Pattern loop */ - case 0x6: - if (effecty == 0) - modplayer.loopstartline = line-1; - else - { - if (modplayer.looptimes == 0) - { - modplayer.currentline = - modplayer.loopstartline; - modplayer.looptimes = effecty; - } - else modplayer.looptimes--; - if (modplayer.looptimes > 0) - modplayer.currentline = - modplayer.loopstartline; - } - break; - /* Set Tremolo waveform */ - case 0x7: - /* Not yet implemented */ - break; - /* Enhanced Effect 8 is not used */ - case 0x8: - break; - /* Retrigger sample */ - case 0x9: - /* Only processed on subsequent ticks */ - break; - /* Fine volume slide up */ - case 0xa: - p_modchannel->volume += effecty; - if (p_modchannel->volume > 64) - p_modchannel->volume = 64; - mixer_setvolume(c, p_modchannel->volume); - break; - /* Fine volume slide down */ - case 0xb: - p_modchannel->volume -= effecty; - if (p_modchannel->volume < 0) - p_modchannel->volume = 0; - mixer_setvolume(c, p_modchannel->volume); - break; - /* Cut sample */ - case 0xc: - /* Continue sample */ - mixer_continuesample(c); - break; - /* Note delay (Usage: $ED + ticks to delay note.) */ - case 0xd: - /* We stop the sample here on tick 0 - * and restart it later in the effect */ - if (effecty > 0) - mixer.channel[c].channelactive = false; - break; - } - break; - - /* Set Speed */ - case 0x0f: - if (p_modchannel->effectparameter < 32) - modplayer.ticksperline = p_modchannel->effectparameter; - else - modplayer.bpm = p_modchannel->effectparameter; - break; - } - } -} - -/* Play the current effect of the note (ticks 1..speed) */ -STATICIRAM void playeffect(int currenttick) ICODE_ATTR; -void playeffect(int currenttick) -{ - int c; - - for (c=0;cperiod == 0) continue; - - unsigned char effectx = p_modchannel->effectparameter>>4; - unsigned char effecty = p_modchannel->effectparameter&0x0f; - - switch (p_modchannel->effect) - { - /* Effect 0: Arpeggio */ - case 0x00: - if (p_modchannel->effectparameter > 0) - { - unsigned short newperiodtableoffset; - switch (currenttick % 3) - { - case 0: - mixer_setamigaperiod(c, - modplayer.periodtable[ - p_modchannel->periodtableoffset]); - break; - case 1: - newperiodtableoffset = - p_modchannel->periodtableoffset+(effectx<<3); - if (newperiodtableoffset < 37*8) - mixer_setamigaperiod(c, - modplayer.periodtable[ - newperiodtableoffset]); - break; - case 2: - newperiodtableoffset = - p_modchannel->periodtableoffset+(effecty<<3); - if (newperiodtableoffset < 37*8) - mixer_setamigaperiod(c, - modplayer.periodtable[ - newperiodtableoffset]); - break; - } - } - break; - - /* Effect 1: Slide Up */ - case 0x01: - mixer_setamigaperiod(c, - p_modchannel->period -= p_modchannel->slideupspeed); - /* Find out the new offset in the period table */ - if (p_modchannel->periodtableoffset <= 37*8) - while (modplayer.periodtable[ - p_modchannel->periodtableoffset] > - p_modchannel->period) - { - p_modchannel->periodtableoffset++; - /* Make sure we don't go out of range */ - if (p_modchannel->periodtableoffset > 37*8) - { - p_modchannel->periodtableoffset = 37*8; - break; - } - } - break; - - /* Effect 2: Slide Down */ - case 0x02: - mixer_setamigaperiod(c, p_modchannel->period += - p_modchannel->slidedownspeed); - /* Find out the new offset in the period table */ - if (p_modchannel->periodtableoffset > 8) - while (modplayer.periodtable[ - p_modchannel->periodtableoffset] < - p_modchannel->period) - { - p_modchannel->periodtableoffset--; - /* Make sure we don't go out of range */ - if (p_modchannel->periodtableoffset < 1) - { - p_modchannel->periodtableoffset = 1; - break; - } - } - break; - - /* Effect 3: Slide to Note */ - case 0x03: - /* Apply smooth sliding, if no glissando is enabled */ - if (modplayer.glissandoenabled == 0) - slidetonote(c); - break; - - /* Effect 4: Vibrato */ - case 0x04: - vibrate(c); - break; - - /* Effect 5: Continue effect 3:'Slide to note', - * but also do Volume slide */ - case 0x05: - slidetonote(c); - volumeslide(c, effectx, effecty); - break; - - /* Effect 6: Continue effect 4:'Vibrato', - * but also do Volume slide */ - case 0x06: - vibrate(c); - volumeslide(c, effectx, effecty); - break; - - /* Effect 7: Tremolo */ - case 0x07: - tremolo(c); - break; - - /* Effect 8 (Set fine panning) is only processed at tick 0 */ - /* Effect 9 (Set sample offset) is only processed at tick 0 */ - - /* Effect A: Volume slide */ - case 0x0a: - volumeslide(c, effectx, effecty); - break; - - /* Effect B (Position jump) is only processed at tick 0 */ - /* Effect C (Set Volume) is only processed at tick 0 */ - /* Effect D (Pattern Preak) is only processed at tick 0 */ - /* Effect E (Enhanced Effect) */ - case 0x0e: - switch (effectx) - { - /* Retrigger sample ($E9 + Tick to Retrig note at) */ - case 0x9: - /* Don't device by zero */ - if (effecty == 0) effecty = 1; - /* Apply retrig */ - if (currenttick % effecty == 0) - mixer_playsample(c, p_modchannel->instrument); - break; - /* Cut note (Usage: $EC + Tick to Cut note at) */ - case 0xc: - if (currenttick == effecty) - mixer_stopsample(c); - break; - /* Delay note (Usage: $ED + ticks to delay note) */ - case 0xd: - /* If this is the correct tick, - * we start playing the sample now */ - if (currenttick == effecty) - mixer.channel[c].channelactive = true; - break; - - } - break; - /* Effect F (Set Speed) is only processed at tick 0 */ - - } - } -} - -static inline int clip(int i) -{ - if (i > 32767) return(32767); - else if (i < -32768) return(-32768); - else return(i); -} - -STATICIRAM void synthrender(int32_t *renderbuffer, int samplecount) ICODE_ATTR; -void synthrender(int32_t *renderbuffer, int samplecount) -{ - /* 125bpm equals to 50Hz (= 0.02s) - * => one tick = mixingrate/50, - * samples passing in one tick: - * mixingrate/(bpm/2.5) = 2.5*mixingrate/bpm */ - - int32_t *p_left = renderbuffer; /* int in rockbox */ - int32_t *p_right = p_left+1; - signed short s; - int qf_distance, qf_distance2; - - int i; - - int c, left, right; - - for (i=0;i= modplayer.ticksperline) - { - modplayer.currentline++; - modplayer.currenttick = 0; - if (modplayer.currentline == 64) - { - modplayer.patterntableposition++; - if (modplayer.patterntableposition >= modsong.songlength) - /* This is for Noise Tracker - * modplayer.patterntableposition = - * modsong.songendjumpposition; - * More compatible approach is restart from 0 */ - modplayer.patterntableposition=0; - modplayer.currentline = 0; - } - } - - modplayer.samplespertick = (20*mixingrate/modplayer.bpm)>>3; - } - /* Mix buffers from here - * Walk through all channels */ - left=0, right=0; - - /* If song has not stopped playing */ - if (modplayer.patterntableposition < 127) - /* Loop through all channels */ - for (c=0;c= mixer.channel[c].loopend) - { - if (mixer.channel[c].loopsample) - mixer.channel[c].samplepos -= - (mixer.channel[c].loopend- - mixer.channel[c].loopstart); - else mixer.channel[c].channelactive = false; - } - - /* If the sample has stopped playing don't mix it */ - if (!mixer.channel[c].channelactive) continue; - - /* Get the sample */ - s = (signed short)(modsong.sampledata[ - mixer.channel[c].samplepos]*mixer.channel[c].volume); - - /* Interpolate if the sample-frequency is lower - * than the mixing rate - * If you don't want interpolation simply skip this part */ - if (mixer.channel[c].frequency < mixingrate) - { - /* Low precision linear interpolation - * (fast integer based) */ - qf_distance = mixer.channel[c].samplefractpos<<16 / - mixingrate; - qf_distance2 = (1<<16)-qf_distance; - s = (qf_distance*s + qf_distance2* - mixer.channel[c].lastsampledata)>>16; - } - - /* Save the last played sample for interpolation purposes */ - mixer.channel[c].lastsampledata = s; - - /* Pan the sample */ - left += s*(16-mixer.channel[c].panning)>>3; - right += s*mixer.channel[c].panning>>3; - - /* Advance sample */ - mixer.channel[c].samplefractpos += mixer.channel[c].frequency; - while (mixer.channel[c].samplefractpos > mixingrate) - { - mixer.channel[c].samplefractpos -= mixingrate; - mixer.channel[c].samplepos++; - } - } - /* If we have more than 4 channels - * we have to make sure that we apply clipping */ - if (modsong.noofchannels > 4) { - *p_left = clip(left)<<13; - *p_right = clip(right)<<13; - } - else { - *p_left = left<<13; - *p_right = right<<13; - } - p_left+=2; - p_right+=2; - } -} - -/* this is the codec entry point */ -enum codec_status codec_main(enum codec_entry_call_reason reason) -{ - if (reason == CODEC_LOAD) { - /* Make use of 44.1khz */ - ci->configure(DSP_SET_FREQUENCY, 44100); - /* Sample depth is 28 bit host endian */ - ci->configure(DSP_SET_SAMPLE_DEPTH, 28); - /* Stereo output */ - ci->configure(DSP_SET_STEREO_MODE, STEREO_INTERLEAVED); - } - - return CODEC_OK; -} - -/* this is called for each file to process */ -enum codec_status codec_run(void) -{ - size_t n; - unsigned char *modfile; - int old_patterntableposition; - int bytesdone; - intptr_t param; - - if (codec_init()) { - return CODEC_ERROR; - } - - codec_set_replaygain(ci->id3); - - /* Load MOD file */ - ci->seek_buffer(0); - modfile = ci->request_buffer(&n, ci->filesize); - if (!modfile || n < (size_t)ci->filesize) { - return CODEC_ERROR; - } - - initmodplayer(); - loadmod(modfile); - - /* The main decoder loop */ - ci->set_elapsed(0); - bytesdone = 0; - old_patterntableposition = 0; - - while (1) { - enum codec_command_action action = ci->get_command(¶m); - - if (action == CODEC_ACTION_HALT) - break; - - if (action == CODEC_ACTION_SEEK_TIME) { - /* New time is ready in param */ - modplayer.patterntableposition = param/1000; - modplayer.currentline = 0; - ci->seek_complete(); - } - - if(old_patterntableposition != modplayer.patterntableposition) { - ci->set_elapsed(modplayer.patterntableposition*1000); - old_patterntableposition=modplayer.patterntableposition; - } - - synthrender(samples, CHUNK_SIZE/2); - - bytesdone += CHUNK_SIZE; - - ci->pcmbuf_insert(samples, NULL, CHUNK_SIZE/2); - - } - - return CODEC_OK; -} diff --git a/apps/codecs/mp3_enc.c b/apps/codecs/mp3_enc.c deleted file mode 100644 index 2f5528f74c..0000000000 --- a/apps/codecs/mp3_enc.c +++ /dev/null @@ -1,2629 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2006 Antonius Hellmann - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ - -// Shine is an MP3 encoder -// Copyright (C) 1999-2000 Gabriel Bouvigne -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Library General Public -// License as published by the Free Software Foundation; either -// version 2 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Library General Public License for more details. - -#include -#include "codeclib.h" - -CODEC_ENC_HEADER - -#define ENC_PADDING_FRAMES1 2 -#define ENC_PADDING_FRAMES2 4 -#define ENC_DELAY_SAMP 576 -#define ENC_DELAY_SIZE (ENC_DELAY_SAMP*4) -#define SAMP_PER_FRAME1 1152 -#define SAMP_PER_FRAME2 576 -#define PCM_CHUNK_SIZE1 (SAMP_PER_FRAME1*4) -#define PCM_CHUNK_SIZE2 (SAMP_PER_FRAME2*4) -#define SAMPL2 576 -#define SBLIMIT 32 -#define HTN 16 -#define memcpy ci->memcpy -#define memset ci->memset -#define putlong(c, s) if(s+sz <= 32) { cc = (cc << s) | c; sz+= s; } \ - else { putbits(cc, sz); cc = c; sz = s; } - -typedef struct { - int type; /* 0=(MPEG2 - 22.05,24,16kHz) 1=(MPEG1 - 44.1,48,32kHz) */ - int mode; /* 0=stereo, 1=jstereo, 2=dual, 3=mono */ - int bitrate; - int padding; - int num_bands; - long bitr_id; - int smpl_id; -} mpeg_t; - -/* Side information */ -typedef struct { - uint32_t part2_3_length; - int count1; /* number of 0-1-quadruples */ - uint32_t global_gain; - uint32_t table_select[4]; - uint32_t region_0_1; - uint32_t address1; - uint32_t address2; - uint32_t address3; - long quantStep; - long additStep; - uint32_t max_val; -} side_info_t; - -typedef struct { - side_info_t cod_info[2][2]; - mpeg_t mpg; - long frac_per_frame; - long byte_per_frame; - long slot_lag; - int sideinfo_len; - int mean_bits; - int ResvSize; - int channels; - int rec_mono_mode; - int granules; - long samplerate; -} config_t; - -typedef struct { - int bitpos; /* current bitpos for writing */ - uint32_t bbuf[263]; -} BF_Data; - -struct huffcodetab { - int len; /* max. index */ - const uint8_t *table; /* pointer to array[len][len] */ - const uint8_t *hlen; /* pointer to array[len][len] */ -}; - -struct huffcodebig { - int len; /* max. index */ - int linbits; /* number of linbits */ - int linmax; /* max number stored in linbits */ -}; - -#define shft4(x) ((x + 8) >> 4) -#define shft9(x) ((x + 256) >> 9) -#define shft13(x) ((x + 4096) >> 13) -#define shft15(x) ((x + 16384) >> 15) -#define shft16(x) ((x + 32768) >> 16) -#define shft_n(x,n) ((x) >> n) -#define SQRT 724 /* sqrt(2) * 512 */ - -static short mfbuf [2*(1152+512)] IBSS_ATTR; /* 3328 Bytes */ -static int sb_data [2][2][18][SBLIMIT] IBSS_ATTR; /* 13824 Bytes */ -static int mdct_freq [SAMPL2] IBSS_ATTR; /* 2304 Bytes */ -static char mdct_sign [SAMPL2] IBSS_ATTR; /* 576 Bytes */ -static short enc_data [SAMPL2] IBSS_ATTR; /* 1152 Bytes */ -static uint32_t scalefac [23] IBSS_ATTR; /* 92 Bytes */ -static BF_Data CodedData IBSS_ATTR; /* 1056 Bytes */ -static int ca [8] IBSS_ATTR; /* 32 Bytes */ -static int cs [8] IBSS_ATTR; /* 32 Bytes */ -static int cx [9] IBSS_ATTR; /* 36 Bytes */ -static int win [18][4] IBSS_ATTR; /* 288 Bytes */ -static short enwindow [15*27+24] IBSS_ATTR; /* 862 Bytes */ -static short int2idx [4096] IBSS_ATTR; /* 8192 Bytes */ -static uint8_t ht_count [2][2][16] IBSS_ATTR; /* 64 Bytes */ -static uint32_t tab01 [ 16] IBSS_ATTR; /* 64 Bytes */ -static uint32_t tab23 [ 9] IBSS_ATTR; /* 36 Bytes */ -static uint32_t tab56 [ 16] IBSS_ATTR; /* 64 Bytes */ -static uint32_t tab1315 [256] IBSS_ATTR; /* 1024 Bytes */ -static uint32_t tab1624 [256] IBSS_ATTR; /* 1024 Bytes */ -static uint32_t tab789 [ 36] IBSS_ATTR; /* 144 Bytes */ -static uint32_t tabABC [ 64] IBSS_ATTR; /* 256 Bytes */ -static uint8_t t1HB [ 4] IBSS_ATTR; -static uint8_t t2HB [ 9] IBSS_ATTR; -static uint8_t t3HB [ 9] IBSS_ATTR; -static uint8_t t5HB [ 16] IBSS_ATTR; -static uint8_t t6HB [ 16] IBSS_ATTR; -static uint8_t t7HB [ 36] IBSS_ATTR; -static uint8_t t8HB [ 36] IBSS_ATTR; -static uint8_t t9HB [ 36] IBSS_ATTR; -static uint8_t t10HB [ 64] IBSS_ATTR; -static uint8_t t11HB [ 64] IBSS_ATTR; -static uint8_t t12HB [ 64] IBSS_ATTR; -static uint8_t t13HB [256] IBSS_ATTR; -static uint8_t t15HB [256] IBSS_ATTR; -static uint16_t t16HB [256] IBSS_ATTR; -static uint16_t t24HB [256] IBSS_ATTR; -static uint8_t t1l [ 8] IBSS_ATTR; -static uint8_t t2l [ 9] IBSS_ATTR; -static uint8_t t3l [ 9] IBSS_ATTR; -static uint8_t t5l [ 16] IBSS_ATTR; -static uint8_t t6l [ 16] IBSS_ATTR; -static uint8_t t7l [ 36] IBSS_ATTR; -static uint8_t t8l [ 36] IBSS_ATTR; -static uint8_t t9l [ 36] IBSS_ATTR; -static uint8_t t10l [ 64] IBSS_ATTR; -static uint8_t t11l [ 64] IBSS_ATTR; -static uint8_t t12l [ 64] IBSS_ATTR; -static uint8_t t13l [256] IBSS_ATTR; -static uint8_t t15l [256] IBSS_ATTR; -static uint8_t t16l [256] IBSS_ATTR; -static uint8_t t24l [256] IBSS_ATTR; -static struct huffcodetab ht [HTN] IBSS_ATTR; - -static unsigned pcm_chunk_size IBSS_ATTR; -static unsigned samp_per_frame IBSS_ATTR; - -static config_t cfg IBSS_ATTR; -static char *res_buffer; -static int32_t err IBSS_ATTR; -static uint8_t band_scale_f[22]; - -static const uint8_t ht_count_const[2][2][16] = -{ { { 1, 5, 4, 5, 6, 5, 4, 4, 7, 3, 6, 0, 7, 2, 3, 1 }, /* table0 */ - { 1, 5, 5, 7, 5, 8, 7, 9, 5, 7, 7, 9, 7, 9, 9,10 } }, /* hleng0 */ - { {15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 }, /* table1 */ - { 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8 } } }; /* hleng1 */ - -static const uint8_t t1HB_const[4] = {1,1,1,0}; -static const uint8_t t2HB_const[9] = {1,2,1,3,1,1,3,2,0}; -static const uint8_t t3HB_const[9] = {3,2,1,1,1,1,3,2,0}; -static const uint8_t t5HB_const[16] = {1,2,6,5,3,1,4,4,7,5,7,1,6,1,1,0}; -static const uint8_t t6HB_const[16] = {7,3,5,1,6,2,3,2,5,4,4,1,3,3,2,0}; - -static const uint8_t t7HB_const[36] = -{ 1, 2,10,19,16,10, 3, 3, 7,10, 5, 3,11, 4,13,17, 8, 4, - 12,11,18,15,11, 2, 7, 6, 9,14, 3, 1, 6, 4, 5, 3, 2, 0 }; - -static const uint8_t t8HB_const[36] = -{ 3, 4, 6,18,12, 5, 5, 1, 2,16, 9, 3, 7, 3, 5,14, 7, 3, - 19,17,15,13,10, 4,13, 5, 8,11, 5, 1,12, 4, 4, 1, 1, 0 }; - -static const uint8_t t9HB_const[36] = -{ 7, 5, 9,14,15, 7, 6, 4, 5, 5, 6, 7, 7, 6, 8, 8, 8, 5, - 15, 6, 9,10, 5, 1,11, 7, 9, 6, 4, 1,14, 4, 6, 2, 6, 0 }; - -static const uint8_t t10HB_const[64] = -{1,2,10,23,35,30,12,17,3,3,8,12,18,21,12,7,11,9,15,21,32, - 40,19,6,14,13,22,34,46,23,18,7,20,19,33,47,27,22,9,3,31,22, - 41,26,21,20,5,3,14,13,10,11,16,6,5,1,9,8,7,8,4,4,2,0 }; - -static const uint8_t t11HB_const[64] = -{3,4,10,24,34,33,21,15,5,3,4,10,32,17,11,10,11,7,13,18,30, - 31,20,5,25,11,19,59,27,18,12,5,35,33,31,58,30,16,7,5,28,26, - 32,19,17,15,8,14,14,12,9,13,14,9,4,1,11,4,6,6,6,3,2,0 }; - -static const uint8_t t12HB_const[64] = -{9,6,16,33,41,39,38,26,7,5,6,9,23,16,26,11,17,7,11,14,21, -30,10,7,17,10,15,12,18,28,14,5,32,13,22,19,18,16,9,5,40,17, -31,29,17,13,4,2,27,12,11,15,10,7,4,1,27,12,8,12,6,3,1,0 }; - -static const uint8_t t13HB_const[256] = -{1,5,14,21,34,51,46,71,42,52,68,52,67,44,43,19,3,4,12,19,31,26,44,33,31,24,32, - 24,31,35,22,14,15,13,23,36,59,49,77,65,29,40,30,40,27,33,42,16,22,20,37,61,56, - 79,73,64,43,76,56,37,26,31,25,14,35,16,60,57,97,75,114,91,54,73,55,41,48,53, - 23,24,58,27,50,96,76,70,93,84,77,58,79,29,74,49,41,17,47,45,78,74,115,94,90, - 79,69,83,71,50,59,38,36,15,72,34,56,95,92,85,91,90,86,73,77,65,51,44,43,42,43, - 20,30,44,55,78,72,87,78,61,46,54,37,30,20,16,53,25,41,37,44,59,54,81,66,76,57, - 54,37,18,39,11,35,33,31,57,42,82,72,80,47,58,55,21,22,26,38,22,53,25,23,38,70, - 60,51,36,55,26,34,23,27,14,9,7,34,32,28,39,49,75,30,52,48,40,52,28,18,17,9,5, - 45,21,34,64,56,50,49,45,31,19,12,15,10,7,6,3,48,23,20,39,36,35,53,21,16,23,13, - 10,6,1,4,2,16,15,17,27,25,20,29,11,17,12,16,8,1,1,0,1 }; - -static const uint8_t t15HB_const[256] = -{7,12,18,53,47,76,124,108,89,123,108,119,107,81,122,63,13,5,16,27,46,36,61,51, - 42,70,52,83,65,41,59,36,19,17,15,24,41,34,59,48,40,64,50,78,62,80,56,33,29,28, - 25,43,39,63,55,93,76,59,93,72,54,75,50,29,52,22,42,40,67,57,95,79,72,57,89,69, - 49,66,46,27,77,37,35,66,58,52,91,74,62,48,79,63,90,62,40,38,125,32,60,56,50, - 92,78,65,55,87,71,51,73,51,70,30,109,53,49,94,88,75,66,122,91,73,56,42,64,44, - 21,25,90,43,41,77,73,63,56,92,77,66,47,67,48,53,36,20,71,34,67,60,58,49,88,76, - 67,106,71,54,38,39,23,15,109,53,51,47,90,82,58,57,48,72,57,41,23,27,62,9,86, - 42,40,37,70,64,52,43,70,55,42,25,29,18,11,11,118,68,30,55,50,46,74,65,49,39, - 24,16,22,13,14,7,91,44,39,38,34,63,52,45,31,52,28,19,14,8,9,3,123,60,58,53,47, - 43,32,22,37,24,17,12,15,10,2,1,71,37,34,30,28,20,17,26,21,16,10,6,8,6,2,0}; - -static const uint16_t t16HB_const[256] = -{1,5,14,44,74,63,110,93,172,149,138,242,225,195,376,17,3,4,12,20,35,62,53,47, - 83,75,68,119,201,107,207,9,15,13,23,38,67,58,103,90,161,72,127,117,110,209, - 206,16,45,21,39,69,64,114,99,87,158,140,252,212,199,387,365,26,75,36,68,65, - 115,101,179,164,155,264,246,226,395,382,362,9,66,30,59,56,102,185,173,265,142, - 253,232,400,388,378,445,16,111,54,52,100,184,178,160,133,257,244,228,217,385, - 366,715,10,98,48,91,88,165,157,148,261,248,407,397,372,380,889,884,8,85,84,81, - 159,156,143,260,249,427,401,392,383,727,713,708,7,154,76,73,141,131,256,245, - 426,406,394,384,735,359,710,352,11,139,129,67,125,247,233,229,219,393,743,737, - 720,885,882,439,4,243,120,118,115,227,223,396,746,742,736,721,712,706,223,436, - 6,202,224,222,218,216,389,386,381,364,888,443,707,440,437,1728,4,747,211,210, - 208,370,379,734,723,714,1735,883,877,876,3459,865,2,377,369,102,187,726,722, - 358,711,709,866,1734,871,3458,870,434,0,12,10,7,11,10,17,11,9,13,12,10,7,5,3, - 1,3}; - -static const uint16_t t24HB_const[256] = -{15,13,46,80,146,262,248,434,426,669,653,649,621,517,1032,88,14,12,21,38,71, - 130,122,216,209,198,327,345,319,297,279,42,47,22,41,74,68,128,120,221,207,194, - 182,340,315,295,541,18,81,39,75,70,134,125,116,220,204,190,178,325,311,293, - 271,16,147,72,69,135,127,118,112,210,200,188,352,323,306,285,540,14,263,66, - 129,126,119,114,214,202,192,180,341,317,301,281,262,12,249,123,121,117,113, - 215,206,195,185,347,330,308,291,272,520,10,435,115,111,109,211,203,196,187, - 353,332,313,298,283,531,381,17,427,212,208,205,201,193,186,177,169,320,303, - 286,268,514,377,16,335,199,197,191,189,181,174,333,321,305,289,275,521,379, - 371,11,668,184,183,179,175,344,331,314,304,290,277,530,383,373,366,10,652,346, - 171,168,164,318,309,299,287,276,263,513,375,368,362,6,648,322,316,312,307,302, - 292,284,269,261,512,376,370,364,359,4,620,300,296,294,288,282,273,266,515,380, - 374,369,365,361,357,2,1033,280,278,274,267,264,259,382,378,372,367,363,360, - 358,356,0,43,20,19,17,15,13,11,9,7,6,4,7,5,3,1,3}; - -static const uint32_t tab1315_const[256] = -{ 0x010003,0x050005,0x070006,0x080008,0x090008,0x0a0009,0x0a000a,0x0b000a, - 0x0a000a,0x0b000b,0x0c000b,0x0c000c,0x0d000c,0x0d000c,0x0e000d,0x0e000e, - 0x040005,0x060005,0x080007,0x090008,0x0a0009,0x0a0009,0x0b000a,0x0b000a, - 0x0b000a,0x0b000b,0x0c000b,0x0c000c,0x0d000c,0x0e000c,0x0e000d,0x0e000d, - 0x070006,0x080007,0x090007,0x0a0008,0x0b0009,0x0b0009,0x0c000a,0x0c000a, - 0x0b000a,0x0c000b,0x0c000b,0x0d000c,0x0d000c,0x0e000d,0x0f000d,0x0f000d, - 0x080007,0x090008,0x0a0008,0x0b0009,0x0b0009,0x0c000a,0x0c000a,0x0c000b, - 0x0c000b,0x0d000b,0x0d000c,0x0d000c,0x0d000c,0x0e000d,0x0f000d,0x0f000d, - 0x090008,0x090008,0x0b0009,0x0b0009,0x0c000a,0x0c000a,0x0d000b,0x0d000b, - 0x0c000b,0x0d000b,0x0d000c,0x0e000c,0x0e000c,0x0f000d,0x0f000d,0x10000d, - 0x0a0009,0x0a0009,0x0b0009,0x0c000a,0x0c000a,0x0c000a,0x0d000b,0x0d000b, - 0x0d000b,0x0d000b,0x0e000c,0x0d000c,0x0f000d,0x0f000d,0x10000d,0x10000e, - 0x0a000a,0x0b0009,0x0c000a,0x0c000a,0x0d000a,0x0d000b,0x0d000b,0x0d000b, - 0x0d000b,0x0e000c,0x0e000c,0x0e000c,0x0f000d,0x0f000d,0x10000e,0x10000e, - 0x0b000a,0x0b000a,0x0c000a,0x0d000b,0x0d000b,0x0d000b,0x0e000b,0x0e000c, - 0x0e000c,0x0e000c,0x0f000c,0x0f000c,0x0f000d,0x10000d,0x12000d,0x12000e, - 0x0a000a,0x0a000a,0x0b000a,0x0c000b,0x0c000b,0x0d000b,0x0d000b,0x0e000c, - 0x0e000c,0x0e000c,0x0e000c,0x0f000d,0x0f000d,0x10000e,0x11000e,0x11000e, - 0x0b000a,0x0b000a,0x0c000b,0x0c000b,0x0d000b,0x0d000b,0x0d000c,0x0f000c, - 0x0e000c,0x0f000d,0x0f000d,0x10000d,0x10000d,0x10000e,0x12000e,0x11000e, - 0x0b000b,0x0c000b,0x0c000b,0x0d000b,0x0d000c,0x0e000c,0x0e000c,0x0f000c, - 0x0e000c,0x0f000d,0x10000d,0x0f000d,0x10000d,0x11000e,0x12000f,0x13000e, - 0x0c000b,0x0c000b,0x0c000b,0x0d000b,0x0e000c,0x0e000c,0x0e000c,0x0e000c, - 0x0f000d,0x0f000d,0x0f000d,0x10000d,0x11000e,0x11000e,0x11000e,0x12000f, - 0x0c000c,0x0d000c,0x0d000b,0x0e000c,0x0e000c,0x0f000c,0x0e000d,0x0f000d, - 0x10000d,0x10000d,0x11000d,0x11000d,0x11000e,0x12000e,0x12000f,0x12000f, - 0x0d000c,0x0d000c,0x0e000c,0x0f000c,0x0f000c,0x0f000d,0x10000d,0x10000d, - 0x10000d,0x10000e,0x10000e,0x11000e,0x12000e,0x11000e,0x12000f,0x12000f, - 0x0e000d,0x0e000d,0x0e000d,0x0f000d,0x0f000d,0x0f000d,0x11000d,0x10000d, - 0x10000e,0x13000e,0x11000e,0x11000e,0x11000f,0x13000f,0x12000e,0x12000f, - 0x0d000d,0x0e000d,0x0f000d,0x10000d,0x10000d,0x10000d,0x11000d,0x10000e, - 0x11000e,0x11000e,0x12000e,0x12000e,0x15000f,0x14000f,0x15000f,0x12000f }; - -static const uint32_t tab01_const[16] = -{ 0x10004,0x50005,0x50005,0x70006,0x50005,0x80006,0x70006,0x90007, - 0x50005,0x70006,0x70006,0x90007,0x70006,0x90007,0x90007,0xa0008 }; - -static const uint32_t tab23_const[ 9] = -{ 0x10002,0x40003,0x70007,0x40004,0x50004,0x70007,0x60006,0x70007,0x80008 }; - -static const uint32_t tab56_const[16] = -{ 0x10003,0x40004,0x70006,0x80008,0x40004,0x50004,0x80006,0x90007, - 0x70005,0x80006,0x90007,0xa0008,0x80007,0x80007,0x90008,0xa0009 }; - -static const uint32_t tab789_const[36] = -{0x00100803,0x00401004,0x00701c06,0x00902407,0x00902409,0x00a0280a,0x00401004, - 0x00601005,0x00801806,0x00902807,0x00902808,0x00a0280a,0x00701c05,0x00701806, - 0x00902007,0x00a02808,0x00a02809,0x00b02c0a,0x00802407,0x00902807,0x00a02808, - 0x00b02c09,0x00b02c09,0x00b0300a,0x00802408,0x00902408,0x00a02809,0x00b02c09, - 0x00b0300a,0x00c0300b,0x00902809,0x00a02809,0x00b02c0a,0x00c02c0a,0x00c0340b, - 0x00c0340b}; - -static const uint32_t tabABC_const[64] = -{0x00100804,0x00401004,0x00701806,0x00902008,0x00a02409,0x00a0280a,0x00a0240a, - 0x00b0280a,0x00401004,0x00601405,0x00801806,0x00902007,0x00a02809,0x00b02809, - 0x00a0240a,0x00a0280a,0x00701806,0x00801c06,0x00902007,0x00a02408,0x00b02809, - 0x00c02c0a,0x00b02809,0x00b0280a,0x00802007,0x00902007,0x00a02408,0x00b02c08, - 0x00c02809,0x00c0300a,0x00b0280a,0x00c02c0a,0x00902408,0x00a02808,0x00b02809, - 0x00c02c09,0x00c02c0a,0x00c0300a,0x00c02c0a,0x00c0300b,0x00a02409,0x00b02809, - 0x00c02c0a,0x00c0300a,0x00d0300a,0x00d0340b,0x00c0300a,0x00d0340b,0x00902409, - 0x00a02409,0x00b02409,0x00c0280a,0x00c02c0a,0x00c0300b,0x00d0300b,0x00d0300c, - 0x00a0240a,0x00a0240a,0x00b0280a,0x00c02c0b,0x00c0300b,0x00d0300b,0x00d0300b, - 0x00d0300c}; - -static const uint32_t tab1624_const[256] = -{0x00010004,0x00050005,0x00070007,0x00090008,0x000a0009,0x000a000a,0x000b000a, - 0x000b000b,0x000c000b,0x000c000c,0x000c000c,0x000d000c,0x000d000c,0x000d000c, - 0x000e000d,0x000a000a,0x00040005,0x00060006,0x00080007,0x00090008,0x000a0009, - 0x000b000a,0x000b000a,0x000b000b,0x000c000b,0x000c000b,0x000c000c,0x000d000c, - 0x000e000c,0x000d000c,0x000e000c,0x000a000a,0x00070007,0x00080007,0x00090008, - 0x000a0009,0x000b0009,0x000b000a,0x000c000a,0x000c000b,0x000d000b,0x000c000b, - 0x000d000b,0x000d000c,0x000d000c,0x000e000c,0x000e000d,0x000b0009,0x00090008, - 0x00090008,0x000a0009,0x000b0009,0x000b000a,0x000c000a,0x000c000a,0x000c000b, - 0x000d000b,0x000d000b,0x000e000b,0x000e000c,0x000e000c,0x000f000c,0x000f000c, - 0x000c0009,0x000a0009,0x000a0009,0x000b0009,0x000b000a,0x000c000a,0x000c000a, - 0x000d000a,0x000d000b,0x000d000b,0x000e000b,0x000e000c,0x000e000c,0x000f000c, - 0x000f000c,0x000f000d,0x000b0009,0x000a000a,0x000a0009,0x000b000a,0x000b000a, - 0x000c000a,0x000d000a,0x000d000b,0x000e000b,0x000d000b,0x000e000b,0x000e000c, - 0x000f000c,0x000f000c,0x000f000c,0x0010000c,0x000c0009,0x000b000a,0x000b000a, - 0x000b000a,0x000c000a,0x000d000a,0x000d000b,0x000d000b,0x000d000b,0x000e000b, - 0x000e000c,0x000e000c,0x000e000c,0x000f000c,0x000f000c,0x0010000d,0x000c0009, - 0x000b000b,0x000b000a,0x000c000a,0x000c000a,0x000d000b,0x000d000b,0x000d000b, - 0x000e000b,0x000e000c,0x000f000c,0x000f000c,0x000f000c,0x000f000c,0x0011000d, - 0x0011000d,0x000c000a,0x000b000b,0x000c000b,0x000c000b,0x000d000b,0x000d000b, - 0x000d000b,0x000e000b,0x000e000b,0x000f000b,0x000f000c,0x000f000c,0x000f000c, - 0x0010000c,0x0010000d,0x0010000d,0x000c000a,0x000c000b,0x000c000b,0x000c000b, - 0x000d000b,0x000d000b,0x000e000b,0x000e000b,0x000f000c,0x000f000c,0x000f000c, - 0x000f000c,0x0010000c,0x000f000d,0x0010000d,0x000f000d,0x000d000a,0x000c000c, - 0x000d000b,0x000c000b,0x000d000b,0x000e000b,0x000e000c,0x000e000c,0x000e000c, - 0x000f000c,0x0010000c,0x0010000c,0x0010000d,0x0011000d,0x0011000d,0x0010000d, - 0x000c000a,0x000d000c,0x000d000c,0x000d000b,0x000d000b,0x000e000b,0x000e000c, - 0x000f000c,0x0010000c,0x0010000c,0x0010000c,0x0010000c,0x0010000d,0x0010000d, - 0x000f000d,0x0010000d,0x000d000a,0x000d000c,0x000e000c,0x000e000c,0x000e000c, - 0x000e000c,0x000f000c,0x000f000c,0x000f000c,0x000f000c,0x0011000c,0x0010000d, - 0x0010000d,0x0010000d,0x0010000d,0x0012000d,0x000d000a,0x000f000c,0x000e000c, - 0x000e000c,0x000e000c,0x000f000c,0x000f000c,0x0010000c,0x0010000c,0x0010000d, - 0x0012000d,0x0011000d,0x0011000d,0x0011000d,0x0013000d,0x0011000d,0x000d000a, - 0x000e000d,0x000f000c,0x000d000c,0x000e000c,0x0010000c,0x0010000c,0x000f000c, - 0x0010000d,0x0010000d,0x0011000d,0x0012000d,0x0011000d,0x0013000d,0x0011000d, - 0x0010000d,0x000d000a,0x000a0009,0x000a0009,0x000a0009,0x000b0009,0x000b0009, - 0x000c0009,0x000c0009,0x000c0009,0x000d0009,0x000d0009,0x000d0009,0x000d000a, - 0x000d000a,0x000d000a,0x000d000a,0x000a0006}; - -static const uint8_t t1l_const[8] = {1,3,2,3,1,4,3,5}; -static const uint8_t t2l_const[9] = {1,3,6,3,3,5,5,5,6}; -static const uint8_t t3l_const[9] = {2,2,6,3,2,5,5,5,6}; -static const uint8_t t5l_const[16] = {1,3,6,7,3,3,6,7,6,6,7,8,7,6,7,8}; -static const uint8_t t6l_const[16] = {3,3,5,7,3,2,4,5,4,4,5,6,6,5,6,7}; - -static const uint8_t t7l_const[36] = -{1,3,6,8,8,9,3,4,6,7,7,8,6,5,7,8,8,9,7,7,8,9,9,9,7,7,8,9,9,10,8,8,9,10,10,10}; - -static const uint8_t t8l_const[36] = -{2,3,6,8,8,9,3,2,4,8,8,8,6,4,6,8,8,9,8,8,8,9,9,10,8,7,8,9,10,10,9,8,9,9,11,11}; - -static const uint8_t t9l_const[36] = -{3,3,5,6,8,9,3,3,4,5,6,8,4,4,5,6,7,8,6,5,6,7,7,8,7,6,7,7,8,9,8,7,8,8,9,9}; - -static const uint8_t t10l_const[64] = -{1,3,6,8,9,9,9,10,3,4,6,7,8,9,8,8,6,6,7,8,9,10,9,9,7,7,8,9,10,10,9,10,8,8,9,10, - 10,10,10,10,9,9,10,10,11,11,10,11,8,8,9,10,10,10,11,11,9,8,9,10,10,11,11,11}; - -static const uint8_t t11l_const[64] = -{2,3,5,7,8,9,8,9,3,3,4,6,8,8,7,8,5,5,6,7,8,9,8,8,7,6,7,9,8,10,8,9,8,8,8,9,9,10, - 9,10,8,8,9,10,10,11,10,11,8,7,7,8,9,10,10,10,8,7,8,9,10,10,10,10}; - -static const uint8_t t12l_const[64] = -{4,3,5,7,8,9,9,9,3,3,4,5,7,7,8,8,5,4,5,6,7,8,7,8,6,5,6,6,7,8,8,8,7,6,7,7,8, - 8,8,9,8,7,8,8,8,9,8,9,8,7,7,8,8,9,9,10,9,8,8,9,9,9,9,10}; - -static const uint8_t t13l_const[256] = -{1,4,6,7,8,9,9,10,9,10,11,11,12,12,13,13,3,4,6,7,8,8,9,9,9,9,10,10,11,12,12,12, - 6,6,7,8,9,9,10,10,9,10,10,11,11,12,13,13,7,7,8,9,9,10,10,10,10,11,11,11,11,12, - 13,13,8,7,9,9,10,10,11,11,10,11,11,12,12,13,13,14,9,8,9,10,10,10,11,11,11,11, - 12,11,13,13,14,14,9,9,10,10,11,11,11,11,11,12,12,12,13,13,14,14,10,9,10,11,11, - 11,12,12,12,12,13,13,13,14,16,16,9,8,9,10,10,11,11,12,12,12,12,13,13,14,15,15, - 10,9,10,10,11,11,11,13,12,13,13,14,14,14,16,15,10,10,10,11,11,12,12,13,12,13, - 14,13,14,15,16,17,11,10,10,11,12,12,12,12,13,13,13,14,15,15,15,16,11,11,11,12, - 12,13,12,13,14,14,15,15,15,16,16,16,12,11,12,13,13,13,14,14,14,14,14,15,16,15, - 16,16,13,12,12,13,13,13,15,14,14,17,15,15,15,17,16,16,12,12,13,14,14,14,15,14, - 15,15,16,16,19,18,19,16}; - -static const uint8_t t15l_const[256] = -{3,4,5,7,7,8,9,9,9,10,10,11,11,11,12,13,4,3,5,6,7,7,8,8,8,9,9,10,10,10,11,11,5, - 5,5,6,7,7,8,8,8,9,9,10,10,11,11,11,6,6,6,7,7,8,8,9,9,9,10,10,10,11,11,11,7,6, - 7,7,8,8,9,9,9,9,10,10,10,11,11,11,8,7,7,8,8,8,9,9,9,9,10,10,11,11,11,12,9,7,8, - 8,8,9,9,9,9,10,10,10,11,11,12,12,9,8,8,9,9,9,9,10,10,10,10,10,11,11,11,12,9,8, - 8,9,9,9,9,10,10,10,10,11,11,12,12,12,9,8,9,9,9,9,10,10,10,11,11,11,11,12,12, - 12,10,9,9,9,10,10,10,10,10,11,11,11,11,12,13,12,10,9,9,9,10,10,10,10,11,11,11, - 11,12,12,12,13,11,10,9,10,10,10,11,11,11,11,11,11,12,12,13,13,11,10,10,10,10, - 11,11,11,11,12,12,12,12,12,13,13,12,11,11,11,11,11,11,11,12,12,12,12,13,13,12, - 13,12,11,11,11,11,11,11,12,12,12,12,12,13,13,13,13}; - -static const uint8_t t16l_const[256] = -{1,4,6,8,9,9,10,10,11,11,11,12,12,12,13,9,3,4,6,7,8,9,9,9,10,10,10,11,12,11,12, - 8,6,6,7,8,9,9,10,10,11,10,11,11,11,12,12,9,8,7,8,9,9,10,10,10,11,11,12,12,12, - 13,13,10,9,8,9,9,10,10,11,11,11,12,12,12,13,13,13,9,9,8,9,9,10,11,11,12,11,12, - 12,13,13,13,14,10,10,9,9,10,11,11,11,11,12,12,12,12,13,13,14,10,10,9,10,10,11, - 11,11,12,12,13,13,13,13,15,15,10,10,10,10,11,11,11,12,12,13,13,13,13,14,14,14, - 10,11,10,10,11,11,12,12,13,13,13,13,14,13,14,13,11,11,11,10,11,12,12,12,12,13, - 14,14,14,15,15,14,10,12,11,11,11,12,12,13,14,14,14,14,14,14,13,14,11,12,12,12, - 12,12,13,13,13,13,15,14,14,14,14,16,11,14,12,12,12,13,13,14,14,14,16,15,15,15, - 17,15,11,13,13,11,12,14,14,13,14,14,15,16,15,17,15,14,11,9,8,8,9,9,10,10,10, - 11,11,11,11,11,11,11,8}; - -static const uint8_t t24l_const[256] = -{4,4,6,7,8,9,9,10,10,11,11,11,11,11,12,9,4,4,5,6,7,8,8,9,9,9,10,10,10,10,10,8, - 6,5,6,7,7,8,8,9,9,9,9,10,10,10,11,7,7,6,7,7,8,8,8,9,9,9,9,10,10,10,10,7,8,7,7, - 8,8,8,8,9,9,9,10,10,10,10,11,7,9,7,8,8,8,8,9,9,9,9,10,10,10,10,10,7,9,8,8,8,8, - 9,9,9,9,10,10,10,10,10,11,7,10,8,8,8,9,9,9,9,10,10,10,10,10,11,11,8,10,9,9,9, - 9,9,9,9,9,10,10,10,10,11,11,8,10,9,9,9,9,9,9,10,10,10,10,10,11,11,11,8,11,9,9, - 9,9,10,10,10,10,10,10,11,11,11,11,8,11,10,9,9,9,10,10,10,10,10,10,11,11,11,11, - 8,11,10,10,10,10,10,10,10,10,10,11,11,11,11,11,8,11,10,10,10,10,10,10,10,11, - 11,11,11,11,11,11,8,12,10,10,10,10,10,10,11,11,11,11,11,11,11,11,8,8,7,7,7,7, - 7,7,7,7,7,7,8,8,8,8,4}; - -static const struct huffcodetab ht_const[HTN] = -{ { 0, NULL, NULL}, /* Apparently not used */ - { 2, t1HB, t1l}, - { 3, t2HB, t2l}, - { 3, t3HB, t3l}, - { 0, NULL, NULL}, /* Apparently not used */ - { 4, t5HB, t5l}, - { 4, t6HB, t6l}, - { 6, t7HB, t7l}, - { 6, t8HB, t8l}, - { 6, t9HB, t9l}, - { 8, t10HB, t10l}, - { 8, t11HB, t11l}, - { 8, t12HB, t12l}, - {16, t13HB, t13l}, - { 0, NULL, NULL}, /* Apparently not used */ - {16, t15HB, t15l} }; - -static const struct huffcodebig ht_big[HTN] = -{ { 16, 1, 1 }, - { 16, 2, 3 }, - { 16, 3, 7 }, - { 16, 4, 15 }, - { 16, 6, 63 }, - { 16, 8, 255 }, - { 16, 10, 1023 }, - { 16, 13, 8191 }, - { 16, 4, 15 }, - { 16, 5, 31 }, - { 16, 6, 63 }, - { 16, 7, 127 }, - { 16, 8, 255 }, - { 16, 9, 511 }, - { 16, 11, 2047 }, - { 16, 13, 8191 } }; - -static const struct -{ - uint32_t region0_cnt; - uint32_t region1_cnt; -} subdv_table[23] = -{ {0, 0}, /* 0 bands */ - {0, 0}, /* 1 bands */ - {0, 0}, /* 2 bands */ - {0, 0}, /* 3 bands */ - {0, 0}, /* 4 bands */ - {0, 1}, /* 5 bands */ - {1, 1}, /* 6 bands */ - {1, 1}, /* 7 bands */ - {1, 2}, /* 8 bands */ - {2, 2}, /* 9 bands */ - {2, 3}, /* 10 bands */ - {2, 3}, /* 11 bands */ - {3, 4}, /* 12 bands */ - {3, 4}, /* 13 bands */ - {3, 4}, /* 14 bands */ - {4, 5}, /* 15 bands */ - {4, 5}, /* 16 bands */ - {4, 6}, /* 17 bands */ - {5, 6}, /* 18 bands */ - {5, 6}, /* 19 bands */ - {5, 7}, /* 20 bands */ - {6, 7}, /* 21 bands */ - {6, 7}, /* 22 bands */ -}; - -static const uint32_t sfBand[6][23] = -{ -/* Table B.2.b: 22.05 kHz */ -{0,6,12,18,24,30,36,44,54,66,80,96,116,140,168,200,238,284,336,396,464,522,576}, -/* Table B.2.c: 24 kHz */ -{0,6,12,18,24,30,36,44,54,66,80,96,114,136,162,194,232,278,330,394,464,540,576}, -/* Table B.2.a: 16 kHz */ -{0,6,12,18,24,30,36,44,45,66,80,96,116,140,168,200,238,248,336,396,464,522,576}, -/* Table B.8.b: 44.1 kHz */ -{0,4, 8,12,16,20,24,30,36,44,52,62, 74, 90,110,134,162,196,238,288,342,418,576}, -/* Table B.8.c: 48 kHz */ -{0,4, 8,12,16,20,24,30,36,42,50,60, 72, 88,106,128,156,190,230,276,330,384,576}, -/* Table B.8.a: 32 kHz */ -{0,4, 8,12,16,20,24,30,36,44,54,66, 82,102,126,156,194,240,296,364,448,550,576} }; - - -static const short int2idx_const[4096] = /* int2idx[i] = sqrt(i*sqrt(i)); */ -{ - 0, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 6, 7, 7, 8, 8, 8, 9, 9, - 9, 10, 10, 11, 11, 11, 12, 12, 12, 12, 13, 13, 13, 14, 14, 14, 15, 15, 15, 16, - 16, 16, 16, 17, 17, 17, 18, 18, 18, 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, - 22, 22, 22, 22, 23, 23, 23, 23, 24, 24, 24, 24, 25, 25, 25, 25, 26, 26, 26, 26, - 27, 27, 27, 27, 28, 28, 28, 28, 29, 29, 29, 29, 30, 30, 30, 30, 31, 31, 31, 31, - 32, 32, 32, 32, 33, 33, 33, 33, 34, 34, 34, 34, 34, 35, 35, 35, 35, 36, 36, 36, - 36, 36, 37, 37, 37, 37, 38, 38, 38, 38, 38, 39, 39, 39, 39, 40, 40, 40, 40, 40, - 41, 41, 41, 41, 42, 42, 42, 42, 42, 43, 43, 43, 43, 44, 44, 44, 44, 44, 45, 45, - 45, 45, 45, 46, 46, 46, 46, 46, 47, 47, 47, 47, 47, 48, 48, 48, 48, 49, 49, 49, - 49, 49, 50, 50, 50, 50, 50, 51, 51, 51, 51, 51, 52, 52, 52, 52, 52, 53, 53, 53, - 53, 53, 54, 54, 54, 54, 54, 55, 55, 55, 55, 55, 56, 56, 56, 56, 56, 57, 57, 57, - 57, 57, 58, 58, 58, 58, 58, 58, 59, 59, 59, 59, 59, 60, 60, 60, 60, 60, 61, 61, - 61, 61, 61, 62, 62, 62, 62, 62, 62, 63, 63, 63, 63, 63, 64, 64, 64, 64, 64, 65, - 65, 65, 65, 65, 65, 66, 66, 66, 66, 66, 67, 67, 67, 67, 67, 68, 68, 68, 68, 68, - 68, 69, 69, 69, 69, 69, 70, 70, 70, 70, 70, 70, 71, 71, 71, 71, 71, 72, 72, 72, - 72, 72, 72, 73, 73, 73, 73, 73, 74, 74, 74, 74, 74, 74, 75, 75, 75, 75, 75, 75, - 76, 76, 76, 76, 76, 77, 77, 77, 77, 77, 77, 78, 78, 78, 78, 78, 78, 79, 79, 79, - 79, 79, 80, 80, 80, 80, 80, 80, 81, 81, 81, 81, 81, 81, 82, 82, 82, 82, 82, 82, - 83, 83, 83, 83, 83, 84, 84, 84, 84, 84, 84, 85, 85, 85, 85, 85, 85, 86, 86, 86, - 86, 86, 86, 87, 87, 87, 87, 87, 87, 88, 88, 88, 88, 88, 88, 89, 89, 89, 89, 89, - 89, 90, 90, 90, 90, 90, 90, 91, 91, 91, 91, 91, 91, 92, 92, 92, 92, 92, 92, 93, - 93, 93, 93, 93, 93, 94, 94, 94, 94, 94, 94, 95, 95, 95, 95, 95, 95, 96, 96, 96, - 96, 96, 96, 97, 97, 97, 97, 97, 97, 98, 98, 98, 98, 98, 98, 99, 99, 99, 99, 99, - 99, 99,100,100,100,100,100,100,101,101,101,101,101,101,102,102,102,102,102,102, -103,103,103,103,103,103,104,104,104,104,104,104,104,105,105,105,105,105,105,106, -106,106,106,106,106,107,107,107,107,107,107,107,108,108,108,108,108,108,109,109, -109,109,109,109,110,110,110,110,110,110,110,111,111,111,111,111,111,112,112,112, -112,112,112,112,113,113,113,113,113,113,114,114,114,114,114,114,115,115,115,115, -115,115,115,116,116,116,116,116,116,117,117,117,117,117,117,117,118,118,118,118, -118,118,118,119,119,119,119,119,119,120,120,120,120,120,120,120,121,121,121,121, -121,121,122,122,122,122,122,122,122,123,123,123,123,123,123,123,124,124,124,124, -124,124,125,125,125,125,125,125,125,126,126,126,126,126,126,126,127,127,127,127, -127,127,128,128,128,128,128,128,128,129,129,129,129,129,129,129,130,130,130,130, -130,130,131,131,131,131,131,131,131,132,132,132,132,132,132,132,133,133,133,133, -133,133,133,134,134,134,134,134,134,134,135,135,135,135,135,135,136,136,136,136, -136,136,136,137,137,137,137,137,137,137,138,138,138,138,138,138,138,139,139,139, -139,139,139,139,140,140,140,140,140,140,140,141,141,141,141,141,141,141,142,142, -142,142,142,142,142,143,143,143,143,143,143,143,144,144,144,144,144,144,144,145, -145,145,145,145,145,145,146,146,146,146,146,146,146,147,147,147,147,147,147,147, -148,148,148,148,148,148,148,149,149,149,149,149,149,149,150,150,150,150,150,150, -150,151,151,151,151,151,151,151,152,152,152,152,152,152,152,153,153,153,153,153, -153,153,154,154,154,154,154,154,154,154,155,155,155,155,155,155,155,156,156,156, -156,156,156,156,157,157,157,157,157,157,157,158,158,158,158,158,158,158,159,159, -159,159,159,159,159,160,160,160,160,160,160,160,160,161,161,161,161,161,161,161, -162,162,162,162,162,162,162,163,163,163,163,163,163,163,163,164,164,164,164,164, -164,164,165,165,165,165,165,165,165,166,166,166,166,166,166,166,167,167,167,167, -167,167,167,167,168,168,168,168,168,168,168,169,169,169,169,169,169,169,169,170, -170,170,170,170,170,170,171,171,171,171,171,171,171,172,172,172,172,172,172,172, -172,173,173,173,173,173,173,173,174,174,174,174,174,174,174,174,175,175,175,175, -175,175,175,176,176,176,176,176,176,176,176,177,177,177,177,177,177,177,178,178, -178,178,178,178,178,178,179,179,179,179,179,179,179,180,180,180,180,180,180,180, -180,181,181,181,181,181,181,181,182,182,182,182,182,182,182,182,183,183,183,183, -183,183,183,184,184,184,184,184,184,184,184,185,185,185,185,185,185,185,186,186, -186,186,186,186,186,186,187,187,187,187,187,187,187,187,188,188,188,188,188,188, -188,189,189,189,189,189,189,189,189,190,190,190,190,190,190,190,190,191,191,191, -191,191,191,191,192,192,192,192,192,192,192,192,193,193,193,193,193,193,193,193, -194,194,194,194,194,194,194,195,195,195,195,195,195,195,195,196,196,196,196,196, -196,196,196,197,197,197,197,197,197,197,197,198,198,198,198,198,198,198,199,199, -199,199,199,199,199,199,200,200,200,200,200,200,200,200,201,201,201,201,201,201, -201,201,202,202,202,202,202,202,202,202,203,203,203,203,203,203,203,204,204,204, -204,204,204,204,204,205,205,205,205,205,205,205,205,206,206,206,206,206,206,206, -206,207,207,207,207,207,207,207,207,208,208,208,208,208,208,208,208,209,209,209, -209,209,209,209,209,210,210,210,210,210,210,210,210,211,211,211,211,211,211,211, -211,212,212,212,212,212,212,212,212,213,213,213,213,213,213,213,213,214,214,214, -214,214,214,214,214,215,215,215,215,215,215,215,215,216,216,216,216,216,216,216, -216,217,217,217,217,217,217,217,217,218,218,218,218,218,218,218,218,219,219,219, -219,219,219,219,219,220,220,220,220,220,220,220,220,221,221,221,221,221,221,221, -221,222,222,222,222,222,222,222,222,223,223,223,223,223,223,223,223,224,224,224, -224,224,224,224,224,225,225,225,225,225,225,225,225,226,226,226,226,226,226,226, -226,227,227,227,227,227,227,227,227,228,228,228,228,228,228,228,228,229,229,229, -229,229,229,229,229,229,230,230,230,230,230,230,230,230,231,231,231,231,231,231, -231,231,232,232,232,232,232,232,232,232,233,233,233,233,233,233,233,233,234,234, -234,234,234,234,234,234,234,235,235,235,235,235,235,235,235,236,236,236,236,236, -236,236,236,237,237,237,237,237,237,237,237,238,238,238,238,238,238,238,238,238, -239,239,239,239,239,239,239,239,240,240,240,240,240,240,240,240,241,241,241,241, -241,241,241,241,242,242,242,242,242,242,242,242,242,243,243,243,243,243,243,243, -243,244,244,244,244,244,244,244,244,245,245,245,245,245,245,245,245,245,246,246, -246,246,246,246,246,246,247,247,247,247,247,247,247,247,248,248,248,248,248,248, -248,248,248,249,249,249,249,249,249,249,249,250,250,250,250,250,250,250,250,250, -251,251,251,251,251,251,251,251,252,252,252,252,252,252,252,252,253,253,253,253, -253,253,253,253,253,254,254,254,254,254,254,254,254,255,255,255,255,255,255,255, -255,255,256,256,256,256,256,256,256,256,257,257,257,257,257,257,257,257,257,258, -258,258,258,258,258,258,258,259,259,259,259,259,259,259,259,259,260,260,260,260, -260,260,260,260,261,261,261,261,261,261,261,261,261,262,262,262,262,262,262,262, -262,263,263,263,263,263,263,263,263,263,264,264,264,264,264,264,264,264,265,265, -265,265,265,265,265,265,265,266,266,266,266,266,266,266,266,267,267,267,267,267, -267,267,267,267,268,268,268,268,268,268,268,268,268,269,269,269,269,269,269,269, -269,270,270,270,270,270,270,270,270,270,271,271,271,271,271,271,271,271,271,272, -272,272,272,272,272,272,272,273,273,273,273,273,273,273,273,273,274,274,274,274, -274,274,274,274,275,275,275,275,275,275,275,275,275,276,276,276,276,276,276,276, -276,276,277,277,277,277,277,277,277,277,277,278,278,278,278,278,278,278,278,279, -279,279,279,279,279,279,279,279,280,280,280,280,280,280,280,280,280,281,281,281, -281,281,281,281,281,282,282,282,282,282,282,282,282,282,283,283,283,283,283,283, -283,283,283,284,284,284,284,284,284,284,284,284,285,285,285,285,285,285,285,285, -286,286,286,286,286,286,286,286,286,287,287,287,287,287,287,287,287,287,288,288, -288,288,288,288,288,288,288,289,289,289,289,289,289,289,289,289,290,290,290,290, -290,290,290,290,291,291,291,291,291,291,291,291,291,292,292,292,292,292,292,292, -292,292,293,293,293,293,293,293,293,293,293,294,294,294,294,294,294,294,294,294, -295,295,295,295,295,295,295,295,295,296,296,296,296,296,296,296,296,296,297,297, -297,297,297,297,297,297,297,298,298,298,298,298,298,298,298,299,299,299,299,299, -299,299,299,299,300,300,300,300,300,300,300,300,300,301,301,301,301,301,301,301, -301,301,302,302,302,302,302,302,302,302,302,303,303,303,303,303,303,303,303,303, -304,304,304,304,304,304,304,304,304,305,305,305,305,305,305,305,305,305,306,306, -306,306,306,306,306,306,306,307,307,307,307,307,307,307,307,307,308,308,308,308, -308,308,308,308,308,309,309,309,309,309,309,309,309,309,310,310,310,310,310,310, -310,310,310,311,311,311,311,311,311,311,311,311,312,312,312,312,312,312,312,312, -312,313,313,313,313,313,313,313,313,313,314,314,314,314,314,314,314,314,314,315, -315,315,315,315,315,315,315,315,316,316,316,316,316,316,316,316,316,317,317,317, -317,317,317,317,317,317,318,318,318,318,318,318,318,318,318,318,319,319,319,319, -319,319,319,319,319,320,320,320,320,320,320,320,320,320,321,321,321,321,321,321, -321,321,321,322,322,322,322,322,322,322,322,322,323,323,323,323,323,323,323,323, -323,324,324,324,324,324,324,324,324,324,325,325,325,325,325,325,325,325,325,325, -326,326,326,326,326,326,326,326,326,327,327,327,327,327,327,327,327,327,328,328, -328,328,328,328,328,328,328,329,329,329,329,329,329,329,329,329,330,330,330,330, -330,330,330,330,330,330,331,331,331,331,331,331,331,331,331,332,332,332,332,332, -332,332,332,332,333,333,333,333,333,333,333,333,333,334,334,334,334,334,334,334, -334,334,335,335,335,335,335,335,335,335,335,335,336,336,336,336,336,336,336,336, -336,337,337,337,337,337,337,337,337,337,338,338,338,338,338,338,338,338,338,338, -339,339,339,339,339,339,339,339,339,340,340,340,340,340,340,340,340,340,341,341, -341,341,341,341,341,341,341,341,342,342,342,342,342,342,342,342,342,343,343,343, -343,343,343,343,343,343,344,344,344,344,344,344,344,344,344,344,345,345,345,345, -345,345,345,345,345,346,346,346,346,346,346,346,346,346,347,347,347,347,347,347, -347,347,347,347,348,348,348,348,348,348,348,348,348,349,349,349,349,349,349,349, -349,349,350,350,350,350,350,350,350,350,350,350,351,351,351,351,351,351,351,351, -351,352,352,352,352,352,352,352,352,352,352,353,353,353,353,353,353,353,353,353, -354,354,354,354,354,354,354,354,354,355,355,355,355,355,355,355,355,355,355,356, -356,356,356,356,356,356,356,356,357,357,357,357,357,357,357,357,357,357,358,358, -358,358,358,358,358,358,358,359,359,359,359,359,359,359,359,359,359,360,360,360, -360,360,360,360,360,360,361,361,361,361,361,361,361,361,361,361,362,362,362,362, -362,362,362,362,362,363,363,363,363,363,363,363,363,363,363,364,364,364,364,364, -364,364,364,364,365,365,365,365,365,365,365,365,365,365,366,366,366,366,366,366, -366,366,366,367,367,367,367,367,367,367,367,367,367,368,368,368,368,368,368,368, -368,368,369,369,369,369,369,369,369,369,369,369,370,370,370,370,370,370,370,370, -370,370,371,371,371,371,371,371,371,371,371,372,372,372,372,372,372,372,372,372, -372,373,373,373,373,373,373,373,373,373,374,374,374,374,374,374,374,374,374,374, -375,375,375,375,375,375,375,375,375,375,376,376,376,376,376,376,376,376,376,377, -377,377,377,377,377,377,377,377,377,378,378,378,378,378,378,378,378,378,379,379, -379,379,379,379,379,379,379,379,380,380,380,380,380,380,380,380,380,380,381,381, -381,381,381,381,381,381,381,382,382,382,382,382,382,382,382,382,382,383,383,383, -383,383,383,383,383,383,383,384,384,384,384,384,384,384,384,384,385,385,385,385, -385,385,385,385,385,385,386,386,386,386,386,386,386,386,386,386,387,387,387,387, -387,387,387,387,387,387,388,388,388,388,388,388,388,388,388,389,389,389,389,389, -389,389,389,389,389,390,390,390,390,390,390,390,390,390,390,391,391,391,391,391, -391,391,391,391,391,392,392,392,392,392,392,392,392,392,393,393,393,393,393,393, -393,393,393,393,394,394,394,394,394,394,394,394,394,394,395,395,395,395,395,395, -395,395,395,395,396,396,396,396,396,396,396,396,396,397,397,397,397,397,397,397, -397,397,397,398,398,398,398,398,398,398,398,398,398,399,399,399,399,399,399,399, -399,399,399,400,400,400,400,400,400,400,400,400,400,401,401,401,401,401,401,401, -401,401,402,402,402,402,402,402,402,402,402,402,403,403,403,403,403,403,403,403, -403,403,404,404,404,404,404,404,404,404,404,404,405,405,405,405,405,405,405,405, -405,405,406,406,406,406,406,406,406,406,406,406,407,407,407,407,407,407,407,407, -407,407,408,408,408,408,408,408,408,408,408,408,409,409,409,409,409,409,409,409, -409,410,410,410,410,410,410,410,410,410,410,411,411,411,411,411,411,411,411,411, -411,412,412,412,412,412,412,412,412,412,412,413,413,413,413,413,413,413,413,413, -413,414,414,414,414,414,414,414,414,414,414,415,415,415,415,415,415,415,415,415, -415,416,416,416,416,416,416,416,416,416,416,417,417,417,417,417,417,417,417,417, -417,418,418,418,418,418,418,418,418,418,418,419,419,419,419,419,419,419,419,419, -419,420,420,420,420,420,420,420,420,420,420,421,421,421,421,421,421,421,421,421, -421,422,422,422,422,422,422,422,422,422,422,423,423,423,423,423,423,423,423,423, -423,424,424,424,424,424,424,424,424,424,424,425,425,425,425,425,425,425,425,425, -425,426,426,426,426,426,426,426,426,426,426,427,427,427,427,427,427,427,427,427, -427,428,428,428,428,428,428,428,428,428,428,429,429,429,429,429,429,429,429,429, -429,430,430,430,430,430,430,430,430,430,430,431,431,431,431,431,431,431,431,431, -431,432,432,432,432,432,432,432,432,432,432,433,433,433,433,433,433,433,433,433, -433,434,434,434,434,434,434,434,434,434,434,435,435,435,435,435,435,435,435,435, -435,435,436,436,436,436,436,436,436,436,436,436,437,437,437,437,437,437,437,437, -437,437,438,438,438,438,438,438,438,438,438,438,439,439,439,439,439,439,439,439, -439,439,440,440,440,440,440,440,440,440,440,440,441,441,441,441,441,441,441,441, -441,441,442,442,442,442,442,442,442,442,442,442,443,443,443,443,443,443,443,443, -443,443,443,444,444,444,444,444,444,444,444,444,444,445,445,445,445,445,445,445, -445,445,445,446,446,446,446,446,446,446,446,446,446,447,447,447,447,447,447,447, -447,447,447,448,448,448,448,448,448,448,448,448,448,448,449,449,449,449,449,449, -449,449,449,449,450,450,450,450,450,450,450,450,450,450,451,451,451,451,451,451, -451,451,451,451,452,452,452,452,452,452,452,452,452,452,453,453,453,453,453,453, -453,453,453,453,453,454,454,454,454,454,454,454,454,454,454,455,455,455,455,455, -455,455,455,455,455,456,456,456,456,456,456,456,456,456,456,457,457,457,457,457, -457,457,457,457,457,457,458,458,458,458,458,458,458,458,458,458,459,459,459,459, -459,459,459,459,459,459,460,460,460,460,460,460,460,460,460,460,460,461,461,461, -461,461,461,461,461,461,461,462,462,462,462,462,462,462,462,462,462,463,463,463, -463,463,463,463,463,463,463,463,464,464,464,464,464,464,464,464,464,464,465,465, -465,465,465,465,465,465,465,465,466,466,466,466,466,466,466,466,466,466,466,467, -467,467,467,467,467,467,467,467,467,468,468,468,468,468,468,468,468,468,468,469, -469,469,469,469,469,469,469,469,469,469,470,470,470,470,470,470,470,470,470,470, -471,471,471,471,471,471,471,471,471,471,472,472,472,472,472,472,472,472,472,472, -472,473,473,473,473,473,473,473,473,473,473,474,474,474,474,474,474,474,474,474, -474,475,475,475,475,475,475,475,475,475,475,475,476,476,476,476,476,476,476,476, -476,476,477,477,477,477,477,477,477,477,477,477,477,478,478,478,478,478,478,478, -478,478,478,479,479,479,479,479,479,479,479,479,479,479,480,480,480,480,480,480, -480,480,480,480,481,481,481,481,481,481,481,481,481,481,482,482,482,482,482,482, -482,482,482,482,482,483,483,483,483,483,483,483,483,483,483,484,484,484,484,484, -484,484,484,484,484,484,485,485,485,485,485,485,485,485,485,485,486,486,486,486, -486,486,486,486,486,486,486,487,487,487,487,487,487,487,487,487,487,488,488,488, -488,488,488,488,488,488,488,488,489,489,489,489,489,489,489,489,489,489,490,490, -490,490,490,490,490,490,490,490,490,491,491,491,491,491,491,491,491,491,491,492, -492,492,492,492,492,492,492,492,492,492,493,493,493,493,493,493,493,493,493,493, -494,494,494,494,494,494,494,494,494,494,494,495,495,495,495,495,495,495,495,495, -495,496,496,496,496,496,496,496,496,496,496,496,497,497,497,497,497,497,497,497, -497,497,497,498,498,498,498,498,498,498,498,498,498,499,499,499,499,499,499,499, -499,499,499,499,500,500,500,500,500,500,500,500,500,500,501,501,501,501,501,501, -501,501,501,501,501,502,502,502,502,502,502,502,502,502,502,503,503,503,503,503, -503,503,503,503,503,503,504,504,504,504,504,504,504,504,504,504,504,505,505,505, -505,505,505,505,505,505,505,506,506,506,506,506,506,506,506,506,506,506,507,507, -507,507,507,507,507,507,507,507,507,508,508,508,508,508,508,508,508,508,508,509, -509,509,509,509,509,509,509,509,509,509,510,510,510,510,510,510,510,510,510,510, -510,511,511,511,511,511,511,511,511,511,511,512,512,512,512,512 }; - -static const int order[32] = -{ 0, 1, 16, 17, 8, 9, 24, 25, 4, 5, 20, 21, 12, 13, 28, 29, - 2, 3, 18, 19,10,11, 26, 27, 6, 7, 22, 23, 14, 15, 30, 31 }; - -static const long sampr_index[2][3] = -{ { 22050, 24000, 16000 }, /* MPEG 2 */ - { 44100, 48000, 32000 } }; /* MPEG 1 */ - -static const long bitr_index[2][15] = -{ {0, 8,16,24,32,40,48,56, 64, 80, 96,112,128,144,160}, /* MPEG 2 */ - {0,32,40,48,56,64,80,96,112,128,160,192,224,256,320} }; /* MPEG 1 */ - -static const int num_bands[3][15] = -{ {0,10,10,10,10,12,14,16, 20, 22, 24, 26, 28, 30, 32}, - {0,10,10,10,10,10,12,14, 18, 24, 26, 28, 30, 32, 32}, - {0,10,12,14,18,24,26,28, 30, 32, 32, 32, 32, 32, 32} }; - -static const int cx_const[9] = -{ 16135, 10531, 5604, 15396, -2845,-12551, 14189, 8192, 16384 }; - -static const int ca_const[8] = -{-16859,-15458,-10269, -5961, -3099, -1342, -465, -121 }; - -static const int cs_const[8] = -{ 28098, 28893, 31117, 32221, 32621, 32740, 32765, 32768 }; - -static const short enwindow_const[15*27+24] = -{ 0, 65, 593, 1766, 22228, 2115, 611, 62, - 8, 119, 1419, 10564,-11659,-1635,-154, -9, - -8, -119,-1419,-10564, 11659, 1635, 154, 9, 464, 100, 91, - 0, 69, 604, 1635, 23148, 2363, 643, 62, - 7, 107, 1368, 10449,-12733,-1818,-180,-11, - -7, -107,-1368,-10449, 12733, 1818, 180, 11, 420, 200, 164, - 0, 72, 608, 1465, 23979, 2600, 671, 63, - 7, 94, 1305, 10265,-13818,-2004,-207,-12, - -7, -94,-1305,-10265, 13818, 2004, 207, 12, 380, 297, 220, - 0, 76, 606, 1256, 24718, 2825, 693, 63, - 6, 81, 1232, 10016,-14908,-2192,-236,-14, - -6, -81,-1232,-10016, 14908, 2192, 236, 14, 342, 392, 262, - 0, 78, 597, 1007, 25359, 3033, 712, 63, - 6, 68, 1150, 9706,-15995,-2380,-267,-15, - -6, -68,-1150, -9706, 15995, 2380, 267, 15, 307, 483, 289, - 0, 80, 580, 719, 25901, 3224, 726, 62, - 6, 54, 1060, 9343,-17072,-2565,-299,-17, - -6, -54,-1060, -9343, 17072, 2565, 299, 17, 274, 569, 304, - -1, 82, 555, 391, 26339, 3395, 735, 61, - 5, 40, 963, 8930,-18131,-2747,-332,-19, - -5, -40, -963, -8930, 18131, 2747, 332, 19, 242, 650, 307, - -1, 83, 523, 26, 26672, 3545, 740, 60, - 5, 27, 861, 8474,-19164,-2923,-366,-21, - -5, -27, -861, -8474, 19164, 2923, 366, 21, 212, 724, 300, - -1, 83, 482, -376, 26900, 3672, 739, 58, - 4, 14, 756, 7981,-20163,-3092,-401,-24, - -4, -14, -756, -7981, 20163, 3092, 401, 24, 183, 792, 283, - -1, 82, 433, -812, 27022, 3776, 735, 56, - 4, 1, 648, 7456,-21122,-3250,-435,-26, - -4, -1, -648, -7456, 21122, 3250, 435, 26, 155, 851, 258, - -1, 81, 376, -1281, 27038, 3855, 726, 54, - 3, -11, 539, 6907,-22032,-3397,-470,-28, - -3, 11, -539, -6907, 22032, 3397, 470, 28, 128, 903, 226, - -1, 78, 312, -1778, 26951, 3910, 713, 52, - 3, -22, 430, 6338,-22887,-3530,-503,-31, - -3, 22, -430, -6338, 22887, 3530, 503, 31, 102, 946, 188, - -2, 75, 239, -2302, 26761, 3941, 696, 49, - 3, -33, 322, 5757,-23678,-3648,-537,-34, - -3, 33, -322, -5757, 23678, 3648, 537, 34, 76, 980, 145, - -2, 70, 160, -2848, 26472, 3948, 676, 47, - 3, -42, 217, 5167,-24399,-3749,-568,-36, - -3, 42, -217, -5167, 24399, 3749, 568, 36, 50, 1004, 99, - -2, 65, 74, -3412, 26087, 3931, 653, 44, - 2, -51, 115, 4577,-25045,-3830,-599,-39, - -2, 51, -115, -4577, 25045, 3830, 599, 39, 25, 1019, 50, - - 25610,3891,627,42,-3990,-18,58,-2, - 21226,-21226,10604,-10604,1860,-1860,1458,-1458,576,-576,130,-130,60,-60,8,-8 -}; - -static const int win_const[18][4] = { - { -3072, -134, -146, 3352 }, - { -2747, -362, -471, 3579 }, - { -2387, -529, -831, 3747 }, - { -2004, -632,-1214, 3850 }, - { -1609, -666,-1609, 3884 }, - { -1214, -632,-2004, 3850 }, - { -831, -529,-2387, 3747 }, - { -471, -362,-2747, 3579 }, - { -146, -134,-3072, 3352 }, - { 134,-3072,-3352, -146 }, - { 362,-2747,-3579, -471 }, - { 529,-2387,-3747, -831 }, - { 632,-2004,-3850,-1214 }, - { 666,-1609,-3884,-1609 }, - { 632,-1214,-3850,-2004 }, - { 529, -831,-3747,-2387 }, - { 362, -471,-3579,-2747 }, - { 134, -146,-3352,-3072 } }; - -/* forward declarations */ -static int HuffmanCode( short *ix, char *xr_sign, uint32_t begin, uint32_t end, int table); -static int HuffmanCod1( short *ix, char *xr_sign, uint32_t begin, uint32_t end, int table); -static void putbits(uint32_t val, uint32_t nbit); -static int find_best_2( short *ix, uint32_t start, uint32_t end, const uint32_t *table, - uint32_t len, int *bits); -static int find_best_3( short *ix, uint32_t start, uint32_t end, const uint32_t *table, - uint32_t len, int *bits); -static int count_bit1 ( short *ix, uint32_t start, uint32_t end, int *bits ); -static int count_bigv ( short *ix, uint32_t start, uint32_t end, int table0, int table1, - int *bits); - - -static void encodeSideInfo( side_info_t si[2][2] ) -{ - int gr, ch, header; - uint32_t cc=0, sz=0; - - /* - * MPEG header layout: - * AAAAAAAA AAABBCCD EEEEFFGH IIJJKLMM - * A (31-21) = frame sync - * B (20-19) = MPEG type - * C (18-17) = MPEG layer - * D (16) = protection bit - * E (15-12) = bitrate index - * F (11-10) = samplerate index - * G (9) = padding bit - * H (8) = private bit - * I (7-6) = channel mode - * J (5-4) = mode extension (jstereo only) - * K (3) = copyright bit - * L (2) = original - * M (1-0) = emphasis - */ - - header = (0xfff00000) | /* frame sync (AAAAAAAAA AAA) - mp3 type (upper): 1 (B) */ - (0x01 << 17) | /* mp3 layer: 01 (CC) */ - ( 0x1 << 16) | /* mp3 crc: 1 (D) */ - ( 0x1 << 2); /* mp3 org: 1 (L) */ - header |= cfg.mpg.type << 19; - header |= cfg.mpg.bitr_id << 12; - header |= cfg.mpg.smpl_id << 10; - header |= cfg.mpg.padding << 9; - header |= cfg.mpg.mode << 6; - /* no emphasis (bits 0-1) */ - putbits( header, 32 ); - - if(cfg.mpg.type == 1) - { /* MPEG1 */ - if(cfg.channels == 2) { putlong( 0, 20); } - else { putlong( 0, 18); } - - for(gr=0; grpart2_3_length+42),12 ); /* add scale_facs array size */ - putlong( gi->address3>>1, 9 ); - putlong( gi->global_gain, 8 ); - putlong( 9, 4 ); /* set scale_facs compr type */ - putlong( gi->table_select[0], 6 ); - putlong( gi->table_select[1], 5 ); - putlong( gi->table_select[2], 5 ); - putlong( gi->region_0_1, 7 ); - putlong( 1 , 2 ); /* set scale_facs to 1bit */ - putlong( gi->table_select[3], 1 ); - } - } - else - { /* MPEG2 */ - if(cfg.channels == 2) { putlong( 0, 10); } - else { putlong( 0, 9); } - - for(ch=0; chpart2_3_length+42),12 ); /* add scale_facs array size */ - putlong( gi->address3>>1, 9 ); - putlong( gi->global_gain, 8 ); - putlong( 0xCA, 9 ); /* set scale_facs compr type */ - putlong( gi->table_select[0], 6 ); - putlong( gi->table_select[1], 5 ); - putlong( gi->table_select[2], 5 ); - putlong( gi->region_0_1 , 7 ); - putlong( 1 , 1 ); /* set scale_facs to 1bit */ - putlong( gi->table_select[3], 1 ); - } - } - /* flush remaining bits */ - putbits(cc, sz); -} - -/* Note the discussion of huffmancodebits() on pages 28 and 29 of the IS, - as well as the definitions of the side information on pages 26 and 27. */ -static void Huffmancodebits( short *ix, char *xr_sign, side_info_t *gi ) -{ - int region1 = gi->address1; - int region2 = gi->address2; - int bigvals = gi->address3; - int count1 = bigvals + (gi->count1 << 2); - int stuffBits = 0; - int bits = 0; - int i, v; - - for(i=v=0; i<32; i+=2) - v |= band_scale_f[i>>1] << (30-i); - putbits(v, 32); // store scale_facs (part1) - - for(v=0; i<42; i+=2) - v |= band_scale_f[i>>1] << (40-i); - putbits(v, 10); // store scale_facs (part2) - - if(region1 > 0) - bits += HuffmanCode(ix, xr_sign, 0 , region1, gi->table_select[0]); - - if(region2 > region1) - bits += HuffmanCode(ix, xr_sign, region1, region2, gi->table_select[1]); - - if(bigvals > region2) - bits += HuffmanCode(ix, xr_sign, region2, bigvals, gi->table_select[2]); - - if(count1 > bigvals) - bits += HuffmanCod1(ix, xr_sign, bigvals, count1, gi->table_select[3]); - - if((stuffBits = gi->part2_3_length - bits) > 0) - { - int stuffWords = stuffBits >> 5; - int remainBits = stuffBits & 31; - - if( remainBits ) - putbits( ~0, remainBits ); - - while( stuffWords-- ) - putbits( ~0, 32 ); /* Huffman code tables leed to padding ones */ - } -} - -int HuffmanCod1( short *ix, char *xr_sign, uint32_t begin, uint32_t end, int tbl) -{ - uint32_t cc=0, sz=0; - uint32_t i, d, p; - int sumbit=0, s=0, l=0, v, w, x, y; - #define sgnv xr_sign[i+0] - #define sgnw xr_sign[i+1] - #define sgnx xr_sign[i+2] - #define sgny xr_sign[i+3] - - for(i=begin; i 15 ) - { /* ESC-table is used */ - uint32_t linbits = ht_big[table-16].linbits; - uint16_t *hffcode = table < 24 ? t16HB : t24HB; - uint8_t *hlen = table < 24 ? t16l : t24l; - - for(i=begin; i 14) { xl = x - 15; x = 15; } - if(y > 14) { yl = y - 15; y = 15; } - - idx = x * 16 + y; - code = hffcode[idx]; - bit = hlen [idx]; - - if(x) - { - if(x > 14) - { - code = (code << linbits) | xl; - bit += linbits; - } - - code = (code << 1) | sign_x; - bit += 1; - } - - if(y) - { - if(y > 14) - { - if(bit + linbits + 1 > 32) - { - putlong( code, bit ); - sumbit += bit; - code = bit = 0; - } - - code = (code << linbits) | yl; - bit += linbits; - } - - code = (code << 1) | sign_y; - bit += 1; - } - - putlong( code, bit ); - sumbit += bit; - } - } - else - { /* No ESC-words */ - const struct huffcodetab *h = &ht[table]; - - for(i=begin; ilen + y; - code = h->table[idx]; - bit = h->hlen [idx]; - - if(x) - { - code = (code << 1) | sign_x; - bit += 1; - } - - if(y) - { - code = (code << 1) | sign_y; - bit += 1; - } - - putlong( code, bit ); - sumbit += bit; - } - } - - /* flush remaining bits */ - putbits(cc, sz); - - return sumbit; -} - -void putbits(uint32_t val, uint32_t nbit) -{ - int new_bitpos = CodedData.bitpos + nbit; - int ptrpos = CodedData.bitpos >> 5; - - val = val & (0xffffffff >> (32 - nbit)); - - /* data fit in one uint32_t */ - if(((new_bitpos - 1) >> 5) == ptrpos) - CodedData.bbuf[ptrpos] |= val << ((32 - new_bitpos) & 31); - else - { - CodedData.bbuf[ptrpos ] |= val >> ((new_bitpos - 32) & 31); - CodedData.bbuf[ptrpos+1] |= val << ((32 - new_bitpos) & 31); - } - - CodedData.bitpos = new_bitpos; -} - -/***************************************************************************/ -/* Choose the Huffman table that will encode ix[begin..end] with */ -/* the fewest bits. */ -/* Note: This code contains knowledge about the sizes and characteristic */ -/* of the Huffman tables as defined in the IS (Table B.7), and will not */ -/* work with any arbitrary tables. */ -/***************************************************************************/ -static int choose_table( short *ix, uint32_t begin, uint32_t end, int *bits ) -{ - uint32_t i; - int max, table0, table1; - - for(i=begin,max=0; i max) - max = ix[i]; - - if(max < 16) - { - /* tables without linbits */ - /* indx: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 */ - /* len: 0, 2, 3, 3, 0, 4, 4, 6, 6, 6, 8, 8, 8, 16, 0, 16 */ - switch(max) - { - case 0: return 0; - case 1: return count_bit1(ix, begin, end, bits); - case 2: return 2 + find_best_2(ix, begin, end, tab23, 3, bits); - case 3: return 5 + find_best_2(ix, begin, end, tab56, 4, bits); - case 4: - case 5: return 7 + find_best_3(ix, begin, end, tab789, 6, bits); - case 6: - case 7: return 10 + find_best_3(ix, begin, end, tabABC, 8, bits); - default: return 13 + find_best_2(ix, begin, end, tab1315, 16, bits) * 2; - } - } - else - { - /* tables with linbits */ - max -= 15; - - for(table0=0; table0<8; table0++) - if(ht_big[table0].linmax >= max) - break; - - for(table1=8; table1<16; table1++) - if(ht_big[table1].linmax >= max) - break; - - return 16 + count_bigv(ix, begin, end, table0, table1, bits); - } -} - -int find_best_2(short *ix, uint32_t start, uint32_t end, const uint32_t *table, - uint32_t len, int *bits) -{ - uint32_t i, sum = 0; - - for(i=start; i> 16)) - { - *bits = (sum & 0xffff); - return 1; - } - else - { - *bits = sum >> 16; - return 0; - } -} - -int find_best_3(short *ix, uint32_t start, uint32_t end, const uint32_t *table, - uint32_t len, int *bits) -{ - uint32_t i, j, sum = 0; - int sum1 = 0; - int sum2 = 0; - int sum3 = 0; - - /* avoid overflow in packed additions: 78*13 < 1024 */ - for(i=start; i end ? end : i + 2*78; - - for(sum=0; i> 20); - sum2 += (sum >> 10) & 0x3ff; - sum3 += (sum >> 0) & 0x3ff; - } - - i = 0; - if(sum1 > sum2) { sum1 = sum2; i = 1; } - if(sum1 > sum3) { sum1 = sum3; i = 2; } - - *bits = sum1; - - return i; -} - -/*************************************************************************/ -/* Function: Count the number of bits necessary to code the subregion. */ -/*************************************************************************/ -int count_bit1(short *ix, uint32_t start, uint32_t end, int *bits ) -{ - uint32_t i, sum = 0; - - for(i=start; i 14) { x = 15; bigv++; } - if(y > 14) { y = 15; bigv++; } - - sum += tab1624[x * 16 + y]; - } - - sum0 = (sum >> 16) + bigv * ht_big[table0].linbits; - sum1 = (sum & 0xffff) + bigv * ht_big[table1].linbits; - - if(sum0 <= sum1) - { - *bits = sum0; - return table0; - } - else - { - *bits = sum1; - return table1; - } -} - -/*************************************************************************/ -/* Function: Calculation of rzero, count1, address3 */ -/* (Partitions ix into big values, quadruples and zeros). */ -/*************************************************************************/ -static int calc_runlen( short *ix, side_info_t *si ) -{ - int p, i, sum = 0; - - for(i=SAMPL2; i-=2; ) - if(*(uint32_t*)&ix[i-2]) /* !!!! short *ix; !!!!! */ - break; - - si->count1 = 0; - - for( ; i>3; i-=4) - { - int v = ix[i-1]; - int w = ix[i-2]; - int x = ix[i-3]; - int y = ix[i-4]; - - if((v | w | x | y) <= 1) - { - p = (y<<3) + (x<<2) + (w<<1) + (v); - - sum += tab01[p]; - - si->count1++; - } - else break; - } - - si->address3 = i; - - if((sum >> 16) < (sum & 0xffff)) - { - si->table_select[3] = 0; - return sum >> 16; - } - else - { - si->table_select[3] = 1; - return sum & 0xffff; - } -} - - -/*************************************************************************/ -/* Function: Quantization of the vector xr ( -> ix) */ -/*************************************************************************/ -static int quantize_int(int *xr, short *ix, side_info_t *si) -{ - unsigned int i, idx, s, frac_pow[] = { 0x10000, 0xd745, 0xb505, 0x9838 }; - - s = frac_pow[si->quantStep & 3] >> si->quantStep / 4; - - /* check for possible 'out of range' values */ - if(((si->max_val + 256) >> 8) * s >= (65536 << 8)) - return 0; - - if(((si->max_val + 256) >> 8) * s < (4096 << 8)) - { /* all values fit the table size */ - for(i=SAMPL2; i--; ) - ix[i] = int2idx[(xr[i] * s + 0x8000) >> 16]; - } - else - { /* check each index wether it fits the table */ - for(i=SAMPL2; i--; ) - { - idx = (xr[i] * s + 0x08000) >> 16; - - if(idx > 4095) ix[i] = int2idx[(idx + 8) >> 4] << 3; - else ix[i] = int2idx[idx]; - } - } - - return 1; -} - -/*************************************************************************/ -/* subdivides the bigvalue region which will use separate Huffman tables */ -/*************************************************************************/ -static void subdivide(side_info_t *si) -{ - int scfb, count0, count1; - - if( !si->address3 ) - { /* no bigvalue region */ - si->region_0_1 = 0; - si->address1 = 0; - si->address2 = 0; - } - else - { - /* Calculate scale factor band index */ - for(scfb=0; scalefac[scfb] < si->address3; ) - scfb++; - - count0 = subdv_table[scfb].region0_cnt; - count1 = subdv_table[scfb].region1_cnt; - - si->region_0_1 = (count0 << 3) | count1; - si->address1 = scalefac[count0 + 1]; - si->address2 = scalefac[count0 + 1 + count1 + 1]; - } -} - -/*******************************************************************/ -/* Count the number of bits necessary to code the bigvalues region */ -/*******************************************************************/ -static int bigv_bitcount(short *ix, side_info_t *gi) -{ - int b1=0, b2=0, b3=0; - - /* Select huffman code tables for bigvalues regions */ - gi->table_select[0] = 0; - gi->table_select[1] = 0; - gi->table_select[2] = 0; - - if( gi->address1 > 0 ) /* region0 */ - gi->table_select[0] = choose_table(ix, 0 , gi->address1, &b1); - - if( gi->address2 > gi->address1 ) /* region1 */ - gi->table_select[1] = choose_table(ix, gi->address1, gi->address2, &b2); - - if( gi->address3 > gi->address2 ) /* region2 */ - gi->table_select[2] = choose_table(ix, gi->address2, gi->address3, &b3); - - return b1+b2+b3; -} - -static int quantize_and_count_bits(int *xr, short *ix, side_info_t *si) -{ - int bits = 10000; - - if(quantize_int(xr, ix, si)) - { - bits = calc_runlen(ix, si); /* rzero,count1,address3 */ - subdivide(si); /* bigvalues sfb division */ - bits += bigv_bitcount(ix,si); /* bit count */ - } - - return bits; -} - -/************************************************************************/ -/* The code selects the best quantStep for a particular set of scalefacs*/ -/************************************************************************/ -static int inner_loop(int *xr, int max_bits, side_info_t *si) -{ - int bits; - - while((bits=quantize_and_count_bits(xr, enc_data, si)) < max_bits-64) - { - if(si->quantStep == 0) - break; - - if(si->quantStep <= 2) - si->quantStep = 0; - else - si->quantStep -= 2; - } - - while(bits > max_bits) - { - si->quantStep++; - bits = quantize_and_count_bits(xr, enc_data, si); - } - - return bits; -} - -static void iteration_loop(int *xr, side_info_t *si, int gr_cnt) -{ - int remain, tar_bits, max_bits = cfg.mean_bits; - - /* distribute reserved bits to remaining granules */ - tar_bits = max_bits + (cfg.ResvSize / gr_cnt & ~7); - if(tar_bits > max_bits + max_bits/2) - tar_bits = max_bits + max_bits/2; - - si->part2_3_length = inner_loop(xr, tar_bits, si); - si->global_gain = si->quantStep + 142 - si->additStep; - - /* unused bits of the reservoir can be used for remaining granules */ - cfg.ResvSize += max_bits - si->part2_3_length; - - /* end: distribute the reserved bits to one or two granules */ - if(gr_cnt == 1) - { - si->part2_3_length += cfg.ResvSize; - /* mp3 format allows max 12bits for granule length */ - if(si->part2_3_length > 4092) - { - remain = (si->part2_3_length - 4092 + 31) >> 5; - si->part2_3_length -= remain << 5; - si[-1].part2_3_length += remain << 5; - - while(remain--) - putbits(~0, 32); - } - } -} - - -/* returns sum_j=0^31 a[j]*cos(PI*j*(k+1/2)/32), 0<=k<32 */ -void window_subband1(short *wk, int sb0[SBLIMIT], int sb1[SBLIMIT]) ICODE_ATTR; -void window_subband1(short *wk, int sb0[SBLIMIT], int sb1[SBLIMIT]) -{ - int k, i, u, v; - short *wp, *x1, *x2; - -#ifdef CPU_COLDFIRE - int s0, s1, t0, t1; - - for(k=0; k<18; k++, wk+=64, sb0+=SBLIMIT, sb1+=SBLIMIT) - { - wp = enwindow; - x1 = wk; - x2 = x1 - 124; - - for(i=-15; i<0; i++) - { - asm volatile( - "move.l (-224*4,%[x2]), %%d4\n" /* d4 = x2[-224] */ - "movem.l (%[wp]), %%d0-%%d3\n" /* load 8 values */ - "mac.w %%d0u, %%d4u, %%acc0\n" - "mac.w %%d0u, %%d4l, (-160*4,%[x2]), %%d4, %%acc1\n" - "mac.w %%d0l, %%d4u, %%acc0\n" - "mac.w %%d0l, %%d4l, ( -96*4,%[x2]), %%d4, %%acc1\n" - "mac.w %%d1u, %%d4u, %%acc0\n" - "mac.w %%d1u, %%d4l, ( -32*4,%[x2]), %%d4, %%acc1\n" - "mac.w %%d1l, %%d4u, %%acc0\n" - "mac.w %%d1l, %%d4l, ( 32*4,%[x2]), %%d4, %%acc1\n" - "mac.w %%d2u, %%d4u, %%acc0\n" - "mac.w %%d2u, %%d4l, ( 96*4,%[x2]), %%d4, %%acc1\n" - "mac.w %%d2l, %%d4u, %%acc0\n" - "mac.w %%d2l, %%d4l, ( 160*4,%[x2]), %%d4, %%acc1\n" - "mac.w %%d3u, %%d4u, %%acc0\n" - "mac.w %%d3u, %%d4l, ( 224*4,%[x2]), %%d4, %%acc1\n" - "mac.w %%d3l, %%d4u, %%acc0\n" - "mac.w %%d3l, %%d4l, (-256*4,%[x1]), %%d4, %%acc1\n" - "movem.l (16,%[wp]), %%d0-%%d3\n" /* load 8 values */ - "mac.w %%d0u, %%d4u, %%acc0\n" - "mac.w %%d0u, %%d4l, (-192*4,%[x1]), %%d4, %%acc1\n" - "mac.w %%d0l, %%d4u, %%acc0\n" - "mac.w %%d0l, %%d4l, (-128*4,%[x1]), %%d4, %%acc1\n" - "mac.w %%d1u, %%d4u, %%acc0\n" - "mac.w %%d1u, %%d4l, ( -64*4,%[x1]), %%d4, %%acc1\n" - "mac.w %%d1l, %%d4u, %%acc0\n" - "mac.w %%d1l, %%d4l, ( 0*4,%[x1]), %%d4, %%acc1\n" - "mac.w %%d2u, %%d4u, %%acc0\n" - "mac.w %%d2u, %%d4l, ( 64*4,%[x1]), %%d4, %%acc1\n" - "mac.w %%d2l, %%d4u, %%acc0\n" - "mac.w %%d2l, %%d4l, ( 128*4,%[x1]), %%d4, %%acc1\n" - "mac.w %%d3u, %%d4u, %%acc0\n" - "mac.w %%d3u, %%d4l, ( 192*4,%[x1]), %%d4, %%acc1\n" - "mac.w %%d3l, %%d4u, %%acc0\n" - "mac.w %%d3l, %%d4l, ( 224*4,%[x1]), %%d4, %%acc1\n" - "movclr.l %%acc0, %%d0\n" - "move.l %%d0, %[s0]\n" - "movclr.l %%acc1, %%d0\n" - "move.l %%d0, %[s1]\n" - - "movem.l (%[wp]), %%d0-%%d3\n" /* load 8 values */ - "mac.w %%d0u, %%d4u, %%acc0\n" - "mac.w %%d0u, %%d4l, ( 160*4,%[x1]), %%d4, %%acc1\n" - "mac.w %%d0l, %%d4u, %%acc0\n" - "mac.w %%d0l, %%d4l, ( 96*4,%[x1]), %%d4, %%acc1\n" - "mac.w %%d1u, %%d4u, %%acc0\n" - "mac.w %%d1u, %%d4l, ( 32*4,%[x1]), %%d4, %%acc1\n" - "mac.w %%d1l, %%d4u, %%acc0\n" - "mac.w %%d1l, %%d4l, ( -32*4,%[x1]), %%d4, %%acc1\n" - "mac.w %%d2u, %%d4u, %%acc0\n" - "mac.w %%d2u, %%d4l, ( -96*4,%[x1]), %%d4, %%acc1\n" - "mac.w %%d2l, %%d4u, %%acc0\n" - "mac.w %%d2l, %%d4l, (-160*4,%[x1]), %%d4, %%acc1\n" - "mac.w %%d3u, %%d4u, %%acc0\n" - "mac.w %%d3u, %%d4l, (-224*4,%[x1]), %%d4, %%acc1\n" - "mac.w %%d3l, %%d4u, %%acc0\n" - "mac.w %%d3l, %%d4l, ( 256*4,%[x2]), %%d4, %%acc1\n" - "movem.l (32,%[wp]), %%d0-%%d3\n" /* load 8 values */ - "mac.w %%d0u, %%d4u, %%acc0\n" - "mac.w %%d0u, %%d4l, ( 192*4,%[x2]), %%d4, %%acc1\n" - "mac.w %%d0l, %%d4u, %%acc0\n" - "mac.w %%d0l, %%d4l, ( 128*4,%[x2]), %%d4, %%acc1\n" - "mac.w %%d1u, %%d4u, %%acc0\n" - "mac.w %%d1u, %%d4l, ( 64*4,%[x2]), %%d4, %%acc1\n" - "mac.w %%d1l, %%d4u, %%acc0\n" - "mac.w %%d1l, %%d4l, ( 0*4,%[x2]), %%d4, %%acc1\n" - "mac.w %%d2u, %%d4u, %%acc0\n" - "mac.w %%d2u, %%d4l, ( -64*4,%[x2]), %%d4, %%acc1\n" - "mac.w %%d2l, %%d4u, %%acc0\n" - "mac.w %%d2l, %%d4l, (-128*4,%[x2]), %%d4, %%acc1\n" - "mac.w %%d3u, %%d4u, %%acc0\n" - "mac.w %%d3u, %%d4l, (-192*4,%[x2]), %%d4, %%acc1\n" - "mac.w %%d3l, %%d4u, %%acc0\n" - "mac.w %%d3l, %%d4l, %%acc1\n" - "movclr.l %%acc0, %%d0\n" - "move.l %%d0, %[t0]\n" - "movclr.l %%acc1, %%d0\n" - "move.l %%d0, %[t1]\n" - - : [x1] "+a" (x1), [x2] "+a" (x2), [s0] "+m" (s0), [t0] "+m" (t0), - [s1] "+m" (s1), [t1] "+m" (t1) - : [wp] "a" (wp) : "d0", "d1", "d2", "d3", "d4"); - - sb0[30+i*2] = shft4(t0) + shft13(s0) * wp[24]; - sb0[31+i*2] = shft13(t0) * wp[25] - shft13(s0) * wp[26]; - sb1[30+i*2] = shft4(t1) + shft13(s1) * wp[24]; - sb1[31+i*2] = shft13(t1) * wp[25] - shft13(s1) * wp[26]; - wp += 27; - x1 -= 2; - x2 += 2; - } - - asm volatile( - "move.l ( -32*4,%[x1]), %%d4\n" /* d4 = x1[-32] */ - "movem.l (%[wp]), %%d0-%%d3\n" /* load 8 values */ - - "mac.w %%d0u, %%d4u, %%acc0\n" - "mac.w %%d0u, %%d4l, ( -96*4,%[x1]), %%d4, %%acc1\n" - "mac.w %%d0l, %%d4u, %%acc0\n" - "mac.w %%d0l, %%d4l, (-160*4,%[x1]), %%d4, %%acc1\n" - "mac.w %%d1u, %%d4u, %%acc0\n" - "mac.w %%d1u, %%d4l, (-224*4,%[x1]), %%d4, %%acc1\n" - "mac.w %%d1l, %%d4u, %%acc0\n" - "mac.w %%d1l, %%d4l, ( 32*4,%[x1]), %%d4, %%acc1\n" - "mac.w %%d2u, %%d4u, %%acc0\n" - "mac.w %%d2u, %%d4l, ( 96*4,%[x1]), %%d4, %%acc1\n" - "mac.w %%d2l, %%d4u, %%acc0\n" - "mac.w %%d2l, %%d4l, ( 160*4,%[x1]), %%d4, %%acc1\n" - "mac.w %%d3u, %%d4u, %%acc0\n" - "mac.w %%d3u, %%d4l, ( 224*4,%[x1]), %%d4, %%acc1\n" - "mac.w %%d3l, %%d4u, %%acc0\n" - "mac.w %%d3l, %%d4l, ( -16*4,%[x1]), %%d4, %%acc1\n" - "movclr.l %%acc0, %%d0\n" - "move.l %%d0, %[s0]\n" - "movclr.l %%acc1, %%d0\n" - "move.l %%d0, %[s1]\n" - - "movem.l (16,%[wp]), %%d0-%%d3\n" /* load 8 values */ - "mac.w %%d0u, %%d4u, %%acc0\n" - "mac.w %%d0u, %%d4l, ( -48*4,%[x1]), %%d4, %%acc1\n" - "mac.w %%d1u, %%d4u, %%acc0\n" - "mac.w %%d1u, %%d4l, ( 16*4,%[x1]), %%d4, %%acc1\n" - "mac.w %%d1l, %%d4u, %%acc0\n" - "mac.w %%d1l, %%d4l, ( -80*4,%[x1]), %%d4, %%acc1\n" - "mac.w %%d2u, %%d4u, %%acc0\n" - "mac.w %%d2u, %%d4l, ( 48*4,%[x1]), %%d4, %%acc1\n" - "mac.w %%d2u, %%d4u, %%acc0\n" - "mac.w %%d2u, %%d4l, (-112*4,%[x1]), %%d4, %%acc1\n" - "mac.w %%d3u, %%d4u, %%acc0\n" - "mac.w %%d3u, %%d4l, ( 80*4,%[x1]), %%d4, %%acc1\n" - "mac.w %%d3l, %%d4u, %%acc0\n" - "mac.w %%d3l, %%d4l, (-144*4,%[x1]), %%d4, %%acc1\n" - "movem.l (32,%[wp]), %%d0-%%d3\n" /* load 8 values */ - "mac.w %%d0u, %%d4u, %%acc0\n" - "mac.w %%d0u, %%d4l, ( 112*4,%[x1]), %%d4, %%acc1\n" - "mac.w %%d0u, %%d4u, %%acc0\n" - "mac.w %%d0u, %%d4l, (-176*4,%[x1]), %%d4, %%acc1\n" - "mac.w %%d1u, %%d4u, %%acc0\n" - "mac.w %%d1u, %%d4l, ( 144*4,%[x1]), %%d4, %%acc1\n" - "mac.w %%d1l, %%d4u, %%acc0\n" - "mac.w %%d1l, %%d4l, (-208*4,%[x1]), %%d4, %%acc1\n" - "mac.w %%d2u, %%d4u, %%acc0\n" - "mac.w %%d2u, %%d4l, ( 176*4,%[x1]), %%d4, %%acc1\n" - "mac.w %%d2u, %%d4u, %%acc0\n" - "mac.w %%d2u, %%d4l, (-240*4,%[x1]), %%d4, %%acc1\n" - "mac.w %%d3u, %%d4u, %%acc0\n" - "mac.w %%d3u, %%d4l, ( 208*4,%[x1]), %%d4, %%acc1\n" - "mac.w %%d3l, %%d4u, %%acc0\n" - "mac.w %%d3l, %%d4l, %%acc1\n" - "movclr.l %%acc0, %%d0\n" - "move.l %%d0, %[t0]\n" - "movclr.l %%acc1, %%d0\n" - "move.l %%d0, %[t1]\n" - - : [x1] "+a" (x1), [s0] "+m" (s0), [t0] "+m" (t0), - [s1] "+m" (s1), [t1] "+m" (t1) - : [wp] "a" (wp) : "d0", "d1", "d2", "d3", "d4"); - - u = shft4(s0 - t0); - v = shft4(s0 + t0); - t0 = sb0[14]; - s0 = sb0[15] - t0; - - sb0[31] = v + t0; /* A0 */ - sb0[30] = u + s0; /* A1 */ - sb0[15] = u - s0; /* A2 */ - sb0[14] = v - t0; /* A3 */ - - u = shft4(s1 - t1); - v = shft4(s1 + t1); - t1 = sb1[14]; - s1 = sb1[15] - t1; - - sb1[31] = v + t1; /* A0 */ - sb1[30] = u + s1; /* A1 */ - sb1[15] = u - s1; /* A2 */ - sb1[14] = v - t1; /* A3 */ - } -#else - int ch, s, t, *a; - - for(ch=0; ch 160) - bitrate = 160; - - return ci->round_value_to_list32(bitrate, - &bitr_index[type][1], 14, true) + 1; -} - -static int find_samplerate_index(long freq, int *mp3_type) -{ - int mpeg = freq >= (32000+24000)/2 ? 1 : 0; - int i = ci->round_value_to_list32(freq, sampr_index[mpeg], 3, true); - *mp3_type = mpeg; - return i; -} - -static bool init_mp3_encoder_engine(int sample_rate, - int num_channels, - int rec_mono_mode, - struct encoder_config *enc_cfg) -{ - const bool stereo = num_channels > 1; - uint32_t avg_byte_per_frame; - - cfg.channels = stereo ? 2 : 1; - cfg.rec_mono_mode = rec_mono_mode; - cfg.mpg.mode = stereo ? 0 : 3; /* 0=stereo, 3=mono */ - cfg.mpg.smpl_id = find_samplerate_index(sample_rate, &cfg.mpg.type); - cfg.samplerate = sampr_index[cfg.mpg.type][cfg.mpg.smpl_id]; - cfg.mpg.bitr_id = find_bitrate_index(cfg.mpg.type, - enc_cfg->mp3_enc.bitrate, - stereo); - cfg.mpg.bitrate = bitr_index[cfg.mpg.type][cfg.mpg.bitr_id]; - cfg.mpg.num_bands = num_bands[stereo ? cfg.mpg.type : 2][cfg.mpg.bitr_id]; - - if (cfg.mpg.type == 1) - { - cfg.granules = 2; - pcm_chunk_size = PCM_CHUNK_SIZE1; - samp_per_frame = SAMP_PER_FRAME1; - } - else - { - cfg.granules = 1; - pcm_chunk_size = PCM_CHUNK_SIZE2; - samp_per_frame = SAMP_PER_FRAME2; - } - - memcpy(scalefac, sfBand[cfg.mpg.smpl_id + 3*cfg.mpg.type], sizeof(scalefac)); - memset(mfbuf , 0 , sizeof(mfbuf )); - memset(mdct_freq , 0 , sizeof(mdct_freq )); - memset(enc_data , 0 , sizeof(enc_data )); - memset(sb_data , 0 , sizeof(sb_data )); - memset(&CodedData, 0 , sizeof(CodedData )); - memcpy(ca , ca_const , sizeof(ca )); - memcpy(cs , cs_const , sizeof(cs )); - memcpy(cx , cx_const , sizeof(cx )); - memcpy(win , win_const , sizeof(win )); - memcpy(enwindow , enwindow_const , sizeof(enwindow )); - memcpy(int2idx , int2idx_const , sizeof(int2idx )); - memcpy(ht_count , ht_count_const , sizeof(ht_count )); - memcpy( tab01 , tab01_const , sizeof(tab01 )); - memcpy( tab23 , tab23_const , sizeof(tab23 )); - memcpy( tab56 , tab56_const , sizeof(tab56 )); - memcpy( tab1315 , tab1315_const , sizeof(tab1315 )); - memcpy( tab1624 , tab1624_const , sizeof(tab1624 )); - memcpy( tab789 , tab789_const , sizeof(tab789 )); - memcpy( tabABC , tabABC_const , sizeof(tabABC )); - memcpy( t1HB , t1HB_const , sizeof(t1HB )); - memcpy( t2HB , t2HB_const , sizeof(t2HB )); - memcpy( t3HB , t3HB_const , sizeof(t3HB )); - memcpy( t5HB , t5HB_const , sizeof(t5HB )); - memcpy( t6HB , t6HB_const , sizeof(t6HB )); - memcpy( t7HB , t7HB_const , sizeof(t7HB )); - memcpy( t8HB , t8HB_const , sizeof(t8HB )); - memcpy( t9HB , t9HB_const , sizeof(t9HB )); - memcpy(t10HB , t10HB_const , sizeof(t10HB )); - memcpy(t11HB , t11HB_const , sizeof(t11HB )); - memcpy(t12HB , t12HB_const , sizeof(t12HB )); - memcpy(t13HB , t13HB_const , sizeof(t13HB )); - memcpy(t15HB , t15HB_const , sizeof(t15HB )); - memcpy(t16HB , t16HB_const , sizeof(t16HB )); - memcpy(t24HB , t24HB_const , sizeof(t24HB )); - memcpy( t1l , t1l_const , sizeof(t1l )); - memcpy( t2l , t2l_const , sizeof(t2l )); - memcpy( t3l , t3l_const , sizeof(t3l )); - memcpy( t5l , t5l_const , sizeof(t5l )); - memcpy( t6l , t6l_const , sizeof(t6l )); - memcpy( t7l , t7l_const , sizeof(t7l )); - memcpy( t8l , t8l_const , sizeof(t8l )); - memcpy( t9l , t9l_const , sizeof(t9l )); - memcpy(t10l , t10l_const , sizeof(t10l )); - memcpy(t11l , t11l_const , sizeof(t11l )); - memcpy(t12l , t12l_const , sizeof(t12l )); - memcpy(t13l , t13l_const , sizeof(t13l )); - memcpy(t15l , t15l_const , sizeof(t15l )); - memcpy(t16l , t16l_const , sizeof(t16l )); - memcpy(t24l , t24l_const , sizeof(t24l )); - memcpy(ht , ht_const , sizeof(ht )); - - ht[ 0].table = NULL; ht[ 0].hlen = NULL; /* Apparently not used */ - ht[ 1].table = t1HB; ht[ 1].hlen = t1l; - ht[ 2].table = t2HB; ht[ 2].hlen = t2l; - ht[ 3].table = t3HB; ht[ 3].hlen = t3l; - ht[ 4].table = NULL; ht[ 4].hlen = NULL; /* Apparently not used */ - ht[ 5].table = t5HB; ht[ 5].hlen = t5l; - ht[ 6].table = t6HB; ht[ 6].hlen = t6l; - ht[ 7].table = t7HB; ht[ 7].hlen = t7l; - ht[ 8].table = t8HB; ht[ 8].hlen = t8l; - ht[ 9].table = t9HB; ht[ 9].hlen = t9l; - ht[10].table = t10HB; ht[10].hlen = t10l; - ht[11].table = t11HB; ht[11].hlen = t11l; - ht[12].table = t12HB; ht[12].hlen = t12l; - ht[13].table = t13HB; ht[13].hlen = t13l; - ht[14].table = NULL; ht[14].hlen = NULL; /* Apparently not used */ - ht[15].table = t15HB; ht[15].hlen = t15l; - - /* Figure average number of 'bytes' per frame */ - avg_byte_per_frame = SAMPL2 * 16000 * cfg.mpg.bitrate / (2 - cfg.mpg.type); - avg_byte_per_frame = avg_byte_per_frame / cfg.samplerate; - cfg.byte_per_frame = avg_byte_per_frame / 64; - cfg.frac_per_frame = avg_byte_per_frame & 63; - cfg.slot_lag = 0; - cfg.sideinfo_len = 32 + (cfg.mpg.type ? (cfg.channels == 1 ? 136 : 256) - : (cfg.channels == 1 ? 72 : 136)); - - return true; -} - -STATICIRAM void to_mono_mm(void) ICODE_ATTR; -STATICIRAM void to_mono_mm(void) -{ - /* |llllllllllllllll|rrrrrrrrrrrrrrrr| => - * |mmmmmmmmmmmmmmmm|mmmmmmmmmmmmmmmm| - */ - uint16_t *samp = &mfbuf[2*512]; - uint16_t *samp_end = samp + 2*samp_per_frame; - - inline void to_mono(uint16_t **samp) - { - int16_t l = **samp; - int16_t r = *(*samp+1); - int32_t m; - - switch(cfg.rec_mono_mode) - { - case 1: - /* mono = L */ - m = l; - break; - case 2: - /* mono = R */ - m = r; - break; - case 0: - default: - /* mono = (L+R)/2 */ - m = l + r + err; - err = m & 1; - m >>= 1; - break; - } - *(*samp)++ = (uint16_t)m; - *(*samp)++ = (uint16_t)m; - } /* to_mono */ - - do - { - to_mono(&samp); - to_mono(&samp); - to_mono(&samp); - to_mono(&samp); - to_mono(&samp); - to_mono(&samp); - to_mono(&samp); - to_mono(&samp); - } - while (samp < samp_end); -} /* to_mono_mm */ - -#ifdef ROCKBOX_LITTLE_ENDIAN -/* Swaps a frame to big endian */ -static inline void byte_swap_frame32(uint32_t *dst, uint32_t *src, - size_t size) -{ - uint32_t *src_end = SKIPBYTES(src, size); - - do - { - *dst++ = swap32(*src++); - *dst++ = swap32(*src++); - *dst++ = swap32(*src++); - *dst++ = swap32(*src++); - *dst++ = swap32(*src++); - *dst++ = swap32(*src++); - *dst++ = swap32(*src++); - *dst++ = swap32(*src++); - } - while(src < src_end); -} /* byte_swap_frame32 */ -#endif /* ROCKBOX_LITTLE_ENDIAN */ - -static void set_scale_facs(int *mdct_freq) -{ - unsigned int i, is, ie, k, s; - int max_freq_val, avrg_freq_val; - - /* calc average of first 256 frequency values */ - for(avrg_freq_val=i=0; i<256; i++) - avrg_freq_val += mdct_freq[i]; - avrg_freq_val >>= 8; - - /* if max of current band is smaller than average, increase precision */ - /* last band keeps untouched (not scaled) */ - for(is=k=0; is avrg_freq_val) - break; - - band_scale_f[k] = (unsigned char)s; - - for(i=is; s && i= 64) - { /* Padding for this frame */ - cfg.slot_lag -= 64; - cfg.mpg.padding = 1; - } - else - cfg.mpg.padding = 0; - - cfg.mean_bits = (8 * cfg.byte_per_frame + 8 * cfg.mpg.padding - - cfg.sideinfo_len) / cfg.granules / cfg.channels - - 42; // reserved for scale_facs - - /* shift out old samples */ - memcpy(mfbuf, mfbuf + 2*cfg.granules*576, 4*512); - - if (chunk->flags & CHUNKF_START_FILE) - { - /* prefix silent samples for encoder delay */ - memset(mfbuf + 2*512, 0, ENC_DELAY_SIZE); - /* read new samples to iram for further processing */ - memcpy(mfbuf + 2*512 + ENC_DELAY_SIZE/2, - buffer, pcm_chunk_size - ENC_DELAY_SIZE); - chunk->num_pcm = samp_per_frame - ENC_DELAY_SAMP; - } - else - { - /* read new samples to iram for further processing */ - memcpy(mfbuf + 2*512, buffer, pcm_chunk_size); - chunk->num_pcm = samp_per_frame; - } - - if (cfg.channels == 1) - to_mono_mm(); - - cfg.ResvSize = 0; - gr_cnt = cfg.granules * cfg.channels; - CodedData.bitpos = cfg.sideinfo_len; /* leave space for mp3 header */ - - for(gr=0; gr> 2); - for(k=1,ii=0; ii<3 && k; ii++) - { - int *mdct = mdct_freq; - int band; - - cfg.cod_info[gr][ch].additStep = 4 * (14 - shift); - - for(band=0; band=0; --k) - { - int bu, bd; - bu = shft15(mdct[k]) * ca[k] + - shft15(mdct[-1-k]) * cs[k]; - bd = shft15(mdct[k]) * cs[k] - - shft15(mdct[-1-k]) * ca[k]; - mdct[-1-k] = bu; - mdct[ k ] = bd; - } - } - } - - max = 0; - for(k=0; k<576; k++) - { - if(mdct_freq[k] < 0) - { - mdct_sign[k] = 1; /* negative */ - mdct_freq[k] = shft13(-mdct_freq[k]); - } - else - { - mdct_sign[k] = 0; /* positive */ - mdct_freq[k] = shft13(mdct_freq[k]); - } - - if(max < (uint32_t)mdct_freq[k]) - max = (uint32_t)mdct_freq[k]; - } - cfg.cod_info[gr][ch].max_val = max; - - /* calc new shift for higher integer precision */ - for(k=0; max<(uint32_t)(0x7800>>k); k++) shift--; - for( ; (max>>k)>=(uint32_t)0x10000; k++) shift++; - if(shift < 0) shift = 0; - } - - cfg.cod_info[gr][ch].quantStep += - cfg.cod_info[gr][ch].additStep; - - set_scale_facs(mdct_freq); - - /* bit and noise allocation */ - iteration_loop(mdct_freq, &cfg.cod_info[gr][ch], - gr_cnt--); - /* write the frame to the bitstream */ - Huffmancodebits(enc_data, mdct_sign, - &cfg.cod_info[gr][ch]); - - cfg.cod_info[gr][ch].quantStep -= - cfg.cod_info[gr][ch].additStep; - - if(cfg.granules == 1) - { - memcpy(sb_data[ch][0], sb_data[ch][1], - sizeof(sb_data[ch][0])); - } - } - } - - chunk->enc_size = cfg.byte_per_frame + cfg.mpg.padding; - - /* finish this chunk by adding sideinfo header data */ - CodedData.bitpos = 0; - encodeSideInfo( cfg.cod_info ); - -#ifdef ROCKBOX_BIG_ENDIAN - /* copy chunk to enc_buffer */ - memcpy(chunk->enc_data, CodedData.bbuf, chunk->enc_size); -#else - /* swap frame to big endian */ - byte_swap_frame32((uint32_t *)chunk->enc_data, CodedData.bbuf, chunk->enc_size); -#endif -} /* encode_frame */ - -/* called very often - inline */ -static inline bool is_file_data_ok(struct enc_file_event_data *filed) -{ - return filed->rec_file >= 0 && (long)filed->chunk->flags >= 0; -} /* is_event_ok */ - -static unsigned char mp3_data[16384] __attribute__((aligned(4))); -static unsigned int mp3_data_len; /* current data size in buffer */ - -/* called very often - inline */ -static inline bool on_write_chunk(struct enc_file_event_data *data) -{ - if (!is_file_data_ok(data)) - return false; - - if (data->chunk->enc_data == NULL) - { -#ifdef ROCKBOX_HAS_LOGF - ci->logf("mp3 enc: NULL data"); -#endif - return true; - } - - /* if current chunk doesn't fit => write collected data */ - if (mp3_data_len + data->chunk->enc_size > sizeof(mp3_data)) - { - if (ci->write(data->rec_file, mp3_data, - mp3_data_len) != (ssize_t)mp3_data_len) - return false; - - mp3_data_len = 0; - } - - memcpy(mp3_data+mp3_data_len, data->chunk->enc_data, - data->chunk->enc_size); - - mp3_data_len += data->chunk->enc_size; - - data->num_pcm_samples += data->chunk->num_pcm; - return true; -} /* on_write_chunk */ - -static bool on_start_file(struct enc_file_event_data *data) -{ - if ((data->chunk->flags & CHUNKF_ERROR) || *data->filename == '\0') - return false; - - data->rec_file = ci->open(data->filename, O_RDWR|O_CREAT|O_TRUNC, 0666); - - if (data->rec_file < 0) - return false; - - /* reset sample count */ - data->num_pcm_samples = 0; - - /* reset buffer write position */ - mp3_data_len = 0; - - return true; -} /* on_start_file */ - -static bool on_end_file(struct enc_file_event_data *data) -{ - if (data->rec_file < 0) - return false; /* file already closed, nothing more we can do */ - - /* write the remaining mp3_data */ - if (ci->write(data->rec_file, mp3_data, mp3_data_len) - != (ssize_t)mp3_data_len) - return false; - - /* reset buffer write position */ - mp3_data_len = 0; - - /* always _try_ to write the file header, even on error */ - if (ci->close(data->rec_file) != 0) - return false; - - data->rec_file = -1; - - return true; -} /* on_end_file */ - -static void on_rec_new_stream(struct enc_buffer_event_data *data) -{ - int num_frames = cfg.mpg.type == 1 ? - ENC_PADDING_FRAMES1 : ENC_PADDING_FRAMES2; - - if (data->flags & CHUNKF_END_FILE) - { - /* add silent frames to end - encoder will also be flushed for start - of next file if any */ - memset(res_buffer, 0, pcm_chunk_size); - - /* the initial chunk given for the end is at enc_wr_index */ - while (num_frames-- > 0) - { - data->chunk->enc_data = ENC_CHUNK_SKIP_HDR(data->chunk->enc_data, - data->chunk); - - encode_frame(res_buffer, data->chunk); - data->chunk->num_pcm = samp_per_frame; - - ci->enc_finish_chunk(); - data->chunk = ci->enc_get_chunk(); - } - } - else if (data->flags & CHUNKF_PRERECORD) - { - /* nothing to add and we cannot change prerecorded data */ - } - else if (data->flags & CHUNKF_START_FILE) - { - /* starting fresh ... be sure to flush encoder first */ - struct enc_chunk_hdr *chunk = ENC_CHUNK_HDR(res_buffer); - - chunk->flags = 0; - chunk->enc_data = ENC_CHUNK_SKIP_HDR(chunk->enc_data, chunk); - - while (num_frames-- > 0) - { - memset(chunk->enc_data, 0, pcm_chunk_size); - encode_frame(chunk->enc_data, chunk); - } - } -} /* on_rec_new_stream */ - -static void enc_events_callback(enum enc_events event, void *data) -{ - switch (event) - { - case ENC_WRITE_CHUNK: - if (on_write_chunk((struct enc_file_event_data *)data)) - return; - - break; - - case ENC_START_FILE: - if (on_start_file((struct enc_file_event_data *)data)) - return; - - break; - - case ENC_END_FILE: - if (on_end_file((struct enc_file_event_data *)data)) - return; - - break; - - case ENC_REC_NEW_STREAM: - on_rec_new_stream((struct enc_buffer_event_data *)data); - return; - - default: - return; - } - - /* Something failed above. Signal error back to core. */ - ((struct enc_file_event_data *)data)->chunk->flags |= CHUNKF_ERROR; -} /* enc_events_callback */ - -static bool enc_init(void) -{ - struct enc_inputs inputs; - struct enc_parameters params; - - if (ci->enc_get_inputs == NULL || - ci->enc_set_parameters == NULL || - ci->enc_get_chunk == NULL || - ci->enc_finish_chunk == NULL || - ci->enc_get_pcm_data == NULL || - ci->enc_unget_pcm_data == NULL ) - return false; - - ci->enc_get_inputs(&inputs); - - if (inputs.config->afmt != AFMT_MPA_L3) - return false; - - init_mp3_encoder_engine(inputs.sample_rate, inputs.num_channels, - inputs.rec_mono_mode, inputs.config); - - err = 0; - - /* configure the buffer system */ - params.afmt = AFMT_MPA_L3; - params.chunk_size = cfg.byte_per_frame + 1; - params.enc_sample_rate = cfg.samplerate; - /* need enough reserved bytes to hold one frame of pcm samples + hdr - for padding and flushing */ - params.reserve_bytes = ENC_CHUNK_HDR_SIZE + pcm_chunk_size; - params.events_callback = enc_events_callback; - ci->enc_set_parameters(¶ms); - - res_buffer = params.reserve_buffer; - -#ifdef CPU_COLDFIRE - asm volatile ("move.l #0, %macsr"); /* integer mode */ -#endif - - return true; -} /* enc_init */ - -/* this is the codec entry point */ -enum codec_status codec_main(enum codec_entry_call_reason reason) -{ - if (reason == CODEC_LOAD) { - if (!enc_init()) - return CODEC_ERROR; - } - else if (reason == CODEC_UNLOAD) { - /* reset parameters to initial state */ - ci->enc_set_parameters(NULL); - } - - return CODEC_OK; -} - -/* this is called for each file to process */ -enum codec_status codec_run(void) -{ - /* main encoding loop */ - while(ci->get_command(NULL) != CODEC_ACTION_HALT) - { - char *buffer = buffer = ci->enc_get_pcm_data(pcm_chunk_size); - struct enc_chunk_hdr *chunk; - - if(buffer == NULL) - continue; - - chunk = ci->enc_get_chunk(); - chunk->enc_data = ENC_CHUNK_SKIP_HDR(chunk->enc_data, chunk); - - encode_frame(buffer, chunk); - - if (chunk->num_pcm < samp_per_frame) - { - ci->enc_unget_pcm_data(pcm_chunk_size - chunk->num_pcm*4); - chunk->num_pcm = samp_per_frame; - } - - ci->enc_finish_chunk(); - } - - return CODEC_OK; -} diff --git a/apps/codecs/mpa.c b/apps/codecs/mpa.c deleted file mode 100644 index f9bf7e600f..0000000000 --- a/apps/codecs/mpa.c +++ /dev/null @@ -1,521 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2005 Dave Chapman - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ - -#include "codeclib.h" -#include -#include - -CODEC_HEADER - -#if NUM_CORES > 1 && !defined(MPEGPLAYER) -#define MPA_SYNTH_ON_COP -#endif - -static struct mad_stream stream IBSS_ATTR; -static struct mad_frame frame IBSS_ATTR; -static struct mad_synth synth IBSS_ATTR; - -#ifdef MPA_SYNTH_ON_COP -static volatile short die IBSS_ATTR = 0; /*thread should die*/ - -#if (CONFIG_CPU == PP5024) || (CONFIG_CPU == PP5022) -static mad_fixed_t sbsample_prev[2][36][32] IBSS_ATTR; -#else -static mad_fixed_t sbsample_prev[2][36][32] SHAREDBSS_ATTR; -#endif - -static struct semaphore synth_done_sem IBSS_ATTR; -static struct semaphore synth_pending_sem IBSS_ATTR; -#endif - -#define INPUT_CHUNK_SIZE 8192 - -static mad_fixed_t mad_frame_overlap[2][32][18] IBSS_ATTR; -static mad_fixed_t sbsample[2][36][32] IBSS_ATTR; - -static unsigned char mad_main_data[MAD_BUFFER_MDLEN] IBSS_ATTR; -/* TODO: what latency does layer 1 have? */ -static int mpeg_latency[3] = { 0, 481, 529 }; -static int mpeg_framesize[3] = {384, 1152, 1152}; - -static void init_mad(void) -{ - ci->memset(&stream, 0, sizeof(struct mad_stream)); - ci->memset(&frame , 0, sizeof(struct mad_frame)); - ci->memset(&synth , 0, sizeof(struct mad_synth)); - -#ifdef MPA_SYNTH_ON_COP - frame.sbsample_prev = &sbsample_prev; - frame.sbsample = &sbsample; -#else - frame.sbsample_prev = &sbsample; - frame.sbsample = &sbsample; -#endif - - /* We do this so libmad doesn't try to call codec_calloc(). This needs to - * be called before mad_stream_init(), mad_frame_inti() and - * mad_synth_init(). */ - frame.overlap = &mad_frame_overlap; - stream.main_data = &mad_main_data; - - /* Call mad initialization. Those will zero the arrays frame.overlap, - * frame.sbsample and frame.sbsample_prev. Therefore there is no need to - * zero them here. */ - mad_stream_init(&stream); - mad_frame_init(&frame); - mad_synth_init(&synth); -} - -static int get_file_pos(int newtime) -{ - int pos = -1; - struct mp3entry *id3 = ci->id3; - - if (id3->vbr) { - /* Convert newtime and id3->length to seconds to - * avoid overflow */ - unsigned int newtime_s = newtime/1000; - unsigned int length_s = id3->length/1000; - - if (id3->has_toc) { - /* Use the TOC to find the new position */ - unsigned int percent, remainder; - int curtoc, nexttoc, plen; - - percent = (newtime_s*100) / length_s; - if (percent > 99) - percent = 99; - - curtoc = id3->toc[percent]; - - if (percent < 99) { - nexttoc = id3->toc[percent+1]; - } else { - nexttoc = 256; - } - - pos = (id3->filesize/256)*curtoc; - - /* Use the remainder to get a more accurate position */ - remainder = (newtime_s*100) % length_s; - remainder = (remainder*100) / length_s; - plen = (nexttoc - curtoc)*(id3->filesize/256); - pos += (plen/100)*remainder; - } else { - /* No TOC exists, estimate the new position */ - pos = (id3->filesize / length_s) * newtime_s; - } - } else if (id3->bitrate) { - pos = newtime * (id3->bitrate / 8); - } else { - return -1; - } - - /* Don't seek right to the end of the file so that we can - transition properly to the next song */ - if (pos >= (int)(id3->filesize - id3->id3v1len)) - pos = id3->filesize - id3->id3v1len - 1; - - /* id3->filesize excludes id3->first_frame_offset, so add it now */ - pos += id3->first_frame_offset; - - return pos; -} - -static void set_elapsed(struct mp3entry* id3) -{ - unsigned long offset = id3->offset > id3->first_frame_offset ? - id3->offset - id3->first_frame_offset : 0; - unsigned long elapsed = id3->elapsed; - - if ( id3->vbr ) { - if ( id3->has_toc ) { - /* calculate elapsed time using TOC */ - int i; - unsigned int remainder, plen, relpos, nextpos; - - /* find wich percent we're at */ - for (i=0; i<100; i++ ) - if ( offset < id3->toc[i] * (id3->filesize / 256) ) - break; - - i--; - if (i < 0) - i = 0; - - relpos = id3->toc[i]; - - if (i < 99) - nextpos = id3->toc[i+1]; - else - nextpos = 256; - - remainder = offset - (relpos * (id3->filesize / 256)); - - /* set time for this percent (divide before multiply to prevent - overflow on long files. loss of precision is negligible on - short files) */ - elapsed = i * (id3->length / 100); - - /* calculate remainder time */ - plen = (nextpos - relpos) * (id3->filesize / 256); - elapsed += (((remainder * 100) / plen) * (id3->length / 10000)); - } - else { - /* no TOC exists. set a rough estimate using average bitrate */ - int tpk = id3->length / - ((id3->filesize - id3->first_frame_offset - id3->id3v1len) / - 1024); - elapsed = offset / 1024 * tpk; - } - } - else - { - /* constant bitrate, use exact calculation */ - if (id3->bitrate != 0) - elapsed = offset / (id3->bitrate / 8); - } - - ci->set_elapsed(elapsed); -} - -#ifdef MPA_SYNTH_ON_COP - -/* - * Run the synthesis filter on the COProcessor - */ - -static int mad_synth_thread_stack[DEFAULT_STACK_SIZE/sizeof(int)] IBSS_ATTR; - -static const unsigned char * const mad_synth_thread_name = "mp3dec"; -static unsigned int mad_synth_thread_id = 0; - - -static void mad_synth_thread(void) -{ - while(1) { - ci->semaphore_release(&synth_done_sem); - ci->semaphore_wait(&synth_pending_sem, TIMEOUT_BLOCK); - - if(die) - break; - - mad_synth_frame(&synth, &frame); - } -} - -/* wait for the synth thread to go idle which indicates a PCM frame has been - * synthesized */ -static inline void mad_synth_thread_wait_pcm(void) -{ - ci->semaphore_wait(&synth_done_sem, TIMEOUT_BLOCK); -} - -/* increment the done semaphore - used after a wait for idle to preserve the - * semaphore count */ -static inline void mad_synth_thread_unwait_pcm(void) -{ - ci->semaphore_release(&synth_done_sem); -} - -/* after synth thread has gone idle - switch decoded frames and commence - * synthesis on it */ -static void mad_synth_thread_ready(void) -{ - mad_fixed_t (*temp)[2][36][32]; - - /*circular buffer that holds 2 frames' samples*/ - temp=frame.sbsample; - frame.sbsample = frame.sbsample_prev; - frame.sbsample_prev=temp; - - ci->semaphore_release(&synth_pending_sem); -} - -static bool mad_synth_thread_create(void) -{ - ci->semaphore_init(&synth_done_sem, 1, 0); - ci->semaphore_init(&synth_pending_sem, 1, 0); - - mad_synth_thread_id = ci->create_thread(mad_synth_thread, - mad_synth_thread_stack, - sizeof(mad_synth_thread_stack), 0, - mad_synth_thread_name - IF_PRIO(, PRIORITY_PLAYBACK) - IF_COP(, COP)); - - if (mad_synth_thread_id == 0) - return false; - - return true; -} - -static void mad_synth_thread_quit(void) -{ - /* mop up COP thread */ - die = 1; - ci->semaphore_release(&synth_pending_sem); - ci->thread_wait(mad_synth_thread_id); - ci->commit_discard_dcache(); -} -#else -static inline void mad_synth_thread_ready(void) -{ - mad_synth_frame(&synth, &frame); -} - -static inline bool mad_synth_thread_create(void) -{ - return true; -} - -static inline void mad_synth_thread_quit(void) -{ -} - -static inline void mad_synth_thread_wait_pcm(void) -{ -} - -static inline void mad_synth_thread_unwait_pcm(void) -{ -} -#endif /* MPA_SYNTH_ON_COP */ - -/* this is the codec entry point */ -enum codec_status codec_main(enum codec_entry_call_reason reason) -{ - if (reason == CODEC_LOAD) { - /* Create a decoder instance */ - if (codec_init()) - return CODEC_ERROR; - - ci->configure(DSP_SET_SAMPLE_DEPTH, MAD_F_FRACBITS); - - /* does nothing on 1 processor systems except return true */ - if(!mad_synth_thread_create()) - return CODEC_ERROR; - } - else if (reason == CODEC_UNLOAD) { - /* mop up COP thread - MT only */ - mad_synth_thread_quit(); - } - - return CODEC_OK; -} - -/* this is called for each file to process */ -enum codec_status codec_run(void) -{ - size_t size; - int file_end; - int samples_to_skip; /* samples to skip in total for this file (at start) */ - char *inputbuffer; - int64_t samplesdone; - int stop_skip, start_skip; - int current_stereo_mode = -1; - unsigned long current_frequency = 0; - int framelength; - int padding = MAD_BUFFER_GUARD; /* to help mad decode the last frame */ - intptr_t param; - - /* Reinitializing seems to be necessary to avoid playback quircks when seeking. */ - init_mad(); - - file_end = 0; - - ci->configure(DSP_SWITCH_FREQUENCY, ci->id3->frequency); - current_frequency = ci->id3->frequency; - codec_set_replaygain(ci->id3); - - if (ci->id3->offset) { - ci->seek_buffer(ci->id3->offset); - set_elapsed(ci->id3); - } - else - ci->seek_buffer(ci->id3->first_frame_offset); - - if (ci->id3->lead_trim >= 0 && ci->id3->tail_trim >= 0) { - stop_skip = ci->id3->tail_trim - mpeg_latency[ci->id3->layer]; - if (stop_skip < 0) stop_skip = 0; - start_skip = ci->id3->lead_trim + mpeg_latency[ci->id3->layer]; - } else { - stop_skip = 0; - /* We want to skip this amount anyway */ - start_skip = mpeg_latency[ci->id3->layer]; - } - - /* Libmad will not decode the last frame without 8 bytes of extra padding - in the buffer. So, we can trick libmad into not decoding the last frame - if we are to skip it entirely and then cut the appropriate samples from - final frame that we did decode. Note, if all tags (ID3, APE) are not - properly stripped from the end of the file, this trick will not work. */ - if (stop_skip >= mpeg_framesize[ci->id3->layer]) { - padding = 0; - stop_skip -= mpeg_framesize[ci->id3->layer]; - } else { - padding = MAD_BUFFER_GUARD; - } - - samplesdone = ((int64_t)ci->id3->elapsed) * current_frequency / 1000; - - /* Don't skip any samples unless we start at the beginning. */ - if (samplesdone > 0) - samples_to_skip = 0; - else - samples_to_skip = start_skip; - - framelength = 0; - - /* This is the decoding loop. */ - while (1) { - enum codec_command_action action = ci->get_command(¶m); - - if (action == CODEC_ACTION_HALT) - break; - - if (action == CODEC_ACTION_SEEK_TIME) { - int newpos; - - /*make sure the synth thread is idle before seeking - MT only*/ - mad_synth_thread_wait_pcm(); - mad_synth_thread_unwait_pcm(); - - samplesdone = ((int64_t)param)*current_frequency/1000; - - if (param == 0) { - newpos = ci->id3->first_frame_offset; - samples_to_skip = start_skip; - } else { - newpos = get_file_pos(param); - samples_to_skip = 0; - } - - if (!ci->seek_buffer(newpos)) - { - ci->seek_complete(); - break; - } - - ci->set_elapsed((samplesdone * 1000) / current_frequency); - ci->seek_complete(); - init_mad(); - framelength = 0; - } - - /* Lock buffers */ - if (stream.error == 0) { - inputbuffer = ci->request_buffer(&size, INPUT_CHUNK_SIZE); - if (size == 0 || inputbuffer == NULL) - break; - mad_stream_buffer(&stream, (unsigned char *)inputbuffer, - size + padding); - } - - if (mad_frame_decode(&frame, &stream)) { - if (stream.error == MAD_ERROR_BUFLEN) { - /* This makes the codec support partially corrupted files */ - if (file_end == 30) - break; - - /* Fill the buffer */ - if (stream.next_frame) - ci->advance_buffer(stream.next_frame - stream.buffer); - else - ci->advance_buffer(size); - stream.error = 0; /* Must get new inputbuffer next time */ - file_end++; - continue; - } else if (MAD_RECOVERABLE(stream.error)) { - /* Probably syncing after a seek */ - continue; - } else { - /* Some other unrecoverable error */ - return CODEC_ERROR; - } - } - - /* Do the pcmbuf insert here. Note, this is the PREVIOUS frame's pcm - data (not the one just decoded above). When we exit the decoding - loop we will need to process the final frame that was decoded. */ - mad_synth_thread_wait_pcm(); - - if (framelength > 0) { - - /* In case of a mono file, the second array will be ignored. */ - ci->pcmbuf_insert(&synth.pcm.samples[0][samples_to_skip], - &synth.pcm.samples[1][samples_to_skip], - framelength); - - /* Only skip samples for the first frame added. */ - samples_to_skip = 0; - } - - /* Initiate PCM synthesis on the COP (MT) or perform it here (ST) */ - mad_synth_thread_ready(); - - /* Check if sample rate and stereo settings changed in this frame. */ - if (frame.header.samplerate != current_frequency) { - current_frequency = frame.header.samplerate; - ci->configure(DSP_SWITCH_FREQUENCY, current_frequency); - } - if (MAD_NCHANNELS(&frame.header) == 2) { - if (current_stereo_mode != STEREO_NONINTERLEAVED) { - ci->configure(DSP_SET_STEREO_MODE, STEREO_NONINTERLEAVED); - current_stereo_mode = STEREO_NONINTERLEAVED; - } - } else { - if (current_stereo_mode != STEREO_MONO) { - ci->configure(DSP_SET_STEREO_MODE, STEREO_MONO); - current_stereo_mode = STEREO_MONO; - } - } - - if (stream.next_frame) - ci->advance_buffer(stream.next_frame - stream.buffer); - else - ci->advance_buffer(size); - stream.error = 0; /* Must get new inputbuffer next time */ - file_end = 0; - - framelength = synth.pcm.length - samples_to_skip; - if (framelength < 0) { - framelength = 0; - samples_to_skip -= synth.pcm.length; - } - - samplesdone += framelength; - ci->set_elapsed((samplesdone * 1000) / current_frequency); - } - - /* wait for synth idle - MT only*/ - mad_synth_thread_wait_pcm(); - mad_synth_thread_unwait_pcm(); - - /* Finish the remaining decoded frame. - Cut the required samples from the end. */ - if (framelength > stop_skip){ - ci->pcmbuf_insert(synth.pcm.samples[0], synth.pcm.samples[1], - framelength - stop_skip); - } - - return CODEC_OK; -} diff --git a/apps/codecs/mpc.c b/apps/codecs/mpc.c deleted file mode 100644 index b2628f988e..0000000000 --- a/apps/codecs/mpc.c +++ /dev/null @@ -1,186 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2005 Thom Johansen - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ - -#include "codeclib.h" -#include -#include - -CODEC_HEADER - -static MPC_SAMPLE_FORMAT sample_buffer[MPC_DECODER_BUFFER_LENGTH] IBSS_ATTR; - -/* Our implementations of the mpc_reader callback functions. */ -static mpc_int32_t read_impl(mpc_reader *reader, void *ptr, mpc_int32_t size) -{ - (void)reader; - return ((mpc_int32_t)(ci->read_filebuf(ptr, size))); -} - -static mpc_bool_t seek_impl(mpc_reader *reader, mpc_int32_t offset) -{ - (void)reader; - return ci->seek_buffer(offset); -} - -static mpc_int32_t tell_impl(mpc_reader *reader) -{ - (void)reader; - return ci->curpos; -} - -static mpc_int32_t get_size_impl(mpc_reader *reader) -{ - (void)reader; - return ci->filesize; -} - -/* this is the codec entry point */ -enum codec_status codec_main(enum codec_entry_call_reason reason) -{ - if (reason == CODEC_LOAD) { - /* musepack's sample representation is 18.14 - * DSP_SET_SAMPLE_DEPTH = 14 (FRACT) + 16 (NATIVE) - 1 (SIGN) = 29 */ - ci->configure(DSP_SET_SAMPLE_DEPTH, 29); - } - - return CODEC_OK; -} - -/* this is called for each file to process */ -enum codec_status codec_run(void) -{ - mpc_int64_t samplesdone; - uint32_t frequency; /* 0.1 kHz accuracy */ - uint32_t elapsed_time; /* milliseconds */ - uint32_t byterate; /* bytes per second */ - mpc_status status; - mpc_reader reader; - mpc_streaminfo info; - mpc_frame_info frame; - mpc_demux *demux = NULL; - intptr_t param; - - frame.buffer = sample_buffer; - - /* Create a decoder instance */ - reader.read = read_impl; - reader.seek = seek_impl; - reader.tell = tell_impl; - reader.get_size = get_size_impl; - - if (codec_init()) - return CODEC_ERROR; - - /* Prep position */ - ci->seek_buffer(0); - - /* Initialize demux/decoder. */ - demux = mpc_demux_init(&reader); - if (NULL == demux) - return CODEC_ERROR; - - /* Read file's streaminfo data. */ - mpc_demux_get_info(demux, &info); - - byterate = (mpc_uint32_t)(info.average_bitrate) / 8; - frequency = info.sample_freq / 100; /* 0.1 kHz accuracy */ - ci->configure(DSP_SWITCH_FREQUENCY, info.sample_freq); - - /* Remark: rockbox offset is the file offset in bytes. So, estimate the - * sample seek position from the file offset, the sampling frequency and - * the bitrate. As the saved position is exactly calculated the reverse way - * there is no loss of information except rounding. */ - samplesdone = 100 * (((mpc_uint64_t)ci->id3->offset * frequency) / byterate); - - /* Set up digital signal processing for correct number of channels */ - /* NOTE: current musepack format only allows for stereo files - but code is here to handle other configurations anyway */ - if (info.channels == 2) - ci->configure(DSP_SET_STEREO_MODE, STEREO_NONINTERLEAVED); - else if (info.channels == 1) - ci->configure(DSP_SET_STEREO_MODE, STEREO_MONO); - else - return CODEC_ERROR; - - codec_set_replaygain(ci->id3); - - /* Resume to saved sample offset. */ - elapsed_time = 0; - - if (samplesdone > 0) - { - if (mpc_demux_seek_sample(demux, samplesdone) == MPC_STATUS_OK) - { - elapsed_time = (samplesdone*10)/frequency; - } - else - { - samplesdone = 0; - } - } - - ci->set_elapsed(elapsed_time); - - /* This is the decoding loop. */ - do - { - enum codec_command_action action = ci->get_command(¶m); - - if (action == CODEC_ACTION_HALT) - return CODEC_OK; - - /* Complete seek handler. */ - if (action == CODEC_ACTION_SEEK_TIME) - { - mpc_int64_t new_offset = (param/10)*frequency; - if (mpc_demux_seek_sample(demux, new_offset) == MPC_STATUS_OK) - { - samplesdone = new_offset; - } - - elapsed_time = (samplesdone*10)/frequency; - ci->set_elapsed(elapsed_time); - ci->seek_complete(); - } - - /* Decode one frame. */ - status = mpc_demux_decode(demux, &frame); - ci->yield(); - if (frame.bits == -1) - { - /* Decoding error, exit decoding loop. */ - return (status == MPC_STATUS_OK) ? CODEC_OK : CODEC_ERROR; - } - else - { - /* Decoding passed, insert samples to PCM buffer. */ - ci->pcmbuf_insert(frame.buffer, - frame.buffer + MPC_FRAME_LENGTH, - frame.samples); - samplesdone += frame.samples; - elapsed_time = (samplesdone*10)/frequency; - ci->set_elapsed(elapsed_time); - /* Remark: rockbox offset is the file offset in bytes. So estimate - * this offset from the samples, sampling frequency and bitrate */ - ci->set_offset( (samplesdone * byterate)/(frequency*100) ); - } - } while (true); -} diff --git a/apps/codecs/nsf.c b/apps/codecs/nsf.c deleted file mode 100644 index 4c5b37c3fa..0000000000 --- a/apps/codecs/nsf.c +++ /dev/null @@ -1,135 +0,0 @@ - -/* Ripped off from Game_Music_Emu 0.5.2. http://www.slack.net/~ant/ */ - -#define GME_NSF_TYPE - -#include -#include "libgme/nsf_emu.h" - -CODEC_HEADER - -/* Maximum number of bytes to process in one iteration */ -#define CHUNK_SIZE (1024*2) - -static int16_t samples[CHUNK_SIZE] IBSS_ATTR; -static struct Nsf_Emu nsf_emu; - -/****************** rockbox interface ******************/ - -static void set_codec_track(int t, int multitrack) { - Nsf_start_track(&nsf_emu, t); - - /* for REPEAT_ONE we disable track limits */ - if (!ci->loop_track()) { - Track_set_fade(&nsf_emu, Track_length( &nsf_emu, t ) - 4000, 4000); - } - if (multitrack) ci->set_elapsed(t*1000); /* t is track no to display */ - else ci->set_elapsed(0); -} - -/* this is the codec entry point */ -enum codec_status codec_main(enum codec_entry_call_reason reason) -{ - if (reason == CODEC_LOAD) { - /* we only render 16 bits */ - ci->configure(DSP_SET_SAMPLE_DEPTH, 16); - - /* 44 Khz, Interleaved stereo */ - ci->configure(DSP_SET_FREQUENCY, 44100); - ci->configure(DSP_SET_STEREO_MODE, STEREO_INTERLEAVED); - - Nsf_init(&nsf_emu); - Nsf_set_sample_rate(&nsf_emu, 44100); - } - - return CODEC_OK; -} - -/* this is called for each file to process */ -enum codec_status codec_run(void) -{ - blargg_err_t err; - uint8_t *buf; - size_t n; - int track, is_multitrack; - uint32_t elapsed_time; - intptr_t param; - - track = is_multitrack = 0; - elapsed_time = 0; - - DEBUGF("NSF: next_track\n"); - if (codec_init()) { - return CODEC_ERROR; - } - - codec_set_replaygain(ci->id3); - - /* Read the entire file */ - DEBUGF("NSF: request file\n"); - ci->seek_buffer(0); - buf = ci->request_buffer(&n, ci->filesize); - if (!buf || n < (size_t)ci->filesize) { - DEBUGF("NSF: file load failed\n"); - return CODEC_ERROR; - } - - if ((err = Nsf_load_mem(&nsf_emu, buf, ci->filesize))) { - DEBUGF("NSF: Nsf_load_mem failed (%s)\n", err); - return CODEC_ERROR; - } - - /* Update internal track count */ - if (nsf_emu.m3u.size > 0) - nsf_emu.track_count = nsf_emu.m3u.size; - - if (nsf_emu.track_count > 1) is_multitrack = 1; - -next_track: - set_codec_track(track, is_multitrack); - - /* The main decoder loop */ - while (1) { - enum codec_command_action action = ci->get_command(¶m); - - if (action == CODEC_ACTION_HALT) - break; - - if (action == CODEC_ACTION_SEEK_TIME) { - if (is_multitrack) { - track = param/1000; - ci->seek_complete(); - if (track >= nsf_emu.track_count) break; - goto next_track; - } - - ci->set_elapsed(param); - elapsed_time = param; - Track_seek(&nsf_emu, param); - ci->seek_complete(); - - /* Set fade again */ - if (!ci->loop_track()) { - Track_set_fade(&nsf_emu, Track_length( &nsf_emu, track ), 4000); - } - } - - /* Generate audio buffer */ - err = Nsf_play(&nsf_emu, CHUNK_SIZE, samples); - if (err || Track_ended(&nsf_emu)) { - track++; - if (track >= nsf_emu.track_count) break; - goto next_track; - } - - ci->pcmbuf_insert(samples, NULL, CHUNK_SIZE >> 1); - - /* Set elapsed time for one track files */ - if (is_multitrack == 0) { - elapsed_time += (CHUNK_SIZE / 2) * 10 / 441; - ci->set_elapsed(elapsed_time); - } - } - - return CODEC_OK; -} diff --git a/apps/codecs/raac.c b/apps/codecs/raac.c deleted file mode 100644 index 0ef7e715bc..0000000000 --- a/apps/codecs/raac.c +++ /dev/null @@ -1,212 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2009 Mohamed Tarek - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ - -#include "codeclib.h" -#include "librm/rm.h" -#include "libfaad/common.h" -#include "libfaad/structs.h" -#include "libfaad/decoder.h" -/* rockbox: not used -#include "libfaad/output.h" -*/ - -CODEC_HEADER - -static void init_rm(RMContext *rmctx) -{ - memcpy(rmctx, (void*)(( (intptr_t)ci->id3->id3v2buf + 3 ) &~ 3), sizeof(RMContext)); -} - -static RMContext rmctx; -static RMPacket pkt; - -/* this is the codec entry point */ -enum codec_status codec_main(enum codec_entry_call_reason reason) -{ - if (reason == CODEC_LOAD) { - /* Generic codec initialisation */ - ci->configure(DSP_SET_STEREO_MODE, STEREO_NONINTERLEAVED); - ci->configure(DSP_SET_SAMPLE_DEPTH, 29); - } - - return CODEC_OK; -} - -/* this is called for each file to process */ -enum codec_status codec_run(void) -{ - static NeAACDecFrameInfo frame_info; - NeAACDecHandle decoder; - size_t n; - unsigned int i; - unsigned char* buffer; - int err, consumed, pkt_offset, skipped = 0; - uint32_t s = 0; /* sample rate */ - unsigned char c = 0; /* channels */ - int playback_on = -1; - size_t resume_offset; - intptr_t param; - enum codec_command_action action = CODEC_ACTION_NULL; - - if (codec_init()) { - DEBUGF("FAAD: Codec init error\n"); - return CODEC_ERROR; - } - - resume_offset = ci->id3->offset; - - ci->memset(&rmctx,0,sizeof(RMContext)); - ci->memset(&pkt,0,sizeof(RMPacket)); - - ci->seek_buffer(0); - - init_rm(&rmctx); - ci->configure(DSP_SWITCH_FREQUENCY, ci->id3->frequency); - codec_set_replaygain(ci->id3); - - /* initialise the sound converter */ - decoder = NeAACDecOpen(); - - if (!decoder) { - DEBUGF("FAAD: Decode open error\n"); - return CODEC_ERROR; - } - - NeAACDecConfigurationPtr conf = NeAACDecGetCurrentConfiguration(decoder); - conf->outputFormat = FAAD_FMT_16BIT; /* irrelevant, we don't convert */ - NeAACDecSetConfiguration(decoder, conf); - - decoder->config.defObjectType = rmctx.codec_extradata[0]; - decoder->config.defSampleRate = rmctx.sample_rate; - err = NeAACDecInit(decoder, NULL, 0, &s, &c); - - if (err) { - DEBUGF("FAAD: DecInit: %d, %d\n", err, decoder->object_type); - return CODEC_ERROR; - } - - /* check for a mid-track resume and force a seek time accordingly */ - if(resume_offset > rmctx.data_offset + DATA_HEADER_SIZE) { - resume_offset -= rmctx.data_offset + DATA_HEADER_SIZE; - /* put number of subpackets to skip in resume_offset */ - resume_offset /= (rmctx.block_align + PACKET_HEADER_SIZE); - param = (int)resume_offset * ((rmctx.block_align * 8 * 1000)/rmctx.bit_rate); - action = CODEC_ACTION_SEEK_TIME; - } - ci->set_elapsed(0); - ci->advance_buffer(rmctx.data_offset + DATA_HEADER_SIZE); - - /* The main decoding loop */ - while (1) { - if (action == CODEC_ACTION_NULL) - action = ci->get_command(¶m); - - if (action == CODEC_ACTION_HALT) - break; - - if (action == CODEC_ACTION_SEEK_TIME) { - /* Do not allow seeking beyond the file's length */ - if ((unsigned) param > ci->id3->length) { - ci->set_elapsed(ci->id3->length); - ci->seek_complete(); - break; - } - - ci->seek_buffer(rmctx.data_offset + DATA_HEADER_SIZE); - - /* Seek to the start of the track */ - if (param == 0) { - ci->set_elapsed(0); - ci->seek_complete(); - action = CODEC_ACTION_NULL; - continue; - } - - skipped = 0; - while(1) { - buffer = ci->request_buffer(&n,rmctx.audio_framesize + 1000); - pkt_offset = skipped - pkt.length; - consumed = rm_get_packet(&buffer, &rmctx, &pkt); - if(consumed < 0 && playback_on != 0) { - if(playback_on == -1) { - /* Error only if packet-parsing failed and playback hadn't started */ - DEBUGF("rm_get_packet failed\n"); - ci->seek_complete(); - return CODEC_ERROR; - } - else { - ci->seek_complete(); - return CODEC_OK; - } - } - skipped += pkt.length; - - if(pkt.timestamp > (unsigned)param) - break; - - ci->advance_buffer(pkt.length); - } - ci->seek_buffer(pkt_offset + rmctx.data_offset + DATA_HEADER_SIZE); - buffer = ci->request_buffer(&n,rmctx.audio_framesize + 1000); - NeAACDecPostSeekReset(decoder, decoder->frame); - ci->set_elapsed(pkt.timestamp); - ci->seek_complete(); - } - - action = CODEC_ACTION_NULL; - - /* Request the required number of bytes from the input buffer */ - buffer=ci->request_buffer(&n,rmctx.audio_framesize + 1000); - consumed = rm_get_packet(&buffer, &rmctx, &pkt); - - if(consumed < 0 && playback_on != 0) { - if(playback_on == -1) { - /* Error only if packet-parsing failed and playback hadn't started */ - DEBUGF("rm_get_packet failed\n"); - return CODEC_ERROR; - } - else - break; - } - - playback_on = 1; - if (pkt.timestamp >= ci->id3->length) - break; - - /* Decode one block - returned samples will be host-endian */ - for(i = 0; i < rmctx.sub_packet_cnt; i++) { - NeAACDecDecode(decoder, &frame_info, buffer, rmctx.sub_packet_lengths[i]); - buffer += rmctx.sub_packet_lengths[i]; - if (frame_info.error > 0) { - DEBUGF("FAAD: decode error '%s'\n", NeAACDecGetErrorMessage(frame_info.error)); - return CODEC_ERROR; - } - ci->pcmbuf_insert(decoder->time_out[0], - decoder->time_out[1], - decoder->frameLength); - ci->set_elapsed(pkt.timestamp); - } - - ci->advance_buffer(pkt.length); - } - - return CODEC_OK; -} diff --git a/apps/codecs/sgc.c b/apps/codecs/sgc.c deleted file mode 100644 index 348a54a2d3..0000000000 --- a/apps/codecs/sgc.c +++ /dev/null @@ -1,123 +0,0 @@ - -/* Ripped off from Game_Music_Emu 0.5.2. http://www.slack.net/~ant/ */ - -#include -#include "libgme/sgc_emu.h" - -CODEC_HEADER - -/* Maximum number of bytes to process in one iteration */ -#define CHUNK_SIZE (1024*2) - -static int16_t samples[CHUNK_SIZE] IBSS_ATTR; -static struct Sgc_Emu sgc_emu; - -/* Coleco Bios */ -/* Colecovision not supported yet -static char coleco_bios[0x2000]; -*/ - -/****************** rockbox interface ******************/ - -static void set_codec_track(int t) { - Sgc_start_track(&sgc_emu, t); - - /* for REPEAT_ONE we disable track limits */ - if (!ci->loop_track()) { - Track_set_fade(&sgc_emu, Track_get_length( &sgc_emu, t ), 4000); - } - ci->set_elapsed(t*1000); /* t is track no to display */ -} - -/* this is the codec entry point */ -enum codec_status codec_main(enum codec_entry_call_reason reason) -{ - if (reason == CODEC_LOAD) { - /* we only render 16 bits */ - ci->configure(DSP_SET_SAMPLE_DEPTH, 16); - - /* 44 Khz, Interleaved stereo */ - ci->configure(DSP_SET_FREQUENCY, 44100); - ci->configure(DSP_SET_STEREO_MODE, STEREO_INTERLEAVED); - - Sgc_init(&sgc_emu); - Sgc_set_sample_rate(&sgc_emu, 44100); - - /* set coleco bios, should be named coleco_bios.rom */ - /* Colecovision not supported yet - int fd = ci->open("/coleco_bios.rom", O_RDONLY); - if ( fd >= 0 ) { - ci->read(fd, coleco_bios, 0x2000); - ci->close(fd); - set_coleco_bios( &sgc_emu, coleco_bios ); - } - */ - } - - return CODEC_OK; -} - -/* this is called for each file to process */ -enum codec_status codec_run(void) -{ - blargg_err_t err; - uint8_t *buf; - size_t n; - intptr_t param; - int track = 0; - - DEBUGF("SGC: next_track\n"); - if (codec_init()) { - return CODEC_ERROR; - } - - codec_set_replaygain(ci->id3); - - /* Read the entire file */ - DEBUGF("SGC: request file\n"); - ci->seek_buffer(0); - buf = ci->request_buffer(&n, ci->filesize); - if (!buf || n < (size_t)ci->filesize) { - DEBUGF("SGC: file load failed\n"); - return CODEC_ERROR; - } - - if ((err = Sgc_load_mem(&sgc_emu, buf, ci->filesize))) { - DEBUGF("SGC: Sgc_load_mem failed (%s)\n", err); - return CODEC_ERROR; - } - - /* Update internal track count */ - if (sgc_emu.m3u.size > 0) - sgc_emu.track_count = sgc_emu.m3u.size; - -next_track: - set_codec_track(track); - - /* The main decoder loop */ - while (1) { - enum codec_command_action action = ci->get_command(¶m); - - if (action == CODEC_ACTION_HALT) - break; - - if (action == CODEC_ACTION_SEEK_TIME) { - track = param/1000; - ci->seek_complete(); - if (track >= sgc_emu.track_count) break; - goto next_track; - } - - /* Generate audio buffer */ - err = Sgc_play(&sgc_emu, CHUNK_SIZE, samples); - if (err || Track_ended(&sgc_emu)) { - track++; - if (track >= sgc_emu.track_count) break; - goto next_track; - } - - ci->pcmbuf_insert(samples, NULL, CHUNK_SIZE >> 1); - } - - return CODEC_OK; -} diff --git a/apps/codecs/shorten.c b/apps/codecs/shorten.c deleted file mode 100644 index a8ab3f30a0..0000000000 --- a/apps/codecs/shorten.c +++ /dev/null @@ -1,164 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id: - * - * Copyright (C) 2005 Mark Arigo - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ - -#include "codeclib.h" -#include - -CODEC_HEADER - -#ifndef IBSS_ATTR_SHORTEN_DECODED0 -#define IBSS_ATTR_SHORTEN_DECODED0 IBSS_ATTR -#endif - -static int32_t decoded0[MAX_DECODE_SIZE] IBSS_ATTR_SHORTEN_DECODED0; -static int32_t decoded1[MAX_DECODE_SIZE] IBSS_ATTR; - -static int32_t offset0[MAX_OFFSET_SIZE] IBSS_ATTR; -static int32_t offset1[MAX_OFFSET_SIZE] IBSS_ATTR; - -static int8_t ibuf[MAX_BUFFER_SIZE] IBSS_ATTR; - -/* this is the codec entry point */ -enum codec_status codec_main(enum codec_entry_call_reason reason) -{ - if (reason == CODEC_LOAD) { - /* Generic codec initialisation */ - ci->configure(DSP_SET_STEREO_MODE, STEREO_NONINTERLEAVED); - ci->configure(DSP_SET_SAMPLE_DEPTH, SHN_OUTPUT_DEPTH-1); - } - - return CODEC_OK; -} - -/* this is called for each file to process */ -enum codec_status codec_run(void) -{ - ShortenContext sc; - uint32_t samplesdone; - uint32_t elapsedtime; - int8_t *buf; - int consumed, res, nsamples; - size_t bytesleft; - intptr_t param; - - /* Codec initialization */ - if (codec_init()) { - LOGF("Shorten: codec_init error\n"); - return CODEC_ERROR; - } - - codec_set_replaygain(ci->id3); - - /* Shorten decoder initialization */ - ci->memset(&sc, 0, sizeof(ShortenContext)); - - /* Skip id3v2 tags */ - ci->seek_buffer(ci->id3->first_frame_offset); - - /* Read the shorten & wave headers */ - buf = ci->request_buffer(&bytesleft, MAX_HEADER_SIZE); - res = shorten_init(&sc, (unsigned char *)buf, bytesleft); - if (res < 0) { - LOGF("Shorten: shorten_init error: %d\n", res); - return CODEC_ERROR; - } - - ci->id3->frequency = sc.sample_rate; - ci->configure(DSP_SWITCH_FREQUENCY, sc.sample_rate); - - if (sc.sample_rate) { - ci->id3->length = (sc.totalsamples / sc.sample_rate) * 1000; - } else { - ci->id3->length = 0; - } - - if (ci->id3->length) { - ci->id3->bitrate = (ci->id3->filesize * 8) / ci->id3->length; - } - - consumed = sc.gb.index/8; - ci->advance_buffer(consumed); - sc.bitindex = sc.gb.index - 8*consumed; - -seek_start: - ci->set_elapsed(0); - - /* The main decoding loop */ - ci->memset(&decoded0, 0, sizeof(int32_t)*MAX_DECODE_SIZE); - ci->memset(&decoded1, 0, sizeof(int32_t)*MAX_DECODE_SIZE); - ci->memset(&offset0, 0, sizeof(int32_t)*MAX_OFFSET_SIZE); - ci->memset(&offset1, 0, sizeof(int32_t)*MAX_OFFSET_SIZE); - - samplesdone = 0; - buf = ci->request_buffer(&bytesleft, MAX_BUFFER_SIZE); - while (bytesleft) { - enum codec_command_action action = ci->get_command(¶m); - - if (action == CODEC_ACTION_HALT) - break; - - /* Seek to start of track */ - if (action == CODEC_ACTION_SEEK_TIME) { - if (param == 0 && - ci->seek_buffer(sc.header_bits/8 + ci->id3->first_frame_offset)) { - sc.bitindex = sc.header_bits - 8*(sc.header_bits/8); - ci->seek_complete(); - goto seek_start; - } - ci->seek_complete(); - } - - /* Decode a frame */ - ci->memcpy(ibuf, buf, bytesleft); /* copy buf to iram */ - res = shorten_decode_frames(&sc, &nsamples, decoded0, decoded1, - offset0, offset1, (unsigned char *)ibuf, - bytesleft, ci->yield); - - if (res == FN_ERROR) { - LOGF("Shorten: shorten_decode_frames error (%lu)\n", - (unsigned long)samplesdone); - return CODEC_ERROR; - } else { - /* Insert decoded samples in pcmbuf */ - if (nsamples) { - ci->yield(); - ci->pcmbuf_insert(decoded0 + sc.nwrap, decoded1 + sc.nwrap, - nsamples); - - /* Update the elapsed-time indicator */ - samplesdone += nsamples; - elapsedtime = (samplesdone*10) / (sc.sample_rate/100); - ci->set_elapsed(elapsedtime); - } - - /* End of shorten stream...go to next track */ - if (res == FN_QUIT) - break; - } - - consumed = sc.gb.index/8; - ci->advance_buffer(consumed); - buf = ci->request_buffer(&bytesleft, MAX_BUFFER_SIZE); - sc.bitindex = sc.gb.index - 8*consumed; - } - - return CODEC_OK; -} diff --git a/apps/codecs/sid.c b/apps/codecs/sid.c deleted file mode 100644 index 9b19a20ba7..0000000000 --- a/apps/codecs/sid.c +++ /dev/null @@ -1,1340 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * SID Codec for rockbox based on the TinySID engine - * - * Written by Tammo Hinrichs (kb) and Rainer Sinsch in 1998-1999 - * Ported to rockbox on 14 April 2006 - * - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ - - /***************************** - * kb explicitly points out that this emulation sounds crappy, though - * we decided to put it open source so everyone can enjoy sidmusic - * on rockbox - * - *****************************/ - - /********************* - * v1.1 - * Added 16-04-2006: Rainer Sinsch - * Removed all time critical floating point operations and - * replaced them with quick & dirty integer calculations - * - * Added 17-04-2006: Rainer Sinsch - * Improved quick & dirty integer calculations for the resonant filter - * Improved audio quality by 4 bits - * - * v1.2 - * Added 17-04-2006: Dave Chapman - * Improved file loading - * - * Added 17-04-2006: Rainer Sinsch - * Added sample routines - * Added cia timing routines - * Added fast forwarding capabilities - * Corrected bug in sid loading - * - * v1.2.1 - * Added 04-05-2006: Rainer Sinsch - * Implemented Marco Alanens suggestion for subsong selection: - * Select the subsong by seeking: Each second represents a subsong - * - **************************/ - -#define USE_FILTER - -#include "debug.h" -#include "codeclib.h" -#include - -CODEC_HEADER - -#define CHUNK_SIZE (1024*2) -#define SID_BUFFER_SIZE 0x10000 -#define SAMPLE_RATE 44100 - -/* This codec supports SID Files: - * - */ - -static int32_t samples[CHUNK_SIZE] IBSS_ATTR; /* The sample buffer */ - -void sidPoke(int reg, unsigned char val) ICODE_ATTR; - -#define FLAG_N 128 -#define FLAG_V 64 -#define FLAG_B 16 -#define FLAG_D 8 -#define FLAG_I 4 -#define FLAG_Z 2 -#define FLAG_C 1 - -#define imp 0 -#define imm 1 -#define _abs 2 -#define absx 3 -#define absy 4 -#define zp 6 -#define zpx 7 -#define zpy 8 -#define ind 9 -#define indx 10 -#define indy 11 -#define acc 12 -#define rel 13 - -enum { - adc, _and, asl, bcc, bcs, beq, bit, bmi, bne, bpl, _brk, bvc, bvs, clc, - cld, cli, clv, cmp, cpx, cpy, dec, dex, dey, eor, inc, inx, iny, jmp, - jsr, lda, ldx, ldy, lsr, _nop, ora, pha, php, pla, plp, rol, ror, rti, - rts, sbc, sec, sed, sei, sta, stx, sty, tax, tay, tsx, txa, txs, tya, - xxx -}; - -/* SID register definition */ -struct s6581 { - struct sidvoice { - unsigned short freq; - unsigned short pulse; - unsigned char wave; - unsigned char ad; - unsigned char sr; - } v[3]; - unsigned char ffreqlo; - unsigned char ffreqhi; - unsigned char res_ftv; - unsigned char ftp_vol; -}; - -/* internal oscillator def */ -struct sidosc { - unsigned long freq; - unsigned long pulse; - unsigned char wave; - unsigned char filter; - unsigned long attack; - unsigned long decay; - unsigned long sustain; - unsigned long release; - unsigned long counter; - signed long envval; - unsigned char envphase; - unsigned long noisepos; - unsigned long noiseval; - unsigned char noiseout; -}; - -/* internal filter def */ -struct sidflt { - int freq; - unsigned char l_ena; - unsigned char b_ena; - unsigned char h_ena; - unsigned char v3ena; - int vol; - int rez; - int h; - int b; - int l; -}; - -/* ------------------------ pseudo-constants (depending on mixing freq) */ -int mixing_frequency IDATA_ATTR; -unsigned long freqmul IDATA_ATTR; -int filtmul IDATA_ATTR; -#ifndef ROCKBOX -unsigned long attacks [16] IDATA_ATTR; -unsigned long releases[16] IDATA_ATTR; -#endif - -/* ------------------------------------------------------------ globals */ -struct s6581 sid IDATA_ATTR; -struct sidosc osc[3] IDATA_ATTR; -struct sidflt filter IDATA_ATTR; - -/* ------------------------------------------------------ C64 Emu Stuff */ -unsigned char bval IDATA_ATTR; -unsigned short wval IDATA_ATTR; -/* -------------------------------------------------- Register & memory */ -unsigned char a,x,y,s,p IDATA_ATTR; -unsigned short pc IDATA_ATTR; - -unsigned char memory[65536]; - -/* ----------------------------------------- Variables for sample stuff */ -static int sample_active IDATA_ATTR; -static int sample_position, sample_start, sample_end, sample_repeat_start IDATA_ATTR; -static int fracPos IDATA_ATTR; /* Fractal position of sample */ -static int sample_period IDATA_ATTR; -static int sample_repeats IDATA_ATTR; -static int sample_order IDATA_ATTR; -static int sample_nibble IDATA_ATTR; - -static int internal_period, internal_order, internal_start, internal_end, - internal_add, internal_repeat_times, internal_repeat_start IDATA_ATTR; - -/* ---------------------------------------------------------- constants */ -#ifndef ROCKBOX -static const float attackTimes[16] ICONST_ATTR = -{ - 0.0022528606, 0.0080099577, 0.0157696042, 0.0237795619, - 0.0372963655, 0.0550684591, 0.0668330845, 0.0783473987, - 0.0981219818, 0.244554021, 0.489108042, 0.782472742, - 0.977715461, 2.93364701, 4.88907793, 7.82272493 -}; -static const float decayReleaseTimes[16] ICONST_ATTR = -{ - 0.00891777693, 0.024594051, 0.0484185907, 0.0730116639, 0.114512475, - 0.169078356, 0.205199432, 0.240551975, 0.301266125, 0.750858245, - 1.50171551, 2.40243682, 3.00189298, 9.00721405, 15.010998, 24.0182111 -}; -#else -#define DIV(X) ((int)(0x1000000 / (X * SAMPLE_RATE))) -static const unsigned long attacks[16] ICONST_ATTR = -{ - DIV(0.0022528606), DIV(0.0080099577), DIV(0.0157696042), DIV(0.0237795619), - DIV(0.0372963655), DIV(0.0550684591), DIV(0.0668330845), DIV(0.0783473987), - DIV(0.0981219818), DIV(0.2445540210), DIV(0.4891080420), DIV(0.7824727420), - DIV(0.9777154610), DIV(2.9336470100), DIV(4.8890779300), DIV(7.8227249300) -}; -static const unsigned long releases[16] ICONST_ATTR = -{ - DIV(0.00891777693), DIV(0.0245940510), DIV(0.0484185907), DIV(0.0730116639), - DIV(0.11451247500), DIV(0.1690783560), DIV(0.2051994320), DIV(0.2405519750), - DIV(0.30126612500), DIV(0.7508582450), DIV(1.5017155100), DIV(2.4024368200), - DIV(3.00189298000), DIV(9.0072140500), DIV(15.010998000), DIV(24.018211100) -}; -#endif -static const int opcodes[256] ICONST_ATTR = { - _brk,ora,xxx,xxx,xxx,ora,asl,xxx,php,ora,asl,xxx,xxx,ora,asl,xxx, - bpl,ora,xxx,xxx,xxx,ora,asl,xxx,clc,ora,xxx,xxx,xxx,ora,asl,xxx, - jsr,_and,xxx,xxx,bit,_and,rol,xxx,plp,_and,rol,xxx,bit,_and,rol,xxx, - bmi,_and,xxx,xxx,xxx,_and,rol,xxx,sec,_and,xxx,xxx,xxx,_and,rol,xxx, - rti,eor,xxx,xxx,xxx,eor,lsr,xxx,pha,eor,lsr,xxx,jmp,eor,lsr,xxx, - bvc,eor,xxx,xxx,xxx,eor,lsr,xxx,cli,eor,xxx,xxx,xxx,eor,lsr,xxx, - rts,adc,xxx,xxx,xxx,adc,ror,xxx,pla,adc,ror,xxx,jmp,adc,ror,xxx, - bvs,adc,xxx,xxx,xxx,adc,ror,xxx,sei,adc,xxx,xxx,xxx,adc,ror,xxx, - xxx,sta,xxx,xxx,sty,sta,stx,xxx,dey,xxx,txa,xxx,sty,sta,stx,xxx, - bcc,sta,xxx,xxx,sty,sta,stx,xxx,tya,sta,txs,xxx,xxx,sta,xxx,xxx, - ldy,lda,ldx,xxx,ldy,lda,ldx,xxx,tay,lda,tax,xxx,ldy,lda,ldx,xxx, - bcs,lda,xxx,xxx,ldy,lda,ldx,xxx,clv,lda,tsx,xxx,ldy,lda,ldx,xxx, - cpy,cmp,xxx,xxx,cpy,cmp,dec,xxx,iny,cmp,dex,xxx,cpy,cmp,dec,xxx, - bne,cmp,xxx,xxx,xxx,cmp,dec,xxx,cld,cmp,xxx,xxx,xxx,cmp,dec,xxx, - cpx,sbc,xxx,xxx,cpx,sbc,inc,xxx,inx,sbc,_nop,xxx,cpx,sbc,inc,xxx, - beq,sbc,xxx,xxx,xxx,sbc,inc,xxx,sed,sbc,xxx,xxx,xxx,sbc,inc,xxx -}; - - -static const int modes[256] ICONST_ATTR = { - imp,indx,xxx,xxx,zp,zp,zp,xxx,imp,imm,acc,xxx,_abs,_abs,_abs,xxx, - rel,indy,xxx,xxx,xxx,zpx,zpx,xxx,imp,absy,xxx,xxx,xxx,absx,absx,xxx, - _abs,indx,xxx,xxx,zp,zp,zp,xxx,imp,imm,acc,xxx,_abs,_abs,_abs,xxx, - rel,indy,xxx,xxx,xxx,zpx,zpx,xxx,imp,absy,xxx,xxx,xxx,absx,absx,xxx, - imp,indx,xxx,xxx,zp,zp,zp,xxx,imp,imm,acc,xxx,_abs,_abs,_abs,xxx, - rel,indy,xxx,xxx,xxx,zpx,zpx,xxx,imp,absy,xxx,xxx,xxx,absx,absx,xxx, - imp,indx,xxx,xxx,zp,zp,zp,xxx,imp,imm,acc,xxx,ind,_abs,_abs,xxx, - rel,indy,xxx,xxx,xxx,zpx,zpx,xxx,imp,absy,xxx,xxx,xxx,absx,absx,xxx, - imm,indx,xxx,xxx,zp,zp,zp,xxx,imp,imm,acc,xxx,_abs,_abs,_abs,xxx, - rel,indy,xxx,xxx,zpx,zpx,zpy,xxx,imp,absy,acc,xxx,xxx,absx,absx,xxx, - imm,indx,imm,xxx,zp,zp,zp,xxx,imp,imm,acc,xxx,_abs,_abs,_abs,xxx, - rel,indy,xxx,xxx,zpx,zpx,zpy,xxx,imp,absy,acc,xxx,absx,absx,absy,xxx, - imm,indx,xxx,xxx,zp,zp,zp,xxx,imp,imm,acc,xxx,_abs,_abs,_abs,xxx, - rel,indy,xxx,xxx,zpx,zpx,zpx,xxx,imp,absy,acc,xxx,xxx,absx,absx,xxx, - imm,indx,xxx,xxx,zp,zp,zp,xxx,imp,imm,acc,xxx,_abs,_abs,_abs,xxx, - rel,indy,xxx,xxx,zpx,zpx,zpx,xxx,imp,absy,acc,xxx,xxx,absx,absx,xxx -}; - -/* Routines for quick & dirty float calculation */ - -static inline int quickfloat_ConvertFromInt(int i) -{ - return (i<<16); -} -#ifndef ROCKBOX -static inline int quickfloat_ConvertFromFloat(float f) -{ - return (int)(f*(1<<16)); -} -#else -#define quickfloat_ConvertFromFloat(X) (int)(X*(1<<16)) -#endif -static inline int quickfloat_Multiply(int a, int b) -{ - return (a>>8)*(b>>8); -} -static inline int quickfloat_ConvertToInt(int i) -{ - return (i>>16); -} - -/* Get the bit from an unsigned long at a specified position */ -static inline unsigned char get_bit(unsigned long val, unsigned char b) -{ - return (unsigned char) ((val >> b) & 1); -} - - -static inline int GenerateDigi(int sIn) -{ - static int sample = 0; - - if (!sample_active) return(sIn); - - if ((sample_position < sample_end) && (sample_position >= sample_start)) - { - sIn += sample; - - fracPos += 985248/sample_period; - - if (fracPos > mixing_frequency) - { - fracPos%=mixing_frequency; - - // N�hstes Samples holen - if (sample_order == 0) { - sample_nibble++; // Nähstes Sample-Nibble - if (sample_nibble==2) { - sample_nibble = 0; - sample_position++; - } - } - else { - sample_nibble--; - if (sample_nibble < 0) { - sample_nibble=1; - sample_position++; - } - } - if (sample_repeats) - { - if (sample_position > sample_end) - { - sample_repeats--; - sample_position = sample_repeat_start; - } - else sample_active = 0; - } - - sample = memory[sample_position&0xffff]; - if (sample_nibble==1) // Hi-Nibble holen? - sample = (sample & 0xf0)>>4; - else sample = sample & 0x0f; - - sample -= 7; - sample <<= 10; - } - } - - return (sIn); -} - -/* ------------------------------------------------------------- synthesis - initialize SID and frequency dependant values */ -void synth_init(unsigned long mixfrq) ICODE_ATTR; -void synth_init(unsigned long mixfrq) -{ -#ifndef ROCKBOX - int i; -#endif - mixing_frequency = mixfrq; - fracPos = 0; - freqmul = 15872000 / mixfrq; - filtmul = quickfloat_ConvertFromFloat(21.5332031f)/mixfrq; -#ifndef ROCKBOX - for (i=0;i<16;i++) { - attacks [i]=(int) (0x1000000 / (attackTimes[i]*mixfrq)); - releases[i]=(int) (0x1000000 / (decayReleaseTimes[i]*mixfrq)); - } -#endif - memset(&sid,0,sizeof(sid)); - memset(osc,0,sizeof(osc)); - memset(&filter,0,sizeof(filter)); - osc[0].noiseval = 0xffffff; - osc[1].noiseval = 0xffffff; - osc[2].noiseval = 0xffffff; -} - -/* render a buffer of n samples with the actual register contents */ -void synth_render (int32_t *buffer, unsigned long len) ICODE_ATTR; -void synth_render (int32_t *buffer, unsigned long len) -{ - unsigned long bp; - /* step 1: convert the not easily processable sid registers into some - more convenient and fast values (makes the thing much faster - if you process more than 1 sample value at once) */ - unsigned char v; - for (v=0;v<3;v++) { - osc[v].pulse = (sid.v[v].pulse & 0xfff) << 16; - osc[v].filter = get_bit(sid.res_ftv,v); - osc[v].attack = attacks[sid.v[v].ad >> 4]; - osc[v].decay = releases[sid.v[v].ad & 0xf]; - osc[v].sustain = sid.v[v].sr & 0xf0; - osc[v].release = releases[sid.v[v].sr & 0xf]; - osc[v].wave = sid.v[v].wave; - osc[v].freq = ((unsigned long)sid.v[v].freq)*freqmul; - } - -#ifdef USE_FILTER - filter.freq = (16*sid.ffreqhi + (sid.ffreqlo&0x7)) * filtmul; - - if (filter.freq>quickfloat_ConvertFromInt(1)) - filter.freq=quickfloat_ConvertFromInt(1); - /* the above line isnt correct at all - the problem is that the filter - works only up to rmxfreq/4 - this is sufficient for 44KHz but isnt - for 32KHz and lower - well, but sound quality is bad enough then to - neglect the fact that the filter doesnt come that high ;) */ - filter.l_ena = get_bit(sid.ftp_vol,4); - filter.b_ena = get_bit(sid.ftp_vol,5); - filter.h_ena = get_bit(sid.ftp_vol,6); - filter.v3ena = !get_bit(sid.ftp_vol,7); - filter.vol = (sid.ftp_vol & 0xf); - filter.rez = quickfloat_ConvertFromFloat(1.2f) - - quickfloat_ConvertFromFloat(0.04f)*(sid.res_ftv >> 4); - - /* We precalculate part of the quick float operation, saves time in loop later */ - filter.rez>>=8; -#endif - - - /* now render the buffer */ - for (bp=0;bp>19); - if (osc[v].counter>>27) - triout^=0xff; - unsigned char sawout = (unsigned char) (osc[v].counter >> 20); - unsigned char plsout = (unsigned char) ((osc[v].counter > osc[v].pulse)-1); - - /* generate noise waveform exactly as the SID does. */ - if (osc[v].noisepos!=(osc[v].counter>>23)) - { - osc[v].noisepos = osc[v].counter >> 23; - osc[v].noiseval = (osc[v].noiseval << 1) | - (get_bit(osc[v].noiseval,22) ^ get_bit(osc[v].noiseval,17)); - osc[v].noiseout = (get_bit(osc[v].noiseval,22) << 7) | - (get_bit(osc[v].noiseval,20) << 6) | - (get_bit(osc[v].noiseval,16) << 5) | - (get_bit(osc[v].noiseval,13) << 4) | - (get_bit(osc[v].noiseval,11) << 3) | - (get_bit(osc[v].noiseval, 7) << 2) | - (get_bit(osc[v].noiseval, 4) << 1) | - (get_bit(osc[v].noiseval, 2) << 0); - } - unsigned char nseout = osc[v].noiseout; - - /* modulate triangle wave if ringmod bit set */ - if (osc[v].wave & 0x04) - if (osc[refosc].counter < 0x8000000) - triout ^= 0xff; - - /* now mix the oscillators with an AND operation as stated in - the SID's reference manual - even if this is completely wrong. - well, at least, the $30 and $70 waveform sounds correct and there's - no real solution to do $50 and $60, so who cares. */ - - unsigned char outv=0xFF; - if (osc[v].wave & 0x10) outv &= triout; - if (osc[v].wave & 0x20) outv &= sawout; - if (osc[v].wave & 0x40) outv &= plsout; - if (osc[v].wave & 0x80) outv &= nseout; - - /* so now process the volume according to the phase and adsr values */ - switch (osc[v].envphase) { - case 0 : { /* Phase 0 : Attack */ - osc[v].envval+=osc[v].attack; - if (osc[v].envval >= 0xFFFFFF) - { - osc[v].envval = 0xFFFFFF; - osc[v].envphase = 1; - } - break; - } - case 1 : { /* Phase 1 : Decay */ - osc[v].envval-=osc[v].decay; - if ((signed int) osc[v].envval <= (signed int) (osc[v].sustain<<16)) - { - osc[v].envval = osc[v].sustain<<16; - osc[v].envphase = 2; - } - break; - } - case 2 : { /* Phase 2 : Sustain */ - if ((signed int) osc[v].envval != (signed int) (osc[v].sustain<<16)) - { - osc[v].envphase = 1; - } - /* :) yes, thats exactly how the SID works. and maybe - a music routine out there supports this, so better - let it in, thanks :) */ - break; - } - case 3 : { /* Phase 3 : Release */ - osc[v].envval-=osc[v].release; - if (osc[v].envval < 0x40000) osc[v].envval= 0x40000; - - /* the volume offset is because the SID does not - completely silence the voices when it should. most - emulators do so though and thats the main reason - why the sound of emulators is too, err... emulated :) */ - break; - } - } - -#ifdef USE_FILTER - - /* now route the voice output to either the non-filtered or the - filtered channel and dont forget to blank out osc3 if desired */ - - if (v<2 || filter.v3ena) - { - if (osc[v].filter) - outf+=(((int)(outv-0x80))*osc[v].envval)>>22; - else - outo+=(((int)(outv-0x80))*osc[v].envval)>>22; - } -#endif -#ifndef USE_FILTER - /* Don't use filters, just mix all voices together */ - outf+=((signed short)(outv-0x80)) * (osc[v].envval>>4); -#endif - } - - -#ifdef USE_FILTER - /* step 3 - * so, now theres finally time to apply the multi-mode resonant filter - * to the signal. The easiest thing ist just modelling a real electronic - * filter circuit instead of fiddling around with complex IIRs or even - * FIRs ... - * it sounds as good as them or maybe better and needs only 3 MULs and - * 4 ADDs for EVERYTHING. SIDPlay uses this kind of filter, too, but - * Mage messed the whole thing completely up - as the rest of the - * emulator. - * This filter sounds a lot like the 8580, as the low-quality, dirty - * sound of the 6581 is uuh too hard to achieve :) */ - - filter.h = quickfloat_ConvertFromInt(outf) - (filter.b>>8)*filter.rez - filter.l; - filter.b += quickfloat_Multiply(filter.freq, filter.h); - filter.l += quickfloat_Multiply(filter.freq, filter.b); - - outf = 0; - - if (filter.l_ena) outf+=quickfloat_ConvertToInt(filter.l); - if (filter.b_ena) outf+=quickfloat_ConvertToInt(filter.b); - if (filter.h_ena) outf+=quickfloat_ConvertToInt(filter.h); - - int final_sample = (filter.vol*(outo+outf)); - *(buffer+bp)= GenerateDigi(final_sample)<<13; -#endif -#ifndef USE_FILTER - *(buffer+bp) = GenerateDigi(outf)<<3; -#endif - } -} - - - -/* -* C64 Mem Routines -*/ -static inline unsigned char getmem(unsigned short addr) -{ - return memory[addr]; -} - -static inline void setmem(unsigned short addr, unsigned char value) -{ - if ((addr&0xfc00)==0xd400) - { - sidPoke(addr&0x1f,value); - /* New SID-Register */ - if (addr > 0xd418) - { - switch (addr) - { - case 0xd41f: /* Start-Hi */ - internal_start = (internal_start&0x00ff) | (value<<8); break; - case 0xd41e: /* Start-Lo */ - internal_start = (internal_start&0xff00) | (value); break; - case 0xd47f: /* Repeat-Hi */ - internal_repeat_start = (internal_repeat_start&0x00ff) | (value<<8); break; - case 0xd47e: /* Repeat-Lo */ - internal_repeat_start = (internal_repeat_start&0xff00) | (value); break; - case 0xd43e: /* End-Hi */ - internal_end = (internal_end&0x00ff) | (value<<8); break; - case 0xd43d: /* End-Lo */ - internal_end = (internal_end&0xff00) | (value); break; - case 0xd43f: /* Loop-Size */ - internal_repeat_times = value; break; - case 0xd45e: /* Period-Hi */ - internal_period = (internal_period&0x00ff) | (value<<8); break; - case 0xd45d: /* Period-Lo */ - internal_period = (internal_period&0xff00) | (value); break; - case 0xd47d: /* Sample Order */ - internal_order = value; break; - case 0xd45f: /* Sample Add */ - internal_add = value; break; - case 0xd41d: /* Start sampling */ - sample_repeats = internal_repeat_times; - sample_position = internal_start; - sample_start = internal_start; - sample_end = internal_end; - sample_repeat_start = internal_repeat_start; - sample_period = internal_period; - sample_order = internal_order; - switch (value) - { - case 0xfd: sample_active = 0; break; - case 0xfe: - case 0xff: sample_active = 1; break; - default: return; - } - break; - } - } - } - else memory[addr]=value; -} - -/* -* Poke a value into the sid register -*/ -void sidPoke(int reg, unsigned char val) ICODE_ATTR; -void sidPoke(int reg, unsigned char val) -{ - int voice=0; - - if ((reg >= 7) && (reg <=13)) {voice=1; reg-=7;} - else if ((reg >= 14) && (reg <=20)) {voice=2; reg-=14;} - - switch (reg) { - case 0: { /* Set frequency: Low byte */ - sid.v[voice].freq = (sid.v[voice].freq&0xff00)+val; - break; - } - case 1: { /* Set frequency: High byte */ - sid.v[voice].freq = (sid.v[voice].freq&0xff)+(val<<8); - break; - } - case 2: { /* Set pulse width: Low byte */ - sid.v[voice].pulse = (sid.v[voice].pulse&0xff00)+val; - break; - } - case 3: { /* Set pulse width: High byte */ - sid.v[voice].pulse = (sid.v[voice].pulse&0xff)+(val<<8); - break; - } - case 4: { sid.v[voice].wave = val; - /* Directly look at GATE-Bit! - * a change may happen twice or more often during one cpujsr - * Put the Envelope Generator into attack or release phase if desired - */ - if ((val & 0x01) == 0) osc[voice].envphase=3; - else if (osc[voice].envphase==3) osc[voice].envphase=0; - break; - } - - case 5: { sid.v[voice].ad = val; break;} - case 6: { sid.v[voice].sr = val; break;} - - case 21: { sid.ffreqlo = val; break; } - case 22: { sid.ffreqhi = val; break; } - case 23: { sid.res_ftv = val; break; } - case 24: { sid.ftp_vol = val; break;} - } - return; -} - -static inline unsigned char getaddr(int mode) -{ - unsigned short ad,ad2; - switch(mode) - { - case imp: - return 0; - case imm: - return getmem(pc++); - case _abs: - ad=getmem(pc++); - ad|=256*getmem(pc++); - return getmem(ad); - case absx: - ad=getmem(pc++); - ad|=256*getmem(pc++); - ad2=ad+x; - return getmem(ad2); - case absy: - ad=getmem(pc++); - ad|=256*getmem(pc++); - ad2=ad+y; - return getmem(ad2); - case zp: - ad=getmem(pc++); - return getmem(ad); - case zpx: - ad=getmem(pc++); - ad+=x; - return getmem(ad&0xff); - case zpy: - ad=getmem(pc++); - ad+=y; - return getmem(ad&0xff); - case indx: - ad=getmem(pc++); - ad+=x; - ad2=getmem(ad&0xff); - ad++; - ad2|=getmem(ad&0xff)<<8; - return getmem(ad2); - case indy: - ad=getmem(pc++); - ad2=getmem(ad); - ad2|=getmem((ad+1)&0xff)<<8; - ad=ad2+y; - return getmem(ad); - case acc: - return a; - } - return 0; -} - -static inline void setaddr(int mode, unsigned char val) -{ - unsigned short ad,ad2; - switch(mode) - { - case _abs: - ad=getmem(pc-2); - ad|=256*getmem(pc-1); - setmem(ad,val); - return; - case absx: - ad=getmem(pc-2); - ad|=256*getmem(pc-1); - ad2=ad+x; - setmem(ad2,val); - return; - case zp: - ad=getmem(pc-1); - setmem(ad,val); - return; - case zpx: - ad=getmem(pc-1); - ad+=x; - setmem(ad&0xff,val); - return; - case acc: - a=val; - return; - } -} - - -static inline void putaddr(int mode, unsigned char val) -{ - unsigned short ad,ad2; - switch(mode) - { - case _abs: - ad=getmem(pc++); - ad|=getmem(pc++)<<8; - setmem(ad,val); - return; - case absx: - ad=getmem(pc++); - ad|=getmem(pc++)<<8; - ad2=ad+x; - setmem(ad2,val); - return; - case absy: - ad=getmem(pc++); - ad|=getmem(pc++)<<8; - ad2=ad+y; - setmem(ad2,val); - return; - case zp: - ad=getmem(pc++); - setmem(ad,val); - return; - case zpx: - ad=getmem(pc++); - ad+=x; - setmem(ad&0xff,val); - return; - case zpy: - ad=getmem(pc++); - ad+=y; - setmem(ad&0xff,val); - return; - case indx: - ad=getmem(pc++); - ad+=x; - ad2=getmem(ad&0xff); - ad++; - ad2|=getmem(ad&0xff)<<8; - setmem(ad2,val); - return; - case indy: - ad=getmem(pc++); - ad2=getmem(ad); - ad2|=getmem((ad+1)&0xff)<<8; - ad=ad2+y; - setmem(ad,val); - return; - case acc: - a=val; - return; - } -} - - -static inline void setflags(int flag, int cond) -{ - if (cond) p|=flag; - else p&=~flag; -} - - -static inline void push(unsigned char val) -{ - setmem(0x100+s,val); - if (s) s--; -} - -static inline unsigned char pop(void) -{ - if (s<0xff) s++; - return getmem(0x100+s); -} - -static inline void branch(int flag) -{ - signed char dist; - dist=(signed char)getaddr(imm); - wval=pc+dist; - if (flag) pc=wval; -} - -void cpuReset(void) ICODE_ATTR; -void cpuReset(void) -{ - a=x=y=0; - p=0; - s=255; - pc=getaddr(0xfffc); -} - -void cpuResetTo(unsigned short npc, unsigned char na) ICODE_ATTR; -void cpuResetTo(unsigned short npc, unsigned char na) -{ - a=na; - x=0; - y=0; - p=0; - s=255; - pc=npc; -} - -static inline void cpuParse(void) -{ - unsigned char opc=getmem(pc++); - int cmd=opcodes[opc]; - int addr=modes[opc]; - int c; - switch (cmd) - { - case adc: - wval=(unsigned short)a+getaddr(addr)+((p&FLAG_C)?1:0); - setflags(FLAG_C, wval&0x100); - a=(unsigned char)wval; - setflags(FLAG_Z, !a); - setflags(FLAG_N, a&0x80); - setflags(FLAG_V, (!!(p&FLAG_C)) ^ (!!(p&FLAG_N))); - break; - case _and: - bval=getaddr(addr); - a&=bval; - setflags(FLAG_Z, !a); - setflags(FLAG_N, a&0x80); - break; - case asl: - wval=getaddr(addr); - wval<<=1; - setaddr(addr,(unsigned char)wval); - setflags(FLAG_Z,!wval); - setflags(FLAG_N,wval&0x80); - setflags(FLAG_C,wval&0x100); - break; - case bcc: - branch(!(p&FLAG_C)); - break; - case bcs: - branch(p&FLAG_C); - break; - case bne: - branch(!(p&FLAG_Z)); - break; - case beq: - branch(p&FLAG_Z); - break; - case bpl: - branch(!(p&FLAG_N)); - break; - case bmi: - branch(p&FLAG_N); - break; - case bvc: - branch(!(p&FLAG_V)); - break; - case bvs: - branch(p&FLAG_V); - break; - case bit: - bval=getaddr(addr); - setflags(FLAG_Z,!(a&bval)); - setflags(FLAG_N,bval&0x80); - setflags(FLAG_V,bval&0x40); - break; - case _brk: - pc=0; /* Just quit the emulation */ - break; - case clc: - setflags(FLAG_C,0); - break; - case cld: - setflags(FLAG_D,0); - break; - case cli: - setflags(FLAG_I,0); - break; - case clv: - setflags(FLAG_V,0); - break; - case cmp: - bval=getaddr(addr); - wval=(unsigned short)a-bval; - setflags(FLAG_Z,!wval); - setflags(FLAG_N,wval&0x80); - setflags(FLAG_C,a>=bval); - break; - case cpx: - bval=getaddr(addr); - wval=(unsigned short)x-bval; - setflags(FLAG_Z,!wval); - setflags(FLAG_N,wval&0x80); - setflags(FLAG_C,x>=bval); - break; - case cpy: - bval=getaddr(addr); - wval=(unsigned short)y-bval; - setflags(FLAG_Z,!wval); - setflags(FLAG_N,wval&0x80); - setflags(FLAG_C,y>=bval); - break; - case dec: - bval=getaddr(addr); - bval--; - setaddr(addr,bval); - setflags(FLAG_Z,!bval); - setflags(FLAG_N,bval&0x80); - break; - case dex: - x--; - setflags(FLAG_Z,!x); - setflags(FLAG_N,x&0x80); - break; - case dey: - y--; - setflags(FLAG_Z,!y); - setflags(FLAG_N,y&0x80); - break; - case eor: - bval=getaddr(addr); - a^=bval; - setflags(FLAG_Z,!a); - setflags(FLAG_N,a&0x80); - break; - case inc: - bval=getaddr(addr); - bval++; - setaddr(addr,bval); - setflags(FLAG_Z,!bval); - setflags(FLAG_N,bval&0x80); - break; - case inx: - x++; - setflags(FLAG_Z,!x); - setflags(FLAG_N,x&0x80); - break; - case iny: - y++; - setflags(FLAG_Z,!y); - setflags(FLAG_N,y&0x80); - break; - case jmp: - wval=getmem(pc++); - wval|=256*getmem(pc++); - switch (addr) - { - case _abs: - pc=wval; - break; - case ind: - pc=getmem(wval); - pc|=256*getmem(wval+1); - break; - } - break; - case jsr: - push((pc+1)>>8); - push((pc+1)); - wval=getmem(pc++); - wval|=256*getmem(pc++); - pc=wval; - break; - case lda: - a=getaddr(addr); - setflags(FLAG_Z,!a); - setflags(FLAG_N,a&0x80); - break; - case ldx: - x=getaddr(addr); - setflags(FLAG_Z,!x); - setflags(FLAG_N,x&0x80); - break; - case ldy: - y=getaddr(addr); - setflags(FLAG_Z,!y); - setflags(FLAG_N,y&0x80); - break; - case lsr: - bval=getaddr(addr); wval=(unsigned char)bval; - wval>>=1; - setaddr(addr,(unsigned char)wval); - setflags(FLAG_Z,!wval); - setflags(FLAG_N,wval&0x80); - setflags(FLAG_C,bval&1); - break; - case _nop: - break; - case ora: - bval=getaddr(addr); - a|=bval; - setflags(FLAG_Z,!a); - setflags(FLAG_N,a&0x80); - break; - case pha: - push(a); - break; - case php: - push(p); - break; - case pla: - a=pop(); - setflags(FLAG_Z,!a); - setflags(FLAG_N,a&0x80); - break; - case plp: - p=pop(); - break; - case rol: - bval=getaddr(addr); - c=!!(p&FLAG_C); - setflags(FLAG_C,bval&0x80); - bval<<=1; - bval|=c; - setaddr(addr,bval); - setflags(FLAG_N,bval&0x80); - setflags(FLAG_Z,!bval); - break; - case ror: - bval=getaddr(addr); - c=!!(p&FLAG_C); - setflags(FLAG_C,bval&1); - bval>>=1; - bval|=128*c; - setaddr(addr,bval); - setflags(FLAG_N,bval&0x80); - setflags(FLAG_Z,!bval); - break; - case rti: - /* Treat RTI like RTS */ - case rts: - wval=pop(); - wval|=pop()<<8; - pc=wval+1; - break; - case sbc: - bval=getaddr(addr)^0xff; - wval=(unsigned short)a+bval+((p&FLAG_C)?1:0); - setflags(FLAG_C, wval&0x100); - a=(unsigned char)wval; - setflags(FLAG_Z, !a); - setflags(FLAG_N, a>127); - setflags(FLAG_V, (!!(p&FLAG_C)) ^ (!!(p&FLAG_N))); - break; - case sec: - setflags(FLAG_C,1); - break; - case sed: - setflags(FLAG_D,1); - break; - case sei: - setflags(FLAG_I,1); - break; - case sta: - putaddr(addr,a); - break; - case stx: - putaddr(addr,x); - break; - case sty: - putaddr(addr,y); - break; - case tax: - x=a; - setflags(FLAG_Z, !x); - setflags(FLAG_N, x&0x80); - break; - case tay: - y=a; - setflags(FLAG_Z, !y); - setflags(FLAG_N, y&0x80); - break; - case tsx: - x=s; - setflags(FLAG_Z, !x); - setflags(FLAG_N, x&0x80); - break; - case txa: - a=x; - setflags(FLAG_Z, !a); - setflags(FLAG_N, a&0x80); - break; - case txs: - s=x; - break; - case tya: - a=y; - setflags(FLAG_Z, !a); - setflags(FLAG_N, a&0x80); - break; - } -} - -void cpuJSR(unsigned short npc, unsigned char na) ICODE_ATTR; -void cpuJSR(unsigned short npc, unsigned char na) -{ - a=na; - x=0; - y=0; - p=0; - s=255; - pc=npc; - push(0); - push(0); - - while (pc > 1) - cpuParse(); - -} - -void c64Init(int nSampleRate) ICODE_ATTR; -void c64Init(int nSampleRate) -{ - synth_init(nSampleRate); - memset(memory, 0, sizeof(memory)); - - cpuReset(); -} - - - -unsigned short LoadSIDFromMemory(void *pSidData, unsigned short *load_addr, - unsigned short *init_addr, unsigned short *play_addr, unsigned char *subsongs, unsigned char *startsong, unsigned char *speed, unsigned short size) ICODE_ATTR; -unsigned short LoadSIDFromMemory(void *pSidData, unsigned short *load_addr, - unsigned short *init_addr, unsigned short *play_addr, unsigned char *subsongs, unsigned char *startsong, unsigned char *speed, unsigned short size) -{ - unsigned char *pData; - unsigned char data_file_offset; - - pData = (unsigned char*)pSidData; - data_file_offset = pData[7]; - - *load_addr = pData[8]<<8; - *load_addr|= pData[9]; - - *init_addr = pData[10]<<8; - *init_addr|= pData[11]; - - *play_addr = pData[12]<<8; - *play_addr|= pData[13]; - - *subsongs = pData[0xf]-1; - *startsong = pData[0x11]-1; - - *load_addr = pData[data_file_offset]; - *load_addr|= pData[data_file_offset+1]<<8; - - *speed = pData[0x15]; - - memset(memory, 0, sizeof(memory)); - memcpy(&memory[*load_addr], &pData[data_file_offset+2], size-(data_file_offset+2)); - - if (*play_addr == 0) - { - cpuJSR(*init_addr, 0); - *play_addr = (memory[0x0315]<<8)+memory[0x0314]; - } - - return *load_addr; -} - -static int nSamplesRendered = 0; -static int nSamplesPerCall = 882; /* This is PAL SID single speed (44100/50Hz) */ -static int nSamplesToRender = 0; - -/* this is the codec entry point */ -enum codec_status codec_main(enum codec_entry_call_reason reason) -{ - if (reason == CODEC_LOAD) { - /* Make use of 44.1khz */ - ci->configure(DSP_SWITCH_FREQUENCY, SAMPLE_RATE); - /* Sample depth is 28 bit host endian */ - ci->configure(DSP_SET_SAMPLE_DEPTH, 28); - /* Mono output */ - ci->configure(DSP_SET_STEREO_MODE, STEREO_MONO); - } - - return CODEC_OK; -} - -/* this is called for each file to process */ -enum codec_status codec_run(void) -{ - size_t filesize; - unsigned short load_addr, init_addr, play_addr; - unsigned char subSongsMax, subSong, song_speed; - unsigned char *sidfile = NULL; - intptr_t param; - - if (codec_init()) { - return CODEC_ERROR; - } - - codec_set_replaygain(ci->id3); - - /* Load SID file the read_filebuf callback will return the full requested - * size if at all possible, so there is no need to loop */ - ci->seek_buffer(0); - sidfile = ci->request_buffer(&filesize, SID_BUFFER_SIZE); - - if (filesize == 0) { - return CODEC_ERROR; - } - - c64Init(SAMPLE_RATE); - LoadSIDFromMemory(sidfile, &load_addr, &init_addr, &play_addr, - &subSongsMax, &subSong, &song_speed, (unsigned short)filesize); - sidPoke(24, 15); /* Turn on full volume */ - cpuJSR(init_addr, subSong); /* Start the song initialize */ - - - /* Set the elapsed time to the current subsong (in seconds) */ - ci->set_elapsed(subSong*1000); - - /* The main decoder loop */ - while (1) { - enum codec_command_action action = ci->get_command(¶m); - - if (action == CODEC_ACTION_HALT) - break; - - if (action == CODEC_ACTION_SEEK_TIME) { - /* New time is ready in param */ - - /* Start playing from scratch */ - c64Init(SAMPLE_RATE); - LoadSIDFromMemory(sidfile, &load_addr, &init_addr, &play_addr, - &subSongsMax, &subSong, &song_speed, (unsigned short)filesize); - sidPoke(24, 15); /* Turn on full volume */ - subSong = param / 1000; /* Now use the current seek time in seconds as subsong */ - cpuJSR(init_addr, subSong); /* Start the song initialize */ - nSamplesToRender = 0; /* Start the rendering from scratch */ - - /* Set the elapsed time to the current subsong (in seconds) */ - ci->set_elapsed(subSong*1000); - ci->seek_complete(); - } - - nSamplesRendered = 0; - while (nSamplesRendered < CHUNK_SIZE) - { - if (nSamplesToRender == 0) - { - cpuJSR(play_addr, 0); - - /* Find out if cia timing is used and how many samples - have to be calculated for each cpujsr */ - int nRefreshCIA = (int)(20000*(memory[0xdc04]|(memory[0xdc05]<<8))/0x4c00); - if ((nRefreshCIA==0) || (song_speed == 0)) - nRefreshCIA = 20000; - nSamplesPerCall = mixing_frequency*nRefreshCIA/1000000; - - nSamplesToRender = nSamplesPerCall; - } - if (nSamplesRendered + nSamplesToRender > CHUNK_SIZE) - { - synth_render(samples+nSamplesRendered, CHUNK_SIZE-nSamplesRendered); - nSamplesToRender -= CHUNK_SIZE-nSamplesRendered; - nSamplesRendered = CHUNK_SIZE; - } - else - { - synth_render(samples+nSamplesRendered, nSamplesToRender); - nSamplesRendered += nSamplesToRender; - nSamplesToRender = 0; - } - } - - ci->pcmbuf_insert(samples, NULL, CHUNK_SIZE); - } - - return CODEC_OK; -} diff --git a/apps/codecs/smaf.c b/apps/codecs/smaf.c deleted file mode 100644 index 0203d1b4e3..0000000000 --- a/apps/codecs/smaf.c +++ /dev/null @@ -1,492 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (c) 2010 Yoshihisa Uchida - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ - -#include "codeclib.h" -#include "codecs/libpcm/support_formats.h" - -CODEC_HEADER - -/* - * SMAF (Synthetic music Mobile Application Format) - * - * References - * [1] YAMAHA Corporation, Synthetic music Mobile Application Format Ver.3.05, 2002 - */ - -enum { - SMAF_AUDIO_TRACK_CHUNK = 0, /* PCM Audio Track */ - SMAF_SCORE_TRACK_CHUNK, /* Score Track */ -}; - -/* SMAF supported codec formats */ -enum { - SMAF_FORMAT_UNSUPPORT = 0, /* unsupported format */ - SMAF_FORMAT_SIGNED_PCM, /* 2's complement PCM */ - SMAF_FORMAT_UNSIGNED_PCM, /* Offset Binary PCM */ - SMAF_FORMAT_ADPCM, /* YAMAHA ADPCM */ -}; - -static const int support_formats[2][3] = { - {SMAF_FORMAT_SIGNED_PCM, SMAF_FORMAT_ADPCM, SMAF_FORMAT_UNSUPPORT }, - {SMAF_FORMAT_SIGNED_PCM, SMAF_FORMAT_UNSIGNED_PCM, SMAF_FORMAT_ADPCM }, -}; - -static const struct pcm_entry pcm_codecs[] = { - { SMAF_FORMAT_SIGNED_PCM, get_linear_pcm_codec }, - { SMAF_FORMAT_UNSIGNED_PCM, get_linear_pcm_codec }, - { SMAF_FORMAT_ADPCM, get_yamaha_adpcm_codec }, -}; - -#define NUM_FORMATS 3 - -static const int basebits[4] = { 4, 8, 12, 16 }; - -#define PCM_SAMPLE_SIZE (2048*2) - -static int32_t samples[PCM_SAMPLE_SIZE] IBSS_ATTR; - -static const struct pcm_codec *get_codec(uint32_t formattag) -{ - int i; - - for (i = 0; i < NUM_FORMATS; i++) - { - if (pcm_codecs[i].format_tag == formattag) - { - if (pcm_codecs[i].get_codec) - return pcm_codecs[i].get_codec(); - return 0; - } - } - return 0; -} - -static unsigned int get_be32(const uint8_t *buf) -{ - return (buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3]; -} - -static int convert_smaf_channels(unsigned int ch) -{ - return (ch >> 7) + 1; -} - -static int convert_smaf_audio_format(unsigned int chunk, unsigned int audio_format) -{ - int idx = (audio_format & 0x70) >> 4; - - if (idx < 3) - return support_formats[chunk][idx]; - - DEBUGF("CODEC_ERROR: unsupport audio format: %d\n", audio_format); - return SMAF_FORMAT_UNSUPPORT; -} - -static int convert_smaf_audio_basebit(unsigned int basebit) -{ - if (basebit < 4) - return basebits[basebit]; - - DEBUGF("CODEC_ERROR: illegal basebit: %d\n", basebit); - return 0; -} - -static unsigned int search_chunk(const unsigned char *name, int nlen, off_t *pos) -{ - const unsigned char *buf; - unsigned int chunksize; - size_t size; - - while (true) - { - buf = ci->request_buffer(&size, 8); - if (size < 8) - break; - - chunksize = get_be32(buf + 4); - ci->advance_buffer(8); - *pos += 8; - if (memcmp(buf, name, nlen) == 0) - return chunksize; - - ci->advance_buffer(chunksize); - *pos += chunksize; - } - DEBUGF("CODEC_ERROR: missing '%s' chunk\n", name); - return 0; -} - -static bool parse_audio_track(struct pcm_format *fmt, unsigned int chunksize, off_t *pos) -{ - const unsigned char *buf; - size_t size; - - /* search PCM Audio Track Chunk */ - ci->advance_buffer(chunksize); - *pos += chunksize; - if (search_chunk("ATR", 3, pos) == 0) - { - DEBUGF("CODEC_ERROR: missing PCM Audio Track Chunk\n"); - return false; - } - - /* - * get format - * buf - * +0: Format Type - * +1: Sequence Type - * +2: bit 7 0:mono/1:stereo, bit 4-6 format, bit 0-3: frequency - * +3: bit 4-7: base bit - * +4: TimeBase_D - * +5: TimeBase_G - * - * Note: If PCM Audio Track does not include Sequence Data Chunk, - * tmp+6 is the start position of Wave Data Chunk. - */ - buf = ci->request_buffer(&size, 6); - if (size < 6) - { - DEBUGF("CODEC_ERROR: smaf is too small\n"); - return false; - } - - fmt->formattag = convert_smaf_audio_format(SMAF_AUDIO_TRACK_CHUNK, buf[2]); - fmt->channels = convert_smaf_channels(buf[2]); - fmt->bitspersample = convert_smaf_audio_basebit(buf[3] >> 4); - - /* search Wave Data Chunk */ - ci->advance_buffer(6); - *pos += 6; - fmt->numbytes = search_chunk("Awa", 3, pos); - if (fmt->numbytes == 0) - { - DEBUGF("CODEC_ERROR: missing Wave Data Chunk\n"); - return false; - } - - return true; -} - -static bool parse_score_track(struct pcm_format *fmt, off_t *pos) -{ - const unsigned char *buf; - unsigned int chunksize; - size_t size; - - /* parse Optional Data Chunk */ - buf = ci->request_buffer(&size, 13); - if (size < 13) - { - DEBUGF("CODEC_ERROR: smaf is too small\n"); - return false; - } - - if (memcmp(buf + 5, "OPDA", 4) != 0) - { - DEBUGF("CODEC_ERROR: missing Optional Data Chunk\n"); - return false; - } - - /* Optional Data Chunk size */ - chunksize = get_be32(buf + 9); - - /* search Score Track Chunk */ - ci->advance_buffer(13 + chunksize); - *pos += (13 + chunksize); - if (search_chunk("MTR", 3, pos) == 0) - { - DEBUGF("CODEC_ERROR: missing Score Track Chunk\n"); - return false; - } - - /* - * search next chunk - * usually, next chunk ('M***') found within 40 bytes. - */ - buf = ci->request_buffer(&size, 40); - if (size < 40) - { - DEBUGF("CODEC_ERROR: smaf is too small\n"); - return false; - } - - size = 0; - while (size < 40 && buf[size] != 'M') - size++; - - if (size >= 40) - { - DEBUGF("CODEC_ERROR: missing Score Track Stream PCM Data Chunk"); - return false; - } - - /* search Score Track Stream PCM Data Chunk */ - ci->advance_buffer(size); - *pos += size; - if (search_chunk("Mtsp", 4, pos) == 0) - { - DEBUGF("CODEC_ERROR: missing Score Track Stream PCM Data Chunk\n"); - return false; - } - - /* - * parse Score Track Stream Wave Data Chunk - * buf - * +4-7: chunk size (WaveType(3bytes) + wave data count) - * +8: bit 7 0:mono/1:stereo, bit 4-6 format, bit 0-3: base bit - * +9: frequency (MSB) - * +10: frequency (LSB) - */ - buf = ci->request_buffer(&size, 9); - if (size < 9) - { - DEBUGF("CODEC_ERROR: smaf is too small\n"); - return false; - } - - if (memcmp(buf, "Mwa", 3) != 0) - { - DEBUGF("CODEC_ERROR: missing Score Track Stream Wave Data Chunk\n"); - return false; - } - - fmt->formattag = convert_smaf_audio_format(SMAF_SCORE_TRACK_CHUNK, buf[8]); - fmt->channels = convert_smaf_channels(buf[8]); - fmt->bitspersample = convert_smaf_audio_basebit(buf[8] & 0xf); - fmt->numbytes = get_be32(buf + 4) - 3; - - *pos += 11; - return true; -} - -static bool parse_header(struct pcm_format *fmt, off_t *pos) -{ - const unsigned char *buf; - unsigned int chunksize; - size_t size; - - ci->memset(fmt, 0, sizeof(struct pcm_format)); - - /* check File Chunk and Contents Info Chunk */ - buf = ci->request_buffer(&size, 16); - if (size < 16) - { - DEBUGF("CODEC_ERROR: smaf is too small\n"); - return false; - } - - if ((memcmp(buf, "MMMD", 4) != 0) || (memcmp(buf + 8, "CNTI", 4) != 0)) - { - DEBUGF("CODEC_ERROR: does not smaf format\n"); - return false; - } - - chunksize = get_be32(buf + 12); - ci->advance_buffer(16); - *pos = 16; - if (chunksize > 5) - { - if (!parse_audio_track(fmt, chunksize, pos)) - return false; - } - else if (!parse_score_track(fmt, pos)) - return false; - - /* data signess (default signed) */ - fmt->is_signed = (fmt->formattag != SMAF_FORMAT_UNSIGNED_PCM); - - /* data is always big endian */ - fmt->is_little_endian = false; - - return true; -} - -static struct pcm_format format; -static uint32_t bytesdone; - -static uint8_t *read_buffer(size_t *realsize) -{ - uint8_t *buffer = (uint8_t *)ci->request_buffer(realsize, format.chunksize); - if (bytesdone + (*realsize) > format.numbytes) - *realsize = format.numbytes - bytesdone; - bytesdone += *realsize; - ci->advance_buffer(*realsize); - return buffer; -} - -/* this is the codec entry point */ -enum codec_status codec_main(enum codec_entry_call_reason reason) -{ - if (reason == CODEC_LOAD) { - /* Generic codec initialisation */ - ci->configure(DSP_SET_SAMPLE_DEPTH, PCM_OUTPUT_DEPTH-1); - } - - return CODEC_OK; -} - -/* this is called for each file to process */ -enum codec_status codec_run(void) -{ - uint32_t decodedsamples; - size_t n; - int bufcount; - int endofstream; - uint8_t *smafbuf; - off_t firstblockposn; /* position of the first block in file */ - const struct pcm_codec *codec; - intptr_t param; - - if (codec_init()) - return CODEC_ERROR; - - codec_set_replaygain(ci->id3); - - /* Need to save offset for later use (cleared indirectly by advance_buffer) */ - bytesdone = ci->id3->offset; - - decodedsamples = 0; - codec = 0; - - ci->seek_buffer(0); - if (!parse_header(&format, &firstblockposn)) - { - return CODEC_ERROR; - } - - codec = get_codec(format.formattag); - if (codec == 0) - { - DEBUGF("CODEC_ERROR: unsupport audio format: 0x%x\n", (int)format.formattag); - return CODEC_ERROR; - } - - if (!codec->set_format(&format)) - { - return CODEC_ERROR; - } - - /* check chunksize */ - if ((format.chunksize / format.blockalign) * format.samplesperblock * format.channels - > PCM_SAMPLE_SIZE) - format.chunksize = (PCM_SAMPLE_SIZE / format.blockalign) * format.blockalign; - if (format.chunksize == 0) - { - DEBUGF("CODEC_ERROR: chunksize is 0\n"); - return CODEC_ERROR; - } - - ci->configure(DSP_SWITCH_FREQUENCY, ci->id3->frequency); - - if (format.channels == 2) { - ci->configure(DSP_SET_STEREO_MODE, STEREO_INTERLEAVED); - } else if (format.channels == 1) { - ci->configure(DSP_SET_STEREO_MODE, STEREO_MONO); - } else { - DEBUGF("CODEC_ERROR: more than 2 channels unsupported\n"); - return CODEC_ERROR; - } - - ci->seek_buffer(firstblockposn); - - /* make sure we're at the correct offset */ - if (bytesdone > (uint32_t) firstblockposn) - { - /* Round down to previous block */ - struct pcm_pos *newpos = codec->get_seek_pos(bytesdone - firstblockposn, - PCM_SEEK_POS, &read_buffer); - - if (newpos->pos > format.numbytes) - return CODEC_OK; - - if (ci->seek_buffer(firstblockposn + newpos->pos)) - { - bytesdone = newpos->pos; - decodedsamples = newpos->samples; - } - } - else - { - /* already where we need to be */ - bytesdone = 0; - } - - ci->set_elapsed(decodedsamples*1000LL/ci->id3->frequency); - - /* The main decoder loop */ - endofstream = 0; - - while (!endofstream) { - enum codec_command_action action = ci->get_command(¶m); - - if (action == CODEC_ACTION_HALT) - break; - - if (action == CODEC_ACTION_SEEK_TIME) { - struct pcm_pos *newpos = codec->get_seek_pos(param, PCM_SEEK_TIME, - &read_buffer); - - if (newpos->pos > format.numbytes) - { - ci->set_elapsed(ci->id3->length); - ci->seek_complete(); - break; - } - - if (ci->seek_buffer(firstblockposn + newpos->pos)) - { - bytesdone = newpos->pos; - decodedsamples = newpos->samples; - } - - ci->set_elapsed(decodedsamples*1000LL/ci->id3->frequency); - ci->seek_complete(); - } - - smafbuf = (uint8_t *)ci->request_buffer(&n, format.chunksize); - - if (n == 0) - break; /* End of stream */ - - if (bytesdone + n > format.numbytes) { - n = format.numbytes - bytesdone; - endofstream = 1; - } - - if (codec->decode(smafbuf, n, samples, &bufcount) == CODEC_ERROR) - { - DEBUGF("codec error\n"); - return CODEC_ERROR; - } - - ci->pcmbuf_insert(samples, NULL, bufcount); - - ci->advance_buffer(n); - bytesdone += n; - decodedsamples += bufcount; - if (bytesdone >= format.numbytes) - endofstream = 1; - - ci->set_elapsed(decodedsamples*1000LL/ci->id3->frequency); - } - - return CODEC_OK; -} diff --git a/apps/codecs/spc.c b/apps/codecs/spc.c deleted file mode 100644 index 809562e2a0..0000000000 --- a/apps/codecs/spc.c +++ /dev/null @@ -1,586 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2007-2008 Michael Sevakis (jhMikeS) - * Copyright (C) 2006-2007 Adam Gashlin (hcs) - * Copyright (C) 2004-2007 Shay Green (blargg) - * Copyright (C) 2002 Brad Martin - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ - -/* lovingly ripped off from Game_Music_Emu 0.5.2. http://www.slack.net/~ant/ */ -/* DSP Based on Brad Martin's OpenSPC DSP emulator */ -/* tag reading from sexyspc by John Brawn (John_Brawn@yahoo.com) and others */ -#include "codeclib.h" -#include "../fracmul.h" -#include "libspc/spc_codec.h" -#include "libspc/spc_profiler.h" - -CODEC_HEADER - -/**************** ID666 parsing ****************/ - -static struct { - unsigned char isBinary; - char song[32]; - char game[32]; - char dumper[16]; - char comments[32]; - int day,month,year; - unsigned long length; - unsigned long fade; - char artist[32]; - unsigned char muted; - unsigned char emulator; -} ID666; - -static int LoadID666(unsigned char *buf) { - unsigned char *ib=buf; - int isbinary = 1; - int i; - - memcpy(ID666.song,ib,32); - ID666.song[31]=0; - ib+=32; - - memcpy(ID666.game,ib,32); - ID666.game[31]=0; - ib+=32; - - memcpy(ID666.dumper,ib,16); - ID666.dumper[15]=0; - ib+=16; - - memcpy(ID666.comments,ib,32); - ID666.comments[31]=0; - ib+=32; - - /* Ok, now comes the fun part. */ - - /* Date check */ - if(ib[2] == '/' && ib[5] == '/' ) - isbinary = 0; - - /* Reserved bytes check */ - if(ib[0xD2 - 0x2E - 112] >= '0' && - ib[0xD2 - 0x2E - 112] <= '9' && - ib[0xD3 - 0x2E - 112] == 0x00) - isbinary = 0; - - /* is length & fade only digits? */ - for (i=0;i<8 && ( - (ib[0xA9 - 0x2E - 112+i]>='0'&&ib[0xA9 - 0x2E - 112+i]<='9') || - ib[0xA9 - 0x2E - 112+i]=='\0'); - i++); - if (i==8) isbinary=0; - - ID666.isBinary = isbinary; - - if(isbinary) { - DEBUGF("binary tag detected\n"); - ID666.year=*ib; - ib++; - ID666.year|=*ib<<8; - ib++; - ID666.month=*ib; - ib++; - ID666.day=*ib; - ib++; - - ib+=7; - - ID666.length=*ib; - ib++; - - ID666.length|=*ib<<8; - ib++; - - ID666.length|=*ib<<16; - ID666.length*=1000; - ib++; - - ID666.fade=*ib; - ib++; - ID666.fade|=*ib<<8; - ib++; - ID666.fade|=*ib<<16; - ib++; - ID666.fade|=*ib<<24; - ib++; - - memcpy(ID666.artist,ib,32); - ID666.artist[31]=0; - ib+=32; - - ID666.muted=*ib; - ib++; - - ID666.emulator=*ib; - ib++; - } else { - unsigned long tmp; - char buf[64]; - - DEBUGF("text tag detected\n"); - - memcpy(buf, ib, 2); - buf[2] = 0; - tmp = 0; - for (i=0;i<2 && buf[i]>='0' && buf[i]<='9';i++) tmp=tmp*10+buf[i]-'0'; - ID666.month = tmp; - ib+=3; - - memcpy(buf, ib, 2); - buf[2] = 0; - tmp = 0; - for (i=0;i<2 && buf[i]>='0' && buf[i]<='9';i++) tmp=tmp*10+buf[i]-'0'; - ID666.day = tmp; - ib+=3; - - memcpy(buf, ib, 4); - buf[4] = 0; - tmp = 0; - for (i=0;i<4 && buf[i]>='0' && buf[i]<='9';i++) tmp=tmp*10+buf[i]-'0'; - ID666.year = tmp; - ib+=5; - - memcpy(buf, ib, 3); - buf[3] = 0; - tmp = 0; - for (i=0;i<3 && buf[i]>='0' && buf[i]<='9';i++) tmp=tmp*10+buf[i]-'0'; - ID666.length = tmp * 1000; - ib+=3; - - memcpy(buf, ib, 5); - buf[5] = 0; - tmp = 0; - for (i=0;i<5 && buf[i]>='0' && buf[i]<='9';i++) tmp=tmp*10+buf[i]-'0'; - ID666.fade = tmp; - ib+=5; - - memcpy(ID666.artist,ib,32); - ID666.artist[31]=0; - ib+=32; - - /*I have no idea if this is right or not.*/ - ID666.muted=*ib; - ib++; - - memcpy(buf, ib, 1); - buf[1] = 0; - tmp = 0; - ib++; - } - return 1; -} - -/**************** Codec ****************/ -enum {SAMPLE_RATE = 32000}; -static struct Spc_Emu spc_emu IBSS_ATTR_SPC CACHEALIGN_ATTR; - -#if SPC_DUAL_CORE -/** Implementations for pipelined dual-core operation **/ -static int spc_emu_thread_stack[DEFAULT_STACK_SIZE/sizeof(int)] - CACHEALIGN_ATTR; - -static const unsigned char * const spc_emu_thread_name = "spc emu"; -static unsigned int emu_thread_id = 0; - -enum -{ - SPC_EMU_AUDIO = 0, - SPC_EMU_LOAD, - SPC_EMU_QUIT, -}; - -struct spc_load -{ - uint8_t *buf; - size_t size; -}; - -/* sample queue */ -#define WAV_NUM_CHUNKS 2 -#define WAV_CHUNK_MASK (WAV_NUM_CHUNKS-1) -struct sample_queue_chunk -{ - long id; - union - { - intptr_t data; - int32_t audio[WAV_CHUNK_SIZE*2]; - }; -}; - -static struct -{ - int head, tail; - struct semaphore emu_sem_head; - struct semaphore emu_sem_tail; - struct semaphore emu_evt_reply; - intptr_t retval; - struct sample_queue_chunk wav_chunk[WAV_NUM_CHUNKS]; -} sample_queue SHAREDBSS_ATTR; - -static inline void samples_release_wrbuf(void) -{ - sample_queue.tail++; - ci->semaphore_release(&sample_queue.emu_sem_head); -} - -static inline struct sample_queue_chunk * samples_get_wrbuf(void) -{ - ci->semaphore_wait(&sample_queue.emu_sem_tail, TIMEOUT_BLOCK); - return &sample_queue.wav_chunk[sample_queue.tail & WAV_CHUNK_MASK]; -} - -static inline void samples_release_rdbuf(void) -{ - if (sample_queue.head != sample_queue.tail) { - sample_queue.head++; - } - - ci->semaphore_release(&sample_queue.emu_sem_tail); -} - -static inline int32_t * samples_get_rdbuf(void) -{ - ci->semaphore_wait(&sample_queue.emu_sem_head, TIMEOUT_BLOCK); - return sample_queue.wav_chunk[sample_queue.head & WAV_CHUNK_MASK].audio; -} - -static intptr_t emu_thread_send_msg(long id, intptr_t data) -{ - struct sample_queue_chunk *chunk; - /* Grab an audio output buffer */ - ci->semaphore_wait(&sample_queue.emu_sem_head, TIMEOUT_BLOCK); - chunk = &sample_queue.wav_chunk[sample_queue.head & WAV_CHUNK_MASK]; - /* Place a message in it instead of audio */ - chunk->id = id; - chunk->data = data; - /* Release it to the emu thread */ - samples_release_rdbuf(); - - if (id != SPC_EMU_QUIT) { - /* Wait for a response */ - ci->semaphore_wait(&sample_queue.emu_evt_reply, TIMEOUT_BLOCK); - } - - return sample_queue.retval; -} - -/* thread function */ -static bool emu_thread_process_msg(struct sample_queue_chunk *chunk) -{ - long id = chunk->id; - bool ret = id != SPC_EMU_QUIT; - - chunk->id = SPC_EMU_AUDIO; /* Reset chunk type to audio */ - sample_queue.retval = 0; - - if (id == SPC_EMU_LOAD) - { - struct spc_load *ld = (struct spc_load *)chunk->data; - ci->commit_discard_dcache(); - SPC_Init(&spc_emu); - sample_queue.retval = SPC_load_spc(&spc_emu, ld->buf, ld->size); - - /* Empty the audio queue */ - ci->semaphore_release(&sample_queue.emu_sem_tail); - ci->semaphore_release(&sample_queue.emu_sem_tail); - ci->semaphore_wait(&sample_queue.emu_sem_head, TIMEOUT_NOBLOCK); - ci->semaphore_wait(&sample_queue.emu_sem_head, TIMEOUT_NOBLOCK); - sample_queue.head = sample_queue.tail = 0; - } - - if (id != SPC_EMU_QUIT) { - ci->semaphore_release(&sample_queue.emu_evt_reply); - } - - return ret; -} - -static void spc_emu_thread(void) -{ - CPU_Init(&spc_emu); - - while (1) { - /* get a buffer for output */ - struct sample_queue_chunk *chunk = samples_get_wrbuf(); - - if (chunk->id != SPC_EMU_AUDIO) { - /* This chunk doesn't contain audio but a command */ - if (!emu_thread_process_msg(chunk)) - break; - /* Have to re-get this pointer to keep semaphore counts correct */ - continue; - } - - ENTER_TIMER(render); - /* fill samples buffer */ - if ( SPC_play(&spc_emu, WAV_CHUNK_SIZE*2, chunk->audio) ) - assert( false ); - EXIT_TIMER(render); - - /* done so release it to output */ - samples_release_wrbuf(); - ci->yield(); - } -} - -static bool spc_emu_start(void) -{ - emu_thread_id = ci->create_thread(spc_emu_thread, spc_emu_thread_stack, - sizeof(spc_emu_thread_stack), CREATE_THREAD_FROZEN, - spc_emu_thread_name IF_PRIO(, PRIORITY_PLAYBACK), COP); - - if (emu_thread_id == 0) - return false; - - /* Initialize audio queue as full to prevent emu thread from trying to run the - emulator before loading something */ - ci->semaphore_init(&sample_queue.emu_evt_reply, 1, 0); - ci->semaphore_init(&sample_queue.emu_sem_tail, 2, 0); - ci->semaphore_init(&sample_queue.emu_sem_head, 2, 2); - sample_queue.head = 0; - sample_queue.tail = 2; - - /* Start it running */ - ci->thread_thaw(emu_thread_id); - return true; -} - -/* load a new program on the emu thread */ -static inline int load_spc_buffer(uint8_t *buf, size_t size) -{ - struct spc_load ld = { buf, size }; - ci->commit_dcache(); - return emu_thread_send_msg(SPC_EMU_LOAD, (intptr_t)&ld); -} - -static inline void spc_emu_quit(void) -{ - if (emu_thread_id != 0) { - emu_thread_send_msg(SPC_EMU_QUIT, 0); - /* Wait for emu thread to be killed */ - ci->thread_wait(emu_thread_id); - ci->commit_discard_dcache(); - } -} - -static inline int32_t * spc_play_get_samples(void) -{ - /* obtain filled samples buffer */ - return samples_get_rdbuf(); -} - -static inline void spc_play_send_samples(int32_t *samples) -{ - ci->pcmbuf_insert(samples, samples+WAV_CHUNK_SIZE, WAV_CHUNK_SIZE); - /* done with chunk so release it to emu thread */ - samples_release_rdbuf(); -} - -#else /* !SPC_DUAL_CORE */ -/** Implementations for single-core operation **/ -static int32_t wav_chunk[WAV_CHUNK_SIZE*2] IBSS_ATTR; - -/* load a new program into emu */ -static inline int load_spc_buffer(uint8_t *buf, size_t size) -{ - SPC_Init(&spc_emu); - return SPC_load_spc(&spc_emu, buf, size); -} - -static inline bool spc_emu_start(void) -{ -#ifdef CPU_COLDFIRE - /* signed integer mode with saturation */ - coldfire_set_macsr(EMAC_SATURATE); -#endif - CPU_Init(&spc_emu); - return true; -} - -static inline void spc_play_send_samples(int32_t *samples) -{ - ci->pcmbuf_insert(samples, samples+WAV_CHUNK_SIZE, WAV_CHUNK_SIZE); -} - -#define spc_emu_quit() -#define samples_release_rdbuf() - -static inline int32_t * spc_play_get_samples(void) -{ - ENTER_TIMER(render); - /* fill samples buffer */ - if ( SPC_play(&spc_emu,WAV_CHUNK_SIZE*2,wav_chunk) ) - assert( false ); - EXIT_TIMER(render); - return wav_chunk; -} -#endif /* SPC_DUAL_CORE */ - -/* The main decoder loop */ -static int play_track( void ) -{ - int sampleswritten=0; - - unsigned long fadestartsample = ID666.length*(long long) SAMPLE_RATE/1000; - unsigned long fadeendsample = (ID666.length+ID666.fade)*(long long) SAMPLE_RATE/1000; - int fadedec = 0; - int fadevol = 0x7fffffffl; - intptr_t param; - - if (fadeendsample>fadestartsample) - fadedec=0x7fffffffl/(fadeendsample-fadestartsample)+1; - - ENTER_TIMER(total); - - while ( 1 ) - { - enum codec_command_action action = ci->get_command(¶m); - - if (action == CODEC_ACTION_HALT) - break; - - if (action == CODEC_ACTION_SEEK_TIME) { - int curtime = sampleswritten*1000LL/SAMPLE_RATE; - DEBUGF("seek to %ld\ncurrently at %d\n", (long)param, curtime); - if (param < curtime) { - DEBUGF("seek backwards = reset\n"); - ci->set_elapsed(0); - ci->seek_complete(); - return 1; - } - - ci->set_elapsed(curtime); - ci->seek_complete(); - } - - int32_t *samples = spc_play_get_samples(); - - sampleswritten += WAV_CHUNK_SIZE; - - /* is track timed? */ - if (!ci->loop_track() && ci->id3->length) { - unsigned long curtime = sampleswritten*1000LL/SAMPLE_RATE; - unsigned long lasttimesample = (sampleswritten-WAV_CHUNK_SIZE); - - /* fade? */ - if (curtime>ID666.length) - { - #ifdef CPU_COLDFIRE - /* Have to switch modes to do this */ - long macsr = coldfire_get_macsr(); - coldfire_set_macsr(EMAC_SATURATE | EMAC_FRACTIONAL | EMAC_ROUND); - #endif - int i; - for (i=0;ifadestartsample) { - if (fadevol>0) { - samples[i] = FRACMUL(samples[i], fadevol); - samples[i+WAV_CHUNK_SIZE] = FRACMUL(samples[i+WAV_CHUNK_SIZE], fadevol); - } else samples[i]=samples[i+WAV_CHUNK_SIZE]=0; - fadevol-=fadedec; - } - } - #ifdef CPU_COLDFIRE - coldfire_set_macsr(macsr); - #endif - } - /* end? */ - if (lasttimesample>=fadeendsample) - { - samples_release_rdbuf(); - break; - } - } - - spc_play_send_samples(samples); - - if (ci->loop_track()) - ci->set_elapsed(0); - else - ci->set_elapsed(sampleswritten*1000LL/SAMPLE_RATE); - } - - EXIT_TIMER(total); - return 0; -} - -/* this is the codec entry point */ -enum codec_status codec_main(enum codec_entry_call_reason reason) -{ - if (reason == CODEC_LOAD) { - if (!spc_emu_start()) - return CODEC_ERROR; - - ci->configure(DSP_SET_SAMPLE_DEPTH, 24); - ci->configure(DSP_SET_FREQUENCY, SAMPLE_RATE); - ci->configure(DSP_SET_STEREO_MODE, STEREO_NONINTERLEAVED); - } - else if (reason == CODEC_UNLOAD) { - spc_emu_quit(); - } - - return CODEC_OK; -} - -/* this is called for each file to process */ -enum codec_status codec_run(void) -{ - DEBUGF("SPC: next_track\n"); - if (codec_init()) - return CODEC_ERROR; - DEBUGF("SPC: after init\n"); - - codec_set_replaygain(ci->id3); - - /* Read the entire file */ - DEBUGF("SPC: request initial buffer\n"); - ci->seek_buffer(0); - size_t buffersize; - uint8_t* buffer = ci->request_buffer(&buffersize, ci->filesize); - if (!buffer) - return CODEC_ERROR; - - DEBUGF("SPC: read size = 0x%lx\n",(unsigned long)buffersize); - ci->set_elapsed(0); - - do - { - if (load_spc_buffer(buffer, buffersize)) { - DEBUGF("SPC load failure\n"); - return CODEC_ERROR; - } - - LoadID666(buffer+0x2e); - - if (!ci->loop_track() && ID666.length==0) { - ID666.length=3*60*1000; /* 3 minutes */ - ID666.fade=5*1000; /* 5 seconds */ - } - - reset_profile_timers(); - } - while ( play_track() ); - - print_timers(ci->id3->path); - - return CODEC_OK; -} diff --git a/apps/codecs/speex.c b/apps/codecs/speex.c deleted file mode 100644 index ac3bc963b1..0000000000 --- a/apps/codecs/speex.c +++ /dev/null @@ -1,583 +0,0 @@ -/************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * - * Copyright (C) 2006 Frederik M.J. Vestre - * Based on vorbis.c codec interface: - * Copyright (C) 2002 Björn Stenberg - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ***************************************************************************/ - -#include "libspeex/speex/ogg.h" -#include "libspeex/speex/speex.h" -#include "libspeex/speex/speex_callbacks.h" -#include "libspeex/speex/speex_header.h" -#include "libspeex/speex/speex_stereo.h" -#include "libspeex/speex/speex_config_types.h" -#include "codeclib.h" - -/* Room for one stereo frame of max size, 2*640 */ -#define MAX_FRAME_SIZE 1280 -#define CHUNKSIZE 10000 /*2kb*/ -#define SEEK_CHUNKSIZE 7*CHUNKSIZE - -CODEC_HEADER - -static spx_int16_t output[MAX_FRAME_SIZE] IBSS_ATTR; - -static int get_more_data(spx_ogg_sync_state *oy) -{ - int bytes; - char *buffer; - - buffer = (char *)spx_ogg_sync_buffer(oy,CHUNKSIZE); - - bytes = ci->read_filebuf(buffer, sizeof(char)*CHUNKSIZE); - - spx_ogg_sync_wrote(oy,bytes); - - return bytes; -} - -/* The read/seek functions track absolute position within the stream */ - -static spx_int64_t get_next_page(spx_ogg_sync_state *oy,spx_ogg_page *og, - spx_int64_t boundary) -{ - spx_int64_t localoffset = ci->curpos; - long more; - long ret; - - if (boundary > 0) - boundary += ci->curpos; - - while (1) { - more = spx_ogg_sync_pageseek(oy,og); - - if (more < 0) { - /* skipped n bytes */ - localoffset-=more; - } else { - if (more == 0) { - /* send more paramedics */ - if(!boundary)return(-1); - { - ret = get_more_data(oy); - if (ret == 0) - return(-2); - - if (ret < 0) - return(-3); - } - } else { - /* got a page. Return the offset at the page beginning, - advance the internal offset past the page end */ - - spx_int64_t ret=localoffset; - - return(ret); - } - } - } -} - -static spx_int64_t seek_backwards(spx_ogg_sync_state *oy, spx_ogg_page *og, - spx_int64_t wantedpos) -{ - spx_int64_t crofs; - spx_int64_t *curoffset=&crofs; - *curoffset=ci->curpos; - spx_int64_t begin=*curoffset; - spx_int64_t end=begin; - spx_int64_t ret; - spx_int64_t offset=-1; - spx_int64_t avgpagelen=-1; - spx_int64_t lastgranule=-1; - - short time = -1; - - while (offset == -1) { - - begin -= SEEK_CHUNKSIZE; - - if (begin < 0) { - if (time < 0) { - begin = 0; - time++; - } else { - LOGF("Can't seek that early:%lld\n",begin); - return -3; /* too early */ - } - } - - *curoffset = begin; - - ci->seek_buffer(*curoffset); - - spx_ogg_sync_reset(oy); - - lastgranule = -1; - - while (*curoffset < end) { - ret = get_next_page(oy,og,end-*curoffset); - - if (ret > 0) { - if (lastgranule != -1) { - if (avgpagelen < 0) - avgpagelen = (spx_ogg_page_granulepos(og)-lastgranule); - else - avgpagelen=((spx_ogg_page_granulepos(og)-lastgranule) - + avgpagelen) / 2; - } - - lastgranule=spx_ogg_page_granulepos(og); - - if ((lastgranule - (avgpagelen/4)) < wantedpos && - (lastgranule + avgpagelen + (avgpagelen/4)) > wantedpos) { - - /*wanted offset found Yeay!*/ - - /*LOGF("GnPagefound:%d,%d,%d,%d\n",ret, - lastgranule,wantedpos,avgpagelen);*/ - - return ret; - - } else if (lastgranule > wantedpos) { /*too late, seek more*/ - if (offset != -1) { - LOGF("Toolate, returnanyway:%lld,%lld,%lld,%lld\n", - ret,lastgranule,wantedpos,avgpagelen); - return ret; - } - break; - } else{ /*if (spx_ogg_page_granulepos(&og)curpos; - spx_int64_t curoffset; - curoffset = *curbyteoffset; - spx_int64_t offset = 0; - spx_ogg_page og = {0,0,0,0}; - spx_int64_t avgpagelen = -1; - spx_int64_t lastgranule = -1; - - if(abs(pos-curpos)>10000 && headerssize>0 && curoffset-headerssize>10000) { - /* if seeking for more that 10sec, - headersize is known & more than 10kb is played, - try to guess a place to seek from the number of - bytes playe for this position, this works best when - the bitrate is relativly constant. - */ - - curoffset = (((*curbyteoffset-headerssize) * pos)/curpos)*98/100; - if (curoffset < 0) - curoffset=0; - - //spx_int64_t toffset=curoffset; - - ci->seek_buffer(curoffset); - - spx_ogg_sync_reset(oy); - - offset = get_next_page(oy,&og,-1); - - if (offset < 0) { /* could not find new page,use old offset */ - LOGF("Seek/guess/fault:%lld->-<-%d,%lld:%lld,%d,%ld,%d\n", - curpos,0,pos,offset,0, - ci->curpos,/*stream_length*/0); - - curoffset = *curbyteoffset; - - ci->seek_buffer(curoffset); - - spx_ogg_sync_reset(oy); - } else { - if (spx_ogg_page_granulepos(&og) == 0 && pos > 5000) { - LOGF("SEEK/guess/fault:%lld->-<-%lld,%lld:%lld,%d,%ld,%d\n", - curpos,spx_ogg_page_granulepos(&og),pos, - offset,0,ci->curpos,/*stream_length*/0); - - curoffset = *curbyteoffset; - - ci->seek_buffer(curoffset); - - spx_ogg_sync_reset(oy); - } else { - curoffset = offset; - curpos = spx_ogg_page_granulepos(&og); - } - } - } - - /* which way do we want to seek? */ - - if (curpos > pos) { /* backwards */ - offset = seek_backwards(oy,&og,pos); - - if (offset > 0) { - *curbyteoffset = curoffset; - return 1; - } - } else { /* forwards */ - - while ( (offset = get_next_page(oy,&og,-1)) > 0) { - if (lastgranule != -1) { - if (avgpagelen < 0) - avgpagelen = (spx_ogg_page_granulepos(&og) - lastgranule); - else - avgpagelen = ((spx_ogg_page_granulepos(&og) - lastgranule) - + avgpagelen) / 2; - } - - lastgranule = spx_ogg_page_granulepos(&og); - - if ( ((lastgranule - (avgpagelen/4)) < pos && ( lastgranule + - avgpagelen + (avgpagelen / 4)) > pos) || - lastgranule > pos) { - - /*wanted offset found Yeay!*/ - - *curbyteoffset = offset; - - return offset; - } - } - } - - ci->seek_buffer(*curbyteoffset); - - spx_ogg_sync_reset(oy); - - LOGF("Seek failed:%lld\n", offset); - - return -1; -} - -static void *process_header(spx_ogg_packet *op, - int enh_enabled, - int *frame_size, - int *rate, - int *nframes, - int *channels, - SpeexStereoState *stereo, - int *extra_headers - ) -{ - void *st; - const SpeexMode *mode; - SpeexHeader *header; - int modeID; - SpeexCallback callback; - - header = speex_packet_to_header((char*)op->packet, op->bytes); - - if (!header){ - DEBUGF ("Cannot read header\n"); - return NULL; - } - - if (header->mode >= SPEEX_NB_MODES){ - DEBUGF ("Mode does not exist\n"); - return NULL; - } - - modeID = header->mode; - - mode = speex_lib_get_mode(modeID); - - if (header->speex_version_id > 1) { - DEBUGF("Undecodeable bitstream"); - return NULL; - } - - if (mode->bitstream_version < header->mode_bitstream_version){ - DEBUGF("Undecodeable bitstream, newer bitstream"); - return NULL; - } - - if (mode->bitstream_version > header->mode_bitstream_version){ - DEBUGF("Too old bitstream"); - return NULL; - } - - st = speex_decoder_init(mode); - if (!st){ - DEBUGF("Decoder init failed"); - return NULL; - } - speex_decoder_ctl(st, SPEEX_SET_ENH, &enh_enabled); - speex_decoder_ctl(st, SPEEX_GET_FRAME_SIZE, frame_size); - - if (header->nb_channels!=1){ - callback.callback_id = SPEEX_INBAND_STEREO; - callback.func = speex_std_stereo_request_handler; - callback.data = stereo; - speex_decoder_ctl(st, SPEEX_SET_HANDLER, &callback); - } - *channels = header->nb_channels; - - if (!*rate) - *rate = header->rate; - - speex_decoder_ctl(st, SPEEX_SET_SAMPLING_RATE, rate); - - *nframes = header->frames_per_packet; - - *extra_headers = header->extra_headers; - - return st; -} - -/* this is the codec entry point */ -enum codec_status codec_main(enum codec_entry_call_reason reason) -{ - /* Nothing to do */ - return CODEC_OK; - (void)reason; -} - -/* this is called for each file to process */ -enum codec_status codec_run(void) -{ - int error = CODEC_ERROR; - - SpeexBits bits; - int eof = 0; - spx_ogg_sync_state oy; - spx_ogg_page og; - spx_ogg_packet op; - spx_ogg_stream_state os; - spx_int64_t page_granule = 0; - spx_int64_t cur_granule = 0; - int enh_enabled = 1; - int nframes = 2; - int eos = 0; - SpeexStereoState *stereo; - int channels = -1; - int samplerate = ci->id3->frequency; - int extra_headers = 0; - int stream_init = 0; - /* rockbox: comment 'set but unused' variables - int page_nb_packets; - */ - int frame_size; - int packet_count = 0; - int lookahead; - int headerssize = 0; - unsigned long strtoffset = ci->id3->offset; - void *st = NULL; - int j = 0; - intptr_t param; - - memset(&bits, 0, sizeof(bits)); - memset(&oy, 0, sizeof(oy)); - - /* Ogg handling still uses mallocs, so reset the malloc buffer per track */ - if (codec_init()) { - goto exit; - } - - ci->seek_buffer(0); - ci->set_elapsed(0); - - stereo = speex_stereo_state_init(); - spx_ogg_sync_init(&oy); - spx_ogg_alloc_buffer(&oy,2*CHUNKSIZE); - - codec_set_replaygain(ci->id3); - - eof = 0; - while (!eof) { - enum codec_command_action action = ci->get_command(¶m); - - if (action == CODEC_ACTION_HALT) - break; - - /*seek (seeks to the page before the position) */ - if (action == CODEC_ACTION_SEEK_TIME) { - if(samplerate!=0&&packet_count>1){ - LOGF("Speex seek page:%lld,%lld,%ld,%lld,%d\n", - ((spx_int64_t)param/1000) * - (spx_int64_t)samplerate, - page_granule, (long)param, - (page_granule/samplerate)*1000, samplerate); - - speex_seek_page_granule(((spx_int64_t)param/1000) * - (spx_int64_t)samplerate, - page_granule, &oy, headerssize); - } - - ci->set_elapsed(param); - ci->seek_complete(); - } - -next_page: - /*Get the ogg buffer for writing*/ - if(get_more_data(&oy)<1){/*read error*/ - goto done; - } - - /* Loop for all complete pages we got (most likely only one) */ - while (spx_ogg_sync_pageout(&oy, &og) == 1) { - int packet_no; - if (stream_init == 0) { - spx_ogg_stream_init(&os, spx_ogg_page_serialno(&og)); - stream_init = 1; - } - - /* Add page to the bitstream */ - spx_ogg_stream_pagein(&os, &og); - - page_granule = spx_ogg_page_granulepos(&og); - /* page_nb_packets = spx_ogg_page_packets(&og); */ - - cur_granule = page_granule; - - /* Extract all available packets */ - packet_no=0; - - while (!eos && spx_ogg_stream_packetout(&os, &op)==1){ - /* If first packet, process as Speex header */ - if (packet_count==0){ - st = process_header(&op, enh_enabled, &frame_size, - &samplerate, &nframes, &channels, - stereo, &extra_headers); - - speex_decoder_ctl(st, SPEEX_GET_LOOKAHEAD, &lookahead); - if (!nframes) - nframes=1; - - if (!st){ - goto done; - } - - ci->configure(DSP_SET_FREQUENCY, ci->id3->frequency); - ci->configure(DSP_SET_SAMPLE_DEPTH, 16); - if (channels == 2) { - ci->configure(DSP_SET_STEREO_MODE, STEREO_INTERLEAVED); - } else if (channels == 1) { - ci->configure(DSP_SET_STEREO_MODE, STEREO_MONO); - } - - /* Speex header in its own page, add the whole page - headersize */ - headerssize += og.header_len+og.body_len; - - } else if (packet_count<=1+extra_headers){ - /* add packet to headersize */ - headerssize += op.bytes; - - /* Ignore extra headers */ - } else { - if (packet_count <= 2+extra_headers) { - if (strtoffset) { - ci->seek_buffer(strtoffset); - spx_ogg_sync_reset(&oy); - packet_count++; - goto next_page; - } - } - packet_no++; - - if (op.e_o_s) /* End of stream condition */ - eos=1; - - /* Set Speex bitstream to point to Ogg packet */ - speex_bits_set_bit_buffer(&bits, (char *)op.packet, - op.bytes); - for (j = 0; j != nframes; j++){ - int ret; - - /* Decode frame */ - ret = speex_decode_int(st, &bits, output); - - if (ret == -1) - break; - - if (ret == -2) - break; - - if (speex_bits_remaining(&bits) < 0) - break; - - if (channels == 2) - speex_decode_stereo_int(output, frame_size, stereo); - - if (frame_size > 0) { - spx_int16_t *frame_start = output + lookahead; - - if (channels == 2) - frame_start += lookahead; - ci->pcmbuf_insert(frame_start, NULL, - frame_size - lookahead); - lookahead = 0; - /* 2 bytes/sample */ - cur_granule += frame_size / 2; - - ci->set_offset((long) ci->curpos); - - ci->set_elapsed((samplerate == 0) ? 0 : - cur_granule * 1000 / samplerate); - } - } - } - packet_count++; - } - } - } - - error = CODEC_OK; -done: - /* Clean things up for the next track */ - speex_bits_destroy(&bits); - - if (st) - speex_decoder_destroy(st); - - if (stream_init) - spx_ogg_stream_destroy(&os); - - spx_ogg_sync_destroy(&oy); - -exit: - return error; -} diff --git a/apps/codecs/tta.c b/apps/codecs/tta.c deleted file mode 100644 index dda33b3f5e..0000000000 --- a/apps/codecs/tta.c +++ /dev/null @@ -1,127 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2010 Yoshihisa Uchida - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ - -#include "codeclib.h" -#include "codecs/libtta/ttalib.h" - -CODEC_HEADER - -/* - * TTA (True Audio) codec: - * - * References - * [1] TRUE AUDIO CODEC SOFTWARE http://true-audio.com/ - */ - -static int32_t samples[PCM_BUFFER_LENGTH * 2] IBSS_ATTR; - -/* this is the codec entry point */ -enum codec_status codec_main(enum codec_entry_call_reason reason) -{ - if (reason == CODEC_LOAD) { - /* Generic codec initialisation */ - ci->configure(DSP_SET_SAMPLE_DEPTH, TTA_OUTPUT_DEPTH - 1); - } - - return CODEC_OK; -} - -/* this is called for each file to process */ -enum codec_status codec_run(void) -{ - tta_info info; - unsigned int decodedsamples; - int endofstream; - int new_pos = 0; - int sample_count; - intptr_t param; - - if (codec_init()) - { - DEBUGF("codec_init() error\n"); - return CODEC_ERROR; - } - - ci->seek_buffer(0); - - if (set_tta_info(&info) < 0 || player_init(&info) < 0) - return CODEC_ERROR; - - codec_set_replaygain(ci->id3); - - ci->configure(DSP_SWITCH_FREQUENCY, ci->id3->frequency); - if (info.NCH == 2) { - ci->configure(DSP_SET_STEREO_MODE, STEREO_INTERLEAVED); - } else if (info.NCH == 1) { - ci->configure(DSP_SET_STEREO_MODE, STEREO_MONO); - } else { - DEBUGF("CODEC_ERROR: more than 2 channels\n"); - player_stop(); - return CODEC_ERROR; - } - - /* The main decoder loop */ - decodedsamples = 0; - endofstream = 0; - - if (ci->id3->offset > 0) - { - /* Need to save offset for later use (cleared indirectly by advance_buffer) */ - new_pos = set_position(ci->id3->offset, TTA_SEEK_POS); - if (new_pos >= 0) - decodedsamples = new_pos; - } - - ci->set_elapsed((uint64_t)info.LENGTH * 1000 * decodedsamples / info.DATALENGTH); - - while (!endofstream) - { - enum codec_command_action action = ci->get_command(¶m); - - if (action == CODEC_ACTION_HALT) - break; - - if (action == CODEC_ACTION_SEEK_TIME) - { - new_pos = set_position(param / SEEK_STEP, TTA_SEEK_TIME); - if (new_pos >= 0) - { - decodedsamples = new_pos; - } - - ci->set_elapsed((uint64_t)info.LENGTH * 1000 * decodedsamples / info.DATALENGTH); - ci->seek_complete(); - } - - sample_count = get_samples(samples); - if (sample_count < 0) - break; - - ci->pcmbuf_insert(samples, NULL, sample_count); - decodedsamples += sample_count; - if (decodedsamples >= info.DATALENGTH) - endofstream = 1; - ci->set_elapsed((uint64_t)info.LENGTH * 1000 * decodedsamples / info.DATALENGTH); - } - - player_stop(); - return CODEC_OK; -} diff --git a/apps/codecs/vgm.c b/apps/codecs/vgm.c deleted file mode 100644 index 416f772f1d..0000000000 --- a/apps/codecs/vgm.c +++ /dev/null @@ -1,142 +0,0 @@ - -/* Ripped off from Game_Music_Emu 0.5.2. http://www.slack.net/~ant/ */ -/* Inflate code taken from WikiViewer plugin by Adam Gashlin */ - -#include - -#include "libgme/blargg_endian.h" -#include "libgme/vgm_emu.h" -#include "libgme/inflate/mallocer.h" -#include "libgme/inflate/inflate.h" - -CODEC_HEADER - -/* Maximum number of bytes to process in one iteration */ -#define CHUNK_SIZE (1024*4) -#define MAINMEMBUF 0 - -static int16_t samples[CHUNK_SIZE] IBSS_ATTR; -static struct Vgm_Emu vgm_emu; - -static void *inflatebuf; /* heap for gunzip */ -static char *songbuf; /* destination for uncompressed song */ -static uint32_t songbuflen=0; /* size of the song buffer */ -static uint32_t songlen=0; /* used size of the song buffer */ - -/****************** rockbox interface ******************/ - -/* this is the codec entry point */ -enum codec_status codec_main(enum codec_entry_call_reason reason) -{ - if (reason == CODEC_LOAD) { - /* we only render 16 bits */ - ci->configure(DSP_SET_SAMPLE_DEPTH, 16); - - /* 32 Khz, Interleaved stereo */ - ci->configure(DSP_SET_FREQUENCY, 44100); - ci->configure(DSP_SET_STEREO_MODE, STEREO_INTERLEAVED); - - Vgm_init(&vgm_emu); - Vgm_set_sample_rate(&vgm_emu, 44100); - } - - return CODEC_OK; -} - -/* this is called for each file to process */ -enum codec_status codec_run(void) -{ - blargg_err_t err; - uint8_t *buf; - size_t n; - intptr_t param; - - uint32_t elapsed_time = 0; - - DEBUGF("VGM: next_track\n"); - if (codec_init()) { - return CODEC_ERROR; - } - - codec_set_replaygain(ci->id3); - - /* Read the entire file */ - DEBUGF("VGM: request file\n"); - ci->seek_buffer(0); - buf = ci->request_buffer(&n, ci->filesize); - if (!buf) { - DEBUGF("VGM: file load failed\n"); - return CODEC_ERROR; - } - - /* If couldn't get the whole buffer - will trim file and put and 'end_command' - at the end*/ - if (n < (size_t)ci->filesize) { - DEBUGF("VGM: file was trimmed\n"); - } - - /* If is gzipped decompress it */ - if ( get_le16( buf ) == 0x8b1f ) { - wpw_init_mempool(MAINMEMBUF); - inflatebuf=wpw_malloc(MAINMEMBUF,0x13500); - - /* Will use available remaining memory - as output buffer */ - songbuflen=wpw_available(MAINMEMBUF); - songbuf=wpw_malloc(MAINMEMBUF,songbuflen); - - songlen=decompress(buf,n,songbuf,songbuflen,0,inflatebuf); - - if ((err = Vgm_load_mem(&vgm_emu, songbuf, songlen, true))) { - DEBUGF("VGM: Vgm_load_mem failed (%s)\n", err); - return CODEC_ERROR; - } - - /* Since metadata parser doesn't support VGZ - will set song length here */ - ci->id3->length = Track_get_length( &vgm_emu ); - } - else if ((err = Vgm_load_mem(&vgm_emu, buf, n, false))) { - DEBUGF("VGM: Vgm_load failed_mem (%s)\n", err); - return CODEC_ERROR; - } - - Vgm_start_track(&vgm_emu); - - /* for REPEAT_ONE we disable track limits */ - if (!ci->loop_track()) { - Track_set_fade(&vgm_emu, ci->id3->length - 4000, 4000); - } - - ci->set_elapsed(0); - - /* The main decoder loop */ - while (1) { - enum codec_command_action action = ci->get_command(¶m); - - if (action == CODEC_ACTION_HALT) - break; - - if (action == CODEC_ACTION_SEEK_TIME) { - ci->set_elapsed(param); - elapsed_time = param; - Track_seek(&vgm_emu, param); - ci->seek_complete(); - - /* Set fade again in case we seek to start of song */ - Track_set_fade(&vgm_emu, ci->id3->length - 4000, 4000); - } - - /* Generate audio buffer */ - err = Vgm_play(&vgm_emu, CHUNK_SIZE, samples); - if (err || Track_ended(&vgm_emu)) break; - - ci->pcmbuf_insert(samples, NULL, CHUNK_SIZE >> 1); - - elapsed_time += (CHUNK_SIZE / 2) * 10 / 441; - ci->set_elapsed(elapsed_time); - } - - return CODEC_OK; -} diff --git a/apps/codecs/vorbis.c b/apps/codecs/vorbis.c deleted file mode 100644 index 944dd6d60c..0000000000 --- a/apps/codecs/vorbis.c +++ /dev/null @@ -1,263 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2002 Björn Stenberg - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ - -#include "codeclib.h" -#include "libtremor/ivorbisfile.h" -#include "libtremor/ogg.h" -#ifdef SIMULATOR -#include -#endif - -CODEC_HEADER - -#if defined(CPU_ARM) || defined(CPU_COLDFIRE) || defined(CPU_MIPS) -#include -jmp_buf rb_jump_buf; -#endif - -/* Some standard functions and variables needed by Tremor */ - -static size_t read_handler(void *ptr, size_t size, size_t nmemb, void *datasource) -{ - (void)datasource; - return ci->read_filebuf(ptr, nmemb*size); -} - -static int initial_seek_handler(void *datasource, ogg_int64_t offset, int whence) -{ - (void)datasource; - (void)offset; - (void)whence; - return -1; -} - -static int seek_handler(void *datasource, ogg_int64_t offset, int whence) -{ - (void)datasource; - - if (whence == SEEK_CUR) { - offset += ci->curpos; - } else if (whence == SEEK_END) { - offset += ci->filesize; - } - - if (ci->seek_buffer(offset)) { - return 0; - } - - return -1; -} - -static int close_handler(void *datasource) -{ - (void)datasource; - return 0; -} - -static long tell_handler(void *datasource) -{ - (void)datasource; - return ci->curpos; -} - -/* This sets the DSP parameters based on the current logical bitstream - * (sampling rate, number of channels, etc). - */ -static bool vorbis_set_codec_parameters(OggVorbis_File *vf) -{ - vorbis_info *vi; - - vi = ov_info(vf, -1); - - if (vi == NULL) { - return false; - } - - ci->configure(DSP_SWITCH_FREQUENCY, ci->id3->frequency); - codec_set_replaygain(ci->id3); - - if (vi->channels == 2) { - ci->configure(DSP_SET_STEREO_MODE, STEREO_NONINTERLEAVED); - } else if (vi->channels == 1) { - ci->configure(DSP_SET_STEREO_MODE, STEREO_MONO); - } - - return true; -} - -/* this is the codec entry point */ -enum codec_status codec_main(enum codec_entry_call_reason reason) -{ - if (reason == CODEC_LOAD) { - if (codec_init()) - return CODEC_ERROR; - ci->configure(DSP_SET_SAMPLE_DEPTH, 24); - } - - return CODEC_OK; -} - -/* this is called for each file to process */ -enum codec_status codec_run(void) -{ - ov_callbacks callbacks; - OggVorbis_File vf; - ogg_int32_t **pcm; - - int error = CODEC_ERROR; - long n; - int current_section; - int previous_section; - int eof; - ogg_int64_t vf_offsets[2]; - ogg_int64_t vf_dataoffsets; - ogg_uint32_t vf_serialnos; - ogg_int64_t vf_pcmlengths[2]; - intptr_t param; - -#if defined(CPU_ARM) || defined(CPU_COLDFIRE) || defined(CPU_MIPS) - if (setjmp(rb_jump_buf) != 0) { - /* malloc failed; finish with this track */ - goto done; - } -#endif - ogg_malloc_init(); - - /* Create a decoder instance */ - callbacks.read_func = read_handler; - callbacks.seek_func = initial_seek_handler; - callbacks.tell_func = tell_handler; - callbacks.close_func = close_handler; - - ci->seek_buffer(0); - - /* Open a non-seekable stream */ - error = ov_open_callbacks(ci, &vf, NULL, 0, callbacks); - - /* If the non-seekable open was successful, we need to supply the missing - * data to make it seekable. This is a hack, but it's reasonable since we - * don't want to run the whole file through the buffer before we start - * playing. Using Tremor's seekable open routine would cause us to do - * this, so we pretend not to be seekable at first. Then we fill in the - * missing fields of vf with 1) information in ci->id3, and 2) info - * obtained by Tremor in the above ov_open call. - * - * Note that this assumes there is only ONE logical Vorbis bitstream in our - * physical Ogg bitstream. This is verified in metadata.c, well before we - * get here. - */ - if (!error) { - ogg_free(vf.offsets); - ogg_free(vf.dataoffsets); - ogg_free(vf.serialnos); - - vf.offsets = vf_offsets; - vf.dataoffsets = &vf_dataoffsets; - vf.serialnos = &vf_serialnos; - vf.pcmlengths = vf_pcmlengths; - - vf.offsets[0] = 0; - vf.offsets[1] = ci->id3->filesize; - vf.dataoffsets[0] = vf.offset; - vf.pcmlengths[0] = 0; - vf.pcmlengths[1] = ci->id3->samples; - vf.serialnos[0] = vf.current_serialno; - vf.callbacks.seek_func = seek_handler; - vf.seekable = 1; - vf.end = ci->id3->filesize; - vf.ready_state = OPENED; - vf.links = 1; - } else { - DEBUGF("Vorbis: ov_open failed: %d\n", error); - goto done; - } - - if (ci->id3->offset) { - ci->seek_buffer(ci->id3->offset); - ov_raw_seek(&vf, ci->id3->offset); - ci->set_elapsed(ov_time_tell(&vf)); - ci->set_offset(ov_raw_tell(&vf)); - } - else { - ci->set_elapsed(0); - } - - previous_section = -1; - eof = 0; - while (!eof) { - enum codec_command_action action = ci->get_command(¶m); - - if (action == CODEC_ACTION_HALT) - break; - - if (action == CODEC_ACTION_SEEK_TIME) { - if (ov_time_seek(&vf, param)) { - //ci->logf("ov_time_seek failed"); - } - - ci->set_elapsed(ov_time_tell(&vf)); - ci->seek_complete(); - } - - /* Read host-endian signed 24-bit PCM samples */ - n = ov_read_fixed(&vf, &pcm, 1024, ¤t_section); - - /* Change DSP and buffer settings for this bitstream */ - if (current_section != previous_section) { - if (!vorbis_set_codec_parameters(&vf)) { - goto done; - } else { - previous_section = current_section; - } - } - - if (n == 0) { - eof = 1; - } else if (n < 0) { - DEBUGF("Vorbis: Error decoding frame\n"); - } else { - ci->pcmbuf_insert(pcm[0], pcm[1], n); - ci->set_offset(ov_raw_tell(&vf)); - ci->set_elapsed(ov_time_tell(&vf)); - } - } - - error = CODEC_OK; -done: -#if 0 /* defined(SIMULATOR) */ - { - size_t bufsize; - void* buf = ci->codec_get_buffer(&bufsize); - - DEBUGF("Vorbis: Memory max: %zu\n", get_max_size(buf)); - } -#endif - ogg_malloc_destroy(); - - /* Clean things up for the next track */ - vf.dataoffsets = NULL; - vf.offsets = NULL; - vf.serialnos = NULL; - vf.pcmlengths = NULL; - ov_clear(&vf); - - return error; -} diff --git a/apps/codecs/vox.c b/apps/codecs/vox.c deleted file mode 100644 index 279d003162..0000000000 --- a/apps/codecs/vox.c +++ /dev/null @@ -1,201 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2010 Yoshihisa Uchida - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ - -#include "codeclib.h" -#include "codecs/libpcm/support_formats.h" - -CODEC_HEADER - -/* vox codec (Dialogic telephony file formats) */ - -#define PCM_SAMPLE_SIZE (2048) - -static int32_t samples[PCM_SAMPLE_SIZE] IBSS_ATTR; - -static struct pcm_format format; -static uint32_t bytesdone; - -static uint8_t *read_buffer(size_t *realsize) -{ - uint8_t *buffer = (uint8_t *)ci->request_buffer(realsize, format.chunksize); - if (bytesdone + (*realsize) > format.numbytes) - *realsize = format.numbytes - bytesdone; - bytesdone += *realsize; - ci->advance_buffer(*realsize); - return buffer; -} - -/* this is the codec entry point */ -enum codec_status codec_main(enum codec_entry_call_reason reason) -{ - if (reason == CODEC_LOAD) { - /* Generic codec initialisation */ - ci->configure(DSP_SET_SAMPLE_DEPTH, PCM_OUTPUT_DEPTH-1); - } - - return CODEC_OK; -} - -/* this is called for each file to process */ -enum codec_status codec_run(void) -{ - uint32_t decodedsamples; - size_t n; - int bufcount; - int endofstream; - uint8_t *voxbuf; - off_t firstblockposn = 0; /* position of the first block in file */ - const struct pcm_codec *codec; - intptr_t param; - - if (codec_init()) { - DEBUGF("codec_init() error\n"); - return CODEC_ERROR; - } - - codec_set_replaygain(ci->id3); - - /* Need to save offset for later use (cleared indirectly by advance_buffer) */ - bytesdone = ci->id3->offset; - ci->seek_buffer(0); - - ci->memset(&format, 0, sizeof(struct pcm_format)); - - /* set format */ - format.channels = 1; - format.bitspersample = 4; - format.numbytes = ci->id3->filesize; - format.blockalign = 1; - - /* advance to first WAVE chunk */ - firstblockposn = 0; - decodedsamples = 0; - ci->advance_buffer(firstblockposn); - - /* - * get codec - * supports dialogic oki adpcm only - */ - codec = get_dialogic_oki_adpcm_codec(); - if (!codec) - { - DEBUGF("CODEC_ERROR: dialogic oki adpcm codec does not load.\n"); - return CODEC_ERROR; - } - - if (!codec->set_format(&format)) { - return CODEC_ERROR; - } - - if (format.numbytes == 0) { - DEBUGF("CODEC_ERROR: data size is 0\n"); - return CODEC_ERROR; - } - - /* check chunksize */ - if (format.chunksize * 2 > PCM_SAMPLE_SIZE) - format.chunksize = PCM_SAMPLE_SIZE / 2; - if (format.chunksize == 0) - { - DEBUGF("CODEC_ERROR: chunksize is 0\n"); - return CODEC_ERROR; - } - - ci->configure(DSP_SWITCH_FREQUENCY, ci->id3->frequency); - ci->configure(DSP_SET_STEREO_MODE, STEREO_MONO); - - /* make sure we're at the correct offset */ - if (bytesdone > (uint32_t) firstblockposn) { - /* Round down to previous block */ - struct pcm_pos *newpos = codec->get_seek_pos(bytesdone - firstblockposn, - PCM_SEEK_POS, &read_buffer); - - if (newpos->pos > format.numbytes) { - return CODEC_OK; - } - if (ci->seek_buffer(firstblockposn + newpos->pos)) - { - bytesdone = newpos->pos; - decodedsamples = newpos->samples; - } - } else { - /* already where we need to be */ - bytesdone = 0; - } - - ci->set_elapsed(decodedsamples*1000LL/ci->id3->frequency); - - /* The main decoder loop */ - endofstream = 0; - - while (!endofstream) { - enum codec_command_action action = ci->get_command(¶m); - - if (action == CODEC_ACTION_HALT) - break; - - if (action == CODEC_ACTION_SEEK_TIME) { - struct pcm_pos *newpos = codec->get_seek_pos(param, PCM_SEEK_TIME, - &read_buffer); - - if (newpos->pos > format.numbytes) - { - ci->set_elapsed(ci->id3->length); - ci->seek_complete(); - break; - } - - if (ci->seek_buffer(firstblockposn + newpos->pos)) - { - bytesdone = newpos->pos; - decodedsamples = newpos->samples; - } - - ci->set_elapsed(decodedsamples*1000LL/ci->id3->frequency); - ci->seek_complete(); - } - - voxbuf = (uint8_t *)ci->request_buffer(&n, format.chunksize); - if (n == 0) - break; /* End of stream */ - if (bytesdone + n > format.numbytes) { - n = format.numbytes - bytesdone; - endofstream = 1; - } - - if (codec->decode(voxbuf, n, samples, &bufcount) == CODEC_ERROR) - { - DEBUGF("codec error\n"); - return CODEC_ERROR; - } - - ci->pcmbuf_insert(samples, NULL, bufcount); - ci->advance_buffer(n); - bytesdone += n; - decodedsamples += bufcount; - - if (bytesdone >= format.numbytes) - endofstream = 1; - ci->set_elapsed(decodedsamples*1000LL/ci->id3->frequency); - } - - return CODEC_OK; -} diff --git a/apps/codecs/wav.c b/apps/codecs/wav.c deleted file mode 100644 index d20331bc6c..0000000000 --- a/apps/codecs/wav.c +++ /dev/null @@ -1,437 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2005 Dave Chapman - * Copyright (C) 2009 Yoshihisa Uchida - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ - -#include "codeclib.h" -#include "codecs/libpcm/support_formats.h" - -CODEC_HEADER - -/* WAVE (RIFF) codec: - * - * For a good documentation on WAVE files, see: - * http://www.tsp.ece.mcgill.ca/MMSP/Documents/AudioFormats/WAVE/WAVE.html - * and - * http://www.sonicspot.com/guide/wavefiles.html - * - * For sample WAV files, see: - * http://www.tsp.ece.mcgill.ca/MMSP/Documents/AudioFormats/WAVE/Samples.html - * - */ - -#define PCM_SAMPLE_SIZE (4096*2) - -static int32_t samples[PCM_SAMPLE_SIZE] IBSS_ATTR; - -/* This codec support WAVE files with the following formats: */ -enum -{ - WAVE_FORMAT_UNKNOWN = 0x0000, /* Microsoft Unknown Wave Format */ - WAVE_FORMAT_PCM = 0x0001, /* Microsoft PCM Format */ - WAVE_FORMAT_ADPCM = 0x0002, /* Microsoft ADPCM Format */ - WAVE_FORMAT_IEEE_FLOAT = 0x0003, /* IEEE Float */ - WAVE_FORMAT_ALAW = 0x0006, /* Microsoft ALAW */ - WAVE_FORMAT_MULAW = 0x0007, /* Microsoft MULAW */ - WAVE_FORMAT_DVI_ADPCM = 0x0011, /* Intel's DVI ADPCM */ - WAVE_FORMAT_DIALOGIC_OKI_ADPCM = 0x0017, /* Dialogic OKI ADPCM */ - WAVE_FORMAT_YAMAHA_ADPCM = 0x0020, /* Yamaha ADPCM */ - WAVE_FORMAT_XBOX_ADPCM = 0x0069, /* XBOX ADPCM */ - IBM_FORMAT_MULAW = 0x0101, /* same as WAVE_FORMAT_MULAW */ - IBM_FORMAT_ALAW = 0x0102, /* same as WAVE_FORMAT_ALAW */ - WAVE_FORMAT_SWF_ADPCM = 0x5346, /* Adobe SWF ADPCM */ - WAVE_FORMAT_EXTENSIBLE = 0xFFFE -}; - -static const struct pcm_entry wave_codecs[] = { - { WAVE_FORMAT_UNKNOWN, 0 }, - { WAVE_FORMAT_PCM, get_linear_pcm_codec }, - { WAVE_FORMAT_ADPCM, get_ms_adpcm_codec }, - { WAVE_FORMAT_IEEE_FLOAT, get_ieee_float_codec }, - { WAVE_FORMAT_ALAW, get_itut_g711_alaw_codec }, - { WAVE_FORMAT_MULAW, get_itut_g711_mulaw_codec }, - { WAVE_FORMAT_DVI_ADPCM, get_dvi_adpcm_codec }, - { WAVE_FORMAT_DIALOGIC_OKI_ADPCM, get_dialogic_oki_adpcm_codec }, - { WAVE_FORMAT_YAMAHA_ADPCM, get_yamaha_adpcm_codec }, - { WAVE_FORMAT_XBOX_ADPCM, get_dvi_adpcm_codec }, - { IBM_FORMAT_MULAW, get_itut_g711_mulaw_codec }, - { IBM_FORMAT_ALAW, get_itut_g711_alaw_codec }, - { WAVE_FORMAT_SWF_ADPCM, get_swf_adpcm_codec }, -}; - -#define NUM_FORMATS 13 - -static const struct pcm_codec *get_wave_codec(uint32_t formattag) -{ - int i; - - for (i = 0; i < NUM_FORMATS; i++) - { - if (wave_codecs[i].format_tag == formattag) - { - if (wave_codecs[i].get_codec) - return wave_codecs[i].get_codec(); - return 0; - } - } - return 0; -} - -static struct pcm_format format; -static uint32_t bytesdone; - -static bool set_msadpcm_coeffs(const uint8_t *buf) -{ - int i; - int num; - int size; - - buf += 4; /* skip 'fmt ' */ - size = buf[0] | (buf[1] << 8) | (buf[1] << 16) | (buf[1] << 24); - if (size < 50) - { - DEBUGF("CODEC_ERROR: microsoft adpcm 'fmt ' chunk size=%lu < 50\n", - (unsigned long)size); - return false; - } - - /* get nNumCoef */ - buf += 24; - num = buf[0] | (buf[1] << 8); - - /* - * In many case, nNumCoef is 7. - * Depending upon the encoder, as for this value there is a possibility of - * increasing more. - * If you found the file where this value exceeds 7, please report. - */ - if (num != MSADPCM_NUM_COEFF) - { - DEBUGF("CODEC_ERROR: microsoft adpcm nNumCoef=%d != 7\n", num); - return false; - } - - /* get aCoeffs */ - buf += 2; - for (i = 0; i < MSADPCM_NUM_COEFF; i++) - { - format.coeffs[i][0] = buf[0] | (SE(buf[1]) << 8); - format.coeffs[i][1] = buf[2] | (SE(buf[3]) << 8); - buf += 4; - } - - return true; -} - -static uint8_t *read_buffer(size_t *realsize) -{ - uint8_t *buffer = (uint8_t *)ci->request_buffer(realsize, format.chunksize); - if (bytesdone + (*realsize) > format.numbytes) - *realsize = format.numbytes - bytesdone; - bytesdone += *realsize; - ci->advance_buffer(*realsize); - return buffer; -} - -/* this is the codec entry point */ -enum codec_status codec_main(enum codec_entry_call_reason reason) -{ - if (reason == CODEC_LOAD) { - /* Generic codec initialisation */ - ci->configure(DSP_SET_SAMPLE_DEPTH, PCM_OUTPUT_DEPTH-1); - } - - return CODEC_OK; -} - -/* this is called for each file to process */ -enum codec_status codec_run(void) -{ - uint32_t decodedsamples; - size_t n; - int bufcount; - int endofstream; - unsigned char *buf; - uint8_t *wavbuf; - off_t firstblockposn; /* position of the first block in file */ - const struct pcm_codec *codec; - uint32_t size; - intptr_t param; - - if (codec_init()) { - DEBUGF("codec_init() error\n"); - return CODEC_ERROR; - } - - codec_set_replaygain(ci->id3); - - /* Need to save offset for later use (cleared indirectly by advance_buffer) */ - bytesdone = ci->id3->offset; - - /* get RIFF chunk header */ - ci->seek_buffer(0); - buf = ci->request_buffer(&n, 12); - if (n < 12) { - DEBUGF("request_buffer error\n"); - return CODEC_ERROR; - } - if ((memcmp(buf, "RIFF", 4) != 0) || (memcmp(&buf[8], "WAVE", 4) != 0)) { - DEBUGF("CODEC_ERROR: missing riff header\n"); - return CODEC_ERROR; - } - - /* advance to first WAVE chunk */ - ci->advance_buffer(12); - - firstblockposn = 12; - ci->memset(&format, 0, sizeof(struct pcm_format)); - format.is_signed = true; - format.is_little_endian = true; - - decodedsamples = 0; - codec = 0; - - /* iterate over WAVE chunks until the 'data' chunk, which should be after the 'fmt ' chunk */ - while (true) { - /* get WAVE chunk header */ - buf = ci->request_buffer(&n, 1024); - if (n < 8) { - DEBUGF("data chunk request_buffer error\n"); - /* no more chunks, 'data' chunk must not have been found */ - return CODEC_ERROR; - } - - /* chunkSize */ - size = (buf[4]|(buf[5]<<8)|(buf[6]<<16)|(buf[7]<<24)); - if (memcmp(buf, "fmt ", 4) == 0) { - if (size < 16) { - DEBUGF("CODEC_ERROR: 'fmt ' chunk size=%lu < 16\n", - (unsigned long)size); - return CODEC_ERROR; - } - /* wFormatTag */ - format.formattag=buf[8]|(buf[9]<<8); - /* wChannels */ - format.channels=buf[10]|(buf[11]<<8); - /* skipping dwSamplesPerSec */ - /* skipping dwAvgBytesPerSec */ - /* wBlockAlign */ - format.blockalign=buf[20]|(buf[21]<<8); - /* wBitsPerSample */ - format.bitspersample=buf[22]|(buf[23]<<8); - if (format.formattag != WAVE_FORMAT_PCM) { - if (size < 18) { - /* this is not a fatal error with some formats, - * we'll see later if we can't decode it */ - DEBUGF("CODEC_WARNING: non-PCM WAVE (formattag=0x%x) " - "doesn't have ext. fmt descr (chunksize=%d<18).\n", - (unsigned int)format.formattag, (int)size); - } - else - { - if (format.formattag != WAVE_FORMAT_EXTENSIBLE) - format.samplesperblock = buf[26]|(buf[27]<<8); - else - { - format.size = buf[24]|(buf[25]<<8); - if (format.size < 22) { - DEBUGF("CODEC_ERROR: WAVE_FORMAT_EXTENSIBLE is " - "missing extension\n"); - return CODEC_ERROR; - } - /* wValidBitsPerSample */ - format.bitspersample = buf[26]|(buf[27]<<8); - /* skipping dwChannelMask (4bytes) */ - /* SubFormat (only get the first two bytes) */ - format.formattag = buf[32]|(buf[33]<<8); - } - } - } - - /* msadpcm specific */ - if (format.formattag == WAVE_FORMAT_ADPCM) - { - if (!set_msadpcm_coeffs(buf)) - { - return CODEC_ERROR; - } - } - - /* get codec */ - codec = get_wave_codec(format.formattag); - if (!codec) - { - DEBUGF("CODEC_ERROR: unsupported wave format 0x%x\n", - (unsigned int) format.formattag); - return CODEC_ERROR; - } - - /* riff 8bit linear pcm is unsigned */ - if (format.formattag == WAVE_FORMAT_PCM && format.bitspersample == 8) - format.is_signed = false; - - /* set format, parse codec specific tag, check format, and calculate chunk size */ - if (!codec->set_format(&format)) - { - return CODEC_ERROR; - } - } else if (memcmp(buf, "data", 4) == 0) { - format.numbytes = size; - /* advance to start of data */ - ci->advance_buffer(8); - firstblockposn += 8; - break; - } else if (memcmp(buf, "fact", 4) == 0) { - /* dwSampleLength */ - if (size >= 4) - format.totalsamples = - (buf[8]|(buf[9]<<8)|(buf[10]<<16)|(buf[11]<<24)); - } else { - DEBUGF("unknown WAVE chunk: '%c%c%c%c', size=%lu\n", - buf[0], buf[1], buf[2], buf[3], (unsigned long)size); - } - - /* go to next chunk (even chunk sizes must be padded) */ - size += 8 + (size & 0x01); - - ci->advance_buffer(size); - firstblockposn += size; - } - - if (!codec) - { - DEBUGF("CODEC_ERROR: 'fmt ' chunk not found\n"); - return CODEC_ERROR; - } - - /* common format check */ - if (format.channels == 0) { - DEBUGF("CODEC_ERROR: 'fmt ' chunk not found or 0-channels file\n"); - return CODEC_ERROR; - } - if (format.samplesperblock == 0) { - DEBUGF("CODEC_ERROR: 'fmt ' chunk not found or 0-wSamplesPerBlock file\n"); - return CODEC_ERROR; - } - if (format.blockalign == 0) - { - DEBUGF("CODEC_ERROR: 'fmt ' chunk not found or 0-blockalign file\n"); - return CODEC_ERROR; - } - if (format.numbytes == 0) { - DEBUGF("CODEC_ERROR: 'data' chunk not found or has zero-length\n"); - return CODEC_ERROR; - } - - /* check chunksize */ - if ((format.chunksize / format.blockalign) * format.samplesperblock * format.channels - > PCM_SAMPLE_SIZE) - format.chunksize = (PCM_SAMPLE_SIZE / format.blockalign) * format.blockalign; - if (format.chunksize == 0) - { - DEBUGF("CODEC_ERROR: chunksize is 0\n"); - return CODEC_ERROR; - } - - ci->configure(DSP_SWITCH_FREQUENCY, ci->id3->frequency); - if (format.channels == 2) { - ci->configure(DSP_SET_STEREO_MODE, STEREO_INTERLEAVED); - } else if (format.channels == 1) { - ci->configure(DSP_SET_STEREO_MODE, STEREO_MONO); - } else { - DEBUGF("CODEC_ERROR: more than 2 channels\n"); - return CODEC_ERROR; - } - - /* make sure we're at the correct offset */ - if (bytesdone > (uint32_t) firstblockposn) { - /* Round down to previous block */ - struct pcm_pos *newpos = codec->get_seek_pos(bytesdone - firstblockposn, - PCM_SEEK_POS, &read_buffer); - - if (newpos->pos > format.numbytes) - return CODEC_OK; - if (ci->seek_buffer(firstblockposn + newpos->pos)) - { - bytesdone = newpos->pos; - decodedsamples = newpos->samples; - } - } else { - /* already where we need to be */ - bytesdone = 0; - } - - ci->set_elapsed(decodedsamples*1000LL/ci->id3->frequency); - - /* The main decoder loop */ - endofstream = 0; - - while (!endofstream) { - enum codec_command_action action = ci->get_command(¶m); - - if (action == CODEC_ACTION_HALT) - break; - - if (action == CODEC_ACTION_SEEK_TIME) { - struct pcm_pos *newpos = codec->get_seek_pos(param, PCM_SEEK_TIME, - &read_buffer); - if (newpos->pos > format.numbytes) - { - ci->set_elapsed(ci->id3->length); - ci->seek_complete(); - break; - } - - if (ci->seek_buffer(firstblockposn + newpos->pos)) - { - bytesdone = newpos->pos; - decodedsamples = newpos->samples; - } - - ci->set_elapsed(decodedsamples*1000LL/ci->id3->frequency); - ci->seek_complete(); - } - - wavbuf = (uint8_t *)ci->request_buffer(&n, format.chunksize); - if (n == 0) - break; /* End of stream */ - if (bytesdone + n > format.numbytes) { - n = format.numbytes - bytesdone; - endofstream = 1; - } - - if (codec->decode(wavbuf, n, samples, &bufcount) == CODEC_ERROR) - { - DEBUGF("codec error\n"); - return CODEC_ERROR; - } - - ci->pcmbuf_insert(samples, NULL, bufcount); - ci->advance_buffer(n); - bytesdone += n; - decodedsamples += bufcount; - - if (bytesdone >= format.numbytes) - endofstream = 1; - ci->set_elapsed(decodedsamples*1000LL/ci->id3->frequency); - } - - return CODEC_OK; -} diff --git a/apps/codecs/wav64.c b/apps/codecs/wav64.c deleted file mode 100644 index 184f39bf18..0000000000 --- a/apps/codecs/wav64.c +++ /dev/null @@ -1,441 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2010 Yoshihisa Uchida - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ - -#include "codeclib.h" -#include "codecs/libpcm/support_formats.h" - -CODEC_HEADER - -/* Wave64 codec - * - * References - * [1] VCS Aktiengesellschaft, Sony Wave64, Informations_about_Sony_Wave64.pdf - */ - -#define PCM_SAMPLE_SIZE (4096*2) - -static int32_t samples[PCM_SAMPLE_SIZE] IBSS_ATTR; - -/* Wave64 GUIDs */ -#define WAVE64_GUID_RIFF "riff\x2e\x91\xcf\x11\xa5\xd6\x28\xdb\x04\xc1\x00\x00" -#define WAVE64_GUID_WAVE "wave\xf3\xac\xd3\x11\x8c\xd1\x00\xc0\x4f\x8e\xdb\x8a" -#define WAVE64_GUID_FMT "fmt \xf3\xac\xd3\x11\x8c\xd1\x00\xc0\x4f\x8e\xdb\x8a" -#define WAVE64_GUID_FACT "fact\xf3\xac\xd3\x11\x8c\xd1\x00\xc0\x4f\x8e\xdb\x8a" -#define WAVE64_GUID_DATA "data\xf3\xac\xd3\x11\x8c\xd1\x00\xc0\x4f\x8e\xdb\x8a" - -/* This codec support WAVE files with the following formats: */ -enum -{ - WAVE_FORMAT_UNKNOWN = 0x0000, /* Microsoft Unknown Wave Format */ - WAVE_FORMAT_PCM = 0x0001, /* Microsoft PCM Format */ - WAVE_FORMAT_ADPCM = 0x0002, /* Microsoft ADPCM Format */ - WAVE_FORMAT_IEEE_FLOAT = 0x0003, /* IEEE Float */ - WAVE_FORMAT_ALAW = 0x0006, /* Microsoft ALAW */ - WAVE_FORMAT_MULAW = 0x0007, /* Microsoft MULAW */ - WAVE_FORMAT_DVI_ADPCM = 0x0011, /* Intel's DVI ADPCM */ - WAVE_FORMAT_DIALOGIC_OKI_ADPCM = 0x0017, /* Dialogic OKI ADPCM */ - WAVE_FORMAT_YAMAHA_ADPCM = 0x0020, /* Yamaha ADPCM */ - WAVE_FORMAT_XBOX_ADPCM = 0x0069, /* XBOX ADPCM */ - IBM_FORMAT_MULAW = 0x0101, /* same as WAVE_FORMAT_MULAW */ - IBM_FORMAT_ALAW = 0x0102, /* same as WAVE_FORMAT_ALAW */ - WAVE_FORMAT_SWF_ADPCM = 0x5346, /* Adobe SWF ADPCM */ - WAVE_FORMAT_EXTENSIBLE = 0xFFFE -}; - -const struct pcm_entry wave_codecs[] = { - { WAVE_FORMAT_UNKNOWN, 0 }, - { WAVE_FORMAT_PCM, get_linear_pcm_codec }, - { WAVE_FORMAT_ADPCM, get_ms_adpcm_codec }, - { WAVE_FORMAT_IEEE_FLOAT, get_ieee_float_codec }, - { WAVE_FORMAT_ALAW, get_itut_g711_alaw_codec }, - { WAVE_FORMAT_MULAW, get_itut_g711_mulaw_codec }, - { WAVE_FORMAT_DVI_ADPCM, get_dvi_adpcm_codec }, - { WAVE_FORMAT_DIALOGIC_OKI_ADPCM, get_dialogic_oki_adpcm_codec }, - { WAVE_FORMAT_YAMAHA_ADPCM, get_yamaha_adpcm_codec }, - { WAVE_FORMAT_XBOX_ADPCM, get_dvi_adpcm_codec }, - { IBM_FORMAT_MULAW, get_itut_g711_mulaw_codec }, - { IBM_FORMAT_ALAW, get_itut_g711_alaw_codec }, - { WAVE_FORMAT_SWF_ADPCM, get_swf_adpcm_codec }, -}; - -#define NUM_FORMATS 13 - -static const struct pcm_codec *get_wave_codec(uint32_t formattag) -{ - int i; - - for (i = 0; i < NUM_FORMATS; i++) - { - if (wave_codecs[i].format_tag == formattag) - { - if (wave_codecs[i].get_codec) - return wave_codecs[i].get_codec(); - return 0; - } - } - return 0; -} - -static struct pcm_format format; -static uint32_t bytesdone; - -/* Read an unaligned 64-bit little endian unsigned integer from buffer. */ -static uint64_t get_uint64_le(void* buf) -{ - unsigned char* p = (unsigned char*) buf; - - return p[0] | (p[1] << 8) | (p[2] << 16) | (p[3] << 24) | ((uint64_t)p[4] << 32) | - ((uint64_t)p[5] << 40) | ((uint64_t)p[6] << 48) | ((uint64_t)p[7] << 56); -} - -static bool set_msadpcm_coeffs(unsigned char *buf) -{ - int i; - int num; - uint64_t size; - - buf += 16; /* skip 'fmt ' GUID */ - size = get_uint64_le(buf); - if (size < 50) - { - DEBUGF("CODEC_ERROR: microsoft adpcm 'fmt ' chunk size=%d < 50\n", (int)size); - return false; - } - - /* get nNumCoef */ - buf += 28; - num = buf[0] | (buf[1] << 8); - - /* - * In many case, nNumCoef is 7. - * Depending upon the encoder, as for this value there is a possibility of - * increasing more. - * If you found the file where this value exceeds 7, please report. - */ - if (num != MSADPCM_NUM_COEFF) - { - DEBUGF("CODEC_ERROR: microsoft adpcm nNumCoef=%d != 7\n", num); - return false; - } - - /* get aCoeffs */ - buf += 2; - for (i = 0; i < MSADPCM_NUM_COEFF; i++) - { - format.coeffs[i][0] = buf[0] | (SE(buf[1]) << 8); - format.coeffs[i][1] = buf[2] | (SE(buf[3]) << 8); - buf += 4; - } - - return true; -} - -static uint8_t *read_buffer(size_t *realsize) -{ - uint8_t *buffer = (uint8_t *)ci->request_buffer(realsize, format.chunksize); - if (bytesdone + (*realsize) > format.numbytes) - *realsize = format.numbytes - bytesdone; - bytesdone += *realsize; - ci->advance_buffer(*realsize); - return buffer; -} - -/* this is the codec entry point */ -enum codec_status codec_main(enum codec_entry_call_reason reason) -{ - if (reason == CODEC_LOAD) { - /* Generic codec initialisation */ - ci->configure(DSP_SET_SAMPLE_DEPTH, PCM_OUTPUT_DEPTH-1); - } - - return CODEC_OK; -} - -/* this is called for each file to process */ -enum codec_status codec_run(void) -{ - uint32_t decodedsamples; - size_t n; - int bufcount; - int endofstream; - unsigned char *buf; - uint8_t *wavbuf; - off_t firstblockposn; /* position of the first block in file */ - const struct pcm_codec *codec; - uint64_t size; - intptr_t param; - - if (codec_init()) { - DEBUGF("codec_init() error\n"); - return CODEC_ERROR; - } - - codec_set_replaygain(ci->id3); - - /* Need to save offset for later use (cleared indirectly by advance_buffer) */ - bytesdone = ci->id3->offset; - - /* get RIFF chunk header */ - ci->seek_buffer(0); - buf = ci->request_buffer(&n, 40); - if (n < 40) { - DEBUGF("request_buffer error\n"); - return CODEC_ERROR; - } - if ((memcmp(buf , WAVE64_GUID_RIFF, 16) != 0) || - (memcmp(buf+24, WAVE64_GUID_WAVE, 16) != 0)) - { - return CODEC_ERROR; - } - - /* advance to first WAVE chunk */ - ci->advance_buffer(40); - - firstblockposn = 40; - ci->memset(&format, 0, sizeof(struct pcm_format)); - format.is_signed = true; - format.is_little_endian = true; - - decodedsamples = 0; - codec = 0; - - /* iterate over WAVE chunks until the 'data' chunk, which should be after the 'fmt ' chunk */ - while (true) { - /* get WAVE chunk header */ - buf = ci->request_buffer(&n, 1024); - if (n < 8) { - DEBUGF("data chunk request_buffer error\n"); - /* no more chunks, 'data' chunk must not have been found */ - return CODEC_ERROR; - } - - /* chunkSize */ - size = get_uint64_le(buf+16) - 24; - if (memcmp(buf, WAVE64_GUID_FMT, 16) == 0) { - if (size < 16) { - DEBUGF("CODEC_ERROR: 'fmt ' chunk size=%d < 16\n", (int)size); - return CODEC_ERROR; - } - /* wFormatTag */ - format.formattag=buf[24]|(buf[25]<<8); - /* wChannels */ - format.channels=buf[26]|(buf[27]<<8); - /* skipping dwSamplesPerSec */ - /* skipping dwAvgBytesPerSec */ - /* wBlockAlign */ - format.blockalign=buf[36]|(buf[37]<<8); - /* wBitsPerSample */ - format.bitspersample=buf[38]|(buf[39]<<8); - if (format.formattag != WAVE_FORMAT_PCM) { - if (size < 18) { - /* this is not a fatal error with some formats, - * we'll see later if we can't decode it */ - DEBUGF("CODEC_WARNING: non-PCM WAVE (formattag=0x%x) " - "doesn't have ext. fmt descr (chunksize=%d<18).\n", - (unsigned int)format.formattag, (int)size); - } - else - { - if (format.formattag != WAVE_FORMAT_EXTENSIBLE) - format.samplesperblock = buf[42]|(buf[43]<<8); - else { - format.size = buf[40]|(buf[41]<<8); - if (format.size < 22) { - DEBUGF("CODEC_ERROR: WAVE_FORMAT_EXTENSIBLE is " - "missing extension\n"); - return CODEC_ERROR; - } - /* wValidBitsPerSample */ - format.bitspersample = buf[42]|(buf[43]<<8); - /* skipping dwChannelMask (4bytes) */ - /* SubFormat (only get the first two bytes) */ - format.formattag = buf[48]|(buf[49]<<8); - } - } - } - - /* msadpcm specific */ - if (format.formattag == WAVE_FORMAT_ADPCM) - { - if (!set_msadpcm_coeffs(buf)) - return CODEC_ERROR; - } - - /* get codec */ - codec = get_wave_codec(format.formattag); - if (!codec) - { - DEBUGF("CODEC_ERROR: unsupported wave format 0x%x\n", - (unsigned int) format.formattag); - return CODEC_ERROR; - } - - /* riff 8bit linear pcm is unsigned */ - if (format.formattag == WAVE_FORMAT_PCM && format.bitspersample == 8) - format.is_signed = false; - - /* check format, and calculate chunk size */ - if (!codec->set_format(&format)) - return CODEC_ERROR; - } else if (memcmp(buf, WAVE64_GUID_DATA, 16) == 0) { - format.numbytes = size; - /* advance to start of data */ - ci->advance_buffer(24); - firstblockposn += 24; - break; - } else if (memcmp(buf, WAVE64_GUID_FACT, 16) == 0) { - /* skip 'fact' chunk */ - } else { - DEBUGF("unknown Wave64 chunk: " - "'%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x'\n", - buf[0], buf[1], buf[ 2], buf[ 3], buf[ 4], buf[ 5], buf[ 6], buf[ 7], - buf[8], buf[9], buf[10], buf[11], buf[12], buf[13], buf[14], buf[15]); - } - - /* go to next chunk (8byte bound) */ - size += 24 + ((1 + ~size) & 0x07); - - ci->advance_buffer(size); - firstblockposn += size; - } - - if (!codec) - { - DEBUGF("CODEC_ERROR: 'fmt ' chunk not found\n"); - return CODEC_ERROR; - } - - /* common format check */ - if (format.channels == 0) { - DEBUGF("CODEC_ERROR: 'fmt ' chunk not found or 0-channels file\n"); - return CODEC_ERROR; - } - if (format.samplesperblock == 0) { - DEBUGF("CODEC_ERROR: 'fmt ' chunk not found or 0-wSamplesPerBlock file\n"); - return CODEC_ERROR; - } - if (format.blockalign == 0) - { - DEBUGF("CODEC_ERROR: 'fmt ' chunk not found or 0-blockalign file\n"); - return CODEC_ERROR; - } - if (format.numbytes == 0) { - DEBUGF("CODEC_ERROR: 'data' chunk not found or has zero-length\n"); - return CODEC_ERROR; - } - - /* check chunksize */ - if ((format.chunksize / format.blockalign) * format.samplesperblock * format.channels - > PCM_SAMPLE_SIZE) - format.chunksize = (PCM_SAMPLE_SIZE / format.blockalign) * format.blockalign; - if (format.chunksize == 0) - { - DEBUGF("CODEC_ERROR: chunksize is 0\n"); - return CODEC_ERROR; - } - - ci->configure(DSP_SWITCH_FREQUENCY, ci->id3->frequency); - if (format.channels == 2) { - ci->configure(DSP_SET_STEREO_MODE, STEREO_INTERLEAVED); - } else if (format.channels == 1) { - ci->configure(DSP_SET_STEREO_MODE, STEREO_MONO); - } else { - DEBUGF("CODEC_ERROR: more than 2 channels\n"); - return CODEC_ERROR; - } - - /* make sure we're at the correct offset */ - if (bytesdone > (uint32_t) firstblockposn) { - /* Round down to previous block */ - struct pcm_pos *newpos = codec->get_seek_pos(bytesdone - firstblockposn, - PCM_SEEK_POS, &read_buffer); - - if (newpos->pos > format.numbytes) { - return CODEC_OK; - } - if (ci->seek_buffer(firstblockposn + newpos->pos)) - { - bytesdone = newpos->pos; - decodedsamples = newpos->samples; - } - } else { - /* already where we need to be */ - bytesdone = 0; - } - - ci->set_elapsed(decodedsamples*1000LL/ci->id3->frequency); - - /* The main decoder loop */ - endofstream = 0; - - while (!endofstream) { - enum codec_command_action action = ci->get_command(¶m); - - if (action == CODEC_ACTION_HALT) - break; - - if (action == CODEC_ACTION_SEEK_TIME) { - struct pcm_pos *newpos = codec->get_seek_pos(param, PCM_SEEK_TIME, - &read_buffer); - - if (newpos->pos > format.numbytes) - { - ci->set_elapsed(ci->id3->length); - ci->seek_complete(); - break; - } - - if (ci->seek_buffer(firstblockposn + newpos->pos)) - { - bytesdone = newpos->pos; - decodedsamples = newpos->samples; - } - - ci->set_elapsed(decodedsamples*1000LL/ci->id3->frequency); - ci->seek_complete(); - } - - wavbuf = (uint8_t *)ci->request_buffer(&n, format.chunksize); - if (n == 0) - break; /* End of stream */ - if (bytesdone + n > format.numbytes) { - n = format.numbytes - bytesdone; - endofstream = 1; - } - - if (codec->decode(wavbuf, n, samples, &bufcount) == CODEC_ERROR) - { - DEBUGF("codec error\n"); - return CODEC_ERROR; - } - - ci->pcmbuf_insert(samples, NULL, bufcount); - ci->advance_buffer(n); - bytesdone += n; - decodedsamples += bufcount; - - if (bytesdone >= format.numbytes) - endofstream = 1; - ci->set_elapsed(decodedsamples*1000LL/ci->id3->frequency); - } - - return CODEC_OK; -} diff --git a/apps/codecs/wav_enc.c b/apps/codecs/wav_enc.c deleted file mode 100644 index e4afeaf93c..0000000000 --- a/apps/codecs/wav_enc.c +++ /dev/null @@ -1,386 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2006 Antonius Hellmann - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ - -#include -#include "codeclib.h" - -CODEC_ENC_HEADER - -struct riff_header -{ - uint8_t riff_id[4]; /* 00h - "RIFF" */ - uint32_t riff_size; /* 04h - sz following headers + data_size */ - /* format header */ - uint8_t format[4]; /* 08h - "WAVE" */ - uint8_t format_id[4]; /* 0Ch - "fmt " */ - uint32_t format_size; /* 10h - 16 for PCM (sz format data) */ - /* format data */ - uint16_t audio_format; /* 14h - 1=PCM */ - uint16_t num_channels; /* 16h - 1=M, 2=S, etc. */ - uint32_t sample_rate; /* 18h - HZ */ - uint32_t byte_rate; /* 1Ch - num_channels*sample_rate*bits_per_sample/8 */ - uint16_t block_align; /* 20h - num_channels*bits_per_samples/8 */ - uint16_t bits_per_sample; /* 22h - 8=8 bits, 16=16 bits, etc. */ - /* Not for audio_format=1 (PCM) */ -/* unsigned short extra_param_size; 24h - size of extra data */ -/* unsigned char *extra_params; */ - /* data header */ - uint8_t data_id[4]; /* 24h - "data" */ - uint32_t data_size; /* 28h - num_samples*num_channels*bits_per_sample/8 */ -/* unsigned char *data; 2ch - actual sound data */ -} __attribute__((packed)); - -#define RIFF_FMT_HEADER_SIZE 12 /* format -> format_size */ -#define RIFF_FMT_DATA_SIZE 16 /* audio_format -> bits_per_sample */ -#define RIFF_DATA_HEADER_SIZE 8 /* data_id -> data_size */ - -#define PCM_DEPTH_BYTES 2 -#define PCM_DEPTH_BITS 16 -#define PCM_SAMP_PER_CHUNK 2048 -#define PCM_CHUNK_SIZE (PCM_SAMP_PER_CHUNK*4) - -static int num_channels IBSS_ATTR; -static int rec_mono_mode IBSS_ATTR; -static uint32_t sample_rate; -static uint32_t enc_size; -static int32_t err IBSS_ATTR; - -static const struct riff_header riff_header = -{ - /* "RIFF" header */ - { 'R', 'I', 'F', 'F' }, /* riff_id */ - 0, /* riff_size (*) */ - /* format header */ - { 'W', 'A', 'V', 'E' }, /* format */ - { 'f', 'm', 't', ' ' }, /* format_id */ - htole32(16), /* format_size */ - /* format data */ - htole16(1), /* audio_format */ - 0, /* num_channels (*) */ - 0, /* sample_rate (*) */ - 0, /* byte_rate (*) */ - 0, /* block_align (*) */ - htole16(PCM_DEPTH_BITS), /* bits_per_sample */ - /* data header */ - { 'd', 'a', 't', 'a' }, /* data_id */ - 0 /* data_size (*) */ - /* (*) updated during ENC_END_FILE event */ -}; - -/* called version often - inline */ -static inline bool is_file_data_ok(struct enc_file_event_data *data) ICODE_ATTR; -static inline bool is_file_data_ok(struct enc_file_event_data *data) -{ - return data->rec_file >= 0 && (long)data->chunk->flags >= 0; -} /* is_file_data_ok */ - -/* called version often - inline */ -static inline bool on_write_chunk(struct enc_file_event_data *data) ICODE_ATTR; -static inline bool on_write_chunk(struct enc_file_event_data *data) -{ - if (!is_file_data_ok(data)) - return false; - - if (data->chunk->enc_data == NULL) - { -#ifdef ROCKBOX_HAS_LOGF - ci->logf("wav enc: NULL data"); -#endif - return true; - } - - if (ci->write(data->rec_file, data->chunk->enc_data, - data->chunk->enc_size) != (ssize_t)data->chunk->enc_size) - return false; - - data->num_pcm_samples += data->chunk->num_pcm; - return true; -} /* on_write_chunk */ - -static bool on_start_file(struct enc_file_event_data *data) -{ - if ((data->chunk->flags & CHUNKF_ERROR) || *data->filename == '\0') - return false; - - data->rec_file = ci->open(data->filename, O_RDWR|O_CREAT|O_TRUNC, 0666); - - if (data->rec_file < 0) - return false; - - /* reset sample count */ - data->num_pcm_samples = 0; - - /* write template header */ - if (ci->write(data->rec_file, &riff_header, sizeof (riff_header)) - != sizeof (riff_header)) - { - return false; - } - - data->new_enc_size += sizeof (riff_header); - return true; -} /* on_start_file */ - -static bool on_end_file(struct enc_file_event_data *data) -{ - /* update template header */ - struct riff_header hdr; - uint32_t data_size; - - if (data->rec_file < 0) - return false; /* file already closed, nothing more we can do */ - - /* always _try_ to write the file header, even on error */ - if ((ci->lseek(data->rec_file, 0, SEEK_SET)) || - (ci->read(data->rec_file, &hdr, sizeof (hdr)) != sizeof (hdr))) - { - return false; - } - - data_size = data->num_pcm_samples*num_channels*PCM_DEPTH_BYTES; - - /* "RIFF" header */ - hdr.riff_size = htole32(RIFF_FMT_HEADER_SIZE + RIFF_FMT_DATA_SIZE - + RIFF_DATA_HEADER_SIZE + data_size); - - /* format data */ - hdr.num_channels = htole16(num_channels); - hdr.sample_rate = htole32(sample_rate); - hdr.byte_rate = htole32(sample_rate*num_channels* PCM_DEPTH_BYTES); - hdr.block_align = htole16(num_channels*PCM_DEPTH_BYTES); - - /* data header */ - hdr.data_size = htole32(data_size); - - if (ci->lseek(data->rec_file, 0, SEEK_SET) != 0 || - ci->write(data->rec_file, &hdr, sizeof (hdr)) != sizeof (hdr) || - ci->close(data->rec_file) != 0) - { - return false; - } - - data->rec_file = -1; - - return true; -} /* on_end_file */ - -STATICIRAM void enc_events_callback(enum enc_events event, void *data) - ICODE_ATTR; -STATICIRAM void enc_events_callback(enum enc_events event, void *data) -{ - switch (event) - { - case ENC_WRITE_CHUNK: - if (on_write_chunk((struct enc_file_event_data *)data)) - return; - - break; - - case ENC_START_FILE: - if (on_start_file((struct enc_file_event_data *)data)) - return; - - break; - - case ENC_END_FILE: - if (on_end_file((struct enc_file_event_data *)data)) - return; - - break; - - default: - return; - } - - /* Something failed above. Signal error back to core. */ - ((struct enc_file_event_data *)data)->chunk->flags |= CHUNKF_ERROR; -} /* enc_events_callback */ - -/* convert native pcm samples to wav format samples */ -static inline void sample_to_mono(uint32_t **src, uint32_t **dst) -{ - int32_t lr1, lr2; - - switch(rec_mono_mode) - { - case 1: - /* mono = L */ - lr1 = *(*src)++; - lr1 = lr1 >> 16; - lr2 = *(*src)++; - lr2 = lr2 >> 16; - break; - case 2: - /* mono = R */ - lr1 = *(*src)++; - lr1 = (uint16_t)lr1; - lr2 = *(*src)++; - lr2 = (uint16_t)lr2; - break; - case 0: - default: - /* mono = (L+R)/2 */ - lr1 = *(*src)++; - lr1 = (int16_t)lr1 + (lr1 >> 16) + err; - err = lr1 & 1; - lr1 >>= 1; - - lr2 = *(*src)++; - lr2 = (int16_t)lr2 + (lr2 >> 16) + err; - err = lr2 & 1; - lr2 >>= 1; - break; - } - *(*dst)++ = htole32((lr2 << 16) | (uint16_t)lr1); -} /* sample_to_mono */ - -STATICIRAM void chunk_to_wav_format(uint32_t *src, uint32_t *dst) ICODE_ATTR; -STATICIRAM void chunk_to_wav_format(uint32_t *src, uint32_t *dst) -{ - if (num_channels == 1) - { - /* On big endian: - * |LLLLLLLLllllllll|RRRRRRRRrrrrrrrr| - * |LLLLLLLLllllllll|RRRRRRRRrrrrrrrr| => - * |mmmmmmmmMMMMMMMM|mmmmmmmmMMMMMMMM| - * - * On little endian: - * |llllllllLLLLLLLL|rrrrrrrrRRRRRRRR| - * |llllllllLLLLLLLL|rrrrrrrrRRRRRRRR| => - * |mmmmmmmmMMMMMMMM|mmmmmmmmMMMMMMMM| - */ - uint32_t *src_end = src + PCM_SAMP_PER_CHUNK; - - do - { - sample_to_mono(&src, &dst); - sample_to_mono(&src, &dst); - sample_to_mono(&src, &dst); - sample_to_mono(&src, &dst); - sample_to_mono(&src, &dst); - sample_to_mono(&src, &dst); - sample_to_mono(&src, &dst); - sample_to_mono(&src, &dst); - } - while (src < src_end); - } - else - { -#ifdef ROCKBOX_BIG_ENDIAN - /* |LLLLLLLLllllllll|RRRRRRRRrrrrrrrr| => - * |llllllllLLLLLLLL|rrrrrrrrRRRRRRRR| - */ - uint32_t *src_end = src + PCM_SAMP_PER_CHUNK; - - do - { - *dst++ = swap_odd_even32(*src++); - *dst++ = swap_odd_even32(*src++); - *dst++ = swap_odd_even32(*src++); - *dst++ = swap_odd_even32(*src++); - *dst++ = swap_odd_even32(*src++); - *dst++ = swap_odd_even32(*src++); - *dst++ = swap_odd_even32(*src++); - *dst++ = swap_odd_even32(*src++); - } - while (src < src_end); -#else - /* |llllllllLLLLLLLL|rrrrrrrrRRRRRRRR| => - * |llllllllLLLLLLLL|rrrrrrrrRRRRRRRR| - */ - ci->memcpy(dst, src, PCM_CHUNK_SIZE); -#endif - } -} /* chunk_to_wav_format */ - -static bool init_encoder(void) -{ - struct enc_inputs inputs; - struct enc_parameters params; - - if (ci->enc_get_inputs == NULL || - ci->enc_set_parameters == NULL || - ci->enc_get_chunk == NULL || - ci->enc_finish_chunk == NULL || - ci->enc_get_pcm_data == NULL ) - return false; - - ci->enc_get_inputs(&inputs); - - if (inputs.config->afmt != AFMT_PCM_WAV) - return false; - - sample_rate = inputs.sample_rate; - num_channels = inputs.num_channels; - rec_mono_mode = inputs.rec_mono_mode; - err = 0; - - /* configure the buffer system */ - params.afmt = AFMT_PCM_WAV; - enc_size = PCM_CHUNK_SIZE*inputs.num_channels / 2; - params.chunk_size = enc_size; - params.enc_sample_rate = sample_rate; - params.reserve_bytes = 0; - params.events_callback = enc_events_callback; - ci->enc_set_parameters(¶ms); - - return true; -} /* init_encoder */ - -/* this is the codec entry point */ -enum codec_status codec_main(enum codec_entry_call_reason reason) -{ - if (reason == CODEC_LOAD) { - if (!init_encoder()) - return CODEC_ERROR; - } - else if (reason == CODEC_UNLOAD) { - /* reset parameters to initial state */ - ci->enc_set_parameters(NULL); - } - - return CODEC_OK; -} - -/* this is called for each file to process */ -enum codec_status codec_run(void) -{ - /* main encoding loop */ - while(ci->get_command(NULL) != CODEC_ACTION_HALT) - { - uint32_t *src = (uint32_t *)ci->enc_get_pcm_data(PCM_CHUNK_SIZE); - struct enc_chunk_hdr *chunk; - - if(src == NULL) - continue; - - chunk = ci->enc_get_chunk(); - chunk->enc_size = enc_size; - chunk->num_pcm = PCM_SAMP_PER_CHUNK; - chunk->enc_data = ENC_CHUNK_SKIP_HDR(chunk->enc_data, chunk); - - chunk_to_wav_format(src, (uint32_t *)chunk->enc_data); - - ci->enc_finish_chunk(); - } - - return CODEC_OK; -} diff --git a/apps/codecs/wavpack.c b/apps/codecs/wavpack.c deleted file mode 100644 index 4d42391fc1..0000000000 --- a/apps/codecs/wavpack.c +++ /dev/null @@ -1,127 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2005 David Bryant - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ - -#include "codeclib.h" -#include "libwavpack/wavpack.h" - -CODEC_HEADER - -#define BUFFER_SIZE 4096 - -static int32_t temp_buffer [BUFFER_SIZE] IBSS_ATTR; - -static int32_t read_callback (void *buffer, int32_t bytes) -{ - int32_t retval = ci->read_filebuf (buffer, bytes); - ci->set_offset(ci->curpos); - return retval; -} - -/* this is the codec entry point */ -enum codec_status codec_main(enum codec_entry_call_reason reason) -{ - if (reason == CODEC_LOAD) { - /* Generic codec initialisation */ - ci->configure(DSP_SET_SAMPLE_DEPTH, 28); - } - - return CODEC_OK; -} - -/* this is called for each file to process */ -enum codec_status codec_run(void) -{ - WavpackContext *wpc; - char error [80]; - /* rockbox: comment 'set but unused' variables - int bps; - */ - int nchans, sr_100; - intptr_t param; - - if (codec_init()) - return CODEC_ERROR; - - ci->seek_buffer (ci->id3->offset); - - /* Create a decoder instance */ - wpc = WavpackOpenFileInput (read_callback, error); - - if (!wpc) - return CODEC_ERROR; - - ci->configure(DSP_SWITCH_FREQUENCY, WavpackGetSampleRate (wpc)); - codec_set_replaygain(ci->id3); - /* bps = WavpackGetBytesPerSample (wpc); */ - nchans = WavpackGetReducedChannels (wpc); - ci->configure(DSP_SET_STEREO_MODE, nchans == 2 ? STEREO_INTERLEAVED : STEREO_MONO); - sr_100 = ci->id3->frequency / 100; - - ci->set_elapsed (WavpackGetSampleIndex (wpc) / sr_100 * 10); - - /* The main decoder loop */ - - while (1) { - int32_t nsamples; - enum codec_command_action action = ci->get_command(¶m); - - if (action == CODEC_ACTION_HALT) - break; - - if (action == CODEC_ACTION_SEEK_TIME) { - int curpos_ms = WavpackGetSampleIndex (wpc) / sr_100 * 10; - int n, d, skip; - - if (param > curpos_ms) { - n = param - curpos_ms; - d = ci->id3->length - curpos_ms; - skip = (int)((int64_t)(ci->filesize - ci->curpos) * n / d); - ci->seek_buffer (ci->curpos + skip); - } - else if (curpos_ms != 0) { - n = curpos_ms - param; - d = curpos_ms; - skip = (int)((int64_t) ci->curpos * n / d); - ci->seek_buffer (ci->curpos - skip); - } - - wpc = WavpackOpenFileInput (read_callback, error); - if (!wpc) - { - ci->seek_complete(); - break; - } - - ci->set_elapsed (WavpackGetSampleIndex (wpc) / sr_100 * 10); - ci->seek_complete(); - } - - nsamples = WavpackUnpackSamples (wpc, temp_buffer, BUFFER_SIZE / nchans); - - if (!nsamples) - break; - - ci->pcmbuf_insert (temp_buffer, NULL, nsamples); - ci->set_elapsed (WavpackGetSampleIndex (wpc) / sr_100 * 10); - } - - return CODEC_OK; -} diff --git a/apps/codecs/wavpack_enc.c b/apps/codecs/wavpack_enc.c deleted file mode 100644 index 730cf0734b..0000000000 --- a/apps/codecs/wavpack_enc.c +++ /dev/null @@ -1,467 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2006 Antonius Hellmann - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ - -#include "codeclib.h" -#include "libwavpack/wavpack.h" - -CODEC_ENC_HEADER - -/** Types **/ -typedef struct -{ - uint8_t type; /* Type of metadata */ - uint8_t word_size; /* Size of metadata in words */ -} __attribute__((packed)) WavpackMetadataHeader; - -struct riff_header -{ - uint8_t riff_id[4]; /* 00h - "RIFF" */ - uint32_t riff_size; /* 04h - sz following headers + data_size */ - /* format header */ - uint8_t format[4]; /* 08h - "WAVE" */ - uint8_t format_id[4]; /* 0Ch - "fmt " */ - uint32_t format_size; /* 10h - 16 for PCM (sz format data) */ - /* format data */ - uint16_t audio_format; /* 14h - 1=PCM */ - uint16_t num_channels; /* 16h - 1=M, 2=S, etc. */ - uint32_t sample_rate; /* 18h - HZ */ - uint32_t byte_rate; /* 1Ch - num_channels*sample_rate*bits_per_sample/8 */ - uint16_t block_align; /* 20h - num_channels*bits_per_samples/8 */ - uint16_t bits_per_sample; /* 22h - 8=8 bits, 16=16 bits, etc. */ - /* Not for audio_format=1 (PCM) */ -/* unsigned short extra_param_size; 24h - size of extra data */ -/* unsigned char *extra_params; */ - /* data header */ - uint8_t data_id[4]; /* 24h - "data" */ - uint32_t data_size; /* 28h - num_samples*num_channels*bits_per_sample/8 */ -/* unsigned char *data; 2ch - actual sound data */ -} __attribute__((packed)); - -#define RIFF_FMT_HEADER_SIZE 12 /* format -> format_size */ -#define RIFF_FMT_DATA_SIZE 16 /* audio_format -> bits_per_sample */ -#define RIFF_DATA_HEADER_SIZE 8 /* data_id -> data_size */ - -#define PCM_DEPTH_BITS 16 -#define PCM_DEPTH_BYTES 2 -#define PCM_SAMP_PER_CHUNK 5000 -#define PCM_CHUNK_SIZE (4*PCM_SAMP_PER_CHUNK) - -/** Data **/ -static int8_t input_buffer[PCM_CHUNK_SIZE*2] IBSS_ATTR; -static WavpackConfig config IBSS_ATTR; -static WavpackContext *wpc; -static int32_t data_size, input_size, input_step IBSS_ATTR; -static int32_t err IBSS_ATTR; - -static const WavpackMetadataHeader wvpk_mdh = -{ - ID_RIFF_HEADER, - sizeof (struct riff_header) / sizeof (uint16_t), -}; - -static const struct riff_header riff_header = -{ - /* "RIFF" header */ - { 'R', 'I', 'F', 'F' }, /* riff_id */ - 0, /* riff_size (*) */ - /* format header */ - { 'W', 'A', 'V', 'E' }, /* format */ - { 'f', 'm', 't', ' ' }, /* format_id */ - htole32(16), /* format_size */ - /* format data */ - htole16(1), /* audio_format */ - 0, /* num_channels (*) */ - 0, /* sample_rate (*) */ - 0, /* byte_rate (*) */ - 0, /* block_align (*) */ - htole16(PCM_DEPTH_BITS), /* bits_per_sample */ - /* data header */ - { 'd', 'a', 't', 'a' }, /* data_id */ - 0 /* data_size (*) */ - /* (*) updated during ENC_END_FILE event */ -}; - -static inline void sample_to_int32_mono(int32_t **src, int32_t **dst) -{ - int32_t t = *(*src)++; - /* endianness irrelevant */ - t = (int16_t)t + (t >> 16) + err; - err = t & 1; - *(*dst)++ = t >> 1; -} /* sample_to_int32_mono */ - -static inline void sample_to_int32_stereo(int32_t **src, int32_t **dst) -{ - int32_t t = *(*src)++; -#ifdef ROCKBOX_BIG_ENDIAN - *(*dst)++ = t >> 16, *(*dst)++ = (int16_t)t; -#else - *(*dst)++ = (int16_t)t, *(*dst)++ = t >> 16; -#endif -} /* sample_to_int32_stereo */ - -STATICIRAM void chunk_to_int32(int32_t *src) ICODE_ATTR; -STATICIRAM void chunk_to_int32(int32_t *src) -{ - int32_t *src_end, *dst; -#ifdef USE_IRAM - /* copy to IRAM before converting data */ - dst = (int32_t *)input_buffer + PCM_SAMP_PER_CHUNK; - src_end = dst + PCM_SAMP_PER_CHUNK; - - memcpy(dst, src, PCM_CHUNK_SIZE); - - src = dst; -#else - src_end = src + PCM_SAMP_PER_CHUNK; -#endif - - dst = (int32_t *)input_buffer; - - if (config.num_channels == 1) - { - /* - * |llllllllllllllll|rrrrrrrrrrrrrrrr| => - * |mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm| - */ - do - { - /* read 10 longs and write 10 longs */ - sample_to_int32_mono(&src, &dst); - sample_to_int32_mono(&src, &dst); - sample_to_int32_mono(&src, &dst); - sample_to_int32_mono(&src, &dst); - sample_to_int32_mono(&src, &dst); - sample_to_int32_mono(&src, &dst); - sample_to_int32_mono(&src, &dst); - sample_to_int32_mono(&src, &dst); - sample_to_int32_mono(&src, &dst); - sample_to_int32_mono(&src, &dst); - } - while(src < src_end); - - return; - } - else - { - /* - * |llllllllllllllll|rrrrrrrrrrrrrrrr| => - * |llllllllllllllllllllllllllllllll|rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr| - */ - do - { - /* read 10 longs and write 20 longs */ - sample_to_int32_stereo(&src, &dst); - sample_to_int32_stereo(&src, &dst); - sample_to_int32_stereo(&src, &dst); - sample_to_int32_stereo(&src, &dst); - sample_to_int32_stereo(&src, &dst); - sample_to_int32_stereo(&src, &dst); - sample_to_int32_stereo(&src, &dst); - sample_to_int32_stereo(&src, &dst); - sample_to_int32_stereo(&src, &dst); - sample_to_int32_stereo(&src, &dst); - } - while (src < src_end); - - return; - } -} /* chunk_to_int32 */ - -/* called very often - inline */ -static inline bool is_file_data_ok(struct enc_file_event_data *data) ICODE_ATTR; -static inline bool is_file_data_ok(struct enc_file_event_data *data) -{ - return data->rec_file >= 0 && (long)data->chunk->flags >= 0; -} /* is_file_data_ok */ - -/* called very often - inline */ -static inline bool on_write_chunk(struct enc_file_event_data *data) ICODE_ATTR; -static inline bool on_write_chunk(struct enc_file_event_data *data) -{ - if (!is_file_data_ok(data)) - return false; - - if (data->chunk->enc_data == NULL) - { -#ifdef ROCKBOX_HAS_LOGF - ci->logf("wvpk enc: NULL data"); -#endif - return true; - } - - /* update timestamp (block_index) */ - ((WavpackHeader *)data->chunk->enc_data)->block_index = - htole32(data->num_pcm_samples); - - if (ci->write(data->rec_file, data->chunk->enc_data, - data->chunk->enc_size) != (ssize_t)data->chunk->enc_size) - return false; - - data->num_pcm_samples += data->chunk->num_pcm; - return true; -} /* on_write_chunk */ - -static bool on_start_file(struct enc_file_event_data *data) -{ - if ((data->chunk->flags & CHUNKF_ERROR) || *data->filename == '\0') - return false; - - data->rec_file = ci->open(data->filename, O_RDWR|O_CREAT|O_TRUNC, 0666); - - if (data->rec_file < 0) - return false; - - /* reset sample count */ - data->num_pcm_samples = 0; - - /* write template headers */ - if (ci->write(data->rec_file, &wvpk_mdh, sizeof (wvpk_mdh)) - != sizeof (wvpk_mdh) || - ci->write(data->rec_file, &riff_header, sizeof (riff_header)) - != sizeof (riff_header)) - { - return false; - } - - data->new_enc_size += sizeof(wvpk_mdh) + sizeof(riff_header); - return true; -} /* on_start_file */ - -static bool on_end_file(struct enc_file_event_data *data) -{ - struct - { - WavpackMetadataHeader wpmdh; - struct riff_header rhdr; - WavpackHeader wph; - } __attribute__ ((packed)) h; - - uint32_t data_size; - - if (data->rec_file < 0) - return false; /* file already closed, nothing more we can do */ - - /* always _try_ to write the file header, even on error */ - - /* read template headers at start */ - if (ci->lseek(data->rec_file, 0, SEEK_SET) != 0 || - ci->read(data->rec_file, &h, sizeof (h)) != sizeof (h)) - return false; - - data_size = data->num_pcm_samples*config.num_channels*PCM_DEPTH_BYTES; - - /** "RIFF" header **/ - h.rhdr.riff_size = htole32(RIFF_FMT_HEADER_SIZE + - RIFF_FMT_DATA_SIZE + RIFF_DATA_HEADER_SIZE + data_size); - - /* format data */ - h.rhdr.num_channels = htole16(config.num_channels); - h.rhdr.sample_rate = htole32(config.sample_rate); - h.rhdr.byte_rate = htole32(config.sample_rate*config.num_channels* - PCM_DEPTH_BYTES); - h.rhdr.block_align = htole16(config.num_channels*PCM_DEPTH_BYTES); - - /* data header */ - h.rhdr.data_size = htole32(data_size); - - /** Wavpack header **/ - h.wph.ckSize = htole32(letoh32(h.wph.ckSize) + sizeof (h.wpmdh) - + sizeof (h.rhdr)); - h.wph.total_samples = htole32(data->num_pcm_samples); - - /* MDH|RIFF|WVPK => WVPK|MDH|RIFF */ - if (ci->lseek(data->rec_file, 0, SEEK_SET) - != 0 || - ci->write(data->rec_file, &h.wph, sizeof (h.wph)) - != sizeof (h.wph) || - ci->write(data->rec_file, &h.wpmdh, sizeof (h.wpmdh)) - != sizeof (h.wpmdh) || - ci->write(data->rec_file, &h.rhdr, sizeof (h.rhdr)) - != sizeof (h.rhdr) || - ci->close(data->rec_file) != 0 ) - { - return false; - } - - data->rec_file = -1; - - return true; -} /* on_end_file */ - -STATICIRAM void enc_events_callback(enum enc_events event, void *data) - ICODE_ATTR; -STATICIRAM void enc_events_callback(enum enc_events event, void *data) -{ - switch (event) - { - case ENC_WRITE_CHUNK: - if (on_write_chunk((struct enc_file_event_data *)data)) - return; - - break; - - case ENC_START_FILE: - /* write metadata header and RIFF header */ - if (on_start_file((struct enc_file_event_data *)data)) - return; - - break; - - case ENC_END_FILE: - if (on_end_file((struct enc_file_event_data *)data)) - return; - - break; - - default: - return; - } - - /* Something failed above. Signal error back to core. */ - ((struct enc_file_event_data *)data)->chunk->flags |= CHUNKF_ERROR; -} /* enc_events_callback */ - -static bool init_encoder(void) -{ - struct enc_inputs inputs; - struct enc_parameters params; - - codec_init(); - - if (ci->enc_get_inputs == NULL || - ci->enc_set_parameters == NULL || - ci->enc_get_chunk == NULL || - ci->enc_finish_chunk == NULL || - ci->enc_get_pcm_data == NULL || - ci->enc_unget_pcm_data == NULL ) - return false; - - ci->enc_get_inputs(&inputs); - - if (inputs.config->afmt != AFMT_WAVPACK) - return false; - - memset(&config, 0, sizeof (config)); - config.bits_per_sample = PCM_DEPTH_BITS; - config.bytes_per_sample = PCM_DEPTH_BYTES; - config.sample_rate = inputs.sample_rate; - config.num_channels = inputs.num_channels; - - wpc = WavpackOpenFileOutput (); - - if (!WavpackSetConfiguration(wpc, &config, -1)) - return false; - - err = 0; - - /* configure the buffer system */ - params.afmt = AFMT_WAVPACK; - input_size = PCM_CHUNK_SIZE*inputs.num_channels / 2; - data_size = 105*input_size / 100; - input_size *= 2; - input_step = input_size / 4; - params.chunk_size = data_size; - params.enc_sample_rate = inputs.sample_rate; - params.reserve_bytes = 0; - params.events_callback = enc_events_callback; - - ci->enc_set_parameters(¶ms); - - return true; -} /* init_encoder */ - -/* this is the codec entry point */ -enum codec_status codec_main(enum codec_entry_call_reason reason) -{ - if (reason == CODEC_LOAD) { - /* initialize params and config */ - if (!init_encoder()) - return CODEC_ERROR; - } - else if (reason == CODEC_UNLOAD) { - /* reset parameters to initial state */ - ci->enc_set_parameters(NULL); - } - - return CODEC_OK; -} - -/* this is called for each file to process */ -enum codec_status codec_run(void) -{ - /* main encoding loop */ - while(ci->get_command(NULL) != CODEC_ACTION_HALT) - { - uint8_t *src = (uint8_t *)ci->enc_get_pcm_data(PCM_CHUNK_SIZE); - struct enc_chunk_hdr *chunk; - bool abort_chunk; - uint8_t *dst; - uint8_t *src_end; - - if(src == NULL) - continue; - - chunk = ci->enc_get_chunk(); - - /* reset counts and pointer */ - chunk->enc_size = 0; - chunk->num_pcm = 0; - chunk->enc_data = NULL; - - dst = ENC_CHUNK_SKIP_HDR(dst, chunk); - - WavpackStartBlock(wpc, dst, dst + data_size); - - chunk_to_int32((uint32_t*)src); - src = input_buffer; - src_end = src + input_size; - - /* encode chunk in four steps yielding between each */ - do - { - abort_chunk = true; - if (WavpackPackSamples(wpc, (int32_t *)src, - PCM_SAMP_PER_CHUNK/4)) - { - chunk->num_pcm += PCM_SAMP_PER_CHUNK/4; - ci->yield(); - /* could've been stopped in some way */ - abort_chunk = chunk->flags & CHUNKF_ABORT; - } - - src += input_step; - } - while (!abort_chunk && src < src_end); - - if (!abort_chunk) - { - chunk->enc_data = dst; - if (chunk->num_pcm < PCM_SAMP_PER_CHUNK) - ci->enc_unget_pcm_data(PCM_CHUNK_SIZE - chunk->num_pcm*4); - /* finish the chunk and store chunk size info */ - chunk->enc_size = WavpackFinishBlock(wpc); - ci->enc_finish_chunk(); - } - } - - return CODEC_OK; -} diff --git a/apps/codecs/wma.c b/apps/codecs/wma.c deleted file mode 100755 index f9501ffad3..0000000000 --- a/apps/codecs/wma.c +++ /dev/null @@ -1,196 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2007 Dave Chapman - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ - -#include "codeclib.h" -#include "libasf/asf.h" -#include "libwma/wmadec.h" - -CODEC_HEADER - -/* NOTE: WMADecodeContext is 120152 bytes (on x86) */ -static WMADecodeContext wmadec; - -/* this is the codec entry point */ -enum codec_status codec_main(enum codec_entry_call_reason reason) -{ - if (reason == CODEC_LOAD) { - /* Generic codec initialisation */ - ci->configure(DSP_SET_SAMPLE_DEPTH, 29); - } - - return CODEC_OK; -} - -/* this is called for each file to process */ -enum codec_status codec_run(void) -{ - uint32_t elapsedtime; - asf_waveformatex_t wfx; - size_t resume_offset; - int i; - int wmares = 0; - int res = 0; - uint8_t* audiobuf; - int audiobufsize; - int packetlength = 0; - int errcount = 0; - intptr_t param; - - /* Remember the resume position - when the codec is opened, the - playback engine will reset it. */ - resume_offset = ci->id3->offset; - -restart_track: - - /* Proper reset of the decoder context. */ - memset(&wmadec, 0, sizeof(wmadec)); - - if (codec_init()) { - LOGF("WMA: Error initialising codec\n"); - return CODEC_ERROR; - } - - /* Copy the format metadata we've stored in the id3 TOC field. This - saves us from parsing it again here. */ - memcpy(&wfx, ci->id3->toc, sizeof(wfx)); - - ci->seek_buffer(ci->id3->first_frame_offset); - if (wma_decode_init(&wmadec,&wfx) < 0) { - LOGF("WMA: Unsupported or corrupt file\n"); - return CODEC_ERROR; - } - - if (resume_offset > ci->id3->first_frame_offset) - { - /* Get start of current packet */ - int packet_offset = (resume_offset - ci->id3->first_frame_offset) - % wfx.packet_size; - ci->seek_buffer(resume_offset - packet_offset); - elapsedtime = asf_get_timestamp(&i); - } - else - { - /* Now advance the file position to the first frame */ - ci->seek_buffer(ci->id3->first_frame_offset); - elapsedtime = 0; - } - - ci->set_elapsed(elapsedtime); - - resume_offset = 0; - ci->configure(DSP_SWITCH_FREQUENCY, wfx.rate); - ci->configure(DSP_SET_STEREO_MODE, wfx.channels == 1 ? - STEREO_MONO : STEREO_NONINTERLEAVED); - codec_set_replaygain(ci->id3); - - /* The main decoding loop */ - while (res >= 0) - { - enum codec_command_action action = ci->get_command(¶m); - - if (action == CODEC_ACTION_HALT) - break; - - /* Deal with any pending seek requests */ - if (action == CODEC_ACTION_SEEK_TIME) { - - /*flush the wma decoder state*/ - wmadec.last_superframe_len = 0; - wmadec.last_bitoffset = 0; - - /*zero the frame out buffer so we don't overlap with a - stale samples*/ - memset((*(wmadec.frame_out)), 0, - sizeof(fixed32) * MAX_CHANNELS * BLOCK_MAX_SIZE * 2); - - if (param == 0) { - ci->set_elapsed(0); - ci->seek_complete(); - goto restart_track; /* Pretend you never saw this... */ - } - - elapsedtime = asf_seek(param, &wfx); - if (elapsedtime < 1){ - ci->set_elapsed(0); - ci->seek_complete(); - break; - } - /*DEBUGF("Seek returned %d\n", (int)elapsedtime);*/ - - ci->set_elapsed(elapsedtime); - ci->seek_complete(); - } - errcount = 0; -new_packet: - res = asf_read_packet(&audiobuf, &audiobufsize, &packetlength, &wfx); - - if (res < 0) { - /* We'll try to recover from a parse error a certain number of - * times. If we succeed, the error counter will be reset. - */ - - if (res == ASF_ERROR_EOF) { - /* File ended - not an error */ - break; - } - - errcount++; - DEBUGF("read_packet error %d, errcount %d\n",wmares, errcount); - if (errcount > 5) { - return CODEC_ERROR; - } else { - ci->advance_buffer(packetlength); - goto new_packet; - } - } else if (res > 0) { - wma_decode_superframe_init(&wmadec, audiobuf, audiobufsize); - - for (i=0; i < wmadec.nb_frames; i++) - { - wmares = wma_decode_superframe_frame(&wmadec, - audiobuf, audiobufsize); - - ci->yield (); - - if (wmares < 0) { - /* Do the above, but for errors in decode. */ - errcount++; - DEBUGF("WMA decode error %d, errcount %d\n",wmares, errcount); - if (errcount > 5) { - return CODEC_ERROR; - } else { - ci->advance_buffer(packetlength); - goto new_packet; - } - } else if (wmares > 0) { - ci->pcmbuf_insert((*wmadec.frame_out)[0], (*wmadec.frame_out)[1], wmares); - elapsedtime += (wmares*10)/(wfx.rate/100); - ci->set_elapsed(elapsedtime); - } - } - } - - ci->advance_buffer(packetlength); - } - - /*LOGF("WMA: Decoded %ld samples\n",elapsedtime*wfx.rate/1000);*/ - return CODEC_OK; -} diff --git a/apps/codecs/wmapro.c b/apps/codecs/wmapro.c deleted file mode 100644 index bab3b5a027..0000000000 --- a/apps/codecs/wmapro.c +++ /dev/null @@ -1,152 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2010 Mohamed Tarek - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ - -#include "codeclib.h" -#include "libasf/asf.h" -#include "libwmapro/wmaprodec.h" - -CODEC_HEADER - -static int32_t *dec[2]; /* pointers to the output buffers in WMAProDecodeCtx in - wmaprodec.c */ - - -/* this is the codec entry point */ -enum codec_status codec_main(enum codec_entry_call_reason reason) -{ - if (reason == CODEC_LOAD) { - /* Generic codec initialisation */ - ci->configure(DSP_SET_SAMPLE_DEPTH, WMAPRO_DSP_SAMPLE_DEPTH); - } - - return CODEC_OK; -} - -/* this is called for each file to process */ -enum codec_status codec_run(void) -{ - uint32_t elapsedtime; - asf_waveformatex_t wfx; /* Holds the stream properties */ - int res; /* Return values from asf_read_packet() and decode_packet() */ - uint8_t* audiobuf; /* Pointer to the payload of one wma pro packet */ - int audiobufsize; /* Payload size */ - int packetlength = 0; /* Logical packet size (minus the header size) */ - int outlen = 0; /* Number of bytes written to the output buffer */ - int pktcnt = 0; /* Count of the packets played */ - uint8_t *data; /* Pointer to decoder input buffer */ - int size; /* Size of the input frame to the decoder */ - intptr_t param; - -restart_track: - if (codec_init()) { - LOGF("(WMA PRO) Error: Error initialising codec\n"); - return CODEC_ERROR; - } - - /* Copy the format metadata we've stored in the id3 TOC field. This - saves us from parsing it again here. */ - memcpy(&wfx, ci->id3->toc, sizeof(wfx)); - - ci->configure(DSP_SWITCH_FREQUENCY, wfx.rate); - ci->configure(DSP_SET_STEREO_MODE, wfx.channels == 1 ? - STEREO_MONO : STEREO_NONINTERLEAVED); - codec_set_replaygain(ci->id3); - - if (decode_init(&wfx) < 0) { - LOGF("(WMA PRO) Error: Unsupported or corrupt file\n"); - return CODEC_ERROR; - } - - /* Now advance the file position to the first frame */ - ci->seek_buffer(ci->id3->first_frame_offset); - - elapsedtime = 0; - ci->set_elapsed(0); - - /* The main decoding loop */ - - while (pktcnt < wfx.numpackets) - { - enum codec_command_action action = ci->get_command(¶m); - - if (action == CODEC_ACTION_HALT) - break; - - /* Deal with any pending seek requests */ - if (action == CODEC_ACTION_SEEK_TIME) { - if (param == 0) { - ci->set_elapsed(0); - ci->seek_complete(); - goto restart_track; /* Pretend you never saw this... */ - } - - elapsedtime = asf_seek(param, &wfx); - if (elapsedtime < 1){ - ci->set_elapsed(0); - ci->seek_complete(); - break; - } - - ci->set_elapsed(elapsedtime); - ci->seek_complete(); - } - - res = asf_read_packet(&audiobuf, &audiobufsize, &packetlength, &wfx); - - if (res < 0) { - LOGF("(WMA PRO) Warning: asf_read_packet returned %d", res); - return CODEC_ERROR; - } else { - data = audiobuf; - size = audiobufsize; - pktcnt++; - - /* We now loop on the packet, decoding and outputting the subframes - * one-by-one. For more information about how wma pro structures its - * audio frames, see libwmapro/wmaprodec.c */ - while(size > 0) - { - res = decode_packet(&wfx, dec, &outlen, data, size); - if(res < 0) { - LOGF("(WMA PRO) Error: decode_packet returned %d", res); - return CODEC_ERROR; - } - data += res; - size -= res; - if(outlen) { - ci->yield (); - outlen /= (wfx.channels); - ci->pcmbuf_insert(dec[0], dec[1], outlen ); - elapsedtime += outlen*10/(wfx.rate/100); - ci->set_elapsed(elapsedtime); - ci->yield (); - } - } - - } - - /* Advance to the next logical packet */ - ci->advance_buffer(packetlength); - } - - return CODEC_OK; -} - diff --git a/apps/codecs/wmavoice.c b/apps/codecs/wmavoice.c deleted file mode 100644 index 9cf5a49f1a..0000000000 --- a/apps/codecs/wmavoice.c +++ /dev/null @@ -1,195 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2010 Mohamed Tarek - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ - -#include "codeclib.h" -#include "libasf/asf.h" -#include "libwmavoice/wmavoice.h" - -CODEC_HEADER - -static AVCodecContext avctx; -static AVPacket avpkt; - -#define MAX_FRAMES 3 /*maximum number of frames per superframe*/ -#define MAX_FRAMESIZE 160 /* maximum number of samples per frame */ -#define BUFSIZE MAX_FRAMES*MAX_FRAMESIZE -static int32_t decoded[BUFSIZE] IBSS_ATTR; - - -/* This function initialises AVCodecContext with the data needed for the wmapro - * decoder to work. The required data is taken from asf_waveformatex_t because that's - * what the rockbox asf metadata parser fill/work with. In the future, when the - * codec is being optimised for on-target playback this function should not be needed. */ -static void init_codec_ctx(AVCodecContext *avctx, asf_waveformatex_t *wfx) -{ - /* Copy the extra-data */ - avctx->extradata_size = wfx->datalen; - avctx->extradata = (uint8_t *)malloc(wfx->datalen*sizeof(uint8_t)); - memcpy(avctx->extradata, wfx->data, wfx->datalen*sizeof(uint8_t)); - - avctx->block_align = wfx->blockalign; - avctx->sample_rate = wfx->rate; - avctx->channels = wfx->channels; - -} - -/* this is the codec entry point */ -enum codec_status codec_main(enum codec_entry_call_reason reason) -{ - if (reason == CODEC_LOAD) { - /* Generic codec initialisation */ - ci->configure(DSP_SET_SAMPLE_DEPTH, 31); - } - - return CODEC_OK; -} - -/* this is called for each file to process */ -enum codec_status codec_run(void) -{ - uint32_t elapsedtime; - asf_waveformatex_t wfx; /* Holds the stream properties */ - size_t resume_offset; - int res; /* Return values from asf_read_packet() and decode_packet() */ - uint8_t* audiobuf; /* Pointer to the payload of one wma pro packet */ - int audiobufsize; /* Payload size */ - int packetlength = 0; /* Logical packet size (minus the header size) */ - int outlen = 0; /* Number of bytes written to the output buffer */ - int pktcnt = 0; /* Count of the packets played */ - intptr_t param; - - /* Remember the resume position */ - resume_offset = ci->id3->offset; -restart_track: - if (codec_init()) { - LOGF("(WMA Voice) Error: Error initialising codec\n"); - return CODEC_ERROR; - } - - /* Copy the format metadata we've stored in the id3 TOC field. This - saves us from parsing it again here. */ - memcpy(&wfx, ci->id3->toc, sizeof(wfx)); - memset(&avctx, 0, sizeof(AVCodecContext)); - memset(&avpkt, 0, sizeof(AVPacket)); - - ci->configure(DSP_SWITCH_FREQUENCY, wfx.rate); - ci->configure(DSP_SET_STEREO_MODE, wfx.channels == 1 ? - STEREO_MONO : STEREO_INTERLEAVED); - codec_set_replaygain(ci->id3); - - ci->seek_buffer(0); - - /* Initialise the AVCodecContext */ - init_codec_ctx(&avctx, &wfx); - - if (wmavoice_decode_init(&avctx) < 0) { - LOGF("(WMA Voice) Error: Unsupported or corrupt file\n"); - return CODEC_ERROR; - } - - /* Now advance the file position to the first frame */ - ci->seek_buffer(ci->id3->first_frame_offset); - - elapsedtime = 0; - ci->set_elapsed(0); - - resume_offset = 0; - - /* The main decoding loop */ - - while (pktcnt < wfx.numpackets) - { - enum codec_command_action action = ci->get_command(¶m); - - if (action == CODEC_ACTION_HALT) - break; - - /* Deal with any pending seek requests */ - if (action == CODEC_ACTION_SEEK_TIME) { - ci->set_elapsed(param); - - if (param == 0) { - ci->set_elapsed(0); - ci->seek_complete(); - goto restart_track; /* Pretend you never saw this... */ - } - - elapsedtime = asf_seek(param, &wfx); - if (elapsedtime < 1){ - ci->set_elapsed(0); - ci->seek_complete(); - goto next_track; - } - - ci->set_elapsed(elapsedtime); - ci->seek_complete(); - } - -new_packet: - res = asf_read_packet(&audiobuf, &audiobufsize, &packetlength, &wfx); - - if (res < 0) { - LOGF("(WMA Voice) read_packet error %d\n",res); - return CODEC_ERROR; - } else { - avpkt.data = audiobuf; - avpkt.size = audiobufsize; - pktcnt++; - - while(avpkt.size > 0) - { - /* wmavoice_decode_packet checks for the output buffer size to - avoid overflows */ - outlen = BUFSIZE*sizeof(int32_t); - - res = wmavoice_decode_packet(&avctx, decoded, &outlen, &avpkt); - if(res < 0) { - LOGF("(WMA Voice) Error: decode_packet returned %d", res); - if(res == ERROR_WMAPRO_IN_WMAVOICE){ - /* Just skip this packet */ - ci->advance_buffer(packetlength); - goto new_packet; - } - else { - return CODEC_ERROR; - } - } - avpkt.data += res; - avpkt.size -= res; - if(outlen) { - ci->yield (); - outlen /= sizeof(int32_t); - ci->pcmbuf_insert(decoded, NULL, outlen); - elapsedtime += outlen*10/(wfx.rate/100); - ci->set_elapsed(elapsedtime); - ci->yield (); - } - } - - } - - /* Advance to the next logical packet */ - ci->advance_buffer(packetlength); - } - - return CODEC_OK; -} - diff --git a/apps/plugins/plugins.make b/apps/plugins/plugins.make index 27bc69f1ca..12344ae590 100644 --- a/apps/plugins/plugins.make +++ b/apps/plugins/plugins.make @@ -87,7 +87,7 @@ $(BUILDDIR)/credits.raw credits.raw: $(DOCSDIR)/CREDITS $(call PRINTS,Create credits.raw)perl $(APPSDIR)/plugins/credits.pl < $< > $(BUILDDIR)/$(@F) # special dependencies -$(BUILDDIR)/apps/plugins/wav2wv.rock: $(BUILDDIR)/apps/codecs/libwavpack.a $(PLUGIN_LIBS) +$(BUILDDIR)/apps/plugins/wav2wv.rock: $(RBCODEC_BLD)/codecs/libwavpack.a $(PLUGIN_LIBS) # Do not use '-ffunction-sections' and '-fdata-sections' when compiling sdl-sim ifeq ($(findstring sdl-sim, $(APP_TYPE)), sdl-sim) diff --git a/firmware/target/hosted/ypr0/ypr0.make b/firmware/target/hosted/ypr0/ypr0.make index d0f4cb7fe2..67ff326de0 100644 --- a/firmware/target/hosted/ypr0/ypr0.make +++ b/firmware/target/hosted/ypr0/ypr0.make @@ -16,7 +16,7 @@ SIMFLAGS += $(INCLUDES) $(DEFINES) -DHAVE_CONFIG_H $(GCCOPTS) $(BUILDDIR)/rockbox.elf : $$(OBJ) $(FIRMLIB) $(VOICESPEEXLIB) $(CORE_LIBS) $(call PRINTS,LD $(@F))$(CC) $(GCCOPTS) -Os -o $@ $(OBJ) \ -L$(BUILDDIR)/firmware -lfirmware \ - -L$(BUILDDIR)/apps/codecs $(call a2lnk, $(VOICESPEEXLIB)) \ + -L$(RBCODEC_BLD)/codecs $(call a2lnk, $(VOICESPEEXLIB)) \ -L$(BUILDDIR)/lib $(call a2lnk,$(CORE_LIBS)) \ $(LDOPTS) $(GLOBAL_LDOPTS) -Wl,-Map,$(BUILDDIR)/rockbox.map diff --git a/lib/rbcodec/codecs/SOURCES b/lib/rbcodec/codecs/SOURCES new file mode 100644 index 0000000000..db6e82c75f --- /dev/null +++ b/lib/rbcodec/codecs/SOURCES @@ -0,0 +1,54 @@ +/* decoders */ + +vorbis.c +mpa.c +flac.c +wav.c +a52.c +wavpack.c +#ifndef RB_PROFILE +alac.c +#endif +cook.c +raac.c +a52_rm.c +atrac3_rm.c +atrac3_oma.c +mpc.c +wma.c +sid.c +ape.c +asap.c +aac.c +spc.c +mod.c +shorten.c +aiff.c +speex.c +adx.c +smaf.c +au.c +vox.c +wav64.c +tta.c +wmapro.c +ay.c +gbs.c +hes.c +nsf.c +sgc.c +vgm.c +#if MEMORYSIZE > 2 +kss.c +#endif + +#ifdef HAVE_RECORDING + +/* encoders */ + +aiff_enc.c +mp3_enc.c +wav_enc.c +wavpack_enc.c + +#endif /* HAVE_RECORDING */ diff --git a/lib/rbcodec/codecs/a52.c b/lib/rbcodec/codecs/a52.c new file mode 100644 index 0000000000..cb6e66dd05 --- /dev/null +++ b/lib/rbcodec/codecs/a52.c @@ -0,0 +1,192 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2005 Dave Chapman + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include "codeclib.h" +#include /* Needed by a52.h */ +#include +#include + +CODEC_HEADER + +#define BUFFER_SIZE 4096 + +#define A52_SAMPLESPERFRAME (6*256) + +static a52_state_t *state; +static unsigned long samplesdone; +static unsigned long frequency; + +/* used outside liba52 */ +static uint8_t buf[3840] IBSS_ATTR; + +static inline void output_audio(sample_t *samples) +{ + ci->yield(); + ci->pcmbuf_insert(&samples[0], &samples[256], 256); +} + +static void a52_decode_data(uint8_t *start, uint8_t *end) +{ + static uint8_t *bufptr = buf; + static uint8_t *bufpos = buf + 7; + /* + * sample_rate and flags are static because this routine could + * exit between the a52_syncinfo() and the ao_setup(), and we want + * to have the same values when we get back ! + */ + static int sample_rate; + static int flags; + int bit_rate; + int len; + + while (1) { + len = end - start; + if (!len) + break; + if (len > bufpos - bufptr) + len = bufpos - bufptr; + memcpy(bufptr, start, len); + bufptr += len; + start += len; + if (bufptr == bufpos) { + if (bufpos == buf + 7) { + int length; + + length = a52_syncinfo(buf, &flags, &sample_rate, &bit_rate); + if (!length) { + //DEBUGF("skip\n"); + for (bufptr = buf; bufptr < buf + 6; bufptr++) + bufptr[0] = bufptr[1]; + continue; + } + bufpos = buf + length; + } else { + /* Unity gain is 1 << 26, and we want to end up on 28 bits + of precision instead of the default 30. + */ + level_t level = 1 << 24; + sample_t bias = 0; + int i; + + /* This is the configuration for the downmixing: */ + flags = A52_STEREO | A52_ADJUST_LEVEL; + + if (a52_frame(state, buf, &flags, &level, bias)) + goto error; + a52_dynrng(state, NULL, NULL); + frequency = sample_rate; + + /* An A52 frame consists of 6 blocks of 256 samples + So we decode and output them one block at a time */ + for (i = 0; i < 6; i++) { + if (a52_block(state)) + goto error; + output_audio(a52_samples(state)); + samplesdone += 256; + } + ci->set_elapsed(samplesdone/(frequency/1000)); + bufptr = buf; + bufpos = buf + 7; + continue; + error: + //logf("Error decoding A52 stream\n"); + bufptr = buf; + bufpos = buf + 7; + } + } + } +} + +/* this is the codec entry point */ +enum codec_status codec_main(enum codec_entry_call_reason reason) +{ + if (reason == CODEC_LOAD) { + /* Generic codec initialisation */ + ci->configure(DSP_SET_STEREO_MODE, STEREO_NONINTERLEAVED); + ci->configure(DSP_SET_SAMPLE_DEPTH, 28); + } + else if (reason == CODEC_UNLOAD) { + if (state) + a52_free(state); + } + + return CODEC_OK; +} + +/* this is called for each file to process */ +enum codec_status codec_run(void) +{ + size_t n; + unsigned char *filebuf; + int sample_loc; + intptr_t param; + + if (codec_init()) + return CODEC_ERROR; + + ci->configure(DSP_SWITCH_FREQUENCY, ci->id3->frequency); + codec_set_replaygain(ci->id3); + + /* Intialise the A52 decoder and check for success */ + state = a52_init(0); + + samplesdone = 0; + + /* The main decoding loop */ + if (ci->id3->offset) { + if (ci->seek_buffer(ci->id3->offset)) { + samplesdone = (ci->id3->offset / ci->id3->bytesperframe) * + A52_SAMPLESPERFRAME; + ci->set_elapsed(samplesdone/(ci->id3->frequency / 1000)); + } + } + else { + ci->seek_buffer(ci->id3->first_frame_offset); + ci->set_elapsed(0); + } + + while (1) { + enum codec_command_action action = ci->get_command(¶m); + + if (action == CODEC_ACTION_HALT) + break; + + if (action == CODEC_ACTION_SEEK_TIME) { + sample_loc = param/1000 * ci->id3->frequency; + + if (ci->seek_buffer((sample_loc/A52_SAMPLESPERFRAME)*ci->id3->bytesperframe)) { + samplesdone = sample_loc; + ci->set_elapsed(samplesdone/(ci->id3->frequency/1000)); + } + ci->seek_complete(); + } + + filebuf = ci->request_buffer(&n, BUFFER_SIZE); + + if (n == 0) /* End of Stream */ + break; + + a52_decode_data(filebuf, filebuf + n); + ci->advance_buffer(n); + } + + return CODEC_OK; +} diff --git a/lib/rbcodec/codecs/a52_rm.c b/lib/rbcodec/codecs/a52_rm.c new file mode 100644 index 0000000000..2db126f5b1 --- /dev/null +++ b/lib/rbcodec/codecs/a52_rm.c @@ -0,0 +1,227 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2009 Mohamed Tarek + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include "codeclib.h" +#include +#include /* Needed by a52.h */ +#include +#include + +CODEC_HEADER + +#define BUFFER_SIZE 4096 + +#define A52_SAMPLESPERFRAME (6*256) + +static a52_state_t *state; +static unsigned long samplesdone; +static unsigned long frequency; +static RMContext rmctx; +static RMPacket pkt; + +static void init_rm(RMContext *rmctx) +{ + memcpy(rmctx, (void*)(( (intptr_t)ci->id3->id3v2buf + 3 ) &~ 3), sizeof(RMContext)); +} + +/* used outside liba52 */ +static uint8_t buf[3840] IBSS_ATTR; + +/* The following two functions, a52_decode_data and output_audio are taken from a52.c */ +static inline void output_audio(sample_t *samples) +{ + ci->yield(); + ci->pcmbuf_insert(&samples[0], &samples[256], 256); +} + +static void a52_decode_data(uint8_t *start, uint8_t *end) +{ + static uint8_t *bufptr = buf; + static uint8_t *bufpos = buf + 7; + /* + * sample_rate and flags are static because this routine could + * exit between the a52_syncinfo() and the ao_setup(), and we want + * to have the same values when we get back ! + */ + static int sample_rate; + static int flags; + int bit_rate; + int len; + + while (1) { + len = end - start; + if (!len) + break; + if (len > bufpos - bufptr) + len = bufpos - bufptr; + memcpy(bufptr, start, len); + bufptr += len; + start += len; + if (bufptr == bufpos) { + if (bufpos == buf + 7) { + int length; + + length = a52_syncinfo(buf, &flags, &sample_rate, &bit_rate); + if (!length) { + //DEBUGF("skip\n"); + for (bufptr = buf; bufptr < buf + 6; bufptr++) + bufptr[0] = bufptr[1]; + continue; + } + bufpos = buf + length; + } else { + /* Unity gain is 1 << 26, and we want to end up on 28 bits + of precision instead of the default 30. + */ + level_t level = 1 << 24; + sample_t bias = 0; + int i; + + /* This is the configuration for the downmixing: */ + flags = A52_STEREO | A52_ADJUST_LEVEL; + + if (a52_frame(state, buf, &flags, &level, bias)) + goto error; + a52_dynrng(state, NULL, NULL); + frequency = sample_rate; + + /* An A52 frame consists of 6 blocks of 256 samples + So we decode and output them one block at a time */ + for (i = 0; i < 6; i++) { + if (a52_block(state)) + goto error; + output_audio(a52_samples(state)); + samplesdone += 256; + } + ci->set_elapsed(samplesdone/(frequency/1000)); + bufptr = buf; + bufpos = buf + 7; + continue; + error: + //logf("Error decoding A52 stream\n"); + bufptr = buf; + bufpos = buf + 7; + } + } + } +} + +/* this is the codec entry point */ +enum codec_status codec_main(enum codec_entry_call_reason reason) +{ + if (reason == CODEC_LOAD) { + /* Generic codec initialisation */ + ci->configure(DSP_SET_STEREO_MODE, STEREO_NONINTERLEAVED); + ci->configure(DSP_SET_SAMPLE_DEPTH, 28); + } + else if (reason == CODEC_UNLOAD) { + if (state) + a52_free(state); + } + + return CODEC_OK; +} + +/* this is called for each file to process */ +enum codec_status codec_run(void) +{ + size_t n; + uint8_t *filebuf; + int consumed, packet_offset; + int playback_on = -1; + size_t resume_offset; + intptr_t param; + enum codec_command_action action = CODEC_ACTION_NULL; + + if (codec_init()) { + return CODEC_ERROR; + } + + resume_offset = ci->id3->offset; + + ci->configure(DSP_SWITCH_FREQUENCY, ci->id3->frequency); + codec_set_replaygain(ci->id3); + + ci->seek_buffer(ci->id3->first_frame_offset); + + /* Intializations */ + state = a52_init(0); + ci->memset(&rmctx,0,sizeof(RMContext)); + ci->memset(&pkt,0,sizeof(RMPacket)); + init_rm(&rmctx); + + samplesdone = 0; + + /* check for a mid-track resume and force a seek time accordingly */ + if(resume_offset > rmctx.data_offset + DATA_HEADER_SIZE) { + resume_offset -= rmctx.data_offset + DATA_HEADER_SIZE; + /* put number of subpackets to skip in resume_offset */ + resume_offset /= (rmctx.block_align + PACKET_HEADER_SIZE); + param = (int)resume_offset * ((rmctx.block_align * 8 * 1000)/rmctx.bit_rate); + action = CODEC_ACTION_SEEK_TIME; + } + else { + /* Seek to the first packet */ + ci->set_elapsed(0); + ci->advance_buffer(rmctx.data_offset + DATA_HEADER_SIZE ); + } + + /* The main decoding loop */ + while((unsigned)rmctx.audio_pkt_cnt < rmctx.nb_packets) { + if (action == CODEC_ACTION_NULL) + action = ci->get_command(¶m); + + if (action == CODEC_ACTION_HALT) + break; + + if (action == CODEC_ACTION_SEEK_TIME) { + packet_offset = param / ((rmctx.block_align*8*1000)/rmctx.bit_rate); + ci->seek_buffer(rmctx.data_offset + DATA_HEADER_SIZE + + packet_offset*(rmctx.block_align + PACKET_HEADER_SIZE)); + rmctx.audio_pkt_cnt = packet_offset; + samplesdone = (rmctx.sample_rate/1000 * param); + ci->set_elapsed(samplesdone/(frequency/1000)); + ci->seek_complete(); + } + + action = CODEC_ACTION_NULL; + + filebuf = ci->request_buffer(&n, rmctx.block_align + PACKET_HEADER_SIZE); + consumed = rm_get_packet(&filebuf, &rmctx, &pkt); + + if(consumed < 0 && playback_on != 0) { + if(playback_on == -1) { + /* Error only if packet-parsing failed and playback hadn't started */ + DEBUGF("rm_get_packet failed\n"); + return CODEC_ERROR; + } + else { + break; + } + } + + playback_on = 1; + a52_decode_data(filebuf, filebuf + rmctx.block_align); + ci->advance_buffer(pkt.length); + } + + return CODEC_OK; +} diff --git a/lib/rbcodec/codecs/aac.c b/lib/rbcodec/codecs/aac.c new file mode 100644 index 0000000000..365dca804d --- /dev/null +++ b/lib/rbcodec/codecs/aac.c @@ -0,0 +1,297 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2005 Dave Chapman + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include "codeclib.h" +#include "libm4a/m4a.h" +#include "libfaad/common.h" +#include "libfaad/structs.h" +#include "libfaad/decoder.h" + +CODEC_HEADER + +/* The maximum buffer size handled by faad. 12 bytes are required by libfaad + * as headroom (see libfaad/bits.c). FAAD_BYTE_BUFFER_SIZE bytes are buffered + * for each frame. */ +#define FAAD_BYTE_BUFFER_SIZE (2048-12) + +/* this is the codec entry point */ +enum codec_status codec_main(enum codec_entry_call_reason reason) +{ + if (reason == CODEC_LOAD) { + /* Generic codec initialisation */ + ci->configure(DSP_SET_STEREO_MODE, STEREO_NONINTERLEAVED); + ci->configure(DSP_SET_SAMPLE_DEPTH, 29); + } + + return CODEC_OK; +} + +/* this is called for each file to process */ +enum codec_status codec_run(void) +{ + /* Note that when dealing with QuickTime/MPEG4 files, terminology is + * a bit confusing. Files with sound are split up in chunks, where + * each chunk contains one or more samples. Each sample in turn + * contains a number of "sound samples" (the kind you refer to with + * the sampling frequency). + */ + size_t n; + demux_res_t demux_res; + stream_t input_stream; + uint32_t sound_samples_done; + uint32_t elapsed_time; + int file_offset; + int framelength; + int lead_trim = 0; + unsigned int frame_samples; + unsigned int i; + unsigned char* buffer; + NeAACDecFrameInfo frame_info; + NeAACDecHandle decoder; + int err; + uint32_t seek_idx = 0; + uint32_t s = 0; + uint32_t sbr_fac = 1; + unsigned char c = 0; + void *ret; + intptr_t param; + bool empty_first_frame = false; + + /* Clean and initialize decoder structures */ + memset(&demux_res , 0, sizeof(demux_res)); + if (codec_init()) { + LOGF("FAAD: Codec init error\n"); + return CODEC_ERROR; + } + + file_offset = ci->id3->offset; + + ci->configure(DSP_SWITCH_FREQUENCY, ci->id3->frequency); + codec_set_replaygain(ci->id3); + + stream_create(&input_stream,ci); + + ci->seek_buffer(ci->id3->first_frame_offset); + + /* if qtmovie_read returns successfully, the stream is up to + * the movie data, which can be used directly by the decoder */ + if (!qtmovie_read(&input_stream, &demux_res)) { + LOGF("FAAD: File init error\n"); + return CODEC_ERROR; + } + + /* initialise the sound converter */ + decoder = NeAACDecOpen(); + + if (!decoder) { + LOGF("FAAD: Decode open error\n"); + return CODEC_ERROR; + } + + NeAACDecConfigurationPtr conf = NeAACDecGetCurrentConfiguration(decoder); + conf->outputFormat = FAAD_FMT_24BIT; /* irrelevant, we don't convert */ + NeAACDecSetConfiguration(decoder, conf); + + err = NeAACDecInit2(decoder, demux_res.codecdata, demux_res.codecdata_len, &s, &c); + if (err) { + LOGF("FAAD: DecInit: %d, %d\n", err, decoder->object_type); + return CODEC_ERROR; + } + +#ifdef SBR_DEC + /* Check for need of special handling for seek/resume and elapsed time. */ + if (ci->id3->needs_upsampling_correction) { + sbr_fac = 2; + } else { + sbr_fac = 1; + } +#endif + + i = 0; + + if (file_offset > 0) { + /* Resume the desired (byte) position. Important: When resuming SBR + * upsampling files the resulting sound_samples_done must be expanded + * by a factor of 2. This is done via using sbr_fac. */ + if (m4a_seek_raw(&demux_res, &input_stream, file_offset, + &sound_samples_done, (int*) &i)) { + sound_samples_done *= sbr_fac; + } else { + sound_samples_done = 0; + } + NeAACDecPostSeekReset(decoder, i); + } else { + sound_samples_done = 0; + } + + elapsed_time = (sound_samples_done * 10) / (ci->id3->frequency / 100); + ci->set_elapsed(elapsed_time); + + if (i == 0) + { + lead_trim = ci->id3->lead_trim; + } + + /* The main decoding loop */ + while (i < demux_res.num_sample_byte_sizes) { + enum codec_command_action action = ci->get_command(¶m); + + if (action == CODEC_ACTION_HALT) + break; + + /* Deal with any pending seek requests */ + if (action == CODEC_ACTION_SEEK_TIME) { + /* Seek to the desired time position. Important: When seeking in SBR + * upsampling files the seek_time must be divided by 2 when calling + * m4a_seek and the resulting sound_samples_done must be expanded + * by a factor 2. This is done via using sbr_fac. */ + if (m4a_seek(&demux_res, &input_stream, + (param/10/sbr_fac)*(ci->id3->frequency/100), + &sound_samples_done, (int*) &i)) { + sound_samples_done *= sbr_fac; + elapsed_time = (sound_samples_done * 10) / (ci->id3->frequency / 100); + ci->set_elapsed(elapsed_time); + seek_idx = 0; + + if (i == 0) + { + lead_trim = ci->id3->lead_trim; + } + } + NeAACDecPostSeekReset(decoder, i); + ci->seek_complete(); + } + + /* There can be gaps between chunks, so skip ahead if needed. It + * doesn't seem to happen much, but it probably means that a + * "proper" file can have chunks out of order. Why one would want + * that an good question (but files with gaps do exist, so who + * knows?), so we don't support that - for now, at least. + */ + file_offset = m4a_check_sample_offset(&demux_res, i, &seek_idx); + + if (file_offset > ci->curpos) + { + ci->advance_buffer(file_offset - ci->curpos); + } + else if (file_offset == 0) + { + LOGF("AAC: get_sample_offset error\n"); + return CODEC_ERROR; + } + + /* Request the required number of bytes from the input buffer */ + buffer=ci->request_buffer(&n, FAAD_BYTE_BUFFER_SIZE); + + /* Decode one block - returned samples will be host-endian */ + ret = NeAACDecDecode(decoder, &frame_info, buffer, n); + + /* NeAACDecDecode may sometimes return NULL without setting error. */ + if (ret == NULL || frame_info.error > 0) { + LOGF("FAAD: decode error '%s'\n", NeAACDecGetErrorMessage(frame_info.error)); + return CODEC_ERROR; + } + + /* Advance codec buffer (no need to call set_offset because of this) */ + ci->advance_buffer(frame_info.bytesconsumed); + + /* Output the audio */ + ci->yield(); + + frame_samples = frame_info.samples >> 1; + + if (empty_first_frame) + { + /* Remove the first frame from lead_trim, under the assumption + * that it had the same size as this frame + */ + empty_first_frame = false; + lead_trim -= frame_samples; + + if (lead_trim < 0) + { + lead_trim = 0; + } + } + + /* Gather number of samples for the decoded frame. */ + framelength = frame_samples - lead_trim; + + if (i == demux_res.num_sample_byte_sizes - 1) + { + // Size of the last frame + const uint32_t sample_duration = (demux_res.num_time_to_samples > 0) ? + demux_res.time_to_sample[demux_res.num_time_to_samples - 1].sample_duration : + frame_samples; + + /* Currently limited to at most one frame of tail_trim. + * Seems to be enough. + */ + if (ci->id3->tail_trim == 0 && sample_duration < frame_samples) + { + /* Subtract lead_trim just in case we decode a file with only + * one audio frame with actual data (lead_trim is usually zero + * here). + */ + framelength = sample_duration - lead_trim; + } + else + { + framelength -= ci->id3->tail_trim; + } + } + + if (framelength > 0) + { + ci->pcmbuf_insert(&decoder->time_out[0][lead_trim], + &decoder->time_out[1][lead_trim], + framelength); + sound_samples_done += framelength; + /* Update the elapsed-time indicator */ + elapsed_time = ((uint64_t) sound_samples_done * 1000) / + ci->id3->frequency; + ci->set_elapsed(elapsed_time); + } + + if (lead_trim > 0) + { + /* frame_info.samples can be 0 for frame 0. We still want to + * remove it from lead_trim, so do that during frame 1. + */ + if (0 == i && 0 == frame_info.samples) + { + empty_first_frame = true; + } + + lead_trim -= frame_samples; + + if (lead_trim < 0) + { + lead_trim = 0; + } + } + + ++i; + } + + LOGF("AAC: Decoded %lu samples\n", (unsigned long)sound_samples_done); + return CODEC_OK; +} diff --git a/lib/rbcodec/codecs/adx.c b/lib/rbcodec/codecs/adx.c new file mode 100644 index 0000000000..0c67fc8d6e --- /dev/null +++ b/lib/rbcodec/codecs/adx.c @@ -0,0 +1,404 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * + * Copyright (C) 2006-2008 Adam Gashlin (hcs) + * Copyright (C) 2006 Jens Arnold + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include +#include "codeclib.h" +#include "inttypes.h" +#include "math.h" +#include "lib/fixedpoint.h" + +CODEC_HEADER + +/* Maximum number of bytes to process in one iteration */ +#define WAV_CHUNK_SIZE (1024*2) + +/* Number of times to loop looped tracks when repeat is disabled */ +#define LOOP_TIMES 2 + +/* Length of fade-out for looped tracks (milliseconds) */ +#define FADE_LENGTH 10000L + +/* Default high pass filter cutoff frequency is 500 Hz. + * Others can be set, but the default is nearly always used, + * and there is no way to determine if another was used, anyway. + */ +static const long cutoff = 500; + +static int16_t samples[WAV_CHUNK_SIZE] IBSS_ATTR; + +/* this is the codec entry point */ +enum codec_status codec_main(enum codec_entry_call_reason reason) +{ + if (reason == CODEC_LOAD) { + /* Generic codec initialisation */ + /* we only render 16 bits */ + ci->configure(DSP_SET_SAMPLE_DEPTH, 16); + } + + return CODEC_OK; +} + +/* this is called for each file to process */ +enum codec_status codec_run(void) +{ + int channels; + int sampleswritten, i; + uint8_t *buf; + int32_t ch1_1, ch1_2, ch2_1, ch2_2; /* ADPCM history */ + size_t n; + int endofstream; /* end of stream flag */ + uint32_t avgbytespersec; + int looping; /* looping flag */ + int loop_count; /* number of loops done so far */ + int fade_count; /* countdown for fadeout */ + int fade_frames; /* length of fade in frames */ + off_t start_adr, end_adr; /* loop points */ + off_t chanstart, bufoff; + /*long coef1=0x7298L,coef2=-0x3350L;*/ + long coef1, coef2; + intptr_t param; + + DEBUGF("ADX: next_track\n"); + if (codec_init()) { + return CODEC_ERROR; + } + DEBUGF("ADX: after init\n"); + + /* init history */ + ch1_1=ch1_2=ch2_1=ch2_2=0; + + codec_set_replaygain(ci->id3); + + /* Get header */ + DEBUGF("ADX: request initial buffer\n"); + ci->seek_buffer(0); + buf = ci->request_buffer(&n, 0x38); + if (!buf || n < 0x38) { + return CODEC_ERROR; + } + bufoff = 0; + DEBUGF("ADX: read size = %lx\n",(unsigned long)n); + + /* Get file header for starting offset, channel count */ + + chanstart = ((buf[2] << 8) | buf[3]) + 4; + channels = buf[7]; + + /* useful for seeking and reporting current playback position */ + avgbytespersec = ci->id3->frequency * 18 * channels / 32; + DEBUGF("avgbytespersec=%ld\n",(unsigned long)avgbytespersec); + + /* calculate filter coefficients */ + + /** + * A simple table of these coefficients would be nice, but + * some very odd frequencies are used and if I'm going to + * interpolate I might as well just go all the way and + * calclate them precisely. + * Speed is not an issue as this only needs to be done once per file. + */ + { + const int64_t big28 = 0x10000000LL; + const int64_t big32 = 0x100000000LL; + int64_t frequency = ci->id3->frequency; + int64_t phasemultiple = cutoff*big32/frequency; + + long z; + int64_t a; + const int64_t b = (M_SQRT2*big28)-big28; + int64_t c; + int64_t d; + + fp_sincos((unsigned long)phasemultiple,&z); + + a = (M_SQRT2*big28) - (z >> 3); + + /** + * In the long passed to fsqrt there are only 4 nonfractional bits, + * which is sufficient here, but this is the only reason why I don't + * use 32 fractional bits everywhere. + */ + d = fp_sqrt((a+b)*(a-b)/big28,28); + c = (a-d)*big28/b; + + coef1 = (c*8192) >> 28; + coef2 = (c*c/big28*-4096) >> 28; + DEBUGF("ADX: samprate=%ld ",(long)frequency); + DEBUGF("coef1 %04x ",(unsigned int)(coef1*4)); + DEBUGF("coef2 %04x\n",(unsigned int)(coef2*-4)); + } + + /* Get loop data */ + + looping = 0; start_adr = 0; end_adr = 0; + if (!memcmp(buf+0x10,"\x01\xF4\x03",3)) { + /* Soul Calibur 2 style (type 03) */ + DEBUGF("ADX: type 03 found\n"); + /* check if header is too small for loop data */ + if (chanstart-6 < 0x2c) looping=0; + else { + looping = (buf[0x18]) || + (buf[0x19]) || + (buf[0x1a]) || + (buf[0x1b]); + end_adr = (buf[0x28]<<24) | + (buf[0x29]<<16) | + (buf[0x2a]<<8) | + (buf[0x2b]); + + start_adr = ( + (buf[0x1c]<<24) | + (buf[0x1d]<<16) | + (buf[0x1e]<<8) | + (buf[0x1f]) + )/32*channels*18+chanstart; + } + } else if (!memcmp(buf+0x10,"\x01\xF4\x04",3)) { + /* Standard (type 04) */ + DEBUGF("ADX: type 04 found\n"); + /* check if header is too small for loop data */ + if (chanstart-6 < 0x38) looping=0; + else { + looping = (buf[0x24]) || + (buf[0x25]) || + (buf[0x26]) || + (buf[0x27]); + end_adr = (buf[0x34]<<24) | + (buf[0x35]<<16) | + (buf[0x36]<<8) | + buf[0x37]; + start_adr = ( + (buf[0x28]<<24) | + (buf[0x29]<<16) | + (buf[0x2a]<<8) | + (buf[0x2b]) + )/32*channels*18+chanstart; + } + } else { + DEBUGF("ADX: error, couldn't determine ADX type\n"); + return CODEC_ERROR; + } + + /* is file using encryption */ + if (buf[0x13]==0x08) { + DEBUGF("ADX: error, encrypted ADX not supported\n"); + return false; + } + + if (looping) { + DEBUGF("ADX: looped, start: %lx end: %lx\n",start_adr,end_adr); + } else { + DEBUGF("ADX: not looped\n"); + } + + /* advance to first frame */ + DEBUGF("ADX: first frame at %lx\n",chanstart); + bufoff = chanstart; + + /* get in position */ + ci->seek_buffer(bufoff); + ci->set_elapsed(0); + + /* setup pcm buffer format */ + ci->configure(DSP_SWITCH_FREQUENCY, ci->id3->frequency); + if (channels == 2) { + ci->configure(DSP_SET_STEREO_MODE, STEREO_INTERLEAVED); + } else if (channels == 1) { + ci->configure(DSP_SET_STEREO_MODE, STEREO_MONO); + } else { + DEBUGF("ADX CODEC_ERROR: more than 2 channels\n"); + return CODEC_ERROR; + } + + endofstream = 0; + loop_count = 0; + fade_count = -1; /* disable fade */ + fade_frames = 1; + + /* The main decoder loop */ + + while (!endofstream) { + enum codec_command_action action = ci->get_command(¶m); + + if (action == CODEC_ACTION_HALT) + break; + + /* do we need to loop? */ + if (bufoff > end_adr-18*channels && looping) { + DEBUGF("ADX: loop!\n"); + /* check for endless looping */ + if (ci->loop_track()) { + loop_count=0; + fade_count = -1; /* disable fade */ + } else { + /* otherwise start fade after LOOP_TIMES loops */ + loop_count++; + if (loop_count >= LOOP_TIMES && fade_count < 0) { + /* frames to fade over */ + fade_frames = FADE_LENGTH*ci->id3->frequency/32/1000; + /* volume relative to fade_frames */ + fade_count = fade_frames; + DEBUGF("ADX: fade_frames = %d\n",fade_frames); + } + } + bufoff = start_adr; + ci->seek_buffer(bufoff); + } + + /* do we need to seek? */ + if (action == CODEC_ACTION_SEEK_TIME) { + uint32_t newpos; + + DEBUGF("ADX: seek to %ldms\n", (long)param); + + endofstream = 0; + loop_count = 0; + fade_count = -1; /* disable fade */ + fade_frames = 1; + + newpos = (((uint64_t)avgbytespersec*param) + / (1000LL*18*channels))*(18*channels); + bufoff = chanstart + newpos; + while (bufoff > end_adr-18*channels) { + bufoff-=end_adr-start_adr; + loop_count++; + } + ci->seek_buffer(bufoff); + + ci->set_elapsed( + ((end_adr-start_adr)*loop_count + bufoff-chanstart)* + 1000LL/avgbytespersec); + + ci->seek_complete(); + } + + if (bufoff>ci->filesize-channels*18) break; /* End of stream */ + + sampleswritten=0; + + while ( + /* Is there data left in the file? */ + (bufoff <= ci->filesize-(18*channels)) && + /* Is there space in the output buffer? */ + (sampleswritten <= WAV_CHUNK_SIZE-(32*channels)) && + /* Should we be looping? */ + ((!looping) || bufoff <= end_adr-18*channels)) + { + /* decode first/only channel */ + int32_t scale; + int32_t ch1_0, d; + + /* fetch a frame */ + buf = ci->request_buffer(&n, 18); + + if (!buf || n!=18) { + DEBUGF("ADX: couldn't get buffer at %lx\n", + bufoff); + return CODEC_ERROR; + } + + scale = ((buf[0] << 8) | (buf[1])) +1; + + for (i = 2; i < 18; i++) + { + d = (buf[i] >> 4) & 15; + if (d & 8) d-= 16; + ch1_0 = d*scale + ((coef1*ch1_1 + coef2*ch1_2) >> 12); + if (ch1_0 > 32767) ch1_0 = 32767; + else if (ch1_0 < -32768) ch1_0 = -32768; + samples[sampleswritten] = ch1_0; + sampleswritten+=channels; + ch1_2 = ch1_1; ch1_1 = ch1_0; + + d = buf[i] & 15; + if (d & 8) d -= 16; + ch1_0 = d*scale + ((coef1*ch1_1 + coef2*ch1_2) >> 12); + if (ch1_0 > 32767) ch1_0 = 32767; + else if (ch1_0 < -32768) ch1_0 = -32768; + samples[sampleswritten] = ch1_0; + sampleswritten+=channels; + ch1_2 = ch1_1; ch1_1 = ch1_0; + } + bufoff+=18; + ci->advance_buffer(18); + + if (channels == 2) { + /* decode second channel */ + int32_t scale; + int32_t ch2_0, d; + + buf = ci->request_buffer(&n, 18); + + if (!buf || n!=18) { + DEBUGF("ADX: couldn't get buffer at %lx\n", + bufoff); + return CODEC_ERROR; + } + + scale = ((buf[0] << 8)|(buf[1]))+1; + + sampleswritten-=63; + + for (i = 2; i < 18; i++) + { + d = (buf[i] >> 4) & 15; + if (d & 8) d-= 16; + ch2_0 = d*scale + ((coef1*ch2_1 + coef2*ch2_2) >> 12); + if (ch2_0 > 32767) ch2_0 = 32767; + else if (ch2_0 < -32768) ch2_0 = -32768; + samples[sampleswritten] = ch2_0; + sampleswritten+=2; + ch2_2 = ch2_1; ch2_1 = ch2_0; + + d = buf[i] & 15; + if (d & 8) d -= 16; + ch2_0 = d*scale + ((coef1*ch2_1 + coef2*ch2_2) >> 12); + if (ch2_0 > 32767) ch2_0 = 32767; + else if (ch2_0 < -32768) ch2_0 = -32768; + samples[sampleswritten] = ch2_0; + sampleswritten+=2; + ch2_2 = ch2_1; ch2_1 = ch2_0; + } + bufoff+=18; + ci->advance_buffer(18); + sampleswritten--; /* go back to first channel's next sample */ + } + + if (fade_count>0) { + fade_count--; + for (i=0;i<(channels==1?32:64);i++) samples[sampleswritten-i-1]= + ((int32_t)samples[sampleswritten-i-1])*fade_count/fade_frames; + if (fade_count==0) {endofstream=1; break;} + } + } + + if (channels == 2) + sampleswritten >>= 1; /* make samples/channel */ + + ci->pcmbuf_insert(samples, NULL, sampleswritten); + + ci->set_elapsed( + ((end_adr-start_adr)*loop_count + bufoff-chanstart)* + 1000LL/avgbytespersec); + } + + return CODEC_OK; +} diff --git a/lib/rbcodec/codecs/aiff.c b/lib/rbcodec/codecs/aiff.c new file mode 100644 index 0000000000..333bcd0455 --- /dev/null +++ b/lib/rbcodec/codecs/aiff.c @@ -0,0 +1,350 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (c) 2005 Jvo Studer + * Copyright (c) 2009 Yoshihisa Uchida + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include "codeclib.h" +#include "codecs/libpcm/support_formats.h" + +CODEC_HEADER + +#define FOURCC(c1, c2, c3, c4) \ +((((uint32_t)c1)<<24)|(((uint32_t)c2)<<16)|(((uint32_t)c3)<<8)|((uint32_t)c4)) + +/* This codec supports the following AIFC compressionType formats */ +enum { + AIFC_FORMAT_PCM = FOURCC('N', 'O', 'N', 'E'), /* AIFC PCM Format (big endian) */ + AIFC_FORMAT_ALAW = FOURCC('a', 'l', 'a', 'w'), /* AIFC ALaw compressed */ + AIFC_FORMAT_MULAW = FOURCC('u', 'l', 'a', 'w'), /* AIFC uLaw compressed */ + AIFC_FORMAT_IEEE_FLOAT32 = FOURCC('f', 'l', '3', '2'), /* AIFC IEEE float 32 bit */ + AIFC_FORMAT_IEEE_FLOAT64 = FOURCC('f', 'l', '6', '4'), /* AIFC IEEE float 64 bit */ + AIFC_FORMAT_QT_IMA_ADPCM = FOURCC('i', 'm', 'a', '4'), /* AIFC QuickTime IMA ADPCM */ +}; + +static const struct pcm_entry pcm_codecs[] = { + { AIFC_FORMAT_PCM, get_linear_pcm_codec }, + { AIFC_FORMAT_ALAW, get_itut_g711_alaw_codec }, + { AIFC_FORMAT_MULAW, get_itut_g711_mulaw_codec }, + { AIFC_FORMAT_IEEE_FLOAT32, get_ieee_float_codec }, + { AIFC_FORMAT_IEEE_FLOAT64, get_ieee_float_codec }, + { AIFC_FORMAT_QT_IMA_ADPCM, get_qt_ima_adpcm_codec }, +}; + +#define PCM_SAMPLE_SIZE (1024*2) + +static int32_t samples[PCM_SAMPLE_SIZE] IBSS_ATTR; + +static const struct pcm_codec *get_codec(uint32_t formattag) +{ + unsigned i; + for (i = 0; i < sizeof(pcm_codecs)/sizeof(pcm_codecs[0]); i++) + if (pcm_codecs[i].format_tag == formattag) + return pcm_codecs[i].get_codec(); + + return NULL; +} + +/* this is the codec entry point */ +enum codec_status codec_main(enum codec_entry_call_reason reason) +{ + if (reason == CODEC_LOAD) { + /* Generic codec initialisation */ + ci->configure(DSP_SET_SAMPLE_DEPTH, PCM_OUTPUT_DEPTH-1); + } + + return CODEC_OK; +} + +/* this is called for each file to process */ +enum codec_status codec_run(void) +{ + struct pcm_format format; + uint32_t bytesdone, decodedsamples; + /* rockbox: comment 'set but unused' variables + uint32_t num_sample_frames = 0; + */ + size_t n; + int bufcount; + int endofstream; + unsigned char *buf; + uint8_t *aifbuf; + uint32_t offset2snd = 0; + off_t firstblockposn; /* position of the first block in file */ + bool is_aifc = false; + const struct pcm_codec *codec; + uint32_t size; + intptr_t param; + + if (codec_init()) { + return CODEC_ERROR; + } + + codec_set_replaygain(ci->id3); + + /* Need to save offset for later use (cleared indirectly by advance_buffer) */ + bytesdone = ci->id3->offset; + + /* assume the AIFF header is less than 1024 bytes */ + ci->seek_buffer(0); + buf = ci->request_buffer(&n, 1024); + if (n < 54) { + return CODEC_ERROR; + } + + if (memcmp(buf, "FORM", 4) != 0) + { + DEBUGF("CODEC_ERROR: does not aiff format %4.4s\n", (char*)&buf[0]); + return CODEC_ERROR; + } + if (memcmp(&buf[8], "AIFF", 4) == 0) + is_aifc = false; + else if (memcmp(&buf[8], "AIFC", 4) == 0) + is_aifc = true; + else + { + DEBUGF("CODEC_ERROR: does not aiff format %4.4s\n", (char*)&buf[8]); + return CODEC_ERROR; + } + + buf += 12; + n -= 12; + + ci->memset(&format, 0, sizeof(struct pcm_format)); + format.is_signed = true; + format.is_little_endian = false; + + decodedsamples = 0; + codec = 0; + + /* read until 'SSND' chunk, which typically is last */ + while (format.numbytes == 0 && n >= 8) + { + /* chunkSize */ + size = ((buf[4]<<24)|(buf[5]<<16)|(buf[6]<<8)|buf[7]); + if (memcmp(buf, "COMM", 4) == 0) { + if ((!is_aifc && size < 18) || (is_aifc && size < 22)) + { + DEBUGF("CODEC_ERROR: 'COMM' chunk size=%lu < %d\n", + (unsigned long)size, (is_aifc)?22:18); + return CODEC_ERROR; + } + /* num_channels */ + format.channels = ((buf[8]<<8)|buf[9]); + /* num_sample_frames */ + /* + num_sample_frames = ((buf[10]<<24)|(buf[11]<<16)|(buf[12]<<8) + |buf[13]); + */ + + /* sample_size */ + format.bitspersample = ((buf[14]<<8)|buf[15]); + /* sample_rate (don't use last 4 bytes, only integer fs) */ + if (buf[16] != 0x40) { + DEBUGF("CODEC_ERROR: weird sampling rate (no @)\n"); + return CODEC_ERROR; + } + format.samplespersec = ((buf[18]<<24)|(buf[19]<<16)|(buf[20]<<8)|buf[21])+1; + format.samplespersec >>= (16 + 14 - buf[17]); + /* compressionType (AIFC only) */ + if (is_aifc) + { + format.formattag = (buf[26]<<24)|(buf[27]<<16)|(buf[28]<<8)|buf[29]; + + /* + * aiff's sample_size is uncompressed sound data size. + * But format.bitspersample is compressed sound data size. + */ + if (format.formattag == AIFC_FORMAT_ALAW || + format.formattag == AIFC_FORMAT_MULAW) + format.bitspersample = 8; + else if (format.formattag == AIFC_FORMAT_QT_IMA_ADPCM) + format.bitspersample = 4; + } + else + format.formattag = AIFC_FORMAT_PCM; + /* calc average bytes per second */ + format.avgbytespersec = format.samplespersec*format.channels*format.bitspersample/8; + } else if (memcmp(buf, "SSND", 4)==0) { + if (format.bitspersample == 0) { + DEBUGF("CODEC_ERROR: unsupported chunk order\n"); + return CODEC_ERROR; + } + /* offset2snd */ + offset2snd = (buf[8]<<24)|(buf[9]<<16)|(buf[10]<<8)|buf[11]; + /* block_size */ + format.blockalign = ((buf[12]<<24)|(buf[13]<<16)|(buf[14]<<8)|buf[15]) >> 3; + if (format.blockalign == 0) + format.blockalign = format.channels * format.bitspersample >> 3; + format.numbytes = size - 8 - offset2snd; + size = 8 + offset2snd; /* advance to the beginning of data */ + } else if (is_aifc && (memcmp(buf, "FVER", 4)==0)) { + /* Format Version Chunk (AIFC only chunk) */ + /* skip this chunk */ + } else { + DEBUGF("unsupported AIFF chunk: '%c%c%c%c', size=%lu\n", + buf[0], buf[1], buf[2], buf[3], (unsigned long)size); + } + + size += 8 + (size & 0x01); /* odd chunk sizes must be padded */ + + buf += size; + if (n < size) { + DEBUGF("CODEC_ERROR: AIFF header size > 1024\n"); + return CODEC_ERROR; + } + n -= size; + } /* while 'SSND' */ + + if (format.channels == 0) { + DEBUGF("CODEC_ERROR: 'COMM' chunk not found or 0-channels file\n"); + return CODEC_ERROR; + } + if (format.numbytes == 0) { + DEBUGF("CODEC_ERROR: 'SSND' chunk not found or has zero length\n"); + return CODEC_ERROR; + } + + codec = get_codec(format.formattag); + if (codec == 0) + { + DEBUGF("CODEC_ERROR: AIFC does not support compressionType: 0x%x\n", + (unsigned int)format.formattag); + return CODEC_ERROR; + } + + if (!codec->set_format(&format)) + { + return CODEC_ERROR; + } + + ci->configure(DSP_SWITCH_FREQUENCY, ci->id3->frequency); + + if (format.channels == 2) { + ci->configure(DSP_SET_STEREO_MODE, STEREO_INTERLEAVED); + } else if (format.channels == 1) { + ci->configure(DSP_SET_STEREO_MODE, STEREO_MONO); + } else { + DEBUGF("CODEC_ERROR: more than 2 channels unsupported\n"); + return CODEC_ERROR; + } + + if (format.samplesperblock == 0) + { + DEBUGF("CODEC_ERROR: samplesperblock is 0\n"); + return CODEC_ERROR; + } + if (format.blockalign == 0) + { + DEBUGF("CODEC_ERROR: blockalign is 0\n"); + return CODEC_ERROR; + } + + /* check chunksize */ + if ((format.chunksize / format.blockalign) * format.samplesperblock * format.channels + > PCM_SAMPLE_SIZE) + format.chunksize = (PCM_SAMPLE_SIZE / format.blockalign) * format.blockalign; + if (format.chunksize == 0) + { + DEBUGF("CODEC_ERROR: chunksize is 0\n"); + return CODEC_ERROR; + } + + firstblockposn = 1024 - n; + ci->advance_buffer(firstblockposn); + + /* make sure we're at the correct offset */ + if (bytesdone > (uint32_t) firstblockposn) { + /* Round down to previous block */ + struct pcm_pos *newpos = codec->get_seek_pos(bytesdone - firstblockposn, + PCM_SEEK_POS, NULL); + + if (newpos->pos > format.numbytes) + return CODEC_OK; + + if (ci->seek_buffer(firstblockposn + newpos->pos)) + { + bytesdone = newpos->pos; + decodedsamples = newpos->samples; + } + } else { + /* already where we need to be */ + bytesdone = 0; + } + + ci->set_elapsed(decodedsamples*1000LL/ci->id3->frequency); + + /* The main decoder loop */ + endofstream = 0; + + while (!endofstream) { + enum codec_command_action action = ci->get_command(¶m); + + if (action == CODEC_ACTION_HALT) + break; + + if (action == CODEC_ACTION_SEEK_TIME) { + /* 3rd args(read_buffer) is unnecessary in the format which AIFF supports. */ + struct pcm_pos *newpos = codec->get_seek_pos(param, PCM_SEEK_TIME, NULL); + + if (newpos->pos > format.numbytes) + { + ci->set_elapsed(ci->id3->length); + ci->seek_complete(); + break; + } + + if (ci->seek_buffer(firstblockposn + newpos->pos)) + { + bytesdone = newpos->pos; + decodedsamples = newpos->samples; + } + + ci->set_elapsed(decodedsamples*1000LL/ci->id3->frequency); + ci->seek_complete(); + } + aifbuf = (uint8_t *)ci->request_buffer(&n, format.chunksize); + + if (n == 0) + break; /* End of stream */ + + if (bytesdone + n > format.numbytes) { + n = format.numbytes - bytesdone; + endofstream = 1; + } + + if (codec->decode(aifbuf, n, samples, &bufcount) == CODEC_ERROR) + { + DEBUGF("codec error\n"); + return CODEC_ERROR; + } + + ci->pcmbuf_insert(samples, NULL, bufcount); + + ci->advance_buffer(n); + bytesdone += n; + decodedsamples += bufcount; + if (bytesdone >= format.numbytes) + endofstream = 1; + + ci->set_elapsed(decodedsamples*1000LL/ci->id3->frequency); + } + + return CODEC_OK; +} diff --git a/lib/rbcodec/codecs/aiff_enc.c b/lib/rbcodec/codecs/aiff_enc.c new file mode 100644 index 0000000000..fc44196eb0 --- /dev/null +++ b/lib/rbcodec/codecs/aiff_enc.c @@ -0,0 +1,400 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2006 Antonius Hellmann + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include +#include "codeclib.h" + +CODEC_ENC_HEADER + +struct aiff_header +{ + uint8_t form_id[4]; /* 00h - 'FORM' */ + uint32_t form_size; /* 04h - size of file - 8 */ + uint8_t aiff_id[4]; /* 08h - 'AIFF' */ + uint8_t comm_id[4]; /* 0Ch - 'COMM' */ + int32_t comm_size; /* 10h - num_channels through sample_rate + (18) */ + int16_t num_channels; /* 14h - 1=M, 2=S, etc. */ + uint32_t num_sample_frames; /* 16h - num samples for each channel */ + int16_t sample_size; /* 1ah - 1-32 bits per sample */ + uint8_t sample_rate[10]; /* 1ch - IEEE 754 80-bit floating point */ + uint8_t ssnd_id[4]; /* 26h - "SSND" */ + int32_t ssnd_size; /* 2ah - size of chunk from offset to + end of pcm data */ + uint32_t offset; /* 2eh - data offset from end of header */ + uint32_t block_size; /* 32h - pcm data alignment */ + /* 36h */ +} __attribute__((packed)); + +#define PCM_DEPTH_BYTES 2 +#define PCM_DEPTH_BITS 16 +#define PCM_SAMP_PER_CHUNK 2048 +#define PCM_CHUNK_SIZE (PCM_SAMP_PER_CHUNK*4) + +/* Template headers */ +struct aiff_header aiff_header = +{ + { 'F', 'O', 'R', 'M' }, /* form_id */ + 0, /* form_size (*) */ + { 'A', 'I', 'F', 'F' }, /* aiff_id */ + { 'C', 'O', 'M', 'M' }, /* comm_id */ + htobe32(18), /* comm_size */ + 0, /* num_channels (*) */ + 0, /* num_sample_frames (*) */ + htobe16(PCM_DEPTH_BITS), /* sample_size */ + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* sample_rate (*) */ + { 'S', 'S', 'N', 'D' }, /* ssnd_id */ + 0, /* ssnd_size (*) */ + htobe32(0), /* offset */ + htobe32(0), /* block_size */ +}; + +/* (*) updated when finalizing file */ + +static int num_channels IBSS_ATTR; +static int rec_mono_mode IBSS_ATTR; +static uint32_t sample_rate; +static uint32_t enc_size; +static int32_t err IBSS_ATTR; + +/* convert unsigned 32 bit value to 80-bit floating point number */ +STATICIRAM void uint32_h_to_ieee754_extended_be(uint8_t f[10], uint32_t l) + ICODE_ATTR; +STATICIRAM void uint32_h_to_ieee754_extended_be(uint8_t f[10], uint32_t l) +{ + int32_t exp; + + ci->memset(f, 0, 10); + + if (l == 0) + return; + + for (exp = 30; (l & (1ul << 31)) == 0; exp--) + l <<= 1; + + /* sign always zero - bit 79 */ + /* exponent is 0-31 (normalized: 31 - shift + 16383) - bits 64-78 */ + f[0] = 0x40; + f[1] = (uint8_t)exp; + /* mantissa is value left justified with most significant non-zero + bit stored in bit 63 - bits 0-63 */ + f[2] = (uint8_t)(l >> 24); + f[3] = (uint8_t)(l >> 16); + f[4] = (uint8_t)(l >> 8); + f[5] = (uint8_t)(l >> 0); +} /* uint32_h_to_ieee754_extended_be */ + +/* called version often - inline */ +static inline bool is_file_data_ok(struct enc_file_event_data *data) ICODE_ATTR; +static inline bool is_file_data_ok(struct enc_file_event_data *data) +{ + return data->rec_file >= 0 && (long)data->chunk->flags >= 0; +} /* is_file_data_ok */ + +/* called version often - inline */ +static inline bool on_write_chunk(struct enc_file_event_data *data) ICODE_ATTR; +static inline bool on_write_chunk(struct enc_file_event_data *data) +{ + if (!is_file_data_ok(data)) + return false; + + if (data->chunk->enc_data == NULL) + { +#ifdef ROCKBOX_HAS_LOGF + ci->logf("aiff enc: NULL data"); +#endif + return true; + } + + if (ci->write(data->rec_file, data->chunk->enc_data, + data->chunk->enc_size) != (ssize_t)data->chunk->enc_size) + return false; + + data->num_pcm_samples += data->chunk->num_pcm; + return true; +} /* on_write_chunk */ + +static bool on_start_file(struct enc_file_event_data *data) +{ + if ((data->chunk->flags & CHUNKF_ERROR) || *data->filename == '\0') + return false; + + data->rec_file = ci->open(data->filename, O_RDWR|O_CREAT|O_TRUNC, 0666); + + if (data->rec_file < 0) + return false; + + /* reset sample count */ + data->num_pcm_samples = 0; + + /* write template headers */ + if (ci->write(data->rec_file, &aiff_header, sizeof (aiff_header)) + != sizeof (aiff_header)) + { + return false; + } + + data->new_enc_size += sizeof(aiff_header); + return true; +} /* on_start_file */ + +static bool on_end_file(struct enc_file_event_data *data) +{ + /* update template headers */ + struct aiff_header hdr; + uint32_t data_size; + + if (!is_file_data_ok(data)) + return false; + + if (ci->lseek(data->rec_file, 0, SEEK_SET) != 0 || + ci->read(data->rec_file, &hdr, sizeof (hdr)) != sizeof (hdr)) + { + return false; + } + + data_size = data->num_pcm_samples*num_channels*PCM_DEPTH_BYTES; + + /* 'FORM' chunk */ + hdr.form_size = htobe32(data_size + sizeof (hdr) - 8); + + /* 'COMM' chunk */ + hdr.num_channels = htobe16(num_channels); + hdr.num_sample_frames = htobe32(data->num_pcm_samples); + uint32_h_to_ieee754_extended_be(hdr.sample_rate, sample_rate); + + /* 'SSND' chunk */ + hdr.ssnd_size = htobe32(data_size + 8); + + if (ci->lseek(data->rec_file, 0, SEEK_SET) != 0 || + ci->write(data->rec_file, &hdr, sizeof (hdr)) != sizeof (hdr) || + ci->close(data->rec_file) != 0) + { + return false; + } + + data->rec_file = -1; + + return true; +} /* on_end_file */ + +STATICIRAM void enc_events_callback(enum enc_events event, void *data) + ICODE_ATTR; +STATICIRAM void enc_events_callback(enum enc_events event, void *data) +{ + switch (event) + { + case ENC_WRITE_CHUNK: + if (on_write_chunk((struct enc_file_event_data *)data)) + return; + + break; + + case ENC_START_FILE: + if (on_start_file((struct enc_file_event_data *)data)) + return; + + break; + + case ENC_END_FILE: + if (on_end_file((struct enc_file_event_data *)data)) + return; + + break; + + default: + return; + } + + /* Something failed above. Signal error back to core. */ + ((struct enc_file_event_data *)data)->chunk->flags |= CHUNKF_ERROR; +} /* enc_events_callback */ + +/* convert native pcm samples to aiff format samples */ +static inline void sample_to_mono(uint32_t **src, uint32_t **dst) +{ + int32_t lr1, lr2; + + switch(rec_mono_mode) + { + case 1: + /* mono = L */ + lr1 = *(*src)++; + lr1 = lr1 >> 16; + lr2 = *(*src)++; + lr2 = lr2 >> 16; + break; + case 2: + /* mono = R */ + lr1 = *(*src)++; + lr1 = (int16_t)lr1; + lr2 = *(*src)++; + lr2 = (int16_t)lr2; + break; + case 0: + default: + /* mono = (L+R)/2 */ + lr1 = *(*src)++; + lr1 = (int16_t)lr1 + (lr1 >> 16) + err; + err = lr1 & 1; + lr1 >>= 1; + + lr2 = *(*src)++; + lr2 = (int16_t)lr2 + (lr2 >> 16) + err; + err = lr2 & 1; + lr2 >>= 1; + break; + } + *(*dst)++ = htobe32((lr1 << 16) | (uint16_t)lr2); +} /* sample_to_mono */ + +STATICIRAM void chunk_to_aiff_format(uint32_t *src, uint32_t *dst) ICODE_ATTR; +STATICIRAM void chunk_to_aiff_format(uint32_t *src, uint32_t *dst) +{ + if (num_channels == 1) + { + /* On big endian: + * |LLLLLLLLllllllll|RRRRRRRRrrrrrrrr| + * |LLLLLLLLllllllll|RRRRRRRRrrrrrrrr| => + * |MMMMMMMMmmmmmmmm|MMMMMMMMmmmmmmmm| + * + * On little endian: + * |llllllllLLLLLLLL|rrrrrrrrRRRRRRRR| + * |llllllllLLLLLLLL|rrrrrrrrRRRRRRRR| => + * |MMMMMMMMmmmmmmmm|MMMMMMMMmmmmmmmm| + */ + uint32_t *src_end = src + PCM_SAMP_PER_CHUNK; + + do + { + sample_to_mono(&src, &dst); + sample_to_mono(&src, &dst); + sample_to_mono(&src, &dst); + sample_to_mono(&src, &dst); + sample_to_mono(&src, &dst); + sample_to_mono(&src, &dst); + sample_to_mono(&src, &dst); + sample_to_mono(&src, &dst); + } + while (src < src_end); + } + else + { +#ifdef ROCKBOX_BIG_ENDIAN + /* |LLLLLLLLllllllll|RRRRRRRRrrrrrrrr| => + * |LLLLLLLLllllllll|RRRRRRRRrrrrrrrr| + */ + ci->memcpy(dst, src, PCM_CHUNK_SIZE); +#else + /* |llllllllLLLLLLLL|rrrrrrrrRRRRRRRR| => + * |LLLLLLLLllllllll|RRRRRRRRrrrrrrrr| + */ + uint32_t *src_end = src + PCM_SAMP_PER_CHUNK; + + do + { + *dst++ = swap_odd_even32(*src++); + *dst++ = swap_odd_even32(*src++); + *dst++ = swap_odd_even32(*src++); + *dst++ = swap_odd_even32(*src++); + *dst++ = swap_odd_even32(*src++); + *dst++ = swap_odd_even32(*src++); + *dst++ = swap_odd_even32(*src++); + *dst++ = swap_odd_even32(*src++); + } + while (src < src_end); +#endif + } +} /* chunk_to_aiff_format */ + +static bool init_encoder(void) +{ + struct enc_inputs inputs; + struct enc_parameters params; + + if (ci->enc_get_inputs == NULL || + ci->enc_set_parameters == NULL || + ci->enc_get_chunk == NULL || + ci->enc_finish_chunk == NULL || + ci->enc_get_pcm_data == NULL ) + return false; + + ci->enc_get_inputs(&inputs); + + if (inputs.config->afmt != AFMT_AIFF) + return false; + + sample_rate = inputs.sample_rate; + num_channels = inputs.num_channels; + rec_mono_mode = inputs.rec_mono_mode; + err = 0; + + /* configure the buffer system */ + params.afmt = AFMT_AIFF; + enc_size = PCM_CHUNK_SIZE*inputs.num_channels / 2; + params.chunk_size = enc_size; + params.enc_sample_rate = sample_rate; + params.reserve_bytes = 0; + params.events_callback = enc_events_callback; + ci->enc_set_parameters(¶ms); + + return true; +} /* init_encoder */ + +/* this is the codec entry point */ +enum codec_status codec_main(enum codec_entry_call_reason reason) +{ + if (reason == CODEC_LOAD) { + if (!init_encoder()) + return CODEC_ERROR; + } + else if (reason == CODEC_UNLOAD) { + /* reset parameters to initial state */ + ci->enc_set_parameters(NULL); + } + + return CODEC_OK; +} + +/* this is called for each file to process */ +enum codec_status codec_run(void) +{ + /* main encoding loop */ + while (ci->get_command(NULL) != CODEC_ACTION_HALT) + { + uint32_t *src = (uint32_t *)ci->enc_get_pcm_data(PCM_CHUNK_SIZE); + struct enc_chunk_hdr *chunk; + + if (src == NULL) + continue; + + chunk = ci->enc_get_chunk(); + chunk->enc_size = enc_size; + chunk->num_pcm = PCM_SAMP_PER_CHUNK; + chunk->enc_data = ENC_CHUNK_SKIP_HDR(chunk->enc_data, chunk); + + chunk_to_aiff_format(src, (uint32_t *)chunk->enc_data); + + ci->enc_finish_chunk(); + } + + return CODEC_OK; +} diff --git a/lib/rbcodec/codecs/alac.c b/lib/rbcodec/codecs/alac.c new file mode 100644 index 0000000000..144d796e5f --- /dev/null +++ b/lib/rbcodec/codecs/alac.c @@ -0,0 +1,146 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2005 Dave Chapman + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include "codeclib.h" +#include "libm4a/m4a.h" +#include "libalac/decomp.h" + +CODEC_HEADER + +/* The maximum buffer size handled. This amount of bytes is buffered for each + * frame. */ +#define ALAC_BYTE_BUFFER_SIZE 32768 + +static int32_t outputbuffer[ALAC_MAX_CHANNELS][ALAC_BLOCKSIZE] IBSS_ATTR; + +/* this is the codec entry point */ +enum codec_status codec_main(enum codec_entry_call_reason reason) +{ + if (reason == CODEC_LOAD) { + /* Generic codec initialisation */ + ci->configure(DSP_SET_STEREO_MODE, STEREO_NONINTERLEAVED); + ci->configure(DSP_SET_SAMPLE_DEPTH, ALAC_OUTPUT_DEPTH-1); + } + + return CODEC_OK; +} + +/* this is called for each file to process */ +enum codec_status codec_run(void) +{ + size_t n; + demux_res_t demux_res; + stream_t input_stream; + uint32_t samplesdone; + uint32_t elapsedtime = 0; + int samplesdecoded; + unsigned int i; + unsigned char* buffer; + alac_file alac; + intptr_t param; + + /* Clean and initialize decoder structures */ + memset(&demux_res , 0, sizeof(demux_res)); + if (codec_init()) { + LOGF("ALAC: Error initialising codec\n"); + return CODEC_ERROR; + } + + ci->configure(DSP_SWITCH_FREQUENCY, ci->id3->frequency); + codec_set_replaygain(ci->id3); + + ci->seek_buffer(0); + + stream_create(&input_stream,ci); + + /* Read from ci->id3->offset before calling qtmovie_read. */ + samplesdone = (uint32_t)(((uint64_t)(ci->id3->offset) * ci->id3->frequency) / + (ci->id3->bitrate*128)); + + /* if qtmovie_read returns successfully, the stream is up to + * the movie data, which can be used directly by the decoder */ + if (!qtmovie_read(&input_stream, &demux_res)) { + LOGF("ALAC: Error initialising file\n"); + return CODEC_ERROR; + } + + /* initialise the sound converter */ + alac_set_info(&alac, demux_res.codecdata); + + /* Set i for first frame, seek to desired sample position for resuming. */ + i=0; + if (samplesdone > 0) { + if (m4a_seek(&demux_res, &input_stream, samplesdone, + &samplesdone, (int*) &i)) { + elapsedtime = (samplesdone * 10) / (ci->id3->frequency / 100); + ci->set_elapsed(elapsedtime); + } else { + samplesdone = 0; + } + } + + ci->set_elapsed(elapsedtime); + + /* The main decoding loop */ + while (i < demux_res.num_sample_byte_sizes) { + enum codec_command_action action = ci->get_command(¶m); + + if (action == CODEC_ACTION_HALT) + break; + + /* Request the required number of bytes from the input buffer */ + buffer=ci->request_buffer(&n, ALAC_BYTE_BUFFER_SIZE); + + /* Deal with any pending seek requests */ + if (action == CODEC_ACTION_SEEK_TIME) { + if (m4a_seek(&demux_res, &input_stream, + (param/10) * (ci->id3->frequency/100), + &samplesdone, (int *)&i)) { + elapsedtime=(samplesdone*10)/(ci->id3->frequency/100); + } + ci->set_elapsed(elapsedtime); + ci->seek_complete(); + } + + /* Request the required number of bytes from the input buffer */ + buffer=ci->request_buffer(&n, ALAC_BYTE_BUFFER_SIZE); + + /* Decode one block - returned samples will be host-endian */ + samplesdecoded=alac_decode_frame(&alac, buffer, outputbuffer, ci->yield); + ci->yield(); + + /* Advance codec buffer by amount of consumed bytes */ + ci->advance_buffer(alac.bytes_consumed); + + /* Output the audio */ + ci->pcmbuf_insert(outputbuffer[0], outputbuffer[1], samplesdecoded); + + /* Update the elapsed-time indicator */ + samplesdone+=samplesdecoded; + elapsedtime=(samplesdone*10)/(ci->id3->frequency/100); + ci->set_elapsed(elapsedtime); + + i++; + } + + LOGF("ALAC: Decoded %lu samples\n",(unsigned long)samplesdone); + return CODEC_OK; +} diff --git a/lib/rbcodec/codecs/ape.c b/lib/rbcodec/codecs/ape.c new file mode 100644 index 0000000000..ed6ea21685 --- /dev/null +++ b/lib/rbcodec/codecs/ape.c @@ -0,0 +1,330 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2007 Dave Chapman + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include "codeclib.h" +#include + +CODEC_HEADER + +#define BLOCKS_PER_LOOP 1024 +#define MAX_CHANNELS 2 +#define MAX_BYTESPERSAMPLE 3 + +/* Monkey's Audio files have one seekpoint per frame. The framesize + varies between 73728 and 1179648 samples. + + At the smallest framesize, 30000 frames would be 50155 seconds of + audio - almost 14 hours. This should be enough for any file a user + would want to play in Rockbox, given the 2GB FAT filesize (and 4GB + seektable entry size) limit. + + This means the seektable is 120000 bytes, but we have a lot of + spare room in the codec buffer - the APE codec itself is small. +*/ + +#define MAX_SEEKPOINTS 30000 +static uint32_t seektablebuf[MAX_SEEKPOINTS]; + +#define INPUT_CHUNKSIZE (32*1024) + +/* 1024*4 = 4096 bytes per channel */ +static int32_t decoded0[BLOCKS_PER_LOOP] IBSS_ATTR; +static int32_t decoded1[BLOCKS_PER_LOOP] IBSS_ATTR; + +#define MAX_SUPPORTED_SEEKTABLE_SIZE 5000 + + +/* Given an ape_ctx and a sample to seek to, return the file position + to the frame containing that sample, and the number of samples to + skip in that frame. +*/ + +static bool ape_calc_seekpos(struct ape_ctx_t* ape_ctx, + uint32_t new_sample, + uint32_t* newframe, + uint32_t* filepos, + uint32_t* samplestoskip) +{ + uint32_t n; + + n = new_sample / ape_ctx->blocksperframe; + if (n >= ape_ctx->numseekpoints) + { + /* We don't have a seekpoint for that frame */ + return false; + } + + *newframe = n; + *filepos = ape_ctx->seektable[n]; + *samplestoskip = new_sample - (n * ape_ctx->blocksperframe); + + return true; +} + +/* The resume offset is a value in bytes - we need to + turn it into a frame number and samplestoskip value */ + +static void ape_resume(struct ape_ctx_t* ape_ctx, size_t resume_offset, + uint32_t* currentframe, uint32_t* samplesdone, + uint32_t* samplestoskip, int* firstbyte) +{ + off_t newfilepos; + int64_t framesize; + int64_t offset; + + *currentframe = 0; + *samplesdone = 0; + *samplestoskip = 0; + + while ((*currentframe < ape_ctx->totalframes) && + (*currentframe < ape_ctx->numseekpoints) && + (resume_offset > ape_ctx->seektable[*currentframe])) + { + ++*currentframe; + *samplesdone += ape_ctx->blocksperframe; + } + + if ((*currentframe > 0) && + (ape_ctx->seektable[*currentframe] > resume_offset)) { + --*currentframe; + *samplesdone -= ape_ctx->blocksperframe; + } + + newfilepos = ape_ctx->seektable[*currentframe]; + + /* APE's bytestream is weird... */ + *firstbyte = 3 - (newfilepos & 3); + newfilepos &= ~3; + + ci->seek_buffer(newfilepos); + + /* We estimate where we were in the current frame, based on the + byte offset */ + if (*currentframe < (ape_ctx->totalframes - 1)) { + framesize = ape_ctx->seektable[*currentframe+1] - ape_ctx->seektable[*currentframe]; + offset = resume_offset - ape_ctx->seektable[*currentframe]; + + *samplestoskip = (offset * ape_ctx->blocksperframe) / framesize; + } +} + +/* this is the codec entry point */ +enum codec_status codec_main(enum codec_entry_call_reason reason) +{ + if (reason == CODEC_LOAD) { + /* Generic codec initialisation */ + ci->configure(DSP_SET_SAMPLE_DEPTH, APE_OUTPUT_DEPTH-1); + } + + return CODEC_OK; +} + +/* this is called for each file to process */ +enum codec_status codec_run(void) +{ + struct ape_ctx_t ape_ctx; + uint32_t samplesdone; + uint32_t elapsedtime; + size_t bytesleft; + + uint32_t currentframe; + uint32_t newfilepos; + uint32_t samplestoskip; + int nblocks; + int bytesconsumed; + unsigned char* inbuffer; + uint32_t blockstodecode; + int res; + int firstbyte; + size_t resume_offset; + intptr_t param; + + if (codec_init()) { + LOGF("APE: Error initialising codec\n"); + return CODEC_ERROR; + } + + /* Remember the resume position - when the codec is opened, the + playback engine will reset it. */ + resume_offset = ci->id3->offset; + + ci->seek_buffer(0); + inbuffer = ci->request_buffer(&bytesleft, INPUT_CHUNKSIZE); + + /* Read the file headers to populate the ape_ctx struct */ + if (ape_parseheaderbuf(inbuffer,&ape_ctx) < 0) { + LOGF("APE: Error reading header\n"); + return CODEC_ERROR; + } + + /* Initialise the seektable for this file */ + ape_ctx.seektable = seektablebuf; + ape_ctx.numseekpoints = MIN(MAX_SEEKPOINTS,ape_ctx.numseekpoints); + + ci->advance_buffer(ape_ctx.seektablefilepos); + + /* The seektable may be bigger than the guard buffer (32KB), so we + do a read() */ + ci->read_filebuf(ape_ctx.seektable, ape_ctx.numseekpoints * sizeof(uint32_t)); + +#ifdef ROCKBOX_BIG_ENDIAN + /* Byte-swap the little-endian seekpoints */ + { + uint32_t i; + + for(i = 0; i < ape_ctx.numseekpoints; i++) + ape_ctx.seektable[i] = swap32(ape_ctx.seektable[i]); + } +#endif + + /* Now advance the file position to the first frame */ + ci->advance_buffer(ape_ctx.firstframe - + (ape_ctx.seektablefilepos + + ape_ctx.numseekpoints * sizeof(uint32_t))); + + ci->configure(DSP_SWITCH_FREQUENCY, ape_ctx.samplerate); + ci->configure(DSP_SET_STEREO_MODE, ape_ctx.channels == 1 ? + STEREO_MONO : STEREO_NONINTERLEAVED); + codec_set_replaygain(ci->id3); + + /* The main decoding loop */ + + if (resume_offset) { + /* The resume offset is a value in bytes - we need to + turn it into a frame number and samplestoskip value */ + + ape_resume(&ape_ctx, resume_offset, + ¤tframe, &samplesdone, &samplestoskip, &firstbyte); + } else { + currentframe = 0; + samplesdone = 0; + samplestoskip = 0; + firstbyte = 3; /* Take account of the little-endian 32-bit byte ordering */ + } + + elapsedtime = (samplesdone*10)/(ape_ctx.samplerate/100); + ci->set_elapsed(elapsedtime); + + /* Initialise the buffer */ + inbuffer = ci->request_buffer(&bytesleft, INPUT_CHUNKSIZE); + + /* The main decoding loop - we decode the frames a small chunk at a time */ + while (currentframe < ape_ctx.totalframes) + { +frame_start: + /* Calculate how many blocks there are in this frame */ + if (currentframe == (ape_ctx.totalframes - 1)) + nblocks = ape_ctx.finalframeblocks; + else + nblocks = ape_ctx.blocksperframe; + + ape_ctx.currentframeblocks = nblocks; + + /* Initialise the frame decoder */ + init_frame_decoder(&ape_ctx, inbuffer, &firstbyte, &bytesconsumed); + + ci->advance_buffer(bytesconsumed); + inbuffer = ci->request_buffer(&bytesleft, INPUT_CHUNKSIZE); + + /* Decode the frame a chunk at a time */ + while (nblocks > 0) + { + enum codec_command_action action = ci->get_command(¶m); + + if (action == CODEC_ACTION_HALT) + goto done; + + /* Deal with any pending seek requests */ + if (action == CODEC_ACTION_SEEK_TIME) + { + if (ape_calc_seekpos(&ape_ctx, + (param/10) * (ci->id3->frequency/100), + ¤tframe, + &newfilepos, + &samplestoskip)) + { + samplesdone = currentframe * ape_ctx.blocksperframe; + + /* APE's bytestream is weird... */ + firstbyte = 3 - (newfilepos & 3); + newfilepos &= ~3; + + ci->seek_buffer(newfilepos); + inbuffer = ci->request_buffer(&bytesleft, INPUT_CHUNKSIZE); + + elapsedtime = (samplesdone*10)/(ape_ctx.samplerate/100); + ci->set_elapsed(elapsedtime); + ci->seek_complete(); + goto frame_start; /* Sorry... */ + } + + ci->seek_complete(); + } + + blockstodecode = MIN(BLOCKS_PER_LOOP, nblocks); + + if ((res = decode_chunk(&ape_ctx, inbuffer, &firstbyte, + &bytesconsumed, + decoded0, decoded1, + blockstodecode)) < 0) + { + /* Frame decoding error, abort */ + LOGF("APE: Frame %lu, error %d\n",(unsigned long)currentframe,res); + return CODEC_ERROR; + } + + ci->yield(); + + if (samplestoskip > 0) { + if (samplestoskip < blockstodecode) { + ci->pcmbuf_insert(decoded0 + samplestoskip, + decoded1 + samplestoskip, + blockstodecode - samplestoskip); + samplestoskip = 0; + } else { + samplestoskip -= blockstodecode; + } + } else { + ci->pcmbuf_insert(decoded0, decoded1, blockstodecode); + } + + samplesdone += blockstodecode; + + if (!samplestoskip) { + /* Update the elapsed-time indicator */ + elapsedtime = (samplesdone*10)/(ape_ctx.samplerate/100); + ci->set_elapsed(elapsedtime); + } + + ci->advance_buffer(bytesconsumed); + inbuffer = ci->request_buffer(&bytesleft, INPUT_CHUNKSIZE); + + /* Decrement the block count */ + nblocks -= blockstodecode; + } + + currentframe++; + } + +done: + LOGF("APE: Decoded %lu samples\n",(unsigned long)samplesdone); + return CODEC_OK; +} diff --git a/lib/rbcodec/codecs/asap.c b/lib/rbcodec/codecs/asap.c new file mode 100644 index 0000000000..19b39a44c4 --- /dev/null +++ b/lib/rbcodec/codecs/asap.c @@ -0,0 +1,140 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2008 Dominik Wenger + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include "codeclib.h" +#include "libasap/asap.h" + +CODEC_HEADER + +#define CHUNK_SIZE (1024*2) + +static byte samples[CHUNK_SIZE] IBSS_ATTR; /* The sample buffer */ +static ASAP_State asap IBSS_ATTR; /* asap codec state */ + +/* this is the codec entry point */ +enum codec_status codec_main(enum codec_entry_call_reason reason) +{ + /* Nothing to do */ + return CODEC_OK; + (void)reason; +} + +/* this is called for each file to process */ +enum codec_status codec_run(void) +{ + int n_bytes; + int song; + int duration; + char* module; + int bytesPerSample =2; + intptr_t param; + + if (codec_init()) { + DEBUGF("codec init failed\n"); + return CODEC_ERROR; + } + + codec_set_replaygain(ci->id3); + + int bytes_done =0; + size_t filesize; + ci->seek_buffer(0); + module = ci->request_buffer(&filesize, ci->filesize); + if (!module || (size_t)filesize < (size_t)ci->filesize) + { + DEBUGF("loading error\n"); + return CODEC_ERROR; + } + + /*Init ASAP */ + if (!ASAP_Load(&asap, ci->id3->path, module, filesize)) + { + DEBUGF("%s: format not supported",ci->id3->path); + return CODEC_ERROR; + } + + /* Make use of 44.1khz */ + ci->configure(DSP_SET_FREQUENCY, 44100); + /* Sample depth is 16 bit little endian */ + ci->configure(DSP_SET_SAMPLE_DEPTH, 16); + /* Stereo or Mono output ? */ + if(asap.module_info->channels ==1) + { + ci->configure(DSP_SET_STEREO_MODE, STEREO_MONO); + bytesPerSample = 2; + } + else + { + ci->configure(DSP_SET_STEREO_MODE, STEREO_INTERLEAVED); + bytesPerSample = 4; + } + /* reset eleapsed */ + ci->set_elapsed(0); + + song = asap.module_info->default_song; + duration = asap.module_info->durations[song]; + if (duration < 0) + duration = 180 * 1000; + + /* set id3 length, because metadata parse might not have done it */ + ci->id3->length = duration; + + ASAP_PlaySong(&asap, song, duration); + ASAP_MutePokeyChannels(&asap, 0); + + /* The main decoder loop */ + while (1) { + enum codec_command_action action = ci->get_command(¶m); + + if (action == CODEC_ACTION_HALT) + break; + + if (action == CODEC_ACTION_SEEK_TIME) { + /* New time is ready in param */ + + /* seek to pos */ + ASAP_Seek(&asap,param); + /* update bytes_done */ + bytes_done = param*44.1*2; + /* update elapsed */ + ci->set_elapsed((bytes_done / 2) / 44.1); + /* seek ready */ + ci->seek_complete(); + } + + /* Generate a buffer full of Audio */ + #ifdef ROCKBOX_LITTLE_ENDIAN + n_bytes = ASAP_Generate(&asap, samples, sizeof(samples), ASAP_FORMAT_S16_LE); + #else + n_bytes = ASAP_Generate(&asap, samples, sizeof(samples), ASAP_FORMAT_S16_BE); + #endif + + ci->pcmbuf_insert(samples, NULL, n_bytes /bytesPerSample); + + bytes_done += n_bytes; + ci->set_elapsed((bytes_done / 2) / 44.1); + + if(n_bytes != sizeof(samples)) + break; + } + + return CODEC_OK; +} diff --git a/lib/rbcodec/codecs/atrac3_oma.c b/lib/rbcodec/codecs/atrac3_oma.c new file mode 100644 index 0000000000..50f7c8f163 --- /dev/null +++ b/lib/rbcodec/codecs/atrac3_oma.c @@ -0,0 +1,153 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2009 Mohamed Tarek + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include + +#include "logf.h" +#include "codeclib.h" +#include "inttypes.h" +#include "libatrac/atrac3.h" + +CODEC_HEADER + +#define FRAMESIZE ci->id3->bytesperframe +#define BITRATE ci->id3->bitrate + +static ATRAC3Context q IBSS_ATTR; + +/* this is the codec entry point */ +enum codec_status codec_main(enum codec_entry_call_reason reason) +{ + /* Nothing to do */ + return CODEC_OK; + (void)reason; +} + +/* this is called for each file to process */ +enum codec_status codec_run(void) +{ + static size_t buff_size; + int datasize, res, frame_counter, total_frames, seek_frame_offset; + uint8_t *bit_buffer; + int elapsed = 0; + size_t resume_offset; + intptr_t param; + enum codec_command_action action = CODEC_ACTION_NULL; + + if (codec_init()) { + DEBUGF("codec init failed\n"); + return CODEC_ERROR; + } + + resume_offset = ci->id3->offset; + + codec_set_replaygain(ci->id3); + ci->memset(&q,0,sizeof(ATRAC3Context)); + + ci->configure(DSP_SET_FREQUENCY, ci->id3->frequency); + ci->configure(DSP_SET_SAMPLE_DEPTH, 17); /* Remark: atrac3 uses s15.0 by default, s15.2 was hacked. */ + ci->configure(DSP_SET_STEREO_MODE, ci->id3->channels == 1 ? + STEREO_MONO : STEREO_NONINTERLEAVED); + + ci->seek_buffer(0); + + res = atrac3_decode_init(&q, ci->id3); + if(res < 0) { + DEBUGF("failed to initialize OMA atrac decoder\n"); + return CODEC_ERROR; + } + + total_frames = (ci->id3->filesize - ci->id3->first_frame_offset) / FRAMESIZE; + frame_counter = 0; + + /* check for a mid-track resume and force a seek time accordingly */ + if(resume_offset > ci->id3->first_frame_offset) { + resume_offset -= ci->id3->first_frame_offset; + /* calculate resume_offset in frames */ + resume_offset = (int)resume_offset / FRAMESIZE; + param = (int)resume_offset * ((FRAMESIZE * 8)/BITRATE); + action = CODEC_ACTION_SEEK_TIME; + } + else { + ci->set_elapsed(0); + ci->seek_buffer(ci->id3->first_frame_offset); + } + + /* The main decoder loop */ + while(frame_counter < total_frames) + { + if (action == CODEC_ACTION_NULL) + action = ci->get_command(¶m); + + if (action == CODEC_ACTION_HALT) + break; + + bit_buffer = (uint8_t *) ci->request_buffer(&buff_size, FRAMESIZE); + + if (action == CODEC_ACTION_SEEK_TIME) { + /* Do not allow seeking beyond the file's length */ + if ((unsigned) param > ci->id3->length) { + ci->set_elapsed(ci->id3->length); + ci->seek_complete(); + break; + } + + /* Seek to the start of the track */ + if (param == 0) { + elapsed = 0; + ci->set_elapsed(0); + ci->seek_buffer(ci->id3->first_frame_offset); + ci->seek_complete(); + action = CODEC_ACTION_NULL; + continue; + } + + seek_frame_offset = (param * BITRATE) / (8 * FRAMESIZE); + frame_counter = seek_frame_offset; + ci->seek_buffer(ci->id3->first_frame_offset + seek_frame_offset* FRAMESIZE); + bit_buffer = (uint8_t *) ci->request_buffer(&buff_size, FRAMESIZE); + elapsed = param; + ci->set_elapsed(elapsed); + ci->seek_complete(); + } + + action = CODEC_ACTION_NULL; + + res = atrac3_decode_frame(FRAMESIZE, &q, &datasize, bit_buffer, FRAMESIZE); + + if(res != (int)FRAMESIZE) { + DEBUGF("codec error\n"); + return CODEC_ERROR; + } + + if(datasize) + ci->pcmbuf_insert(q.outSamples, q.outSamples + 1024, + q.samples_per_frame / ci->id3->channels); + + elapsed += (FRAMESIZE * 8) / BITRATE; + ci->set_elapsed(elapsed); + + ci->advance_buffer(FRAMESIZE); + frame_counter++; + } + + return CODEC_OK; +} diff --git a/lib/rbcodec/codecs/atrac3_rm.c b/lib/rbcodec/codecs/atrac3_rm.c new file mode 100644 index 0000000000..997507425e --- /dev/null +++ b/lib/rbcodec/codecs/atrac3_rm.c @@ -0,0 +1,215 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2009 Mohamed Tarek + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include + +#include "logf.h" +#include "codeclib.h" +#include "inttypes.h" +#include "libatrac/atrac3.h" + +CODEC_HEADER + +static RMContext rmctx IBSS_ATTR_LARGE_IRAM; +static RMPacket pkt IBSS_ATTR_LARGE_IRAM; +static ATRAC3Context q IBSS_ATTR; + +static void init_rm(RMContext *rmctx) +{ + /* initialize the RMContext */ + memcpy(rmctx, (void*)(( (intptr_t)ci->id3->id3v2buf + 3 ) &~ 3), sizeof(RMContext)); + + /* and atrac3 expects extadata in id3v2buf, so we shall give it that */ + memcpy(ci->id3->id3v2buf, (char*)rmctx->codec_extradata, rmctx->extradata_size*sizeof(char)); +} + +/* this is the codec entry point */ +enum codec_status codec_main(enum codec_entry_call_reason reason) +{ + /* Nothing to do */ + return CODEC_OK; + (void)reason; +} + +/* this is called for each file to process */ +enum codec_status codec_run(void) +{ + static size_t buff_size; + int datasize, res, consumed, i, time_offset; + uint8_t *bit_buffer; + uint16_t fs,sps,h; + uint32_t packet_count; + int scrambling_unit_size, num_units, elapsed = 0; + int playback_on = -1; + size_t resume_offset; + intptr_t param; + enum codec_command_action action = CODEC_ACTION_NULL; + + if (codec_init()) { + DEBUGF("codec init failed\n"); + return CODEC_ERROR; + } + + resume_offset = ci->id3->offset; + + codec_set_replaygain(ci->id3); + ci->memset(&rmctx,0,sizeof(RMContext)); + ci->memset(&pkt,0,sizeof(RMPacket)); + ci->memset(&q,0,sizeof(ATRAC3Context)); + + ci->seek_buffer(0); + init_rm(&rmctx); + + ci->configure(DSP_SET_FREQUENCY, ci->id3->frequency); + ci->configure(DSP_SET_SAMPLE_DEPTH, 17); /* Remark: atrac3 uses s15.0 by default, s15.2 was hacked. */ + ci->configure(DSP_SET_STEREO_MODE, rmctx.nb_channels == 1 ? + STEREO_MONO : STEREO_NONINTERLEAVED); + + packet_count = rmctx.nb_packets; + rmctx.audio_framesize = rmctx.block_align; + rmctx.block_align = rmctx.sub_packet_size; + fs = rmctx.audio_framesize; + sps= rmctx.block_align; + h = rmctx.sub_packet_h; + scrambling_unit_size = h * (fs + PACKET_HEADER_SIZE); + + res = atrac3_decode_init(&q, ci->id3); + if(res < 0) { + DEBUGF("failed to initialize RM atrac decoder\n"); + return CODEC_ERROR; + } + + /* check for a mid-track resume and force a seek time accordingly */ + if(resume_offset > rmctx.data_offset + DATA_HEADER_SIZE) { + resume_offset -= rmctx.data_offset + DATA_HEADER_SIZE; + num_units = (int)resume_offset / scrambling_unit_size; + /* put number of subpackets to skip in resume_offset */ + resume_offset /= (sps + PACKET_HEADER_SIZE); + param = (int)resume_offset * ((sps * 8 * 1000)/rmctx.bit_rate); + action = CODEC_ACTION_SEEK_TIME; + } + else { + ci->set_elapsed(0); + } + + ci->advance_buffer(rmctx.data_offset + DATA_HEADER_SIZE); + + /* The main decoder loop */ +seek_start : + while((unsigned)elapsed < rmctx.duration) + { + bit_buffer = (uint8_t *) ci->request_buffer(&buff_size, scrambling_unit_size); + consumed = rm_get_packet(&bit_buffer, &rmctx, &pkt); + if(consumed < 0 && playback_on != 0) { + if(playback_on == -1) { + /* Error only if packet-parsing failed and playback hadn't started */ + DEBUGF("rm_get_packet failed\n"); + return CODEC_ERROR; + } + else + return CODEC_OK; + } + + for(i = 0; i < rmctx.audio_pkt_cnt*(fs/sps) ; i++) + { + if (action == CODEC_ACTION_NULL) + action = ci->get_command(¶m); + + if (action == CODEC_ACTION_HALT) + return CODEC_OK; + + if (action == CODEC_ACTION_SEEK_TIME) { + /* Do not allow seeking beyond the file's length */ + if ((unsigned) param > ci->id3->length) { + ci->set_elapsed(ci->id3->length); + ci->seek_complete(); + return CODEC_OK; + } + + ci->seek_buffer(rmctx.data_offset + DATA_HEADER_SIZE); + packet_count = rmctx.nb_packets; + rmctx.audio_pkt_cnt = 0; + rmctx.frame_number = 0; + + /* Seek to the start of the track */ + if (param == 0) { + ci->set_elapsed(0); + ci->seek_complete(); + action = CODEC_ACTION_NULL; + goto seek_start; + } + num_units = (param/(sps*1000*8/rmctx.bit_rate))/(h*(fs/sps)); + ci->seek_buffer(rmctx.data_offset + DATA_HEADER_SIZE + consumed * num_units); + bit_buffer = (uint8_t *) ci->request_buffer(&buff_size, scrambling_unit_size); + consumed = rm_get_packet(&bit_buffer, &rmctx, &pkt); + if(consumed < 0 && playback_on != 0) { + if(playback_on == -1) { + /* Error only if packet-parsing failed and playback hadn't started */ + DEBUGF("rm_get_packet failed\n"); + return CODEC_ERROR; + } + else + return CODEC_OK; + } + + packet_count = rmctx.nb_packets - rmctx.audio_pkt_cnt * num_units; + rmctx.frame_number = (param/(sps*1000*8/rmctx.bit_rate)); + while(rmctx.audiotimestamp > (unsigned) param) { + rmctx.audio_pkt_cnt = 0; + ci->seek_buffer(rmctx.data_offset + DATA_HEADER_SIZE + consumed * (num_units-1)); + bit_buffer = (uint8_t *) ci->request_buffer(&buff_size, scrambling_unit_size); + consumed = rm_get_packet(&bit_buffer, &rmctx, &pkt); + packet_count += rmctx.audio_pkt_cnt; + num_units--; + } + time_offset = param - rmctx.audiotimestamp; + i = (time_offset/((sps * 8 * 1000)/rmctx.bit_rate)); + elapsed = rmctx.audiotimestamp+(1000*8*sps/rmctx.bit_rate)*i; + ci->set_elapsed(elapsed); + ci->seek_complete(); + } + + action = CODEC_ACTION_NULL; + + if(pkt.length) + res = atrac3_decode_frame(rmctx.block_align, &q, &datasize, pkt.frames[i], rmctx.block_align); + else /* indicates that there are no remaining frames */ + return CODEC_OK; + + if(res != rmctx.block_align) { + DEBUGF("codec error\n"); + return CODEC_ERROR; + } + + if(datasize) + ci->pcmbuf_insert(q.outSamples, q.outSamples + 1024, q.samples_per_frame / rmctx.nb_channels); + playback_on = 1; + elapsed = rmctx.audiotimestamp+(1000*8*sps/rmctx.bit_rate)*i; + ci->set_elapsed(elapsed); + rmctx.frame_number++; + } + packet_count -= rmctx.audio_pkt_cnt; + rmctx.audio_pkt_cnt = 0; + ci->advance_buffer(consumed); + } + + return CODEC_OK; +} diff --git a/lib/rbcodec/codecs/au.c b/lib/rbcodec/codecs/au.c new file mode 100644 index 0000000000..cb75c7423d --- /dev/null +++ b/lib/rbcodec/codecs/au.c @@ -0,0 +1,314 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2010 Yoshihisa Uchida + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include "codeclib.h" +#include "codecs/libpcm/support_formats.h" + +CODEC_HEADER + +/* Sun Audio file (Au file format) codec + * + * References + * [1] Sun Microsystems, Inc., Header file for Audio, .au, 1992 + * URL http://www.opengroup.org/public/pubs/external/auformat.html + * [2] Wikipedia, Au file format, URL: http://en.wikipedia.org/wiki/Sun_Audio + */ + +#define PCM_SAMPLE_SIZE (1024*2) + +static int32_t samples[PCM_SAMPLE_SIZE] IBSS_ATTR; + +enum +{ + AU_FORMAT_UNSUPPORT = 0, /* unsupported format */ + AU_FORMAT_MULAW, /* G.711 MULAW */ + AU_FORMAT_PCM, /* Linear PCM */ + AU_FORMAT_IEEE_FLOAT, /* IEEE float */ + AU_FORMAT_ALAW, /* G.711 ALAW */ +}; + +static const char support_formats[9][2] = { + { AU_FORMAT_UNSUPPORT, 0 }, /* encoding */ + { AU_FORMAT_MULAW, 8 }, /* 1: G.711 MULAW */ + { AU_FORMAT_PCM, 8 }, /* 2: Linear PCM 8bit (signed) */ + { AU_FORMAT_PCM, 16 }, /* 3: Linear PCM 16bit (signed, big endian) */ + { AU_FORMAT_PCM, 24 }, /* 4: Linear PCM 24bit (signed, big endian) */ + { AU_FORMAT_PCM, 32 }, /* 5: Linear PCM 32bit (signed, big endian) */ + { AU_FORMAT_IEEE_FLOAT, 32 }, /* 6: Linear PCM float 32bit (signed, big endian) */ + { AU_FORMAT_IEEE_FLOAT, 64 }, /* 7: Linear PCM float 64bit (signed, big endian) */ + /* encoding 8 - 26 unsupported. */ + { AU_FORMAT_ALAW, 8 }, /* 27: G.711 ALAW */ +}; + +static const struct pcm_entry au_codecs[] = { + { AU_FORMAT_MULAW, get_itut_g711_mulaw_codec }, + { AU_FORMAT_PCM, get_linear_pcm_codec }, + { AU_FORMAT_IEEE_FLOAT, get_ieee_float_codec }, + { AU_FORMAT_ALAW, get_itut_g711_alaw_codec }, +}; + +#define NUM_FORMATS 4 + +static const struct pcm_codec *get_au_codec(uint32_t formattag) +{ + int i; + + for (i = 0; i < NUM_FORMATS; i++) + { + if (au_codecs[i].format_tag == formattag) + { + if (au_codecs[i].get_codec) + return au_codecs[i].get_codec(); + return 0; + } + } + return 0; +} + +static unsigned int get_be32(uint8_t *buf) +{ + return (buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3]; +} + +static int convert_au_format(unsigned int encoding, struct pcm_format *fmt) +{ + fmt->formattag = AU_FORMAT_UNSUPPORT; + if (encoding < 8) + { + fmt->formattag = support_formats[encoding][0]; + fmt->bitspersample = support_formats[encoding][1]; + } + else if (encoding == 27) + { + fmt->formattag = support_formats[8][0]; + fmt->bitspersample = support_formats[8][1]; + } + + return fmt->formattag; +} + +/* this is the codec entry point */ +enum codec_status codec_main(enum codec_entry_call_reason reason) +{ + if (reason == CODEC_LOAD) { + /* Generic codec initialisation */ + ci->configure(DSP_SET_SAMPLE_DEPTH, PCM_OUTPUT_DEPTH-1); + } + + return CODEC_OK; +} + +/* this is called for each file to process */ +enum codec_status codec_run(void) +{ + struct pcm_format format; + uint32_t bytesdone, decodedsamples; + size_t n; + int bufcount; + int endofstream; + unsigned char *buf; + uint8_t *aubuf; + off_t firstblockposn; /* position of the first block in file */ + const struct pcm_codec *codec; + int offset = 0; + intptr_t param; + + if (codec_init()) { + DEBUGF("codec_init() error\n"); + return CODEC_ERROR; + } + + codec_set_replaygain(ci->id3); + + /* Need to save offset for later use (cleared indirectly by advance_buffer) */ + bytesdone = ci->id3->offset; + + ci->memset(&format, 0, sizeof(struct pcm_format)); + format.is_signed = true; + format.is_little_endian = false; + + /* set format */ + ci->seek_buffer(0); + buf = ci->request_buffer(&n, 24); + if (n < 24 || (memcmp(buf, ".snd", 4) != 0)) + { + /* + * headerless sun audio file + * It is decoded under conditions. + * format: G.711 mu-law + * channel: mono + * frequency: 8000 kHz + */ + offset = 0; + format.formattag = AU_FORMAT_MULAW; + format.channels = 1; + format.bitspersample = 8; + format.numbytes = ci->id3->filesize; + } + else + { + /* parse header */ + + /* data offset */ + offset = get_be32(buf + 4); + if (offset < 24) + { + DEBUGF("CODEC_ERROR: sun audio offset size is small: %d\n", offset); + return CODEC_ERROR; + } + /* data size */ + format.numbytes = get_be32(buf + 8); + if (format.numbytes == (uint32_t)0xffffffff) + format.numbytes = ci->id3->filesize - offset; + /* encoding */ + format.formattag = convert_au_format(get_be32(buf + 12), &format); + if (format.formattag == AU_FORMAT_UNSUPPORT) + { + DEBUGF("CODEC_ERROR: sun audio unsupport format: %d\n", get_be32(buf + 12)); + return CODEC_ERROR; + } + /* skip sample rate */ + format.channels = get_be32(buf + 20); + } + + /* advance to first WAVE chunk */ + ci->advance_buffer(offset); + + firstblockposn = offset; + + decodedsamples = 0; + codec = 0; + + /* get codec */ + codec = get_au_codec(format.formattag); + if (!codec) + { + DEBUGF("CODEC_ERROR: unsupport sun audio format: %x\n", (int)format.formattag); + return CODEC_ERROR; + } + + if (!codec->set_format(&format)) + { + return CODEC_ERROR; + } + + if (format.numbytes == 0) { + DEBUGF("CODEC_ERROR: data size is 0\n"); + return CODEC_ERROR; + } + + /* check chunksize */ + if ((format.chunksize / format.blockalign) * format.samplesperblock * format.channels + > PCM_SAMPLE_SIZE) + format.chunksize = (PCM_SAMPLE_SIZE / format.blockalign) * format.blockalign; + if (format.chunksize == 0) + { + DEBUGF("CODEC_ERROR: chunksize is 0\n"); + return CODEC_ERROR; + } + + ci->configure(DSP_SWITCH_FREQUENCY, ci->id3->frequency); + if (format.channels == 2) { + ci->configure(DSP_SET_STEREO_MODE, STEREO_INTERLEAVED); + } else if (format.channels == 1) { + ci->configure(DSP_SET_STEREO_MODE, STEREO_MONO); + } else { + DEBUGF("CODEC_ERROR: more than 2 channels\n"); + return CODEC_ERROR; + } + + /* make sure we're at the correct offset */ + if (bytesdone > (uint32_t) firstblockposn) { + /* Round down to previous block */ + struct pcm_pos *newpos = codec->get_seek_pos(bytesdone - firstblockposn, + PCM_SEEK_POS, NULL); + + if (newpos->pos > format.numbytes) + goto done; + if (ci->seek_buffer(firstblockposn + newpos->pos)) + { + bytesdone = newpos->pos; + decodedsamples = newpos->samples; + } + } else { + /* already where we need to be */ + bytesdone = 0; + } + + ci->set_elapsed(decodedsamples*1000LL/ci->id3->frequency); + + /* The main decoder loop */ + endofstream = 0; + + while (!endofstream) { + enum codec_command_action action = ci->get_command(¶m); + + if (action == CODEC_ACTION_HALT) + break; + + if (action == CODEC_ACTION_SEEK_TIME) { + /* 3rd args(read_buffer) is unnecessary in the format which Sun Audio supports. */ + struct pcm_pos *newpos = codec->get_seek_pos(param, PCM_SEEK_TIME, NULL); + + if (newpos->pos > format.numbytes) + { + ci->set_elapsed(ci->id3->length); + ci->seek_complete(); + break; + } + + if (ci->seek_buffer(firstblockposn + newpos->pos)) + { + bytesdone = newpos->pos; + decodedsamples = newpos->samples; + } + + ci->set_elapsed(decodedsamples*1000LL/ci->id3->frequency); + ci->seek_complete(); + } + + aubuf = (uint8_t *)ci->request_buffer(&n, format.chunksize); + if (n == 0) + break; /* End of stream */ + if (bytesdone + n > format.numbytes) { + n = format.numbytes - bytesdone; + endofstream = 1; + } + + if (codec->decode(aubuf, n, samples, &bufcount) == CODEC_ERROR) + { + DEBUGF("codec error\n"); + return CODEC_ERROR; + } + + ci->pcmbuf_insert(samples, NULL, bufcount); + ci->advance_buffer(n); + bytesdone += n; + decodedsamples += bufcount; + + if (bytesdone >= format.numbytes) + endofstream = 1; + ci->set_elapsed(decodedsamples*1000LL/ci->id3->frequency); + } + +done: + return CODEC_OK; +} diff --git a/lib/rbcodec/codecs/ay.c b/lib/rbcodec/codecs/ay.c new file mode 100644 index 0000000000..b11ad84294 --- /dev/null +++ b/lib/rbcodec/codecs/ay.c @@ -0,0 +1,137 @@ + +/* Ripped off from Game_Music_Emu 0.5.2. http://www.slack.net/~ant/ */ + +#include +#include "libgme/ay_emu.h" + +CODEC_HEADER + +/* Maximum number of bytes to process in one iteration */ +#define CHUNK_SIZE (1024*2) + +static int16_t samples[CHUNK_SIZE] IBSS_ATTR; +static struct Ay_Emu ay_emu; + +/****************** rockbox interface ******************/ + +static void set_codec_track(int t, int multitrack) { + Ay_start_track(&ay_emu, t); + + /* for loop mode we disable track limits */ + if (!ci->loop_track()) { + Track_set_fade(&ay_emu, Track_get_length( &ay_emu, t ) - 4000, 4000); + } + if (multitrack) ci->set_elapsed(t*1000); /* t is track no to display */ + else ci->set_elapsed(0); +} + +/* this is the codec entry point */ +enum codec_status codec_main(enum codec_entry_call_reason reason) +{ + if (reason == CODEC_LOAD) { + /* we only render 16 bits */ + ci->configure(DSP_SET_SAMPLE_DEPTH, 16); + + /* 44 Khz, Interleaved stereo */ + ci->configure(DSP_SET_FREQUENCY, 44100); + ci->configure(DSP_SET_STEREO_MODE, STEREO_INTERLEAVED); + + Ay_init(&ay_emu); + Ay_set_sample_rate(&ay_emu, 44100); + } + + return CODEC_OK; +} + +/* this is called for each file to process */ +enum codec_status codec_run(void) +{ + blargg_err_t err; + uint8_t *buf; + size_t n; + int track, is_multitrack; + intptr_t param; + uint32_t elapsed_time; + + /* reset values */ + track = is_multitrack = 0; + elapsed_time = 0; + + DEBUGF("AY: next_track\n"); + if (codec_init()) { + return CODEC_ERROR; + } + + codec_set_replaygain(ci->id3); + + /* Read the entire file */ + DEBUGF("AY: request file\n"); + ci->seek_buffer(0); + buf = ci->request_buffer(&n, ci->filesize); + if (!buf || n < (size_t)ci->filesize) { + DEBUGF("AY: file load failed\n"); + return CODEC_ERROR; + } + + if ((err = Ay_load_mem(&ay_emu, buf, ci->filesize))) { + DEBUGF("AY: Ay_load_mem failed (%s)\n", err); + return CODEC_ERROR; + } + + /* Update internal track count */ + if (ay_emu.m3u.size > 0) + ay_emu.track_count = ay_emu.m3u.size; + + /* Check if file has multiple tracks */ + if (ay_emu.track_count > 1) { + is_multitrack = 1; + } + +next_track: + set_codec_track(track, is_multitrack); + + /* The main decoder loop */ + while (1) { + enum codec_command_action action = ci->get_command(¶m); + + if (action == CODEC_ACTION_HALT) + break; + + if (action == CODEC_ACTION_SEEK_TIME) { + if (is_multitrack) { + track = param/1000; + ci->seek_complete(); + if (track >= ay_emu.track_count) break; + goto next_track; + } + + ci->set_elapsed(param); + elapsed_time = param; + Track_seek(&ay_emu, param); + ci->seek_complete(); + + /* Set fade again */ + if (!ci->loop_track()) { + Track_set_fade(&ay_emu, Track_get_length( &ay_emu, track ) - 4000, 4000); + } + } + + /* Generate audio buffer */ + err = Ay_play(&ay_emu, CHUNK_SIZE, samples); + if (err || Track_ended(&ay_emu)) { + track++; + if (track >= ay_emu.track_count) break; + goto next_track; + } + + ci->pcmbuf_insert(samples, NULL, CHUNK_SIZE >> 1); + + /* Set elapsed time for one track files */ + if (!is_multitrack) { + elapsed_time += (CHUNK_SIZE / 2) * 10 / 441; + ci->set_elapsed(elapsed_time); + } + } + + return CODEC_OK; +} diff --git a/lib/rbcodec/codecs/codec_crt0.c b/lib/rbcodec/codecs/codec_crt0.c new file mode 100644 index 0000000000..e3c3321e54 --- /dev/null +++ b/lib/rbcodec/codecs/codec_crt0.c @@ -0,0 +1,74 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2006 Tomasz Malesinski + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include "config.h" +#include "codecs.h" + +struct codec_api *ci DATA_ATTR; + +extern unsigned char plugin_bss_start[]; +extern unsigned char plugin_end_addr[]; + +/* stub, the entry point is called via its reference in __header to + * avoid warning with certain compilers */ +int _start(void) {return 0;} + +enum codec_status codec_start(enum codec_entry_call_reason reason) +{ +#if (CONFIG_PLATFORM & PLATFORM_NATIVE) + if (reason == CODEC_LOAD) + { +#ifdef USE_IRAM + extern char iramcopy[], iramstart[], iramend[], iedata[], iend[]; + size_t iram_size = iramend - iramstart; + size_t ibss_size = iend - iedata; + if (iram_size > 0 || ibss_size > 0) + { + ci->memcpy(iramstart, iramcopy, iram_size); + ci->memset(iedata, 0, ibss_size); + /* make the icache (if it exists) up to date with the new code */ + ci->commit_discard_idcache(); + /* barrier to prevent reordering iram copy and BSS clearing, + * because the BSS segment alias the IRAM copy. + */ + asm volatile ("" ::: "memory"); + } +#endif /* PLUGIN_USE_IRAM */ + ci->memset(plugin_bss_start, 0, plugin_end_addr - plugin_bss_start); + /* Some parts of bss may be used via a no-cache alias (at least + * portalplayer has this). If we don't clear the cache, those aliases + * may read garbage */ + ci->commit_dcache(); + } +#endif /* CONFIG_PLATFORM */ + + /* Note: If for any reason codec_main would not be called with CODEC_LOAD + * because the above code failed then it must not be ever be called with + * any other value and some strategy to avoid doing so must be conceived */ + return codec_main(reason); +} + +#if defined(CPU_ARM) && (CONFIG_PLATFORM & PLATFORM_NATIVE) +void __attribute__((naked)) __div0(void) +{ + asm volatile("bx %0" : : "r"(ci->__div0)); +} +#endif diff --git a/lib/rbcodec/codecs/codecs.h b/lib/rbcodec/codecs/codecs.h new file mode 100644 index 0000000000..bad8cdd469 --- /dev/null +++ b/lib/rbcodec/codecs/codecs.h @@ -0,0 +1,291 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2002 Björn Stenberg + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ +#ifndef _CODECS_H_ +#define _CODECS_H_ + +/* instruct simulator code to not redefine any symbols when compiling codecs. + (the CODEC macro is defined in codecs.make) */ +#ifdef CODEC +#define NO_REDEFINES_PLEASE +#endif + +#include +#include +#include "strlcpy.h" +#include "config.h" +#include "system.h" +#include "metadata.h" +#include "audio.h" +#ifdef RB_PROFILE +#include "profile.h" +#include "thread.h" +#endif +#if (CONFIG_CODEC == SWCODEC) +#ifdef HAVE_RECORDING +#include "pcm_record.h" +#endif +#include "dsp.h" +#include "dsp-util.h" +#endif + +#include "gcc_extensions.h" +#include "load_code.h" + +#ifdef CODEC +#if defined(DEBUG) || defined(SIMULATOR) +#undef DEBUGF +#define DEBUGF ci->debugf +#undef LDEBUGF +#define LDEBUGF ci->debugf +#else +#define DEBUGF(...) +#define LDEBUGF(...) +#endif + +#ifdef ROCKBOX_HAS_LOGF +#undef LOGF +#define LOGF ci->logf +#else +#define LOGF(...) +#endif + +#endif + +/* magic for normal codecs */ +#define CODEC_MAGIC 0x52434F44 /* RCOD */ +/* magic for encoder codecs */ +#define CODEC_ENC_MAGIC 0x52454E43 /* RENC */ + +/* increase this every time the api struct changes */ +#define CODEC_API_VERSION 44 + +/* update this to latest version if a change to the api struct breaks + backwards compatibility (and please take the opportunity to sort in any + new function which are "waiting" at the end of the function table) */ +#define CODEC_MIN_API_VERSION 43 + +/* reasons for calling codec main entrypoint */ +enum codec_entry_call_reason { + CODEC_LOAD = 0, + CODEC_UNLOAD +}; + +/* codec return codes */ +enum codec_status { + CODEC_OK = 0, + CODEC_ERROR = -1, +}; + +/* codec command action codes */ +enum codec_command_action { + CODEC_ACTION_HALT = -1, + CODEC_ACTION_NULL = 0, + CODEC_ACTION_SEEK_TIME = 1, +}; + +/* NOTE: To support backwards compatibility, only add new functions at + the end of the structure. Every time you add a new function, + remember to increase CODEC_API_VERSION. If you make changes to the + existing APIs then also update CODEC_MIN_API_VERSION to current + version + */ +struct codec_api { + off_t filesize; /* Total file length */ + off_t curpos; /* Current buffer position */ + + struct mp3entry *id3; /* TAG metadata pointer */ + int audio_hid; /* Current audio handle */ + + /* The dsp instance to be used for audio output */ + struct dsp_config *dsp; + + /* Returns buffer to malloc array. Only codeclib should need this. */ + void* (*codec_get_buffer)(size_t *size); + /* Insert PCM data into audio buffer for playback. Playback will start + automatically. */ + void (*pcmbuf_insert)(const void *ch1, const void *ch2, int count); + /* Set song position in WPS (value in ms). */ + void (*set_elapsed)(unsigned long value); + + /* Read next amount bytes from file buffer to . + Will return number of bytes read or 0 if end of file. */ + size_t (*read_filebuf)(void *ptr, size_t size); + /* Request pointer to file buffer which can be used to read + amount of data. tells the buffer system + how much data it should try to allocate. If is 0, + end of file is reached. */ + void* (*request_buffer)(size_t *realsize, size_t reqsize); + /* Advance file buffer position by amount of bytes. */ + void (*advance_buffer)(size_t amount); + /* Seek file buffer to position beginning of file. */ + bool (*seek_buffer)(size_t newpos); + /* Codec should call this function when it has done the seeking. */ + void (*seek_complete)(void); + /* Update the current position */ + void (*set_offset)(size_t value); + /* Configure different codec buffer parameters. */ + void (*configure)(int setting, intptr_t value); + /* Obtain command action on what to do next */ + enum codec_command_action (*get_command)(intptr_t *param); + /* Determine whether the track should be looped, if applicable. */ + bool (*loop_track)(void); + + /* kernel/ system */ +#if defined(CPU_ARM) && CONFIG_PLATFORM & PLATFORM_NATIVE + void (*__div0)(void); +#endif + unsigned (*sleep)(unsigned ticks); + void (*yield)(void); + +#if NUM_CORES > 1 + unsigned int + (*create_thread)(void (*function)(void), void* stack, + size_t stack_size, unsigned flags, const char *name + IF_PRIO(, int priority) + IF_COP(, unsigned int core)); + + void (*thread_thaw)(unsigned int thread_id); + void (*thread_wait)(unsigned int thread_id); + void (*semaphore_init)(struct semaphore *s, int max, int start); + int (*semaphore_wait)(struct semaphore *s, int timeout); + void (*semaphore_release)(struct semaphore *s); +#endif /* NUM_CORES */ + + void (*commit_dcache)(void); + void (*commit_discard_dcache)(void); + + /* strings and memory */ + char* (*strcpy)(char *dst, const char *src); + size_t (*strlen)(const char *str); + int (*strcmp)(const char *, const char *); + char *(*strcat)(char *s1, const char *s2); + void* (*memset)(void *dst, int c, size_t length); + void* (*memcpy)(void *out, const void *in, size_t n); + void* (*memmove)(void *out, const void *in, size_t n); + int (*memcmp)(const void *s1, const void *s2, size_t n); + void *(*memchr)(const void *s1, int c, size_t n); + +#if defined(DEBUG) || defined(SIMULATOR) + void (*debugf)(const char *fmt, ...) ATTRIBUTE_PRINTF(1, 2); +#endif +#ifdef ROCKBOX_HAS_LOGF + void (*logf)(const char *fmt, ...) ATTRIBUTE_PRINTF(1, 2); +#endif + + /* Tremor requires qsort */ + void (*qsort)(void *base, size_t nmemb, size_t size, + int(*compar)(const void *, const void *)); + +#ifdef RB_PROFILE + void (*profile_thread)(void); + void (*profstop)(void); + void (*profile_func_enter)(void *this_fn, void *call_site); + void (*profile_func_exit)(void *this_fn, void *call_site); +#endif + +#ifdef HAVE_RECORDING + void (*enc_get_inputs)(struct enc_inputs *inputs); + void (*enc_set_parameters)(struct enc_parameters *params); + struct enc_chunk_hdr * (*enc_get_chunk)(void); + void (*enc_finish_chunk)(void); + unsigned char * (*enc_get_pcm_data)(size_t size); + size_t (*enc_unget_pcm_data)(size_t size); + + /* file */ + int (*open)(const char* pathname, int flags, ...); + int (*close)(int fd); + ssize_t (*read)(int fd, void* buf, size_t count); + off_t (*lseek)(int fd, off_t offset, int whence); + ssize_t (*write)(int fd, const void* buf, size_t count); + int (*round_value_to_list32)(unsigned long value, + const unsigned long list[], + int count, + bool signd); +#endif + + /* new stuff at the end, sort into place next time + the API gets incompatible */ + void (*commit_discard_idcache)(void); +}; + +/* codec header */ +struct codec_header { + struct lc_header lc_hdr; /* must be first */ + enum codec_status(*entry_point)(enum codec_entry_call_reason reason); + enum codec_status(*run_proc)(void); + struct codec_api **api; +}; + +#ifdef CODEC +#if (CONFIG_PLATFORM & PLATFORM_NATIVE) +/* plugin_* is correct, codecs use the plugin linker script */ +extern unsigned char plugin_start_addr[]; +extern unsigned char plugin_end_addr[]; +/* decoders */ +#define CODEC_HEADER \ + const struct codec_header __header \ + __attribute__ ((section (".header")))= { \ + { CODEC_MAGIC, TARGET_ID, CODEC_API_VERSION, \ + plugin_start_addr, plugin_end_addr }, codec_start, \ + codec_run, &ci }; +/* encoders */ +#define CODEC_ENC_HEADER \ + const struct codec_header __header \ + __attribute__ ((section (".header")))= { \ + { CODEC_ENC_MAGIC, TARGET_ID, CODEC_API_VERSION, \ + plugin_start_addr, plugin_end_addr }, codec_start, \ + codec_run, &ci }; + +#else /* def SIMULATOR */ +/* decoders */ +#define CODEC_HEADER \ + const struct codec_header __header \ + __attribute__((visibility("default"))) = { \ + { CODEC_MAGIC, TARGET_ID, CODEC_API_VERSION, NULL, NULL }, \ + codec_start, codec_run, &ci }; +/* encoders */ +#define CODEC_ENC_HEADER \ + const struct codec_header __header = { \ + { CODEC_ENC_MAGIC, TARGET_ID, CODEC_API_VERSION, NULL, NULL }, \ + codec_start, codec_run, &ci }; +#endif /* SIMULATOR */ +#endif /* CODEC */ + +/* create full codec path from root filenames in audio_formats[] + assumes buffer size is MAX_PATH */ +void codec_get_full_path(char *path, const char *codec_root_fn); + +/* Returns pointer to and size of free codec RAM */ +void *codec_get_buffer_callback(size_t *size); + +/* defined by the codec loader (codec.c) */ +int codec_load_buf(int hid, struct codec_api *api); +int codec_load_file(const char* codec, struct codec_api *api); +int codec_run_proc(void); +int codec_halt(void); +int codec_close(void); + +/* defined by the codec */ +enum codec_status codec_start(enum codec_entry_call_reason reason); +enum codec_status codec_main(enum codec_entry_call_reason reason); +enum codec_status codec_run(void); + +#endif /* _CODECS_H_ */ diff --git a/lib/rbcodec/codecs/codecs.make b/lib/rbcodec/codecs/codecs.make new file mode 100644 index 0000000000..919aef2024 --- /dev/null +++ b/lib/rbcodec/codecs/codecs.make @@ -0,0 +1,206 @@ +# __________ __ ___. +# Open \______ \ ____ ____ | | _\_ |__ _______ ___ +# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / +# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < +# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ +# \/ \/ \/ \/ \/ +# $Id$ +# + +CODECDIR = $(RBCODEC_BLD)/codecs +CODECS_SRC := $(call preprocess, $(RBCODECLIB_DIR)/codecs/SOURCES) +OTHER_SRC += $(CODECS_SRC) + +CODECS := $(CODECS_SRC:.c=.codec) +CODECS := $(subst $(RBCODECLIB_DIR),$(RBCODEC_BLD),$(CODECS)) + +# the codec helper library +include $(RBCODECLIB_DIR)/codecs/lib/libcodec.make +OTHER_INC += -I$(RBCODECLIB_DIR)/codecs/lib + +# extra libraries +CODEC_LIBS := $(EXTRA_LIBS) $(CODECLIB) + +# the codec libraries +include $(RBCODECLIB_DIR)/codecs/demac/libdemac.make +include $(RBCODECLIB_DIR)/codecs/liba52/liba52.make +include $(RBCODECLIB_DIR)/codecs/libalac/libalac.make +include $(RBCODECLIB_DIR)/codecs/libasap/libasap.make +include $(RBCODECLIB_DIR)/codecs/libasf/libasf.make +include $(RBCODECLIB_DIR)/codecs/libfaad/libfaad.make +include $(RBCODECLIB_DIR)/codecs/libffmpegFLAC/libffmpegFLAC.make +include $(RBCODECLIB_DIR)/codecs/libm4a/libm4a.make +include $(RBCODECLIB_DIR)/codecs/libmad/libmad.make +include $(RBCODECLIB_DIR)/codecs/libmusepack/libmusepack.make +include $(RBCODECLIB_DIR)/codecs/libspc/libspc.make +include $(RBCODECLIB_DIR)/codecs/libspeex/libspeex.make +include $(RBCODECLIB_DIR)/codecs/libtremor/libtremor.make +include $(RBCODECLIB_DIR)/codecs/libwavpack/libwavpack.make +include $(RBCODECLIB_DIR)/codecs/libwma/libwma.make +include $(RBCODECLIB_DIR)/codecs/libwmapro/libwmapro.make +include $(RBCODECLIB_DIR)/codecs/libcook/libcook.make +include $(RBCODECLIB_DIR)/codecs/librm/librm.make +include $(RBCODECLIB_DIR)/codecs/libatrac/libatrac.make +include $(RBCODECLIB_DIR)/codecs/libpcm/libpcm.make +include $(RBCODECLIB_DIR)/codecs/libtta/libtta.make +include $(RBCODECLIB_DIR)/codecs/libgme/libay.make +include $(RBCODECLIB_DIR)/codecs/libgme/libgbs.make +include $(RBCODECLIB_DIR)/codecs/libgme/libhes.make +include $(RBCODECLIB_DIR)/codecs/libgme/libnsf.make +include $(RBCODECLIB_DIR)/codecs/libgme/libsgc.make +include $(RBCODECLIB_DIR)/codecs/libgme/libvgm.make +include $(RBCODECLIB_DIR)/codecs/libgme/libkss.make +include $(RBCODECLIB_DIR)/codecs/libgme/libemu2413.make + +# compile flags for codecs +CODECFLAGS = $(CFLAGS) $(RBCODEC_CFLAGS) -fstrict-aliasing \ + -I$(RBCODECLIB_DIR)/codecs -I$(RBCODECLIB_DIR)/codecs/lib -DCODEC + +# set CODECFLAGS per codec lib, since gcc takes the last -Ox and the last +# in a -ffoo -fno-foo pair, there is no need to filter them out +$(A52LIB) : CODECFLAGS += -O1 +$(ALACLIB) : CODECFLAGS += -O1 +$(ASAPLIB) : CODECFLAGS += -O1 +$(ASFLIB) : CODECFLAGS += -O2 +$(ATRACLIB) : CODECFLAGS += -O1 +$(AYLIB) : CODECFLAGS += -O2 +$(COOKLIB): CODECFLAGS += -O1 +$(DEMACLIB) : CODECFLAGS += -O3 +$(FAADLIB) : CODECFLAGS += -O2 +$(FFMPEGFLACLIB) : CODECFLAGS += -O2 +$(GBSLIB) : CODECFLAGS += -O2 +$(HESLIB) : CODECFLAGS += -O2 +$(KSSLIB) : CODECFLAGS += -O2 +$(M4ALIB) : CODECFLAGS += -O3 +$(MUSEPACKLIB) : CODECFLAGS += -O1 +$(NSFLIB) : CODECFLAGS += -O2 +$(PCMSLIB) : CODECFLAGS += -O1 +$(RMLIB) : CODECFLAGS += -O3 +$(SGCLIB) : CODECFLAGS += -O2 +$(SPCLIB) : CODECFLAGS += -O1 +$(TREMORLIB) : CODECFLAGS += -O2 +$(TTALIB) : CODECFLAGS += -O2 +$(VGMLIB) : CODECFLAGS += -O2 +$(EMU2413LIB) : CODECFLAGS += -O3 +$(WAVPACKLIB) : CODECFLAGS += -O1 +$(WMALIB) : CODECFLAGS += -O2 +$(WMAPROLIB) : CODECFLAGS += -O1 +$(WMAVOICELIB) : CODECFLAGS += -O1 + +# fine-tuning of CODECFLAGS per cpu arch +ifeq ($(ARCH),arch_arm) + # redo per arm generation + $(ALACLIB) : CODECFLAGS += -O2 + $(AYLIB) : CODECFLAGS += -O1 + $(GBSLIB) : CODECFLAGS += -O1 + $(HESLIB) : CODECFLAGS += -O1 + $(KSSLIB) : CODECFLAGS += -O1 + $(NSFLIB) : CODECFLAGS += -O1 + $(SGCLIB) : CODECFLAGS += -O1 + $(VGMLIB) : CODECFLAGS += -O1 + $(EMU2413LIB) : CODECFLAGS += -O3 + $(WAVPACKLIB) : CODECFLAGS += -O3 +else ifeq ($(ARCH),arch_m68k) + $(A52LIB) : CODECFLAGS += -O2 + $(ASFLIB) : CODECFLAGS += -O3 + $(ATRACLIB) : CODECFLAGS += -O2 + $(COOKLIB): CODECFLAGS += -O2 + $(DEMACLIB) : CODECFLAGS += -O2 + $(SPCLIB) : CODECFLAGS += -O3 + $(WMAPROLIB) : CODECFLAGS += -O3 + $(WMAVOICELIB) : CODECFLAGS += -O2 +endif + +ifeq ($(MEMORYSIZE),2) + $(ASFLIB) : CODECFLAGS += -Os + $(WMALIB) : CODECFLAGS += -Os +endif + +ifndef APP_TYPE + CONFIGFILE := $(FIRMDIR)/export/config/$(MODELNAME).h + CODEC_LDS := $(APPSDIR)/plugins/plugin.lds # codecs and plugins use same file + CODECLINK_LDS := $(CODECDIR)/codec.link +endif + +CODEC_CRT0 := $(CODECDIR)/codec_crt0.o + +$(CODECS): $(CODEC_CRT0) $(CODECLINK_LDS) + +$(CODECLINK_LDS): $(CODEC_LDS) $(CONFIGFILE) + $(call PRINTS,PP $(@F)) + $(shell mkdir -p $(dir $@)) + $(call preprocess2file, $<, $@, -DCODEC) + +# codec/library dependencies +$(CODECDIR)/spc.codec : $(CODECDIR)/libspc.a +$(CODECDIR)/mpa.codec : $(CODECDIR)/libmad.a +$(CODECDIR)/a52.codec : $(CODECDIR)/liba52.a +$(CODECDIR)/flac.codec : $(CODECDIR)/libffmpegFLAC.a +$(CODECDIR)/vorbis.codec : $(CODECDIR)/libtremor.a +$(CODECDIR)/speex.codec : $(CODECDIR)/libspeex.a +$(CODECDIR)/mpc.codec : $(CODECDIR)/libmusepack.a +$(CODECDIR)/wavpack.codec : $(CODECDIR)/libwavpack.a +$(CODECDIR)/alac.codec : $(CODECDIR)/libalac.a $(CODECDIR)/libm4a.a +$(CODECDIR)/aac.codec : $(CODECDIR)/libfaad.a $(CODECDIR)/libm4a.a +$(CODECDIR)/shorten.codec : $(CODECDIR)/libffmpegFLAC.a +$(CODECDIR)/ape-pre.map : $(CODECDIR)/libdemac-pre.a +$(CODECDIR)/ape.codec : $(CODECDIR)/libdemac.a +$(CODECDIR)/wma.codec : $(CODECDIR)/libwma.a $(CODECDIR)/libasf.a +$(CODECDIR)/wmapro.codec : $(CODECDIR)/libwmapro.a $(CODECDIR)/libasf.a +$(CODECDIR)/wavpack_enc.codec: $(CODECDIR)/libwavpack.a +$(CODECDIR)/asap.codec : $(CODECDIR)/libasap.a +$(CODECDIR)/cook.codec : $(CODECDIR)/libcook.a $(CODECDIR)/librm.a +$(CODECDIR)/raac.codec : $(CODECDIR)/libfaad.a $(CODECDIR)/librm.a +$(CODECDIR)/a52_rm.codec : $(CODECDIR)/liba52.a $(CODECDIR)/librm.a +$(CODECDIR)/atrac3_rm.codec : $(CODECDIR)/libatrac.a $(CODECDIR)/librm.a +$(CODECDIR)/atrac3_oma.codec : $(CODECDIR)/libatrac.a +$(CODECDIR)/aiff.codec : $(CODECDIR)/libpcm.a +$(CODECDIR)/wav.codec : $(CODECDIR)/libpcm.a +$(CODECDIR)/smaf.codec : $(CODECDIR)/libpcm.a +$(CODECDIR)/au.codec : $(CODECDIR)/libpcm.a +$(CODECDIR)/vox.codec : $(CODECDIR)/libpcm.a +$(CODECDIR)/wav64.codec : $(CODECDIR)/libpcm.a +$(CODECDIR)/tta.codec : $(CODECDIR)/libtta.a +$(CODECDIR)/ay.codec : $(CODECDIR)/libay.a +$(CODECDIR)/gbs.codec : $(CODECDIR)/libgbs.a +$(CODECDIR)/hes.codec : $(CODECDIR)/libhes.a +$(CODECDIR)/nsf.codec : $(CODECDIR)/libnsf.a $(CODECDIR)/libemu2413.a +$(CODECDIR)/sgc.codec : $(CODECDIR)/libsgc.a $(CODECDIR)/libemu2413.a +$(CODECDIR)/vgm.codec : $(CODECDIR)/libvgm.a $(CODECDIR)/libemu2413.a +$(CODECDIR)/kss.codec : $(CODECDIR)/libkss.a $(CODECDIR)/libemu2413.a + +$(CODECS): $(CODEC_LIBS) # this must be last in codec dependency list + +# pattern rule for compiling codecs +$(CODECDIR)/%.o: $(RBCODECLIB_DIR)/codecs/%.c + $(SILENT)mkdir -p $(dir $@) + $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) \ + -I$(dir $<) $(CODECFLAGS) -c $< -o $@ + +# pattern rule for compiling codecs +$(CODECDIR)/%.o: $(RBCODECLIB_DIR)/codecs/%.S + $(SILENT)mkdir -p $(dir $@) + $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) \ + -I$(dir $<) $(CODECFLAGS) $(ASMFLAGS) -c $< -o $@ + +ifdef APP_TYPE + CODECLDFLAGS = $(SHARED_LDFLAG) -Wl,--gc-sections -Wl,-Map,$(CODECDIR)/$*.map + CODECFLAGS += $(SHARED_CFLAGS) # <-- from Makefile +else + CODECLDFLAGS = -T$(CODECLINK_LDS) -Wl,--gc-sections -Wl,-Map,$(CODECDIR)/$*.map + CODECFLAGS += -UDEBUG -DNDEBUG +endif +CODECLDFLAGS += $(GLOBAL_LDOPTS) + +$(CODECDIR)/%-pre.map: $(CODEC_CRT0) $(CODECLINK_LDS) $(CODECDIR)/%.o $(CODECS_LIBS) + $(call PRINTS,LD $(@F))$(CC) $(CODECFLAGS) -o $(CODECDIR)/$*-pre.elf \ + $(filter %.o, $^) \ + $(filter-out $(CODECLIB),$(filter %.a, $+)) $(CODECLIB) \ + -lgcc $(subst .map,-pre.map,$(CODECLDFLAGS)) + +$(CODECDIR)/%.codec: $(CODECDIR)/%.o + $(call PRINTS,LD $(@F))$(CC) $(CODECFLAGS) -o $(CODECDIR)/$*.elf \ + $(filter %.o, $^) \ + $(filter %.a, $+) \ + -lgcc $(CODECLDFLAGS) + $(SILENT)$(call objcopy,$(CODECDIR)/$*.elf,$@) diff --git a/lib/rbcodec/codecs/cook.c b/lib/rbcodec/codecs/cook.c new file mode 100644 index 0000000000..55188aad36 --- /dev/null +++ b/lib/rbcodec/codecs/cook.c @@ -0,0 +1,202 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2009 Mohamed Tarek + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include + +#include "logf.h" +#include "codeclib.h" +#include "inttypes.h" +#include "libcook/cook.h" + +CODEC_HEADER + +static RMContext rmctx IBSS_ATTR_COOK_LARGE_IRAM; +static RMPacket pkt IBSS_ATTR_COOK_LARGE_IRAM; +static COOKContext q IBSS_ATTR; +static int32_t rm_outbuf[2048] IBSS_ATTR_COOK_LARGE_IRAM MEM_ALIGN_ATTR; + +static void init_rm(RMContext *rmctx) +{ + memcpy(rmctx, (void*)(( (intptr_t)ci->id3->id3v2buf + 3 ) &~ 3), sizeof(RMContext)); +} + +/* this is the codec entry point */ +enum codec_status codec_main(enum codec_entry_call_reason reason) +{ + /* Nothing to do */ + return CODEC_OK; + (void)reason; +} + +/* this is called for each file to process */ +enum codec_status codec_run(void) +{ + static size_t buff_size; + int datasize, res, consumed, i, time_offset; + uint8_t *bit_buffer; + uint16_t fs,sps,h; + uint32_t packet_count; + int scrambling_unit_size, num_units; + size_t resume_offset; + intptr_t param = 0; + enum codec_command_action action = CODEC_ACTION_NULL; + + if (codec_init()) { + DEBUGF("codec init failed\n"); + return CODEC_ERROR; + } + + resume_offset = ci->id3->offset; + + codec_set_replaygain(ci->id3); + ci->memset(&rmctx,0,sizeof(RMContext)); + ci->memset(&pkt,0,sizeof(RMPacket)); + ci->memset(&q,0,sizeof(COOKContext)); + + ci->seek_buffer(0); + + init_rm(&rmctx); + + ci->configure(DSP_SET_FREQUENCY, ci->id3->frequency); + /* cook's sample representation is 21.11 + * DSP_SET_SAMPLE_DEPTH = 11 (FRACT) + 16 (NATIVE) - 1 (SIGN) = 26 */ + ci->configure(DSP_SET_SAMPLE_DEPTH, 26); + ci->configure(DSP_SET_STEREO_MODE, rmctx.nb_channels == 1 ? + STEREO_MONO : STEREO_NONINTERLEAVED); + + packet_count = rmctx.nb_packets; + rmctx.audio_framesize = rmctx.block_align; + rmctx.block_align = rmctx.sub_packet_size; + fs = rmctx.audio_framesize; + sps= rmctx.block_align; + h = rmctx.sub_packet_h; + scrambling_unit_size = h * (fs + PACKET_HEADER_SIZE); + + res =cook_decode_init(&rmctx, &q); + if(res < 0) { + DEBUGF("failed to initialize cook decoder\n"); + return CODEC_ERROR; + } + + /* check for a mid-track resume and force a seek time accordingly */ + if(resume_offset > rmctx.data_offset + DATA_HEADER_SIZE) { + resume_offset -= rmctx.data_offset + DATA_HEADER_SIZE; + num_units = (int)resume_offset / scrambling_unit_size; + /* put number of subpackets to skip in resume_offset */ + resume_offset /= (sps + PACKET_HEADER_SIZE); + param = (int)resume_offset * ((sps * 8 * 1000)/rmctx.bit_rate); + action = CODEC_ACTION_SEEK_TIME; + } + else { + ci->set_elapsed(0); + } + + ci->advance_buffer(rmctx.data_offset + DATA_HEADER_SIZE); + + /* The main decoder loop */ +seek_start : + while(packet_count) + { + bit_buffer = (uint8_t *) ci->request_buffer(&buff_size, scrambling_unit_size); + consumed = rm_get_packet(&bit_buffer, &rmctx, &pkt); + if(consumed < 0) { + DEBUGF("rm_get_packet failed\n"); + return CODEC_ERROR; + } + + for(i = 0; i < rmctx.audio_pkt_cnt*(fs/sps) ; i++) + { + if (action == CODEC_ACTION_NULL) + action = ci->get_command(¶m); + + if (action == CODEC_ACTION_HALT) + return CODEC_OK; + + if (action == CODEC_ACTION_SEEK_TIME) { + /* Do not allow seeking beyond the file's length */ + if ((unsigned) param > ci->id3->length) { + ci->set_elapsed(ci->id3->length); + ci->seek_complete(); + return CODEC_OK; + } + + ci->seek_buffer(rmctx.data_offset + DATA_HEADER_SIZE); + packet_count = rmctx.nb_packets; + rmctx.audio_pkt_cnt = 0; + rmctx.frame_number = 0; + + /* Seek to the start of the track */ + if (param == 0) { + ci->set_elapsed(0); + ci->seek_complete(); + action = CODEC_ACTION_NULL; + goto seek_start; + } + num_units = (param/(sps*1000*8/rmctx.bit_rate))/(h*(fs/sps)); + ci->seek_buffer(rmctx.data_offset + DATA_HEADER_SIZE + consumed * num_units); + bit_buffer = (uint8_t *) ci->request_buffer(&buff_size, scrambling_unit_size); + consumed = rm_get_packet(&bit_buffer, &rmctx, &pkt); + if(consumed < 0) { + DEBUGF("rm_get_packet failed\n"); + ci->seek_complete(); + return CODEC_ERROR; + } + packet_count = rmctx.nb_packets - rmctx.audio_pkt_cnt * num_units; + rmctx.frame_number = (param/(sps*1000*8/rmctx.bit_rate)); + while(rmctx.audiotimestamp > (unsigned) param) { + rmctx.audio_pkt_cnt = 0; + ci->seek_buffer(rmctx.data_offset + DATA_HEADER_SIZE + consumed * (num_units-1)); + bit_buffer = (uint8_t *) ci->request_buffer(&buff_size, scrambling_unit_size); + consumed = rm_get_packet(&bit_buffer, &rmctx, &pkt); + packet_count += rmctx.audio_pkt_cnt; + num_units--; + } + time_offset = param - rmctx.audiotimestamp; + i = (time_offset/((sps * 8 * 1000)/rmctx.bit_rate)); + ci->set_elapsed(rmctx.audiotimestamp+(1000*8*sps/rmctx.bit_rate)*i); + ci->seek_complete(); + } + + action = CODEC_ACTION_NULL; + + res = cook_decode_frame(&rmctx,&q, rm_outbuf, &datasize, pkt.frames[i], rmctx.block_align); + rmctx.frame_number++; + + /* skip the first two frames; no valid audio */ + if(rmctx.frame_number < 3) continue; + + if(res != rmctx.block_align) { + DEBUGF("codec error\n"); + return CODEC_ERROR; + } + + ci->pcmbuf_insert(rm_outbuf, + rm_outbuf+q.samples_per_channel, + q.samples_per_channel); + ci->set_elapsed(rmctx.audiotimestamp+(1000*8*sps/rmctx.bit_rate)*i); + } + packet_count -= rmctx.audio_pkt_cnt; + rmctx.audio_pkt_cnt = 0; + ci->advance_buffer(consumed); + } + + return CODEC_OK; +} diff --git a/lib/rbcodec/codecs/demac/COPYING b/lib/rbcodec/codecs/demac/COPYING new file mode 100644 index 0000000000..d511905c16 --- /dev/null +++ b/lib/rbcodec/codecs/demac/COPYING @@ -0,0 +1,339 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. diff --git a/lib/rbcodec/codecs/demac/Makefile b/lib/rbcodec/codecs/demac/Makefile new file mode 100644 index 0000000000..7843be6e49 --- /dev/null +++ b/lib/rbcodec/codecs/demac/Makefile @@ -0,0 +1,42 @@ +# $Id$ + +FILTERS = libdemac/filter_16_11.o libdemac/filter_64_11.o libdemac/filter_256_13.o libdemac/filter_32_10.o libdemac/filter_1280_15.o +LIBOBJS = libdemac/parser.o libdemac/decoder.o libdemac/entropy.o libdemac/predictor.o libdemac/crc.o $(FILTERS) +OBJS = demac.o wavwrite.o $(LIBOBJS) + +CFLAGS = -Wall -g -O3 -Ilibdemac + +ifeq ($(findstring CYGWIN,$(shell uname)),CYGWIN) +EXT = .exe +CROSS = +CFLAGS += -mno-cygwin +else + ifdef WIN + EXT = .exe + CROSS = i586-mingw32msvc- + else + EXT = + CROSS = + endif +endif + +CC = $(CROSS)gcc +STRIP = $(CROSS)strip +OUTPUT = demac$(EXT) + +all: $(OUTPUT) + +$(OUTPUT): $(OBJS) + $(CC) $(CFLAGS) -o $(OUTPUT) $(OBJS) + +.c.o : + $(CC) $(CFLAGS) $(INC) -c -o $@ $< + +libdemac/filter_16_11.o: libdemac/filter.c +libdemac/filter_64_11.o: libdemac/filter.c +libdemac/filter_256_13.o: libdemac/filter.c +libdemac/filter_1280_15.o: libdemac/filter.c +libdemac/filter_32_10.o: libdemac/filter.c + +clean: + rm -f $(OUTPUT) $(OBJS) *~ */*~ diff --git a/lib/rbcodec/codecs/demac/README b/lib/rbcodec/codecs/demac/README new file mode 100644 index 0000000000..73a1c22485 --- /dev/null +++ b/lib/rbcodec/codecs/demac/README @@ -0,0 +1,69 @@ +demac - a decoder for Monkey's Audio files. + +Introduction + +demac is an implementation in portable ANSI C of a decoder for the +Monkey's Audio lossless compression format. It has the following +features: + + * Open source (GNU GPL) + * Written in portable ANSI C + * Designed for use on low memory and embedded devices. All internal + buffers are statically declared - the core library doesn't require + malloc/free. This has the disadvantage that the library isn't + re-entrant. + + +Compatibility + + +libdemac is still in the early stages of development but has been +relatively well tested with v3.99 files at all compression levels. + +v3.97 files have received less testing - 16-bit files seem to work, +but 24-bit files are causing problems in the range decoder. + +Files earlier than v3.97 are not supported by libdemac, but support +might be added in the future. + + +Source Code + +The source code in this directory is structured as follows: + +demac/Makefile - Makefile for the standalone demac decoder +demac/demac.c - Simple standalone test program to decoder an APE file to WAV +demac/wavwrite.[ch] - Helper functions for demac.c +demac/libdemac/Makefile - A Makefile for use in Rockbox +demac/libdemac/*.[ch] - The main libdemac code + + +Latest Version + +The latest version of demac and libdemac can always be found in the +"lib/rbcodec/codecs/demac/" directory in the Rockbox source. You can check +this out from svn with the command: + +svn co svn://svn.rockbox.org/rockbox/trunk/lib/rbcodec/codecs/demac demac + +Or browse the source code online here: + +http://svn.rockbox.org/viewvc.cgi/trunk/lib/rbcodec/codecs/demac + + + +Acknowledgements + +Thanks to Matt. T. Ashland for writing Monkey's Audio. His website +can be found here: http://www.monkeysaudio.com + + +Copyright and license + + +libdemac is (C) 2007 Dave Chapman and is licensed under the GNU +GPL. See the COPYING file in this directory. + +The exception is the majority of rangecoding.h, which is (C) 1997, +1998, 1999, 2000 Michael Schindler and is also licensed under the GPL. +See that source file for full details. diff --git a/lib/rbcodec/codecs/demac/demac.c b/lib/rbcodec/codecs/demac/demac.c new file mode 100644 index 0000000000..3e97fff2c9 --- /dev/null +++ b/lib/rbcodec/codecs/demac/demac.c @@ -0,0 +1,281 @@ +/* + +demac - A Monkey's Audio decoder + +$Id$ + +Copyright (C) Dave Chapman 2007 + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA + +*/ + +/* + +This example is intended to demonstrate how the decoder can be used in +embedded devices - there is no usage of dynamic memory (i.e. no +malloc/free) and small buffer sizes are chosen to minimise both the +memory usage and decoding latency. + +This implementation requires the following memory and supports decoding of all APE files up to 24-bit Stereo. + +32768 - data from the input stream to be presented to the decoder in one contiguous chunk. +18432 - decoding buffer (left channel) +18432 - decoding buffer (right channel) + +17408+5120+2240 - buffers used for filter histories (compression levels 2000-5000) + +In addition, this example uses a static 27648 byte buffer as temporary +storage for outputting the data to a WAV file but that could be +avoided by writing the decoded data one sample at a time. + +*/ + +#include +#include +#include +#include +#include +#include +#include + +#include "demac.h" +#include "wavwrite.h" + +#ifndef __WIN32__ +#define O_BINARY 0 +#endif + +#define CALC_CRC 1 + +#define BLOCKS_PER_LOOP 4608 +#define MAX_CHANNELS 2 +#define MAX_BYTESPERSAMPLE 3 + +#define INPUT_CHUNKSIZE (32*1024) + +#ifndef MIN +#define MIN(a,b) ((a) < (b) ? (a) : (b)) +#endif + + +/* 4608*2*3 = 27648 bytes */ +static unsigned char wavbuffer[BLOCKS_PER_LOOP*MAX_CHANNELS*MAX_BYTESPERSAMPLE]; + +/* 4608*4 = 18432 bytes per channel */ +static int32_t decoded0[BLOCKS_PER_LOOP]; +static int32_t decoded1[BLOCKS_PER_LOOP]; + +/* We assume that 32KB of compressed data is enough to extract up to + 27648 bytes of decompressed data. */ + +static unsigned char inbuffer[INPUT_CHUNKSIZE]; + +int ape_decode(char* infile, char* outfile) +{ + int fd; + int fdwav; + int currentframe; + int nblocks; + int bytesconsumed; + struct ape_ctx_t ape_ctx; + int i, n; + unsigned char* p; + int bytesinbuffer; + int blockstodecode; + int res; + int firstbyte; + int16_t sample16; + int32_t sample32; + uint32_t frame_crc; + int crc_errors = 0; + + fd = open(infile,O_RDONLY|O_BINARY); + if (fd < 0) return -1; + + /* Read the file headers to populate the ape_ctx struct */ + if (ape_parseheader(fd,&ape_ctx) < 0) { + printf("Cannot read header\n"); + close(fd); + return -1; + } + + if ((ape_ctx.fileversion < APE_MIN_VERSION) || (ape_ctx.fileversion > APE_MAX_VERSION)) { + printf("Unsupported file version - %.2f\n", ape_ctx.fileversion/1000.0); + close(fd); + return -2; + } + + //ape_dumpinfo(&ape_ctx); + + printf("Decoding file - v%.2f, compression level %d\n",ape_ctx.fileversion/1000.0,ape_ctx.compressiontype); + + /* Open the WAV file and write a canonical 44-byte WAV header + based on the audio format information in the ape_ctx struct. + + NOTE: This example doesn't write the original WAV header and + tail data which are (optionally) stored in the APE file. + */ + fdwav = open_wav(&ape_ctx,outfile); + + currentframe = 0; + + /* Initialise the buffer */ + lseek(fd, ape_ctx.firstframe, SEEK_SET); + bytesinbuffer = read(fd, inbuffer, INPUT_CHUNKSIZE); + firstbyte = 3; /* Take account of the little-endian 32-bit byte ordering */ + + /* The main decoding loop - we decode the frames a small chunk at a time */ + while (currentframe < ape_ctx.totalframes) + { + /* Calculate how many blocks there are in this frame */ + if (currentframe == (ape_ctx.totalframes - 1)) + nblocks = ape_ctx.finalframeblocks; + else + nblocks = ape_ctx.blocksperframe; + + ape_ctx.currentframeblocks = nblocks; + + /* Initialise the frame decoder */ + init_frame_decoder(&ape_ctx, inbuffer, &firstbyte, &bytesconsumed); + + /* Update buffer */ + memmove(inbuffer,inbuffer + bytesconsumed, bytesinbuffer - bytesconsumed); + bytesinbuffer -= bytesconsumed; + + n = read(fd, inbuffer + bytesinbuffer, INPUT_CHUNKSIZE - bytesinbuffer); + bytesinbuffer += n; + +#if CALC_CRC + frame_crc = ape_initcrc(); +#endif + + /* Decode the frame a chunk at a time */ + while (nblocks > 0) + { + blockstodecode = MIN(BLOCKS_PER_LOOP, nblocks); + + if ((res = decode_chunk(&ape_ctx, inbuffer, &firstbyte, + &bytesconsumed, + decoded0, decoded1, + blockstodecode)) < 0) + { + /* Frame decoding error, abort */ + close(fd); + return res; + } + + /* Convert the output samples to WAV format and write to output file */ + p = wavbuffer; + if (ape_ctx.bps == 8) { + for (i = 0 ; i < blockstodecode ; i++) + { + /* 8 bit WAV uses unsigned samples */ + *(p++) = (decoded0[i] + 0x80) & 0xff; + + if (ape_ctx.channels == 2) { + *(p++) = (decoded1[i] + 0x80) & 0xff; + } + } + } else if (ape_ctx.bps == 16) { + for (i = 0 ; i < blockstodecode ; i++) + { + sample16 = decoded0[i]; + *(p++) = sample16 & 0xff; + *(p++) = (sample16 >> 8) & 0xff; + + if (ape_ctx.channels == 2) { + sample16 = decoded1[i]; + *(p++) = sample16 & 0xff; + *(p++) = (sample16 >> 8) & 0xff; + } + } + } else if (ape_ctx.bps == 24) { + for (i = 0 ; i < blockstodecode ; i++) + { + sample32 = decoded0[i]; + *(p++) = sample32 & 0xff; + *(p++) = (sample32 >> 8) & 0xff; + *(p++) = (sample32 >> 16) & 0xff; + + if (ape_ctx.channels == 2) { + sample32 = decoded1[i]; + *(p++) = sample32 & 0xff; + *(p++) = (sample32 >> 8) & 0xff; + *(p++) = (sample32 >> 16) & 0xff; + } + } + } + +#if CALC_CRC + frame_crc = ape_updatecrc(wavbuffer, p - wavbuffer, frame_crc); +#endif + write(fdwav,wavbuffer,p - wavbuffer); + + /* Update the buffer */ + memmove(inbuffer,inbuffer + bytesconsumed, bytesinbuffer - bytesconsumed); + bytesinbuffer -= bytesconsumed; + + n = read(fd, inbuffer + bytesinbuffer, INPUT_CHUNKSIZE - bytesinbuffer); + bytesinbuffer += n; + + /* Decrement the block count */ + nblocks -= blockstodecode; + } + +#if CALC_CRC + frame_crc = ape_finishcrc(frame_crc); + + if (ape_ctx.CRC != frame_crc) + { + fprintf(stderr,"CRC error in frame %d\n",currentframe); + crc_errors++; + } +#endif + + currentframe++; + } + + close(fd); + close(fdwav); + + if (crc_errors > 0) + return -1; + else + return 0; +} + +int main(int argc, char* argv[]) +{ + int res; + + if (argc != 3) { + fprintf(stderr,"Usage: demac infile.ape outfile.wav\n"); + return 0; + } + + res = ape_decode(argv[1], argv[2]); + + if (res < 0) + { + fprintf(stderr,"DECODING ERROR %d, ABORTING\n", res); + } + else + { + fprintf(stderr,"DECODED OK - NO CRC ERRORS.\n"); + } + + return 0; +} diff --git a/lib/rbcodec/codecs/demac/libdemac.make b/lib/rbcodec/codecs/demac/libdemac.make new file mode 100644 index 0000000000..6f64b2ff10 --- /dev/null +++ b/lib/rbcodec/codecs/demac/libdemac.make @@ -0,0 +1,35 @@ +# __________ __ ___. +# Open \______ \ ____ ____ | | _\_ |__ _______ ___ +# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / +# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < +# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ +# \/ \/ \/ \/ \/ +# $Id$ +# + +# libdemac +DEMACLIB := $(CODECDIR)/libdemac.a +DEMACLIB_SRC := $(call preprocess, $(RBCODECLIB_DIR)/codecs/demac/libdemac/SOURCES) +DEMACLIB_OBJ := $(call c2obj, $(DEMACLIB_SRC)) +OTHER_SRC += $(DEMACLIB_SRC) +ifeq ($(ARCH),arch_arm) +OTHER_SRC += $(RBCODECLIB_DIR)/codecs/demac/libdemac/udiv32_arm-pre.S +endif +DEMACLIB_PRE := $(subst .a,-pre.a,$(DEMACLIB)) +DEMACLIB_OBJ_PRE := $(subst udiv32_arm.o,udiv32_arm-pre.o,$(DEMACLIB_OBJ)) + +$(DEMACLIB_PRE): $(DEMACLIB_OBJ_PRE) + $(SILENT)$(shell rm -f $@) + $(call PRINTS,AR $(@F))$(AR) rcs $@ $^ >/dev/null + +$(DEMACLIB): $(DEMACLIB_OBJ) + $(SILENT)$(shell rm -f $@) + $(call PRINTS,AR $(@F))$(AR) rcs $@ $^ >/dev/null + +$(CODECDIR)/ape_free_iram.h: $(CODECDIR)/ape-pre.map + $(call PRINTS,GEN $(@F))perl -an \ + -e 'if(/^PLUGIN_IRAM/){$$istart=hex($$F[1]);$$ilen=hex($$F[2])}' \ + -e 'if(/iend = /){$$iend=hex($$F[0]);}' \ + -e '}{if($$ilen){print"#define FREE_IRAM ".($$ilen+$$istart-$$iend)."\n";}' \ + $(CODECDIR)/ape-pre.map \ + > $@ diff --git a/lib/rbcodec/codecs/demac/libdemac/SOURCES b/lib/rbcodec/codecs/demac/libdemac/SOURCES new file mode 100644 index 0000000000..018f35a73c --- /dev/null +++ b/lib/rbcodec/codecs/demac/libdemac/SOURCES @@ -0,0 +1,15 @@ +predictor.c +#ifdef CPU_ARM +predictor-arm.S +udiv32_arm.S +#elif defined CPU_COLDFIRE +predictor-cf.S +#endif +entropy.c +decoder.c +parser.c +filter_1280_15.c +filter_16_11.c +filter_256_13.c +filter_32_10.c +filter_64_11.c diff --git a/lib/rbcodec/codecs/demac/libdemac/crc.c b/lib/rbcodec/codecs/demac/libdemac/crc.c new file mode 100644 index 0000000000..fa3ea89d7e --- /dev/null +++ b/lib/rbcodec/codecs/demac/libdemac/crc.c @@ -0,0 +1,120 @@ +/* + +libdemac - A Monkey's Audio decoder + +$Id$ + +Copyright (C) Dave Chapman 2007 + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA + +*/ + +#include +#include "demac.h" + +static const uint32_t crctab32[] = +{ + 0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, + 0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3, + 0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988, + 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91, + 0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE, + 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7, + 0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC, + 0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5, + 0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172, + 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B, + 0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940, + 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59, + 0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116, + 0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F, + 0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924, + 0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D, + + 0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A, + 0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433, + 0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818, + 0x7F6A0DBB, 0x086D3D2D, 0x91646C97, 0xE6635C01, + 0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E, + 0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457, + 0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, 0xFCB9887C, + 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65, + 0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2, + 0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB, + 0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0, + 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9, + 0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086, + 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F, + 0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4, + 0x59B33D17, 0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD, + + 0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A, + 0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683, + 0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8, + 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1, + 0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE, + 0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7, + 0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC, + 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5, + 0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252, + 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B, + 0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60, + 0xDF60EFC3, 0xA867DF55, 0x316E8EEF, 0x4669BE79, + 0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236, + 0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F, + 0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04, + 0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D, + + 0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A, + 0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713, + 0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38, + 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21, + 0x86D3D2D4, 0xF1D4E242, 0x68DDB3F8, 0x1FDA836E, + 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777, + 0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C, + 0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45, + 0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2, + 0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB, + 0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0, + 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9, + 0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, + 0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF, + 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94, + 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D +}; + +uint32_t ape_initcrc(void) +{ + return 0xffffffff; +} + +/* Update the CRC from a block of WAV-format audio data */ +uint32_t ape_updatecrc(unsigned char *block, int count, uint32_t crc) +{ + while (count--) + crc = (crc >> 8) ^ crctab32[(crc & 0xff) ^ *block++]; + + return crc; +} + +uint32_t ape_finishcrc(uint32_t crc) +{ + crc ^= 0xffffffff; + crc >>= 1; + + return crc; +} + diff --git a/lib/rbcodec/codecs/demac/libdemac/decoder.c b/lib/rbcodec/codecs/demac/libdemac/decoder.c new file mode 100644 index 0000000000..b0339a75d9 --- /dev/null +++ b/lib/rbcodec/codecs/demac/libdemac/decoder.c @@ -0,0 +1,216 @@ +/* + +libdemac - A Monkey's Audio decoder + +$Id$ + +Copyright (C) Dave Chapman 2007 + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA + +*/ + +#include +#include + +#include "demac.h" +#include "predictor.h" +#include "entropy.h" +#include "filter.h" +#include "demac_config.h" + +/* Statically allocate the filter buffers */ + +#ifdef FILTER256_IRAM +static filter_int filterbuf32[(32*3 + FILTER_HISTORY_SIZE) * 2] + IBSS_ATTR_DEMAC MEM_ALIGN_ATTR; + /* 2432 or 4864 bytes */ +static filter_int filterbuf256[(256*3 + FILTER_HISTORY_SIZE) * 2] + IBSS_ATTR_DEMAC MEM_ALIGN_ATTR; + /* 5120 or 10240 bytes */ +#define FILTERBUF64 filterbuf256 +#define FILTERBUF32 filterbuf32 +#define FILTERBUF16 filterbuf32 +#else +static filter_int filterbuf64[(64*3 + FILTER_HISTORY_SIZE) * 2] + IBSS_ATTR_DEMAC MEM_ALIGN_ATTR; + /* 2432 or 4864 bytes */ +static filter_int filterbuf256[(256*3 + FILTER_HISTORY_SIZE) * 2] + MEM_ALIGN_ATTR; /* 5120 or 10240 bytes */ +#define FILTERBUF64 filterbuf64 +#define FILTERBUF32 filterbuf64 +#define FILTERBUF16 filterbuf64 +#endif + +/* This is only needed for "insane" files, and no current Rockbox targets + can hope to decode them in realtime, except the Gigabeat S (at 528MHz). */ +static filter_int filterbuf1280[(1280*3 + FILTER_HISTORY_SIZE) * 2] + IBSS_ATTR_DEMAC_INSANEBUF MEM_ALIGN_ATTR; + /* 17408 or 34816 bytes */ + +void init_frame_decoder(struct ape_ctx_t* ape_ctx, + unsigned char* inbuffer, int* firstbyte, + int* bytesconsumed) +{ + init_entropy_decoder(ape_ctx, inbuffer, firstbyte, bytesconsumed); + //printf("CRC=0x%08x\n",ape_ctx->CRC); + //printf("Flags=0x%08x\n",ape_ctx->frameflags); + + init_predictor_decoder(&ape_ctx->predictor); + + switch (ape_ctx->compressiontype) + { + case 2000: + init_filter_16_11(FILTERBUF16); + break; + + case 3000: + init_filter_64_11(FILTERBUF64); + break; + + case 4000: + init_filter_256_13(filterbuf256); + init_filter_32_10(FILTERBUF32); + break; + + case 5000: + init_filter_1280_15(filterbuf1280); + init_filter_256_13(filterbuf256); + init_filter_16_11(FILTERBUF32); + } +} + +int ICODE_ATTR_DEMAC decode_chunk(struct ape_ctx_t* ape_ctx, + unsigned char* inbuffer, int* firstbyte, + int* bytesconsumed, + int32_t* decoded0, int32_t* decoded1, + int count) +{ + int32_t left, right; +#ifdef ROCKBOX + int scale = (APE_OUTPUT_DEPTH - ape_ctx->bps); + #define SCALE(x) ((x) << scale) +#else + #define SCALE(x) (x) +#endif + + if ((ape_ctx->channels==1) || ((ape_ctx->frameflags + & (APE_FRAMECODE_PSEUDO_STEREO|APE_FRAMECODE_STEREO_SILENCE)) + == APE_FRAMECODE_PSEUDO_STEREO)) { + + entropy_decode(ape_ctx, inbuffer, firstbyte, bytesconsumed, + decoded0, NULL, count); + + if (ape_ctx->frameflags & APE_FRAMECODE_MONO_SILENCE) { + /* We are pure silence, so we're done. */ + return 0; + } + + switch (ape_ctx->compressiontype) + { + case 2000: + apply_filter_16_11(ape_ctx->fileversion,0,decoded0,count); + break; + + case 3000: + apply_filter_64_11(ape_ctx->fileversion,0,decoded0,count); + break; + + case 4000: + apply_filter_32_10(ape_ctx->fileversion,0,decoded0,count); + apply_filter_256_13(ape_ctx->fileversion,0,decoded0,count); + break; + + case 5000: + apply_filter_16_11(ape_ctx->fileversion,0,decoded0,count); + apply_filter_256_13(ape_ctx->fileversion,0,decoded0,count); + apply_filter_1280_15(ape_ctx->fileversion,0,decoded0,count); + } + + /* Now apply the predictor decoding */ + predictor_decode_mono(&ape_ctx->predictor,decoded0,count); + + if (ape_ctx->channels==2) { + /* Pseudo-stereo - copy left channel to right channel */ + while (count--) + { + left = *decoded0; + *(decoded1++) = *(decoded0++) = SCALE(left); + } + } +#ifdef ROCKBOX + else { + /* Scale to output depth */ + while (count--) + { + left = *decoded0; + *(decoded0++) = SCALE(left); + } + } +#endif + } else { /* Stereo */ + entropy_decode(ape_ctx, inbuffer, firstbyte, bytesconsumed, + decoded0, decoded1, count); + + if ((ape_ctx->frameflags & APE_FRAMECODE_STEREO_SILENCE) + == APE_FRAMECODE_STEREO_SILENCE) { + /* We are pure silence, so we're done. */ + return 0; + } + + /* Apply filters - compression type 1000 doesn't have any */ + switch (ape_ctx->compressiontype) + { + case 2000: + apply_filter_16_11(ape_ctx->fileversion,0,decoded0,count); + apply_filter_16_11(ape_ctx->fileversion,1,decoded1,count); + break; + + case 3000: + apply_filter_64_11(ape_ctx->fileversion,0,decoded0,count); + apply_filter_64_11(ape_ctx->fileversion,1,decoded1,count); + break; + + case 4000: + apply_filter_32_10(ape_ctx->fileversion,0,decoded0,count); + apply_filter_32_10(ape_ctx->fileversion,1,decoded1,count); + apply_filter_256_13(ape_ctx->fileversion,0,decoded0,count); + apply_filter_256_13(ape_ctx->fileversion,1,decoded1,count); + break; + + case 5000: + apply_filter_16_11(ape_ctx->fileversion,0,decoded0,count); + apply_filter_16_11(ape_ctx->fileversion,1,decoded1,count); + apply_filter_256_13(ape_ctx->fileversion,0,decoded0,count); + apply_filter_256_13(ape_ctx->fileversion,1,decoded1,count); + apply_filter_1280_15(ape_ctx->fileversion,0,decoded0,count); + apply_filter_1280_15(ape_ctx->fileversion,1,decoded1,count); + } + + /* Now apply the predictor decoding */ + predictor_decode_stereo(&ape_ctx->predictor,decoded0,decoded1,count); + + /* Decorrelate and scale to output depth */ + while (count--) + { + left = *decoded1 - (*decoded0 / 2); + right = left + *decoded0; + + *(decoded0++) = SCALE(left); + *(decoded1++) = SCALE(right); + } + } + return 0; +} diff --git a/lib/rbcodec/codecs/demac/libdemac/decoder.h b/lib/rbcodec/codecs/demac/libdemac/decoder.h new file mode 100644 index 0000000000..aeac569509 --- /dev/null +++ b/lib/rbcodec/codecs/demac/libdemac/decoder.h @@ -0,0 +1,40 @@ +/* + +libdemac - A Monkey's Audio decoder + +$Id$ + +Copyright (C) Dave Chapman 2007 + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA + +*/ + +#ifndef _APE_DECODER_H +#define _APE_DECODER_H + +#include +#include "parser.h" + +void init_frame_decoder(struct ape_ctx_t* ape_ctx, + unsigned char* inbuffer, int* firstbyte, + int* bytesconsumed); + +int decode_chunk(struct ape_ctx_t* ape_ctx, + unsigned char* inbuffer, int* firstbyte, + int* bytesconsumed, + int32_t* decoded0, int32_t* decoded1, + int count); +#endif diff --git a/lib/rbcodec/codecs/demac/libdemac/demac.h b/lib/rbcodec/codecs/demac/libdemac/demac.h new file mode 100644 index 0000000000..696b2aba73 --- /dev/null +++ b/lib/rbcodec/codecs/demac/libdemac/demac.h @@ -0,0 +1,45 @@ +/* + +libdemac - A Monkey's Audio decoder + +$Id$ + +Copyright (C) Dave Chapman 2007 + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA + +*/ + +#ifndef _APE_DECODER_H +#define _APE_DECODER_H + +#include +#include "parser.h" + +void init_frame_decoder(struct ape_ctx_t* ape_ctx, + unsigned char* inbuffer, int* firstbyte, + int* bytesconsumed); + +int decode_chunk(struct ape_ctx_t* ape_ctx, + unsigned char* inbuffer, int* firstbyte, + int* bytesconsumed, + int32_t* decoded0, int32_t* decoded1, + int count); + +uint32_t ape_initcrc(void); +uint32_t ape_updatecrc(unsigned char *block, int count, uint32_t crc); +uint32_t ape_finishcrc(uint32_t crc); + +#endif diff --git a/lib/rbcodec/codecs/demac/libdemac/demac_config.h b/lib/rbcodec/codecs/demac/libdemac/demac_config.h new file mode 100644 index 0000000000..fa4f008036 --- /dev/null +++ b/lib/rbcodec/codecs/demac/libdemac/demac_config.h @@ -0,0 +1,145 @@ +/* + +libdemac - A Monkey's Audio decoder + +$Id$ + +Copyright (C) Dave Chapman 2007 + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA + +*/ + +#ifndef _DEMAC_CONFIG_H +#define _DEMAC_CONFIG_H + +/* Build-time choices for libdemac. + * Note that this file is included by both .c and .S files. */ + +#ifdef ROCKBOX + +#include "config.h" + +#ifndef __ASSEMBLER__ +#include "codeclib.h" +#include +#endif + +#define APE_OUTPUT_DEPTH 29 + +/* On ARMv4, using 32 bit ints for the filters is faster. */ +#if defined(CPU_ARM) && (ARM_ARCH == 4) +#define FILTER_BITS 32 +#endif + +#if !defined(CPU_PP) && !defined(CPU_S5L870X) +#define FILTER256_IRAM +#endif + +#if CONFIG_CPU == PP5002 || defined(CPU_S5L870X) +/* Code and data IRAM for speed (PP5002 has a broken cache), not enough IRAM + * for the insane filter buffer. Reciprocal table for division in IRAM. */ +#define ICODE_SECTION_DEMAC_ARM .icode +#define ICODE_ATTR_DEMAC ICODE_ATTR +#define ICONST_ATTR_DEMAC ICONST_ATTR +#define IBSS_ATTR_DEMAC IBSS_ATTR +#define IBSS_ATTR_DEMAC_INSANEBUF + +#elif CONFIG_CPU == PP5020 +/* Code and small data in DRAM for speed (PP5020 IRAM isn't completely single + * cycle). Insane filter buffer not in IRAM in favour of reciprocal table for + * divison. Decoded data buffers should be in IRAM (defined by the caller). */ +#define ICODE_SECTION_DEMAC_ARM .text +#define ICODE_ATTR_DEMAC +#define ICONST_ATTR_DEMAC +#define IBSS_ATTR_DEMAC +#define IBSS_ATTR_DEMAC_INSANEBUF + +#elif CONFIG_CPU == PP5022 +/* Code in DRAM, data in IRAM. Insane filter buffer not in IRAM in favour of + * reciprocal table for divison */ +#define ICODE_SECTION_DEMAC_ARM .text +#define ICODE_ATTR_DEMAC +#define ICONST_ATTR_DEMAC ICONST_ATTR +#define IBSS_ATTR_DEMAC IBSS_ATTR +#define IBSS_ATTR_DEMAC_INSANEBUF + +#else +/* Code in DRAM, data in IRAM, including insane filter buffer. */ +#define ICODE_SECTION_DEMAC_ARM .text +#define ICODE_ATTR_DEMAC +#define ICONST_ATTR_DEMAC ICONST_ATTR +#define IBSS_ATTR_DEMAC IBSS_ATTR +#define IBSS_ATTR_DEMAC_INSANEBUF IBSS_ATTR +#endif + +#else /* !ROCKBOX */ + +#define APE_OUTPUT_DEPTH (ape_ctx->bps) + +#define MEM_ALIGN_ATTR __attribute__((aligned(16))) + /* adjust to target architecture for best performance */ + +#define ICODE_ATTR_DEMAC +#define ICONST_ATTR_DEMAC +#define IBSS_ATTR_DEMAC +#define IBSS_ATTR_DEMAC_INSANEBUF + +/* Use to give gcc hints on which branch is most likely taken */ +#if defined(__GNUC__) && __GNUC__ >= 3 +#define LIKELY(x) __builtin_expect(!!(x), 1) +#define UNLIKELY(x) __builtin_expect(!!(x), 0) +#else +#define LIKELY(x) (x) +#define UNLIKELY(x) (x) +#endif + +#endif /* !ROCKBOX */ + +/* Defaults */ + +#ifndef FILTER_HISTORY_SIZE +#define FILTER_HISTORY_SIZE 512 +#endif + +#ifndef PREDICTOR_HISTORY_SIZE +#define PREDICTOR_HISTORY_SIZE 512 +#endif + +#ifndef FILTER_BITS +#define FILTER_BITS 16 +#endif + + +#ifndef __ASSEMBLER__ + +#if defined(CPU_ARM) && (ARM_ARCH < 5 || defined(USE_IRAM)) +/* optimised unsigned integer division for ARMv4, in IRAM */ +unsigned udiv32_arm(unsigned a, unsigned b); +#define UDIV32(a, b) udiv32_arm(a, b) +#else +/* default */ +#define UDIV32(a, b) (a / b) +#endif + +#include +#if FILTER_BITS == 32 +typedef int32_t filter_int; +#elif FILTER_BITS == 16 +typedef int16_t filter_int; +#endif +#endif + +#endif /* _DEMAC_CONFIG_H */ diff --git a/lib/rbcodec/codecs/demac/libdemac/entropy.c b/lib/rbcodec/codecs/demac/libdemac/entropy.c new file mode 100644 index 0000000000..1cef979808 --- /dev/null +++ b/lib/rbcodec/codecs/demac/libdemac/entropy.c @@ -0,0 +1,464 @@ +/* + +libdemac - A Monkey's Audio decoder + +$Id$ + +Copyright (C) Dave Chapman 2007 + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA + +*/ + +#include +#include + +#include "parser.h" +#include "entropy.h" +#include "demac_config.h" + +#define MODEL_ELEMENTS 64 + +/* + The following counts arrays for use with the range decoder are + hard-coded in the Monkey's Audio decoder. +*/ + +static const int counts_3970[65] ICONST_ATTR_DEMAC = +{ + 0,14824,28224,39348,47855,53994,58171,60926, + 62682,63786,64463,64878,65126,65276,65365,65419, + 65450,65469,65480,65487,65491,65493,65494,65495, + 65496,65497,65498,65499,65500,65501,65502,65503, + 65504,65505,65506,65507,65508,65509,65510,65511, + 65512,65513,65514,65515,65516,65517,65518,65519, + 65520,65521,65522,65523,65524,65525,65526,65527, + 65528,65529,65530,65531,65532,65533,65534,65535, + 65536 +}; + +/* counts_diff_3970[i] = counts_3970[i+1] - counts_3970[i] */ +static const int counts_diff_3970[64] ICONST_ATTR_DEMAC = +{ + 14824,13400,11124,8507,6139,4177,2755,1756, + 1104,677,415,248,150,89,54,31, + 19,11,7,4,2,1,1,1, + 1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1 +}; + +static const int counts_3980[65] ICONST_ATTR_DEMAC = +{ + 0,19578,36160,48417,56323,60899,63265,64435, + 64971,65232,65351,65416,65447,65466,65476,65482, + 65485,65488,65490,65491,65492,65493,65494,65495, + 65496,65497,65498,65499,65500,65501,65502,65503, + 65504,65505,65506,65507,65508,65509,65510,65511, + 65512,65513,65514,65515,65516,65517,65518,65519, + 65520,65521,65522,65523,65524,65525,65526,65527, + 65528,65529,65530,65531,65532,65533,65534,65535, + 65536 +}; + +/* counts_diff_3980[i] = counts_3980[i+1] - counts_3980[i] */ + +static const int counts_diff_3980[64] ICONST_ATTR_DEMAC = +{ + 19578,16582,12257,7906,4576,2366,1170,536, + 261,119,65,31,19,10,6,3, + 3,2,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1 +}; + +/* + +Range decoder adapted from rangecod.c included in: + + http://www.compressconsult.com/rangecoder/rngcod13.zip + + rangecod.c range encoding + + (c) Michael Schindler + 1997, 1998, 1999, 2000 + http://www.compressconsult.com/ + michael@compressconsult.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + +The encoding functions were removed, and functions turned into "static +inline" functions. Some minor cosmetic changes were made (e.g. turning +pre-processor symbols into upper-case, removing the rc parameter from +each function (and the RNGC macro)). + +*/ + +/* BITSTREAM READING FUNCTIONS */ + +/* We deal with the input data one byte at a time - to ensure + functionality on CPUs of any endianness regardless of any requirements + for aligned reads. +*/ + +static unsigned char* bytebuffer IBSS_ATTR_DEMAC; +static int bytebufferoffset IBSS_ATTR_DEMAC; + +static inline void skip_byte(void) +{ + bytebufferoffset--; + bytebuffer += bytebufferoffset & 4; + bytebufferoffset &= 3; +} + +static inline int read_byte(void) +{ + int ch = bytebuffer[bytebufferoffset]; + + skip_byte(); + + return ch; +} + +/* RANGE DECODING FUNCTIONS */ + +/* SIZE OF RANGE ENCODING CODE VALUES. */ + +#define CODE_BITS 32 +#define TOP_VALUE ((unsigned int)1 << (CODE_BITS-1)) +#define SHIFT_BITS (CODE_BITS - 9) +#define EXTRA_BITS ((CODE_BITS-2) % 8 + 1) +#define BOTTOM_VALUE (TOP_VALUE >> 8) + +struct rangecoder_t +{ + uint32_t low; /* low end of interval */ + uint32_t range; /* length of interval */ + uint32_t help; /* bytes_to_follow resp. intermediate value */ + unsigned int buffer; /* buffer for input/output */ +}; + +static struct rangecoder_t rc IBSS_ATTR_DEMAC; + +/* Start the decoder */ +static inline void range_start_decoding(void) +{ + rc.buffer = read_byte(); + rc.low = rc.buffer >> (8 - EXTRA_BITS); + rc.range = (uint32_t) 1 << EXTRA_BITS; +} + +static inline void range_dec_normalize(void) +{ + while (rc.range <= BOTTOM_VALUE) + { + rc.buffer = (rc.buffer << 8) | read_byte(); + rc.low = (rc.low << 8) | ((rc.buffer >> 1) & 0xff); + rc.range <<= 8; + } +} + +/* Calculate culmulative frequency for next symbol. Does NO update!*/ +/* tot_f is the total frequency */ +/* or: totf is (code_value)1<> shift; + return UDIV32(rc.low, rc.help); +} + + +/* Update decoding state */ +/* sy_f is the interval length (frequency of the symbol) */ +/* lt_f is the lower end (frequency sum of < symbols) */ +static inline void range_decode_update(int sy_f, int lt_f) +{ + rc.low -= rc.help * lt_f; + rc.range = rc.help * sy_f; +} + + +/* Decode a byte/short without modelling */ +static inline unsigned char decode_byte(void) +{ int tmp = range_decode_culshift(8); + range_decode_update( 1,tmp); + return tmp; +} + +static inline unsigned short range_decode_short(void) +{ int tmp = range_decode_culshift(16); + range_decode_update( 1,tmp); + return tmp; +} + +/* Decode n bits (n <= 16) without modelling - based on range_decode_short */ +static inline int range_decode_bits(int n) +{ int tmp = range_decode_culshift(n); + range_decode_update( 1,tmp); + return tmp; +} + + +/* Finish decoding */ +static inline void range_done_decoding(void) +{ range_dec_normalize(); /* normalize to use up all bytes */ +} + +/* + range_get_symbol_* functions based on main decoding loop in simple_d.c from + http://www.compressconsult.com/rangecoder/rngcod13.zip + (c) Michael Schindler +*/ + +static inline int range_get_symbol_3980(void) +{ + int symbol, cf; + + cf = range_decode_culshift(16); + + /* figure out the symbol inefficiently; a binary search would be much better */ + for (symbol = 0; counts_3980[symbol+1] <= cf; symbol++); + + range_decode_update(counts_diff_3980[symbol],counts_3980[symbol]); + + return symbol; +} + +static inline int range_get_symbol_3970(void) +{ + int symbol, cf; + + cf = range_decode_culshift(16); + + /* figure out the symbol inefficiently; a binary search would be much better */ + for (symbol = 0; counts_3970[symbol+1] <= cf; symbol++); + + range_decode_update(counts_diff_3970[symbol],counts_3970[symbol]); + + return symbol; +} + +/* MAIN DECODING FUNCTIONS */ + +struct rice_t +{ + uint32_t k; + uint32_t ksum; +}; + +static struct rice_t riceX IBSS_ATTR_DEMAC; +static struct rice_t riceY IBSS_ATTR_DEMAC; + +static inline void update_rice(struct rice_t* rice, int x) +{ + rice->ksum += ((x + 1) / 2) - ((rice->ksum + 16) >> 5); + + if (UNLIKELY(rice->k == 0)) { + rice->k = 1; + } else { + uint32_t lim = 1 << (rice->k + 4); + if (UNLIKELY(rice->ksum < lim)) { + rice->k--; + } else if (UNLIKELY(rice->ksum >= 2 * lim)) { + rice->k++; + } + } +} + +static inline int entropy_decode3980(struct rice_t* rice) +{ + int base, x, pivot, overflow; + + pivot = rice->ksum >> 5; + if (UNLIKELY(pivot == 0)) + pivot=1; + + overflow = range_get_symbol_3980(); + + if (UNLIKELY(overflow == (MODEL_ELEMENTS-1))) { + overflow = range_decode_short() << 16; + overflow |= range_decode_short(); + } + + if (pivot >= 0x10000) { + /* Codepath for 24-bit streams */ + int nbits, lo_bits, base_hi, base_lo; + + /* Count the number of bits in pivot */ + nbits = 17; /* We know there must be at least 17 bits */ + while ((pivot >> nbits) > 0) { nbits++; } + + /* base_lo is the low (nbits-16) bits of base + base_hi is the high 16 bits of base + */ + lo_bits = (nbits - 16); + + base_hi = range_decode_culfreq((pivot >> lo_bits) + 1); + range_decode_update(1, base_hi); + + base_lo = range_decode_culshift(lo_bits); + range_decode_update(1, base_lo); + + base = (base_hi << lo_bits) + base_lo; + } else { + /* Codepath for 16-bit streams */ + base = range_decode_culfreq(pivot); + range_decode_update(1, base); + } + + x = base + (overflow * pivot); + update_rice(rice, x); + + /* Convert to signed */ + if (x & 1) + return (x >> 1) + 1; + else + return -(x >> 1); +} + + +static inline int entropy_decode3970(struct rice_t* rice) +{ + int x, tmpk; + + int overflow = range_get_symbol_3970(); + + if (UNLIKELY(overflow == (MODEL_ELEMENTS - 1))) { + tmpk = range_decode_bits(5); + overflow = 0; + } else { + tmpk = (rice->k < 1) ? 0 : rice->k - 1; + } + + if (tmpk <= 16) { + x = range_decode_bits(tmpk); + } else { + x = range_decode_short(); + x |= (range_decode_bits(tmpk - 16) << 16); + } + x += (overflow << tmpk); + + update_rice(rice, x); + + /* Convert to signed */ + if (x & 1) + return (x >> 1) + 1; + else + return -(x >> 1); +} + +void init_entropy_decoder(struct ape_ctx_t* ape_ctx, + unsigned char* inbuffer, int* firstbyte, + int* bytesconsumed) +{ + bytebuffer = inbuffer; + bytebufferoffset = *firstbyte; + + /* Read the CRC */ + ape_ctx->CRC = read_byte(); + ape_ctx->CRC = (ape_ctx->CRC << 8) | read_byte(); + ape_ctx->CRC = (ape_ctx->CRC << 8) | read_byte(); + ape_ctx->CRC = (ape_ctx->CRC << 8) | read_byte(); + + /* Read the frame flags if they exist */ + ape_ctx->frameflags = 0; + if ((ape_ctx->fileversion > 3820) && (ape_ctx->CRC & 0x80000000)) { + ape_ctx->CRC &= ~0x80000000; + + ape_ctx->frameflags = read_byte(); + ape_ctx->frameflags = (ape_ctx->frameflags << 8) | read_byte(); + ape_ctx->frameflags = (ape_ctx->frameflags << 8) | read_byte(); + ape_ctx->frameflags = (ape_ctx->frameflags << 8) | read_byte(); + } + /* Keep a count of the blocks decoded in this frame */ + ape_ctx->blocksdecoded = 0; + + /* Initialise the rice structs */ + riceX.k = 10; + riceX.ksum = (1 << riceX.k) * 16; + riceY.k = 10; + riceY.ksum = (1 << riceY.k) * 16; + + /* The first 8 bits of input are ignored. */ + skip_byte(); + + range_start_decoding(); + + /* Return the new state of the buffer */ + *bytesconsumed = (intptr_t)bytebuffer - (intptr_t)inbuffer; + *firstbyte = bytebufferoffset; +} + +void ICODE_ATTR_DEMAC entropy_decode(struct ape_ctx_t* ape_ctx, + unsigned char* inbuffer, int* firstbyte, + int* bytesconsumed, + int32_t* decoded0, int32_t* decoded1, + int blockstodecode) +{ + bytebuffer = inbuffer; + bytebufferoffset = *firstbyte; + + ape_ctx->blocksdecoded += blockstodecode; + + if ((ape_ctx->frameflags & APE_FRAMECODE_LEFT_SILENCE) + && ((ape_ctx->frameflags & APE_FRAMECODE_RIGHT_SILENCE) + || (decoded1 == NULL))) { + /* We are pure silence, just memset the output buffer. */ + memset(decoded0, 0, blockstodecode * sizeof(int32_t)); + if (decoded1 != NULL) + memset(decoded1, 0, blockstodecode * sizeof(int32_t)); + } else { + if (ape_ctx->fileversion > 3970) { + while (LIKELY(blockstodecode--)) { + *(decoded0++) = entropy_decode3980(&riceY); + if (decoded1 != NULL) + *(decoded1++) = entropy_decode3980(&riceX); + } + } else { + while (LIKELY(blockstodecode--)) { + *(decoded0++) = entropy_decode3970(&riceY); + if (decoded1 != NULL) + *(decoded1++) = entropy_decode3970(&riceX); + } + } + } + + if (ape_ctx->blocksdecoded == ape_ctx->currentframeblocks) + { + range_done_decoding(); + } + + /* Return the new state of the buffer */ + *bytesconsumed = bytebuffer - inbuffer; + *firstbyte = bytebufferoffset; +} diff --git a/lib/rbcodec/codecs/demac/libdemac/entropy.h b/lib/rbcodec/codecs/demac/libdemac/entropy.h new file mode 100644 index 0000000000..fac2a44d99 --- /dev/null +++ b/lib/rbcodec/codecs/demac/libdemac/entropy.h @@ -0,0 +1,40 @@ +/* + +libdemac - A Monkey's Audio decoder + +$Id$ + +Copyright (C) Dave Chapman 2007 + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA + +*/ + +#ifndef _APE_ENTROPY_H +#define _APE_ENTROPY_H + +#include + +void init_entropy_decoder(struct ape_ctx_t* ape_ctx, + unsigned char* inbuffer, int* firstbyte, + int* bytesconsumed); + +void entropy_decode(struct ape_ctx_t* ape_ctx, + unsigned char* inbuffer, int* firstbyte, + int* bytesconsumed, + int32_t* decoded0, int32_t* decoded1, + int blockstodecode); + +#endif diff --git a/lib/rbcodec/codecs/demac/libdemac/filter.c b/lib/rbcodec/codecs/demac/libdemac/filter.c new file mode 100644 index 0000000000..903885cf00 --- /dev/null +++ b/lib/rbcodec/codecs/demac/libdemac/filter.c @@ -0,0 +1,296 @@ +/* + +libdemac - A Monkey's Audio decoder + +$Id$ + +Copyright (C) Dave Chapman 2007 + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA + +*/ + +#include +#include + +#include "demac.h" +#include "filter.h" +#include "demac_config.h" + +#if FILTER_BITS == 32 + +#if defined(CPU_ARM) && (ARM_ARCH == 4) +#include "vector_math32_armv4.h" +#else +#include "vector_math_generic.h" +#endif + +#else /* FILTER_BITS == 16 */ + +#ifdef CPU_COLDFIRE +#include "vector_math16_cf.h" +#elif defined(CPU_ARM) && (ARM_ARCH >= 7) +#include "vector_math16_armv7.h" +#elif defined(CPU_ARM) && (ARM_ARCH >= 6) +#include "vector_math16_armv6.h" +#elif defined(CPU_ARM) && (ARM_ARCH >= 5) +/* Assume all our ARMv5 targets are ARMv5te(j) */ +#include "vector_math16_armv5te.h" +#elif (defined(__i386__) || defined(__i486__)) && defined(__MMX__) \ + || defined(__x86_64__) +#include "vector_math16_mmx.h" +#else +#include "vector_math_generic.h" +#endif + +#endif /* FILTER_BITS */ + +struct filter_t { + filter_int* coeffs; /* ORDER entries */ + + /* We store all the filter delays in a single buffer */ + filter_int* history_end; + + filter_int* delay; + filter_int* adaptcoeffs; + + int avg; +}; + +/* We name the functions according to the ORDER and FRACBITS + pre-processor symbols and build multiple .o files from this .c file + - this increases code-size but gives the compiler more scope for + optimising the individual functions, as well as replacing a lot of + variables with constants. +*/ + +#if FRACBITS == 11 + #if ORDER == 16 + #define INIT_FILTER init_filter_16_11 + #define APPLY_FILTER apply_filter_16_11 + #elif ORDER == 64 + #define INIT_FILTER init_filter_64_11 + #define APPLY_FILTER apply_filter_64_11 + #endif +#elif FRACBITS == 13 + #define INIT_FILTER init_filter_256_13 + #define APPLY_FILTER apply_filter_256_13 +#elif FRACBITS == 10 + #define INIT_FILTER init_filter_32_10 + #define APPLY_FILTER apply_filter_32_10 +#elif FRACBITS == 15 + #define INIT_FILTER init_filter_1280_15 + #define APPLY_FILTER apply_filter_1280_15 +#endif + +/* Some macros to handle the fixed-point stuff */ + +/* Convert from (32-FRACBITS).FRACBITS fixed-point format to an + integer (rounding to nearest). */ +#define FP_HALF (1 << (FRACBITS - 1)) /* 0.5 in fixed-point format. */ +#define FP_TO_INT(x) ((x + FP_HALF) >> FRACBITS) /* round(x) */ + +#ifdef CPU_ARM +#if ARM_ARCH >= 6 +#define SATURATE(x) ({int __res; asm("ssat %0, #16, %1" : "=r"(__res) : "r"(x)); __res; }) +#else /* ARM_ARCH < 6 */ +/* Keeping the asr #31 outside of the asm allows loads to be scheduled between + it and the rest of the block on ARM9E, with the load's result latency filled + by the other calculations. */ +#define SATURATE(x) ({ \ + int __res = (x) >> 31; \ + asm volatile ( \ + "teq %0, %1, asr #15\n\t" \ + "moveq %0, %1\n\t" \ + "eorne %0, %0, #0xff\n\t" \ + "eorne %0, %0, #0x7f00" \ + : "+r" (__res) : "r" (x) : "cc" \ + ); \ + __res; \ +}) +#endif /* ARM_ARCH */ +#else /* CPU_ARM */ +#define SATURATE(x) (LIKELY((x) == (int16_t)(x)) ? (x) : ((x) >> 31) ^ 0x7FFF) +#endif + +/* Apply the filter with state f to count entries in data[] */ + +static void ICODE_ATTR_DEMAC do_apply_filter_3980(struct filter_t* f, + int32_t* data, int count) +{ + int res; + int absres; + +#ifdef PREPARE_SCALARPRODUCT + PREPARE_SCALARPRODUCT +#endif + + while(LIKELY(count--)) + { +#ifdef FUSED_VECTOR_MATH + if (LIKELY(*data != 0)) { + if (*data < 0) + res = vector_sp_add(f->coeffs, f->delay - ORDER, + f->adaptcoeffs - ORDER); + else + res = vector_sp_sub(f->coeffs, f->delay - ORDER, + f->adaptcoeffs - ORDER); + } else { + res = scalarproduct(f->coeffs, f->delay - ORDER); + } + res = FP_TO_INT(res); +#else + res = FP_TO_INT(scalarproduct(f->coeffs, f->delay - ORDER)); + + if (LIKELY(*data != 0)) { + if (*data < 0) + vector_add(f->coeffs, f->adaptcoeffs - ORDER); + else + vector_sub(f->coeffs, f->adaptcoeffs - ORDER); + } +#endif + + res += *data; + + *data++ = res; + + /* Update the output history */ + *f->delay++ = SATURATE(res); + + /* Version 3.98 and later files */ + + /* Update the adaption coefficients */ + absres = (res < 0 ? -res : res); + + if (UNLIKELY(absres > 3 * f->avg)) + *f->adaptcoeffs = ((res >> 25) & 64) - 32; + else if (3 * absres > 4 * f->avg) + *f->adaptcoeffs = ((res >> 26) & 32) - 16; + else if (LIKELY(absres > 0)) + *f->adaptcoeffs = ((res >> 27) & 16) - 8; + else + *f->adaptcoeffs = 0; + + f->avg += (absres - f->avg) / 16; + + f->adaptcoeffs[-1] >>= 1; + f->adaptcoeffs[-2] >>= 1; + f->adaptcoeffs[-8] >>= 1; + + f->adaptcoeffs++; + + /* Have we filled the history buffer? */ + if (UNLIKELY(f->delay == f->history_end)) { + memmove(f->coeffs + ORDER, f->delay - (ORDER*2), + (ORDER*2) * sizeof(filter_int)); + f->adaptcoeffs = f->coeffs + ORDER*2; + f->delay = f->coeffs + ORDER*3; + } + } +} + +static void ICODE_ATTR_DEMAC do_apply_filter_3970(struct filter_t* f, + int32_t* data, int count) +{ + int res; + +#ifdef PREPARE_SCALARPRODUCT + PREPARE_SCALARPRODUCT +#endif + + while(LIKELY(count--)) + { +#ifdef FUSED_VECTOR_MATH + if (LIKELY(*data != 0)) { + if (*data < 0) + res = vector_sp_add(f->coeffs, f->delay - ORDER, + f->adaptcoeffs - ORDER); + else + res = vector_sp_sub(f->coeffs, f->delay - ORDER, + f->adaptcoeffs - ORDER); + } else { + res = scalarproduct(f->coeffs, f->delay - ORDER); + } + res = FP_TO_INT(res); +#else + res = FP_TO_INT(scalarproduct(f->coeffs, f->delay - ORDER)); + + if (LIKELY(*data != 0)) { + if (*data < 0) + vector_add(f->coeffs, f->adaptcoeffs - ORDER); + else + vector_sub(f->coeffs, f->adaptcoeffs - ORDER); + } +#endif + + /* Convert res from (32-FRACBITS).FRACBITS fixed-point format to an + integer (rounding to nearest) and add the input value to + it */ + res += *data; + + *data++ = res; + + /* Update the output history */ + *f->delay++ = SATURATE(res); + + /* Version ??? to < 3.98 files (untested) */ + f->adaptcoeffs[0] = (res == 0) ? 0 : ((res >> 28) & 8) - 4; + f->adaptcoeffs[-4] >>= 1; + f->adaptcoeffs[-8] >>= 1; + + f->adaptcoeffs++; + + /* Have we filled the history buffer? */ + if (UNLIKELY(f->delay == f->history_end)) { + memmove(f->coeffs + ORDER, f->delay - (ORDER*2), + (ORDER*2) * sizeof(filter_int)); + f->adaptcoeffs = f->coeffs + ORDER*2; + f->delay = f->coeffs + ORDER*3; + } + } +} + +static struct filter_t filter[2] IBSS_ATTR_DEMAC; + +static void do_init_filter(struct filter_t* f, filter_int* buf) +{ + f->coeffs = buf; + f->history_end = buf + ORDER*3 + FILTER_HISTORY_SIZE; + + /* Init pointers */ + f->adaptcoeffs = f->coeffs + ORDER*2; + f->delay = f->coeffs + ORDER*3; + + /* Zero coefficients and history buffer */ + memset(f->coeffs, 0, ORDER*3 * sizeof(filter_int)); + + /* Zero the running average */ + f->avg = 0; +} + +void INIT_FILTER(filter_int* buf) +{ + do_init_filter(&filter[0], buf); + do_init_filter(&filter[1], buf + ORDER*3 + FILTER_HISTORY_SIZE); +} + +void ICODE_ATTR_DEMAC APPLY_FILTER(int fileversion, int channel, + int32_t* data, int count) +{ + if (fileversion >= 3980) + do_apply_filter_3980(&filter[channel], data, count); + else + do_apply_filter_3970(&filter[channel], data, count); +} diff --git a/lib/rbcodec/codecs/demac/libdemac/filter.h b/lib/rbcodec/codecs/demac/libdemac/filter.h new file mode 100644 index 0000000000..609ea12496 --- /dev/null +++ b/lib/rbcodec/codecs/demac/libdemac/filter.h @@ -0,0 +1,50 @@ +/* + +libdemac - A Monkey's Audio decoder + +$Id$ + +Copyright (C) Dave Chapman 2007 + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA + +*/ + +#ifndef _APE_FILTER_H +#define _APE_FILTER_H + +#include "demac_config.h" + +void init_filter_16_11(filter_int* buf); +void apply_filter_16_11(int fileversion, int channel, + int32_t* decoded, int count); + +void init_filter_64_11(filter_int* buf); +void apply_filter_64_11(int fileversion, int channel, + int32_t* decoded, int count); + +void init_filter_32_10(filter_int* buf); +void apply_filter_32_10(int fileversion, int channel, + int32_t* decoded, int count); + +void init_filter_256_13(filter_int* buf); +void apply_filter_256_13(int fileversion, int channel, + int32_t* decoded, int count); + +void init_filter_1280_15(filter_int* buf); +void apply_filter_1280_15(int fileversion, int channel, + int32_t* decoded, int count); + +#endif diff --git a/lib/rbcodec/codecs/demac/libdemac/filter_1280_15.c b/lib/rbcodec/codecs/demac/libdemac/filter_1280_15.c new file mode 100644 index 0000000000..f2301fb02a --- /dev/null +++ b/lib/rbcodec/codecs/demac/libdemac/filter_1280_15.c @@ -0,0 +1,32 @@ +/* + +libdemac - A Monkey's Audio decoder + +$Id$ + +Copyright (C) Dave Chapman 2007 + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA + +*/ + +#include "demac_config.h" +#ifndef FILTER256_IRAM +#undef ICODE_ATTR_DEMAC +#define ICODE_ATTR_DEMAC +#endif +#define ORDER 1280 +#define FRACBITS 15 +#include "filter.c" diff --git a/lib/rbcodec/codecs/demac/libdemac/filter_16_11.c b/lib/rbcodec/codecs/demac/libdemac/filter_16_11.c new file mode 100644 index 0000000000..94c56e247f --- /dev/null +++ b/lib/rbcodec/codecs/demac/libdemac/filter_16_11.c @@ -0,0 +1,27 @@ +/* + +libdemac - A Monkey's Audio decoder + +$Id$ + +Copyright (C) Dave Chapman 2007 + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA + +*/ + +#define ORDER 16 +#define FRACBITS 11 +#include "filter.c" diff --git a/lib/rbcodec/codecs/demac/libdemac/filter_256_13.c b/lib/rbcodec/codecs/demac/libdemac/filter_256_13.c new file mode 100644 index 0000000000..9e4b9fcb13 --- /dev/null +++ b/lib/rbcodec/codecs/demac/libdemac/filter_256_13.c @@ -0,0 +1,32 @@ +/* + +libdemac - A Monkey's Audio decoder + +$Id$ + +Copyright (C) Dave Chapman 2007 + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA + +*/ + +#include "demac_config.h" +#ifndef FILTER256_IRAM +#undef ICODE_ATTR_DEMAC +#define ICODE_ATTR_DEMAC +#endif +#define ORDER 256 +#define FRACBITS 13 +#include "filter.c" diff --git a/lib/rbcodec/codecs/demac/libdemac/filter_32_10.c b/lib/rbcodec/codecs/demac/libdemac/filter_32_10.c new file mode 100644 index 0000000000..5ec85089db --- /dev/null +++ b/lib/rbcodec/codecs/demac/libdemac/filter_32_10.c @@ -0,0 +1,27 @@ +/* + +libdemac - A Monkey's Audio decoder + +$Id$ + +Copyright (C) Dave Chapman 2007 + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA + +*/ + +#define ORDER 32 +#define FRACBITS 10 +#include "filter.c" diff --git a/lib/rbcodec/codecs/demac/libdemac/filter_64_11.c b/lib/rbcodec/codecs/demac/libdemac/filter_64_11.c new file mode 100644 index 0000000000..cd74fa5f6b --- /dev/null +++ b/lib/rbcodec/codecs/demac/libdemac/filter_64_11.c @@ -0,0 +1,27 @@ +/* + +libdemac - A Monkey's Audio decoder + +$Id$ + +Copyright (C) Dave Chapman 2007 + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA + +*/ + +#define ORDER 64 +#define FRACBITS 11 +#include "filter.c" diff --git a/lib/rbcodec/codecs/demac/libdemac/parser.c b/lib/rbcodec/codecs/demac/libdemac/parser.c new file mode 100644 index 0000000000..2af4a292b8 --- /dev/null +++ b/lib/rbcodec/codecs/demac/libdemac/parser.c @@ -0,0 +1,402 @@ +/* + +libdemac - A Monkey's Audio decoder + +$Id$ + +Copyright (C) Dave Chapman 2007 + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA + +*/ + +#include +#include +#ifndef ROCKBOX +#include +#include +#include "inttypes.h" +#include +#include +#include +#endif + +#include "parser.h" + +#ifdef APE_MAX +#undef APE_MAX +#endif +#define APE_MAX(a,b) ((a)>(b)?(a):(b)) + + +static inline int16_t get_int16(unsigned char* buf) +{ + return(buf[0] | (buf[1] << 8)); +} + +static inline uint16_t get_uint16(unsigned char* buf) +{ + return(buf[0] | (buf[1] << 8)); +} + +static inline uint32_t get_uint32(unsigned char* buf) +{ + return(buf[0] | (buf[1] << 8) | (buf[2] << 16) | (buf[3] << 24)); +} + + +int ape_parseheaderbuf(unsigned char* buf, struct ape_ctx_t* ape_ctx) +{ + unsigned char* header; + + memset(ape_ctx,0,sizeof(struct ape_ctx_t)); + /* TODO: Skip any leading junk such as id3v2 tags */ + ape_ctx->junklength = 0; + + memcpy(ape_ctx->magic, buf, 4); + if (memcmp(ape_ctx->magic,"MAC ",4)!=0) + { + return -1; + } + + ape_ctx->fileversion = get_int16(buf + 4); + + if (ape_ctx->fileversion >= 3980) + { + ape_ctx->padding1 = get_int16(buf + 6); + ape_ctx->descriptorlength = get_uint32(buf + 8); + ape_ctx->headerlength = get_uint32(buf + 12); + ape_ctx->seektablelength = get_uint32(buf + 16); + ape_ctx->wavheaderlength = get_uint32(buf + 20); + ape_ctx->audiodatalength = get_uint32(buf + 24); + ape_ctx->audiodatalength_high = get_uint32(buf + 28); + ape_ctx->wavtaillength = get_uint32(buf + 32); + memcpy(ape_ctx->md5, buf + 36, 16); + + header = buf + ape_ctx->descriptorlength; + + /* Read header data */ + ape_ctx->compressiontype = get_uint16(header + 0); + ape_ctx->formatflags = get_uint16(header + 2); + ape_ctx->blocksperframe = get_uint32(header + 4); + ape_ctx->finalframeblocks = get_uint32(header + 8); + ape_ctx->totalframes = get_uint32(header + 12); + ape_ctx->bps = get_uint16(header + 16); + ape_ctx->channels = get_uint16(header + 18); + ape_ctx->samplerate = get_uint32(header + 20); + + ape_ctx->seektablefilepos = ape_ctx->junklength + + ape_ctx->descriptorlength + + ape_ctx->headerlength; + + ape_ctx->firstframe = ape_ctx->junklength + ape_ctx->descriptorlength + + ape_ctx->headerlength + ape_ctx->seektablelength + + ape_ctx->wavheaderlength; + } else { + ape_ctx->headerlength = 32; + ape_ctx->compressiontype = get_uint16(buf + 6); + ape_ctx->formatflags = get_uint16(buf + 8); + ape_ctx->channels = get_uint16(buf + 10); + ape_ctx->samplerate = get_uint32(buf + 12); + ape_ctx->wavheaderlength = get_uint32(buf + 16); + ape_ctx->totalframes = get_uint32(buf + 24); + ape_ctx->finalframeblocks = get_uint32(buf + 28); + + if (ape_ctx->formatflags & MAC_FORMAT_FLAG_HAS_PEAK_LEVEL) + { + ape_ctx->headerlength += 4; + } + + if (ape_ctx->formatflags & MAC_FORMAT_FLAG_HAS_SEEK_ELEMENTS) + { + ape_ctx->seektablelength = get_uint32(buf + ape_ctx->headerlength); + ape_ctx->seektablelength *= sizeof(int32_t); + ape_ctx->headerlength += 4; + } else { + ape_ctx->seektablelength = ape_ctx->totalframes * sizeof(int32_t); + } + + if (ape_ctx->formatflags & MAC_FORMAT_FLAG_8_BIT) + ape_ctx->bps = 8; + else if (ape_ctx->formatflags & MAC_FORMAT_FLAG_24_BIT) + ape_ctx->bps = 24; + else + ape_ctx->bps = 16; + + if (ape_ctx->fileversion >= 3950) + ape_ctx->blocksperframe = 73728 * 4; + else if ((ape_ctx->fileversion >= 3900) || (ape_ctx->fileversion >= 3800 && ape_ctx->compressiontype >= 4000)) + ape_ctx->blocksperframe = 73728; + else + ape_ctx->blocksperframe = 9216; + + ape_ctx->seektablefilepos = ape_ctx->junklength + ape_ctx->headerlength + + ape_ctx->wavheaderlength; + + ape_ctx->firstframe = ape_ctx->junklength + ape_ctx->headerlength + + ape_ctx->wavheaderlength + ape_ctx->seektablelength; + } + + ape_ctx->totalsamples = ape_ctx->finalframeblocks; + if (ape_ctx->totalframes > 1) + ape_ctx->totalsamples += ape_ctx->blocksperframe * (ape_ctx->totalframes-1); + + ape_ctx->numseekpoints = APE_MAX(ape_ctx->maxseekpoints, + ape_ctx->seektablelength / sizeof(int32_t)); + + return 0; +} + + +#ifndef ROCKBOX +/* Helper functions */ + +static int read_uint16(int fd, uint16_t* x) +{ + unsigned char tmp[2]; + int n; + + n = read(fd,tmp,2); + + if (n != 2) + return -1; + + *x = tmp[0] | (tmp[1] << 8); + + return 0; +} + +static int read_int16(int fd, int16_t* x) +{ + return read_uint16(fd, (uint16_t*)x); +} + +static int read_uint32(int fd, uint32_t* x) +{ + unsigned char tmp[4]; + int n; + + n = read(fd,tmp,4); + + if (n != 4) + return -1; + + *x = tmp[0] | (tmp[1] << 8) | (tmp[2] << 16) | (tmp[3] << 24); + + return 0; +} + +int ape_parseheader(int fd, struct ape_ctx_t* ape_ctx) +{ + int i,n; + + /* TODO: Skip any leading junk such as id3v2 tags */ + ape_ctx->junklength = 0; + + lseek(fd,ape_ctx->junklength,SEEK_SET); + + n = read(fd,&ape_ctx->magic,4); + if (n != 4) return -1; + + if (memcmp(ape_ctx->magic,"MAC ",4)!=0) + { + return -1; + } + + if (read_int16(fd,&ape_ctx->fileversion) < 0) + return -1; + + if (ape_ctx->fileversion >= 3980) + { + if (read_int16(fd,&ape_ctx->padding1) < 0) + return -1; + if (read_uint32(fd,&ape_ctx->descriptorlength) < 0) + return -1; + if (read_uint32(fd,&ape_ctx->headerlength) < 0) + return -1; + if (read_uint32(fd,&ape_ctx->seektablelength) < 0) + return -1; + if (read_uint32(fd,&ape_ctx->wavheaderlength) < 0) + return -1; + if (read_uint32(fd,&ape_ctx->audiodatalength) < 0) + return -1; + if (read_uint32(fd,&ape_ctx->audiodatalength_high) < 0) + return -1; + if (read_uint32(fd,&ape_ctx->wavtaillength) < 0) + return -1; + if (read(fd,&ape_ctx->md5,16) != 16) + return -1; + + /* Skip any unknown bytes at the end of the descriptor. This is for future + compatibility */ + if (ape_ctx->descriptorlength > 52) + lseek(fd,ape_ctx->descriptorlength - 52, SEEK_CUR); + + /* Read header data */ + if (read_uint16(fd,&ape_ctx->compressiontype) < 0) + return -1; + if (read_uint16(fd,&ape_ctx->formatflags) < 0) + return -1; + if (read_uint32(fd,&ape_ctx->blocksperframe) < 0) + return -1; + if (read_uint32(fd,&ape_ctx->finalframeblocks) < 0) + return -1; + if (read_uint32(fd,&ape_ctx->totalframes) < 0) + return -1; + if (read_uint16(fd,&ape_ctx->bps) < 0) + return -1; + if (read_uint16(fd,&ape_ctx->channels) < 0) + return -1; + if (read_uint32(fd,&ape_ctx->samplerate) < 0) + return -1; + } else { + ape_ctx->descriptorlength = 0; + ape_ctx->headerlength = 32; + + if (read_uint16(fd,&ape_ctx->compressiontype) < 0) + return -1; + if (read_uint16(fd,&ape_ctx->formatflags) < 0) + return -1; + if (read_uint16(fd,&ape_ctx->channels) < 0) + return -1; + if (read_uint32(fd,&ape_ctx->samplerate) < 0) + return -1; + if (read_uint32(fd,&ape_ctx->wavheaderlength) < 0) + return -1; + if (read_uint32(fd,&ape_ctx->wavtaillength) < 0) + return -1; + if (read_uint32(fd,&ape_ctx->totalframes) < 0) + return -1; + if (read_uint32(fd,&ape_ctx->finalframeblocks) < 0) + return -1; + + if (ape_ctx->formatflags & MAC_FORMAT_FLAG_HAS_PEAK_LEVEL) + { + lseek(fd, 4, SEEK_CUR); /* Skip the peak level */ + ape_ctx->headerlength += 4; + } + + if (ape_ctx->formatflags & MAC_FORMAT_FLAG_HAS_SEEK_ELEMENTS) + { + if (read_uint32(fd,&ape_ctx->seektablelength) < 0) + return -1; + ape_ctx->headerlength += 4; + ape_ctx->seektablelength *= sizeof(int32_t); + } else { + ape_ctx->seektablelength = ape_ctx->totalframes * sizeof(int32_t); + } + + if (ape_ctx->formatflags & MAC_FORMAT_FLAG_8_BIT) + ape_ctx->bps = 8; + else if (ape_ctx->formatflags & MAC_FORMAT_FLAG_24_BIT) + ape_ctx->bps = 24; + else + ape_ctx->bps = 16; + + if (ape_ctx->fileversion >= 3950) + ape_ctx->blocksperframe = 73728 * 4; + else if ((ape_ctx->fileversion >= 3900) || (ape_ctx->fileversion >= 3800 && ape_ctx->compressiontype >= 4000)) + ape_ctx->blocksperframe = 73728; + else + ape_ctx->blocksperframe = 9216; + + /* Skip any stored wav header */ + if (!(ape_ctx->formatflags & MAC_FORMAT_FLAG_CREATE_WAV_HEADER)) + { + lseek(fd, ape_ctx->wavheaderlength, SEEK_CUR); + } + } + + ape_ctx->totalsamples = ape_ctx->finalframeblocks; + if (ape_ctx->totalframes > 1) + ape_ctx->totalsamples += ape_ctx->blocksperframe * (ape_ctx->totalframes-1); + + if (ape_ctx->seektablelength > 0) + { + ape_ctx->seektable = malloc(ape_ctx->seektablelength); + if (ape_ctx->seektable == NULL) + return -1; + for (i=0; i < ape_ctx->seektablelength / sizeof(uint32_t); i++) + { + if (read_uint32(fd,&ape_ctx->seektable[i]) < 0) + { + free(ape_ctx->seektable); + return -1; + } + } + } + + ape_ctx->firstframe = ape_ctx->junklength + ape_ctx->descriptorlength + + ape_ctx->headerlength + ape_ctx->seektablelength + + ape_ctx->wavheaderlength; + + return 0; +} + +void ape_dumpinfo(struct ape_ctx_t* ape_ctx) +{ + int i; + + printf("Descriptor Block:\n\n"); + printf("magic = \"%c%c%c%c\"\n", + ape_ctx->magic[0],ape_ctx->magic[1], + ape_ctx->magic[2],ape_ctx->magic[3]); + printf("fileversion = %d\n",ape_ctx->fileversion); + printf("descriptorlength = %d\n",ape_ctx->descriptorlength); + printf("headerlength = %d\n",ape_ctx->headerlength); + printf("seektablelength = %d\n",ape_ctx->seektablelength); + printf("wavheaderlength = %d\n",ape_ctx->wavheaderlength); + printf("audiodatalength = %d\n",ape_ctx->audiodatalength); + printf("audiodatalength_high = %d\n",ape_ctx->audiodatalength_high); + printf("wavtaillength = %d\n",ape_ctx->wavtaillength); + printf("md5 = "); + for (i = 0; i < 16; i++) + printf("%02x",ape_ctx->md5[i]); + printf("\n"); + + printf("\nHeader Block:\n\n"); + + printf("compressiontype = %d\n",ape_ctx->compressiontype); + printf("formatflags = %d\n",ape_ctx->formatflags); + printf("blocksperframe = %d\n",ape_ctx->blocksperframe); + printf("finalframeblocks = %d\n",ape_ctx->finalframeblocks); + printf("totalframes = %d\n",ape_ctx->totalframes); + printf("bps = %d\n",ape_ctx->bps); + printf("channels = %d\n",ape_ctx->channels); + printf("samplerate = %d\n",ape_ctx->samplerate); + + printf("\nSeektable\n\n"); + if ((ape_ctx->seektablelength / sizeof(uint32_t)) != ape_ctx->totalframes) + { + printf("No seektable\n"); + } + else + { + for ( i = 0; i < ape_ctx->seektablelength / sizeof(uint32_t) ; i++) + { + if (i < ape_ctx->totalframes-1) { + printf("%8d %d (%d bytes)\n",i,ape_ctx->seektable[i],ape_ctx->seektable[i+1]-ape_ctx->seektable[i]); + } else { + printf("%8d %d\n",i,ape_ctx->seektable[i]); + } + } + } + printf("\nCalculated information:\n\n"); + printf("junklength = %d\n",ape_ctx->junklength); + printf("firstframe = %d\n",ape_ctx->firstframe); + printf("totalsamples = %d\n",ape_ctx->totalsamples); +} + +#endif /* !ROCKBOX */ diff --git a/lib/rbcodec/codecs/demac/libdemac/parser.h b/lib/rbcodec/codecs/demac/libdemac/parser.h new file mode 100644 index 0000000000..6f07deac12 --- /dev/null +++ b/lib/rbcodec/codecs/demac/libdemac/parser.h @@ -0,0 +1,137 @@ +/* + +libdemac - A Monkey's Audio decoder + +$Id$ + +Copyright (C) Dave Chapman 2007 + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA + +*/ + +#ifndef _APE_PARSER_H +#define _APE_PARSER_H + +#include +#include "demac_config.h" + +/* The earliest and latest file formats supported by this library */ +#define APE_MIN_VERSION 3970 +#define APE_MAX_VERSION 3990 + +#define MAC_FORMAT_FLAG_8_BIT 1 // is 8-bit [OBSOLETE] +#define MAC_FORMAT_FLAG_CRC 2 // uses the new CRC32 error detection [OBSOLETE] +#define MAC_FORMAT_FLAG_HAS_PEAK_LEVEL 4 // uint32 nPeakLevel after the header [OBSOLETE] +#define MAC_FORMAT_FLAG_24_BIT 8 // is 24-bit [OBSOLETE] +#define MAC_FORMAT_FLAG_HAS_SEEK_ELEMENTS 16 // has the number of seek elements after the peak level +#define MAC_FORMAT_FLAG_CREATE_WAV_HEADER 32 // create the wave header on decompression (not stored) + + +/* Special frame codes: + + MONO_SILENCE - All PCM samples in frame are zero (mono streams only) + LEFT_SILENCE - All PCM samples for left channel in frame are zero (stereo streams) + RIGHT_SILENCE - All PCM samples for left channel in frame are zero (stereo streams) + PSEUDO_STEREO - Left and Right channels are identical + +*/ + +#define APE_FRAMECODE_MONO_SILENCE 1 +#define APE_FRAMECODE_LEFT_SILENCE 1 /* same as mono */ +#define APE_FRAMECODE_RIGHT_SILENCE 2 +#define APE_FRAMECODE_STEREO_SILENCE 3 /* combined */ +#define APE_FRAMECODE_PSEUDO_STEREO 4 + +#define PREDICTOR_ORDER 8 +/* Total size of all predictor histories - 50 * sizeof(int32_t) */ +#define PREDICTOR_SIZE 50 + + +/* NOTE: This struct is used in predictor-arm.S - any updates need to + be reflected there. */ + +struct predictor_t +{ + /* Filter histories */ + int32_t* buf; + + int32_t YlastA; + int32_t XlastA; + + /* NOTE: The order of the next four fields is important for + predictor-arm.S */ + int32_t YfilterB; + int32_t XfilterA; + int32_t XfilterB; + int32_t YfilterA; + + /* Adaption co-efficients */ + int32_t YcoeffsA[4]; + int32_t XcoeffsA[4]; + int32_t YcoeffsB[5]; + int32_t XcoeffsB[5]; + int32_t historybuffer[PREDICTOR_HISTORY_SIZE + PREDICTOR_SIZE]; +}; + +struct ape_ctx_t +{ + /* Derived fields */ + uint32_t junklength; + uint32_t firstframe; + uint32_t totalsamples; + + /* Info from Descriptor Block */ + char magic[4]; + int16_t fileversion; + int16_t padding1; + uint32_t descriptorlength; + uint32_t headerlength; + uint32_t seektablelength; + uint32_t wavheaderlength; + uint32_t audiodatalength; + uint32_t audiodatalength_high; + uint32_t wavtaillength; + uint8_t md5[16]; + + /* Info from Header Block */ + uint16_t compressiontype; + uint16_t formatflags; + uint32_t blocksperframe; + uint32_t finalframeblocks; + uint32_t totalframes; + uint16_t bps; + uint16_t channels; + uint32_t samplerate; + + /* Seektable */ + uint32_t* seektable; /* Seektable buffer */ + uint32_t maxseekpoints; /* Max seekpoints we can store (size of seektable buffer) */ + uint32_t numseekpoints; /* Number of seekpoints */ + int seektablefilepos; /* Location in .ape file of seektable */ + + /* Decoder state */ + uint32_t CRC; + int frameflags; + int currentframeblocks; + int blocksdecoded; + struct predictor_t predictor; +}; + +int ape_parseheader(int fd, struct ape_ctx_t* ape_ctx); +int ape_parseheaderbuf(unsigned char* buf, struct ape_ctx_t* ape_ctx); +void ape_dumpinfo(struct ape_ctx_t* ape_ctx); + +#endif diff --git a/lib/rbcodec/codecs/demac/libdemac/predictor-arm.S b/lib/rbcodec/codecs/demac/libdemac/predictor-arm.S new file mode 100644 index 0000000000..92a78ed9b4 --- /dev/null +++ b/lib/rbcodec/codecs/demac/libdemac/predictor-arm.S @@ -0,0 +1,702 @@ +/* + +libdemac - A Monkey's Audio decoder + +$Id$ + +Copyright (C) Dave Chapman 2007 + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA + +*/ +#include "demac_config.h" + + .section ICODE_SECTION_DEMAC_ARM,"ax",%progbits + + .align 2 + +/* NOTE: The following need to be kept in sync with parser.h */ + +#define YDELAYA 200 +#define YDELAYB 168 +#define XDELAYA 136 +#define XDELAYB 104 +#define YADAPTCOEFFSA 72 +#define XADAPTCOEFFSA 56 +#define YADAPTCOEFFSB 40 +#define XADAPTCOEFFSB 20 + +/* struct predictor_t members: */ +#define buf 0 /* int32_t* buf */ + +#define YlastA 4 /* int32_t YlastA; */ +#define XlastA 8 /* int32_t XlastA; */ + +#define YfilterB 12 /* int32_t YfilterB; */ +#define XfilterA 16 /* int32_t XfilterA; */ + +#define XfilterB 20 /* int32_t XfilterB; */ +#define YfilterA 24 /* int32_t YfilterA; */ + +#define YcoeffsA 28 /* int32_t YcoeffsA[4]; */ +#define XcoeffsA 44 /* int32_t XcoeffsA[4]; */ +#define YcoeffsB 60 /* int32_t YcoeffsB[5]; */ +#define XcoeffsB 80 /* int32_t XcoeffsB[5]; */ + +#define historybuffer 100 /* int32_t historybuffer[] */ + +@ Macro for loading 2 registers, for various ARM versions. +@ Registers must start with an even register, and must be consecutive. + +.macro LDR2OFS reg1, reg2, base, offset +#if ARM_ARCH >= 6 + ldrd \reg1, [\base, \offset] +#else /* ARM_ARCH < 6 */ +#ifdef CPU_ARM7TDMI + add \reg1, \base, \offset + ldmia \reg1, {\reg1, \reg2} +#else /* ARM9 (v4 and v5) is faster this way */ + ldr \reg1, [\base, \offset] + ldr \reg2, [\base, \offset+4] +#endif +#endif /* ARM_ARCH */ +.endm + +@ Macro for storing 2 registers, for various ARM versions. +@ Registers must start with an even register, and must be consecutive. + +.macro STR2OFS reg1, reg2, base, offset +#if ARM_ARCH >= 6 + strd \reg1, [\base, \offset] +#else + str \reg1, [\base, \offset] + str \reg2, [\base, \offset+4] +#endif +.endm + + .global predictor_decode_stereo + .type predictor_decode_stereo,%function + +@ Register usage: +@ +@ r0-r11 - scratch +@ r12 - struct predictor_t* p +@ r14 - int32_t* p->buf + +@ void predictor_decode_stereo(struct predictor_t* p, +@ int32_t* decoded0, +@ int32_t* decoded1, +@ int count) + +predictor_decode_stereo: + stmdb sp!, {r1-r11, lr} + + @ r1 (decoded0) is [sp] + @ r2 (decoded1) is [sp, #4] + @ r3 (count) is [sp, #8] + + mov r12, r0 @ r12 := p + ldr r14, [r0] @ r14 := p->buf + +loop: + +@@@@@@@@@@@@@@@@@@@@@@@@@@@ PREDICTOR Y + +@ Predictor Y, Filter A + + ldr r11, [r12, #YlastA] @ r11 := p->YlastA + + add r2, r14, #YDELAYA-12 @ r2 := &p->buf[YDELAYA-3] + ldmia r2, {r2, r3, r10} @ r2 := p->buf[YDELAYA-3] + @ r3 := p->buf[YDELAYA-2] + @ r10 := p->buf[YDELAYA-1] + + add r6, r12, #YcoeffsA + ldmia r6, {r6 - r9} @ r6 := p->YcoeffsA[0] + @ r7 := p->YcoeffsA[1] + @ r8 := p->YcoeffsA[2] + @ r9 := p->YcoeffsA[3] + + subs r10, r11, r10 @ r10 := r11 - r10 + + STR2OFS r10, r11, r14, #YDELAYA-4 + @ p->buf[YDELAYA-1] = r10 + @ p->buf[YDELAYA] = r11 + + mul r0, r11, r6 @ r0 := p->buf[YDELAYA] * p->YcoeffsA[0] + mla r0, r10, r7, r0 @ r0 += p->buf[YDELAYA-1] * p->YcoeffsA[1] + mla r0, r3, r8, r0 @ r0 += p->buf[YDELAYA-2] * p->YcoeffsA[2] + mla r0, r2, r9, r0 @ r0 += p->buf[YDELAYA-3] * p->YcoeffsA[3] + + @ flags were set above, in the subs instruction + mvngt r10, #0 + movlt r10, #1 @ r10 := SIGN(r10) (see .c for SIGN macro) + + cmp r11, #0 + mvngt r11, #0 + movlt r11, #1 @ r11 := SIGN(r11) (see .c for SIGN macro) + + STR2OFS r10, r11, r14, #YADAPTCOEFFSA-4 + @ p->buf[YADAPTCOEFFSA-1] := r10 + @ p->buf[YADAPTCOEFFSA] := r11 + + @ NOTE: r0 now contains predictionA - don't overwrite. + +@ Predictor Y, Filter B + + LDR2OFS r6, r7, r12, #YfilterB @ r6 := p->YfilterB + @ r7 := p->XfilterA + + add r2, r14, #YDELAYB-16 @ r2 := &p->buf[YDELAYB-4] + ldmia r2, {r2 - r4, r10} @ r2 := p->buf[YDELAYB-4] + @ r3 := p->buf[YDELAYB-3] + @ r4 := p->buf[YDELAYB-2] + @ r10 := p->buf[YDELAYB-1] + + rsb r6, r6, r6, lsl #5 @ r6 := r6 * 32 - r6 ( == r6*31) + sub r11, r7, r6, asr #5 @ r11 (p->buf[YDELAYB]) := r7 - (r6 >> 5) + + str r7, [r12, #YfilterB] @ p->YfilterB := r7 (p->XfilterA) + + add r5, r12, #YcoeffsB + ldmia r5, {r5 - r9} @ r5 := p->YcoeffsB[0] + @ r6 := p->YcoeffsB[1] + @ r7 := p->YcoeffsB[2] + @ r8 := p->YcoeffsB[3] + @ r9 := p->YcoeffsB[4] + + subs r10, r11, r10 @ r10 := r11 - r10 + + STR2OFS r10, r11, r14, #YDELAYB-4 + @ p->buf[YDELAYB-1] = r10 + @ p->buf[YDELAYB] = r11 + + mul r1, r11, r5 @ r1 := p->buf[YDELAYB] * p->YcoeffsB[0] + mla r1, r10, r6, r1 @ r1 += p->buf[YDELAYB-1] * p->YcoeffsB[1] + mla r1, r4, r7, r1 @ r1 += p->buf[YDELAYB-2] * p->YcoeffsB[2] + mla r1, r3, r8, r1 @ r1 += p->buf[YDELAYB-3] * p->YcoeffsB[3] + mla r1, r2, r9, r1 @ r1 += p->buf[YDELAYB-4] * p->YcoeffsB[4] + + @ flags were set above, in the subs instruction + mvngt r10, #0 + movlt r10, #1 @ r10 := SIGN(r10) (see .c for SIGN macro) + + cmp r11, #0 + mvngt r11, #0 + movlt r11, #1 @ r11 := SIGN(r11) (see .c for SIGN macro) + + STR2OFS r10, r11, r14, #YADAPTCOEFFSB-4 + @ p->buf[YADAPTCOEFFSB-1] := r10 + @ p->buf[YADAPTCOEFFSB] := r11 + + @ r0 still contains predictionA + @ r1 contains predictionB + + @ Finish Predictor Y + + ldr r2, [sp] @ r2 := decoded0 + add r0, r0, r1, asr #1 @ r0 := r0 + (r1 >> 1) + ldr r4, [r12, #YfilterA] @ r4 := p->YfilterA + ldr r3, [r2] @ r3 := *decoded0 + rsb r4, r4, r4, lsl #5 @ r4 := r4 * 32 - r4 ( == r4*31) + add r1, r3, r0, asr #10 @ r1 := r3 + (r0 >> 10) + str r1, [r12, #YlastA] @ p->YlastA := r1 + add r1, r1, r4, asr #5 @ r1 := r1 + (r4 >> 5) + str r1, [r12, #YfilterA] @ p->YfilterA := r1 + + @ r1 contains p->YfilterA + @ r2 contains decoded0 + @ r3 contains *decoded0 + + @ r5, r6, r7, r8, r9 contain p->YcoeffsB[0..4] + @ r10, r11 contain p->buf[YADAPTCOEFFSB-1] and p->buf[YADAPTCOEFFSB] + + str r1, [r2], #4 @ *(decoded0++) := r1 (p->YfilterA) + str r2, [sp] @ save decoded0 + cmp r3, #0 + beq 3f + + add r2, r14, #YADAPTCOEFFSB-16 + ldmia r2, {r2 - r4} @ r2 := p->buf[YADAPTCOEFFSB-4] + @ r3 := p->buf[YADAPTCOEFFSB-3] + @ r4 := p->buf[YADAPTCOEFFSB-2] + blt 1f + + @ *decoded0 > 0 + + sub r5, r5, r11 @ r5 := p->YcoeffsB[0] - p->buf[YADAPTCOEFFSB] + sub r6, r6, r10 @ r6 := p->YcoeffsB[1] - p->buf[YADAPTCOEFFSB-1] + sub r9, r9, r2 @ r9 := p->YcoeffsB[4] - p->buf[YADAPTCOEFFSB-4] + sub r8, r8, r3 @ r8 := p->YcoeffsB[3] - p->buf[YADAPTCOEFFSB-3] + sub r7, r7, r4 @ r7 := p->YcoeffsB[2] - p->buf[YADAPTCOEFFSB-2] + + add r0, r12, #YcoeffsB + stmia r0, {r5 - r9} @ Save p->YcoeffsB[] + + add r1, r12, #YcoeffsA + ldmia r1, {r2 - r5} @ r2 := p->YcoeffsA[0] + @ r3 := p->YcoeffsA[1] + @ r4 := p->YcoeffsA[2] + @ r5 := p->YcoeffsA[3] + + add r6, r14, #YADAPTCOEFFSA-12 + ldmia r6, {r6 - r9} @ r6 := p->buf[YADAPTCOEFFSA-3] + @ r7 := p->buf[YADAPTCOEFFSA-2] + @ r8 := p->buf[YADAPTCOEFFSA-1] + @ r9 := p->buf[YADAPTCOEFFSA] + + sub r5, r5, r6 @ r5 := p->YcoeffsA[3] - p->buf[YADAPTCOEFFSA-3] + sub r4, r4, r7 @ r4 := p->YcoeffsA[2] - p->buf[YADAPTCOEFFSA-2] + sub r3, r3, r8 @ r3 := p->YcoeffsA[1] - p->buf[YADAPTCOEFFSA-1] + sub r2, r2, r9 @ r2 := p->YcoeffsA[0] - p->buf[YADAPTCOEFFSA] + + b 2f + + +1: @ *decoded0 < 0 + + add r5, r5, r11 @ r5 := p->YcoeffsB[0] + p->buf[YADAPTCOEFFSB] + add r6, r6, r10 @ r6 := p->YcoeffsB[1] + p->buf[YADAPTCOEFFSB-1] + add r9, r9, r2 @ r9 := p->YcoeffsB[4] + p->buf[YADAPTCOEFFSB-4] + add r8, r8, r3 @ r9 := p->YcoeffsB[3] + p->buf[YADAPTCOEFFSB-3] + add r7, r7, r4 @ r8 := p->YcoeffsB[2] + p->buf[YADAPTCOEFFSB-2] + + add r0, r12, #YcoeffsB + stmia r0, {r5 - r9} @ Save p->YcoeffsB[] + + add r1, r12, #YcoeffsA + ldmia r1, {r2 - r5} @ r2 := p->YcoeffsA[0] + @ r3 := p->YcoeffsA[1] + @ r4 := p->YcoeffsA[2] + @ r5 := p->YcoeffsA[3] + + add r6, r14, #YADAPTCOEFFSA-12 + ldmia r6, {r6 - r9} @ r6 := p->buf[YADAPTCOEFFSA-3] + @ r7 := p->buf[YADAPTCOEFFSA-2] + @ r8 := p->buf[YADAPTCOEFFSA-1] + @ r9 := p->buf[YADAPTCOEFFSA] + + add r5, r5, r6 @ r5 := p->YcoeffsA[3] + p->buf[YADAPTCOEFFSA-3] + add r4, r4, r7 @ r4 := p->YcoeffsA[2] + p->buf[YADAPTCOEFFSA-2] + add r3, r3, r8 @ r3 := p->YcoeffsA[1] + p->buf[YADAPTCOEFFSA-1] + add r2, r2, r9 @ r2 := p->YcoeffsA[0] + p->buf[YADAPTCOEFFSA] + +2: + stmia r1, {r2 - r5} @ Save p->YcoeffsA + +3: + +@@@@@@@@@@@@@@@@@@@@@@@@@@@ PREDICTOR X + +@ Predictor X, Filter A + + ldr r11, [r12, #XlastA] @ r11 := p->XlastA + + add r2, r14, #XDELAYA-12 @ r2 := &p->buf[XDELAYA-3] + ldmia r2, {r2, r3, r10} @ r2 := p->buf[XDELAYA-3] + @ r3 := p->buf[XDELAYA-2] + @ r10 := p->buf[XDELAYA-1] + + add r6, r12, #XcoeffsA + ldmia r6, {r6 - r9} @ r6 := p->XcoeffsA[0] + @ r7 := p->XcoeffsA[1] + @ r8 := p->XcoeffsA[2] + @ r9 := p->XcoeffsA[3] + + subs r10, r11, r10 @ r10 := r11 - r10 + + STR2OFS r10, r11, r14, #XDELAYA-4 + @ p->buf[XDELAYA-1] = r10 + @ p->buf[XDELAYA] = r11 + + mul r0, r11, r6 @ r0 := p->buf[XDELAYA] * p->XcoeffsA[0] + mla r0, r10, r7, r0 @ r0 += p->buf[XDELAYA-1] * p->XcoeffsA[1] + mla r0, r3, r8, r0 @ r0 += p->buf[XDELAYA-2] * p->XcoeffsA[2] + mla r0, r2, r9, r0 @ r0 += p->buf[XDELAYA-3] * p->XcoeffsA[3] + + @ flags were set above, in the subs instruction + mvngt r10, #0 + movlt r10, #1 @ r10 := SIGN(r10) (see .c for SIGN macro) + + cmp r11, #0 + mvngt r11, #0 + movlt r11, #1 @ r11 := SIGN(r11) (see .c for SIGN macro) + + STR2OFS r10, r11, r14, #XADAPTCOEFFSA-4 + @ p->buf[XADAPTCOEFFSA-1] := r10 + @ p->buf[XADAPTCOEFFSA] := r11 + + @ NOTE: r0 now contains predictionA - don't overwrite. + +@ Predictor X, Filter B + + LDR2OFS r6, r7, r12, #XfilterB @ r6 := p->XfilterB + @ r7 := p->YfilterA + + add r2, r14, #XDELAYB-16 @ r2 := &p->buf[XDELAYB-4] + ldmia r2, {r2 - r4, r10} @ r2 := p->buf[XDELAYB-4] + @ r3 := p->buf[XDELAYB-3] + @ r4 := p->buf[XDELAYB-2] + @ r10 := p->buf[XDELAYB-1] + + rsb r6, r6, r6, lsl #5 @ r6 := r2 * 32 - r6 ( == r6*31) + sub r11, r7, r6, asr #5 @ r11 (p->buf[XDELAYB]) := r7 - (r6 >> 5) + + str r7, [r12, #XfilterB] @ p->XfilterB := r7 (p->YfilterA) + + add r5, r12, #XcoeffsB + ldmia r5, {r5 - r9} @ r5 := p->XcoeffsB[0] + @ r6 := p->XcoeffsB[1] + @ r7 := p->XcoeffsB[2] + @ r8 := p->XcoeffsB[3] + @ r9 := p->XcoeffsB[4] + + subs r10, r11, r10 @ r10 := r11 - r10 + + STR2OFS r10, r11, r14, #XDELAYB-4 + @ p->buf[XDELAYB-1] = r10 + @ p->buf[XDELAYB] = r11 + + mul r1, r11, r5 @ r1 := p->buf[XDELAYB] * p->XcoeffsB[0] + mla r1, r10, r6, r1 @ r1 += p->buf[XDELAYB-1] * p->XcoeffsB[1] + mla r1, r4, r7, r1 @ r1 += p->buf[XDELAYB-2] * p->XcoeffsB[2] + mla r1, r3, r8, r1 @ r1 += p->buf[XDELAYB-3] * p->XcoeffsB[3] + mla r1, r2, r9, r1 @ r1 += p->buf[XDELAYB-4] * p->XcoeffsB[4] + + @ flags were set above, in the subs instruction + mvngt r10, #0 + movlt r10, #1 @ r10 := SIGN(r10) (see .c for SIGN macro) + + cmp r11, #0 + mvngt r11, #0 + movlt r11, #1 @ r11 := SIGN(r11) (see .c for SIGN macro) + + STR2OFS r10, r11, r14, #XADAPTCOEFFSB-4 + @ p->buf[XADAPTCOEFFSB-1] := r10 + @ p->buf[XADAPTCOEFFSB] := r11 + + @ r0 still contains predictionA + @ r1 contains predictionB + + @ Finish Predictor X + + ldr r2, [sp, #4] @ r2 := decoded1 + add r0, r0, r1, asr #1 @ r0 := r0 + (r1 >> 1) + ldr r4, [r12, #XfilterA] @ r4 := p->XfilterA + ldr r3, [r2] @ r3 := *decoded1 + rsb r4, r4, r4, lsl #5 @ r4 := r4 * 32 - r4 ( == r4*31) + add r1, r3, r0, asr #10 @ r1 := r3 + (r0 >> 10) + str r1, [r12, #XlastA] @ p->XlastA := r1 + add r1, r1, r4, asr #5 @ r1 := r1 + (r4 >> 5) + str r1, [r12, #XfilterA] @ p->XfilterA := r1 + + @ r1 contains p->XfilterA + @ r2 contains decoded1 + @ r3 contains *decoded1 + + @ r5, r6, r7, r8, r9 contain p->XcoeffsB[0..4] + @ r10, r11 contain p->buf[XADAPTCOEFFSB-1] and p->buf[XADAPTCOEFFSB] + + str r1, [r2], #4 @ *(decoded1++) := r1 (p->XfilterA) + str r2, [sp, #4] @ save decoded1 + cmp r3, #0 + beq 3f + + add r2, r14, #XADAPTCOEFFSB-16 + ldmia r2, {r2 - r4} @ r2 := p->buf[XADAPTCOEFFSB-4] + @ r3 := p->buf[XADAPTCOEFFSB-3] + @ r4 := p->buf[XADAPTCOEFFSB-2] + blt 1f + + @ *decoded1 > 0 + + sub r5, r5, r11 @ r5 := p->XcoeffsB[0] - p->buf[XADAPTCOEFFSB] + sub r6, r6, r10 @ r6 := p->XcoeffsB[1] - p->buf[XADAPTCOEFFSB-1] + sub r9, r9, r2 @ r9 := p->XcoeffsB[4] - p->buf[XADAPTCOEFFSB-4] + sub r8, r8, r3 @ r8 := p->XcoeffsB[3] - p->buf[XADAPTCOEFFSB-3] + sub r7, r7, r4 @ r7 := p->XcoeffsB[2] - p->buf[XADAPTCOEFFSB-2] + + add r0, r12, #XcoeffsB + stmia r0, {r5 - r9} @ Save p->XcoeffsB[] + + add r1, r12, #XcoeffsA + ldmia r1, {r2 - r5} @ r2 := p->XcoeffsA[0] + @ r3 := p->XcoeffsA[1] + @ r4 := p->XcoeffsA[2] + @ r5 := p->XcoeffsA[3] + + add r6, r14, #XADAPTCOEFFSA-12 + ldmia r6, {r6 - r9} @ r6 := p->buf[XADAPTCOEFFSA-3] + @ r7 := p->buf[XADAPTCOEFFSA-2] + @ r8 := p->buf[XADAPTCOEFFSA-1] + @ r9 := p->buf[XADAPTCOEFFSA] + + sub r5, r5, r6 @ r5 := p->XcoeffsA[3] - p->buf[XADAPTCOEFFSA-3] + sub r4, r4, r7 @ r4 := p->XcoeffsA[2] - p->buf[XADAPTCOEFFSA-2] + sub r3, r3, r8 @ r3 := p->XcoeffsA[1] - p->buf[XADAPTCOEFFSA-1] + sub r2, r2, r9 @ r2 := p->XcoeffsA[0] - p->buf[XADAPTCOEFFSA] + + b 2f + + +1: @ *decoded1 < 0 + + add r5, r5, r11 @ r5 := p->XcoeffsB[0] + p->buf[XADAPTCOEFFSB] + add r6, r6, r10 @ r6 := p->XcoeffsB[1] + p->buf[XADAPTCOEFFSB-1] + add r9, r9, r2 @ r9 := p->XcoeffsB[4] + p->buf[XADAPTCOEFFSB-4] + add r8, r8, r3 @ r8 := p->XcoeffsB[3] + p->buf[XADAPTCOEFFSB-3] + add r7, r7, r4 @ r7 := p->XcoeffsB[2] + p->buf[XADAPTCOEFFSB-2] + + add r0, r12, #XcoeffsB + stmia r0, {r5 - r9} @ Save p->XcoeffsB[] + + add r1, r12, #XcoeffsA + ldmia r1, {r2 - r5} @ r2 := p->XcoeffsA[0] + @ r3 := p->XcoeffsA[1] + @ r4 := p->XcoeffsA[2] + @ r5 := p->XcoeffsA[3] + + add r6, r14, #XADAPTCOEFFSA-12 + ldmia r6, {r6 - r9} @ r6 := p->buf[XADAPTCOEFFSA-3] + @ r7 := p->buf[XADAPTCOEFFSA-2] + @ r8 := p->buf[XADAPTCOEFFSA-1] + @ r9 := p->buf[XADAPTCOEFFSA] + + add r5, r5, r6 @ r5 := p->XcoeffsA[3] + p->buf[XADAPTCOEFFSA-3] + add r4, r4, r7 @ r4 := p->XcoeffsA[2] + p->buf[XADAPTCOEFFSA-2] + add r3, r3, r8 @ r3 := p->XcoeffsA[1] + p->buf[XADAPTCOEFFSA-1] + add r2, r2, r9 @ r2 := p->XcoeffsA[0] + p->buf[XADAPTCOEFFSA] + +2: + stmia r1, {r2 - r5} @ Save p->XcoeffsA + +3: + +@@@@@@@@@@@@@@@@@@@@@@@@@@@ COMMON + + add r14, r14, #4 @ p->buf++ + + add r11, r12, #historybuffer @ r11 := &p->historybuffer[0] + + sub r10, r14, #PREDICTOR_HISTORY_SIZE*4 + @ r10 := p->buf - PREDICTOR_HISTORY_SIZE + + ldr r0, [sp, #8] + cmp r10, r11 + beq move_hist @ The history buffer is full, we need to do a memmove + + @ Check loop count + subs r0, r0, #1 + strne r0, [sp, #8] + bne loop + +done: + str r14, [r12] @ Save value of p->buf + add sp, sp, #12 @ Don't bother restoring r1-r3 +#ifdef ROCKBOX + ldmpc regs=r4-r11 +#else + ldmia sp!, {r4 - r11, pc} +#endif + +move_hist: + @ dest = r11 (p->historybuffer) + @ src = r14 (p->buf) + @ n = 200 + + ldmia r14!, {r0-r9} @ 40 bytes + stmia r11!, {r0-r9} + ldmia r14!, {r0-r9} @ 40 bytes + stmia r11!, {r0-r9} + ldmia r14!, {r0-r9} @ 40 bytes + stmia r11!, {r0-r9} + ldmia r14!, {r0-r9} @ 40 bytes + stmia r11!, {r0-r9} + ldmia r14!, {r0-r9} @ 40 bytes + stmia r11!, {r0-r9} + + ldr r0, [sp, #8] + add r14, r12, #historybuffer @ p->buf = &p->historybuffer[0] + + @ Check loop count + subs r0, r0, #1 + strne r0, [sp, #8] + bne loop + + b done + .size predictor_decode_stereo, .-predictor_decode_stereo + + .global predictor_decode_mono + .type predictor_decode_mono,%function + +@ Register usage: +@ +@ r0-r11 - scratch +@ r12 - struct predictor_t* p +@ r14 - int32_t* p->buf + +@ void predictor_decode_mono(struct predictor_t* p, +@ int32_t* decoded0, +@ int count) + +predictor_decode_mono: + stmdb sp!, {r1, r2, r4-r11, lr} + + @ r1 (decoded0) is [sp] + @ r2 (count) is [sp, #4] + + mov r12, r0 @ r12 := p + ldr r14, [r0] @ r14 := p->buf + +loopm: + +@@@@@@@@@@@@@@@@@@@@@@@@@@@ PREDICTOR + + ldr r11, [r12, #YlastA] @ r11 := p->YlastA + + add r2, r14, #YDELAYA-12 @ r2 := &p->buf[YDELAYA-3] + ldmia r2, {r2, r3, r10} @ r2 := p->buf[YDELAYA-3] + @ r3 := p->buf[YDELAYA-2] + @ r10 := p->buf[YDELAYA-1] + + add r5, r12, #YcoeffsA @ r5 := &p->YcoeffsA[0] + ldmia r5, {r6 - r9} @ r6 := p->YcoeffsA[0] + @ r7 := p->YcoeffsA[1] + @ r8 := p->YcoeffsA[2] + @ r9 := p->YcoeffsA[3] + + subs r10, r11, r10 @ r10 := r11 - r10 + + STR2OFS r10, r11, r14, #YDELAYA-4 + @ p->buf[YDELAYA-1] = r10 + @ p->buf[YDELAYA] = r11 + + mul r0, r11, r6 @ r0 := p->buf[YDELAYA] * p->YcoeffsA[0] + mla r0, r10, r7, r0 @ r0 += p->buf[YDELAYA-1] * p->YcoeffsA[1] + mla r0, r3, r8, r0 @ r0 += p->buf[YDELAYA-2] * p->YcoeffsA[2] + mla r0, r2, r9, r0 @ r0 += p->buf[YDELAYA-3] * p->YcoeffsA[3] + + @ flags were set above, in the subs instruction + mvngt r10, #0 + movlt r10, #1 @ r10 := SIGN(r10) (see .c for SIGN macro) + + cmp r11, #0 + mvngt r11, #0 + movlt r11, #1 @ r11 := SIGN(r11) (see .c for SIGN macro) + + STR2OFS r10, r11, r14, #YADAPTCOEFFSA-4 + @ p->buf[YADAPTCOEFFSA-1] := r10 + @ p->buf[YADAPTCOEFFSA] := r11 + + ldr r2, [sp] @ r2 := decoded0 + ldr r4, [r12, #YfilterA] @ r4 := p->YfilterA + ldr r3, [r2] @ r3 := *decoded0 + rsb r4, r4, r4, lsl #5 @ r4 := r4 * 32 - r4 ( == r4*31) + add r1, r3, r0, asr #10 @ r1 := r3 + (r0 >> 10) + str r1, [r12, #YlastA] @ p->YlastA := r1 + add r1, r1, r4, asr #5 @ r1 := r1 + (r4 >> 5) + str r1, [r12, #YfilterA] @ p->YfilterA := r1 + + @ r1 contains p->YfilterA + @ r2 contains decoded0 + @ r3 contains *decoded0 + + @ r6, r7, r8, r9 contain p->YcoeffsA[0..3] + @ r10, r11 contain p->buf[YADAPTCOEFFSA-1] and p->buf[YADAPTCOEFFSA] + + str r1, [r2], #4 @ *(decoded0++) := r1 (p->YfilterA) + str r2, [sp] @ save decoded0 + cmp r3, #0 + beq 3f + + LDR2OFS r2, r3, r14, #YADAPTCOEFFSA-12 + @ r2 := p->buf[YADAPTCOEFFSA-3] + @ r3 := p->buf[YADAPTCOEFFSA-2] + blt 1f + + @ *decoded0 > 0 + + sub r6, r6, r11 @ r6 := p->YcoeffsA[0] - p->buf[YADAPTCOEFFSA] + sub r7, r7, r10 @ r7 := p->YcoeffsA[1] - p->buf[YADAPTCOEFFSA-1] + sub r9, r9, r2 @ r9 := p->YcoeffsA[3] - p->buf[YADAPTCOEFFSA-3] + sub r8, r8, r3 @ r8 := p->YcoeffsA[2] - p->buf[YADAPTCOEFFSA-2] + + b 2f + +1: @ *decoded0 < 0 + + add r6, r6, r11 @ r6 := p->YcoeffsA[0] + p->buf[YADAPTCOEFFSA] + add r7, r7, r10 @ r7 := p->YcoeffsA[1] + p->buf[YADAPTCOEFFSA-1] + add r9, r9, r2 @ r9 := p->YcoeffsA[3] + p->buf[YADAPTCOEFFSA-3] + add r8, r8, r3 @ r8 := p->YcoeffsA[2] + p->buf[YADAPTCOEFFSA-2] + +2: + stmia r5, {r6 - r9} @ Save p->YcoeffsA + +3: + +@@@@@@@@@@@@@@@@@@@@@@@@@@@ COMMON + + add r14, r14, #4 @ p->buf++ + + add r11, r12, #historybuffer @ r11 := &p->historybuffer[0] + + sub r10, r14, #PREDICTOR_HISTORY_SIZE*4 + @ r10 := p->buf - PREDICTOR_HISTORY_SIZE + + ldr r0, [sp, #4] + cmp r10, r11 + beq move_histm @ The history buffer is full, we need to do a memmove + + @ Check loop count + subs r0, r0, #1 + strne r0, [sp, #4] + bne loopm + +donem: + str r14, [r12] @ Save value of p->buf + add sp, sp, #8 @ Don't bother restoring r1, r2 +#ifdef ROCKBOX + ldmpc regs=r4-r11 +#else + ldmia sp!, {r4 - r11, pc} +#endif + +move_histm: + @ dest = r11 (p->historybuffer) + @ src = r14 (p->buf) + @ n = 200 + + ldmia r14!, {r0-r9} @ 40 bytes + stmia r11!, {r0-r9} + ldmia r14!, {r0-r9} @ 40 bytes + stmia r11!, {r0-r9} + ldmia r14!, {r0-r9} @ 40 bytes + stmia r11!, {r0-r9} + ldmia r14!, {r0-r9} @ 40 bytes + stmia r11!, {r0-r9} + ldmia r14!, {r0-r9} @ 40 bytes + stmia r11!, {r0-r9} + + ldr r0, [sp, #4] + add r14, r12, #historybuffer @ p->buf = &p->historybuffer[0] + + @ Check loop count + subs r0, r0, #1 + strne r0, [sp, #4] + bne loopm + + b donem + .size predictor_decode_mono, .-predictor_decode_mono diff --git a/lib/rbcodec/codecs/demac/libdemac/predictor-cf.S b/lib/rbcodec/codecs/demac/libdemac/predictor-cf.S new file mode 100644 index 0000000000..fc1d901a59 --- /dev/null +++ b/lib/rbcodec/codecs/demac/libdemac/predictor-cf.S @@ -0,0 +1,660 @@ +/* + +libdemac - A Monkey's Audio decoder + +$Id$ + +Copyright (C) Dave Chapman 2007 + +Coldfire predictor copyright (C) 2007 Jens Arnold + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA + +*/ + +#include "demac_config.h" + +/* NOTE: The following need to be kept in sync with parser.h */ + +#define YDELAYA 200 +#define YDELAYB 168 +#define XDELAYA 136 +#define XDELAYB 104 +#define YADAPTCOEFFSA 72 +#define XADAPTCOEFFSA 56 +#define YADAPTCOEFFSB 40 +#define XADAPTCOEFFSB 20 + +/* struct predictor_t members: */ +#define buf 0 /* int32_t* buf */ + +#define YlastA 4 /* int32_t YlastA; */ +#define XlastA 8 /* int32_t XlastA; */ + +#define YfilterB 12 /* int32_t YfilterB; */ +#define XfilterA 16 /* int32_t XfilterA; */ + +#define XfilterB 20 /* int32_t XfilterB; */ +#define YfilterA 24 /* int32_t YfilterA; */ + +#define YcoeffsA 28 /* int32_t YcoeffsA[4]; */ +#define XcoeffsA 44 /* int32_t XcoeffsA[4]; */ +#define YcoeffsB 60 /* int32_t YcoeffsB[5]; */ +#define XcoeffsB 80 /* int32_t XcoeffsB[5]; */ + +#define historybuffer 100 /* int32_t historybuffer[] */ + + + .text + + .align 2 + + .global predictor_decode_stereo + .type predictor_decode_stereo,@function + +| void predictor_decode_stereo(struct predictor_t* p, +| int32_t* decoded0, +| int32_t* decoded1, +| int count) + +predictor_decode_stereo: + lea.l (-12*4,%sp), %sp + movem.l %d2-%d7/%a2-%a6, (4,%sp) + + movem.l (12*4+8,%sp), %a3-%a5 | %a3 = decoded0 + | %a4 = decoded1 + move.l %a5, (%sp) | (%sp) = count + + move.l #0, %macsr | signed integer mode + move.l (12*4+4,%sp), %a6 | %a6 = p + move.l (%a6), %a5 | %a5 = p->buf + +.loop: + + | ***** PREDICTOR Y ***** + + | Predictor Y, Filter A + + move.l (YlastA,%a6), %d3 | %d3 = p->YlastA + + movem.l (YDELAYA-12,%a5), %d0-%d2 | %d0 = p->buf[YDELAYA-3] + | %d1 = p->buf[YDELAYA-2] + | %d2 = p->buf[YDELAYA-1] + + move.l %d3, (YDELAYA,%a5) | p->buf[YDELAYA] = %d3 + + sub.l %d3, %d2 + neg.l %d2 | %d2 = %d3 - %d2 + + move.l %d2, (YDELAYA-4,%a5) | p->buf[YDELAYA-1] = %d2 + + movem.l (YcoeffsA,%a6), %d4-%d7 | %d4 = p->YcoeffsA[0] + | %d5 = p->YcoeffsA[1] + | %d6 = p->YcoeffsA[2] + | %d7 = p->YcoeffsA[3] + + mac.l %d3, %d4, %acc0 | %acc0 = p->buf[YDELAYA] * p->YcoeffsA[0] + mac.l %d2, %d5, %acc0 | %acc0 += p->buf[YDELAYA-1] * p->YcoeffsA[1] + mac.l %d1, %d6, %acc0 | %acc0 += p->buf[YDELAYA-2] * p->YcoeffsA[2] + mac.l %d0, %d7, %acc0 | %acc0 += p->buf[YDELAYA-3] * p->YcoeffsA[3] + + tst.l %d2 + beq.s 1f + spl.b %d2 | pos: 0x??????ff, neg: 0x??????00 + extb.l %d2 | pos: 0xffffffff, neg: 0x00000000 + or.l #1, %d2 | pos: 0xffffffff, neg: 0x00000001 +1: | %d2 = SIGN(%d2) + move.l %d2, (YADAPTCOEFFSA-4,%a5) | p->buf[YADAPTCOEFFSA-1] = %d2 + + tst.l %d3 + beq.s 1f + spl.b %d3 + extb.l %d3 + or.l #1, %d3 +1: | %d3 = SIGN(%d3) + move.l %d3, (YADAPTCOEFFSA,%a5) | p->buf[YADAPTCOEFFSA] = %d3 + + | Predictor Y, Filter B + + movem.l (YfilterB,%a6), %d2-%d3 | %d2 = p->YfilterB + | %d3 = p->XfilterA + move.l %d3, (YfilterB,%a6) | p->YfilterB = %d3 + + move.l %d2, %d1 | %d1 = %d2 + lsl.l #5, %d2 | %d2 = %d2 * 32 + sub.l %d1, %d2 | %d2 -= %d1 (== 31 * old_d2) + asr.l #5, %d2 | %d2 >>= 5 + sub.l %d2, %d3 | %d3 -= %d2 + + movem.l (YDELAYB-16,%a5), %d4-%d7 | %d4 = p->buf[YDELAYB-4] + | %d5 = p->buf[YDELAYB-3] + | %d6 = p->buf[YDELAYB-2] + | %d7 = p->buf[YDELAYB-1] + sub.l %d3, %d7 + neg.l %d7 | %d7 = %d3 - %d7 + + move.l %d7, (YDELAYB-4,%a5) | p->buf[YDELAYB-1] = %d7 + + movem.l (YcoeffsB,%a6), %d1-%d2/%a0-%a2 | %d1 = p->YcoeffsB[0] + | %d2 = p->YcoeffsB[1] + | %a0 = p->YcoeffsB[2] + | %a1 = p->YcoeffsB[3] + | %a2 = p->YcoeffsB[4] + + mac.l %d3, %d1, %acc1 | %acc1 = p->buf[YDELAYB] * p->YcoeffsB[0] + mac.l %d7, %d2, %acc1 | %acc1 += p->buf[YDELAYB-1] * p->YcoeffsB[1] + mac.l %d6, %a0, %acc1 | %acc1 += p->buf[YDELAYB-2] * p->YcoeffsB[2] + mac.l %d5, %a1, %acc1 | %acc1 += p->buf[YDELAYB-3] * p->YcoeffsB[3] + mac.l %d4, %a2, %acc1 | %acc1 += p->buf[YDELAYB-4] * p->YcoeffsB[4] + + move.l %d3, (YDELAYB, %a5) | p->buf[YDELAYB] = %d3 + + tst.l %d7 + beq.s 1f + spl.b %d7 + extb.l %d7 + or.l #1, %d7 +1: | %d7 = SIGN(%d7) + move.l %d7, (YADAPTCOEFFSB-4,%a5) | p->buf[YADAPTCOEFFSB-1] = %d7 + tst.l %d3 + beq.s 1f + spl.b %d3 + extb.l %d3 + or.l #1, %d3 +1: | %d3 = SIGN(%d3) + move.l %d3, (YADAPTCOEFFSB, %a5) | p->buf[YADAPTCOEFFSB] = %d3 + + | %d1, %d2, %a0, %a1, %a2 contain p->YcoeffsB[0..4] + | %d7, %d3 contain p->buf[YADAPTCOEFFSB-1] and p->buf[YADAPTCOEFFSB] + + move.l (%a3), %d0 | %d0 = *decoded0 + beq.s 3f + + movem.l (YADAPTCOEFFSB-16,%a5), %d4-%d6 | %d4 = p->buf[YADAPTCOEFFSB-4] + | %d5 = p->buf[YADAPTCOEFFSB-3] + | %d6 = p->buf[YADAPTCOEFFSB-2] + + bmi.s 1f | flags still valid here + + | *decoded0 > 0 + + sub.l %d3, %d1 | %d1 = p->YcoeffsB[0] - p->buf[YADAPTCOEFFSB] + sub.l %d7, %d2 | %d2 = p->YcoeffsB[1] - p->buf[YADAPTCOEFFSB-1] + sub.l %d6, %a0 | %a0 = p->YcoeffsB[2] - p->buf[YADAPTCOEFFSB-2] + sub.l %d5, %a1 | %a1 = p->YcoeffsB[3] - p->buf[YADAPTCOEFFSB-3] + sub.l %d4, %a2 | %a2 = p->YcoeffsB[4] - p->buf[YADAPTCOEFFSB-4] + + movem.l %d1-%d2/%a0-%a2, (YcoeffsB,%a6) | Save p->YcoeffsB[] + + movem.l (YcoeffsA,%a6), %d4-%d7 | %d4 = p->YcoeffsA[0] + | %d5 = p->YcoeffsA[1] + | %d6 = p->YcoeffsA[2] + | %d7 = p->YcoeffsA[3] + + movem.l (YADAPTCOEFFSA-12,%a5), %d2/%a0-%a2 + | %d2 = p->buf[YADAPTCOEFFSA-3] + | %a0 = p->buf[YADAPTCOEFFSA-2] + | %a1 = p->buf[YADAPTCOEFFSA-1] + | %a2 = p->buf[YADAPTCOEFFSA] + + sub.l %a2, %d4 | %d4 = p->YcoeffsA[0] - p->buf[YADAPTCOEFFSA] + sub.l %a1, %d5 | %d5 = p->YcoeffsA[1] - p->buf[YADAPTCOEFFSA-1] + sub.l %a0, %d6 | %d6 = p->YcoeffsA[2] - p->buf[YADAPTCOEFFSA-2] + sub.l %d2, %d7 | %d7 = p->YcoeffsA[3] - p->buf[YADAPTCOEFFSA-3] + + bra.s 2f + +1: | *decoded0 < 0 + + add.l %d3, %d1 | %d1 = p->YcoeffsB[0] + p->buf[YADAPTCOEFFSB] + add.l %d7, %d2 | %d2 = p->YcoeffsB[1] + p->buf[YADAPTCOEFFSB-1] + add.l %d6, %a0 | %a0 = p->YcoeffsB[2] + p->buf[YADAPTCOEFFSB-2] + add.l %d5, %a1 | %a1 = p->YcoeffsB[3] + p->buf[YADAPTCOEFFSB-3] + add.l %d4, %a2 | %a2 = p->YcoeffsB[4] + p->buf[YADAPTCOEFFSB-4] + + movem.l %d1-%d2/%a0-%a2, (YcoeffsB,%a6) | Save p->YcoeffsB[] + + movem.l (YcoeffsA,%a6), %d4-%d7 | %d4 = p->YcoeffsA[0] + | %d5 = p->YcoeffsA[1] + | %d6 = p->YcoeffsA[2] + | %d7 = p->YcoeffsA[3] + + movem.l (YADAPTCOEFFSA-12,%a5), %d2/%a0-%a2 + | %d2 = p->buf[YADAPTCOEFFSA-3] + | %a0 = p->buf[YADAPTCOEFFSA-2] + | %a1 = p->buf[YADAPTCOEFFSA-1] + | %a2 = p->buf[YADAPTCOEFFSA] + + add.l %a2, %d4 | %d4 = p->YcoeffsA[0] + p->buf[YADAPTCOEFFSA] + add.l %a1, %d5 | %d5 = p->YcoeffsA[1] + p->buf[YADAPTCOEFFSA-1] + add.l %a0, %d6 | %d6 = p->YcoeffsA[2] + p->buf[YADAPTCOEFFSA-2] + add.l %d2, %d7 | %d7 = p->YcoeffsA[3] + p->buf[YADAPTCOEFFSA-3] + +2: + movem.l %d4-%d7, (YcoeffsA,%a6) | Save p->YcoeffsA[] + +3: + | Finish Predictor Y + + movclr.l %acc0, %d1 | %d1 = predictionA + movclr.l %acc1, %d2 | %d2 = predictionB + asr.l #1, %d2 + add.l %d2, %d1 | %d1 += (%d2 >> 1) + asr.l #8, %d1 + asr.l #2, %d1 | %d1 >>= 10 + add.l %d0, %d1 | %d1 += %d0 + move.l %d1, (YlastA,%a6) | p->YlastA = %d1 + + move.l (YfilterA,%a6), %d2 | %d2 = p->YfilterA + move.l %d2, %d0 + lsl.l #5, %d2 + sub.l %d0, %d2 | %d2 = 31 * %d2 + asr.l #5, %d2 | %d2 >>= 5 + add.l %d1, %d2 + move.l %d2, (YfilterA,%a6) | p->YfilterA = %d2 + + | *decoded0 stored 2 instructions down, avoiding pipeline stall + + | ***** PREDICTOR X ***** + + | Predictor X, Filter A + + move.l (XlastA,%a6), %d3 | %d3 = p->XlastA + + move.l %d2, (%a3)+ | *(decoded0++) = %d2 (p->YfilterA) + + movem.l (XDELAYA-12,%a5), %d0-%d2 | %d0 = p->buf[XDELAYA-3] + | %d1 = p->buf[XDELAYA-2] + | %d2 = p->buf[XDELAYA-1] + + move.l %d3, (XDELAYA,%a5) | p->buf[XDELAYA] = %d3 + + sub.l %d3, %d2 + neg.l %d2 | %d2 = %d3 -%d2 + + move.l %d2, (XDELAYA-4,%a5) | p->buf[XDELAYA-1] = %d2 + + movem.l (XcoeffsA,%a6), %d4-%d7 | %d4 = p->XcoeffsA[0] + | %d5 = p->XcoeffsA[1] + | %d6 = p->XcoeffsA[2] + | %d7 = p->XcoeffsA[3] + + mac.l %d3, %d4, %acc0 | %acc0 = p->buf[XDELAYA] * p->XcoeffsA[0] + mac.l %d2, %d5, %acc0 | %acc0 += p->buf[XDELAYA-1] * p->XcoeffsA[1] + mac.l %d1, %d6, %acc0 | %acc0 += p->buf[XDELAYA-2] * p->XcoeffsA[2] + mac.l %d0, %d7, %acc0 | %acc0 += p->buf[XDELAYA-3] * p->XcoeffsA[3] + + tst.l %d2 + beq.s 1f + spl.b %d2 | pos: 0x??????ff, neg: 0x??????00 + extb.l %d2 | pos: 0xffffffff, neg: 0x00000000 + or.l #1, %d2 | pos: 0xffffffff, neg: 0x00000001 +1: | %d2 = SIGN(%d2) + move.l %d2, (XADAPTCOEFFSA-4,%a5) | p->buf[XADAPTCOEFFSA-1] = %d2 + + tst.l %d3 + beq.s 1f + spl.b %d3 + extb.l %d3 + or.l #1, %d3 +1: | %d3 = SIGN(%d3) + move.l %d3, (XADAPTCOEFFSA,%a5) | p->buf[XADAPTCOEFFSA] = %d3 + + | Predictor X, Filter B + + movem.l (XfilterB,%a6), %d2-%d3 | %d2 = p->XfilterB + | %d3 = p->YfilterA + move.l %d3, (XfilterB,%a6) | p->XfilterB = %d3 + + move.l %d2, %d1 | %d1 = %d2 + lsl.l #5, %d2 | %d2 = %d2 * 32 + sub.l %d1, %d2 | %d2 -= %d1 (== 31 * old_d2) + asr.l #5, %d2 | %d2 >>= 5 + sub.l %d2, %d3 | %d3 -= %d2 + + movem.l (XDELAYB-16,%a5), %d4-%d7 | %d4 = p->buf[XDELAYB-4] + | %d5 = p->buf[XDELAYB-3] + | %d6 = p->buf[XDELAYB-2] + | %d7 = p->buf[XDELAYB-1] + sub.l %d3, %d7 + neg.l %d7 | %d7 = %d3 - %d7 + + move.l %d7, (XDELAYB-4,%a5) | p->buf[XDELAYB-1] = %d7 + + movem.l (XcoeffsB,%a6), %d1-%d2/%a0-%a2 | %d1 = p->XcoeffsB[0] + | %d2 = p->XcoeffsB[1] + | %a0 = p->XcoeffsB[2] + | %a1 = p->XcoeffsB[3] + | %a2 = p->XcoeffsB[4] + + mac.l %d3, %d1, %acc1 | %acc1 = p->buf[XDELAYB] * p->XcoeffsB[0] + mac.l %d7, %d2, %acc1 | %acc1 += p->buf[XDELAYB-1] * p->XcoeffsB[1] + mac.l %d6, %a0, %acc1 | %acc1 += p->buf[XDELAYB-2] * p->XcoeffsB[2] + mac.l %d5, %a1, %acc1 | %acc1 += p->buf[XDELAYB-3] * p->XcoeffsB[3] + mac.l %d4, %a2, %acc1 | %acc1 += p->buf[XDELAYB-4] * p->XcoeffsB[4] + + move.l %d3, (XDELAYB, %a5) | p->buf[XDELAYB] = %d3 + + tst.l %d7 + beq.s 1f + spl.b %d7 + extb.l %d7 + or.l #1, %d7 +1: | %d7 = SIGN(%d7) + move.l %d7, (XADAPTCOEFFSB-4,%a5) | p->buf[XADAPTCOEFFSB-1] = %d7 + + tst.l %d3 + beq.s 1f + spl.b %d3 + extb.l %d3 + or.l #1, %d3 +1: | %d3 = SIGN(%d3) + move.l %d3, (XADAPTCOEFFSB, %a5) | p->buf[XADAPTCOEFFSB] = %d3 + + | %d1, %d2, %a0, %a1, %a2 contain p->XcoeffsB[0..4] + | %d7, %d3 contain p->buf[XADAPTCOEFFSB-1] and p->buf[XADAPTCOEFFSB] + + move.l (%a4), %d0 | %d0 = *decoded1 + beq.s 3f + + movem.l (XADAPTCOEFFSB-16,%a5), %d4-%d6 | %d4 = p->buf[XADAPTCOEFFSB-4] + | %d5 = p->buf[XADAPTCOEFFSB-3] + | %d6 = p->buf[XADAPTCOEFFSB-2] + + bmi.s 1f | flags still valid here + + | *decoded1 > 0 + + sub.l %d3, %d1 | %d1 = p->XcoeffsB[0] - p->buf[XADAPTCOEFFSB] + sub.l %d7, %d2 | %d2 = p->XcoeffsB[1] - p->buf[XADAPTCOEFFSB-1] + sub.l %d6, %a0 | %a0 = p->XcoeffsB[2] - p->buf[XADAPTCOEFFSB-2] + sub.l %d5, %a1 | %a1 = p->XcoeffsB[3] - p->buf[XADAPTCOEFFSB-3] + sub.l %d4, %a2 | %a2 = p->XcoeffsB[4] - p->buf[XADAPTCOEFFSB-4] + + movem.l %d1-%d2/%a0-%a2, (XcoeffsB,%a6) | Save p->XcoeffsB[] + + movem.l (XcoeffsA,%a6), %d4-%d7 | %d4 = p->XcoeffsA[0] + | %d5 = p->XcoeffsA[1] + | %d6 = p->XcoeffsA[2] + | %d7 = p->XcoeffsA[3] + + movem.l (XADAPTCOEFFSA-12,%a5), %d2/%a0-%a2 + | %d2 = p->buf[XADAPTCOEFFSA-3] + | %a0 = p->buf[XADAPTCOEFFSA-2] + | %a1 = p->buf[XADAPTCOEFFSA-1] + | %a2 = p->buf[XADAPTCOEFFSA] + + sub.l %a2, %d4 | %d4 = p->XcoeffsA[0] - p->buf[XADAPTCOEFFSA] + sub.l %a1, %d5 | %d5 = p->XcoeffsA[1] - p->buf[XADAPTCOEFFSA-1] + sub.l %a0, %d6 | %d6 = p->XcoeffsA[2] - p->buf[XADAPTCOEFFSA-2] + sub.l %d2, %d7 | %d7 = p->XcoeffsA[3] - p->buf[XADAPTCOEFFSA-3] + + bra.s 2f + +1: | *decoded1 < 0 + + add.l %d3, %d1 | %d1 = p->XcoeffsB[0] + p->buf[XADAPTCOEFFSB] + add.l %d7, %d2 | %d2 = p->XcoeffsB[1] + p->buf[XADAPTCOEFFSB-1] + add.l %d6, %a0 | %a0 = p->XcoeffsB[2] + p->buf[XADAPTCOEFFSB-2] + add.l %d5, %a1 | %a1 = p->XcoeffsB[3] + p->buf[XADAPTCOEFFSB-3] + add.l %d4, %a2 | %a2 = p->XcoeffsB[4] + p->buf[XADAPTCOEFFSB-4] + + movem.l %d1-%d2/%a0-%a2, (XcoeffsB,%a6) | Save p->XcoeffsB[] + + movem.l (XcoeffsA,%a6), %d4-%d7 | %d4 = p->XcoeffsA[0] + | %d5 = p->XcoeffsA[1] + | %d6 = p->XcoeffsA[2] + | %d7 = p->XcoeffsA[3] + + movem.l (XADAPTCOEFFSA-12,%a5), %d2/%a0-%a2 + | %d2 = p->buf[XADAPTCOEFFSA-3] + | %a0 = p->buf[XADAPTCOEFFSA-2] + | %a1 = p->buf[XADAPTCOEFFSA-1] + | %a2 = p->buf[XADAPTCOEFFSA] + + add.l %a2, %d4 | %d4 = p->XcoeffsA[0] + p->buf[XADAPTCOEFFSA] + add.l %a1, %d5 | %d5 = p->XcoeffsA[1] + p->buf[XADAPTCOEFFSA-1] + add.l %a0, %d6 | %d6 = p->XcoeffsA[2] + p->buf[XADAPTCOEFFSA-2] + add.l %d2, %d7 | %d7 = p->XcoeffsA[3] + p->buf[XADAPTCOEFFSA-3] + +2: + movem.l %d4-%d7, (XcoeffsA,%a6) | Save p->XcoeffsA[] + +3: + | Finish Predictor X + + movclr.l %acc0, %d1 | %d1 = predictionA + movclr.l %acc1, %d2 | %d2 = predictionB + asr.l #1, %d2 + add.l %d2, %d1 | %d1 += (%d2 >> 1) + asr.l #8, %d1 + asr.l #2, %d1 | %d1 >>= 10 + add.l %d0, %d1 | %d1 += %d0 + move.l %d1, (XlastA,%a6) | p->XlastA = %d1 + + move.l (XfilterA,%a6), %d2 | %d2 = p->XfilterA + move.l %d2, %d0 + lsl.l #5, %d2 + sub.l %d0, %d2 | %d2 = 31 * %d2 + asr.l #5, %d2 | %d6 >>= 2 + add.l %d1, %d2 + move.l %d2, (XfilterA,%a6) | p->XfilterA = %d2 + + | *decoded1 stored 3 instructions down, avoiding pipeline stall + + | ***** COMMON ***** + + addq.l #4, %a5 | p->buf++ + lea.l (historybuffer+PREDICTOR_HISTORY_SIZE*4,%a6), %a2 + | %a2 = &p->historybuffer[PREDICTOR_HISTORY_SIZE] + + move.l %d2, (%a4)+ | *(decoded1++) = %d2 (p->XfilterA) + + cmp.l %a2, %a5 + beq.s .move_hist | History buffer is full, we need to do a memmove + + subq.l #1, (%sp) | decrease loop count + bne.w .loop + +.done: + move.l %a5, (%a6) | Save value of p->buf + movem.l (4,%sp), %d2-%d7/%a2-%a6 + lea.l (12*4,%sp), %sp + rts + +.move_hist: + lea.l (historybuffer,%a6), %a2 + + | dest = %a2 (p->historybuffer) + | src = %a5 (p->buf) + | n = 200 + + movem.l (%a5), %d0-%d7/%a0-%a1 | 40 bytes + movem.l %d0-%d7/%a0-%a1, (%a2) + movem.l (40,%a5), %d0-%d7/%a0-%a1 | 40 bytes + movem.l %d0-%d7/%a0-%a1, (40,%a2) + movem.l (80,%a5), %d0-%d7/%a0-%a1 | 40 bytes + movem.l %d0-%d7/%a0-%a1, (80,%a2) + movem.l (120,%a5), %d0-%d7/%a0-%a1 | 40 bytes + movem.l %d0-%d7/%a0-%a1, (120,%a2) + movem.l (160,%a5), %d0-%d7/%a0-%a1 | 40 bytes + movem.l %d0-%d7/%a0-%a1, (160,%a2) + + move.l %a2, %a5 | p->buf = &p->historybuffer[0] + + subq.l #1, (%sp) | decrease loop count + bne.w .loop + + bra.s .done + .size predictor_decode_stereo, .-predictor_decode_stereo + + + .global predictor_decode_mono + .type predictor_decode_mono,@function + +| void predictor_decode_mono(struct predictor_t* p, +| int32_t* decoded0, +| int count) + +predictor_decode_mono: + lea.l (-11*4,%sp), %sp + movem.l %d2-%d7/%a2-%a6, (%sp) + + move.l #0, %macsr | signed integer mode + + move.l (11*4+4,%sp), %a6 | %a6 = p + move.l (11*4+8,%sp), %a4 | %a4 = decoded0 + move.l (11*4+12,%sp), %d7 | %d7 = count + move.l (%a6), %a5 | %a5 = p->buf + + move.l (YlastA,%a6), %d3 | %d3 = p->YlastA + +.loopm: + + | ***** PREDICTOR ***** + + movem.l (YDELAYA-12,%a5), %d0-%d2 | %d0 = p->buf[YDELAYA-3] + | %d1 = p->buf[YDELAYA-2] + | %d2 = p->buf[YDELAYA-1] + + move.l %d3, (YDELAYA,%a5) | p->buf[YDELAYA] = %d3 + + sub.l %d3, %d2 + neg.l %d2 | %d2 = %d3 - %d2 + + move.l %d2, (YDELAYA-4,%a5) | p->buf[YDELAYA-1] = %d2 + + movem.l (YcoeffsA,%a6), %a0-%a3 | %a0 = p->YcoeffsA[0] + | %a1 = p->YcoeffsA[1] + | %a2 = p->YcoeffsA[2] + | %a3 = p->YcoeffsA[3] + + mac.l %d3, %a0, %acc0 | %acc0 = p->buf[YDELAYA] * p->YcoeffsA[0] + mac.l %d2, %a1, %acc0 | %acc0 += p->buf[YDELAYA-1] * p->YcoeffsA[1] + mac.l %d1, %a2, %acc0 | %acc0 += p->buf[YDELAYA-2] * p->YcoeffsA[2] + mac.l %d0, %a3, %acc0 | %acc0 += p->buf[YDELAYA-3] * p->YcoeffsA[3] + + tst.l %d2 + beq.s 1f + spl.b %d2 | pos: 0x??????ff, neg: 0x??????00 + extb.l %d2 | pos: 0xffffffff, neg: 0x00000000 + or.l #1, %d2 | pos: 0xffffffff, neg: 0x00000001 +1: | %d2 = SIGN(%d2) + move.l %d2, (YADAPTCOEFFSA-4,%a5) | p->buf[YADAPTCOEFFSA-1] = %d2 + + tst.l %d3 + beq.s 1f + spl.b %d3 + extb.l %d3 + or.l #1, %d3 +1: | %d3 = SIGN(%d3) + move.l %d3, (YADAPTCOEFFSA,%a5) | p->buf[YADAPTCOEFFSA] = %d3 + + move.l (%a4), %d0 | %d0 = *decoded0 + beq.s 3f + + movem.l (YADAPTCOEFFSA-12,%a5),%d4-%d5 | %d4 = p->buf[YADAPTCOEFFSA-3] + | %d5 = p->buf[YADAPTCOEFFSA-2] + + bmi.s 1f | flags still valid here + + | *decoded0 > 0 + + sub.l %d3, %a0 | %a0 = p->YcoeffsA[0] - p->buf[YADAPTCOEFFSA] + sub.l %d2, %a1 | %a1 = p->YcoeffsA[1] - p->buf[YADAPTCOEFFSA-1] + sub.l %d5, %a2 | %a2 = p->YcoeffsA[2] - p->buf[YADAPTCOEFFSA-2] + sub.l %d4, %a3 | %a3 = p->YcoeffsA[3] - p->buf[YADAPTCOEFFSA-3] + + bra.s 2f + +1: | *decoded0 < 0 + + add.l %d3, %a0 | %a0 = p->YcoeffsA[0] - p->buf[YADAPTCOEFFSA] + add.l %d2, %a1 | %a1 = p->YcoeffsA[1] - p->buf[YADAPTCOEFFSA-1] + add.l %d5, %a2 | %a2 = p->YcoeffsA[2] - p->buf[YADAPTCOEFFSA-2] + add.l %d4, %a3 | %a3 = p->YcoeffsA[3] - p->buf[YADAPTCOEFFSA-3] + +2: + movem.l %a0-%a3, (YcoeffsA,%a6) | save p->YcoeffsA[] + +3: + | Finish Predictor + + movclr.l %acc0, %d3 | %d3 = predictionA + asr.l #8, %d3 + asr.l #2, %d3 | %d3 >>= 10 + add.l %d0, %d3 | %d3 += %d0 + + move.l (YfilterA,%a6), %d2 | %d2 = p->YfilterA + move.l %d2, %d0 + lsl.l #5, %d2 + sub.l %d0, %d2 | %d2 = 31 * %d2 + asr.l #5, %d2 | %d2 >>= 5 + add.l %d3, %d2 + move.l %d2, (YfilterA,%a6) | p->YfilterA = %d2 + + | *decoded0 stored 3 instructions down, avoiding pipeline stall + + | ***** COMMON ***** + + addq.l #4, %a5 | p->buf++ + lea.l (historybuffer+PREDICTOR_HISTORY_SIZE*4,%a6), %a3 + | %a3 = &p->historybuffer[PREDICTOR_HISTORY_SIZE] + + move.l %d2, (%a4)+ | *(decoded0++) = %d2 (p->YfilterA) + + cmp.l %a3, %a5 + beq.s .move_histm | History buffer is full, we need to do a memmove + + subq.l #1, %d7 | decrease loop count + bne.w .loopm + + move.l %d3, (YlastA,%a6) | %d3 = p->YlastA + +.donem: + move.l %a5, (%a6) | Save value of p->buf + movem.l (%sp), %d2-%d7/%a2-%a6 + lea.l (11*4,%sp), %sp + rts + +.move_histm: + move.l %d3, (YlastA,%a6) | %d3 = p->YlastA + + lea.l (historybuffer,%a6), %a3 + + | dest = %a3 (p->historybuffer) + | src = %a5 (p->buf) + | n = 200 + + movem.l (%a5), %d0-%d6/%a0-%a2 | 40 bytes + movem.l %d0-%d6/%a0-%a2, (%a3) + movem.l (40,%a5), %d0-%d6/%a0-%a2 | 40 bytes + movem.l %d0-%d6/%a0-%a2, (40,%a3) + movem.l (80,%a5), %d0-%d6/%a0-%a2 | 40 bytes + movem.l %d0-%d6/%a0-%a2, (80,%a3) + movem.l (120,%a5), %d0-%d6/%a0-%a2 | 40 bytes + movem.l %d0-%d6/%a0-%a2, (120,%a3) + movem.l (160,%a5), %d0-%d6/%a0-%a2 | 40 bytes + movem.l %d0-%d6/%a0-%a2, (160,%a3) + + move.l %a3, %a5 | p->buf = &p->historybuffer[0] + + move.l (YlastA,%a6), %d3 | %d3 = p->YlastA + + subq.l #1, %d7 | decrease loop count + bne.w .loopm + + bra.s .donem + .size predictor_decode_mono, .-predictor_decode_mono diff --git a/lib/rbcodec/codecs/demac/libdemac/predictor.c b/lib/rbcodec/codecs/demac/libdemac/predictor.c new file mode 100644 index 0000000000..45912dddbd --- /dev/null +++ b/lib/rbcodec/codecs/demac/libdemac/predictor.c @@ -0,0 +1,271 @@ +/* + +libdemac - A Monkey's Audio decoder + +$Id$ + +Copyright (C) Dave Chapman 2007 + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA + +*/ + +#include +#include + +#include "parser.h" +#include "predictor.h" +#include "demac_config.h" + +/* Return 0 if x is zero, -1 if x is positive, 1 if x is negative */ +#define SIGN(x) (x) ? (((x) > 0) ? -1 : 1) : 0 + +static const int32_t initial_coeffs[4] = { + 360, 317, -109, 98 +}; + +#define YDELAYA (18 + PREDICTOR_ORDER*4) +#define YDELAYB (18 + PREDICTOR_ORDER*3) +#define XDELAYA (18 + PREDICTOR_ORDER*2) +#define XDELAYB (18 + PREDICTOR_ORDER) + +#define YADAPTCOEFFSA (18) +#define XADAPTCOEFFSA (14) +#define YADAPTCOEFFSB (10) +#define XADAPTCOEFFSB (5) + +void init_predictor_decoder(struct predictor_t* p) +{ + /* Zero the history buffers */ + memset(p->historybuffer, 0, PREDICTOR_SIZE * sizeof(int32_t)); + p->buf = p->historybuffer; + + /* Initialise and zero the co-efficients */ + memcpy(p->YcoeffsA, initial_coeffs, sizeof(initial_coeffs)); + memcpy(p->XcoeffsA, initial_coeffs, sizeof(initial_coeffs)); + memset(p->YcoeffsB, 0, sizeof(p->YcoeffsB)); + memset(p->XcoeffsB, 0, sizeof(p->XcoeffsB)); + + p->YfilterA = 0; + p->YfilterB = 0; + p->YlastA = 0; + + p->XfilterA = 0; + p->XfilterB = 0; + p->XlastA = 0; +} + +#if !defined(CPU_ARM) && !defined(CPU_COLDFIRE) +void ICODE_ATTR_DEMAC predictor_decode_stereo(struct predictor_t* p, + int32_t* decoded0, + int32_t* decoded1, + int count) +{ + int32_t predictionA, predictionB; + + while (LIKELY(count--)) + { + /* Predictor Y */ + p->buf[YDELAYA] = p->YlastA; + p->buf[YADAPTCOEFFSA] = SIGN(p->buf[YDELAYA]); + + p->buf[YDELAYA-1] = p->buf[YDELAYA] - p->buf[YDELAYA-1]; + p->buf[YADAPTCOEFFSA-1] = SIGN(p->buf[YDELAYA-1]); + + predictionA = (p->buf[YDELAYA] * p->YcoeffsA[0]) + + (p->buf[YDELAYA-1] * p->YcoeffsA[1]) + + (p->buf[YDELAYA-2] * p->YcoeffsA[2]) + + (p->buf[YDELAYA-3] * p->YcoeffsA[3]); + + /* Apply a scaled first-order filter compression */ + p->buf[YDELAYB] = p->XfilterA - ((p->YfilterB * 31) >> 5); + p->buf[YADAPTCOEFFSB] = SIGN(p->buf[YDELAYB]); + p->YfilterB = p->XfilterA; + + p->buf[YDELAYB-1] = p->buf[YDELAYB] - p->buf[YDELAYB-1]; + p->buf[YADAPTCOEFFSB-1] = SIGN(p->buf[YDELAYB-1]); + + predictionB = (p->buf[YDELAYB] * p->YcoeffsB[0]) + + (p->buf[YDELAYB-1] * p->YcoeffsB[1]) + + (p->buf[YDELAYB-2] * p->YcoeffsB[2]) + + (p->buf[YDELAYB-3] * p->YcoeffsB[3]) + + (p->buf[YDELAYB-4] * p->YcoeffsB[4]); + + p->YlastA = *decoded0 + ((predictionA + (predictionB >> 1)) >> 10); + p->YfilterA = p->YlastA + ((p->YfilterA * 31) >> 5); + + /* Predictor X */ + + p->buf[XDELAYA] = p->XlastA; + p->buf[XADAPTCOEFFSA] = SIGN(p->buf[XDELAYA]); + p->buf[XDELAYA-1] = p->buf[XDELAYA] - p->buf[XDELAYA-1]; + p->buf[XADAPTCOEFFSA-1] = SIGN(p->buf[XDELAYA-1]); + + predictionA = (p->buf[XDELAYA] * p->XcoeffsA[0]) + + (p->buf[XDELAYA-1] * p->XcoeffsA[1]) + + (p->buf[XDELAYA-2] * p->XcoeffsA[2]) + + (p->buf[XDELAYA-3] * p->XcoeffsA[3]); + + /* Apply a scaled first-order filter compression */ + p->buf[XDELAYB] = p->YfilterA - ((p->XfilterB * 31) >> 5); + p->buf[XADAPTCOEFFSB] = SIGN(p->buf[XDELAYB]); + p->XfilterB = p->YfilterA; + p->buf[XDELAYB-1] = p->buf[XDELAYB] - p->buf[XDELAYB-1]; + p->buf[XADAPTCOEFFSB-1] = SIGN(p->buf[XDELAYB-1]); + + predictionB = (p->buf[XDELAYB] * p->XcoeffsB[0]) + + (p->buf[XDELAYB-1] * p->XcoeffsB[1]) + + (p->buf[XDELAYB-2] * p->XcoeffsB[2]) + + (p->buf[XDELAYB-3] * p->XcoeffsB[3]) + + (p->buf[XDELAYB-4] * p->XcoeffsB[4]); + + p->XlastA = *decoded1 + ((predictionA + (predictionB >> 1)) >> 10); + p->XfilterA = p->XlastA + ((p->XfilterA * 31) >> 5); + + if (LIKELY(*decoded0 != 0)) + { + if (*decoded0 > 0) + { + p->YcoeffsA[0] -= p->buf[YADAPTCOEFFSA]; + p->YcoeffsA[1] -= p->buf[YADAPTCOEFFSA-1]; + p->YcoeffsA[2] -= p->buf[YADAPTCOEFFSA-2]; + p->YcoeffsA[3] -= p->buf[YADAPTCOEFFSA-3]; + + p->YcoeffsB[0] -= p->buf[YADAPTCOEFFSB]; + p->YcoeffsB[1] -= p->buf[YADAPTCOEFFSB-1]; + p->YcoeffsB[2] -= p->buf[YADAPTCOEFFSB-2]; + p->YcoeffsB[3] -= p->buf[YADAPTCOEFFSB-3]; + p->YcoeffsB[4] -= p->buf[YADAPTCOEFFSB-4]; + } + else + { + p->YcoeffsA[0] += p->buf[YADAPTCOEFFSA]; + p->YcoeffsA[1] += p->buf[YADAPTCOEFFSA-1]; + p->YcoeffsA[2] += p->buf[YADAPTCOEFFSA-2]; + p->YcoeffsA[3] += p->buf[YADAPTCOEFFSA-3]; + + p->YcoeffsB[0] += p->buf[YADAPTCOEFFSB]; + p->YcoeffsB[1] += p->buf[YADAPTCOEFFSB-1]; + p->YcoeffsB[2] += p->buf[YADAPTCOEFFSB-2]; + p->YcoeffsB[3] += p->buf[YADAPTCOEFFSB-3]; + p->YcoeffsB[4] += p->buf[YADAPTCOEFFSB-4]; + } + } + + *(decoded0++) = p->YfilterA; + + if (LIKELY(*decoded1 != 0)) + { + if (*decoded1 > 0) + { + p->XcoeffsA[0] -= p->buf[XADAPTCOEFFSA]; + p->XcoeffsA[1] -= p->buf[XADAPTCOEFFSA-1]; + p->XcoeffsA[2] -= p->buf[XADAPTCOEFFSA-2]; + p->XcoeffsA[3] -= p->buf[XADAPTCOEFFSA-3]; + + p->XcoeffsB[0] -= p->buf[XADAPTCOEFFSB]; + p->XcoeffsB[1] -= p->buf[XADAPTCOEFFSB-1]; + p->XcoeffsB[2] -= p->buf[XADAPTCOEFFSB-2]; + p->XcoeffsB[3] -= p->buf[XADAPTCOEFFSB-3]; + p->XcoeffsB[4] -= p->buf[XADAPTCOEFFSB-4]; + } + else + { + p->XcoeffsA[0] += p->buf[XADAPTCOEFFSA]; + p->XcoeffsA[1] += p->buf[XADAPTCOEFFSA-1]; + p->XcoeffsA[2] += p->buf[XADAPTCOEFFSA-2]; + p->XcoeffsA[3] += p->buf[XADAPTCOEFFSA-3]; + + p->XcoeffsB[0] += p->buf[XADAPTCOEFFSB]; + p->XcoeffsB[1] += p->buf[XADAPTCOEFFSB-1]; + p->XcoeffsB[2] += p->buf[XADAPTCOEFFSB-2]; + p->XcoeffsB[3] += p->buf[XADAPTCOEFFSB-3]; + p->XcoeffsB[4] += p->buf[XADAPTCOEFFSB-4]; + } + } + + *(decoded1++) = p->XfilterA; + + /* Combined */ + p->buf++; + + /* Have we filled the history buffer? */ + if (UNLIKELY(p->buf == p->historybuffer + PREDICTOR_HISTORY_SIZE)) { + memmove(p->historybuffer, p->buf, + PREDICTOR_SIZE * sizeof(int32_t)); + p->buf = p->historybuffer; + } + } +} + +void ICODE_ATTR_DEMAC predictor_decode_mono(struct predictor_t* p, + int32_t* decoded0, + int count) +{ + int32_t predictionA, currentA, A; + + currentA = p->YlastA; + + while (LIKELY(count--)) + { + A = *decoded0; + + p->buf[YDELAYA] = currentA; + p->buf[YDELAYA-1] = p->buf[YDELAYA] - p->buf[YDELAYA-1]; + + predictionA = (p->buf[YDELAYA] * p->YcoeffsA[0]) + + (p->buf[YDELAYA-1] * p->YcoeffsA[1]) + + (p->buf[YDELAYA-2] * p->YcoeffsA[2]) + + (p->buf[YDELAYA-3] * p->YcoeffsA[3]); + + currentA = A + (predictionA >> 10); + + p->buf[YADAPTCOEFFSA] = SIGN(p->buf[YDELAYA]); + p->buf[YADAPTCOEFFSA-1] = SIGN(p->buf[YDELAYA-1]); + + if (LIKELY(A != 0)) + { + if (A > 0) + { + p->YcoeffsA[0] -= p->buf[YADAPTCOEFFSA]; + p->YcoeffsA[1] -= p->buf[YADAPTCOEFFSA-1]; + p->YcoeffsA[2] -= p->buf[YADAPTCOEFFSA-2]; + p->YcoeffsA[3] -= p->buf[YADAPTCOEFFSA-3]; + } + else + { + p->YcoeffsA[0] += p->buf[YADAPTCOEFFSA]; + p->YcoeffsA[1] += p->buf[YADAPTCOEFFSA-1]; + p->YcoeffsA[2] += p->buf[YADAPTCOEFFSA-2]; + p->YcoeffsA[3] += p->buf[YADAPTCOEFFSA-3]; + } + } + + p->buf++; + + /* Have we filled the history buffer? */ + if (UNLIKELY(p->buf == p->historybuffer + PREDICTOR_HISTORY_SIZE)) { + memmove(p->historybuffer, p->buf, + PREDICTOR_SIZE * sizeof(int32_t)); + p->buf = p->historybuffer; + } + + p->YfilterA = currentA + ((p->YfilterA * 31) >> 5); + *(decoded0++) = p->YfilterA; + } + + p->YlastA = currentA; +} +#endif diff --git a/lib/rbcodec/codecs/demac/libdemac/predictor.h b/lib/rbcodec/codecs/demac/libdemac/predictor.h new file mode 100644 index 0000000000..6a0a81983b --- /dev/null +++ b/lib/rbcodec/codecs/demac/libdemac/predictor.h @@ -0,0 +1,38 @@ +/* + +libdemac - A Monkey's Audio decoder + +$Id$ + +Copyright (C) Dave Chapman 2007 + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA + +*/ + +#ifndef _APE_PREDICTOR_H +#define _APE_PREDICTOR_H + +#include +#include "parser.h" +#include "filter.h" + +void init_predictor_decoder(struct predictor_t* p); +void predictor_decode_stereo(struct predictor_t* p, int32_t* decoded0, + int32_t* decoded1, int count); +void predictor_decode_mono(struct predictor_t* p, int32_t* decoded0, + int count); + +#endif diff --git a/lib/rbcodec/codecs/demac/libdemac/udiv32_arm-pre.S b/lib/rbcodec/codecs/demac/libdemac/udiv32_arm-pre.S new file mode 100644 index 0000000000..459cab8240 --- /dev/null +++ b/lib/rbcodec/codecs/demac/libdemac/udiv32_arm-pre.S @@ -0,0 +1,25 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2010 by Andrew Mahone + * + * Wrapper for udiv32_arm.S to test available IRAM by pre-linking the codec. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#define APE_PRE +#include "udiv32_arm.S" diff --git a/lib/rbcodec/codecs/demac/libdemac/udiv32_arm.S b/lib/rbcodec/codecs/demac/libdemac/udiv32_arm.S new file mode 100644 index 0000000000..7b851659bd --- /dev/null +++ b/lib/rbcodec/codecs/demac/libdemac/udiv32_arm.S @@ -0,0 +1,318 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2008 by Jens Arnold + * Copyright (C) 2009 by Andrew Mahone + * + * Optimised unsigned integer division for ARMv4 + * + * Based on: libgcc routines for ARM cpu, additional algorithms from ARM System + * Developer's Guide + * Division routines, written by Richard Earnshaw, (rearnsha@armltd.co.uk) + * Copyright 1995, 1996, 1998, 1999, 2000, 2003, 2004, 2005 + * Free Software Foundation, Inc. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include "config.h" +/* On targets with codec iram, a header file will be generated after an initial + link of the APE codec, stating the amount of IRAM remaining for use by the + reciprocal lookup table. */ +#if !defined(APE_PRE) && defined(USE_IRAM) && ARM_ARCH < 5 +#include "lib/rbcodec/codecs/ape_free_iram.h" +#endif + +/* Codecs should not normally do this, but we need to check a macro, and + * codecs.h would confuse the assembler. */ + +#ifdef USE_IRAM +#define DIV_RECIP + .section .icode,"ax",%progbits +#else + .text +#endif + .align + .global udiv32_arm + .type udiv32_arm,%function + +#if ARM_ARCH < 5 +/* Adapted from an algorithm given in ARM System Developer's Guide (7.3.1.2) + for dividing a 30-bit value by a 15-bit value, with two operations per + iteration by storing quotient and remainder together and adding the previous + quotient bit during trial subtraction. Modified to work with any dividend + and divisor both less than 1 << 30, and skipping trials by calculating bits + in output. */ +.macro ARM_DIV_31_BODY dividend, divisor, result, bits, curbit, quotient, remainder + + mov \bits, #1 + /* Shift the divisor left until it aligns with the numerator. If it already + has the high bit set, this is fine, everything inside .rept will be + skipped, and the add before and adcs after will set the one-bit result + to zero. */ + cmn \divisor, \dividend, lsr #16 + movcs \divisor, \divisor, lsl #16 + addcs \bits, \bits, #16 + cmn \divisor, \dividend, lsr #8 + movcs \divisor, \divisor, lsl #8 + addcs \bits, \bits, #8 + cmn \divisor, \dividend, lsr #4 + movcs \divisor, \divisor, lsl #4 + addcs \bits, \bits, #4 + cmn \divisor, \dividend, lsr #2 + movcs \divisor, \divisor, lsl #2 + addcs \bits, \bits, #2 + cmn \divisor, \dividend, lsr #1 + movcs \divisor, \divisor, lsl #1 + addcs \bits, \bits, #1 + adds \result, \dividend, \divisor + subcc \result, \result, \divisor + rsb \curbit, \bits, #31 + add pc, pc, \curbit, lsl #3 + nop + .rept 30 + adcs \result, \divisor, \result, lsl #1 + /* Fix the remainder portion of the result. This must be done because the + handler for 32-bit numerators needs the remainder. */ + subcc \result, \result, \divisor + .endr + /* Shift remainder/quotient left one, add final quotient bit */ + adc \result, \result, \result + mov \remainder, \result, lsr \bits + eor \quotient, \result, \remainder, lsl \bits +.endm + +#ifndef FREE_IRAM +.set recip_max, 2 +#else +/* Each table entry is one word. Since a compare is done against the maximum + entry as an immediate, the maximum entry must be a valid ARM immediate, + which means a byte shifted by an even number of places. */ +.set recip_max, 2 + FREE_IRAM / 4 +.set recip_max_tmp, recip_max >> 8 +.set recip_mask_shift, 0 +.set tmp_shift, 16 +.rept 5 + .if recip_max_tmp >> tmp_shift + .set recip_max_tmp, recip_max_tmp >> tmp_shift + .set recip_mask_shift, recip_mask_shift + tmp_shift + .endif + .set tmp_shift, tmp_shift >> 1 +.endr +.if recip_max_tmp + .set recip_mask_shift, recip_mask_shift + 1 +.endif +.set recip_mask_shift, (recip_mask_shift + 1) & 62 +.set recip_max, recip_max & (255 << recip_mask_shift) +//.set recip_max, 2 +#endif + +udiv32_arm: +#ifdef DIV_RECIP + cmp r1, #3 + bcc .L_udiv_tiny + cmp r1, #recip_max + bhi .L_udiv + adr r3, .L_udiv_recip_table-12 + ldr r2, [r3, r1, lsl #2] + mov r3, r0 + umull ip, r0, r2, r0 + mul r2, r0, r1 + cmp r3, r2 + bxcs lr + sub r0, r0, #1 + bx lr +.L_udiv_tiny: + cmp r1, #1 + movhi r0, r0, lsr #1 + bxcs lr + b .L_div0 +#endif +.L_udiv: + /* Invert divisor. ARM_DIV_31_BODY uses adc to both subtract the divisor + and add the next bit of the result. The correction code at .L_udiv32 + does not need the divisor inverted, but can be modified to work with it, + and this allows the zero divisor test to be done early and without an + explicit comparison. */ + rsbs r1, r1, #0 +#ifndef DIV_RECIP + beq .L_div0 +#endif + tst r0, r0 + /* High bit must be unset, otherwise shift numerator right, calculate, + and correct results. As this case is very uncommon we want to avoid + any other delays on the main path in handling it, so the long divide + calls the short divide as a function. */ + bmi .L_udiv32 +.L_udiv31: + ARM_DIV_31_BODY r0, r1, r2, r3, ip, r0, r1 + bx lr +.L_udiv32: + /* store original numerator and divisor, we'll need them to correct the + result, */ + stmdb sp, { r0, r1, lr } + /* Call __div0 here if divisor is zero, otherwise it would report the wrong + address. */ + mov r0, r0, lsr #1 + bl .L_udiv31 + ldmdb sp, { r2, r3, lr } + /* Move the low bit of the original numerator to the carry bit */ + movs r2, r2, lsr #1 + /* Shift the remainder left one and add in the carry bit */ + adc r1, r1, r1 + /* Subtract the original divisor from the remainder, setting carry if the + result is non-negative */ + adds r1, r1, r3 + /* Shift quotient left one and add carry bit */ + adc r0, r0, r0 + bx lr +.L_div0: + /* __div0 expects the calling address on the top of the stack */ + stmdb sp!, { lr } + mov r0, #0 +#if defined(__ARM_EABI__) || !defined(USE_IRAM) + bl __div0 +#else + ldr pc, [pc, #-4] + .word __div0 +#endif +#ifdef DIV_RECIP +.L_udiv_recip_table: + .set div, 3 + .rept recip_max - 2 + .if (div - 1) & div + .set q, 0x40000000 / div + .set r, (0x40000000 - (q * div))<<1 + .set q, q << 1 + .if r >= div + .set q, q + 1 + .set r, r - div + .endif + .set r, r << 1 + .set q, q << 1 + .if r >= div + .set q, q + 1 + .set r, r - div + .endif + .set q, q + 1 + .else + .set q, 0x40000000 / div * 4 + .endif + .word q + .set div, div+1 + .endr +#endif + .size udiv32_arm, . - udiv32_arm + +#else +.macro ARMV5_UDIV32_BODY numerator, divisor, quotient, bits, inv, neg, div0label + cmp \numerator, \divisor + clz \bits, \divisor + bcc 30f + mov \inv, \divisor, lsl \bits + add \neg, pc, \inv, lsr #25 + cmp \inv, #1<<31 + ldrhib \inv, [\neg, #.L_udiv_est_table-.-64] + bls 20f + subs \bits, \bits, #7 + rsb \neg, \divisor, #0 + movpl \divisor, \inv, lsl \bits + bmi 10f + mul \inv, \divisor, \neg + smlawt \divisor, \divisor, \inv, \divisor + mul \inv, \divisor, \neg + /* This will save a cycle on ARMv6, but requires that the numerator sign + bit is not set (that of inv is guaranteed unset). The branch should + predict very well, making it typically 1 cycle, and thus both the branch + and test fill delay cycles for the multiplies. Based on logging of + numerator sizes in the APE codec, the branch is taken about 1/10^7 of + the time. */ +#if ARM_ARCH >= 6 + tst \numerator, \numerator + smmla \divisor, \divisor, \inv, \divisor + bmi 40f + smmul \inv, \numerator, \divisor +#else + mov \bits, #0 + smlal \bits, \divisor, \inv, \divisor + umull \bits, \inv, \numerator, \divisor +#endif + add \numerator, \numerator, \neg + mla \divisor, \inv, \neg, \numerator + mov \quotient, \inv + cmn \divisor, \neg + addcc \quotient, \quotient, #1 + addpl \quotient, \quotient, #2 + bx lr +10: + rsb \bits, \bits, #0 + sub \inv, \inv, #4 + mov \divisor, \inv, lsr \bits + umull \bits, \inv, \numerator, \divisor + mla \divisor, \inv, \neg, \numerator + mov \quotient, \inv + cmn \neg, \divisor, lsr #1 + addcs \divisor, \divisor, \neg, lsl #1 + addcs \quotient, \quotient, #2 + cmn \neg, \divisor + addcs \quotient, \quotient, #1 + bx lr +20: +.ifnc "", "\div0label" + rsb \bits, \bits, #31 + bne \div0label +.endif + mov \quotient, \numerator, lsr \bits + bx lr +30: + mov \quotient, #0 + bx lr +#if ARM_ARCH >= 6 +40: + umull \bits, \inv, \numerator, \divisor + add \numerator, \numerator, \neg + mla \divisor, \inv, \neg, \numerator + mov \quotient, \inv + cmn \divisor, \neg + addcc \quotient, \quotient, #1 + addpl \quotient, \quotient, #2 + bx lr +#endif +.endm + +udiv32_arm: + ARMV5_UDIV32_BODY r0, r1, r0, r2, r3, ip, .L_div0 +.L_div0: + /* __div0 expects the calling address on the top of the stack */ + stmdb sp!, { lr } + mov r0, #0 +#if defined(__ARM_EABI__) || !defined(USE_IRAM) + bl __div0 +#else + ldr pc, [pc, #-4] + .word __div0 +#endif +.L_udiv_est_table: + .byte 0xff, 0xfc, 0xf8, 0xf4, 0xf0, 0xed, 0xea, 0xe6 + .byte 0xe3, 0xe0, 0xdd, 0xda, 0xd7, 0xd4, 0xd2, 0xcf + .byte 0xcc, 0xca, 0xc7, 0xc5, 0xc3, 0xc0, 0xbe, 0xbc + .byte 0xba, 0xb8, 0xb6, 0xb4, 0xb2, 0xb0, 0xae, 0xac + .byte 0xaa, 0xa8, 0xa7, 0xa5, 0xa3, 0xa2, 0xa0, 0x9f + .byte 0x9d, 0x9c, 0x9a, 0x99, 0x97, 0x96, 0x94, 0x93 + .byte 0x92, 0x90, 0x8f, 0x8e, 0x8d, 0x8c, 0x8a, 0x89 + .byte 0x88, 0x87, 0x86, 0x85, 0x84, 0x83, 0x82, 0x81 +#endif + .size udiv32_arm, . - udiv32_arm diff --git a/lib/rbcodec/codecs/demac/libdemac/vector_math16_armv5te.h b/lib/rbcodec/codecs/demac/libdemac/vector_math16_armv5te.h new file mode 100644 index 0000000000..ae7427c137 --- /dev/null +++ b/lib/rbcodec/codecs/demac/libdemac/vector_math16_armv5te.h @@ -0,0 +1,404 @@ +/* + +libdemac - A Monkey's Audio decoder + +$Id$ + +Copyright (C) Dave Chapman 2007 + +ARMv5te vector math copyright (C) 2008 Jens Arnold + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA + +*/ + +#define FUSED_VECTOR_MATH + +#define REPEAT_3(x) x x x +#if ORDER > 16 +#define REPEAT_MLA(x) x x x x x x x +#else +#define REPEAT_MLA(x) x x x +#endif + +/* Calculate scalarproduct, then add a 2nd vector (fused for performance) + * This version fetches data as 32 bit words, and *requires* v1 to be + * 32 bit aligned. It also requires that f2 and s2 are either both 32 bit + * aligned or both unaligned. If either condition isn't met, it will either + * result in a data abort or incorrect results. */ +static inline int32_t vector_sp_add(int16_t* v1, int16_t* f2, int16_t* s2) +{ + int res; +#if ORDER > 16 + int cnt = ORDER>>4; +#endif + +#define ADDHALFREGS(sum, s1, s2) /* Adds register */ \ + "mov " #s1 ", " #s1 ", ror #16 \n" /* halves straight */ \ + "add " #sum ", " #s1 ", " #s2 ", lsl #16 \n" /* Clobbers 's1' */ \ + "add " #s1 ", " #s1 ", " #s2 ", lsr #16 \n" \ + "mov " #s1 ", " #s1 ", lsl #16 \n" \ + "orr " #sum ", " #s1 ", " #sum ", lsr #16 \n" + +#define ADDHALFXREGS(sum, s1, s2) /* Adds register */ \ + "add " #s1 ", " #s1 ", " #sum ", lsl #16 \n" /* halves across. */ \ + "add " #sum ", " #s2 ", " #sum ", lsr #16 \n" /* Clobbers 's1'. */ \ + "mov " #sum ", " #sum ", lsl #16 \n" \ + "orr " #sum ", " #sum ", " #s1 ", lsr #16 \n" + + asm volatile ( +#if ORDER > 16 + "mov %[res], #0 \n" +#endif + "tst %[f2], #2 \n" + "beq 20f \n" + + "10: \n" + "ldrh r4, [%[s2]], #2 \n" + "mov r4, r4, lsl #16 \n" + "ldrh r3, [%[f2]], #2 \n" +#if ORDER > 16 + "mov r3, r3, lsl #16 \n" + "1: \n" + "ldmia %[v1], {r0,r1} \n" + "smlabt %[res], r0, r3, %[res] \n" +#else + "ldmia %[v1], {r0,r1} \n" + "smulbb %[res], r0, r3 \n" +#endif + "ldmia %[f2]!, {r2,r3} \n" + "smlatb %[res], r0, r2, %[res] \n" + "smlabt %[res], r1, r2, %[res] \n" + "smlatb %[res], r1, r3, %[res] \n" + "ldmia %[s2]!, {r2,r5} \n" + ADDHALFXREGS(r0, r4, r2) + ADDHALFXREGS(r1, r2, r5) + "stmia %[v1]!, {r0,r1} \n" + "ldmia %[v1], {r0,r1} \n" + "smlabt %[res], r0, r3, %[res] \n" + "ldmia %[f2]!, {r2,r3} \n" + "smlatb %[res], r0, r2, %[res] \n" + "smlabt %[res], r1, r2, %[res] \n" + "smlatb %[res], r1, r3, %[res] \n" + "ldmia %[s2]!, {r2,r4} \n" + ADDHALFXREGS(r0, r5, r2) + ADDHALFXREGS(r1, r2, r4) + "stmia %[v1]!, {r0,r1} \n" + + "ldmia %[v1], {r0,r1} \n" + "smlabt %[res], r0, r3, %[res] \n" + "ldmia %[f2]!, {r2,r3} \n" + "smlatb %[res], r0, r2, %[res] \n" + "smlabt %[res], r1, r2, %[res] \n" + "smlatb %[res], r1, r3, %[res] \n" + "ldmia %[s2]!, {r2,r5} \n" + ADDHALFXREGS(r0, r4, r2) + ADDHALFXREGS(r1, r2, r5) + "stmia %[v1]!, {r0,r1} \n" + "ldmia %[v1], {r0,r1} \n" + "smlabt %[res], r0, r3, %[res] \n" + "ldmia %[f2]!, {r2,r3} \n" + "smlatb %[res], r0, r2, %[res] \n" + "smlabt %[res], r1, r2, %[res] \n" + "smlatb %[res], r1, r3, %[res] \n" + "ldmia %[s2]!, {r2,r4} \n" + ADDHALFXREGS(r0, r5, r2) + ADDHALFXREGS(r1, r2, r4) + "stmia %[v1]!, {r0,r1} \n" +#if ORDER > 16 + "subs %[cnt], %[cnt], #1 \n" + "bne 1b \n" +#endif + "b 99f \n" + + "20: \n" + "1: \n" + "ldmia %[v1], {r1,r2} \n" + "ldmia %[f2]!, {r3,r4} \n" +#if ORDER > 16 + "smlabb %[res], r1, r3, %[res] \n" +#else + "smulbb %[res], r1, r3 \n" +#endif + "smlatt %[res], r1, r3, %[res] \n" + "smlabb %[res], r2, r4, %[res] \n" + "smlatt %[res], r2, r4, %[res] \n" + "ldmia %[s2]!, {r3,r4} \n" + ADDHALFREGS(r0, r1, r3) + ADDHALFREGS(r1, r2, r4) + "stmia %[v1]!, {r0,r1} \n" + + REPEAT_3( + "ldmia %[v1], {r1,r2} \n" + "ldmia %[f2]!, {r3,r4} \n" + "smlabb %[res], r1, r3, %[res] \n" + "smlatt %[res], r1, r3, %[res] \n" + "smlabb %[res], r2, r4, %[res] \n" + "smlatt %[res], r2, r4, %[res] \n" + "ldmia %[s2]!, {r3,r4} \n" + ADDHALFREGS(r0, r1, r3) + ADDHALFREGS(r1, r2, r4) + "stmia %[v1]!, {r0,r1} \n" + ) +#if ORDER > 16 + "subs %[cnt], %[cnt], #1 \n" + "bne 1b \n" +#endif + + "99: \n" + : /* outputs */ +#if ORDER > 16 + [cnt]"+r"(cnt), +#endif + [v1] "+r"(v1), + [f2] "+r"(f2), + [s2] "+r"(s2), + [res]"=r"(res) + : /* inputs */ + : /* clobbers */ + "r0", "r1", "r2", "r3", "r4", "r5", "cc", "memory" + ); + return res; +} + +/* Calculate scalarproduct, then subtract a 2nd vector (fused for performance) + * This version fetches data as 32 bit words, and *requires* v1 to be + * 32 bit aligned. It also requires that f2 and s2 are either both 32 bit + * aligned or both unaligned. If either condition isn't met, it will either + * result in a data abort or incorrect results. */ +static inline int32_t vector_sp_sub(int16_t* v1, int16_t* f2, int16_t* s2) +{ + int res; +#if ORDER > 16 + int cnt = ORDER>>4; +#endif + +#define SUBHALFREGS(dif, s1, s2) /* Subtracts reg. */ \ + "mov " #s1 ", " #s1 ", ror #16 \n" /* halves straight */ \ + "sub " #dif ", " #s1 ", " #s2 ", lsl #16 \n" /* Clobbers 's1' */ \ + "sub " #s1 ", " #s1 ", " #s2 ", lsr #16 \n" \ + "mov " #s1 ", " #s1 ", lsl #16 \n" \ + "orr " #dif ", " #s1 ", " #dif ", lsr #16 \n" + +#define SUBHALFXREGS(dif, s1, s2, msk) /* Subtracts reg. */ \ + "sub " #s1 ", " #dif ", " #s1 ", lsr #16 \n" /* halves across. */ \ + "and " #s1 ", " #s1 ", " #msk " \n" /* Needs msk = */ \ + "rsb " #dif ", " #s2 ", " #dif ", lsr #16 \n" /* 0x0000ffff, */ \ + "orr " #dif ", " #s1 ", " #dif ", lsl #16 \n" /* clobbers 's1'. */ + + asm volatile ( +#if ORDER > 16 + "mov %[res], #0 \n" +#endif + "tst %[f2], #2 \n" + "beq 20f \n" + + "10: \n" + "mov r6, #0xff \n" + "orr r6, r6, #0xff00 \n" + "ldrh r4, [%[s2]], #2 \n" + "mov r4, r4, lsl #16 \n" + "ldrh r3, [%[f2]], #2 \n" +#if ORDER > 16 + "mov r3, r3, lsl #16 \n" + "1: \n" + "ldmia %[v1], {r0,r1} \n" + "smlabt %[res], r0, r3, %[res] \n" +#else + "ldmia %[v1], {r0,r1} \n" + "smulbb %[res], r0, r3 \n" +#endif + "ldmia %[f2]!, {r2,r3} \n" + "smlatb %[res], r0, r2, %[res] \n" + "smlabt %[res], r1, r2, %[res] \n" + "smlatb %[res], r1, r3, %[res] \n" + "ldmia %[s2]!, {r2,r5} \n" + SUBHALFXREGS(r0, r4, r2, r6) + SUBHALFXREGS(r1, r2, r5, r6) + "stmia %[v1]!, {r0,r1} \n" + "ldmia %[v1], {r0,r1} \n" + "smlabt %[res], r0, r3, %[res] \n" + "ldmia %[f2]!, {r2,r3} \n" + "smlatb %[res], r0, r2, %[res] \n" + "smlabt %[res], r1, r2, %[res] \n" + "smlatb %[res], r1, r3, %[res] \n" + "ldmia %[s2]!, {r2,r4} \n" + SUBHALFXREGS(r0, r5, r2, r6) + SUBHALFXREGS(r1, r2, r4, r6) + "stmia %[v1]!, {r0,r1} \n" + + "ldmia %[v1], {r0,r1} \n" + "smlabt %[res], r0, r3, %[res] \n" + "ldmia %[f2]!, {r2,r3} \n" + "smlatb %[res], r0, r2, %[res] \n" + "smlabt %[res], r1, r2, %[res] \n" + "smlatb %[res], r1, r3, %[res] \n" + "ldmia %[s2]!, {r2,r5} \n" + SUBHALFXREGS(r0, r4, r2, r6) + SUBHALFXREGS(r1, r2, r5, r6) + "stmia %[v1]!, {r0,r1} \n" + "ldmia %[v1], {r0,r1} \n" + "smlabt %[res], r0, r3, %[res] \n" + "ldmia %[f2]!, {r2,r3} \n" + "smlatb %[res], r0, r2, %[res] \n" + "smlabt %[res], r1, r2, %[res] \n" + "smlatb %[res], r1, r3, %[res] \n" + "ldmia %[s2]!, {r2,r4} \n" + SUBHALFXREGS(r0, r5, r2, r6) + SUBHALFXREGS(r1, r2, r4, r6) + "stmia %[v1]!, {r0,r1} \n" +#if ORDER > 16 + "subs %[cnt], %[cnt], #1 \n" + "bne 1b \n" +#endif + "b 99f \n" + + "20: \n" + "1: \n" + "ldmia %[v1], {r1,r2} \n" + "ldmia %[f2]!, {r3,r4} \n" +#if ORDER > 16 + "smlabb %[res], r1, r3, %[res] \n" +#else + "smulbb %[res], r1, r3 \n" +#endif + "smlatt %[res], r1, r3, %[res] \n" + "smlabb %[res], r2, r4, %[res] \n" + "smlatt %[res], r2, r4, %[res] \n" + "ldmia %[s2]!, {r3,r4} \n" + SUBHALFREGS(r0, r1, r3) + SUBHALFREGS(r1, r2, r4) + "stmia %[v1]!, {r0,r1} \n" + + REPEAT_3( + "ldmia %[v1], {r1,r2} \n" + "ldmia %[f2]!, {r3,r4} \n" + "smlabb %[res], r1, r3, %[res] \n" + "smlatt %[res], r1, r3, %[res] \n" + "smlabb %[res], r2, r4, %[res] \n" + "smlatt %[res], r2, r4, %[res] \n" + "ldmia %[s2]!, {r3,r4} \n" + SUBHALFREGS(r0, r1, r3) + SUBHALFREGS(r1, r2, r4) + "stmia %[v1]!, {r0,r1} \n" + ) +#if ORDER > 16 + "subs %[cnt], %[cnt], #1 \n" + "bne 1b \n" +#endif + + "99: \n" + : /* outputs */ +#if ORDER > 16 + [cnt]"+r"(cnt), +#endif + [v1] "+r"(v1), + [f2] "+r"(f2), + [s2] "+r"(s2), + [res]"=r"(res) + : /* inputs */ + : /* clobbers */ + "r0", "r1", "r2", "r3", "r4", "r5", "r6", "cc", "memory" + ); + return res; +} + +/* This version fetches data as 32 bit words, and *requires* v1 to be + * 32 bit aligned, otherwise it will result either in a data abort, or + * incorrect results (if ARM aligncheck is disabled). */ +static inline int32_t scalarproduct(int16_t* v1, int16_t* v2) +{ + int res; +#if ORDER > 32 + int cnt = ORDER>>5; +#endif + + asm volatile ( +#if ORDER > 32 + "mov %[res], #0 \n" +#endif + "tst %[v2], #2 \n" + "beq 20f \n" + + "10: \n" + "ldrh r3, [%[v2]], #2 \n" +#if ORDER > 32 + "mov r3, r3, lsl #16 \n" + "1: \n" + "ldmia %[v1]!, {r0,r1} \n" + "smlabt %[res], r0, r3, %[res] \n" +#else + "ldmia %[v1]!, {r0,r1} \n" + "smulbb %[res], r0, r3 \n" +#endif + "ldmia %[v2]!, {r2,r3} \n" + "smlatb %[res], r0, r2, %[res] \n" + "smlabt %[res], r1, r2, %[res] \n" + "smlatb %[res], r1, r3, %[res] \n" + + REPEAT_MLA( + "ldmia %[v1]!, {r0,r1} \n" + "smlabt %[res], r0, r3, %[res] \n" + "ldmia %[v2]!, {r2,r3} \n" + "smlatb %[res], r0, r2, %[res] \n" + "smlabt %[res], r1, r2, %[res] \n" + "smlatb %[res], r1, r3, %[res] \n" + ) +#if ORDER > 32 + "subs %[cnt], %[cnt], #1 \n" + "bne 1b \n" +#endif + "b 99f \n" + + "20: \n" + "1: \n" + "ldmia %[v1]!, {r0,r1} \n" + "ldmia %[v2]!, {r2,r3} \n" +#if ORDER > 32 + "smlabb %[res], r0, r2, %[res] \n" +#else + "smulbb %[res], r0, r2 \n" +#endif + "smlatt %[res], r0, r2, %[res] \n" + "smlabb %[res], r1, r3, %[res] \n" + "smlatt %[res], r1, r3, %[res] \n" + + REPEAT_MLA( + "ldmia %[v1]!, {r0,r1} \n" + "ldmia %[v2]!, {r2,r3} \n" + "smlabb %[res], r0, r2, %[res] \n" + "smlatt %[res], r0, r2, %[res] \n" + "smlabb %[res], r1, r3, %[res] \n" + "smlatt %[res], r1, r3, %[res] \n" + ) +#if ORDER > 32 + "subs %[cnt], %[cnt], #1 \n" + "bne 1b \n" +#endif + + "99: \n" + : /* outputs */ +#if ORDER > 32 + [cnt]"+r"(cnt), +#endif + [v1] "+r"(v1), + [v2] "+r"(v2), + [res]"=r"(res) + : /* inputs */ + : /* clobbers */ + "r0", "r1", "r2", "r3", "cc", "memory" + ); + return res; +} diff --git a/lib/rbcodec/codecs/demac/libdemac/vector_math16_armv6.h b/lib/rbcodec/codecs/demac/libdemac/vector_math16_armv6.h new file mode 100644 index 0000000000..8d27331b62 --- /dev/null +++ b/lib/rbcodec/codecs/demac/libdemac/vector_math16_armv6.h @@ -0,0 +1,490 @@ +/* + +libdemac - A Monkey's Audio decoder + +$Id$ + +Copyright (C) Dave Chapman 2007 + +ARMv6 vector math copyright (C) 2008 Jens Arnold + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA + +*/ + +#define FUSED_VECTOR_MATH + +#if ORDER > 16 +#define REPEAT_BLOCK(x) x x x +#else +#define REPEAT_BLOCK(x) x +#endif + +/* Calculate scalarproduct, then add a 2nd vector (fused for performance) + * This version fetches data as 32 bit words, and *requires* v1 to be + * 32 bit aligned. It also requires that f2 and s2 are either both 32 bit + * aligned or both unaligned. If either condition isn't met, it will either + * result in a data abort or incorrect results. */ +static inline int32_t vector_sp_add(int16_t* v1, int16_t* f2, int16_t* s2) +{ + int res; +#if ORDER > 32 + int cnt = ORDER>>5; +#endif + + asm volatile ( +#if ORDER > 32 + "mov %[res], #0 \n" +#endif + "tst %[f2], #2 \n" + "beq 20f \n" + + "10: \n" + "ldrh r3, [%[f2]], #2 \n" + "ldrh r6, [%[s2]], #2 \n" + "ldmia %[f2]!, {r2,r4} \n" + "mov r3, r3, lsl #16 \n" + "mov r6, r6, lsl #16 \n" + + "1: \n" + "ldmia %[s2]!, {r5,r7} \n" + "pkhtb r3, r3, r2 \n" + "pkhtb r2, r2, r4 \n" + "ldrd r0, [%[v1]] \n" + "mov r5, r5, ror #16 \n" + "pkhtb r6, r5, r6, asr #16 \n" + "pkhbt r5, r5, r7, lsl #16 \n" +#if ORDER > 32 + "smladx %[res], r0, r3, %[res] \n" +#else + "smuadx %[res], r0, r3 \n" +#endif + "smladx %[res], r1, r2, %[res] \n" + "ldmia %[f2]!, {r2,r3} \n" + "sadd16 r0, r0, r6 \n" + "sadd16 r1, r1, r5 \n" + "strd r0, [%[v1]], #8 \n" + + REPEAT_BLOCK( + "ldmia %[s2]!, {r5,r6} \n" + "pkhtb r4, r4, r2 \n" + "pkhtb r2, r2, r3 \n" + "ldrd r0, [%[v1]] \n" + "mov r5, r5, ror #16 \n" + "pkhtb r7, r5, r7, asr #16 \n" + "pkhbt r5, r5, r6, lsl #16 \n" + "smladx %[res], r0, r4, %[res] \n" + "smladx %[res], r1, r2, %[res] \n" + "ldmia %[f2]!, {r2,r4} \n" + "sadd16 r0, r0, r7 \n" + "sadd16 r1, r1, r5 \n" + "strd r0, [%[v1]], #8 \n" + "ldmia %[s2]!, {r5,r7} \n" + "pkhtb r3, r3, r2 \n" + "pkhtb r2, r2, r4 \n" + "ldrd r0, [%[v1]] \n" + "mov r5, r5, ror #16 \n" + "pkhtb r6, r5, r6, asr #16 \n" + "pkhbt r5, r5, r7, lsl #16 \n" + "smladx %[res], r0, r3, %[res] \n" + "smladx %[res], r1, r2, %[res] \n" + "ldmia %[f2]!, {r2,r3} \n" + "sadd16 r0, r0, r6 \n" + "sadd16 r1, r1, r5 \n" + "strd r0, [%[v1]], #8 \n" + ) + + "ldmia %[s2]!, {r5,r6} \n" + "pkhtb r4, r4, r2 \n" + "pkhtb r2, r2, r3 \n" + "ldrd r0, [%[v1]] \n" + "mov r5, r5, ror #16 \n" + "pkhtb r7, r5, r7, asr #16 \n" + "pkhbt r5, r5, r6, lsl #16 \n" + "smladx %[res], r0, r4, %[res] \n" + "smladx %[res], r1, r2, %[res] \n" +#if ORDER > 32 + "subs %[cnt], %[cnt], #1 \n" + "ldmneia %[f2]!, {r2,r4} \n" + "sadd16 r0, r0, r7 \n" + "sadd16 r1, r1, r5 \n" + "strd r0, [%[v1]], #8 \n" + "bne 1b \n" +#else + "sadd16 r0, r0, r7 \n" + "sadd16 r1, r1, r5 \n" + "strd r0, [%[v1]], #8 \n" +#endif + + "b 99f \n" + + "20: \n" + "ldrd r4, [%[f2]], #8 \n" + "ldrd r0, [%[v1]] \n" + +#if ORDER > 32 + "1: \n" + "smlad %[res], r0, r4, %[res] \n" +#else + "smuad %[res], r0, r4 \n" +#endif + "ldrd r6, [%[s2]], #8 \n" + "smlad %[res], r1, r5, %[res] \n" + "ldrd r4, [%[f2]], #8 \n" + "ldrd r2, [%[v1], #8] \n" + "sadd16 r0, r0, r6 \n" + "sadd16 r1, r1, r7 \n" + "strd r0, [%[v1]], #8 \n" + + REPEAT_BLOCK( + "smlad %[res], r2, r4, %[res] \n" + "ldrd r6, [%[s2]], #8 \n" + "smlad %[res], r3, r5, %[res] \n" + "ldrd r4, [%[f2]], #8 \n" + "ldrd r0, [%[v1], #8] \n" + "sadd16 r2, r2, r6 \n" + "sadd16 r3, r3, r7 \n" + "strd r2, [%[v1]], #8 \n" + "smlad %[res], r0, r4, %[res] \n" + "ldrd r6, [%[s2]], #8 \n" + "smlad %[res], r1, r5, %[res] \n" + "ldrd r4, [%[f2]], #8 \n" + "ldrd r2, [%[v1], #8] \n" + "sadd16 r0, r0, r6 \n" + "sadd16 r1, r1, r7 \n" + "strd r0, [%[v1]], #8 \n" + ) + + "smlad %[res], r2, r4, %[res] \n" + "ldrd r6, [%[s2]], #8 \n" + "smlad %[res], r3, r5, %[res] \n" +#if ORDER > 32 + "subs %[cnt], %[cnt], #1 \n" + "ldrned r4, [%[f2]], #8 \n" + "ldrned r0, [%[v1], #8] \n" + "sadd16 r2, r2, r6 \n" + "sadd16 r3, r3, r7 \n" + "strd r2, [%[v1]], #8 \n" + "bne 1b \n" +#else + "sadd16 r2, r2, r6 \n" + "sadd16 r3, r3, r7 \n" + "strd r2, [%[v1]], #8 \n" +#endif + + "99: \n" + : /* outputs */ +#if ORDER > 32 + [cnt]"+r"(cnt), +#endif + [v1] "+r"(v1), + [f2] "+r"(f2), + [s2] "+r"(s2), + [res]"=r"(res) + : /* inputs */ + : /* clobbers */ + "r0", "r1", "r2", "r3", "r4", + "r5", "r6", "r7", "cc", "memory" + ); + return res; +} + +/* Calculate scalarproduct, then subtract a 2nd vector (fused for performance) + * This version fetches data as 32 bit words, and *requires* v1 to be + * 32 bit aligned. It also requires that f2 and s2 are either both 32 bit + * aligned or both unaligned. If either condition isn't met, it will either + * result in a data abort or incorrect results. */ +static inline int32_t vector_sp_sub(int16_t* v1, int16_t* f2, int16_t* s2) +{ + int res; +#if ORDER > 32 + int cnt = ORDER>>5; +#endif + + asm volatile ( +#if ORDER > 32 + "mov %[res], #0 \n" +#endif + "tst %[f2], #2 \n" + "beq 20f \n" + + "10: \n" + "ldrh r3, [%[f2]], #2 \n" + "ldrh r6, [%[s2]], #2 \n" + "ldmia %[f2]!, {r2,r4} \n" + "mov r3, r3, lsl #16 \n" + "mov r6, r6, lsl #16 \n" + + "1: \n" + "ldmia %[s2]!, {r5,r7} \n" + "pkhtb r3, r3, r2 \n" + "pkhtb r2, r2, r4 \n" + "ldrd r0, [%[v1]] \n" + "mov r5, r5, ror #16 \n" + "pkhtb r6, r5, r6, asr #16 \n" + "pkhbt r5, r5, r7, lsl #16 \n" +#if ORDER > 32 + "smladx %[res], r0, r3, %[res] \n" +#else + "smuadx %[res], r0, r3 \n" +#endif + "smladx %[res], r1, r2, %[res] \n" + "ldmia %[f2]!, {r2,r3} \n" + "ssub16 r0, r0, r6 \n" + "ssub16 r1, r1, r5 \n" + "strd r0, [%[v1]], #8 \n" + + REPEAT_BLOCK( + "ldmia %[s2]!, {r5,r6} \n" + "pkhtb r4, r4, r2 \n" + "pkhtb r2, r2, r3 \n" + "ldrd r0, [%[v1]] \n" + "mov r5, r5, ror #16 \n" + "pkhtb r7, r5, r7, asr #16 \n" + "pkhbt r5, r5, r6, lsl #16 \n" + "smladx %[res], r0, r4, %[res] \n" + "smladx %[res], r1, r2, %[res] \n" + "ldmia %[f2]!, {r2,r4} \n" + "ssub16 r0, r0, r7 \n" + "ssub16 r1, r1, r5 \n" + "strd r0, [%[v1]], #8 \n" + "ldmia %[s2]!, {r5,r7} \n" + "pkhtb r3, r3, r2 \n" + "pkhtb r2, r2, r4 \n" + "ldrd r0, [%[v1]] \n" + "mov r5, r5, ror #16 \n" + "pkhtb r6, r5, r6, asr #16 \n" + "pkhbt r5, r5, r7, lsl #16 \n" + "smladx %[res], r0, r3, %[res] \n" + "smladx %[res], r1, r2, %[res] \n" + "ldmia %[f2]!, {r2,r3} \n" + "ssub16 r0, r0, r6 \n" + "ssub16 r1, r1, r5 \n" + "strd r0, [%[v1]], #8 \n" + ) + + "ldmia %[s2]!, {r5,r6} \n" + "pkhtb r4, r4, r2 \n" + "pkhtb r2, r2, r3 \n" + "ldrd r0, [%[v1]] \n" + "mov r5, r5, ror #16 \n" + "pkhtb r7, r5, r7, asr #16 \n" + "pkhbt r5, r5, r6, lsl #16 \n" + "smladx %[res], r0, r4, %[res] \n" + "smladx %[res], r1, r2, %[res] \n" +#if ORDER > 32 + "subs %[cnt], %[cnt], #1 \n" + "ldmneia %[f2]!, {r2,r4} \n" + "ssub16 r0, r0, r7 \n" + "ssub16 r1, r1, r5 \n" + "strd r0, [%[v1]], #8 \n" + "bne 1b \n" +#else + "ssub16 r0, r0, r7 \n" + "ssub16 r1, r1, r5 \n" + "strd r0, [%[v1]], #8 \n" +#endif + + "b 99f \n" + + "20: \n" + "ldrd r4, [%[f2]], #8 \n" + "ldrd r0, [%[v1]] \n" + +#if ORDER > 32 + "1: \n" + "smlad %[res], r0, r4, %[res] \n" +#else + "smuad %[res], r0, r4 \n" +#endif + "ldrd r6, [%[s2]], #8 \n" + "smlad %[res], r1, r5, %[res] \n" + "ldrd r4, [%[f2]], #8 \n" + "ldrd r2, [%[v1], #8] \n" + "ssub16 r0, r0, r6 \n" + "ssub16 r1, r1, r7 \n" + "strd r0, [%[v1]], #8 \n" + + REPEAT_BLOCK( + "smlad %[res], r2, r4, %[res] \n" + "ldrd r6, [%[s2]], #8 \n" + "smlad %[res], r3, r5, %[res] \n" + "ldrd r4, [%[f2]], #8 \n" + "ldrd r0, [%[v1], #8] \n" + "ssub16 r2, r2, r6 \n" + "ssub16 r3, r3, r7 \n" + "strd r2, [%[v1]], #8 \n" + "smlad %[res], r0, r4, %[res] \n" + "ldrd r6, [%[s2]], #8 \n" + "smlad %[res], r1, r5, %[res] \n" + "ldrd r4, [%[f2]], #8 \n" + "ldrd r2, [%[v1], #8] \n" + "ssub16 r0, r0, r6 \n" + "ssub16 r1, r1, r7 \n" + "strd r0, [%[v1]], #8 \n" + ) + + "smlad %[res], r2, r4, %[res] \n" + "ldrd r6, [%[s2]], #8 \n" + "smlad %[res], r3, r5, %[res] \n" +#if ORDER > 32 + "subs %[cnt], %[cnt], #1 \n" + "ldrned r4, [%[f2]], #8 \n" + "ldrned r0, [%[v1], #8] \n" + "ssub16 r2, r2, r6 \n" + "ssub16 r3, r3, r7 \n" + "strd r2, [%[v1]], #8 \n" + "bne 1b \n" +#else + "ssub16 r2, r2, r6 \n" + "ssub16 r3, r3, r7 \n" + "strd r2, [%[v1]], #8 \n" +#endif + + "99: \n" + : /* outputs */ +#if ORDER > 32 + [cnt]"+r"(cnt), +#endif + [v1] "+r"(v1), + [f2] "+r"(f2), + [s2] "+r"(s2), + [res]"=r"(res) + : /* inputs */ + : /* clobbers */ + "r0", "r1", "r2", "r3", "r4", + "r5", "r6", "r7", "cc", "memory" + ); + return res; +} + +/* This version fetches data as 32 bit words, and *requires* v1 to be + * 32 bit aligned, otherwise it will result either in a data abort, or + * incorrect results (if ARM aligncheck is disabled). */ +static inline int32_t scalarproduct(int16_t* v1, int16_t* v2) +{ + int res; +#if ORDER > 32 + int cnt = ORDER>>5; +#endif + + asm volatile ( +#if ORDER > 32 + "mov %[res], #0 \n" +#endif + "tst %[v2], #2 \n" + "beq 20f \n" + + "10: \n" + "bic %[v2], %[v2], #2 \n" + "ldmia %[v2]!, {r5-r7} \n" + "ldrd r0, [%[v1]], #8 \n" + + "1: \n" + "pkhtb r3, r5, r6 \n" + "ldrd r4, [%[v2]], #8 \n" +#if ORDER > 32 + "smladx %[res], r0, r3, %[res] \n" +#else + "smuadx %[res], r0, r3 \n" +#endif + REPEAT_BLOCK( + "pkhtb r0, r6, r7 \n" + "ldrd r2, [%[v1]], #8 \n" + "smladx %[res], r1, r0, %[res] \n" + "pkhtb r1, r7, r4 \n" + "ldrd r6, [%[v2]], #8 \n" + "smladx %[res], r2, r1, %[res] \n" + "pkhtb r2, r4, r5 \n" + "ldrd r0, [%[v1]], #8 \n" + "smladx %[res], r3, r2, %[res] \n" + "pkhtb r3, r5, r6 \n" + "ldrd r4, [%[v2]], #8 \n" + "smladx %[res], r0, r3, %[res] \n" + ) + + "pkhtb r0, r6, r7 \n" + "ldrd r2, [%[v1]], #8 \n" + "smladx %[res], r1, r0, %[res] \n" + "pkhtb r1, r7, r4 \n" +#if ORDER > 32 + "subs %[cnt], %[cnt], #1 \n" + "ldrned r6, [%[v2]], #8 \n" + "smladx %[res], r2, r1, %[res] \n" + "pkhtb r2, r4, r5 \n" + "ldrned r0, [%[v1]], #8 \n" + "smladx %[res], r3, r2, %[res] \n" + "bne 1b \n" +#else + "pkhtb r4, r4, r5 \n" + "smladx %[res], r2, r1, %[res] \n" + "smladx %[res], r3, r4, %[res] \n" +#endif + + "b 99f \n" + + "20: \n" + "ldrd r0, [%[v1]], #8 \n" + "ldmia %[v2]!, {r5-r7} \n" + + "1: \n" + "ldrd r2, [%[v1]], #8 \n" +#if ORDER > 32 + "smlad %[res], r0, r5, %[res] \n" +#else + "smuad %[res], r0, r5 \n" +#endif + REPEAT_BLOCK( + "ldrd r4, [%[v2]], #8 \n" + "smlad %[res], r1, r6, %[res] \n" + "ldrd r0, [%[v1]], #8 \n" + "smlad %[res], r2, r7, %[res] \n" + "ldrd r6, [%[v2]], #8 \n" + "smlad %[res], r3, r4, %[res] \n" + "ldrd r2, [%[v1]], #8 \n" + "smlad %[res], r0, r5, %[res] \n" + ) + +#if ORDER > 32 + "ldrd r4, [%[v2]], #8 \n" + "smlad %[res], r1, r6, %[res] \n" + "subs %[cnt], %[cnt], #1 \n" + "ldrned r0, [%[v1]], #8 \n" + "smlad %[res], r2, r7, %[res] \n" + "ldrned r6, [%[v2]], #8 \n" + "smlad %[res], r3, r4, %[res] \n" + "bne 1b \n" +#else + "ldr r4, [%[v2]], #4 \n" + "smlad %[res], r1, r6, %[res] \n" + "smlad %[res], r2, r7, %[res] \n" + "smlad %[res], r3, r4, %[res] \n" +#endif + + "99: \n" + : /* outputs */ +#if ORDER > 32 + [cnt]"+r"(cnt), +#endif + [v1] "+r"(v1), + [v2] "+r"(v2), + [res]"=r"(res) + : /* inputs */ + : /* clobbers */ + "r0", "r1", "r2", "r3", + "r4", "r5", "r6", "r7", "cc", "memory" + ); + return res; +} diff --git a/lib/rbcodec/codecs/demac/libdemac/vector_math16_armv7.h b/lib/rbcodec/codecs/demac/libdemac/vector_math16_armv7.h new file mode 100644 index 0000000000..84afda3e5d --- /dev/null +++ b/lib/rbcodec/codecs/demac/libdemac/vector_math16_armv7.h @@ -0,0 +1,214 @@ +/* + +libdemac - A Monkey's Audio decoder + +$Id$ + +Copyright (C) Dave Chapman 2007 + +ARMv7 neon vector math copyright (C) 2010 Jens Arnold + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA + +*/ + +#define FUSED_VECTOR_MATH + +#if ORDER > 32 +#define REPEAT_BLOCK(x) x x x +#elif ORDER > 16 +#define REPEAT_BLOCK(x) x +#else +#define REPEAT_BLOCK(x) +#endif + +/* Calculate scalarproduct, then add a 2nd vector (fused for performance) */ +static inline int32_t vector_sp_add(int16_t* v1, int16_t* f2, int16_t* s2) +{ + int res; +#if ORDER > 64 + int cnt = ORDER>>6; +#endif + + asm volatile ( +#if ORDER > 64 + "vmov.i16 q0, #0 \n" + "1: \n" + "subs %[cnt], %[cnt], #1 \n" +#endif + "vld1.16 {d6-d9}, [%[f2]]! \n" + "vld1.16 {d2-d5}, [%[v1]] \n" + "vld1.16 {d10-d13}, [%[s2]]! \n" +#if ORDER > 64 + "vmlal.s16 q0, d2, d6 \n" +#else + "vmull.s16 q0, d2, d6 \n" +#endif + "vmlal.s16 q0, d3, d7 \n" + "vmlal.s16 q0, d4, d8 \n" + "vmlal.s16 q0, d5, d9 \n" + "vadd.i16 q1, q1, q5 \n" + "vadd.i16 q2, q2, q6 \n" + "vst1.16 {d2-d5}, [%[v1]]! \n" + + REPEAT_BLOCK( + "vld1.16 {d6-d9}, [%[f2]]! \n" + "vld1.16 {d2-d5}, [%[v1]] \n" + "vld1.16 {d10-d13}, [%[s2]]! \n" + "vmlal.s16 q0, d2, d6 \n" + "vmlal.s16 q0, d3, d7 \n" + "vmlal.s16 q0, d4, d8 \n" + "vmlal.s16 q0, d5, d9 \n" + "vadd.i16 q1, q1, q5 \n" + "vadd.i16 q2, q2, q6 \n" + "vst1.16 {d2-d5}, [%[v1]]! \n" + ) +#if ORDER > 64 + "bne 1b \n" +#endif + "vpadd.i32 d0, d0, d1 \n" + "vpaddl.s32 d0, d0 \n" + "vmov.32 %[res], d0[0] \n" + : /* outputs */ +#if ORDER > 64 + [cnt]"+r"(cnt), +#endif + [v1] "+r"(v1), + [f2] "+r"(f2), + [s2] "+r"(s2), + [res]"=r"(res) + : /* inputs */ + : /* clobbers */ + "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", + "d8", "d9", "d10", "d11", "d12", "d13", "memory" + ); + return res; +} + +/* Calculate scalarproduct, then subtract a 2nd vector (fused for performance) */ +static inline int32_t vector_sp_sub(int16_t* v1, int16_t* f2, int16_t* s2) +{ + int res; +#if ORDER > 64 + int cnt = ORDER>>6; +#endif + + asm volatile ( +#if ORDER > 64 + "vmov.i16 q0, #0 \n" + "1: \n" + "subs %[cnt], %[cnt], #1 \n" +#endif + "vld1.16 {d6-d9}, [%[f2]]! \n" + "vld1.16 {d2-d5}, [%[v1]] \n" + "vld1.16 {d10-d13}, [%[s2]]! \n" +#if ORDER > 64 + "vmlal.s16 q0, d2, d6 \n" +#else + "vmull.s16 q0, d2, d6 \n" +#endif + "vmlal.s16 q0, d3, d7 \n" + "vmlal.s16 q0, d4, d8 \n" + "vmlal.s16 q0, d5, d9 \n" + "vsub.i16 q1, q1, q5 \n" + "vsub.i16 q2, q2, q6 \n" + "vst1.16 {d2-d5}, [%[v1]]! \n" + + REPEAT_BLOCK( + "vld1.16 {d6-d9}, [%[f2]]! \n" + "vld1.16 {d2-d5}, [%[v1]] \n" + "vld1.16 {d10-d13}, [%[s2]]! \n" + "vmlal.s16 q0, d2, d6 \n" + "vmlal.s16 q0, d3, d7 \n" + "vmlal.s16 q0, d4, d8 \n" + "vmlal.s16 q0, d5, d9 \n" + "vsub.i16 q1, q1, q5 \n" + "vsub.i16 q2, q2, q6 \n" + "vst1.16 {d2-d5}, [%[v1]]! \n" + ) +#if ORDER > 64 + "bne 1b \n" +#endif + "vpadd.i32 d0, d0, d1 \n" + "vpaddl.s32 d0, d0 \n" + "vmov.32 %[res], d0[0] \n" + : /* outputs */ +#if ORDER > 64 + [cnt]"+r"(cnt), +#endif + [v1] "+r"(v1), + [f2] "+r"(f2), + [s2] "+r"(s2), + [res]"=r"(res) + : /* inputs */ + : /* clobbers */ + "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", + "d8", "d9", "d10", "d11", "d12", "d13", "memory" + ); + return res; +} + +static inline int32_t scalarproduct(int16_t* v1, int16_t* v2) +{ + int res; +#if ORDER > 64 + int cnt = ORDER>>6; +#endif + + asm volatile ( +#if ORDER > 64 + "vmov.i16 q0, #0 \n" + "1: \n" + "subs %[cnt], %[cnt], #1 \n" +#endif + "vld1.16 {d2-d5}, [%[v1]]! \n" + "vld1.16 {d6-d9}, [%[v2]]! \n" +#if ORDER > 64 + "vmlal.s16 q0, d2, d6 \n" +#else + "vmull.s16 q0, d2, d6 \n" +#endif + "vmlal.s16 q0, d3, d7 \n" + "vmlal.s16 q0, d4, d8 \n" + "vmlal.s16 q0, d5, d9 \n" + + REPEAT_BLOCK( + "vld1.16 {d2-d5}, [%[v1]]! \n" + "vld1.16 {d6-d9}, [%[v2]]! \n" + "vmlal.s16 q0, d2, d6 \n" + "vmlal.s16 q0, d3, d7 \n" + "vmlal.s16 q0, d4, d8 \n" + "vmlal.s16 q0, d5, d9 \n" + ) +#if ORDER > 64 + "bne 1b \n" +#endif + "vpadd.i32 d0, d0, d1 \n" + "vpaddl.s32 d0, d0 \n" + "vmov.32 %[res], d0[0] \n" + : /* outputs */ +#if ORDER > 64 + [cnt]"+r"(cnt), +#endif + [v1] "+r"(v1), + [v2] "+r"(v2), + [res]"=r"(res) + : /* inputs */ + : /* clobbers */ + "d0", "d1", "d2", "d3", "d4", + "d5", "d6", "d7", "d8", "d9" + ); + return res; +} diff --git a/lib/rbcodec/codecs/demac/libdemac/vector_math16_cf.h b/lib/rbcodec/codecs/demac/libdemac/vector_math16_cf.h new file mode 100644 index 0000000000..4d77d3be31 --- /dev/null +++ b/lib/rbcodec/codecs/demac/libdemac/vector_math16_cf.h @@ -0,0 +1,364 @@ +/* + +libdemac - A Monkey's Audio decoder + +$Id$ + +Copyright (C) Dave Chapman 2007 + +Coldfire vector math copyright (C) 2007 Jens Arnold + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA + +*/ + +#define FUSED_VECTOR_MATH + +#define PREPARE_SCALARPRODUCT coldfire_set_macsr(0); /* signed integer mode */ + +#define REPEAT_2(x) x x +#define REPEAT_3(x) x x x +#define REPEAT_7(x) x x x x x x x + +/* Calculate scalarproduct, then add a 2nd vector (fused for performance) + * This version fetches data as 32 bit words, and *recommends* v1 to be + * 32 bit aligned. It also assumes that f2 and s2 are either both 32 bit + * aligned or both unaligned. Performance will suffer if either condition + * isn't met. It also needs EMAC in signed integer mode. */ +static inline int32_t vector_sp_add(int16_t* v1, int16_t* f2, int16_t* s2) +{ + int res; +#if ORDER > 16 + int cnt = ORDER>>4; +#endif + +#define ADDHALFREGS(s1, s2, sum) /* Add register halves straight. */ \ + "move.l " #s1 ", " #sum "\n" /* 's1' and 's2' can be A or D */ \ + "add.l " #s2 ", " #s1 "\n" /* regs, 'sum' must be a D reg. */ \ + "clr.w " #sum " \n" /* 's1' is clobbered! */ \ + "add.l " #s2 ", " #sum "\n" \ + "move.w " #s1 ", " #sum "\n" + +#define ADDHALFXREGS(s1, s2, sum) /* Add register halves across. */ \ + "clr.w " #sum " \n" /* Needs 'sum' pre-swapped, swaps */ \ + "add.l " #s1 ", " #sum "\n" /* 's2', and clobbers 's1'. */ \ + "swap " #s2 " \n" /* 's1' can be an A or D reg. */ \ + "add.l " #s2 ", " #s1 "\n" /* 'sum' and 's2' must be D regs. */ \ + "move.w " #s1 ", " #sum "\n" + + asm volatile ( + "move.l %[f2], %%d0 \n" + "and.l #2, %%d0 \n" + "jeq 20f \n" + + "10: \n" + "move.w (%[f2])+, %%d0 \n" + "move.w (%[s2])+, %%d1 \n" + "swap %%d1 \n" + "1: \n" + REPEAT_2( + "movem.l (%[v1]), %%d6-%%d7/%%a0-%%a1 \n" + "mac.w %%d0l, %%d6u, (%[f2])+, %%d0, %%acc0\n" + "mac.w %%d0u, %%d6l, (%[s2])+, %%d2, %%acc0\n" + ADDHALFXREGS(%%d6, %%d2, %%d1) + "mac.w %%d0l, %%d7u, (%[f2])+, %%d0, %%acc0\n" + "mac.w %%d0u, %%d7l, (%[s2])+, %%d6, %%acc0\n" + "move.l %%d1, (%[v1])+ \n" + ADDHALFXREGS(%%d7, %%d6, %%d2) + "mac.w %%d0l, %%a0u, (%[f2])+, %%d0, %%acc0\n" + "mac.w %%d0u, %%a0l, (%[s2])+, %%d7, %%acc0\n" + "move.l %%d2, (%[v1])+ \n" + ADDHALFXREGS(%%a0, %%d7, %%d6) + "mac.w %%d0l, %%a1u, (%[f2])+, %%d0, %%acc0\n" + "mac.w %%d0u, %%a1l, (%[s2])+, %%d1, %%acc0\n" + "move.l %%d6, (%[v1])+ \n" + ADDHALFXREGS(%%a1, %%d1, %%d7) + "move.l %%d7, (%[v1])+ \n" + ) + +#if ORDER > 16 + "subq.l #1, %[res] \n" + "bne.w 1b \n" +#endif + "jra 99f \n" + + "20: \n" + "move.l (%[f2])+, %%d0 \n" + "1: \n" + "movem.l (%[v1]), %%d6-%%d7/%%a0-%%a1 \n" + "mac.w %%d0u, %%d6u, (%[s2])+, %%d1, %%acc0\n" + "mac.w %%d0l, %%d6l, (%[f2])+, %%d0, %%acc0\n" + ADDHALFREGS(%%d6, %%d1, %%d2) + "mac.w %%d0u, %%d7u, (%[s2])+, %%d1, %%acc0\n" + "mac.w %%d0l, %%d7l, (%[f2])+, %%d0, %%acc0\n" + "move.l %%d2, (%[v1])+ \n" + ADDHALFREGS(%%d7, %%d1, %%d2) + "mac.w %%d0u, %%a0u, (%[s2])+, %%d1, %%acc0\n" + "mac.w %%d0l, %%a0l, (%[f2])+, %%d0, %%acc0\n" + "move.l %%d2, (%[v1])+ \n" + ADDHALFREGS(%%a0, %%d1, %%d2) + "mac.w %%d0u, %%a1u, (%[s2])+, %%d1, %%acc0\n" + "mac.w %%d0l, %%a1l, (%[f2])+, %%d0, %%acc0\n" + "move.l %%d2, (%[v1])+ \n" + ADDHALFREGS(%%a1, %%d1, %%d2) + "move.l %%d2, (%[v1])+ \n" + + "movem.l (%[v1]), %%d6-%%d7/%%a0-%%a1 \n" + "mac.w %%d0u, %%d6u, (%[s2])+, %%d1, %%acc0\n" + "mac.w %%d0l, %%d6l, (%[f2])+, %%d0, %%acc0\n" + ADDHALFREGS(%%d6, %%d1, %%d2) + "mac.w %%d0u, %%d7u, (%[s2])+, %%d1, %%acc0\n" + "mac.w %%d0l, %%d7l, (%[f2])+, %%d0, %%acc0\n" + "move.l %%d2, (%[v1])+ \n" + ADDHALFREGS(%%d7, %%d1, %%d2) + "mac.w %%d0u, %%a0u, (%[s2])+, %%d1, %%acc0\n" + "mac.w %%d0l, %%a0l, (%[f2])+, %%d0, %%acc0\n" + "move.l %%d2, (%[v1])+ \n" + ADDHALFREGS(%%a0, %%d1, %%d2) + "mac.w %%d0u, %%a1u, (%[s2])+, %%d1, %%acc0\n" +#if ORDER > 16 + "mac.w %%d0l, %%a1l, (%[f2])+, %%d0, %%acc0\n" +#else + "mac.w %%d0l, %%a1l, %%acc0 \n" +#endif + "move.l %%d2, (%[v1])+ \n" + ADDHALFREGS(%%a1, %%d1, %%d2) + "move.l %%d2, (%[v1])+ \n" +#if ORDER > 16 + "subq.l #1, %[res] \n" + "bne.w 1b \n" +#endif + + "99: \n" + "movclr.l %%acc0, %[res] \n" + : /* outputs */ + [v1]"+a"(v1), + [f2]"+a"(f2), + [s2]"+a"(s2), + [res]"=d"(res) + : /* inputs */ +#if ORDER > 16 + [cnt]"[res]"(cnt) +#endif + : /* clobbers */ + "d0", "d1", "d2", "d6", "d7", + "a0", "a1", "memory" + + ); + return res; +} + +/* Calculate scalarproduct, then subtract a 2nd vector (fused for performance) + * This version fetches data as 32 bit words, and *recommends* v1 to be + * 32 bit aligned. It also assumes that f2 and s2 are either both 32 bit + * aligned or both unaligned. Performance will suffer if either condition + * isn't met. It also needs EMAC in signed integer mode. */ +static inline int32_t vector_sp_sub(int16_t* v1, int16_t* f2, int16_t* s2) +{ + int res; +#if ORDER > 16 + int cnt = ORDER>>4; +#endif + +#define SUBHALFREGS(min, sub, dif) /* Subtract register halves straight. */ \ + "move.l " #min ", " #dif "\n" /* 'min' can be an A or D reg */ \ + "sub.l " #sub ", " #min "\n" /* 'sub' and 'dif' must be D regs */ \ + "clr.w " #sub "\n" /* 'min' and 'sub' are clobbered! */ \ + "sub.l " #sub ", " #dif "\n" \ + "move.w " #min ", " #dif "\n" + +#define SUBHALFXREGS(min, s2, s1d) /* Subtract register halves across. */ \ + "clr.w " #s1d "\n" /* Needs 's1d' pre-swapped, swaps */ \ + "sub.l " #s1d ", " #min "\n" /* 's2' and clobbers 'min'. */ \ + "move.l " #min ", " #s1d "\n" /* 'min' can be an A or D reg, */ \ + "swap " #s2 "\n" /* 's2' and 's1d' must be D regs. */ \ + "sub.l " #s2 ", " #min "\n" \ + "move.w " #min ", " #s1d "\n" + + asm volatile ( + "move.l %[f2], %%d0 \n" + "and.l #2, %%d0 \n" + "jeq 20f \n" + + "10: \n" + "move.w (%[f2])+, %%d0 \n" + "move.w (%[s2])+, %%d1 \n" + "swap %%d1 \n" + "1: \n" + REPEAT_2( + "movem.l (%[v1]), %%d6-%%d7/%%a0-%%a1 \n" + "mac.w %%d0l, %%d6u, (%[f2])+, %%d0, %%acc0\n" + "mac.w %%d0u, %%d6l, (%[s2])+, %%d2, %%acc0\n" + SUBHALFXREGS(%%d6, %%d2, %%d1) + "mac.w %%d0l, %%d7u, (%[f2])+, %%d0, %%acc0\n" + "mac.w %%d0u, %%d7l, (%[s2])+, %%d6, %%acc0\n" + "move.l %%d1, (%[v1])+ \n" + SUBHALFXREGS(%%d7, %%d6, %%d2) + "mac.w %%d0l, %%a0u, (%[f2])+, %%d0, %%acc0\n" + "mac.w %%d0u, %%a0l, (%[s2])+, %%d7, %%acc0\n" + "move.l %%d2, (%[v1])+ \n" + SUBHALFXREGS(%%a0, %%d7, %%d6) + "mac.w %%d0l, %%a1u, (%[f2])+, %%d0, %%acc0\n" + "mac.w %%d0u, %%a1l, (%[s2])+, %%d1, %%acc0\n" + "move.l %%d6, (%[v1])+ \n" + SUBHALFXREGS(%%a1, %%d1, %%d7) + "move.l %%d7, (%[v1])+ \n" + ) + +#if ORDER > 16 + "subq.l #1, %[res] \n" + "bne.w 1b \n" +#endif + + "jra 99f \n" + + "20: \n" + "move.l (%[f2])+, %%d0 \n" + "1: \n" + "movem.l (%[v1]), %%d6-%%d7/%%a0-%%a1 \n" + "mac.w %%d0u, %%d6u, (%[s2])+, %%d1, %%acc0\n" + "mac.w %%d0l, %%d6l, (%[f2])+, %%d0, %%acc0\n" + SUBHALFREGS(%%d6, %%d1, %%d2) + "mac.w %%d0u, %%d7u, (%[s2])+, %%d1, %%acc0\n" + "mac.w %%d0l, %%d7l, (%[f2])+, %%d0, %%acc0\n" + "move.l %%d2, (%[v1])+ \n" + SUBHALFREGS(%%d7, %%d1, %%d2) + "mac.w %%d0u, %%a0u, (%[s2])+, %%d1, %%acc0\n" + "mac.w %%d0l, %%a0l, (%[f2])+, %%d0, %%acc0\n" + "move.l %%d2, (%[v1])+ \n" + SUBHALFREGS(%%a0, %%d1, %%d2) + "mac.w %%d0u, %%a1u, (%[s2])+, %%d1, %%acc0\n" + "mac.w %%d0l, %%a1l, (%[f2])+, %%d0, %%acc0\n" + "move.l %%d2, (%[v1])+ \n" + SUBHALFREGS(%%a1, %%d1, %%d2) + "move.l %%d2, (%[v1])+ \n" + + "movem.l (%[v1]), %%d6-%%d7/%%a0-%%a1 \n" + "mac.w %%d0u, %%d6u, (%[s2])+, %%d1, %%acc0\n" + "mac.w %%d0l, %%d6l, (%[f2])+, %%d0, %%acc0\n" + SUBHALFREGS(%%d6, %%d1, %%d2) + "mac.w %%d0u, %%d7u, (%[s2])+, %%d1, %%acc0\n" + "mac.w %%d0l, %%d7l, (%[f2])+, %%d0, %%acc0\n" + "move.l %%d2, (%[v1])+ \n" + SUBHALFREGS(%%d7, %%d1, %%d2) + "mac.w %%d0u, %%a0u, (%[s2])+, %%d1, %%acc0\n" + "mac.w %%d0l, %%a0l, (%[f2])+, %%d0, %%acc0\n" + "move.l %%d2, (%[v1])+ \n" + SUBHALFREGS(%%a0, %%d1, %%d2) + "mac.w %%d0u, %%a1u, (%[s2])+, %%d1, %%acc0\n" +#if ORDER > 16 + "mac.w %%d0l, %%a1l, (%[f2])+, %%d0, %%acc0\n" +#else + "mac.w %%d0l, %%a1l, %%acc0 \n" +#endif + "move.l %%d2, (%[v1])+ \n" + SUBHALFREGS(%%a1, %%d1, %%d2) + "move.l %%d2, (%[v1])+ \n" +#if ORDER > 16 + "subq.l #1, %[res] \n" + "bne.w 1b \n" +#endif + + "99: \n" + "movclr.l %%acc0, %[res] \n" + : /* outputs */ + [v1]"+a"(v1), + [f2]"+a"(f2), + [s2]"+a"(s2), + [res]"=d"(res) + : /* inputs */ +#if ORDER > 16 + [cnt]"[res]"(cnt) +#endif + : /* clobbers */ + "d0", "d1", "d2", "d6", "d7", + "a0", "a1", "memory" + + ); + return res; +} + +/* This version fetches data as 32 bit words, and *recommends* v1 to be + * 32 bit aligned, otherwise performance will suffer. It also needs EMAC + * in signed integer mode. */ +static inline int32_t scalarproduct(int16_t* v1, int16_t* v2) +{ + int res; +#if ORDER > 16 + int cnt = ORDER>>4; +#endif + + asm volatile ( + "move.l %[v2], %%d0 \n" + "and.l #2, %%d0 \n" + "jeq 20f \n" + + "10: \n" + "move.l (%[v1])+, %%d0 \n" + "move.w (%[v2])+, %%d1 \n" + "1: \n" + REPEAT_7( + "mac.w %%d0u, %%d1l, (%[v2])+, %%d1, %%acc0\n" + "mac.w %%d0l, %%d1u, (%[v1])+, %%d0, %%acc0\n" + ) + + "mac.w %%d0u, %%d1l, (%[v2])+, %%d1, %%acc0\n" +#if ORDER > 16 + "mac.w %%d0l, %%d1u, (%[v1])+, %%d0, %%acc0\n" + "subq.l #1, %[res] \n" + "bne.b 1b \n" +#else + "mac.w %%d0l, %%d1u, %%acc0 \n" +#endif + "jra 99f \n" + + "20: \n" + "move.l (%[v1])+, %%d0 \n" + "move.l (%[v2])+, %%d1 \n" + "1: \n" + REPEAT_3( + "mac.w %%d0u, %%d1u, (%[v1])+, %%d2, %%acc0\n" + "mac.w %%d0l, %%d1l, (%[v2])+, %%d1, %%acc0\n" + "mac.w %%d2u, %%d1u, (%[v1])+, %%d0, %%acc0\n" + "mac.w %%d2l, %%d1l, (%[v2])+, %%d1, %%acc0\n" + ) + + "mac.w %%d0u, %%d1u, (%[v1])+, %%d2, %%acc0\n" + "mac.w %%d0l, %%d1l, (%[v2])+, %%d1, %%acc0\n" +#if ORDER > 16 + "mac.w %%d2u, %%d1u, (%[v1])+, %%d0, %%acc0\n" + "mac.w %%d2l, %%d1l, (%[v2])+, %%d1, %%acc0\n" + "subq.l #1, %[res] \n" + "bne.b 1b \n" +#else + "mac.w %%d2u, %%d1u, %%acc0 \n" + "mac.w %%d2l, %%d1l, %%acc0 \n" +#endif + + "99: \n" + "movclr.l %%acc0, %[res] \n" + : /* outputs */ + [v1]"+a"(v1), + [v2]"+a"(v2), + [res]"=d"(res) + : /* inputs */ +#if ORDER > 16 + [cnt]"[res]"(cnt) +#endif + : /* clobbers */ + "d0", "d1", "d2" + ); + return res; +} diff --git a/lib/rbcodec/codecs/demac/libdemac/vector_math16_mmx.h b/lib/rbcodec/codecs/demac/libdemac/vector_math16_mmx.h new file mode 100644 index 0000000000..2177fe88ea --- /dev/null +++ b/lib/rbcodec/codecs/demac/libdemac/vector_math16_mmx.h @@ -0,0 +1,234 @@ +/* + +libdemac - A Monkey's Audio decoder + +$Id$ + +Copyright (C) Dave Chapman 2007 + +MMX vector math copyright (C) 2010 Jens Arnold + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA + +*/ + +#define FUSED_VECTOR_MATH + +#define REPEAT_MB3(x, n) x(n) x(n+8) x(n+16) +#define REPEAT_MB7(x, n) x(n) x(n+8) x(n+16) x(n+24) x(n+32) x(n+40) x(n+48) +#define REPEAT_MB8(x, n) REPEAT_MB7(x, n) x(n+56) + +#if ORDER == 16 /* 3 times */ +#define REPEAT_MB(x) REPEAT_MB3(x, 8) +#elif ORDER == 32 /* 7 times */ +#define REPEAT_MB(x) REPEAT_MB7(x, 8) +#elif ORDER == 64 /* 5*3 == 15 times */ +#define REPEAT_MB(x) REPEAT_MB3(x, 8) REPEAT_MB3(x, 32) REPEAT_MB3(x, 56) \ + REPEAT_MB3(x, 80) REPEAT_MB3(x, 104) +#elif ORDER == 256 /* 9*7 == 63 times */ +#define REPEAT_MB(x) REPEAT_MB7(x, 8) REPEAT_MB7(x, 64) REPEAT_MB7(x, 120) \ + REPEAT_MB7(x, 176) REPEAT_MB7(x, 232) REPEAT_MB7(x, 288) \ + REPEAT_MB7(x, 344) REPEAT_MB7(x, 400) REPEAT_MB7(x, 456) +#elif ORDER == 1280 /* 8*8 == 64 times */ +#define REPEAT_MB(x) REPEAT_MB8(x, 0) REPEAT_MB8(x, 64) REPEAT_MB8(x, 128) \ + REPEAT_MB8(x, 192) REPEAT_MB8(x, 256) REPEAT_MB8(x, 320) \ + REPEAT_MB8(x, 384) REPEAT_MB8(x, 448) +#else +#error unsupported order +#endif + + +static inline int32_t vector_sp_add(int16_t* v1, int16_t* f2, int16_t *s2) +{ + int res, t; +#if ORDER > 256 + int cnt = ORDER>>8; +#endif + + asm volatile ( +#if ORDER > 256 + "pxor %%mm2, %%mm2 \n" + "1: \n" +#else + "movq (%[v1]), %%mm2 \n" + "movq %%mm2, %%mm0 \n" + "pmaddwd (%[f2]), %%mm2 \n" + "paddw (%[s2]), %%mm0 \n" + "movq %%mm0, (%[v1]) \n" +#endif + +#define SP_ADD_BLOCK(n) \ + "movq " #n "(%[v1]), %%mm1 \n" \ + "movq %%mm1, %%mm0 \n" \ + "pmaddwd " #n "(%[f2]), %%mm1 \n" \ + "paddw " #n "(%[s2]), %%mm0 \n" \ + "movq %%mm0, " #n "(%[v1]) \n" \ + "paddd %%mm1, %%mm2 \n" + +REPEAT_MB(SP_ADD_BLOCK) + +#if ORDER > 256 + "add $512, %[v1] \n" + "add $512, %[s2] \n" + "add $512, %[f2] \n" + "dec %[cnt] \n" + "jne 1b \n" +#endif + + "movd %%mm2, %[t] \n" + "psrlq $32, %%mm2 \n" + "movd %%mm2, %[res] \n" + "add %[t], %[res] \n" + : /* outputs */ +#if ORDER > 256 + [cnt]"+r"(cnt), + [s2] "+r"(s2), + [res]"=r"(res), + [t] "=r"(t) + : /* inputs */ + [v1]"2"(v1), + [f2]"3"(f2) +#else + [res]"=r"(res), + [t] "=r"(t) + : /* inputs */ + [v1]"r"(v1), + [f2]"r"(f2), + [s2]"r"(s2) +#endif + : /* clobbers */ + "mm0", "mm1", "mm2" + ); + return res; +} + +static inline int32_t vector_sp_sub(int16_t* v1, int16_t* f2, int16_t *s2) +{ + int res, t; +#if ORDER > 256 + int cnt = ORDER>>8; +#endif + + asm volatile ( +#if ORDER > 256 + "pxor %%mm2, %%mm2 \n" + "1: \n" +#else + "movq (%[v1]), %%mm2 \n" + "movq %%mm2, %%mm0 \n" + "pmaddwd (%[f2]), %%mm2 \n" + "psubw (%[s2]), %%mm0 \n" + "movq %%mm0, (%[v1]) \n" +#endif + +#define SP_SUB_BLOCK(n) \ + "movq " #n "(%[v1]), %%mm1 \n" \ + "movq %%mm1, %%mm0 \n" \ + "pmaddwd " #n "(%[f2]), %%mm1 \n" \ + "psubw " #n "(%[s2]), %%mm0 \n" \ + "movq %%mm0, " #n "(%[v1]) \n" \ + "paddd %%mm1, %%mm2 \n" + +REPEAT_MB(SP_SUB_BLOCK) + +#if ORDER > 256 + "add $512, %[v1] \n" + "add $512, %[s2] \n" + "add $512, %[f2] \n" + "dec %[cnt] \n" + "jne 1b \n" +#endif + + "movd %%mm2, %[t] \n" + "psrlq $32, %%mm2 \n" + "movd %%mm2, %[res] \n" + "add %[t], %[res] \n" + : /* outputs */ +#if ORDER > 256 + [cnt]"+r"(cnt), + [s2] "+r"(s2), + [res]"=r"(res), + [t] "=r"(t) + : /* inputs */ + [v1]"2"(v1), + [f2]"3"(f2) +#else + [res]"=r"(res), + [t] "=r"(t) + : /* inputs */ + [v1]"r"(v1), + [f2]"r"(f2), + [s2]"r"(s2) +#endif + : /* clobbers */ + "mm0", "mm1", "mm2" + ); + return res; +} + +static inline int32_t scalarproduct(int16_t* v1, int16_t* v2) +{ + int res, t; +#if ORDER > 256 + int cnt = ORDER>>8; +#endif + + asm volatile ( +#if ORDER > 256 + "pxor %%mm1, %%mm1 \n" + "1: \n" +#else + "movq (%[v1]), %%mm1 \n" + "pmaddwd (%[v2]), %%mm1 \n" +#endif + +#define SP_BLOCK(n) \ + "movq " #n "(%[v1]), %%mm0 \n" \ + "pmaddwd " #n "(%[v2]), %%mm0 \n" \ + "paddd %%mm0, %%mm1 \n" + +REPEAT_MB(SP_BLOCK) + +#if ORDER > 256 + "add $512, %[v1] \n" + "add $512, %[v2] \n" + "dec %[cnt] \n" + "jne 1b \n" +#endif + + "movd %%mm1, %[t] \n" + "psrlq $32, %%mm1 \n" + "movd %%mm1, %[res] \n" + "add %[t], %[res] \n" + : /* outputs */ +#if ORDER > 256 + [cnt]"+r"(cnt), + [res]"=r"(res), + [t] "=r"(t) + : /* inputs */ + [v1]"1"(v1), + [v2]"2"(v2) +#else + [res]"=r"(res), + [t] "=r"(t) + : /* inputs */ + [v1]"r"(v1), + [v2]"r"(v2) +#endif + : /* clobbers */ + "mm0", "mm1" + ); + return res; +} diff --git a/lib/rbcodec/codecs/demac/libdemac/vector_math32_armv4.h b/lib/rbcodec/codecs/demac/libdemac/vector_math32_armv4.h new file mode 100644 index 0000000000..d6bb9b0d9c --- /dev/null +++ b/lib/rbcodec/codecs/demac/libdemac/vector_math32_armv4.h @@ -0,0 +1,201 @@ +/* + +libdemac - A Monkey's Audio decoder + +$Id$ + +Copyright (C) Dave Chapman 2007 + +ARMv4 vector math copyright (C) 2008 Jens Arnold + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA + +*/ + +#define FUSED_VECTOR_MATH + +#if ORDER > 32 +#define REPEAT_BLOCK(x) x x x x x x x x +#elif ORDER > 16 +#define REPEAT_BLOCK(x) x x x x x x x +#else +#define REPEAT_BLOCK(x) x x x +#endif + +/* Calculate scalarproduct, then add a 2nd vector (fused for performance) */ +static inline int32_t vector_sp_add(int32_t* v1, int32_t* f2, int32_t* s2) +{ + int res; +#if ORDER > 32 + int cnt = ORDER>>5; +#endif + + asm volatile ( +#if ORDER > 32 + "mov %[res], #0 \n" + "1: \n" +#else + "ldmia %[v1], {r0-r3} \n" + "ldmia %[f2]!, {r4-r7} \n" + "mul %[res], r4, r0 \n" + "mla %[res], r5, r1, %[res] \n" + "mla %[res], r6, r2, %[res] \n" + "mla %[res], r7, r3, %[res] \n" + "ldmia %[s2]!, {r4-r7} \n" + "add r0, r0, r4 \n" + "add r1, r1, r5 \n" + "add r2, r2, r6 \n" + "add r3, r3, r7 \n" + "stmia %[v1]!, {r0-r3} \n" +#endif + REPEAT_BLOCK( + "ldmia %[v1], {r0-r3} \n" + "ldmia %[f2]!, {r4-r7} \n" + "mla %[res], r4, r0, %[res] \n" + "mla %[res], r5, r1, %[res] \n" + "mla %[res], r6, r2, %[res] \n" + "mla %[res], r7, r3, %[res] \n" + "ldmia %[s2]!, {r4-r7} \n" + "add r0, r0, r4 \n" + "add r1, r1, r5 \n" + "add r2, r2, r6 \n" + "add r3, r3, r7 \n" + "stmia %[v1]!, {r0-r3} \n" + ) +#if ORDER > 32 + "subs %[cnt], %[cnt], #1 \n" + "bne 1b \n" +#endif + : /* outputs */ +#if ORDER > 32 + [cnt]"+r"(cnt), +#endif + [v1] "+r"(v1), + [f2] "+r"(f2), + [s2] "+r"(s2), + [res]"=r"(res) + : /* inputs */ + : /* clobbers */ + "r0", "r1", "r2", "r3", "r4", + "r5", "r6", "r7", "cc", "memory" + ); + return res; +} + +/* Calculate scalarproduct, then subtract a 2nd vector (fused for performance) */ +static inline int32_t vector_sp_sub(int32_t* v1, int32_t* f2, int32_t* s2) +{ + int res; +#if ORDER > 32 + int cnt = ORDER>>5; +#endif + + asm volatile ( +#if ORDER > 32 + "mov %[res], #0 \n" + "1: \n" +#else + "ldmia %[v1], {r0-r3} \n" + "ldmia %[f2]!, {r4-r7} \n" + "mul %[res], r4, r0 \n" + "mla %[res], r5, r1, %[res] \n" + "mla %[res], r6, r2, %[res] \n" + "mla %[res], r7, r3, %[res] \n" + "ldmia %[s2]!, {r4-r7} \n" + "sub r0, r0, r4 \n" + "sub r1, r1, r5 \n" + "sub r2, r2, r6 \n" + "sub r3, r3, r7 \n" + "stmia %[v1]!, {r0-r3} \n" +#endif + REPEAT_BLOCK( + "ldmia %[v1], {r0-r3} \n" + "ldmia %[f2]!, {r4-r7} \n" + "mla %[res], r4, r0, %[res] \n" + "mla %[res], r5, r1, %[res] \n" + "mla %[res], r6, r2, %[res] \n" + "mla %[res], r7, r3, %[res] \n" + "ldmia %[s2]!, {r4-r7} \n" + "sub r0, r0, r4 \n" + "sub r1, r1, r5 \n" + "sub r2, r2, r6 \n" + "sub r3, r3, r7 \n" + "stmia %[v1]!, {r0-r3} \n" + ) +#if ORDER > 32 + "subs %[cnt], %[cnt], #1 \n" + "bne 1b \n" +#endif + : /* outputs */ +#if ORDER > 32 + [cnt]"+r"(cnt), +#endif + [v1] "+r"(v1), + [f2] "+r"(f2), + [s2] "+r"(s2), + [res]"=r"(res) + : /* inputs */ + : /* clobbers */ + "r0", "r1", "r2", "r3", "r4", + "r5", "r6", "r7", "cc", "memory" + ); + return res; +} + +static inline int32_t scalarproduct(int32_t* v1, int32_t* v2) +{ + int res; +#if ORDER > 32 + int cnt = ORDER>>5; +#endif + + asm volatile ( +#if ORDER > 32 + "mov %[res], #0 \n" + "1: \n" +#else + "ldmia %[v1]!, {r0-r3} \n" + "ldmia %[v2]!, {r4-r7} \n" + "mul %[res], r4, r0 \n" + "mla %[res], r5, r1, %[res] \n" + "mla %[res], r6, r2, %[res] \n" + "mla %[res], r7, r3, %[res] \n" +#endif + REPEAT_BLOCK( + "ldmia %[v1]!, {r0-r3} \n" + "ldmia %[v2]!, {r4-r7} \n" + "mla %[res], r4, r0, %[res] \n" + "mla %[res], r5, r1, %[res] \n" + "mla %[res], r6, r2, %[res] \n" + "mla %[res], r7, r3, %[res] \n" + ) +#if ORDER > 32 + "subs %[cnt], %[cnt], #1 \n" + "bne 1b \n" +#endif + : /* outputs */ +#if ORDER > 32 + [cnt]"+r"(cnt), +#endif + [v1] "+r"(v1), + [v2] "+r"(v2), + [res]"=r"(res) + : /* inputs */ + : /* clobbers */ + "r0", "r1", "r2", "r3", + "r4", "r5", "r6", "r7", "cc", "memory" + ); + return res; +} diff --git a/lib/rbcodec/codecs/demac/libdemac/vector_math_generic.h b/lib/rbcodec/codecs/demac/libdemac/vector_math_generic.h new file mode 100644 index 0000000000..00bf07a007 --- /dev/null +++ b/lib/rbcodec/codecs/demac/libdemac/vector_math_generic.h @@ -0,0 +1,160 @@ +/* + +libdemac - A Monkey's Audio decoder + +$Id$ + +Copyright (C) Dave Chapman 2007 + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA + +*/ + +#include "demac_config.h" + +static inline void vector_add(filter_int* v1, filter_int* v2) +{ +#if ORDER > 32 + int order = (ORDER >> 5); + while (order--) +#endif + { + *v1++ += *v2++; + *v1++ += *v2++; + *v1++ += *v2++; + *v1++ += *v2++; + *v1++ += *v2++; + *v1++ += *v2++; + *v1++ += *v2++; + *v1++ += *v2++; + *v1++ += *v2++; + *v1++ += *v2++; + *v1++ += *v2++; + *v1++ += *v2++; + *v1++ += *v2++; + *v1++ += *v2++; + *v1++ += *v2++; + *v1++ += *v2++; +#if ORDER > 16 + *v1++ += *v2++; + *v1++ += *v2++; + *v1++ += *v2++; + *v1++ += *v2++; + *v1++ += *v2++; + *v1++ += *v2++; + *v1++ += *v2++; + *v1++ += *v2++; + *v1++ += *v2++; + *v1++ += *v2++; + *v1++ += *v2++; + *v1++ += *v2++; + *v1++ += *v2++; + *v1++ += *v2++; + *v1++ += *v2++; + *v1++ += *v2++; +#endif + } +} + +static inline void vector_sub(filter_int* v1, filter_int* v2) +{ +#if ORDER > 32 + int order = (ORDER >> 5); + while (order--) +#endif + { + *v1++ -= *v2++; + *v1++ -= *v2++; + *v1++ -= *v2++; + *v1++ -= *v2++; + *v1++ -= *v2++; + *v1++ -= *v2++; + *v1++ -= *v2++; + *v1++ -= *v2++; + *v1++ -= *v2++; + *v1++ -= *v2++; + *v1++ -= *v2++; + *v1++ -= *v2++; + *v1++ -= *v2++; + *v1++ -= *v2++; + *v1++ -= *v2++; + *v1++ -= *v2++; +#if ORDER > 16 + *v1++ -= *v2++; + *v1++ -= *v2++; + *v1++ -= *v2++; + *v1++ -= *v2++; + *v1++ -= *v2++; + *v1++ -= *v2++; + *v1++ -= *v2++; + *v1++ -= *v2++; + *v1++ -= *v2++; + *v1++ -= *v2++; + *v1++ -= *v2++; + *v1++ -= *v2++; + *v1++ -= *v2++; + *v1++ -= *v2++; + *v1++ -= *v2++; + *v1++ -= *v2++; +#endif + } +} + +static inline int32_t scalarproduct(filter_int* v1, filter_int* v2) +{ + int res = 0; + +#if ORDER > 32 + int order = (ORDER >> 5); + while (order--) +#endif + { + res += *v1++ * *v2++; + res += *v1++ * *v2++; + res += *v1++ * *v2++; + res += *v1++ * *v2++; + res += *v1++ * *v2++; + res += *v1++ * *v2++; + res += *v1++ * *v2++; + res += *v1++ * *v2++; + res += *v1++ * *v2++; + res += *v1++ * *v2++; + res += *v1++ * *v2++; + res += *v1++ * *v2++; + res += *v1++ * *v2++; + res += *v1++ * *v2++; + res += *v1++ * *v2++; + res += *v1++ * *v2++; +#if ORDER > 16 + res += *v1++ * *v2++; + res += *v1++ * *v2++; + res += *v1++ * *v2++; + res += *v1++ * *v2++; + res += *v1++ * *v2++; + res += *v1++ * *v2++; + res += *v1++ * *v2++; + res += *v1++ * *v2++; + res += *v1++ * *v2++; + res += *v1++ * *v2++; + res += *v1++ * *v2++; + res += *v1++ * *v2++; + res += *v1++ * *v2++; + res += *v1++ * *v2++; + res += *v1++ * *v2++; + res += *v1++ * *v2++; +#endif + } + return res; +} diff --git a/lib/rbcodec/codecs/demac/wavwrite.c b/lib/rbcodec/codecs/demac/wavwrite.c new file mode 100644 index 0000000000..71d2b7bb97 --- /dev/null +++ b/lib/rbcodec/codecs/demac/wavwrite.c @@ -0,0 +1,110 @@ +/* + +demac - A Monkey's Audio decoder + +$Id$ + +Copyright (C) Dave Chapman 2007 + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA + +*/ + +#include +#include +#include +#include "inttypes.h" +#include +#include +#include +#include + +#include "parser.h" + +#ifndef __WIN32__ +#define O_BINARY 0 +#endif + +static unsigned char wav_header[44]={ + 'R','I','F','F',// 0 - ChunkID + 0,0,0,0, // 4 - ChunkSize (filesize-8) + 'W','A','V','E',// 8 - Format + 'f','m','t',' ',// 12 - SubChunkID + 16,0,0,0, // 16 - SubChunk1ID // 16 for PCM + 1,0, // 20 - AudioFormat (1=Uncompressed) + 2,0, // 22 - NumChannels + 0,0,0,0, // 24 - SampleRate in Hz + 0,0,0,0, // 28 - Byte Rate (SampleRate*NumChannels*(BitsPerSample/8) + 4,0, // 32 - BlockAlign (== NumChannels * BitsPerSample/8) + 16,0, // 34 - BitsPerSample + 'd','a','t','a',// 36 - Subchunk2ID + 0,0,0,0 // 40 - Subchunk2Size +}; + +int open_wav(struct ape_ctx_t* ape_ctx, char* filename) +{ + int fd; + int x; + int filesize; + int bytespersample; + + fd=open(filename, O_CREAT|O_WRONLY|O_TRUNC|O_BINARY, 0644); + if (fd < 0) + return fd; + + bytespersample=ape_ctx->bps/8; + + filesize=ape_ctx->totalsamples*bytespersample*ape_ctx->channels+44; + + // ChunkSize + x=filesize-8; + wav_header[4]=(x&0xff); + wav_header[5]=(x&0xff00)>>8; + wav_header[6]=(x&0xff0000)>>16; + wav_header[7]=(x&0xff000000)>>24; + + // Number of channels + wav_header[22]=ape_ctx->channels; + + // Samplerate + wav_header[24]=ape_ctx->samplerate&0xff; + wav_header[25]=(ape_ctx->samplerate&0xff00)>>8; + wav_header[26]=(ape_ctx->samplerate&0xff0000)>>16; + wav_header[27]=(ape_ctx->samplerate&0xff000000)>>24; + + // ByteRate + x=ape_ctx->samplerate*(ape_ctx->bps/8)*ape_ctx->channels; + wav_header[28]=(x&0xff); + wav_header[29]=(x&0xff00)>>8; + wav_header[30]=(x&0xff0000)>>16; + wav_header[31]=(x&0xff000000)>>24; + + // BlockAlign + wav_header[32]=(ape_ctx->bps/8)*ape_ctx->channels; + + // Bits per sample + wav_header[34]=ape_ctx->bps; + + // Subchunk2Size + x=filesize-44; + wav_header[40]=(x&0xff); + wav_header[41]=(x&0xff00)>>8; + wav_header[42]=(x&0xff0000)>>16; + wav_header[43]=(x&0xff000000)>>24; + + write(fd,wav_header,sizeof(wav_header)); + + return fd; +} diff --git a/lib/rbcodec/codecs/demac/wavwrite.h b/lib/rbcodec/codecs/demac/wavwrite.h new file mode 100644 index 0000000000..a124353229 --- /dev/null +++ b/lib/rbcodec/codecs/demac/wavwrite.h @@ -0,0 +1,32 @@ +/* + +demac - A Monkey's Audio decoder + +$Id$ + +Copyright (C) Dave Chapman 2007 + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA + +*/ + +#ifndef _APE_WAVWRITE_H +#define _APE_WAVWRITE_H + +#include "parser.h" + +int open_wav(struct ape_ctx_t* ape_ctx, char* filename); + +#endif diff --git a/lib/rbcodec/codecs/flac.c b/lib/rbcodec/codecs/flac.c new file mode 100644 index 0000000000..e10403819c --- /dev/null +++ b/lib/rbcodec/codecs/flac.c @@ -0,0 +1,536 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2005 Dave Chapman + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include "codeclib.h" +#include + +CODEC_HEADER + +static FLACContext fc IBSS_ATTR_FLAC; + +/* The output buffers containing the decoded samples (channels 0 and 1) */ +static int32_t decoded0[MAX_BLOCKSIZE] IBSS_ATTR_FLAC; +static int32_t decoded1[MAX_BLOCKSIZE] IBSS_ATTR_FLAC; +static int32_t decoded2[MAX_BLOCKSIZE] IBSS_ATTR_FLAC_LARGE_IRAM; +static int32_t decoded3[MAX_BLOCKSIZE] IBSS_ATTR_FLAC_LARGE_IRAM; +static int32_t decoded4[MAX_BLOCKSIZE] IBSS_ATTR_FLAC_XLARGE_IRAM; +static int32_t decoded5[MAX_BLOCKSIZE] IBSS_ATTR_FLAC_XLARGE_IRAM; + +#define MAX_SUPPORTED_SEEKTABLE_SIZE 5000 + +/* Notes about seeking: + + The full seek table consists of: + uint64_t sample (only 36 bits are used) + uint64_t offset + uint32_t blocksize + + We also limit the sample and offset values to 32-bits - Rockbox doesn't + support files bigger than 2GB on FAT32 filesystems. + + The reference FLAC encoder produces a seek table with points every + 10 seconds, but this can be overridden by the user when encoding a file. + + With the default settings, a typical 4 minute track will contain + 24 seek points. + + Taking the extreme case of a Rockbox supported file to be a 2GB (compressed) + 16-bit/44.1KHz mono stream with a likely uncompressed size of 4GB: + Total duration is: 48694 seconds (about 810 minutes - 13.5 hours) + Total number of seek points: 4869 + + Therefore we limit the number of seek points to 5000. This is a + very extreme case, and requires 5000*8=40000 bytes of storage. + + If we come across a FLAC file with more than this number of seekpoints, we + just use the first 5000. + +*/ + +struct FLACseekpoints { + uint32_t sample; + uint32_t offset; + uint16_t blocksize; +}; + +static struct FLACseekpoints seekpoints[MAX_SUPPORTED_SEEKTABLE_SIZE]; +static int nseekpoints; + +static int8_t *bit_buffer; +static size_t buff_size; + +static bool flac_init(FLACContext* fc, int first_frame_offset) +{ + unsigned char buf[255]; + bool found_streaminfo=false; + uint32_t seekpoint_hi,seekpoint_lo; + uint32_t offset_hi,offset_lo; + uint16_t blocksize; + int endofmetadata=0; + uint32_t blocklength; + + ci->memset(fc,0,sizeof(FLACContext)); + nseekpoints=0; + + fc->sample_skip = 0; + + /* Reset sample buffers */ + memset(decoded0, 0, sizeof(decoded0)); + memset(decoded1, 0, sizeof(decoded1)); + memset(decoded2, 0, sizeof(decoded2)); + memset(decoded3, 0, sizeof(decoded3)); + memset(decoded4, 0, sizeof(decoded4)); + memset(decoded5, 0, sizeof(decoded5)); + + /* Set sample buffers in decoder structure */ + fc->decoded[0] = decoded0; + fc->decoded[1] = decoded1; + fc->decoded[2] = decoded2; + fc->decoded[3] = decoded3; + fc->decoded[4] = decoded4; + fc->decoded[5] = decoded5; + + + /* Skip any foreign tags at start of file */ + ci->seek_buffer(first_frame_offset); + + fc->metadatalength = first_frame_offset; + + if (ci->read_filebuf(buf, 4) < 4) + { + return false; + } + + if (ci->memcmp(buf,"fLaC",4) != 0) + { + return false; + } + fc->metadatalength += 4; + + while (!endofmetadata) { + if (ci->read_filebuf(buf, 4) < 4) + { + return false; + } + + endofmetadata=(buf[0]&0x80); + blocklength = (buf[1] << 16) | (buf[2] << 8) | buf[3]; + fc->metadatalength+=blocklength+4; + + if ((buf[0] & 0x7f) == 0) /* 0 is the STREAMINFO block */ + { + if (ci->read_filebuf(buf, blocklength) < blocklength) return false; + + fc->filesize = ci->filesize; + fc->min_blocksize = (buf[0] << 8) | buf[1]; + int max_blocksize = (buf[2] << 8) | buf[3]; + if (max_blocksize > MAX_BLOCKSIZE) + { + LOGF("FLAC: Maximum blocksize is too large (%d > %d)\n", + max_blocksize, MAX_BLOCKSIZE); + return false; + } + fc->max_blocksize = max_blocksize; + fc->min_framesize = (buf[4] << 16) | (buf[5] << 8) | buf[6]; + fc->max_framesize = (buf[7] << 16) | (buf[8] << 8) | buf[9]; + fc->samplerate = (buf[10] << 12) | (buf[11] << 4) + | ((buf[12] & 0xf0) >> 4); + fc->channels = ((buf[12]&0x0e)>>1) + 1; + fc->bps = (((buf[12]&0x01) << 4) | ((buf[13]&0xf0)>>4) ) + 1; + + /* totalsamples is a 36-bit field, but we assume <= 32 bits are + used */ + fc->totalsamples = (buf[14] << 24) | (buf[15] << 16) + | (buf[16] << 8) | buf[17]; + + /* Calculate track length (in ms) and estimate the bitrate + (in kbit/s) */ + fc->length = ((int64_t) fc->totalsamples * 1000) / fc->samplerate; + + found_streaminfo=true; + } else if ((buf[0] & 0x7f) == 3) { /* 3 is the SEEKTABLE block */ + while ((nseekpoints < MAX_SUPPORTED_SEEKTABLE_SIZE) && + (blocklength >= 18)) { + if (ci->read_filebuf(buf,18) < 18) return false; + blocklength-=18; + + seekpoint_hi=(buf[0] << 24) | (buf[1] << 16) | + (buf[2] << 8) | buf[3]; + seekpoint_lo=(buf[4] << 24) | (buf[5] << 16) | + (buf[6] << 8) | buf[7]; + offset_hi=(buf[8] << 24) | (buf[9] << 16) | + (buf[10] << 8) | buf[11]; + offset_lo=(buf[12] << 24) | (buf[13] << 16) | + (buf[14] << 8) | buf[15]; + + blocksize=(buf[16] << 8) | buf[17]; + + /* Only store seekpoints where the high 32 bits are zero */ + if ((seekpoint_hi == 0) && (seekpoint_lo != 0xffffffff) && + (offset_hi == 0)) { + seekpoints[nseekpoints].sample=seekpoint_lo; + seekpoints[nseekpoints].offset=offset_lo; + seekpoints[nseekpoints].blocksize=blocksize; + nseekpoints++; + } + } + /* Skip any unread seekpoints */ + if (blocklength > 0) + ci->advance_buffer(blocklength); + } else { + /* Skip to next metadata block */ + ci->advance_buffer(blocklength); + } + } + + if (found_streaminfo) { + fc->bitrate = ((int64_t) (fc->filesize-fc->metadatalength) * 8) + / fc->length; + return true; + } else { + return false; + } +} + +/* Synchronize to next frame in stream - adapted from libFLAC 1.1.3b2 */ +static bool frame_sync(FLACContext* fc) { + unsigned int x = 0; + bool cached = false; + + /* Make sure we're byte aligned. */ + align_get_bits(&fc->gb); + + while(1) { + if(fc->gb.size_in_bits - get_bits_count(&fc->gb) < 8) { + /* Error, end of bitstream, a valid stream should never reach here + * since the buffer should contain at least one frame header. + */ + return false; + } + + if(cached) + cached = false; + else + x = get_bits(&fc->gb, 8); + + if(x == 0xff) { /* MAGIC NUMBER for first 8 frame sync bits. */ + x = get_bits(&fc->gb, 8); + /* We have to check if we just read two 0xff's in a row; the second + * may actually be the beginning of the sync code. + */ + if(x == 0xff) { /* MAGIC NUMBER for first 8 frame sync bits. */ + cached = true; + } + else if(x >> 2 == 0x3e) { /* MAGIC NUMBER for last 6 sync bits. */ + /* Succesfully synced. */ + break; + } + } + } + + /* Advance and init bit buffer to the new frame. */ + ci->advance_buffer((get_bits_count(&fc->gb)-16)>>3); /* consumed bytes */ + bit_buffer = ci->request_buffer(&buff_size, MAX_FRAMESIZE+16); + init_get_bits(&fc->gb, bit_buffer, buff_size*8); + + /* Decode the frame to verify the frame crc and + * fill fc with its metadata. + */ + if(flac_decode_frame(fc, + bit_buffer, buff_size, ci->yield) < 0) { + return false; + } + + return true; +} + +/* Seek to sample - adapted from libFLAC 1.1.3b2+ */ +static bool flac_seek(FLACContext* fc, uint32_t target_sample) { + off_t orig_pos = ci->curpos; + off_t pos = -1; + unsigned long lower_bound, upper_bound; + unsigned long lower_bound_sample, upper_bound_sample; + int i; + unsigned approx_bytes_per_frame; + uint32_t this_frame_sample = fc->samplenumber; + unsigned this_block_size = fc->blocksize; + bool needs_seek = true, first_seek = true; + + /* We are just guessing here. */ + if(fc->max_framesize > 0) + approx_bytes_per_frame = (fc->max_framesize + fc->min_framesize)/2 + 1; + /* Check if it's a known fixed-blocksize stream. */ + else if(fc->min_blocksize == fc->max_blocksize && fc->min_blocksize > 0) + approx_bytes_per_frame = fc->min_blocksize*fc->channels*fc->bps/8 + 64; + else + approx_bytes_per_frame = 4608 * fc->channels * fc->bps/8 + 64; + + /* Set an upper and lower bound on where in the stream we will search. */ + lower_bound = fc->metadatalength; + lower_bound_sample = 0; + upper_bound = fc->filesize; + upper_bound_sample = fc->totalsamples>0 ? fc->totalsamples : target_sample; + + /* Refine the bounds if we have a seektable with suitable points. */ + if(nseekpoints > 0) { + /* Find the closest seek point <= target_sample, if it exists. */ + for(i = nseekpoints-1; i >= 0; i--) { + if(seekpoints[i].sample <= target_sample) + break; + } + if(i >= 0) { /* i.e. we found a suitable seek point... */ + lower_bound = fc->metadatalength + seekpoints[i].offset; + lower_bound_sample = seekpoints[i].sample; + } + + /* Find the closest seek point > target_sample, if it exists. */ + for(i = 0; i < nseekpoints; i++) { + if(seekpoints[i].sample > target_sample) + break; + } + if(i < nseekpoints) { /* i.e. we found a suitable seek point... */ + upper_bound = fc->metadatalength + seekpoints[i].offset; + upper_bound_sample = seekpoints[i].sample; + } + } + + while(1) { + /* Check if bounds are still ok. */ + if(lower_bound_sample >= upper_bound_sample || + lower_bound > upper_bound) { + return false; + } + + /* Calculate new seek position */ + if(needs_seek) { + pos = (off_t)(lower_bound + + (((target_sample - lower_bound_sample) * + (int64_t)(upper_bound - lower_bound)) / + (upper_bound_sample - lower_bound_sample)) - + approx_bytes_per_frame); + + if(pos >= (off_t)upper_bound) + pos = (off_t)upper_bound-1; + if(pos < (off_t)lower_bound) + pos = (off_t)lower_bound; + } + + if(!ci->seek_buffer(pos)) + return false; + + bit_buffer = ci->request_buffer(&buff_size, MAX_FRAMESIZE+16); + init_get_bits(&fc->gb, bit_buffer, buff_size*8); + + /* Now we need to get a frame. It is possible for our seek + * to land in the middle of audio data that looks exactly like + * a frame header from a future version of an encoder. When + * that happens, frame_sync() will return false. + * But there is a remote possibility that it is properly + * synced at such a "future-codec frame", so to make sure, + * we wait to see several "unparseable" errors in a row before + * bailing out. + */ + { + unsigned unparseable_count; + bool got_a_frame = false; + for(unparseable_count = 0; !got_a_frame + && unparseable_count < 10; unparseable_count++) { + if(frame_sync(fc)) + got_a_frame = true; + } + if(!got_a_frame) { + ci->seek_buffer(orig_pos); + return false; + } + } + + this_frame_sample = fc->samplenumber; + this_block_size = fc->blocksize; + + if(target_sample >= this_frame_sample + && target_sample < this_frame_sample+this_block_size) { + /* Found the frame containing the target sample. */ + fc->sample_skip = target_sample - this_frame_sample; + break; + } + + if(this_frame_sample + this_block_size >= upper_bound_sample && + !first_seek) { + if(pos == (off_t)lower_bound || !needs_seek) { + ci->seek_buffer(orig_pos); + return false; + } + /* Our last move backwards wasn't big enough, try again. */ + approx_bytes_per_frame *= 2; + continue; + } + /* Allow one seek over upper bound, + * required for streams with unknown total samples. + */ + first_seek = false; + + /* Make sure we are not seeking in a corrupted stream */ + if(this_frame_sample < lower_bound_sample) { + ci->seek_buffer(orig_pos); + return false; + } + + approx_bytes_per_frame = this_block_size*fc->channels*fc->bps/8 + 64; + + /* We need to narrow the search. */ + if(target_sample < this_frame_sample) { + upper_bound_sample = this_frame_sample; + upper_bound = ci->curpos; + } + else { /* Target is beyond this frame. */ + /* We are close, continue in decoding next frames. */ + if(target_sample < this_frame_sample + 4*this_block_size) { + pos = ci->curpos + fc->framesize; + needs_seek = false; + } + + lower_bound_sample = this_frame_sample + this_block_size; + lower_bound = ci->curpos + fc->framesize; + } + } + + return true; +} + +/* Seek to file offset */ +static bool flac_seek_offset(FLACContext* fc, uint32_t offset) { + unsigned unparseable_count; + bool got_a_frame = false; + + if(!ci->seek_buffer(offset)) + return false; + + bit_buffer = ci->request_buffer(&buff_size, MAX_FRAMESIZE); + init_get_bits(&fc->gb, bit_buffer, buff_size*8); + + for(unparseable_count = 0; !got_a_frame + && unparseable_count < 10; unparseable_count++) { + if(frame_sync(fc)) + got_a_frame = true; + } + + if(!got_a_frame) { + ci->seek_buffer(fc->metadatalength); + return false; + } + + return true; +} + +/* this is the codec entry point */ +enum codec_status codec_main(enum codec_entry_call_reason reason) +{ + if (reason == CODEC_LOAD) { + /* Generic codec initialisation */ + ci->configure(DSP_SET_SAMPLE_DEPTH, FLAC_OUTPUT_DEPTH-1); + } + + return CODEC_OK; +} + +/* this is called for each file to process */ +enum codec_status codec_run(void) +{ + int8_t *buf; + uint32_t samplesdone; + uint32_t elapsedtime; + size_t bytesleft; + int consumed; + int res; + int frame; + intptr_t param; + + if (codec_init()) { + LOGF("FLAC: Error initialising codec\n"); + return CODEC_ERROR; + } + + /* Need to save offset for later use (cleared indirectly by flac_init) */ + samplesdone = ci->id3->offset; + + if (!flac_init(&fc,ci->id3->first_frame_offset)) { + LOGF("FLAC: Error initialising codec\n"); + return CODEC_ERROR; + } + + ci->configure(DSP_SWITCH_FREQUENCY, ci->id3->frequency); + ci->configure(DSP_SET_STEREO_MODE, fc.channels == 1 ? + STEREO_MONO : STEREO_NONINTERLEAVED); + codec_set_replaygain(ci->id3); + + flac_seek_offset(&fc, samplesdone); + samplesdone=fc.samplenumber+fc.blocksize; + elapsedtime=(samplesdone*10)/(ci->id3->frequency/100); + ci->set_elapsed(elapsedtime); + + /* The main decoding loop */ + frame=0; + buf = ci->request_buffer(&bytesleft, MAX_FRAMESIZE); + while (bytesleft) { + enum codec_command_action action = ci->get_command(¶m); + + if (action == CODEC_ACTION_HALT) + break; + + /* Deal with any pending seek requests */ + if (action == CODEC_ACTION_SEEK_TIME) { + if (flac_seek(&fc,(uint32_t)(((uint64_t)param + *ci->id3->frequency)/1000))) { + /* Refill the input buffer */ + buf = ci->request_buffer(&bytesleft, MAX_FRAMESIZE); + } + + ci->set_elapsed(param); + ci->seek_complete(); + } + + if((res=flac_decode_frame(&fc,buf, + bytesleft,ci->yield)) < 0) { + LOGF("FLAC: Frame %d, error %d\n",frame,res); + return CODEC_ERROR; + } + consumed=fc.gb.index/8; + frame++; + + ci->yield(); + ci->pcmbuf_insert(&fc.decoded[0][fc.sample_skip], &fc.decoded[1][fc.sample_skip], + fc.blocksize - fc.sample_skip); + + fc.sample_skip = 0; + + /* Update the elapsed-time indicator */ + samplesdone=fc.samplenumber+fc.blocksize; + elapsedtime=(samplesdone*10)/(ci->id3->frequency/100); + ci->set_elapsed(elapsedtime); + + ci->advance_buffer(consumed); + + buf = ci->request_buffer(&bytesleft, MAX_FRAMESIZE); + } + + LOGF("FLAC: Decoded %lu samples\n",(unsigned long)samplesdone); + return CODEC_OK; +} diff --git a/lib/rbcodec/codecs/gbs.c b/lib/rbcodec/codecs/gbs.c new file mode 100644 index 0000000000..def05ed351 --- /dev/null +++ b/lib/rbcodec/codecs/gbs.c @@ -0,0 +1,108 @@ + +/* Ripped off from Game_Music_Emu 0.5.2. http://www.slack.net/~ant/ */ + +#include +#include "libgme/gbs_emu.h" + +CODEC_HEADER + +/* Maximum number of bytes to process in one iteration */ +#define CHUNK_SIZE (1024*2) + +static int16_t samples[CHUNK_SIZE] IBSS_ATTR; +static struct Gbs_Emu gbs_emu; + +/****************** rockbox interface ******************/ + +static void set_codec_track(int t) { + Gbs_start_track(&gbs_emu, t); + + /* for loop mode we disable track limits */ + if (!ci->loop_track()) { + Track_set_fade(&gbs_emu, Track_get_length( &gbs_emu, t ), 4000); + } + ci->set_elapsed(t*1000); /* t is track no to display */ +} + +/* this is the codec entry point */ +enum codec_status codec_main(enum codec_entry_call_reason reason) +{ + if (reason == CODEC_LOAD) { + /* we only render 16 bits */ + ci->configure(DSP_SET_SAMPLE_DEPTH, 16); + + /* 44 Khz, Interleaved stereo */ + ci->configure(DSP_SET_FREQUENCY, 44100); + ci->configure(DSP_SET_STEREO_MODE, STEREO_INTERLEAVED); + + Gbs_init(&gbs_emu); + Gbs_set_sample_rate(&gbs_emu, 44100); + } + + return CODEC_OK; +} + +/* this is called for each file to process */ +enum codec_status codec_run(void) +{ + blargg_err_t err; + uint8_t *buf; + size_t n; + intptr_t param; + int track = 0; + + DEBUGF("GBS: next_track\n"); + if (codec_init()) { + return CODEC_ERROR; + } + + codec_set_replaygain(ci->id3); + + /* Read the entire file */ + DEBUGF("GBS: request file\n"); + ci->seek_buffer(0); + buf = ci->request_buffer(&n, ci->filesize); + if (!buf || n < (size_t)ci->filesize) { + DEBUGF("GBS: file load failed\n"); + return CODEC_ERROR; + } + + if ((err = Gbs_load_mem(&gbs_emu, buf, ci->filesize))) { + DEBUGF("GBS: Gbs_load_mem failed (%s)\n", err); + return CODEC_ERROR; + } + + /* Update internal track count */ + if (gbs_emu.m3u.size > 0) + gbs_emu.track_count = gbs_emu.m3u.size; + +next_track: + set_codec_track(track); + + /* The main decoder loop */ + while (1) { + enum codec_command_action action = ci->get_command(¶m); + + if (action == CODEC_ACTION_HALT) + break; + + if (action == CODEC_ACTION_SEEK_TIME) { + track = param/1000; + ci->seek_complete(); + if (track >= gbs_emu.track_count) break; + goto next_track; + } + + /* Generate audio buffer */ + err = Gbs_play(&gbs_emu, CHUNK_SIZE, samples); + if (err || Track_ended(&gbs_emu)) { + track++; + if (track >= gbs_emu.track_count) break; + goto next_track; + } + + ci->pcmbuf_insert(samples, NULL, CHUNK_SIZE >> 1); + } + + return CODEC_OK; +} diff --git a/lib/rbcodec/codecs/hes.c b/lib/rbcodec/codecs/hes.c new file mode 100644 index 0000000000..849fd88f12 --- /dev/null +++ b/lib/rbcodec/codecs/hes.c @@ -0,0 +1,108 @@ +/* Ripped off from Game_Music_Emu 0.5.2. http://www.slack.net/~ant/ */ + +#include +#include "codeclib.h" +#include "libgme/hes_emu.h" + +CODEC_HEADER + +/* Maximum number of bytes to process in one iteration */ +#define CHUNK_SIZE (1024*2) + +static int16_t samples[CHUNK_SIZE] IBSS_ATTR; +static struct Hes_Emu hes_emu; + +/****************** rockbox interface ******************/ + +static void set_codec_track(int t) { + Hes_start_track(&hes_emu, t); + + /* for loop mode we disable track limits */ + if (!ci->loop_track()) { + Track_set_fade(&hes_emu, Track_get_length( &hes_emu, t ), 4000); + } + ci->set_elapsed(t*1000); /* t is track no to display */ +} + +/* this is the codec entry point */ +enum codec_status codec_main(enum codec_entry_call_reason reason) +{ + if (reason == CODEC_LOAD) { + /* we only render 16 bits */ + ci->configure(DSP_SET_SAMPLE_DEPTH, 16); + + /* 44 Khz, Interleaved stereo */ + ci->configure(DSP_SET_FREQUENCY, 44100); + ci->configure(DSP_SET_STEREO_MODE, STEREO_INTERLEAVED); + + Hes_init(&hes_emu); + Hes_set_sample_rate(&hes_emu, 44100); + } + + return CODEC_OK; +} + +/* this is called for each file to process */ +enum codec_status codec_run(void) +{ + blargg_err_t err; + uint8_t *buf; + size_t n; + intptr_t param; + int track = 0; + + DEBUGF("HES: next_track\n"); + if (codec_init()) { + return CODEC_ERROR; + } + + codec_set_replaygain(ci->id3); + + /* Read the entire file */ + DEBUGF("HES: request file\n"); + ci->seek_buffer(0); + buf = ci->request_buffer(&n, ci->filesize); + if (!buf || n < (size_t)ci->filesize) { + DEBUGF("HES: file load failed\n"); + return CODEC_ERROR; + } + + if ((err = Hes_load_mem(&hes_emu, buf, ci->filesize))) { + DEBUGF("HES: Hes_load_mem failed (%s)\n", err); + return CODEC_ERROR; + } + + /* Update internal track count */ + if (hes_emu.m3u.size > 0) + hes_emu.track_count = hes_emu.m3u.size; + +next_track: + set_codec_track(track); + + /* The main decoder loop */ + while ( 1 ) { + enum codec_command_action action = ci->get_command(¶m); + + if (action == CODEC_ACTION_HALT) + break; + + if (action == CODEC_ACTION_SEEK_TIME) { + track = param/1000; + ci->seek_complete(); + if (track >= hes_emu.track_count) break; + goto next_track; + } + + /* Generate audio buffer */ + err = Hes_play(&hes_emu, CHUNK_SIZE, samples); + if (err || Track_ended(&hes_emu)) { + track++; + if (track >= hes_emu.track_count) break; + goto next_track; + } + + ci->pcmbuf_insert(samples, NULL, CHUNK_SIZE >> 1); + } + + return CODEC_OK; +} diff --git a/lib/rbcodec/codecs/kss.c b/lib/rbcodec/codecs/kss.c new file mode 100644 index 0000000000..92efcd4e5f --- /dev/null +++ b/lib/rbcodec/codecs/kss.c @@ -0,0 +1,111 @@ + +/* Ripped off from Game_Music_Emu 0.5.2. http://www.slack.net/~ant/ */ + +#include +#include "libgme/kss_emu.h" + +CODEC_HEADER + +/* Maximum number of bytes to process in one iteration */ +#define CHUNK_SIZE (1024*2) + +static int16_t samples[CHUNK_SIZE] IBSS_ATTR; +static struct Kss_Emu kss_emu; + +/****************** rockbox interface ******************/ + +static void set_codec_track(int t) { + Kss_start_track(&kss_emu, t); + + /* for REPEAT_ONE we disable track limits */ + if (!ci->loop_track()) { + Track_set_fade(&kss_emu, Track_get_length( &kss_emu, t ), 4000); + } + ci->set_elapsed(t*1000); /* t is track no to display */ +} + +/* this is the codec entry point */ +enum codec_status codec_main(enum codec_entry_call_reason reason) +{ + if (reason == CODEC_LOAD) { + /* we only render 16 bits */ + ci->configure(DSP_SET_SAMPLE_DEPTH, 16); + + /* 44 Khz, Interleaved stereo */ + ci->configure(DSP_SET_FREQUENCY, 44100); + ci->configure(DSP_SET_STEREO_MODE, STEREO_INTERLEAVED); + + Kss_init(&kss_emu); + Kss_set_sample_rate(&kss_emu, 44100); + } + + return CODEC_OK; +} + +/* this is called for each file to process */ +enum codec_status codec_run(void) +{ + blargg_err_t err; + uint8_t *buf; + size_t n; + int track; + intptr_t param; + + /* reset values */ + track = 0; + + DEBUGF("KSS: next_track\n"); + if (codec_init()) { + return CODEC_ERROR; + } + + codec_set_replaygain(ci->id3); + + /* Read the entire file */ + DEBUGF("KSS: request file\n"); + ci->seek_buffer(0); + buf = ci->request_buffer(&n, ci->filesize); + if (!buf || n < (size_t)ci->filesize) { + DEBUGF("KSS: file load failed\n"); + return CODEC_ERROR; + } + + if ((err = Kss_load_mem(&kss_emu, buf, ci->filesize))) { + DEBUGF("KSS: Kss_load failed (%s)\n", err); + return CODEC_ERROR; + } + + /* Update internal track count */ + if (kss_emu.m3u.size > 0) + kss_emu.track_count = kss_emu.m3u.size; + +next_track: + set_codec_track(track); + + /* The main decoder loop */ + while (1) { + enum codec_command_action action = ci->get_command(¶m); + + if (action == CODEC_ACTION_HALT) + break; + + if (action == CODEC_ACTION_SEEK_TIME) { + track = param/1000; + ci->seek_complete(); + if (track >= kss_emu.track_count) break; + goto next_track; + } + + /* Generate audio buffer */ + err = Kss_play(&kss_emu, CHUNK_SIZE, samples); + if (err || Track_ended(&kss_emu)) { + track++; + if (track >= kss_emu.track_count) break; + goto next_track; + } + + ci->pcmbuf_insert(samples, NULL, CHUNK_SIZE >> 1); + } + + return CODEC_OK; +} diff --git a/lib/rbcodec/codecs/lib/SOURCES b/lib/rbcodec/codecs/lib/SOURCES new file mode 100644 index 0000000000..257dcb5838 --- /dev/null +++ b/lib/rbcodec/codecs/lib/SOURCES @@ -0,0 +1,12 @@ +#if CONFIG_CODEC == SWCODEC /* software codec platforms */ +codeclib.c +fixedpoint.c +ffmpeg_bitstream.c + +mdct_lookup.c +fft-ffmpeg.c +mdct.c + +#elif (CONFIG_PLATFORM & PLATFORM_HOSTED) && defined(__APPLE__) +osx.dummy.c +#endif diff --git a/lib/rbcodec/codecs/lib/asm_arm.h b/lib/rbcodec/codecs/lib/asm_arm.h new file mode 100644 index 0000000000..8e5d0e68df --- /dev/null +++ b/lib/rbcodec/codecs/lib/asm_arm.h @@ -0,0 +1,292 @@ +/******************************************************************** + * * + * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * + * * + * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * + * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * + * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * + * * + * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * + * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * + * * + ******************************************************************** + + function: arm7 and later wide math functions + + ********************************************************************/ +#ifdef CPU_ARM + +#define INCL_OPTIMIZED_MULT32 +#if ARM_ARCH >= 6 +static inline int32_t MULT32(int32_t x, int32_t y) { + int32_t hi; + asm volatile("smmul %[hi], %[x], %[y] \n\t" + : [hi] "=&r" (hi) + : [x] "r" (x), [y] "r" (y) ); + return(hi); +} +#else +static inline int32_t MULT32(int32_t x, int32_t y) { + int32_t lo, hi; + asm volatile("smull\t%0, %1, %2, %3 \n\t" + : "=&r"(lo),"=&r"(hi) + : "r"(x),"r"(y) ); + return(hi); +} +#endif + +#define INCL_OPTIMIZED_MULT31 +static inline int32_t MULT31(int32_t x, int32_t y) { + return MULT32(x,y)<<1; +} + +#define INCL_OPTIMIZED_MULT31_SHIFT15 +static inline int32_t MULT31_SHIFT15(int32_t x, int32_t y) { + int32_t lo,hi; + asm volatile("smull %0, %1, %2, %3\n\t" + "movs %0, %0, lsr #15\n\t" + "adc %1, %0, %1, lsl #17\n\t" + : "=&r"(lo),"=&r"(hi) + : "r"(x),"r"(y) + : "cc" ); + return(hi); +} + +#define INCL_OPTIMIZED_MULT31_SHIFT16 +static inline int32_t MULT31_SHIFT16(int32_t x, int32_t y) { + int32_t lo,hi; + asm volatile("smull %0, %1, %2, %3\n\t" + "movs %0, %0, lsr #16\n\t" + "adc %1, %0, %1, lsl #16\n\t" + : "=&r"(lo),"=&r"(hi) + : "r"(x),"r"(y) + : "cc" ); + return(hi); +} + +#define INCL_OPTIMIZED_XPROD32 +#define XPROD32(a, b, t, v, x, y) \ +{ \ + int32_t l; \ + asm("smull %0, %1, %3, %5\n\t" \ + "rsb %2, %6, #0\n\t" \ + "smlal %0, %1, %4, %6\n\t" \ + "smull %0, %2, %3, %2\n\t" \ + "smlal %0, %2, %4, %5" \ + : "=&r" (l), "=&r" (x), "=&r" (y) \ + : "r" ((a)), "r" ((b)), "r" ((t)), "r" ((v)) ); \ +} + +#define INCL_OPTIMIZED_XPROD31_R +#define INCL_OPTIMIZED_XNPROD31_R +#if ARM_ARCH >= 6 +/* These may yield slightly different result from the macros below + because only the high 32 bits of the multiplications are accumulated while + the below macros use a 64 bit accumulator that is truncated to 32 bits.*/ +#define XPROD31_R(_a, _b, _t, _v, _x, _y)\ +{\ + int32_t x1, y1;\ + asm("smmul %[x1], %[t], %[a] \n\t"\ + "smmul %[y1], %[t], %[b] \n\t"\ + "smmla %[x1], %[v], %[b], %[x1] \n\t"\ + "smmls %[y1], %[v], %[a], %[y1] \n\t"\ + : [x1] "=&r" (x1), [y1] "=&r" (y1)\ + : [a] "r" (_a), [b] "r" (_b), [t] "r" (_t), [v] "r" (_v) );\ + _x = x1 << 1;\ + _y = y1 << 1;\ +} + +#define XNPROD31_R(_a, _b, _t, _v, _x, _y)\ +{\ + int32_t x1, y1;\ + asm("smmul %[x1], %[t], %[a] \n\t"\ + "smmul %[y1], %[t], %[b] \n\t"\ + "smmls %[x1], %[v], %[b], %[x1] \n\t"\ + "smmla %[y1], %[v], %[a], %[y1] \n\t"\ + : [x1] "=&r" (x1), [y1] "=&r" (y1)\ + : [a] "r" (_a), [b] "r" (_b), [t] "r" (_t), [v] "r" (_v) );\ + _x = x1 << 1;\ + _y = y1 << 1;\ +} +#else +#define XPROD31_R(_a, _b, _t, _v, _x, _y)\ +{\ + int32_t x1, y1, l;\ + asm("smull %0, %1, %5, %3\n\t"\ + "rsb %2, %3, #0\n\t"\ + "smlal %0, %1, %6, %4\n\t"\ + "smull %0, %2, %6, %2\n\t"\ + "smlal %0, %2, %5, %4"\ + : "=&r" (l), "=&r" (x1), "=&r" (y1)\ + : "r" (_a), "r" (_b), "r" (_t), "r" (_v) );\ + _x = x1 << 1;\ + _y = y1 << 1;\ +} + +#define XNPROD31_R(_a, _b, _t, _v, _x, _y)\ +{\ + int32_t x1, y1, l;\ + asm("smull %0, %1, %5, %3\n\t"\ + "rsb %2, %4, #0\n\t"\ + "smlal %0, %1, %6, %2\n\t"\ + "smull %0, %2, %5, %4\n\t"\ + "smlal %0, %2, %6, %3"\ + : "=&r" (l), "=&r" (x1), "=&r" (y1)\ + : "r" (_a), "r" (_b), "r" (_t), "r" (_v) );\ + _x = x1 << 1;\ + _y = y1 << 1;\ +} +#endif + +#define INCL_OPTIMIZED_XPROD31 +static inline void XPROD31(int32_t a, int32_t b, + int32_t t, int32_t v, + int32_t *x, int32_t *y) +{ + int32_t _x1, _y1; + XPROD31_R(a, b, t, v, _x1, _y1); + *x = _x1; + *y = _y1; +} + +#define INCL_OPTIMIZED_XNPROD31 +static inline void XNPROD31(int32_t a, int32_t b, + int32_t t, int32_t v, + int32_t *x, int32_t *y) +{ + int32_t _x1, _y1; + XNPROD31_R(a, b, t, v, _x1, _y1); + *x = _x1; + *y = _y1; +} + + +#ifndef _V_VECT_OPS +#define _V_VECT_OPS + +/* asm versions of vector operations for block.c, window.c */ +static inline +void vect_add(int32_t *x, const int32_t *y, int n) +{ + while (n>=4) { + asm volatile ("ldmia %[x], {r0, r1, r2, r3};" + "ldmia %[y]!, {r4, r5, r6, r7};" + "add r0, r0, r4;" + "add r1, r1, r5;" + "add r2, r2, r6;" + "add r3, r3, r7;" + "stmia %[x]!, {r0, r1, r2, r3};" + : [x] "+r" (x), [y] "+r" (y) + : : "r0", "r1", "r2", "r3", + "r4", "r5", "r6", "r7", + "memory"); + n -= 4; + } + /* add final elements */ + while (n>0) { + *x++ += *y++; + n--; + } +} + +static inline +void vect_copy(int32_t *x, const int32_t *y, int n) +{ + while (n>=4) { + asm volatile ("ldmia %[y]!, {r0, r1, r2, r3};" + "stmia %[x]!, {r0, r1, r2, r3};" + : [x] "+r" (x), [y] "+r" (y) + : : "r0", "r1", "r2", "r3", + "memory"); + n -= 4; + } + /* copy final elements */ + while (n>0) { + *x++ = *y++; + n--; + } +} + +static inline +void vect_mult_fw(int32_t *data, const int32_t *window, int n) +{ + while (n>=4) { + asm volatile ("ldmia %[d], {r0, r1, r2, r3};" + "ldmia %[w]!, {r4, r5, r6, r7};" + "smull r8, r9, r0, r4;" + "mov r0, r9, lsl #1;" + "smull r8, r9, r1, r5;" + "mov r1, r9, lsl #1;" + "smull r8, r9, r2, r6;" + "mov r2, r9, lsl #1;" + "smull r8, r9, r3, r7;" + "mov r3, r9, lsl #1;" + "stmia %[d]!, {r0, r1, r2, r3};" + : [d] "+r" (data), [w] "+r" (window) + : : "r0", "r1", "r2", "r3", + "r4", "r5", "r6", "r7", "r8", "r9", + "memory" ); + n -= 4; + } + while(n>0) { + *data = MULT31(*data, *window); + data++; + window++; + n--; + } +} + +static inline +void vect_mult_bw(int32_t *data, const int32_t *window, int n) +{ + while (n>=4) { + asm volatile ("ldmia %[d], {r0, r1, r2, r3};" + "ldmda %[w]!, {r4, r5, r6, r7};" + "smull r8, r9, r0, r7;" + "mov r0, r9, lsl #1;" + "smull r8, r9, r1, r6;" + "mov r1, r9, lsl #1;" + "smull r8, r9, r2, r5;" + "mov r2, r9, lsl #1;" + "smull r8, r9, r3, r4;" + "mov r3, r9, lsl #1;" + "stmia %[d]!, {r0, r1, r2, r3};" + : [d] "+r" (data), [w] "+r" (window) + : : "r0", "r1", "r2", "r3", + "r4", "r5", "r6", "r7", "r8", "r9", + "memory" ); + n -= 4; + } + while(n>0) { + *data = MULT31(*data, *window); + data++; + window--; + n--; + } +} + +#endif + +/* not used anymore */ +/* +#ifndef _V_CLIP_MATH +#define _V_CLIP_MATH + +static inline int32_t CLIP_TO_15(int32_t x) { + int tmp; + asm volatile("subs %1, %0, #32768\n\t" + "movpl %0, #0x7f00\n\t" + "orrpl %0, %0, #0xff\n" + "adds %1, %0, #32768\n\t" + "movmi %0, #0x8000" + : "+r"(x),"=r"(tmp) + : + : "cc"); + return(x); +} + +#endif +*/ + +#endif + diff --git a/lib/rbcodec/codecs/lib/asm_mcf5249.h b/lib/rbcodec/codecs/lib/asm_mcf5249.h new file mode 100644 index 0000000000..841c413a94 --- /dev/null +++ b/lib/rbcodec/codecs/lib/asm_mcf5249.h @@ -0,0 +1,353 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * + * Copyright (C) 2005 by Pedro Vasconcelos + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ +/* asm routines for wide math on the MCF5249 */ + +#if defined(CPU_COLDFIRE) + +#define INCL_OPTIMIZED_MULT32 +static inline int32_t MULT32(int32_t x, int32_t y) { + + asm volatile ("mac.l %[x], %[y], %%acc0;" /* multiply & shift */ + "movclr.l %%acc0, %[x];" /* move & clear acc */ + "asr.l #1, %[x];" /* no overflow test */ + : [x] "+&d" (x) + : [y] "r" (y) + : "cc"); + return x; +} + +#define INCL_OPTIMIZED_MULT31 +static inline int32_t MULT31(int32_t x, int32_t y) { + asm volatile ("mac.l %[x], %[y], %%acc0;" /* multiply */ + "movclr.l %%acc0, %[x];" /* move and clear */ + : [x] "+&r" (x) + : [y] "r" (y) + : "cc"); + return x; +} + +#define INCL_OPTIMIZED_MULT31_SHIFT15 +/* NOTE: this requires that the emac is *NOT* rounding */ +static inline int32_t MULT31_SHIFT15(int32_t x, int32_t y) { + int32_t r; + + asm volatile ("mac.l %[x], %[y], %%acc0;" /* multiply */ + "mulu.l %[y], %[x];" /* get lower half, avoid emac stall */ + "movclr.l %%acc0, %[r];" /* get higher half */ + "swap %[r];" /* hi<<16, plus one free */ + "lsr.l #8, %[x];" /* (unsigned)lo >> 15 */ + "lsr.l #7, %[x];" + "move.w %[x], %[r];" /* logical-or results */ + : [r] "=&d" (r), [x] "+d" (x) + : [y] "d" (y) + : "cc"); + return r; +} + +#define INCL_OPTIMIZED_MULT31_SHIFT16 +static inline int32_t MULT31_SHIFT16(int32_t x, int32_t y) { + int32_t r; + + asm volatile ("mac.l %[x], %[y], %%acc0;" /* multiply */ + "mulu.l %[y], %[x];" /* get lower half, avoid emac stall */ + "movclr.l %%acc0, %[r];" /* get higher half */ + "lsr.l #1, %[r];" /* hi >> 1, to compensate emac shift */ + "move.w %[r], %[x];" /* x = x & 0xffff0000 | r & 0xffff */ + "swap %[x];" /* x = (unsigned)x << 16 | (unsigned)x >> 16 */ + : [r] "=&d" (r), [x] "+d" (x) + : [y] "d" (y) + : "cc"); + return x; +} + +#define INCL_OPTIMIZED_XPROD31 +static inline +void XPROD31(int32_t a, int32_t b, + int32_t t, int32_t v, + int32_t *x, int32_t *y) +{ + asm volatile ("mac.l %[a], %[t], %%acc0;" + "mac.l %[b], %[v], %%acc0;" + "mac.l %[b], %[t], %%acc1;" + "msac.l %[a], %[v], %%acc1;" + "movclr.l %%acc0, %[a];" + "move.l %[a], (%[x]);" + "movclr.l %%acc1, %[a];" + "move.l %[a], (%[y]);" + : [a] "+&r" (a) + : [x] "a" (x), [y] "a" (y), + [b] "r" (b), [t] "r" (t), [v] "r" (v) + : "cc", "memory"); +} + +#define INCL_OPTIMIZED_XNPROD31 +static inline +void XNPROD31(int32_t a, int32_t b, + int32_t t, int32_t v, + int32_t *x, int32_t *y) +{ + asm volatile ("mac.l %[a], %[t], %%acc0;" + "msac.l %[b], %[v], %%acc0;" + "mac.l %[b], %[t], %%acc1;" + "mac.l %[a], %[v], %%acc1;" + "movclr.l %%acc0, %[a];" + "move.l %[a], (%[x]);" + "movclr.l %%acc1, %[a];" + "move.l %[a], (%[y]);" + : [a] "+&r" (a) + : [x] "a" (x), [y] "a" (y), + [b] "r" (b), [t] "r" (t), [v] "r" (v) + : "cc", "memory"); +} + + +/* this could lose the LSB by overflow, but i don't think it'll ever happen. + if anyone think they can hear a bug caused by this, please try the above + version. */ +#define INCL_OPTIMIZED_XPROD32 +#define XPROD32(_a, _b, _t, _v, _x, _y) \ + asm volatile ("mac.l %[a], %[t], %%acc0;" \ + "mac.l %[b], %[v], %%acc0;" \ + "mac.l %[b], %[t], %%acc1;" \ + "msac.l %[a], %[v], %%acc1;" \ + "movclr.l %%acc0, %[x];" \ + "asr.l #1, %[x];" \ + "movclr.l %%acc1, %[y];" \ + "asr.l #1, %[y];" \ + : [x] "=d" (_x), [y] "=d" (_y) \ + : [a] "r" (_a), [b] "r" (_b), \ + [t] "r" (_t), [v] "r" (_v) \ + : "cc"); + +#define INCL_OPTIMIZED_XPROD31_R +#define XPROD31_R(_a, _b, _t, _v, _x, _y) \ + asm volatile ("mac.l %[a], %[t], %%acc0;" \ + "mac.l %[b], %[v], %%acc0;" \ + "mac.l %[b], %[t], %%acc1;" \ + "msac.l %[a], %[v], %%acc1;" \ + "movclr.l %%acc0, %[x];" \ + "movclr.l %%acc1, %[y];" \ + : [x] "=r" (_x), [y] "=r" (_y) \ + : [a] "r" (_a), [b] "r" (_b), \ + [t] "r" (_t), [v] "r" (_v) \ + : "cc"); + +#define INCL_OPTIMIZED_XNPROD31_R +#define XNPROD31_R(_a, _b, _t, _v, _x, _y) \ + asm volatile ("mac.l %[a], %[t], %%acc0;" \ + "msac.l %[b], %[v], %%acc0;" \ + "mac.l %[b], %[t], %%acc1;" \ + "mac.l %[a], %[v], %%acc1;" \ + "movclr.l %%acc0, %[x];" \ + "movclr.l %%acc1, %[y];" \ + : [x] "=r" (_x), [y] "=r" (_y) \ + : [a] "r" (_a), [b] "r" (_b), \ + [t] "r" (_t), [v] "r" (_v) \ + : "cc"); + +#ifndef _V_VECT_OPS +#define _V_VECT_OPS + +/* asm versions of vector operations for block.c, window.c */ +/* assumes MAC is initialized & accumulators cleared */ +static inline +void vect_add(int32_t *x, const int32_t *y, int n) +{ + /* align to 16 bytes */ + while(n>0 && (int)x&15) { + *x++ += *y++; + n--; + } + asm volatile ("bra 1f;" + "0:" /* loop start */ + "movem.l (%[x]), %%d0-%%d3;" /* fetch values */ + "movem.l (%[y]), %%a0-%%a3;" + /* add */ + "add.l %%a0, %%d0;" + "add.l %%a1, %%d1;" + "add.l %%a2, %%d2;" + "add.l %%a3, %%d3;" + /* store and advance */ + "movem.l %%d0-%%d3, (%[x]);" + "lea.l (4*4, %[x]), %[x];" + "lea.l (4*4, %[y]), %[y];" + "subq.l #4, %[n];" /* done 4 elements */ + "1: cmpi.l #4, %[n];" + "bge 0b;" + : [n] "+d" (n), [x] "+a" (x), [y] "+a" (y) + : : "%d0", "%d1", "%d2", "%d3", "%a0", "%a1", "%a2", "%a3", + "cc", "memory"); + /* add final elements */ + while (n>0) { + *x++ += *y++; + n--; + } +} + +static inline +void vect_copy(int32_t *x, const int32_t *y, int n) +{ + /* align to 16 bytes */ + while(n>0 && (int)x&15) { + *x++ = *y++; + n--; + } + asm volatile ("bra 1f;" + "0:" /* loop start */ + "movem.l (%[y]), %%d0-%%d3;" /* fetch values */ + "movem.l %%d0-%%d3, (%[x]);" /* store */ + "lea.l (4*4, %[x]), %[x];" /* advance */ + "lea.l (4*4, %[y]), %[y];" + "subq.l #4, %[n];" /* done 4 elements */ + "1: cmpi.l #4, %[n];" + "bge 0b;" + : [n] "+d" (n), [x] "+a" (x), [y] "+a" (y) + : : "%d0", "%d1", "%d2", "%d3", "cc", "memory"); + /* copy final elements */ + while (n>0) { + *x++ = *y++; + n--; + } +} + +static inline +void vect_mult_fw(int32_t *data, const int32_t *window, int n) +{ + /* ensure data is aligned to 16-bytes */ + while(n>0 && (int)data&15) { + *data = MULT31(*data, *window); + data++; + window++; + n--; + } + asm volatile ("movem.l (%[d]), %%d0-%%d3;" /* loop start */ + "movem.l (%[w]), %%a0-%%a3;" /* pre-fetch registers */ + "lea.l (4*4, %[w]), %[w];" + "bra 1f;" /* jump to loop condition */ + "0:" /* loop body */ + /* multiply and load next window values */ + "mac.l %%d0, %%a0, (%[w])+, %%a0, %%acc0;" + "mac.l %%d1, %%a1, (%[w])+, %%a1, %%acc1;" + "mac.l %%d2, %%a2, (%[w])+, %%a2, %%acc2;" + "mac.l %%d3, %%a3, (%[w])+, %%a3, %%acc3;" + "movclr.l %%acc0, %%d0;" /* get the products */ + "movclr.l %%acc1, %%d1;" + "movclr.l %%acc2, %%d2;" + "movclr.l %%acc3, %%d3;" + /* store and advance */ + "movem.l %%d0-%%d3, (%[d]);" + "lea.l (4*4, %[d]), %[d];" + "movem.l (%[d]), %%d0-%%d3;" + "subq.l #4, %[n];" /* done 4 elements */ + "1: cmpi.l #4, %[n];" + "bge 0b;" + /* multiply final elements */ + "tst.l %[n];" + "beq 1f;" /* n=0 */ + "mac.l %%d0, %%a0, %%acc0;" + "movclr.l %%acc0, %%d0;" + "move.l %%d0, (%[d])+;" + "subq.l #1, %[n];" + "beq 1f;" /* n=1 */ + "mac.l %%d1, %%a1, %%acc0;" + "movclr.l %%acc0, %%d1;" + "move.l %%d1, (%[d])+;" + "subq.l #1, %[n];" + "beq 1f;" /* n=2 */ + /* otherwise n = 3 */ + "mac.l %%d2, %%a2, %%acc0;" + "movclr.l %%acc0, %%d2;" + "move.l %%d2, (%[d])+;" + "1:" + : [n] "+d" (n), [d] "+a" (data), [w] "+a" (window) + : : "%d0", "%d1", "%d2", "%d3", "%a0", "%a1", "%a2", "%a3", + "cc", "memory"); +} + +static inline +void vect_mult_bw(int32_t *data, const int32_t *window, int n) +{ + /* ensure at least data is aligned to 16-bytes */ + while(n>0 && (int)data&15) { + *data = MULT31(*data, *window); + data++; + window--; + n--; + } + asm volatile ("lea.l (-3*4, %[w]), %[w];" /* loop start */ + "movem.l (%[d]), %%d0-%%d3;" /* pre-fetch registers */ + "movem.l (%[w]), %%a0-%%a3;" + "bra 1f;" /* jump to loop condition */ + "0:" /* loop body */ + /* multiply and load next window value */ + "mac.l %%d0, %%a3, -(%[w]), %%a3, %%acc0;" + "mac.l %%d1, %%a2, -(%[w]), %%a2, %%acc1;" + "mac.l %%d2, %%a1, -(%[w]), %%a1, %%acc2;" + "mac.l %%d3, %%a0, -(%[w]), %%a0, %%acc3;" + "movclr.l %%acc0, %%d0;" /* get the products */ + "movclr.l %%acc1, %%d1;" + "movclr.l %%acc2, %%d2;" + "movclr.l %%acc3, %%d3;" + /* store and advance */ + "movem.l %%d0-%%d3, (%[d]);" + "lea.l (4*4, %[d]), %[d];" + "movem.l (%[d]), %%d0-%%d3;" + "subq.l #4, %[n];" /* done 4 elements */ + "1: cmpi.l #4, %[n];" + "bge 0b;" + /* multiply final elements */ + "tst.l %[n];" + "beq 1f;" /* n=0 */ + "mac.l %%d0, %%a3, %%acc0;" + "movclr.l %%acc0, %%d0;" + "move.l %%d0, (%[d])+;" + "subq.l #1, %[n];" + "beq 1f;" /* n=1 */ + "mac.l %%d1, %%a2, %%acc0;" + "movclr.l %%acc0, %%d1;" + "move.l %%d1, (%[d])+;" + "subq.l #1, %[n];" + "beq 1f;" /* n=2 */ + /* otherwise n = 3 */ + "mac.l %%d2, %%a1, %%acc0;" + "movclr.l %%acc0, %%d2;" + "move.l %%d2, (%[d])+;" + "1:" + : [n] "+d" (n), [d] "+a" (data), [w] "+a" (window) + : : "%d0", "%d1", "%d2", "%d3", "%a0", "%a1", "%a2", "%a3", + "cc", "memory"); +} + +#endif + +/* not used anymore */ +/* +#ifndef _V_CLIP_MATH +#define _V_CLIP_MATH + +* this is portable C and simple; why not use this as default? +static inline int32_t CLIP_TO_15(register int32_t x) { + register int32_t hi=32767, lo=-32768; + return (x>=hi ? hi : (x<=lo ? lo : x)); +} + +#endif +*/ +#endif diff --git a/lib/rbcodec/codecs/lib/codeclib.c b/lib/rbcodec/codecs/lib/codeclib.c new file mode 100644 index 0000000000..36f4279941 --- /dev/null +++ b/lib/rbcodec/codecs/lib/codeclib.c @@ -0,0 +1,182 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2005 Dave Chapman + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +/* "helper functions" common to all codecs */ + +#include +#include "codecs.h" +#include "dsp.h" +#include "codeclib.h" +#include "metadata.h" + +/* The following variables are used by codec_malloc() to make use of free RAM + * within the statically allocated codec buffer. */ +static size_t mem_ptr = 0; +static size_t bufsize = 0; +static unsigned char* mallocbuf = NULL; + +int codec_init(void) +{ + /* codec_get_buffer() aligns the resulting point to CACHEALIGN_SIZE. */ + mem_ptr = 0; + mallocbuf = (unsigned char *)ci->codec_get_buffer((size_t *)&bufsize); + + return 0; +} + +void codec_set_replaygain(const struct mp3entry *id3) +{ + ci->configure(DSP_SET_TRACK_GAIN, id3->track_gain); + ci->configure(DSP_SET_ALBUM_GAIN, id3->album_gain); + ci->configure(DSP_SET_TRACK_PEAK, id3->track_peak); + ci->configure(DSP_SET_ALBUM_PEAK, id3->album_peak); +} + +/* Various "helper functions" common to all the xxx2wav decoder plugins */ + + +void* codec_malloc(size_t size) +{ + void* x; + + if (mem_ptr + (long)size > bufsize) + return NULL; + + x=&mallocbuf[mem_ptr]; + + /* Keep memory aligned to CACHEALIGN_SIZE. */ + mem_ptr += (size + (CACHEALIGN_SIZE-1)) & ~(CACHEALIGN_SIZE-1); + + return(x); +} + +void* codec_calloc(size_t nmemb, size_t size) +{ + void* x; + x = codec_malloc(nmemb*size); + if (x == NULL) + return NULL; + ci->memset(x,0,nmemb*size); + return(x); +} + +void codec_free(void* ptr) { + (void)ptr; +} + +void* codec_realloc(void* ptr, size_t size) +{ + void* x; + (void)ptr; + x = codec_malloc(size); + return(x); +} + +size_t strlen(const char *s) +{ + return(ci->strlen(s)); +} + +char *strcpy(char *dest, const char *src) +{ + return(ci->strcpy(dest,src)); +} + +char *strcat(char *dest, const char *src) +{ + return(ci->strcat(dest,src)); +} + +int strcmp(const char *s1, const char *s2) +{ + return(ci->strcmp(s1,s2)); +} + +void *memcpy(void *dest, const void *src, size_t n) +{ + return(ci->memcpy(dest,src,n)); +} + +void *memset(void *s, int c, size_t n) +{ + return(ci->memset(s,c,n)); +} + +int memcmp(const void *s1, const void *s2, size_t n) +{ + return(ci->memcmp(s1,s2,n)); +} + +void* memchr(const void *s, int c, size_t n) +{ + return(ci->memchr(s,c,n)); +} + +void *memmove(void *dest, const void *src, size_t n) +{ + return(ci->memmove(dest,src,n)); +} + +void qsort(void *base, size_t nmemb, size_t size, + int(*compar)(const void *, const void *)) +{ + ci->qsort(base,nmemb,size,compar); +} + +/* From ffmpeg - libavutil/common.h */ +const uint8_t bs_log2_tab[256] ICONST_ATTR = { + 0,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, + 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, + 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, + 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, + 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, + 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, + 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, + 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7 +}; + +const uint8_t bs_clz_tab[256] ICONST_ATTR = { + 8,7,6,6,5,5,5,5,4,4,4,4,4,4,4,4,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, + 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +}; + +#ifdef RB_PROFILE +void __cyg_profile_func_enter(void *this_fn, void *call_site) { +/* This workaround is required for coldfire gcc 3.4 but is broken for 4.4 + and 4.5, but for those the other way works. */ +#if defined(CPU_COLDFIRE) && defined(__GNUC__) && __GNUC__ < 4 + (void)call_site; + ci->profile_func_enter(this_fn, __builtin_return_address(1)); +#else + ci->profile_func_enter(this_fn, call_site); +#endif +} + +void __cyg_profile_func_exit(void *this_fn, void *call_site) { + ci->profile_func_exit(this_fn,call_site); +} +#endif diff --git a/lib/rbcodec/codecs/lib/codeclib.h b/lib/rbcodec/codecs/lib/codeclib.h new file mode 100644 index 0000000000..d0f985b8e1 --- /dev/null +++ b/lib/rbcodec/codecs/lib/codeclib.h @@ -0,0 +1,163 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2005 Dave Chapman + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#ifndef __CODECLIB_H__ +#define __CODECLIB_H__ + +#include +#include +#include "config.h" +#include "codecs.h" +#include "mdct.h" +#include "fft.h" + +extern struct codec_api *ci; + +/* Standard library functions that are used by the codecs follow here */ + +/* Get these functions 'out of the way' of the standard functions. Not doing + * so confuses the cygwin linker, and maybe others. These functions need to + * be implemented elsewhere */ +#define malloc(x) codec_malloc(x) +#define calloc(x,y) codec_calloc(x,y) +#define realloc(x,y) codec_realloc(x,y) +#define free(x) codec_free(x) +#undef alloca +#define alloca(x) __builtin_alloca(x) + +void* codec_malloc(size_t size); +void* codec_calloc(size_t nmemb, size_t size); +void* codec_realloc(void* ptr, size_t size); +void codec_free(void* ptr); + +void *memcpy(void *dest, const void *src, size_t n); +void *memset(void *s, int c, size_t n); +int memcmp(const void *s1, const void *s2, size_t n); +void *memmove(void *s1, const void *s2, size_t n); + +size_t strlen(const char *s); +char *strcpy(char *dest, const char *src); +char *strcat(char *dest, const char *src); + +/* on some platforms strcmp() seems to be a tricky define which + * breaks if we write down strcmp's prototype */ +#undef strcmp +int strcmp(const char *s1, const char *s2); + +void qsort(void *base, size_t nmemb, size_t size, int(*compar)(const void *, const void *)); + +/*MDCT library functions*/ +/* -1- Tremor mdct */ +extern void mdct_backward(int n, int32_t *in, int32_t *out); +/* -2- ffmpeg fft-based mdct */ +extern void ff_imdct_half(unsigned int nbits, int32_t *output, const int32_t *input); +extern void ff_imdct_calc(unsigned int nbits, int32_t *output, const int32_t *input); +/*ffmpeg fft (can be used without mdct)*/ +extern void ff_fft_calc_c(int nbits, FFTComplex *z); + +#if !defined(CPU_ARM) || ARM_ARCH < 5 +/* From libavutil/common.h */ +extern const uint8_t bs_log2_tab[256] ICONST_ATTR; +extern const uint8_t bs_clz_tab[256] ICONST_ATTR; +#endif + +#define BS_LOG2 0 /* default personality, equivalent floor(log2(x)) */ +#define BS_CLZ 1 /* alternate personality, Count Leading Zeros */ +#define BS_SHORT 2 /* input guaranteed not to exceed 16 bits */ +#define BS_0_0 4 /* guarantee mapping of 0 input to 0 output */ + +/* Generic bit-scanning function, used to wrap platform CLZ instruction or + scan-and-lookup code, and to provide control over output for 0 inputs. */ +static inline unsigned int bs_generic(unsigned int v, int mode) +{ +#if defined(CPU_ARM) && ARM_ARCH >= 5 + unsigned int r = __builtin_clz(v); + if (mode & BS_CLZ) + { + if (mode & BS_0_0) + r &= 31; + } else { + r = 31 - r; + /* If mode is constant, this is a single conditional instruction */ + if (mode & BS_0_0 && (signed)r < 0) + r += 1; + } +#else + const uint8_t *bs_tab; + unsigned int r; + unsigned int n = v; + int inc; + /* Set up table, increment, and initial result value based on + personality. */ + if (mode & BS_CLZ) + { + bs_tab = bs_clz_tab; + r = 24; + inc = -16; + } else { + bs_tab = bs_log2_tab; + r = 0; + inc = 16; + } + if (!(mode & BS_SHORT) && n >= 0x10000) { + n >>= 16; + r += inc; + } + if (n > 0xff) { + n >>= 8; + r += inc / 2; + } +#ifdef CPU_COLDFIRE + /* The high 24 bits of n are guaranteed empty after the above, so a + superfluous ext.b instruction can be saved by loading the LUT value over + n with asm */ + asm volatile ( + "move.b (%1,%0.l),%0" + : "+d" (n) + : "a" (bs_tab) + ); +#else + n = bs_tab[n]; +#endif + r += n; + if (mode & BS_CLZ && mode & BS_0_0 && v == 0) + r = 0; +#endif + return r; +} + +/* TODO figure out if we really need to care about calculating + av_log2(0) */ +#define av_log2(v) bs_generic(v, BS_0_0) + +/* Various codec helper functions */ + +int codec_init(void); +void codec_set_replaygain(const struct mp3entry *id3); + +#ifdef RB_PROFILE +void __cyg_profile_func_enter(void *this_fn, void *call_site) + NO_PROF_ATTR ICODE_ATTR; +void __cyg_profile_func_exit(void *this_fn, void *call_site) + NO_PROF_ATTR ICODE_ATTR; +#endif + +#endif /* __CODECLIB_H__ */ diff --git a/lib/rbcodec/codecs/lib/codeclib_misc.h b/lib/rbcodec/codecs/lib/codeclib_misc.h new file mode 100644 index 0000000000..8ebe22e37b --- /dev/null +++ b/lib/rbcodec/codecs/lib/codeclib_misc.h @@ -0,0 +1,310 @@ +/******************************************************************** + * * + * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * + * * + * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * + * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * + * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * + * * + * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * + * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * + * * + ******************************************************************** + + function: miscellaneous math and prototypes + + ********************************************************************/ + +#ifndef _CODECLIB_MISC_H_ +#define _CODECLIB_MISC_H_ + +#include +#include "asm_arm.h" +#include "asm_mcf5249.h" + +#ifndef _LOW_ACCURACY_ +/* 64 bit multiply */ + +#ifdef ROCKBOX_LITTLE_ENDIAN +union magic { + struct { + int32_t lo; + int32_t hi; + } halves; + int64_t whole; +}; +#elif defined(ROCKBOX_BIG_ENDIAN) +union magic { + struct { + int32_t hi; + int32_t lo; + } halves; + int64_t whole; +}; +#endif + +#ifndef INCL_OPTIMIZED_MULT32 +#define INCL_OPTIMIZED_MULT32 +static inline int32_t MULT32(int32_t x, int32_t y) { + union magic magic; + magic.whole = (int64_t)x * y; + return magic.halves.hi; +} +#endif + +#ifndef INCL_OPTIMIZED_MULT31 +#define INCL_OPTIMIZED_MULT31 +static inline int32_t MULT31(int32_t x, int32_t y) { + return MULT32(x,y)<<1; +} +#endif + +#ifndef INCL_OPTIMIZED_MULT31_SHIFT15 +#define INCL_OPTIMIZED_MULT31_SHIFT15 +static inline int32_t MULT31_SHIFT15(int32_t x, int32_t y) { + union magic magic; + magic.whole = (int64_t)x * y; + return ((uint32_t)(magic.halves.lo)>>15) | ((magic.halves.hi)<<17); +} +#endif + +#ifndef INCL_OPTIMIZED_MULT31_SHIFT16 +#define INCL_OPTIMIZED_MULT31_SHIFT16 +static inline int32_t MULT31_SHIFT16(int32_t x, int32_t y) { + union magic magic; + magic.whole = (int64_t)x * y; + return ((uint32_t)(magic.halves.lo)>>16) | ((magic.halves.hi)<<16); +} +#endif + +#else +/* Rockbox: unused */ +#if 0 +/* 32 bit multiply, more portable but less accurate */ + +/* + * Note: Precision is biased towards the first argument therefore ordering + * is important. Shift values were chosen for the best sound quality after + * many listening tests. + */ + +/* + * For MULT32 and MULT31: The second argument is always a lookup table + * value already preshifted from 31 to 8 bits. We therefore take the + * opportunity to save on text space and use unsigned char for those + * tables in this case. + */ + +static inline int32_t MULT32(int32_t x, int32_t y) { + return (x >> 9) * y; /* y preshifted >>23 */ +} + +static inline int32_t MULT31(int32_t x, int32_t y) { + return (x >> 8) * y; /* y preshifted >>23 */ +} + +static inline int32_t MULT31_SHIFT15(int32_t x, int32_t y) { + return (x >> 6) * y; /* y preshifted >>9 */ +} +#endif +#endif + +/* + * The XPROD functions are meant to optimize the cross products found all + * over the place in mdct.c by forcing memory operation ordering to avoid + * unnecessary register reloads as soon as memory is being written to. + * However this is only beneficial on CPUs with a sane number of general + * purpose registers which exclude the Intel x86. On Intel, better let the + * compiler actually reload registers directly from original memory by using + * macros. + */ + +#ifndef INCL_OPTIMIZED_XPROD32 +#define INCL_OPTIMIZED_XPROD32 +/* replaced XPROD32 with a macro to avoid memory reference + _x, _y are the results (must be l-values) */ +#define XPROD32(_a, _b, _t, _v, _x, _y) \ + { (_x)=MULT32(_a,_t)+MULT32(_b,_v); \ + (_y)=MULT32(_b,_t)-MULT32(_a,_v); } +#endif + +/* Rockbox: Unused */ +/* +#ifdef __i386__ + +#define XPROD31(_a, _b, _t, _v, _x, _y) \ + { *(_x)=MULT31(_a,_t)+MULT31(_b,_v); \ + *(_y)=MULT31(_b,_t)-MULT31(_a,_v); } +#define XNPROD31(_a, _b, _t, _v, _x, _y) \ + { *(_x)=MULT31(_a,_t)-MULT31(_b,_v); \ + *(_y)=MULT31(_b,_t)+MULT31(_a,_v); } + +#else +*/ + +#ifndef INCL_OPTIMIZED_XPROD31 +#define INCL_OPTIMIZED_XPROD31 +static inline void XPROD31(int32_t a, int32_t b, + int32_t t, int32_t v, + int32_t *x, int32_t *y) +{ + *x = MULT31(a, t) + MULT31(b, v); + *y = MULT31(b, t) - MULT31(a, v); +} +#endif + +#ifndef INCL_OPTIMIZED_XNPROD31 +#define INCL_OPTIMIZED_XNPROD31 +static inline void XNPROD31(int32_t a, int32_t b, + int32_t t, int32_t v, + int32_t *x, int32_t *y) +{ + *x = MULT31(a, t) - MULT31(b, v); + *y = MULT31(b, t) + MULT31(a, v); +} +#endif +/*#endif*/ + +#ifndef INCL_OPTIMIZED_XPROD31_R +#define INCL_OPTIMIZED_XPROD31_R +#define XPROD31_R(_a, _b, _t, _v, _x, _y)\ +{\ + _x = MULT31(_a, _t) + MULT31(_b, _v);\ + _y = MULT31(_b, _t) - MULT31(_a, _v);\ +} +#endif + +#ifndef INCL_OPTIMIZED_XNPROD31_R +#define INCL_OPTIMIZED_XNPROD31_R +#define XNPROD31_R(_a, _b, _t, _v, _x, _y)\ +{\ + _x = MULT31(_a, _t) - MULT31(_b, _v);\ + _y = MULT31(_b, _t) + MULT31(_a, _v);\ +} +#endif + +#ifndef _V_VECT_OPS +#define _V_VECT_OPS + +static inline +void vect_add(int32_t *x, const int32_t *y, int n) +{ + while (n>0) { + *x++ += *y++; + n--; + } +} + +static inline +void vect_copy(int32_t *x, const int32_t *y, int n) +{ + while (n>0) { + *x++ = *y++; + n--; + } +} + +static inline +void vect_mult_fw(int32_t *data, const int32_t *window, int n) +{ + while(n>0) { + *data = MULT31(*data, *window); + data++; + window++; + n--; + } +} + +static inline +void vect_mult_bw(int32_t *data, const int32_t *window, int n) +{ + while(n>0) { + *data = MULT31(*data, *window); + data++; + window--; + n--; + } +} +#endif + +/* not used anymore */ +/* +#ifndef _V_CLIP_MATH +#define _V_CLIP_MATH + +static inline int32_t CLIP_TO_15(int32_t x) { + int ret=x; + ret-= ((x<=32767)-1)&(x-32767); + ret-= ((x>=-32768)-1)&(x+32768); + return(ret); +} + +#endif +*/ +static inline int32_t VFLOAT_MULT(int32_t a,int32_t ap, + int32_t b,int32_t bp, + int32_t *p){ + if(a && b){ +#ifndef _LOW_ACCURACY_ + *p=ap+bp+32; + return MULT32(a,b); +#else + *p=ap+bp+31; + return (a>>15)*(b>>16); +#endif + }else + return 0; +} + +/*static inline int32_t VFLOAT_MULTI(int32_t a,int32_t ap, + int32_t i, + int32_t *p){ + + int ip=_ilog(abs(i))-31; + return VFLOAT_MULT(a,ap,i<<-ip,ip,p); +} +*/ +static inline int32_t VFLOAT_ADD(int32_t a,int32_t ap, + int32_t b,int32_t bp, + int32_t *p){ + + if(!a){ + *p=bp; + return b; + }else if(!b){ + *p=ap; + return a; + } + + /* yes, this can leak a bit. */ + if(ap>bp){ + int shift=ap-bp+1; + *p=ap+1; + a>>=1; + if(shift<32){ + b=(b+(1<<(shift-1)))>>shift; + }else{ + b=0; + } + }else{ + int shift=bp-ap+1; + *p=bp+1; + b>>=1; + if(shift<32){ + a=(a+(1<<(shift-1)))>>shift; + }else{ + a=0; + } + } + + a+=b; + if((a&0xc0000000)==0xc0000000 || + (a&0xc0000000)==0){ + a<<=1; + (*p)--; + } + return(a); +} + +#endif + diff --git a/lib/rbcodec/codecs/lib/ffmpeg_bitstream.c b/lib/rbcodec/codecs/lib/ffmpeg_bitstream.c new file mode 100644 index 0000000000..e16df8dcce --- /dev/null +++ b/lib/rbcodec/codecs/lib/ffmpeg_bitstream.c @@ -0,0 +1,374 @@ +/* + * Common bit i/o utils + * Copyright (c) 2000, 2001 Fabrice Bellard + * Copyright (c) 2002-2004 Michael Niedermayer + * Copyright (c) 2010 Loren Merritt + * + * alternative bitstream reader & writer by Michael Niedermayer + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * bitstream api. + */ + +//#include "avcodec.h" +#include "ffmpeg_get_bits.h" +#include "ffmpeg_put_bits.h" +#include "ffmpeg_intreadwrite.h" + +#define av_log(...) + +#ifdef ROCKBOX +#undef DEBUGF +#define DEBUGF(...) +#endif + +const uint8_t ff_log2_run[32]={ + 0, 0, 0, 0, 1, 1, 1, 1, + 2, 2, 2, 2, 3, 3, 3, 3, + 4, 4, 5, 5, 6, 6, 7, 7, + 8, 9,10,11,12,13,14,15 +}; + +#if 0 // unused in rockbox +void align_put_bits(PutBitContext *s) +{ +#ifdef ALT_BITSTREAM_WRITER + put_bits(s,( - s->index) & 7,0); +#else + put_bits(s,s->bit_left & 7,0); +#endif +} + +void ff_put_string(PutBitContext *pb, const char *string, int terminate_string) +{ + while(*string){ + put_bits(pb, 8, *string); + string++; + } + if(terminate_string) + put_bits(pb, 8, 0); +} +#endif + +void ff_copy_bits(PutBitContext *pb, const uint8_t *src, int length) +{ + int words= length>>4; + int bits= length&15; + int i; + + if(length==0) return; + + if(words < 16 || put_bits_count(pb)&7){ + for(i=0; i>(16-bits)); +} + +/* VLC decoding */ + +//#define DEBUG_VLC + +#define GET_DATA(v, table, i, wrap, size) \ +{\ + const uint8_t *ptr = (const uint8_t *)table + i * wrap;\ + switch(size) {\ + case 1:\ + v = *(const uint8_t *)ptr;\ + break;\ + case 2:\ + v = *(const uint16_t *)ptr;\ + break;\ + default:\ + v = *(const uint32_t *)ptr;\ + break;\ + }\ +} + + +static int alloc_table(VLC *vlc, int size, int use_static) +{ + int index; + index = vlc->table_size; + vlc->table_size += size; + if (vlc->table_size > vlc->table_allocated) { + if(use_static) + { + DEBUGF("init_vlc() used with too little memory : table_size > allocated_memory\n"); + return -1; + } +// abort(); //cant do anything, init_vlc() is used with too little memory +// vlc->table_allocated += (1 << vlc->bits); +// vlc->table = av_realloc(vlc->table, +// sizeof(VLC_TYPE) * 2 * vlc->table_allocated); + if (!vlc->table) + return -1; + } + return index; +} + +/* +static av_always_inline uint32_t bitswap_32(uint32_t x) { + return av_reverse[x&0xFF]<<24 + | av_reverse[(x>>8)&0xFF]<<16 + | av_reverse[(x>>16)&0xFF]<<8 + | av_reverse[x>>24]; +} +*/ + +typedef struct { + uint8_t bits; + uint16_t symbol; + /** codeword, with the first bit-to-be-read in the msb + * (even if intended for a little-endian bitstream reader) */ + uint32_t code; +} __attribute__((__packed__)) VLCcode; /* packed to save space */ + +static int compare_vlcspec(const void *a, const void *b) +{ + const VLCcode *sa=a, *sb=b; + return (sa->code >> 1) - (sb->code >> 1); +} + +/** + * Build VLC decoding tables suitable for use with get_vlc(). + * + * @param vlc the context to be initted + * + * @param table_nb_bits max length of vlc codes to store directly in this table + * (Longer codes are delegated to subtables.) + * + * @param nb_codes number of elements in codes[] + * + * @param codes descriptions of the vlc codes + * These must be ordered such that codes going into the same subtable are contiguous. + * Sorting by VLCcode.code is sufficient, though not necessary. + */ +static int build_table(VLC *vlc, int table_nb_bits, int nb_codes, + VLCcode *codes, int flags) +{ + int table_size, table_index, index, symbol, subtable_bits; + int i, j, k, n, nb, inc; + uint32_t code, code_prefix; + VLC_TYPE (*table)[2]; + + table_size = 1 << table_nb_bits; + table_index = alloc_table(vlc, table_size, flags & INIT_VLC_USE_NEW_STATIC); +#ifdef DEBUG_VLC + av_log(NULL,AV_LOG_DEBUG,"new table index=%d size=%d\n", + table_index, table_size); +#endif + if (table_index < 0) + return -1; + table = &vlc->table[table_index]; + + for (i = 0; i < table_size; i++) { + table[i][1] = 0; //bits + table[i][0] = -1; //codes + } + + /* first pass: map codes and compute auxillary table sizes */ + for (i = 0; i < nb_codes; i++) { + n = codes[i].bits; + code = codes[i].code; + symbol = codes[i].symbol; +#if defined(DEBUG_VLC) && 0 + av_log(NULL,AV_LOG_DEBUG,"i=%d n=%d code=0x%x\n", i, n, code); +#endif + if (n <= table_nb_bits) { + /* no need to add another table */ + j = code >> (32 - table_nb_bits); + nb = 1 << (table_nb_bits - n); + inc = 1; +/* if (flags & INIT_VLC_LE) { + j = bitswap_32(code); + inc = 1 << n; + } */ + for (k = 0; k < nb; k++) { +#ifdef DEBUG_VLC + av_log(NULL, AV_LOG_DEBUG, "%4x: code=%d n=%d\n", + j, i, n); +#endif + if (table[j][1] /*bits*/ != 0) { + av_log(NULL, AV_LOG_ERROR, "incorrect codes\n"); + return -1; + } + table[j][1] = n; //bits + table[j][0] = symbol; + j += inc; + } + } else { + /* fill auxiliary table recursively */ + n -= table_nb_bits; + code_prefix = code >> (32 - table_nb_bits); + subtable_bits = n; + codes[i].bits = n; + codes[i].code = code << table_nb_bits; + for (k = i+1; k < nb_codes; k++) { + n = codes[k].bits - table_nb_bits; + if (n <= 0) + break; + code = codes[k].code; + if (code >> (32 - table_nb_bits) != code_prefix) + break; + codes[k].bits = n; + codes[k].code = code << table_nb_bits; + subtable_bits = FFMAX(subtable_bits, n); + } + subtable_bits = FFMIN(subtable_bits, table_nb_bits); + j = /*(flags & INIT_VLC_LE) ? bitswap_32(code_prefix) >> (32 - table_nb_bits) :*/ code_prefix; + table[j][1] = -subtable_bits; +#ifdef DEBUG_VLC + av_log(NULL,AV_LOG_DEBUG,"%4x: n=%d (subtable)\n", + j, codes[i].bits + table_nb_bits); +#endif + index = build_table(vlc, subtable_bits, k-i, codes+i, flags); + if (index < 0) + return -1; + /* note: realloc has been done, so reload tables */ + table = &vlc->table[table_index]; + table[j][0] = index; //code + i = k-1; + } + } + return table_index; +} + + +/* Build VLC decoding tables suitable for use with get_vlc(). + + 'nb_bits' set thee decoding table size (2^nb_bits) entries. The + bigger it is, the faster is the decoding. But it should not be too + big to save memory and L1 cache. '9' is a good compromise. + + 'nb_codes' : number of vlcs codes + + 'bits' : table which gives the size (in bits) of each vlc code. + + 'codes' : table which gives the bit pattern of of each vlc code. + + 'symbols' : table which gives the values to be returned from get_vlc(). + + 'xxx_wrap' : give the number of bytes between each entry of the + 'bits' or 'codes' tables. + + 'xxx_size' : gives the number of bytes of each entry of the 'bits' + or 'codes' tables. + + 'wrap' and 'size' allows to use any memory configuration and types + (byte/word/long) to store the 'bits', 'codes', and 'symbols' tables. + + 'use_static' should be set to 1 for tables, which should be freed + with av_free_static(), 0 if free_vlc() will be used. +*/ + +/* Rockbox: support for INIT_VLC_LE is currently disabled since none of our + codecs use it, there's a LUT based bit reverse function for this commented + out above (bitswap_32) and an inline asm version in libtremor/codebook.c + if we ever want this */ + +static VLCcode buf[1336+1]; /* worst case is wma, which has one table with 1336 entries */ + +int init_vlc_sparse(VLC *vlc, int nb_bits, int nb_codes, + const void *bits, int bits_wrap, int bits_size, + const void *codes, int codes_wrap, int codes_size, + const void *symbols, int symbols_wrap, int symbols_size, + int flags) +{ + if (nb_codes+1 > (int)(sizeof (buf)/ sizeof (VLCcode))) + { + DEBUGF("Table is larger than temp buffer!\n"); + return -1; + } + + int i, j, ret; + + vlc->bits = nb_bits; + if(flags & INIT_VLC_USE_NEW_STATIC){ + if(vlc->table_size && vlc->table_size == vlc->table_allocated){ + return 0; + }else if(vlc->table_size){ + DEBUGF("fatal error, we are called on a partially initialized table\n"); + return -1; +// abort(); // fatal error, we are called on a partially initialized table + } + }else { + vlc->table = NULL; + vlc->table_allocated = 0; + vlc->table_size = 0; + } + +#ifdef DEBUG_VLC + av_log(NULL,AV_LOG_DEBUG,"build table nb_codes=%d\n", nb_codes); +#endif + +// buf = av_malloc((nb_codes+1)*sizeof(VLCcode)); + +// assert(symbols_size <= 2 || !symbols); + j = 0; +#define COPY(condition)\ + for (i = 0; i < nb_codes; i++) {\ + GET_DATA(buf[j].bits, bits, i, bits_wrap, bits_size);\ + if (!(condition))\ + continue;\ + GET_DATA(buf[j].code, codes, i, codes_wrap, codes_size);\ +/* if (flags & INIT_VLC_LE)*/\ +/* buf[j].code = bitswap_32(buf[j].code);*/\ +/* else*/\ + buf[j].code <<= 32 - buf[j].bits;\ + if (symbols)\ + GET_DATA(buf[j].symbol, symbols, i, symbols_wrap, symbols_size)\ + else\ + buf[j].symbol = i;\ + j++;\ + } + COPY(buf[j].bits > nb_bits); + // qsort is the slowest part of init_vlc, and could probably be improved or avoided + qsort(buf, j, sizeof(VLCcode), compare_vlcspec); + COPY(buf[j].bits && buf[j].bits <= nb_bits); + nb_codes = j; + + ret = build_table(vlc, nb_bits, nb_codes, buf, flags); + +// av_free(buf); + if (ret < 0) { +// av_freep(&vlc->table); + return -1; + } + if((flags & INIT_VLC_USE_NEW_STATIC) && vlc->table_size != vlc->table_allocated) { + av_log(NULL, AV_LOG_ERROR, "needed %d had %d\n", vlc->table_size, vlc->table_allocated); + } + return 0; +} + +/* not used in rockbox +void free_vlc(VLC *vlc) +{ + av_freep(&vlc->table); +} +*/ + diff --git a/lib/rbcodec/codecs/lib/ffmpeg_bswap.h b/lib/rbcodec/codecs/lib/ffmpeg_bswap.h new file mode 100644 index 0000000000..24a2aab7ea --- /dev/null +++ b/lib/rbcodec/codecs/lib/ffmpeg_bswap.h @@ -0,0 +1,150 @@ +/** + * @file bswap.h + * byte swap. + */ + +#ifndef __BSWAP_H__ +#define __BSWAP_H__ + +#ifdef HAVE_BYTESWAP_H +#include +#else + +#ifdef ROCKBOX +#include "codecs.h" + +/* rockbox' optimised inline functions */ +#define bswap_16(x) swap16(x) +#define bswap_32(x) swap32(x) + +static inline uint64_t ByteSwap64(uint64_t x) +{ + union { + uint64_t ll; + struct { + uint32_t l,h; + } l; + } r; + r.l.l = bswap_32 (x); + r.l.h = bswap_32 (x>>32); + return r.ll; +} +#define bswap_64(x) ByteSwap64(x) + +#elif defined(ARCH_X86) +static inline unsigned short ByteSwap16(unsigned short x) +{ + __asm("xchgb %b0,%h0" : + "=q" (x) : + "0" (x)); + return x; +} +#define bswap_16(x) ByteSwap16(x) + +static inline unsigned int ByteSwap32(unsigned int x) +{ +#if __CPU__ > 386 + __asm("bswap %0": + "=r" (x) : +#else + __asm("xchgb %b0,%h0\n" + " rorl $16,%0\n" + " xchgb %b0,%h0": + "=q" (x) : +#endif + "0" (x)); + return x; +} +#define bswap_32(x) ByteSwap32(x) + +static inline unsigned long long int ByteSwap64(unsigned long long int x) +{ + register union { __extension__ uint64_t __ll; + uint32_t __l[2]; } __x; + asm("xchgl %0,%1": + "=r"(__x.__l[0]),"=r"(__x.__l[1]): + "0"(bswap_32((unsigned long)x)),"1"(bswap_32((unsigned long)(x>>32)))); + return __x.__ll; +} +#define bswap_64(x) ByteSwap64(x) + +#elif defined(ARCH_SH4) + +static inline uint16_t ByteSwap16(uint16_t x) { + __asm__("swap.b %0,%0":"=r"(x):"0"(x)); + return x; +} + +static inline uint32_t ByteSwap32(uint32_t x) { + __asm__( + "swap.b %0,%0\n" + "swap.w %0,%0\n" + "swap.b %0,%0\n" + :"=r"(x):"0"(x)); + return x; +} + +#define bswap_16(x) ByteSwap16(x) +#define bswap_32(x) ByteSwap32(x) + +static inline uint64_t ByteSwap64(uint64_t x) +{ + union { + uint64_t ll; + struct { + uint32_t l,h; + } l; + } r; + r.l.l = bswap_32 (x); + r.l.h = bswap_32 (x>>32); + return r.ll; +} +#define bswap_64(x) ByteSwap64(x) + +#else + +#define bswap_16(x) (((x) & 0x00ff) << 8 | ((x) & 0xff00) >> 8) + + +// code from bits/byteswap.h (C) 1997, 1998 Free Software Foundation, Inc. +#define bswap_32(x) \ + ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) | \ + (((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24)) + +static inline uint64_t ByteSwap64(uint64_t x) +{ + union { + uint64_t ll; + uint32_t l[2]; + } w, r; + w.ll = x; + r.l[0] = bswap_32 (w.l[1]); + r.l[1] = bswap_32 (w.l[0]); + return r.ll; +} +#define bswap_64(x) ByteSwap64(x) + +#endif /* !ARCH_X86 */ + +#endif /* !HAVE_BYTESWAP_H */ + +// be2me ... BigEndian to MachineEndian +// le2me ... LittleEndian to MachineEndian + +#ifdef ROCKBOX_BIG_ENDIAN +#define be2me_16(x) (x) +#define be2me_32(x) (x) +#define be2me_64(x) (x) +#define le2me_16(x) bswap_16(x) +#define le2me_32(x) bswap_32(x) +#define le2me_64(x) bswap_64(x) +#else +#define be2me_16(x) bswap_16(x) +#define be2me_32(x) bswap_32(x) +#define be2me_64(x) bswap_64(x) +#define le2me_16(x) (x) +#define le2me_32(x) (x) +#define le2me_64(x) (x) +#endif + +#endif /* __BSWAP_H__ */ diff --git a/lib/rbcodec/codecs/lib/ffmpeg_get_bits.h b/lib/rbcodec/codecs/lib/ffmpeg_get_bits.h new file mode 100644 index 0000000000..04eda021a7 --- /dev/null +++ b/lib/rbcodec/codecs/lib/ffmpeg_get_bits.h @@ -0,0 +1,743 @@ +/* + * copyright (c) 2004 Michael Niedermayer + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * bitstream reader API header. + */ + +#ifndef AVCODEC_GET_BITS_H +#define AVCODEC_GET_BITS_H + +#include +#include +#include "ffmpeg_intreadwrite.h" +//#include +//#include "libavutil/bswap.h" +//#include "libavutil/common.h" +//#include "libavutil/intreadwrite.h" +//#include "libavutil/log.h" +//#include "mathops.h" + +#include "codecs.h" + +/* rockbox' optimised inline functions */ +#define bswap_16(x) swap16(x) +#define bswap_32(x) swap32(x) + +#ifdef ROCKBOX_BIG_ENDIAN +#define be2me_16(x) (x) +#define be2me_32(x) (x) +#define le2me_16(x) bswap_16(x) +#define le2me_32(x) bswap_32(x) +#else +#define be2me_16(x) bswap_16(x) +#define be2me_32(x) bswap_32(x) +#define le2me_16(x) (x) +#define le2me_32(x) (x) +#endif + +#define av_const __attribute__((const)) +#define av_always_inline inline __attribute__((always_inline)) + +/* The following is taken from mathops.h */ + +#ifndef sign_extend +static inline av_const int sign_extend(int val, unsigned bits) +{ + return (val << ((8 * sizeof(int)) - bits)) >> ((8 * sizeof(int)) - bits); +} +#endif + +#ifndef NEG_SSR32 +# define NEG_SSR32(a,s) ((( int32_t)(a))>>(32-(s))) +#endif + +#ifndef NEG_USR32 +# define NEG_USR32(a,s) (((uint32_t)(a))>>(32-(s))) +#endif + +/* these 2 are from libavutil/common.h */ + +#define FFMAX(a,b) ((a) > (b) ? (a) : (b)) +#define FFMIN(a,b) ((a) > (b) ? (b) : (a)) + +#if defined(ALT_BITSTREAM_READER_LE) && !defined(ALT_BITSTREAM_READER) +# define ALT_BITSTREAM_READER +#endif + +/* +#if !defined(LIBMPEG2_BITSTREAM_READER) && !defined(A32_BITSTREAM_READER) && !defined(ALT_BITSTREAM_READER) +# if ARCH_ARM && !HAVE_FAST_UNALIGNED +# define A32_BITSTREAM_READER +# else +*/ +# define ALT_BITSTREAM_READER +/* +//#define LIBMPEG2_BITSTREAM_READER +//#define A32_BITSTREAM_READER +# endif +#endif +*/ + +/* bit input */ +/* buffer, buffer_end and size_in_bits must be present and used by every reader */ +typedef struct GetBitContext { + const uint8_t *buffer, *buffer_end; +#ifdef ALT_BITSTREAM_READER + int index; +#elif defined LIBMPEG2_BITSTREAM_READER + uint8_t *buffer_ptr; + uint32_t cache; + int bit_count; +#elif defined A32_BITSTREAM_READER + uint32_t *buffer_ptr; + uint32_t cache0; + uint32_t cache1; + int bit_count; +#endif + int size_in_bits; +} GetBitContext; + +#define VLC_TYPE int16_t + +typedef struct VLC { + int bits; + VLC_TYPE (*table)[2]; ///< code, bits + int table_size, table_allocated; +} VLC; + +typedef struct RL_VLC_ELEM { + int16_t level; + int8_t len; + uint8_t run; +} RL_VLC_ELEM; + +/* Bitstream reader API docs: +name + arbitrary name which is used as prefix for the internal variables + +gb + getbitcontext + +OPEN_READER(name, gb) + loads gb into local variables + +CLOSE_READER(name, gb) + stores local vars in gb + +UPDATE_CACHE(name, gb) + refills the internal cache from the bitstream + after this call at least MIN_CACHE_BITS will be available, + +GET_CACHE(name, gb) + will output the contents of the internal cache, next bit is MSB of 32 or 64 bit (FIXME 64bit) + +SHOW_UBITS(name, gb, num) + will return the next num bits + +SHOW_SBITS(name, gb, num) + will return the next num bits and do sign extension + +SKIP_BITS(name, gb, num) + will skip over the next num bits + note, this is equivalent to SKIP_CACHE; SKIP_COUNTER + +SKIP_CACHE(name, gb, num) + will remove the next num bits from the cache (note SKIP_COUNTER MUST be called before UPDATE_CACHE / CLOSE_READER) + +SKIP_COUNTER(name, gb, num) + will increment the internal bit counter (see SKIP_CACHE & SKIP_BITS) + +LAST_SKIP_CACHE(name, gb, num) + will remove the next num bits from the cache if it is needed for UPDATE_CACHE otherwise it will do nothing + +LAST_SKIP_BITS(name, gb, num) + is equivalent to LAST_SKIP_CACHE; SKIP_COUNTER + +for examples see get_bits, show_bits, skip_bits, get_vlc +*/ + +#ifdef ALT_BITSTREAM_READER +# define MIN_CACHE_BITS 25 + + +/* ROCKBOX: work around "set but not used" warning */ +# define OPEN_READER(name, gb)\ + unsigned int name##_index= (gb)->index;\ + int name##_cache __attribute__((unused)) = 0;\ + +# define CLOSE_READER(name, gb)\ + (gb)->index= name##_index;\ + +# ifdef ALT_BITSTREAM_READER_LE +# define UPDATE_CACHE(name, gb)\ + name##_cache= AV_RL32( ((const uint8_t *)(gb)->buffer)+(name##_index>>3) ) >> (name##_index&0x07);\ + +# define SKIP_CACHE(name, gb, num)\ + name##_cache >>= (num); +# else +# define UPDATE_CACHE(name, gb)\ + name##_cache= AV_RB32( ((const uint8_t *)(gb)->buffer)+(name##_index>>3) ) << (name##_index&0x07);\ + +# define SKIP_CACHE(name, gb, num)\ + name##_cache <<= (num); +# endif + +// FIXME name? +# define SKIP_COUNTER(name, gb, num)\ + name##_index += (num);\ + +# define SKIP_BITS(name, gb, num)\ + {\ + SKIP_CACHE(name, gb, num)\ + SKIP_COUNTER(name, gb, num)\ + }\ + +# define LAST_SKIP_BITS(name, gb, num) SKIP_COUNTER(name, gb, num) +# define LAST_SKIP_CACHE(name, gb, num) ; + +# ifdef ALT_BITSTREAM_READER_LE +# define SHOW_UBITS(name, gb, num)\ + zero_extend(name##_cache, num) + +# define SHOW_SBITS(name, gb, num)\ + sign_extend(name##_cache, num) +# else +# define SHOW_UBITS(name, gb, num)\ + NEG_USR32(name##_cache, num) + +# define SHOW_SBITS(name, gb, num)\ + NEG_SSR32(name##_cache, num) +# endif + +# define GET_CACHE(name, gb)\ + ((uint32_t)name##_cache) + +static inline int get_bits_count(const GetBitContext *s){ + return s->index; +} + +static inline void skip_bits_long(GetBitContext *s, int n){ + s->index += n; +} + +#elif defined LIBMPEG2_BITSTREAM_READER +//libmpeg2 like reader + +# define MIN_CACHE_BITS 17 + +# define OPEN_READER(name, gb)\ + int name##_bit_count=(gb)->bit_count;\ + int name##_cache= (gb)->cache;\ + uint8_t * name##_buffer_ptr=(gb)->buffer_ptr;\ + +# define CLOSE_READER(name, gb)\ + (gb)->bit_count= name##_bit_count;\ + (gb)->cache= name##_cache;\ + (gb)->buffer_ptr= name##_buffer_ptr;\ + +# define UPDATE_CACHE(name, gb)\ + if(name##_bit_count >= 0){\ + name##_cache+= AV_RB16(name##_buffer_ptr) << name##_bit_count; \ + name##_buffer_ptr+=2;\ + name##_bit_count-= 16;\ + }\ + +# define SKIP_CACHE(name, gb, num)\ + name##_cache <<= (num);\ + +# define SKIP_COUNTER(name, gb, num)\ + name##_bit_count += (num);\ + +# define SKIP_BITS(name, gb, num)\ + {\ + SKIP_CACHE(name, gb, num)\ + SKIP_COUNTER(name, gb, num)\ + }\ + +# define LAST_SKIP_BITS(name, gb, num) SKIP_BITS(name, gb, num) +# define LAST_SKIP_CACHE(name, gb, num) SKIP_CACHE(name, gb, num) + +# define SHOW_UBITS(name, gb, num)\ + NEG_USR32(name##_cache, num) + +# define SHOW_SBITS(name, gb, num)\ + NEG_SSR32(name##_cache, num) + +# define GET_CACHE(name, gb)\ + ((uint32_t)name##_cache) + +static inline int get_bits_count(const GetBitContext *s){ + return (s->buffer_ptr - s->buffer)*8 - 16 + s->bit_count; +} + +static inline void skip_bits_long(GetBitContext *s, int n){ + OPEN_READER(re, s) + re_bit_count += n; + re_buffer_ptr += 2*(re_bit_count>>4); + re_bit_count &= 15; + re_cache = ((re_buffer_ptr[-2]<<8) + re_buffer_ptr[-1]) << (16+re_bit_count); + UPDATE_CACHE(re, s) + CLOSE_READER(re, s) +} + +#elif defined A32_BITSTREAM_READER + +# define MIN_CACHE_BITS 32 + +# define OPEN_READER(name, gb)\ + int name##_bit_count=(gb)->bit_count;\ + uint32_t name##_cache0= (gb)->cache0;\ + uint32_t name##_cache1= (gb)->cache1;\ + uint32_t * name##_buffer_ptr=(gb)->buffer_ptr;\ + +# define CLOSE_READER(name, gb)\ + (gb)->bit_count= name##_bit_count;\ + (gb)->cache0= name##_cache0;\ + (gb)->cache1= name##_cache1;\ + (gb)->buffer_ptr= name##_buffer_ptr;\ + +# define UPDATE_CACHE(name, gb)\ + if(name##_bit_count > 0){\ + const uint32_t next= av_be2ne32( *name##_buffer_ptr );\ + name##_cache0 |= NEG_USR32(next,name##_bit_count);\ + name##_cache1 |= next<buffer_ptr - s->buffer)*8 - 32 + s->bit_count; +} + +static inline void skip_bits_long(GetBitContext *s, int n){ + OPEN_READER(re, s) + re_bit_count += n; + re_buffer_ptr += re_bit_count>>5; + re_bit_count &= 31; + re_cache0 = av_be2ne32( re_buffer_ptr[-1] ) << re_bit_count; + re_cache1 = 0; + UPDATE_CACHE(re, s) + CLOSE_READER(re, s) +} + +#endif + +/** + * read mpeg1 dc style vlc (sign bit + mantisse with no MSB). + * if MSB not set it is negative + * @param n length in bits + * @author BERO + */ +static inline int get_xbits(GetBitContext *s, int n){ + register int sign; + register int32_t cache; + OPEN_READER(re, s) + UPDATE_CACHE(re, s) + cache = GET_CACHE(re,s); + sign=(~cache)>>31; + LAST_SKIP_BITS(re, s, n) + CLOSE_READER(re, s) + return (NEG_USR32(sign ^ cache, n) ^ sign) - sign; +} + +static inline int get_sbits(GetBitContext *s, int n){ + register int tmp; + OPEN_READER(re, s) + UPDATE_CACHE(re, s) + tmp= SHOW_SBITS(re, s, n); + LAST_SKIP_BITS(re, s, n) + CLOSE_READER(re, s) + return tmp; +} + +/** + * reads 1-17 bits. + * Note, the alt bitstream reader can read up to 25 bits, but the libmpeg2 reader can't + */ +static inline unsigned int get_bits(GetBitContext *s, int n){ + register int tmp; + OPEN_READER(re, s) + UPDATE_CACHE(re, s) + tmp= SHOW_UBITS(re, s, n); + LAST_SKIP_BITS(re, s, n) + CLOSE_READER(re, s) + return tmp; +} + +/** + * shows 1-17 bits. + * Note, the alt bitstream reader can read up to 25 bits, but the libmpeg2 reader can't + */ +static inline unsigned int show_bits(GetBitContext *s, int n){ + register int tmp; + OPEN_READER(re, s) + UPDATE_CACHE(re, s) + tmp= SHOW_UBITS(re, s, n); +// CLOSE_READER(re, s) + return tmp; +} + +static inline void skip_bits(GetBitContext *s, int n){ + //Note gcc seems to optimize this to s->index+=n for the ALT_READER :)) + OPEN_READER(re, s) + UPDATE_CACHE(re, s) + LAST_SKIP_BITS(re, s, n) + CLOSE_READER(re, s) +} + +static inline unsigned int get_bits1(GetBitContext *s){ +#ifdef ALT_BITSTREAM_READER + unsigned int index= s->index; + uint8_t result= s->buffer[ index>>3 ]; +#ifdef ALT_BITSTREAM_READER_LE + result>>= (index&0x07); + result&= 1; +#else + result<<= (index&0x07); + result>>= 8 - 1; +#endif + index++; + s->index= index; + + return result; +#else + return get_bits(s, 1); +#endif +} + +static inline unsigned int show_bits1(GetBitContext *s){ + return show_bits(s, 1); +} + +static inline void skip_bits1(GetBitContext *s){ + skip_bits(s, 1); +} + +/** + * reads 0-32 bits. + */ +static inline unsigned int get_bits_long(GetBitContext *s, int n){ + if(n<=MIN_CACHE_BITS) return get_bits(s, n); + else{ +#ifdef ALT_BITSTREAM_READER_LE + int ret= get_bits(s, 16); + return ret | (get_bits(s, n-16) << 16); +#else + int ret= get_bits(s, 16) << (n-16); + return ret | get_bits(s, n-16); +#endif + } +} + +/** + * reads 0-32 bits as a signed integer. + */ +static inline int get_sbits_long(GetBitContext *s, int n) { + return sign_extend(get_bits_long(s, n), n); +} + +/** + * shows 0-32 bits. + */ +static inline unsigned int show_bits_long(GetBitContext *s, int n){ + if(n<=MIN_CACHE_BITS) return show_bits(s, n); + else{ + GetBitContext gb= *s; + return get_bits_long(&gb, n); + } +} + +/* not used +static inline int check_marker(GetBitContext *s, const char *msg) +{ + int bit= get_bits1(s); + if(!bit) + av_log(NULL, AV_LOG_INFO, "Marker bit missing %s\n", msg); + + return bit; +} +*/ + +/** + * init GetBitContext. + * @param buffer bitstream buffer, must be FF_INPUT_BUFFER_PADDING_SIZE bytes larger then the actual read bits + * because some optimized bitstream readers read 32 or 64 bit at once and could read over the end + * @param bit_size the size of the buffer in bits + * + * While GetBitContext stores the buffer size, for performance reasons you are + * responsible for checking for the buffer end yourself (take advantage of the padding)! + */ +static inline void init_get_bits(GetBitContext *s, + const uint8_t *buffer, int bit_size) +{ + int buffer_size= (bit_size+7)>>3; + if(buffer_size < 0 || bit_size < 0) { + buffer_size = bit_size = 0; + buffer = NULL; + } + + s->buffer= buffer; + s->size_in_bits= bit_size; + s->buffer_end= buffer + buffer_size; +#ifdef ALT_BITSTREAM_READER + s->index=0; +#elif defined LIBMPEG2_BITSTREAM_READER + s->buffer_ptr = (uint8_t*)((intptr_t)buffer&(~1)); + s->bit_count = 16 + 8*((intptr_t)buffer&1); + skip_bits_long(s, 0); +#elif defined A32_BITSTREAM_READER + s->buffer_ptr = (uint32_t*)((intptr_t)buffer&(~3)); + s->bit_count = 32 + 8*((intptr_t)buffer&3); + skip_bits_long(s, 0); +#endif +} + +static inline void align_get_bits(GetBitContext *s) +{ + int n= (-get_bits_count(s)) & 7; + if(n) skip_bits(s, n); +} + +#define init_vlc(vlc, nb_bits, nb_codes,\ + bits, bits_wrap, bits_size,\ + codes, codes_wrap, codes_size,\ + flags)\ + init_vlc_sparse(vlc, nb_bits, nb_codes,\ + bits, bits_wrap, bits_size,\ + codes, codes_wrap, codes_size,\ + NULL, 0, 0, flags) + +int init_vlc_sparse(VLC *vlc, int nb_bits, int nb_codes, + const void *bits, int bits_wrap, int bits_size, + const void *codes, int codes_wrap, int codes_size, + const void *symbols, int symbols_wrap, int symbols_size, + int flags); +#define INIT_VLC_LE 2 +#define INIT_VLC_USE_NEW_STATIC 4 +void free_vlc(VLC *vlc); + +#define INIT_VLC_STATIC(vlc, bits, a,b,c,d,e,f,g, static_size, attr)\ +{\ + static VLC_TYPE table[static_size][2] attr;\ + (vlc)->table= table;\ + (vlc)->table_allocated= static_size;\ + init_vlc(vlc, bits, a,b,c,d,e,f,g, INIT_VLC_USE_NEW_STATIC);\ +} + + +/** + * + * If the vlc code is invalid and max_depth=1, then no bits will be removed. + * If the vlc code is invalid and max_depth>1, then the number of bits removed + * is undefined. + */ +#define GET_VLC(code, name, gb, table, bits, max_depth)\ +{\ + int n, nb_bits;\ + unsigned int index;\ +\ + index= SHOW_UBITS(name, gb, bits);\ + code = table[index][0];\ + n = table[index][1];\ +\ + if(max_depth > 1 && n < 0){\ + LAST_SKIP_BITS(name, gb, bits)\ + UPDATE_CACHE(name, gb)\ +\ + nb_bits = -n;\ +\ + index= SHOW_UBITS(name, gb, nb_bits) + code;\ + code = table[index][0];\ + n = table[index][1];\ + if(max_depth > 2 && n < 0){\ + LAST_SKIP_BITS(name, gb, nb_bits)\ + UPDATE_CACHE(name, gb)\ +\ + nb_bits = -n;\ +\ + index= SHOW_UBITS(name, gb, nb_bits) + code;\ + code = table[index][0];\ + n = table[index][1];\ + }\ + }\ + SKIP_BITS(name, gb, n)\ +} + +#define GET_RL_VLC(level, run, name, gb, table, bits, max_depth, need_update)\ +{\ + int n, nb_bits;\ + unsigned int index;\ +\ + index= SHOW_UBITS(name, gb, bits);\ + level = table[index].level;\ + n = table[index].len;\ +\ + if(max_depth > 1 && n < 0){\ + SKIP_BITS(name, gb, bits)\ + if(need_update){\ + UPDATE_CACHE(name, gb)\ + }\ +\ + nb_bits = -n;\ +\ + index= SHOW_UBITS(name, gb, nb_bits) + level;\ + level = table[index].level;\ + n = table[index].len;\ + }\ + run= table[index].run;\ + SKIP_BITS(name, gb, n)\ +} + + +/** + * parses a vlc code, faster then get_vlc() + * @param bits is the number of bits which will be read at once, must be + * identical to nb_bits in init_vlc() + * @param max_depth is the number of times bits bits must be read to completely + * read the longest vlc code + * = (max_vlc_length + bits - 1) / bits + */ +static av_always_inline int get_vlc2(GetBitContext *s, VLC_TYPE (*table)[2], + int bits, int max_depth) +{ + int code; + + OPEN_READER(re, s) + UPDATE_CACHE(re, s) + + GET_VLC(code, re, s, table, bits, max_depth) + + CLOSE_READER(re, s) + return code; +} + +//#define TRACE + +#ifdef TRACE +static inline void print_bin(int bits, int n){ + int i; + + for(i=n-1; i>=0; i--){ + av_log(NULL, AV_LOG_DEBUG, "%d", (bits>>i)&1); + } + for(i=n; i<24; i++) + av_log(NULL, AV_LOG_DEBUG, " "); +} + +static inline int get_bits_trace(GetBitContext *s, int n, char *file, const char *func, int line){ + int r= get_bits(s, n); + + print_bin(r, n); + av_log(NULL, AV_LOG_DEBUG, "%5d %2d %3d bit @%5d in %s %s:%d\n", r, n, r, get_bits_count(s)-n, file, func, line); + return r; +} +static inline int get_vlc_trace(GetBitContext *s, VLC_TYPE (*table)[2], int bits, int max_depth, char *file, const char *func, int line){ + int show= show_bits(s, 24); + int pos= get_bits_count(s); + int r= get_vlc2(s, table, bits, max_depth); + int len= get_bits_count(s) - pos; + int bits2= show>>(24-len); + + print_bin(bits2, len); + + av_log(NULL, AV_LOG_DEBUG, "%5d %2d %3d vlc @%5d in %s %s:%d\n", bits2, len, r, pos, file, func, line); + return r; +} +static inline int get_xbits_trace(GetBitContext *s, int n, char *file, const char *func, int line){ + int show= show_bits(s, n); + int r= get_xbits(s, n); + + print_bin(show, n); + av_log(NULL, AV_LOG_DEBUG, "%5d %2d %3d xbt @%5d in %s %s:%d\n", show, n, r, get_bits_count(s)-n, file, func, line); + return r; +} + +#define get_bits(s, n) get_bits_trace(s, n, __FILE__, __PRETTY_FUNCTION__, __LINE__) +#define get_bits1(s) get_bits_trace(s, 1, __FILE__, __PRETTY_FUNCTION__, __LINE__) +#define get_xbits(s, n) get_xbits_trace(s, n, __FILE__, __PRETTY_FUNCTION__, __LINE__) +#define get_vlc(s, vlc) get_vlc_trace(s, (vlc)->table, (vlc)->bits, 3, __FILE__, __PRETTY_FUNCTION__, __LINE__) +#define get_vlc2(s, tab, bits, max) get_vlc_trace(s, tab, bits, max, __FILE__, __PRETTY_FUNCTION__, __LINE__) + +#define tprintf(p, ...) av_log(p, AV_LOG_DEBUG, __VA_ARGS__) + +#else //TRACE +#define tprintf(p, ...) {} +#endif + +static inline int decode012(GetBitContext *gb){ + int n; + n = get_bits1(gb); + if (n == 0) + return 0; + else + return get_bits1(gb) + 1; +} + +static inline int decode210(GetBitContext *gb){ + if (get_bits1(gb)) + return 0; + else + return 2 - get_bits1(gb); +} + +static inline int get_bits_left(GetBitContext *gb) +{ + return gb->size_in_bits - get_bits_count(gb); +} + +#endif /* AVCODEC_GET_BITS_H */ diff --git a/lib/rbcodec/codecs/lib/ffmpeg_intreadwrite.h b/lib/rbcodec/codecs/lib/ffmpeg_intreadwrite.h new file mode 100644 index 0000000000..24f03292e8 --- /dev/null +++ b/lib/rbcodec/codecs/lib/ffmpeg_intreadwrite.h @@ -0,0 +1,484 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_INTREADWRITE_H +#define AVUTIL_INTREADWRITE_H + +#include +/* + * Arch-specific headers can provide any combination of + * AV_[RW][BLN](16|24|32|64) and AV_(COPY|SWAP|ZERO)(64|128) macros. + * Preprocessor symbols must be defined, even if these are implemented + * as inline functions. + */ + +/* + * Map AV_RNXX <-> AV_R[BL]XX for all variants provided by per-arch headers. + */ +#define HAVE_BIGENDIAN 0 +#if HAVE_BIGENDIAN + +# if defined(AV_RN16) && !defined(AV_RB16) +# define AV_RB16(p) AV_RN16(p) +# elif !defined(AV_RN16) && defined(AV_RB16) +# define AV_RN16(p) AV_RB16(p) +# endif + +# if defined(AV_WN16) && !defined(AV_WB16) +# define AV_WB16(p, v) AV_WN16(p, v) +# elif !defined(AV_WN16) && defined(AV_WB16) +# define AV_WN16(p, v) AV_WB16(p, v) +# endif + +# if defined(AV_RN24) && !defined(AV_RB24) +# define AV_RB24(p) AV_RN24(p) +# elif !defined(AV_RN24) && defined(AV_RB24) +# define AV_RN24(p) AV_RB24(p) +# endif + +# if defined(AV_WN24) && !defined(AV_WB24) +# define AV_WB24(p, v) AV_WN24(p, v) +# elif !defined(AV_WN24) && defined(AV_WB24) +# define AV_WN24(p, v) AV_WB24(p, v) +# endif + +# if defined(AV_RN32) && !defined(AV_RB32) +# define AV_RB32(p) AV_RN32(p) +# elif !defined(AV_RN32) && defined(AV_RB32) +# define AV_RN32(p) AV_RB32(p) +# endif + +# if defined(AV_WN32) && !defined(AV_WB32) +# define AV_WB32(p, v) AV_WN32(p, v) +# elif !defined(AV_WN32) && defined(AV_WB32) +# define AV_WN32(p, v) AV_WB32(p, v) +# endif + +# if defined(AV_RN64) && !defined(AV_RB64) +# define AV_RB64(p) AV_RN64(p) +# elif !defined(AV_RN64) && defined(AV_RB64) +# define AV_RN64(p) AV_RB64(p) +# endif + +# if defined(AV_WN64) && !defined(AV_WB64) +# define AV_WB64(p, v) AV_WN64(p, v) +# elif !defined(AV_WN64) && defined(AV_WB64) +# define AV_WN64(p, v) AV_WB64(p, v) +# endif + +#else /* HAVE_BIGENDIAN */ + +# if defined(AV_RN16) && !defined(AV_RL16) +# define AV_RL16(p) AV_RN16(p) +# elif !defined(AV_RN16) && defined(AV_RL16) +# define AV_RN16(p) AV_RL16(p) +# endif + +# if defined(AV_WN16) && !defined(AV_WL16) +# define AV_WL16(p, v) AV_WN16(p, v) +# elif !defined(AV_WN16) && defined(AV_WL16) +# define AV_WN16(p, v) AV_WL16(p, v) +# endif + +# if defined(AV_RN24) && !defined(AV_RL24) +# define AV_RL24(p) AV_RN24(p) +# elif !defined(AV_RN24) && defined(AV_RL24) +# define AV_RN24(p) AV_RL24(p) +# endif + +# if defined(AV_WN24) && !defined(AV_WL24) +# define AV_WL24(p, v) AV_WN24(p, v) +# elif !defined(AV_WN24) && defined(AV_WL24) +# define AV_WN24(p, v) AV_WL24(p, v) +# endif + +# if defined(AV_RN32) && !defined(AV_RL32) +# define AV_RL32(p) AV_RN32(p) +# elif !defined(AV_RN32) && defined(AV_RL32) +# define AV_RN32(p) AV_RL32(p) +# endif + +# if defined(AV_WN32) && !defined(AV_WL32) +# define AV_WL32(p, v) AV_WN32(p, v) +# elif !defined(AV_WN32) && defined(AV_WL32) +# define AV_WN32(p, v) AV_WL32(p, v) +# endif + +# if defined(AV_RN64) && !defined(AV_RL64) +# define AV_RL64(p) AV_RN64(p) +# elif !defined(AV_RN64) && defined(AV_RL64) +# define AV_RN64(p) AV_RL64(p) +# endif + +# if defined(AV_WN64) && !defined(AV_WL64) +# define AV_WL64(p, v) AV_WN64(p, v) +# elif !defined(AV_WN64) && defined(AV_WL64) +# define AV_WN64(p, v) AV_WL64(p, v) +# endif + +#endif /* !HAVE_BIGENDIAN */ + +#define HAVE_ATTRIBUTE_PACKED 0 +#define HAVE_FAST_UNALIGNED 0 +/* + * Define AV_[RW]N helper macros to simplify definitions not provided + * by per-arch headers. + */ + +#if HAVE_ATTRIBUTE_PACKED + +union unaligned_64 { uint64_t l; } __attribute__((packed)) av_alias; +union unaligned_32 { uint32_t l; } __attribute__((packed)) av_alias; +union unaligned_16 { uint16_t l; } __attribute__((packed)) av_alias; + +# define AV_RN(s, p) (((const union unaligned_##s *) (p))->l) +# define AV_WN(s, p, v) ((((union unaligned_##s *) (p))->l) = (v)) + +#elif defined(__DECC) + +# define AV_RN(s, p) (*((const __unaligned uint##s##_t*)(p))) +# define AV_WN(s, p, v) (*((__unaligned uint##s##_t*)(p)) = (v)) + +#elif HAVE_FAST_UNALIGNED + +# define AV_RN(s, p) (((const av_alias##s*)(p))->u##s) +# define AV_WN(s, p, v) (((av_alias##s*)(p))->u##s = (v)) + +#else + +#ifndef AV_RB16 +# define AV_RB16(x) \ + ((((const uint8_t*)(x))[0] << 8) | \ + ((const uint8_t*)(x))[1]) +#endif +#ifndef AV_WB16 +# define AV_WB16(p, d) do { \ + ((uint8_t*)(p))[1] = (d); \ + ((uint8_t*)(p))[0] = (d)>>8; \ + } while(0) +#endif + +#ifndef AV_RL16 +# define AV_RL16(x) \ + ((((const uint8_t*)(x))[1] << 8) | \ + ((const uint8_t*)(x))[0]) +#endif +#ifndef AV_WL16 +# define AV_WL16(p, d) do { \ + ((uint8_t*)(p))[0] = (d); \ + ((uint8_t*)(p))[1] = (d)>>8; \ + } while(0) +#endif + +#ifndef AV_RB32 +/* Coldfire and ARMv6 and above support unaligned long reads */ +#if defined CPU_COLDFIRE || (defined CPU_ARM && ARM_ARCH >= 6) +#define AV_RB32(x) (htobe32(*(const uint32_t*)(x))) +#else +# define AV_RB32(x) \ + ((((const uint8_t*)(x))[0] << 24) | \ + (((const uint8_t*)(x))[1] << 16) | \ + (((const uint8_t*)(x))[2] << 8) | \ + ((const uint8_t*)(x))[3]) +#endif +#endif +#ifndef AV_WB32 +# define AV_WB32(p, d) do { \ + ((uint8_t*)(p))[3] = (d); \ + ((uint8_t*)(p))[2] = (d)>>8; \ + ((uint8_t*)(p))[1] = (d)>>16; \ + ((uint8_t*)(p))[0] = (d)>>24; \ + } while(0) +#endif + +#ifndef AV_RL32 +# define AV_RL32(x) \ + ((((const uint8_t*)(x))[3] << 24) | \ + (((const uint8_t*)(x))[2] << 16) | \ + (((const uint8_t*)(x))[1] << 8) | \ + ((const uint8_t*)(x))[0]) +#endif +#ifndef AV_WL32 +# define AV_WL32(p, d) do { \ + ((uint8_t*)(p))[0] = (d); \ + ((uint8_t*)(p))[1] = (d)>>8; \ + ((uint8_t*)(p))[2] = (d)>>16; \ + ((uint8_t*)(p))[3] = (d)>>24; \ + } while(0) +#endif + +#ifndef AV_RB64 +# define AV_RB64(x) \ + (((uint64_t)((const uint8_t*)(x))[0] << 56) | \ + ((uint64_t)((const uint8_t*)(x))[1] << 48) | \ + ((uint64_t)((const uint8_t*)(x))[2] << 40) | \ + ((uint64_t)((const uint8_t*)(x))[3] << 32) | \ + ((uint64_t)((const uint8_t*)(x))[4] << 24) | \ + ((uint64_t)((const uint8_t*)(x))[5] << 16) | \ + ((uint64_t)((const uint8_t*)(x))[6] << 8) | \ + (uint64_t)((const uint8_t*)(x))[7]) +#endif +#ifndef AV_WB64 +# define AV_WB64(p, d) do { \ + ((uint8_t*)(p))[7] = (d); \ + ((uint8_t*)(p))[6] = (d)>>8; \ + ((uint8_t*)(p))[5] = (d)>>16; \ + ((uint8_t*)(p))[4] = (d)>>24; \ + ((uint8_t*)(p))[3] = (d)>>32; \ + ((uint8_t*)(p))[2] = (d)>>40; \ + ((uint8_t*)(p))[1] = (d)>>48; \ + ((uint8_t*)(p))[0] = (d)>>56; \ + } while(0) +#endif + +#ifndef AV_RL64 +# define AV_RL64(x) \ + (((uint64_t)((const uint8_t*)(x))[7] << 56) | \ + ((uint64_t)((const uint8_t*)(x))[6] << 48) | \ + ((uint64_t)((const uint8_t*)(x))[5] << 40) | \ + ((uint64_t)((const uint8_t*)(x))[4] << 32) | \ + ((uint64_t)((const uint8_t*)(x))[3] << 24) | \ + ((uint64_t)((const uint8_t*)(x))[2] << 16) | \ + ((uint64_t)((const uint8_t*)(x))[1] << 8) | \ + (uint64_t)((const uint8_t*)(x))[0]) +#endif +#ifndef AV_WL64 +# define AV_WL64(p, d) do { \ + ((uint8_t*)(p))[0] = (d); \ + ((uint8_t*)(p))[1] = (d)>>8; \ + ((uint8_t*)(p))[2] = (d)>>16; \ + ((uint8_t*)(p))[3] = (d)>>24; \ + ((uint8_t*)(p))[4] = (d)>>32; \ + ((uint8_t*)(p))[5] = (d)>>40; \ + ((uint8_t*)(p))[6] = (d)>>48; \ + ((uint8_t*)(p))[7] = (d)>>56; \ + } while(0) +#endif + +#if HAVE_BIGENDIAN +# define AV_RN(s, p) AV_RB##s(p) +# define AV_WN(s, p, v) AV_WB##s(p, v) +#else +# define AV_RN(s, p) AV_RL##s(p) +# define AV_WN(s, p, v) AV_WL##s(p, v) +#endif + +#endif /* HAVE_FAST_UNALIGNED */ + +#ifndef AV_RN16 +# define AV_RN16(p) AV_RN(16, p) +#endif + +#ifndef AV_RN32 +# define AV_RN32(p) AV_RN(32, p) +#endif + +#ifndef AV_RN64 +# define AV_RN64(p) AV_RN(64, p) +#endif + +#ifndef AV_WN16 +# define AV_WN16(p, v) AV_WN(16, p, v) +#endif + +#ifndef AV_WN32 +# define AV_WN32(p, v) AV_WN(32, p, v) +#endif + +#ifndef AV_WN64 +# define AV_WN64(p, v) AV_WN(64, p, v) +#endif + +#if HAVE_BIGENDIAN +# define AV_RB(s, p) AV_RN##s(p) +# define AV_WB(s, p, v) AV_WN##s(p, v) +# define AV_RL(s, p) bswap_##s(AV_RN##s(p)) +# define AV_WL(s, p, v) AV_WN##s(p, bswap_##s(v)) +#else +# define AV_RB(s, p) bswap_##s(AV_RN##s(p)) +# define AV_WB(s, p, v) AV_WN##s(p, bswap_##s(v)) +# define AV_RL(s, p) AV_RN##s(p) +# define AV_WL(s, p, v) AV_WN##s(p, v) +#endif + +#define AV_RB8(x) (((const uint8_t*)(x))[0]) +#define AV_WB8(p, d) do { ((uint8_t*)(p))[0] = (d); } while(0) + +#define AV_RL8(x) AV_RB8(x) +#define AV_WL8(p, d) AV_WB8(p, d) + +#ifndef AV_RB16 +# define AV_RB16(p) AV_RB(16, p) +#endif +#ifndef AV_WB16 +# define AV_WB16(p, v) AV_WB(16, p, v) +#endif + +#ifndef AV_RL16 +# define AV_RL16(p) AV_RL(16, p) +#endif +#ifndef AV_WL16 +# define AV_WL16(p, v) AV_WL(16, p, v) +#endif + +#ifndef AV_RB32 +# define AV_RB32(p) AV_RB(32, p) +#endif +#ifndef AV_WB32 +# define AV_WB32(p, v) AV_WB(32, p, v) +#endif + +#ifndef AV_RL32 +# define AV_RL32(p) AV_RL(32, p) +#endif +#ifndef AV_WL32 +# define AV_WL32(p, v) AV_WL(32, p, v) +#endif + +#ifndef AV_RB64 +# define AV_RB64(p) AV_RB(64, p) +#endif +#ifndef AV_WB64 +# define AV_WB64(p, v) AV_WB(64, p, v) +#endif + +#ifndef AV_RL64 +# define AV_RL64(p) AV_RL(64, p) +#endif +#ifndef AV_WL64 +# define AV_WL64(p, v) AV_WL(64, p, v) +#endif + +#ifndef AV_RB24 +# define AV_RB24(x) \ + ((((const uint8_t*)(x))[0] << 16) | \ + (((const uint8_t*)(x))[1] << 8) | \ + ((const uint8_t*)(x))[2]) +#endif +#ifndef AV_WB24 +# define AV_WB24(p, d) do { \ + ((uint8_t*)(p))[2] = (d); \ + ((uint8_t*)(p))[1] = (d)>>8; \ + ((uint8_t*)(p))[0] = (d)>>16; \ + } while(0) +#endif + +#ifndef AV_RL24 +# define AV_RL24(x) \ + ((((const uint8_t*)(x))[2] << 16) | \ + (((const uint8_t*)(x))[1] << 8) | \ + ((const uint8_t*)(x))[0]) +#endif +#ifndef AV_WL24 +# define AV_WL24(p, d) do { \ + ((uint8_t*)(p))[0] = (d); \ + ((uint8_t*)(p))[1] = (d)>>8; \ + ((uint8_t*)(p))[2] = (d)>>16; \ + } while(0) +#endif + +/* + * The AV_[RW]NA macros access naturally aligned data + * in a type-safe way. + */ + +#define AV_RNA(s, p) (((const av_alias##s*)(p))->u##s) +#define AV_WNA(s, p, v) (((av_alias##s*)(p))->u##s = (v)) + +#ifndef AV_RN16A +# define AV_RN16A(p) AV_RNA(16, p) +#endif + +#ifndef AV_RN32A +# define AV_RN32A(p) AV_RNA(32, p) +#endif + +#ifndef AV_RN64A +# define AV_RN64A(p) AV_RNA(64, p) +#endif + +#ifndef AV_WN16A +# define AV_WN16A(p, v) AV_WNA(16, p, v) +#endif + +#ifndef AV_WN32A +# define AV_WN32A(p, v) AV_WNA(32, p, v) +#endif + +#ifndef AV_WN64A +# define AV_WN64A(p, v) AV_WNA(64, p, v) +#endif + +/* Parameters for AV_COPY*, AV_SWAP*, AV_ZERO* must be + * naturally aligned. They may be implemented using MMX, + * so emms_c() must be called before using any float code + * afterwards. + */ + +#define AV_COPY(n, d, s) \ + (((av_alias##n*)(d))->u##n = ((const av_alias##n*)(s))->u##n) + +#ifndef AV_COPY16 +# define AV_COPY16(d, s) AV_COPY(16, d, s) +#endif + +#ifndef AV_COPY32 +# define AV_COPY32(d, s) AV_COPY(32, d, s) +#endif + +#ifndef AV_COPY64 +# define AV_COPY64(d, s) AV_COPY(64, d, s) +#endif + +#ifndef AV_COPY128 +# define AV_COPY128(d, s) \ + do { \ + AV_COPY64(d, s); \ + AV_COPY64((char*)(d)+8, (char*)(s)+8); \ + } while(0) +#endif + +#define AV_SWAP(n, a, b) FFSWAP(av_alias##n, *(av_alias##n*)(a), *(av_alias##n*)(b)) + +#ifndef AV_SWAP64 +# define AV_SWAP64(a, b) AV_SWAP(64, a, b) +#endif + +#define AV_ZERO(n, d) (((av_alias##n*)(d))->u##n = 0) + +#ifndef AV_ZERO16 +# define AV_ZERO16(d) AV_ZERO(16, d) +#endif + +#ifndef AV_ZERO32 +# define AV_ZERO32(d) AV_ZERO(32, d) +#endif + +#ifndef AV_ZERO64 +# define AV_ZERO64(d) AV_ZERO(64, d) +#endif + +#ifndef AV_ZERO128 +# define AV_ZERO128(d) \ + do { \ + AV_ZERO64(d); \ + AV_ZERO64((char*)(d)+8); \ + } while(0) +#endif + +#endif /* AVUTIL_INTREADWRITE_H */ diff --git a/lib/rbcodec/codecs/lib/ffmpeg_put_bits.h b/lib/rbcodec/codecs/lib/ffmpeg_put_bits.h new file mode 100644 index 0000000000..38db55fe18 --- /dev/null +++ b/lib/rbcodec/codecs/lib/ffmpeg_put_bits.h @@ -0,0 +1,323 @@ +/* + * copyright (c) 2004 Michael Niedermayer + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file libavcodec/put_bits.h + * bitstream writer API + */ + +#ifndef AVCODEC_PUT_BITS_H +#define AVCODEC_PUT_BITS_H + +#include +#include +#include "ffmpeg_bswap.h" +#include "ffmpeg_intreadwrite.h" + +#define av_log(...) +#define HAVE_FAST_UNALIGNED 0 + +/* buf and buf_end must be present and used by every alternative writer. */ +typedef struct PutBitContext { +#ifdef ALT_BITSTREAM_WRITER + uint8_t *buf, *buf_end; + int index; +#else + uint32_t bit_buf; + int bit_left; + uint8_t *buf, *buf_ptr, *buf_end; +#endif + int size_in_bits; +} PutBitContext; + +/** + * Initializes the PutBitContext s. + * + * @param buffer the buffer where to put bits + * @param buffer_size the size in bytes of buffer + */ +static inline void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size) +{ + if(buffer_size < 0) { + buffer_size = 0; + buffer = NULL; + } + + s->size_in_bits= 8*buffer_size; + s->buf = buffer; + s->buf_end = s->buf + buffer_size; +#ifdef ALT_BITSTREAM_WRITER + s->index=0; + ((uint32_t*)(s->buf))[0]=0; +// memset(buffer, 0, buffer_size); +#else + s->buf_ptr = s->buf; + s->bit_left=32; + s->bit_buf=0; +#endif +} + +/** + * Returns the total number of bits written to the bitstream. + */ +static inline int put_bits_count(PutBitContext *s) +{ +#ifdef ALT_BITSTREAM_WRITER + return s->index; +#else + return (s->buf_ptr - s->buf) * 8 + 32 - s->bit_left; +#endif +} + +/** + * Pads the end of the output stream with zeros. + */ +static inline void flush_put_bits(PutBitContext *s) +{ +#ifdef ALT_BITSTREAM_WRITER + align_put_bits(s); +#else +#ifndef BITSTREAM_WRITER_LE + s->bit_buf<<= s->bit_left; +#endif + while (s->bit_left < 32) { + /* XXX: should test end of buffer */ +#ifdef BITSTREAM_WRITER_LE + *s->buf_ptr++=s->bit_buf; + s->bit_buf>>=8; +#else + *s->buf_ptr++=s->bit_buf >> 24; + s->bit_buf<<=8; +#endif + s->bit_left+=8; + } + s->bit_left=32; + s->bit_buf=0; +#endif +} + +#if defined(ALT_BITSTREAM_WRITER) || defined(BITSTREAM_WRITER_LE) +#define align_put_bits align_put_bits_unsupported_here +#define ff_put_string ff_put_string_unsupported_here +#define ff_copy_bits ff_copy_bits_unsupported_here +#else +/** + * Pads the bitstream with zeros up to the next byte boundary. + */ +void align_put_bits(PutBitContext *s); + +/** + * Puts the string string in the bitstream. + * + * @param terminate_string 0-terminates the written string if value is 1 + */ +void ff_put_string(PutBitContext *pb, const char *string, int terminate_string); + +/** + * Copies the content of src to the bitstream. + * + * @param length the number of bits of src to copy + */ +void ff_copy_bits(PutBitContext *pb, const uint8_t *src, int length); +#endif + +/** + * Writes up to 31 bits into a bitstream. + * Use put_bits32 to write 32 bits. + */ +static inline void put_bits(PutBitContext *s, int n, unsigned int value) +#ifndef ALT_BITSTREAM_WRITER +{ + unsigned int bit_buf; + int bit_left; + + // printf("put_bits=%d %x\n", n, value); + //assert(n <= 31 && value < (1U << n)); + + bit_buf = s->bit_buf; + bit_left = s->bit_left; + + // printf("n=%d value=%x cnt=%d buf=%x\n", n, value, bit_cnt, bit_buf); + /* XXX: optimize */ +#ifdef BITSTREAM_WRITER_LE + bit_buf |= value << (32 - bit_left); + if (n >= bit_left) { +#if !HAVE_FAST_UNALIGNED + if (3 & (intptr_t) s->buf_ptr) { + AV_WL32(s->buf_ptr, bit_buf); + } else +#endif + *(uint32_t *)s->buf_ptr = le2me_32(bit_buf); + s->buf_ptr+=4; + bit_buf = (bit_left==32)?0:value >> bit_left; + bit_left+=32; + } + bit_left-=n; +#else + if (n < bit_left) { + bit_buf = (bit_buf<> (n - bit_left); +#if !HAVE_FAST_UNALIGNED + if (3 & (intptr_t) s->buf_ptr) { + AV_WB32(s->buf_ptr, bit_buf); + } else +#endif + *(uint32_t *)s->buf_ptr = be2me_32(bit_buf); + //printf("bitbuf = %08x\n", bit_buf); + s->buf_ptr+=4; + bit_left+=32 - n; + bit_buf = value; + } +#endif + + s->bit_buf = bit_buf; + s->bit_left = bit_left; +} +#else /* ALT_BITSTREAM_WRITER defined */ +{ +# ifdef ALIGNED_BITSTREAM_WRITER +# if ARCH_X86 + __asm__ volatile( + "movl %0, %%ecx \n\t" + "xorl %%eax, %%eax \n\t" + "shrdl %%cl, %1, %%eax \n\t" + "shrl %%cl, %1 \n\t" + "movl %0, %%ecx \n\t" + "shrl $3, %%ecx \n\t" + "andl $0xFFFFFFFC, %%ecx \n\t" + "bswapl %1 \n\t" + "orl %1, (%2, %%ecx) \n\t" + "bswapl %%eax \n\t" + "addl %3, %0 \n\t" + "movl %%eax, 4(%2, %%ecx) \n\t" + : "=&r" (s->index), "=&r" (value) + : "r" (s->buf), "r" (n), "0" (s->index), "1" (value<<(-n)) + : "%eax", "%ecx" + ); +# else + int index= s->index; + uint32_t *ptr= ((uint32_t *)s->buf)+(index>>5); + + value<<= 32-n; + + ptr[0] |= be2me_32(value>>(index&31)); + ptr[1] = be2me_32(value<<(32-(index&31))); +//if(n>24) printf("%d %d\n", n, value); + index+= n; + s->index= index; +# endif +# else //ALIGNED_BITSTREAM_WRITER +# if ARCH_X86 + __asm__ volatile( + "movl $7, %%ecx \n\t" + "andl %0, %%ecx \n\t" + "addl %3, %%ecx \n\t" + "negl %%ecx \n\t" + "shll %%cl, %1 \n\t" + "bswapl %1 \n\t" + "movl %0, %%ecx \n\t" + "shrl $3, %%ecx \n\t" + "orl %1, (%%ecx, %2) \n\t" + "addl %3, %0 \n\t" + "movl $0, 4(%%ecx, %2) \n\t" + : "=&r" (s->index), "=&r" (value) + : "r" (s->buf), "r" (n), "0" (s->index), "1" (value) + : "%ecx" + ); +# else + int index= s->index; + uint32_t *ptr= (uint32_t*)(((uint8_t *)s->buf)+(index>>3)); + + ptr[0] |= be2me_32(value<<(32-n-(index&7) )); + ptr[1] = 0; +//if(n>24) printf("%d %d\n", n, value); + index+= n; + s->index= index; +# endif +# endif //!ALIGNED_BITSTREAM_WRITER +} +#endif + +static inline void put_sbits(PutBitContext *pb, int n, int32_t value) +{ + //assert(n >= 0 && n <= 31); + + put_bits(pb, n, value & ((1<buf + (s->index>>3); +#else + return s->buf_ptr; +#endif +} + +/** + * Skips the given number of bytes. + * PutBitContext must be flushed & aligned to a byte boundary before calling this. + */ +static inline void skip_put_bytes(PutBitContext *s, int n) +{ + //assert((put_bits_count(s)&7)==0); +#ifdef ALT_BITSTREAM_WRITER + FIXME may need some cleaning of the buffer + s->index += n<<3; +#else + //assert(s->bit_left==32); + s->buf_ptr += n; +#endif +} + +/** + * Skips the given number of bits. + * Must only be used if the actual values in the bitstream do not matter. + * If n is 0 the behavior is undefined. + */ +static inline void skip_put_bits(PutBitContext *s, int n) +{ +#ifdef ALT_BITSTREAM_WRITER + s->index += n; +#else + s->bit_left -= n; + s->buf_ptr-= 4*(s->bit_left>>5); + s->bit_left &= 31; +#endif +} + +/** + * Changes the end of the buffer. + * + * @param size the new size in bytes of the buffer where to put bits + */ +static inline void set_put_bits_buffer_size(PutBitContext *s, int size) +{ + s->buf_end= s->buf + size; +} + +#endif /* AVCODEC_PUT_BITS_H */ diff --git a/lib/rbcodec/codecs/lib/fft-ffmpeg.c b/lib/rbcodec/codecs/lib/fft-ffmpeg.c new file mode 100644 index 0000000000..807f606038 --- /dev/null +++ b/lib/rbcodec/codecs/lib/fft-ffmpeg.c @@ -0,0 +1,473 @@ +/* + * FFT/IFFT transforms converted to integer precision + * Copyright (c) 2010 Dave Hooper, Mohamed Tarek, Michael Giacomelli + * Copyright (c) 2008 Loren Merritt + * Copyright (c) 2002 Fabrice Bellard + * Partly based on libdjbfft by D. J. Bernstein + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file libavcodec/fft.c + * FFT/IFFT transforms. + */ + + +#ifdef CPU_ARM +// we definitely want CONFIG_SMALL undefined for ipod +// so we get the inlined version of fft16 (which is measurably faster) +#undef CONFIG_SMALL +#else +#undef CONFIG_SMALL +#endif + +#include "fft.h" +#include +#include +#include +#include +#include +#include + +#include "codeclib_misc.h" +#include "mdct_lookup.h" + +/* constants for fft_16 (same constants as in mdct_arm.S ... ) */ +#define cPI1_8 (0x7641af3d) /* cos(pi/8) s.31 */ +#define cPI2_8 (0x5a82799a) /* cos(2pi/8) = 1/sqrt(2) s.31 */ +#define cPI3_8 (0x30fbc54d) /* cos(3pi/8) s.31 */ + +/* asm-optimised functions and/or macros */ +#include "fft-ffmpeg_arm.h" +#include "fft-ffmpeg_cf.h" + +#ifndef ICODE_ATTR_TREMOR_MDCT +#define ICODE_ATTR_TREMOR_MDCT ICODE_ATTR +#endif + +#if 0 +static int split_radix_permutation(int i, int n, int inverse) +{ + int m; + if(n <= 2) return i&1; + m = n >> 1; + if(!(i&m)) return split_radix_permutation(i, m, inverse)*2; + m >>= 1; + if(inverse == !(i&m)) return split_radix_permutation(i, m, inverse)*4 + 1; + else return split_radix_permutation(i, m, inverse)*4 - 1; +} + +static void ff_fft_permute_c(FFTContext *s, FFTComplex *z) +{ + int j, k, np; + FFTComplex tmp; + //const uint16_t *revtab = s->revtab; + np = 1 << s->nbits; + + const int revtab_shift = (12 - s->nbits); + + /* reverse */ + for(j=0;j>revtab_shift; + if (k < j) { + tmp = z[k]; + z[k] = z[j]; + z[j] = tmp; + } + } +} +#endif + +#define BF(x,y,a,b) {\ + x = a - b;\ + y = a + b;\ +} + +#define BF_REV(x,y,a,b) {\ + x = a + b;\ + y = a - b;\ +} + +#ifndef FFT_FFMPEG_INCL_OPTIMISED_BUTTERFLIES +#define BUTTERFLIES(a0,a1,a2,a3) {\ + {\ + FFTSample temp1,temp2;\ + BF(temp1, temp2, t5, t1);\ + BF(a2.re, a0.re, a0.re, temp2);\ + BF(a3.im, a1.im, a1.im, temp1);\ + }\ + {\ + FFTSample temp1,temp2;\ + BF(temp1, temp2, t2, t6);\ + BF(a3.re, a1.re, a1.re, temp1);\ + BF(a2.im, a0.im, a0.im, temp2);\ + }\ +} + +// force loading all the inputs before storing any. +// this is slightly slower for small data, but avoids store->load aliasing +// for addresses separated by large powers of 2. +#define BUTTERFLIES_BIG(a0,a1,a2,a3) {\ + FFTSample r0=a0.re, i0=a0.im, r1=a1.re, i1=a1.im;\ + {\ + FFTSample temp1, temp2;\ + BF(temp1, temp2, t5, t1);\ + BF(a2.re, a0.re, r0, temp2);\ + BF(a3.im, a1.im, i1, temp1);\ + }\ + {\ + FFTSample temp1, temp2;\ + BF(temp1, temp2, t2, t6);\ + BF(a3.re, a1.re, r1, temp1);\ + BF(a2.im, a0.im, i0, temp2);\ + }\ +} +#endif + +/* + see conjugate pair description in + http://www.fftw.org/newsplit.pdf + + a0 = z[k] + a1 = z[k+N/4] + a2 = z[k+2N/4] + a3 = z[k+3N/4] + + result: + y[k] = z[k]+w(z[k+2N/4])+w'(z[k+3N/4]) + y[k+N/4] = z[k+N/4]-iw(z[k+2N/4])+iw'(z[k+3N/4]) + y[k+2N/4] = z[k]-w(z[k+2N/4])-w'(z[k+3N/4]) + y[k+3N/4] = z[k+N/4]+iw(z[k+2N/4])-iw'(z[k+3N/4]) + + i.e. + + a0 = a0 + (w.a2 + w'.a3) + a1 = a1 - i(w.a2 - w'.a3) + a2 = a0 - (w.a2 + w'.a3) + a3 = a1 + i(w.a2 - w'.a3) + + note re(w') = re(w) and im(w') = -im(w) + + so therefore + + re(a0) = re(a0) + re(w.a2) + re(w.a3) + im(a0) = im(a0) + im(w.a2) - im(w.a3) etc + + and remember also that + Re([s+it][u+iv]) = su-tv + Im([s+it][u+iv]) = sv+tu + + so + Re(w'.(s+it)) = Re(w').s - Im(w').t = Re(w).s + Im(w).t + Im(w'.(s+it)) = Re(w').t + Im(w').s = Re(w).t - Im(w).s + + For inverse dft we take the complex conjugate of all twiddle factors. + Hence + + a0 = a0 + (w'.a2 + w.a3) + a1 = a1 - i(w'.a2 - w.a3) + a2 = a0 - (w'.a2 + w.a3) + a3 = a1 + i(w'.a2 - w.a3) + + Define t1 = Re(w'.a2) = Re(w)*Re(a2) + Im(w)*Im(a2) + t2 = Im(w'.a2) = Re(w)*Im(a2) - Im(w)*Re(a2) + t5 = Re(w.a3) = Re(w)*Re(a3) - Im(w)*Im(a3) + t6 = Im(w.a3) = Re(w)*Im(a3) + Im(w)*Re(a3) + + Then we just output: + a0.re = a0.re + ( t1 + t5 ) + a0.im = a0.im + ( t2 + t6 ) + a1.re = a1.re + ( t2 - t6 ) // since we multiply by -i and i(-i) = 1 + a1.im = a1.im - ( t1 - t5 ) // since we multiply by -i and 1(-i) = -i + a2.re = a0.re - ( t1 + t5 ) + a2.im = a0.im - ( t1 + t5 ) + a3.re = a1.re - ( t2 - t6 ) // since we multiply by +i and i(+i) = -1 + a3.im = a1.im + ( t1 - t5 ) // since we multiply by +i and 1(+i) = i + + +*/ + +#ifndef FFT_FFMPEG_INCL_OPTIMISED_TRANSFORM +static inline FFTComplex* TRANSFORM(FFTComplex * z, unsigned int n, FFTSample wre, FFTSample wim) +{ + register FFTSample t1,t2,t5,t6,r_re,r_im; + r_re = z[n*2].re; + r_im = z[n*2].im; + XPROD31_R(r_re, r_im, wre, wim, t1,t2); + r_re = z[n*3].re; + r_im = z[n*3].im; + XNPROD31_R(r_re, r_im, wre, wim, t5,t6); + BUTTERFLIES(z[0],z[n],z[n*2],z[n*3]); + return z+1; +} + +static inline FFTComplex* TRANSFORM_W01(FFTComplex * z, unsigned int n, const FFTSample * w) +{ + register const FFTSample wre=w[0],wim=w[1]; + register FFTSample t1,t2,t5,t6,r_re,r_im; + r_re = z[n*2].re; + r_im = z[n*2].im; + XPROD31_R(r_re, r_im, wre, wim, t1,t2); + r_re = z[n*3].re; + r_im = z[n*3].im; + XNPROD31_R(r_re, r_im, wre, wim, t5,t6); + BUTTERFLIES(z[0],z[n],z[n*2],z[n*3]); + return z+1; +} + +static inline FFTComplex* TRANSFORM_W10(FFTComplex * z, unsigned int n, const FFTSample * w) +{ + register const FFTSample wim=w[0],wre=w[1]; + register FFTSample t1,t2,t5,t6,r_re,r_im; + r_re = z[n*2].re; + r_im = z[n*2].im; + XPROD31_R(r_re, r_im, wre, wim, t1,t2); + r_re = z[n*3].re; + r_im = z[n*3].im; + XNPROD31_R(r_re, r_im, wre, wim, t5,t6); + BUTTERFLIES(z[0],z[n],z[n*2],z[n*3]); + return z+1; +} + +static inline FFTComplex* TRANSFORM_EQUAL(FFTComplex * z, unsigned int n) +{ + register FFTSample t1,t2,t5,t6,temp1,temp2; + register FFTSample * my_z = (FFTSample *)(z); + my_z += n*4; + t2 = MULT31(my_z[0], cPI2_8); + temp1 = MULT31(my_z[1], cPI2_8); + my_z += n*2; + temp2 = MULT31(my_z[0], cPI2_8); + t5 = MULT31(my_z[1], cPI2_8); + t1 = ( temp1 + t2 ); + t2 = ( temp1 - t2 ); + t6 = ( temp2 + t5 ); + t5 = ( temp2 - t5 ); + my_z -= n*6; + BUTTERFLIES(z[0],z[n],z[n*2],z[n*3]); + return z+1; +} + +static inline FFTComplex* TRANSFORM_ZERO(FFTComplex * z, unsigned int n) +{ + FFTSample t1,t2,t5,t6; + t1 = z[n*2].re; + t2 = z[n*2].im; + t5 = z[n*3].re; + t6 = z[n*3].im; + BUTTERFLIES(z[0],z[n],z[n*2],z[n*3]); + return z+1; +} +#endif + +/* z[0...8n-1], w[1...2n-1] */ +static void pass(FFTComplex *z_arg, unsigned int STEP_arg, unsigned int n_arg) ICODE_ATTR_TREMOR_MDCT; +static void pass(FFTComplex *z_arg, unsigned int STEP_arg, unsigned int n_arg) +{ + register FFTComplex * z = z_arg; + register unsigned int STEP = STEP_arg; + register unsigned int n = n_arg; + + register const FFTSample *w = sincos_lookup0+STEP; + /* wre = *(wim+1) . ordering is sin,cos */ + register const FFTSample *w_end = sincos_lookup0+1024; + + /* first two are special (well, first one is special, but we need to do pairs) */ + z = TRANSFORM_ZERO(z,n); + z = TRANSFORM_W10(z,n,w); + w += STEP; + /* first pass forwards through sincos_lookup0*/ + do { + z = TRANSFORM_W10(z,n,w); + w += STEP; + z = TRANSFORM_W10(z,n,w); + w += STEP; + } while(LIKELY(w < w_end)); + /* second half: pass backwards through sincos_lookup0*/ + /* wim and wre are now in opposite places so ordering now [0],[1] */ + w_end=sincos_lookup0; + while(LIKELY(w>w_end)) + { + z = TRANSFORM_W01(z,n,w); + w -= STEP; + z = TRANSFORM_W01(z,n,w); + w -= STEP; + } +} + +/* what is STEP? + sincos_lookup0 has sin,cos pairs for 1/4 cycle, in 1024 points + so half cycle would be 2048 points + ff_cos_16 has 8 elements corresponding to 4 cos points and 4 sin points + so each of the 4 points pairs corresponds to a 256*2-byte jump in sincos_lookup0 + 8192/16 (from "ff_cos_16") is 512 bytes. + i.e. for fft16, STEP = 8192/16 */ +#define DECL_FFT(n,n2,n4)\ +static void fft##n(FFTComplex *z) ICODE_ATTR_TREMOR_MDCT;\ +static void fft##n(FFTComplex *z)\ +{\ + fft##n2(z);\ + fft##n4(z+n4*2);\ + fft##n4(z+n4*3);\ + pass(z,8192/n,n4);\ +} + +#ifndef FFT_FFMPEG_INCL_OPTIMISED_FFT4 +static inline void fft4(FFTComplex *z) +{ + FFTSample t1, t2, t3, t4, t5, t6, t7, t8; + + BF(t3, t1, z[0].re, z[1].re); // t3=r1-r3 ; t1 = r1+r3 + BF(t8, t6, z[3].re, z[2].re); // t8=r7-r5 ; t6 = r7+r5 + + BF(z[2].re, z[0].re, t1, t6); // r5=t1-t6 ; r1 = t1+t6 + + BF(t4, t2, z[0].im, z[1].im); // t4=r2-r4 ; t2 = r2+r4 + BF(t7, t5, z[2].im, z[3].im); // t7=r6-r8 ; t5 = r6+r8 + + BF(z[3].im, z[1].im, t4, t8); // r8=t4-t8 ; r4 = t4+t8 + BF(z[3].re, z[1].re, t3, t7); // r7=t3-t7 ; r3 = t3+t7 + BF(z[2].im, z[0].im, t2, t5); // r6=t2-t5 ; r2 = t2+t5 +} +#endif + +static void fft4_dispatch(FFTComplex *z) +{ + fft4(z); +} + +#ifndef FFT_FFMPEG_INCL_OPTIMISED_FFT8 +static inline void fft8(FFTComplex *z) +{ + fft4(z); + FFTSample t1,t2,t3,t4,t7,t8; + + BF(t1, z[5].re, z[4].re, -z[5].re); + BF(t2, z[5].im, z[4].im, -z[5].im); + BF(t3, z[7].re, z[6].re, -z[7].re); + BF(t4, z[7].im, z[6].im, -z[7].im); + BF(t8, t1, t3, t1); + BF(t7, t2, t2, t4); + BF(z[4].re, z[0].re, z[0].re, t1); + BF(z[4].im, z[0].im, z[0].im, t2); + BF(z[6].re, z[2].re, z[2].re, t7); + BF(z[6].im, z[2].im, z[2].im, t8); + + z++; + TRANSFORM_EQUAL(z,2); +} +#endif + +static void fft8_dispatch(FFTComplex *z) +{ + fft8(z); +} + +#ifndef CONFIG_SMALL +static void fft16(FFTComplex *z) ICODE_ATTR_TREMOR_MDCT; +static void fft16(FFTComplex *z) +{ + fft8(z); + fft4(z+8); + fft4(z+12); + + TRANSFORM_ZERO(z,4); + z+=2; + TRANSFORM_EQUAL(z,4); + z-=1; + TRANSFORM(z,4,cPI1_8,cPI3_8); + z+=2; + TRANSFORM(z,4,cPI3_8,cPI1_8); +} +#else +DECL_FFT(16,8,4) +#endif +DECL_FFT(32,16,8) +DECL_FFT(64,32,16) +DECL_FFT(128,64,32) +DECL_FFT(256,128,64) +DECL_FFT(512,256,128) +DECL_FFT(1024,512,256) +DECL_FFT(2048,1024,512) +DECL_FFT(4096,2048,1024) + +static void (*fft_dispatch[])(FFTComplex*) = { + fft4_dispatch, fft8_dispatch, fft16, fft32, fft64, fft128, fft256, fft512, fft1024, + fft2048, fft4096 +}; + +void ff_fft_calc_c(int nbits, FFTComplex *z) +{ + fft_dispatch[nbits-2](z); +} + +#if 0 +int main (void) +{ +#define PRECISION 16 +#define FFT_SIZE 1024 +#define ftofix32(x) ((fixed32)((x) * (float)(1 << PRECISION) + ((x) < 0 ? -0.5 : 0.5))) +#define itofix32(x) ((x) << PRECISION) +#define fixtoi32(x) ((x) >> PRECISION) + + int j; + const long N = FFT_SIZE; + double r[FFT_SIZE] = {0.0}, i[FFT_SIZE] = {0.0}; + long n; + double t; + double amp, phase; + clock_t start, end; + double exec_time = 0; + FFTContext s; + FFTComplex z[FFT_SIZE]; + memset(z, 0, 64*sizeof(FFTComplex)); + + /* Generate saw-tooth test data */ + for (n = 0; n < FFT_SIZE; n++) + { + t = (2 * M_PI * n)/N; + /*z[n].re = 1.1 + sin( t) + + 0.5 * sin(2.0 * t) + + (1.0/3.0) * sin(3.0 * t) + + 0.25 * sin(4.0 * t) + + 0.2 * sin(5.0 * t) + + (1.0/6.0) * sin(6.0 * t) + + (1.0/7.0) * sin(7.0 * t) ;*/ + z[n].re = ftofix32(cos(2*M_PI*n/64)); + //printf("z[%d] = %f\n", n, z[n].re); + //getchar(); + } + + ff_fft_init(&s, 10, 1); +//start = clock(); +//for(n = 0; n < 1000000; n++) + ff_fft_permute_c(&s, z); + ff_fft_calc_c(&s, z); +//end = clock(); +//exec_time = (((double)end-(double)start)/CLOCKS_PER_SEC); + for(j = 0; j < FFT_SIZE; j++) + { + printf("%8.4f\n", sqrt(pow(fixtof32(z[j].re),2)+ pow(fixtof32(z[j].im), 2))); + //getchar(); + } + printf("muls = %d, adds = %d\n", muls, adds); +//printf(" Time elapsed = %f\n", exec_time); + //ff_fft_end(&s); + +} +#endif diff --git a/lib/rbcodec/codecs/lib/fft-ffmpeg_arm.h b/lib/rbcodec/codecs/lib/fft-ffmpeg_arm.h new file mode 100644 index 0000000000..073ad8ee46 --- /dev/null +++ b/lib/rbcodec/codecs/lib/fft-ffmpeg_arm.h @@ -0,0 +1,456 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2010 Dave Hooper + * + * ARM optimisations for ffmpeg's fft (used in fft-ffmpeg.c) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#ifdef CPU_ARM + +/* Start off with optimised variants of the butterflies that work + nicely on arm */ +/* 1. where y and a share the same variable/register */ +#define BF_OPT(x,y,a,b) {\ + y = a + b;\ + x = y - (b<<1);\ +} + +/* 2. where y and b share the same variable/register */ +#define BF_OPT2(x,y,a,b) {\ + x = a - b;\ + y = x + (b<<1);\ +} + +/* 3. where y and b share the same variable/register (but y=(-b)) */ +#define BF_OPT2_REV(x,y,a,b) {\ + x = a + b;\ + y = x - (b<<1);\ +} + + +/* standard BUTTERFLIES package. Note, we actually manually inline this + in all the TRANSFORM macros below anyway */ +#define FFT_FFMPEG_INCL_OPTIMISED_BUTTERFLIES +#define BUTTERFLIES(a0,a1,a2,a3) {\ + {\ + BF_OPT(t1, t5, t5, t1);\ + BF_OPT(t6, t2, t2, t6);\ + BF_OPT(a2.re, a0.re, a0.re, t5);\ + BF_OPT(a2.im, a0.im, a0.im, t2);\ + BF_OPT(a3.re, a1.re, a1.re, t6);\ + BF_OPT(a3.im, a1.im, a1.im, t1);\ + }\ +} + +#define FFT_FFMPEG_INCL_OPTIMISED_TRANSFORM + +static inline FFTComplex* TRANSFORM( FFTComplex* z, int n, FFTSample wre, FFTSample wim ) +{ + register FFTSample t1,t2 asm("r5"),t5 asm("r6"),t6 asm("r7"),r_re asm("r8"),r_im asm("r9"); + z += n*2; /* z[o2] */ + asm volatile( "ldmia %[my_z], {%[r_re],%[r_im]}\n\t":[r_re] "=r" (r_re), [r_im] "=r" (r_im):[my_z] "r" (z)); + XPROD31_R(r_re, r_im, wre, wim, t1,t2); + + z += n; /* z[o3] */ + asm volatile( "ldmia %[my_z], {%[r_re],%[r_im]}\n\t":[r_re] "=r" (r_re), [r_im] "=r" (r_im):[my_z] "r" (z)); + XNPROD31_R(r_re, r_im, wre, wim, t5,t6); + + BF_OPT(t1, t5, t5, t1); + BF_OPT(t6, t2, t2, t6); + + { + register FFTSample rt0temp asm("r4"); + /*{*/ + /* BF_OPT(t1, t5, t5, t1);*/ + /* BF_OPT(t6, t2, t2, t6);*/ + /* BF_OPT(a2.re, a0.re, a0.re, t5);*/ + /* BF_OPT(a2.im, a0.im, a0.im, t2);*/ + /* BF_OPT(a3.re, a1.re, a1.re, t6);*/ + /* BF_OPT(a3.im, a1.im, a1.im, t1);*/ + /*}*/ + z -= n*3; + /* r_re = my_z[0]; r_im = my_z[1]; */ + asm volatile( "ldmia %[my_z], {%[r_re],%[r_im]}\n\t":[r_re] "=r" (r_re), [r_im] "=r" (r_im):[my_z] "r" (z)); + BF_OPT(rt0temp, r_re, r_re, t5); + BF_OPT(t2, r_im, r_im, t2); + /* my_z[0] = r_re; my_z[1] = r_im; */ + asm volatile( "stmia %[my_z], {%[r_re],%[r_im]}\n\t"::[my_z] "r" (z), [r_re] "r" (r_re), [r_im] "r" (r_im):"memory" ); + z += n; + /* r_re = my_z[0]; r_im = my_z[1]; */ + asm volatile( "ldmia %[my_z], {%[r_re],%[r_im]}\n\t":[r_re] "=r" (r_re), [r_im] "=r" (r_im):[my_z] "r" (z)); + BF_OPT(t5, r_re, r_re, t6); + BF_OPT(t6, r_im, r_im, t1); + /* my_z[0] = r_re; my_z[1] = r_im; */ + asm volatile( "stmia %[my_z], {%[r_re],%[r_im]}\n\t"::[my_z] "r" (z), [r_re] "r" (r_re), [r_im] "r" (r_im):"memory"); + z += n; + /* my_z[0] = rt0temp; my_z[1] = t2; */ + asm volatile( "stmia %[my_z], {%[rt0temp],%[t2]}\n\t"::[my_z] "r" (z), [rt0temp] "r" (rt0temp), [t2] "r" (t2):"memory"); + } + z += n; + + /* my_z[0] = t5; my_z[1] = t6; */ + asm volatile( "stmia %[my_z]!, {%[t5],%[t6]}\n\t":[my_z] "+r" (z) : [t5] "r" (t5), [t6] "r" (t6):"memory"); + z -= n*3; + return(z); +} + +static inline FFTComplex* TRANSFORM_W01( FFTComplex* z, int n, const FFTSample* w ) +{ + register FFTSample t1,t2 asm("r5"),t5 asm("r6"),t6 asm("r7"),r_re asm("r8"),r_im asm("r9"); + + /* load wre,wim into t5,t6 */ + asm volatile( "ldmia %[w], {%[wre], %[wim]}\n\t":[wre] "=r" (t5), [wim] "=r" (t6):[w] "r" (w)); + z += n*2; /* z[o2] -- 2n * 2 since complex numbers */ + asm volatile( "ldmia %[my_z], {%[r_re],%[r_im]}\n\t":[r_re] "=r" (r_re), [r_im] "=r" (r_im):[my_z] "r" (z)); + XPROD31_R(r_re, r_im, t5 /*wre*/, t6 /*wim*/, t1,t2); + + z += n; /* z[o3] */ + asm volatile( "ldmia %[my_z], {%[r_re],%[r_im]}\n\t":[r_re] "=r" (r_re), [r_im] "=r" (r_im):[my_z] "r" (z)); + XNPROD31_R(r_re, r_im, t5 /*wre*/, t6 /*wim*/, t5,t6); + + BF_OPT(t1, t5, t5, t1); + BF_OPT(t6, t2, t2, t6); + { + register FFTSample rt0temp asm("r4"); + /*{*/ + /* BF_OPT(t1, t5, t5, t1);*/ + /* BF_OPT(t6, t2, t2, t6);*/ + /* BF_OPT(a2.re, a0.re, a0.re, t5);*/ + /* BF_OPT(a2.im, a0.im, a0.im, t2);*/ + /* BF_OPT(a3.re, a1.re, a1.re, t6);*/ + /* BF_OPT(a3.im, a1.im, a1.im, t1);*/ + /*}*/ + z -= n*3; + /* r_re = my_z[0]; r_im = my_z[1]; */ + asm volatile( "ldmia %[my_z], {%[r_re],%[r_im]}\n\t":[r_re] "=r" (r_re), [r_im] "=r" (r_im):[my_z] "r" (z)); + BF_OPT(rt0temp, r_re, r_re, t5); + BF_OPT(t2, r_im, r_im, t2); + /* my_z[0] = r_re; my_z[1] = r_im; */ + asm volatile( "stmia %[my_z], {%[r_re],%[r_im]}\n\t"::[my_z] "r" (z), [r_re] "r" (r_re), [r_im] "r" (r_im):"memory"); + z += n; + /* r_re = my_z[0]; r_im = my_z[1]; */ + asm volatile( "ldmia %[my_z], {%[r_re],%[r_im]}\n\t":[r_re] "=r" (r_re), [r_im] "=r" (r_im):[my_z] "r" (z)); + BF_OPT(t5, r_re, r_re, t6); + BF_OPT(t6, r_im, r_im, t1); + /* my_z[0] = r_re; my_z[1] = r_im; */ + asm volatile( "stmia %[my_z], {%[r_re],%[r_im]}\n\t"::[my_z] "r" (z), [r_re] "r" (r_re), [r_im] "r" (r_im):"memory"); + z += n; + /* my_z[0] = rt0temp; my_z[1] = t2; */ + asm volatile( "stmia %[my_z], {%[rt0temp],%[t2]}\n\t"::[my_z] "r" (z), [rt0temp] "r" (rt0temp), [t2] "r" (t2):"memory"); + } + z += n; + + /* my_z[0] = t5; my_z[1] = t6; */ + asm volatile( "stmia %[my_z]!, {%[t5],%[t6]}\n\t":[my_z] "+r" (z) : [t5] "r" (t5), [t6] "r" (t6):"memory"); + z -= n*3; + return(z); +} + +static inline FFTComplex* TRANSFORM_W10( FFTComplex* z, int n, const FFTSample* w ) +{ + register FFTSample t1,t2 asm("r5"),t5 asm("r6"),t6 asm("r7"),r_re asm("r8"),r_im asm("r9"); + + /* load wim,wre into t5,t6 */ + asm volatile( "ldmia %[w], {%[wim], %[wre]}\n\t":[wim] "=r" (t5), [wre] "=r" (t6):[w] "r" (w)); + z += n*2; /* z[o2] -- 2n * 2 since complex numbers */ + asm volatile( "ldmia %[my_z], {%[r_re],%[r_im]}\n\t":[r_re] "=r" (r_re), [r_im] "=r" (r_im):[my_z] "r" (z)); + XPROD31_R(r_re, r_im, t6 /*wim*/, t5 /*wre*/, t1,t2); + + z += n; /* z[o3] */ + asm volatile( "ldmia %[my_z], {%[r_re],%[r_im]}\n\t":[r_re] "=r" (r_re), [r_im] "=r" (r_im):[my_z] "r" (z)); + XNPROD31_R(r_re, r_im, t6 /*wim*/, t5 /*wre*/, t5,t6); + + BF_OPT(t1, t5, t5, t1); + BF_OPT(t6, t2, t2, t6); + { + register FFTSample rt0temp asm("r4"); + /*{*/ + /* BF_OPT(t1, t5, t5, t1);*/ + /* BF_OPT(t6, t2, t2, t6);*/ + /* BF_OPT(a2.re, a0.re, a0.re, t5);*/ + /* BF_OPT(a2.im, a0.im, a0.im, t2);*/ + /* BF_OPT(a3.re, a1.re, a1.re, t6);*/ + /* BF_OPT(a3.im, a1.im, a1.im, t1);*/ + /*}*/ + z -= n*3; + /* r_re = my_z[0]; r_im = my_z[1]; */ + asm volatile( "ldmia %[my_z], {%[r_re],%[r_im]}\n\t":[r_re] "=r" (r_re), [r_im] "=r" (r_im):[my_z] "r" (z)); + BF_OPT(rt0temp, r_re, r_re, t5); + BF_OPT(t2, r_im, r_im, t2); + /* my_z[0] = r_re; my_z[1] = r_im; */ + asm volatile( "stmia %[my_z], {%[r_re],%[r_im]}\n\t"::[my_z] "r" (z), [r_re] "r" (r_re), [r_im] "r" (r_im):"memory"); + z += n; + /* r_re = my_z[0]; r_im = my_z[1]; */ + asm volatile( "ldmia %[my_z], {%[r_re],%[r_im]}\n\t":[r_re] "=r" (r_re), [r_im] "=r" (r_im):[my_z] "r" (z)); + BF_OPT(t5, r_re, r_re, t6); + BF_OPT(t6, r_im, r_im, t1); + /* my_z[0] = r_re; my_z[1] = r_im; */ + asm volatile( "stmia %[my_z], {%[r_re],%[r_im]}\n\t"::[my_z] "r" (z), [r_re] "r" (r_re), [r_im] "r" (r_im):"memory"); + z += n; + /* my_z[0] = rt0temp; my_z[1] = t2; */ + asm volatile( "stmia %[my_z], {%[rt0temp],%[t2]}\n\t"::[my_z] "r" (z), [rt0temp] "r" (rt0temp), [t2] "r" (t2):"memory"); + } + z += n; + + /* my_z[0] = t5; my_z[1] = t6; */ + asm volatile( "stmia %[my_z]!, {%[t5],%[t6]}\n\t":[my_z] "+r" (z) : [t5] "r" (t5), [t6] "r" (t6):"memory"); + z -= n*3; + return(z); +} + +static inline FFTComplex* TRANSFORM_EQUAL( FFTComplex* z, int n ) +{ + register FFTSample t1,t2 asm("r5"),t5 asm("r6"),t6 asm("r7"),r_re asm("r8"),r_im asm("r9"); + + z += n*2; /* z[o2] -- 2n * 2 since complex numbers */ + asm volatile( "ldmia %[my_z], {%[t5],%[t6]}\n\t":[t5] "=r" (t5), [t6] "=r" (t6):[my_z] "r" (z)); + z += n; /* z[o3] */ + asm volatile( "ldmia %[my_z], {%[r_re],%[r_im]}\n\t":[r_re] "=r" (r_re), [r_im] "=r" (r_im):[my_z] "r" (z)); + +/**/ +/*t2 = MULT32(cPI2_8, t5);*/ +/*t1 = MULT31(cPI2_8, t6);*/ +/*t6 = MULT31(cPI2_8, r_re);*/ +/*t5 = MULT32(cPI2_8, r_im);*/ + +/*t1 = ( t1 + (t2<<1) );*/ +/*t2 = ( t1 - (t2<<2) );*/ +/*t6 = ( t6 + (t5<<1) );*/ +/*t5 = ( t6 - (t5<<2) );*/ +/**/ + t2 = MULT31(cPI2_8, t5); + t6 = MULT31(cPI2_8, t6); + r_re = MULT31(cPI2_8, r_re); + t5 = MULT31(cPI2_8, r_im); + + t1 = ( t6 + t2 ); + t2 = ( t6 - t2 ); + t6 = ( r_re + t5 ); + t5 = ( r_re - t5 ); + + BF_OPT(t1, t5, t5, t1); + BF_OPT(t6, t2, t2, t6); + { + register FFTSample rt0temp asm("r4"); + /*{*/ + /* BF_OPT(t1, t5, t5, t1);*/ + /* BF_OPT(t6, t2, t2, t6);*/ + /* BF_OPT(a2.re, a0.re, a0.re, t5);*/ + /* BF_OPT(a2.im, a0.im, a0.im, t2);*/ + /* BF_OPT(a3.re, a1.re, a1.re, t6);*/ + /* BF_OPT(a3.im, a1.im, a1.im, t1);*/ + /*}*/ + z -= n*3; + /* r_re = my_z[0]; r_im = my_z[1]; */ + asm volatile( "ldmia %[my_z], {%[r_re],%[r_im]}\n\t":[r_re] "=r" (r_re), [r_im] "=r" (r_im):[my_z] "r" (z)); + BF_OPT(rt0temp, r_re, r_re, t5); + BF_OPT(t2, r_im, r_im, t2); + /* my_z[0] = r_re; my_z[1] = r_im; */ + asm volatile( "stmia %[my_z], {%[r_re],%[r_im]}\n\t"::[my_z] "r" (z), [r_re] "r" (r_re), [r_im] "r" (r_im):"memory"); + z += n; + /* r_re = my_z[0]; r_im = my_z[1]; */ + asm volatile( "ldmia %[my_z], {%[r_re],%[r_im]}\n\t":[r_re] "=r" (r_re), [r_im] "=r" (r_im):[my_z] "r" (z)); + BF_OPT(t5, r_re, r_re, t6); + BF_OPT(t6, r_im, r_im, t1); + /* my_z[0] = r_re; my_z[1] = r_im; */ + asm volatile( "stmia %[my_z], {%[r_re],%[r_im]}\n\t"::[my_z] "r" (z), [r_re] "r" (r_re), [r_im] "r" (r_im):"memory"); + z += n; + /* my_z[0] = rt0temp; my_z[1] = t2; */ + asm volatile( "stmia %[my_z], {%[rt0temp],%[t2]}\n\t"::[my_z] "r" (z), [rt0temp] "r" (rt0temp), [t2] "r" (t2):"memory"); + } + z += n; + + /* my_z[0] = t5; my_z[1] = t6; */ + asm volatile( "stmia %[my_z]!, {%[t5],%[t6]}\n\t":[my_z] "+r" (z) : [t5] "r" (t5), [t6] "r" (t6):"memory"); + z -= n*3; + return(z); +} + +static inline FFTComplex* TRANSFORM_ZERO( FFTComplex* z, int n ) +{ + register FFTSample t1,t2 asm("r5"),t5 asm("r6"),t6 asm("r7"), r_re asm("r8"), r_im asm("r9"); + + z += n*2; /* z[o2] -- 2n * 2 since complex numbers */ + asm volatile( "ldmia %[my_z], {%[r_re],%[r_im]}\n\t":[r_re] "=r" (r_re), [r_im] "=r" (r_im):[my_z] "r" (z)); + z += n; /* z[o3] */ + asm volatile( "ldmia %[my_z], {%[t5],%[t6]}\n\t":[t5] "=r" (t5), [t6] "=r" (t6):[my_z] "r" (z)); + + BF_OPT(t1, t5, t5, r_re); + BF_OPT(t6, t2, r_im, t6); + { + register FFTSample rt0temp asm("r4"); + /*{*/ + /* BF_OPT(t1, t5, t5, t1);*/ + /* BF_OPT(t6, t2, t2, t6);*/ + /* BF_OPT(a2.re, a0.re, a0.re, t5);*/ + /* BF_OPT(a2.im, a0.im, a0.im, t2);*/ + /* BF_OPT(a3.re, a1.re, a1.re, t6);*/ + /* BF_OPT(a3.im, a1.im, a1.im, t1);*/ + /*}*/ + z -= n*3; + /* r_re = my_z[0]; r_im = my_z[1]; */ + asm volatile( "ldmia %[my_z], {%[r_re],%[r_im]}\n\t":[r_re] "=r" (r_re), [r_im] "=r" (r_im):[my_z] "r" (z)); + BF_OPT(rt0temp, r_re, r_re, t5); + BF_OPT(t2, r_im, r_im, t2); + /* my_z[0] = r_re; my_z[1] = r_im; */ + asm volatile( "stmia %[my_z], {%[r_re],%[r_im]}\n\t"::[my_z] "r" (z), [r_re] "r" (r_re), [r_im] "r" (r_im):"memory"); + z += n; + /* r_re = my_z[0]; r_im = my_z[1]; */ + asm volatile( "ldmia %[my_z], {%[r_re],%[r_im]}\n\t":[r_re] "=r" (r_re), [r_im] "=r" (r_im):[my_z] "r" (z)); + BF_OPT(t5, r_re, r_re, t6); + BF_OPT(t6, r_im, r_im, t1); + /* my_z[0] = r_re; my_z[1] = r_im; */ + asm volatile( "stmia %[my_z], {%[r_re],%[r_im]}\n\t"::[my_z] "r" (z), [r_re] "r" (r_re), [r_im] "r" (r_im):"memory"); + z += n; + /* my_z[0] = rt0temp; my_z[1] = t2; */ + asm volatile( "stmia %[my_z], {%[rt0temp],%[t2]}\n\t"::[my_z] "r" (z), [rt0temp] "r" (rt0temp), [t2] "r" (t2):"memory"); + } + z += n; + + /* my_z[0] = t5; my_z[1] = t6; */ + asm volatile( "stmia %[my_z]!, {%[t5],%[t6]}\n\t":[my_z] "+r" (z) : [t5] "r" (t5), [t6] "r" (t6):"memory"); + z -= n*3; + return(z); +} + +#define FFT_FFMPEG_INCL_OPTIMISED_FFT4 +static inline FFTComplex* fft4(FFTComplex * z) +{ + FFTSample temp; + + /* input[0..7] -> output[0..7] */ + /* load r1=z[0],r2=z[1],...,r8=z[7] */ + asm volatile( + "ldmia %[z], {r1-r8}\n\t" + "add r1,r1,r3\n\t" /* r1 :=t1 */ + "sub r3,r1,r3, lsl #1\n\t" /* r3 :=t3 */ + "sub r7,r7,r5\n\t" /* r10:=t8 */ + "add r5,r7,r5, lsl #1\n\t" /* r5 :=t6 */ + + "add r1,r1,r5\n\t" /* r1 = o[0] */ + "sub r5,r1,r5, lsl #1\n\t" /* r5 = o[4] */ + + "add r2,r2,r4\n\t" /* r2 :=t2 */ + "sub r4,r2,r4, lsl #1\n\t" /* r9 :=t4 */ + + "add %[temp],r6,r8\n\t" /* r10:=t5 */ + "sub r6,r6,r8\n\t" /* r6 :=t7 */ + + "sub r8,r4,r7\n\t" /* r8 = o[7]*/ + "add r4,r4,r7\n\t" /* r4 = o[3]*/ + "sub r7,r3,r6\n\t" /* r7 = o[6]*/ + "add r3,r3,r6\n\t" /* r3 = o[2]*/ + "sub r6,r2,%[temp]\n\t" /* r6 = o[5]*/ + "add r2,r2,%[temp]\n\t" /* r2 = o[1]*/ + + "stmia %[z]!, {r1-r8}\n\t" + : /* outputs */ [z] "+r" (z), [temp] "=r" (temp) + : /* inputs */ + : /* clobbers */ + "r1","r2","r3","r4","r5","r6","r7","r8","memory" + ); + return z; +} + +#define FFT_FFMPEG_INCL_OPTIMISED_FFT8 + /* The chunk of asm below is equivalent to the following: + + // first load in z[4].re thru z[7].im into local registers + // ... + BF_OPT2_REV(z[4].re, z[5].re, z[4].re, z[5].re); // x=a+b; y=x-(b<<1) + BF_OPT2_REV(z[4].im, z[5].im, z[4].im, z[5].im); + BF_REV (temp, z[7].re, z[6].re, z[7].re); // x=a+b; y=a-b; + BF_REV (z[6].re, z[7].im, z[6].im, z[7].im); + // save z[7].re and z[7].im as those are complete now + // z[5].re and z[5].im are also complete now but save these later on + + BF(z[6].im, z[4].re, temp, z[4].re); // x=a-b; y=a+b + BF_OPT(z[6].re, z[4].im, z[4].im, z[6].re); // y=a+b; x=y-(b<<1) + // now load z[2].re and z[2].im + // ... + BF_OPT(z[6].re, z[2].re, z[2].re, z[6].re); // y=a+b; x=y-(b<<1) + BF_OPT(z[6].im, z[2].im, z[2].im, z[6].im); // y=a+b; x=y-(b<<1) + // Now save z[6].re and z[6].im, along with z[5].re and z[5].im + // for efficiency. Also save z[2].re and z[2].im. + // Now load z[0].re and z[0].im + // ... + + BF_OPT(z[4].re, z[0].re, z[0].re, z[4].re); // y=a+b; x=y-(b<<1) + BF_OPT(z[4].im, z[0].im, z[0].im, z[4].im); // y=a+b; x=y-(b<<1) + // Finally save out z[4].re, z[4].im, z[0].re and z[0].im + // ... + */ +static inline void fft8(FFTComplex * z) +{ + FFTComplex* m4 = fft4(z); + { + /* note that we increment z_ptr on the final stmia, which + leaves z_ptr pointing to z[1].re ready for the Transform step */ + + register FFTSample temp; + + asm volatile( + /* read in z[4].re thru z[7].im */ + "ldmia %[z4_ptr]!, {r1-r8}\n\t" + /* (now points one word past &z[7].im) */ + "add r1,r1,r3\n\t" + "sub r3,r1,r3,lsl #1\n\t" + "add r2,r2,r4\n\t" + "sub r4,r2,r4,lsl #1\n\t" + "add %[temp],r5,r7\n\t" + "sub r7,r5,r7\n\t" + "add r5,r6,r8\n\t" + "sub r8,r6,r8\n\t" + + "stmdb %[z4_ptr]!, {r7,r8}\n\t" /* write z[7].re,z[7].im straight away */ + /* Note, registers r7 & r8 now free */ + + "sub r6,%[temp],r1\n\t" + "add r1,%[temp],r1\n\t" + "add r2,r2,r5\n\t" + "sub r5,r2,r5,lsl #1\n\t" + "add %[temp], %[z_ptr], #16\n\t" /* point to &z[2].re */ + "ldmia %[temp],{r7,r8}\n\t" /* load z[2].re and z[2].im */ + "add r7,r7,r5\n\t" + "sub r5,r7,r5,lsl #1\n\t" + "add r8,r8,r6\n\t" + "sub r6,r8,r6,lsl #1\n\t" + + /* write out z[5].re, z[5].im, z[6].re, z[6].im in one go*/ + "stmdb %[z4_ptr]!, {r3-r6}\n\t" + "stmia %[temp],{r7,r8}\n\t" /* write out z[2].re, z[2].im */ + "ldmia %[z_ptr],{r7,r8}\n\t" /* load r[0].re, r[0].im */ + + "add r7,r7,r1\n\t" + "sub r1,r7,r1,lsl #1\n\t" + "add r8,r8,r2\n\t" + "sub r2,r8,r2,lsl #1\n\t" + + "stmia %[z_ptr]!,{r7,r8}\n\t" /* write out z[0].re, z[0].im */ + "stmdb %[z4_ptr], {r1,r2}\n\t" /* write out z[4].re, z[4].im */ + : [z4_ptr] "+r" (m4), [temp] "=r" (temp), [z_ptr] "+r" (z) + : + : "r1","r2","r3","r4","r5","r6","r7","r8","memory" + ); + } + + TRANSFORM_EQUAL(z,2); +} + +#endif // CPU_ARM diff --git a/lib/rbcodec/codecs/lib/fft-ffmpeg_cf.h b/lib/rbcodec/codecs/lib/fft-ffmpeg_cf.h new file mode 100644 index 0000000000..a29464a23d --- /dev/null +++ b/lib/rbcodec/codecs/lib/fft-ffmpeg_cf.h @@ -0,0 +1,370 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2010 Nils Wallménius + * + * Coldfire v2 optimisations for ffmpeg's fft (used in fft-ffmpeg.c) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#ifdef CPU_COLDFIRE +#define FFT_FFMPEG_INCL_OPTIMISED_FFT4 +static inline void fft4(FFTComplex * z) +{ + asm volatile ("movem.l (%[z]), %%d0-%%d7\n\t" + "move.l %%d0, %%a0\n\t" + "add.l %%d2, %%d0\n\t" /* d0 == t1 */ + "neg.l %%d2\n\t" + "add.l %%a0, %%d2\n\t" /* d2 == t3, a0 free */ + "move.l %%d6, %%a0\n\t" + "sub.l %%d4, %%d6\n\t" /* d6 == t8 */ + "add.l %%d4, %%a0\n\t" /* a0 == t6 */ + + "move.l %%d0, %%d4\n\t" + "sub.l %%a0, %%d4\n\t" /* z[2].re done */ + "add.l %%a0, %%d0\n\t" /* z[0].re done, a0 free */ + + "move.l %%d5, %%a0\n\t" + "sub.l %%d7, %%d5\n\t" /* d5 == t7 */ + "add.l %%d7, %%a0\n\t" /* a0 == t5 */ + + "move.l %%d1, %%d7\n\t" + "sub.l %%d3, %%d7\n\t" /* d7 == t4 */ + "add.l %%d3, %%d1\n\t" /* d1 == t2 */ + + "move.l %%d7, %%d3\n\t" + "sub.l %%d6, %%d7\n\t" /* z[3].im done */ + "add.l %%d6, %%d3\n\t" /* z[1].im done */ + + "move.l %%d2, %%d6\n\t" + "sub.l %%d5, %%d6\n\t" /* z[3].re done */ + "add.l %%d5, %%d2\n\t" /* z[1].re done */ + + "move.l %%d1, %%d5\n\t" + "sub.l %%a0, %%d5\n\t" /* z[2].im done */ + "add.l %%a0, %%d1\n\t" /* z[0].im done */ + + "movem.l %%d0-%%d7, (%[z])\n\t" + : :[z] "a" (z) + : "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", + "a0", "cc", "memory"); + +} + +#define FFT_FFMPEG_INCL_OPTIMISED_FFT8 +static inline void fft8(FFTComplex *z) +{ + asm volatile ("movem.l (4*8, %[z]), %%d0-%%d7\n\t" + "move.l %%d0, %%a1\n\t" + "add.l %%d2, %%a1\n\t" /* a1 == t1 */ + "sub.l %%d2, %%d0\n\t" /* d0 == z[5].re */ + + "move.l %%d1, %%a2\n\t" + "add.l %%d3, %%a2\n\t" /* a2 == t2 */ + "sub.l %%d3, %%d1\n\t" /* d1 == z[5].im */ + + "move.l %%d4, %%d2\n\t" + "add.l %%d6, %%d2\n\t" /* d2 == t3 */ + "sub.l %%d6, %%d4\n\t" /* d4 == z[7].re */ + + "move.l %%d5, %%d3\n\t" + "add.l %%d7, %%d3\n\t" /* d3 == t4 */ + "sub.l %%d7, %%d5\n\t" /* d5 == z[7].im */ + + "move.l %%d2, %%a4\n\t" + "sub.l %%a1, %%a4\n\t" /* a4 == t8 */ + "add.l %%d2, %%a1\n\t" /* a1 == t1, d2 free */ + + "move.l %%a2, %%a3\n\t" + "sub.l %%d3, %%a3\n\t" /* a3 == t7 */ + "add.l %%d3, %%a2\n\t" /* a2 == t2, d3 free */ + + /* emac block from TRANSFORM_EQUAL, do this now + so we don't need to store and load z[5] and z[7] */ + "move.l %[_cPI2_8], %%d2\n\t" + "mac.l %%d2, %%d0, %%acc0\n\t" + "mac.l %%d2, %%d1, %%acc1\n\t" + "mac.l %%d2, %%d4, %%acc2\n\t" + "mac.l %%d2, %%d5, %%acc3\n\t" + + /* fft4, clobbers all d regs and a0 */ + "movem.l (%[z]), %%d0-%%d7\n\t" + "move.l %%d0, %%a0\n\t" + "add.l %%d2, %%d0\n\t" /* d0 == t1 */ + "neg.l %%d2\n\t" + "add.l %%a0, %%d2\n\t" /* d2 == t3, a0 free */ + "move.l %%d6, %%a0\n\t" + "sub.l %%d4, %%d6\n\t" /* d6 == t8 */ + "add.l %%d4, %%a0\n\t" /* a0 == t6 */ + + "move.l %%d0, %%d4\n\t" + "sub.l %%a0, %%d4\n\t" /* z[2].re done */ + "add.l %%a0, %%d0\n\t" /* z[0].re done, a0 free */ + + "move.l %%d5, %%a0\n\t" + "sub.l %%d7, %%d5\n\t" /* d5 == t7 */ + "add.l %%d7, %%a0\n\t" /* a0 == t5 */ + + "move.l %%d1, %%d7\n\t" + "sub.l %%d3, %%d7\n\t" /* d7 == t4 */ + "add.l %%d3, %%d1\n\t" /* d1 == t2 */ + + "move.l %%d7, %%d3\n\t" + "sub.l %%d6, %%d7\n\t" /* z[3].im done */ + "add.l %%d6, %%d3\n\t" /* z[1].im done */ + + "move.l %%d2, %%d6\n\t" + "sub.l %%d5, %%d6\n\t" /* z[3].re done */ + "add.l %%d5, %%d2\n\t" /* z[1].re done */ + + "move.l %%d1, %%d5\n\t" + "sub.l %%a0, %%d5\n\t" /* z[2].im done */ + "add.l %%a0, %%d1\n\t" /* z[0].im done */ + /* end of fft4, but don't store yet */ + + "move.l %%d0, %%a0\n\t" + "add.l %%a1, %%d0\n\t" + "sub.l %%a1, %%a0\n\t" /* z[4].re, z[0].re done, a1 free */ + + "move.l %%d1, %%a1\n\t" + "add.l %%a2, %%d1\n\t" + "sub.l %%a2, %%a1\n\t" /* z[4].im, z[0].im done, a2 free */ + + "move.l %%d4, %%a2\n\t" + "add.l %%a3, %%d4\n\t" + "sub.l %%a3, %%a2\n\t" /* z[6].re, z[2].re done, a3 free */ + + "move.l %%d5, %%a3\n\t" + "add.l %%a4, %%d5\n\t" + "sub.l %%a4, %%a3\n\t" /* z[6].im, z[2].im done, a4 free */ + + "movem.l %%d0-%%d1, (%[z])\n\t" /* save z[0] */ + "movem.l %%d4-%%d5, (2*8, %[z])\n\t" /* save z[2] */ + "movem.l %%a0-%%a1, (4*8, %[z])\n\t" /* save z[4] */ + "movem.l %%a2-%%a3, (6*8, %[z])\n\t" /* save z[6] */ + + /* TRANSFORM_EQUAL */ + "movclr.l %%acc0, %%d0\n\t" + "movclr.l %%acc1, %%d1\n\t" + "movclr.l %%acc2, %%d4\n\t" + "movclr.l %%acc3, %%d5\n\t" + + "move.l %%d1, %%a0\n\t" + "add.l %%d0, %%a0\n\t" /* a0 == t1 */ + "sub.l %%d0, %%d1\n\t" /* d1 == t2 */ + + "move.l %%d4, %%d0\n\t" + "add.l %%d5, %%d0\n\t" /* d0 == t6 */ + "sub.l %%d5, %%d4\n\t" /* d4 == t5 */ + + "move.l %%d4, %%a1\n\t" + "sub.l %%a0, %%a1\n\t" /* a1 == temp1 */ + "add.l %%a0, %%d4\n\t" /* d4 == temp2 */ + + "move.l %%d2, %%a2\n\t" + "sub.l %%d4, %%a2\n\t" /* a2 == z[5].re */ + "add.l %%d4, %%d2\n\t" /* z[1].re done */ + + "move.l %%d7, %%d5\n\t" + "sub.l %%a1, %%d5\n\t" /* d5 == z[7].im */ + "add.l %%a1, %%d7\n\t" /* z[3].im done */ + + "move.l %%d1, %%a0\n\t" + "sub.l %%d0, %%a0\n\t" /* a0 == temp1 */ + "add.l %%d0, %%d1\n\t" /* d1 == temp2 */ + + "move.l %%d6, %%d4\n\t" + "sub.l %%a0, %%d4\n\t" /* d4 == z[7].re */ + "add.l %%a0, %%d6\n\t" /* z[3].re done */ + + "move.l %%d3, %%a3\n\t" + "sub.l %%d1, %%a3\n\t" /* a3 == z[5].im */ + "add.l %%d1, %%d3\n\t" /* z[1].im done */ + + "movem.l %%d2-%%d3, (1*8, %[z])\n\t" /* save z[1] */ + "movem.l %%d6-%%d7, (3*8, %[z])\n\t" /* save z[3] */ + "movem.l %%a2-%%a3, (5*8, %[z])\n\t" /* save z[5] */ + "movem.l %%d4-%%d5, (7*8, %[z])\n\t" /* save z[7] */ + : :[z] "a" (z), [_cPI2_8] "i" (cPI2_8) + : "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", + "a0", "a1", "a2", "a3", "a4", "cc", "memory"); +} + +#define FFT_FFMPEG_INCL_OPTIMISED_TRANSFORM + +static inline FFTComplex* TRANSFORM(FFTComplex * z, unsigned int n, FFTSample wre, FFTSample wim) +{ + asm volatile ("move.l (%[z2]), %%d5\n\t" + "mac.l %%d5, %[wre], (4, %[z2]), %%d4, %%acc0\n\t" + "mac.l %%d4, %[wim], %%acc0\n\t" + "mac.l %%d4, %[wre], (%[z3]), %%d6, %%acc1\n\t" + "msac.l %%d5, %[wim], (4, %[z3]), %%d7, %%acc1\n\t" + "mac.l %%d6, %[wre], (%[z])+, %%d4, %%acc2\n\t" + "msac.l %%d7, %[wim], (%[z])+, %%d5, %%acc2\n\t" + "mac.l %%d7, %[wre], %%acc3\n\t" + "mac.l %%d6, %[wim], %%acc3\n\t" + + "movclr.l %%acc0, %[wre]\n\t" /* t1 */ + "movclr.l %%acc2, %[wim]\n\t" /* t5 */ + + "move.l %%d4, %%d6\n\t" + "move.l %[wim], %%d7\n\t" + "sub.l %[wre], %[wim]\n\t" /* t5 = t5-t1 */ + "add.l %[wre], %%d7\n\t" + "sub.l %%d7, %%d6\n\t" /* d6 = a0re - (t5+t1) => a2re */ + "add.l %%d7, %%d4\n\t" /* d4 = a0re + (t5+t1) => a0re */ + + "movclr.l %%acc3, %%d7\n\t" /* t6 */ + "movclr.l %%acc1, %%d3\n\t" /* t2 */ + + "move.l %%d3, %[wre]\n\t" + "add.l %%d7, %[wre]\n\t" + "sub.l %%d7, %%d3\n\t" /* t2 = t6-t2 */ + "move.l %%d5, %%d7\n\t" + "sub.l %[wre], %%d7\n\t" /* d7 = a0im - (t2+t6) => a2im */ + + "movem.l %%d6-%%d7, (%[z2])\n\t" /* store z2 */ + "add.l %[wre], %%d5\n\t" /* d5 = a0im + (t2+t6) => a0im */ + "movem.l %%d4-%%d5, (-8, %[z])\n\t" /* store z0 */ + + "movem.l (%[z1]), %%d4-%%d5\n\t" /* load z1 */ + "move.l %%d4, %%d6\n\t" + + "sub.l %%d3, %%d6\n\t" /* d6 = a1re - (t2-t6) => a3re */ + "add.l %%d3, %%d4\n\t" /* d4 = a1re + (t2-t6) => a1re */ + + "move.l %%d5, %%d7\n\t" + "sub.l %[wim], %%d7\n\t" + "movem.l %%d6-%%d7, (%[z3])\n\t" /* store z3 */ + "add.l %[wim], %%d5\n\t" + "movem.l %%d4-%%d5, (%[z1])\n\t" /* store z1 */ + + : [wre] "+r" (wre), [wim] "+r" (wim), /* we clobber these after using them */ + [z] "+a" (z) + : [z1] "a" (&z[n]), [z2] "a" (&z[2*n]), [z3] "a" (&z[3*n]) + : "d3", "d4", "d5", "d6", "d7", "cc", "memory"); + return z; +} + +static inline FFTComplex* TRANSFORM_W01(FFTComplex * z, unsigned int n, const FFTSample * w) +{ + return TRANSFORM(z, n, w[0], w[1]); +} + +static inline FFTComplex* TRANSFORM_W10(FFTComplex * z, unsigned int n, const FFTSample * w) +{ + return TRANSFORM(z, n, w[1], w[0]); +} + +static inline FFTComplex* TRANSFORM_ZERO(FFTComplex * z, unsigned int n) +{ + asm volatile("movem.l (%[z]), %%d4-%%d5\n\t" /* load z0 */ + "move.l %%d4, %%d6\n\t" + "movem.l (%[z2]), %%d2-%%d3\n\t" /* load z2 */ + "movem.l (%[z3]), %%d0-%%d1\n\t" /* load z0 */ + "move.l %%d0, %%d7\n\t" + "sub.l %%d2, %%d0\n\t" + "add.l %%d2, %%d7\n\t" + "sub.l %%d7, %%d6\n\t" /* d6 = a0re - (t5+t1) => a2re */ + "add.l %%d7, %%d4\n\t" /* d4 = a0re + (t5+t1) => a0re */ + + "move.l %%d5, %%d7\n\t" + "move.l %%d3, %%d2\n\t" + "add.l %%d1, %%d2\n\t" + "sub.l %%d2, %%d7\n\t" /* d7 = a0im - (t2+t6) => a2im */ + "movem.l %%d6-%%d7, (%[z2])\n\t" /* store z2 */ + "add.l %%d2, %%d5\n\t" /* d5 = a0im + (t2+t6) => a0im */ + "movem.l %%d4-%%d5, (%[z])\n\t" /* store z0 */ + + "movem.l (%[z1]), %%d4-%%d5\n\t" /* load z1 */ + "move.l %%d4, %%d6\n\t" + "sub.l %%d1, %%d3\n\t" + "sub.l %%d3, %%d6\n\t" /* d6 = a1re - (t2-t6) => a3re */ + "add.l %%d3, %%d4\n\t" /* d4 = a1re + (t2-t6) => a1re */ + + "move.l %%d5, %%d7\n\t" + "sub.l %%d0, %%d7\n\t" + "movem.l %%d6-%%d7, (%[z3])\n\t" /* store z3 */ + "add.l %%d0, %%d5\n\t" + + "movem.l %%d4-%%d5, (%[z1])\n\t" /* store z1 */ + + : + : [z] "a" (z), [z1] "a" (&z[n]), [z2] "a" (&z[2*n]), [z3] "a" (&z[3*n]) + : "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", "cc", "memory"); + return z+1; +} + +static inline FFTComplex* TRANSFORM_EQUAL(FFTComplex * z, unsigned int n) +{ + asm volatile ("movem.l (%[z2]), %%d0-%%d1\n\t" + "move.l %[_cPI2_8], %%d2\n\t" + "mac.l %%d0, %%d2, (%[z3]), %%d0, %%acc0\n\t" + "mac.l %%d1, %%d2, (4, %[z3]), %%d1, %%acc1\n\t" + "mac.l %%d0, %%d2, (%[z]), %%d4, %%acc2\n\t" + "mac.l %%d1, %%d2, (4, %[z]), %%d5, %%acc3\n\t" + + "movclr.l %%acc0, %%d0\n\t" + "movclr.l %%acc1, %%d1\n\t" + "movclr.l %%acc2, %%d2\n\t" + "movclr.l %%acc3, %%d3\n\t" + + "move.l %%d0, %%d7\n\t" + "add.l %%d1, %%d0\n\t" /* d0 == t1 */ + "sub.l %%d7, %%d1\n\t" /* d1 == t2 */ + + "move.l %%d3, %%d7\n\t" + "add.l %%d2, %%d3\n\t" /* d3 == t6 */ + "sub.l %%d7, %%d2\n\t" /* d2 == t5 */ + + "move.l %%d4, %%d6\n\t" + "move.l %%d2, %%d7\n\t" + "sub.l %%d0, %%d2\n\t" /* t5 = t5-t1 */ + "add.l %%d0, %%d7\n\t" + "sub.l %%d7, %%d6\n\t" /* d6 = a0re - (t5+t1) => a2re */ + "add.l %%d7, %%d4\n\t" /* d4 = a0re + (t5+t1) => a0re */ + + "move.l %%d1, %%d0\n\t" + "add.l %%d3, %%d0\n\t" + "sub.l %%d3, %%d1\n\t" /* t2 = t6-t2 */ + "move.l %%d5, %%d7\n\t" + "sub.l %%d0, %%d7\n\t" /* d7 = a0im - (t2+t6) => a2im */ + + "movem.l %%d6-%%d7, (%[z2])\n\t" /* store z2 */ + "add.l %%d0, %%d5\n\t" /* d5 = a0im + (t2+t6) => a0im */ + "movem.l %%d4-%%d5, (%[z])\n\t" /* store z0 */ + + "movem.l (%[z1]), %%d4-%%d5\n\t" /* load z1 */ + "move.l %%d4, %%d6\n\t" + + "sub.l %%d1, %%d6\n\t" /* d6 = a1re - (t2-t6) => a3re */ + "add.l %%d1, %%d4\n\t" /* d4 = a1re + (t2-t6) => a1re */ + + "move.l %%d5, %%d7\n\t" + "sub.l %%d2, %%d7\n\t" + "movem.l %%d6-%%d7, (%[z3])\n\t" /* store z3 */ + "add.l %%d2, %%d5\n\t" + "movem.l %%d4-%%d5, (%[z1])\n\t" /* store z1 */ + + :: [z] "a" (z), [z1] "a" (&z[n]), [z2] "a" (&z[2*n]), [z3] "a" (&z[3*n]), + [_cPI2_8] "i" (cPI2_8) + : "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", "cc", "memory"); + + return z+1; +} + +#endif /* CPU_COLDIFRE */ diff --git a/lib/rbcodec/codecs/lib/fft.h b/lib/rbcodec/codecs/lib/fft.h new file mode 100644 index 0000000000..302a3b3996 --- /dev/null +++ b/lib/rbcodec/codecs/lib/fft.h @@ -0,0 +1,64 @@ +/* + * WMA compatible decoder + * Copyright (c) 2002 The FFmpeg Project. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#ifndef CODECLIB_FFT_H_INCLUDED +#define CODECLIB_FFT_H_INCLUDED + +#include +typedef int32_t fixed32; +typedef int64_t fixed64; + +#define FFT_FIXED + +#ifdef FFT_FIXED +typedef fixed32 FFTSample; +#else /* FFT_FIXED */ +typedef float FFTSample; +#endif /* FFT_FIXED */ + +typedef struct FFTComplex { + FFTSample re, im; +} FFTComplex; + +typedef struct FFTContext { + int nbits; + int inverse; + uint16_t *revtab; + int mdct_size; /* size of MDCT (i.e. number of input data * 2) */ + int mdct_bits; /* n = 2^nbits */ + /* pre/post rotation tables */ + FFTSample *tcos; + FFTSample *tsin; + void (*fft_permute)(struct FFTContext *s, FFTComplex *z); + void (*fft_calc)(struct FFTContext *s, FFTComplex *z); + void (*imdct_calc)(struct FFTContext *s, FFTSample *output, const FFTSample *input); + void (*imdct_half)(struct FFTContext *s, FFTSample *output, const FFTSample *input); + void (*mdct_calc)(struct FFTContext *s, FFTSample *output, const FFTSample *input); + int split_radix; + int permutation; +#define FF_MDCT_PERM_NONE 0 +#define FF_MDCT_PERM_INTERLEAVE 1 +} FFTContext; + +// internal api (fft<->mdct) +//int fft_calc_unscaled(FFTContext *s, FFTComplex *z); +//void ff_fft_permute_c(FFTContext *s, FFTComplex *z); // internal only? +void ff_fft_calc_c(int nbits, FFTComplex *z); + +#endif // CODECLIB_FFT_H_INCLUDED + diff --git a/lib/rbcodec/codecs/lib/fixedpoint.c b/lib/rbcodec/codecs/lib/fixedpoint.c new file mode 100644 index 0000000000..a66dcb1270 --- /dev/null +++ b/lib/rbcodec/codecs/lib/fixedpoint.c @@ -0,0 +1 @@ +#include "../../../apps/fixedpoint.c" diff --git a/lib/rbcodec/codecs/lib/fixedpoint.h b/lib/rbcodec/codecs/lib/fixedpoint.h new file mode 100644 index 0000000000..1cbd1573bb --- /dev/null +++ b/lib/rbcodec/codecs/lib/fixedpoint.h @@ -0,0 +1,49 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2006 Jens Arnold + * + * Fixed point library for plugins + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + + /** CODECS - FIXED POINT MATH ROUTINES - USAGE + * + * - x and y arguments are fixed point integers + * - fracbits is the number of fractional bits in the argument(s) + * - functions return long fixed point integers with the specified number + * of fractional bits unless otherwise specified + * + * Calculate sin and cos of an angle: + * fp_sincos(phase, *cos) + * where phase is a 32 bit unsigned integer with 0 representing 0 + * and 0xFFFFFFFF representing 2*pi, and *cos is the address to + * a long signed integer. Value returned is a long signed integer + * from -0x80000000 to 0x7fffffff, representing -1 to 1 respectively. + * That is, value is a fixed point integer with 31 fractional bits. + * + * Take square root of a fixed point number: + * fp_sqrt(x, fracbits) + * + */ +#ifndef _FIXEDPOINT_H_CODECS +#define _FIXEDPOINT_H_CODECS + +long fp_sincos(unsigned long phase, long *cos); +long fp_sqrt(long a, unsigned int fracbits); + +#endif diff --git a/lib/rbcodec/codecs/lib/libcodec.make b/lib/rbcodec/codecs/lib/libcodec.make new file mode 100644 index 0000000000..4931d36b74 --- /dev/null +++ b/lib/rbcodec/codecs/lib/libcodec.make @@ -0,0 +1,37 @@ +# __________ __ ___. +# Open \______ \ ____ ____ | | _\_ |__ _______ ___ +# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / +# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < +# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ +# \/ \/ \/ \/ \/ +# $Id$ +# + +CODECLIB := $(CODECDIR)/libcodec.a +CODECLIB_SRC := $(call preprocess, $(RBCODECLIB_DIR)/codecs/lib/SOURCES) +CODECLIB_OBJ := $(call c2obj, $(CODECLIB_SRC)) +OTHER_SRC += $(CODECLIB_SRC) + +$(CODECLIB): $(CODECLIB_OBJ) + $(SILENT)$(shell rm -f $@) + $(call PRINTS,AR $(@F))$(AR) rcs $@ $^ >/dev/null + +CODECLIBFLAGS = $(filter-out -O%,$(CODECFLAGS)) + +ifeq ($(MEMORYSIZE),2) + CODECLIBFLAGS += -Os +else ifeq ($(ARCH),arch_m68k) + CODECLIBFLAGS += -O2 +else + CODECLIBFLAGS += -O1 +endif + +# Do not use '-ffunction-sections' when compiling sdl-sim +ifneq ($(findstring sdl-sim, $(APP_TYPE)), sdl-sim) + CODECLIBFLAGS += -ffunction-sections +endif + +$(CODECDIR)/lib/%.o: $(RBCODECLIB_DIR)/codecs/lib/%.c + $(SILENT)mkdir -p $(dir $@) + $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) \ + -I$(dir $<) $(CODECLIBFLAGS) -c $< -o $@ diff --git a/lib/rbcodec/codecs/lib/mdct.c b/lib/rbcodec/codecs/lib/mdct.c new file mode 100644 index 0000000000..777aec4a55 --- /dev/null +++ b/lib/rbcodec/codecs/lib/mdct.c @@ -0,0 +1,644 @@ +/* + * Fixed Point IMDCT + * Copyright (c) 2002 The FFmpeg Project. + * Copyright (c) 2010 Dave Hooper, Mohamed Tarek, Michael Giacomelli + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "codeclib.h" +#include "mdct.h" +#include "codeclib_misc.h" +#include "mdct_lookup.h" + +#ifndef ICODE_ATTR_TREMOR_MDCT +#define ICODE_ATTR_TREMOR_MDCT ICODE_ATTR +#endif + +/** + * Compute the middle half of the inverse MDCT of size N = 2^nbits + * thus excluding the parts that can be derived by symmetry + * @param output N/2 samples + * @param input N/2 samples + * + * NOTE - CANNOT CURRENTLY OPERATE IN PLACE (input and output must + * not overlap or intersect at all) + */ +void ff_imdct_half(unsigned int nbits, fixed32 *output, const fixed32 *input) ICODE_ATTR_TREMOR_MDCT; +void ff_imdct_half(unsigned int nbits, fixed32 *output, const fixed32 *input) +{ + int n8, n4, n2, n, j; + const fixed32 *in1, *in2; + (void)j; + n = 1 << nbits; + + n2 = n >> 1; + n4 = n >> 2; + n8 = n >> 3; + + FFTComplex *z = (FFTComplex *)output; + + /* pre rotation */ + in1 = input; + in2 = input + n2 - 1; + + /* revtab comes from the fft; revtab table is sized for N=4096 size fft = 2^12. + The fft is size N/4 so s->nbits-2, so our shift needs to be (12-(nbits-2)) */ + const int revtab_shift = (14- nbits); + + /* bitreverse reorder the input and rotate; result here is in OUTPUT ... */ + /* (note that when using the current split radix, the bitreverse ordering is + complex, meaning that this reordering cannot easily be done in-place) */ + /* Using the following pdf, you can see that it is possible to rearrange + the 'classic' pre/post rotate with an alternative one that enables + us to use fewer distinct twiddle factors. + http://www.eurasip.org/Proceedings/Eusipco/Eusipco2006/papers/1568980508.pdf + + For prerotation, the factors are just sin,cos(2PI*i/N) + For postrotation, the factors are sin,cos(2PI*(i+1/4)/N) + + Therefore, prerotation can immediately reuse the same twiddles as fft + (for postrotation it's still a bit complex, we reuse the fft trig tables + where we can, or a special table for N=2048, or interpolate between + trig tables for N>2048) + */ + const int32_t *T = sincos_lookup0; + const int step = 2<<(12-nbits); + const uint16_t * p_revtab=revtab; + { + const uint16_t * const p_revtab_end = p_revtab + n8; +#ifdef CPU_COLDFIRE + asm volatile ("move.l (%[in2]), %%d0\n\t" + "move.l (%[in1]), %%d1\n\t" + "bra.s 1f\n\t" + "0:\n\t" + "movem.l (%[T]), %%d2-%%d3\n\t" + + "addq.l #8, %[in1]\n\t" + "subq.l #8, %[in2]\n\t" + + "lea (%[step]*4, %[T]), %[T]\n\t" + + "mac.l %%d0, %%d3, (%[T]), %%d4, %%acc0;" + "msac.l %%d1, %%d2, (4, %[T]), %%d5, %%acc0;" + "mac.l %%d1, %%d3, (%[in1]), %%d1, %%acc1;" + "mac.l %%d0, %%d2, (%[in2]), %%d0, %%acc1;" + + "addq.l #8, %[in1]\n\t" + "subq.l #8, %[in2]\n\t" + + "mac.l %%d0, %%d5, %%acc2;" + "msac.l %%d1, %%d4, (%[p_revtab])+, %%d2, %%acc2;" + "mac.l %%d1, %%d5, (%[in1]), %%d1, %%acc3;" + "mac.l %%d0, %%d4, (%[in2]), %%d0, %%acc3;" + + "clr.l %%d3\n\t" + "move.w %%d2, %%d3\n\t" + "eor.l %%d3, %%d2\n\t" + "swap %%d2\n\t" + "lsr.l %[revtab_shift], %%d2\n\t" + + "movclr.l %%acc0, %%d4;" + "movclr.l %%acc1, %%d5;" + "lsl.l #3, %%d2\n\t" + "lea (%%d2, %[z]), %%a1\n\t" + "movem.l %%d4-%%d5, (%%a1)\n\t" + + "lsr.l %[revtab_shift], %%d3\n\t" + + "movclr.l %%acc2, %%d4;" + "movclr.l %%acc3, %%d5;" + "lsl.l #3, %%d3\n\t" + "lea (%%d3, %[z]), %%a1\n\t" + "movem.l %%d4-%%d5, (%%a1)\n\t" + + "lea (%[step]*4, %[T]), %[T]\n\t" + + "1:\n\t" + "cmp.l %[p_revtab_end], %[p_revtab]\n\t" + "bcs.s 0b\n\t" + : [in1] "+a" (in1), [in2] "+a" (in2), [T] "+a" (T), + [p_revtab] "+a" (p_revtab) + : [z] "a" (z), [step] "d" (step), [revtab_shift] "d" (revtab_shift), + [p_revtab_end] "r" (p_revtab_end) + : "d0", "d1", "d2", "d3", "d4", "d5", "a1", "cc", "memory"); +#else + while(LIKELY(p_revtab < p_revtab_end)) + { + j = (*p_revtab)>>revtab_shift; + XNPROD31(*in2, *in1, T[1], T[0], &z[j].re, &z[j].im ); + T += step; + in1 += 2; + in2 -= 2; + p_revtab++; + j = (*p_revtab)>>revtab_shift; + XNPROD31(*in2, *in1, T[1], T[0], &z[j].re, &z[j].im ); + T += step; + in1 += 2; + in2 -= 2; + p_revtab++; + } +#endif + } + { + const uint16_t * const p_revtab_end = p_revtab + n8; +#ifdef CPU_COLDFIRE + asm volatile ("move.l (%[in2]), %%d0\n\t" + "move.l (%[in1]), %%d1\n\t" + "bra.s 1f\n\t" + "0:\n\t" + "movem.l (%[T]), %%d2-%%d3\n\t" + + "addq.l #8, %[in1]\n\t" + "subq.l #8, %[in2]\n\t" + + "lea (%[step]*4, %[T]), %[T]\n\t" + + "mac.l %%d0, %%d2, (%[T]), %%d4, %%acc0;" + "msac.l %%d1, %%d3, (4, %[T]), %%d5, %%acc0;" + "mac.l %%d1, %%d2, (%[in1]), %%d1, %%acc1;" + "mac.l %%d0, %%d3, (%[in2]), %%d0, %%acc1;" + + "addq.l #8, %[in1]\n\t" + "subq.l #8, %[in2]\n\t" + + "mac.l %%d0, %%d4, %%acc2;" + "msac.l %%d1, %%d5, (%[p_revtab])+, %%d2, %%acc2;" + "mac.l %%d1, %%d4, (%[in1]), %%d1, %%acc3;" + "mac.l %%d0, %%d5, (%[in2]), %%d0, %%acc3;" + + "clr.l %%d3\n\t" + "move.w %%d2, %%d3\n\t" + "eor.l %%d3, %%d2\n\t" + "swap %%d2\n\t" + "lsr.l %[revtab_shift], %%d2\n\t" + + "movclr.l %%acc0, %%d4;" + "movclr.l %%acc1, %%d5;" + "lsl.l #3, %%d2\n\t" + "lea (%%d2, %[z]), %%a1\n\t" + "movem.l %%d4-%%d5, (%%a1)\n\t" + + "lsr.l %[revtab_shift], %%d3\n\t" + + "movclr.l %%acc2, %%d4;" + "movclr.l %%acc3, %%d5;" + "lsl.l #3, %%d3\n\t" + "lea (%%d3, %[z]), %%a1\n\t" + "movem.l %%d4-%%d5, (%%a1)\n\t" + + "lea (%[step]*4, %[T]), %[T]\n\t" + + "1:\n\t" + "cmp.l %[p_revtab_end], %[p_revtab]\n\t" + "bcs.s 0b\n\t" + : [in1] "+a" (in1), [in2] "+a" (in2), [T] "+a" (T), + [p_revtab] "+a" (p_revtab) + : [z] "a" (z), [step] "d" (-step), [revtab_shift] "d" (revtab_shift), + [p_revtab_end] "r" (p_revtab_end) + : "d0", "d1", "d2", "d3", "d4", "d5", "a1", "cc", "memory"); +#else + while(LIKELY(p_revtab < p_revtab_end)) + { + j = (*p_revtab)>>revtab_shift; + XNPROD31(*in2, *in1, T[0], T[1], &z[j].re, &z[j].im); + T -= step; + in1 += 2; + in2 -= 2; + p_revtab++; + j = (*p_revtab)>>revtab_shift; + XNPROD31(*in2, *in1, T[0], T[1], &z[j].re, &z[j].im); + T -= step; + in1 += 2; + in2 -= 2; + p_revtab++; + } +#endif + } + + + /* ... and so fft runs in OUTPUT buffer */ + ff_fft_calc_c(nbits-2, z); + + /* post rotation + reordering. now keeps the result within the OUTPUT buffer */ + switch( nbits ) + { + default: + { + fixed32 * z1 = (fixed32 *)(&z[0]); + int magic_step = step>>2; + int newstep; + if(n<=1024) + { + T = sincos_lookup0 + magic_step; + newstep = step>>1; + } + else + { + T = sincos_lookup1; + newstep = 2; + } + +#ifdef CPU_COLDFIRE + fixed32 * z2 = (fixed32 *)(&z[n4]); + int c = n4; + if (newstep == 2) + { + asm volatile ("movem.l (%[z1]), %%d0-%%d1\n\t" + "addq.l #8, %[z1]\n\t" + "movem.l (%[T]), %%d2-%%d3\n\t" + "addq.l #8, %[T]\n\t" + "bra.s 1f\n\t" + "0:\n\t" + "msac.l %%d1, %%d2, (%[T])+, %%a3, %%acc0\n\t" + "mac.l %%d0, %%d3, (%[T])+, %%a4, %%acc0\n\t" + + "msac.l %%d1, %%d3, -(%[z2]), %%d1, %%acc1\n\t" + "msac.l %%d0, %%d2, -(%[z2]), %%d0, %%acc1\n\t" + + "msac.l %%d1, %%a4, (%[T])+, %%d2, %%acc2\n\t" + "mac.l %%d0, %%a3, (%[T])+, %%d3, %%acc2\n\t" + "msac.l %%d0, %%a4, (%[z1])+, %%d0, %%acc3\n\t" + "msac.l %%d1, %%a3, (%[z1])+, %%d1, %%acc3\n\t" + + "movclr.l %%acc0, %%a3\n\t" + "movclr.l %%acc3, %%a4\n\t" + "movem.l %%a3-%%a4, (-16, %[z1])\n\t" + + "movclr.l %%acc1, %%a4\n\t" + "movclr.l %%acc2, %%a3\n\t" + "movem.l %%a3-%%a4, (%[z2])\n\t" + + "subq.l #2, %[n]\n\t" + "1:\n\t" + "bhi.s 0b\n\t" + : [z1] "+a" (z1), [z2] "+a" (z2), [T] "+a" (T), [n] "+d" (c) + : + : "d0", "d1", "d2", "d3", "a3", "a4", "cc", "memory"); + } + else + { + asm volatile ("movem.l (%[z1]), %%d0-%%d1\n\t" + "addq.l #8, %[z1]\n\t" + "movem.l (%[T]), %%d2-%%d3\n\t" + "lea (%[newstep]*4, %[T]), %[T]\n\t" + "bra.s 1f\n\t" + "0:\n\t" + "msac.l %%d1, %%d2, (%[T]), %%a3, %%acc0\n\t" + "mac.l %%d0, %%d3, (4, %[T]), %%a4, %%acc0\n\t" + "msac.l %%d1, %%d3, -(%[z2]), %%d1, %%acc1\n\t" + "msac.l %%d0, %%d2, -(%[z2]), %%d0, %%acc1\n\t" + + "lea (%[newstep]*4, %[T]), %[T]\n\t" + "msac.l %%d1, %%a4, (%[T]), %%d2, %%acc2\n\t" + "mac.l %%d0, %%a3, (4, %[T]), %%d3, %%acc2\n\t" + "msac.l %%d0, %%a4, (%[z1])+, %%d0, %%acc3\n\t" + "msac.l %%d1, %%a3, (%[z1])+, %%d1, %%acc3\n\t" + + "lea (%[newstep]*4, %[T]), %[T]\n\t" + + "movclr.l %%acc0, %%a3\n\t" + "movclr.l %%acc3, %%a4\n\t" + "movem.l %%a3-%%a4, (-16, %[z1])\n\t" + + "movclr.l %%acc1, %%a4\n\t" + "movclr.l %%acc2, %%a3\n\t" + "movem.l %%a3-%%a4, (%[z2])\n\t" + + "subq.l #2, %[n]\n\t" + "1:\n\t" + "bhi.s 0b\n\t" + : [z1] "+a" (z1), [z2] "+a" (z2), [T] "+a" (T), [n] "+d" (c) + : [newstep] "d" (newstep) + : "d0", "d1", "d2", "d3", "a3", "a4", "cc", "memory"); + } +#else + fixed32 * z2 = (fixed32 *)(&z[n4-1]); + while(z1>1; t1=T[1]>>1; + + while(z1>1)); + t1 += (v1 = (V[1]>>1)); + XNPROD31_R(z1[1], z1[0], t0, t1, r0, i1 ); + T+=2; + v0 += (t0 = (T[0]>>1)); + v1 += (t1 = (T[1]>>1)); + XNPROD31_R(z2[1], z2[0], v1, v0, r1, i0 ); + z1[0] = -r0; + z1[1] = -i0; + z2[0] = -r1; + z2[1] = -i1; + z1+=2; + z2-=2; + V+=2; + } + + break; + } + + case 13: /* n = 8192 */ + { + /* weight linear interpolation between sincos_lookup0 and sincos_lookup1 + specifically: 25:75 for first twiddle and 75:25 for second twiddle */ + const int32_t * V = sincos_lookup1; + T = sincos_lookup0; + int32_t t0,t1,v0,v1,q0,q1; + fixed32 * z1 = (fixed32 *)(&z[0]); + fixed32 * z2 = (fixed32 *)(&z[n4-1]); + + t0 = T[0]; t1=T[1]; + + while(z1>1); + t1 += (q1 = (v1-t1)>>1); + XNPROD31_R(z1[1], z1[0], t0, t1, r0, i1 ); + t0 = v0-q0; + t1 = v1-q1; + XNPROD31_R(z2[1], z2[0], t1, t0, r1, i0 ); + z1[0] = -r0; + z1[1] = -i0; + z2[0] = -r1; + z2[1] = -i1; + z1+=2; + z2-=2; + T+=2; + + t0 = T[0]; t1 = T[1]; + v0 += (q0 = (t0-v0)>>1); + v1 += (q1 = (t1-v1)>>1); + XNPROD31_R(z1[1], z1[0], v0, v1, r0, i1 ); + v0 = t0-q0; + v1 = t1-q1; + XNPROD31_R(z2[1], z2[0], v1, v0, r1, i0 ); + z1[0] = -r0; + z1[1] = -i0; + z2[0] = -r1; + z2[1] = -i1; + z1+=2; + z2-=2; + V+=2; + } + + break; + } + } +} + +/** + * Compute inverse MDCT of size N = 2^nbits + * @param output N samples + * @param input N/2 samples + * "In-place" processing can be achieved provided that: + * [0 .. N/2-1 | N/2 .. N-1 ] + * <----input----> + * <-----------output-----------> + * + * The result of ff_imdct_half is to put the 'half' imdct here + * + * N/2 N-1 + * <--half imdct--> + * + * We want it here for the full imdct: + * N/4 3N/4-1 + * <--------------> + * + * In addition we need to apply two symmetries to get the full imdct: + * + * + * + * + * D is a reflection of C + * A is a reflection of B (but with sign flipped) + * + * We process the symmetries at the same time as we 'move' the half imdct + * from [N/2,N-1] to [N/4,3N/4-1] + * + * TODO: find a way to make ff_imdct_half put the result in [N/4..3N/4-1] + * This would require being able to use revtab 'inplace' (since the input + * and output of imdct_half would then overlap somewhat) + */ +void ff_imdct_calc(unsigned int nbits, fixed32 *output, const fixed32 *input) ICODE_ATTR_TREMOR_MDCT; +#ifndef CPU_ARM +void ff_imdct_calc(unsigned int nbits, fixed32 *output, const fixed32 *input) +{ + const int n = (1<>1); + const int n4 = (n>>2); + + /* tell imdct_half to put the output in [N/2..3N/4-1] i.e. output+n2 */ + ff_imdct_half(nbits,output+n2,input); + + fixed32 * in_r, * in_r2, * out_r, * out_r2; + + /* Copy BBBB to AAAA, reflected and sign-flipped. + Also copy BBBB to its correct destination (from [N/2..3N/4-1] to [N/4..N/2-1]) */ + out_r = output; + out_r2 = output+n2-8; + in_r = output+n2+n4-8; + while(out_r <- ^b ^c -> <- ^d + * + * #1: copy from ^c to ^a + * #2: copy from ^d to ^b + * #3: swap ^c and ^d in place + */ + /* #1 pt1 : load 4 words from ^c. */ + t0=in_r[0]; t1=in_r[1]; t2=in_r[2]; t3=in_r[3]; + /* #1 pt2 : write to ^a */ + out_r[0]=t0;out_r[1]=t1;out_r[2]=t2;out_r[3]=t3; + /* #2 pt1 : load 4 words from ^d */ + s0=in_r2[0];s1=in_r2[1];s2=in_r2[2];s3=in_r2[3]; + /* #2 pt2 : write to ^b */ + out_r2[0]=s0;out_r2[1]=s1;out_r2[2]=s2;out_r2[3]=s3; + /* #3 pt1 : write words from #2 to ^c */ + in_r[0]=s3;in_r[1]=s2;in_r[2]=s1;in_r[3]=s0; + /* #3 pt2 : write words from #1 to ^d */ + in_r2[0]=t3;in_r2[1]=t2;in_r2[2]=t1;in_r2[3]=t0; + + in_r += 4; + in_r2 -= 4; + out_r += 4; + out_r2 -= 4; +#endif + } +} +#else +/* Follows the same structure as the canonical version above */ +void ff_imdct_calc(unsigned int nbits, fixed32 *output, const fixed32 *input) +{ + const int n = (1<>1); + const int n4 = (n>>2); + + ff_imdct_half(nbits,output+n2,input); + + fixed32 * in_r, * in_r2, * out_r, * out_r2; + + out_r = output; + out_r2 = output+n2; + in_r = output+n2+n4; + while(out_r>= 31; //16+31-16 = 31 bits + + return (fixed32)temp; +} +#endif + + +#ifdef CPU_ARM +static inline +void CMUL(fixed32 *x, fixed32 *y, + fixed32 a, fixed32 b, + fixed32 t, fixed32 v) +{ + /* This version loses one bit of precision. Could be solved at the cost + * of 2 extra cycles if it becomes an issue. */ + int x1, y1, l; + asm( + "smull %[l], %[y1], %[b], %[t] \n" + "smlal %[l], %[y1], %[a], %[v] \n" + "rsb %[b], %[b], #0 \n" + "smull %[l], %[x1], %[a], %[t] \n" + "smlal %[l], %[x1], %[b], %[v] \n" + : [l] "=&r" (l), [x1]"=&r" (x1), [y1]"=&r" (y1), [b] "+r" (b) + : [a] "r" (a), [t] "r" (t), [v] "r" (v) + : "cc" + ); + *x = x1 << 1; + *y = y1 << 1; +} +#elif defined CPU_COLDFIRE +static inline +void CMUL(fixed32 *x, fixed32 *y, + fixed32 a, fixed32 b, + fixed32 t, fixed32 v) +{ + asm volatile ("mac.l %[a], %[t], %%acc0;" + "msac.l %[b], %[v], %%acc0;" + "mac.l %[b], %[t], %%acc1;" + "mac.l %[a], %[v], %%acc1;" + "movclr.l %%acc0, %[a];" + "move.l %[a], (%[x]);" + "movclr.l %%acc1, %[a];" + "move.l %[a], (%[y]);" + : [a] "+&r" (a) + : [x] "a" (x), [y] "a" (y), + [b] "r" (b), [t] "r" (t), [v] "r" (v) + : "cc", "memory"); +} +#else +static inline +void CMUL(fixed32 *pre, + fixed32 *pim, + fixed32 are, + fixed32 aim, + fixed32 bre, + fixed32 bim) +{ + //int64_t x,y; + fixed32 _aref = are; + fixed32 _aimf = aim; + fixed32 _bref = bre; + fixed32 _bimf = bim; + fixed32 _r1 = fixmul32b(_bref, _aref); + fixed32 _r2 = fixmul32b(_bimf, _aimf); + fixed32 _r3 = fixmul32b(_bref, _aimf); + fixed32 _r4 = fixmul32b(_bimf, _aref); + *pre = _r1 - _r2; + *pim = _r3 + _r4; + +} +#endif + + +#endif // CODECLIB_MDCT_H_INCLUDED diff --git a/lib/rbcodec/codecs/lib/mdct_lookup.c b/lib/rbcodec/codecs/lib/mdct_lookup.c new file mode 100644 index 0000000000..a8ca748206 --- /dev/null +++ b/lib/rbcodec/codecs/lib/mdct_lookup.c @@ -0,0 +1,872 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2009 Michael Giacomelli + * + * + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#ifdef ROCKBOX +#include +#else +#include +#include +#endif /* ROCKBOX */ + +/* {sin(2*i*PI/4096, cos(2*i*PI/4096)}, with i = 0 to 512 */ +const int32_t sincos_lookup0[1026] ICONST_ATTR = { + 0x00000000, 0x7fffffff, 0x003243f5, 0x7ffff621, + 0x006487e3, 0x7fffd886, 0x0096cbc1, 0x7fffa72c, + 0x00c90f88, 0x7fff6216, 0x00fb5330, 0x7fff0943, + 0x012d96b1, 0x7ffe9cb2, 0x015fda03, 0x7ffe1c65, + 0x01921d20, 0x7ffd885a, 0x01c45ffe, 0x7ffce093, + 0x01f6a297, 0x7ffc250f, 0x0228e4e2, 0x7ffb55ce, + 0x025b26d7, 0x7ffa72d1, 0x028d6870, 0x7ff97c18, + 0x02bfa9a4, 0x7ff871a2, 0x02f1ea6c, 0x7ff75370, + 0x03242abf, 0x7ff62182, 0x03566a96, 0x7ff4dbd9, + 0x0388a9ea, 0x7ff38274, 0x03bae8b2, 0x7ff21553, + 0x03ed26e6, 0x7ff09478, 0x041f6480, 0x7feeffe1, + 0x0451a177, 0x7fed5791, 0x0483ddc3, 0x7feb9b85, + 0x04b6195d, 0x7fe9cbc0, 0x04e8543e, 0x7fe7e841, + 0x051a8e5c, 0x7fe5f108, 0x054cc7b1, 0x7fe3e616, + 0x057f0035, 0x7fe1c76b, 0x05b137df, 0x7fdf9508, + 0x05e36ea9, 0x7fdd4eec, 0x0615a48b, 0x7fdaf519, + 0x0647d97c, 0x7fd8878e, 0x067a0d76, 0x7fd6064c, + 0x06ac406f, 0x7fd37153, 0x06de7262, 0x7fd0c8a3, + 0x0710a345, 0x7fce0c3e, 0x0742d311, 0x7fcb3c23, + 0x077501be, 0x7fc85854, 0x07a72f45, 0x7fc560cf, + 0x07d95b9e, 0x7fc25596, 0x080b86c2, 0x7fbf36aa, + 0x083db0a7, 0x7fbc040a, 0x086fd947, 0x7fb8bdb8, + 0x08a2009a, 0x7fb563b3, 0x08d42699, 0x7fb1f5fc, + 0x09064b3a, 0x7fae7495, 0x09386e78, 0x7faadf7c, + 0x096a9049, 0x7fa736b4, 0x099cb0a7, 0x7fa37a3c, + 0x09cecf89, 0x7f9faa15, 0x0a00ece8, 0x7f9bc640, + 0x0a3308bd, 0x7f97cebd, 0x0a6522fe, 0x7f93c38c, + 0x0a973ba5, 0x7f8fa4b0, 0x0ac952aa, 0x7f8b7227, + 0x0afb6805, 0x7f872bf3, 0x0b2d7baf, 0x7f82d214, + 0x0b5f8d9f, 0x7f7e648c, 0x0b919dcf, 0x7f79e35a, + 0x0bc3ac35, 0x7f754e80, 0x0bf5b8cb, 0x7f70a5fe, + 0x0c27c389, 0x7f6be9d4, 0x0c59cc68, 0x7f671a05, + 0x0c8bd35e, 0x7f62368f, 0x0cbdd865, 0x7f5d3f75, + 0x0cefdb76, 0x7f5834b7, 0x0d21dc87, 0x7f531655, + 0x0d53db92, 0x7f4de451, 0x0d85d88f, 0x7f489eaa, + 0x0db7d376, 0x7f434563, 0x0de9cc40, 0x7f3dd87c, + 0x0e1bc2e4, 0x7f3857f6, 0x0e4db75b, 0x7f32c3d1, + 0x0e7fa99e, 0x7f2d1c0e, 0x0eb199a4, 0x7f2760af, + 0x0ee38766, 0x7f2191b4, 0x0f1572dc, 0x7f1baf1e, + 0x0f475bff, 0x7f15b8ee, 0x0f7942c7, 0x7f0faf25, + 0x0fab272b, 0x7f0991c4, 0x0fdd0926, 0x7f0360cb, + 0x100ee8ad, 0x7efd1c3c, 0x1040c5bb, 0x7ef6c418, + 0x1072a048, 0x7ef05860, 0x10a4784b, 0x7ee9d914, + 0x10d64dbd, 0x7ee34636, 0x11082096, 0x7edc9fc6, + 0x1139f0cf, 0x7ed5e5c6, 0x116bbe60, 0x7ecf1837, + 0x119d8941, 0x7ec8371a, 0x11cf516a, 0x7ec14270, + 0x120116d5, 0x7eba3a39, 0x1232d979, 0x7eb31e78, + 0x1264994e, 0x7eabef2c, 0x1296564d, 0x7ea4ac58, + 0x12c8106f, 0x7e9d55fc, 0x12f9c7aa, 0x7e95ec1a, + 0x132b7bf9, 0x7e8e6eb2, 0x135d2d53, 0x7e86ddc6, + 0x138edbb1, 0x7e7f3957, 0x13c0870a, 0x7e778166, + 0x13f22f58, 0x7e6fb5f4, 0x1423d492, 0x7e67d703, + 0x145576b1, 0x7e5fe493, 0x148715ae, 0x7e57dea7, + 0x14b8b17f, 0x7e4fc53e, 0x14ea4a1f, 0x7e47985b, + 0x151bdf86, 0x7e3f57ff, 0x154d71aa, 0x7e37042a, + 0x157f0086, 0x7e2e9cdf, 0x15b08c12, 0x7e26221f, + 0x15e21445, 0x7e1d93ea, 0x16139918, 0x7e14f242, + 0x16451a83, 0x7e0c3d29, 0x1676987f, 0x7e0374a0, + 0x16a81305, 0x7dfa98a8, 0x16d98a0c, 0x7df1a942, + 0x170afd8d, 0x7de8a670, 0x173c6d80, 0x7ddf9034, + 0x176dd9de, 0x7dd6668f, 0x179f429f, 0x7dcd2981, + 0x17d0a7bc, 0x7dc3d90d, 0x1802092c, 0x7dba7534, + 0x183366e9, 0x7db0fdf8, 0x1864c0ea, 0x7da77359, + 0x18961728, 0x7d9dd55a, 0x18c7699b, 0x7d9423fc, + 0x18f8b83c, 0x7d8a5f40, 0x192a0304, 0x7d808728, + 0x195b49ea, 0x7d769bb5, 0x198c8ce7, 0x7d6c9ce9, + 0x19bdcbf3, 0x7d628ac6, 0x19ef0707, 0x7d58654d, + 0x1a203e1b, 0x7d4e2c7f, 0x1a517128, 0x7d43e05e, + 0x1a82a026, 0x7d3980ec, 0x1ab3cb0d, 0x7d2f0e2b, + 0x1ae4f1d6, 0x7d24881b, 0x1b161479, 0x7d19eebf, + 0x1b4732ef, 0x7d0f4218, 0x1b784d30, 0x7d048228, + 0x1ba96335, 0x7cf9aef0, 0x1bda74f6, 0x7ceec873, + 0x1c0b826a, 0x7ce3ceb2, 0x1c3c8b8c, 0x7cd8c1ae, + 0x1c6d9053, 0x7ccda169, 0x1c9e90b8, 0x7cc26de5, + 0x1ccf8cb3, 0x7cb72724, 0x1d00843d, 0x7cabcd28, + 0x1d31774d, 0x7ca05ff1, 0x1d6265dd, 0x7c94df83, + 0x1d934fe5, 0x7c894bde, 0x1dc4355e, 0x7c7da505, + 0x1df5163f, 0x7c71eaf9, 0x1e25f282, 0x7c661dbc, + 0x1e56ca1e, 0x7c5a3d50, 0x1e879d0d, 0x7c4e49b7, + 0x1eb86b46, 0x7c4242f2, 0x1ee934c3, 0x7c362904, + 0x1f19f97b, 0x7c29fbee, 0x1f4ab968, 0x7c1dbbb3, + 0x1f7b7481, 0x7c116853, 0x1fac2abf, 0x7c0501d2, + 0x1fdcdc1b, 0x7bf88830, 0x200d888d, 0x7bebfb70, + 0x203e300d, 0x7bdf5b94, 0x206ed295, 0x7bd2a89e, + 0x209f701c, 0x7bc5e290, 0x20d0089c, 0x7bb9096b, + 0x21009c0c, 0x7bac1d31, 0x21312a65, 0x7b9f1de6, + 0x2161b3a0, 0x7b920b89, 0x219237b5, 0x7b84e61f, + 0x21c2b69c, 0x7b77ada8, 0x21f3304f, 0x7b6a6227, + 0x2223a4c5, 0x7b5d039e, 0x225413f8, 0x7b4f920e, + 0x22847de0, 0x7b420d7a, 0x22b4e274, 0x7b3475e5, + 0x22e541af, 0x7b26cb4f, 0x23159b88, 0x7b190dbc, + 0x2345eff8, 0x7b0b3d2c, 0x23763ef7, 0x7afd59a4, + 0x23a6887f, 0x7aef6323, 0x23d6cc87, 0x7ae159ae, + 0x24070b08, 0x7ad33d45, 0x243743fa, 0x7ac50dec, + 0x24677758, 0x7ab6cba4, 0x2497a517, 0x7aa8766f, + 0x24c7cd33, 0x7a9a0e50, 0x24f7efa2, 0x7a8b9348, + 0x25280c5e, 0x7a7d055b, 0x2558235f, 0x7a6e648a, + 0x2588349d, 0x7a5fb0d8, 0x25b84012, 0x7a50ea47, + 0x25e845b6, 0x7a4210d8, 0x26184581, 0x7a332490, + 0x26483f6c, 0x7a24256f, 0x26783370, 0x7a151378, + 0x26a82186, 0x7a05eead, 0x26d809a5, 0x79f6b711, + 0x2707ebc7, 0x79e76ca7, 0x2737c7e3, 0x79d80f6f, + 0x27679df4, 0x79c89f6e, 0x27976df1, 0x79b91ca4, + 0x27c737d3, 0x79a98715, 0x27f6fb92, 0x7999dec4, + 0x2826b928, 0x798a23b1, 0x2856708d, 0x797a55e0, + 0x288621b9, 0x796a7554, 0x28b5cca5, 0x795a820e, + 0x28e5714b, 0x794a7c12, 0x29150fa1, 0x793a6361, + 0x2944a7a2, 0x792a37fe, 0x29743946, 0x7919f9ec, + 0x29a3c485, 0x7909a92d, 0x29d34958, 0x78f945c3, + 0x2a02c7b8, 0x78e8cfb2, 0x2a323f9e, 0x78d846fb, + 0x2a61b101, 0x78c7aba2, 0x2a911bdc, 0x78b6fda8, + 0x2ac08026, 0x78a63d11, 0x2aefddd8, 0x789569df, + 0x2b1f34eb, 0x78848414, 0x2b4e8558, 0x78738bb3, + 0x2b7dcf17, 0x786280bf, 0x2bad1221, 0x7851633b, + 0x2bdc4e6f, 0x78403329, 0x2c0b83fa, 0x782ef08b, + 0x2c3ab2b9, 0x781d9b65, 0x2c69daa6, 0x780c33b8, + 0x2c98fbba, 0x77fab989, 0x2cc815ee, 0x77e92cd9, + 0x2cf72939, 0x77d78daa, 0x2d263596, 0x77c5dc01, + 0x2d553afc, 0x77b417df, 0x2d843964, 0x77a24148, + 0x2db330c7, 0x7790583e, 0x2de2211e, 0x777e5cc3, + 0x2e110a62, 0x776c4edb, 0x2e3fec8b, 0x775a2e89, + 0x2e6ec792, 0x7747fbce, 0x2e9d9b70, 0x7735b6af, + 0x2ecc681e, 0x77235f2d, 0x2efb2d95, 0x7710f54c, + 0x2f29ebcc, 0x76fe790e, 0x2f58a2be, 0x76ebea77, + 0x2f875262, 0x76d94989, 0x2fb5fab2, 0x76c69647, + 0x2fe49ba7, 0x76b3d0b4, 0x30133539, 0x76a0f8d2, + 0x3041c761, 0x768e0ea6, 0x30705217, 0x767b1231, + 0x309ed556, 0x76680376, 0x30cd5115, 0x7654e279, + 0x30fbc54d, 0x7641af3d, 0x312a31f8, 0x762e69c4, + 0x3158970e, 0x761b1211, 0x3186f487, 0x7607a828, + 0x31b54a5e, 0x75f42c0b, 0x31e39889, 0x75e09dbd, + 0x3211df04, 0x75ccfd42, 0x32401dc6, 0x75b94a9c, + 0x326e54c7, 0x75a585cf, 0x329c8402, 0x7591aedd, + 0x32caab6f, 0x757dc5ca, 0x32f8cb07, 0x7569ca99, + 0x3326e2c3, 0x7555bd4c, 0x3354f29b, 0x75419de7, + 0x3382fa88, 0x752d6c6c, 0x33b0fa84, 0x751928e0, + 0x33def287, 0x7504d345, 0x340ce28b, 0x74f06b9e, + 0x343aca87, 0x74dbf1ef, 0x3468aa76, 0x74c7663a, + 0x34968250, 0x74b2c884, 0x34c4520d, 0x749e18cd, + 0x34f219a8, 0x7489571c, 0x351fd918, 0x74748371, + 0x354d9057, 0x745f9dd1, 0x357b3f5d, 0x744aa63f, + 0x35a8e625, 0x74359cbd, 0x35d684a6, 0x74208150, + 0x36041ad9, 0x740b53fb, 0x3631a8b8, 0x73f614c0, + 0x365f2e3b, 0x73e0c3a3, 0x368cab5c, 0x73cb60a8, + 0x36ba2014, 0x73b5ebd1, 0x36e78c5b, 0x73a06522, + 0x3714f02a, 0x738acc9e, 0x37424b7b, 0x73752249, + 0x376f9e46, 0x735f6626, 0x379ce885, 0x73499838, + 0x37ca2a30, 0x7333b883, 0x37f76341, 0x731dc70a, + 0x382493b0, 0x7307c3d0, 0x3851bb77, 0x72f1aed9, + 0x387eda8e, 0x72db8828, 0x38abf0ef, 0x72c54fc1, + 0x38d8fe93, 0x72af05a7, 0x39060373, 0x7298a9dd, + 0x3932ff87, 0x72823c67, 0x395ff2c9, 0x726bbd48, + 0x398cdd32, 0x72552c85, 0x39b9bebc, 0x723e8a20, + 0x39e6975e, 0x7227d61c, 0x3a136712, 0x7211107e, + 0x3a402dd2, 0x71fa3949, 0x3a6ceb96, 0x71e35080, + 0x3a99a057, 0x71cc5626, 0x3ac64c0f, 0x71b54a41, + 0x3af2eeb7, 0x719e2cd2, 0x3b1f8848, 0x7186fdde, + 0x3b4c18ba, 0x716fbd68, 0x3b78a007, 0x71586b74, + 0x3ba51e29, 0x71410805, 0x3bd19318, 0x7129931f, + 0x3bfdfecd, 0x71120cc5, 0x3c2a6142, 0x70fa74fc, + 0x3c56ba70, 0x70e2cbc6, 0x3c830a50, 0x70cb1128, + 0x3caf50da, 0x70b34525, 0x3cdb8e09, 0x709b67c0, + 0x3d07c1d6, 0x708378ff, 0x3d33ec39, 0x706b78e3, + 0x3d600d2c, 0x70536771, 0x3d8c24a8, 0x703b44ad, + 0x3db832a6, 0x7023109a, 0x3de4371f, 0x700acb3c, + 0x3e10320d, 0x6ff27497, 0x3e3c2369, 0x6fda0cae, + 0x3e680b2c, 0x6fc19385, 0x3e93e950, 0x6fa90921, + 0x3ebfbdcd, 0x6f906d84, 0x3eeb889c, 0x6f77c0b3, + 0x3f1749b8, 0x6f5f02b2, 0x3f430119, 0x6f463383, + 0x3f6eaeb8, 0x6f2d532c, 0x3f9a5290, 0x6f1461b0, + 0x3fc5ec98, 0x6efb5f12, 0x3ff17cca, 0x6ee24b57, + 0x401d0321, 0x6ec92683, 0x40487f94, 0x6eaff099, + 0x4073f21d, 0x6e96a99d, 0x409f5ab6, 0x6e7d5193, + 0x40cab958, 0x6e63e87f, 0x40f60dfb, 0x6e4a6e66, + 0x4121589b, 0x6e30e34a, 0x414c992f, 0x6e174730, + 0x4177cfb1, 0x6dfd9a1c, 0x41a2fc1a, 0x6de3dc11, + 0x41ce1e65, 0x6dca0d14, 0x41f93689, 0x6db02d29, + 0x42244481, 0x6d963c54, 0x424f4845, 0x6d7c3a98, + 0x427a41d0, 0x6d6227fa, 0x42a5311b, 0x6d48047e, + 0x42d0161e, 0x6d2dd027, 0x42faf0d4, 0x6d138afb, + 0x4325c135, 0x6cf934fc, 0x4350873c, 0x6cdece2f, + 0x437b42e1, 0x6cc45698, 0x43a5f41e, 0x6ca9ce3b, + 0x43d09aed, 0x6c8f351c, 0x43fb3746, 0x6c748b3f, + 0x4425c923, 0x6c59d0a9, 0x4450507e, 0x6c3f055d, + 0x447acd50, 0x6c242960, 0x44a53f93, 0x6c093cb6, + 0x44cfa740, 0x6bee3f62, 0x44fa0450, 0x6bd3316a, + 0x452456bd, 0x6bb812d1, 0x454e9e80, 0x6b9ce39b, + 0x4578db93, 0x6b81a3cd, 0x45a30df0, 0x6b66536b, + 0x45cd358f, 0x6b4af279, 0x45f7526b, 0x6b2f80fb, + 0x4621647d, 0x6b13fef5, 0x464b6bbe, 0x6af86c6c, + 0x46756828, 0x6adcc964, 0x469f59b4, 0x6ac115e2, + 0x46c9405c, 0x6aa551e9, 0x46f31c1a, 0x6a897d7d, + 0x471cece7, 0x6a6d98a4, 0x4746b2bc, 0x6a51a361, + 0x47706d93, 0x6a359db9, 0x479a1d67, 0x6a1987b0, + 0x47c3c22f, 0x69fd614a, 0x47ed5be6, 0x69e12a8c, + 0x4816ea86, 0x69c4e37a, 0x48406e08, 0x69a88c19, + 0x4869e665, 0x698c246c, 0x48935397, 0x696fac78, + 0x48bcb599, 0x69532442, 0x48e60c62, 0x69368bce, + 0x490f57ee, 0x6919e320, 0x49389836, 0x68fd2a3d, + 0x4961cd33, 0x68e06129, 0x498af6df, 0x68c387e9, + 0x49b41533, 0x68a69e81, 0x49dd282a, 0x6889a4f6, + 0x4a062fbd, 0x686c9b4b, 0x4a2f2be6, 0x684f8186, + 0x4a581c9e, 0x683257ab, 0x4a8101de, 0x68151dbe, + 0x4aa9dba2, 0x67f7d3c5, 0x4ad2a9e2, 0x67da79c3, + 0x4afb6c98, 0x67bd0fbd, 0x4b2423be, 0x679f95b7, + 0x4b4ccf4d, 0x67820bb7, 0x4b756f40, 0x676471c0, + 0x4b9e0390, 0x6746c7d8, 0x4bc68c36, 0x67290e02, + 0x4bef092d, 0x670b4444, 0x4c177a6e, 0x66ed6aa1, + 0x4c3fdff4, 0x66cf8120, 0x4c6839b7, 0x66b187c3, + 0x4c9087b1, 0x66937e91, 0x4cb8c9dd, 0x6675658c, + 0x4ce10034, 0x66573cbb, 0x4d092ab0, 0x66390422, + 0x4d31494b, 0x661abbc5, 0x4d595bfe, 0x65fc63a9, + 0x4d8162c4, 0x65ddfbd3, 0x4da95d96, 0x65bf8447, + 0x4dd14c6e, 0x65a0fd0b, 0x4df92f46, 0x65826622, + 0x4e210617, 0x6563bf92, 0x4e48d0dd, 0x6545095f, + 0x4e708f8f, 0x6526438f, 0x4e984229, 0x65076e25, + 0x4ebfe8a5, 0x64e88926, 0x4ee782fb, 0x64c99498, + 0x4f0f1126, 0x64aa907f, 0x4f369320, 0x648b7ce0, + 0x4f5e08e3, 0x646c59bf, 0x4f857269, 0x644d2722, + 0x4faccfab, 0x642de50d, 0x4fd420a4, 0x640e9386, + 0x4ffb654d, 0x63ef3290, 0x50229da1, 0x63cfc231, + 0x5049c999, 0x63b0426d, 0x5070e92f, 0x6390b34a, + 0x5097fc5e, 0x637114cc, 0x50bf031f, 0x635166f9, + 0x50e5fd6d, 0x6331a9d4, 0x510ceb40, 0x6311dd64, + 0x5133cc94, 0x62f201ac, 0x515aa162, 0x62d216b3, + 0x518169a5, 0x62b21c7b, 0x51a82555, 0x6292130c, + 0x51ced46e, 0x6271fa69, 0x51f576ea, 0x6251d298, + 0x521c0cc2, 0x62319b9d, 0x524295f0, 0x6211557e, + 0x5269126e, 0x61f1003f, 0x528f8238, 0x61d09be5, + 0x52b5e546, 0x61b02876, 0x52dc3b92, 0x618fa5f7, + 0x53028518, 0x616f146c, 0x5328c1d0, 0x614e73da, + 0x534ef1b5, 0x612dc447, 0x537514c2, 0x610d05b7, + 0x539b2af0, 0x60ec3830, 0x53c13439, 0x60cb5bb7, + 0x53e73097, 0x60aa7050, 0x540d2005, 0x60897601, + 0x5433027d, 0x60686ccf, 0x5458d7f9, 0x604754bf, + 0x547ea073, 0x60262dd6, 0x54a45be6, 0x6004f819, + 0x54ca0a4b, 0x5fe3b38d, 0x54efab9c, 0x5fc26038, + 0x55153fd4, 0x5fa0fe1f, 0x553ac6ee, 0x5f7f8d46, + 0x556040e2, 0x5f5e0db3, 0x5585adad, 0x5f3c7f6b, + 0x55ab0d46, 0x5f1ae274, 0x55d05faa, 0x5ef936d1, + 0x55f5a4d2, 0x5ed77c8a, 0x561adcb9, 0x5eb5b3a2, + 0x56400758, 0x5e93dc1f, 0x566524aa, 0x5e71f606, + 0x568a34a9, 0x5e50015d, 0x56af3750, 0x5e2dfe29, + 0x56d42c99, 0x5e0bec6e, 0x56f9147e, 0x5de9cc33, + 0x571deefa, 0x5dc79d7c, 0x5742bc06, 0x5da5604f, + 0x57677b9d, 0x5d8314b1, 0x578c2dba, 0x5d60baa7, + 0x57b0d256, 0x5d3e5237, 0x57d5696d, 0x5d1bdb65, + 0x57f9f2f8, 0x5cf95638, 0x581e6ef1, 0x5cd6c2b5, + 0x5842dd54, 0x5cb420e0, 0x58673e1b, 0x5c9170bf, + 0x588b9140, 0x5c6eb258, 0x58afd6bd, 0x5c4be5b0, + 0x58d40e8c, 0x5c290acc, 0x58f838a9, 0x5c0621b2, + 0x591c550e, 0x5be32a67, 0x594063b5, 0x5bc024f0, + 0x59646498, 0x5b9d1154, 0x598857b2, 0x5b79ef96, + 0x59ac3cfd, 0x5b56bfbd, 0x59d01475, 0x5b3381ce, + 0x59f3de12, 0x5b1035cf, 0x5a1799d1, 0x5aecdbc5, + 0x5a3b47ab, 0x5ac973b5, 0x5a5ee79a, 0x5aa5fda5, + 0x5a82799a, 0x5a82799a + }; + + /* {sin((2*i+1)*PI/4096, cos((2*i+1)*PI/4096)}, with i = 0 to 511 */ +const int32_t sincos_lookup1[1024] ICONST_ATTR = { + 0x001921fb, 0x7ffffd88, 0x004b65ee, 0x7fffe9cb, + 0x007da9d4, 0x7fffc251, 0x00afeda8, 0x7fff8719, + 0x00e23160, 0x7fff3824, 0x011474f6, 0x7ffed572, + 0x0146b860, 0x7ffe5f03, 0x0178fb99, 0x7ffdd4d7, + 0x01ab3e97, 0x7ffd36ee, 0x01dd8154, 0x7ffc8549, + 0x020fc3c6, 0x7ffbbfe6, 0x024205e8, 0x7ffae6c7, + 0x027447b0, 0x7ff9f9ec, 0x02a68917, 0x7ff8f954, + 0x02d8ca16, 0x7ff7e500, 0x030b0aa4, 0x7ff6bcf0, + 0x033d4abb, 0x7ff58125, 0x036f8a51, 0x7ff4319d, + 0x03a1c960, 0x7ff2ce5b, 0x03d407df, 0x7ff1575d, + 0x040645c7, 0x7fefcca4, 0x04388310, 0x7fee2e30, + 0x046abfb3, 0x7fec7c02, 0x049cfba7, 0x7feab61a, + 0x04cf36e5, 0x7fe8dc78, 0x05017165, 0x7fe6ef1c, + 0x0533ab20, 0x7fe4ee06, 0x0565e40d, 0x7fe2d938, + 0x05981c26, 0x7fe0b0b1, 0x05ca5361, 0x7fde7471, + 0x05fc89b8, 0x7fdc247a, 0x062ebf22, 0x7fd9c0ca, + 0x0660f398, 0x7fd74964, 0x06932713, 0x7fd4be46, + 0x06c5598a, 0x7fd21f72, 0x06f78af6, 0x7fcf6ce8, + 0x0729bb4e, 0x7fcca6a7, 0x075bea8c, 0x7fc9ccb2, + 0x078e18a7, 0x7fc6df08, 0x07c04598, 0x7fc3dda9, + 0x07f27157, 0x7fc0c896, 0x08249bdd, 0x7fbd9fd0, + 0x0856c520, 0x7fba6357, 0x0888ed1b, 0x7fb7132b, + 0x08bb13c5, 0x7fb3af4e, 0x08ed3916, 0x7fb037bf, + 0x091f5d06, 0x7facac7f, 0x09517f8f, 0x7fa90d8e, + 0x0983a0a7, 0x7fa55aee, 0x09b5c048, 0x7fa1949e, + 0x09e7de6a, 0x7f9dbaa0, 0x0a19fb04, 0x7f99ccf4, + 0x0a4c1610, 0x7f95cb9a, 0x0a7e2f85, 0x7f91b694, + 0x0ab0475c, 0x7f8d8de1, 0x0ae25d8d, 0x7f895182, + 0x0b147211, 0x7f850179, 0x0b4684df, 0x7f809dc5, + 0x0b7895f0, 0x7f7c2668, 0x0baaa53b, 0x7f779b62, + 0x0bdcb2bb, 0x7f72fcb4, 0x0c0ebe66, 0x7f6e4a5e, + 0x0c40c835, 0x7f698461, 0x0c72d020, 0x7f64aabf, + 0x0ca4d620, 0x7f5fbd77, 0x0cd6da2d, 0x7f5abc8a, + 0x0d08dc3f, 0x7f55a7fa, 0x0d3adc4e, 0x7f507fc7, + 0x0d6cda53, 0x7f4b43f2, 0x0d9ed646, 0x7f45f47b, + 0x0dd0d01f, 0x7f409164, 0x0e02c7d7, 0x7f3b1aad, + 0x0e34bd66, 0x7f359057, 0x0e66b0c3, 0x7f2ff263, + 0x0e98a1e9, 0x7f2a40d2, 0x0eca90ce, 0x7f247ba5, + 0x0efc7d6b, 0x7f1ea2dc, 0x0f2e67b8, 0x7f18b679, + 0x0f604faf, 0x7f12b67c, 0x0f923546, 0x7f0ca2e7, + 0x0fc41876, 0x7f067bba, 0x0ff5f938, 0x7f0040f6, + 0x1027d784, 0x7ef9f29d, 0x1059b352, 0x7ef390ae, + 0x108b8c9b, 0x7eed1b2c, 0x10bd6356, 0x7ee69217, + 0x10ef377d, 0x7edff570, 0x11210907, 0x7ed94538, + 0x1152d7ed, 0x7ed28171, 0x1184a427, 0x7ecbaa1a, + 0x11b66dad, 0x7ec4bf36, 0x11e83478, 0x7ebdc0c6, + 0x1219f880, 0x7eb6aeca, 0x124bb9be, 0x7eaf8943, + 0x127d7829, 0x7ea85033, 0x12af33ba, 0x7ea1039b, + 0x12e0ec6a, 0x7e99a37c, 0x1312a230, 0x7e922fd6, + 0x13445505, 0x7e8aa8ac, 0x137604e2, 0x7e830dff, + 0x13a7b1bf, 0x7e7b5fce, 0x13d95b93, 0x7e739e1d, + 0x140b0258, 0x7e6bc8eb, 0x143ca605, 0x7e63e03b, + 0x146e4694, 0x7e5be40c, 0x149fe3fc, 0x7e53d462, + 0x14d17e36, 0x7e4bb13c, 0x1503153a, 0x7e437a9c, + 0x1534a901, 0x7e3b3083, 0x15663982, 0x7e32d2f4, + 0x1597c6b7, 0x7e2a61ed, 0x15c95097, 0x7e21dd73, + 0x15fad71b, 0x7e194584, 0x162c5a3b, 0x7e109a24, + 0x165dd9f0, 0x7e07db52, 0x168f5632, 0x7dff0911, + 0x16c0cef9, 0x7df62362, 0x16f2443e, 0x7ded2a47, + 0x1723b5f9, 0x7de41dc0, 0x17552422, 0x7ddafdce, + 0x17868eb3, 0x7dd1ca75, 0x17b7f5a3, 0x7dc883b4, + 0x17e958ea, 0x7dbf298d, 0x181ab881, 0x7db5bc02, + 0x184c1461, 0x7dac3b15, 0x187d6c82, 0x7da2a6c6, + 0x18aec0db, 0x7d98ff17, 0x18e01167, 0x7d8f4409, + 0x19115e1c, 0x7d85759f, 0x1942a6f3, 0x7d7b93da, + 0x1973ebe6, 0x7d719eba, 0x19a52ceb, 0x7d679642, + 0x19d669fc, 0x7d5d7a74, 0x1a07a311, 0x7d534b50, + 0x1a38d823, 0x7d4908d9, 0x1a6a0929, 0x7d3eb30f, + 0x1a9b361d, 0x7d3449f5, 0x1acc5ef6, 0x7d29cd8c, + 0x1afd83ad, 0x7d1f3dd6, 0x1b2ea43a, 0x7d149ad5, + 0x1b5fc097, 0x7d09e489, 0x1b90d8bb, 0x7cff1af5, + 0x1bc1ec9e, 0x7cf43e1a, 0x1bf2fc3a, 0x7ce94dfb, + 0x1c240786, 0x7cde4a98, 0x1c550e7c, 0x7cd333f3, + 0x1c861113, 0x7cc80a0f, 0x1cb70f43, 0x7cbcccec, + 0x1ce80906, 0x7cb17c8d, 0x1d18fe54, 0x7ca618f3, + 0x1d49ef26, 0x7c9aa221, 0x1d7adb73, 0x7c8f1817, + 0x1dabc334, 0x7c837ad8, 0x1ddca662, 0x7c77ca65, + 0x1e0d84f5, 0x7c6c06c0, 0x1e3e5ee5, 0x7c602fec, + 0x1e6f342c, 0x7c5445e9, 0x1ea004c1, 0x7c4848ba, + 0x1ed0d09d, 0x7c3c3860, 0x1f0197b8, 0x7c3014de, + 0x1f325a0b, 0x7c23de35, 0x1f63178f, 0x7c179467, + 0x1f93d03c, 0x7c0b3777, 0x1fc4840a, 0x7bfec765, + 0x1ff532f2, 0x7bf24434, 0x2025dcec, 0x7be5ade6, + 0x205681f1, 0x7bd9047c, 0x208721f9, 0x7bcc47fa, + 0x20b7bcfe, 0x7bbf7860, 0x20e852f6, 0x7bb295b0, + 0x2118e3dc, 0x7ba59fee, 0x21496fa7, 0x7b989719, + 0x2179f64f, 0x7b8b7b36, 0x21aa77cf, 0x7b7e4c45, + 0x21daf41d, 0x7b710a49, 0x220b6b32, 0x7b63b543, + 0x223bdd08, 0x7b564d36, 0x226c4996, 0x7b48d225, + 0x229cb0d5, 0x7b3b4410, 0x22cd12bd, 0x7b2da2fa, + 0x22fd6f48, 0x7b1feee5, 0x232dc66d, 0x7b1227d3, + 0x235e1826, 0x7b044dc7, 0x238e646a, 0x7af660c2, + 0x23beab33, 0x7ae860c7, 0x23eeec78, 0x7ada4dd8, + 0x241f2833, 0x7acc27f7, 0x244f5e5c, 0x7abdef25, + 0x247f8eec, 0x7aafa367, 0x24afb9da, 0x7aa144bc, + 0x24dfdf20, 0x7a92d329, 0x250ffeb7, 0x7a844eae, + 0x25401896, 0x7a75b74f, 0x25702cb7, 0x7a670d0d, + 0x25a03b11, 0x7a584feb, 0x25d0439f, 0x7a497feb, + 0x26004657, 0x7a3a9d0f, 0x26304333, 0x7a2ba75a, + 0x26603a2c, 0x7a1c9ece, 0x26902b39, 0x7a0d836d, + 0x26c01655, 0x79fe5539, 0x26effb76, 0x79ef1436, + 0x271fda96, 0x79dfc064, 0x274fb3ae, 0x79d059c8, + 0x277f86b5, 0x79c0e062, 0x27af53a6, 0x79b15435, + 0x27df1a77, 0x79a1b545, 0x280edb23, 0x79920392, + 0x283e95a1, 0x79823f20, 0x286e49ea, 0x797267f2, + 0x289df7f8, 0x79627e08, 0x28cd9fc1, 0x79528167, + 0x28fd4140, 0x79427210, 0x292cdc6d, 0x79325006, + 0x295c7140, 0x79221b4b, 0x298bffb2, 0x7911d3e2, + 0x29bb87bc, 0x790179cd, 0x29eb0957, 0x78f10d0f, + 0x2a1a847b, 0x78e08dab, 0x2a49f920, 0x78cffba3, + 0x2a796740, 0x78bf56f9, 0x2aa8ced3, 0x78ae9fb0, + 0x2ad82fd2, 0x789dd5cb, 0x2b078a36, 0x788cf94c, + 0x2b36ddf7, 0x787c0a36, 0x2b662b0e, 0x786b088c, + 0x2b957173, 0x7859f44f, 0x2bc4b120, 0x7848cd83, + 0x2bf3ea0d, 0x7837942b, 0x2c231c33, 0x78264849, + 0x2c52478a, 0x7814e9df, 0x2c816c0c, 0x780378f1, + 0x2cb089b1, 0x77f1f581, 0x2cdfa071, 0x77e05f91, + 0x2d0eb046, 0x77ceb725, 0x2d3db928, 0x77bcfc3f, + 0x2d6cbb10, 0x77ab2ee2, 0x2d9bb5f6, 0x77994f11, + 0x2dcaa9d5, 0x77875cce, 0x2df996a3, 0x7775581d, + 0x2e287c5a, 0x776340ff, 0x2e575af3, 0x77511778, + 0x2e863267, 0x773edb8b, 0x2eb502ae, 0x772c8d3a, + 0x2ee3cbc1, 0x771a2c88, 0x2f128d99, 0x7707b979, + 0x2f41482e, 0x76f5340e, 0x2f6ffb7a, 0x76e29c4b, + 0x2f9ea775, 0x76cff232, 0x2fcd4c19, 0x76bd35c7, + 0x2ffbe95d, 0x76aa670d, 0x302a7f3a, 0x76978605, + 0x30590dab, 0x768492b4, 0x308794a6, 0x76718d1c, + 0x30b61426, 0x765e7540, 0x30e48c22, 0x764b4b23, + 0x3112fc95, 0x76380ec8, 0x31416576, 0x7624c031, + 0x316fc6be, 0x76115f63, 0x319e2067, 0x75fdec60, + 0x31cc7269, 0x75ea672a, 0x31fabcbd, 0x75d6cfc5, + 0x3228ff5c, 0x75c32634, 0x32573a3f, 0x75af6a7b, + 0x32856d5e, 0x759b9c9b, 0x32b398b3, 0x7587bc98, + 0x32e1bc36, 0x7573ca75, 0x330fd7e1, 0x755fc635, + 0x333debab, 0x754bafdc, 0x336bf78f, 0x7537876c, + 0x3399fb85, 0x75234ce8, 0x33c7f785, 0x750f0054, + 0x33f5eb89, 0x74faa1b3, 0x3423d78a, 0x74e63108, + 0x3451bb81, 0x74d1ae55, 0x347f9766, 0x74bd199f, + 0x34ad6b32, 0x74a872e8, 0x34db36df, 0x7493ba34, + 0x3508fa66, 0x747eef85, 0x3536b5be, 0x746a12df, + 0x356468e2, 0x74552446, 0x359213c9, 0x744023bc, + 0x35bfb66e, 0x742b1144, 0x35ed50c9, 0x7415ece2, + 0x361ae2d3, 0x7400b69a, 0x36486c86, 0x73eb6e6e, + 0x3675edd9, 0x73d61461, 0x36a366c6, 0x73c0a878, + 0x36d0d746, 0x73ab2ab4, 0x36fe3f52, 0x73959b1b, + 0x372b9ee3, 0x737ff9ae, 0x3758f5f2, 0x736a4671, + 0x37864477, 0x73548168, 0x37b38a6d, 0x733eaa96, + 0x37e0c7cc, 0x7328c1ff, 0x380dfc8d, 0x7312c7a5, + 0x383b28a9, 0x72fcbb8c, 0x38684c19, 0x72e69db7, + 0x389566d6, 0x72d06e2b, 0x38c278d9, 0x72ba2cea, + 0x38ef821c, 0x72a3d9f7, 0x391c8297, 0x728d7557, + 0x39497a43, 0x7276ff0d, 0x39766919, 0x7260771b, + 0x39a34f13, 0x7249dd86, 0x39d02c2a, 0x72333251, + 0x39fd0056, 0x721c7580, 0x3a29cb91, 0x7205a716, + 0x3a568dd4, 0x71eec716, 0x3a834717, 0x71d7d585, + 0x3aaff755, 0x71c0d265, 0x3adc9e86, 0x71a9bdba, + 0x3b093ca3, 0x71929789, 0x3b35d1a5, 0x717b5fd3, + 0x3b625d86, 0x7164169d, 0x3b8ee03e, 0x714cbbeb, + 0x3bbb59c7, 0x71354fc0, 0x3be7ca1a, 0x711dd220, + 0x3c143130, 0x7106430e, 0x3c408f03, 0x70eea28e, + 0x3c6ce38a, 0x70d6f0a4, 0x3c992ec0, 0x70bf2d53, + 0x3cc5709e, 0x70a7589f, 0x3cf1a91c, 0x708f728b, + 0x3d1dd835, 0x70777b1c, 0x3d49fde1, 0x705f7255, + 0x3d761a19, 0x70475839, 0x3da22cd7, 0x702f2ccd, + 0x3dce3614, 0x7016f014, 0x3dfa35c8, 0x6ffea212, + 0x3e262bee, 0x6fe642ca, 0x3e52187f, 0x6fcdd241, + 0x3e7dfb73, 0x6fb5507a, 0x3ea9d4c3, 0x6f9cbd79, + 0x3ed5a46b, 0x6f841942, 0x3f016a61, 0x6f6b63d8, + 0x3f2d26a0, 0x6f529d40, 0x3f58d921, 0x6f39c57d, + 0x3f8481dd, 0x6f20dc92, 0x3fb020ce, 0x6f07e285, + 0x3fdbb5ec, 0x6eeed758, 0x40074132, 0x6ed5bb10, + 0x4032c297, 0x6ebc8db0, 0x405e3a16, 0x6ea34f3d, + 0x4089a7a8, 0x6e89ffb9, 0x40b50b46, 0x6e709f2a, + 0x40e064ea, 0x6e572d93, 0x410bb48c, 0x6e3daaf8, + 0x4136fa27, 0x6e24175c, 0x416235b2, 0x6e0a72c5, + 0x418d6729, 0x6df0bd35, 0x41b88e84, 0x6dd6f6b1, + 0x41e3abbc, 0x6dbd1f3c, 0x420ebecb, 0x6da336dc, + 0x4239c7aa, 0x6d893d93, 0x4264c653, 0x6d6f3365, + 0x428fbabe, 0x6d551858, 0x42baa4e6, 0x6d3aec6e, + 0x42e584c3, 0x6d20afac, 0x43105a50, 0x6d066215, + 0x433b2585, 0x6cec03af, 0x4365e65b, 0x6cd1947c, + 0x43909ccd, 0x6cb71482, 0x43bb48d4, 0x6c9c83c3, + 0x43e5ea68, 0x6c81e245, 0x44108184, 0x6c67300b, + 0x443b0e21, 0x6c4c6d1a, 0x44659039, 0x6c319975, + 0x449007c4, 0x6c16b521, 0x44ba74bd, 0x6bfbc021, + 0x44e4d71c, 0x6be0ba7b, 0x450f2edb, 0x6bc5a431, + 0x45397bf4, 0x6baa7d49, 0x4563be60, 0x6b8f45c7, + 0x458df619, 0x6b73fdae, 0x45b82318, 0x6b58a503, + 0x45e24556, 0x6b3d3bcb, 0x460c5cce, 0x6b21c208, + 0x46366978, 0x6b0637c1, 0x46606b4e, 0x6aea9cf8, + 0x468a624a, 0x6acef1b2, 0x46b44e65, 0x6ab335f4, + 0x46de2f99, 0x6a9769c1, 0x470805df, 0x6a7b8d1e, + 0x4731d131, 0x6a5fa010, 0x475b9188, 0x6a43a29a, + 0x478546de, 0x6a2794c1, 0x47aef12c, 0x6a0b7689, + 0x47d8906d, 0x69ef47f6, 0x48022499, 0x69d3090e, + 0x482badab, 0x69b6b9d3, 0x48552b9b, 0x699a5a4c, + 0x487e9e64, 0x697dea7b, 0x48a805ff, 0x69616a65, + 0x48d16265, 0x6944da10, 0x48fab391, 0x6928397e, + 0x4923f97b, 0x690b88b5, 0x494d341e, 0x68eec7b9, + 0x49766373, 0x68d1f68f, 0x499f8774, 0x68b5153a, + 0x49c8a01b, 0x689823bf, 0x49f1ad61, 0x687b2224, + 0x4a1aaf3f, 0x685e106c, 0x4a43a5b0, 0x6840ee9b, + 0x4a6c90ad, 0x6823bcb7, 0x4a957030, 0x68067ac3, + 0x4abe4433, 0x67e928c5, 0x4ae70caf, 0x67cbc6c0, + 0x4b0fc99d, 0x67ae54ba, 0x4b387af9, 0x6790d2b6, + 0x4b6120bb, 0x677340ba, 0x4b89badd, 0x67559eca, + 0x4bb24958, 0x6737ecea, 0x4bdacc28, 0x671a2b20, + 0x4c034345, 0x66fc596f, 0x4c2baea9, 0x66de77dc, + 0x4c540e4e, 0x66c0866d, 0x4c7c622d, 0x66a28524, + 0x4ca4aa41, 0x66847408, 0x4ccce684, 0x6666531d, + 0x4cf516ee, 0x66482267, 0x4d1d3b7a, 0x6629e1ec, + 0x4d455422, 0x660b91af, 0x4d6d60df, 0x65ed31b5, + 0x4d9561ac, 0x65cec204, 0x4dbd5682, 0x65b0429f, + 0x4de53f5a, 0x6591b38c, 0x4e0d1c30, 0x657314cf, + 0x4e34ecfc, 0x6554666d, 0x4e5cb1b9, 0x6535a86b, + 0x4e846a60, 0x6516dacd, 0x4eac16eb, 0x64f7fd98, + 0x4ed3b755, 0x64d910d1, 0x4efb4b96, 0x64ba147d, + 0x4f22d3aa, 0x649b08a0, 0x4f4a4f89, 0x647bed3f, + 0x4f71bf2e, 0x645cc260, 0x4f992293, 0x643d8806, + 0x4fc079b1, 0x641e3e38, 0x4fe7c483, 0x63fee4f8, + 0x500f0302, 0x63df7c4d, 0x50363529, 0x63c0043b, + 0x505d5af1, 0x63a07cc7, 0x50847454, 0x6380e5f6, + 0x50ab814d, 0x63613fcd, 0x50d281d5, 0x63418a50, + 0x50f975e6, 0x6321c585, 0x51205d7b, 0x6301f171, + 0x5147388c, 0x62e20e17, 0x516e0715, 0x62c21b7e, + 0x5194c910, 0x62a219aa, 0x51bb7e75, 0x628208a1, + 0x51e22740, 0x6261e866, 0x5208c36a, 0x6241b8ff, + 0x522f52ee, 0x62217a72, 0x5255d5c5, 0x62012cc2, + 0x527c4bea, 0x61e0cff5, 0x52a2b556, 0x61c06410, + 0x52c91204, 0x619fe918, 0x52ef61ee, 0x617f5f12, + 0x5315a50e, 0x615ec603, 0x533bdb5d, 0x613e1df0, + 0x536204d7, 0x611d66de, 0x53882175, 0x60fca0d2, + 0x53ae3131, 0x60dbcbd1, 0x53d43406, 0x60bae7e1, + 0x53fa29ed, 0x6099f505, 0x542012e1, 0x6078f344, + 0x5445eedb, 0x6057e2a2, 0x546bbdd7, 0x6036c325, + 0x54917fce, 0x601594d1, 0x54b734ba, 0x5ff457ad, + 0x54dcdc96, 0x5fd30bbc, 0x5502775c, 0x5fb1b104, + 0x55280505, 0x5f90478a, 0x554d858d, 0x5f6ecf53, + 0x5572f8ed, 0x5f4d4865, 0x55985f20, 0x5f2bb2c5, + 0x55bdb81f, 0x5f0a0e77, 0x55e303e6, 0x5ee85b82, + 0x5608426e, 0x5ec699e9, 0x562d73b2, 0x5ea4c9b3, + 0x565297ab, 0x5e82eae5, 0x5677ae54, 0x5e60fd84, + 0x569cb7a8, 0x5e3f0194, 0x56c1b3a1, 0x5e1cf71c, + 0x56e6a239, 0x5dfade20, 0x570b8369, 0x5dd8b6a7, + 0x5730572e, 0x5db680b4, 0x57551d80, 0x5d943c4e, + 0x5779d65b, 0x5d71e979, 0x579e81b8, 0x5d4f883b, + 0x57c31f92, 0x5d2d189a, 0x57e7afe4, 0x5d0a9a9a, + 0x580c32a7, 0x5ce80e41, 0x5830a7d6, 0x5cc57394, + 0x58550f6c, 0x5ca2ca99, 0x58796962, 0x5c801354, + 0x589db5b3, 0x5c5d4dcc, 0x58c1f45b, 0x5c3a7a05, + 0x58e62552, 0x5c179806, 0x590a4893, 0x5bf4a7d2, + 0x592e5e19, 0x5bd1a971, 0x595265df, 0x5bae9ce7, + 0x59765fde, 0x5b8b8239, 0x599a4c12, 0x5b68596d, + 0x59be2a74, 0x5b452288, 0x59e1faff, 0x5b21dd90, + 0x5a05bdae, 0x5afe8a8b, 0x5a29727b, 0x5adb297d, + 0x5a4d1960, 0x5ab7ba6c, 0x5a70b258, 0x5a943d5e, +}; + +/*split radix bit reverse table for FFT of size up to 2048*/ + +const uint16_t revtab[1<<12] = { +0, 3072, 1536, 2816, 768, 3840, 1408, 2432, 384, 3456, 1920, 2752, 704, +3776, 1216, 2240, 192, 3264, 1728, 3008, 960, 4032, 1376, 2400, 352, 3424, +1888, 2656, 608, 3680, 1120, 2144, 96, 3168, 1632, 2912, 864, 3936, 1504, +2528, 480, 3552, 2016, 2736, 688, 3760, 1200, 2224, 176, 3248, 1712, 2992, +944, 4016, 1328, 2352, 304, 3376, 1840, 2608, 560, 3632, 1072, 2096, 48, +3120, 1584, 2864, 816, 3888, 1456, 2480, 432, 3504, 1968, 2800, 752, 3824, +1264, 2288, 240, 3312, 1776, 3056, 1008, 4080, 1368, 2392, 344, 3416, 1880, +2648, 600, 3672, 1112, 2136, 88, 3160, 1624, 2904, 856, 3928, 1496, 2520, +472, 3544, 2008, 2712, 664, 3736, 1176, 2200, 152, 3224, 1688, 2968, 920, +3992, 1304, 2328, 280, 3352, 1816, 2584, 536, 3608, 1048, 2072, 24, 3096, +1560, 2840, 792, 3864, 1432, 2456, 408, 3480, 1944, 2776, 728, 3800, 1240, +2264, 216, 3288, 1752, 3032, 984, 4056, 1400, 2424, 376, 3448, 1912, 2680, +632, 3704, 1144, 2168, 120, 3192, 1656, 2936, 888, 3960, 1528, 2552, 504, +3576, 2040, 2732, 684, 3756, 1196, 2220, 172, 3244, 1708, 2988, 940, 4012, +1324, 2348, 300, 3372, 1836, 2604, 556, 3628, 1068, 2092, 44, 3116, 1580, +2860, 812, 3884, 1452, 2476, 428, 3500, 1964, 2796, 748, 3820, 1260, 2284, +236, 3308, 1772, 3052, 1004, 4076, 1356, 2380, 332, 3404, 1868, 2636, 588, +3660, 1100, 2124, 76, 3148, 1612, 2892, 844, 3916, 1484, 2508, 460, 3532, +1996, 2700, 652, 3724, 1164, 2188, 140, 3212, 1676, 2956, 908, 3980, 1292, +2316, 268, 3340, 1804, 2572, 524, 3596, 1036, 2060, 12, 3084, 1548, 2828, +780, 3852, 1420, 2444, 396, 3468, 1932, 2764, 716, 3788, 1228, 2252, 204, +3276, 1740, 3020, 972, 4044, 1388, 2412, 364, 3436, 1900, 2668, 620, 3692, +1132, 2156, 108, 3180, 1644, 2924, 876, 3948, 1516, 2540, 492, 3564, 2028, +2748, 700, 3772, 1212, 2236, 188, 3260, 1724, 3004, 956, 4028, 1340, 2364, +316, 3388, 1852, 2620, 572, 3644, 1084, 2108, 60, 3132, 1596, 2876, 828, +3900, 1468, 2492, 444, 3516, 1980, 2812, 764, 3836, 1276, 2300, 252, 3324, +1788, 3068, 1020, 4092, 1366, 2390, 342, 3414, 1878, 2646, 598, 3670, 1110, +2134, 86, 3158, 1622, 2902, 854, 3926, 1494, 2518, 470, 3542, 2006, 2710, +662, 3734, 1174, 2198, 150, 3222, 1686, 2966, 918, 3990, 1302, 2326, 278, +3350, 1814, 2582, 534, 3606, 1046, 2070, 22, 3094, 1558, 2838, 790, 3862, +1430, 2454, 406, 3478, 1942, 2774, 726, 3798, 1238, 2262, 214, 3286, 1750, +3030, 982, 4054, 1398, 2422, 374, 3446, 1910, 2678, 630, 3702, 1142, 2166, +118, 3190, 1654, 2934, 886, 3958, 1526, 2550, 502, 3574, 2038, 2726, 678, +3750, 1190, 2214, 166, 3238, 1702, 2982, 934, 4006, 1318, 2342, 294, 3366, +1830, 2598, 550, 3622, 1062, 2086, 38, 3110, 1574, 2854, 806, 3878, 1446, +2470, 422, 3494, 1958, 2790, 742, 3814, 1254, 2278, 230, 3302, 1766, 3046, +998, 4070, 1350, 2374, 326, 3398, 1862, 2630, 582, 3654, 1094, 2118, 70, +3142, 1606, 2886, 838, 3910, 1478, 2502, 454, 3526, 1990, 2694, 646, 3718, +1158, 2182, 134, 3206, 1670, 2950, 902, 3974, 1286, 2310, 262, 3334, 1798, +2566, 518, 3590, 1030, 2054, 6, 3078, 1542, 2822, 774, 3846, 1414, 2438, +390, 3462, 1926, 2758, 710, 3782, 1222, 2246, 198, 3270, 1734, 3014, 966, +4038, 1382, 2406, 358, 3430, 1894, 2662, 614, 3686, 1126, 2150, 102, 3174, +1638, 2918, 870, 3942, 1510, 2534, 486, 3558, 2022, 2742, 694, 3766, 1206, +2230, 182, 3254, 1718, 2998, 950, 4022, 1334, 2358, 310, 3382, 1846, 2614, +566, 3638, 1078, 2102, 54, 3126, 1590, 2870, 822, 3894, 1462, 2486, 438, +3510, 1974, 2806, 758, 3830, 1270, 2294, 246, 3318, 1782, 3062, 1014, 4086, +1374, 2398, 350, 3422, 1886, 2654, 606, 3678, 1118, 2142, 94, 3166, 1630, +2910, 862, 3934, 1502, 2526, 478, 3550, 2014, 2718, 670, 3742, 1182, 2206, +158, 3230, 1694, 2974, 926, 3998, 1310, 2334, 286, 3358, 1822, 2590, 542, +3614, 1054, 2078, 30, 3102, 1566, 2846, 798, 3870, 1438, 2462, 414, 3486, +1950, 2782, 734, 3806, 1246, 2270, 222, 3294, 1758, 3038, 990, 4062, 1406, +2430, 382, 3454, 1918, 2686, 638, 3710, 1150, 2174, 126, 3198, 1662, 2942, +894, 3966, 1534, 2558, 510, 3582, 2046, 2731, 683, 3755, 1195, 2219, 171, +3243, 1707, 2987, 939, 4011, 1323, 2347, 299, 3371, 1835, 2603, 555, 3627, +1067, 2091, 43, 3115, 1579, 2859, 811, 3883, 1451, 2475, 427, 3499, 1963, +2795, 747, 3819, 1259, 2283, 235, 3307, 1771, 3051, 1003, 4075, 1355, 2379, +331, 3403, 1867, 2635, 587, 3659, 1099, 2123, 75, 3147, 1611, 2891, 843, +3915, 1483, 2507, 459, 3531, 1995, 2699, 651, 3723, 1163, 2187, 139, 3211, +1675, 2955, 907, 3979, 1291, 2315, 267, 3339, 1803, 2571, 523, 3595, 1035, +2059, 11, 3083, 1547, 2827, 779, 3851, 1419, 2443, 395, 3467, 1931, 2763, +715, 3787, 1227, 2251, 203, 3275, 1739, 3019, 971, 4043, 1387, 2411, 363, +3435, 1899, 2667, 619, 3691, 1131, 2155, 107, 3179, 1643, 2923, 875, 3947, +1515, 2539, 491, 3563, 2027, 2747, 699, 3771, 1211, 2235, 187, 3259, 1723, +3003, 955, 4027, 1339, 2363, 315, 3387, 1851, 2619, 571, 3643, 1083, 2107, +59, 3131, 1595, 2875, 827, 3899, 1467, 2491, 443, 3515, 1979, 2811, 763, +3835, 1275, 2299, 251, 3323, 1787, 3067, 1019, 4091, 1363, 2387, 339, 3411, +1875, 2643, 595, 3667, 1107, 2131, 83, 3155, 1619, 2899, 851, 3923, 1491, +2515, 467, 3539, 2003, 2707, 659, 3731, 1171, 2195, 147, 3219, 1683, 2963, +915, 3987, 1299, 2323, 275, 3347, 1811, 2579, 531, 3603, 1043, 2067, 19, +3091, 1555, 2835, 787, 3859, 1427, 2451, 403, 3475, 1939, 2771, 723, 3795, +1235, 2259, 211, 3283, 1747, 3027, 979, 4051, 1395, 2419, 371, 3443, 1907, +2675, 627, 3699, 1139, 2163, 115, 3187, 1651, 2931, 883, 3955, 1523, 2547, +499, 3571, 2035, 2723, 675, 3747, 1187, 2211, 163, 3235, 1699, 2979, 931, +4003, 1315, 2339, 291, 3363, 1827, 2595, 547, 3619, 1059, 2083, 35, 3107, +1571, 2851, 803, 3875, 1443, 2467, 419, 3491, 1955, 2787, 739, 3811, 1251, +2275, 227, 3299, 1763, 3043, 995, 4067, 1347, 2371, 323, 3395, 1859, 2627, +579, 3651, 1091, 2115, 67, 3139, 1603, 2883, 835, 3907, 1475, 2499, 451, +3523, 1987, 2691, 643, 3715, 1155, 2179, 131, 3203, 1667, 2947, 899, 3971, +1283, 2307, 259, 3331, 1795, 2563, 515, 3587, 1027, 2051, 3, 3075, 1539, +2819, 771, 3843, 1411, 2435, 387, 3459, 1923, 2755, 707, 3779, 1219, 2243, +195, 3267, 1731, 3011, 963, 4035, 1379, 2403, 355, 3427, 1891, 2659, 611, +3683, 1123, 2147, 99, 3171, 1635, 2915, 867, 3939, 1507, 2531, 483, 3555, +2019, 2739, 691, 3763, 1203, 2227, 179, 3251, 1715, 2995, 947, 4019, 1331, +2355, 307, 3379, 1843, 2611, 563, 3635, 1075, 2099, 51, 3123, 1587, 2867, +819, 3891, 1459, 2483, 435, 3507, 1971, 2803, 755, 3827, 1267, 2291, 243, +3315, 1779, 3059, 1011, 4083, 1371, 2395, 347, 3419, 1883, 2651, 603, 3675, +1115, 2139, 91, 3163, 1627, 2907, 859, 3931, 1499, 2523, 475, 3547, 2011, +2715, 667, 3739, 1179, 2203, 155, 3227, 1691, 2971, 923, 3995, 1307, 2331, +283, 3355, 1819, 2587, 539, 3611, 1051, 2075, 27, 3099, 1563, 2843, 795, +3867, 1435, 2459, 411, 3483, 1947, 2779, 731, 3803, 1243, 2267, 219, 3291, +1755, 3035, 987, 4059, 1403, 2427, 379, 3451, 1915, 2683, 635, 3707, 1147, +2171, 123, 3195, 1659, 2939, 891, 3963, 1531, 2555, 507, 3579, 2043, 2735, +687, 3759, 1199, 2223, 175, 3247, 1711, 2991, 943, 4015, 1327, 2351, 303, +3375, 1839, 2607, 559, 3631, 1071, 2095, 47, 3119, 1583, 2863, 815, 3887, +1455, 2479, 431, 3503, 1967, 2799, 751, 3823, 1263, 2287, 239, 3311, 1775, +3055, 1007, 4079, 1359, 2383, 335, 3407, 1871, 2639, 591, 3663, 1103, 2127, +79, 3151, 1615, 2895, 847, 3919, 1487, 2511, 463, 3535, 1999, 2703, 655, +3727, 1167, 2191, 143, 3215, 1679, 2959, 911, 3983, 1295, 2319, 271, 3343, +1807, 2575, 527, 3599, 1039, 2063, 15, 3087, 1551, 2831, 783, 3855, 1423, +2447, 399, 3471, 1935, 2767, 719, 3791, 1231, 2255, 207, 3279, 1743, 3023, +975, 4047, 1391, 2415, 367, 3439, 1903, 2671, 623, 3695, 1135, 2159, 111, +3183, 1647, 2927, 879, 3951, 1519, 2543, 495, 3567, 2031, 2751, 703, 3775, +1215, 2239, 191, 3263, 1727, 3007, 959, 4031, 1343, 2367, 319, 3391, 1855, +2623, 575, 3647, 1087, 2111, 63, 3135, 1599, 2879, 831, 3903, 1471, 2495, +447, 3519, 1983, 2815, 767, 3839, 1279, 2303, 255, 3327, 1791, 3071, 1023, +4095, 1365, 2389, 341, 3413, 1877, 2645, 597, 3669, 1109, 2133, 85, 3157, +1621, 2901, 853, 3925, 1493, 2517, 469, 3541, 2005, 2709, 661, 3733, 1173, +2197, 149, 3221, 1685, 2965, 917, 3989, 1301, 2325, 277, 3349, 1813, 2581, +533, 3605, 1045, 2069, 21, 3093, 1557, 2837, 789, 3861, 1429, 2453, 405, +3477, 1941, 2773, 725, 3797, 1237, 2261, 213, 3285, 1749, 3029, 981, 4053, +1397, 2421, 373, 3445, 1909, 2677, 629, 3701, 1141, 2165, 117, 3189, 1653, +2933, 885, 3957, 1525, 2549, 501, 3573, 2037, 2725, 677, 3749, 1189, 2213, +165, 3237, 1701, 2981, 933, 4005, 1317, 2341, 293, 3365, 1829, 2597, 549, +3621, 1061, 2085, 37, 3109, 1573, 2853, 805, 3877, 1445, 2469, 421, 3493, +1957, 2789, 741, 3813, 1253, 2277, 229, 3301, 1765, 3045, 997, 4069, 1349, +2373, 325, 3397, 1861, 2629, 581, 3653, 1093, 2117, 69, 3141, 1605, 2885, +837, 3909, 1477, 2501, 453, 3525, 1989, 2693, 645, 3717, 1157, 2181, 133, +3205, 1669, 2949, 901, 3973, 1285, 2309, 261, 3333, 1797, 2565, 517, 3589, +1029, 2053, 5, 3077, 1541, 2821, 773, 3845, 1413, 2437, 389, 3461, 1925, +2757, 709, 3781, 1221, 2245, 197, 3269, 1733, 3013, 965, 4037, 1381, 2405, +357, 3429, 1893, 2661, 613, 3685, 1125, 2149, 101, 3173, 1637, 2917, 869, +3941, 1509, 2533, 485, 3557, 2021, 2741, 693, 3765, 1205, 2229, 181, 3253, +1717, 2997, 949, 4021, 1333, 2357, 309, 3381, 1845, 2613, 565, 3637, 1077, +2101, 53, 3125, 1589, 2869, 821, 3893, 1461, 2485, 437, 3509, 1973, 2805, +757, 3829, 1269, 2293, 245, 3317, 1781, 3061, 1013, 4085, 1373, 2397, 349, +3421, 1885, 2653, 605, 3677, 1117, 2141, 93, 3165, 1629, 2909, 861, 3933, +1501, 2525, 477, 3549, 2013, 2717, 669, 3741, 1181, 2205, 157, 3229, 1693, +2973, 925, 3997, 1309, 2333, 285, 3357, 1821, 2589, 541, 3613, 1053, 2077, +29, 3101, 1565, 2845, 797, 3869, 1437, 2461, 413, 3485, 1949, 2781, 733, +3805, 1245, 2269, 221, 3293, 1757, 3037, 989, 4061, 1405, 2429, 381, 3453, +1917, 2685, 637, 3709, 1149, 2173, 125, 3197, 1661, 2941, 893, 3965, 1533, +2557, 509, 3581, 2045, 2729, 681, 3753, 1193, 2217, 169, 3241, 1705, 2985, +937, 4009, 1321, 2345, 297, 3369, 1833, 2601, 553, 3625, 1065, 2089, 41, +3113, 1577, 2857, 809, 3881, 1449, 2473, 425, 3497, 1961, 2793, 745, 3817, +1257, 2281, 233, 3305, 1769, 3049, 1001, 4073, 1353, 2377, 329, 3401, 1865, +2633, 585, 3657, 1097, 2121, 73, 3145, 1609, 2889, 841, 3913, 1481, 2505, +457, 3529, 1993, 2697, 649, 3721, 1161, 2185, 137, 3209, 1673, 2953, 905, +3977, 1289, 2313, 265, 3337, 1801, 2569, 521, 3593, 1033, 2057, 9, 3081, +1545, 2825, 777, 3849, 1417, 2441, 393, 3465, 1929, 2761, 713, 3785, 1225, +2249, 201, 3273, 1737, 3017, 969, 4041, 1385, 2409, 361, 3433, 1897, 2665, +617, 3689, 1129, 2153, 105, 3177, 1641, 2921, 873, 3945, 1513, 2537, 489, +3561, 2025, 2745, 697, 3769, 1209, 2233, 185, 3257, 1721, 3001, 953, 4025, +1337, 2361, 313, 3385, 1849, 2617, 569, 3641, 1081, 2105, 57, 3129, 1593, +2873, 825, 3897, 1465, 2489, 441, 3513, 1977, 2809, 761, 3833, 1273, 2297, +249, 3321, 1785, 3065, 1017, 4089, 1361, 2385, 337, 3409, 1873, 2641, 593, +3665, 1105, 2129, 81, 3153, 1617, 2897, 849, 3921, 1489, 2513, 465, 3537, +2001, 2705, 657, 3729, 1169, 2193, 145, 3217, 1681, 2961, 913, 3985, 1297, +2321, 273, 3345, 1809, 2577, 529, 3601, 1041, 2065, 17, 3089, 1553, 2833, +785, 3857, 1425, 2449, 401, 3473, 1937, 2769, 721, 3793, 1233, 2257, 209, +3281, 1745, 3025, 977, 4049, 1393, 2417, 369, 3441, 1905, 2673, 625, 3697, +1137, 2161, 113, 3185, 1649, 2929, 881, 3953, 1521, 2545, 497, 3569, 2033, +2721, 673, 3745, 1185, 2209, 161, 3233, 1697, 2977, 929, 4001, 1313, 2337, +289, 3361, 1825, 2593, 545, 3617, 1057, 2081, 33, 3105, 1569, 2849, 801, +3873, 1441, 2465, 417, 3489, 1953, 2785, 737, 3809, 1249, 2273, 225, 3297, +1761, 3041, 993, 4065, 1345, 2369, 321, 3393, 1857, 2625, 577, 3649, 1089, +2113, 65, 3137, 1601, 2881, 833, 3905, 1473, 2497, 449, 3521, 1985, 2689, +641, 3713, 1153, 2177, 129, 3201, 1665, 2945, 897, 3969, 1281, 2305, 257, +3329, 1793, 2561, 513, 3585, 1025, 2049, 1, 3073, 1537, 2817, 769, 3841, +1409, 2433, 385, 3457, 1921, 2753, 705, 3777, 1217, 2241, 193, 3265, 1729, +3009, 961, 4033, 1377, 2401, 353, 3425, 1889, 2657, 609, 3681, 1121, 2145, +97, 3169, 1633, 2913, 865, 3937, 1505, 2529, 481, 3553, 2017, 2737, 689, +3761, 1201, 2225, 177, 3249, 1713, 2993, 945, 4017, 1329, 2353, 305, 3377, +1841, 2609, 561, 3633, 1073, 2097, 49, 3121, 1585, 2865, 817, 3889, 1457, +2481, 433, 3505, 1969, 2801, 753, 3825, 1265, 2289, 241, 3313, 1777, 3057, +1009, 4081, 1369, 2393, 345, 3417, 1881, 2649, 601, 3673, 1113, 2137, 89, +3161, 1625, 2905, 857, 3929, 1497, 2521, 473, 3545, 2009, 2713, 665, 3737, +1177, 2201, 153, 3225, 1689, 2969, 921, 3993, 1305, 2329, 281, 3353, 1817, +2585, 537, 3609, 1049, 2073, 25, 3097, 1561, 2841, 793, 3865, 1433, 2457, +409, 3481, 1945, 2777, 729, 3801, 1241, 2265, 217, 3289, 1753, 3033, 985, +4057, 1401, 2425, 377, 3449, 1913, 2681, 633, 3705, 1145, 2169, 121, 3193, +1657, 2937, 889, 3961, 1529, 2553, 505, 3577, 2041, 2733, 685, 3757, 1197, +2221, 173, 3245, 1709, 2989, 941, 4013, 1325, 2349, 301, 3373, 1837, 2605, +557, 3629, 1069, 2093, 45, 3117, 1581, 2861, 813, 3885, 1453, 2477, 429, +3501, 1965, 2797, 749, 3821, 1261, 2285, 237, 3309, 1773, 3053, 1005, 4077, +1357, 2381, 333, 3405, 1869, 2637, 589, 3661, 1101, 2125, 77, 3149, 1613, +2893, 845, 3917, 1485, 2509, 461, 3533, 1997, 2701, 653, 3725, 1165, 2189, +141, 3213, 1677, 2957, 909, 3981, 1293, 2317, 269, 3341, 1805, 2573, 525, +3597, 1037, 2061, 13, 3085, 1549, 2829, 781, 3853, 1421, 2445, 397, 3469, +1933, 2765, 717, 3789, 1229, 2253, 205, 3277, 1741, 3021, 973, 4045, 1389, +2413, 365, 3437, 1901, 2669, 621, 3693, 1133, 2157, 109, 3181, 1645, 2925, +877, 3949, 1517, 2541, 493, 3565, 2029, 2749, 701, 3773, 1213, 2237, 189, +3261, 1725, 3005, 957, 4029, 1341, 2365, 317, 3389, 1853, 2621, 573, 3645, +1085, 2109, 61, 3133, 1597, 2877, 829, 3901, 1469, 2493, 445, 3517, 1981, +2813, 765, 3837, 1277, 2301, 253, 3325, 1789, 3069, 1021, 4093, 1367, 2391, +343, 3415, 1879, 2647, 599, 3671, 1111, 2135, 87, 3159, 1623, 2903, 855, +3927, 1495, 2519, 471, 3543, 2007, 2711, 663, 3735, 1175, 2199, 151, 3223, +1687, 2967, 919, 3991, 1303, 2327, 279, 3351, 1815, 2583, 535, 3607, 1047, +2071, 23, 3095, 1559, 2839, 791, 3863, 1431, 2455, 407, 3479, 1943, 2775, +727, 3799, 1239, 2263, 215, 3287, 1751, 3031, 983, 4055, 1399, 2423, 375, +3447, 1911, 2679, 631, 3703, 1143, 2167, 119, 3191, 1655, 2935, 887, 3959, +1527, 2551, 503, 3575, 2039, 2727, 679, 3751, 1191, 2215, 167, 3239, 1703, +2983, 935, 4007, 1319, 2343, 295, 3367, 1831, 2599, 551, 3623, 1063, 2087, +39, 3111, 1575, 2855, 807, 3879, 1447, 2471, 423, 3495, 1959, 2791, 743, +3815, 1255, 2279, 231, 3303, 1767, 3047, 999, 4071, 1351, 2375, 327, 3399, +1863, 2631, 583, 3655, 1095, 2119, 71, 3143, 1607, 2887, 839, 3911, 1479, +2503, 455, 3527, 1991, 2695, 647, 3719, 1159, 2183, 135, 3207, 1671, 2951, +903, 3975, 1287, 2311, 263, 3335, 1799, 2567, 519, 3591, 1031, 2055, 7, +3079, 1543, 2823, 775, 3847, 1415, 2439, 391, 3463, 1927, 2759, 711, 3783, +1223, 2247, 199, 3271, 1735, 3015, 967, 4039, 1383, 2407, 359, 3431, 1895, +2663, 615, 3687, 1127, 2151, 103, 3175, 1639, 2919, 871, 3943, 1511, 2535, +487, 3559, 2023, 2743, 695, 3767, 1207, 2231, 183, 3255, 1719, 2999, 951, +4023, 1335, 2359, 311, 3383, 1847, 2615, 567, 3639, 1079, 2103, 55, 3127, +1591, 2871, 823, 3895, 1463, 2487, 439, 3511, 1975, 2807, 759, 3831, 1271, +2295, 247, 3319, 1783, 3063, 1015, 4087, 1375, 2399, 351, 3423, 1887, 2655, +607, 3679, 1119, 2143, 95, 3167, 1631, 2911, 863, 3935, 1503, 2527, 479, +3551, 2015, 2719, 671, 3743, 1183, 2207, 159, 3231, 1695, 2975, 927, 3999, +1311, 2335, 287, 3359, 1823, 2591, 543, 3615, 1055, 2079, 31, 3103, 1567, +2847, 799, 3871, 1439, 2463, 415, 3487, 1951, 2783, 735, 3807, 1247, 2271, +223, 3295, 1759, 3039, 991, 4063, 1407, 2431, 383, 3455, 1919, 2687, 639, +3711, 1151, 2175, 127, 3199, 1663, 2943, 895, 3967, 1535, 2559, 511, 3583, +2047, 2730, 682, 3754, 1194, 2218, 170, 3242, 1706, 2986, 938, 4010, 1322, +2346, 298, 3370, 1834, 2602, 554, 3626, 1066, 2090, 42, 3114, 1578, 2858, +810, 3882, 1450, 2474, 426, 3498, 1962, 2794, 746, 3818, 1258, 2282, 234, +3306, 1770, 3050, 1002, 4074, 1354, 2378, 330, 3402, 1866, 2634, 586, 3658, +1098, 2122, 74, 3146, 1610, 2890, 842, 3914, 1482, 2506, 458, 3530, 1994, +2698, 650, 3722, 1162, 2186, 138, 3210, 1674, 2954, 906, 3978, 1290, 2314, +266, 3338, 1802, 2570, 522, 3594, 1034, 2058, 10, 3082, 1546, 2826, 778, +3850, 1418, 2442, 394, 3466, 1930, 2762, 714, 3786, 1226, 2250, 202, 3274, +1738, 3018, 970, 4042, 1386, 2410, 362, 3434, 1898, 2666, 618, 3690, 1130, +2154, 106, 3178, 1642, 2922, 874, 3946, 1514, 2538, 490, 3562, 2026, 2746, +698, 3770, 1210, 2234, 186, 3258, 1722, 3002, 954, 4026, 1338, 2362, 314, +3386, 1850, 2618, 570, 3642, 1082, 2106, 58, 3130, 1594, 2874, 826, 3898, +1466, 2490, 442, 3514, 1978, 2810, 762, 3834, 1274, 2298, 250, 3322, 1786, +3066, 1018, 4090, 1362, 2386, 338, 3410, 1874, 2642, 594, 3666, 1106, 2130, +82, 3154, 1618, 2898, 850, 3922, 1490, 2514, 466, 3538, 2002, 2706, 658, +3730, 1170, 2194, 146, 3218, 1682, 2962, 914, 3986, 1298, 2322, 274, 3346, +1810, 2578, 530, 3602, 1042, 2066, 18, 3090, 1554, 2834, 786, 3858, 1426, +2450, 402, 3474, 1938, 2770, 722, 3794, 1234, 2258, 210, 3282, 1746, 3026, +978, 4050, 1394, 2418, 370, 3442, 1906, 2674, 626, 3698, 1138, 2162, 114, +3186, 1650, 2930, 882, 3954, 1522, 2546, 498, 3570, 2034, 2722, 674, 3746, +1186, 2210, 162, 3234, 1698, 2978, 930, 4002, 1314, 2338, 290, 3362, 1826, +2594, 546, 3618, 1058, 2082, 34, 3106, 1570, 2850, 802, 3874, 1442, 2466, +418, 3490, 1954, 2786, 738, 3810, 1250, 2274, 226, 3298, 1762, 3042, 994, +4066, 1346, 2370, 322, 3394, 1858, 2626, 578, 3650, 1090, 2114, 66, 3138, +1602, 2882, 834, 3906, 1474, 2498, 450, 3522, 1986, 2690, 642, 3714, 1154, +2178, 130, 3202, 1666, 2946, 898, 3970, 1282, 2306, 258, 3330, 1794, 2562, +514, 3586, 1026, 2050, 2, 3074, 1538, 2818, 770, 3842, 1410, 2434, 386, +3458, 1922, 2754, 706, 3778, 1218, 2242, 194, 3266, 1730, 3010, 962, 4034, +1378, 2402, 354, 3426, 1890, 2658, 610, 3682, 1122, 2146, 98, 3170, 1634, +2914, 866, 3938, 1506, 2530, 482, 3554, 2018, 2738, 690, 3762, 1202, 2226, +178, 3250, 1714, 2994, 946, 4018, 1330, 2354, 306, 3378, 1842, 2610, 562, +3634, 1074, 2098, 50, 3122, 1586, 2866, 818, 3890, 1458, 2482, 434, 3506, +1970, 2802, 754, 3826, 1266, 2290, 242, 3314, 1778, 3058, 1010, 4082, 1370, +2394, 346, 3418, 1882, 2650, 602, 3674, 1114, 2138, 90, 3162, 1626, 2906, +858, 3930, 1498, 2522, 474, 3546, 2010, 2714, 666, 3738, 1178, 2202, 154, +3226, 1690, 2970, 922, 3994, 1306, 2330, 282, 3354, 1818, 2586, 538, 3610, +1050, 2074, 26, 3098, 1562, 2842, 794, 3866, 1434, 2458, 410, 3482, 1946, +2778, 730, 3802, 1242, 2266, 218, 3290, 1754, 3034, 986, 4058, 1402, 2426, +378, 3450, 1914, 2682, 634, 3706, 1146, 2170, 122, 3194, 1658, 2938, 890, +3962, 1530, 2554, 506, 3578, 2042, 2734, 686, 3758, 1198, 2222, 174, 3246, +1710, 2990, 942, 4014, 1326, 2350, 302, 3374, 1838, 2606, 558, 3630, 1070, +2094, 46, 3118, 1582, 2862, 814, 3886, 1454, 2478, 430, 3502, 1966, 2798, +750, 3822, 1262, 2286, 238, 3310, 1774, 3054, 1006, 4078, 1358, 2382, 334, +3406, 1870, 2638, 590, 3662, 1102, 2126, 78, 3150, 1614, 2894, 846, 3918, +1486, 2510, 462, 3534, 1998, 2702, 654, 3726, 1166, 2190, 142, 3214, 1678, +2958, 910, 3982, 1294, 2318, 270, 3342, 1806, 2574, 526, 3598, 1038, 2062, +14, 3086, 1550, 2830, 782, 3854, 1422, 2446, 398, 3470, 1934, 2766, 718, +3790, 1230, 2254, 206, 3278, 1742, 3022, 974, 4046, 1390, 2414, 366, 3438, +1902, 2670, 622, 3694, 1134, 2158, 110, 3182, 1646, 2926, 878, 3950, 1518, +2542, 494, 3566, 2030, 2750, 702, 3774, 1214, 2238, 190, 3262, 1726, 3006, +958, 4030, 1342, 2366, 318, 3390, 1854, 2622, 574, 3646, 1086, 2110, 62, +3134, 1598, 2878, 830, 3902, 1470, 2494, 446, 3518, 1982, 2814, 766, 3838, +1278, 2302, 254, 3326, 1790, 3070, 1022, 4094, 1364, 2388, 340, 3412, 1876, +2644, 596, 3668, 1108, 2132, 84, 3156, 1620, 2900, 852, 3924, 1492, 2516, +468, 3540, 2004, 2708, 660, 3732, 1172, 2196, 148, 3220, 1684, 2964, 916, +3988, 1300, 2324, 276, 3348, 1812, 2580, 532, 3604, 1044, 2068, 20, 3092, +1556, 2836, 788, 3860, 1428, 2452, 404, 3476, 1940, 2772, 724, 3796, 1236, +2260, 212, 3284, 1748, 3028, 980, 4052, 1396, 2420, 372, 3444, 1908, 2676, +628, 3700, 1140, 2164, 116, 3188, 1652, 2932, 884, 3956, 1524, 2548, 500, +3572, 2036, 2724, 676, 3748, 1188, 2212, 164, 3236, 1700, 2980, 932, 4004, +1316, 2340, 292, 3364, 1828, 2596, 548, 3620, 1060, 2084, 36, 3108, 1572, +2852, 804, 3876, 1444, 2468, 420, 3492, 1956, 2788, 740, 3812, 1252, 2276, +228, 3300, 1764, 3044, 996, 4068, 1348, 2372, 324, 3396, 1860, 2628, 580, +3652, 1092, 2116, 68, 3140, 1604, 2884, 836, 3908, 1476, 2500, 452, 3524, +1988, 2692, 644, 3716, 1156, 2180, 132, 3204, 1668, 2948, 900, 3972, 1284, +2308, 260, 3332, 1796, 2564, 516, 3588, 1028, 2052, 4, 3076, 1540, 2820, +772, 3844, 1412, 2436, 388, 3460, 1924, 2756, 708, 3780, 1220, 2244, 196, +3268, 1732, 3012, 964, 4036, 1380, 2404, 356, 3428, 1892, 2660, 612, 3684, +1124, 2148, 100, 3172, 1636, 2916, 868, 3940, 1508, 2532, 484, 3556, 2020, +2740, 692, 3764, 1204, 2228, 180, 3252, 1716, 2996, 948, 4020, 1332, 2356, +308, 3380, 1844, 2612, 564, 3636, 1076, 2100, 52, 3124, 1588, 2868, 820, +3892, 1460, 2484, 436, 3508, 1972, 2804, 756, 3828, 1268, 2292, 244, 3316, +1780, 3060, 1012, 4084, 1372, 2396, 348, 3420, 1884, 2652, 604, 3676, 1116, +2140, 92, 3164, 1628, 2908, 860, 3932, 1500, 2524, 476, 3548, 2012, 2716, +668, 3740, 1180, 2204, 156, 3228, 1692, 2972, 924, 3996, 1308, 2332, 284, +3356, 1820, 2588, 540, 3612, 1052, 2076, 28, 3100, 1564, 2844, 796, 3868, +1436, 2460, 412, 3484, 1948, 2780, 732, 3804, 1244, 2268, 220, 3292, 1756, +3036, 988, 4060, 1404, 2428, 380, 3452, 1916, 2684, 636, 3708, 1148, 2172, +124, 3196, 1660, 2940, 892, 3964, 1532, 2556, 508, 3580, 2044, 2728, 680, +3752, 1192, 2216, 168, 3240, 1704, 2984, 936, 4008, 1320, 2344, 296, 3368, +1832, 2600, 552, 3624, 1064, 2088, 40, 3112, 1576, 2856, 808, 3880, 1448, +2472, 424, 3496, 1960, 2792, 744, 3816, 1256, 2280, 232, 3304, 1768, 3048, +1000, 4072, 1352, 2376, 328, 3400, 1864, 2632, 584, 3656, 1096, 2120, 72, +3144, 1608, 2888, 840, 3912, 1480, 2504, 456, 3528, 1992, 2696, 648, 3720, +1160, 2184, 136, 3208, 1672, 2952, 904, 3976, 1288, 2312, 264, 3336, 1800, +2568, 520, 3592, 1032, 2056, 8, 3080, 1544, 2824, 776, 3848, 1416, 2440, +392, 3464, 1928, 2760, 712, 3784, 1224, 2248, 200, 3272, 1736, 3016, 968, +4040, 1384, 2408, 360, 3432, 1896, 2664, 616, 3688, 1128, 2152, 104, 3176, +1640, 2920, 872, 3944, 1512, 2536, 488, 3560, 2024, 2744, 696, 3768, 1208, +2232, 184, 3256, 1720, 3000, 952, 4024, 1336, 2360, 312, 3384, 1848, 2616, +568, 3640, 1080, 2104, 56, 3128, 1592, 2872, 824, 3896, 1464, 2488, 440, +3512, 1976, 2808, 760, 3832, 1272, 2296, 248, 3320, 1784, 3064, 1016, 4088, +1360, 2384, 336, 3408, 1872, 2640, 592, 3664, 1104, 2128, 80, 3152, 1616, +2896, 848, 3920, 1488, 2512, 464, 3536, 2000, 2704, 656, 3728, 1168, 2192, +144, 3216, 1680, 2960, 912, 3984, 1296, 2320, 272, 3344, 1808, 2576, 528, +3600, 1040, 2064, 16, 3088, 1552, 2832, 784, 3856, 1424, 2448, 400, 3472, +1936, 2768, 720, 3792, 1232, 2256, 208, 3280, 1744, 3024, 976, 4048, 1392, +2416, 368, 3440, 1904, 2672, 624, 3696, 1136, 2160, 112, 3184, 1648, 2928, +880, 3952, 1520, 2544, 496, 3568, 2032, 2720, 672, 3744, 1184, 2208, 160, +3232, 1696, 2976, 928, 4000, 1312, 2336, 288, 3360, 1824, 2592, 544, 3616, +1056, 2080, 32, 3104, 1568, 2848, 800, 3872, 1440, 2464, 416, 3488, 1952, +2784, 736, 3808, 1248, 2272, 224, 3296, 1760, 3040, 992, 4064, 1344, 2368, +320, 3392, 1856, 2624, 576, 3648, 1088, 2112, 64, 3136, 1600, 2880, 832, +3904, 1472, 2496, 448, 3520, 1984, 2688, 640, 3712, 1152, 2176, 128, 3200, +1664, 2944, 896, 3968, 1280, 2304, 256, 3328, 1792, 2560, 512, 3584, 1024, +2048}; + + diff --git a/lib/rbcodec/codecs/lib/mdct_lookup.h b/lib/rbcodec/codecs/lib/mdct_lookup.h new file mode 100644 index 0000000000..909b95ddbb --- /dev/null +++ b/lib/rbcodec/codecs/lib/mdct_lookup.h @@ -0,0 +1,24 @@ +/******************************************************************** + * * + * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * + * * + * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * + * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * + * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * + * * + * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * + * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * + * * + ******************************************************************** + + function: sin,cos lookup tables + + ********************************************************************/ + + +extern const int32_t sincos_lookup0[1026]; +extern const int32_t sincos_lookup1[1024]; +extern const uint16_t revtab[1<<12]; + + + diff --git a/lib/rbcodec/codecs/lib/osx.dummy.c b/lib/rbcodec/codecs/lib/osx.dummy.c new file mode 100644 index 0000000000..e69de29bb2 diff --git a/lib/rbcodec/codecs/liba52/AUTHORS b/lib/rbcodec/codecs/liba52/AUTHORS new file mode 100644 index 0000000000..a6bd695228 --- /dev/null +++ b/lib/rbcodec/codecs/liba52/AUTHORS @@ -0,0 +1,23 @@ +Aaron Holtzman started the project and +made the initial working implementation. + +Michel Lespinasse did major changes for speed and +conformance and is the current maintainer. + +Other contributors include: + Gildas Bazin - mingw32 port + Billy Biggs - most of liba52.txt + Jeroen Dobbelaere - fixed point version + Eduard Hasenleithner - gcc 3.0 fixes + HÃ¥kan Hjort - Solaris output, mlib code + Charles M. Hannum - fixes + Chris Hodges - made the library reentrant + Michael Holzt - OSS output.c and misc errata + Angelos Keromytis - OpenBSD fixes + David I. Lehn - API cleanup suggestion + Don Mahurin - stdin support for extract_a52 + Jim Miller - IRIX output.c + Takefumi Sayo - FreeBSD tweak + Shoji Tokunaga - aif file output + +(let me know if I forgot anyone) diff --git a/lib/rbcodec/codecs/liba52/COPYING b/lib/rbcodec/codecs/liba52/COPYING new file mode 100644 index 0000000000..60549be514 --- /dev/null +++ b/lib/rbcodec/codecs/liba52/COPYING @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) 19yy + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) 19yy name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/lib/rbcodec/codecs/liba52/ChangeLog b/lib/rbcodec/codecs/liba52/ChangeLog new file mode 100644 index 0000000000..4adac364eb --- /dev/null +++ b/lib/rbcodec/codecs/liba52/ChangeLog @@ -0,0 +1,97 @@ +a52dec-0.7.4 Sat Jul 27 20:44:00 PDT 2002 +-The library is now fully reentrant. +-Added win32 output module, al file output, gain control. +-A few additional portability enhancements. + +a52dec-0.7.3 Wed Feb 20 23:38:22 PST 2002 +-rewrite of the imdct code, making a52dec 40% to 80% faster than version 0.7.2 +-fixed one memory corruption problem in parse.c +-small liba52 portability fixes +-byte order and CRLF bugfixes in wav file output +-aif file output +-IRIX al sound output (untested, tell us if it works) + +a52dec-0.7.2 Sun Dec 16 14:39:56 PST 2001 +-demuxer improvements, with support for TS streams. +-smaller demux buffer, making it easier to use a52dec as a pipe +-wav output +-avoid -fPIC when possible (-prefer-non-pic) +-support for vc++ and TenDRA +-portability fixes + +a52dec-0.7.1b Fri Aug 31 02:37:23 PDT 2001 +-removed an #include that was only breaking libc5 builds + +a52dec-0.7.1 Thu Aug 30 02:13:23 PDT 2001 +-gcc 3.0 fixes +-mlib fixes (now passes the test suite) +-in a52dec.c, made sample_data and flags static +-removed a few statics in liba52/parse.c (still not reentrant, but closer) + +a52dec-0.7.0 Thu Aug 23 23:18:00 PDT 2001 +-Downmix to arbitrary speaker configurations +-Dynamic range compression +-Major speedups: 2x for 2.0 streams with 2.0 output, + 3x for 5.1 streams with 2.0 output. +-New library interface +-Rematrixing bugfix +-Higher precision + +ac3dec-0.6.1 Mon Mar 27 20:27:06 EST 2000 +-Fix another 2.0 problem (rematrix was wrong). +-Fix the never resync on a bad crc bug. + +ac3dec-0.6.0 Sat Mar 18 19:43:25 EST 2000 +-New library interface +-Fix bug wrt coupling channels that was causing sound quality problems. +-Fix 2.0 mode problems (aka the I forgot to implement the phase flags bug). +-All around speed improvements (almost twice as fast) +-Improved robustness when fed bad data. The entire frame is checksummed before playback. + +ac3dec-0.5.6 Tue Nov 16 00:37:34 EST 1999 +-Irix support +-Alpha fixes +-Minor performance enhancements to downmix and imdct +-OpenBSD fixes +-extract_ac3 can now read from stdin +-Change output_linux to block on write instead of using the + ring buffer. Let me know if this causes/fixes any problems + +ac3dec-0.5.5 Wed Aug 25 15:36:44 EDT 1999 +-Fixed a cut and paste bug (argh!) in parse.c which potentially + screwed up delta bit allocation info. +-Martin Mueller informed me that I was missing + some corrections from the AC-3 errata document. It turns out that + I used an earlier version of the errata when I initially wrote ac3dec. + Fortunately the errata fix the outstanding bugs that I was pulling + my hair out on for a long time. Woohoo! Thanks Martin. Kudos to Dolby + Labs for keeping their documentation up to date as well. +-stereo downmixing (downmix.c) is now in. Matrix encoded surround + (Dolby Prologic Surround) should work too. +-clipping due to high level signals has been fixed. We normalize a + block of samples by its maximum absolute value if the max exceeds + the %100 digital level. This shouldn't be a problem, but for some + reason some channels have a dynamic range that exceeds [-1.0,1.0]. + I blame the encoder :) +-Multiple track support in extract_ac3. Simply just give it the track + number you want [1,8] after the filename. + +ac3dec-0.5.4 Thu Jul 29 16:55:10 PDT 1999 +-Fixed a stupid bug with the coupling channel that was causing + high frequencies to be attenuated. +-Re-wrote the extract_ac3 tool. +-Added to a tool to verify the checksums on a given AC3 stream. + (tools/verify_ac3) + +ac3dec-0.5.3 Mon Jul 12 10:45:56 PDT 1999 +-Fixed problems related to streams with coupling channel enabled. +-Minor performance enhancements + +ac3dec-0.5.2 Sun Jul 4 12:00:25 PDT 1999 +-output_linux.c patch provided by Michael Holzt + +ac3dec-0.5.1 Wed Jun 30 17:48:52 PDT 1999 +-Compiles and dies gracefully under Linux now. + +ac3dec-0.5.0 Wed Jun 23 11:06:06 EDT 1999 +-First public release of ac3dec. diff --git a/lib/rbcodec/codecs/liba52/HISTORY b/lib/rbcodec/codecs/liba52/HISTORY new file mode 100644 index 0000000000..c2b9d02ee1 --- /dev/null +++ b/lib/rbcodec/codecs/liba52/HISTORY @@ -0,0 +1,28 @@ +changes that affected the PCM output: + +2001/05/14 05:48:59 - aaron's 0.6.1 was cutting before the end + +2001/06/04 01:42:47 - slightly adjusted some values (volume, downmix adjustemtn, clev/slev tables) +2001/06/04 05:48:31 - added adjust_level to the downmix + +2001/06/12 +2001/06/13 - changed the order of the dither() calls + also introduced bug with thx_2_0 stream + +2001/06/22 08:23:37 - fixed bug with thx_2_0 stream (see parse.c) + +2001/07/02 08:44:55 - changed float-to-int conversion (+ added saturation) + +2001/07/06 06:53:01 - more precise imdct init, more precise q_* coefficients + +2001/07/06 08:52:30 - rematrixing fixes + +2001/07/26 21:31:39 - do 3dB dither reduction in coeff_get() not dither_gen() + +2001/08/09 08:11:31 - implemented dynamic range compression + +2002/02/24 08:54:49 - window function computed at runtime, with more precision + +2003/01/28 06.57:37 - switched to integer q_* coefficients + +2003/01/28 07:39:35 - use level of 0.75 for dithering instead of 0.707 diff --git a/lib/rbcodec/codecs/liba52/INSTALL b/lib/rbcodec/codecs/liba52/INSTALL new file mode 100644 index 0000000000..30a07fecff --- /dev/null +++ b/lib/rbcodec/codecs/liba52/INSTALL @@ -0,0 +1,58 @@ +Unix build instructions +----------------------- + +./configure +make +make install + +If you install from CVS you'll have to run ./bootstrap first + + +Building for win32 +------------------ + +There are at least three ways to do it: + +- natively on Windows using Microsoft VC++ and the vc++ project + included in this distribution. + +- natively on Windows using MSYS + MINGW (www.mingw.org) (MSYS is a + minimal build environnement to compile unixish projects under + windows. It provides all the common unix tools like sh, gmake...) + +- or on Linux, using the mingw32 cross-compiler + + +Building using MSYS + MINGW on windows +-------------------------------------- + +First you will need to download and install the latest MSYS (version +1.0.7 as of now) and MINGW. The installation is really easy. Begin +with the MSYS auto-installer and once this is done, extract MINGW into +c:\msys\1.0\mingw. You also have to remember to remove the make +utility included with MINGW as it conflicts with the one from MSYS +(just rename or remove c:\msys\1.0\mingw\bin\make.exe). + +http://prdownloads.sourceforge.net/mingw/MSYS-1.0.7-i686-2002.04.24-1.exe +http://prdownloads.sourceforge.net/mingw/MinGW-1.1.tar.gz + +Then you can build the package using: +# ./configure +# make + + +Building using the mingw32 cross-compiler +----------------------------------------- + +You need to install mingw32 first. For Debian GNU/Linux users, there +is a mingw32 package. Otherwise you might get it from the mingw site +at http://www.mingw.org/download.shtml. + +The videolan project also keeps precompiled mingw32 binaries at +http://www.videolan.org/vlc/windows.html . If you install these, +you'll have to set your PATH accordingly to include +/usr/local/cross-tools/bin too. + +The build should then proceed using something like: +# CC=i586-mingw32msvc-gcc ./configure --host=i586-mingw32msvc +# make diff --git a/lib/rbcodec/codecs/liba52/NEWS b/lib/rbcodec/codecs/liba52/NEWS new file mode 100644 index 0000000000..4bee9cac8d --- /dev/null +++ b/lib/rbcodec/codecs/liba52/NEWS @@ -0,0 +1,46 @@ +a52dec-0.7.4 Sat Jul 27 20:44:00 PDT 2002 + +The library is now fully reentrant. + +Added win32 output module, al file output, gain control. + +A few additional portability enhancements. + + +a52dec-0.7.3 Wed Feb 20 23:38:22 PST 2002 + +Performance enhancements, from 40% to 80% depending on streams. + +Fixed a few embarassing bugs in liba52: one memory corruption issue +and a few minor portability problems. + +Several new output modules, and fixes in the existing .wav file output. + + +a52dec-0.7.2 Sun Dec 16 14:39:56 PST 2001 + +Minor bugfixes, performance and portability enhancements. + +Also added wav format output, and reduced the demux buffer size which +makes it easier to use a52dec as a pipe. + + +a52dec-0.7.1 Thu Aug 30 02:13:23 PDT 2001 + +Minor release for bugfixes. Looks like 0.7.0 was a bit rushed out. + +Now compiles with gcc 3.0, made sure mlib implementation works, and +fixed a small bug in the a52dec test program. + + +a52dec-0.7.0 Thu Aug 23 23:18:00 PDT 2001 + +First release since more than one year ! + +The most user-noticeable additions are the downmix to arbitrary +speaker configurations, and the implementation of dynamic range +compression. + +The speed has been improved by a factor of 2 to 3, the conformance and +precision should be higher, and we also fixed a small bug when playing +stereo rematrixed streams. diff --git a/lib/rbcodec/codecs/liba52/README b/lib/rbcodec/codecs/liba52/README new file mode 100644 index 0000000000..eb6c64df84 --- /dev/null +++ b/lib/rbcodec/codecs/liba52/README @@ -0,0 +1,180 @@ + + +ABOUT LIBA52 + +liba52 is a free library for decoding ATSC A/52 streams. It is +released under the terms of the GPL license. The A/52 standard is used +in a variety of applications, including digital television and DVD. It +is also known as AC-3. + +The main goals in liba52 development are: + + * Portability - Currently all of the code is written in C, and + when we write platform-specific optimizations we will always + keep a generic C routine to fall back on. + + * Reuseability - we do not want liba52 to include any + project-specific code, but it should still include enough + features to be used by very diverse projects. + + * Precision - We are trying to implement all of the A/52 + standard, and to have a very precise output by doing all the + calculations in floating point. We have a test suite that + detects any deviation in the output when compared to previous + versions. We do not have access to official A/52 test vectors + though, so we have to use our judgement to ensure that such + deviations are only intruduced when we fix bugs ! + + * Speed - liba52 is really fast, on any modern PC it should take + only a few percent of CPU time. + +The project homepage is at http://liba52.sourceforge.net/ + + +A52DEC + +a52dec is a test program for liba52. It decodes ATSC A/52 streams, and +also includes a demultiplexer for mpeg-1 and mpeg-2 program streams. + +The liba52 source code is always distributed in the a52dec package, to +make sure it easier for people to test it. + +The basic usage is to just type "a52dec file" where file is an ATSC +A/52 file. + +The "-s" option must be used for multiplexed (audio and video) mpeg-2 +files. These files are usualy found on the internet or on unencrypted +DVDs. + +The "-o" option is used to select a given output layer. By default +a52dec does a stereo downmix and outputs to your speakers, but you can +try other choices using this option. This is also used for performance +testing and conformance testing. + +The "-c" option is used to disable all optimizations (currently only djbfft). + +The "-r" option is used to disable the dynamic range compression. + + +OTHER PROJECTS USING LIBA52 + +liba52 (and its ancestor libac3) is being used by various other +projects, including: + + * xine (http://xine.sourceforge.net/) - started as a simple + mpeg-2 audio and video decoder, but it since became a + full-featured DVD and video media player. + + * VideoLAN (http://www.videolan.org/) - video streaming over an + ethernet network, can also be used as a standalone player. + + * MPlayer (http://www.MPlayerHQ.hu) - another good player, it is + also very robust against damaged streams. + + * movietime (http://movietime.sourceforge.net/) - still quite + young, but it looks very promising ! + + * ffmpeg (http://ffmpeg.sourceforge.net/) - a nice audio/video + encoder and transcoder, uses liba52 for decoding A/52 streams. + + * Ogle (http://www.dtek.chalmers.se/groups/dvd/) - a good DVD + player with menu support + + * a52decX (http://homepage1.nifty.com/~toku/software_en.html) - + a graphical interface for a52dec in macintosh osX. + + * TCVP (http://tcvp.sf.net) - video and music player for unix. + + * bd4go (http://denisx.dyndns.org/bd4go/) - another graphical + interface for macintosh osX. + + * drip (http://drip.sourceforge.net/) - a DVD to DIVX transcoder. + + * OMS (http://www.linuxvideo.org/oms/) + + * XMPS (http://xmps.sourceforge.net/) + + * GStreamer (http://www.gstreamer.net/) - a framework for + streaming media; it has an A/52 decoding plugin based on liba52. + + * mpeglib (http://mpeglib.sourceforge.net/) - a video decoding + library that usess liba52 when decoding A/52 streams. + +If you use liba52 in another project, let us know ! + + +TASKS + +There are several places where we could easily use some help: + + * Web design: This site sucks ! at the very least, we'd like to + come up with a nicer background picture and a logo. + + * Testing: If you find any stream that does not decode right + with liba52, let us know ! The best thing would be to mail to + the liba52-devel mailing list. Also if you have access to + encoders, we'd love to get test streams that would be free of + rights - so that we can put them on this server. + + * Coding: you can have a look in the TODO file first ! The most + important item is probably to make the code fully reentrant. + + * Porting: If you're porting to a new architecture, you might + want to experiment with the compile flags defined in + configure.in . When you figure out whats fastest on your + platform, send us a patch ! + + +REFERENCES + +The A/52 standard, as published by the ATSC, is available at +http://www.atsc.org/standards/a_52a.pdf + + +CVS SNAPSHOTS + +A daily snapshot is created using "make distcheck" every night and +uploaded to http://liba52.sourceforge.net/files/a52dec-snapshot.tar.gz . +It is easier to use than the CVS repository, because you do not need +to have the right versions of automake, autoconf and libtool +installed. It might be convenient when working on a liba52 port for +example. + + +CVS REPOSITORY + +The latest liba52 and a52dec source code can always be found by +anonymous CVS: + +# export CVSROOT=:pserver:anonymous@cvs.liba52.sourceforge.net:/cvsroot/liba52 +# cvs login (Just press Return when prompted for a password) +# cvs checkout a52dec + +You can also browse the latest changes online at +http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/liba52/a52dec/ + +The other CVS modules are ac3dec-livid for the CVS history of the +project while it was still hosted on the linuxvideo.org servers, and +ac3dec for the CVS history of the project while the linuxvideo.org +servers were down and before the library switched its name to liba52. + + +MAILING LISTS + +See the subscription information at http://liba52.sourceforge.net/lists.html + +liba52-devel + +This is the main mailing list for technical discussion about +liba52. Anyone wanting to work on liba52, or maybe just stay informed +about the development process, should probably subscribe to this list. + +liba52-checkins + +All liba52 checkins are announced there. This is a good way to keep +track of what goes into CVS. + +liba52-announce + +This is a very low traffic mailing list, only for announcements of new +versions of liba52. Only project administrators can post there. diff --git a/lib/rbcodec/codecs/liba52/README.rockbox b/lib/rbcodec/codecs/liba52/README.rockbox new file mode 100644 index 0000000000..79768c5d72 --- /dev/null +++ b/lib/rbcodec/codecs/liba52/README.rockbox @@ -0,0 +1,27 @@ +Library: liba52-0.7.5 (CVS version 2005-02-16) +Imported: 2005-02-16 by Dave Chapman + + +This directory contains a local version of liba52 for decoding ATSC +A/52 (aka AC-3) audio streams. A/52 is commonly used in digital TV and +on DVDs. + +LICENSING INFORMATION + +liba52 is released under the GNU General Public License as described +in the COPYING file in this directory. + + +IMPORT DETAILS + +The base version first imported into Rockbox was the CVS version of +liba52-0.7.5 (0.7.4 was at the time the latest official) which was +checked out of sourceforge on 2005-02-16. + +The .[ch] files from a52dec/liba52/ and a52dec/include/ as well as the +documentation files in a52dec/ were imported into Rockbox. The other +files in the archive relate to the test player (a52dec) and were not +imported. + +A simple config.h file was added to enable liba52's fixed-point +integer-only mode and to specify the endianness of the target CPU. diff --git a/lib/rbcodec/codecs/liba52/SOURCES b/lib/rbcodec/codecs/liba52/SOURCES new file mode 100644 index 0000000000..733b95e8a6 --- /dev/null +++ b/lib/rbcodec/codecs/liba52/SOURCES @@ -0,0 +1,5 @@ +bit_allocate.c +bitstream.c +downmix.c +imdct.c +parse.c diff --git a/lib/rbcodec/codecs/liba52/TODO b/lib/rbcodec/codecs/liba52/TODO new file mode 100644 index 0000000000..dc5fb84203 --- /dev/null +++ b/lib/rbcodec/codecs/liba52/TODO @@ -0,0 +1,17 @@ +* look at possible overflow/precision issues in integer port + +* redo all bit allocation if previous frame had zero_snr_offsets +* make dynrng work in dual-channel streams + +* implement A/52a downmix extensions +* reduce size of delay buffer by 50% +* include float->s16 conversion in liba52 API ? +* include up/downsampling 44100<->48000 in liba52 API ? +* include audio dithering in liba52 API ? +* API extensions might be at a different level (base vs. extended) + +* use restrict pointers where appropriate +* avoid overflows, including reading the a52 stream !!! +* faster bitstream parsing ? +* make dither code faster (generate dither table in advance ?) +* SIMD optimizations diff --git a/lib/rbcodec/codecs/liba52/a52.h b/lib/rbcodec/codecs/liba52/a52.h new file mode 100644 index 0000000000..e852e8d6bb --- /dev/null +++ b/lib/rbcodec/codecs/liba52/a52.h @@ -0,0 +1,67 @@ +/* + * a52.h + * Copyright (C) 2000-2003 Michel Lespinasse + * Copyright (C) 1999-2000 Aaron Holtzman + * + * This file is part of a52dec, a free ATSC A-52 stream decoder. + * See http://liba52.sourceforge.net/ for updates. + * + * a52dec is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * a52dec is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef A52_H +#define A52_H + +#if defined(LIBA52_FIXED) +typedef int32_t sample_t; +typedef int32_t level_t; +#elif defined(LIBA52_DOUBLE) +typedef double sample_t; +typedef double level_t; +#else +typedef float sample_t; +typedef float level_t; +#endif + +typedef struct a52_state_s a52_state_t; + +#define A52_CHANNEL 0 +#define A52_MONO 1 +#define A52_STEREO 2 +#define A52_3F 3 +#define A52_2F1R 4 +#define A52_3F1R 5 +#define A52_2F2R 6 +#define A52_3F2R 7 +#define A52_CHANNEL1 8 +#define A52_CHANNEL2 9 +#define A52_DOLBY 10 +#define A52_CHANNEL_MASK 15 + +#define A52_LFE 16 +#define A52_ADJUST_LEVEL 32 + +a52_state_t * a52_init (uint32_t mm_accel); +sample_t * a52_samples (a52_state_t * state); +int a52_syncinfo (uint8_t * buf, int * flags, + int * sample_rate, int * bit_rate); +int a52_frame (a52_state_t * state, uint8_t * buf, int * flags, + level_t * level, sample_t bias); +void a52_dynrng (a52_state_t * state, + level_t (* call) (level_t, void *), void * data); +int a52_block (a52_state_t * state); +void a52_free (a52_state_t * state); + +#endif /* A52_H */ diff --git a/lib/rbcodec/codecs/liba52/a52_internal.h b/lib/rbcodec/codecs/liba52/a52_internal.h new file mode 100644 index 0000000000..3b3d21c9a3 --- /dev/null +++ b/lib/rbcodec/codecs/liba52/a52_internal.h @@ -0,0 +1,215 @@ +/* + * a52_internal.h + * Copyright (C) 2000-2003 Michel Lespinasse + * Copyright (C) 1999-2000 Aaron Holtzman + * + * This file is part of a52dec, a free ATSC A-52 stream decoder. + * See http://liba52.sourceforge.net/ for updates. + * + * a52dec is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * a52dec is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +typedef struct { + uint8_t bai; /* fine SNR offset, fast gain */ + uint8_t deltbae; /* delta bit allocation exists */ + int8_t deltba[50]; /* per-band delta bit allocation */ +} ba_t; + +typedef struct { + uint8_t exp[256]; /* decoded channel exponents */ + int8_t bap[256]; /* derived channel bit allocation */ +} expbap_t; + +struct a52_state_s { + uint8_t fscod; /* sample rate */ + uint8_t halfrate; /* halfrate factor */ + uint8_t acmod; /* coded channels */ + uint8_t lfeon; /* coded lfe channel */ + level_t clev; /* centre channel mix level */ + level_t slev; /* surround channels mix level */ + + int output; /* type of output */ + level_t level; /* output level */ + sample_t bias; /* output bias */ + + int dynrnge; /* apply dynamic range */ + level_t dynrng; /* dynamic range */ + void * dynrngdata; /* dynamic range callback funtion and data */ + level_t (* dynrngcall) (level_t range, void * dynrngdata); + + uint8_t chincpl; /* channel coupled */ + uint8_t phsflginu; /* phase flags in use (stereo only) */ + uint8_t cplstrtmant; /* coupling channel start mantissa */ + uint8_t cplendmant; /* coupling channel end mantissa */ + uint32_t cplbndstrc; /* coupling band structure */ + level_t cplco[5][18]; /* coupling coordinates */ + + /* derived information */ + uint8_t cplstrtbnd; /* coupling start band (for bit allocation) */ + uint8_t ncplbnd; /* number of coupling bands */ + + uint8_t rematflg; /* stereo rematrixing */ + + uint8_t endmant[5]; /* channel end mantissa */ + + uint16_t bai; /* bit allocation information */ + + uint32_t * buffer_start; + uint16_t lfsr_state; /* dither state */ + uint32_t bits_left; + uint32_t current_word; + + uint8_t csnroffst; /* coarse SNR offset */ + ba_t cplba; /* coupling bit allocation parameters */ + ba_t ba[5]; /* channel bit allocation parameters */ + ba_t lfeba; /* lfe bit allocation parameters */ + + uint8_t cplfleak; /* coupling fast leak init */ + uint8_t cplsleak; /* coupling slow leak init */ + + expbap_t cpl_expbap; + expbap_t fbw_expbap[5]; + expbap_t lfe_expbap; + + sample_t * samples; + int downmixed; +}; + +#define LEVEL_PLUS6DB 2.0 +#define LEVEL_PLUS3DB 1.4142135623730951 +#define LEVEL_3DB 0.7071067811865476 +#define LEVEL_45DB 0.5946035575013605 +#define LEVEL_6DB 0.5 + +#define EXP_REUSE (0) +#define EXP_D15 (1) +#define EXP_D25 (2) +#define EXP_D45 (3) + +#define DELTA_BIT_REUSE (0) +#define DELTA_BIT_NEW (1) +#define DELTA_BIT_NONE (2) +#define DELTA_BIT_RESERVED (3) + +void a52_bit_allocate (a52_state_t * state, ba_t * ba, int bndstart, + int start, int end, int fastleak, int slowleak, + expbap_t * expbap); + +int a52_downmix_init (int input, int flags, level_t * level, + level_t clev, level_t slev); +int a52_downmix_coeff (level_t * coeff, int acmod, int output, level_t level, + level_t clev, level_t slev); +void a52_downmix (sample_t * samples, int acmod, int output, + level_t clev, level_t slev); +void a52_upmix (sample_t * samples, int acmod, int output); + +void a52_imdct_init (uint32_t mm_accel); +void a52_imdct_256 (sample_t * data, sample_t * delay); +void a52_imdct_512 (sample_t * data, sample_t * delay); + +#define ROUND(x) ((int)((x) + ((x) > 0 ? 0.5 : -0.5))) + +#ifndef LIBA52_FIXED + +typedef sample_t quantizer_t; +#define SAMPLE(x) (x) +#define LEVEL(x) (x) +#define MUL(a,b) ((a) * (b)) +#define MUL_L(a,b) ((a) * (b)) +#define MUL_C(a,b) ((a) * (b)) +#define DIV(a,b) ((a) / (b)) +#define BIAS(x) ((x) + bias) + +#else /* LIBA52_FIXED */ + +typedef int16_t quantizer_t; +#define SAMPLE(x) (sample_t)((x) * (1 << 30)) +#define LEVEL(x) (level_t)((x) * (1 << 26)) + +#if 0 +#define MUL(a,b) ((int)(((int64_t)(a) * (b) + (1 << 29)) >> 30)) +#define MUL_L(a,b) ((int)(((int64_t)(a) * (b) + (1 << 25)) >> 26)) +#elif defined(CPU_COLDFIRE) +/* loses 1 bit of accuracy */ +#define MUL(a, b) \ +({ \ + int32_t t; \ + asm volatile ( \ + "mac.l %[A], %[B], %%acc0\n\t" \ + "movclr.l %%acc0, %[t]\n\t" \ + "asl.l #1, %[t]" \ + : [t] "=d" (t) \ + : [A] "r" ((a)), [B] "r" ((b))); \ + t; \ +}) +/* loses 5 bits of accuracy */ +#define MUL_L(a, b) \ +({ \ + int32_t t; \ + asm volatile ( \ + "mac.l %[A], %[B], %%acc0\n\t" \ + "movclr.l %%acc0, %[t]\n\t" \ + "asl.l #5, %[t]" \ + : [t] "=d" (t) \ + : [A] "r" ((a)), [B] "r" ((b))); \ + t; \ +}) + +#elif defined(CPU_ARM) +#define MUL(x, y) \ + ({ int32_t __hi; \ + uint32_t __lo; \ + int32_t __result; \ + asm ("smull %0, %1, %3, %4\n\t" \ + "movs %2, %1, lsl #2" \ + : "=&r" (__lo), "=&r" (__hi), "=r" (__result) \ + : "%r" (x), "r" (y) \ + : "cc"); \ + __result; \ + }) + + +#define MUL_L(x, y) \ + ({ int32_t __hi; \ + uint32_t __lo; \ + int32_t __result; \ + asm ("smull %0, %1, %3, %4\n\t" \ + "movs %0, %0, lsr %5\n\t" \ + "adc %2, %0, %1, lsl %6" \ + : "=&r" (__lo), "=&r" (__hi), "=r" (__result) \ + : "%r" (x), "r" (y), \ + "M" (26), "M" (32 - 26) \ + : "cc"); \ + __result; \ + }) + + +#elif 1 +#define MUL(a,b) \ +({ int32_t _ta=(a), _tb=(b), _tc; \ + _tc=(_ta & 0xffff)*(_tb >> 16)+(_ta >> 16)*(_tb & 0xffff); (int32_t)(((_tc >> 14))+ (((_ta >> 16)*(_tb >> 16)) << 2 )); }) +#define MUL_L(a,b) \ +({ int32_t _ta=(a), _tb=(b), _tc; \ + _tc=(_ta & 0xffff)*(_tb >> 16)+(_ta >> 16)*(_tb & 0xffff); (int32_t)((_tc >> 10) + (((_ta >> 16)*(_tb >> 16)) << 6)); }) +#else +#define MUL(a,b) (((a) >> 15) * ((b) >> 15)) +#define MUL_L(a,b) (((a) >> 13) * ((b) >> 13)) +#endif + +#define MUL_C(a,b) MUL_L (a, LEVEL (b)) +#define DIV(a,b) ((((int64_t)LEVEL (a)) << 26) / (b)) +#define BIAS(x) ((x)) + +#endif diff --git a/lib/rbcodec/codecs/liba52/attributes.h b/lib/rbcodec/codecs/liba52/attributes.h new file mode 100644 index 0000000000..988abc0311 --- /dev/null +++ b/lib/rbcodec/codecs/liba52/attributes.h @@ -0,0 +1,37 @@ +/* + * attributes.h + * Copyright (C) 2000-2003 Michel Lespinasse + * Copyright (C) 1999-2000 Aaron Holtzman + * + * This file is part of a52dec, a free ATSC A-52 stream decoder. + * See http://liba52.sourceforge.net/ for updates. + * + * a52dec is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * a52dec is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* use gcc attribs to align critical data structures */ +#ifdef ATTRIBUTE_ALIGNED_MAX +#define ATTR_ALIGN(align) __attribute__ ((__aligned__ ((ATTRIBUTE_ALIGNED_MAX < align) ? ATTRIBUTE_ALIGNED_MAX : align))) +#else +#define ATTR_ALIGN(align) +#endif + +#ifdef HAVE_BUILTIN_EXPECT +#define likely(x) __builtin_expect ((x) != 0, 1) +#define unlikely(x) __builtin_expect ((x) != 0, 0) +#else +#define likely(x) (x) +#define unlikely(x) (x) +#endif diff --git a/lib/rbcodec/codecs/liba52/bit_allocate.c b/lib/rbcodec/codecs/liba52/bit_allocate.c new file mode 100644 index 0000000000..aaac245913 --- /dev/null +++ b/lib/rbcodec/codecs/liba52/bit_allocate.c @@ -0,0 +1,265 @@ +/* + * bit_allocate.c + * Copyright (C) 2000-2003 Michel Lespinasse + * Copyright (C) 1999-2000 Aaron Holtzman + * + * This file is part of a52dec, a free ATSC A-52 stream decoder. + * See http://liba52.sourceforge.net/ for updates. + * + * a52dec is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * a52dec is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "config-a52.h" + +#include + +#include "a52.h" +#include "a52_internal.h" + +static int hthtab[3][50] IDATA_ATTR = { + {0x730, 0x730, 0x7c0, 0x800, 0x820, 0x840, 0x850, 0x850, 0x860, 0x860, + 0x860, 0x860, 0x860, 0x870, 0x870, 0x870, 0x880, 0x880, 0x890, 0x890, + 0x8a0, 0x8a0, 0x8b0, 0x8b0, 0x8c0, 0x8c0, 0x8d0, 0x8e0, 0x8f0, 0x900, + 0x910, 0x910, 0x910, 0x910, 0x900, 0x8f0, 0x8c0, 0x870, 0x820, 0x7e0, + 0x7a0, 0x770, 0x760, 0x7a0, 0x7c0, 0x7c0, 0x6e0, 0x400, 0x3c0, 0x3c0}, + {0x710, 0x710, 0x7a0, 0x7f0, 0x820, 0x830, 0x840, 0x850, 0x850, 0x860, + 0x860, 0x860, 0x860, 0x860, 0x870, 0x870, 0x870, 0x880, 0x880, 0x880, + 0x890, 0x890, 0x8a0, 0x8a0, 0x8b0, 0x8b0, 0x8c0, 0x8c0, 0x8e0, 0x8f0, + 0x900, 0x910, 0x910, 0x910, 0x910, 0x900, 0x8e0, 0x8b0, 0x870, 0x820, + 0x7e0, 0x7b0, 0x760, 0x770, 0x7a0, 0x7c0, 0x780, 0x5d0, 0x3c0, 0x3c0}, + {0x680, 0x680, 0x750, 0x7b0, 0x7e0, 0x810, 0x820, 0x830, 0x840, 0x850, + 0x850, 0x850, 0x860, 0x860, 0x860, 0x860, 0x860, 0x860, 0x860, 0x860, + 0x870, 0x870, 0x870, 0x870, 0x880, 0x880, 0x880, 0x890, 0x8a0, 0x8b0, + 0x8c0, 0x8d0, 0x8e0, 0x8f0, 0x900, 0x910, 0x910, 0x910, 0x900, 0x8f0, + 0x8d0, 0x8b0, 0x840, 0x7f0, 0x790, 0x760, 0x7a0, 0x7c0, 0x7b0, 0x720} +}; + +static int8_t baptab[305] IDATA_ATTR = { + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* 93 padding elems */ + + 16, 16, 16, 16, 16, 16, 16, 16, 16, 14, 14, 14, 14, 14, 14, 14, + 14, 12, 12, 12, 12, 11, 11, 11, 11, 10, 10, 10, 10, 9, 9, 9, + 9, 8, 8, 8, 8, 7, 7, 7, 7, 6, 6, 6, 6, 5, 5, 5, + 5, 4, 4, -3, -3, 3, 3, 3, -2, -2, -1, -1, -1, -1, -1, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0 /* 148 padding elems */ +}; + +static int bndtab[30] IDATA_ATTR = {21, 22, 23, 24, 25, 26, 27, 28, 31, 34, + 37, 40, 43, 46, 49, 55, 61, 67, 73, 79, + 85, 97, 109, 121, 133, 157, 181, 205, 229, 253}; + +static int8_t latab[256] IDATA_ATTR = { + -64, -63, -62, -61, -60, -59, -58, -57, -56, -55, -54, -53, + -52, -52, -51, -50, -49, -48, -47, -47, -46, -45, -44, -44, + -43, -42, -41, -41, -40, -39, -38, -38, -37, -36, -36, -35, + -35, -34, -33, -33, -32, -32, -31, -30, -30, -29, -29, -28, + -28, -27, -27, -26, -26, -25, -25, -24, -24, -23, -23, -22, + -22, -21, -21, -21, -20, -20, -19, -19, -19, -18, -18, -18, + -17, -17, -17, -16, -16, -16, -15, -15, -15, -14, -14, -14, + -13, -13, -13, -13, -12, -12, -12, -12, -11, -11, -11, -11, + -10, -10, -10, -10, -10, -9, -9, -9, -9, -9, -8, -8, + -8, -8, -8, -8, -7, -7, -7, -7, -7, -7, -6, -6, + -6, -6, -6, -6, -6, -6, -5, -5, -5, -5, -5, -5, + -5, -5, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, + -4, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, + -3, -3, -3, -2, -2, -2, -2, -2, -2, -2, -2, -2, + -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0 +}; + +#define UPDATE_LEAK() \ +do { \ + fastleak += fdecay; \ + if (fastleak > psd + fgain) \ + fastleak = psd + fgain; \ + slowleak += sdecay; \ + if (slowleak > psd + sgain) \ + slowleak = psd + sgain; \ +} while (0) + +#define COMPUTE_MASK() \ +do { \ + if (psd > dbknee) \ + mask -= (psd - dbknee) >> 2; \ + if (mask > hth [i >> halfrate]) \ + mask = hth [i >> halfrate]; \ + mask -= snroffset + 128 * deltba[i]; \ + mask = (mask > 0) ? 0 : ((-mask) >> 5); \ + mask -= floor; \ +} while (0) + +void a52_bit_allocate (a52_state_t * state, ba_t * ba, int bndstart, + int start, int end, int fastleak, int slowleak, + expbap_t * expbap) +{ + static int slowgain[4] = {0x540, 0x4d8, 0x478, 0x410}; + static int dbpbtab[4] = {0xc00, 0x500, 0x300, 0x100}; + static int floortab[8] = {0x910, 0x950, 0x990, 0x9d0, + 0xa10, 0xa90, 0xb10, 0x1400}; + + int i, j; + uint8_t * exp; + int8_t * bap; + int fdecay, fgain, sdecay, sgain, dbknee, floor, snroffset; + int psd, mask; + int8_t * deltba; + int * hth; + int halfrate; + + halfrate = state->halfrate; + fdecay = (63 + 20 * ((state->bai >> 7) & 3)) >> halfrate; /* fdcycod */ + fgain = 128 + 128 * (ba->bai & 7); /* fgaincod */ + sdecay = (15 + 2 * (state->bai >> 9)) >> halfrate; /* sdcycod */ + sgain = slowgain[(state->bai >> 5) & 3]; /* sgaincod */ + dbknee = dbpbtab[(state->bai >> 3) & 3]; /* dbpbcod */ + hth = hthtab[state->fscod]; + /* + * if there is no delta bit allocation, make deltba point to an area + * known to contain zeroes. baptab+156 here. + */ + deltba = (ba->deltbae == DELTA_BIT_NONE) ? baptab + 156 : ba->deltba; + floor = floortab[state->bai & 7]; /* floorcod */ + snroffset = 960 - 64 * state->csnroffst - 4 * (ba->bai >> 3) + floor; + floor >>= 5; + + exp = expbap->exp; + bap = expbap->bap; + + i = bndstart; + j = start; + if (start == 0) { /* not the coupling channel */ + int lowcomp; + + lowcomp = 0; + j = end - 1; + do { + if (i < j) { + if (exp[i+1] == exp[i] - 2) + lowcomp = 384; + else if (lowcomp && (exp[i+1] > exp[i])) + lowcomp -= 64; + } + psd = 128 * exp[i]; + mask = psd + fgain + lowcomp; + COMPUTE_MASK (); + bap[i] = (baptab+156)[mask + 4 * exp[i]]; + i++; + } while ((i < 3) || ((i < 7) && (exp[i] > exp[i-1]))); + fastleak = psd + fgain; + slowleak = psd + sgain; + + while (i < 7) { + if (i < j) { + if (exp[i+1] == exp[i] - 2) + lowcomp = 384; + else if (lowcomp && (exp[i+1] > exp[i])) + lowcomp -= 64; + } + psd = 128 * exp[i]; + UPDATE_LEAK (); + mask = ((fastleak + lowcomp < slowleak) ? + fastleak + lowcomp : slowleak); + COMPUTE_MASK (); + bap[i] = (baptab+156)[mask + 4 * exp[i]]; + i++; + } + + if (end == 7) /* lfe channel */ + return; + + do { + if (exp[i+1] == exp[i] - 2) + lowcomp = 320; + else if (lowcomp && (exp[i+1] > exp[i])) + lowcomp -= 64; + psd = 128 * exp[i]; + UPDATE_LEAK (); + mask = ((fastleak + lowcomp < slowleak) ? + fastleak + lowcomp : slowleak); + COMPUTE_MASK (); + bap[i] = (baptab+156)[mask + 4 * exp[i]]; + i++; + } while (i < 20); + + while (lowcomp > 128) { /* two iterations maximum */ + lowcomp -= 128; + psd = 128 * exp[i]; + UPDATE_LEAK (); + mask = ((fastleak + lowcomp < slowleak) ? + fastleak + lowcomp : slowleak); + COMPUTE_MASK (); + bap[i] = (baptab+156)[mask + 4 * exp[i]]; + i++; + } + j = i; + } + + do { + int startband, endband; + + startband = j; + endband = (bndtab[i-20] < end) ? bndtab[i-20] : end; + psd = 128 * exp[j++]; + while (j < endband) { + int next, delta; + + next = 128 * exp[j++]; + delta = next - psd; + switch (delta >> 9) { + case -6: case -5: case -4: case -3: case -2: + psd = next; + break; + case -1: + psd = next + latab[(-delta) >> 1]; + break; + case 0: + psd += latab[delta >> 1]; + break; + } + } + /* minpsd = -289 */ + UPDATE_LEAK (); + mask = (fastleak < slowleak) ? fastleak : slowleak; + COMPUTE_MASK (); + i++; + j = startband; + do { + /* max(mask+4*exp)=147=-(minpsd+fgain-deltba-snroffset)>>5+4*exp */ + /* min(mask+4*exp)=-156=-(sgain-deltba-snroffset)>>5 */ + bap[j] = (baptab+156)[mask + 4 * exp[j]]; + } while (++j < endband); + } while (j < end); +} diff --git a/lib/rbcodec/codecs/liba52/bitstream.c b/lib/rbcodec/codecs/liba52/bitstream.c new file mode 100644 index 0000000000..155368f1ed --- /dev/null +++ b/lib/rbcodec/codecs/liba52/bitstream.c @@ -0,0 +1,97 @@ +/* + * bitstream.c + * Copyright (C) 2000-2003 Michel Lespinasse + * Copyright (C) 1999-2000 Aaron Holtzman + * + * This file is part of a52dec, a free ATSC A-52 stream decoder. + * See http://liba52.sourceforge.net/ for updates. + * + * a52dec is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * a52dec is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "config-a52.h" + +#include + +#include "a52.h" +#include "a52_internal.h" +#include "bitstream.h" + +#define BUFFER_SIZE 4096 + +void a52_bitstream_set_ptr (a52_state_t * state, uint8_t * buf) +{ + int align; + + align = (long)buf & 3; + state->buffer_start = (uint32_t *) (buf - align); + state->bits_left = 0; + state->current_word = 0; + bitstream_get (state, align * 8); + bitstream_get_2 (state, 0); /* pretend function is used - keep gcc happy */ +} + +static inline void bitstream_fill_current (a52_state_t * state) +{ + uint32_t tmp; + + tmp = *(state->buffer_start++); + state->current_word = swab32 (tmp); +} + +/* + * The fast paths for _get is in the + * bitstream.h header file so it can be inlined. + * + * The "bottom half" of this routine is suffixed _bh + * + * -ah + */ + +uint32_t a52_bitstream_get_bh (a52_state_t * state, uint32_t num_bits) +{ + uint32_t result; + + num_bits -= state->bits_left; + result = ((state->current_word << (32 - state->bits_left)) >> + (32 - state->bits_left)); + + bitstream_fill_current (state); + + if (num_bits != 0) + result = (result << num_bits) | (state->current_word >> (32 - num_bits)); + + state->bits_left = 32 - num_bits; + + return result; +} + +int32_t a52_bitstream_get_bh_2 (a52_state_t * state, uint32_t num_bits) +{ + int32_t result; + + num_bits -= state->bits_left; + result = ((((int32_t)state->current_word) << (32 - state->bits_left)) >> + (32 - state->bits_left)); + + bitstream_fill_current(state); + + if (num_bits != 0) + result = (result << num_bits) | (state->current_word >> (32 - num_bits)); + + state->bits_left = 32 - num_bits; + + return result; +} diff --git a/lib/rbcodec/codecs/liba52/bitstream.h b/lib/rbcodec/codecs/liba52/bitstream.h new file mode 100644 index 0000000000..56de1571b7 --- /dev/null +++ b/lib/rbcodec/codecs/liba52/bitstream.h @@ -0,0 +1,54 @@ +/* + * bitstream.h + * Copyright (C) 2000-2003 Michel Lespinasse + * Copyright (C) 1999-2000 Aaron Holtzman + * + * This file is part of a52dec, a free ATSC A-52 stream decoder. + * See http://liba52.sourceforge.net/ for updates. + * + * a52dec is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * a52dec is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#define swab32(x) (betoh32(x)) + +void a52_bitstream_set_ptr (a52_state_t * state, uint8_t * buf); +uint32_t a52_bitstream_get_bh (a52_state_t * state, uint32_t num_bits); +int32_t a52_bitstream_get_bh_2 (a52_state_t * state, uint32_t num_bits); + +static inline uint32_t bitstream_get (a52_state_t * state, uint32_t num_bits) +{ + uint32_t result; + + if (num_bits < state->bits_left) { + result = (state->current_word << (32 - state->bits_left)) >> (32 - num_bits); + state->bits_left -= num_bits; + return result; + } + + return a52_bitstream_get_bh (state, num_bits); +} + +static inline int32_t bitstream_get_2 (a52_state_t * state, uint32_t num_bits) +{ + int32_t result; + + if (num_bits < state->bits_left) { + result = (((int32_t)state->current_word) << (32 - state->bits_left)) >> (32 - num_bits); + state->bits_left -= num_bits; + return result; + } + + return a52_bitstream_get_bh_2 (state, num_bits); +} diff --git a/lib/rbcodec/codecs/liba52/config-a52.h b/lib/rbcodec/codecs/liba52/config-a52.h new file mode 100644 index 0000000000..ade7ecf9b8 --- /dev/null +++ b/lib/rbcodec/codecs/liba52/config-a52.h @@ -0,0 +1,26 @@ +#include "codeclib.h" + +/* a52dec profiling */ +/* #undef A52DEC_GPROF */ + +/* Define to 1 if you have the `memalign' function. */ +/* #undef HAVE_MEMALIGN 1 */ + +/* liba52 djbfft support */ +/* #undef LIBA52_DJBFFT */ + +/* a52 sample precision */ +/* #undef LIBA52_DOUBLE */ + +/* use fixed-point arithmetic */ +#define LIBA52_FIXED + +/* Define to 1 if your processor stores words with the most significant byte + first (like Motorola and SPARC, unlike Intel and VAX). */ + +/* Used in bitstream.h */ + +#ifdef ROCKBOX_BIG_ENDIAN +#define WORDS_BIGENDIAN 1 +#endif + diff --git a/lib/rbcodec/codecs/liba52/downmix.c b/lib/rbcodec/codecs/liba52/downmix.c new file mode 100644 index 0000000000..dd2867cb92 --- /dev/null +++ b/lib/rbcodec/codecs/liba52/downmix.c @@ -0,0 +1,688 @@ +/* + * downmix.c + * Copyright (C) 2000-2003 Michel Lespinasse + * Copyright (C) 1999-2000 Aaron Holtzman + * + * This file is part of a52dec, a free ATSC A-52 stream decoder. + * See http://liba52.sourceforge.net/ for updates. + * + * a52dec is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * a52dec is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "config-a52.h" + +#include +#include + +#include "a52.h" +#include "a52_internal.h" + +#define CONVERT(acmod,output) (((output) << 3) + (acmod)) + +int a52_downmix_init (int input, int flags, level_t * level, + level_t clev, level_t slev) +{ + static uint8_t table[11][8] = { + {A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_STEREO, + A52_STEREO, A52_STEREO, A52_STEREO, A52_STEREO}, + {A52_MONO, A52_MONO, A52_MONO, A52_MONO, + A52_MONO, A52_MONO, A52_MONO, A52_MONO}, + {A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_STEREO, + A52_STEREO, A52_STEREO, A52_STEREO, A52_STEREO}, + {A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_3F, + A52_STEREO, A52_3F, A52_STEREO, A52_3F}, + {A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_STEREO, + A52_2F1R, A52_2F1R, A52_2F1R, A52_2F1R}, + {A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_STEREO, + A52_2F1R, A52_3F1R, A52_2F1R, A52_3F1R}, + {A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_3F, + A52_2F2R, A52_2F2R, A52_2F2R, A52_2F2R}, + {A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_3F, + A52_2F2R, A52_3F2R, A52_2F2R, A52_3F2R}, + {A52_CHANNEL1, A52_MONO, A52_MONO, A52_MONO, + A52_MONO, A52_MONO, A52_MONO, A52_MONO}, + {A52_CHANNEL2, A52_MONO, A52_MONO, A52_MONO, + A52_MONO, A52_MONO, A52_MONO, A52_MONO}, + {A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_DOLBY, + A52_DOLBY, A52_DOLBY, A52_DOLBY, A52_DOLBY} + }; + int output; + + output = flags & A52_CHANNEL_MASK; + if (output > A52_DOLBY) + return -1; + + output = table[output][input & 7]; + + if (output == A52_STEREO && + (input == A52_DOLBY || (input == A52_3F && clev == LEVEL (LEVEL_3DB)))) + output = A52_DOLBY; + + if (flags & A52_ADJUST_LEVEL) { + level_t adjust; + + switch (CONVERT (input & 7, output)) { + + case CONVERT (A52_3F, A52_MONO): + adjust = DIV (LEVEL_3DB, LEVEL (1) + clev); + break; + + case CONVERT (A52_STEREO, A52_MONO): + case CONVERT (A52_2F2R, A52_2F1R): + case CONVERT (A52_3F2R, A52_3F1R): + level_3db: + adjust = LEVEL (LEVEL_3DB); + break; + + case CONVERT (A52_3F2R, A52_2F1R): + if (clev < LEVEL (LEVEL_PLUS3DB - 1)) + goto level_3db; + /* break thru */ + case CONVERT (A52_3F, A52_STEREO): + case CONVERT (A52_3F1R, A52_2F1R): + case CONVERT (A52_3F1R, A52_2F2R): + case CONVERT (A52_3F2R, A52_2F2R): + adjust = DIV (1, LEVEL (1) + clev); + break; + + case CONVERT (A52_2F1R, A52_MONO): + adjust = DIV (LEVEL_PLUS3DB, LEVEL (2) + slev); + break; + + case CONVERT (A52_2F1R, A52_STEREO): + case CONVERT (A52_3F1R, A52_3F): + adjust = DIV (1, LEVEL (1) + MUL_C (slev, LEVEL_3DB)); + break; + + case CONVERT (A52_3F1R, A52_MONO): + adjust = DIV (LEVEL_3DB, LEVEL (1) + clev + MUL_C (slev, 0.5)); + break; + + case CONVERT (A52_3F1R, A52_STEREO): + adjust = DIV (1, LEVEL (1) + clev + MUL_C (slev, LEVEL_3DB)); + break; + + case CONVERT (A52_2F2R, A52_MONO): + adjust = DIV (LEVEL_3DB, LEVEL (1) + slev); + break; + + case CONVERT (A52_2F2R, A52_STEREO): + case CONVERT (A52_3F2R, A52_3F): + adjust = DIV (1, LEVEL (1) + slev); + break; + + case CONVERT (A52_3F2R, A52_MONO): + adjust = DIV (LEVEL_3DB, LEVEL (1) + clev + slev); + break; + + case CONVERT (A52_3F2R, A52_STEREO): + adjust = DIV (1, LEVEL (1) + clev + slev); + break; + + case CONVERT (A52_MONO, A52_DOLBY): + adjust = LEVEL (LEVEL_PLUS3DB); + break; + + case CONVERT (A52_3F, A52_DOLBY): + case CONVERT (A52_2F1R, A52_DOLBY): + adjust = LEVEL (1 / (1 + LEVEL_3DB)); + break; + + case CONVERT (A52_3F1R, A52_DOLBY): + case CONVERT (A52_2F2R, A52_DOLBY): + adjust = LEVEL (1 / (1 + 2 * LEVEL_3DB)); + break; + + case CONVERT (A52_3F2R, A52_DOLBY): + adjust = LEVEL (1 / (1 + 3 * LEVEL_3DB)); + break; + + default: + return output; + } + + *level = MUL_L (*level, adjust); + } + + return output; +} + +int a52_downmix_coeff (level_t * coeff, int acmod, int output, level_t level, + level_t clev, level_t slev) +{ + level_t level_3db; + + level_3db = MUL_C (level, LEVEL_3DB); + + switch (CONVERT (acmod, output & A52_CHANNEL_MASK)) { + + case CONVERT (A52_CHANNEL, A52_CHANNEL): + case CONVERT (A52_MONO, A52_MONO): + case CONVERT (A52_STEREO, A52_STEREO): + case CONVERT (A52_3F, A52_3F): + case CONVERT (A52_2F1R, A52_2F1R): + case CONVERT (A52_3F1R, A52_3F1R): + case CONVERT (A52_2F2R, A52_2F2R): + case CONVERT (A52_3F2R, A52_3F2R): + case CONVERT (A52_STEREO, A52_DOLBY): + coeff[0] = coeff[1] = coeff[2] = coeff[3] = coeff[4] = level; + return 0; + + case CONVERT (A52_CHANNEL, A52_MONO): + coeff[0] = coeff[1] = MUL_C (level, LEVEL_6DB); + return 3; + + case CONVERT (A52_STEREO, A52_MONO): + coeff[0] = coeff[1] = level_3db; + return 3; + + case CONVERT (A52_3F, A52_MONO): + coeff[0] = coeff[2] = level_3db; + coeff[1] = MUL_C (MUL_L (level_3db, clev), LEVEL_PLUS6DB); + return 7; + + case CONVERT (A52_2F1R, A52_MONO): + coeff[0] = coeff[1] = level_3db; + coeff[2] = MUL_L (level_3db, slev); + return 7; + + case CONVERT (A52_2F2R, A52_MONO): + coeff[0] = coeff[1] = level_3db; + coeff[2] = coeff[3] = MUL_L (level_3db, slev); + return 15; + + case CONVERT (A52_3F1R, A52_MONO): + coeff[0] = coeff[2] = level_3db; + coeff[1] = MUL_C (MUL_L (level_3db, clev), LEVEL_PLUS6DB); + coeff[3] = MUL_L (level_3db, slev); + return 15; + + case CONVERT (A52_3F2R, A52_MONO): + coeff[0] = coeff[2] = level_3db; + coeff[1] = MUL_C (MUL_L (level_3db, clev), LEVEL_PLUS6DB); + coeff[3] = coeff[4] = MUL_L (level_3db, slev); + return 31; + + case CONVERT (A52_MONO, A52_DOLBY): + coeff[0] = level_3db; + return 0; + + case CONVERT (A52_3F, A52_DOLBY): + coeff[0] = coeff[2] = coeff[3] = coeff[4] = level; + coeff[1] = level_3db; + return 7; + + case CONVERT (A52_3F, A52_STEREO): + case CONVERT (A52_3F1R, A52_2F1R): + case CONVERT (A52_3F2R, A52_2F2R): + coeff[0] = coeff[2] = coeff[3] = coeff[4] = level; + coeff[1] = MUL_L (level, clev); + return 7; + + case CONVERT (A52_2F1R, A52_DOLBY): + coeff[0] = coeff[1] = level; + coeff[2] = level_3db; + return 7; + + case CONVERT (A52_2F1R, A52_STEREO): + coeff[0] = coeff[1] = level; + coeff[2] = MUL_L (level_3db, slev); + return 7; + + case CONVERT (A52_3F1R, A52_DOLBY): + coeff[0] = coeff[2] = level; + coeff[1] = coeff[3] = level_3db; + return 15; + + case CONVERT (A52_3F1R, A52_STEREO): + coeff[0] = coeff[2] = level; + coeff[1] = MUL_L (level, clev); + coeff[3] = MUL_L (level_3db, slev); + return 15; + + case CONVERT (A52_2F2R, A52_DOLBY): + coeff[0] = coeff[1] = level; + coeff[2] = coeff[3] = level_3db; + return 15; + + case CONVERT (A52_2F2R, A52_STEREO): + coeff[0] = coeff[1] = level; + coeff[2] = coeff[3] = MUL_L (level, slev); + return 15; + + case CONVERT (A52_3F2R, A52_DOLBY): + coeff[0] = coeff[2] = level; + coeff[1] = coeff[3] = coeff[4] = level_3db; + return 31; + + case CONVERT (A52_3F2R, A52_2F1R): + coeff[0] = coeff[2] = level; + coeff[1] = MUL_L (level, clev); + coeff[3] = coeff[4] = level_3db; + return 31; + + case CONVERT (A52_3F2R, A52_STEREO): + coeff[0] = coeff[2] = level; + coeff[1] = MUL_L (level, clev); + coeff[3] = coeff[4] = MUL_L (level, slev); + return 31; + + case CONVERT (A52_3F1R, A52_3F): + coeff[0] = coeff[1] = coeff[2] = level; + coeff[3] = MUL_L (level_3db, slev); + return 13; + + case CONVERT (A52_3F2R, A52_3F): + coeff[0] = coeff[1] = coeff[2] = level; + coeff[3] = coeff[4] = MUL_L (level, slev); + return 29; + + case CONVERT (A52_2F2R, A52_2F1R): + coeff[0] = coeff[1] = level; + coeff[2] = coeff[3] = level_3db; + return 12; + + case CONVERT (A52_3F2R, A52_3F1R): + coeff[0] = coeff[1] = coeff[2] = level; + coeff[3] = coeff[4] = level_3db; + return 24; + + case CONVERT (A52_2F1R, A52_2F2R): + coeff[0] = coeff[1] = level; + coeff[2] = level_3db; + return 0; + + case CONVERT (A52_3F1R, A52_2F2R): + coeff[0] = coeff[2] = level; + coeff[1] = MUL_L (level, clev); + coeff[3] = level_3db; + return 7; + + case CONVERT (A52_3F1R, A52_3F2R): + coeff[0] = coeff[1] = coeff[2] = level; + coeff[3] = level_3db; + return 0; + + case CONVERT (A52_CHANNEL, A52_CHANNEL1): + coeff[0] = level; + coeff[1] = 0; + return 0; + + case CONVERT (A52_CHANNEL, A52_CHANNEL2): + coeff[0] = 0; + coeff[1] = level; + return 0; + } + + return -1; /* NOTREACHED */ +} + +static void mix2to1 (sample_t * dest, sample_t * src) +{ + int i; + + for (i = 0; i < 256; i++) + dest[i] += BIAS (src[i]); +} + +static void mix3to1 (sample_t * samples) +{ + int i; + + for (i = 0; i < 256; i++) + samples[i] += BIAS (samples[i + 256] + samples[i + 512]); +} + +static void mix4to1 (sample_t * samples) +{ + int i; + + for (i = 0; i < 256; i++) + samples[i] += BIAS (samples[i + 256] + samples[i + 512] + + samples[i + 768]); +} + +static void mix5to1 (sample_t * samples) +{ + int i; + + for (i = 0; i < 256; i++) + samples[i] += BIAS (samples[i + 256] + samples[i + 512] + + samples[i + 768] + samples[i + 1024]); +} + +static void mix3to2 (sample_t * samples) +{ + int i; + sample_t common; + + for (i = 0; i < 256; i++) { + common = BIAS (samples[i + 256]); + samples[i] += common; + samples[i + 256] = samples[i + 512] + common; + } +} + +static void mix21to2 (sample_t * left, sample_t * right) +{ + int i; + sample_t common; + + for (i = 0; i < 256; i++) { + common = BIAS (right[i + 256]); + left[i] += common; + right[i] += common; + } +} + +static void mix21toS (sample_t * samples) +{ + int i; + sample_t surround; + + for (i = 0; i < 256; i++) { + surround = samples[i + 512]; + samples[i] += BIAS (-surround); + samples[i + 256] += BIAS (surround); + } +} + +static void mix31to2 (sample_t * samples) +{ + int i; + sample_t common; + + for (i = 0; i < 256; i++) { + common = BIAS (samples[i + 256] + samples[i + 768]); + samples[i] += common; + samples[i + 256] = samples[i + 512] + common; + } +} + +static void mix31toS (sample_t * samples) +{ + int i; + sample_t common, surround; + + for (i = 0; i < 256; i++) { + common = BIAS (samples[i + 256]); + surround = samples[i + 768]; + samples[i] += common - surround; + samples[i + 256] = samples[i + 512] + common + surround; + } +} + +static void mix22toS (sample_t * samples) +{ + int i; + sample_t surround; + + for (i = 0; i < 256; i++) { + surround = samples[i + 512] + samples[i + 768]; + samples[i] += BIAS (-surround); + samples[i + 256] += BIAS (surround); + } +} + +static void mix32to2 (sample_t * samples) +{ + int i; + sample_t common; + + for (i = 0; i < 256; i++) { + common = BIAS (samples[i + 256]); + samples[i] += common + samples[i + 768]; + samples[i + 256] = common + samples[i + 512] + samples[i + 1024]; + } +} + +static void mix32toS (sample_t * samples) +{ + int i; + sample_t common, surround; + + for (i = 0; i < 256; i++) { + common = BIAS (samples[i + 256]); + surround = samples[i + 768] + samples[i + 1024]; + samples[i] += common - surround; + samples[i + 256] = samples[i + 512] + common + surround; + } +} + +static void move2to1 (sample_t * src, sample_t * dest) +{ + int i; + + for (i = 0; i < 256; i++) + dest[i] = BIAS (src[i] + src[i + 256]); +} + +static void zero (sample_t * samples) +{ + int i; + + for (i = 0; i < 256; i++) + samples[i] = 0; +} + +void a52_downmix (sample_t * samples, int acmod, int output, + level_t clev, level_t slev) +{ + /* avoid compiler warning */ + (void)clev; + + switch (CONVERT (acmod, output & A52_CHANNEL_MASK)) { + + case CONVERT (A52_CHANNEL, A52_CHANNEL2): + memcpy (samples, samples + 256, 256 * sizeof (sample_t)); + break; + + case CONVERT (A52_CHANNEL, A52_MONO): + case CONVERT (A52_STEREO, A52_MONO): + mix_2to1: + mix2to1 (samples, samples + 256); + break; + + case CONVERT (A52_2F1R, A52_MONO): + if (slev == 0) + goto mix_2to1; + case CONVERT (A52_3F, A52_MONO): + mix_3to1: + mix3to1 (samples); + break; + + case CONVERT (A52_3F1R, A52_MONO): + if (slev == 0) + goto mix_3to1; + case CONVERT (A52_2F2R, A52_MONO): + if (slev == 0) + goto mix_2to1; + mix4to1 (samples); + break; + + case CONVERT (A52_3F2R, A52_MONO): + if (slev == 0) + goto mix_3to1; + mix5to1 (samples); + break; + + case CONVERT (A52_MONO, A52_DOLBY): + memcpy (samples + 256, samples, 256 * sizeof (sample_t)); + break; + + case CONVERT (A52_3F, A52_STEREO): + case CONVERT (A52_3F, A52_DOLBY): + mix_3to2: + mix3to2 (samples); + break; + + case CONVERT (A52_2F1R, A52_STEREO): + if (slev == 0) + break; + mix21to2 (samples, samples + 256); + break; + + case CONVERT (A52_2F1R, A52_DOLBY): + mix21toS (samples); + break; + + case CONVERT (A52_3F1R, A52_STEREO): + if (slev == 0) + goto mix_3to2; + mix31to2 (samples); + break; + + case CONVERT (A52_3F1R, A52_DOLBY): + mix31toS (samples); + break; + + case CONVERT (A52_2F2R, A52_STEREO): + if (slev == 0) + break; + mix2to1 (samples, samples + 512); + mix2to1 (samples + 256, samples + 768); + break; + + case CONVERT (A52_2F2R, A52_DOLBY): + mix22toS (samples); + break; + + case CONVERT (A52_3F2R, A52_STEREO): + if (slev == 0) + goto mix_3to2; + mix32to2 (samples); + break; + + case CONVERT (A52_3F2R, A52_DOLBY): + mix32toS (samples); + break; + + case CONVERT (A52_3F1R, A52_3F): + if (slev == 0) + break; + mix21to2 (samples, samples + 512); + break; + + case CONVERT (A52_3F2R, A52_3F): + if (slev == 0) + break; + mix2to1 (samples, samples + 768); + mix2to1 (samples + 512, samples + 1024); + break; + + case CONVERT (A52_3F1R, A52_2F1R): + mix3to2 (samples); + memcpy (samples + 512, samples + 768, 256 * sizeof (sample_t)); + break; + + case CONVERT (A52_2F2R, A52_2F1R): + mix2to1 (samples + 512, samples + 768); + break; + + case CONVERT (A52_3F2R, A52_2F1R): + mix3to2 (samples); + move2to1 (samples + 768, samples + 512); + break; + + case CONVERT (A52_3F2R, A52_3F1R): + mix2to1 (samples + 768, samples + 1024); + break; + + case CONVERT (A52_2F1R, A52_2F2R): + memcpy (samples + 768, samples + 512, 256 * sizeof (sample_t)); + break; + + case CONVERT (A52_3F1R, A52_2F2R): + mix3to2 (samples); + memcpy (samples + 512, samples + 768, 256 * sizeof (sample_t)); + break; + + case CONVERT (A52_3F2R, A52_2F2R): + mix3to2 (samples); + memcpy (samples + 512, samples + 768, 256 * sizeof (sample_t)); + memcpy (samples + 768, samples + 1024, 256 * sizeof (sample_t)); + break; + + case CONVERT (A52_3F1R, A52_3F2R): + memcpy (samples + 1024, samples + 768, 256 * sizeof (sample_t)); + break; + } +} + +void a52_upmix (sample_t * samples, int acmod, int output) +{ + switch (CONVERT (acmod, output & A52_CHANNEL_MASK)) { + + case CONVERT (A52_CHANNEL, A52_CHANNEL2): + memcpy (samples + 256, samples, 256 * sizeof (sample_t)); + break; + + case CONVERT (A52_3F2R, A52_MONO): + zero (samples + 1024); + case CONVERT (A52_3F1R, A52_MONO): + case CONVERT (A52_2F2R, A52_MONO): + zero (samples + 768); + case CONVERT (A52_3F, A52_MONO): + case CONVERT (A52_2F1R, A52_MONO): + zero (samples + 512); + case CONVERT (A52_CHANNEL, A52_MONO): + case CONVERT (A52_STEREO, A52_MONO): + zero (samples + 256); + break; + + case CONVERT (A52_3F2R, A52_STEREO): + case CONVERT (A52_3F2R, A52_DOLBY): + zero (samples + 1024); + case CONVERT (A52_3F1R, A52_STEREO): + case CONVERT (A52_3F1R, A52_DOLBY): + zero (samples + 768); + case CONVERT (A52_3F, A52_STEREO): + case CONVERT (A52_3F, A52_DOLBY): + mix_3to2: + memcpy (samples + 512, samples + 256, 256 * sizeof (sample_t)); + zero (samples + 256); + break; + + case CONVERT (A52_2F2R, A52_STEREO): + case CONVERT (A52_2F2R, A52_DOLBY): + zero (samples + 768); + case CONVERT (A52_2F1R, A52_STEREO): + case CONVERT (A52_2F1R, A52_DOLBY): + zero (samples + 512); + break; + + case CONVERT (A52_3F2R, A52_3F): + zero (samples + 1024); + case CONVERT (A52_3F1R, A52_3F): + case CONVERT (A52_2F2R, A52_2F1R): + zero (samples + 768); + break; + + case CONVERT (A52_3F2R, A52_3F1R): + zero (samples + 1024); + break; + + case CONVERT (A52_3F2R, A52_2F1R): + zero (samples + 1024); + case CONVERT (A52_3F1R, A52_2F1R): + mix_31to21: + memcpy (samples + 768, samples + 512, 256 * sizeof (sample_t)); + goto mix_3to2; + + case CONVERT (A52_3F2R, A52_2F2R): + memcpy (samples + 1024, samples + 768, 256 * sizeof (sample_t)); + goto mix_31to21; + } +} diff --git a/lib/rbcodec/codecs/liba52/imdct.c b/lib/rbcodec/codecs/liba52/imdct.c new file mode 100644 index 0000000000..e93424c5fa --- /dev/null +++ b/lib/rbcodec/codecs/liba52/imdct.c @@ -0,0 +1,486 @@ +/* + * imdct.c + * Copyright (C) 2000-2003 Michel Lespinasse + * Copyright (C) 1999-2000 Aaron Holtzman + * + * The ifft algorithms in this file have been largely inspired by Dan + * Bernstein's work, djbfft, available at http://cr.yp.to/djbfft.html + * + * This file is part of a52dec, a free ATSC A-52 stream decoder. + * See http://liba52.sourceforge.net/ for updates. + * + * a52dec is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * a52dec is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "config-a52.h" + +#include +#include +#ifdef LIBA52_DJBFFT +#include +#include +#endif +#ifndef M_PI +#define M_PI 3.1415926535897932384626433832795029 +#endif +#include + +#include "a52.h" +#include "a52_internal.h" +#include "mm_accel.h" + +typedef struct complex_s { + sample_t real; + sample_t imag; +} complex_t; + +static const uint8_t fftorder[] = { + 0,128, 64,192, 32,160,224, 96, 16,144, 80,208,240,112, 48,176, + 8,136, 72,200, 40,168,232,104,248,120, 56,184, 24,152,216, 88, + 4,132, 68,196, 36,164,228,100, 20,148, 84,212,244,116, 52,180, + 252,124, 60,188, 28,156,220, 92, 12,140, 76,204,236,108, 44,172, + 2,130, 66,194, 34,162,226, 98, 18,146, 82,210,242,114, 50,178, + 10,138, 74,202, 42,170,234,106,250,122, 58,186, 26,154,218, 90, + 254,126, 62,190, 30,158,222, 94, 14,142, 78,206,238,110, 46,174, + 6,134, 70,198, 38,166,230,102,246,118, 54,182, 22,150,214, 86 +}; + +/* Root values for IFFT */ +//static sample_t roots16[3]; +//static sample_t roots32[7]; +//static sample_t roots64[15]; +//static sample_t roots128[31]; + +/* Twiddle factors for IMDCT */ +//static complex_t pre1[128]; +//static complex_t post1[64]; +//static complex_t pre2[64]; +//static complex_t post2[32]; + +//static sample_t a52_imdct_window[256]; +#include "imdct_lookups.h" + + +/* +static void (* ifft128) (complex_t * buf); +static void (* ifft64) (complex_t * buf); + +static inline void ifft2 (complex_t * buf) +{ + sample_t r, i; + + r = buf[0].real; + i = buf[0].imag; + buf[0].real += buf[1].real; + buf[0].imag += buf[1].imag; + buf[1].real = r - buf[1].real; + buf[1].imag = i - buf[1].imag; +} + +static inline void ifft4 (complex_t * buf) +{ + sample_t tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7, tmp8; + + tmp1 = buf[0].real + buf[1].real; + tmp2 = buf[3].real + buf[2].real; + tmp3 = buf[0].imag + buf[1].imag; + tmp4 = buf[2].imag + buf[3].imag; + tmp5 = buf[0].real - buf[1].real; + tmp6 = buf[0].imag - buf[1].imag; + tmp7 = buf[2].imag - buf[3].imag; + tmp8 = buf[3].real - buf[2].real; + + buf[0].real = tmp1 + tmp2; + buf[0].imag = tmp3 + tmp4; + buf[2].real = tmp1 - tmp2; + buf[2].imag = tmp3 - tmp4; + buf[1].real = tmp5 + tmp7; + buf[1].imag = tmp6 + tmp8; + buf[3].real = tmp5 - tmp7; + buf[3].imag = tmp6 - tmp8; +} +*/ +/* basic radix-2 ifft butterfly */ + +#define BUTTERFLY_0(t0,t1,W0,W1,d0,d1) do { \ + t0 = MUL (W1, d1) + MUL (W0, d0); \ + t1 = MUL (W0, d1) - MUL (W1, d0); \ +} while (0) + +/* radix-2 ifft butterfly with bias */ + +#define BUTTERFLY_B(t0,t1,W0,W1,d0,d1) do { \ + t0 = BIAS (MUL (d1, W1) + MUL (d0, W0)); \ + t1 = BIAS (MUL (d1, W0) - MUL (d0, W1)); \ +} while (0) + +/* the basic split-radix ifft butterfly */ + +#define BUTTERFLY(a0,a1,a2,a3,wr,wi) do { \ + BUTTERFLY_0 (tmp5, tmp6, wr, wi, a2.real, a2.imag); \ + BUTTERFLY_0 (tmp8, tmp7, wr, wi, a3.imag, a3.real); \ + tmp1 = tmp5 + tmp7; \ + tmp2 = tmp6 + tmp8; \ + tmp3 = tmp6 - tmp8; \ + tmp4 = tmp7 - tmp5; \ + a2.real = a0.real - tmp1; \ + a2.imag = a0.imag - tmp2; \ + a3.real = a1.real - tmp3; \ + a3.imag = a1.imag - tmp4; \ + a0.real += tmp1; \ + a0.imag += tmp2; \ + a1.real += tmp3; \ + a1.imag += tmp4; \ +} while (0) + +/* split-radix ifft butterfly, specialized for wr=1 wi=0 */ + +#define BUTTERFLY_ZERO(a0,a1,a2,a3) do { \ + tmp1 = a2.real + a3.real; \ + tmp2 = a2.imag + a3.imag; \ + tmp3 = a2.imag - a3.imag; \ + tmp4 = a3.real - a2.real; \ + a2.real = a0.real - tmp1; \ + a2.imag = a0.imag - tmp2; \ + a3.real = a1.real - tmp3; \ + a3.imag = a1.imag - tmp4; \ + a0.real += tmp1; \ + a0.imag += tmp2; \ + a1.real += tmp3; \ + a1.imag += tmp4; \ +} while (0) + +/* split-radix ifft butterfly, specialized for wr=wi */ +/* +#define BUTTERFLY_HALF(a0,a1,a2,a3,w) do { \ + tmp5 = MUL (a2.real + a2.imag, w); \ + tmp6 = MUL (a2.imag - a2.real, w); \ + tmp7 = MUL (a3.real - a3.imag, w); \ + tmp8 = MUL (a3.imag + a3.real, w); \ + tmp1 = tmp5 + tmp7; \ + tmp2 = tmp6 + tmp8; \ + tmp3 = tmp6 - tmp8; \ + tmp4 = tmp7 - tmp5; \ + a2.real = a0.real - tmp1; \ + a2.imag = a0.imag - tmp2; \ + a3.real = a1.real - tmp3; \ + a3.imag = a1.imag - tmp4; \ + a0.real += tmp1; \ + a0.imag += tmp2; \ + a1.real += tmp3; \ + a1.imag += tmp4; \ +} while (0) + +static inline void ifft8 (complex_t * buf) +{ + sample_t tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7, tmp8; + + ifft4 (buf); + ifft2 (buf + 4); + ifft2 (buf + 6); + BUTTERFLY_ZERO (buf[0], buf[2], buf[4], buf[6]); + BUTTERFLY_HALF (buf[1], buf[3], buf[5], buf[7], roots16[1]); +} + +static void ifft_pass (complex_t * buf, const sample_t * weight, int n) +{ + complex_t * buf1; + complex_t * buf2; + complex_t * buf3; + sample_t tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7, tmp8; + int i; + + buf++; + buf1 = buf + n; + buf2 = buf + 2 * n; + buf3 = buf + 3 * n; + + BUTTERFLY_ZERO (buf[-1], buf1[-1], buf2[-1], buf3[-1]); + + i = n - 1; + + do { + BUTTERFLY (buf[0], buf1[0], buf2[0], buf3[0], + weight[0], weight[2*i-n]); + buf++; + buf1++; + buf2++; + buf3++; + weight++; + } while (--i); +} + +static void ifft16 (complex_t * buf) +{ + ifft8 (buf); + ifft4 (buf + 8); + ifft4 (buf + 12); + ifft_pass (buf, roots16, 4); +} + +static void ifft32 (complex_t * buf) +{ + ifft16 (buf); + ifft8 (buf + 16); + ifft8 (buf + 24); + ifft_pass (buf, roots32, 8); +} + +static void ifft64_c (complex_t * buf) +{ + ifft32 (buf); + ifft16 (buf + 32); + ifft16 (buf + 48); + ifft_pass (buf, roots64, 16); +} + +static void ifft128_c (complex_t * buf) +{ + ifft32 (buf); + ifft16 (buf + 32); + ifft16 (buf + 48); + ifft_pass (buf, roots64, 16); + + ifft32 (buf + 64); + ifft32 (buf + 96); + ifft_pass (buf, roots128, 32); +} +*/ +void a52_imdct_512 (sample_t * data, sample_t * delay) +{ + int i, k; + sample_t t_r, t_i, a_r, a_i, b_r, b_i, w_1, w_2; + const sample_t * window = a52_imdct_window; + FFTComplex buf[128]; + + for (i = 0; i < 128; i++) { + k = fftorder[i]; + t_r = pre1[i].real; + t_i = pre1[i].imag; + BUTTERFLY_0 (buf[i].re, buf[i].im, t_r, t_i, data[k], data[255-k]); + } + + //ifft128 (buf); + ff_fft_calc_c(7, (FFTComplex *)&buf); + + /* Post IFFT complex multiply plus IFFT complex conjugate*/ + /* Window and convert to real valued signal */ + for (i = 0; i < 64; i++) { + /* y[n] = z[n] * (xcos1[n] + j * xsin1[n]) ; */ + t_r = post1[i].real; + t_i = post1[i].imag; + BUTTERFLY_0 (a_r, a_i, t_i, t_r, buf[i].im, buf[i].re); + BUTTERFLY_0 (b_r, b_i, t_r, t_i, buf[127-i].im, buf[127-i].re); + + w_1 = window[2*i]; + w_2 = window[255-2*i]; + BUTTERFLY_B (data[255-2*i], data[2*i], w_2, w_1, a_r, delay[2*i]); + delay[2*i] = a_i; + + w_1 = window[2*i+1]; + w_2 = window[254-2*i]; + BUTTERFLY_B (data[2*i+1], data[254-2*i], w_1, w_2, b_r, delay[2*i+1]); + delay[2*i+1] = b_i; + } +} + +void a52_imdct_256 (sample_t * data, sample_t * delay) +{ + int i, k; + sample_t t_r, t_i, a_r, a_i, b_r, b_i, c_r, c_i, d_r, d_i, w_1, w_2; + const sample_t * window = a52_imdct_window; + FFTComplex buf1[64], buf2[64]; + + /* Pre IFFT complex multiply plus IFFT cmplx conjugate */ + for (i = 0; i < 64; i++) { + k = fftorder[i]; + t_r = pre2[i].real; + t_i = pre2[i].imag; + BUTTERFLY_0 (buf1[i].re, buf1[i].im, t_r, t_i, data[k], data[254-k]); + BUTTERFLY_0 (buf2[i].re, buf2[i].im, t_r, t_i, data[k+1], data[255-k]); + } + + //ifft64 (buf1); + //ifft64 (buf2); + ff_fft_calc_c(6, (FFTComplex *)&buf1); + ff_fft_calc_c(6, (FFTComplex *)&buf2); + + /* Post IFFT complex multiply */ + /* Window and convert to real valued signal */ + for (i = 0; i < 32; i++) { + /* y1[n] = z1[n] * (xcos2[n] + j * xs in2[n]) ; */ + t_r = post2[i].real; + t_i = post2[i].imag; + BUTTERFLY_0 (a_r, a_i, t_i, t_r, buf1[i].im, buf1[i].re); + BUTTERFLY_0 (b_r, b_i, t_r, t_i, buf1[63-i].im, buf1[63-i].re); + BUTTERFLY_0 (c_r, c_i, t_i, t_r, buf2[i].im, buf2[i].re); + BUTTERFLY_0 (d_r, d_i, t_r, t_i, buf2[63-i].im, buf2[63-i].re); + + w_1 = window[2*i]; + w_2 = window[255-2*i]; + BUTTERFLY_B (data[255-2*i], data[2*i], w_2, w_1, a_r, delay[2*i]); + delay[2*i] = c_i; + + w_1 = window[128+2*i]; + w_2 = window[127-2*i]; + BUTTERFLY_B (data[128+2*i], data[127-2*i], w_1, w_2, a_i, delay[127-2*i]); + delay[127-2*i] = c_r; + + w_1 = window[2*i+1]; + w_2 = window[254-2*i]; + BUTTERFLY_B (data[254-2*i], data[2*i+1], w_2, w_1, b_i, delay[2*i+1]); + delay[2*i+1] = d_r; + + w_1 = window[129+2*i]; + w_2 = window[126-2*i]; + BUTTERFLY_B (data[129+2*i], data[126-2*i], w_1, w_2, b_r, delay[126-2*i]); + delay[126-2*i] = d_i; + } +} + +/* +static double besselI0 (double x) +{ + double bessel = 1; + int i = 100; + + do + bessel = bessel * x / (i * i) + 1; + while (--i); + return bessel; +} +*/ + +void a52_imdct_init (uint32_t mm_accel) +{ + (void)mm_accel; + //ff_fft_init(&s128, 7, 1); + //ff_fft_init(&s64, 6, 1); + +/* int i, k; + double sum; + double local_imdct_window[256];*/ + + /* compute imdct window - kaiser-bessel derived window, alpha = 5.0 */ + /* sum = 0; + for (i = 0; i < 256; i++) { + sum += besselI0 (i * (256 - i) * (5 * M_PI / 256) * (5 * M_PI / 256)); + local_imdct_window[i] = sum; + } + sum++; + */ + /* for (i = 0; i < 256; i++) + a52_imdct_window[i] = SAMPLE (sqrt (local_imdct_window[i] / sum)); + + printf("static sample_t a52_imdct_window[256]={"); + for (i=0;i<256;i++) { + if ((i % 16)==0) { printf("\n"); } + printf("%d,",a52_imdct_window[i]); + } + printf("\n}\n"); + */ + + /* for (i = 0; i < 3; i++) + roots16[i] = SAMPLE (cos ((M_PI / 8) * (i + 1))); + + printf("static sample_t roots16[3]={%d,%d,%d};\n\n",roots16[0],roots16[1],roots16[2]); + + for (i = 0; i < 7; i++) + roots32[i] = SAMPLE (cos ((M_PI / 16) * (i + 1))); + + printf("static sample_t roots32[7]={"); + for (i=0;i<7;i++) { printf("%d%s",roots32[i],(i < 6 ? "," : "")); } + printf("};\n"); + + for (i = 0; i < 15; i++) + roots64[i] = SAMPLE (cos ((M_PI / 32) * (i + 1))); + + printf("static sample_t roots64[15]={"); + for (i=0;i<15;i++) { printf("%d%s",roots64[i],(i < 14 ? "," : "")); } + printf("};\n"); + + for (i = 0; i < 31; i++) + roots128[i] = SAMPLE (cos ((M_PI / 64) * (i + 1))); + + printf("static sample_t roots128[31]={"); + for (i=0;i<31;i++) { printf("%d%s",roots128[i],(i < 30 ? "," : "")); } + printf("};\n"); + */ + /* + for (i = 0; i < 64; i++) { + k = fftorder[i] / 2 + 64; + pre1[i].real = SAMPLE (cos ((M_PI / 256) * (k - 0.25))); + pre1[i].imag = SAMPLE (sin ((M_PI / 256) * (k - 0.25))); + } + + for (i = 64; i < 128; i++) { + k = fftorder[i] / 2 + 64; + pre1[i].real = SAMPLE (-cos ((M_PI / 256) * (k - 0.25))); + pre1[i].imag = SAMPLE (-sin ((M_PI / 256) * (k - 0.25))); + } + + printf("static complex_t pre1[128]={"); + for (i=0;i<128;i++) { printf("{%d,%d}%s",pre1[i].real,pre1[i].imag,(i < 127 ? "," : "")); } + printf("};\n"); + */ + /* + for (i = 0; i < 64; i++) { + post1[i].real = SAMPLE (cos ((M_PI / 256) * (i + 0.5))); + post1[i].imag = SAMPLE (sin ((M_PI / 256) * (i + 0.5))); + } + + printf("static complex_t post1[64]={"); + for (i=0;i<64;i++) { printf("{%d,%d}%s",post1[i].real,post1[i].imag,(i < 63 ? "," : "")); } + printf("};\n"); + */ + + /* + for (i = 0; i < 64; i++) { + k = fftorder[i] / 4; + pre2[i].real = SAMPLE (cos ((M_PI / 128) * (k - 0.25))); + pre2[i].imag = SAMPLE (sin ((M_PI / 128) * (k - 0.25))); + } + + printf("static complex_t pre2[64]={"); + for (i=0;i<64;i++) { printf("{%d,%d}%s",pre2[i].real,pre2[i].imag,(i < 63 ? "," : "")); } + printf("};\n"); + + for (i = 0; i < 32; i++) { + post2[i].real = SAMPLE (cos ((M_PI / 128) * (i + 0.5))); + post2[i].imag = SAMPLE (sin ((M_PI / 128) * (i + 0.5))); + } + + printf("static complex_t post2[32]={"); + for (i=0;i<32;i++) { printf("{%d,%d}%s",post2[i].real,post2[i].imag,(i < 31 ? "," : "")); } + printf("};\n"); + + +#ifdef LIBA52_DJBFFT + if (mm_accel & MM_ACCEL_DJBFFT) { +#ifndef LIBA52_DOUBLE + ifft128 = (void (*) (complex_t *)) fftc4_un128; + ifft64 = (void (*) (complex_t *)) fftc4_un64; +#else + ifft128 = (void (*) (complex_t *)) fftc8_un128; + ifft64 = (void (*) (complex_t *)) fftc8_un64; +#endif + } else +#endif + { + ifft128 = ifft128_c; + ifft64 = ifft64_c; + } + */ +} diff --git a/lib/rbcodec/codecs/liba52/imdct_lookups.h b/lib/rbcodec/codecs/liba52/imdct_lookups.h new file mode 100644 index 0000000000..9d14fe21a7 --- /dev/null +++ b/lib/rbcodec/codecs/liba52/imdct_lookups.h @@ -0,0 +1,15 @@ +static const sample_t a52_imdct_window[256]ICONST_ATTR={ + 146020,261886,393529,545197,719447,918478,1144416,1399394,1685589,2005234,2360623,2754115,3188134,3665170,4187773,4758556, 5380193,6055411,6786995,7577779,8430645,9348521,10334375,11391212,12522071,13730020,15018150,16389576,17847424,19394833,21034947,22770912, 24605865,26542938,28585242,30735872,32997891,35374332,37868188,40482408,43219889,46083473,49075937,52199993,55458273,58853331,62387636,66063559, 69883377,73849259,77963266,82227341,86643307,91212859,95937560,100818835,105857968,111056092,116414194,121933098,127613474,133455822,139460477,145627601, 151957182,158449029,165102772,171917855,178893540,186028900,193322822,200774000,208380940,216141958,224055176,232118527,240329753,248686407,257185854,265825270, 274601649,283511802,292552357,301719768,311010314,320420105,329945084,339581031,349323572,359168178,369110174,379144743,389266934,399471665,409753732,420107815, 430528483,441010205,451547355,462134219,472765003,483433845,494134818,504861939,515609181,526370480,537139740,547910849,558677680,569434108,580174011,590891284, 601579849,612233658,622846709,633413050,643926788,654382103,664773249,675094567,685340494,695505569,705584441,715571877,725462772,735252152,744935184,754507184, 763963620,773300119,782512477,791596659,800548807,809365245,818042484,826577226,834966364,843206992,851296404,859232096,867011771,874633340,882094922,889394844, 896531647,903504079,910311101,916951881,923425798,929732436,935871584,941843233,947647575,953284997,958756080,964061593,969202490,974179906,978995149,983649698, 988145195,992483442,996666390,1000696136,1004574919,1008305104,1011889185,1015329772,1018629583,1021791439,1024818257,1027713038,1030478862,1033118881,1035636308,1038034411, 1040316504,1042485942,1044546109,1046500412,1048352275,1050105129,1051762405,1053327531,1054803917,1056194958,1057504020,1058734435,1059889501,1060972468,1061986539,1062934861, 1063820523,1064646551,1065415903,1066131467,1066796055,1067412403,1067983168,1068510924,1068998160,1069447282,1069860607,1070240366,1070588702,1070907668,1071199230,1071465266, 1071707567,1071927836,1072127692,1072308670,1072472221,1072619716,1072752449,1072871635,1072978415,1073073858,1073158963,1073234663,1073301826,1073361257,1073413702,1073459852, 1073500344,1073535763,1073566646,1073593486,1073616731,1073636791,1073654036,1073668804,1073681398,1073692090,1073701126,1073708726,1073715084,1073720373,1073724748,1073728344, 1073731279,1073733657,1073735568,1073737090,1073738291,1073739229,1073739951,1073740500,1073740912,1073741214,1073741431,1073741582,1073741685,1073741751,1073741792,1073741814 +}; + +static const sample_t roots16[3]ICONST_ATTR={992008094,759250124,410903206}; +static const sample_t roots32[7]ICONST_ATTR={1053110175,992008094,892783698,759250124,596538995,410903206,209476638}; +static const sample_t roots64[15]ICONST_ATTR={1068571463,1053110175,1027506861,992008094,946955747,892783698,830013654,759250124,681174602,596538995,506158392,410903206,311690798,209476638,105245103}; +static const sample_t roots128[31]ICONST_ATTR={1072448454,1068571463,1062120190,1053110175,1041563127,1027506861,1010975241,992008094,970651112,946955747,920979082,892783698,862437519,830013654,795590212,759250124,721080937,681174602,639627257,596538995,552013618,506158392,459083785,410903206,361732725,311690798,260897981,209476638,157550647,105245103,52686014}; + +static const complex_t pre1[128]ICONST_ATTR={{761575898,756917205},{3294193,1073736770},{413944710,990742792},{-407857834,993264059},{599275209,890949340},{-206244755,1053747885},{-593797166,894609652},{212706548,1052462554},{683717842,827919933},{-101966276,1068889322},{314841678,1026545772},{-503250790,948504162},{-678624950,832099562},{108522938,1068243547},{509061229,945398418},{-308536985,1028458279},{723518379,793374223},{-49395540,1072605046},{364832651,1009860703},{-456103709,972054993},{554836544,919281193},{-257701283,1042358649},{-636978326,864395809},{160808444,1061631832},{-718636707,797798713},{55975991,1072281769},{462059540,969238095},{-358629394,1012080264},{642270168,860471112},{-154291366,1062598550},{-549185496,922668301},{264092224,1040757801},{742770847,775379244},{-23057618,1073494224},{389505993,1000603111},{-432110916,982955574},{577229727,905387953},{-232042906,1048369016},{-615573145,879767700},{186813761,1057365652},{663193747,844449855},{-128167423,1066065014},{289554159,1033963197},{-526376678,935868098},{-698841306,815194659},{82274244,1070585098},{485706670,957606670},{-333683689,1020576650},{-737999227,779922204},{29644020,1073332537},{438134083,980285687},{-383359075,1002974238},{620959710,875974053},{-180322371,1058492015},{-571663505,908912724},{238471209,1046925492},{703830091,810891303},{-75703709,1071069770},{339939548,1018509994},{-479821763,960568883},{-657999815,848503239},{134706262,1065258526},{532109148,932620694},{-283204430,1035720404},{-752230014,-766205918},{9882456,-1073696345},{-401755603,-995747929},{420016001,-988184225},{-588296766,-898236282},{219160333,-1051137599},{604730690,-887255485},{-199775197,-1054993542},{-673506508,-836247862},{115075515,-1067557553},{-302220675,-1030332066},{514852501,-942257080},{688784992,-823709134},{-95405775,-1069494853},{-497421404,-951574195},{321134518,-1024594615},{-713727978,-802193167},{62554335,-1071918121},{-352412636,-1014261720},{467997975,-966384705},{-543513771,-926020671},{270473222,-1039117770},{647537829,-856514018},{-147768480,-1063525261},{728372812,-788919863},{-42813229,-1072887940},{-450130706,-974835294},{371022172,-1007603122},{-631662502,-868287963},{167319467,-1060625145},{560466703,-915859475},{-251300639,-1043920252},{747514502,-770807091},{-16470347,-1073615495},{-426071479,-985588453},{395638246,-998194311},{-610163404,-883528225},{193298118,-1056199480},{582774217,-901829094},{-225605866,-1049773069},{-693826210,-819467323},{88841682,-1070060119},{-327415267,-1022604883},{491573291,-954608403},{668362709,-840364678},{-121623758,-1066831367},{-520624390,-939080267},{295892987,-1032167062},{-733199822,-784435800},{36229307,-1073130440},{-377197724,-1005307605},{444140755,-977578893},{-566075760,-912403275},{244890534,-1045442552},{626322896,-872147426},{-173824191,-1059578527},{708792377,-806557418},{-69130323,-1071514117},{-473918791,-963494932},{346182609,-1016404991},{-652781111,-852524677},{141240030,-1064411930},{537821584,-929338177},{-276844037,-1037438616}}; + +static const complex_t post1[64]ICONST_ATTR={{1073721611,6588355},{1073559912,19764075},{1073236539,32936819},{1072751541,46104602},{1072104991,59265442},{1071296985,72417357},{1070327646,85558366},{1069197119,98686490},{1067905576,111799753},{1066453209,124896178},{1064840239,137973795},{1063066908,151030634},{1061133483,164064728},{1059040255,177074114},{1056787539,190056834},{1054375675,203010932},{1051805026,215934457},{1049075979,228825463},{1046188946,241682009},{1043144359,254502159},{1039942680,267283981},{1036584388,280025551},{1033069991,292724951},{1029400017,305380267},{1025575020,317989594},{1021595574,330551034},{1017462280,343062693},{1013175760,355522688},{1008736660,367929143},{1004145647,380280189},{999403414,392573967},{994510674,404808624},{989468165,416982318},{984276645,429093217},{978936897,441139495},{973449725,453119340},{967815955,465030947},{962036435,476872521},{956112036,488642280},{950043650,500338452},{943832191,511959274},{937478594,523502998},{930983817,534967883},{924348836,546352205},{917574653,557654248},{910662286,568872310},{903612776,580004702},{896427186,591049747},{889106597,602005783},{881652112,612871159},{874064853,623644238},{866345963,634323399},{858496605,644907034},{850517961,655393547},{842411231,665781361},{834177638,676068911},{825818420,686254647},{817334837,696337035},{808728167,706314558},{799999705,716185713},{791150766,725949012},{782182683,735602987},{773096806,745146182},{763894503,754577161}}; + +static const complex_t pre2[64]ICONST_ATTR={{1073721611,-6588355},{763894503,754577161},{994510674,404808624},{416982318,989468165},{1054375675,203010932},{602005783,889106597},{215934457,1051805026},{896427186,591049747},{1069197119,98686490},{686254647,825818420},{950043650,500338452},{317989594,1025575020},{111799753,1067905576},{834177638,676068911},{1029400017,305380267},{511959274,943832191},{1072751541,46104602},{725949012,791150766},{973449725,453119340},{367929143,1008736660},{1043144359,254502159},{557654248,917574653},{164064728,1061133483},{866345963,634323399},{59265442,1072104991},{799999705,716185713},{1013175760,355522688},{465030947,967815955},{1063066908,151030634},{644907034,858496605},{267283981,1039942680},{924348836,546352205},{1073559912,19764075},{745146182,773096806},{984276645,429093217},{392573967,999403414},{1049075979,228825463},{580004702,903612776},{190056834,1056787539},{881652112,612871159},{1066453209,124896178},{665781361,842411231},{937478594,523502998},{292724951,1033069991},{85558366,1070327646},{817334837,696337035},{1021595574,330551034},{488642280,956112036},{32936819,1073236539},{782182683,735602987},{1004145647,380280189},{441139495,978936897},{1059040255,177074114},{623644238,874064853},{241682009,1046188946},{910662286,568872310},{1071296985,72417357},{706314558,808728167},{962036435,476872521},{343062693,1017462280},{137973795,1064840239},{850517961,655393547},{1036584388,280025551},{534967883,930983817}}; +static const complex_t post2[32]ICONST_ATTR={{1073660973,13176463},{1073014239,39521454},{1071721163,65842639},{1069782521,92124162},{1067199482,118350193},{1063973603,144504935},{1060106825,170572632},{1055601479,196537583},{1050460278,222384146},{1044686318,248096754},{1038283079,273659918},{1031254417,299058239},{1023604566,324276418},{1015338134,349299266},{1006460100,374111709},{996975812,398698801},{986890983,423045731},{976211688,447137835},{964944359,470960600},{953095785,494499675},{940673100,517740882},{927683790,540670222},{914135677,563273882},{900036924,585538247},{885396022,607449906},{870221790,628995659},{854523369,650162530},{838310215,670937766},{821592095,691308855},{804379078,711263525},{786681534,730789756},{768510121,749875787}}; diff --git a/lib/rbcodec/codecs/liba52/liba52.make b/lib/rbcodec/codecs/liba52/liba52.make new file mode 100644 index 0000000000..04cae4f080 --- /dev/null +++ b/lib/rbcodec/codecs/liba52/liba52.make @@ -0,0 +1,18 @@ +# __________ __ ___. +# Open \______ \ ____ ____ | | _\_ |__ _______ ___ +# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / +# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < +# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ +# \/ \/ \/ \/ \/ +# $Id$ +# + +# liba52 +A52LIB := $(CODECDIR)/liba52.a +A52LIB_SRC := $(call preprocess, $(RBCODECLIB_DIR)/codecs/liba52/SOURCES) +A52LIB_OBJ := $(call c2obj, $(A52LIB_SRC)) +OTHER_SRC += $(A52LIB_SRC) + +$(A52LIB): $(A52LIB_OBJ) + $(SILENT)$(shell rm -f $@) + $(call PRINTS,AR $(@F))$(AR) rcs $@ $^ >/dev/null diff --git a/lib/rbcodec/codecs/liba52/mm_accel.h b/lib/rbcodec/codecs/liba52/mm_accel.h new file mode 100644 index 0000000000..aafc3fed82 --- /dev/null +++ b/lib/rbcodec/codecs/liba52/mm_accel.h @@ -0,0 +1,37 @@ +/* + * mm_accel.h + * Copyright (C) 2000-2003 Michel Lespinasse + * Copyright (C) 1999-2000 Aaron Holtzman + * + * This file is part of a52dec, a free ATSC A-52 stream decoder. + * See http://liba52.sourceforge.net/ for updates. + * + * a52dec is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * a52dec is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef MM_ACCEL_H +#define MM_ACCEL_H + +/* generic accelerations */ +#define MM_ACCEL_DJBFFT 0x00000001 + +/* x86 accelerations */ +#define MM_ACCEL_X86_MMX 0x80000000 +#define MM_ACCEL_X86_3DNOW 0x40000000 +#define MM_ACCEL_X86_MMXEXT 0x20000000 + +uint32_t mm_accel (void); + +#endif /* MM_ACCEL_H */ diff --git a/lib/rbcodec/codecs/liba52/parse.c b/lib/rbcodec/codecs/liba52/parse.c new file mode 100644 index 0000000000..c61c13cdb5 --- /dev/null +++ b/lib/rbcodec/codecs/liba52/parse.c @@ -0,0 +1,956 @@ +/* + * parse.c + * Copyright (C) 2000-2003 Michel Lespinasse + * Copyright (C) 1999-2000 Aaron Holtzman + * + * This file is part of a52dec, a free ATSC A-52 stream decoder. + * See http://liba52.sourceforge.net/ for updates. + * + * a52dec is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * a52dec is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "config-a52.h" + +#include +#include + +#include "a52.h" +#include "a52_internal.h" +#include "bitstream.h" +#include "tables.h" + +#if defined(HAVE_MEMALIGN) && !defined(__cplusplus) +/* some systems have memalign() but no declaration for it */ +void * memalign (size_t align, size_t size); +#else +/* assume malloc alignment is sufficient */ +#define memalign(align,size) malloc (size) +#endif + +typedef struct { + quantizer_t q1[2]; + quantizer_t q2[2]; + quantizer_t q4; + int q1_ptr; + int q2_ptr; + int q4_ptr; +} quantizer_set_t; + +static a52_state_t istate IBSS_ATTR; +static sample_t isamples[256*12] IBSS_ATTR; + +static uint8_t halfrate[12] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3}; + +a52_state_t * a52_init (uint32_t mm_accel) +{ + a52_state_t * state; + int i; + + #if defined(CPU_COLDFIRE) + coldfire_set_macsr(EMAC_FRACTIONAL | EMAC_ROUND | EMAC_SATURATE); + #endif + /* + this needs to come back if we ever want two decoder instances + simultenously. NOTE, you also need to remove comments in a52_free. + state = (a52_state_t *) malloc (sizeof (a52_state_t)); + if (state == NULL) + return NULL; + + state->samples = (sample_t *) memalign (16, 256 * 12 * sizeof (sample_t)); + if (state->samples == NULL) { + free (state); + return NULL; + } + + */ + state = &istate; + state->samples = isamples; + for (i = 0; i < 256 * 12; i++) + state->samples[i] = 0; + + state->downmixed = 1; + + state->lfsr_state = 1; + + a52_imdct_init (mm_accel); + + return state; +} + +sample_t * a52_samples (a52_state_t * state) +{ + return state->samples; +} + +int a52_syncinfo (uint8_t * buf, int * flags, + int * sample_rate, int * bit_rate) +{ + static int rate[] = { 32, 40, 48, 56, 64, 80, 96, 112, + 128, 160, 192, 224, 256, 320, 384, 448, + 512, 576, 640}; + static uint8_t lfeon[8] = {0x10, 0x10, 0x04, 0x04, 0x04, 0x01, 0x04, 0x01}; + int frmsizecod; + int bitrate; + int half; + int acmod; + + if ((buf[0] != 0x0b) || (buf[1] != 0x77)) /* syncword */ + return 0; + + if (buf[5] >= 0x60) /* bsid >= 12 */ + return 0; + half = halfrate[buf[5] >> 3]; + + /* acmod, dsurmod and lfeon */ + acmod = buf[6] >> 5; + *flags = ((((buf[6] & 0xf8) == 0x50) ? A52_DOLBY : acmod) | + ((buf[6] & lfeon[acmod]) ? A52_LFE : 0)); + + frmsizecod = buf[4] & 63; + if (frmsizecod >= 38) + return 0; + bitrate = rate [frmsizecod >> 1]; + *bit_rate = (bitrate * 1000) >> half; + + switch (buf[4] & 0xc0) { + case 0: + *sample_rate = 48000 >> half; + return 4 * bitrate; + case 0x40: + *sample_rate = 44100 >> half; + return 2 * (320 * bitrate / 147 + (frmsizecod & 1)); + case 0x80: + *sample_rate = 32000 >> half; + return 6 * bitrate; + default: + return 0; + } +} + +int a52_frame (a52_state_t * state, uint8_t * buf, int * flags, + level_t * level, sample_t bias) +{ + static level_t clev[4] = { LEVEL (LEVEL_3DB), LEVEL (LEVEL_45DB), + LEVEL (LEVEL_6DB), LEVEL (LEVEL_45DB) }; + static level_t slev[4] = { LEVEL (LEVEL_3DB), LEVEL (LEVEL_6DB), + 0, LEVEL (LEVEL_6DB) }; + int chaninfo; + int acmod; + + state->fscod = buf[4] >> 6; + state->halfrate = halfrate[buf[5] >> 3]; + state->acmod = acmod = buf[6] >> 5; + + a52_bitstream_set_ptr (state, buf + 6); + bitstream_get (state, 3); /* skip acmod we already parsed */ + + if ((acmod == 2) && (bitstream_get (state, 2) == 2)) /* dsurmod */ + acmod = A52_DOLBY; + + state->clev = state->slev = 0; + + if ((acmod & 1) && (acmod != 1)) + state->clev = clev[bitstream_get (state, 2)]; /* cmixlev */ + + if (acmod & 4) + state->slev = slev[bitstream_get (state, 2)]; /* surmixlev */ + + state->lfeon = bitstream_get (state, 1); + + state->output = a52_downmix_init (acmod, *flags, level, + state->clev, state->slev); + if (state->output < 0) + return 1; + if (state->lfeon && (*flags & A52_LFE)) + state->output |= A52_LFE; + *flags = state->output; + /* the 2* compensates for differences in imdct */ + state->dynrng = state->level = MUL_C (*level, 2); + state->bias = bias; + state->dynrnge = 1; + state->dynrngcall = NULL; + state->cplba.deltbae = DELTA_BIT_NONE; + state->ba[0].deltbae = state->ba[1].deltbae = state->ba[2].deltbae = + state->ba[3].deltbae = state->ba[4].deltbae = DELTA_BIT_NONE; + + chaninfo = !acmod; + do { + bitstream_get (state, 5); /* dialnorm */ + if (bitstream_get (state, 1)) /* compre */ + bitstream_get (state, 8); /* compr */ + if (bitstream_get (state, 1)) /* langcode */ + bitstream_get (state, 8); /* langcod */ + if (bitstream_get (state, 1)) /* audprodie */ + bitstream_get (state, 7); /* mixlevel + roomtyp */ + } while (chaninfo--); + + bitstream_get (state, 2); /* copyrightb + origbs */ + + if (bitstream_get (state, 1)) /* timecod1e */ + bitstream_get (state, 14); /* timecod1 */ + if (bitstream_get (state, 1)) /* timecod2e */ + bitstream_get (state, 14); /* timecod2 */ + + if (bitstream_get (state, 1)) { /* addbsie */ + int addbsil; + + addbsil = bitstream_get (state, 6); + do { + bitstream_get (state, 8); /* addbsi */ + } while (addbsil--); + } + + return 0; +} + +void a52_dynrng (a52_state_t * state, + level_t (* call) (level_t, void *), void * data) +{ + state->dynrnge = 0; + if (call) { + state->dynrnge = 1; + state->dynrngcall = call; + state->dynrngdata = data; + } +} + +static int parse_exponents (a52_state_t * state, int expstr, int ngrps, + uint8_t exponent, uint8_t * dest) +{ + int exps; + + while (ngrps--) { + exps = bitstream_get (state, 7); + + exponent += exp_1[exps]; + if (exponent > 24) + return 1; + + switch (expstr) { + case EXP_D45: + *(dest++) = exponent; + *(dest++) = exponent; + case EXP_D25: + *(dest++) = exponent; + case EXP_D15: + *(dest++) = exponent; + } + + exponent += exp_2[exps]; + if (exponent > 24) + return 1; + + switch (expstr) { + case EXP_D45: + *(dest++) = exponent; + *(dest++) = exponent; + case EXP_D25: + *(dest++) = exponent; + case EXP_D15: + *(dest++) = exponent; + } + + exponent += exp_3[exps]; + if (exponent > 24) + return 1; + + switch (expstr) { + case EXP_D45: + *(dest++) = exponent; + *(dest++) = exponent; + case EXP_D25: + *(dest++) = exponent; + case EXP_D15: + *(dest++) = exponent; + } + } + + return 0; +} + +static int parse_deltba (a52_state_t * state, int8_t * deltba) +{ + int deltnseg, deltlen, delta, j; + + memset (deltba, 0, 50); + + deltnseg = bitstream_get (state, 3); + j = 0; + do { + j += bitstream_get (state, 5); + deltlen = bitstream_get (state, 4); + delta = bitstream_get (state, 3); + delta -= (delta >= 4) ? 3 : 4; + if (!deltlen) + continue; + if (j + deltlen >= 50) + return 1; + while (deltlen--) + deltba[j++] = delta; + } while (deltnseg--); + + return 0; +} + +static inline int zero_snr_offsets (int nfchans, a52_state_t * state) +{ + int i; + + if ((state->csnroffst) || + (state->chincpl && state->cplba.bai >> 3) || /* cplinu, fsnroffst */ + (state->lfeon && state->lfeba.bai >> 3)) /* fsnroffst */ + return 0; + for (i = 0; i < nfchans; i++) + if (state->ba[i].bai >> 3) /* fsnroffst */ + return 0; + return 1; +} + +static inline int16_t dither_gen (a52_state_t * state) +{ + int16_t nstate; + + nstate = dither_lut[state->lfsr_state >> 8] ^ (state->lfsr_state << 8); + + state->lfsr_state = (uint16_t) nstate; + + return (3 * nstate) >> 2; +} + +#ifndef LIBA52_FIXED +#define COEFF(c,t,l,s,e) (c) = (t) * (s)[e] +#else +#define COEFF(c,_t,_l,s,e) do { \ + quantizer_t t = (_t); \ + level_t l = (_l); \ + int shift = e - 5; \ + sample_t tmp = t * (l >> 16) + ((t * (l & 0xffff)) >> 16); \ + if (shift >= 0) \ + (c) = tmp >> shift; \ + else \ + (c) = tmp << -shift; \ +} while (0) +#endif + +static void coeff_get (a52_state_t * state, sample_t * coeff, + expbap_t * expbap, quantizer_set_t * quant, + level_t level, int dither, int end) +{ + int i; + uint8_t * exp; + int8_t * bap; + +#ifndef LIBA52_FIXED + sample_t factor[25]; + + for (i = 0; i <= 24; i++) + factor[i] = scale_factor[i] * level; +#endif + + exp = expbap->exp; + bap = expbap->bap; + + for (i = 0; i < end; i++) { + int bapi; + + bapi = bap[i]; + switch (bapi) { + case 0: + if (dither) { + COEFF (coeff[i], dither_gen (state), level, factor, exp[i]); + continue; + } else { + coeff[i] = 0; + continue; + } + + case -1: + if (quant->q1_ptr >= 0) { + COEFF (coeff[i], quant->q1[quant->q1_ptr--], level, + factor, exp[i]); + continue; + } else { + int code; + + code = bitstream_get (state, 5); + + quant->q1_ptr = 1; + quant->q1[0] = q_1_2[code]; + quant->q1[1] = q_1_1[code]; + COEFF (coeff[i], q_1_0[code], level, factor, exp[i]); + continue; + } + + case -2: + if (quant->q2_ptr >= 0) { + COEFF (coeff[i], quant->q2[quant->q2_ptr--], level, + factor, exp[i]); + continue; + } else { + int code; + + code = bitstream_get (state, 7); + + quant->q2_ptr = 1; + quant->q2[0] = q_2_2[code]; + quant->q2[1] = q_2_1[code]; + COEFF (coeff[i], q_2_0[code], level, factor, exp[i]); + continue; + } + + case 3: + COEFF (coeff[i], q_3[bitstream_get (state, 3)], level, + factor, exp[i]); + continue; + + case -3: + if (quant->q4_ptr == 0) { + quant->q4_ptr = -1; + COEFF (coeff[i], quant->q4, level, factor, exp[i]); + continue; + } else { + int code; + + code = bitstream_get (state, 7); + + quant->q4_ptr = 0; + quant->q4 = q_4_1[code]; + COEFF (coeff[i], q_4_0[code], level, factor, exp[i]); + continue; + } + + case 4: + COEFF (coeff[i], q_5[bitstream_get (state, 4)], level, + factor, exp[i]); + continue; + + default: + COEFF (coeff[i], bitstream_get_2 (state, bapi) << (16 - bapi), + level, factor, exp[i]); + } + } +} + +static void coeff_get_coupling (a52_state_t * state, int nfchans, + level_t * coeff, sample_t (* samples)[256], + quantizer_set_t * quant, uint8_t dithflag[5]) +{ + int cplbndstrc, bnd, i, i_end, ch; + uint8_t * exp; + int8_t * bap; + level_t cplco[5]; + + exp = state->cpl_expbap.exp; + bap = state->cpl_expbap.bap; + bnd = 0; + cplbndstrc = state->cplbndstrc; + i = state->cplstrtmant; + while (i < state->cplendmant) { + i_end = i + 12; + while (cplbndstrc & 1) { + cplbndstrc >>= 1; + i_end += 12; + } + cplbndstrc >>= 1; + for (ch = 0; ch < nfchans; ch++) + cplco[ch] = MUL_L (state->cplco[ch][bnd], coeff[ch]); + bnd++; + + while (i < i_end) { + quantizer_t cplcoeff; + int bapi; + + bapi = bap[i]; + switch (bapi) { + case 0: + for (ch = 0; ch < nfchans; ch++) + if ((state->chincpl >> ch) & 1) { + if (dithflag[ch]) +#ifndef LIBA52_FIXED + samples[ch][i] = (scale_factor[exp[i]] * + cplco[ch] * dither_gen (state)); +#else + COEFF (samples[ch][i], dither_gen (state), + cplco[ch], scale_factor, exp[i]); +#endif + else + samples[ch][i] = 0; + } + i++; + continue; + + case -1: + if (quant->q1_ptr >= 0) { + cplcoeff = quant->q1[quant->q1_ptr--]; + break; + } else { + int code; + + code = bitstream_get (state, 5); + + quant->q1_ptr = 1; + quant->q1[0] = q_1_2[code]; + quant->q1[1] = q_1_1[code]; + cplcoeff = q_1_0[code]; + break; + } + + case -2: + if (quant->q2_ptr >= 0) { + cplcoeff = quant->q2[quant->q2_ptr--]; + break; + } else { + int code; + + code = bitstream_get (state, 7); + + quant->q2_ptr = 1; + quant->q2[0] = q_2_2[code]; + quant->q2[1] = q_2_1[code]; + cplcoeff = q_2_0[code]; + break; + } + + case 3: + cplcoeff = q_3[bitstream_get (state, 3)]; + break; + + case -3: + if (quant->q4_ptr == 0) { + quant->q4_ptr = -1; + cplcoeff = quant->q4; + break; + } else { + int code; + + code = bitstream_get (state, 7); + + quant->q4_ptr = 0; + quant->q4 = q_4_1[code]; + cplcoeff = q_4_0[code]; + break; + } + + case 4: + cplcoeff = q_5[bitstream_get (state, 4)]; + break; + + default: + cplcoeff = bitstream_get_2 (state, bapi) << (16 - bapi); + } +#ifndef LIBA52_FIXED + cplcoeff *= scale_factor[exp[i]]; +#endif + for (ch = 0; ch < nfchans; ch++) + if ((state->chincpl >> ch) & 1) +#ifndef LIBA52_FIXED + samples[ch][i] = cplcoeff * cplco[ch]; +#else + COEFF (samples[ch][i], cplcoeff, cplco[ch], + scale_factor, exp[i]); +#endif + i++; + } + } +} + +int a52_block (a52_state_t * state) +{ + static const uint8_t nfchans_tbl[] = {2, 1, 2, 3, 3, 4, 4, 5, 1, 1, 2}; + static int rematrix_band[4] = {25, 37, 61, 253}; + int i, nfchans, chaninfo; + uint8_t cplexpstr, chexpstr[5], lfeexpstr, do_bit_alloc, done_cpl; + uint8_t blksw[5], dithflag[5]; + level_t coeff[5]; + int chanbias; + quantizer_set_t quant; + sample_t * samples; + + nfchans = nfchans_tbl[state->acmod]; + + for (i = 0; i < nfchans; i++) + blksw[i] = bitstream_get (state, 1); + + for (i = 0; i < nfchans; i++) + dithflag[i] = bitstream_get (state, 1); + + chaninfo = !state->acmod; + do { + if (bitstream_get (state, 1)) { /* dynrnge */ + int dynrng; + + dynrng = bitstream_get_2 (state, 8); + if (state->dynrnge) { + level_t range; + +#if !defined(LIBA52_FIXED) + range = ((((dynrng & 0x1f) | 0x20) << 13) * + scale_factor[3 - (dynrng >> 5)]); +#else + range = ((dynrng & 0x1f) | 0x20) << (21 + (dynrng >> 5)); +#endif + if (state->dynrngcall) + range = state->dynrngcall (range, state->dynrngdata); + state->dynrng = MUL_L (state->level, range); + } + } + } while (chaninfo--); + + if (bitstream_get (state, 1)) { /* cplstre */ + state->chincpl = 0; + if (bitstream_get (state, 1)) { /* cplinu */ + static uint8_t bndtab[16] = {31, 35, 37, 39, 41, 42, 43, 44, + 45, 45, 46, 46, 47, 47, 48, 48}; + int cplbegf; + int cplendf; + int ncplsubnd; + + for (i = 0; i < nfchans; i++) + state->chincpl |= bitstream_get (state, 1) << i; + switch (state->acmod) { + case 0: case 1: + return 1; + case 2: + state->phsflginu = bitstream_get (state, 1); + } + cplbegf = bitstream_get (state, 4); + cplendf = bitstream_get (state, 4); + + if (cplendf + 3 - cplbegf < 0) + return 1; + state->ncplbnd = ncplsubnd = cplendf + 3 - cplbegf; + state->cplstrtbnd = bndtab[cplbegf]; + state->cplstrtmant = cplbegf * 12 + 37; + state->cplendmant = cplendf * 12 + 73; + + state->cplbndstrc = 0; + for (i = 0; i < ncplsubnd - 1; i++) + if (bitstream_get (state, 1)) { + state->cplbndstrc |= 1 << i; + state->ncplbnd--; + } + } + } + + if (state->chincpl) { /* cplinu */ + int j, cplcoe; + + cplcoe = 0; + for (i = 0; i < nfchans; i++) + if ((state->chincpl) >> i & 1) + if (bitstream_get (state, 1)) { /* cplcoe */ + int mstrcplco, cplcoexp, cplcomant; + + cplcoe = 1; + mstrcplco = 3 * bitstream_get (state, 2); + for (j = 0; j < state->ncplbnd; j++) { + cplcoexp = bitstream_get (state, 4); + cplcomant = bitstream_get (state, 4); + if (cplcoexp == 15) + cplcomant <<= 14; + else + cplcomant = (cplcomant | 0x10) << 13; +#ifndef LIBA52_FIXED + state->cplco[i][j] = + cplcomant * scale_factor[cplcoexp + mstrcplco]; +#else + state->cplco[i][j] = (cplcomant << 11) >> (cplcoexp + mstrcplco); +#endif + + } + } + if ((state->acmod == 2) && state->phsflginu && cplcoe) + for (j = 0; j < state->ncplbnd; j++) + if (bitstream_get (state, 1)) /* phsflg */ + state->cplco[1][j] = -state->cplco[1][j]; + } + + if ((state->acmod == 2) && (bitstream_get (state, 1))) { /* rematstr */ + int end; + + state->rematflg = 0; + end = (state->chincpl) ? state->cplstrtmant : 253; /* cplinu */ + i = 0; + do + state->rematflg |= bitstream_get (state, 1) << i; + while (rematrix_band[i++] < end); + } + + cplexpstr = EXP_REUSE; + lfeexpstr = EXP_REUSE; + if (state->chincpl) /* cplinu */ + cplexpstr = bitstream_get (state, 2); + for (i = 0; i < nfchans; i++) + chexpstr[i] = bitstream_get (state, 2); + if (state->lfeon) + lfeexpstr = bitstream_get (state, 1); + + for (i = 0; i < nfchans; i++) + if (chexpstr[i] != EXP_REUSE) { + if ((state->chincpl >> i) & 1) + state->endmant[i] = state->cplstrtmant; + else { + int chbwcod; + + chbwcod = bitstream_get (state, 6); + if (chbwcod > 60) + return 1; + state->endmant[i] = chbwcod * 3 + 73; + } + } + + do_bit_alloc = 0; + + if (cplexpstr != EXP_REUSE) { + int cplabsexp, ncplgrps; + + do_bit_alloc = 64; + ncplgrps = ((state->cplendmant - state->cplstrtmant) / + (3 << (cplexpstr - 1))); + cplabsexp = bitstream_get (state, 4) << 1; + if (parse_exponents (state, cplexpstr, ncplgrps, cplabsexp, + state->cpl_expbap.exp + state->cplstrtmant)) + return 1; + } + for (i = 0; i < nfchans; i++) + if (chexpstr[i] != EXP_REUSE) { + int grp_size, nchgrps; + + do_bit_alloc |= 1 << i; + grp_size = 3 << (chexpstr[i] - 1); + nchgrps = (state->endmant[i] + grp_size - 4) / grp_size; + state->fbw_expbap[i].exp[0] = bitstream_get (state, 4); + if (parse_exponents (state, chexpstr[i], nchgrps, + state->fbw_expbap[i].exp[0], + state->fbw_expbap[i].exp + 1)) + return 1; + bitstream_get (state, 2); /* gainrng */ + } + if (lfeexpstr != EXP_REUSE) { + do_bit_alloc |= 32; + state->lfe_expbap.exp[0] = bitstream_get (state, 4); + if (parse_exponents (state, lfeexpstr, 2, state->lfe_expbap.exp[0], + state->lfe_expbap.exp + 1)) + return 1; + } + + if (bitstream_get (state, 1)) { /* baie */ + do_bit_alloc = 127; + state->bai = bitstream_get (state, 11); + } + if (bitstream_get (state, 1)) { /* snroffste */ + do_bit_alloc = 127; + state->csnroffst = bitstream_get (state, 6); + if (state->chincpl) /* cplinu */ + state->cplba.bai = bitstream_get (state, 7); + for (i = 0; i < nfchans; i++) + state->ba[i].bai = bitstream_get (state, 7); + if (state->lfeon) + state->lfeba.bai = bitstream_get (state, 7); + } + if ((state->chincpl) && (bitstream_get (state, 1))) { /* cplleake */ + do_bit_alloc |= 64; + state->cplfleak = 9 - bitstream_get (state, 3); + state->cplsleak = 9 - bitstream_get (state, 3); + } + + if (bitstream_get (state, 1)) { /* deltbaie */ + do_bit_alloc = 127; + if (state->chincpl) /* cplinu */ + state->cplba.deltbae = bitstream_get (state, 2); + for (i = 0; i < nfchans; i++) + state->ba[i].deltbae = bitstream_get (state, 2); + if (state->chincpl && /* cplinu */ + (state->cplba.deltbae == DELTA_BIT_NEW) && + parse_deltba (state, state->cplba.deltba)) + return 1; + for (i = 0; i < nfchans; i++) + if ((state->ba[i].deltbae == DELTA_BIT_NEW) && + parse_deltba (state, state->ba[i].deltba)) + return 1; + } + + if (do_bit_alloc) { + if (zero_snr_offsets (nfchans, state)) { + memset (state->cpl_expbap.bap, 0, sizeof (state->cpl_expbap.bap)); + for (i = 0; i < nfchans; i++) + memset (state->fbw_expbap[i].bap, 0, + sizeof (state->fbw_expbap[i].bap)); + memset (state->lfe_expbap.bap, 0, sizeof (state->lfe_expbap.bap)); + } else { + if (state->chincpl && (do_bit_alloc & 64)) /* cplinu */ + a52_bit_allocate (state, &state->cplba, state->cplstrtbnd, + state->cplstrtmant, state->cplendmant, + state->cplfleak << 8, state->cplsleak << 8, + &state->cpl_expbap); + for (i = 0; i < nfchans; i++) + if (do_bit_alloc & (1 << i)) + a52_bit_allocate (state, state->ba + i, 0, 0, + state->endmant[i], 0, 0, + state->fbw_expbap +i); + if (state->lfeon && (do_bit_alloc & 32)) { + state->lfeba.deltbae = DELTA_BIT_NONE; + a52_bit_allocate (state, &state->lfeba, 0, 0, 7, 0, 0, + &state->lfe_expbap); + } + } + } + + if (bitstream_get (state, 1)) { /* skiple */ + i = bitstream_get (state, 9); /* skipl */ + while (i--) + bitstream_get (state, 8); + } + + samples = state->samples; + if (state->output & A52_LFE) + samples += 256; /* shift for LFE channel */ + + chanbias = a52_downmix_coeff (coeff, state->acmod, state->output, + state->dynrng, state->clev, state->slev); + + quant.q1_ptr = quant.q2_ptr = quant.q4_ptr = -1; + done_cpl = 0; + + for (i = 0; i < nfchans; i++) { + int j; + + coeff_get (state, samples + 256 * i, state->fbw_expbap +i, &quant, + coeff[i], dithflag[i], state->endmant[i]); + + if ((state->chincpl >> i) & 1) { + if (!done_cpl) { + done_cpl = 1; + coeff_get_coupling (state, nfchans, coeff, + (sample_t (*)[256])samples, &quant, + dithflag); + } + j = state->cplendmant; + } else + j = state->endmant[i]; + do + (samples + 256 * i)[j] = 0; + while (++j < 256); + } + + if (state->acmod == 2) { + int j, end, band, rematflg; + + end = ((state->endmant[0] < state->endmant[1]) ? + state->endmant[0] : state->endmant[1]); + + i = 0; + j = 13; + rematflg = state->rematflg; + do { + if (! (rematflg & 1)) { + rematflg >>= 1; + j = rematrix_band[i++]; + continue; + } + rematflg >>= 1; + band = rematrix_band[i++]; + if (band > end) + band = end; + do { + sample_t tmp0, tmp1; + + tmp0 = samples[j]; + tmp1 = (samples+256)[j]; + samples[j] = tmp0 + tmp1; + (samples+256)[j] = tmp0 - tmp1; + } while (++j < band); + } while (j < end); + } + + if (state->lfeon) { + if (state->output & A52_LFE) { + coeff_get (state, samples - 256, &state->lfe_expbap, &quant, + state->dynrng, 0, 7); + for (i = 7; i < 256; i++) + (samples-256)[i] = 0; + a52_imdct_512 (samples - 256, samples + 1536 - 256); + } else { + /* just skip the LFE coefficients */ + coeff_get (state, samples + 1280, &state->lfe_expbap, &quant, + 0, 0, 7); + } + } + + i = 0; + if (nfchans_tbl[state->output & A52_CHANNEL_MASK] < nfchans) + for (i = 1; i < nfchans; i++) + if (blksw[i] != blksw[0]) + break; + + if (i < nfchans) { + if (state->downmixed) { + state->downmixed = 0; + a52_upmix (samples + 1536, state->acmod, state->output); + } + + for (i = 0; i < nfchans; i++) { + sample_t bias; + + bias = 0; + if (!(chanbias & (1 << i))) + bias = state->bias; + + if (coeff[i]) { + if (blksw[i]) + a52_imdct_256 (samples + 256 * i, samples + 1536 + 256 * i); + else + a52_imdct_512 (samples + 256 * i, samples + 1536 + 256 * i); + } else { + int j; + + for (j = 0; j < 256; j++) + (samples + 256 * i)[j] = bias; + } + } + + a52_downmix (samples, state->acmod, state->output, + state->clev, state->slev); + } else { + nfchans = nfchans_tbl[state->output & A52_CHANNEL_MASK]; + + a52_downmix (samples, state->acmod, state->output, + state->clev, state->slev); + + if (!state->downmixed) { + state->downmixed = 1; + a52_downmix (samples + 1536, state->acmod, state->output, + state->clev, state->slev); + } + + if (blksw[0]) + for (i = 0; i < nfchans; i++) + a52_imdct_256 (samples + 256 * i, samples + 1536 + 256 * i); + else + for (i = 0; i < nfchans; i++) + a52_imdct_512 (samples + 256 * i, samples + 1536 + 256 * i); + } + + return 0; +} + +void a52_free (a52_state_t * state) +{ + (void)state; + /* + free (state->samples); + free (state); + */ +} diff --git a/lib/rbcodec/codecs/liba52/tables.h b/lib/rbcodec/codecs/liba52/tables.h new file mode 100644 index 0000000000..b067c63f69 --- /dev/null +++ b/lib/rbcodec/codecs/liba52/tables.h @@ -0,0 +1,246 @@ +/* + * tables.h + * Copyright (C) 2000-2003 Michel Lespinasse + * Copyright (C) 1999-2000 Aaron Holtzman + * + * This file is part of a52dec, a free ATSC A-52 stream decoder. + * See http://liba52.sourceforge.net/ for updates. + * + * a52dec is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * a52dec is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +static const int8_t exp_1[128] = { + -2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2, + -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 25,25,25 +}; +static const int8_t exp_2[128] = { + -2,-2,-2,-2,-2,-1,-1,-1,-1,-1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, + -2,-2,-2,-2,-2,-1,-1,-1,-1,-1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, + -2,-2,-2,-2,-2,-1,-1,-1,-1,-1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, + -2,-2,-2,-2,-2,-1,-1,-1,-1,-1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, + -2,-2,-2,-2,-2,-1,-1,-1,-1,-1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, + 25,25,25 +}; +static const int8_t exp_3[128] = { + -2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2, + -2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2, + -2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2, + -2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2, + -2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2, + 25,25,25 +}; + +#define Q(x) ROUND (32768.0 * x) + +#define Q0 Q (-2/3) +#define Q1 Q (0) +#define Q2 Q (2/3) + +static const quantizer_t q_1_0[32] = { + Q0, Q0, Q0, Q0, Q0, Q0, Q0, Q0, Q0, + Q1, Q1, Q1, Q1, Q1, Q1, Q1, Q1, Q1, + Q2, Q2, Q2, Q2, Q2, Q2, Q2, Q2, Q2, + 0, 0, 0, 0, 0 +}; + +static const quantizer_t q_1_1[32] = { + Q0, Q0, Q0, Q1, Q1, Q1, Q2, Q2, Q2, + Q0, Q0, Q0, Q1, Q1, Q1, Q2, Q2, Q2, + Q0, Q0, Q0, Q1, Q1, Q1, Q2, Q2, Q2, + 0, 0, 0, 0, 0 +}; + +static const quantizer_t q_1_2[32] = { + Q0, Q1, Q2, Q0, Q1, Q2, Q0, Q1, Q2, + Q0, Q1, Q2, Q0, Q1, Q2, Q0, Q1, Q2, + Q0, Q1, Q2, Q0, Q1, Q2, Q0, Q1, Q2, + 0, 0, 0, 0, 0 +}; + +#undef Q0 +#undef Q1 +#undef Q2 + +#define Q0 Q (-4/5) +#define Q1 Q (-2/5) +#define Q2 Q (0) +#define Q3 Q (2/5) +#define Q4 Q (4/5) + +static const quantizer_t q_2_0[128] = { + Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0, + Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1, + Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2, + Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3, + Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4, + 0,0,0 +}; + +static const quantizer_t q_2_1[128] = { + Q0,Q0,Q0,Q0,Q0,Q1,Q1,Q1,Q1,Q1,Q2,Q2,Q2,Q2,Q2,Q3,Q3,Q3,Q3,Q3,Q4,Q4,Q4,Q4,Q4, + Q0,Q0,Q0,Q0,Q0,Q1,Q1,Q1,Q1,Q1,Q2,Q2,Q2,Q2,Q2,Q3,Q3,Q3,Q3,Q3,Q4,Q4,Q4,Q4,Q4, + Q0,Q0,Q0,Q0,Q0,Q1,Q1,Q1,Q1,Q1,Q2,Q2,Q2,Q2,Q2,Q3,Q3,Q3,Q3,Q3,Q4,Q4,Q4,Q4,Q4, + Q0,Q0,Q0,Q0,Q0,Q1,Q1,Q1,Q1,Q1,Q2,Q2,Q2,Q2,Q2,Q3,Q3,Q3,Q3,Q3,Q4,Q4,Q4,Q4,Q4, + Q0,Q0,Q0,Q0,Q0,Q1,Q1,Q1,Q1,Q1,Q2,Q2,Q2,Q2,Q2,Q3,Q3,Q3,Q3,Q3,Q4,Q4,Q4,Q4,Q4, + 0,0,0 +}; + +static const quantizer_t q_2_2[128] = { + Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4, + Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4, + Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4, + Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4, + Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4, + 0,0,0 +}; + +#undef Q0 +#undef Q1 +#undef Q2 +#undef Q3 +#undef Q4 + +static const quantizer_t q_3[8] = { + Q (-6/7), Q (-4/7), Q (-2/7), Q (0), Q (2/7), Q (4/7), Q (6/7), 0 +}; + +#define Q0 Q (-10/11) +#define Q1 Q (-8/11) +#define Q2 Q (-6/11) +#define Q3 Q (-4/11) +#define Q4 Q (-2/11) +#define Q5 Q (0) +#define Q6 Q (2/11) +#define Q7 Q (4/11) +#define Q8 Q (6/11) +#define Q9 Q (8/11) +#define QA Q (10/11) + +static const quantizer_t q_4_0[128] = { + Q0, Q0, Q0, Q0, Q0, Q0, Q0, Q0, Q0, Q0, Q0, + Q1, Q1, Q1, Q1, Q1, Q1, Q1, Q1, Q1, Q1, Q1, + Q2, Q2, Q2, Q2, Q2, Q2, Q2, Q2, Q2, Q2, Q2, + Q3, Q3, Q3, Q3, Q3, Q3, Q3, Q3, Q3, Q3, Q3, + Q4, Q4, Q4, Q4, Q4, Q4, Q4, Q4, Q4, Q4, Q4, + Q5, Q5, Q5, Q5, Q5, Q5, Q5, Q5, Q5, Q5, Q5, + Q6, Q6, Q6, Q6, Q6, Q6, Q6, Q6, Q6, Q6, Q6, + Q7, Q7, Q7, Q7, Q7, Q7, Q7, Q7, Q7, Q7, Q7, + Q8, Q8, Q8, Q8, Q8, Q8, Q8, Q8, Q8, Q8, Q8, + Q9, Q9, Q9, Q9, Q9, Q9, Q9, Q9, Q9, Q9, Q9, + QA, QA, QA, QA, QA, QA, QA, QA, QA, QA, QA, + 0, 0, 0, 0, 0, 0, 0 +}; + +static const quantizer_t q_4_1[128] = { + Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, QA, + Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, QA, + Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, QA, + Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, QA, + Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, QA, + Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, QA, + Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, QA, + Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, QA, + Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, QA, + Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, QA, + Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, QA, + 0, 0, 0, 0, 0, 0, 0 +}; + +#undef Q0 +#undef Q1 +#undef Q2 +#undef Q3 +#undef Q4 +#undef Q5 +#undef Q6 +#undef Q7 +#undef Q8 +#undef Q9 +#undef QA + +static const quantizer_t q_5[16] = { + Q (-14/15), Q (-12/15), Q (-10/15), Q (-8/15), Q (-6/15), + Q (-4/15), Q (-2/15), Q (0), Q (2/15), Q (4/15), + Q (6/15), Q (8/15), Q (10/15), Q (12/15), Q (14/15), 0 +}; + +#ifndef LIBA52_FIXED +static const sample_t scale_factor[25] = { + 0.000030517578125, + 0.0000152587890625, + 0.00000762939453125, + 0.000003814697265625, + 0.0000019073486328125, + 0.00000095367431640625, + 0.000000476837158203125, + 0.0000002384185791015625, + 0.00000011920928955078125, + 0.000000059604644775390625, + 0.0000000298023223876953125, + 0.00000001490116119384765625, + 0.000000007450580596923828125, + 0.0000000037252902984619140625, + 0.00000000186264514923095703125, + 0.000000000931322574615478515625, + 0.0000000004656612873077392578125, + 0.00000000023283064365386962890625, + 0.000000000116415321826934814453125, + 0.0000000000582076609134674072265625, + 0.00000000002910383045673370361328125, + 0.000000000014551915228366851806640625, + 0.0000000000072759576141834259033203125, + 0.00000000000363797880709171295166015625, + 0.000000000001818989403545856475830078125 +}; +#endif + +static const uint16_t dither_lut[256] = { + 0x0000, 0xa011, 0xe033, 0x4022, 0x6077, 0xc066, 0x8044, 0x2055, + 0xc0ee, 0x60ff, 0x20dd, 0x80cc, 0xa099, 0x0088, 0x40aa, 0xe0bb, + 0x21cd, 0x81dc, 0xc1fe, 0x61ef, 0x41ba, 0xe1ab, 0xa189, 0x0198, + 0xe123, 0x4132, 0x0110, 0xa101, 0x8154, 0x2145, 0x6167, 0xc176, + 0x439a, 0xe38b, 0xa3a9, 0x03b8, 0x23ed, 0x83fc, 0xc3de, 0x63cf, + 0x8374, 0x2365, 0x6347, 0xc356, 0xe303, 0x4312, 0x0330, 0xa321, + 0x6257, 0xc246, 0x8264, 0x2275, 0x0220, 0xa231, 0xe213, 0x4202, + 0xa2b9, 0x02a8, 0x428a, 0xe29b, 0xc2ce, 0x62df, 0x22fd, 0x82ec, + 0x8734, 0x2725, 0x6707, 0xc716, 0xe743, 0x4752, 0x0770, 0xa761, + 0x47da, 0xe7cb, 0xa7e9, 0x07f8, 0x27ad, 0x87bc, 0xc79e, 0x678f, + 0xa6f9, 0x06e8, 0x46ca, 0xe6db, 0xc68e, 0x669f, 0x26bd, 0x86ac, + 0x6617, 0xc606, 0x8624, 0x2635, 0x0660, 0xa671, 0xe653, 0x4642, + 0xc4ae, 0x64bf, 0x249d, 0x848c, 0xa4d9, 0x04c8, 0x44ea, 0xe4fb, + 0x0440, 0xa451, 0xe473, 0x4462, 0x6437, 0xc426, 0x8404, 0x2415, + 0xe563, 0x4572, 0x0550, 0xa541, 0x8514, 0x2505, 0x6527, 0xc536, + 0x258d, 0x859c, 0xc5be, 0x65af, 0x45fa, 0xe5eb, 0xa5c9, 0x05d8, + 0xae79, 0x0e68, 0x4e4a, 0xee5b, 0xce0e, 0x6e1f, 0x2e3d, 0x8e2c, + 0x6e97, 0xce86, 0x8ea4, 0x2eb5, 0x0ee0, 0xaef1, 0xeed3, 0x4ec2, + 0x8fb4, 0x2fa5, 0x6f87, 0xcf96, 0xefc3, 0x4fd2, 0x0ff0, 0xafe1, + 0x4f5a, 0xef4b, 0xaf69, 0x0f78, 0x2f2d, 0x8f3c, 0xcf1e, 0x6f0f, + 0xede3, 0x4df2, 0x0dd0, 0xadc1, 0x8d94, 0x2d85, 0x6da7, 0xcdb6, + 0x2d0d, 0x8d1c, 0xcd3e, 0x6d2f, 0x4d7a, 0xed6b, 0xad49, 0x0d58, + 0xcc2e, 0x6c3f, 0x2c1d, 0x8c0c, 0xac59, 0x0c48, 0x4c6a, 0xec7b, + 0x0cc0, 0xacd1, 0xecf3, 0x4ce2, 0x6cb7, 0xcca6, 0x8c84, 0x2c95, + 0x294d, 0x895c, 0xc97e, 0x696f, 0x493a, 0xe92b, 0xa909, 0x0918, + 0xe9a3, 0x49b2, 0x0990, 0xa981, 0x89d4, 0x29c5, 0x69e7, 0xc9f6, + 0x0880, 0xa891, 0xe8b3, 0x48a2, 0x68f7, 0xc8e6, 0x88c4, 0x28d5, + 0xc86e, 0x687f, 0x285d, 0x884c, 0xa819, 0x0808, 0x482a, 0xe83b, + 0x6ad7, 0xcac6, 0x8ae4, 0x2af5, 0x0aa0, 0xaab1, 0xea93, 0x4a82, + 0xaa39, 0x0a28, 0x4a0a, 0xea1b, 0xca4e, 0x6a5f, 0x2a7d, 0x8a6c, + 0x4b1a, 0xeb0b, 0xab29, 0x0b38, 0x2b6d, 0x8b7c, 0xcb5e, 0x6b4f, + 0x8bf4, 0x2be5, 0x6bc7, 0xcbd6, 0xeb83, 0x4b92, 0x0bb0, 0xaba1 +}; diff --git a/lib/rbcodec/codecs/liba52/tendra.h b/lib/rbcodec/codecs/liba52/tendra.h new file mode 100644 index 0000000000..cc740fceeb --- /dev/null +++ b/lib/rbcodec/codecs/liba52/tendra.h @@ -0,0 +1,35 @@ +/* + * tendra.h + * Copyright (C) 2000-2003 Michel Lespinasse + * Copyright (C) 1999-2000 Aaron Holtzman + * + * This file is part of a52dec, a free ATSC A-52 stream decoder. + * See http://liba52.sourceforge.net/ for updates. + * + * a52dec is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * a52dec is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#pragma TenDRA begin +#pragma TenDRA longlong type warning + +#ifdef TenDRA_check + +#pragma TenDRA conversion analysis (pointer-int explicit) off +#pragma TenDRA implicit function declaration off + +/* avoid the "No declarations in translation unit" problem */ +int TenDRA; + +#endif /* TenDRA_check */ diff --git a/lib/rbcodec/codecs/libalac/README b/lib/rbcodec/codecs/libalac/README new file mode 100644 index 0000000000..1b304d2d93 --- /dev/null +++ b/lib/rbcodec/codecs/libalac/README @@ -0,0 +1,43 @@ +INSTALLATION: +------------- + +Simply compile by running 'make' + +USAGE: +------ + +Then run the program, it will give you usage instructions. + +It's really quite trivial to use. + +For example, to decode input.m4a to output.wav: +./alac -f output.wav input.m4a + +Or, as another example, say if you wanted to stream play +http://www.mplayerhq.hu/MPlayer/samples/A-codecs/lossless/luckynight.m4a +and you're system uses the ALSA sound system: +wget -O - http://www.mplayerhq.hu/MPlayer/samples/A-codecs/lossless/luckynight.m4a | ./alac - | aplay + +By default the output file is in WAV format. To output as raw PCM, provide the +-r option on the command line. + +MORE INFORMATION: +----------------- + +Please visit http://crazney.net/programs/itunes/alac.html for more information. + +HELP NEEDED: +------------ +I need help to allow myself to continue hacking on various Apple Audio things, please visit +http://crazney.net/programs/itunes/help.html + +AUTHOR: +------- + +David Hammerton + +CONTRIBUTORS: +------------- + +Cody Brocious + diff --git a/lib/rbcodec/codecs/libalac/README.rockbox b/lib/rbcodec/codecs/libalac/README.rockbox new file mode 100644 index 0000000000..891e581cfc --- /dev/null +++ b/lib/rbcodec/codecs/libalac/README.rockbox @@ -0,0 +1,80 @@ +Library: Reverse-engineered ALAC decoder v0.1.0 +Imported: 2005-08-14 by Dave Chapman + + +This directory contains a local version of an ALAC (Apple Lossless Audio +Codec) for use by Rockbox for software decoding of ALAC files. It is +based on the reverse-engineered decoder by David Hamilton. + +LICENSING INFORMATION + +/* + * ALAC (Apple Lossless Audio Codec) decoder + * Copyright (c) 2005 David Hammerton + * All rights reserved. + * + * This is the actual decoder. + * + * http://crazney.net/programs/itunes/alac.html + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + */ + +IMPORT DETAILS + +The base version first imported into Rockbox was the first release +(v0.1.0) of the ALAC decoder by David Hammerton. + +Only the files alac.[ch], demux.[ch] and stream.h were used. + +stream.c (the original FILE* based I/O implementation) was replaced with +functions in the ALAC codec - to interface with the Rockbox audio playback +system. + +References to were replaced with and debugging +calls to fprintf were removed. + +The ALAC decoder itself was modified to return samples in host-endian +order, instead of little-endian. + +The run-time detection of CPU endianness was replaced with +compile-time tests of the ROCKBOX_LITTLE_ENDIAN define. + +All malloc calls were removed from alac.c, but some are still present +in the metadata parser in demux.c - to store unbounded data such as +the size in bytes of each compressed block in the file. + +The only changes to demux.c were to remove debugging calls to fprintf. + +The most-used buffers (the temporary 32-bit output buffer) were moved +into IRAM (on the iRiver). This was enough to make the decoder work +in real-time. + +A point of interest - the -O3 gcc option (the setting used in the +original Makefile provided with the alac decoder) gives a significant +speedup compared to -O2. With -O2, the Coldfire runs at a constant +120MHz, but with -O3, it can power-down to 40MHz for a small amount of +time. + +The file alac.c contained some hints from the original author for +places where major optimisations can be made - specifically the +unrolling and optimisation of certain cases of general loops. diff --git a/lib/rbcodec/codecs/libalac/SOURCES b/lib/rbcodec/codecs/libalac/SOURCES new file mode 100644 index 0000000000..854b9e6f88 --- /dev/null +++ b/lib/rbcodec/codecs/libalac/SOURCES @@ -0,0 +1 @@ +alac.c diff --git a/lib/rbcodec/codecs/libalac/alac.c b/lib/rbcodec/codecs/libalac/alac.c new file mode 100644 index 0000000000..fd24656504 --- /dev/null +++ b/lib/rbcodec/codecs/libalac/alac.c @@ -0,0 +1,1148 @@ +/* + * ALAC (Apple Lossless Audio Codec) decoder + * Copyright (c) 2005 David Hammerton + * All rights reserved. + * + * This is the actual decoder. + * + * http://crazney.net/programs/itunes/alac.html + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + */ + + +#include +#include +#include +#include + +#include "codeclib.h" +#include "decomp.h" + +#define SIGNEXTEND24(val) (((signed)val<<8)>>8) + +static int16_t predictor_coef_table[32] IBSS_ATTR; +static int16_t predictor_coef_table_a[32] IBSS_ATTR; +static int16_t predictor_coef_table_b[32] IBSS_ATTR; + + +/* Endian/aligment safe functions - only used in alac_set_info() */ +static uint32_t get_uint32be(unsigned char* p) +{ + return((p[0]<<24) | (p[1]<<16) | (p[2]<<8) | p[3]); +} + +static uint16_t get_uint16be(unsigned char* p) +{ + return((p[0]<<8) | p[1]); +} + +void alac_set_info(alac_file *alac, char *inputbuffer) +{ + unsigned char* ptr = (unsigned char*)inputbuffer; + ptr += 4; /* size */ + ptr += 4; /* frma */ + ptr += 4; /* alac */ + ptr += 4; /* size */ + ptr += 4; /* alac */ + + ptr += 4; /* 0 ? */ + + alac->setinfo_max_samples_per_frame = get_uint32be(ptr); /* buffer size / 2 ? */ + ptr += 4; + alac->setinfo_7a = *ptr++; + alac->setinfo_sample_size = *ptr++; + alac->setinfo_rice_historymult = *ptr++; + alac->setinfo_rice_initialhistory = *ptr++; + alac->setinfo_rice_kmodifier = *ptr++; + alac->setinfo_7f = *ptr++; + ptr += 1; + alac->setinfo_80 = get_uint16be(ptr); + ptr += 2; + alac->setinfo_82 = get_uint32be(ptr); + ptr += 4; + alac->setinfo_86 = get_uint32be(ptr); + ptr += 4; + alac->setinfo_8a_rate = get_uint32be(ptr); + ptr += 4; +} + +/* stream reading */ + +/* supports reading 1 to 16 bits, in big endian format */ +static inline uint32_t readbits_16(alac_file *alac, int bits) +{ + uint32_t result; + int new_accumulator; + + result = (alac->input_buffer[0] << 16) | + (alac->input_buffer[1] << 8) | + (alac->input_buffer[2]); + + /* shift left by the number of bits we've already read, + * so that the top 'n' bits of the 24 bits we read will + * be the return bits */ + result = result << alac->input_buffer_bitaccumulator; + + result = result & 0x00ffffff; + + /* and then only want the top 'n' bits from that, where + * n is 'bits' */ + result = result >> (24 - bits); + + new_accumulator = (alac->input_buffer_bitaccumulator + bits); + + /* increase the buffer pointer if we've read over n bytes. */ + alac->input_buffer += (new_accumulator >> 3); + + /* and the remainder goes back into the bit accumulator */ + alac->input_buffer_bitaccumulator = (new_accumulator & 7); + + return result; +} + +/* supports reading 1 to 32 bits, in big endian format */ +static inline uint32_t readbits(alac_file *alac, int bits) +{ + int32_t result = 0; + + if (bits > 16) + { + bits -= 16; + result = readbits_16(alac, 16) << bits; + } + + result |= readbits_16(alac, bits); + + return result; +} + +/* reads a single bit */ +static inline int readbit(alac_file *alac) +{ + int result; + int new_accumulator; + + result = alac->input_buffer[0]; + + result = result << alac->input_buffer_bitaccumulator; + + result = result >> 7 & 1; + + new_accumulator = (alac->input_buffer_bitaccumulator + 1); + + alac->input_buffer += (new_accumulator / 8); + + alac->input_buffer_bitaccumulator = (new_accumulator % 8); + + return result; +} + +static inline void unreadbits(alac_file *alac, int bits) +{ + int new_accumulator = (alac->input_buffer_bitaccumulator - bits); + + alac->input_buffer += (new_accumulator >> 3); + + alac->input_buffer_bitaccumulator = (new_accumulator & 7); + if (alac->input_buffer_bitaccumulator < 0) + alac->input_buffer_bitaccumulator *= -1; +} + +#define count_leading_zeros(x) bs_generic(x, BS_CLZ|BS_SHORT) + +#define RICE_THRESHOLD 8 // maximum number of bits for a rice prefix. + +static inline int32_t entropy_decode_value(alac_file* alac, + int readsamplesize, + int k) ICODE_ATTR_ALAC; +static inline int32_t entropy_decode_value(alac_file* alac, + int readsamplesize, + int k) +{ + int32_t x = 0; // decoded value + + // read x, number of 1s before 0 represent the rice value. + while (x <= RICE_THRESHOLD && readbit(alac)) + { + x++; + } + + if (x > RICE_THRESHOLD) + { + // read the number from the bit stream (raw value) + int32_t value; + + value = readbits(alac, readsamplesize); + + /* mask value to readsamplesize size */ + if (readsamplesize != 32) + value &= (((uint32_t)0xffffffff) >> (32 - readsamplesize)); + + x = value; + } + else + { + if (k != 1) + { + int extrabits = readbits(alac, k); + + // x = x * (2^k - 1) + x = (x << k) - x; + + if (extrabits > 1) + x += extrabits - 1; + else + unreadbits(alac, 1); + } + } + + return x; +} + +static void entropy_rice_decode(alac_file* alac, + int32_t* output_buffer, + int output_size, + int readsamplesize, + int rice_initialhistory, + int rice_kmodifier, + int rice_historymult, + int rice_kmodifier_mask) ICODE_ATTR_ALAC; +static void entropy_rice_decode(alac_file* alac, + int32_t* output_buffer, + int output_size, + int readsamplesize, + int rice_initialhistory, + int rice_kmodifier, + int rice_historymult, + int rice_kmodifier_mask) +{ + int output_count; + int history = rice_initialhistory; + int sign_modifier = 0; + + for (output_count = 0; output_count < output_size; output_count++) + { + int32_t decoded_value; + int32_t final_value; + int32_t k; + + k = 31 - rice_kmodifier - count_leading_zeros((history >> 9) + 3); + + if (k < 0) k += rice_kmodifier; + else k = rice_kmodifier; + + decoded_value = entropy_decode_value(alac, readsamplesize, k); + + decoded_value += sign_modifier; + final_value = (decoded_value + 1) / 2; // inc by 1 and shift out sign bit + if (decoded_value & 1) // the sign is stored in the low bit + final_value *= -1; + + output_buffer[output_count] = final_value; + + sign_modifier = 0; + + // update history + history += (decoded_value * rice_historymult) + - ((history * rice_historymult) >> 9); + + if (decoded_value > 0xFFFF) + history = 0xFFFF; + + // special case, for compressed blocks of 0 + if ((history < 128) && (output_count + 1 < output_size)) + { + int32_t block_size; + + sign_modifier = 1; + + k = count_leading_zeros(history) + ((history + 16) / 64) - 24; + + // note: block_size is always 16bit + block_size = entropy_decode_value(alac, 16, k) & rice_kmodifier_mask; + + // got block_size 0s + if (block_size > 0) + { + memset(&output_buffer[output_count + 1], 0, + block_size * sizeof(*output_buffer)); + output_count += block_size; + } + + if (block_size > 0xFFFF) + sign_modifier = 0; + + history = 0; + } + } +} + +#define SIGN_EXTENDED32(val, bits) ((val << (32 - bits)) >> (32 - bits)) + +#define SIGN_ONLY(v) \ + ((v < 0) ? (-1) : \ + ((v > 0) ? (1) : \ + (0))) + +static void predictor_decompress_fir_adapt(int32_t *error_buffer, + int32_t *buffer_out, + int output_size, + int readsamplesize, + int16_t *predictor_coef_table, + int predictor_coef_num, + int predictor_quantitization) ICODE_ATTR_ALAC; +static void predictor_decompress_fir_adapt(int32_t *error_buffer, + int32_t *buffer_out, + int output_size, + int readsamplesize, + int16_t *predictor_coef_table, + int predictor_coef_num, + int predictor_quantitization) +{ + int i; + + /* first sample always copies */ + *buffer_out = *error_buffer; + + if (!predictor_coef_num) + { + if (output_size <= 1) return; + memcpy(buffer_out+1, error_buffer+1, (output_size-1) * 4); + return; + } + + if (predictor_coef_num == 0x1f) /* 11111 - max value of predictor_coef_num */ + { /* second-best case scenario for fir decompression, + * error describes a small difference from the previous sample only + */ + if (output_size <= 1) return; + for (i = 0; i < output_size - 1; i++) + { + int32_t prev_value; + int32_t error_value; + + prev_value = buffer_out[i]; + error_value = error_buffer[i+1]; + buffer_out[i+1] = SIGN_EXTENDED32((prev_value + error_value), readsamplesize); + } + return; + } + + /* read warm-up samples */ + if (predictor_coef_num > 0) + { + int i; + for (i = 0; i < predictor_coef_num; i++) + { + int32_t val; + + val = buffer_out[i] + error_buffer[i+1]; + + val = SIGN_EXTENDED32(val, readsamplesize); + + buffer_out[i+1] = val; + } + } + + /* 4 and 8 are very common cases (the only ones i've seen). + + The following code is an initial attempt to unroll and optimise + these two cases by the Rockbox project. More work is needed. + */ + + /* optimised case: 4 */ + if (predictor_coef_num == 4) + { + for (i = 4 + 1; i < output_size; i++) + { + int sum = 0; + int outval; + int error_val = error_buffer[i]; + + sum = (buffer_out[4] - buffer_out[0]) * predictor_coef_table[0] + + (buffer_out[3] - buffer_out[0]) * predictor_coef_table[1] + + (buffer_out[2] - buffer_out[0]) * predictor_coef_table[2] + + (buffer_out[1] - buffer_out[0]) * predictor_coef_table[3]; + + outval = (1 << (predictor_quantitization-1)) + sum; + outval = outval >> predictor_quantitization; + outval = outval + buffer_out[0] + error_val; + outval = SIGN_EXTENDED32(outval, readsamplesize); + + buffer_out[4+1] = outval; + + if (error_val > 0) + { + int predictor_num = 4 - 1; + + while (predictor_num >= 0 && error_val > 0) + { + int val = buffer_out[0] - buffer_out[4 - predictor_num]; + + if (val!=0) { + if (val < 0) { + predictor_coef_table[predictor_num]++; + val=-val; + } else { + predictor_coef_table[predictor_num]--; + } + error_val -= ((val >> predictor_quantitization) * (4 - predictor_num)); + } + predictor_num--; + } + } + else if (error_val < 0) + { + int predictor_num = 4 - 1; + + while (predictor_num >= 0 && error_val < 0) + { + int val = buffer_out[0] - buffer_out[4 - predictor_num]; + + if (val != 0) { + if (val > 0) { + predictor_coef_table[predictor_num]++; + val=-val; /* neg value */ + } else { + predictor_coef_table[predictor_num]--; + } + error_val -= ((val >> predictor_quantitization) * (4 - predictor_num)); + } + predictor_num--; + } + } + + buffer_out++; + } + return; + } + + /* optimised case: 8 */ + if (predictor_coef_num == 8) + { + for (i = 8 + 1; + i < output_size; + i++) + { + int sum; + int outval; + int error_val = error_buffer[i]; + + sum = (buffer_out[8] - buffer_out[0]) * predictor_coef_table[0] + + (buffer_out[7] - buffer_out[0]) * predictor_coef_table[1] + + (buffer_out[6] - buffer_out[0]) * predictor_coef_table[2] + + (buffer_out[5] - buffer_out[0]) * predictor_coef_table[3] + + (buffer_out[4] - buffer_out[0]) * predictor_coef_table[4] + + (buffer_out[3] - buffer_out[0]) * predictor_coef_table[5] + + (buffer_out[2] - buffer_out[0]) * predictor_coef_table[6] + + (buffer_out[1] - buffer_out[0]) * predictor_coef_table[7]; + + outval = (1 << (predictor_quantitization-1)) + sum; + outval = outval >> predictor_quantitization; + outval = outval + buffer_out[0] + error_val; + outval = SIGN_EXTENDED32(outval, readsamplesize); + + buffer_out[8+1] = outval; + + if (error_val > 0) + { + int predictor_num = 8 - 1; + + while (predictor_num >= 0 && error_val > 0) + { + int val = buffer_out[0] - buffer_out[8 - predictor_num]; + + if (val!=0) { + if (val < 0) { + predictor_coef_table[predictor_num]++; + val=-val; + } else { + predictor_coef_table[predictor_num]--; + } + error_val -= ((val >> predictor_quantitization) * (8 - predictor_num)); + } + predictor_num--; + } + } + else if (error_val < 0) + { + int predictor_num = 8 - 1; + + while (predictor_num >= 0 && error_val < 0) + { + int val = buffer_out[0] - buffer_out[8 - predictor_num]; + if (val != 0) { + if (val > 0) { + predictor_coef_table[predictor_num]++; + val=-val; /* neg value */ + } else { + predictor_coef_table[predictor_num]--; + } + error_val -= ((val >> predictor_quantitization) * (8 - predictor_num)); + } + predictor_num--; + } + } + + buffer_out++; + } + return; + } + + /* general case */ + if (predictor_coef_num > 0) + { + for (i = predictor_coef_num + 1; + i < output_size; + i++) + { + int j; + int sum = 0; + int outval; + int error_val = error_buffer[i]; + + for (j = 0; j < predictor_coef_num; j++) + { + sum += (buffer_out[predictor_coef_num-j] - buffer_out[0]) * + predictor_coef_table[j]; + } + + outval = (1 << (predictor_quantitization-1)) + sum; + outval = outval >> predictor_quantitization; + outval = outval + buffer_out[0] + error_val; + outval = SIGN_EXTENDED32(outval, readsamplesize); + + buffer_out[predictor_coef_num+1] = outval; + + if (error_val > 0) + { + int predictor_num = predictor_coef_num - 1; + + while (predictor_num >= 0 && error_val > 0) + { + int val = buffer_out[0] - buffer_out[predictor_coef_num - predictor_num]; + int sign = SIGN_ONLY(val); + + predictor_coef_table[predictor_num] -= sign; + + val *= sign; /* absolute value */ + + error_val -= ((val >> predictor_quantitization) * + (predictor_coef_num - predictor_num)); + + predictor_num--; + } + } + else if (error_val < 0) + { + int predictor_num = predictor_coef_num - 1; + + while (predictor_num >= 0 && error_val < 0) + { + int val = buffer_out[0] - buffer_out[predictor_coef_num - predictor_num]; + int sign = - SIGN_ONLY(val); + + predictor_coef_table[predictor_num] -= sign; + + val *= sign; /* neg value */ + + error_val -= ((val >> predictor_quantitization) * + (predictor_coef_num - predictor_num)); + + predictor_num--; + } + } + + buffer_out++; + } + } +} + +static void deinterlace_16(int32_t* buffer0, + int32_t* buffer1, + int numsamples, + uint8_t interlacing_shift, + uint8_t interlacing_leftweight) ICODE_ATTR_ALAC; +static void deinterlace_16(int32_t* buffer0, + int32_t* buffer1, + int numsamples, + uint8_t interlacing_shift, + uint8_t interlacing_leftweight) +{ + int i; + if (numsamples <= 0) return; + + /* weighted interlacing */ + if (interlacing_leftweight) + { + for (i = 0; i < numsamples; i++) + { + int32_t difference, midright; + + midright = buffer0[i]; + difference = buffer1[i]; + + buffer0[i] = ((midright - ((difference * interlacing_leftweight) + >> interlacing_shift)) + difference) << SCALE16; + buffer1[i] = (midright - ((difference * interlacing_leftweight) + >> interlacing_shift)) << SCALE16; + } + + return; + } + + /* otherwise basic interlacing took place */ + for (i = 0; i < numsamples; i++) + { + buffer0[i] = buffer0[i] << SCALE16; + buffer1[i] = buffer1[i] << SCALE16; + } +} + +static void deinterlace_24(int32_t *buffer0, int32_t *buffer1, + int uncompressed_bytes, + int32_t *uncompressed_bytes_buffer0, + int32_t *uncompressed_bytes_buffer1, + int numsamples, + uint8_t interlacing_shift, + uint8_t interlacing_leftweight) ICODE_ATTR_ALAC; +static void deinterlace_24(int32_t *buffer0, int32_t *buffer1, + int uncompressed_bytes, + int32_t *uncompressed_bytes_buffer0, + int32_t *uncompressed_bytes_buffer1, + int numsamples, + uint8_t interlacing_shift, + uint8_t interlacing_leftweight) +{ + int i; + if (numsamples <= 0) return; + + /* weighted interlacing */ + if (interlacing_leftweight) + { + for (i = 0; i < numsamples; i++) + { + int32_t difference, midright; + + midright = buffer0[i]; + difference = buffer1[i]; + + buffer0[i] = ((midright - ((difference * interlacing_leftweight) + >> interlacing_shift)) + difference) << SCALE24; + buffer1[i] = (midright - ((difference * interlacing_leftweight) + >> interlacing_shift)) << SCALE24; + + if (uncompressed_bytes) + { + uint32_t mask = ~(0xFFFFFFFF << (uncompressed_bytes * 8)); + buffer0[i] <<= (uncompressed_bytes * 8); + buffer1[i] <<= (uncompressed_bytes * 8); + + buffer0[i] |= uncompressed_bytes_buffer0[i] & mask; + buffer1[i] |= uncompressed_bytes_buffer1[i] & mask; + } + + } + + return; + } + + /* otherwise basic interlacing took place */ + for (i = 0; i < numsamples; i++) + { + if (uncompressed_bytes) + { + uint32_t mask = ~(0xFFFFFFFF << (uncompressed_bytes * 8)); + buffer0[i] <<= (uncompressed_bytes * 8); + buffer1[i] <<= (uncompressed_bytes * 8); + + buffer0[i] |= uncompressed_bytes_buffer0[i] & mask; + buffer1[i] |= uncompressed_bytes_buffer1[i] & mask; + } + + buffer0[i] = buffer0[i] << SCALE24; + buffer1[i] = buffer1[i] << SCALE24; + } + +} + +static inline int decode_frame_mono( + alac_file *alac, + int32_t outputbuffer[ALAC_MAX_CHANNELS][ALAC_BLOCKSIZE], + void (*yield)(void)) +{ + int hassize; + int isnotcompressed; + int readsamplesize; + int infosamplesize = alac->setinfo_sample_size; + int outputsamples = alac->setinfo_max_samples_per_frame; + + int uncompressed_bytes; + int ricemodifier; + + + /* 2^result = something to do with output waiting. + * perhaps matters if we read > 1 frame in a pass? + */ + readbits(alac, 4); + + readbits(alac, 12); /* unknown, skip 12 bits */ + + hassize = readbits(alac, 1); /* the output sample size is stored soon */ + + /* number of bytes in the (compressed) stream that are not compressed */ + uncompressed_bytes = readbits(alac, 2); + + isnotcompressed = readbits(alac, 1); /* whether the frame is compressed */ + + if (hassize) + { + /* now read the number of samples, + * as a 32bit integer */ + outputsamples = readbits(alac, 32); + } + + readsamplesize = infosamplesize - (uncompressed_bytes * 8); + + if (!isnotcompressed) + { /* so it is compressed */ + int predictor_coef_num; + int prediction_type; + int prediction_quantitization; + int i; + + /* skip 16 bits, not sure what they are. seem to be used in + * two channel case */ + readbits(alac, 8); + readbits(alac, 8); + + prediction_type = readbits(alac, 4); + prediction_quantitization = readbits(alac, 4); + + ricemodifier = readbits(alac, 3); + predictor_coef_num = readbits(alac, 5); + + /* read the predictor table */ + for (i = 0; i < predictor_coef_num; i++) + { + predictor_coef_table[i] = (int16_t)readbits(alac, 16); + } + + if (uncompressed_bytes) + { + int i; + for (i = 0; i < outputsamples; i++) + { + outputbuffer[0][i] = readbits(alac, uncompressed_bytes * 8); + outputbuffer[1][i] = outputbuffer[0][i]; + } + } + + yield(); + + entropy_rice_decode(alac, + outputbuffer[0], + outputsamples, + readsamplesize, + alac->setinfo_rice_initialhistory, + alac->setinfo_rice_kmodifier, + ricemodifier * alac->setinfo_rice_historymult / 4, + (1 << alac->setinfo_rice_kmodifier) - 1); + + yield(); + + if (prediction_type == 0) + { /* adaptive fir */ + predictor_decompress_fir_adapt(outputbuffer[0], + outputbuffer[0], + outputsamples, + readsamplesize, + predictor_coef_table, + predictor_coef_num, + prediction_quantitization); + } + else + { + //fprintf(stderr, "FIXME: unhandled predicition type: %i\n", prediction_type); + /* i think the only other prediction type (or perhaps this is just a + * boolean?) runs adaptive fir twice.. like: + * predictor_decompress_fir_adapt(predictor_error, tempout, ...) + * predictor_decompress_fir_adapt(predictor_error, outputsamples ...) + * little strange.. + */ + } + + } + else + { /* not compressed, easy case */ + if (infosamplesize <= 16) + { + int i; + for (i = 0; i < outputsamples; i++) + { + int32_t audiobits = readbits(alac, infosamplesize); + + audiobits = SIGN_EXTENDED32(audiobits, infosamplesize); + + outputbuffer[0][i] = audiobits; + } + } + else + { + int i; + for (i = 0; i < outputsamples; i++) + { + int32_t audiobits; + + audiobits = readbits(alac, 16); + /* special case of sign extension.. + * as we'll be ORing the low 16bits into this */ + audiobits = audiobits << (infosamplesize - 16); + audiobits |= readbits(alac, infosamplesize - 16); + audiobits = SIGNEXTEND24(audiobits); + + outputbuffer[0][i] = audiobits; + } + } + uncompressed_bytes = 0; // always 0 for uncompressed + } + + yield(); + + switch(infosamplesize) + { + case 16: + { + int i; + for (i = 0; i < outputsamples; i++) + { + /* Output mono data as stereo */ + outputbuffer[0][i] = outputbuffer[0][i] << SCALE16; + outputbuffer[1][i] = outputbuffer[0][i]; + } + break; + } + case 24: + { + int i; + for (i = 0; i < outputsamples; i++) + { + int32_t sample = outputbuffer[0][i]; + + if (uncompressed_bytes) + { + uint32_t mask; + sample = sample << (uncompressed_bytes * 8); + mask = ~(0xFFFFFFFF << (uncompressed_bytes * 8)); + sample |= outputbuffer[0][i] & mask; + } + + outputbuffer[0][i] = sample << SCALE24; + outputbuffer[1][i] = outputbuffer[0][i]; + } + break; + } + case 20: + case 32: + //fprintf(stderr, "FIXME: unimplemented sample size %i\n", infosamplesize); + break; + default: + break; + } + + return outputsamples; +} + +static inline int decode_frame_stereo( + alac_file *alac, + int32_t outputbuffer[ALAC_MAX_CHANNELS][ALAC_BLOCKSIZE], + void (*yield)(void)) +{ + int hassize; + int isnotcompressed; + int readsamplesize; + int infosamplesize = alac->setinfo_sample_size; + int outputsamples = alac->setinfo_max_samples_per_frame; + int uncompressed_bytes; + + uint8_t interlacing_shift; + uint8_t interlacing_leftweight; + + /* 2^result = something to do with output waiting. + * perhaps matters if we read > 1 frame in a pass? + */ + readbits(alac, 4); + + readbits(alac, 12); /* unknown, skip 12 bits */ + + hassize = readbits(alac, 1); /* the output sample size is stored soon */ + + /* the number of bytes in the (compressed) stream that are not compressed */ + uncompressed_bytes = readbits(alac, 2); + + isnotcompressed = readbits(alac, 1); /* whether the frame is compressed */ + + if (hassize) + { + /* now read the number of samples, + * as a 32bit integer */ + outputsamples = readbits(alac, 32); + } + + readsamplesize = infosamplesize - (uncompressed_bytes * 8) + 1; + + yield(); + if (!isnotcompressed) + { /* compressed */ + int predictor_coef_num_a; + int prediction_type_a; + int prediction_quantitization_a; + int ricemodifier_a; + + int predictor_coef_num_b; + int prediction_type_b; + int prediction_quantitization_b; + int ricemodifier_b; + + int i; + + interlacing_shift = readbits(alac, 8); + interlacing_leftweight = readbits(alac, 8); + + /******** channel 1 ***********/ + prediction_type_a = readbits(alac, 4); + prediction_quantitization_a = readbits(alac, 4); + + ricemodifier_a = readbits(alac, 3); + predictor_coef_num_a = readbits(alac, 5); + + /* read the predictor table */ + for (i = 0; i < predictor_coef_num_a; i++) + { + predictor_coef_table_a[i] = (int16_t)readbits(alac, 16); + } + + /******** channel 2 *********/ + prediction_type_b = readbits(alac, 4); + prediction_quantitization_b = readbits(alac, 4); + + ricemodifier_b = readbits(alac, 3); + predictor_coef_num_b = readbits(alac, 5); + + /* read the predictor table */ + for (i = 0; i < predictor_coef_num_b; i++) + { + predictor_coef_table_b[i] = (int16_t)readbits(alac, 16); + } + + /*********************/ + if (uncompressed_bytes) + { /* see mono case */ + int i; + for (i = 0; i < outputsamples; i++) + { + outputbuffer[0][i] = readbits(alac, uncompressed_bytes * 8); + outputbuffer[1][i] = readbits(alac, uncompressed_bytes * 8); + } + } + + yield(); + /* channel 1 */ + entropy_rice_decode(alac, + outputbuffer[0], + outputsamples, + readsamplesize, + alac->setinfo_rice_initialhistory, + alac->setinfo_rice_kmodifier, + ricemodifier_a * alac->setinfo_rice_historymult / 4, + (1 << alac->setinfo_rice_kmodifier) - 1); + + yield(); + if (prediction_type_a == 0) + { /* adaptive fir */ + predictor_decompress_fir_adapt(outputbuffer[0], + outputbuffer[0], + outputsamples, + readsamplesize, + predictor_coef_table_a, + predictor_coef_num_a, + prediction_quantitization_a); + } + else + { /* see mono case */ + //fprintf(stderr, "FIXME: unhandled predicition type: %i\n", prediction_type_a); + } + + yield(); + + /* channel 2 */ + entropy_rice_decode(alac, + outputbuffer[1], + outputsamples, + readsamplesize, + alac->setinfo_rice_initialhistory, + alac->setinfo_rice_kmodifier, + ricemodifier_b * alac->setinfo_rice_historymult / 4, + (1 << alac->setinfo_rice_kmodifier) - 1); + + yield(); + if (prediction_type_b == 0) + { /* adaptive fir */ + predictor_decompress_fir_adapt(outputbuffer[1], + outputbuffer[1], + outputsamples, + readsamplesize, + predictor_coef_table_b, + predictor_coef_num_b, + prediction_quantitization_b); + } + else + { + //fprintf(stderr, "FIXME: unhandled predicition type: %i\n", prediction_type_b); + } + } + else + { /* not compressed, easy case */ + if (infosamplesize <= 16) + { + int i; + for (i = 0; i < outputsamples; i++) + { + int32_t audiobits_a, audiobits_b; + + audiobits_a = readbits(alac, infosamplesize); + audiobits_b = readbits(alac, infosamplesize); + + audiobits_a = SIGN_EXTENDED32(audiobits_a, infosamplesize); + audiobits_b = SIGN_EXTENDED32(audiobits_b, infosamplesize); + + outputbuffer[0][i] = audiobits_a; + outputbuffer[1][i] = audiobits_b; + } + } + else + { + int i; + for (i = 0; i < outputsamples; i++) + { + int32_t audiobits_a, audiobits_b; + + audiobits_a = readbits(alac, 16); + audiobits_a = audiobits_a << (infosamplesize - 16); + audiobits_a |= readbits(alac, infosamplesize - 16); + audiobits_a = SIGNEXTEND24(audiobits_a); + + audiobits_b = readbits(alac, 16); + audiobits_b = audiobits_b << (infosamplesize - 16); + audiobits_b |= readbits(alac, infosamplesize - 16); + audiobits_b = SIGNEXTEND24(audiobits_b); + + outputbuffer[0][i] = audiobits_a; + outputbuffer[1][i] = audiobits_b; + } + } + uncompressed_bytes = 0; // always 0 for uncompressed + interlacing_shift = 0; + interlacing_leftweight = 0; + } + + yield(); + + switch(infosamplesize) + { + case 16: + { + deinterlace_16(outputbuffer[0], + outputbuffer[1], + outputsamples, + interlacing_shift, + interlacing_leftweight); + break; + } + case 24: + { + deinterlace_24(outputbuffer[0], + outputbuffer[1], + uncompressed_bytes, + outputbuffer[0], + outputbuffer[1], + outputsamples, + interlacing_shift, + interlacing_leftweight); + break; + } + case 20: + case 32: + //fprintf(stderr, "FIXME: unimplemented sample size %i\n", infosamplesize); + break; + default: + break; + } + return outputsamples; +} + +int alac_decode_frame(alac_file *alac, + unsigned char *inbuffer, + int32_t outputbuffer[ALAC_MAX_CHANNELS][ALAC_BLOCKSIZE], + void (*yield)(void)) +{ + int channels; + int outputsamples; + unsigned char *input_buffer_start; + + /* setup the stream */ + alac->input_buffer = inbuffer; + alac->input_buffer_bitaccumulator = 0; + + /* save to gather byte consumption */ + input_buffer_start = alac->input_buffer; + + channels = readbits(alac, 3); + + /* TODO: The mono and stereo functions should be combined. */ + switch(channels) + { + case 0: /* 1 channel */ + outputsamples=decode_frame_mono(alac,outputbuffer,yield); + break; + case 1: /* 2 channels */ + outputsamples=decode_frame_stereo(alac,outputbuffer,yield); + break; + default: /* Unsupported */ + return -1; + } + + /* calculate consumed bytes */ + alac->bytes_consumed = (int)(alac->input_buffer - input_buffer_start); + alac->bytes_consumed += (alac->input_buffer_bitaccumulator>5) ? 2 : 1; + + return outputsamples; +} + +/* rockbox: not used +void create_alac(int samplesize, int numchannels, alac_file* alac) +{ + alac->samplesize = samplesize; + alac->numchannels = numchannels; + alac->bytespersample = (samplesize / 8) * numchannels; +} */ diff --git a/lib/rbcodec/codecs/libalac/decomp.h b/lib/rbcodec/codecs/libalac/decomp.h new file mode 100644 index 0000000000..21dabd86b0 --- /dev/null +++ b/lib/rbcodec/codecs/libalac/decomp.h @@ -0,0 +1,54 @@ +#ifndef __ALAC__DECOMP_H +#define __ALAC__DECOMP_H + +#ifndef ICODE_ATTR_ALAC +#define ICODE_ATTR_ALAC ICODE_ATTR +#endif + +/* Always output samples shifted to 28 bits + sign*/ +#define ALAC_OUTPUT_DEPTH 29 +#define SCALE16 (ALAC_OUTPUT_DEPTH - 16) +#define SCALE24 (ALAC_OUTPUT_DEPTH - 24) +#define ALAC_MAX_CHANNELS 2 +#define ALAC_BLOCKSIZE 4096 /* Number of samples per channel per block */ + +typedef struct +{ + unsigned char *input_buffer; + int input_buffer_bitaccumulator; /* used so we can do arbitary + bit reads */ + + /* rockbox: not used + int samplesize; + int numchannels; + int bytespersample; */ + + int bytes_consumed; + + /* stuff from setinfo */ + uint32_t setinfo_max_samples_per_frame; /* 0x1000 = 4096 */ /* max samples per frame? */ + uint8_t setinfo_7a; /* 0x00 */ + uint8_t setinfo_sample_size; /* 0x10 */ + uint8_t setinfo_rice_historymult; /* 0x28 */ + uint8_t setinfo_rice_initialhistory; /* 0x0a */ + uint8_t setinfo_rice_kmodifier; /* 0x0e */ + uint8_t setinfo_7f; /* 0x02 */ + uint16_t setinfo_80; /* 0x00ff */ + uint32_t setinfo_82; /* 0x000020e7 */ + uint32_t setinfo_86; /* 0x00069fe4 */ + uint32_t setinfo_8a_rate; /* 0x0000ac44 */ + /* end setinfo stuff */ +} alac_file; + +/* rockbox: not used +void create_alac(int samplesize, int numchannels, alac_file* alac) + ICODE_ATTR_ALAC; */ + +int alac_decode_frame(alac_file *alac, + unsigned char *inbuffer, + int32_t outputbuffer[ALAC_MAX_CHANNELS][ALAC_BLOCKSIZE], + void (*yield)(void)) ICODE_ATTR_ALAC; +void alac_set_info(alac_file *alac, char *inputbuffer) ICODE_ATTR_ALAC; + +#endif /* __ALAC__DECOMP_H */ + diff --git a/lib/rbcodec/codecs/libalac/libalac.make b/lib/rbcodec/codecs/libalac/libalac.make new file mode 100644 index 0000000000..8b8a842f8e --- /dev/null +++ b/lib/rbcodec/codecs/libalac/libalac.make @@ -0,0 +1,18 @@ +# __________ __ ___. +# Open \______ \ ____ ____ | | _\_ |__ _______ ___ +# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / +# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < +# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ +# \/ \/ \/ \/ \/ +# $Id$ +# + +# libalac +ALACLIB := $(CODECDIR)/libalac.a +ALACLIB_SRC := $(call preprocess, $(RBCODECLIB_DIR)/codecs/libalac/SOURCES) +ALACLIB_OBJ := $(call c2obj, $(ALACLIB_SRC)) +OTHER_SRC += $(ALACLIB_SRC) + +$(ALACLIB): $(ALACLIB_OBJ) + $(SILENT)$(shell rm -f $@) + $(call PRINTS,AR $(@F))$(AR) rcs $@ $^ >/dev/null diff --git a/lib/rbcodec/codecs/libasap/CREDITS b/lib/rbcodec/codecs/libasap/CREDITS new file mode 100644 index 0000000000..387cbb6266 --- /dev/null +++ b/lib/rbcodec/codecs/libasap/CREDITS @@ -0,0 +1,58 @@ +Authors +------- + +Piotr Fusik {asapwww!}:: +Creator and main developer. + +Atari800 Emulator Developers {asapwww!(http://atari800.sourceforge.net)}:: +6502 and POKEY emulation used in 0.x.y versions of ASAP. + +Zdenek Eisenhammer {asapwww!}:: +Testing. + +Henryk Karpowicz {asapwww!}:: +CMC routine modified for the CM3 format. + +Maciek Konecki {asapwww!}:: +Porting to C#. + +Marek Konopka {asapwww!}:: +6502 routine for playing DLT. + +Marcin Lewandowski {asapwww!}:: +6502 routines for playing CMC, MPT, TMC and TM2. + +Adrian Matoga {asapwww!}:: +COVOX information and test files. Testing. + +Perry McFarlane {asapwww!}:: +POKEY reverse-engineering. + +Kostas Nakos {asapwww!}:: +Windows CE testing. + +Mariusz Rozwadowski {asapwww!}:: +Suggested CMS, CM3 and DLT format support. + +Slawomir Sledz {asapwww!}:: +Testing. + +David Spilka:: +6502 routine for playing CMS. + +Radek Sterba {asapwww!}:: +6502 routine for playing RMT. +Testing. + +Lukasz Sychowicz {asapwww!}:: +Windows icons. +Testing. + +Pawel Szewczyk {asapwww!}:: +Windows setup graphics. + +Michal Szpilowski {asapwww!}:: +Testing. + +Grzegorz Zyla {asapwww!}:: +XBMC plugin testing. diff --git a/lib/rbcodec/codecs/libasap/README b/lib/rbcodec/codecs/libasap/README new file mode 100644 index 0000000000..d4fbfe6297 --- /dev/null +++ b/lib/rbcodec/codecs/libasap/README @@ -0,0 +1,148 @@ +ASAP - Another Slight Atari Player +================================== + +// This file is in AsciiDoc format. It is converted to README.html. +:Compact-Option: + +ifdef::asapwww[] +http://sourceforge.net/projects/asap/files/asap/[Download] | +http://asap.git.sourceforge.net/git/gitweb.cgi?p=asap/asap;a=summary[Browse source code (Git)] | +http://sourceforge.net/scm/?type=git&group_id=154391[Get latest source code (Git)] | +http://sourceforge.net/projects/asap/[SourceForge project page] +endif::asapwww[] + +ASAP is a player of http://en.wikipedia.org/wiki/Atari_8-bit_family[8-bit Atari] +music for modern computers. +It emulates the http://en.wikipedia.org/wiki/POKEY[POKEY sound chip] +and the http://en.wikipedia.org/wiki/6502[6502 processor]. +The project was initially based on the routines from the +http://atari800.sourceforge.net/[Atari800 emulator], +but the current version has a completely new original emulation core. + +ASAP includes the following programs: + +- asapconv - portable command-line converter {asapwin=} +- WASAP - tiny player for Windows {asapwin=}{asapwince=} +- plugin for http://koti.welho.com/hylinen/apollo/[Apollo] {asapwin=} +- plugin for http://audacious-media-player.org/[Audacious] +- plugin for http://foobar2000.org/[foobar2000] {asapwin=} +- plugin for http://hp.vector.co.jp/authors/VA032810/[GSPlayer] {asapwin=}{asapwince=} +- plugin for http://moc.daper.net/[MOC] +- plugin for http://www.winamp.com/[Winamp] {asapwin=} +- plugin for http://www.microsoft.com/windows/windowsmedia/player/[Windows Media Player] {asapwin=} +- plugin for http://xbmc.org/[XBMC] {asapwin=} +- plugin for http://xmms.org/[XMMS] +- plugin for http://www.un4seen.com/xmplay.html[XMPlay] {asapwin=} +- add-on for http://www.un4seen.com/bass.html[BASS] (for http://www.aimp.ru/[AIMP] and http://www.un4seen.com/bass_showcase.php[other players]) {asapwin=} +- POKEY sound emulation DLL for http://raster.infos.cz/atari/rmt/rmt.htm[Raster Music Tracker] {asapwin=} +- Windows Explorer extension - shows metadata {asapwin=} +- Java version of ASAP2WAV - command-line converter to WAV files {asapjava=} +- Java applet - for web pages {asapjava=}{asapwww?(see link:applet.html[online demo])} +- Java midlet - for mobile devices {asapjava=} +- C# version of ASAP2WAV +- JavaScript version of ASAP2WAV running in http://en.wikipedia.org/wiki/Windows_Script_Host[Windows Script Host], https://developer.mozilla.org/en/Rhino_Shell[Rhino Shell], http://code.google.com/p/v8/[V8 Shell], http://en.wikipedia.org/wiki/JScript_.NET[JScript .NET] and http://en.wikipedia.org/wiki/JaegerMonkey[JaegerMonkey] {asapjavascript=} +- experimental JavaScript version of ASAP2WAV running in Firefox {asapjavascript=} +- Flash player - for web pages {asapflash=}{asapwww?(see link:flash.html[online demo])} +- asapplay - simple command-line player in C# +- http://www.silverlight.net/[Silverlight] player - for web pages {asapwww?(see link:silverlight.html[online demo])} +- AndroidASAP - for mobile devices + +{asapports}The summary of the differences between the above versions is in link:PORTS.xml[this table]. + +There are other projects which use ASAP: + +- http://mmsap.sourceforge.net/[mmSAP 2] - standalone player for GNU/Linux with GTK+ user interface +- http://www.rockbox.org/[Rockbox] - open source firmware for MP3 players + + +Input file formats +------------------ + +ASAP supports the following file formats (determined by the filename extension): + +SAP (Slight Atari Player):: +The format designed for playing 8-bit Atari music on modern computers. +All other formats can be converted to SAP. +http://asma.atari.org/[Atari SAP Music Archive (ASMA)] +is a single big collection of SAP files. + +CMC (Chaos Music Composer):: +Atari music editor from early 1990s. + +CM3 (CMC "3/4"):: +CMC with modified pattern length. + +CMR (CMC "Rzog"):: +CMC with modified bass sounds. + +CMS (Stereo Double CMC):: +Stereo CMC. + +DMC (DoublePlay CMC):: +CMC with 6502 routine executed at double rate of the original CMC. + +DLT (Delta Music Composer):: +Atari music editor from 1990s. + +MPT (Music ProTracker):: +Atari music editor from 1990s. + +MPD (MPT DoublePlay):: +MPT with 6502 routine executed at double rate of the original MPT. + +RMT (http://raster.infos.cz/atari/rmt/rmt.htm[Raster Music Tracker]):: +Modern Atari music editor running on Windows. + +TMC, TM8 (http://jaskier.atari8.info/[Theta Music Composer] 1.x):: +Atari music editor from late 1990s. +The two file extensions are treated identically and played in stereo. +TM8 means it's stereo (8-channel) music while TMC can be either mono or stereo. + +TM2 (http://jaskier.atari8.info/[Theta Music Composer] 2.x):: +Modern Atari music editor. + + +ifdef::asapsrc[] +include::INSTALL[] +endif::asapsrc[] + +ifdef::asapflash[] +include::flash/USAGE[] +endif::asapflash[] + +ifdef::asapjava[] +include::java/USAGE[] +endif::asapjava[] + +ifdef::asapjavascript[] +include::javascript/USAGE[] +endif::asapjavascript[] + +ifdef::asapwin[] +include::win32/USAGE[] +endif::asapwin[] + +ifdef::asapwince[] +include::win32/wince/USAGE[] +endif::asapwince[] + +include::NEWS[] + +include::CREDITS[] + + +Feedback +-------- + +If you are interested in the ASAP project, please subscribe its +https://lists.sourceforge.net/lists/listinfo/asap-users[mailing list]. +This list is for users and developers. +Once you subscribe, you can post comments, ideas and questions about ASAP. +They will be answered ASAP. ;-) + +Use http://sourceforge.net/tracker/?group_id=154391[tracker] +to submit bug reports, feature requests and small code patches. + +ifdef::asapwww[] +image::http://sflogo.sourceforge.net/sflogo.php?group_id=154391&type=13["Get ASAP - Another Slight Atari Player at SourceForge.net. Fast, secure and Free Open Source software downloads",width=120,height=30,link="http://sourceforge.net/projects/asap/"] +endif::asapwww[] diff --git a/lib/rbcodec/codecs/libasap/README.rockbox b/lib/rbcodec/codecs/libasap/README.rockbox new file mode 100644 index 0000000000..62184822d4 --- /dev/null +++ b/lib/rbcodec/codecs/libasap/README.rockbox @@ -0,0 +1,22 @@ +Library: asap-2.1.2 +Imported: 2010-02-02 by Dominik Wenger +Updated: 2010-08-11 by Dominik Wenger + +This directory contains a local version of asap (http://asap.sourceforge.net/) for decoding Atari 8bit .sap +audio streams. + +LICENSING INFORMATION + +Asap is available under the terms of the GPL v2 or later +license, which is both an open source and free software license. +The Licence is the same as the rest of Rockbox. + + +IMPORT DETAILS + +The .[ch] files in apps/codec/libasap are copied from ASAP. + +players.h (contains binarys of players) was generated and copied +into Rockbox. + + diff --git a/lib/rbcodec/codecs/libasap/SOURCES b/lib/rbcodec/codecs/libasap/SOURCES new file mode 100644 index 0000000000..0d1f1f46fa --- /dev/null +++ b/lib/rbcodec/codecs/libasap/SOURCES @@ -0,0 +1,3 @@ +acpu.c +asap.c +apokeysnd.c diff --git a/lib/rbcodec/codecs/libasap/acpu.c b/lib/rbcodec/codecs/libasap/acpu.c new file mode 100644 index 0000000000..0fd5988b83 --- /dev/null +++ b/lib/rbcodec/codecs/libasap/acpu.c @@ -0,0 +1,1291 @@ +/* + * acpu.c - another 6502 CPU emulator + * + * Copyright (C) 2007-2010 Piotr Fusik + * + * This file is part of ASAP (Another Slight Atari Player), + * see http://asap.sourceforge.net + * + * ASAP is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published + * by the Free Software Foundation; either version 2 of the License, + * or (at your option) any later version. + * + * ASAP is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with ASAP; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/* How 6502 registers are stored in this emulator: + All variables are int, because modern processors (and Java bytecode) + tend to operate more effectively on these type than narrower ones. + pc is really an unsigned 16-bit integer. + a, x, y and s are unsigned 8-bit integers. + Flags are decomposed into three variables for improved performance. + c is either 0 or 1. + nz contains 6502 flags N and Z. + N is set if (nz >= 0x80). Z is set if ((nz & 0xff) == 0). + Usually nz is simply assigned the unsigned 8-bit operation result. + There are just a few operations (ADC in decimal mode, BIT, PLP and RTI) + where both N and Z may be set. In these cases, N is reflected by the 8th + (not 7th) bit of nz. + vdi contains rarely used flags V, D and I, as a combination + of V_FLAG, D_FLAG and I_FLAG. Other vdi bits are clear. + + "Unofficial" opcodes are not documented as "legal" 6502 opcodes. + Their operation has been reverse-engineered on Atari 800XL and Atari 65XE. + Unofficial opcodes are identical to C64's 6510, except for 0x8b and 0xab. + The operation of "unstable" opcodes is partially uncertain. + Explanation is welcome. + + Emulation of POKEY timer interrupts is included. + + Two preprocessor symbols may be used to strip the size of this emulator. + Define ACPU_NO_DECIMAL to disable emulation of the BCD mode. + Define ACPU_NO_UNOFFICIAL to disable emulation of unofficial opcodes. */ + +#include "asap_internal.h" + +CONST_ARRAY(int, opcode_cycles) +/* 0 1 2 3 4 5 6 7 8 9 A B C D E F */ + 7, 6, 2, 8, 3, 3, 5, 5, 3, 2, 2, 2, 4, 4, 6, 6, /* 0x */ + 2, 5, 2, 8, 4, 4, 6, 6, 2, 4, 2, 7, 4, 4, 7, 7, /* 1x */ + 6, 6, 2, 8, 3, 3, 5, 5, 4, 2, 2, 2, 4, 4, 6, 6, /* 2x */ + 2, 5, 2, 8, 4, 4, 6, 6, 2, 4, 2, 7, 4, 4, 7, 7, /* 3x */ + 6, 6, 2, 8, 3, 3, 5, 5, 3, 2, 2, 2, 3, 4, 6, 6, /* 4x */ + 2, 5, 2, 8, 4, 4, 6, 6, 2, 4, 2, 7, 4, 4, 7, 7, /* 5x */ + 6, 6, 2, 8, 3, 3, 5, 5, 4, 2, 2, 2, 5, 4, 6, 6, /* 6x */ + 2, 5, 2, 8, 4, 4, 6, 6, 2, 4, 2, 7, 4, 4, 7, 7, /* 7x */ + 2, 6, 2, 6, 3, 3, 3, 3, 2, 2, 2, 2, 4, 4, 4, 4, /* 8x */ + 2, 6, 2, 6, 4, 4, 4, 4, 2, 5, 2, 5, 5, 5, 5, 5, /* 9x */ + 2, 6, 2, 6, 3, 3, 3, 3, 2, 2, 2, 2, 4, 4, 4, 4, /* Ax */ + 2, 5, 2, 5, 4, 4, 4, 4, 2, 4, 2, 4, 4, 4, 4, 4, /* Bx */ + 2, 6, 2, 8, 3, 3, 5, 5, 2, 2, 2, 2, 4, 4, 6, 6, /* Cx */ + 2, 5, 2, 8, 4, 4, 6, 6, 2, 4, 2, 7, 4, 4, 7, 7, /* Dx */ + 2, 6, 2, 8, 3, 3, 5, 5, 2, 2, 2, 2, 4, 4, 6, 6, /* Ex */ + 2, 5, 2, 8, 4, 4, 6, 6, 2, 4, 2, 7, 4, 4, 7, 7 /* Fx */ +END_CONST_ARRAY; + +#ifdef ACPU_NO_DECIMAL + +#define DO_ADC \ + { \ + /* binary mode */ \ + V(int, tmp) = a + data + c; \ + vdi = (vdi & (D_FLAG | I_FLAG)) + (((~(data ^ a) & (a ^ tmp)) >> 1) & V_FLAG); \ + c = tmp >> 8; \ + nz = a = tmp & 0xff; \ + } + +#define DO_SBC \ + { \ + /* binary mode */ \ + V(int, tmp) = a - data - 1 + c; \ + vdi = (vdi & (D_FLAG | I_FLAG)) + ((((data ^ a) & (a ^ tmp)) >> 1) & V_FLAG); \ + c = (tmp >= 0) ? 1 : 0; \ + nz = a = tmp & 0xff; \ + } + +#else /* ACPU_NO_DECIMAL */ + +#define DO_ADC \ + { \ + V(int, tmp) = a + data + c; \ + nz = tmp & 0xff; \ + if ((vdi & D_FLAG) == 0) { \ + /* binary mode */ \ + vdi = (vdi & (D_FLAG | I_FLAG)) + (((~(data ^ a) & (a ^ tmp)) >> 1) & V_FLAG); \ + c = tmp >> 8; \ + a = nz; \ + } \ + else { \ + /* decimal mode */ \ + V(int, al) = (a & 0x0f) + (data & 0x0f) + c; \ + if (al >= 10) \ + tmp += (al < 26) ? 6 : -10; \ + nz = ((tmp & 0x80) << 1) + (nz != 0 ? 1 : 0); \ + vdi = (vdi & (D_FLAG | I_FLAG)) + (((~(data ^ a) & (a ^ tmp)) >> 1) & V_FLAG); \ + if (tmp >= 0xa0) { \ + c = 1; \ + a = (tmp + 0x60) & 0xff; \ + } \ + else { \ + c = 0; \ + a = tmp; \ + } \ + } \ + } + +#define DO_SBC \ + {\ + V(int, tmp) = a - data - 1 + c; \ + V(int, al) = (a & 0x0f) - (data & 0x0f) - 1 + c; \ + vdi = (vdi & (D_FLAG | I_FLAG)) + ((((data ^ a) & (a ^ tmp)) >> 1) & V_FLAG); \ + c = (tmp >= 0) ? 1 : 0; \ + nz = a = tmp & 0xff; \ + if ((vdi & D_FLAG) != 0) { \ + /* decimal mode */ \ + if (al < 0) \ + a += (al < -10) ? 10 : -6; \ + if (c == 0) \ + a = (a - 0x60) & 0xff; \ + } \ + } + +#endif /* ACPU_NO_DECIMAL */ + +#define zGetByte(addr) dGetByte((addr) & 0xff) + +#define PEEK dGetByte(pc) +#define FETCH dGetByte(pc++) + +#define ABSOLUTE addr = FETCH; addr += FETCH << 8 +#define ABSOLUTE_X addr = FETCH; addr = (addr + (FETCH << 8) + x) & 0xffff +#define ABSOLUTE_Y addr = FETCH; addr = (addr + (FETCH << 8) + y) & 0xffff +#define ZPAGE addr = FETCH +#define ZPAGE_X addr = (FETCH + x) & 0xff +#define ZPAGE_Y addr = (FETCH + y) & 0xff +#define INDIRECT_X addr = (FETCH + x) & 0xff; addr = dGetByte(addr) + (zGetByte(addr + 1) << 8) +#define INDIRECT_Y addr = FETCH; addr = (dGetByte(addr) + (zGetByte(addr + 1) << 8) + y) & 0xffff +#define NCYCLES_X if ((addr & 0xff) < x) ast _ cycle++ +#define NCYCLES_Y if ((addr & 0xff) < y) ast _ cycle++ + +#define PL(dest) s = (s + 1) & 0xff; dest = dGetByte(0x0100 + s) +#define PLP PL(vdi); nz = ((vdi & 0x80) << 1) + (~vdi & Z_FLAG); c = vdi & 1; vdi &= V_FLAG | D_FLAG | I_FLAG +#define PH(data) dPutByte(0x0100 + s, data); s = (s - 1) & 0xff +#define PHW(data) PH((data) >> 8); PH(TO_BYTE(data)) +#define PHP(bflag) PH(((nz | (nz >> 1)) & 0x80) + vdi + ((nz & 0xff) == 0 ? Z_FLAG : 0) + c + bflag) +#define PHPB0 PHP(0x20) /* push flags with B flag clear (NMI, IRQ) */ +#define PHPB1 PHP(0x30) /* push flags with B flag set (PHP, BRK) */ +#define PHPC PHW(pc) + +#define LDA nz = a = GetByte(addr) +#define LDA_ZP nz = a = dGetByte(addr) +#define LDX nz = x = GetByte(addr) +#define LDX_ZP nz = x = dGetByte(addr) +#define LDY nz = y = GetByte(addr) +#define LDY_ZP nz = y = dGetByte(addr) +#define LAX nz = x = a = GetByte(addr) +#define LAX_ZP nz = x = a = dGetByte(addr) +#define STA PutByte(addr, a) +#define STA_ZP dPutByte(addr, a) +#define STX PutByte(addr, x) +#define STX_ZP dPutByte(addr, x) +#define STY PutByte(addr, y) +#define STY_ZP dPutByte(addr, y) +#define SAX data = a & x; PutByte(addr, data) +#define SAX_ZP data = a & x; dPutByte(addr, data) +#define CMP nz = GetByte(addr); c = (a >= nz) ? 1 : 0; nz = (a - nz) & 0xff +#define CMP_ZP nz = dGetByte(addr); c = (a >= nz) ? 1 : 0; nz = (a - nz) & 0xff +#define CPX nz = GetByte(addr); c = (x >= nz) ? 1 : 0; nz = (x - nz) & 0xff +#define CPX_ZP nz = dGetByte(addr); c = (x >= nz) ? 1 : 0; nz = (x - nz) & 0xff +#define CPY nz = GetByte(addr); c = (y >= nz) ? 1 : 0; nz = (y - nz) & 0xff +#define CPY_ZP nz = dGetByte(addr); c = (y >= nz) ? 1 : 0; nz = (y - nz) & 0xff +#define AND nz = a &= GetByte(addr) +#define AND_ZP nz = a &= dGetByte(addr) +#define ORA nz = a |= GetByte(addr) +#define ORA_ZP nz = a |= dGetByte(addr) +#define EOR nz = a ^= GetByte(addr) +#define EOR_ZP nz = a ^= dGetByte(addr) +#define ADC data = GetByte(addr); DO_ADC +#define ADC_ZP data = dGetByte(addr); DO_ADC +#define SBC data = GetByte(addr); DO_SBC +#define SBC_ZP data = dGetByte(addr); DO_SBC + +#define ASL RMW_GetByte(nz, addr); c = nz >> 7; nz = (nz << 1) & 0xff; PutByte(addr, nz) +#define ASL_ZP nz = dGetByte(addr); c = nz >> 7; nz = (nz << 1) & 0xff; dPutByte(addr, nz) +#define ROL RMW_GetByte(nz, addr); nz = (nz << 1) + c; c = nz >> 8; nz &= 0xff; PutByte(addr, nz) +#define ROL_ZP nz = dGetByte(addr); nz = (nz << 1) + c; c = nz >> 8; nz &= 0xff; dPutByte(addr, nz) +#define LSR RMW_GetByte(nz, addr); c = nz & 1; nz >>= 1; PutByte(addr, nz) +#define LSR_ZP nz = dGetByte(addr); c = nz & 1; nz >>= 1; dPutByte(addr, nz) +#define ROR RMW_GetByte(nz, addr); nz += c << 8; c = nz & 1; nz >>= 1; PutByte(addr, nz) +#define ROR_ZP nz = dGetByte(addr) + (c << 8); c = nz & 1; nz >>= 1; dPutByte(addr, nz) +#define DEC RMW_GetByte(nz, addr); nz = (nz - 1) & 0xff; PutByte(addr, nz) +#define DEC_ZP nz = dGetByte(addr); nz = (nz - 1) & 0xff; dPutByte(addr, nz) +#define INC RMW_GetByte(nz, addr); nz = (nz + 1) & 0xff; PutByte(addr, nz) +#define INC_ZP nz = dGetByte(addr); nz = (nz + 1) & 0xff; dPutByte(addr, nz) + +#define ASO ASL; nz = a |= nz +#define ASO_ZP ASL_ZP; nz = a |= nz +#define RLA ROL; nz = a &= nz +#define RLA_ZP ROL_ZP; nz = a &= nz +#define LSE LSR; nz = a ^= nz +#define LSE_ZP LSR_ZP; nz = a ^= nz +#define RRA ROR; data = nz; DO_ADC +#define RRA_ZP ROR_ZP; data = nz; DO_ADC +#define DCM DEC; c = (a >= nz) ? 1 : 0; nz = (a - nz) & 0xff +#define DCM_ZP DEC_ZP; c = (a >= nz) ? 1 : 0; nz = (a - nz) & 0xff +#define INS INC; data = nz; DO_SBC +#define INS_ZP INC_ZP; data = nz; DO_SBC + +#define BRANCH(cond) \ + if (cond) { \ + addr = SBYTE(PEEK); \ + pc++; \ + addr += pc; \ + if ((addr ^ pc) >> 8 != 0) \ + ast _ cycle++; \ + ast _ cycle++; \ + pc = addr; \ + break; \ + } \ + pc++; \ + break + +#define CHECK_IRQ \ + if ((vdi & I_FLAG) == 0 && ast _ irqst != 0xff) { \ + PHPC; \ + PHPB0; \ + vdi |= I_FLAG; \ + pc = dGetWord(0xfffe); \ + ast _ cycle += 7; \ + } + +/* Runs 6502 emulation for the specified number of Atari scanlines. + Each scanline is 114 cycles of which 9 is taken by ANTIC for memory refresh. */ +FUNC(void, Cpu_RunScanlines, (P(ASAP_State PTR, ast), P(int, scanlines))) +{ + /* copy registers from ASAP_State to local variables for improved performance */ + V(int, pc); + V(int, nz); + V(int, a); + V(int, x); + V(int, y); + V(int, c); + V(int, s); + V(int, vdi); + V(int, next_event_cycle); + V(int, cycle_limit); + pc = ast _ cpu_pc; + nz = ast _ cpu_nz; + a = ast _ cpu_a; + x = ast _ cpu_x; + y = ast _ cpu_y; + c = ast _ cpu_c; + s = ast _ cpu_s; + vdi = ast _ cpu_vdi; + ast _ next_scanline_cycle = 114; + next_event_cycle = 114; + cycle_limit = 114 * scanlines; + if (next_event_cycle > ast _ timer1_cycle) + next_event_cycle = ast _ timer1_cycle; + if (next_event_cycle > ast _ timer2_cycle) + next_event_cycle = ast _ timer2_cycle; + if (next_event_cycle > ast _ timer4_cycle) + next_event_cycle = ast _ timer4_cycle; + ast _ nearest_event_cycle = next_event_cycle; + for (;;) { + V(int, cycle); + V(int, addr); + V(int, data); + cycle = ast _ cycle; + if (cycle >= ast _ nearest_event_cycle) { + if (cycle >= ast _ next_scanline_cycle) { + if (++ast _ scanline_number == (ast _ module_info->ntsc ? 262 : 312)) + ast _ scanline_number = 0; + ast _ cycle = cycle += 9; + ast _ next_scanline_cycle += 114; + if (--scanlines <= 0) + break; + } + next_event_cycle = ast _ next_scanline_cycle; +#define CHECK_TIMER_IRQ(ch) \ + if (cycle >= ast _ timer##ch##_cycle) { \ + ast _ irqst &= ~ch; \ + ast _ timer##ch##_cycle = NEVER; \ + } \ + else if (next_event_cycle > ast _ timer##ch##_cycle) \ + next_event_cycle = ast _ timer##ch##_cycle; + CHECK_TIMER_IRQ(1); + CHECK_TIMER_IRQ(2); + CHECK_TIMER_IRQ(4); + ast _ nearest_event_cycle = next_event_cycle; + CHECK_IRQ; + } +#ifdef ASAPSCAN + if (cpu_trace != 0) + trace_cpu(ast, pc, a, x, y, s, nz, vdi, c); +#endif + data = FETCH; + ast _ cycle += opcode_cycles[data]; + switch (data) { + case 0x00: /* BRK */ + pc++; + PHPC; + PHPB1; + vdi |= I_FLAG; + pc = dGetWord(0xfffe); + break; + case 0x01: /* ORA (ab,x) */ + INDIRECT_X; + ORA; + break; + case 0x02: /* CIM [unofficial] */ + case 0x12: + case 0x22: + case 0x32: + case 0x42: + case 0x52: + case 0x62: + case 0x72: + case 0x92: + case 0xb2: + case 0xd2: + case 0xf2: + ast _ scanline_number = (ast _ scanline_number + scanlines - 1) % (ast _ module_info->ntsc ? 262 : 312); + scanlines = 1; + ast _ cycle = cycle_limit; + break; +#ifndef ACPU_NO_UNOFFICIAL + case 0x03: /* ASO (ab,x) [unofficial] */ + INDIRECT_X; + ASO; + break; + case 0x04: /* NOP ab [unofficial] */ + case 0x44: + case 0x64: + case 0x14: /* NOP ab,x [unofficial] */ + case 0x34: + case 0x54: + case 0x74: + case 0xd4: + case 0xf4: + case 0x80: /* NOP #ab [unofficial] */ + case 0x82: + case 0x89: + case 0xc2: + case 0xe2: + pc++; + break; + case 0x07: /* ASO ab [unofficial] */ + ZPAGE; + ASO_ZP; + break; + case 0x0b: /* ANC #ab [unofficial] */ + case 0x2b: + nz = a &= FETCH; + c = nz >> 7; + break; + case 0x0c: /* NOP abcd [unofficial] */ + pc += 2; + break; + case 0x0f: /* ASO abcd [unofficial] */ + ABSOLUTE; + ASO; + break; + case 0x13: /* ASO (ab),y [unofficial] */ + INDIRECT_Y; + ASO; + break; + case 0x17: /* ASO ab,x [unofficial] */ + ZPAGE_X; + ASO_ZP; + break; + case 0x1b: /* ASO abcd,y [unofficial] */ + ABSOLUTE_Y; + ASO; + break; + case 0x1c: /* NOP abcd,x [unofficial] */ + case 0x3c: + case 0x5c: + case 0x7c: + case 0xdc: + case 0xfc: + if (FETCH + x >= 0x100) + ast _ cycle++; + pc++; + break; + case 0x1f: /* ASO abcd,x [unofficial] */ + ABSOLUTE_X; + ASO; + break; + case 0x23: /* RLA (ab,x) [unofficial] */ + INDIRECT_X; + RLA; + break; + case 0x27: /* RLA ab [unofficial] */ + ZPAGE; + RLA_ZP; + break; + case 0x2f: /* RLA abcd [unofficial] */ + ABSOLUTE; + RLA; + break; + case 0x33: /* RLA (ab),y [unofficial] */ + INDIRECT_Y; + RLA; + break; + case 0x37: /* RLA ab,x [unofficial] */ + ZPAGE_X; + RLA_ZP; + break; + case 0x3b: /* RLA abcd,y [unofficial] */ + ABSOLUTE_Y; + RLA; + break; + case 0x3f: /* RLA abcd,x [unofficial] */ + ABSOLUTE_X; + RLA; + break; + case 0x43: /* LSE (ab,x) [unofficial] */ + INDIRECT_X; + LSE; + break; + case 0x47: /* LSE ab [unofficial] */ + ZPAGE; + LSE_ZP; + break; + case 0x4b: /* ALR #ab [unofficial] */ + a &= FETCH; + c = a & 1; + nz = a >>= 1; + break; + case 0x4f: /* LSE abcd [unofficial] */ + ABSOLUTE; + LSE; + break; + case 0x53: /* LSE (ab),y [unofficial] */ + INDIRECT_Y; + LSE; + break; + case 0x57: /* LSE ab,x [unofficial] */ + ZPAGE_X; + LSE_ZP; + break; + case 0x5b: /* LSE abcd,y [unofficial] */ + ABSOLUTE_Y; + LSE; + break; + case 0x5f: /* LSE abcd,x [unofficial] */ + ABSOLUTE_X; + LSE; + break; + case 0x63: /* RRA (ab,x) [unofficial] */ + INDIRECT_X; + RRA; + break; + case 0x67: /* RRA ab [unofficial] */ + ZPAGE; + RRA_ZP; + break; + case 0x6b: /* ARR #ab [unofficial] */ + data = a & FETCH; + nz = a = (data >> 1) + (c << 7); + vdi = (vdi & (D_FLAG | I_FLAG)) + ((a ^ data) & V_FLAG); +#ifdef ACPU_NO_DECIMAL + c = data >> 7; +#else + if ((vdi & D_FLAG) == 0) + c = data >> 7; + else { + if ((data & 0xf) >= 5) + a = (a & 0xf0) + ((a + 6) & 0xf); + if (data >= 0x50) { + a = (a + 0x60) & 0xff; + c = 1; + } + else + c = 0; + } +#endif + break; + case 0x6f: /* RRA abcd [unofficial] */ + ABSOLUTE; + RRA; + break; + case 0x73: /* RRA (ab),y [unofficial] */ + INDIRECT_Y; + RRA; + break; + case 0x77: /* RRA ab,x [unofficial] */ + ZPAGE_X; + RRA_ZP; + break; + case 0x7b: /* RRA abcd,y [unofficial] */ + ABSOLUTE_Y; + RRA; + break; + case 0x7f: /* RRA abcd,x [unofficial] */ + ABSOLUTE_X; + RRA; + break; + case 0x83: /* SAX (ab,x) [unofficial] */ + INDIRECT_X; + SAX; + break; + case 0x87: /* SAX ab [unofficial] */ + ZPAGE; + SAX_ZP; + break; + case 0x8b: /* ANE #ab [unofficial] */ + data = FETCH; + a &= x; + nz = a & data; + a &= data | 0xef; + break; + case 0x8f: /* SAX abcd [unofficial] */ + ABSOLUTE; + SAX; + break; + case 0x93: /* SHA (ab),y [unofficial, unstable] */ + ZPAGE; + data = zGetByte(addr + 1); + addr = (dGetByte(addr) + (data << 8) + y) & 0xffff; + data = a & x & (data + 1); + PutByte(addr, data); + break; + case 0x97: /* SAX ab,y [unofficial] */ + ZPAGE_Y; + SAX_ZP; + break; + case 0x9b: /* SHS abcd,y [unofficial, unstable] */ + /* S seems to be stable, only memory values vary */ + addr = FETCH; + data = FETCH; + addr = (addr + (data << 8) + y) & 0xffff; + s = a & x; + data = s & (data + 1); + PutByte(addr, data); + break; + case 0x9c: /* SHY abcd,x [unofficial] */ + addr = FETCH; + data = FETCH; + addr = (addr + (data << 8) + x) & 0xffff; + data = y & (data + 1); + PutByte(addr, data); + break; + case 0x9e: /* SHX abcd,y [unofficial] */ + addr = FETCH; + data = FETCH; + addr = (addr + (data << 8) + y) & 0xffff; + data = x & (data + 1); + PutByte(addr, data); + break; + case 0x9f: /* SHA abcd,y [unofficial, unstable] */ + addr = FETCH; + data = FETCH; + addr = (addr + (data << 8) + y) & 0xffff; + data = a & x & (data + 1); + PutByte(addr, data); + break; + case 0xa3: /* LAX (ab,x) [unofficial] */ + INDIRECT_X; + LAX; + break; + case 0xa7: /* LAX ab [unofficial] */ + ZPAGE; + LAX_ZP; + break; + case 0xab: /* ANX #ab [unofficial] */ + nz = x = a &= FETCH; + break; + case 0xaf: /* LAX abcd [unofficial] */ + ABSOLUTE; + LAX; + break; + case 0xb3: /* LAX (ab),y [unofficial] */ + INDIRECT_Y; + NCYCLES_Y; + LAX; + break; + case 0xb7: /* LAX ab,y [unofficial] */ + ZPAGE_Y; + LAX_ZP; + break; + case 0xbb: /* LAS abcd,y [unofficial] */ + ABSOLUTE_Y; + NCYCLES_Y; + nz = x = a = s &= GetByte(addr); + break; + case 0xbf: /* LAX abcd,y [unofficial] */ + ABSOLUTE_Y; + NCYCLES_Y; + LAX; + break; + case 0xc3: /* DCM (ab,x) [unofficial] */ + INDIRECT_X; + DCM; + break; + case 0xc7: /* DCM ab [unofficial] */ + ZPAGE; + DCM_ZP; + break; + case 0xcb: /* SBX #ab [unofficial] */ + nz = FETCH; + x &= a; + c = (x >= nz) ? 1 : 0; + nz = x = (x - nz) & 0xff; + break; + case 0xcf: /* DCM abcd [unofficial] */ + ABSOLUTE; + DCM; + break; + case 0xd3: /* DCM (ab),y [unofficial] */ + INDIRECT_Y; + DCM; + break; + case 0xd7: /* DCM ab,x [unofficial] */ + ZPAGE_X; + DCM_ZP; + break; + case 0xdb: /* DCM abcd,y [unofficial] */ + ABSOLUTE_Y; + DCM; + break; + case 0xdf: /* DCM abcd,x [unofficial] */ + ABSOLUTE_X; + DCM; + break; + case 0xe3: /* INS (ab,x) [unofficial] */ + INDIRECT_X; + INS; + break; + case 0xe7: /* INS ab [unofficial] */ + ZPAGE; + INS_ZP; + break; + case 0xef: /* INS abcd [unofficial] */ + ABSOLUTE; + INS; + break; + case 0xf3: /* INS (ab),y [unofficial] */ + INDIRECT_Y; + INS; + break; + case 0xf7: /* INS ab,x [unofficial] */ + ZPAGE_X; + INS_ZP; + break; + case 0xfb: /* INS abcd,y [unofficial] */ + ABSOLUTE_Y; + INS; + break; + case 0xff: /* INS abcd,x [unofficial] */ + ABSOLUTE_X; + INS; + break; +#endif /* ACPU_NO_UNOFFICIAL */ + case 0x05: /* ORA ab */ + ZPAGE; + ORA_ZP; + break; + case 0x06: /* ASL ab */ + ZPAGE; + ASL_ZP; + break; + case 0x08: /* PHP */ + PHPB1; + break; + case 0x09: /* ORA #ab */ + nz = a |= FETCH; + break; + case 0x0a: /* ASL */ + c = a >> 7; + nz = a = (a << 1) & 0xff; + break; + case 0x0d: /* ORA abcd */ + ABSOLUTE; + ORA; + break; + case 0x0e: /* ASL abcd */ + ABSOLUTE; + ASL; + break; + case 0x10: /* BPL */ + BRANCH(nz < 0x80); + case 0x11: /* ORA (ab),y */ + INDIRECT_Y; + NCYCLES_Y; + ORA; + break; + case 0x15: /* ORA ab,x */ + ZPAGE_X; + ORA_ZP; + break; + case 0x16: /* ASL ab,x */ + ZPAGE_X; + ASL_ZP; + break; + case 0x18: /* CLC */ + c = 0; + break; + case 0x19: /* ORA abcd,y */ + ABSOLUTE_Y; + NCYCLES_Y; + ORA; + break; + case 0x1d: /* ORA abcd,x */ + ABSOLUTE_X; + NCYCLES_X; + ORA; + break; + case 0x1e: /* ASL abcd,x */ + ABSOLUTE_X; + ASL; + break; + case 0x20: /* JSR abcd */ + addr = FETCH; + PHPC; + pc = addr + (PEEK << 8); + break; + case 0x21: /* AND (ab,x) */ + INDIRECT_X; + AND; + break; + case 0x24: /* BIT ab */ + ZPAGE; + nz = dGetByte(addr); + vdi = (vdi & (D_FLAG | I_FLAG)) + (nz & V_FLAG); + nz = ((nz & 0x80) << 1) + (nz & a); + break; + case 0x25: /* AND ab */ + ZPAGE; + AND_ZP; + break; + case 0x26: /* ROL ab */ + ZPAGE; + ROL_ZP; + break; + case 0x28: /* PLP */ + PLP; + CHECK_IRQ; + break; + case 0x29: /* AND #ab */ + nz = a &= FETCH; + break; + case 0x2a: /* ROL */ + a = (a << 1) + c; + c = a >> 8; + nz = a &= 0xff; + break; + case 0x2c: /* BIT abcd */ + ABSOLUTE; + nz = GetByte(addr); + vdi = (vdi & (D_FLAG | I_FLAG)) + (nz & V_FLAG); + nz = ((nz & 0x80) << 1) + (nz & a); + break; + case 0x2d: /* AND abcd */ + ABSOLUTE; + AND; + break; + case 0x2e: /* ROL abcd */ + ABSOLUTE; + ROL; + break; + case 0x30: /* BMI */ + BRANCH(nz >= 0x80); + case 0x31: /* AND (ab),y */ + INDIRECT_Y; + NCYCLES_Y; + AND; + break; + case 0x35: /* AND ab,x */ + ZPAGE_X; + AND_ZP; + break; + case 0x36: /* ROL ab,x */ + ZPAGE_X; + ROL_ZP; + break; + case 0x38: /* SEC */ + c = 1; + break; + case 0x39: /* AND abcd,y */ + ABSOLUTE_Y; + NCYCLES_Y; + AND; + break; + case 0x3d: /* AND abcd,x */ + ABSOLUTE_X; + NCYCLES_X; + AND; + break; + case 0x3e: /* ROL abcd,x */ + ABSOLUTE_X; + ROL; + break; + case 0x40: /* RTI */ + PLP; + PL(pc); + PL(addr); + pc += addr << 8; + CHECK_IRQ; + break; + case 0x41: /* EOR (ab,x) */ + INDIRECT_X; + EOR; + break; + case 0x45: /* EOR ab */ + ZPAGE; + EOR_ZP; + break; + case 0x46: /* LSR ab */ + ZPAGE; + LSR_ZP; + break; + case 0x48: /* PHA */ + PH(a); + break; + case 0x49: /* EOR #ab */ + nz = a ^= FETCH; + break; + case 0x4a: /* LSR */ + c = a & 1; + nz = a >>= 1; + break; + case 0x4c: /* JMP abcd */ + addr = FETCH; + pc = addr + (PEEK << 8); + break; + case 0x4d: /* EOR abcd */ + ABSOLUTE; + EOR; + break; + case 0x4e: /* LSR abcd */ + ABSOLUTE; + LSR; + break; + case 0x50: /* BVC */ + BRANCH((vdi & V_FLAG) == 0); + case 0x51: /* EOR (ab),y */ + INDIRECT_Y; + NCYCLES_Y; + EOR; + break; + case 0x55: /* EOR ab,x */ + ZPAGE_X; + EOR_ZP; + break; + case 0x56: /* LSR ab,x */ + ZPAGE_X; + LSR_ZP; + break; + case 0x58: /* CLI */ + vdi &= V_FLAG | D_FLAG; + CHECK_IRQ; + break; + case 0x59: /* EOR abcd,y */ + ABSOLUTE_Y; + NCYCLES_Y; + EOR; + break; + case 0x5d: /* EOR abcd,x */ + ABSOLUTE_X; + NCYCLES_X; + EOR; + break; + case 0x5e: /* LSR abcd,x */ + ABSOLUTE_X; + LSR; + break; + case 0x60: /* RTS */ + PL(pc); + PL(addr); + pc += (addr << 8) + 1; + break; + case 0x61: /* ADC (ab,x) */ + INDIRECT_X; + ADC; + break; + case 0x65: /* ADC ab */ + ZPAGE; + ADC_ZP; + break; + case 0x66: /* ROR ab */ + ZPAGE; + ROR_ZP; + break; + case 0x68: /* PLA */ + PL(a); + nz = a; + break; + case 0x69: /* ADC #ab */ + data = FETCH; + DO_ADC; + break; + case 0x6a: /* ROR */ + nz = (c << 7) + (a >> 1); + c = a & 1; + a = nz; + break; + case 0x6c: /* JMP (abcd) */ + ABSOLUTE; + if ((addr & 0xff) == 0xff) + pc = (dGetByte(addr - 0xff) << 8) + dGetByte(addr); + else + pc = dGetWord(addr); + break; + case 0x6d: /* ADC abcd */ + ABSOLUTE; + ADC; + break; + case 0x6e: /* ROR abcd */ + ABSOLUTE; + ROR; + break; + case 0x70: /* BVS */ + BRANCH((vdi & V_FLAG) != 0); + case 0x71: /* ADC (ab),y */ + INDIRECT_Y; + NCYCLES_Y; + ADC; + break; + case 0x75: /* ADC ab,x */ + ZPAGE_X; + ADC_ZP; + break; + case 0x76: /* ROR ab,x */ + ZPAGE_X; + ROR_ZP; + break; + case 0x78: /* SEI */ + vdi |= I_FLAG; + break; + case 0x79: /* ADC abcd,y */ + ABSOLUTE_Y; + NCYCLES_Y; + ADC; + break; + case 0x7d: /* ADC abcd,x */ + ABSOLUTE_X; + NCYCLES_X; + ADC; + break; + case 0x7e: /* ROR abcd,x */ + ABSOLUTE_X; + ROR; + break; + case 0x81: /* STA (ab,x) */ + INDIRECT_X; + STA; + break; + case 0x84: /* STY ab */ + ZPAGE; + STY_ZP; + break; + case 0x85: /* STA ab */ + ZPAGE; + STA_ZP; + break; + case 0x86: /* STX ab */ + ZPAGE; + STX_ZP; + break; + case 0x88: /* DEY */ + nz = y = (y - 1) & 0xff; + break; + case 0x8a: /* TXA */ + nz = a = x; + break; + case 0x8c: /* STY abcd */ + ABSOLUTE; + STY; + break; + case 0x8d: /* STA abcd */ + ABSOLUTE; + STA; + break; + case 0x8e: /* STX abcd */ + ABSOLUTE; + STX; + break; + case 0x90: /* BCC */ + BRANCH(c == 0); + case 0x91: /* STA (ab),y */ + INDIRECT_Y; + STA; + break; + case 0x94: /* STY ab,x */ + ZPAGE_X; + STY_ZP; + break; + case 0x95: /* STA ab,x */ + ZPAGE_X; + STA_ZP; + break; + case 0x96: /* STX ab,y */ + ZPAGE_Y; + STX_ZP; + break; + case 0x98: /* TYA */ + nz = a = y; + break; + case 0x99: /* STA abcd,y */ + ABSOLUTE_Y; + STA; + break; + case 0x9a: /* TXS */ + s = x; + break; + case 0x9d: /* STA abcd,x */ + ABSOLUTE_X; + STA; + break; + case 0xa0: /* LDY #ab */ + nz = y = FETCH; + break; + case 0xa1: /* LDA (ab,x) */ + INDIRECT_X; + LDA; + break; + case 0xa2: /* LDX #ab */ + nz = x = FETCH; + break; + case 0xa4: /* LDY ab */ + ZPAGE; + LDY_ZP; + break; + case 0xa5: /* LDA ab */ + ZPAGE; + LDA_ZP; + break; + case 0xa6: /* LDX ab */ + ZPAGE; + LDX_ZP; + break; + case 0xa8: /* TAY */ + nz = y = a; + break; + case 0xa9: /* LDA #ab */ + nz = a = FETCH; + break; + case 0xaa: /* TAX */ + nz = x = a; + break; + case 0xac: /* LDY abcd */ + ABSOLUTE; + LDY; + break; + case 0xad: /* LDA abcd */ + ABSOLUTE; + LDA; + break; + case 0xae: /* LDX abcd */ + ABSOLUTE; + LDX; + break; + case 0xb0: /* BCS */ + BRANCH(c != 0); + case 0xb1: /* LDA (ab),y */ + INDIRECT_Y; + NCYCLES_Y; + LDA; + break; + case 0xb4: /* LDY ab,x */ + ZPAGE_X; + LDY_ZP; + break; + case 0xb5: /* LDA ab,x */ + ZPAGE_X; + LDA_ZP; + break; + case 0xb6: /* LDX ab,y */ + ZPAGE_Y; + LDX_ZP; + break; + case 0xb8: /* CLV */ + vdi &= D_FLAG | I_FLAG; + break; + case 0xb9: /* LDA abcd,y */ + ABSOLUTE_Y; + NCYCLES_Y; + LDA; + break; + case 0xba: /* TSX */ + nz = x = s; + break; + case 0xbc: /* LDY abcd,x */ + ABSOLUTE_X; + NCYCLES_X; + LDY; + break; + case 0xbd: /* LDA abcd,x */ + ABSOLUTE_X; + NCYCLES_X; + LDA; + break; + case 0xbe: /* LDX abcd,y */ + ABSOLUTE_Y; + NCYCLES_Y; + LDX; + break; + case 0xc0: /* CPY #ab */ + nz = FETCH; + c = (y >= nz) ? 1 : 0; + nz = (y - nz) & 0xff; + break; + case 0xc1: /* CMP (ab,x) */ + INDIRECT_X; + CMP; + break; + case 0xc4: /* CPY ab */ + ZPAGE; + CPY_ZP; + break; + case 0xc5: /* CMP ab */ + ZPAGE; + CMP_ZP; + break; + case 0xc6: /* DEC ab */ + ZPAGE; + DEC_ZP; + break; + case 0xc8: /* INY */ + nz = y = (y + 1) & 0xff; + break; + case 0xc9: /* CMP #ab */ + nz = FETCH; + c = (a >= nz) ? 1 : 0; + nz = (a - nz) & 0xff; + break; + case 0xca: /* DEX */ + nz = x = (x - 1) & 0xff; + break; + case 0xcc: /* CPY abcd */ + ABSOLUTE; + CPY; + break; + case 0xcd: /* CMP abcd */ + ABSOLUTE; + CMP; + break; + case 0xce: /* DEC abcd */ + ABSOLUTE; + DEC; + break; + case 0xd0: /* BNE */ + BRANCH((nz & 0xff) != 0); + case 0xd1: /* CMP (ab),y */ + INDIRECT_Y; + NCYCLES_Y; + CMP; + break; + case 0xd5: /* CMP ab,x */ + ZPAGE_X; + CMP_ZP; + break; + case 0xd6: /* DEC ab,x */ + ZPAGE_X; + DEC_ZP; + break; + case 0xd8: /* CLD */ + vdi &= V_FLAG | I_FLAG; + break; + case 0xd9: /* CMP abcd,y */ + ABSOLUTE_Y; + NCYCLES_Y; + CMP; + break; + case 0xdd: /* CMP abcd,x */ + ABSOLUTE_X; + NCYCLES_X; + CMP; + break; + case 0xde: /* DEC abcd,x */ + ABSOLUTE_X; + DEC; + break; + case 0xe0: /* CPX #ab */ + nz = FETCH; + c = (x >= nz) ? 1 : 0; + nz = (x - nz) & 0xff; + break; + case 0xe1: /* SBC (ab,x) */ + INDIRECT_X; + SBC; + break; + case 0xe4: /* CPX ab */ + ZPAGE; + CPX_ZP; + break; + case 0xe5: /* SBC ab */ + ZPAGE; + SBC_ZP; + break; + case 0xe6: /* INC ab */ + ZPAGE; + INC_ZP; + break; + case 0xe8: /* INX */ + nz = x = (x + 1) & 0xff; + break; + case 0xe9: /* SBC #ab */ + case 0xeb: /* SBC #ab [unofficial] */ + data = FETCH; + DO_SBC; + break; + case 0xea: /* NOP */ + case 0x1a: /* NOP [unofficial] */ + case 0x3a: + case 0x5a: + case 0x7a: + case 0xda: + case 0xfa: + break; + case 0xec: /* CPX abcd */ + ABSOLUTE; + CPX; + break; + case 0xed: /* SBC abcd */ + ABSOLUTE; + SBC; + break; + case 0xee: /* INC abcd */ + ABSOLUTE; + INC; + break; + case 0xf0: /* BEQ */ + BRANCH((nz & 0xff) == 0); + case 0xf1: /* SBC (ab),y */ + INDIRECT_Y; + NCYCLES_Y; + SBC; + break; + case 0xf5: /* SBC ab,x */ + ZPAGE_X; + SBC_ZP; + break; + case 0xf6: /* INC ab,x */ + ZPAGE_X; + INC_ZP; + break; + case 0xf8: /* SED */ + vdi |= D_FLAG; + break; + case 0xf9: /* SBC abcd,y */ + ABSOLUTE_Y; + NCYCLES_Y; + SBC; + break; + case 0xfd: /* SBC abcd,x */ + ABSOLUTE_X; + NCYCLES_X; + SBC; + break; + case 0xfe: /* INC abcd,x */ + ABSOLUTE_X; + INC; + break; + } + } + ast _ cpu_pc = pc; + ast _ cpu_nz = nz; + ast _ cpu_a = a; + ast _ cpu_x = x; + ast _ cpu_y = y; + ast _ cpu_c = c; + ast _ cpu_s = s; + ast _ cpu_vdi = vdi; + ast _ cycle -= cycle_limit; + if (ast _ timer1_cycle != NEVER) + ast _ timer1_cycle -= cycle_limit; + if (ast _ timer2_cycle != NEVER) + ast _ timer2_cycle -= cycle_limit; + if (ast _ timer4_cycle != NEVER) + ast _ timer4_cycle -= cycle_limit; +} diff --git a/lib/rbcodec/codecs/libasap/anylang.h b/lib/rbcodec/codecs/libasap/anylang.h new file mode 100644 index 0000000000..e56dfbae0e --- /dev/null +++ b/lib/rbcodec/codecs/libasap/anylang.h @@ -0,0 +1,218 @@ +/* + * anylang.h - C/Java/C#/JavaScript/ActionScript abstraction layer + * + * Copyright (C) 2007-2010 Piotr Fusik + * + * This file is part of ASAP (Another Slight Atari Player), + * see http://asap.sourceforge.net + * + * ASAP is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published + * by the Free Software Foundation; either version 2 of the License, + * or (at your option) any later version. + * + * ASAP is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with ASAP; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef _ANYLANG_H_ +#define _ANYLANG_H_ + +#if defined(JAVA) || defined(CSHARP) || defined(JAVASCRIPT) || defined(ACTIONSCRIPT) + +#define FALSE false +#define TRUE true +#define NULL null +#define _ . +#define PRIVATE +#define CONST +#define OUT_STRING STRING + +#else + +#define C +#include + +#define PRIVATE static +#define FUNC(type, name, pars) type name pars +#define P(type, name) type name +#define V(type, name) type name +#define CONST const +#define _ -> +#define PTR * +#define ADDRESSOF & +#define CAST(type) (type) +#define TO_INT(x) (int) (x) +#define TO_BYTE(x) (byte) (x) +#define BYTEARRAY byte * +#define BOOLARRAY abool * +#define VOIDPTR void * +#define UBYTE(data) (data) +#define SBYTE(data) (signed char) (data) +#define CONST_ARRAY(type, name) static const type name[] = { +#define END_CONST_ARRAY } +#define ZERO_ARRAY(array) memset(array, 0, sizeof(array)) +#define COPY_ARRAY(dest, dest_offset, src, src_offset, len) \ + memcpy(dest + dest_offset, src + src_offset, len) +#define NEW_ARRAY(type, name, size) \ + type name[size] +#define INIT_ARRAY(array) memset(array, 0, sizeof(array)) +#define STRING const char * +#define OUT_STRING char * +#define CHARAT(s, i) (s)[i] +#define CHARCODEAT(s, i) (s)[i] +#define CHARCODE(c) (c) +#define EQUAL_STRINGS(s1, s2) (strcmp(s1, s2) == 0) +#define EMPTY_STRING(s) (s)[0] = '\0' +#define SUBSTR(s, i) (s + i) +#define BYTES_TO_STRING(dest, src, src_offset, len) \ + do { memcpy(dest, src + src_offset, len); (dest)[len] = '\0'; } while (FALSE) +#define SUBSTRING(dest, src, src_offset, len) \ + do { memcpy(dest, src + src_offset, len); (dest)[len] = '\0'; } while (FALSE) + +#define RESOURCE const byte * +#define GET_RESOURCE(name, ext) name##_##ext + +#endif /* defined(JAVA) || defined(CSHARP) || defined(JAVASCRIPT) || defined(ACTIONSCRIPT) */ + +#ifdef JAVA + +#define abool boolean +#define FUNC(type, name, pars) private static type name pars +#define P(type, name) type name +#define V(type, name) type name +#define PTR +#define ADDRESSOF +#define CAST(type) (type) +#define TO_INT(x) (int) (x) +#define TO_BYTE(x) (byte) (x) +#define BYTEARRAY byte[] +#define BOOLARRAY boolean[] +#define VOIDPTR byte[] +#define UBYTE(data) ((data) & 0xff) +#define SBYTE(data) (byte) (data) +#define CONST_ARRAY(type, name) private static final type[] name = { +#define END_CONST_ARRAY } +#define sizeof(array) array.length +#define ZERO_ARRAY(array) for (int ii = 0; ii < array.length; ii++) array[ii] = 0 +#define COPY_ARRAY(dest, dest_offset, src, src_offset, len) \ + System.arraycopy(src, src_offset, dest, dest_offset, len) +#define NEW_ARRAY(type, name, size) \ + type[] name = new type[size] +#define INIT_ARRAY(array) +#define STRING String +#define CHARAT(s, i) (s).charAt(i) +#define CHARCODEAT(s, i) (s).charAt(i) +#define CHARCODE(c) (c) +#define strlen(s) (s).length() +#define EQUAL_STRINGS(s1, s2) (s1).equals(s2) +#define EMPTY_STRING(s) (s) = "" +#define SUBSTR(s, i) (s).substring(i) +#define BYTES_TO_STRING(dest, src, src_offset, len) \ + (dest) = new String(src, src_offset, len) +#define SUBSTRING(dest, src, src_offset, len) \ + (dest) = (src).substring(src_offset, src_offset + len) + +#define RESOURCE byte[] +#define GET_RESOURCE(name, ext) getResourceBytes(#name + "." + #ext) + +#elif defined(CSHARP) + +#define abool bool +#define FUNC(type, name, pars) private static type name pars +#define P(type, name) type name +#define V(type, name) type name +#define PTR +#define ADDRESSOF +#define CAST(type) (type) +#define TO_INT(x) (int) (x) +#define TO_BYTE(x) (byte) (x) +#define BYTEARRAY byte[] +#define BOOLARRAY bool[] +#define VOIDPTR byte[] +#define UBYTE(data) (data) +#define SBYTE(data) (sbyte) (data) +#define CONST_ARRAY(type, name) private static readonly type[] name = { +#define END_CONST_ARRAY } +#define sizeof(array) array.Length +#define ZERO_ARRAY(array) Array.Clear(array, 0, array.Length) +#define COPY_ARRAY(dest, dest_offset, src, src_offset, len) \ + Array.Copy(src, src_offset, dest, dest_offset, len) +#define NEW_ARRAY(type, name, size) \ + type[] name = new type[size] +#define INIT_ARRAY(array) +#define STRING string +#define CHARAT(s, i) (s)[i] +#define CHARCODEAT(s, i) (s)[i] +#define CHARCODE(c) (c) +#define strlen(s) (s).Length +#define EQUAL_STRINGS(s1, s2) ((s1) == (s2)) +#define EMPTY_STRING(s) (s) = string.Empty +#define SUBSTR(s, i) (s).Substring(i) +#define BYTES_TO_STRING(dest, src, src_offset, len) \ + (dest) = System.Text.Encoding.UTF8.GetString(src, src_offset, len) +#define SUBSTRING(dest, src, src_offset, len) \ + (dest) = (src).Substring(src_offset, len) + +#define RESOURCE byte[] +#define GET_RESOURCE(name, ext) name##_##ext + +#elif defined(JAVASCRIPT) || defined(ACTIONSCRIPT) + +#ifdef ACTIONSCRIPT +#define abool Boolean +#define char String +#define STRING String +#define BYTEARRAY ByteArray +#define BOOLARRAY Array +#define VOIDPTR ByteArray +#define RESOURCE Array +#define FUNC(type, name, pars) private static function name pars : type +#define P(type, name) name : type +#define V(type, name) var name : type +#define TO_INT(x) int(x) +#define CONST_ARRAY(type, name) private static const name : Array = [ +#else +#define FUNC(type, name, pars) function name pars +#define P(type, name) name +#define V(type, name) var name +#define TO_INT(x) Math.floor(x) +#define CONST_ARRAY(type, name) var name = [ +#endif +#define PTR +#define ADDRESSOF +#define CAST(type) +#define TO_BYTE(x) ((x) & 0xff) +#define UBYTE(data) (data) +#define SBYTE(data) ((data) < 0x80 ? (data) : (data) - 256) +#define END_CONST_ARRAY ] +#define sizeof(array) array.length +#define ZERO_ARRAY(array) for (V(int, ii) = 0; ii < array.length; ii++) array[ii] = 0 +#define COPY_ARRAY(dest, dest_offset, src, src_offset, len) \ + for (V(int, ii) = 0; ii < len; ii++) dest[dest_offset + ii] = src[src_offset + ii] +#define NEW_ARRAY(type, name, size) \ + V(Array, name) = new Array(size) +#define INIT_ARRAY(array) for (V(int, ii) = 0; ii < array.length; ii++) array[ii] = 0 +#define CHARAT(s, i) (s).charAt(i) +#define CHARCODEAT(s, i) (s).charCodeAt(i) +#define CHARCODE(c) (c).charCodeAt(0) +#define strlen(s) (s).length +#define EQUAL_STRINGS(s1, s2) ((s1) == (s2)) +#define EMPTY_STRING(s) s = "" +#define SUBSTR(s, i) (s).substr(i) +#define BYTES_TO_STRING(dest, src, src_offset, len) \ + { dest = ""; for (V(int, ii) = 0; ii < len; ii++) dest += String.fromCharCode(src[src_offset + ii]); } +#define SUBSTRING(dest, src, src_offset, len) \ + dest = (src).substring(src_offset, src_offset + len) + +#define GET_RESOURCE(name, ext) name##_##ext + +#endif + +#endif /* _ANYLANG_H_ */ diff --git a/lib/rbcodec/codecs/libasap/apokeysnd.c b/lib/rbcodec/codecs/libasap/apokeysnd.c new file mode 100644 index 0000000000..811e2f9b4a --- /dev/null +++ b/lib/rbcodec/codecs/libasap/apokeysnd.c @@ -0,0 +1,599 @@ +/* + * apokeysnd.c - another POKEY sound emulator + * + * Copyright (C) 2007-2010 Piotr Fusik + * + * This file is part of ASAP (Another Slight Atari Player), + * see http://asap.sourceforge.net + * + * ASAP is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published + * by the Free Software Foundation; either version 2 of the License, + * or (at your option) any later version. + * + * ASAP is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with ASAP; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "asap_internal.h" + +#define ULTRASOUND_CYCLES 112 + +#define MUTE_FREQUENCY 1 +#define MUTE_INIT 2 +#define MUTE_USER 4 + +CONST_ARRAY(byte, poly4_lookup) + 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1 +END_CONST_ARRAY; +CONST_ARRAY(byte, poly5_lookup) + 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, + 0, 1, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1 +END_CONST_ARRAY; + +PRIVATE FUNC(void, PokeySound_InitializeChip, (P(PokeyState PTR, pst))) +{ + pst _ audctl = 0; + pst _ init = FALSE; + pst _ poly_index = 15 * 31 * 131071; + pst _ div_cycles = 28; + pst _ mute1 = MUTE_FREQUENCY | MUTE_USER; + pst _ mute2 = MUTE_FREQUENCY | MUTE_USER; + pst _ mute3 = MUTE_FREQUENCY | MUTE_USER; + pst _ mute4 = MUTE_FREQUENCY | MUTE_USER; + pst _ audf1 = 0; + pst _ audf2 = 0; + pst _ audf3 = 0; + pst _ audf4 = 0; + pst _ audc1 = 0; + pst _ audc2 = 0; + pst _ audc3 = 0; + pst _ audc4 = 0; + pst _ tick_cycle1 = NEVER; + pst _ tick_cycle2 = NEVER; + pst _ tick_cycle3 = NEVER; + pst _ tick_cycle4 = NEVER; + pst _ period_cycles1 = 28; + pst _ period_cycles2 = 28; + pst _ period_cycles3 = 28; + pst _ period_cycles4 = 28; + pst _ reload_cycles1 = 28; + pst _ reload_cycles3 = 28; + pst _ out1 = 0; + pst _ out2 = 0; + pst _ out3 = 0; + pst _ out4 = 0; + pst _ delta1 = 0; + pst _ delta2 = 0; + pst _ delta3 = 0; + pst _ delta4 = 0; + pst _ skctl = 3; + ZERO_ARRAY(pst _ delta_buffer); +} + +FUNC(void, PokeySound_Initialize, (P(ASAP_State PTR, ast))) +{ + V(int, i); + V(int, reg); + reg = 0x1ff; + for (i = 0; i < 511; i++) { + reg = ((((reg >> 5) ^ reg) & 1) << 8) + (reg >> 1); + ast _ poly9_lookup[i] = TO_BYTE(reg); + } + reg = 0x1ffff; + for (i = 0; i < 16385; i++) { + reg = ((((reg >> 5) ^ reg) & 0xff) << 9) + (reg >> 8); + ast _ poly17_lookup[i] = TO_BYTE(reg >> 1); + } + ast _ sample_offset = 0; + ast _ sample_index = 0; + ast _ samples = 0; + ast _ iir_acc_left = 0; + ast _ iir_acc_right = 0; + PokeySound_InitializeChip(ADDRESSOF ast _ base_pokey); + PokeySound_InitializeChip(ADDRESSOF ast _ extra_pokey); +} + +#define DO_TICK(ch) \ + if (pst _ init) { \ + switch (pst _ audc##ch >> 4) { \ + case 10: \ + case 14: \ + pst _ out##ch ^= 1; \ + pst _ delta_buffer[CYCLE_TO_SAMPLE(cycle)] += pst _ delta##ch = -pst _ delta##ch; \ + break; \ + default: \ + break; \ + } \ + } \ + else { \ + V(int, poly) = cycle + pst _ poly_index - (ch - 1); \ + V(int, newout) = pst _ out##ch; \ + switch (pst _ audc##ch >> 4) { \ + case 0: \ + if (poly5_lookup[poly % 31] != 0) { \ + if ((pst _ audctl & 0x80) != 0) \ + newout = ast _ poly9_lookup[poly % 511] & 1; \ + else { \ + poly %= 131071; \ + newout = (ast _ poly17_lookup[poly >> 3] >> (poly & 7)) & 1; \ + } \ + } \ + break; \ + case 2: \ + case 6: \ + newout ^= poly5_lookup[poly % 31]; \ + break; \ + case 4: \ + if (poly5_lookup[poly % 31] != 0) \ + newout = poly4_lookup[poly % 15]; \ + break; \ + case 8: \ + if ((pst _ audctl & 0x80) != 0) \ + newout = ast _ poly9_lookup[poly % 511] & 1; \ + else { \ + poly %= 131071; \ + newout = (ast _ poly17_lookup[poly >> 3] >> (poly & 7)) & 1; \ + } \ + break; \ + case 10: \ + case 14: \ + newout ^= 1; \ + break; \ + case 12: \ + newout = poly4_lookup[poly % 15]; \ + break; \ + default: \ + break; \ + } \ + if (newout != pst _ out##ch) { \ + pst _ out##ch = newout; \ + pst _ delta_buffer[CYCLE_TO_SAMPLE(cycle)] += pst _ delta##ch = -pst _ delta##ch; \ + } \ + } + +/* Fills delta_buffer up to current_cycle basing on current AUDF/AUDC/AUDCTL values. */ +PRIVATE FUNC(void, PokeySound_GenerateUntilCycle, (P(ASAP_State PTR, ast), P(PokeyState PTR, pst), P(int, current_cycle))) +{ + for (;;) { + V(int, cycle) = current_cycle; + if (cycle > pst _ tick_cycle1) + cycle = pst _ tick_cycle1; + if (cycle > pst _ tick_cycle2) + cycle = pst _ tick_cycle2; + if (cycle > pst _ tick_cycle3) + cycle = pst _ tick_cycle3; + if (cycle > pst _ tick_cycle4) + cycle = pst _ tick_cycle4; + if (cycle == current_cycle) + break; + if (cycle == pst _ tick_cycle3) { + pst _ tick_cycle3 += pst _ period_cycles3; + if ((pst _ audctl & 4) != 0 && pst _ delta1 > 0 && pst _ mute1 == 0) + pst _ delta_buffer[CYCLE_TO_SAMPLE(cycle)] += pst _ delta1 = -pst _ delta1; + DO_TICK(3); + } + if (cycle == pst _ tick_cycle4) { + pst _ tick_cycle4 += pst _ period_cycles4; + if ((pst _ audctl & 8) != 0) + pst _ tick_cycle3 = cycle + pst _ reload_cycles3; + if ((pst _ audctl & 2) != 0 && pst _ delta2 > 0 && pst _ mute2 == 0) + pst _ delta_buffer[CYCLE_TO_SAMPLE(cycle)] += pst _ delta2 = -pst _ delta2; + DO_TICK(4); + } + if (cycle == pst _ tick_cycle1) { + pst _ tick_cycle1 += pst _ period_cycles1; + if ((pst _ skctl & 0x88) == 8) /* two-tone, sending 1 (i.e. timer1) */ + pst _ tick_cycle2 = cycle + pst _ period_cycles2; + DO_TICK(1); + } + if (cycle == pst _ tick_cycle2) { + pst _ tick_cycle2 += pst _ period_cycles2; + if ((pst _ audctl & 0x10) != 0) + pst _ tick_cycle1 = cycle + pst _ reload_cycles1; + else if ((pst _ skctl & 8) != 0) /* two-tone */ + pst _ tick_cycle1 = cycle + pst _ period_cycles1; + DO_TICK(2); + } + } +} + +#ifdef APOKEYSND + +#define CURRENT_CYCLE 0 +#define CURRENT_SAMPLE 0 +#define DO_STORE(reg) \ + if (data == pst _ reg) \ + break; \ + pst _ reg = data; + +#else + +#define CURRENT_CYCLE ast _ cycle +#define CURRENT_SAMPLE CYCLE_TO_SAMPLE(ast _ cycle) +#define DO_STORE(reg) \ + if (data == pst _ reg) \ + break; \ + PokeySound_GenerateUntilCycle(ast, pst, ast _ cycle); \ + pst _ reg = data; + +#endif /* APOKEYSND */ + +#define MUTE_CHANNEL(ch, cond, mask) \ + if (cond) { \ + pst _ mute##ch |= mask; \ + pst _ tick_cycle##ch = NEVER; \ + } \ + else { \ + pst _ mute##ch &= ~mask; \ + if (pst _ tick_cycle##ch == NEVER && pst _ mute##ch == 0) \ + pst _ tick_cycle##ch = CURRENT_CYCLE; \ + } + +#define DO_ULTRASOUND(ch) \ + MUTE_CHANNEL(ch, pst _ period_cycles##ch <= ULTRASOUND_CYCLES && (pst _ audc##ch >> 4 == 10 || pst _ audc##ch >> 4 == 14), MUTE_FREQUENCY) + +#define DO_AUDC(ch) \ + DO_STORE(audc##ch); \ + if ((data & 0x10) != 0) { \ + data = (data & 0xf) << DELTA_SHIFT_POKEY; \ + if ((pst _ mute##ch & MUTE_USER) == 0) \ + pst _ delta_buffer[CURRENT_SAMPLE] \ + += pst _ delta##ch > 0 ? data - pst _ delta##ch : data; \ + pst _ delta##ch = data; \ + } \ + else { \ + data = (data & 0xf) << DELTA_SHIFT_POKEY; \ + DO_ULTRASOUND(ch); \ + if (pst _ delta##ch > 0) { \ + if ((pst _ mute##ch & MUTE_USER) == 0) \ + pst _ delta_buffer[CURRENT_SAMPLE] \ + += data - pst _ delta##ch; \ + pst _ delta##ch = data; \ + } \ + else \ + pst _ delta##ch = -data; \ + } \ + break; + +#define DO_INIT(ch, cond) \ + MUTE_CHANNEL(ch, pst _ init && cond, MUTE_INIT) + +FUNC(void, PokeySound_PutByte, (P(ASAP_State PTR, ast), P(int, addr), P(int, data))) +{ + V(PokeyState PTR, pst) = (addr & ast _ extra_pokey_mask) != 0 + ? ADDRESSOF ast _ extra_pokey : ADDRESSOF ast _ base_pokey; + switch (addr & 0xf) { + case 0x00: + DO_STORE(audf1); + switch (pst _ audctl & 0x50) { + case 0x00: + pst _ period_cycles1 = pst _ div_cycles * (data + 1); + break; + case 0x10: + pst _ period_cycles2 = pst _ div_cycles * (data + 256 * pst _ audf2 + 1); + pst _ reload_cycles1 = pst _ div_cycles * (data + 1); + DO_ULTRASOUND(2); + break; + case 0x40: + pst _ period_cycles1 = data + 4; + break; + case 0x50: + pst _ period_cycles2 = data + 256 * pst _ audf2 + 7; + pst _ reload_cycles1 = data + 4; + DO_ULTRASOUND(2); + break; + } + DO_ULTRASOUND(1); + break; + case 0x01: + DO_AUDC(1) + case 0x02: + DO_STORE(audf2); + switch (pst _ audctl & 0x50) { + case 0x00: + case 0x40: + pst _ period_cycles2 = pst _ div_cycles * (data + 1); + break; + case 0x10: + pst _ period_cycles2 = pst _ div_cycles * (pst _ audf1 + 256 * data + 1); + break; + case 0x50: + pst _ period_cycles2 = pst _ audf1 + 256 * data + 7; + break; + } + DO_ULTRASOUND(2); + break; + case 0x03: + DO_AUDC(2) + case 0x04: + DO_STORE(audf3); + switch (pst _ audctl & 0x28) { + case 0x00: + pst _ period_cycles3 = pst _ div_cycles * (data + 1); + break; + case 0x08: + pst _ period_cycles4 = pst _ div_cycles * (data + 256 * pst _ audf4 + 1); + pst _ reload_cycles3 = pst _ div_cycles * (data + 1); + DO_ULTRASOUND(4); + break; + case 0x20: + pst _ period_cycles3 = data + 4; + break; + case 0x28: + pst _ period_cycles4 = data + 256 * pst _ audf4 + 7; + pst _ reload_cycles3 = data + 4; + DO_ULTRASOUND(4); + break; + } + DO_ULTRASOUND(3); + break; + case 0x05: + DO_AUDC(3) + case 0x06: + DO_STORE(audf4); + switch (pst _ audctl & 0x28) { + case 0x00: + case 0x20: + pst _ period_cycles4 = pst _ div_cycles * (data + 1); + break; + case 0x08: + pst _ period_cycles4 = pst _ div_cycles * (pst _ audf3 + 256 * data + 1); + break; + case 0x28: + pst _ period_cycles4 = pst _ audf3 + 256 * data + 7; + break; + } + DO_ULTRASOUND(4); + break; + case 0x07: + DO_AUDC(4) + case 0x08: + DO_STORE(audctl); + pst _ div_cycles = ((data & 1) != 0) ? 114 : 28; + /* TODO: tick_cycles */ + switch (data & 0x50) { + case 0x00: + pst _ period_cycles1 = pst _ div_cycles * (pst _ audf1 + 1); + pst _ period_cycles2 = pst _ div_cycles * (pst _ audf2 + 1); + break; + case 0x10: + pst _ period_cycles1 = pst _ div_cycles * 256; + pst _ period_cycles2 = pst _ div_cycles * (pst _ audf1 + 256 * pst _ audf2 + 1); + pst _ reload_cycles1 = pst _ div_cycles * (pst _ audf1 + 1); + break; + case 0x40: + pst _ period_cycles1 = pst _ audf1 + 4; + pst _ period_cycles2 = pst _ div_cycles * (pst _ audf2 + 1); + break; + case 0x50: + pst _ period_cycles1 = 256; + pst _ period_cycles2 = pst _ audf1 + 256 * pst _ audf2 + 7; + pst _ reload_cycles1 = pst _ audf1 + 4; + break; + } + DO_ULTRASOUND(1); + DO_ULTRASOUND(2); + switch (data & 0x28) { + case 0x00: + pst _ period_cycles3 = pst _ div_cycles * (pst _ audf3 + 1); + pst _ period_cycles4 = pst _ div_cycles * (pst _ audf4 + 1); + break; + case 0x08: + pst _ period_cycles3 = pst _ div_cycles * 256; + pst _ period_cycles4 = pst _ div_cycles * (pst _ audf3 + 256 * pst _ audf4 + 1); + pst _ reload_cycles3 = pst _ div_cycles * (pst _ audf3 + 1); + break; + case 0x20: + pst _ period_cycles3 = pst _ audf3 + 4; + pst _ period_cycles4 = pst _ div_cycles * (pst _ audf4 + 1); + break; + case 0x28: + pst _ period_cycles3 = 256; + pst _ period_cycles4 = pst _ audf3 + 256 * pst _ audf4 + 7; + pst _ reload_cycles3 = pst _ audf3 + 4; + break; + } + DO_ULTRASOUND(3); + DO_ULTRASOUND(4); + DO_INIT(1, (data & 0x40) == 0); + DO_INIT(2, (data & 0x50) != 0x50); + DO_INIT(3, (data & 0x20) == 0); + DO_INIT(4, (data & 0x28) != 0x28); + break; + case 0x09: + /* TODO: STIMER */ + break; + case 0x0f: + DO_STORE(skctl); + pst _ init = ((data & 3) == 0); + DO_INIT(1, (pst _ audctl & 0x40) == 0); + DO_INIT(2, (pst _ audctl & 0x50) != 0x50); + DO_INIT(3, (pst _ audctl & 0x20) == 0); + DO_INIT(4, (pst _ audctl & 0x28) != 0x28); + break; + default: + break; + } +} + +FUNC(int, PokeySound_GetRandom, (P(ASAP_State PTR, ast), P(int, addr), P(int, cycle))) +{ + V(PokeyState PTR, pst) = (addr & ast _ extra_pokey_mask) != 0 + ? ADDRESSOF ast _ extra_pokey : ADDRESSOF ast _ base_pokey; + V(int, i); + if (pst _ init) + return 0xff; + i = cycle + pst _ poly_index; + if ((pst _ audctl & 0x80) != 0) + return ast _ poly9_lookup[i % 511]; + else { + V(int, j); + i %= 131071; + j = i >> 3; + i &= 7; + return ((ast _ poly17_lookup[j] >> i) + (ast _ poly17_lookup[j + 1] << (8 - i))) & 0xff; + } +} + +PRIVATE FUNC(void, end_frame, (P(ASAP_State PTR, ast), P(PokeyState PTR, pst), P(int, cycle_limit))) +{ + V(int, m); + PokeySound_GenerateUntilCycle(ast, pst, cycle_limit); + pst _ poly_index += cycle_limit; + m = ((pst _ audctl & 0x80) != 0) ? 15 * 31 * 511 : 15 * 31 * 131071; + if (pst _ poly_index >= 2 * m) + pst _ poly_index -= m; + if (pst _ tick_cycle1 != NEVER) + pst _ tick_cycle1 -= cycle_limit; + if (pst _ tick_cycle2 != NEVER) + pst _ tick_cycle2 -= cycle_limit; + if (pst _ tick_cycle3 != NEVER) + pst _ tick_cycle3 -= cycle_limit; + if (pst _ tick_cycle4 != NEVER) + pst _ tick_cycle4 -= cycle_limit; +} + +FUNC(void, PokeySound_StartFrame, (P(ASAP_State PTR, ast))) +{ + ZERO_ARRAY(ast _ base_pokey.delta_buffer); + if (ast _ extra_pokey_mask != 0) + ZERO_ARRAY(ast _ extra_pokey.delta_buffer); +} + +FUNC(void, PokeySound_EndFrame, (P(ASAP_State PTR, ast), P(int, current_cycle))) +{ + V(int, clk) = ASAP_MAIN_CLOCK(ast); + end_frame(ast, ADDRESSOF ast _ base_pokey, current_cycle); + if (ast _ extra_pokey_mask != 0) + end_frame(ast, ADDRESSOF ast _ extra_pokey, current_cycle); + ast _ sample_offset += current_cycle * ASAP_SAMPLE_RATE; + ast _ sample_index = 0; + ast _ samples = TO_INT(ast _ sample_offset / clk); + ast _ sample_offset %= clk; +} + +/* Fills buffer with samples from delta_buffer. */ +FUNC(int, PokeySound_Generate, (P(ASAP_State PTR, ast), P(BYTEARRAY, buffer), P(int, buffer_offset), P(int, blocks), P(ASAP_SampleFormat, format))) +{ + V(int, i) = ast _ sample_index; + V(int, samples) = ast _ samples; + V(int, acc_left) = ast _ iir_acc_left; + V(int, acc_right) = ast _ iir_acc_right; + if (blocks < samples - i) + samples = i + blocks; + else + blocks = samples - i; + for (; i < samples; i++) { +#ifdef ACTIONSCRIPT + acc_left += ast _ base_pokey.delta_buffer[i] - (acc_left * 3 >> 10); + var sample : Number = acc_left / 33553408; + buffer.writeFloat(sample); + if (ast.extra_pokey_mask != 0) { + acc_right += ast _ extra_pokey.delta_buffer[i] - (acc_right * 3 >> 10); + sample = acc_right / 33553408; + } + buffer.writeFloat(sample); +#else + V(int, sample); + acc_left += ast _ base_pokey.delta_buffer[i] - (acc_left * 3 >> 10); + sample = acc_left >> 10; +#define STORE_SAMPLE \ + if (sample < -32767) \ + sample = -32767; \ + else if (sample > 32767) \ + sample = 32767; \ + switch (format) { \ + case ASAP_FORMAT_U8: \ + buffer[buffer_offset++] = CAST(byte) ((sample >> 8) + 128); \ + break; \ + case ASAP_FORMAT_S16_LE: \ + buffer[buffer_offset++] = TO_BYTE(sample); \ + buffer[buffer_offset++] = TO_BYTE(sample >> 8); \ + break; \ + case ASAP_FORMAT_S16_BE: \ + buffer[buffer_offset++] = TO_BYTE(sample >> 8); \ + buffer[buffer_offset++] = TO_BYTE(sample); \ + break; \ + } + STORE_SAMPLE; + if (ast _ extra_pokey_mask != 0) { + acc_right += ast _ extra_pokey.delta_buffer[i] - (acc_right * 3 >> 10); + sample = acc_right >> 10; + STORE_SAMPLE; + } +#endif /* ACTIONSCRIPT */ + } + if (i == ast _ samples) { + acc_left += ast _ base_pokey.delta_buffer[i]; + acc_right += ast _ extra_pokey.delta_buffer[i]; + } + ast _ sample_index = i; + ast _ iir_acc_left = acc_left; + ast _ iir_acc_right = acc_right; +#ifdef APOKEYSND + return buffer_offset; +#else + return blocks; +#endif +} + +FUNC(abool, PokeySound_IsSilent, (P(CONST PokeyState PTR, pst))) +{ + return ((pst _ audc1 | pst _ audc2 | pst _ audc3 | pst _ audc4) & 0xf) == 0; +} + +FUNC(void, PokeySound_Mute, (P(CONST ASAP_State PTR, ast), P(PokeyState PTR, pst), P(int, mask))) +{ + MUTE_CHANNEL(1, (mask & 1) != 0, MUTE_USER); + MUTE_CHANNEL(2, (mask & 2) != 0, MUTE_USER); + MUTE_CHANNEL(3, (mask & 4) != 0, MUTE_USER); + MUTE_CHANNEL(4, (mask & 8) != 0, MUTE_USER); +} + +#ifdef APOKEYSND + +static ASAP_State asap; + +__declspec(dllexport) void APokeySound_Initialize(abool stereo) +{ + asap.extra_pokey_mask = stereo ? 0x10 : 0; + PokeySound_Initialize(&asap); + PokeySound_Mute(&asap, &asap.base_pokey, 0); + PokeySound_Mute(&asap, &asap.extra_pokey, 0); + PokeySound_StartFrame(&asap); +} + +__declspec(dllexport) void APokeySound_PutByte(int addr, int data) +{ + PokeySound_PutByte(&asap, addr, data); +} + +__declspec(dllexport) int APokeySound_GetRandom(int addr, int cycle) +{ + return PokeySound_GetRandom(&asap, addr, cycle); +} + +__declspec(dllexport) int APokeySound_Generate(int cycles, byte buffer[], ASAP_SampleFormat format) +{ + int len; + PokeySound_EndFrame(&asap, cycles); + len = PokeySound_Generate(&asap, buffer, 0, asap.samples, format); + PokeySound_StartFrame(&asap); + return len; +} + +__declspec(dllexport) void APokeySound_About(const char **name, const char **author, const char **description) +{ + *name = "Another POKEY sound emulator, v" ASAP_VERSION; + *author = "Piotr Fusik, (C) " ASAP_YEARS; + *description = "Part of ASAP, http://asap.sourceforge.net"; +} + +#endif /* APOKEYSND */ diff --git a/lib/rbcodec/codecs/libasap/asap.c b/lib/rbcodec/codecs/libasap/asap.c new file mode 100644 index 0000000000..1aeb843fa3 --- /dev/null +++ b/lib/rbcodec/codecs/libasap/asap.c @@ -0,0 +1,2273 @@ +/* + * asap.c - ASAP engine + * + * Copyright (C) 2005-2010 Piotr Fusik + * + * This file is part of ASAP (Another Slight Atari Player), + * see http://asap.sourceforge.net + * + * ASAP is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published + * by the Free Software Foundation; either version 2 of the License, + * or (at your option) any later version. + * + * ASAP is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with ASAP; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "asap_internal.h" + +static byte s_memory[65536]; +static ASAP_ModuleInfo s_module_info; + +#ifdef ASAP_ONLY_INFO + +#define GET_PLAYER(name) NULL + +#else + +#define GET_PLAYER(name) GET_RESOURCE(name, obx) + +FUNC(int, ASAP_GetByte, (P(ASAP_State PTR, ast), P(int, addr))) +{ + switch (addr & 0xff1f) { + case 0xd014: + return ast _ module_info->ntsc ? 0xf : 1; + case 0xd20a: + case 0xd21a: + return PokeySound_GetRandom(ast, addr, ast _ cycle); + case 0xd20e: + return ast _ irqst; + case 0xd21e: + if (ast _ extra_pokey_mask != 0) { + /* interrupts in the extra POKEY not emulated at the moment */ + return 0xff; + } + return ast _ irqst; + case 0xd20c: + case 0xd21c: + case 0xd20f: /* just because some SAP files rely on this */ + case 0xd21f: + return 0xff; + case 0xd40b: + case 0xd41b: + return ast _ scanline_number >> 1; + default: + return dGetByte(addr); + } +} + +FUNC(void, ASAP_PutByte, (P(ASAP_State PTR, ast), P(int, addr), P(int, data))) +{ + if ((addr >> 8) == 0xd2) { + if ((addr & (ast _ extra_pokey_mask + 0xf)) == 0xe) { + ast _ irqst |= data ^ 0xff; +#define SET_TIMER_IRQ(ch) \ + if ((data & ast _ irqst & ch) != 0) { \ + if (ast _ timer##ch##_cycle == NEVER) { \ + V(int, t) = ast _ base_pokey.tick_cycle##ch; \ + while (t < ast _ cycle) \ + t += ast _ base_pokey.period_cycles##ch; \ + ast _ timer##ch##_cycle = t; \ + if (ast _ nearest_event_cycle > t) \ + ast _ nearest_event_cycle = t; \ + } \ + } \ + else \ + ast _ timer##ch##_cycle = NEVER; + SET_TIMER_IRQ(1); + SET_TIMER_IRQ(2); + SET_TIMER_IRQ(4); + } + else + PokeySound_PutByte(ast, addr, data); + } + else if ((addr & 0xff0f) == 0xd40a) { + if (ast _ cycle <= ast _ next_scanline_cycle - 8) + ast _ cycle = ast _ next_scanline_cycle - 8; + else + ast _ cycle = ast _ next_scanline_cycle + 106; + } + else if ((addr & 0xff00) == ast _ module_info->covox_addr) { + V(PokeyState PTR, pst); + addr &= 3; + if (addr == 0 || addr == 3) + pst = ADDRESSOF ast _ base_pokey; + else + pst = ADDRESSOF ast _ extra_pokey; + pst _ delta_buffer[CYCLE_TO_SAMPLE(ast _ cycle)] += (data - UBYTE(ast _ covox[addr])) << DELTA_SHIFT_COVOX; + ast _ covox[addr] = CAST(byte) (data); + } + else if ((addr & 0xff1f) == 0xd01f) { + V(int, sample) = CYCLE_TO_SAMPLE(ast _ cycle); + V(int, delta); + data &= 8; + /* NOT data - ast _ consol; reverse to the POKEY sound */ + delta = (ast _ consol - data) << DELTA_SHIFT_GTIA; + ast _ consol = data; + ast _ base_pokey.delta_buffer[sample] += delta; + ast _ extra_pokey.delta_buffer[sample] += delta; + } + else + dPutByte(addr, data); +} + +#endif /* ASAP_ONLY_INFO */ + +#define UWORD(array, index) (UBYTE(array[index]) + (UBYTE(array[(index) + 1]) << 8)) + +#ifndef ASAP_ONLY_SAP + +#ifndef ASAP_ONLY_INFO + +#ifndef JAVA +#include "players.h" +#endif + +#define CMR_BASS_TABLE_OFFSET 0x70f + +CONST_ARRAY(byte, cmr_bass_table) + 0x5C, 0x56, 0x50, 0x4D, 0x47, 0x44, 0x41, 0x3E, + 0x38, 0x35, CAST(byte) (0x88), 0x7F, 0x79, 0x73, 0x6C, 0x67, + 0x60, 0x5A, 0x55, 0x51, 0x4C, 0x48, 0x43, 0x3F, + 0x3D, 0x39, 0x34, 0x33, 0x30, 0x2D, 0x2A, 0x28, + 0x25, 0x24, 0x21, 0x1F, 0x1E +END_CONST_ARRAY; + +#endif /* ASAP_ONLY_INFO */ + +CONST_ARRAY(int, perframe2fastplay) + 312, 312 / 2, 312 / 3, 312 / 4 +END_CONST_ARRAY; + +/* Loads native module (anything except SAP) and 6502 player routine. */ +PRIVATE FUNC(abool, load_native, ( + P(ASAP_State PTR, ast), P(ASAP_ModuleInfo PTR, module_info), + P(CONST BYTEARRAY, module), P(int, module_len), P(RESOURCE, player))) +{ +#ifndef ASAP_ONLY_INFO + V(int, player_last_byte); +#endif + V(int, music_last_byte); + V(int, block_len); + if ((UBYTE(module[0]) != 0xff || UBYTE(module[1]) != 0xff) + && (module[0] != 0 || module[1] != 0)) /* some CMC and clones start with zeros */ + return FALSE; + module_info _ music = UWORD(module, 2); +#ifndef ASAP_ONLY_INFO + module_info _ player = UWORD(player, 2); + player_last_byte = UWORD(player, 4); + if (module_info _ music <= player_last_byte) + return FALSE; +#endif + music_last_byte = UWORD(module, 4); + if (module_info _ music <= 0xd7ff && music_last_byte >= 0xd000) + return FALSE; + block_len = music_last_byte + 1 - module_info _ music; + if (6 + block_len != module_len) { + V(int, info_addr); + V(int, info_len); + if (module_info _ type != ASAP_TYPE_RMT || 11 + block_len > module_len) + return FALSE; + /* allow optional info for Raster Music Tracker */ + info_addr = UWORD(module, 6 + block_len); + if (info_addr != module_info _ music + block_len) + return FALSE; + info_len = UWORD(module, 8 + block_len) + 1 - info_addr; + if (10 + block_len + info_len != module_len) + return FALSE; + } +#ifndef ASAP_ONLY_INFO + if (ast != NULL) { + COPY_ARRAY(ast _ memory, module_info _ music, module, 6, block_len); + COPY_ARRAY(ast _ memory, module_info _ player, player, 6, player_last_byte + 1 - module_info _ player); + } +#endif + return TRUE; +} + +PRIVATE FUNC(void, set_song_duration, (P(ASAP_ModuleInfo PTR, module_info), P(int, player_calls))) +{ + module_info _ durations[module_info _ songs] = TO_INT(player_calls * module_info _ fastplay * 114000.0 / 1773447); + module_info _ songs++; +} + +#define SEEN_THIS_CALL 1 +#define SEEN_BEFORE 2 +#define SEEN_REPEAT 3 + +PRIVATE FUNC(void, parse_cmc_song, (P(ASAP_ModuleInfo PTR, module_info), P(CONST BYTEARRAY, module), P(int, pos))) +{ + V(int, tempo) = UBYTE(module[0x19]); + V(int, player_calls) = 0; + V(int, rep_start_pos) = 0; + V(int, rep_end_pos) = 0; + V(int, rep_times) = 0; + NEW_ARRAY(byte, seen, 0x55); + INIT_ARRAY(seen); + while (pos >= 0 && pos < 0x55) { + V(int, p1); + V(int, p2); + V(int, p3); + if (pos == rep_end_pos && rep_times > 0) { + for (p1 = 0; p1 < 0x55; p1++) + if (seen[p1] == SEEN_THIS_CALL || seen[p1] == SEEN_REPEAT) + seen[p1] = 0; + rep_times--; + pos = rep_start_pos; + } + if (seen[pos] != 0) { + if (seen[pos] != SEEN_THIS_CALL) + module_info _ loops[module_info _ songs] = TRUE; + break; + } + seen[pos] = SEEN_THIS_CALL; + p1 = UBYTE(module[0x206 + pos]); + p2 = UBYTE(module[0x25b + pos]); + p3 = UBYTE(module[0x2b0 + pos]); + if (p1 == 0xfe || p2 == 0xfe || p3 == 0xfe) { + pos++; + continue; + } + p1 >>= 4; + if (p1 == 8) + break; + if (p1 == 9) { + pos = p2; + continue; + } + if (p1 == 0xa) { + pos -= p2; + continue; + } + if (p1 == 0xb) { + pos += p2; + continue; + } + if (p1 == 0xc) { + tempo = p2; + pos++; + continue; + } + if (p1 == 0xd) { + pos++; + rep_start_pos = pos; + rep_end_pos = pos + p2; + rep_times = p3 - 1; + continue; + } + if (p1 == 0xe) { + module_info _ loops[module_info _ songs] = TRUE; + break; + } + p2 = rep_times > 0 ? SEEN_REPEAT : SEEN_BEFORE; + for (p1 = 0; p1 < 0x55; p1++) + if (seen[p1] == SEEN_THIS_CALL) + seen[p1] = CAST(byte) p2; + player_calls += tempo * (module_info _ type == ASAP_TYPE_CM3 ? 48 : 64); + pos++; + } + set_song_duration(module_info, player_calls); +} + +PRIVATE FUNC(abool, parse_cmc, ( + P(ASAP_State PTR, ast), P(ASAP_ModuleInfo PTR, module_info), + P(CONST BYTEARRAY, module), P(int, module_len), P(int, type), P(RESOURCE, player))) +{ + V(int, last_pos); + V(int, pos); + if (module_len < 0x306) + return FALSE; + module_info _ type = type; + if (!load_native(ast, module_info, module, module_len, player)) + return FALSE; +#ifndef ASAP_ONLY_INFO + if (ast != NULL && type == ASAP_TYPE_CMR) + COPY_ARRAY(ast _ memory, 0x500 + CMR_BASS_TABLE_OFFSET, cmr_bass_table, 0, sizeof(cmr_bass_table)); +#endif + last_pos = 0x54; + while (--last_pos >= 0) { + if (UBYTE(module[0x206 + last_pos]) < 0xb0 + || UBYTE(module[0x25b + last_pos]) < 0x40 + || UBYTE(module[0x2b0 + last_pos]) < 0x40) + break; + if (module_info _ channels == 2) { + if (UBYTE(module[0x306 + last_pos]) < 0xb0 + || UBYTE(module[0x35b + last_pos]) < 0x40 + || UBYTE(module[0x3b0 + last_pos]) < 0x40) + break; + } + } + module_info _ songs = 0; + parse_cmc_song(module_info, module, 0); + for (pos = 0; pos < last_pos && module_info _ songs < ASAP_SONGS_MAX; pos++) + if (UBYTE(module[0x206 + pos]) == 0x8f || UBYTE(module[0x206 + pos]) == 0xef) + parse_cmc_song(module_info, module, pos + 1); + return TRUE; +} + +PRIVATE FUNC(abool, is_dlt_track_empty, (P(CONST BYTEARRAY, module), P(int, pos))) +{ + return UBYTE(module[0x2006 + pos]) >= 0x43 + && UBYTE(module[0x2106 + pos]) >= 0x40 + && UBYTE(module[0x2206 + pos]) >= 0x40 + && UBYTE(module[0x2306 + pos]) >= 0x40; +} + +PRIVATE FUNC(abool, is_dlt_pattern_end, (P(CONST BYTEARRAY, module), P(int, pos), P(int, i))) +{ + V(int, ch); + for (ch = 0; ch < 4; ch++) { + V(int, pattern) = UBYTE(module[0x2006 + (ch << 8) + pos]); + if (pattern < 64) { + V(int, offset) = 6 + (pattern << 7) + (i << 1); + if ((module[offset] & 0x80) == 0 && (module[offset + 1] & 0x80) != 0) + return TRUE; + } + } + return FALSE; +} + +PRIVATE FUNC(void, parse_dlt_song, ( + P(ASAP_ModuleInfo PTR, module_info), P(CONST BYTEARRAY, module), + P(BOOLARRAY, seen), P(int, pos))) +{ + V(int, player_calls) = 0; + V(abool, loop) = FALSE; + V(int, tempo) = 6; + while (pos < 128 && !seen[pos] && is_dlt_track_empty(module, pos)) + seen[pos++] = TRUE; + module_info _ song_pos[module_info _ songs] = CAST(byte) pos; + while (pos < 128) { + V(int, p1); + if (seen[pos]) { + loop = TRUE; + break; + } + seen[pos] = TRUE; + p1 = module[0x2006 + pos]; + if (p1 == 0x40 || is_dlt_track_empty(module, pos)) + break; + if (p1 == 0x41) + pos = UBYTE(module[0x2086 + pos]); + else if (p1 == 0x42) + tempo = UBYTE(module[0x2086 + pos++]); + else { + V(int, i); + for (i = 0; i < 64 && !is_dlt_pattern_end(module, pos, i); i++) + player_calls += tempo; + pos++; + } + } + if (player_calls > 0) { + module_info _ loops[module_info _ songs] = loop; + set_song_duration(module_info, player_calls); + } +} + +PRIVATE FUNC(abool, parse_dlt, ( + P(ASAP_State PTR, ast), P(ASAP_ModuleInfo PTR, module_info), + P(CONST BYTEARRAY, module), P(int, module_len))) +{ + V(int, pos); + NEW_ARRAY(abool, seen, 128); + if (module_len == 0x2c06) { + if (ast != NULL) + ast _ memory[0x4c00] = 0; + } + else if (module_len != 0x2c07) + return FALSE; + module_info _ type = ASAP_TYPE_DLT; + if (!load_native(ast, module_info, module, module_len, GET_PLAYER(dlt)) + || module_info _ music != 0x2000) { + return FALSE; + } + INIT_ARRAY(seen); + module_info _ songs = 0; + for (pos = 0; pos < 128 && module_info _ songs < ASAP_SONGS_MAX; pos++) { + if (!seen[pos]) + parse_dlt_song(module_info, module, seen, pos); + } + return module_info _ songs > 0; +} + +PRIVATE FUNC(void, parse_mpt_song, ( + P(ASAP_ModuleInfo PTR, module_info), P(CONST BYTEARRAY, module), + P(BOOLARRAY, global_seen), P(int, song_len), P(int, pos))) +{ + V(int, addr_to_offset) = UWORD(module, 2) - 6; + V(int, tempo) = UBYTE(module[0x1cf]); + V(int, player_calls) = 0; + NEW_ARRAY(byte, seen, 256); + NEW_ARRAY(int, pattern_offset, 4); + NEW_ARRAY(int, blank_rows, 4); + NEW_ARRAY(int, blank_rows_counter, 4); + INIT_ARRAY(seen); + INIT_ARRAY(blank_rows); + while (pos < song_len) { + V(int, i); + V(int, ch); + V(int, pattern_rows); + if (seen[pos] != 0) { + if (seen[pos] != SEEN_THIS_CALL) + module_info _ loops[module_info _ songs] = TRUE; + break; + } + seen[pos] = SEEN_THIS_CALL; + global_seen[pos] = TRUE; + i = UBYTE(module[0x1d0 + pos * 2]); + if (i == 0xff) { + pos = UBYTE(module[0x1d1 + pos * 2]); + continue; + } + for (ch = 3; ch >= 0; ch--) { + i = UBYTE(module[0x1c6 + ch]) + (UBYTE(module[0x1ca + ch]) << 8) - addr_to_offset; + i = UBYTE(module[i + pos * 2]); + if (i >= 0x40) + break; + i <<= 1; + i = UWORD(module, 0x46 + i); + pattern_offset[ch] = i == 0 ? 0 : i - addr_to_offset; + blank_rows_counter[ch] = 0; + } + if (ch >= 0) + break; + for (i = 0; i < song_len; i++) + if (seen[i] == SEEN_THIS_CALL) + seen[i] = SEEN_BEFORE; + for (pattern_rows = UBYTE(module[0x1ce]); --pattern_rows >= 0; ) { + for (ch = 3; ch >= 0; ch--) { + if (pattern_offset[ch] == 0 || --blank_rows_counter[ch] >= 0) + continue; + for (;;) { + i = UBYTE(module[pattern_offset[ch]++]); + if (i < 0x40 || i == 0xfe) + break; + if (i < 0x80) + continue; + if (i < 0xc0) { + blank_rows[ch] = i - 0x80; + continue; + } + if (i < 0xd0) + continue; + if (i < 0xe0) { + tempo = i - 0xcf; + continue; + } + pattern_rows = 0; + } + blank_rows_counter[ch] = blank_rows[ch]; + } + player_calls += tempo; + } + pos++; + } + if (player_calls > 0) + set_song_duration(module_info, player_calls); +} + +PRIVATE FUNC(abool, parse_mpt, ( + P(ASAP_State PTR, ast), P(ASAP_ModuleInfo PTR, module_info), + P(CONST BYTEARRAY, module), P(int, module_len))) +{ + V(int, track0_addr); + V(int, pos); + V(int, song_len); + /* seen[i] == TRUE if the track position i has been processed */ + NEW_ARRAY(abool, global_seen, 256); + if (module_len < 0x1d0) + return FALSE; + module_info _ type = ASAP_TYPE_MPT; + if (!load_native(ast, module_info, module, module_len, GET_PLAYER(mpt))) + return FALSE; + track0_addr = UWORD(module, 2) + 0x1ca; + if (UBYTE(module[0x1c6]) + (UBYTE(module[0x1ca]) << 8) != track0_addr) + return FALSE; + /* Calculate the length of the first track. Address of the second track minus + address of the first track equals the length of the first track in bytes. + Divide by two to get number of track positions. */ + song_len = (UBYTE(module[0x1c7]) + (UBYTE(module[0x1cb]) << 8) - track0_addr) >> 1; + if (song_len > 0xfe) + return FALSE; + INIT_ARRAY(global_seen); + module_info _ songs = 0; + for (pos = 0; pos < song_len && module_info _ songs < ASAP_SONGS_MAX; pos++) { + if (!global_seen[pos]) { + module_info _ song_pos[module_info _ songs] = CAST(byte) pos; + parse_mpt_song(module_info, module, global_seen, song_len, pos); + } + } + return module_info _ songs > 0; +} + +CONST_ARRAY(byte, rmt_volume_silent) + 16, 8, 4, 3, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1 +END_CONST_ARRAY; + +PRIVATE FUNC(int, rmt_instrument_frames, ( + P(CONST BYTEARRAY, module), P(int, instrument), + P(int, volume), P(int, volume_frame), P(abool, extra_pokey))) +{ + V(int, addr_to_offset) = UWORD(module, 2) - 6; + V(int, per_frame) = module[0xc]; + V(int, player_call); + V(int, player_calls); + V(int, index); + V(int, index_end); + V(int, index_loop); + V(int, volume_slide_depth); + V(int, volume_min); + V(int, volume_slide); + V(abool, silent_loop); + instrument = UWORD(module, 0xe) - addr_to_offset + (instrument << 1); + if (module[instrument + 1] == 0) + return 0; + instrument = UWORD(module, instrument) - addr_to_offset; + player_calls = player_call = volume_frame * per_frame; + index = UBYTE(module[instrument]) + 1 + player_call * 3; + index_end = UBYTE(module[instrument + 2]) + 3; + index_loop = UBYTE(module[instrument + 3]); + if (index_loop >= index_end) + return 0; /* error */ + volume_slide_depth = UBYTE(module[instrument + 6]); + volume_min = UBYTE(module[instrument + 7]); + if (index >= index_end) + index = (index - index_end) % (index_end - index_loop) + index_loop; + else { + do { + V(int, vol) = module[instrument + index]; + if (extra_pokey) + vol >>= 4; + if ((vol & 0xf) >= rmt_volume_silent[volume]) + player_calls = player_call + 1; + player_call++; + index += 3; + } while (index < index_end); + } + if (volume_slide_depth == 0) + return player_calls / per_frame; + volume_slide = 128; + silent_loop = FALSE; + for (;;) { + V(int, vol); + if (index >= index_end) { + if (silent_loop) + break; + silent_loop = TRUE; + index = index_loop; + } + vol = module[instrument + index]; + if (extra_pokey) + vol >>= 4; + if ((vol & 0xf) >= rmt_volume_silent[volume]) { + player_calls = player_call + 1; + silent_loop = FALSE; + } + player_call++; + index += 3; + volume_slide -= volume_slide_depth; + if (volume_slide < 0) { + volume_slide += 256; + if (--volume <= volume_min) + break; + } + } + return player_calls / per_frame; +} + +PRIVATE FUNC(void, parse_rmt_song, ( + P(ASAP_ModuleInfo PTR, module_info), P(CONST BYTEARRAY, module), + P(BOOLARRAY, global_seen), P(int, song_len), P(int, pos_shift), P(int, pos))) +{ + V(int, ch); + V(int, addr_to_offset) = UWORD(module, 2) - 6; + V(int, tempo) = UBYTE(module[0xb]); + V(int, frames) = 0; + V(int, song_offset) = UWORD(module, 0x14) - addr_to_offset; + V(int, pattern_lo_offset) = UWORD(module, 0x10) - addr_to_offset; + V(int, pattern_hi_offset) = UWORD(module, 0x12) - addr_to_offset; + V(int, instrument_frames); + NEW_ARRAY(byte, seen, 256); + NEW_ARRAY(int, pattern_begin, 8); + NEW_ARRAY(int, pattern_offset, 8); + NEW_ARRAY(int, blank_rows, 8); + NEW_ARRAY(int, instrument_no, 8); + NEW_ARRAY(int, instrument_frame, 8); + NEW_ARRAY(int, volume_value, 8); + NEW_ARRAY(int, volume_frame, 8); + INIT_ARRAY(seen); + INIT_ARRAY(instrument_no); + INIT_ARRAY(instrument_frame); + INIT_ARRAY(volume_value); + INIT_ARRAY(volume_frame); + while (pos < song_len) { + V(int, i); + V(int, pattern_rows); + if (seen[pos] != 0) { + if (seen[pos] != SEEN_THIS_CALL) + module_info _ loops[module_info _ songs] = TRUE; + break; + } + seen[pos] = SEEN_THIS_CALL; + global_seen[pos] = TRUE; + if (UBYTE(module[song_offset + (pos << pos_shift)]) == 0xfe) { + pos = UBYTE(module[song_offset + (pos << pos_shift) + 1]); + continue; + } + for (ch = 0; ch < 1 << pos_shift; ch++) { + i = UBYTE(module[song_offset + (pos << pos_shift) + ch]); + if (i == 0xff) + blank_rows[ch] = 256; + else { + pattern_offset[ch] = pattern_begin[ch] = UBYTE(module[pattern_lo_offset + i]) + + (UBYTE(module[pattern_hi_offset + i]) << 8) - addr_to_offset; + blank_rows[ch] = 0; + } + } + for (i = 0; i < song_len; i++) + if (seen[i] == SEEN_THIS_CALL) + seen[i] = SEEN_BEFORE; + for (pattern_rows = UBYTE(module[0xa]); --pattern_rows >= 0; ) { + for (ch = 0; ch < 1 << pos_shift; ch++) { + if (--blank_rows[ch] > 0) + continue; + for (;;) { + i = UBYTE(module[pattern_offset[ch]++]); + if ((i & 0x3f) < 62) { + i += UBYTE(module[pattern_offset[ch]++]) << 8; + if ((i & 0x3f) != 61) { + instrument_no[ch] = i >> 10; + instrument_frame[ch] = frames; + } + volume_value[ch] = (i >> 6) & 0xf; + volume_frame[ch] = frames; + break; + } + if (i == 62) { + blank_rows[ch] = UBYTE(module[pattern_offset[ch]++]); + break; + } + if ((i & 0x3f) == 62) { + blank_rows[ch] = i >> 6; + break; + } + if ((i & 0xbf) == 63) { + tempo = UBYTE(module[pattern_offset[ch]++]); + continue; + } + if (i == 0xbf) { + pattern_offset[ch] = pattern_begin[ch] + UBYTE(module[pattern_offset[ch]]); + continue; + } + /* assert(i == 0xff); */ + pattern_rows = -1; + break; + } + if (pattern_rows < 0) + break; + } + if (pattern_rows >= 0) + frames += tempo; + } + pos++; + } + instrument_frames = 0; + for (ch = 0; ch < 1 << pos_shift; ch++) { + V(int, frame) = instrument_frame[ch]; + frame += rmt_instrument_frames(module, instrument_no[ch], volume_value[ch], volume_frame[ch] - frame, ch >= 4); + if (instrument_frames < frame) + instrument_frames = frame; + } + if (frames > instrument_frames) { + if (frames - instrument_frames > 100) + module_info _ loops[module_info _ songs] = FALSE; + frames = instrument_frames; + } + if (frames > 0) + set_song_duration(module_info, frames); +} + +PRIVATE FUNC(abool, parse_rmt, ( + P(ASAP_State PTR, ast), P(ASAP_ModuleInfo PTR, module_info), + P(CONST BYTEARRAY, module), P(int, module_len))) +{ + V(int, per_frame); + V(int, pos_shift); + V(int, song_len); + V(int, pos); + NEW_ARRAY(abool, global_seen, 256); + if (module_len < 0x30 || module[6] != CHARCODE('R') || module[7] != CHARCODE('M') + || module[8] != CHARCODE('T') || module[0xd] != 1) + return FALSE; + switch (CAST(char) module[9]) { + case CHARCODE('4'): + pos_shift = 2; + break; + case CHARCODE('8'): + module_info _ channels = 2; + pos_shift = 3; + break; + default: + return FALSE; + } + per_frame = module[0xc]; + if (per_frame < 1 || per_frame > 4) + return FALSE; + module_info _ type = ASAP_TYPE_RMT; + if (!load_native(ast, module_info, module, module_len, + module_info _ channels == 2 ? GET_PLAYER(rmt8) : GET_PLAYER(rmt4))) + return FALSE; + song_len = UWORD(module, 4) + 1 - UWORD(module, 0x14); + if (pos_shift == 3 && (song_len & 4) != 0 + && UBYTE(module[6 + UWORD(module, 4) - UWORD(module, 2) - 3]) == 0xfe) + song_len += 4; + song_len >>= pos_shift; + if (song_len >= 0x100) + return FALSE; + INIT_ARRAY(global_seen); + module_info _ songs = 0; + for (pos = 0; pos < song_len && module_info _ songs < ASAP_SONGS_MAX; pos++) { + if (!global_seen[pos]) { + module_info _ song_pos[module_info _ songs] = CAST(byte) pos; + parse_rmt_song(module_info, module, global_seen, song_len, pos_shift, pos); + } + } + /* must set fastplay after song durations calculations, so they assume 312 */ + module_info _ fastplay = perframe2fastplay[per_frame - 1]; + module_info _ player = 0x600; + return module_info _ songs > 0; +} + +PRIVATE FUNC(void, parse_tmc_song, ( + P(ASAP_ModuleInfo PTR, module_info), P(CONST BYTEARRAY, module), P(int, pos))) +{ + V(int, addr_to_offset) = UWORD(module, 2) - 6; + V(int, tempo) = UBYTE(module[0x24]) + 1; + V(int, frames) = 0; + NEW_ARRAY(int, pattern_offset, 8); + NEW_ARRAY(int, blank_rows, 8); + while (UBYTE(module[0x1a6 + 15 + pos]) < 0x80) { + V(int, ch); + V(int, pattern_rows); + for (ch = 7; ch >= 0; ch--) { + V(int, pat) = UBYTE(module[0x1a6 + 15 + pos - 2 * ch]); + pattern_offset[ch] = UBYTE(module[0xa6 + pat]) + (UBYTE(module[0x126 + pat]) << 8) - addr_to_offset; + blank_rows[ch] = 0; + } + for (pattern_rows = 64; --pattern_rows >= 0; ) { + for (ch = 7; ch >= 0; ch--) { + if (--blank_rows[ch] >= 0) + continue; + for (;;) { + V(int, i) = UBYTE(module[pattern_offset[ch]++]); + if (i < 0x40) { + pattern_offset[ch]++; + break; + } + if (i == 0x40) { + i = UBYTE(module[pattern_offset[ch]++]); + if ((i & 0x7f) == 0) + pattern_rows = 0; + else + tempo = (i & 0x7f) + 1; + if (i >= 0x80) + pattern_offset[ch]++; + break; + } + if (i < 0x80) { + i = module[pattern_offset[ch]++] & 0x7f; + if (i == 0) + pattern_rows = 0; + else + tempo = i + 1; + pattern_offset[ch]++; + break; + } + if (i < 0xc0) + continue; + blank_rows[ch] = i - 0xbf; + break; + } + } + frames += tempo; + } + pos += 16; + } + if (UBYTE(module[0x1a6 + 14 + pos]) < 0x80) + module_info _ loops[module_info _ songs] = TRUE; + set_song_duration(module_info, frames); +} + +PRIVATE FUNC(abool, parse_tmc, ( + P(ASAP_State PTR, ast), P(ASAP_ModuleInfo PTR, module_info), + P(CONST BYTEARRAY, module), P(int, module_len))) +{ + V(int, i); + V(int, last_pos); + if (module_len < 0x1d0) + return FALSE; + module_info _ type = ASAP_TYPE_TMC; + if (!load_native(ast, module_info, module, module_len, GET_PLAYER(tmc))) + return FALSE; + module_info _ channels = 2; + i = 0; + /* find first instrument */ + while (module[0x66 + i] == 0) { + if (++i >= 64) + return FALSE; /* no instrument */ + } + last_pos = (UBYTE(module[0x66 + i]) << 8) + UBYTE(module[0x26 + i]) + - UWORD(module, 2) - 0x1b0; + if (0x1b5 + last_pos >= module_len) + return FALSE; + /* skip trailing jumps */ + do { + if (last_pos <= 0) + return FALSE; /* no pattern to play */ + last_pos -= 16; + } while (UBYTE(module[0x1b5 + last_pos]) >= 0x80); + module_info _ songs = 0; + parse_tmc_song(module_info, module, 0); + for (i = 0; i < last_pos && module_info _ songs < ASAP_SONGS_MAX; i += 16) + if (UBYTE(module[0x1b5 + i]) >= 0x80) + parse_tmc_song(module_info, module, i + 16); + /* must set fastplay after song durations calculations, so they assume 312 */ + i = module[0x25]; + if (i < 1 || i > 4) + return FALSE; + if (ast != NULL) + ast _ tmc_per_frame = module[0x25]; + module_info _ fastplay = perframe2fastplay[i - 1]; + return TRUE; +} + +PRIVATE FUNC(void, parse_tm2_song, ( + P(ASAP_ModuleInfo PTR, module_info), P(CONST BYTEARRAY, module), P(int, pos))) +{ + V(int, addr_to_offset) = UWORD(module, 2) - 6; + V(int, tempo) = UBYTE(module[0x24]) + 1; + V(int, player_calls) = 0; + NEW_ARRAY(int, pattern_offset, 8); + NEW_ARRAY(int, blank_rows, 8); + for (;;) { + V(int, ch); + V(int, pattern_rows) = UBYTE(module[0x386 + 16 + pos]); + if (pattern_rows == 0) + break; + if (pattern_rows >= 0x80) { + module_info _ loops[module_info _ songs] = TRUE; + break; + } + for (ch = 7; ch >= 0; ch--) { + V(int, pat) = UBYTE(module[0x386 + 15 + pos - 2 * ch]); + pattern_offset[ch] = UBYTE(module[0x106 + pat]) + (UBYTE(module[0x206 + pat]) << 8) - addr_to_offset; + blank_rows[ch] = 0; + } + while (--pattern_rows >= 0) { + for (ch = 7; ch >= 0; ch--) { + if (--blank_rows[ch] >= 0) + continue; + for (;;) { + V(int, i) = UBYTE(module[pattern_offset[ch]++]); + if (i == 0) { + pattern_offset[ch]++; + break; + } + if (i < 0x40) { + if (UBYTE(module[pattern_offset[ch]++]) >= 0x80) + pattern_offset[ch]++; + break; + } + if (i < 0x80) { + pattern_offset[ch]++; + break; + } + if (i == 0x80) { + blank_rows[ch] = UBYTE(module[pattern_offset[ch]++]); + break; + } + if (i < 0xc0) + break; + if (i < 0xd0) { + tempo = i - 0xbf; + continue; + } + if (i < 0xe0) { + pattern_offset[ch]++; + break; + } + if (i < 0xf0) { + pattern_offset[ch] += 2; + break; + } + if (i < 0xff) { + blank_rows[ch] = i - 0xf0; + break; + } + blank_rows[ch] = 64; + break; + } + } + player_calls += tempo; + } + pos += 17; + } + set_song_duration(module_info, player_calls); +} + +PRIVATE FUNC(abool, parse_tm2, ( + P(ASAP_State PTR, ast), P(ASAP_ModuleInfo PTR, module_info), + P(CONST BYTEARRAY, module), P(int, module_len))) +{ + V(int, i); + V(int, last_pos); + V(int, c); + if (module_len < 0x3a4) + return FALSE; + module_info _ type = ASAP_TYPE_TM2; + if (!load_native(ast, module_info, module, module_len, GET_PLAYER(tm2))) + return FALSE; + i = module[0x25]; + if (i < 1 || i > 4) + return FALSE; + module_info _ fastplay = perframe2fastplay[i - 1]; + module_info _ player = 0x500; + if (module[0x1f] != 0) + module_info _ channels = 2; + last_pos = 0xffff; + for (i = 0; i < 0x80; i++) { + V(int, instr_addr) = UBYTE(module[0x86 + i]) + (UBYTE(module[0x306 + i]) << 8); + if (instr_addr != 0 && instr_addr < last_pos) + last_pos = instr_addr; + } + for (i = 0; i < 0x100; i++) { + V(int, pattern_addr) = UBYTE(module[0x106 + i]) + (UBYTE(module[0x206 + i]) << 8); + if (pattern_addr != 0 && pattern_addr < last_pos) + last_pos = pattern_addr; + } + last_pos -= UWORD(module, 2) + 0x380; + if (0x386 + last_pos >= module_len) + return FALSE; + /* skip trailing stop/jump commands */ + do { + if (last_pos <= 0) + return FALSE; + last_pos -= 17; + c = UBYTE(module[0x386 + 16 + last_pos]); + } while (c == 0 || c >= 0x80); + module_info _ songs = 0; + parse_tm2_song(module_info, module, 0); + for (i = 0; i < last_pos && module_info _ songs < ASAP_SONGS_MAX; i += 17) { + c = UBYTE(module[0x386 + 16 + i]); + if (c == 0 || c >= 0x80) + parse_tm2_song(module_info, module, i + 17); + } + return TRUE; +} + +#endif /* ASAP_ONLY_SAP */ + +PRIVATE FUNC(abool, has_string_at, (P(CONST BYTEARRAY, module), P(int, module_index), P(STRING, s))) +{ + V(int, i); + V(int, n) = strlen(s); + for (i = 0; i < n; i++) + if (module[module_index + i] != CHARCODEAT(s, i)) + return FALSE; + return TRUE; +} + +PRIVATE FUNC(STRING, parse_text, (P(OUT_STRING, dest), P(CONST BYTEARRAY, module), P(int, module_index))) +{ + V(int, i); + if (module[module_index] != CHARCODE('"')) + return NULL; + if (has_string_at(module, module_index + 1, "\"")) + return dest; + for (i = 0; ; i++) { + V(int, c) = module[module_index + 1 + i]; + if (c == CHARCODE('"')) + break; + if (c < 32 || c >= 127) + return NULL; + } + BYTES_TO_STRING(dest, module, module_index + 1, i); + return dest; +} + +PRIVATE FUNC(int, parse_dec, (P(CONST BYTEARRAY, module), P(int, module_index), P(int, maxval))) +{ + V(int, r); + if (module[module_index] == 0xd) + return -1; + for (r = 0;;) { + V(int, c) = module[module_index++]; + if (c == 0xd) + break; + if (c < CHARCODE('0') || c > CHARCODE('9')) + return -1; + r = 10 * r + c - 48; + if (r > maxval) + return -1; + } + return r; +} + +PRIVATE FUNC(int, parse_hex, (P(CONST BYTEARRAY, module), P(int, module_index))) +{ + V(int, r); + if (module[module_index] == 0xd) + return -1; + for (r = 0;;) { + V(int, c) = module[module_index++]; + if (c == 0xd) + break; + if (r > 0xfff) + return -1; + r <<= 4; + if (c >= CHARCODE('0') && c <= CHARCODE('9')) + r += c - CHARCODE('0'); + else if (c >= CHARCODE('A') && c <= CHARCODE('F')) + r += c - CHARCODE('A') + 10; + else if (c >= CHARCODE('a') && c <= CHARCODE('f')) + r += c - CHARCODE('a') + 10; + else + return -1; + } + return r; +} + +FUNC(int, ASAP_ParseDuration, (P(STRING, s))) +{ + V(int, i) = 0; + V(int, r); + V(int, d); + V(int, n) = strlen(s); +#define PARSE_DIGIT(maxdig, retifnot) \ + if (i >= n) \ + return retifnot; \ + d = CHARCODEAT(s, i) - 48; \ + if (d < 0 || d > maxdig) \ + return -1; \ + i++; + + PARSE_DIGIT(9, -1); + r = d; + if (i < n) { + d = CHARCODEAT(s, i) - 48; + if (d >= 0 && d <= 9) { + i++; + r = 10 * r + d; + } + if (i < n && CHARAT(s, i) == ':') { + i++; + PARSE_DIGIT(5, -1); + r = (6 * r + d) * 10; + PARSE_DIGIT(9, -1); + r += d; + } + } + r *= 1000; + if (i >= n) + return r; + if (CHARAT(s, i) != '.') + return -1; + i++; + PARSE_DIGIT(9, -1); + r += 100 * d; + PARSE_DIGIT(9, r); + r += 10 * d; + PARSE_DIGIT(9, r); + r += d; + return r; +} + +PRIVATE FUNC(abool, parse_sap_header, ( + P(ASAP_ModuleInfo PTR, module_info), P(CONST BYTEARRAY, module), P(int, module_len))) +{ + V(int, module_index); + V(int, type) = 0; + V(int, duration_index) = 0; + if (!has_string_at(module, 0, "SAP\r\n")) + return FALSE; + module_info _ fastplay = -1; + module_index = 5; + while (UBYTE(module[module_index]) != 0xff) { + if (module_index + 8 >= module_len) + return FALSE; +#define TAG_IS(s) has_string_at(module, module_index, s) +#ifdef C +#define SET_TEXT(v, i) if (parse_text(v, module, module_index + i) == NULL) return FALSE +#else +#define SET_TEXT(v, i) v = parse_text(v, module, module_index + i); if (v == NULL) return FALSE +#endif +#define SET_DEC(v, i, min, max) v = parse_dec(module, module_index + i, max); if (v < min) return FALSE +#define SET_HEX(v, i) v = parse_hex(module, module_index + i) + if (TAG_IS("AUTHOR ")) { + SET_TEXT(module_info _ author, 7); + } + else if (TAG_IS("NAME ")) { + SET_TEXT(module_info _ name, 5); + } + else if (TAG_IS("DATE ")) { + SET_TEXT(module_info _ date, 5); + } + else if (TAG_IS("SONGS ")) { + SET_DEC(module_info _ songs, 6, 1, ASAP_SONGS_MAX); + } + else if (TAG_IS("DEFSONG ")) { + SET_DEC(module_info _ default_song, 8, 0, ASAP_SONGS_MAX - 1); + } + else if (TAG_IS("STEREO\r")) + module_info _ channels = 2; + else if (TAG_IS("NTSC\r")) + module_info _ ntsc = TRUE; + else if (TAG_IS("TIME ")) { + V(int, i); +#ifdef C + char s[ASAP_DURATION_CHARS]; +#else + V(STRING, s); +#endif + module_index += 5; + for (i = 0; module[module_index + i] != 0xd; i++) { } + if (i > 5 && has_string_at(module, module_index + i - 5, " LOOP")) { + module_info _ loops[duration_index] = TRUE; + i -= 5; + } +#ifdef C + if (i >= ASAP_DURATION_CHARS) + return FALSE; +#endif + BYTES_TO_STRING(s, module, module_index, i); + i = ASAP_ParseDuration(s); + if (i < 0 || duration_index >= ASAP_SONGS_MAX) + return FALSE; + module_info _ durations[duration_index++] = i; + } + else if (TAG_IS("TYPE ")) + type = module[module_index + 5]; + else if (TAG_IS("FASTPLAY ")) { + SET_DEC(module_info _ fastplay, 9, 1, 312); + } + else if (TAG_IS("MUSIC ")) { + SET_HEX(module_info _ music, 6); + } + else if (TAG_IS("INIT ")) { + SET_HEX(module_info _ init, 5); + } + else if (TAG_IS("PLAYER ")) { + SET_HEX(module_info _ player, 7); + } + else if (TAG_IS("COVOX ")) { + SET_HEX(module_info _ covox_addr, 6); + if (module_info _ covox_addr != 0xd600) + return FALSE; + module_info _ channels = 2; + } + + while (module[module_index++] != 0x0d) { + if (module_index >= module_len) + return FALSE; + } + if (module[module_index++] != 0x0a) + return FALSE; + } + if (module_info _ default_song >= module_info _ songs) + return FALSE; + switch (type) { + case CHARCODE('B'): + if (module_info _ player < 0 || module_info _ init < 0) + return FALSE; + module_info _ type = ASAP_TYPE_SAP_B; + break; + case CHARCODE('C'): + if (module_info _ player < 0 || module_info _ music < 0) + return FALSE; + module_info _ type = ASAP_TYPE_SAP_C; + break; + case CHARCODE('D'): + if (module_info _ init < 0) + return FALSE; + module_info _ type = ASAP_TYPE_SAP_D; + break; + case CHARCODE('S'): + if (module_info _ init < 0) + return FALSE; + module_info _ type = ASAP_TYPE_SAP_S; + module_info _ fastplay = 78; + break; + default: + return FALSE; + } + if (module_info _ fastplay < 0) + module_info _ fastplay = module_info _ ntsc ? 262 : 312; + else if (module_info _ ntsc && module_info _ fastplay > 262) + return FALSE; + if (UBYTE(module[module_index + 1]) != 0xff) + return FALSE; + module_info _ header_len = module_index; + return TRUE; +} + +PRIVATE FUNC(abool, parse_sap, ( + P(ASAP_State PTR, ast), P(ASAP_ModuleInfo PTR, module_info), + P(CONST BYTEARRAY, module), P(int, module_len))) +{ + V(int, module_index); + if (!parse_sap_header(module_info, module, module_len)) + return FALSE; + if (ast == NULL) + return TRUE; + ZERO_ARRAY(ast _ memory); + module_index = module_info _ header_len + 2; + while (module_index + 5 <= module_len) { + V(int, start_addr) = UWORD(module, module_index); + V(int, block_len) = UWORD(module, module_index + 2) + 1 - start_addr; + if (block_len <= 0 || module_index + block_len > module_len) + return FALSE; + module_index += 4; + COPY_ARRAY(ast _ memory, start_addr, module, module_index, block_len); + module_index += block_len; + if (module_index == module_len) + return TRUE; + if (module_index + 7 <= module_len + && UBYTE(module[module_index]) == 0xff && UBYTE(module[module_index + 1]) == 0xff) + module_index += 2; + } + return FALSE; +} + +#define ASAP_EXT(c1, c2, c3) ((CHARCODE(c1) + (CHARCODE(c2) << 8) + (CHARCODE(c3) << 16)) | 0x202020) + +PRIVATE FUNC(int, get_packed_ext, (P(STRING, filename))) +{ + V(int, i) = strlen(filename); + V(int, ext) = 0; + while (--i > 0) { + V(char, c) = CHARAT(filename, i); + if (c <= ' ' || c > 'z') + return 0; + if (c == '.') + return ext | 0x202020; + ext = (ext << 8) + CHARCODE(c); + } + return 0; +} + +PRIVATE FUNC(abool, is_our_ext, (P(int, ext))) +{ + switch (ext) { + case ASAP_EXT('S', 'A', 'P'): +#ifndef ASAP_ONLY_SAP + case ASAP_EXT('C', 'M', 'C'): + case ASAP_EXT('C', 'M', '3'): + case ASAP_EXT('C', 'M', 'R'): + case ASAP_EXT('C', 'M', 'S'): + case ASAP_EXT('D', 'M', 'C'): + case ASAP_EXT('D', 'L', 'T'): + case ASAP_EXT('M', 'P', 'T'): + case ASAP_EXT('M', 'P', 'D'): + case ASAP_EXT('R', 'M', 'T'): + case ASAP_EXT('T', 'M', 'C'): + case ASAP_EXT('T', 'M', '8'): + case ASAP_EXT('T', 'M', '2'): +#endif + return TRUE; + default: + return FALSE; + } +} + +FUNC(abool, ASAP_IsOurFile, (P(STRING, filename))) +{ + V(int, ext) = get_packed_ext(filename); + return is_our_ext(ext); +} + +FUNC(abool, ASAP_IsOurExt, (P(STRING, ext))) +{ + return strlen(ext) == 3 + && is_our_ext(ASAP_EXT(CHARAT(ext, 0), CHARAT(ext, 1), CHARAT(ext, 2))); +} + +PRIVATE FUNC(abool, parse_file, ( + P(ASAP_State PTR, ast), P(ASAP_ModuleInfo PTR, module_info), + P(STRING, filename), P(CONST BYTEARRAY, module), P(int, module_len))) +{ + V(int, i); + V(int, len) = strlen(filename); + V(int, basename) = 0; + V(int, ext) = -1; + for (i = 0; i < len; i++) { + V(char, c) = CHARAT(filename, i); + if (c == '/' || c == '\\') { + basename = i + 1; + ext = -1; + } + else if (c == '.') + ext = i; + } + if (ext < 0) + return FALSE; + EMPTY_STRING(module_info _ author); + SUBSTRING(module_info _ name, filename, basename, ext - basename); + EMPTY_STRING(module_info _ date); + module_info _ channels = 1; + module_info _ songs = 1; + module_info _ default_song = 0; + for (i = 0; i < ASAP_SONGS_MAX; i++) { + module_info _ durations[i] = -1; + module_info _ loops[i] = FALSE; + } + module_info _ ntsc = FALSE; + module_info _ fastplay = 312; + module_info _ music = -1; + module_info _ init = -1; + module_info _ player = -1; + module_info _ covox_addr = -1; + switch (get_packed_ext(filename)) { + case ASAP_EXT('S', 'A', 'P'): + return parse_sap(ast, module_info, module, module_len); +#ifndef ASAP_ONLY_SAP + case ASAP_EXT('C', 'M', 'C'): + return parse_cmc(ast, module_info, module, module_len, ASAP_TYPE_CMC, GET_PLAYER(cmc)); + case ASAP_EXT('C', 'M', '3'): + return parse_cmc(ast, module_info, module, module_len, ASAP_TYPE_CM3, GET_PLAYER(cm3)); + case ASAP_EXT('C', 'M', 'R'): + return parse_cmc(ast, module_info, module, module_len, ASAP_TYPE_CMR, GET_PLAYER(cmc)); + case ASAP_EXT('C', 'M', 'S'): + module_info _ channels = 2; + return parse_cmc(ast, module_info, module, module_len, ASAP_TYPE_CMS, GET_PLAYER(cms)); + case ASAP_EXT('D', 'M', 'C'): + module_info _ fastplay = 156; + return parse_cmc(ast, module_info, module, module_len, ASAP_TYPE_CMC, GET_PLAYER(cmc)); + case ASAP_EXT('D', 'L', 'T'): + return parse_dlt(ast, module_info, module, module_len); + case ASAP_EXT('M', 'P', 'T'): + return parse_mpt(ast, module_info, module, module_len); + case ASAP_EXT('M', 'P', 'D'): + module_info _ fastplay = 156; + return parse_mpt(ast, module_info, module, module_len); + case ASAP_EXT('R', 'M', 'T'): + return parse_rmt(ast, module_info, module, module_len); + case ASAP_EXT('T', 'M', 'C'): + case ASAP_EXT('T', 'M', '8'): + return parse_tmc(ast, module_info, module, module_len); + case ASAP_EXT('T', 'M', '2'): + return parse_tm2(ast, module_info, module, module_len); +#endif + default: + return FALSE; + } +} + +FUNC(abool, ASAP_GetModuleInfo, ( + P(ASAP_ModuleInfo PTR, module_info), P(STRING, filename), + P(CONST BYTEARRAY, module), P(int, module_len))) +{ + return parse_file(NULL, module_info, filename, module, module_len); +} + +#ifndef ASAP_ONLY_INFO + +FUNC(abool, ASAP_Load, ( + P(ASAP_State PTR, ast), P(STRING, filename), + P(CONST BYTEARRAY, module), P(int, module_len))) +{ + /* Set up ast */ + ast _ memory = s_memory; + ast _ module_info = &s_module_info; + ast _ silence_cycles = 0; + return parse_file(ast, ast _ module_info, filename, module, module_len); +} + +FUNC(void, ASAP_DetectSilence, (P(ASAP_State PTR, ast), P(int, seconds))) +{ + ast _ silence_cycles = seconds * ASAP_MAIN_CLOCK(ast); +} + +PRIVATE FUNC(void, call_6502, (P(ASAP_State PTR, ast), P(int, addr), P(int, max_scanlines))) +{ + ast _ cpu_pc = addr; + /* put a CIM at 0xd20a and a return address on stack */ + dPutByte(0xd20a, 0xd2); + dPutByte(0x01fe, 0x09); + dPutByte(0x01ff, 0xd2); + ast _ cpu_s = 0xfd; + Cpu_RunScanlines(ast, max_scanlines); +} + +/* 50 Atari frames for the initialization routine - some SAPs are self-extracting. */ +#define SCANLINES_FOR_INIT (50 * 312) + +PRIVATE FUNC(void, call_6502_init, (P(ASAP_State PTR, ast), P(int, addr), P(int, a), P(int, x), P(int, y))) +{ + ast _ cpu_a = a & 0xff; + ast _ cpu_x = x & 0xff; + ast _ cpu_y = y & 0xff; + call_6502(ast, addr, SCANLINES_FOR_INIT); +} + +FUNC(void, ASAP_PlaySong, (P(ASAP_State PTR, ast), P(int, song), P(int, duration))) +{ + ast _ current_song = song; + ast _ current_duration = duration; + ast _ blocks_played = 0; + ast _ silence_cycles_counter = ast _ silence_cycles; + ast _ extra_pokey_mask = ast _ module_info->channels > 1 ? 0x10 : 0; + ast _ consol = 8; + ast _ covox[0] = CAST(byte) 0x80; + ast _ covox[1] = CAST(byte) 0x80; + ast _ covox[2] = CAST(byte) 0x80; + ast _ covox[3] = CAST(byte) 0x80; + PokeySound_Initialize(ast); + ast _ cycle = 0; + ast _ cpu_nz = 0; + ast _ cpu_c = 0; + ast _ cpu_vdi = 0; + ast _ scanline_number = 0; + ast _ next_scanline_cycle = 0; + ast _ timer1_cycle = NEVER; + ast _ timer2_cycle = NEVER; + ast _ timer4_cycle = NEVER; + ast _ irqst = 0xff; + switch (ast _ module_info->type) { + case ASAP_TYPE_SAP_B: + call_6502_init(ast, ast _ module_info->init, song, 0, 0); + break; + case ASAP_TYPE_SAP_C: +#ifndef ASAP_ONLY_SAP + case ASAP_TYPE_CMC: + case ASAP_TYPE_CM3: + case ASAP_TYPE_CMR: + case ASAP_TYPE_CMS: +#endif + call_6502_init(ast, ast _ module_info->player + 3, 0x70, ast _ module_info->music, ast _ module_info->music >> 8); + call_6502_init(ast, ast _ module_info->player + 3, 0x00, song, 0); + break; + case ASAP_TYPE_SAP_D: + case ASAP_TYPE_SAP_S: + ast _ cpu_a = song; + ast _ cpu_x = 0x00; + ast _ cpu_y = 0x00; + ast _ cpu_s = 0xff; + ast _ cpu_pc = ast _ module_info->init; + break; +#ifndef ASAP_ONLY_SAP + case ASAP_TYPE_DLT: + call_6502_init(ast, ast _ module_info->player + 0x100, 0x00, 0x00, ast _ module_info->song_pos[song]); + break; + case ASAP_TYPE_MPT: + call_6502_init(ast, ast _ module_info->player, 0x00, ast _ module_info->music >> 8, ast _ module_info->music); + call_6502_init(ast, ast _ module_info->player, 0x02, ast _ module_info->song_pos[song], 0); + break; + case ASAP_TYPE_RMT: + call_6502_init(ast, ast _ module_info->player, ast _ module_info->song_pos[song], ast _ module_info->music, ast _ module_info->music >> 8); + break; + case ASAP_TYPE_TMC: + case ASAP_TYPE_TM2: + call_6502_init(ast, ast _ module_info->player, 0x70, ast _ module_info->music >> 8, ast _ module_info->music); + call_6502_init(ast, ast _ module_info->player, 0x00, song, 0); + ast _ tmc_per_frame_counter = 1; + break; +#endif + } + ASAP_MutePokeyChannels(ast, 0); +} + +FUNC(void, ASAP_MutePokeyChannels, (P(ASAP_State PTR, ast), P(int, mask))) +{ + PokeySound_Mute(ast, ADDRESSOF ast _ base_pokey, mask); + PokeySound_Mute(ast, ADDRESSOF ast _ extra_pokey, mask >> 4); +} + +FUNC(abool, call_6502_player, (P(ASAP_State PTR, ast))) +{ + V(int, player) = ast _ module_info->player; + PokeySound_StartFrame(ast); + switch (ast _ module_info->type) { + case ASAP_TYPE_SAP_B: + call_6502(ast, player, ast _ module_info->fastplay); + break; + case ASAP_TYPE_SAP_C: +#ifndef ASAP_ONLY_SAP + case ASAP_TYPE_CMC: + case ASAP_TYPE_CM3: + case ASAP_TYPE_CMR: + case ASAP_TYPE_CMS: +#endif + call_6502(ast, player + 6, ast _ module_info->fastplay); + break; + case ASAP_TYPE_SAP_D: + if (player >= 0) { + V(int, s)= ast _ cpu_s; +#define PUSH_ON_6502_STACK(x) dPutByte(0x100 + s, x); s = (s - 1) & 0xff +#define RETURN_FROM_PLAYER_ADDR 0xd200 + /* save 6502 state on 6502 stack */ + PUSH_ON_6502_STACK(ast _ cpu_pc >> 8); + PUSH_ON_6502_STACK(ast _ cpu_pc & 0xff); + PUSH_ON_6502_STACK(((ast _ cpu_nz | (ast _ cpu_nz >> 1)) & 0x80) + ast _ cpu_vdi + \ + ((ast _ cpu_nz & 0xff) == 0 ? Z_FLAG : 0) + ast _ cpu_c + 0x20); + PUSH_ON_6502_STACK(ast _ cpu_a); + PUSH_ON_6502_STACK(ast _ cpu_x); + PUSH_ON_6502_STACK(ast _ cpu_y); + /* RTS will jump to 6502 code that restores the state */ + PUSH_ON_6502_STACK((RETURN_FROM_PLAYER_ADDR - 1) >> 8); + PUSH_ON_6502_STACK((RETURN_FROM_PLAYER_ADDR - 1) & 0xff); + ast _ cpu_s = s; + dPutByte(RETURN_FROM_PLAYER_ADDR, 0x68); /* PLA */ + dPutByte(RETURN_FROM_PLAYER_ADDR + 1, 0xa8); /* TAY */ + dPutByte(RETURN_FROM_PLAYER_ADDR + 2, 0x68); /* PLA */ + dPutByte(RETURN_FROM_PLAYER_ADDR + 3, 0xaa); /* TAX */ + dPutByte(RETURN_FROM_PLAYER_ADDR + 4, 0x68); /* PLA */ + dPutByte(RETURN_FROM_PLAYER_ADDR + 5, 0x40); /* RTI */ + ast _ cpu_pc = player; + } + Cpu_RunScanlines(ast, ast _ module_info->fastplay); + break; + case ASAP_TYPE_SAP_S: + Cpu_RunScanlines(ast, ast _ module_info->fastplay); + { + V(int, i) = dGetByte(0x45) - 1; + dPutByte(0x45, i); + if (i == 0) + dPutByte(0xb07b, dGetByte(0xb07b) + 1); + } + break; +#ifndef ASAP_ONLY_SAP + case ASAP_TYPE_DLT: + call_6502(ast, player + 0x103, ast _ module_info->fastplay); + break; + case ASAP_TYPE_MPT: + case ASAP_TYPE_RMT: + case ASAP_TYPE_TM2: + call_6502(ast, player + 3, ast _ module_info->fastplay); + break; + case ASAP_TYPE_TMC: + if (--ast _ tmc_per_frame_counter <= 0) { + ast _ tmc_per_frame_counter = ast _ tmc_per_frame; + call_6502(ast, player + 3, ast _ module_info->fastplay); + } + else + call_6502(ast, player + 6, ast _ module_info->fastplay); + break; +#endif + } + PokeySound_EndFrame(ast, ast _ module_info->fastplay * 114); + if (ast _ silence_cycles > 0) { + if (PokeySound_IsSilent(ADDRESSOF ast _ base_pokey) + && PokeySound_IsSilent(ADDRESSOF ast _ extra_pokey)) { + ast _ silence_cycles_counter -= ast _ module_info->fastplay * 114; + if (ast _ silence_cycles_counter <= 0) + return FALSE; + } + else + ast _ silence_cycles_counter = ast _ silence_cycles; + } + return TRUE; +} + +FUNC(int, ASAP_GetPosition, (P(CONST ASAP_State PTR, ast))) +{ + return ast _ blocks_played * 10 / (ASAP_SAMPLE_RATE / 100); +} + +FUNC(int, milliseconds_to_blocks, (P(int, milliseconds))) +{ + return milliseconds * (ASAP_SAMPLE_RATE / 100) / 10; +} + +#ifndef ACTIONSCRIPT + +FUNC(void, ASAP_Seek, (P(ASAP_State PTR, ast), P(int, position))) +{ + V(int, block) = milliseconds_to_blocks(position); + if (block < ast _ blocks_played) + ASAP_PlaySong(ast, ast _ current_song, ast _ current_duration); + while (ast _ blocks_played + ast _ samples - ast _ sample_index < block) { + ast _ blocks_played += ast _ samples - ast _ sample_index; + call_6502_player(ast); + } + ast _ sample_index += block - ast _ blocks_played; + ast _ blocks_played = block; +} + +PRIVATE FUNC(void, serialize_int, (P(BYTEARRAY, buffer), P(int, offset), P(int, value))) +{ + buffer[offset] = TO_BYTE(value); + buffer[offset + 1] = TO_BYTE(value >> 8); + buffer[offset + 2] = TO_BYTE(value >> 16); + buffer[offset + 3] = TO_BYTE(value >> 24); +} + +FUNC(void, ASAP_GetWavHeader, ( + P(CONST ASAP_State PTR, ast), P(BYTEARRAY, buffer), P(ASAP_SampleFormat, format))) +{ + V(int, use_16bit) = format != ASAP_FORMAT_U8 ? 1 : 0; + V(int, block_size) = ast _ module_info->channels << use_16bit; + V(int, bytes_per_second) = ASAP_SAMPLE_RATE * block_size; + V(int, total_blocks) = milliseconds_to_blocks(ast _ current_duration); + V(int, n_bytes) = (total_blocks - ast _ blocks_played) * block_size; + buffer[0] = CAST(byte) CHARCODE('R'); + buffer[1] = CAST(byte) CHARCODE('I'); + buffer[2] = CAST(byte) CHARCODE('F'); + buffer[3] = CAST(byte) CHARCODE('F'); + serialize_int(buffer, 4, n_bytes + 36); + buffer[8] = CAST(byte) CHARCODE('W'); + buffer[9] = CAST(byte) CHARCODE('A'); + buffer[10] = CAST(byte) CHARCODE('V'); + buffer[11] = CAST(byte) CHARCODE('E'); + buffer[12] = CAST(byte) CHARCODE('f'); + buffer[13] = CAST(byte) CHARCODE('m'); + buffer[14] = CAST(byte) CHARCODE('t'); + buffer[15] = CAST(byte) CHARCODE(' '); + buffer[16] = 16; + buffer[17] = 0; + buffer[18] = 0; + buffer[19] = 0; + buffer[20] = 1; + buffer[21] = 0; + buffer[22] = CAST(byte) ast _ module_info->channels; + buffer[23] = 0; + serialize_int(buffer, 24, ASAP_SAMPLE_RATE); + serialize_int(buffer, 28, bytes_per_second); + buffer[32] = CAST(byte) block_size; + buffer[33] = 0; + buffer[34] = CAST(byte) (8 << use_16bit); + buffer[35] = 0; + buffer[36] = CAST(byte) CHARCODE('d'); + buffer[37] = CAST(byte) CHARCODE('a'); + buffer[38] = CAST(byte) CHARCODE('t'); + buffer[39] = CAST(byte) CHARCODE('a'); + serialize_int(buffer, 40, n_bytes); +} + +#endif /* ACTIONSCRIPT */ + +PRIVATE FUNC(int, ASAP_GenerateAt, (P(ASAP_State PTR, ast), P(VOIDPTR, buffer), P(int, buffer_offset), P(int, buffer_len), P(ASAP_SampleFormat, format))) +{ + V(int, block_shift); + V(int, buffer_blocks); + V(int, block); + if (ast _ silence_cycles > 0 && ast _ silence_cycles_counter <= 0) + return 0; +#ifdef ACTIONSCRIPT + block_shift = 0; +#else + block_shift = (ast _ module_info->channels - 1) + (format != ASAP_FORMAT_U8 ? 1 : 0); +#endif + buffer_blocks = buffer_len >> block_shift; + if (ast _ current_duration > 0) { + V(int, total_blocks) = milliseconds_to_blocks(ast _ current_duration); + if (buffer_blocks > total_blocks - ast _ blocks_played) + buffer_blocks = total_blocks - ast _ blocks_played; + } + block = 0; + do { + V(int, blocks) = PokeySound_Generate(ast, CAST(BYTEARRAY) buffer, + buffer_offset + (block << block_shift), buffer_blocks - block, format); + ast _ blocks_played += blocks; + block += blocks; + } while (block < buffer_blocks && call_6502_player(ast)); + return block << block_shift; +} + +FUNC(int, ASAP_Generate, (P(ASAP_State PTR, ast), P(VOIDPTR, buffer), P(int, buffer_len), P(ASAP_SampleFormat, format))) +{ + return ASAP_GenerateAt(ast, buffer, 0, buffer_len, format); +} + +#endif /* ASAP_ONLY_INFO */ + +#ifdef C + +abool ASAP_CanSetModuleInfo(const char *filename) +{ + int ext = get_packed_ext(filename); + return ext == ASAP_EXT('S', 'A', 'P'); +} + +abool ASAP_ChangeExt(char *filename, const char *ext) +{ + char *dest = NULL; + while (*filename != '\0') { + if (*filename == '/' || *filename == '\\') + dest = NULL; + else if (*filename == '.') + dest = filename + 1; + filename++; + } + if (dest == NULL) + return FALSE; + strcpy(dest, ext); + return TRUE; +} + +static byte *put_string(byte *dest, const char *str) +{ + while (*str != '\0') + *dest++ = *str++; + return dest; +} + +static byte *put_dec(byte *dest, int value) +{ + if (value >= 10) { + dest = put_dec(dest, value / 10); + value %= 10; + } + *dest++ = '0' + value; + return dest; +} + +static byte *put_text_tag(byte *dest, const char *tag, const char *value) +{ + dest = put_string(dest, tag); + *dest++ = '"'; + if (*value == '\0') + value = ""; + while (*value != '\0') { + if (*value < ' ' || *value > 'z' || *value == '"' || *value == '`') + return NULL; + *dest++ = *value++; + } + *dest++ = '"'; + *dest++ = '\r'; + *dest++ = '\n'; + return dest; +} + +static byte *put_dec_tag(byte *dest, const char *tag, int value) +{ + dest = put_string(dest, tag); + dest = put_dec(dest, value); + *dest++ = '\r'; + *dest++ = '\n'; + return dest; +} + +static byte *start_sap_header(byte *dest, const ASAP_ModuleInfo *module_info) +{ + dest = put_string(dest, "SAP\r\n"); + dest = put_text_tag(dest, "AUTHOR ", module_info->author); + if (dest == NULL) + return NULL; + dest = put_text_tag(dest, "NAME ", module_info->name); + if (dest == NULL) + return NULL; + dest = put_text_tag(dest, "DATE ", module_info->date); + if (dest == NULL) + return NULL; + if (module_info->songs > 1) { + dest = put_dec_tag(dest, "SONGS ", module_info->songs); + if (module_info->default_song > 0) + dest = put_dec_tag(dest, "DEFSONG ", module_info->default_song); + } + if (module_info->channels > 1) + dest = put_string(dest, "STEREO\r\n"); + return dest; +} + +static char *two_digits(char *s, int x) +{ + s[0] = '0' + x / 10; + s[1] = '0' + x % 10; + return s + 2; +} + +void ASAP_DurationToString(char *s, int duration) +{ + if (duration >= 0 && duration < 100 * 60 * 1000) { + int seconds = duration / 1000; + s = two_digits(s, seconds / 60); + *s++ = ':'; + s = two_digits(s, seconds % 60); + duration %= 1000; + if (duration != 0) { + *s++ = '.'; + s = two_digits(s, duration / 10); + duration %= 10; + if (duration != 0) + *s++ = '0' + duration; + } + } + *s = '\0'; +} + +static byte *put_durations(byte *dest, const ASAP_ModuleInfo *module_info) +{ + int song; + for (song = 0; song < module_info->songs; song++) { + if (module_info->durations[song] < 0) + break; + dest = put_string(dest, "TIME "); + ASAP_DurationToString((char *) dest, module_info->durations[song]); + while (*dest != '\0') + dest++; + if (module_info->loops[song]) + dest = put_string(dest, " LOOP"); + *dest++ = '\r'; + *dest++ = '\n'; + } + return dest; +} + +int ASAP_SetModuleInfo(const ASAP_ModuleInfo *module_info, const BYTEARRAY module, int module_len, BYTEARRAY out_module) +{ + byte *dest; + int i; + if (memcmp(module, "SAP\r\n", 5) != 0) + return -1; + dest = start_sap_header(out_module, module_info); + if (dest == NULL) + return -1; + i = 5; + while (i < module_len && module[i] != 0xff) { + if (memcmp(module + i, "AUTHOR ", 7) == 0 + || memcmp(module + i, "NAME ", 5) == 0 + || memcmp(module + i, "DATE ", 5) == 0 + || memcmp(module + i, "SONGS ", 6) == 0 + || memcmp(module + i, "DEFSONG ", 8) == 0 + || memcmp(module + i, "STEREO\r", 7) == 0 + || memcmp(module + i, "TIME ", 5) == 0) { + while (i < module_len && module[i++] != 0x0a); + } + else { + int b; + do { + b = module[i++]; + *dest++ = b; + } while (i < module_len && b != 0x0a); + } + } + dest = put_durations(dest, module_info); + module_len -= i; + memcpy(dest, module + i, module_len); + dest += module_len; + return dest - out_module; +} + +#if !defined(ASAP_ONLY_SAP) && !defined(ASAP_ONLY_INFO) + +#define RMT_INIT 0x0c80 +#define TM2_INIT 0x1080 + +const char *ASAP_CanConvert( + const char *filename, const ASAP_ModuleInfo *module_info, + const BYTEARRAY module, int module_len) +{ + (void) filename; + switch (module_info->type) { + case ASAP_TYPE_SAP_B: + if ((module_info->init == 0x3fb || module_info->init == 0x3f9) && module_info->player == 0x503) + return "dlt"; + if (module_info->init == 0x4f3 || module_info->init == 0xf4f3 || module_info->init == 0x4ef) + return module_info->fastplay == 156 ? "mpd" : "mpt"; + if (module_info->init == RMT_INIT) + return "rmt"; + if ((module_info->init == 0x4f5 || module_info->init == 0xf4f5 || module_info->init == 0x4f2) + || ((module_info->init == 0x4e7 || module_info->init == 0xf4e7 || module_info->init == 0x4e4) && module_info->fastplay == 156) + || ((module_info->init == 0x4e5 || module_info->init == 0xf4e5 || module_info->init == 0x4e2) && (module_info->fastplay == 104 || module_info->fastplay == 78))) + return "tmc"; + if (module_info->init == TM2_INIT) + return "tm2"; + break; + case ASAP_TYPE_SAP_C: + if (module_info->player == 0x500 || module_info->player == 0xf500) { + if (module_info->fastplay == 156) + return "dmc"; + if (module_info->channels > 1) + return "cms"; + if (module[module_len - 170] == 0x1e) + return "cmr"; + if (module[module_len - 909] == 0x30) + return "cm3"; + return "cmc"; + } + break; + case ASAP_TYPE_CMC: + case ASAP_TYPE_CM3: + case ASAP_TYPE_CMR: + case ASAP_TYPE_CMS: + case ASAP_TYPE_DLT: + case ASAP_TYPE_MPT: + case ASAP_TYPE_RMT: + case ASAP_TYPE_TMC: + case ASAP_TYPE_TM2: + return "sap"; + default: + break; + } + return NULL; +} + +static byte *put_hex_tag(byte *dest, const char *tag, int value) +{ + int i; + if (value < 0) + return dest; + dest = put_string(dest, tag); + for (i = 12; i >= 0; i -= 4) { + int digit = (value >> i) & 0xf; + *dest++ = (byte) (digit + (digit < 10 ? '0' : 'A' - 10)); + } + *dest++ = '\r'; + *dest++ = '\n'; + return dest; +} + +static byte *put_sap_header(byte *dest, const ASAP_ModuleInfo *module_info, char type, int music, int init, int player) +{ + dest = start_sap_header(dest, module_info); + if (dest == NULL) + return NULL; + dest = put_string(dest, "TYPE "); + *dest++ = type; + *dest++ = '\r'; + *dest++ = '\n'; + if (module_info->fastplay != 312) + dest = put_dec_tag(dest, "FASTPLAY ", module_info->fastplay); + dest = put_hex_tag(dest, "MUSIC ", music); + dest = put_hex_tag(dest, "INIT ", init); + dest = put_hex_tag(dest, "PLAYER ", player); + dest = put_durations(dest, module_info); + return dest; +} + +int ASAP_Convert( + const char *filename, const ASAP_ModuleInfo *module_info, + const BYTEARRAY module, int module_len, BYTEARRAY out_module) +{ + (void) filename; + int out_len; + byte *dest; + int addr; + int player; + static const int tmc_player[4] = { 3, -9, -10, -10 }; + static const int tmc_init[4] = { -14, -16, -17, -17 }; + switch (module_info->type) { + case ASAP_TYPE_SAP_B: + case ASAP_TYPE_SAP_C: + out_len = UWORD(module, module_info->header_len + 4) - UWORD(module, module_info->header_len + 2) + 7; + if (out_len < 7 || module_info->header_len + out_len >= module_len) + return -1; + memcpy(out_module, module + module_info->header_len, out_len); + return out_len; + case ASAP_TYPE_CMC: + case ASAP_TYPE_CM3: + case ASAP_TYPE_CMR: + case ASAP_TYPE_CMS: + dest = put_sap_header(out_module, module_info, 'C', module_info->music, -1, module_info->player); + if (dest == NULL) + return -1; + memcpy(dest, module, module_len); + dest[0] = 0xff; /* some modules start with zeros */ + dest[1] = 0xff; + dest += module_len; + if (module_info->type == ASAP_TYPE_CM3) { + memcpy(dest, cm3_obx + 2, sizeof(cm3_obx) - 2); + dest += sizeof(cm3_obx) - 2; + } + else if (module_info->type == ASAP_TYPE_CMS) { + memcpy(dest, cms_obx + 2, sizeof(cms_obx) - 2); + dest += sizeof(cms_obx) - 2; + } + else { + memcpy(dest, cmc_obx + 2, sizeof(cmc_obx) - 2); + if (module_info->type == ASAP_TYPE_CMR) + memcpy(dest + 4 + CMR_BASS_TABLE_OFFSET, cmr_bass_table, sizeof(cmr_bass_table)); + dest += sizeof(cmc_obx) - 2; + } + return dest - out_module; + case ASAP_TYPE_DLT: + if (module_info->songs != 1) { + addr = module_info->player - 7 - module_info->songs; + dest = put_sap_header(out_module, module_info, 'B', -1, module_info->player - 7, module_info->player + 0x103); + } + else { + addr = module_info->player - 5; + dest = put_sap_header(out_module, module_info, 'B', -1, addr, module_info->player + 0x103); + } + if (dest == NULL) + return -1; + memcpy(dest, module, module_len); + if (module_len == 0x2c06) { + dest[4] = 0; + dest[5] = 0x4c; + dest[0x2c06] = 0; + } + dest += 0x2c07; + *dest++ = (byte) addr; + *dest++ = (byte) (addr >> 8); + *dest++ = dlt_obx[4]; + *dest++ = dlt_obx[5]; + if (module_info->songs != 1) { + memcpy(dest, module_info->song_pos, module_info->songs); + dest += module_info->songs; + *dest++ = 0xaa; /* tax */ + *dest++ = 0xbc; /* ldy song2pos,x */ + *dest++ = (byte) addr; + *dest++ = (byte) (addr >> 8); + } + else { + *dest++ = 0xa0; /* ldy #0 */ + *dest++ = 0; + } + *dest++ = 0x4c; /* jmp init */ + *dest++ = (byte) module_info->player; + *dest++ = (byte) ((module_info->player >> 8) + 1); + memcpy(dest, dlt_obx + 6, sizeof(dlt_obx) - 6); + dest += sizeof(dlt_obx) - 6; + return dest - out_module; + case ASAP_TYPE_MPT: + if (module_info->songs != 1) { + addr = module_info->player - 17 - module_info->songs; + dest = put_sap_header(out_module, module_info, 'B', -1, module_info->player - 17, module_info->player + 3); + } + else { + addr = module_info->player - 13; + dest = put_sap_header(out_module, module_info, 'B', -1, addr, module_info->player + 3); + } + if (dest == NULL) + return -1; + memcpy(dest, module, module_len); + dest += module_len; + *dest++ = (byte) addr; + *dest++ = (byte) (addr >> 8); + *dest++ = mpt_obx[4]; + *dest++ = mpt_obx[5]; + if (module_info->songs != 1) { + memcpy(dest, module_info->song_pos, module_info->songs); + dest += module_info->songs; + *dest++ = 0x48; /* pha */ + } + *dest++ = 0xa0; /* ldy #music; + *dest++ = 0xa2; /* ldx #>music */ + *dest++ = (byte) (module_info->music >> 8); + *dest++ = 0xa9; /* lda #0 */ + *dest++ = 0; + *dest++ = 0x20; /* jsr player */ + *dest++ = (byte) module_info->player; + *dest++ = (byte) (module_info->player >> 8); + if (module_info->songs != 1) { + *dest++ = 0x68; /* pla */ + *dest++ = 0xa8; /* tay */ + *dest++ = 0xbe; /* ldx song2pos,y */ + *dest++ = (byte) addr; + *dest++ = (byte) (addr >> 8); + } + else { + *dest++ = 0xa2; /* ldx #0 */ + *dest++ = 0; + } + *dest++ = 0xa9; /* lda #2 */ + *dest++ = 2; + memcpy(dest, mpt_obx + 6, sizeof(mpt_obx) - 6); + dest += sizeof(mpt_obx) - 6; + return dest - out_module; + case ASAP_TYPE_RMT: + dest = put_sap_header(out_module, module_info, 'B', -1, RMT_INIT, module_info->player + 3); + if (dest == NULL) + return -1; + memcpy(dest, module, module_len); + dest += module_len; + *dest++ = (byte) RMT_INIT; + *dest++ = (byte) (RMT_INIT >> 8); + if (module_info->songs != 1) { + addr = RMT_INIT + 10 + module_info->songs; + *dest++ = (byte) addr; + *dest++ = (byte) (addr >> 8); + *dest++ = 0xa8; /* tay */ + *dest++ = 0xb9; /* lda song2pos,y */ + *dest++ = (byte) (RMT_INIT + 11); + *dest++ = (byte) ((RMT_INIT + 11) >> 8); + } + else { + *dest++ = (byte) (RMT_INIT + 8); + *dest++ = (byte) ((RMT_INIT + 8) >> 8); + *dest++ = 0xa9; /* lda #0 */ + *dest++ = 0; + } + *dest++ = 0xa2; /* ldx #music; + *dest++ = 0xa0; /* ldy #>music */ + *dest++ = (byte) (module_info->music >> 8); + *dest++ = 0x4c; /* jmp player */ + *dest++ = (byte) module_info->player; + *dest++ = (byte) (module_info->player >> 8); + if (module_info->songs != 1) { + memcpy(dest, module_info->song_pos, module_info->songs); + dest += module_info->songs; + } + if (module_info->channels == 1) { + memcpy(dest, rmt4_obx + 2, sizeof(rmt4_obx) - 2); + dest += sizeof(rmt4_obx) - 2; + } + else { + memcpy(dest, rmt8_obx + 2, sizeof(rmt8_obx) - 2); + dest += sizeof(rmt8_obx) - 2; + } + return dest - out_module; + case ASAP_TYPE_TMC: + player = module_info->player + tmc_player[module[0x25] - 1]; + addr = player + tmc_init[module[0x25] - 1]; + if (module_info->songs != 1) + addr -= 3; + dest = put_sap_header(out_module, module_info, 'B', -1, addr, player); + if (dest == NULL) + return -1; + memcpy(dest, module, module_len); + dest += module_len; + *dest++ = (byte) addr; + *dest++ = (byte) (addr >> 8); + *dest++ = tmc_obx[4]; + *dest++ = tmc_obx[5]; + if (module_info->songs != 1) + *dest++ = 0x48; /* pha */ + *dest++ = 0xa0; /* ldy #music; + *dest++ = 0xa2; /* ldx #>music */ + *dest++ = (byte) (module_info->music >> 8); + *dest++ = 0xa9; /* lda #$70 */ + *dest++ = 0x70; + *dest++ = 0x20; /* jsr player */ + *dest++ = (byte) module_info->player; + *dest++ = (byte) (module_info->player >> 8); + if (module_info->songs != 1) { + *dest++ = 0x68; /* pla */ + *dest++ = 0xaa; /* tax */ + *dest++ = 0xa9; /* lda #0 */ + *dest++ = 0; + } + else { + *dest++ = 0xa9; /* lda #$60 */ + *dest++ = 0x60; + } + switch (module[0x25]) { + case 2: + *dest++ = 0x06; /* asl 0 */ + *dest++ = 0; + *dest++ = 0x4c; /* jmp player */ + *dest++ = (byte) module_info->player; + *dest++ = (byte) (module_info->player >> 8); + *dest++ = 0xa5; /* lda 0 */ + *dest++ = 0; + *dest++ = 0xe6; /* inc 0 */ + *dest++ = 0; + *dest++ = 0x4a; /* lsr @ */ + *dest++ = 0x90; /* bcc player+3 */ + *dest++ = 5; + *dest++ = 0xb0; /* bcs player+6 */ + *dest++ = 6; + break; + case 3: + case 4: + *dest++ = 0xa0; /* ldy #1 */ + *dest++ = 1; + *dest++ = 0x84; /* sty 0 */ + *dest++ = 0; + *dest++ = 0xd0; /* bne player */ + *dest++ = 10; + *dest++ = 0xc6; /* dec 0 */ + *dest++ = 0; + *dest++ = 0xd0; /* bne player+6 */ + *dest++ = 12; + *dest++ = 0xa0; /* ldy #3 */ + *dest++ = module[0x25]; + *dest++ = 0x84; /* sty 0 */ + *dest++ = 0; + *dest++ = 0xd0; /* bne player+3 */ + *dest++ = 3; + break; + default: + break; + } + memcpy(dest, tmc_obx + 6, sizeof(tmc_obx) - 6); + dest += sizeof(tmc_obx) - 6; + return dest - out_module; + case ASAP_TYPE_TM2: + dest = put_sap_header(out_module, module_info, 'B', -1, TM2_INIT, module_info->player + 3); + if (dest == NULL) + return -1; + memcpy(dest, module, module_len); + dest += module_len; + *dest++ = (byte) TM2_INIT; + *dest++ = (byte) (TM2_INIT >> 8); + if (module_info->songs != 1) { + *dest++ = (byte) (TM2_INIT + 16); + *dest++ = (byte) ((TM2_INIT + 16) >> 8); + *dest++ = 0x48; /* pha */ + } + else { + *dest++ = (byte) (TM2_INIT + 14); + *dest++ = (byte) ((TM2_INIT + 14) >> 8); + } + *dest++ = 0xa0; /* ldy #music; + *dest++ = 0xa2; /* ldx #>music */ + *dest++ = (byte) (module_info->music >> 8); + *dest++ = 0xa9; /* lda #$70 */ + *dest++ = 0x70; + *dest++ = 0x20; /* jsr player */ + *dest++ = (byte) module_info->player; + *dest++ = (byte) (module_info->player >> 8); + if (module_info->songs != 1) { + *dest++ = 0x68; /* pla */ + *dest++ = 0xaa; /* tax */ + *dest++ = 0xa9; /* lda #0 */ + *dest++ = 0; + } + else { + *dest++ = 0xa9; /* lda #0 */ + *dest++ = 0; + *dest++ = 0xaa; /* tax */ + } + *dest++ = 0x4c; /* jmp player */ + *dest++ = (byte) module_info->player; + *dest++ = (byte) (module_info->player >> 8); + memcpy(dest, tm2_obx + 2, sizeof(tm2_obx) - 2); + dest += sizeof(tm2_obx) - 2; + return dest - out_module; + default: + return -1; + } +} + +#endif /* !defined(ASAP_ONLY_SAP) && !defined(ASAP_ONLY_INFO) */ + +static abool has_two_digits(const char *s) +{ + return s[0] >= '0' && s[0] <= '9' && s[1] >= '0' && s[1] <= '9'; +} + +/* "DD/MM/YYYY", "MM/YYYY", "YYYY" -> "YYYY" */ +abool ASAP_DateToYear(const char *date, char *year) +{ + if (!has_two_digits(date)) + return FALSE; + if (date[2] == '/') { + date += 3; + if (!has_two_digits(date)) + return FALSE; + if (date[2] == '/') { + date += 3; + if (!has_two_digits(date)) + return FALSE; + } + } + if (!has_two_digits(date + 2) || date[4] != '\0') + return FALSE; + memcpy(year, date, 5); + return TRUE; +} + +#endif /* C */ diff --git a/lib/rbcodec/codecs/libasap/asap.h b/lib/rbcodec/codecs/libasap/asap.h new file mode 100644 index 0000000000..1cbf8d0100 --- /dev/null +++ b/lib/rbcodec/codecs/libasap/asap.h @@ -0,0 +1,328 @@ +/* + * asap.h - public interface of ASAP + * + * Copyright (C) 2005-2010 Piotr Fusik + * + * This file is part of ASAP (Another Slight Atari Player), + * see http://asap.sourceforge.net + * + * ASAP is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published + * by the Free Software Foundation; either version 2 of the License, + * or (at your option) any later version. + * + * ASAP is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with ASAP; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef _ASAP_H_ +#define _ASAP_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/* ASAP version. */ +#define ASAP_VERSION_MAJOR 2 +#define ASAP_VERSION_MINOR 1 +#define ASAP_VERSION_MICRO 2 +#define ASAP_VERSION "2.1.2" + +/* Short credits of the ASAP engine. */ +#define ASAP_YEARS "2005-2010" +#define ASAP_CREDITS \ + "Another Slight Atari Player (C) 2005-2010 Piotr Fusik\n" \ + "CMC, MPT, TMC, TM2 players (C) 1994-2005 Marcin Lewandowski\n" \ + "RMT player (C) 2002-2005 Radek Sterba\n" \ + "DLT player (C) 2009 Marek Konopka\n" \ + "CMS player (C) 1999 David Spilka\n" + +/* Short GPL notice. + Display after the credits. */ +#define ASAP_COPYRIGHT \ + "This program is free software; you can redistribute it and/or modify\n" \ + "it under the terms of the GNU General Public License as published\n" \ + "by the Free Software Foundation; either version 2 of the License,\n" \ + "or (at your option) any later version." + +/* Maximum length of AUTHOR, NAME and DATE tags including the terminator. */ +#define ASAP_INFO_CHARS 128 + +/* Maximum length of a "mm:ss.xxx" string including the terminator. */ +#define ASAP_DURATION_CHARS 10 + +/* Maximum length of a supported input file. + You can assume that files longer than this are not supported by ASAP. */ +#define ASAP_MODULE_MAX 65000 + +/* Maximum number of songs in a file. */ +#define ASAP_SONGS_MAX 32 + +/* Output sample rate. */ +#define ASAP_SAMPLE_RATE 44100 + +/* WAV file header length. */ +#define ASAP_WAV_HEADER_BYTES 44 + +/* Output formats. */ +typedef enum { + ASAP_FORMAT_U8 = 8, /* unsigned char */ + ASAP_FORMAT_S16_LE = 16, /* signed short, little-endian */ + ASAP_FORMAT_S16_BE = -16 /* signed short, big-endian */ +} ASAP_SampleFormat; + +/* Useful type definitions. */ +#ifndef FALSE +#define FALSE 0 +#endif +#ifndef TRUE +#define TRUE 1 +#endif +typedef int abool; +typedef unsigned char byte; + +/* Information about a music file. */ +typedef struct { + char author[ASAP_INFO_CHARS]; /* author's name */ + char name[ASAP_INFO_CHARS]; /* title */ + char date[ASAP_INFO_CHARS]; /* creation date */ + int channels; /* 1 for mono or 2 for stereo */ + int songs; /* number of subsongs */ + int default_song; /* 0-based index of the "main" subsong */ + int durations[ASAP_SONGS_MAX]; /* lengths of songs, in milliseconds, -1 = indeterminate */ + abool loops[ASAP_SONGS_MAX]; /* whether songs repeat or not */ + /* the following technical information should not be used outside ASAP. */ + abool ntsc; + int type; + int fastplay; + int music; + int init; + int player; + int covox_addr; + int header_len; + byte song_pos[ASAP_SONGS_MAX]; +} ASAP_ModuleInfo; + +/* POKEY state. + Not for use outside the ASAP engine. */ +typedef struct { + int audctl; + abool init; + int poly_index; + int div_cycles; + int mute1; + int mute2; + int mute3; + int mute4; + int audf1; + int audf2; + int audf3; + int audf4; + int audc1; + int audc2; + int audc3; + int audc4; + int tick_cycle1; + int tick_cycle2; + int tick_cycle3; + int tick_cycle4; + int period_cycles1; + int period_cycles2; + int period_cycles3; + int period_cycles4; + int reload_cycles1; + int reload_cycles3; + int out1; + int out2; + int out3; + int out4; + int delta1; + int delta2; + int delta3; + int delta4; + int skctl; + int delta_buffer[888]; +} PokeyState; + +/* Player state. + Only module_info is meant to be read outside the ASAP engine. */ +typedef struct { + int cycle; + int cpu_pc; + int cpu_a; + int cpu_x; + int cpu_y; + int cpu_s; + int cpu_nz; + int cpu_c; + int cpu_vdi; + int scanline_number; + int nearest_event_cycle; + int next_scanline_cycle; + int timer1_cycle; + int timer2_cycle; + int timer4_cycle; + int irqst; + int extra_pokey_mask; + int consol; + byte covox[4]; + PokeyState base_pokey; + PokeyState extra_pokey; + int sample_offset; + int sample_index; + int samples; + int iir_acc_left; + int iir_acc_right; + ASAP_ModuleInfo *module_info; + int tmc_per_frame; + int tmc_per_frame_counter; + int current_song; + int current_duration; + int blocks_played; + int silence_cycles; + int silence_cycles_counter; + byte poly9_lookup[511]; + byte poly17_lookup[16385]; + byte *memory; +} ASAP_State; + +/* Parses the string in the "mm:ss.xxx" format + and returns the number of milliseconds or -1 if an error occurs. */ +int ASAP_ParseDuration(const char *s); + +/* Converts number of milliseconds to a string in the "mm:ss.xxx" format. */ +void ASAP_DurationToString(char *s, int duration); + +/* Checks whether the extension of the passed filename is known to ASAP. */ +abool ASAP_IsOurFile(const char *filename); + +/* Checks whether the filename extension is known to ASAP. */ +abool ASAP_IsOurExt(const char *ext); + +/* Changes the filename extension, returns true on success. */ +abool ASAP_ChangeExt(char *filename, const char *ext); + +/* Gets information about a module. + "module_info" is the structure where the information is returned. + "filename" determines file format. + "module" is the music data (contents of the file). + "module_len" is the number of data bytes. + ASAP_GetModuleInfo() returns true on success. */ +abool ASAP_GetModuleInfo(ASAP_ModuleInfo *module_info, const char *filename, + const byte module[], int module_len); + +/* Extracts year from date. */ +abool ASAP_DateToYear(const char *date, char *year); + +/* Loads music data. + "ast" is the destination structure. + "filename" determines file format. + "module" is the music data (contents of the file). + "module_len" is the number of data bytes. + ASAP does not make copies of the passed pointers. You can overwrite + or free "filename" and "module" once this function returns. + ASAP_Load() returns true on success. + If false is returned, the structure is invalid and you cannot + call the following functions. */ +abool ASAP_Load(ASAP_State *ast, const char *filename, + const byte module[], int module_len); + +/* Enables silence detection. + Makes ASAP finish playing after the specified period of silence. + "ast" is ASAP state initialized by ASAP_Load(). + "seconds" is the minimum length of silence that ends playback. */ +void ASAP_DetectSilence(ASAP_State *ast, int seconds); + +/* Prepares ASAP to play the specified song of the loaded module. + "ast" is ASAP state initialized by ASAP_Load(). + "song" is a zero-based index which must be less than the "songs" field + of the ASAP_ModuleInfo structure. + "duration" is playback time in milliseconds - use durations[song] + unless you want to override it. -1 means indefinitely. */ +void ASAP_PlaySong(ASAP_State *ast, int song, int duration); + +/* Mutes the selected POKEY channels. + This is only useful for people who want to grab samples of individual + instruments. + "ast" is ASAP state after calling ASAP_PlaySong(). + "mask" is a bit mask which selects POKEY channels to be muted. + Bits 0-3 control the base POKEY channels, + bits 4-7 control the extra POKEY channels. */ +void ASAP_MutePokeyChannels(ASAP_State *ast, int mask); + +/* Returns current position in milliseconds. + "ast" is ASAP state initialized by ASAP_PlaySong(). */ +int ASAP_GetPosition(const ASAP_State *ast); + +/* Rewinds the current song. + "ast" is ASAP state initialized by ASAP_PlaySong(). + "position" is the requested absolute position in milliseconds. */ +void ASAP_Seek(ASAP_State *ast, int position); + +/* Fills the specified buffer with WAV file header. + "ast" is ASAP state initialized by ASAP_PlaySong() with a positive "duration". + "buffer" is buffer of ASAP_WAV_HEADER_BYTES bytes. + "format" is the format of samples. */ +void ASAP_GetWavHeader(const ASAP_State *ast, byte buffer[], + ASAP_SampleFormat format); + +/* Fills the specified buffer with generated samples. + "ast" is ASAP state initialized by ASAP_PlaySong(). + "buffer" is the destination buffer. + "buffer_len" is the length of this buffer in bytes. + "format" is the format of samples. + ASAP_Generate() returns number of bytes actually written + (less than buffer_len if reached the end of the song). + Normally you use a buffer of a few kilobytes or less, + and call ASAP_Generate() in a loop or via a callback. */ +int ASAP_Generate(ASAP_State *ast, void *buffer, int buffer_len, + ASAP_SampleFormat format); + +/* Checks whether information in the specified file can be edited. */ +abool ASAP_CanSetModuleInfo(const char *filename); + +/* Updates the specified module with author, name, date, stereo + and song durations as specified in "module_info". + "module_info" contains the new module information. + "module" is the source file contents. + "module_len" is the source file length. + "out_module" is the destination buffer of size ASAP_MODULE_MAX. + ASAP_SetModuleInfo() returns the resulting file length (number of bytes + written to "out_module") or -1 if illegal characters were found. */ +int ASAP_SetModuleInfo(const ASAP_ModuleInfo *module_info, const byte module[], + int module_len, byte out_module[]); + +/* Checks whether the specified module can be converted to another format. + "filename" determines the source format. + "module_info" contains the information about the source module, + with possibly modified public fields. + "module" is the source file contents. + "module_len" is the source file length. + ASAP_CanConvert() returns the extension of the target format + or NULL if there's no possible conversion. */ +const char *ASAP_CanConvert(const char *filename, const ASAP_ModuleInfo *module_info, + const byte module[], int module_len); + +/* Converts the specified module to the format returned by ASAP_CanConvert(). + "filename" determines the source format. + "module_info" contains the information about the source module, + with possibly modified public fields. + "module" is the source file contents. + "module_len" is the source file length. + "out_module" is the destination buffer of size ASAP_MODULE_MAX. + ASAP_Convert() returns the resulting file length (number of bytes + written to "out_module") or -1 on error. */ +int ASAP_Convert(const char *filename, const ASAP_ModuleInfo *module_info, + const byte module[], int module_len, byte out_module[]); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/lib/rbcodec/codecs/libasap/asap_internal.h b/lib/rbcodec/codecs/libasap/asap_internal.h new file mode 100644 index 0000000000..def444bc2f --- /dev/null +++ b/lib/rbcodec/codecs/libasap/asap_internal.h @@ -0,0 +1,115 @@ +/* + * asap_internal.h - private interface of ASAP + * + * Copyright (C) 2005-2010 Piotr Fusik + * + * This file is part of ASAP (Another Slight Atari Player), + * see http://asap.sourceforge.net + * + * ASAP is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published + * by the Free Software Foundation; either version 2 of the License, + * or (at your option) any later version. + * + * ASAP is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with ASAP; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef _ASAP_INTERNAL_H_ +#define _ASAP_INTERNAL_H_ + +#include "anylang.h" + +#ifndef C + +#define ASAP_SONGS_MAX 32 +#define ASAP_SAMPLE_RATE 44100 + +#endif + +#ifdef JAVA + +#define ASAP_FORMAT_U8 8 +#define ASAP_FORMAT_S16_LE 16 +#define ASAP_FORMAT_S16_BE -16 +#define ASAP_SampleFormat int + +#elif defined(CSHARP) || defined(JAVASCRIPT) + +#define ASAP_FORMAT_U8 ASAP_SampleFormat.U8 +#define ASAP_FORMAT_S16_LE ASAP_SampleFormat.S16LE +#define ASAP_FORMAT_S16_BE ASAP_SampleFormat.S16BE + +#elif defined(ACTIONSCRIPT) + +#define ASAP_SampleFormat int + +#else /* C */ + +#include "asap.h" + +int ASAP_GetByte(ASAP_State *ast, int addr); +void ASAP_PutByte(ASAP_State *ast, int addr, int data); + +void Cpu_RunScanlines(ASAP_State *ast, int scanlines); + +void PokeySound_Initialize(ASAP_State *ast); +void PokeySound_StartFrame(ASAP_State *ast); +void PokeySound_PutByte(ASAP_State *ast, int addr, int data); +int PokeySound_GetRandom(ASAP_State *ast, int addr, int cycle); +void PokeySound_EndFrame(ASAP_State *ast, int cycle_limit); +int PokeySound_Generate(ASAP_State *ast, byte buffer[], int buffer_offset, int blocks, ASAP_SampleFormat format); +abool PokeySound_IsSilent(const PokeyState *pst); +void PokeySound_Mute(const ASAP_State *ast, PokeyState *pst, int mask); + +#ifdef ASAPSCAN +abool call_6502_player(ASAP_State *ast); +extern int cpu_trace; +void trace_cpu(const ASAP_State *ast, int pc, int a, int x, int y, int s, int nz, int vdi, int c); +#endif + +#endif /* C */ + +#define V_FLAG 0x40 +#define D_FLAG 0x08 +#define I_FLAG 0x04 +#define Z_FLAG 0x02 + +#define NEVER 0x800000 + +#define DELTA_SHIFT_POKEY 20 +#define DELTA_SHIFT_GTIA 20 +#define DELTA_SHIFT_COVOX 17 + +/* 6502 player types */ +#define ASAP_TYPE_SAP_B 1 +#define ASAP_TYPE_SAP_C 2 +#define ASAP_TYPE_SAP_D 3 +#define ASAP_TYPE_SAP_S 4 +#define ASAP_TYPE_CMC 5 +#define ASAP_TYPE_CM3 6 +#define ASAP_TYPE_CMR 7 +#define ASAP_TYPE_CMS 8 +#define ASAP_TYPE_DLT 9 +#define ASAP_TYPE_MPT 10 +#define ASAP_TYPE_RMT 11 +#define ASAP_TYPE_TMC 12 +#define ASAP_TYPE_TM2 13 + +#define dGetByte(addr) UBYTE(ast _ memory[addr]) +#define dPutByte(addr, data) ast _ memory[addr] = CAST(byte) (data) +#define dGetWord(addr) (dGetByte(addr) + (dGetByte((addr) + 1) << 8)) +#define GetByte(addr) (((addr) & 0xf900) == 0xd000 ? ASAP_GetByte(ast, addr) : dGetByte(addr)) +#define PutByte(addr, data) do { if (((addr) & 0xf900) == 0xd000) ASAP_PutByte(ast, addr, data); else dPutByte(addr, data); } while (FALSE) +#define RMW_GetByte(dest, addr) do { if (((addr) >> 8) == 0xd2) { dest = ASAP_GetByte(ast, addr); ast _ cycle--; ASAP_PutByte(ast, addr, dest); ast _ cycle++; } else dest = dGetByte(addr); } while (FALSE) + +#define ASAP_MAIN_CLOCK(ast) ((ast) _ module_info->ntsc ? 1789772 : 1773447) +#define CYCLE_TO_SAMPLE(cycle) TO_INT(((cycle) * ASAP_SAMPLE_RATE + ast _ sample_offset) / ASAP_MAIN_CLOCK(ast)) + +#endif /* _ASAP_INTERNAL_H_ */ diff --git a/lib/rbcodec/codecs/libasap/libasap.make b/lib/rbcodec/codecs/libasap/libasap.make new file mode 100644 index 0000000000..cbf461d4fb --- /dev/null +++ b/lib/rbcodec/codecs/libasap/libasap.make @@ -0,0 +1,18 @@ +# __________ __ ___. +# Open \______ \ ____ ____ | | _\_ |__ _______ ___ +# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / +# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < +# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ +# \/ \/ \/ \/ \/ +# $Id$ +# + +# libasap +ASAPLIB := $(CODECDIR)/libasap.a +ASAPLIB_SRC := $(call preprocess, $(RBCODECLIB_DIR)/codecs/libasap/SOURCES) +ASAPLIB_OBJ := $(call c2obj, $(ASAPLIB_SRC)) +OTHER_SRC += $(ASAPLIB_SRC) + +$(ASAPLIB): $(ASAPLIB_OBJ) + $(SILENT)$(shell rm -f $@) + $(call PRINTS,AR $(@F))$(AR) rcs $@ $^ >/dev/null diff --git a/lib/rbcodec/codecs/libasap/players.h b/lib/rbcodec/codecs/libasap/players.h new file mode 100644 index 0000000000..fb90b0c76a --- /dev/null +++ b/lib/rbcodec/codecs/libasap/players.h @@ -0,0 +1,1386 @@ +CONST_ARRAY(byte, cmc_obx) + 255,255,0,5,220,12,76,15,11,76,120,5,76,203,7,0, + 0,0,0,0,0,0,0,0,160,227,237,227,160,240,236,225, + 249,229,242,160,246,160,178,174,177,160,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255, + 255,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,128,128,128,128,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,141,110, + 5,142,111,5,140,112,5,41,112,74,74,74,170,189,145,11, + 141,169,5,189,146,11,141,170,5,169,3,141,15,210,216,165, + 254,72,165,255,72,172,112,5,174,111,5,173,110,5,32,178, + 5,104,133,255,104,133,254,96,173,118,5,133,254,173,119,5, + 133,255,160,0,138,240,28,177,254,201,143,240,4,201,239,208, + 12,202,208,9,200,192,84,176,9,152,170,16,6,200,192,84, + 144,229,96,142,104,5,32,123,6,169,0,162,9,157,69,5, + 202,16,250,141,103,5,169,1,141,113,5,169,255,141,106,5, + 173,114,5,133,254,173,115,5,133,255,160,19,177,254,170,173, + 118,5,133,254,173,119,5,133,255,172,104,5,177,254,201,207, + 208,13,152,24,105,85,168,177,254,48,15,170,76,52,6,201, + 143,240,7,201,239,240,3,136,16,226,142,108,5,142,109,5, + 96,41,15,240,245,142,218,10,142,240,10,142,255,10,140,219, + 10,140,241,10,140,0,11,96,142,114,5,134,254,140,115,5, + 132,255,24,138,105,20,141,116,5,152,105,0,141,117,5,142, + 118,5,200,200,140,119,5,160,19,177,254,141,108,5,141,109, + 5,162,8,169,0,141,113,5,157,0,210,224,3,176,8,157, + 9,5,169,255,157,57,5,202,16,233,169,128,162,3,157,75, + 5,202,16,250,96,169,1,141,113,5,169,0,240,238,41,3, + 201,3,240,240,224,64,176,236,192,26,176,232,170,169,128,157, + 75,5,169,0,157,57,5,157,60,5,157,63,5,173,111,5, + 157,12,5,173,112,5,10,10,10,133,254,24,173,114,5,105, + 48,72,173,115,5,105,1,168,104,24,101,254,157,97,5,152, + 105,0,157,100,5,24,173,114,5,105,148,133,254,173,115,5, + 105,0,133,255,173,112,5,10,109,112,5,10,168,177,254,157, + 79,5,200,177,254,157,82,5,41,7,141,110,5,200,177,254, + 157,85,5,200,177,254,157,88,5,200,177,254,157,91,5,200, + 177,254,157,94,5,160,0,173,110,5,201,3,208,2,160,2, + 201,7,208,2,160,4,185,175,11,133,254,185,176,11,133,255, + 189,85,5,74,74,74,74,24,109,111,5,141,111,5,141,194, + 7,168,173,110,5,201,7,208,15,152,10,168,177,254,157,45, + 5,200,140,111,5,76,131,7,177,254,157,45,5,189,85,5, + 41,15,24,109,111,5,141,111,5,172,111,5,173,110,5,201, + 5,8,177,254,40,240,8,221,45,5,208,3,56,233,1,157, + 48,5,189,79,5,72,41,3,168,185,181,11,157,54,5,104, + 74,74,74,74,160,62,201,15,240,16,160,55,201,14,240,10, + 160,48,201,13,240,4,24,105,0,168,185,185,11,157,51,5, + 96,216,165,252,72,165,253,72,165,254,72,165,255,72,173,113, + 5,208,3,76,2,11,173,78,5,240,3,76,107,9,173,108, + 5,205,109,5,240,3,76,88,9,173,103,5,240,3,76,220, + 8,162,2,188,75,5,48,3,157,75,5,157,69,5,202,16, + 242,173,118,5,133,252,173,119,5,133,253,172,104,5,132,254, + 204,106,5,208,25,173,107,5,240,20,173,104,5,172,105,5, + 140,104,5,206,107,5,208,232,141,104,5,168,16,226,162,0, + 177,252,201,254,208,14,172,104,5,200,196,254,240,67,140,104, + 5,76,26,8,157,66,5,24,152,105,85,168,232,224,3,144, + 223,172,104,5,177,252,16,122,201,255,240,118,74,74,74,41, + 14,170,189,161,11,141,126,8,189,162,11,141,127,8,173,67, + 5,133,255,32,147,8,140,104,5,192,85,176,4,196,254,208, + 143,164,254,140,104,5,76,2,11,32,148,6,160,255,96,48, + 251,168,96,48,247,56,152,229,255,168,96,48,239,24,152,101, + 255,168,96,48,231,141,108,5,141,109,5,200,96,48,221,173, + 68,5,48,216,141,107,5,200,140,105,5,24,152,101,255,141, + 106,5,96,136,48,10,177,252,201,143,240,4,201,239,208,243, + 200,96,162,2,189,72,5,240,5,222,72,5,16,99,189,75, + 5,208,94,188,66,5,192,64,176,87,173,116,5,133,252,173, + 117,5,133,253,177,252,133,254,24,152,105,64,168,177,252,133, + 255,37,254,201,255,240,58,188,69,5,177,254,41,192,208,12, + 177,254,41,63,157,15,5,254,69,5,16,235,201,64,208,19, + 177,254,41,63,141,111,5,189,15,5,141,112,5,32,188,6, + 76,72,9,201,128,208,10,177,254,41,63,157,72,5,254,69, + 5,202,16,144,174,103,5,232,138,41,63,141,103,5,206,109, + 5,208,14,173,108,5,141,109,5,173,103,5,208,3,238,104, + 5,172,48,5,173,82,5,41,7,201,5,240,4,201,6,208, + 1,136,140,39,5,160,0,201,5,240,4,201,6,208,2,160, + 2,201,7,208,2,160,40,140,44,5,162,2,189,82,5,41, + 224,157,40,5,189,97,5,133,252,189,100,5,133,253,189,57, + 5,201,255,240,54,201,15,208,32,189,63,5,240,45,222,63, + 5,189,63,5,208,37,188,9,5,240,1,136,152,157,9,5, + 189,88,5,157,63,5,76,229,9,189,57,5,74,168,177,252, + 144,4,74,74,74,74,41,15,157,9,5,188,45,5,189,82, + 5,41,7,201,1,208,31,136,152,200,221,48,5,8,169,1, + 40,208,2,10,10,61,60,5,240,12,188,48,5,192,255,208, + 5,169,0,157,9,5,152,157,36,5,169,1,141,110,5,189, + 57,5,201,15,240,56,41,7,168,185,205,12,133,254,189,57, + 5,41,8,8,138,40,24,240,2,105,3,168,185,91,5,37, + 254,240,27,189,51,5,157,36,5,142,110,5,202,16,8,141, + 39,5,169,0,141,44,5,232,189,54,5,157,40,5,189,57, + 5,41,15,201,15,240,16,254,57,5,189,57,5,201,15,208, + 6,189,88,5,157,63,5,189,75,5,16,10,189,9,5,208, + 5,169,64,157,75,5,254,60,5,160,0,189,82,5,74,74, + 74,74,144,1,136,74,144,1,200,24,152,125,45,5,157,45, + 5,189,48,5,201,255,208,2,160,0,24,152,125,48,5,157, + 48,5,202,48,3,76,150,9,173,40,5,141,43,5,173,82, + 5,41,7,170,160,3,173,110,5,240,3,188,213,12,152,72, + 185,185,12,8,41,127,170,152,41,3,10,168,189,36,5,153, + 0,210,200,189,9,5,224,3,208,3,173,9,5,29,40,5, + 40,16,2,169,0,153,0,210,104,168,136,41,3,208,207,160, + 8,173,44,5,153,0,210,24,104,133,255,104,133,254,104,133, + 253,104,133,252,96,104,170,240,78,201,2,240,6,104,104,202, + 208,251,96,165,20,197,20,240,252,173,36,2,201,134,208,7, + 173,37,2,201,11,240,230,173,36,2,141,143,11,173,37,2, + 141,144,11,169,134,141,36,2,169,11,141,37,2,104,104,240, + 3,56,233,1,141,93,11,104,168,104,170,169,112,32,120,5, + 169,0,162,0,76,120,5,165,20,197,20,240,252,173,36,2, + 201,134,208,174,173,37,2,201,11,208,167,173,143,11,141,36, + 2,173,144,11,141,37,2,169,64,76,120,5,32,203,7,144, + 3,32,117,11,76,255,255,178,5,221,5,168,6,59,6,123, + 6,148,6,159,6,82,6,147,8,153,8,157,8,165,8,173, + 8,183,8,205,8,185,11,250,11,59,12,128,160,32,64,255, + 241,228,215,203,192,181,170,161,152,143,135,127,120,114,107,101, + 95,90,85,80,75,71,67,63,60,56,53,50,47,44,42,39, + 37,35,33,31,29,28,26,24,23,22,20,19,18,17,16,15, + 14,13,12,11,10,9,8,7,6,5,4,3,2,1,0,0, + 0,0,0,0,242,233,218,206,191,182,170,161,152,143,137,128, + 122,113,107,101,95,0,86,80,103,96,90,85,81,76,72,67, + 63,61,57,52,51,57,45,42,40,37,36,33,31,30,0,0, + 15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0, + 0,56,11,140,10,0,10,106,9,232,8,106,8,239,7,128, + 7,8,7,174,6,70,6,230,5,149,5,65,5,246,4,176, + 4,110,4,48,4,246,3,187,3,132,3,82,3,34,3,244, + 2,200,2,160,2,122,2,85,2,52,2,20,2,245,1,216, + 1,189,1,164,1,141,1,119,1,96,1,78,1,56,1,39, + 1,21,1,6,1,247,0,232,0,219,0,207,0,195,0,184, + 0,172,0,162,0,154,0,144,0,136,0,127,0,120,0,112, + 0,106,0,100,0,94,0,87,0,82,0,50,0,10,0,0, + 1,2,131,0,1,2,3,1,0,2,131,1,0,2,3,1, + 2,128,3,128,64,32,16,8,4,2,1,3,3,3,3,7, + 11,15,19 +END_CONST_ARRAY; +CONST_ARRAY(byte, cm3_obx) + 255,255,0,5,223,12,76,18,11,76,120,5,76,203,7,0, + 0,0,0,0,0,0,0,0,160,227,237,227,160,240,236,225, + 249,229,242,160,246,160,178,174,177,160,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255, + 255,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,128,128,128,128,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,141,110, + 5,142,111,5,140,112,5,41,112,74,74,74,170,189,148,11, + 141,169,5,189,149,11,141,170,5,169,3,141,15,210,216,165, + 254,72,165,255,72,172,112,5,174,111,5,173,110,5,32,178, + 5,104,133,255,104,133,254,96,173,118,5,133,254,173,119,5, + 133,255,160,0,138,240,28,177,254,201,143,240,4,201,239,208, + 12,202,208,9,200,192,84,176,9,152,170,16,6,200,192,84, + 144,229,96,142,104,5,32,123,6,169,0,162,9,157,69,5, + 202,16,250,141,103,5,169,1,141,113,5,169,255,141,106,5, + 173,114,5,133,254,173,115,5,133,255,160,19,177,254,170,173, + 118,5,133,254,173,119,5,133,255,172,104,5,177,254,201,207, + 208,13,152,24,105,85,168,177,254,48,15,170,76,52,6,201, + 143,240,7,201,239,240,3,136,16,226,142,108,5,142,109,5, + 96,41,15,240,245,142,221,10,142,243,10,142,2,11,140,222, + 10,140,244,10,140,3,11,96,142,114,5,134,254,140,115,5, + 132,255,24,138,105,20,141,116,5,152,105,0,141,117,5,142, + 118,5,200,200,140,119,5,160,19,177,254,141,108,5,141,109, + 5,162,8,169,0,141,113,5,157,0,210,224,3,176,8,157, + 9,5,169,255,157,57,5,202,16,233,169,128,162,3,157,75, + 5,202,16,250,96,169,1,141,113,5,169,0,240,238,41,3, + 201,3,240,240,224,64,176,236,192,26,176,232,170,169,128,157, + 75,5,169,0,157,57,5,157,60,5,157,63,5,173,111,5, + 157,12,5,173,112,5,10,10,10,133,254,24,173,114,5,105, + 48,72,173,115,5,105,1,168,104,24,101,254,157,97,5,152, + 105,0,157,100,5,24,173,114,5,105,148,133,254,173,115,5, + 105,0,133,255,173,112,5,10,109,112,5,10,168,177,254,157, + 79,5,200,177,254,157,82,5,41,7,141,110,5,200,177,254, + 157,85,5,200,177,254,157,88,5,200,177,254,157,91,5,200, + 177,254,157,94,5,160,0,173,110,5,201,3,208,2,160,2, + 201,7,208,2,160,4,185,178,11,133,254,185,179,11,133,255, + 189,85,5,74,74,74,74,24,109,111,5,141,111,5,141,194, + 7,168,173,110,5,201,7,208,15,152,10,168,177,254,157,45, + 5,200,140,111,5,76,131,7,177,254,157,45,5,189,85,5, + 41,15,24,109,111,5,141,111,5,172,111,5,173,110,5,201, + 5,8,177,254,40,240,8,221,45,5,208,3,56,233,1,157, + 48,5,189,79,5,72,41,3,168,185,184,11,157,54,5,104, + 74,74,74,74,160,62,201,15,240,16,160,55,201,14,240,10, + 160,48,201,13,240,4,24,105,0,168,185,188,11,157,51,5, + 96,216,165,252,72,165,253,72,165,254,72,165,255,72,173,113, + 5,208,3,76,5,11,173,78,5,240,3,76,110,9,173,108, + 5,205,109,5,240,3,76,91,9,173,103,5,240,3,76,220, + 8,162,2,188,75,5,48,3,157,75,5,157,69,5,202,16, + 242,173,118,5,133,252,173,119,5,133,253,172,104,5,132,254, + 204,106,5,208,25,173,107,5,240,20,173,104,5,172,105,5, + 140,104,5,206,107,5,208,232,141,104,5,168,16,226,162,0, + 177,252,201,254,208,14,172,104,5,200,196,254,240,67,140,104, + 5,76,26,8,157,66,5,24,152,105,85,168,232,224,3,144, + 223,172,104,5,177,252,16,122,201,255,240,118,74,74,74,41, + 14,170,189,164,11,141,126,8,189,165,11,141,127,8,173,67, + 5,133,255,32,147,8,140,104,5,192,85,176,4,196,254,208, + 143,164,254,140,104,5,76,5,11,32,148,6,160,255,96,48, + 251,168,96,48,247,56,152,229,255,168,96,48,239,24,152,101, + 255,168,96,48,231,141,108,5,141,109,5,200,96,48,221,173, + 68,5,48,216,141,107,5,200,140,105,5,24,152,101,255,141, + 106,5,96,136,48,10,177,252,201,143,240,4,201,239,208,243, + 200,96,162,2,189,72,5,240,5,222,72,5,16,99,189,75, + 5,208,94,188,66,5,192,64,176,87,173,116,5,133,252,173, + 117,5,133,253,177,252,133,254,24,152,105,64,168,177,252,133, + 255,37,254,201,255,240,58,188,69,5,177,254,41,192,208,12, + 177,254,41,63,157,15,5,254,69,5,16,235,201,64,208,19, + 177,254,41,63,141,111,5,189,15,5,141,112,5,32,188,6, + 76,72,9,201,128,208,10,177,254,41,63,157,72,5,254,69, + 5,202,16,144,174,103,5,232,224,48,144,2,162,0,142,103, + 5,206,109,5,208,14,173,108,5,141,109,5,173,103,5,208, + 3,238,104,5,172,48,5,173,82,5,41,7,201,5,240,4, + 201,6,208,1,136,140,39,5,160,0,201,5,240,4,201,6, + 208,2,160,2,201,7,208,2,160,40,140,44,5,162,2,189, + 82,5,41,224,157,40,5,189,97,5,133,252,189,100,5,133, + 253,189,57,5,201,255,240,54,201,15,208,32,189,63,5,240, + 45,222,63,5,189,63,5,208,37,188,9,5,240,1,136,152, + 157,9,5,189,88,5,157,63,5,76,232,9,189,57,5,74, + 168,177,252,144,4,74,74,74,74,41,15,157,9,5,188,45, + 5,189,82,5,41,7,201,1,208,31,136,152,200,221,48,5, + 8,169,1,40,208,2,10,10,61,60,5,240,12,188,48,5, + 192,255,208,5,169,0,157,9,5,152,157,36,5,169,1,141, + 110,5,189,57,5,201,15,240,56,41,7,168,185,208,12,133, + 254,189,57,5,41,8,8,138,40,24,240,2,105,3,168,185, + 91,5,37,254,240,27,189,51,5,157,36,5,142,110,5,202, + 16,8,141,39,5,169,0,141,44,5,232,189,54,5,157,40, + 5,189,57,5,41,15,201,15,240,16,254,57,5,189,57,5, + 201,15,208,6,189,88,5,157,63,5,189,75,5,16,10,189, + 9,5,208,5,169,64,157,75,5,254,60,5,160,0,189,82, + 5,74,74,74,74,144,1,136,74,144,1,200,24,152,125,45, + 5,157,45,5,189,48,5,201,255,208,2,160,0,24,152,125, + 48,5,157,48,5,202,48,3,76,153,9,173,40,5,141,43, + 5,173,82,5,41,7,170,160,3,173,110,5,240,3,188,216, + 12,152,72,185,188,12,8,41,127,170,152,41,3,10,168,189, + 36,5,153,0,210,200,189,9,5,224,3,208,3,173,9,5, + 29,40,5,40,16,2,169,0,153,0,210,104,168,136,41,3, + 208,207,160,8,173,44,5,153,0,210,24,104,133,255,104,133, + 254,104,133,253,104,133,252,96,104,170,240,78,201,2,240,6, + 104,104,202,208,251,96,165,20,197,20,240,252,173,36,2,201, + 137,208,7,173,37,2,201,11,240,230,173,36,2,141,146,11, + 173,37,2,141,147,11,169,137,141,36,2,169,11,141,37,2, + 104,104,240,3,56,233,1,141,96,11,104,168,104,170,169,112, + 32,120,5,169,0,162,0,76,120,5,165,20,197,20,240,252, + 173,36,2,201,137,208,174,173,37,2,201,11,208,167,173,146, + 11,141,36,2,173,147,11,141,37,2,169,64,76,120,5,32, + 203,7,144,3,32,120,11,76,255,255,178,5,221,5,168,6, + 59,6,123,6,148,6,159,6,82,6,147,8,153,8,157,8, + 165,8,173,8,183,8,205,8,188,11,253,11,62,12,128,160, + 32,64,255,241,228,215,203,192,181,170,161,152,143,135,127,120, + 114,107,101,95,90,85,80,75,71,67,63,60,56,53,50,47, + 44,42,39,37,35,33,31,29,28,26,24,23,22,20,19,18, + 17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2, + 1,0,0,0,0,0,0,242,233,218,206,191,182,170,161,152, + 143,137,128,122,113,107,101,95,0,86,80,103,96,90,85,81, + 76,72,67,63,61,57,52,51,57,45,42,40,37,36,33,31, + 30,0,0,15,14,13,12,11,10,9,8,7,6,5,4,3, + 2,1,0,0,56,11,140,10,0,10,106,9,232,8,106,8, + 239,7,128,7,8,7,174,6,70,6,230,5,149,5,65,5, + 246,4,176,4,110,4,48,4,246,3,187,3,132,3,82,3, + 34,3,244,2,200,2,160,2,122,2,85,2,52,2,20,2, + 245,1,216,1,189,1,164,1,141,1,119,1,96,1,78,1, + 56,1,39,1,21,1,6,1,247,0,232,0,219,0,207,0, + 195,0,184,0,172,0,162,0,154,0,144,0,136,0,127,0, + 120,0,112,0,106,0,100,0,94,0,87,0,82,0,50,0, + 10,0,0,1,2,131,0,1,2,3,1,0,2,131,1,0, + 2,3,1,2,128,3,128,64,32,16,8,4,2,1,3,3, + 3,3,7,11,15,19 +END_CONST_ARRAY; +CONST_ARRAY(byte, cms_obx) + 255,255,0,5,186,15,234,234,234,76,21,8,76,92,15,35, + 5,169,5,173,5,184,5,0,0,0,0,0,0,0,0,0, + 0,0,0,128,128,128,128,128,128,0,0,0,0,0,0,255, + 255,255,255,255,255,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,130,0,0,6,6,0, + 128,20,128,128,0,0,0,0,0,0,0,0,0,0,0,15, + 15,0,0,0,0,0,0,0,0,255,0,0,0,0,0,0, + 1,2,131,0,1,2,3,1,0,2,131,1,0,2,3,1, + 2,128,3,128,64,32,16,8,4,2,1,75,8,118,8,133, + 9,19,9,80,9,110,9,124,9,26,9,128,160,32,64,255, + 241,228,215,203,192,181,170,161,152,143,135,127,120,114,107,101, + 95,90,85,80,75,71,67,63,60,56,53,50,47,44,42,39, + 37,35,33,31,29,28,26,24,23,22,20,19,18,17,16,15, + 14,13,12,11,10,9,8,7,6,5,4,3,2,1,0,0, + 0,0,0,0,242,233,218,206,191,182,170,161,152,143,137,128, + 122,113,107,101,95,0,86,80,103,96,90,85,81,76,72,67, + 63,61,57,52,51,57,45,42,40,37,36,33,31,30,0,0, + 15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0, + 0,56,11,140,10,0,10,106,9,232,8,106,8,239,7,128, + 7,8,7,174,6,70,6,230,5,149,5,65,5,246,4,176, + 4,110,4,48,4,246,3,187,3,132,3,82,3,34,3,244, + 2,200,2,160,2,122,2,85,2,52,2,20,2,245,1,216, + 1,189,1,164,1,141,1,119,1,96,1,78,1,56,1,39, + 1,21,1,6,1,247,0,232,0,219,0,207,0,195,0,184, + 0,172,0,162,0,154,0,144,0,136,0,127,0,120,0,112, + 0,106,0,100,0,94,0,87,0,82,0,50,0,10,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,0, + 0,0,0,1,1,1,1,1,1,1,1,2,2,2,2,0, + 0,0,0,1,1,1,1,2,2,2,2,2,3,3,3,0, + 0,1,1,1,2,2,2,2,2,3,3,3,3,4,4,0, + 0,1,1,1,2,2,2,3,3,3,4,4,4,5,5,0, + 0,1,1,2,2,2,3,3,4,4,4,5,5,6,6,0, + 0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,0, + 1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,0, + 1,1,2,2,3,4,4,5,5,6,7,7,8,8,9,0, + 1,1,2,3,3,4,5,5,6,7,7,8,9,9,10,0, + 1,1,2,3,4,4,5,6,7,7,8,9,10,10,11,0, + 1,2,2,3,4,5,6,7,8,9,9,10,11,11,12,0, + 1,2,3,4,5,5,6,7,8,9,10,10,11,12,13,0, + 1,2,3,4,5,6,7,7,8,9,10,11,12,13,14,0, + 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,6, + 12,12,12,18,12,28,12,38,12,50,12,79,12,233,5,42, + 6,107,6,161,11,196,11,185,11,0,0,0,0,0,0,0, + 0,0,0,3,3,3,3,7,11,15,19,141,143,5,142,144, + 5,140,145,5,41,112,74,74,74,170,169,3,141,15,210,189, + 213,5,141,73,8,189,214,5,141,74,8,169,3,141,31,210, + 169,1,141,146,5,172,145,5,174,144,5,173,143,5,76,72, + 8,173,147,5,133,252,173,148,5,133,253,160,0,138,240,28, + 177,252,201,143,240,4,201,239,208,12,202,208,9,200,192,84, + 176,9,152,170,16,6,200,192,84,144,229,96,142,149,5,169, + 0,162,5,157,17,5,157,23,5,157,29,5,202,16,244,141, + 150,5,141,157,5,160,255,140,159,5,173,153,5,133,252,173, + 154,5,133,253,160,19,177,252,170,173,147,5,133,252,173,148, + 5,133,253,172,149,5,152,72,169,15,141,169,5,141,170,5, + 177,252,201,135,208,35,152,72,24,105,85,168,177,252,16,2, + 169,15,41,15,141,169,5,152,24,105,85,168,177,252,16,3, + 173,169,5,41,15,141,170,5,104,76,243,8,177,252,201,143, + 240,7,201,239,240,3,136,16,199,104,168,177,252,201,207,208, + 13,152,24,105,85,168,177,252,48,15,170,76,19,9,201,143, + 240,7,201,239,240,3,136,16,226,142,151,5,142,152,5,96, + 142,153,5,134,252,140,154,5,132,253,24,138,105,20,141,155, + 5,152,105,0,141,156,5,24,138,105,0,141,147,5,152,105, + 2,141,148,5,160,19,177,252,141,151,5,141,152,5,162,3, + 142,31,210,142,15,210,169,0,141,146,5,160,8,169,0,153, + 0,210,153,16,210,192,6,176,8,153,35,5,169,255,153,41, + 5,136,16,233,169,128,162,5,157,29,5,202,16,250,141,157, + 5,96,169,0,240,240,141,157,5,240,11,173,143,5,41,7, + 170,169,128,157,29,5,172,145,5,173,144,5,141,143,5,140, + 145,5,169,0,157,83,5,157,41,5,157,77,5,152,10,10, + 10,133,254,24,173,153,5,105,48,72,173,154,5,105,1,168, + 104,24,101,254,157,101,5,152,105,0,157,71,5,24,173,153, + 5,105,148,133,252,173,154,5,105,0,133,253,173,145,5,10, + 109,145,5,10,168,140,145,5,200,200,200,200,200,177,252,157, + 113,5,136,177,252,157,107,5,136,177,252,157,119,5,136,136, + 177,252,157,59,5,160,0,41,7,201,3,208,2,160,2,201, + 7,208,2,160,4,185,247,7,133,254,185,248,7,133,255,172, + 145,5,200,200,177,252,74,74,74,74,24,109,143,5,141,143, + 5,141,159,10,168,189,59,5,41,7,201,7,208,15,152,10, + 168,177,254,157,125,5,200,140,143,5,76,92,10,177,254,157, + 125,5,172,145,5,200,200,177,252,41,15,24,109,143,5,141, + 143,5,172,143,5,189,59,5,41,7,201,5,8,177,254,40, + 240,8,221,125,5,208,3,56,233,1,157,89,5,172,145,5, + 177,252,72,41,3,168,185,229,5,157,131,5,104,74,74,74, + 74,160,62,201,15,240,16,160,55,201,14,240,10,160,48,201, + 13,240,4,24,105,50,168,185,233,5,157,137,5,96,216,165, + 252,72,165,253,72,165,254,72,165,255,72,173,146,5,208,3, + 76,47,15,173,157,5,240,3,76,225,12,173,152,5,205,151, + 5,176,3,76,206,12,173,150,5,240,3,76,158,11,162,5, + 169,0,188,29,5,48,3,157,29,5,157,17,5,202,16,242, + 173,147,5,133,252,173,148,5,133,253,172,149,5,140,161,5, + 204,159,5,208,25,173,160,5,240,20,173,149,5,172,158,5, + 140,149,5,206,160,5,208,232,141,149,5,168,16,226,162,0, + 177,252,201,254,240,28,157,53,5,230,253,177,252,198,253,201, + 254,240,15,157,56,5,24,152,105,85,168,232,224,3,144,224, + 176,34,172,149,5,200,204,161,5,240,80,140,149,5,76,250, + 10,104,41,14,170,189,253,7,141,135,11,189,254,7,141,136, + 11,76,129,11,172,149,5,177,252,16,57,201,255,240,53,74, + 74,74,72,41,1,240,218,104,41,14,170,189,233,7,141,135, + 11,189,234,7,141,136,11,173,54,5,133,254,32,134,11,140, + 149,5,192,85,176,5,204,161,5,208,179,172,161,5,140,149, + 5,76,47,15,76,94,12,165,254,48,18,41,15,141,169,5, + 173,55,5,16,3,173,169,5,41,15,141,170,5,200,96,165, + 254,48,250,41,1,141,184,5,200,96,173,179,5,48,20,206, + 180,5,208,51,169,50,141,180,5,206,179,5,208,41,206,179, + 5,200,96,165,254,48,214,141,180,5,238,180,5,165,254,48, + 204,141,180,5,238,180,5,173,55,5,141,179,5,16,5,169, + 0,141,179,5,238,179,5,104,104,76,225,12,32,110,9,160, + 255,96,165,254,48,249,168,96,165,254,48,243,56,152,229,254, + 168,96,165,254,48,233,24,152,101,254,168,96,165,254,48,223, + 141,151,5,141,152,5,200,96,165,254,48,211,173,55,5,48, + 206,200,140,158,5,24,152,101,254,141,159,5,173,55,5,141, + 160,5,192,84,96,136,48,10,177,252,201,143,240,4,201,239, + 208,243,200,96,162,5,189,23,5,240,5,222,23,5,16,87, + 189,29,5,208,82,188,53,5,201,64,176,75,173,155,5,133, + 252,173,156,5,133,253,177,252,133,254,24,152,105,64,168,177, + 252,133,255,188,17,5,177,254,41,192,208,12,177,254,41,63, + 157,47,5,254,17,5,16,235,201,64,208,13,177,254,41,63, + 188,47,5,32,150,9,76,190,12,201,128,208,10,177,254,41, + 63,157,23,5,254,17,5,202,16,156,174,150,5,232,138,41, + 63,141,150,5,206,152,5,208,14,173,151,5,141,152,5,173, + 150,5,208,3,238,149,5,172,89,5,173,59,5,41,7,201, + 5,240,4,201,6,208,1,136,140,162,5,160,0,201,5,240, + 4,201,6,208,2,160,2,201,7,208,2,160,40,140,164,5, + 172,92,5,173,62,5,41,7,201,5,240,4,201,6,208,1, + 136,140,163,5,160,0,201,5,240,4,201,6,208,2,160,2, + 201,7,208,2,160,40,140,165,5,162,5,189,59,5,41,224, + 157,65,5,189,101,5,133,252,189,71,5,133,253,189,41,5, + 201,255,240,55,201,15,208,33,189,77,5,240,46,222,77,5, + 189,77,5,208,38,188,35,5,240,1,136,152,157,35,5,189, + 119,5,157,77,5,136,76,133,13,189,41,5,74,168,177,252, + 144,4,74,74,74,74,41,15,157,35,5,188,125,5,189,59, + 5,41,7,201,1,208,31,136,152,200,221,89,5,8,169,1, + 40,208,2,10,10,61,83,5,240,12,188,89,5,192,255,208, + 5,169,0,157,35,5,152,157,95,5,169,1,141,168,5,189, + 41,5,201,15,240,76,41,7,168,185,205,5,133,254,189,41, + 5,41,8,8,138,40,24,240,2,105,6,168,185,107,5,37, + 254,240,47,189,137,5,157,95,5,142,168,5,202,224,2,240, + 15,224,255,208,22,141,162,5,169,0,141,164,5,76,5,14, + 173,140,5,141,163,5,169,0,141,165,5,232,189,131,5,157, + 65,5,189,41,5,41,15,201,15,240,18,254,41,5,189,41, + 5,41,15,201,15,208,6,189,119,5,157,77,5,189,29,5, + 16,10,189,35,5,208,5,169,64,157,29,5,254,83,5,160, + 0,189,59,5,74,74,74,74,144,1,136,74,144,1,200,24, + 152,125,125,5,157,125,5,189,89,5,201,255,208,2,160,0, + 24,152,125,89,5,157,89,5,202,48,3,76,53,13,32,123, + 15,173,65,5,141,166,5,173,68,5,141,167,5,173,59,5, + 41,7,32,181,15,152,72,185,185,5,8,41,127,170,152,41, + 3,10,168,224,3,208,3,76,196,14,189,173,5,208,39,189, + 95,5,153,0,210,189,35,5,29,65,5,40,16,2,169,0, + 153,1,210,104,168,136,41,3,240,3,76,127,14,173,164,5, + 141,8,210,76,228,14,40,76,173,14,173,173,5,208,23,173, + 162,5,153,0,210,173,35,5,13,166,5,40,16,2,169,0, + 153,1,210,76,173,14,40,76,173,14,173,62,5,41,7,32, + 181,15,152,72,185,185,5,8,41,127,170,152,41,3,10,168, + 224,3,208,3,76,60,15,189,176,5,208,30,189,98,5,153, + 16,210,189,38,5,29,68,5,40,16,2,169,0,153,17,210, + 104,168,136,41,3,240,7,76,236,14,40,76,26,15,173,165, + 5,141,24,210,24,104,133,255,104,133,254,104,133,253,104,133, + 252,96,173,176,5,208,23,173,163,5,153,16,210,173,38,5, + 13,167,5,40,16,2,169,0,153,17,210,76,26,15,40,76, + 26,15,32,168,10,176,25,173,184,5,240,20,173,157,5,141, + 183,5,169,1,141,157,5,32,168,10,173,183,5,141,157,5, + 96,173,169,5,10,10,10,10,141,171,5,173,170,5,10,10, + 10,10,141,172,5,162,2,134,200,173,171,5,29,35,5,170, + 189,233,6,166,200,157,35,5,173,172,5,29,38,5,170,189, + 233,6,166,200,157,38,5,202,16,221,96,168,185,13,8,168, + 96 +END_CONST_ARRAY; +CONST_ARRAY(byte, dlt_obx) + 255,255,0,4,70,12,255,241,228,215,203,192,181,170,161,152, + 143,135,127,121,114,107,101,95,90,85,80,75,71,67,63,60, + 56,53,50,47,44,42,39,37,35,33,31,29,28,26,24,23, + 22,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6, + 5,4,255,241,228,215,242,233,218,206,191,182,170,161,152,143, + 137,128,122,113,107,101,95,92,86,80,103,96,90,85,81,76, + 72,67,63,61,57,52,51,48,45,42,40,37,36,33,31,30, + 28,27,25,0,22,21,0,10,9,8,7,6,5,4,3,2, + 1,0,242,233,218,206,242,233,218,206,191,182,170,161,152,143, + 137,128,122,113,107,101,95,92,86,80,103,96,90,85,81,76, + 72,67,63,61,57,52,51,48,45,42,40,37,36,33,31,30, + 28,27,25,0,22,21,0,10,9,8,7,6,5,4,3,2, + 1,0,242,233,218,206,255,241,228,216,202,192,181,171,162,153, + 142,135,127,120,115,108,102,97,90,85,81,75,72,67,63,60, + 57,52,51,48,45,42,40,37,36,33,31,30,28,27,25,23, + 22,21,19,18,17,16,15,14,13,12,11,10,9,8,7,6, + 5,4,3,2,1,255,76,9,5,76,200,5,76,183,5,136, + 140,54,3,169,126,141,53,3,162,6,142,51,3,162,1,142, + 52,3,32,51,5,32,95,5,32,163,5,32,139,5,169,1, + 141,50,3,169,3,141,15,210,96,162,0,160,32,142,48,3, + 140,49,3,160,0,173,48,3,153,0,2,173,49,3,153,64, + 2,173,48,3,24,105,128,141,48,3,144,3,238,49,3,200, + 192,64,208,225,96,162,0,160,68,142,48,3,140,49,3,160, + 0,173,48,3,153,128,2,173,49,3,153,160,2,173,48,3, + 24,105,64,141,48,3,144,3,238,49,3,200,192,32,208,225, + 96,173,0,76,41,1,74,106,106,168,162,0,185,128,4,157, + 64,4,200,232,224,64,208,244,96,160,3,169,0,153,40,3, + 153,32,3,153,36,3,153,44,3,136,16,241,96,169,0,141, + 50,3,160,7,169,0,153,0,210,136,16,250,96,96,173,50, + 3,240,250,173,40,3,13,41,3,13,42,3,13,43,3,141, + 8,210,174,36,3,172,32,3,142,0,210,140,1,210,174,37, + 3,172,33,3,142,2,210,140,3,210,174,38,3,172,34,3, + 142,4,210,140,5,210,174,39,3,172,35,3,142,6,210,140, + 7,210,206,52,3,208,74,173,51,3,141,52,3,238,53,3, + 238,53,3,16,28,238,54,3,169,0,141,53,3,32,199,6, + 173,4,3,13,5,3,13,6,3,13,7,3,208,3,76,183, + 5,173,4,3,240,3,32,97,7,173,5,3,240,3,32,192, + 7,173,6,3,240,3,32,31,8,173,7,3,240,3,32,126, + 8,173,4,3,240,8,173,44,3,240,3,32,221,8,173,5, + 3,240,8,173,45,3,240,3,32,206,9,173,6,3,240,8, + 173,46,3,240,3,32,191,10,173,7,3,240,8,173,47,3, + 240,3,32,131,11,96,192,67,144,14,169,0,141,4,3,141, + 32,3,141,40,3,76,230,6,192,66,208,15,189,128,64,141, + 51,3,141,52,3,238,54,3,76,199,6,192,65,208,9,189, + 128,64,141,54,3,76,199,6,104,104,76,183,5,174,54,3, + 188,0,64,192,64,176,191,189,128,64,141,24,3,185,0,2, + 133,224,185,64,2,133,225,169,1,141,4,3,188,0,65,192, + 64,176,78,189,128,65,141,25,3,185,0,2,133,226,185,64, + 2,133,227,169,1,141,5,3,188,0,66,192,64,176,63,189, + 128,66,141,26,3,185,0,2,133,228,185,64,2,133,229,169, + 1,141,6,3,188,0,67,192,64,176,48,189,128,67,141,27, + 3,185,0,2,133,230,185,64,2,133,231,169,1,141,7,3, + 96,169,0,141,5,3,141,33,3,141,41,3,240,186,169,0, + 141,6,3,141,34,3,141,42,3,240,201,169,0,141,7,3, + 141,35,3,141,43,3,96,172,53,3,177,224,48,11,200,177, + 224,48,1,96,104,104,76,31,6,24,109,24,3,41,127,141, + 8,3,169,15,141,0,3,141,44,3,200,177,224,170,189,160, + 2,133,233,133,241,133,249,189,128,2,133,232,73,16,133,240, + 73,48,133,248,160,49,177,232,141,12,3,160,51,177,232,41, + 127,141,16,3,169,0,141,20,3,141,28,3,160,48,177,232, + 41,213,141,40,3,96,172,53,3,177,226,48,11,200,177,226, + 48,1,96,104,104,76,31,6,24,109,25,3,41,127,141,9, + 3,169,15,141,1,3,141,45,3,200,177,226,170,189,160,2, + 133,235,133,243,133,251,189,128,2,133,234,73,16,133,242,73, + 48,133,250,160,49,177,234,141,13,3,160,51,177,234,41,127, + 141,17,3,169,0,141,21,3,141,29,3,160,48,177,234,41, + 131,141,41,3,96,172,53,3,177,228,48,11,200,177,228,48, + 1,96,104,104,76,31,6,24,109,26,3,41,127,141,10,3, + 169,15,141,2,3,141,46,3,200,177,228,170,189,160,2,133, + 237,133,245,133,253,189,128,2,133,236,73,16,133,244,73,48, + 133,252,160,49,177,236,141,14,3,160,51,177,236,41,127,141, + 18,3,169,0,141,22,3,141,30,3,160,48,177,236,41,169, + 141,42,3,96,172,53,3,177,230,48,11,200,177,230,48,1, + 96,104,104,76,31,6,24,109,27,3,41,127,141,11,3,169, + 15,141,3,3,141,47,3,200,177,230,170,189,160,2,133,239, + 133,247,133,255,189,128,2,133,238,73,16,133,246,73,48,133, + 254,160,49,177,238,141,15,3,160,51,177,238,41,127,141,19, + 3,169,0,141,23,3,141,31,3,160,48,177,238,41,129,141, + 43,3,96,172,0,3,48,70,177,232,141,32,3,177,240,208, + 9,32,108,9,206,0,3,76,79,9,201,1,240,39,201,3, + 208,16,173,8,3,24,113,248,170,173,28,3,141,55,3,76, + 24,9,173,28,3,24,113,248,141,55,3,174,8,3,32,150, + 9,206,0,3,96,177,248,141,36,3,206,0,3,96,32,108, + 9,160,49,177,232,240,30,206,12,3,240,3,76,79,9,173, + 32,3,41,15,240,11,206,32,3,177,232,141,12,3,76,79, + 9,141,44,3,96,173,28,3,24,160,50,113,232,141,28,3, + 206,16,3,208,12,238,20,3,160,51,177,232,41,127,141,16, + 3,96,173,20,3,41,3,24,105,52,168,177,232,170,160,51, + 177,232,48,14,138,109,8,3,170,173,28,3,141,55,3,76, + 150,9,138,109,28,3,141,55,3,174,8,3,189,0,4,24, + 109,55,3,141,36,3,173,40,3,41,4,208,1,96,172,0, + 3,177,240,208,21,138,24,160,0,113,248,170,189,0,4,24, + 109,55,3,24,105,255,141,38,3,96,173,36,3,24,105,255, + 141,38,3,96,172,1,3,48,70,177,234,141,33,3,177,242, + 208,9,32,93,10,206,1,3,76,64,10,201,1,240,39,201, + 3,208,16,173,9,3,24,113,250,170,173,29,3,141,55,3, + 76,9,10,173,29,3,24,113,250,141,55,3,174,9,3,32, + 135,10,206,1,3,96,177,250,141,37,3,206,1,3,96,32, + 93,10,160,49,177,234,240,30,206,13,3,240,3,76,64,10, + 173,33,3,41,15,240,11,206,33,3,177,234,141,13,3,76, + 64,10,141,45,3,96,173,29,3,24,160,50,113,234,141,29, + 3,206,17,3,208,12,238,21,3,160,51,177,234,41,127,141, + 17,3,96,173,21,3,41,3,24,105,52,168,177,234,170,160, + 51,177,234,48,14,138,109,9,3,170,173,29,3,141,55,3, + 76,135,10,138,109,29,3,141,55,3,174,9,3,189,0,4, + 24,109,55,3,141,37,3,173,41,3,41,2,208,1,96,172, + 1,3,177,242,208,21,138,24,160,0,113,250,170,189,0,4, + 24,109,55,3,24,105,255,141,39,3,96,173,37,3,24,105, + 255,141,39,3,96,172,2,3,48,70,177,236,141,34,3,177, + 244,208,9,32,78,11,206,2,3,76,49,11,201,1,240,39, + 201,3,208,16,173,10,3,24,113,252,170,173,30,3,141,55, + 3,76,250,10,173,30,3,24,113,252,141,55,3,174,10,3, + 32,120,11,206,2,3,96,177,252,141,38,3,206,2,3,96, + 32,78,11,160,49,177,236,240,30,206,14,3,240,3,76,49, + 11,173,34,3,41,15,240,11,206,34,3,177,236,141,14,3, + 76,49,11,141,46,3,96,173,30,3,24,160,50,113,236,141, + 30,3,206,18,3,208,12,238,22,3,160,51,177,236,41,127, + 141,18,3,96,173,22,3,41,3,24,105,52,168,177,236,170, + 160,51,177,236,48,14,138,109,10,3,170,173,30,3,141,55, + 3,76,120,11,138,109,30,3,141,55,3,174,10,3,189,0, + 4,24,109,55,3,141,38,3,96,172,3,3,48,70,177,238, + 141,35,3,177,246,208,9,32,18,12,206,3,3,76,245,11, + 201,1,240,39,201,3,208,16,173,11,3,24,113,254,170,173, + 31,3,141,55,3,76,190,11,173,31,3,24,113,254,141,55, + 3,174,11,3,32,60,12,206,3,3,96,177,254,141,39,3, + 206,3,3,96,32,18,12,160,49,177,238,240,30,206,15,3, + 240,3,76,245,11,173,35,3,41,15,240,11,206,35,3,177, + 238,141,15,3,76,245,11,141,47,3,96,173,31,3,24,160, + 50,113,238,141,31,3,206,19,3,208,12,238,23,3,160,51, + 177,238,41,127,141,19,3,96,173,23,3,41,3,24,105,52, + 168,177,238,170,160,51,177,238,48,14,138,109,11,3,170,173, + 31,3,141,55,3,76,60,12,138,109,31,3,141,55,3,174, + 11,3,189,0,4,24,109,55,3,141,39,3,96 +END_CONST_ARRAY; +CONST_ARRAY(byte, mpt_obx) + 255,255,0,5,178,13,76,205,11,173,46,7,208,1,96,169, + 0,141,28,14,238,29,14,173,23,14,205,187,13,144,80,206, + 21,14,240,3,76,197,5,162,0,142,23,14,169,0,157,237, + 13,157,245,13,189,179,13,133,236,189,183,13,133,237,172,22, + 14,177,236,200,201,255,240,7,201,254,208,15,76,42,12,177, + 236,48,249,10,168,140,22,14,76,59,5,157,233,13,177,236, + 157,213,13,232,224,4,208,196,200,140,22,14,76,197,5,206, + 21,14,16,87,173,188,13,141,21,14,162,3,222,245,13,16, + 68,189,233,13,10,168,185,255,255,133,236,200,185,255,255,133, + 237,5,236,240,48,189,237,13,141,31,14,32,62,7,172,31, + 14,200,152,157,237,13,189,241,13,157,245,13,224,2,208,21, + 189,197,13,73,15,10,10,10,10,105,69,141,161,13,169,10, + 105,0,141,162,13,202,16,180,238,23,14,162,1,173,27,14, + 201,2,240,2,162,3,173,27,14,201,2,208,5,236,25,14, + 240,3,76,118,6,181,240,61,114,6,240,18,160,40,177,236, + 24,125,225,13,32,117,9,56,125,1,14,157,203,13,202,16, + 213,169,3,141,15,210,165,241,41,16,240,15,172,226,13,185, + 198,9,141,201,13,185,5,10,141,202,13,173,201,13,141,0, + 210,173,202,13,141,2,210,173,203,13,141,4,210,173,204,13, + 141,6,210,173,193,13,162,255,172,27,14,192,1,208,5,174, + 25,14,240,3,141,1,210,173,194,13,224,1,240,3,141,3, + 210,192,2,240,20,173,195,13,224,2,240,3,141,5,210,173, + 196,13,224,3,240,3,141,7,210,165,240,5,241,5,242,5, + 243,13,28,14,141,8,210,96,4,2,0,0,189,217,13,133, + 236,189,221,13,133,237,5,236,208,8,157,193,13,149,240,76, + 248,5,180,244,192,32,240,66,177,236,56,253,197,13,44,58, + 7,240,2,41,240,157,193,13,200,177,236,141,30,14,200,148, + 244,41,7,240,60,168,185,126,9,141,203,6,185,133,9,141, + 204,6,173,30,14,74,74,74,74,74,9,40,168,177,236,24, + 32,255,255,169,0,149,240,76,248,5,189,9,14,240,18,222, + 13,14,208,13,157,13,14,189,193,13,41,15,240,3,222,193, + 13,160,35,177,236,149,240,189,17,14,24,105,37,168,41,3, + 157,17,14,136,177,236,125,209,13,157,225,13,32,119,9,157, + 201,13,189,5,14,240,6,222,5,14,76,223,5,189,189,13, + 141,30,7,16,254,76,194,8,0,76,229,8,0,76,251,8, + 0,76,21,9,0,76,37,9,0,76,56,9,0,76,66,9, + 16,76,72,9,169,0,157,197,13,172,31,14,136,200,177,236, + 201,254,208,4,140,31,14,96,201,224,144,8,173,187,13,141, + 23,14,208,233,201,208,144,10,41,15,141,188,13,141,21,14, + 16,219,201,192,144,9,41,15,73,15,157,197,13,16,206,201, + 128,144,7,41,63,157,241,13,16,195,201,64,144,27,200,140, + 31,14,41,31,157,229,13,10,168,185,255,255,157,217,13,200, + 185,255,255,157,221,13,76,62,7,140,31,14,141,30,14,24, + 125,213,13,157,209,13,173,27,14,240,66,201,2,240,58,189, + 229,13,201,31,208,55,173,30,14,56,233,1,41,15,168,177, + 254,133,253,152,9,16,168,177,254,133,248,160,1,5,253,208, + 2,160,0,140,26,14,169,0,133,252,157,217,13,157,221,13, + 138,10,141,24,14,142,25,14,96,224,2,176,99,189,217,13, + 133,238,189,221,13,133,239,5,238,240,74,160,32,177,238,41, + 15,157,249,13,177,238,41,112,74,74,157,189,13,200,177,238, + 10,10,72,41,63,157,5,14,104,41,192,157,205,13,200,177, + 238,157,9,14,157,13,14,169,0,149,244,157,17,14,157,253, + 13,157,1,14,189,209,13,157,225,13,32,117,9,157,201,13, + 236,25,14,240,1,96,160,255,140,25,14,200,140,26,14,96, + 224,2,208,51,172,211,13,185,69,11,141,121,13,185,129,11, + 141,127,13,169,0,133,249,133,250,173,231,13,41,15,168,177, + 254,133,251,152,9,16,168,177,254,141,137,13,5,251,208,6, + 141,121,13,141,127,13,96,173,232,13,41,15,168,177,254,133, + 253,152,9,16,168,177,254,5,253,240,15,177,254,56,229,253, + 133,248,169,0,133,252,169,141,208,2,169,173,141,97,13,141, + 56,13,169,24,141,7,210,96,173,29,14,41,7,74,74,144, + 18,208,24,189,249,13,24,157,1,14,125,201,13,157,201,13, + 76,223,5,169,0,157,1,14,76,223,5,189,201,13,56,253, + 249,13,157,201,13,56,169,0,253,249,13,157,1,14,76,223, + 5,189,253,13,24,157,1,14,125,201,13,157,201,13,24,189, + 253,13,125,249,13,157,253,13,76,223,5,189,225,13,56,253, + 253,13,157,225,13,32,117,9,76,5,9,169,0,56,253,253, + 13,157,1,14,189,201,13,56,253,253,13,76,5,9,189,225, + 13,24,125,253,13,76,28,9,32,85,9,76,208,8,32,85, + 9,24,125,225,13,32,155,9,76,223,5,188,253,13,189,249, + 13,48,2,200,200,136,152,157,253,13,221,249,13,208,8,189, + 249,13,73,255,157,249,13,189,253,13,96,41,63,29,205,13, + 168,185,255,255,96,148,145,152,165,173,180,192,9,9,9,9, + 9,9,9,64,0,32,0,125,201,13,157,201,13,96,125,209, + 13,157,225,13,32,117,9,157,201,13,96,157,201,13,189,141, + 9,16,12,157,201,13,169,128,208,5,157,201,13,169,1,13, + 28,14,141,28,14,96,45,10,210,157,201,13,96,242,51,150, + 226,56,140,0,106,232,106,239,128,8,174,70,230,149,65,246, + 176,110,48,246,187,132,82,34,244,200,160,122,85,52,20,245, + 216,189,164,141,119,96,78,56,39,21,6,247,232,219,207,195, + 184,172,162,154,144,136,127,120,112,106,100,94,13,13,12,11, + 11,10,10,9,8,8,7,7,7,6,6,5,5,5,4,4, + 4,4,3,3,3,3,3,2,2,2,2,2,2,2,1,1, + 1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,24,24,24,24,24, + 24,24,24,24,24,24,24,24,24,24,24,22,22,23,23,23, + 23,24,24,24,24,24,25,25,25,25,26,21,21,22,22,22, + 23,23,24,24,24,25,25,26,26,26,27,20,21,21,22,22, + 23,23,24,24,24,25,25,26,26,27,27,20,20,21,21,22, + 22,23,23,24,25,25,26,26,27,27,28,19,20,20,21,22, + 22,23,23,24,25,25,26,26,27,28,28,19,19,20,21,21, + 22,23,23,24,25,25,26,27,27,28,29,18,19,20,20,21, + 22,23,23,24,25,25,26,27,28,28,29,18,19,19,20,21, + 22,22,23,24,25,26,26,27,28,29,29,18,18,19,20,21, + 22,22,23,24,25,26,26,27,28,29,30,17,18,19,20,21, + 22,22,23,24,25,26,26,27,28,29,30,17,18,19,20,21, + 21,22,23,24,25,26,27,27,28,29,30,17,18,19,20,20, + 21,22,23,24,25,26,27,28,28,29,30,17,18,19,19,20, + 21,22,23,24,25,26,27,28,29,29,30,17,18,18,19,20, + 21,22,23,24,25,26,27,28,29,30,30,16,17,18,19,20, + 21,22,23,24,25,26,27,28,29,30,31,32,34,36,38,41, + 43,46,48,51,55,58,61,65,69,73,77,82,87,92,97,103, + 110,116,123,130,138,146,155,164,174,184,195,207,220,233,246,5, + 21,37,55,73,93,113,135,159,184,210,237,11,42,75,110,147, + 186,227,15,62,112,164,219,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1, + 1,1,1,1,1,1,1,2,2,2,2,2,2,2,3,3, + 3,3,3,229,42,64,89,100,238,8,166,11,12,12,12,12, + 12,13,13,142,50,7,140,54,7,41,7,168,185,189,11,141, + 227,11,185,197,11,141,228,11,76,255,255,173,54,7,174,50, + 7,141,148,7,141,155,7,142,149,7,142,156,7,24,105,64, + 141,129,5,141,135,5,144,1,232,142,130,5,142,136,5,24, + 105,128,141,124,9,144,1,232,142,125,9,232,141,31,12,142, + 32,12,162,9,189,255,255,157,179,13,202,16,247,206,188,13, + 169,0,141,46,7,162,98,157,189,13,202,16,250,162,8,157, + 0,210,202,16,250,96,32,42,12,173,50,7,10,141,22,14, + 173,187,13,141,23,14,169,1,141,21,14,141,46,7,96,173, + 54,7,133,254,173,50,7,133,255,96,173,54,7,41,3,170, + 173,50,7,32,198,7,173,26,14,240,238,14,54,7,32,190, + 12,169,1,141,27,14,173,26,14,240,222,201,1,208,5,160, + 0,238,26,14,177,252,174,24,14,74,74,74,74,9,16,141, + 10,212,141,10,212,157,1,210,177,252,9,16,141,10,212,141, + 10,212,157,1,210,200,208,206,230,253,165,253,197,248,208,198, + 140,26,14,96,144,21,169,234,141,153,12,141,154,12,141,155, + 12,141,166,12,141,167,12,141,168,12,96,169,141,141,153,12, + 141,166,12,169,10,141,154,12,141,167,12,169,212,141,155,12, + 141,168,12,96,169,0,141,26,14,173,50,7,74,32,190,12, + 169,1,141,27,14,32,128,12,173,27,14,208,248,96,169,2, + 141,27,14,141,25,14,169,24,141,7,210,169,17,133,250,169, + 13,133,251,169,173,141,97,13,141,56,13,160,0,140,121,13, + 140,127,13,174,11,212,177,252,74,74,74,74,9,16,141,7, + 210,32,117,13,236,11,212,240,251,141,5,210,174,11,212,177, + 252,230,252,208,16,230,253,198,248,208,10,169,173,141,97,13, + 141,56,13,169,8,9,16,141,7,210,32,117,13,236,11,212, + 240,251,141,5,210,173,27,14,208,185,96,24,165,249,105,0, + 133,249,165,250,105,0,133,250,144,15,230,251,165,251,201,0, + 208,7,140,121,13,140,127,13,96,177,250,36,249,48,4,74, + 74,74,74,41,15,168,185,69,10,160,0,96,160,0,140,27, + 14,140,26,14,136,140,25,14,96 +END_CONST_ARRAY; +CONST_ARRAY(byte, rmt4_obx) + 255,255,144,3,96,11,128,0,128,32,128,64,0,192,128,128, + 128,160,0,192,64,192,0,1,5,11,21,0,1,255,255,1, + 1,0,255,255,0,1,1,1,0,255,255,255,255,0,1,1, + 0,0,0,0,0,0,242,51,150,226,56,140,0,106,232,106, + 239,128,8,174,70,230,149,65,246,176,110,48,246,187,132,82, + 34,244,200,160,122,85,52,20,245,216,189,164,141,119,96,78, + 56,39,21,6,247,232,219,207,195,184,172,162,154,144,136,127, + 120,112,106,100,94,0,191,182,170,161,152,143,137,128,242,230, + 218,206,191,182,170,161,152,143,137,128,122,113,107,101,95,92, + 86,80,77,71,68,62,60,56,53,50,47,45,42,40,37,35, + 33,31,29,28,26,24,23,22,20,19,18,17,16,15,14,13, + 12,11,10,9,8,7,255,241,228,216,202,192,181,171,162,153, + 142,135,127,121,115,112,102,97,90,85,82,75,72,67,63,60, + 57,55,51,48,45,42,40,37,36,33,31,30,28,27,25,23, + 22,21,19,18,17,16,15,14,13,12,11,10,9,8,7,6, + 5,4,3,2,1,0,243,230,217,204,193,181,173,162,153,144, + 136,128,121,114,108,102,96,91,85,81,76,72,68,64,60,57, + 53,50,47,45,42,40,37,35,33,31,29,28,26,24,23,22, + 20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5, + 4,3,2,1,0,0,13,13,12,11,11,10,10,9,8,8, + 7,7,7,6,6,5,5,5,4,4,4,4,3,3,3,3, + 3,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1, + 1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1, + 1,1,1,1,1,1,0,0,0,0,1,1,1,1,1,1, + 1,1,2,2,2,2,0,0,0,1,1,1,1,1,2,2, + 2,2,2,3,3,3,0,0,1,1,1,1,2,2,2,2, + 3,3,3,3,4,4,0,0,1,1,1,2,2,2,3,3, + 3,4,4,4,5,5,0,0,1,1,2,2,2,3,3,4, + 4,4,5,5,6,6,0,0,1,1,2,2,3,3,4,4, + 5,5,6,6,7,7,0,1,1,2,2,3,3,4,4,5, + 5,6,6,7,7,8,0,1,1,2,2,3,4,4,5,5, + 6,7,7,8,8,9,0,1,1,2,3,3,4,5,5,6, + 7,7,8,9,9,10,0,1,1,2,3,4,4,5,6,7, + 7,8,9,10,10,11,0,1,2,2,3,4,5,6,6,7, + 8,9,10,10,11,12,0,1,2,3,3,4,5,6,7,8, + 9,10,10,11,12,13,0,1,2,3,4,5,6,7,7,8, + 9,10,11,12,13,14,0,1,2,3,4,5,6,7,8,9, + 10,11,12,13,14,15,76,15,6,76,252,7,76,33,8,76, + 88,6,76,43,11,134,211,132,212,72,160,168,169,0,153,127, + 2,136,208,250,160,4,177,211,141,21,8,200,177,211,141,36, + 3,200,177,211,141,5,8,141,38,3,160,8,177,211,153,195, + 0,200,192,16,208,246,104,72,10,10,24,101,209,133,209,104, + 8,41,192,10,42,42,40,101,210,133,210,32,110,6,169,0, + 141,8,210,160,3,140,15,210,160,8,153,0,210,136,16,250, + 173,5,8,96,162,0,142,39,3,138,168,177,209,201,254,176, + 45,168,177,205,157,128,2,177,207,157,132,2,169,0,157,136, + 2,169,1,157,140,2,169,128,157,180,2,232,224,4,208,217, + 165,209,24,105,4,133,209,144,27,230,210,76,190,6,240,4, + 169,0,240,223,160,2,177,209,170,200,177,209,133,210,134,209, + 162,0,240,181,173,36,3,141,22,7,162,255,232,222,140,2, + 208,69,189,128,2,133,211,189,132,2,133,212,188,136,2,254, + 136,2,177,211,133,217,41,63,201,61,240,17,176,56,157,144, + 2,157,16,3,200,177,211,74,41,126,157,180,2,169,1,157, + 140,2,188,136,2,254,136,2,177,211,74,102,217,74,102,217, + 165,217,41,240,157,148,2,224,3,208,177,169,255,141,36,3, + 141,37,3,76,101,7,201,63,240,27,165,217,41,192,240,9, + 10,42,42,157,140,2,76,17,7,200,177,211,157,140,2,254, + 136,2,76,17,7,165,217,48,12,200,177,211,141,22,7,254, + 136,2,76,214,6,201,255,240,9,200,177,211,157,136,2,76, + 214,6,76,110,6,76,33,8,202,48,250,188,180,2,48,248, + 177,203,157,184,2,133,215,200,177,203,157,188,2,133,216,169, + 1,157,20,3,168,177,215,157,4,3,200,177,215,157,196,2, + 200,177,215,157,200,2,200,177,215,157,240,2,41,63,157,8, + 3,177,215,41,64,157,244,2,200,177,215,157,32,3,200,177, + 215,157,208,2,200,177,215,157,216,2,200,177,215,157,220,2, + 200,177,215,168,185,160,3,157,224,2,157,228,2,185,161,3, + 157,232,2,160,10,177,215,157,236,2,169,128,157,212,2,157, + 180,2,10,157,204,2,157,156,2,168,177,215,157,0,3,105, + 0,157,192,2,169,12,157,252,2,168,177,215,157,248,2,76, + 98,7,32,43,11,206,38,3,208,29,169,255,141,38,3,206, + 37,3,208,19,238,39,3,173,39,3,201,255,240,3,76,190, + 6,76,110,6,76,95,10,169,4,133,214,162,3,189,188,2, + 240,242,133,212,189,184,2,133,211,188,192,2,177,211,133,217, + 200,177,211,133,218,200,177,211,133,219,200,152,221,196,2,144, + 10,240,8,169,128,157,204,2,189,200,2,157,192,2,165,217, + 41,15,29,148,2,168,185,0,5,133,220,165,218,41,14,168, + 185,144,3,133,213,165,220,25,145,3,157,28,3,189,220,2, + 240,40,201,1,208,33,189,156,2,24,125,236,2,24,188,224, + 2,121,165,3,157,156,2,200,152,221,232,2,208,3,189,228, + 2,157,224,2,76,164,8,222,220,2,188,0,3,192,13,144, + 60,189,8,3,16,49,152,221,252,2,208,8,189,4,3,157, + 252,2,208,3,254,252,2,189,184,2,133,215,189,188,2,133, + 216,188,252,2,177,215,188,244,2,240,4,24,125,248,2,157, + 248,2,189,240,2,41,63,56,233,1,157,8,3,189,204,2, + 16,31,189,148,2,240,26,221,216,2,240,21,144,19,168,189, + 212,2,24,125,208,2,157,212,2,144,6,152,233,16,157,148, + 2,169,0,133,221,165,218,157,12,3,41,112,74,74,141,28, + 9,144,254,76,210,9,234,76,60,9,234,76,65,9,234,76, + 75,9,234,76,87,9,234,76,102,9,234,76,169,9,234,76, + 184,9,165,219,76,21,10,165,219,133,221,189,144,2,76,216, + 9,189,144,2,24,101,219,157,144,2,76,216,9,189,156,2, + 24,101,219,157,156,2,189,144,2,76,216,9,189,240,2,16, + 12,188,144,2,177,213,24,125,248,2,76,135,9,189,144,2, + 24,125,248,2,201,61,144,2,169,63,168,177,213,157,160,2, + 164,219,208,3,157,164,2,152,74,74,74,74,157,168,2,157, + 172,2,165,219,41,15,157,176,2,189,144,2,76,216,9,165, + 219,24,125,20,3,157,20,3,189,144,2,76,216,9,165,219, + 201,128,240,6,157,144,2,76,216,9,189,28,3,9,240,157, + 28,3,189,144,2,76,216,9,189,144,2,24,101,219,188,240, + 2,48,31,24,125,248,2,201,61,144,7,169,0,157,28,3, + 169,63,157,16,3,168,177,213,24,125,156,2,24,101,221,76, + 21,10,201,61,144,7,169,0,157,28,3,169,63,168,189,156, + 2,24,125,248,2,24,113,213,24,101,221,157,24,3,189,172, + 2,240,50,222,172,2,208,45,189,168,2,157,172,2,189,164, + 2,221,160,2,240,31,176,13,125,176,2,176,18,221,160,2, + 176,13,76,76,10,253,176,2,144,5,221,160,2,176,3,189, + 160,2,157,164,2,165,218,41,1,240,10,189,164,2,24,125, + 156,2,157,24,3,202,48,3,76,39,8,173,32,3,13,33, + 3,13,34,3,13,35,3,170,142,44,11,173,12,3,16,33, + 173,28,3,41,15,240,26,173,24,3,24,109,20,3,141,26, + 3,173,30,3,41,16,208,5,169,0,141,30,3,138,9,4, + 170,173,13,3,16,33,173,29,3,41,15,240,26,173,25,3, + 24,109,21,3,141,27,3,173,31,3,41,16,208,5,169,0, + 141,31,3,138,9,2,170,236,44,11,208,94,173,13,3,41, + 14,201,6,208,38,173,29,3,41,15,240,31,172,17,3,185, + 192,3,141,24,3,185,192,4,141,25,3,173,28,3,41,16, + 208,5,169,0,141,28,3,138,9,80,170,173,15,3,41,14, + 201,6,208,38,173,31,3,41,15,240,31,172,19,3,185,192, + 3,141,26,3,185,192,4,141,27,3,173,30,3,41,16,208, + 5,169,0,141,30,3,138,9,40,170,142,44,11,173,38,3, + 96,160,255,173,24,3,174,28,3,141,0,210,142,1,210,173, + 25,3,174,29,3,141,2,210,142,3,210,173,26,3,174,30, + 3,141,4,210,142,5,210,173,27,3,174,31,3,141,6,210, + 142,7,210,140,8,210,96 +END_CONST_ARRAY; +CONST_ARRAY(byte, rmt8_obx) + 255,255,144,3,108,12,128,0,128,32,128,64,0,192,128,128, + 128,160,0,192,64,192,0,1,5,11,21,0,1,255,255,1, + 1,0,255,255,0,1,1,1,0,255,255,255,255,0,1,1, + 0,0,0,0,0,0,242,51,150,226,56,140,0,106,232,106, + 239,128,8,174,70,230,149,65,246,176,110,48,246,187,132,82, + 34,244,200,160,122,85,52,20,245,216,189,164,141,119,96,78, + 56,39,21,6,247,232,219,207,195,184,172,162,154,144,136,127, + 120,112,106,100,94,0,191,182,170,161,152,143,137,128,242,230, + 218,206,191,182,170,161,152,143,137,128,122,113,107,101,95,92, + 86,80,77,71,68,62,60,56,53,50,47,45,42,40,37,35, + 33,31,29,28,26,24,23,22,20,19,18,17,16,15,14,13, + 12,11,10,9,8,7,255,241,228,216,202,192,181,171,162,153, + 142,135,127,121,115,112,102,97,90,85,82,75,72,67,63,60, + 57,55,51,48,45,42,40,37,36,33,31,30,28,27,25,23, + 22,21,19,18,17,16,15,14,13,12,11,10,9,8,7,6, + 5,4,3,2,1,0,243,230,217,204,193,181,173,162,153,144, + 136,128,121,114,108,102,96,91,85,81,76,72,68,64,60,57, + 53,50,47,45,42,40,37,35,33,31,29,28,26,24,23,22, + 20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5, + 4,3,2,1,0,0,13,13,12,11,11,10,10,9,8,8, + 7,7,7,6,6,5,5,5,4,4,4,4,3,3,3,3, + 3,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1, + 1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1, + 1,1,1,1,1,1,0,0,0,0,1,1,1,1,1,1, + 1,1,2,2,2,2,0,0,0,1,1,1,1,1,2,2, + 2,2,2,3,3,3,0,0,1,1,1,1,2,2,2,2, + 3,3,3,3,4,4,0,0,1,1,1,2,2,2,3,3, + 3,4,4,4,5,5,0,0,1,1,2,2,2,3,3,4, + 4,4,5,5,6,6,0,0,1,1,2,2,3,3,4,4, + 5,5,6,6,7,7,0,1,1,2,2,3,3,4,4,5, + 5,6,6,7,7,8,0,1,1,2,2,3,4,4,5,5, + 6,7,7,8,8,9,0,1,1,2,3,3,4,5,5,6, + 7,7,8,9,9,10,0,1,1,2,3,4,4,5,6,7, + 7,8,9,10,10,11,0,1,2,2,3,4,5,6,6,7, + 8,9,10,10,11,12,0,1,2,3,3,4,5,6,7,8, + 9,10,10,11,12,13,0,1,2,3,4,5,6,7,7,8, + 9,10,11,12,13,14,0,1,2,3,4,5,6,7,8,9, + 10,11,12,13,14,15,76,15,6,76,9,8,76,46,8,76, + 92,6,76,2,12,134,211,132,212,72,160,0,152,153,0,2, + 153,76,2,200,208,247,160,4,177,211,141,34,8,200,177,211, + 141,72,3,200,177,211,141,18,8,141,74,3,160,8,177,211, + 153,195,0,200,192,16,208,246,104,72,10,10,10,24,101,209, + 133,209,104,8,41,224,10,42,42,42,40,101,210,133,210,32, + 123,6,169,0,141,8,210,141,24,210,160,3,140,15,210,140, + 31,210,160,8,153,0,210,153,16,210,136,16,247,173,18,8, + 96,162,0,142,75,3,138,168,177,209,201,254,176,45,168,177, + 205,157,0,2,177,207,157,8,2,169,0,157,16,2,169,1, + 157,24,2,169,128,157,104,2,232,224,8,208,217,165,209,24, + 105,8,133,209,144,27,230,210,76,203,6,240,4,169,0,240, + 223,160,2,177,209,170,200,177,209,133,210,134,209,162,0,240, + 181,173,72,3,141,35,7,162,255,232,222,24,2,208,69,189, + 0,2,133,211,189,8,2,133,212,188,16,2,254,16,2,177, + 211,133,217,41,63,201,61,240,17,176,56,157,32,2,157,32, + 3,200,177,211,74,41,126,157,104,2,169,1,157,24,2,188, + 16,2,254,16,2,177,211,74,102,217,74,102,217,165,217,41, + 240,157,40,2,224,7,208,177,169,255,141,72,3,141,73,3, + 76,114,7,201,63,240,27,165,217,41,192,240,9,10,42,42, + 157,24,2,76,30,7,200,177,211,157,24,2,254,16,2,76, + 30,7,165,217,48,12,200,177,211,141,35,7,254,16,2,76, + 227,6,201,255,240,9,200,177,211,157,16,2,76,227,6,76, + 123,6,76,46,8,202,48,250,188,104,2,48,248,177,203,157, + 112,2,133,215,200,177,203,157,120,2,133,216,169,1,157,40, + 3,168,177,215,157,8,3,200,177,215,157,136,2,200,177,215, + 157,144,2,200,177,215,157,224,2,41,63,157,16,3,177,215, + 41,64,157,232,2,200,177,215,157,64,3,200,177,215,157,160, + 2,200,177,215,157,176,2,200,177,215,157,184,2,200,177,215, + 168,185,160,3,157,192,2,157,200,2,185,161,3,157,208,2, + 160,10,177,215,157,216,2,169,128,157,168,2,157,104,2,10, + 157,152,2,157,56,2,168,177,215,157,0,3,105,0,157,128, + 2,169,12,157,248,2,168,177,215,157,240,2,76,111,7,32, + 2,12,206,74,3,208,29,169,255,141,74,3,206,73,3,208, + 19,238,75,3,173,75,3,201,255,240,3,76,203,6,76,123, + 6,76,116,10,169,4,133,214,162,7,189,120,2,240,242,133, + 212,189,112,2,133,211,188,128,2,177,211,133,217,200,177,211, + 133,218,200,177,211,133,219,200,152,221,136,2,144,10,240,8, + 169,128,157,152,2,189,144,2,157,128,2,165,217,224,4,144, + 4,74,74,74,74,41,15,29,40,2,168,185,0,5,133,220, + 165,218,41,14,168,185,144,3,133,213,165,220,25,145,3,157, + 56,3,189,184,2,240,40,201,1,208,33,189,56,2,24,125, + 216,2,24,188,192,2,121,165,3,157,56,2,200,152,221,208, + 2,208,3,189,200,2,157,192,2,76,185,8,222,184,2,188, + 0,3,192,13,144,60,189,16,3,16,49,152,221,248,2,208, + 8,189,8,3,157,248,2,208,3,254,248,2,189,112,2,133, + 215,189,120,2,133,216,188,248,2,177,215,188,232,2,240,4, + 24,125,240,2,157,240,2,189,224,2,41,63,56,233,1,157, + 16,3,189,152,2,16,31,189,40,2,240,26,221,176,2,240, + 21,144,19,168,189,168,2,24,125,160,2,157,168,2,144,6, + 152,233,16,157,40,2,169,0,133,221,165,218,157,24,3,41, + 112,74,74,141,49,9,144,254,76,231,9,234,76,81,9,234, + 76,86,9,234,76,96,9,234,76,108,9,234,76,123,9,234, + 76,190,9,234,76,205,9,165,219,76,42,10,165,219,133,221, + 189,32,2,76,237,9,189,32,2,24,101,219,157,32,2,76, + 237,9,189,56,2,24,101,219,157,56,2,189,32,2,76,237, + 9,189,224,2,16,12,188,32,2,177,213,24,125,240,2,76, + 156,9,189,32,2,24,125,240,2,201,61,144,2,169,63,168, + 177,213,157,64,2,164,219,208,3,157,72,2,152,74,74,74, + 74,157,80,2,157,88,2,165,219,41,15,157,96,2,189,32, + 2,76,237,9,165,219,24,125,40,3,157,40,3,189,32,2, + 76,237,9,165,219,201,128,240,6,157,32,2,76,237,9,189, + 56,3,9,240,157,56,3,189,32,2,76,237,9,189,32,2, + 24,101,219,188,224,2,48,31,24,125,240,2,201,61,144,7, + 169,0,157,56,3,169,63,157,32,3,168,177,213,24,125,56, + 2,24,101,221,76,42,10,201,61,144,7,169,0,157,56,3, + 169,63,168,189,56,2,24,125,240,2,24,113,213,24,101,221, + 157,48,3,189,88,2,240,50,222,88,2,208,45,189,80,2, + 157,88,2,189,72,2,221,64,2,240,31,176,13,125,96,2, + 176,18,221,64,2,176,13,76,97,10,253,96,2,144,5,221, + 64,2,176,3,189,64,2,157,72,2,165,218,41,1,240,10, + 189,72,2,24,125,56,2,157,48,3,202,48,3,76,52,8, + 173,64,3,13,65,3,13,66,3,13,67,3,170,142,101,12, + 173,24,3,16,33,173,56,3,41,15,240,26,173,48,3,24, + 109,40,3,141,50,3,173,58,3,41,16,208,5,169,0,141, + 58,3,138,9,4,170,173,25,3,16,33,173,57,3,41,15, + 240,26,173,49,3,24,109,41,3,141,51,3,173,59,3,41, + 16,208,5,169,0,141,59,3,138,9,2,170,236,101,12,208, + 94,173,25,3,41,14,201,6,208,38,173,57,3,41,15,240, + 31,172,33,3,185,192,3,141,48,3,185,192,4,141,49,3, + 173,56,3,41,16,208,5,169,0,141,56,3,138,9,80,170, + 173,27,3,41,14,201,6,208,38,173,59,3,41,15,240,31, + 172,35,3,185,192,3,141,50,3,185,192,4,141,51,3,173, + 58,3,41,16,208,5,169,0,141,58,3,138,9,40,170,142, + 101,12,173,68,3,13,69,3,13,70,3,13,71,3,170,142, + 3,12,173,28,3,16,33,173,60,3,41,15,240,26,173,52, + 3,24,109,44,3,141,54,3,173,62,3,41,16,208,5,169, + 0,141,62,3,138,9,4,170,173,29,3,16,33,173,61,3, + 41,15,240,26,173,53,3,24,109,45,3,141,55,3,173,63, + 3,41,16,208,5,169,0,141,63,3,138,9,2,170,236,3, + 12,208,94,173,29,3,41,14,201,6,208,38,173,61,3,41, + 15,240,31,172,37,3,185,192,3,141,52,3,185,192,4,141, + 53,3,173,60,3,41,16,208,5,169,0,141,60,3,138,9, + 80,170,173,31,3,41,14,201,6,208,38,173,63,3,41,15, + 240,31,172,39,3,185,192,3,141,54,3,185,192,4,141,55, + 3,173,62,3,41,16,208,5,169,0,141,62,3,138,9,40, + 170,142,3,12,173,74,3,96,160,255,173,52,3,174,48,3, + 141,16,210,142,0,210,173,60,3,174,56,3,141,17,210,142, + 1,210,173,53,3,174,49,3,141,18,210,142,2,210,173,61, + 3,174,57,3,141,19,210,142,3,210,173,54,3,174,50,3, + 141,20,210,142,4,210,173,62,3,174,58,3,141,21,210,142, + 5,210,173,55,3,174,51,3,141,22,210,142,6,210,173,63, + 3,174,59,3,141,23,210,142,7,210,169,255,140,24,210,141, + 8,210,96 +END_CONST_ARRAY; +CONST_ARRAY(byte, tmc_obx) + 255,255,0,5,104,15,76,206,13,76,208,8,76,239,9,15, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1, + 1,1,0,0,0,0,1,1,1,1,1,1,1,1,2,2, + 2,2,0,0,0,1,1,1,1,1,2,2,2,2,2,3, + 3,3,0,0,1,1,1,1,2,2,2,2,3,3,3,3, + 4,4,0,0,1,1,1,2,2,2,3,3,3,4,4,4, + 5,5,0,0,1,1,2,2,2,3,3,4,4,4,5,5, + 6,6,0,0,1,1,2,2,3,3,4,4,5,5,6,6, + 7,7,0,1,1,2,2,3,3,4,4,5,5,6,6,7, + 7,8,0,1,1,2,2,3,4,4,5,5,6,7,7,8, + 8,9,0,1,1,2,3,3,4,5,5,6,7,7,8,9, + 9,10,0,1,1,2,3,4,4,5,6,7,7,8,9,10, + 10,11,0,1,2,2,3,4,5,6,6,7,8,9,10,10, + 11,12,0,1,2,3,3,4,5,6,7,8,9,10,10,11, + 12,13,0,1,2,3,4,5,6,7,7,8,9,10,11,12, + 13,14,0,1,2,3,4,5,6,7,8,9,10,11,12,13, + 14,15,0,241,228,215,203,192,181,170,161,152,143,135,127,120, + 114,107,101,95,90,85,80,75,71,67,63,60,56,53,50,47, + 44,42,39,37,35,33,31,29,28,26,24,23,22,20,19,18, + 17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2, + 1,0,0,242,230,218,206,191,182,170,161,152,143,137,128,122, + 113,107,101,95,92,86,80,77,71,68,62,60,56,53,50,47, + 45,42,40,37,35,33,31,29,28,26,24,23,22,20,19,18, + 17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2, + 1,0,0,255,241,228,216,202,192,181,171,162,153,142,135,127, + 121,115,112,102,97,90,85,82,75,72,67,63,60,57,55,51, + 48,45,42,40,37,36,33,31,30,28,27,25,23,22,21,19, + 18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3, + 2,1,0,243,230,217,204,193,181,173,162,153,144,136,128,121, + 114,108,102,96,91,85,81,76,72,68,64,60,57,53,50,47, + 45,42,40,37,35,33,31,29,28,26,24,23,22,20,19,18, + 17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2, + 1,0,0,242,51,150,226,56,140,0,106,232,106,239,128,8, + 174,70,230,149,65,246,176,110,48,246,187,132,82,34,244,200, + 160,122,85,52,20,245,216,189,164,141,119,96,78,56,39,21, + 6,247,232,219,207,195,184,172,162,154,144,136,127,120,112,106, + 100,94,0,13,13,12,11,11,10,10,9,8,8,7,7,7, + 6,6,5,5,5,4,4,4,4,3,3,3,3,3,2,2, + 2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1, + 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,5, + 6,7,0,1,2,3,4,2,0,0,4,2,0,0,0,16, + 0,8,0,16,0,8,173,183,8,240,94,173,182,8,201,64, + 144,90,206,181,8,240,3,76,239,9,162,7,169,0,157,196, + 7,157,204,7,202,16,247,141,182,8,170,160,15,177,254,16, + 32,136,177,254,16,3,76,95,14,134,252,10,10,38,252,10, + 38,252,10,38,252,105,0,133,254,165,252,105,0,133,255,144, + 218,157,212,7,136,177,254,157,220,7,232,136,16,207,24,165, + 254,105,16,133,254,144,2,230,255,76,239,9,206,181,8,16, + 248,238,182,8,173,180,8,141,181,8,162,7,222,204,7,48, + 3,76,233,9,188,212,7,185,255,255,133,252,185,255,255,133, + 253,188,196,7,177,252,208,6,32,109,13,76,230,9,201,64, + 176,18,125,220,7,157,228,7,32,109,13,188,42,5,32,188, + 14,76,230,9,208,34,200,254,196,7,177,252,16,7,133,251, + 32,109,13,165,251,41,127,208,7,169,64,141,182,8,208,76, + 141,180,8,141,181,8,208,68,201,128,176,43,41,63,125,220, + 7,157,228,7,200,254,196,7,177,252,41,127,208,7,169,64, + 141,182,8,208,6,141,180,8,141,181,8,32,109,13,188,42, + 5,32,188,14,76,230,9,201,192,176,12,41,63,157,42,5, + 200,254,196,7,76,94,9,41,63,157,204,7,254,196,7,202, + 48,3,76,70,9,162,7,189,188,7,240,33,32,46,11,189, + 50,5,61,192,8,240,22,160,71,177,252,24,125,34,5,157, + 36,5,168,185,60,6,56,125,100,8,157,246,7,202,16,215, + 14,9,5,14,9,5,14,9,5,14,9,5,232,134,252,134, + 253,162,7,138,168,185,252,7,208,12,188,184,8,185,4,8, + 208,4,138,168,169,0,133,250,152,157,26,5,185,244,7,157, + 18,5,185,50,5,133,251,5,253,133,253,165,251,61,192,8, + 240,6,185,246,7,157,20,5,165,251,61,200,8,240,18,185, + 34,5,41,63,168,200,132,252,185,123,7,157,18,5,76,137, + 10,164,252,240,10,185,59,7,157,18,5,169,0,133,252,165, + 250,13,9,5,168,185,60,5,188,26,5,25,236,7,157,10, + 5,224,4,208,9,165,253,141,59,5,169,0,133,253,202,16, + 130,78,9,5,78,9,5,78,9,5,78,9,5,165,253,162, + 3,142,31,210,142,15,210,174,22,5,172,18,5,142,16,210, + 140,0,210,174,14,5,172,10,5,142,17,210,140,1,210,174, + 23,5,172,19,5,142,18,210,140,2,210,174,15,5,172,11, + 5,142,19,210,140,3,210,174,24,5,172,20,5,142,20,210, + 140,4,210,174,16,5,172,12,5,142,21,210,140,5,210,174, + 25,5,172,21,5,142,22,210,140,6,210,174,17,5,172,13, + 5,142,23,210,140,7,210,141,58,5,174,59,5,142,24,210, + 141,8,210,96,189,28,8,133,252,189,36,8,133,253,188,44, + 8,192,63,240,123,254,44,8,254,44,8,254,44,8,177,252, + 41,240,157,236,7,177,252,41,15,56,253,12,8,16,2,169, + 0,157,252,7,200,177,252,41,15,56,253,20,8,16,2,169, + 0,157,4,8,177,252,41,240,240,116,16,11,160,73,177,252, + 188,44,8,136,136,16,2,169,0,157,50,5,177,252,41,112, + 240,99,74,74,141,154,11,169,0,157,100,8,200,177,252,144, + 254,234,234,234,234,76,56,13,234,76,53,13,234,76,60,13, + 234,76,74,13,234,76,84,13,234,76,95,13,234,76,81,13, + 189,52,8,240,18,222,68,8,208,13,157,68,8,189,252,7, + 41,15,240,3,222,252,7,189,60,8,240,18,222,76,8,208, + 13,157,76,8,189,4,8,41,15,240,3,222,4,8,160,72, + 177,252,157,50,5,189,148,8,24,105,63,168,177,252,125,228, + 7,157,34,5,168,185,60,6,157,244,7,222,164,8,16,51, + 189,156,8,157,164,8,189,172,8,240,24,24,125,148,8,157, + 148,8,240,7,221,140,8,208,26,169,254,24,105,1,157,172, + 8,208,16,254,148,8,189,140,8,221,148,8,176,5,169,0, + 157,148,8,189,116,8,240,4,222,116,8,96,189,108,8,133, + 250,189,92,8,133,251,32,105,12,222,132,8,16,16,165,250, + 157,108,8,165,251,157,92,8,189,124,8,157,132,8,96,189, + 84,8,141,112,12,16,254,76,167,12,234,76,144,12,234,76, + 174,12,234,76,180,12,234,76,190,12,234,76,210,12,234,76, + 226,12,234,76,244,12,165,250,230,250,41,3,74,144,15,208, + 71,165,251,157,100,8,24,125,244,7,157,244,7,96,169,0, + 157,100,8,96,32,29,13,76,157,12,32,29,13,24,125,34, + 5,76,84,13,165,250,157,100,8,24,125,244,7,157,244,7, + 165,250,24,101,251,133,250,96,189,34,5,56,229,250,157,34, + 5,168,185,60,6,76,199,12,189,244,7,56,229,251,157,244, + 7,56,169,0,229,251,157,100,8,96,189,132,8,208,174,165, + 251,16,16,189,4,8,240,165,189,252,7,201,15,240,158,254, + 252,7,96,189,252,7,240,149,189,4,8,201,15,240,142,254, + 4,8,96,164,250,165,251,48,2,200,200,136,152,133,250,197, + 251,208,6,165,251,73,255,133,251,152,96,125,244,7,157,244, + 7,96,188,228,7,121,60,6,157,244,7,152,157,34,5,96, + 45,10,210,157,244,7,96,125,228,7,157,34,5,168,185,60, + 6,157,244,7,96,157,34,5,168,189,244,7,121,60,6,157, + 244,7,96,200,254,196,7,177,252,74,74,74,74,157,12,8, + 177,252,41,15,157,20,8,96,32,95,14,160,15,169,0,133, + 254,169,0,133,255,138,240,46,177,254,16,1,202,24,165,254, + 105,16,133,254,144,239,230,255,176,235,32,95,14,169,0,133, + 252,138,10,10,38,252,10,38,252,10,38,252,105,0,133,254, + 165,252,105,0,133,255,169,64,141,182,8,169,1,141,181,8, + 141,183,8,96,201,16,144,176,201,32,144,206,201,48,176,3, + 76,174,14,201,64,176,9,138,41,15,240,3,141,180,8,96, + 201,80,144,113,201,96,176,6,169,0,141,183,8,96,201,112, + 144,248,169,1,141,181,8,169,64,141,182,8,132,252,134,253, + 160,30,177,252,141,180,8,165,252,24,105,32,141,194,14,144, + 1,232,142,195,14,24,105,64,141,202,14,144,1,232,142,203, + 14,24,105,64,141,82,9,144,1,232,142,83,9,24,105,128, + 141,87,9,144,1,232,142,88,9,24,105,128,133,254,141,16, + 9,141,136,13,141,183,13,144,1,232,134,255,142,22,9,142, + 140,13,142,189,13,160,7,169,0,141,183,8,153,0,210,153, + 16,210,153,10,5,153,252,7,153,4,8,153,50,5,153,188, + 7,136,16,232,141,8,210,141,24,210,141,58,5,141,59,5, + 96,157,252,7,157,4,8,157,50,5,189,228,7,157,34,5, + 96,152,73,240,74,74,74,74,157,12,8,152,41,15,73,15, + 157,20,8,96,41,7,133,252,138,166,252,41,63,240,226,157, + 228,7,169,0,157,188,7,185,255,255,157,28,8,133,252,185, + 255,255,157,36,8,133,253,5,252,240,182,160,74,177,252,157, + 52,8,157,68,8,200,177,252,157,60,8,157,76,8,200,177, + 252,41,112,74,74,157,84,8,177,252,41,15,157,92,8,177, + 252,16,11,189,92,8,73,255,24,105,1,157,92,8,200,177, + 252,157,116,8,200,177,252,41,63,157,124,8,157,132,8,200, + 177,252,41,128,240,2,169,1,157,172,8,177,252,41,112,74, + 74,74,74,157,140,8,208,3,157,172,8,177,252,41,15,157, + 156,8,157,164,8,136,177,252,41,192,24,125,228,7,157,228, + 7,157,34,5,168,185,60,6,157,244,7,169,0,157,44,8, + 157,100,8,157,108,8,157,148,8,169,1,157,188,7,96 +END_CONST_ARRAY; +CONST_ARRAY(byte, tm2_obx) + 255,255,0,2,107,16,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1, + 1,1,1,1,1,1,0,0,0,0,1,1,1,1,1,1, + 1,1,2,2,2,2,0,0,0,1,1,1,1,1,2,2, + 2,2,2,3,3,3,0,0,1,1,1,1,2,2,2,2, + 3,3,3,3,4,4,0,0,1,1,1,2,2,2,3,3, + 3,4,4,4,5,5,0,0,1,1,2,2,2,3,3,4, + 4,4,5,5,6,6,0,0,1,1,2,2,3,3,4,4, + 5,5,6,6,7,7,0,1,1,2,2,3,3,4,4,5, + 5,6,6,7,7,8,0,1,1,2,2,3,4,4,5,5, + 6,7,7,8,8,9,0,1,1,2,3,3,4,5,5,6, + 7,7,8,9,9,10,0,1,1,2,3,4,4,5,6,7, + 7,8,9,10,10,11,0,1,2,2,3,4,5,6,6,7, + 8,9,10,10,11,12,0,1,2,3,3,4,5,6,7,8, + 9,10,10,11,12,13,0,1,2,3,4,5,6,7,7,8, + 9,10,11,12,13,14,0,1,2,3,4,5,6,7,8,9, + 10,11,12,13,14,15,0,241,228,215,203,192,181,170,161,152, + 143,135,127,120,114,107,101,95,90,85,80,75,71,67,63,60, + 56,53,50,47,44,42,39,37,35,33,31,29,28,26,24,23, + 22,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6, + 5,4,3,2,1,0,0,242,233,218,206,191,182,170,161,152, + 143,137,128,122,113,107,101,95,92,86,80,77,71,68,62,60, + 56,53,50,47,45,42,40,37,35,33,31,29,28,26,24,23, + 22,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6, + 5,4,3,2,1,0,0,255,241,228,216,202,192,181,171,162, + 153,142,135,127,121,115,112,102,97,90,85,82,75,72,67,63, + 60,57,55,51,48,45,42,40,37,36,33,31,30,28,27,25, + 23,22,21,19,18,17,16,15,14,13,12,11,10,9,8,7, + 6,5,4,3,2,1,0,243,230,217,204,193,181,173,162,153, + 144,136,128,121,114,108,102,96,91,85,81,76,72,68,64,60, + 57,53,50,47,45,42,40,37,35,33,31,29,28,26,24,23, + 22,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6, + 5,4,3,2,1,0,226,56,140,0,106,232,106,239,128,8, + 174,70,230,149,65,246,176,110,48,246,187,132,82,34,244,200, + 160,122,85,52,20,245,216,189,164,141,119,96,78,56,39,21, + 6,247,232,219,207,195,184,172,162,154,144,136,127,120,112,106, + 100,94,87,82,50,10,0,242,51,150,226,56,140,0,106,232, + 106,239,128,8,174,70,230,149,65,246,176,110,48,246,187,132, + 82,34,244,200,160,122,85,52,20,245,216,189,164,141,119,96, + 78,56,39,21,6,247,232,219,207,195,184,172,162,154,144,136, + 127,120,112,106,100,94,11,11,10,10,9,8,8,7,7,7, + 6,6,5,5,5,4,4,4,4,3,3,3,3,3,2,2, + 2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1, + 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,13,13,12,11,11,10,10,9,8, + 8,7,7,7,6,6,5,5,5,4,4,4,4,3,3,3, + 3,3,2,2,2,2,2,2,2,1,1,1,1,1,1,1, + 1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,76,228,13,76,227,6,76,159,8,1, + 16,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,5, + 6,7,0,1,2,3,4,2,0,0,4,2,0,0,0,16, + 0,8,0,16,0,8,133,211,129,169,133,211,129,169,136,177, + 250,141,23,5,162,0,134,252,10,38,252,10,38,252,10,38, + 252,10,38,252,109,23,5,144,2,230,252,24,105,0,133,250, + 165,252,105,0,133,251,76,7,7,32,181,9,173,22,5,240, + 5,206,28,5,48,3,76,162,8,206,29,5,208,82,162,0, + 238,23,5,173,25,5,133,250,173,26,5,133,251,160,16,177, + 250,48,171,208,3,76,44,15,141,29,5,136,177,250,136,132, + 252,168,185,255,255,157,80,5,185,255,255,157,88,5,169,0, + 157,112,5,157,96,5,164,252,177,250,157,104,5,232,136,16, + 219,169,17,24,101,250,141,25,5,169,0,101,251,141,26,5, + 173,27,5,141,28,5,162,7,222,112,5,48,6,202,16,248, + 76,162,8,189,80,5,133,250,189,88,5,133,251,188,96,5, + 177,250,208,28,200,177,250,157,208,5,41,240,157,216,5,177, + 250,10,10,10,10,157,224,5,200,152,157,96,5,76,87,7, + 201,64,176,79,125,104,5,157,152,5,200,177,250,16,37,41, + 127,133,252,200,177,250,157,208,5,41,240,157,216,5,177,250, + 10,10,10,10,157,224,5,200,152,157,96,5,164,252,32,156, + 15,76,87,7,168,254,96,5,254,96,5,189,208,5,41,240, + 157,216,5,189,208,5,10,10,10,10,157,224,5,32,156,15, + 76,87,7,201,128,176,37,41,63,24,125,104,5,157,152,5, + 200,177,250,157,208,5,41,240,157,216,5,177,250,10,10,10, + 10,157,224,5,200,152,157,96,5,76,87,7,208,14,200,177, + 250,157,112,5,200,152,157,96,5,76,87,7,201,192,176,15, + 41,63,24,125,104,5,157,152,5,254,96,5,76,87,7,201, + 208,176,15,200,254,96,5,41,15,141,27,5,141,28,5,76, + 106,7,201,224,176,22,177,250,133,252,200,177,250,133,253,200, + 152,157,96,5,165,252,32,14,14,76,87,7,201,240,176,46, + 177,250,133,252,200,177,250,133,253,165,252,32,14,14,188,96, + 5,200,200,177,250,157,208,5,41,240,157,216,5,177,250,10, + 10,10,10,157,224,5,200,152,157,96,5,76,87,7,201,255, + 176,11,233,239,157,112,5,254,96,5,76,87,7,169,64,157, + 112,5,76,87,7,32,181,9,162,7,189,120,5,240,115,76, + 217,10,189,14,5,240,14,169,0,157,32,5,157,40,5,202, + 16,232,76,31,9,164,253,185,0,3,24,101,252,157,56,5, + 152,157,160,5,189,176,5,61,168,6,240,40,165,253,41,127, + 168,185,0,4,24,101,252,157,55,5,185,128,4,105,0,157, + 56,5,169,0,157,31,5,188,152,6,153,39,5,202,202,16, + 169,76,31,9,189,176,5,61,160,6,240,22,189,104,6,24, + 101,253,157,162,5,168,185,0,3,24,101,252,56,101,254,157, + 58,5,202,16,133,232,134,252,162,3,173,9,5,240,6,41, + 64,208,60,162,7,138,168,185,32,5,208,12,188,152,6,185, + 40,5,208,4,138,168,169,0,25,168,5,157,48,5,185,56, + 5,157,72,5,185,160,5,157,64,5,185,176,5,5,252,133, + 252,224,4,208,3,141,31,5,202,16,202,141,30,5,96,189, + 32,5,29,168,5,157,48,5,189,44,5,29,172,5,157,52, + 5,189,56,5,157,72,5,189,60,5,157,76,5,189,160,5, + 157,64,5,189,164,5,157,68,5,202,16,211,173,176,5,13, + 177,5,13,178,5,13,179,5,141,30,5,173,180,5,13,181, + 5,13,182,5,13,183,5,141,31,5,96,173,9,5,208,3, + 76,144,10,48,3,76,72,10,173,13,5,170,74,74,41,1, + 168,185,30,5,141,56,210,138,41,4,168,185,56,5,141,48, + 210,189,32,5,141,49,210,185,57,5,141,50,210,189,33,5, + 141,51,210,185,58,5,141,52,210,189,34,5,141,53,210,185, + 59,5,141,54,210,189,35,5,141,55,210,173,12,5,170,74, + 74,41,1,168,185,30,5,141,40,210,138,41,4,168,185,56, + 5,141,32,210,189,32,5,141,33,210,185,57,5,141,34,210, + 189,33,5,141,35,210,185,58,5,141,36,210,189,34,5,141, + 37,210,185,59,5,141,38,210,189,35,5,141,39,210,173,11, + 5,170,74,74,41,1,168,185,30,5,141,24,210,138,172,9, + 5,16,2,41,4,168,185,56,5,141,16,210,189,32,5,141, + 17,210,185,57,5,141,18,210,189,33,5,141,19,210,185,58, + 5,141,20,210,189,34,5,141,21,210,185,59,5,141,22,210, + 189,35,5,141,23,210,173,10,5,170,74,74,41,1,168,185, + 30,5,141,8,210,138,172,9,5,16,2,41,4,168,185,56, + 5,141,0,210,189,32,5,141,1,210,185,57,5,141,2,210, + 189,33,5,141,3,210,185,58,5,141,4,210,189,34,5,141, + 5,210,185,59,5,141,6,210,189,35,5,141,7,210,96,189, + 128,5,133,250,189,136,5,133,251,189,128,6,133,252,189,136, + 6,133,253,189,144,6,133,254,189,184,5,221,192,5,144,12, + 157,8,6,189,200,5,157,184,5,76,11,11,189,8,6,240, + 48,189,232,5,240,19,222,248,5,208,14,157,248,5,189,216, + 5,240,6,56,233,16,157,216,5,189,240,5,240,19,222,0, + 6,208,14,157,0,6,189,224,5,240,6,56,233,16,157,224, + 5,188,72,6,177,250,24,125,152,5,24,101,253,133,253,222, + 88,6,16,57,189,80,6,157,88,6,189,96,6,240,30,24, + 125,72,6,157,72,6,240,13,221,64,6,144,32,169,255,157, + 96,6,76,135,11,169,1,157,96,6,76,135,11,254,72,6, + 189,64,6,221,72,6,176,5,169,0,157,72,6,169,19,24, + 101,250,133,250,144,2,230,251,188,184,5,177,250,41,240,157, + 168,5,177,250,41,15,29,216,5,168,185,0,2,5,255,168, + 185,0,2,157,32,5,188,184,5,200,177,250,41,15,29,224, + 5,168,185,0,2,5,255,168,185,0,2,157,40,5,189,40, + 6,208,39,189,16,6,141,212,11,16,254,76,209,12,234,76, + 108,12,234,76,167,12,234,76,212,12,234,76,1,13,234,76, + 33,13,234,76,65,13,234,76,73,13,222,40,6,188,184,5, + 200,177,250,41,112,74,74,74,141,34,12,177,250,48,6,189, + 112,6,76,18,12,189,120,6,61,176,6,157,176,5,200,200, + 152,157,184,5,136,177,250,144,254,144,22,144,12,144,34,144, + 24,144,46,144,36,144,50,144,52,125,128,6,157,128,6,177, + 250,24,101,252,133,252,76,172,8,125,136,6,157,136,6,177, + 250,24,101,253,133,253,76,172,8,125,144,6,157,144,6,177, + 250,24,101,254,133,254,76,172,8,133,252,169,0,133,253,76, + 172,8,189,32,6,41,3,74,144,10,208,25,189,24,6,24, + 101,252,133,252,222,56,6,16,78,254,32,6,189,48,6,157, + 56,6,76,247,11,165,252,253,24,6,133,252,222,56,6,16, + 54,254,32,6,189,48,6,157,56,6,76,247,11,188,32,6, + 189,24,6,48,2,200,200,136,152,24,101,252,133,252,222,56, + 6,16,20,152,157,32,6,221,24,6,208,5,73,255,157,24, + 6,189,48,6,157,56,6,76,247,11,188,32,6,189,24,6, + 48,2,200,200,136,152,24,101,253,133,253,222,56,6,16,231, + 152,157,32,6,221,24,6,208,216,73,255,157,24,6,189,48, + 6,157,56,6,76,247,11,189,32,6,24,101,252,133,252,222, + 56,6,16,195,189,24,6,24,125,32,6,157,32,6,189,48, + 6,157,56,6,76,247,11,165,253,56,253,32,6,133,253,222, + 56,6,16,163,189,24,6,24,125,32,6,157,32,6,189,48, + 6,157,56,6,76,247,11,189,24,6,24,101,252,133,252,76, + 247,11,160,16,169,0,133,250,169,0,133,251,169,0,141,23, + 5,138,240,63,177,250,240,2,16,1,202,169,17,24,101,250, + 133,250,144,2,230,251,238,23,5,208,230,162,0,169,0,133, + 252,138,141,23,5,10,38,252,10,38,252,10,38,252,10,38, + 252,109,23,5,144,2,230,252,24,105,0,133,250,165,252,105, + 0,133,251,32,44,15,165,250,141,25,5,165,251,141,26,5, + 162,7,169,255,157,208,5,169,240,157,216,5,157,224,5,202, + 16,240,169,3,141,15,210,141,31,210,141,47,210,141,63,210, + 206,23,5,232,142,28,5,232,142,29,5,142,22,5,96,138, + 41,15,141,27,5,96,142,22,5,96,201,16,176,3,76,76, + 13,201,32,144,136,201,48,176,3,76,133,15,201,64,144,223, + 201,80,176,3,76,44,15,201,96,144,219,201,112,144,3,76, + 180,14,132,253,41,15,10,141,23,14,165,253,144,254,144,30, + 144,56,144,89,144,96,144,26,144,28,144,30,144,32,144,34, + 144,36,144,13,144,11,144,9,144,7,144,5,144,3,141,24, + 5,96,157,104,6,96,157,112,6,96,157,120,6,96,157,144, + 6,96,157,128,6,96,157,136,6,96,41,112,74,74,157,16, + 6,41,48,208,3,157,32,6,165,253,48,6,41,15,157,24, + 6,96,41,15,73,255,24,105,1,157,24,6,96,41,63,157, + 48,6,157,56,6,96,41,128,10,42,157,96,6,165,253,41, + 112,74,74,74,74,157,64,6,208,3,157,96,6,165,253,41, + 15,157,80,6,157,88,6,189,72,6,221,64,6,144,143,189, + 64,6,240,2,233,1,157,72,6,96,132,250,134,251,160,25, + 177,250,200,141,9,5,177,250,200,141,10,5,177,250,200,141, + 11,5,177,250,200,141,12,5,177,250,200,141,13,5,177,250, + 141,27,5,165,250,73,128,48,1,232,141,172,15,142,173,15, + 73,128,48,1,232,141,29,7,142,30,7,232,141,35,7,142, + 36,7,232,141,162,15,142,163,15,73,128,48,1,232,141,25, + 5,141,215,6,141,79,13,141,148,13,142,26,5,142,221,6, + 142,83,13,142,154,13,169,240,133,255,169,0,141,22,5,141, + 24,5,162,7,169,0,141,22,5,157,120,5,157,176,5,157, + 32,5,157,40,5,157,48,5,157,48,210,157,32,210,157,16, + 210,157,0,210,202,16,226,141,24,210,141,8,210,141,56,210, + 141,40,210,141,30,5,141,31,5,96,157,32,5,157,40,5, + 157,48,5,157,176,5,96,152,157,208,5,41,240,157,216,5, + 189,208,5,10,10,10,10,157,224,5,96,41,7,133,250,138, + 166,250,41,63,240,225,157,152,5,152,48,238,189,208,5,32, + 117,15,169,0,157,120,5,185,255,255,240,190,157,136,5,133, + 251,185,255,255,157,128,5,133,250,152,157,144,5,160,8,177, + 250,200,157,192,5,177,250,200,157,200,5,177,250,200,157,104, + 6,177,250,200,157,112,6,177,250,200,157,120,6,177,250,200, + 157,232,5,157,248,5,177,250,200,157,240,5,157,0,6,177, + 250,41,112,74,74,157,16,6,177,250,200,48,8,41,15,157, + 24,6,76,9,16,41,15,73,255,24,105,1,157,24,6,177, + 250,200,157,40,6,177,250,200,41,63,157,48,6,157,56,6, + 177,250,41,128,10,42,157,96,6,177,250,41,112,74,74,74, + 74,157,64,6,208,3,157,96,6,177,250,136,41,15,157,80, + 6,157,88,6,177,250,41,192,29,152,5,157,152,5,168,185, + 0,3,157,56,5,169,0,157,184,5,157,32,6,157,8,6, + 157,72,6,157,128,6,157,136,6,157,144,6,169,1,157,120, + 5,96 +END_CONST_ARRAY; diff --git a/lib/rbcodec/codecs/libasf/SOURCES b/lib/rbcodec/codecs/libasf/SOURCES new file mode 100644 index 0000000000..1fee336990 --- /dev/null +++ b/lib/rbcodec/codecs/libasf/SOURCES @@ -0,0 +1 @@ +asf.c diff --git a/lib/rbcodec/codecs/libasf/asf.c b/lib/rbcodec/codecs/libasf/asf.c new file mode 100644 index 0000000000..4e3235a422 --- /dev/null +++ b/lib/rbcodec/codecs/libasf/asf.c @@ -0,0 +1,435 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2007 Dave Chapman + * + * ASF parsing code based on libasf by Juho Vähä-Herttua + * http://code.google.com/p/libasf/ libasf itself was based on the ASF + * parser in VLC - http://www.videolan.org/ + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ +#include +#include "codeclib.h" +#include "asf.h" + +/* Read an unaligned 32-bit little endian long from buffer. */ +static unsigned long get_long_le(void* buf) +{ + unsigned char* p = (unsigned char*) buf; + + return p[0] | (p[1] << 8) | (p[2] << 16) | (p[3] << 24); +} + +/* Read an unaligned 16-bit little endian short from buffer. */ +static unsigned short get_short_le(void* buf) +{ + unsigned char* p = (unsigned char*) buf; + + return p[0] | (p[1] << 8); +} + +#define GETLEN2b(bits) (((bits) == 0x03) ? 4 : bits) + +#define GETVALUE2b(bits, data) \ + (((bits) != 0x03) ? ((bits) != 0x02) ? ((bits) != 0x01) ? \ + 0 : *(data) : get_short_le(data) : get_long_le(data)) + +int asf_read_packet(uint8_t** audiobuf, int* audiobufsize, int* packetlength, + asf_waveformatex_t* wfx) +{ + uint8_t tmp8, packet_flags, packet_property; + int stream_id; + int ec_length, opaque_data, ec_length_type; + int datalen; + uint8_t data[18]; + uint8_t* datap; + uint32_t length; + uint32_t padding_length; + /* rockbox: comment 'set but unused' variables + uint32_t send_time; + uint16_t duration; + uint32_t media_object_number; + uint32_t media_object_offset; + */ + uint16_t payload_count; + int payload_length_type; + uint32_t payload_hdrlen; + int payload_datalen; + int multiple; + uint32_t replicated_length; + uint32_t bytesread = 0; + uint8_t* buf; + size_t bufsize; + int i; + /*DEBUGF("Reading new packet at %d bytes ", (int)ci->curpos);*/ + + if (ci->read_filebuf(&tmp8, 1) == 0) { + return ASF_ERROR_EOF; + } + bytesread++; + + /* TODO: We need a better way to detect endofstream */ + if (tmp8 != 0x82) { + DEBUGF("Read failed: packet did not sync\n"); + return -1; + } + + + if (tmp8 & 0x80) { + ec_length = tmp8 & 0x0f; + opaque_data = (tmp8 >> 4) & 0x01; + ec_length_type = (tmp8 >> 5) & 0x03; + + if (ec_length_type != 0x00 || opaque_data != 0 || ec_length != 0x02) { + DEBUGF("incorrect error correction flags\n"); + return ASF_ERROR_INVALID_VALUE; + } + + /* Skip ec_data */ + ci->advance_buffer(ec_length); + bytesread += ec_length; + } else { + ec_length = 0; + } + + if (ci->read_filebuf(&packet_flags, 1) == 0) { return ASF_ERROR_EOF; } + if (ci->read_filebuf(&packet_property, 1) == 0) { return ASF_ERROR_EOF; } + bytesread += 2; + + datalen = GETLEN2b((packet_flags >> 1) & 0x03) + + GETLEN2b((packet_flags >> 3) & 0x03) + + GETLEN2b((packet_flags >> 5) & 0x03) + 6; + +#if 0 + if (datalen > sizeof(data)) { + DEBUGF("Unexpectedly long datalen in data - %d\n",datalen); + return ASF_ERROR_OUTOFMEM; + } +#endif + + if (ci->read_filebuf(data, datalen) == 0) { + return ASF_ERROR_EOF; + } + + bytesread += datalen; + + datap = data; + length = GETVALUE2b((packet_flags >> 5) & 0x03, datap); + datap += GETLEN2b((packet_flags >> 5) & 0x03); + /* sequence value is not used */ + GETVALUE2b((packet_flags >> 1) & 0x03, datap); + datap += GETLEN2b((packet_flags >> 1) & 0x03); + padding_length = GETVALUE2b((packet_flags >> 3) & 0x03, datap); + datap += GETLEN2b((packet_flags >> 3) & 0x03); + /* send_time = get_long_le(datap); */ + datap += 4; + /* duration = get_short_le(datap); */ + datap += 2; + /*DEBUGF("and duration %d ms\n", duration);*/ + + /* this is really idiotic, packet length can (and often will) be + * undefined and we just have to use the header packet size as the size + * value */ + if (!((packet_flags >> 5) & 0x03)) { + length = wfx->packet_size; + } + + /* this is also really idiotic, if packet length is smaller than packet + * size, we need to manually add the additional bytes into padding length + */ + if (length < wfx->packet_size) { + padding_length += wfx->packet_size - length; + length = wfx->packet_size; + } + + if (length > wfx->packet_size) { + DEBUGF("packet with too big length value\n"); + return ASF_ERROR_INVALID_LENGTH; + } + + /* check if we have multiple payloads */ + if (packet_flags & 0x01) { + if (ci->read_filebuf(&tmp8, 1) == 0) { + return ASF_ERROR_EOF; + } + payload_count = tmp8 & 0x3f; + payload_length_type = (tmp8 >> 6) & 0x03; + bytesread++; + } else { + payload_count = 1; + payload_length_type = 0x02; /* not used */ + } + + if (length < bytesread) { + DEBUGF("header exceeded packet size, invalid file - length=%d, bytesread=%d\n",(int)length,(int)bytesread); + /* FIXME: should this be checked earlier? */ + return ASF_ERROR_INVALID_LENGTH; + } + + + /* We now parse the individual payloads, and move all payloads + belonging to our audio stream to a contiguous block, starting at + the location of the first payload. + */ + + *audiobuf = NULL; + *audiobufsize = 0; + *packetlength = length - bytesread; + + buf = ci->request_buffer(&bufsize, length); + datap = buf; + +#define ASF_MAX_REQUEST (1L<<15) /* 32KB */ + if (bufsize != length && length >= ASF_MAX_REQUEST) { + /* This should only happen with packets larger than 32KB (the + guard buffer size). All the streams I've seen have + relatively small packets less than about 8KB), but I don't + know what is expected. + */ + DEBUGF("Could not read packet (requested %d bytes, received %d), curpos=%d, aborting\n", + (int)length,(int)bufsize,(int)ci->curpos); + return -1; + } + + for (i=0; i> 2) & 0x03) + + GETLEN2b((packet_property >> 4) & 0x03); + + //DEBUGF("payload_hdrlen = %d\n",payload_hdrlen); +#if 0 + /* TODO */ + if (payload_hdrlen > size) { + return ASF_ERROR_INVALID_LENGTH; + } +#endif + if (payload_hdrlen > sizeof(data)) { + DEBUGF("Unexpectedly long datalen in data - %d\n",datalen); + return ASF_ERROR_OUTOFMEM; + } + + bytesread += payload_hdrlen; + /* media_object_number = GETVALUE2b((packet_property >> 4) & 0x03, datap); */ + datap += GETLEN2b((packet_property >> 4) & 0x03); + /* media_object_offset = GETVALUE2b((packet_property >> 2) & 0x03, datap); */ + datap += GETLEN2b((packet_property >> 2) & 0x03); + replicated_length = GETVALUE2b(packet_property & 0x03, datap); + datap += GETLEN2b(packet_property & 0x03); + + /* TODO: Validate replicated_length */ + /* TODO: Is the content of this important for us? */ + datap += replicated_length; + bytesread += replicated_length; + + multiple = packet_flags & 0x01; + + + if (multiple) { + int x; + + x = GETLEN2b(payload_length_type); + + if (x != 2) { + /* in multiple payloads datalen should be a word */ + return ASF_ERROR_INVALID_VALUE; + } + +#if 0 + if (skip + tmp > datalen) { + /* not enough data */ + return ASF_ERROR_INVALID_LENGTH; + } +#endif + payload_datalen = GETVALUE2b(payload_length_type, datap); + datap += x; + bytesread += x; + } else { + payload_datalen = length - bytesread - padding_length; + } + + if (replicated_length==1) + datap++; + + if (stream_id == wfx->audiostream) + { + if (*audiobuf == NULL) { + /* The first payload can stay where it is */ + *audiobuf = datap; + *audiobufsize = payload_datalen; + } else { + /* The second and subsequent payloads in this packet + that belong to the audio stream need to be moved to be + contiguous with the first payload. + */ + memmove(*audiobuf + *audiobufsize, datap, payload_datalen); + *audiobufsize += payload_datalen; + } + } + datap += payload_datalen; + bytesread += payload_datalen; + } + + if (*audiobuf != NULL) + return 1; + else + return 0; +} + + +int asf_get_timestamp(int *duration) +{ + uint8_t tmp8, packet_flags, packet_property; + int ec_length, opaque_data, ec_length_type; + int datalen; + uint8_t data[18]; + uint8_t* datap; + /* rockbox: comment 'set but unused' variables + uint32_t length; + uint32_t padding_length; + */ + uint32_t send_time; + static int packet_count = 0; + + uint32_t bytesread = 0; + packet_count++; + if (ci->read_filebuf(&tmp8, 1) == 0) { + DEBUGF("ASF ERROR (EOF?)\n"); + return ASF_ERROR_EOF; + } + bytesread++; + + /* TODO: We need a better way to detect endofstream */ + if (tmp8 != 0x82) { + DEBUGF("Get timestamp: Detected end of stream\n"); + return ASF_ERROR_EOF; + } + + + if (tmp8 & 0x80) { + ec_length = tmp8 & 0x0f; + opaque_data = (tmp8 >> 4) & 0x01; + ec_length_type = (tmp8 >> 5) & 0x03; + + if (ec_length_type != 0x00 || opaque_data != 0 || ec_length != 0x02) { + DEBUGF("incorrect error correction flags\n"); + return ASF_ERROR_INVALID_VALUE; + } + + /* Skip ec_data */ + ci->advance_buffer(ec_length); + bytesread += ec_length; + } else { + ec_length = 0; + } + + if (ci->read_filebuf(&packet_flags, 1) == 0) { + DEBUGF("Detected end of stream 2\n"); + return ASF_ERROR_EOF; + } + + if (ci->read_filebuf(&packet_property, 1) == 0) { + DEBUGF("Detected end of stream3\n"); + return ASF_ERROR_EOF; + } + bytesread += 2; + + datalen = GETLEN2b((packet_flags >> 1) & 0x03) + + GETLEN2b((packet_flags >> 3) & 0x03) + + GETLEN2b((packet_flags >> 5) & 0x03) + 6; + + if (ci->read_filebuf(data, datalen) == 0) { + DEBUGF("Detected end of stream4\n"); + return ASF_ERROR_EOF; + } + + bytesread += datalen; + + datap = data; + /* length = GETVALUE2b((packet_flags >> 5) & 0x03, datap); */ + datap += GETLEN2b((packet_flags >> 5) & 0x03); + + /* sequence value is not used */ + GETVALUE2b((packet_flags >> 1) & 0x03, datap); + datap += GETLEN2b((packet_flags >> 1) & 0x03); + /* padding_length = GETVALUE2b((packet_flags >> 3) & 0x03, datap); */ + datap += GETLEN2b((packet_flags >> 3) & 0x03); + send_time = get_long_le(datap); + datap += 4; + *duration = get_short_le(datap); + + /*the asf_get_timestamp function advances us 12-13 bytes past the packet start, + need to undo this here so that we stay synced with the packet*/ + ci->seek_buffer(ci->curpos-bytesread); + + return send_time; +} + +/*entry point for seeks*/ +int asf_seek(int ms, asf_waveformatex_t* wfx) +{ + int time, duration, delta, temp, count=0; + + /*estimate packet number from bitrate*/ + int initial_packet = ci->curpos/wfx->packet_size; + int packet_num = (((int64_t)ms)*(wfx->bitrate>>3))/wfx->packet_size/1000; + int last_packet = ci->id3->filesize / wfx->packet_size; + + if (packet_num > last_packet) { + packet_num = last_packet; + } + + /*calculate byte address of the start of that packet*/ + int packet_offset = packet_num*wfx->packet_size; + + /*seek to estimated packet*/ + ci->seek_buffer(ci->id3->first_frame_offset+packet_offset); + temp = ms; + while (1) + { + /*for very large files it can be difficult and unimportant to find the exact packet*/ + count++; + + /*check the time stamp of our packet*/ + time = asf_get_timestamp(&duration); + /*DEBUGF("seeked to %d ms with duration %d\n", time, duration);*/ + + if (time < 0) { + /*unknown error, try to recover*/ + DEBUGF("UKNOWN SEEK ERROR\n"); + ci->seek_buffer(ci->id3->first_frame_offset+initial_packet*wfx->packet_size); + /*seek failed so return time stamp of the initial packet*/ + return asf_get_timestamp(&duration); + } + + if ((time+duration>=ms && time<=ms) || count > 10) { + /*DEBUGF("Found our packet! Now at %d packet\n", packet_num);*/ + return time; + } else { + /*seek again*/ + delta = ms-time; + /*estimate new packet number from bitrate and our current position*/ + temp += delta; + packet_num = ((temp/1000)*(wfx->bitrate>>3) - (wfx->packet_size>>1))/wfx->packet_size; //round down! + packet_offset = packet_num*wfx->packet_size; + ci->seek_buffer(ci->id3->first_frame_offset+packet_offset); + } + } +} diff --git a/lib/rbcodec/codecs/libasf/asf.h b/lib/rbcodec/codecs/libasf/asf.h new file mode 100644 index 0000000000..a7d384cf3d --- /dev/null +++ b/lib/rbcodec/codecs/libasf/asf.h @@ -0,0 +1,49 @@ +#ifndef _ASF_H +#define _ASF_H + +#include + +/* ASF codec IDs */ +#define ASF_CODEC_ID_WMAV1 0x160 +#define ASF_CODEC_ID_WMAV2 0x161 +#define ASF_CODEC_ID_WMAPRO 0x162 +#define ASF_CODEC_ID_WMAVOICE 0x00A + +enum asf_error_e { + ASF_ERROR_INTERNAL = -1, /* incorrect input to API calls */ + ASF_ERROR_OUTOFMEM = -2, /* some malloc inside program failed */ + ASF_ERROR_EOF = -3, /* unexpected end of file */ + ASF_ERROR_IO = -4, /* error reading or writing to file */ + ASF_ERROR_INVALID_LENGTH = -5, /* length value conflict in input data */ + ASF_ERROR_INVALID_VALUE = -6, /* other value conflict in input data */ + ASF_ERROR_INVALID_OBJECT = -7, /* ASF object missing or in wrong place */ + ASF_ERROR_OBJECT_SIZE = -8, /* invalid ASF object size (too small) */ + ASF_ERROR_SEEKABLE = -9, /* file not seekable */ + ASF_ERROR_SEEK = -10, /* file is seekable but seeking failed */ + ASF_ERROR_ENCRYPTED = -11 /* file is encrypted */ +}; + +struct asf_waveformatex_s { + uint32_t packet_size; + int audiostream; + uint16_t codec_id; + uint16_t channels; + uint32_t rate; + uint32_t bitrate; + uint16_t blockalign; + uint16_t bitspersample; + uint16_t datalen; + uint16_t numpackets; + uint8_t data[46]; +}; +typedef struct asf_waveformatex_s asf_waveformatex_t; + +int asf_read_packet(uint8_t** audiobuf, int* audiobufsize, int* packetlength, + asf_waveformatex_t* wfx); + +int asf_get_timestamp(int *duration); + +int asf_seek(int ms, asf_waveformatex_t* wfx); + + +#endif /* _ASF_H */ diff --git a/lib/rbcodec/codecs/libasf/libasf.make b/lib/rbcodec/codecs/libasf/libasf.make new file mode 100644 index 0000000000..dad0570402 --- /dev/null +++ b/lib/rbcodec/codecs/libasf/libasf.make @@ -0,0 +1,18 @@ +# __________ __ ___. +# Open \______ \ ____ ____ | | _\_ |__ _______ ___ +# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / +# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < +# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ +# \/ \/ \/ \/ \/ +# $Id$ +# + +# libasf +ASFLIB := $(CODECDIR)/libasf.a +ASFLIB_SRC := $(call preprocess, $(RBCODECLIB_DIR)/codecs/libasf/SOURCES) +ASFLIB_OBJ := $(call c2obj, $(ASFLIB_SRC)) +OTHER_SRC += $(ASFLIB_SRC) + +$(ASFLIB): $(ASFLIB_OBJ) + $(SILENT)$(shell rm -f $@) + $(call PRINTS,AR $(@F))$(AR) rcs $@ $^ >/dev/null diff --git a/lib/rbcodec/codecs/libatrac/README.rockbox b/lib/rbcodec/codecs/libatrac/README.rockbox new file mode 100644 index 0000000000..30703a3e49 --- /dev/null +++ b/lib/rbcodec/codecs/libatrac/README.rockbox @@ -0,0 +1,30 @@ +Library: libatrac +Imported by : Mohamed Tarek +Import date : 10-August-2009 + +LICENSING INFORMATION + +ffmpeg is licensed under the Lesser GNU General Public License. + +IMPORT DETAILS + +The decoder is based on ffmpeg-svn r18110 : Mar 21 2009. +Some changes were done on in order to use static VLC tables +according to this commit : +http://git.ffmpeg.org/?p=ffmpeg;a=commit;h=4c20cf13a166577d93f5b2b0abb4609c60104d33 + +The decoder had been modified to use fixed-point arithmetic. + +TESTING + +The test program should compile in any Unix-like environment using the +command "make -f Makefile.test". + +For ARM targets add -DCPU_ARM to CFLAGS in Makefile.test to make use of +the asm ARM optimisations in rockbox's mdct library. + +For Big-endian targets, change -D"ROCKBOX_LITTLE_ENDIAN=1" +to -D"ROCKBOX_BIG_ENDIAN=1" in Makefile.test. + +Running "./atractest file.rm" will decode the audio data to a WAV file +called "output.wav" in the current directory. diff --git a/lib/rbcodec/codecs/libatrac/SOURCES b/lib/rbcodec/codecs/libatrac/SOURCES new file mode 100644 index 0000000000..85f011cb87 --- /dev/null +++ b/lib/rbcodec/codecs/libatrac/SOURCES @@ -0,0 +1,8 @@ +atrac3.c +#if defined(CPU_ARM) +atrac3_arm.S +#if (ARM_ARCH >= 5) +atrac3_armv5e.S +#endif +#endif + diff --git a/lib/rbcodec/codecs/libatrac/atrac3.c b/lib/rbcodec/codecs/libatrac/atrac3.c new file mode 100644 index 0000000000..bb52dd4cf0 --- /dev/null +++ b/lib/rbcodec/codecs/libatrac/atrac3.c @@ -0,0 +1,1293 @@ +/* + * Atrac 3 compatible decoder + * Copyright (c) 2006-2008 Maxim Poliakovski + * Copyright (c) 2006-2008 Benjamin Larsson + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file libavcodec/atrac3.c + * Atrac 3 compatible decoder. + * This decoder handles Sony's ATRAC3 data. + * + * Container formats used to store atrac 3 data: + * RealMedia (.rm), RIFF WAV (.wav, .at3), Sony OpenMG (.oma, .aa3). + * + * To use this decoder, a calling application must supply the extradata + * bytes provided in the containers above. + */ + +#include +#include +#include + +#include "atrac3.h" +#include "atrac3data.h" +#include "atrac3data_fixed.h" +#include "fixp_math.h" + +#define JOINT_STEREO 0x12 +#define STEREO 0x2 + +#ifdef ROCKBOX +#undef DEBUGF +#define DEBUGF(...) +#endif /* ROCKBOX */ + +/* FFMAX/MIN/SWAP and av_clip were taken from libavutil/common.h */ +#define FFMAX(a,b) ((a) > (b) ? (a) : (b)) +#define FFMIN(a,b) ((a) > (b) ? (b) : (a)) +#define FFSWAP(type,a,b) do{type SWAP_tmp= b; b= a; a= SWAP_tmp;}while(0) + +#if defined(CPU_ARM) && (ARM_ARCH >= 5) + #define QMFWIN_TYPE int16_t /* ARMv5e+ uses 32x16 multiplication */ +#else + #define QMFWIN_TYPE int32_t +#endif + +static VLC spectral_coeff_tab[7] IBSS_ATTR_LARGE_IRAM; +static QMFWIN_TYPE qmf_window[48] IBSS_ATTR MEM_ALIGN_ATTR; +static int32_t atrac3_spectrum [2][1024] IBSS_ATTR MEM_ALIGN_ATTR; +static int32_t atrac3_IMDCT_buf[2][ 512] IBSS_ATTR MEM_ALIGN_ATTR; +static int32_t atrac3_prevFrame[2][1024] IBSS_ATTR MEM_ALIGN_ATTR; +static channel_unit channel_units[2] IBSS_ATTR_LARGE_IRAM; +static VLC_TYPE atrac3_vlc_table[4096][2] IBSS_ATTR_LARGE_IRAM; +static int vlcs_initialized = 0; + + + +/** + * Matrixing within quadrature mirror synthesis filter. + * + * @param p3 output buffer + * @param inlo lower part of spectrum + * @param inhi higher part of spectrum + * @param nIn size of spectrum buffer + */ + +#if defined(CPU_ARM) + extern void + atrac3_iqmf_matrixing(int32_t *p3, + int32_t *inlo, + int32_t *inhi, + unsigned int nIn); +#else + static inline void + atrac3_iqmf_matrixing(int32_t *p3, + int32_t *inlo, + int32_t *inhi, + unsigned int nIn) + { + uint32_t i; + for(i=0; i= 5) + extern void + atrac3_iqmf_dewindowing_armv5e(int32_t *out, + int32_t *in, + int16_t *win, + unsigned int nIn); + static inline void + atrac3_iqmf_dewindowing(int32_t *out, + int32_t *in, + int16_t *win, + unsigned int nIn) + { + atrac3_iqmf_dewindowing_armv5e(out, in, win, nIn); + + } + + +#elif defined(CPU_ARM) + extern void + atrac3_iqmf_dewindowing(int32_t *out, + int32_t *in, + int32_t *win, + unsigned int nIn); + +#elif defined (CPU_COLDFIRE) + #define MULTIPLY_ADD_BLOCK \ + "movem.l (%[win]), %%d0-%%d7 \n\t" \ + "lea.l (8*4, %[win]), %[win] \n\t" \ + "mac.l %%d0, %%a5, (%[in])+, %%a5, %%acc0\n\t" \ + "mac.l %%d1, %%a5, (%[in])+, %%a5, %%acc1\n\t" \ + "mac.l %%d2, %%a5, (%[in])+, %%a5, %%acc0\n\t" \ + "mac.l %%d3, %%a5, (%[in])+, %%a5, %%acc1\n\t" \ + "mac.l %%d4, %%a5, (%[in])+, %%a5, %%acc0\n\t" \ + "mac.l %%d5, %%a5, (%[in])+, %%a5, %%acc1\n\t" \ + "mac.l %%d6, %%a5, (%[in])+, %%a5, %%acc0\n\t" \ + "mac.l %%d7, %%a5, (%[in])+, %%a5, %%acc1\n\t" \ + + + static inline void + atrac3_iqmf_dewindowing(int32_t *out, + int32_t *in, + int32_t *win, + unsigned int nIn) + { + int32_t j; + int32_t *_in, *_win; + for (j = nIn; j != 0; j--, in+=2, out+=2) { + _in = in; + _win = win; + + asm volatile ( + "move.l (%[in])+, %%a5 \n\t" /* preload frist in value */ + MULTIPLY_ADD_BLOCK /* 0.. 7 */ + MULTIPLY_ADD_BLOCK /* 8..15 */ + MULTIPLY_ADD_BLOCK /* 16..23 */ + MULTIPLY_ADD_BLOCK /* 24..31 */ + MULTIPLY_ADD_BLOCK /* 32..39 */ + /* 40..47 */ + "movem.l (%[win]), %%d0-%%d7 \n\t" + "mac.l %%d0, %%a5, (%[in])+, %%a5, %%acc0 \n\t" + "mac.l %%d1, %%a5, (%[in])+, %%a5, %%acc1 \n\t" + "mac.l %%d2, %%a5, (%[in])+, %%a5, %%acc0 \n\t" + "mac.l %%d3, %%a5, (%[in])+, %%a5, %%acc1 \n\t" + "mac.l %%d4, %%a5, (%[in])+, %%a5, %%acc0 \n\t" + "mac.l %%d5, %%a5, (%[in])+, %%a5, %%acc1 \n\t" + "mac.l %%d6, %%a5, (%[in])+, %%a5, %%acc0 \n\t" + "mac.l %%d7, %%a5, %%acc1 \n\t" + "movclr.l %%acc0, %%d1 \n\t" /* s1 */ + "movclr.l %%acc1, %%d0 \n\t" /* s2 */ + "movem.l %%d0-%%d1, (%[out]) \n\t" + : [in] "+a" (_in), [win] "+a" (_win) + : [out] "a" (out) + : "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", "a5", "memory"); + } + } +#else + #define MULTIPLY_ADD_BLOCK(y1, y2, x, c, k) \ + y1 += fixmul31(c[k], x[k]); k++; \ + y2 += fixmul31(c[k], x[k]); k++; \ + y1 += fixmul31(c[k], x[k]); k++; \ + y2 += fixmul31(c[k], x[k]); k++; \ + y1 += fixmul31(c[k], x[k]); k++; \ + y2 += fixmul31(c[k], x[k]); k++; \ + y1 += fixmul31(c[k], x[k]); k++; \ + y2 += fixmul31(c[k], x[k]); k++; + + static inline void + atrac3_iqmf_dewindowing(int32_t *out, + int32_t *in, + int32_t *win, + unsigned int nIn) + { + int32_t i, j, s1, s2; + + for (j = nIn; j != 0; j--, in+=2, out+=2) { + s1 = s2 = i = 0; + + MULTIPLY_ADD_BLOCK(s1, s2, in, win, i); /* 0.. 7 */ + MULTIPLY_ADD_BLOCK(s1, s2, in, win, i); /* 8..15 */ + MULTIPLY_ADD_BLOCK(s1, s2, in, win, i); /* 16..23 */ + MULTIPLY_ADD_BLOCK(s1, s2, in, win, i); /* 24..31 */ + MULTIPLY_ADD_BLOCK(s1, s2, in, win, i); /* 32..39 */ + MULTIPLY_ADD_BLOCK(s1, s2, in, win, i); /* 40..47 */ + + out[0] = s2; + out[1] = s1; + + } + + } +#endif + + +/** + * IMDCT windowing. + * + * @param buffer sample buffer + * @param win window coefficients + */ + +static inline void +atrac3_imdct_windowing(int32_t *buffer, + const int32_t *win) +{ + int32_t i; + /* win[0..127] = win[511..384], win[128..383] = 1 */ + for(i = 0; i<128; i++) { + buffer[ i] = fixmul31(win[i], buffer[ i]); + buffer[511-i] = fixmul31(win[i], buffer[511-i]); + } +} + + +/** + * Quadrature mirror synthesis filter. + * + * @param inlo lower part of spectrum + * @param inhi higher part of spectrum + * @param nIn size of spectrum buffer + * @param pOut out buffer + * @param delayBuf delayBuf buffer + * @param temp temp buffer + */ + +static void iqmf (int32_t *inlo, int32_t *inhi, unsigned int nIn, int32_t *pOut, int32_t *delayBuf, int32_t *temp) +{ + + /* Restore the delay buffer */ + memcpy(temp, delayBuf, 46*sizeof(int32_t)); + + /* loop1: matrixing */ + atrac3_iqmf_matrixing(temp + 46, inlo, inhi, nIn); + + /* loop2: dewindowing */ + atrac3_iqmf_dewindowing(pOut, temp, qmf_window, nIn); + + /* Save the delay buffer */ + memcpy(delayBuf, temp + (nIn << 1), 46*sizeof(int32_t)); +} + + +/** + * Regular 512 points IMDCT without overlapping, with the exception of the swapping of odd bands + * caused by the reverse spectra of the QMF. + * + * @param pInput input + * @param pOutput output + * @param odd_band 1 if the band is an odd band + */ + +static void IMLT(int32_t *pInput, int32_t *pOutput) +{ + /* Apply the imdct. */ + ff_imdct_calc(9, pOutput, pInput); + + /* Windowing. */ + atrac3_imdct_windowing(pOutput, window_lookup); + +} + + +/** + * Atrac 3 indata descrambling, only used for data coming from the rm container + * + * @param in pointer to 8 bit array of indata + * @param bits amount of bits + * @param out pointer to 8 bit array of outdata + */ + +static int decode_bytes(const uint8_t* inbuffer, uint8_t* out, int bytes){ + int i, off; + uint32_t c; + const uint32_t* buf; + uint32_t* obuf = (uint32_t*) out; + +#if ((defined(TEST) || defined(SIMULATOR)) && !defined(CPU_ARM)) + off = 0; /* no check for memory alignment of inbuffer */ +#else + off = (intptr_t)inbuffer & 3; +#endif /* TEST */ + buf = (const uint32_t*) (inbuffer - off); + + c = be2me_32((0x537F6103 >> (off*8)) | (0x537F6103 << (32-(off*8)))); + bytes += 3 + off; + for (i = 0; i < bytes/4; i++) + obuf[i] = c ^ buf[i]; + + return off; +} + + +static void init_atrac3_transforms(void) +{ + int32_t s; + int i; + + /* Generate the mdct window, for details see + * http://wiki.multimedia.cx/index.php?title=RealAudio_atrc#Windows */ + + /* mdct window had been generated and saved as a lookup table in atrac3data_fixed.h */ + + /* Generate the QMF window. */ + for (i=0 ; i<24; i++) { + s = qmf_48tap_half_fix[i] << 1; + #if defined(CPU_ARM) && (ARM_ARCH >= 5) + qmf_window[i] = qmf_window[47-i] = (int16_t)((s+(1<<15))>>16); + #else + qmf_window[i] = qmf_window[47-i] = s; + #endif + } + +} + + +/** + * Mantissa decoding + * + * @param gb the GetBit context + * @param selector what table is the output values coded with + * @param codingFlag constant length coding or variable length coding + * @param mantissas mantissa output table + * @param numCodes amount of values to get + */ + +static void readQuantSpectralCoeffs (GetBitContext *gb, int selector, int codingFlag, int* mantissas, int numCodes) +{ + int numBits, cnt, code, huffSymb; + + if (selector == 1) + numCodes /= 2; + + if (codingFlag != 0) { + /* constant length coding (CLC) */ + numBits = CLCLengthTab[selector]; + + if (selector > 1) { + for (cnt = 0; cnt < numCodes; cnt++) { + if (numBits) + code = get_sbits(gb, numBits); + else + code = 0; + mantissas[cnt] = code; + } + } else { + for (cnt = 0; cnt < numCodes; cnt++) { + if (numBits) + code = get_bits(gb, numBits); /* numBits is always 4 in this case */ + else + code = 0; + mantissas[cnt*2] = seTab_0[code >> 2]; + mantissas[cnt*2+1] = seTab_0[code & 3]; + } + } + } else { + /* variable length coding (VLC) */ + if (selector != 1) { + for (cnt = 0; cnt < numCodes; cnt++) { + huffSymb = get_vlc2(gb, spectral_coeff_tab[selector-1].table, spectral_coeff_tab[selector-1].bits, 3); + huffSymb += 1; + code = huffSymb >> 1; + if (huffSymb & 1) + code = -code; + mantissas[cnt] = code; + } + } else { + for (cnt = 0; cnt < numCodes; cnt++) { + huffSymb = get_vlc2(gb, spectral_coeff_tab[selector-1].table, spectral_coeff_tab[selector-1].bits, 3); + mantissas[cnt*2] = decTable1[huffSymb*2]; + mantissas[cnt*2+1] = decTable1[huffSymb*2+1]; + } + } + } +} + + +/** + * Requantize the spectrum. + * + * @param *mantissas pointer to mantissas for each spectral line + * @param pOut requantized band spectrum + * @param first first spectral line in subband + * @param last last spectral line in subband + * @param SF scalefactor for all spectral lines of this band + */ + +static void inverseQuantizeSpectrum(int *mantissas, int32_t *pOut, + int32_t first, int32_t last, int32_t SF) +{ + int *pIn = mantissas; + + /* Inverse quantize the coefficients. */ + if((first/256) &1) { + /* Odd band - Reverse coefficients */ + do { + pOut[last--] = fixmul16(*pIn++, SF); + pOut[last--] = fixmul16(*pIn++, SF); + pOut[last--] = fixmul16(*pIn++, SF); + pOut[last--] = fixmul16(*pIn++, SF); + pOut[last--] = fixmul16(*pIn++, SF); + pOut[last--] = fixmul16(*pIn++, SF); + pOut[last--] = fixmul16(*pIn++, SF); + pOut[last--] = fixmul16(*pIn++, SF); + } while (last>first); + } else { + /* Even band - Do not reverse coefficients */ + do { + pOut[first++] = fixmul16(*pIn++, SF); + pOut[first++] = fixmul16(*pIn++, SF); + pOut[first++] = fixmul16(*pIn++, SF); + pOut[first++] = fixmul16(*pIn++, SF); + pOut[first++] = fixmul16(*pIn++, SF); + pOut[first++] = fixmul16(*pIn++, SF); + pOut[first++] = fixmul16(*pIn++, SF); + pOut[first++] = fixmul16(*pIn++, SF); + } while (first> 2] == 0) + continue; + + coded_components = get_bits(gb,3); + + for (k=0; kgBlock; + + for (i=0 ; i<=numBands; i++) + { + numData = get_bits(gb,3); + pGain[i].num_gain_data = numData; + pLevel = pGain[i].levcode; + pLoc = pGain[i].loccode; + + for (cf = 0; cf < numData; cf++){ + pLevel[cf]= get_bits(gb,4); + pLoc [cf]= get_bits(gb,5); + if(cf && pLoc[cf] <= pLoc[cf-1]) + return -1; + } + } + + /* Clear the unused blocks. */ + for (; i<4 ; i++) + pGain[i].num_gain_data = 0; + + return 0; +} + + +/** + * Apply fix (constant) gain and overlap for sample[start...255]. + * + * @param pIn input buffer + * @param pPrev previous buffer to perform overlap against + * @param pOut output buffer + * @param start index to start with (always a multiple of 8) + * @param gain gain to apply + */ + +static void applyFixGain (int32_t *pIn, int32_t *pPrev, int32_t *pOut, + int32_t start, int32_t gain) +{ + int32_t i = start; + + /* start is always a multiple of 8 and therefore allows us to unroll the + * loop to 8 calculation per loop + */ + if (ONE_16 == gain) { + /* gain1 = 1.0 -> no multiplication needed, just adding */ + /* Remark: This path is called >90%. */ + while (i<256) { + pOut[i] = pIn[i] + pPrev[i]; i++; + pOut[i] = pIn[i] + pPrev[i]; i++; + pOut[i] = pIn[i] + pPrev[i]; i++; + pOut[i] = pIn[i] + pPrev[i]; i++; + pOut[i] = pIn[i] + pPrev[i]; i++; + pOut[i] = pIn[i] + pPrev[i]; i++; + pOut[i] = pIn[i] + pPrev[i]; i++; + pOut[i] = pIn[i] + pPrev[i]; i++; + }; + } else { + /* gain1 != 1.0 -> we need to do a multiplication */ + /* Remark: This path is called seldom. */ + while (i<256) { + pOut[i] = fixmul16(pIn[i], gain) + pPrev[i]; i++; + pOut[i] = fixmul16(pIn[i], gain) + pPrev[i]; i++; + pOut[i] = fixmul16(pIn[i], gain) + pPrev[i]; i++; + pOut[i] = fixmul16(pIn[i], gain) + pPrev[i]; i++; + pOut[i] = fixmul16(pIn[i], gain) + pPrev[i]; i++; + pOut[i] = fixmul16(pIn[i], gain) + pPrev[i]; i++; + pOut[i] = fixmul16(pIn[i], gain) + pPrev[i]; i++; + pOut[i] = fixmul16(pIn[i], gain) + pPrev[i]; i++; + }; + } +} + + +/** + * Apply variable gain and overlap. Returns sample index after applying gain, + * resulting sample index is always a multiple of 8. + * + * @param pIn input buffer + * @param pPrev previous buffer to perform overlap against + * @param pOut output buffer + * @param start index to start with (always a multiple of 8) + * @param end end index for first loop (always a multiple of 8) + * @param gain1 current bands gain to apply + * @param gain2 next bands gain to apply + * @param gain_inc stepwise adaption from gain1 to gain2 + */ + +static int applyVariableGain (int32_t *pIn, int32_t *pPrev, int32_t *pOut, + int32_t start, int32_t end, + int32_t gain1, int32_t gain2, int32_t gain_inc) +{ + int32_t i = start; + + /* Apply fix gains until end index is reached */ + do { + pOut[i] = fixmul16((fixmul16(pIn[i], gain1) + pPrev[i]), gain2); i++; + pOut[i] = fixmul16((fixmul16(pIn[i], gain1) + pPrev[i]), gain2); i++; + pOut[i] = fixmul16((fixmul16(pIn[i], gain1) + pPrev[i]), gain2); i++; + pOut[i] = fixmul16((fixmul16(pIn[i], gain1) + pPrev[i]), gain2); i++; + pOut[i] = fixmul16((fixmul16(pIn[i], gain1) + pPrev[i]), gain2); i++; + pOut[i] = fixmul16((fixmul16(pIn[i], gain1) + pPrev[i]), gain2); i++; + pOut[i] = fixmul16((fixmul16(pIn[i], gain1) + pPrev[i]), gain2); i++; + pOut[i] = fixmul16((fixmul16(pIn[i], gain1) + pPrev[i]), gain2); i++; + } while (i < end); + + /* Interpolation is done over next eight samples */ + pOut[i] = fixmul16((fixmul16(pIn[i], gain1) + pPrev[i]), gain2); i++; + gain2 = fixmul16(gain2, gain_inc); + pOut[i] = fixmul16((fixmul16(pIn[i], gain1) + pPrev[i]), gain2); i++; + gain2 = fixmul16(gain2, gain_inc); + pOut[i] = fixmul16((fixmul16(pIn[i], gain1) + pPrev[i]), gain2); i++; + gain2 = fixmul16(gain2, gain_inc); + pOut[i] = fixmul16((fixmul16(pIn[i], gain1) + pPrev[i]), gain2); i++; + gain2 = fixmul16(gain2, gain_inc); + pOut[i] = fixmul16((fixmul16(pIn[i], gain1) + pPrev[i]), gain2); i++; + gain2 = fixmul16(gain2, gain_inc); + pOut[i] = fixmul16((fixmul16(pIn[i], gain1) + pPrev[i]), gain2); i++; + gain2 = fixmul16(gain2, gain_inc); + pOut[i] = fixmul16((fixmul16(pIn[i], gain1) + pPrev[i]), gain2); i++; + gain2 = fixmul16(gain2, gain_inc); + pOut[i] = fixmul16((fixmul16(pIn[i], gain1) + pPrev[i]), gain2); i++; + gain2 = fixmul16(gain2, gain_inc); + + return i; +} + + +/** + * Apply gain parameters and perform the MDCT overlapping part + * + * @param pIn input buffer + * @param pPrev previous buffer to perform overlap against + * @param pOut output buffer + * @param pGain1 current band gain info + * @param pGain2 next band gain info + */ + +static void gainCompensateAndOverlap (int32_t *pIn, int32_t *pPrev, int32_t *pOut, + gain_info *pGain1, gain_info *pGain2) +{ + /* gain compensation function */ + int32_t gain1, gain2, gain_inc; + int cnt, numdata, nsample, startLoc; + + if (pGain2->num_gain_data == 0) + gain1 = ONE_16; + else + gain1 = (ONE_16<<4)>>(pGain2->levcode[0]); + + if (pGain1->num_gain_data == 0) { + /* Remark: This path is called >90%. */ + /* Apply gain for all samples from 0...255 */ + applyFixGain(pIn, pPrev, pOut, 0, gain1); + } else { + /* Remark: This path is called seldom. */ + numdata = pGain1->num_gain_data; + pGain1->loccode[numdata] = 32; + pGain1->levcode[numdata] = 4; + + nsample = 0; /* starting loop with =0 */ + + for (cnt = 0; cnt < numdata; cnt++) { + startLoc = pGain1->loccode[cnt] * 8; + + gain2 = (ONE_16<<4)>>(pGain1->levcode[cnt]); + gain_inc = gain_tab2[(pGain1->levcode[cnt+1] - pGain1->levcode[cnt])+15]; + + /* Apply variable gain (gain1 -> gain2) to samples */ + nsample = applyVariableGain(pIn, pPrev, pOut, nsample, startLoc, gain1, gain2, gain_inc); + } + /* Apply gain for the residual samples from nsample...255 */ + applyFixGain(pIn, pPrev, pOut, nsample, gain1); + } + + /* Delay for the overlapping part. */ + memcpy(pPrev, &pIn[256], 256*sizeof(int32_t)); +} + + +/** + * Combine the tonal band spectrum and regular band spectrum + * Return position of the last tonal coefficient + + * + * @param pSpectrum output spectrum buffer + * @param numComponents amount of tonal components + * @param pComponent tonal components for this band + */ + +static int addTonalComponents (int32_t *pSpectrum, int numComponents, tonal_component *pComponent) +{ + int cnt, i, lastPos = -1; + int32_t *pOut; + int32_t *pIn; + + for (cnt = 0; cnt < numComponents; cnt++){ + lastPos = FFMAX(pComponent[cnt].pos + pComponent[cnt].numCoefs, lastPos); + pIn = pComponent[cnt].coef; + pOut = &(pSpectrum[pComponent[cnt].pos]); + + for (i=0 ; i>3), (((y) - (x))))) +*/ +#define INTERPOLATE_FP16(x, y, s) ((x) + ((s*((y)-(x)))>>3)) + +static void reverseMatrixing(int32_t *su1, int32_t *su2, int *pPrevCode, int *pCurrCode) +{ + int i, band, nsample, s1, s2; + int32_t c1, c2; + int32_t mc1_l, mc1_r, mc2_l, mc2_r; + + for (i=0,band = 0; band < 4*256; band+=256,i++) { + s1 = pPrevCode[i]; + s2 = pCurrCode[i]; + nsample = 0; + + if (s1 != s2) { + /* Selector value changed, interpolation needed. */ + mc1_l = matrixCoeffs_fix[s1<<1]; + mc1_r = matrixCoeffs_fix[(s1<<1)+1]; + mc2_l = matrixCoeffs_fix[s2<<1]; + mc2_r = matrixCoeffs_fix[(s2<<1)+1]; + + /* Interpolation is done over the first eight samples. */ + for(; nsample < 8; nsample++) { + c1 = su1[band+nsample]; + c2 = su2[band+nsample]; + c2 = fixmul16(c1, INTERPOLATE_FP16(mc1_l, mc2_l, nsample)) + fixmul16(c2, INTERPOLATE_FP16(mc1_r, mc2_r, nsample)); + su1[band+nsample] = c2; + su2[band+nsample] = (c1 << 1) - c2; + } + } + + /* Apply the matrix without interpolation. */ + switch (s2) { + case 0: /* M/S decoding */ + for (; nsample < 256; nsample++) { + c1 = su1[band+nsample]; + c2 = su2[band+nsample]; + su1[band+nsample] = c2 << 1; + su2[band+nsample] = (c1 - c2) << 1; + } + break; + + case 1: + for (; nsample < 256; nsample++) { + c1 = su1[band+nsample]; + c2 = su2[band+nsample]; + su1[band+nsample] = (c1 + c2) << 1; + su2[band+nsample] = -1*(c2 << 1); + } + break; + case 2: + case 3: + for (; nsample < 256; nsample++) { + c1 = su1[band+nsample]; + c2 = su2[band+nsample]; + su1[band+nsample] = c1 + c2; + su2[band+nsample] = c1 - c2; + } + break; + default: + /* assert(0) */; + break; + } + } +} + +static void getChannelWeights (int indx, int flag, int32_t ch[2]){ + /* Read channel weights from table */ + if (flag) { + /* Swap channel weights */ + ch[1] = channelWeights0[indx&7]; + ch[0] = channelWeights1[indx&7]; + } else { + ch[0] = channelWeights0[indx&7]; + ch[1] = channelWeights1[indx&7]; + } +} + +static void channelWeighting (int32_t *su1, int32_t *su2, int *p3) +{ + int band, nsample; + /* w[x][y] y=0 is left y=1 is right */ + int32_t w[2][2]; + + if (p3[1] != 7 || p3[3] != 7){ + getChannelWeights(p3[1], p3[0], w[0]); + getChannelWeights(p3[3], p3[2], w[1]); + + for(band = 1; band < 4; band++) { + /* scale the channels by the weights */ + for(nsample = 0; nsample < 8; nsample++) { + su1[band*256+nsample] = fixmul16(su1[band*256+nsample], INTERPOLATE_FP16(w[0][0], w[0][1], nsample)); + su2[band*256+nsample] = fixmul16(su2[band*256+nsample], INTERPOLATE_FP16(w[1][0], w[1][1], nsample)); + } + + for(; nsample < 256; nsample++) { + su1[band*256+nsample] = fixmul16(su1[band*256+nsample], w[1][0]); + su2[band*256+nsample] = fixmul16(su2[band*256+nsample], w[1][1]); + } + } + } +} + +/** + * Decode a Sound Unit + * + * @param gb the GetBit context + * @param pSnd the channel unit to be used + * @param pOut the decoded samples before IQMF + * @param channelNum channel number + * @param codingMode the coding mode (JOINT_STEREO or regular stereo/mono) + */ + +static int decodeChannelSoundUnit (GetBitContext *gb, channel_unit *pSnd, int32_t *pOut, int channelNum, int codingMode) +{ + int band, result=0, numSubbands, lastTonal, numBands; + if (codingMode == JOINT_STEREO && channelNum == 1) { + if (get_bits(gb,2) != 3) { + DEBUGF("JS mono Sound Unit id != 3.\n"); + return -1; + } + } else { + if (get_bits(gb,6) != 0x28) { + DEBUGF("Sound Unit id != 0x28.\n"); + return -1; + } + } + + /* number of coded QMF bands */ + pSnd->bandsCoded = get_bits(gb,2); + + result = decodeGainControl (gb, &(pSnd->gainBlock[pSnd->gcBlkSwitch]), pSnd->bandsCoded); + if (result) return result; + + pSnd->numComponents = decodeTonalComponents (gb, pSnd->components, pSnd->bandsCoded); + if (pSnd->numComponents == -1) return -1; + + numSubbands = decodeSpectrum (gb, pSnd->spectrum); + + /* Merge the decoded spectrum and tonal components. */ + lastTonal = addTonalComponents (pSnd->spectrum, pSnd->numComponents, pSnd->components); + + + /* calculate number of used MLT/QMF bands according to the amount of coded spectral lines */ + numBands = (subbandTab[numSubbands] - 1) >> 8; + if (lastTonal >= 0) + numBands = FFMAX((lastTonal + 256) >> 8, numBands); + + /* Reconstruct time domain samples. */ + for (band=0; band<4; band++) { + /* Perform the IMDCT step without overlapping. */ + if (band <= numBands) { + IMLT(&(pSnd->spectrum[band*256]), pSnd->IMDCT_buf); + } else { + memset(pSnd->IMDCT_buf, 0, 512 * sizeof(int32_t)); + } + + /* gain compensation and overlapping */ + gainCompensateAndOverlap (pSnd->IMDCT_buf, &(pSnd->prevFrame[band*256]), &(pOut[band*256]), + &((pSnd->gainBlock[1 - (pSnd->gcBlkSwitch)]).gBlock[band]), + &((pSnd->gainBlock[pSnd->gcBlkSwitch]).gBlock[band])); + } + + /* Swap the gain control buffers for the next frame. */ + pSnd->gcBlkSwitch ^= 1; + + return 0; +} + +/** + * Frame handling + * + * @param q Atrac3 private context + * @param databuf the input data + */ + +static int decodeFrame(ATRAC3Context *q, const uint8_t* databuf, int off) +{ + int result, i; + int32_t *p1, *p2, *p3, *p4; + uint8_t *ptr1; + + if (q->codingMode == JOINT_STEREO) { + + /* channel coupling mode */ + /* decode Sound Unit 1 */ + init_get_bits(&q->gb,databuf,q->bits_per_frame); + + result = decodeChannelSoundUnit(&q->gb, q->pUnits, q->outSamples, 0, JOINT_STEREO); + if (result != 0) + return (result); + + /* Framedata of the su2 in the joint-stereo mode is encoded in + * reverse byte order so we need to swap it first. */ + if (databuf == q->decoded_bytes_buffer) { + uint8_t *ptr2 = q->decoded_bytes_buffer+q->bytes_per_frame-1; + ptr1 = q->decoded_bytes_buffer; + for (i = 0; i < (q->bytes_per_frame/2); i++, ptr1++, ptr2--) { + FFSWAP(uint8_t,*ptr1,*ptr2); + } + } else { + const uint8_t *ptr2 = databuf+q->bytes_per_frame-1; + for (i = 0; i < q->bytes_per_frame; i++) + q->decoded_bytes_buffer[i] = *ptr2--; + } + + /* Skip the sync codes (0xF8). */ + ptr1 = q->decoded_bytes_buffer; + for (i = 4; *ptr1 == 0xF8; i++, ptr1++) { + if (i >= q->bytes_per_frame) + return -1; + } + + + /* set the bitstream reader at the start of the second Sound Unit*/ + init_get_bits(&q->gb,ptr1,q->bits_per_frame); + + /* Fill the Weighting coeffs delay buffer */ + memmove(q->weighting_delay,&(q->weighting_delay[2]),4*sizeof(int)); + q->weighting_delay[4] = get_bits1(&q->gb); + q->weighting_delay[5] = get_bits(&q->gb,3); + + for (i = 0; i < 4; i++) { + q->matrix_coeff_index_prev[i] = q->matrix_coeff_index_now[i]; + q->matrix_coeff_index_now[i] = q->matrix_coeff_index_next[i]; + q->matrix_coeff_index_next[i] = get_bits(&q->gb,2); + } + + /* Decode Sound Unit 2. */ + result = decodeChannelSoundUnit(&q->gb, &q->pUnits[1], &q->outSamples[1024], 1, JOINT_STEREO); + if (result != 0) + return (result); + + /* Reconstruct the channel coefficients. */ + reverseMatrixing(q->outSamples, &q->outSamples[1024], q->matrix_coeff_index_prev, q->matrix_coeff_index_now); + + channelWeighting(q->outSamples, &q->outSamples[1024], q->weighting_delay); + + } else { + /* normal stereo mode or mono */ + /* Decode the channel sound units. */ + for (i=0 ; ichannels ; i++) { + + /* Set the bitstream reader at the start of a channel sound unit. */ + init_get_bits(&q->gb, databuf+((i*q->bytes_per_frame)/q->channels)+off, (q->bits_per_frame)/q->channels); + + result = decodeChannelSoundUnit(&q->gb, &q->pUnits[i], &q->outSamples[i*1024], i, q->codingMode); + if (result != 0) + return (result); + } + } + + /* Apply the iQMF synthesis filter. */ + p1= q->outSamples; + for (i=0 ; ichannels ; i++) { + p2= p1+256; + p3= p2+256; + p4= p3+256; + iqmf (p1, p2, 256, p1, q->pUnits[i].delayBuf1, q->tempBuf); + iqmf (p4, p3, 256, p3, q->pUnits[i].delayBuf2, q->tempBuf); + iqmf (p1, p3, 512, p1, q->pUnits[i].delayBuf3, q->tempBuf); + p1 +=1024; + } + + return 0; +} + + +/** + * Atrac frame decoding + * + * @param rmctx pointer to the AVCodecContext + */ + +int atrac3_decode_frame(unsigned long block_align, ATRAC3Context *q, + int *data_size, const uint8_t *buf, int buf_size) { + int result = 0, off = 0; + const uint8_t* databuf; + + if ((unsigned)buf_size < block_align) + return buf_size; + + /* Check if we need to descramble and what buffer to pass on. */ + if (q->scrambled_stream) { + off = decode_bytes(buf, q->decoded_bytes_buffer, block_align); + databuf = q->decoded_bytes_buffer; + } else { + databuf = buf; + } + + result = decodeFrame(q, databuf, off); + + if (result != 0) { + DEBUGF("Frame decoding error!\n"); + return -1; + } + + if (q->channels == 1) + *data_size = 1024 * sizeof(int32_t); + else + *data_size = 2048 * sizeof(int32_t); + + return block_align; +} + + +/** + * Atrac3 initialization + * + * @param rmctx pointer to the RMContext + */ +int atrac3_decode_init(ATRAC3Context *q, struct mp3entry *id3) +{ + int i; + uint8_t *edata_ptr = (uint8_t*)&id3->id3v2buf; + +#if defined(CPU_COLDFIRE) + coldfire_set_macsr(EMAC_FRACTIONAL | EMAC_SATURATE); +#endif + + /* Take data from the RM container. */ + q->sample_rate = id3->frequency; + q->channels = id3->channels; + q->bit_rate = id3->bitrate * 1000; + q->bits_per_frame = id3->bytesperframe * 8; + q->bytes_per_frame = id3->bytesperframe; + + /* Take care of the codec-specific extradata. */ + + if (id3->extradata_size == 14) { + /* Parse the extradata, WAV format */ + DEBUGF("[0-1] %d\n",rm_get_uint16le(&edata_ptr[0])); /* Unknown value always 1 */ + q->samples_per_channel = rm_get_uint32le(&edata_ptr[2]); + q->codingMode = rm_get_uint16le(&edata_ptr[6]); + DEBUGF("[8-9] %d\n",rm_get_uint16le(&edata_ptr[8])); /* Dupe of coding mode */ + q->frame_factor = rm_get_uint16le(&edata_ptr[10]); /* Unknown always 1 */ + DEBUGF("[12-13] %d\n",rm_get_uint16le(&edata_ptr[12])); /* Unknown always 0 */ + + /* setup */ + q->samples_per_frame = 1024 * q->channels; + q->atrac3version = 4; + q->delay = 0x88E; + if (q->codingMode) + q->codingMode = JOINT_STEREO; + else + q->codingMode = STEREO; + q->scrambled_stream = 0; + + if ((q->bytes_per_frame == 96*q->channels*q->frame_factor) || (q->bytes_per_frame == 152*q->channels*q->frame_factor) || (q->bytes_per_frame == 192*q->channels*q->frame_factor)) { + } else { + DEBUGF("Unknown frame/channel/frame_factor configuration %d/%d/%d\n", q->bytes_per_frame, q->channels, q->frame_factor); + return -1; + } + + } else if (id3->extradata_size == 10) { + /* Parse the extradata, RM format. */ + q->atrac3version = rm_get_uint32be(&edata_ptr[0]); + q->samples_per_frame = rm_get_uint16be(&edata_ptr[4]); + q->delay = rm_get_uint16be(&edata_ptr[6]); + q->codingMode = rm_get_uint16be(&edata_ptr[8]); + + q->samples_per_channel = q->samples_per_frame / q->channels; + q->scrambled_stream = 1; + + } else { + DEBUGF("Unknown extradata size %d.\n",id3->extradata_size); + } + /* Check the extradata. */ + + if (q->atrac3version != 4) { + DEBUGF("Version %d != 4.\n",q->atrac3version); + return -1; + } + + if (q->samples_per_frame != 1024 && q->samples_per_frame != 2048) { + DEBUGF("Unknown amount of samples per frame %d.\n",q->samples_per_frame); + return -1; + } + + if (q->delay != 0x88E) { + DEBUGF("Unknown amount of delay %x != 0x88E.\n",q->delay); + return -1; + } + + if (q->codingMode == STEREO) { + DEBUGF("Normal stereo detected.\n"); + } else if (q->codingMode == JOINT_STEREO) { + DEBUGF("Joint stereo detected.\n"); + } else { + DEBUGF("Unknown channel coding mode %x!\n",q->codingMode); + return -1; + } + + if (id3->channels <= 0 || id3->channels > 2 ) { + DEBUGF("Channel configuration error!\n"); + return -1; + } + + + if(id3->bytesperframe >= UINT16_MAX/2) + return -1; + + + /* Initialize the VLC tables. */ + if (!vlcs_initialized) { + for (i=0 ; i<7 ; i++) { + spectral_coeff_tab[i].table = &atrac3_vlc_table[atrac3_vlc_offs[i]]; + spectral_coeff_tab[i].table_allocated = atrac3_vlc_offs[i + 1] - atrac3_vlc_offs[i]; + init_vlc (&spectral_coeff_tab[i], 9, huff_tab_sizes[i], + huff_bits[i], 1, 1, + huff_codes[i], 1, 1, INIT_VLC_USE_NEW_STATIC); + } + + vlcs_initialized = 1; + + } + + init_atrac3_transforms(); + + /* init the joint-stereo decoding data */ + q->weighting_delay[0] = 0; + q->weighting_delay[1] = 7; + q->weighting_delay[2] = 0; + q->weighting_delay[3] = 7; + q->weighting_delay[4] = 0; + q->weighting_delay[5] = 7; + + for (i=0; i<4; i++) { + q->matrix_coeff_index_prev[i] = 3; + q->matrix_coeff_index_now[i] = 3; + q->matrix_coeff_index_next[i] = 3; + } + + /* Link the iram'ed arrays to the decoder's data structure */ + q->pUnits = channel_units; + q->pUnits[0].spectrum = &atrac3_spectrum [0][0]; + q->pUnits[1].spectrum = &atrac3_spectrum [1][0]; + q->pUnits[0].IMDCT_buf = &atrac3_IMDCT_buf[0][0]; + q->pUnits[1].IMDCT_buf = &atrac3_IMDCT_buf[1][0]; + q->pUnits[0].prevFrame = &atrac3_prevFrame[0][0]; + q->pUnits[1].prevFrame = &atrac3_prevFrame[1][0]; + + return 0; +} + diff --git a/lib/rbcodec/codecs/libatrac/atrac3.h b/lib/rbcodec/codecs/libatrac/atrac3.h new file mode 100644 index 0000000000..64086b6411 --- /dev/null +++ b/lib/rbcodec/codecs/libatrac/atrac3.h @@ -0,0 +1,114 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2009 Mohamed Tarek + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include "ffmpeg_get_bits.h" +#include "../librm/rm.h" +#include "codeclib.h" + +#if (CONFIG_CPU == PP5022) || (CONFIG_CPU == PP5024) || \ + (CONFIG_CPU == MCF5250) || defined(CPU_S5L870X) +/* PP5022/24, MCF5250 and S5L870x have larger IRAM */ +#define IBSS_ATTR_LARGE_IRAM IBSS_ATTR +#define ICODE_ATTR_LARGE_IRAM ICODE_ATTR +#define ICONST_ATTR_LARGE_IRAM ICONST_ATTR +#else +/* other CPUs IRAM is not large enough */ +#define IBSS_ATTR_LARGE_IRAM +#define ICODE_ATTR_LARGE_IRAM +#define ICONST_ATTR_LARGE_IRAM +#endif + +/* These structures are needed to store the parsed gain control data. */ +typedef struct { + int num_gain_data; + int levcode[8]; + int loccode[8]; +} gain_info; + +typedef struct { + gain_info gBlock[4]; +} gain_block; + +typedef struct { + int pos; + int numCoefs; + int32_t coef[8]; +} tonal_component; + +typedef struct { + int bandsCoded; + int numComponents; + tonal_component components[64]; + int32_t *prevFrame; + int gcBlkSwitch; + gain_block gainBlock[2]; + + int32_t *spectrum; + int32_t *IMDCT_buf; + + int32_t delayBuf1[46] MEM_ALIGN_ATTR; /// ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id: + * + * Copyright (C) 2009 by Andree Buschmann + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include "config.h" + + .section .text, "ax", %progbits + +/**************************************************************************** + * void atrac3_iqmf_matrixing(int32_t *dest, + * int32_t *inlo, + * int32_t *inhi, + * unsigned int count); + * + * Matrixing step within iqmf of atrac3 synthesis. Reference implementation: + * + * for(i=0; i>31 || hi<<1 */ + mov r12, r12, lsr #31 + orr r8, r12, r8, lsl #1 /* s2 = low>>31 || hi<<1 */ + + stmia r0!, {r8, r9} /* store result out[0]=s2, out[1]=s1 */ + sub r1, r1, #184 /* roll back 64 entries = 184 bytes */ + sub r2, r2, #192 /* roll back 48 entries = 192 bytes = win[0] */ + + subs r3, r3, #1 /* outer loop -= 1 */ + bgt .iqmf_dewindow_outer_loop + + ldmpc regs=r4-r9 /* restore registers */ + +.atrac3_iqmf_dewindowing_end: + .size atrac3_iqmf_dewindowing,.atrac3_iqmf_dewindowing_end-atrac3_iqmf_dewindowing diff --git a/lib/rbcodec/codecs/libatrac/atrac3_armv5e.S b/lib/rbcodec/codecs/libatrac/atrac3_armv5e.S new file mode 100644 index 0000000000..1d9d35a5da --- /dev/null +++ b/lib/rbcodec/codecs/libatrac/atrac3_armv5e.S @@ -0,0 +1,163 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id: + * + * Copyright (C) 2010 by Michael Giacomelli + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include "config.h" + + .section .text, "ax", %progbits + + +/**************************************************************************** + * atrac3_iqmf_dewindowing_armv5e(int32_t *out, + * int32_t *in, + * int32_t *win, + * unsigned int nIn); + * + * Dewindowing step within iqmf of atrac3 synthesis using 16 bit filter + * coefficients and armv5e packed multiply instructions. Uses 2.5 cycles + * per filter coefficient (ideal). Benchmarked 3.54 per coefficient (Clip+). + * + * Reference implementation: + * + * for (j = nIn; j != 0; j--) { + * s1 = fixmul32(in[0], win[0]); + * s2 = fixmul32(in[1], win[1]); + * for (i = 2; i < 48; i += 2) { + * s1 += fixmul32(in[i ], win[i ]); + * s2 += fixmul32(in[i+1], win[i+1]); + * } + * out[0] = s2 << 1; + * out[1] = s1 << 1; + * in += 2; + * out += 2; + * } + * Note: r12 is a scratch register and can be used without restorage. + ****************************************************************************/ + .align 2 + .global atrac3_iqmf_dewindowing_armv5e + .type atrac3_iqmf_dewindowing_armv5e, %function + +atrac3_iqmf_dewindowing_armv5e: + /* r0 = dest */ + /* r1 = input samples */ + /* r2 = window coefficients */ + /* r3 = counter */ + stmfd sp!, {r4-r11, lr} /* save non-scratch registers */ + +.iqmf_dewindow_outer_loop: /* outer loop 0...counter-1 */ + /* 0.. 7 */ + ldmia r2!, {r4, r5, r8, r9} /* load win[0..7] */ + ldmia r1!, {r6, r7, r10, r11} /* load in[0..3] to avoid stall on arm11 */ + smulwb lr, r6, r4 /* s1 = in[0] * win[0] */ + smulwt r12, r7, r4 /* s2 = in[1] * win[1] */ + smlawb lr, r10, r5, lr /* s1 += in[i ] * win[i ] >> 16 */ + smlawt r12, r11,r5, r12 /* s2 += in[i+1] * win[i+1] >> 16 */ + + ldmia r1!, {r6, r7, r10, r11} /* load in[i...i+3] */ + smlawb lr, r6, r8, lr /* s1 += in[i ] * win[i ] >> 16 */ + smlawt r12, r7, r8, r12 /* s2 += in[i+1] * win[i+1] >> 16 */ + smlawb lr, r10, r9, lr /* s1 += in[i ] * win[i ] >> 16 */ + smlawt r12, r11, r9, r12 /* s2 += in[i+1] * win[i+1] >> 16 */ + + /* 8..15 */ + ldmia r2!, {r4, r5, r8, r9} /* load win[8..15] */ + ldmia r1!, {r6, r7, r10, r11} /* load in[i...i+3] */ + smlawb lr, r6, r4, lr /* s1 += in[i ] * win[i ] >> 16 */ + smlawt r12, r7, r4, r12 /* s2 += in[i+1] * win[i+1] >> 16 */ + smlawb lr, r10, r5, lr /* s1 += in[i ] * win[i ] >> 16 */ + smlawt r12, r11,r5, r12 /* s2 += in[i+1] * win[i+1] >> 16 */ + + ldmia r1!, {r6, r7, r10, r11} /* load in[i...i+3] */ + smlawb lr, r6, r8, lr /* s1 += in[i ] * win[i ] >> 16 */ + smlawt r12, r7, r8, r12 /* s2 += in[i+1] * win[i+1] >> 16 */ + smlawb lr, r10, r9, lr /* s1 += in[i ] * win[i ] >> 16 */ + smlawt r12, r11,r9, r12 /* s2 += in[i+1] * win[i+1] >> 16 */ + + /* 16..23 */ + ldmia r2!, {r4, r5, r8, r9} /* load win[16..23] */ + ldmia r1!, {r6, r7, r10, r11} /* load in[i...i+3] */ + smlawb lr, r6, r4, lr /* s1 += in[i ] * win[i ] >> 16 */ + smlawt r12, r7, r4, r12 /* s2 += in[i+1] * win[i+1] >> 16 */ + smlawb lr, r10, r5, lr /* s1 += in[i ] * win[i ] >> 16 */ + smlawt r12, r11,r5, r12 /* s2 += in[i+1] * win[i+1] >> 16 */ + + ldmia r1!, {r6, r7, r10, r11} /* load in[i...i+3] */ + smlawb lr, r6, r8, lr /* s1 += in[i ] * win[i ] >> 16 */ + smlawt r12, r7, r8, r12 /* s2 += in[i+1] * win[i+1] >> 16 */ + smlawb lr, r10, r9, lr /* s1 += in[i ] * win[i ] >> 16 */ + smlawt r12, r11,r9, r12 /* s2 += in[i+1] * win[i+1] >> 16 */ + + /* 24..31 */ + ldmia r2!, {r4, r5, r8, r9} /* load win[24..31] */ + ldmia r1!, {r6, r7, r10, r11} /* load in[i...i+3] */ + smlawb lr, r6, r4, lr /* s1 += in[i ] * win[i ] >> 16 */ + smlawt r12, r7, r4, r12 /* s2 += in[i+1] * win[i+1] >> 16 */ + smlawb lr, r10, r5, lr /* s1 += in[i ] * win[i ] >> 16 */ + smlawt r12, r11,r5, r12 /* s2 += in[i+1] * win[i+1] >> 16 */ + + ldmia r1!, {r6, r7, r10, r11} /* load in[i...i+3] */ + smlawb lr, r6, r8, lr /* s1 += in[i ] * win[i ] >> 16 */ + smlawt r12, r7, r8, r12 /* s2 += in[i+1] * win[i+1] >> 16 */ + smlawb lr, r10, r9, lr /* s1 += in[i ] * win[i ] >> 16 */ + smlawt r12, r11,r9, r12 /* s2 += in[i+1] * win[i+1] >> 16 */ + + /* 32..39 */ + ldmia r2!, {r4, r5, r8, r9} /* load win[32..39] */ + ldmia r1!, {r6, r7, r10, r11} /* load in[i...i+3] */ + smlawb lr, r6, r4, lr /* s1 += in[i ] * win[i ] >> 16 */ + smlawt r12, r7, r4, r12 /* s2 += in[i+1] * win[i+1] >> 16 */ + smlawb lr, r10, r5, lr /* s1 += in[i ] * win[i ] >> 16 */ + smlawt r12, r11,r5, r12 /* s2 += in[i+1] * win[i+1] >> 16 */ + + ldmia r1!, {r6, r7, r10, r11} /* load in[i...i+3] */ + smlawb lr, r6, r8, lr /* s1 += in[i ] * win[i ] >> 16 */ + smlawt r12, r7, r8, r12 /* s2 += in[i+1] * win[i+1] >> 16 */ + smlawb lr, r10, r9, lr /* s1 += in[i ] * win[i ] >> 16 */ + smlawt r12, r11,r9, r12 /* s2 += in[i+1] * win[i+1] >> 16 */ + + /* 40..47 */ + ldmia r2!, {r4, r5, r8, r9} /* load win[40..47] */ + ldmia r1!, {r6, r7, r10, r11} /* load in[i...i+3] */ + smlawb lr, r6, r4, lr /* s1 += in[i ] * win[i ] >> 16 */ + smlawt r12, r7, r4, r12 /* s2 += in[i+1] * win[i+1] >> 16 */ + smlawb lr, r10, r5, lr /* s1 += in[i ] * win[i ] >> 16 */ + smlawt r12, r11,r5, r12 /* s2 += in[i+1] * win[i+1] >> 16 */ + + ldmia r1!, {r6, r7, r10, r11} /* load in[i...i+3] */ + smlawb lr, r6, r8, lr /* s1 += in[i ] * win[i ] >> 16 */ + smlawt r12, r7, r8, r12 /* s2 += in[i+1] * win[i+1] >> 16 */ + smlawb lr, r10, r9, lr /* s1 += in[i ] * win[i ] >> 16 */ + smlawt r12, r11,r9, r12 /* s2 += in[i+1] * win[i+1] >> 16 */ + + + mov lr , lr , lsl #1 + mov r12, r12, lsl #1 + + stmia r0!, {r12, lr} /* store result out[0]=s2, out[1]=s1 */ + sub r1, r1, #184 /* roll back 64 entries = 184 bytes */ + sub r2, r2, #96 /* roll back 48 entries * 2 bytes = 96 bytes = win[0] */ + + subs r3, r3, #1 /* outer loop -= 1 */ + bgt .iqmf_dewindow_outer_loop + + ldmpc regs=r4-r11 /* restore registers */ + +.atrac3_iqmf_dewindowing_armv5e_end: + .size atrac3_iqmf_dewindowing_armv5e,.atrac3_iqmf_dewindowing_armv5e_end-atrac3_iqmf_dewindowing_armv5e diff --git a/lib/rbcodec/codecs/libatrac/atrac3data.h b/lib/rbcodec/codecs/libatrac/atrac3data.h new file mode 100644 index 0000000000..30abb37572 --- /dev/null +++ b/lib/rbcodec/codecs/libatrac/atrac3data.h @@ -0,0 +1,148 @@ +/* + * Atrac 3 compatible decoder data + * Copyright (c) 2006-2007 Maxim Poliakovski + * Copyright (c) 2006-2007 Benjamin Larsson + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file libavcodec/atrac3data.h + * Atrac 3 AKA RealAudio 8 compatible decoder data + */ + +#ifndef AVCODEC_ATRAC3DATA_H +#define AVCODEC_ATRAC3DATA_H + +#include + +/* VLC tables */ + +static const uint8_t huffcode1[9] ICONST_ATTR_LARGE_IRAM = { + 0x0,0x4,0x5,0xC,0xD,0x1C,0x1D,0x1E,0x1F, +}; + +static const uint8_t huffbits1[9] ICONST_ATTR_LARGE_IRAM = { + 1,3,3,4,4,5,5,5,5, +}; + +static const uint8_t huffcode2[5] ICONST_ATTR_LARGE_IRAM = { + 0x0,0x4,0x5,0x6,0x7, +}; + +static const uint8_t huffbits2[5] ICONST_ATTR_LARGE_IRAM = { + 1,3,3,3,3, +}; + +static const uint8_t huffcode3[7] ICONST_ATTR_LARGE_IRAM = { +0x0,0x4,0x5,0xC,0xD,0xE,0xF, +}; + +static const uint8_t huffbits3[7] ICONST_ATTR_LARGE_IRAM = { + 1,3,3,4,4,4,4, +}; + +static const uint8_t huffcode4[9] ICONST_ATTR_LARGE_IRAM = { + 0x0,0x4,0x5,0xC,0xD,0x1C,0x1D,0x1E,0x1F, +}; + +static const uint8_t huffbits4[9] ICONST_ATTR_LARGE_IRAM = { + 1,3,3,4,4,5,5,5,5, +}; + +static const uint8_t huffcode5[15] ICONST_ATTR_LARGE_IRAM = { + 0x0,0x2,0x3,0x8,0x9,0xA,0xB,0x1C,0x1D,0x3C,0x3D,0x3E,0x3F,0xC,0xD, +}; + +static const uint8_t huffbits5[15] ICONST_ATTR_LARGE_IRAM = { + 2,3,3,4,4,4,4,5,5,6,6,6,6,4,4 +}; + +static const uint8_t huffcode6[31] ICONST_ATTR_LARGE_IRAM = { + 0x0,0x2,0x3,0x4,0x5,0x6,0x7,0x14,0x15,0x16,0x17,0x18,0x19,0x34,0x35, + 0x36,0x37,0x38,0x39,0x3A,0x3B,0x78,0x79,0x7A,0x7B,0x7C,0x7D,0x7E,0x7F,0x8,0x9, +}; + +static const uint8_t huffbits6[31] ICONST_ATTR_LARGE_IRAM = { + 3,4,4,4,4,4,4,5,5,5,5,5,5,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,4,4 +}; + +static const uint8_t huffcode7[63] ICONST_ATTR_LARGE_IRAM = { + 0x0,0x8,0x9,0xA,0xB,0xC,0xD,0xE,0xF,0x10,0x11,0x24,0x25,0x26,0x27,0x28, + 0x29,0x2A,0x2B,0x2C,0x2D,0x2E,0x2F,0x30,0x31,0x32,0x33,0x68,0x69,0x6A,0x6B,0x6C, + 0x6D,0x6E,0x6F,0x70,0x71,0x72,0x73,0x74,0x75,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2, + 0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF,0x2,0x3, +}; + +static const uint8_t huffbits7[63] ICONST_ATTR_LARGE_IRAM = { + 3,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,7,7,7,7,7, + 7,7,7,7,7,7,7,7,7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,4,4 +}; + +static const uint8_t huff_tab_sizes[7] ICONST_ATTR_LARGE_IRAM = { + 9, 5, 7, 9, 15, 31, 63, +}; + +static const uint8_t* const huff_codes[7] ICONST_ATTR_LARGE_IRAM = { + huffcode1,huffcode2,huffcode3,huffcode4,huffcode5,huffcode6,huffcode7, +}; + +static const uint8_t* const huff_bits[7] ICONST_ATTR_LARGE_IRAM = { + huffbits1,huffbits2,huffbits3,huffbits4,huffbits5,huffbits6,huffbits7, +}; + +static const uint16_t atrac3_vlc_offs[] ICONST_ATTR_LARGE_IRAM = { + 0,512,1024,1536,2048,2560,3072,3584,4096 +}; + +/* selector tables */ + +static const uint8_t CLCLengthTab[8] ICONST_ATTR_LARGE_IRAM = { + 0, 4, 3, 3, 4, 4, 5, 6}; +static const int8_t seTab_0[4] ICONST_ATTR_LARGE_IRAM = { + 0, 1, -2, -1}; +static const int8_t decTable1[18] ICONST_ATTR_LARGE_IRAM = { + 0,0, 0,1, 0,-1, 1,0, -1,0, 1,1, 1,-1, -1,1, -1,-1}; + + +/* tables for the scalefactor decoding */ +/* not needed anymore +static const float iMaxQuant[8] = { + 0.0, 1.0/1.5, 1.0/2.5, 1.0/3.5, 1.0/4.5, 1.0/7.5, 1.0/15.5, 1.0/31.5 +}; +*/ +static const uint16_t subbandTab[33] ICONST_ATTR_LARGE_IRAM = { + 0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160, 176, 192, 224, + 256, 288, 320, 352, 384, 416, 448, 480, 512, 576, 640, 704, 768, 896, 1024 +}; + +/* transform data */ +/* not needed anymore +static const float qmf_48tap_half[24] = { + -0.00001461907, -0.00009205479, -0.000056157569, 0.00030117269, + 0.0002422519,-0.00085293897, -0.0005205574, 0.0020340169, + 0.00078333891, -0.0042153862, -0.00075614988, 0.0078402944, + -0.000061169922, -0.01344162, 0.0024626821, 0.021736089, + -0.007801671, -0.034090221, 0.01880949, 0.054326009, + -0.043596379, -0.099384367, 0.13207909, 0.46424159 +}; +*/ +/* joint stereo related tables */ +/* not needed anymore +static const float matrixCoeffs[8] = {0.0, 2.0, 2.0, 2.0, 0.0, 0.0, 1.0, 1.0}; +*/ +#endif /* AVCODEC_ATRAC3DATA_H */ diff --git a/lib/rbcodec/codecs/libatrac/atrac3data_fixed.h b/lib/rbcodec/codecs/libatrac/atrac3data_fixed.h new file mode 100644 index 0000000000..9eb79731ce --- /dev/null +++ b/lib/rbcodec/codecs/libatrac/atrac3data_fixed.h @@ -0,0 +1,108 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2009 Michael Giacomelli + * Copyright (C) 2009 Mohamed Tarek + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ +/* tables for the scalefactor decoding */ +/* scaled by 2^31*/ +static const int32_t iMaxQuant_fix[8] ICONST_ATTR = { + 0x0, 0x55555580, 0x33333340, 0x24924940, 0x1c71c720, 0x11111120, 0x8421080, + 0x4104108 +}; + +/* scaled by 2^16 */ +static const int32_t SFTable_fixed[64] ICONST_ATTR = { + 0x00000800, 0x00000a14, 0x00000cb3, 0x00001000, 0x00001429, 0x00001966, + 0x00002000, 0x00002851, 0x000032cc, 0x00004000, 0x000050a3, 0x00006598, + 0x00008000, 0x0000a145, 0x0000cb30, 0x00010000, 0x0001428a, 0x00019660, + 0x00020000, 0x00028514, 0x00032cc0, 0x00040000, 0x00050a29, 0x00065980, + 0x00080000, 0x000a1452, 0x000cb2ff, 0x00100000, 0x001428a3, 0x001965ff, + 0x00200000, 0x00285146, 0x0032cbfd, 0x00400000, 0x0050a28c, 0x006597fb, + 0x00800000, 0x00a14518, 0x00cb2ff5, 0x01000000, 0x01428a30, 0x01965fea, + 0x02000000, 0x02851460, 0x032cbfd4, 0x04000000, 0x050a28c0, 0x06597fa8, + 0x08000000, 0x0a145180, 0x0cb2ff50, 0x10000000, 0x1428a300, 0x1965fea0, + 0x20000000, 0x28514600, 0x32cbfd40, 0x40000000, 0x50a28c00, 0x6597fa80, + 0x80000000, 0x80000000, 0x80000000, 0x80000000, +}; + +/* transform data */ +/* floating point values scaled by 2^31 */ +static const int32_t qmf_48tap_half_fix[24] = { + 0xffff855e, 0xfffcfbca, 0xfffe28eb, 0x0009de6b, 0x0007f028, 0xffe40d08, + 0xffeef140, 0x0042a692, 0x0019ab1f, 0xff75dec7, 0xffe738f5, 0x0100e928, + 0xfffdfedf, 0xfe478b84, 0x0050b279, 0x02c83f88, 0xff005ad7, 0xfba2ee80, + 0x02685970, 0x06f42798, 0xfa6b6f10, 0xf3475f80, 0x10e7f7c0, 0x3b6c44c0 +}; + +/* mdct window scaled by 2^31 */ +/* Remark: The preceding sign corrects the sign of the hexadecimal values */ +static const int32_t window_lookup[128] ICONST_ATTR MEM_ALIGN_ATTR = { + -0xffffb10c, -0xfffd394b, -0xfff8494f, -0xfff0e025, -0xffe6fc5f, -0xffda9c15, + -0xffcbbce6, -0xffba5bf4, -0xffa675e8, -0xff9006f0, -0xff770aba, -0xff5b7c7e, + -0xff3d56f2, -0xff1c9452, -0xfef92e59, -0xfed31e45, -0xfeaa5cd5, -0xfe7ee247, + -0xfe50a657, -0xfe1fa041, -0xfdebc6c1, -0xfdb5100d, -0xfd7b71d5, -0xfd3ee149, + -0xfcff5311, -0xfcbcbb49, -0xfc770d99, -0xfc2e3d15, -0xfbe23c39, -0xfb92fd29, + -0xfb407141, -0xfaea8989, -0xfa913661, -0xfa3467b1, -0xf9d40cd9, -0xf9701499, + -0xf9086d41, -0xf89d04a9, -0xf82dc7f1, -0xf7baa3e1, -0xf74384b1, -0xf6c85611, + -0xf6490321, -0xf5c576b1, -0xf53d9b21, -0xf4b15a01, -0xf4209ce1, -0xf38b4c71, + -0xf2f15171, -0xf2529411, -0xf1aefbf1, -0xf10670a1, -0xf058d941, -0xefa61cc1, + -0xeeee21c1, -0xee30cec1, -0xed6e0a41, -0xeca5ba61, -0xebd7c5c1, -0xeb041241, + -0xea2a8601, -0xe94b0861, -0xe8657f61, -0xe779d241, -0xe687e861, -0xe58fa9e1, + -0xe490fec1, -0xe38bd101, -0xe28009c1, -0xe16d93e1, -0xe0545ba1, -0xdf344dc1, + -0xde0d5881, -0xdcdf6bc1, -0xdbaa7801, -0xda6e70c1, -0xd92b4ac1, -0xd7e0fc81, + -0xd68f7ec1, -0xd536cd41, -0xd3d6e5c1, -0xd26fc901, -0xd10179c1, -0xcf8bff41, + -0xce0f6301, -0xcc8bb241, -0xcb00fdc1, -0xc96f5b01, -0xc7d6e141, -0xc637af41, + -0xc491e4c1, -0xc2e5a801, -0xc1332401, -0xbf7a8701, -0xbdbc0681, -0xbbf7da01, + -0xba2e4181, -0xb85f7f81, -0xb68bde01, -0xb4b3a981, -0xb2d73781, -0xb0f6df01, + -0xaf12ff01, -0xad2bfa81, -0xab423981, -0xa9562981, -0xa7683c01, -0xa578e701, + -0xa388a681, -0xa197f801, -0x9fa75e81, -0x9db75f01, -0x9bc88201, -0x99db5301, + -0x97f06001, -0x96083601, -0x94236601, -0x92427f81, -0x90661481, -0x8e8eb481, + -0x8cbced01, -0x8af14d81, -0x892c5f81, -0x876eab01, -0x85b8b681, -0x840b0301, + -0x82660c01, -0x80ca4a01, +}; + +/* Gain tables scaled by 2^16 */ +static const int32_t gain_tab2[31] ICONST_ATTR = { + 0x0003ab03, 0x00035d14, 0x0003159d, 0x0002d414, 0x000297fb, 0x000260e0, + 0x00022e57, 0x00020000, 0x0001d582, 0x0001ae8a, 0x00018ace, 0x00016a0a, + 0x00014bfe, 0x00013070, 0x0001172c, 0x00010000, 0x0000eac1, 0x0000d745, + 0x0000c567, 0x0000b505, 0x0000a5ff, 0x00009838, 0x00008b96, 0x00008000, + 0x00007560, 0x00006ba2, 0x000062b4, 0x00005a82, 0x000052ff, 0x00004c1c, + 0x000045cb, + +}; + +/* Joint-Stereo related tables, scaled by 2^16 */ +static const int32_t matrixCoeffs_fix[8] ICONST_ATTR = { + 0x00000000, 0x00020000, 0x00020000, 0x00020000, + 0x00000000, 0x00000000, 0x00010000, 0x00010000, +}; + +/* channelWeights0[i] = ONE_16 * ((i & 7)/7) */ +static const int32_t channelWeights0[8] = { + 0x00000000, 0x00002492, 0x00004925, 0x00006DB7, + 0x00009249, 0x0000B6DB, 0x0000DB6D, 0x00010000, +}; + +/* channelWeights1[i] = ONE_16 * sqrt(2-channelWeights0^2) */ +static const int32_t channelWeights1[8] = { + 0x00016A0A, 0x00016830, 0x00016293, 0x00015904, + 0x00014B2B, 0x00013877, 0x00011FF7, 0x00010000, +}; + diff --git a/lib/rbcodec/codecs/libatrac/fixp_math.h b/lib/rbcodec/codecs/libatrac/fixp_math.h new file mode 100644 index 0000000000..014c5aa559 --- /dev/null +++ b/lib/rbcodec/codecs/libatrac/fixp_math.h @@ -0,0 +1,111 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2009 Mohamed Tarek + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ +#include +#include + +/* Macros for converting between various fixed-point representations and floating point. */ +#define ONE_16 (1L << 16) +#define fixtof64(x) (float)((float)(x) / (float)(1 << 16)) //does not work on int64_t! +#define ftofix32(x) ((int32_t)((x) * (float)(1 << 16) + ((x) < 0 ? -0.5 : 0.5))) +#define ftofix31(x) ((int32_t)((x) * (float)(1 << 31) + ((x) < 0 ? -0.5 : 0.5))) +#define fix31tof64(x) (float)((float)(x) / (float)(1 << 31)) + +/* Fixed point math routines for use in atrac3.c */ + +#if defined(CPU_ARM) + /* Calculates: result = (X*Y)>>16 */ + #define fixmul16(X,Y) \ + ({ \ + int32_t lo; \ + int32_t hi; \ + asm volatile ( \ + "smull %[lo], %[hi], %[x], %[y] \n\t" /* multiply */ \ + "mov %[lo], %[lo], lsr #16 \n\t" /* lo >>= 16 */ \ + "orr %[lo], %[lo], %[hi], lsl #16" /* lo |= (hi << 16) */ \ + : [lo]"=&r"(lo), [hi]"=&r"(hi) \ + : [x]"r"(X), [y]"r"(Y)); \ + lo; \ + }) + + /* Calculates: result = (X*Y)>>31 */ + /* Use scratch register r12 */ + #define fixmul31(X,Y) \ + ({ \ + int32_t lo; \ + int32_t hi; \ + asm volatile ( \ + "smull %[lo], %[hi], %[x], %[y] \n\t" /* multiply */ \ + "mov %[lo], %[lo], lsr #31 \n\t" /* lo >>= 31 */ \ + "orr %[lo], %[lo], %[hi], lsl #1" /* lo |= (hi << 1) */ \ + : [lo]"=&r"(lo), [hi]"=&r"(hi) \ + : [x]"r"(X), [y]"r"(Y)); \ + lo; \ + }) +#elif defined(CPU_COLDFIRE) + /* Calculates: result = (X*Y)>>16 */ + #define fixmul16(X,Y) \ + ({ \ + int32_t t, x = (X); \ + asm volatile ( \ + "mac.l %[x],%[y],%%acc0\n\t" /* multiply */ \ + "mulu.l %[y],%[x] \n\t" /* get lower half, avoid emac stall */ \ + "movclr.l %%acc0,%[t] \n\t" /* get higher half */ \ + "lsr.l #1,%[t] \n\t" /* hi >>= 1 to compensate emac shift */ \ + "move.w %[t],%[x] \n\t" /* combine halfwords */\ + "swap %[x] \n\t" \ + : [t]"=&d"(t), [x] "+d" (x) \ + : [y] "d" ((Y))); \ + x; \ + }) + + #define fixmul31(X,Y) \ + ({ \ + int32_t t; \ + asm volatile ( \ + "mac.l %[x], %[y], %%acc0\n\t" /* multiply */ \ + "movclr.l %%acc0, %[t]\n\t" /* get higher half as result */ \ + : [t] "=d" (t) \ + : [x] "r" ((X)), [y] "r" ((Y))); \ + t; \ + }) +#else + static inline int32_t fixmul16(int32_t x, int32_t y) + { + int64_t temp; + temp = x; + temp *= y; + + temp >>= 16; + + return (int32_t)temp; + } + + static inline int32_t fixmul31(int32_t x, int32_t y) + { + int64_t temp; + temp = x; + temp *= y; + + temp >>= 31; //16+31-16 = 31 bits + + return (int32_t)temp; + } +#endif diff --git a/lib/rbcodec/codecs/libatrac/libatrac.make b/lib/rbcodec/codecs/libatrac/libatrac.make new file mode 100644 index 0000000000..69a66eb6f5 --- /dev/null +++ b/lib/rbcodec/codecs/libatrac/libatrac.make @@ -0,0 +1,18 @@ +# __________ __ ___. +# Open \______ \ ____ ____ | | _\_ |__ _______ ___ +# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / +# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < +# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ +# \/ \/ \/ \/ \/ +# $Id: libatrac.make 20151 2009-03-01 09:04:15Z amiconn $ +# + +# libatrac +ATRACLIB := $(CODECDIR)/libatrac.a +ATRACLIB_SRC := $(call preprocess, $(RBCODECLIB_DIR)/codecs/libatrac/SOURCES) +ATRACLIB_OBJ := $(call c2obj, $(ATRACLIB_SRC)) +OTHER_SRC += $(ATRACLIB_SRC) + +$(ATRACLIB): $(ATRACLIB_OBJ) + $(SILENT)$(shell rm -f $@) + $(call PRINTS,AR $(@F))$(AR) rcs $@ $^ >/dev/null diff --git a/lib/rbcodec/codecs/libcook/README.rockbox b/lib/rbcodec/codecs/libcook/README.rockbox new file mode 100644 index 0000000000..ae72f2a2f2 --- /dev/null +++ b/lib/rbcodec/codecs/libcook/README.rockbox @@ -0,0 +1,47 @@ +Library: libcook +Imported by : Mohamed Tarek + +These files comprise a rm parser and a cook decoder based on the decoder +from ffmpeg. + +LICENSING INFORMATION + +ffmpeg is licensed under the Lesser GNU General Public License and the +file cook.c is Copyright 2003 Sascha Sommer and 2005 Benjamin Larsson. + +IMPORT DETAILS + +The decoder is based on ffmpeg-svn r18079. + +CONVERSION TO FIXED-POINT + +A patch from ffmpeg's mailing list was used to convert the decoder to +use fixed-point arithmetic. The patch was done by Ian Braithwaite, and +discussed here : + +http://thread.gmane.org/gmane.comp.video.ffmpeg.devel/46024 + +The patch is a bit dated (2007) so the modifications to cook.c had to +be done manually. The patch was also applied to cookdata.h and was +used to create cookdata_fixpoint.h, cook_fixpoint.h and +cook_fixp_mdct.h. + +cook_fixp_mdct.h and parts from cookdata_fixpoint.h were dropped and +rockbox's mdct library is now used in both the test program and the +real codec. + +Note : Only parts of the patch were committed to ffmpeg's repository. + +TESTING + +The test program should compile in any Unix-like environment using the +command "make -f Makefile.test". + +For ARM targets add -DCPU_ARM to CFLAGS in Makefile.test to make use of +the asm ARM optimisations in rockbox's mdct library. + +For Big-endian targets, change -D"ROCKBOX_LITTLE_ENDIAN=1" +to -D"ROCKBOX_BIG_ENDIAN=1" in Makefile.test. + +Running "./cooktest file.rm" will decode the audio data to a WAV file +called "output.wav" in the current directory. diff --git a/lib/rbcodec/codecs/libcook/SOURCES b/lib/rbcodec/codecs/libcook/SOURCES new file mode 100644 index 0000000000..b656fdd2f7 --- /dev/null +++ b/lib/rbcodec/codecs/libcook/SOURCES @@ -0,0 +1,2 @@ +cook.c + diff --git a/lib/rbcodec/codecs/libcook/cook.c b/lib/rbcodec/codecs/libcook/cook.c new file mode 100644 index 0000000000..29a1bab7d6 --- /dev/null +++ b/lib/rbcodec/codecs/libcook/cook.c @@ -0,0 +1,907 @@ +/* + * COOK compatible decoder + * Copyright (c) 2003 Sascha Sommer + * Copyright (c) 2005 Benjamin Larsson + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file cook.c + * Cook compatible decoder. Bastardization of the G.722.1 standard. + * This decoder handles RealNetworks, RealAudio G2 data. + * Cook is identified by the codec name cook in RM files. + * + * To use this decoder, a calling application must supply the extradata + * bytes provided from the RM container; 8+ bytes for mono streams and + * 16+ for stereo streams (maybe more). + * + * Codec technicalities (all this assume a buffer length of 1024): + * Cook works with several different techniques to achieve its compression. + * In the timedomain the buffer is divided into 8 pieces and quantized. If + * two neighboring pieces have different quantization index a smooth + * quantization curve is used to get a smooth overlap between the different + * pieces. + * To get to the transformdomain Cook uses a modulated lapped transform. + * The transform domain has 50 subbands with 20 elements each. This + * means only a maximum of 50*20=1000 coefficients are used out of the 1024 + * available. + */ + +#include +#include +#include +#include +#include +#include "codeclib.h" + +#include "cook.h" +#include "cookdata.h" + +/* the different Cook versions */ +#define MONO 0x1000001 +#define STEREO 0x1000002 +#define JOINT_STEREO 0x1000003 +#define MC_COOK 0x2000000 //multichannel Cook, not supported + +#define SUBBAND_SIZE 20 +#define MAX_SUBPACKETS 5 +//#define COOKDEBUG +#ifndef COOKDEBUG +#undef DEBUGF +#define DEBUGF(...) +#endif + +/** + * Random bit stream generator. + */ +static inline int cook_random(COOKContext *q) +{ + q->random_state = + q->random_state * 214013 + 2531011; /* typical RNG numbers */ + + return (q->random_state/0x1000000)&1; /*>>31*/ +} +#include "cook_fixpoint.h" + +/* debug functions */ + +#ifdef COOKDEBUG +static void dump_int_table(int* table, int size, int delimiter) { + int i=0; + DEBUGF("\n[%d]: ",i); + for (i=0 ; ienvelope_quant_index[ 0].table = vlcbuf00; + q->envelope_quant_index[ 1].table = vlcbuf01; + q->envelope_quant_index[ 2].table = vlcbuf02; + q->envelope_quant_index[ 3].table = vlcbuf03; + q->envelope_quant_index[ 4].table = vlcbuf04; + q->envelope_quant_index[ 5].table = vlcbuf05; + q->envelope_quant_index[ 6].table = vlcbuf06; + q->envelope_quant_index[ 7].table = vlcbuf07; + q->envelope_quant_index[ 8].table = vlcbuf08; + q->envelope_quant_index[ 9].table = vlcbuf09; + q->envelope_quant_index[10].table = vlcbuf10; + q->envelope_quant_index[11].table = vlcbuf11; + q->envelope_quant_index[12].table = vlcbuf12; + q->sqvh[0].table = vlcbuf13; + q->sqvh[1].table = vlcbuf14; + q->sqvh[2].table = vlcbuf15; + q->sqvh[3].table = vlcbuf16; + q->sqvh[4].table = vlcbuf17; + q->sqvh[5].table = vlcbuf18; + q->sqvh[6].table = vlcbuf19; + q->ccpl.table = vlcbuf20; + + /* Init envelope VLC (13 books) */ + for (i=0 ; i<13 ; i++) { + q->envelope_quant_index[i].table_allocated = env_size[i]; + result |= init_vlc (&q->envelope_quant_index[i], 9, 24, + envelope_quant_index_huffbits[i], 1, 1, + envelope_quant_index_huffcodes[i], 2, 2, INIT_VLC_USE_NEW_STATIC); + } + + /* Init subband VLC (7 books) */ + for (i=0 ; i<7 ; i++) { + q->sqvh[i].table_allocated = sqvh_size[i]; + result |= init_vlc (&q->sqvh[i], vhvlcsize_tab[i], vhsize_tab[i], + cvh_huffbits[i], 1, 1, + cvh_huffcodes[i], 2, 2, INIT_VLC_USE_NEW_STATIC); + } + + /* Init Joint-Stereo VLC (1 book) */ + if (q->nb_channels==2 && q->joint_stereo==1){ + q->ccpl.table_allocated = ccpl_size; + result |= init_vlc (&q->ccpl, 6, (1<js_vlc_bits)-1, + ccpl_huffbits[q->js_vlc_bits-2], 1, 1, + ccpl_huffcodes[q->js_vlc_bits-2], 2, 2, INIT_VLC_USE_NEW_STATIC); + DEBUGF("Joint-stereo VLC used.\n"); + } + + DEBUGF("VLC tables initialized. Result = %d\n",result); + return result; +} +/*************** init functions end ***********/ + +/** + * Cook indata decoding, every 32 bits are XORed with 0x37c511f2. + * Why? No idea, some checksum/error detection method maybe. + * + * Out buffer size: extra bytes are needed to cope with + * padding/misalignment. + * Subpackets passed to the decoder can contain two, consecutive + * half-subpackets, of identical but arbitrary size. + * 1234 1234 1234 1234 extraA extraB + * Case 1: AAAA BBBB 0 0 + * Case 2: AAAA ABBB BB-- 3 3 + * Case 3: AAAA AABB BBBB 2 2 + * Case 4: AAAA AAAB BBBB BB-- 1 5 + * + * Nice way to waste CPU cycles. + * + * @param inbuffer pointer to byte array of indata + * @param out pointer to byte array of outdata + * @param bytes number of bytes + */ +#define DECODE_BYTES_PAD1(bytes) (3 - ((bytes)+3) % 4) +#define DECODE_BYTES_PAD2(bytes) ((bytes) % 4 + DECODE_BYTES_PAD1(2 * (bytes))) + +static inline int decode_bytes(const uint8_t* inbuffer, uint8_t* out, int bytes){ + int i, off; + uint32_t c; + const uint32_t* buf; + uint32_t* obuf = (uint32_t*) out; + /* FIXME: 64 bit platforms would be able to do 64 bits at a time. + * I'm too lazy though, should be something like + * for(i=0 ; i> (off*8)) | (0x37c511f2 << (32-(off*8)))); + bytes += 3 + off; + for (i = 0; i < bytes/4; i++) + obuf[i] = c ^ buf[i]; + + return off; +} + +/** + * Fill the gain array for the timedomain quantization. + * + * @param q pointer to the COOKContext + * @param gaininfo[9] array of gain indexes + */ + +static void decode_gain_info(GetBitContext *gb, int *gaininfo) +{ + int i, n; + + while (get_bits1(gb)) {} + n = get_bits_count(gb) - 1; //amount of elements*2 to update + + i = 0; + while (n--) { + int index = get_bits(gb, 3); + int gain = get_bits1(gb) ? (int)get_bits(gb, 4) - 7 : -1; + + while (i <= index) gaininfo[i++] = gain; + } + while (i <= 8) gaininfo[i++] = 0; +} + +/** + * Create the quant index table needed for the envelope. + * + * @param q pointer to the COOKContext + * @param quant_index_table pointer to the array + */ + +static void decode_envelope(COOKContext *q, int* quant_index_table) { + int i,j, vlc_index; + + quant_index_table[0]= get_bits(&q->gb,6) - 6; //This is used later in categorize + + for (i=1 ; i < q->total_subbands ; i++){ + vlc_index=i; + if (i >= q->js_subband_start * 2) { + vlc_index-=q->js_subband_start; + } else { + vlc_index/=2; + if(vlc_index < 1) vlc_index = 1; + } + if (vlc_index>13) vlc_index = 13; //the VLC tables >13 are identical to No. 13 + + j = get_vlc2(&q->gb, q->envelope_quant_index[vlc_index-1].table, + q->envelope_quant_index[vlc_index-1].bits,2); + quant_index_table[i] = quant_index_table[i-1] + j - 12; //differential encoding + } +} + +/** + * Calculate the category and category_index vector. + * + * @param q pointer to the COOKContext + * @param quant_index_table pointer to the array + * @param category pointer to the category array + * @param category_index pointer to the category_index array + */ + +static void categorize(COOKContext *q, int* quant_index_table, + int* category, int* category_index){ + int exp_idx, bias, tmpbias1, tmpbias2, bits_left, num_bits, index, v, i, j; + int exp_index2[102]; + int exp_index1[102]; + + int tmp_categorize_array[128*2]; + int tmp_categorize_array1_idx=q->numvector_size; + int tmp_categorize_array2_idx=q->numvector_size; + + bits_left = q->bits_per_subpacket - get_bits_count(&q->gb); + + if(bits_left > q->samples_per_channel) { + bits_left = q->samples_per_channel + + ((bits_left - q->samples_per_channel)*5)/8; + //av_log(q->avctx, AV_LOG_ERROR, "bits_left = %d\n",bits_left); + } + + memset(&exp_index1,0,102*sizeof(int)); + memset(&exp_index2,0,102*sizeof(int)); + memset(&tmp_categorize_array,0,128*2*sizeof(int)); + + bias=-32; + + /* Estimate bias. */ + for (i=32 ; i>0 ; i=i/2){ + num_bits = 0; + index = 0; + for (j=q->total_subbands ; j>0 ; j--){ + exp_idx = av_clip((i - quant_index_table[index] + bias) / 2, 0, 7); + index++; + num_bits+=expbits_tab[exp_idx]; + } + if(num_bits >= bits_left - 32){ + bias+=i; + } + } + + /* Calculate total number of bits. */ + num_bits=0; + for (i=0 ; itotal_subbands ; i++) { + exp_idx = av_clip((bias - quant_index_table[i]) / 2, 0, 7); + num_bits += expbits_tab[exp_idx]; + exp_index1[i] = exp_idx; + exp_index2[i] = exp_idx; + } + tmpbias1 = tmpbias2 = num_bits; + + for (j = 1 ; j < q->numvector_size ; j++) { + if (tmpbias1 + tmpbias2 > 2*bits_left) { /* ---> */ + int max = -999999; + index=-1; + for (i=0 ; itotal_subbands ; i++){ + if (exp_index1[i] < 7) { + v = (-2*exp_index1[i]) - quant_index_table[i] + bias; + if ( v >= max) { + max = v; + index = i; + } + } + } + if(index==-1)break; + tmp_categorize_array[tmp_categorize_array1_idx++] = index; + tmpbias1 -= expbits_tab[exp_index1[index]] - + expbits_tab[exp_index1[index]+1]; + ++exp_index1[index]; + } else { /* <--- */ + int min = 999999; + index=-1; + for (i=0 ; itotal_subbands ; i++){ + if(exp_index2[i] > 0){ + v = (-2*exp_index2[i])-quant_index_table[i]+bias; + if ( v < min) { + min = v; + index = i; + } + } + } + if(index == -1)break; + tmp_categorize_array[--tmp_categorize_array2_idx] = index; + tmpbias2 -= expbits_tab[exp_index2[index]] - + expbits_tab[exp_index2[index]-1]; + --exp_index2[index]; + } + } + memcpy(category, exp_index2, sizeof(int) * q->total_subbands ); + memcpy(category_index, tmp_categorize_array+tmp_categorize_array2_idx, sizeof(int) * (q->numvector_size-1) ); +} + + +/** + * Expand the category vector. + * + * @param q pointer to the COOKContext + * @param category pointer to the category array + * @param category_index pointer to the category_index array + */ + +static inline void expand_category(COOKContext *q, int* category, + int* category_index){ + int i; + for(i=0 ; inum_vectors ; i++){ + ++category[category_index[i]]; + } +} + +/** + * Unpack the subband_coef_index and subband_coef_sign vectors. + * + * @param q pointer to the COOKContext + * @param category pointer to the category array + * @param subband_coef_index array of indexes to quant_centroid_tab + * @param subband_coef_sign signs of coefficients + */ + +static int unpack_SQVH(COOKContext *q, int category, int* subband_coef_index, + int* subband_coef_sign) { + int i,j; + int vlc, vd ,tmp, result; + + vd = vd_tab[category]; + result = 0; + for(i=0 ; igb, q->sqvh[category].table, q->sqvh[category].bits, 3); + if (q->bits_per_subpacket < get_bits_count(&q->gb)) + { + vlc = 0; + result = 1; + memset(subband_coef_index, 0, sizeof(int)*vd); + memset(subband_coef_sign, 0, sizeof(int)*vd); + subband_coef_index+=vd; + subband_coef_sign+=vd; + } + else + { + for(j=vd-1 ; j>=0 ; j--){ + tmp = (vlc * invradix_tab[category])/0x100000; + subband_coef_index[j] = vlc - tmp * (kmax_tab[category]+1); + vlc = tmp; + } + + for(j=0 ; jgb) < q->bits_per_subpacket) { + *subband_coef_sign++ = get_bits1(&q->gb); + } else { + result=1; + *subband_coef_sign++=0; + } + } else { + *subband_coef_sign++=0; + } + } + } + } + return result; +} + + +/** + * Fill the mlt_buffer with mlt coefficients. + * + * @param q pointer to the COOKContext + * @param category pointer to the category array + * @param quant_index_table pointer to the array + * @param mlt_buffer pointer to mlt coefficients + */ + +static void decode_vectors(COOKContext* q, int* category, + int *quant_index_table, REAL_T* mlt_buffer) + ICODE_ATTR_COOK_DECODE; +static void decode_vectors(COOKContext* q, int* category, + int *quant_index_table, REAL_T* mlt_buffer){ + /* A zero in this table means that the subband coefficient is + random noise coded. */ + int subband_coef_index[SUBBAND_SIZE]; + /* A zero in this table means that the subband coefficient is a + positive multiplicator. */ + int subband_coef_sign[SUBBAND_SIZE]; + int band, j; + int index=0; + + for(band=0 ; bandtotal_subbands ; band++){ + index = category[band]; + if(category[band] < 7){ + if(unpack_SQVH(q, category[band], subband_coef_index, subband_coef_sign)){ + index=7; + for(j=0 ; jtotal_subbands ; j++) category[band+j]=7; + } + } + if(index>=7) { + memset(subband_coef_index, 0, sizeof(subband_coef_index)); + memset(subband_coef_sign, 0, sizeof(subband_coef_sign)); + } + scalar_dequant_math(q, index, quant_index_table[band], + subband_coef_index, subband_coef_sign, + &mlt_buffer[band * SUBBAND_SIZE]); + } + + if(q->total_subbands*SUBBAND_SIZE >= q->samples_per_channel){ + return; + } /* FIXME: should this be removed, or moved into loop above? */ +} + + +/** + * function for decoding mono data + * + * @param q pointer to the COOKContext + * @param mlt_buffer pointer to mlt coefficients + */ + +static void mono_decode(COOKContext *q, REAL_T* mlt_buffer) ICODE_ATTR_COOK_DECODE; +static void mono_decode(COOKContext *q, REAL_T* mlt_buffer) { + + int category_index[128]; + int quant_index_table[102]; + int category[128]; + + memset(&category, 0, 128*sizeof(int)); + memset(&category_index, 0, 128*sizeof(int)); + + decode_envelope(q, quant_index_table); + q->num_vectors = get_bits(&q->gb,q->log2_numvector_size); + categorize(q, quant_index_table, category, category_index); + expand_category(q, category, category_index); + decode_vectors(q, category, quant_index_table, mlt_buffer); +} + +/** + * function for getting the jointstereo coupling information + * + * @param q pointer to the COOKContext + * @param decouple_tab decoupling array + * + */ + +static void decouple_info(COOKContext *q, int* decouple_tab){ + int length, i; + + if(get_bits1(&q->gb)) { + if(cplband[q->js_subband_start] > cplband[q->subbands-1]) return; + + length = cplband[q->subbands-1] - cplband[q->js_subband_start] + 1; + for (i=0 ; ijs_subband_start] + i] = get_vlc2(&q->gb, q->ccpl.table, q->ccpl.bits, 2); + } + return; + } + + if(cplband[q->js_subband_start] > cplband[q->subbands-1]) return; + + length = cplband[q->subbands-1] - cplband[q->js_subband_start] + 1; + for (i=0 ; ijs_subband_start] + i] = get_bits(&q->gb, q->js_vlc_bits); + } + return; +} + +/** + * function for decoding joint stereo data + * + * @param q pointer to the COOKContext + * @param mlt_buffer1 pointer to left channel mlt coefficients + * @param mlt_buffer2 pointer to right channel mlt coefficients + */ + +static void joint_decode(COOKContext *q, REAL_T* mlt_buffer1, + REAL_T* mlt_buffer2) { + int i; + int decouple_tab[SUBBAND_SIZE]; + REAL_T *decode_buffer = q->decode_buffer_0; + int idx; + + memset(decouple_tab, 0, sizeof(decouple_tab)); + memset(decode_buffer, 0, sizeof(q->decode_buffer_0)); + + /* Make sure the buffers are zeroed out. */ + memset(mlt_buffer1,0, 1024*sizeof(REAL_T)); + memset(mlt_buffer2,0, 1024*sizeof(REAL_T)); + decouple_info(q, decouple_tab); + mono_decode(q, decode_buffer); + + /* The two channels are stored interleaved in decode_buffer. */ + REAL_T * mlt_buffer1_end = mlt_buffer1 + (q->js_subband_start*SUBBAND_SIZE); + while(mlt_buffer1 < mlt_buffer1_end) + { + memcpy(mlt_buffer1,decode_buffer,sizeof(REAL_T)*SUBBAND_SIZE); + memcpy(mlt_buffer2,decode_buffer+20,sizeof(REAL_T)*SUBBAND_SIZE); + mlt_buffer1 += 20; + mlt_buffer2 += 20; + decode_buffer += 40; + } + + /* When we reach js_subband_start (the higher frequencies) + the coefficients are stored in a coupling scheme. */ + idx = (1 << q->js_vlc_bits) - 1; + for (i=q->js_subband_start ; isubbands ; i++) { + int i1 = decouple_tab[cplband[i]]; + int i2 = idx - i1 - 1; + mlt_buffer1_end = mlt_buffer1 + SUBBAND_SIZE; + while(mlt_buffer1 < mlt_buffer1_end) + { + *mlt_buffer1++ = cplscale_math(*decode_buffer, q->js_vlc_bits, i1); + *mlt_buffer2++ = cplscale_math(*decode_buffer++, q->js_vlc_bits, i2); + } + mlt_buffer1 += (20-SUBBAND_SIZE); + mlt_buffer2 += (20-SUBBAND_SIZE); + decode_buffer += (20-SUBBAND_SIZE); + } +} + +/** + * First part of subpacket decoding: + * decode raw stream bytes and read gain info. + * + * @param q pointer to the COOKContext + * @param inbuffer pointer to raw stream data + * @param gain_ptr array of current/prev gain pointers + */ + +#define FFSWAP(type,a,b) do{type SWAP_tmp= b; b= a; a= SWAP_tmp;}while(0) + +static inline void +decode_bytes_and_gain(COOKContext *q, const uint8_t *inbuffer, + cook_gains *gains_ptr) +{ + int offset; + + offset = decode_bytes(inbuffer, q->decoded_bytes_buffer, + q->bits_per_subpacket/8); + init_get_bits(&q->gb, q->decoded_bytes_buffer + offset, + q->bits_per_subpacket); + decode_gain_info(&q->gb, gains_ptr->now); + + /* Swap current and previous gains */ + FFSWAP(int *, gains_ptr->now, gains_ptr->previous); +} + +/** + * Final part of subpacket decoding: + * Apply modulated lapped transform, gain compensation, + * clip and convert to integer. + * + * @param q pointer to the COOKContext + * @param decode_buffer pointer to the mlt coefficients + * @param gain_ptr array of current/prev gain pointers + * @param previous_buffer pointer to the previous buffer to be used for overlapping + * @param out pointer to the output buffer + * @param chan 0: left or single channel, 1: right channel + */ + +static void +mlt_compensate_output(COOKContext *q, REAL_T *decode_buffer, + cook_gains *gains, REAL_T *previous_buffer, + int32_t *out, int chan) +{ + REAL_T *buffer = q->mono_mdct_output; + int i; + imlt_math(q, decode_buffer); + + /* Overlap with the previous block. */ + overlap_math(q, gains->previous[0], previous_buffer); + + /* Apply gain profile */ + for (i = 0; i < 8; i++) { + if (gains->now[i] || gains->now[i + 1]) + interpolate_math(q, &buffer[q->samples_per_channel/8 * i], + gains->now[i], gains->now[i + 1]); + } + + /* Save away the current to be previous block. */ + memcpy(previous_buffer, buffer+q->samples_per_channel, + sizeof(REAL_T)*q->samples_per_channel); + + /* Copy output to non-interleaved sample buffer */ + memcpy(out + (chan * q->samples_per_channel), buffer, + sizeof(REAL_T)*q->samples_per_channel); +} + + +/** + * Cook subpacket decoding. This function returns one decoded subpacket, + * usually 1024 samples per channel. + * + * @param q pointer to the COOKContext + * @param inbuffer pointer to the inbuffer + * @param sub_packet_size subpacket size + * @param outbuffer pointer to the outbuffer + */ + + +static int decode_subpacket(COOKContext *q, const uint8_t *inbuffer, + int sub_packet_size, int32_t *outbuffer) { + /* packet dump */ +// for (i=0 ; igains1); + + if (q->joint_stereo) { + joint_decode(q, q->decode_buffer_1, q->decode_buffer_2); + } else { + mono_decode(q, q->decode_buffer_1); + + if (q->nb_channels == 2) { + decode_bytes_and_gain(q, inbuffer + sub_packet_size/2, &q->gains2); + mono_decode(q, q->decode_buffer_2); + } + } + + mlt_compensate_output(q, q->decode_buffer_1, &q->gains1, + q->mono_previous_buffer1, outbuffer, 0); + + if (q->nb_channels == 2) { + if (q->joint_stereo) { + mlt_compensate_output(q, q->decode_buffer_2, &q->gains1, + q->mono_previous_buffer2, outbuffer, 1); + } else { + mlt_compensate_output(q, q->decode_buffer_2, &q->gains2, + q->mono_previous_buffer2, outbuffer, 1); + } + } + return q->samples_per_frame * sizeof(int32_t); +} + + +/** + * Cook frame decoding + * + * @param rmctx pointer to the RMContext + */ + +int cook_decode_frame(RMContext *rmctx,COOKContext *q, + int32_t *outbuffer, int *data_size, + const uint8_t *inbuffer, int buf_size) { + //COOKContext *q = avctx->priv_data; + //COOKContext *q; + + if (buf_size < rmctx->block_align) + return buf_size; + + *data_size = decode_subpacket(q, inbuffer, rmctx->block_align, outbuffer); + + /* Discard the first two frames: no valid audio. */ + if (rmctx->frame_number < 2) *data_size = 0; + + return rmctx->block_align; +} + +#ifdef COOKDEBUG +static void dump_cook_context(COOKContext *q) +{ + //int i=0; +#define PRINT(a,b) DEBUGF(" %s = %d\n", a, b); + DEBUGF("COOKextradata\n"); + DEBUGF("cookversion=%x\n",q->cookversion); + if (q->cookversion > STEREO) { + PRINT("js_subband_start",q->js_subband_start); + PRINT("js_vlc_bits",q->js_vlc_bits); + } + PRINT("nb_channels",q->nb_channels); + PRINT("bit_rate",q->bit_rate); + PRINT("sample_rate",q->sample_rate); + PRINT("samples_per_channel",q->samples_per_channel); + PRINT("samples_per_frame",q->samples_per_frame); + PRINT("subbands",q->subbands); + PRINT("random_state",q->random_state); + PRINT("js_subband_start",q->js_subband_start); + PRINT("log2_numvector_size",q->log2_numvector_size); + PRINT("numvector_size",q->numvector_size); + PRINT("total_subbands",q->total_subbands); +} +#endif + +/** + * Cook initialization + */ + +int cook_decode_init(RMContext *rmctx, COOKContext *q) +{ +#if defined(CPU_COLDFIRE) + coldfire_set_macsr(EMAC_FRACTIONAL | EMAC_SATURATE); +#endif + /* cook extradata */ + q->cookversion = rm_get_uint32be(rmctx->codec_extradata); + q->samples_per_frame = rm_get_uint16be(&rmctx->codec_extradata[4]); + q->subbands = rm_get_uint16be(&rmctx->codec_extradata[6]); + q->extradata_size = rmctx->extradata_size; + if (q->extradata_size >= 16){ + q->js_subband_start = rm_get_uint16be(&rmctx->codec_extradata[12]); + q->js_vlc_bits = rm_get_uint16be(&rmctx->codec_extradata[14]); + } + + /* Take data from the RMContext (RM container). */ + q->sample_rate = rmctx->sample_rate; + q->nb_channels = rmctx->nb_channels; + q->bit_rate = rmctx->bit_rate; + + /* Initialize RNG. */ + q->random_state = 0; + + /* Initialize extradata related variables. */ + q->samples_per_channel = q->samples_per_frame >> (q->nb_channels-1); + q->bits_per_subpacket = rmctx->block_align * 8; + + /* Initialize default data states. */ + q->log2_numvector_size = 5; + q->total_subbands = q->subbands; + + /* Initialize version-dependent variables */ + DEBUGF("q->cookversion=%x\n",q->cookversion); + q->joint_stereo = 0; + switch (q->cookversion) { + case MONO: + if (q->nb_channels != 1) { + DEBUGF("Container channels != 1, report sample!\n"); + return -1; + } + DEBUGF("MONO\n"); + break; + case STEREO: + if (q->nb_channels != 1) { + q->bits_per_subpacket = q->bits_per_subpacket/2; + } + DEBUGF("STEREO\n"); + break; + case JOINT_STEREO: + if (q->nb_channels != 2) { + DEBUGF("Container channels != 2, report sample!\n"); + return -1; + } + DEBUGF("JOINT_STEREO\n"); + if (q->extradata_size >= 16){ + q->total_subbands = q->subbands + q->js_subband_start; + q->joint_stereo = 1; + } + if (q->samples_per_channel > 256) { + q->log2_numvector_size = 6; + } + if (q->samples_per_channel > 512) { + q->log2_numvector_size = 7; + } + break; + case MC_COOK: + DEBUGF("MC_COOK not supported!\n"); + return -1; + break; + default: + DEBUGF("Unknown Cook version, report sample!\n"); + return -1; + break; + } + + /* Initialize variable relations */ + q->numvector_size = (1 << q->log2_numvector_size); + q->mdct_nbits = av_log2(q->samples_per_channel)+1; + + /* Generate tables */ + if (init_cook_vlc_tables(q) != 0) + return -1; + + + if(rmctx->block_align >= UINT16_MAX/2) + return -1; + + q->gains1.now = q->gain_1; + q->gains1.previous = q->gain_2; + q->gains2.now = q->gain_3; + q->gains2.previous = q->gain_4; + + + /* Initialize COOK signal arithmetic handling */ + /* + if (1) { + q->scalar_dequant = scalar_dequant_math; + q->interpolate = interpolate_math; + } + */ + + /* Try to catch some obviously faulty streams, othervise it might be exploitable */ + if (q->total_subbands > 53) { + DEBUGF("total_subbands > 53, report sample!\n"); + return -1; + } + if (q->subbands > 50) { + DEBUGF("subbands > 50, report sample!\n"); + return -1; + } + if ((q->samples_per_channel == 256) || (q->samples_per_channel == 512) || (q->samples_per_channel == 1024)) { + } else { + DEBUGF("unknown amount of samples_per_channel = %d, report sample!\n",q->samples_per_channel); + return -1; + } + if ((q->js_vlc_bits > 6) || (q->js_vlc_bits < 0)) { + DEBUGF("q->js_vlc_bits = %d, only >= 0 and <= 6 allowed!\n",q->js_vlc_bits); + return -1; + } + + +#ifdef COOKDEBUG + dump_cook_context(q); +#endif + return 0; +} + diff --git a/lib/rbcodec/codecs/libcook/cook.h b/lib/rbcodec/codecs/libcook/cook.h new file mode 100644 index 0000000000..fcb437a0e1 --- /dev/null +++ b/lib/rbcodec/codecs/libcook/cook.h @@ -0,0 +1,131 @@ +/* + * COOK compatible decoder + * Copyright (c) 2003 Sascha Sommer + * Copyright (c) 2005 Benjamin Larsson + * + * This file is taken from FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ +#ifndef _COOK_H +#define _COOK_H + +#include +#include "ffmpeg_get_bits.h" +#include "../librm/rm.h" +#include "cookdata_fixpoint.h" + +#include "codeclib.h" + +#if (CONFIG_CPU == PP5022) || (CONFIG_CPU == PP5024) || (CONFIG_CPU == MCF5250) +/* PP5022/24, MCF5250 have large IRAM */ +#define IBSS_ATTR_COOK_LARGE_IRAM IBSS_ATTR +#define ICODE_ATTR_COOK_LARGE_IRAM ICODE_ATTR +#define ICONST_ATTR_COOK_LARGE_IRAM ICONST_ATTR +#define IBSS_ATTR_COOK_VLCBUF +#define ICODE_ATTR_COOK_DECODE + +#elif defined(CPU_S5L870X) +/* S5L870X have even larger IRAM and it is faster to use ICODE_ATTR. */ +#define IBSS_ATTR_COOK_LARGE_IRAM IBSS_ATTR +#define ICODE_ATTR_COOK_LARGE_IRAM ICODE_ATTR +#define ICONST_ATTR_COOK_LARGE_IRAM ICONST_ATTR +#define IBSS_ATTR_COOK_VLCBUF IBSS_ATTR +#define ICODE_ATTR_COOK_DECODE ICODE_ATTR + +#else +/* other CPUs IRAM is not large enough */ +#define IBSS_ATTR_COOK_LARGE_IRAM +#define ICODE_ATTR_COOK_LARGE_IRAM +#define ICONST_ATTR_COOK_LARGE_IRAM +#define IBSS_ATTR_COOK_VLCBUF +#define ICODE_ATTR_COOK_DECODE + +#endif + +typedef struct { + int *now; + int *previous; +} cook_gains; + +typedef struct cook { + /* + * The following 2 functions provide the lowlevel arithmetic on + * the internal audio buffers. + */ + void (* scalar_dequant)(struct cook *q, int index, int quant_index, + int* subband_coef_index, int* subband_coef_sign, + REAL_T* mlt_p); + + void (* interpolate) (struct cook *q, REAL_T* buffer, + int gain_index, int gain_index_next); + + GetBitContext gb; + int frame_number; + int block_align; + int extradata_size; + /* stream data */ + int nb_channels; + int joint_stereo; + int bit_rate; + int sample_rate; + int samples_per_channel; + int samples_per_frame; + int subbands; + int log2_numvector_size; + int numvector_size; //1 << log2_numvector_size; + int js_subband_start; + int total_subbands; + int num_vectors; + int bits_per_subpacket; + int cookversion; + int mdct_nbits; /* is this the same as one of above? */ + /* states */ + int random_state; + + /* gain buffers */ + cook_gains gains1; + cook_gains gains2; + int gain_1[9]; + int gain_2[9]; + int gain_3[9]; + int gain_4[9]; + + /* VLC data */ + int js_vlc_bits; + VLC envelope_quant_index[13]; + VLC sqvh[7]; //scalar quantization + VLC ccpl; //channel coupling + + /* generatable tables and related variables */ + int gain_size_factor; + + /* data buffers */ + + uint8_t decoded_bytes_buffer[1024] MEM_ALIGN_ATTR; + REAL_T mono_mdct_output[2048] MEM_ALIGN_ATTR; + REAL_T mono_previous_buffer1[1024] MEM_ALIGN_ATTR; + REAL_T mono_previous_buffer2[1024] MEM_ALIGN_ATTR; + REAL_T decode_buffer_1[1024] MEM_ALIGN_ATTR; + REAL_T decode_buffer_2[1024] MEM_ALIGN_ATTR; + /* static allocation for joint decode */ + REAL_T decode_buffer_0[1060] MEM_ALIGN_ATTR; +} COOKContext; + +int cook_decode_init(RMContext *rmctx, COOKContext *q); +int cook_decode_frame(RMContext *rmctx,COOKContext *q, + int32_t *outbuffer, int *data_size, + const uint8_t *inbuffer, int buf_size); +#endif /*_COOK_H */ diff --git a/lib/rbcodec/codecs/libcook/cook_fixpoint.h b/lib/rbcodec/codecs/libcook/cook_fixpoint.h new file mode 100644 index 0000000000..5c4a5d1a5a --- /dev/null +++ b/lib/rbcodec/codecs/libcook/cook_fixpoint.h @@ -0,0 +1,278 @@ +/* + * COOK compatible decoder, fixed point implementation. + * Copyright (c) 2007 Ian Braithwaite + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +/** + * @file cook_fixpoint.h + * + * Cook AKA RealAudio G2 fixed point functions. + * + * Fixed point values are represented as 32 bit signed integers, + * which can be added and subtracted directly in C (without checks for + * overflow/saturation. + * Two multiplication routines are provided: + * 1) Multiplication by powers of two (2^-31 .. 2^31), implemented + * with C's bit shift operations. + * 2) Multiplication by 16 bit fractions (0 <= x < 1), implemented + * in C using two 32 bit integer multiplications. + */ + +#ifdef ROCKBOX +/* get definitions of MULT31, MULT31_SHIFT16, vect_add, from codelib */ +#include "codeclib_misc.h" +#include "codeclib.h" +#endif + +/* cplscales was moved from cookdata_fixpoint.h since only * + * cook_fixpoint.h should see/use it. */ +static const FIXPU* cplscales[5] = { + cplscale2, cplscale3, cplscale4, cplscale5, cplscale6 +}; + +/** + * Fixed point multiply by power of two. + * + * @param x fix point value + * @param i integer power-of-two, -31..+31 + */ +static inline FIXP fixp_pow2(FIXP x, int i) +{ + if (i < 0) + return (x >> -i); + else + return x << i; /* no check for overflow */ +} + +/** + * Fixed point multiply by fraction. + * + * @param a fix point value + * @param b fix point fraction, 0 <= b < 1 + */ +#ifdef ROCKBOX +#define fixp_mult_su(x,y) (MULT31_SHIFT16(x,y)) +#else +static inline FIXP fixp_mult_su(FIXP a, FIXPU b) +{ + int32_t hb = (a >> 16) * b; + uint32_t lb = (a & 0xffff) * b; + + return hb + (lb >> 16) + ((lb & 0x8000) >> 15); +} +#endif + +/* Faster version of the above using 32x32=64 bit multiply */ +#ifdef ROCKBOX +#define fixmul31(x,y) (MULT31(x,y)) +#else +static inline int32_t fixmul31(int32_t x, int32_t y) +{ + int64_t temp; + + temp = x; + temp *= y; + + temp >>= 31; //16+31-16 = 31 bits + + return (int32_t)temp; +} +#endif + +/** + * Clips a signed integer value into the amin-amax range. + * @param a value to clip + * @param amin minimum value of the clip range + * @param amax maximum value of the clip range + * @return clipped value + */ +static inline int av_clip(int a, int amin, int amax) +{ + if (a < amin) return amin; + else if (a > amax) return amax; + else return a; +} + +/** + * The real requantization of the mltcoefs + * + * @param q pointer to the COOKContext + * @param index index + * @param quant_index quantisation index for this band + * @param subband_coef_index array of indexes to quant_centroid_tab + * @param subband_coef_sign use random noise instead of predetermined value + * @param mlt_ptr pointer to the mlt coefficients + */ + +static void scalar_dequant_math(COOKContext *q, int index, + int quant_index, int* subband_coef_index, + int* subband_coef_sign, REAL_T *mlt_p) + ICODE_ATTR_COOK_DECODE; +static void scalar_dequant_math(COOKContext *q, int index, + int quant_index, int* subband_coef_index, + int* subband_coef_sign, REAL_T *mlt_p) +{ + /* Num. half bits to right shift */ + const int s = 33 - quant_index + av_log2(q->samples_per_channel); + const FIXP *table = quant_tables[s & 1][index]; + FIXP f; + int i; + + + if(s >= 64) + memset(mlt_p, 0, sizeof(REAL_T)*SUBBAND_SIZE); + else + { + for(i=0 ; i> (s >> 1); + /* noise coding if subband_coef_index[i] == 0 */ + if (((subband_coef_index[i] == 0) && cook_random(q)) || + ((subband_coef_index[i] != 0) && subband_coef_sign[i])) + f = -f; + + *mlt_p++ = f; + } + } +} + +/** + * The modulated lapped transform, this takes transform coefficients + * and transforms them into timedomain samples. + * A window step is also included. + * + * @param q pointer to the COOKContext + * @param inbuffer pointer to the mltcoefficients + * @param outbuffer pointer to the timedomain buffer + * @param mlt_tmp pointer to temporary storage space + */ +#include "../lib/mdct_lookup.h" + +void imlt_math(COOKContext *q, FIXP *in) ICODE_ATTR; +void imlt_math(COOKContext *q, FIXP *in) +{ + const int n = q->samples_per_channel; + const int step = 2 << (10 - av_log2(n)); + REAL_T *mdct_out = q->mono_mdct_output; + REAL_T tmp; + int i = 0, j = 0; + + ff_imdct_calc(q->mdct_nbits, q->mono_mdct_output, in); + + do { + tmp = mdct_out[i]; + mdct_out[i ] = fixmul31(-mdct_out[n+i], (sincos_lookup0[j ])); + mdct_out[n+i] = fixmul31(tmp , (sincos_lookup0[j+1])); + + j += step; + } while (++i < n/2); + + do { + j -= step; + + tmp = mdct_out[i]; + mdct_out[i ] = fixmul31(-mdct_out[n+i], (sincos_lookup0[j+1])); + mdct_out[n+i] = fixmul31(tmp , (sincos_lookup0[j ])); + } while (++i < n); +} + +/** + * Perform buffer overlapping. + * + * @param q pointer to the COOKContext + * @param gain gain correction to apply first to output buffer + * @param buffer data to overlap + */ +void overlap_math(COOKContext *q, int gain, FIXP buffer[]) ICODE_ATTR; +void overlap_math(COOKContext *q, int gain, FIXP buffer[]) +{ + int i; +#ifdef ROCKBOX + if(LIKELY(gain == 0)) + { + vect_add(q->mono_mdct_output, buffer, q->samples_per_channel); + + } else if (gain > 0){ + for(i=0 ; isamples_per_channel ; i++) { + q->mono_mdct_output[i] = (q->mono_mdct_output[i]<< gain) + buffer[i]; } + + } else { + for(i=0 ; isamples_per_channel ; i++) { + q->mono_mdct_output[i] = (q->mono_mdct_output[i]>>-gain) + buffer[i]; + } + } +#else + for(i=0 ; isamples_per_channel ; i++) { + q->mono_mdct_output[i] = + fixp_pow2(q->mono_mdct_output[i], gain) + buffer[i]; + } +#endif +} + + +/** + * the actual requantization of the timedomain samples + * + * @param q pointer to the COOKContext + * @param buffer pointer to the timedomain buffer + * @param gain_index index for the block multiplier + * @param gain_index_next index for the next block multiplier + */ +static inline void +interpolate_math(COOKContext *q, register FIXP* buffer, + int gain_index, int gain_index_next) +{ + int i; + int gain_size_factor = q->samples_per_channel / 8; + + if(gain_index == gain_index_next){ //static gain + for(i = 0; i < gain_size_factor; i++) { + buffer[i] = fixp_pow2(buffer[i], gain_index); + } + } else { //smooth gain + int step = (gain_index_next - gain_index) + << (7 - av_log2(gain_size_factor)); + int x = 0; + register FIXP* bufferend = buffer+gain_size_factor; + while(buffer < bufferend ) + { + *buffer = fixp_pow2( + fixp_mult_su(*buffer, pow128_tab[x]), + gain_index+1); + buffer++; + + x += step; + gain_index += ( (x + 128) >> 7 ) - 1; + x = ( (x + 128) & 127 ); + } + } +} + + +/** + * Decoupling calculation for joint stereo coefficients. + * + * @param x mono coefficient + * @param table number of decoupling table + * @param i table index + */ +static inline FIXP cplscale_math(FIXP x, int table, int i) +{ + return fixp_mult_su(x, cplscales[table-2][i]); +} diff --git a/lib/rbcodec/codecs/libcook/cookdata.h b/lib/rbcodec/codecs/libcook/cookdata.h new file mode 100644 index 0000000000..a73b96c5f5 --- /dev/null +++ b/lib/rbcodec/codecs/libcook/cookdata.h @@ -0,0 +1,493 @@ +/* + * COOK compatible decoder data + * Copyright (c) 2003 Sascha Sommer + * Copyright (c) 2005 Benjamin Larsson + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +/** + * @file cookdata.h + * Cook AKA RealAudio G2 compatible decoderdata + */ + +/* various data tables */ + +static const int expbits_tab[8] = { + 52,47,43,37,29,22,16,0, +}; + +static const int invradix_tab[7] = { + 74899, 104858, 149797, 209716, 262144, 349526, 524288, +}; + +static const int kmax_tab[7] = { + 13, 9, 6, 4, 3, 2, 1, +}; + +static const int vd_tab[7] = { + 2, 2, 2, 4, 4, 5, 5, +}; + +static const int vpr_tab[7] = { + 10, 10, 10, 5, 5, 4, 4, +}; + + + +/* VLC data */ + +static const int vhsize_tab[7] = { + 191, 97, 48, 607, 246, 230, 32, +}; + +static const int vhvlcsize_tab[7] = { + 8, 7, 7, 10, 9, 9, 6, +}; + +static const uint8_t envelope_quant_index_huffbits[13][24] = { + { 4, 6, 5, 5, 4, 4, 4, 4, 4, 4, 3, 3, 3, 4, 5, 7, 8, 9, 11, 11, 12, 12, 12, 12 }, + { 10, 8, 6, 5, 5, 4, 3, 3, 3, 3, 3, 3, 4, 5, 7, 9, 11, 12, 13, 15, 15, 15, 16, 16 }, + { 12, 10, 8, 6, 5, 4, 4, 4, 4, 4, 4, 3, 3, 3, 4, 4, 5, 5, 7, 9, 11, 13, 14, 14 }, + { 13, 10, 9, 9, 7, 7, 5, 5, 4, 3, 3, 3, 3, 3, 4, 4, 4, 5, 7, 9, 11, 13, 13, 13 }, + { 12, 13, 10, 8, 6, 6, 5, 5, 4, 4, 3, 3, 3, 3, 3, 4, 5, 5, 6, 7, 9, 11, 14, 14 }, + { 12, 11, 9, 8, 8, 7, 5, 4, 4, 3, 3, 3, 3, 3, 4, 4, 5, 5, 7, 8, 10, 13, 14, 14 }, + { 15, 16, 15, 12, 10, 8, 6, 5, 4, 3, 3, 3, 2, 3, 4, 5, 5, 7, 9, 11, 13, 16, 16, 16 }, + { 14, 14, 11, 10, 9, 7, 7, 5, 5, 4, 3, 3, 2, 3, 3, 4, 5, 7, 9, 9, 12, 14, 15, 15 }, + { 9, 9, 9, 8, 7, 6, 5, 4, 3, 3, 3, 3, 3, 3, 4, 5, 6, 7, 8, 10, 11, 12, 13, 13 }, + { 14, 12, 10, 8, 6, 6, 5, 4, 3, 3, 3, 3, 3, 3, 4, 5, 6, 8, 8, 9, 11, 14, 14, 14 }, + { 13, 10, 9, 8, 6, 6, 5, 4, 4, 4, 3, 3, 2, 3, 4, 5, 6, 8, 9, 9, 11, 12, 14, 14 }, + { 16, 13, 12, 11, 9, 6, 5, 5, 4, 4, 4, 3, 2, 3, 3, 4, 5, 7, 8, 10, 14, 16, 16, 16 }, + { 13, 14, 14, 14, 10, 8, 7, 7, 5, 4, 3, 3, 2, 3, 3, 4, 5, 5, 7, 9, 11, 14, 14, 14 }, +}; + +static const uint16_t envelope_quant_index_huffcodes[13][24] = { + {0x0006, 0x003e, 0x001c, 0x001d, 0x0007, 0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x0000, 0x0001, + 0x0002, 0x000d, 0x001e, 0x007e, 0x00fe, 0x01fe, 0x07fc, 0x07fd, 0x0ffc, 0x0ffd, 0x0ffe, 0x0fff}, + {0x03fe, 0x00fe, 0x003e, 0x001c, 0x001d, 0x000c, 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, + 0x000d, 0x001e, 0x007e, 0x01fe, 0x07fe, 0x0ffe, 0x1ffe, 0x7ffc, 0x7ffd, 0x7ffe, 0xfffe, 0xffff}, + {0x0ffe, 0x03fe, 0x00fe, 0x003e, 0x001c, 0x0006, 0x0007, 0x0008, 0x0009, 0x000a, 0x000b, 0x0000, + 0x0001, 0x0002, 0x000c, 0x000d, 0x001d, 0x001e, 0x007e, 0x01fe, 0x07fe, 0x1ffe, 0x3ffe, 0x3fff}, + {0x1ffc, 0x03fe, 0x01fc, 0x01fd, 0x007c, 0x007d, 0x001c, 0x001d, 0x000a, 0x0000, 0x0001, 0x0002, + 0x0003, 0x0004, 0x000b, 0x000c, 0x000d, 0x001e, 0x007e, 0x01fe, 0x07fe, 0x1ffd, 0x1ffe, 0x1fff}, + {0x0ffe, 0x1ffe, 0x03fe, 0x00fe, 0x003c, 0x003d, 0x001a, 0x001b, 0x000a, 0x000b, 0x0000, 0x0001, + 0x0002, 0x0003, 0x0004, 0x000c, 0x001c, 0x001d, 0x003e, 0x007e, 0x01fe, 0x07fe, 0x3ffe, 0x3fff}, + {0x0ffe, 0x07fe, 0x01fe, 0x00fc, 0x00fd, 0x007c, 0x001c, 0x000a, 0x000b, 0x0000, 0x0001, 0x0002, + 0x0003, 0x0004, 0x000c, 0x000d, 0x001d, 0x001e, 0x007d, 0x00fe, 0x03fe, 0x1ffe, 0x3ffe, 0x3fff}, + {0x7ffc, 0xfffc, 0x7ffd, 0x0ffe, 0x03fe, 0x00fe, 0x003e, 0x001c, 0x000c, 0x0002, 0x0003, 0x0004, + 0x0000, 0x0005, 0x000d, 0x001d, 0x001e, 0x007e, 0x01fe, 0x07fe, 0x1ffe, 0xfffd, 0xfffe, 0xffff}, + {0x3ffc, 0x3ffd, 0x07fe, 0x03fe, 0x01fc, 0x007c, 0x007d, 0x001c, 0x001d, 0x000c, 0x0002, 0x0003, + 0x0000, 0x0004, 0x0005, 0x000d, 0x001e, 0x007e, 0x01fd, 0x01fe, 0x0ffe, 0x3ffe, 0x7ffe, 0x7fff}, + {0x01fc, 0x01fd, 0x01fe, 0x00fc, 0x007c, 0x003c, 0x001c, 0x000c, 0x0000, 0x0001, 0x0002, 0x0003, + 0x0004, 0x0005, 0x000d, 0x001d, 0x003d, 0x007d, 0x00fd, 0x03fe, 0x07fe, 0x0ffe, 0x1ffe, 0x1fff}, + {0x3ffc, 0x0ffe, 0x03fe, 0x00fc, 0x003c, 0x003d, 0x001c, 0x000c, 0x0000, 0x0001, 0x0002, 0x0003, + 0x0004, 0x0005, 0x000d, 0x001d, 0x003e, 0x00fd, 0x00fe, 0x01fe, 0x07fe, 0x3ffd, 0x3ffe, 0x3fff}, + {0x1ffe, 0x03fe, 0x01fc, 0x00fc, 0x003c, 0x003d, 0x001c, 0x000a, 0x000b, 0x000c, 0x0002, 0x0003, + 0x0000, 0x0004, 0x000d, 0x001d, 0x003e, 0x00fd, 0x01fd, 0x01fe, 0x07fe, 0x0ffe, 0x3ffe, 0x3fff}, + {0xfffc, 0x1ffe, 0x0ffe, 0x07fe, 0x01fe, 0x003e, 0x001c, 0x001d, 0x000a, 0x000b, 0x000c, 0x0002, + 0x0000, 0x0003, 0x0004, 0x000d, 0x001e, 0x007e, 0x00fe, 0x03fe, 0x3ffe, 0xfffd, 0xfffe, 0xffff}, + {0x1ffc, 0x3ffa, 0x3ffb, 0x3ffc, 0x03fe, 0x00fe, 0x007c, 0x007d, 0x001c, 0x000c, 0x0002, 0x0003, + 0x0000, 0x0004, 0x0005, 0x000d, 0x001d, 0x001e, 0x007e, 0x01fe, 0x07fe, 0x3ffd, 0x3ffe, 0x3fff}, +}; + + +static const uint8_t cvh_huffbits0[191] = { + 1, 4, 6, 6, 7, 7, 8, 8, 8, 9, 9, 10, + 11, 11, 4, 5, 6, 7, 7, 8, 8, 9, 9, 9, + 9, 10, 11, 11, 5, 6, 7, 8, 8, 9, 9, 9, + 9, 10, 10, 10, 11, 12, 6, 7, 8, 9, 9, 9, + 9, 10, 10, 10, 10, 11, 12, 13, 7, 7, 8, 9, + 9, 9, 10, 10, 10, 10, 11, 11, 12, 13, 8, 8, + 9, 9, 9, 10, 10, 10, 10, 11, 11, 12, 13, 14, + 8, 8, 9, 9, 10, 10, 11, 11, 11, 12, 12, 13, + 13, 15, 8, 8, 9, 9, 10, 10, 11, 11, 11, 12, + 12, 13, 14, 15, 9, 9, 9, 10, 10, 10, 11, 11, + 12, 13, 12, 14, 15, 16, 9, 9, 10, 10, 10, 10, + 11, 12, 12, 14, 14, 16, 16, 0, 9, 9, 10, 10, + 11, 11, 12, 13, 13, 14, 14, 15, 0, 0, 10, 10, + 10, 11, 11, 12, 12, 13, 15, 15, 16, 0, 0, 0, + 11, 11, 11, 12, 13, 13, 13, 15, 16, 16, 0, 0, + 0, 0, 11, 11, 12, 13, 13, 14, 15, 16, 16, +}; + +static const uint16_t cvh_huffcodes0[191] = { + 0x0000,0x0008,0x002c,0x002d,0x0062,0x0063,0x00d4,0x00d5,0x00d6,0x01c6,0x01c7,0x03ca, + 0x07d6,0x07d7,0x0009,0x0014,0x002e,0x0064,0x0065,0x00d7,0x00d8,0x01c8,0x01c9,0x01ca, + 0x01cb,0x03cb,0x07d8,0x07d9,0x0015,0x002f,0x0066,0x00d9,0x00da,0x01cc,0x01cd,0x01ce, + 0x01cf,0x03cc,0x03cd,0x03ce,0x07da,0x0fe4,0x0030,0x0067,0x00db,0x01d0,0x01d1,0x01d2, + 0x01d3,0x03cf,0x03d0,0x03d1,0x03d2,0x07db,0x0fe5,0x1fea,0x0068,0x0069,0x00dc,0x01d4, + 0x01d5,0x01d6,0x03d3,0x03d4,0x03d5,0x03d6,0x07dc,0x07dd,0x0fe6,0x1feb,0x00dd,0x00de, + 0x01d7,0x01d8,0x01d9,0x03d7,0x03d8,0x03d9,0x03da,0x07de,0x07df,0x0fe7,0x1fec,0x3ff2, + 0x00df,0x00e0,0x01da,0x01db,0x03db,0x03dc,0x07e0,0x07e1,0x07e2,0x0fe8,0x0fe9,0x1fed, + 0x1fee,0x7ff4,0x00e1,0x00e2,0x01dc,0x01dd,0x03dd,0x03de,0x07e3,0x07e4,0x07e5,0x0fea, + 0x0feb,0x1fef,0x3ff3,0x7ff5,0x01de,0x01df,0x01e0,0x03df,0x03e0,0x03e1,0x07e6,0x07e7, + 0x0fec,0x1ff0,0x0fed,0x3ff4,0x7ff6,0xfff8,0x01e1,0x01e2,0x03e2,0x03e3,0x03e4,0x03e5, + 0x07e8,0x0fee,0x0fef,0x3ff5,0x3ff6,0xfff9,0xfffa,0xfffa,0x01e3,0x01e4,0x03e6,0x03e7, + 0x07e9,0x07ea,0x0ff0,0x1ff1,0x1ff2,0x3ff7,0x3ff8,0x7ff7,0x7ff7,0xfffa,0x03e8,0x03e9, + 0x03ea,0x07eb,0x07ec,0x0ff1,0x0ff2,0x1ff3,0x7ff8,0x7ff9,0xfffb,0x3ff8,0x7ff7,0x7ff7, + 0x07ed,0x07ee,0x07ef,0x0ff3,0x1ff4,0x1ff5,0x1ff6,0x7ffa,0xfffc,0xfffd,0xfffb,0xfffb, + 0x3ff8,0x7ff7,0x07f0,0x07f1,0x0ff4,0x1ff7,0x1ff8,0x3ff9,0x7ffb,0xfffe,0xffff, +}; + + +static const uint8_t cvh_huffbits1[97] = { + 1, 4, 5, 6, 7, 8, 8, 9, 10, 10, 4, 5, + 6, 7, 7, 8, 8, 9, 9, 11, 5, 5, 6, 7, + 8, 8, 9, 9, 10, 11, 6, 6, 7, 8, 8, 9, + 9, 10, 11, 12, 7, 7, 8, 8, 9, 9, 10, 11, + 11, 13, 8, 8, 8, 9, 9, 10, 10, 11, 12, 14, + 8, 8, 8, 9, 10, 11, 11, 12, 13, 15, 9, 9, + 9, 10, 11, 12, 12, 14, 14, 0, 9, 9, 9, 10, + 11, 12, 14, 16, 0, 0, 10, 10, 11, 12, 13, 14, + 16, +}; + + +static const uint16_t cvh_huffcodes1[97] = { + 0x0000,0x0008,0x0014,0x0030,0x006a,0x00e2,0x00e3,0x01e4,0x03ec,0x03ed,0x0009,0x0015, + 0x0031,0x006b,0x006c,0x00e4,0x00e5,0x01e5,0x01e6,0x07f0,0x0016,0x0017,0x0032,0x006d, + 0x00e6,0x00e7,0x01e7,0x01e8,0x03ee,0x07f1,0x0033,0x0034,0x006e,0x00e8,0x00e9,0x01e9, + 0x01ea,0x03ef,0x07f2,0x0ff6,0x006f,0x0070,0x00ea,0x00eb,0x01eb,0x01ec,0x03f0,0x07f3, + 0x07f4,0x1ffa,0x00ec,0x00ed,0x00ee,0x01ed,0x01ee,0x03f1,0x03f2,0x07f5,0x0ff7,0x3ffa, + 0x00ef,0x00f0,0x00f1,0x01ef,0x03f3,0x07f6,0x07f7,0x0ff8,0x1ffb,0x7ffe,0x01f0,0x01f1, + 0x01f2,0x03f4,0x07f8,0x0ff9,0x0ffa,0x3ffb,0x3ffc,0x0000,0x01f3,0x01f4,0x01f5,0x03f5, + 0x07f9,0x0ffb,0x3ffd,0xfffe,0x0000,0x0000,0x03f6,0x03f7,0x07fa,0x0ffc,0x1ffc,0x3ffe, + 0xffff, +}; + +static const uint8_t cvh_huffbits2[48] = { + 1, 4, 5, 7, 8, 9, 10, 3, 4, 5, 7, 8, + 9, 10, 5, 5, 6, 7, 8, 10, 10, 7, 6, 7, + 8, 9, 10, 12, 8, 8, 8, 9, 10, 12, 14, 8, + 9, 9, 10, 11, 15, 16, 9, 10, 11, 12, 13, 16, +}; + +static const uint16_t cvh_huffcodes2[48] = { + 0x0000,0x000a,0x0018,0x0074,0x00f2,0x01f4,0x03f6,0x0004,0x000b,0x0019,0x0075,0x00f3, + 0x01f5,0x03f7,0x001a,0x001b,0x0038,0x0076,0x00f4,0x03f8,0x03f9,0x0077,0x0039,0x0078, + 0x00f5,0x01f6,0x03fa,0x0ffc,0x00f6,0x00f7,0x00f8,0x01f7,0x03fb,0x0ffd,0x3ffe,0x00f9, + 0x01f8,0x01f9,0x03fc,0x07fc,0x7ffe,0xfffe,0x01fa,0x03fd,0x07fd,0x0ffe,0x1ffe,0xffff, +}; + +static const uint8_t cvh_huffbits3[607] = { + 2, 4, 6, 8, 10, 5, 5, 6, 8, 10, 7, 8, + 8, 10, 12, 9, 9, 10, 12, 15, 10, 11, 13, 16, + 16, 5, 6, 8, 10, 11, 5, 6, 8, 10, 12, 7, + 7, 8, 10, 13, 9, 9, 10, 12, 15, 12, 11, 13, + 16, 16, 7, 9, 10, 12, 15, 7, 8, 10, 12, 13, + 9, 9, 11, 13, 16, 11, 11, 12, 14, 16, 12, 12, + 14, 16, 0, 9, 11, 12, 16, 16, 9, 10, 13, 15, + 16, 10, 11, 12, 16, 16, 13, 13, 16, 16, 16, 16, + 16, 15, 16, 0, 11, 13, 16, 16, 15, 11, 13, 15, + 16, 16, 13, 13, 16, 16, 0, 14, 16, 16, 16, 0, + 16, 16, 0, 0, 0, 4, 6, 8, 10, 13, 6, 6, + 8, 10, 13, 9, 8, 10, 12, 16, 10, 10, 11, 15, + 16, 13, 12, 14, 16, 16, 5, 6, 8, 11, 13, 6, + 6, 8, 10, 13, 8, 8, 9, 11, 14, 10, 10, 12, + 12, 16, 13, 12, 13, 15, 16, 7, 8, 9, 12, 16, + 7, 8, 10, 12, 14, 9, 9, 10, 13, 16, 11, 10, + 12, 15, 16, 13, 13, 16, 16, 0, 9, 11, 13, 16, + 16, 9, 10, 12, 15, 16, 10, 11, 13, 16, 16, 13, + 12, 16, 16, 16, 16, 16, 16, 16, 0, 11, 13, 16, + 16, 16, 11, 13, 16, 16, 16, 12, 13, 15, 16, 0, + 16, 16, 16, 16, 0, 16, 16, 0, 0, 0, 6, 8, + 11, 13, 16, 8, 8, 10, 12, 16, 11, 10, 11, 13, + 16, 12, 13, 13, 15, 16, 16, 16, 14, 16, 0, 6, + 8, 10, 13, 16, 8, 8, 10, 12, 16, 10, 10, 11, + 13, 16, 13, 12, 13, 16, 16, 14, 14, 14, 16, 0, + 8, 9, 11, 13, 16, 8, 9, 11, 16, 14, 10, 10, + 12, 15, 16, 12, 12, 13, 16, 16, 15, 16, 16, 16, + 0, 10, 12, 15, 16, 16, 10, 12, 12, 14, 16, 12, + 12, 13, 16, 16, 14, 15, 16, 16, 0, 16, 16, 16, + 0, 0, 12, 15, 15, 16, 0, 13, 13, 16, 16, 0, + 14, 16, 16, 16, 0, 16, 16, 16, 0, 0, 0, 0, + 0, 0, 0, 8, 10, 13, 15, 16, 10, 11, 13, 16, + 16, 13, 13, 14, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 0, 8, 10, 11, 15, 16, 9, 10, 12, + 16, 16, 12, 12, 15, 16, 16, 16, 14, 16, 16, 16, + 16, 16, 16, 16, 0, 9, 11, 14, 16, 16, 10, 11, + 13, 16, 16, 14, 13, 14, 16, 16, 16, 15, 15, 16, + 0, 16, 16, 16, 0, 0, 11, 13, 16, 16, 16, 11, + 13, 15, 16, 16, 13, 16, 16, 16, 0, 16, 16, 16, + 16, 0, 16, 16, 0, 0, 0, 15, 16, 16, 16, 0, + 14, 16, 16, 16, 0, 16, 16, 16, 0, 0, 16, 16, + 0, 0, 0, 0, 0, 0, 0, 0, 9, 13, 16, 16, + 16, 11, 13, 16, 16, 16, 14, 15, 16, 16, 0, 15, + 16, 16, 16, 0, 16, 16, 0, 0, 0, 9, 13, 15, + 15, 16, 12, 13, 14, 16, 16, 16, 15, 16, 16, 0, + 16, 16, 16, 16, 0, 16, 16, 0, 0, 0, 11, 13, + 15, 16, 0, 12, 14, 16, 16, 0, 16, 16, 16, 16, + 0, 16, 16, 16, 0, 0, 0, 0, 0, 0, 0, 16, + 16, 16, 16, 0, 16, 16, 16, 16, 0, 16, 16, 16, + 0, 0, 16, 16, 0, 0, 0, 0, 0, 0, 0, 0, + 16, 16, 0, 0, 0, 16, 16, +}; + + +static const uint16_t cvh_huffcodes3[607] = { + 0x0000,0x0004,0x0022,0x00c6,0x03b0,0x000c,0x000d,0x0023,0x00c7,0x03b1,0x005c,0x00c8, + 0x00c9,0x03b2,0x0fa4,0x01c2,0x01c3,0x03b3,0x0fa5,0x7f72,0x03b4,0x07b2,0x1f9a,0xff24, + 0xff25,0x000e,0x0024,0x00ca,0x03b5,0x07b3,0x000f,0x0025,0x00cb,0x03b6,0x0fa6,0x005d, + 0x005e,0x00cc,0x03b7,0x1f9b,0x01c4,0x01c5,0x03b8,0x0fa7,0x7f73,0x0fa8,0x07b4,0x1f9c, + 0xff26,0xff27,0x005f,0x01c6,0x03b9,0x0fa9,0x7f74,0x0060,0x00cd,0x03ba,0x0faa,0x1f9d, + 0x01c7,0x01c8,0x07b5,0x1f9e,0xff28,0x07b6,0x07b7,0x0fab,0x3fa2,0xff29,0x0fac,0x0fad, + 0x3fa3,0xff2a,0x3fa2,0x01c9,0x07b8,0x0fae,0xff2b,0xff2c,0x01ca,0x03bb,0x1f9f,0x7f75, + 0xff2d,0x03bc,0x07b9,0x0faf,0xff2e,0xff2f,0x1fa0,0x1fa1,0xff30,0xff31,0xff32,0xff33, + 0xff34,0x7f76,0xff35,0xff31,0x07ba,0x1fa2,0xff36,0xff37,0x7f77,0x07bb,0x1fa3,0x7f78, + 0xff38,0xff39,0x1fa4,0x1fa5,0xff3a,0xff3b,0xff2e,0x3fa4,0xff3c,0xff3d,0xff3e,0xff31, + 0xff3f,0xff40,0xff30,0xff31,0xff31,0x0005,0x0026,0x00ce,0x03bd,0x1fa6,0x0027,0x0028, + 0x00cf,0x03be,0x1fa7,0x01cb,0x00d0,0x03bf,0x0fb0,0xff41,0x03c0,0x03c1,0x07bc,0x7f79, + 0xff42,0x1fa8,0x0fb1,0x3fa5,0xff43,0xff44,0x0010,0x0029,0x00d1,0x07bd,0x1fa9,0x002a, + 0x002b,0x00d2,0x03c2,0x1faa,0x00d3,0x00d4,0x01cc,0x07be,0x3fa6,0x03c3,0x03c4,0x0fb2, + 0x0fb3,0xff45,0x1fab,0x0fb4,0x1fac,0x7f7a,0xff46,0x0061,0x00d5,0x01cd,0x0fb5,0xff47, + 0x0062,0x00d6,0x03c5,0x0fb6,0x3fa7,0x01ce,0x01cf,0x03c6,0x1fad,0xff48,0x07bf,0x03c7, + 0x0fb7,0x7f7b,0xff49,0x1fae,0x1faf,0xff4a,0xff4b,0x7f7b,0x01d0,0x07c0,0x1fb0,0xff4c, + 0xff4d,0x01d1,0x03c8,0x0fb8,0x7f7c,0xff4e,0x03c9,0x07c1,0x1fb1,0xff4f,0xff50,0x1fb2, + 0x0fb9,0xff51,0xff52,0xff53,0xff54,0xff55,0xff56,0xff57,0xff52,0x07c2,0x1fb3,0xff58, + 0xff59,0xff5a,0x07c3,0x1fb4,0xff5b,0xff5c,0xff5d,0x0fba,0x1fb5,0x7f7d,0xff5e,0xff4f, + 0xff5f,0xff60,0xff61,0xff62,0xff52,0xff63,0xff64,0xff51,0xff52,0xff52,0x002c,0x00d7, + 0x07c4,0x1fb6,0xff65,0x00d8,0x00d9,0x03ca,0x0fbb,0xff66,0x07c5,0x03cb,0x07c6,0x1fb7, + 0xff67,0x0fbc,0x1fb8,0x1fb9,0x7f7e,0xff68,0xff69,0xff6a,0x3fa8,0xff6b,0x7f7e,0x002d, + 0x00da,0x03cc,0x1fba,0xff6c,0x00db,0x00dc,0x03cd,0x0fbd,0xff6d,0x03ce,0x03cf,0x07c7, + 0x1fbb,0xff6e,0x1fbc,0x0fbe,0x1fbd,0xff6f,0xff70,0x3fa9,0x3faa,0x3fab,0xff71,0xff6f, + 0x00dd,0x01d2,0x07c8,0x1fbe,0xff72,0x00de,0x01d3,0x07c9,0xff73,0x3fac,0x03d0,0x03d1, + 0x0fbf,0x7f7f,0xff74,0x0fc0,0x0fc1,0x1fbf,0xff75,0xff76,0x7f80,0xff77,0xff78,0xff79, + 0xff75,0x03d2,0x0fc2,0x7f81,0xff7a,0xff7b,0x03d3,0x0fc3,0x0fc4,0x3fad,0xff7c,0x0fc5, + 0x0fc6,0x1fc0,0xff7d,0xff7e,0x3fae,0x7f82,0xff7f,0xff80,0xff80,0xff81,0xff82,0xff83, + 0xff80,0xff80,0x0fc7,0x7f83,0x7f84,0xff84,0xff7a,0x1fc1,0x1fc2,0xff85,0xff86,0x3fad, + 0x3faf,0xff87,0xff88,0xff89,0xff7d,0xff8a,0xff8b,0xff8c,0xff80,0xff80,0x3fae,0x7f82, + 0xff7f,0xff80,0xff80,0x00df,0x03d4,0x1fc3,0x7f85,0xff8d,0x03d5,0x07ca,0x1fc4,0xff8e, + 0xff8f,0x1fc5,0x1fc6,0x3fb0,0xff90,0xff91,0xff92,0xff93,0xff94,0xff95,0xff96,0xff97, + 0xff98,0xff99,0xff9a,0xff95,0x00e0,0x03d6,0x07cb,0x7f86,0xff9b,0x01d4,0x03d7,0x0fc8, + 0xff9c,0xff9d,0x0fc9,0x0fca,0x7f87,0xff9e,0xff9f,0xffa0,0x3fb1,0xffa1,0xffa2,0xffa3, + 0xffa4,0xffa5,0xffa6,0xffa7,0xffa2,0x01d5,0x07cc,0x3fb2,0xffa8,0xffa9,0x03d8,0x07cd, + 0x1fc7,0xffaa,0xffab,0x3fb3,0x1fc8,0x3fb4,0xffac,0xffad,0xffae,0x7f88,0x7f89,0xffaf, + 0xffaf,0xffb0,0xffb1,0xffb2,0xffaf,0xffaf,0x07ce,0x1fc9,0xffb3,0xffb4,0xffb5,0x07cf, + 0x1fca,0x7f8a,0xffb6,0xffb7,0x1fcb,0xffb8,0xffb9,0xffba,0xffba,0xffbb,0xffbc,0xffbd, + 0xffbe,0xffbe,0xffbf,0xffc0,0xffbd,0xffbe,0xffbe,0x7f8b,0xffc1,0xffc2,0xffc3,0xffb4, + 0x3fb5,0xffc4,0xffc5,0xffc6,0xffb6,0xffc7,0xffc8,0xffc9,0xffba,0xffba,0xffca,0xffcb, + 0xffbd,0xffbe,0xffbe,0xffbb,0xffbc,0xffbd,0xffbe,0xffbe,0x01d6,0x1fcc,0xffcc,0xffcd, + 0xffce,0x07d0,0x1fcd,0xffcf,0xffd0,0xffd1,0x3fb6,0x7f8c,0xffd2,0xffd3,0xff90,0x7f8d, + 0xffd4,0xffd5,0xffd6,0xff95,0xffd7,0xffd8,0xff94,0xff95,0xff95,0x01d7,0x1fce,0x7f8e, + 0x7f8f,0xffd9,0x0fcb,0x1fcf,0x3fb7,0xffda,0xffdb,0xffdc,0x7f90,0xffdd,0xffde,0xff9e, + 0xffdf,0xffe0,0xffe1,0xffe2,0xffa2,0xffe3,0xffe4,0xffa1,0xffa2,0xffa2,0x07d1,0x1fd0, + 0x7f91,0xffe5,0xffa8,0x0fcc,0x3fb8,0xffe6,0xffe7,0xffaa,0xffe8,0xffe9,0xffea,0xffeb, + 0xffac,0xffec,0xffed,0xffee,0xffaf,0xffaf,0xffae,0x7f88,0x7f89,0xffaf,0xffaf,0xffef, + 0xfff0,0xfff1,0xfff2,0xffb4,0xfff3,0xfff4,0xfff5,0xfff6,0xffb6,0xfff7,0xfff8,0xfff9, + 0xffba,0xffba,0xfffa,0xfffb,0xffbd,0xffbe,0xffbe,0xffbb,0xffbc,0xffbd,0xffbe,0xffbe, + 0xfffc,0xfffd,0xffb3,0xffb4,0xffb4,0xfffe,0xffff, +}; + +static const uint8_t cvh_huffbits4[246] = { + 2, 4, 7, 10, 4, 5, 7, 10, 7, 8, 10, 14, + 11, 11, 15, 15, 4, 5, 9, 12, 5, 5, 8, 12, + 8, 7, 10, 15, 11, 11, 15, 15, 7, 9, 12, 15, + 8, 8, 12, 15, 10, 10, 13, 15, 14, 14, 15, 0, + 11, 13, 15, 15, 11, 13, 15, 15, 14, 15, 15, 0, + 15, 15, 0, 0, 4, 5, 9, 13, 5, 6, 9, 13, + 9, 9, 11, 15, 14, 13, 15, 15, 4, 6, 9, 12, + 5, 6, 9, 13, 9, 8, 11, 15, 13, 12, 15, 15, + 7, 9, 12, 15, 7, 8, 11, 15, 10, 10, 14, 15, + 14, 15, 15, 0, 10, 12, 15, 15, 11, 13, 15, 15, + 15, 15, 15, 0, 15, 15, 0, 0, 6, 9, 13, 14, + 8, 9, 12, 15, 12, 12, 15, 15, 15, 15, 15, 0, + 7, 9, 13, 15, 8, 9, 12, 15, 11, 12, 15, 15, + 15, 15, 15, 0, 9, 11, 15, 15, 9, 11, 15, 15, + 14, 14, 15, 0, 15, 15, 0, 0, 14, 15, 15, 0, + 14, 15, 15, 0, 15, 15, 0, 0, 0, 0, 0, 0, + 9, 12, 15, 15, 12, 13, 15, 15, 15, 15, 15, 0, + 15, 15, 0, 0, 10, 12, 15, 15, 12, 14, 15, 15, + 15, 15, 15, 0, 15, 15, 0, 0, 14, 15, 15, 0, + 15, 15, 15, 0, 15, 15, 0, 0, 0, 0, 0, 0, + 15, 15, 0, 0, 15, 15, +}; + + +static const uint16_t cvh_huffcodes4[246] = { + 0x0000,0x0004,0x006c,0x03e6,0x0005,0x0012,0x006d,0x03e7,0x006e,0x00e8,0x03e8,0x3fc4, + 0x07e0,0x07e1,0x7fa4,0x7fa5,0x0006,0x0013,0x01e2,0x0fda,0x0014,0x0015,0x00e9,0x0fdb, + 0x00ea,0x006f,0x03e9,0x7fa6,0x07e2,0x07e3,0x7fa7,0x7fa8,0x0070,0x01e3,0x0fdc,0x7fa9, + 0x00eb,0x00ec,0x0fdd,0x7faa,0x03ea,0x03eb,0x1fd6,0x7fab,0x3fc5,0x3fc6,0x7fac,0x1fd6, + 0x07e4,0x1fd7,0x7fad,0x7fae,0x07e5,0x1fd8,0x7faf,0x7fb0,0x3fc7,0x7fb1,0x7fb2,0x1fd6, + 0x7fb3,0x7fb4,0x1fd6,0x1fd6,0x0007,0x0016,0x01e4,0x1fd9,0x0017,0x0032,0x01e5,0x1fda, + 0x01e6,0x01e7,0x07e6,0x7fb5,0x3fc8,0x1fdb,0x7fb6,0x7fb7,0x0008,0x0033,0x01e8,0x0fde, + 0x0018,0x0034,0x01e9,0x1fdc,0x01ea,0x00ed,0x07e7,0x7fb8,0x1fdd,0x0fdf,0x7fb9,0x7fba, + 0x0071,0x01eb,0x0fe0,0x7fbb,0x0072,0x00ee,0x07e8,0x7fbc,0x03ec,0x03ed,0x3fc9,0x7fbd, + 0x3fca,0x7fbe,0x7fbf,0x3fc9,0x03ee,0x0fe1,0x7fc0,0x7fc1,0x07e9,0x1fde,0x7fc2,0x7fc3, + 0x7fc4,0x7fc5,0x7fc6,0x3fc9,0x7fc7,0x7fc8,0x3fc9,0x3fc9,0x0035,0x01ec,0x1fdf,0x3fcb, + 0x00ef,0x01ed,0x0fe2,0x7fc9,0x0fe3,0x0fe4,0x7fca,0x7fcb,0x7fcc,0x7fcd,0x7fce,0x7fca, + 0x0073,0x01ee,0x1fe0,0x7fcf,0x00f0,0x01ef,0x0fe5,0x7fd0,0x07ea,0x0fe6,0x7fd1,0x7fd2, + 0x7fd3,0x7fd4,0x7fd5,0x7fd1,0x01f0,0x07eb,0x7fd6,0x7fd7,0x01f1,0x07ec,0x7fd8,0x7fd9, + 0x3fcc,0x3fcd,0x7fda,0x7fda,0x7fdb,0x7fdc,0x7fda,0x7fda,0x3fce,0x7fdd,0x7fde,0x7fd6, + 0x3fcf,0x7fdf,0x7fe0,0x7fd8,0x7fe1,0x7fe2,0x7fda,0x7fda,0x3fcc,0x3fcd,0x7fda,0x7fda, + 0x01f2,0x0fe7,0x7fe3,0x7fe4,0x0fe8,0x1fe1,0x7fe5,0x7fe6,0x7fe7,0x7fe8,0x7fe9,0x7fca, + 0x7fea,0x7feb,0x7fca,0x7fca,0x03ef,0x0fe9,0x7fec,0x7fed,0x0fea,0x3fd0,0x7fee,0x7fef, + 0x7ff0,0x7ff1,0x7ff2,0x7fd1,0x7ff3,0x7ff4,0x7fd1,0x7fd1,0x3fd1,0x7ff5,0x7ff6,0x7fd6, + 0x7ff7,0x7ff8,0x7ff9,0x7fd8,0x7ffa,0x7ffb,0x7fda,0x7fda,0x3fcc,0x3fcd,0x7fda,0x7fda, + 0x7ffc,0x7ffd,0x7fd6,0x7fd6,0x7ffe,0x7fff, +}; + + +static const uint8_t cvh_huffbits5[230] = { + 2, 4, 8, 4, 5, 9, 9, 10, 14, 4, 6, 11, + 5, 6, 12, 10, 11, 15, 9, 11, 15, 10, 13, 15, + 14, 15, 0, 4, 6, 12, 6, 7, 12, 12, 12, 15, + 5, 7, 13, 6, 7, 13, 12, 13, 15, 10, 12, 15, + 11, 13, 15, 15, 15, 0, 8, 13, 15, 11, 12, 15, + 15, 15, 0, 10, 13, 15, 12, 15, 15, 15, 15, 0, + 15, 15, 0, 15, 15, 0, 0, 0, 0, 4, 5, 11, + 5, 7, 12, 11, 12, 15, 6, 7, 13, 7, 8, 14, + 12, 14, 15, 11, 13, 15, 12, 13, 15, 15, 15, 0, + 5, 6, 13, 7, 8, 15, 12, 14, 15, 6, 8, 14, + 7, 8, 15, 14, 15, 15, 12, 12, 15, 12, 13, 15, + 15, 15, 0, 9, 13, 15, 12, 13, 15, 15, 15, 0, + 11, 13, 15, 13, 13, 15, 15, 15, 0, 14, 15, 0, + 15, 15, 0, 0, 0, 0, 8, 10, 15, 11, 12, 15, + 15, 15, 0, 10, 12, 15, 12, 13, 15, 15, 15, 0, + 14, 15, 0, 15, 15, 0, 0, 0, 0, 8, 12, 15, + 12, 13, 15, 15, 15, 0, 11, 13, 15, 13, 15, 15, + 15, 15, 0, 15, 15, 0, 15, 15, 0, 0, 0, 0, + 14, 15, 0, 15, 15, 0, 0, 0, 0, 15, 15, 0, + 15, 15, +}; + + + +static const uint16_t cvh_huffcodes5[230] = { + 0x0000,0x0004,0x00f0,0x0005,0x0012,0x01f0,0x01f1,0x03e8,0x3fce,0x0006,0x0030,0x07de, + 0x0013,0x0031,0x0fd2,0x03e9,0x07df,0x7fb0,0x01f2,0x07e0,0x7fb1,0x03ea,0x1fd2,0x7fb2, + 0x3fcf,0x7fb3,0x0031,0x0007,0x0032,0x0fd3,0x0033,0x0070,0x0fd4,0x0fd5,0x0fd6,0x7fb4, + 0x0014,0x0071,0x1fd3,0x0034,0x0072,0x1fd4,0x0fd7,0x1fd5,0x7fb5,0x03eb,0x0fd8,0x7fb6, + 0x07e1,0x1fd6,0x7fb7,0x7fb8,0x7fb9,0x0072,0x00f1,0x1fd7,0x7fba,0x07e2,0x0fd9,0x7fbb, + 0x7fbc,0x7fbd,0x0070,0x03ec,0x1fd8,0x7fbe,0x0fda,0x7fbf,0x7fc0,0x7fc1,0x7fc2,0x0072, + 0x7fc3,0x7fc4,0x0071,0x7fc5,0x7fc6,0x0072,0x0034,0x0072,0x0072,0x0008,0x0015,0x07e3, + 0x0016,0x0073,0x0fdb,0x07e4,0x0fdc,0x7fc7,0x0035,0x0074,0x1fd9,0x0075,0x00f2,0x3fd0, + 0x0fdd,0x3fd1,0x7fc8,0x07e5,0x1fda,0x7fc9,0x0fde,0x1fdb,0x7fca,0x7fcb,0x7fcc,0x00f2, + 0x0017,0x0036,0x1fdc,0x0076,0x00f3,0x7fcd,0x0fdf,0x3fd2,0x7fce,0x0037,0x00f4,0x3fd3, + 0x0077,0x00f5,0x7fcf,0x3fd4,0x7fd0,0x7fd1,0x0fe0,0x0fe1,0x7fd2,0x0fe2,0x1fdd,0x7fd3, + 0x7fd4,0x7fd5,0x00f5,0x01f3,0x1fde,0x7fd6,0x0fe3,0x1fdf,0x7fd7,0x7fd8,0x7fd9,0x00f3, + 0x07e6,0x1fe0,0x7fda,0x1fe1,0x1fe2,0x7fdb,0x7fdc,0x7fdd,0x00f5,0x3fd5,0x7fde,0x00f4, + 0x7fdf,0x7fe0,0x00f5,0x0077,0x00f5,0x00f5,0x00f6,0x03ed,0x7fe1,0x07e7,0x0fe4,0x7fe2, + 0x7fe3,0x7fe4,0x0073,0x03ee,0x0fe5,0x7fe5,0x0fe6,0x1fe3,0x7fe6,0x7fe7,0x7fe8,0x00f2, + 0x3fd6,0x7fe9,0x0074,0x7fea,0x7feb,0x00f2,0x0075,0x00f2,0x00f2,0x00f7,0x0fe7,0x7fec, + 0x0fe8,0x1fe4,0x7fed,0x7fee,0x7fef,0x00f3,0x07e8,0x1fe5,0x7ff0,0x1fe6,0x7ff1,0x7ff2, + 0x7ff3,0x7ff4,0x00f5,0x7ff5,0x7ff6,0x00f4,0x7ff7,0x7ff8,0x00f5,0x0077,0x00f5,0x00f5, + 0x3fd7,0x7ff9,0x0036,0x7ffa,0x7ffb,0x00f3,0x0076,0x00f3,0x00f3,0x7ffc,0x7ffd,0x0000, + 0x7ffe,0x7fff, +}; + + +static const uint8_t cvh_huffbits6[32] = { + 1, 4, 4, 6, 4, 6, 6, 8, 4, 6, 6, 8, + 6, 9, 8, 10, 4, 6, 7, 8, 6, 9, 8, 11, + 6, 9, 8, 10, 8, 10, 9, 11, +}; + +static const uint16_t cvh_huffcodes6[32] = { + 0x0000,0x0008,0x0009,0x0034,0x000a,0x0035,0x0036,0x00f6,0x000b,0x0037,0x0038,0x00f7, + 0x0039,0x01fa,0x00f8,0x03fc,0x000c,0x003a,0x007a,0x00f9,0x003b,0x01fb,0x00fa,0x07fe, + 0x003c,0x01fc,0x00fb,0x03fd,0x00fc,0x03fe,0x01fd,0x07ff, +}; + +static const uint16_t* cvh_huffcodes[7] = { + cvh_huffcodes0, cvh_huffcodes1, cvh_huffcodes2, cvh_huffcodes3, + cvh_huffcodes4, cvh_huffcodes5, cvh_huffcodes6, +}; + +static const uint8_t* cvh_huffbits[7] = { + cvh_huffbits0, cvh_huffbits1, cvh_huffbits2, cvh_huffbits3, + cvh_huffbits4, cvh_huffbits5, cvh_huffbits6, +}; + + +static const uint16_t ccpl_huffcodes2[3] = { + 0x02,0x00,0x03, +}; + +static const uint16_t ccpl_huffcodes3[7] = { + 0x3e,0x1e,0x02,0x00,0x06,0x0e,0x3f, +}; + +static const uint16_t ccpl_huffcodes4[15] = { + 0xfc,0xfd,0x7c,0x3c,0x1c,0x0c,0x04,0x00,0x05,0x0d,0x1d,0x3d, + 0x7d,0xfe,0xff, +}; + +static const uint16_t ccpl_huffcodes5[31] = { + 0x03f8,0x03f9,0x03fa,0x03fb,0x01f8,0x01f9,0x00f8,0x00f9,0x0078,0x0079,0x0038,0x0039, + 0x0018,0x0019,0x0004,0x0000,0x0005,0x001a,0x001b,0x003a,0x003b,0x007a,0x007b,0x00fa, + 0x00fb,0x01fa,0x01fb,0x03fc,0x03fd,0x03fe,0x03ff, +}; + +static const uint16_t ccpl_huffcodes6[63] = { + 0x0004,0x0005,0x0005,0x0006,0x0006,0x0007,0x0007,0x0007,0x0007,0x0008,0x0008,0x0008, + 0x0008,0x0009,0x0009,0x0009,0x0009,0x000a,0x000a,0x000a,0x000a,0x000a,0x000b,0x000b, + 0x000b,0x000b,0x000c,0x000d,0x000e,0x000e,0x0010,0x0000,0x000a,0x0018,0x0019,0x0036, + 0x0037,0x0074,0x0075,0x0076,0x0077,0x00f4,0x00f5,0x00f6,0x00f7,0x01f5,0x01f6,0x01f7, + 0x01f8,0x03f6,0x03f7,0x03f8,0x03f9,0x03fa,0x07fa,0x07fb,0x07fc,0x07fd,0x0ffd,0x1ffd, + 0x3ffd,0x3ffe,0xffff, +}; + +static const uint8_t ccpl_huffbits2[3] = { + 2,1,2, +}; + +static const uint8_t ccpl_huffbits3[7] = { + 6,5,2,1,3,4,6, +}; + +static const uint8_t ccpl_huffbits4[15] = { + 8,8,7,6,5,4,3,1,3,4,5,6,7,8,8, +}; + +static const uint8_t ccpl_huffbits5[31] = { + 10,10,10,10,9,9,8,8,7,7,6,6, + 5,5,3,1,3,5,5,6,6,7,7,8, + 8,9,9,10,10,10,10, +}; + +static const uint8_t ccpl_huffbits6[63] = { + 16,15,14,13,12,11,11,11,11,10,10,10, + 10,9,9,9,9,9,8,8,8,8,7,7, + 7,7,6,6,5,5,3,1,4,5,5,6, + 6,7,7,7,7,8,8,8,8,9,9,9, + 9,10,10,10,10,10,11,11,11,11,12,13, + 14,14,16, +}; + +static const uint16_t* ccpl_huffcodes[5] = { + ccpl_huffcodes2,ccpl_huffcodes3, + ccpl_huffcodes4,ccpl_huffcodes5,ccpl_huffcodes6 +}; + +static const uint8_t* ccpl_huffbits[5] = { + ccpl_huffbits2,ccpl_huffbits3, + ccpl_huffbits4,ccpl_huffbits5,ccpl_huffbits6 +}; + + +//Coupling tables + +static const int cplband[51] = { + 0,1,2,3,4,5,6,7,8,9, + 10,11,11,12,12,13,13,14,14,14, + 15,15,15,15,16,16,16,16,16,17, + 17,17,17,17,17,18,18,18,18,18, + 18,18,19,19,19,19,19,19,19,19, + 19, +}; diff --git a/lib/rbcodec/codecs/libcook/cookdata_fixpoint.h b/lib/rbcodec/codecs/libcook/cookdata_fixpoint.h new file mode 100644 index 0000000000..b58666031d --- /dev/null +++ b/lib/rbcodec/codecs/libcook/cookdata_fixpoint.h @@ -0,0 +1,164 @@ +/* + * COOK compatible decoder fixed point data types and constants + * Copyright (c) 2007 Ian Braithwaite + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +/** + * @file cookdata_fixpoint.h + * Cook AKA RealAudio G2 compatible decoder + * fixed point data types and constants + */ + +#include +typedef int32_t FIXP; /* Fixed point variable type */ +typedef uint16_t FIXPU; /* Fixed point fraction 0<=x<1 */ + +typedef FIXP REAL_T; + + +/* No additional variables in COOKContext + * for fixed point routines + */ +typedef struct { +} realvars_t; + +static const FIXPU pow128_tab[128] = { + /* x_i = 2^(15+i/128) */ + 0x8000, 0x80b2, 0x8165, 0x8219, 0x82ce, 0x8383, 0x843a, 0x84f2, 0x85ab, + 0x8665, 0x871f, 0x87db, 0x8898, 0x8956, 0x8a15, 0x8ad5, 0x8b96, 0x8c58, + 0x8d1b, 0x8ddf, 0x8ea4, 0x8f6b, 0x9032, 0x90fa, 0x91c4, 0x928e, 0x935a, + 0x9427, 0x94f5, 0x95c4, 0x9694, 0x9765, 0x9838, 0x990c, 0x99e0, 0x9ab6, + 0x9b8d, 0x9c65, 0x9d3f, 0x9e19, 0x9ef5, 0x9fd2, 0xa0b0, 0xa190, 0xa270, + 0xa352, 0xa435, 0xa519, 0xa5ff, 0xa6e6, 0xa7ce, 0xa8b7, 0xa9a1, 0xaa8d, + 0xab7a, 0xac69, 0xad58, 0xae49, 0xaf3b, 0xb02f, 0xb124, 0xb21a, 0xb312, + 0xb40b, 0xb505, 0xb601, 0xb6fe, 0xb7fc, 0xb8fc, 0xb9fd, 0xbaff, 0xbc03, + 0xbd09, 0xbe0f, 0xbf18, 0xc021, 0xc12c, 0xc239, 0xc347, 0xc456, 0xc567, + 0xc67a, 0xc78d, 0xc8a3, 0xc9ba, 0xcad2, 0xcbec, 0xcd08, 0xce25, 0xcf43, + 0xd063, 0xd185, 0xd2a8, 0xd3cd, 0xd4f3, 0xd61b, 0xd745, 0xd870, 0xd99d, + 0xdacc, 0xdbfc, 0xdd2e, 0xde61, 0xdf96, 0xe0cd, 0xe205, 0xe340, 0xe47b, + 0xe5b9, 0xe6f8, 0xe839, 0xe97c, 0xeac1, 0xec07, 0xed4f, 0xee99, 0xefe5, + 0xf132, 0xf281, 0xf3d3, 0xf525, 0xf67a, 0xf7d1, 0xf929, 0xfa84, 0xfbe0, + 0xfd3e, 0xfe9e +}; + + + +/* dither_table and quant_centroid_table. + * Index 1: [0] - scaled by 2^13, [1] - scaled by 2^13 / sqrt(2) + * Index 2: [0..7] - category + * Index 3: [0] - dither_table, [1..13] - quant_centroid_table + */ +static const FIXP quant_tables[2][8][14] ICONST_ATTR = {{{ + 0x00000000, 0x0645a1cb, 0x0c2d0e56, 0x11eb851f, 0x17a1cac1, 0x1d4fdf3b, + 0x22ed9168, 0x28a7ef9e, 0x2e49ba5e, 0x33eb851f, 0x39916873, 0x3f126e98, + 0x449ba5e3, 0x4b958106 +},{ + 0x00000000, 0x08b43958, 0x10f5c28f, 0x19020c4a, 0x2116872b, 0x2922d0e5, + 0x3126e979, 0x38fdf3b6, 0x411eb852, 0x49eb851f, 0x00000000, 0x00000000, + 0x00000000, 0x00000000 +},{ + 0x00000000, 0x0bef9db2, 0x176c8b44, 0x22e147ae, 0x2e1cac08, 0x39581062, + 0x450e5604, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000 +},{ + 0x00000000, 0x10189375, 0x20000000, 0x2fe353f8, 0x3fc28f5c, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000 +},{ + 0x00000000, 0x1522d0e5, 0x2b3f7cee, 0x3fba5e35, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000 +},{ + 0x02d413cd, 0x1a83126f, 0x37db22d1, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000 +},{ + 0x04000000, 0x1f6c8b44, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000 +},{ + 0x0b504f33, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000 +}},{{ + 0x00000000, 0x046f5a70, 0x089c1768, 0x0cabddd3, 0x10b5d955, 0x14ba09ed, + 0x18b2a4b4, 0x1cbf85aa, 0x20bb05e5, 0x24b68620, 0x28b4ebcf, 0x2c994066, + 0x30835fe6, 0x35722a5e +},{ + 0x00000000, 0x062797a1, 0x0bfe1683, 0x11aeee7a, 0x1765915b, 0x1d166952, + 0x22c17660, 0x284ca76c, 0x2e0bfaaa, 0x3444f306, 0x00000000, 0x00000000, + 0x00000000, 0x00000000 +},{ + 0x00000000, 0x0870a594, 0x1090326a, 0x18a9f456, 0x209b29e3, 0x288c5f70, + 0x30d478a5, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000 +},{ + 0x00000000, 0x0b61afee, 0x16a09e66, 0x21dca76a, 0x2d15caf9, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000 +},{ + 0x00000000, 0x0ef20652, 0x1e94b968, 0x2d100010, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000 +},{ + 0x02000000, 0x12bf2f44, 0x277f041b, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000 +},{ + 0x02d413cd, 0x16385a03, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000 +},{ + 0x08000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000 +}}}; + +static const FIXPU cplscale2[3] = { + /* 2^16 C_ij */ + 0xf3f9, 0xb505, 0x4d8b +}; +static const FIXPU cplscale3[7] = { + /* 2^16 C_ij */ + 0xfb35, 0xefdf, 0xe03d, 0xb505, 0x7b81, 0x596e, 0x314d +}; +static const FIXPU cplscale4[15] = { + /* 2^16 C_ij */ + 0xfdd2, 0xf927, 0xf3f9, 0xee1d, 0xe749, 0xdee9, 0xd381, 0xb505, 0x903b, + 0x7de2, 0x6dbe, 0x5e02, 0x4d8b, 0x3ad1, 0x2155 +}; +static const FIXPU cplscale5[31] = { + /* 2^16 C_ij */ + 0xfef5, 0xfcce, 0xfa8e, 0xf832, 0xf5b5, 0xf314, 0xf049, 0xed4c, 0xea12, + 0xe68e, 0xe2ab, 0xde4b, 0xd938, 0xd30b, 0xcab6, 0xb505, 0x9c59, 0x90e8, + 0x8778, 0x7ef9, 0x76fc, 0x6f45, 0x67ab, 0x600e, 0x5850, 0x504d, 0x47db, + 0x3ebd, 0x3486, 0x2853, 0x1715 +}; +static const FIXPU cplscale6[63] = { + /* 2^16 C_ij */ + 0xff7d, 0xfe74, 0xfd65, 0xfc50, 0xfb35, 0xfa14, 0xf8eb, 0xf7bb, 0xf683, + 0xf543, 0xf3f9, 0xf2a6, 0xf148, 0xefdf, 0xee6a, 0xece6, 0xeb54, 0xe9b2, + 0xe7fd, 0xe634, 0xe453, 0xe258, 0xe03d, 0xddff, 0xdb94, 0xd8f4, 0xd610, + 0xd2d2, 0xcf13, 0xca8c, 0xc47c, 0xb505, 0xa41a, 0x9c90, 0x9685, 0x913a, + 0x8c67, 0x87e5, 0x839c, 0x7f7e, 0x7b81, 0x779b, 0x73c7, 0x6fff, 0x6c3f, + 0x6883, 0x64c7, 0x6107, 0x5d40, 0x596e, 0x558d, 0x5198, 0x4d8b, 0x495f, + 0x450d, 0x408b, 0x3bcd, 0x36c1, 0x314d, 0x2b4a, 0x246e, 0x1c1a, 0x1029 +}; + diff --git a/lib/rbcodec/codecs/libcook/libcook.make b/lib/rbcodec/codecs/libcook/libcook.make new file mode 100644 index 0000000000..c7bdca90c5 --- /dev/null +++ b/lib/rbcodec/codecs/libcook/libcook.make @@ -0,0 +1,18 @@ +# __________ __ ___. +# Open \______ \ ____ ____ | | _\_ |__ _______ ___ +# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / +# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < +# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ +# \/ \/ \/ \/ \/ +# $Id:$ +# + +# libcook +COOKLIB := $(CODECDIR)/libcook.a +COOKLIB_SRC := $(call preprocess, $(RBCODECLIB_DIR)/codecs/libcook/SOURCES) +COOKLIB_OBJ := $(call c2obj, $(COOKLIB_SRC)) +OTHER_SRC += $(COOKLIB_SRC) + +$(COOKLIB): $(COOKLIB_OBJ) + $(SILENT)$(shell rm -f $@) + $(call PRINTS,AR $(@F))$(AR) rcs $@ $^ >/dev/null diff --git a/lib/rbcodec/codecs/libfaad/COPYING b/lib/rbcodec/codecs/libfaad/COPYING new file mode 100644 index 0000000000..920c4e6744 --- /dev/null +++ b/lib/rbcodec/codecs/libfaad/COPYING @@ -0,0 +1,350 @@ + +Any non-GPL usage of this software or parts of this software is strictly +forbidden. + +Commercial non-GPL licensing of this software is possible. +For more info contact Ahead Software through Mpeg4AAClicense@nero.com. + + + + + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) 19yy + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) 19yy name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/lib/rbcodec/codecs/libfaad/README b/lib/rbcodec/codecs/libfaad/README new file mode 100644 index 0000000000..a3a3d5a833 --- /dev/null +++ b/lib/rbcodec/codecs/libfaad/README @@ -0,0 +1,122 @@ + +Freeware Advanced Audio (AAC) Decoder including SBR decoding +http://www.audiocoding.com/ + +FAAD2 is a HE, LC, MAIN and LTP profile, MPEG2 and MPEG-4 AAC decoder. +FAAD2 includes code for SBR (HE AAC) decoding. +FAAD2 is licensed under the GPL. + + +__________ +COPYRIGHTS + +For FAAD2 the following license applies: + +****************************************************************************** +** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding +** Copyright (C) 2003 M. Bakker (mbakker(at)nero.com), Ahead Software AG +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +** +** Commercial non-GPL licensing of this software is also possible. +** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +****************************************************************************** + + +Please note that the use of this software may require the payment of +patent royalties. You need to consider this issue before you start +building derivative works. We are not warranting or indemnifying you in +any way for patent royalities! YOU ARE SOLELY RESPONSIBLE FOR YOUR OWN +ACTIONS! + + +______ +PEOPLE + +FAAD2 is written by: + - M. Bakker (mbakker(at)nero.com). + + +_______________ +VERSION HISTORY + +Sorry, try building a ChangeLog from CVS. + +__________________________________ +REDISTRIBUTED OPEN SOURCE PACKAGES + +This is the list of redistributed open source packages that are included +in FAAD2: + +Name: mp4v2 +Version: 0.9.8.6 +Origin: http://www.mpeg4ip.net +Author: David Mackie +Directory: common/mp4v2 +License: MPL, Mozilla Public License, version 1.1 + +Name: mp4av +Version: 0.9.8.6 +Origin: http://www.mpeg4ip.net +Author: David Mackie +Directory: common/mp4av +License: MPL, Mozilla Public License, version 1.1 + + +___________________ +DIRECTORY STRUCTURE + +faad2 - top level directory. + + aacDECdrop - windows decoder/player with drag'n'drop functionality + + common - generally used libraries and code. + + faad - general common functions like filereading and streaming + as well as getting info from aac files. + + mp4v2 - MPEG-4 file reading library. + + mp4av - MPEG-4 file general function library. + + mp4ff - Small MP4 file format library (includes tagging abilities). + + CoreAAC - AAC DirectShow filter. + + frontend - command line frontend to the FAAD2 library, also supports + MPEG-4 file decoding. + + include - inlude file for the FAAD2 library. + + libfaad - the FAAD2 AAC decoder library including SBR. + + codebook - Huffman codebooks + + plugins - plugins for all kinds of pograms. + + in_mp4 - winamp MPEG-4 AAC file input plugin. + + QCD - Quintessential player AAC plugin. + + QCDMp4 - Quintessential player MP4 plugin. + + winamp - winamp2 AAC input plugin. + + winamp3 - winamp3 AAC input plugin. + + xmms - xmms AAC plugin + + mpeg4ip - plugin for the mpeg4ip player + diff --git a/lib/rbcodec/codecs/libfaad/README.rockbox b/lib/rbcodec/codecs/libfaad/README.rockbox new file mode 100644 index 0000000000..5b70f231ba --- /dev/null +++ b/lib/rbcodec/codecs/libfaad/README.rockbox @@ -0,0 +1,19 @@ +Library: libfaad (FAAD2) +Imported: 2005-10-31 by Dave Chapman + +This directory contains the libfaad library from the FAAD2 project. + +LICENSING INFORMATION + +FAAD2 is licensed under the GNU General Public License and is +Copyright (C) 2003 M. Bakker (mbakker(at)nero.com), Ahead Software AG + +IMPORT DETAILS + +The decoder is based on the CVS version of libfaad from 2 February 2005. + +A non GPL compatible clause was added to the license as part of the +CVS commit on 2 February 2005 - so we are not able to use later +versions of that project in Rockbox. + + diff --git a/lib/rbcodec/codecs/libfaad/SOURCES b/lib/rbcodec/codecs/libfaad/SOURCES new file mode 100644 index 0000000000..8447354fd3 --- /dev/null +++ b/lib/rbcodec/codecs/libfaad/SOURCES @@ -0,0 +1,27 @@ +bits.c +common.c +decoder.c +drc.c +error.c +filtbank.c +huffman.c +is.c +mp4.c +ms.c +pns.c +ps_dec.c +ps_syntax.c +pulse.c +sbr_dct.c +sbr_dec.c +sbr_e_nf.c +sbr_fbt.c +sbr_hfadj.c +sbr_hfgen.c +sbr_huff.c +sbr_qmf.c +sbr_syntax.c +sbr_tf_grid.c +specrec.c +syntax.c +tns.c diff --git a/lib/rbcodec/codecs/libfaad/analysis.h b/lib/rbcodec/codecs/libfaad/analysis.h new file mode 100644 index 0000000000..f1c3da7a8f --- /dev/null +++ b/lib/rbcodec/codecs/libfaad/analysis.h @@ -0,0 +1,49 @@ +/* +** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding +** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +** +** Any non-GPL usage of this software or parts of this software is strictly +** forbidden. +** +** Commercial non-GPL licensing of this software is possible. +** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** +** $Id$ +**/ + +#ifndef __ANALYSIS_H__ +#define __ANALYSIS_H__ + +#ifdef __cplusplus +extern "C" { +#endif + + +#ifdef ANALYSIS +#define DEBUGDEC ,uint8_t print,uint16_t var,uint8_t *dbg +#define DEBUGVAR(A,B,C) ,A,B,C +extern uint16_t dbg_count; +#else +#define DEBUGDEC +#define DEBUGVAR(A,B,C) +#endif + + +#ifdef __cplusplus +} +#endif +#endif diff --git a/lib/rbcodec/codecs/libfaad/bits.c b/lib/rbcodec/codecs/libfaad/bits.c new file mode 100644 index 0000000000..a3640077d8 --- /dev/null +++ b/lib/rbcodec/codecs/libfaad/bits.c @@ -0,0 +1,208 @@ +/* +** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding +** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +** +** Any non-GPL usage of this software or parts of this software is strictly +** forbidden. +** +** Commercial non-GPL licensing of this software is possible. +** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** +** $Id$ +**/ + +#include "common.h" +#include "structs.h" + +#include +#include +#include "bits.h" + +/* Need to be large enough to fit the largest compressed sample in a file. + * Samples were observed to need up to 1500 bytes (400 kbps nero aac). + */ +#define BUFFER_SIZE 2048 +static uint8_t static_buffer[BUFFER_SIZE] IBSS_ATTR; + +/* initialize buffer, call once before first getbits or showbits */ +void faad_initbits(bitfile *ld, const void *_buffer, const uint32_t buffer_size) +{ + uint32_t tmp; + + if (ld == NULL) + return; + + memset(ld, 0, sizeof(bitfile)); + + if (buffer_size == 0 || _buffer == NULL || (buffer_size+12)>BUFFER_SIZE) + { + ld->error = 1; + ld->no_more_reading = 1; + return; + } + + ld->buffer = &static_buffer; + memset(ld->buffer, 0, (buffer_size+12)*sizeof(uint8_t)); + memcpy(ld->buffer, _buffer, buffer_size*sizeof(uint8_t)); + + ld->buffer_size = buffer_size; + + tmp = getdword((uint32_t*)ld->buffer); + ld->bufa = tmp; + + tmp = getdword((uint32_t*)ld->buffer + 1); + ld->bufb = tmp; + + ld->start = (uint32_t*)ld->buffer; + ld->tail = ((uint32_t*)ld->buffer + 2); + + ld->bits_left = 32; + + ld->bytes_used = 0; + ld->no_more_reading = 0; + ld->error = 0; +} + +void faad_endbits(bitfile *ld) +{ +#if 0 + if (ld) + { + if (ld->buffer) + { + faad_free(ld->buffer); + ld->buffer = NULL; + } + } +#else + (void) ld; +#endif +} + +uint32_t faad_get_processed_bits(bitfile *ld) +{ + return (uint32_t)(8 * (4*(ld->tail - ld->start) - 4) - (ld->bits_left)); +} + +uint8_t faad_byte_align(bitfile *ld) +{ + uint8_t remainder = (uint8_t)((32 - ld->bits_left) % 8); + + if (remainder) + { + faad_flushbits(ld, 8 - remainder); + return (8 - remainder); + } + return 0; +} + +/* rewind to beginning */ +/* not used +void faad_rewindbits(bitfile *ld) +{ + uint32_t tmp; + + tmp = ld->start[0]; +#ifndef ARCH_IS_BIG_ENDIAN + tmp = BSWAP(tmp); +#endif + ld->bufa = tmp; + + tmp = ld->start[1]; +#ifndef ARCH_IS_BIG_ENDIAN + tmp = BSWAP(tmp); +#endif + ld->bufb = tmp; + ld->bits_left = 32; + ld->tail = &ld->start[2]; + ld->bytes_used = 0; + ld->no_more_reading = 0; +} +*/ + +#ifdef ERROR_RESILIENCE +uint8_t *faad_getbitbuffer(bitfile *ld, uint32_t bits + DEBUGDEC) +{ + uint16_t i; + uint8_t temp; + uint16_t bytes = (uint16_t)bits / 8; + uint8_t remainder = (uint8_t)bits % 8; + + uint8_t *buffer = (uint8_t*)faad_malloc((bytes+1)*sizeof(uint8_t)); + + for (i = 0; i < bytes; i++) + { + buffer[i] = (uint8_t)faad_getbits(ld, 8 DEBUGVAR(print,var,dbg)); + } + + if (remainder) + { + temp = (uint8_t)faad_getbits(ld, remainder DEBUGVAR(print,var,dbg)) << (8-remainder); + + buffer[bytes] = temp; + } + + return buffer; +} +#endif + +#ifdef DRM +/* return the original data buffer */ +void *faad_origbitbuffer(bitfile *ld) +{ + return (void*)ld->start; +} + +/* return the original data buffer size */ +uint32_t faad_origbitbuffer_size(bitfile *ld) +{ + return ld->buffer_size; +} +#endif + +/* reversed bit reading routines, used for RVLC and HCR */ +/* not used +void faad_initbits_rev(bitfile *ld, void *buffer, + uint32_t bits_in_buffer) +{ + uint32_t tmp; + int32_t index; + + ld->buffer_size = bit2byte(bits_in_buffer); + + index = (bits_in_buffer+31)/32 - 1; + + ld->start = (uint32_t*)buffer + index - 2; + + tmp = getdword((uint32_t*)buffer + index); + ld->bufa = tmp; + + tmp = getdword((uint32_t*)buffer + index - 1); + ld->bufb = tmp; + + ld->tail = (uint32_t*)buffer + index; + + ld->bits_left = bits_in_buffer % 32; + if (ld->bits_left == 0) + ld->bits_left = 32; + + ld->bytes_used = 0; + ld->no_more_reading = 0; + ld->error = 0; +} +*/ diff --git a/lib/rbcodec/codecs/libfaad/bits.h b/lib/rbcodec/codecs/libfaad/bits.h new file mode 100644 index 0000000000..f9417b8670 --- /dev/null +++ b/lib/rbcodec/codecs/libfaad/bits.h @@ -0,0 +1,381 @@ +/* +** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding +** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +** +** Any non-GPL usage of this software or parts of this software is strictly +** forbidden. +** +** Commercial non-GPL licensing of this software is possible. +** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** +** $Id$ +**/ + +#ifndef __BITS_H__ +#define __BITS_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "analysis.h" +#ifdef ANALYSIS +#include +#endif + +#define BYTE_NUMBIT 8 +#define bit2byte(a) ((a+7)/BYTE_NUMBIT) + +typedef struct _bitfile +{ + /* bit input */ + uint32_t bufa; + uint32_t bufb; + uint32_t bits_left; + uint32_t buffer_size; /* size of the buffer in bytes */ + uint32_t bytes_used; + uint8_t no_more_reading; + uint8_t error; + uint32_t *tail; + uint32_t *start; + void *buffer; +} bitfile; + +/* rockbox: use asm optimized swap32() +#define BSWAP(a) \ + ((a) = ( ((a)&0xff)<<24) | (((a)&0xff00)<<8) | (((a)>>8)&0xff00) | (((a)>>24)&0xff)) +*/ +#define BSWAP(a) swap32(a) + +static uint32_t bitmask[] = { + 0x0, 0x1, 0x3, 0x7, 0xF, 0x1F, 0x3F, 0x7F, 0xFF, 0x1FF, + 0x3FF, 0x7FF, 0xFFF, 0x1FFF, 0x3FFF, 0x7FFF, 0xFFFF, + 0x1FFFF, 0x3FFFF, 0x7FFFF, 0xFFFFF, 0x1FFFFF, 0x3FFFFF, + 0x7FFFFF, 0xFFFFFF, 0x1FFFFFF, 0x3FFFFFF, 0x7FFFFFF, + 0xFFFFFFF, 0x1FFFFFFF, 0x3FFFFFFF, 0x7FFFFFFF + /* added bitmask 32, correct?!?!?! */ + , 0xFFFFFFFF +}; + +void faad_initbits(bitfile *ld, const void *buffer, const uint32_t buffer_size); +void faad_endbits(bitfile *ld); +/* not used +void faad_initbits_rev(bitfile *ld, void *buffer, + uint32_t bits_in_buffer); +*/ +uint8_t faad_byte_align(bitfile *ld); +uint32_t faad_get_processed_bits(bitfile *ld); +void faad_rewindbits(bitfile *ld); +uint8_t *faad_getbitbuffer(bitfile *ld, uint32_t bits + DEBUGDEC); +#ifdef DRM +void *faad_origbitbuffer(bitfile *ld); +uint32_t faad_origbitbuffer_size(bitfile *ld); +#endif + +static INLINE uint32_t getdword(void *mem) +{ +#ifndef ARCH_IS_BIG_ENDIAN + return BSWAP(*(uint32_t*)mem); +#else + return *(uint32_t*)mem; +#endif +} + +static INLINE void faad_flushbits_ex(bitfile *ld, uint32_t bits) +{ + uint32_t tmp; + + ld->bufa = ld->bufb; + if (ld->no_more_reading == 0) + { + tmp = getdword(ld->tail); + ld->tail++; + } else { + tmp = 0; + } + ld->bufb = tmp; + ld->bits_left += (32 - bits); + ld->bytes_used += 4; + if (ld->bytes_used == ld->buffer_size) + ld->no_more_reading = 1; + if (ld->bytes_used > ld->buffer_size) + ld->error = 1; +} + +static INLINE uint32_t faad_showbits(bitfile *ld, uint32_t bits) +{ + if (bits <= ld->bits_left) + { + return (ld->bufa >> (ld->bits_left - bits)) & bitmask[bits]; + } + + bits -= ld->bits_left; + return ((ld->bufa & bitmask[ld->bits_left]) << bits) | (ld->bufb >> (32 - bits)); +} + +static INLINE void faad_flushbits(bitfile *ld, uint32_t bits) +{ + /* do nothing if error */ + if (ld->error != 0) + return; + + if (bits < ld->bits_left) + { + ld->bits_left -= bits; + } else { + faad_flushbits_ex(ld, bits); + } +} + +/* return next n bits (right adjusted) */ +static uint32_t faad_getbits(bitfile *ld, uint32_t n DEBUGDEC) +{ + uint32_t ret; + + if (ld->no_more_reading || n == 0) + return 0; + + ret = faad_showbits(ld, n); + faad_flushbits(ld, n); + +#ifdef ANALYSIS + if (print) + fprintf(stdout, "%4d %2d bits, val: %4d, variable: %d %s\n", dbg_count++, n, ret, var, dbg); +#endif + + return ret; +} + +static INLINE uint8_t faad_get1bit(bitfile *ld DEBUGDEC) +{ + uint8_t r; + + if (ld->bits_left > 0) + { + ld->bits_left--; + r = (uint8_t)((ld->bufa >> ld->bits_left) & 1); + return r; + } + + /* bits_left == 0 */ +#if 0 + r = (uint8_t)(ld->bufb >> 31); + faad_flushbits_ex(ld, 1); +#else + r = (uint8_t)faad_getbits(ld, 1); +#endif + return r; +} + +/* reversed bitreading routines */ +static INLINE uint32_t faad_showbits_rev(bitfile *ld, uint32_t bits) +{ + uint8_t i; + uint32_t B = 0; + + if (bits <= ld->bits_left) + { + for (i = 0; i < bits; i++) + { + if (ld->bufa & (1 << (i + (32 - ld->bits_left)))) + B |= (1 << (bits - i - 1)); + } + return B; + } else { + for (i = 0; i < ld->bits_left; i++) + { + if (ld->bufa & (1 << (i + (32 - ld->bits_left)))) + B |= (1 << (bits - i - 1)); + } + for (i = 0; i < bits - ld->bits_left; i++) + { + if (ld->bufb & (1 << (i + (32-ld->bits_left)))) + B |= (1 << (bits - ld->bits_left - i - 1)); + } + return B; + } +} + +static INLINE void faad_flushbits_rev(bitfile *ld, uint32_t bits) +{ + /* do nothing if error */ + if (ld->error != 0) + return; + + if (bits < ld->bits_left) + { + ld->bits_left -= bits; + } else { + uint32_t tmp; + + ld->bufa = ld->bufb; + tmp = getdword(ld->start); + ld->bufb = tmp; + ld->start--; + ld->bits_left += (32 - bits); + + ld->bytes_used += 4; + if (ld->bytes_used == ld->buffer_size) + ld->no_more_reading = 1; + if (ld->bytes_used > ld->buffer_size) + ld->error = 1; + } +} + +static INLINE uint32_t faad_getbits_rev(bitfile *ld, uint32_t n + DEBUGDEC) +{ + uint32_t ret; + + if (ld->no_more_reading) + return 0; + + if (n == 0) + return 0; + + ret = faad_showbits_rev(ld, n); + faad_flushbits_rev(ld, n); + +#ifdef ANALYSIS + if (print) + fprintf(stdout, "%4d %2d bits, val: %4d, variable: %d %s\n", dbg_count++, n, ret, var, dbg); +#endif + + return ret; +} + +#ifdef DRM +static uint8_t faad_check_CRC(bitfile *ld, uint16_t len) +{ + uint8_t CRC; + uint16_t r=255; /* Initialize to all ones */ + + /* CRC polynome used x^8 + x^4 + x^3 + x^2 +1 */ +#define GPOLY 0435 + + faad_rewindbits(ld); + + CRC = (uint8_t) ~faad_getbits(ld, 8 + DEBUGVAR(1,999,"faad_check_CRC(): CRC")); /* CRC is stored inverted */ + + for (; len>0; len--) + { + r = ( (r << 1) ^ (( ( faad_get1bit(ld + DEBUGVAR(1,998,"")) & 1) ^ ((r >> 7) & 1)) * GPOLY )) & 0xFF; + } + + if (r != CRC) + { + return 8; + } else { + return 0; + } +} + +static uint8_t tabFlipbits[256] = { + 0,128,64,192,32,160,96,224,16,144,80,208,48,176,112,240, + 8,136,72,200,40,168,104,232,24,152,88,216,56,184,120,248, + 4,132,68,196,36,164,100,228,20,148,84,212,52,180,116,244, + 12,140,76,204,44,172,108,236,28,156,92,220,60,188,124,252, + 2,130,66,194,34,162,98,226,18,146,82,210,50,178,114,242, + 10,138,74,202,42,170,106,234,26,154,90,218,58,186,122,250, + 6,134,70,198,38,166,102,230,22,150,86,214,54,182,118,246, + 14,142,78,206,46,174,110,238,30,158,94,222,62,190,126,254, + 1,129,65,193,33,161,97,225,17,145,81,209,49,177,113,241, + 9,137,73,201,41,169,105,233,25,153,89,217,57,185,121,249, + 5,133,69,197,37,165,101,229,21,149,85,213,53,181,117,245, + 13,141,77,205,45,173,109,237,29,157,93,221,61,189,125,253, + 3,131,67,195,35,163,99,227,19,147,83,211,51,179,115,243, + 11,139,75,203,43,171,107,235,27,155,91,219,59,187,123,251, + 7,135,71,199,39,167,103,231,23,151,87,215,55,183,119,247, + 15,143,79,207,47,175,111,239,31,159,95,223,63,191,127,255 +}; +#endif + +#ifdef ERROR_RESILIENCE + +/* Modified bit reading functions for HCR */ + +typedef struct +{ + /* bit input */ + uint32_t bufa; + uint32_t bufb; + int8_t len; +} bits_t; + + +static INLINE uint32_t showbits_hcr(bits_t *ld, uint8_t bits) +{ + if (bits == 0) return 0; + if (ld->len <= 32) + { + /* huffman_spectral_data_2 needs to read more than may be available, bits maybe + > ld->len, deliver 0 than */ + if (ld->len >= bits) + return ((ld->bufa >> (ld->len - bits)) & (0xFFFFFFFF >> (32 - bits))); + else + return ((ld->bufa << (bits - ld->len)) & (0xFFFFFFFF >> (32 - bits))); + } else { + if ((ld->len - bits) < 32) + { + return ( (ld->bufb & (0xFFFFFFFF >> (64 - ld->len))) << (bits - ld->len + 32)) | + (ld->bufa >> (ld->len - bits)); + } else { + return ((ld->bufb >> (ld->len - bits - 32)) & (0xFFFFFFFF >> (32 - bits))); + } + } +} + +/* return 1 if position is outside of buffer, 0 otherwise */ +static INLINE int8_t flushbits_hcr( bits_t *ld, uint8_t bits) +{ + ld->len -= bits; + + if (ld->len <0) + { + ld->len = 0; + return 1; + } else { + return 0; + } +} + +static INLINE int8_t getbits_hcr(bits_t *ld, uint8_t n, uint32_t *result) +{ + *result = showbits_hcr(ld, n); + return flushbits_hcr(ld, n); +} + +static INLINE int8_t get1bit_hcr(bits_t *ld, uint8_t *result) +{ + uint32_t res; + int8_t ret; + + ret = getbits_hcr(ld, 1, &res); + *result = (int8_t)(res & 1); + return ret; +} + +#endif + + +#ifdef __cplusplus +} +#endif +#endif diff --git a/lib/rbcodec/codecs/libfaad/codebook/hcb.h b/lib/rbcodec/codecs/libfaad/codebook/hcb.h new file mode 100644 index 0000000000..eaefdbf437 --- /dev/null +++ b/lib/rbcodec/codecs/libfaad/codebook/hcb.h @@ -0,0 +1,142 @@ +/* +** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding +** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +** +** Any non-GPL usage of this software or parts of this software is strictly +** forbidden. +** +** Commercial non-GPL licensing of this software is possible. +** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** +** $Id$ +**/ + +#ifndef __HCB_H__ +#define __HCB_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Optimal huffman decoding for AAC taken from: + * "SELECTING AN OPTIMAL HUFFMAN DECODER FOR AAC" by + * VLADIMIR Z. MESAROVIC , RAGHUNATH RAO, MIROSLAV V. DOKIC, and SACHIN DEO + * AES paper 5436 + * + * 2 methods are used for huffman decoding: + * - binary search + * - 2-step table lookup + * + * The choice of the "optimal" method is based on the fact that if the + * memory size for the Two-step is exorbitantly high then the decision + * is Binary search for that codebook. However, for marginally more memory + * size, if Twostep outperforms even the best case of Binary then the + * decision is Two-step for that codebook. + * + * The following methods are used for the different tables. + * codebook "optimal" method + * HCB_1 2-Step + * HCB_2 2-Step + * HCB_3 Binary + * HCB_4 2-Step + * HCB_5 Binary + * HCB_6 2-Step + * HCB_7 Binary + * HCB_8 2-Step + * HCB_9 Binary + * HCB_10 2-Step + * HCB_11 2-Step + * HCB_SF Binary + * + */ + + +#define ZERO_HCB 0 +#define FIRST_PAIR_HCB 5 +#define ESC_HCB 11 +#define QUAD_LEN 4 +#define PAIR_LEN 2 +#define NOISE_HCB 13 +#define INTENSITY_HCB2 14 +#define INTENSITY_HCB 15 + +/* 1st step table */ +typedef struct +{ + uint8_t offset; + uint8_t extra_bits; +} hcb; + +/* 2nd step table with quadruple data */ +typedef struct +{ + uint8_t bits; + int8_t x; + int8_t y; +} hcb_2_pair; + +typedef struct +{ + uint8_t bits; + int8_t x; + int8_t y; + int8_t v; + int8_t w; +} hcb_2_quad; + +/* binary search table */ +typedef struct +{ + uint8_t is_leaf; + int8_t data[4]; +} hcb_bin_quad; + +typedef struct +{ + uint8_t is_leaf; + int8_t data[2]; +} hcb_bin_pair; + +hcb *hcb_table[]; +hcb_2_quad *hcb_2_quad_table[]; +hcb_2_pair *hcb_2_pair_table[]; +hcb_bin_pair *hcb_bin_table[]; +uint8_t hcbN[]; +uint8_t unsigned_cb[]; +int hcb_2_quad_table_size[]; +int hcb_2_pair_table_size[]; +int hcb_bin_table_size[]; + +#include "codebook/hcb_1.h" +#include "codebook/hcb_2.h" +#include "codebook/hcb_3.h" +#include "codebook/hcb_4.h" +#include "codebook/hcb_5.h" +#include "codebook/hcb_6.h" +#include "codebook/hcb_7.h" +#include "codebook/hcb_8.h" +#include "codebook/hcb_9.h" +#include "codebook/hcb_10.h" +#include "codebook/hcb_11.h" +#include "codebook/hcb_sf.h" + + +#ifdef __cplusplus +} +#endif +#endif diff --git a/lib/rbcodec/codecs/libfaad/codebook/hcb_1.h b/lib/rbcodec/codecs/libfaad/codebook/hcb_1.h new file mode 100644 index 0000000000..88c04b6012 --- /dev/null +++ b/lib/rbcodec/codecs/libfaad/codebook/hcb_1.h @@ -0,0 +1,183 @@ +/* +** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding +** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +** +** Any non-GPL usage of this software or parts of this software is strictly +** forbidden. +** +** Commercial non-GPL licensing of this software is possible. +** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** +** $Id$ +**/ + +/* 2-step huffman table HCB_1 */ + + +/* 1st step: 5 bits + * 2^5 = 32 entries + * + * Used to find offset into 2nd step table and number of extra bits to get + */ +static hcb hcb1_1[] ICONST_ATTR_FAAD_LARGE_IRAM = { + { /* 00000 */ 0, 0 }, + { /* */ 0, 0 }, + { /* */ 0, 0 }, + { /* */ 0, 0 }, + { /* */ 0, 0 }, + { /* */ 0, 0 }, + { /* */ 0, 0 }, + { /* */ 0, 0 }, + { /* */ 0, 0 }, + { /* */ 0, 0 }, + { /* */ 0, 0 }, + { /* */ 0, 0 }, + { /* */ 0, 0 }, + { /* */ 0, 0 }, + { /* */ 0, 0 }, + { /* */ 0, 0 }, + { /* 10000 */ 1, 0 }, + { /* 10001 */ 2, 0 }, + { /* 10010 */ 3, 0 }, + { /* 10011 */ 4, 0 }, + { /* 10100 */ 5, 0 }, + { /* 10101 */ 6, 0 }, + { /* 10110 */ 7, 0 }, + { /* 10111 */ 8, 0 }, + + /* 7 bit codewords */ + { /* 11000 */ 9, 2 }, + { /* 11001 */ 13, 2 }, + { /* 11010 */ 17, 2 }, + { /* 11011 */ 21, 2 }, + { /* 11100 */ 25, 2 }, + { /* 11101 */ 29, 2 }, + + /* 9 bit codewords */ + { /* 11110 */ 33, 4 }, + + /* 9/10/11 bit codewords */ + { /* 11111 */ 49, 6 } +}; + +/* 2nd step table + * + * Gives size of codeword and actual data (x,y,v,w) + */ +static hcb_2_quad hcb1_2[] ICONST_ATTR_FAAD_LARGE_IRAM = { + /* 1 bit codeword */ + { 1, 0, 0, 0, 0 }, + + /* 5 bit codewords */ + { 5, 1, 0, 0, 0 }, + { 5, -1, 0, 0, 0 }, + { 5, 0, 0, 0, -1 }, + { 5, 0, 1, 0, 0 }, + { 5, 0, 0, 0, 1 }, + { 5, 0, 0, -1, 0 }, + { 5, 0, 0, 1, 0 }, + { 5, 0, -1, 0, 0 }, + + /* 7 bit codewords */ + /* first 5 bits: 11000 */ + { 7, 1, -1, 0, 0 }, + { 7, -1, 1, 0, 0 }, + { 7, 0, 0, -1, 1 }, + { 7, 0, 1, -1, 0 }, + /* first 5 bits: 11001 */ + { 7, 0, -1, 1, 0 }, + { 7, 0, 0, 1, -1 }, + { 7, 1, 1, 0, 0 }, + { 7, 0, 0, -1, -1 }, + /* first 5 bits: 11010 */ + { 7, -1, -1, 0, 0 }, + { 7, 0, -1, -1, 0 }, + { 7, 1, 0, -1, 0 }, + { 7, 0, 1, 0, -1 }, + /* first 5 bits: 11011 */ + { 7, -1, 0, 1, 0 }, + { 7, 0, 0, 1, 1 }, + { 7, 1, 0, 1, 0 }, + { 7, 0, -1, 0, 1 }, + /* first 5 bits: 11100 */ + { 7, 0, 1, 1, 0 }, + { 7, 0, 1, 0, 1 }, + { 7, -1, 0, -1, 0 }, + { 7, 1, 0, 0, 1 }, + /* first 5 bits: 11101 */ + { 7, -1, 0, 0, -1 }, + { 7, 1, 0, 0, -1 }, + { 7, -1, 0, 0, 1 }, + { 7, 0, -1, 0, -1 }, + + /* 9 bit codeword */ + /* first 5 bits: 11110 */ + { 9, 1, 1, -1, 0 }, + { 9, -1, 1, -1, 0 }, + { 9, 1, -1, 1, 0 }, + { 9, 0, 1, 1, -1 }, + { 9, 0, 1, -1, 1 }, + { 9, 0, -1, 1, 1 }, + { 9, 0, -1, 1, -1 }, + { 9, 1, -1, -1, 0 }, + { 9, 1, 0, -1, 1 }, + { 9, 0, 1, -1, -1 }, + { 9, -1, 1, 1, 0 }, + { 9, -1, 0, 1, -1 }, + { 9, -1, -1, 1, 0 }, + { 9, 0, -1, -1, 1 }, + { 9, 1, -1, 0, 1 }, + { 9, 1, -1, 0, -1 }, + + /* 9/10/11 bit codewords */ + /* first 5 bits: 11111 */ + /* 9 bit: reading 11 bits -> 2 too much so 4 entries for each codeword */ + { 9, -1, 1, 0, -1 }, { 9, -1, 1, 0, -1 }, { 9, -1, 1, 0, -1 }, { 9, -1, 1, 0, -1 }, + { 9, -1, -1, -1, 0 }, { 9, -1, -1, -1, 0 }, { 9, -1, -1, -1, 0 }, { 9, -1, -1, -1, 0 }, + { 9, 0, -1, -1, -1 }, { 9, 0, -1, -1, -1 }, { 9, 0, -1, -1, -1 }, { 9, 0, -1, -1, -1 }, + { 9, 0, 1, 1, 1 }, { 9, 0, 1, 1, 1 }, { 9, 0, 1, 1, 1 }, { 9, 0, 1, 1, 1 }, + { 9, 1, 0, 1, -1 }, { 9, 1, 0, 1, -1 }, { 9, 1, 0, 1, -1 }, { 9, 1, 0, 1, -1 }, + { 9, 1, 1, 0, 1 }, { 9, 1, 1, 0, 1 }, { 9, 1, 1, 0, 1 }, { 9, 1, 1, 0, 1 }, + { 9, -1, 1, 0, 1 }, { 9, -1, 1, 0, 1 }, { 9, -1, 1, 0, 1 }, { 9, -1, 1, 0, 1 }, + { 9, 1, 1, 1, 0 }, { 9, 1, 1, 1, 0 }, { 9, 1, 1, 1, 0 }, { 9, 1, 1, 1, 0 }, + /* 10 bit: reading 11 bits -> 1 too much so 2 entries for each codeword */ + { 10, -1, -1, 0, 1 }, { 10, -1, -1, 0, 1 }, + { 10, -1, 0, -1, -1 }, { 10, -1, 0, -1, -1 }, + { 10, 1, 1, 0, -1 }, { 10, 1, 1, 0, -1 }, + { 10, 1, 0, -1, -1 }, { 10, 1, 0, -1, -1 }, + { 10, -1, 0, -1, 1 }, { 10, -1, 0, -1, 1 }, + { 10, -1, -1, 0, -1 }, { 10, -1, -1, 0, -1 }, + { 10, -1, 0, 1, 1 }, { 10, -1, 0, 1, 1 }, + { 10, 1, 0, 1, 1 }, { 10, 1, 0, 1, 1 }, + /* 11 bit */ + { 11, 1, -1, 1, -1 }, + { 11, -1, 1, -1, 1 }, + { 11, -1, 1, 1, -1 }, + { 11, 1, -1, -1, 1 }, + { 11, 1, 1, 1, 1 }, + { 11, -1, -1, 1, 1 }, + { 11, 1, 1, -1, -1 }, + { 11, -1, -1, 1, -1 }, + { 11, -1, -1, -1, -1 }, + { 11, 1, 1, -1, 1 }, + { 11, 1, -1, 1, 1 }, + { 11, -1, 1, 1, 1 }, + { 11, -1, 1, -1, -1 }, + { 11, -1, -1, -1, 1 }, + { 11, 1, -1, -1, -1 }, + { 11, 1, 1, 1, -1 } +}; diff --git a/lib/rbcodec/codecs/libfaad/codebook/hcb_10.h b/lib/rbcodec/codecs/libfaad/codebook/hcb_10.h new file mode 100644 index 0000000000..af48711460 --- /dev/null +++ b/lib/rbcodec/codecs/libfaad/codebook/hcb_10.h @@ -0,0 +1,309 @@ +/* +** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding +** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +** +** Any non-GPL usage of this software or parts of this software is strictly +** forbidden. +** +** Commercial non-GPL licensing of this software is possible. +** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** +** $Id$ +**/ + +/* 2-step huffman table HCB_10 */ + + +/* 1st step: 6 bits + * 2^6 = 64 entries + * + * Used to find offset into 2nd step table and number of extra bits to get + */ +static hcb hcb10_1[] ICONST_ATTR_FAAD_LARGE_IRAM = { + /* 4 bit codewords */ + { /* 000000 */ 0, 0 }, + { /* */ 0, 0 }, + { /* */ 0, 0 }, + { /* */ 0, 0 }, + { /* 000100 */ 1, 0 }, + { /* */ 1, 0 }, + { /* */ 1, 0 }, + { /* */ 1, 0 }, + { /* 001000 */ 2, 0 }, + { /* */ 2, 0 }, + { /* */ 2, 0 }, + { /* */ 2, 0 }, + /* 5 bit codewords */ + { /* 001100 */ 3, 0 }, + { /* */ 3, 0 }, + { /* 001110 */ 4, 0 }, + { /* */ 4, 0 }, + { /* 010000 */ 5, 0 }, + { /* */ 5, 0 }, + { /* 010010 */ 6, 0 }, + { /* */ 6, 0 }, + { /* 010100 */ 7, 0 }, + { /* */ 7, 0 }, + { /* 010110 */ 8, 0 }, + { /* */ 8, 0 }, + { /* 011000 */ 9, 0 }, + { /* */ 9, 0 }, + { /* 011010 */ 10, 0 }, + { /* */ 10, 0 }, + /* 6 bit codewords */ + { /* 011100 */ 11, 0 }, + { /* 011101 */ 12, 0 }, + { /* 011110 */ 13, 0 }, + { /* 011111 */ 14, 0 }, + { /* 100000 */ 15, 0 }, + { /* 100001 */ 16, 0 }, + { /* 100010 */ 17, 0 }, + { /* 100011 */ 18, 0 }, + { /* 100100 */ 19, 0 }, + { /* 100101 */ 20, 0 }, + { /* 100110 */ 21, 0 }, + { /* 100111 */ 22, 0 }, + { /* 101000 */ 23, 0 }, + { /* 101001 */ 24, 0 }, + /* 7 bit codewords */ + { /* 101010 */ 25, 1 }, + { /* 101011 */ 27, 1 }, + { /* 101100 */ 29, 1 }, + { /* 101101 */ 31, 1 }, + { /* 101110 */ 33, 1 }, + { /* 101111 */ 35, 1 }, + { /* 110000 */ 37, 1 }, + { /* 110001 */ 39, 1 }, + /* 7/8 bit codewords */ + { /* 110010 */ 41, 2 }, + /* 8 bit codewords */ + { /* 110011 */ 45, 2 }, + { /* 110100 */ 49, 2 }, + { /* 110101 */ 53, 2 }, + { /* 110110 */ 57, 2 }, + { /* 110111 */ 61, 2 }, + /* 8/9 bit codewords */ + { /* 111000 */ 65, 3 }, + /* 9 bit codewords */ + { /* 111001 */ 73, 3 }, + { /* 111010 */ 81, 3 }, + { /* 111011 */ 89, 3 }, + /* 9/10 bit codewords */ + { /* 111100 */ 97, 4 }, + /* 10 bit codewords */ + { /* 111101 */ 113, 4 }, + { /* 111110 */ 129, 4 }, + /* 10/11/12 bit codewords */ + { /* 111111 */ 145, 6 } +}; + +/* 2nd step table + * + * Gives size of codeword and actual data (x,y,v,w) + */ +static hcb_2_pair hcb10_2[] ICONST_ATTR_FAAD_LARGE_IRAM = { + /* 4 bit codewords */ + { 4, 1, 1 }, + { 4, 1, 2 }, + { 4, 2, 1 }, + + /* 5 bit codewords */ + { 5, 2, 2 }, + { 5, 1, 0 }, + { 5, 0, 1 }, + { 5, 1, 3 }, + { 5, 3, 2 }, + { 5, 3, 1 }, + { 5, 2, 3 }, + { 5, 3, 3 }, + + /* 6 bit codewords */ + { 6, 2, 0 }, + { 6, 0, 2 }, + { 6, 2, 4 }, + { 6, 4, 2 }, + { 6, 1, 4 }, + { 6, 4, 1 }, + { 6, 0, 0 }, + { 6, 4, 3 }, + { 6, 3, 4 }, + { 6, 3, 0 }, + { 6, 0, 3 }, + { 6, 4, 4 }, + { 6, 2, 5 }, + { 6, 5, 2 }, + + /* 7 bit codewords */ + { 7, 1, 5 }, + { 7, 5, 1 }, + { 7, 5, 3 }, + { 7, 3, 5 }, + { 7, 5, 4 }, + { 7, 4, 5 }, + { 7, 6, 2 }, + { 7, 2, 6 }, + { 7, 6, 3 }, + { 7, 4, 0 }, + { 7, 6, 1 }, + { 7, 0, 4 }, + { 7, 1, 6 }, + { 7, 3, 6 }, + { 7, 5, 5 }, + { 7, 6, 4 }, + + /* 7/8 bit codewords */ + { 7, 4, 6 }, { 7, 4, 6 }, + { 8, 6, 5 }, + { 8, 7, 2 }, + + /* 8 bit codewords */ + { 8, 3, 7 }, + { 8, 2, 7 }, + { 8, 5, 6 }, + { 8, 8, 2 }, + { 8, 7, 3 }, + { 8, 5, 0 }, + { 8, 7, 1 }, + { 8, 0, 5 }, + { 8, 8, 1 }, + { 8, 1, 7 }, + { 8, 8, 3 }, + { 8, 7, 4 }, + { 8, 4, 7 }, + { 8, 2, 8 }, + { 8, 6, 6 }, + { 8, 7, 5 }, + { 8, 1, 8 }, + { 8, 3, 8 }, + { 8, 8, 4 }, + { 8, 4, 8 }, + + /* 8/9 bit codewords */ + { 8, 5, 7 }, { 8, 5, 7 }, + { 8, 8, 5 }, { 8, 8, 5 }, + { 8, 5, 8 }, { 8, 5, 8 }, + { 9, 7, 6 }, + { 9, 6, 7 }, + + /* 9 bit codewords */ + { 9, 9, 2 }, + { 9, 6, 0 }, + { 9, 6, 8 }, + { 9, 9, 3 }, + { 9, 3, 9 }, + { 9, 9, 1 }, + { 9, 2, 9 }, + { 9, 0, 6 }, + { 9, 8, 6 }, + { 9, 9, 4 }, + { 9, 4, 9 }, + { 9, 10, 2 }, + { 9, 1, 9 }, + { 9, 7, 7 }, + { 9, 8, 7 }, + { 9, 9, 5 }, + { 9, 7, 8 }, + { 9, 10, 3 }, + { 9, 5, 9 }, + { 9, 10, 4 }, + { 9, 2, 10 }, + { 9, 10, 1 }, + { 9, 3, 10 }, + { 9, 9, 6 }, + + /* 9/10 bit codewords */ + { 9, 6, 9 }, { 9, 6, 9 }, + { 9, 8, 0 }, { 9, 8, 0 }, + { 9, 4, 10 }, { 9, 4, 10 }, + { 9, 7, 0 }, { 9, 7, 0 }, + { 9, 11, 2 }, { 9, 11, 2 }, + { 10, 7, 9 }, + { 10, 11, 3 }, + { 10, 10, 6 }, + { 10, 1, 10 }, + { 10, 11, 1 }, + { 10, 9, 7 }, + + /* 10 bit codewords */ + { 10, 0, 7 }, + { 10, 8, 8 }, + { 10, 10, 5 }, + { 10, 3, 11 }, + { 10, 5, 10 }, + { 10, 8, 9 }, + { 10, 11, 5 }, + { 10, 0, 8 }, + { 10, 11, 4 }, + { 10, 2, 11 }, + { 10, 7, 10 }, + { 10, 6, 10 }, + { 10, 10, 7 }, + { 10, 4, 11 }, + { 10, 1, 11 }, + { 10, 12, 2 }, + { 10, 9, 8 }, + { 10, 12, 3 }, + { 10, 11, 6 }, + { 10, 5, 11 }, + { 10, 12, 4 }, + { 10, 11, 7 }, + { 10, 12, 5 }, + { 10, 3, 12 }, + { 10, 6, 11 }, + { 10, 9, 0 }, + { 10, 10, 8 }, + { 10, 10, 0 }, + { 10, 12, 1 }, + { 10, 0, 9 }, + { 10, 4, 12 }, + { 10, 9, 9 }, + + /* 10/11/12 bit codewords */ + { 10, 12, 6 }, { 10, 12, 6 }, { 10, 12, 6 }, { 10, 12, 6 }, + { 10, 2, 12 }, { 10, 2, 12 }, { 10, 2, 12 }, { 10, 2, 12 }, + { 10, 8, 10 }, { 10, 8, 10 }, { 10, 8, 10 }, { 10, 8, 10 }, + { 11, 9, 10 }, { 11, 9, 10 }, + { 11, 1, 12 }, { 11, 1, 12 }, + { 11, 11, 8 }, { 11, 11, 8 }, + { 11, 12, 7 }, { 11, 12, 7 }, + { 11, 7, 11 }, { 11, 7, 11 }, + { 11, 5, 12 }, { 11, 5, 12 }, + { 11, 6, 12 }, { 11, 6, 12 }, + { 11, 10, 9 }, { 11, 10, 9 }, + { 11, 8, 11 }, { 11, 8, 11 }, + { 11, 12, 8 }, { 11, 12, 8 }, + { 11, 0, 10 }, { 11, 0, 10 }, + { 11, 7, 12 }, { 11, 7, 12 }, + { 11, 11, 0 }, { 11, 11, 0 }, + { 11, 10, 10 }, { 11, 10, 10 }, + { 11, 11, 9 }, { 11, 11, 9 }, + { 11, 11, 10 }, { 11, 11, 10 }, + { 11, 0, 11 }, { 11, 0, 11 }, + { 11, 11, 11 }, { 11, 11, 11 }, + { 11, 9, 11 }, { 11, 9, 11 }, + { 11, 10, 11 }, { 11, 10, 11 }, + { 11, 12, 0 }, { 11, 12, 0 }, + { 11, 8, 12 }, { 11, 8, 12 }, + { 12, 12, 9 }, + { 12, 10, 12 }, + { 12, 9, 12 }, + { 12, 11, 12 }, + { 12, 12, 11 }, + { 12, 0, 12 }, + { 12, 12, 10 }, + { 12, 12, 12 } +}; diff --git a/lib/rbcodec/codecs/libfaad/codebook/hcb_11.h b/lib/rbcodec/codecs/libfaad/codebook/hcb_11.h new file mode 100644 index 0000000000..49e97af23f --- /dev/null +++ b/lib/rbcodec/codecs/libfaad/codebook/hcb_11.h @@ -0,0 +1,412 @@ +/* +** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding +** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +** +** Any non-GPL usage of this software or parts of this software is strictly +** forbidden. +** +** Commercial non-GPL licensing of this software is possible. +** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** +** $Id$ +**/ + +/* 2-step huffman table HCB_11 */ + + +/* 1st step: 5 bits + * 2^5 = 32 entries + * + * Used to find offset into 2nd step table and number of extra bits to get + */ +static hcb hcb11_1[] ICONST_ATTR_FAAD_LARGE_IRAM = { + /* 4 bits */ + { /* 00000 */ 0, 0 }, + { /* */ 0, 0 }, + { /* 00010 */ 1, 0 }, + { /* */ 1, 0 }, + + /* 5 bits */ + { /* 00100 */ 2, 0 }, + { /* 00101 */ 3, 0 }, + { /* 00110 */ 4, 0 }, + { /* 00111 */ 5, 0 }, + { /* 01000 */ 6, 0 }, + { /* 01001 */ 7, 0 }, + + /* 6 bits */ + { /* 01010 */ 8, 1 }, + { /* 01011 */ 10, 1 }, + { /* 01100 */ 12, 1 }, + + /* 6/7 bits */ + { /* 01101 */ 14, 2 }, + + /* 7 bits */ + { /* 01110 */ 18, 2 }, + { /* 01111 */ 22, 2 }, + { /* 10000 */ 26, 2 }, + + /* 7/8 bits */ + { /* 10001 */ 30, 3 }, + + /* 8 bits */ + { /* 10010 */ 38, 3 }, + { /* 10011 */ 46, 3 }, + { /* 10100 */ 54, 3 }, + { /* 10101 */ 62, 3 }, + { /* 10110 */ 70, 3 }, + { /* 10111 */ 78, 3 }, + + /* 8/9 bits */ + { /* 11000 */ 86, 4 }, + + /* 9 bits */ + { /* 11001 */ 102, 4 }, + { /* 11010 */ 118, 4 }, + { /* 11011 */ 134, 4 }, + + /* 9/10 bits */ + { /* 11100 */ 150, 5 }, + + /* 10 bits */ + { /* 11101 */ 182, 5 }, + { /* 11110 */ 214, 5 }, + + /* 10/11/12 bits */ + { /* 11111 */ 246, 7 } +}; + +/* 2nd step table + * + * Gives size of codeword and actual data (x,y,v,w) + */ +static hcb_2_pair hcb11_2[] ICONST_ATTR_FAAD_LARGE_IRAM = { + /* 4 */ + { 4, 0, 0 }, + { 4, 1, 1 }, + + /* 5 */ + { 5, 16, 16 }, + { 5, 1, 0 }, + { 5, 0, 1 }, + { 5, 2, 1 }, + { 5, 1, 2 }, + { 5, 2, 2 }, + + /* 6 */ + { 6, 1, 3 }, + { 6, 3, 1 }, + { 6, 3, 2 }, + { 6, 2, 0 }, + { 6, 2, 3 }, + { 6, 0, 2 }, + + /* 6/7 */ + { 6, 3, 3 }, { 6, 3, 3 }, + { 7, 4, 1 }, + { 7, 1, 4 }, + + /* 7 */ + { 7, 4, 2 }, + { 7, 2, 4 }, + { 7, 4, 3 }, + { 7, 3, 4 }, + { 7, 3, 0 }, + { 7, 0, 3 }, + { 7, 5, 1 }, + { 7, 5, 2 }, + { 7, 2, 5 }, + { 7, 4, 4 }, + { 7, 1, 5 }, + { 7, 5, 3 }, + + /* 7/8 */ + { 7, 3, 5 }, { 7, 3, 5 }, + { 7, 5, 4 }, { 7, 5, 4 }, + { 8, 4, 5 }, + { 8, 6, 2 }, + { 8, 2, 6 }, + { 8, 6, 1 }, + + /* 8 */ + { 8, 6, 3 }, + { 8, 3, 6 }, + { 8, 1, 6 }, + { 8, 4, 16 }, + { 8, 3, 16 }, + { 8, 16, 5 }, + { 8, 16, 3 }, + { 8, 16, 4 }, + { 8, 6, 4 }, + { 8, 16, 6 }, + { 8, 4, 0 }, + { 8, 4, 6 }, + { 8, 0, 4 }, + { 8, 2, 16 }, + { 8, 5, 5 }, + { 8, 5, 16 }, + { 8, 16, 7 }, + { 8, 16, 2 }, + { 8, 16, 8 }, + { 8, 2, 7 }, + { 8, 7, 2 }, + { 8, 3, 7 }, + { 8, 6, 5 }, + { 8, 5, 6 }, + { 8, 6, 16 }, + { 8, 16, 10 }, + { 8, 7, 3 }, + { 8, 7, 1 }, + { 8, 16, 9 }, + { 8, 7, 16 }, + { 8, 1, 16 }, + { 8, 1, 7 }, + { 8, 4, 7 }, + { 8, 16, 11 }, + { 8, 7, 4 }, + { 8, 16, 12 }, + { 8, 8, 16 }, + { 8, 16, 1 }, + { 8, 6, 6 }, + { 8, 9, 16 }, + { 8, 2, 8 }, + { 8, 5, 7 }, + { 8, 10, 16 }, + { 8, 16, 13 }, + { 8, 8, 3 }, + { 8, 8, 2 }, + { 8, 3, 8 }, + { 8, 5, 0 }, + + /* 8/9 */ + { 8, 16, 14 }, { 8, 16, 14 }, + { 8, 11, 16 }, { 8, 11, 16 }, + { 8, 7, 5 }, { 8, 7, 5 }, + { 8, 4, 8 }, { 8, 4, 8 }, + { 8, 6, 7 }, { 8, 6, 7 }, + { 8, 7, 6 }, { 8, 7, 6 }, + { 8, 0, 5 }, { 8, 0, 5 }, + { 9, 8, 4 }, + { 9, 16, 15 }, + + /* 9 */ + { 9, 12, 16 }, + { 9, 1, 8 }, + { 9, 8, 1 }, + { 9, 14, 16 }, + { 9, 5, 8 }, + { 9, 13, 16 }, + { 9, 3, 9 }, + { 9, 8, 5 }, + { 9, 7, 7 }, + { 9, 2, 9 }, + { 9, 8, 6 }, + { 9, 9, 2 }, + { 9, 9, 3 }, + { 9, 15, 16 }, + { 9, 4, 9 }, + { 9, 6, 8 }, + { 9, 6, 0 }, + { 9, 9, 4 }, + { 9, 5, 9 }, + { 9, 8, 7 }, + { 9, 7, 8 }, + { 9, 1, 9 }, + { 9, 10, 3 }, + { 9, 0, 6 }, + { 9, 10, 2 }, + { 9, 9, 1 }, + { 9, 9, 5 }, + { 9, 4, 10 }, + { 9, 2, 10 }, + { 9, 9, 6 }, + { 9, 3, 10 }, + { 9, 6, 9 }, + { 9, 10, 4 }, + { 9, 8, 8 }, + { 9, 10, 5 }, + { 9, 9, 7 }, + { 9, 11, 3 }, + { 9, 1, 10 }, + { 9, 7, 0 }, + { 9, 10, 6 }, + { 9, 7, 9 }, + { 9, 3, 11 }, + { 9, 5, 10 }, + { 9, 10, 1 }, + { 9, 4, 11 }, + { 9, 11, 2 }, + { 9, 13, 2 }, + { 9, 6, 10 }, + + /* 9/10 */ + { 9, 13, 3 }, { 9, 13, 3 }, + { 9, 2, 11 }, { 9, 2, 11 }, + { 9, 16, 0 }, { 9, 16, 0 }, + { 9, 5, 11 }, { 9, 5, 11 }, + { 9, 11, 5 }, { 9, 11, 5 }, + { 10, 11, 4 }, + { 10, 9, 8 }, + { 10, 7, 10 }, + { 10, 8, 9 }, + { 10, 0, 16 }, + { 10, 4, 13 }, + { 10, 0, 7 }, + { 10, 3, 13 }, + { 10, 11, 6 }, + { 10, 13, 1 }, + { 10, 13, 4 }, + { 10, 12, 3 }, + { 10, 2, 13 }, + { 10, 13, 5 }, + { 10, 8, 10 }, + { 10, 6, 11 }, + { 10, 10, 8 }, + { 10, 10, 7 }, + { 10, 14, 2 }, + { 10, 12, 4 }, + { 10, 1, 11 }, + { 10, 4, 12 }, + + /* 10 */ + { 10, 11, 1 }, + { 10, 3, 12 }, + { 10, 1, 13 }, + { 10, 12, 2 }, + { 10, 7, 11 }, + { 10, 3, 14 }, + { 10, 5, 12 }, + { 10, 5, 13 }, + { 10, 14, 4 }, + { 10, 4, 14 }, + { 10, 11, 7 }, + { 10, 14, 3 }, + { 10, 12, 5 }, + { 10, 13, 6 }, + { 10, 12, 6 }, + { 10, 8, 0 }, + { 10, 11, 8 }, + { 10, 2, 12 }, + { 10, 9, 9 }, + { 10, 14, 5 }, + { 10, 6, 13 }, + { 10, 10, 10 }, + { 10, 15, 2 }, + { 10, 8, 11 }, + { 10, 9, 10 }, + { 10, 14, 6 }, + { 10, 10, 9 }, + { 10, 5, 14 }, + { 10, 11, 9 }, + { 10, 14, 1 }, + { 10, 2, 14 }, + { 10, 6, 12 }, + { 10, 1, 12 }, + { 10, 13, 8 }, + { 10, 0, 8 }, + { 10, 13, 7 }, + { 10, 7, 12 }, + { 10, 12, 7 }, + { 10, 7, 13 }, + { 10, 15, 3 }, + { 10, 12, 1 }, + { 10, 6, 14 }, + { 10, 2, 15 }, + { 10, 15, 5 }, + { 10, 15, 4 }, + { 10, 1, 14 }, + { 10, 9, 11 }, + { 10, 4, 15 }, + { 10, 14, 7 }, + { 10, 8, 13 }, + { 10, 13, 9 }, + { 10, 8, 12 }, + { 10, 5, 15 }, + { 10, 3, 15 }, + { 10, 10, 11 }, + { 10, 11, 10 }, + { 10, 12, 8 }, + { 10, 15, 6 }, + { 10, 15, 7 }, + { 10, 8, 14 }, + { 10, 15, 1 }, + { 10, 7, 14 }, + { 10, 9, 0 }, + { 10, 0, 9 }, + + /* 10/11/12 */ + { 10, 9, 13 }, { 10, 9, 13 }, { 10, 9, 13 }, { 10, 9, 13 }, + { 10, 9, 12 }, { 10, 9, 12 }, { 10, 9, 12 }, { 10, 9, 12 }, + { 10, 12, 9 }, { 10, 12, 9 }, { 10, 12, 9 }, { 10, 12, 9 }, + { 10, 14, 8 }, { 10, 14, 8 }, { 10, 14, 8 }, { 10, 14, 8 }, + { 10, 10, 13 }, { 10, 10, 13 }, { 10, 10, 13 }, { 10, 10, 13 }, + { 10, 14, 9 }, { 10, 14, 9 }, { 10, 14, 9 }, { 10, 14, 9 }, + { 10, 12, 10 }, { 10, 12, 10 }, { 10, 12, 10 }, { 10, 12, 10 }, + { 10, 6, 15 }, { 10, 6, 15 }, { 10, 6, 15 }, { 10, 6, 15 }, + { 10, 7, 15 }, { 10, 7, 15 }, { 10, 7, 15 }, { 10, 7, 15 }, + + { 11, 9, 14 }, { 11, 9, 14 }, + { 11, 15, 8 }, { 11, 15, 8 }, + { 11, 11, 11 }, { 11, 11, 11 }, + { 11, 11, 14 }, { 11, 11, 14 }, + { 11, 1, 15 }, { 11, 1, 15 }, + { 11, 10, 12 }, { 11, 10, 12 }, + { 11, 10, 14 }, { 11, 10, 14 }, + { 11, 13, 11 }, { 11, 13, 11 }, + { 11, 13, 10 }, { 11, 13, 10 }, + { 11, 11, 13 }, { 11, 11, 13 }, + { 11, 11, 12 }, { 11, 11, 12 }, + { 11, 8, 15 }, { 11, 8, 15 }, + { 11, 14, 11 }, { 11, 14, 11 }, + { 11, 13, 12 }, { 11, 13, 12 }, + { 11, 12, 13 }, { 11, 12, 13 }, + { 11, 15, 9 }, { 11, 15, 9 }, + { 11, 14, 10 }, { 11, 14, 10 }, + { 11, 10, 0 }, { 11, 10, 0 }, + { 11, 12, 11 }, { 11, 12, 11 }, + { 11, 9, 15 }, { 11, 9, 15 }, + { 11, 0, 10 }, { 11, 0, 10 }, + { 11, 12, 12 }, { 11, 12, 12 }, + { 11, 11, 0 }, { 11, 11, 0 }, + { 11, 12, 14 }, { 11, 12, 14 }, + { 11, 10, 15 }, { 11, 10, 15 }, + { 11, 13, 13 }, { 11, 13, 13 }, + { 11, 0, 13 }, { 11, 0, 13 }, + { 11, 14, 12 }, { 11, 14, 12 }, + { 11, 15, 10 }, { 11, 15, 10 }, + { 11, 15, 11 }, { 11, 15, 11 }, + { 11, 11, 15 }, { 11, 11, 15 }, + { 11, 14, 13 }, { 11, 14, 13 }, + { 11, 13, 0 }, { 11, 13, 0 }, + { 11, 0, 11 }, { 11, 0, 11 }, + { 11, 13, 14 }, { 11, 13, 14 }, + { 11, 15, 12 }, { 11, 15, 12 }, + { 11, 15, 13 }, { 11, 15, 13 }, + { 11, 12, 15 }, { 11, 12, 15 }, + { 11, 14, 0 }, { 11, 14, 0 }, + { 11, 14, 14 }, { 11, 14, 14 }, + { 11, 13, 15 }, { 11, 13, 15 }, + { 11, 12, 0 }, { 11, 12, 0 }, + { 11, 14, 15 }, { 11, 14, 15 }, + { 12, 0, 14 }, + { 12, 0, 12 }, + { 12, 15, 14 }, + { 12, 15, 0 }, + { 12, 0, 15 }, + { 12, 15, 15 } +}; diff --git a/lib/rbcodec/codecs/libfaad/codebook/hcb_2.h b/lib/rbcodec/codecs/libfaad/codebook/hcb_2.h new file mode 100644 index 0000000000..15e7d57084 --- /dev/null +++ b/lib/rbcodec/codecs/libfaad/codebook/hcb_2.h @@ -0,0 +1,182 @@ +/* +** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding +** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +** +** Any non-GPL usage of this software or parts of this software is strictly +** forbidden. +** +** Commercial non-GPL licensing of this software is possible. +** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** +** $Id$ +**/ + +/* 2-step huffman table HCB_2 */ + + +/* 1st step: 5 bits + * 2^5 = 32 entries + * + * Used to find offset into 2nd step table and number of extra bits to get + */ +static hcb hcb2_1[] ICONST_ATTR_FAAD_LARGE_IRAM = { + { /* 00000 */ 0, 0 }, + { /* */ 0, 0 }, + { /* */ 0, 0 }, + { /* */ 0, 0 }, + { /* 00100 */ 1, 0 }, + { /* */ 1, 0 }, + { /* 00110 */ 2, 0 }, + { /* 00111 */ 3, 0 }, + { /* 01000 */ 4, 0 }, + { /* 01001 */ 5, 0 }, + { /* 01010 */ 6, 0 }, + { /* 01011 */ 7, 0 }, + { /* 01100 */ 8, 0 }, + + /* 6 bit codewords */ + { /* 01101 */ 9, 1 }, + { /* 01110 */ 11, 1 }, + { /* 01111 */ 13, 1 }, + { /* 10000 */ 15, 1 }, + { /* 10001 */ 17, 1 }, + { /* 10010 */ 19, 1 }, + { /* 10011 */ 21, 1 }, + { /* 10100 */ 23, 1 }, + { /* 10101 */ 25, 1 }, + { /* 10110 */ 27, 1 }, + { /* 10111 */ 29, 1 }, + { /* 11000 */ 31, 1 }, + + /* 7 bit codewords */ + { /* 11001 */ 33, 2 }, + { /* 11010 */ 37, 2 }, + { /* 11011 */ 41, 2 }, + + /* 7/8 bit codewords */ + { /* 11100 */ 45, 3 }, + + /* 8 bit codewords */ + { /* 11101 */ 53, 3 }, + { /* 11110 */ 61, 3 }, + + /* 8/9 bit codewords */ + { /* 11111 */ 69, 4 } +}; + +/* 2nd step table + * + * Gives size of codeword and actual data (x,y,v,w) + */ +static hcb_2_quad hcb2_2[] ICONST_ATTR_FAAD_LARGE_IRAM = { + /* 3 bit codeword */ + { 3, 0, 0, 0, 0 }, + + /* 4 bit codeword */ + { 4, 1, 0, 0, 0 }, + + /* 5 bit codewords */ + { 5, -1, 0, 0, 0 }, + { 5, 0, 0, 0, 1 }, + { 5, 0, 0, -1, 0 }, + { 5, 0, 0, 0, -1 }, + { 5, 0, -1, 0, 0 }, + { 5, 0, 0, 1, 0 }, + { 5, 0, 1, 0, 0 }, + + /* 6 bit codewords */ + { 6, 0, -1, 1, 0 }, + { 6, -1, 1, 0, 0 }, + { 6, 0, 1, -1, 0 }, + { 6, 0, 0, 1, -1 }, + { 6, 0, 1, 0, -1 }, + { 6, 0, 0, -1, 1 }, + { 6, -1, 0, 0, -1 }, + { 6, 1, -1, 0, 0 }, + { 6, 1, 0, -1, 0 }, + { 6, -1, -1, 0, 0 }, + { 6, 0, 0, -1, -1 }, + { 6, 1, 0, 1, 0 }, + { 6, 1, 0, 0, 1 }, + { 6, 0, -1, 0, 1 }, + { 6, -1, 0, 1, 0 }, + { 6, 0, 1, 0, 1 }, + { 6, 0, -1, -1, 0 }, + { 6, -1, 0, 0, 1 }, + { 6, 0, -1, 0, -1 }, + { 6, -1, 0, -1, 0 }, + { 6, 1, 1, 0, 0 }, + { 6, 0, 1, 1, 0 }, + { 6, 0, 0, 1, 1 }, + { 6, 1, 0, 0, -1 }, + + /* 7 bit codewords */ + { 7, 0, 1, -1, 1 }, + { 7, 1, 0, -1, 1 }, + { 7, -1, 1, -1, 0 }, + { 7, 0, -1, 1, -1 }, + { 7, 1, -1, 1, 0 }, + { 7, 1, 1, 0, -1 }, + { 7, 1, 0, 1, 1 }, + { 7, -1, 1, 1, 0 }, + { 7, 0, -1, -1, 1 }, + { 7, 1, 1, 1, 0 }, + { 7, -1, 0, 1, -1 }, + { 7, -1, -1, -1, 0 }, + + /* 7/8 bit codewords */ + { 7, -1, 0, -1, 1 }, { 7, -1, 0, -1, 1 }, + { 7, 1, -1, -1, 0 }, { 7, 1, -1, -1, 0 }, + { 7, 1, 1, -1, 0 }, { 7, 1, 1, -1, 0 }, + { 8, 1, -1, 0, 1 }, + { 8, -1, 1, 0, -1 }, + + /* 8 bit codewords */ + { 8, -1, -1, 1, 0 }, + { 8, -1, 0, 1, 1 }, + { 8, -1, -1, 0, 1 }, + { 8, -1, -1, 0, -1 }, + { 8, 0, -1, -1, -1 }, + { 8, 1, 0, 1, -1 }, + { 8, 1, 0, -1, -1 }, + { 8, 0, 1, -1, -1 }, + { 8, 0, 1, 1, 1 }, + { 8, -1, 1, 0, 1 }, + { 8, -1, 0, -1, -1 }, + { 8, 0, 1, 1, -1 }, + { 8, 1, -1, 0, -1 }, + { 8, 0, -1, 1, 1 }, + { 8, 1, 1, 0, 1 }, + { 8, 1, -1, 1, -1 }, + + /* 8/9 bit codewords */ + { 8, -1, 1, -1, 1 }, { 8, -1, 1, -1, 1 }, + { 9, 1, -1, -1, 1 }, + { 9, -1, -1, -1, -1 }, + { 9, -1, 1, 1, -1 }, + { 9, -1, 1, 1, 1 }, + { 9, 1, 1, 1, 1 }, + { 9, -1, -1, 1, -1 }, + { 9, 1, -1, 1, 1 }, + { 9, -1, 1, -1, -1 }, + { 9, -1, -1, 1, 1 }, + { 9, 1, 1, -1, -1 }, + { 9, 1, -1, -1, -1 }, + { 9, -1, -1, -1, 1 }, + { 9, 1, 1, -1, 1 }, + { 9, 1, 1, 1, -1 } +}; diff --git a/lib/rbcodec/codecs/libfaad/codebook/hcb_3.h b/lib/rbcodec/codecs/libfaad/codebook/hcb_3.h new file mode 100644 index 0000000000..3b12fdff60 --- /dev/null +++ b/lib/rbcodec/codecs/libfaad/codebook/hcb_3.h @@ -0,0 +1,193 @@ +/* +** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding +** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +** +** Any non-GPL usage of this software or parts of this software is strictly +** forbidden. +** +** Commercial non-GPL licensing of this software is possible. +** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** +** $Id$ +**/ + +/* Binary search huffman table HCB_3 */ + + +static hcb_bin_quad hcb3[] ICONST_ATTR_FAAD_LARGE_IRAM = { + { /* 0 */ 0, { 1, 2, 0, 0 } }, + { /* 1 */ 1, { 0, 0, 0, 0 } }, /* 0 */ + { /* 2 */ 0, { 1, 2, 0, 0 } }, + { /* 3 */ 0, { 2, 3, 0, 0 } }, + { /* 4 */ 0, { 3, 4, 0, 0 } }, + { /* 5 */ 0, { 4, 5, 0, 0 } }, + { /* 6 */ 0, { 5, 6, 0, 0 } }, + { /* 7 */ 0, { 6, 7, 0, 0 } }, + { /* 8 */ 0, { 7, 8, 0, 0 } }, + { /* 9 */ 1, { 1, 0, 0, 0 } }, /* 1000 */ + { /* 10 */ 1, { 0, 0, 0, 1 } }, /* 1001 */ + { /* 11 */ 1, { 0, 1, 0, 0 } }, /* 1010 */ + { /* 12 */ 1, { 0, 0, 1, 0 } }, /* 1011 */ + { /* 13 */ 0, { 4, 5, 0, 0 } }, + { /* 14 */ 0, { 5, 6, 0, 0 } }, + { /* 15 */ 0, { 6, 7, 0, 0 } }, + { /* 16 */ 0, { 7, 8, 0, 0 } }, + { /* 17 */ 1, { 1, 1, 0, 0 } }, + { /* 18 */ 1, { 0, 0, 1, 1 } }, + { /* 19 */ 0, { 6, 7, 0, 0 } }, + { /* 20 */ 0, { 7, 8, 0, 0 } }, + { /* 21 */ 0, { 8, 9, 0, 0 } }, + { /* 22 */ 0, { 9, 10, 0, 0 } }, + { /* 23 */ 0, { 10, 11, 0, 0 } }, + { /* 24 */ 0, { 11, 12, 0, 0 } }, + { /* 25 */ 1, { 0, 1, 1, 0 } }, /* 110100 */ + { /* 26 */ 1, { 0, 1, 0, 1 } }, /* 110101 */ + { /* 27 */ 1, { 1, 0, 1, 0 } }, /* 110110 */ + { /* 28 */ 1, { 0, 1, 1, 1 } }, /* 110111 */ + { /* 29 */ 1, { 1, 0, 0, 1 } }, /* 111000 */ + { /* 30 */ 1, { 1, 1, 1, 0 } }, /* 111001 */ + { /* 31 */ 0, { 6, 7, 0, 0 } }, + { /* 32 */ 0, { 7, 8, 0, 0 } }, + { /* 33 */ 0, { 8, 9, 0, 0 } }, + { /* 34 */ 0, { 9, 10, 0, 0 } }, + { /* 35 */ 0, { 10, 11, 0, 0 } }, + { /* 36 */ 0, { 11, 12, 0, 0 } }, + { /* 37 */ 1, { 1, 1, 1, 1 } }, /* 1110100 */ + { /* 38 */ 1, { 1, 0, 1, 1 } }, /* 1110101 */ + { /* 39 */ 1, { 1, 1, 0, 1 } }, /* 1110110 */ + { /* 40 */ 0, { 9, 10, 0, 0 } }, + { /* 41 */ 0, { 10, 11, 0, 0 } }, + { /* 42 */ 0, { 11, 12, 0, 0 } }, + { /* 43 */ 0, { 12, 13, 0, 0 } }, + { /* 44 */ 0, { 13, 14, 0, 0 } }, + { /* 45 */ 0, { 14, 15, 0, 0 } }, + { /* 46 */ 0, { 15, 16, 0, 0 } }, + { /* 47 */ 0, { 16, 17, 0, 0 } }, + { /* 48 */ 0, { 17, 18, 0, 0 } }, + { /* 49 */ 1, { 2, 0, 0, 0 } }, /* 11101110 */ + { /* 50 */ 1, { 0, 0, 0, 2 } }, /* 11101111 */ + { /* 51 */ 1, { 0, 0, 1, 2 } }, /* 11110000 */ + { /* 52 */ 1, { 2, 1, 0, 0 } }, /* 11110001 */ + { /* 53 */ 1, { 1, 2, 1, 0 } }, /* 11110010 */ + { /* 54 */ 0, { 13, 14, 0, 0 } }, + { /* 55 */ 0, { 14, 15, 0, 0 } }, + { /* 56 */ 0, { 15, 16, 0, 0 } }, + { /* 57 */ 0, { 16, 17, 0, 0 } }, + { /* 58 */ 0, { 17, 18, 0, 0 } }, + { /* 59 */ 0, { 18, 19, 0, 0 } }, + { /* 60 */ 0, { 19, 20, 0, 0 } }, + { /* 61 */ 0, { 20, 21, 0, 0 } }, + { /* 62 */ 0, { 21, 22, 0, 0 } }, + { /* 63 */ 0, { 22, 23, 0, 0 } }, + { /* 64 */ 0, { 23, 24, 0, 0 } }, + { /* 65 */ 0, { 24, 25, 0, 0 } }, + { /* 66 */ 0, { 25, 26, 0, 0 } }, + { /* 67 */ 1, { 0, 0, 2, 1 } }, + { /* 68 */ 1, { 0, 1, 2, 1 } }, + { /* 69 */ 1, { 1, 2, 0, 0 } }, + { /* 70 */ 1, { 0, 1, 1, 2 } }, + { /* 71 */ 1, { 2, 1, 1, 0 } }, + { /* 72 */ 1, { 0, 0, 2, 0 } }, + { /* 73 */ 1, { 0, 2, 1, 0 } }, + { /* 74 */ 1, { 0, 1, 2, 0 } }, + { /* 75 */ 1, { 0, 2, 0, 0 } }, + { /* 76 */ 1, { 0, 1, 0, 2 } }, + { /* 77 */ 1, { 2, 0, 1, 0 } }, + { /* 78 */ 1, { 1, 2, 1, 1 } }, + { /* 79 */ 1, { 0, 2, 1, 1 } }, + { /* 80 */ 1, { 1, 1, 2, 0 } }, + { /* 81 */ 1, { 1, 1, 2, 1 } }, + { /* 82 */ 0, { 11, 12, 0, 0 } }, + { /* 83 */ 0, { 12, 13, 0, 0 } }, + { /* 84 */ 0, { 13, 14, 0, 0 } }, + { /* 85 */ 0, { 14, 15, 0, 0 } }, + { /* 86 */ 0, { 15, 16, 0, 0 } }, + { /* 87 */ 0, { 16, 17, 0, 0 } }, + { /* 88 */ 0, { 17, 18, 0, 0 } }, + { /* 89 */ 0, { 18, 19, 0, 0 } }, + { /* 90 */ 0, { 19, 20, 0, 0 } }, + { /* 91 */ 0, { 20, 21, 0, 0 } }, + { /* 92 */ 0, { 21, 22, 0, 0 } }, + { /* 93 */ 1, { 1, 2, 0, 1 } }, /* 1111101010 */ + { /* 94 */ 1, { 1, 0, 2, 0 } }, /* 1111101011 */ + { /* 95 */ 1, { 1, 0, 2, 1 } }, /* 1111101100 */ + { /* 96 */ 1, { 0, 2, 0, 1 } }, /* 1111101101 */ + { /* 97 */ 1, { 2, 1, 1, 1 } }, /* 1111101110 */ + { /* 98 */ 1, { 1, 1, 1, 2 } }, /* 1111101111 */ + { /* 99 */ 1, { 2, 1, 0, 1 } }, /* 1111110000 */ + { /* 00 */ 1, { 1, 0, 1, 2 } }, /* 1111110001 */ + { /* 01 */ 1, { 0, 0, 2, 2 } }, /* 1111110010 */ + { /* 02 */ 1, { 0, 1, 2, 2 } }, /* 1111110011 */ + { /* 03 */ 1, { 2, 2, 1, 0 } }, /* 1111110100 */ + { /* 04 */ 1, { 1, 2, 2, 0 } }, /* 1111110101 */ + { /* 05 */ 1, { 1, 0, 0, 2 } }, /* 1111110110 */ + { /* 06 */ 1, { 2, 0, 0, 1 } }, /* 1111110111 */ + { /* 07 */ 1, { 0, 2, 2, 1 } }, /* 1111111000 */ + { /* 08 */ 0, { 7, 8, 0, 0 } }, + { /* 09 */ 0, { 8, 9, 0, 0 } }, + { /* 10 */ 0, { 9, 10, 0, 0 } }, + { /* 11 */ 0, { 10, 11, 0, 0 } }, + { /* 12 */ 0, { 11, 12, 0, 0 } }, + { /* 13 */ 0, { 12, 13, 0, 0 } }, + { /* 14 */ 0, { 13, 14, 0, 0 } }, + { /* 15 */ 1, { 2, 2, 0, 0 } }, /* 11111110010 */ + { /* 16 */ 1, { 1, 2, 2, 1 } }, /* 11111110011 */ + { /* 17 */ 1, { 1, 1, 0, 2 } }, /* 11111110100 */ + { /* 18 */ 1, { 2, 0, 1, 1 } }, /* 11111110101 */ + { /* 19 */ 1, { 1, 1, 2, 2 } }, /* 11111110110 */ + { /* 20 */ 1, { 2, 2, 1, 1 } }, /* 11111110111 */ + { /* 21 */ 1, { 0, 2, 2, 0 } }, /* 11111111000 */ + { /* 22 */ 1, { 0, 2, 1, 2 } }, /* 11111111001 */ + { /* 23 */ 0, { 6, 7, 0, 0 } }, + { /* 24 */ 0, { 7, 8, 0, 0 } }, + { /* 25 */ 0, { 8, 9, 0, 0 } }, + { /* 26 */ 0, { 9, 10, 0, 0 } }, + { /* 27 */ 0, { 10, 11, 0, 0 } }, + { /* 28 */ 0, { 11, 12, 0, 0 } }, + { /* 29 */ 1, { 1, 0, 2, 2 } }, /* 111111110100 */ + { /* 30 */ 1, { 2, 2, 0, 1 } }, /* 111111110101 */ + { /* 31 */ 1, { 2, 1, 2, 0 } }, /* 111111110110 */ + { /* 32 */ 1, { 2, 2, 2, 0 } }, /* 111111110111 */ + { /* 33 */ 1, { 0, 2, 2, 2 } }, /* 111111111000 */ + { /* 34 */ 1, { 2, 2, 2, 1 } }, /* 111111111001 */ + { /* 35 */ 1, { 2, 1, 2, 1 } }, /* 111111111010 */ + { /* 36 */ 1, { 1, 2, 1, 2 } }, /* 111111111011 */ + { /* 37 */ 1, { 1, 2, 2, 2 } }, /* 111111111100 */ + { /* 38 */ 0, { 3, 4, 0, 0 } }, + { /* 39 */ 0, { 4, 5, 0, 0 } }, + { /* 40 */ 0, { 5, 6, 0, 0 } }, + { /* 41 */ 1, { 0, 2, 0, 2 } }, /* 1111111111010 */ + { /* 42 */ 1, { 2, 0, 2, 0 } }, /* 1111111111011 */ + { /* 43 */ 1, { 1, 2, 0, 2 } }, /* 1111111111100 */ + { /* 44 */ 0, { 3, 4, 0, 0 } }, + { /* 45 */ 0, { 4, 5, 0, 0 } }, + { /* 46 */ 0, { 5, 6, 0, 0 } }, + { /* 47 */ 1, { 2, 0, 2, 1 } }, /* 11111111111010 */ + { /* 48 */ 1, { 2, 1, 1, 2 } }, /* 11111111111011 */ + { /* 49 */ 1, { 2, 1, 0, 2 } }, /* 11111111111100 */ + { /* 50 */ 0, { 3, 4, 0, 0 } }, + { /* 51 */ 0, { 4, 5, 0, 0 } }, + { /* 52 */ 0, { 5, 6, 0, 0 } }, + { /* 53 */ 1, { 2, 2, 2, 2 } }, /* 111111111111010 */ + { /* 54 */ 1, { 2, 2, 1, 2 } }, /* 111111111111011 */ + { /* 55 */ 1, { 2, 1, 2, 2 } }, /* 111111111111100 */ + { /* 56 */ 1, { 2, 0, 1, 2 } }, /* 111111111111101 */ + { /* 57 */ 1, { 2, 0, 0, 2 } }, /* 111111111111110 */ + { /* 58 */ 0, { 1, 2, 0, 0 } }, + { /* 59 */ 1, { 2, 2, 0, 2 } }, /* 1111111111111110 */ + { /* 60 */ 1, { 2, 0, 2, 2 } } /* 1111111111111111 */ +}; diff --git a/lib/rbcodec/codecs/libfaad/codebook/hcb_4.h b/lib/rbcodec/codecs/libfaad/codebook/hcb_4.h new file mode 100644 index 0000000000..67397e1fb0 --- /dev/null +++ b/lib/rbcodec/codecs/libfaad/codebook/hcb_4.h @@ -0,0 +1,196 @@ +/* +** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding +** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +** +** Any non-GPL usage of this software or parts of this software is strictly +** forbidden. +** +** Commercial non-GPL licensing of this software is possible. +** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** +** $Id$ +**/ + +/* 2-step huffman table HCB_4 */ + + +/* 1st step: 5 bits + * 2^5 = 32 entries + * + * Used to find offset into 2nd step table and number of extra bits to get + */ +static hcb hcb4_1[] ICONST_ATTR_FAAD_LARGE_IRAM = { + /* 4 bit codewords */ + { /* 00000 */ 0, 0 }, + { /* */ 0, 0 }, + { /* 00010 */ 1, 0 }, + { /* */ 1, 0 }, + { /* 00100 */ 2, 0 }, + { /* */ 2, 0 }, + { /* 00110 */ 3, 0 }, + { /* */ 3, 0 }, + { /* 01000 */ 4, 0 }, + { /* */ 4, 0 }, + { /* 01010 */ 5, 0 }, + { /* */ 5, 0 }, + { /* 01100 */ 6, 0 }, + { /* */ 6, 0 }, + { /* 01110 */ 7, 0 }, + { /* */ 7, 0 }, + { /* 10000 */ 8, 0 }, + { /* */ 8, 0 }, + { /* 10010 */ 9, 0 }, + { /* */ 9, 0 }, + + /* 5 bit codewords */ + { /* 10100 */ 10, 0 }, + { /* 10101 */ 11, 0 }, + { /* 10110 */ 12, 0 }, + { /* 10111 */ 13, 0 }, + { /* 11000 */ 14, 0 }, + { /* 11001 */ 15, 0 }, + + /* 7 bit codewords */ + { /* 11010 */ 16, 2 }, + { /* 11011 */ 20, 2 }, + + /* 7/8 bit codewords */ + { /* 11100 */ 24, 3 }, + + /* 8 bit codewords */ + { /* 11101 */ 32, 3 }, + + /* 8/9 bit codewords */ + { /* 11110 */ 40, 4 }, + + /* 9/10/11/12 bit codewords */ + { /* 11111 */ 56, 7 } +}; + +/* 2nd step table + * + * Gives size of codeword and actual data (x,y,v,w) + */ +static hcb_2_quad hcb4_2[] ICONST_ATTR_FAAD_LARGE_IRAM = { + /* 4 bit codewords */ + { 4, 1, 1, 1, 1 }, + { 4, 0, 1, 1, 1 }, + { 4, 1, 1, 0, 1 }, + { 4, 1, 1, 1, 0 }, + { 4, 1, 0, 1, 1 }, + { 4, 1, 0, 0, 0 }, + { 4, 1, 1, 0, 0 }, + { 4, 0, 0, 0, 0 }, + { 4, 0, 0, 1, 1 }, + { 4, 1, 0, 1, 0 }, + + /* 5 bit codewords */ + { 5, 1, 0, 0, 1 }, + { 5, 0, 1, 1, 0 }, + { 5, 0, 0, 0, 1 }, + { 5, 0, 1, 0, 1 }, + { 5, 0, 0, 1, 0 }, + { 5, 0, 1, 0, 0 }, + + /* 7 bit codewords */ + /* first 5 bits: 11010 */ + { 7, 2, 1, 1, 1 }, + { 7, 1, 1, 2, 1 }, + { 7, 1, 2, 1, 1 }, + { 7, 1, 1, 1, 2 }, + /* first 5 bits: 11011 */ + { 7, 2, 1, 1, 0 }, + { 7, 2, 1, 0, 1 }, + { 7, 1, 2, 1, 0 }, + { 7, 2, 0, 1, 1 }, + + /* 7/8 bit codewords */ + /* first 5 bits: 11100 */ + { 7, 0, 1, 2, 1 }, { 7, 0, 1, 2, 1 }, + { 8, 0, 1, 1, 2 }, + { 8, 1, 1, 2, 0 }, + { 8, 0, 2, 1, 1 }, + { 8, 1, 0, 1, 2 }, + { 8, 1, 2, 0, 1 }, + { 8, 1, 1, 0, 2 }, + + /* 8 bit codewords */ + { 8, 1, 0, 2, 1 }, + { 8, 2, 1, 0, 0 }, + { 8, 2, 0, 1, 0 }, + { 8, 1, 2, 0, 0 }, + { 8, 2, 0, 0, 1 }, + { 8, 0, 1, 0, 2 }, + { 8, 0, 2, 1, 0 }, + { 8, 0, 0, 1, 2 }, + + /* 8/9 bit codewords */ + { 8, 0, 1, 2, 0 }, { 8, 0, 1, 2, 0 }, + { 8, 0, 2, 0, 1 }, { 8, 0, 2, 0, 1 }, + { 8, 1, 0, 0, 2 }, { 8, 1, 0, 0, 2 }, + { 8, 0, 0, 2, 1 }, { 8, 0, 0, 2, 1 }, + { 8, 1, 0, 2, 0 }, { 8, 1, 0, 2, 0 }, + { 8, 2, 0, 0, 0 }, { 8, 2, 0, 0, 0 }, + { 8, 0, 0, 0, 2 }, { 8, 0, 0, 0, 2 }, + { 9, 0, 2, 0, 0 }, + { 9, 0, 0, 2, 0 }, + + /* 9/10/11 bit codewords */ + /* 9 bit codewords repeated 2^3 = 8 times */ + { 9, 1, 2, 2, 1 }, { 9, 1, 2, 2, 1 }, { 9, 1, 2, 2, 1 }, { 9, 1, 2, 2, 1 }, + { 9, 1, 2, 2, 1 }, { 9, 1, 2, 2, 1 }, { 9, 1, 2, 2, 1 }, { 9, 1, 2, 2, 1 }, + { 9, 2, 2, 1, 1 }, { 9, 2, 2, 1, 1 }, { 9, 2, 2, 1, 1 }, { 9, 2, 2, 1, 1 }, + { 9, 2, 2, 1, 1 }, { 9, 2, 2, 1, 1 }, { 9, 2, 2, 1, 1 }, { 9, 2, 2, 1, 1 }, + { 9, 2, 1, 2, 1 }, { 9, 2, 1, 2, 1 }, { 9, 2, 1, 2, 1 }, { 9, 2, 1, 2, 1 }, + { 9, 2, 1, 2, 1 }, { 9, 2, 1, 2, 1 }, { 9, 2, 1, 2, 1 }, { 9, 2, 1, 2, 1 }, + { 9, 1, 1, 2, 2 }, { 9, 1, 1, 2, 2 }, { 9, 1, 1, 2, 2 }, { 9, 1, 1, 2, 2 }, + { 9, 1, 1, 2, 2 }, { 9, 1, 1, 2, 2 }, { 9, 1, 1, 2, 2 }, { 9, 1, 1, 2, 2 }, + { 9, 1, 2, 1, 2 }, { 9, 1, 2, 1, 2 }, { 9, 1, 2, 1, 2 }, { 9, 1, 2, 1, 2 }, + { 9, 1, 2, 1, 2 }, { 9, 1, 2, 1, 2 }, { 9, 1, 2, 1, 2 }, { 9, 1, 2, 1, 2 }, + { 9, 2, 1, 1, 2 }, { 9, 2, 1, 1, 2 }, { 9, 2, 1, 1, 2 }, { 9, 2, 1, 1, 2 }, + { 9, 2, 1, 1, 2 }, { 9, 2, 1, 1, 2 }, { 9, 2, 1, 1, 2 }, { 9, 2, 1, 1, 2 }, + /* 10 bit codewords repeated 2^2 = 4 times */ + { 10, 1, 2, 2, 0 }, { 10, 1, 2, 2, 0 }, { 10, 1, 2, 2, 0 }, { 10, 1, 2, 2, 0 }, + { 10, 2, 2, 1, 0 }, { 10, 2, 2, 1, 0 }, { 10, 2, 2, 1, 0 }, { 10, 2, 2, 1, 0 }, + { 10, 2, 1, 2, 0 }, { 10, 2, 1, 2, 0 }, { 10, 2, 1, 2, 0 }, { 10, 2, 1, 2, 0 }, + { 10, 0, 2, 2, 1 }, { 10, 0, 2, 2, 1 }, { 10, 0, 2, 2, 1 }, { 10, 0, 2, 2, 1 }, + { 10, 0, 1, 2, 2 }, { 10, 0, 1, 2, 2 }, { 10, 0, 1, 2, 2 }, { 10, 0, 1, 2, 2 }, + { 10, 2, 2, 0, 1 }, { 10, 2, 2, 0, 1 }, { 10, 2, 2, 0, 1 }, { 10, 2, 2, 0, 1 }, + { 10, 0, 2, 1, 2 }, { 10, 0, 2, 1, 2 }, { 10, 0, 2, 1, 2 }, { 10, 0, 2, 1, 2 }, + { 10, 2, 0, 2, 1 }, { 10, 2, 0, 2, 1 }, { 10, 2, 0, 2, 1 }, { 10, 2, 0, 2, 1 }, + { 10, 1, 0, 2, 2 }, { 10, 1, 0, 2, 2 }, { 10, 1, 0, 2, 2 }, { 10, 1, 0, 2, 2 }, + { 10, 2, 2, 2, 1 }, { 10, 2, 2, 2, 1 }, { 10, 2, 2, 2, 1 }, { 10, 2, 2, 2, 1 }, + { 10, 1, 2, 0, 2 }, { 10, 1, 2, 0, 2 }, { 10, 1, 2, 0, 2 }, { 10, 1, 2, 0, 2 }, + { 10, 2, 0, 1, 2 }, { 10, 2, 0, 1, 2 }, { 10, 2, 0, 1, 2 }, { 10, 2, 0, 1, 2 }, + { 10, 2, 1, 0, 2 }, { 10, 2, 1, 0, 2 }, { 10, 2, 1, 0, 2 }, { 10, 2, 1, 0, 2 }, + { 10, 1, 2, 2, 2 }, { 10, 1, 2, 2, 2 }, { 10, 1, 2, 2, 2 }, { 10, 1, 2, 2, 2 }, + /* 11 bit codewords repeated 2^1 = 2 times */ + { 11, 2, 1, 2, 2 }, { 11, 2, 1, 2, 2 }, + { 11, 2, 2, 1, 2 }, { 11, 2, 2, 1, 2 }, + { 11, 0, 2, 2, 0 }, { 11, 0, 2, 2, 0 }, + { 11, 2, 2, 0, 0 }, { 11, 2, 2, 0, 0 }, + { 11, 0, 0, 2, 2 }, { 11, 0, 0, 2, 2 }, + { 11, 2, 0, 2, 0 }, { 11, 2, 0, 2, 0 }, + { 11, 0, 2, 0, 2 }, { 11, 0, 2, 0, 2 }, + { 11, 2, 0, 0, 2 }, { 11, 2, 0, 0, 2 }, + { 11, 2, 2, 2, 2 }, { 11, 2, 2, 2, 2 }, + { 11, 0, 2, 2, 2 }, { 11, 0, 2, 2, 2 }, + { 11, 2, 2, 2, 0 }, { 11, 2, 2, 2, 0 }, + /* 12 bit codewords */ + { 12, 2, 2, 0, 2 }, + { 12, 2, 0, 2, 2 }, +}; diff --git a/lib/rbcodec/codecs/libfaad/codebook/hcb_5.h b/lib/rbcodec/codecs/libfaad/codebook/hcb_5.h new file mode 100644 index 0000000000..0143482901 --- /dev/null +++ b/lib/rbcodec/codecs/libfaad/codebook/hcb_5.h @@ -0,0 +1,193 @@ +/* +** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding +** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +** +** Any non-GPL usage of this software or parts of this software is strictly +** forbidden. +** +** Commercial non-GPL licensing of this software is possible. +** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** +** $Id$ +**/ + +/* Binary search huffman table HCB_5 */ + + +static hcb_bin_pair hcb5[] ICONST_ATTR_FAAD_LARGE_IRAM = { + { /* 0 */ 0, { 1, 2 } }, + { /* 1 */ 1, { 0, 0 } }, /* 0 */ + { /* 2 */ 0, { 1, 2 } }, + { /* 3 */ 0, { 2, 3 } }, + { /* 4 */ 0, { 3, 4 } }, + { /* 5 */ 0, { 4, 5 } }, + { /* 6 */ 0, { 5, 6 } }, + { /* 7 */ 0, { 6, 7 } }, + { /* 8 */ 0, { 7, 8 } }, + { /* 9 */ 1, { -1, 0 } }, /* 1000 */ + { /* 10 */ 1, { 1, 0 } }, /* 1001 */ + { /* 11 */ 1, { 0, 1 } }, /* 1010 */ + { /* 12 */ 1, { 0, -1 } }, /* 1011 */ + { /* 13 */ 0, { 4, 5 } }, + { /* 14 */ 0, { 5, 6 } }, + { /* 15 */ 0, { 6, 7 } }, + { /* 16 */ 0, { 7, 8 } }, + { /* 17 */ 1, { 1, -1 } }, + { /* 18 */ 1, { -1, 1 } }, + { /* 19 */ 1, { -1, -1 } }, + { /* 20 */ 1, { 1, 1 } }, + { /* 21 */ 0, { 4, 5 } }, + { /* 22 */ 0, { 5, 6 } }, + { /* 23 */ 0, { 6, 7 } }, + { /* 24 */ 0, { 7, 8 } }, + { /* 25 */ 0, { 8, 9 } }, + { /* 26 */ 0, { 9, 10 } }, + { /* 27 */ 0, { 10, 11 } }, + { /* 28 */ 0, { 11, 12 } }, + { /* 29 */ 0, { 12, 13 } }, + { /* 30 */ 0, { 13, 14 } }, + { /* 31 */ 0, { 14, 15 } }, + { /* 32 */ 0, { 15, 16 } }, + { /* 33 */ 1, { -2, 0 } }, + { /* 34 */ 1, { 0, 2 } }, + { /* 35 */ 1, { 2, 0 } }, + { /* 36 */ 1, { 0, -2 } }, + { /* 37 */ 0, { 12, 13 } }, + { /* 38 */ 0, { 13, 14 } }, + { /* 39 */ 0, { 14, 15 } }, + { /* 40 */ 0, { 15, 16 } }, + { /* 41 */ 0, { 16, 17 } }, + { /* 42 */ 0, { 17, 18 } }, + { /* 43 */ 0, { 18, 19 } }, + { /* 44 */ 0, { 19, 20 } }, + { /* 45 */ 0, { 20, 21 } }, + { /* 46 */ 0, { 21, 22 } }, + { /* 47 */ 0, { 22, 23 } }, + { /* 48 */ 0, { 23, 24 } }, + { /* 49 */ 1, { -2, -1 } }, + { /* 50 */ 1, { 2, 1 } }, + { /* 51 */ 1, { -1, -2 } }, + { /* 52 */ 1, { 1, 2 } }, + { /* 53 */ 1, { -2, 1 } }, + { /* 54 */ 1, { 2, -1 } }, + { /* 55 */ 1, { -1, 2 } }, + { /* 56 */ 1, { 1, -2 } }, + { /* 57 */ 1, { -3, 0 } }, + { /* 58 */ 1, { 3, 0 } }, + { /* 59 */ 1, { 0, -3 } }, + { /* 60 */ 1, { 0, 3 } }, + { /* 61 */ 0, { 12, 13 } }, + { /* 62 */ 0, { 13, 14 } }, + { /* 63 */ 0, { 14, 15 } }, + { /* 64 */ 0, { 15, 16 } }, + { /* 65 */ 0, { 16, 17 } }, + { /* 66 */ 0, { 17, 18 } }, + { /* 67 */ 0, { 18, 19 } }, + { /* 68 */ 0, { 19, 20 } }, + { /* 69 */ 0, { 20, 21 } }, + { /* 70 */ 0, { 21, 22 } }, + { /* 71 */ 0, { 22, 23 } }, + { /* 72 */ 0, { 23, 24 } }, + { /* 73 */ 1, { -3, -1 } }, + { /* 74 */ 1, { 1, 3 } }, + { /* 75 */ 1, { 3, 1 } }, + { /* 76 */ 1, { -1, -3 } }, + { /* 77 */ 1, { -3, 1 } }, + { /* 78 */ 1, { 3, -1 } }, + { /* 79 */ 1, { 1, -3 } }, + { /* 80 */ 1, { -1, 3 } }, + { /* 81 */ 1, { -2, 2 } }, + { /* 82 */ 1, { 2, 2 } }, + { /* 83 */ 1, { -2, -2 } }, + { /* 84 */ 1, { 2, -2 } }, + { /* 85 */ 0, { 12, 13 } }, + { /* 86 */ 0, { 13, 14 } }, + { /* 87 */ 0, { 14, 15 } }, + { /* 88 */ 0, { 15, 16 } }, + { /* 89 */ 0, { 16, 17 } }, + { /* 90 */ 0, { 17, 18 } }, + { /* 91 */ 0, { 18, 19 } }, + { /* 92 */ 0, { 19, 20 } }, + { /* 93 */ 0, { 20, 21 } }, + { /* 94 */ 0, { 21, 22 } }, + { /* 95 */ 0, { 22, 23 } }, + { /* 96 */ 0, { 23, 24 } }, + { /* 97 */ 1, { -3, -2 } }, + { /* 98 */ 1, { 3, -2 } }, + { /* 99 */ 1, { -2, 3 } }, + { /* 00 */ 1, { 2, -3 } }, + { /* 01 */ 1, { 3, 2 } }, + { /* 02 */ 1, { 2, 3 } }, + { /* 03 */ 1, { -3, 2 } }, + { /* 04 */ 1, { -2, -3 } }, + { /* 05 */ 1, { 0, -4 } }, + { /* 06 */ 1, { -4, 0 } }, + { /* 07 */ 1, { 4, 1 } }, + { /* 08 */ 1, { 4, 0 } }, + { /* 09 */ 0, { 12, 13 } }, + { /* 10 */ 0, { 13, 14 } }, + { /* 11 */ 0, { 14, 15 } }, + { /* 12 */ 0, { 15, 16 } }, + { /* 13 */ 0, { 16, 17 } }, + { /* 14 */ 0, { 17, 18 } }, + { /* 15 */ 0, { 18, 19 } }, + { /* 16 */ 0, { 19, 20 } }, + { /* 17 */ 0, { 20, 21 } }, + { /* 18 */ 0, { 21, 22 } }, + { /* 19 */ 0, { 22, 23 } }, + { /* 20 */ 0, { 23, 24 } }, + { /* 21 */ 1, { -4, -1 } }, + { /* 22 */ 1, { 0, 4 } }, + { /* 23 */ 1, { 4, -1 } }, + { /* 24 */ 1, { -1, -4 } }, + { /* 25 */ 1, { 1, 4 } }, + { /* 26 */ 1, { -1, 4 } }, + { /* 27 */ 1, { -4, 1 } }, + { /* 28 */ 1, { 1, -4 } }, + { /* 29 */ 1, { 3, -3 } }, + { /* 30 */ 1, { -3, -3 } }, + { /* 31 */ 1, { -3, 3 } }, + { /* 32 */ 1, { -2, 4 } }, + { /* 33 */ 1, { -4, -2 } }, + { /* 34 */ 1, { 4, 2 } }, + { /* 35 */ 1, { 2, -4 } }, + { /* 36 */ 1, { 2, 4 } }, + { /* 37 */ 1, { 3, 3 } }, + { /* 38 */ 1, { -4, 2 } }, + { /* 39 */ 0, { 6, 7 } }, + { /* 40 */ 0, { 7, 8 } }, + { /* 41 */ 0, { 8, 9 } }, + { /* 42 */ 0, { 9, 10 } }, + { /* 43 */ 0, { 10, 11 } }, + { /* 44 */ 0, { 11, 12 } }, + { /* 45 */ 1, { -2, -4 } }, + { /* 46 */ 1, { 4, -2 } }, + { /* 47 */ 1, { 3, -4 } }, + { /* 48 */ 1, { -4, -3 } }, + { /* 49 */ 1, { -4, 3 } }, + { /* 50 */ 1, { 3, 4 } }, + { /* 51 */ 1, { -3, 4 } }, + { /* 52 */ 1, { 4, 3 } }, + { /* 53 */ 1, { 4, -3 } }, + { /* 54 */ 1, { -3, -4 } }, + { /* 55 */ 0, { 2, 3 } }, + { /* 56 */ 0, { 3, 4 } }, + { /* 57 */ 1, { 4, -4 } }, + { /* 58 */ 1, { -4, 4 } }, + { /* 59 */ 1, { 4, 4 } }, + { /* 60 */ 1, { -4, -4 } } +}; diff --git a/lib/rbcodec/codecs/libfaad/codebook/hcb_6.h b/lib/rbcodec/codecs/libfaad/codebook/hcb_6.h new file mode 100644 index 0000000000..9988133552 --- /dev/null +++ b/lib/rbcodec/codecs/libfaad/codebook/hcb_6.h @@ -0,0 +1,179 @@ +/* +** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding +** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +** +** Any non-GPL usage of this software or parts of this software is strictly +** forbidden. +** +** Commercial non-GPL licensing of this software is possible. +** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** +** $Id$ +**/ + +/* 2-step huffman table HCB_6 */ + + +/* 1st step: 5 bits + * 2^5 = 32 entries + * + * Used to find offset into 2nd step table and number of extra bits to get + */ +static hcb hcb6_1[] ICONST_ATTR = { + /* 4 bit codewords */ + { /* 00000 */ 0, 0 }, + { /* */ 0, 0 }, + { /* 00010 */ 1, 0 }, + { /* */ 1, 0 }, + { /* 00100 */ 2, 0 }, + { /* */ 2, 0 }, + { /* 00110 */ 3, 0 }, + { /* */ 3, 0 }, + { /* 01000 */ 4, 0 }, + { /* */ 4, 0 }, + { /* 01010 */ 5, 0 }, + { /* */ 5, 0 }, + { /* 01100 */ 6, 0 }, + { /* */ 6, 0 }, + { /* 01110 */ 7, 0 }, + { /* */ 7, 0 }, + { /* 10000 */ 8, 0 }, + { /* */ 8, 0 }, + + /* 6 bit codewords */ + { /* 10010 */ 9, 1 }, + { /* 10011 */ 11, 1 }, + { /* 10100 */ 13, 1 }, + { /* 10101 */ 15, 1 }, + { /* 10110 */ 17, 1 }, + { /* 10111 */ 19, 1 }, + { /* 11000 */ 21, 1 }, + { /* 11001 */ 23, 1 }, + + /* 7 bit codewords */ + { /* 11010 */ 25, 2 }, + { /* 11011 */ 29, 2 }, + { /* 11100 */ 33, 2 }, + + /* 7/8 bit codewords */ + { /* 11101 */ 37, 3 }, + + /* 8/9 bit codewords */ + { /* 11110 */ 45, 4 }, + + /* 9/10/11 bit codewords */ + { /* 11111 */ 61, 6 } +}; + +/* 2nd step table + * + * Gives size of codeword and actual data (x,y,v,w) + */ +static hcb_2_pair hcb6_2[] ICONST_ATTR = { + /* 4 bit codewords */ + { 4, 0, 0 }, + { 4, 1, 0 }, + { 4, 0, -1 }, + { 4, 0, 1 }, + { 4, -1, 0 }, + { 4, 1, 1 }, + { 4, -1, 1 }, + { 4, 1, -1 }, + { 4, -1, -1 }, + + /* 6 bit codewords */ + { 6, 2, -1 }, + { 6, 2, 1 }, + { 6, -2, 1 }, + { 6, -2, -1 }, + { 6, -2, 0 }, + { 6, -1, 2 }, + { 6, 2, 0 }, + { 6, 1, -2 }, + { 6, 1, 2 }, + { 6, 0, -2 }, + { 6, -1, -2 }, + { 6, 0, 2 }, + { 6, 2, -2 }, + { 6, -2, 2 }, + { 6, -2, -2 }, + { 6, 2, 2 }, + + /* 7 bit codewords */ + { 7, -3, 1 }, + { 7, 3, 1 }, + { 7, 3, -1 }, + { 7, -1, 3 }, + { 7, -3, -1 }, + { 7, 1, 3 }, + { 7, 1, -3 }, + { 7, -1, -3 }, + { 7, 3, 0 }, + { 7, -3, 0 }, + { 7, 0, -3 }, + { 7, 0, 3 }, + + /* 7/8 bit codewords */ + { 7, 3, 2 }, { 7, 3, 2 }, + { 8, -3, -2 }, + { 8, -2, 3 }, + { 8, 2, 3 }, + { 8, 3, -2 }, + { 8, 2, -3 }, + { 8, -2, -3 }, + + /* 8 bit codewords */ + { 8, -3, 2 }, { 8, -3, 2 }, + { 8, 3, 3 }, { 8, 3, 3 }, + { 9, 3, -3 }, + { 9, -3, -3 }, + { 9, -3, 3 }, + { 9, 1, -4 }, + { 9, -1, -4 }, + { 9, 4, 1 }, + { 9, -4, 1 }, + { 9, -4, -1 }, + { 9, 1, 4 }, + { 9, 4, -1 }, + { 9, -1, 4 }, + { 9, 0, -4 }, + + /* 9/10/11 bit codewords */ + { 9, -4, 2 }, { 9, -4, 2 }, { 9, -4, 2 }, { 9, -4, 2 }, + { 9, -4, -2 }, { 9, -4, -2 }, { 9, -4, -2 }, { 9, -4, -2 }, + { 9, 2, 4 }, { 9, 2, 4 }, { 9, 2, 4 }, { 9, 2, 4 }, + { 9, -2, -4 }, { 9, -2, -4 }, { 9, -2, -4 }, { 9, -2, -4 }, + { 9, -4, 0 }, { 9, -4, 0 }, { 9, -4, 0 }, { 9, -4, 0 }, + { 9, 4, 2 }, { 9, 4, 2 }, { 9, 4, 2 }, { 9, 4, 2 }, + { 9, 4, -2 }, { 9, 4, -2 }, { 9, 4, -2 }, { 9, 4, -2 }, + { 9, -2, 4 }, { 9, -2, 4 }, { 9, -2, 4 }, { 9, -2, 4 }, + { 9, 4, 0 }, { 9, 4, 0 }, { 9, 4, 0 }, { 9, 4, 0 }, + { 9, 2, -4 }, { 9, 2, -4 }, { 9, 2, -4 }, { 9, 2, -4 }, + { 9, 0, 4 }, { 9, 0, 4 }, { 9, 0, 4 }, { 9, 0, 4 }, + { 10, -3, -4 }, { 10, -3, -4 }, + { 10, -3, 4 }, { 10, -3, 4 }, + { 10, 3, -4 }, { 10, 3, -4 }, + { 10, 4, -3 }, { 10, 4, -3 }, + { 10, 3, 4 }, { 10, 3, 4 }, + { 10, 4, 3 }, { 10, 4, 3 }, + { 10, -4, 3 }, { 10, -4, 3 }, + { 10, -4, -3 }, { 10, -4, -3 }, + { 11, 4, 4 }, + { 11, -4, 4 }, + { 11, -4, -4 }, + { 11, 4, -4 } +}; diff --git a/lib/rbcodec/codecs/libfaad/codebook/hcb_7.h b/lib/rbcodec/codecs/libfaad/codebook/hcb_7.h new file mode 100644 index 0000000000..3b378dc5cd --- /dev/null +++ b/lib/rbcodec/codecs/libfaad/codebook/hcb_7.h @@ -0,0 +1,159 @@ +/* +** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding +** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +** +** Any non-GPL usage of this software or parts of this software is strictly +** forbidden. +** +** Commercial non-GPL licensing of this software is possible. +** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** +** $Id$ +**/ + +/* Binary search huffman table HCB_7 */ + + +static hcb_bin_pair hcb7[] ICONST_ATTR_FAAD_LARGE_IRAM = { + { /* 0 */ 0, { 1, 2 } }, + { /* 1 */ 1, { 0, 0 } }, + { /* 2 */ 0, { 1, 2 } }, + { /* 3 */ 0, { 2, 3 } }, + { /* 4 */ 0, { 3, 4 } }, + { /* 5 */ 1, { 1, 0 } }, + { /* 6 */ 1, { 0, 1 } }, + { /* 7 */ 0, { 2, 3 } }, + { /* 8 */ 0, { 3, 4 } }, + { /* 9 */ 1, { 1, 1 } }, + { /* 10 */ 0, { 3, 4 } }, + { /* 11 */ 0, { 4, 5 } }, + { /* 12 */ 0, { 5, 6 } }, + { /* 13 */ 0, { 6, 7 } }, + { /* 14 */ 0, { 7, 8 } }, + { /* 15 */ 0, { 8, 9 } }, + { /* 16 */ 0, { 9, 10 } }, + { /* 17 */ 0, { 10, 11 } }, + { /* 18 */ 0, { 11, 12 } }, + { /* 19 */ 1, { 2, 1 } }, + { /* 20 */ 1, { 1, 2 } }, + { /* 21 */ 1, { 2, 0 } }, + { /* 22 */ 1, { 0, 2 } }, + { /* 23 */ 0, { 8, 9 } }, + { /* 24 */ 0, { 9, 10 } }, + { /* 25 */ 0, { 10, 11 } }, + { /* 26 */ 0, { 11, 12 } }, + { /* 27 */ 0, { 12, 13 } }, + { /* 28 */ 0, { 13, 14 } }, + { /* 29 */ 0, { 14, 15 } }, + { /* 30 */ 0, { 15, 16 } }, + { /* 31 */ 1, { 3, 1 } }, + { /* 32 */ 1, { 1, 3 } }, + { /* 33 */ 1, { 2, 2 } }, + { /* 34 */ 1, { 3, 0 } }, + { /* 35 */ 1, { 0, 3 } }, + { /* 36 */ 0, { 11, 12 } }, + { /* 37 */ 0, { 12, 13 } }, + { /* 38 */ 0, { 13, 14 } }, + { /* 39 */ 0, { 14, 15 } }, + { /* 40 */ 0, { 15, 16 } }, + { /* 41 */ 0, { 16, 17 } }, + { /* 42 */ 0, { 17, 18 } }, + { /* 43 */ 0, { 18, 19 } }, + { /* 44 */ 0, { 19, 20 } }, + { /* 45 */ 0, { 20, 21 } }, + { /* 46 */ 0, { 21, 22 } }, + { /* 47 */ 1, { 2, 3 } }, + { /* 48 */ 1, { 3, 2 } }, + { /* 49 */ 1, { 1, 4 } }, + { /* 50 */ 1, { 4, 1 } }, + { /* 51 */ 1, { 1, 5 } }, + { /* 52 */ 1, { 5, 1 } }, + { /* 53 */ 1, { 3, 3 } }, + { /* 54 */ 1, { 2, 4 } }, + { /* 55 */ 1, { 0, 4 } }, + { /* 56 */ 1, { 4, 0 } }, + { /* 57 */ 0, { 12, 13 } }, + { /* 58 */ 0, { 13, 14 } }, + { /* 59 */ 0, { 14, 15 } }, + { /* 60 */ 0, { 15, 16 } }, + { /* 61 */ 0, { 16, 17 } }, + { /* 62 */ 0, { 17, 18 } }, + { /* 63 */ 0, { 18, 19 } }, + { /* 64 */ 0, { 19, 20 } }, + { /* 65 */ 0, { 20, 21 } }, + { /* 66 */ 0, { 21, 22 } }, + { /* 67 */ 0, { 22, 23 } }, + { /* 68 */ 0, { 23, 24 } }, + { /* 69 */ 1, { 4, 2 } }, + { /* 70 */ 1, { 2, 5 } }, + { /* 71 */ 1, { 5, 2 } }, + { /* 72 */ 1, { 0, 5 } }, + { /* 73 */ 1, { 6, 1 } }, + { /* 74 */ 1, { 5, 0 } }, + { /* 75 */ 1, { 1, 6 } }, + { /* 76 */ 1, { 4, 3 } }, + { /* 77 */ 1, { 3, 5 } }, + { /* 78 */ 1, { 3, 4 } }, + { /* 79 */ 1, { 5, 3 } }, + { /* 80 */ 1, { 2, 6 } }, + { /* 81 */ 1, { 6, 2 } }, + { /* 82 */ 1, { 1, 7 } }, + { /* 83 */ 0, { 10, 11 } }, + { /* 84 */ 0, { 11, 12 } }, + { /* 85 */ 0, { 12, 13 } }, + { /* 86 */ 0, { 13, 14 } }, + { /* 87 */ 0, { 14, 15 } }, + { /* 88 */ 0, { 15, 16 } }, + { /* 89 */ 0, { 16, 17 } }, + { /* 90 */ 0, { 17, 18 } }, + { /* 91 */ 0, { 18, 19 } }, + { /* 92 */ 0, { 19, 20 } }, + { /* 93 */ 1, { 3, 6 } }, + { /* 94 */ 1, { 0, 6 } }, + { /* 95 */ 1, { 6, 0 } }, + { /* 96 */ 1, { 4, 4 } }, + { /* 97 */ 1, { 7, 1 } }, + { /* 98 */ 1, { 4, 5 } }, + { /* 99 */ 1, { 7, 2 } }, + { /* 00 */ 1, { 5, 4 } }, + { /* 01 */ 1, { 6, 3 } }, + { /* 02 */ 1, { 2, 7 } }, + { /* 03 */ 1, { 7, 3 } }, + { /* 04 */ 1, { 6, 4 } }, + { /* 05 */ 1, { 5, 5 } }, + { /* 06 */ 1, { 4, 6 } }, + { /* 07 */ 1, { 3, 7 } }, + { /* 08 */ 0, { 5, 6 } }, + { /* 09 */ 0, { 6, 7 } }, + { /* 10 */ 0, { 7, 8 } }, + { /* 11 */ 0, { 8, 9 } }, + { /* 12 */ 0, { 9, 10 } }, + { /* 13 */ 1, { 7, 0 } }, + { /* 14 */ 1, { 0, 7 } }, + { /* 15 */ 1, { 6, 5 } }, + { /* 16 */ 1, { 5, 6 } }, + { /* 17 */ 1, { 7, 4 } }, + { /* 18 */ 1, { 4, 7 } }, + { /* 19 */ 1, { 5, 7 } }, + { /* 20 */ 1, { 7, 5 } }, + { /* 21 */ 0, { 2, 3 } }, + { /* 22 */ 0, { 3, 4 } }, + { /* 23 */ 1, { 7, 6 } }, + { /* 24 */ 1, { 6, 6 } }, + { /* 25 */ 1, { 6, 7 } }, + { /* 26 */ 1, { 7, 7 } } +}; diff --git a/lib/rbcodec/codecs/libfaad/codebook/hcb_8.h b/lib/rbcodec/codecs/libfaad/codebook/hcb_8.h new file mode 100644 index 0000000000..b76eb8f667 --- /dev/null +++ b/lib/rbcodec/codecs/libfaad/codebook/hcb_8.h @@ -0,0 +1,170 @@ +/* +** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding +** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +** +** Any non-GPL usage of this software or parts of this software is strictly +** forbidden. +** +** Commercial non-GPL licensing of this software is possible. +** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** +** $Id$ +**/ + +/* 2-step huffman table HCB_8 */ + + +/* 1st step: 5 bits + * 2^5 = 32 entries + * + * Used to find offset into 2nd step table and number of extra bits to get + */ +static hcb hcb8_1[] ICONST_ATTR = { + /* 3 bit codeword */ + { /* 00000 */ 0, 0 }, + { /* */ 0, 0 }, + { /* */ 0, 0 }, + { /* */ 0, 0 }, + + /* 4 bit codewords */ + { /* 00100 */ 1, 0 }, + { /* */ 1, 0 }, + { /* 00110 */ 2, 0 }, + { /* */ 2, 0 }, + { /* 01000 */ 3, 0 }, + { /* */ 3, 0 }, + { /* 01010 */ 4, 0 }, + { /* */ 4, 0 }, + { /* 01100 */ 5, 0 }, + { /* */ 5, 0 }, + + /* 5 bit codewords */ + { /* 01110 */ 6, 0 }, + { /* 01111 */ 7, 0 }, + { /* 10000 */ 8, 0 }, + { /* 10001 */ 9, 0 }, + { /* 10010 */ 10, 0 }, + { /* 10011 */ 11, 0 }, + { /* 10100 */ 12, 0 }, + + /* 6 bit codewords */ + { /* 10101 */ 13, 1 }, + { /* 10110 */ 15, 1 }, + { /* 10111 */ 17, 1 }, + { /* 11000 */ 19, 1 }, + { /* 11001 */ 21, 1 }, + + /* 7 bit codewords */ + { /* 11010 */ 23, 2 }, + { /* 11011 */ 27, 2 }, + { /* 11100 */ 31, 2 }, + + /* 7/8 bit codewords */ + { /* 11101 */ 35, 3 }, + + /* 8 bit codewords */ + { /* 11110 */ 43, 3 }, + + /* 8/9/10 bit codewords */ + { /* 11111 */ 51, 5 } +}; + +/* 2nd step table + * + * Gives size of codeword and actual data (x,y,v,w) + */ +static hcb_2_pair hcb8_2[] ICONST_ATTR = { + /* 3 bit codeword */ + { 3, 1, 1 }, + + /* 4 bit codewords */ + { 4, 2, 1 }, + { 4, 1, 0 }, + { 4, 1, 2 }, + { 4, 0, 1 }, + { 4, 2, 2 }, + + /* 5 bit codewords */ + { 5, 0, 0 }, + { 5, 2, 0 }, + { 5, 0, 2 }, + { 5, 3, 1 }, + { 5, 1, 3 }, + { 5, 3, 2 }, + { 5, 2, 3 }, + + /* 6 bit codewords */ + { 6, 3, 3 }, + { 6, 4, 1 }, + { 6, 1, 4 }, + { 6, 4, 2 }, + { 6, 2, 4 }, + { 6, 3, 0 }, + { 6, 0, 3 }, + { 6, 4, 3 }, + { 6, 3, 4 }, + { 6, 5, 2 }, + + /* 7 bit codewords */ + { 7, 5, 1 }, + { 7, 2, 5 }, + { 7, 1, 5 }, + { 7, 5, 3 }, + { 7, 3, 5 }, + { 7, 4, 4 }, + { 7, 5, 4 }, + { 7, 0, 4 }, + { 7, 4, 5 }, + { 7, 4, 0 }, + { 7, 2, 6 }, + { 7, 6, 2 }, + + /* 7/8 bit codewords */ + { 7, 6, 1 }, { 7, 6, 1 }, + { 7, 1, 6 }, { 7, 1, 6 }, + { 8, 3, 6 }, + { 8, 6, 3 }, + { 8, 5, 5 }, + { 8, 5, 0 }, + + /* 8 bit codewords */ + { 8, 6, 4 }, + { 8, 0, 5 }, + { 8, 4, 6 }, + { 8, 7, 1 }, + { 8, 7, 2 }, + { 8, 2, 7 }, + { 8, 6, 5 }, + { 8, 7, 3 }, + + /* 8/9/10 bit codewords */ + { 8, 1, 7 }, { 8, 1, 7 }, { 8, 1, 7 }, { 8, 1, 7 }, + { 8, 5, 6 }, { 8, 5, 6 }, { 8, 5, 6 }, { 8, 5, 6 }, + { 8, 3, 7 }, { 8, 3, 7 }, { 8, 3, 7 }, { 8, 3, 7 }, + { 9, 6, 6 }, { 9, 6, 6 }, + { 9, 7, 4 }, { 9, 7, 4 }, + { 9, 6, 0 }, { 9, 6, 0 }, + { 9, 4, 7 }, { 9, 4, 7 }, + { 9, 0, 6 }, { 9, 0, 6 }, + { 9, 7, 5 }, { 9, 7, 5 }, + { 9, 7, 6 }, { 9, 7, 6 }, + { 9, 6, 7 }, { 9, 6, 7 }, + { 10, 5, 7 }, + { 10, 7, 0 }, + { 10, 0, 7 }, + { 10, 7, 7 } +}; diff --git a/lib/rbcodec/codecs/libfaad/codebook/hcb_9.h b/lib/rbcodec/codecs/libfaad/codebook/hcb_9.h new file mode 100644 index 0000000000..2932001294 --- /dev/null +++ b/lib/rbcodec/codecs/libfaad/codebook/hcb_9.h @@ -0,0 +1,369 @@ +/* +** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding +** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +** +** Any non-GPL usage of this software or parts of this software is strictly +** forbidden. +** +** Commercial non-GPL licensing of this software is possible. +** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** +** $Id$ +**/ + +/* Binary search huffman table HCB_9 */ + + +static hcb_bin_pair hcb9[] ICONST_ATTR_FAAD_LARGE_IRAM = { + { /* 0 */ 0, { 1, 2 } }, + { /* 1 */ 1, { 0, 0 } }, + { /* 2 */ 0, { 1, 2 } }, + { /* 3 */ 0, { 2, 3 } }, + { /* 4 */ 0, { 3, 4 } }, + { /* 5 */ 1, { 1, 0 } }, + { /* 6 */ 1, { 0, 1 } }, + { /* 7 */ 0, { 2, 3 } }, + { /* 8 */ 0, { 3, 4 } }, + { /* 9 */ 1, { 1, 1 } }, + { /* 10 */ 0, { 3, 4 } }, + { /* 11 */ 0, { 4, 5 } }, + { /* 12 */ 0, { 5, 6 } }, + { /* 13 */ 0, { 6, 7 } }, + { /* 14 */ 0, { 7, 8 } }, + { /* 15 */ 0, { 8, 9 } }, + { /* 16 */ 0, { 9, 10 } }, + { /* 17 */ 0, { 10, 11 } }, + { /* 18 */ 0, { 11, 12 } }, + { /* 19 */ 1, { 2, 1 } }, + { /* 20 */ 1, { 1, 2 } }, + { /* 21 */ 1, { 2, 0 } }, + { /* 22 */ 1, { 0, 2 } }, + { /* 23 */ 0, { 8, 9 } }, + { /* 24 */ 0, { 9, 10 } }, + { /* 25 */ 0, { 10, 11 } }, + { /* 26 */ 0, { 11, 12 } }, + { /* 27 */ 0, { 12, 13 } }, + { /* 28 */ 0, { 13, 14 } }, + { /* 29 */ 0, { 14, 15 } }, + { /* 30 */ 0, { 15, 16 } }, + { /* 31 */ 1, { 3, 1 } }, + { /* 32 */ 1, { 2, 2 } }, + { /* 33 */ 1, { 1, 3 } }, + { /* 34 */ 0, { 13, 14 } }, + { /* 35 */ 0, { 14, 15 } }, + { /* 36 */ 0, { 15, 16 } }, + { /* 37 */ 0, { 16, 17 } }, + { /* 38 */ 0, { 17, 18 } }, + { /* 39 */ 0, { 18, 19 } }, + { /* 40 */ 0, { 19, 20 } }, + { /* 41 */ 0, { 20, 21 } }, + { /* 42 */ 0, { 21, 22 } }, + { /* 43 */ 0, { 22, 23 } }, + { /* 44 */ 0, { 23, 24 } }, + { /* 45 */ 0, { 24, 25 } }, + { /* 46 */ 0, { 25, 26 } }, + { /* 47 */ 1, { 3, 0 } }, + { /* 48 */ 1, { 0, 3 } }, + { /* 49 */ 1, { 2, 3 } }, + { /* 50 */ 1, { 3, 2 } }, + { /* 51 */ 1, { 1, 4 } }, + { /* 52 */ 1, { 4, 1 } }, + { /* 53 */ 1, { 2, 4 } }, + { /* 54 */ 1, { 1, 5 } }, + { /* 55 */ 0, { 18, 19 } }, + { /* 56 */ 0, { 19, 20 } }, + { /* 57 */ 0, { 20, 21 } }, + { /* 58 */ 0, { 21, 22 } }, + { /* 59 */ 0, { 22, 23 } }, + { /* 60 */ 0, { 23, 24 } }, + { /* 61 */ 0, { 24, 25 } }, + { /* 62 */ 0, { 25, 26 } }, + { /* 63 */ 0, { 26, 27 } }, + { /* 64 */ 0, { 27, 28 } }, + { /* 65 */ 0, { 28, 29 } }, + { /* 66 */ 0, { 29, 30 } }, + { /* 67 */ 0, { 30, 31 } }, + { /* 68 */ 0, { 31, 32 } }, + { /* 69 */ 0, { 32, 33 } }, + { /* 70 */ 0, { 33, 34 } }, + { /* 71 */ 0, { 34, 35 } }, + { /* 72 */ 0, { 35, 36 } }, + { /* 73 */ 1, { 4, 2 } }, + { /* 74 */ 1, { 3, 3 } }, + { /* 75 */ 1, { 0, 4 } }, + { /* 76 */ 1, { 4, 0 } }, + { /* 77 */ 1, { 5, 1 } }, + { /* 78 */ 1, { 2, 5 } }, + { /* 79 */ 1, { 1, 6 } }, + { /* 80 */ 1, { 3, 4 } }, + { /* 81 */ 1, { 5, 2 } }, + { /* 82 */ 1, { 6, 1 } }, + { /* 83 */ 1, { 4, 3 } }, + { /* 84 */ 0, { 25, 26 } }, + { /* 85 */ 0, { 26, 27 } }, + { /* 86 */ 0, { 27, 28 } }, + { /* 87 */ 0, { 28, 29 } }, + { /* 88 */ 0, { 29, 30 } }, + { /* 89 */ 0, { 30, 31 } }, + { /* 90 */ 0, { 31, 32 } }, + { /* 91 */ 0, { 32, 33 } }, + { /* 92 */ 0, { 33, 34 } }, + { /* 93 */ 0, { 34, 35 } }, + { /* 94 */ 0, { 35, 36 } }, + { /* 95 */ 0, { 36, 37 } }, + { /* 96 */ 0, { 37, 38 } }, + { /* 97 */ 0, { 38, 39 } }, + { /* 98 */ 0, { 39, 40 } }, + { /* 99 */ 0, { 40, 41 } }, + { /* 00 */ 0, { 41, 42 } }, + { /* 01 */ 0, { 42, 43 } }, + { /* 02 */ 0, { 43, 44 } }, + { /* 03 */ 0, { 44, 45 } }, + { /* 04 */ 0, { 45, 46 } }, + { /* 05 */ 0, { 46, 47 } }, + { /* 06 */ 0, { 47, 48 } }, + { /* 07 */ 0, { 48, 49 } }, + { /* 08 */ 0, { 49, 50 } }, + { /* 09 */ 1, { 0, 5 } }, + { /* 10 */ 1, { 2, 6 } }, + { /* 11 */ 1, { 5, 0 } }, + { /* 12 */ 1, { 1, 7 } }, + { /* 13 */ 1, { 3, 5 } }, + { /* 14 */ 1, { 1, 8 } }, + { /* 15 */ 1, { 8, 1 } }, + { /* 16 */ 1, { 4, 4 } }, + { /* 17 */ 1, { 5, 3 } }, + { /* 18 */ 1, { 6, 2 } }, + { /* 19 */ 1, { 7, 1 } }, + { /* 20 */ 1, { 0, 6 } }, + { /* 21 */ 1, { 8, 2 } }, + { /* 22 */ 1, { 2, 8 } }, + { /* 23 */ 1, { 3, 6 } }, + { /* 24 */ 1, { 2, 7 } }, + { /* 25 */ 1, { 4, 5 } }, + { /* 26 */ 1, { 9, 1 } }, + { /* 27 */ 1, { 1, 9 } }, + { /* 28 */ 1, { 7, 2 } }, + { /* 29 */ 0, { 30, 31 } }, + { /* 30 */ 0, { 31, 32 } }, + { /* 31 */ 0, { 32, 33 } }, + { /* 32 */ 0, { 33, 34 } }, + { /* 33 */ 0, { 34, 35 } }, + { /* 34 */ 0, { 35, 36 } }, + { /* 35 */ 0, { 36, 37 } }, + { /* 36 */ 0, { 37, 38 } }, + { /* 37 */ 0, { 38, 39 } }, + { /* 38 */ 0, { 39, 40 } }, + { /* 39 */ 0, { 40, 41 } }, + { /* 40 */ 0, { 41, 42 } }, + { /* 41 */ 0, { 42, 43 } }, + { /* 42 */ 0, { 43, 44 } }, + { /* 43 */ 0, { 44, 45 } }, + { /* 44 */ 0, { 45, 46 } }, + { /* 45 */ 0, { 46, 47 } }, + { /* 46 */ 0, { 47, 48 } }, + { /* 47 */ 0, { 48, 49 } }, + { /* 48 */ 0, { 49, 50 } }, + { /* 49 */ 0, { 50, 51 } }, + { /* 50 */ 0, { 51, 52 } }, + { /* 51 */ 0, { 52, 53 } }, + { /* 52 */ 0, { 53, 54 } }, + { /* 53 */ 0, { 54, 55 } }, + { /* 54 */ 0, { 55, 56 } }, + { /* 55 */ 0, { 56, 57 } }, + { /* 56 */ 0, { 57, 58 } }, + { /* 57 */ 0, { 58, 59 } }, + { /* 58 */ 0, { 59, 60 } }, + { /* 59 */ 1, { 6, 0 } }, + { /* 60 */ 1, { 5, 4 } }, + { /* 61 */ 1, { 6, 3 } }, + { /* 62 */ 1, { 8, 3 } }, + { /* 63 */ 1, { 0, 7 } }, + { /* 64 */ 1, { 9, 2 } }, + { /* 65 */ 1, { 3, 8 } }, + { /* 66 */ 1, { 4, 6 } }, + { /* 67 */ 1, { 3, 7 } }, + { /* 68 */ 1, { 0, 8 } }, + { /* 69 */ 1, { 10, 1 } }, + { /* 70 */ 1, { 6, 4 } }, + { /* 71 */ 1, { 2, 9 } }, + { /* 72 */ 1, { 5, 5 } }, + { /* 73 */ 1, { 8, 0 } }, + { /* 74 */ 1, { 7, 0 } }, + { /* 75 */ 1, { 7, 3 } }, + { /* 76 */ 1, { 10, 2 } }, + { /* 77 */ 1, { 9, 3 } }, + { /* 78 */ 1, { 8, 4 } }, + { /* 79 */ 1, { 1, 10 } }, + { /* 80 */ 1, { 7, 4 } }, + { /* 81 */ 1, { 6, 5 } }, + { /* 82 */ 1, { 5, 6 } }, + { /* 83 */ 1, { 4, 8 } }, + { /* 84 */ 1, { 4, 7 } }, + { /* 85 */ 1, { 3, 9 } }, + { /* 86 */ 1, { 11, 1 } }, + { /* 87 */ 1, { 5, 8 } }, + { /* 88 */ 1, { 9, 0 } }, + { /* 89 */ 1, { 8, 5 } }, + { /* 90 */ 0, { 29, 30 } }, + { /* 91 */ 0, { 30, 31 } }, + { /* 92 */ 0, { 31, 32 } }, + { /* 93 */ 0, { 32, 33 } }, + { /* 94 */ 0, { 33, 34 } }, + { /* 95 */ 0, { 34, 35 } }, + { /* 96 */ 0, { 35, 36 } }, + { /* 97 */ 0, { 36, 37 } }, + { /* 98 */ 0, { 37, 38 } }, + { /* 99 */ 0, { 38, 39 } }, + { /* 00 */ 0, { 39, 40 } }, + { /* 01 */ 0, { 40, 41 } }, + { /* 02 */ 0, { 41, 42 } }, + { /* 03 */ 0, { 42, 43 } }, + { /* 04 */ 0, { 43, 44 } }, + { /* 05 */ 0, { 44, 45 } }, + { /* 06 */ 0, { 45, 46 } }, + { /* 07 */ 0, { 46, 47 } }, + { /* 08 */ 0, { 47, 48 } }, + { /* 09 */ 0, { 48, 49 } }, + { /* 10 */ 0, { 49, 50 } }, + { /* 11 */ 0, { 50, 51 } }, + { /* 12 */ 0, { 51, 52 } }, + { /* 13 */ 0, { 52, 53 } }, + { /* 14 */ 0, { 53, 54 } }, + { /* 15 */ 0, { 54, 55 } }, + { /* 16 */ 0, { 55, 56 } }, + { /* 17 */ 0, { 56, 57 } }, + { /* 18 */ 0, { 57, 58 } }, + { /* 19 */ 1, { 10, 3 } }, + { /* 20 */ 1, { 2, 10 } }, + { /* 21 */ 1, { 0, 9 } }, + { /* 22 */ 1, { 11, 2 } }, + { /* 23 */ 1, { 9, 4 } }, + { /* 24 */ 1, { 6, 6 } }, + { /* 25 */ 1, { 12, 1 } }, + { /* 26 */ 1, { 4, 9 } }, + { /* 27 */ 1, { 8, 6 } }, + { /* 28 */ 1, { 1, 11 } }, + { /* 29 */ 1, { 9, 5 } }, + { /* 30 */ 1, { 10, 4 } }, + { /* 31 */ 1, { 5, 7 } }, + { /* 32 */ 1, { 7, 5 } }, + { /* 33 */ 1, { 2, 11 } }, + { /* 34 */ 1, { 1, 12 } }, + { /* 35 */ 1, { 12, 2 } }, + { /* 36 */ 1, { 11, 3 } }, + { /* 37 */ 1, { 3, 10 } }, + { /* 38 */ 1, { 5, 9 } }, + { /* 39 */ 1, { 6, 7 } }, + { /* 40 */ 1, { 8, 7 } }, + { /* 41 */ 1, { 11, 4 } }, + { /* 42 */ 1, { 0, 10 } }, + { /* 43 */ 1, { 7, 6 } }, + { /* 44 */ 1, { 12, 3 } }, + { /* 45 */ 1, { 10, 0 } }, + { /* 46 */ 1, { 10, 5 } }, + { /* 47 */ 1, { 4, 10 } }, + { /* 48 */ 1, { 6, 8 } }, + { /* 49 */ 1, { 2, 12 } }, + { /* 50 */ 1, { 9, 6 } }, + { /* 51 */ 1, { 9, 7 } }, + { /* 52 */ 1, { 4, 11 } }, + { /* 53 */ 1, { 11, 0 } }, + { /* 54 */ 1, { 6, 9 } }, + { /* 55 */ 1, { 3, 11 } }, + { /* 56 */ 1, { 5, 10 } }, + { /* 57 */ 0, { 20, 21 } }, + { /* 58 */ 0, { 21, 22 } }, + { /* 59 */ 0, { 22, 23 } }, + { /* 60 */ 0, { 23, 24 } }, + { /* 61 */ 0, { 24, 25 } }, + { /* 62 */ 0, { 25, 26 } }, + { /* 63 */ 0, { 26, 27 } }, + { /* 64 */ 0, { 27, 28 } }, + { /* 65 */ 0, { 28, 29 } }, + { /* 66 */ 0, { 29, 30 } }, + { /* 67 */ 0, { 30, 31 } }, + { /* 68 */ 0, { 31, 32 } }, + { /* 69 */ 0, { 32, 33 } }, + { /* 70 */ 0, { 33, 34 } }, + { /* 71 */ 0, { 34, 35 } }, + { /* 72 */ 0, { 35, 36 } }, + { /* 73 */ 0, { 36, 37 } }, + { /* 74 */ 0, { 37, 38 } }, + { /* 75 */ 0, { 38, 39 } }, + { /* 76 */ 0, { 39, 40 } }, + { /* 77 */ 1, { 8, 8 } }, + { /* 78 */ 1, { 7, 8 } }, + { /* 79 */ 1, { 12, 5 } }, + { /* 80 */ 1, { 3, 12 } }, + { /* 81 */ 1, { 11, 5 } }, + { /* 82 */ 1, { 7, 7 } }, + { /* 83 */ 1, { 12, 4 } }, + { /* 84 */ 1, { 11, 6 } }, + { /* 85 */ 1, { 10, 6 } }, + { /* 86 */ 1, { 4, 12 } }, + { /* 87 */ 1, { 7, 9 } }, + { /* 88 */ 1, { 5, 11 } }, + { /* 89 */ 1, { 0, 11 } }, + { /* 90 */ 1, { 12, 6 } }, + { /* 91 */ 1, { 6, 10 } }, + { /* 92 */ 1, { 12, 0 } }, + { /* 93 */ 1, { 10, 7 } }, + { /* 94 */ 1, { 5, 12 } }, + { /* 95 */ 1, { 7, 10 } }, + { /* 96 */ 1, { 9, 8 } }, + { /* 97 */ 1, { 0, 12 } }, + { /* 98 */ 1, { 11, 7 } }, + { /* 99 */ 1, { 8, 9 } }, + { /* 00 */ 1, { 9, 9 } }, + { /* 01 */ 1, { 10, 8 } }, + { /* 02 */ 1, { 7, 11 } }, + { /* 03 */ 1, { 12, 7 } }, + { /* 04 */ 1, { 6, 11 } }, + { /* 05 */ 1, { 8, 11 } }, + { /* 06 */ 1, { 11, 8 } }, + { /* 07 */ 1, { 7, 12 } }, + { /* 08 */ 1, { 6, 12 } }, + { /* 09 */ 0, { 8, 9 } }, + { /* 10 */ 0, { 9, 10 } }, + { /* 11 */ 0, { 10, 11 } }, + { /* 12 */ 0, { 11, 12 } }, + { /* 13 */ 0, { 12, 13 } }, + { /* 14 */ 0, { 13, 14 } }, + { /* 15 */ 0, { 14, 15 } }, + { /* 16 */ 0, { 15, 16 } }, + { /* 17 */ 1, { 8, 10 } }, + { /* 18 */ 1, { 10, 9 } }, + { /* 19 */ 1, { 8, 12 } }, + { /* 20 */ 1, { 9, 10 } }, + { /* 21 */ 1, { 9, 11 } }, + { /* 22 */ 1, { 9, 12 } }, + { /* 23 */ 1, { 10, 11 } }, + { /* 24 */ 1, { 12, 9 } }, + { /* 25 */ 1, { 10, 10 } }, + { /* 26 */ 1, { 11, 9 } }, + { /* 27 */ 1, { 12, 8 } }, + { /* 28 */ 1, { 11, 10 } }, + { /* 29 */ 1, { 12, 10 } }, + { /* 30 */ 1, { 12, 11 } }, + { /* 31 */ 0, { 2, 3 } }, + { /* 32 */ 0, { 3, 4 } }, + { /* 33 */ 1, { 10, 12 } }, + { /* 34 */ 1, { 11, 11 } }, + { /* 35 */ 1, { 11, 12 } }, + { /* 36 */ 1, { 12, 12 } } +}; diff --git a/lib/rbcodec/codecs/libfaad/codebook/hcb_sf.h b/lib/rbcodec/codecs/libfaad/codebook/hcb_sf.h new file mode 100644 index 0000000000..66762e2fce --- /dev/null +++ b/lib/rbcodec/codecs/libfaad/codebook/hcb_sf.h @@ -0,0 +1,273 @@ +/* +** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding +** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +** +** Any non-GPL usage of this software or parts of this software is strictly +** forbidden. +** +** Commercial non-GPL licensing of this software is possible. +** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** +** $Id$ +**/ + +/* Binary search huffman table HCB_SF */ + + +static uint8_t hcb_sf[][2] ICONST_ATTR_FAAD_LARGE_IRAM = { + { /* 0 */ 1, 2 }, + { /* 1 */ 60, 0 }, + { /* 2 */ 1, 2 }, + { /* 3 */ 2, 3 }, + { /* 4 */ 3, 4 }, + { /* 5 */ 59, 0 }, + { /* 6 */ 3, 4 }, + { /* 7 */ 4, 5 }, + { /* 8 */ 5, 6 }, + { /* 9 */ 61, 0 }, + { /* 10 */ 58, 0 }, + { /* 11 */ 62, 0 }, + { /* 12 */ 3, 4 }, + { /* 13 */ 4, 5 }, + { /* 14 */ 5, 6 }, + { /* 15 */ 57, 0 }, + { /* 16 */ 63, 0 }, + { /* 17 */ 4, 5 }, + { /* 18 */ 5, 6 }, + { /* 19 */ 6, 7 }, + { /* 20 */ 7, 8 }, + { /* 21 */ 56, 0 }, + { /* 22 */ 64, 0 }, + { /* 23 */ 55, 0 }, + { /* 24 */ 65, 0 }, + { /* 25 */ 4, 5 }, + { /* 26 */ 5, 6 }, + { /* 27 */ 6, 7 }, + { /* 28 */ 7, 8 }, + { /* 29 */ 66, 0 }, + { /* 30 */ 54, 0 }, + { /* 31 */ 67, 0 }, + { /* 32 */ 5, 6 }, + { /* 33 */ 6, 7 }, + { /* 34 */ 7, 8 }, + { /* 35 */ 8, 9 }, + { /* 36 */ 9, 10 }, + { /* 37 */ 53, 0 }, + { /* 38 */ 68, 0 }, + { /* 39 */ 52, 0 }, + { /* 40 */ 69, 0 }, + { /* 41 */ 51, 0 }, + { /* 42 */ 5, 6 }, + { /* 43 */ 6, 7 }, + { /* 44 */ 7, 8 }, + { /* 45 */ 8, 9 }, + { /* 46 */ 9, 10 }, + { /* 47 */ 70, 0 }, + { /* 48 */ 50, 0 }, + { /* 49 */ 49, 0 }, + { /* 50 */ 71, 0 }, + { /* 51 */ 6, 7 }, + { /* 52 */ 7, 8 }, + { /* 53 */ 8, 9 }, + { /* 54 */ 9, 10 }, + { /* 55 */ 10, 11 }, + { /* 56 */ 11, 12 }, + { /* 57 */ 72, 0 }, + { /* 58 */ 48, 0 }, + { /* 59 */ 73, 0 }, + { /* 60 */ 47, 0 }, + { /* 61 */ 74, 0 }, + { /* 62 */ 46, 0 }, + { /* 63 */ 6, 7 }, + { /* 64 */ 7, 8 }, + { /* 65 */ 8, 9 }, + { /* 66 */ 9, 10 }, + { /* 67 */ 10, 11 }, + { /* 68 */ 11, 12 }, + { /* 69 */ 76, 0 }, + { /* 70 */ 75, 0 }, + { /* 71 */ 77, 0 }, + { /* 72 */ 78, 0 }, + { /* 73 */ 45, 0 }, + { /* 74 */ 43, 0 }, + { /* 75 */ 6, 7 }, + { /* 76 */ 7, 8 }, + { /* 77 */ 8, 9 }, + { /* 78 */ 9, 10 }, + { /* 79 */ 10, 11 }, + { /* 80 */ 11, 12 }, + { /* 81 */ 44, 0 }, + { /* 82 */ 79, 0 }, + { /* 83 */ 42, 0 }, + { /* 84 */ 41, 0 }, + { /* 85 */ 80, 0 }, + { /* 86 */ 40, 0 }, + { /* 87 */ 6, 7 }, + { /* 88 */ 7, 8 }, + { /* 89 */ 8, 9 }, + { /* 90 */ 9, 10 }, + { /* 91 */ 10, 11 }, + { /* 92 */ 11, 12 }, + { /* 93 */ 81, 0 }, + { /* 94 */ 39, 0 }, + { /* 95 */ 82, 0 }, + { /* 96 */ 38, 0 }, + { /* 97 */ 83, 0 }, + { /* 98 */ 7, 8 }, + { /* 99 */ 8, 9 }, + { /* 00 */ 9, 10 }, + { /* 01 */ 10, 11 }, + { /* 02 */ 11, 12 }, + { /* 03 */ 12, 13 }, + { /* 04 */ 13, 14 }, + { /* 05 */ 37, 0 }, + { /* 06 */ 35, 0 }, + { /* 07 */ 85, 0 }, + { /* 08 */ 33, 0 }, + { /* 09 */ 36, 0 }, + { /* 10 */ 34, 0 }, + { /* 11 */ 84, 0 }, + { /* 12 */ 32, 0 }, + { /* 13 */ 6, 7 }, + { /* 14 */ 7, 8 }, + { /* 15 */ 8, 9 }, + { /* 16 */ 9, 10 }, + { /* 17 */ 10, 11 }, + { /* 18 */ 11, 12 }, + { /* 19 */ 87, 0 }, + { /* 20 */ 89, 0 }, + { /* 21 */ 30, 0 }, + { /* 22 */ 31, 0 }, + { /* 23 */ 8, 9 }, + { /* 24 */ 9, 10 }, + { /* 25 */ 10, 11 }, + { /* 26 */ 11, 12 }, + { /* 27 */ 12, 13 }, + { /* 28 */ 13, 14 }, + { /* 29 */ 14, 15 }, + { /* 30 */ 15, 16 }, + { /* 31 */ 86, 0 }, + { /* 32 */ 29, 0 }, + { /* 33 */ 26, 0 }, + { /* 34 */ 27, 0 }, + { /* 35 */ 28, 0 }, + { /* 36 */ 24, 0 }, + { /* 37 */ 88, 0 }, + { /* 38 */ 9, 10 }, + { /* 39 */ 10, 11 }, + { /* 40 */ 11, 12 }, + { /* 41 */ 12, 13 }, + { /* 42 */ 13, 14 }, + { /* 43 */ 14, 15 }, + { /* 44 */ 15, 16 }, + { /* 45 */ 16, 17 }, + { /* 46 */ 17, 18 }, + { /* 47 */ 25, 0 }, + { /* 48 */ 22, 0 }, + { /* 49 */ 23, 0 }, + { /* 50 */ 15, 16 }, + { /* 51 */ 16, 17 }, + { /* 52 */ 17, 18 }, + { /* 53 */ 18, 19 }, + { /* 54 */ 19, 20 }, + { /* 55 */ 20, 21 }, + { /* 56 */ 21, 22 }, + { /* 57 */ 22, 23 }, + { /* 58 */ 23, 24 }, + { /* 59 */ 24, 25 }, + { /* 60 */ 25, 26 }, + { /* 61 */ 26, 27 }, + { /* 62 */ 27, 28 }, + { /* 63 */ 28, 29 }, + { /* 64 */ 29, 30 }, + { /* 65 */ 90, 0 }, + { /* 66 */ 21, 0 }, + { /* 67 */ 19, 0 }, + { /* 68 */ 3, 0 }, + { /* 69 */ 1, 0 }, + { /* 70 */ 2, 0 }, + { /* 71 */ 0, 0 }, + { /* 72 */ 23, 24 }, + { /* 73 */ 24, 25 }, + { /* 74 */ 25, 26 }, + { /* 75 */ 26, 27 }, + { /* 76 */ 27, 28 }, + { /* 77 */ 28, 29 }, + { /* 78 */ 29, 30 }, + { /* 79 */ 30, 31 }, + { /* 80 */ 31, 32 }, + { /* 81 */ 32, 33 }, + { /* 82 */ 33, 34 }, + { /* 83 */ 34, 35 }, + { /* 84 */ 35, 36 }, + { /* 85 */ 36, 37 }, + { /* 86 */ 37, 38 }, + { /* 87 */ 38, 39 }, + { /* 88 */ 39, 40 }, + { /* 89 */ 40, 41 }, + { /* 90 */ 41, 42 }, + { /* 91 */ 42, 43 }, + { /* 92 */ 43, 44 }, + { /* 93 */ 44, 45 }, + { /* 94 */ 45, 46 }, + { /* 95 */ 98, 0 }, + { /* 96 */ 99, 0 }, + { /* 97 */ 100, 0 }, + { /* 98 */ 101, 0 }, + { /* 99 */ 102, 0 }, + { /* 00 */ 117, 0 }, + { /* 01 */ 97, 0 }, + { /* 02 */ 91, 0 }, + { /* 03 */ 92, 0 }, + { /* 04 */ 93, 0 }, + { /* 05 */ 94, 0 }, + { /* 06 */ 95, 0 }, + { /* 07 */ 96, 0 }, + { /* 08 */ 104, 0 }, + { /* 09 */ 111, 0 }, + { /* 10 */ 112, 0 }, + { /* 11 */ 113, 0 }, + { /* 12 */ 114, 0 }, + { /* 13 */ 115, 0 }, + { /* 14 */ 116, 0 }, + { /* 15 */ 110, 0 }, + { /* 16 */ 105, 0 }, + { /* 17 */ 106, 0 }, + { /* 18 */ 107, 0 }, + { /* 19 */ 108, 0 }, + { /* 20 */ 109, 0 }, + { /* 21 */ 118, 0 }, + { /* 22 */ 6, 0 }, + { /* 23 */ 8, 0 }, + { /* 24 */ 9, 0 }, + { /* 25 */ 10, 0 }, + { /* 26 */ 5, 0 }, + { /* 27 */ 103, 0 }, + { /* 28 */ 120, 0 }, + { /* 29 */ 119, 0 }, + { /* 30 */ 4, 0 }, + { /* 31 */ 7, 0 }, + { /* 32 */ 15, 0 }, + { /* 33 */ 16, 0 }, + { /* 34 */ 18, 0 }, + { /* 35 */ 20, 0 }, + { /* 36 */ 17, 0 }, + { /* 37 */ 11, 0 }, + { /* 38 */ 12, 0 }, + { /* 39 */ 14, 0 }, + { /* 40 */ 13, 0 } +}; diff --git a/lib/rbcodec/codecs/libfaad/common.c b/lib/rbcodec/codecs/libfaad/common.c new file mode 100644 index 0000000000..bedf56a212 --- /dev/null +++ b/lib/rbcodec/codecs/libfaad/common.c @@ -0,0 +1,440 @@ +/* +** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding +** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +** +** Any non-GPL usage of this software or parts of this software is strictly +** forbidden. +** +** Commercial non-GPL licensing of this software is possible. +** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** +** $Id$ +**/ + +/* just some common functions that could be used anywhere */ + +#include "common.h" +#include "structs.h" + +#include +#include "syntax.h" + + +/* Returns the sample rate index based on the samplerate */ +uint8_t get_sr_index(const uint32_t samplerate) +{ + if (92017 <= samplerate) return 0; + if (75132 <= samplerate) return 1; + if (55426 <= samplerate) return 2; + if (46009 <= samplerate) return 3; + if (37566 <= samplerate) return 4; + if (27713 <= samplerate) return 5; + if (23004 <= samplerate) return 6; + if (18783 <= samplerate) return 7; + if (13856 <= samplerate) return 8; + if (11502 <= samplerate) return 9; + if (9391 <= samplerate) return 10; + if (16428320 <= samplerate) return 11; + + return 11; +} + +/* Returns the sample rate based on the sample rate index */ +uint32_t get_sample_rate(const uint8_t sr_index) +{ + static const uint32_t sample_rates[] = + { + 96000, 88200, 64000, 48000, 44100, 32000, + 24000, 22050, 16000, 12000, 11025, 8000 + }; + + if (sr_index < 12) + return sample_rates[sr_index]; + + return 0; +} + +uint8_t max_pred_sfb(const uint8_t sr_index) +{ + static const uint8_t pred_sfb_max[] = + { + 33, 33, 38, 40, 40, 40, 41, 41, 37, 37, 37, 34 + }; + + + if (sr_index < 12) + return pred_sfb_max[sr_index]; + + return 0; +} + +uint8_t max_tns_sfb(const uint8_t sr_index, const uint8_t object_type, + const uint8_t is_short) +{ + /* entry for each sampling rate + * 1 Main/LC long window + * 2 Main/LC short window + * 3 SSR long window + * 4 SSR short window + */ + static const uint8_t tns_sbf_max[][4] = + { + {31, 9, 28, 7}, /* 96000 */ + {31, 9, 28, 7}, /* 88200 */ + {34, 10, 27, 7}, /* 64000 */ + {40, 14, 26, 6}, /* 48000 */ + {42, 14, 26, 6}, /* 44100 */ + {51, 14, 26, 6}, /* 32000 */ + {46, 14, 29, 7}, /* 24000 */ + {46, 14, 29, 7}, /* 22050 */ + {42, 14, 23, 8}, /* 16000 */ + {42, 14, 23, 8}, /* 12000 */ + {42, 14, 23, 8}, /* 11025 */ + {39, 14, 19, 7}, /* 8000 */ + {39, 14, 19, 7}, /* 7350 */ + {0,0,0,0}, + {0,0,0,0}, + {0,0,0,0} + }; + uint8_t i = 0; + + if (is_short) i++; + if (object_type == SSR) i += 2; + + return tns_sbf_max[sr_index][i]; +} + +/* Returns 0 if an object type is decodable, otherwise returns -1 */ +int8_t can_decode_ot(const uint8_t object_type) +{ + switch (object_type) + { + case LC: + return 0; + case MAIN: +#ifdef MAIN_DEC + return 0; +#else + return -1; +#endif + case SSR: +#ifdef SSR_DEC + return 0; +#else + return -1; +#endif + case LTP: +#ifdef LTP_DEC + return 0; +#else + return -1; +#endif + + /* ER object types */ +#ifdef ERROR_RESILIENCE + case ER_LC: +#ifdef DRM + case DRM_ER_LC: +#endif + return 0; + case ER_LTP: +#ifdef LTP_DEC + return 0; +#else + return -1; +#endif + case LD: +#ifdef LD_DEC + return 0; +#else + return -1; +#endif +#endif + } + + return -1; +} + +static const uint8_t Parity [256] = { // parity + 0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1, + 1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0, + 1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0, + 0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1, + 1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0, + 0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1, + 0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1, + 1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0 +}; + +static uint32_t __r1 = 1; +static uint32_t __r2 = 1; + + +/* + * This is a simple random number generator with good quality for audio purposes. + * It consists of two polycounters with opposite rotation direction and different + * periods. The periods are coprime, so the total period is the product of both. + * + * ------------------------------------------------------------------------------------------------- + * +-> |31:30:29:28:27:26:25:24:23:22:21:20:19:18:17:16:15:14:13:12:11:10: 9: 8: 7: 6: 5: 4: 3: 2: 1: 0| + * | ------------------------------------------------------------------------------------------------- + * | | | | | | | + * | +--+--+--+-XOR-+--------+ + * | | + * +--------------------------------------------------------------------------------------+ + * + * ------------------------------------------------------------------------------------------------- + * |31:30:29:28:27:26:25:24:23:22:21:20:19:18:17:16:15:14:13:12:11:10: 9: 8: 7: 6: 5: 4: 3: 2: 1: 0| <-+ + * ------------------------------------------------------------------------------------------------- | + * | | | | | + * +--+----XOR----+--+ | + * | | + * +----------------------------------------------------------------------------------------+ + * + * + * The first has an period of 3*5*17*257*65537, the second of 7*47*73*178481, + * which gives a period of 18.410.713.077.675.721.215. The result is the + * XORed values of both generators. + */ +uint32_t random_int(void) +{ + uint32_t t1, t2, t3, t4; + + t3 = t1 = __r1; t4 = t2 = __r2; // Parity calculation is done via table lookup, this is also available + t1 &= 0xF5; t2 >>= 25; // on CPUs without parity, can be implemented in C and avoid unpredictable + t1 = Parity [t1]; t2 &= 0x63; // jumps and slow rotate through the carry flag operations. + t1 <<= 31; t2 = Parity [t2]; + + return (__r1 = (t3 >> 1) | t1 ) ^ (__r2 = (t4 + t4) | t2 ); +} + +#define floor_log2(x) bs_generic(x, BS_LOG2) + +#ifdef FIXED_POINT + +#define TABLE_BITS 6 +/* just take the maximum number of bits for interpolation */ +#define INTERP_BITS (REAL_BITS-TABLE_BITS) + +static const real_t pow2_tab[] ICONST_ATTR = { + REAL_CONST(1.000000000000000), REAL_CONST(1.010889286051701), REAL_CONST(1.021897148654117), + REAL_CONST(1.033024879021228), REAL_CONST(1.044273782427414), REAL_CONST(1.055645178360557), + REAL_CONST(1.067140400676824), REAL_CONST(1.078760797757120), REAL_CONST(1.090507732665258), + REAL_CONST(1.102382583307841), REAL_CONST(1.114386742595892), REAL_CONST(1.126521618608242), + REAL_CONST(1.138788634756692), REAL_CONST(1.151189229952983), REAL_CONST(1.163724858777578), + REAL_CONST(1.176396991650281), REAL_CONST(1.189207115002721), REAL_CONST(1.202156731452703), + REAL_CONST(1.215247359980469), REAL_CONST(1.228480536106870), REAL_CONST(1.241857812073484), + REAL_CONST(1.255380757024691), REAL_CONST(1.269050957191733), REAL_CONST(1.282870016078778), + REAL_CONST(1.296839554651010), REAL_CONST(1.310961211524764), REAL_CONST(1.325236643159741), + REAL_CONST(1.339667524053303), REAL_CONST(1.354255546936893), REAL_CONST(1.369002422974591), + REAL_CONST(1.383909881963832), REAL_CONST(1.398979672538311), REAL_CONST(1.414213562373095), + REAL_CONST(1.429613338391970), REAL_CONST(1.445180806977047), REAL_CONST(1.460917794180647), + REAL_CONST(1.476826145939499), REAL_CONST(1.492907728291265), REAL_CONST(1.509164427593423), + REAL_CONST(1.525598150744538), REAL_CONST(1.542210825407941), REAL_CONST(1.559004400237837), + REAL_CONST(1.575980845107887), REAL_CONST(1.593142151342267), REAL_CONST(1.610490331949254), + REAL_CONST(1.628027421857348), REAL_CONST(1.645755478153965), REAL_CONST(1.663676580326736), + REAL_CONST(1.681792830507429), REAL_CONST(1.700106353718524), REAL_CONST(1.718619298122478), + REAL_CONST(1.737333835273706), REAL_CONST(1.756252160373300), REAL_CONST(1.775376492526521), + REAL_CONST(1.794709075003107), REAL_CONST(1.814252175500399), REAL_CONST(1.834008086409342), + REAL_CONST(1.853979125083386), REAL_CONST(1.874167634110300), REAL_CONST(1.894575981586966), + REAL_CONST(1.915206561397147), REAL_CONST(1.936061793492294), REAL_CONST(1.957144124175400), + REAL_CONST(1.978456026387951), REAL_CONST(2.000000000000000) +}; + +static const real_t log2_tab[] ICONST_ATTR_FAAD_LARGE_IRAM = { + REAL_CONST(0.000000000000000), REAL_CONST(0.022367813028455), REAL_CONST(0.044394119358453), + REAL_CONST(0.066089190457772), REAL_CONST(0.087462841250339), REAL_CONST(0.108524456778169), + REAL_CONST(0.129283016944966), REAL_CONST(0.149747119504682), REAL_CONST(0.169925001442312), + REAL_CONST(0.189824558880017), REAL_CONST(0.209453365628950), REAL_CONST(0.228818690495881), + REAL_CONST(0.247927513443585), REAL_CONST(0.266786540694901), REAL_CONST(0.285402218862248), + REAL_CONST(0.303780748177103), REAL_CONST(0.321928094887362), REAL_CONST(0.339850002884625), + REAL_CONST(0.357552004618084), REAL_CONST(0.375039431346925), REAL_CONST(0.392317422778760), + REAL_CONST(0.409390936137702), REAL_CONST(0.426264754702098), REAL_CONST(0.442943495848728), + REAL_CONST(0.459431618637297), REAL_CONST(0.475733430966398), REAL_CONST(0.491853096329675), + REAL_CONST(0.507794640198696), REAL_CONST(0.523561956057013), REAL_CONST(0.539158811108031), + REAL_CONST(0.554588851677637), REAL_CONST(0.569855608330948), REAL_CONST(0.584962500721156), + REAL_CONST(0.599912842187128), REAL_CONST(0.614709844115208), REAL_CONST(0.629356620079610), + REAL_CONST(0.643856189774725), REAL_CONST(0.658211482751795), REAL_CONST(0.672425341971496), + REAL_CONST(0.686500527183218), REAL_CONST(0.700439718141092), REAL_CONST(0.714245517666123), + REAL_CONST(0.727920454563199), REAL_CONST(0.741466986401147), REAL_CONST(0.754887502163469), + REAL_CONST(0.768184324776926), REAL_CONST(0.781359713524660), REAL_CONST(0.794415866350106), + REAL_CONST(0.807354922057604), REAL_CONST(0.820178962415188), REAL_CONST(0.832890014164742), + REAL_CONST(0.845490050944375), REAL_CONST(0.857980995127572), REAL_CONST(0.870364719583405), + REAL_CONST(0.882643049361841), REAL_CONST(0.894817763307943), REAL_CONST(0.906890595608519), + REAL_CONST(0.918863237274595), REAL_CONST(0.930737337562886), REAL_CONST(0.942514505339240), + REAL_CONST(0.954196310386875), REAL_CONST(0.965784284662087), REAL_CONST(0.977279923499917), + REAL_CONST(0.988684686772166), REAL_CONST(1.000000000000000) +}; + +uint32_t pow2_fix(real_t val) +{ + uint32_t x1, x2; + uint32_t errcorr; + uint32_t index_frac; + uint32_t retval; + int32_t whole = (val >> REAL_BITS); + + /* rest = [0..1] */ + int32_t rest = val - (whole << REAL_BITS); + + /* index into pow2_tab */ + int32_t index = (rest >> (REAL_BITS-TABLE_BITS)) & ((1<> (REAL_BITS-TABLE_BITS-INTERP_BITS); + index_frac = index_frac & ((1<= 0) + retval = REAL_CONST(1) << whole; + else + retval = REAL_CONST(1) >> -whole; + + x1 = pow2_tab[index ]; + x2 = pow2_tab[index + 1]; + errcorr = (index_frac*(x2-x1)) >> INTERP_BITS; + + retval = MUL_R(retval, (errcorr + x1)); + + return retval; +} + +uint32_t pow2_int(real_t val) +{ + uint32_t x1, x2; + uint32_t errcorr; + uint32_t index_frac; + uint32_t retval; + int32_t whole = (val >> REAL_BITS); + + /* rest = [0..1] */ + int32_t rest = val - (whole << REAL_BITS); + + /* index into pow2_tab */ + int32_t index = (rest >> (REAL_BITS-TABLE_BITS)) & ((1<> (REAL_BITS-TABLE_BITS-INTERP_BITS); + index_frac = index_frac & ((1<= 0) + retval = 1 << whole; + else + retval = 1 >> -whole; + + x1 = pow2_tab[index ]; + x2 = pow2_tab[index + 1]; + errcorr = (index_frac*(x2-x1)) >> INTERP_BITS; + + retval = MUL_R(retval, (errcorr + x1)); + + return retval; +} + +/* ld(x) = ld(x*y/y) = ld(x/y) + ld(y), with y=2^N and [1 <= (x/y) < 2] */ +int32_t log2_int(uint32_t val) +{ + uint32_t frac; + int32_t exp = 0; + uint32_t index; + uint32_t index_frac; + uint32_t x1, x2; + uint32_t errcorr; + + /* error */ + if (val == 0) + return -10000; + + exp = floor_log2(val); + exp -= REAL_BITS; + + /* frac = [1..2] */ + if (exp >= 0) + frac = val >> exp; + else + frac = val << -exp; + + /* index in the log2 table */ + index = frac >> (REAL_BITS-TABLE_BITS); + + /* leftover part for linear interpolation */ + index_frac = frac & ((1<<(REAL_BITS-TABLE_BITS))-1); + + /* leave INTERP_BITS bits */ + index_frac = index_frac >> (REAL_BITS-TABLE_BITS-INTERP_BITS); + + x1 = log2_tab[index & ((1<> INTERP_BITS; + + return ((exp+REAL_BITS) << REAL_BITS) + errcorr + x1; +} + +/* ld(x) = ld(x*y/y) = ld(x/y) + ld(y), with y=2^N and [1 <= (x/y) < 2] */ +real_t log2_fix(uint32_t val) +{ + uint32_t frac; + int8_t exp = 0; + uint32_t index; + uint32_t index_frac; + uint32_t x1, x2; + uint32_t errcorr; + + /* error */ + if (val == 0) + return -100000; + + exp = floor_log2(val); + exp -= REAL_BITS; + + /* frac = [1..2] */ + if (exp >= 0) + frac = val >> exp; + else + frac = val << -exp; + + /* index in the log2 table */ + index = frac >> (REAL_BITS-TABLE_BITS); + + /* leftover part for linear interpolation */ + index_frac = frac & ((1<<(REAL_BITS-TABLE_BITS))-1); + + /* leave INTERP_BITS bits */ + index_frac = index_frac >> (REAL_BITS-TABLE_BITS-INTERP_BITS); + + x1 = log2_tab[index & ((1<> INTERP_BITS; + + return (exp << REAL_BITS) + errcorr + x1; +} +#endif diff --git a/lib/rbcodec/codecs/libfaad/common.h b/lib/rbcodec/codecs/libfaad/common.h new file mode 100644 index 0000000000..720042b4aa --- /dev/null +++ b/lib/rbcodec/codecs/libfaad/common.h @@ -0,0 +1,475 @@ +/* +** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding +** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +** +** Any non-GPL usage of this software or parts of this software is strictly +** forbidden. +** +** Commercial non-GPL licensing of this software is possible. +** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** +** $Id$ +**/ + +#ifndef __COMMON_H__ +#define __COMMON_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "faad_config.h" +#include "codeclib.h" + +extern struct codec_api* ci; + +#if defined(DEBUG) || defined(SIMULATOR) +#undef DEBUGF +#define DEBUGF ci->debugf +#else +#define DEBUGF(...) +#endif + +#ifdef ROCKBOX_HAS_LOGF +#undef LOGF +#define LOGF ci->logf +#else +#define LOGF(...) +#endif + +#if (CONFIG_CPU == MCF5250) +/* Enough IRAM but performance suffers with ICODE_ATTR. */ +#define IBSS_ATTR_FAAD_LARGE_IRAM IBSS_ATTR +#define ICODE_ATTR_FAAD_LARGE_IRAM +#define ICONST_ATTR_FAAD_LARGE_IRAM ICONST_ATTR +#define IBSS_ATTR_FAAD_XLR + +#elif (CONFIG_CPU == PP5022) || (CONFIG_CPU == PP5024) +/* Enough IRAM to move additional data and code to it. */ +#define IBSS_ATTR_FAAD_LARGE_IRAM IBSS_ATTR +#define ICODE_ATTR_FAAD_LARGE_IRAM ICODE_ATTR +#define ICONST_ATTR_FAAD_LARGE_IRAM ICONST_ATTR +#define IBSS_ATTR_FAAD_XLR + +#elif defined(CPU_S5L870X) +/* Very large IRAM. Move even more data to it. */ +#define IBSS_ATTR_FAAD_LARGE_IRAM IBSS_ATTR +#define ICODE_ATTR_FAAD_LARGE_IRAM ICODE_ATTR +#define ICONST_ATTR_FAAD_LARGE_IRAM ICONST_ATTR +#define IBSS_ATTR_FAAD_XLR IBSS_ATTR +#define HAVE_FAAD_XLR_IN_IRAM + +#else +/* Not enough IRAM available. */ +#define IBSS_ATTR_FAAD_LARGE_IRAM +#define ICODE_ATTR_FAAD_LARGE_IRAM +#define ICONST_ATTR_FAAD_LARGE_IRAM +#define IBSS_ATTR_FAAD_XLR +#endif + +/* Used to allocate several SBR + PS arrays and variables statically. */ +//#define FAAD_STATIC_ALLOC + +#define INLINE __inline +#if 0 //defined(_WIN32) && !defined(_WIN32_WCE) +#define ALIGN __declspec(align(16)) +#else +#define ALIGN +#endif + +#ifndef max +#define max(a, b) (((a) > (b)) ? (a) : (b)) +#endif +#ifndef min +#define min(a, b) (((a) < (b)) ? (a) : (b)) +#endif + +/* COMPILE TIME DEFINITIONS */ + +/* use double precision */ +/* #define USE_DOUBLE_PRECISION */ +/* use fixed point reals */ +#define FIXED_POINT +#define BIG_IQ_TABLE /* BIG_IQ_TABLE results in faster requantization */ + +/* Use if target platform has address generators with autoincrement */ +//#define PREFER_POINTERS + +#define ERROR_RESILIENCE + + +/* Allow decoding of MAIN profile AAC */ +#define MAIN_DEC +/* Allow decoding of SSR profile AAC */ +#define SSR_DEC +/* Allow decoding of LTP profile AAC */ +#define LTP_DEC +/* Allow decoding of LD profile AAC */ +#define LD_DEC +/* Allow decoding of scalable profiles */ +//#define SCALABLE_DEC +/* Allow decoding of Digital Radio Mondiale (DRM) */ +//#define DRM +//#define DRM_PS + +/* LD can't do without LTP */ +#ifdef LD_DEC +#ifndef ERROR_RESILIENCE +#define ERROR_RESILIENCE +#endif +#ifndef LTP_DEC +#define LTP_DEC +#endif +#endif + +#define ALLOW_SMALL_FRAMELENGTH + + +// Define LC_ONLY_DECODER if you want a pure AAC LC decoder (independant of SBR_DEC and PS_DEC) +#define LC_ONLY_DECODER +#ifdef LC_ONLY_DECODER + #undef LD_DEC + #undef LTP_DEC + #undef MAIN_DEC + #undef SSR_DEC + #undef DRM + #undef ALLOW_SMALL_FRAMELENGTH + #undef ERROR_RESILIENCE +#endif + +#if CODEC_SIZE >= 0x80000 +#define SBR_DEC +//#define SBR_LOW_POWER /* Does not work yet in rockbox. */ +#define PS_DEC +#endif + +/* FIXED POINT: No MAIN decoding */ +#ifdef FIXED_POINT +# ifdef MAIN_DEC +# undef MAIN_DEC +# endif +#endif // FIXED_POINT + +#ifdef DRM +# ifndef SCALABLE_DEC +# define SCALABLE_DEC +# endif +#endif + + +#ifdef FIXED_POINT +#define DIV_R(A, B) (((int64_t)A << REAL_BITS)/B) +#define DIV_C(A, B) (((int64_t)A << COEF_BITS)/B) +#define DIV_Q(A, B) (((int64_t)A << Q2_BITS )/B) +#else +#define DIV_R(A, B) ((A)/(B)) +#define DIV_C(A, B) ((A)/(B)) +#define DIV_Q(A, B) ((A)/(B)) +#endif + +#ifndef SBR_LOW_POWER +#define qmf_t complex_t +#define QMF_RE(A) RE(A) +#define QMF_IM(A) IM(A) +#else +#define qmf_t real_t +#define QMF_RE(A) (A) +#define QMF_IM(A) +#endif + + +/* END COMPILE TIME DEFINITIONS */ + +#if defined(_WIN32) && !defined(__MINGW32__) + +#include + +typedef unsigned __int64 uint64_t; +typedef unsigned __int32 uint32_t; +typedef unsigned __int16 uint16_t; +typedef unsigned __int8 uint8_t; +typedef __int64 int64_t; +typedef __int32 int32_t; +typedef __int16 int16_t; +typedef __int8 int8_t; +typedef float float32_t; + + +#else + +#include +#ifdef HAVE_SYS_TYPES_H +# include "inttypes.h" +#endif +#ifdef HAVE_SYS_STAT_H +# include +#endif +#ifdef STDC_HEADERS +# include +# include +#else +# ifdef HAVE_STDLIB_H +# include +# endif +#endif +#ifdef HAVE_STRING_H +# if !defined(STDC_HEADERS) && defined(HAVE_MEMORY_H) +# include +# endif +//# include +#endif +#ifdef HAVE_STRINGS_H +//# include +#endif +#ifdef HAVE_INTTYPES_H +# include +#else +# ifdef HAVE_STDINT_H +# include +# else +/* we need these... */ +typedef unsigned long long uint64_t; +typedef unsigned long uint32_t; +typedef unsigned short uint16_t; +typedef unsigned char uint8_t; +typedef long long int64_t; +typedef long int32_t; +typedef short int16_t; +typedef char int8_t; +# endif +#endif +#ifdef HAVE_UNISTD_H +# include +#endif + +#ifndef HAVE_FLOAT32_T +typedef float float32_t; +#endif + +#if STDC_HEADERS +//# include +#else +# if !HAVE_STRCHR +# define strchr index +# define strrchr rindex +# endif +char *strchr(), *strrchr(); +# if !HAVE_MEMCPY +# define memcpy(d, s, n) bcopy((s), (d), (n)) +# define memmove(d, s, n) bcopy((s), (d), (n)) +# endif +#endif + +#endif + +#ifdef WORDS_BIGENDIAN +#define ARCH_IS_BIG_ENDIAN +#endif + +/* FIXED_POINT doesn't work with MAIN and SSR yet */ +#ifdef FIXED_POINT + #undef MAIN_DEC + #undef SSR_DEC +#endif + + +#if defined(FIXED_POINT) + + #include "fixed.h" + +#elif defined(USE_DOUBLE_PRECISION) + + typedef double real_t; + + #include + + #define MUL_R(A,B) ((A)*(B)) + #define MUL_C(A,B) ((A)*(B)) + #define MUL_F(A,B) ((A)*(B)) + #define MUL_Q2(A,B) ((A)*(B)) + + /* Complex multiplication */ + static INLINE void ComplexMult(real_t *y1, real_t *y2, + real_t x1, real_t x2, real_t c1, real_t c2) + { + *y1 = MUL_F(x1, c1) + MUL_F(x2, c2); + *y2 = MUL_F(x2, c1) - MUL_F(x1, c2); + } + + #define REAL_CONST(A) ((real_t)(A)) + #define COEF_CONST(A) ((real_t)(A)) + #define Q2_CONST(A) ((real_t)(A)) + #define FRAC_CONST(A) ((real_t)(A)) /* pure fractional part */ + +#else /* Normal floating point operation */ + + typedef float real_t; + + #define MUL_R(A,B) ((A)*(B)) + #define MUL_C(A,B) ((A)*(B)) + #define MUL_F(A,B) ((A)*(B)) + #define MUL_Q2(A,B) ((A)*(B)) + + #define REAL_CONST(A) ((real_t)(A)) + #define COEF_CONST(A) ((real_t)(A)) + #define Q2_CONST(A) ((real_t)(A)) + #define FRAC_CONST(A) ((real_t)(A)) /* pure fractional part */ + + /* Complex multiplication */ + static INLINE void ComplexMult(real_t *y1, real_t *y2, + real_t x1, real_t x2, real_t c1, real_t c2) + { + *y1 = MUL_F(x1, c1) + MUL_F(x2, c2); + *y2 = MUL_F(x2, c1) - MUL_F(x1, c2); + } + +/* rockbox: must be commented to build for non-FP + #if defined(_WIN32) && !defined(__MINGW32__) + #define HAS_LRINTF + static INLINE int lrintf(float f) + { + int i; + __asm + { + fld f + fistp i + } + return i; + } + #elif (defined(__i386__) && defined(__GNUC__)) + #define HAS_LRINTF + // from http://www.stereopsis.com/FPU.html + static INLINE int lrintf(float f) + { + int i; + __asm__ __volatile__ ( + "flds %1 \n\t" + "fistpl %0 \n\t" + : "=m" (i) + : "m" (f)); + return i; + } + #endif +*/ + + #ifdef __ICL /* only Intel C compiler has fmath ??? */ + + #include + + #define sin sinf + #define cos cosf + #define log logf + #define floor floorf + #define ceil ceilf + #define sqrt sqrtf + + #else + +#ifdef HAVE_LRINTF +# define HAS_LRINTF +# define _ISOC9X_SOURCE 1 +# define _ISOC99_SOURCE 1 +# define __USE_ISOC9X 1 +# define __USE_ISOC99 1 +#endif + + #include + +#ifdef HAVE_SINF +# define sin sinf +#error +#endif +#ifdef HAVE_COSF +# define cos cosf +#endif +#ifdef HAVE_LOGF +# define log logf +#endif +#ifdef HAVE_EXPF +# define exp expf +#endif +#ifdef HAVE_FLOORF +# define floor floorf +#endif +#ifdef HAVE_CEILF +# define ceil ceilf +#endif +#ifdef HAVE_SQRTF +# define sqrt sqrtf +#endif + + #endif + +#endif + +#ifndef HAS_LRINTF +/* standard cast */ +#define lrintf(f) ((int32_t)(f)) +#endif + +typedef real_t complex_t[2]; +#define RE(A) A[0] +#define IM(A) A[1] + + +/* common functions */ +uint8_t cpu_has_sse(void); +uint32_t random_int(void); +#define wl_min_lzc(x) bs_generic(x, BS_LOG2|BS_0_0) +#ifdef FIXED_POINT +#define LOG2_MIN_INF REAL_CONST(-10000) +int32_t log2_int(uint32_t val); +int32_t log2_fix(uint32_t val); +uint32_t pow2_int(real_t val); +uint32_t pow2_fix(real_t val); +#endif +uint8_t get_sr_index(const uint32_t samplerate); +uint8_t max_pred_sfb(const uint8_t sr_index); +uint8_t max_tns_sfb(const uint8_t sr_index, const uint8_t object_type, + const uint8_t is_short); +uint32_t get_sample_rate(const uint8_t sr_index); +int8_t can_decode_ot(const uint8_t object_type); + +#ifndef FAAD_STATIC_ALLOC +/* Those should not be defined or used anymore */ +#define faad_malloc(A) malloc(A) +#define faad_free(A) free(A) +#endif + +//#define PROFILE +#ifdef PROFILE +static int64_t faad_get_ts() +{ + __asm + { + rdtsc + } +} +#endif + +#ifndef M_PI +#define M_PI 3.14159265358979323846 +#endif +#ifndef M_PI_2 /* PI/2 */ +#define M_PI_2 1.57079632679489661923 +#endif + + +#ifdef __cplusplus +} +#endif +#endif diff --git a/lib/rbcodec/codecs/libfaad/decoder.c b/lib/rbcodec/codecs/libfaad/decoder.c new file mode 100644 index 0000000000..d68d093b0b --- /dev/null +++ b/lib/rbcodec/codecs/libfaad/decoder.c @@ -0,0 +1,1029 @@ +/* +** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding +** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +** +** Any non-GPL usage of this software or parts of this software is strictly +** forbidden. +** +** Commercial non-GPL licensing of this software is possible. +** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** +** $Id$ +**/ + +#include "common.h" +#include "structs.h" + +#include +#include + +#include "decoder.h" +#include "mp4.h" +#include "syntax.h" +#include "error.h" +/* rockbox: not used +#include "output.h" +*/ +#include "filtbank.h" +#include "drc.h" +#ifdef SBR_DEC +#include "sbr_dec.h" +#include "sbr_syntax.h" +#endif +#ifdef SSR_DEC +#include "ssr.h" +#endif + +/* Globals */ +#ifdef ANALYSIS +uint16_t dbg_count; +#endif + +/* static variables */ +static NeAACDecStruct s_AACDec; +static real_t s_fb_intermed [MAX_CHANNELS][1*FRAME_LEN] IBSS_ATTR_FAAD_LARGE_IRAM MEM_ALIGN_ATTR; +static real_t s_time_buf_1024[MAX_CHANNELS][1*FRAME_LEN] IBSS_ATTR_FAAD_LARGE_IRAM MEM_ALIGN_ATTR; +#ifdef SBR_DEC +#ifdef FAAD_STATIC_ALLOC +static real_t s_time_buf_2048[MAX_CHANNELS][2*FRAME_LEN] MEM_ALIGN_ATTR; +#endif +#endif +#ifdef SSR_DEC +static real_t s_ssr_overlap [MAX_CHANNELS][2*FRAME_LEN] MEM_ALIGN_ATTR; +static real_t s_prev_fmd [MAX_CHANNELS][2*FRAME_LEN] MEM_ALIGN_ATTR; +#endif +#ifdef MAIN_DEC +static pred_state s_pred_stat[MAX_CHANNELS][1*FRAME_LEN] MEM_ALIGN_ATTR; +#endif +#ifdef LTP_DEC +static int16_t s_lt_pred_stat[MAX_CHANNELS][4*FRAME_LEN] MEM_ALIGN_ATTR; +#endif + + +/* static function declarations */ +static void* aac_frame_decode(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hInfo, + uint8_t *buffer, uint32_t buffer_size); +/* not used by rockbox +static void create_channel_config(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hInfo); +*/ + +char* NEAACDECAPI NeAACDecGetErrorMessage(uint8_t errcode) +{ + if (errcode >= NUM_ERROR_MESSAGES) + return NULL; + return err_msg[errcode]; +} + +/* rockbox: not used */ +#if 0 +uint32_t NEAACDECAPI NeAACDecGetCapabilities(void) +{ + uint32_t cap = 0; + + /* can't do without it */ + cap += LC_DEC_CAP; + +#ifdef MAIN_DEC + cap += MAIN_DEC_CAP; +#endif +#ifdef LTP_DEC + cap += LTP_DEC_CAP; +#endif +#ifdef LD_DEC + cap += LD_DEC_CAP; +#endif +#ifdef ERROR_RESILIENCE + cap += ERROR_RESILIENCE_CAP; +#endif +#ifdef FIXED_POINT + cap += FIXED_POINT_CAP; +#endif + + return cap; +} +#endif + +NeAACDecHandle NEAACDECAPI NeAACDecOpen(void) +{ + uint8_t i; + NeAACDecHandle hDecoder = NULL; + + #if defined(CPU_COLDFIRE) + coldfire_set_macsr(EMAC_FRACTIONAL | EMAC_SATURATE); + #endif + + hDecoder = &s_AACDec; + + memset(hDecoder , 0, sizeof(NeAACDecStruct)); + memset(s_fb_intermed, 0, sizeof(s_fb_intermed)); +#ifdef SSR_DEC + memset(s_ssr_overlap, 0, sizeof(s_ssr_overlap)); + memset(s_prev_fmd , 0, sizeof(s_prev_fmd)); +#endif +#ifdef LTP_DEC + memset(s_lt_pred_stat, 0, sizeof(s_s_lt_pred_statpred_stat)); +#endif + + hDecoder->config.outputFormat = FAAD_FMT_16BIT; + hDecoder->config.defObjectType = MAIN; + hDecoder->config.defSampleRate = 44100; + hDecoder->config.downMatrix = 0; + hDecoder->adts_header_present = 0; + hDecoder->adif_header_present = 0; +#ifdef ERROR_RESILIENCE + hDecoder->aacSectionDataResilienceFlag = 0; + hDecoder->aacScalefactorDataResilienceFlag = 0; + hDecoder->aacSpectralDataResilienceFlag = 0; +#endif + hDecoder->frameLength = FRAME_LEN; + + hDecoder->frame = 0; + + for (i = 0; i < MAX_CHANNELS; i++) + { + hDecoder->window_shape_prev[i] = 0; + hDecoder->time_out[i] = NULL; + hDecoder->fb_intermed[i] = s_fb_intermed[i]; +#ifdef SSR_DEC + hDecoder->ssr_overlap[i] = s_ssr_overlap[i]; + hDecoder->prev_fmd[i] = s_prev_fmd[i]; + for (int k = 0; k < 2048; k++) + hDecoder->prev_fmd[i][k] = REAL_CONST(-1); +#endif +#ifdef MAIN_DEC + hDecoder->pred_stat[i] = s_pred_stat[i]; + reset_all_predictors(hDecoder->pred_stat[channel], FRAME_LEN); +#endif +#ifdef LTP_DEC + hDecoder->ltp_lag[i] = 0; + hDecoder->lt_pred_stat[i] = s_lt_pred_stat[i]; +#endif + } + +#ifdef SBR_DEC + for (i = 0; i < MAX_SYNTAX_ELEMENTS; i++) + { + hDecoder->sbr[i] = NULL; + } +#endif + + hDecoder->drc = drc_init(REAL_CONST(1.0), REAL_CONST(1.0)); + + return hDecoder; +} + +NeAACDecConfigurationPtr NEAACDECAPI NeAACDecGetCurrentConfiguration(NeAACDecHandle hDecoder) +{ + if (hDecoder) + { + NeAACDecConfigurationPtr config = &(hDecoder->config); + + return config; + } + + return NULL; +} + +uint8_t NEAACDECAPI NeAACDecSetConfiguration(NeAACDecHandle hDecoder, + NeAACDecConfigurationPtr config) +{ + if (hDecoder && config) + { + /* check if we can decode this object type */ + if (can_decode_ot(config->defObjectType) < 0) + return 0; + hDecoder->config.defObjectType = config->defObjectType; + + /* samplerate: anything but 0 should be possible */ + if (config->defSampleRate == 0) + return 0; + hDecoder->config.defSampleRate = config->defSampleRate; + + /* check output format */ +#ifdef FIXED_POINT + if ((config->outputFormat < 1) || (config->outputFormat > 4)) + return 0; +#else + if ((config->outputFormat < 1) || (config->outputFormat > 5)) + return 0; +#endif + hDecoder->config.outputFormat = config->outputFormat; + + if (config->downMatrix > 1) + return 0; + hDecoder->config.downMatrix = config->downMatrix; + + /* OK */ + return 1; + } + + return 0; +} + +int32_t NEAACDECAPI NeAACDecInit(NeAACDecHandle hDecoder, uint8_t *buffer, + uint32_t buffer_size, + uint32_t *samplerate, uint8_t *channels) +{ + uint32_t i; + uint32_t bits = 0; + bitfile ld; + adif_header adif; + adts_header adts; + + if ((hDecoder == NULL) || (samplerate == NULL) || (channels == NULL)) + return -1; + + hDecoder->sf_index = get_sr_index(hDecoder->config.defSampleRate); + hDecoder->object_type = hDecoder->config.defObjectType; + *samplerate = get_sample_rate(hDecoder->sf_index); + *channels = 1; + + if (buffer != NULL) + { + faad_initbits(&ld, buffer, buffer_size); + + /* Check if an ADIF header is present */ + if ((buffer[0] == 'A') && (buffer[1] == 'D') && + (buffer[2] == 'I') && (buffer[3] == 'F')) + { + hDecoder->adif_header_present = 1; + + get_adif_header(&adif, &ld); + faad_byte_align(&ld); + + hDecoder->sf_index = adif.pce[0].sf_index; + hDecoder->object_type = adif.pce[0].object_type + 1; + + *samplerate = get_sample_rate(hDecoder->sf_index); + *channels = adif.pce[0].channels; + + memcpy(&(hDecoder->pce), &(adif.pce[0]), sizeof(program_config)); + hDecoder->pce_set = 1; + + bits = bit2byte(faad_get_processed_bits(&ld)); + + /* Check if an ADTS header is present */ + } else if (faad_showbits(&ld, 12) == 0xfff) { + hDecoder->adts_header_present = 1; + + adts.old_format = hDecoder->config.useOldADTSFormat; + adts_frame(&adts, &ld); + + hDecoder->sf_index = adts.sf_index; + hDecoder->object_type = adts.profile + 1; + + *samplerate = get_sample_rate(hDecoder->sf_index); + *channels = (adts.channel_configuration > 6) ? + 2 : adts.channel_configuration; + } + + if (ld.error) + { + faad_endbits(&ld); + return -1; + } + faad_endbits(&ld); + } + hDecoder->channelConfiguration = *channels; + +#if (defined(PS_DEC) || defined(DRM_PS)) + /* check if we have a mono file */ + if (*channels == 1) + { + /* upMatrix to 2 channels for implicit signalling of PS */ + *channels = 2; + } +#endif + + /* A maximum of MAX_CHANNELS channels is supported. */ + if (*channels > MAX_CHANNELS) + { + return -1; + } + +#ifdef SBR_DEC + /* implicit signalling */ + if (*samplerate <= 24000 && !(hDecoder->config.dontUpSampleImplicitSBR)) + { + *samplerate *= 2; + hDecoder->forceUpSampling = 1; + } else if (*samplerate > 24000 && !(hDecoder->config.dontUpSampleImplicitSBR)) { + hDecoder->downSampledSBR = 1; + } +#endif + + /* must be done before frameLength is divided by 2 for LD */ +#ifdef SSR_DEC + if (hDecoder->object_type == SSR) + hDecoder->fb = ssr_filter_bank_init(hDecoder->frameLength/SSR_BANDS); + else +#endif + + +#ifdef LD_DEC + if (hDecoder->object_type == LD) + hDecoder->frameLength >>= 1; +#endif + + for (i=0; isbr_alloced[hDecoder->fr_ch_ele] = 0; + if ((hDecoder->sbr_present_flag == 1) || (hDecoder->forceUpSampling == 1)) + { +#ifdef FAAD_STATIC_ALLOC + hDecoder->time_out[i] = s_time_buf_2048[i]; +#else + hDecoder->time_out[i] = (real_t*)faad_malloc(2*FRAME_LEN*sizeof(real_t)); + if (hDecoder->time_out[i] == NULL) + { + /* could not allocate memory */ + return -1; + } +#endif + memset(hDecoder->time_out[i], 0, 2*FRAME_LEN); + hDecoder->sbr_alloced[hDecoder->fr_ch_ele] = 1; + } + else +#endif + { + hDecoder->time_out[i] = s_time_buf_1024[i]; + memset(hDecoder->time_out[i], 0, 1*FRAME_LEN); + } + } + + if (can_decode_ot(hDecoder->object_type) < 0) + return -1; + + return bits; +} + +/* Init the library using a DecoderSpecificInfo */ +int8_t NEAACDECAPI NeAACDecInit2(NeAACDecHandle hDecoder, uint8_t *pBuffer, + uint32_t SizeOfDecoderSpecificInfo, + uint32_t *samplerate, uint8_t *channels) +{ + int8_t rc; + uint32_t i; + mp4AudioSpecificConfig mp4ASC; + + if((hDecoder == NULL) + || (pBuffer == NULL) + || (SizeOfDecoderSpecificInfo < 2) + || (samplerate == NULL) + || (channels == NULL)) + { + return -1; + } + + hDecoder->adif_header_present = 0; + hDecoder->adts_header_present = 0; + + /* decode the audio specific config */ + rc = AudioSpecificConfig2(pBuffer, SizeOfDecoderSpecificInfo, &mp4ASC, + &(hDecoder->pce)); + + /* copy the relevant info to the decoder handle */ + *samplerate = mp4ASC.samplingFrequency; + if (mp4ASC.channelsConfiguration) + { + *channels = mp4ASC.channelsConfiguration; + } else { + *channels = hDecoder->pce.channels; + hDecoder->pce_set = 1; + } +#if (defined(PS_DEC) || defined(DRM_PS)) + /* check if we have a mono file */ + if (*channels == 1) + { + /* upMatrix to 2 channels for implicit signalling of PS */ + *channels = 2; + } +#endif + + /* A maximum of MAX_CHANNELS channels is supported. */ + if (*channels > MAX_CHANNELS) + { + return -1; + } + + hDecoder->sf_index = mp4ASC.samplingFrequencyIndex; + hDecoder->object_type = mp4ASC.objectTypeIndex; +#ifdef ERROR_RESILIENCE + hDecoder->aacSectionDataResilienceFlag = mp4ASC.aacSectionDataResilienceFlag; + hDecoder->aacScalefactorDataResilienceFlag = mp4ASC.aacScalefactorDataResilienceFlag; + hDecoder->aacSpectralDataResilienceFlag = mp4ASC.aacSpectralDataResilienceFlag; +#endif +#ifdef SBR_DEC + hDecoder->sbr_present_flag = mp4ASC.sbr_present_flag; + hDecoder->downSampledSBR = mp4ASC.downSampledSBR; + if (hDecoder->config.dontUpSampleImplicitSBR == 0) + hDecoder->forceUpSampling = mp4ASC.forceUpSampling; + else + hDecoder->forceUpSampling = 0; + + /* AAC core decoder samplerate is 2 times as low */ + if (((hDecoder->sbr_present_flag == 1)&&(!hDecoder->downSampledSBR)) || hDecoder->forceUpSampling == 1) + { + hDecoder->sf_index = get_sr_index(mp4ASC.samplingFrequency / 2); + } +#endif + + if (rc != 0) + { + return rc; + } + hDecoder->channelConfiguration = mp4ASC.channelsConfiguration; + if (mp4ASC.frameLengthFlag) +#ifdef ALLOW_SMALL_FRAMELENGTH + hDecoder->frameLength = 960; +#else + return -1; +#endif + + /* must be done before frameLength is divided by 2 for LD */ +#ifdef SSR_DEC + if (hDecoder->object_type == SSR) + hDecoder->fb = ssr_filter_bank_init(hDecoder->frameLength/SSR_BANDS); + else +#endif + +#ifdef LD_DEC + if (hDecoder->object_type == LD) + hDecoder->frameLength >>= 1; +#endif + + for (i=0; isbr_alloced[hDecoder->fr_ch_ele] = 0; + if ((hDecoder->sbr_present_flag == 1) || (hDecoder->forceUpSampling == 1)) + { +#ifdef FAAD_STATIC_ALLOC + hDecoder->time_out[i] = s_time_buf_2048[i]; +#else + hDecoder->time_out[i] = (real_t*)faad_malloc(2*FRAME_LEN*sizeof(real_t)); + if (hDecoder->time_out[i] == NULL) + { + /* could not allocate memory */ + return -1; + } +#endif + memset(hDecoder->time_out[i], 0, 2*FRAME_LEN); + hDecoder->sbr_alloced[hDecoder->fr_ch_ele] = 1; + } + else +#endif + { + hDecoder->time_out[i] = s_time_buf_1024[i]; + memset(hDecoder->time_out[i], 0, 1*FRAME_LEN); + } + } + + return 0; +} + +#ifdef DRM +int8_t NEAACDECAPI NeAACDecInitDRM(NeAACDecHandle *hDecoder, uint32_t samplerate, + uint8_t channels) +{ + if (hDecoder == NULL) + return 1; /* error */ + + *hDecoder = NeAACDecOpen(); + + /* Special object type defined for DRM */ + (*hDecoder)->config.defObjectType = DRM_ER_LC; + + (*hDecoder)->config.defSampleRate = samplerate; +#ifdef ERROR_RESILIENCE // This shoudl always be defined for DRM + (*hDecoder)->aacSectionDataResilienceFlag = 1; /* VCB11 */ + (*hDecoder)->aacScalefactorDataResilienceFlag = 0; /* no RVLC */ + (*hDecoder)->aacSpectralDataResilienceFlag = 1; /* HCR */ +#endif + (*hDecoder)->frameLength = 960; + (*hDecoder)->sf_index = get_sr_index((*hDecoder)->config.defSampleRate); + (*hDecoder)->object_type = (*hDecoder)->config.defObjectType; + + if ((channels == DRMCH_STEREO) || (channels == DRMCH_SBR_STEREO)) + (*hDecoder)->channelConfiguration = 2; + else + (*hDecoder)->channelConfiguration = 1; + +#ifdef SBR_DEC + if ((channels == DRMCH_MONO) || (channels == DRMCH_STEREO)) + (*hDecoder)->sbr_present_flag = 0; + else + (*hDecoder)->sbr_present_flag = 1; +#endif + + + return 0; +} +#endif + +void NEAACDECAPI NeAACDecPostSeekReset(NeAACDecHandle hDecoder, int32_t frame) +{ + if (hDecoder) + { + hDecoder->postSeekResetFlag = 1; + + if (frame != -1) + hDecoder->frame = frame; + } +} + +/* not used by rockbox */ +#if 0 +static void create_channel_config(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hInfo) +{ + hInfo->num_front_channels = 0; + hInfo->num_side_channels = 0; + hInfo->num_back_channels = 0; + hInfo->num_lfe_channels = 0; + memset(hInfo->channel_position, 0, MAX_CHANNELS*sizeof(uint8_t)); + + if (hDecoder->downMatrix) + { + hInfo->num_front_channels = 2; + hInfo->channel_position[0] = FRONT_CHANNEL_LEFT; + hInfo->channel_position[1] = FRONT_CHANNEL_RIGHT; + return; + } + + /* check if there is a PCE */ + if (hDecoder->pce_set) + { + uint8_t i, chpos = 0; + uint8_t chdir, back_center = 0; + + hInfo->num_front_channels = hDecoder->pce.num_front_channels; + hInfo->num_side_channels = hDecoder->pce.num_side_channels; + hInfo->num_back_channels = hDecoder->pce.num_back_channels; + hInfo->num_lfe_channels = hDecoder->pce.num_lfe_channels; + + chdir = hInfo->num_front_channels; + if (chdir & 1) + { + hInfo->channel_position[chpos++] = FRONT_CHANNEL_CENTER; + chdir--; + } + for (i = 0; i < chdir; i += 2) + { + hInfo->channel_position[chpos++] = FRONT_CHANNEL_LEFT; + hInfo->channel_position[chpos++] = FRONT_CHANNEL_RIGHT; + } + + for (i = 0; i < hInfo->num_side_channels; i += 2) + { + hInfo->channel_position[chpos++] = SIDE_CHANNEL_LEFT; + hInfo->channel_position[chpos++] = SIDE_CHANNEL_RIGHT; + } + + chdir = hInfo->num_back_channels; + if (chdir & 1) + { + back_center = 1; + chdir--; + } + for (i = 0; i < chdir; i += 2) + { + hInfo->channel_position[chpos++] = BACK_CHANNEL_LEFT; + hInfo->channel_position[chpos++] = BACK_CHANNEL_RIGHT; + } + if (back_center) + { + hInfo->channel_position[chpos++] = BACK_CHANNEL_CENTER; + } + + for (i = 0; i < hInfo->num_lfe_channels; i++) + { + hInfo->channel_position[chpos++] = LFE_CHANNEL; + } + + } else { + switch (hDecoder->channelConfiguration) + { + case 1: + hInfo->num_front_channels = 1; + hInfo->channel_position[0] = FRONT_CHANNEL_CENTER; + break; + case 2: + hInfo->num_front_channels = 2; + hInfo->channel_position[0] = FRONT_CHANNEL_LEFT; + hInfo->channel_position[1] = FRONT_CHANNEL_RIGHT; + break; + case 3: + hInfo->num_front_channels = 3; + hInfo->channel_position[0] = FRONT_CHANNEL_CENTER; + hInfo->channel_position[1] = FRONT_CHANNEL_LEFT; + hInfo->channel_position[2] = FRONT_CHANNEL_RIGHT; + break; + case 4: + hInfo->num_front_channels = 3; + hInfo->num_back_channels = 1; + hInfo->channel_position[0] = FRONT_CHANNEL_CENTER; + hInfo->channel_position[1] = FRONT_CHANNEL_LEFT; + hInfo->channel_position[2] = FRONT_CHANNEL_RIGHT; + hInfo->channel_position[3] = BACK_CHANNEL_CENTER; + break; + case 5: + hInfo->num_front_channels = 3; + hInfo->num_back_channels = 2; + hInfo->channel_position[0] = FRONT_CHANNEL_CENTER; + hInfo->channel_position[1] = FRONT_CHANNEL_LEFT; + hInfo->channel_position[2] = FRONT_CHANNEL_RIGHT; + hInfo->channel_position[3] = BACK_CHANNEL_LEFT; + hInfo->channel_position[4] = BACK_CHANNEL_RIGHT; + break; + case 6: + hInfo->num_front_channels = 3; + hInfo->num_back_channels = 2; + hInfo->num_lfe_channels = 1; + hInfo->channel_position[0] = FRONT_CHANNEL_CENTER; + hInfo->channel_position[1] = FRONT_CHANNEL_LEFT; + hInfo->channel_position[2] = FRONT_CHANNEL_RIGHT; + hInfo->channel_position[3] = BACK_CHANNEL_LEFT; + hInfo->channel_position[4] = BACK_CHANNEL_RIGHT; + hInfo->channel_position[5] = LFE_CHANNEL; + break; + case 7: + hInfo->num_front_channels = 3; + hInfo->num_side_channels = 2; + hInfo->num_back_channels = 2; + hInfo->num_lfe_channels = 1; + hInfo->channel_position[0] = FRONT_CHANNEL_CENTER; + hInfo->channel_position[1] = FRONT_CHANNEL_LEFT; + hInfo->channel_position[2] = FRONT_CHANNEL_RIGHT; + hInfo->channel_position[3] = SIDE_CHANNEL_LEFT; + hInfo->channel_position[4] = SIDE_CHANNEL_RIGHT; + hInfo->channel_position[5] = BACK_CHANNEL_LEFT; + hInfo->channel_position[6] = BACK_CHANNEL_RIGHT; + hInfo->channel_position[7] = LFE_CHANNEL; + break; + default: /* channelConfiguration == 0 || channelConfiguration > 7 */ + { + uint8_t i; + uint8_t ch = hDecoder->fr_channels - hDecoder->has_lfe; + if (ch & 1) /* there's either a center front or a center back channel */ + { + uint8_t ch1 = (ch-1)/2; + if (hDecoder->first_syn_ele == ID_SCE) + { + hInfo->num_front_channels = ch1 + 1; + hInfo->num_back_channels = ch1; + hInfo->channel_position[0] = FRONT_CHANNEL_CENTER; + for (i = 1; i <= ch1; i+=2) + { + hInfo->channel_position[i] = FRONT_CHANNEL_LEFT; + hInfo->channel_position[i+1] = FRONT_CHANNEL_RIGHT; + } + for (i = ch1+1; i < ch; i+=2) + { + hInfo->channel_position[i] = BACK_CHANNEL_LEFT; + hInfo->channel_position[i+1] = BACK_CHANNEL_RIGHT; + } + } else { + hInfo->num_front_channels = ch1; + hInfo->num_back_channels = ch1 + 1; + for (i = 0; i < ch1; i+=2) + { + hInfo->channel_position[i] = FRONT_CHANNEL_LEFT; + hInfo->channel_position[i+1] = FRONT_CHANNEL_RIGHT; + } + for (i = ch1; i < ch-1; i+=2) + { + hInfo->channel_position[i] = BACK_CHANNEL_LEFT; + hInfo->channel_position[i+1] = BACK_CHANNEL_RIGHT; + } + hInfo->channel_position[ch-1] = BACK_CHANNEL_CENTER; + } + } else { + uint8_t ch1 = (ch)/2; + hInfo->num_front_channels = ch1; + hInfo->num_back_channels = ch1; + if (ch1 & 1) + { + hInfo->channel_position[0] = FRONT_CHANNEL_CENTER; + for (i = 1; i <= ch1; i+=2) + { + hInfo->channel_position[i] = FRONT_CHANNEL_LEFT; + hInfo->channel_position[i+1] = FRONT_CHANNEL_RIGHT; + } + for (i = ch1+1; i < ch-1; i+=2) + { + hInfo->channel_position[i] = BACK_CHANNEL_LEFT; + hInfo->channel_position[i+1] = BACK_CHANNEL_RIGHT; + } + hInfo->channel_position[ch-1] = BACK_CHANNEL_CENTER; + } else { + for (i = 0; i < ch1; i+=2) + { + hInfo->channel_position[i] = FRONT_CHANNEL_LEFT; + hInfo->channel_position[i+1] = FRONT_CHANNEL_RIGHT; + } + for (i = ch1; i < ch; i+=2) + { + hInfo->channel_position[i] = BACK_CHANNEL_LEFT; + hInfo->channel_position[i+1] = BACK_CHANNEL_RIGHT; + } + } + } + hInfo->num_lfe_channels = hDecoder->has_lfe; + for (i = ch; i < hDecoder->fr_channels; i++) + { + hInfo->channel_position[i] = LFE_CHANNEL; + } + } + break; + } + } +} +#endif + +void* NEAACDECAPI NeAACDecDecode(NeAACDecHandle hDecoder, + NeAACDecFrameInfo *hInfo, + uint8_t *buffer, uint32_t buffer_size) +{ + return aac_frame_decode(hDecoder, hInfo, buffer, buffer_size); +} + +static void* aac_frame_decode(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hInfo, + uint8_t *buffer, uint32_t buffer_size) +{ + uint8_t channels = 0; + uint8_t output_channels = 0; + bitfile ld; + uint32_t bitsconsumed; + uint16_t frame_len; + +#ifdef PROFILE + int64_t count = faad_get_ts(); +#endif + + /* safety checks */ + if ((hDecoder == NULL) || (hInfo == NULL) || (buffer == NULL)) + { + return NULL; + } + +#if 0 + printf("%d\n", buffer_size*8); +#endif + + frame_len = hDecoder->frameLength; + + + memset(hInfo, 0, sizeof(NeAACDecFrameInfo)); + memset(hDecoder->internal_channel, 0, MAX_CHANNELS*sizeof(hDecoder->internal_channel[0])); + + /* initialize the bitstream */ + faad_initbits(&ld, buffer, buffer_size); + +#if 0 + { + int i; + for (i = 0; i < ((buffer_size+3)>>2); i++) + { + uint8_t *buf; + uint32_t temp = 0; + buf = faad_getbitbuffer(&ld, 32); + //temp = getdword((void*)buf); + temp = *((uint32_t*)buf); + printf("0x%.8X\n", temp); + free(buf); + } + faad_endbits(&ld); + faad_initbits(&ld, buffer, buffer_size); + } +#endif + +#ifdef DRM + if (hDecoder->object_type == DRM_ER_LC) + { + /* We do not support stereo right now */ + if (0) //(hDecoder->channelConfiguration == 2) + { + hInfo->error = 8; // Throw CRC error + goto error; + } + + faad_getbits(&ld, 8 + DEBUGVAR(1,1,"NeAACDecDecode(): skip CRC")); + } +#endif + + if (hDecoder->adts_header_present) + { + adts_header adts; + + adts.old_format = hDecoder->config.useOldADTSFormat; + if ((hInfo->error = adts_frame(&adts, &ld)) > 0) + goto error; + + /* MPEG2 does byte_alignment() here, + * but ADTS header is always multiple of 8 bits in MPEG2 + * so not needed to actually do it. + */ + } + +#ifdef ANALYSIS + dbg_count = 0; +#endif + + /* decode the complete bitstream */ +#ifdef SCALABLE_DEC + if ((hDecoder->object_type == 6) || (hDecoder->object_type == DRM_ER_LC)) + { + aac_scalable_main_element(hDecoder, hInfo, &ld, &hDecoder->pce, hDecoder->drc); + } else { +#endif + raw_data_block(hDecoder, hInfo, &ld, &hDecoder->pce, hDecoder->drc); +#ifdef SCALABLE_DEC + } +#endif + + channels = hDecoder->fr_channels; + + if (hInfo->error > 0) + goto error; + + /* safety check */ + if (channels == 0 || channels > MAX_CHANNELS) + { + /* invalid number of channels */ + hInfo->error = 12; + goto error; + } + + /* no more bit reading after this */ + bitsconsumed = faad_get_processed_bits(&ld); + hInfo->bytesconsumed = bit2byte(bitsconsumed); + if (ld.error) + { + hInfo->error = 14; + goto error; + } + faad_endbits(&ld); + + + if (!hDecoder->adts_header_present && !hDecoder->adif_header_present) + { + if (hDecoder->channelConfiguration == 0) + hDecoder->channelConfiguration = channels; + + if (channels == 8) /* 7.1 */ + hDecoder->channelConfiguration = 7; + if (channels == 7) /* not a standard channelConfiguration */ + hDecoder->channelConfiguration = 0; + } + + if ((channels == 5 || channels == 6) && hDecoder->config.downMatrix) + { + hDecoder->downMatrix = 1; + output_channels = 2; + } else { + output_channels = channels; + } + +#if (defined(PS_DEC) || defined(DRM_PS)) + hDecoder->upMatrix = 0; + /* check if we have a mono file */ + if (output_channels == 1) + { + /* upMatrix to 2 channels for implicit signalling of PS */ + hDecoder->upMatrix = 1; + output_channels = 2; + } +#endif + + /* Make a channel configuration based on either a PCE or a channelConfiguration */ + /* not used by rockbox + create_channel_config(hDecoder, hInfo); + */ + + /* number of samples in this frame */ + hInfo->samples = frame_len*output_channels; + /* number of channels in this frame */ + hInfo->channels = output_channels; + /* samplerate */ + hInfo->samplerate = get_sample_rate(hDecoder->sf_index); + /* object type */ + hInfo->object_type = hDecoder->object_type; + /* sbr */ + hInfo->sbr = NO_SBR; + /* header type */ + hInfo->header_type = RAW; + if (hDecoder->adif_header_present) + hInfo->header_type = ADIF; + if (hDecoder->adts_header_present) + hInfo->header_type = ADTS; +#if (defined(PS_DEC) || defined(DRM_PS)) + hInfo->ps = hDecoder->ps_used_global; +#endif + + /* check if frame has channel elements */ + if (channels == 0) + { + hDecoder->frame++; + return NULL; + } + + /* allocate the buffer for the final samples */ + if (hDecoder->alloced_channels != output_channels) + { + hDecoder->alloced_channels = output_channels; + } + +#ifdef SBR_DEC + if ((hDecoder->sbr_present_flag == 1) || (hDecoder->forceUpSampling == 1)) + { + uint8_t ele; + + /* this data is different when SBR is used or when the data is upsampled */ + if (!hDecoder->downSampledSBR) + { + frame_len *= 2; + hInfo->samples *= 2; + hInfo->samplerate *= 2; + } + + /* check if every element was provided with SBR data */ + for (ele = 0; ele < hDecoder->fr_ch_ele; ele++) + { + if (hDecoder->sbr[ele] == NULL) + { + hInfo->error = 25; + goto error; + } + } + + /* sbr */ + if (hDecoder->sbr_present_flag == 1) + { + hInfo->object_type = HE_AAC; + hInfo->sbr = SBR_UPSAMPLED; + } else { + hInfo->sbr = NO_SBR_UPSAMPLED; + } + if (hDecoder->downSampledSBR) + { + hInfo->sbr = SBR_DOWNSAMPLED; + } + } +#endif + + hDecoder->postSeekResetFlag = 0; + + hDecoder->frame++; +#ifdef LD_DEC + if (hDecoder->object_type != LD) + { +#endif + if (hDecoder->frame <= 1) + hInfo->samples = 0; +#ifdef LD_DEC + } else { + /* LD encoders will give lower delay */ + if (hDecoder->frame <= 0) + hInfo->samples = 0; + } +#endif + + /* cleanup */ +#ifdef ANALYSIS + fflush(stdout); +#endif + +#ifdef PROFILE + count = faad_get_ts() - count; + hDecoder->cycles += count; +#endif + + return hDecoder; /* return void* != NULL */ + +error: + + faad_endbits(&ld); + + /* cleanup */ +#ifdef ANALYSIS + fflush(stdout); +#endif + + return NULL; +} diff --git a/lib/rbcodec/codecs/libfaad/decoder.h b/lib/rbcodec/codecs/libfaad/decoder.h new file mode 100644 index 0000000000..f5c477e186 --- /dev/null +++ b/lib/rbcodec/codecs/libfaad/decoder.h @@ -0,0 +1,112 @@ +/* +** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding +** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +** +** Any non-GPL usage of this software or parts of this software is strictly +** forbidden. +** +** Commercial non-GPL licensing of this software is possible. +** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** +** $Id$ +**/ + +#ifndef __DECODER_H__ +#define __DECODER_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _WIN32 + #pragma pack(push, 8) + #ifndef NEAACDECAPI + #define NEAACDECAPI __cdecl + #endif +#else + #ifndef NEAACDECAPI + #define NEAACDECAPI + #endif +#endif + + +/* library output formats */ +#define FAAD_FMT_16BIT 1 +#define FAAD_FMT_24BIT 2 +#define FAAD_FMT_32BIT 3 +#define FAAD_FMT_FLOAT 4 +#define FAAD_FMT_FIXED FAAD_FMT_FLOAT +#define FAAD_FMT_DOUBLE 5 + +#define LC_DEC_CAP (1<<0) +#define MAIN_DEC_CAP (1<<1) +#define LTP_DEC_CAP (1<<2) +#define LD_DEC_CAP (1<<3) +#define ERROR_RESILIENCE_CAP (1<<4) +#define FIXED_POINT_CAP (1<<5) + +#define FRONT_CHANNEL_CENTER (1) +#define FRONT_CHANNEL_LEFT (2) +#define FRONT_CHANNEL_RIGHT (3) +#define SIDE_CHANNEL_LEFT (4) +#define SIDE_CHANNEL_RIGHT (5) +#define BACK_CHANNEL_LEFT (6) +#define BACK_CHANNEL_RIGHT (7) +#define BACK_CHANNEL_CENTER (8) +#define LFE_CHANNEL (9) +#define UNKNOWN_CHANNEL (0) + +char* NEAACDECAPI NeAACDecGetErrorMessage(uint8_t errcode); + +NeAACDecHandle NEAACDECAPI NeAACDecOpen(void); + +NeAACDecConfigurationPtr NEAACDECAPI NeAACDecGetCurrentConfiguration(NeAACDecHandle hDecoder); + +uint8_t NEAACDECAPI NeAACDecSetConfiguration(NeAACDecHandle hDecoder, + NeAACDecConfigurationPtr config); + +/* Init the library based on info from the AAC file (ADTS/ADIF) */ +int32_t NEAACDECAPI NeAACDecInit(NeAACDecHandle hDecoder, + uint8_t *buffer, + uint32_t buffer_size, + uint32_t *samplerate, + uint8_t *channels); + +/* Init the library using a DecoderSpecificInfo */ +int8_t NEAACDECAPI NeAACDecInit2(NeAACDecHandle hDecoder, uint8_t *pBuffer, + uint32_t SizeOfDecoderSpecificInfo, + uint32_t *samplerate, uint8_t *channels); + +/* Init the library for DRM */ +int8_t NEAACDECAPI NeAACDecInitDRM(NeAACDecHandle *hDecoder, uint32_t samplerate, + uint8_t channels); + +void NEAACDECAPI NeAACDecPostSeekReset(NeAACDecHandle hDecoder, int32_t frame); + +void* NEAACDECAPI NeAACDecDecode(NeAACDecHandle hDecoder, + NeAACDecFrameInfo *hInfo, + uint8_t *buffer, + uint32_t buffer_size); + +#ifdef _WIN32 + #pragma pack(pop) +#endif + +#ifdef __cplusplus +} +#endif +#endif diff --git a/lib/rbcodec/codecs/libfaad/drc.c b/lib/rbcodec/codecs/libfaad/drc.c new file mode 100644 index 0000000000..6e081489aa --- /dev/null +++ b/lib/rbcodec/codecs/libfaad/drc.c @@ -0,0 +1,168 @@ +/* +** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding +** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +** +** Any non-GPL usage of this software or parts of this software is strictly +** forbidden. +** +** Commercial non-GPL licensing of this software is possible. +** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** +** $Id$ +**/ + +#include "common.h" +#include "structs.h" + +#include +#include +#include "syntax.h" +#include "drc.h" + +/* static variables */ +static drc_info s_drc_info; + +drc_info *drc_init(real_t cut, real_t boost) +{ + drc_info *drc = &s_drc_info; + memset(drc, 0, sizeof(drc_info)); + + drc->ctrl1 = cut; + drc->ctrl2 = boost; + + drc->num_bands = 1; + drc->band_top[0] = 1024/4 - 1; + drc->dyn_rng_sgn[0] = 1; + drc->dyn_rng_ctl[0] = 0; + + return drc; +} + +#ifdef FIXED_POINT +static real_t drc_pow2_table[] = +{ + COEF_CONST(0.5146511183), + COEF_CONST(0.5297315472), + COEF_CONST(0.5452538663), + COEF_CONST(0.5612310242), + COEF_CONST(0.5776763484), + COEF_CONST(0.5946035575), + COEF_CONST(0.6120267717), + COEF_CONST(0.6299605249), + COEF_CONST(0.6484197773), + COEF_CONST(0.6674199271), + COEF_CONST(0.6869768237), + COEF_CONST(0.7071067812), + COEF_CONST(0.7278265914), + COEF_CONST(0.7491535384), + COEF_CONST(0.7711054127), + COEF_CONST(0.7937005260), + COEF_CONST(0.8169577266), + COEF_CONST(0.8408964153), + COEF_CONST(0.8655365610), + COEF_CONST(0.8908987181), + COEF_CONST(0.9170040432), + COEF_CONST(0.9438743127), + COEF_CONST(0.9715319412), + COEF_CONST(1.0000000000), + COEF_CONST(1.0293022366), + COEF_CONST(1.0594630944), + COEF_CONST(1.0905077327), + COEF_CONST(1.1224620483), + COEF_CONST(1.1553526969), + COEF_CONST(1.1892071150), + COEF_CONST(1.2240535433), + COEF_CONST(1.2599210499), + COEF_CONST(1.2968395547), + COEF_CONST(1.3348398542), + COEF_CONST(1.3739536475), + COEF_CONST(1.4142135624), + COEF_CONST(1.4556531828), + COEF_CONST(1.4983070769), + COEF_CONST(1.5422108254), + COEF_CONST(1.5874010520), + COEF_CONST(1.6339154532), + COEF_CONST(1.6817928305), + COEF_CONST(1.7310731220), + COEF_CONST(1.7817974363), + COEF_CONST(1.8340080864), + COEF_CONST(1.8877486254), + COEF_CONST(1.9430638823) +}; +#endif + +void drc_decode(drc_info *drc, real_t *spec) +{ + uint16_t i, bd, top; +#ifdef FIXED_POINT + int32_t exp, frac; +#else + real_t factor, exp; +#endif + uint16_t bottom = 0; + + if (drc->num_bands == 1) + drc->band_top[0] = 1024/4 - 1; + + for (bd = 0; bd < drc->num_bands; bd++) + { + top = 4 * (drc->band_top[bd] + 1); + +#ifndef FIXED_POINT + /* Decode DRC gain factor */ + if (drc->dyn_rng_sgn[bd]) /* compress */ + exp = -drc->ctrl1 * (drc->dyn_rng_ctl[bd] - (DRC_REF_LEVEL - drc->prog_ref_level))/REAL_CONST(24.0); + else /* boost */ + exp = drc->ctrl2 * (drc->dyn_rng_ctl[bd] - (DRC_REF_LEVEL - drc->prog_ref_level))/REAL_CONST(24.0); + factor = (real_t)pow(2.0, exp); + + /* Apply gain factor */ + for (i = bottom; i < top; i++) + spec[i] *= factor; +#else + /* Decode DRC gain factor */ + if (drc->dyn_rng_sgn[bd]) /* compress */ + { + exp = -1 * (drc->dyn_rng_ctl[bd] - (DRC_REF_LEVEL - drc->prog_ref_level))/ 24; + frac = -1 * (drc->dyn_rng_ctl[bd] - (DRC_REF_LEVEL - drc->prog_ref_level)) % 24; + } else { /* boost */ + exp = (drc->dyn_rng_ctl[bd] - (DRC_REF_LEVEL - drc->prog_ref_level))/ 24; + frac = (drc->dyn_rng_ctl[bd] - (DRC_REF_LEVEL - drc->prog_ref_level)) % 24; + } + + /* Apply gain factor */ + if (exp < 0) + { + for (i = bottom; i < top; i++) + { + spec[i] >>= -exp; + if (frac) + spec[i] = MUL_R(spec[i],drc_pow2_table[frac+23]); + } + } else { + for (i = bottom; i < top; i++) + { + spec[i] <<= exp; + if (frac) + spec[i] = MUL_R(spec[i],drc_pow2_table[frac+23]); + } + } +#endif + + bottom = top; + } +} diff --git a/lib/rbcodec/codecs/libfaad/drc.h b/lib/rbcodec/codecs/libfaad/drc.h new file mode 100644 index 0000000000..38037a1a12 --- /dev/null +++ b/lib/rbcodec/codecs/libfaad/drc.h @@ -0,0 +1,45 @@ +/* +** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding +** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +** +** Any non-GPL usage of this software or parts of this software is strictly +** forbidden. +** +** Commercial non-GPL licensing of this software is possible. +** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** +** $Id$ +**/ + +#ifndef __DRC_H__ +#define __DRC_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#define DRC_REF_LEVEL 20*4 /* -20 dB */ + + +drc_info *drc_init(real_t cut, real_t boost); +void drc_decode(drc_info *drc, real_t *spec); + + +#ifdef __cplusplus +} +#endif +#endif diff --git a/lib/rbcodec/codecs/libfaad/drm_dec.c b/lib/rbcodec/codecs/libfaad/drm_dec.c new file mode 100644 index 0000000000..f0b0f01f2b --- /dev/null +++ b/lib/rbcodec/codecs/libfaad/drm_dec.c @@ -0,0 +1,992 @@ +/* +** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR and PS decoding +** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +** +** Any non-GPL usage of this software or parts of this software is strictly +** forbidden. +** +** Commercial non-GPL licensing of this software is possible. +** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** +** $Id$ +**/ + +#include +#include +#include +#include +#include "common.h" + +#ifdef DRM + +#include "sbr_dec.h" +#include "drm_dec.h" +#include "bits.h" + +/* constants */ +#define DECAY_CUTOFF 3 +#define DECAY_SLOPE 0.05f + +/* type definitions */ +typedef const int8_t (*drm_ps_huff_tab)[2]; + + +/* binary search huffman tables */ +static const int8_t f_huffman_sa[][2] = +{ + { /*0*/ -15, 1 }, /* index 0: 1 bits: x */ + { 2, 3 }, /* index 1: 2 bits: 1x */ + { /*7*/ -8, 4 }, /* index 2: 3 bits: 10x */ + { 5, 6 }, /* index 3: 3 bits: 11x */ + { /*1*/ -14, /*-1*/ -16 }, /* index 4: 4 bits: 101x */ + { /*-2*/ -17, 7 }, /* index 5: 4 bits: 110x */ + { 8, 9 }, /* index 6: 4 bits: 111x */ + { /*2*/ -13, /*-3*/ -18 }, /* index 7: 5 bits: 1101x */ + { /*3*/ -12, 10 }, /* index 8: 5 bits: 1110x */ + { 11, 12 }, /* index 9: 5 bits: 1111x */ + { /*4*/ -11, /*5*/ -10 }, /* index 10: 6 bits: 11101x */ + { /*-4*/ -19, /*-5*/ -20 }, /* index 11: 6 bits: 11110x */ + { /*6*/ -9, 13 }, /* index 12: 6 bits: 11111x */ + { /*-7*/ -22, /*-6*/ -21 } /* index 13: 7 bits: 111111x */ +}; + +static const int8_t t_huffman_sa[][2] = +{ + { /*0*/ -15, 1 }, /* index 0: 1 bits: x */ + { 2, 3 }, /* index 1: 2 bits: 1x */ + { /*-1*/ -16, /*1*/ -14 }, /* index 2: 3 bits: 10x */ + { 4, 5 }, /* index 3: 3 bits: 11x */ + { /*-2*/ -17, /*2*/ -13 }, /* index 4: 4 bits: 110x */ + { 6, 7 }, /* index 5: 4 bits: 111x */ + { /*-3*/ -18, /*3*/ -12 }, /* index 6: 5 bits: 1110x */ + { 8, 9 }, /* index 7: 5 bits: 1111x */ + { /*-4*/ -19, /*4*/ -11 }, /* index 8: 6 bits: 11110x */ + { 10, 11 }, /* index 9: 6 bits: 11111x */ + { /*-5*/ -20, /*5*/ -10 }, /* index 10: 7 bits: 111110x */ + { /*-6*/ -21, 12 }, /* index 11: 7 bits: 111111x */ + { /*-7*/ -22, 13 }, /* index 12: 8 bits: 1111111x */ + { /*6*/ -9, /*7*/ -8 } /* index 13: 9 bits: 11111111x */ +}; + +static const int8_t f_huffman_pan[][2] = +{ + { /*0*/ -15, 1 }, /* index 0: 1 bits: x */ + { /*-1*/ -16, 2 }, /* index 1: 2 bits: 1x */ + { /*1*/ -14, 3 }, /* index 2: 3 bits: 11x */ + { 4, 5 }, /* index 3: 4 bits: 111x */ + { /*-2*/ -17, /*2*/ -13 }, /* index 4: 5 bits: 1110x */ + { 6, 7 }, /* index 5: 5 bits: 1111x */ + { /*-3*/ -18, /*3*/ -12 }, /* index 6: 6 bits: 11110x */ + { 8, 9 }, /* index 7: 6 bits: 11111x */ + { /*-4*/ -19, /*4*/ -11 }, /* index 8: 7 bits: 111110x */ + { 10, 11 }, /* index 9: 7 bits: 111111x */ + { /*-5*/ -20, /*5*/ -10 }, /* index 10: 8 bits: 1111110x */ + { 12, 13 }, /* index 11: 8 bits: 1111111x */ + { /*-6*/ -21, /*6*/ -9 }, /* index 12: 9 bits: 11111110x */ + { /*-7*/ -22, 14 }, /* index 13: 9 bits: 11111111x */ + { /*7*/ -8, 15 }, /* index 14: 10 bits: 111111111x */ + { 16, 17 }, /* index 15: 11 bits: 1111111111x */ + { /*-8*/ -23, /*8*/ -7 }, /* index 16: 12 bits: 11111111110x */ + { 18, 19 }, /* index 17: 12 bits: 11111111111x */ + { /*-10*/ -25, 20 }, /* index 18: 13 bits: 111111111110x */ + { 21, 22 }, /* index 19: 13 bits: 111111111111x */ + { /*-9*/ -24, /*9*/ -6 }, /* index 20: 14 bits: 1111111111101x */ + { /*10*/ -5, 23 }, /* index 21: 14 bits: 1111111111110x */ + { 24, 25 }, /* index 22: 14 bits: 1111111111111x */ + { /*-13*/ -28, /*-11*/ -26 }, /* index 23: 15 bits: 11111111111101x */ + { /*11*/ -4, /*13*/ -2 }, /* index 24: 15 bits: 11111111111110x */ + { 26, 27 }, /* index 25: 15 bits: 11111111111111x */ + { /*-14*/ -29, /*-12*/ -27 }, /* index 26: 16 bits: 111111111111110x */ + { /*12*/ -3, /*14*/ -1 } /* index 27: 16 bits: 111111111111111x */ +}; + +static const int8_t t_huffman_pan[][2] = +{ + { /*0*/ -15, 1 }, /* index 0: 1 bits: x */ + { /*-1*/ -16, 2 }, /* index 1: 2 bits: 1x */ + { /*1*/ -14, 3 }, /* index 2: 3 bits: 11x */ + { /*-2*/ -17, 4 }, /* index 3: 4 bits: 111x */ + { /*2*/ -13, 5 }, /* index 4: 5 bits: 1111x */ + { /*-3*/ -18, 6 }, /* index 5: 6 bits: 11111x */ + { /*3*/ -12, 7 }, /* index 6: 7 bits: 111111x */ + { /*-4*/ -19, 8 }, /* index 7: 8 bits: 1111111x */ + { /*4*/ -11, 9 }, /* index 8: 9 bits: 11111111x */ + { 10, 11 }, /* index 9: 10 bits: 111111111x */ + { /*-5*/ -20, /*5*/ -10 }, /* index 10: 11 bits: 1111111110x */ + { 12, 13 }, /* index 11: 11 bits: 1111111111x */ + { /*-6*/ -21, /*6*/ -9 }, /* index 12: 12 bits: 11111111110x */ + { 14, 15 }, /* index 13: 12 bits: 11111111111x */ + { /*-7*/ -22, /*7*/ -8 }, /* index 14: 13 bits: 111111111110x */ + { 16, 17 }, /* index 15: 13 bits: 111111111111x */ + { /*-8*/ -23, /*8*/ -7 }, /* index 16: 14 bits: 1111111111110x */ + { 18, 19 }, /* index 17: 14 bits: 1111111111111x */ + { /*-10*/ -25, /*10*/ -5 }, /* index 18: 15 bits: 11111111111110x */ + { 20, 21 }, /* index 19: 15 bits: 11111111111111x */ + { /*-9*/ -24, /*9*/ -6 }, /* index 20: 16 bits: 111111111111110x */ + { 22, 23 }, /* index 21: 16 bits: 111111111111111x */ + { 24, 25 }, /* index 22: 17 bits: 1111111111111110x */ + { 26, 27 }, /* index 23: 17 bits: 1111111111111111x */ + { /*-14*/ -29, /*-13*/ -28 }, /* index 24: 18 bits: 11111111111111100x */ + { /*-12*/ -27, /*-11*/ -26 }, /* index 25: 18 bits: 11111111111111101x */ + { /*11*/ -4, /*12*/ -3 }, /* index 26: 18 bits: 11111111111111110x */ + { /*13*/ -2, /*14*/ -1 } /* index 27: 18 bits: 11111111111111111x */ +}; + +/* There are 3 classes in the standard but the last 2 are identical */ +static const real_t sa_quant[8][2] = +{ + { FRAC_CONST(0.0000), FRAC_CONST(0.0000) }, + { FRAC_CONST(0.0501), FRAC_CONST(0.1778) }, + { FRAC_CONST(0.0706), FRAC_CONST(0.2818) }, + { FRAC_CONST(0.0995), FRAC_CONST(0.4467) }, + { FRAC_CONST(0.1399), FRAC_CONST(0.5623) }, + { FRAC_CONST(0.1957), FRAC_CONST(0.7079) }, + { FRAC_CONST(0.2713), FRAC_CONST(0.8913) }, + { FRAC_CONST(0.3699), FRAC_CONST(1.0000) }, +}; + +/* We don't need the actual quantizer values */ +#if 0 +static const real_t pan_quant[8][5] = +{ + { COEF_CONST(0.0000), COEF_CONST(0.0000), COEF_CONST(0.0000), COEF_CONST(0.0000), COEF_CONST(0.0000) }, + { COEF_CONST(0.1661), COEF_CONST(0.1661), COEF_CONST(0.3322), COEF_CONST(0.3322), COEF_CONST(0.3322) }, + { COEF_CONST(0.3322), COEF_CONST(0.3322), COEF_CONST(0.6644), COEF_CONST(0.8305), COEF_CONST(0.8305) }, + { COEF_CONST(0.4983), COEF_CONST(0.6644), COEF_CONST(0.9966), COEF_CONST(1.4949), COEF_CONST(1.6610) }, + { COEF_CONST(0.6644), COEF_CONST(0.9966), COEF_CONST(1.4949), COEF_CONST(2.1593), COEF_CONST(2.4914) }, + { COEF_CONST(0.8305), COEF_CONST(1.3288), COEF_CONST(2.1593), COEF_CONST(2.9897), COEF_CONST(3.4880) }, + { COEF_CONST(0.9966), COEF_CONST(1.8271), COEF_CONST(2.8236), COEF_CONST(3.8202), COEF_CONST(4.6507) }, + { COEF_CONST(1.3288), COEF_CONST(2.3253), COEF_CONST(3.4880), COEF_CONST(4.6507), COEF_CONST(5.8134) }, +}; +#endif + +/* 2^(pan_quant[x][y] */ +static const real_t pan_pow_2_pos[8][5] = { + { REAL_CONST(1.0000000), REAL_CONST(1.0000000), REAL_CONST(1.0000000), REAL_CONST(1.0000000), REAL_CONST(1.0000000) }, + { REAL_CONST(1.1220021), REAL_CONST(1.1220021), REAL_CONST(1.2589312), REAL_CONST(1.2589312), REAL_CONST(1.2589312) }, + { REAL_CONST(1.2589312), REAL_CONST(1.2589312), REAL_CONST(1.5849090), REAL_CONST(1.7783016), REAL_CONST(1.7783016) }, + { REAL_CONST(1.4125481), REAL_CONST(1.5849090), REAL_CONST(1.9952921), REAL_CONST(2.8184461), REAL_CONST(3.1623565) }, + { REAL_CONST(1.5849090), REAL_CONST(1.9952922), REAL_CONST(2.8184461), REAL_CONST(4.4669806), REAL_CONST(5.6232337) }, + { REAL_CONST(1.7783016), REAL_CONST(2.5119365), REAL_CONST(4.4669806), REAL_CONST(7.9430881), REAL_CONST(11.219994) }, + { REAL_CONST(1.9952921), REAL_CONST(3.5482312), REAL_CONST(7.0792671), REAL_CONST(14.125206), REAL_CONST(25.118876) }, + { REAL_CONST(2.5119365), REAL_CONST(5.0116998), REAL_CONST(11.219994), REAL_CONST(25.118876), REAL_CONST(56.235140) } +}; + +/* 2^(-pan_quant[x][y] */ +static const real_t pan_pow_2_neg[8][5] = { + { REAL_CONST(1), REAL_CONST(1), REAL_CONST(1), REAL_CONST(1), REAL_CONST(1) }, + { REAL_CONST(0.8912487), REAL_CONST(0.8912487), REAL_CONST(0.7943242), REAL_CONST(0.7943242), REAL_CONST(0.7943242) }, + { REAL_CONST(0.7943242), REAL_CONST(0.7943242), REAL_CONST(0.6309511), REAL_CONST(0.5623344), REAL_CONST(0.5623344) }, + { REAL_CONST(0.7079405), REAL_CONST(0.6309511), REAL_CONST(0.5011797), REAL_CONST(0.3548054), REAL_CONST(0.3162199) }, + { REAL_CONST(0.6309511), REAL_CONST(0.5011797), REAL_CONST(0.3548054), REAL_CONST(0.2238649), REAL_CONST(0.1778336) }, + { REAL_CONST(0.5623343), REAL_CONST(0.3980992), REAL_CONST(0.2238649), REAL_CONST(0.1258956), REAL_CONST(0.0891266) }, + { REAL_CONST(0.5011797), REAL_CONST(0.2818306), REAL_CONST(0.1412576), REAL_CONST(0.0707954), REAL_CONST(0.0398107) }, + { REAL_CONST(0.3980992), REAL_CONST(0.1995331), REAL_CONST(0.0891267), REAL_CONST(0.0398107), REAL_CONST(0.0177825) } +}; + +/* 2^(pan_quant[x][y]/30) */ +static const real_t pan_pow_2_30_pos[8][5] = { + { COEF_CONST(1), COEF_CONST(1), COEF_CONST(1), COEF_CONST(1), COEF_CONST(1) }, + { COEF_CONST(1.003845098), COEF_CONST(1.003845098), COEF_CONST(1.007704982), COEF_CONST(1.007704982), COEF_CONST(1.007704982) }, + { COEF_CONST(1.007704982), COEF_CONST(1.007704982), COEF_CONST(1.01546933), COEF_CONST(1.019373909), COEF_CONST(1.019373909) }, + { COEF_CONST(1.011579706), COEF_CONST(1.01546933), COEF_CONST(1.023293502), COEF_CONST(1.035142941), COEF_CONST(1.039123167) }, + { COEF_CONST(1.01546933), COEF_CONST(1.023293502), COEF_CONST(1.035142941), COEF_CONST(1.051155908), COEF_CONST(1.059252598) }, + { COEF_CONST(1.019373909), COEF_CONST(1.03117796), COEF_CONST(1.051155908), COEF_CONST(1.071518432), COEF_CONST(1.0839263) }, + { COEF_CONST(1.023293502), COEF_CONST(1.043118698), COEF_CONST(1.067414119), COEF_CONST(1.092277933), COEF_CONST(1.113439626) }, + { COEF_CONST(1.03117796), COEF_CONST(1.055195268), COEF_CONST(1.0839263), COEF_CONST(1.113439626), COEF_CONST(1.143756546) } +}; + +/* 2^(-pan_quant[x][y]/30) */ +static const real_t pan_pow_2_30_neg[8][5] = { + { COEF_CONST(1), COEF_CONST(1), COEF_CONST(1), COEF_CONST(1), COEF_CONST(1) }, + { COEF_CONST(0.99616963), COEF_CONST(0.99616963), COEF_CONST(0.992353931), COEF_CONST(0.992353931), COEF_CONST(0.99235393) }, + { COEF_CONST(0.992353931), COEF_CONST(0.992353931), COEF_CONST(0.984766325), COEF_CONST(0.980994305), COEF_CONST(0.980994305) }, + { COEF_CONST(0.988552848), COEF_CONST(0.984766325), COEF_CONST(0.977236734), COEF_CONST(0.966050157), COEF_CONST(0.962349827) }, + { COEF_CONST(0.984766325), COEF_CONST(0.977236734), COEF_CONST(0.966050157), COEF_CONST(0.951333663), COEF_CONST(0.944061881) }, + { COEF_CONST(0.980994305), COEF_CONST(0.969764715), COEF_CONST(0.951333663), COEF_CONST(0.933255062), COEF_CONST(0.922571949) }, + { COEF_CONST(0.977236734), COEF_CONST(0.958663671), COEF_CONST(0.936843519), COEF_CONST(0.915517901), COEF_CONST(0.898117847) }, + { COEF_CONST(0.969764715), COEF_CONST(0.947691892), COEF_CONST(0.922571949), COEF_CONST(0.898117847), COEF_CONST(0.874311936) } +}; + +static const real_t g_decayslope[MAX_SA_BAND] = { + FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(0.95),FRAC_CONST(0.9), FRAC_CONST(0.85), FRAC_CONST(0.8), + FRAC_CONST(0.75),FRAC_CONST(0.7), FRAC_CONST(0.65),FRAC_CONST(0.6), FRAC_CONST(0.55),FRAC_CONST(0.5), FRAC_CONST(0.45), + FRAC_CONST(0.4), FRAC_CONST(0.35),FRAC_CONST(0.3), FRAC_CONST(0.25),FRAC_CONST(0.2), FRAC_CONST(0.15), FRAC_CONST(0.1), + FRAC_CONST(0.05),FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), + FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), + FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0), + FRAC_CONST(0), FRAC_CONST(0), FRAC_CONST(0) +}; + +static const real_t sa_sqrt_1_minus[8][2] = { + { FRAC_CONST(1), FRAC_CONST(1) }, + { FRAC_CONST(0.998744206), FRAC_CONST(0.984066644) }, + { FRAC_CONST(0.997504707), FRAC_CONST(0.959473168) }, + { FRAC_CONST(0.995037562), FRAC_CONST(0.894683804) }, + { FRAC_CONST(0.990165638), FRAC_CONST(0.826933317) }, + { FRAC_CONST(0.980663811), FRAC_CONST(0.706312672) }, + { FRAC_CONST(0.962494836), FRAC_CONST(0.45341406) }, + { FRAC_CONST(0.929071574), FRAC_CONST(0) } +}; + +static const uint8_t sa_freq_scale[9][2] = +{ + { 0, 0}, + { 1, 1}, + { 2, 2}, + { 3, 3}, + { 5, 5}, + { 7, 7}, + {10,10}, + {13,13}, + {46,23} +}; + +static const uint8_t pan_freq_scale[21] = +{ + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, + 11, 12, 13, 14, 15, 18, 22, 26, 32, 64 +}; + +static const uint8_t pan_quant_class[20] = +{ + 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 2, 2, 2, 2, 3, 3, 3, 4, 4, 4 +}; + +/* Inverse mapping lookup */ +static const uint8_t pan_inv_freq[64] = { + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 15, 15, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, + 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19 +}; + +static const uint8_t sa_inv_freq[MAX_SA_BAND] = { + 0, 1, 2, 3, 3, 4, 4, 5, 5, 5, 6, 6, 6, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7 +}; + +static const real_t filter_coeff[] = +{ + FRAC_CONST(0.65143905754106), + FRAC_CONST(0.56471812200776), + FRAC_CONST(0.48954165955695) +}; + +static const uint8_t delay_length[][2] = +{ + { 1, 3 }, { 2, 4 }, { 3, 5 } +}; + +static const real_t delay_fraction[] = +{ + FRAC_CONST(0.43), FRAC_CONST(0.75), FRAC_CONST(0.347) +}; + +static const real_t peak_decay[2] = +{ + FRAC_CONST(0.58664621951003), FRAC_CONST(0.76592833836465) +}; + +static const real_t smooth_coeff[2] = +{ + FRAC_CONST(0.6), FRAC_CONST(0.25) +}; + +/* Please note that these are the same tables as in plain PS */ +static const complex_t Q_Fract_allpass_Qmf[][3] = { + { { FRAC_CONST(0.7804303765), FRAC_CONST(0.6252426505) }, { FRAC_CONST(0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(0.8550928831), FRAC_CONST(0.5184748173) } }, + { { FRAC_CONST(-0.4399392009), FRAC_CONST(0.8980275393) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(-0.0643581524), FRAC_CONST(0.9979268909) } }, + { { FRAC_CONST(-0.9723699093), FRAC_CONST(-0.2334454209) }, { FRAC_CONST(0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(-0.9146071672), FRAC_CONST(0.4043435752) } }, + { { FRAC_CONST(0.0157073960), FRAC_CONST(-0.9998766184) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(-0.7814115286), FRAC_CONST(-0.6240159869) } }, + { { FRAC_CONST(0.9792228341), FRAC_CONST(-0.2027871907) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(0.1920081824), FRAC_CONST(-0.9813933372) } }, + { { FRAC_CONST(0.4115142524), FRAC_CONST(0.9114032984) }, { FRAC_CONST(0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(0.9589683414), FRAC_CONST(-0.2835132182) } }, + { { FRAC_CONST(-0.7996847630), FRAC_CONST(0.6004201174) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(0.6947838664), FRAC_CONST(0.7192186117) } }, + { { FRAC_CONST(-0.7604058385), FRAC_CONST(-0.6494481564) }, { FRAC_CONST(0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(-0.3164770305), FRAC_CONST(0.9486001730) } }, + { { FRAC_CONST(0.4679299891), FRAC_CONST(-0.8837655187) }, { FRAC_CONST(0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(-0.9874414206), FRAC_CONST(0.1579856575) } }, + { { FRAC_CONST(0.9645573497), FRAC_CONST(0.2638732493) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(-0.5966450572), FRAC_CONST(-0.8025052547) } }, + { { FRAC_CONST(-0.0471066870), FRAC_CONST(0.9988898635) }, { FRAC_CONST(0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(0.4357025325), FRAC_CONST(-0.9000906944) } }, + { { FRAC_CONST(-0.9851093888), FRAC_CONST(0.1719288528) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(0.9995546937), FRAC_CONST(-0.0298405960) } }, + { { FRAC_CONST(-0.3826831877), FRAC_CONST(-0.9238796234) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(0.4886211455), FRAC_CONST(0.8724960685) } }, + { { FRAC_CONST(0.8181498647), FRAC_CONST(-0.5750049949) }, { FRAC_CONST(0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(-0.5477093458), FRAC_CONST(0.8366686702) } }, + { { FRAC_CONST(0.7396308780), FRAC_CONST(0.6730127335) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(-0.9951074123), FRAC_CONST(-0.0987988561) } }, + { { FRAC_CONST(-0.4954589605), FRAC_CONST(0.8686313629) }, { FRAC_CONST(0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(-0.3725017905), FRAC_CONST(-0.9280315042) } }, + { { FRAC_CONST(-0.9557929039), FRAC_CONST(-0.2940406799) }, { FRAC_CONST(0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(0.6506417990), FRAC_CONST(-0.7593847513) } }, + { { FRAC_CONST(0.0784594864), FRAC_CONST(-0.9969173074) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(0.9741733670), FRAC_CONST(0.2258014232) } }, + { { FRAC_CONST(0.9900237322), FRAC_CONST(-0.1409008205) }, { FRAC_CONST(0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(0.2502108514), FRAC_CONST(0.9681913853) } }, + { { FRAC_CONST(0.3534744382), FRAC_CONST(0.9354441762) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(-0.7427945137), FRAC_CONST(0.6695194840) } }, + { { FRAC_CONST(-0.8358076215), FRAC_CONST(0.5490224361) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(-0.9370992780), FRAC_CONST(-0.3490629196) } }, + { { FRAC_CONST(-0.7181259394), FRAC_CONST(-0.6959131360) }, { FRAC_CONST(0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(-0.1237744763), FRAC_CONST(-0.9923103452) } }, + { { FRAC_CONST(0.5224990249), FRAC_CONST(-0.8526399136) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(0.8226406574), FRAC_CONST(-0.5685616732) } }, + { { FRAC_CONST(0.9460852146), FRAC_CONST(0.3239179254) }, { FRAC_CONST(0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(0.8844994903), FRAC_CONST(0.4665412009) } }, + { { FRAC_CONST(-0.1097348556), FRAC_CONST(0.9939609170) }, { FRAC_CONST(0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(-0.0047125919), FRAC_CONST(0.9999889135) } }, + { { FRAC_CONST(-0.9939610362), FRAC_CONST(0.1097337380) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(-0.8888573647), FRAC_CONST(0.4581840038) } }, + { { FRAC_CONST(-0.3239168525), FRAC_CONST(-0.9460855722) }, { FRAC_CONST(0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(-0.8172453642), FRAC_CONST(-0.5762898922) } }, + { { FRAC_CONST(0.8526405096), FRAC_CONST(-0.5224980116) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(0.1331215799), FRAC_CONST(-0.9910997152) } }, + { { FRAC_CONST(0.6959123611), FRAC_CONST(0.7181267142) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(0.9403476119), FRAC_CONST(-0.3402152061) } }, + { { FRAC_CONST(-0.5490233898), FRAC_CONST(0.8358070254) }, { FRAC_CONST(0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(0.7364512086), FRAC_CONST(0.6764906645) } }, + { { FRAC_CONST(-0.9354437590), FRAC_CONST(-0.3534754813) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(-0.2593250275), FRAC_CONST(0.9657900929) } }, + { { FRAC_CONST(0.1409019381), FRAC_CONST(-0.9900235534) }, { FRAC_CONST(0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(-0.9762582779), FRAC_CONST(0.2166097313) } }, + { { FRAC_CONST(0.9969173670), FRAC_CONST(-0.0784583688) }, { FRAC_CONST(0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(-0.6434556246), FRAC_CONST(-0.7654833794) } }, + { { FRAC_CONST(0.2940396070), FRAC_CONST(0.9557932615) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(0.3812320232), FRAC_CONST(-0.9244794250) } }, + { { FRAC_CONST(-0.8686318994), FRAC_CONST(0.4954580069) }, { FRAC_CONST(0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(0.9959943891), FRAC_CONST(-0.0894154981) } }, + { { FRAC_CONST(-0.6730118990), FRAC_CONST(-0.7396316528) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(0.5397993922), FRAC_CONST(0.8417937160) } }, + { { FRAC_CONST(0.5750059485), FRAC_CONST(-0.8181492686) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(-0.4968227744), FRAC_CONST(0.8678520322) } }, + { { FRAC_CONST(0.9238792062), FRAC_CONST(0.3826842010) }, { FRAC_CONST(0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(-0.9992290139), FRAC_CONST(-0.0392601527) } }, + { { FRAC_CONST(-0.1719299555), FRAC_CONST(0.9851091504) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(-0.4271997511), FRAC_CONST(-0.9041572809) } }, + { { FRAC_CONST(-0.9988899231), FRAC_CONST(0.0471055657) }, { FRAC_CONST(0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(0.6041822433), FRAC_CONST(-0.7968461514) } }, + { { FRAC_CONST(-0.2638721764), FRAC_CONST(-0.9645576477) }, { FRAC_CONST(0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(0.9859085083), FRAC_CONST(0.1672853529) } }, + { { FRAC_CONST(0.8837660551), FRAC_CONST(-0.4679289758) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(0.3075223565), FRAC_CONST(0.9515408874) } }, + { { FRAC_CONST(0.6494473219), FRAC_CONST(0.7604066133) }, { FRAC_CONST(0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(-0.7015317082), FRAC_CONST(0.7126382589) } }, + { { FRAC_CONST(-0.6004210114), FRAC_CONST(0.7996840477) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(-0.9562535882), FRAC_CONST(-0.2925389707) } }, + { { FRAC_CONST(-0.9114028811), FRAC_CONST(-0.4115152657) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(-0.1827499419), FRAC_CONST(-0.9831594229) } }, + { { FRAC_CONST(0.2027882934), FRAC_CONST(-0.9792225957) }, { FRAC_CONST(0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(0.7872582674), FRAC_CONST(-0.6166234016) } }, + { { FRAC_CONST(0.9998766780), FRAC_CONST(-0.0157062728) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(0.9107555747), FRAC_CONST(0.4129458666) } }, + { { FRAC_CONST(0.2334443331), FRAC_CONST(0.9723701477) }, { FRAC_CONST(0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(0.0549497530), FRAC_CONST(0.9984891415) } }, + { { FRAC_CONST(-0.8980280757), FRAC_CONST(0.4399381876) }, { FRAC_CONST(0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(-0.8599416018), FRAC_CONST(0.5103924870) } }, + { { FRAC_CONST(-0.6252418160), FRAC_CONST(-0.7804310918) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(-0.8501682281), FRAC_CONST(-0.5265110731) } }, + { { FRAC_CONST(0.6252435446), FRAC_CONST(-0.7804297209) }, { FRAC_CONST(0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(0.0737608299), FRAC_CONST(-0.9972759485) } }, + { { FRAC_CONST(0.8980270624), FRAC_CONST(0.4399402142) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(0.9183775187), FRAC_CONST(-0.3957053721) } }, + { { FRAC_CONST(-0.2334465086), FRAC_CONST(0.9723696709) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(0.7754954696), FRAC_CONST(0.6313531399) } }, + { { FRAC_CONST(-0.9998766184), FRAC_CONST(-0.0157085191) }, { FRAC_CONST(0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(-0.2012493610), FRAC_CONST(0.9795400500) } }, + { { FRAC_CONST(-0.2027861029), FRAC_CONST(-0.9792230725) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(-0.9615978599), FRAC_CONST(0.2744622827) } }, + { { FRAC_CONST(0.9114037752), FRAC_CONST(-0.4115132093) }, { FRAC_CONST(0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(-0.6879743338), FRAC_CONST(-0.7257350087) } }, + { { FRAC_CONST(0.6004192233), FRAC_CONST(0.7996854186) }, { FRAC_CONST(0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(0.3254036009), FRAC_CONST(-0.9455752373) } }, + { { FRAC_CONST(-0.6494490504), FRAC_CONST(0.7604051232) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(0.9888865948), FRAC_CONST(-0.1486719251) } }, + { { FRAC_CONST(-0.8837650418), FRAC_CONST(-0.4679309726) }, { FRAC_CONST(0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(0.5890548825), FRAC_CONST(0.8080930114) } }, + { { FRAC_CONST(0.2638743520), FRAC_CONST(-0.9645570517) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(-0.4441666007), FRAC_CONST(0.8959442377) } }, + { { FRAC_CONST(0.9988898039), FRAC_CONST(0.0471078083) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(-0.9997915030), FRAC_CONST(0.0204183888) } }, + { { FRAC_CONST(0.1719277352), FRAC_CONST(0.9851095676) }, { FRAC_CONST(0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(-0.4803760946), FRAC_CONST(-0.8770626187) } }, + { { FRAC_CONST(-0.9238800406), FRAC_CONST(0.3826821446) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(0.5555707216), FRAC_CONST(-0.8314692974) } }, + { { FRAC_CONST(-0.5750041008), FRAC_CONST(-0.8181505203) }, { FRAC_CONST(0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(0.9941320419), FRAC_CONST(0.1081734300) } } +}; + +static const complex_t Phi_Fract_Qmf[] = { + { FRAC_CONST(0.8181497455), FRAC_CONST(0.5750052333) }, + { FRAC_CONST(-0.2638730407), FRAC_CONST(0.9645574093) }, + { FRAC_CONST(-0.9969173074), FRAC_CONST(0.0784590989) }, + { FRAC_CONST(-0.4115143716), FRAC_CONST(-0.9114032984) }, + { FRAC_CONST(0.7181262970), FRAC_CONST(-0.6959127784) }, + { FRAC_CONST(0.8980275989), FRAC_CONST(0.4399391711) }, + { FRAC_CONST(-0.1097343117), FRAC_CONST(0.9939609766) }, + { FRAC_CONST(-0.9723699093), FRAC_CONST(0.2334453613) }, + { FRAC_CONST(-0.5490227938), FRAC_CONST(-0.8358073831) }, + { FRAC_CONST(0.6004202366), FRAC_CONST(-0.7996846437) }, + { FRAC_CONST(0.9557930231), FRAC_CONST(0.2940403223) }, + { FRAC_CONST(0.0471064523), FRAC_CONST(0.9988898635) }, + { FRAC_CONST(-0.9238795042), FRAC_CONST(0.3826834261) }, + { FRAC_CONST(-0.6730124950), FRAC_CONST(-0.7396311164) }, + { FRAC_CONST(0.4679298103), FRAC_CONST(-0.8837656379) }, + { FRAC_CONST(0.9900236726), FRAC_CONST(0.1409012377) }, + { FRAC_CONST(0.2027872950), FRAC_CONST(0.9792228341) }, + { FRAC_CONST(-0.8526401520), FRAC_CONST(0.5224985480) }, + { FRAC_CONST(-0.7804304361), FRAC_CONST(-0.6252426505) }, + { FRAC_CONST(0.3239174187), FRAC_CONST(-0.9460853338) }, + { FRAC_CONST(0.9998766184), FRAC_CONST(-0.0157073177) }, + { FRAC_CONST(0.3534748554), FRAC_CONST(0.9354440570) }, + { FRAC_CONST(-0.7604059577), FRAC_CONST(0.6494480371) }, + { FRAC_CONST(-0.8686315417), FRAC_CONST(-0.4954586625) }, + { FRAC_CONST(0.1719291061), FRAC_CONST(-0.9851093292) }, + { FRAC_CONST(0.9851093292), FRAC_CONST(-0.1719291061) }, + { FRAC_CONST(0.4954586625), FRAC_CONST(0.8686315417) }, + { FRAC_CONST(-0.6494480371), FRAC_CONST(0.7604059577) }, + { FRAC_CONST(-0.9354440570), FRAC_CONST(-0.3534748554) }, + { FRAC_CONST(0.0157073177), FRAC_CONST(-0.9998766184) }, + { FRAC_CONST(0.9460853338), FRAC_CONST(-0.3239174187) }, + { FRAC_CONST(0.6252426505), FRAC_CONST(0.7804304361) }, + { FRAC_CONST(-0.5224985480), FRAC_CONST(0.8526401520) }, + { FRAC_CONST(-0.9792228341), FRAC_CONST(-0.2027872950) }, + { FRAC_CONST(-0.1409012377), FRAC_CONST(-0.9900236726) }, + { FRAC_CONST(0.8837656379), FRAC_CONST(-0.4679298103) }, + { FRAC_CONST(0.7396311164), FRAC_CONST(0.6730124950) }, + { FRAC_CONST(-0.3826834261), FRAC_CONST(0.9238795042) }, + { FRAC_CONST(-0.9988898635), FRAC_CONST(-0.0471064523) }, + { FRAC_CONST(-0.2940403223), FRAC_CONST(-0.9557930231) }, + { FRAC_CONST(0.7996846437), FRAC_CONST(-0.6004202366) }, + { FRAC_CONST(0.8358073831), FRAC_CONST(0.5490227938) }, + { FRAC_CONST(-0.2334453613), FRAC_CONST(0.9723699093) }, + { FRAC_CONST(-0.9939609766), FRAC_CONST(0.1097343117) }, + { FRAC_CONST(-0.4399391711), FRAC_CONST(-0.8980275989) }, + { FRAC_CONST(0.6959127784), FRAC_CONST(-0.7181262970) }, + { FRAC_CONST(0.9114032984), FRAC_CONST(0.4115143716) }, + { FRAC_CONST(-0.0784590989), FRAC_CONST(0.9969173074) }, + { FRAC_CONST(-0.9645574093), FRAC_CONST(0.2638730407) }, + { FRAC_CONST(-0.5750052333), FRAC_CONST(-0.8181497455) }, + { FRAC_CONST(0.5750052333), FRAC_CONST(-0.8181497455) }, + { FRAC_CONST(0.9645574093), FRAC_CONST(0.2638730407) }, + { FRAC_CONST(0.0784590989), FRAC_CONST(0.9969173074) }, + { FRAC_CONST(-0.9114032984), FRAC_CONST(0.4115143716) }, + { FRAC_CONST(-0.6959127784), FRAC_CONST(-0.7181262970) }, + { FRAC_CONST(0.4399391711), FRAC_CONST(-0.8980275989) }, + { FRAC_CONST(0.9939609766), FRAC_CONST(0.1097343117) }, + { FRAC_CONST(0.2334453613), FRAC_CONST(0.9723699093) }, + { FRAC_CONST(-0.8358073831), FRAC_CONST(0.5490227938) }, + { FRAC_CONST(-0.7996846437), FRAC_CONST(-0.6004202366) }, + { FRAC_CONST(0.2940403223), FRAC_CONST(-0.9557930231) }, + { FRAC_CONST(0.9988898635), FRAC_CONST(-0.0471064523) }, + { FRAC_CONST(0.3826834261), FRAC_CONST(0.9238795042) }, + { FRAC_CONST(-0.7396311164), FRAC_CONST(0.6730124950) } +}; + +/* static variables */ +static drm_ps_info s_drm_ps_info; + +/* static function declarations */ +static void drm_ps_sa_element(drm_ps_info *ps, bitfile *ld); +static void drm_ps_pan_element(drm_ps_info *ps, bitfile *ld); +static int8_t huff_dec(bitfile *ld, drm_ps_huff_tab huff); + + +uint16_t drm_ps_data(drm_ps_info *ps, bitfile *ld) +{ + uint16_t bits = (uint16_t)faad_get_processed_bits(ld); + + ps->drm_ps_data_available = 1; + + ps->bs_enable_sa = faad_get1bit(ld); + ps->bs_enable_pan = faad_get1bit(ld); + + if (ps->bs_enable_sa) + { + drm_ps_sa_element(ps, ld); + } + + if (ps->bs_enable_pan) + { + drm_ps_pan_element(ps, ld); + } + + bits = (uint16_t)faad_get_processed_bits(ld) - bits; + + return bits; +} + +static void drm_ps_sa_element(drm_ps_info *ps, bitfile *ld) +{ + drm_ps_huff_tab huff; + uint8_t band; + + ps->bs_sa_dt_flag = faad_get1bit(ld); + if (ps->bs_sa_dt_flag) + { + huff = t_huffman_sa; + } else { + huff = f_huffman_sa; + } + + for (band = 0; band < DRM_NUM_SA_BANDS; band++) + { + ps->bs_sa_data[band] = huff_dec(ld, huff); + } +} + +static void drm_ps_pan_element(drm_ps_info *ps, bitfile *ld) +{ + drm_ps_huff_tab huff; + uint8_t band; + + ps->bs_pan_dt_flag = faad_get1bit(ld); + if (ps->bs_pan_dt_flag) + { + huff = t_huffman_pan; + } else { + huff = f_huffman_pan; + } + + for (band = 0; band < DRM_NUM_PAN_BANDS; band++) + { + ps->bs_pan_data[band] = huff_dec(ld, huff); + } +} + +/* binary search huffman decoding */ +static int8_t huff_dec(bitfile *ld, drm_ps_huff_tab huff) +{ + uint8_t bit; + int16_t index = 0; + + while (index >= 0) + { + bit = (uint8_t)faad_get1bit(ld); + index = huff[index][bit]; + } + + return index + 15; +} + + +static int8_t sa_delta_clip(drm_ps_info *ps, int8_t i) +{ + if (i < 0) { + /* printf(" SAminclip %d", i); */ + ps->sa_decode_error = 1; + return 0; + } else if (i > 7) { + /* printf(" SAmaxclip %d", i); */ + ps->sa_decode_error = 1; + return 7; + } else + return i; +} + +static int8_t pan_delta_clip(drm_ps_info *ps, int8_t i) +{ + if (i < -7) { + /* printf(" PANminclip %d", i); */ + ps->pan_decode_error = 1; + return -7; + } else if (i > 7) { + /* printf(" PANmaxclip %d", i); */ + ps->pan_decode_error = 1; + return 7; + } else + return i; +} + +static void drm_ps_delta_decode(drm_ps_info *ps) +{ + uint8_t band; + + if (ps->bs_enable_sa) + { + if (ps->bs_sa_dt_flag && !ps->g_last_had_sa) + { + for (band = 0; band < DRM_NUM_SA_BANDS; band++) + { + ps->g_prev_sa_index[band] = 0; + } + } + if (ps->bs_sa_dt_flag) + { + ps->g_sa_index[0] = sa_delta_clip(ps, ps->g_prev_sa_index[0]+ps->bs_sa_data[0]); + + } else { + ps->g_sa_index[0] = sa_delta_clip(ps,ps->bs_sa_data[0]); + } + + for (band = 1; band < DRM_NUM_SA_BANDS; band++) + { + if (ps->bs_sa_dt_flag) + { + ps->g_sa_index[band] = sa_delta_clip(ps, ps->g_prev_sa_index[band] + ps->bs_sa_data[band]); + } else { + ps->g_sa_index[band] = sa_delta_clip(ps, ps->g_sa_index[band-1] + ps->bs_sa_data[band]); + } + } + } + + /* An error during SA decoding implies PAN data will be undecodable, too */ + /* Also, we don't like on/off switching in PS, so we force to last settings */ + if (ps->sa_decode_error) { + ps->pan_decode_error = 1; + ps->bs_enable_pan = ps->g_last_had_pan; + ps->bs_enable_sa = ps->g_last_had_sa; + } + + + if (ps->bs_enable_sa) + { + if (ps->sa_decode_error) { + for (band = 0; band < DRM_NUM_SA_BANDS; band++) + { + ps->g_sa_index[band] = ps->g_last_good_sa_index[band]; + } + } else { + for (band = 0; band < DRM_NUM_SA_BANDS; band++) + { + ps->g_last_good_sa_index[band] = ps->g_sa_index[band]; + } + } + } + + if (ps->bs_enable_pan) + { + if (ps->bs_pan_dt_flag && !ps->g_last_had_pan) + { +/* The DRM PS spec doesn't say anything about this case. (deltacoded in time without a previous frame) + AAC PS spec you must tread previous frame as 0, so that's what we try. +*/ + for (band = 0; band < DRM_NUM_PAN_BANDS; band++) + { + ps->g_prev_pan_index[band] = 0; + } + } + + if (ps->bs_pan_dt_flag) + { + ps->g_pan_index[0] = pan_delta_clip(ps, ps->g_prev_pan_index[0]+ps->bs_pan_data[0]); + } else { + ps->g_pan_index[0] = pan_delta_clip(ps, ps->bs_pan_data[0]); + } + + for (band = 1; band < DRM_NUM_PAN_BANDS; band++) + { + if (ps->bs_pan_dt_flag) + { + ps->g_pan_index[band] = pan_delta_clip(ps, ps->g_prev_pan_index[band] + ps->bs_pan_data[band]); + } else { + ps->g_pan_index[band] = pan_delta_clip(ps, ps->g_pan_index[band-1] + ps->bs_pan_data[band]); + } + } + + if (ps->pan_decode_error) { + for (band = 0; band < DRM_NUM_PAN_BANDS; band++) + { + ps->g_pan_index[band] = ps->g_last_good_pan_index[band]; + } + } else { + for (band = 0; band < DRM_NUM_PAN_BANDS; band++) + { + ps->g_last_good_pan_index[band] = ps->g_pan_index[band]; + } + } + } +} + +static void drm_calc_sa_side_signal(drm_ps_info *ps, qmf_t X[MAX_NTSRPS][64], uint8_t rateselect) +{ + uint8_t s, b, k; + complex_t qfrac, tmp0, tmp, in, R0; + real_t peakdiff; + real_t nrg; + real_t power; + real_t transratio; + real_t new_delay_slopes[NUM_OF_LINKS]; + uint8_t temp_delay_ser[NUM_OF_LINKS]; + complex_t Phi_Fract; +#ifdef FIXED_POINT + uint32_t in_re, in_im; +#endif + + for (b = 0; b < sa_freq_scale[DRM_NUM_SA_BANDS][rateselect]; b++) + { + /* set delay indices */ + for (k = 0; k < NUM_OF_LINKS; k++) + temp_delay_ser[k] = ps->delay_buf_index_ser[k]; + + RE(Phi_Fract) = RE(Phi_Fract_Qmf[b]); + IM(Phi_Fract) = IM(Phi_Fract_Qmf[b]); + + for (s = 0; s < NUM_OF_SUBSAMPLES; s++) + { + const real_t gamma = REAL_CONST(1.5); + const real_t sigma = REAL_CONST(1.5625); + + RE(in) = QMF_RE(X[s][b]); + IM(in) = QMF_IM(X[s][b]); + +#ifdef FIXED_POINT + /* NOTE: all input is scaled by 2^(-5) because of fixed point QMF + * meaning that P will be scaled by 2^(-10) compared to floating point version + */ + in_re = ((abs(RE(in))+(1<<(REAL_BITS-1)))>>REAL_BITS); + in_im = ((abs(IM(in))+(1<<(REAL_BITS-1)))>>REAL_BITS); + power = in_re*in_re + in_im*in_im; +#else + power = MUL_R(RE(in),RE(in)) + MUL_R(IM(in),IM(in)); +#endif + + ps->peakdecay_fast[b] = MUL_F(ps->peakdecay_fast[b], peak_decay[rateselect]); + if (ps->peakdecay_fast[b] < power) + ps->peakdecay_fast[b] = power; + + peakdiff = ps->prev_peakdiff[b]; + peakdiff += MUL_F((ps->peakdecay_fast[b] - power - ps->prev_peakdiff[b]), smooth_coeff[rateselect]); + ps->prev_peakdiff[b] = peakdiff; + + nrg = ps->prev_nrg[b]; + nrg += MUL_F((power - ps->prev_nrg[b]), smooth_coeff[rateselect]); + ps->prev_nrg[b] = nrg; + + if (MUL_R(peakdiff, gamma) <= nrg) { + transratio = sigma; + } else { + transratio = MUL_R(DIV_R(nrg, MUL_R(peakdiff, gamma)), sigma); + } + + for (k = 0; k < NUM_OF_LINKS; k++) + { + new_delay_slopes[k] = MUL_F(g_decayslope[b], filter_coeff[k]); + } + + RE(tmp0) = RE(ps->d_buff[0][b]); + IM(tmp0) = IM(ps->d_buff[0][b]); + + RE(ps->d_buff[0][b]) = RE(ps->d_buff[1][b]); + IM(ps->d_buff[0][b]) = IM(ps->d_buff[1][b]); + + RE(ps->d_buff[1][b]) = RE(in); + IM(ps->d_buff[1][b]) = IM(in); + + ComplexMult(&RE(tmp), &IM(tmp), RE(tmp0), IM(tmp0), RE(Phi_Fract), IM(Phi_Fract)); + + RE(R0) = RE(tmp); + IM(R0) = IM(tmp); + + for (k = 0; k < NUM_OF_LINKS; k++) + { + RE(qfrac) = RE(Q_Fract_allpass_Qmf[b][k]); + IM(qfrac) = IM(Q_Fract_allpass_Qmf[b][k]); + + RE(tmp0) = RE(ps->d2_buff[k][temp_delay_ser[k]][b]); + IM(tmp0) = IM(ps->d2_buff[k][temp_delay_ser[k]][b]); + + ComplexMult(&RE(tmp), &IM(tmp), RE(tmp0), IM(tmp0), RE(qfrac), IM(qfrac)); + + RE(tmp) += -MUL_F(new_delay_slopes[k], RE(R0)); + IM(tmp) += -MUL_F(new_delay_slopes[k], IM(R0)); + + RE(ps->d2_buff[k][temp_delay_ser[k]][b]) = RE(R0) + MUL_F(new_delay_slopes[k], RE(tmp)); + IM(ps->d2_buff[k][temp_delay_ser[k]][b]) = IM(R0) + MUL_F(new_delay_slopes[k], IM(tmp)); + + RE(R0) = RE(tmp); + IM(R0) = IM(tmp); + } + + QMF_RE(ps->SA[s][b]) = MUL_R(RE(R0), transratio); + QMF_IM(ps->SA[s][b]) = MUL_R(IM(R0), transratio); + + for (k = 0; k < NUM_OF_LINKS; k++) + { + if (++temp_delay_ser[k] >= delay_length[k][rateselect]) + temp_delay_ser[k] = 0; + } + } + } + + for (k = 0; k < NUM_OF_LINKS; k++) + ps->delay_buf_index_ser[k] = temp_delay_ser[k]; +} + +static void drm_add_ambiance(drm_ps_info *ps, uint8_t rateselect, + qmf_t X_left[MAX_NTSRPS][64], + qmf_t X_right[MAX_NTSRPS][64]) +{ + uint8_t s, b, ifreq, qclass; + real_t sa_map[MAX_SA_BAND], sa_dir_map[MAX_SA_BAND], k_sa_map[MAX_SA_BAND], k_sa_dir_map[MAX_SA_BAND]; + real_t new_dir_map, new_sa_map; + + if (ps->bs_enable_sa) + { + /* Instead of dequantization and mapping, we use an inverse mapping + to look up all the values we need */ + for (b = 0; b < sa_freq_scale[DRM_NUM_SA_BANDS][rateselect]; b++) + { + const real_t inv_f_num_of_subsamples = FRAC_CONST(0.03333333333); + + ifreq = sa_inv_freq[b]; + qclass = (b != 0); + + sa_map[b] = sa_quant[ps->g_prev_sa_index[ifreq]][qclass]; + new_sa_map = sa_quant[ps->g_sa_index[ifreq]][qclass]; + + k_sa_map[b] = MUL_F(inv_f_num_of_subsamples, (new_sa_map - sa_map[b])); + + sa_dir_map[b] = sa_sqrt_1_minus[ps->g_prev_sa_index[ifreq]][qclass]; + new_dir_map = sa_sqrt_1_minus[ps->g_sa_index[ifreq]][qclass]; + + k_sa_dir_map[b] = MUL_F(inv_f_num_of_subsamples, (new_dir_map - sa_dir_map[b])); + + } + + for (s = 0; s < NUM_OF_SUBSAMPLES; s++) + { + for (b = 0; b < sa_freq_scale[DRM_NUM_SA_BANDS][rateselect]; b++) + { + QMF_RE(X_right[s][b]) = MUL_F(QMF_RE(X_left[s][b]), sa_dir_map[b]) - MUL_F(QMF_RE(ps->SA[s][b]), sa_map[b]); + QMF_IM(X_right[s][b]) = MUL_F(QMF_IM(X_left[s][b]), sa_dir_map[b]) - MUL_F(QMF_IM(ps->SA[s][b]), sa_map[b]); + QMF_RE(X_left[s][b]) = MUL_F(QMF_RE(X_left[s][b]), sa_dir_map[b]) + MUL_F(QMF_RE(ps->SA[s][b]), sa_map[b]); + QMF_IM(X_left[s][b]) = MUL_F(QMF_IM(X_left[s][b]), sa_dir_map[b]) + MUL_F(QMF_IM(ps->SA[s][b]), sa_map[b]); + + sa_map[b] += k_sa_map[b]; + sa_dir_map[b] += k_sa_dir_map[b]; + } + for (b = sa_freq_scale[DRM_NUM_SA_BANDS][rateselect]; b < NUM_OF_QMF_CHANNELS; b++) + { + QMF_RE(X_right[s][b]) = QMF_RE(X_left[s][b]); + QMF_IM(X_right[s][b]) = QMF_IM(X_left[s][b]); + } + } + } + else { + for (s = 0; s < NUM_OF_SUBSAMPLES; s++) + { + for (b = 0; b < NUM_OF_QMF_CHANNELS; b++) + { + QMF_RE(X_right[s][b]) = QMF_RE(X_left[s][b]); + QMF_IM(X_right[s][b]) = QMF_IM(X_left[s][b]); + } + } + } +} + +static void drm_add_pan(drm_ps_info *ps, uint8_t rateselect, + qmf_t X_left[MAX_NTSRPS][64], + qmf_t X_right[MAX_NTSRPS][64]) +{ + uint8_t s, b, qclass, ifreq; + real_t tmp, coeff1, coeff2; + real_t pan_base[MAX_PAN_BAND]; + real_t pan_delta[MAX_PAN_BAND]; + qmf_t temp_l, temp_r; + + if (ps->bs_enable_pan) + { + for (b = 0; b < NUM_OF_QMF_CHANNELS; b++) + { + /* Instead of dequantization, 20->64 mapping and 2^G(x,y) we do an + inverse mapping 64->20 and look up the 2^G(x,y) values directly */ + ifreq = pan_inv_freq[b]; + qclass = pan_quant_class[ifreq]; + + if (ps->g_prev_pan_index[ifreq] >= 0) + { + pan_base[b] = pan_pow_2_pos[ps->g_prev_pan_index[ifreq]][qclass]; + } else { + pan_base[b] = pan_pow_2_neg[-ps->g_prev_pan_index[ifreq]][qclass]; + } + + /* 2^((a-b)/30) = 2^(a/30) * 1/(2^(b/30)) */ + /* a en b can be negative so we may need to inverse parts */ + if (ps->g_pan_index[ifreq] >= 0) + { + if (ps->g_prev_pan_index[ifreq] >= 0) + { + pan_delta[b] = MUL_C(pan_pow_2_30_pos[ps->g_pan_index[ifreq]][qclass], + pan_pow_2_30_neg[ps->g_prev_pan_index[ifreq]][qclass]); + } else { + pan_delta[b] = MUL_C(pan_pow_2_30_pos[ps->g_pan_index[ifreq]][qclass], + pan_pow_2_30_pos[-ps->g_prev_pan_index[ifreq]][qclass]); + } + } else { + if (ps->g_prev_pan_index[ifreq] >= 0) + { + pan_delta[b] = MUL_C(pan_pow_2_30_neg[-ps->g_pan_index[ifreq]][qclass], + pan_pow_2_30_neg[ps->g_prev_pan_index[ifreq]][qclass]); + } else { + pan_delta[b] = MUL_C(pan_pow_2_30_neg[-ps->g_pan_index[ifreq]][qclass], + pan_pow_2_30_pos[-ps->g_prev_pan_index[ifreq]][qclass]); + } + } + } + + for (s = 0; s < NUM_OF_SUBSAMPLES; s++) + { + /* PAN always uses all 64 channels */ + for (b = 0; b < NUM_OF_QMF_CHANNELS; b++) + { + tmp = pan_base[b]; + + coeff2 = DIV_R(REAL_CONST(2.0), (REAL_CONST(1.0) + tmp)); + coeff1 = MUL_R(coeff2, tmp); + + QMF_RE(temp_l) = QMF_RE(X_left[s][b]); + QMF_IM(temp_l) = QMF_IM(X_left[s][b]); + QMF_RE(temp_r) = QMF_RE(X_right[s][b]); + QMF_IM(temp_r) = QMF_IM(X_right[s][b]); + + QMF_RE(X_left[s][b]) = MUL_R(QMF_RE(temp_l), coeff1); + QMF_IM(X_left[s][b]) = MUL_R(QMF_IM(temp_l), coeff1); + QMF_RE(X_right[s][b]) = MUL_R(QMF_RE(temp_r), coeff2); + QMF_IM(X_right[s][b]) = MUL_R(QMF_IM(temp_r), coeff2); + + /* 2^(a+k*b) = 2^a * 2^b * ... * 2^b */ + /* ^^^^^^^^^^^^^^^ k times */ + pan_base[b] = MUL_C(pan_base[b], pan_delta[b]); + } + } + } +} + +drm_ps_info *drm_ps_init(void) +{ + drm_ps_info *ps = &s_drm_ps_info; + memset(ps, 0, sizeof(drm_ps_info)); + + return ps; +} + +/* main DRM PS decoding function */ +uint8_t drm_ps_decode(drm_ps_info *ps, uint8_t guess, uint32_t samplerate, + qmf_t X_left[MAX_NTSRPS][64], + qmf_t X_right[MAX_NTSRPS][64]) +{ + uint8_t rateselect = (samplerate >= 24000); + + if (ps == NULL) + { + memcpy(X_right, X_left, sizeof(qmf_t)*30*64); + return 0; + } + + if (!ps->drm_ps_data_available && !guess) + { + memcpy(X_right, X_left, sizeof(qmf_t)*30*64); + memset(ps->g_prev_sa_index, 0, sizeof(ps->g_prev_sa_index)); + memset(ps->g_prev_pan_index, 0, sizeof(ps->g_prev_pan_index)); + return 0; + } + + /* if SBR CRC doesn't match out, we can assume decode errors to start with, + and we'll guess what the parameters should be */ + if (!guess) + { + ps->sa_decode_error = 0; + ps->pan_decode_error = 0; + drm_ps_delta_decode(ps); + } else + { + ps->sa_decode_error = 1; + ps->pan_decode_error = 1; + /* don't even bother decoding */ + } + + ps->drm_ps_data_available = 0; + + drm_calc_sa_side_signal(ps, X_left, rateselect); + drm_add_ambiance(ps, rateselect, X_left, X_right); + + if (ps->bs_enable_sa) + { + ps->g_last_had_sa = 1; + + memcpy(ps->g_prev_sa_index, ps->g_sa_index, sizeof(int8_t) * DRM_NUM_SA_BANDS); + + } else { + ps->g_last_had_sa = 0; + } + + if (ps->bs_enable_pan) + { + drm_add_pan(ps, rateselect, X_left, X_right); + + ps->g_last_had_pan = 1; + + memcpy(ps->g_prev_pan_index, ps->g_pan_index, sizeof(int8_t) * DRM_NUM_PAN_BANDS); + + } else { + ps->g_last_had_pan = 0; + } + + + return 0; +} + +#endif diff --git a/lib/rbcodec/codecs/libfaad/drm_dec.h b/lib/rbcodec/codecs/libfaad/drm_dec.h new file mode 100644 index 0000000000..d7ae9d0166 --- /dev/null +++ b/lib/rbcodec/codecs/libfaad/drm_dec.h @@ -0,0 +1,98 @@ +/* +** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding +** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +** +** Any non-GPL usage of this software or parts of this software is strictly +** forbidden. +** +** Commercial non-GPL licensing of this software is possible. +** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** +** $Id$ +**/ + +#ifndef __DRM_DEC_H__ +#define __DRM_DEC_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "bits.h" + +#define DRM_PARAMETRIC_STEREO 0 +#define DRM_NUM_SA_BANDS 8 +#define DRM_NUM_PAN_BANDS 20 +#define NUM_OF_LINKS 3 +#define NUM_OF_QMF_CHANNELS 64 +#define NUM_OF_SUBSAMPLES 30 +#define MAX_SA_BAND 46 +#define MAX_PAN_BAND 64 +#define MAX_DELAY 5 + +typedef struct +{ + uint8_t drm_ps_data_available; + uint8_t bs_enable_sa; + uint8_t bs_enable_pan; + + uint8_t bs_sa_dt_flag; + uint8_t bs_pan_dt_flag; + + uint8_t g_last_had_sa; + uint8_t g_last_had_pan; + + int8_t bs_sa_data[DRM_NUM_SA_BANDS]; + int8_t bs_pan_data[DRM_NUM_PAN_BANDS]; + + int8_t g_sa_index[DRM_NUM_SA_BANDS]; + int8_t g_pan_index[DRM_NUM_PAN_BANDS]; + int8_t g_prev_sa_index[DRM_NUM_SA_BANDS]; + int8_t g_prev_pan_index[DRM_NUM_PAN_BANDS]; + + int8_t sa_decode_error; + int8_t pan_decode_error; + + int8_t g_last_good_sa_index[DRM_NUM_SA_BANDS]; + int8_t g_last_good_pan_index[DRM_NUM_PAN_BANDS]; + + qmf_t SA[NUM_OF_SUBSAMPLES][MAX_SA_BAND]; + + complex_t d_buff[2][MAX_SA_BAND]; + complex_t d2_buff[NUM_OF_LINKS][MAX_DELAY][MAX_SA_BAND]; + + uint8_t delay_buf_index_ser[NUM_OF_LINKS]; + + real_t prev_nrg[MAX_SA_BAND]; + real_t prev_peakdiff[MAX_SA_BAND]; + real_t peakdecay_fast[MAX_SA_BAND]; +} drm_ps_info; + + +uint16_t drm_ps_data(drm_ps_info *ps, bitfile *ld); + +drm_ps_info *drm_ps_init(void); + +uint8_t drm_ps_decode(drm_ps_info *ps, uint8_t guess, uint32_t samplerate, + qmf_t X_left[MAX_NTSRPS][64], + qmf_t X_right[MAX_NTSRPS][64]); + +#ifdef __cplusplus +} +#endif +#endif + diff --git a/lib/rbcodec/codecs/libfaad/error.c b/lib/rbcodec/codecs/libfaad/error.c new file mode 100644 index 0000000000..ff2f9c3d13 --- /dev/null +++ b/lib/rbcodec/codecs/libfaad/error.c @@ -0,0 +1,62 @@ +/* +** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding +** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +** +** Any non-GPL usage of this software or parts of this software is strictly +** forbidden. +** +** Commercial non-GPL licensing of this software is possible. +** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** +** $Id$ +**/ + +#include "common.h" +#include "error.h" + +char *err_msg[] = { + "No error", + "Gain control not yet implemented", + "Pulse coding not allowed in short blocks", + "Invalid huffman codebook", + "Scalefactor out of range", + "Unable to find ADTS syncword", + "Channel coupling not yet implemented", + "Channel configuration not allowed in error resilient frame", + "Bit error in error resilient scalefactor decoding", + "Error decoding huffman scalefactor (bitstream error)", + "Error decoding huffman codeword (bitstream error)", + "Non existent huffman codebook number found", + "Invalid number of channels", + "Maximum number of bitstream elements exceeded", + "Input data buffer too small", + "Array index out of range", + "Maximum number of scalefactor bands exceeded", + "Quantised value out of range", + "LTP lag out of range", + "Invalid SBR parameter decoded", + "SBR called without being initialised", + "Unexpected channel configuration change", + "Error in program_config_element", + "First SBR frame is not the same as first AAC frame", + "Unexpected fill element with SBR data", + "Not all elements were provided with SBR data", + "LTP decoding not available", + "Output data buffer too small", + "Could not allocate enough memory" +}; + diff --git a/lib/rbcodec/codecs/libfaad/error.h b/lib/rbcodec/codecs/libfaad/error.h new file mode 100644 index 0000000000..94ca7bba75 --- /dev/null +++ b/lib/rbcodec/codecs/libfaad/error.h @@ -0,0 +1,41 @@ +/* +** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding +** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +** +** Any non-GPL usage of this software or parts of this software is strictly +** forbidden. +** +** Commercial non-GPL licensing of this software is possible. +** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** +** $Id$ +**/ + +#ifndef __ERROR_H__ +#define __ERROR_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#define NUM_ERROR_MESSAGES 28 +extern char *err_msg[]; + +#ifdef __cplusplus +} +#endif +#endif diff --git a/lib/rbcodec/codecs/libfaad/faad_config.h b/lib/rbcodec/codecs/libfaad/faad_config.h new file mode 100644 index 0000000000..163b55669e --- /dev/null +++ b/lib/rbcodec/codecs/libfaad/faad_config.h @@ -0,0 +1,120 @@ +/* config.h. Generated by configure. */ +/* config.h.in. Generated from configure.in by autoheader. */ + +#include + +/* Define if you want to use libfaad together with Digital Radio Mondiale + (DRM) */ +/* #undef DRM */ + +/* Define if you want support for Digital Radio Mondiale (DRM) parametric + stereo */ +/* #undef DRM_PS */ + +/* Define to 1 if you have the header file. */ +//#define HAVE_DLFCN_H 1 + +/* Define to 1 if you have the header file. */ +//#define HAVE_ERRNO_H 1 + +/* Define if needed */ +/* #undef HAVE_FLOAT32_T */ + +/* Define to 1 if you have the header file. */ +//#define HAVE_FLOAT_H 1 + +/* Define to 1 if you have the `getpwuid' function. */ +#define HAVE_GETPWUID 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_INTTYPES_H 1 + +/* Define if you have the IOKit API */ +/* #undef HAVE_IOKIT_IOKITLIB_H */ + +/* Define to 1 if you have the header file. */ +//#define HAVE_LIMITS_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_MATHF_H */ + +/* Define to 1 if you have the `memcpy' function. */ +#define HAVE_MEMCPY 1 + +/* Define to 1 if you have the header file. */ +//#define HAVE_MEMORY_H 1 + +/* Define to 1 if you have the header file. */ +//#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the `strchr' function. */ +#define HAVE_STRCHR 1 + +/* Define to 1 if you have the header file. */ +//#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the `strsep' function. */ +//#define HAVE_STRSEP 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYSFS_LIBSYSFS_H */ + +/* Define to 1 if you have the header file. */ +//#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the header file. */ +//#define HAVE_SYS_TIME_H 1 + +/* Define to 1 if you have the header file. */ +//#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the header file. */ +//#define HAVE_UNISTD_H 1 + +/* Name of package */ +#define PACKAGE "faad2" + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "" + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "" + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Define to 1 if you can safely include both and . */ +//#define TIME_WITH_SYS_TIME 1 + +/* Version number of package */ +#define LIBFAAD_VERSION "2.0" + +/* Define to 1 if your processor stores words with the most significant byte + first (like Motorola and SPARC, unlike Intel and VAX). */ +#ifdef ROCKBOX_BIG_ENDIAN +#define WORDS_BIGENDIAN 1 +#endif + +/* Define to `__inline__' or `__inline' if that's what the C compiler + calls it, or to nothing if 'inline' is not supported under any name. */ +#ifndef __cplusplus +/* #undef inline */ +#endif + +/* Define to `long' if does not define. */ +/* #undef off_t */ diff --git a/lib/rbcodec/codecs/libfaad/filtbank.c b/lib/rbcodec/codecs/libfaad/filtbank.c new file mode 100644 index 0000000000..fd7a4dc91f --- /dev/null +++ b/lib/rbcodec/codecs/libfaad/filtbank.c @@ -0,0 +1,482 @@ +/* +** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding +** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +** +** Any non-GPL usage of this software or parts of this software is strictly +** forbidden. +** +** Commercial non-GPL licensing of this software is possible. +** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** +** $Id$ +**/ + +#include "common.h" +#include "structs.h" + +#include +#include +#ifdef _WIN32_WCE +#define assert(x) +#else +#include +#endif + +#include "filtbank.h" +#include "decoder.h" +#include "syntax.h" +#include "kbd_win.h" +#include "sine_win.h" + + +/* static variables */ +static real_t transf_buf[2*FRAME_LEN] IBSS_ATTR MEM_ALIGN_ATTR; +#ifdef LTP_DEC +static real_t windowed_buf[2*FRAME_LEN] MEM_ALIGN_ATTR = {0}; +#endif + + +/*Windowing functions borrowed from libwmai*/ +#ifdef CPU_ARM +static inline +void vector_fmul_add_add(real_t *dst, const real_t *src0, const real_t *src1, const real_t *src2, int len) +{ + /* Block sizes are always power of two */ + asm volatile ( + "0:" + "ldmia %[d]!, {r0, r1};" + "ldmia %[w]!, {r4, r5};" + /* consume the first data and window value so we can use those + * registers again */ + "smull r8, r9, r0, r4;" + "ldmia %[src2]!, {r0, r4};" + "add r0, r0, r9, lsl #1;" /* *dst=*dst+(r9<<1)*/ + "smull r8, r9, r1, r5;" + "add r1, r4, r9, lsl #1;" + "stmia %[dst]!, {r0, r1};" + "subs %[n], %[n], #2;" + "bne 0b;" + : [d] "+r" (src0), [w] "+r" (src1), [src2] "+r" (src2), [dst] "+r" (dst), [n] "+r" (len) + : + : "r0", "r1", "r4", "r5", "r8", "r9", "memory", "cc"); +} +static inline +void vector_fmul_reverse(real_t *dst, const real_t *src0, const real_t *src1, + int len) +{ + /* Block sizes are always power of two */ + asm volatile ( + "add %[s1], %[s1], %[n], lsl #2;" + "0:" + "ldmia %[s0]!, {r0, r1};" + "ldmdb %[s1]!, {r4, r5};" + "smull r8, r9, r0, r5;" + "mov r0, r9, lsl #1;" + "smull r8, r9, r1, r4;" + "mov r1, r9, lsl #1;" + "stmia %[dst]!, {r0, r1};" + "subs %[n], %[n], #2;" + "bne 0b;" + : [s0] "+r" (src0), [s1] "+r" (src1), [dst] "+r" (dst), [n] "+r" (len) + : + : "r0", "r1", "r4", "r5", "r8", "r9", "memory", "cc"); +} + +#elif defined(CPU_COLDFIRE) +static inline +void vector_fmul_add_add(real_t *dst, const real_t *src0, const real_t *src1, const real_t *src2, int len) +{ + /* Block sizes are always power of two. Smallest block is always way bigger + * than four too.*/ + asm volatile ( + "0:" + "movem.l (%[src0]), %%d0-%%d3;" + "movem.l (%[src1]), %%d4-%%d5/%%a0-%%a1;" + "mac.l %%d0, %%d4, %%acc0;" + "mac.l %%d1, %%d5, %%acc1;" + "mac.l %%d2, %%a0, %%acc2;" + "mac.l %%d3, %%a1, %%acc3;" + "lea.l (16, %[src0]), %[src0];" + "lea.l (16, %[src1]), %[src1];" + "movclr.l %%acc0, %%d0;" + "movclr.l %%acc1, %%d1;" + "movclr.l %%acc2, %%d2;" + "movclr.l %%acc3, %%d3;" + "movem.l (%[src2]), %%d4-%%d5/%%a0-%%a1;" + "lea.l (16, %[src2]), %[src2];" + "add.l %%d4, %%d0;" + "add.l %%d5, %%d1;" + "add.l %%a0, %%d2;" + "add.l %%a1, %%d3;" + "movem.l %%d0-%%d3, (%[dst]);" + "lea.l (16, %[dst]), %[dst];" + "subq.l #4, %[n];" + "jne 0b;" + : [src0] "+a" (src0), [src1] "+a" (src1), [src2] "+a" (src2), [dst] "+a" (dst), [n] "+d" (len) + : + : "d0", "d1", "d2", "d3", "d4", "d5", "a0", "a1", "memory", "cc"); +} + +static inline +void vector_fmul_reverse(real_t *dst, const real_t *src0, const real_t *src1, + int len) +{ + /* Block sizes are always power of two. Smallest block is always way bigger + * than four too.*/ + asm volatile ( + "lea.l (-16, %[s1], %[n]*4), %[s1];" + "0:" + "movem.l (%[s0]), %%d0-%%d3;" + "movem.l (%[s1]), %%d4-%%d5/%%a0-%%a1;" + "mac.l %%d0, %%a1, %%acc0;" + "mac.l %%d1, %%a0, %%acc1;" + "mac.l %%d2, %%d5, %%acc2;" + "mac.l %%d3, %%d4, %%acc3;" + "lea.l (16, %[s0]), %[s0];" + "lea.l (-16, %[s1]), %[s1];" + "movclr.l %%acc0, %%d0;" + "movclr.l %%acc1, %%d1;" + "movclr.l %%acc2, %%d2;" + "movclr.l %%acc3, %%d3;" + "movem.l %%d0-%%d3, (%[dst]);" + "lea.l (16, %[dst]), %[dst];" + "subq.l #4, %[n];" + "jne 0b;" + : [s0] "+a" (src0), [s1] "+a" (src1), [dst] "+a" (dst), [n] "+d" (len) + : : "d0", "d1", "d2", "d3", "d4", "d5", "a0", "a1", "memory", "cc"); +} + +#else +static inline void vector_fmul_add_add(real_t *dst, const real_t *src0, const real_t *src1, const real_t *src2, int len){ + int i; + for(i=0; imdct2048; + break; + case 256: + case 240: + mdct = fb->mdct256; + break; +#ifdef LD_DEC + case 1024: + case 960: + mdct = fb->mdct1024; + break; +#endif + } + + faad_mdct(mdct, in_data, out_data); +} +#endif + +void ifilter_bank(uint8_t window_sequence, uint8_t window_shape, + uint8_t window_shape_prev, real_t *freq_in, + real_t *time_out, real_t *overlap, + uint8_t object_type, uint16_t frame_len) +{ + int32_t i, idx0, idx1; + real_t win0, win1, win2; + + const real_t *window_long = NULL; + const real_t *window_long_prev = NULL; + const real_t *window_short = NULL; + const real_t *window_short_prev = NULL; + + int32_t nlong = frame_len; + int32_t nshort = frame_len/8; + int32_t nflat_ls = (nlong-nshort)/2; + +#ifdef PROFILE + int64_t count = faad_get_ts(); +#endif + + memset(transf_buf,0,sizeof(transf_buf)); + /* select windows of current frame and previous frame (Sine or KBD) */ +#ifdef LD_DEC + if (object_type == LD) + { + window_long = fb->ld_window[window_shape]; + window_long_prev = fb->ld_window[window_shape_prev]; + } else { +#else + (void) object_type; +#endif + + /* AAC uses two different window shapes depending on spectal features */ + if (window_shape == 0) { + window_long = sine_long_1024; + window_short = sine_short_128; + } else { + window_long = kbd_long_1024; + window_short = kbd_short_128; + } + + if (window_shape_prev == 0) { + window_long_prev = sine_long_1024; + window_short_prev = sine_short_128; + } else { + window_long_prev = kbd_long_1024; + window_short_prev = kbd_short_128; + } + +#ifdef LD_DEC + } +#endif + +#if 0 + for (i = 0; i < 1024; i++) + { + printf("%d\n", freq_in[i]); + } +#endif + +#if 0 + printf("%d %d\n", window_sequence, window_shape); +#endif + switch (window_sequence) + { + case ONLY_LONG_SEQUENCE: + /* perform iMDCT */ + ff_imdct_calc(11, transf_buf, freq_in); + + /* add second half output of previous frame to windowed output of current frame */ + vector_fmul_add_add(time_out, transf_buf, window_long_prev, overlap, nlong); + + /* window the second half and save as overlap for next frame */ + vector_fmul_reverse(overlap, transf_buf+nlong, window_long, nlong); + + break; + + case LONG_START_SEQUENCE: + /* perform iMDCT */ + ff_imdct_calc(11, transf_buf, freq_in); + + /* add second half output of previous frame to windowed output of current frame */ + vector_fmul_add_add(time_out, transf_buf, window_long_prev, overlap, nlong); + + /* window the second half and save as overlap for next frame */ + /* construct second half window using padding with 1's and 0's */ + + memcpy(overlap, transf_buf+nlong, nflat_ls*sizeof(real_t)); + + vector_fmul_reverse(overlap+nflat_ls, transf_buf+nlong+nflat_ls, window_short, nshort); + + memset(overlap+nflat_ls+nshort, 0, nflat_ls*sizeof(real_t)); + break; + + case EIGHT_SHORT_SEQUENCE: + /* this could be assemblerized too, but this case is extremely uncommon */ + + /* perform iMDCT for each short block */ + idx0 = 0; ff_imdct_calc(8, transf_buf , freq_in ); + idx0 += nshort; ff_imdct_calc(8, transf_buf + (idx0<<1), freq_in + idx0); + idx0 += nshort; ff_imdct_calc(8, transf_buf + (idx0<<1), freq_in + idx0); + idx0 += nshort; ff_imdct_calc(8, transf_buf + (idx0<<1), freq_in + idx0); + idx0 += nshort; ff_imdct_calc(8, transf_buf + (idx0<<1), freq_in + idx0); + idx0 += nshort; ff_imdct_calc(8, transf_buf + (idx0<<1), freq_in + idx0); + idx0 += nshort; ff_imdct_calc(8, transf_buf + (idx0<<1), freq_in + idx0); + idx0 += nshort; ff_imdct_calc(8, transf_buf + (idx0<<1), freq_in + idx0); + + /* Add second half output of previous frame to windowed output of current + * frame */ + /* Step 1: copy */ + memcpy(time_out, overlap, nflat_ls*sizeof(real_t)); + /* Step 2: First window half, first half of nshort */ + for (i = 0; i < nshort/2; i++) { + win0 = window_short[nshort-1-i]; + win1 = window_short[i]; + win2 = window_short_prev[i]; + idx0 = nflat_ls + i; + idx1 = i; + time_out[idx0] = overlap[idx0] + MUL_F(transf_buf[idx1], win2); idx0 += nshort; idx1 += (nshort<<1); + time_out[idx0] = overlap[idx0] + MUL_F(transf_buf[idx1-nshort], win0) + MUL_F(transf_buf[idx1], win1); idx0 += nshort; idx1 += (nshort<<1); + time_out[idx0] = overlap[idx0] + MUL_F(transf_buf[idx1-nshort], win0) + MUL_F(transf_buf[idx1], win1); idx0 += nshort; idx1 += (nshort<<1); + time_out[idx0] = overlap[idx0] + MUL_F(transf_buf[idx1-nshort], win0) + MUL_F(transf_buf[idx1], win1); idx0 += nshort; idx1 += (nshort<<1); + time_out[idx0] = overlap[idx0] + MUL_F(transf_buf[idx1-nshort], win0) + MUL_F(transf_buf[idx1], win1); + } + /* Step 3: First window half, second half of nshort */ + for (; i < nshort; i++) { + win0 = window_short[nshort-1-i]; + win1 = window_short[i]; + idx0 = nflat_ls + i; + idx1 = i; + time_out[idx0] = overlap[idx0] + MUL_F(transf_buf[idx1], win1); idx0 += nshort; idx1 += (nshort<<1); + time_out[idx0] = overlap[idx0] + MUL_F(transf_buf[idx1-nshort], win0) + MUL_F(transf_buf[idx1], win1); idx0 += nshort; idx1 += (nshort<<1); + time_out[idx0] = overlap[idx0] + MUL_F(transf_buf[idx1-nshort], win0) + MUL_F(transf_buf[idx1], win1); idx0 += nshort; idx1 += (nshort<<1); + time_out[idx0] = overlap[idx0] + MUL_F(transf_buf[idx1-nshort], win0) + MUL_F(transf_buf[idx1], win1); + } + + /* Window the second half and save as overlap for next frame */ + /* Step 1: Second window half, first half of nshort */ + for (i = 0; i < nshort/2; i++) { + win0 = window_short[nshort-1-i]; + win1 = window_short[i]; + idx0 = nflat_ls + 5*nshort + i - nlong; + idx1 = nshort*10 + i; + overlap[idx0] = MUL_F(transf_buf[idx1-nshort], win0) + MUL_F(transf_buf[idx1], win1); idx0 += nshort; idx1 += (nshort<<1); + overlap[idx0] = MUL_F(transf_buf[idx1-nshort], win0) + MUL_F(transf_buf[idx1], win1); idx0 += nshort; idx1 += (nshort<<1); + overlap[idx0] = MUL_F(transf_buf[idx1-nshort], win0) + MUL_F(transf_buf[idx1], win1); idx0 += nshort; idx1 += (nshort<<1); + overlap[idx0] = MUL_F(transf_buf[idx1-nshort], win0); + } + /* Step 2: Second window half, second half of nshort */ + for (; i < nshort; i++) { + win0 = window_short[nshort-1-i]; + win1 = window_short[i]; + idx0 = nflat_ls + 4*nshort + i - nlong; + idx1 = nshort*8 + i; + overlap[idx0] = MUL_F(transf_buf[idx1-nshort], win0) + MUL_F(transf_buf[idx1], win1); idx0 += nshort; idx1 += (nshort<<1); + overlap[idx0] = MUL_F(transf_buf[idx1-nshort], win0) + MUL_F(transf_buf[idx1], win1); idx0 += nshort; idx1 += (nshort<<1); + overlap[idx0] = MUL_F(transf_buf[idx1-nshort], win0) + MUL_F(transf_buf[idx1], win1); idx0 += nshort; idx1 += (nshort<<1); + overlap[idx0] = MUL_F(transf_buf[idx1-nshort], win0) + MUL_F(transf_buf[idx1], win1); idx0 += nshort; idx1 += (nshort<<1); + overlap[idx0] = MUL_F(transf_buf[idx1-nshort], win0); + } + /* Step 3: Set to zero */ + memset(overlap+nflat_ls+nshort, 0, nflat_ls*sizeof(real_t)); + + break; + + case LONG_STOP_SEQUENCE: + /* perform iMDCT */ + ff_imdct_calc(11, transf_buf, freq_in); + + /* add second half output of previous frame to windowed output of current frame */ + /* construct first half window using padding with 1's and 0's */ + memcpy(time_out, overlap, nflat_ls*sizeof(real_t)); + + vector_fmul_add_add(time_out+nflat_ls, transf_buf+nflat_ls, window_short_prev, overlap+nflat_ls, nshort); + + /* nflat_ls can be divided by 2. */ + idx0 = nflat_ls + nshort; + for (i = 0; i < nflat_ls; i+=2) { + time_out[idx0] = overlap[idx0] + transf_buf[idx0]; idx0++; + time_out[idx0] = overlap[idx0] + transf_buf[idx0]; idx0++; + } + + /* window the second half and save as overlap for next frame */ + vector_fmul_reverse(overlap, transf_buf+nlong, window_long, nlong); + break; + } + +#if 0 + for (i = 0; i < 1024; i++) + { + printf("%d\n", time_out[i]); + //printf("0x%.8X\n", time_out[i]); + } +#endif + + +#ifdef PROFILE + count = faad_get_ts() - count; + fb->cycles += count; +#endif +} + + +#ifdef LTP_DEC +/* only works for LTP -> no overlapping, no short blocks */ +void filter_bank_ltp(fb_info *fb, uint8_t window_sequence, uint8_t window_shape, + uint8_t window_shape_prev, real_t *in_data, real_t *out_mdct, + uint8_t object_type, uint16_t frame_len) +{ + int16_t i; + + const real_t *window_long = NULL; + const real_t *window_long_prev = NULL; + const real_t *window_short = NULL; + const real_t *window_short_prev = NULL; + + uint16_t nlong = frame_len; + uint16_t nshort = frame_len/8; + uint16_t nflat_ls = (nlong-nshort)/2; + + //assert(window_sequence != EIGHT_SHORT_SEQUENCE); + + memset(windowed_buf,0,sizeof(windowed_buf)); +#ifdef LD_DEC + if (object_type == LD) + { + window_long = fb->ld_window[window_shape]; + window_long_prev = fb->ld_window[window_shape_prev]; + } else { +#else + (void) object_type; +#endif + window_long = fb->long_window[window_shape]; + window_long_prev = fb->long_window[window_shape_prev]; + window_short = fb->short_window[window_shape]; + window_short_prev = fb->short_window[window_shape_prev]; +#ifdef LD_DEC + } +#endif + + switch(window_sequence) + { + case ONLY_LONG_SEQUENCE: + for (i = nlong-1; i >= 0; i--) + { + windowed_buf[i] = MUL_F(in_data[i], window_long_prev[i]); + windowed_buf[i+nlong] = MUL_F(in_data[i+nlong], window_long[nlong-1-i]); + } + mdct(fb, windowed_buf, out_mdct, 2*nlong); + break; + + case LONG_START_SEQUENCE: + for (i = 0; i < nlong; i++) + windowed_buf[i] = MUL_F(in_data[i], window_long_prev[i]); + for (i = 0; i < nflat_ls; i++) + windowed_buf[i+nlong] = in_data[i+nlong]; + for (i = 0; i < nshort; i++) + windowed_buf[i+nlong+nflat_ls] = MUL_F(in_data[i+nlong+nflat_ls], window_short[nshort-1-i]); + for (i = 0; i < nflat_ls; i++) + windowed_buf[i+nlong+nflat_ls+nshort] = 0; + mdct(fb, windowed_buf, out_mdct, 2*nlong); + break; + + case LONG_STOP_SEQUENCE: + for (i = 0; i < nflat_ls; i++) + windowed_buf[i] = 0; + for (i = 0; i < nshort; i++) + windowed_buf[i+nflat_ls] = MUL_F(in_data[i+nflat_ls], window_short_prev[i]); + for (i = 0; i < nflat_ls; i++) + windowed_buf[i+nflat_ls+nshort] = in_data[i+nflat_ls+nshort]; + for (i = 0; i < nlong; i++) + windowed_buf[i+nlong] = MUL_F(in_data[i+nlong], window_long[nlong-1-i]); + mdct(fb, windowed_buf, out_mdct, 2*nlong); + break; + } +} +#endif diff --git a/lib/rbcodec/codecs/libfaad/filtbank.h b/lib/rbcodec/codecs/libfaad/filtbank.h new file mode 100644 index 0000000000..8c9f1e3490 --- /dev/null +++ b/lib/rbcodec/codecs/libfaad/filtbank.h @@ -0,0 +1,54 @@ +/* +** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding +** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +** +** Any non-GPL usage of this software or parts of this software is strictly +** forbidden. +** +** Commercial non-GPL licensing of this software is possible. +** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** +** $Id$ +**/ + +#ifndef __FILTBANK_H__ +#define __FILTBANK_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef LTP_DEC +void filter_bank_ltp(fb_info *fb, + uint8_t window_sequence, + uint8_t window_shape, + uint8_t window_shape_prev, + real_t *in_data, + real_t *out_mdct, + uint8_t object_type, + uint16_t frame_len); +#endif + +void ifilter_bank(uint8_t window_sequence, uint8_t window_shape, + uint8_t window_shape_prev, real_t *freq_in, + real_t *time_out, real_t *overlap, + uint8_t object_type, uint16_t frame_len); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/lib/rbcodec/codecs/libfaad/fixed.h b/lib/rbcodec/codecs/libfaad/fixed.h new file mode 100644 index 0000000000..ca0402e4d3 --- /dev/null +++ b/lib/rbcodec/codecs/libfaad/fixed.h @@ -0,0 +1,230 @@ +/* +** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding +** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +** +** Any non-GPL usage of this software or parts of this software is strictly +** forbidden. +** +** Commercial non-GPL licensing of this software is possible. +** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** +** $Id$ +**/ + +#ifndef __FIXED_H__ +#define __FIXED_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(_WIN32_WCE) && defined(_ARM_) +#include +#endif + +#define COEF_BITS 28 +#define COEF_PRECISION (1 << COEF_BITS) +#define REAL_BITS 14 // MAXIMUM OF 14 FOR FIXED POINT SBR +#define REAL_PRECISION (1 << REAL_BITS) + +/* FRAC is the fractional only part of the fixed point number [0.0..1.0) */ +#define FRAC_SIZE 32 /* frac is a 32 bit integer */ +#define FRAC_BITS 31 +#define FRAC_PRECISION ((uint32_t)(1 << FRAC_BITS)) +#define FRAC_MAX 0x7FFFFFFF + +typedef int32_t real_t; + +#define FIX_CONST(A,PRECISION) (((A) >= 0) ? ((real_t)((A)*(PRECISION)+0.5)) : ((real_t)((A)*(PRECISION)-0.5))) +#define REAL_CONST(A) FIX_CONST((A),(REAL_PRECISION)) +#define COEF_CONST(A) FIX_CONST((A),(COEF_PRECISION)) +#define FRAC_CONST(A) (((A) == 1.00) ? ((real_t)FRAC_MAX) : FIX_CONST((A),(FRAC_PRECISION))) +//#define FRAC_CONST(A) (((A) >= 0) ? ((real_t)((A)*(FRAC_PRECISION)+0.5)) : ((real_t)((A)*(FRAC_PRECISION)-0.5))) + +#define Q2_BITS 22 +#define Q2_PRECISION (1 << Q2_BITS) +#define Q2_CONST(A) FIX_CONST((A),(Q2_PRECISION)) + +#if defined(CPU_COLDFIRE) + +static INLINE real_t MUL_F(real_t A, real_t B) +{ + asm volatile ( + "mac.l %[A], %[B], %%acc0\n\t" + "movclr.l %%acc0, %[A]" + : [A] "+&r" (A) : [B] "r" (B) + ); + return A; +} + +static INLINE real_t MUL_C(real_t A, real_t B) +{ + asm volatile ( + "mac.l %[A], %[B], %%acc0\n\t" + "movclr.l %%acc0, %[A]\n\t" + : [A] "+&d" (A) : [B] "r" (B) + ); + return A << 3; +} + +/* MUL_R needs too many shifts for us to just operate on the top 32 bits the + emac unit gives as usual, so we do a full 64 bit mul here. */ +static INLINE real_t MUL_R(real_t x, real_t y) +{ + real_t t1, t2; + asm volatile ( + "mac.l %[x],%[y],%%acc0\n" /* multiply */ + "mulu.l %[y],%[x] \n" /* get lower half, avoid emac stall */ + "movclr.l %%acc0,%[t1] \n" /* get higher half */ + "moveq.l #17,%[t2] \n" + "asl.l %[t2],%[t1] \n" /* hi <<= 17, plus one free */ + "moveq.l #14,%[t2] \n" + "lsr.l %[t2],%[x] \n" /* (unsigned)lo >>= 14 */ + "or.l %[x],%[t1] \n" /* combine result */ + : /* outputs */ + [t1]"=&d"(t1), + [t2]"=&d"(t2), + [x] "+d" (x) + : /* inputs */ + [y] "d" (y) + ); + return t1; +} + +static INLINE void ComplexMult(real_t *y1, real_t *y2, + real_t x1, real_t x2, real_t c1, real_t c2) +{ + asm volatile( + "mac.l %[x1], %[c1], %%acc0\n\t" + "mac.l %[x2], %[c2], %%acc0\n\t" + "mac.l %[x2], %[c1], %%acc1\n\t" + "msac.l %[x1], %[c2], %%acc1\n\t" + "movclr.l %%acc0, %[x1]\n\t" + "move.l %[x1], (%[y1])\n\t" + "movclr.l %%acc1, %[x1]\n\t" + "move.l %[x1], (%[y2])" + : [x1] "+&r" (x1) + : [x2] "r" (x2), [y1] "a" (y1), [y2] "a" (y2), + [c1] "r" (c1), [c2] "r" (c2) + : "memory" + ); +} + + /* the following see little or no use, so just ignore them for now */ + #define MUL_Q2(A,B) (real_t)(((int64_t)(A)*(int64_t)(B)+(1 << (Q2_BITS-1))) >> Q2_BITS) + +#elif defined(__GNUC__) && defined (__arm__) + +/* taken from MAD */ +#define arm_mul(x, y, SCALEBITS) \ +({ \ + uint32_t __hi; \ + uint32_t __lo; \ + uint32_t __result; \ + asm("smull %0, %1, %3, %4\n\t" \ + "movs %0, %0, lsr %5\n\t" \ + "adc %2, %0, %1, lsl %6" \ + : "=&r" (__lo), "=&r" (__hi), "=r" (__result) \ + : "%r" (x), "r" (y), \ + "M" (SCALEBITS), "M" (32 - (SCALEBITS)) \ + : "cc"); \ + __result; \ +}) + +static INLINE real_t MUL_R(real_t A, real_t B) +{ + return arm_mul(A, B, REAL_BITS); +} + +static INLINE real_t MUL_C(real_t A, real_t B) +{ + return arm_mul(A, B, COEF_BITS); +} + +static INLINE real_t MUL_Q2(real_t A, real_t B) +{ + return arm_mul(A, B, Q2_BITS); +} + +static INLINE real_t _MulHigh(real_t x, real_t y) +{ + uint32_t __lo; + uint32_t __hi; + asm("smull\t%0, %1, %2, %3" + : "=&r"(__lo),"=&r"(__hi) + : "%r"(x),"r"(y) + : "cc"); + return __hi; +} + +static INLINE real_t MUL_F(real_t A, real_t B) +{ + return _MulHigh(A, B) << (FRAC_SIZE-FRAC_BITS); +} + +/* Complex multiplication */ +static INLINE void ComplexMult(real_t *y1, real_t *y2, + real_t x1, real_t x2, real_t c1, real_t c2) +{ + int32_t tmp, yt1, yt2; + asm("smull %0, %1, %4, %6\n\t" + "smlal %0, %1, %5, %7\n\t" + "rsb %3, %4, #0\n\t" + "smull %0, %2, %5, %6\n\t" + "smlal %0, %2, %3, %7" + : "=&r" (tmp), "=&r" (yt1), "=&r" (yt2), "=r" (x1) + : "3" (x1), "r" (x2), "r" (c1), "r" (c2) + : "cc" ); + *y1 = yt1 << (FRAC_SIZE-FRAC_BITS); + *y2 = yt2 << (FRAC_SIZE-FRAC_BITS); +} + +#else + + /* multiply with real shift */ + #define MUL_R(A,B) (real_t)(((int64_t)(A)*(int64_t)(B)+(1 << (REAL_BITS-1))) >> REAL_BITS) + /* multiply with coef shift */ + #define MUL_C(A,B) (real_t)(((int64_t)(A)*(int64_t)(B)+(1 << (COEF_BITS-1))) >> COEF_BITS) + /* multiply with fractional shift */ +#if defined(_WIN32_WCE) && defined(_ARM_) + /* eVC for PocketPC has an intrinsic function that returns only the high 32 bits of a 32x32 bit multiply */ + static INLINE real_t MUL_F(real_t A, real_t B) + { + return _MulHigh(A,B) << (32-FRAC_BITS); + } +#else + #define _MulHigh(A,B) (real_t)(((int64_t)(A)*(int64_t)(B)+(1 << (FRAC_SIZE-1))) >> FRAC_SIZE) + #define MUL_F(A,B) (real_t)(((int64_t)(A)*(int64_t)(B)+(1 << (FRAC_BITS-1))) >> FRAC_BITS) +#endif + #define MUL_Q2(A,B) (real_t)(((int64_t)(A)*(int64_t)(B)+(1 << (Q2_BITS-1))) >> Q2_BITS) + +/* Complex multiplication */ +static INLINE void ComplexMult(real_t *y1, real_t *y2, + real_t x1, real_t x2, real_t c1, real_t c2) +{ + *y1 = (_MulHigh(x1, c1) + _MulHigh(x2, c2))<<(FRAC_SIZE-FRAC_BITS); + *y2 = (_MulHigh(x2, c1) - _MulHigh(x1, c2))<<(FRAC_SIZE-FRAC_BITS); +} + +#endif + + + +#ifdef __cplusplus +} +#endif +#endif diff --git a/lib/rbcodec/codecs/libfaad/hcr.c b/lib/rbcodec/codecs/libfaad/hcr.c new file mode 100644 index 0000000000..f968ea7bec --- /dev/null +++ b/lib/rbcodec/codecs/libfaad/hcr.c @@ -0,0 +1,409 @@ +/* +** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding +** Copyright (C) 2004 G.C. Pascutto, Ahead Software AG, http://www.nero.com +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +** +** Any non-GPL usage of this software or parts of this software is strictly +** forbidden. +** +** Commercial non-GPL licensing of this software is possible. +** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** +** $Id$ +**/ + +#include "common.h" +#include "structs.h" + +#include +#include + +#include "specrec.h" +#include "huffman.h" + +/* ISO/IEC 14496-3/Amd.1 + * 8.5.3.3: Huffman Codeword Reordering for AAC spectral data (HCR) + * + * HCR devides the spectral data in known fixed size segments, and + * sorts it by the importance of the data. The importance is firstly + * the (lower) position in the spectrum, and secondly the largest + * value in the used codebook. + * The most important data is written at the start of each segment + * (at known positions), the remaining data is interleaved inbetween, + * with the writing direction alternating. + * Data length is not increased. +*/ + +#ifdef ERROR_RESILIENCE + +/* 8.5.3.3.1 Pre-sorting */ + +#define NUM_CB 6 +#define NUM_CB_ER 22 +#define MAX_CB 32 +#define VCB11_FIRST 16 +#define VCB11_LAST 31 + +static const uint8_t PreSortCB_STD[NUM_CB] = + { 11, 9, 7, 5, 3, 1}; + +static const uint8_t PreSortCB_ER[NUM_CB_ER] = + { 11, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 9, 7, 5, 3, 1}; + +/* 8.5.3.3.2 Derivation of segment width */ + +static const uint8_t maxCwLen[MAX_CB] = {0, 11, 9, 20, 16, 13, 11, 14, 12, 17, 14, 49, + 0, 0, 0, 0, 14, 17, 21, 21, 25, 25, 29, 29, 29, 29, 33, 33, 33, 37, 37, 41}; + +#define segmentWidth(cb) min(maxCwLen[cb], ics->length_of_longest_codeword) + +/* bit-twiddling helpers */ +static const uint8_t S[] = {1, 2, 4, 8, 16}; +static const uint32_t B[] = {0x55555555, 0x33333333, 0x0F0F0F0F, 0x00FF00FF, 0x0000FFFF}; + +typedef struct +{ + uint8_t cb; + uint8_t decoded; + uint16_t sp_offset; + bits_t bits; +} codeword_t; + +/* rewind and reverse */ +/* 32 bit version */ +static uint32_t rewrev_word(uint32_t v, const uint8_t len) +{ + /* 32 bit reverse */ + v = ((v >> S[0]) & B[0]) | ((v << S[0]) & ~B[0]); + v = ((v >> S[1]) & B[1]) | ((v << S[1]) & ~B[1]); + v = ((v >> S[2]) & B[2]) | ((v << S[2]) & ~B[2]); + v = ((v >> S[3]) & B[3]) | ((v << S[3]) & ~B[3]); + v = ((v >> S[4]) & B[4]) | ((v << S[4]) & ~B[4]); + + /* shift off low bits */ + v >>= (32 - len); + + return v; +} + +/* 64 bit version */ +static void rewrev_lword(uint32_t *hi, uint32_t *lo, const uint8_t len) +{ + if (len <= 32) { + *hi = 0; + *lo = rewrev_word(*lo, len); + } else + { + uint32_t t = *hi, v = *lo; + + /* double 32 bit reverse */ + v = ((v >> S[0]) & B[0]) | ((v << S[0]) & ~B[0]); + t = ((t >> S[0]) & B[0]) | ((t << S[0]) & ~B[0]); + v = ((v >> S[1]) & B[1]) | ((v << S[1]) & ~B[1]); + t = ((t >> S[1]) & B[1]) | ((t << S[1]) & ~B[1]); + v = ((v >> S[2]) & B[2]) | ((v << S[2]) & ~B[2]); + t = ((t >> S[2]) & B[2]) | ((t << S[2]) & ~B[2]); + v = ((v >> S[3]) & B[3]) | ((v << S[3]) & ~B[3]); + t = ((t >> S[3]) & B[3]) | ((t << S[3]) & ~B[3]); + v = ((v >> S[4]) & B[4]) | ((v << S[4]) & ~B[4]); + t = ((t >> S[4]) & B[4]) | ((t << S[4]) & ~B[4]); + + /* last 32<>32 bit swap is implicit below */ + + /* shift off low bits (this is really only one 64 bit shift) */ + *lo = (t >> (64 - len)) | (v << (len - 32)); + *hi = v >> (64 - len); + } +} + + +/* bits_t version */ +static void rewrev_bits(bits_t *bits) +{ + if (bits->len == 0) return; + rewrev_lword(&bits->bufb, &bits->bufa, bits->len); +} + + +/* merge bits of a to b */ +static void concat_bits(bits_t *b, bits_t *a) +{ + uint32_t bl, bh, al, ah; + + if (a->len == 0) return; + + al = a->bufa; + ah = a->bufb; + + if (b->len > 32) + { + /* maskoff superfluous high b bits */ + bl = b->bufa; + bh = b->bufb & ((1 << (b->len-32)) - 1); + /* left shift a b->len bits */ + ah = al << (b->len - 32); + al = 0; + } else { + bl = b->bufa & ((1 << (b->len)) - 1); + bh = 0; + ah = (ah << (b->len)) | (al >> (32 - b->len)); + al = al << b->len; + } + + /* merge */ + b->bufa = bl | al; + b->bufb = bh | ah; + + b->len += a->len; +} + +uint8_t is_good_cb(uint8_t this_CB, uint8_t this_sec_CB) +{ + /* only want spectral data CB's */ + if ((this_sec_CB > ZERO_HCB && this_sec_CB <= ESC_HCB) || (this_sec_CB >= VCB11_FIRST && this_sec_CB <= VCB11_LAST)) + { + if (this_CB < ESC_HCB) + { + /* normal codebook pairs */ + return ((this_sec_CB == this_CB) || (this_sec_CB == this_CB + 1)); + } else + { + /* escape codebook */ + return (this_sec_CB == this_CB); + } + } + return 0; +} + +void read_segment(bits_t *segment, uint8_t segwidth, bitfile *ld) +{ + segment->len = segwidth; + + if (segwidth > 32) + { + segment->bufb = faad_getbits(ld, segwidth - 32); + segment->bufa = faad_getbits(ld, 32); + + } else { + segment->bufa = faad_getbits(ld, segwidth); + segment->bufb = 0; + } +} + +void fill_in_codeword(codeword_t *codeword, uint16_t index, uint16_t sp, uint8_t cb) +{ + codeword[index].sp_offset = sp; + codeword[index].cb = cb; + codeword[index].decoded = 0; + codeword[index].bits.len = 0; +} + +uint8_t reordered_spectral_data(NeAACDecHandle hDecoder, ic_stream *ics, + bitfile *ld, int16_t *spectral_data) +{ + uint16_t PCWs_done; + uint16_t numberOfSegments, numberOfSets, numberOfCodewords; + + static codeword_t codeword[512]; + static bits_t segment[512]; + + uint16_t sp_offset[8]; + uint16_t g, i, sortloop, set, bitsread; + uint8_t w_idx, sfb, this_CB, last_CB, this_sec_CB; + + const uint16_t nshort = hDecoder->frameLength/8; + const uint16_t sp_data_len = ics->length_of_reordered_spectral_data; + + const uint8_t *PreSortCb; + + /* no data (e.g. silence) */ + if (sp_data_len == 0) + return 0; + + /* since there is spectral data, at least one codeword has nonzero length */ + if (ics->length_of_longest_codeword == 0) + return 10; + + if (sp_data_len < ics->length_of_longest_codeword) + return 10; + + sp_offset[0] = 0; + for (g = 1; g < ics->num_window_groups; g++) + { + sp_offset[g] = sp_offset[g-1] + nshort*ics->window_group_length[g-1]; + } + + PCWs_done = 0; + numberOfSegments = 0; + numberOfCodewords = 0; + bitsread = 0; + + /* VCB11 code books in use */ + if (hDecoder->aacSectionDataResilienceFlag) + { + PreSortCb = PreSortCB_ER; + last_CB = NUM_CB_ER; + } else + { + PreSortCb = PreSortCB_STD; + last_CB = NUM_CB; + } + + /* step 1: decode PCW's (set 0), and stuff data in easier-to-use format */ + for (sortloop = 0; sortloop < last_CB; sortloop++) + { + /* select codebook to process this pass */ + this_CB = PreSortCb[sortloop]; + + /* loop over sfbs */ + for (sfb = 0; sfb < ics->max_sfb; sfb++) + { + /* loop over all in this sfb, 4 lines per loop */ + for (w_idx = 0; 4*w_idx < (ics->swb_offset[sfb+1] - ics->swb_offset[sfb]); w_idx++) + { + for(g = 0; g < ics->num_window_groups; g++) + { + for (i = 0; i < ics->num_sec[g]; i++) + { + /* check whether sfb used here is the one we want to process */ + if ((ics->sect_start[g][i] <= sfb) && (ics->sect_end[g][i] > sfb)) + { + /* check whether codebook used here is the one we want to process */ + this_sec_CB = ics->sect_cb[g][i]; + + if (is_good_cb(this_CB, this_sec_CB)) + { + /* precalculate some stuff */ + uint16_t sect_sfb_size = ics->sect_sfb_offset[g][sfb+1] - ics->sect_sfb_offset[g][sfb]; + uint8_t inc = (this_sec_CB < FIRST_PAIR_HCB) ? QUAD_LEN : PAIR_LEN; + uint16_t group_cws_count = (4*ics->window_group_length[g])/inc; + uint8_t segwidth = segmentWidth(this_sec_CB); + uint16_t cws; + + /* read codewords until end of sfb or end of window group (shouldn't only 1 trigger?) */ + for (cws = 0; (cws < group_cws_count) && ((cws + w_idx*group_cws_count) < sect_sfb_size); cws++) + { + uint16_t sp = sp_offset[g] + ics->sect_sfb_offset[g][sfb] + inc * (cws + w_idx*group_cws_count); + + /* read and decode PCW */ + if (!PCWs_done) + { + /* read in normal segments */ + if (bitsread + segwidth <= sp_data_len) + { + read_segment(&segment[numberOfSegments], segwidth, ld); + bitsread += segwidth; + + huffman_spectral_data_2(this_sec_CB, &segment[numberOfSegments], &spectral_data[sp]); + + /* keep leftover bits */ + rewrev_bits(&segment[numberOfSegments]); + + numberOfSegments++; + } else { + /* remaining stuff after last segment, we unfortunately couldn't read + this in earlier because it might not fit in 64 bits. since we already + decoded (and removed) the PCW it is now guaranteed to fit */ + if (bitsread < sp_data_len) + { + const uint8_t additional_bits = sp_data_len - bitsread; + + read_segment(&segment[numberOfSegments], additional_bits, ld); + segment[numberOfSegments].len += segment[numberOfSegments-1].len; + rewrev_bits(&segment[numberOfSegments]); + + if (segment[numberOfSegments-1].len > 32) + { + segment[numberOfSegments-1].bufb = segment[numberOfSegments].bufb + + showbits_hcr(&segment[numberOfSegments-1], segment[numberOfSegments-1].len - 32); + segment[numberOfSegments-1].bufa = segment[numberOfSegments].bufa + + showbits_hcr(&segment[numberOfSegments-1], 32); + } else { + segment[numberOfSegments-1].bufa = segment[numberOfSegments].bufa + + showbits_hcr(&segment[numberOfSegments-1], segment[numberOfSegments-1].len); + segment[numberOfSegments-1].bufb = segment[numberOfSegments].bufb; + } + segment[numberOfSegments-1].len += additional_bits; + } + bitsread = sp_data_len; + PCWs_done = 1; + + fill_in_codeword(codeword, 0, sp, this_sec_CB); + } + } else { + fill_in_codeword(codeword, numberOfCodewords - numberOfSegments, sp, this_sec_CB); + } + numberOfCodewords++; + } + } + } + } + } + } + } + } + + if (numberOfSegments == 0) + return 10; + + numberOfSets = numberOfCodewords / numberOfSegments; + + /* step 2: decode nonPCWs */ + for (set = 1; set <= numberOfSets; set++) + { + uint16_t trial; + + for (trial = 0; trial < numberOfSegments; trial++) + { + uint16_t codewordBase; + + for (codewordBase = 0; codewordBase < numberOfSegments; codewordBase++) + { + const uint16_t segment_idx = (trial + codewordBase) % numberOfSegments; + const uint16_t codeword_idx = codewordBase + set*numberOfSegments - numberOfSegments; + + /* data up */ + if (codeword_idx >= numberOfCodewords - numberOfSegments) break; + + if (!codeword[codeword_idx].decoded && segment[segment_idx].len > 0) + { + uint8_t tmplen; + + if (codeword[codeword_idx].bits.len != 0) + concat_bits(&segment[segment_idx], &codeword[codeword_idx].bits); + + tmplen = segment[segment_idx].len; + + if (huffman_spectral_data_2(codeword[codeword_idx].cb, &segment[segment_idx], + &spectral_data[codeword[codeword_idx].sp_offset]) >= 0) + { + codeword[codeword_idx].decoded = 1; + } else + { + codeword[codeword_idx].bits = segment[segment_idx]; + codeword[codeword_idx].bits.len = tmplen; + } + + } + } + } + for (i = 0; i < numberOfSegments; i++) + rewrev_bits(&segment[i]); + } + + return 0; +} +#endif diff --git a/lib/rbcodec/codecs/libfaad/huffman.c b/lib/rbcodec/codecs/libfaad/huffman.c new file mode 100644 index 0000000000..bea0dd7bf2 --- /dev/null +++ b/lib/rbcodec/codecs/libfaad/huffman.c @@ -0,0 +1,563 @@ +/* +** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding +** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +** +** Any non-GPL usage of this software or parts of this software is strictly +** forbidden. +** +** Commercial non-GPL licensing of this software is possible. +** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** +** $Id$ +**/ + +#include "common.h" +#include "structs.h" + +#include +#ifdef ANALYSIS +#include +#endif + +#include "bits.h" +#include "huffman.h" +#include "codebook/hcb.h" + + +/* static function declarations */ +static INLINE void huffman_sign_bits_pair(bitfile *ld, int16_t *sp); +static INLINE void huffman_sign_bits_quad(bitfile *ld, int16_t *sp); +static INLINE int16_t huffman_getescape(bitfile *ld, int16_t sp); +static uint8_t huffman_2step_quad(uint8_t cb, bitfile *ld, int16_t *sp); +static uint8_t huffman_2step_quad_sign(uint8_t cb, bitfile *ld, int16_t *sp); +static INLINE uint8_t huffman_2step_pair(uint8_t cb, bitfile *ld, int16_t *sp); +static INLINE uint8_t huffman_2step_pair_sign(uint8_t cb, bitfile *ld, int16_t *sp); +static uint8_t huffman_binary_quad(uint8_t cb, bitfile *ld, int16_t *sp); +static uint8_t huffman_binary_quad_sign(uint8_t cb, bitfile *ld, int16_t *sp); +static uint8_t huffman_binary_pair(uint8_t cb, bitfile *ld, int16_t *sp); +static uint8_t huffman_binary_pair_sign(uint8_t cb, bitfile *ld, int16_t *sp); +static int16_t huffman_codebook(uint8_t i) ICODE_ATTR_FAAD_LARGE_IRAM; +#ifdef ERROR_RESILIENCE +static void vcb11_check_LAV(uint8_t cb, int16_t *sp); +#endif + +int8_t huffman_scale_factor(bitfile *ld) +{ + uint16_t offset = 0; + + while (hcb_sf[offset][1]) + { + uint8_t b = faad_get1bit(ld + DEBUGVAR(1,255,"huffman_scale_factor()")); + offset += hcb_sf[offset][b]; + + if (offset > 240) + { + /* printf("ERROR: offset into hcb_sf = %d >240!\n", offset); */ + return -1; + } + } + + return hcb_sf[offset][0]; +} + + +hcb *hcb_table[] ICONST_ATTR = { + 0, hcb1_1, hcb2_1, 0, hcb4_1, 0, hcb6_1, 0, hcb8_1, 0, hcb10_1, hcb11_1 +}; + +hcb_2_quad *hcb_2_quad_table[] ICONST_ATTR = { + 0, hcb1_2, hcb2_2, 0, hcb4_2, 0, 0, 0, 0, 0, 0, 0 +}; + +hcb_2_pair *hcb_2_pair_table[] ICONST_ATTR = { + 0, 0, 0, 0, 0, 0, hcb6_2, 0, hcb8_2, 0, hcb10_2, hcb11_2 +}; + +hcb_bin_pair *hcb_bin_table[] ICONST_ATTR = { + 0, 0, 0, 0, 0, hcb5, 0, hcb7, 0, hcb9, 0, 0 +}; + +uint8_t hcbN[] ICONST_ATTR = { 0, 5, 5, 0, 5, 0, 5, 0, 5, 0, 6, 5 }; + +/* defines whether a huffman codebook is unsigned or not */ +/* Table 4.6.2 */ +uint8_t unsigned_cb[] ICONST_ATTR = { 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, + /* codebook 16 to 31 */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 +}; + +int hcb_2_quad_table_size[] ICONST_ATTR = { 0, 114, 86, 0, 185, 0, 0, 0, 0, 0, 0, 0 }; +int hcb_2_pair_table_size[] ICONST_ATTR = { 0, 0, 0, 0, 0, 0, 126, 0, 83, 0, 210, 373 }; +int hcb_bin_table_size[] ICONST_ATTR = { 0, 0, 0, 161, 0, 161, 0, 127, 0, 337, 0, 0 }; + +#define FAAD_GET_SIGN(idx) \ + if (sp[idx]) \ + if (faad_get1bit(ld)&1) \ + sp[idx] = -sp[idx]; \ + +static INLINE void huffman_sign_bits_pair(bitfile *ld, int16_t *sp) +{ + FAAD_GET_SIGN(0) + FAAD_GET_SIGN(1) +} + +static INLINE void huffman_sign_bits_quad(bitfile *ld, int16_t *sp) +{ + FAAD_GET_SIGN(0) + FAAD_GET_SIGN(1) + FAAD_GET_SIGN(2) + FAAD_GET_SIGN(3) +} + +static INLINE int16_t huffman_getescape(bitfile *ld, int16_t sp) +{ + uint8_t neg, i; + int16_t j; + int16_t off; + + if (sp < 0) + { + if (sp != -16) + return sp; + neg = 1; + } else { + if (sp != 16) + return sp; + neg = 0; + } + + for (i = 4; ; i++) + { + if (faad_get1bit(ld + DEBUGVAR(1,6,"huffman_getescape(): escape size")) == 0) + { + break; + } + } + + off = (int16_t)faad_getbits(ld, i + DEBUGVAR(1,9,"huffman_getescape(): escape")); + + j = off | (1< hcb_2_quad_table_size[cb]) + { + /* printf("ERROR: offset into hcb_2_quad_table = %d >%d!\n", offset, + hcb_2_quad_table_size[cb]); */ + return 10; + } + + sp[0] = hcb_2_quad_table[cb][offset].x; + sp[1] = hcb_2_quad_table[cb][offset].y; + sp[2] = hcb_2_quad_table[cb][offset].v; + sp[3] = hcb_2_quad_table[cb][offset].w; + + return 0; +} + +static uint8_t huffman_2step_quad_sign(uint8_t cb, bitfile *ld, int16_t *sp) +{ + uint8_t err = huffman_2step_quad(cb, ld, sp); + huffman_sign_bits_quad(ld, sp); + + return err; +} + +static INLINE uint8_t huffman_2step_pair(uint8_t cb, bitfile *ld, int16_t *sp) +{ + uint32_t cw; + uint16_t offset = 0; + uint8_t extra_bits; + + cw = faad_showbits(ld, hcbN[cb]); + offset = hcb_table[cb][cw].offset; + extra_bits = hcb_table[cb][cw].extra_bits; + + if (extra_bits) + { + /* we know for sure it's more than hcbN[cb] bits long */ + faad_flushbits(ld, hcbN[cb]); + offset += (uint16_t)faad_showbits(ld, extra_bits); + faad_flushbits(ld, hcb_2_pair_table[cb][offset].bits - hcbN[cb]); + } else { + faad_flushbits(ld, hcb_2_pair_table[cb][offset].bits); + } + + if (offset > hcb_2_pair_table_size[cb]) + { + /* printf("ERROR: offset into hcb_2_pair_table = %d >%d!\n", offset, + hcb_2_pair_table_size[cb]); */ + return 10; + } + + sp[0] = hcb_2_pair_table[cb][offset].x; + sp[1] = hcb_2_pair_table[cb][offset].y; + + return 0; +} + +static INLINE uint8_t huffman_2step_pair_sign(uint8_t cb, bitfile *ld, int16_t *sp) +{ + uint8_t err = huffman_2step_pair(cb, ld, sp); + huffman_sign_bits_pair(ld, sp); + + return err; +} + +static uint8_t huffman_binary_quad(uint8_t cb, bitfile *ld, int16_t *sp) +{ + uint16_t offset = 0; + + while (!hcb3[offset].is_leaf) + { + uint8_t b = faad_get1bit(ld + DEBUGVAR(1,255,"huffman_spectral_data():3")); + offset += hcb3[offset].data[b]; + } + + if (offset > hcb_bin_table_size[cb]) + { + /* printf("ERROR: offset into hcb_bin_table = %d >%d!\n", offset, + hcb_bin_table_size[cb]); */ + return 10; + } + + sp[0] = hcb3[offset].data[0]; + sp[1] = hcb3[offset].data[1]; + sp[2] = hcb3[offset].data[2]; + sp[3] = hcb3[offset].data[3]; + + return 0; +} + +static uint8_t huffman_binary_quad_sign(uint8_t cb, bitfile *ld, int16_t *sp) +{ + uint8_t err = huffman_binary_quad(cb, ld, sp); + huffman_sign_bits_quad(ld, sp); + + return err; +} + +static uint8_t huffman_binary_pair(uint8_t cb, bitfile *ld, int16_t *sp) +{ + uint16_t offset = 0; + + while (!hcb_bin_table[cb][offset].is_leaf) + { + uint8_t b = faad_get1bit(ld + DEBUGVAR(1,255,"huffman_spectral_data():9")); + offset += hcb_bin_table[cb][offset].data[b]; + } + + if (offset > hcb_bin_table_size[cb]) + { + /* printf("ERROR: offset into hcb_bin_table = %d >%d!\n", offset, + hcb_bin_table_size[cb]); */ + return 10; + } + + sp[0] = hcb_bin_table[cb][offset].data[0]; + sp[1] = hcb_bin_table[cb][offset].data[1]; + + return 0; +} + +static uint8_t huffman_binary_pair_sign(uint8_t cb, bitfile *ld, int16_t *sp) +{ + uint8_t err = huffman_binary_pair(cb, ld, sp); + huffman_sign_bits_pair(ld, sp); + + return err; +} + +static int16_t huffman_codebook(uint8_t i) +{ + static const uint32_t data = 16428320; + if (i == 0) return (int16_t)(data >> 16) & 0xFFFF; + else return (int16_t)data & 0xFFFF; +} + +#ifdef ERROR_RESILIENCE +static void vcb11_check_LAV(uint8_t cb, int16_t *sp) +{ + static const uint16_t vcb11_LAV_tab[] = { + 16, 31, 47, 63, 95, 127, 159, 191, 223, + 255, 319, 383, 511, 767, 1023, 2047 + }; + uint16_t max = 0; + + if (cb < 16 || cb > 31) + return; + + max = vcb11_LAV_tab[cb - 16]; + + if ((abs(sp[0]) > max) || (abs(sp[1]) > max)) + { + sp[0] = 0; + sp[1] = 0; + } +} +#endif + +uint8_t huffman_spectral_data(uint8_t cb, bitfile *ld, int16_t *sp) +{ + switch (cb) + { + case 1: /* 2-step method for data quadruples */ + case 2: + return huffman_2step_quad(cb, ld, sp); + case 3: /* binary search for data quadruples */ + return huffman_binary_quad_sign(cb, ld, sp); + case 4: /* 2-step method for data quadruples */ + return huffman_2step_quad_sign(cb, ld, sp); + case 5: /* binary search for data pairs */ + return huffman_binary_pair(cb, ld, sp); + case 6: /* 2-step method for data pairs */ + return huffman_2step_pair(cb, ld, sp); + case 7: /* binary search for data pairs */ + case 9: + return huffman_binary_pair_sign(cb, ld, sp); + case 8: /* 2-step method for data pairs */ + case 10: + return huffman_2step_pair_sign(cb, ld, sp); + case 12: { + uint8_t err = huffman_2step_pair(11, ld, sp); + sp[0] = huffman_codebook(0); sp[1] = huffman_codebook(1); + return err; } + case 11: + { + uint8_t err = huffman_2step_pair_sign(11, ld, sp); + sp[0] = huffman_getescape(ld, sp[0]); + sp[1] = huffman_getescape(ld, sp[1]); + return err; + } +#ifdef ERROR_RESILIENCE + /* VCB11 uses codebook 11 */ + case 16: case 17: case 18: case 19: case 20: case 21: case 22: case 23: + case 24: case 25: case 26: case 27: case 28: case 29: case 30: case 31: + { + uint8_t err = huffman_2step_pair_sign(11, ld, sp); + sp[0] = huffman_getescape(ld, sp[0]); + sp[1] = huffman_getescape(ld, sp[1]); + + /* check LAV (Largest Absolute Value) */ + /* this finds errors in the ESCAPE signal */ + vcb11_check_LAV(cb, sp); + + return err; + } +#endif + default: + /* Non existent codebook number, something went wrong */ + return 11; + } + + return 0; +} + + +#ifdef ERROR_RESILIENCE + +/* Special version of huffman_spectral_data +Will not read from a bitfile but a bits_t structure. +Will keep track of the bits decoded and return the number of bits remaining. +Do not read more than ld->len, return -1 if codeword would be longer */ + +int8_t huffman_spectral_data_2(uint8_t cb, bits_t *ld, int16_t *sp) +{ + uint32_t cw; + uint16_t offset = 0; + uint8_t extra_bits; + uint8_t i, vcb11 = 0; + + + switch (cb) + { + case 1: /* 2-step method for data quadruples */ + case 2: + case 4: + + cw = showbits_hcr(ld, hcbN[cb]); + offset = hcb_table[cb][cw].offset; + extra_bits = hcb_table[cb][cw].extra_bits; + + if (extra_bits) + { + /* we know for sure it's more than hcbN[cb] bits long */ + if ( flushbits_hcr(ld, hcbN[cb]) ) return -1; + offset += (uint16_t)showbits_hcr(ld, extra_bits); + if ( flushbits_hcr(ld, hcb_2_quad_table[cb][offset].bits - hcbN[cb]) ) return -1; + } else { + if ( flushbits_hcr(ld, hcb_2_quad_table[cb][offset].bits) ) return -1; + } + + sp[0] = hcb_2_quad_table[cb][offset].x; + sp[1] = hcb_2_quad_table[cb][offset].y; + sp[2] = hcb_2_quad_table[cb][offset].v; + sp[3] = hcb_2_quad_table[cb][offset].w; + break; + + case 6: /* 2-step method for data pairs */ + case 8: + case 10: + case 11: + /* VCB11 uses codebook 11 */ + case 16: case 17: case 18: case 19: case 20: case 21: case 22: case 23: + case 24: case 25: case 26: case 27: case 28: case 29: case 30: case 31: + + if (cb >= 16) + { + /* store the virtual codebook */ + vcb11 = cb; + cb = 11; + } + + cw = showbits_hcr(ld, hcbN[cb]); + offset = hcb_table[cb][cw].offset; + extra_bits = hcb_table[cb][cw].extra_bits; + + if (extra_bits) + { + /* we know for sure it's more than hcbN[cb] bits long */ + if ( flushbits_hcr(ld, hcbN[cb]) ) return -1; + offset += (uint16_t)showbits_hcr(ld, extra_bits); + if ( flushbits_hcr(ld, hcb_2_pair_table[cb][offset].bits - hcbN[cb]) ) return -1; + } else { + if ( flushbits_hcr(ld, hcb_2_pair_table[cb][offset].bits) ) return -1; + } + sp[0] = hcb_2_pair_table[cb][offset].x; + sp[1] = hcb_2_pair_table[cb][offset].y; + break; + + case 3: /* binary search for data quadruples */ + + while (!hcb3[offset].is_leaf) + { + uint8_t b; + + if ( get1bit_hcr(ld, &b) ) return -1; + offset += hcb3[offset].data[b]; + } + + sp[0] = hcb3[offset].data[0]; + sp[1] = hcb3[offset].data[1]; + sp[2] = hcb3[offset].data[2]; + sp[3] = hcb3[offset].data[3]; + + break; + + case 5: /* binary search for data pairs */ + case 7: + case 9: + + while (!hcb_bin_table[cb][offset].is_leaf) + { + uint8_t b; + + if (get1bit_hcr(ld, &b) ) return -1; + offset += hcb_bin_table[cb][offset].data[b]; + } + + sp[0] = hcb_bin_table[cb][offset].data[0]; + sp[1] = hcb_bin_table[cb][offset].data[1]; + + break; + } + + /* decode sign bits */ + if (unsigned_cb[cb]) + { + for(i = 0; i < ((cb < FIRST_PAIR_HCB) ? QUAD_LEN : PAIR_LEN); i++) + { + if(sp[i]) + { + uint8_t b; + if ( get1bit_hcr(ld, &b) ) return -1; + if (b != 0) { + sp[i] = -sp[i]; + } + } + } + } + + /* decode huffman escape bits */ + if ((cb == ESC_HCB) || (cb >= 16)) + { + uint8_t k; + for (k = 0; k < 2; k++) + { + if ((sp[k] == 16) || (sp[k] == -16)) + { + uint8_t neg, i; + int32_t j; + uint32_t off; + + neg = (sp[k] < 0) ? 1 : 0; + + for (i = 4; ; i++) + { + uint8_t b; + if (get1bit_hcr(ld, &b)) + return -1; + if (b == 0) + break; + } + + if (getbits_hcr(ld, i, &off)) + return -1; + j = off + (1<len; +} + +#endif + diff --git a/lib/rbcodec/codecs/libfaad/huffman.h b/lib/rbcodec/codecs/libfaad/huffman.h new file mode 100644 index 0000000000..214d3a220f --- /dev/null +++ b/lib/rbcodec/codecs/libfaad/huffman.h @@ -0,0 +1,44 @@ +/* +** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding +** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +** +** Any non-GPL usage of this software or parts of this software is strictly +** forbidden. +** +** Commercial non-GPL licensing of this software is possible. +** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** +** $Id$ +**/ + +#ifndef __HUFFMAN_H__ +#define __HUFFMAN_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +int8_t huffman_scale_factor(bitfile *ld); +uint8_t huffman_spectral_data(uint8_t cb, bitfile *ld, int16_t *sp) ICODE_ATTR_FAAD_LARGE_IRAM; +#ifdef ERROR_RESILIENCE +int8_t huffman_spectral_data_2(uint8_t cb, bits_t *ld, int16_t *sp); +#endif + +#ifdef __cplusplus +} +#endif +#endif diff --git a/lib/rbcodec/codecs/libfaad/ic_predict.c b/lib/rbcodec/codecs/libfaad/ic_predict.c new file mode 100644 index 0000000000..02cadd65b1 --- /dev/null +++ b/lib/rbcodec/codecs/libfaad/ic_predict.c @@ -0,0 +1,267 @@ +/* +** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding +** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +** +** Any non-GPL usage of this software or parts of this software is strictly +** forbidden. +** +** Commercial non-GPL licensing of this software is possible. +** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** +** $Id$ +**/ + +#include "common.h" +#include "structs.h" + +#ifdef MAIN_DEC + +#include "syntax.h" +#include "ic_predict.h" +#include "pns.h" + + +static void flt_round(float32_t *pf) +{ + int32_t flg; + uint32_t tmp, tmp1, tmp2; + + tmp = *(uint32_t*)pf; + flg = tmp & (uint32_t)0x00008000; + tmp &= (uint32_t)0xffff0000; + tmp1 = tmp; + /* round 1/2 lsb toward infinity */ + if (flg) + { + tmp &= (uint32_t)0xff800000; /* extract exponent and sign */ + tmp |= (uint32_t)0x00010000; /* insert 1 lsb */ + tmp2 = tmp; /* add 1 lsb and elided one */ + tmp &= (uint32_t)0xff800000; /* extract exponent and sign */ + + *pf = *(float32_t*)&tmp1 + *(float32_t*)&tmp2 - *(float32_t*)&tmp; + } else { + *pf = *(float32_t*)&tmp; + } +} + +static int16_t quant_pred(float32_t x) +{ + int16_t q; + uint32_t *tmp = (uint32_t*)&x; + + q = (int16_t)(*tmp>>16); + + return q; +} + +static float32_t inv_quant_pred(int16_t q) +{ + float32_t x; + uint32_t *tmp = (uint32_t*)&x; + *tmp = ((uint32_t)q)<<16; + + return x; +} + +static void ic_predict(pred_state *state, real_t input, real_t *output, uint8_t pred) +{ + uint16_t tmp; + int16_t i, j; + real_t dr1, predictedvalue; + real_t e0, e1; + real_t k1, k2; + + real_t r[2]; + real_t COR[2]; + real_t VAR[2]; + + r[0] = inv_quant_pred(state->r[0]); + r[1] = inv_quant_pred(state->r[1]); + COR[0] = inv_quant_pred(state->COR[0]); + COR[1] = inv_quant_pred(state->COR[1]); + VAR[0] = inv_quant_pred(state->VAR[0]); + VAR[1] = inv_quant_pred(state->VAR[1]); + + +#if 1 + tmp = state->VAR[0]; + j = (tmp >> 7); + i = tmp & 0x7f; + if (j >= 128) + { + j -= 128; + k1 = COR[0] * exp_table[j] * mnt_table[i]; + } else { + k1 = REAL_CONST(0); + } +#else + + { +#define B 0.953125 + real_t c = COR[0]; + real_t v = VAR[0]; + real_t tmp; + if (c == 0 || v <= 1) + { + k1 = 0; + } else { + tmp = B / v; + flt_round(&tmp); + k1 = c * tmp; + } + } +#endif + + if (pred) + { +#if 1 + tmp = state->VAR[1]; + j = (tmp >> 7); + i = tmp & 0x7f; + if (j >= 128) + { + j -= 128; + k2 = COR[1] * exp_table[j] * mnt_table[i]; + } else { + k2 = REAL_CONST(0); + } +#else + +#define B 0.953125 + real_t c = COR[1]; + real_t v = VAR[1]; + real_t tmp; + if (c == 0 || v <= 1) + { + k2 = 0; + } else { + tmp = B / v; + flt_round(&tmp); + k2 = c * tmp; + } +#endif + + predictedvalue = k1*r[0] + k2*r[1]; + flt_round(&predictedvalue); + *output = input + predictedvalue; + } + + /* calculate new state data */ + e0 = *output; + e1 = e0 - k1*r[0]; + dr1 = k1*e0; + + VAR[0] = ALPHA*VAR[0] + 0.5f * (r[0]*r[0] + e0*e0); + COR[0] = ALPHA*COR[0] + r[0]*e0; + VAR[1] = ALPHA*VAR[1] + 0.5f * (r[1]*r[1] + e1*e1); + COR[1] = ALPHA*COR[1] + r[1]*e1; + + r[1] = A * (r[0]-dr1); + r[0] = A * e0; + + state->r[0] = quant_pred(r[0]); + state->r[1] = quant_pred(r[1]); + state->COR[0] = quant_pred(COR[0]); + state->COR[1] = quant_pred(COR[1]); + state->VAR[0] = quant_pred(VAR[0]); + state->VAR[1] = quant_pred(VAR[1]); +} + +static void reset_pred_state(pred_state *state) +{ + state->r[0] = 0; + state->r[1] = 0; + state->COR[0] = 0; + state->COR[1] = 0; + state->VAR[0] = 0x3F80; + state->VAR[1] = 0x3F80; +} + +void pns_reset_pred_state(ic_stream *ics, pred_state *state) +{ + uint8_t sfb, g, b; + uint16_t i, offs, offs2; + + /* prediction only for long blocks */ + if (ics->window_sequence == EIGHT_SHORT_SEQUENCE) + return; + + for (g = 0; g < ics->num_window_groups; g++) + { + for (b = 0; b < ics->window_group_length[g]; b++) + { + for (sfb = 0; sfb < ics->max_sfb; sfb++) + { + if (is_noise(ics, g, sfb)) + { + offs = ics->swb_offset[sfb]; + offs2 = ics->swb_offset[sfb+1]; + + for (i = offs; i < offs2; i++) + reset_pred_state(&state[i]); + } + } + } + } +} + +void reset_all_predictors(pred_state *state, uint16_t frame_len) +{ + uint16_t i; + + for (i = 0; i < frame_len; i++) + reset_pred_state(&state[i]); +} + +/* intra channel prediction */ +void ic_prediction(ic_stream *ics, real_t *spec, pred_state *state, + uint16_t frame_len, uint8_t sf_index) +{ + uint8_t sfb; + uint16_t bin; + + if (ics->window_sequence == EIGHT_SHORT_SEQUENCE) + { + reset_all_predictors(state, frame_len); + } else { + for (sfb = 0; sfb < max_pred_sfb(sf_index); sfb++) + { + uint16_t low = ics->swb_offset[sfb]; + uint16_t high = ics->swb_offset[sfb+1]; + + for (bin = low; bin < high; bin++) + { + ic_predict(&state[bin], spec[bin], &spec[bin], + (ics->predictor_data_present && ics->pred.prediction_used[sfb])); + } + } + + if (ics->predictor_data_present) + { + if (ics->pred.predictor_reset) + { + for (bin = ics->pred.predictor_reset_group_number - 1; + bin < frame_len; bin += 30) + { + reset_pred_state(&state[bin]); + } + } + } + } +} + +#endif diff --git a/lib/rbcodec/codecs/libfaad/ic_predict.h b/lib/rbcodec/codecs/libfaad/ic_predict.h new file mode 100644 index 0000000000..1f2d2c657e --- /dev/null +++ b/lib/rbcodec/codecs/libfaad/ic_predict.h @@ -0,0 +1,249 @@ +/* +** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding +** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +** +** Any non-GPL usage of this software or parts of this software is strictly +** forbidden. +** +** Commercial non-GPL licensing of this software is possible. +** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** +** $Id$ +**/ + +#ifdef MAIN_DEC + +#ifndef __IC_PREDICT_H__ +#define __IC_PREDICT_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#define ALPHA REAL_CONST(0.90625) +#define A REAL_CONST(0.953125) + + +void pns_reset_pred_state(ic_stream *ics, pred_state *state); +void reset_all_predictors(pred_state *state, uint16_t frame_len); +void ic_prediction(ic_stream *ics, real_t *spec, pred_state *state, + uint16_t frame_len, uint8_t sf_index); +#warning MEM_ALIGN_ATTR me! +static const real_t mnt_table[128] = { + COEF_CONST(0.9531250000), COEF_CONST(0.9453125000), + COEF_CONST(0.9375000000), COEF_CONST(0.9296875000), + COEF_CONST(0.9257812500), COEF_CONST(0.9179687500), + COEF_CONST(0.9101562500), COEF_CONST(0.9023437500), + COEF_CONST(0.8984375000), COEF_CONST(0.8906250000), + COEF_CONST(0.8828125000), COEF_CONST(0.8789062500), + COEF_CONST(0.8710937500), COEF_CONST(0.8671875000), + COEF_CONST(0.8593750000), COEF_CONST(0.8515625000), + COEF_CONST(0.8476562500), COEF_CONST(0.8398437500), + COEF_CONST(0.8359375000), COEF_CONST(0.8281250000), + COEF_CONST(0.8242187500), COEF_CONST(0.8203125000), + COEF_CONST(0.8125000000), COEF_CONST(0.8085937500), + COEF_CONST(0.8007812500), COEF_CONST(0.7968750000), + COEF_CONST(0.7929687500), COEF_CONST(0.7851562500), + COEF_CONST(0.7812500000), COEF_CONST(0.7773437500), + COEF_CONST(0.7734375000), COEF_CONST(0.7656250000), + COEF_CONST(0.7617187500), COEF_CONST(0.7578125000), + COEF_CONST(0.7539062500), COEF_CONST(0.7500000000), + COEF_CONST(0.7421875000), COEF_CONST(0.7382812500), + COEF_CONST(0.7343750000), COEF_CONST(0.7304687500), + COEF_CONST(0.7265625000), COEF_CONST(0.7226562500), + COEF_CONST(0.7187500000), COEF_CONST(0.7148437500), + COEF_CONST(0.7109375000), COEF_CONST(0.7070312500), + COEF_CONST(0.6992187500), COEF_CONST(0.6953125000), + COEF_CONST(0.6914062500), COEF_CONST(0.6875000000), + COEF_CONST(0.6835937500), COEF_CONST(0.6796875000), + COEF_CONST(0.6796875000), COEF_CONST(0.6757812500), + COEF_CONST(0.6718750000), COEF_CONST(0.6679687500), + COEF_CONST(0.6640625000), COEF_CONST(0.6601562500), + COEF_CONST(0.6562500000), COEF_CONST(0.6523437500), + COEF_CONST(0.6484375000), COEF_CONST(0.6445312500), + COEF_CONST(0.6406250000), COEF_CONST(0.6406250000), + COEF_CONST(0.6367187500), COEF_CONST(0.6328125000), + COEF_CONST(0.6289062500), COEF_CONST(0.6250000000), + COEF_CONST(0.6210937500), COEF_CONST(0.6210937500), + COEF_CONST(0.6171875000), COEF_CONST(0.6132812500), + COEF_CONST(0.6093750000), COEF_CONST(0.6054687500), + COEF_CONST(0.6054687500), COEF_CONST(0.6015625000), + COEF_CONST(0.5976562500), COEF_CONST(0.5937500000), + COEF_CONST(0.5937500000), COEF_CONST(0.5898437500), + COEF_CONST(0.5859375000), COEF_CONST(0.5820312500), + COEF_CONST(0.5820312500), COEF_CONST(0.5781250000), + COEF_CONST(0.5742187500), COEF_CONST(0.5742187500), + COEF_CONST(0.5703125000), COEF_CONST(0.5664062500), + COEF_CONST(0.5664062500), COEF_CONST(0.5625000000), + COEF_CONST(0.5585937500), COEF_CONST(0.5585937500), + COEF_CONST(0.5546875000), COEF_CONST(0.5507812500), + COEF_CONST(0.5507812500), COEF_CONST(0.5468750000), + COEF_CONST(0.5429687500), COEF_CONST(0.5429687500), + COEF_CONST(0.5390625000), COEF_CONST(0.5390625000), + COEF_CONST(0.5351562500), COEF_CONST(0.5312500000), + COEF_CONST(0.5312500000), COEF_CONST(0.5273437500), + COEF_CONST(0.5273437500), COEF_CONST(0.5234375000), + COEF_CONST(0.5195312500), COEF_CONST(0.5195312500), + COEF_CONST(0.5156250000), COEF_CONST(0.5156250000), + COEF_CONST(0.5117187500), COEF_CONST(0.5117187500), + COEF_CONST(0.5078125000), COEF_CONST(0.5078125000), + COEF_CONST(0.5039062500), COEF_CONST(0.5039062500), + COEF_CONST(0.5000000000), COEF_CONST(0.4980468750), + COEF_CONST(0.4960937500), COEF_CONST(0.4941406250), + COEF_CONST(0.4921875000), COEF_CONST(0.4902343750), + COEF_CONST(0.4882812500), COEF_CONST(0.4863281250), + COEF_CONST(0.4843750000), COEF_CONST(0.4824218750), + COEF_CONST(0.4804687500), COEF_CONST(0.4785156250) +}; +#warning MEM_ALIGN_ATTR me! +static const real_t exp_table[128] = { + COEF_CONST(0.50000000000000000000000000000000000000000000000000), + COEF_CONST(0.25000000000000000000000000000000000000000000000000), + COEF_CONST(0.12500000000000000000000000000000000000000000000000), + COEF_CONST(0.06250000000000000000000000000000000000000000000000), + COEF_CONST(0.03125000000000000000000000000000000000000000000000), + COEF_CONST(0.01562500000000000000000000000000000000000000000000), + COEF_CONST(0.00781250000000000000000000000000000000000000000000), + COEF_CONST(0.00390625000000000000000000000000000000000000000000), + COEF_CONST(0.00195312500000000000000000000000000000000000000000), + COEF_CONST(0.00097656250000000000000000000000000000000000000000), + COEF_CONST(0.00048828125000000000000000000000000000000000000000), + COEF_CONST(0.00024414062500000000000000000000000000000000000000), + COEF_CONST(0.00012207031250000000000000000000000000000000000000), + COEF_CONST(0.00006103515625000000000000000000000000000000000000), + COEF_CONST(0.00003051757812500000000000000000000000000000000000), + COEF_CONST(0.00001525878906250000000000000000000000000000000000), + COEF_CONST(0.00000762939453125000000000000000000000000000000000), + COEF_CONST(0.00000381469726562500000000000000000000000000000000), + COEF_CONST(0.00000190734863281250000000000000000000000000000000), + COEF_CONST(0.00000095367431640625000000000000000000000000000000), + COEF_CONST(0.00000047683715820312500000000000000000000000000000), + COEF_CONST(0.00000023841857910156250000000000000000000000000000), + COEF_CONST(0.00000011920928955078125000000000000000000000000000), + COEF_CONST(0.00000005960464477539062500000000000000000000000000), + COEF_CONST(0.00000002980232238769531300000000000000000000000000), + COEF_CONST(0.00000001490116119384765600000000000000000000000000), + COEF_CONST(0.00000000745058059692382810000000000000000000000000), + COEF_CONST(0.00000000372529029846191410000000000000000000000000), + COEF_CONST(0.00000000186264514923095700000000000000000000000000), + COEF_CONST(0.00000000093132257461547852000000000000000000000000), + COEF_CONST(0.00000000046566128730773926000000000000000000000000), + COEF_CONST(0.00000000023283064365386963000000000000000000000000), + COEF_CONST(0.00000000011641532182693481000000000000000000000000), + COEF_CONST(0.00000000005820766091346740700000000000000000000000), + COEF_CONST(0.00000000002910383045673370400000000000000000000000), + COEF_CONST(0.00000000001455191522836685200000000000000000000000), + COEF_CONST(0.00000000000727595761418342590000000000000000000000), + COEF_CONST(0.00000000000363797880709171300000000000000000000000), + COEF_CONST(0.00000000000181898940354585650000000000000000000000), + COEF_CONST(0.00000000000090949470177292824000000000000000000000), + COEF_CONST(0.00000000000045474735088646412000000000000000000000), + COEF_CONST(0.00000000000022737367544323206000000000000000000000), + COEF_CONST(0.00000000000011368683772161603000000000000000000000), + COEF_CONST(0.00000000000005684341886080801500000000000000000000), + COEF_CONST(0.00000000000002842170943040400700000000000000000000), + COEF_CONST(0.00000000000001421085471520200400000000000000000000), + COEF_CONST(0.00000000000000710542735760100190000000000000000000), + COEF_CONST(0.00000000000000355271367880050090000000000000000000), + COEF_CONST(0.00000000000000177635683940025050000000000000000000), + COEF_CONST(0.00000000000000088817841970012523000000000000000000), + COEF_CONST(0.00000000000000044408920985006262000000000000000000), + COEF_CONST(0.00000000000000022204460492503131000000000000000000), + COEF_CONST(0.00000000000000011102230246251565000000000000000000), + COEF_CONST(0.00000000000000005551115123125782700000000000000000), + COEF_CONST(0.00000000000000002775557561562891400000000000000000), + COEF_CONST(0.00000000000000001387778780781445700000000000000000), + COEF_CONST(0.00000000000000000693889390390722840000000000000000), + COEF_CONST(0.00000000000000000346944695195361420000000000000000), + COEF_CONST(0.00000000000000000173472347597680710000000000000000), + COEF_CONST(0.00000000000000000086736173798840355000000000000000), + COEF_CONST(0.00000000000000000043368086899420177000000000000000), + COEF_CONST(0.00000000000000000021684043449710089000000000000000), + COEF_CONST(0.00000000000000000010842021724855044000000000000000), + COEF_CONST(0.00000000000000000005421010862427522200000000000000), + COEF_CONST(0.00000000000000000002710505431213761100000000000000), + COEF_CONST(0.00000000000000000001355252715606880500000000000000), + COEF_CONST(0.00000000000000000000677626357803440270000000000000), + COEF_CONST(0.00000000000000000000338813178901720140000000000000), + COEF_CONST(0.00000000000000000000169406589450860070000000000000), + COEF_CONST(0.00000000000000000000084703294725430034000000000000), + COEF_CONST(0.00000000000000000000042351647362715017000000000000), + COEF_CONST(0.00000000000000000000021175823681357508000000000000), + COEF_CONST(0.00000000000000000000010587911840678754000000000000), + COEF_CONST(0.00000000000000000000005293955920339377100000000000), + COEF_CONST(0.00000000000000000000002646977960169688600000000000), + COEF_CONST(0.00000000000000000000001323488980084844300000000000), + COEF_CONST(0.00000000000000000000000661744490042422140000000000), + COEF_CONST(0.00000000000000000000000330872245021211070000000000), + COEF_CONST(0.00000000000000000000000165436122510605530000000000), + COEF_CONST(0.00000000000000000000000082718061255302767000000000), + COEF_CONST(0.00000000000000000000000041359030627651384000000000), + COEF_CONST(0.00000000000000000000000020679515313825692000000000), + COEF_CONST(0.00000000000000000000000010339757656912846000000000), + COEF_CONST(0.00000000000000000000000005169878828456423000000000), + COEF_CONST(0.00000000000000000000000002584939414228211500000000), + COEF_CONST(0.00000000000000000000000001292469707114105700000000), + COEF_CONST(0.00000000000000000000000000646234853557052870000000), + COEF_CONST(0.00000000000000000000000000323117426778526440000000), + COEF_CONST(0.00000000000000000000000000161558713389263220000000), + COEF_CONST(0.00000000000000000000000000080779356694631609000000), + COEF_CONST(0.00000000000000000000000000040389678347315804000000), + COEF_CONST(0.00000000000000000000000000020194839173657902000000), + COEF_CONST(0.00000000000000000000000000010097419586828951000000), + COEF_CONST(0.00000000000000000000000000005048709793414475600000), + COEF_CONST(0.00000000000000000000000000002524354896707237800000), + COEF_CONST(0.00000000000000000000000000001262177448353618900000), + COEF_CONST(0.00000000000000000000000000000631088724176809440000), + COEF_CONST(0.00000000000000000000000000000315544362088404720000), + COEF_CONST(0.00000000000000000000000000000157772181044202360000), + COEF_CONST(0.00000000000000000000000000000078886090522101181000), + COEF_CONST(0.00000000000000000000000000000039443045261050590000), + COEF_CONST(0.00000000000000000000000000000019721522630525295000), + COEF_CONST(0.00000000000000000000000000000009860761315262647600), + COEF_CONST(0.00000000000000000000000000000004930380657631323800), + COEF_CONST(0.00000000000000000000000000000002465190328815661900), + COEF_CONST(0.00000000000000000000000000000001232595164407830900), + COEF_CONST(0.00000000000000000000000000000000616297582203915470), + COEF_CONST(0.00000000000000000000000000000000308148791101957740), + COEF_CONST(0.00000000000000000000000000000000154074395550978870), + COEF_CONST(0.00000000000000000000000000000000077037197775489434), + COEF_CONST(0.00000000000000000000000000000000038518598887744717), + COEF_CONST(0.00000000000000000000000000000000019259299443872359), + COEF_CONST(0.00000000000000000000000000000000009629649721936179), + COEF_CONST(0.00000000000000000000000000000000004814824860968090), + COEF_CONST(0.00000000000000000000000000000000002407412430484045), + COEF_CONST(0.00000000000000000000000000000000001203706215242022), + COEF_CONST(0.00000000000000000000000000000000000601853107621011), + COEF_CONST(0.00000000000000000000000000000000000300926553810506), + COEF_CONST(0.00000000000000000000000000000000000150463276905253), + COEF_CONST(0.00000000000000000000000000000000000075231638452626), + COEF_CONST(0.00000000000000000000000000000000000037615819226313), + COEF_CONST(0.00000000000000000000000000000000000018807909613157), + COEF_CONST(0.00000000000000000000000000000000000009403954806578), + COEF_CONST(0.00000000000000000000000000000000000004701977403289), + COEF_CONST(0.00000000000000000000000000000000000002350988701645), + COEF_CONST(0.00000000000000000000000000000000000001175494350822), + COEF_CONST(0.0 /* 0000000000000000000000000000000000000587747175411 "floating point underflow" */), + COEF_CONST(0.0) +}; + +#ifdef __cplusplus +} +#endif +#endif + +#endif diff --git a/lib/rbcodec/codecs/libfaad/iq_table.h b/lib/rbcodec/codecs/libfaad/iq_table.h new file mode 100644 index 0000000000..eaf2fe4671 --- /dev/null +++ b/lib/rbcodec/codecs/libfaad/iq_table.h @@ -0,0 +1,16455 @@ +/* +** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding +** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +** +** Any non-GPL usage of this software or parts of this software is strictly +** forbidden. +** +** Commercial non-GPL licensing of this software is possible. +** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** +** $Id$ +**/ + +#ifndef IQ_TABLE_H__ +#define IQ_TABLE_H__ + +#ifdef __cplusplus +extern "C" { +#endif + + +/* !!!DON'T CHANGE IQ_TABLE_SIZE!!! */ + + +#ifndef FIXED_POINT + +#define IQ_TABLE_SIZE 8192 + +#ifdef _MSC_VER +#pragma warning(disable:4305) +#pragma warning(disable:4244) +#endif + +static const real_t iq_table[IQ_TABLE_SIZE] MEM_ALIGN_ATTR = +{ + 0, + 1, + 2.5198420997897464, + 4.3267487109222245, + 6.3496042078727974, + 8.5498797333834844, + 10.902723556992836, + 13.390518279406722, + 15.999999999999998, + 18.720754407467133, + 21.544346900318832, + 24.463780996262464, + 27.47314182127996, + 30.567350940369842, + 33.741991698453212, + 36.993181114957046, + 40.317473596635935, + 43.711787041189993, + 47.173345095760126, + 50.699631325716943, + 54.288352331898118, + 57.937407704003519, + 61.6448652744185, + 65.408940536585988, + 69.227979374755591, + 73.100443455321638, + 77.024897778591622, + 80.999999999999986, + 85.024491212518527, + 89.097187944889555, + 93.216975178615741, + 97.382800224133163, + 101.59366732596474, + 105.84863288986224, + 110.14680124343441, + 114.4873208566006, + 118.86938096020653, + 123.29220851090024, + 127.75506545836058, + 132.25724627755247, + 136.79807573413572, + 141.37690685569191, + 145.99311908523086, + 150.6461165966291, + 155.33532675434674, + 160.06019870205279, + 164.82020206673349, + 169.61482576651861, + 174.44357691188537, + 179.30597979112557, + 184.20157493201927, + 189.12991823257562, + 194.09058015449685, + 199.08314497371677, + 204.1072100829694, + 209.16238534187647, + 214.24829247050752, + 219.36456448277784, + 224.51084515641216, + 229.6867885365223, + 234.89205847013176, + 240.12632816923249, + 245.38927980018505, + 250.68060409747261, + 255.99999999999991, + 261.34717430828869, + 266.72184136106449, + 272.12372272986045, + 277.55254693037961, + 283.0080491494619, + 288.48997098659891, + 293.99806020902247, + 299.53207051947408, + 305.0917613358298, + 310.67689758182206, + 316.28724948815585, + 321.92259240337177, + 327.58270661385535, + 333.26737717243742, + 338.97639373507025, + 344.70955040510125, + 350.46664558470013, + 356.24748183302603, + 362.05186573075139, + 367.87960775058258, + 373.73052213344511, + 379.60442677002078, + 385.50114308734607, + 391.42049594019937, + 397.36231350702371, + 403.32642719014467, + 409.31267152006262, + 415.32088406360799, + 421.35090533576471, + 427.40257871497619, + 433.4757503617617, + 439.5702691404793, + 445.68598654408271, + 451.82275662172759, + 457.98043590909128, + 464.15888336127773, + 470.35796028818726, + 476.5775302922363, + 482.81745920832043, + 489.07761504591741, + 495.35786793323581, + 501.65809006331688, + 507.97815564200368, + 514.31794083769648, + 520.67732373281672, + 527.05618427690604, + 533.45440424129174, + 539.87186717525128, + 546.30845836361505, + 552.76406478574609, + 559.23857507584194, + 565.73187948450413, + 572.24386984152341, + 578.77443951983378, + 585.32348340058843, + 591.89089783931263, + 598.47658063309257, + 605.08043098876044, + 611.70234949203643, + 618.3422380775919, + 624.99999999999977, + 631.67553980553748, + 638.36876330481164, + 645.07957754617485, + 651.80789078990415, + 658.55361248311499, + 665.31665323538357, + 672.09692479505225, + 678.8943400261943, + 685.70881288621433, + 692.540258404062, + 699.38859265903977, + 706.25373276018058, + 713.13559682617972, + 720.03410396586037, + 726.94917425915435, + 733.88072873858209, + 740.82868937121543, + 747.79297904110535, + 754.77352153216191, + 761.77024151147043, + 768.78306451302956, + 775.81191692189896, + 782.85672595874246, + 789.91741966475445, + 796.99392688695798, + 804.08617726386274, + 811.19410121147098, + 818.31762990962227, + 825.45669528866563, + 832.61123001644864, + 839.78116748561604, + 846.96644180120552, + 854.16698776853514, + 861.38274088137143, + 868.61363731036977, + 875.85961389178203, + 883.12060811641959, + 890.39655811886757, + 897.68740266694181, + 904.99308115138172, + 912.31353357577188, + 919.64870054668756, + 926.99852326405619, + 934.36294351172899, + 941.74190364825859, + 949.13534659787422, + 956.54321584165211, + 963.96545540887348, + 971.40200986856541, + 978.85282432122176, + 986.31784439069588, + 993.7970162162635, + 1001.29028644485, + 1008.797602223418, + 1016.3189111915103, + 1023.8541614739464, + 1031.4033016736653, + 1038.9662808647138, + 1046.5430485853758, + 1054.1335548314366, + 1061.7377500495838, + 1069.3555851309357, + 1076.9870114046978, + 1084.6319806319441, + 1092.2904449995174, + 1099.9623571140482, + 1107.6476699960892, + 1115.3463370743607, + 1123.058312180106, + 1130.7835495415541, + 1138.5220037784854, + 1146.273629896901, + 1154.0383832837879, + 1161.816219701986, + 1169.607095285146, + 1177.4109665327808, + 1185.2277903054078, + 1193.0575238197798, + 1200.9001246442001, + 1208.7555506939248, + 1216.6237602266442, + 1224.5047118380478, + 1232.3983644574657, + 1240.3046773435874, + 1248.2236100802568, + 1256.1551225723395, + 1264.099175041662, + 1272.0557280230228, + 1280.0247423602691, + 1288.0061792024444, + 1295.9999999999995, + 1304.006166501068, + 1312.0246407478062, + 1320.0553850727929, + 1328.0983620954903, + 1336.1535347187651, + 1344.2208661254647, + 1352.3003197750522, + 1360.3918594002962, + 1368.4954490040145, + 1376.6110528558709, + 1384.7386354892244, + 1392.8781616980295, + 1401.0295965337855, + 1409.1929053025353, + 1417.3680535619119, + 1425.5550071182327, + 1433.7537320236374, + 1441.9641945732744, + 1450.1863613025282, + 1458.4201989842913, + 1466.6656746262797, + 1474.9227554683875, + 1483.1914089800841, + 1491.4716028578516, + 1499.7633050226596, + 1508.0664836174794, + 1516.3811070048375, + 1524.7071437644029, + 1533.0445626906128, + 1541.3933327903342, + 1549.7534232805581, + 1558.1248035861302, + 1566.507443337515, + 1574.9013123685909, + 1583.3063807144795, + 1591.7226186094069, + 1600.1499964845941, + 1608.58848496618, + 1617.0380548731737, + 1625.4986772154357, + 1633.9703231916887, + 1642.4529641875577, + 1650.9465717736346, + 1659.4511177035752, + 1667.9665739122186, + 1676.4929125137353, + 1685.030105799801, + 1693.5781262377957, + 1702.136946469027, + 1710.7065393069795, + 1719.2868777355877, + 1727.8779349075323, + 1736.4796841425596, + 1745.092098925825, + 1753.7151529062583, + 1762.3488198949503, + 1770.9930738635628, + 1779.6478889427597, + 1788.3132394206564, + 1796.9890997412947, + 1805.6754445031333, + 1814.3722484575621, + 1823.0794865074322, + 1831.7971337056094, + 1840.5251652535437, + 1849.2635564998579, + 1858.0122829389563, + 1866.7713202096493, + 1875.5406440937966, + 1884.3202305149687, + 1893.110055537124, + 1901.9100953633042, + 1910.7203263343454, + 1919.5407249276057, + 1928.3712677557098, + 1937.2119315653083, + 1946.0626932358525, + 1954.923529778386, + 1963.79441833435, + 1972.6753361744036, + 1981.5662606972594, + 1990.467169428533, + 1999.3780400196069, + 2008.2988502465078, + 2017.2295780087982, + 2026.1702013284819, + 2035.1206983489212, + 2044.0810473337688, + 2053.0512266659125, + 2062.0312148464309, + 2071.0209904935646, + 2080.0205323416958, + 2089.0298192403443, + 2098.0488301531714, + 2107.0775441569995, + 2116.115940440839, + 2125.1639983049317, + 2134.2216971597995, + 2143.2890165253098, + 2152.3659360297484, + 2161.4524354089031, + 2170.5484945051617, + 2179.6540932666144, + 2188.7692117461711, + 2197.8938301006888, + 2207.0279285901042, + 2216.1714875765838, + 2225.324487523676, + 2234.4869089954782, + 2243.6587326558101, + 2252.8399392673982, + 2262.0305096910702, + 2271.2304248849537, + 2280.4396659036897, + 2289.6582138976523, + 2298.8860501121762, + 2308.1231558867926, + 2317.3695126544767, + 2326.6251019409005, + 2335.8899053636933, + 2345.1639046317132, + 2354.4470815443233, + 2363.7394179906792, + 2373.0408959490205, + 2382.3514974859731, + 2391.6712047558558, + 2400.9999999999991, + 2410.3378655460651, + 2419.6847838073813, + 2429.0407372822747, + 2438.4057085534191, + 2447.7796802871858, + 2457.1626352330004, + 2466.5545562227112, + 2475.9554261699564, + 2485.3652280695474, + 2494.7839449968492, + 2504.2115601071737, + 2513.6480566351788, + 2523.0934178942675, + 2532.5476272760025, + 2542.0106682495189, + 2551.482524360948, + 2560.9631792328441, + 2570.4526165636184, + 2579.9508201269791, + 2589.4577737713744, + 2598.9734614194458, + 2608.4978670674823, + 2618.0309747848837, + 2627.5727687136259, + 2637.1232330677353, + 2646.6823521327647, + 2656.2501102652768, + 2665.8264918923328, + 2675.4114815109842, + 2685.0050636877722, + 2694.6072230582295, + 2704.2179443263894, + 2713.8372122642972, + 2723.4650117115279, + 2733.1013275747096, + 2742.7461448270483, + 2752.3994485078601, + 2762.0612237221085, + 2771.7314556399419, + 2781.4101294962406, + 2791.0972305901655, + 2800.7927442847094, + 2810.4966560062589, + 2820.2089512441521, + 2829.9296155502466, + 2839.6586345384894, + 2849.3959938844923, + 2859.1416793251065, + 2868.8956766580086, + 2878.6579717412847, + 2888.4285504930212, + 2898.2073988908974, + 2907.9945029717837, + 2917.789848831344, + 2927.5934226236377, + 2937.4052105607311, + 2947.2251989123079, + 2957.0533740052865, + 2966.8897222234368, + 2976.734230007005, + 2986.5868838523397, + 2996.4476703115197, + 3006.3165759919889, + 3016.1935875561908, + 3026.0786917212095, + 3035.9718752584108, + 3045.8731249930906, + 3055.7824278041207, + 3065.6997706236039, + 3075.625140436528, + 3085.5585242804245, + 3095.4999092450298, + 3105.4492824719491, + 3115.4066311543256, + 3125.3719425365089, + 3135.3452039137287, + 3145.3264026317715, + 3155.3155260866592, + 3165.3125617243295, + 3175.3174970403229, + 3185.3303195794679, + 3195.35101693557, + 3205.3795767511078, + 3215.4159867169251, + 3225.460234571929, + 3235.5123081027928, + 3245.5721951436558, + 3255.63988357583, + 3265.7153613275095, + 3275.7986163734795, + 3285.8896367348289, + 3295.9884104786665, + 3306.0949257178395, + 3316.2091706106517, + 3326.331133360588, + 3336.4608022160378, + 3346.5981654700231, + 3356.7432114599264, + 3366.8959285672249, + 3377.0563052172211, + 3387.2243298787821, + 3397.3999910640764, + 3407.5832773283128, + 3417.7741772694862, + 3427.9726795281199, + 3438.1787727870123, + 3448.3924457709873, + 3458.6136872466445, + 3468.8424860221107, + 3479.0788309467976, + 3489.3227109111554, + 3499.5741148464344, + 3509.8330317244445, + 3520.0994505573185, + 3530.3733603972751, + 3540.6547503363886, + 3550.9436095063534, + 3561.239927078258, + 3571.5436922623535, + 3581.8548943078308, + 3592.1735225025936, + 3602.4995661730372, + 3612.8330146838275, + 3623.1738574376814, + 3633.5220838751502, + 3643.8776834744031, + 3654.2406457510142, + 3664.6109602577494, + 3674.9886165843564, + 3685.3736043573545, + 3695.7659132398294, + 3706.1655329312248, + 3716.5724531671399, + 3726.9866637191262, + 3737.4081543944876, + 3747.8369150360782, + 3758.2729355221072, + 3768.7162057659411, + 3779.1667157159077, + 3789.6244553551055, + 3800.0894147012082, + 3810.5615838062768, + 3821.0409527565694, + 3831.5275116723533, + 3842.0212507077194, + 3852.522160050396, + 3863.0302299215673, + 3873.5454505756893, + 3884.0678123003108, + 3894.5973054158922, + 3905.1339202756285, + 3915.6776472652732, + 3926.2284768029604, + 3936.7863993390338, + 3947.3514053558706, + 3957.9234853677135, + 3968.5026299204969, + 3979.0888295916798, + 3989.6820749900776, + 4000.2823567556948, + 4010.8896655595613, + 4021.5039921035655, + 4032.1253271202945, + 4042.7536613728694, + 4053.3889856547858, + 4064.0312907897551, + 4074.6805676315448, + 4085.3368070638221, + 4095.9999999999982, + 4106.6701373830711, + 4117.347210185475, + 4128.0312094089259, + 4138.722126084268, + 4149.4199512713267, + 4160.1246760587583, + 4170.8362915638982, + 4181.5547889326181, + 4192.2801593391769, + 4203.0123939860741, + 4213.7514841039101, + 4224.4974209512384, + 4235.2501958144258, + 4246.0098000075095, + 4256.7762248720574, + 4267.549461777031, + 4278.3295021186423, + 4289.1163373202198, + 4299.9099588320714, + 4310.7103581313495, + 4321.5175267219138, + 4332.3314561342004, + 4343.152137925088, + 4353.9795636777671, + 4364.8137250016052, + 4375.6546135320223, + 4386.5022209303588, + 4397.3565388837469, + 4408.2175591049827, + 4419.0852733324018, + 4429.9596733297531, + 4440.8407508860728, + 4451.7284978155603, + 4462.6229059574571, + 4473.5239671759227, + 4484.4316733599126, + 4495.3460164230582, + 4506.2669883035496, + 4517.1945809640119, + 4528.1287863913894, + 4539.069596596828, + 4550.0170036155587, + 4560.9709995067806, + 4571.931576353546, + 4582.898726262647, + 4593.8724413645004, + 4604.8527138130348, + 4615.8395357855816, + 4626.8328994827571, + 4637.8327971283588, + 4648.8392209692511, + 4659.8521632752563, + 4670.8716163390473, + 4681.8975724760394, + 4692.9300240242837, + 4703.9689633443595, + 4715.0143828192668, + 4726.0662748543255, + 4737.1246318770682, + 4748.1894463371373, + 4759.2607107061804, + 4770.3384174777493, + 4781.4225591671993, + 4792.5131283115852, + 4803.6101174695614, + 4814.7135192212854, + 4825.8233261683154, + 4836.9395309335096, + 4848.0621261609349, + 4859.1911045157631, + 4870.3264586841779, + 4881.4681813732768, + 4892.6162653109768, + 4903.7707032459193, + 4914.931487947375, + 4926.0986122051509, + 4937.2720688294967, + 4948.4518506510112, + 4959.637950520555, + 4970.8303613091521, + 4982.0290759079044, + 4993.2340872278974, + 5004.4453882001153, + 5015.6629717753467, + 5026.8868309241007, + 5038.1169586365131, + 5049.353347922266, + 5060.5959918104927, + 5071.8448833496996, + 5083.1000156076734, + 5094.3613816713996, + 5105.6289746469747, + 5116.9027876595246, + 5128.18281385312, + 5139.4690463906918, + 5150.7614784539473, + 5162.0601032432933, + 5173.3649139777472, + 5184.6759038948594, + 5195.9930662506322, + 5207.3163943194386, + 5218.6458813939435, + 5229.9815207850224, + 5241.3233058216847, + 5252.6712298509919, + 5264.025286237983, + 5275.3854683655954, + 5286.7517696345885, + 5298.1241834634639, + 5309.5027032883945, + 5320.887322563146, + 5332.2780347589978, + 5343.6748333646756, + 5355.0777118862716, + 5366.4866638471722, + 5377.901682787985, + 5389.3227622664635, + 5400.749895857437, + 5412.1830771527357, + 5423.622299761123, + 5435.067557308219, + 5446.5188434364318, + 5457.9761518048872, + 5469.4394760893592, + 5480.9088099821975, + 5492.3841471922606, + 5503.8654814448455, + 5515.3528064816201, + 5526.846116060552, + 5538.3454039558474, + 5549.8506639578736, + 5561.3618898731029, + 5572.8790755240361, + 5584.4022147491451, + 5595.9313014027975, + 5607.4663293552012, + 5619.0072924923297, + 5630.5541847158656, + 5642.1069999431284, + 5653.665732107017, + 5665.230375155943, + 5676.8009230537655, + 5688.3773697797333, + 5699.9597093284156, + 5711.5479357096474, + 5723.1420429484588, + 5734.7420250850209, + 5746.347876174581, + 5757.9595902874016, + 5769.5771615087006, + 5781.2005839385911, + 5792.8298516920213, + 5804.4649588987149, + 5816.1058997031105, + 5827.7526682643065, + 5839.4052587559972, + 5851.0636653664196, + 5862.7278822982908, + 5874.3979037687541, + 5886.0737240093204, + 5897.7553372658094, + 5909.4427377982956, + 5921.1359198810505, + 5932.8348778024874, + 5944.5396058651031, + 5956.2500983854261, + 5967.9663496939575, + 5979.6883541351208, + 5991.4161060672022, + 6003.1495998623004, + 6014.8888299062692, + 6026.6337905986684, + 6038.3844763527022, + 6050.1408815951781, + 6061.9030007664414, + 6073.6708283203316, + 6085.4443587241267, + 6097.2235864584891, + 6109.0085060174197, + 6120.7991119081998, + 6132.595398651345, + 6144.3973607805519, + 6156.2049928426459, + 6168.0182893975361, + 6179.8372450181578, + 6191.6618542904307, + 6203.4921118132024, + 6215.3280121982016, + 6227.1695500699925, + 6239.0167200659189, + 6250.8695168360628, + 6262.7279350431891, + 6274.5919693627056, + 6286.4616144826068, + 6298.3368651034316, + 6310.2177159382172, + 6322.1041617124456, + 6333.9961971640032, + 6345.8938170431311, + 6357.7970161123785, + 6369.7057891465583, + 6381.6201309327007, + 6393.5400362700075, + 6405.4654999698032, + 6417.3965168554978, + 6429.3330817625329, + 6441.2751895383453, + 6453.2228350423138, + 6465.176013145724, + 6477.134718731716, + 6489.0989466952469, + 6501.0686919430445, + 6513.0439493935628, + 6525.0247139769417, + 6537.010980634961, + 6549.002744321001, + 6560.9999999999973, + 6573.0027426483985, + 6585.0109672541284, + 6597.0246688165371, + 6609.0438423463656, + 6621.0684828657004, + 6633.0985854079354, + 6645.134145017727, + 6657.1751567509573, + 6669.2216156746908, + 6681.2735168671343, + 6693.3308554176001, + 6705.3936264264594, + 6717.461825005108, + 6729.535446275926, + 6741.6144853722335, + 6753.6989374382601, + 6765.7887976290967, + 6777.8840611106634, + 6789.9847230596661, + 6802.0907786635626, + 6814.2022231205201, + 6826.3190516393797, + 6838.4412594396181, + 6850.5688417513074, + 6862.701793815083, + 6874.840110882099, + 6886.9837882139991, + 6899.1328210828724, + 6911.2872047712199, + 6923.4469345719199, + 6935.6120057881863, + 6947.7824137335365, + 6959.9581537317536, + 6972.1392211168532, + 6984.3256112330409, + 6996.5173194346862, + 7008.7143410862773, + 7020.9166715623942, + 7033.1243062476678, + 7045.3372405367481, + 7057.5554698342685, + 7069.7789895548103, + 7082.0077951228714, + 7094.2418819728273, + 7106.4812455489018, + 7118.7258813051285, + 7130.9757847053224, + 7143.2309512230404, + 7155.4913763415516, + 7167.7570555538041, + 7180.0279843623894, + 7192.3041582795131, + 7204.5855728269571, + 7216.8722235360519, + 7229.1641059476406, + 7241.4612156120484, + 7253.7635480890503, + 7266.0710989478375, + 7278.3838637669869, + 7290.7018381344296, + 7303.0250176474174, + 7315.3533979124932, + 7327.6869745454596, + 7340.0257431713462, + 7352.3696994243801, + 7364.7188389479543, + 7377.0731573945968, + 7389.4326504259407, + 7401.7973137126937, + 7414.1671429346061, + 7426.5421337804428, + 7438.922281947951, + 7451.3075831438346, + 7463.6980330837177, + 7476.0936274921214, + 7488.4943621024304, + 7500.9002326568652, + 7513.3112349064522, + 7525.7273646109943, + 7538.1486175390446, + 7550.5749894678729, + 7563.0064761834419, + 7575.4430734803736, + 7587.8847771619248, + 7600.3315830399597, + 7612.7834869349153, + 7625.24048467578, + 7637.7025721000637, + 7650.1697450537677, + 7662.6419993913596, + 7675.1193309757446, + 7687.6017356782404, + 7700.0892093785433, + 7712.5817479647112, + 7725.079347333125, + 7737.5820033884729, + 7750.0897120437139, + 7762.6024692200581, + 7775.1202708469355, + 7787.6431128619733, + 7800.1709912109645, + 7812.7039018478481, + 7825.2418407346768, + 7837.7848038415968, + 7850.3327871468155, + 7862.8857866365806, + 7875.4437983051539, + 7888.006818154784, + 7900.5748421956796, + 7913.1478664459901, + 7925.725886931772, + 7938.3088996869719, + 7950.8969007533951, + 7963.4898861806851, + 7976.0878520262959, + 7988.6907943554688, + 8001.2987092412086, + 8013.911592764257, + 8026.5294410130691, + 8039.1522500837891, + 8051.7800160802271, + 8064.412735113835, + 8077.0504033036796, + 8089.6930167764222, + 8102.3405716662946, + 8114.9930641150731, + 8127.6504902720571, + 8140.3128462940449, + 8152.9801283453098, + 8165.6523325975786, + 8178.3294552300049, + 8191.0114924291529, + 8203.6984403889655, + 8216.3902953107463, + 8229.0870534031419, + 8241.7887108821069, + 8254.4952639708936, + 8267.2067089000211, + 8279.9230419072574, + 8292.6442592375952, + 8305.3703571432306, + 8318.101331883543, + 8330.8371797250657, + 8343.577896941475, + 8356.3234798135582, + 8369.0739246291978, + 8381.8292276833508, + 8394.5893852780209, + 8407.3543937222421, + 8420.1242493320569, + 8432.8989484304948, + 8445.6784873475499, + 8458.4628624201578, + 8471.2520699921806, + 8484.0461064143838, + 8496.8449680444082, + 8509.6486512467636, + 8522.4571523927953, + 8535.270467860666, + 8548.0885940353437, + 8560.9115273085663, + 8573.7392640788403, + 8586.5718007514006, + 8599.4091337382069, + 8612.2512594579148, + 8625.0981743358552, + 8637.9498748040205, + 8650.8063573010386, + 8663.6676182721567, + 8676.533654169225, + 8689.4044614506638, + 8702.2800365814601, + 8715.1603760331418, + 8728.0454762837508, + 8740.9353338178389, + 8753.8299451264356, + 8766.7293067070332, + 8779.6334150635721, + 8792.5422667064158, + 8805.4558581523324, + 8818.3741859244819, + 8831.2972465523908, + 8844.2250365719356, + 8857.1575525253265, + 8870.0947909610859, + 8883.0367484340295, + 8895.9834215052524, + 8908.934806742107, + 8921.8909007181846, + 8934.8517000132997, + 8947.817201213471, + 8960.7874009109, + 8973.7622957039603, + 8986.7418821971733, + 8999.7261570011924, + 9012.7151167327884, + 9025.7087580148236, + 9038.7070774762469, + 9051.7100717520643, + 9064.7177374833282, + 9077.7300713171153, + 9090.7470699065179, + 9103.7687299106146, + 9116.7950479944648, + 9129.8260208290812, + 9142.8616450914233, + 9155.9019174643727, + 9168.9468346367157, + 9181.9963933031358, + 9195.0505901641845, + 9208.1094219262741, + 9221.1728853016557, + 9234.240977008405, + 9247.3136937704076, + 9260.3910323173386, + 9273.472989384647, + 9286.5595617135423, + 9299.6507460509747, + 9312.7465391496207, + 9325.8469377678684, + 9338.9519386698012, + 9352.0615386251757, + 9365.1757344094131, + 9378.2945228035842, + 9391.4179005943843, + 9404.5458645741273, + 9417.6784115407263, + 9430.8155382976747, + 9443.9572416540359, + 9457.1035184244265, + 9470.2543654290002, + 9483.4097794934296, + 9496.5697574488931, + 9509.7342961320664, + 9522.9033923850911, + 9536.0770430555804, + 9549.2552449965824, + 9562.4379950665825, + 9575.6252901294793, + 9588.8171270545736, + 9602.0135027165488, + 9615.2144139954635, + 9628.4198577767274, + 9641.629830951093, + 9654.844330414644, + 9668.0633530687719, + 9681.286895820167, + 9694.5149555808002, + 9707.7475292679192, + 9720.9846138040157, + 9734.2262061168276, + 9747.4723031393187, + 9760.7229018096641, + 9773.9779990712323, + 9787.2375918725811, + 9800.5016771674327, + 9813.7702519146696, + 9827.0433130783094, + 9840.3208576275028, + 9853.602882536512, + 9866.8893847846994, + 9880.1803613565116, + 9893.4758092414686, + 9906.7757254341523, + 9920.0801069341851, + 9933.3889507462245, + 9946.7022538799429, + 9960.0200133500221, + 9973.3422261761298, + 9986.6688893829159, + 9999.9999999999945, + 10013.335555061929, + 10026.675551608221, + 10040.019986683301, + 10053.368857336509, + 10066.722160622081, + 10080.079893599144, + 10093.442053331697, + 10106.808636888598, + 10120.179641343551, + 10133.555063775095, + 10146.934901266595, + 10160.31915090622, + 10173.707809786936, + 10187.100875006496, + 10200.498343667417, + 10213.900212876984, + 10227.306479747222, + 10240.717141394889, + 10254.132194941467, + 10267.551637513146, + 10280.975466240814, + 10294.40367826004, + 10307.836270711066, + 10321.273240738796, + 10334.71458549278, + 10348.160302127204, + 10361.610387800878, + 10375.064839677221, + 10388.523654924258, + 10401.986830714593, + 10415.454364225412, + 10428.926252638465, + 10442.402493140049, + 10455.883082921007, + 10469.368019176709, + 10482.85729910704, + 10496.350919916393, + 10509.848878813653, + 10523.351173012188, + 10536.857799729838, + 10550.3687561889, + 10563.884039616123, + 10577.403647242685, + 10590.927576304197, + 10604.455824040679, + 10617.988387696556, + 10631.525264520642, + 10645.066451766135, + 10658.611946690598, + 10672.161746555956, + 10685.715848628475, + 10699.274250178762, + 10712.836948481747, + 10726.403940816675, + 10739.975224467091, + 10753.550796720834, + 10767.130654870027, + 10780.714796211059, + 10794.303218044579, + 10807.895917675487, + 10821.492892412922, + 10835.094139570248, + 10848.699656465047, + 10862.309440419107, + 10875.923488758415, + 10889.541798813138, + 10903.16436791762, + 10916.791193410372, + 10930.422272634056, + 10944.05760293548, + 10957.697181665582, + 10971.341006179427, + 10984.98907383619, + 10998.641381999149, + 11012.297928035676, + 11025.958709317223, + 11039.623723219316, + 11053.292967121541, + 11066.966438407539, + 11080.64413446499, + 11094.326052685608, + 11108.012190465128, + 11121.702545203296, + 11135.397114303863, + 11149.095895174571, + 11162.798885227143, + 11176.506081877278, + 11190.217482544635, + 11203.933084652828, + 11217.652885629415, + 11231.376882905886, + 11245.105073917659, + 11258.837456104062, + 11272.574026908333, + 11286.314783777601, + 11300.059724162888, + 11313.808845519083, + 11327.562145304952, + 11341.319620983111, + 11355.081270020033, + 11368.847089886023, + 11382.617078055218, + 11396.391232005579, + 11410.169549218874, + 11423.952027180676, + 11437.738663380349, + 11451.529455311042, + 11465.324400469679, + 11479.123496356951, + 11492.926740477304, + 11506.734130338931, + 11520.545663453764, + 11534.361337337466, + 11548.181149509423, + 11562.005097492724, + 11575.83317881417, + 11589.665391004253, + 11603.501731597149, + 11617.342198130715, + 11631.186788146468, + 11645.035499189589, + 11658.888328808911, + 11672.745274556904, + 11686.606333989675, + 11700.471504666955, + 11714.340784152086, + 11728.214170012021, + 11742.091659817312, + 11755.973251142101, + 11769.858941564111, + 11783.748728664636, + 11797.642610028539, + 11811.540583244237, + 11825.442645903697, + 11839.34879560242, + 11853.259029939445, + 11867.173346517333, + 11881.091742942155, + 11895.014216823492, + 11908.940765774427, + 11922.871387411526, + 11936.806079354839, + 11950.744839227897, + 11964.687664657684, + 11978.634553274653, + 11992.585502712702, + 12006.540510609168, + 12020.499574604828, + 12034.462692343877, + 12048.429861473938, + 12062.401079646032, + 12076.376344514589, + 12090.355653737433, + 12104.339004975769, + 12118.326395894188, + 12132.317824160644, + 12146.313287446457, + 12160.312783426305, + 12174.316309778205, + 12188.323864183525, + 12202.335444326955, + 12216.351047896511, + 12230.370672583531, + 12244.394316082657, + 12258.421976091831, + 12272.453650312296, + 12286.489336448574, + 12300.529032208471, + 12314.572735303058, + 12328.620443446678, + 12342.672154356922, + 12356.727865754638, + 12370.787575363909, + 12384.851280912055, + 12398.918980129623, + 12412.990670750381, + 12427.066350511306, + 12441.146017152583, + 12455.229668417589, + 12469.317302052901, + 12483.40891580827, + 12497.50450743663, + 12511.604074694078, + 12525.707615339878, + 12539.815127136444, + 12553.926607849342, + 12568.042055247275, + 12582.161467102082, + 12596.284841188726, + 12610.41217528529, + 12624.543467172971, + 12638.678714636069, + 12652.817915461985, + 12666.961067441209, + 12681.108168367316, + 12695.259216036962, + 12709.414208249869, + 12723.573142808827, + 12737.736017519681, + 12751.902830191326, + 12766.073578635704, + 12780.248260667788, + 12794.426874105588, + 12808.609416770132, + 12822.795886485468, + 12836.986281078653, + 12851.180598379744, + 12865.378836221802, + 12879.580992440871, + 12893.787064875984, + 12907.997051369144, + 12922.210949765335, + 12936.428757912496, + 12950.650473661524, + 12964.876094866273, + 12979.105619383534, + 12993.339045073039, + 13007.576369797454, + 13021.817591422368, + 13036.062707816285, + 13050.311716850629, + 13064.564616399723, + 13078.821404340792, + 13093.082078553954, + 13107.346636922217, + 13121.615077331464, + 13135.887397670458, + 13150.163595830827, + 13164.44366970706, + 13178.727617196502, + 13193.015436199352, + 13207.307124618648, + 13221.602680360265, + 13235.902101332911, + 13250.205385448118, + 13264.512530620239, + 13278.823534766434, + 13293.138395806676, + 13307.457111663734, + 13321.779680263176, + 13336.106099533356, + 13350.436367405409, + 13364.77048181325, + 13379.108440693562, + 13393.450241985796, + 13407.795883632158, + 13422.145363577607, + 13436.498679769853, + 13450.855830159346, + 13465.216812699266, + 13479.581625345529, + 13493.950266056772, + 13508.32273279435, + 13522.699023522329, + 13537.079136207483, + 13551.463068819286, + 13565.850819329906, + 13580.2423857142, + 13594.63776594971, + 13609.036958016657, + 13623.439959897927, + 13637.846769579081, + 13652.257385048335, + 13666.67180429656, + 13681.090025317284, + 13695.512046106669, + 13709.937864663521, + 13724.367478989278, + 13738.800887088004, + 13753.238086966385, + 13767.679076633727, + 13782.123854101939, + 13796.572417385545, + 13811.024764501659, + 13825.480893469998, + 13839.94080231286, + 13854.404489055134, + 13868.871951724283, + 13883.34318835034, + 13897.818196965914, + 13912.296975606168, + 13926.779522308825, + 13941.26583511416, + 13955.755912064991, + 13970.249751206682, + 13984.747350587126, + 13999.248708256751, + 14013.753822268511, + 14028.262690677873, + 14042.775311542828, + 14057.291682923867, + 14071.811802883994, + 14086.335669488704, + 14100.863280805994, + 14115.394634906341, + 14129.92972986271, + 14144.468563750548, + 14159.01113464777, + 14173.55744063476, + 14188.107479794369, + 14202.661250211901, + 14217.218749975118, + 14231.779977174227, + 14246.344929901879, + 14260.913606253163, + 14275.486004325601, + 14290.062122219146, + 14304.641958036171, + 14319.225509881464, + 14333.812775862236, + 14348.403754088098, + 14362.998442671067, + 14377.59683972556, + 14392.198943368388, + 14406.804751718748, + 14421.414262898223, + 14436.027475030774, + 14450.64438624274, + 14465.264994662828, + 14479.889298422106, + 14494.517295654005, + 14509.148984494313, + 14523.784363081166, + 14538.423429555049, + 14553.066182058781, + 14567.712618737527, + 14582.362737738777, + 14597.016537212348, + 14611.674015310382, + 14626.33517018734, + 14640.999999999993, + 14655.668502907418, + 14670.340677071003, + 14685.016520654426, + 14699.696031823671, + 14714.379208746999, + 14729.066049594967, + 14743.756552540408, + 14758.45071575843, + 14773.148537426418, + 14787.850015724018, + 14802.555148833142, + 14817.263934937961, + 14831.976372224897, + 14846.692458882624, + 14861.41219310206, + 14876.135573076363, + 14890.862597000923, + 14905.593263073371, + 14920.327569493558, + 14935.065514463557, + 14949.807096187662, + 14964.552312872382, + 14979.301162726431, + 14994.053643960735, + 15008.809754788414, + 15023.569493424788, + 15038.332858087369, + 15053.099846995858, + 15067.870458372134, + 15082.644690440264, + 15097.422541426484, + 15112.204009559202, + 15126.989093068994, + 15141.777790188597, + 15156.570099152905, + 15171.366018198967, + 15186.165545565986, + 15200.968679495301, + 15215.775418230402, + 15230.585760016909, + 15245.399703102579, + 15260.217245737298, + 15275.038386173073, + 15289.863122664035, + 15304.691453466432, + 15319.523376838621, + 15334.358891041069, + 15349.197994336346, + 15364.040684989128, + 15378.886961266177, + 15393.736821436356, + 15408.590263770609, + 15423.447286541972, + 15438.307888025554, + 15453.172066498542, + 15468.039820240196, + 15482.91114753184, + 15497.786046656869, + 15512.664515900733, + 15527.546553550939, + 15542.432157897045, + 15557.32132723066, + 15572.214059845435, + 15587.110354037064, + 15602.010208103273, + 15616.913620343823, + 15631.820589060506, + 15646.731112557136, + 15661.645189139546, + 15676.562817115593, + 15691.483994795139, + 15706.408720490062, + 15721.336992514242, + 15736.268809183561, + 15751.204168815901, + 15766.143069731135, + 15781.085510251132, + 15796.03148869974, + 15810.981003402798, + 15825.934052688119, + 15840.890634885489, + 15855.850748326673, + 15870.814391345401, + 15885.781562277361, + 15900.752259460214, + 15915.726481233565, + 15930.704225938984, + 15945.685491919978, + 15960.670277522009, + 15975.658581092481, + 15990.65040098073, + 16005.645735538035, + 16020.644583117599, + 16035.646942074556, + 16050.652810765967, + 16065.662187550806, + 16080.675070789974, + 16095.691458846273, + 16110.711350084424, + 16125.734742871053, + 16140.761635574685, + 16155.792026565747, + 16170.825914216561, + 16185.863296901338, + 16200.904172996183, + 16215.948540879079, + 16230.996398929899, + 16246.047745530386, + 16261.102579064163, + 16276.160897916721, + 16291.22270047542, + 16306.287985129484, + 16321.356750269995, + 16336.428994289896, + 16351.504715583982, + 16366.5839125489, + 16381.666583583141, + 16396.752727087041, + 16411.842341462776, + 16426.935425114363, + 16442.031976447644, + 16457.131993870298, + 16472.235475791829, + 16487.342420623561, + 16502.452826778641, + 16517.566692672033, + 16532.684016720516, + 16547.804797342676, + 16562.929032958902, + 16578.056721991394, + 16593.18786286415, + 16608.322454002962, + 16623.460493835417, + 16638.601980790896, + 16653.746913300558, + 16668.895289797354, + 16684.047108716015, + 16699.202368493046, + 16714.361067566726, + 16729.523204377107, + 16744.688777366009, + 16759.857784977012, + 16775.030225655464, + 16790.206097848466, + 16805.385400004874, + 16820.568130575302, + 16835.754288012104, + 16850.943870769381, + 16866.136877302983, + 16881.333306070494, + 16896.53315553123, + 16911.736424146249, + 16926.943110378332, + 16942.153212691992, + 16957.366729553454, + 16972.583659430682, + 16987.804000793338, + 17003.027752112816, + 17018.254911862205, + 17033.485478516312, + 17048.719450551645, + 17063.956826446421, + 17079.197604680547, + 17094.44178373563, + 17109.689362094967, + 17124.940338243552, + 17140.194710668064, + 17155.452477856852, + 17170.713638299967, + 17185.978190489128, + 17201.246132917724, + 17216.517464080825, + 17231.792182475165, + 17247.070286599141, + 17262.351774952826, + 17277.636646037936, + 17292.924898357855, + 17308.216530417623, + 17323.511540723921, + 17338.809927785089, + 17354.111690111105, + 17369.416826213594, + 17384.725334605821, + 17400.037213802683, + 17415.352462320716, + 17430.67107867809, + 17445.993061394587, + 17461.318408991636, + 17476.647119992274, + 17491.979192921168, + 17507.314626304586, + 17522.653418670423, + 17537.995568548187, + 17553.341074468986, + 17568.689934965536, + 17584.042148572156, + 17599.397713824768, + 17614.75662926089, + 17630.118893419625, + 17645.484504841683, + 17660.853462069354, + 17676.225763646511, + 17691.601408118619, + 17706.980394032718, + 17722.362719937424, + 17737.748384382936, + 17753.137385921014, + 17768.529723104999, + 17783.92539448979, + 17799.324398631856, + 17814.726734089225, + 17830.13239942148, + 17845.541393189767, + 17860.95371395678, + 17876.369360286772, + 17891.788330745527, + 17907.210623900395, + 17922.636238320254, + 17938.065172575527, + 17953.497425238176, + 17968.932994881692, + 17984.371880081104, + 17999.814079412972, + 18015.259591455371, + 18030.708414787914, + 18046.160547991731, + 18061.615989649465, + 18077.074738345284, + 18092.536792664861, + 18108.002151195393, + 18123.470812525571, + 18138.942775245599, + 18154.418037947191, + 18169.896599223546, + 18185.37845766938, + 18200.863611880886, + 18216.352060455767, + 18231.843801993204, + 18247.338835093873, + 18262.837158359936, + 18278.338770395032, + 18293.84366980429, + 18309.351855194309, + 18324.863325173166, + 18340.378078350412, + 18355.896113337069, + 18371.417428745623, + 18386.942023190033, + 18402.469895285718, + 18418.00104364955, + 18433.53546689987, + 18449.073163656474, + 18464.614132540602, + 18480.158372174956, + 18495.705881183676, + 18511.256658192357, + 18526.810701828035, + 18542.368010719183, + 18557.928583495715, + 18573.492418788985, + 18589.059515231773, + 18604.629871458303, + 18620.203486104212, + 18635.78035780658, + 18651.360485203899, + 18666.943866936086, + 18682.53050164448, + 18698.120387971841, + 18713.713524562332, + 18729.30991006154, + 18744.909543116457, + 18760.512422375479, + 18776.118546488418, + 18791.727914106479, + 18807.340523882274, + 18822.95637446981, + 18838.575464524489, + 18854.197792703111, + 18869.823357663863, + 18885.452158066328, + 18901.08419257147, + 18916.719459841639, + 18932.357958540564, + 18947.999687333362, + 18963.644644886521, + 18979.292829867907, + 18994.944240946759, + 19010.598876793687, + 19026.256736080668, + 19041.917817481048, + 19057.582119669532, + 19073.2496413222, + 19088.920381116473, + 19104.594337731145, + 19120.271509846356, + 19135.951896143604, + 19151.635495305738, + 19167.322306016948, + 19183.012326962784, + 19198.705556830122, + 19214.401994307198, + 19230.101638083579, + 19245.804486850167, + 19261.510539299208, + 19277.219794124274, + 19292.932250020265, + 19308.647905683421, + 19324.366759811302, + 19340.088811102793, + 19355.8140582581, + 19371.542499978754, + 19387.2741349676, + 19403.008961928797, + 19418.746979567823, + 19434.488186591469, + 19450.232581707827, + 19465.980163626304, + 19481.730931057613, + 19497.484882713761, + 19513.242017308068, + 19529.002333555141, + 19544.765830170898, + 19560.532505872539, + 19576.302359378566, + 19592.075389408761, + 19607.851594684209, + 19623.630973927269, + 19639.41352586159, + 19655.199249212103, + 19670.988142705017, + 19686.780205067826, + 19702.575435029288, + 19718.373831319448, + 19734.175392669615, + 19749.980117812371, + 19765.788005481569, + 19781.599054412323, + 19797.413263341008, + 19813.230631005274, + 19829.051156144014, + 19844.874837497395, + 19860.701673806827, + 19876.531663814985, + 19892.364806265789, + 19908.201099904403, + 19924.040543477258, + 19939.883135732012, + 19955.728875417579, + 19971.577761284105, + 19987.429792082985, + 20003.284966566847, + 20019.14328348956, + 20035.004741606219, + 20050.869339673161, + 20066.737076447946, + 20082.607950689362, + 20098.481961157428, + 20114.359106613385, + 20130.239385819699, + 20146.122797540058, + 20162.009340539353, + 20177.899013583716, + 20193.791815440476, + 20209.687744878182, + 20225.586800666591, + 20241.488981576669, + 20257.394286380597, + 20273.302713851754, + 20289.214262764715, + 20305.128931895277, + 20321.046720020415, + 20336.967625918318, + 20352.891648368361, + 20368.818786151114, + 20384.749038048347, + 20400.682402843009, + 20416.618879319249, + 20432.558466262391, + 20448.501162458953, + 20464.446966696629, + 20480.395877764302, + 20496.347894452025, + 20512.303015551031, + 20528.261239853735, + 20544.22256615372, + 20560.186993245738, + 20576.15451992572, + 20592.125144990758, + 20608.098867239107, + 20624.075685470198, + 20640.055598484618, + 20656.038605084115, + 20672.024704071595, + 20688.013894251126, + 20704.006174427926, + 20720.001543408373, + 20735.999999999989, + 20752.001543011454, + 20768.006171252597, + 20784.013883534382, + 20800.024678668931, + 20816.038555469506, + 20832.055512750507, + 20848.075549327474, + 20864.098664017085, + 20880.124855637161, + 20896.154123006647, + 20912.186464945626, + 20928.221880275312, + 20944.260367818049, + 20960.301926397311, + 20976.346554837684, + 20992.394251964895, + 21008.445016605787, + 21024.498847588318, + 21040.555743741574, + 21056.615703895754, + 21072.678726882168, + 21088.744811533252, + 21104.813956682538, + 21120.886161164683, + 21136.961423815443, + 21153.039743471683, + 21169.121118971379, + 21185.205549153605, + 21201.293032858535, + 21217.383568927453, + 21233.477156202731, + 21249.573793527841, + 21265.673479747358, + 21281.776213706937, + 21297.881994253334, + 21313.990820234398, + 21330.102690499054, + 21346.21760389733, + 21362.335559280327, + 21378.456555500241, + 21394.580591410333, + 21410.707665864964, + 21426.83777771956, + 21442.970925830628, + 21459.107109055756, + 21475.246326253604, + 21491.388576283895, + 21507.533858007431, + 21523.682170286087, + 21539.833511982797, + 21555.987881961566, + 21572.145279087465, + 21588.305702226615, + 21604.469150246216, + 21620.635622014521, + 21636.805116400832, + 21652.977632275521, + 21669.153168510009, + 21685.331723976764, + 21701.513297549318, + 21717.697888102244, + 21733.885494511167, + 21750.076115652759, + 21766.269750404736, + 21782.466397645861, + 21798.666056255934, + 21814.868725115801, + 21831.074403107345, + 21847.283089113484, + 21863.494782018177, + 21879.709480706417, + 21895.927184064229, + 21912.147890978667, + 21928.371600337818, + 21944.598311030797, + 21960.828021947746, + 21977.060731979829, + 21993.296440019243, + 22009.535144959198, + 22025.77684569393, + 22042.021541118691, + 22058.269230129757, + 22074.519911624411, + 22090.773584500959, + 22107.030247658717, + 22123.289899998013, + 22139.552540420187, + 22155.818167827587, + 22172.086781123569, + 22188.358379212495, + 22204.632960999726, + 22220.910525391639, + 22237.191071295601, + 22253.474597619981, + 22269.761103274148, + 22286.050587168469, + 22302.343048214312, + 22318.638485324027, + 22334.936897410968, + 22351.23828338947, + 22367.542642174871, + 22383.849972683485, + 22400.160273832618, + 22416.473544540564, + 22432.789783726603, + 22449.108990310986, + 22465.431163214958, + 22481.75630136074, + 22498.084403671528, + 22514.415469071497, + 22530.749496485802, + 22547.086484840562, + 22563.426433062879, + 22579.769340080824, + 22596.115204823436, + 22612.464026220721, + 22628.815803203655, + 22645.170534704179, + 22661.5282196552, + 22677.888856990587, + 22694.252445645168, + 22710.618984554734, + 22726.988472656034, + 22743.360908886778, + 22759.736292185622, + 22776.114621492186, + 22792.495895747044, + 22808.880113891719, + 22825.267274868678, + 22841.657377621348, + 22858.050421094096, + 22874.446404232243, + 22890.845325982053, + 22907.247185290722, + 22923.651981106406, + 22940.059712378195, + 22956.470378056114, + 22972.883977091129, + 22989.300508435153, + 23005.719971041017, + 23022.142363862498, + 23038.567685854305, + 23054.995935972078, + 23071.427113172387, + 23087.86121641273, + 23104.298244651531, + 23120.738196848146, + 23137.181071962848, + 23153.626868956846, + 23170.075586792263, + 23186.527224432142, + 23202.981780840448, + 23219.439254982066, + 23235.899645822796, + 23252.362952329357, + 23268.829173469378, + 23285.298308211408, + 23301.770355524899, + 23318.245314380223, + 23334.723183748658, + 23351.203962602387, + 23367.687649914504, + 23384.174244659007, + 23400.663745810798, + 23417.15615234568, + 23433.651463240367, + 23450.149677472462, + 23466.650794020472, + 23483.154811863806, + 23499.661729982763, + 23516.171547358543, + 23532.684262973235, + 23549.199875809823, + 23565.718384852185, + 23582.239789085092, + 23598.764087494197, + 23615.291279066041, + 23631.821362788058, + 23648.354337648565, + 23664.890202636761, + 23681.428956742733, + 23697.970598957443, + 23714.515128272738, + 23731.062543681343, + 23747.612844176863, + 23764.166028753778, + 23780.72209640744, + 23797.281046134085, + 23813.842876930816, + 23830.407587795606, + 23846.975177727301, + 23863.545645725622, + 23880.11899079115, + 23896.695211925336, + 23913.274308130498, + 23929.856278409821, + 23946.441121767348, + 23963.028837207989, + 23979.619423737513, + 23996.212880362549, + 24012.809206090584, + 24029.408399929966, + 24046.010460889898, + 24062.615387980433, + 24079.223180212492, + 24095.833836597827, + 24112.447356149063, + 24129.063737879667, + 24145.682980803951, + 24162.305083937081, + 24178.930046295067, + 24195.557866894767, + 24212.188544753884, + 24228.822078890964, + 24245.458468325389, + 24262.097712077397, + 24278.739809168052, + 24295.384758619261, + 24312.032559453768, + 24328.683210695162, + 24345.336711367858, + 24361.993060497109, + 24378.652257108995, + 24395.314300230442, + 24411.979188889192, + 24428.646922113825, + 24445.317498933746, + 24461.990918379193, + 24478.667179481225, + 24495.346281271726, + 24512.028222783407, + 24528.713003049801, + 24545.400621105266, + 24562.091075984976, + 24578.784366724925, + 24595.480492361927, + 24612.179451933614, + 24628.881244478438, + 24645.585869035654, + 24662.293324645343, + 24679.003610348394, + 24695.716725186514, + 24712.432668202211, + 24729.151438438807, + 24745.873034940436, + 24762.597456752032, + 24779.324702919344, + 24796.054772488926, + 24812.787664508123, + 24829.5233780251, + 24846.261912088819, + 24863.003265749034, + 24879.747438056307, + 24896.494428062004, + 24913.244234818278, + 24929.996857378079, + 24946.752294795166, + 24963.510546124078, + 24980.271610420157, + 24997.035486739525, + 25013.802174139113, + 25030.571671676629, + 25047.343978410572, + 25064.119093400237, + 25080.897015705697, + 25097.677744387816, + 25114.461278508239, + 25131.2476171294, + 25148.036759314517, + 25164.828704127583, + 25181.623450633375, + 25198.42099789745, + 25215.221344986145, + 25232.024490966574, + 25248.830434906627, + 25265.639175874974, + 25282.450712941049, + 25299.265045175071, + 25316.082171648024, + 25332.902091431668, + 25349.724803598532, + 25366.550307221914, + 25383.378601375884, + 25400.209685135269, + 25417.043557575678, + 25433.880217773472, + 25450.719664805783, + 25467.561897750507, + 25484.406915686297, + 25501.254717692573, + 25518.105302849512, + 25534.958670238051, + 25551.814818939893, + 25568.67374803748, + 25585.535456614027, + 25602.399943753502, + 25619.267208540619, + 25636.137250060852, + 25653.010067400432, + 25669.885659646327, + 25686.76402588627, + 25703.645165208734, + 25720.529076702944, + 25737.415759458876, + 25754.305212567244, + 25771.197435119517, + 25788.092426207899, + 25804.990184925344, + 25821.890710365547, + 25838.794001622944, + 25855.700057792714, + 25872.608877970775, + 25889.520461253778, + 25906.434806739118, + 25923.351913524923, + 25940.271780710063, + 25957.194407394138, + 25974.11979267748, + 25991.047935661154, + 26007.978835446964, + 26024.912491137442, + 26041.848901835841, + 26058.788066646157, + 26075.729984673108, + 26092.674655022136, + 26109.622076799409, + 26126.572249111829, + 26143.525171067016, + 26160.480841773315, + 26177.43926033979, + 26194.400425876229, + 26211.364337493149, + 26228.330994301767, + 26245.30039541404, + 26262.272539942627, + 26279.247427000919, + 26296.225055703002, + 26313.205425163702, + 26330.188534498539, + 26347.174382823756, + 26364.162969256304, + 26381.154292913852, + 26398.148352914774, + 26415.145148378149, + 26432.144678423778, + 26449.146942172156, + 26466.151938744493, + 26483.159667262702, + 26500.170126849403, + 26517.183316627921, + 26534.199235722277, + 26551.217883257199, + 26568.239258358124, + 26585.263360151173, + 26602.290187763181, + 26619.319740321676, + 26636.352016954883, + 26653.387016791727, + 26670.424738961825, + 26687.465182595493, + 26704.508346823739, + 26721.554230778267, + 26738.602833591467, + 26755.65415439643, + 26772.708192326929, + 26789.764946517433, + 26806.824416103096, + 26823.886600219761, + 26840.95149800396, + 26858.019108592915, + 26875.089431124517, + 26892.162464737365, + 26909.238208570721, + 26926.316661764544, + 26943.397823459472, + 26960.481692796813, + 26977.568268918571, + 26994.657550967422, + 27011.749538086722, + 27028.844229420498, + 27045.941624113464, + 27063.041721311005, + 27080.144520159181, + 27097.250019804727, + 27114.35821939505, + 27131.469118078236, + 27148.582715003027, + 27165.699009318858, + 27182.818000175819, + 27199.939686724665, + 27217.064068116837, + 27234.191143504428, + 27251.320912040203, + 27268.453372877593, + 27285.588525170693, + 27302.726368074269, + 27319.866900743735, + 27337.010122335181, + 27354.156032005358, + 27371.304628911668, + 27388.455912212183, + 27405.609881065626, + 27422.766534631384, + 27439.925872069507, + 27457.087892540683, + 27474.252595206275, + 27491.419979228293, + 27508.5900437694, + 27525.762787992917, + 27542.93821106281, + 27560.116312143706, + 27577.297090400876, + 27594.480545000242, + 27611.666675108383, + 27628.855479892518, + 27646.046958520514, + 27663.241110160889, + 27680.437933982801, + 27697.637429156068, + 27714.839594851132, + 27732.04443023909, + 27749.251934491687, + 27766.462106781299, + 27783.674946280949, + 27800.890452164302, + 27818.108623605654, + 27835.329459779954, + 27852.55295986278, + 27869.779123030345, + 27887.007948459504, + 27904.239435327745, + 27921.473582813196, + 27938.710390094613, + 27955.949856351392, + 27973.19198076355, + 27990.436762511745, + 28007.684200777272, + 28024.934294742041, + 28042.187043588601, + 28059.442446500128, + 28076.700502660427, + 28093.961211253929, + 28111.224571465693, + 28128.490582481401, + 28145.759243487362, + 28163.030553670509, + 28180.304512218394, + 28197.581118319198, + 28214.860371161725, + 28232.14226993539, + 28249.42681383024, + 28266.71400203693, + 28284.003833746745, + 28301.296308151585, + 28318.591424443959, + 28335.889181817001, + 28353.189579464462, + 28370.492616580705, + 28387.798292360701, + 28405.106606000048, + 28422.417556694945, + 28439.731143642206, + 28457.047366039264, + 28474.366223084147, + 28491.687713975512, + 28509.011837912611, + 28526.338594095305, + 28543.667981724069, + 28560.999999999982, + 28578.334648124732, + 28595.671925300605, + 28613.011830730498, + 28630.354363617909, + 28647.699523166943, + 28665.0473085823, + 28682.397719069289, + 28699.750753833818, + 28717.10641208239, + 28734.464693022121, + 28751.825595860708, + 28769.189119806462, + 28786.55526406828, + 28803.924027855664, + 28821.295410378701, + 28838.669410848088, + 28856.046028475103, + 28873.425262471628, + 28890.80711205013, + 28908.191576423673, + 28925.578654805915, + 28942.968346411097, + 28960.360650454055, + 28977.755566150216, + 28995.153092715591, + 29012.553229366786, + 29029.955975320987, + 29047.361329795975, + 29064.769292010107, + 29082.179861182336, + 29099.593036532187, + 29117.00881727978, + 29134.427202645813, + 29151.848191851568, + 29169.271784118911, + 29186.697978670283, + 29204.126774728706, + 29221.55817151779, + 29238.992168261717, + 29256.42876418525, + 29273.867958513725, + 29291.309750473058, + 29308.754139289747, + 29326.201124190855, + 29343.65070440403, + 29361.102879157483, + 29378.557647680012, + 29396.015009200975, + 29413.474962950309, + 29430.937508158524, + 29448.402644056692, + 29465.870369876469, + 29483.340684850071, + 29500.81358821028, + 29518.289079190454, + 29535.767157024511, + 29553.247820946945, + 29570.731070192807, + 29588.216903997723, + 29605.70532159787, + 29623.19632223, + 29640.689905131429, + 29658.186069540028, + 29675.684814694236, + 29693.186139833047, + 29710.690044196028, + 29728.196527023298, + 29745.705587555527, + 29763.217225033964, + 29780.731438700397, + 29798.248227797183, + 29815.76759156723, + 29833.289529254005, + 29850.81404010153, + 29868.341123354381, + 29885.870778257693, + 29903.403004057145, + 29920.937799998974, + 29938.475165329975, + 29956.015099297485, + 29973.557601149394, + 29991.102670134147, + 30008.650305500738, + 30026.200506498706, + 30043.753272378144, + 30061.308602389683, + 30078.866495784507, + 30096.426951814352, + 30113.989969731494, + 30131.55554878875, + 30149.123688239491, + 30166.694387337629, + 30184.267645337608, + 30201.843461494434, + 30219.42183506364, + 30237.002765301309, + 30254.586251464058, + 30272.172292809046, + 30289.760888593977, + 30307.35203807709, + 30324.94574051716, + 30342.541995173502, + 30360.140801305966, + 30377.742158174944, + 30395.346065041358, + 30412.952521166666, + 30430.561525812864, + 30448.173078242475, + 30465.787177718561, + 30483.403823504719, + 30501.02301486507, + 30518.644751064272, + 30536.269031367516, + 30553.895855040515, + 30571.525221349519, + 30589.157129561307, + 30606.791578943175, + 30624.428568762964, + 30642.06809828903, + 30659.710166790261, + 30677.35477353607, + 30695.001917796391, + 30712.651598841687, + 30730.303815942945, + 30747.958568371676, + 30765.615855399912, + 30783.275676300211, + 30800.938030345646, + 30818.602916809814, + 30836.270334966837, + 30853.940284091354, + 30871.612763458521, + 30889.287772344011, + 30906.965310024025, + 30924.645375775272, + 30942.327968874983, + 30960.013088600903, + 30977.700734231294, + 30995.390905044929, + 31013.083600321101, + 31030.778819339619, + 31048.476561380798, + 31066.17682572547, + 31083.879611654978, + 31101.584918451179, + 31119.29274539644, + 31137.003091773637, + 31154.715956866155, + 31172.431339957893, + 31190.14924033326, + 31207.869657277162, + 31225.592590075023, + 31243.318038012771, + 31261.046000376838, + 31278.776476454172, + 31296.50946553221, + 31314.24496689891, + 31331.98297984272, + 31349.7235036526, + 31367.466537618013, + 31385.212081028923, + 31402.960133175795, + 31420.710693349596, + 31438.463760841791, + 31456.219334944351, + 31473.977414949743, + 31491.738000150934, + 31509.501089841389, + 31527.266683315069, + 31545.034779866437, + 31562.80537879045, + 31580.578479382562, + 31598.35408093872, + 31616.132182755369, + 31633.91278412945, + 31651.695884358396, + 31669.481482740131, + 31687.269578573076, + 31705.060171156143, + 31722.853259788735, + 31740.648843770748, + 31758.446922402567, + 31776.247494985066, + 31794.050560819614, + 31811.85611920806, + 31829.664169452753, + 31847.474710856521, + 31865.287742722685, + 31883.103264355046, + 31900.921275057899, + 31918.741774136019, + 31936.564760894671, + 31954.390234639599, + 31972.21819467704, + 31990.048640313704, + 32007.881570856793, + 32025.716985613984, + 32043.554883893445, + 32061.395265003815, + 32079.238128254223, + 32097.083472954269, + 32114.931298414049, + 32132.781603944117, + 32150.634388855524, + 32168.48965245979, + 32186.347394068915, + 32204.207612995371, + 32222.07030855212, + 32239.935480052583, + 32257.803126810672, + 32275.673248140767, + 32293.545843357719, + 32311.420911776862, + 32329.298452713996, + 32347.178465485395, + 32365.060949407813, + 32382.945903798463, + 32400.83332797504, + 32418.723221255706, + 32436.615582959093, + 32454.510412404306, + 32472.407708910916, + 32490.307471798966, + 32508.209700388961, + 32526.114394001877, + 32544.021551959166, + 32561.931173582732, + 32579.843258194956, + 32597.757805118679, + 32615.674813677211, + 32633.594283194328, + 32651.516212994258, + 32669.440602401712, + 32687.367450741847, + 32705.296757340297, + 32723.228521523146, + 32741.162742616943, + 32759.099419948703, + 32777.038552845901, + 32794.980140636464, + 32812.924182648792, + 32830.87067821173, + 32848.819626654593, + 32866.77102730715, + 32884.724879499619, + 32902.681182562686, + 32920.639935827494, + 32938.601138625643, + 32956.56479028918, + 32974.530890150607, + 32992.499437542894, + 33010.470431799447, + 33028.443872254145, + 33046.419758241311, + 33064.39808909571, + 33082.378864152583, + 33100.36208274759, + 33118.347744216881, + 33136.335847897026, + 33154.326393125062, + 33172.31937923847, + 33190.314805575174, + 33208.312671473555, + 33226.312976272442, + 33244.315719311111, + 33262.320899929284, + 33280.328517467125, + 33298.33857126526, + 33316.351060664747, + 33334.365985007091, + 33352.383343634239, + 33370.403135888591, + 33388.42536111299, + 33406.450018650721, + 33424.477107845501, + 33442.506628041512, + 33460.53857858335, + 33478.572958816083, + 33496.609768085189, + 33514.649005736617, + 33532.690671116739, + 33550.734763572356, + 33568.781282450735, + 33586.830227099563, + 33604.881596866973, + 33622.935391101528, + 33640.991609152239, + 33659.050250368542, + 33677.111314100322, + 33695.174799697881, + 33713.240706511984, + 33731.309033893805, + 33749.37978119497, + 33767.452947767531, + 33785.528532963974, + 33803.606536137209, + 33821.686956640602, + 33839.769793827938, + 33857.855047053425, + 33875.942715671707, + 33894.032799037872, + 33912.125296507431, + 33930.220207436316, + 33948.317531180888, + 33966.417267097961, + 33984.519414544746, + 34002.623972878901, + 34020.730941458511, + 34038.840319642077, + 34056.952106788536, + 34075.066302257255, + 34093.182905408015, + 34111.301915601027, + 34129.42333219693, + 34147.547154556785, + 34165.673382042078, + 34183.80201401472, + 34201.933049837033, + 34220.06648887178, + 34238.202330482141, + 34256.340574031703, + 34274.481218884495, + 34292.624264404949, + 34310.769709957938, + 34328.91755490873, + 34347.067798623029, + 34365.220440466954, + 34383.375479807051, + 34401.532916010263, + 34419.692748443973, + 34437.854976475966, + 34456.01959947445, + 34474.18661680806, + 34492.356027845817, + 34510.527831957188, + 34528.702028512052, + 34546.878616880676, + 34565.05759643377, + 34583.238966542449, + 34601.422726578232, + 34619.608875913065, + 34637.797413919296, + 34655.988339969692, + 34674.181653437423, + 34692.37735369608, + 34710.575440119668, + 34728.775912082579, + 34746.978768959649, + 34765.184010126082, + 34783.391634957537, + 34801.60164283005, + 34819.814033120063, + 34838.028805204456, + 34856.24595846048, + 34874.465492265823, + 34892.687405998557, + 34910.911699037177, + 34929.138370760564, + 34947.367420548027, + 34965.598847779271, + 34983.832651834389, + 35002.068832093908, + 35020.307387938738, + 35038.548318750189, + 35056.79162390998, + 35075.03730280025, + 35093.285354803513, + 35111.535779302685, + 35129.788575681116, + 35148.043743322516, + 35166.301281611013, + 35184.561189931141, + 35202.823467667826, + 35221.088114206388, + 35239.355128932555, + 35257.624511232447, + 35275.896260492584, + 35294.170376099886, + 35312.446857441668, + 35330.725703905628, + 35349.006914879887, + 35367.290489752944, + 35385.576427913686, + 35403.864728751418, + 35422.155391655811, + 35440.448416016967, + 35458.743801225341, + 35477.041546671804, + 35495.341651747622, + 35513.644115844436, + 35531.948938354304, + 35550.256118669655, + 35568.565656183309, + 35586.877550288496, + 35605.191800378816, + 35623.508405848268, + 35641.827366091238, + 35660.148680502505, + 35678.472348477233, + 35696.798369410979, + 35715.126742699678, + 35733.457467739659, + 35751.790543927644, + 35770.125970660738, + 35788.46374733642, + 35806.803873352568, + 35825.146348107453, + 35843.49117099971, + 35861.838341428367, + 35880.187858792851, + 35898.539722492955, + 35916.893931928862, + 35935.250486501129, + 35953.609385610718, + 35971.970628658957, + 35990.334215047558, + 36008.700144178612, + 36027.068415454596, + 36045.439028278372, + 36063.811982053165, + 36082.187276182609, + 36100.564910070694, + 36118.944883121789, + 36137.327194740654, + 36155.711844332429, + 36174.098831302617, + 36192.488155057115, + 36210.87981500219, + 36229.273810544473, + 36247.670141091003, + 36266.068806049167, + 36284.469804826738, + 36302.873136831862, + 36321.278801473069, + 36339.686798159251, + 36358.097126299683, + 36376.509785304013, + 36394.924774582258, + 36413.342093544816, + 36431.761741602444, + 36450.183718166292, + 36468.608022647859, + 36487.034654459028, + 36505.463613012063, + 36523.894897719583, + 36542.328507994578, + 36560.764443250409, + 36579.202702900831, + 36597.643286359926, + 36616.086193042182, + 36634.531422362437, + 36652.978973735895, + 36671.428846578143, + 36689.881040305125, + 36708.335554333149, + 36726.792388078902, + 36745.251540959427, + 36763.713012392138, + 36782.176801794812, + 36800.642908585593, + 36819.111332182983, + 36837.582072005869, + 36856.055127473483, + 36874.530498005421, + 36893.008183021651, + 36911.488181942506, + 36929.970494188674, + 36948.455119181206, + 36966.942056341519, + 36985.431305091392, + 37003.922864852961, + 37022.416735048733, + 37040.912915101559, + 37059.411404434657, + 37077.91220247162, + 37096.415308636388, + 37114.920722353243, + 37133.428443046862, + 37151.938470142253, + 37170.450803064785, + 37188.965441240209, + 37207.482384094597, + 37226.001631054402, + 37244.523181546429, + 37263.047034997842, + 37281.573190836149, + 37300.101648489224, + 37318.632407385296, + 37337.165466952945, + 37355.700826621112, + 37374.238485819085, + 37392.778443976509, + 37411.320700523385, + 37429.865254890057, + 37448.412106507232, + 37466.961254805974, + 37485.512699217681, + 37504.066439174116, + 37522.622474107404, + 37541.180803449992, + 37559.741426634704, + 37578.304343094693, + 37596.869552263488, + 37615.43705357494, + 37634.006846463279, + 37652.578930363044, + 37671.153304709165, + 37689.729968936896, + 37708.308922481847, + 37726.890164779965, + 37745.473695267559, + 37764.059513381275, + 37782.647618558112, + 37801.238010235415, + 37819.830687850859, + 37838.425650842495, + 37857.022898648691, + 37875.622430708172, + 37894.224246460013, + 37912.828345343616, + 37931.434726798747, + 37950.043390265506, + 37968.654335184328, + 37987.267560995999, + 38005.883067141665, + 38024.500853062775, + 38043.120918201159, + 38061.743261998963, + 38080.367883898682, + 38098.994783343158, + 38117.623959775563, + 38136.255412639417, + 38154.889141378575, + 38173.525145437234, + 38192.163424259939, + 38210.803977291551, + 38229.446803977284, + 38248.091903762703, + 38266.739276093685, + 38285.388920416466, + 38304.040836177606, + 38322.695022824002, + 38341.351479802899, + 38360.010206561863, + 38378.671202548816, + 38397.334467211993, + 38415.999999999978, + 38434.667800361683, + 38453.33786774637, + 38472.010201603611, + 38490.684801383337, + 38509.361666535784, + 38528.040796511552, + 38546.722190761553, + 38565.405848737035, + 38584.091769889594, + 38602.779953671132, + 38621.470399533908, + 38640.163106930493, + 38658.858075313794, + 38677.555304137059, + 38696.254792853862, + 38714.956540918094, + 38733.660547783991, + 38752.366812906112, + 38771.075335739348, + 38789.78611573892, + 38808.499152360368, + 38827.214445059573, + 38845.931993292739, + 38864.651796516388, + 38883.373854187383, + 38902.098165762916, + 38920.824730700486, + 38939.553548457938, + 38958.284618493431, + 38977.017940265461, + 38995.753513232834, + 39014.491336854699, + 39033.231410590517, + 39051.973733900079, + 39070.718306243485, + 39089.465127081188, + 39108.214195873945, + 39126.965512082832, + 39145.719075169261, + 39164.474884594965, + 39183.232939821988, + 39201.99324031271, + 39220.755785529815, + 39239.52057493633, + 39258.287607995589, + 39277.056884171245, + 39295.828402927284, + 39314.602163728006, + 39333.378166038019, + 39352.15640932227, + 39370.936893046004, + 39389.719616674811, + 39408.504579674584, + 39427.291781511522, + 39446.081221652174, + 39464.872899563372, + 39483.666814712291, + 39502.462966566411, + 39521.261354593538, + 39540.06197826178, + 39558.864837039568, + 39577.669930395656, + 39596.47725779911, + 39615.286818719302, + 39634.098612625923, + 39652.912638988993, + 39671.728897278823, + 39690.547386966064, + 39709.368107521652, + 39728.191058416858, + 39747.016239123259, + 39765.84364911275, + 39784.673287857528, + 39803.505154830105, + 39822.339249503319, + 39841.175571350293, + 39860.014119844491, + 39878.854894459677, + 39897.697894669909, + 39916.54311994958, + 39935.390569773372, + 39954.240243616303, + 39973.092140953675, + 39991.946261261117, + 40010.802604014549, + 40029.661168690225, + 40048.521954764678, + 40067.384961714779, + 40086.250189017679, + 40105.117636150855, + 40123.98730259209, + 40142.859187819471, + 40161.733291311379, + 40180.609612546526, + 40199.488151003912, + 40218.368906162854, + 40237.25187750296, + 40256.137064504153, + 40275.024466646668, + 40293.914083411029, + 40312.805914278084, + 40331.699958728961, + 40350.596216245103, + 40369.494686308273, + 40388.39536840051, + 40407.298262004173, + 40426.20336660192, + 40445.110681676706, + 40464.020206711793, + 40482.931941190756, + 40501.845884597446, + 40520.762036416032, + 40539.680396130985, + 40558.600963227072, + 40577.523737189367, + 40596.448717503234, + 40615.375903654342, + 40634.305295128659, + 40653.236891412453, + 40672.170691992294, + 40691.106696355047, + 40710.044903987873, + 40728.985314378238, + 40747.927927013901, + 40766.872741382918, + 40785.819756973651, + 40804.768973274746, + 40823.720389775161, + 40842.674005964131, + 40861.629821331211, + 40880.587835366234, + 40899.548047559321, + 40918.510457400931, + 40937.475064381761, + 40956.441867992849, + 40975.410867725499, + 40994.382063071331, + 41013.355453522236, + 41032.331038570417, + 41051.308817708363, + 41070.288790428858, + 41089.270956224987, + 41108.255314590111, + 41127.241865017888, + 41146.23060700229, + 41165.221540037543, + 41184.214663618193, + 41203.209977239079, + 41222.207480395307, + 41241.207172582297, + 41260.209053295752, + 41279.213122031659, + 41298.219378286303, + 41317.227821556255, + 41336.23845133838, + 41355.251267129832, + 41374.266268428037, + 41393.283454730743, + 41412.302825535953, + 41431.324380341983, + 41450.348118647416, + 41469.374039951144, + 41488.402143752326, + 41507.432429550427, + 41526.464896845187, + 41545.499545136627, + 41564.536373925075, + 41583.575382711126, + 41602.616570995662, + 41621.659938279874, + 41640.705484065205, + 41659.753207853406, + 41678.803109146495, + 41697.855187446803, + 41716.909442256911, + 41735.965873079709, + 41755.02447941836, + 41774.085260776315, + 41793.148216657297, + 41812.213346565331, + 41831.280650004708, + 41850.350126480014, + 41869.421775496106, + 41888.495596558132, + 41907.571589171515, + 41926.649752841957, + 41945.730087075463, + 41964.812591378286, + 41983.897265256979, + 42002.984108218378, + 42022.073119769593, + 42041.164299418015, + 42060.257646671307, + 42079.353161037419, + 42098.450842024591, + 42117.550689141324, + 42136.652701896404, + 42155.756879798893, + 42174.863222358137, + 42193.971729083758, + 42213.082399485655, + 42232.195233074002, + 42251.310229359246, + 42270.427387852127, + 42289.546708063644, + 42308.668189505079, + 42327.791831687995, + 42346.917634124227, + 42366.045596325886, + 42385.175717805352, + 42404.307998075295, + 42423.442436648642, + 42442.579033038608, + 42461.717786758672, + 42480.858697322597, + 42500.001764244422, + 42519.146987038446, + 42538.294365219248, + 42557.443898301688, + 42576.595585800882, + 42595.749427232236, + 42614.90542211142, + 42634.063569954378, + 42653.223870277317, + 42672.386322596729, + 42691.55092642938, + 42710.717681292292, + 42729.886586702756, + 42749.057642178363, + 42768.23084723694, + 42787.406201396603, + 42806.58370417574, + 42825.76335509299, + 42844.945153667286, + 42864.129099417805, + 42883.315191864014, + 42902.503430525649, + 42921.693814922692, + 42940.88634457541, + 42960.081019004348, + 42979.277837730297, + 42998.476800274322, + 43017.677906157769, + 43036.881154902228, + 43056.086546029583, + 43075.294079061961, + 43094.503753521763, + 43113.715568931671, + 43132.929524814601, + 43152.145620693766, + 43171.363856092619, + 43190.584230534907, + 43209.806743544621, + 43229.031394646016, + 43248.258183363621, + 43267.487109222224, + 43286.718171746885, + 43305.951370462906, + 43325.186704895881, + 43344.42417457165, + 43363.663779016322, + 43382.905517756262, + 43402.149390318104, + 43421.395396228749, + 43440.643535015348, + 43459.89380620532, + 43479.146209326354, + 43498.400743906379, + 43517.657409473606, + 43536.916205556496, + 43556.177131683784, + 43575.44018738444, + 43594.705372187724, + 43613.972685623135, + 43633.242127220445, + 43652.513696509668, + 43671.787393021099, + 43691.063216285271, + 43710.341165833001, + 43729.621241195346, + 43748.903441903625, + 43768.187767489413, + 43787.474217484552, + 43806.762791421126, + 43826.053488831501, + 43845.346309248278, + 43864.641252204325, + 43883.938317232765, + 43903.237503866971, + 43922.538811640596, + 43941.842240087513, + 43961.147788741881, + 43980.455457138101, + 43999.765244810835, + 44019.077151295001, + 44038.391176125755, + 44057.70731883854, + 44077.02557896902, + 44096.345956053141, + 44115.668449627083, + 44134.993059227287, + 44154.319784390456, + 44173.648624653535, + 44192.979579553728, + 44212.312648628489, + 44231.647831415532, + 44250.985127452805, + 44270.324536278538, + 44289.666057431183, + 44309.009690449464, + 44328.355434872348, + 44347.703290239064, + 44367.053256089079, + 44386.405331962109, + 44405.759517398139, + 44425.115811937387, + 44444.474215120332, + 44463.834726487694, + 44483.197345580462, + 44502.562071939843, + 44521.928905107328, + 44541.297844624634, + 44560.668890033732, + 44580.042040876848, + 44599.417296696454, + 44618.794657035272, + 44638.174121436256, + 44657.555689442641, + 44676.939360597877, + 44696.325134445673, + 44715.713010530002, + 44735.102988395054, + 44754.495067585296, + 44773.88924764542, + 44793.285528120374, + 44812.683908555344, + 44832.084388495779, + 44851.486967487363, + 44870.891645076015, + 44890.298420807922, + 44909.707294229491, + 44929.118264887409, + 44948.531332328566, + 44967.946496100136, + 44987.363755749502, + 45006.783110824319, + 45026.204560872473, + 45045.628105442098, + 45065.053744081561, + 45084.48147633949, + 45103.911301764747, + 45123.343219906426, + 45142.777230313885, + 45162.21333253671, + 45181.651526124733, + 45201.091810628037, + 45220.534185596924, + 45239.978650581965, + 45259.425205133957, + 45278.873848803938, + 45298.324581143192, + 45317.777401703235, + 45337.232310035848, + 45356.68930569302, + 45376.148388226997, + 45395.60955719027, + 45415.072812135557, + 45434.538152615823, + 45454.005578184282, + 45473.475088394356, + 45492.946682799746, + 45512.420360954362, + 45531.896122412363, + 45551.373966728155, + 45570.853893456362, + 45590.33590215187, + 45609.819992369776, + 45629.306163665438, + 45648.794415594442, + 45668.284747712612, + 45687.777159576006, + 45707.27165074092, + 45726.768220763894, + 45746.266869201696, + 45765.767595611323, + 45785.270399550034, + 45804.775280575297, + 45824.282238244828, + 45843.79127211657, + 45863.302381748719, + 45882.815566699683, + 45902.33082652813, + 45921.848160792935, + 45941.367569053225, + 45960.889050868354, + 45980.41260579793, + 45999.938233401757, + 46019.465933239902, + 46038.995704872657, + 46058.527547860547, + 46078.06146176433, + 46097.597446144995, + 46117.135500563774, + 46136.675624582109, + 46156.217817761702, + 46175.762079664462, + 46195.308409852543, + 46214.856807888333, + 46234.407273334444, + 46253.959805753715, + 46273.51440470924, + 46293.071069764315, + 46312.629800482478, + 46332.190596427499, + 46351.753457163381, + 46371.318382254351, + 46390.885371264863, + 46410.45442375962, + 46430.025539303526, + 46449.598717461733, + 46469.17395779962, + 46488.751259882782, + 46508.33062327707, + 46527.912047548532, + 46547.495532263471, + 46567.081076988397, + 46586.668681290059, + 46606.258344735434, + 46625.850066891719, + 46645.443847326351, + 46665.039685606986, + 46684.637581301497, + 46704.237533978005, + 46723.839543204842, + 46743.443608550573, + 46763.049729583989, + 46782.657905874104, + 46802.268136990162, + 46821.880422501628, + 46841.494761978196, + 46861.111154989776, + 46880.729601106526, + 46900.350099898795, + 46919.97265093719, + 46939.597253792526, + 46959.223908035841, + 46978.852613238392, + 46998.483368971691, + 47018.11617480743, + 47037.751030317551, + 47057.387935074221, + 47077.026888649809, + 47096.66789061694, + 47116.310940548428, + 47135.956038017328, + 47155.603182596918, + 47175.252373860698, + 47194.903611382375, + 47214.556894735892, + 47234.212223495422, + 47253.869597235338, + 47273.52901553025, + 47293.19047795498, + 47312.853984084577, + 47332.519533494306, + 47352.187125759658, + 47371.856760456343, + 47391.528437160297, + 47411.202155447652, + 47430.877914894787, + 47450.555715078299, + 47470.235555574982, + 47489.917435961863, + 47509.601355816201, + 47529.287314715453, + 47548.975312237308, + 47568.665347959672, + 47588.357421460656, + 47608.051532318605, + 47627.747680112072, + 47647.445864419846, + 47667.14608482091, + 47686.848340894474, + 47706.552632219973, + 47726.258958377046, + 47745.967318945557, + 47765.677713505589, + 47785.390141637428, + 47805.104602921601, + 47824.821096938824, + 47844.539623270044, + 47864.260181496429, + 47883.982771199349, + 47903.707391960394, + 47923.434043361369, + 47943.162724984308, + 47962.893436411439, + 47982.626177225218, + 48002.36094700831, + 48022.097745343599, + 48041.836571814172, + 48061.57742600335, + 48081.32030749465, + 48101.065215871815, + 48120.81215071879, + 48140.56111161974, + 48160.312098159047, + 48180.065109921306, + 48199.820146491307, + 48219.577207454073, + 48239.336292394844, + 48259.097400899045, + 48278.860532552339, + 48298.625686940592, + 48318.392863649875, + 48338.162062266485, + 48357.933282376915, + 48377.706523567889, + 48397.481785426316, + 48417.259067539344, + 48437.038369494308, + 48456.819690878765, + 48476.603031280487, + 48496.388390287451, + 48516.175767487839, + 48535.965162470042, + 48555.756574822684, + 48575.550004134566, + 48595.345449994718, + 48615.142911992378, + 48634.942389716991, + 48654.743882758201, + 48674.547390705877, + 48694.352913150084, + 48714.160449681112, + 48733.969999889443, + 48753.781563365759, + 48773.595139700978, + 48793.410728486211, + 48813.228329312769, + 48833.047941772187, + 48852.869565456189, + 48872.693199956717, + 48892.518844865925, + 48912.346499776155, + 48932.176164279976, + 48952.007837970152, + 48971.841520439666, + 48991.677211281676, + 49011.514910089587, + 49031.354616456978, + 49051.196329977654, + 49071.04005024561, + 49090.885776855059, + 49110.733509400408, + 49130.583247476279, + 49150.434990677488, + 49170.288738599062, + 49190.144490836232, + 49210.002246984441, + 49229.86200663932, + 49249.723769396718, + 49269.587534852675, + 49289.453302603448, + 49309.32107224549, + 49329.190843375451, + 49349.062615590192, + 49368.936388486785, + 49388.812161662492, + 49408.689934714785, + 49428.569707241324, + 49448.45147883999, + 49468.335249108866, + 49488.22101764621, + 49508.108784050521, + 49527.99854792047, + 49547.890308854934, + 49567.784066453009, + 49587.679820313977, + 49607.57757003732, + 49627.477315222721, + 49647.379055470075, + 49667.28279037946, + 49687.188519551179, + 49707.096242585707, + 49727.005959083741, + 49746.917668646165, + 49766.831370874068, + 49786.747065368734, + 49806.66475173166, + 49826.584429564515, + 49846.506098469203, + 49866.429758047794, + 49886.355407902578, + 49906.283047636032, + 49926.212676850846, + 49946.144295149883, + 49966.077902136225, + 49986.013497413151, + 50005.951080584135, + 50025.890651252834, + 50045.832209023123, + 50065.775753499074, + 50085.721284284933, + 50105.668800985164, + 50125.618303204428, + 50145.569790547575, + 50165.523262619652, + 50185.478719025901, + 50205.436159371769, + 50225.395583262893, + 50245.356990305103, + 50265.320380104429, + 50285.285752267104, + 50305.253106399534, + 50325.222442108337, + 50345.193759000336, + 50365.16705668252, + 50385.142334762102, + 50405.119592846473, + 50425.098830543218, + 50445.080047460127, + 50465.063243205179, + 50485.048417386541, + 50505.035569612577, + 50525.024699491856, + 50545.015806633128, + 50565.008890645338, + 50585.003951137631, + 50605.00098771933, + 50624.999999999971, + 50645.000987589265, + 50665.003950097132, + 50685.008887133677, + 50705.015798309192, + 50725.024683234165, + 50745.035541519283, + 50765.048372775411, + 50785.063176613621, + 50805.079952645159, + 50825.098700481489, + 50845.119419734241, + 50865.142110015244, + 50885.166770936521, + 50905.193402110279, + 50925.222003148934, + 50945.252573665071, + 50965.285113271471, + 50985.319621581119, + 51005.356098207172, + 51025.394542762981, + 51045.434954862096, + 51065.477334118244, + 51085.521680145357, + 51105.567992557546, + 51125.616270969113, + 51145.66651499454, + 51165.718724248516, + 51185.772898345916, + 51205.829036901778, + 51225.887139531362, + 51245.947205850105, + 51266.009235473619, + 51286.073228017718, + 51306.139183098399, + 51326.207100331856, + 51346.276979334456, + 51366.348819722756, + 51386.42262111351, + 51406.498383123653, + 51426.57610537031, + 51446.655787470787, + 51466.737429042587, + 51486.82102970338, + 51506.906589071048, + 51526.994106763632, + 51547.083582399391, + 51567.175015596738, + 51587.268405974297, + 51607.363753150858, + 51627.461056745415, + 51647.56031637713, + 51667.661531665362, + 51687.764702229651, + 51707.869827689727, + 51727.976907665499, + 51748.085941777055, + 51768.196929644677, + 51788.309870888836, + 51808.42476513017, + 51828.541611989524, + 51848.660411087905, + 51868.781162046515, + 51888.90386448674, + 51909.028518030143, + 51929.155122298485, + 51949.283676913685, + 51969.414181497872, + 51989.546635673345, + 52009.681039062583, + 52029.817391288263, + 52049.955691973213, + 52070.095940740481, + 52090.238137213273, + 52110.382281014987, + 52130.5283717692, + 52150.676409099666, + 52170.826392630333, + 52190.97832198532, + 52211.132196788931, + 52231.288016665654, + 52251.445781240145, + 52271.60549013727, + 52291.76714298204, + 52311.930739399664, + 52332.096279015546, + 52352.263761455244, + 52372.433186344519, + 52392.604553309284, + 52412.777861975665, + 52432.953111969946, + 52453.130302918595, + 52473.309434448267, + 52493.490506185793, + 52513.67351775818, + 52533.858468792605, + 52554.045358916446, + 52574.234187757254, + 52594.42495494274, + 52614.617660100812, + 52634.812302859558, + 52655.008882847229, + 52675.20739969227, + 52695.407853023295, + 52715.610242469098, + 52735.814567658657, + 52756.02082822111, + 52776.229023785803, + 52796.439153982225, + 52816.651218440056, + 52836.865216789171, + 52857.081148659599, + 52877.29901368155, + 52897.518811485425, + 52917.740541701773, + 52937.964203961354, + 52958.18979789508, + 52978.417323134046, + 52998.646779309529, + 53018.878166052978, + 53039.111482996006, + 53059.346729770419, + 53079.583906008193, + 53099.823011341483, + 53120.0640454026, + 53140.307007824063, + 53160.551898238533, + 53180.79871627887, + 53201.047461578091, + 53221.2981337694, + 53241.550732486176, + 53261.805257361964, + 53282.061708030487, + 53302.32008412564, + 53322.580385281493, + 53342.842611132299, + 53363.106761312469, + 53383.372835456597, + 53403.640833199453, + 53423.910754175973, + 53444.18259802126, + 53464.456364370613, + 53484.732052859479, + 53505.009663123499, + 53525.289194798468, + 53545.570647520362, + 53565.854020925333, + 53586.139314649699, + 53606.426528329954, + 53626.715661602764, + 53647.006714104959, + 53667.299685473547, + 53687.59457534572, + 53707.891383358816, + 53728.190109150361, + 53748.490752358055, + 53768.793312619753, + 53789.09778957349, + 53809.404182857485, + 53829.712492110106, + 53850.022716969899, + 53870.334857075584, + 53890.648912066055, + 53910.964881580367, + 53931.28276525774, + 53951.602562737586, + 53971.924273659461, + 53992.24789766311, + 54012.57343438844, + 54032.90088347553, + 54053.23024456462, + 54073.561517296133, + 54093.894701310644, + 54114.22979624891, + 54134.566801751855, + 54154.90571746057, + 54175.246543016314, + 54195.589278060506, + 54215.933922234755, + 54236.280475180814, + 54256.628936540626, + 54276.97930595628, + 54297.331583070045, + 54317.685767524359, + 54338.041858961828, + 54358.399857025215, + 54378.759761357462, + 54399.121571601667, + 54419.485287401105, + 54439.850908399218, + 54460.218434239614, + 54480.587864566056, + 54500.95919902248, + 54521.332437252997, + 54541.707578901878, + 54562.084623613555, + 54582.46357103264, + 54602.844420803893, + 54623.227172572246, + 54643.611825982807, + 54663.998380680838, + 54684.386836311773, + 54704.777192521207, + 54725.169448954897, + 54745.563605258772, + 54765.959661078923, + 54786.357616061614, + 54806.757469853255, + 54827.159222100439, + 54847.562872449904, + 54867.968420548583, + 54888.375866043534, + 54908.785208582012, + 54929.196447811417, + 54949.609583379322, + 54970.024614933463, + 54990.441542121727, + 55010.86036459219, + 55031.28108199306, + 55051.703693972733, + 55072.128200179759, + 55092.554600262847, + 55112.982893870874, + 55133.413080652877, + 55153.845160258061, + 55174.279132335789, + 55194.714996535586, + 55215.152752507143, + 55235.592399900306, + 55256.033938365079, + 55276.477367551655, + 55296.92268711036, + 55317.369896691685, + 55337.818995946305, + 55358.269984525024, + 55378.72286207883, + 55399.177628258869, + 55419.634282716441, + 55440.092825103013, + 55460.553255070205, + 55481.015572269804, + 55501.479776353764, + 55521.945866974187, + 55542.413843783339, + 55562.883706433655, + 55583.355454577715, + 55603.82908786826, + 55624.304605958219, + 55644.782008500639, + 55665.261295148754, + 55685.742465555952, + 55706.225519375774, + 55726.710456261928, + 55747.197275868275, + 55767.685977848843, + 55788.176561857814, + 55808.669027549528, + 55829.163374578478, + 55849.659602599328, + 55870.157711266889, + 55890.657700236145, + 55911.159569162221, + 55931.663317700411, + 55952.168945506164, + 55972.676452235086, + 55993.185837542944, + 56013.697101085651, + 56034.210242519301, + 56054.72526150012, + 56075.242157684508, + 56095.760930729011, + 56116.281580290342, + 56136.804106025367, + 56157.328507591104, + 56177.85478464474, + 56198.382936843598, + 56218.912963845185, + 56239.444865307138, + 56259.978640887268, + 56280.514290243525, + 56301.051813034042, + 56321.591208917082, + 56342.13247755108, + 56362.675618594607, + 56383.220631706419, + 56403.767516545398, + 56424.316272770608, + 56444.866900041241, + 56465.419398016667, + 56485.973766356394, + 56506.530004720102, + 56527.088112767611, + 56547.648090158902, + 56568.209936554107, + 56588.773651613519, + 56609.339234997584, + 56629.9066863669, + 56650.47600538221, + 56671.04719170442, + 56691.620244994599, + 56712.195164913959, + 56732.771951123868, + 56753.350603285835, + 56773.931121061541, + 56794.513504112823, + 56815.097752101647, + 56835.683864690152, + 56856.271841540627, + 56876.86168231551, + 56897.453386677393, + 56918.046954289028, + 56938.642384813298, + 56959.239677913261, + 56979.838833252121, + 57000.439850493225, + 57021.04272930009, + 57041.647469336371, + 57062.254070265873, + 57082.862531752558, + 57103.472853460553, + 57124.085035054108, + 57144.699076197649, + 57165.314976555739, + 57185.932735793103, + 57206.552353574611, + 57227.173829565276, + 57247.797163430281, + 57268.42235483494, + 57289.049403444733, + 57309.678308925286, + 57330.30907094237, + 57350.941689161911, + 57371.576163249985, + 57392.212492872815, + 57412.850677696784, + 57433.490717388406, + 57454.132611614368, + 57474.776360041491, + 57495.421962336746, + 57516.069418167266, + 57536.718727200314, + 57557.36988910332, + 57578.022903543861, + 57598.677770189643, + 57619.334488708548, + 57639.993058768589, + 57660.653480037938, + 57681.315752184906, + 57701.979874877965, + 57722.64584778573, + 57743.31367057695, + 57763.983342920546, + 57784.654864485572, + 57805.328234941233, + 57826.003453956881, + 57846.680521202026, + 57867.359436346305, + 57888.040199059527, + 57908.722809011633, + 57929.407265872709, + 57950.093569313001, + 57970.781719002895, + 57991.471714612911, + 58012.16355581375, + 58032.857242276223, + 58053.552773671312, + 58074.25014967013, + 58094.949369943948, + 58115.650434164185, + 58136.353342002389, + 58157.058093130276, + 58177.764687219693, + 58198.47312394264, + 58219.183402971255, + 58239.895523977837, + 58260.609486634821, + 58281.325290614775, + 58302.042935590434, + 58322.762421234678, + 58343.483747220511, + 58364.206913221096, + 58384.931918909751, + 58405.658763959924, + 58426.3874480452, + 58447.117970839339, + 58467.85033201622, + 58488.584531249864, + 58509.320568214462, + 58530.058442584334, + 58550.798154033931, + 58571.539702237875, + 58592.283086870906, + 58613.028307607929, + 58633.775364123983, + 58654.52425609425, + 58675.274983194053, + 58696.027545098877, + 58716.781941484325, + 58737.538172026158, + 58758.296236400274, + 58779.056134282728, + 58799.817865349694, + 58820.581429277503, + 58841.346825742643, + 58862.114054421712, + 58882.883114991484, + 58903.654007128847, + 58924.426730510851, + 58945.201284814684, + 58965.977669717664, + 58986.755884897269, + 59007.535930031117, + 59028.317804796949, + 59049.101508872664, + 59069.887041936301, + 59090.674403666046, + 59111.463593740213, + 59132.254611837263, + 59153.047457635803, + 59173.84213081457, + 59194.638631052461, + 59215.436958028506, + 59236.237111421855, + 59257.039090911829, + 59277.842896177877, + 59298.648526899589, + 59319.455982756685, + 59340.26526342905, + 59361.076368596696, + 59381.889297939757, + 59402.704051138542, + 59423.520627873484, + 59444.339027825139, + 59465.159250674224, + 59485.9812961016, + 59506.805163788253, + 59527.630853415307, + 59548.458364664046, + 59569.287697215863, + 59590.118850752311, + 59610.951824955089, + 59631.786619506012, + 59652.623234087048, + 59673.461668380311, + 59694.301922068029, + 59715.143994832593, + 59735.987886356525, + 59756.833596322482, + 59777.681124413255, + 59798.530470311794, + 59819.381633701159, + 59840.234614264569, + 59861.089411685381, + 59881.94602564707, + 59902.804455833269, + 59923.664701927737, + 59944.526763614384, + 59965.390640577243, + 59986.256332500488, + 60007.123839068438, + 60027.993159965539, + 60048.864294876381, + 60069.737243485688, + 60090.612005478324, + 60111.488580539284, + 60132.366968353708, + 60153.247168606867, + 60174.129180984164, + 60195.013005171153, + 60215.898640853513, + 60236.786087717061, + 60257.675345447751, + 60278.566413731671, + 60299.459292255044, + 60320.353980704247, + 60341.25047876576, + 60362.148786126229, + 60383.048902472423, + 60403.950827491237, + 60424.854560869717, + 60445.76010229504, + 60466.667451454516, + 60487.57660803559, + 60508.487571725847, + 60529.400342212997, + 60550.314919184893, + 60571.231302329521, + 60592.149491335003, + 60613.069485889588, + 60633.991285681674, + 60654.914890399785, + 60675.840299732568, + 60696.767513368832, + 60717.696530997484, + 60738.627352307602, + 60759.55997698837, + 60780.494404729128, + 60801.430635219323, + 60822.368668148556, + 60843.308503206565, + 60864.250140083204, + 60885.193578468468, + 60906.138818052495, + 60927.085858525541, + 60948.034699578006, + 60968.985340900421, + 60989.937782183442, + 61010.892023117864, + 61031.848063394616, + 61052.805902704764, + 61073.765540739492, + 61094.726977190134, + 61115.690211748137, + 61136.655244105103, + 61157.622073952742, + 61178.590700982917, + 61199.561124887616, + 61220.533345358948, + 61241.507362089171, + 61262.483174770663, + 61283.460783095943, + 61304.440186757645, + 61325.421385448557, + 61346.404378861582, + 61367.389166689762, + 61388.375748626262, + 61409.364124364387, + 61430.354293597571, + 61451.346256019373, + 61472.340011323497, + 61493.335559203762, + 61514.332899354122, + 61535.332031468672, + 61556.332955241618, + 61577.335670367313, + 61598.340176540238, + 61619.346473454993, + 61640.354560806329, + 61661.3644382891, + 61682.376105598312, + 61703.389562429089, + 61724.404808476691, + 61745.42184343651, + 61766.440667004063, + 61787.461278874987, + 61808.483678745069, + 61829.507866310203, + 61850.533841266435, + 61871.561603309929, + 61892.591152136971, + 61913.622487443987, + 61934.655608927525, + 61955.690516284267, + 61976.727209211022, + 61997.765687404724, + 62018.805950562448, + 62039.847998381381, + 62060.891830558845, + 62081.93744679229, + 62102.984846779298, + 62124.034030217575, + 62145.084996804966, + 62166.137746239416, + 62187.19227821903, + 62208.248592442025, + 62229.306688606739, + 62250.366566411656, + 62271.428225555377, + 62292.491665736627, + 62313.556886654267, + 62334.623888007271, + 62355.692669494762, + 62376.763230815974, + 62397.835571670272, + 62418.909691757144, + 62439.98559077621, + 62461.063268427228, + 62482.142724410049, + 62503.223958424685, + 62524.306970171267, + 62545.39175935003, + 62566.478325661366, + 62587.566668805768, + 62608.656788483881, + 62629.748684396451, + 62650.842356244357, + 62671.937803728622, + 62693.035026550366, + 62714.134024410858, + 62735.234797011479, + 62756.337344053733, + 62777.441665239276, + 62798.547760269852, + 62819.655628847358, + 62840.765270673801, + 62861.876685451323, + 62882.989872882186, + 62904.104832668774, + 62925.221564513602, + 62946.340068119309, + 62967.460343188657, + 62988.582389424526, + 63009.70620652994, + 63030.831794208025, + 63051.959152162039, + 63073.08828009537, + 63094.219177711529, + 63115.351844714154, + 63136.486280806988, + 63157.622485693922, + 63178.760459078956, + 63199.900200666219, + 63221.041710159967, + 63242.184987264569, + 63263.330031684534, + 63284.476843124474, + 63305.625421289144, + 63326.775765883409, + 63347.927876612259, + 63369.081753180813, + 63390.237395294316, + 63411.39480265812, + 63432.553974977716, + 63453.714911958712, + 63474.877613306839, + 63496.042078727944, + 63517.208307927998, + 63538.376300613119, + 63559.546056489504, + 63580.717575263516, + 63601.890856641607, + 63623.065900330374, + 63644.242706036515, + 63665.421273466869, + 63686.601602328381, + 63707.783692328136, + 63728.967543173334, + 63750.153154571279, + 63771.340526229418, + 63792.529657855317, + 63813.720549156649, + 63834.913199841227, + 63856.107609616978, + 63877.303778191941, + 63898.501705274284, + 63919.7013905723, + 63940.902833794404, + 63962.106034649114, + 63983.310992845094, + 64004.517708091109, + 64025.726180096048, + 64046.936408568938, + 64068.1483932189, + 64089.362133755196, + 64110.577629887193, + 64131.794881324393, + 64153.013887776404, + 64174.234648952966, + 64195.457164563937, + 64216.681434319289, + 64237.907457929112, + 64259.135235103626, + 64280.36476555316, + 64301.596048988169, + 64322.829085119236, + 64344.06387365704, + 64365.300414312398, + 64386.538706796251, + 64407.778750819634, + 64429.020546093721, + 64450.26409232981, + 64471.509389239291, + 64492.756436533709, + 64514.005233924705, + 64535.255781124033, + 64556.50807784358, + 64577.762123795357, + 64599.017918691468, + 64620.275462244172, + 64641.534754165805, + 64662.795794168844, + 64684.058581965895, + 64705.323117269661, + 64726.589399792974, + 64747.857429248776, + 64769.127205350138, + 64790.398727810236, + 64811.671996342375, + 64832.947010659969, + 64854.223770476558, + 64875.502275505794, + 64896.782525461451, + 64918.064520057414, + 64939.348259007682, + 64960.633742026388, + 64981.920968827762, + 65003.209939126165, + 65024.500652636067, + 65045.793109072067, + 65067.087308148861, + 65088.383249581282, + 65109.680933084259, + 65130.980358372864, + 65152.28152516226, + 65173.584433167736, + 65194.889082104703, + 65216.195471688683, + 65237.503601635319, + 65258.813471660353, + 65280.125081479666, + 65301.438430809241, + 65322.753519365178, + 65344.070346863708, + 65365.388913021146, + 65386.709217553958, + 65408.031260178701, + 65429.355040612056, + 65450.680558570821, + 65472.00781377191, + 65493.336805932355, + 65514.66753476928, + 65535.999999999956, + 65557.334201341757, + 65578.670138512171, + 65600.007811228788, + 65621.347219209332, + 65642.688362171626, + 65664.031239833639, + 65685.375851913413, + 65706.722198129137, + 65728.070278199084, + 65749.420091841661, + 65770.771638775404, + 65792.124918718939, + 65813.479931391004, + 65834.836676510458, + 65856.195153796303, + 65877.5553629676, + 65898.917303743554, + 65920.280975843489, + 65941.646378986843, + 65963.013512893158, + 65984.382377282076, + 66005.752971873386, + 66027.125296386963, + 66048.499350542799, + 66069.875134061018, + 66091.252646661844, + 66112.631888065618, + 66134.01285799277, + 66155.395556163887, + 66176.779982299631, + 66198.166136120795, + 66219.554017348273, + 66240.943625703105, + 66262.334960906388, + 66283.728022679396, + 66305.122810743444, + 66326.519324820023, + 66347.917564630698, + 66369.317529897162, + 66390.719220341227, + 66412.122635684791, + 66433.527775649884, + 66454.934639958636, + 66476.343228333324, + 66497.753540496284, + 66519.165576169995, + 66540.57933507704, + 66561.994816940118, + 66583.412021482043, + 66604.830948425733, + 66626.251597494222, + 66647.673968410629, + 66669.098060898235, + 66690.523874680381, + 66711.951409480564, + 66733.380665022371, + 66754.811641029475, + 66776.244337225711, + 66797.678753334985, + 66819.11488908132, + 66840.552744188884, + 66861.992318381905, + 66883.433611384738, + 66904.876622921889, + 66926.321352717903, + 66947.767800497502, + 66969.215965985466, + 66990.665848906734, + 67012.117448986304, + 67033.570765949335, + 67055.025799521056, + 67076.482549426815, + 67097.941015392076, + 67119.401197142433, + 67140.863094403554, + 67162.326706901222, + 67183.792034361351, + 67205.259076509959, + 67226.72783307315, + 67248.198303777172, + 67269.670488348347, + 67291.144386513144, + 67312.619997998088, + 67334.09732252988, + 67355.576359835293, + 67377.057109641188, + 67398.53957167457, + 67420.023745662547, + 67441.50963133233, + 67462.99722841123, + 67484.486536626689, + 67505.977555706224, + 67527.470285377494, + 67548.964725368263, + 67570.460875406367, + 67591.9587352198, + 67613.458304536631, + 67634.95958308503, + 67656.462570593329, + 67677.967266789899, + 67699.473671403248, + 67720.981784162024, + 67742.491604794923, + 67764.003133030797, + 67785.516368598575, + 67807.031311227314, + 67828.547960646174, + 67850.066316584402, + 67871.58637877139, + 67893.108146936589, + 67914.63162080961, + 67936.156800120138, + 67957.683684597971, + 67979.212273973011, + 68000.742567975263, + 68022.274566334876, + 68043.808268782057, + 68065.343675047145, + 68086.880784860579, + 68108.419597952918, + 68129.960114054789, + 68151.502332896969, + 68173.04625421032, + 68194.591877725834, + 68216.139203174564, + 68237.688230287706, + 68259.238958796544, + 68280.791388432481, + 68302.345518927032, + 68323.901350011787, + 68345.458881418483, + 68367.018112878912, + 68388.579044125028, + 68410.141674888844, + 68431.706004902502, + 68453.272033898262, + 68474.839761608455, + 68496.409187765545, + 68517.980312102081, + 68539.553134350732, + 68561.127654244279, + 68582.70387151558, + 68604.281785897634, + 68625.861397123503, + 68647.44270492639, + 68669.025709039604, + 68690.610409196524, + 68712.196805130661, + 68733.784896575627, + 68755.374683265123, + 68776.966164932994, + 68798.559341313128, + 68820.154212139591, + 68841.750777146473, + 68863.349036068044, + 68884.948988638629, + 68906.550634592684, + 68928.153973664739, + 68949.75900558944, + 68971.365730101577, + 68992.974146935987, + 69014.584255827634, + 69036.196056511588, + 69057.809548723017, + 69079.424732197207, + 69101.041606669532, + 69122.660171875468, + 69144.280427550606, + 69165.902373430625, + 69187.526009251334, + 69209.151334748618, + 69230.778349658474, + 69252.40705371699, + 69274.037446660412, + 69295.669528225, + 69317.303298147192, + 69338.938756163494, + 69360.575902010532, + 69382.214735425005, + 69403.855256143754, + 69425.497463903681, + 69447.141358441833, + 69468.78693949533, + 69490.434206801394, + 69512.083160097391, + 69533.733799120717, + 69555.386123608929, + 69577.04013329967, + 69598.695827930685, + 69620.353207239794, + 69642.012270964973, + 69663.67301884426, + 69685.335450615792, + 69706.999566017839, + 69728.665364788743, + 69750.332846666963, + 69772.002011391058, + 69793.672858699691, + 69815.345388331611, + 69837.019600025669, + 69858.695493520849, + 69880.373068556204, + 69902.052324870907, + 69923.733262204216, + 69945.415880295492, + 69967.100178884211, + 69988.786157709939, + 70010.473816512356, + 70032.163155031216, + 70053.854173006403, + 70075.546870177874, + 70097.241246285717, + 70118.937301070109, + 70140.635034271298, + 70162.334445629691, + 70184.035534885741, + 70205.738301780017, + 70227.442746053217, + 70249.1488674461, + 70270.856665699539, + 70292.566140554511, + 70314.277291752107, + 70335.990119033493, + 70357.704622139936, + 70379.420800812819, + 70401.138654793613, + 70422.85818382389, + 70444.579387645339, + 70466.302265999722, + 70488.026818628918, + 70509.753045274876, + 70531.480945679708, + 70553.210519585555, + 70574.941766734701, + 70596.674686869505, + 70618.409279732456, + 70640.145545066101, + 70661.883482613106, + 70683.623092116264, + 70705.364373318414, + 70727.107325962526, + 70748.851949791671, + 70770.598244549008, + 70792.346209977783, + 70814.095845821372, + 70835.847151823225, + 70857.600127726895, + 70879.354773276034, + 70901.111088214413, + 70922.869072285859, + 70944.628725234332, + 70966.390046803877, + 70988.153036738629, + 71009.917694782853, + 71031.684020680885, + 71053.45201417715, + 71075.221675016204, + 71096.993002942661, + 71118.765997701266, + 71140.540659036851, + 71162.316986694335, + 71184.09498041874, + 71205.874639955218, + 71227.655965048951, + 71249.438955445294, + 71271.223610889632, + 71293.009931127483, + 71314.797915904477, + 71336.587564966307, + 71358.378878058764, + 71380.171854927772, + 71401.966495319313, + 71423.762798979486, + 71445.560765654489, + 71467.360395090596, + 71489.161687034211, + 71510.964641231811, + 71532.769257429973, + 71554.575535375348, + 71576.383474814749, + 71598.19307549503, + 71620.004337163133, + 71641.817259566145, + 71663.631842451214, + 71685.4480855656, + 71707.26598865664, + 71729.085551471784, + 71750.906773758586, + 71772.729655264673, + 71794.554195737772, + 71816.380394925713, + 71838.208252576442, + 71860.037768437964, + 71881.868942258385, + 71903.701773785942, + 71925.536262768932, + 71947.372408955751, + 71969.210212094898, + 71991.049671934976, + 72012.890788224686, + 72034.73356071279, + 72056.577989148165, + 72078.424073279821, + 72100.271812856794, + 72122.121207628254, + 72143.97225734347, + 72165.824961751801, + 72187.679320602692, + 72209.53533364569, + 72231.393000630429, + 72253.252321306645, + 72275.113295424177, + 72296.975922732949, + 72318.840202982959, + 72340.706135924338, + 72362.573721307272, + 72384.442958882093, + 72406.313848399179, + 72428.186389609036, + 72450.060582262216, + 72471.936426109431, + 72493.813920901433, + 72515.693066389096, + 72537.573862323392, + 72559.456308455352, + 72581.340404536139, + 72603.226150316987, + 72625.113545549248, + 72647.002589984331, + 72668.893283373764, + 72690.785625469172, + 72712.679616022273, + 72734.575254784853, + 72756.472541508803, + 72778.371475946144, + 72800.272057848939, + 72822.174286969355, + 72844.07816305969, + 72865.983685872285, + 72887.890855159596, + 72909.799670674183, + 72931.710132168693, + 72953.622239395845, + 72975.535992108475, + 72997.451390059519, + 73019.368433001961, + 73041.287120688925, + 73063.207452873612, + 73085.129429309294, + 73107.053049749389, + 73128.978313947344, + 73150.905221656736, + 73172.833772631217, + 73194.763966624567, + 73216.695803390612, + 73238.62928268328, + 73260.564404256627, + 73282.501167864757, + 73304.439573261901, + 73326.379620202337, + 73348.321308440485, + 73370.264637730841, + 73392.209607827957, + 73414.156218486532, + 73436.104469461323, + 73458.054360507173, + 73480.005891379056, + 73501.959061831993, + 73523.913871621116, + 73545.870320501665, + 73567.828408228932, + 73589.78813455833, + 73611.749499245358, + 73633.712502045615, + 73655.677142714747, + 73677.643421008557, + 73699.611336682879, + 73721.580889493693, + 73743.552079197019, + 73765.524905548999, + 73787.499368305856, + 73809.475467223907, + 73831.453202059551, + 73853.432572569291, + 73875.413578509717, + 73897.396219637507, + 73919.380495709411, + 73941.36640648231, + 73963.353951713143, + 73985.343131158952, + 74007.333944576865, + 74029.326391724098, + 74051.320472357969, + 74073.316186235883, + 74095.313533115303, + 74117.312512753837, + 74139.313124909138, + 74161.315369338976, + 74183.319245801191, + 74205.324754053727, + 74227.331893854629, + 74249.340664961986, + 74271.351067134034, + 74293.363100129049, + 74315.376763705441, + 74337.392057621662, + 74359.408981636298, + 74381.427535508003, + 74403.447718995507, + 74425.469531857671, + 74447.492973853383, + 74469.518044741693, + 74491.54474428168, + 74513.573072232539, + 74535.603028353551, + 74557.634612404087, + 74579.667824143602, + 74601.702663331642, + 74623.739129727837, + 74645.777223091936, + 74667.816943183716, + 74689.858289763113, + 74711.901262590094, + 74733.945861424741, + 74755.992086027225, + 74778.039936157802, + 74800.089411576817, + 74822.140512044702, + 74844.193237321961, + 74866.24758716923, + 74888.303561347187, + 74910.36115961663, + 74932.420381738411, + 74954.481227473516, + 74976.543696582972, + 74998.607788827925, + 75020.673503969607, + 75042.740841769322, + 75064.809801988464, + 75086.88038438854, + 75108.952588731103, + 75131.026414777836, + 75153.101862290467, + 75175.178931030852, + 75197.257620760924, + 75219.33793124267, + 75241.419862238225, + 75263.503413509738, + 75285.588584819503, + 75307.675375929874, + 75329.763786603318, + 75351.853816602365, + 75373.945465689612, + 75396.038733627807, + 75418.133620179724, + 75440.230125108254, + 75462.32824817636, + 75484.427989147109, + 75506.529347783653, + 75528.63232384919, + 75550.736917107075, + 75572.843127320695, + 75594.950954253538, + 75617.060397669193, + 75639.171457331307, + 75661.284133003646, + 75683.398424450032, + 75705.514331434402, + 75727.631853720741, + 75749.750991073175, + 75771.871743255862, + 75793.994110033076, + 75816.118091169177, + 75838.243686428585, + 75860.370895575848, + 75882.499718375562, + 75904.630154592422, + 75926.762203991224, + 75948.895866336825, + 75971.031141394182, + 75993.168028928325, + 76015.306528704401, + 76037.4466404876, + 76059.588364043215, + 76081.731699136653, + 76103.876645533353, + 76126.023202998884, + 76148.171371298871, + 76170.321150199044, + 76192.472539465205, + 76214.625538863256, + 76236.780148159174, + 76258.936367119008, + 76281.094195508922, + 76303.253633095141, + 76325.414679643975, + 76347.577334921851, + 76369.741598695226, + 76391.907470730686, + 76414.074950794879, + 76436.244038654564, + 76458.414734076548, + 76480.587036827754, + 76502.760946675175, + 76524.936463385893, + 76547.11358672705, + 76569.292316465915, + 76591.472652369819, + 76613.654594206164, + 76635.838141742468, + 76658.023294746308, + 76680.210052985349, + 76702.398416227341, + 76724.588384240138, + 76746.779956791637, + 76768.973133649866, + 76791.167914582897, + 76813.364299358902, + 76835.562287746157, + 76857.761879512967, + 76879.963074427797, + 76902.165872259109, + 76924.37027277553, + 76946.576275745727, + 76968.783880938441, + 76990.993088122515, + 77013.203897066895, + 77035.416307540567, + 77057.630319312622, + 77079.845932152239, + 77102.063145828695, + 77124.281960111301, + 77146.50237476948, + 77168.724389572759, + 77190.948004290723, + 77213.173218693031, + 77235.400032549442, + 77257.628445629802, + 77279.858457704031, + 77302.090068542122, + 77324.323277914169, + 77346.558085590339, + 77368.794491340886, + 77391.032494936138, + 77413.272096146524, + 77435.51329474253, + 77457.756090494731, + 77480.000483173804, + 77502.246472550498, + 77524.494058395634, + 77546.743240480107, + 77568.994018574944, + 77591.246392451198, + 77613.500361880026, + 77635.755926632657, + 77658.013086480438, + 77680.271841194757, + 77702.532190547092, + 77724.794134309021, + 77747.057672252195, + 77769.322804148323, + 77791.589529769248, + 77813.857848886837, + 77836.127761273063, + 77858.399266699998, + 77880.67236493979, + 77902.947055764627, + 77925.223338946831, + 77947.50121425878, + 77969.780681472927, + 77992.061740361838, + 78014.344390698127, + 78036.628632254491, + 78058.914464803747, + 78081.201888118725, + 78103.490901972415, + 78125.781506137821, + 78148.073700388064, + 78170.367484496339, + 78192.662858235926, + 78214.959821380166, + 78237.258373702498, + 78259.558514976452, + 78281.860244975614, + 78304.163563473659, + 78326.468470244363, + 78348.77496506153, + 78371.083047699125, + 78393.392717931114, + 78415.703975531578, + 78438.016820274701, + 78460.331251934695, + 78482.647270285903, + 78504.964875102727, + 78527.284066159627, + 78549.604843231195, + 78571.927206092048, + 78594.251154516911, + 78616.576688280606, + 78638.903807157985, + 78661.232510924034, + 78683.562799353778, + 78705.894672222363, + 78728.228129304945, + 78750.563170376859, + 78772.899795213423, + 78795.238003590101, + 78817.577795282399, + 78839.919170065928, + 78862.262127716356, + 78884.606668009452, + 78906.952790721043, + 78929.300495627045, + 78951.64978250346, + 78974.000651126378, + 78996.353101271932, + 79018.707132716358, + 79041.062745235977, + 79063.41993860717, + 79085.778712606436, + 79108.139067010285, + 79130.501001595389, + 79152.864516138419, + 79175.22961041618, + 79197.596284205531, + 79219.96453728342, + 79242.33436942687, + 79264.705780412987, + 79287.078770018954, + 79309.453338022009, + 79331.829484199508, + 79354.207208328866, + 79376.586510187582, + 79398.967389553218, + 79421.349846203433, + 79443.733879915948, + 79466.119490468584, + 79488.50667763922, + 79510.895441205823, + 79533.285780946433, + 79555.677696639163, + 79578.071188062226, + 79600.466254993895, + 79622.862897212515, + 79645.261114496549, + 79667.660906624471, + 79690.062273374875, + 79712.465214526455, + 79734.869729857935, + 79757.275819148126, + 79779.683482175955, + 79802.092718720378, + 79824.503528560454, + 79846.915911475327, + 79869.329867244203, + 79891.745395646343, + 79914.162496461155, + 79936.581169468045, + 79959.001414446553, + 79981.423231176261, + 80003.846619436852, + 80026.271579008084, + 80048.698109669771, + 80071.12621120183, + 80093.555883384237, + 80115.987125997053, + 80138.419938820414, + 80160.854321634528, + 80183.290274219689, + 80205.727796356281, + 80228.166887824715, + 80250.607548405547, + 80273.049777879336, + 80295.493576026798, + 80317.938942628651, + 80340.385877465727, + 80362.834380318949, + 80385.28445096928, + 80407.736089197788, + 80430.189294785596, + 80452.644067513917, + 80475.100407164035, + 80497.558313517322, + 80520.017786355209, + 80542.478825459213, + 80564.941430610925, + 80587.405601592007, + 80609.871338184195, + 80632.338640169342, + 80654.8075073293, + 80677.277939446067, + 80699.749936301683, + 80722.223497678278, + 80744.698623358039, + 80767.17531312324, + 80789.653566756242, + 80812.133384039465, + 80834.614764755403, + 80857.097708686648, + 80879.582215615854, + 80902.068285325731, + 80924.555917599093, + 80947.045112218824, + 80969.535868967869, + 80992.028187629272, + 81014.522067986123, + 81037.017509821613, + 81059.514512919006, + 81082.013077061609, + 81104.513202032831, + 81127.014887616184, + 81149.518133595193, + 81172.022939753486, + 81194.529305874807, + 81217.037231742899, + 81239.546717141639, + 81262.057761854958, + 81284.570365666848, + 81307.084528361403, + 81329.600249722775, + 81352.117529535186, + 81374.636367582949, + 81397.156763650448, + 81419.678717522125, + 81442.202228982511, + 81464.727297816222, + 81487.253923807933, + 81509.782106742379, + 81532.311846404409, + 81554.843142578902, + 81577.375995050839, + 81599.910403605274, + 81622.446368027333, + 81644.983888102215, + 81667.522963615178, + 81690.063594351581, + 81712.605780096841, + 81735.149520636449, + 81757.694815755967, + 81780.241665241047, + 81802.79006887741, + 81825.340026450824, + 81847.891537747171, + 81870.444602552379, + 81892.999220652477, + 81915.555391833506, + 81938.113115881672, + 81960.672392583176, + 81983.233221724338, + 82005.795603091537, + 82028.359536471224, + 82050.925021649906, + 82073.492058414209, + 82096.060646550788, + 82118.630785846399, + 82141.202476087841, + 82163.775717062032, + 82186.35050855593, + 82208.926850356569, + 82231.504742251054, + 82254.084184026578, + 82276.665175470393, + 82299.24771636985, + 82321.831806512317, + 82344.417445685307, + 82367.004633676348, + 82389.593370273054, + 82412.183655263143, + 82434.775488434374, + 82457.368869574595, + 82479.963798471697, + 82502.560274913689, + 82525.158298688606, + 82547.757869584602, + 82570.35898738986, + 82592.961651892678, + 82615.565862881398, + 82638.171620144421, + 82660.778923470265, + 82683.387772647475, + 82705.998167464713, + 82728.610107710658, + 82751.223593174116, + 82773.83862364394, + 82796.45519890904, + 82819.073318758441, + 82841.692982981185, + 82864.314191366429, + 82886.936943703375, + 82909.561239781324, + 82932.187079389638, + 82954.814462317736, + 82977.443388355125, + 83000.073857291369, + 83022.70586891612, + 83045.339423019104, + 83067.974519390089, + 83090.611157818959, + 83113.249338095629, + 83135.8890600101, + 83158.530323352461, + 83181.173127912858, + 83203.817473481497, + 83226.463359848669, + 83249.11078680474, + 83271.759754140134, + 83294.410261645375, + 83317.062309111003, + 83339.715896327703, + 83362.371023086147, + 83385.027689177165, + 83407.685894391587, + 83430.345638520361, + 83453.006921354478, + 83475.669742685001, + 83498.334102303095, + 83520.999999999942, + 83543.667435566866, + 83566.336408795192, + 83589.006919476349, + 83611.678967401851, + 83634.352552363242, + 83657.027674152167, + 83679.704332560359, + 83702.382527379552, + 83725.062258401638, + 83747.743525418511, + 83770.42632822218, + 83793.110666604684, + 83815.796540358162, + 83838.483949274829, + 83861.172893146941, + 83883.863371766842, + 83906.555384926964, + 83929.248932419752, + 83951.944014037799, + 83974.640629573696, + 83997.338778820151, + 84020.038461569929, + 84042.739677615857, + 84065.442426750829, + 84088.146708767847, + 84110.852523459922, + 84133.559870620171, + 84156.268750041796, + 84178.979161518029, + 84201.691104842204, + 84224.404579807713, + 84247.119586208006, + 84269.83612383662, + 84292.55419248715, + 84315.273791953281, + 84337.994922028738, + 84360.717582507335, + 84383.441773182945, + 84406.167493849513, + 84428.894744301069, + 84451.623524331691, + 84474.353833735542, + 84497.085672306828, + 84519.819039839858, + 84542.553936128999, + 84565.290360968676, + 84588.028314153402, + 84610.767795477717, + 84633.508804736295, + 84656.251341723822, + 84678.995406235073, + 84701.740998064924, + 84724.488117008252, + 84747.236762860062, + 84769.986935415407, + 84792.73863446941, + 84815.491859817252, + 84838.246611254188, + 84861.002888575575, + 84883.760691576768, + 84906.520020053256, + 84929.28087380057, + 84952.043252614312, + 84974.807156290146, + 84997.572584623806, + 85020.339537411113, + 85043.108014447949, + 85065.878015530237, + 85088.649540453989, + 85111.422589015303, + 85134.197161010321, + 85156.973256235244, + 85179.750874486374, + 85202.530015560071, + 85225.310679252725, + 85248.092865360857, + 85270.876573681016, + 85293.661804009811, + 85316.448556143951, + 85339.236829880188, + 85362.026625015351, + 85384.817941346351, + 85407.610778670132, + 85430.405136783724, + 85453.201015484257, + 85475.998414568865, + 85498.797333834795, + 85521.597773079353, + 85544.399732099904, + 85567.203210693886, + 85590.008208658808, + 85612.814725792239, + 85635.62276189182, + 85658.432316755265, + 85681.243390180331, + 85704.055981964877, + 85726.870091906807, + 85749.685719804082, + 85772.502865454764, + 85795.321528656961, + 85818.141709208852, + 85840.963406908675, + 85863.78662155474, + 85886.611352945445, + 85909.437600879217, + 85932.26536515457, + 85955.094645570091, + 85977.92544192441, + 86000.757754016275, + 86023.591581644432, + 86046.426924607746, + 86069.263782705122, + 86092.102155735556, + 86114.942043498071, + 86137.783445791807, + 86160.626362415918, + 86183.470793169676, + 86206.316737852379, + 86229.164196263402, + 86252.013168202204, + 86274.863653468303, + 86297.715651861261, + 86320.569163180728, + 86343.424187226425, + 86366.280723798132, + 86389.138772695675, + 86411.998333718977, + 86434.859406668009, + 86457.721991342827, + 86480.586087543532, + 86503.451695070296, + 86526.318813723352, + 86549.187443303032, + 86572.057583609683, + 86594.929234443756, + 86617.802395605773, + 86640.677066896271, + 86663.553248115903, + 86686.43093906538, + 86709.310139545443, + 86732.190849356964, + 86755.073068300815, + 86777.956796177954, + 86800.842032789442, + 86823.728777936354, + 86846.617031419853, + 86869.506793041175, + 86892.398062601613, + 86915.290839902518, + 86938.185124745316, + 86961.080916931489, + 86983.978216262592, + 87006.87702254027, + 87029.777335566177, + 87052.67915514209, + 87075.582481069796, + 87098.487313151185, + 87121.39365118822, + 87144.301494982894, + 87167.210844337285, + 87190.121699053532, + 87213.034058933845, + 87235.947923780506, + 87258.863293395829, + 87281.780167582241, + 87304.698546142172, + 87327.618428878181, + 87350.539815592856, + 87373.462706088845, + 87396.387100168897, + 87419.312997635774, + 87442.240398292357, + 87465.16930194154, + 87488.099708386319, + 87511.031617429733, + 87533.965028874911, + 87556.899942525008, + 87579.836358183282, + 87602.774275653021, + 87625.713694737613, + 87648.654615240492, + 87671.597036965148, + 87694.540959715145, + 87717.486383294105, + 87740.433307505737, + 87763.381732153779, + 87786.331657042057, + 87809.283081974456, + 87832.236006754916, + 87855.190431187453, + 87878.146355076155, + 87901.103778225151, + 87924.062700438633, + 87947.023121520891, + 87969.985041276246, + 87992.948459509105, + 88015.913376023906, + 88038.879790625171, + 88061.847703117513, + 88084.817113305573, + 88107.788020994049, + 88130.760425987726, + 88153.734328091465, + 88176.709727110137, + 88199.686622848749, + 88222.665015112303, + 88245.644903705906, + 88268.626288434709, + 88291.609169103947, + 88314.593545518903, + 88337.579417484914, + 88360.566784807408, + 88383.555647291854, + 88406.546004743795, + 88429.537856968818, + 88452.531203772611, + 88475.52604496089, + 88498.522380339447, + 88521.52020971413, + 88544.519532890874, + 88567.520349675644, + 88590.522659874507, + 88613.526463293543, + 88636.531759738922, + 88659.538549016899, + 88682.546830933745, + 88705.556605295846, + 88728.567871909589, + 88751.580630581491, + 88774.594881118086, + 88797.610623325963, + 88820.62785701183, + 88843.646581982393, + 88866.666798044462, + 88889.688505004888, + 88912.711702670611, + 88935.7363908486, + 88958.762569345898, + 88981.790237969632, + 89004.81939652696, + 89027.850044825114, + 89050.882182671412, + 89073.9158098732, + 89096.950926237885, + 89119.987531572973, + 89143.025625686001, + 89166.065208384563, + 89189.106279476357, + 89212.148838769106, + 89235.192886070581, + 89258.238421188667, + 89281.285443931265, + 89304.333954106376, + 89327.383951522017, + 89350.435435986306, + 89373.488407307406, + 89396.542865293537, + 89419.598809753006, + 89442.656240494165, + 89465.715157325409, + 89488.775560055219, + 89511.837448492137, + 89534.900822444746, + 89557.965681721733, + 89581.032026131812, + 89604.099855483742, + 89627.169169586399, + 89650.239968248672, + 89673.312251279538, + 89696.386018488018, + 89719.461269683205, + 89742.53800467425, + 89765.616223270365, + 89788.69592528083, + 89811.777110514988, + 89834.859778782207, + 89857.943929891975, + 89881.029563653807, + 89904.116679877261, + 89927.205278372014, + 89950.29535894774, + 89973.386921414218, + 89996.479965581268, + 90019.574491258769, + 90042.670498256688, + 90065.767986385021, + 90088.866955453836, + 90111.967405273259, + 90135.069335653476, + 90158.172746404758, + 90181.277637337407, + 90204.384008261797, + 90227.49185898836, + 90250.601189327586, + 90273.711999090039, + 90296.824288086325, + 90319.938056127125, + 90343.053303023189, + 90366.170028585286, + 90389.288232624298, + 90412.407914951138, + 90435.529075376777, + 90458.651713712257, + 90481.775829768681, + 90504.901423357209, + 90528.028494289058, + 90551.157042375504, + 90574.287067427911, + 90597.418569257643, + 90620.551547676194, + 90643.686002495073, + 90666.821933525847, + 90689.959340580186, + 90713.098223469773, + 90736.238582006365, + 90759.380416001804, + 90782.523725267951, + 90805.668509616764, + 90828.814768860233, + 90851.962502810435, + 90875.11171127946, + 90898.262394079517, + 90921.414551022855, + 90944.568181921743, + 90967.72328658856, + 90990.879864835719, + 91014.037916475718, + 91037.19744132107, + 91060.358439184391, + 91083.520909878338, + 91106.684853215629, + 91129.850269009039, + 91153.017157071401, + 91176.185517215621, + 91199.355349254649, + 91222.526653001492, + 91245.699428269247, + 91268.873674871036, + 91292.049392620058, + 91315.226581329553, + 91338.405240812834, + 91361.585370883287, + 91384.766971354344, + 91407.950042039476, + 91431.134582752245, + 91454.320593306256, + 91477.508073515171, + 91500.697023192712, + 91523.887442152685, + 91547.07933020893, + 91570.272687175326, + 91593.467512865856, + 91616.663807094534, + 91639.861569675442, + 91663.060800422725, + 91686.261499150554, + 91709.463665673218, + 91732.66729980502, + 91755.872401360321, + 91779.078970153569, + 91802.287005999257, + 91825.49650871192, + 91848.707478106167, + 91871.91991399668, + 91895.133816198169, + 91918.349184525418, + 91941.566018793281, + 91964.784318816659, + 91988.004084410495, + 92011.22531538982, + 92034.448011569708, + 92057.672172765277, + 92080.897798791746, + 92104.124889464365, + 92127.353444598411, + 92150.58346400928, + 92173.814947512379, + 92197.04789492322, + 92220.282306057314, + 92243.518180730272, + 92266.755518757753, + 92289.994319955469, + 92313.234584139194, + 92336.476311124774, + 92359.719500728082, + 92382.964152765067, + 92406.210267051734, + 92429.457843404161, + 92452.706881638471, + 92475.957381570814, + 92499.209343017443, + 92522.462765794655, + 92545.717649718805, + 92568.973994606305, + 92592.231800273614, + 92615.491066537259, + 92638.751793213814, + 92662.01398011994, + 92685.277627072326, + 92708.54273388772, + 92731.809300382942, + 92755.077326374871, + 92778.346811680414, + 92801.617756116568, + 92824.890159500384, + 92848.164021648947, + 92871.439342379424, + 92894.716121509016, + 92917.994358855023, + 92941.274054234746, + 92964.555207465572, + 92987.837818364962, + 93011.121886750407, + 93034.407412439468, + 93057.694395249753, + 93080.982834998955, + 93104.272731504767, + 93127.564084584999, + 93150.856894057491, + 93174.15115974014, + 93197.446881450916, + 93220.744059007804, + 93244.04269222889, + 93267.342780932304, + 93290.644324936235, + 93313.947324058914, + 93337.251778118633, + 93360.557686933767, + 93383.865050322696, + 93407.173868103928, + 93430.484140095941, + 93453.795866117362, + 93477.109045986799, + 93500.423679522952, + 93523.739766544561, + 93547.057306870454, + 93570.376300319491, + 93593.696746710571, + 93617.018645862699, + 93640.341997594893, + 93663.666801726242, + 93686.993058075881, + 93710.320766463032, + 93733.64992670693, + 93756.980538626914, + 93780.312602042337, + 93803.646116772637, + 93826.981082637285, + 93850.317499455836, + 93873.655367047861, + 93896.994685233032, + 93920.335453831038, + 93943.677672661666, + 93967.021341544707, + 93990.366460300051, + 94013.713028747632, + 94037.061046707429, + 94060.410513999494, + 94083.761430443905, + 94107.113795860845, + 94130.467610070496, + 94153.822872893157, + 94177.179584149111, + 94200.537743658759, + 94223.897351242529, + 94247.25840672091, + 94270.620909914433, + 94293.98486064373, + 94317.350258729421, + 94340.71710399224, + 94364.085396252936, + 94387.455135332348, + 94410.82632105134, + 94434.198953230851, + 94457.573031691878, + 94480.948556255447, + 94504.325526742658, + 94527.70394297468, + 94551.083804772716, + 94574.465111958023, + 94597.847864351934, + 94621.232061775823, + 94644.617704051096, + 94668.004790999272, + 94691.393322441872, + 94714.783298200506, + 94738.174718096794, + 94761.567581952477, + 94784.961889589307, + 94808.357640829097, + 94831.754835493703, + 94855.153473405066, + 94878.553554385173, + 94901.955078256055, + 94925.358044839784, + 94948.762453958523, + 94972.168305434476, + 94995.575599089891, + 95018.984334747074, + 95042.394512228391, + 95065.806131356265, + 95089.219191953176, + 95112.633693841635, + 95136.04963684424, + 95159.467020783617, + 95182.885845482466, + 95206.306110763529, + 95229.727816449609, + 95253.150962363579, + 95276.575548328314, + 95300.001574166803, + 95323.429039702052, + 95346.857944757154, + 95370.288289155214, + 95393.720072719429, + 95417.153295273019, + 95440.587956639298, + 95464.024056641589, + 95487.461595103305, + 95510.900571847902, + 95534.340986698866, + 95557.782839479783, + 95581.226130014256, + 95604.670858125959, + 95628.117023638595, + 95651.564626375985, + 95675.013666161918, + 95698.464142820303, + 95721.916056175076, + 95745.369406050231, + 95768.824192269807, + 95792.280414657915, + 95815.738073038709, + 95839.197167236387, + 95862.657697075221, + 95886.11966237954, + 95909.583062973688, + 95933.047898682111, + 95956.514169329268, + 95979.981874739708, + 96003.451014738006, + 96026.921589148798, + 96050.393597796792, + 96073.867040506724, + 96097.341917103375, + 96120.818227411626, + 96144.295971256375, + 96167.775148462577, + 96191.255758855244, + 96214.737802259449, + 96238.221278500292, + 96261.70618740299, + 96285.192528792715, + 96308.680302494788, + 96332.169508334526, + 96355.660146137321, + 96379.152215728609, + 96402.645716933868, + 96426.14064957868, + 96449.637013488609, + 96473.134808489311, + 96496.63403440651, + 96520.134691065963, + 96543.636778293469, + 96567.140295914898, + 96590.645243756153, + 96614.151621643221, + 96637.659429402134, + 96661.168666858954, + 96684.679333839798, + 96708.191430170875, + 96731.70495567839, + 96755.219910188665, + 96778.736293528011, + 96802.254105522836, + 96825.77334599958, + 96849.29401478474, + 96872.816111704873, + 96896.339636586577, + 96919.864589256511, + 96943.390969541389, + 96966.918777267958, + 96990.448012263048, + 97013.978674353522, + 97037.510763366285, + 97061.044279128328, + 97084.579221466673, + 97108.115590208385, + 97131.653385180587, + 97155.19260621049, + 97178.733253125291, + 97202.2753257523, + 97225.81882391886, + 97249.363747452342, + 97272.910096180189, + 97296.457869929916, + 97320.007068529041, + 97343.557691805196, + 97367.109739586012, + 97390.663211699197, + 97414.218107972498, + 97437.774428233737, + 97461.332172310766, + 97484.891340031507, + 97508.451931223899, + 97532.013945715982, + 97555.577383335811, + 97579.142243911512, + 97602.708527271257, + 97626.276233243261, + 97649.845361655811, + 97673.415912337223, + 97696.987885115886, + 97720.561279820206, + 97744.1360962787, + 97767.712334319876, + 97791.289993772341, + 97814.869074464703, + 97838.449576225685, + 97862.031498883996, + 97885.614842268449, + 97909.199606207883, + 97932.785790531183, + 97956.37339506732, + 97979.962419645264, + 98003.552864094076, + 98027.144728242856, + 98050.738011920766, + 98074.332714956996, + 98097.928837180807, + 98121.526378421506, + 98145.125338508456, + 98168.725717271067, + 98192.327514538789, + 98215.930730141132, + 98239.535363907664, + 98263.141415668011, + 98286.748885251814, + 98310.357772488816, + 98333.968077208759, + 98357.579799241488, + 98381.192938416847, + 98404.807494564782, + 98428.42346751524, + 98452.040857098269, + 98475.659663143917, + 98499.27988548232, + 98522.901523943656, + 98546.524578358163, + 98570.149048556093, + 98593.774934367786, + 98617.402235623624, + 98641.030952154048, + 98664.661083789513, + 98688.292630360564, + 98711.925591697771, + 98735.559967631794, + 98759.195757993293, + 98782.832962613014, + 98806.471581321734, + 98830.111613950285, + 98853.753060329575, + 98877.39592029051, + 98901.040193664099, + 98924.68588028138, + 98948.33297997342, + 98971.981492571387, + 98995.63141790645, + 99019.282755809851, + 99042.935506112874, + 99066.589668646877, + 99090.245243243233, + 99113.902229733401, + 99137.560627948857, + 99161.220437721131, + 99184.881658881859, + 99208.544291262631, + 99232.208334695169, + 99255.87378901121, + 99279.540654042547, + 99303.208929621018, + 99326.878615578535, + 99350.549711746993, + 99374.222217958435, + 99397.896134044888, + 99421.571459838422, + 99445.248195171211, + 99468.926339875441, + 99492.605893783344, + 99516.286856727209, + 99539.969228539398, + 99563.653009052287, + 99587.338198098325, + 99611.024795510006, + 99634.712801119866, + 99658.402214760499, + 99682.093036264545, + 99705.785265464699, + 99729.478902193689, + 99753.173946284325, + 99776.870397569437, + 99800.56825588191, + 99824.267521054688, + 99847.968192920773, + 99871.670271313182, + 99895.373756065004, + 99919.078647009388, + 99942.78494397951, + 99966.492646808634, + 99990.20175533001, + 100013.91226937699, + 100037.62418878295, + 100061.33751338134, + 100085.05224300563, + 100108.76837748935, + 100132.4859166661, + 100156.2048603695, + 100179.92520843323, + 100203.64696069101, + 100227.37011697664, + 100251.09467712394, + 100274.82064096678, + 100298.54800833909, + 100322.27677907483, + 100346.00695300807, + 100369.73852997283, + 100393.47150980328, + 100417.20589233354, + 100440.94167739789, + 100464.67886483055, + 100488.41745446586, + 100512.1574461382, + 100535.89883968196, + 100559.64163493161, + 100583.38583172169, + 100607.13142988674, + 100630.87842926137, + 100654.62682968024, + 100678.37663097809, + 100702.12783298964, + 100725.88043554971, + 100749.63443849317, + 100773.38984165489, + 100797.14664486986, + 100820.90484797307, + 100844.66445079957, + 100868.42545318443, + 100892.18785496285, + 100915.95165596998, + 100939.71685604109, + 100963.48345501146, + 100987.25145271645, + 101011.02084899142, + 101034.79164367182, + 101058.56383659317, + 101082.33742759094, + 101106.11241650078, + 101129.88880315828, + 101153.66658739912, + 101177.44576905905, + 101201.22634797383, + 101225.00832397929, + 101248.7916969113, + 101272.57646660579, + 101296.36263289873, + 101320.15019562612, + 101343.93915462404, + 101367.7295097286, + 101391.52126077596, + 101415.31440760233, + 101439.10895004397, + 101462.9048879372, + 101486.70222111834, + 101510.50094942382, + 101534.30107269008, + 101558.10259075361, + 101581.90550345098, + 101605.70981061876, + 101629.5155120936, + 101653.32260771218, + 101677.13109731126, + 101700.9409807276, + 101724.75225779804, + 101748.56492835947, + 101772.37899224881, + 101796.19444930303, + 101820.01129935916, + 101843.82954225427, + 101867.64917782549, + 101891.47020590997, + 101915.29262634492, + 101939.11643896763, + 101962.94164361537, + 101986.76824012553, + 102010.59622833549, + 102034.42560808272, + 102058.25637920471, + 102082.08854153901, + 102105.9220949232, + 102129.75703919494, + 102153.59337419191, + 102177.43109975185, + 102201.27021571253, + 102225.1107219118, + 102248.95261818753, + 102272.79590437764, + 102296.64058032009, + 102320.48664585294, + 102344.33410081422, + 102368.18294504205, + 102392.03317837461, + 102415.88480065008, + 102439.73781170673, + 102463.59221138287, + 102487.44799951684, + 102511.30517594704, + 102535.1637405119, + 102559.02369304992, + 102582.88503339965, + 102606.74776139967, + 102630.61187688859, + 102654.4773797051, + 102678.34426968795, + 102702.21254667587, + 102726.08221050771, + 102749.95326102231, + 102773.8256980586, + 102797.69952145554, + 102821.57473105213, + 102845.45132668741, + 102869.32930820051, + 102893.20867543056, + 102917.08942821674, + 102940.97156639832, + 102964.85508981455, + 102988.73999830478, + 103012.6262917084, + 103036.51396986481, + 103060.40303261351, + 103084.293479794, + 103108.18531124585, + 103132.07852680866, + 103155.97312632212, + 103179.8691096259, + 103203.76647655977, + 103227.66522696352, + 103251.56536067701, + 103275.46687754011, + 103299.36977739276, + 103323.27406007495, + 103347.1797254267, + 103371.0867732881, + 103394.99520349925, + 103418.90501590034, + 103442.81621033157, + 103466.72878663319, + 103490.64274464553, + 103514.55808420894, + 103538.4748051638, + 103562.39290735057, + 103586.31239060973, + 103610.23325478184, + 103634.15549970744, + 103658.07912522719, + 103682.00413118176, + 103705.93051741188, + 103729.85828375829, + 103753.78743006183, + 103777.71795616332, + 103801.64986190372, + 103825.58314712394, + 103849.51781166498, + 103873.4538553679, + 103897.39127807376, + 103921.33007962372, + 103945.27025985894, + 103969.21181862066, + 103993.15475575015, + 104017.0990710887, + 104041.0447644777, + 104064.99183575854, + 104088.94028477269, + 104112.89011136163, + 104136.84131536692, + 104160.79389663014, + 104184.74785499295, + 104208.70319029699, + 104232.65990238401, + 104256.61799109577, + 104280.57745627411, + 104304.53829776087, + 104328.50051539797, + 104352.46410902737, + 104376.42907849104, + 104400.39542363105, + 104424.36314428948, + 104448.33224030846, + 104472.3027115302, + 104496.27455779689, + 104520.24777895081, + 104544.22237483428, + 104568.19834528965, + 104592.17569015936, + 104616.15440928582, + 104640.13450251156, + 104664.1159696791, + 104688.09881063103, + 104712.08302520998, + 104736.06861325864, + 104760.05557461972, + 104784.043909136, + 104808.03361665027, + 104832.0246970054, + 104856.01715004431, + 104880.01097560991, + 104904.00617354522, + 104928.00274369326, + 104952.00068589712, + 104975.99999999993, + 105000.00068584486, + 105024.00274327511, + 105048.00617213396, + 105072.0109722647, + 105096.0171435107, + 105120.02468571534, + 105144.03359872208, + 105168.04388237436, + 105192.05553651576, + 105216.06856098982, + 105240.08295564017, + 105264.09872031047, + 105288.11585484444, + 105312.13435908582, + 105336.1542328784, + 105360.17547606604, + 105384.19808849262, + 105408.22207000206, + 105432.24742043833, + 105456.27413964548, + 105480.30222746753, + 105504.33168374863, + 105528.36250833291, + 105552.39470106458, + 105576.42826178786, + 105600.46319034706, + 105624.49948658649, + 105648.53715035053, + 105672.5761814836, + 105696.61657983017, + 105720.65834523473, + 105744.70147754184, + 105768.7459765961, + 105792.79184224214, + 105816.83907432464, + 105840.88767268835, + 105864.93763717801, + 105888.98896763846, + 105913.04166391456, + 105937.09572585119, + 105961.15115329332, + 105985.20794608595, + 106009.26610407409, + 106033.32562710284, + 106057.38651501729, + 106081.44876766266, + 106105.51238488412, + 106129.57736652695, + 106153.64371243643, + 106177.71142245791, + 106201.78049643678, + 106225.85093421848, + 106249.92273564848, + 106273.99590057228, + 106298.07042883546, + 106322.14632028362, + 106346.22357476239, + 106370.30219211751, + 106394.38217219469, + 106418.46351483969, + 106442.54621989837, + 106466.63028721658, + 106490.71571664025, + 106514.80250801529, + 106538.89066118775, + 106562.98017600364, + 106587.07105230905, + 106611.16328995011, + 106635.25688877302, + 106659.35184862395, + 106683.44816934918, + 106707.54585079502, + 106731.64489280782, + 106755.74529523395, + 106779.84705791986, + 106803.95018071201, + 106828.05466345693, + 106852.16050600118, + 106876.26770819137, + 106900.37626987413, + 106924.48619089619, + 106948.59747110425, + 106972.71011034511, + 106996.82410846559, + 107020.93946531253, + 107045.05618073288, + 107069.17425457356, + 107093.29368668159, + 107117.41447690397, + 107141.53662508781, + 107165.66013108024, + 107189.7849947284, + 107213.91121587952, + 107238.03879438085, + 107262.16773007967, + 107286.29802282334, + 107310.42967245923, + 107334.56267883476, + 107358.69704179741, + 107382.83276119467, + 107406.96983687414, + 107431.10826868335, + 107455.24805646999, + 107479.38920008171, + 107503.53169936626, + 107527.67555417139, + 107551.82076434491, + 107575.96732973469, + 107600.11525018861, + 107624.26452555459, + 107648.41515568066, + 107672.56714041479, + 107696.72047960508, + 107720.87517309963, + 107745.03122074658, + 107769.18862239413, + 107793.34737789053, + 107817.50748708403, + 107841.66894982298, + 107865.83176595572, + 107889.99593533068, + 107914.16145779629, + 107938.32833320105, + 107962.49656139348, + 107986.66614222217, + 108010.83707553572, + 108035.00936118282, + 108059.18299901215, + 108083.35798887245, + 108107.53433061253, + 108131.71202408121, + 108155.89106912735, + 108180.07146559987, + 108204.25321334775, + 108228.43631221994, + 108252.62076206553, + 108276.80656273357, + 108300.99371407321, + 108325.18221593359, + 108349.37206816394, + 108373.56327061349, + 108397.75582313156, + 108421.94972556747, + 108446.1449777706, + 108470.34157959036, + 108494.53953087622, + 108518.73883147769, + 108542.93948124432, + 108567.14148002568, + 108591.34482767139, + 108615.54952403114, + 108639.75556895464, + 108663.96296229165, + 108688.17170389196, + 108712.38179360541, + 108736.59323128188, + 108760.80601677128, + 108785.02014992358, + 108809.23563058881, + 108833.45245861699, + 108857.67063385822, + 108881.89015616261, + 108906.11102538036, + 108930.33324136167, + 108954.55680395682, + 108978.78171301607, + 109003.00796838976, + 109027.23556992831, + 109051.46451748211, + 109075.69481090162, + 109099.92645003737, + 109124.15943473989, + 109148.39376485976, + 109172.62944024763, + 109196.86646075416, + 109221.10482623006, + 109245.34453652608, + 109269.58559149304, + 109293.82799098175, + 109318.07173484311, + 109342.31682292801, + 109366.56325508743, + 109390.81103117237, + 109415.06015103387, + 109439.31061452301, + 109463.56242149093, + 109487.8155717888, + 109512.07006526781, + 109536.3259017792, + 109560.58308117429, + 109584.8416033044, + 109609.1014680209, + 109633.36267517522, + 109657.62522461878, + 109681.88911620311, + 109706.15434977971, + 109730.4209252002, + 109754.68884231619, + 109778.95810097932, + 109803.22870104131, + 109827.50064235389, + 109851.77392476884, + 109876.04854813802, + 109900.32451231324, + 109924.60181714644, + 109948.88046248957, + 109973.1604481946, + 109997.44177411357, + 110021.72444009855, + 110046.00844600165, + 110070.29379167501, + 110094.58047697082, + 110118.86850174134, + 110143.15786583882, + 110167.44856911557, + 110191.74061142397, + 110216.03399261639, + 110240.32871254528, + 110264.62477106311, + 110288.9221680224, + 110313.22090327571, + 110337.52097667565, + 110361.82238807483, + 110386.12513732594, + 110410.42922428172, + 110434.73464879491, + 110459.04141071832, + 110483.34950990479, + 110507.6589462072, + 110531.96971947847, + 110556.28182957157, + 110580.5952763395, + 110604.91005963532, + 110629.22617931209, + 110653.54363522294, + 110677.86242722106, + 110702.18255515963, + 110726.50401889188, + 110750.82681827113, + 110775.1509531507, + 110799.47642338395, + 110823.80322882428, + 110848.13136932514, + 110872.46084474004, + 110896.79165492248, + 110921.12379972603, + 110945.4572790043, + 110969.79209261097, + 110994.12824039967, + 111018.46572222417, + 111042.80453793822, + 111067.14468739564, + 111091.48617045028, + 111115.82898695602, + 111140.1731367668, + 111164.51861973655, + 111188.86543571933, + 111213.21358456917, + 111237.56306614014, + 111261.91388028639, + 111286.26602686207, + 111310.61950572141, + 111334.97431671864, + 111359.33045970804, + 111383.68793454397, + 111408.04674108078, + 111432.40687917286, + 111456.76834867468, + 111481.13114944073, + 111505.49528132551, + 111529.86074418361, + 111554.22753786964, + 111578.59566223821, + 111602.96511714405, + 111627.33590244185, + 111651.7080179864, + 111676.08146363248, + 111700.45623923496, + 111724.8323446487, + 111749.20977972864, + 111773.58854432974, + 111797.96863830699, + 111822.35006151545, + 111846.73281381019, + 111871.11689504632, + 111895.50230507903, + 111919.8890437635, + 111944.27711095495, + 111968.6665065087, + 111993.05723028004, + 112017.44928212435, + 112041.842661897, + 112066.23736945343, + 112090.63340464912, + 112115.03076733962, + 112139.42945738042, + 112163.82947462716, + 112188.23081893545, + 112212.63349016097, + 112237.03748815943, + 112261.44281278658, + 112285.84946389822, + 112310.25744135017, + 112334.66674499828, + 112359.07737469849, + 112383.48933030672, + 112407.90261167898, + 112432.31721867126, + 112456.73315113965, + 112481.15040894024, + 112505.56899192919, + 112529.98889996267, + 112554.41013289688, + 112578.8326905881, + 112603.25657289263, + 112627.68177966679, + 112652.10831076698, + 112676.53616604958, + 112700.96534537108, + 112725.39584858794, + 112749.82767555672, + 112774.26082613398, + 112798.6953001763, + 112823.13109754038, + 112847.56821808286, + 112872.00666166049, + 112896.44642813003, + 112920.88751734827, + 112945.32992917208, + 112969.77366345831, + 112994.21872006389, + 113018.66509884578, + 113043.11279966099, + 113067.56182236652, + 113092.01216681948, + 113116.46383287695, + 113140.9168203961, + 113165.37112923413, + 113189.82675924824, + 113214.28371029573, + 113238.74198223387, + 113263.20157492002, + 113287.66248821157, + 113312.12472196593, + 113336.58827604055, + 113361.05315029295, + 113385.51934458067, + 113409.98685876124, + 113434.45569269233, + 113458.92584623155, + 113483.39731923661, + 113507.87011156522, + 113532.34422307517, + 113556.81965362425, + 113581.2964030703, + 113605.77447127122, + 113630.25385808491, + 113654.73456336933, + 113679.2165869825, + 113703.69992878241, + 113728.18458862718, + 113752.67056637487, + 113777.15786188368, + 113801.64647501177, + 113826.13640561736, + 113850.62765355874, + 113875.12021869418, + 113899.61410088204, + 113924.1092999807, + 113948.60581584855, + 113973.10364834407, + 113997.60279732574, + 114022.1032626521, + 114046.60504418171, + 114071.10814177318, + 114095.61255528514, + 114120.11828457628, + 114144.62532950533, + 114169.13368993104, + 114193.6433657122, + 114218.15435670764, + 114242.66666277625, + 114267.18028377694, + 114291.69521956862, + 114316.21147001031, + 114340.72903496103, + 114365.24791427983, + 114389.7681078258, + 114414.2896154581, + 114438.81243703589, + 114463.33657241837, + 114487.8620214648, + 114512.38878403447, + 114536.91685998671, + 114561.44624918087, + 114585.97695147636, + 114610.5089667326, + 114635.04229480909, + 114659.57693556532, + 114684.11288886084, + 114708.65015455526, + 114733.18873250818, + 114757.72862257928, + 114782.26982462825, + 114806.81233851484, + 114831.35616409882, + 114855.90130123998, + 114880.44774979822, + 114904.99550963337, + 114929.5445806054, + 114954.09496257425, + 114978.64665539992, + 115003.19965894247, + 115027.75397306195, + 115052.30959761847, + 115076.86653247218, + 115101.42477748329, + 115125.984332512, + 115150.54519741859, + 115175.10737206334, + 115199.67085630659, + 115224.23565000873, + 115248.80175303014, + 115273.3691652313, + 115297.93788647266, + 115322.50791661476, + 115347.07925551817, + 115371.65190304347, + 115396.22585905129, + 115420.80112340231, + 115445.37769595724, + 115469.95557657682, + 115494.53476512182, + 115519.11526145306, + 115543.69706543141, + 115568.28017691776, + 115592.86459577303, + 115617.4503218582, + 115642.03735503425, + 115666.62569516223, + 115691.21534210323, + 115715.80629571836, + 115740.39855586876, + 115764.99212241563, + 115789.58699522018, + 115814.18317414368, + 115838.78065904744, + 115863.37944979276, + 115887.97954624105, + 115912.5809482537, + 115937.18365569216, + 115961.78766841792, + 115986.39298629249, + 116010.99960917742, + 116035.60753693432, + 116060.21676942479, + 116084.82730651053, + 116109.43914805322, + 116134.0522939146, + 116158.66674395646, + 116183.2824980406, + 116207.89955602887, + 116232.51791778316, + 116257.13758316539, + 116281.75855203751, + 116306.38082426153, + 116331.00439969949, + 116355.62927821343, + 116380.25545966547, + 116404.88294391775, + 116429.51173083246, + 116454.14182027178, + 116478.77321209799, + 116503.40590617337, + 116528.03990236025, + 116552.67520052097, + 116577.31180051794, + 116601.94970221359, + 116626.5889054704, + 116651.22941015086, + 116675.87121611751, + 116700.51432323294, + 116725.15873135976, + 116749.8044403606, + 116774.45145009817, + 116799.0997604352, + 116823.74937123443, + 116848.40028235866, + 116873.05249367072, + 116897.70600503348, + 116922.36081630984, + 116947.01692736275, + 116971.67433805518, + 116996.33304825013, + 117020.99305781067, + 117045.65436659988, + 117070.31697448085, + 117094.98088131678, + 117119.64608697082, + 117144.31259130624, + 117168.98039418629, + 117193.64949547425, + 117218.31989503348, + 117242.99159272734, + 117267.66458841923, + 117292.33888197262, + 117317.01447325097, + 117341.6913621178, + 117366.36954843666, + 117391.04903207115, + 117415.72981288488, + 117440.41189074152, + 117465.09526550474, + 117489.77993703831, + 117514.46590520597, + 117539.15316987153, + 117563.84173089883, + 117588.53158815173, + 117613.22274149416, + 117637.91519079007, + 117662.60893590341, + 117687.30397669821, + 117712.00031303853, + 117736.69794478847, + 117761.39687181212, + 117786.09709397367, + 117810.7986111373, + 117835.50142316725, + 117860.20552992777, + 117884.91093128319, + 117909.6176270978, + 117934.32561723603, + 117959.03490156225, + 117983.74547994092, + 118008.45735223651, + 118033.17051831353, + 118057.88497803656, + 118082.60073127014, + 118107.31777787894, + 118132.03611772758, + 118156.75575068076, + 118181.47667660323, + 118206.19889535972, + 118230.92240681504, + 118255.64721083404, + 118280.37330728157, + 118305.10069602253, + 118329.82937692189, + 118354.55934984458, + 118379.29061465565, + 118404.02317122012, + 118428.75701940308, + 118453.49215906965, + 118478.22859008498, + 118502.96631231424, + 118527.70532562268, + 118552.44562987552, + 118577.18722493808, + 118601.93011067568, + 118626.67428695368, + 118651.41975363747, + 118676.16651059251, + 118700.91455768423, + 118725.66389477813, + 118750.41452173979, + 118775.16643843475, + 118799.91964472862, + 118824.67414048707, + 118849.42992557574, + 118874.18699986035, + 118898.94536320666, + 118923.70501548045, + 118948.46595654752, + 118973.22818627374, + 118997.99170452499, + 119022.7565111672, + 119047.52260606633, + 119072.28998908834, + 119097.0586600993, + 119121.82861896523, + 119146.59986555226, + 119171.3723997265, + 119196.14622135412, + 119220.92133030134, + 119245.69772643436, + 119270.47540961947, + 119295.25437972297, + 119320.03463661121, + 119344.81618015055, + 119369.5990102074, + 119394.38312664822, + 119419.16852933947, + 119443.95521814766, + 119468.74319293935, + 119493.53245358112, + 119518.32299993958, + 119543.11483188139, + 119567.90794927324, + 119592.70235198183, + 119617.49803987393, + 119642.29501281632, + 119667.09327067583, + 119691.89281331931, + 119716.69364061367, + 119741.49575242582, + 119766.29914862274, + 119791.10382907141, + 119815.90979363887, + 119840.71704219218, + 119865.52557459843, + 119890.33539072477, + 119915.14649043836, + 119939.95887360642, + 119964.77254009615, + 119989.58748977486, + 120014.40372250983, + 120039.22123816841, + 120064.04003661797, + 120088.86011772591, + 120113.6814813597, + 120138.5041273868, + 120163.3280556747, + 120188.15326609099, + 120212.97975850321, + 120237.807532779, + 120262.63658878599, + 120287.46692639188, + 120312.29854546436, + 120337.13144587121, + 120361.9656274802, + 120386.80109015915, + 120411.63783377589, + 120436.47585819835, + 120461.31516329442, + 120486.15574893207, + 120510.99761497928, + 120535.84076130406, + 120560.68518777451, + 120585.53089425867, + 120610.3778806247, + 120635.22614674074, + 120660.07569247499, + 120684.92651769568, + 120709.77862227106, + 120734.63200606944, + 120759.48666895913, + 120784.3426108085, + 120809.19983148595, + 120834.05833085992, + 120858.91810879884, + 120883.77916517125, + 120908.64149984565, + 120933.5051126906, + 120958.37000357473, + 120983.23617236665, + 121008.10361893504, + 121032.97234314861, + 121057.84234487606, + 121082.71362398617, + 121107.58618034775, + 121132.46001382964, + 121157.33512430069, + 121182.21151162982, + 121207.08917568595, + 121231.96811633807, + 121256.84833345517, + 121281.72982690629, + 121306.61259656049, + 121331.49664228689, + 121356.38196395461, + 121381.26856143285, + 121406.15643459078, + 121431.04558329767, + 121455.93600742276, + 121480.82770683538, + 121505.72068140487, + 121530.61493100057, + 121555.51045549192, + 121580.40725474835, + 121605.30532863933, + 121630.20467703436, + 121655.10529980299, + 121680.00719681478, + 121704.91036793934, + 121729.81481304632, + 121754.72053200539, + 121779.62752468624, + 121804.53579095862, + 121829.44533069231, + 121854.3561437571, + 121879.26823002285, + 121904.1815893594, + 121929.09622163669, + 121954.01212672464, + 121978.92930449323, + 122003.84775481246, + 122028.76747755238, + 122053.68847258303, + 122078.61073977455, + 122103.53427899707, + 122128.45909012076, + 122153.38517301581, + 122178.31252755247, + 122203.24115360099, + 122228.17105103172, + 122253.10221971494, + 122278.03465952107, + 122302.96837032049, + 122327.90335198362, + 122352.83960438096, + 122377.777127383, + 122402.71592086025, + 122427.65598468333, + 122452.59731872278, + 122477.53992284928, + 122502.48379693348, + 122527.42894084606, + 122552.37535445779, + 122577.32303763942, + 122602.27199026172, + 122627.22221219557, + 122652.17370331181, + 122677.12646348133, + 122702.08049257506, + 122727.03579046397, + 122751.99235701906, + 122776.95019211136, + 122801.9092956119, + 122826.8696673918, + 122851.83130732219, + 122876.79421527422, + 122901.75839111909, + 122926.72383472799, + 122951.69054597223, + 122976.65852472307, + 123001.62777085182, + 123026.59828422987, + 123051.57006472857, + 123076.54311221937, + 123101.5174265737, + 123126.49300766307, + 123151.46985535898, + 123176.44796953299, + 123201.42735005668, + 123226.40799680166, + 123251.38990963959, + 123276.37308844214, + 123301.35753308103, + 123326.343243428, + 123351.33021935483, + 123376.31846073334, + 123401.30796743535, + 123426.29873933276, + 123451.29077629748, + 123476.28407820144, + 123501.2786449166, + 123526.27447631498, + 123551.27157226863, + 123576.26993264959, + 123601.26955732999, + 123626.27044618195, + 123651.27259907764, + 123676.27601588926, + 123701.28069648903, + 123726.28664074924, + 123751.29384854218, + 123776.30231974016, + 123801.31205421555, + 123826.32305184075, + 123851.33531248817, + 123876.34883603029, + 123901.36362233957, + 123926.37967128855, + 123951.39698274979, + 123976.41555659588, + 124001.43539269941, + 124026.45649093305, + 124051.47885116948, + 124076.50247328142, + 124101.5273571416, + 124126.55350262282, + 124151.58090959788, + 124176.60957793961, + 124201.63950752091, + 124226.67069821467, + 124251.70314989384, + 124276.73686243138, + 124301.7718357003, + 124326.80806957364, + 124351.84556392446, + 124376.88431862585, + 124401.92433355095, + 124426.96560857294, + 124452.00814356498, + 124477.05193840031, + 124502.0969929522, + 124527.14330709392, + 124552.19088069882, + 124577.23971364023, + 124602.28980579154, + 124627.34115702618, + 124652.3937672176, + 124677.44763623926, + 124702.50276396469, + 124727.55915026742, + 124752.61679502104, + 124777.67569809916, + 124802.73585937542, + 124827.79727872348, + 124852.85995601704, + 124877.92389112986, + 124902.98908393568, + 124928.05553430831, + 124953.1232421216, + 124978.19220724938, + 125003.26242956554, + 125028.33390894404, + 125053.40664525882, + 125078.48063838384, + 125103.55588819318, + 125128.63239456083, + 125153.71015736091, + 125178.78917646752, + 125203.86945175481, + 125228.95098309696, + 125254.03377036817, + 125279.1178134427, + 125304.20311219479, + 125329.28966649878, + 125354.37747622898, + 125379.46654125977, + 125404.55686146552, + 125429.6484367207, + 125454.74126689974, + 125479.83535187715, + 125504.93069152744, + 125530.02728572517, + 125555.12513434493, + 125580.22423726133, + 125605.32459434902, + 125630.4262054827, + 125655.52907053704, + 125680.63318938682, + 125705.73856190679, + 125730.84518797178, + 125755.9530674566, + 125781.06220023613, + 125806.17258618528, + 125831.28422517896, + 125856.39711709213, + 125881.51126179981, + 125906.62665917698, + 125931.74330909875, + 125956.86121144016, + 125981.98036607634, + 126007.10077288245, + 126032.22243173365, + 126057.34534250517, + 126082.46950507225, + 126107.59491931014, + 126132.72158509417, + 126157.84950229966, + 126182.97867080198, + 126208.10909047653, + 126233.24076119871, + 126258.37368284403, + 126283.50785528794, + 126308.64327840599, + 126333.77995207369, + 126358.91787616667, + 126384.0570505605, + 126409.19747513086, + 126434.3391497534, + 126459.48207430386, + 126484.62624865794, + 126509.77167269142, + 126534.9183462801, + 126560.06626929982, + 126585.21544162642, + 126610.36586313581, + 126635.51753370393, + 126660.67045320668, + 126685.82462152008, + 126710.98003852014, + 126736.13670408291, + 126761.29461808444, + 126786.45378040087, + 126811.61419090834, + 126836.77584948298, + 126861.93875600102, + 126887.10291033868, + 126912.26831237224, + 126937.43496197795, + 126962.60285903217, + 126987.77200341123, + 127012.94239499152, + 127038.11403364947, + 127063.2869192615, + 127088.46105170409, + 127113.63643085376, + 127138.81305658702, + 127163.99092878048, + 127189.17004731069, + 127214.35041205429, + 127239.53202288797, + 127264.71487968838, + 127289.89898233226, + 127315.08433069635, + 127340.27092465744, + 127365.45876409234, + 127390.64784887788, + 127415.83817889093, + 127441.02975400841, + 127466.22257410725, + 127491.41663906439, + 127516.61194875685, + 127541.80850306165, + 127567.00630185583, + 127592.20534501647, + 127617.4056324207, + 127642.60716394568, + 127667.80993946856, + 127693.01395886653, + 127718.21922201688, + 127743.42572879682, + 127768.63347908368, + 127793.84247275478, + 127819.05270968749, + 127844.26418975917, + 127869.47691284724, + 127894.69087882918, + 127919.90608758242, + 127945.12253898452, + 127970.34023291297, + 127995.55916924537, + 128020.77934785932, + 128046.00076863244, + 128071.22343144237, + 128096.44733616684, + 128121.67248268353, + 128146.89887087021, + 128172.12650060465, + 128197.35537176467, + 128222.5854842281, + 128247.81683787282, + 128273.04943257671, + 128298.28326821771, + 128323.51834467379, + 128348.75466182294, + 128373.99221954317, + 128399.23101771252, + 128424.47105620909, + 128449.71233491098, + 128474.95485369631, + 128500.19861244329, + 128525.44361103009, + 128550.68984933494, + 128575.93732723613, + 128601.18604461191, + 128626.43600134061, + 128651.68719730059, + 128676.93963237021, + 128702.1933064279, + 128727.44821935208, + 128752.70437102125, + 128777.96176131385, + 128803.22039010846, + 128828.48025728362, + 128853.74136271792, + 128879.00370628996, + 128904.26728787841, + 128929.53210736193, + 128954.79816461923, + 128980.06545952905, + 129005.33399197015, + 129030.60376182134, + 129055.87476896142, + 129081.14701326926, + 129106.42049462376, + 129131.6952129038, + 129156.97116798835, + 129182.24835975636, + 129207.52678808685, + 129232.80645285884, + 129258.08735395141, + 129283.36949124365, + 129308.65286461466, + 129333.9374739436, + 129359.22331910966, + 129384.51039999202, + 129409.79871646997, + 129435.08826842274, + 129460.37905572963, + 129485.67107826998, + 129510.96433592314, + 129536.25882856851, + 129561.55455608548, + 129586.85151835352, + 129612.14971525209, + 129637.4491466607, + 129662.74981245887, + 129688.0517125262, + 129713.35484674224, + 129738.65921498663, + 129763.96481713903, + 129789.27165307909, + 129814.57972268655, + 129839.88902584116, + 129865.19956242264, + 129890.51133231082, + 129915.82433538554, + 129941.13857152662, + 129966.45404061397, + 129991.7707425275, + 130017.08867714716, + 130042.4078443529, + 130067.72824402474, + 130093.04987604271, + 130118.37274028687, + 130143.69683663732, + 130169.02216497416, + 130194.34872517755, + 130219.67651712766, + 130245.0055407047, + 130270.33579578891, + 130295.66728226055, + 130320.99999999991, + 130346.33394888733, + 130371.66912880314, + 130397.00553962773, + 130422.34318124152, + 130447.68205352494, + 130473.02215635845, + 130498.36348962256, + 130523.70605319779, + 130549.0498469647, + 130574.39487080388, + 130599.74112459592, + 130625.08860822149, + 130650.43732156123, + 130675.78726449587, + 130701.13843690613, + 130726.49083867275, + 130751.84446967654, + 130777.19932979831, + 130802.5554189189, + 130827.91273691918, + 130853.27128368006, + 130878.63105908247, + 130903.99206300738, + 130929.35429533575, + 130954.71775594862, + 130980.08244472703, + 131005.44836155206, + 131030.81550630482, + 131056.18387886642, + 131081.55347911804, + 131106.92430694087, + 131132.29636221612, + 131157.66964482504, + 131183.0441546489, + 131208.41989156904, + 131233.79685546676, + 131259.17504622342, + 131284.55446372041, + 131309.93510783918, + 131335.31697846117, + 131360.70007546784, + 131386.0843987407, + 131411.46994816128, + 131436.85672361116, + 131462.24472497194, + 131487.63395212521, + 131513.02440495262, + 131538.41608333588, + 131563.80898715663, + 131589.2031162967, + 131614.59847063778, + 131639.9950500617, + 131665.39285445024, + 131690.79188368531, + 131716.19213764873, + 131741.59361622241, + 131766.99631928833, + 131792.40024672839, + 131817.80539842462, + 131843.21177425905, + 131868.61937411371, + 131894.02819787065, + 131919.43824541202, + 131944.84951661993, + 131970.26201137656, + 131995.67572956407, + 132021.09067106468, + 132046.50683576067, + 132071.9242235343, + 132097.34283426782, + 132122.76266784366, + 132148.1837241441, + 132173.60600305157, + 132199.02950444847, + 132224.45422821722, + 132249.88017424036, + 132275.30734240031, + 132300.73573257966, + 132326.16534466096, + 132351.59617852676, + 132377.02823405969, + 132402.46151114244, + 132427.89600965759, + 132453.33172948789, + 132478.76867051609, + 132504.20683262491, + 132529.64621569714, + 132555.08681961559, + 132580.5286442631, + 132605.97168952253, + 132631.41595527678, + 132656.86144140881, + 132682.30814780149, + 132707.75607433787, + 132733.20522090094, + 132758.65558737374, + 132784.10717363929, + 132809.55997958075, + 132835.01400508118, + 132860.46925002377, + 132885.92571429166, + 132911.38339776811, + 132936.84230033628, + 132962.30242187946, + 132987.76376228096, + 133013.22632142407, + 133038.69009919214, + 133064.15509546854, + 133089.62131013666, + 133115.08874307995, + 133140.55739418184, + 133166.02726332581, + 133191.49835039541, + 133216.97065527414, + 133242.44417784561, + 133267.91891799335, + 133293.39487560102, + 133318.87205055228, + 133344.35044273079, + 133369.83005202023, + 133395.31087830439, + 133420.79292146701, + 133446.27618139185, + 133471.76065796276, + 133497.24635106357, + 133522.73326057816, + 133548.22138639039, + 133573.71072838426, + 133599.20128644365, + 133624.69306045261, + 133650.1860502951, + 133675.68025585517, + 133701.1756770169, + 133726.67231366437, + 133752.17016568172, + 133777.66923295305, + 133803.16951536259, + 133828.67101279454, + 133854.17372513309, + 133879.67765226253, + 133905.18279406714, + 133930.68915043125, + 133956.19672123916, + 133981.70550637526, + 134007.21550572399, + 134032.7267191697, + 134058.23914659687, + 134083.75278789, + 134109.26764293358, + 134134.78371161217, + 134160.30099381026, + 134185.8194894125, + 134211.33919830353, + 134236.8601203679, + 134262.38225549037, + 134287.90560355558, + 134313.43016444831, + 134338.95593805326, + 134364.48292425525, + 134390.01112293909, + 134415.54053398955, + 134441.07115729159, + 134466.60299273001, + 134492.1360401898, + 134517.67029955584, + 134543.20577071316, + 134568.74245354676, + 134594.28034794159, + 134619.81945378278, + 134645.35977095537, + 134670.90129934452, + 134696.4440388353, + 134721.98798931291, + 134747.53315066252, + 134773.07952276937, + 134798.62710551871, + 134824.17589879577, + 134849.72590248589, + 134875.27711647438, + 134900.82954064661, + 134926.38317488792, + 134951.93801908373, + 134977.49407311951, + 135003.05133688069, + 135028.60981025276, + 135054.16949312127, + 135079.73038537172, + 135105.29248688967, + 135130.85579756077, + 135156.42031727062, + 135181.98604590484, + 135207.55298334916, + 135233.12112948924, + 135258.69048421088, + 135284.26104739975, + 135309.83281894168, + 135335.4057987225, + 135360.97998662802, + 135386.55538254412, + 135412.13198635669, + 135437.70979795168, + 135463.28881721498, + 135488.86904403262, + 135514.45047829056, + 135540.03311987486, + 135565.61696867159, + 135591.20202456677, + 135616.78828744654, + 135642.37575719706, + 135667.96443370447, + 135693.55431685498, + 135719.14540653475, + 135744.73770263011, + 135770.33120502727, + 135795.92591361253, + 135821.52182827223, + 135847.11894889272, + 135872.7172753604, + 135898.31680756161, + 135923.91754538284, + 135949.51948871053, + 135975.12263743114, + 136000.72699143123, + 136026.33255059729, + 136051.93931481591, + 136077.54728397369, + 136103.15645795723, + 136128.76683665317, + 136154.37841994822, + 136179.99120772901, + 136205.60519988232, + 136231.2203962949, + 136256.83679685349, + 136282.45440144493, + 136308.07320995603, + 136333.69322227367, + 136359.31443828469, + 136384.93685787608, + 136410.56048093468, + 136436.18530734754, + 136461.81133700156, + 136487.43856978384, + 136513.06700558143, + 136538.6966442813, + 136564.32748577066, + 136589.95952993655, + 136615.59277666616, + 136641.22722584667, + 136666.86287736523, + 136692.49973110916, + 136718.13778696564, + 136743.77704482197, + 136769.41750456547, + 136795.05916608346, + 136820.70202926331, + 136846.34609399244, + 136871.99136015819, + 136897.63782764805, + 136923.28549634948, + 136948.93436614997, + 136974.58443693706, + 137000.23570859825, + 137025.88818102115, + 137051.54185409332, + 137077.19672770242, + 137102.85280173609, + 137128.51007608202, + 137154.16855062786, + 137179.82822526142, + 137205.48909987041, + 137231.15117434258, + 137256.8144485658, + 137282.47892242789, + 137308.14459581667, + 137333.81146862009, + 137359.47954072602, + 137385.14881202241, + 137410.81928239719, + 137436.49095173844, + 137462.16381993407, + 137487.83788687221, + 137513.51315244089, + 137539.18961652822, + 137564.86727902229, + 137590.54613981131, + 137616.22619878338, + 137641.90745582676, + 137667.58991082967, + 137693.27356368033, + 137718.95841426702, + 137744.64446247809, + 137770.33170820182, + 137796.02015132661, + 137821.70979174081, + 137847.40062933284, + 137873.09266399115, + 137898.78589560417, + 137924.48032406042, + 137950.17594924837, + 137975.8727710566, + 138001.57078937365, + 138027.27000408815, + 138052.97041508864, + 138078.67202226384, + 138104.3748255024, + 138130.07882469296, + 138155.78401972432, + 138181.49041048516, + 138207.1979968643, + 138232.9067787505, + 138258.61675603263, + 138284.32792859949, + 138310.04029633995, + 138335.75385914298, + 138361.46861689744, + 138387.18456949232, + 138412.90171681659, + 138438.62005875923, + 138464.33959520931, + 138490.06032605586, + 138515.78225118798, + 138541.50537049473, + 138567.2296838653, + 138592.95519118884, + 138618.68189235451, + 138644.40978725153, + 138670.13887576913, + 138695.86915779658, + 138721.60063322316, + 138747.33330193823, + 138773.06716383106, + 138798.80221879104, + 138824.53846670757, + 138850.27590747006, + 138876.01454096794, + 138901.7543670907, + 138927.49538572782, + 138953.2375967688, + 138978.9810001032, + 139004.72559562061, + 139030.47138321059, + 139056.2183627628, + 139081.96653416683, + 139107.71589731239, + 139133.46645208917, + 139159.21819838689, + 139184.97113609532, + 139210.72526510421, + 139236.48058530336, + 139262.23709658257, + 139287.99479883176, + 139313.75369194071, + 139339.51377579942, + 139365.27505029776, + 139391.03751532568, + 139416.80117077316, + 139442.56601653024, + 139468.33205248689, + 139494.09927853322, + 139519.86769455927, + 139545.63730045516, + 139571.408096111, + 139597.18008141697, + 139622.95325626322, + 139648.72762054001, + 139674.5031741375, + 139700.27991694602, + 139726.05784885579, + 139751.83696975713, + 139777.61727954043, + 139803.39877809596, + 139829.18146531415, + 139854.96534108539, + 139880.75040530015, + 139906.53665784886, + 139932.32409862199, + 139958.11272751007, + 139983.90254440365, + 140009.69354919327, + 140035.48574176949, + 140061.27912202294, + 140087.07368984428, + 140112.86944512415, + 140138.66638775321, + 140164.4645176222, + 140190.26383462184, + 140216.06433864293, + 140241.86602957622, + 140267.66890731253, + 140293.47297174268, + 140319.27822275754, + 140345.08466024802, + 140370.89228410498, + 140396.70109421943, + 140422.51109048226, + 140448.32227278448, + 140474.13464101712, + 140499.94819507122, + 140525.76293483781, + 140551.57886020801, + 140577.3959710729, + 140603.21426732364, + 140629.03374885136, + 140654.85441554731, + 140680.67626730262, + 140706.49930400858, + 140732.32352555645, + 140758.1489318375, + 140783.97552274304, + 140809.80329816442, + 140835.63225799298, + 140861.46240212015, + 140887.29373043729, + 140913.12624283586, + 140938.95993920733, + 140964.79481944317, + 140990.63088343487, + 141016.46813107401, + 141042.30656225214, + 141068.14617686081, + 141093.98697479168, + 141119.82895593636, + 141145.6721201865, + 141171.51646743377, + 141197.36199756994, + 141223.20871048668, + 141249.05660607578, + 141274.90568422904, + 141300.75594483822, + 141326.6073877952, + 141352.4600129918, + 141378.31382031992, + 141404.16880967148, + 141430.02498093838, + 141455.8823340126, + 141481.74086878612, + 141507.60058515094, + 141533.46148299909, + 141559.32356222265, + 141585.18682271364, + 141611.05126436421, + 141636.9168870665, + 141662.78369071262, + 141688.65167519479, + 141714.5208404052, + 141740.39118623605, + 141766.26271257963, + 141792.1354193282, + 141818.00930637406, + 141843.88437360956, + 141869.760620927, + 141895.6380482188, + 141921.51665537735, + 141947.39644229505, + 141973.27740886438, + 141999.15955497778, + 142025.04288052776, + 142050.92738540689, + 142076.81306950765, + 142102.69993272264, + 142128.58797494444, + 142154.47719606571, + 142180.36759597904, + 142206.25917457714, + 142232.15193175265, + 142258.04586739838, + 142283.94098140698, + 142309.83727367126, + 142335.73474408401, + 142361.63339253806, + 142387.5332189262, + 142413.43422314132, + 142439.33640507635, + 142465.23976462413, + 142491.14430167765, + 142517.05001612983, + 142542.95690787368, + 142568.86497680223, + 142594.77422280848, + 142620.68464578551, + 142646.5962456264, + 142672.50902222423, + 142698.42297547215, + 142724.33810526333, + 142750.25441149093, + 142776.17189404817, + 142802.09055282827, + 142828.01038772447, + 142853.93139863008, + 142879.85358543837, + 142905.77694804268, + 142931.70148633636, + 142957.62720021277, + 142983.55408956532, + 143009.48215428743, + 143035.41139427255, + 143061.34180941415, + 143087.27339960571, + 143113.20616474075, + 143139.14010471283, + 143165.07521941551, + 143191.01150874238, + 143216.94897258704, + 143242.88761084314, + 143268.82742340435, + 143294.76841016437, + 143320.71057101688, + 143346.65390585564, + 143372.59841457437, + 143398.54409706692, + 143424.49095322701, + 143450.43898294857, + 143476.38818612538, + 143502.33856265133, + 143528.29011242036, + 143554.24283532638, + 143580.19673126334, + 143606.1518001252, + 143632.10804180597, + 143658.06545619969, + 143684.02404320039, + 143709.98380270213, + 143735.944734599, + 143761.90683878519, + 143787.87011515474, + 143813.83456360188, + 143839.8001840208, + 143865.76697630569, + 143891.73494035081, + 143917.7040760504, + 143943.67438329876, + 143969.6458619902, + 143995.61851201905, + 144021.59233327967, + 144047.56732566646, + 144073.54348907378, + 144099.52082339607, + 144125.49932852783, + 144151.4790043635, + 144177.45985079758, + 144203.44186772458, + 144229.42505503909, + 144255.40941263564, + 144281.39494040885, + 144307.38163825331, + 144333.36950606373, + 144359.35854373468, + 144385.34875116093, + 144411.34012823718, + 144437.33267485813, + 144463.32639091855, + 144489.32127631325, + 144515.31733093705, + 144541.31455468474, + 144567.3129474512, + 144593.3125091313, + 144619.31323961995, + 144645.31513881206, + 144671.31820660262, + 144697.32244288657, + 144723.32784755889, + 144749.33442051467, + 144775.34216164888, + 144801.35107085665, + 144827.36114803303, + 144853.37239307314, + 144879.38480587213, + 144905.39838632516, + 144931.41313432742, + 144957.4290497741, + 144983.44613256046, + 145009.46438258173, + 145035.48379973322, + 145061.50438391021, + 145087.52613500805, + 145113.54905292206, + 145139.57313754765, + 145165.59838878017, + 145191.62480651509, + 145217.65239064783, + 145243.68114107384, + 145269.71105768863, + 145295.74214038774, + 145321.77438906668, + 145347.80780362099, + 145373.84238394629, + 145399.87812993818, + 145425.91504149229, + 145451.95311850426, + 145477.9923608698, + 145504.03276848458, + 145530.07434124436, + 145556.11707904484, + 145582.16098178181, + 145608.20604935108, + 145634.25228164849, + 145660.29967856981, + 145686.34824001096, + 145712.39796586783, + 145738.4488560363, + 145764.50091041232, + 145790.55412889185, + 145816.60851137087, + 145842.66405774537, + 145868.72076791141, + 145894.77864176501, + 145920.83767920226, + 145946.89788011924, + 145972.95924441208, + 145999.02177197693, + 146025.08546270995, + 146051.15031650732, + 146077.21633326527, + 146103.28351288004, + 146129.35185524789, + 146155.42136026506, + 146181.49202782792, + 146207.56385783272, + 146233.63685017588, + 146259.71100475377, + 146285.78632146274, + 146311.86280019928, + 146337.94044085976, + 146364.01924334071, + 146390.09920753856, + 146416.18033334985, + 146442.26262067116, + 146468.34606939898, + 146494.43067942993, + 146520.51645066062, + 146546.60338298764, + 146572.69147630769, + 146598.78073051744, + 146624.87114551352, + 146650.96272119274, + 146677.05545745179, + 146703.14935418745, + 146729.2444112965, + 146755.34062867577, + 146781.43800622207, + 146807.53654383228, + 146833.63624140329, + 146859.73709883197, + 146885.83911601527, + 146911.94229285014, + 146938.04662923355, + 146964.15212506248, + 146990.25878023397, + 147016.36659464505, + 147042.47556819281, + 147068.58570077427, + 147094.6969922866, + 147120.80944262692, + 147146.92305169237, + 147173.03781938017, + 147199.15374558745, + 147225.27083021149, + 147251.38907314953, + 147277.50847429881, + 147303.62903355664, + 147329.75075082036, + 147355.87362598727, + 147381.99765895473, + 147408.12284962015, + 147434.24919788091, + 147460.37670363448, + 147486.50536677826, + 147512.63518720976, + 147538.76616482646, + 147564.89829952587, + 147591.03159120557, + 147617.16603976308, + 147643.30164509601, + 147669.43840710199, + 147695.57632567859, + 147721.71540072354, + 147747.85563213445, + 147773.99701980909, + 147800.13956364512, + 147826.28326354033, + 147852.42811939248, + 147878.57413109933, + 147904.72129855872, + 147930.86962166851, + 147957.01910032652, + 147983.16973443062, + 148009.32152387875, + 148035.47446856883, + 148061.62856839882, + 148087.78382326665, + 148113.94023307035, + 148140.09779770792, + 148166.25651707739, + 148192.41639107687, + 148218.57741960438, + 148244.73960255808, + 148270.90293983606, + 148297.0674313365, + 148323.23307695755, + 148349.39987659742, + 148375.56783015432, + 148401.73693752653, + 148427.90719861226, + 148454.07861330983, + 148480.25118151752, + 148506.42490313368, + 148532.59977805667, + 148558.77580618486, + 148584.95298741665, + 148611.13132165043, + 148637.31080878471, + 148663.49144871789, + 148689.6732413485, + 148715.85618657502, + 148742.040284296, + 148768.22553440998, + 148794.41193681557, + 148820.59949141133, + 148846.78819809589, + 148872.97805676793, + 148899.16906732606, + 148925.36122966901, + 148951.55454369547, + 148977.74900930419, + 149003.9446263939, + 149030.1413948634, + 149056.33931461151, + 149082.53838553699, + 149108.73860753875, + 149134.9399805156, + 149161.14250436646, + 149187.34617899026, + 149213.5510042859, + 149239.75698015234, + 149265.96410648854, + 149292.17238319354, + 149318.38181016635, + 149344.59238730598, + 149370.80411451156, + 149397.01699168212, + 149423.23101871679, + 149449.44619551473, + 149475.66252197503, + 149501.87999799693, + 149528.0986234796, + 149554.31839832227, + 149580.53932242419, + 149606.76139568459, + 149632.98461800278, + 149659.20898927809, + 149685.43450940982, + 149711.66117829733, + 149737.88899584001, + 149764.11796193724, + 149790.34807648844, + 149816.57933939309, + 149842.81175055061, + 149869.04530986046, + 149895.28001722222, + 149921.51587253538, + 149947.75287569952, + 149973.99102661415, + 150000.23032517891, + 150026.47077129342, + 150052.71236485732, + 150078.95510577026, + 150105.1989939319, + 150131.444029242, + 150157.69021160025, + 150183.93754090639, + 150210.18601706024, + 150236.43563996154, + 150262.68640951012, + 150288.93832560582, + 150315.19138814852, + 150341.44559703805, + 150367.70095217437, + 150393.95745345735, + 150420.21510078697, + 150446.47389406321, + 150472.73383318601, + 150498.99491805542, + 150525.25714857146, + 150551.52052463419, + 150577.78504614369, + 150604.05071300003, + 150630.31752510337, + 150656.58548235384, + 150682.85458465159, + 150709.1248318968, + 150735.39622398972, + 150761.66876083051, + 150787.9424423195, + 150814.21726835691, + 150840.49323884305, + 150866.77035367821, + 150893.04861276277, + 150919.32801599705, + 150945.60856328148, + 150971.89025451642, + 150998.17308960229, + 151024.45706843957, + 151050.74219092872, + 151077.02845697021, + 151103.31586646455, + 151129.60441931229, + 151155.894115414, + 151182.1849546702, + 151208.47693698155, + 151234.77006224863, + 151261.06433037209, + 151287.35974125259, + 151313.65629479082, + 151339.95399088747, + 151366.25282944329, + 151392.55281035902, + 151418.85393353543, + 151445.1561988733, + 151471.45960627345, + 151497.76415563675, + 151524.06984686397, + 151550.37667985607, + 151576.68465451393, + 151602.99377073845, + 151629.30402843058, + 151655.61542749128, + 151681.92796782157, + 151708.24164932242, + 151734.55647189484, + 151760.87243543993, + 151787.18953985872, + 151813.50778505235, + 151839.82717092187, + 151866.14769736846, + 151892.46936429327, + 151918.79217159748, + 151945.11611918229, + 151971.44120694889, + 151997.76743479856, + 152024.09480263255, + 152050.42331035214, + 152076.75295785864, + 152103.08374505339, + 152129.41567183775, + 152155.74873811303, + 152182.08294378067, + 152208.41828874208, + 152234.75477289871, + 152261.09239615197, + 152287.43115840337, + 152313.77105955439, + 152340.11209950657, + 152366.45427816146, + 152392.79759542056, + 152419.14205118554, + 152445.48764535793, + 152471.8343778394, + 152498.18224853161, + 152524.53125733617, + 152550.88140415482, + 152577.23268888926, + 152603.58511144121, + 152629.93867171241, + 152656.29336960468, + 152682.64920501978, + 152709.00617785956, + 152735.36428802583, + 152761.72353542043, + 152788.08391994529, + 152814.44544150229, + 152840.80809999333, + 152867.17189532038, + 152893.53682738543, + 152919.90289609041, + 152946.27010133737, + 152972.63844302832, + 152999.00792106529, + 153025.37853535041, + 153051.7502857857, + 153078.12317227334, + 153104.4971947154, + 153130.8723530141, + 153157.24864707157, + 153183.62607679001, + 153210.00464207167, + 153236.38434281875, + 153262.76517893354, + 153289.14715031831, + 153315.53025687535, + 153341.91449850702, + 153368.2998751156, + 153394.68638660354, + 153421.07403287315, + 153447.46281382689, + 153473.85272936718, + 153500.24377939643, + 153526.63596381716, + 153553.02928253182, + 153579.42373544298, + 153605.81932245308, + 153632.21604346478, + 153658.61389838057, + 153685.0128871031, + 153711.41300953497, + 153737.81426557881, + 153764.21665513728, + 153790.62017811305, + 153817.02483440886, + 153843.43062392739, + 153869.83754657139, + 153896.24560224367, + 153922.65479084692, + 153949.06511228404, + 153975.4765664578, + 154001.88915327107, + 154028.30287262669, + 154054.71772442761, + 154081.13370857667, + 154107.55082497682, + 154133.96907353101, + 154160.38845414223, + 154186.80896671346, + 154213.23061114774, + 154239.65338734805, + 154266.07729521746, + 154292.50233465908, + 154318.92850557598, + 154345.35580787127, + 154371.7842414481, + 154398.21380620965, + 154424.64450205903, + 154451.07632889951, + 154477.50928663427, + 154503.94337516659, + 154530.37859439969, + 154556.81494423689, + 154583.25242458144, + 154609.69103533673, + 154636.13077640603, + 154662.57164769279, + 154689.01364910032, + 154715.45678053208, + 154741.90104189145, + 154768.34643308193, + 154794.79295400696, + 154821.24060457002, + 154847.68938467462, + 154874.13929422433, + 154900.59033312264, + 154927.04250127316, + 154953.49579857948, + 154979.95022494521, + 155006.40578027396, + 155032.86246446942, + 155059.32027743524, + 155085.77921907514, + 155112.2392892928, + 155138.70048799197, + 155165.16281507642, + 155191.62627044989, + 155218.09085401625, + 155244.55656567923, + 155271.02340534274, + 155297.49137291059, + 155323.96046828668, + 155350.4306913749, + 155376.90204207919, + 155403.37452030348, + 155429.84812595171, + 155456.32285892789, + 155482.79871913602, + 155509.27570648011, + 155535.75382086422, + 155562.23306219239, + 155588.71343036872, + 155615.19492529731, + 155641.67754688227, + 155668.16129502779, + 155694.64616963797, + 155721.13217061706, + 155747.61929786921, + 155774.10755129869, + 155800.59693080973, + 155827.08743630661, + 155853.57906769359, + 155880.07182487496, + 155906.56570775513, + 155933.06071623837, + 155959.55685022907, + 155986.05410963166, + 156012.5524943505, + 156039.05200429002, + 156065.55263935472, + 156092.054399449, + 156118.5572844774, + 156145.06129434443, + 156171.5664289546, + 156198.07268821247, + 156224.5800720226, + 156251.08858028959, + 156277.59821291809, + 156304.10896981266, + 156330.62085087801, + 156357.1338560188, + 156383.64798513969, + 156410.16323814544, + 156436.67961494075, + 156463.1971154304, + 156489.71573951913, + 156516.23548711176, + 156542.75635811311, + 156569.27835242799, + 156595.80146996127, + 156622.32571061782, + 156648.85107430254, + 156675.37756092031, + 156701.90517037612, + 156728.43390257491, + 156754.96375742162, + 156781.49473482129, + 156808.02683467892, + 156834.5600568995, + 156861.09440138817, + 156887.62986804993, + 156914.16645678994, + 156940.70416751326, + 156967.24300012505, + 156993.78295453047, + 157020.32403063469, + 157046.8662283429, + 157073.40954756032, + 157099.9539881922, + 157126.49955014378, + 157153.04623332032, + 157179.59403762716, + 157206.14296296958, + 157232.69300925292, + 157259.24417638258, + 157285.79646426387, + 157312.34987280221, + 157338.90440190304, + 157365.46005147175, + 157392.01682141385, + 157418.57471163478, + 157445.13372204005, + 157471.69385253513, + 157498.25510302564, + 157524.81747341706, + 157551.38096361503, + 157577.9455735251, + 157604.51130305286, + 157631.07815210402, + 157657.64612058419, + 157684.21520839902, + 157710.78541545427, + 157737.35674165559, + 157763.92918690876, + 157790.50275111952, + 157817.07743419363, + 157843.65323603692, + 157870.23015655516, + 157896.80819565422, + 157923.3873532399, + 157949.96762921812, + 157976.54902349479, + 158003.13153597576, + 158029.71516656701, + 158056.29991517449, + 158082.88578170416, + 158109.47276606198, + 158136.06086815402, + 158162.65008788629, + 158189.24042516484, + 158215.83187989573, + 158242.42445198505, + 158269.01814133892, + 158295.61294786347, + 158322.20887146486, + 158348.80591204923, + 158375.4040695228, + 158402.00334379176, + 158428.60373476235, + 158455.2052423408, + 158481.80786643337, + 158508.41160694641, + 158535.01646378616, + 158561.62243685898, + 158588.2295260712, + 158614.8377313292, + 158641.44705253936, + 158668.05748960807, + 158694.66904244179, + 158721.28171094693, + 158747.89549502998, + 158774.5103945974, + 158801.12640955573, + 158827.74353981143, + 158854.36178527112, + 158880.9811458413, + 158907.60162142856, + 158934.22321193956, + 158960.84591728085, + 158987.46973735912, + 159014.09467208097, + 159040.72072135314, + 159067.3478850823, + 159093.97616317519, + 159120.60555553852, + 159147.23606207906, + 159173.8676827036, + 159200.50041731889, + 159227.13426583182, + 159253.76922814918, + 159280.40530417781, + 159307.04249382461, + 159333.68079699649, + 159360.32021360032, + 159386.96074354305, + 159413.60238673165, + 159440.24514307309, + 159466.88901247433, + 159493.53399484244, + 159520.18009008438, + 159546.82729810724, + 159573.47561881805, + 159600.12505212394, + 159626.77559793202, + 159653.42725614941, + 159680.08002668325, + 159706.73390944069, + 159733.38890432892, + 159760.04501125516, + 159786.70223012666, + 159813.36056085059, + 159840.02000333427, + 159866.68055748497, + 159893.34222320997, + 159920.00500041663, + 159946.66888901225, + 159973.33388890422, + 159999.99999999988, + 160026.66722220668, + 160053.33555543202, + 160080.0049995833, + 160106.67555456801, + 160133.3472202936, + 160160.0199966676, + 160186.6938835975, + 160213.36888099083, + 160240.04498875517, + 160266.72220679806, + 160293.40053502709, + 160320.07997334987, + 160346.76052167406, + 160373.44217990729, + 160400.1249479572, + 160426.80882573154, + 160453.49381313793, + 160480.17991008417, + 160506.86711647795, + 160533.55543222709, + 160560.24485723933, + 160586.93539142248, + 160613.62703468435, + 160640.31978693281, + 160667.01364807569, + 160693.70861802087, + 160720.40469667627, + 160747.1018839498, + 160773.80017974938, + 160800.49958398298, + 160827.20009655855, + 160853.90171738411, + 160880.60444636765, + 160907.30828341722, + 160934.01322844089, + 160960.71928134665, + 160987.42644204266, + 161014.13471043704, + 161040.84408643784, + 161067.55456995327, + 161094.26616089148, + 161120.97885916062, + 161147.69266466892, + 161174.40757732463, + 161201.12359703594, + 161227.84072371112, + 161254.55895725847, + 161281.27829758628, + 161307.99874460287, + 161334.72029821656, + 161361.44295833571, + 161388.1667248687, + 161414.89159772391, + 161441.61757680977, + 161468.34466203468, + 161495.07285330712, + 161521.80215053557, + 161548.53255362847, + 161575.26406249436, + 161601.99667704175, + 161628.7303971792, + 161655.46522281526, + 161682.20115385848, + 161708.93819021754, + 161735.67633180099, + 161762.41557851751, + 161789.15593027571, + 161815.89738698432, + 161842.63994855201, + 161869.38361488748, + 161896.1283858995, + 161922.87426149679, + 161949.62124158812, + 161976.36932608229, + 162003.1185148881, + 162029.8688079144, + 162056.62020507001, + 162083.37270626382, + 162110.12631140469, + 162136.88102040152, + 162163.63683316324, + 162190.39374959879, + 162217.15176961714, + 162243.91089312723, + 162270.67112003808, + 162297.43245025873, + 162324.19488369819, + 162350.9584202655, + 162377.72305986975, + 162404.48880242003, + 162431.25564782543, + 162458.02359599507, + 162484.79264683815, + 162511.56280026378, + 162538.33405618116, + 162565.10641449949, + 162591.87987512801, + 162618.65443797593, + 162645.43010295252, + 162672.20686996708, + 162698.98473892888, + 162725.76370974723, + 162752.54378233149, + 162779.32495659095, + 162806.10723243505, + 162832.89060977317, + 162859.67508851466, + 162886.46066856899, + 162913.24734984562, + 162940.03513225398, + 162966.82401570358, + 162993.6140001039, + 163020.40508536444, + 163047.19727139481, + 163073.99055810447, + 163100.78494540305, + 163127.58043320014, + 163154.37702140535, + 163181.17470992831, + 163207.97349867865, + 163234.77338756606, + 163261.57437650024, + 163288.37646539087, + 163315.17965414765, + 163341.98394268038, + 163368.78933089875, + 163395.59581871261, + 163422.40340603172, + 163449.2120927659, + 163476.02187882498, + 163502.83276411882, + 163529.6447485573, + 163556.45783205028, + 163583.2720145077, + 163610.08729583945, + 163636.90367595552, + 163663.72115476584, + 163690.53973218042, + 163717.35940810922, + 163744.18018246227, + 163771.00205514964, + 163797.82502608138, + 163824.64909516752, + 163851.4742623182, + 163878.3005274435, + 163905.12789045356, + 163931.95635125853, + 163958.78590976857, + 163985.61656589387, + 164012.44831954464, + 164039.28117063109, + 164066.11511906344, + 164092.95016475199, + 164119.78630760699, + 164146.62354753874, + 164173.46188445756, + 164200.30131827376, + 164227.14184889771, + 164253.98347623978, + 164280.82620021031, + 164307.67002071979, + 164334.51493767856, + 164361.3609509971, + 164388.20806058586, + 164415.05626635533, + 164441.905568216, + 164468.75596607837, + 164495.607459853, + 164522.4600494504, + 164549.31373478117, + 164576.16851575591, + 164603.02439228518, + 164629.88136427966, + 164656.73943164994, + 164683.59859430668, + 164710.45885216061, + 164737.32020512238, + 164764.1826531027, + 164791.04619601235, + 164817.91083376206, + 164844.77656626256, + 164871.64339342469, + 164898.51131515924, + 164925.38033137703, + 164952.25044198887, + 164979.1216469057, + 165005.9939460383, + 165032.86733929763, + 165059.7418265946, + 165086.61740784015, + 165113.4940829452 +}; + +#else + +#ifdef BIG_IQ_TABLE +#define IQ_TABLE_SIZE 8192 +#else +#define IQ_TABLE_SIZE 1026 +#endif + +static const real_t iq_table[IQ_TABLE_SIZE] MEM_ALIGN_ATTR = +{ + REAL_CONST(0.0), + REAL_CONST(1.0/8.0), + REAL_CONST(2.5198420997897464/8.0), + REAL_CONST(4.3267487109222245/8.0), + REAL_CONST(6.3496042078727974/8.0), + REAL_CONST(8.5498797333834844/8.0), + REAL_CONST(10.902723556992836/8.0), + REAL_CONST(13.390518279406722/8.0), + REAL_CONST(15.999999999999998/8.0), + REAL_CONST(18.720754407467133/8.0), + REAL_CONST(21.544346900318832/8.0), + REAL_CONST(24.463780996262464/8.0), + REAL_CONST(27.47314182127996/8.0), + REAL_CONST(30.567350940369842/8.0), + REAL_CONST(33.741991698453212/8.0), + REAL_CONST(36.993181114957046/8.0), + REAL_CONST(40.317473596635935/8.0), + REAL_CONST(43.711787041189993/8.0), + REAL_CONST(47.173345095760126/8.0), + REAL_CONST(50.699631325716943/8.0), + REAL_CONST(54.288352331898118/8.0), + REAL_CONST(57.937407704003519/8.0), + REAL_CONST(61.6448652744185/8.0), + REAL_CONST(65.408940536585988/8.0), + REAL_CONST(69.227979374755591/8.0), + REAL_CONST(73.100443455321638/8.0), + REAL_CONST(77.024897778591622/8.0), + REAL_CONST(80.999999999999986/8.0), + REAL_CONST(85.024491212518527/8.0), + REAL_CONST(89.097187944889555/8.0), + REAL_CONST(93.216975178615741/8.0), + REAL_CONST(97.382800224133163/8.0), + REAL_CONST(101.59366732596474/8.0), + REAL_CONST(105.84863288986224/8.0), + REAL_CONST(110.14680124343441/8.0), + REAL_CONST(114.4873208566006/8.0), + REAL_CONST(118.86938096020653/8.0), + REAL_CONST(123.29220851090024/8.0), + REAL_CONST(127.75506545836058/8.0), + REAL_CONST(132.25724627755247/8.0), + REAL_CONST(136.79807573413572/8.0), + REAL_CONST(141.37690685569191/8.0), + REAL_CONST(145.99311908523086/8.0), + REAL_CONST(150.6461165966291/8.0), + REAL_CONST(155.33532675434674/8.0), + REAL_CONST(160.06019870205279/8.0), + REAL_CONST(164.82020206673349/8.0), + REAL_CONST(169.61482576651861/8.0), + REAL_CONST(174.44357691188537/8.0), + REAL_CONST(179.30597979112557/8.0), + REAL_CONST(184.20157493201927/8.0), + REAL_CONST(189.12991823257562/8.0), + REAL_CONST(194.09058015449685/8.0), + REAL_CONST(199.08314497371677/8.0), + REAL_CONST(204.1072100829694/8.0), + REAL_CONST(209.16238534187647/8.0), + REAL_CONST(214.24829247050752/8.0), + REAL_CONST(219.36456448277784/8.0), + REAL_CONST(224.51084515641216/8.0), + REAL_CONST(229.6867885365223/8.0), + REAL_CONST(234.89205847013176/8.0), + REAL_CONST(240.12632816923249/8.0), + REAL_CONST(245.38927980018505/8.0), + REAL_CONST(250.68060409747261/8.0), + REAL_CONST(255.99999999999991/8.0), + REAL_CONST(261.34717430828869/8.0), + REAL_CONST(266.72184136106449/8.0), + REAL_CONST(272.12372272986045/8.0), + REAL_CONST(277.55254693037961/8.0), + REAL_CONST(283.0080491494619/8.0), + REAL_CONST(288.48997098659891/8.0), + REAL_CONST(293.99806020902247/8.0), + REAL_CONST(299.53207051947408/8.0), + REAL_CONST(305.0917613358298/8.0), + REAL_CONST(310.67689758182206/8.0), + REAL_CONST(316.28724948815585/8.0), + REAL_CONST(321.92259240337177/8.0), + REAL_CONST(327.58270661385535/8.0), + REAL_CONST(333.26737717243742/8.0), + REAL_CONST(338.97639373507025/8.0), + REAL_CONST(344.70955040510125/8.0), + REAL_CONST(350.46664558470013/8.0), + REAL_CONST(356.24748183302603/8.0), + REAL_CONST(362.05186573075139/8.0), + REAL_CONST(367.87960775058258/8.0), + REAL_CONST(373.73052213344511/8.0), + REAL_CONST(379.60442677002078/8.0), + REAL_CONST(385.50114308734607/8.0), + REAL_CONST(391.42049594019937/8.0), + REAL_CONST(397.36231350702371/8.0), + REAL_CONST(403.32642719014467/8.0), + REAL_CONST(409.31267152006262/8.0), + REAL_CONST(415.32088406360799/8.0), + REAL_CONST(421.35090533576471/8.0), + REAL_CONST(427.40257871497619/8.0), + REAL_CONST(433.4757503617617/8.0), + REAL_CONST(439.5702691404793/8.0), + REAL_CONST(445.68598654408271/8.0), + REAL_CONST(451.82275662172759/8.0), + REAL_CONST(457.98043590909128/8.0), + REAL_CONST(464.15888336127773/8.0), + REAL_CONST(470.35796028818726/8.0), + REAL_CONST(476.5775302922363/8.0), + REAL_CONST(482.81745920832043/8.0), + REAL_CONST(489.07761504591741/8.0), + REAL_CONST(495.35786793323581/8.0), + REAL_CONST(501.65809006331688/8.0), + REAL_CONST(507.97815564200368/8.0), + REAL_CONST(514.31794083769648/8.0), + REAL_CONST(520.67732373281672/8.0), + REAL_CONST(527.05618427690604/8.0), + REAL_CONST(533.45440424129174/8.0), + REAL_CONST(539.87186717525128/8.0), + REAL_CONST(546.30845836361505/8.0), + REAL_CONST(552.76406478574609/8.0), + REAL_CONST(559.23857507584194/8.0), + REAL_CONST(565.73187948450413/8.0), + REAL_CONST(572.24386984152341/8.0), + REAL_CONST(578.77443951983378/8.0), + REAL_CONST(585.32348340058843/8.0), + REAL_CONST(591.89089783931263/8.0), + REAL_CONST(598.47658063309257/8.0), + REAL_CONST(605.08043098876044/8.0), + REAL_CONST(611.70234949203643/8.0), + REAL_CONST(618.3422380775919/8.0), + REAL_CONST(624.99999999999977/8.0), + REAL_CONST(631.67553980553748/8.0), + REAL_CONST(638.36876330481164/8.0), + REAL_CONST(645.07957754617485/8.0), + REAL_CONST(651.80789078990415/8.0), + REAL_CONST(658.55361248311499/8.0), + REAL_CONST(665.31665323538357/8.0), + REAL_CONST(672.09692479505225/8.0), + REAL_CONST(678.8943400261943/8.0), + REAL_CONST(685.70881288621433/8.0), + REAL_CONST(692.540258404062/8.0), + REAL_CONST(699.38859265903977/8.0), + REAL_CONST(706.25373276018058/8.0), + REAL_CONST(713.13559682617972/8.0), + REAL_CONST(720.03410396586037/8.0), + REAL_CONST(726.94917425915435/8.0), + REAL_CONST(733.88072873858209/8.0), + REAL_CONST(740.82868937121543/8.0), + REAL_CONST(747.79297904110535/8.0), + REAL_CONST(754.77352153216191/8.0), + REAL_CONST(761.77024151147043/8.0), + REAL_CONST(768.78306451302956/8.0), + REAL_CONST(775.81191692189896/8.0), + REAL_CONST(782.85672595874246/8.0), + REAL_CONST(789.91741966475445/8.0), + REAL_CONST(796.99392688695798/8.0), + REAL_CONST(804.08617726386274/8.0), + REAL_CONST(811.19410121147098/8.0), + REAL_CONST(818.31762990962227/8.0), + REAL_CONST(825.45669528866563/8.0), + REAL_CONST(832.61123001644864/8.0), + REAL_CONST(839.78116748561604/8.0), + REAL_CONST(846.96644180120552/8.0), + REAL_CONST(854.16698776853514/8.0), + REAL_CONST(861.38274088137143/8.0), + REAL_CONST(868.61363731036977/8.0), + REAL_CONST(875.85961389178203/8.0), + REAL_CONST(883.12060811641959/8.0), + REAL_CONST(890.39655811886757/8.0), + REAL_CONST(897.68740266694181/8.0), + REAL_CONST(904.99308115138172/8.0), + REAL_CONST(912.31353357577188/8.0), + REAL_CONST(919.64870054668756/8.0), + REAL_CONST(926.99852326405619/8.0), + REAL_CONST(934.36294351172899/8.0), + REAL_CONST(941.74190364825859/8.0), + REAL_CONST(949.13534659787422/8.0), + REAL_CONST(956.54321584165211/8.0), + REAL_CONST(963.96545540887348/8.0), + REAL_CONST(971.40200986856541/8.0), + REAL_CONST(978.85282432122176/8.0), + REAL_CONST(986.31784439069588/8.0), + REAL_CONST(993.7970162162635/8.0), + REAL_CONST(1001.29028644485/8.0), + REAL_CONST(1008.797602223418/8.0), + REAL_CONST(1016.3189111915103/8.0), + REAL_CONST(1023.8541614739464/8.0), + REAL_CONST(1031.4033016736653/8.0), + REAL_CONST(1038.9662808647138/8.0), + REAL_CONST(1046.5430485853758/8.0), + REAL_CONST(1054.1335548314366/8.0), + REAL_CONST(1061.7377500495838/8.0), + REAL_CONST(1069.3555851309357/8.0), + REAL_CONST(1076.9870114046978/8.0), + REAL_CONST(1084.6319806319441/8.0), + REAL_CONST(1092.2904449995174/8.0), + REAL_CONST(1099.9623571140482/8.0), + REAL_CONST(1107.6476699960892/8.0), + REAL_CONST(1115.3463370743607/8.0), + REAL_CONST(1123.058312180106/8.0), + REAL_CONST(1130.7835495415541/8.0), + REAL_CONST(1138.5220037784854/8.0), + REAL_CONST(1146.273629896901/8.0), + REAL_CONST(1154.0383832837879/8.0), + REAL_CONST(1161.816219701986/8.0), + REAL_CONST(1169.607095285146/8.0), + REAL_CONST(1177.4109665327808/8.0), + REAL_CONST(1185.2277903054078/8.0), + REAL_CONST(1193.0575238197798/8.0), + REAL_CONST(1200.9001246442001/8.0), + REAL_CONST(1208.7555506939248/8.0), + REAL_CONST(1216.6237602266442/8.0), + REAL_CONST(1224.5047118380478/8.0), + REAL_CONST(1232.3983644574657/8.0), + REAL_CONST(1240.3046773435874/8.0), + REAL_CONST(1248.2236100802568/8.0), + REAL_CONST(1256.1551225723395/8.0), + REAL_CONST(1264.099175041662/8.0), + REAL_CONST(1272.0557280230228/8.0), + REAL_CONST(1280.0247423602691/8.0), + REAL_CONST(1288.0061792024444/8.0), + REAL_CONST(1295.9999999999995/8.0), + REAL_CONST(1304.006166501068/8.0), + REAL_CONST(1312.0246407478062/8.0), + REAL_CONST(1320.0553850727929/8.0), + REAL_CONST(1328.0983620954903/8.0), + REAL_CONST(1336.1535347187651/8.0), + REAL_CONST(1344.2208661254647/8.0), + REAL_CONST(1352.3003197750522/8.0), + REAL_CONST(1360.3918594002962/8.0), + REAL_CONST(1368.4954490040145/8.0), + REAL_CONST(1376.6110528558709/8.0), + REAL_CONST(1384.7386354892244/8.0), + REAL_CONST(1392.8781616980295/8.0), + REAL_CONST(1401.0295965337855/8.0), + REAL_CONST(1409.1929053025353/8.0), + REAL_CONST(1417.3680535619119/8.0), + REAL_CONST(1425.5550071182327/8.0), + REAL_CONST(1433.7537320236374/8.0), + REAL_CONST(1441.9641945732744/8.0), + REAL_CONST(1450.1863613025282/8.0), + REAL_CONST(1458.4201989842913/8.0), + REAL_CONST(1466.6656746262797/8.0), + REAL_CONST(1474.9227554683875/8.0), + REAL_CONST(1483.1914089800841/8.0), + REAL_CONST(1491.4716028578516/8.0), + REAL_CONST(1499.7633050226596/8.0), + REAL_CONST(1508.0664836174794/8.0), + REAL_CONST(1516.3811070048375/8.0), + REAL_CONST(1524.7071437644029/8.0), + REAL_CONST(1533.0445626906128/8.0), + REAL_CONST(1541.3933327903342/8.0), + REAL_CONST(1549.7534232805581/8.0), + REAL_CONST(1558.1248035861302/8.0), + REAL_CONST(1566.507443337515/8.0), + REAL_CONST(1574.9013123685909/8.0), + REAL_CONST(1583.3063807144795/8.0), + REAL_CONST(1591.7226186094069/8.0), + REAL_CONST(1600.1499964845941/8.0), + REAL_CONST(1608.58848496618/8.0), + REAL_CONST(1617.0380548731737/8.0), + REAL_CONST(1625.4986772154357/8.0), + REAL_CONST(1633.9703231916887/8.0), + REAL_CONST(1642.4529641875577/8.0), + REAL_CONST(1650.9465717736346/8.0), + REAL_CONST(1659.4511177035752/8.0), + REAL_CONST(1667.9665739122186/8.0), + REAL_CONST(1676.4929125137353/8.0), + REAL_CONST(1685.030105799801/8.0), + REAL_CONST(1693.5781262377957/8.0), + REAL_CONST(1702.136946469027/8.0), + REAL_CONST(1710.7065393069795/8.0), + REAL_CONST(1719.2868777355877/8.0), + REAL_CONST(1727.8779349075323/8.0), + REAL_CONST(1736.4796841425596/8.0), + REAL_CONST(1745.092098925825/8.0), + REAL_CONST(1753.7151529062583/8.0), + REAL_CONST(1762.3488198949503/8.0), + REAL_CONST(1770.9930738635628/8.0), + REAL_CONST(1779.6478889427597/8.0), + REAL_CONST(1788.3132394206564/8.0), + REAL_CONST(1796.9890997412947/8.0), + REAL_CONST(1805.6754445031333/8.0), + REAL_CONST(1814.3722484575621/8.0), + REAL_CONST(1823.0794865074322/8.0), + REAL_CONST(1831.7971337056094/8.0), + REAL_CONST(1840.5251652535437/8.0), + REAL_CONST(1849.2635564998579/8.0), + REAL_CONST(1858.0122829389563/8.0), + REAL_CONST(1866.7713202096493/8.0), + REAL_CONST(1875.5406440937966/8.0), + REAL_CONST(1884.3202305149687/8.0), + REAL_CONST(1893.110055537124/8.0), + REAL_CONST(1901.9100953633042/8.0), + REAL_CONST(1910.7203263343454/8.0), + REAL_CONST(1919.5407249276057/8.0), + REAL_CONST(1928.3712677557098/8.0), + REAL_CONST(1937.2119315653083/8.0), + REAL_CONST(1946.0626932358525/8.0), + REAL_CONST(1954.923529778386/8.0), + REAL_CONST(1963.79441833435/8.0), + REAL_CONST(1972.6753361744036/8.0), + REAL_CONST(1981.5662606972594/8.0), + REAL_CONST(1990.467169428533/8.0), + REAL_CONST(1999.3780400196069/8.0), + REAL_CONST(2008.2988502465078/8.0), + REAL_CONST(2017.2295780087982/8.0), + REAL_CONST(2026.1702013284819/8.0), + REAL_CONST(2035.1206983489212/8.0), + REAL_CONST(2044.0810473337688/8.0), + REAL_CONST(2053.0512266659125/8.0), + REAL_CONST(2062.0312148464309/8.0), + REAL_CONST(2071.0209904935646/8.0), + REAL_CONST(2080.0205323416958/8.0), + REAL_CONST(2089.0298192403443/8.0), + REAL_CONST(2098.0488301531714/8.0), + REAL_CONST(2107.0775441569995/8.0), + REAL_CONST(2116.115940440839/8.0), + REAL_CONST(2125.1639983049317/8.0), + REAL_CONST(2134.2216971597995/8.0), + REAL_CONST(2143.2890165253098/8.0), + REAL_CONST(2152.3659360297484/8.0), + REAL_CONST(2161.4524354089031/8.0), + REAL_CONST(2170.5484945051617/8.0), + REAL_CONST(2179.6540932666144/8.0), + REAL_CONST(2188.7692117461711/8.0), + REAL_CONST(2197.8938301006888/8.0), + REAL_CONST(2207.0279285901042/8.0), + REAL_CONST(2216.1714875765838/8.0), + REAL_CONST(2225.324487523676/8.0), + REAL_CONST(2234.4869089954782/8.0), + REAL_CONST(2243.6587326558101/8.0), + REAL_CONST(2252.8399392673982/8.0), + REAL_CONST(2262.0305096910702/8.0), + REAL_CONST(2271.2304248849537/8.0), + REAL_CONST(2280.4396659036897/8.0), + REAL_CONST(2289.6582138976523/8.0), + REAL_CONST(2298.8860501121762/8.0), + REAL_CONST(2308.1231558867926/8.0), + REAL_CONST(2317.3695126544767/8.0), + REAL_CONST(2326.6251019409005/8.0), + REAL_CONST(2335.8899053636933/8.0), + REAL_CONST(2345.1639046317132/8.0), + REAL_CONST(2354.4470815443233/8.0), + REAL_CONST(2363.7394179906792/8.0), + REAL_CONST(2373.0408959490205/8.0), + REAL_CONST(2382.3514974859731/8.0), + REAL_CONST(2391.6712047558558/8.0), + REAL_CONST(2400.9999999999991/8.0), + REAL_CONST(2410.3378655460651/8.0), + REAL_CONST(2419.6847838073813/8.0), + REAL_CONST(2429.0407372822747/8.0), + REAL_CONST(2438.4057085534191/8.0), + REAL_CONST(2447.7796802871858/8.0), + REAL_CONST(2457.1626352330004/8.0), + REAL_CONST(2466.5545562227112/8.0), + REAL_CONST(2475.9554261699564/8.0), + REAL_CONST(2485.3652280695474/8.0), + REAL_CONST(2494.7839449968492/8.0), + REAL_CONST(2504.2115601071737/8.0), + REAL_CONST(2513.6480566351788/8.0), + REAL_CONST(2523.0934178942675/8.0), + REAL_CONST(2532.5476272760025/8.0), + REAL_CONST(2542.0106682495189/8.0), + REAL_CONST(2551.482524360948/8.0), + REAL_CONST(2560.9631792328441/8.0), + REAL_CONST(2570.4526165636184/8.0), + REAL_CONST(2579.9508201269791/8.0), + REAL_CONST(2589.4577737713744/8.0), + REAL_CONST(2598.9734614194458/8.0), + REAL_CONST(2608.4978670674823/8.0), + REAL_CONST(2618.0309747848837/8.0), + REAL_CONST(2627.5727687136259/8.0), + REAL_CONST(2637.1232330677353/8.0), + REAL_CONST(2646.6823521327647/8.0), + REAL_CONST(2656.2501102652768/8.0), + REAL_CONST(2665.8264918923328/8.0), + REAL_CONST(2675.4114815109842/8.0), + REAL_CONST(2685.0050636877722/8.0), + REAL_CONST(2694.6072230582295/8.0), + REAL_CONST(2704.2179443263894/8.0), + REAL_CONST(2713.8372122642972/8.0), + REAL_CONST(2723.4650117115279/8.0), + REAL_CONST(2733.1013275747096/8.0), + REAL_CONST(2742.7461448270483/8.0), + REAL_CONST(2752.3994485078601/8.0), + REAL_CONST(2762.0612237221085/8.0), + REAL_CONST(2771.7314556399419/8.0), + REAL_CONST(2781.4101294962406/8.0), + REAL_CONST(2791.0972305901655/8.0), + REAL_CONST(2800.7927442847094/8.0), + REAL_CONST(2810.4966560062589/8.0), + REAL_CONST(2820.2089512441521/8.0), + REAL_CONST(2829.9296155502466/8.0), + REAL_CONST(2839.6586345384894/8.0), + REAL_CONST(2849.3959938844923/8.0), + REAL_CONST(2859.1416793251065/8.0), + REAL_CONST(2868.8956766580086/8.0), + REAL_CONST(2878.6579717412847/8.0), + REAL_CONST(2888.4285504930212/8.0), + REAL_CONST(2898.2073988908974/8.0), + REAL_CONST(2907.9945029717837/8.0), + REAL_CONST(2917.789848831344/8.0), + REAL_CONST(2927.5934226236377/8.0), + REAL_CONST(2937.4052105607311/8.0), + REAL_CONST(2947.2251989123079/8.0), + REAL_CONST(2957.0533740052865/8.0), + REAL_CONST(2966.8897222234368/8.0), + REAL_CONST(2976.734230007005/8.0), + REAL_CONST(2986.5868838523397/8.0), + REAL_CONST(2996.4476703115197/8.0), + REAL_CONST(3006.3165759919889/8.0), + REAL_CONST(3016.1935875561908/8.0), + REAL_CONST(3026.0786917212095/8.0), + REAL_CONST(3035.9718752584108/8.0), + REAL_CONST(3045.8731249930906/8.0), + REAL_CONST(3055.7824278041207/8.0), + REAL_CONST(3065.6997706236039/8.0), + REAL_CONST(3075.625140436528/8.0), + REAL_CONST(3085.5585242804245/8.0), + REAL_CONST(3095.4999092450298/8.0), + REAL_CONST(3105.4492824719491/8.0), + REAL_CONST(3115.4066311543256/8.0), + REAL_CONST(3125.3719425365089/8.0), + REAL_CONST(3135.3452039137287/8.0), + REAL_CONST(3145.3264026317715/8.0), + REAL_CONST(3155.3155260866592/8.0), + REAL_CONST(3165.3125617243295/8.0), + REAL_CONST(3175.3174970403229/8.0), + REAL_CONST(3185.3303195794679/8.0), + REAL_CONST(3195.35101693557/8.0), + REAL_CONST(3205.3795767511078/8.0), + REAL_CONST(3215.4159867169251/8.0), + REAL_CONST(3225.460234571929/8.0), + REAL_CONST(3235.5123081027928/8.0), + REAL_CONST(3245.5721951436558/8.0), + REAL_CONST(3255.63988357583/8.0), + REAL_CONST(3265.7153613275095/8.0), + REAL_CONST(3275.7986163734795/8.0), + REAL_CONST(3285.8896367348289/8.0), + REAL_CONST(3295.9884104786665/8.0), + REAL_CONST(3306.0949257178395/8.0), + REAL_CONST(3316.2091706106517/8.0), + REAL_CONST(3326.331133360588/8.0), + REAL_CONST(3336.4608022160378/8.0), + REAL_CONST(3346.5981654700231/8.0), + REAL_CONST(3356.7432114599264/8.0), + REAL_CONST(3366.8959285672249/8.0), + REAL_CONST(3377.0563052172211/8.0), + REAL_CONST(3387.2243298787821/8.0), + REAL_CONST(3397.3999910640764/8.0), + REAL_CONST(3407.5832773283128/8.0), + REAL_CONST(3417.7741772694862/8.0), + REAL_CONST(3427.9726795281199/8.0), + REAL_CONST(3438.1787727870123/8.0), + REAL_CONST(3448.3924457709873/8.0), + REAL_CONST(3458.6136872466445/8.0), + REAL_CONST(3468.8424860221107/8.0), + REAL_CONST(3479.0788309467976/8.0), + REAL_CONST(3489.3227109111554/8.0), + REAL_CONST(3499.5741148464344/8.0), + REAL_CONST(3509.8330317244445/8.0), + REAL_CONST(3520.0994505573185/8.0), + REAL_CONST(3530.3733603972751/8.0), + REAL_CONST(3540.6547503363886/8.0), + REAL_CONST(3550.9436095063534/8.0), + REAL_CONST(3561.239927078258/8.0), + REAL_CONST(3571.5436922623535/8.0), + REAL_CONST(3581.8548943078308/8.0), + REAL_CONST(3592.1735225025936/8.0), + REAL_CONST(3602.4995661730372/8.0), + REAL_CONST(3612.8330146838275/8.0), + REAL_CONST(3623.1738574376814/8.0), + REAL_CONST(3633.5220838751502/8.0), + REAL_CONST(3643.8776834744031/8.0), + REAL_CONST(3654.2406457510142/8.0), + REAL_CONST(3664.6109602577494/8.0), + REAL_CONST(3674.9886165843564/8.0), + REAL_CONST(3685.3736043573545/8.0), + REAL_CONST(3695.7659132398294/8.0), + REAL_CONST(3706.1655329312248/8.0), + REAL_CONST(3716.5724531671399/8.0), + REAL_CONST(3726.9866637191262/8.0), + REAL_CONST(3737.4081543944876/8.0), + REAL_CONST(3747.8369150360782/8.0), + REAL_CONST(3758.2729355221072/8.0), + REAL_CONST(3768.7162057659411/8.0), + REAL_CONST(3779.1667157159077/8.0), + REAL_CONST(3789.6244553551055/8.0), + REAL_CONST(3800.0894147012082/8.0), + REAL_CONST(3810.5615838062768/8.0), + REAL_CONST(3821.0409527565694/8.0), + REAL_CONST(3831.5275116723533/8.0), + REAL_CONST(3842.0212507077194/8.0), + REAL_CONST(3852.522160050396/8.0), + REAL_CONST(3863.0302299215673/8.0), + REAL_CONST(3873.5454505756893/8.0), + REAL_CONST(3884.0678123003108/8.0), + REAL_CONST(3894.5973054158922/8.0), + REAL_CONST(3905.1339202756285/8.0), + REAL_CONST(3915.6776472652732/8.0), + REAL_CONST(3926.2284768029604/8.0), + REAL_CONST(3936.7863993390338/8.0), + REAL_CONST(3947.3514053558706/8.0), + REAL_CONST(3957.9234853677135/8.0), + REAL_CONST(3968.5026299204969/8.0), + REAL_CONST(3979.0888295916798/8.0), + REAL_CONST(3989.6820749900776/8.0), + REAL_CONST(4000.2823567556948/8.0), + REAL_CONST(4010.8896655595613/8.0), + REAL_CONST(4021.5039921035655/8.0), + REAL_CONST(4032.1253271202945/8.0), + REAL_CONST(4042.7536613728694/8.0), + REAL_CONST(4053.3889856547858/8.0), + REAL_CONST(4064.0312907897551/8.0), + REAL_CONST(4074.6805676315448/8.0), + REAL_CONST(4085.3368070638221/8.0), + REAL_CONST(4095.9999999999982/8.0), + REAL_CONST(4106.6701373830711/8.0), + REAL_CONST(4117.347210185475/8.0), + REAL_CONST(4128.0312094089259/8.0), + REAL_CONST(4138.722126084268/8.0), + REAL_CONST(4149.4199512713267/8.0), + REAL_CONST(4160.1246760587583/8.0), + REAL_CONST(4170.8362915638982/8.0), + REAL_CONST(4181.5547889326181/8.0), + REAL_CONST(4192.2801593391769/8.0), + REAL_CONST(4203.0123939860741/8.0), + REAL_CONST(4213.7514841039101/8.0), + REAL_CONST(4224.4974209512384/8.0), + REAL_CONST(4235.2501958144258/8.0), + REAL_CONST(4246.0098000075095/8.0), + REAL_CONST(4256.7762248720574/8.0), + REAL_CONST(4267.549461777031/8.0), + REAL_CONST(4278.3295021186423/8.0), + REAL_CONST(4289.1163373202198/8.0), + REAL_CONST(4299.9099588320714/8.0), + REAL_CONST(4310.7103581313495/8.0), + REAL_CONST(4321.5175267219138/8.0), + REAL_CONST(4332.3314561342004/8.0), + REAL_CONST(4343.152137925088/8.0), + REAL_CONST(4353.9795636777671/8.0), + REAL_CONST(4364.8137250016052/8.0), + REAL_CONST(4375.6546135320223/8.0), + REAL_CONST(4386.5022209303588/8.0), + REAL_CONST(4397.3565388837469/8.0), + REAL_CONST(4408.2175591049827/8.0), + REAL_CONST(4419.0852733324018/8.0), + REAL_CONST(4429.9596733297531/8.0), + REAL_CONST(4440.8407508860728/8.0), + REAL_CONST(4451.7284978155603/8.0), + REAL_CONST(4462.6229059574571/8.0), + REAL_CONST(4473.5239671759227/8.0), + REAL_CONST(4484.4316733599126/8.0), + REAL_CONST(4495.3460164230582/8.0), + REAL_CONST(4506.2669883035496/8.0), + REAL_CONST(4517.1945809640119/8.0), + REAL_CONST(4528.1287863913894/8.0), + REAL_CONST(4539.069596596828/8.0), + REAL_CONST(4550.0170036155587/8.0), + REAL_CONST(4560.9709995067806/8.0), + REAL_CONST(4571.931576353546/8.0), + REAL_CONST(4582.898726262647/8.0), + REAL_CONST(4593.8724413645004/8.0), + REAL_CONST(4604.8527138130348/8.0), + REAL_CONST(4615.8395357855816/8.0), + REAL_CONST(4626.8328994827571/8.0), + REAL_CONST(4637.8327971283588/8.0), + REAL_CONST(4648.8392209692511/8.0), + REAL_CONST(4659.8521632752563/8.0), + REAL_CONST(4670.8716163390473/8.0), + REAL_CONST(4681.8975724760394/8.0), + REAL_CONST(4692.9300240242837/8.0), + REAL_CONST(4703.9689633443595/8.0), + REAL_CONST(4715.0143828192668/8.0), + REAL_CONST(4726.0662748543255/8.0), + REAL_CONST(4737.1246318770682/8.0), + REAL_CONST(4748.1894463371373/8.0), + REAL_CONST(4759.2607107061804/8.0), + REAL_CONST(4770.3384174777493/8.0), + REAL_CONST(4781.4225591671993/8.0), + REAL_CONST(4792.5131283115852/8.0), + REAL_CONST(4803.6101174695614/8.0), + REAL_CONST(4814.7135192212854/8.0), + REAL_CONST(4825.8233261683154/8.0), + REAL_CONST(4836.9395309335096/8.0), + REAL_CONST(4848.0621261609349/8.0), + REAL_CONST(4859.1911045157631/8.0), + REAL_CONST(4870.3264586841779/8.0), + REAL_CONST(4881.4681813732768/8.0), + REAL_CONST(4892.6162653109768/8.0), + REAL_CONST(4903.7707032459193/8.0), + REAL_CONST(4914.931487947375/8.0), + REAL_CONST(4926.0986122051509/8.0), + REAL_CONST(4937.2720688294967/8.0), + REAL_CONST(4948.4518506510112/8.0), + REAL_CONST(4959.637950520555/8.0), + REAL_CONST(4970.8303613091521/8.0), + REAL_CONST(4982.0290759079044/8.0), + REAL_CONST(4993.2340872278974/8.0), + REAL_CONST(5004.4453882001153/8.0), + REAL_CONST(5015.6629717753467/8.0), + REAL_CONST(5026.8868309241007/8.0), + REAL_CONST(5038.1169586365131/8.0), + REAL_CONST(5049.353347922266/8.0), + REAL_CONST(5060.5959918104927/8.0), + REAL_CONST(5071.8448833496996/8.0), + REAL_CONST(5083.1000156076734/8.0), + REAL_CONST(5094.3613816713996/8.0), + REAL_CONST(5105.6289746469747/8.0), + REAL_CONST(5116.9027876595246/8.0), + REAL_CONST(5128.18281385312/8.0), + REAL_CONST(5139.4690463906918/8.0), + REAL_CONST(5150.7614784539473/8.0), + REAL_CONST(5162.0601032432933/8.0), + REAL_CONST(5173.3649139777472/8.0), + REAL_CONST(5184.6759038948594/8.0), + REAL_CONST(5195.9930662506322/8.0), + REAL_CONST(5207.3163943194386/8.0), + REAL_CONST(5218.6458813939435/8.0), + REAL_CONST(5229.9815207850224/8.0), + REAL_CONST(5241.3233058216847/8.0), + REAL_CONST(5252.6712298509919/8.0), + REAL_CONST(5264.025286237983/8.0), + REAL_CONST(5275.3854683655954/8.0), + REAL_CONST(5286.7517696345885/8.0), + REAL_CONST(5298.1241834634639/8.0), + REAL_CONST(5309.5027032883945/8.0), + REAL_CONST(5320.887322563146/8.0), + REAL_CONST(5332.2780347589978/8.0), + REAL_CONST(5343.6748333646756/8.0), + REAL_CONST(5355.0777118862716/8.0), + REAL_CONST(5366.4866638471722/8.0), + REAL_CONST(5377.901682787985/8.0), + REAL_CONST(5389.3227622664635/8.0), + REAL_CONST(5400.749895857437/8.0), + REAL_CONST(5412.1830771527357/8.0), + REAL_CONST(5423.622299761123/8.0), + REAL_CONST(5435.067557308219/8.0), + REAL_CONST(5446.5188434364318/8.0), + REAL_CONST(5457.9761518048872/8.0), + REAL_CONST(5469.4394760893592/8.0), + REAL_CONST(5480.9088099821975/8.0), + REAL_CONST(5492.3841471922606/8.0), + REAL_CONST(5503.8654814448455/8.0), + REAL_CONST(5515.3528064816201/8.0), + REAL_CONST(5526.846116060552/8.0), + REAL_CONST(5538.3454039558474/8.0), + REAL_CONST(5549.8506639578736/8.0), + REAL_CONST(5561.3618898731029/8.0), + REAL_CONST(5572.8790755240361/8.0), + REAL_CONST(5584.4022147491451/8.0), + REAL_CONST(5595.9313014027975/8.0), + REAL_CONST(5607.4663293552012/8.0), + REAL_CONST(5619.0072924923297/8.0), + REAL_CONST(5630.5541847158656/8.0), + REAL_CONST(5642.1069999431284/8.0), + REAL_CONST(5653.665732107017/8.0), + REAL_CONST(5665.230375155943/8.0), + REAL_CONST(5676.8009230537655/8.0), + REAL_CONST(5688.3773697797333/8.0), + REAL_CONST(5699.9597093284156/8.0), + REAL_CONST(5711.5479357096474/8.0), + REAL_CONST(5723.1420429484588/8.0), + REAL_CONST(5734.7420250850209/8.0), + REAL_CONST(5746.347876174581/8.0), + REAL_CONST(5757.9595902874016/8.0), + REAL_CONST(5769.5771615087006/8.0), + REAL_CONST(5781.2005839385911/8.0), + REAL_CONST(5792.8298516920213/8.0), + REAL_CONST(5804.4649588987149/8.0), + REAL_CONST(5816.1058997031105/8.0), + REAL_CONST(5827.7526682643065/8.0), + REAL_CONST(5839.4052587559972/8.0), + REAL_CONST(5851.0636653664196/8.0), + REAL_CONST(5862.7278822982908/8.0), + REAL_CONST(5874.3979037687541/8.0), + REAL_CONST(5886.0737240093204/8.0), + REAL_CONST(5897.7553372658094/8.0), + REAL_CONST(5909.4427377982956/8.0), + REAL_CONST(5921.1359198810505/8.0), + REAL_CONST(5932.8348778024874/8.0), + REAL_CONST(5944.5396058651031/8.0), + REAL_CONST(5956.2500983854261/8.0), + REAL_CONST(5967.9663496939575/8.0), + REAL_CONST(5979.6883541351208/8.0), + REAL_CONST(5991.4161060672022/8.0), + REAL_CONST(6003.1495998623004/8.0), + REAL_CONST(6014.8888299062692/8.0), + REAL_CONST(6026.6337905986684/8.0), + REAL_CONST(6038.3844763527022/8.0), + REAL_CONST(6050.1408815951781/8.0), + REAL_CONST(6061.9030007664414/8.0), + REAL_CONST(6073.6708283203316/8.0), + REAL_CONST(6085.4443587241267/8.0), + REAL_CONST(6097.2235864584891/8.0), + REAL_CONST(6109.0085060174197/8.0), + REAL_CONST(6120.7991119081998/8.0), + REAL_CONST(6132.595398651345/8.0), + REAL_CONST(6144.3973607805519/8.0), + REAL_CONST(6156.2049928426459/8.0), + REAL_CONST(6168.0182893975361/8.0), + REAL_CONST(6179.8372450181578/8.0), + REAL_CONST(6191.6618542904307/8.0), + REAL_CONST(6203.4921118132024/8.0), + REAL_CONST(6215.3280121982016/8.0), + REAL_CONST(6227.1695500699925/8.0), + REAL_CONST(6239.0167200659189/8.0), + REAL_CONST(6250.8695168360628/8.0), + REAL_CONST(6262.7279350431891/8.0), + REAL_CONST(6274.5919693627056/8.0), + REAL_CONST(6286.4616144826068/8.0), + REAL_CONST(6298.3368651034316/8.0), + REAL_CONST(6310.2177159382172/8.0), + REAL_CONST(6322.1041617124456/8.0), + REAL_CONST(6333.9961971640032/8.0), + REAL_CONST(6345.8938170431311/8.0), + REAL_CONST(6357.7970161123785/8.0), + REAL_CONST(6369.7057891465583/8.0), + REAL_CONST(6381.6201309327007/8.0), + REAL_CONST(6393.5400362700075/8.0), + REAL_CONST(6405.4654999698032/8.0), + REAL_CONST(6417.3965168554978/8.0), + REAL_CONST(6429.3330817625329/8.0), + REAL_CONST(6441.2751895383453/8.0), + REAL_CONST(6453.2228350423138/8.0), + REAL_CONST(6465.176013145724/8.0), + REAL_CONST(6477.134718731716/8.0), + REAL_CONST(6489.0989466952469/8.0), + REAL_CONST(6501.0686919430445/8.0), + REAL_CONST(6513.0439493935628/8.0), + REAL_CONST(6525.0247139769417/8.0), + REAL_CONST(6537.010980634961/8.0), + REAL_CONST(6549.002744321001/8.0), + REAL_CONST(6560.9999999999973/8.0), + REAL_CONST(6573.0027426483985/8.0), + REAL_CONST(6585.0109672541284/8.0), + REAL_CONST(6597.0246688165371/8.0), + REAL_CONST(6609.0438423463656/8.0), + REAL_CONST(6621.0684828657004/8.0), + REAL_CONST(6633.0985854079354/8.0), + REAL_CONST(6645.134145017727/8.0), + REAL_CONST(6657.1751567509573/8.0), + REAL_CONST(6669.2216156746908/8.0), + REAL_CONST(6681.2735168671343/8.0), + REAL_CONST(6693.3308554176001/8.0), + REAL_CONST(6705.3936264264594/8.0), + REAL_CONST(6717.461825005108/8.0), + REAL_CONST(6729.535446275926/8.0), + REAL_CONST(6741.6144853722335/8.0), + REAL_CONST(6753.6989374382601/8.0), + REAL_CONST(6765.7887976290967/8.0), + REAL_CONST(6777.8840611106634/8.0), + REAL_CONST(6789.9847230596661/8.0), + REAL_CONST(6802.0907786635626/8.0), + REAL_CONST(6814.2022231205201/8.0), + REAL_CONST(6826.3190516393797/8.0), + REAL_CONST(6838.4412594396181/8.0), + REAL_CONST(6850.5688417513074/8.0), + REAL_CONST(6862.701793815083/8.0), + REAL_CONST(6874.840110882099/8.0), + REAL_CONST(6886.9837882139991/8.0), + REAL_CONST(6899.1328210828724/8.0), + REAL_CONST(6911.2872047712199/8.0), + REAL_CONST(6923.4469345719199/8.0), + REAL_CONST(6935.6120057881863/8.0), + REAL_CONST(6947.7824137335365/8.0), + REAL_CONST(6959.9581537317536/8.0), + REAL_CONST(6972.1392211168532/8.0), + REAL_CONST(6984.3256112330409/8.0), + REAL_CONST(6996.5173194346862/8.0), + REAL_CONST(7008.7143410862773/8.0), + REAL_CONST(7020.9166715623942/8.0), + REAL_CONST(7033.1243062476678/8.0), + REAL_CONST(7045.3372405367481/8.0), + REAL_CONST(7057.5554698342685/8.0), + REAL_CONST(7069.7789895548103/8.0), + REAL_CONST(7082.0077951228714/8.0), + REAL_CONST(7094.2418819728273/8.0), + REAL_CONST(7106.4812455489018/8.0), + REAL_CONST(7118.7258813051285/8.0), + REAL_CONST(7130.9757847053224/8.0), + REAL_CONST(7143.2309512230404/8.0), + REAL_CONST(7155.4913763415516/8.0), + REAL_CONST(7167.7570555538041/8.0), + REAL_CONST(7180.0279843623894/8.0), + REAL_CONST(7192.3041582795131/8.0), + REAL_CONST(7204.5855728269571/8.0), + REAL_CONST(7216.8722235360519/8.0), + REAL_CONST(7229.1641059476406/8.0), + REAL_CONST(7241.4612156120484/8.0), + REAL_CONST(7253.7635480890503/8.0), + REAL_CONST(7266.0710989478375/8.0), + REAL_CONST(7278.3838637669869/8.0), + REAL_CONST(7290.7018381344296/8.0), + REAL_CONST(7303.0250176474174/8.0), + REAL_CONST(7315.3533979124932/8.0), + REAL_CONST(7327.6869745454596/8.0), + REAL_CONST(7340.0257431713462/8.0), + REAL_CONST(7352.3696994243801/8.0), + REAL_CONST(7364.7188389479543/8.0), + REAL_CONST(7377.0731573945968/8.0), + REAL_CONST(7389.4326504259407/8.0), + REAL_CONST(7401.7973137126937/8.0), + REAL_CONST(7414.1671429346061/8.0), + REAL_CONST(7426.5421337804428/8.0), + REAL_CONST(7438.922281947951/8.0), + REAL_CONST(7451.3075831438346/8.0), + REAL_CONST(7463.6980330837177/8.0), + REAL_CONST(7476.0936274921214/8.0), + REAL_CONST(7488.4943621024304/8.0), + REAL_CONST(7500.9002326568652/8.0), + REAL_CONST(7513.3112349064522/8.0), + REAL_CONST(7525.7273646109943/8.0), + REAL_CONST(7538.1486175390446/8.0), + REAL_CONST(7550.5749894678729/8.0), + REAL_CONST(7563.0064761834419/8.0), + REAL_CONST(7575.4430734803736/8.0), + REAL_CONST(7587.8847771619248/8.0), + REAL_CONST(7600.3315830399597/8.0), + REAL_CONST(7612.7834869349153/8.0), + REAL_CONST(7625.24048467578/8.0), + REAL_CONST(7637.7025721000637/8.0), + REAL_CONST(7650.1697450537677/8.0), + REAL_CONST(7662.6419993913596/8.0), + REAL_CONST(7675.1193309757446/8.0), + REAL_CONST(7687.6017356782404/8.0), + REAL_CONST(7700.0892093785433/8.0), + REAL_CONST(7712.5817479647112/8.0), + REAL_CONST(7725.079347333125/8.0), + REAL_CONST(7737.5820033884729/8.0), + REAL_CONST(7750.0897120437139/8.0), + REAL_CONST(7762.6024692200581/8.0), + REAL_CONST(7775.1202708469355/8.0), + REAL_CONST(7787.6431128619733/8.0), + REAL_CONST(7800.1709912109645/8.0), + REAL_CONST(7812.7039018478481/8.0), + REAL_CONST(7825.2418407346768/8.0), + REAL_CONST(7837.7848038415968/8.0), + REAL_CONST(7850.3327871468155/8.0), + REAL_CONST(7862.8857866365806/8.0), + REAL_CONST(7875.4437983051539/8.0), + REAL_CONST(7888.006818154784/8.0), + REAL_CONST(7900.5748421956796/8.0), + REAL_CONST(7913.1478664459901/8.0), + REAL_CONST(7925.725886931772/8.0), + REAL_CONST(7938.3088996869719/8.0), + REAL_CONST(7950.8969007533951/8.0), + REAL_CONST(7963.4898861806851/8.0), + REAL_CONST(7976.0878520262959/8.0), + REAL_CONST(7988.6907943554688/8.0), + REAL_CONST(8001.2987092412086/8.0), + REAL_CONST(8013.911592764257/8.0), + REAL_CONST(8026.5294410130691/8.0), + REAL_CONST(8039.1522500837891/8.0), + REAL_CONST(8051.7800160802271/8.0), + REAL_CONST(8064.412735113835/8.0), + REAL_CONST(8077.0504033036796/8.0), + REAL_CONST(8089.6930167764222/8.0), + REAL_CONST(8102.3405716662946/8.0), + REAL_CONST(8114.9930641150731/8.0), + REAL_CONST(8127.6504902720571/8.0), + REAL_CONST(8140.3128462940449/8.0), + REAL_CONST(8152.9801283453098/8.0), + REAL_CONST(8165.6523325975786/8.0), + REAL_CONST(8178.3294552300049/8.0), + REAL_CONST(8191.0114924291529/8.0), + REAL_CONST(8203.6984403889655/8.0), + REAL_CONST(8216.3902953107463/8.0), + REAL_CONST(8229.0870534031419/8.0), + REAL_CONST(8241.7887108821069/8.0), + REAL_CONST(8254.4952639708936/8.0), + REAL_CONST(8267.2067089000211/8.0), + REAL_CONST(8279.9230419072574/8.0), + REAL_CONST(8292.6442592375952/8.0), + REAL_CONST(8305.3703571432306/8.0), + REAL_CONST(8318.101331883543/8.0), + REAL_CONST(8330.8371797250657/8.0), + REAL_CONST(8343.577896941475/8.0), + REAL_CONST(8356.3234798135582/8.0), + REAL_CONST(8369.0739246291978/8.0), + REAL_CONST(8381.8292276833508/8.0), + REAL_CONST(8394.5893852780209/8.0), + REAL_CONST(8407.3543937222421/8.0), + REAL_CONST(8420.1242493320569/8.0), + REAL_CONST(8432.8989484304948/8.0), + REAL_CONST(8445.6784873475499/8.0), + REAL_CONST(8458.4628624201578/8.0), + REAL_CONST(8471.2520699921806/8.0), + REAL_CONST(8484.0461064143838/8.0), + REAL_CONST(8496.8449680444082/8.0), + REAL_CONST(8509.6486512467636/8.0), + REAL_CONST(8522.4571523927953/8.0), + REAL_CONST(8535.270467860666/8.0), + REAL_CONST(8548.0885940353437/8.0), + REAL_CONST(8560.9115273085663/8.0), + REAL_CONST(8573.7392640788403/8.0), + REAL_CONST(8586.5718007514006/8.0), + REAL_CONST(8599.4091337382069/8.0), + REAL_CONST(8612.2512594579148/8.0), + REAL_CONST(8625.0981743358552/8.0), + REAL_CONST(8637.9498748040205/8.0), + REAL_CONST(8650.8063573010386/8.0), + REAL_CONST(8663.6676182721567/8.0), + REAL_CONST(8676.533654169225/8.0), + REAL_CONST(8689.4044614506638/8.0), + REAL_CONST(8702.2800365814601/8.0), + REAL_CONST(8715.1603760331418/8.0), + REAL_CONST(8728.0454762837508/8.0), + REAL_CONST(8740.9353338178389/8.0), + REAL_CONST(8753.8299451264356/8.0), + REAL_CONST(8766.7293067070332/8.0), + REAL_CONST(8779.6334150635721/8.0), + REAL_CONST(8792.5422667064158/8.0), + REAL_CONST(8805.4558581523324/8.0), + REAL_CONST(8818.3741859244819/8.0), + REAL_CONST(8831.2972465523908/8.0), + REAL_CONST(8844.2250365719356/8.0), + REAL_CONST(8857.1575525253265/8.0), + REAL_CONST(8870.0947909610859/8.0), + REAL_CONST(8883.0367484340295/8.0), + REAL_CONST(8895.9834215052524/8.0), + REAL_CONST(8908.934806742107/8.0), + REAL_CONST(8921.8909007181846/8.0), + REAL_CONST(8934.8517000132997/8.0), + REAL_CONST(8947.817201213471/8.0), + REAL_CONST(8960.7874009109/8.0), + REAL_CONST(8973.7622957039603/8.0), + REAL_CONST(8986.7418821971733/8.0), + REAL_CONST(8999.7261570011924/8.0), + REAL_CONST(9012.7151167327884/8.0), + REAL_CONST(9025.7087580148236/8.0), + REAL_CONST(9038.7070774762469/8.0), + REAL_CONST(9051.7100717520643/8.0), + REAL_CONST(9064.7177374833282/8.0), + REAL_CONST(9077.7300713171153/8.0), + REAL_CONST(9090.7470699065179/8.0), + REAL_CONST(9103.7687299106146/8.0), + REAL_CONST(9116.7950479944648/8.0), + REAL_CONST(9129.8260208290812/8.0), + REAL_CONST(9142.8616450914233/8.0), + REAL_CONST(9155.9019174643727/8.0), + REAL_CONST(9168.9468346367157/8.0), + REAL_CONST(9181.9963933031358/8.0), + REAL_CONST(9195.0505901641845/8.0), + REAL_CONST(9208.1094219262741/8.0), + REAL_CONST(9221.1728853016557/8.0), + REAL_CONST(9234.240977008405/8.0), + REAL_CONST(9247.3136937704076/8.0), + REAL_CONST(9260.3910323173386/8.0), + REAL_CONST(9273.472989384647/8.0), + REAL_CONST(9286.5595617135423/8.0), + REAL_CONST(9299.6507460509747/8.0), + REAL_CONST(9312.7465391496207/8.0), + REAL_CONST(9325.8469377678684/8.0), + REAL_CONST(9338.9519386698012/8.0), + REAL_CONST(9352.0615386251757/8.0), + REAL_CONST(9365.1757344094131/8.0), + REAL_CONST(9378.2945228035842/8.0), + REAL_CONST(9391.4179005943843/8.0), + REAL_CONST(9404.5458645741273/8.0), + REAL_CONST(9417.6784115407263/8.0), + REAL_CONST(9430.8155382976747/8.0), + REAL_CONST(9443.9572416540359/8.0), + REAL_CONST(9457.1035184244265/8.0), + REAL_CONST(9470.2543654290002/8.0), + REAL_CONST(9483.4097794934296/8.0), + REAL_CONST(9496.5697574488931/8.0), + REAL_CONST(9509.7342961320664/8.0), + REAL_CONST(9522.9033923850911/8.0), + REAL_CONST(9536.0770430555804/8.0), + REAL_CONST(9549.2552449965824/8.0), + REAL_CONST(9562.4379950665825/8.0), + REAL_CONST(9575.6252901294793/8.0), + REAL_CONST(9588.8171270545736/8.0), + REAL_CONST(9602.0135027165488/8.0), + REAL_CONST(9615.2144139954635/8.0), + REAL_CONST(9628.4198577767274/8.0), + REAL_CONST(9641.629830951093/8.0), + REAL_CONST(9654.844330414644/8.0), + REAL_CONST(9668.0633530687719/8.0), + REAL_CONST(9681.286895820167/8.0), + REAL_CONST(9694.5149555808002/8.0), + REAL_CONST(9707.7475292679192/8.0), + REAL_CONST(9720.9846138040157/8.0), + REAL_CONST(9734.2262061168276/8.0), + REAL_CONST(9747.4723031393187/8.0), + REAL_CONST(9760.7229018096641/8.0), + REAL_CONST(9773.9779990712323/8.0), + REAL_CONST(9787.2375918725811/8.0), + REAL_CONST(9800.5016771674327/8.0), + REAL_CONST(9813.7702519146696/8.0), + REAL_CONST(9827.0433130783094/8.0), + REAL_CONST(9840.3208576275028/8.0), + REAL_CONST(9853.602882536512/8.0), + REAL_CONST(9866.8893847846994/8.0), + REAL_CONST(9880.1803613565116/8.0), + REAL_CONST(9893.4758092414686/8.0), + REAL_CONST(9906.7757254341523/8.0), + REAL_CONST(9920.0801069341851/8.0), + REAL_CONST(9933.3889507462245/8.0), + REAL_CONST(9946.7022538799429/8.0), + REAL_CONST(9960.0200133500221/8.0), + REAL_CONST(9973.3422261761298/8.0), + REAL_CONST(9986.6688893829159/8.0), + REAL_CONST(9999.9999999999945/8.0), + REAL_CONST(10013.335555061929/8.0), + REAL_CONST(10026.675551608221/8.0), + REAL_CONST(10040.019986683301/8.0), + REAL_CONST(10053.368857336509/8.0), + REAL_CONST(10066.722160622081/8.0), + REAL_CONST(10080.079893599144/8.0), + REAL_CONST(10093.442053331697/8.0), + REAL_CONST(10106.808636888598/8.0), + REAL_CONST(10120.179641343551/8.0), + REAL_CONST(10133.555063775095/8.0), + REAL_CONST(10146.934901266595/8.0), + REAL_CONST(10160.31915090622/8.0), + REAL_CONST(10173.707809786936/8.0), + REAL_CONST(10187.100875006496/8.0), + REAL_CONST(10200.498343667417/8.0), + REAL_CONST(10213.900212876984/8.0), + REAL_CONST(10227.306479747222/8.0), + REAL_CONST(10240.717141394889/8.0), + REAL_CONST(10254.132194941467/8.0), + REAL_CONST(10267.551637513146/8.0), + REAL_CONST(10280.975466240814/8.0), + REAL_CONST(10294.40367826004/8.0), + REAL_CONST(10307.836270711066/8.0), + REAL_CONST(10321.273240738796/8.0), + REAL_CONST(10334.71458549278/8.0) +#ifdef BIG_IQ_TABLE + ,REAL_CONST(10348.160302127204/8.0), + REAL_CONST(10361.610387800878/8.0), + REAL_CONST(10375.064839677221/8.0), + REAL_CONST(10388.523654924258/8.0), + REAL_CONST(10401.986830714593/8.0), + REAL_CONST(10415.454364225412/8.0), + REAL_CONST(10428.926252638465/8.0), + REAL_CONST(10442.402493140049/8.0), + REAL_CONST(10455.883082921007/8.0), + REAL_CONST(10469.368019176709/8.0), + REAL_CONST(10482.85729910704/8.0), + REAL_CONST(10496.350919916393/8.0), + REAL_CONST(10509.848878813653/8.0), + REAL_CONST(10523.351173012188/8.0), + REAL_CONST(10536.857799729838/8.0), + REAL_CONST(10550.3687561889/8.0), + REAL_CONST(10563.884039616123/8.0), + REAL_CONST(10577.403647242685/8.0), + REAL_CONST(10590.927576304197/8.0), + REAL_CONST(10604.455824040679/8.0), + REAL_CONST(10617.988387696556/8.0), + REAL_CONST(10631.525264520642/8.0), + REAL_CONST(10645.066451766135/8.0), + REAL_CONST(10658.611946690598/8.0), + REAL_CONST(10672.161746555956/8.0), + REAL_CONST(10685.715848628475/8.0), + REAL_CONST(10699.274250178762/8.0), + REAL_CONST(10712.836948481747/8.0), + REAL_CONST(10726.403940816675/8.0), + REAL_CONST(10739.975224467091/8.0), + REAL_CONST(10753.550796720834/8.0), + REAL_CONST(10767.130654870027/8.0), + REAL_CONST(10780.714796211059/8.0), + REAL_CONST(10794.303218044579/8.0), + REAL_CONST(10807.895917675487/8.0), + REAL_CONST(10821.492892412922/8.0), + REAL_CONST(10835.094139570248/8.0), + REAL_CONST(10848.699656465047/8.0), + REAL_CONST(10862.309440419107/8.0), + REAL_CONST(10875.923488758415/8.0), + REAL_CONST(10889.541798813138/8.0), + REAL_CONST(10903.16436791762/8.0), + REAL_CONST(10916.791193410372/8.0), + REAL_CONST(10930.422272634056/8.0), + REAL_CONST(10944.05760293548/8.0), + REAL_CONST(10957.697181665582/8.0), + REAL_CONST(10971.341006179427/8.0), + REAL_CONST(10984.98907383619/8.0), + REAL_CONST(10998.641381999149/8.0), + REAL_CONST(11012.297928035676/8.0), + REAL_CONST(11025.958709317223/8.0), + REAL_CONST(11039.623723219316/8.0), + REAL_CONST(11053.292967121541/8.0), + REAL_CONST(11066.966438407539/8.0), + REAL_CONST(11080.64413446499/8.0), + REAL_CONST(11094.326052685608/8.0), + REAL_CONST(11108.012190465128/8.0), + REAL_CONST(11121.702545203296/8.0), + REAL_CONST(11135.397114303863/8.0), + REAL_CONST(11149.095895174571/8.0), + REAL_CONST(11162.798885227143/8.0), + REAL_CONST(11176.506081877278/8.0), + REAL_CONST(11190.217482544635/8.0), + REAL_CONST(11203.933084652828/8.0), + REAL_CONST(11217.652885629415/8.0), + REAL_CONST(11231.376882905886/8.0), + REAL_CONST(11245.105073917659/8.0), + REAL_CONST(11258.837456104062/8.0), + REAL_CONST(11272.574026908333/8.0), + REAL_CONST(11286.314783777601/8.0), + REAL_CONST(11300.059724162888/8.0), + REAL_CONST(11313.808845519083/8.0), + REAL_CONST(11327.562145304952/8.0), + REAL_CONST(11341.319620983111/8.0), + REAL_CONST(11355.081270020033/8.0), + REAL_CONST(11368.847089886023/8.0), + REAL_CONST(11382.617078055218/8.0), + REAL_CONST(11396.391232005579/8.0), + REAL_CONST(11410.169549218874/8.0), + REAL_CONST(11423.952027180676/8.0), + REAL_CONST(11437.738663380349/8.0), + REAL_CONST(11451.529455311042/8.0), + REAL_CONST(11465.324400469679/8.0), + REAL_CONST(11479.123496356951/8.0), + REAL_CONST(11492.926740477304/8.0), + REAL_CONST(11506.734130338931/8.0), + REAL_CONST(11520.545663453764/8.0), + REAL_CONST(11534.361337337466/8.0), + REAL_CONST(11548.181149509423/8.0), + REAL_CONST(11562.005097492724/8.0), + REAL_CONST(11575.83317881417/8.0), + REAL_CONST(11589.665391004253/8.0), + REAL_CONST(11603.501731597149/8.0), + REAL_CONST(11617.342198130715/8.0), + REAL_CONST(11631.186788146468/8.0), + REAL_CONST(11645.035499189589/8.0), + REAL_CONST(11658.888328808911/8.0), + REAL_CONST(11672.745274556904/8.0), + REAL_CONST(11686.606333989675/8.0), + REAL_CONST(11700.471504666955/8.0), + REAL_CONST(11714.340784152086/8.0), + REAL_CONST(11728.214170012021/8.0), + REAL_CONST(11742.091659817312/8.0), + REAL_CONST(11755.973251142101/8.0), + REAL_CONST(11769.858941564111/8.0), + REAL_CONST(11783.748728664636/8.0), + REAL_CONST(11797.642610028539/8.0), + REAL_CONST(11811.540583244237/8.0), + REAL_CONST(11825.442645903697/8.0), + REAL_CONST(11839.34879560242/8.0), + REAL_CONST(11853.259029939445/8.0), + REAL_CONST(11867.173346517333/8.0), + REAL_CONST(11881.091742942155/8.0), + REAL_CONST(11895.014216823492/8.0), + REAL_CONST(11908.940765774427/8.0), + REAL_CONST(11922.871387411526/8.0), + REAL_CONST(11936.806079354839/8.0), + REAL_CONST(11950.744839227897/8.0), + REAL_CONST(11964.687664657684/8.0), + REAL_CONST(11978.634553274653/8.0), + REAL_CONST(11992.585502712702/8.0), + REAL_CONST(12006.540510609168/8.0), + REAL_CONST(12020.499574604828/8.0), + REAL_CONST(12034.462692343877/8.0), + REAL_CONST(12048.429861473938/8.0), + REAL_CONST(12062.401079646032/8.0), + REAL_CONST(12076.376344514589/8.0), + REAL_CONST(12090.355653737433/8.0), + REAL_CONST(12104.339004975769/8.0), + REAL_CONST(12118.326395894188/8.0), + REAL_CONST(12132.317824160644/8.0), + REAL_CONST(12146.313287446457/8.0), + REAL_CONST(12160.312783426305/8.0), + REAL_CONST(12174.316309778205/8.0), + REAL_CONST(12188.323864183525/8.0), + REAL_CONST(12202.335444326955/8.0), + REAL_CONST(12216.351047896511/8.0), + REAL_CONST(12230.370672583531/8.0), + REAL_CONST(12244.394316082657/8.0), + REAL_CONST(12258.421976091831/8.0), + REAL_CONST(12272.453650312296/8.0), + REAL_CONST(12286.489336448574/8.0), + REAL_CONST(12300.529032208471/8.0), + REAL_CONST(12314.572735303058/8.0), + REAL_CONST(12328.620443446678/8.0), + REAL_CONST(12342.672154356922/8.0), + REAL_CONST(12356.727865754638/8.0), + REAL_CONST(12370.787575363909/8.0), + REAL_CONST(12384.851280912055/8.0), + REAL_CONST(12398.918980129623/8.0), + REAL_CONST(12412.990670750381/8.0), + REAL_CONST(12427.066350511306/8.0), + REAL_CONST(12441.146017152583/8.0), + REAL_CONST(12455.229668417589/8.0), + REAL_CONST(12469.317302052901/8.0), + REAL_CONST(12483.40891580827/8.0), + REAL_CONST(12497.50450743663/8.0), + REAL_CONST(12511.604074694078/8.0), + REAL_CONST(12525.707615339878/8.0), + REAL_CONST(12539.815127136444/8.0), + REAL_CONST(12553.926607849342/8.0), + REAL_CONST(12568.042055247275/8.0), + REAL_CONST(12582.161467102082/8.0), + REAL_CONST(12596.284841188726/8.0), + REAL_CONST(12610.41217528529/8.0), + REAL_CONST(12624.543467172971/8.0), + REAL_CONST(12638.678714636069/8.0), + REAL_CONST(12652.817915461985/8.0), + REAL_CONST(12666.961067441209/8.0), + REAL_CONST(12681.108168367316/8.0), + REAL_CONST(12695.259216036962/8.0), + REAL_CONST(12709.414208249869/8.0), + REAL_CONST(12723.573142808827/8.0), + REAL_CONST(12737.736017519681/8.0), + REAL_CONST(12751.902830191326/8.0), + REAL_CONST(12766.073578635704/8.0), + REAL_CONST(12780.248260667788/8.0), + REAL_CONST(12794.426874105588/8.0), + REAL_CONST(12808.609416770132/8.0), + REAL_CONST(12822.795886485468/8.0), + REAL_CONST(12836.986281078653/8.0), + REAL_CONST(12851.180598379744/8.0), + REAL_CONST(12865.378836221802/8.0), + REAL_CONST(12879.580992440871/8.0), + REAL_CONST(12893.787064875984/8.0), + REAL_CONST(12907.997051369144/8.0), + REAL_CONST(12922.210949765335/8.0), + REAL_CONST(12936.428757912496/8.0), + REAL_CONST(12950.650473661524/8.0), + REAL_CONST(12964.876094866273/8.0), + REAL_CONST(12979.105619383534/8.0), + REAL_CONST(12993.339045073039/8.0), + REAL_CONST(13007.576369797454/8.0), + REAL_CONST(13021.817591422368/8.0), + REAL_CONST(13036.062707816285/8.0), + REAL_CONST(13050.311716850629/8.0), + REAL_CONST(13064.564616399723/8.0), + REAL_CONST(13078.821404340792/8.0), + REAL_CONST(13093.082078553954/8.0), + REAL_CONST(13107.346636922217/8.0), + REAL_CONST(13121.615077331464/8.0), + REAL_CONST(13135.887397670458/8.0), + REAL_CONST(13150.163595830827/8.0), + REAL_CONST(13164.44366970706/8.0), + REAL_CONST(13178.727617196502/8.0), + REAL_CONST(13193.015436199352/8.0), + REAL_CONST(13207.307124618648/8.0), + REAL_CONST(13221.602680360265/8.0), + REAL_CONST(13235.902101332911/8.0), + REAL_CONST(13250.205385448118/8.0), + REAL_CONST(13264.512530620239/8.0), + REAL_CONST(13278.823534766434/8.0), + REAL_CONST(13293.138395806676/8.0), + REAL_CONST(13307.457111663734/8.0), + REAL_CONST(13321.779680263176/8.0), + REAL_CONST(13336.106099533356/8.0), + REAL_CONST(13350.436367405409/8.0), + REAL_CONST(13364.77048181325/8.0), + REAL_CONST(13379.108440693562/8.0), + REAL_CONST(13393.450241985796/8.0), + REAL_CONST(13407.795883632158/8.0), + REAL_CONST(13422.145363577607/8.0), + REAL_CONST(13436.498679769853/8.0), + REAL_CONST(13450.855830159346/8.0), + REAL_CONST(13465.216812699266/8.0), + REAL_CONST(13479.581625345529/8.0), + REAL_CONST(13493.950266056772/8.0), + REAL_CONST(13508.32273279435/8.0), + REAL_CONST(13522.699023522329/8.0), + REAL_CONST(13537.079136207483/8.0), + REAL_CONST(13551.463068819286/8.0), + REAL_CONST(13565.850819329906/8.0), + REAL_CONST(13580.2423857142/8.0), + REAL_CONST(13594.63776594971/8.0), + REAL_CONST(13609.036958016657/8.0), + REAL_CONST(13623.439959897927/8.0), + REAL_CONST(13637.846769579081/8.0), + REAL_CONST(13652.257385048335/8.0), + REAL_CONST(13666.67180429656/8.0), + REAL_CONST(13681.090025317284/8.0), + REAL_CONST(13695.512046106669/8.0), + REAL_CONST(13709.937864663521/8.0), + REAL_CONST(13724.367478989278/8.0), + REAL_CONST(13738.800887088004/8.0), + REAL_CONST(13753.238086966385/8.0), + REAL_CONST(13767.679076633727/8.0), + REAL_CONST(13782.123854101939/8.0), + REAL_CONST(13796.572417385545/8.0), + REAL_CONST(13811.024764501659/8.0), + REAL_CONST(13825.480893469998/8.0), + REAL_CONST(13839.94080231286/8.0), + REAL_CONST(13854.404489055134/8.0), + REAL_CONST(13868.871951724283/8.0), + REAL_CONST(13883.34318835034/8.0), + REAL_CONST(13897.818196965914/8.0), + REAL_CONST(13912.296975606168/8.0), + REAL_CONST(13926.779522308825/8.0), + REAL_CONST(13941.26583511416/8.0), + REAL_CONST(13955.755912064991/8.0), + REAL_CONST(13970.249751206682/8.0), + REAL_CONST(13984.747350587126/8.0), + REAL_CONST(13999.248708256751/8.0), + REAL_CONST(14013.753822268511/8.0), + REAL_CONST(14028.262690677873/8.0), + REAL_CONST(14042.775311542828/8.0), + REAL_CONST(14057.291682923867/8.0), + REAL_CONST(14071.811802883994/8.0), + REAL_CONST(14086.335669488704/8.0), + REAL_CONST(14100.863280805994/8.0), + REAL_CONST(14115.394634906341/8.0), + REAL_CONST(14129.92972986271/8.0), + REAL_CONST(14144.468563750548/8.0), + REAL_CONST(14159.01113464777/8.0), + REAL_CONST(14173.55744063476/8.0), + REAL_CONST(14188.107479794369/8.0), + REAL_CONST(14202.661250211901/8.0), + REAL_CONST(14217.218749975118/8.0), + REAL_CONST(14231.779977174227/8.0), + REAL_CONST(14246.344929901879/8.0), + REAL_CONST(14260.913606253163/8.0), + REAL_CONST(14275.486004325601/8.0), + REAL_CONST(14290.062122219146/8.0), + REAL_CONST(14304.641958036171/8.0), + REAL_CONST(14319.225509881464/8.0), + REAL_CONST(14333.812775862236/8.0), + REAL_CONST(14348.403754088098/8.0), + REAL_CONST(14362.998442671067/8.0), + REAL_CONST(14377.59683972556/8.0), + REAL_CONST(14392.198943368388/8.0), + REAL_CONST(14406.804751718748/8.0), + REAL_CONST(14421.414262898223/8.0), + REAL_CONST(14436.027475030774/8.0), + REAL_CONST(14450.64438624274/8.0), + REAL_CONST(14465.264994662828/8.0), + REAL_CONST(14479.889298422106/8.0), + REAL_CONST(14494.517295654005/8.0), + REAL_CONST(14509.148984494313/8.0), + REAL_CONST(14523.784363081166/8.0), + REAL_CONST(14538.423429555049/8.0), + REAL_CONST(14553.066182058781/8.0), + REAL_CONST(14567.712618737527/8.0), + REAL_CONST(14582.362737738777/8.0), + REAL_CONST(14597.016537212348/8.0), + REAL_CONST(14611.674015310382/8.0), + REAL_CONST(14626.33517018734/8.0), + REAL_CONST(14640.999999999993/8.0), + REAL_CONST(14655.668502907418/8.0), + REAL_CONST(14670.340677071003/8.0), + REAL_CONST(14685.016520654426/8.0), + REAL_CONST(14699.696031823671/8.0), + REAL_CONST(14714.379208746999/8.0), + REAL_CONST(14729.066049594967/8.0), + REAL_CONST(14743.756552540408/8.0), + REAL_CONST(14758.45071575843/8.0), + REAL_CONST(14773.148537426418/8.0), + REAL_CONST(14787.850015724018/8.0), + REAL_CONST(14802.555148833142/8.0), + REAL_CONST(14817.263934937961/8.0), + REAL_CONST(14831.976372224897/8.0), + REAL_CONST(14846.692458882624/8.0), + REAL_CONST(14861.41219310206/8.0), + REAL_CONST(14876.135573076363/8.0), + REAL_CONST(14890.862597000923/8.0), + REAL_CONST(14905.593263073371/8.0), + REAL_CONST(14920.327569493558/8.0), + REAL_CONST(14935.065514463557/8.0), + REAL_CONST(14949.807096187662/8.0), + REAL_CONST(14964.552312872382/8.0), + REAL_CONST(14979.301162726431/8.0), + REAL_CONST(14994.053643960735/8.0), + REAL_CONST(15008.809754788414/8.0), + REAL_CONST(15023.569493424788/8.0), + REAL_CONST(15038.332858087369/8.0), + REAL_CONST(15053.099846995858/8.0), + REAL_CONST(15067.870458372134/8.0), + REAL_CONST(15082.644690440264/8.0), + REAL_CONST(15097.422541426484/8.0), + REAL_CONST(15112.204009559202/8.0), + REAL_CONST(15126.989093068994/8.0), + REAL_CONST(15141.777790188597/8.0), + REAL_CONST(15156.570099152905/8.0), + REAL_CONST(15171.366018198967/8.0), + REAL_CONST(15186.165545565986/8.0), + REAL_CONST(15200.968679495301/8.0), + REAL_CONST(15215.775418230402/8.0), + REAL_CONST(15230.585760016909/8.0), + REAL_CONST(15245.399703102579/8.0), + REAL_CONST(15260.217245737298/8.0), + REAL_CONST(15275.038386173073/8.0), + REAL_CONST(15289.863122664035/8.0), + REAL_CONST(15304.691453466432/8.0), + REAL_CONST(15319.523376838621/8.0), + REAL_CONST(15334.358891041069/8.0), + REAL_CONST(15349.197994336346/8.0), + REAL_CONST(15364.040684989128/8.0), + REAL_CONST(15378.886961266177/8.0), + REAL_CONST(15393.736821436356/8.0), + REAL_CONST(15408.590263770609/8.0), + REAL_CONST(15423.447286541972/8.0), + REAL_CONST(15438.307888025554/8.0), + REAL_CONST(15453.172066498542/8.0), + REAL_CONST(15468.039820240196/8.0), + REAL_CONST(15482.91114753184/8.0), + REAL_CONST(15497.786046656869/8.0), + REAL_CONST(15512.664515900733/8.0), + REAL_CONST(15527.546553550939/8.0), + REAL_CONST(15542.432157897045/8.0), + REAL_CONST(15557.32132723066/8.0), + REAL_CONST(15572.214059845435/8.0), + REAL_CONST(15587.110354037064/8.0), + REAL_CONST(15602.010208103273/8.0), + REAL_CONST(15616.913620343823/8.0), + REAL_CONST(15631.820589060506/8.0), + REAL_CONST(15646.731112557136/8.0), + REAL_CONST(15661.645189139546/8.0), + REAL_CONST(15676.562817115593/8.0), + REAL_CONST(15691.483994795139/8.0), + REAL_CONST(15706.408720490062/8.0), + REAL_CONST(15721.336992514242/8.0), + REAL_CONST(15736.268809183561/8.0), + REAL_CONST(15751.204168815901/8.0), + REAL_CONST(15766.143069731135/8.0), + REAL_CONST(15781.085510251132/8.0), + REAL_CONST(15796.03148869974/8.0), + REAL_CONST(15810.981003402798/8.0), + REAL_CONST(15825.934052688119/8.0), + REAL_CONST(15840.890634885489/8.0), + REAL_CONST(15855.850748326673/8.0), + REAL_CONST(15870.814391345401/8.0), + REAL_CONST(15885.781562277361/8.0), + REAL_CONST(15900.752259460214/8.0), + REAL_CONST(15915.726481233565/8.0), + REAL_CONST(15930.704225938984/8.0), + REAL_CONST(15945.685491919978/8.0), + REAL_CONST(15960.670277522009/8.0), + REAL_CONST(15975.658581092481/8.0), + REAL_CONST(15990.65040098073/8.0), + REAL_CONST(16005.645735538035/8.0), + REAL_CONST(16020.644583117599/8.0), + REAL_CONST(16035.646942074556/8.0), + REAL_CONST(16050.652810765967/8.0), + REAL_CONST(16065.662187550806/8.0), + REAL_CONST(16080.675070789974/8.0), + REAL_CONST(16095.691458846273/8.0), + REAL_CONST(16110.711350084424/8.0), + REAL_CONST(16125.734742871053/8.0), + REAL_CONST(16140.761635574685/8.0), + REAL_CONST(16155.792026565747/8.0), + REAL_CONST(16170.825914216561/8.0), + REAL_CONST(16185.863296901338/8.0), + REAL_CONST(16200.904172996183/8.0), + REAL_CONST(16215.948540879079/8.0), + REAL_CONST(16230.996398929899/8.0), + REAL_CONST(16246.047745530386/8.0), + REAL_CONST(16261.102579064163/8.0), + REAL_CONST(16276.160897916721/8.0), + REAL_CONST(16291.22270047542/8.0), + REAL_CONST(16306.287985129484/8.0), + REAL_CONST(16321.356750269995/8.0), + REAL_CONST(16336.428994289896/8.0), + REAL_CONST(16351.504715583982/8.0), + REAL_CONST(16366.5839125489/8.0), + REAL_CONST(16381.666583583141/8.0), + REAL_CONST(16396.752727087041/8.0), + REAL_CONST(16411.842341462776/8.0), + REAL_CONST(16426.935425114363/8.0), + REAL_CONST(16442.031976447644/8.0), + REAL_CONST(16457.131993870298/8.0), + REAL_CONST(16472.235475791829/8.0), + REAL_CONST(16487.342420623561/8.0), + REAL_CONST(16502.452826778641/8.0), + REAL_CONST(16517.566692672033/8.0), + REAL_CONST(16532.684016720516/8.0), + REAL_CONST(16547.804797342676/8.0), + REAL_CONST(16562.929032958902/8.0), + REAL_CONST(16578.056721991394/8.0), + REAL_CONST(16593.18786286415/8.0), + REAL_CONST(16608.322454002962/8.0), + REAL_CONST(16623.460493835417/8.0), + REAL_CONST(16638.601980790896/8.0), + REAL_CONST(16653.746913300558/8.0), + REAL_CONST(16668.895289797354/8.0), + REAL_CONST(16684.047108716015/8.0), + REAL_CONST(16699.202368493046/8.0), + REAL_CONST(16714.361067566726/8.0), + REAL_CONST(16729.523204377107/8.0), + REAL_CONST(16744.688777366009/8.0), + REAL_CONST(16759.857784977012/8.0), + REAL_CONST(16775.030225655464/8.0), + REAL_CONST(16790.206097848466/8.0), + REAL_CONST(16805.385400004874/8.0), + REAL_CONST(16820.568130575302/8.0), + REAL_CONST(16835.754288012104/8.0), + REAL_CONST(16850.943870769381/8.0), + REAL_CONST(16866.136877302983/8.0), + REAL_CONST(16881.333306070494/8.0), + REAL_CONST(16896.53315553123/8.0), + REAL_CONST(16911.736424146249/8.0), + REAL_CONST(16926.943110378332/8.0), + REAL_CONST(16942.153212691992/8.0), + REAL_CONST(16957.366729553454/8.0), + REAL_CONST(16972.583659430682/8.0), + REAL_CONST(16987.804000793338/8.0), + REAL_CONST(17003.027752112816/8.0), + REAL_CONST(17018.254911862205/8.0), + REAL_CONST(17033.485478516312/8.0), + REAL_CONST(17048.719450551645/8.0), + REAL_CONST(17063.956826446421/8.0), + REAL_CONST(17079.197604680547/8.0), + REAL_CONST(17094.44178373563/8.0), + REAL_CONST(17109.689362094967/8.0), + REAL_CONST(17124.940338243552/8.0), + REAL_CONST(17140.194710668064/8.0), + REAL_CONST(17155.452477856852/8.0), + REAL_CONST(17170.713638299967/8.0), + REAL_CONST(17185.978190489128/8.0), + REAL_CONST(17201.246132917724/8.0), + REAL_CONST(17216.517464080825/8.0), + REAL_CONST(17231.792182475165/8.0), + REAL_CONST(17247.070286599141/8.0), + REAL_CONST(17262.351774952826/8.0), + REAL_CONST(17277.636646037936/8.0), + REAL_CONST(17292.924898357855/8.0), + REAL_CONST(17308.216530417623/8.0), + REAL_CONST(17323.511540723921/8.0), + REAL_CONST(17338.809927785089/8.0), + REAL_CONST(17354.111690111105/8.0), + REAL_CONST(17369.416826213594/8.0), + REAL_CONST(17384.725334605821/8.0), + REAL_CONST(17400.037213802683/8.0), + REAL_CONST(17415.352462320716/8.0), + REAL_CONST(17430.67107867809/8.0), + REAL_CONST(17445.993061394587/8.0), + REAL_CONST(17461.318408991636/8.0), + REAL_CONST(17476.647119992274/8.0), + REAL_CONST(17491.979192921168/8.0), + REAL_CONST(17507.314626304586/8.0), + REAL_CONST(17522.653418670423/8.0), + REAL_CONST(17537.995568548187/8.0), + REAL_CONST(17553.341074468986/8.0), + REAL_CONST(17568.689934965536/8.0), + REAL_CONST(17584.042148572156/8.0), + REAL_CONST(17599.397713824768/8.0), + REAL_CONST(17614.75662926089/8.0), + REAL_CONST(17630.118893419625/8.0), + REAL_CONST(17645.484504841683/8.0), + REAL_CONST(17660.853462069354/8.0), + REAL_CONST(17676.225763646511/8.0), + REAL_CONST(17691.601408118619/8.0), + REAL_CONST(17706.980394032718/8.0), + REAL_CONST(17722.362719937424/8.0), + REAL_CONST(17737.748384382936/8.0), + REAL_CONST(17753.137385921014/8.0), + REAL_CONST(17768.529723104999/8.0), + REAL_CONST(17783.92539448979/8.0), + REAL_CONST(17799.324398631856/8.0), + REAL_CONST(17814.726734089225/8.0), + REAL_CONST(17830.13239942148/8.0), + REAL_CONST(17845.541393189767/8.0), + REAL_CONST(17860.95371395678/8.0), + REAL_CONST(17876.369360286772/8.0), + REAL_CONST(17891.788330745527/8.0), + REAL_CONST(17907.210623900395/8.0), + REAL_CONST(17922.636238320254/8.0), + REAL_CONST(17938.065172575527/8.0), + REAL_CONST(17953.497425238176/8.0), + REAL_CONST(17968.932994881692/8.0), + REAL_CONST(17984.371880081104/8.0), + REAL_CONST(17999.814079412972/8.0), + REAL_CONST(18015.259591455371/8.0), + REAL_CONST(18030.708414787914/8.0), + REAL_CONST(18046.160547991731/8.0), + REAL_CONST(18061.615989649465/8.0), + REAL_CONST(18077.074738345284/8.0), + REAL_CONST(18092.536792664861/8.0), + REAL_CONST(18108.002151195393/8.0), + REAL_CONST(18123.470812525571/8.0), + REAL_CONST(18138.942775245599/8.0), + REAL_CONST(18154.418037947191/8.0), + REAL_CONST(18169.896599223546/8.0), + REAL_CONST(18185.37845766938/8.0), + REAL_CONST(18200.863611880886/8.0), + REAL_CONST(18216.352060455767/8.0), + REAL_CONST(18231.843801993204/8.0), + REAL_CONST(18247.338835093873/8.0), + REAL_CONST(18262.837158359936/8.0), + REAL_CONST(18278.338770395032/8.0), + REAL_CONST(18293.84366980429/8.0), + REAL_CONST(18309.351855194309/8.0), + REAL_CONST(18324.863325173166/8.0), + REAL_CONST(18340.378078350412/8.0), + REAL_CONST(18355.896113337069/8.0), + REAL_CONST(18371.417428745623/8.0), + REAL_CONST(18386.942023190033/8.0), + REAL_CONST(18402.469895285718/8.0), + REAL_CONST(18418.00104364955/8.0), + REAL_CONST(18433.53546689987/8.0), + REAL_CONST(18449.073163656474/8.0), + REAL_CONST(18464.614132540602/8.0), + REAL_CONST(18480.158372174956/8.0), + REAL_CONST(18495.705881183676/8.0), + REAL_CONST(18511.256658192357/8.0), + REAL_CONST(18526.810701828035/8.0), + REAL_CONST(18542.368010719183/8.0), + REAL_CONST(18557.928583495715/8.0), + REAL_CONST(18573.492418788985/8.0), + REAL_CONST(18589.059515231773/8.0), + REAL_CONST(18604.629871458303/8.0), + REAL_CONST(18620.203486104212/8.0), + REAL_CONST(18635.78035780658/8.0), + REAL_CONST(18651.360485203899/8.0), + REAL_CONST(18666.943866936086/8.0), + REAL_CONST(18682.53050164448/8.0), + REAL_CONST(18698.120387971841/8.0), + REAL_CONST(18713.713524562332/8.0), + REAL_CONST(18729.30991006154/8.0), + REAL_CONST(18744.909543116457/8.0), + REAL_CONST(18760.512422375479/8.0), + REAL_CONST(18776.118546488418/8.0), + REAL_CONST(18791.727914106479/8.0), + REAL_CONST(18807.340523882274/8.0), + REAL_CONST(18822.95637446981/8.0), + REAL_CONST(18838.575464524489/8.0), + REAL_CONST(18854.197792703111/8.0), + REAL_CONST(18869.823357663863/8.0), + REAL_CONST(18885.452158066328/8.0), + REAL_CONST(18901.08419257147/8.0), + REAL_CONST(18916.719459841639/8.0), + REAL_CONST(18932.357958540564/8.0), + REAL_CONST(18947.999687333362/8.0), + REAL_CONST(18963.644644886521/8.0), + REAL_CONST(18979.292829867907/8.0), + REAL_CONST(18994.944240946759/8.0), + REAL_CONST(19010.598876793687/8.0), + REAL_CONST(19026.256736080668/8.0), + REAL_CONST(19041.917817481048/8.0), + REAL_CONST(19057.582119669532/8.0), + REAL_CONST(19073.2496413222/8.0), + REAL_CONST(19088.920381116473/8.0), + REAL_CONST(19104.594337731145/8.0), + REAL_CONST(19120.271509846356/8.0), + REAL_CONST(19135.951896143604/8.0), + REAL_CONST(19151.635495305738/8.0), + REAL_CONST(19167.322306016948/8.0), + REAL_CONST(19183.012326962784/8.0), + REAL_CONST(19198.705556830122/8.0), + REAL_CONST(19214.401994307198/8.0), + REAL_CONST(19230.101638083579/8.0), + REAL_CONST(19245.804486850167/8.0), + REAL_CONST(19261.510539299208/8.0), + REAL_CONST(19277.219794124274/8.0), + REAL_CONST(19292.932250020265/8.0), + REAL_CONST(19308.647905683421/8.0), + REAL_CONST(19324.366759811302/8.0), + REAL_CONST(19340.088811102793/8.0), + REAL_CONST(19355.8140582581/8.0), + REAL_CONST(19371.542499978754/8.0), + REAL_CONST(19387.2741349676/8.0), + REAL_CONST(19403.008961928797/8.0), + REAL_CONST(19418.746979567823/8.0), + REAL_CONST(19434.488186591469/8.0), + REAL_CONST(19450.232581707827/8.0), + REAL_CONST(19465.980163626304/8.0), + REAL_CONST(19481.730931057613/8.0), + REAL_CONST(19497.484882713761/8.0), + REAL_CONST(19513.242017308068/8.0), + REAL_CONST(19529.002333555141/8.0), + REAL_CONST(19544.765830170898/8.0), + REAL_CONST(19560.532505872539/8.0), + REAL_CONST(19576.302359378566/8.0), + REAL_CONST(19592.075389408761/8.0), + REAL_CONST(19607.851594684209/8.0), + REAL_CONST(19623.630973927269/8.0), + REAL_CONST(19639.41352586159/8.0), + REAL_CONST(19655.199249212103/8.0), + REAL_CONST(19670.988142705017/8.0), + REAL_CONST(19686.780205067826/8.0), + REAL_CONST(19702.575435029288/8.0), + REAL_CONST(19718.373831319448/8.0), + REAL_CONST(19734.175392669615/8.0), + REAL_CONST(19749.980117812371/8.0), + REAL_CONST(19765.788005481569/8.0), + REAL_CONST(19781.599054412323/8.0), + REAL_CONST(19797.413263341008/8.0), + REAL_CONST(19813.230631005274/8.0), + REAL_CONST(19829.051156144014/8.0), + REAL_CONST(19844.874837497395/8.0), + REAL_CONST(19860.701673806827/8.0), + REAL_CONST(19876.531663814985/8.0), + REAL_CONST(19892.364806265789/8.0), + REAL_CONST(19908.201099904403/8.0), + REAL_CONST(19924.040543477258/8.0), + REAL_CONST(19939.883135732012/8.0), + REAL_CONST(19955.728875417579/8.0), + REAL_CONST(19971.577761284105/8.0), + REAL_CONST(19987.429792082985/8.0), + REAL_CONST(20003.284966566847/8.0), + REAL_CONST(20019.14328348956/8.0), + REAL_CONST(20035.004741606219/8.0), + REAL_CONST(20050.869339673161/8.0), + REAL_CONST(20066.737076447946/8.0), + REAL_CONST(20082.607950689362/8.0), + REAL_CONST(20098.481961157428/8.0), + REAL_CONST(20114.359106613385/8.0), + REAL_CONST(20130.239385819699/8.0), + REAL_CONST(20146.122797540058/8.0), + REAL_CONST(20162.009340539353/8.0), + REAL_CONST(20177.899013583716/8.0), + REAL_CONST(20193.791815440476/8.0), + REAL_CONST(20209.687744878182/8.0), + REAL_CONST(20225.586800666591/8.0), + REAL_CONST(20241.488981576669/8.0), + REAL_CONST(20257.394286380597/8.0), + REAL_CONST(20273.302713851754/8.0), + REAL_CONST(20289.214262764715/8.0), + REAL_CONST(20305.128931895277/8.0), + REAL_CONST(20321.046720020415/8.0), + REAL_CONST(20336.967625918318/8.0), + REAL_CONST(20352.891648368361/8.0), + REAL_CONST(20368.818786151114/8.0), + REAL_CONST(20384.749038048347/8.0), + REAL_CONST(20400.682402843009/8.0), + REAL_CONST(20416.618879319249/8.0), + REAL_CONST(20432.558466262391/8.0), + REAL_CONST(20448.501162458953/8.0), + REAL_CONST(20464.446966696629/8.0), + REAL_CONST(20480.395877764302/8.0), + REAL_CONST(20496.347894452025/8.0), + REAL_CONST(20512.303015551031/8.0), + REAL_CONST(20528.261239853735/8.0), + REAL_CONST(20544.22256615372/8.0), + REAL_CONST(20560.186993245738/8.0), + REAL_CONST(20576.15451992572/8.0), + REAL_CONST(20592.125144990758/8.0), + REAL_CONST(20608.098867239107/8.0), + REAL_CONST(20624.075685470198/8.0), + REAL_CONST(20640.055598484618/8.0), + REAL_CONST(20656.038605084115/8.0), + REAL_CONST(20672.024704071595/8.0), + REAL_CONST(20688.013894251126/8.0), + REAL_CONST(20704.006174427926/8.0), + REAL_CONST(20720.001543408373/8.0), + REAL_CONST(20735.999999999989/8.0), + REAL_CONST(20752.001543011454/8.0), + REAL_CONST(20768.006171252597/8.0), + REAL_CONST(20784.013883534382/8.0), + REAL_CONST(20800.024678668931/8.0), + REAL_CONST(20816.038555469506/8.0), + REAL_CONST(20832.055512750507/8.0), + REAL_CONST(20848.075549327474/8.0), + REAL_CONST(20864.098664017085/8.0), + REAL_CONST(20880.124855637161/8.0), + REAL_CONST(20896.154123006647/8.0), + REAL_CONST(20912.186464945626/8.0), + REAL_CONST(20928.221880275312/8.0), + REAL_CONST(20944.260367818049/8.0), + REAL_CONST(20960.301926397311/8.0), + REAL_CONST(20976.346554837684/8.0), + REAL_CONST(20992.394251964895/8.0), + REAL_CONST(21008.445016605787/8.0), + REAL_CONST(21024.498847588318/8.0), + REAL_CONST(21040.555743741574/8.0), + REAL_CONST(21056.615703895754/8.0), + REAL_CONST(21072.678726882168/8.0), + REAL_CONST(21088.744811533252/8.0), + REAL_CONST(21104.813956682538/8.0), + REAL_CONST(21120.886161164683/8.0), + REAL_CONST(21136.961423815443/8.0), + REAL_CONST(21153.039743471683/8.0), + REAL_CONST(21169.121118971379/8.0), + REAL_CONST(21185.205549153605/8.0), + REAL_CONST(21201.293032858535/8.0), + REAL_CONST(21217.383568927453/8.0), + REAL_CONST(21233.477156202731/8.0), + REAL_CONST(21249.573793527841/8.0), + REAL_CONST(21265.673479747358/8.0), + REAL_CONST(21281.776213706937/8.0), + REAL_CONST(21297.881994253334/8.0), + REAL_CONST(21313.990820234398/8.0), + REAL_CONST(21330.102690499054/8.0), + REAL_CONST(21346.21760389733/8.0), + REAL_CONST(21362.335559280327/8.0), + REAL_CONST(21378.456555500241/8.0), + REAL_CONST(21394.580591410333/8.0), + REAL_CONST(21410.707665864964/8.0), + REAL_CONST(21426.83777771956/8.0), + REAL_CONST(21442.970925830628/8.0), + REAL_CONST(21459.107109055756/8.0), + REAL_CONST(21475.246326253604/8.0), + REAL_CONST(21491.388576283895/8.0), + REAL_CONST(21507.533858007431/8.0), + REAL_CONST(21523.682170286087/8.0), + REAL_CONST(21539.833511982797/8.0), + REAL_CONST(21555.987881961566/8.0), + REAL_CONST(21572.145279087465/8.0), + REAL_CONST(21588.305702226615/8.0), + REAL_CONST(21604.469150246216/8.0), + REAL_CONST(21620.635622014521/8.0), + REAL_CONST(21636.805116400832/8.0), + REAL_CONST(21652.977632275521/8.0), + REAL_CONST(21669.153168510009/8.0), + REAL_CONST(21685.331723976764/8.0), + REAL_CONST(21701.513297549318/8.0), + REAL_CONST(21717.697888102244/8.0), + REAL_CONST(21733.885494511167/8.0), + REAL_CONST(21750.076115652759/8.0), + REAL_CONST(21766.269750404736/8.0), + REAL_CONST(21782.466397645861/8.0), + REAL_CONST(21798.666056255934/8.0), + REAL_CONST(21814.868725115801/8.0), + REAL_CONST(21831.074403107345/8.0), + REAL_CONST(21847.283089113484/8.0), + REAL_CONST(21863.494782018177/8.0), + REAL_CONST(21879.709480706417/8.0), + REAL_CONST(21895.927184064229/8.0), + REAL_CONST(21912.147890978667/8.0), + REAL_CONST(21928.371600337818/8.0), + REAL_CONST(21944.598311030797/8.0), + REAL_CONST(21960.828021947746/8.0), + REAL_CONST(21977.060731979829/8.0), + REAL_CONST(21993.296440019243/8.0), + REAL_CONST(22009.535144959198/8.0), + REAL_CONST(22025.77684569393/8.0), + REAL_CONST(22042.021541118691/8.0), + REAL_CONST(22058.269230129757/8.0), + REAL_CONST(22074.519911624411/8.0), + REAL_CONST(22090.773584500959/8.0), + REAL_CONST(22107.030247658717/8.0), + REAL_CONST(22123.289899998013/8.0), + REAL_CONST(22139.552540420187/8.0), + REAL_CONST(22155.818167827587/8.0), + REAL_CONST(22172.086781123569/8.0), + REAL_CONST(22188.358379212495/8.0), + REAL_CONST(22204.632960999726/8.0), + REAL_CONST(22220.910525391639/8.0), + REAL_CONST(22237.191071295601/8.0), + REAL_CONST(22253.474597619981/8.0), + REAL_CONST(22269.761103274148/8.0), + REAL_CONST(22286.050587168469/8.0), + REAL_CONST(22302.343048214312/8.0), + REAL_CONST(22318.638485324027/8.0), + REAL_CONST(22334.936897410968/8.0), + REAL_CONST(22351.23828338947/8.0), + REAL_CONST(22367.542642174871/8.0), + REAL_CONST(22383.849972683485/8.0), + REAL_CONST(22400.160273832618/8.0), + REAL_CONST(22416.473544540564/8.0), + REAL_CONST(22432.789783726603/8.0), + REAL_CONST(22449.108990310986/8.0), + REAL_CONST(22465.431163214958/8.0), + REAL_CONST(22481.75630136074/8.0), + REAL_CONST(22498.084403671528/8.0), + REAL_CONST(22514.415469071497/8.0), + REAL_CONST(22530.749496485802/8.0), + REAL_CONST(22547.086484840562/8.0), + REAL_CONST(22563.426433062879/8.0), + REAL_CONST(22579.769340080824/8.0), + REAL_CONST(22596.115204823436/8.0), + REAL_CONST(22612.464026220721/8.0), + REAL_CONST(22628.815803203655/8.0), + REAL_CONST(22645.170534704179/8.0), + REAL_CONST(22661.5282196552/8.0), + REAL_CONST(22677.888856990587/8.0), + REAL_CONST(22694.252445645168/8.0), + REAL_CONST(22710.618984554734/8.0), + REAL_CONST(22726.988472656034/8.0), + REAL_CONST(22743.360908886778/8.0), + REAL_CONST(22759.736292185622/8.0), + REAL_CONST(22776.114621492186/8.0), + REAL_CONST(22792.495895747044/8.0), + REAL_CONST(22808.880113891719/8.0), + REAL_CONST(22825.267274868678/8.0), + REAL_CONST(22841.657377621348/8.0), + REAL_CONST(22858.050421094096/8.0), + REAL_CONST(22874.446404232243/8.0), + REAL_CONST(22890.845325982053/8.0), + REAL_CONST(22907.247185290722/8.0), + REAL_CONST(22923.651981106406/8.0), + REAL_CONST(22940.059712378195/8.0), + REAL_CONST(22956.470378056114/8.0), + REAL_CONST(22972.883977091129/8.0), + REAL_CONST(22989.300508435153/8.0), + REAL_CONST(23005.719971041017/8.0), + REAL_CONST(23022.142363862498/8.0), + REAL_CONST(23038.567685854305/8.0), + REAL_CONST(23054.995935972078/8.0), + REAL_CONST(23071.427113172387/8.0), + REAL_CONST(23087.86121641273/8.0), + REAL_CONST(23104.298244651531/8.0), + REAL_CONST(23120.738196848146/8.0), + REAL_CONST(23137.181071962848/8.0), + REAL_CONST(23153.626868956846/8.0), + REAL_CONST(23170.075586792263/8.0), + REAL_CONST(23186.527224432142/8.0), + REAL_CONST(23202.981780840448/8.0), + REAL_CONST(23219.439254982066/8.0), + REAL_CONST(23235.899645822796/8.0), + REAL_CONST(23252.362952329357/8.0), + REAL_CONST(23268.829173469378/8.0), + REAL_CONST(23285.298308211408/8.0), + REAL_CONST(23301.770355524899/8.0), + REAL_CONST(23318.245314380223/8.0), + REAL_CONST(23334.723183748658/8.0), + REAL_CONST(23351.203962602387/8.0), + REAL_CONST(23367.687649914504/8.0), + REAL_CONST(23384.174244659007/8.0), + REAL_CONST(23400.663745810798/8.0), + REAL_CONST(23417.15615234568/8.0), + REAL_CONST(23433.651463240367/8.0), + REAL_CONST(23450.149677472462/8.0), + REAL_CONST(23466.650794020472/8.0), + REAL_CONST(23483.154811863806/8.0), + REAL_CONST(23499.661729982763/8.0), + REAL_CONST(23516.171547358543/8.0), + REAL_CONST(23532.684262973235/8.0), + REAL_CONST(23549.199875809823/8.0), + REAL_CONST(23565.718384852185/8.0), + REAL_CONST(23582.239789085092/8.0), + REAL_CONST(23598.764087494197/8.0), + REAL_CONST(23615.291279066041/8.0), + REAL_CONST(23631.821362788058/8.0), + REAL_CONST(23648.354337648565/8.0), + REAL_CONST(23664.890202636761/8.0), + REAL_CONST(23681.428956742733/8.0), + REAL_CONST(23697.970598957443/8.0), + REAL_CONST(23714.515128272738/8.0), + REAL_CONST(23731.062543681343/8.0), + REAL_CONST(23747.612844176863/8.0), + REAL_CONST(23764.166028753778/8.0), + REAL_CONST(23780.72209640744/8.0), + REAL_CONST(23797.281046134085/8.0), + REAL_CONST(23813.842876930816/8.0), + REAL_CONST(23830.407587795606/8.0), + REAL_CONST(23846.975177727301/8.0), + REAL_CONST(23863.545645725622/8.0), + REAL_CONST(23880.11899079115/8.0), + REAL_CONST(23896.695211925336/8.0), + REAL_CONST(23913.274308130498/8.0), + REAL_CONST(23929.856278409821/8.0), + REAL_CONST(23946.441121767348/8.0), + REAL_CONST(23963.028837207989/8.0), + REAL_CONST(23979.619423737513/8.0), + REAL_CONST(23996.212880362549/8.0), + REAL_CONST(24012.809206090584/8.0), + REAL_CONST(24029.408399929966/8.0), + REAL_CONST(24046.010460889898/8.0), + REAL_CONST(24062.615387980433/8.0), + REAL_CONST(24079.223180212492/8.0), + REAL_CONST(24095.833836597827/8.0), + REAL_CONST(24112.447356149063/8.0), + REAL_CONST(24129.063737879667/8.0), + REAL_CONST(24145.682980803951/8.0), + REAL_CONST(24162.305083937081/8.0), + REAL_CONST(24178.930046295067/8.0), + REAL_CONST(24195.557866894767/8.0), + REAL_CONST(24212.188544753884/8.0), + REAL_CONST(24228.822078890964/8.0), + REAL_CONST(24245.458468325389/8.0), + REAL_CONST(24262.097712077397/8.0), + REAL_CONST(24278.739809168052/8.0), + REAL_CONST(24295.384758619261/8.0), + REAL_CONST(24312.032559453768/8.0), + REAL_CONST(24328.683210695162/8.0), + REAL_CONST(24345.336711367858/8.0), + REAL_CONST(24361.993060497109/8.0), + REAL_CONST(24378.652257108995/8.0), + REAL_CONST(24395.314300230442/8.0), + REAL_CONST(24411.979188889192/8.0), + REAL_CONST(24428.646922113825/8.0), + REAL_CONST(24445.317498933746/8.0), + REAL_CONST(24461.990918379193/8.0), + REAL_CONST(24478.667179481225/8.0), + REAL_CONST(24495.346281271726/8.0), + REAL_CONST(24512.028222783407/8.0), + REAL_CONST(24528.713003049801/8.0), + REAL_CONST(24545.400621105266/8.0), + REAL_CONST(24562.091075984976/8.0), + REAL_CONST(24578.784366724925/8.0), + REAL_CONST(24595.480492361927/8.0), + REAL_CONST(24612.179451933614/8.0), + REAL_CONST(24628.881244478438/8.0), + REAL_CONST(24645.585869035654/8.0), + REAL_CONST(24662.293324645343/8.0), + REAL_CONST(24679.003610348394/8.0), + REAL_CONST(24695.716725186514/8.0), + REAL_CONST(24712.432668202211/8.0), + REAL_CONST(24729.151438438807/8.0), + REAL_CONST(24745.873034940436/8.0), + REAL_CONST(24762.597456752032/8.0), + REAL_CONST(24779.324702919344/8.0), + REAL_CONST(24796.054772488926/8.0), + REAL_CONST(24812.787664508123/8.0), + REAL_CONST(24829.5233780251/8.0), + REAL_CONST(24846.261912088819/8.0), + REAL_CONST(24863.003265749034/8.0), + REAL_CONST(24879.747438056307/8.0), + REAL_CONST(24896.494428062004/8.0), + REAL_CONST(24913.244234818278/8.0), + REAL_CONST(24929.996857378079/8.0), + REAL_CONST(24946.752294795166/8.0), + REAL_CONST(24963.510546124078/8.0), + REAL_CONST(24980.271610420157/8.0), + REAL_CONST(24997.035486739525/8.0), + REAL_CONST(25013.802174139113/8.0), + REAL_CONST(25030.571671676629/8.0), + REAL_CONST(25047.343978410572/8.0), + REAL_CONST(25064.119093400237/8.0), + REAL_CONST(25080.897015705697/8.0), + REAL_CONST(25097.677744387816/8.0), + REAL_CONST(25114.461278508239/8.0), + REAL_CONST(25131.2476171294/8.0), + REAL_CONST(25148.036759314517/8.0), + REAL_CONST(25164.828704127583/8.0), + REAL_CONST(25181.623450633375/8.0), + REAL_CONST(25198.42099789745/8.0), + REAL_CONST(25215.221344986145/8.0), + REAL_CONST(25232.024490966574/8.0), + REAL_CONST(25248.830434906627/8.0), + REAL_CONST(25265.639175874974/8.0), + REAL_CONST(25282.450712941049/8.0), + REAL_CONST(25299.265045175071/8.0), + REAL_CONST(25316.082171648024/8.0), + REAL_CONST(25332.902091431668/8.0), + REAL_CONST(25349.724803598532/8.0), + REAL_CONST(25366.550307221914/8.0), + REAL_CONST(25383.378601375884/8.0), + REAL_CONST(25400.209685135269/8.0), + REAL_CONST(25417.043557575678/8.0), + REAL_CONST(25433.880217773472/8.0), + REAL_CONST(25450.719664805783/8.0), + REAL_CONST(25467.561897750507/8.0), + REAL_CONST(25484.406915686297/8.0), + REAL_CONST(25501.254717692573/8.0), + REAL_CONST(25518.105302849512/8.0), + REAL_CONST(25534.958670238051/8.0), + REAL_CONST(25551.814818939893/8.0), + REAL_CONST(25568.67374803748/8.0), + REAL_CONST(25585.535456614027/8.0), + REAL_CONST(25602.399943753502/8.0), + REAL_CONST(25619.267208540619/8.0), + REAL_CONST(25636.137250060852/8.0), + REAL_CONST(25653.010067400432/8.0), + REAL_CONST(25669.885659646327/8.0), + REAL_CONST(25686.76402588627/8.0), + REAL_CONST(25703.645165208734/8.0), + REAL_CONST(25720.529076702944/8.0), + REAL_CONST(25737.415759458876/8.0), + REAL_CONST(25754.305212567244/8.0), + REAL_CONST(25771.197435119517/8.0), + REAL_CONST(25788.092426207899/8.0), + REAL_CONST(25804.990184925344/8.0), + REAL_CONST(25821.890710365547/8.0), + REAL_CONST(25838.794001622944/8.0), + REAL_CONST(25855.700057792714/8.0), + REAL_CONST(25872.608877970775/8.0), + REAL_CONST(25889.520461253778/8.0), + REAL_CONST(25906.434806739118/8.0), + REAL_CONST(25923.351913524923/8.0), + REAL_CONST(25940.271780710063/8.0), + REAL_CONST(25957.194407394138/8.0), + REAL_CONST(25974.11979267748/8.0), + REAL_CONST(25991.047935661154/8.0), + REAL_CONST(26007.978835446964/8.0), + REAL_CONST(26024.912491137442/8.0), + REAL_CONST(26041.848901835841/8.0), + REAL_CONST(26058.788066646157/8.0), + REAL_CONST(26075.729984673108/8.0), + REAL_CONST(26092.674655022136/8.0), + REAL_CONST(26109.622076799409/8.0), + REAL_CONST(26126.572249111829/8.0), + REAL_CONST(26143.525171067016/8.0), + REAL_CONST(26160.480841773315/8.0), + REAL_CONST(26177.43926033979/8.0), + REAL_CONST(26194.400425876229/8.0), + REAL_CONST(26211.364337493149/8.0), + REAL_CONST(26228.330994301767/8.0), + REAL_CONST(26245.30039541404/8.0), + REAL_CONST(26262.272539942627/8.0), + REAL_CONST(26279.247427000919/8.0), + REAL_CONST(26296.225055703002/8.0), + REAL_CONST(26313.205425163702/8.0), + REAL_CONST(26330.188534498539/8.0), + REAL_CONST(26347.174382823756/8.0), + REAL_CONST(26364.162969256304/8.0), + REAL_CONST(26381.154292913852/8.0), + REAL_CONST(26398.148352914774/8.0), + REAL_CONST(26415.145148378149/8.0), + REAL_CONST(26432.144678423778/8.0), + REAL_CONST(26449.146942172156/8.0), + REAL_CONST(26466.151938744493/8.0), + REAL_CONST(26483.159667262702/8.0), + REAL_CONST(26500.170126849403/8.0), + REAL_CONST(26517.183316627921/8.0), + REAL_CONST(26534.199235722277/8.0), + REAL_CONST(26551.217883257199/8.0), + REAL_CONST(26568.239258358124/8.0), + REAL_CONST(26585.263360151173/8.0), + REAL_CONST(26602.290187763181/8.0), + REAL_CONST(26619.319740321676/8.0), + REAL_CONST(26636.352016954883/8.0), + REAL_CONST(26653.387016791727/8.0), + REAL_CONST(26670.424738961825/8.0), + REAL_CONST(26687.465182595493/8.0), + REAL_CONST(26704.508346823739/8.0), + REAL_CONST(26721.554230778267/8.0), + REAL_CONST(26738.602833591467/8.0), + REAL_CONST(26755.65415439643/8.0), + REAL_CONST(26772.708192326929/8.0), + REAL_CONST(26789.764946517433/8.0), + REAL_CONST(26806.824416103096/8.0), + REAL_CONST(26823.886600219761/8.0), + REAL_CONST(26840.95149800396/8.0), + REAL_CONST(26858.019108592915/8.0), + REAL_CONST(26875.089431124517/8.0), + REAL_CONST(26892.162464737365/8.0), + REAL_CONST(26909.238208570721/8.0), + REAL_CONST(26926.316661764544/8.0), + REAL_CONST(26943.397823459472/8.0), + REAL_CONST(26960.481692796813/8.0), + REAL_CONST(26977.568268918571/8.0), + REAL_CONST(26994.657550967422/8.0), + REAL_CONST(27011.749538086722/8.0), + REAL_CONST(27028.844229420498/8.0), + REAL_CONST(27045.941624113464/8.0), + REAL_CONST(27063.041721311005/8.0), + REAL_CONST(27080.144520159181/8.0), + REAL_CONST(27097.250019804727/8.0), + REAL_CONST(27114.35821939505/8.0), + REAL_CONST(27131.469118078236/8.0), + REAL_CONST(27148.582715003027/8.0), + REAL_CONST(27165.699009318858/8.0), + REAL_CONST(27182.818000175819/8.0), + REAL_CONST(27199.939686724665/8.0), + REAL_CONST(27217.064068116837/8.0), + REAL_CONST(27234.191143504428/8.0), + REAL_CONST(27251.320912040203/8.0), + REAL_CONST(27268.453372877593/8.0), + REAL_CONST(27285.588525170693/8.0), + REAL_CONST(27302.726368074269/8.0), + REAL_CONST(27319.866900743735/8.0), + REAL_CONST(27337.010122335181/8.0), + REAL_CONST(27354.156032005358/8.0), + REAL_CONST(27371.304628911668/8.0), + REAL_CONST(27388.455912212183/8.0), + REAL_CONST(27405.609881065626/8.0), + REAL_CONST(27422.766534631384/8.0), + REAL_CONST(27439.925872069507/8.0), + REAL_CONST(27457.087892540683/8.0), + REAL_CONST(27474.252595206275/8.0), + REAL_CONST(27491.419979228293/8.0), + REAL_CONST(27508.5900437694/8.0), + REAL_CONST(27525.762787992917/8.0), + REAL_CONST(27542.93821106281/8.0), + REAL_CONST(27560.116312143706/8.0), + REAL_CONST(27577.297090400876/8.0), + REAL_CONST(27594.480545000242/8.0), + REAL_CONST(27611.666675108383/8.0), + REAL_CONST(27628.855479892518/8.0), + REAL_CONST(27646.046958520514/8.0), + REAL_CONST(27663.241110160889/8.0), + REAL_CONST(27680.437933982801/8.0), + REAL_CONST(27697.637429156068/8.0), + REAL_CONST(27714.839594851132/8.0), + REAL_CONST(27732.04443023909/8.0), + REAL_CONST(27749.251934491687/8.0), + REAL_CONST(27766.462106781299/8.0), + REAL_CONST(27783.674946280949/8.0), + REAL_CONST(27800.890452164302/8.0), + REAL_CONST(27818.108623605654/8.0), + REAL_CONST(27835.329459779954/8.0), + REAL_CONST(27852.55295986278/8.0), + REAL_CONST(27869.779123030345/8.0), + REAL_CONST(27887.007948459504/8.0), + REAL_CONST(27904.239435327745/8.0), + REAL_CONST(27921.473582813196/8.0), + REAL_CONST(27938.710390094613/8.0), + REAL_CONST(27955.949856351392/8.0), + REAL_CONST(27973.19198076355/8.0), + REAL_CONST(27990.436762511745/8.0), + REAL_CONST(28007.684200777272/8.0), + REAL_CONST(28024.934294742041/8.0), + REAL_CONST(28042.187043588601/8.0), + REAL_CONST(28059.442446500128/8.0), + REAL_CONST(28076.700502660427/8.0), + REAL_CONST(28093.961211253929/8.0), + REAL_CONST(28111.224571465693/8.0), + REAL_CONST(28128.490582481401/8.0), + REAL_CONST(28145.759243487362/8.0), + REAL_CONST(28163.030553670509/8.0), + REAL_CONST(28180.304512218394/8.0), + REAL_CONST(28197.581118319198/8.0), + REAL_CONST(28214.860371161725/8.0), + REAL_CONST(28232.14226993539/8.0), + REAL_CONST(28249.42681383024/8.0), + REAL_CONST(28266.71400203693/8.0), + REAL_CONST(28284.003833746745/8.0), + REAL_CONST(28301.296308151585/8.0), + REAL_CONST(28318.591424443959/8.0), + REAL_CONST(28335.889181817001/8.0), + REAL_CONST(28353.189579464462/8.0), + REAL_CONST(28370.492616580705/8.0), + REAL_CONST(28387.798292360701/8.0), + REAL_CONST(28405.106606000048/8.0), + REAL_CONST(28422.417556694945/8.0), + REAL_CONST(28439.731143642206/8.0), + REAL_CONST(28457.047366039264/8.0), + REAL_CONST(28474.366223084147/8.0), + REAL_CONST(28491.687713975512/8.0), + REAL_CONST(28509.011837912611/8.0), + REAL_CONST(28526.338594095305/8.0), + REAL_CONST(28543.667981724069/8.0), + REAL_CONST(28560.999999999982/8.0), + REAL_CONST(28578.334648124732/8.0), + REAL_CONST(28595.671925300605/8.0), + REAL_CONST(28613.011830730498/8.0), + REAL_CONST(28630.354363617909/8.0), + REAL_CONST(28647.699523166943/8.0), + REAL_CONST(28665.0473085823/8.0), + REAL_CONST(28682.397719069289/8.0), + REAL_CONST(28699.750753833818/8.0), + REAL_CONST(28717.10641208239/8.0), + REAL_CONST(28734.464693022121/8.0), + REAL_CONST(28751.825595860708/8.0), + REAL_CONST(28769.189119806462/8.0), + REAL_CONST(28786.55526406828/8.0), + REAL_CONST(28803.924027855664/8.0), + REAL_CONST(28821.295410378701/8.0), + REAL_CONST(28838.669410848088/8.0), + REAL_CONST(28856.046028475103/8.0), + REAL_CONST(28873.425262471628/8.0), + REAL_CONST(28890.80711205013/8.0), + REAL_CONST(28908.191576423673/8.0), + REAL_CONST(28925.578654805915/8.0), + REAL_CONST(28942.968346411097/8.0), + REAL_CONST(28960.360650454055/8.0), + REAL_CONST(28977.755566150216/8.0), + REAL_CONST(28995.153092715591/8.0), + REAL_CONST(29012.553229366786/8.0), + REAL_CONST(29029.955975320987/8.0), + REAL_CONST(29047.361329795975/8.0), + REAL_CONST(29064.769292010107/8.0), + REAL_CONST(29082.179861182336/8.0), + REAL_CONST(29099.593036532187/8.0), + REAL_CONST(29117.00881727978/8.0), + REAL_CONST(29134.427202645813/8.0), + REAL_CONST(29151.848191851568/8.0), + REAL_CONST(29169.271784118911/8.0), + REAL_CONST(29186.697978670283/8.0), + REAL_CONST(29204.126774728706/8.0), + REAL_CONST(29221.55817151779/8.0), + REAL_CONST(29238.992168261717/8.0), + REAL_CONST(29256.42876418525/8.0), + REAL_CONST(29273.867958513725/8.0), + REAL_CONST(29291.309750473058/8.0), + REAL_CONST(29308.754139289747/8.0), + REAL_CONST(29326.201124190855/8.0), + REAL_CONST(29343.65070440403/8.0), + REAL_CONST(29361.102879157483/8.0), + REAL_CONST(29378.557647680012/8.0), + REAL_CONST(29396.015009200975/8.0), + REAL_CONST(29413.474962950309/8.0), + REAL_CONST(29430.937508158524/8.0), + REAL_CONST(29448.402644056692/8.0), + REAL_CONST(29465.870369876469/8.0), + REAL_CONST(29483.340684850071/8.0), + REAL_CONST(29500.81358821028/8.0), + REAL_CONST(29518.289079190454/8.0), + REAL_CONST(29535.767157024511/8.0), + REAL_CONST(29553.247820946945/8.0), + REAL_CONST(29570.731070192807/8.0), + REAL_CONST(29588.216903997723/8.0), + REAL_CONST(29605.70532159787/8.0), + REAL_CONST(29623.19632223/8.0), + REAL_CONST(29640.689905131429/8.0), + REAL_CONST(29658.186069540028/8.0), + REAL_CONST(29675.684814694236/8.0), + REAL_CONST(29693.186139833047/8.0), + REAL_CONST(29710.690044196028/8.0), + REAL_CONST(29728.196527023298/8.0), + REAL_CONST(29745.705587555527/8.0), + REAL_CONST(29763.217225033964/8.0), + REAL_CONST(29780.731438700397/8.0), + REAL_CONST(29798.248227797183/8.0), + REAL_CONST(29815.76759156723/8.0), + REAL_CONST(29833.289529254005/8.0), + REAL_CONST(29850.81404010153/8.0), + REAL_CONST(29868.341123354381/8.0), + REAL_CONST(29885.870778257693/8.0), + REAL_CONST(29903.403004057145/8.0), + REAL_CONST(29920.937799998974/8.0), + REAL_CONST(29938.475165329975/8.0), + REAL_CONST(29956.015099297485/8.0), + REAL_CONST(29973.557601149394/8.0), + REAL_CONST(29991.102670134147/8.0), + REAL_CONST(30008.650305500738/8.0), + REAL_CONST(30026.200506498706/8.0), + REAL_CONST(30043.753272378144/8.0), + REAL_CONST(30061.308602389683/8.0), + REAL_CONST(30078.866495784507/8.0), + REAL_CONST(30096.426951814352/8.0), + REAL_CONST(30113.989969731494/8.0), + REAL_CONST(30131.55554878875/8.0), + REAL_CONST(30149.123688239491/8.0), + REAL_CONST(30166.694387337629/8.0), + REAL_CONST(30184.267645337608/8.0), + REAL_CONST(30201.843461494434/8.0), + REAL_CONST(30219.42183506364/8.0), + REAL_CONST(30237.002765301309/8.0), + REAL_CONST(30254.586251464058/8.0), + REAL_CONST(30272.172292809046/8.0), + REAL_CONST(30289.760888593977/8.0), + REAL_CONST(30307.35203807709/8.0), + REAL_CONST(30324.94574051716/8.0), + REAL_CONST(30342.541995173502/8.0), + REAL_CONST(30360.140801305966/8.0), + REAL_CONST(30377.742158174944/8.0), + REAL_CONST(30395.346065041358/8.0), + REAL_CONST(30412.952521166666/8.0), + REAL_CONST(30430.561525812864/8.0), + REAL_CONST(30448.173078242475/8.0), + REAL_CONST(30465.787177718561/8.0), + REAL_CONST(30483.403823504719/8.0), + REAL_CONST(30501.02301486507/8.0), + REAL_CONST(30518.644751064272/8.0), + REAL_CONST(30536.269031367516/8.0), + REAL_CONST(30553.895855040515/8.0), + REAL_CONST(30571.525221349519/8.0), + REAL_CONST(30589.157129561307/8.0), + REAL_CONST(30606.791578943175/8.0), + REAL_CONST(30624.428568762964/8.0), + REAL_CONST(30642.06809828903/8.0), + REAL_CONST(30659.710166790261/8.0), + REAL_CONST(30677.35477353607/8.0), + REAL_CONST(30695.001917796391/8.0), + REAL_CONST(30712.651598841687/8.0), + REAL_CONST(30730.303815942945/8.0), + REAL_CONST(30747.958568371676/8.0), + REAL_CONST(30765.615855399912/8.0), + REAL_CONST(30783.275676300211/8.0), + REAL_CONST(30800.938030345646/8.0), + REAL_CONST(30818.602916809814/8.0), + REAL_CONST(30836.270334966837/8.0), + REAL_CONST(30853.940284091354/8.0), + REAL_CONST(30871.612763458521/8.0), + REAL_CONST(30889.287772344011/8.0), + REAL_CONST(30906.965310024025/8.0), + REAL_CONST(30924.645375775272/8.0), + REAL_CONST(30942.327968874983/8.0), + REAL_CONST(30960.013088600903/8.0), + REAL_CONST(30977.700734231294/8.0), + REAL_CONST(30995.390905044929/8.0), + REAL_CONST(31013.083600321101/8.0), + REAL_CONST(31030.778819339619/8.0), + REAL_CONST(31048.476561380798/8.0), + REAL_CONST(31066.17682572547/8.0), + REAL_CONST(31083.879611654978/8.0), + REAL_CONST(31101.584918451179/8.0), + REAL_CONST(31119.29274539644/8.0), + REAL_CONST(31137.003091773637/8.0), + REAL_CONST(31154.715956866155/8.0), + REAL_CONST(31172.431339957893/8.0), + REAL_CONST(31190.14924033326/8.0), + REAL_CONST(31207.869657277162/8.0), + REAL_CONST(31225.592590075023/8.0), + REAL_CONST(31243.318038012771/8.0), + REAL_CONST(31261.046000376838/8.0), + REAL_CONST(31278.776476454172/8.0), + REAL_CONST(31296.50946553221/8.0), + REAL_CONST(31314.24496689891/8.0), + REAL_CONST(31331.98297984272/8.0), + REAL_CONST(31349.7235036526/8.0), + REAL_CONST(31367.466537618013/8.0), + REAL_CONST(31385.212081028923/8.0), + REAL_CONST(31402.960133175795/8.0), + REAL_CONST(31420.710693349596/8.0), + REAL_CONST(31438.463760841791/8.0), + REAL_CONST(31456.219334944351/8.0), + REAL_CONST(31473.977414949743/8.0), + REAL_CONST(31491.738000150934/8.0), + REAL_CONST(31509.501089841389/8.0), + REAL_CONST(31527.266683315069/8.0), + REAL_CONST(31545.034779866437/8.0), + REAL_CONST(31562.80537879045/8.0), + REAL_CONST(31580.578479382562/8.0), + REAL_CONST(31598.35408093872/8.0), + REAL_CONST(31616.132182755369/8.0), + REAL_CONST(31633.91278412945/8.0), + REAL_CONST(31651.695884358396/8.0), + REAL_CONST(31669.481482740131/8.0), + REAL_CONST(31687.269578573076/8.0), + REAL_CONST(31705.060171156143/8.0), + REAL_CONST(31722.853259788735/8.0), + REAL_CONST(31740.648843770748/8.0), + REAL_CONST(31758.446922402567/8.0), + REAL_CONST(31776.247494985066/8.0), + REAL_CONST(31794.050560819614/8.0), + REAL_CONST(31811.85611920806/8.0), + REAL_CONST(31829.664169452753/8.0), + REAL_CONST(31847.474710856521/8.0), + REAL_CONST(31865.287742722685/8.0), + REAL_CONST(31883.103264355046/8.0), + REAL_CONST(31900.921275057899/8.0), + REAL_CONST(31918.741774136019/8.0), + REAL_CONST(31936.564760894671/8.0), + REAL_CONST(31954.390234639599/8.0), + REAL_CONST(31972.21819467704/8.0), + REAL_CONST(31990.048640313704/8.0), + REAL_CONST(32007.881570856793/8.0), + REAL_CONST(32025.716985613984/8.0), + REAL_CONST(32043.554883893445/8.0), + REAL_CONST(32061.395265003815/8.0), + REAL_CONST(32079.238128254223/8.0), + REAL_CONST(32097.083472954269/8.0), + REAL_CONST(32114.931298414049/8.0), + REAL_CONST(32132.781603944117/8.0), + REAL_CONST(32150.634388855524/8.0), + REAL_CONST(32168.48965245979/8.0), + REAL_CONST(32186.347394068915/8.0), + REAL_CONST(32204.207612995371/8.0), + REAL_CONST(32222.07030855212/8.0), + REAL_CONST(32239.935480052583/8.0), + REAL_CONST(32257.803126810672/8.0), + REAL_CONST(32275.673248140767/8.0), + REAL_CONST(32293.545843357719/8.0), + REAL_CONST(32311.420911776862/8.0), + REAL_CONST(32329.298452713996/8.0), + REAL_CONST(32347.178465485395/8.0), + REAL_CONST(32365.060949407813/8.0), + REAL_CONST(32382.945903798463/8.0), + REAL_CONST(32400.83332797504/8.0), + REAL_CONST(32418.723221255706/8.0), + REAL_CONST(32436.615582959093/8.0), + REAL_CONST(32454.510412404306/8.0), + REAL_CONST(32472.407708910916/8.0), + REAL_CONST(32490.307471798966/8.0), + REAL_CONST(32508.209700388961/8.0), + REAL_CONST(32526.114394001877/8.0), + REAL_CONST(32544.021551959166/8.0), + REAL_CONST(32561.931173582732/8.0), + REAL_CONST(32579.843258194956/8.0), + REAL_CONST(32597.757805118679/8.0), + REAL_CONST(32615.674813677211/8.0), + REAL_CONST(32633.594283194328/8.0), + REAL_CONST(32651.516212994258/8.0), + REAL_CONST(32669.440602401712/8.0), + REAL_CONST(32687.367450741847/8.0), + REAL_CONST(32705.296757340297/8.0), + REAL_CONST(32723.228521523146/8.0), + REAL_CONST(32741.162742616943/8.0), + REAL_CONST(32759.099419948703/8.0), + REAL_CONST(32777.038552845901/8.0), + REAL_CONST(32794.980140636464/8.0), + REAL_CONST(32812.924182648792/8.0), + REAL_CONST(32830.87067821173/8.0), + REAL_CONST(32848.819626654593/8.0), + REAL_CONST(32866.77102730715/8.0), + REAL_CONST(32884.724879499619/8.0), + REAL_CONST(32902.681182562686/8.0), + REAL_CONST(32920.639935827494/8.0), + REAL_CONST(32938.601138625643/8.0), + REAL_CONST(32956.56479028918/8.0), + REAL_CONST(32974.530890150607/8.0), + REAL_CONST(32992.499437542894/8.0), + REAL_CONST(33010.470431799447/8.0), + REAL_CONST(33028.443872254145/8.0), + REAL_CONST(33046.419758241311/8.0), + REAL_CONST(33064.39808909571/8.0), + REAL_CONST(33082.378864152583/8.0), + REAL_CONST(33100.36208274759/8.0), + REAL_CONST(33118.347744216881/8.0), + REAL_CONST(33136.335847897026/8.0), + REAL_CONST(33154.326393125062/8.0), + REAL_CONST(33172.31937923847/8.0), + REAL_CONST(33190.314805575174/8.0), + REAL_CONST(33208.312671473555/8.0), + REAL_CONST(33226.312976272442/8.0), + REAL_CONST(33244.315719311111/8.0), + REAL_CONST(33262.320899929284/8.0), + REAL_CONST(33280.328517467125/8.0), + REAL_CONST(33298.33857126526/8.0), + REAL_CONST(33316.351060664747/8.0), + REAL_CONST(33334.365985007091/8.0), + REAL_CONST(33352.383343634239/8.0), + REAL_CONST(33370.403135888591/8.0), + REAL_CONST(33388.42536111299/8.0), + REAL_CONST(33406.450018650721/8.0), + REAL_CONST(33424.477107845501/8.0), + REAL_CONST(33442.506628041512/8.0), + REAL_CONST(33460.53857858335/8.0), + REAL_CONST(33478.572958816083/8.0), + REAL_CONST(33496.609768085189/8.0), + REAL_CONST(33514.649005736617/8.0), + REAL_CONST(33532.690671116739/8.0), + REAL_CONST(33550.734763572356/8.0), + REAL_CONST(33568.781282450735/8.0), + REAL_CONST(33586.830227099563/8.0), + REAL_CONST(33604.881596866973/8.0), + REAL_CONST(33622.935391101528/8.0), + REAL_CONST(33640.991609152239/8.0), + REAL_CONST(33659.050250368542/8.0), + REAL_CONST(33677.111314100322/8.0), + REAL_CONST(33695.174799697881/8.0), + REAL_CONST(33713.240706511984/8.0), + REAL_CONST(33731.309033893805/8.0), + REAL_CONST(33749.37978119497/8.0), + REAL_CONST(33767.452947767531/8.0), + REAL_CONST(33785.528532963974/8.0), + REAL_CONST(33803.606536137209/8.0), + REAL_CONST(33821.686956640602/8.0), + REAL_CONST(33839.769793827938/8.0), + REAL_CONST(33857.855047053425/8.0), + REAL_CONST(33875.942715671707/8.0), + REAL_CONST(33894.032799037872/8.0), + REAL_CONST(33912.125296507431/8.0), + REAL_CONST(33930.220207436316/8.0), + REAL_CONST(33948.317531180888/8.0), + REAL_CONST(33966.417267097961/8.0), + REAL_CONST(33984.519414544746/8.0), + REAL_CONST(34002.623972878901/8.0), + REAL_CONST(34020.730941458511/8.0), + REAL_CONST(34038.840319642077/8.0), + REAL_CONST(34056.952106788536/8.0), + REAL_CONST(34075.066302257255/8.0), + REAL_CONST(34093.182905408015/8.0), + REAL_CONST(34111.301915601027/8.0), + REAL_CONST(34129.42333219693/8.0), + REAL_CONST(34147.547154556785/8.0), + REAL_CONST(34165.673382042078/8.0), + REAL_CONST(34183.80201401472/8.0), + REAL_CONST(34201.933049837033/8.0), + REAL_CONST(34220.06648887178/8.0), + REAL_CONST(34238.202330482141/8.0), + REAL_CONST(34256.340574031703/8.0), + REAL_CONST(34274.481218884495/8.0), + REAL_CONST(34292.624264404949/8.0), + REAL_CONST(34310.769709957938/8.0), + REAL_CONST(34328.91755490873/8.0), + REAL_CONST(34347.067798623029/8.0), + REAL_CONST(34365.220440466954/8.0), + REAL_CONST(34383.375479807051/8.0), + REAL_CONST(34401.532916010263/8.0), + REAL_CONST(34419.692748443973/8.0), + REAL_CONST(34437.854976475966/8.0), + REAL_CONST(34456.01959947445/8.0), + REAL_CONST(34474.18661680806/8.0), + REAL_CONST(34492.356027845817/8.0), + REAL_CONST(34510.527831957188/8.0), + REAL_CONST(34528.702028512052/8.0), + REAL_CONST(34546.878616880676/8.0), + REAL_CONST(34565.05759643377/8.0), + REAL_CONST(34583.238966542449/8.0), + REAL_CONST(34601.422726578232/8.0), + REAL_CONST(34619.608875913065/8.0), + REAL_CONST(34637.797413919296/8.0), + REAL_CONST(34655.988339969692/8.0), + REAL_CONST(34674.181653437423/8.0), + REAL_CONST(34692.37735369608/8.0), + REAL_CONST(34710.575440119668/8.0), + REAL_CONST(34728.775912082579/8.0), + REAL_CONST(34746.978768959649/8.0), + REAL_CONST(34765.184010126082/8.0), + REAL_CONST(34783.391634957537/8.0), + REAL_CONST(34801.60164283005/8.0), + REAL_CONST(34819.814033120063/8.0), + REAL_CONST(34838.028805204456/8.0), + REAL_CONST(34856.24595846048/8.0), + REAL_CONST(34874.465492265823/8.0), + REAL_CONST(34892.687405998557/8.0), + REAL_CONST(34910.911699037177/8.0), + REAL_CONST(34929.138370760564/8.0), + REAL_CONST(34947.367420548027/8.0), + REAL_CONST(34965.598847779271/8.0), + REAL_CONST(34983.832651834389/8.0), + REAL_CONST(35002.068832093908/8.0), + REAL_CONST(35020.307387938738/8.0), + REAL_CONST(35038.548318750189/8.0), + REAL_CONST(35056.79162390998/8.0), + REAL_CONST(35075.03730280025/8.0), + REAL_CONST(35093.285354803513/8.0), + REAL_CONST(35111.535779302685/8.0), + REAL_CONST(35129.788575681116/8.0), + REAL_CONST(35148.043743322516/8.0), + REAL_CONST(35166.301281611013/8.0), + REAL_CONST(35184.561189931141/8.0), + REAL_CONST(35202.823467667826/8.0), + REAL_CONST(35221.088114206388/8.0), + REAL_CONST(35239.355128932555/8.0), + REAL_CONST(35257.624511232447/8.0), + REAL_CONST(35275.896260492584/8.0), + REAL_CONST(35294.170376099886/8.0), + REAL_CONST(35312.446857441668/8.0), + REAL_CONST(35330.725703905628/8.0), + REAL_CONST(35349.006914879887/8.0), + REAL_CONST(35367.290489752944/8.0), + REAL_CONST(35385.576427913686/8.0), + REAL_CONST(35403.864728751418/8.0), + REAL_CONST(35422.155391655811/8.0), + REAL_CONST(35440.448416016967/8.0), + REAL_CONST(35458.743801225341/8.0), + REAL_CONST(35477.041546671804/8.0), + REAL_CONST(35495.341651747622/8.0), + REAL_CONST(35513.644115844436/8.0), + REAL_CONST(35531.948938354304/8.0), + REAL_CONST(35550.256118669655/8.0), + REAL_CONST(35568.565656183309/8.0), + REAL_CONST(35586.877550288496/8.0), + REAL_CONST(35605.191800378816/8.0), + REAL_CONST(35623.508405848268/8.0), + REAL_CONST(35641.827366091238/8.0), + REAL_CONST(35660.148680502505/8.0), + REAL_CONST(35678.472348477233/8.0), + REAL_CONST(35696.798369410979/8.0), + REAL_CONST(35715.126742699678/8.0), + REAL_CONST(35733.457467739659/8.0), + REAL_CONST(35751.790543927644/8.0), + REAL_CONST(35770.125970660738/8.0), + REAL_CONST(35788.46374733642/8.0), + REAL_CONST(35806.803873352568/8.0), + REAL_CONST(35825.146348107453/8.0), + REAL_CONST(35843.49117099971/8.0), + REAL_CONST(35861.838341428367/8.0), + REAL_CONST(35880.187858792851/8.0), + REAL_CONST(35898.539722492955/8.0), + REAL_CONST(35916.893931928862/8.0), + REAL_CONST(35935.250486501129/8.0), + REAL_CONST(35953.609385610718/8.0), + REAL_CONST(35971.970628658957/8.0), + REAL_CONST(35990.334215047558/8.0), + REAL_CONST(36008.700144178612/8.0), + REAL_CONST(36027.068415454596/8.0), + REAL_CONST(36045.439028278372/8.0), + REAL_CONST(36063.811982053165/8.0), + REAL_CONST(36082.187276182609/8.0), + REAL_CONST(36100.564910070694/8.0), + REAL_CONST(36118.944883121789/8.0), + REAL_CONST(36137.327194740654/8.0), + REAL_CONST(36155.711844332429/8.0), + REAL_CONST(36174.098831302617/8.0), + REAL_CONST(36192.488155057115/8.0), + REAL_CONST(36210.87981500219/8.0), + REAL_CONST(36229.273810544473/8.0), + REAL_CONST(36247.670141091003/8.0), + REAL_CONST(36266.068806049167/8.0), + REAL_CONST(36284.469804826738/8.0), + REAL_CONST(36302.873136831862/8.0), + REAL_CONST(36321.278801473069/8.0), + REAL_CONST(36339.686798159251/8.0), + REAL_CONST(36358.097126299683/8.0), + REAL_CONST(36376.509785304013/8.0), + REAL_CONST(36394.924774582258/8.0), + REAL_CONST(36413.342093544816/8.0), + REAL_CONST(36431.761741602444/8.0), + REAL_CONST(36450.183718166292/8.0), + REAL_CONST(36468.608022647859/8.0), + REAL_CONST(36487.034654459028/8.0), + REAL_CONST(36505.463613012063/8.0), + REAL_CONST(36523.894897719583/8.0), + REAL_CONST(36542.328507994578/8.0), + REAL_CONST(36560.764443250409/8.0), + REAL_CONST(36579.202702900831/8.0), + REAL_CONST(36597.643286359926/8.0), + REAL_CONST(36616.086193042182/8.0), + REAL_CONST(36634.531422362437/8.0), + REAL_CONST(36652.978973735895/8.0), + REAL_CONST(36671.428846578143/8.0), + REAL_CONST(36689.881040305125/8.0), + REAL_CONST(36708.335554333149/8.0), + REAL_CONST(36726.792388078902/8.0), + REAL_CONST(36745.251540959427/8.0), + REAL_CONST(36763.713012392138/8.0), + REAL_CONST(36782.176801794812/8.0), + REAL_CONST(36800.642908585593/8.0), + REAL_CONST(36819.111332182983/8.0), + REAL_CONST(36837.582072005869/8.0), + REAL_CONST(36856.055127473483/8.0), + REAL_CONST(36874.530498005421/8.0), + REAL_CONST(36893.008183021651/8.0), + REAL_CONST(36911.488181942506/8.0), + REAL_CONST(36929.970494188674/8.0), + REAL_CONST(36948.455119181206/8.0), + REAL_CONST(36966.942056341519/8.0), + REAL_CONST(36985.431305091392/8.0), + REAL_CONST(37003.922864852961/8.0), + REAL_CONST(37022.416735048733/8.0), + REAL_CONST(37040.912915101559/8.0), + REAL_CONST(37059.411404434657/8.0), + REAL_CONST(37077.91220247162/8.0), + REAL_CONST(37096.415308636388/8.0), + REAL_CONST(37114.920722353243/8.0), + REAL_CONST(37133.428443046862/8.0), + REAL_CONST(37151.938470142253/8.0), + REAL_CONST(37170.450803064785/8.0), + REAL_CONST(37188.965441240209/8.0), + REAL_CONST(37207.482384094597/8.0), + REAL_CONST(37226.001631054402/8.0), + REAL_CONST(37244.523181546429/8.0), + REAL_CONST(37263.047034997842/8.0), + REAL_CONST(37281.573190836149/8.0), + REAL_CONST(37300.101648489224/8.0), + REAL_CONST(37318.632407385296/8.0), + REAL_CONST(37337.165466952945/8.0), + REAL_CONST(37355.700826621112/8.0), + REAL_CONST(37374.238485819085/8.0), + REAL_CONST(37392.778443976509/8.0), + REAL_CONST(37411.320700523385/8.0), + REAL_CONST(37429.865254890057/8.0), + REAL_CONST(37448.412106507232/8.0), + REAL_CONST(37466.961254805974/8.0), + REAL_CONST(37485.512699217681/8.0), + REAL_CONST(37504.066439174116/8.0), + REAL_CONST(37522.622474107404/8.0), + REAL_CONST(37541.180803449992/8.0), + REAL_CONST(37559.741426634704/8.0), + REAL_CONST(37578.304343094693/8.0), + REAL_CONST(37596.869552263488/8.0), + REAL_CONST(37615.43705357494/8.0), + REAL_CONST(37634.006846463279/8.0), + REAL_CONST(37652.578930363044/8.0), + REAL_CONST(37671.153304709165/8.0), + REAL_CONST(37689.729968936896/8.0), + REAL_CONST(37708.308922481847/8.0), + REAL_CONST(37726.890164779965/8.0), + REAL_CONST(37745.473695267559/8.0), + REAL_CONST(37764.059513381275/8.0), + REAL_CONST(37782.647618558112/8.0), + REAL_CONST(37801.238010235415/8.0), + REAL_CONST(37819.830687850859/8.0), + REAL_CONST(37838.425650842495/8.0), + REAL_CONST(37857.022898648691/8.0), + REAL_CONST(37875.622430708172/8.0), + REAL_CONST(37894.224246460013/8.0), + REAL_CONST(37912.828345343616/8.0), + REAL_CONST(37931.434726798747/8.0), + REAL_CONST(37950.043390265506/8.0), + REAL_CONST(37968.654335184328/8.0), + REAL_CONST(37987.267560995999/8.0), + REAL_CONST(38005.883067141665/8.0), + REAL_CONST(38024.500853062775/8.0), + REAL_CONST(38043.120918201159/8.0), + REAL_CONST(38061.743261998963/8.0), + REAL_CONST(38080.367883898682/8.0), + REAL_CONST(38098.994783343158/8.0), + REAL_CONST(38117.623959775563/8.0), + REAL_CONST(38136.255412639417/8.0), + REAL_CONST(38154.889141378575/8.0), + REAL_CONST(38173.525145437234/8.0), + REAL_CONST(38192.163424259939/8.0), + REAL_CONST(38210.803977291551/8.0), + REAL_CONST(38229.446803977284/8.0), + REAL_CONST(38248.091903762703/8.0), + REAL_CONST(38266.739276093685/8.0), + REAL_CONST(38285.388920416466/8.0), + REAL_CONST(38304.040836177606/8.0), + REAL_CONST(38322.695022824002/8.0), + REAL_CONST(38341.351479802899/8.0), + REAL_CONST(38360.010206561863/8.0), + REAL_CONST(38378.671202548816/8.0), + REAL_CONST(38397.334467211993/8.0), + REAL_CONST(38415.999999999978/8.0), + REAL_CONST(38434.667800361683/8.0), + REAL_CONST(38453.33786774637/8.0), + REAL_CONST(38472.010201603611/8.0), + REAL_CONST(38490.684801383337/8.0), + REAL_CONST(38509.361666535784/8.0), + REAL_CONST(38528.040796511552/8.0), + REAL_CONST(38546.722190761553/8.0), + REAL_CONST(38565.405848737035/8.0), + REAL_CONST(38584.091769889594/8.0), + REAL_CONST(38602.779953671132/8.0), + REAL_CONST(38621.470399533908/8.0), + REAL_CONST(38640.163106930493/8.0), + REAL_CONST(38658.858075313794/8.0), + REAL_CONST(38677.555304137059/8.0), + REAL_CONST(38696.254792853862/8.0), + REAL_CONST(38714.956540918094/8.0), + REAL_CONST(38733.660547783991/8.0), + REAL_CONST(38752.366812906112/8.0), + REAL_CONST(38771.075335739348/8.0), + REAL_CONST(38789.78611573892/8.0), + REAL_CONST(38808.499152360368/8.0), + REAL_CONST(38827.214445059573/8.0), + REAL_CONST(38845.931993292739/8.0), + REAL_CONST(38864.651796516388/8.0), + REAL_CONST(38883.373854187383/8.0), + REAL_CONST(38902.098165762916/8.0), + REAL_CONST(38920.824730700486/8.0), + REAL_CONST(38939.553548457938/8.0), + REAL_CONST(38958.284618493431/8.0), + REAL_CONST(38977.017940265461/8.0), + REAL_CONST(38995.753513232834/8.0), + REAL_CONST(39014.491336854699/8.0), + REAL_CONST(39033.231410590517/8.0), + REAL_CONST(39051.973733900079/8.0), + REAL_CONST(39070.718306243485/8.0), + REAL_CONST(39089.465127081188/8.0), + REAL_CONST(39108.214195873945/8.0), + REAL_CONST(39126.965512082832/8.0), + REAL_CONST(39145.719075169261/8.0), + REAL_CONST(39164.474884594965/8.0), + REAL_CONST(39183.232939821988/8.0), + REAL_CONST(39201.99324031271/8.0), + REAL_CONST(39220.755785529815/8.0), + REAL_CONST(39239.52057493633/8.0), + REAL_CONST(39258.287607995589/8.0), + REAL_CONST(39277.056884171245/8.0), + REAL_CONST(39295.828402927284/8.0), + REAL_CONST(39314.602163728006/8.0), + REAL_CONST(39333.378166038019/8.0), + REAL_CONST(39352.15640932227/8.0), + REAL_CONST(39370.936893046004/8.0), + REAL_CONST(39389.719616674811/8.0), + REAL_CONST(39408.504579674584/8.0), + REAL_CONST(39427.291781511522/8.0), + REAL_CONST(39446.081221652174/8.0), + REAL_CONST(39464.872899563372/8.0), + REAL_CONST(39483.666814712291/8.0), + REAL_CONST(39502.462966566411/8.0), + REAL_CONST(39521.261354593538/8.0), + REAL_CONST(39540.06197826178/8.0), + REAL_CONST(39558.864837039568/8.0), + REAL_CONST(39577.669930395656/8.0), + REAL_CONST(39596.47725779911/8.0), + REAL_CONST(39615.286818719302/8.0), + REAL_CONST(39634.098612625923/8.0), + REAL_CONST(39652.912638988993/8.0), + REAL_CONST(39671.728897278823/8.0), + REAL_CONST(39690.547386966064/8.0), + REAL_CONST(39709.368107521652/8.0), + REAL_CONST(39728.191058416858/8.0), + REAL_CONST(39747.016239123259/8.0), + REAL_CONST(39765.84364911275/8.0), + REAL_CONST(39784.673287857528/8.0), + REAL_CONST(39803.505154830105/8.0), + REAL_CONST(39822.339249503319/8.0), + REAL_CONST(39841.175571350293/8.0), + REAL_CONST(39860.014119844491/8.0), + REAL_CONST(39878.854894459677/8.0), + REAL_CONST(39897.697894669909/8.0), + REAL_CONST(39916.54311994958/8.0), + REAL_CONST(39935.390569773372/8.0), + REAL_CONST(39954.240243616303/8.0), + REAL_CONST(39973.092140953675/8.0), + REAL_CONST(39991.946261261117/8.0), + REAL_CONST(40010.802604014549/8.0), + REAL_CONST(40029.661168690225/8.0), + REAL_CONST(40048.521954764678/8.0), + REAL_CONST(40067.384961714779/8.0), + REAL_CONST(40086.250189017679/8.0), + REAL_CONST(40105.117636150855/8.0), + REAL_CONST(40123.98730259209/8.0), + REAL_CONST(40142.859187819471/8.0), + REAL_CONST(40161.733291311379/8.0), + REAL_CONST(40180.609612546526/8.0), + REAL_CONST(40199.488151003912/8.0), + REAL_CONST(40218.368906162854/8.0), + REAL_CONST(40237.25187750296/8.0), + REAL_CONST(40256.137064504153/8.0), + REAL_CONST(40275.024466646668/8.0), + REAL_CONST(40293.914083411029/8.0), + REAL_CONST(40312.805914278084/8.0), + REAL_CONST(40331.699958728961/8.0), + REAL_CONST(40350.596216245103/8.0), + REAL_CONST(40369.494686308273/8.0), + REAL_CONST(40388.39536840051/8.0), + REAL_CONST(40407.298262004173/8.0), + REAL_CONST(40426.20336660192/8.0), + REAL_CONST(40445.110681676706/8.0), + REAL_CONST(40464.020206711793/8.0), + REAL_CONST(40482.931941190756/8.0), + REAL_CONST(40501.845884597446/8.0), + REAL_CONST(40520.762036416032/8.0), + REAL_CONST(40539.680396130985/8.0), + REAL_CONST(40558.600963227072/8.0), + REAL_CONST(40577.523737189367/8.0), + REAL_CONST(40596.448717503234/8.0), + REAL_CONST(40615.375903654342/8.0), + REAL_CONST(40634.305295128659/8.0), + REAL_CONST(40653.236891412453/8.0), + REAL_CONST(40672.170691992294/8.0), + REAL_CONST(40691.106696355047/8.0), + REAL_CONST(40710.044903987873/8.0), + REAL_CONST(40728.985314378238/8.0), + REAL_CONST(40747.927927013901/8.0), + REAL_CONST(40766.872741382918/8.0), + REAL_CONST(40785.819756973651/8.0), + REAL_CONST(40804.768973274746/8.0), + REAL_CONST(40823.720389775161/8.0), + REAL_CONST(40842.674005964131/8.0), + REAL_CONST(40861.629821331211/8.0), + REAL_CONST(40880.587835366234/8.0), + REAL_CONST(40899.548047559321/8.0), + REAL_CONST(40918.510457400931/8.0), + REAL_CONST(40937.475064381761/8.0), + REAL_CONST(40956.441867992849/8.0), + REAL_CONST(40975.410867725499/8.0), + REAL_CONST(40994.382063071331/8.0), + REAL_CONST(41013.355453522236/8.0), + REAL_CONST(41032.331038570417/8.0), + REAL_CONST(41051.308817708363/8.0), + REAL_CONST(41070.288790428858/8.0), + REAL_CONST(41089.270956224987/8.0), + REAL_CONST(41108.255314590111/8.0), + REAL_CONST(41127.241865017888/8.0), + REAL_CONST(41146.23060700229/8.0), + REAL_CONST(41165.221540037543/8.0), + REAL_CONST(41184.214663618193/8.0), + REAL_CONST(41203.209977239079/8.0), + REAL_CONST(41222.207480395307/8.0), + REAL_CONST(41241.207172582297/8.0), + REAL_CONST(41260.209053295752/8.0), + REAL_CONST(41279.213122031659/8.0), + REAL_CONST(41298.219378286303/8.0), + REAL_CONST(41317.227821556255/8.0), + REAL_CONST(41336.23845133838/8.0), + REAL_CONST(41355.251267129832/8.0), + REAL_CONST(41374.266268428037/8.0), + REAL_CONST(41393.283454730743/8.0), + REAL_CONST(41412.302825535953/8.0), + REAL_CONST(41431.324380341983/8.0), + REAL_CONST(41450.348118647416/8.0), + REAL_CONST(41469.374039951144/8.0), + REAL_CONST(41488.402143752326/8.0), + REAL_CONST(41507.432429550427/8.0), + REAL_CONST(41526.464896845187/8.0), + REAL_CONST(41545.499545136627/8.0), + REAL_CONST(41564.536373925075/8.0), + REAL_CONST(41583.575382711126/8.0), + REAL_CONST(41602.616570995662/8.0), + REAL_CONST(41621.659938279874/8.0), + REAL_CONST(41640.705484065205/8.0), + REAL_CONST(41659.753207853406/8.0), + REAL_CONST(41678.803109146495/8.0), + REAL_CONST(41697.855187446803/8.0), + REAL_CONST(41716.909442256911/8.0), + REAL_CONST(41735.965873079709/8.0), + REAL_CONST(41755.02447941836/8.0), + REAL_CONST(41774.085260776315/8.0), + REAL_CONST(41793.148216657297/8.0), + REAL_CONST(41812.213346565331/8.0), + REAL_CONST(41831.280650004708/8.0), + REAL_CONST(41850.350126480014/8.0), + REAL_CONST(41869.421775496106/8.0), + REAL_CONST(41888.495596558132/8.0), + REAL_CONST(41907.571589171515/8.0), + REAL_CONST(41926.649752841957/8.0), + REAL_CONST(41945.730087075463/8.0), + REAL_CONST(41964.812591378286/8.0), + REAL_CONST(41983.897265256979/8.0), + REAL_CONST(42002.984108218378/8.0), + REAL_CONST(42022.073119769593/8.0), + REAL_CONST(42041.164299418015/8.0), + REAL_CONST(42060.257646671307/8.0), + REAL_CONST(42079.353161037419/8.0), + REAL_CONST(42098.450842024591/8.0), + REAL_CONST(42117.550689141324/8.0), + REAL_CONST(42136.652701896404/8.0), + REAL_CONST(42155.756879798893/8.0), + REAL_CONST(42174.863222358137/8.0), + REAL_CONST(42193.971729083758/8.0), + REAL_CONST(42213.082399485655/8.0), + REAL_CONST(42232.195233074002/8.0), + REAL_CONST(42251.310229359246/8.0), + REAL_CONST(42270.427387852127/8.0), + REAL_CONST(42289.546708063644/8.0), + REAL_CONST(42308.668189505079/8.0), + REAL_CONST(42327.791831687995/8.0), + REAL_CONST(42346.917634124227/8.0), + REAL_CONST(42366.045596325886/8.0), + REAL_CONST(42385.175717805352/8.0), + REAL_CONST(42404.307998075295/8.0), + REAL_CONST(42423.442436648642/8.0), + REAL_CONST(42442.579033038608/8.0), + REAL_CONST(42461.717786758672/8.0), + REAL_CONST(42480.858697322597/8.0), + REAL_CONST(42500.001764244422/8.0), + REAL_CONST(42519.146987038446/8.0), + REAL_CONST(42538.294365219248/8.0), + REAL_CONST(42557.443898301688/8.0), + REAL_CONST(42576.595585800882/8.0), + REAL_CONST(42595.749427232236/8.0), + REAL_CONST(42614.90542211142/8.0), + REAL_CONST(42634.063569954378/8.0), + REAL_CONST(42653.223870277317/8.0), + REAL_CONST(42672.386322596729/8.0), + REAL_CONST(42691.55092642938/8.0), + REAL_CONST(42710.717681292292/8.0), + REAL_CONST(42729.886586702756/8.0), + REAL_CONST(42749.057642178363/8.0), + REAL_CONST(42768.23084723694/8.0), + REAL_CONST(42787.406201396603/8.0), + REAL_CONST(42806.58370417574/8.0), + REAL_CONST(42825.76335509299/8.0), + REAL_CONST(42844.945153667286/8.0), + REAL_CONST(42864.129099417805/8.0), + REAL_CONST(42883.315191864014/8.0), + REAL_CONST(42902.503430525649/8.0), + REAL_CONST(42921.693814922692/8.0), + REAL_CONST(42940.88634457541/8.0), + REAL_CONST(42960.081019004348/8.0), + REAL_CONST(42979.277837730297/8.0), + REAL_CONST(42998.476800274322/8.0), + REAL_CONST(43017.677906157769/8.0), + REAL_CONST(43036.881154902228/8.0), + REAL_CONST(43056.086546029583/8.0), + REAL_CONST(43075.294079061961/8.0), + REAL_CONST(43094.503753521763/8.0), + REAL_CONST(43113.715568931671/8.0), + REAL_CONST(43132.929524814601/8.0), + REAL_CONST(43152.145620693766/8.0), + REAL_CONST(43171.363856092619/8.0), + REAL_CONST(43190.584230534907/8.0), + REAL_CONST(43209.806743544621/8.0), + REAL_CONST(43229.031394646016/8.0), + REAL_CONST(43248.258183363621/8.0), + REAL_CONST(43267.487109222224/8.0), + REAL_CONST(43286.718171746885/8.0), + REAL_CONST(43305.951370462906/8.0), + REAL_CONST(43325.186704895881/8.0), + REAL_CONST(43344.42417457165/8.0), + REAL_CONST(43363.663779016322/8.0), + REAL_CONST(43382.905517756262/8.0), + REAL_CONST(43402.149390318104/8.0), + REAL_CONST(43421.395396228749/8.0), + REAL_CONST(43440.643535015348/8.0), + REAL_CONST(43459.89380620532/8.0), + REAL_CONST(43479.146209326354/8.0), + REAL_CONST(43498.400743906379/8.0), + REAL_CONST(43517.657409473606/8.0), + REAL_CONST(43536.916205556496/8.0), + REAL_CONST(43556.177131683784/8.0), + REAL_CONST(43575.44018738444/8.0), + REAL_CONST(43594.705372187724/8.0), + REAL_CONST(43613.972685623135/8.0), + REAL_CONST(43633.242127220445/8.0), + REAL_CONST(43652.513696509668/8.0), + REAL_CONST(43671.787393021099/8.0), + REAL_CONST(43691.063216285271/8.0), + REAL_CONST(43710.341165833001/8.0), + REAL_CONST(43729.621241195346/8.0), + REAL_CONST(43748.903441903625/8.0), + REAL_CONST(43768.187767489413/8.0), + REAL_CONST(43787.474217484552/8.0), + REAL_CONST(43806.762791421126/8.0), + REAL_CONST(43826.053488831501/8.0), + REAL_CONST(43845.346309248278/8.0), + REAL_CONST(43864.641252204325/8.0), + REAL_CONST(43883.938317232765/8.0), + REAL_CONST(43903.237503866971/8.0), + REAL_CONST(43922.538811640596/8.0), + REAL_CONST(43941.842240087513/8.0), + REAL_CONST(43961.147788741881/8.0), + REAL_CONST(43980.455457138101/8.0), + REAL_CONST(43999.765244810835/8.0), + REAL_CONST(44019.077151295001/8.0), + REAL_CONST(44038.391176125755/8.0), + REAL_CONST(44057.70731883854/8.0), + REAL_CONST(44077.02557896902/8.0), + REAL_CONST(44096.345956053141/8.0), + REAL_CONST(44115.668449627083/8.0), + REAL_CONST(44134.993059227287/8.0), + REAL_CONST(44154.319784390456/8.0), + REAL_CONST(44173.648624653535/8.0), + REAL_CONST(44192.979579553728/8.0), + REAL_CONST(44212.312648628489/8.0), + REAL_CONST(44231.647831415532/8.0), + REAL_CONST(44250.985127452805/8.0), + REAL_CONST(44270.324536278538/8.0), + REAL_CONST(44289.666057431183/8.0), + REAL_CONST(44309.009690449464/8.0), + REAL_CONST(44328.355434872348/8.0), + REAL_CONST(44347.703290239064/8.0), + REAL_CONST(44367.053256089079/8.0), + REAL_CONST(44386.405331962109/8.0), + REAL_CONST(44405.759517398139/8.0), + REAL_CONST(44425.115811937387/8.0), + REAL_CONST(44444.474215120332/8.0), + REAL_CONST(44463.834726487694/8.0), + REAL_CONST(44483.197345580462/8.0), + REAL_CONST(44502.562071939843/8.0), + REAL_CONST(44521.928905107328/8.0), + REAL_CONST(44541.297844624634/8.0), + REAL_CONST(44560.668890033732/8.0), + REAL_CONST(44580.042040876848/8.0), + REAL_CONST(44599.417296696454/8.0), + REAL_CONST(44618.794657035272/8.0), + REAL_CONST(44638.174121436256/8.0), + REAL_CONST(44657.555689442641/8.0), + REAL_CONST(44676.939360597877/8.0), + REAL_CONST(44696.325134445673/8.0), + REAL_CONST(44715.713010530002/8.0), + REAL_CONST(44735.102988395054/8.0), + REAL_CONST(44754.495067585296/8.0), + REAL_CONST(44773.88924764542/8.0), + REAL_CONST(44793.285528120374/8.0), + REAL_CONST(44812.683908555344/8.0), + REAL_CONST(44832.084388495779/8.0), + REAL_CONST(44851.486967487363/8.0), + REAL_CONST(44870.891645076015/8.0), + REAL_CONST(44890.298420807922/8.0), + REAL_CONST(44909.707294229491/8.0), + REAL_CONST(44929.118264887409/8.0), + REAL_CONST(44948.531332328566/8.0), + REAL_CONST(44967.946496100136/8.0), + REAL_CONST(44987.363755749502/8.0), + REAL_CONST(45006.783110824319/8.0), + REAL_CONST(45026.204560872473/8.0), + REAL_CONST(45045.628105442098/8.0), + REAL_CONST(45065.053744081561/8.0), + REAL_CONST(45084.48147633949/8.0), + REAL_CONST(45103.911301764747/8.0), + REAL_CONST(45123.343219906426/8.0), + REAL_CONST(45142.777230313885/8.0), + REAL_CONST(45162.21333253671/8.0), + REAL_CONST(45181.651526124733/8.0), + REAL_CONST(45201.091810628037/8.0), + REAL_CONST(45220.534185596924/8.0), + REAL_CONST(45239.978650581965/8.0), + REAL_CONST(45259.425205133957/8.0), + REAL_CONST(45278.873848803938/8.0), + REAL_CONST(45298.324581143192/8.0), + REAL_CONST(45317.777401703235/8.0), + REAL_CONST(45337.232310035848/8.0), + REAL_CONST(45356.68930569302/8.0), + REAL_CONST(45376.148388226997/8.0), + REAL_CONST(45395.60955719027/8.0), + REAL_CONST(45415.072812135557/8.0), + REAL_CONST(45434.538152615823/8.0), + REAL_CONST(45454.005578184282/8.0), + REAL_CONST(45473.475088394356/8.0), + REAL_CONST(45492.946682799746/8.0), + REAL_CONST(45512.420360954362/8.0), + REAL_CONST(45531.896122412363/8.0), + REAL_CONST(45551.373966728155/8.0), + REAL_CONST(45570.853893456362/8.0), + REAL_CONST(45590.33590215187/8.0), + REAL_CONST(45609.819992369776/8.0), + REAL_CONST(45629.306163665438/8.0), + REAL_CONST(45648.794415594442/8.0), + REAL_CONST(45668.284747712612/8.0), + REAL_CONST(45687.777159576006/8.0), + REAL_CONST(45707.27165074092/8.0), + REAL_CONST(45726.768220763894/8.0), + REAL_CONST(45746.266869201696/8.0), + REAL_CONST(45765.767595611323/8.0), + REAL_CONST(45785.270399550034/8.0), + REAL_CONST(45804.775280575297/8.0), + REAL_CONST(45824.282238244828/8.0), + REAL_CONST(45843.79127211657/8.0), + REAL_CONST(45863.302381748719/8.0), + REAL_CONST(45882.815566699683/8.0), + REAL_CONST(45902.33082652813/8.0), + REAL_CONST(45921.848160792935/8.0), + REAL_CONST(45941.367569053225/8.0), + REAL_CONST(45960.889050868354/8.0), + REAL_CONST(45980.41260579793/8.0), + REAL_CONST(45999.938233401757/8.0), + REAL_CONST(46019.465933239902/8.0), + REAL_CONST(46038.995704872657/8.0), + REAL_CONST(46058.527547860547/8.0), + REAL_CONST(46078.06146176433/8.0), + REAL_CONST(46097.597446144995/8.0), + REAL_CONST(46117.135500563774/8.0), + REAL_CONST(46136.675624582109/8.0), + REAL_CONST(46156.217817761702/8.0), + REAL_CONST(46175.762079664462/8.0), + REAL_CONST(46195.308409852543/8.0), + REAL_CONST(46214.856807888333/8.0), + REAL_CONST(46234.407273334444/8.0), + REAL_CONST(46253.959805753715/8.0), + REAL_CONST(46273.51440470924/8.0), + REAL_CONST(46293.071069764315/8.0), + REAL_CONST(46312.629800482478/8.0), + REAL_CONST(46332.190596427499/8.0), + REAL_CONST(46351.753457163381/8.0), + REAL_CONST(46371.318382254351/8.0), + REAL_CONST(46390.885371264863/8.0), + REAL_CONST(46410.45442375962/8.0), + REAL_CONST(46430.025539303526/8.0), + REAL_CONST(46449.598717461733/8.0), + REAL_CONST(46469.17395779962/8.0), + REAL_CONST(46488.751259882782/8.0), + REAL_CONST(46508.33062327707/8.0), + REAL_CONST(46527.912047548532/8.0), + REAL_CONST(46547.495532263471/8.0), + REAL_CONST(46567.081076988397/8.0), + REAL_CONST(46586.668681290059/8.0), + REAL_CONST(46606.258344735434/8.0), + REAL_CONST(46625.850066891719/8.0), + REAL_CONST(46645.443847326351/8.0), + REAL_CONST(46665.039685606986/8.0), + REAL_CONST(46684.637581301497/8.0), + REAL_CONST(46704.237533978005/8.0), + REAL_CONST(46723.839543204842/8.0), + REAL_CONST(46743.443608550573/8.0), + REAL_CONST(46763.049729583989/8.0), + REAL_CONST(46782.657905874104/8.0), + REAL_CONST(46802.268136990162/8.0), + REAL_CONST(46821.880422501628/8.0), + REAL_CONST(46841.494761978196/8.0), + REAL_CONST(46861.111154989776/8.0), + REAL_CONST(46880.729601106526/8.0), + REAL_CONST(46900.350099898795/8.0), + REAL_CONST(46919.97265093719/8.0), + REAL_CONST(46939.597253792526/8.0), + REAL_CONST(46959.223908035841/8.0), + REAL_CONST(46978.852613238392/8.0), + REAL_CONST(46998.483368971691/8.0), + REAL_CONST(47018.11617480743/8.0), + REAL_CONST(47037.751030317551/8.0), + REAL_CONST(47057.387935074221/8.0), + REAL_CONST(47077.026888649809/8.0), + REAL_CONST(47096.66789061694/8.0), + REAL_CONST(47116.310940548428/8.0), + REAL_CONST(47135.956038017328/8.0), + REAL_CONST(47155.603182596918/8.0), + REAL_CONST(47175.252373860698/8.0), + REAL_CONST(47194.903611382375/8.0), + REAL_CONST(47214.556894735892/8.0), + REAL_CONST(47234.212223495422/8.0), + REAL_CONST(47253.869597235338/8.0), + REAL_CONST(47273.52901553025/8.0), + REAL_CONST(47293.19047795498/8.0), + REAL_CONST(47312.853984084577/8.0), + REAL_CONST(47332.519533494306/8.0), + REAL_CONST(47352.187125759658/8.0), + REAL_CONST(47371.856760456343/8.0), + REAL_CONST(47391.528437160297/8.0), + REAL_CONST(47411.202155447652/8.0), + REAL_CONST(47430.877914894787/8.0), + REAL_CONST(47450.555715078299/8.0), + REAL_CONST(47470.235555574982/8.0), + REAL_CONST(47489.917435961863/8.0), + REAL_CONST(47509.601355816201/8.0), + REAL_CONST(47529.287314715453/8.0), + REAL_CONST(47548.975312237308/8.0), + REAL_CONST(47568.665347959672/8.0), + REAL_CONST(47588.357421460656/8.0), + REAL_CONST(47608.051532318605/8.0), + REAL_CONST(47627.747680112072/8.0), + REAL_CONST(47647.445864419846/8.0), + REAL_CONST(47667.14608482091/8.0), + REAL_CONST(47686.848340894474/8.0), + REAL_CONST(47706.552632219973/8.0), + REAL_CONST(47726.258958377046/8.0), + REAL_CONST(47745.967318945557/8.0), + REAL_CONST(47765.677713505589/8.0), + REAL_CONST(47785.390141637428/8.0), + REAL_CONST(47805.104602921601/8.0), + REAL_CONST(47824.821096938824/8.0), + REAL_CONST(47844.539623270044/8.0), + REAL_CONST(47864.260181496429/8.0), + REAL_CONST(47883.982771199349/8.0), + REAL_CONST(47903.707391960394/8.0), + REAL_CONST(47923.434043361369/8.0), + REAL_CONST(47943.162724984308/8.0), + REAL_CONST(47962.893436411439/8.0), + REAL_CONST(47982.626177225218/8.0), + REAL_CONST(48002.36094700831/8.0), + REAL_CONST(48022.097745343599/8.0), + REAL_CONST(48041.836571814172/8.0), + REAL_CONST(48061.57742600335/8.0), + REAL_CONST(48081.32030749465/8.0), + REAL_CONST(48101.065215871815/8.0), + REAL_CONST(48120.81215071879/8.0), + REAL_CONST(48140.56111161974/8.0), + REAL_CONST(48160.312098159047/8.0), + REAL_CONST(48180.065109921306/8.0), + REAL_CONST(48199.820146491307/8.0), + REAL_CONST(48219.577207454073/8.0), + REAL_CONST(48239.336292394844/8.0), + REAL_CONST(48259.097400899045/8.0), + REAL_CONST(48278.860532552339/8.0), + REAL_CONST(48298.625686940592/8.0), + REAL_CONST(48318.392863649875/8.0), + REAL_CONST(48338.162062266485/8.0), + REAL_CONST(48357.933282376915/8.0), + REAL_CONST(48377.706523567889/8.0), + REAL_CONST(48397.481785426316/8.0), + REAL_CONST(48417.259067539344/8.0), + REAL_CONST(48437.038369494308/8.0), + REAL_CONST(48456.819690878765/8.0), + REAL_CONST(48476.603031280487/8.0), + REAL_CONST(48496.388390287451/8.0), + REAL_CONST(48516.175767487839/8.0), + REAL_CONST(48535.965162470042/8.0), + REAL_CONST(48555.756574822684/8.0), + REAL_CONST(48575.550004134566/8.0), + REAL_CONST(48595.345449994718/8.0), + REAL_CONST(48615.142911992378/8.0), + REAL_CONST(48634.942389716991/8.0), + REAL_CONST(48654.743882758201/8.0), + REAL_CONST(48674.547390705877/8.0), + REAL_CONST(48694.352913150084/8.0), + REAL_CONST(48714.160449681112/8.0), + REAL_CONST(48733.969999889443/8.0), + REAL_CONST(48753.781563365759/8.0), + REAL_CONST(48773.595139700978/8.0), + REAL_CONST(48793.410728486211/8.0), + REAL_CONST(48813.228329312769/8.0), + REAL_CONST(48833.047941772187/8.0), + REAL_CONST(48852.869565456189/8.0), + REAL_CONST(48872.693199956717/8.0), + REAL_CONST(48892.518844865925/8.0), + REAL_CONST(48912.346499776155/8.0), + REAL_CONST(48932.176164279976/8.0), + REAL_CONST(48952.007837970152/8.0), + REAL_CONST(48971.841520439666/8.0), + REAL_CONST(48991.677211281676/8.0), + REAL_CONST(49011.514910089587/8.0), + REAL_CONST(49031.354616456978/8.0), + REAL_CONST(49051.196329977654/8.0), + REAL_CONST(49071.04005024561/8.0), + REAL_CONST(49090.885776855059/8.0), + REAL_CONST(49110.733509400408/8.0), + REAL_CONST(49130.583247476279/8.0), + REAL_CONST(49150.434990677488/8.0), + REAL_CONST(49170.288738599062/8.0), + REAL_CONST(49190.144490836232/8.0), + REAL_CONST(49210.002246984441/8.0), + REAL_CONST(49229.86200663932/8.0), + REAL_CONST(49249.723769396718/8.0), + REAL_CONST(49269.587534852675/8.0), + REAL_CONST(49289.453302603448/8.0), + REAL_CONST(49309.32107224549/8.0), + REAL_CONST(49329.190843375451/8.0), + REAL_CONST(49349.062615590192/8.0), + REAL_CONST(49368.936388486785/8.0), + REAL_CONST(49388.812161662492/8.0), + REAL_CONST(49408.689934714785/8.0), + REAL_CONST(49428.569707241324/8.0), + REAL_CONST(49448.45147883999/8.0), + REAL_CONST(49468.335249108866/8.0), + REAL_CONST(49488.22101764621/8.0), + REAL_CONST(49508.108784050521/8.0), + REAL_CONST(49527.99854792047/8.0), + REAL_CONST(49547.890308854934/8.0), + REAL_CONST(49567.784066453009/8.0), + REAL_CONST(49587.679820313977/8.0), + REAL_CONST(49607.57757003732/8.0), + REAL_CONST(49627.477315222721/8.0), + REAL_CONST(49647.379055470075/8.0), + REAL_CONST(49667.28279037946/8.0), + REAL_CONST(49687.188519551179/8.0), + REAL_CONST(49707.096242585707/8.0), + REAL_CONST(49727.005959083741/8.0), + REAL_CONST(49746.917668646165/8.0), + REAL_CONST(49766.831370874068/8.0), + REAL_CONST(49786.747065368734/8.0), + REAL_CONST(49806.66475173166/8.0), + REAL_CONST(49826.584429564515/8.0), + REAL_CONST(49846.506098469203/8.0), + REAL_CONST(49866.429758047794/8.0), + REAL_CONST(49886.355407902578/8.0), + REAL_CONST(49906.283047636032/8.0), + REAL_CONST(49926.212676850846/8.0), + REAL_CONST(49946.144295149883/8.0), + REAL_CONST(49966.077902136225/8.0), + REAL_CONST(49986.013497413151/8.0), + REAL_CONST(50005.951080584135/8.0), + REAL_CONST(50025.890651252834/8.0), + REAL_CONST(50045.832209023123/8.0), + REAL_CONST(50065.775753499074/8.0), + REAL_CONST(50085.721284284933/8.0), + REAL_CONST(50105.668800985164/8.0), + REAL_CONST(50125.618303204428/8.0), + REAL_CONST(50145.569790547575/8.0), + REAL_CONST(50165.523262619652/8.0), + REAL_CONST(50185.478719025901/8.0), + REAL_CONST(50205.436159371769/8.0), + REAL_CONST(50225.395583262893/8.0), + REAL_CONST(50245.356990305103/8.0), + REAL_CONST(50265.320380104429/8.0), + REAL_CONST(50285.285752267104/8.0), + REAL_CONST(50305.253106399534/8.0), + REAL_CONST(50325.222442108337/8.0), + REAL_CONST(50345.193759000336/8.0), + REAL_CONST(50365.16705668252/8.0), + REAL_CONST(50385.142334762102/8.0), + REAL_CONST(50405.119592846473/8.0), + REAL_CONST(50425.098830543218/8.0), + REAL_CONST(50445.080047460127/8.0), + REAL_CONST(50465.063243205179/8.0), + REAL_CONST(50485.048417386541/8.0), + REAL_CONST(50505.035569612577/8.0), + REAL_CONST(50525.024699491856/8.0), + REAL_CONST(50545.015806633128/8.0), + REAL_CONST(50565.008890645338/8.0), + REAL_CONST(50585.003951137631/8.0), + REAL_CONST(50605.00098771933/8.0), + REAL_CONST(50624.999999999971/8.0), + REAL_CONST(50645.000987589265/8.0), + REAL_CONST(50665.003950097132/8.0), + REAL_CONST(50685.008887133677/8.0), + REAL_CONST(50705.015798309192/8.0), + REAL_CONST(50725.024683234165/8.0), + REAL_CONST(50745.035541519283/8.0), + REAL_CONST(50765.048372775411/8.0), + REAL_CONST(50785.063176613621/8.0), + REAL_CONST(50805.079952645159/8.0), + REAL_CONST(50825.098700481489/8.0), + REAL_CONST(50845.119419734241/8.0), + REAL_CONST(50865.142110015244/8.0), + REAL_CONST(50885.166770936521/8.0), + REAL_CONST(50905.193402110279/8.0), + REAL_CONST(50925.222003148934/8.0), + REAL_CONST(50945.252573665071/8.0), + REAL_CONST(50965.285113271471/8.0), + REAL_CONST(50985.319621581119/8.0), + REAL_CONST(51005.356098207172/8.0), + REAL_CONST(51025.394542762981/8.0), + REAL_CONST(51045.434954862096/8.0), + REAL_CONST(51065.477334118244/8.0), + REAL_CONST(51085.521680145357/8.0), + REAL_CONST(51105.567992557546/8.0), + REAL_CONST(51125.616270969113/8.0), + REAL_CONST(51145.66651499454/8.0), + REAL_CONST(51165.718724248516/8.0), + REAL_CONST(51185.772898345916/8.0), + REAL_CONST(51205.829036901778/8.0), + REAL_CONST(51225.887139531362/8.0), + REAL_CONST(51245.947205850105/8.0), + REAL_CONST(51266.009235473619/8.0), + REAL_CONST(51286.073228017718/8.0), + REAL_CONST(51306.139183098399/8.0), + REAL_CONST(51326.207100331856/8.0), + REAL_CONST(51346.276979334456/8.0), + REAL_CONST(51366.348819722756/8.0), + REAL_CONST(51386.42262111351/8.0), + REAL_CONST(51406.498383123653/8.0), + REAL_CONST(51426.57610537031/8.0), + REAL_CONST(51446.655787470787/8.0), + REAL_CONST(51466.737429042587/8.0), + REAL_CONST(51486.82102970338/8.0), + REAL_CONST(51506.906589071048/8.0), + REAL_CONST(51526.994106763632/8.0), + REAL_CONST(51547.083582399391/8.0), + REAL_CONST(51567.175015596738/8.0), + REAL_CONST(51587.268405974297/8.0), + REAL_CONST(51607.363753150858/8.0), + REAL_CONST(51627.461056745415/8.0), + REAL_CONST(51647.56031637713/8.0), + REAL_CONST(51667.661531665362/8.0), + REAL_CONST(51687.764702229651/8.0), + REAL_CONST(51707.869827689727/8.0), + REAL_CONST(51727.976907665499/8.0), + REAL_CONST(51748.085941777055/8.0), + REAL_CONST(51768.196929644677/8.0), + REAL_CONST(51788.309870888836/8.0), + REAL_CONST(51808.42476513017/8.0), + REAL_CONST(51828.541611989524/8.0), + REAL_CONST(51848.660411087905/8.0), + REAL_CONST(51868.781162046515/8.0), + REAL_CONST(51888.90386448674/8.0), + REAL_CONST(51909.028518030143/8.0), + REAL_CONST(51929.155122298485/8.0), + REAL_CONST(51949.283676913685/8.0), + REAL_CONST(51969.414181497872/8.0), + REAL_CONST(51989.546635673345/8.0), + REAL_CONST(52009.681039062583/8.0), + REAL_CONST(52029.817391288263/8.0), + REAL_CONST(52049.955691973213/8.0), + REAL_CONST(52070.095940740481/8.0), + REAL_CONST(52090.238137213273/8.0), + REAL_CONST(52110.382281014987/8.0), + REAL_CONST(52130.5283717692/8.0), + REAL_CONST(52150.676409099666/8.0), + REAL_CONST(52170.826392630333/8.0), + REAL_CONST(52190.97832198532/8.0), + REAL_CONST(52211.132196788931/8.0), + REAL_CONST(52231.288016665654/8.0), + REAL_CONST(52251.445781240145/8.0), + REAL_CONST(52271.60549013727/8.0), + REAL_CONST(52291.76714298204/8.0), + REAL_CONST(52311.930739399664/8.0), + REAL_CONST(52332.096279015546/8.0), + REAL_CONST(52352.263761455244/8.0), + REAL_CONST(52372.433186344519/8.0), + REAL_CONST(52392.604553309284/8.0), + REAL_CONST(52412.777861975665/8.0), + REAL_CONST(52432.953111969946/8.0), + REAL_CONST(52453.130302918595/8.0), + REAL_CONST(52473.309434448267/8.0), + REAL_CONST(52493.490506185793/8.0), + REAL_CONST(52513.67351775818/8.0), + REAL_CONST(52533.858468792605/8.0), + REAL_CONST(52554.045358916446/8.0), + REAL_CONST(52574.234187757254/8.0), + REAL_CONST(52594.42495494274/8.0), + REAL_CONST(52614.617660100812/8.0), + REAL_CONST(52634.812302859558/8.0), + REAL_CONST(52655.008882847229/8.0), + REAL_CONST(52675.20739969227/8.0), + REAL_CONST(52695.407853023295/8.0), + REAL_CONST(52715.610242469098/8.0), + REAL_CONST(52735.814567658657/8.0), + REAL_CONST(52756.02082822111/8.0), + REAL_CONST(52776.229023785803/8.0), + REAL_CONST(52796.439153982225/8.0), + REAL_CONST(52816.651218440056/8.0), + REAL_CONST(52836.865216789171/8.0), + REAL_CONST(52857.081148659599/8.0), + REAL_CONST(52877.29901368155/8.0), + REAL_CONST(52897.518811485425/8.0), + REAL_CONST(52917.740541701773/8.0), + REAL_CONST(52937.964203961354/8.0), + REAL_CONST(52958.18979789508/8.0), + REAL_CONST(52978.417323134046/8.0), + REAL_CONST(52998.646779309529/8.0), + REAL_CONST(53018.878166052978/8.0), + REAL_CONST(53039.111482996006/8.0), + REAL_CONST(53059.346729770419/8.0), + REAL_CONST(53079.583906008193/8.0), + REAL_CONST(53099.823011341483/8.0), + REAL_CONST(53120.0640454026/8.0), + REAL_CONST(53140.307007824063/8.0), + REAL_CONST(53160.551898238533/8.0), + REAL_CONST(53180.79871627887/8.0), + REAL_CONST(53201.047461578091/8.0), + REAL_CONST(53221.2981337694/8.0), + REAL_CONST(53241.550732486176/8.0), + REAL_CONST(53261.805257361964/8.0), + REAL_CONST(53282.061708030487/8.0), + REAL_CONST(53302.32008412564/8.0), + REAL_CONST(53322.580385281493/8.0), + REAL_CONST(53342.842611132299/8.0), + REAL_CONST(53363.106761312469/8.0), + REAL_CONST(53383.372835456597/8.0), + REAL_CONST(53403.640833199453/8.0), + REAL_CONST(53423.910754175973/8.0), + REAL_CONST(53444.18259802126/8.0), + REAL_CONST(53464.456364370613/8.0), + REAL_CONST(53484.732052859479/8.0), + REAL_CONST(53505.009663123499/8.0), + REAL_CONST(53525.289194798468/8.0), + REAL_CONST(53545.570647520362/8.0), + REAL_CONST(53565.854020925333/8.0), + REAL_CONST(53586.139314649699/8.0), + REAL_CONST(53606.426528329954/8.0), + REAL_CONST(53626.715661602764/8.0), + REAL_CONST(53647.006714104959/8.0), + REAL_CONST(53667.299685473547/8.0), + REAL_CONST(53687.59457534572/8.0), + REAL_CONST(53707.891383358816/8.0), + REAL_CONST(53728.190109150361/8.0), + REAL_CONST(53748.490752358055/8.0), + REAL_CONST(53768.793312619753/8.0), + REAL_CONST(53789.09778957349/8.0), + REAL_CONST(53809.404182857485/8.0), + REAL_CONST(53829.712492110106/8.0), + REAL_CONST(53850.022716969899/8.0), + REAL_CONST(53870.334857075584/8.0), + REAL_CONST(53890.648912066055/8.0), + REAL_CONST(53910.964881580367/8.0), + REAL_CONST(53931.28276525774/8.0), + REAL_CONST(53951.602562737586/8.0), + REAL_CONST(53971.924273659461/8.0), + REAL_CONST(53992.24789766311/8.0), + REAL_CONST(54012.57343438844/8.0), + REAL_CONST(54032.90088347553/8.0), + REAL_CONST(54053.23024456462/8.0), + REAL_CONST(54073.561517296133/8.0), + REAL_CONST(54093.894701310644/8.0), + REAL_CONST(54114.22979624891/8.0), + REAL_CONST(54134.566801751855/8.0), + REAL_CONST(54154.90571746057/8.0), + REAL_CONST(54175.246543016314/8.0), + REAL_CONST(54195.589278060506/8.0), + REAL_CONST(54215.933922234755/8.0), + REAL_CONST(54236.280475180814/8.0), + REAL_CONST(54256.628936540626/8.0), + REAL_CONST(54276.97930595628/8.0), + REAL_CONST(54297.331583070045/8.0), + REAL_CONST(54317.685767524359/8.0), + REAL_CONST(54338.041858961828/8.0), + REAL_CONST(54358.399857025215/8.0), + REAL_CONST(54378.759761357462/8.0), + REAL_CONST(54399.121571601667/8.0), + REAL_CONST(54419.485287401105/8.0), + REAL_CONST(54439.850908399218/8.0), + REAL_CONST(54460.218434239614/8.0), + REAL_CONST(54480.587864566056/8.0), + REAL_CONST(54500.95919902248/8.0), + REAL_CONST(54521.332437252997/8.0), + REAL_CONST(54541.707578901878/8.0), + REAL_CONST(54562.084623613555/8.0), + REAL_CONST(54582.46357103264/8.0), + REAL_CONST(54602.844420803893/8.0), + REAL_CONST(54623.227172572246/8.0), + REAL_CONST(54643.611825982807/8.0), + REAL_CONST(54663.998380680838/8.0), + REAL_CONST(54684.386836311773/8.0), + REAL_CONST(54704.777192521207/8.0), + REAL_CONST(54725.169448954897/8.0), + REAL_CONST(54745.563605258772/8.0), + REAL_CONST(54765.959661078923/8.0), + REAL_CONST(54786.357616061614/8.0), + REAL_CONST(54806.757469853255/8.0), + REAL_CONST(54827.159222100439/8.0), + REAL_CONST(54847.562872449904/8.0), + REAL_CONST(54867.968420548583/8.0), + REAL_CONST(54888.375866043534/8.0), + REAL_CONST(54908.785208582012/8.0), + REAL_CONST(54929.196447811417/8.0), + REAL_CONST(54949.609583379322/8.0), + REAL_CONST(54970.024614933463/8.0), + REAL_CONST(54990.441542121727/8.0), + REAL_CONST(55010.86036459219/8.0), + REAL_CONST(55031.28108199306/8.0), + REAL_CONST(55051.703693972733/8.0), + REAL_CONST(55072.128200179759/8.0), + REAL_CONST(55092.554600262847/8.0), + REAL_CONST(55112.982893870874/8.0), + REAL_CONST(55133.413080652877/8.0), + REAL_CONST(55153.845160258061/8.0), + REAL_CONST(55174.279132335789/8.0), + REAL_CONST(55194.714996535586/8.0), + REAL_CONST(55215.152752507143/8.0), + REAL_CONST(55235.592399900306/8.0), + REAL_CONST(55256.033938365079/8.0), + REAL_CONST(55276.477367551655/8.0), + REAL_CONST(55296.92268711036/8.0), + REAL_CONST(55317.369896691685/8.0), + REAL_CONST(55337.818995946305/8.0), + REAL_CONST(55358.269984525024/8.0), + REAL_CONST(55378.72286207883/8.0), + REAL_CONST(55399.177628258869/8.0), + REAL_CONST(55419.634282716441/8.0), + REAL_CONST(55440.092825103013/8.0), + REAL_CONST(55460.553255070205/8.0), + REAL_CONST(55481.015572269804/8.0), + REAL_CONST(55501.479776353764/8.0), + REAL_CONST(55521.945866974187/8.0), + REAL_CONST(55542.413843783339/8.0), + REAL_CONST(55562.883706433655/8.0), + REAL_CONST(55583.355454577715/8.0), + REAL_CONST(55603.82908786826/8.0), + REAL_CONST(55624.304605958219/8.0), + REAL_CONST(55644.782008500639/8.0), + REAL_CONST(55665.261295148754/8.0), + REAL_CONST(55685.742465555952/8.0), + REAL_CONST(55706.225519375774/8.0), + REAL_CONST(55726.710456261928/8.0), + REAL_CONST(55747.197275868275/8.0), + REAL_CONST(55767.685977848843/8.0), + REAL_CONST(55788.176561857814/8.0), + REAL_CONST(55808.669027549528/8.0), + REAL_CONST(55829.163374578478/8.0), + REAL_CONST(55849.659602599328/8.0), + REAL_CONST(55870.157711266889/8.0), + REAL_CONST(55890.657700236145/8.0), + REAL_CONST(55911.159569162221/8.0), + REAL_CONST(55931.663317700411/8.0), + REAL_CONST(55952.168945506164/8.0), + REAL_CONST(55972.676452235086/8.0), + REAL_CONST(55993.185837542944/8.0), + REAL_CONST(56013.697101085651/8.0), + REAL_CONST(56034.210242519301/8.0), + REAL_CONST(56054.72526150012/8.0), + REAL_CONST(56075.242157684508/8.0), + REAL_CONST(56095.760930729011/8.0), + REAL_CONST(56116.281580290342/8.0), + REAL_CONST(56136.804106025367/8.0), + REAL_CONST(56157.328507591104/8.0), + REAL_CONST(56177.85478464474/8.0), + REAL_CONST(56198.382936843598/8.0), + REAL_CONST(56218.912963845185/8.0), + REAL_CONST(56239.444865307138/8.0), + REAL_CONST(56259.978640887268/8.0), + REAL_CONST(56280.514290243525/8.0), + REAL_CONST(56301.051813034042/8.0), + REAL_CONST(56321.591208917082/8.0), + REAL_CONST(56342.13247755108/8.0), + REAL_CONST(56362.675618594607/8.0), + REAL_CONST(56383.220631706419/8.0), + REAL_CONST(56403.767516545398/8.0), + REAL_CONST(56424.316272770608/8.0), + REAL_CONST(56444.866900041241/8.0), + REAL_CONST(56465.419398016667/8.0), + REAL_CONST(56485.973766356394/8.0), + REAL_CONST(56506.530004720102/8.0), + REAL_CONST(56527.088112767611/8.0), + REAL_CONST(56547.648090158902/8.0), + REAL_CONST(56568.209936554107/8.0), + REAL_CONST(56588.773651613519/8.0), + REAL_CONST(56609.339234997584/8.0), + REAL_CONST(56629.9066863669/8.0), + REAL_CONST(56650.47600538221/8.0), + REAL_CONST(56671.04719170442/8.0), + REAL_CONST(56691.620244994599/8.0), + REAL_CONST(56712.195164913959/8.0), + REAL_CONST(56732.771951123868/8.0), + REAL_CONST(56753.350603285835/8.0), + REAL_CONST(56773.931121061541/8.0), + REAL_CONST(56794.513504112823/8.0), + REAL_CONST(56815.097752101647/8.0), + REAL_CONST(56835.683864690152/8.0), + REAL_CONST(56856.271841540627/8.0), + REAL_CONST(56876.86168231551/8.0), + REAL_CONST(56897.453386677393/8.0), + REAL_CONST(56918.046954289028/8.0), + REAL_CONST(56938.642384813298/8.0), + REAL_CONST(56959.239677913261/8.0), + REAL_CONST(56979.838833252121/8.0), + REAL_CONST(57000.439850493225/8.0), + REAL_CONST(57021.04272930009/8.0), + REAL_CONST(57041.647469336371/8.0), + REAL_CONST(57062.254070265873/8.0), + REAL_CONST(57082.862531752558/8.0), + REAL_CONST(57103.472853460553/8.0), + REAL_CONST(57124.085035054108/8.0), + REAL_CONST(57144.699076197649/8.0), + REAL_CONST(57165.314976555739/8.0), + REAL_CONST(57185.932735793103/8.0), + REAL_CONST(57206.552353574611/8.0), + REAL_CONST(57227.173829565276/8.0), + REAL_CONST(57247.797163430281/8.0), + REAL_CONST(57268.42235483494/8.0), + REAL_CONST(57289.049403444733/8.0), + REAL_CONST(57309.678308925286/8.0), + REAL_CONST(57330.30907094237/8.0), + REAL_CONST(57350.941689161911/8.0), + REAL_CONST(57371.576163249985/8.0), + REAL_CONST(57392.212492872815/8.0), + REAL_CONST(57412.850677696784/8.0), + REAL_CONST(57433.490717388406/8.0), + REAL_CONST(57454.132611614368/8.0), + REAL_CONST(57474.776360041491/8.0), + REAL_CONST(57495.421962336746/8.0), + REAL_CONST(57516.069418167266/8.0), + REAL_CONST(57536.718727200314/8.0), + REAL_CONST(57557.36988910332/8.0), + REAL_CONST(57578.022903543861/8.0), + REAL_CONST(57598.677770189643/8.0), + REAL_CONST(57619.334488708548/8.0), + REAL_CONST(57639.993058768589/8.0), + REAL_CONST(57660.653480037938/8.0), + REAL_CONST(57681.315752184906/8.0), + REAL_CONST(57701.979874877965/8.0), + REAL_CONST(57722.64584778573/8.0), + REAL_CONST(57743.31367057695/8.0), + REAL_CONST(57763.983342920546/8.0), + REAL_CONST(57784.654864485572/8.0), + REAL_CONST(57805.328234941233/8.0), + REAL_CONST(57826.003453956881/8.0), + REAL_CONST(57846.680521202026/8.0), + REAL_CONST(57867.359436346305/8.0), + REAL_CONST(57888.040199059527/8.0), + REAL_CONST(57908.722809011633/8.0), + REAL_CONST(57929.407265872709/8.0), + REAL_CONST(57950.093569313001/8.0), + REAL_CONST(57970.781719002895/8.0), + REAL_CONST(57991.471714612911/8.0), + REAL_CONST(58012.16355581375/8.0), + REAL_CONST(58032.857242276223/8.0), + REAL_CONST(58053.552773671312/8.0), + REAL_CONST(58074.25014967013/8.0), + REAL_CONST(58094.949369943948/8.0), + REAL_CONST(58115.650434164185/8.0), + REAL_CONST(58136.353342002389/8.0), + REAL_CONST(58157.058093130276/8.0), + REAL_CONST(58177.764687219693/8.0), + REAL_CONST(58198.47312394264/8.0), + REAL_CONST(58219.183402971255/8.0), + REAL_CONST(58239.895523977837/8.0), + REAL_CONST(58260.609486634821/8.0), + REAL_CONST(58281.325290614775/8.0), + REAL_CONST(58302.042935590434/8.0), + REAL_CONST(58322.762421234678/8.0), + REAL_CONST(58343.483747220511/8.0), + REAL_CONST(58364.206913221096/8.0), + REAL_CONST(58384.931918909751/8.0), + REAL_CONST(58405.658763959924/8.0), + REAL_CONST(58426.3874480452/8.0), + REAL_CONST(58447.117970839339/8.0), + REAL_CONST(58467.85033201622/8.0), + REAL_CONST(58488.584531249864/8.0), + REAL_CONST(58509.320568214462/8.0), + REAL_CONST(58530.058442584334/8.0), + REAL_CONST(58550.798154033931/8.0), + REAL_CONST(58571.539702237875/8.0), + REAL_CONST(58592.283086870906/8.0), + REAL_CONST(58613.028307607929/8.0), + REAL_CONST(58633.775364123983/8.0), + REAL_CONST(58654.52425609425/8.0), + REAL_CONST(58675.274983194053/8.0), + REAL_CONST(58696.027545098877/8.0), + REAL_CONST(58716.781941484325/8.0), + REAL_CONST(58737.538172026158/8.0), + REAL_CONST(58758.296236400274/8.0), + REAL_CONST(58779.056134282728/8.0), + REAL_CONST(58799.817865349694/8.0), + REAL_CONST(58820.581429277503/8.0), + REAL_CONST(58841.346825742643/8.0), + REAL_CONST(58862.114054421712/8.0), + REAL_CONST(58882.883114991484/8.0), + REAL_CONST(58903.654007128847/8.0), + REAL_CONST(58924.426730510851/8.0), + REAL_CONST(58945.201284814684/8.0), + REAL_CONST(58965.977669717664/8.0), + REAL_CONST(58986.755884897269/8.0), + REAL_CONST(59007.535930031117/8.0), + REAL_CONST(59028.317804796949/8.0), + REAL_CONST(59049.101508872664/8.0), + REAL_CONST(59069.887041936301/8.0), + REAL_CONST(59090.674403666046/8.0), + REAL_CONST(59111.463593740213/8.0), + REAL_CONST(59132.254611837263/8.0), + REAL_CONST(59153.047457635803/8.0), + REAL_CONST(59173.84213081457/8.0), + REAL_CONST(59194.638631052461/8.0), + REAL_CONST(59215.436958028506/8.0), + REAL_CONST(59236.237111421855/8.0), + REAL_CONST(59257.039090911829/8.0), + REAL_CONST(59277.842896177877/8.0), + REAL_CONST(59298.648526899589/8.0), + REAL_CONST(59319.455982756685/8.0), + REAL_CONST(59340.26526342905/8.0), + REAL_CONST(59361.076368596696/8.0), + REAL_CONST(59381.889297939757/8.0), + REAL_CONST(59402.704051138542/8.0), + REAL_CONST(59423.520627873484/8.0), + REAL_CONST(59444.339027825139/8.0), + REAL_CONST(59465.159250674224/8.0), + REAL_CONST(59485.9812961016/8.0), + REAL_CONST(59506.805163788253/8.0), + REAL_CONST(59527.630853415307/8.0), + REAL_CONST(59548.458364664046/8.0), + REAL_CONST(59569.287697215863/8.0), + REAL_CONST(59590.118850752311/8.0), + REAL_CONST(59610.951824955089/8.0), + REAL_CONST(59631.786619506012/8.0), + REAL_CONST(59652.623234087048/8.0), + REAL_CONST(59673.461668380311/8.0), + REAL_CONST(59694.301922068029/8.0), + REAL_CONST(59715.143994832593/8.0), + REAL_CONST(59735.987886356525/8.0), + REAL_CONST(59756.833596322482/8.0), + REAL_CONST(59777.681124413255/8.0), + REAL_CONST(59798.530470311794/8.0), + REAL_CONST(59819.381633701159/8.0), + REAL_CONST(59840.234614264569/8.0), + REAL_CONST(59861.089411685381/8.0), + REAL_CONST(59881.94602564707/8.0), + REAL_CONST(59902.804455833269/8.0), + REAL_CONST(59923.664701927737/8.0), + REAL_CONST(59944.526763614384/8.0), + REAL_CONST(59965.390640577243/8.0), + REAL_CONST(59986.256332500488/8.0), + REAL_CONST(60007.123839068438/8.0), + REAL_CONST(60027.993159965539/8.0), + REAL_CONST(60048.864294876381/8.0), + REAL_CONST(60069.737243485688/8.0), + REAL_CONST(60090.612005478324/8.0), + REAL_CONST(60111.488580539284/8.0), + REAL_CONST(60132.366968353708/8.0), + REAL_CONST(60153.247168606867/8.0), + REAL_CONST(60174.129180984164/8.0), + REAL_CONST(60195.013005171153/8.0), + REAL_CONST(60215.898640853513/8.0), + REAL_CONST(60236.786087717061/8.0), + REAL_CONST(60257.675345447751/8.0), + REAL_CONST(60278.566413731671/8.0), + REAL_CONST(60299.459292255044/8.0), + REAL_CONST(60320.353980704247/8.0), + REAL_CONST(60341.25047876576/8.0), + REAL_CONST(60362.148786126229/8.0), + REAL_CONST(60383.048902472423/8.0), + REAL_CONST(60403.950827491237/8.0), + REAL_CONST(60424.854560869717/8.0), + REAL_CONST(60445.76010229504/8.0), + REAL_CONST(60466.667451454516/8.0), + REAL_CONST(60487.57660803559/8.0), + REAL_CONST(60508.487571725847/8.0), + REAL_CONST(60529.400342212997/8.0), + REAL_CONST(60550.314919184893/8.0), + REAL_CONST(60571.231302329521/8.0), + REAL_CONST(60592.149491335003/8.0), + REAL_CONST(60613.069485889588/8.0), + REAL_CONST(60633.991285681674/8.0), + REAL_CONST(60654.914890399785/8.0), + REAL_CONST(60675.840299732568/8.0), + REAL_CONST(60696.767513368832/8.0), + REAL_CONST(60717.696530997484/8.0), + REAL_CONST(60738.627352307602/8.0), + REAL_CONST(60759.55997698837/8.0), + REAL_CONST(60780.494404729128/8.0), + REAL_CONST(60801.430635219323/8.0), + REAL_CONST(60822.368668148556/8.0), + REAL_CONST(60843.308503206565/8.0), + REAL_CONST(60864.250140083204/8.0), + REAL_CONST(60885.193578468468/8.0), + REAL_CONST(60906.138818052495/8.0), + REAL_CONST(60927.085858525541/8.0), + REAL_CONST(60948.034699578006/8.0), + REAL_CONST(60968.985340900421/8.0), + REAL_CONST(60989.937782183442/8.0), + REAL_CONST(61010.892023117864/8.0), + REAL_CONST(61031.848063394616/8.0), + REAL_CONST(61052.805902704764/8.0), + REAL_CONST(61073.765540739492/8.0), + REAL_CONST(61094.726977190134/8.0), + REAL_CONST(61115.690211748137/8.0), + REAL_CONST(61136.655244105103/8.0), + REAL_CONST(61157.622073952742/8.0), + REAL_CONST(61178.590700982917/8.0), + REAL_CONST(61199.561124887616/8.0), + REAL_CONST(61220.533345358948/8.0), + REAL_CONST(61241.507362089171/8.0), + REAL_CONST(61262.483174770663/8.0), + REAL_CONST(61283.460783095943/8.0), + REAL_CONST(61304.440186757645/8.0), + REAL_CONST(61325.421385448557/8.0), + REAL_CONST(61346.404378861582/8.0), + REAL_CONST(61367.389166689762/8.0), + REAL_CONST(61388.375748626262/8.0), + REAL_CONST(61409.364124364387/8.0), + REAL_CONST(61430.354293597571/8.0), + REAL_CONST(61451.346256019373/8.0), + REAL_CONST(61472.340011323497/8.0), + REAL_CONST(61493.335559203762/8.0), + REAL_CONST(61514.332899354122/8.0), + REAL_CONST(61535.332031468672/8.0), + REAL_CONST(61556.332955241618/8.0), + REAL_CONST(61577.335670367313/8.0), + REAL_CONST(61598.340176540238/8.0), + REAL_CONST(61619.346473454993/8.0), + REAL_CONST(61640.354560806329/8.0), + REAL_CONST(61661.3644382891/8.0), + REAL_CONST(61682.376105598312/8.0), + REAL_CONST(61703.389562429089/8.0), + REAL_CONST(61724.404808476691/8.0), + REAL_CONST(61745.42184343651/8.0), + REAL_CONST(61766.440667004063/8.0), + REAL_CONST(61787.461278874987/8.0), + REAL_CONST(61808.483678745069/8.0), + REAL_CONST(61829.507866310203/8.0), + REAL_CONST(61850.533841266435/8.0), + REAL_CONST(61871.561603309929/8.0), + REAL_CONST(61892.591152136971/8.0), + REAL_CONST(61913.622487443987/8.0), + REAL_CONST(61934.655608927525/8.0), + REAL_CONST(61955.690516284267/8.0), + REAL_CONST(61976.727209211022/8.0), + REAL_CONST(61997.765687404724/8.0), + REAL_CONST(62018.805950562448/8.0), + REAL_CONST(62039.847998381381/8.0), + REAL_CONST(62060.891830558845/8.0), + REAL_CONST(62081.93744679229/8.0), + REAL_CONST(62102.984846779298/8.0), + REAL_CONST(62124.034030217575/8.0), + REAL_CONST(62145.084996804966/8.0), + REAL_CONST(62166.137746239416/8.0), + REAL_CONST(62187.19227821903/8.0), + REAL_CONST(62208.248592442025/8.0), + REAL_CONST(62229.306688606739/8.0), + REAL_CONST(62250.366566411656/8.0), + REAL_CONST(62271.428225555377/8.0), + REAL_CONST(62292.491665736627/8.0), + REAL_CONST(62313.556886654267/8.0), + REAL_CONST(62334.623888007271/8.0), + REAL_CONST(62355.692669494762/8.0), + REAL_CONST(62376.763230815974/8.0), + REAL_CONST(62397.835571670272/8.0), + REAL_CONST(62418.909691757144/8.0), + REAL_CONST(62439.98559077621/8.0), + REAL_CONST(62461.063268427228/8.0), + REAL_CONST(62482.142724410049/8.0), + REAL_CONST(62503.223958424685/8.0), + REAL_CONST(62524.306970171267/8.0), + REAL_CONST(62545.39175935003/8.0), + REAL_CONST(62566.478325661366/8.0), + REAL_CONST(62587.566668805768/8.0), + REAL_CONST(62608.656788483881/8.0), + REAL_CONST(62629.748684396451/8.0), + REAL_CONST(62650.842356244357/8.0), + REAL_CONST(62671.937803728622/8.0), + REAL_CONST(62693.035026550366/8.0), + REAL_CONST(62714.134024410858/8.0), + REAL_CONST(62735.234797011479/8.0), + REAL_CONST(62756.337344053733/8.0), + REAL_CONST(62777.441665239276/8.0), + REAL_CONST(62798.547760269852/8.0), + REAL_CONST(62819.655628847358/8.0), + REAL_CONST(62840.765270673801/8.0), + REAL_CONST(62861.876685451323/8.0), + REAL_CONST(62882.989872882186/8.0), + REAL_CONST(62904.104832668774/8.0), + REAL_CONST(62925.221564513602/8.0), + REAL_CONST(62946.340068119309/8.0), + REAL_CONST(62967.460343188657/8.0), + REAL_CONST(62988.582389424526/8.0), + REAL_CONST(63009.70620652994/8.0), + REAL_CONST(63030.831794208025/8.0), + REAL_CONST(63051.959152162039/8.0), + REAL_CONST(63073.08828009537/8.0), + REAL_CONST(63094.219177711529/8.0), + REAL_CONST(63115.351844714154/8.0), + REAL_CONST(63136.486280806988/8.0), + REAL_CONST(63157.622485693922/8.0), + REAL_CONST(63178.760459078956/8.0), + REAL_CONST(63199.900200666219/8.0), + REAL_CONST(63221.041710159967/8.0), + REAL_CONST(63242.184987264569/8.0), + REAL_CONST(63263.330031684534/8.0), + REAL_CONST(63284.476843124474/8.0), + REAL_CONST(63305.625421289144/8.0), + REAL_CONST(63326.775765883409/8.0), + REAL_CONST(63347.927876612259/8.0), + REAL_CONST(63369.081753180813/8.0), + REAL_CONST(63390.237395294316/8.0), + REAL_CONST(63411.39480265812/8.0), + REAL_CONST(63432.553974977716/8.0), + REAL_CONST(63453.714911958712/8.0), + REAL_CONST(63474.877613306839/8.0), + REAL_CONST(63496.042078727944/8.0), + REAL_CONST(63517.208307927998/8.0), + REAL_CONST(63538.376300613119/8.0), + REAL_CONST(63559.546056489504/8.0), + REAL_CONST(63580.717575263516/8.0), + REAL_CONST(63601.890856641607/8.0), + REAL_CONST(63623.065900330374/8.0), + REAL_CONST(63644.242706036515/8.0), + REAL_CONST(63665.421273466869/8.0), + REAL_CONST(63686.601602328381/8.0), + REAL_CONST(63707.783692328136/8.0), + REAL_CONST(63728.967543173334/8.0), + REAL_CONST(63750.153154571279/8.0), + REAL_CONST(63771.340526229418/8.0), + REAL_CONST(63792.529657855317/8.0), + REAL_CONST(63813.720549156649/8.0), + REAL_CONST(63834.913199841227/8.0), + REAL_CONST(63856.107609616978/8.0), + REAL_CONST(63877.303778191941/8.0), + REAL_CONST(63898.501705274284/8.0), + REAL_CONST(63919.7013905723/8.0), + REAL_CONST(63940.902833794404/8.0), + REAL_CONST(63962.106034649114/8.0), + REAL_CONST(63983.310992845094/8.0), + REAL_CONST(64004.517708091109/8.0), + REAL_CONST(64025.726180096048/8.0), + REAL_CONST(64046.936408568938/8.0), + REAL_CONST(64068.1483932189/8.0), + REAL_CONST(64089.362133755196/8.0), + REAL_CONST(64110.577629887193/8.0), + REAL_CONST(64131.794881324393/8.0), + REAL_CONST(64153.013887776404/8.0), + REAL_CONST(64174.234648952966/8.0), + REAL_CONST(64195.457164563937/8.0), + REAL_CONST(64216.681434319289/8.0), + REAL_CONST(64237.907457929112/8.0), + REAL_CONST(64259.135235103626/8.0), + REAL_CONST(64280.36476555316/8.0), + REAL_CONST(64301.596048988169/8.0), + REAL_CONST(64322.829085119236/8.0), + REAL_CONST(64344.06387365704/8.0), + REAL_CONST(64365.300414312398/8.0), + REAL_CONST(64386.538706796251/8.0), + REAL_CONST(64407.778750819634/8.0), + REAL_CONST(64429.020546093721/8.0), + REAL_CONST(64450.26409232981/8.0), + REAL_CONST(64471.509389239291/8.0), + REAL_CONST(64492.756436533709/8.0), + REAL_CONST(64514.005233924705/8.0), + REAL_CONST(64535.255781124033/8.0), + REAL_CONST(64556.50807784358/8.0), + REAL_CONST(64577.762123795357/8.0), + REAL_CONST(64599.017918691468/8.0), + REAL_CONST(64620.275462244172/8.0), + REAL_CONST(64641.534754165805/8.0), + REAL_CONST(64662.795794168844/8.0), + REAL_CONST(64684.058581965895/8.0), + REAL_CONST(64705.323117269661/8.0), + REAL_CONST(64726.589399792974/8.0), + REAL_CONST(64747.857429248776/8.0), + REAL_CONST(64769.127205350138/8.0), + REAL_CONST(64790.398727810236/8.0), + REAL_CONST(64811.671996342375/8.0), + REAL_CONST(64832.947010659969/8.0), + REAL_CONST(64854.223770476558/8.0), + REAL_CONST(64875.502275505794/8.0), + REAL_CONST(64896.782525461451/8.0), + REAL_CONST(64918.064520057414/8.0), + REAL_CONST(64939.348259007682/8.0), + REAL_CONST(64960.633742026388/8.0), + REAL_CONST(64981.920968827762/8.0), + REAL_CONST(65003.209939126165/8.0), + REAL_CONST(65024.500652636067/8.0), + REAL_CONST(65045.793109072067/8.0), + REAL_CONST(65067.087308148861/8.0), + REAL_CONST(65088.383249581282/8.0), + REAL_CONST(65109.680933084259/8.0), + REAL_CONST(65130.980358372864/8.0), + REAL_CONST(65152.28152516226/8.0), + REAL_CONST(65173.584433167736/8.0), + REAL_CONST(65194.889082104703/8.0), + REAL_CONST(65216.195471688683/8.0), + REAL_CONST(65237.503601635319/8.0), + REAL_CONST(65258.813471660353/8.0), + REAL_CONST(65280.125081479666/8.0), + REAL_CONST(65301.438430809241/8.0), + REAL_CONST(65322.753519365178/8.0), + REAL_CONST(65344.070346863708/8.0), + REAL_CONST(65365.388913021146/8.0), + REAL_CONST(65386.709217553958/8.0), + REAL_CONST(65408.031260178701/8.0), + REAL_CONST(65429.355040612056/8.0), + REAL_CONST(65450.680558570821/8.0), + REAL_CONST(65472.00781377191/8.0), + REAL_CONST(65493.336805932355/8.0), + REAL_CONST(65514.66753476928/8.0), + REAL_CONST(65535.999999999956/8.0), + REAL_CONST(65557.334201341757/8.0), + REAL_CONST(65578.670138512171/8.0), + REAL_CONST(65600.007811228788/8.0), + REAL_CONST(65621.347219209332/8.0), + REAL_CONST(65642.688362171626/8.0), + REAL_CONST(65664.031239833639/8.0), + REAL_CONST(65685.375851913413/8.0), + REAL_CONST(65706.722198129137/8.0), + REAL_CONST(65728.070278199084/8.0), + REAL_CONST(65749.420091841661/8.0), + REAL_CONST(65770.771638775404/8.0), + REAL_CONST(65792.124918718939/8.0), + REAL_CONST(65813.479931391004/8.0), + REAL_CONST(65834.836676510458/8.0), + REAL_CONST(65856.195153796303/8.0), + REAL_CONST(65877.5553629676/8.0), + REAL_CONST(65898.917303743554/8.0), + REAL_CONST(65920.280975843489/8.0), + REAL_CONST(65941.646378986843/8.0), + REAL_CONST(65963.013512893158/8.0), + REAL_CONST(65984.382377282076/8.0), + REAL_CONST(66005.752971873386/8.0), + REAL_CONST(66027.125296386963/8.0), + REAL_CONST(66048.499350542799/8.0), + REAL_CONST(66069.875134061018/8.0), + REAL_CONST(66091.252646661844/8.0), + REAL_CONST(66112.631888065618/8.0), + REAL_CONST(66134.01285799277/8.0), + REAL_CONST(66155.395556163887/8.0), + REAL_CONST(66176.779982299631/8.0), + REAL_CONST(66198.166136120795/8.0), + REAL_CONST(66219.554017348273/8.0), + REAL_CONST(66240.943625703105/8.0), + REAL_CONST(66262.334960906388/8.0), + REAL_CONST(66283.728022679396/8.0), + REAL_CONST(66305.122810743444/8.0), + REAL_CONST(66326.519324820023/8.0), + REAL_CONST(66347.917564630698/8.0), + REAL_CONST(66369.317529897162/8.0), + REAL_CONST(66390.719220341227/8.0), + REAL_CONST(66412.122635684791/8.0), + REAL_CONST(66433.527775649884/8.0), + REAL_CONST(66454.934639958636/8.0), + REAL_CONST(66476.343228333324/8.0), + REAL_CONST(66497.753540496284/8.0), + REAL_CONST(66519.165576169995/8.0), + REAL_CONST(66540.57933507704/8.0), + REAL_CONST(66561.994816940118/8.0), + REAL_CONST(66583.412021482043/8.0), + REAL_CONST(66604.830948425733/8.0), + REAL_CONST(66626.251597494222/8.0), + REAL_CONST(66647.673968410629/8.0), + REAL_CONST(66669.098060898235/8.0), + REAL_CONST(66690.523874680381/8.0), + REAL_CONST(66711.951409480564/8.0), + REAL_CONST(66733.380665022371/8.0), + REAL_CONST(66754.811641029475/8.0), + REAL_CONST(66776.244337225711/8.0), + REAL_CONST(66797.678753334985/8.0), + REAL_CONST(66819.11488908132/8.0), + REAL_CONST(66840.552744188884/8.0), + REAL_CONST(66861.992318381905/8.0), + REAL_CONST(66883.433611384738/8.0), + REAL_CONST(66904.876622921889/8.0), + REAL_CONST(66926.321352717903/8.0), + REAL_CONST(66947.767800497502/8.0), + REAL_CONST(66969.215965985466/8.0), + REAL_CONST(66990.665848906734/8.0), + REAL_CONST(67012.117448986304/8.0), + REAL_CONST(67033.570765949335/8.0), + REAL_CONST(67055.025799521056/8.0), + REAL_CONST(67076.482549426815/8.0), + REAL_CONST(67097.941015392076/8.0), + REAL_CONST(67119.401197142433/8.0), + REAL_CONST(67140.863094403554/8.0), + REAL_CONST(67162.326706901222/8.0), + REAL_CONST(67183.792034361351/8.0), + REAL_CONST(67205.259076509959/8.0), + REAL_CONST(67226.72783307315/8.0), + REAL_CONST(67248.198303777172/8.0), + REAL_CONST(67269.670488348347/8.0), + REAL_CONST(67291.144386513144/8.0), + REAL_CONST(67312.619997998088/8.0), + REAL_CONST(67334.09732252988/8.0), + REAL_CONST(67355.576359835293/8.0), + REAL_CONST(67377.057109641188/8.0), + REAL_CONST(67398.53957167457/8.0), + REAL_CONST(67420.023745662547/8.0), + REAL_CONST(67441.50963133233/8.0), + REAL_CONST(67462.99722841123/8.0), + REAL_CONST(67484.486536626689/8.0), + REAL_CONST(67505.977555706224/8.0), + REAL_CONST(67527.470285377494/8.0), + REAL_CONST(67548.964725368263/8.0), + REAL_CONST(67570.460875406367/8.0), + REAL_CONST(67591.9587352198/8.0), + REAL_CONST(67613.458304536631/8.0), + REAL_CONST(67634.95958308503/8.0), + REAL_CONST(67656.462570593329/8.0), + REAL_CONST(67677.967266789899/8.0), + REAL_CONST(67699.473671403248/8.0), + REAL_CONST(67720.981784162024/8.0), + REAL_CONST(67742.491604794923/8.0), + REAL_CONST(67764.003133030797/8.0), + REAL_CONST(67785.516368598575/8.0), + REAL_CONST(67807.031311227314/8.0), + REAL_CONST(67828.547960646174/8.0), + REAL_CONST(67850.066316584402/8.0), + REAL_CONST(67871.58637877139/8.0), + REAL_CONST(67893.108146936589/8.0), + REAL_CONST(67914.63162080961/8.0), + REAL_CONST(67936.156800120138/8.0), + REAL_CONST(67957.683684597971/8.0), + REAL_CONST(67979.212273973011/8.0), + REAL_CONST(68000.742567975263/8.0), + REAL_CONST(68022.274566334876/8.0), + REAL_CONST(68043.808268782057/8.0), + REAL_CONST(68065.343675047145/8.0), + REAL_CONST(68086.880784860579/8.0), + REAL_CONST(68108.419597952918/8.0), + REAL_CONST(68129.960114054789/8.0), + REAL_CONST(68151.502332896969/8.0), + REAL_CONST(68173.04625421032/8.0), + REAL_CONST(68194.591877725834/8.0), + REAL_CONST(68216.139203174564/8.0), + REAL_CONST(68237.688230287706/8.0), + REAL_CONST(68259.238958796544/8.0), + REAL_CONST(68280.791388432481/8.0), + REAL_CONST(68302.345518927032/8.0), + REAL_CONST(68323.901350011787/8.0), + REAL_CONST(68345.458881418483/8.0), + REAL_CONST(68367.018112878912/8.0), + REAL_CONST(68388.579044125028/8.0), + REAL_CONST(68410.141674888844/8.0), + REAL_CONST(68431.706004902502/8.0), + REAL_CONST(68453.272033898262/8.0), + REAL_CONST(68474.839761608455/8.0), + REAL_CONST(68496.409187765545/8.0), + REAL_CONST(68517.980312102081/8.0), + REAL_CONST(68539.553134350732/8.0), + REAL_CONST(68561.127654244279/8.0), + REAL_CONST(68582.70387151558/8.0), + REAL_CONST(68604.281785897634/8.0), + REAL_CONST(68625.861397123503/8.0), + REAL_CONST(68647.44270492639/8.0), + REAL_CONST(68669.025709039604/8.0), + REAL_CONST(68690.610409196524/8.0), + REAL_CONST(68712.196805130661/8.0), + REAL_CONST(68733.784896575627/8.0), + REAL_CONST(68755.374683265123/8.0), + REAL_CONST(68776.966164932994/8.0), + REAL_CONST(68798.559341313128/8.0), + REAL_CONST(68820.154212139591/8.0), + REAL_CONST(68841.750777146473/8.0), + REAL_CONST(68863.349036068044/8.0), + REAL_CONST(68884.948988638629/8.0), + REAL_CONST(68906.550634592684/8.0), + REAL_CONST(68928.153973664739/8.0), + REAL_CONST(68949.75900558944/8.0), + REAL_CONST(68971.365730101577/8.0), + REAL_CONST(68992.974146935987/8.0), + REAL_CONST(69014.584255827634/8.0), + REAL_CONST(69036.196056511588/8.0), + REAL_CONST(69057.809548723017/8.0), + REAL_CONST(69079.424732197207/8.0), + REAL_CONST(69101.041606669532/8.0), + REAL_CONST(69122.660171875468/8.0), + REAL_CONST(69144.280427550606/8.0), + REAL_CONST(69165.902373430625/8.0), + REAL_CONST(69187.526009251334/8.0), + REAL_CONST(69209.151334748618/8.0), + REAL_CONST(69230.778349658474/8.0), + REAL_CONST(69252.40705371699/8.0), + REAL_CONST(69274.037446660412/8.0), + REAL_CONST(69295.669528225/8.0), + REAL_CONST(69317.303298147192/8.0), + REAL_CONST(69338.938756163494/8.0), + REAL_CONST(69360.575902010532/8.0), + REAL_CONST(69382.214735425005/8.0), + REAL_CONST(69403.855256143754/8.0), + REAL_CONST(69425.497463903681/8.0), + REAL_CONST(69447.141358441833/8.0), + REAL_CONST(69468.78693949533/8.0), + REAL_CONST(69490.434206801394/8.0), + REAL_CONST(69512.083160097391/8.0), + REAL_CONST(69533.733799120717/8.0), + REAL_CONST(69555.386123608929/8.0), + REAL_CONST(69577.04013329967/8.0), + REAL_CONST(69598.695827930685/8.0), + REAL_CONST(69620.353207239794/8.0), + REAL_CONST(69642.012270964973/8.0), + REAL_CONST(69663.67301884426/8.0), + REAL_CONST(69685.335450615792/8.0), + REAL_CONST(69706.999566017839/8.0), + REAL_CONST(69728.665364788743/8.0), + REAL_CONST(69750.332846666963/8.0), + REAL_CONST(69772.002011391058/8.0), + REAL_CONST(69793.672858699691/8.0), + REAL_CONST(69815.345388331611/8.0), + REAL_CONST(69837.019600025669/8.0), + REAL_CONST(69858.695493520849/8.0), + REAL_CONST(69880.373068556204/8.0), + REAL_CONST(69902.052324870907/8.0), + REAL_CONST(69923.733262204216/8.0), + REAL_CONST(69945.415880295492/8.0), + REAL_CONST(69967.100178884211/8.0), + REAL_CONST(69988.786157709939/8.0), + REAL_CONST(70010.473816512356/8.0), + REAL_CONST(70032.163155031216/8.0), + REAL_CONST(70053.854173006403/8.0), + REAL_CONST(70075.546870177874/8.0), + REAL_CONST(70097.241246285717/8.0), + REAL_CONST(70118.937301070109/8.0), + REAL_CONST(70140.635034271298/8.0), + REAL_CONST(70162.334445629691/8.0), + REAL_CONST(70184.035534885741/8.0), + REAL_CONST(70205.738301780017/8.0), + REAL_CONST(70227.442746053217/8.0), + REAL_CONST(70249.1488674461/8.0), + REAL_CONST(70270.856665699539/8.0), + REAL_CONST(70292.566140554511/8.0), + REAL_CONST(70314.277291752107/8.0), + REAL_CONST(70335.990119033493/8.0), + REAL_CONST(70357.704622139936/8.0), + REAL_CONST(70379.420800812819/8.0), + REAL_CONST(70401.138654793613/8.0), + REAL_CONST(70422.85818382389/8.0), + REAL_CONST(70444.579387645339/8.0), + REAL_CONST(70466.302265999722/8.0), + REAL_CONST(70488.026818628918/8.0), + REAL_CONST(70509.753045274876/8.0), + REAL_CONST(70531.480945679708/8.0), + REAL_CONST(70553.210519585555/8.0), + REAL_CONST(70574.941766734701/8.0), + REAL_CONST(70596.674686869505/8.0), + REAL_CONST(70618.409279732456/8.0), + REAL_CONST(70640.145545066101/8.0), + REAL_CONST(70661.883482613106/8.0), + REAL_CONST(70683.623092116264/8.0), + REAL_CONST(70705.364373318414/8.0), + REAL_CONST(70727.107325962526/8.0), + REAL_CONST(70748.851949791671/8.0), + REAL_CONST(70770.598244549008/8.0), + REAL_CONST(70792.346209977783/8.0), + REAL_CONST(70814.095845821372/8.0), + REAL_CONST(70835.847151823225/8.0), + REAL_CONST(70857.600127726895/8.0), + REAL_CONST(70879.354773276034/8.0), + REAL_CONST(70901.111088214413/8.0), + REAL_CONST(70922.869072285859/8.0), + REAL_CONST(70944.628725234332/8.0), + REAL_CONST(70966.390046803877/8.0), + REAL_CONST(70988.153036738629/8.0), + REAL_CONST(71009.917694782853/8.0), + REAL_CONST(71031.684020680885/8.0), + REAL_CONST(71053.45201417715/8.0), + REAL_CONST(71075.221675016204/8.0), + REAL_CONST(71096.993002942661/8.0), + REAL_CONST(71118.765997701266/8.0), + REAL_CONST(71140.540659036851/8.0), + REAL_CONST(71162.316986694335/8.0), + REAL_CONST(71184.09498041874/8.0), + REAL_CONST(71205.874639955218/8.0), + REAL_CONST(71227.655965048951/8.0), + REAL_CONST(71249.438955445294/8.0), + REAL_CONST(71271.223610889632/8.0), + REAL_CONST(71293.009931127483/8.0), + REAL_CONST(71314.797915904477/8.0), + REAL_CONST(71336.587564966307/8.0), + REAL_CONST(71358.378878058764/8.0), + REAL_CONST(71380.171854927772/8.0), + REAL_CONST(71401.966495319313/8.0), + REAL_CONST(71423.762798979486/8.0), + REAL_CONST(71445.560765654489/8.0), + REAL_CONST(71467.360395090596/8.0), + REAL_CONST(71489.161687034211/8.0), + REAL_CONST(71510.964641231811/8.0), + REAL_CONST(71532.769257429973/8.0), + REAL_CONST(71554.575535375348/8.0), + REAL_CONST(71576.383474814749/8.0), + REAL_CONST(71598.19307549503/8.0), + REAL_CONST(71620.004337163133/8.0), + REAL_CONST(71641.817259566145/8.0), + REAL_CONST(71663.631842451214/8.0), + REAL_CONST(71685.4480855656/8.0), + REAL_CONST(71707.26598865664/8.0), + REAL_CONST(71729.085551471784/8.0), + REAL_CONST(71750.906773758586/8.0), + REAL_CONST(71772.729655264673/8.0), + REAL_CONST(71794.554195737772/8.0), + REAL_CONST(71816.380394925713/8.0), + REAL_CONST(71838.208252576442/8.0), + REAL_CONST(71860.037768437964/8.0), + REAL_CONST(71881.868942258385/8.0), + REAL_CONST(71903.701773785942/8.0), + REAL_CONST(71925.536262768932/8.0), + REAL_CONST(71947.372408955751/8.0), + REAL_CONST(71969.210212094898/8.0), + REAL_CONST(71991.049671934976/8.0), + REAL_CONST(72012.890788224686/8.0), + REAL_CONST(72034.73356071279/8.0), + REAL_CONST(72056.577989148165/8.0), + REAL_CONST(72078.424073279821/8.0), + REAL_CONST(72100.271812856794/8.0), + REAL_CONST(72122.121207628254/8.0), + REAL_CONST(72143.97225734347/8.0), + REAL_CONST(72165.824961751801/8.0), + REAL_CONST(72187.679320602692/8.0), + REAL_CONST(72209.53533364569/8.0), + REAL_CONST(72231.393000630429/8.0), + REAL_CONST(72253.252321306645/8.0), + REAL_CONST(72275.113295424177/8.0), + REAL_CONST(72296.975922732949/8.0), + REAL_CONST(72318.840202982959/8.0), + REAL_CONST(72340.706135924338/8.0), + REAL_CONST(72362.573721307272/8.0), + REAL_CONST(72384.442958882093/8.0), + REAL_CONST(72406.313848399179/8.0), + REAL_CONST(72428.186389609036/8.0), + REAL_CONST(72450.060582262216/8.0), + REAL_CONST(72471.936426109431/8.0), + REAL_CONST(72493.813920901433/8.0), + REAL_CONST(72515.693066389096/8.0), + REAL_CONST(72537.573862323392/8.0), + REAL_CONST(72559.456308455352/8.0), + REAL_CONST(72581.340404536139/8.0), + REAL_CONST(72603.226150316987/8.0), + REAL_CONST(72625.113545549248/8.0), + REAL_CONST(72647.002589984331/8.0), + REAL_CONST(72668.893283373764/8.0), + REAL_CONST(72690.785625469172/8.0), + REAL_CONST(72712.679616022273/8.0), + REAL_CONST(72734.575254784853/8.0), + REAL_CONST(72756.472541508803/8.0), + REAL_CONST(72778.371475946144/8.0), + REAL_CONST(72800.272057848939/8.0), + REAL_CONST(72822.174286969355/8.0), + REAL_CONST(72844.07816305969/8.0), + REAL_CONST(72865.983685872285/8.0), + REAL_CONST(72887.890855159596/8.0), + REAL_CONST(72909.799670674183/8.0), + REAL_CONST(72931.710132168693/8.0), + REAL_CONST(72953.622239395845/8.0), + REAL_CONST(72975.535992108475/8.0), + REAL_CONST(72997.451390059519/8.0), + REAL_CONST(73019.368433001961/8.0), + REAL_CONST(73041.287120688925/8.0), + REAL_CONST(73063.207452873612/8.0), + REAL_CONST(73085.129429309294/8.0), + REAL_CONST(73107.053049749389/8.0), + REAL_CONST(73128.978313947344/8.0), + REAL_CONST(73150.905221656736/8.0), + REAL_CONST(73172.833772631217/8.0), + REAL_CONST(73194.763966624567/8.0), + REAL_CONST(73216.695803390612/8.0), + REAL_CONST(73238.62928268328/8.0), + REAL_CONST(73260.564404256627/8.0), + REAL_CONST(73282.501167864757/8.0), + REAL_CONST(73304.439573261901/8.0), + REAL_CONST(73326.379620202337/8.0), + REAL_CONST(73348.321308440485/8.0), + REAL_CONST(73370.264637730841/8.0), + REAL_CONST(73392.209607827957/8.0), + REAL_CONST(73414.156218486532/8.0), + REAL_CONST(73436.104469461323/8.0), + REAL_CONST(73458.054360507173/8.0), + REAL_CONST(73480.005891379056/8.0), + REAL_CONST(73501.959061831993/8.0), + REAL_CONST(73523.913871621116/8.0), + REAL_CONST(73545.870320501665/8.0), + REAL_CONST(73567.828408228932/8.0), + REAL_CONST(73589.78813455833/8.0), + REAL_CONST(73611.749499245358/8.0), + REAL_CONST(73633.712502045615/8.0), + REAL_CONST(73655.677142714747/8.0), + REAL_CONST(73677.643421008557/8.0), + REAL_CONST(73699.611336682879/8.0), + REAL_CONST(73721.580889493693/8.0), + REAL_CONST(73743.552079197019/8.0), + REAL_CONST(73765.524905548999/8.0), + REAL_CONST(73787.499368305856/8.0), + REAL_CONST(73809.475467223907/8.0), + REAL_CONST(73831.453202059551/8.0), + REAL_CONST(73853.432572569291/8.0), + REAL_CONST(73875.413578509717/8.0), + REAL_CONST(73897.396219637507/8.0), + REAL_CONST(73919.380495709411/8.0), + REAL_CONST(73941.36640648231/8.0), + REAL_CONST(73963.353951713143/8.0), + REAL_CONST(73985.343131158952/8.0), + REAL_CONST(74007.333944576865/8.0), + REAL_CONST(74029.326391724098/8.0), + REAL_CONST(74051.320472357969/8.0), + REAL_CONST(74073.316186235883/8.0), + REAL_CONST(74095.313533115303/8.0), + REAL_CONST(74117.312512753837/8.0), + REAL_CONST(74139.313124909138/8.0), + REAL_CONST(74161.315369338976/8.0), + REAL_CONST(74183.319245801191/8.0), + REAL_CONST(74205.324754053727/8.0), + REAL_CONST(74227.331893854629/8.0), + REAL_CONST(74249.340664961986/8.0), + REAL_CONST(74271.351067134034/8.0), + REAL_CONST(74293.363100129049/8.0), + REAL_CONST(74315.376763705441/8.0), + REAL_CONST(74337.392057621662/8.0), + REAL_CONST(74359.408981636298/8.0), + REAL_CONST(74381.427535508003/8.0), + REAL_CONST(74403.447718995507/8.0), + REAL_CONST(74425.469531857671/8.0), + REAL_CONST(74447.492973853383/8.0), + REAL_CONST(74469.518044741693/8.0), + REAL_CONST(74491.54474428168/8.0), + REAL_CONST(74513.573072232539/8.0), + REAL_CONST(74535.603028353551/8.0), + REAL_CONST(74557.634612404087/8.0), + REAL_CONST(74579.667824143602/8.0), + REAL_CONST(74601.702663331642/8.0), + REAL_CONST(74623.739129727837/8.0), + REAL_CONST(74645.777223091936/8.0), + REAL_CONST(74667.816943183716/8.0), + REAL_CONST(74689.858289763113/8.0), + REAL_CONST(74711.901262590094/8.0), + REAL_CONST(74733.945861424741/8.0), + REAL_CONST(74755.992086027225/8.0), + REAL_CONST(74778.039936157802/8.0), + REAL_CONST(74800.089411576817/8.0), + REAL_CONST(74822.140512044702/8.0), + REAL_CONST(74844.193237321961/8.0), + REAL_CONST(74866.24758716923/8.0), + REAL_CONST(74888.303561347187/8.0), + REAL_CONST(74910.36115961663/8.0), + REAL_CONST(74932.420381738411/8.0), + REAL_CONST(74954.481227473516/8.0), + REAL_CONST(74976.543696582972/8.0), + REAL_CONST(74998.607788827925/8.0), + REAL_CONST(75020.673503969607/8.0), + REAL_CONST(75042.740841769322/8.0), + REAL_CONST(75064.809801988464/8.0), + REAL_CONST(75086.88038438854/8.0), + REAL_CONST(75108.952588731103/8.0), + REAL_CONST(75131.026414777836/8.0), + REAL_CONST(75153.101862290467/8.0), + REAL_CONST(75175.178931030852/8.0), + REAL_CONST(75197.257620760924/8.0), + REAL_CONST(75219.33793124267/8.0), + REAL_CONST(75241.419862238225/8.0), + REAL_CONST(75263.503413509738/8.0), + REAL_CONST(75285.588584819503/8.0), + REAL_CONST(75307.675375929874/8.0), + REAL_CONST(75329.763786603318/8.0), + REAL_CONST(75351.853816602365/8.0), + REAL_CONST(75373.945465689612/8.0), + REAL_CONST(75396.038733627807/8.0), + REAL_CONST(75418.133620179724/8.0), + REAL_CONST(75440.230125108254/8.0), + REAL_CONST(75462.32824817636/8.0), + REAL_CONST(75484.427989147109/8.0), + REAL_CONST(75506.529347783653/8.0), + REAL_CONST(75528.63232384919/8.0), + REAL_CONST(75550.736917107075/8.0), + REAL_CONST(75572.843127320695/8.0), + REAL_CONST(75594.950954253538/8.0), + REAL_CONST(75617.060397669193/8.0), + REAL_CONST(75639.171457331307/8.0), + REAL_CONST(75661.284133003646/8.0), + REAL_CONST(75683.398424450032/8.0), + REAL_CONST(75705.514331434402/8.0), + REAL_CONST(75727.631853720741/8.0), + REAL_CONST(75749.750991073175/8.0), + REAL_CONST(75771.871743255862/8.0), + REAL_CONST(75793.994110033076/8.0), + REAL_CONST(75816.118091169177/8.0), + REAL_CONST(75838.243686428585/8.0), + REAL_CONST(75860.370895575848/8.0), + REAL_CONST(75882.499718375562/8.0), + REAL_CONST(75904.630154592422/8.0), + REAL_CONST(75926.762203991224/8.0), + REAL_CONST(75948.895866336825/8.0), + REAL_CONST(75971.031141394182/8.0), + REAL_CONST(75993.168028928325/8.0), + REAL_CONST(76015.306528704401/8.0), + REAL_CONST(76037.4466404876/8.0), + REAL_CONST(76059.588364043215/8.0), + REAL_CONST(76081.731699136653/8.0), + REAL_CONST(76103.876645533353/8.0), + REAL_CONST(76126.023202998884/8.0), + REAL_CONST(76148.171371298871/8.0), + REAL_CONST(76170.321150199044/8.0), + REAL_CONST(76192.472539465205/8.0), + REAL_CONST(76214.625538863256/8.0), + REAL_CONST(76236.780148159174/8.0), + REAL_CONST(76258.936367119008/8.0), + REAL_CONST(76281.094195508922/8.0), + REAL_CONST(76303.253633095141/8.0), + REAL_CONST(76325.414679643975/8.0), + REAL_CONST(76347.577334921851/8.0), + REAL_CONST(76369.741598695226/8.0), + REAL_CONST(76391.907470730686/8.0), + REAL_CONST(76414.074950794879/8.0), + REAL_CONST(76436.244038654564/8.0), + REAL_CONST(76458.414734076548/8.0), + REAL_CONST(76480.587036827754/8.0), + REAL_CONST(76502.760946675175/8.0), + REAL_CONST(76524.936463385893/8.0), + REAL_CONST(76547.11358672705/8.0), + REAL_CONST(76569.292316465915/8.0), + REAL_CONST(76591.472652369819/8.0), + REAL_CONST(76613.654594206164/8.0), + REAL_CONST(76635.838141742468/8.0), + REAL_CONST(76658.023294746308/8.0), + REAL_CONST(76680.210052985349/8.0), + REAL_CONST(76702.398416227341/8.0), + REAL_CONST(76724.588384240138/8.0), + REAL_CONST(76746.779956791637/8.0), + REAL_CONST(76768.973133649866/8.0), + REAL_CONST(76791.167914582897/8.0), + REAL_CONST(76813.364299358902/8.0), + REAL_CONST(76835.562287746157/8.0), + REAL_CONST(76857.761879512967/8.0), + REAL_CONST(76879.963074427797/8.0), + REAL_CONST(76902.165872259109/8.0), + REAL_CONST(76924.37027277553/8.0), + REAL_CONST(76946.576275745727/8.0), + REAL_CONST(76968.783880938441/8.0), + REAL_CONST(76990.993088122515/8.0), + REAL_CONST(77013.203897066895/8.0), + REAL_CONST(77035.416307540567/8.0), + REAL_CONST(77057.630319312622/8.0), + REAL_CONST(77079.845932152239/8.0), + REAL_CONST(77102.063145828695/8.0), + REAL_CONST(77124.281960111301/8.0), + REAL_CONST(77146.50237476948/8.0), + REAL_CONST(77168.724389572759/8.0), + REAL_CONST(77190.948004290723/8.0), + REAL_CONST(77213.173218693031/8.0), + REAL_CONST(77235.400032549442/8.0), + REAL_CONST(77257.628445629802/8.0), + REAL_CONST(77279.858457704031/8.0), + REAL_CONST(77302.090068542122/8.0), + REAL_CONST(77324.323277914169/8.0), + REAL_CONST(77346.558085590339/8.0), + REAL_CONST(77368.794491340886/8.0), + REAL_CONST(77391.032494936138/8.0), + REAL_CONST(77413.272096146524/8.0), + REAL_CONST(77435.51329474253/8.0), + REAL_CONST(77457.756090494731/8.0), + REAL_CONST(77480.000483173804/8.0), + REAL_CONST(77502.246472550498/8.0), + REAL_CONST(77524.494058395634/8.0), + REAL_CONST(77546.743240480107/8.0), + REAL_CONST(77568.994018574944/8.0), + REAL_CONST(77591.246392451198/8.0), + REAL_CONST(77613.500361880026/8.0), + REAL_CONST(77635.755926632657/8.0), + REAL_CONST(77658.013086480438/8.0), + REAL_CONST(77680.271841194757/8.0), + REAL_CONST(77702.532190547092/8.0), + REAL_CONST(77724.794134309021/8.0), + REAL_CONST(77747.057672252195/8.0), + REAL_CONST(77769.322804148323/8.0), + REAL_CONST(77791.589529769248/8.0), + REAL_CONST(77813.857848886837/8.0), + REAL_CONST(77836.127761273063/8.0), + REAL_CONST(77858.399266699998/8.0), + REAL_CONST(77880.67236493979/8.0), + REAL_CONST(77902.947055764627/8.0), + REAL_CONST(77925.223338946831/8.0), + REAL_CONST(77947.50121425878/8.0), + REAL_CONST(77969.780681472927/8.0), + REAL_CONST(77992.061740361838/8.0), + REAL_CONST(78014.344390698127/8.0), + REAL_CONST(78036.628632254491/8.0), + REAL_CONST(78058.914464803747/8.0), + REAL_CONST(78081.201888118725/8.0), + REAL_CONST(78103.490901972415/8.0), + REAL_CONST(78125.781506137821/8.0), + REAL_CONST(78148.073700388064/8.0), + REAL_CONST(78170.367484496339/8.0), + REAL_CONST(78192.662858235926/8.0), + REAL_CONST(78214.959821380166/8.0), + REAL_CONST(78237.258373702498/8.0), + REAL_CONST(78259.558514976452/8.0), + REAL_CONST(78281.860244975614/8.0), + REAL_CONST(78304.163563473659/8.0), + REAL_CONST(78326.468470244363/8.0), + REAL_CONST(78348.77496506153/8.0), + REAL_CONST(78371.083047699125/8.0), + REAL_CONST(78393.392717931114/8.0), + REAL_CONST(78415.703975531578/8.0), + REAL_CONST(78438.016820274701/8.0), + REAL_CONST(78460.331251934695/8.0), + REAL_CONST(78482.647270285903/8.0), + REAL_CONST(78504.964875102727/8.0), + REAL_CONST(78527.284066159627/8.0), + REAL_CONST(78549.604843231195/8.0), + REAL_CONST(78571.927206092048/8.0), + REAL_CONST(78594.251154516911/8.0), + REAL_CONST(78616.576688280606/8.0), + REAL_CONST(78638.903807157985/8.0), + REAL_CONST(78661.232510924034/8.0), + REAL_CONST(78683.562799353778/8.0), + REAL_CONST(78705.894672222363/8.0), + REAL_CONST(78728.228129304945/8.0), + REAL_CONST(78750.563170376859/8.0), + REAL_CONST(78772.899795213423/8.0), + REAL_CONST(78795.238003590101/8.0), + REAL_CONST(78817.577795282399/8.0), + REAL_CONST(78839.919170065928/8.0), + REAL_CONST(78862.262127716356/8.0), + REAL_CONST(78884.606668009452/8.0), + REAL_CONST(78906.952790721043/8.0), + REAL_CONST(78929.300495627045/8.0), + REAL_CONST(78951.64978250346/8.0), + REAL_CONST(78974.000651126378/8.0), + REAL_CONST(78996.353101271932/8.0), + REAL_CONST(79018.707132716358/8.0), + REAL_CONST(79041.062745235977/8.0), + REAL_CONST(79063.41993860717/8.0), + REAL_CONST(79085.778712606436/8.0), + REAL_CONST(79108.139067010285/8.0), + REAL_CONST(79130.501001595389/8.0), + REAL_CONST(79152.864516138419/8.0), + REAL_CONST(79175.22961041618/8.0), + REAL_CONST(79197.596284205531/8.0), + REAL_CONST(79219.96453728342/8.0), + REAL_CONST(79242.33436942687/8.0), + REAL_CONST(79264.705780412987/8.0), + REAL_CONST(79287.078770018954/8.0), + REAL_CONST(79309.453338022009/8.0), + REAL_CONST(79331.829484199508/8.0), + REAL_CONST(79354.207208328866/8.0), + REAL_CONST(79376.586510187582/8.0), + REAL_CONST(79398.967389553218/8.0), + REAL_CONST(79421.349846203433/8.0), + REAL_CONST(79443.733879915948/8.0), + REAL_CONST(79466.119490468584/8.0), + REAL_CONST(79488.50667763922/8.0), + REAL_CONST(79510.895441205823/8.0), + REAL_CONST(79533.285780946433/8.0), + REAL_CONST(79555.677696639163/8.0), + REAL_CONST(79578.071188062226/8.0), + REAL_CONST(79600.466254993895/8.0), + REAL_CONST(79622.862897212515/8.0), + REAL_CONST(79645.261114496549/8.0), + REAL_CONST(79667.660906624471/8.0), + REAL_CONST(79690.062273374875/8.0), + REAL_CONST(79712.465214526455/8.0), + REAL_CONST(79734.869729857935/8.0), + REAL_CONST(79757.275819148126/8.0), + REAL_CONST(79779.683482175955/8.0), + REAL_CONST(79802.092718720378/8.0), + REAL_CONST(79824.503528560454/8.0), + REAL_CONST(79846.915911475327/8.0), + REAL_CONST(79869.329867244203/8.0), + REAL_CONST(79891.745395646343/8.0), + REAL_CONST(79914.162496461155/8.0), + REAL_CONST(79936.581169468045/8.0), + REAL_CONST(79959.001414446553/8.0), + REAL_CONST(79981.423231176261/8.0), + REAL_CONST(80003.846619436852/8.0), + REAL_CONST(80026.271579008084/8.0), + REAL_CONST(80048.698109669771/8.0), + REAL_CONST(80071.12621120183/8.0), + REAL_CONST(80093.555883384237/8.0), + REAL_CONST(80115.987125997053/8.0), + REAL_CONST(80138.419938820414/8.0), + REAL_CONST(80160.854321634528/8.0), + REAL_CONST(80183.290274219689/8.0), + REAL_CONST(80205.727796356281/8.0), + REAL_CONST(80228.166887824715/8.0), + REAL_CONST(80250.607548405547/8.0), + REAL_CONST(80273.049777879336/8.0), + REAL_CONST(80295.493576026798/8.0), + REAL_CONST(80317.938942628651/8.0), + REAL_CONST(80340.385877465727/8.0), + REAL_CONST(80362.834380318949/8.0), + REAL_CONST(80385.28445096928/8.0), + REAL_CONST(80407.736089197788/8.0), + REAL_CONST(80430.189294785596/8.0), + REAL_CONST(80452.644067513917/8.0), + REAL_CONST(80475.100407164035/8.0), + REAL_CONST(80497.558313517322/8.0), + REAL_CONST(80520.017786355209/8.0), + REAL_CONST(80542.478825459213/8.0), + REAL_CONST(80564.941430610925/8.0), + REAL_CONST(80587.405601592007/8.0), + REAL_CONST(80609.871338184195/8.0), + REAL_CONST(80632.338640169342/8.0), + REAL_CONST(80654.8075073293/8.0), + REAL_CONST(80677.277939446067/8.0), + REAL_CONST(80699.749936301683/8.0), + REAL_CONST(80722.223497678278/8.0), + REAL_CONST(80744.698623358039/8.0), + REAL_CONST(80767.17531312324/8.0), + REAL_CONST(80789.653566756242/8.0), + REAL_CONST(80812.133384039465/8.0), + REAL_CONST(80834.614764755403/8.0), + REAL_CONST(80857.097708686648/8.0), + REAL_CONST(80879.582215615854/8.0), + REAL_CONST(80902.068285325731/8.0), + REAL_CONST(80924.555917599093/8.0), + REAL_CONST(80947.045112218824/8.0), + REAL_CONST(80969.535868967869/8.0), + REAL_CONST(80992.028187629272/8.0), + REAL_CONST(81014.522067986123/8.0), + REAL_CONST(81037.017509821613/8.0), + REAL_CONST(81059.514512919006/8.0), + REAL_CONST(81082.013077061609/8.0), + REAL_CONST(81104.513202032831/8.0), + REAL_CONST(81127.014887616184/8.0), + REAL_CONST(81149.518133595193/8.0), + REAL_CONST(81172.022939753486/8.0), + REAL_CONST(81194.529305874807/8.0), + REAL_CONST(81217.037231742899/8.0), + REAL_CONST(81239.546717141639/8.0), + REAL_CONST(81262.057761854958/8.0), + REAL_CONST(81284.570365666848/8.0), + REAL_CONST(81307.084528361403/8.0), + REAL_CONST(81329.600249722775/8.0), + REAL_CONST(81352.117529535186/8.0), + REAL_CONST(81374.636367582949/8.0), + REAL_CONST(81397.156763650448/8.0), + REAL_CONST(81419.678717522125/8.0), + REAL_CONST(81442.202228982511/8.0), + REAL_CONST(81464.727297816222/8.0), + REAL_CONST(81487.253923807933/8.0), + REAL_CONST(81509.782106742379/8.0), + REAL_CONST(81532.311846404409/8.0), + REAL_CONST(81554.843142578902/8.0), + REAL_CONST(81577.375995050839/8.0), + REAL_CONST(81599.910403605274/8.0), + REAL_CONST(81622.446368027333/8.0), + REAL_CONST(81644.983888102215/8.0), + REAL_CONST(81667.522963615178/8.0), + REAL_CONST(81690.063594351581/8.0), + REAL_CONST(81712.605780096841/8.0), + REAL_CONST(81735.149520636449/8.0), + REAL_CONST(81757.694815755967/8.0), + REAL_CONST(81780.241665241047/8.0), + REAL_CONST(81802.79006887741/8.0), + REAL_CONST(81825.340026450824/8.0), + REAL_CONST(81847.891537747171/8.0), + REAL_CONST(81870.444602552379/8.0), + REAL_CONST(81892.999220652477/8.0), + REAL_CONST(81915.555391833506/8.0), + REAL_CONST(81938.113115881672/8.0), + REAL_CONST(81960.672392583176/8.0), + REAL_CONST(81983.233221724338/8.0), + REAL_CONST(82005.795603091537/8.0), + REAL_CONST(82028.359536471224/8.0), + REAL_CONST(82050.925021649906/8.0), + REAL_CONST(82073.492058414209/8.0), + REAL_CONST(82096.060646550788/8.0), + REAL_CONST(82118.630785846399/8.0), + REAL_CONST(82141.202476087841/8.0), + REAL_CONST(82163.775717062032/8.0), + REAL_CONST(82186.35050855593/8.0), + REAL_CONST(82208.926850356569/8.0), + REAL_CONST(82231.504742251054/8.0), + REAL_CONST(82254.084184026578/8.0), + REAL_CONST(82276.665175470393/8.0), + REAL_CONST(82299.24771636985/8.0), + REAL_CONST(82321.831806512317/8.0), + REAL_CONST(82344.417445685307/8.0), + REAL_CONST(82367.004633676348/8.0), + REAL_CONST(82389.593370273054/8.0), + REAL_CONST(82412.183655263143/8.0), + REAL_CONST(82434.775488434374/8.0), + REAL_CONST(82457.368869574595/8.0), + REAL_CONST(82479.963798471697/8.0), + REAL_CONST(82502.560274913689/8.0), + REAL_CONST(82525.158298688606/8.0), + REAL_CONST(82547.757869584602/8.0), + REAL_CONST(82570.35898738986/8.0), + REAL_CONST(82592.961651892678/8.0), + REAL_CONST(82615.565862881398/8.0), + REAL_CONST(82638.171620144421/8.0), + REAL_CONST(82660.778923470265/8.0), + REAL_CONST(82683.387772647475/8.0), + REAL_CONST(82705.998167464713/8.0), + REAL_CONST(82728.610107710658/8.0), + REAL_CONST(82751.223593174116/8.0), + REAL_CONST(82773.83862364394/8.0), + REAL_CONST(82796.45519890904/8.0), + REAL_CONST(82819.073318758441/8.0), + REAL_CONST(82841.692982981185/8.0), + REAL_CONST(82864.314191366429/8.0), + REAL_CONST(82886.936943703375/8.0), + REAL_CONST(82909.561239781324/8.0), + REAL_CONST(82932.187079389638/8.0), + REAL_CONST(82954.814462317736/8.0), + REAL_CONST(82977.443388355125/8.0), + REAL_CONST(83000.073857291369/8.0), + REAL_CONST(83022.70586891612/8.0), + REAL_CONST(83045.339423019104/8.0), + REAL_CONST(83067.974519390089/8.0), + REAL_CONST(83090.611157818959/8.0), + REAL_CONST(83113.249338095629/8.0), + REAL_CONST(83135.8890600101/8.0), + REAL_CONST(83158.530323352461/8.0), + REAL_CONST(83181.173127912858/8.0), + REAL_CONST(83203.817473481497/8.0), + REAL_CONST(83226.463359848669/8.0), + REAL_CONST(83249.11078680474/8.0), + REAL_CONST(83271.759754140134/8.0), + REAL_CONST(83294.410261645375/8.0), + REAL_CONST(83317.062309111003/8.0), + REAL_CONST(83339.715896327703/8.0), + REAL_CONST(83362.371023086147/8.0), + REAL_CONST(83385.027689177165/8.0), + REAL_CONST(83407.685894391587/8.0), + REAL_CONST(83430.345638520361/8.0), + REAL_CONST(83453.006921354478/8.0), + REAL_CONST(83475.669742685001/8.0), + REAL_CONST(83498.334102303095/8.0), + REAL_CONST(83520.999999999942/8.0), + REAL_CONST(83543.667435566866/8.0), + REAL_CONST(83566.336408795192/8.0), + REAL_CONST(83589.006919476349/8.0), + REAL_CONST(83611.678967401851/8.0), + REAL_CONST(83634.352552363242/8.0), + REAL_CONST(83657.027674152167/8.0), + REAL_CONST(83679.704332560359/8.0), + REAL_CONST(83702.382527379552/8.0), + REAL_CONST(83725.062258401638/8.0), + REAL_CONST(83747.743525418511/8.0), + REAL_CONST(83770.42632822218/8.0), + REAL_CONST(83793.110666604684/8.0), + REAL_CONST(83815.796540358162/8.0), + REAL_CONST(83838.483949274829/8.0), + REAL_CONST(83861.172893146941/8.0), + REAL_CONST(83883.863371766842/8.0), + REAL_CONST(83906.555384926964/8.0), + REAL_CONST(83929.248932419752/8.0), + REAL_CONST(83951.944014037799/8.0), + REAL_CONST(83974.640629573696/8.0), + REAL_CONST(83997.338778820151/8.0), + REAL_CONST(84020.038461569929/8.0), + REAL_CONST(84042.739677615857/8.0), + REAL_CONST(84065.442426750829/8.0), + REAL_CONST(84088.146708767847/8.0), + REAL_CONST(84110.852523459922/8.0), + REAL_CONST(84133.559870620171/8.0), + REAL_CONST(84156.268750041796/8.0), + REAL_CONST(84178.979161518029/8.0), + REAL_CONST(84201.691104842204/8.0), + REAL_CONST(84224.404579807713/8.0), + REAL_CONST(84247.119586208006/8.0), + REAL_CONST(84269.83612383662/8.0), + REAL_CONST(84292.55419248715/8.0), + REAL_CONST(84315.273791953281/8.0), + REAL_CONST(84337.994922028738/8.0), + REAL_CONST(84360.717582507335/8.0), + REAL_CONST(84383.441773182945/8.0), + REAL_CONST(84406.167493849513/8.0), + REAL_CONST(84428.894744301069/8.0), + REAL_CONST(84451.623524331691/8.0), + REAL_CONST(84474.353833735542/8.0), + REAL_CONST(84497.085672306828/8.0), + REAL_CONST(84519.819039839858/8.0), + REAL_CONST(84542.553936128999/8.0), + REAL_CONST(84565.290360968676/8.0), + REAL_CONST(84588.028314153402/8.0), + REAL_CONST(84610.767795477717/8.0), + REAL_CONST(84633.508804736295/8.0), + REAL_CONST(84656.251341723822/8.0), + REAL_CONST(84678.995406235073/8.0), + REAL_CONST(84701.740998064924/8.0), + REAL_CONST(84724.488117008252/8.0), + REAL_CONST(84747.236762860062/8.0), + REAL_CONST(84769.986935415407/8.0), + REAL_CONST(84792.73863446941/8.0), + REAL_CONST(84815.491859817252/8.0), + REAL_CONST(84838.246611254188/8.0), + REAL_CONST(84861.002888575575/8.0), + REAL_CONST(84883.760691576768/8.0), + REAL_CONST(84906.520020053256/8.0), + REAL_CONST(84929.28087380057/8.0), + REAL_CONST(84952.043252614312/8.0), + REAL_CONST(84974.807156290146/8.0), + REAL_CONST(84997.572584623806/8.0), + REAL_CONST(85020.339537411113/8.0), + REAL_CONST(85043.108014447949/8.0), + REAL_CONST(85065.878015530237/8.0), + REAL_CONST(85088.649540453989/8.0), + REAL_CONST(85111.422589015303/8.0), + REAL_CONST(85134.197161010321/8.0), + REAL_CONST(85156.973256235244/8.0), + REAL_CONST(85179.750874486374/8.0), + REAL_CONST(85202.530015560071/8.0), + REAL_CONST(85225.310679252725/8.0), + REAL_CONST(85248.092865360857/8.0), + REAL_CONST(85270.876573681016/8.0), + REAL_CONST(85293.661804009811/8.0), + REAL_CONST(85316.448556143951/8.0), + REAL_CONST(85339.236829880188/8.0), + REAL_CONST(85362.026625015351/8.0), + REAL_CONST(85384.817941346351/8.0), + REAL_CONST(85407.610778670132/8.0), + REAL_CONST(85430.405136783724/8.0), + REAL_CONST(85453.201015484257/8.0), + REAL_CONST(85475.998414568865/8.0), + REAL_CONST(85498.797333834795/8.0), + REAL_CONST(85521.597773079353/8.0), + REAL_CONST(85544.399732099904/8.0), + REAL_CONST(85567.203210693886/8.0), + REAL_CONST(85590.008208658808/8.0), + REAL_CONST(85612.814725792239/8.0), + REAL_CONST(85635.62276189182/8.0), + REAL_CONST(85658.432316755265/8.0), + REAL_CONST(85681.243390180331/8.0), + REAL_CONST(85704.055981964877/8.0), + REAL_CONST(85726.870091906807/8.0), + REAL_CONST(85749.685719804082/8.0), + REAL_CONST(85772.502865454764/8.0), + REAL_CONST(85795.321528656961/8.0), + REAL_CONST(85818.141709208852/8.0), + REAL_CONST(85840.963406908675/8.0), + REAL_CONST(85863.78662155474/8.0), + REAL_CONST(85886.611352945445/8.0), + REAL_CONST(85909.437600879217/8.0), + REAL_CONST(85932.26536515457/8.0), + REAL_CONST(85955.094645570091/8.0), + REAL_CONST(85977.92544192441/8.0), + REAL_CONST(86000.757754016275/8.0), + REAL_CONST(86023.591581644432/8.0), + REAL_CONST(86046.426924607746/8.0), + REAL_CONST(86069.263782705122/8.0), + REAL_CONST(86092.102155735556/8.0), + REAL_CONST(86114.942043498071/8.0), + REAL_CONST(86137.783445791807/8.0), + REAL_CONST(86160.626362415918/8.0), + REAL_CONST(86183.470793169676/8.0), + REAL_CONST(86206.316737852379/8.0), + REAL_CONST(86229.164196263402/8.0), + REAL_CONST(86252.013168202204/8.0), + REAL_CONST(86274.863653468303/8.0), + REAL_CONST(86297.715651861261/8.0), + REAL_CONST(86320.569163180728/8.0), + REAL_CONST(86343.424187226425/8.0), + REAL_CONST(86366.280723798132/8.0), + REAL_CONST(86389.138772695675/8.0), + REAL_CONST(86411.998333718977/8.0), + REAL_CONST(86434.859406668009/8.0), + REAL_CONST(86457.721991342827/8.0), + REAL_CONST(86480.586087543532/8.0), + REAL_CONST(86503.451695070296/8.0), + REAL_CONST(86526.318813723352/8.0), + REAL_CONST(86549.187443303032/8.0), + REAL_CONST(86572.057583609683/8.0), + REAL_CONST(86594.929234443756/8.0), + REAL_CONST(86617.802395605773/8.0), + REAL_CONST(86640.677066896271/8.0), + REAL_CONST(86663.553248115903/8.0), + REAL_CONST(86686.43093906538/8.0), + REAL_CONST(86709.310139545443/8.0), + REAL_CONST(86732.190849356964/8.0), + REAL_CONST(86755.073068300815/8.0), + REAL_CONST(86777.956796177954/8.0), + REAL_CONST(86800.842032789442/8.0), + REAL_CONST(86823.728777936354/8.0), + REAL_CONST(86846.617031419853/8.0), + REAL_CONST(86869.506793041175/8.0), + REAL_CONST(86892.398062601613/8.0), + REAL_CONST(86915.290839902518/8.0), + REAL_CONST(86938.185124745316/8.0), + REAL_CONST(86961.080916931489/8.0), + REAL_CONST(86983.978216262592/8.0), + REAL_CONST(87006.87702254027/8.0), + REAL_CONST(87029.777335566177/8.0), + REAL_CONST(87052.67915514209/8.0), + REAL_CONST(87075.582481069796/8.0), + REAL_CONST(87098.487313151185/8.0), + REAL_CONST(87121.39365118822/8.0), + REAL_CONST(87144.301494982894/8.0), + REAL_CONST(87167.210844337285/8.0), + REAL_CONST(87190.121699053532/8.0), + REAL_CONST(87213.034058933845/8.0), + REAL_CONST(87235.947923780506/8.0), + REAL_CONST(87258.863293395829/8.0), + REAL_CONST(87281.780167582241/8.0), + REAL_CONST(87304.698546142172/8.0), + REAL_CONST(87327.618428878181/8.0), + REAL_CONST(87350.539815592856/8.0), + REAL_CONST(87373.462706088845/8.0), + REAL_CONST(87396.387100168897/8.0), + REAL_CONST(87419.312997635774/8.0), + REAL_CONST(87442.240398292357/8.0), + REAL_CONST(87465.16930194154/8.0), + REAL_CONST(87488.099708386319/8.0), + REAL_CONST(87511.031617429733/8.0), + REAL_CONST(87533.965028874911/8.0), + REAL_CONST(87556.899942525008/8.0), + REAL_CONST(87579.836358183282/8.0), + REAL_CONST(87602.774275653021/8.0), + REAL_CONST(87625.713694737613/8.0), + REAL_CONST(87648.654615240492/8.0), + REAL_CONST(87671.597036965148/8.0), + REAL_CONST(87694.540959715145/8.0), + REAL_CONST(87717.486383294105/8.0), + REAL_CONST(87740.433307505737/8.0), + REAL_CONST(87763.381732153779/8.0), + REAL_CONST(87786.331657042057/8.0), + REAL_CONST(87809.283081974456/8.0), + REAL_CONST(87832.236006754916/8.0), + REAL_CONST(87855.190431187453/8.0), + REAL_CONST(87878.146355076155/8.0), + REAL_CONST(87901.103778225151/8.0), + REAL_CONST(87924.062700438633/8.0), + REAL_CONST(87947.023121520891/8.0), + REAL_CONST(87969.985041276246/8.0), + REAL_CONST(87992.948459509105/8.0), + REAL_CONST(88015.913376023906/8.0), + REAL_CONST(88038.879790625171/8.0), + REAL_CONST(88061.847703117513/8.0), + REAL_CONST(88084.817113305573/8.0), + REAL_CONST(88107.788020994049/8.0), + REAL_CONST(88130.760425987726/8.0), + REAL_CONST(88153.734328091465/8.0), + REAL_CONST(88176.709727110137/8.0), + REAL_CONST(88199.686622848749/8.0), + REAL_CONST(88222.665015112303/8.0), + REAL_CONST(88245.644903705906/8.0), + REAL_CONST(88268.626288434709/8.0), + REAL_CONST(88291.609169103947/8.0), + REAL_CONST(88314.593545518903/8.0), + REAL_CONST(88337.579417484914/8.0), + REAL_CONST(88360.566784807408/8.0), + REAL_CONST(88383.555647291854/8.0), + REAL_CONST(88406.546004743795/8.0), + REAL_CONST(88429.537856968818/8.0), + REAL_CONST(88452.531203772611/8.0), + REAL_CONST(88475.52604496089/8.0), + REAL_CONST(88498.522380339447/8.0), + REAL_CONST(88521.52020971413/8.0), + REAL_CONST(88544.519532890874/8.0), + REAL_CONST(88567.520349675644/8.0), + REAL_CONST(88590.522659874507/8.0), + REAL_CONST(88613.526463293543/8.0), + REAL_CONST(88636.531759738922/8.0), + REAL_CONST(88659.538549016899/8.0), + REAL_CONST(88682.546830933745/8.0), + REAL_CONST(88705.556605295846/8.0), + REAL_CONST(88728.567871909589/8.0), + REAL_CONST(88751.580630581491/8.0), + REAL_CONST(88774.594881118086/8.0), + REAL_CONST(88797.610623325963/8.0), + REAL_CONST(88820.62785701183/8.0), + REAL_CONST(88843.646581982393/8.0), + REAL_CONST(88866.666798044462/8.0), + REAL_CONST(88889.688505004888/8.0), + REAL_CONST(88912.711702670611/8.0), + REAL_CONST(88935.7363908486/8.0), + REAL_CONST(88958.762569345898/8.0), + REAL_CONST(88981.790237969632/8.0), + REAL_CONST(89004.81939652696/8.0), + REAL_CONST(89027.850044825114/8.0), + REAL_CONST(89050.882182671412/8.0), + REAL_CONST(89073.9158098732/8.0), + REAL_CONST(89096.950926237885/8.0), + REAL_CONST(89119.987531572973/8.0), + REAL_CONST(89143.025625686001/8.0), + REAL_CONST(89166.065208384563/8.0), + REAL_CONST(89189.106279476357/8.0), + REAL_CONST(89212.148838769106/8.0), + REAL_CONST(89235.192886070581/8.0), + REAL_CONST(89258.238421188667/8.0), + REAL_CONST(89281.285443931265/8.0), + REAL_CONST(89304.333954106376/8.0), + REAL_CONST(89327.383951522017/8.0), + REAL_CONST(89350.435435986306/8.0), + REAL_CONST(89373.488407307406/8.0), + REAL_CONST(89396.542865293537/8.0), + REAL_CONST(89419.598809753006/8.0), + REAL_CONST(89442.656240494165/8.0), + REAL_CONST(89465.715157325409/8.0), + REAL_CONST(89488.775560055219/8.0), + REAL_CONST(89511.837448492137/8.0), + REAL_CONST(89534.900822444746/8.0), + REAL_CONST(89557.965681721733/8.0), + REAL_CONST(89581.032026131812/8.0), + REAL_CONST(89604.099855483742/8.0), + REAL_CONST(89627.169169586399/8.0), + REAL_CONST(89650.239968248672/8.0), + REAL_CONST(89673.312251279538/8.0), + REAL_CONST(89696.386018488018/8.0), + REAL_CONST(89719.461269683205/8.0), + REAL_CONST(89742.53800467425/8.0), + REAL_CONST(89765.616223270365/8.0), + REAL_CONST(89788.69592528083/8.0), + REAL_CONST(89811.777110514988/8.0), + REAL_CONST(89834.859778782207/8.0), + REAL_CONST(89857.943929891975/8.0), + REAL_CONST(89881.029563653807/8.0), + REAL_CONST(89904.116679877261/8.0), + REAL_CONST(89927.205278372014/8.0), + REAL_CONST(89950.29535894774/8.0), + REAL_CONST(89973.386921414218/8.0), + REAL_CONST(89996.479965581268/8.0), + REAL_CONST(90019.574491258769/8.0), + REAL_CONST(90042.670498256688/8.0), + REAL_CONST(90065.767986385021/8.0), + REAL_CONST(90088.866955453836/8.0), + REAL_CONST(90111.967405273259/8.0), + REAL_CONST(90135.069335653476/8.0), + REAL_CONST(90158.172746404758/8.0), + REAL_CONST(90181.277637337407/8.0), + REAL_CONST(90204.384008261797/8.0), + REAL_CONST(90227.49185898836/8.0), + REAL_CONST(90250.601189327586/8.0), + REAL_CONST(90273.711999090039/8.0), + REAL_CONST(90296.824288086325/8.0), + REAL_CONST(90319.938056127125/8.0), + REAL_CONST(90343.053303023189/8.0), + REAL_CONST(90366.170028585286/8.0), + REAL_CONST(90389.288232624298/8.0), + REAL_CONST(90412.407914951138/8.0), + REAL_CONST(90435.529075376777/8.0), + REAL_CONST(90458.651713712257/8.0), + REAL_CONST(90481.775829768681/8.0), + REAL_CONST(90504.901423357209/8.0), + REAL_CONST(90528.028494289058/8.0), + REAL_CONST(90551.157042375504/8.0), + REAL_CONST(90574.287067427911/8.0), + REAL_CONST(90597.418569257643/8.0), + REAL_CONST(90620.551547676194/8.0), + REAL_CONST(90643.686002495073/8.0), + REAL_CONST(90666.821933525847/8.0), + REAL_CONST(90689.959340580186/8.0), + REAL_CONST(90713.098223469773/8.0), + REAL_CONST(90736.238582006365/8.0), + REAL_CONST(90759.380416001804/8.0), + REAL_CONST(90782.523725267951/8.0), + REAL_CONST(90805.668509616764/8.0), + REAL_CONST(90828.814768860233/8.0), + REAL_CONST(90851.962502810435/8.0), + REAL_CONST(90875.11171127946/8.0), + REAL_CONST(90898.262394079517/8.0), + REAL_CONST(90921.414551022855/8.0), + REAL_CONST(90944.568181921743/8.0), + REAL_CONST(90967.72328658856/8.0), + REAL_CONST(90990.879864835719/8.0), + REAL_CONST(91014.037916475718/8.0), + REAL_CONST(91037.19744132107/8.0), + REAL_CONST(91060.358439184391/8.0), + REAL_CONST(91083.520909878338/8.0), + REAL_CONST(91106.684853215629/8.0), + REAL_CONST(91129.850269009039/8.0), + REAL_CONST(91153.017157071401/8.0), + REAL_CONST(91176.185517215621/8.0), + REAL_CONST(91199.355349254649/8.0), + REAL_CONST(91222.526653001492/8.0), + REAL_CONST(91245.699428269247/8.0), + REAL_CONST(91268.873674871036/8.0), + REAL_CONST(91292.049392620058/8.0), + REAL_CONST(91315.226581329553/8.0), + REAL_CONST(91338.405240812834/8.0), + REAL_CONST(91361.585370883287/8.0), + REAL_CONST(91384.766971354344/8.0), + REAL_CONST(91407.950042039476/8.0), + REAL_CONST(91431.134582752245/8.0), + REAL_CONST(91454.320593306256/8.0), + REAL_CONST(91477.508073515171/8.0), + REAL_CONST(91500.697023192712/8.0), + REAL_CONST(91523.887442152685/8.0), + REAL_CONST(91547.07933020893/8.0), + REAL_CONST(91570.272687175326/8.0), + REAL_CONST(91593.467512865856/8.0), + REAL_CONST(91616.663807094534/8.0), + REAL_CONST(91639.861569675442/8.0), + REAL_CONST(91663.060800422725/8.0), + REAL_CONST(91686.261499150554/8.0), + REAL_CONST(91709.463665673218/8.0), + REAL_CONST(91732.66729980502/8.0), + REAL_CONST(91755.872401360321/8.0), + REAL_CONST(91779.078970153569/8.0), + REAL_CONST(91802.287005999257/8.0), + REAL_CONST(91825.49650871192/8.0), + REAL_CONST(91848.707478106167/8.0), + REAL_CONST(91871.91991399668/8.0), + REAL_CONST(91895.133816198169/8.0), + REAL_CONST(91918.349184525418/8.0), + REAL_CONST(91941.566018793281/8.0), + REAL_CONST(91964.784318816659/8.0), + REAL_CONST(91988.004084410495/8.0), + REAL_CONST(92011.22531538982/8.0), + REAL_CONST(92034.448011569708/8.0), + REAL_CONST(92057.672172765277/8.0), + REAL_CONST(92080.897798791746/8.0), + REAL_CONST(92104.124889464365/8.0), + REAL_CONST(92127.353444598411/8.0), + REAL_CONST(92150.58346400928/8.0), + REAL_CONST(92173.814947512379/8.0), + REAL_CONST(92197.04789492322/8.0), + REAL_CONST(92220.282306057314/8.0), + REAL_CONST(92243.518180730272/8.0), + REAL_CONST(92266.755518757753/8.0), + REAL_CONST(92289.994319955469/8.0), + REAL_CONST(92313.234584139194/8.0), + REAL_CONST(92336.476311124774/8.0), + REAL_CONST(92359.719500728082/8.0), + REAL_CONST(92382.964152765067/8.0), + REAL_CONST(92406.210267051734/8.0), + REAL_CONST(92429.457843404161/8.0), + REAL_CONST(92452.706881638471/8.0), + REAL_CONST(92475.957381570814/8.0), + REAL_CONST(92499.209343017443/8.0), + REAL_CONST(92522.462765794655/8.0), + REAL_CONST(92545.717649718805/8.0), + REAL_CONST(92568.973994606305/8.0), + REAL_CONST(92592.231800273614/8.0), + REAL_CONST(92615.491066537259/8.0), + REAL_CONST(92638.751793213814/8.0), + REAL_CONST(92662.01398011994/8.0), + REAL_CONST(92685.277627072326/8.0), + REAL_CONST(92708.54273388772/8.0), + REAL_CONST(92731.809300382942/8.0), + REAL_CONST(92755.077326374871/8.0), + REAL_CONST(92778.346811680414/8.0), + REAL_CONST(92801.617756116568/8.0), + REAL_CONST(92824.890159500384/8.0), + REAL_CONST(92848.164021648947/8.0), + REAL_CONST(92871.439342379424/8.0), + REAL_CONST(92894.716121509016/8.0), + REAL_CONST(92917.994358855023/8.0), + REAL_CONST(92941.274054234746/8.0), + REAL_CONST(92964.555207465572/8.0), + REAL_CONST(92987.837818364962/8.0), + REAL_CONST(93011.121886750407/8.0), + REAL_CONST(93034.407412439468/8.0), + REAL_CONST(93057.694395249753/8.0), + REAL_CONST(93080.982834998955/8.0), + REAL_CONST(93104.272731504767/8.0), + REAL_CONST(93127.564084584999/8.0), + REAL_CONST(93150.856894057491/8.0), + REAL_CONST(93174.15115974014/8.0), + REAL_CONST(93197.446881450916/8.0), + REAL_CONST(93220.744059007804/8.0), + REAL_CONST(93244.04269222889/8.0), + REAL_CONST(93267.342780932304/8.0), + REAL_CONST(93290.644324936235/8.0), + REAL_CONST(93313.947324058914/8.0), + REAL_CONST(93337.251778118633/8.0), + REAL_CONST(93360.557686933767/8.0), + REAL_CONST(93383.865050322696/8.0), + REAL_CONST(93407.173868103928/8.0), + REAL_CONST(93430.484140095941/8.0), + REAL_CONST(93453.795866117362/8.0), + REAL_CONST(93477.109045986799/8.0), + REAL_CONST(93500.423679522952/8.0), + REAL_CONST(93523.739766544561/8.0), + REAL_CONST(93547.057306870454/8.0), + REAL_CONST(93570.376300319491/8.0), + REAL_CONST(93593.696746710571/8.0), + REAL_CONST(93617.018645862699/8.0), + REAL_CONST(93640.341997594893/8.0), + REAL_CONST(93663.666801726242/8.0), + REAL_CONST(93686.993058075881/8.0), + REAL_CONST(93710.320766463032/8.0), + REAL_CONST(93733.64992670693/8.0), + REAL_CONST(93756.980538626914/8.0), + REAL_CONST(93780.312602042337/8.0), + REAL_CONST(93803.646116772637/8.0), + REAL_CONST(93826.981082637285/8.0), + REAL_CONST(93850.317499455836/8.0), + REAL_CONST(93873.655367047861/8.0), + REAL_CONST(93896.994685233032/8.0), + REAL_CONST(93920.335453831038/8.0), + REAL_CONST(93943.677672661666/8.0), + REAL_CONST(93967.021341544707/8.0), + REAL_CONST(93990.366460300051/8.0), + REAL_CONST(94013.713028747632/8.0), + REAL_CONST(94037.061046707429/8.0), + REAL_CONST(94060.410513999494/8.0), + REAL_CONST(94083.761430443905/8.0), + REAL_CONST(94107.113795860845/8.0), + REAL_CONST(94130.467610070496/8.0), + REAL_CONST(94153.822872893157/8.0), + REAL_CONST(94177.179584149111/8.0), + REAL_CONST(94200.537743658759/8.0), + REAL_CONST(94223.897351242529/8.0), + REAL_CONST(94247.25840672091/8.0), + REAL_CONST(94270.620909914433/8.0), + REAL_CONST(94293.98486064373/8.0), + REAL_CONST(94317.350258729421/8.0), + REAL_CONST(94340.71710399224/8.0), + REAL_CONST(94364.085396252936/8.0), + REAL_CONST(94387.455135332348/8.0), + REAL_CONST(94410.82632105134/8.0), + REAL_CONST(94434.198953230851/8.0), + REAL_CONST(94457.573031691878/8.0), + REAL_CONST(94480.948556255447/8.0), + REAL_CONST(94504.325526742658/8.0), + REAL_CONST(94527.70394297468/8.0), + REAL_CONST(94551.083804772716/8.0), + REAL_CONST(94574.465111958023/8.0), + REAL_CONST(94597.847864351934/8.0), + REAL_CONST(94621.232061775823/8.0), + REAL_CONST(94644.617704051096/8.0), + REAL_CONST(94668.004790999272/8.0), + REAL_CONST(94691.393322441872/8.0), + REAL_CONST(94714.783298200506/8.0), + REAL_CONST(94738.174718096794/8.0), + REAL_CONST(94761.567581952477/8.0), + REAL_CONST(94784.961889589307/8.0), + REAL_CONST(94808.357640829097/8.0), + REAL_CONST(94831.754835493703/8.0), + REAL_CONST(94855.153473405066/8.0), + REAL_CONST(94878.553554385173/8.0), + REAL_CONST(94901.955078256055/8.0), + REAL_CONST(94925.358044839784/8.0), + REAL_CONST(94948.762453958523/8.0), + REAL_CONST(94972.168305434476/8.0), + REAL_CONST(94995.575599089891/8.0), + REAL_CONST(95018.984334747074/8.0), + REAL_CONST(95042.394512228391/8.0), + REAL_CONST(95065.806131356265/8.0), + REAL_CONST(95089.219191953176/8.0), + REAL_CONST(95112.633693841635/8.0), + REAL_CONST(95136.04963684424/8.0), + REAL_CONST(95159.467020783617/8.0), + REAL_CONST(95182.885845482466/8.0), + REAL_CONST(95206.306110763529/8.0), + REAL_CONST(95229.727816449609/8.0), + REAL_CONST(95253.150962363579/8.0), + REAL_CONST(95276.575548328314/8.0), + REAL_CONST(95300.001574166803/8.0), + REAL_CONST(95323.429039702052/8.0), + REAL_CONST(95346.857944757154/8.0), + REAL_CONST(95370.288289155214/8.0), + REAL_CONST(95393.720072719429/8.0), + REAL_CONST(95417.153295273019/8.0), + REAL_CONST(95440.587956639298/8.0), + REAL_CONST(95464.024056641589/8.0), + REAL_CONST(95487.461595103305/8.0), + REAL_CONST(95510.900571847902/8.0), + REAL_CONST(95534.340986698866/8.0), + REAL_CONST(95557.782839479783/8.0), + REAL_CONST(95581.226130014256/8.0), + REAL_CONST(95604.670858125959/8.0), + REAL_CONST(95628.117023638595/8.0), + REAL_CONST(95651.564626375985/8.0), + REAL_CONST(95675.013666161918/8.0), + REAL_CONST(95698.464142820303/8.0), + REAL_CONST(95721.916056175076/8.0), + REAL_CONST(95745.369406050231/8.0), + REAL_CONST(95768.824192269807/8.0), + REAL_CONST(95792.280414657915/8.0), + REAL_CONST(95815.738073038709/8.0), + REAL_CONST(95839.197167236387/8.0), + REAL_CONST(95862.657697075221/8.0), + REAL_CONST(95886.11966237954/8.0), + REAL_CONST(95909.583062973688/8.0), + REAL_CONST(95933.047898682111/8.0), + REAL_CONST(95956.514169329268/8.0), + REAL_CONST(95979.981874739708/8.0), + REAL_CONST(96003.451014738006/8.0), + REAL_CONST(96026.921589148798/8.0), + REAL_CONST(96050.393597796792/8.0), + REAL_CONST(96073.867040506724/8.0), + REAL_CONST(96097.341917103375/8.0), + REAL_CONST(96120.818227411626/8.0), + REAL_CONST(96144.295971256375/8.0), + REAL_CONST(96167.775148462577/8.0), + REAL_CONST(96191.255758855244/8.0), + REAL_CONST(96214.737802259449/8.0), + REAL_CONST(96238.221278500292/8.0), + REAL_CONST(96261.70618740299/8.0), + REAL_CONST(96285.192528792715/8.0), + REAL_CONST(96308.680302494788/8.0), + REAL_CONST(96332.169508334526/8.0), + REAL_CONST(96355.660146137321/8.0), + REAL_CONST(96379.152215728609/8.0), + REAL_CONST(96402.645716933868/8.0), + REAL_CONST(96426.14064957868/8.0), + REAL_CONST(96449.637013488609/8.0), + REAL_CONST(96473.134808489311/8.0), + REAL_CONST(96496.63403440651/8.0), + REAL_CONST(96520.134691065963/8.0), + REAL_CONST(96543.636778293469/8.0), + REAL_CONST(96567.140295914898/8.0), + REAL_CONST(96590.645243756153/8.0), + REAL_CONST(96614.151621643221/8.0), + REAL_CONST(96637.659429402134/8.0), + REAL_CONST(96661.168666858954/8.0), + REAL_CONST(96684.679333839798/8.0), + REAL_CONST(96708.191430170875/8.0), + REAL_CONST(96731.70495567839/8.0), + REAL_CONST(96755.219910188665/8.0), + REAL_CONST(96778.736293528011/8.0), + REAL_CONST(96802.254105522836/8.0), + REAL_CONST(96825.77334599958/8.0), + REAL_CONST(96849.29401478474/8.0), + REAL_CONST(96872.816111704873/8.0), + REAL_CONST(96896.339636586577/8.0), + REAL_CONST(96919.864589256511/8.0), + REAL_CONST(96943.390969541389/8.0), + REAL_CONST(96966.918777267958/8.0), + REAL_CONST(96990.448012263048/8.0), + REAL_CONST(97013.978674353522/8.0), + REAL_CONST(97037.510763366285/8.0), + REAL_CONST(97061.044279128328/8.0), + REAL_CONST(97084.579221466673/8.0), + REAL_CONST(97108.115590208385/8.0), + REAL_CONST(97131.653385180587/8.0), + REAL_CONST(97155.19260621049/8.0), + REAL_CONST(97178.733253125291/8.0), + REAL_CONST(97202.2753257523/8.0), + REAL_CONST(97225.81882391886/8.0), + REAL_CONST(97249.363747452342/8.0), + REAL_CONST(97272.910096180189/8.0), + REAL_CONST(97296.457869929916/8.0), + REAL_CONST(97320.007068529041/8.0), + REAL_CONST(97343.557691805196/8.0), + REAL_CONST(97367.109739586012/8.0), + REAL_CONST(97390.663211699197/8.0), + REAL_CONST(97414.218107972498/8.0), + REAL_CONST(97437.774428233737/8.0), + REAL_CONST(97461.332172310766/8.0), + REAL_CONST(97484.891340031507/8.0), + REAL_CONST(97508.451931223899/8.0), + REAL_CONST(97532.013945715982/8.0), + REAL_CONST(97555.577383335811/8.0), + REAL_CONST(97579.142243911512/8.0), + REAL_CONST(97602.708527271257/8.0), + REAL_CONST(97626.276233243261/8.0), + REAL_CONST(97649.845361655811/8.0), + REAL_CONST(97673.415912337223/8.0), + REAL_CONST(97696.987885115886/8.0), + REAL_CONST(97720.561279820206/8.0), + REAL_CONST(97744.1360962787/8.0), + REAL_CONST(97767.712334319876/8.0), + REAL_CONST(97791.289993772341/8.0), + REAL_CONST(97814.869074464703/8.0), + REAL_CONST(97838.449576225685/8.0), + REAL_CONST(97862.031498883996/8.0), + REAL_CONST(97885.614842268449/8.0), + REAL_CONST(97909.199606207883/8.0), + REAL_CONST(97932.785790531183/8.0), + REAL_CONST(97956.37339506732/8.0), + REAL_CONST(97979.962419645264/8.0), + REAL_CONST(98003.552864094076/8.0), + REAL_CONST(98027.144728242856/8.0), + REAL_CONST(98050.738011920766/8.0), + REAL_CONST(98074.332714956996/8.0), + REAL_CONST(98097.928837180807/8.0), + REAL_CONST(98121.526378421506/8.0), + REAL_CONST(98145.125338508456/8.0), + REAL_CONST(98168.725717271067/8.0), + REAL_CONST(98192.327514538789/8.0), + REAL_CONST(98215.930730141132/8.0), + REAL_CONST(98239.535363907664/8.0), + REAL_CONST(98263.141415668011/8.0), + REAL_CONST(98286.748885251814/8.0), + REAL_CONST(98310.357772488816/8.0), + REAL_CONST(98333.968077208759/8.0), + REAL_CONST(98357.579799241488/8.0), + REAL_CONST(98381.192938416847/8.0), + REAL_CONST(98404.807494564782/8.0), + REAL_CONST(98428.42346751524/8.0), + REAL_CONST(98452.040857098269/8.0), + REAL_CONST(98475.659663143917/8.0), + REAL_CONST(98499.27988548232/8.0), + REAL_CONST(98522.901523943656/8.0), + REAL_CONST(98546.524578358163/8.0), + REAL_CONST(98570.149048556093/8.0), + REAL_CONST(98593.774934367786/8.0), + REAL_CONST(98617.402235623624/8.0), + REAL_CONST(98641.030952154048/8.0), + REAL_CONST(98664.661083789513/8.0), + REAL_CONST(98688.292630360564/8.0), + REAL_CONST(98711.925591697771/8.0), + REAL_CONST(98735.559967631794/8.0), + REAL_CONST(98759.195757993293/8.0), + REAL_CONST(98782.832962613014/8.0), + REAL_CONST(98806.471581321734/8.0), + REAL_CONST(98830.111613950285/8.0), + REAL_CONST(98853.753060329575/8.0), + REAL_CONST(98877.39592029051/8.0), + REAL_CONST(98901.040193664099/8.0), + REAL_CONST(98924.68588028138/8.0), + REAL_CONST(98948.33297997342/8.0), + REAL_CONST(98971.981492571387/8.0), + REAL_CONST(98995.63141790645/8.0), + REAL_CONST(99019.282755809851/8.0), + REAL_CONST(99042.935506112874/8.0), + REAL_CONST(99066.589668646877/8.0), + REAL_CONST(99090.245243243233/8.0), + REAL_CONST(99113.902229733401/8.0), + REAL_CONST(99137.560627948857/8.0), + REAL_CONST(99161.220437721131/8.0), + REAL_CONST(99184.881658881859/8.0), + REAL_CONST(99208.544291262631/8.0), + REAL_CONST(99232.208334695169/8.0), + REAL_CONST(99255.87378901121/8.0), + REAL_CONST(99279.540654042547/8.0), + REAL_CONST(99303.208929621018/8.0), + REAL_CONST(99326.878615578535/8.0), + REAL_CONST(99350.549711746993/8.0), + REAL_CONST(99374.222217958435/8.0), + REAL_CONST(99397.896134044888/8.0), + REAL_CONST(99421.571459838422/8.0), + REAL_CONST(99445.248195171211/8.0), + REAL_CONST(99468.926339875441/8.0), + REAL_CONST(99492.605893783344/8.0), + REAL_CONST(99516.286856727209/8.0), + REAL_CONST(99539.969228539398/8.0), + REAL_CONST(99563.653009052287/8.0), + REAL_CONST(99587.338198098325/8.0), + REAL_CONST(99611.024795510006/8.0), + REAL_CONST(99634.712801119866/8.0), + REAL_CONST(99658.402214760499/8.0), + REAL_CONST(99682.093036264545/8.0), + REAL_CONST(99705.785265464699/8.0), + REAL_CONST(99729.478902193689/8.0), + REAL_CONST(99753.173946284325/8.0), + REAL_CONST(99776.870397569437/8.0), + REAL_CONST(99800.56825588191/8.0), + REAL_CONST(99824.267521054688/8.0), + REAL_CONST(99847.968192920773/8.0), + REAL_CONST(99871.670271313182/8.0), + REAL_CONST(99895.373756065004/8.0), + REAL_CONST(99919.078647009388/8.0), + REAL_CONST(99942.78494397951/8.0), + REAL_CONST(99966.492646808634/8.0), + REAL_CONST(99990.20175533001/8.0), + REAL_CONST(100013.91226937699/8.0), + REAL_CONST(100037.62418878295/8.0), + REAL_CONST(100061.33751338134/8.0), + REAL_CONST(100085.05224300563/8.0), + REAL_CONST(100108.76837748935/8.0), + REAL_CONST(100132.4859166661/8.0), + REAL_CONST(100156.2048603695/8.0), + REAL_CONST(100179.92520843323/8.0), + REAL_CONST(100203.64696069101/8.0), + REAL_CONST(100227.37011697664/8.0), + REAL_CONST(100251.09467712394/8.0), + REAL_CONST(100274.82064096678/8.0), + REAL_CONST(100298.54800833909/8.0), + REAL_CONST(100322.27677907483/8.0), + REAL_CONST(100346.00695300807/8.0), + REAL_CONST(100369.73852997283/8.0), + REAL_CONST(100393.47150980328/8.0), + REAL_CONST(100417.20589233354/8.0), + REAL_CONST(100440.94167739789/8.0), + REAL_CONST(100464.67886483055/8.0), + REAL_CONST(100488.41745446586/8.0), + REAL_CONST(100512.1574461382/8.0), + REAL_CONST(100535.89883968196/8.0), + REAL_CONST(100559.64163493161/8.0), + REAL_CONST(100583.38583172169/8.0), + REAL_CONST(100607.13142988674/8.0), + REAL_CONST(100630.87842926137/8.0), + REAL_CONST(100654.62682968024/8.0), + REAL_CONST(100678.37663097809/8.0), + REAL_CONST(100702.12783298964/8.0), + REAL_CONST(100725.88043554971/8.0), + REAL_CONST(100749.63443849317/8.0), + REAL_CONST(100773.38984165489/8.0), + REAL_CONST(100797.14664486986/8.0), + REAL_CONST(100820.90484797307/8.0), + REAL_CONST(100844.66445079957/8.0), + REAL_CONST(100868.42545318443/8.0), + REAL_CONST(100892.18785496285/8.0), + REAL_CONST(100915.95165596998/8.0), + REAL_CONST(100939.71685604109/8.0), + REAL_CONST(100963.48345501146/8.0), + REAL_CONST(100987.25145271645/8.0), + REAL_CONST(101011.02084899142/8.0), + REAL_CONST(101034.79164367182/8.0), + REAL_CONST(101058.56383659317/8.0), + REAL_CONST(101082.33742759094/8.0), + REAL_CONST(101106.11241650078/8.0), + REAL_CONST(101129.88880315828/8.0), + REAL_CONST(101153.66658739912/8.0), + REAL_CONST(101177.44576905905/8.0), + REAL_CONST(101201.22634797383/8.0), + REAL_CONST(101225.00832397929/8.0), + REAL_CONST(101248.7916969113/8.0), + REAL_CONST(101272.57646660579/8.0), + REAL_CONST(101296.36263289873/8.0), + REAL_CONST(101320.15019562612/8.0), + REAL_CONST(101343.93915462404/8.0), + REAL_CONST(101367.7295097286/8.0), + REAL_CONST(101391.52126077596/8.0), + REAL_CONST(101415.31440760233/8.0), + REAL_CONST(101439.10895004397/8.0), + REAL_CONST(101462.9048879372/8.0), + REAL_CONST(101486.70222111834/8.0), + REAL_CONST(101510.50094942382/8.0), + REAL_CONST(101534.30107269008/8.0), + REAL_CONST(101558.10259075361/8.0), + REAL_CONST(101581.90550345098/8.0), + REAL_CONST(101605.70981061876/8.0), + REAL_CONST(101629.5155120936/8.0), + REAL_CONST(101653.32260771218/8.0), + REAL_CONST(101677.13109731126/8.0), + REAL_CONST(101700.9409807276/8.0), + REAL_CONST(101724.75225779804/8.0), + REAL_CONST(101748.56492835947/8.0), + REAL_CONST(101772.37899224881/8.0), + REAL_CONST(101796.19444930303/8.0), + REAL_CONST(101820.01129935916/8.0), + REAL_CONST(101843.82954225427/8.0), + REAL_CONST(101867.64917782549/8.0), + REAL_CONST(101891.47020590997/8.0), + REAL_CONST(101915.29262634492/8.0), + REAL_CONST(101939.11643896763/8.0), + REAL_CONST(101962.94164361537/8.0), + REAL_CONST(101986.76824012553/8.0), + REAL_CONST(102010.59622833549/8.0), + REAL_CONST(102034.42560808272/8.0), + REAL_CONST(102058.25637920471/8.0), + REAL_CONST(102082.08854153901/8.0), + REAL_CONST(102105.9220949232/8.0), + REAL_CONST(102129.75703919494/8.0), + REAL_CONST(102153.59337419191/8.0), + REAL_CONST(102177.43109975185/8.0), + REAL_CONST(102201.27021571253/8.0), + REAL_CONST(102225.1107219118/8.0), + REAL_CONST(102248.95261818753/8.0), + REAL_CONST(102272.79590437764/8.0), + REAL_CONST(102296.64058032009/8.0), + REAL_CONST(102320.48664585294/8.0), + REAL_CONST(102344.33410081422/8.0), + REAL_CONST(102368.18294504205/8.0), + REAL_CONST(102392.03317837461/8.0), + REAL_CONST(102415.88480065008/8.0), + REAL_CONST(102439.73781170673/8.0), + REAL_CONST(102463.59221138287/8.0), + REAL_CONST(102487.44799951684/8.0), + REAL_CONST(102511.30517594704/8.0), + REAL_CONST(102535.1637405119/8.0), + REAL_CONST(102559.02369304992/8.0), + REAL_CONST(102582.88503339965/8.0), + REAL_CONST(102606.74776139967/8.0), + REAL_CONST(102630.61187688859/8.0), + REAL_CONST(102654.4773797051/8.0), + REAL_CONST(102678.34426968795/8.0), + REAL_CONST(102702.21254667587/8.0), + REAL_CONST(102726.08221050771/8.0), + REAL_CONST(102749.95326102231/8.0), + REAL_CONST(102773.8256980586/8.0), + REAL_CONST(102797.69952145554/8.0), + REAL_CONST(102821.57473105213/8.0), + REAL_CONST(102845.45132668741/8.0), + REAL_CONST(102869.32930820051/8.0), + REAL_CONST(102893.20867543056/8.0), + REAL_CONST(102917.08942821674/8.0), + REAL_CONST(102940.97156639832/8.0), + REAL_CONST(102964.85508981455/8.0), + REAL_CONST(102988.73999830478/8.0), + REAL_CONST(103012.6262917084/8.0), + REAL_CONST(103036.51396986481/8.0), + REAL_CONST(103060.40303261351/8.0), + REAL_CONST(103084.293479794/8.0), + REAL_CONST(103108.18531124585/8.0), + REAL_CONST(103132.07852680866/8.0), + REAL_CONST(103155.97312632212/8.0), + REAL_CONST(103179.8691096259/8.0), + REAL_CONST(103203.76647655977/8.0), + REAL_CONST(103227.66522696352/8.0), + REAL_CONST(103251.56536067701/8.0), + REAL_CONST(103275.46687754011/8.0), + REAL_CONST(103299.36977739276/8.0), + REAL_CONST(103323.27406007495/8.0), + REAL_CONST(103347.1797254267/8.0), + REAL_CONST(103371.0867732881/8.0), + REAL_CONST(103394.99520349925/8.0), + REAL_CONST(103418.90501590034/8.0), + REAL_CONST(103442.81621033157/8.0), + REAL_CONST(103466.72878663319/8.0), + REAL_CONST(103490.64274464553/8.0), + REAL_CONST(103514.55808420894/8.0), + REAL_CONST(103538.4748051638/8.0), + REAL_CONST(103562.39290735057/8.0), + REAL_CONST(103586.31239060973/8.0), + REAL_CONST(103610.23325478184/8.0), + REAL_CONST(103634.15549970744/8.0), + REAL_CONST(103658.07912522719/8.0), + REAL_CONST(103682.00413118176/8.0), + REAL_CONST(103705.93051741188/8.0), + REAL_CONST(103729.85828375829/8.0), + REAL_CONST(103753.78743006183/8.0), + REAL_CONST(103777.71795616332/8.0), + REAL_CONST(103801.64986190372/8.0), + REAL_CONST(103825.58314712394/8.0), + REAL_CONST(103849.51781166498/8.0), + REAL_CONST(103873.4538553679/8.0), + REAL_CONST(103897.39127807376/8.0), + REAL_CONST(103921.33007962372/8.0), + REAL_CONST(103945.27025985894/8.0), + REAL_CONST(103969.21181862066/8.0), + REAL_CONST(103993.15475575015/8.0), + REAL_CONST(104017.0990710887/8.0), + REAL_CONST(104041.0447644777/8.0), + REAL_CONST(104064.99183575854/8.0), + REAL_CONST(104088.94028477269/8.0), + REAL_CONST(104112.89011136163/8.0), + REAL_CONST(104136.84131536692/8.0), + REAL_CONST(104160.79389663014/8.0), + REAL_CONST(104184.74785499295/8.0), + REAL_CONST(104208.70319029699/8.0), + REAL_CONST(104232.65990238401/8.0), + REAL_CONST(104256.61799109577/8.0), + REAL_CONST(104280.57745627411/8.0), + REAL_CONST(104304.53829776087/8.0), + REAL_CONST(104328.50051539797/8.0), + REAL_CONST(104352.46410902737/8.0), + REAL_CONST(104376.42907849104/8.0), + REAL_CONST(104400.39542363105/8.0), + REAL_CONST(104424.36314428948/8.0), + REAL_CONST(104448.33224030846/8.0), + REAL_CONST(104472.3027115302/8.0), + REAL_CONST(104496.27455779689/8.0), + REAL_CONST(104520.24777895081/8.0), + REAL_CONST(104544.22237483428/8.0), + REAL_CONST(104568.19834528965/8.0), + REAL_CONST(104592.17569015936/8.0), + REAL_CONST(104616.15440928582/8.0), + REAL_CONST(104640.13450251156/8.0), + REAL_CONST(104664.1159696791/8.0), + REAL_CONST(104688.09881063103/8.0), + REAL_CONST(104712.08302520998/8.0), + REAL_CONST(104736.06861325864/8.0), + REAL_CONST(104760.05557461972/8.0), + REAL_CONST(104784.043909136/8.0), + REAL_CONST(104808.03361665027/8.0), + REAL_CONST(104832.0246970054/8.0), + REAL_CONST(104856.01715004431/8.0), + REAL_CONST(104880.01097560991/8.0), + REAL_CONST(104904.00617354522/8.0), + REAL_CONST(104928.00274369326/8.0), + REAL_CONST(104952.00068589712/8.0), + REAL_CONST(104975.99999999993/8.0), + REAL_CONST(105000.00068584486/8.0), + REAL_CONST(105024.00274327511/8.0), + REAL_CONST(105048.00617213396/8.0), + REAL_CONST(105072.0109722647/8.0), + REAL_CONST(105096.0171435107/8.0), + REAL_CONST(105120.02468571534/8.0), + REAL_CONST(105144.03359872208/8.0), + REAL_CONST(105168.04388237436/8.0), + REAL_CONST(105192.05553651576/8.0), + REAL_CONST(105216.06856098982/8.0), + REAL_CONST(105240.08295564017/8.0), + REAL_CONST(105264.09872031047/8.0), + REAL_CONST(105288.11585484444/8.0), + REAL_CONST(105312.13435908582/8.0), + REAL_CONST(105336.1542328784/8.0), + REAL_CONST(105360.17547606604/8.0), + REAL_CONST(105384.19808849262/8.0), + REAL_CONST(105408.22207000206/8.0), + REAL_CONST(105432.24742043833/8.0), + REAL_CONST(105456.27413964548/8.0), + REAL_CONST(105480.30222746753/8.0), + REAL_CONST(105504.33168374863/8.0), + REAL_CONST(105528.36250833291/8.0), + REAL_CONST(105552.39470106458/8.0), + REAL_CONST(105576.42826178786/8.0), + REAL_CONST(105600.46319034706/8.0), + REAL_CONST(105624.49948658649/8.0), + REAL_CONST(105648.53715035053/8.0), + REAL_CONST(105672.5761814836/8.0), + REAL_CONST(105696.61657983017/8.0), + REAL_CONST(105720.65834523473/8.0), + REAL_CONST(105744.70147754184/8.0), + REAL_CONST(105768.7459765961/8.0), + REAL_CONST(105792.79184224214/8.0), + REAL_CONST(105816.83907432464/8.0), + REAL_CONST(105840.88767268835/8.0), + REAL_CONST(105864.93763717801/8.0), + REAL_CONST(105888.98896763846/8.0), + REAL_CONST(105913.04166391456/8.0), + REAL_CONST(105937.09572585119/8.0), + REAL_CONST(105961.15115329332/8.0), + REAL_CONST(105985.20794608595/8.0), + REAL_CONST(106009.26610407409/8.0), + REAL_CONST(106033.32562710284/8.0), + REAL_CONST(106057.38651501729/8.0), + REAL_CONST(106081.44876766266/8.0), + REAL_CONST(106105.51238488412/8.0), + REAL_CONST(106129.57736652695/8.0), + REAL_CONST(106153.64371243643/8.0), + REAL_CONST(106177.71142245791/8.0), + REAL_CONST(106201.78049643678/8.0), + REAL_CONST(106225.85093421848/8.0), + REAL_CONST(106249.92273564848/8.0), + REAL_CONST(106273.99590057228/8.0), + REAL_CONST(106298.07042883546/8.0), + REAL_CONST(106322.14632028362/8.0), + REAL_CONST(106346.22357476239/8.0), + REAL_CONST(106370.30219211751/8.0), + REAL_CONST(106394.38217219469/8.0), + REAL_CONST(106418.46351483969/8.0), + REAL_CONST(106442.54621989837/8.0), + REAL_CONST(106466.63028721658/8.0), + REAL_CONST(106490.71571664025/8.0), + REAL_CONST(106514.80250801529/8.0), + REAL_CONST(106538.89066118775/8.0), + REAL_CONST(106562.98017600364/8.0), + REAL_CONST(106587.07105230905/8.0), + REAL_CONST(106611.16328995011/8.0), + REAL_CONST(106635.25688877302/8.0), + REAL_CONST(106659.35184862395/8.0), + REAL_CONST(106683.44816934918/8.0), + REAL_CONST(106707.54585079502/8.0), + REAL_CONST(106731.64489280782/8.0), + REAL_CONST(106755.74529523395/8.0), + REAL_CONST(106779.84705791986/8.0), + REAL_CONST(106803.95018071201/8.0), + REAL_CONST(106828.05466345693/8.0), + REAL_CONST(106852.16050600118/8.0), + REAL_CONST(106876.26770819137/8.0), + REAL_CONST(106900.37626987413/8.0), + REAL_CONST(106924.48619089619/8.0), + REAL_CONST(106948.59747110425/8.0), + REAL_CONST(106972.71011034511/8.0), + REAL_CONST(106996.82410846559/8.0), + REAL_CONST(107020.93946531253/8.0), + REAL_CONST(107045.05618073288/8.0), + REAL_CONST(107069.17425457356/8.0), + REAL_CONST(107093.29368668159/8.0), + REAL_CONST(107117.41447690397/8.0), + REAL_CONST(107141.53662508781/8.0), + REAL_CONST(107165.66013108024/8.0), + REAL_CONST(107189.7849947284/8.0), + REAL_CONST(107213.91121587952/8.0), + REAL_CONST(107238.03879438085/8.0), + REAL_CONST(107262.16773007967/8.0), + REAL_CONST(107286.29802282334/8.0), + REAL_CONST(107310.42967245923/8.0), + REAL_CONST(107334.56267883476/8.0), + REAL_CONST(107358.69704179741/8.0), + REAL_CONST(107382.83276119467/8.0), + REAL_CONST(107406.96983687414/8.0), + REAL_CONST(107431.10826868335/8.0), + REAL_CONST(107455.24805646999/8.0), + REAL_CONST(107479.38920008171/8.0), + REAL_CONST(107503.53169936626/8.0), + REAL_CONST(107527.67555417139/8.0), + REAL_CONST(107551.82076434491/8.0), + REAL_CONST(107575.96732973469/8.0), + REAL_CONST(107600.11525018861/8.0), + REAL_CONST(107624.26452555459/8.0), + REAL_CONST(107648.41515568066/8.0), + REAL_CONST(107672.56714041479/8.0), + REAL_CONST(107696.72047960508/8.0), + REAL_CONST(107720.87517309963/8.0), + REAL_CONST(107745.03122074658/8.0), + REAL_CONST(107769.18862239413/8.0), + REAL_CONST(107793.34737789053/8.0), + REAL_CONST(107817.50748708403/8.0), + REAL_CONST(107841.66894982298/8.0), + REAL_CONST(107865.83176595572/8.0), + REAL_CONST(107889.99593533068/8.0), + REAL_CONST(107914.16145779629/8.0), + REAL_CONST(107938.32833320105/8.0), + REAL_CONST(107962.49656139348/8.0), + REAL_CONST(107986.66614222217/8.0), + REAL_CONST(108010.83707553572/8.0), + REAL_CONST(108035.00936118282/8.0), + REAL_CONST(108059.18299901215/8.0), + REAL_CONST(108083.35798887245/8.0), + REAL_CONST(108107.53433061253/8.0), + REAL_CONST(108131.71202408121/8.0), + REAL_CONST(108155.89106912735/8.0), + REAL_CONST(108180.07146559987/8.0), + REAL_CONST(108204.25321334775/8.0), + REAL_CONST(108228.43631221994/8.0), + REAL_CONST(108252.62076206553/8.0), + REAL_CONST(108276.80656273357/8.0), + REAL_CONST(108300.99371407321/8.0), + REAL_CONST(108325.18221593359/8.0), + REAL_CONST(108349.37206816394/8.0), + REAL_CONST(108373.56327061349/8.0), + REAL_CONST(108397.75582313156/8.0), + REAL_CONST(108421.94972556747/8.0), + REAL_CONST(108446.1449777706/8.0), + REAL_CONST(108470.34157959036/8.0), + REAL_CONST(108494.53953087622/8.0), + REAL_CONST(108518.73883147769/8.0), + REAL_CONST(108542.93948124432/8.0), + REAL_CONST(108567.14148002568/8.0), + REAL_CONST(108591.34482767139/8.0), + REAL_CONST(108615.54952403114/8.0), + REAL_CONST(108639.75556895464/8.0), + REAL_CONST(108663.96296229165/8.0), + REAL_CONST(108688.17170389196/8.0), + REAL_CONST(108712.38179360541/8.0), + REAL_CONST(108736.59323128188/8.0), + REAL_CONST(108760.80601677128/8.0), + REAL_CONST(108785.02014992358/8.0), + REAL_CONST(108809.23563058881/8.0), + REAL_CONST(108833.45245861699/8.0), + REAL_CONST(108857.67063385822/8.0), + REAL_CONST(108881.89015616261/8.0), + REAL_CONST(108906.11102538036/8.0), + REAL_CONST(108930.33324136167/8.0), + REAL_CONST(108954.55680395682/8.0), + REAL_CONST(108978.78171301607/8.0), + REAL_CONST(109003.00796838976/8.0), + REAL_CONST(109027.23556992831/8.0), + REAL_CONST(109051.46451748211/8.0), + REAL_CONST(109075.69481090162/8.0), + REAL_CONST(109099.92645003737/8.0), + REAL_CONST(109124.15943473989/8.0), + REAL_CONST(109148.39376485976/8.0), + REAL_CONST(109172.62944024763/8.0), + REAL_CONST(109196.86646075416/8.0), + REAL_CONST(109221.10482623006/8.0), + REAL_CONST(109245.34453652608/8.0), + REAL_CONST(109269.58559149304/8.0), + REAL_CONST(109293.82799098175/8.0), + REAL_CONST(109318.07173484311/8.0), + REAL_CONST(109342.31682292801/8.0), + REAL_CONST(109366.56325508743/8.0), + REAL_CONST(109390.81103117237/8.0), + REAL_CONST(109415.06015103387/8.0), + REAL_CONST(109439.31061452301/8.0), + REAL_CONST(109463.56242149093/8.0), + REAL_CONST(109487.8155717888/8.0), + REAL_CONST(109512.07006526781/8.0), + REAL_CONST(109536.3259017792/8.0), + REAL_CONST(109560.58308117429/8.0), + REAL_CONST(109584.8416033044/8.0), + REAL_CONST(109609.1014680209/8.0), + REAL_CONST(109633.36267517522/8.0), + REAL_CONST(109657.62522461878/8.0), + REAL_CONST(109681.88911620311/8.0), + REAL_CONST(109706.15434977971/8.0), + REAL_CONST(109730.4209252002/8.0), + REAL_CONST(109754.68884231619/8.0), + REAL_CONST(109778.95810097932/8.0), + REAL_CONST(109803.22870104131/8.0), + REAL_CONST(109827.50064235389/8.0), + REAL_CONST(109851.77392476884/8.0), + REAL_CONST(109876.04854813802/8.0), + REAL_CONST(109900.32451231324/8.0), + REAL_CONST(109924.60181714644/8.0), + REAL_CONST(109948.88046248957/8.0), + REAL_CONST(109973.1604481946/8.0), + REAL_CONST(109997.44177411357/8.0), + REAL_CONST(110021.72444009855/8.0), + REAL_CONST(110046.00844600165/8.0), + REAL_CONST(110070.29379167501/8.0), + REAL_CONST(110094.58047697082/8.0), + REAL_CONST(110118.86850174134/8.0), + REAL_CONST(110143.15786583882/8.0), + REAL_CONST(110167.44856911557/8.0), + REAL_CONST(110191.74061142397/8.0), + REAL_CONST(110216.03399261639/8.0), + REAL_CONST(110240.32871254528/8.0), + REAL_CONST(110264.62477106311/8.0), + REAL_CONST(110288.9221680224/8.0), + REAL_CONST(110313.22090327571/8.0), + REAL_CONST(110337.52097667565/8.0), + REAL_CONST(110361.82238807483/8.0), + REAL_CONST(110386.12513732594/8.0), + REAL_CONST(110410.42922428172/8.0), + REAL_CONST(110434.73464879491/8.0), + REAL_CONST(110459.04141071832/8.0), + REAL_CONST(110483.34950990479/8.0), + REAL_CONST(110507.6589462072/8.0), + REAL_CONST(110531.96971947847/8.0), + REAL_CONST(110556.28182957157/8.0), + REAL_CONST(110580.5952763395/8.0), + REAL_CONST(110604.91005963532/8.0), + REAL_CONST(110629.22617931209/8.0), + REAL_CONST(110653.54363522294/8.0), + REAL_CONST(110677.86242722106/8.0), + REAL_CONST(110702.18255515963/8.0), + REAL_CONST(110726.50401889188/8.0), + REAL_CONST(110750.82681827113/8.0), + REAL_CONST(110775.1509531507/8.0), + REAL_CONST(110799.47642338395/8.0), + REAL_CONST(110823.80322882428/8.0), + REAL_CONST(110848.13136932514/8.0), + REAL_CONST(110872.46084474004/8.0), + REAL_CONST(110896.79165492248/8.0), + REAL_CONST(110921.12379972603/8.0), + REAL_CONST(110945.4572790043/8.0), + REAL_CONST(110969.79209261097/8.0), + REAL_CONST(110994.12824039967/8.0), + REAL_CONST(111018.46572222417/8.0), + REAL_CONST(111042.80453793822/8.0), + REAL_CONST(111067.14468739564/8.0), + REAL_CONST(111091.48617045028/8.0), + REAL_CONST(111115.82898695602/8.0), + REAL_CONST(111140.1731367668/8.0), + REAL_CONST(111164.51861973655/8.0), + REAL_CONST(111188.86543571933/8.0), + REAL_CONST(111213.21358456917/8.0), + REAL_CONST(111237.56306614014/8.0), + REAL_CONST(111261.91388028639/8.0), + REAL_CONST(111286.26602686207/8.0), + REAL_CONST(111310.61950572141/8.0), + REAL_CONST(111334.97431671864/8.0), + REAL_CONST(111359.33045970804/8.0), + REAL_CONST(111383.68793454397/8.0), + REAL_CONST(111408.04674108078/8.0), + REAL_CONST(111432.40687917286/8.0), + REAL_CONST(111456.76834867468/8.0), + REAL_CONST(111481.13114944073/8.0), + REAL_CONST(111505.49528132551/8.0), + REAL_CONST(111529.86074418361/8.0), + REAL_CONST(111554.22753786964/8.0), + REAL_CONST(111578.59566223821/8.0), + REAL_CONST(111602.96511714405/8.0), + REAL_CONST(111627.33590244185/8.0), + REAL_CONST(111651.7080179864/8.0), + REAL_CONST(111676.08146363248/8.0), + REAL_CONST(111700.45623923496/8.0), + REAL_CONST(111724.8323446487/8.0), + REAL_CONST(111749.20977972864/8.0), + REAL_CONST(111773.58854432974/8.0), + REAL_CONST(111797.96863830699/8.0), + REAL_CONST(111822.35006151545/8.0), + REAL_CONST(111846.73281381019/8.0), + REAL_CONST(111871.11689504632/8.0), + REAL_CONST(111895.50230507903/8.0), + REAL_CONST(111919.8890437635/8.0), + REAL_CONST(111944.27711095495/8.0), + REAL_CONST(111968.6665065087/8.0), + REAL_CONST(111993.05723028004/8.0), + REAL_CONST(112017.44928212435/8.0), + REAL_CONST(112041.842661897/8.0), + REAL_CONST(112066.23736945343/8.0), + REAL_CONST(112090.63340464912/8.0), + REAL_CONST(112115.03076733962/8.0), + REAL_CONST(112139.42945738042/8.0), + REAL_CONST(112163.82947462716/8.0), + REAL_CONST(112188.23081893545/8.0), + REAL_CONST(112212.63349016097/8.0), + REAL_CONST(112237.03748815943/8.0), + REAL_CONST(112261.44281278658/8.0), + REAL_CONST(112285.84946389822/8.0), + REAL_CONST(112310.25744135017/8.0), + REAL_CONST(112334.66674499828/8.0), + REAL_CONST(112359.07737469849/8.0), + REAL_CONST(112383.48933030672/8.0), + REAL_CONST(112407.90261167898/8.0), + REAL_CONST(112432.31721867126/8.0), + REAL_CONST(112456.73315113965/8.0), + REAL_CONST(112481.15040894024/8.0), + REAL_CONST(112505.56899192919/8.0), + REAL_CONST(112529.98889996267/8.0), + REAL_CONST(112554.41013289688/8.0), + REAL_CONST(112578.8326905881/8.0), + REAL_CONST(112603.25657289263/8.0), + REAL_CONST(112627.68177966679/8.0), + REAL_CONST(112652.10831076698/8.0), + REAL_CONST(112676.53616604958/8.0), + REAL_CONST(112700.96534537108/8.0), + REAL_CONST(112725.39584858794/8.0), + REAL_CONST(112749.82767555672/8.0), + REAL_CONST(112774.26082613398/8.0), + REAL_CONST(112798.6953001763/8.0), + REAL_CONST(112823.13109754038/8.0), + REAL_CONST(112847.56821808286/8.0), + REAL_CONST(112872.00666166049/8.0), + REAL_CONST(112896.44642813003/8.0), + REAL_CONST(112920.88751734827/8.0), + REAL_CONST(112945.32992917208/8.0), + REAL_CONST(112969.77366345831/8.0), + REAL_CONST(112994.21872006389/8.0), + REAL_CONST(113018.66509884578/8.0), + REAL_CONST(113043.11279966099/8.0), + REAL_CONST(113067.56182236652/8.0), + REAL_CONST(113092.01216681948/8.0), + REAL_CONST(113116.46383287695/8.0), + REAL_CONST(113140.9168203961/8.0), + REAL_CONST(113165.37112923413/8.0), + REAL_CONST(113189.82675924824/8.0), + REAL_CONST(113214.28371029573/8.0), + REAL_CONST(113238.74198223387/8.0), + REAL_CONST(113263.20157492002/8.0), + REAL_CONST(113287.66248821157/8.0), + REAL_CONST(113312.12472196593/8.0), + REAL_CONST(113336.58827604055/8.0), + REAL_CONST(113361.05315029295/8.0), + REAL_CONST(113385.51934458067/8.0), + REAL_CONST(113409.98685876124/8.0), + REAL_CONST(113434.45569269233/8.0), + REAL_CONST(113458.92584623155/8.0), + REAL_CONST(113483.39731923661/8.0), + REAL_CONST(113507.87011156522/8.0), + REAL_CONST(113532.34422307517/8.0), + REAL_CONST(113556.81965362425/8.0), + REAL_CONST(113581.2964030703/8.0), + REAL_CONST(113605.77447127122/8.0), + REAL_CONST(113630.25385808491/8.0), + REAL_CONST(113654.73456336933/8.0), + REAL_CONST(113679.2165869825/8.0), + REAL_CONST(113703.69992878241/8.0), + REAL_CONST(113728.18458862718/8.0), + REAL_CONST(113752.67056637487/8.0), + REAL_CONST(113777.15786188368/8.0), + REAL_CONST(113801.64647501177/8.0), + REAL_CONST(113826.13640561736/8.0), + REAL_CONST(113850.62765355874/8.0), + REAL_CONST(113875.12021869418/8.0), + REAL_CONST(113899.61410088204/8.0), + REAL_CONST(113924.1092999807/8.0), + REAL_CONST(113948.60581584855/8.0), + REAL_CONST(113973.10364834407/8.0), + REAL_CONST(113997.60279732574/8.0), + REAL_CONST(114022.1032626521/8.0), + REAL_CONST(114046.60504418171/8.0), + REAL_CONST(114071.10814177318/8.0), + REAL_CONST(114095.61255528514/8.0), + REAL_CONST(114120.11828457628/8.0), + REAL_CONST(114144.62532950533/8.0), + REAL_CONST(114169.13368993104/8.0), + REAL_CONST(114193.6433657122/8.0), + REAL_CONST(114218.15435670764/8.0), + REAL_CONST(114242.66666277625/8.0), + REAL_CONST(114267.18028377694/8.0), + REAL_CONST(114291.69521956862/8.0), + REAL_CONST(114316.21147001031/8.0), + REAL_CONST(114340.72903496103/8.0), + REAL_CONST(114365.24791427983/8.0), + REAL_CONST(114389.7681078258/8.0), + REAL_CONST(114414.2896154581/8.0), + REAL_CONST(114438.81243703589/8.0), + REAL_CONST(114463.33657241837/8.0), + REAL_CONST(114487.8620214648/8.0), + REAL_CONST(114512.38878403447/8.0), + REAL_CONST(114536.91685998671/8.0), + REAL_CONST(114561.44624918087/8.0), + REAL_CONST(114585.97695147636/8.0), + REAL_CONST(114610.5089667326/8.0), + REAL_CONST(114635.04229480909/8.0), + REAL_CONST(114659.57693556532/8.0), + REAL_CONST(114684.11288886084/8.0), + REAL_CONST(114708.65015455526/8.0), + REAL_CONST(114733.18873250818/8.0), + REAL_CONST(114757.72862257928/8.0), + REAL_CONST(114782.26982462825/8.0), + REAL_CONST(114806.81233851484/8.0), + REAL_CONST(114831.35616409882/8.0), + REAL_CONST(114855.90130123998/8.0), + REAL_CONST(114880.44774979822/8.0), + REAL_CONST(114904.99550963337/8.0), + REAL_CONST(114929.5445806054/8.0), + REAL_CONST(114954.09496257425/8.0), + REAL_CONST(114978.64665539992/8.0), + REAL_CONST(115003.19965894247/8.0), + REAL_CONST(115027.75397306195/8.0), + REAL_CONST(115052.30959761847/8.0), + REAL_CONST(115076.86653247218/8.0), + REAL_CONST(115101.42477748329/8.0), + REAL_CONST(115125.984332512/8.0), + REAL_CONST(115150.54519741859/8.0), + REAL_CONST(115175.10737206334/8.0), + REAL_CONST(115199.67085630659/8.0), + REAL_CONST(115224.23565000873/8.0), + REAL_CONST(115248.80175303014/8.0), + REAL_CONST(115273.3691652313/8.0), + REAL_CONST(115297.93788647266/8.0), + REAL_CONST(115322.50791661476/8.0), + REAL_CONST(115347.07925551817/8.0), + REAL_CONST(115371.65190304347/8.0), + REAL_CONST(115396.22585905129/8.0), + REAL_CONST(115420.80112340231/8.0), + REAL_CONST(115445.37769595724/8.0), + REAL_CONST(115469.95557657682/8.0), + REAL_CONST(115494.53476512182/8.0), + REAL_CONST(115519.11526145306/8.0), + REAL_CONST(115543.69706543141/8.0), + REAL_CONST(115568.28017691776/8.0), + REAL_CONST(115592.86459577303/8.0), + REAL_CONST(115617.4503218582/8.0), + REAL_CONST(115642.03735503425/8.0), + REAL_CONST(115666.62569516223/8.0), + REAL_CONST(115691.21534210323/8.0), + REAL_CONST(115715.80629571836/8.0), + REAL_CONST(115740.39855586876/8.0), + REAL_CONST(115764.99212241563/8.0), + REAL_CONST(115789.58699522018/8.0), + REAL_CONST(115814.18317414368/8.0), + REAL_CONST(115838.78065904744/8.0), + REAL_CONST(115863.37944979276/8.0), + REAL_CONST(115887.97954624105/8.0), + REAL_CONST(115912.5809482537/8.0), + REAL_CONST(115937.18365569216/8.0), + REAL_CONST(115961.78766841792/8.0), + REAL_CONST(115986.39298629249/8.0), + REAL_CONST(116010.99960917742/8.0), + REAL_CONST(116035.60753693432/8.0), + REAL_CONST(116060.21676942479/8.0), + REAL_CONST(116084.82730651053/8.0), + REAL_CONST(116109.43914805322/8.0), + REAL_CONST(116134.0522939146/8.0), + REAL_CONST(116158.66674395646/8.0), + REAL_CONST(116183.2824980406/8.0), + REAL_CONST(116207.89955602887/8.0), + REAL_CONST(116232.51791778316/8.0), + REAL_CONST(116257.13758316539/8.0), + REAL_CONST(116281.75855203751/8.0), + REAL_CONST(116306.38082426153/8.0), + REAL_CONST(116331.00439969949/8.0), + REAL_CONST(116355.62927821343/8.0), + REAL_CONST(116380.25545966547/8.0), + REAL_CONST(116404.88294391775/8.0), + REAL_CONST(116429.51173083246/8.0), + REAL_CONST(116454.14182027178/8.0), + REAL_CONST(116478.77321209799/8.0), + REAL_CONST(116503.40590617337/8.0), + REAL_CONST(116528.03990236025/8.0), + REAL_CONST(116552.67520052097/8.0), + REAL_CONST(116577.31180051794/8.0), + REAL_CONST(116601.94970221359/8.0), + REAL_CONST(116626.5889054704/8.0), + REAL_CONST(116651.22941015086/8.0), + REAL_CONST(116675.87121611751/8.0), + REAL_CONST(116700.51432323294/8.0), + REAL_CONST(116725.15873135976/8.0), + REAL_CONST(116749.8044403606/8.0), + REAL_CONST(116774.45145009817/8.0), + REAL_CONST(116799.0997604352/8.0), + REAL_CONST(116823.74937123443/8.0), + REAL_CONST(116848.40028235866/8.0), + REAL_CONST(116873.05249367072/8.0), + REAL_CONST(116897.70600503348/8.0), + REAL_CONST(116922.36081630984/8.0), + REAL_CONST(116947.01692736275/8.0), + REAL_CONST(116971.67433805518/8.0), + REAL_CONST(116996.33304825013/8.0), + REAL_CONST(117020.99305781067/8.0), + REAL_CONST(117045.65436659988/8.0), + REAL_CONST(117070.31697448085/8.0), + REAL_CONST(117094.98088131678/8.0), + REAL_CONST(117119.64608697082/8.0), + REAL_CONST(117144.31259130624/8.0), + REAL_CONST(117168.98039418629/8.0), + REAL_CONST(117193.64949547425/8.0), + REAL_CONST(117218.31989503348/8.0), + REAL_CONST(117242.99159272734/8.0), + REAL_CONST(117267.66458841923/8.0), + REAL_CONST(117292.33888197262/8.0), + REAL_CONST(117317.01447325097/8.0), + REAL_CONST(117341.6913621178/8.0), + REAL_CONST(117366.36954843666/8.0), + REAL_CONST(117391.04903207115/8.0), + REAL_CONST(117415.72981288488/8.0), + REAL_CONST(117440.41189074152/8.0), + REAL_CONST(117465.09526550474/8.0), + REAL_CONST(117489.77993703831/8.0), + REAL_CONST(117514.46590520597/8.0), + REAL_CONST(117539.15316987153/8.0), + REAL_CONST(117563.84173089883/8.0), + REAL_CONST(117588.53158815173/8.0), + REAL_CONST(117613.22274149416/8.0), + REAL_CONST(117637.91519079007/8.0), + REAL_CONST(117662.60893590341/8.0), + REAL_CONST(117687.30397669821/8.0), + REAL_CONST(117712.00031303853/8.0), + REAL_CONST(117736.69794478847/8.0), + REAL_CONST(117761.39687181212/8.0), + REAL_CONST(117786.09709397367/8.0), + REAL_CONST(117810.7986111373/8.0), + REAL_CONST(117835.50142316725/8.0), + REAL_CONST(117860.20552992777/8.0), + REAL_CONST(117884.91093128319/8.0), + REAL_CONST(117909.6176270978/8.0), + REAL_CONST(117934.32561723603/8.0), + REAL_CONST(117959.03490156225/8.0), + REAL_CONST(117983.74547994092/8.0), + REAL_CONST(118008.45735223651/8.0), + REAL_CONST(118033.17051831353/8.0), + REAL_CONST(118057.88497803656/8.0), + REAL_CONST(118082.60073127014/8.0), + REAL_CONST(118107.31777787894/8.0), + REAL_CONST(118132.03611772758/8.0), + REAL_CONST(118156.75575068076/8.0), + REAL_CONST(118181.47667660323/8.0), + REAL_CONST(118206.19889535972/8.0), + REAL_CONST(118230.92240681504/8.0), + REAL_CONST(118255.64721083404/8.0), + REAL_CONST(118280.37330728157/8.0), + REAL_CONST(118305.10069602253/8.0), + REAL_CONST(118329.82937692189/8.0), + REAL_CONST(118354.55934984458/8.0), + REAL_CONST(118379.29061465565/8.0), + REAL_CONST(118404.02317122012/8.0), + REAL_CONST(118428.75701940308/8.0), + REAL_CONST(118453.49215906965/8.0), + REAL_CONST(118478.22859008498/8.0), + REAL_CONST(118502.96631231424/8.0), + REAL_CONST(118527.70532562268/8.0), + REAL_CONST(118552.44562987552/8.0), + REAL_CONST(118577.18722493808/8.0), + REAL_CONST(118601.93011067568/8.0), + REAL_CONST(118626.67428695368/8.0), + REAL_CONST(118651.41975363747/8.0), + REAL_CONST(118676.16651059251/8.0), + REAL_CONST(118700.91455768423/8.0), + REAL_CONST(118725.66389477813/8.0), + REAL_CONST(118750.41452173979/8.0), + REAL_CONST(118775.16643843475/8.0), + REAL_CONST(118799.91964472862/8.0), + REAL_CONST(118824.67414048707/8.0), + REAL_CONST(118849.42992557574/8.0), + REAL_CONST(118874.18699986035/8.0), + REAL_CONST(118898.94536320666/8.0), + REAL_CONST(118923.70501548045/8.0), + REAL_CONST(118948.46595654752/8.0), + REAL_CONST(118973.22818627374/8.0), + REAL_CONST(118997.99170452499/8.0), + REAL_CONST(119022.7565111672/8.0), + REAL_CONST(119047.52260606633/8.0), + REAL_CONST(119072.28998908834/8.0), + REAL_CONST(119097.0586600993/8.0), + REAL_CONST(119121.82861896523/8.0), + REAL_CONST(119146.59986555226/8.0), + REAL_CONST(119171.3723997265/8.0), + REAL_CONST(119196.14622135412/8.0), + REAL_CONST(119220.92133030134/8.0), + REAL_CONST(119245.69772643436/8.0), + REAL_CONST(119270.47540961947/8.0), + REAL_CONST(119295.25437972297/8.0), + REAL_CONST(119320.03463661121/8.0), + REAL_CONST(119344.81618015055/8.0), + REAL_CONST(119369.5990102074/8.0), + REAL_CONST(119394.38312664822/8.0), + REAL_CONST(119419.16852933947/8.0), + REAL_CONST(119443.95521814766/8.0), + REAL_CONST(119468.74319293935/8.0), + REAL_CONST(119493.53245358112/8.0), + REAL_CONST(119518.32299993958/8.0), + REAL_CONST(119543.11483188139/8.0), + REAL_CONST(119567.90794927324/8.0), + REAL_CONST(119592.70235198183/8.0), + REAL_CONST(119617.49803987393/8.0), + REAL_CONST(119642.29501281632/8.0), + REAL_CONST(119667.09327067583/8.0), + REAL_CONST(119691.89281331931/8.0), + REAL_CONST(119716.69364061367/8.0), + REAL_CONST(119741.49575242582/8.0), + REAL_CONST(119766.29914862274/8.0), + REAL_CONST(119791.10382907141/8.0), + REAL_CONST(119815.90979363887/8.0), + REAL_CONST(119840.71704219218/8.0), + REAL_CONST(119865.52557459843/8.0), + REAL_CONST(119890.33539072477/8.0), + REAL_CONST(119915.14649043836/8.0), + REAL_CONST(119939.95887360642/8.0), + REAL_CONST(119964.77254009615/8.0), + REAL_CONST(119989.58748977486/8.0), + REAL_CONST(120014.40372250983/8.0), + REAL_CONST(120039.22123816841/8.0), + REAL_CONST(120064.04003661797/8.0), + REAL_CONST(120088.86011772591/8.0), + REAL_CONST(120113.6814813597/8.0), + REAL_CONST(120138.5041273868/8.0), + REAL_CONST(120163.3280556747/8.0), + REAL_CONST(120188.15326609099/8.0), + REAL_CONST(120212.97975850321/8.0), + REAL_CONST(120237.807532779/8.0), + REAL_CONST(120262.63658878599/8.0), + REAL_CONST(120287.46692639188/8.0), + REAL_CONST(120312.29854546436/8.0), + REAL_CONST(120337.13144587121/8.0), + REAL_CONST(120361.9656274802/8.0), + REAL_CONST(120386.80109015915/8.0), + REAL_CONST(120411.63783377589/8.0), + REAL_CONST(120436.47585819835/8.0), + REAL_CONST(120461.31516329442/8.0), + REAL_CONST(120486.15574893207/8.0), + REAL_CONST(120510.99761497928/8.0), + REAL_CONST(120535.84076130406/8.0), + REAL_CONST(120560.68518777451/8.0), + REAL_CONST(120585.53089425867/8.0), + REAL_CONST(120610.3778806247/8.0), + REAL_CONST(120635.22614674074/8.0), + REAL_CONST(120660.07569247499/8.0), + REAL_CONST(120684.92651769568/8.0), + REAL_CONST(120709.77862227106/8.0), + REAL_CONST(120734.63200606944/8.0), + REAL_CONST(120759.48666895913/8.0), + REAL_CONST(120784.3426108085/8.0), + REAL_CONST(120809.19983148595/8.0), + REAL_CONST(120834.05833085992/8.0), + REAL_CONST(120858.91810879884/8.0), + REAL_CONST(120883.77916517125/8.0), + REAL_CONST(120908.64149984565/8.0), + REAL_CONST(120933.5051126906/8.0), + REAL_CONST(120958.37000357473/8.0), + REAL_CONST(120983.23617236665/8.0), + REAL_CONST(121008.10361893504/8.0), + REAL_CONST(121032.97234314861/8.0), + REAL_CONST(121057.84234487606/8.0), + REAL_CONST(121082.71362398617/8.0), + REAL_CONST(121107.58618034775/8.0), + REAL_CONST(121132.46001382964/8.0), + REAL_CONST(121157.33512430069/8.0), + REAL_CONST(121182.21151162982/8.0), + REAL_CONST(121207.08917568595/8.0), + REAL_CONST(121231.96811633807/8.0), + REAL_CONST(121256.84833345517/8.0), + REAL_CONST(121281.72982690629/8.0), + REAL_CONST(121306.61259656049/8.0), + REAL_CONST(121331.49664228689/8.0), + REAL_CONST(121356.38196395461/8.0), + REAL_CONST(121381.26856143285/8.0), + REAL_CONST(121406.15643459078/8.0), + REAL_CONST(121431.04558329767/8.0), + REAL_CONST(121455.93600742276/8.0), + REAL_CONST(121480.82770683538/8.0), + REAL_CONST(121505.72068140487/8.0), + REAL_CONST(121530.61493100057/8.0), + REAL_CONST(121555.51045549192/8.0), + REAL_CONST(121580.40725474835/8.0), + REAL_CONST(121605.30532863933/8.0), + REAL_CONST(121630.20467703436/8.0), + REAL_CONST(121655.10529980299/8.0), + REAL_CONST(121680.00719681478/8.0), + REAL_CONST(121704.91036793934/8.0), + REAL_CONST(121729.81481304632/8.0), + REAL_CONST(121754.72053200539/8.0), + REAL_CONST(121779.62752468624/8.0), + REAL_CONST(121804.53579095862/8.0), + REAL_CONST(121829.44533069231/8.0), + REAL_CONST(121854.3561437571/8.0), + REAL_CONST(121879.26823002285/8.0), + REAL_CONST(121904.1815893594/8.0), + REAL_CONST(121929.09622163669/8.0), + REAL_CONST(121954.01212672464/8.0), + REAL_CONST(121978.92930449323/8.0), + REAL_CONST(122003.84775481246/8.0), + REAL_CONST(122028.76747755238/8.0), + REAL_CONST(122053.68847258303/8.0), + REAL_CONST(122078.61073977455/8.0), + REAL_CONST(122103.53427899707/8.0), + REAL_CONST(122128.45909012076/8.0), + REAL_CONST(122153.38517301581/8.0), + REAL_CONST(122178.31252755247/8.0), + REAL_CONST(122203.24115360099/8.0), + REAL_CONST(122228.17105103172/8.0), + REAL_CONST(122253.10221971494/8.0), + REAL_CONST(122278.03465952107/8.0), + REAL_CONST(122302.96837032049/8.0), + REAL_CONST(122327.90335198362/8.0), + REAL_CONST(122352.83960438096/8.0), + REAL_CONST(122377.777127383/8.0), + REAL_CONST(122402.71592086025/8.0), + REAL_CONST(122427.65598468333/8.0), + REAL_CONST(122452.59731872278/8.0), + REAL_CONST(122477.53992284928/8.0), + REAL_CONST(122502.48379693348/8.0), + REAL_CONST(122527.42894084606/8.0), + REAL_CONST(122552.37535445779/8.0), + REAL_CONST(122577.32303763942/8.0), + REAL_CONST(122602.27199026172/8.0), + REAL_CONST(122627.22221219557/8.0), + REAL_CONST(122652.17370331181/8.0), + REAL_CONST(122677.12646348133/8.0), + REAL_CONST(122702.08049257506/8.0), + REAL_CONST(122727.03579046397/8.0), + REAL_CONST(122751.99235701906/8.0), + REAL_CONST(122776.95019211136/8.0), + REAL_CONST(122801.9092956119/8.0), + REAL_CONST(122826.8696673918/8.0), + REAL_CONST(122851.83130732219/8.0), + REAL_CONST(122876.79421527422/8.0), + REAL_CONST(122901.75839111909/8.0), + REAL_CONST(122926.72383472799/8.0), + REAL_CONST(122951.69054597223/8.0), + REAL_CONST(122976.65852472307/8.0), + REAL_CONST(123001.62777085182/8.0), + REAL_CONST(123026.59828422987/8.0), + REAL_CONST(123051.57006472857/8.0), + REAL_CONST(123076.54311221937/8.0), + REAL_CONST(123101.5174265737/8.0), + REAL_CONST(123126.49300766307/8.0), + REAL_CONST(123151.46985535898/8.0), + REAL_CONST(123176.44796953299/8.0), + REAL_CONST(123201.42735005668/8.0), + REAL_CONST(123226.40799680166/8.0), + REAL_CONST(123251.38990963959/8.0), + REAL_CONST(123276.37308844214/8.0), + REAL_CONST(123301.35753308103/8.0), + REAL_CONST(123326.343243428/8.0), + REAL_CONST(123351.33021935483/8.0), + REAL_CONST(123376.31846073334/8.0), + REAL_CONST(123401.30796743535/8.0), + REAL_CONST(123426.29873933276/8.0), + REAL_CONST(123451.29077629748/8.0), + REAL_CONST(123476.28407820144/8.0), + REAL_CONST(123501.2786449166/8.0), + REAL_CONST(123526.27447631498/8.0), + REAL_CONST(123551.27157226863/8.0), + REAL_CONST(123576.26993264959/8.0), + REAL_CONST(123601.26955732999/8.0), + REAL_CONST(123626.27044618195/8.0), + REAL_CONST(123651.27259907764/8.0), + REAL_CONST(123676.27601588926/8.0), + REAL_CONST(123701.28069648903/8.0), + REAL_CONST(123726.28664074924/8.0), + REAL_CONST(123751.29384854218/8.0), + REAL_CONST(123776.30231974016/8.0), + REAL_CONST(123801.31205421555/8.0), + REAL_CONST(123826.32305184075/8.0), + REAL_CONST(123851.33531248817/8.0), + REAL_CONST(123876.34883603029/8.0), + REAL_CONST(123901.36362233957/8.0), + REAL_CONST(123926.37967128855/8.0), + REAL_CONST(123951.39698274979/8.0), + REAL_CONST(123976.41555659588/8.0), + REAL_CONST(124001.43539269941/8.0), + REAL_CONST(124026.45649093305/8.0), + REAL_CONST(124051.47885116948/8.0), + REAL_CONST(124076.50247328142/8.0), + REAL_CONST(124101.5273571416/8.0), + REAL_CONST(124126.55350262282/8.0), + REAL_CONST(124151.58090959788/8.0), + REAL_CONST(124176.60957793961/8.0), + REAL_CONST(124201.63950752091/8.0), + REAL_CONST(124226.67069821467/8.0), + REAL_CONST(124251.70314989384/8.0), + REAL_CONST(124276.73686243138/8.0), + REAL_CONST(124301.7718357003/8.0), + REAL_CONST(124326.80806957364/8.0), + REAL_CONST(124351.84556392446/8.0), + REAL_CONST(124376.88431862585/8.0), + REAL_CONST(124401.92433355095/8.0), + REAL_CONST(124426.96560857294/8.0), + REAL_CONST(124452.00814356498/8.0), + REAL_CONST(124477.05193840031/8.0), + REAL_CONST(124502.0969929522/8.0), + REAL_CONST(124527.14330709392/8.0), + REAL_CONST(124552.19088069882/8.0), + REAL_CONST(124577.23971364023/8.0), + REAL_CONST(124602.28980579154/8.0), + REAL_CONST(124627.34115702618/8.0), + REAL_CONST(124652.3937672176/8.0), + REAL_CONST(124677.44763623926/8.0), + REAL_CONST(124702.50276396469/8.0), + REAL_CONST(124727.55915026742/8.0), + REAL_CONST(124752.61679502104/8.0), + REAL_CONST(124777.67569809916/8.0), + REAL_CONST(124802.73585937542/8.0), + REAL_CONST(124827.79727872348/8.0), + REAL_CONST(124852.85995601704/8.0), + REAL_CONST(124877.92389112986/8.0), + REAL_CONST(124902.98908393568/8.0), + REAL_CONST(124928.05553430831/8.0), + REAL_CONST(124953.1232421216/8.0), + REAL_CONST(124978.19220724938/8.0), + REAL_CONST(125003.26242956554/8.0), + REAL_CONST(125028.33390894404/8.0), + REAL_CONST(125053.40664525882/8.0), + REAL_CONST(125078.48063838384/8.0), + REAL_CONST(125103.55588819318/8.0), + REAL_CONST(125128.63239456083/8.0), + REAL_CONST(125153.71015736091/8.0), + REAL_CONST(125178.78917646752/8.0), + REAL_CONST(125203.86945175481/8.0), + REAL_CONST(125228.95098309696/8.0), + REAL_CONST(125254.03377036817/8.0), + REAL_CONST(125279.1178134427/8.0), + REAL_CONST(125304.20311219479/8.0), + REAL_CONST(125329.28966649878/8.0), + REAL_CONST(125354.37747622898/8.0), + REAL_CONST(125379.46654125977/8.0), + REAL_CONST(125404.55686146552/8.0), + REAL_CONST(125429.6484367207/8.0), + REAL_CONST(125454.74126689974/8.0), + REAL_CONST(125479.83535187715/8.0), + REAL_CONST(125504.93069152744/8.0), + REAL_CONST(125530.02728572517/8.0), + REAL_CONST(125555.12513434493/8.0), + REAL_CONST(125580.22423726133/8.0), + REAL_CONST(125605.32459434902/8.0), + REAL_CONST(125630.4262054827/8.0), + REAL_CONST(125655.52907053704/8.0), + REAL_CONST(125680.63318938682/8.0), + REAL_CONST(125705.73856190679/8.0), + REAL_CONST(125730.84518797178/8.0), + REAL_CONST(125755.9530674566/8.0), + REAL_CONST(125781.06220023613/8.0), + REAL_CONST(125806.17258618528/8.0), + REAL_CONST(125831.28422517896/8.0), + REAL_CONST(125856.39711709213/8.0), + REAL_CONST(125881.51126179981/8.0), + REAL_CONST(125906.62665917698/8.0), + REAL_CONST(125931.74330909875/8.0), + REAL_CONST(125956.86121144016/8.0), + REAL_CONST(125981.98036607634/8.0), + REAL_CONST(126007.10077288245/8.0), + REAL_CONST(126032.22243173365/8.0), + REAL_CONST(126057.34534250517/8.0), + REAL_CONST(126082.46950507225/8.0), + REAL_CONST(126107.59491931014/8.0), + REAL_CONST(126132.72158509417/8.0), + REAL_CONST(126157.84950229966/8.0), + REAL_CONST(126182.97867080198/8.0), + REAL_CONST(126208.10909047653/8.0), + REAL_CONST(126233.24076119871/8.0), + REAL_CONST(126258.37368284403/8.0), + REAL_CONST(126283.50785528794/8.0), + REAL_CONST(126308.64327840599/8.0), + REAL_CONST(126333.77995207369/8.0), + REAL_CONST(126358.91787616667/8.0), + REAL_CONST(126384.0570505605/8.0), + REAL_CONST(126409.19747513086/8.0), + REAL_CONST(126434.3391497534/8.0), + REAL_CONST(126459.48207430386/8.0), + REAL_CONST(126484.62624865794/8.0), + REAL_CONST(126509.77167269142/8.0), + REAL_CONST(126534.9183462801/8.0), + REAL_CONST(126560.06626929982/8.0), + REAL_CONST(126585.21544162642/8.0), + REAL_CONST(126610.36586313581/8.0), + REAL_CONST(126635.51753370393/8.0), + REAL_CONST(126660.67045320668/8.0), + REAL_CONST(126685.82462152008/8.0), + REAL_CONST(126710.98003852014/8.0), + REAL_CONST(126736.13670408291/8.0), + REAL_CONST(126761.29461808444/8.0), + REAL_CONST(126786.45378040087/8.0), + REAL_CONST(126811.61419090834/8.0), + REAL_CONST(126836.77584948298/8.0), + REAL_CONST(126861.93875600102/8.0), + REAL_CONST(126887.10291033868/8.0), + REAL_CONST(126912.26831237224/8.0), + REAL_CONST(126937.43496197795/8.0), + REAL_CONST(126962.60285903217/8.0), + REAL_CONST(126987.77200341123/8.0), + REAL_CONST(127012.94239499152/8.0), + REAL_CONST(127038.11403364947/8.0), + REAL_CONST(127063.2869192615/8.0), + REAL_CONST(127088.46105170409/8.0), + REAL_CONST(127113.63643085376/8.0), + REAL_CONST(127138.81305658702/8.0), + REAL_CONST(127163.99092878048/8.0), + REAL_CONST(127189.17004731069/8.0), + REAL_CONST(127214.35041205429/8.0), + REAL_CONST(127239.53202288797/8.0), + REAL_CONST(127264.71487968838/8.0), + REAL_CONST(127289.89898233226/8.0), + REAL_CONST(127315.08433069635/8.0), + REAL_CONST(127340.27092465744/8.0), + REAL_CONST(127365.45876409234/8.0), + REAL_CONST(127390.64784887788/8.0), + REAL_CONST(127415.83817889093/8.0), + REAL_CONST(127441.02975400841/8.0), + REAL_CONST(127466.22257410725/8.0), + REAL_CONST(127491.41663906439/8.0), + REAL_CONST(127516.61194875685/8.0), + REAL_CONST(127541.80850306165/8.0), + REAL_CONST(127567.00630185583/8.0), + REAL_CONST(127592.20534501647/8.0), + REAL_CONST(127617.4056324207/8.0), + REAL_CONST(127642.60716394568/8.0), + REAL_CONST(127667.80993946856/8.0), + REAL_CONST(127693.01395886653/8.0), + REAL_CONST(127718.21922201688/8.0), + REAL_CONST(127743.42572879682/8.0), + REAL_CONST(127768.63347908368/8.0), + REAL_CONST(127793.84247275478/8.0), + REAL_CONST(127819.05270968749/8.0), + REAL_CONST(127844.26418975917/8.0), + REAL_CONST(127869.47691284724/8.0), + REAL_CONST(127894.69087882918/8.0), + REAL_CONST(127919.90608758242/8.0), + REAL_CONST(127945.12253898452/8.0), + REAL_CONST(127970.34023291297/8.0), + REAL_CONST(127995.55916924537/8.0), + REAL_CONST(128020.77934785932/8.0), + REAL_CONST(128046.00076863244/8.0), + REAL_CONST(128071.22343144237/8.0), + REAL_CONST(128096.44733616684/8.0), + REAL_CONST(128121.67248268353/8.0), + REAL_CONST(128146.89887087021/8.0), + REAL_CONST(128172.12650060465/8.0), + REAL_CONST(128197.35537176467/8.0), + REAL_CONST(128222.5854842281/8.0), + REAL_CONST(128247.81683787282/8.0), + REAL_CONST(128273.04943257671/8.0), + REAL_CONST(128298.28326821771/8.0), + REAL_CONST(128323.51834467379/8.0), + REAL_CONST(128348.75466182294/8.0), + REAL_CONST(128373.99221954317/8.0), + REAL_CONST(128399.23101771252/8.0), + REAL_CONST(128424.47105620909/8.0), + REAL_CONST(128449.71233491098/8.0), + REAL_CONST(128474.95485369631/8.0), + REAL_CONST(128500.19861244329/8.0), + REAL_CONST(128525.44361103009/8.0), + REAL_CONST(128550.68984933494/8.0), + REAL_CONST(128575.93732723613/8.0), + REAL_CONST(128601.18604461191/8.0), + REAL_CONST(128626.43600134061/8.0), + REAL_CONST(128651.68719730059/8.0), + REAL_CONST(128676.93963237021/8.0), + REAL_CONST(128702.1933064279/8.0), + REAL_CONST(128727.44821935208/8.0), + REAL_CONST(128752.70437102125/8.0), + REAL_CONST(128777.96176131385/8.0), + REAL_CONST(128803.22039010846/8.0), + REAL_CONST(128828.48025728362/8.0), + REAL_CONST(128853.74136271792/8.0), + REAL_CONST(128879.00370628996/8.0), + REAL_CONST(128904.26728787841/8.0), + REAL_CONST(128929.53210736193/8.0), + REAL_CONST(128954.79816461923/8.0), + REAL_CONST(128980.06545952905/8.0), + REAL_CONST(129005.33399197015/8.0), + REAL_CONST(129030.60376182134/8.0), + REAL_CONST(129055.87476896142/8.0), + REAL_CONST(129081.14701326926/8.0), + REAL_CONST(129106.42049462376/8.0), + REAL_CONST(129131.6952129038/8.0), + REAL_CONST(129156.97116798835/8.0), + REAL_CONST(129182.24835975636/8.0), + REAL_CONST(129207.52678808685/8.0), + REAL_CONST(129232.80645285884/8.0), + REAL_CONST(129258.08735395141/8.0), + REAL_CONST(129283.36949124365/8.0), + REAL_CONST(129308.65286461466/8.0), + REAL_CONST(129333.9374739436/8.0), + REAL_CONST(129359.22331910966/8.0), + REAL_CONST(129384.51039999202/8.0), + REAL_CONST(129409.79871646997/8.0), + REAL_CONST(129435.08826842274/8.0), + REAL_CONST(129460.37905572963/8.0), + REAL_CONST(129485.67107826998/8.0), + REAL_CONST(129510.96433592314/8.0), + REAL_CONST(129536.25882856851/8.0), + REAL_CONST(129561.55455608548/8.0), + REAL_CONST(129586.85151835352/8.0), + REAL_CONST(129612.14971525209/8.0), + REAL_CONST(129637.4491466607/8.0), + REAL_CONST(129662.74981245887/8.0), + REAL_CONST(129688.0517125262/8.0), + REAL_CONST(129713.35484674224/8.0), + REAL_CONST(129738.65921498663/8.0), + REAL_CONST(129763.96481713903/8.0), + REAL_CONST(129789.27165307909/8.0), + REAL_CONST(129814.57972268655/8.0), + REAL_CONST(129839.88902584116/8.0), + REAL_CONST(129865.19956242264/8.0), + REAL_CONST(129890.51133231082/8.0), + REAL_CONST(129915.82433538554/8.0), + REAL_CONST(129941.13857152662/8.0), + REAL_CONST(129966.45404061397/8.0), + REAL_CONST(129991.7707425275/8.0), + REAL_CONST(130017.08867714716/8.0), + REAL_CONST(130042.4078443529/8.0), + REAL_CONST(130067.72824402474/8.0), + REAL_CONST(130093.04987604271/8.0), + REAL_CONST(130118.37274028687/8.0), + REAL_CONST(130143.69683663732/8.0), + REAL_CONST(130169.02216497416/8.0), + REAL_CONST(130194.34872517755/8.0), + REAL_CONST(130219.67651712766/8.0), + REAL_CONST(130245.0055407047/8.0), + REAL_CONST(130270.33579578891/8.0), + REAL_CONST(130295.66728226055/8.0), + REAL_CONST(130320.99999999991/8.0), + REAL_CONST(130346.33394888733/8.0), + REAL_CONST(130371.66912880314/8.0), + REAL_CONST(130397.00553962773/8.0), + REAL_CONST(130422.34318124152/8.0), + REAL_CONST(130447.68205352494/8.0), + REAL_CONST(130473.02215635845/8.0), + REAL_CONST(130498.36348962256/8.0), + REAL_CONST(130523.70605319779/8.0), + REAL_CONST(130549.0498469647/8.0), + REAL_CONST(130574.39487080388/8.0), + REAL_CONST(130599.74112459592/8.0), + REAL_CONST(130625.08860822149/8.0), + REAL_CONST(130650.43732156123/8.0), + REAL_CONST(130675.78726449587/8.0), + REAL_CONST(130701.13843690613/8.0), + REAL_CONST(130726.49083867275/8.0), + REAL_CONST(130751.84446967654/8.0), + REAL_CONST(130777.19932979831/8.0), + REAL_CONST(130802.5554189189/8.0), + REAL_CONST(130827.91273691918/8.0), + REAL_CONST(130853.27128368006/8.0), + REAL_CONST(130878.63105908247/8.0), + REAL_CONST(130903.99206300738/8.0), + REAL_CONST(130929.35429533575/8.0), + REAL_CONST(130954.71775594862/8.0), + REAL_CONST(130980.08244472703/8.0), + REAL_CONST(131005.44836155206/8.0), + REAL_CONST(131030.81550630482/8.0), + REAL_CONST(131056.18387886642/8.0), + REAL_CONST(131081.55347911804/8.0), + REAL_CONST(131106.92430694087/8.0), + REAL_CONST(131132.29636221612/8.0), + REAL_CONST(131157.66964482504/8.0), + REAL_CONST(131183.0441546489/8.0), + REAL_CONST(131208.41989156904/8.0), + REAL_CONST(131233.79685546676/8.0), + REAL_CONST(131259.17504622342/8.0), + REAL_CONST(131284.55446372041/8.0), + REAL_CONST(131309.93510783918/8.0), + REAL_CONST(131335.31697846117/8.0), + REAL_CONST(131360.70007546784/8.0), + REAL_CONST(131386.0843987407/8.0), + REAL_CONST(131411.46994816128/8.0), + REAL_CONST(131436.85672361116/8.0), + REAL_CONST(131462.24472497194/8.0), + REAL_CONST(131487.63395212521/8.0), + REAL_CONST(131513.02440495262/8.0), + REAL_CONST(131538.41608333588/8.0), + REAL_CONST(131563.80898715663/8.0), + REAL_CONST(131589.2031162967/8.0), + REAL_CONST(131614.59847063778/8.0), + REAL_CONST(131639.9950500617/8.0), + REAL_CONST(131665.39285445024/8.0), + REAL_CONST(131690.79188368531/8.0), + REAL_CONST(131716.19213764873/8.0), + REAL_CONST(131741.59361622241/8.0), + REAL_CONST(131766.99631928833/8.0), + REAL_CONST(131792.40024672839/8.0), + REAL_CONST(131817.80539842462/8.0), + REAL_CONST(131843.21177425905/8.0), + REAL_CONST(131868.61937411371/8.0), + REAL_CONST(131894.02819787065/8.0), + REAL_CONST(131919.43824541202/8.0), + REAL_CONST(131944.84951661993/8.0), + REAL_CONST(131970.26201137656/8.0), + REAL_CONST(131995.67572956407/8.0), + REAL_CONST(132021.09067106468/8.0), + REAL_CONST(132046.50683576067/8.0), + REAL_CONST(132071.9242235343/8.0), + REAL_CONST(132097.34283426782/8.0), + REAL_CONST(132122.76266784366/8.0), + REAL_CONST(132148.1837241441/8.0), + REAL_CONST(132173.60600305157/8.0), + REAL_CONST(132199.02950444847/8.0), + REAL_CONST(132224.45422821722/8.0), + REAL_CONST(132249.88017424036/8.0), + REAL_CONST(132275.30734240031/8.0), + REAL_CONST(132300.73573257966/8.0), + REAL_CONST(132326.16534466096/8.0), + REAL_CONST(132351.59617852676/8.0), + REAL_CONST(132377.02823405969/8.0), + REAL_CONST(132402.46151114244/8.0), + REAL_CONST(132427.89600965759/8.0), + REAL_CONST(132453.33172948789/8.0), + REAL_CONST(132478.76867051609/8.0), + REAL_CONST(132504.20683262491/8.0), + REAL_CONST(132529.64621569714/8.0), + REAL_CONST(132555.08681961559/8.0), + REAL_CONST(132580.5286442631/8.0), + REAL_CONST(132605.97168952253/8.0), + REAL_CONST(132631.41595527678/8.0), + REAL_CONST(132656.86144140881/8.0), + REAL_CONST(132682.30814780149/8.0), + REAL_CONST(132707.75607433787/8.0), + REAL_CONST(132733.20522090094/8.0), + REAL_CONST(132758.65558737374/8.0), + REAL_CONST(132784.10717363929/8.0), + REAL_CONST(132809.55997958075/8.0), + REAL_CONST(132835.01400508118/8.0), + REAL_CONST(132860.46925002377/8.0), + REAL_CONST(132885.92571429166/8.0), + REAL_CONST(132911.38339776811/8.0), + REAL_CONST(132936.84230033628/8.0), + REAL_CONST(132962.30242187946/8.0), + REAL_CONST(132987.76376228096/8.0), + REAL_CONST(133013.22632142407/8.0), + REAL_CONST(133038.69009919214/8.0), + REAL_CONST(133064.15509546854/8.0), + REAL_CONST(133089.62131013666/8.0), + REAL_CONST(133115.08874307995/8.0), + REAL_CONST(133140.55739418184/8.0), + REAL_CONST(133166.02726332581/8.0), + REAL_CONST(133191.49835039541/8.0), + REAL_CONST(133216.97065527414/8.0), + REAL_CONST(133242.44417784561/8.0), + REAL_CONST(133267.91891799335/8.0), + REAL_CONST(133293.39487560102/8.0), + REAL_CONST(133318.87205055228/8.0), + REAL_CONST(133344.35044273079/8.0), + REAL_CONST(133369.83005202023/8.0), + REAL_CONST(133395.31087830439/8.0), + REAL_CONST(133420.79292146701/8.0), + REAL_CONST(133446.27618139185/8.0), + REAL_CONST(133471.76065796276/8.0), + REAL_CONST(133497.24635106357/8.0), + REAL_CONST(133522.73326057816/8.0), + REAL_CONST(133548.22138639039/8.0), + REAL_CONST(133573.71072838426/8.0), + REAL_CONST(133599.20128644365/8.0), + REAL_CONST(133624.69306045261/8.0), + REAL_CONST(133650.1860502951/8.0), + REAL_CONST(133675.68025585517/8.0), + REAL_CONST(133701.1756770169/8.0), + REAL_CONST(133726.67231366437/8.0), + REAL_CONST(133752.17016568172/8.0), + REAL_CONST(133777.66923295305/8.0), + REAL_CONST(133803.16951536259/8.0), + REAL_CONST(133828.67101279454/8.0), + REAL_CONST(133854.17372513309/8.0), + REAL_CONST(133879.67765226253/8.0), + REAL_CONST(133905.18279406714/8.0), + REAL_CONST(133930.68915043125/8.0), + REAL_CONST(133956.19672123916/8.0), + REAL_CONST(133981.70550637526/8.0), + REAL_CONST(134007.21550572399/8.0), + REAL_CONST(134032.7267191697/8.0), + REAL_CONST(134058.23914659687/8.0), + REAL_CONST(134083.75278789/8.0), + REAL_CONST(134109.26764293358/8.0), + REAL_CONST(134134.78371161217/8.0), + REAL_CONST(134160.30099381026/8.0), + REAL_CONST(134185.8194894125/8.0), + REAL_CONST(134211.33919830353/8.0), + REAL_CONST(134236.8601203679/8.0), + REAL_CONST(134262.38225549037/8.0), + REAL_CONST(134287.90560355558/8.0), + REAL_CONST(134313.43016444831/8.0), + REAL_CONST(134338.95593805326/8.0), + REAL_CONST(134364.48292425525/8.0), + REAL_CONST(134390.01112293909/8.0), + REAL_CONST(134415.54053398955/8.0), + REAL_CONST(134441.07115729159/8.0), + REAL_CONST(134466.60299273001/8.0), + REAL_CONST(134492.1360401898/8.0), + REAL_CONST(134517.67029955584/8.0), + REAL_CONST(134543.20577071316/8.0), + REAL_CONST(134568.74245354676/8.0), + REAL_CONST(134594.28034794159/8.0), + REAL_CONST(134619.81945378278/8.0), + REAL_CONST(134645.35977095537/8.0), + REAL_CONST(134670.90129934452/8.0), + REAL_CONST(134696.4440388353/8.0), + REAL_CONST(134721.98798931291/8.0), + REAL_CONST(134747.53315066252/8.0), + REAL_CONST(134773.07952276937/8.0), + REAL_CONST(134798.62710551871/8.0), + REAL_CONST(134824.17589879577/8.0), + REAL_CONST(134849.72590248589/8.0), + REAL_CONST(134875.27711647438/8.0), + REAL_CONST(134900.82954064661/8.0), + REAL_CONST(134926.38317488792/8.0), + REAL_CONST(134951.93801908373/8.0), + REAL_CONST(134977.49407311951/8.0), + REAL_CONST(135003.05133688069/8.0), + REAL_CONST(135028.60981025276/8.0), + REAL_CONST(135054.16949312127/8.0), + REAL_CONST(135079.73038537172/8.0), + REAL_CONST(135105.29248688967/8.0), + REAL_CONST(135130.85579756077/8.0), + REAL_CONST(135156.42031727062/8.0), + REAL_CONST(135181.98604590484/8.0), + REAL_CONST(135207.55298334916/8.0), + REAL_CONST(135233.12112948924/8.0), + REAL_CONST(135258.69048421088/8.0), + REAL_CONST(135284.26104739975/8.0), + REAL_CONST(135309.83281894168/8.0), + REAL_CONST(135335.4057987225/8.0), + REAL_CONST(135360.97998662802/8.0), + REAL_CONST(135386.55538254412/8.0), + REAL_CONST(135412.13198635669/8.0), + REAL_CONST(135437.70979795168/8.0), + REAL_CONST(135463.28881721498/8.0), + REAL_CONST(135488.86904403262/8.0), + REAL_CONST(135514.45047829056/8.0), + REAL_CONST(135540.03311987486/8.0), + REAL_CONST(135565.61696867159/8.0), + REAL_CONST(135591.20202456677/8.0), + REAL_CONST(135616.78828744654/8.0), + REAL_CONST(135642.37575719706/8.0), + REAL_CONST(135667.96443370447/8.0), + REAL_CONST(135693.55431685498/8.0), + REAL_CONST(135719.14540653475/8.0), + REAL_CONST(135744.73770263011/8.0), + REAL_CONST(135770.33120502727/8.0), + REAL_CONST(135795.92591361253/8.0), + REAL_CONST(135821.52182827223/8.0), + REAL_CONST(135847.11894889272/8.0), + REAL_CONST(135872.7172753604/8.0), + REAL_CONST(135898.31680756161/8.0), + REAL_CONST(135923.91754538284/8.0), + REAL_CONST(135949.51948871053/8.0), + REAL_CONST(135975.12263743114/8.0), + REAL_CONST(136000.72699143123/8.0), + REAL_CONST(136026.33255059729/8.0), + REAL_CONST(136051.93931481591/8.0), + REAL_CONST(136077.54728397369/8.0), + REAL_CONST(136103.15645795723/8.0), + REAL_CONST(136128.76683665317/8.0), + REAL_CONST(136154.37841994822/8.0), + REAL_CONST(136179.99120772901/8.0), + REAL_CONST(136205.60519988232/8.0), + REAL_CONST(136231.2203962949/8.0), + REAL_CONST(136256.83679685349/8.0), + REAL_CONST(136282.45440144493/8.0), + REAL_CONST(136308.07320995603/8.0), + REAL_CONST(136333.69322227367/8.0), + REAL_CONST(136359.31443828469/8.0), + REAL_CONST(136384.93685787608/8.0), + REAL_CONST(136410.56048093468/8.0), + REAL_CONST(136436.18530734754/8.0), + REAL_CONST(136461.81133700156/8.0), + REAL_CONST(136487.43856978384/8.0), + REAL_CONST(136513.06700558143/8.0), + REAL_CONST(136538.6966442813/8.0), + REAL_CONST(136564.32748577066/8.0), + REAL_CONST(136589.95952993655/8.0), + REAL_CONST(136615.59277666616/8.0), + REAL_CONST(136641.22722584667/8.0), + REAL_CONST(136666.86287736523/8.0), + REAL_CONST(136692.49973110916/8.0), + REAL_CONST(136718.13778696564/8.0), + REAL_CONST(136743.77704482197/8.0), + REAL_CONST(136769.41750456547/8.0), + REAL_CONST(136795.05916608346/8.0), + REAL_CONST(136820.70202926331/8.0), + REAL_CONST(136846.34609399244/8.0), + REAL_CONST(136871.99136015819/8.0), + REAL_CONST(136897.63782764805/8.0), + REAL_CONST(136923.28549634948/8.0), + REAL_CONST(136948.93436614997/8.0), + REAL_CONST(136974.58443693706/8.0), + REAL_CONST(137000.23570859825/8.0), + REAL_CONST(137025.88818102115/8.0), + REAL_CONST(137051.54185409332/8.0), + REAL_CONST(137077.19672770242/8.0), + REAL_CONST(137102.85280173609/8.0), + REAL_CONST(137128.51007608202/8.0), + REAL_CONST(137154.16855062786/8.0), + REAL_CONST(137179.82822526142/8.0), + REAL_CONST(137205.48909987041/8.0), + REAL_CONST(137231.15117434258/8.0), + REAL_CONST(137256.8144485658/8.0), + REAL_CONST(137282.47892242789/8.0), + REAL_CONST(137308.14459581667/8.0), + REAL_CONST(137333.81146862009/8.0), + REAL_CONST(137359.47954072602/8.0), + REAL_CONST(137385.14881202241/8.0), + REAL_CONST(137410.81928239719/8.0), + REAL_CONST(137436.49095173844/8.0), + REAL_CONST(137462.16381993407/8.0), + REAL_CONST(137487.83788687221/8.0), + REAL_CONST(137513.51315244089/8.0), + REAL_CONST(137539.18961652822/8.0), + REAL_CONST(137564.86727902229/8.0), + REAL_CONST(137590.54613981131/8.0), + REAL_CONST(137616.22619878338/8.0), + REAL_CONST(137641.90745582676/8.0), + REAL_CONST(137667.58991082967/8.0), + REAL_CONST(137693.27356368033/8.0), + REAL_CONST(137718.95841426702/8.0), + REAL_CONST(137744.64446247809/8.0), + REAL_CONST(137770.33170820182/8.0), + REAL_CONST(137796.02015132661/8.0), + REAL_CONST(137821.70979174081/8.0), + REAL_CONST(137847.40062933284/8.0), + REAL_CONST(137873.09266399115/8.0), + REAL_CONST(137898.78589560417/8.0), + REAL_CONST(137924.48032406042/8.0), + REAL_CONST(137950.17594924837/8.0), + REAL_CONST(137975.8727710566/8.0), + REAL_CONST(138001.57078937365/8.0), + REAL_CONST(138027.27000408815/8.0), + REAL_CONST(138052.97041508864/8.0), + REAL_CONST(138078.67202226384/8.0), + REAL_CONST(138104.3748255024/8.0), + REAL_CONST(138130.07882469296/8.0), + REAL_CONST(138155.78401972432/8.0), + REAL_CONST(138181.49041048516/8.0), + REAL_CONST(138207.1979968643/8.0), + REAL_CONST(138232.9067787505/8.0), + REAL_CONST(138258.61675603263/8.0), + REAL_CONST(138284.32792859949/8.0), + REAL_CONST(138310.04029633995/8.0), + REAL_CONST(138335.75385914298/8.0), + REAL_CONST(138361.46861689744/8.0), + REAL_CONST(138387.18456949232/8.0), + REAL_CONST(138412.90171681659/8.0), + REAL_CONST(138438.62005875923/8.0), + REAL_CONST(138464.33959520931/8.0), + REAL_CONST(138490.06032605586/8.0), + REAL_CONST(138515.78225118798/8.0), + REAL_CONST(138541.50537049473/8.0), + REAL_CONST(138567.2296838653/8.0), + REAL_CONST(138592.95519118884/8.0), + REAL_CONST(138618.68189235451/8.0), + REAL_CONST(138644.40978725153/8.0), + REAL_CONST(138670.13887576913/8.0), + REAL_CONST(138695.86915779658/8.0), + REAL_CONST(138721.60063322316/8.0), + REAL_CONST(138747.33330193823/8.0), + REAL_CONST(138773.06716383106/8.0), + REAL_CONST(138798.80221879104/8.0), + REAL_CONST(138824.53846670757/8.0), + REAL_CONST(138850.27590747006/8.0), + REAL_CONST(138876.01454096794/8.0), + REAL_CONST(138901.7543670907/8.0), + REAL_CONST(138927.49538572782/8.0), + REAL_CONST(138953.2375967688/8.0), + REAL_CONST(138978.9810001032/8.0), + REAL_CONST(139004.72559562061/8.0), + REAL_CONST(139030.47138321059/8.0), + REAL_CONST(139056.2183627628/8.0), + REAL_CONST(139081.96653416683/8.0), + REAL_CONST(139107.71589731239/8.0), + REAL_CONST(139133.46645208917/8.0), + REAL_CONST(139159.21819838689/8.0), + REAL_CONST(139184.97113609532/8.0), + REAL_CONST(139210.72526510421/8.0), + REAL_CONST(139236.48058530336/8.0), + REAL_CONST(139262.23709658257/8.0), + REAL_CONST(139287.99479883176/8.0), + REAL_CONST(139313.75369194071/8.0), + REAL_CONST(139339.51377579942/8.0), + REAL_CONST(139365.27505029776/8.0), + REAL_CONST(139391.03751532568/8.0), + REAL_CONST(139416.80117077316/8.0), + REAL_CONST(139442.56601653024/8.0), + REAL_CONST(139468.33205248689/8.0), + REAL_CONST(139494.09927853322/8.0), + REAL_CONST(139519.86769455927/8.0), + REAL_CONST(139545.63730045516/8.0), + REAL_CONST(139571.408096111/8.0), + REAL_CONST(139597.18008141697/8.0), + REAL_CONST(139622.95325626322/8.0), + REAL_CONST(139648.72762054001/8.0), + REAL_CONST(139674.5031741375/8.0), + REAL_CONST(139700.27991694602/8.0), + REAL_CONST(139726.05784885579/8.0), + REAL_CONST(139751.83696975713/8.0), + REAL_CONST(139777.61727954043/8.0), + REAL_CONST(139803.39877809596/8.0), + REAL_CONST(139829.18146531415/8.0), + REAL_CONST(139854.96534108539/8.0), + REAL_CONST(139880.75040530015/8.0), + REAL_CONST(139906.53665784886/8.0), + REAL_CONST(139932.32409862199/8.0), + REAL_CONST(139958.11272751007/8.0), + REAL_CONST(139983.90254440365/8.0), + REAL_CONST(140009.69354919327/8.0), + REAL_CONST(140035.48574176949/8.0), + REAL_CONST(140061.27912202294/8.0), + REAL_CONST(140087.07368984428/8.0), + REAL_CONST(140112.86944512415/8.0), + REAL_CONST(140138.66638775321/8.0), + REAL_CONST(140164.4645176222/8.0), + REAL_CONST(140190.26383462184/8.0), + REAL_CONST(140216.06433864293/8.0), + REAL_CONST(140241.86602957622/8.0), + REAL_CONST(140267.66890731253/8.0), + REAL_CONST(140293.47297174268/8.0), + REAL_CONST(140319.27822275754/8.0), + REAL_CONST(140345.08466024802/8.0), + REAL_CONST(140370.89228410498/8.0), + REAL_CONST(140396.70109421943/8.0), + REAL_CONST(140422.51109048226/8.0), + REAL_CONST(140448.32227278448/8.0), + REAL_CONST(140474.13464101712/8.0), + REAL_CONST(140499.94819507122/8.0), + REAL_CONST(140525.76293483781/8.0), + REAL_CONST(140551.57886020801/8.0), + REAL_CONST(140577.3959710729/8.0), + REAL_CONST(140603.21426732364/8.0), + REAL_CONST(140629.03374885136/8.0), + REAL_CONST(140654.85441554731/8.0), + REAL_CONST(140680.67626730262/8.0), + REAL_CONST(140706.49930400858/8.0), + REAL_CONST(140732.32352555645/8.0), + REAL_CONST(140758.1489318375/8.0), + REAL_CONST(140783.97552274304/8.0), + REAL_CONST(140809.80329816442/8.0), + REAL_CONST(140835.63225799298/8.0), + REAL_CONST(140861.46240212015/8.0), + REAL_CONST(140887.29373043729/8.0), + REAL_CONST(140913.12624283586/8.0), + REAL_CONST(140938.95993920733/8.0), + REAL_CONST(140964.79481944317/8.0), + REAL_CONST(140990.63088343487/8.0), + REAL_CONST(141016.46813107401/8.0), + REAL_CONST(141042.30656225214/8.0), + REAL_CONST(141068.14617686081/8.0), + REAL_CONST(141093.98697479168/8.0), + REAL_CONST(141119.82895593636/8.0), + REAL_CONST(141145.6721201865/8.0), + REAL_CONST(141171.51646743377/8.0), + REAL_CONST(141197.36199756994/8.0), + REAL_CONST(141223.20871048668/8.0), + REAL_CONST(141249.05660607578/8.0), + REAL_CONST(141274.90568422904/8.0), + REAL_CONST(141300.75594483822/8.0), + REAL_CONST(141326.6073877952/8.0), + REAL_CONST(141352.4600129918/8.0), + REAL_CONST(141378.31382031992/8.0), + REAL_CONST(141404.16880967148/8.0), + REAL_CONST(141430.02498093838/8.0), + REAL_CONST(141455.8823340126/8.0), + REAL_CONST(141481.74086878612/8.0), + REAL_CONST(141507.60058515094/8.0), + REAL_CONST(141533.46148299909/8.0), + REAL_CONST(141559.32356222265/8.0), + REAL_CONST(141585.18682271364/8.0), + REAL_CONST(141611.05126436421/8.0), + REAL_CONST(141636.9168870665/8.0), + REAL_CONST(141662.78369071262/8.0), + REAL_CONST(141688.65167519479/8.0), + REAL_CONST(141714.5208404052/8.0), + REAL_CONST(141740.39118623605/8.0), + REAL_CONST(141766.26271257963/8.0), + REAL_CONST(141792.1354193282/8.0), + REAL_CONST(141818.00930637406/8.0), + REAL_CONST(141843.88437360956/8.0), + REAL_CONST(141869.760620927/8.0), + REAL_CONST(141895.6380482188/8.0), + REAL_CONST(141921.51665537735/8.0), + REAL_CONST(141947.39644229505/8.0), + REAL_CONST(141973.27740886438/8.0), + REAL_CONST(141999.15955497778/8.0), + REAL_CONST(142025.04288052776/8.0), + REAL_CONST(142050.92738540689/8.0), + REAL_CONST(142076.81306950765/8.0), + REAL_CONST(142102.69993272264/8.0), + REAL_CONST(142128.58797494444/8.0), + REAL_CONST(142154.47719606571/8.0), + REAL_CONST(142180.36759597904/8.0), + REAL_CONST(142206.25917457714/8.0), + REAL_CONST(142232.15193175265/8.0), + REAL_CONST(142258.04586739838/8.0), + REAL_CONST(142283.94098140698/8.0), + REAL_CONST(142309.83727367126/8.0), + REAL_CONST(142335.73474408401/8.0), + REAL_CONST(142361.63339253806/8.0), + REAL_CONST(142387.5332189262/8.0), + REAL_CONST(142413.43422314132/8.0), + REAL_CONST(142439.33640507635/8.0), + REAL_CONST(142465.23976462413/8.0), + REAL_CONST(142491.14430167765/8.0), + REAL_CONST(142517.05001612983/8.0), + REAL_CONST(142542.95690787368/8.0), + REAL_CONST(142568.86497680223/8.0), + REAL_CONST(142594.77422280848/8.0), + REAL_CONST(142620.68464578551/8.0), + REAL_CONST(142646.5962456264/8.0), + REAL_CONST(142672.50902222423/8.0), + REAL_CONST(142698.42297547215/8.0), + REAL_CONST(142724.33810526333/8.0), + REAL_CONST(142750.25441149093/8.0), + REAL_CONST(142776.17189404817/8.0), + REAL_CONST(142802.09055282827/8.0), + REAL_CONST(142828.01038772447/8.0), + REAL_CONST(142853.93139863008/8.0), + REAL_CONST(142879.85358543837/8.0), + REAL_CONST(142905.77694804268/8.0), + REAL_CONST(142931.70148633636/8.0), + REAL_CONST(142957.62720021277/8.0), + REAL_CONST(142983.55408956532/8.0), + REAL_CONST(143009.48215428743/8.0), + REAL_CONST(143035.41139427255/8.0), + REAL_CONST(143061.34180941415/8.0), + REAL_CONST(143087.27339960571/8.0), + REAL_CONST(143113.20616474075/8.0), + REAL_CONST(143139.14010471283/8.0), + REAL_CONST(143165.07521941551/8.0), + REAL_CONST(143191.01150874238/8.0), + REAL_CONST(143216.94897258704/8.0), + REAL_CONST(143242.88761084314/8.0), + REAL_CONST(143268.82742340435/8.0), + REAL_CONST(143294.76841016437/8.0), + REAL_CONST(143320.71057101688/8.0), + REAL_CONST(143346.65390585564/8.0), + REAL_CONST(143372.59841457437/8.0), + REAL_CONST(143398.54409706692/8.0), + REAL_CONST(143424.49095322701/8.0), + REAL_CONST(143450.43898294857/8.0), + REAL_CONST(143476.38818612538/8.0), + REAL_CONST(143502.33856265133/8.0), + REAL_CONST(143528.29011242036/8.0), + REAL_CONST(143554.24283532638/8.0), + REAL_CONST(143580.19673126334/8.0), + REAL_CONST(143606.1518001252/8.0), + REAL_CONST(143632.10804180597/8.0), + REAL_CONST(143658.06545619969/8.0), + REAL_CONST(143684.02404320039/8.0), + REAL_CONST(143709.98380270213/8.0), + REAL_CONST(143735.944734599/8.0), + REAL_CONST(143761.90683878519/8.0), + REAL_CONST(143787.87011515474/8.0), + REAL_CONST(143813.83456360188/8.0), + REAL_CONST(143839.8001840208/8.0), + REAL_CONST(143865.76697630569/8.0), + REAL_CONST(143891.73494035081/8.0), + REAL_CONST(143917.7040760504/8.0), + REAL_CONST(143943.67438329876/8.0), + REAL_CONST(143969.6458619902/8.0), + REAL_CONST(143995.61851201905/8.0), + REAL_CONST(144021.59233327967/8.0), + REAL_CONST(144047.56732566646/8.0), + REAL_CONST(144073.54348907378/8.0), + REAL_CONST(144099.52082339607/8.0), + REAL_CONST(144125.49932852783/8.0), + REAL_CONST(144151.4790043635/8.0), + REAL_CONST(144177.45985079758/8.0), + REAL_CONST(144203.44186772458/8.0), + REAL_CONST(144229.42505503909/8.0), + REAL_CONST(144255.40941263564/8.0), + REAL_CONST(144281.39494040885/8.0), + REAL_CONST(144307.38163825331/8.0), + REAL_CONST(144333.36950606373/8.0), + REAL_CONST(144359.35854373468/8.0), + REAL_CONST(144385.34875116093/8.0), + REAL_CONST(144411.34012823718/8.0), + REAL_CONST(144437.33267485813/8.0), + REAL_CONST(144463.32639091855/8.0), + REAL_CONST(144489.32127631325/8.0), + REAL_CONST(144515.31733093705/8.0), + REAL_CONST(144541.31455468474/8.0), + REAL_CONST(144567.3129474512/8.0), + REAL_CONST(144593.3125091313/8.0), + REAL_CONST(144619.31323961995/8.0), + REAL_CONST(144645.31513881206/8.0), + REAL_CONST(144671.31820660262/8.0), + REAL_CONST(144697.32244288657/8.0), + REAL_CONST(144723.32784755889/8.0), + REAL_CONST(144749.33442051467/8.0), + REAL_CONST(144775.34216164888/8.0), + REAL_CONST(144801.35107085665/8.0), + REAL_CONST(144827.36114803303/8.0), + REAL_CONST(144853.37239307314/8.0), + REAL_CONST(144879.38480587213/8.0), + REAL_CONST(144905.39838632516/8.0), + REAL_CONST(144931.41313432742/8.0), + REAL_CONST(144957.4290497741/8.0), + REAL_CONST(144983.44613256046/8.0), + REAL_CONST(145009.46438258173/8.0), + REAL_CONST(145035.48379973322/8.0), + REAL_CONST(145061.50438391021/8.0), + REAL_CONST(145087.52613500805/8.0), + REAL_CONST(145113.54905292206/8.0), + REAL_CONST(145139.57313754765/8.0), + REAL_CONST(145165.59838878017/8.0), + REAL_CONST(145191.62480651509/8.0), + REAL_CONST(145217.65239064783/8.0), + REAL_CONST(145243.68114107384/8.0), + REAL_CONST(145269.71105768863/8.0), + REAL_CONST(145295.74214038774/8.0), + REAL_CONST(145321.77438906668/8.0), + REAL_CONST(145347.80780362099/8.0), + REAL_CONST(145373.84238394629/8.0), + REAL_CONST(145399.87812993818/8.0), + REAL_CONST(145425.91504149229/8.0), + REAL_CONST(145451.95311850426/8.0), + REAL_CONST(145477.9923608698/8.0), + REAL_CONST(145504.03276848458/8.0), + REAL_CONST(145530.07434124436/8.0), + REAL_CONST(145556.11707904484/8.0), + REAL_CONST(145582.16098178181/8.0), + REAL_CONST(145608.20604935108/8.0), + REAL_CONST(145634.25228164849/8.0), + REAL_CONST(145660.29967856981/8.0), + REAL_CONST(145686.34824001096/8.0), + REAL_CONST(145712.39796586783/8.0), + REAL_CONST(145738.4488560363/8.0), + REAL_CONST(145764.50091041232/8.0), + REAL_CONST(145790.55412889185/8.0), + REAL_CONST(145816.60851137087/8.0), + REAL_CONST(145842.66405774537/8.0), + REAL_CONST(145868.72076791141/8.0), + REAL_CONST(145894.77864176501/8.0), + REAL_CONST(145920.83767920226/8.0), + REAL_CONST(145946.89788011924/8.0), + REAL_CONST(145972.95924441208/8.0), + REAL_CONST(145999.02177197693/8.0), + REAL_CONST(146025.08546270995/8.0), + REAL_CONST(146051.15031650732/8.0), + REAL_CONST(146077.21633326527/8.0), + REAL_CONST(146103.28351288004/8.0), + REAL_CONST(146129.35185524789/8.0), + REAL_CONST(146155.42136026506/8.0), + REAL_CONST(146181.49202782792/8.0), + REAL_CONST(146207.56385783272/8.0), + REAL_CONST(146233.63685017588/8.0), + REAL_CONST(146259.71100475377/8.0), + REAL_CONST(146285.78632146274/8.0), + REAL_CONST(146311.86280019928/8.0), + REAL_CONST(146337.94044085976/8.0), + REAL_CONST(146364.01924334071/8.0), + REAL_CONST(146390.09920753856/8.0), + REAL_CONST(146416.18033334985/8.0), + REAL_CONST(146442.26262067116/8.0), + REAL_CONST(146468.34606939898/8.0), + REAL_CONST(146494.43067942993/8.0), + REAL_CONST(146520.51645066062/8.0), + REAL_CONST(146546.60338298764/8.0), + REAL_CONST(146572.69147630769/8.0), + REAL_CONST(146598.78073051744/8.0), + REAL_CONST(146624.87114551352/8.0), + REAL_CONST(146650.96272119274/8.0), + REAL_CONST(146677.05545745179/8.0), + REAL_CONST(146703.14935418745/8.0), + REAL_CONST(146729.2444112965/8.0), + REAL_CONST(146755.34062867577/8.0), + REAL_CONST(146781.43800622207/8.0), + REAL_CONST(146807.53654383228/8.0), + REAL_CONST(146833.63624140329/8.0), + REAL_CONST(146859.73709883197/8.0), + REAL_CONST(146885.83911601527/8.0), + REAL_CONST(146911.94229285014/8.0), + REAL_CONST(146938.04662923355/8.0), + REAL_CONST(146964.15212506248/8.0), + REAL_CONST(146990.25878023397/8.0), + REAL_CONST(147016.36659464505/8.0), + REAL_CONST(147042.47556819281/8.0), + REAL_CONST(147068.58570077427/8.0), + REAL_CONST(147094.6969922866/8.0), + REAL_CONST(147120.80944262692/8.0), + REAL_CONST(147146.92305169237/8.0), + REAL_CONST(147173.03781938017/8.0), + REAL_CONST(147199.15374558745/8.0), + REAL_CONST(147225.27083021149/8.0), + REAL_CONST(147251.38907314953/8.0), + REAL_CONST(147277.50847429881/8.0), + REAL_CONST(147303.62903355664/8.0), + REAL_CONST(147329.75075082036/8.0), + REAL_CONST(147355.87362598727/8.0), + REAL_CONST(147381.99765895473/8.0), + REAL_CONST(147408.12284962015/8.0), + REAL_CONST(147434.24919788091/8.0), + REAL_CONST(147460.37670363448/8.0), + REAL_CONST(147486.50536677826/8.0), + REAL_CONST(147512.63518720976/8.0), + REAL_CONST(147538.76616482646/8.0), + REAL_CONST(147564.89829952587/8.0), + REAL_CONST(147591.03159120557/8.0), + REAL_CONST(147617.16603976308/8.0), + REAL_CONST(147643.30164509601/8.0), + REAL_CONST(147669.43840710199/8.0), + REAL_CONST(147695.57632567859/8.0), + REAL_CONST(147721.71540072354/8.0), + REAL_CONST(147747.85563213445/8.0), + REAL_CONST(147773.99701980909/8.0), + REAL_CONST(147800.13956364512/8.0), + REAL_CONST(147826.28326354033/8.0), + REAL_CONST(147852.42811939248/8.0), + REAL_CONST(147878.57413109933/8.0), + REAL_CONST(147904.72129855872/8.0), + REAL_CONST(147930.86962166851/8.0), + REAL_CONST(147957.01910032652/8.0), + REAL_CONST(147983.16973443062/8.0), + REAL_CONST(148009.32152387875/8.0), + REAL_CONST(148035.47446856883/8.0), + REAL_CONST(148061.62856839882/8.0), + REAL_CONST(148087.78382326665/8.0), + REAL_CONST(148113.94023307035/8.0), + REAL_CONST(148140.09779770792/8.0), + REAL_CONST(148166.25651707739/8.0), + REAL_CONST(148192.41639107687/8.0), + REAL_CONST(148218.57741960438/8.0), + REAL_CONST(148244.73960255808/8.0), + REAL_CONST(148270.90293983606/8.0), + REAL_CONST(148297.0674313365/8.0), + REAL_CONST(148323.23307695755/8.0), + REAL_CONST(148349.39987659742/8.0), + REAL_CONST(148375.56783015432/8.0), + REAL_CONST(148401.73693752653/8.0), + REAL_CONST(148427.90719861226/8.0), + REAL_CONST(148454.07861330983/8.0), + REAL_CONST(148480.25118151752/8.0), + REAL_CONST(148506.42490313368/8.0), + REAL_CONST(148532.59977805667/8.0), + REAL_CONST(148558.77580618486/8.0), + REAL_CONST(148584.95298741665/8.0), + REAL_CONST(148611.13132165043/8.0), + REAL_CONST(148637.31080878471/8.0), + REAL_CONST(148663.49144871789/8.0), + REAL_CONST(148689.6732413485/8.0), + REAL_CONST(148715.85618657502/8.0), + REAL_CONST(148742.040284296/8.0), + REAL_CONST(148768.22553440998/8.0), + REAL_CONST(148794.41193681557/8.0), + REAL_CONST(148820.59949141133/8.0), + REAL_CONST(148846.78819809589/8.0), + REAL_CONST(148872.97805676793/8.0), + REAL_CONST(148899.16906732606/8.0), + REAL_CONST(148925.36122966901/8.0), + REAL_CONST(148951.55454369547/8.0), + REAL_CONST(148977.74900930419/8.0), + REAL_CONST(149003.9446263939/8.0), + REAL_CONST(149030.1413948634/8.0), + REAL_CONST(149056.33931461151/8.0), + REAL_CONST(149082.53838553699/8.0), + REAL_CONST(149108.73860753875/8.0), + REAL_CONST(149134.9399805156/8.0), + REAL_CONST(149161.14250436646/8.0), + REAL_CONST(149187.34617899026/8.0), + REAL_CONST(149213.5510042859/8.0), + REAL_CONST(149239.75698015234/8.0), + REAL_CONST(149265.96410648854/8.0), + REAL_CONST(149292.17238319354/8.0), + REAL_CONST(149318.38181016635/8.0), + REAL_CONST(149344.59238730598/8.0), + REAL_CONST(149370.80411451156/8.0), + REAL_CONST(149397.01699168212/8.0), + REAL_CONST(149423.23101871679/8.0), + REAL_CONST(149449.44619551473/8.0), + REAL_CONST(149475.66252197503/8.0), + REAL_CONST(149501.87999799693/8.0), + REAL_CONST(149528.0986234796/8.0), + REAL_CONST(149554.31839832227/8.0), + REAL_CONST(149580.53932242419/8.0), + REAL_CONST(149606.76139568459/8.0), + REAL_CONST(149632.98461800278/8.0), + REAL_CONST(149659.20898927809/8.0), + REAL_CONST(149685.43450940982/8.0), + REAL_CONST(149711.66117829733/8.0), + REAL_CONST(149737.88899584001/8.0), + REAL_CONST(149764.11796193724/8.0), + REAL_CONST(149790.34807648844/8.0), + REAL_CONST(149816.57933939309/8.0), + REAL_CONST(149842.81175055061/8.0), + REAL_CONST(149869.04530986046/8.0), + REAL_CONST(149895.28001722222/8.0), + REAL_CONST(149921.51587253538/8.0), + REAL_CONST(149947.75287569952/8.0), + REAL_CONST(149973.99102661415/8.0), + REAL_CONST(150000.23032517891/8.0), + REAL_CONST(150026.47077129342/8.0), + REAL_CONST(150052.71236485732/8.0), + REAL_CONST(150078.95510577026/8.0), + REAL_CONST(150105.1989939319/8.0), + REAL_CONST(150131.444029242/8.0), + REAL_CONST(150157.69021160025/8.0), + REAL_CONST(150183.93754090639/8.0), + REAL_CONST(150210.18601706024/8.0), + REAL_CONST(150236.43563996154/8.0), + REAL_CONST(150262.68640951012/8.0), + REAL_CONST(150288.93832560582/8.0), + REAL_CONST(150315.19138814852/8.0), + REAL_CONST(150341.44559703805/8.0), + REAL_CONST(150367.70095217437/8.0), + REAL_CONST(150393.95745345735/8.0), + REAL_CONST(150420.21510078697/8.0), + REAL_CONST(150446.47389406321/8.0), + REAL_CONST(150472.73383318601/8.0), + REAL_CONST(150498.99491805542/8.0), + REAL_CONST(150525.25714857146/8.0), + REAL_CONST(150551.52052463419/8.0), + REAL_CONST(150577.78504614369/8.0), + REAL_CONST(150604.05071300003/8.0), + REAL_CONST(150630.31752510337/8.0), + REAL_CONST(150656.58548235384/8.0), + REAL_CONST(150682.85458465159/8.0), + REAL_CONST(150709.1248318968/8.0), + REAL_CONST(150735.39622398972/8.0), + REAL_CONST(150761.66876083051/8.0), + REAL_CONST(150787.9424423195/8.0), + REAL_CONST(150814.21726835691/8.0), + REAL_CONST(150840.49323884305/8.0), + REAL_CONST(150866.77035367821/8.0), + REAL_CONST(150893.04861276277/8.0), + REAL_CONST(150919.32801599705/8.0), + REAL_CONST(150945.60856328148/8.0), + REAL_CONST(150971.89025451642/8.0), + REAL_CONST(150998.17308960229/8.0), + REAL_CONST(151024.45706843957/8.0), + REAL_CONST(151050.74219092872/8.0), + REAL_CONST(151077.02845697021/8.0), + REAL_CONST(151103.31586646455/8.0), + REAL_CONST(151129.60441931229/8.0), + REAL_CONST(151155.894115414/8.0), + REAL_CONST(151182.1849546702/8.0), + REAL_CONST(151208.47693698155/8.0), + REAL_CONST(151234.77006224863/8.0), + REAL_CONST(151261.06433037209/8.0), + REAL_CONST(151287.35974125259/8.0), + REAL_CONST(151313.65629479082/8.0), + REAL_CONST(151339.95399088747/8.0), + REAL_CONST(151366.25282944329/8.0), + REAL_CONST(151392.55281035902/8.0), + REAL_CONST(151418.85393353543/8.0), + REAL_CONST(151445.1561988733/8.0), + REAL_CONST(151471.45960627345/8.0), + REAL_CONST(151497.76415563675/8.0), + REAL_CONST(151524.06984686397/8.0), + REAL_CONST(151550.37667985607/8.0), + REAL_CONST(151576.68465451393/8.0), + REAL_CONST(151602.99377073845/8.0), + REAL_CONST(151629.30402843058/8.0), + REAL_CONST(151655.61542749128/8.0), + REAL_CONST(151681.92796782157/8.0), + REAL_CONST(151708.24164932242/8.0), + REAL_CONST(151734.55647189484/8.0), + REAL_CONST(151760.87243543993/8.0), + REAL_CONST(151787.18953985872/8.0), + REAL_CONST(151813.50778505235/8.0), + REAL_CONST(151839.82717092187/8.0), + REAL_CONST(151866.14769736846/8.0), + REAL_CONST(151892.46936429327/8.0), + REAL_CONST(151918.79217159748/8.0), + REAL_CONST(151945.11611918229/8.0), + REAL_CONST(151971.44120694889/8.0), + REAL_CONST(151997.76743479856/8.0), + REAL_CONST(152024.09480263255/8.0), + REAL_CONST(152050.42331035214/8.0), + REAL_CONST(152076.75295785864/8.0), + REAL_CONST(152103.08374505339/8.0), + REAL_CONST(152129.41567183775/8.0), + REAL_CONST(152155.74873811303/8.0), + REAL_CONST(152182.08294378067/8.0), + REAL_CONST(152208.41828874208/8.0), + REAL_CONST(152234.75477289871/8.0), + REAL_CONST(152261.09239615197/8.0), + REAL_CONST(152287.43115840337/8.0), + REAL_CONST(152313.77105955439/8.0), + REAL_CONST(152340.11209950657/8.0), + REAL_CONST(152366.45427816146/8.0), + REAL_CONST(152392.79759542056/8.0), + REAL_CONST(152419.14205118554/8.0), + REAL_CONST(152445.48764535793/8.0), + REAL_CONST(152471.8343778394/8.0), + REAL_CONST(152498.18224853161/8.0), + REAL_CONST(152524.53125733617/8.0), + REAL_CONST(152550.88140415482/8.0), + REAL_CONST(152577.23268888926/8.0), + REAL_CONST(152603.58511144121/8.0), + REAL_CONST(152629.93867171241/8.0), + REAL_CONST(152656.29336960468/8.0), + REAL_CONST(152682.64920501978/8.0), + REAL_CONST(152709.00617785956/8.0), + REAL_CONST(152735.36428802583/8.0), + REAL_CONST(152761.72353542043/8.0), + REAL_CONST(152788.08391994529/8.0), + REAL_CONST(152814.44544150229/8.0), + REAL_CONST(152840.80809999333/8.0), + REAL_CONST(152867.17189532038/8.0), + REAL_CONST(152893.53682738543/8.0), + REAL_CONST(152919.90289609041/8.0), + REAL_CONST(152946.27010133737/8.0), + REAL_CONST(152972.63844302832/8.0), + REAL_CONST(152999.00792106529/8.0), + REAL_CONST(153025.37853535041/8.0), + REAL_CONST(153051.7502857857/8.0), + REAL_CONST(153078.12317227334/8.0), + REAL_CONST(153104.4971947154/8.0), + REAL_CONST(153130.8723530141/8.0), + REAL_CONST(153157.24864707157/8.0), + REAL_CONST(153183.62607679001/8.0), + REAL_CONST(153210.00464207167/8.0), + REAL_CONST(153236.38434281875/8.0), + REAL_CONST(153262.76517893354/8.0), + REAL_CONST(153289.14715031831/8.0), + REAL_CONST(153315.53025687535/8.0), + REAL_CONST(153341.91449850702/8.0), + REAL_CONST(153368.2998751156/8.0), + REAL_CONST(153394.68638660354/8.0), + REAL_CONST(153421.07403287315/8.0), + REAL_CONST(153447.46281382689/8.0), + REAL_CONST(153473.85272936718/8.0), + REAL_CONST(153500.24377939643/8.0), + REAL_CONST(153526.63596381716/8.0), + REAL_CONST(153553.02928253182/8.0), + REAL_CONST(153579.42373544298/8.0), + REAL_CONST(153605.81932245308/8.0), + REAL_CONST(153632.21604346478/8.0), + REAL_CONST(153658.61389838057/8.0), + REAL_CONST(153685.0128871031/8.0), + REAL_CONST(153711.41300953497/8.0), + REAL_CONST(153737.81426557881/8.0), + REAL_CONST(153764.21665513728/8.0), + REAL_CONST(153790.62017811305/8.0), + REAL_CONST(153817.02483440886/8.0), + REAL_CONST(153843.43062392739/8.0), + REAL_CONST(153869.83754657139/8.0), + REAL_CONST(153896.24560224367/8.0), + REAL_CONST(153922.65479084692/8.0), + REAL_CONST(153949.06511228404/8.0), + REAL_CONST(153975.4765664578/8.0), + REAL_CONST(154001.88915327107/8.0), + REAL_CONST(154028.30287262669/8.0), + REAL_CONST(154054.71772442761/8.0), + REAL_CONST(154081.13370857667/8.0), + REAL_CONST(154107.55082497682/8.0), + REAL_CONST(154133.96907353101/8.0), + REAL_CONST(154160.38845414223/8.0), + REAL_CONST(154186.80896671346/8.0), + REAL_CONST(154213.23061114774/8.0), + REAL_CONST(154239.65338734805/8.0), + REAL_CONST(154266.07729521746/8.0), + REAL_CONST(154292.50233465908/8.0), + REAL_CONST(154318.92850557598/8.0), + REAL_CONST(154345.35580787127/8.0), + REAL_CONST(154371.7842414481/8.0), + REAL_CONST(154398.21380620965/8.0), + REAL_CONST(154424.64450205903/8.0), + REAL_CONST(154451.07632889951/8.0), + REAL_CONST(154477.50928663427/8.0), + REAL_CONST(154503.94337516659/8.0), + REAL_CONST(154530.37859439969/8.0), + REAL_CONST(154556.81494423689/8.0), + REAL_CONST(154583.25242458144/8.0), + REAL_CONST(154609.69103533673/8.0), + REAL_CONST(154636.13077640603/8.0), + REAL_CONST(154662.57164769279/8.0), + REAL_CONST(154689.01364910032/8.0), + REAL_CONST(154715.45678053208/8.0), + REAL_CONST(154741.90104189145/8.0), + REAL_CONST(154768.34643308193/8.0), + REAL_CONST(154794.79295400696/8.0), + REAL_CONST(154821.24060457002/8.0), + REAL_CONST(154847.68938467462/8.0), + REAL_CONST(154874.13929422433/8.0), + REAL_CONST(154900.59033312264/8.0), + REAL_CONST(154927.04250127316/8.0), + REAL_CONST(154953.49579857948/8.0), + REAL_CONST(154979.95022494521/8.0), + REAL_CONST(155006.40578027396/8.0), + REAL_CONST(155032.86246446942/8.0), + REAL_CONST(155059.32027743524/8.0), + REAL_CONST(155085.77921907514/8.0), + REAL_CONST(155112.2392892928/8.0), + REAL_CONST(155138.70048799197/8.0), + REAL_CONST(155165.16281507642/8.0), + REAL_CONST(155191.62627044989/8.0), + REAL_CONST(155218.09085401625/8.0), + REAL_CONST(155244.55656567923/8.0), + REAL_CONST(155271.02340534274/8.0), + REAL_CONST(155297.49137291059/8.0), + REAL_CONST(155323.96046828668/8.0), + REAL_CONST(155350.4306913749/8.0), + REAL_CONST(155376.90204207919/8.0), + REAL_CONST(155403.37452030348/8.0), + REAL_CONST(155429.84812595171/8.0), + REAL_CONST(155456.32285892789/8.0), + REAL_CONST(155482.79871913602/8.0), + REAL_CONST(155509.27570648011/8.0), + REAL_CONST(155535.75382086422/8.0), + REAL_CONST(155562.23306219239/8.0), + REAL_CONST(155588.71343036872/8.0), + REAL_CONST(155615.19492529731/8.0), + REAL_CONST(155641.67754688227/8.0), + REAL_CONST(155668.16129502779/8.0), + REAL_CONST(155694.64616963797/8.0), + REAL_CONST(155721.13217061706/8.0), + REAL_CONST(155747.61929786921/8.0), + REAL_CONST(155774.10755129869/8.0), + REAL_CONST(155800.59693080973/8.0), + REAL_CONST(155827.08743630661/8.0), + REAL_CONST(155853.57906769359/8.0), + REAL_CONST(155880.07182487496/8.0), + REAL_CONST(155906.56570775513/8.0), + REAL_CONST(155933.06071623837/8.0), + REAL_CONST(155959.55685022907/8.0), + REAL_CONST(155986.05410963166/8.0), + REAL_CONST(156012.5524943505/8.0), + REAL_CONST(156039.05200429002/8.0), + REAL_CONST(156065.55263935472/8.0), + REAL_CONST(156092.054399449/8.0), + REAL_CONST(156118.5572844774/8.0), + REAL_CONST(156145.06129434443/8.0), + REAL_CONST(156171.5664289546/8.0), + REAL_CONST(156198.07268821247/8.0), + REAL_CONST(156224.5800720226/8.0), + REAL_CONST(156251.08858028959/8.0), + REAL_CONST(156277.59821291809/8.0), + REAL_CONST(156304.10896981266/8.0), + REAL_CONST(156330.62085087801/8.0), + REAL_CONST(156357.1338560188/8.0), + REAL_CONST(156383.64798513969/8.0), + REAL_CONST(156410.16323814544/8.0), + REAL_CONST(156436.67961494075/8.0), + REAL_CONST(156463.1971154304/8.0), + REAL_CONST(156489.71573951913/8.0), + REAL_CONST(156516.23548711176/8.0), + REAL_CONST(156542.75635811311/8.0), + REAL_CONST(156569.27835242799/8.0), + REAL_CONST(156595.80146996127/8.0), + REAL_CONST(156622.32571061782/8.0), + REAL_CONST(156648.85107430254/8.0), + REAL_CONST(156675.37756092031/8.0), + REAL_CONST(156701.90517037612/8.0), + REAL_CONST(156728.43390257491/8.0), + REAL_CONST(156754.96375742162/8.0), + REAL_CONST(156781.49473482129/8.0), + REAL_CONST(156808.02683467892/8.0), + REAL_CONST(156834.5600568995/8.0), + REAL_CONST(156861.09440138817/8.0), + REAL_CONST(156887.62986804993/8.0), + REAL_CONST(156914.16645678994/8.0), + REAL_CONST(156940.70416751326/8.0), + REAL_CONST(156967.24300012505/8.0), + REAL_CONST(156993.78295453047/8.0), + REAL_CONST(157020.32403063469/8.0), + REAL_CONST(157046.8662283429/8.0), + REAL_CONST(157073.40954756032/8.0), + REAL_CONST(157099.9539881922/8.0), + REAL_CONST(157126.49955014378/8.0), + REAL_CONST(157153.04623332032/8.0), + REAL_CONST(157179.59403762716/8.0), + REAL_CONST(157206.14296296958/8.0), + REAL_CONST(157232.69300925292/8.0), + REAL_CONST(157259.24417638258/8.0), + REAL_CONST(157285.79646426387/8.0), + REAL_CONST(157312.34987280221/8.0), + REAL_CONST(157338.90440190304/8.0), + REAL_CONST(157365.46005147175/8.0), + REAL_CONST(157392.01682141385/8.0), + REAL_CONST(157418.57471163478/8.0), + REAL_CONST(157445.13372204005/8.0), + REAL_CONST(157471.69385253513/8.0), + REAL_CONST(157498.25510302564/8.0), + REAL_CONST(157524.81747341706/8.0), + REAL_CONST(157551.38096361503/8.0), + REAL_CONST(157577.9455735251/8.0), + REAL_CONST(157604.51130305286/8.0), + REAL_CONST(157631.07815210402/8.0), + REAL_CONST(157657.64612058419/8.0), + REAL_CONST(157684.21520839902/8.0), + REAL_CONST(157710.78541545427/8.0), + REAL_CONST(157737.35674165559/8.0), + REAL_CONST(157763.92918690876/8.0), + REAL_CONST(157790.50275111952/8.0), + REAL_CONST(157817.07743419363/8.0), + REAL_CONST(157843.65323603692/8.0), + REAL_CONST(157870.23015655516/8.0), + REAL_CONST(157896.80819565422/8.0), + REAL_CONST(157923.3873532399/8.0), + REAL_CONST(157949.96762921812/8.0), + REAL_CONST(157976.54902349479/8.0), + REAL_CONST(158003.13153597576/8.0), + REAL_CONST(158029.71516656701/8.0), + REAL_CONST(158056.29991517449/8.0), + REAL_CONST(158082.88578170416/8.0), + REAL_CONST(158109.47276606198/8.0), + REAL_CONST(158136.06086815402/8.0), + REAL_CONST(158162.65008788629/8.0), + REAL_CONST(158189.24042516484/8.0), + REAL_CONST(158215.83187989573/8.0), + REAL_CONST(158242.42445198505/8.0), + REAL_CONST(158269.01814133892/8.0), + REAL_CONST(158295.61294786347/8.0), + REAL_CONST(158322.20887146486/8.0), + REAL_CONST(158348.80591204923/8.0), + REAL_CONST(158375.4040695228/8.0), + REAL_CONST(158402.00334379176/8.0), + REAL_CONST(158428.60373476235/8.0), + REAL_CONST(158455.2052423408/8.0), + REAL_CONST(158481.80786643337/8.0), + REAL_CONST(158508.41160694641/8.0), + REAL_CONST(158535.01646378616/8.0), + REAL_CONST(158561.62243685898/8.0), + REAL_CONST(158588.2295260712/8.0), + REAL_CONST(158614.8377313292/8.0), + REAL_CONST(158641.44705253936/8.0), + REAL_CONST(158668.05748960807/8.0), + REAL_CONST(158694.66904244179/8.0), + REAL_CONST(158721.28171094693/8.0), + REAL_CONST(158747.89549502998/8.0), + REAL_CONST(158774.5103945974/8.0), + REAL_CONST(158801.12640955573/8.0), + REAL_CONST(158827.74353981143/8.0), + REAL_CONST(158854.36178527112/8.0), + REAL_CONST(158880.9811458413/8.0), + REAL_CONST(158907.60162142856/8.0), + REAL_CONST(158934.22321193956/8.0), + REAL_CONST(158960.84591728085/8.0), + REAL_CONST(158987.46973735912/8.0), + REAL_CONST(159014.09467208097/8.0), + REAL_CONST(159040.72072135314/8.0), + REAL_CONST(159067.3478850823/8.0), + REAL_CONST(159093.97616317519/8.0), + REAL_CONST(159120.60555553852/8.0), + REAL_CONST(159147.23606207906/8.0), + REAL_CONST(159173.8676827036/8.0), + REAL_CONST(159200.50041731889/8.0), + REAL_CONST(159227.13426583182/8.0), + REAL_CONST(159253.76922814918/8.0), + REAL_CONST(159280.40530417781/8.0), + REAL_CONST(159307.04249382461/8.0), + REAL_CONST(159333.68079699649/8.0), + REAL_CONST(159360.32021360032/8.0), + REAL_CONST(159386.96074354305/8.0), + REAL_CONST(159413.60238673165/8.0), + REAL_CONST(159440.24514307309/8.0), + REAL_CONST(159466.88901247433/8.0), + REAL_CONST(159493.53399484244/8.0), + REAL_CONST(159520.18009008438/8.0), + REAL_CONST(159546.82729810724/8.0), + REAL_CONST(159573.47561881805/8.0), + REAL_CONST(159600.12505212394/8.0), + REAL_CONST(159626.77559793202/8.0), + REAL_CONST(159653.42725614941/8.0), + REAL_CONST(159680.08002668325/8.0), + REAL_CONST(159706.73390944069/8.0), + REAL_CONST(159733.38890432892/8.0), + REAL_CONST(159760.04501125516/8.0), + REAL_CONST(159786.70223012666/8.0), + REAL_CONST(159813.36056085059/8.0), + REAL_CONST(159840.02000333427/8.0), + REAL_CONST(159866.68055748497/8.0), + REAL_CONST(159893.34222320997/8.0), + REAL_CONST(159920.00500041663/8.0), + REAL_CONST(159946.66888901225/8.0), + REAL_CONST(159973.33388890422/8.0), + REAL_CONST(159999.99999999988/8.0), + REAL_CONST(160026.66722220668/8.0), + REAL_CONST(160053.33555543202/8.0), + REAL_CONST(160080.0049995833/8.0), + REAL_CONST(160106.67555456801/8.0), + REAL_CONST(160133.3472202936/8.0), + REAL_CONST(160160.0199966676/8.0), + REAL_CONST(160186.6938835975/8.0), + REAL_CONST(160213.36888099083/8.0), + REAL_CONST(160240.04498875517/8.0), + REAL_CONST(160266.72220679806/8.0), + REAL_CONST(160293.40053502709/8.0), + REAL_CONST(160320.07997334987/8.0), + REAL_CONST(160346.76052167406/8.0), + REAL_CONST(160373.44217990729/8.0), + REAL_CONST(160400.1249479572/8.0), + REAL_CONST(160426.80882573154/8.0), + REAL_CONST(160453.49381313793/8.0), + REAL_CONST(160480.17991008417/8.0), + REAL_CONST(160506.86711647795/8.0), + REAL_CONST(160533.55543222709/8.0), + REAL_CONST(160560.24485723933/8.0), + REAL_CONST(160586.93539142248/8.0), + REAL_CONST(160613.62703468435/8.0), + REAL_CONST(160640.31978693281/8.0), + REAL_CONST(160667.01364807569/8.0), + REAL_CONST(160693.70861802087/8.0), + REAL_CONST(160720.40469667627/8.0), + REAL_CONST(160747.1018839498/8.0), + REAL_CONST(160773.80017974938/8.0), + REAL_CONST(160800.49958398298/8.0), + REAL_CONST(160827.20009655855/8.0), + REAL_CONST(160853.90171738411/8.0), + REAL_CONST(160880.60444636765/8.0), + REAL_CONST(160907.30828341722/8.0), + REAL_CONST(160934.01322844089/8.0), + REAL_CONST(160960.71928134665/8.0), + REAL_CONST(160987.42644204266/8.0), + REAL_CONST(161014.13471043704/8.0), + REAL_CONST(161040.84408643784/8.0), + REAL_CONST(161067.55456995327/8.0), + REAL_CONST(161094.26616089148/8.0), + REAL_CONST(161120.97885916062/8.0), + REAL_CONST(161147.69266466892/8.0), + REAL_CONST(161174.40757732463/8.0), + REAL_CONST(161201.12359703594/8.0), + REAL_CONST(161227.84072371112/8.0), + REAL_CONST(161254.55895725847/8.0), + REAL_CONST(161281.27829758628/8.0), + REAL_CONST(161307.99874460287/8.0), + REAL_CONST(161334.72029821656/8.0), + REAL_CONST(161361.44295833571/8.0), + REAL_CONST(161388.1667248687/8.0), + REAL_CONST(161414.89159772391/8.0), + REAL_CONST(161441.61757680977/8.0), + REAL_CONST(161468.34466203468/8.0), + REAL_CONST(161495.07285330712/8.0), + REAL_CONST(161521.80215053557/8.0), + REAL_CONST(161548.53255362847/8.0), + REAL_CONST(161575.26406249436/8.0), + REAL_CONST(161601.99667704175/8.0), + REAL_CONST(161628.7303971792/8.0), + REAL_CONST(161655.46522281526/8.0), + REAL_CONST(161682.20115385848/8.0), + REAL_CONST(161708.93819021754/8.0), + REAL_CONST(161735.67633180099/8.0), + REAL_CONST(161762.41557851751/8.0), + REAL_CONST(161789.15593027571/8.0), + REAL_CONST(161815.89738698432/8.0), + REAL_CONST(161842.63994855201/8.0), + REAL_CONST(161869.38361488748/8.0), + REAL_CONST(161896.1283858995/8.0), + REAL_CONST(161922.87426149679/8.0), + REAL_CONST(161949.62124158812/8.0), + REAL_CONST(161976.36932608229/8.0), + REAL_CONST(162003.1185148881/8.0), + REAL_CONST(162029.8688079144/8.0), + REAL_CONST(162056.62020507001/8.0), + REAL_CONST(162083.37270626382/8.0), + REAL_CONST(162110.12631140469/8.0), + REAL_CONST(162136.88102040152/8.0), + REAL_CONST(162163.63683316324/8.0), + REAL_CONST(162190.39374959879/8.0), + REAL_CONST(162217.15176961714/8.0), + REAL_CONST(162243.91089312723/8.0), + REAL_CONST(162270.67112003808/8.0), + REAL_CONST(162297.43245025873/8.0), + REAL_CONST(162324.19488369819/8.0), + REAL_CONST(162350.9584202655/8.0), + REAL_CONST(162377.72305986975/8.0), + REAL_CONST(162404.48880242003/8.0), + REAL_CONST(162431.25564782543/8.0), + REAL_CONST(162458.02359599507/8.0), + REAL_CONST(162484.79264683815/8.0), + REAL_CONST(162511.56280026378/8.0), + REAL_CONST(162538.33405618116/8.0), + REAL_CONST(162565.10641449949/8.0), + REAL_CONST(162591.87987512801/8.0), + REAL_CONST(162618.65443797593/8.0), + REAL_CONST(162645.43010295252/8.0), + REAL_CONST(162672.20686996708/8.0), + REAL_CONST(162698.98473892888/8.0), + REAL_CONST(162725.76370974723/8.0), + REAL_CONST(162752.54378233149/8.0), + REAL_CONST(162779.32495659095/8.0), + REAL_CONST(162806.10723243505/8.0), + REAL_CONST(162832.89060977317/8.0), + REAL_CONST(162859.67508851466/8.0), + REAL_CONST(162886.46066856899/8.0), + REAL_CONST(162913.24734984562/8.0), + REAL_CONST(162940.03513225398/8.0), + REAL_CONST(162966.82401570358/8.0), + REAL_CONST(162993.6140001039/8.0), + REAL_CONST(163020.40508536444/8.0), + REAL_CONST(163047.19727139481/8.0), + REAL_CONST(163073.99055810447/8.0), + REAL_CONST(163100.78494540305/8.0), + REAL_CONST(163127.58043320014/8.0), + REAL_CONST(163154.37702140535/8.0), + REAL_CONST(163181.17470992831/8.0), + REAL_CONST(163207.97349867865/8.0), + REAL_CONST(163234.77338756606/8.0), + REAL_CONST(163261.57437650024/8.0), + REAL_CONST(163288.37646539087/8.0), + REAL_CONST(163315.17965414765/8.0), + REAL_CONST(163341.98394268038/8.0), + REAL_CONST(163368.78933089875/8.0), + REAL_CONST(163395.59581871261/8.0), + REAL_CONST(163422.40340603172/8.0), + REAL_CONST(163449.2120927659/8.0), + REAL_CONST(163476.02187882498/8.0), + REAL_CONST(163502.83276411882/8.0), + REAL_CONST(163529.6447485573/8.0), + REAL_CONST(163556.45783205028/8.0), + REAL_CONST(163583.2720145077/8.0), + REAL_CONST(163610.08729583945/8.0), + REAL_CONST(163636.90367595552/8.0), + REAL_CONST(163663.72115476584/8.0), + REAL_CONST(163690.53973218042/8.0), + REAL_CONST(163717.35940810922/8.0), + REAL_CONST(163744.18018246227/8.0), + REAL_CONST(163771.00205514964/8.0), + REAL_CONST(163797.82502608138/8.0), + REAL_CONST(163824.64909516752/8.0), + REAL_CONST(163851.4742623182/8.0), + REAL_CONST(163878.3005274435/8.0), + REAL_CONST(163905.12789045356/8.0), + REAL_CONST(163931.95635125853/8.0), + REAL_CONST(163958.78590976857/8.0), + REAL_CONST(163985.61656589387/8.0), + REAL_CONST(164012.44831954464/8.0), + REAL_CONST(164039.28117063109/8.0), + REAL_CONST(164066.11511906344/8.0), + REAL_CONST(164092.95016475199/8.0), + REAL_CONST(164119.78630760699/8.0), + REAL_CONST(164146.62354753874/8.0), + REAL_CONST(164173.46188445756/8.0), + REAL_CONST(164200.30131827376/8.0), + REAL_CONST(164227.14184889771/8.0), + REAL_CONST(164253.98347623978/8.0), + REAL_CONST(164280.82620021031/8.0), + REAL_CONST(164307.67002071979/8.0), + REAL_CONST(164334.51493767856/8.0), + REAL_CONST(164361.3609509971/8.0), + REAL_CONST(164388.20806058586/8.0), + REAL_CONST(164415.05626635533/8.0), + REAL_CONST(164441.905568216/8.0), + REAL_CONST(164468.75596607837/8.0), + REAL_CONST(164495.607459853/8.0), + REAL_CONST(164522.4600494504/8.0), + REAL_CONST(164549.31373478117/8.0), + REAL_CONST(164576.16851575591/8.0), + REAL_CONST(164603.02439228518/8.0), + REAL_CONST(164629.88136427966/8.0), + REAL_CONST(164656.73943164994/8.0), + REAL_CONST(164683.59859430668/8.0), + REAL_CONST(164710.45885216061/8.0), + REAL_CONST(164737.32020512238/8.0), + REAL_CONST(164764.1826531027/8.0), + REAL_CONST(164791.04619601235/8.0), + REAL_CONST(164817.91083376206/8.0), + REAL_CONST(164844.77656626256/8.0), + REAL_CONST(164871.64339342469/8.0), + REAL_CONST(164898.51131515924/8.0), + REAL_CONST(164925.38033137703/8.0), + REAL_CONST(164952.25044198887/8.0), + REAL_CONST(164979.1216469057/8.0), + REAL_CONST(165005.9939460383/8.0), + REAL_CONST(165032.86733929763/8.0), + REAL_CONST(165059.7418265946/8.0), + REAL_CONST(165086.61740784015/8.0), + REAL_CONST(165113.4940829452/8.0) +#endif +}; + +#endif + +#ifdef __cplusplus +} +#endif +#endif diff --git a/lib/rbcodec/codecs/libfaad/is.c b/lib/rbcodec/codecs/libfaad/is.c new file mode 100644 index 0000000000..89c6fcf228 --- /dev/null +++ b/lib/rbcodec/codecs/libfaad/is.c @@ -0,0 +1,108 @@ +/* +** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding +** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +** +** Any non-GPL usage of this software or parts of this software is strictly +** forbidden. +** +** Commercial non-GPL licensing of this software is possible. +** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** +** $Id$ +**/ + +#include "common.h" +#include "structs.h" + +#include "syntax.h" +#include "is.h" + +#ifdef FIXED_POINT +static real_t pow05_table[] ICONST_ATTR = { + COEF_CONST(1.68179283050743), /* 0.5^(-3/4) */ + COEF_CONST(1.41421356237310), /* 0.5^(-2/4) */ + COEF_CONST(1.18920711500272), /* 0.5^(-1/4) */ + COEF_CONST(1.0), /* 0.5^( 0/4) */ + COEF_CONST(0.84089641525371), /* 0.5^(+1/4) */ + COEF_CONST(0.70710678118655), /* 0.5^(+2/4) */ + COEF_CONST(0.59460355750136) /* 0.5^(+3/4) */ +}; +#endif + +void is_decode(ic_stream *ics, ic_stream *icsr, real_t *l_spec, real_t *r_spec, + uint16_t frame_len) +{ + uint8_t g, sfb, b; + uint16_t i, k; +#ifndef FIXED_POINT + real_t scale; +#else + int32_t exp, frac; +#endif + + uint16_t nshort = frame_len/8; + uint8_t group = 0; + + for (g = 0; g < icsr->num_window_groups; g++) + { + /* Do intensity stereo decoding */ + for (b = 0; b < icsr->window_group_length[g]; b++) + { + for (sfb = 0; sfb < icsr->max_sfb; sfb++) + { + if (is_intensity(icsr, g, sfb)) + { +#ifdef MAIN_DEC + /* For scalefactor bands coded in intensity stereo the + corresponding predictors in the right channel are + switched to "off". + */ + ics->pred.prediction_used[sfb] = 0; + icsr->pred.prediction_used[sfb] = 0; +#endif + +#ifndef FIXED_POINT + scale = (real_t)pow(0.5, (0.25*icsr->scale_factors[g][sfb])); +#else + exp = icsr->scale_factors[g][sfb] >> 2; + frac = icsr->scale_factors[g][sfb] & 3; +#endif + + /* Scale from left to right channel, + do not touch left channel */ + k = (group*nshort) + icsr->swb_offset[sfb]; + for (i = icsr->swb_offset[sfb]; i < icsr->swb_offset[sfb+1]; i++, k++) + { +#ifndef FIXED_POINT + r_spec[k] = MUL_R(l_spec[k], scale); +#else + if (exp < 0) + r_spec[k] = l_spec[k] << -exp; + else + r_spec[k] = l_spec[k] >> exp; + + r_spec[k] = MUL_C(r_spec[k], pow05_table[frac + 3]); +#endif + if (is_intensity(icsr, g, sfb) != invert_intensity(ics, g, sfb)) + r_spec[k] = -r_spec[k]; + } + } + } + group++; + } + } +} diff --git a/lib/rbcodec/codecs/libfaad/is.h b/lib/rbcodec/codecs/libfaad/is.h new file mode 100644 index 0000000000..1b68f3ec49 --- /dev/null +++ b/lib/rbcodec/codecs/libfaad/is.h @@ -0,0 +1,64 @@ +/* +** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding +** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +** +** Any non-GPL usage of this software or parts of this software is strictly +** forbidden. +** +** Commercial non-GPL licensing of this software is possible. +** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** +** $Id$ +**/ + +#ifndef __IS_H__ +#define __IS_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "syntax.h" + +void is_decode(ic_stream *ics, ic_stream *icsr, real_t *l_spec, real_t *r_spec, + uint16_t frame_len); + +static INLINE int8_t is_intensity(ic_stream *ics, uint8_t group, uint8_t sfb) +{ + switch (ics->sfb_cb[group][sfb]) + { + case INTENSITY_HCB: + return 1; + case INTENSITY_HCB2: + return -1; + default: + return 0; + } +} + +static INLINE int8_t invert_intensity(ic_stream *ics, uint8_t group, uint8_t sfb) +{ + if (ics->ms_mask_present == 1) + return (1-2*ics->ms_used[group][sfb]); + return 1; +} + + +#ifdef __cplusplus +} +#endif +#endif diff --git a/lib/rbcodec/codecs/libfaad/kbd_win.h b/lib/rbcodec/codecs/libfaad/kbd_win.h new file mode 100644 index 0000000000..8abd3c070c --- /dev/null +++ b/lib/rbcodec/codecs/libfaad/kbd_win.h @@ -0,0 +1,2294 @@ +/* +** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding +** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +** +** Any non-GPL usage of this software or parts of this software is strictly +** forbidden. +** +** Commercial non-GPL licensing of this software is possible. +** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** +** $Id$ +**/ + +#ifndef __KBD_WIN_H__ +#define __KBD_WIN_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _MSC_VER +#pragma warning(disable:4305) +#pragma warning(disable:4244) +#endif + +static const real_t kbd_long_1024[] ICONST_ATTR MEM_ALIGN_ATTR = +{ + FRAC_CONST(0.00029256153896361), + FRAC_CONST(0.00042998567353047), + FRAC_CONST(0.00054674074589540), + FRAC_CONST(0.00065482304299792), + FRAC_CONST(0.00075870195068747), + FRAC_CONST(0.00086059331713336), + FRAC_CONST(0.00096177541439010), + FRAC_CONST(0.0010630609410878), + FRAC_CONST(0.0011650036308132), + FRAC_CONST(0.0012680012194148), + FRAC_CONST(0.0013723517232956), + FRAC_CONST(0.0014782864109136), + FRAC_CONST(0.0015859901976719), + FRAC_CONST(0.0016956148252373), + FRAC_CONST(0.0018072876903517), + FRAC_CONST(0.0019211179405514), + FRAC_CONST(0.0020372007924215), + FRAC_CONST(0.0021556206591754), + FRAC_CONST(0.0022764534599614), + FRAC_CONST(0.0023997683540995), + FRAC_CONST(0.0025256290631156), + FRAC_CONST(0.0026540948920831), + FRAC_CONST(0.0027852215281403), + FRAC_CONST(0.0029190616715331), + FRAC_CONST(0.0030556655443223), + FRAC_CONST(0.0031950812943391), + FRAC_CONST(0.0033373553240392), + FRAC_CONST(0.0034825325586930), + FRAC_CONST(0.0036306566699199), + FRAC_CONST(0.0037817702604646), + FRAC_CONST(0.0039359150179719), + FRAC_CONST(0.0040931318437260), + FRAC_CONST(0.0042534609610026), + FRAC_CONST(0.0044169420066964), + FRAC_CONST(0.0045836141091341), + FRAC_CONST(0.0047535159544086), + FRAC_CONST(0.0049266858431214), + FRAC_CONST(0.0051031617390698), + FRAC_CONST(0.0052829813111335), + FRAC_CONST(0.0054661819693975), + FRAC_CONST(0.0056528008963682), + FRAC_CONST(0.0058428750739943), + FRAC_CONST(0.0060364413070882), + FRAC_CONST(0.0062335362436492), + FRAC_CONST(0.0064341963925079), + FRAC_CONST(0.0066384581386503), + FRAC_CONST(0.0068463577565218), + FRAC_CONST(0.0070579314215715), + FRAC_CONST(0.0072732152202559), + FRAC_CONST(0.0074922451586909), + FRAC_CONST(0.0077150571701162), + FRAC_CONST(0.0079416871213115), + FRAC_CONST(0.0081721708180857), + FRAC_CONST(0.0084065440099458), + FRAC_CONST(0.0086448423940363), + FRAC_CONST(0.0088871016184291), + FRAC_CONST(0.0091333572848345), + FRAC_CONST(0.0093836449507939), + FRAC_CONST(0.0096380001314086), + FRAC_CONST(0.0098964583006517), + FRAC_CONST(0.010159054892306), + FRAC_CONST(0.010425825300561), + FRAC_CONST(0.010696804880310), + FRAC_CONST(0.010972028947167), + FRAC_CONST(0.011251532777236), + FRAC_CONST(0.011535351606646), + FRAC_CONST(0.011823520630897), + FRAC_CONST(0.012116075003993), + FRAC_CONST(0.012413049837429), + FRAC_CONST(0.012714480198999), + FRAC_CONST(0.013020401111478), + FRAC_CONST(0.013330847551161), + FRAC_CONST(0.013645854446288), + FRAC_CONST(0.013965456675352), + FRAC_CONST(0.014289689065314), + FRAC_CONST(0.014618586389712), + FRAC_CONST(0.014952183366697), + FRAC_CONST(0.015290514656976), + FRAC_CONST(0.015633614861688), + FRAC_CONST(0.015981518520214), + FRAC_CONST(0.016334260107915), + FRAC_CONST(0.016691874033817), + FRAC_CONST(0.017054394638241), + FRAC_CONST(0.017421856190380), + FRAC_CONST(0.017794292885832), + FRAC_CONST(0.018171738844085), + FRAC_CONST(0.018554228105962), + FRAC_CONST(0.018941794631032), + FRAC_CONST(0.019334472294980), + FRAC_CONST(0.019732294886947), + FRAC_CONST(0.020135296106839), + FRAC_CONST(0.020543509562604), + FRAC_CONST(0.020956968767488), + FRAC_CONST(0.021375707137257), + FRAC_CONST(0.021799757987407), + FRAC_CONST(0.022229154530343), + FRAC_CONST(0.022663929872540), + FRAC_CONST(0.023104117011689), + FRAC_CONST(0.023549748833816), + FRAC_CONST(0.024000858110398), + FRAC_CONST(0.024457477495451), + FRAC_CONST(0.024919639522613), + FRAC_CONST(0.025387376602207), + FRAC_CONST(0.025860721018295), + FRAC_CONST(0.026339704925726), + FRAC_CONST(0.026824360347160), + FRAC_CONST(0.027314719170100), + FRAC_CONST(0.027810813143900), + FRAC_CONST(0.028312673876775), + FRAC_CONST(0.028820332832801), + FRAC_CONST(0.029333821328905), + FRAC_CONST(0.029853170531859), + FRAC_CONST(0.030378411455255), + FRAC_CONST(0.030909574956490), + FRAC_CONST(0.031446691733739), + FRAC_CONST(0.031989792322926), + FRAC_CONST(0.032538907094693), + FRAC_CONST(0.033094066251369), + FRAC_CONST(0.033655299823935), + FRAC_CONST(0.034222637668991), + FRAC_CONST(0.034796109465717), + FRAC_CONST(0.035375744712844), + FRAC_CONST(0.035961572725616), + FRAC_CONST(0.036553622632758), + FRAC_CONST(0.037151923373446), + FRAC_CONST(0.037756503694277), + FRAC_CONST(0.038367392146243), + FRAC_CONST(0.038984617081711), + FRAC_CONST(0.039608206651398), + FRAC_CONST(0.040238188801359), + FRAC_CONST(0.040874591269976), + FRAC_CONST(0.041517441584950), + FRAC_CONST(0.042166767060301), + FRAC_CONST(0.042822594793376), + FRAC_CONST(0.043484951661852), + FRAC_CONST(0.044153864320760), + FRAC_CONST(0.044829359199509), + FRAC_CONST(0.045511462498913), + FRAC_CONST(0.046200200188234), + FRAC_CONST(0.046895598002228), + FRAC_CONST(0.047597681438201), + FRAC_CONST(0.048306475753074), + FRAC_CONST(0.049022005960455), + FRAC_CONST(0.049744296827725), + FRAC_CONST(0.050473372873129), + FRAC_CONST(0.051209258362879), + FRAC_CONST(0.051951977308273), + FRAC_CONST(0.052701553462813), + FRAC_CONST(0.053458010319350), + FRAC_CONST(0.054221371107223), + FRAC_CONST(0.054991658789428), + FRAC_CONST(0.055768896059787), + FRAC_CONST(0.056553105340134), + FRAC_CONST(0.057344308777513), + FRAC_CONST(0.058142528241393), + FRAC_CONST(0.058947785320893), + FRAC_CONST(0.059760101322019), + FRAC_CONST(0.060579497264926), + FRAC_CONST(0.061405993881180), + FRAC_CONST(0.062239611611049), + FRAC_CONST(0.063080370600799), + FRAC_CONST(0.063928290700012), + FRAC_CONST(0.064783391458919), + FRAC_CONST(0.065645692125747), + FRAC_CONST(0.066515211644086), + FRAC_CONST(0.067391968650269), + FRAC_CONST(0.068275981470777), + FRAC_CONST(0.069167268119652), + FRAC_CONST(0.070065846295935), + FRAC_CONST(0.070971733381121), + FRAC_CONST(0.071884946436630), + FRAC_CONST(0.072805502201299), + FRAC_CONST(0.073733417088896), + FRAC_CONST(0.074668707185649), + FRAC_CONST(0.075611388247794), + FRAC_CONST(0.076561475699152), + FRAC_CONST(0.077518984628715), + FRAC_CONST(0.078483929788261), + FRAC_CONST(0.079456325589986), + FRAC_CONST(0.080436186104162), + FRAC_CONST(0.081423525056808), + FRAC_CONST(0.082418355827392), + FRAC_CONST(0.083420691446553), + FRAC_CONST(0.084430544593841), + FRAC_CONST(0.085447927595483), + FRAC_CONST(0.086472852422178), + FRAC_CONST(0.087505330686900), + FRAC_CONST(0.088545373642744), + FRAC_CONST(0.089592992180780), + FRAC_CONST(0.090648196827937), + FRAC_CONST(0.091710997744919), + FRAC_CONST(0.092781404724131), + FRAC_CONST(0.093859427187640), + FRAC_CONST(0.094945074185163), + FRAC_CONST(0.096038354392069), + FRAC_CONST(0.097139276107423), + FRAC_CONST(0.098247847252041), + FRAC_CONST(0.099364075366580), + FRAC_CONST(0.10048796760965), + FRAC_CONST(0.10161953075597), + FRAC_CONST(0.10275877119451), + FRAC_CONST(0.10390569492671), + FRAC_CONST(0.10506030756469), + FRAC_CONST(0.10622261432949), + FRAC_CONST(0.10739262004941), + FRAC_CONST(0.10857032915821), + FRAC_CONST(0.10975574569357), + FRAC_CONST(0.11094887329534), + FRAC_CONST(0.11214971520402), + FRAC_CONST(0.11335827425914), + FRAC_CONST(0.11457455289772), + FRAC_CONST(0.11579855315274), + FRAC_CONST(0.11703027665170), + FRAC_CONST(0.11826972461510), + FRAC_CONST(0.11951689785504), + FRAC_CONST(0.12077179677383), + FRAC_CONST(0.12203442136263), + FRAC_CONST(0.12330477120008), + FRAC_CONST(0.12458284545102), + FRAC_CONST(0.12586864286523), + FRAC_CONST(0.12716216177615), + FRAC_CONST(0.12846340009971), + FRAC_CONST(0.12977235533312), + FRAC_CONST(0.13108902455375), + FRAC_CONST(0.13241340441801), + FRAC_CONST(0.13374549116025), + FRAC_CONST(0.13508528059173), + FRAC_CONST(0.13643276809961), + FRAC_CONST(0.13778794864595), + FRAC_CONST(0.13915081676677), + FRAC_CONST(0.14052136657114), + FRAC_CONST(0.14189959174027), + FRAC_CONST(0.14328548552671), + FRAC_CONST(0.14467904075349), + FRAC_CONST(0.14608024981336), + FRAC_CONST(0.14748910466804), + FRAC_CONST(0.14890559684750), + FRAC_CONST(0.15032971744929), + FRAC_CONST(0.15176145713790), + FRAC_CONST(0.15320080614414), + FRAC_CONST(0.15464775426459), + FRAC_CONST(0.15610229086100), + FRAC_CONST(0.15756440485987), + FRAC_CONST(0.15903408475193), + FRAC_CONST(0.16051131859170), + FRAC_CONST(0.16199609399712), + FRAC_CONST(0.16348839814917), + FRAC_CONST(0.16498821779156), + FRAC_CONST(0.16649553923042), + FRAC_CONST(0.16801034833404), + FRAC_CONST(0.16953263053270), + FRAC_CONST(0.17106237081842), + FRAC_CONST(0.17259955374484), + FRAC_CONST(0.17414416342714), + FRAC_CONST(0.17569618354193), + FRAC_CONST(0.17725559732720), + FRAC_CONST(0.17882238758238), + FRAC_CONST(0.18039653666830), + FRAC_CONST(0.18197802650733), + FRAC_CONST(0.18356683858343), + FRAC_CONST(0.18516295394233), + FRAC_CONST(0.18676635319174), + FRAC_CONST(0.18837701650148), + FRAC_CONST(0.18999492360384), + FRAC_CONST(0.19162005379380), + FRAC_CONST(0.19325238592940), + FRAC_CONST(0.19489189843209), + FRAC_CONST(0.19653856928714), + FRAC_CONST(0.19819237604409), + FRAC_CONST(0.19985329581721), + FRAC_CONST(0.20152130528605), + FRAC_CONST(0.20319638069594), + FRAC_CONST(0.20487849785865), + FRAC_CONST(0.20656763215298), + FRAC_CONST(0.20826375852540), + FRAC_CONST(0.20996685149083), + FRAC_CONST(0.21167688513330), + FRAC_CONST(0.21339383310678), + FRAC_CONST(0.21511766863598), + FRAC_CONST(0.21684836451719), + FRAC_CONST(0.21858589311922), + FRAC_CONST(0.22033022638425), + FRAC_CONST(0.22208133582887), + FRAC_CONST(0.22383919254503), + FRAC_CONST(0.22560376720111), + FRAC_CONST(0.22737503004300), + FRAC_CONST(0.22915295089517), + FRAC_CONST(0.23093749916189), + FRAC_CONST(0.23272864382838), + FRAC_CONST(0.23452635346201), + FRAC_CONST(0.23633059621364), + FRAC_CONST(0.23814133981883), + FRAC_CONST(0.23995855159925), + FRAC_CONST(0.24178219846403), + FRAC_CONST(0.24361224691114), + FRAC_CONST(0.24544866302890), + FRAC_CONST(0.24729141249740), + FRAC_CONST(0.24914046059007), + FRAC_CONST(0.25099577217522), + FRAC_CONST(0.25285731171763), + FRAC_CONST(0.25472504328019), + FRAC_CONST(0.25659893052556), + FRAC_CONST(0.25847893671788), + FRAC_CONST(0.26036502472451), + FRAC_CONST(0.26225715701781), + FRAC_CONST(0.26415529567692), + FRAC_CONST(0.26605940238966), + FRAC_CONST(0.26796943845439), + FRAC_CONST(0.26988536478190), + FRAC_CONST(0.27180714189742), + FRAC_CONST(0.27373472994256), + FRAC_CONST(0.27566808867736), + FRAC_CONST(0.27760717748238), + FRAC_CONST(0.27955195536071), + FRAC_CONST(0.28150238094021), + FRAC_CONST(0.28345841247557), + FRAC_CONST(0.28542000785059), + FRAC_CONST(0.28738712458038), + FRAC_CONST(0.28935971981364), + FRAC_CONST(0.29133775033492), + FRAC_CONST(0.29332117256704), + FRAC_CONST(0.29530994257338), + FRAC_CONST(0.29730401606034), + FRAC_CONST(0.29930334837974), + FRAC_CONST(0.30130789453132), + FRAC_CONST(0.30331760916521), + FRAC_CONST(0.30533244658452), + FRAC_CONST(0.30735236074785), + FRAC_CONST(0.30937730527195), + FRAC_CONST(0.31140723343430), + FRAC_CONST(0.31344209817583), + FRAC_CONST(0.31548185210356), + FRAC_CONST(0.31752644749341), + FRAC_CONST(0.31957583629288), + FRAC_CONST(0.32162997012390), + FRAC_CONST(0.32368880028565), + FRAC_CONST(0.32575227775738), + FRAC_CONST(0.32782035320134), + FRAC_CONST(0.32989297696566), + FRAC_CONST(0.33197009908736), + FRAC_CONST(0.33405166929523), + FRAC_CONST(0.33613763701295), + FRAC_CONST(0.33822795136203), + FRAC_CONST(0.34032256116495), + FRAC_CONST(0.34242141494820), + FRAC_CONST(0.34452446094547), + FRAC_CONST(0.34663164710072), + FRAC_CONST(0.34874292107143), + FRAC_CONST(0.35085823023181), + FRAC_CONST(0.35297752167598), + FRAC_CONST(0.35510074222129), + FRAC_CONST(0.35722783841160), + FRAC_CONST(0.35935875652060), + FRAC_CONST(0.36149344255514), + FRAC_CONST(0.36363184225864), + FRAC_CONST(0.36577390111444), + FRAC_CONST(0.36791956434930), + FRAC_CONST(0.37006877693676), + FRAC_CONST(0.37222148360070), + FRAC_CONST(0.37437762881878), + FRAC_CONST(0.37653715682603), + FRAC_CONST(0.37870001161834), + FRAC_CONST(0.38086613695607), + FRAC_CONST(0.38303547636766), + FRAC_CONST(0.38520797315322), + FRAC_CONST(0.38738357038821), + FRAC_CONST(0.38956221092708), + FRAC_CONST(0.39174383740701), + FRAC_CONST(0.39392839225157), + FRAC_CONST(0.39611581767449), + FRAC_CONST(0.39830605568342), + FRAC_CONST(0.40049904808370), + FRAC_CONST(0.40269473648218), + FRAC_CONST(0.40489306229101), + FRAC_CONST(0.40709396673153), + FRAC_CONST(0.40929739083810), + FRAC_CONST(0.41150327546197), + FRAC_CONST(0.41371156127524), + FRAC_CONST(0.41592218877472), + FRAC_CONST(0.41813509828594), + FRAC_CONST(0.42035022996702), + FRAC_CONST(0.42256752381274), + FRAC_CONST(0.42478691965848), + FRAC_CONST(0.42700835718423), + FRAC_CONST(0.42923177591866), + FRAC_CONST(0.43145711524314), + FRAC_CONST(0.43368431439580), + FRAC_CONST(0.43591331247564), + FRAC_CONST(0.43814404844658), + FRAC_CONST(0.44037646114161), + FRAC_CONST(0.44261048926688), + FRAC_CONST(0.44484607140589), + FRAC_CONST(0.44708314602359), + FRAC_CONST(0.44932165147057), + FRAC_CONST(0.45156152598727), + FRAC_CONST(0.45380270770813), + FRAC_CONST(0.45604513466581), + FRAC_CONST(0.45828874479543), + FRAC_CONST(0.46053347593880), + FRAC_CONST(0.46277926584861), + FRAC_CONST(0.46502605219277), + FRAC_CONST(0.46727377255861), + FRAC_CONST(0.46952236445718), + FRAC_CONST(0.47177176532752), + FRAC_CONST(0.47402191254100), + FRAC_CONST(0.47627274340557), + FRAC_CONST(0.47852419517009), + FRAC_CONST(0.48077620502869), + FRAC_CONST(0.48302871012505), + FRAC_CONST(0.48528164755674), + FRAC_CONST(0.48753495437962), + FRAC_CONST(0.48978856761212), + FRAC_CONST(0.49204242423966), + FRAC_CONST(0.49429646121898), + FRAC_CONST(0.49655061548250), + FRAC_CONST(0.49880482394273), + FRAC_CONST(0.50105902349665), + FRAC_CONST(0.50331315103004), + FRAC_CONST(0.50556714342194), + FRAC_CONST(0.50782093754901), + FRAC_CONST(0.51007447028990), + FRAC_CONST(0.51232767852971), + FRAC_CONST(0.51458049916433), + FRAC_CONST(0.51683286910489), + FRAC_CONST(0.51908472528213), + FRAC_CONST(0.52133600465083), + FRAC_CONST(0.52358664419420), + FRAC_CONST(0.52583658092832), + FRAC_CONST(0.52808575190648), + FRAC_CONST(0.53033409422367), + FRAC_CONST(0.53258154502092), + FRAC_CONST(0.53482804148974), + FRAC_CONST(0.53707352087652), + FRAC_CONST(0.53931792048690), + FRAC_CONST(0.54156117769021), + FRAC_CONST(0.54380322992385), + FRAC_CONST(0.54604401469766), + FRAC_CONST(0.54828346959835), + FRAC_CONST(0.55052153229384), + FRAC_CONST(0.55275814053768), + FRAC_CONST(0.55499323217338), + FRAC_CONST(0.55722674513883), + FRAC_CONST(0.55945861747062), + FRAC_CONST(0.56168878730842), + FRAC_CONST(0.56391719289930), + FRAC_CONST(0.56614377260214), + FRAC_CONST(0.56836846489188), + FRAC_CONST(0.57059120836390), + FRAC_CONST(0.57281194173835), + FRAC_CONST(0.57503060386439), + FRAC_CONST(0.57724713372458), + FRAC_CONST(0.57946147043912), + FRAC_CONST(0.58167355327012), + FRAC_CONST(0.58388332162591), + FRAC_CONST(0.58609071506528), + FRAC_CONST(0.58829567330173), + FRAC_CONST(0.59049813620770), + FRAC_CONST(0.59269804381879), + FRAC_CONST(0.59489533633802), + FRAC_CONST(0.59708995413996), + FRAC_CONST(0.59928183777495), + FRAC_CONST(0.60147092797329), + FRAC_CONST(0.60365716564937), + FRAC_CONST(0.60584049190582), + FRAC_CONST(0.60802084803764), + FRAC_CONST(0.61019817553632), + FRAC_CONST(0.61237241609393), + FRAC_CONST(0.61454351160718), + FRAC_CONST(0.61671140418155), + FRAC_CONST(0.61887603613527), + FRAC_CONST(0.62103735000336), + FRAC_CONST(0.62319528854167), + FRAC_CONST(0.62534979473088), + FRAC_CONST(0.62750081178042), + FRAC_CONST(0.62964828313250), + FRAC_CONST(0.63179215246597), + FRAC_CONST(0.63393236370030), + FRAC_CONST(0.63606886099946), + FRAC_CONST(0.63820158877577), + FRAC_CONST(0.64033049169379), + FRAC_CONST(0.64245551467413), + FRAC_CONST(0.64457660289729), + FRAC_CONST(0.64669370180740), + FRAC_CONST(0.64880675711607), + FRAC_CONST(0.65091571480603), + FRAC_CONST(0.65302052113494), + FRAC_CONST(0.65512112263906), + FRAC_CONST(0.65721746613689), + FRAC_CONST(0.65930949873289), + FRAC_CONST(0.66139716782102), + FRAC_CONST(0.66348042108842), + FRAC_CONST(0.66555920651892), + FRAC_CONST(0.66763347239664), + FRAC_CONST(0.66970316730947), + FRAC_CONST(0.67176824015260), + FRAC_CONST(0.67382864013196), + FRAC_CONST(0.67588431676768), + FRAC_CONST(0.67793521989751), + FRAC_CONST(0.67998129968017), + FRAC_CONST(0.68202250659876), + FRAC_CONST(0.68405879146403), + FRAC_CONST(0.68609010541774), + FRAC_CONST(0.68811639993588), + FRAC_CONST(0.69013762683195), + FRAC_CONST(0.69215373826012), + FRAC_CONST(0.69416468671849), + FRAC_CONST(0.69617042505214), + FRAC_CONST(0.69817090645634), + FRAC_CONST(0.70016608447958), + FRAC_CONST(0.70215591302664), + FRAC_CONST(0.70414034636163), + FRAC_CONST(0.70611933911096), + FRAC_CONST(0.70809284626630), + FRAC_CONST(0.71006082318751), + FRAC_CONST(0.71202322560554), + FRAC_CONST(0.71398000962530), + FRAC_CONST(0.71593113172842), + FRAC_CONST(0.71787654877613), + FRAC_CONST(0.71981621801195), + FRAC_CONST(0.72175009706445), + FRAC_CONST(0.72367814394990), + FRAC_CONST(0.72560031707496), + FRAC_CONST(0.72751657523927), + FRAC_CONST(0.72942687763803), + FRAC_CONST(0.73133118386457), + FRAC_CONST(0.73322945391280), + FRAC_CONST(0.73512164817975), + FRAC_CONST(0.73700772746796), + FRAC_CONST(0.73888765298787), + FRAC_CONST(0.74076138636020), + FRAC_CONST(0.74262888961827), + FRAC_CONST(0.74449012521027), + FRAC_CONST(0.74634505600152), + FRAC_CONST(0.74819364527663), + FRAC_CONST(0.75003585674175), + FRAC_CONST(0.75187165452661), + FRAC_CONST(0.75370100318668), + FRAC_CONST(0.75552386770515), + FRAC_CONST(0.75734021349500), + FRAC_CONST(0.75915000640095), + FRAC_CONST(0.76095321270137), + FRAC_CONST(0.76274979911019), + FRAC_CONST(0.76453973277875), + FRAC_CONST(0.76632298129757), + FRAC_CONST(0.76809951269819), + FRAC_CONST(0.76986929545481), + FRAC_CONST(0.77163229848604), + FRAC_CONST(0.77338849115651), + FRAC_CONST(0.77513784327849), + FRAC_CONST(0.77688032511340), + FRAC_CONST(0.77861590737340), + FRAC_CONST(0.78034456122283), + FRAC_CONST(0.78206625827961), + FRAC_CONST(0.78378097061667), + FRAC_CONST(0.78548867076330), + FRAC_CONST(0.78718933170643), + FRAC_CONST(0.78888292689189), + FRAC_CONST(0.79056943022564), + FRAC_CONST(0.79224881607494), + FRAC_CONST(0.79392105926949), + FRAC_CONST(0.79558613510249), + FRAC_CONST(0.79724401933170), + FRAC_CONST(0.79889468818046), + FRAC_CONST(0.80053811833858), + FRAC_CONST(0.80217428696334), + FRAC_CONST(0.80380317168028), + FRAC_CONST(0.80542475058405), + FRAC_CONST(0.80703900223920), + FRAC_CONST(0.80864590568089), + FRAC_CONST(0.81024544041560), + FRAC_CONST(0.81183758642175), + FRAC_CONST(0.81342232415032), + FRAC_CONST(0.81499963452540), + FRAC_CONST(0.81656949894467), + FRAC_CONST(0.81813189927991), + FRAC_CONST(0.81968681787738), + FRAC_CONST(0.82123423755821), + FRAC_CONST(0.82277414161874), + FRAC_CONST(0.82430651383076), + FRAC_CONST(0.82583133844180), + FRAC_CONST(0.82734860017528), + FRAC_CONST(0.82885828423070), + FRAC_CONST(0.83036037628369), + FRAC_CONST(0.83185486248609), + FRAC_CONST(0.83334172946597), + FRAC_CONST(0.83482096432759), + FRAC_CONST(0.83629255465130), + FRAC_CONST(0.83775648849344), + FRAC_CONST(0.83921275438615), + FRAC_CONST(0.84066134133716), + FRAC_CONST(0.84210223882952), + FRAC_CONST(0.84353543682130), + FRAC_CONST(0.84496092574524), + FRAC_CONST(0.84637869650833), + FRAC_CONST(0.84778874049138), + FRAC_CONST(0.84919104954855), + FRAC_CONST(0.85058561600677), + FRAC_CONST(0.85197243266520), + FRAC_CONST(0.85335149279457), + FRAC_CONST(0.85472279013653), + FRAC_CONST(0.85608631890295), + FRAC_CONST(0.85744207377513), + FRAC_CONST(0.85879004990298), + FRAC_CONST(0.86013024290422), + FRAC_CONST(0.86146264886346), + FRAC_CONST(0.86278726433124), + FRAC_CONST(0.86410408632306), + FRAC_CONST(0.86541311231838), + FRAC_CONST(0.86671434025950), + FRAC_CONST(0.86800776855046), + FRAC_CONST(0.86929339605590), + FRAC_CONST(0.87057122209981), + FRAC_CONST(0.87184124646433), + FRAC_CONST(0.87310346938840), + FRAC_CONST(0.87435789156650), + FRAC_CONST(0.87560451414719), + FRAC_CONST(0.87684333873173), + FRAC_CONST(0.87807436737261), + FRAC_CONST(0.87929760257204), + FRAC_CONST(0.88051304728038), + FRAC_CONST(0.88172070489456), + FRAC_CONST(0.88292057925645), + FRAC_CONST(0.88411267465117), + FRAC_CONST(0.88529699580537), + FRAC_CONST(0.88647354788545), + FRAC_CONST(0.88764233649580), + FRAC_CONST(0.88880336767692), + FRAC_CONST(0.88995664790351), + FRAC_CONST(0.89110218408260), + FRAC_CONST(0.89223998355154), + FRAC_CONST(0.89337005407600), + FRAC_CONST(0.89449240384793), + FRAC_CONST(0.89560704148345), + FRAC_CONST(0.89671397602074), + FRAC_CONST(0.89781321691786), + FRAC_CONST(0.89890477405053), + FRAC_CONST(0.89998865770993), + FRAC_CONST(0.90106487860034), + FRAC_CONST(0.90213344783689), + FRAC_CONST(0.90319437694315), + FRAC_CONST(0.90424767784873), + FRAC_CONST(0.90529336288690), + FRAC_CONST(0.90633144479201), + FRAC_CONST(0.90736193669708), + FRAC_CONST(0.90838485213119), + FRAC_CONST(0.90940020501694), + FRAC_CONST(0.91040800966776), + FRAC_CONST(0.91140828078533), + FRAC_CONST(0.91240103345685), + FRAC_CONST(0.91338628315231), + FRAC_CONST(0.91436404572173), + FRAC_CONST(0.91533433739238), + FRAC_CONST(0.91629717476594), + FRAC_CONST(0.91725257481564), + FRAC_CONST(0.91820055488334), + FRAC_CONST(0.91914113267664), + FRAC_CONST(0.92007432626589), + FRAC_CONST(0.92100015408120), + FRAC_CONST(0.92191863490944), + FRAC_CONST(0.92282978789113), + FRAC_CONST(0.92373363251740), + FRAC_CONST(0.92463018862687), + FRAC_CONST(0.92551947640245), + FRAC_CONST(0.92640151636824), + FRAC_CONST(0.92727632938624), + FRAC_CONST(0.92814393665320), + FRAC_CONST(0.92900435969727), + FRAC_CONST(0.92985762037477), + FRAC_CONST(0.93070374086684), + FRAC_CONST(0.93154274367610), + FRAC_CONST(0.93237465162328), + FRAC_CONST(0.93319948784382), + FRAC_CONST(0.93401727578443), + FRAC_CONST(0.93482803919967), + FRAC_CONST(0.93563180214841), + FRAC_CONST(0.93642858899043), + FRAC_CONST(0.93721842438279), + FRAC_CONST(0.93800133327637), + FRAC_CONST(0.93877734091223), + FRAC_CONST(0.93954647281807), + FRAC_CONST(0.94030875480458), + FRAC_CONST(0.94106421296182), + FRAC_CONST(0.94181287365556), + FRAC_CONST(0.94255476352362), + FRAC_CONST(0.94328990947213), + FRAC_CONST(0.94401833867184), + FRAC_CONST(0.94474007855439), + FRAC_CONST(0.94545515680855), + FRAC_CONST(0.94616360137644), + FRAC_CONST(0.94686544044975), + FRAC_CONST(0.94756070246592), + FRAC_CONST(0.94824941610434), + FRAC_CONST(0.94893161028248), + FRAC_CONST(0.94960731415209), + FRAC_CONST(0.95027655709525), + FRAC_CONST(0.95093936872056), + FRAC_CONST(0.95159577885924), + FRAC_CONST(0.95224581756115), + FRAC_CONST(0.95288951509097), + FRAC_CONST(0.95352690192417), + FRAC_CONST(0.95415800874314), + FRAC_CONST(0.95478286643320), + FRAC_CONST(0.95540150607863), + FRAC_CONST(0.95601395895871), + FRAC_CONST(0.95662025654373), + FRAC_CONST(0.95722043049100), + FRAC_CONST(0.95781451264084), + FRAC_CONST(0.95840253501260), + FRAC_CONST(0.95898452980058), + FRAC_CONST(0.95956052937008), + FRAC_CONST(0.96013056625336), + FRAC_CONST(0.96069467314557), + FRAC_CONST(0.96125288290073), + FRAC_CONST(0.96180522852773), + FRAC_CONST(0.96235174318622), + FRAC_CONST(0.96289246018262), + FRAC_CONST(0.96342741296604), + FRAC_CONST(0.96395663512424), + FRAC_CONST(0.96448016037959), + FRAC_CONST(0.96499802258499), + FRAC_CONST(0.96551025571985), + FRAC_CONST(0.96601689388602), + FRAC_CONST(0.96651797130376), + FRAC_CONST(0.96701352230768), + FRAC_CONST(0.96750358134269), + FRAC_CONST(0.96798818295998), + FRAC_CONST(0.96846736181297), + FRAC_CONST(0.96894115265327), + FRAC_CONST(0.96940959032667), + FRAC_CONST(0.96987270976912), + FRAC_CONST(0.97033054600270), + FRAC_CONST(0.97078313413161), + FRAC_CONST(0.97123050933818), + FRAC_CONST(0.97167270687887), + FRAC_CONST(0.97210976208030), + FRAC_CONST(0.97254171033525), + FRAC_CONST(0.97296858709871), + FRAC_CONST(0.97339042788392), + FRAC_CONST(0.97380726825843), + FRAC_CONST(0.97421914384017), + FRAC_CONST(0.97462609029350), + FRAC_CONST(0.97502814332534), + FRAC_CONST(0.97542533868127), + FRAC_CONST(0.97581771214160), + FRAC_CONST(0.97620529951759), + FRAC_CONST(0.97658813664749), + FRAC_CONST(0.97696625939282), + FRAC_CONST(0.97733970363445), + FRAC_CONST(0.97770850526884), + FRAC_CONST(0.97807270020427), + FRAC_CONST(0.97843232435704), + FRAC_CONST(0.97878741364771), + FRAC_CONST(0.97913800399743), + FRAC_CONST(0.97948413132414), + FRAC_CONST(0.97982583153895), + FRAC_CONST(0.98016314054243), + FRAC_CONST(0.98049609422096), + FRAC_CONST(0.98082472844313), + FRAC_CONST(0.98114907905608), + FRAC_CONST(0.98146918188197), + FRAC_CONST(0.98178507271438), + FRAC_CONST(0.98209678731477), + FRAC_CONST(0.98240436140902), + FRAC_CONST(0.98270783068385), + FRAC_CONST(0.98300723078342), + FRAC_CONST(0.98330259730589), + FRAC_CONST(0.98359396579995), + FRAC_CONST(0.98388137176152), + FRAC_CONST(0.98416485063031), + FRAC_CONST(0.98444443778651), + FRAC_CONST(0.98472016854752), + FRAC_CONST(0.98499207816463), + FRAC_CONST(0.98526020181980), + FRAC_CONST(0.98552457462240), + FRAC_CONST(0.98578523160609), + FRAC_CONST(0.98604220772560), + FRAC_CONST(0.98629553785362), + FRAC_CONST(0.98654525677772), + FRAC_CONST(0.98679139919726), + FRAC_CONST(0.98703399972035), + FRAC_CONST(0.98727309286089), + FRAC_CONST(0.98750871303556), + FRAC_CONST(0.98774089456089), + FRAC_CONST(0.98796967165036), + FRAC_CONST(0.98819507841154), + FRAC_CONST(0.98841714884323), + FRAC_CONST(0.98863591683269), + FRAC_CONST(0.98885141615285), + FRAC_CONST(0.98906368045957), + FRAC_CONST(0.98927274328896), + FRAC_CONST(0.98947863805473), + FRAC_CONST(0.98968139804554), + FRAC_CONST(0.98988105642241), + FRAC_CONST(0.99007764621618), + FRAC_CONST(0.99027120032501), + FRAC_CONST(0.99046175151186), + FRAC_CONST(0.99064933240208), + FRAC_CONST(0.99083397548099), + FRAC_CONST(0.99101571309153), + FRAC_CONST(0.99119457743191), + FRAC_CONST(0.99137060055337), + FRAC_CONST(0.99154381435784), + FRAC_CONST(0.99171425059582), + FRAC_CONST(0.99188194086414), + FRAC_CONST(0.99204691660388), + FRAC_CONST(0.99220920909823), + FRAC_CONST(0.99236884947045), + FRAC_CONST(0.99252586868186), + FRAC_CONST(0.99268029752989), + FRAC_CONST(0.99283216664606), + FRAC_CONST(0.99298150649419), + FRAC_CONST(0.99312834736847), + FRAC_CONST(0.99327271939167), + FRAC_CONST(0.99341465251338), + FRAC_CONST(0.99355417650825), + FRAC_CONST(0.99369132097430), + FRAC_CONST(0.99382611533130), + FRAC_CONST(0.99395858881910), + FRAC_CONST(0.99408877049612), + FRAC_CONST(0.99421668923778), + FRAC_CONST(0.99434237373503), + FRAC_CONST(0.99446585249289), + FRAC_CONST(0.99458715382906), + FRAC_CONST(0.99470630587254), + FRAC_CONST(0.99482333656229), + FRAC_CONST(0.99493827364600), + FRAC_CONST(0.99505114467878), + FRAC_CONST(0.99516197702200), + FRAC_CONST(0.99527079784214), + FRAC_CONST(0.99537763410962), + FRAC_CONST(0.99548251259777), + FRAC_CONST(0.99558545988178), + FRAC_CONST(0.99568650233767), + FRAC_CONST(0.99578566614138), + FRAC_CONST(0.99588297726783), + FRAC_CONST(0.99597846149005), + FRAC_CONST(0.99607214437834), + FRAC_CONST(0.99616405129947), + FRAC_CONST(0.99625420741595), + FRAC_CONST(0.99634263768527), + FRAC_CONST(0.99642936685928), + FRAC_CONST(0.99651441948352), + FRAC_CONST(0.99659781989663), + FRAC_CONST(0.99667959222978), + FRAC_CONST(0.99675976040620), + FRAC_CONST(0.99683834814063), + FRAC_CONST(0.99691537893895), + FRAC_CONST(0.99699087609774), + FRAC_CONST(0.99706486270391), + FRAC_CONST(0.99713736163442), + FRAC_CONST(0.99720839555593), + FRAC_CONST(0.99727798692461), + FRAC_CONST(0.99734615798589), + FRAC_CONST(0.99741293077431), + FRAC_CONST(0.99747832711337), + FRAC_CONST(0.99754236861541), + FRAC_CONST(0.99760507668158), + FRAC_CONST(0.99766647250181), + FRAC_CONST(0.99772657705478), + FRAC_CONST(0.99778541110799), + FRAC_CONST(0.99784299521785), + FRAC_CONST(0.99789934972976), + FRAC_CONST(0.99795449477828), + FRAC_CONST(0.99800845028730), + FRAC_CONST(0.99806123597027), + FRAC_CONST(0.99811287133042), + FRAC_CONST(0.99816337566108), + FRAC_CONST(0.99821276804596), + FRAC_CONST(0.99826106735952), + FRAC_CONST(0.99830829226732), + FRAC_CONST(0.99835446122649), + FRAC_CONST(0.99839959248609), + FRAC_CONST(0.99844370408765), + FRAC_CONST(0.99848681386566), + FRAC_CONST(0.99852893944805), + FRAC_CONST(0.99857009825685), + FRAC_CONST(0.99861030750869), + FRAC_CONST(0.99864958421549), + FRAC_CONST(0.99868794518504), + FRAC_CONST(0.99872540702178), + FRAC_CONST(0.99876198612738), + FRAC_CONST(0.99879769870160), + FRAC_CONST(0.99883256074295), + FRAC_CONST(0.99886658804953), + FRAC_CONST(0.99889979621983), + FRAC_CONST(0.99893220065356), + FRAC_CONST(0.99896381655254), + FRAC_CONST(0.99899465892154), + FRAC_CONST(0.99902474256924), + FRAC_CONST(0.99905408210916), + FRAC_CONST(0.99908269196056), + FRAC_CONST(0.99911058634952), + FRAC_CONST(0.99913777930986), + FRAC_CONST(0.99916428468421), + FRAC_CONST(0.99919011612505), + FRAC_CONST(0.99921528709576), + FRAC_CONST(0.99923981087174), + FRAC_CONST(0.99926370054150), + FRAC_CONST(0.99928696900779), + FRAC_CONST(0.99930962898876), + FRAC_CONST(0.99933169301910), + FRAC_CONST(0.99935317345126), + FRAC_CONST(0.99937408245662), + FRAC_CONST(0.99939443202674), + FRAC_CONST(0.99941423397457), + FRAC_CONST(0.99943349993572), + FRAC_CONST(0.99945224136972), + FRAC_CONST(0.99947046956130), + FRAC_CONST(0.99948819562171), + FRAC_CONST(0.99950543049000), + FRAC_CONST(0.99952218493439), + FRAC_CONST(0.99953846955355), + FRAC_CONST(0.99955429477803), + FRAC_CONST(0.99956967087154), + FRAC_CONST(0.99958460793242), + FRAC_CONST(0.99959911589494), + FRAC_CONST(0.99961320453077), + FRAC_CONST(0.99962688345035), + FRAC_CONST(0.99964016210433), + FRAC_CONST(0.99965304978499), + FRAC_CONST(0.99966555562769), + FRAC_CONST(0.99967768861231), + FRAC_CONST(0.99968945756473), + FRAC_CONST(0.99970087115825), + FRAC_CONST(0.99971193791510), + FRAC_CONST(0.99972266620792), + FRAC_CONST(0.99973306426121), + FRAC_CONST(0.99974314015288), + FRAC_CONST(0.99975290181568), + FRAC_CONST(0.99976235703876), + FRAC_CONST(0.99977151346914), + FRAC_CONST(0.99978037861326), + FRAC_CONST(0.99978895983845), + FRAC_CONST(0.99979726437448), + FRAC_CONST(0.99980529931507), + FRAC_CONST(0.99981307161943), + FRAC_CONST(0.99982058811377), + FRAC_CONST(0.99982785549283), + FRAC_CONST(0.99983488032144), + FRAC_CONST(0.99984166903600), + FRAC_CONST(0.99984822794606), + FRAC_CONST(0.99985456323584), + FRAC_CONST(0.99986068096572), + FRAC_CONST(0.99986658707386), + FRAC_CONST(0.99987228737764), + FRAC_CONST(0.99987778757524), + FRAC_CONST(0.99988309324717), + FRAC_CONST(0.99988820985777), + FRAC_CONST(0.99989314275675), + FRAC_CONST(0.99989789718072), + FRAC_CONST(0.99990247825468), + FRAC_CONST(0.99990689099357), + FRAC_CONST(0.99991114030376), + FRAC_CONST(0.99991523098456), + FRAC_CONST(0.99991916772971), + FRAC_CONST(0.99992295512891), + FRAC_CONST(0.99992659766930), + FRAC_CONST(0.99993009973692), + FRAC_CONST(0.99993346561824), + FRAC_CONST(0.99993669950161), + FRAC_CONST(0.99993980547870), + FRAC_CONST(0.99994278754604), + FRAC_CONST(0.99994564960642), + FRAC_CONST(0.99994839547033), + FRAC_CONST(0.99995102885747), + FRAC_CONST(0.99995355339809), + FRAC_CONST(0.99995597263451), + FRAC_CONST(0.99995829002249), + FRAC_CONST(0.99996050893264), + FRAC_CONST(0.99996263265183), + FRAC_CONST(0.99996466438460), + FRAC_CONST(0.99996660725452), + FRAC_CONST(0.99996846430558), + FRAC_CONST(0.99997023850356), + FRAC_CONST(0.99997193273736), + FRAC_CONST(0.99997354982037), + FRAC_CONST(0.99997509249183), + FRAC_CONST(0.99997656341810), + FRAC_CONST(0.99997796519400), + FRAC_CONST(0.99997930034415), + FRAC_CONST(0.99998057132421), + FRAC_CONST(0.99998178052220), + FRAC_CONST(0.99998293025975), + FRAC_CONST(0.99998402279338), + FRAC_CONST(0.99998506031574), + FRAC_CONST(0.99998604495686), + FRAC_CONST(0.99998697878536), + FRAC_CONST(0.99998786380966), + FRAC_CONST(0.99998870197921), + FRAC_CONST(0.99998949518567), + FRAC_CONST(0.99999024526408), + FRAC_CONST(0.99999095399401), + FRAC_CONST(0.99999162310077), + FRAC_CONST(0.99999225425649), + FRAC_CONST(0.99999284908128), + FRAC_CONST(0.99999340914435), + FRAC_CONST(0.99999393596510), + FRAC_CONST(0.99999443101421), + FRAC_CONST(0.99999489571473), + FRAC_CONST(0.99999533144314), + FRAC_CONST(0.99999573953040), + FRAC_CONST(0.99999612126300), + FRAC_CONST(0.99999647788395), + FRAC_CONST(0.99999681059383), + FRAC_CONST(0.99999712055178), + FRAC_CONST(0.99999740887647), + FRAC_CONST(0.99999767664709), + FRAC_CONST(0.99999792490431), + FRAC_CONST(0.99999815465123), + FRAC_CONST(0.99999836685427), + FRAC_CONST(0.99999856244415), + FRAC_CONST(0.99999874231676), + FRAC_CONST(0.99999890733405), + FRAC_CONST(0.99999905832493), + FRAC_CONST(0.99999919608613), + FRAC_CONST(0.99999932138304), + FRAC_CONST(0.99999943495056), + FRAC_CONST(0.99999953749392), + FRAC_CONST(0.99999962968950), + FRAC_CONST(0.99999971218563), + FRAC_CONST(0.99999978560337), + FRAC_CONST(0.99999985053727), + FRAC_CONST(0.99999990755616), + FRAC_CONST(0.99999995720387) +}; + +#ifdef ALLOW_SMALL_FRAMELENGTH +static const real_t kbd_long_960[] MEM_ALIGN_ATTR = { + FRAC_CONST(0.0003021562530949), + FRAC_CONST(0.0004452267024786), + FRAC_CONST(0.0005674947527496), + FRAC_CONST(0.0006812465553466), + FRAC_CONST(0.0007910496776387), + FRAC_CONST(0.0008991655033895), + FRAC_CONST(0.0010068978259384), + FRAC_CONST(0.0011150758515751), + FRAC_CONST(0.0012242653193642), + FRAC_CONST(0.0013348735658205), + FRAC_CONST(0.0014472068670273), + FRAC_CONST(0.0015615039850448), + FRAC_CONST(0.0016779568885263), + FRAC_CONST(0.0017967241232412), + FRAC_CONST(0.0019179397560955), + FRAC_CONST(0.0020417195415393), + FRAC_CONST(0.0021681652836642), + FRAC_CONST(0.0022973679910599), + FRAC_CONST(0.0024294102029937), + FRAC_CONST(0.0025643677339078), + FRAC_CONST(0.0027023110014772), + FRAC_CONST(0.0028433060512612), + FRAC_CONST(0.0029874153568025), + FRAC_CONST(0.0031346984511728), + FRAC_CONST(0.0032852124303662), + FRAC_CONST(0.0034390123581190), + FRAC_CONST(0.0035961515940931), + FRAC_CONST(0.0037566820618961), + FRAC_CONST(0.0039206544694386), + FRAC_CONST(0.0040881184912194), + FRAC_CONST(0.0042591229199617), + FRAC_CONST(0.0044337157933972), + FRAC_CONST(0.0046119445007641), + FRAC_CONST(0.0047938558726415), + FRAC_CONST(0.0049794962570131), + FRAC_CONST(0.0051689115838900), + FRAC_CONST(0.0053621474203763), + FRAC_CONST(0.0055592490177131), + FRAC_CONST(0.0057602613515573), + FRAC_CONST(0.0059652291565289), + FRAC_CONST(0.0061741969558843), + FRAC_CONST(0.0063872090870253), + FRAC_CONST(0.0066043097234387), + FRAC_CONST(0.0068255428935640), + FRAC_CONST(0.0070509524970088), + FRAC_CONST(0.0072805823184660), + FRAC_CONST(0.0075144760396340), + FRAC_CONST(0.0077526772493942), + FRAC_CONST(0.0079952294524673), + FRAC_CONST(0.0082421760767325), + FRAC_CONST(0.0084935604793733), + FRAC_CONST(0.0087494259519870), + FRAC_CONST(0.0090098157247792), + FRAC_CONST(0.0092747729699467), + FRAC_CONST(0.0095443408043399), + FRAC_CONST(0.0098185622914832), + FRAC_CONST(0.0100974804430226), + FRAC_CONST(0.0103811382196612), + FRAC_CONST(0.0106695785316351), + FRAC_CONST(0.0109628442387771), + FRAC_CONST(0.0112609781502091), + FRAC_CONST(0.0115640230236993), + FRAC_CONST(0.0118720215647169), + FRAC_CONST(0.0121850164252137), + FRAC_CONST(0.0125030502021561), + FRAC_CONST(0.0128261654358321), + FRAC_CONST(0.0131544046079532), + FRAC_CONST(0.0134878101395681), + FRAC_CONST(0.0138264243888068), + FRAC_CONST(0.0141702896484671), + FRAC_CONST(0.0145194481434592), + FRAC_CONST(0.0148739420281182), + FRAC_CONST(0.0152338133833959), + FRAC_CONST(0.0155991042139432), + FRAC_CONST(0.0159698564450882), + FRAC_CONST(0.0163461119197227), + FRAC_CONST(0.0167279123950996), + FRAC_CONST(0.0171152995395520), + FRAC_CONST(0.0175083149291368), + FRAC_CONST(0.0179070000442104), + FRAC_CONST(0.0183113962659409), + FRAC_CONST(0.0187215448727609), + FRAC_CONST(0.0191374870367659), + FRAC_CONST(0.0195592638200623), + FRAC_CONST(0.0199869161710679), + FRAC_CONST(0.0204204849207691), + FRAC_CONST(0.0208600107789370), + FRAC_CONST(0.0213055343303066), + FRAC_CONST(0.0217570960307201), + FRAC_CONST(0.0222147362032386), + FRAC_CONST(0.0226784950342228), + FRAC_CONST(0.0231484125693867), + FRAC_CONST(0.0236245287098244), + FRAC_CONST(0.0241068832080138), + FRAC_CONST(0.0245955156637973), + FRAC_CONST(0.0250904655203431), + FRAC_CONST(0.0255917720600868), + FRAC_CONST(0.0260994744006559), + FRAC_CONST(0.0266136114907790), + FRAC_CONST(0.0271342221061795), + FRAC_CONST(0.0276613448454576), + FRAC_CONST(0.0281950181259587), + FRAC_CONST(0.0287352801796329), + FRAC_CONST(0.0292821690488833), + FRAC_CONST(0.0298357225824074), + FRAC_CONST(0.0303959784310299), + FRAC_CONST(0.0309629740435296), + FRAC_CONST(0.0315367466624615), + FRAC_CONST(0.0321173333199732), + FRAC_CONST(0.0327047708336193), + FRAC_CONST(0.0332990958021720), + FRAC_CONST(0.0339003446014307), + FRAC_CONST(0.0345085533800302), + FRAC_CONST(0.0351237580552491), + FRAC_CONST(0.0357459943088193), + FRAC_CONST(0.0363752975827358), + FRAC_CONST(0.0370117030750704), + FRAC_CONST(0.0376552457357870), + FRAC_CONST(0.0383059602625614), + FRAC_CONST(0.0389638810966056), + FRAC_CONST(0.0396290424184964), + FRAC_CONST(0.0403014781440112), + FRAC_CONST(0.0409812219199691), + FRAC_CONST(0.0416683071200799), + FRAC_CONST(0.0423627668408009), + FRAC_CONST(0.0430646338972016), + FRAC_CONST(0.0437739408188385), + FRAC_CONST(0.0444907198456388), + FRAC_CONST(0.0452150029237951), + FRAC_CONST(0.0459468217016708), + FRAC_CONST(0.0466862075257170), + FRAC_CONST(0.0474331914364021), + FRAC_CONST(0.0481878041641539), + FRAC_CONST(0.0489500761253148), + FRAC_CONST(0.0497200374181119), + FRAC_CONST(0.0504977178186404), + FRAC_CONST(0.0512831467768636), + FRAC_CONST(0.0520763534126273), + FRAC_CONST(0.0528773665116913), + FRAC_CONST(0.0536862145217772), + FRAC_CONST(0.0545029255486345), + FRAC_CONST(0.0553275273521232), + FRAC_CONST(0.0561600473423164), + FRAC_CONST(0.0570005125756209), + FRAC_CONST(0.0578489497509179), + FRAC_CONST(0.0587053852057233), + FRAC_CONST(0.0595698449123695), + FRAC_CONST(0.0604423544742077), + FRAC_CONST(0.0613229391218317), + FRAC_CONST(0.0622116237093247), + FRAC_CONST(0.0631084327105284), + FRAC_CONST(0.0640133902153352), + FRAC_CONST(0.0649265199260043), + FRAC_CONST(0.0658478451535027), + FRAC_CONST(0.0667773888138695), + FRAC_CONST(0.0677151734246072), + FRAC_CONST(0.0686612211010977), + FRAC_CONST(0.0696155535530446), + FRAC_CONST(0.0705781920809429), + FRAC_CONST(0.0715491575725758), + FRAC_CONST(0.0725284704995383), + FRAC_CONST(0.0735161509137906), + FRAC_CONST(0.0745122184442388), + FRAC_CONST(0.0755166922933461), + FRAC_CONST(0.0765295912337720), + FRAC_CONST(0.0775509336050437), + FRAC_CONST(0.0785807373102561), + FRAC_CONST(0.0796190198128044), + FRAC_CONST(0.0806657981331473), + FRAC_CONST(0.0817210888456026), + FRAC_CONST(0.0827849080751753), + FRAC_CONST(0.0838572714944183), + FRAC_CONST(0.0849381943203265), + FRAC_CONST(0.0860276913112652), + FRAC_CONST(0.0871257767639319), + FRAC_CONST(0.0882324645103534), + FRAC_CONST(0.0893477679149177), + FRAC_CONST(0.0904716998714418), + FRAC_CONST(0.0916042728002747), + FRAC_CONST(0.0927454986454381), + FRAC_CONST(0.0938953888718020), + FRAC_CONST(0.0950539544622996), + FRAC_CONST(0.0962212059151784), + FRAC_CONST(0.0973971532412897), + FRAC_CONST(0.0985818059614169), + FRAC_CONST(0.0997751731036425), + FRAC_CONST(0.1009772632007537), + FRAC_CONST(0.1021880842876888), + FRAC_CONST(0.1034076438990227), + FRAC_CONST(0.1046359490664932), + FRAC_CONST(0.1058730063165681), + FRAC_CONST(0.1071188216680533), + FRAC_CONST(0.1083734006297428), + FRAC_CONST(0.1096367481981100), + FRAC_CONST(0.1109088688550422), + FRAC_CONST(0.1121897665656167), + FRAC_CONST(0.1134794447759207), + FRAC_CONST(0.1147779064109143), + FRAC_CONST(0.1160851538723372), + FRAC_CONST(0.1174011890366591), + FRAC_CONST(0.1187260132530751), + FRAC_CONST(0.1200596273415457), + FRAC_CONST(0.1214020315908810), + FRAC_CONST(0.1227532257568719), + FRAC_CONST(0.1241132090604651), + FRAC_CONST(0.1254819801859856), + FRAC_CONST(0.1268595372794049), + FRAC_CONST(0.1282458779466558), + FRAC_CONST(0.1296409992519942), + FRAC_CONST(0.1310448977164081), + FRAC_CONST(0.1324575693160745), + FRAC_CONST(0.1338790094808633), + FRAC_CONST(0.1353092130928902), + FRAC_CONST(0.1367481744851168), + FRAC_CONST(0.1381958874400010), + FRAC_CONST(0.1396523451881945), + FRAC_CONST(0.1411175404072910), + FRAC_CONST(0.1425914652206223), + FRAC_CONST(0.1440741111961058), + FRAC_CONST(0.1455654693451402), + FRAC_CONST(0.1470655301215526), + FRAC_CONST(0.1485742834205956), + FRAC_CONST(0.1500917185779945), + FRAC_CONST(0.1516178243690463), + FRAC_CONST(0.1531525890077689), + FRAC_CONST(0.1546960001461024), + FRAC_CONST(0.1562480448731608), + FRAC_CONST(0.1578087097145364), + FRAC_CONST(0.1593779806316558), + FRAC_CONST(0.1609558430211876), + FRAC_CONST(0.1625422817145027), + FRAC_CONST(0.1641372809771871), + FRAC_CONST(0.1657408245086070), + FRAC_CONST(0.1673528954415270), + FRAC_CONST(0.1689734763417811), + FRAC_CONST(0.1706025492079969), + FRAC_CONST(0.1722400954713725), + FRAC_CONST(0.1738860959955082), + FRAC_CONST(0.1755405310762898), + FRAC_CONST(0.1772033804418275), + FRAC_CONST(0.1788746232524467), + FRAC_CONST(0.1805542381007349), + FRAC_CONST(0.1822422030116404), + FRAC_CONST(0.1839384954426268), + FRAC_CONST(0.1856430922838810), + FRAC_CONST(0.1873559698585756), + FRAC_CONST(0.1890771039231862), + FRAC_CONST(0.1908064696678625), + FRAC_CONST(0.1925440417168546), + FRAC_CONST(0.1942897941289937), + FRAC_CONST(0.1960437003982277), + FRAC_CONST(0.1978057334542116), + FRAC_CONST(0.1995758656629525), + FRAC_CONST(0.2013540688275098), + FRAC_CONST(0.2031403141887507), + FRAC_CONST(0.2049345724261595), + FRAC_CONST(0.2067368136587033), + FRAC_CONST(0.2085470074457521), + FRAC_CONST(0.2103651227880538), + FRAC_CONST(0.2121911281287646), + FRAC_CONST(0.2140249913545346), + FRAC_CONST(0.2158666797966480), + FRAC_CONST(0.2177161602322188), + FRAC_CONST(0.2195733988854414), + FRAC_CONST(0.2214383614288963), + FRAC_CONST(0.2233110129849106), + FRAC_CONST(0.2251913181269740), + FRAC_CONST(0.2270792408812093), + FRAC_CONST(0.2289747447278976), + FRAC_CONST(0.2308777926030592), + FRAC_CONST(0.2327883469000885), + FRAC_CONST(0.2347063694714437), + FRAC_CONST(0.2366318216303919), + FRAC_CONST(0.2385646641528076), + FRAC_CONST(0.2405048572790267), + FRAC_CONST(0.2424523607157545), + FRAC_CONST(0.2444071336380283), + FRAC_CONST(0.2463691346912334), + FRAC_CONST(0.2483383219931741), + FRAC_CONST(0.2503146531361985), + FRAC_CONST(0.2522980851893767), + FRAC_CONST(0.2542885747007335), + FRAC_CONST(0.2562860776995335), + FRAC_CONST(0.2582905496986215), + FRAC_CONST(0.2603019456968142), + FRAC_CONST(0.2623202201813464), + FRAC_CONST(0.2643453271303700), + FRAC_CONST(0.2663772200155053), + FRAC_CONST(0.2684158518044454), + FRAC_CONST(0.2704611749636135), + FRAC_CONST(0.2725131414608710), + FRAC_CONST(0.2745717027682799), + FRAC_CONST(0.2766368098649151), + FRAC_CONST(0.2787084132397296), + FRAC_CONST(0.2807864628944707), + FRAC_CONST(0.2828709083466482), + FRAC_CONST(0.2849616986325523), + FRAC_CONST(0.2870587823103237), + FRAC_CONST(0.2891621074630737), + FRAC_CONST(0.2912716217020546), + FRAC_CONST(0.2933872721698803), + FRAC_CONST(0.2955090055437973), + FRAC_CONST(0.2976367680390041), + FRAC_CONST(0.2997705054120213), + FRAC_CONST(0.3019101629641097), + FRAC_CONST(0.3040556855447379), + FRAC_CONST(0.3062070175550981), + FRAC_CONST(0.3083641029516701), + FRAC_CONST(0.3105268852498334), + FRAC_CONST(0.3126953075275265), + FRAC_CONST(0.3148693124289546), + FRAC_CONST(0.3170488421683428), + FRAC_CONST(0.3192338385337370), + FRAC_CONST(0.3214242428908514), + FRAC_CONST(0.3236199961869606), + FRAC_CONST(0.3258210389548392), + FRAC_CONST(0.3280273113167459), + FRAC_CONST(0.3302387529884521), + FRAC_CONST(0.3324553032833160), + FRAC_CONST(0.3346769011164010), + FRAC_CONST(0.3369034850086373), + FRAC_CONST(0.3391349930910280), + FRAC_CONST(0.3413713631088974), + FRAC_CONST(0.3436125324261830), + FRAC_CONST(0.3458584380297697), + FRAC_CONST(0.3481090165338656), + FRAC_CONST(0.3503642041844199), + FRAC_CONST(0.3526239368635820), + FRAC_CONST(0.3548881500942010), + FRAC_CONST(0.3571567790443668), + FRAC_CONST(0.3594297585319891), + FRAC_CONST(0.3617070230294185), + FRAC_CONST(0.3639885066681048), + FRAC_CONST(0.3662741432432950), + FRAC_CONST(0.3685638662187693), + FRAC_CONST(0.3708576087316147), + FRAC_CONST(0.3731553035970366), + FRAC_CONST(0.3754568833132069), + FRAC_CONST(0.3777622800661488), + FRAC_CONST(0.3800714257346570), + FRAC_CONST(0.3823842518952546), + FRAC_CONST(0.3847006898271841), + FRAC_CONST(0.3870206705174334), + FRAC_CONST(0.3893441246657958), + FRAC_CONST(0.3916709826899639), + FRAC_CONST(0.3940011747306560), + FRAC_CONST(0.3963346306567764), + FRAC_CONST(0.3986712800706062), + FRAC_CONST(0.4010110523130271), + FRAC_CONST(0.4033538764687756), + FRAC_CONST(0.4056996813717284), + FRAC_CONST(0.4080483956102172), + FRAC_CONST(0.4103999475323736), + FRAC_CONST(0.4127542652515031), + FRAC_CONST(0.4151112766514873), + FRAC_CONST(0.4174709093922143), + FRAC_CONST(0.4198330909150365), + FRAC_CONST(0.4221977484482556), + FRAC_CONST(0.4245648090126334), + FRAC_CONST(0.4269341994269293), + FRAC_CONST(0.4293058463134616), + FRAC_CONST(0.4316796761036958), + FRAC_CONST(0.4340556150438547), + FRAC_CONST(0.4364335892005536), + FRAC_CONST(0.4388135244664580), + FRAC_CONST(0.4411953465659639), + FRAC_CONST(0.4435789810609000), + FRAC_CONST(0.4459643533562509), + FRAC_CONST(0.4483513887059016), + FRAC_CONST(0.4507400122184019), + FRAC_CONST(0.4531301488627497), + FRAC_CONST(0.4555217234741947), + FRAC_CONST(0.4579146607600593), + FRAC_CONST(0.4603088853055777), + FRAC_CONST(0.4627043215797521), + FRAC_CONST(0.4651008939412254), + FRAC_CONST(0.4674985266441709), + FRAC_CONST(0.4698971438441951), + FRAC_CONST(0.4722966696042580), + FRAC_CONST(0.4746970279006055), + FRAC_CONST(0.4770981426287164), + FRAC_CONST(0.4794999376092619), + FRAC_CONST(0.4819023365940778), + FRAC_CONST(0.4843052632721476), + FRAC_CONST(0.4867086412755978), + FRAC_CONST(0.4891123941857028), + FRAC_CONST(0.4915164455388997), + FRAC_CONST(0.4939207188328126), + FRAC_CONST(0.4963251375322855), + FRAC_CONST(0.4987296250754225), + FRAC_CONST(0.5011341048796359), + FRAC_CONST(0.5035385003477012), + FRAC_CONST(0.5059427348738168), + FRAC_CONST(0.5083467318496706), + FRAC_CONST(0.5107504146705106), + FRAC_CONST(0.5131537067412193), + FRAC_CONST(0.5155565314823923), + FRAC_CONST(0.5179588123364193), + FRAC_CONST(0.5203604727735667), + FRAC_CONST(0.5227614362980630), + FRAC_CONST(0.5251616264541841), + FRAC_CONST(0.5275609668323384), + FRAC_CONST(0.5299593810751532), + FRAC_CONST(0.5323567928835578), + FRAC_CONST(0.5347531260228663), + FRAC_CONST(0.5371483043288580), + FRAC_CONST(0.5395422517138538), + FRAC_CONST(0.5419348921727899), + FRAC_CONST(0.5443261497892862), + FRAC_CONST(0.5467159487417104), + FRAC_CONST(0.5491042133092364), + FRAC_CONST(0.5514908678778958), + FRAC_CONST(0.5538758369466227), + FRAC_CONST(0.5562590451332913), + FRAC_CONST(0.5586404171807443), + FRAC_CONST(0.5610198779628133), + FRAC_CONST(0.5633973524903286), + FRAC_CONST(0.5657727659171199), + FRAC_CONST(0.5681460435460047), + FRAC_CONST(0.5705171108347663), + FRAC_CONST(0.5728858934021188), + FRAC_CONST(0.5752523170336598), + FRAC_CONST(0.5776163076878088), + FRAC_CONST(0.5799777915017323), + FRAC_CONST(0.5823366947972535), + FRAC_CONST(0.5846929440867458), + FRAC_CONST(0.5870464660790119), + FRAC_CONST(0.5893971876851449), + FRAC_CONST(0.5917450360243719), + FRAC_CONST(0.5940899384298793), + FRAC_CONST(0.5964318224546208), + FRAC_CONST(0.5987706158771039), + FRAC_CONST(0.6011062467071583), + FRAC_CONST(0.6034386431916822), + FRAC_CONST(0.6057677338203681), + FRAC_CONST(0.6080934473314057), + FRAC_CONST(0.6104157127171639), + FRAC_CONST(0.6127344592298474), + FRAC_CONST(0.6150496163871310), + FRAC_CONST(0.6173611139777690), + FRAC_CONST(0.6196688820671789), + FRAC_CONST(0.6219728510029997), + FRAC_CONST(0.6242729514206247), + FRAC_CONST(0.6265691142487051), + FRAC_CONST(0.6288612707146283), + FRAC_CONST(0.6311493523499663), + FRAC_CONST(0.6334332909958958), + FRAC_CONST(0.6357130188085891), + FRAC_CONST(0.6379884682645743), + FRAC_CONST(0.6402595721660647), + FRAC_CONST(0.6425262636462578), + FRAC_CONST(0.6447884761746012), + FRAC_CONST(0.6470461435620266), + FRAC_CONST(0.6492991999661505), + FRAC_CONST(0.6515475798964411), + FRAC_CONST(0.6537912182193508), + FRAC_CONST(0.6560300501634142), + FRAC_CONST(0.6582640113243098), + FRAC_CONST(0.6604930376698862), + FRAC_CONST(0.6627170655451516), + FRAC_CONST(0.6649360316772256), + FRAC_CONST(0.6671498731802533), + FRAC_CONST(0.6693585275602818), + FRAC_CONST(0.6715619327200959), + FRAC_CONST(0.6737600269640164), + FRAC_CONST(0.6759527490026566), + FRAC_CONST(0.6781400379576392), + FRAC_CONST(0.6803218333662715), + FRAC_CONST(0.6824980751861787), + FRAC_CONST(0.6846687037998949), + FRAC_CONST(0.6868336600194123), + FRAC_CONST(0.6889928850906855), + FRAC_CONST(0.6911463206980928), + FRAC_CONST(0.6932939089688525), + FRAC_CONST(0.6954355924773949), + FRAC_CONST(0.6975713142496884), + FRAC_CONST(0.6997010177675195), + FRAC_CONST(0.7018246469727265), + FRAC_CONST(0.7039421462713862), + FRAC_CONST(0.7060534605379528), + FRAC_CONST(0.7081585351193496), + FRAC_CONST(0.7102573158390105), + FRAC_CONST(0.7123497490008750), + FRAC_CONST(0.7144357813933307), + FRAC_CONST(0.7165153602931092), + FRAC_CONST(0.7185884334691287), + FRAC_CONST(0.7206549491862871), + FRAC_CONST(0.7227148562092042), + FRAC_CONST(0.7247681038059106), + FRAC_CONST(0.7268146417514855), + FRAC_CONST(0.7288544203316418), + FRAC_CONST(0.7308873903462577), + FRAC_CONST(0.7329135031128549), + FRAC_CONST(0.7349327104700221), + FRAC_CONST(0.7369449647807855), + FRAC_CONST(0.7389502189359237), + FRAC_CONST(0.7409484263572271), + FRAC_CONST(0.7429395410007016), + FRAC_CONST(0.7449235173597176), + FRAC_CONST(0.7469003104681008), + FRAC_CONST(0.7488698759031670), + FRAC_CONST(0.7508321697887005), + FRAC_CONST(0.7527871487978728), + FRAC_CONST(0.7547347701561059), + FRAC_CONST(0.7566749916438754), + FRAC_CONST(0.7586077715994560), + FRAC_CONST(0.7605330689216074), + FRAC_CONST(0.7624508430722016), + FRAC_CONST(0.7643610540787891), + FRAC_CONST(0.7662636625371070), + FRAC_CONST(0.7681586296135255), + FRAC_CONST(0.7700459170474343), + FRAC_CONST(0.7719254871535672), + FRAC_CONST(0.7737973028242671), + FRAC_CONST(0.7756613275316875), + FRAC_CONST(0.7775175253299340), + FRAC_CONST(0.7793658608571425), + FRAC_CONST(0.7812062993374951), + FRAC_CONST(0.7830388065831744), + FRAC_CONST(0.7848633489962533), + FRAC_CONST(0.7866798935705233), + FRAC_CONST(0.7884884078932579), + FRAC_CONST(0.7902888601469138), + FRAC_CONST(0.7920812191107668), + FRAC_CONST(0.7938654541624850), + FRAC_CONST(0.7956415352796368), + FRAC_CONST(0.7974094330411343), + FRAC_CONST(0.7991691186286133), + FRAC_CONST(0.8009205638277465), + FRAC_CONST(0.8026637410294932), + FRAC_CONST(0.8043986232312831), + FRAC_CONST(0.8061251840381346), + FRAC_CONST(0.8078433976637077), + FRAC_CONST(0.8095532389312917), + FRAC_CONST(0.8112546832747255), + FRAC_CONST(0.8129477067392539), + FRAC_CONST(0.8146322859823164), + FRAC_CONST(0.8163083982742698), + FRAC_CONST(0.8179760214990457), + FRAC_CONST(0.8196351341547393), + FRAC_CONST(0.8212857153541345), + FRAC_CONST(0.8229277448251595), + FRAC_CONST(0.8245612029112778), + FRAC_CONST(0.8261860705718113), + FRAC_CONST(0.8278023293821971), + FRAC_CONST(0.8294099615341773), + FRAC_CONST(0.8310089498359212), + FRAC_CONST(0.8325992777120815), + FRAC_CONST(0.8341809292037831), + FRAC_CONST(0.8357538889685445), + FRAC_CONST(0.8373181422801330), + FRAC_CONST(0.8388736750283521), + FRAC_CONST(0.8404204737187619), + FRAC_CONST(0.8419585254723335), + FRAC_CONST(0.8434878180250348), + FRAC_CONST(0.8450083397273509), + FRAC_CONST(0.8465200795437368), + FRAC_CONST(0.8480230270520029), + FRAC_CONST(0.8495171724426350), + FRAC_CONST(0.8510025065180464), + FRAC_CONST(0.8524790206917633), + FRAC_CONST(0.8539467069875448), + FRAC_CONST(0.8554055580384357), + FRAC_CONST(0.8568555670857525), + FRAC_CONST(0.8582967279780043), + FRAC_CONST(0.8597290351697464), + FRAC_CONST(0.8611524837203691), + FRAC_CONST(0.8625670692928198), + FRAC_CONST(0.8639727881522599), + FRAC_CONST(0.8653696371646555), + FRAC_CONST(0.8667576137953045), + FRAC_CONST(0.8681367161072958), + FRAC_CONST(0.8695069427599065), + FRAC_CONST(0.8708682930069319), + FRAC_CONST(0.8722207666949527), + FRAC_CONST(0.8735643642615368), + FRAC_CONST(0.8748990867333771), + FRAC_CONST(0.8762249357243662), + FRAC_CONST(0.8775419134336067), + FRAC_CONST(0.8788500226433579), + FRAC_CONST(0.8801492667169208), + FRAC_CONST(0.8814396495964587), + FRAC_CONST(0.8827211758007560), + FRAC_CONST(0.8839938504229149), + FRAC_CONST(0.8852576791279895), + FRAC_CONST(0.8865126681505587), + FRAC_CONST(0.8877588242922386), + FRAC_CONST(0.8889961549191320), + FRAC_CONST(0.8902246679592184), + FRAC_CONST(0.8914443718996848), + FRAC_CONST(0.8926552757841945), + FRAC_CONST(0.8938573892100969), + FRAC_CONST(0.8950507223255798), + FRAC_CONST(0.8962352858267605), + FRAC_CONST(0.8974110909547198), + FRAC_CONST(0.8985781494924783), + FRAC_CONST(0.8997364737619142), + FRAC_CONST(0.9008860766206249), + FRAC_CONST(0.9020269714587307), + FRAC_CONST(0.9031591721956235), + FRAC_CONST(0.9042826932766591), + FRAC_CONST(0.9053975496697941), + FRAC_CONST(0.9065037568621681), + FRAC_CONST(0.9076013308566311), + FRAC_CONST(0.9086902881682180), + FRAC_CONST(0.9097706458205682), + FRAC_CONST(0.9108424213422940), + FRAC_CONST(0.9119056327632955), + FRAC_CONST(0.9129602986110235), + FRAC_CONST(0.9140064379066919), + FRAC_CONST(0.9150440701614393), + FRAC_CONST(0.9160732153724396), + FRAC_CONST(0.9170938940189634), + FRAC_CONST(0.9181061270583908), + FRAC_CONST(0.9191099359221748), + FRAC_CONST(0.9201053425117579), + FRAC_CONST(0.9210923691944400), + FRAC_CONST(0.9220710387992010), + FRAC_CONST(0.9230413746124764), + FRAC_CONST(0.9240034003738882), + FRAC_CONST(0.9249571402719298), + FRAC_CONST(0.9259026189396085), + FRAC_CONST(0.9268398614500427), + FRAC_CONST(0.9277688933120170), + FRAC_CONST(0.9286897404654957), + FRAC_CONST(0.9296024292770939), + FRAC_CONST(0.9305069865355076), + FRAC_CONST(0.9314034394469048), + FRAC_CONST(0.9322918156302762), + FRAC_CONST(0.9331721431127471), + FRAC_CONST(0.9340444503248519), + FRAC_CONST(0.9349087660957711), + FRAC_CONST(0.9357651196485313), + FRAC_CONST(0.9366135405951697), + FRAC_CONST(0.9374540589318637), + FRAC_CONST(0.9382867050340261), + FRAC_CONST(0.9391115096513655), + FRAC_CONST(0.9399285039029165), + FRAC_CONST(0.9407377192720349), + FRAC_CONST(0.9415391876013639), + FRAC_CONST(0.9423329410877687), + FRAC_CONST(0.9431190122772415), + FRAC_CONST(0.9438974340597782), + FRAC_CONST(0.9446682396642262), + FRAC_CONST(0.9454314626531054), + FRAC_CONST(0.9461871369174033), + FRAC_CONST(0.9469352966713429), + FRAC_CONST(0.9476759764471278), + FRAC_CONST(0.9484092110896616), + FRAC_CONST(0.9491350357512457), + FRAC_CONST(0.9498534858862532), + FRAC_CONST(0.9505645972457831), + FRAC_CONST(0.9512684058722927), + FRAC_CONST(0.9519649480942105), + FRAC_CONST(0.9526542605205314), + FRAC_CONST(0.9533363800353921), + FRAC_CONST(0.9540113437926313), + FRAC_CONST(0.9546791892103320), + FRAC_CONST(0.9553399539653500), + FRAC_CONST(0.9559936759878265), + FRAC_CONST(0.9566403934556893), + FRAC_CONST(0.9572801447891388), + FRAC_CONST(0.9579129686451244), + FRAC_CONST(0.9585389039118085), + FRAC_CONST(0.9591579897030224), + FRAC_CONST(0.9597702653527108), + FRAC_CONST(0.9603757704093711), + FRAC_CONST(0.9609745446304828), + FRAC_CONST(0.9615666279769324), + FRAC_CONST(0.9621520606074324), + FRAC_CONST(0.9627308828729358), + FRAC_CONST(0.9633031353110477), + FRAC_CONST(0.9638688586404335), + FRAC_CONST(0.9644280937552258), + FRAC_CONST(0.9649808817194311), + FRAC_CONST(0.9655272637613366), + FRAC_CONST(0.9660672812679171), + FRAC_CONST(0.9666009757792454), + FRAC_CONST(0.9671283889829055), + FRAC_CONST(0.9676495627084089), + FRAC_CONST(0.9681645389216160), + FRAC_CONST(0.9686733597191652), + FRAC_CONST(0.9691760673229058), + FRAC_CONST(0.9696727040743406), + FRAC_CONST(0.9701633124290767), + FRAC_CONST(0.9706479349512860), + FRAC_CONST(0.9711266143081750), + FRAC_CONST(0.9715993932644684), + FRAC_CONST(0.9720663146769026), + FRAC_CONST(0.9725274214887337), + FRAC_CONST(0.9729827567242596), + FRAC_CONST(0.9734323634833574), + FRAC_CONST(0.9738762849360358), + FRAC_CONST(0.9743145643170059), + FRAC_CONST(0.9747472449202687), + FRAC_CONST(0.9751743700937215), + FRAC_CONST(0.9755959832337850), + FRAC_CONST(0.9760121277800496), + FRAC_CONST(0.9764228472099433), + FRAC_CONST(0.9768281850334235), + FRAC_CONST(0.9772281847876897), + FRAC_CONST(0.9776228900319223), + FRAC_CONST(0.9780123443420448), + FRAC_CONST(0.9783965913055132), + FRAC_CONST(0.9787756745161313), + FRAC_CONST(0.9791496375688939), + FRAC_CONST(0.9795185240548578), + FRAC_CONST(0.9798823775560431), + FRAC_CONST(0.9802412416403639), + FRAC_CONST(0.9805951598565897), + FRAC_CONST(0.9809441757293399), + FRAC_CONST(0.9812883327541090), + FRAC_CONST(0.9816276743923267), + FRAC_CONST(0.9819622440664515), + FRAC_CONST(0.9822920851550995), + FRAC_CONST(0.9826172409882086), + FRAC_CONST(0.9829377548422400), + FRAC_CONST(0.9832536699354163), + FRAC_CONST(0.9835650294229984), + FRAC_CONST(0.9838718763926001), + FRAC_CONST(0.9841742538595437), + FRAC_CONST(0.9844722047622547), + FRAC_CONST(0.9847657719576983), + FRAC_CONST(0.9850549982168574), + FRAC_CONST(0.9853399262202529), + FRAC_CONST(0.9856205985535073), + FRAC_CONST(0.9858970577029519), + FRAC_CONST(0.9861693460512790), + FRAC_CONST(0.9864375058732389), + FRAC_CONST(0.9867015793313820), + FRAC_CONST(0.9869616084718489), + FRAC_CONST(0.9872176352202061), + FRAC_CONST(0.9874697013773301), + FRAC_CONST(0.9877178486153397), + FRAC_CONST(0.9879621184735767), + FRAC_CONST(0.9882025523546365), + FRAC_CONST(0.9884391915204485), + FRAC_CONST(0.9886720770884069), + FRAC_CONST(0.9889012500275530), + FRAC_CONST(0.9891267511548089), + FRAC_CONST(0.9893486211312621), + FRAC_CONST(0.9895669004585049), + FRAC_CONST(0.9897816294750255), + FRAC_CONST(0.9899928483526520), + FRAC_CONST(0.9902005970930525), + FRAC_CONST(0.9904049155242876), + FRAC_CONST(0.9906058432974180), + FRAC_CONST(0.9908034198831690), + FRAC_CONST(0.9909976845686489), + FRAC_CONST(0.9911886764541239), + FRAC_CONST(0.9913764344498495), + FRAC_CONST(0.9915609972729590), + FRAC_CONST(0.9917424034444086), + FRAC_CONST(0.9919206912859797), + FRAC_CONST(0.9920958989173397), + FRAC_CONST(0.9922680642531603), + FRAC_CONST(0.9924372250002933), + FRAC_CONST(0.9926034186550070), + FRAC_CONST(0.9927666825002789), + FRAC_CONST(0.9929270536031491), + FRAC_CONST(0.9930845688121325), + FRAC_CONST(0.9932392647546895), + FRAC_CONST(0.9933911778347579), + FRAC_CONST(0.9935403442303433), + FRAC_CONST(0.9936867998911693), + FRAC_CONST(0.9938305805363887), + FRAC_CONST(0.9939717216523539), + FRAC_CONST(0.9941102584904481), + FRAC_CONST(0.9942462260649764), + FRAC_CONST(0.9943796591511174), + FRAC_CONST(0.9945105922829353), + FRAC_CONST(0.9946390597514524), + FRAC_CONST(0.9947650956027824), + FRAC_CONST(0.9948887336363228), + FRAC_CONST(0.9950100074030103), + FRAC_CONST(0.9951289502036336), + FRAC_CONST(0.9952455950872091), + FRAC_CONST(0.9953599748494155), + FRAC_CONST(0.9954721220310890), + FRAC_CONST(0.9955820689167787), + FRAC_CONST(0.9956898475333619), + FRAC_CONST(0.9957954896487196), + FRAC_CONST(0.9958990267704713), + FRAC_CONST(0.9960004901447701), + FRAC_CONST(0.9960999107551559), + FRAC_CONST(0.9961973193214694), + FRAC_CONST(0.9962927462988245), + FRAC_CONST(0.9963862218766388), + FRAC_CONST(0.9964777759777242), + FRAC_CONST(0.9965674382574342), + FRAC_CONST(0.9966552381028704), + FRAC_CONST(0.9967412046321465), + FRAC_CONST(0.9968253666937095), + FRAC_CONST(0.9969077528657186), + FRAC_CONST(0.9969883914554805), + FRAC_CONST(0.9970673104989413), + FRAC_CONST(0.9971445377602348), + FRAC_CONST(0.9972201007312871), + FRAC_CONST(0.9972940266314749), + FRAC_CONST(0.9973663424073412), + FRAC_CONST(0.9974370747323638), + FRAC_CONST(0.9975062500067785), + FRAC_CONST(0.9975738943574574), + FRAC_CONST(0.9976400336378379), + FRAC_CONST(0.9977046934279079), + FRAC_CONST(0.9977678990342401), + FRAC_CONST(0.9978296754900812), + FRAC_CONST(0.9978900475554902), + FRAC_CONST(0.9979490397175296), + FRAC_CONST(0.9980066761905056), + FRAC_CONST(0.9980629809162593), + FRAC_CONST(0.9981179775645063), + FRAC_CONST(0.9981716895332257), + FRAC_CONST(0.9982241399490979), + FRAC_CONST(0.9982753516679893), + FRAC_CONST(0.9983253472754841), + FRAC_CONST(0.9983741490874634), + FRAC_CONST(0.9984217791507299), + FRAC_CONST(0.9984682592436778), + FRAC_CONST(0.9985136108770075), + FRAC_CONST(0.9985578552944850), + FRAC_CONST(0.9986010134737439), + FRAC_CONST(0.9986431061271304), + FRAC_CONST(0.9986841537025921), + FRAC_CONST(0.9987241763846056), + FRAC_CONST(0.9987631940951476), + FRAC_CONST(0.9988012264947044), + FRAC_CONST(0.9988382929833222), + FRAC_CONST(0.9988744127016956), + FRAC_CONST(0.9989096045322947), + FRAC_CONST(0.9989438871005292), + FRAC_CONST(0.9989772787759494), + FRAC_CONST(0.9990097976734847), + FRAC_CONST(0.9990414616547146), + FRAC_CONST(0.9990722883291779), + FRAC_CONST(0.9991022950557125), + FRAC_CONST(0.9991314989438310), + FRAC_CONST(0.9991599168551279), + FRAC_CONST(0.9991875654047181), + FRAC_CONST(0.9992144609627068), + FRAC_CONST(0.9992406196556911), + FRAC_CONST(0.9992660573682882), + FRAC_CONST(0.9992907897446957), + FRAC_CONST(0.9993148321902777), + FRAC_CONST(0.9993381998731797), + FRAC_CONST(0.9993609077259696), + FRAC_CONST(0.9993829704473038), + FRAC_CONST(0.9994044025036201), + FRAC_CONST(0.9994252181308537), + FRAC_CONST(0.9994454313361775), + FRAC_CONST(0.9994650558997651), + FRAC_CONST(0.9994841053765757), + FRAC_CONST(0.9995025930981609), + FRAC_CONST(0.9995205321744921), + FRAC_CONST(0.9995379354958073), + FRAC_CONST(0.9995548157344778), + FRAC_CONST(0.9995711853468930), + FRAC_CONST(0.9995870565753632), + FRAC_CONST(0.9996024414500382), + FRAC_CONST(0.9996173517908444), + FRAC_CONST(0.9996317992094352), + FRAC_CONST(0.9996457951111574), + FRAC_CONST(0.9996593506970310), + FRAC_CONST(0.9996724769657434), + FRAC_CONST(0.9996851847156547), + FRAC_CONST(0.9996974845468164), + FRAC_CONST(0.9997093868630000), + FRAC_CONST(0.9997209018737374), + FRAC_CONST(0.9997320395963699), + FRAC_CONST(0.9997428098581069), + FRAC_CONST(0.9997532222980933), + FRAC_CONST(0.9997632863694836), + FRAC_CONST(0.9997730113415246), + FRAC_CONST(0.9997824063016426), + FRAC_CONST(0.9997914801575380), + FRAC_CONST(0.9998002416392840), + FRAC_CONST(0.9998086993014300), + FRAC_CONST(0.9998168615251084), + FRAC_CONST(0.9998247365201450), + FRAC_CONST(0.9998323323271717), + FRAC_CONST(0.9998396568197407), + FRAC_CONST(0.9998467177064404), + FRAC_CONST(0.9998535225330116), + FRAC_CONST(0.9998600786844637), + FRAC_CONST(0.9998663933871905), + FRAC_CONST(0.9998724737110845), + FRAC_CONST(0.9998783265716498), + FRAC_CONST(0.9998839587321121), + FRAC_CONST(0.9998893768055266), + FRAC_CONST(0.9998945872568815), + FRAC_CONST(0.9998995964051983), + FRAC_CONST(0.9999044104256269), + FRAC_CONST(0.9999090353515359), + FRAC_CONST(0.9999134770765971), + FRAC_CONST(0.9999177413568642), + FRAC_CONST(0.9999218338128448), + FRAC_CONST(0.9999257599315647), + FRAC_CONST(0.9999295250686255), + FRAC_CONST(0.9999331344502529), + FRAC_CONST(0.9999365931753376), + FRAC_CONST(0.9999399062174669), + FRAC_CONST(0.9999430784269460), + FRAC_CONST(0.9999461145328103), + FRAC_CONST(0.9999490191448277), + FRAC_CONST(0.9999517967554878), + FRAC_CONST(0.9999544517419835), + FRAC_CONST(0.9999569883681778), + FRAC_CONST(0.9999594107865607), + FRAC_CONST(0.9999617230401926), + FRAC_CONST(0.9999639290646355), + FRAC_CONST(0.9999660326898712), + FRAC_CONST(0.9999680376422052), + FRAC_CONST(0.9999699475461585), + FRAC_CONST(0.9999717659263435), + FRAC_CONST(0.9999734962093266), + FRAC_CONST(0.9999751417254756), + FRAC_CONST(0.9999767057107922), + FRAC_CONST(0.9999781913087290), + FRAC_CONST(0.9999796015719915), + FRAC_CONST(0.9999809394643231), + FRAC_CONST(0.9999822078622751), + FRAC_CONST(0.9999834095569596), + FRAC_CONST(0.9999845472557860), + FRAC_CONST(0.9999856235841805), + FRAC_CONST(0.9999866410872889), + FRAC_CONST(0.9999876022316609), + FRAC_CONST(0.9999885094069193), + FRAC_CONST(0.9999893649274085), + FRAC_CONST(0.9999901710338274), + FRAC_CONST(0.9999909298948430), + FRAC_CONST(0.9999916436086862), + FRAC_CONST(0.9999923142047299), + FRAC_CONST(0.9999929436450469), + FRAC_CONST(0.9999935338259505), + FRAC_CONST(0.9999940865795161), + FRAC_CONST(0.9999946036750835), + FRAC_CONST(0.9999950868207405), + FRAC_CONST(0.9999955376647868), + FRAC_CONST(0.9999959577971798), + FRAC_CONST(0.9999963487509599), + FRAC_CONST(0.9999967120036571), + FRAC_CONST(0.9999970489786785), + FRAC_CONST(0.9999973610466748), + FRAC_CONST(0.9999976495268890), + FRAC_CONST(0.9999979156884846), + FRAC_CONST(0.9999981607518545), + FRAC_CONST(0.9999983858899099), + FRAC_CONST(0.9999985922293493), + FRAC_CONST(0.9999987808519092), + FRAC_CONST(0.9999989527955938), + FRAC_CONST(0.9999991090558848), + FRAC_CONST(0.9999992505869332), + FRAC_CONST(0.9999993783027293), + FRAC_CONST(0.9999994930782556), + FRAC_CONST(0.9999995957506171), + FRAC_CONST(0.9999996871201549), + FRAC_CONST(0.9999997679515386), + FRAC_CONST(0.9999998389748399), + FRAC_CONST(0.9999999008865869), + FRAC_CONST(0.9999999543507984) +}; +#endif + +static const real_t kbd_short_128[] ICONST_ATTR MEM_ALIGN_ATTR = +{ + FRAC_CONST(4.3795702929468881e-005), + FRAC_CONST(0.00011867384265436617), + FRAC_CONST(0.0002307165763996192), + FRAC_CONST(0.00038947282760568383), + FRAC_CONST(0.00060581272288302553), + FRAC_CONST(0.00089199695169487453), + FRAC_CONST(0.0012617254423430522), + FRAC_CONST(0.0017301724373162003), + FRAC_CONST(0.0023140071937421476), + FRAC_CONST(0.0030313989666022221), + FRAC_CONST(0.0039020049735530842), + FRAC_CONST(0.0049469401815512024), + FRAC_CONST(0.0061887279335368318), + FRAC_CONST(0.0076512306364647726), + FRAC_CONST(0.0093595599562652423), + FRAC_CONST(0.011339966208377799), + FRAC_CONST(0.013619706891715299), + FRAC_CONST(0.016226894586323766), + FRAC_CONST(0.019190324717288168), + FRAC_CONST(0.022539283975960878), + FRAC_CONST(0.026303340480472455), + FRAC_CONST(0.030512117046644357), + FRAC_CONST(0.03519504922365594), + FRAC_CONST(0.040381130021856941), + FRAC_CONST(0.046098643518702249), + FRAC_CONST(0.052374889768730587), + FRAC_CONST(0.059235903660769147), + FRAC_CONST(0.066706170556282418), + FRAC_CONST(0.074808341703430481), + FRAC_CONST(0.083562952548726227), + FRAC_CONST(0.092988147159339674), + FRAC_CONST(0.1030994120216919), + FRAC_CONST(0.11390932249409955), + FRAC_CONST(0.12542730516149531), + FRAC_CONST(0.13765941926783826), + FRAC_CONST(0.15060816028651081), + FRAC_CONST(0.16427228853114245), + FRAC_CONST(0.17864668550988483), + FRAC_CONST(0.19372224048676889), + FRAC_CONST(0.20948576943658073), + FRAC_CONST(0.22591996826744942), + FRAC_CONST(0.24300340184133981), + FRAC_CONST(0.26071052995068139), + FRAC_CONST(0.27901177101369551), + FRAC_CONST(0.29787360383626599), + FRAC_CONST(0.3172587073594233), + FRAC_CONST(0.33712613787396362), + FRAC_CONST(0.35743154274286698), + FRAC_CONST(0.37812740923363009), + FRAC_CONST(0.39916334663203618), + FRAC_CONST(0.42048639939189658), + FRAC_CONST(0.4420413886774246), + FRAC_CONST(0.4637712792815169), + FRAC_CONST(0.4856175685594023), + FRAC_CONST(0.50752069370766872), + FRAC_CONST(0.52942045344797806), + FRAC_CONST(0.55125643994680196), + FRAC_CONST(0.57296847662071559), + FRAC_CONST(0.59449705734411495), + FRAC_CONST(0.61578378249506627), + FRAC_CONST(0.63677178724712891), + FRAC_CONST(0.65740615754163356), + FRAC_CONST(0.67763432925662526), + FRAC_CONST(0.69740646622548552), + FRAC_CONST(0.71667581294953808), + FRAC_CONST(0.73539901809352737), + FRAC_CONST(0.75353642514900732), + FRAC_CONST(0.77105232699609816), + FRAC_CONST(0.78791518148597028), + FRAC_CONST(0.80409778560147072), + FRAC_CONST(0.81957740622770781), + FRAC_CONST(0.83433586607383625), + FRAC_CONST(0.84835958382689225), + FRAC_CONST(0.86163956818294229), + FRAC_CONST(0.87417136598406997), + FRAC_CONST(0.88595496528524853), + FRAC_CONST(0.89699465477567619), + FRAC_CONST(0.90729884157670959), + FRAC_CONST(0.91687983002436779), + FRAC_CONST(0.92575356460899649), + FRAC_CONST(0.93393934077779084), + FRAC_CONST(0.94145948779657318), + FRAC_CONST(0.94833902830402828), + FRAC_CONST(0.95460531956280026), + FRAC_CONST(0.96028768170574896), + FRAC_CONST(0.96541701848104766), + FRAC_CONST(0.97002543610646474), + FRAC_CONST(0.97414586584250062), + FRAC_CONST(0.97781169577969584), + FRAC_CONST(0.98105641710392333), + FRAC_CONST(0.98391328975491177), + FRAC_CONST(0.98641503193166202), + FRAC_CONST(0.98859353733226141), + FRAC_CONST(0.99047962335771556), + FRAC_CONST(0.9921028127769449), + FRAC_CONST(0.99349115056397752), + FRAC_CONST(0.99467105680259038), + FRAC_CONST(0.9956672157341897), + FRAC_CONST(0.99650250022834352), + FRAC_CONST(0.99719793020823266), + FRAC_CONST(0.99777266288955657), + FRAC_CONST(0.99824401211201486), + FRAC_CONST(0.99862749357391212), + FRAC_CONST(0.99893689243401962), + FRAC_CONST(0.99918434952623147), + FRAC_CONST(0.99938046234161726), + FRAC_CONST(0.99953439696357238), + FRAC_CONST(0.99965400728430465), + FRAC_CONST(0.99974595807027455), + FRAC_CONST(0.99981584876278362), + FRAC_CONST(0.99986833527824281), + FRAC_CONST(0.99990724749057802), + FRAC_CONST(0.99993570051598468), + FRAC_CONST(0.99995619835942084), + FRAC_CONST(0.99997072890647543), + FRAC_CONST(0.9999808496399144), + FRAC_CONST(0.99998776381655818), + FRAC_CONST(0.99999238714961569), + FRAC_CONST(0.99999540529959718), + FRAC_CONST(0.99999732268176988), + FRAC_CONST(0.99999850325054862), + FRAC_CONST(0.99999920402413744), + FRAC_CONST(0.9999996021706401), + FRAC_CONST(0.99999981649545566), + FRAC_CONST(0.99999992415545547), + FRAC_CONST(0.99999997338493041), + FRAC_CONST(0.99999999295825959), + FRAC_CONST(0.99999999904096815) +}; + +#ifdef ALLOW_SMALL_FRAMELENGTH +static const real_t kbd_short_120[] MEM_ALIGN_ATTR = +{ + FRAC_CONST(0.0000452320086910), + FRAC_CONST(0.0001274564692111), + FRAC_CONST(0.0002529398385345), + FRAC_CONST(0.0004335140496648), + FRAC_CONST(0.0006827100966952), + FRAC_CONST(0.0010158708222246), + FRAC_CONST(0.0014502162869659), + FRAC_CONST(0.0020048865156264), + FRAC_CONST(0.0027009618393178), + FRAC_CONST(0.0035614590925043), + FRAC_CONST(0.0046113018122711), + FRAC_CONST(0.0058772627936484), + FRAC_CONST(0.0073878776584103), + FRAC_CONST(0.0091733284512589), + FRAC_CONST(0.0112652966728373), + FRAC_CONST(0.0136967855861945), + FRAC_CONST(0.0165019120857793), + FRAC_CONST(0.0197156688892217), + FRAC_CONST(0.0233736582950619), + FRAC_CONST(0.0275117992367496), + FRAC_CONST(0.0321660098468534), + FRAC_CONST(0.0373718682174417), + FRAC_CONST(0.0431642544948834), + FRAC_CONST(0.0495769778717676), + FRAC_CONST(0.0566423924273392), + FRAC_CONST(0.0643910061132260), + FRAC_CONST(0.0728510874761729), + FRAC_CONST(0.0820482749475221), + FRAC_CONST(0.0920051937045235), + FRAC_CONST(0.1027410852163450), + FRAC_CONST(0.1142714546239370), + FRAC_CONST(0.1266077410648368), + FRAC_CONST(0.1397570159398145), + FRAC_CONST(0.1537217139274270), + FRAC_CONST(0.1684994012857075), + FRAC_CONST(0.1840825856392944), + FRAC_CONST(0.2004585710384133), + FRAC_CONST(0.2176093615976121), + FRAC_CONST(0.2355116164824983), + FRAC_CONST(0.2541366584185075), + FRAC_CONST(0.2734505372545160), + FRAC_CONST(0.2934141494343369), + FRAC_CONST(0.3139834135200387), + FRAC_CONST(0.3351095011824163), + FRAC_CONST(0.3567391223361566), + FRAC_CONST(0.3788148623608774), + FRAC_CONST(0.4012755686250732), + FRAC_CONST(0.4240567828288110), + FRAC_CONST(0.4470912150133537), + FRAC_CONST(0.4703092544619664), + FRAC_CONST(0.4936395121456694), + FRAC_CONST(0.5170093888596962), + FRAC_CONST(0.5403456627591340), + FRAC_CONST(0.5635750896430154), + FRAC_CONST(0.5866250090612892), + FRAC_CONST(0.6094239491338723), + FRAC_CONST(0.6319022228794100), + FRAC_CONST(0.6539925088563087), + FRAC_CONST(0.6756304090216887), + FRAC_CONST(0.6967549769155277), + FRAC_CONST(0.7173092095766250), + FRAC_CONST(0.7372404969921184), + FRAC_CONST(0.7565010233699827), + FRAC_CONST(0.7750481150999984), + FRAC_CONST(0.7928445309277697), + FRAC_CONST(0.8098586906021583), + FRAC_CONST(0.8260648390616000), + FRAC_CONST(0.8414431440907889), + FRAC_CONST(0.8559797262966709), + FRAC_CONST(0.8696666212110165), + FRAC_CONST(0.8825016743142358), + FRAC_CONST(0.8944883707784486), + FRAC_CONST(0.9056356027326216), + FRAC_CONST(0.9159573778427816), + FRAC_CONST(0.9254724739583072), + FRAC_CONST(0.9342040454819434), + FRAC_CONST(0.9421791879559176), + FRAC_CONST(0.9494284680976784), + FRAC_CONST(0.9559854271440150), + FRAC_CONST(0.9618860658493898), + FRAC_CONST(0.9671683198119525), + FRAC_CONST(0.9718715339497299), + FRAC_CONST(0.9760359449042233), + FRAC_CONST(0.9797021798981759), + FRAC_CONST(0.9829107801140203), + FRAC_CONST(0.9857017559923277), + FRAC_CONST(0.9881141809867999), + FRAC_CONST(0.9901858292742826), + FRAC_CONST(0.9919528617340944), + FRAC_CONST(0.9934495632180476), + FRAC_CONST(0.9947081327749199), + FRAC_CONST(0.9957585271195989), + FRAC_CONST(0.9966283562984427), + FRAC_CONST(0.9973428292485683), + FRAC_CONST(0.9979247458259197), + FRAC_CONST(0.9983945309245774), + FRAC_CONST(0.9987703055583410), + FRAC_CONST(0.9990679892449266), + FRAC_CONST(0.9993014277313617), + FRAC_CONST(0.9994825400228521), + FRAC_CONST(0.9996214788122335), + FRAC_CONST(0.9997267987294857), + FRAC_CONST(0.9998056273097539), + FRAC_CONST(0.9998638341781910), + FRAC_CONST(0.9999061946325793), + FRAC_CONST(0.9999365445321382), + FRAC_CONST(0.9999579241373735), + FRAC_CONST(0.9999727092594598), + FRAC_CONST(0.9999827287418790), + FRAC_CONST(0.9999893678912771), + FRAC_CONST(0.9999936579844555), + FRAC_CONST(0.9999963523959187), + FRAC_CONST(0.9999979902130101), + FRAC_CONST(0.9999989484358076), + FRAC_CONST(0.9999994840031031), + FRAC_CONST(0.9999997669534347), + FRAC_CONST(0.9999999060327799), + FRAC_CONST(0.9999999680107184), + FRAC_CONST(0.9999999918774242), + FRAC_CONST(0.9999999989770326) +}; +#endif + +#ifdef __cplusplus +} +#endif +#endif diff --git a/lib/rbcodec/codecs/libfaad/libfaad.make b/lib/rbcodec/codecs/libfaad/libfaad.make new file mode 100644 index 0000000000..ec6998f4d3 --- /dev/null +++ b/lib/rbcodec/codecs/libfaad/libfaad.make @@ -0,0 +1,19 @@ +# __________ __ ___. +# Open \______ \ ____ ____ | | _\_ |__ _______ ___ +# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / +# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < +# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ +# \/ \/ \/ \/ \/ +# $Id$ +# + +# libfaad +FAADLIB := $(CODECDIR)/libfaad.a +FAADLIB_SRC := $(call preprocess, $(RBCODECLIB_DIR)/codecs/libfaad/SOURCES) +FAADLIB_OBJ := $(call c2obj, $(FAADLIB_SRC)) +OTHER_SRC += $(FAADLIB_SRC) +OTHER_INC += -I$(RBCODECLIB_DIR)/codecs/libfaad + +$(FAADLIB): $(FAADLIB_OBJ) + $(SILENT)$(shell rm -f $@) + $(call PRINTS,AR $(@F))$(AR) rcs $@ $^ >/dev/null diff --git a/lib/rbcodec/codecs/libfaad/lt_predict.c b/lib/rbcodec/codecs/libfaad/lt_predict.c new file mode 100644 index 0000000000..f03354fc01 --- /dev/null +++ b/lib/rbcodec/codecs/libfaad/lt_predict.c @@ -0,0 +1,215 @@ +/* +** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding +** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +** +** Any non-GPL usage of this software or parts of this software is strictly +** forbidden. +** +** Commercial non-GPL licensing of this software is possible. +** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** +** $Id$ +**/ + + +#include "common.h" +#include "structs.h" + +#ifdef LTP_DEC + +#include +#include "syntax.h" +#include "lt_predict.h" +#include "filtbank.h" +#include "tns.h" + + +/* static function declarations */ +static int16_t real_to_int16(real_t sig_in); + + +/* check if the object type is an object type that can have LTP */ +uint8_t is_ltp_ot(uint8_t object_type) +{ +#ifdef LTP_DEC + if ((object_type == LTP) +#ifdef ERROR_RESILIENCE + || (object_type == ER_LTP) +#endif +#ifdef LD_DEC + || (object_type == LD) +#endif +#ifdef SCALABLE_DEC + || (object_type == 6) /* TODO */ +#endif + ) + { + return 1; + } +#endif + + return 0; +} + +static const real_t codebook[8] MEM_ALIGN_ATTR = +{ + REAL_CONST(0.570829), + REAL_CONST(0.696616), + REAL_CONST(0.813004), + REAL_CONST(0.911304), + REAL_CONST(0.984900), + REAL_CONST(1.067894), + REAL_CONST(1.194601), + REAL_CONST(1.369533) +}; + +static real_t x_est[2048] MEM_ALIGN_ATTR; +static real_t X_est[2048] MEM_ALIGN_ATTR; +void lt_prediction(ic_stream *ics, ltp_info *ltp, real_t *spec, + int16_t *lt_pred_stat, fb_info *fb, uint8_t win_shape, + uint8_t win_shape_prev, uint8_t sr_index, + uint8_t object_type, uint16_t frame_len) +{ + uint8_t sfb; + uint16_t bin, i, num_samples; + + if (ics->window_sequence != EIGHT_SHORT_SEQUENCE) + { + if (ltp->data_present) + { + num_samples = frame_len << 1; + + for(i = 0; i < num_samples; i++) + { + /* The extra lookback M (N/2 for LD, 0 for LTP) is handled + in the buffer updating */ + +#if 0 + x_est[i] = MUL_R_C(lt_pred_stat[num_samples + i - ltp->lag], + codebook[ltp->coef]); +#else + /* lt_pred_stat is a 16 bit int, multiplied with the fixed point real + this gives a real for x_est + */ + x_est[i] = (real_t)lt_pred_stat[num_samples + i - ltp->lag] * codebook[ltp->coef]; +#endif + } + + filter_bank_ltp(fb, ics->window_sequence, win_shape, win_shape_prev, + x_est, X_est, object_type, frame_len); + + tns_encode_frame(ics, &(ics->tns), sr_index, object_type, X_est, + frame_len); + + for (sfb = 0; sfb < ltp->last_band; sfb++) + { + if (ltp->long_used[sfb]) + { + uint16_t low = ics->swb_offset[sfb]; + uint16_t high = ics->swb_offset[sfb+1]; + + for (bin = low; bin < high; bin++) + { + spec[bin] += X_est[bin]; + } + } + } + } + } +} + +#ifdef FIXED_POINT +static INLINE int16_t real_to_int16(real_t sig_in) +{ + if (sig_in >= 0) + { + sig_in += (1 << (REAL_BITS-1)); + if (sig_in >= REAL_CONST(32768)) + return 32767; + } else { + sig_in += -(1 << (REAL_BITS-1)); + if (sig_in <= REAL_CONST(-32768)) + return -32768; + } + + return (sig_in >> REAL_BITS); +} +#else +static INLINE int16_t real_to_int16(real_t sig_in) +{ + if (sig_in >= 0) + { +#ifndef HAS_LRINTF + sig_in += 0.5f; +#endif + if (sig_in >= 32768.0f) + return 32767; + } else { +#ifndef HAS_LRINTF + sig_in += -0.5f; +#endif + if (sig_in <= -32768.0f) + return -32768; + } + + return lrintf(sig_in); +} +#endif + +void lt_update_state(int16_t *lt_pred_stat, real_t *time, real_t *overlap, + uint16_t frame_len, uint8_t object_type) +{ + uint16_t i; + + /* + * The reference point for index i and the content of the buffer + * lt_pred_stat are arranged so that lt_pred_stat(0 ... N/2 - 1) contains the + * last aliased half window from the IMDCT, and lt_pred_stat(N/2 ... N-1) + * is always all zeros. The rest of lt_pred_stat (i<0) contains the previous + * fully reconstructed time domain samples, i.e., output of the decoder. + * + * These values are shifted up by N*2 to avoid (i<0) + * + * For the LD object type an extra 512 samples lookback is accomodated here. + */ +#ifdef LD_DEC + if (object_type == LD) + { + for (i = 0; i < frame_len; i++) + { + lt_pred_stat[i] /* extra 512 */ = lt_pred_stat[i + frame_len]; + lt_pred_stat[frame_len + i] = lt_pred_stat[i + (frame_len * 2)]; + lt_pred_stat[(frame_len * 2) + i] = real_to_int16(time[i]); + lt_pred_stat[(frame_len * 3) + i] = real_to_int16(overlap[i]); + } + } else { +#endif + for (i = 0; i < frame_len; i++) + { + lt_pred_stat[i] = lt_pred_stat[i + frame_len]; + lt_pred_stat[frame_len + i] = real_to_int16(time[i]); + lt_pred_stat[(frame_len * 2) + i] = real_to_int16(overlap[i]); +#if 0 /* set to zero once upon initialisation */ + lt_pred_stat[(frame_len * 3) + i] = 0; +#endif + } +#ifdef LD_DEC + } +#endif +} + +#endif diff --git a/lib/rbcodec/codecs/libfaad/lt_predict.h b/lib/rbcodec/codecs/libfaad/lt_predict.h new file mode 100644 index 0000000000..1c10751888 --- /dev/null +++ b/lib/rbcodec/codecs/libfaad/lt_predict.h @@ -0,0 +1,63 @@ +/* +** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding +** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +** +** Any non-GPL usage of this software or parts of this software is strictly +** forbidden. +** +** Commercial non-GPL licensing of this software is possible. +** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** +** $Id$ +**/ + +#ifdef LTP_DEC + +#ifndef __LT_PREDICT_H__ +#define __LT_PREDICT_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "filtbank.h" + +uint8_t is_ltp_ot(uint8_t object_type); + +void lt_prediction(ic_stream *ics, + ltp_info *ltp, + real_t *spec, + int16_t *lt_pred_stat, + fb_info *fb, + uint8_t win_shape, + uint8_t win_shape_prev, + uint8_t sr_index, + uint8_t object_type, + uint16_t frame_len); + +void lt_update_state(int16_t *lt_pred_stat, + real_t *time, + real_t *overlap, + uint16_t frame_len, + uint8_t object_type); + +#ifdef __cplusplus +} +#endif +#endif + +#endif diff --git a/lib/rbcodec/codecs/libfaad/mp4.c b/lib/rbcodec/codecs/libfaad/mp4.c new file mode 100644 index 0000000000..94e1a1daaa --- /dev/null +++ b/lib/rbcodec/codecs/libfaad/mp4.c @@ -0,0 +1,300 @@ +/* +** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding +** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +** +** Any non-GPL usage of this software or parts of this software is strictly +** forbidden. +** +** Commercial non-GPL licensing of this software is possible. +** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** +** $Id$ +**/ + +#include "common.h" +#include "structs.h" + +#include + +#include "bits.h" +#include "mp4.h" +#include "syntax.h" + +/* defines if an object type can be decoded by this library or not */ +static uint8_t ObjectTypesTable[32] = { + 0, /* 0 NULL */ +#ifdef MAIN_DEC + 1, /* 1 AAC Main */ +#else + 0, /* 1 AAC Main */ +#endif + 1, /* 2 AAC LC */ +#ifdef SSR_DEC + 1, /* 3 AAC SSR */ +#else + 0, /* 3 AAC SSR */ +#endif +#ifdef LTP_DEC + 1, /* 4 AAC LTP */ +#else + 0, /* 4 AAC LTP */ +#endif +#ifdef SBR_DEC + 1, /* 5 SBR */ +#else + 0, /* 5 SBR */ +#endif +#ifdef SCALABLE_DEC + 1, /* 6 AAC Scalable */ +#else + 0, /* 6 AAC Scalable */ +#endif + 0, /* 7 TwinVQ */ + 0, /* 8 CELP */ + 0, /* 9 HVXC */ + 0, /* 10 Reserved */ + 0, /* 11 Reserved */ + 0, /* 12 TTSI */ + 0, /* 13 Main synthetic */ + 0, /* 14 Wavetable synthesis */ + 0, /* 15 General MIDI */ + 0, /* 16 Algorithmic Synthesis and Audio FX */ + + /* MPEG-4 Version 2 */ +#ifdef ERROR_RESILIENCE + 1, /* 17 ER AAC LC */ + 0, /* 18 (Reserved) */ +#ifdef LTP_DEC + 1, /* 19 ER AAC LTP */ +#else + 0, /* 19 ER AAC LTP */ +#endif +#ifdef SCALABLE_DEC + 1, /* 20 ER AAC scalable */ +#else + 0, /* 20 ER AAC scalable */ +#endif + 0, /* 21 ER TwinVQ */ + 0, /* 22 ER BSAC */ +#ifdef LD_DEC + 1, /* 23 ER AAC LD */ +#else + 0, /* 23 ER AAC LD */ +#endif + 0, /* 24 ER CELP */ + 0, /* 25 ER HVXC */ + 0, /* 26 ER HILN */ + 0, /* 27 ER Parametric */ +#else /* No ER defined */ + 0, /* 17 ER AAC LC */ + 0, /* 18 (Reserved) */ + 0, /* 19 ER AAC LTP */ + 0, /* 20 ER AAC scalable */ + 0, /* 21 ER TwinVQ */ + 0, /* 22 ER BSAC */ + 0, /* 23 ER AAC LD */ + 0, /* 24 ER CELP */ + 0, /* 25 ER HVXC */ + 0, /* 26 ER HILN */ + 0, /* 27 ER Parametric */ +#endif + 0, /* 28 (Reserved) */ + 0, /* 29 (Reserved) */ + 0, /* 30 (Reserved) */ + 0 /* 31 (Reserved) */ +}; + +/* Table 1.6.1 */ +/* rockbox: not used +int8_t NEAACDECAPI NeAACDecAudioSpecificConfig(uint8_t *pBuffer, + uint32_t buffer_size, + mp4AudioSpecificConfig *mp4ASC) +{ + return AudioSpecificConfig2(pBuffer, buffer_size, mp4ASC, NULL); +}*/ + +int8_t AudioSpecificConfig2(uint8_t *pBuffer, + uint32_t buffer_size, + mp4AudioSpecificConfig *mp4ASC, + program_config *pce) +{ + bitfile ld; + int8_t result = 0; +#ifdef SBR_DEC + int8_t bits_to_decode = 0; +#endif + + if (pBuffer == NULL) + return -7; + if (mp4ASC == NULL) + return -8; + + memset(mp4ASC, 0, sizeof(mp4AudioSpecificConfig)); + + faad_initbits(&ld, pBuffer, buffer_size); + faad_byte_align(&ld); + + mp4ASC->objectTypeIndex = (uint8_t)faad_getbits(&ld, 5 + DEBUGVAR(1,1,"parse_audio_decoder_specific_info(): ObjectTypeIndex")); + + mp4ASC->samplingFrequencyIndex = (uint8_t)faad_getbits(&ld, 4 + DEBUGVAR(1,2,"parse_audio_decoder_specific_info(): SamplingFrequencyIndex")); + + mp4ASC->channelsConfiguration = (uint8_t)faad_getbits(&ld, 4 + DEBUGVAR(1,3,"parse_audio_decoder_specific_info(): ChannelsConfiguration")); + + mp4ASC->samplingFrequency = get_sample_rate(mp4ASC->samplingFrequencyIndex); + + if (ObjectTypesTable[mp4ASC->objectTypeIndex] != 1) + { + faad_endbits(&ld); + return -1; + } + + if (mp4ASC->samplingFrequency == 0) + { + faad_endbits(&ld); + return -2; + } + + if (mp4ASC->channelsConfiguration > 7) + { + faad_endbits(&ld); + return -3; + } + +#if (defined(PS_DEC) || defined(DRM_PS)) + /* check if we have a mono file */ + if (mp4ASC->channelsConfiguration == 1) + { + /* upMatrix to 2 channels for implicit signalling of PS */ + mp4ASC->channelsConfiguration = 2; + } +#endif + +#ifdef SBR_DEC + mp4ASC->sbr_present_flag = -1; + if (mp4ASC->objectTypeIndex == 5) + { + uint8_t tmp; + + mp4ASC->sbr_present_flag = 1; + tmp = (uint8_t)faad_getbits(&ld, 4 + DEBUGVAR(1,5,"parse_audio_decoder_specific_info(): extensionSamplingFrequencyIndex")); + /* check for downsampled SBR */ + if (tmp == mp4ASC->samplingFrequencyIndex) + mp4ASC->downSampledSBR = 1; + mp4ASC->samplingFrequencyIndex = tmp; + if (mp4ASC->samplingFrequencyIndex == 15) + { + mp4ASC->samplingFrequency = (uint32_t)faad_getbits(&ld, 24 + DEBUGVAR(1,6,"parse_audio_decoder_specific_info(): extensionSamplingFrequencyIndex")); + } else { + mp4ASC->samplingFrequency = get_sample_rate(mp4ASC->samplingFrequencyIndex); + } + mp4ASC->objectTypeIndex = (uint8_t)faad_getbits(&ld, 5 + DEBUGVAR(1,7,"parse_audio_decoder_specific_info(): ObjectTypeIndex")); + } +#endif + + /* get GASpecificConfig */ + if (mp4ASC->objectTypeIndex == 1 || mp4ASC->objectTypeIndex == 2 || + mp4ASC->objectTypeIndex == 3 || mp4ASC->objectTypeIndex == 4 || + mp4ASC->objectTypeIndex == 6 || mp4ASC->objectTypeIndex == 7) + { + result = GASpecificConfig(&ld, mp4ASC, pce); + +#ifdef ERROR_RESILIENCE + } else if (mp4ASC->objectTypeIndex >= ER_OBJECT_START) { /* ER */ + result = GASpecificConfig(&ld, mp4ASC, pce); + mp4ASC->epConfig = (uint8_t)faad_getbits(&ld, 2 + DEBUGVAR(1,143,"parse_audio_decoder_specific_info(): epConfig")); + + if (mp4ASC->epConfig != 0) + result = -5; +#endif + + } else { + result = -4; + } + +#ifdef SSR_DEC + /* shorter frames not allowed for SSR */ + if ((mp4ASC->objectTypeIndex == 4) && mp4ASC->frameLengthFlag) + return -6; +#endif + + +#ifdef SBR_DEC + bits_to_decode = (int8_t)(buffer_size*8 - faad_get_processed_bits(&ld)); + + if ((mp4ASC->objectTypeIndex != 5) && (bits_to_decode >= 16)) + { + int16_t syncExtensionType = (int16_t)faad_getbits(&ld, 11 + DEBUGVAR(1,9,"parse_audio_decoder_specific_info(): syncExtensionType")); + + if (syncExtensionType == 0x2b7) + { + mp4ASC->objectTypeIndex = (uint8_t)faad_getbits(&ld, 5 + DEBUGVAR(1,10,"parse_audio_decoder_specific_info(): extensionAudioObjectType")); + + if (mp4ASC->objectTypeIndex == 5) + { + mp4ASC->sbr_present_flag = (uint8_t)faad_get1bit(&ld + DEBUGVAR(1,11,"parse_audio_decoder_specific_info(): sbr_present_flag")); + + if (mp4ASC->sbr_present_flag) + { + uint8_t tmp; + tmp = (uint8_t)faad_getbits(&ld, 4 + DEBUGVAR(1,12,"parse_audio_decoder_specific_info(): extensionSamplingFrequencyIndex")); + + /* check for downsampled SBR */ + if (tmp == mp4ASC->samplingFrequencyIndex) + mp4ASC->downSampledSBR = 1; + mp4ASC->samplingFrequencyIndex = tmp; + + if (mp4ASC->samplingFrequencyIndex == 15) + { + mp4ASC->samplingFrequency = (uint32_t)faad_getbits(&ld, 24 + DEBUGVAR(1,13,"parse_audio_decoder_specific_info(): extensionSamplingFrequencyIndex")); + } else { + mp4ASC->samplingFrequency = get_sample_rate(mp4ASC->samplingFrequencyIndex); + } + } + } + } + } + + /* no SBR signalled, this could mean either implicit signalling or no SBR in this file */ + /* MPEG specification states: assume SBR on files with samplerate <= 24000 Hz */ + if (mp4ASC->sbr_present_flag == -1) + { + if (mp4ASC->samplingFrequency <= 24000) + { + mp4ASC->samplingFrequency *= 2; + mp4ASC->forceUpSampling = 1; + } else /* > 24000*/ { + mp4ASC->downSampledSBR = 1; + } + } +#endif + + faad_endbits(&ld); + + return result; +} diff --git a/lib/rbcodec/codecs/libfaad/mp4.h b/lib/rbcodec/codecs/libfaad/mp4.h new file mode 100644 index 0000000000..afcf094796 --- /dev/null +++ b/lib/rbcodec/codecs/libfaad/mp4.h @@ -0,0 +1,51 @@ +/* +** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding +** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +** +** Any non-GPL usage of this software or parts of this software is strictly +** forbidden. +** +** Commercial non-GPL licensing of this software is possible. +** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** +** $Id$ +**/ + +#ifndef __MP4_H__ +#define __MP4_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "decoder.h" + +/* rockbox: not used +int8_t NEAACDECAPI NeAACDecAudioSpecificConfig(uint8_t *pBuffer, + uint32_t buffer_size, + mp4AudioSpecificConfig *mp4ASC); +*/ + +int8_t AudioSpecificConfig2(uint8_t *pBuffer, + uint32_t buffer_size, + mp4AudioSpecificConfig *mp4ASC, + program_config *pce); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/lib/rbcodec/codecs/libfaad/ms.c b/lib/rbcodec/codecs/libfaad/ms.c new file mode 100644 index 0000000000..b42e95a408 --- /dev/null +++ b/lib/rbcodec/codecs/libfaad/ms.c @@ -0,0 +1,73 @@ +/* +** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding +** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +** +** Any non-GPL usage of this software or parts of this software is strictly +** forbidden. +** +** Commercial non-GPL licensing of this software is possible. +** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** +** $Id$ +**/ + +#include "common.h" +#include "structs.h" + +#include "syntax.h" +#include "ms.h" +#include "is.h" +#include "pns.h" + +void ms_decode(ic_stream *ics, ic_stream *icsr, real_t *l_spec, real_t *r_spec, + uint16_t frame_len) +{ + uint8_t g, b, sfb; + uint8_t group = 0; + uint16_t nshort = frame_len/8; + + uint16_t i, k; + + if (ics->ms_mask_present >= 1) + { + for (g = 0; g < ics->num_window_groups; g++) + { + for (b = 0; b < ics->window_group_length[g]; b++) + { + for (sfb = 0; sfb < ics->max_sfb; sfb++) + { + /* If intensity stereo coding or noise substitution is on + for a particular scalefactor band, no M/S stereo decoding + is carried out. + */ + if ((ics->ms_used[g][sfb] || ics->ms_mask_present == 2) && + !is_intensity(icsr, g, sfb) && !is_noise(ics, g, sfb)) + { + k = (group*nshort) + ics->swb_offset[sfb]; + for (i = ics->swb_offset[sfb]; i < ics->swb_offset[sfb+1]; i++, k++) + { + /* L' = L+R, R' = L-R */ + l_spec[k] = l_spec[k] + r_spec[k]; + r_spec[k] = l_spec[k] - (r_spec[k]<<1); + } + } + } + group++; + } + } + } +} diff --git a/lib/rbcodec/codecs/libfaad/ms.h b/lib/rbcodec/codecs/libfaad/ms.h new file mode 100644 index 0000000000..384fa4294b --- /dev/null +++ b/lib/rbcodec/codecs/libfaad/ms.h @@ -0,0 +1,41 @@ +/* +** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding +** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +** +** Any non-GPL usage of this software or parts of this software is strictly +** forbidden. +** +** Commercial non-GPL licensing of this software is possible. +** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** +** $Id$ +**/ + +#ifndef __MS_H__ +#define __MS_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +void ms_decode(ic_stream *ics, ic_stream *icsr, real_t *l_spec, real_t *r_spec, + uint16_t frame_len); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/lib/rbcodec/codecs/libfaad/output.c b/lib/rbcodec/codecs/libfaad/output.c new file mode 100644 index 0000000000..6594582bbd --- /dev/null +++ b/lib/rbcodec/codecs/libfaad/output.c @@ -0,0 +1,557 @@ +/* +** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding +** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +** +** Any non-GPL usage of this software or parts of this software is strictly +** forbidden. +** +** Commercial non-GPL licensing of this software is possible. +** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** +** $Id$ +**/ + +#include "common.h" +#include "structs.h" + +#include "output.h" +#include "decoder.h" + +#ifndef FIXED_POINT + + +#define FLOAT_SCALE (1.0f/(1<<15)) + +#define DM_MUL REAL_CONST(0.3203772410170407) // 1/(1+sqrt(2) + 1/sqrt(2)) +#define RSQRT2 REAL_CONST(0.7071067811865475244) // 1/sqrt(2) + + +static INLINE real_t get_sample(real_t **input, uint8_t channel, uint16_t sample, + uint8_t down_matrix, uint8_t *internal_channel) +{ + if (!down_matrix) + return input[internal_channel[channel]][sample]; + + if (channel == 0) + { + return DM_MUL * (input[internal_channel[1]][sample] + + input[internal_channel[0]][sample] * RSQRT2 + + input[internal_channel[3]][sample] * RSQRT2); + } else { + return DM_MUL * (input[internal_channel[2]][sample] + + input[internal_channel[0]][sample] * RSQRT2 + + input[internal_channel[4]][sample] * RSQRT2); + } +} + +#ifndef HAS_LRINTF +#define CLIP(sample, max, min) \ +if (sample >= 0.0f) \ +{ \ + sample += 0.5f; \ + if (sample >= max) \ + sample = max; \ +} else { \ + sample += -0.5f; \ + if (sample <= min) \ + sample = min; \ +} +#else +#define CLIP(sample, max, min) \ +if (sample >= 0.0f) \ +{ \ + if (sample >= max) \ + sample = max; \ +} else { \ + if (sample <= min) \ + sample = min; \ +} +#endif + +#define CONV(a,b) ((a<<1)|(b&0x1)) + +static void to_PCM_16bit(NeAACDecHandle hDecoder, real_t **input, + uint8_t channels, uint16_t frame_len, + int16_t **sample_buffer) +{ + uint8_t ch, ch1; + uint16_t i; + + switch (CONV(channels,hDecoder->downMatrix)) + { + case CONV(1,0): + case CONV(1,1): + for(i = 0; i < frame_len; i++) + { + real_t inp = input[hDecoder->internal_channel[0]][i]; + + CLIP(inp, 32767.0f, -32768.0f); + + (*sample_buffer)[i] = (int16_t)lrintf(inp); + } + break; + case CONV(2,0): + if (hDecoder->upMatrix) + { + ch = hDecoder->internal_channel[0]; + for(i = 0; i < frame_len; i++) + { + real_t inp0 = input[ch][i]; + + CLIP(inp0, 32767.0f, -32768.0f); + + (*sample_buffer)[(i*2)+0] = (int16_t)lrintf(inp0); + (*sample_buffer)[(i*2)+1] = (int16_t)lrintf(inp0); + } + } else { + ch = hDecoder->internal_channel[0]; + ch1 = hDecoder->internal_channel[1]; + for(i = 0; i < frame_len; i++) + { + real_t inp0 = input[ch ][i]; + real_t inp1 = input[ch1][i]; + + CLIP(inp0, 32767.0f, -32768.0f); + CLIP(inp1, 32767.0f, -32768.0f); + + (*sample_buffer)[(i*2)+0] = (int16_t)lrintf(inp0); + (*sample_buffer)[(i*2)+1] = (int16_t)lrintf(inp1); + } + } + break; + default: + for (ch = 0; ch < channels; ch++) + { + for(i = 0; i < frame_len; i++) + { + real_t inp = get_sample(input, ch, i, hDecoder->downMatrix, hDecoder->internal_channel); + + CLIP(inp, 32767.0f, -32768.0f); + + (*sample_buffer)[(i*channels)+ch] = (int16_t)lrintf(inp); + } + } + break; + } +} + +static void to_PCM_24bit(NeAACDecHandle hDecoder, real_t **input, + uint8_t channels, uint16_t frame_len, + int32_t **sample_buffer) +{ + uint8_t ch, ch1; + uint16_t i; + + switch (CONV(channels,hDecoder->downMatrix)) + { + case CONV(1,0): + case CONV(1,1): + for(i = 0; i < frame_len; i++) + { + real_t inp = input[hDecoder->internal_channel[0]][i]; + + inp *= 256.0f; + CLIP(inp, 8388607.0f, -8388608.0f); + + (*sample_buffer)[i] = (int32_t)lrintf(inp); + } + break; + case CONV(2,0): + if (hDecoder->upMatrix) + { + ch = hDecoder->internal_channel[0]; + for(i = 0; i < frame_len; i++) + { + real_t inp0 = input[ch][i]; + + inp0 *= 256.0f; + CLIP(inp0, 8388607.0f, -8388608.0f); + + (*sample_buffer)[(i*2)+0] = (int32_t)lrintf(inp0); + (*sample_buffer)[(i*2)+1] = (int32_t)lrintf(inp0); + } + } else { + ch = hDecoder->internal_channel[0]; + ch1 = hDecoder->internal_channel[1]; + for(i = 0; i < frame_len; i++) + { + real_t inp0 = input[ch ][i]; + real_t inp1 = input[ch1][i]; + + inp0 *= 256.0f; + inp1 *= 256.0f; + CLIP(inp0, 8388607.0f, -8388608.0f); + CLIP(inp1, 8388607.0f, -8388608.0f); + + (*sample_buffer)[(i*2)+0] = (int32_t)lrintf(inp0); + (*sample_buffer)[(i*2)+1] = (int32_t)lrintf(inp1); + } + } + break; + default: + for (ch = 0; ch < channels; ch++) + { + for(i = 0; i < frame_len; i++) + { + real_t inp = get_sample(input, ch, i, hDecoder->downMatrix, hDecoder->internal_channel); + + inp *= 256.0f; + CLIP(inp, 8388607.0f, -8388608.0f); + + (*sample_buffer)[(i*channels)+ch] = (int32_t)lrintf(inp); + } + } + break; + } +} + +static void to_PCM_32bit(NeAACDecHandle hDecoder, real_t **input, + uint8_t channels, uint16_t frame_len, + int32_t **sample_buffer) +{ + uint8_t ch, ch1; + uint16_t i; + + switch (CONV(channels,hDecoder->downMatrix)) + { + case CONV(1,0): + case CONV(1,1): + for(i = 0; i < frame_len; i++) + { + real_t inp = input[hDecoder->internal_channel[0]][i]; + + inp *= 65536.0f; + CLIP(inp, 2147483647.0f, -2147483648.0f); + + (*sample_buffer)[i] = (int32_t)lrintf(inp); + } + break; + case CONV(2,0): + if (hDecoder->upMatrix) + { + ch = hDecoder->internal_channel[0]; + for(i = 0; i < frame_len; i++) + { + real_t inp0 = input[ch][i]; + + inp0 *= 65536.0f; + CLIP(inp0, 2147483647.0f, -2147483648.0f); + + (*sample_buffer)[(i*2)+0] = (int32_t)lrintf(inp0); + (*sample_buffer)[(i*2)+1] = (int32_t)lrintf(inp0); + } + } else { + ch = hDecoder->internal_channel[0]; + ch1 = hDecoder->internal_channel[1]; + for(i = 0; i < frame_len; i++) + { + real_t inp0 = input[ch ][i]; + real_t inp1 = input[ch1][i]; + + inp0 *= 65536.0f; + inp1 *= 65536.0f; + CLIP(inp0, 2147483647.0f, -2147483648.0f); + CLIP(inp1, 2147483647.0f, -2147483648.0f); + + (*sample_buffer)[(i*2)+0] = (int32_t)lrintf(inp0); + (*sample_buffer)[(i*2)+1] = (int32_t)lrintf(inp1); + } + } + break; + default: + for (ch = 0; ch < channels; ch++) + { + for(i = 0; i < frame_len; i++) + { + real_t inp = get_sample(input, ch, i, hDecoder->downMatrix, hDecoder->internal_channel); + + inp *= 65536.0f; + CLIP(inp, 2147483647.0f, -2147483648.0f); + + (*sample_buffer)[(i*channels)+ch] = (int32_t)lrintf(inp); + } + } + break; + } +} + +static void to_PCM_float(NeAACDecHandle hDecoder, real_t **input, + uint8_t channels, uint16_t frame_len, + float32_t **sample_buffer) +{ + uint8_t ch, ch1; + uint16_t i; + + switch (CONV(channels,hDecoder->downMatrix)) + { + case CONV(1,0): + case CONV(1,1): + for(i = 0; i < frame_len; i++) + { + real_t inp = input[hDecoder->internal_channel[0]][i]; + (*sample_buffer)[i] = inp*FLOAT_SCALE; + } + break; + case CONV(2,0): + if (hDecoder->upMatrix) + { + ch = hDecoder->internal_channel[0]; + for(i = 0; i < frame_len; i++) + { + real_t inp0 = input[ch][i]; + (*sample_buffer)[(i*2)+0] = inp0*FLOAT_SCALE; + (*sample_buffer)[(i*2)+1] = inp0*FLOAT_SCALE; + } + } else { + ch = hDecoder->internal_channel[0]; + ch1 = hDecoder->internal_channel[1]; + for(i = 0; i < frame_len; i++) + { + real_t inp0 = input[ch ][i]; + real_t inp1 = input[ch1][i]; + (*sample_buffer)[(i*2)+0] = inp0*FLOAT_SCALE; + (*sample_buffer)[(i*2)+1] = inp1*FLOAT_SCALE; + } + } + break; + default: + for (ch = 0; ch < channels; ch++) + { + for(i = 0; i < frame_len; i++) + { + real_t inp = get_sample(input, ch, i, hDecoder->downMatrix, hDecoder->internal_channel); + (*sample_buffer)[(i*channels)+ch] = inp*FLOAT_SCALE; + } + } + break; + } +} + +static void to_PCM_double(NeAACDecHandle hDecoder, real_t **input, + uint8_t channels, uint16_t frame_len, + double **sample_buffer) +{ + uint8_t ch, ch1; + uint16_t i; + + switch (CONV(channels,hDecoder->downMatrix)) + { + case CONV(1,0): + case CONV(1,1): + for(i = 0; i < frame_len; i++) + { + real_t inp = input[hDecoder->internal_channel[0]][i]; + (*sample_buffer)[i] = (double)inp*FLOAT_SCALE; + } + break; + case CONV(2,0): + if (hDecoder->upMatrix) + { + ch = hDecoder->internal_channel[0]; + for(i = 0; i < frame_len; i++) + { + real_t inp0 = input[ch][i]; + (*sample_buffer)[(i*2)+0] = (double)inp0*FLOAT_SCALE; + (*sample_buffer)[(i*2)+1] = (double)inp0*FLOAT_SCALE; + } + } else { + ch = hDecoder->internal_channel[0]; + ch1 = hDecoder->internal_channel[1]; + for(i = 0; i < frame_len; i++) + { + real_t inp0 = input[ch ][i]; + real_t inp1 = input[ch1][i]; + (*sample_buffer)[(i*2)+0] = (double)inp0*FLOAT_SCALE; + (*sample_buffer)[(i*2)+1] = (double)inp1*FLOAT_SCALE; + } + } + break; + default: + for (ch = 0; ch < channels; ch++) + { + for(i = 0; i < frame_len; i++) + { + real_t inp = get_sample(input, ch, i, hDecoder->downMatrix, hDecoder->internal_channel); + (*sample_buffer)[(i*channels)+ch] = (double)inp*FLOAT_SCALE; + } + } + break; + } +} + +void *output_to_PCM(NeAACDecHandle hDecoder, + real_t **input, void *sample_buffer, uint8_t channels, + uint16_t frame_len, uint8_t format) +{ + int16_t *short_sample_buffer = (int16_t*)sample_buffer; + int32_t *int_sample_buffer = (int32_t*)sample_buffer; + float32_t *float_sample_buffer = (float32_t*)sample_buffer; + double *double_sample_buffer = (double*)sample_buffer; + +#ifdef PROFILE + int64_t count = faad_get_ts(); +#endif + + /* Copy output to a standard PCM buffer */ + switch (format) + { + case FAAD_FMT_16BIT: + to_PCM_16bit(hDecoder, input, channels, frame_len, &short_sample_buffer); + break; + case FAAD_FMT_24BIT: + to_PCM_24bit(hDecoder, input, channels, frame_len, &int_sample_buffer); + break; + case FAAD_FMT_32BIT: + to_PCM_32bit(hDecoder, input, channels, frame_len, &int_sample_buffer); + break; + case FAAD_FMT_FLOAT: + to_PCM_float(hDecoder, input, channels, frame_len, &float_sample_buffer); + break; + case FAAD_FMT_DOUBLE: + to_PCM_double(hDecoder, input, channels, frame_len, &double_sample_buffer); + break; + } + +#ifdef PROFILE + count = faad_get_ts() - count; + hDecoder->output_cycles += count; +#endif + + return sample_buffer; +} + +#else + +#define DM_MUL FRAC_CONST(0.3203772410170407) // 1/(1+sqrt(2) + 1/sqrt(2)) +#define RSQRT2 FRAC_CONST(0.7071067811865475244) // 1/sqrt(2) + +static INLINE real_t get_sample(real_t **input, uint8_t channel, uint16_t sample, + uint8_t down_matrix, uint8_t up_matrix, + uint8_t *internal_channel) +{ + if (up_matrix == 1) + return input[internal_channel[0]][sample]; + + if (!down_matrix) + return input[internal_channel[channel]][sample]; + + if (channel == 0) + { + real_t C = MUL_F(input[internal_channel[0]][sample], RSQRT2); + real_t L_S = MUL_F(input[internal_channel[3]][sample], RSQRT2); + real_t cum = input[internal_channel[1]][sample] + C + L_S; + return MUL_F(cum, DM_MUL); + } else { + real_t C = MUL_F(input[internal_channel[0]][sample], RSQRT2); + real_t R_S = MUL_F(input[internal_channel[4]][sample], RSQRT2); + real_t cum = input[internal_channel[2]][sample] + C + R_S; + return MUL_F(cum, DM_MUL); + } +} + +void* output_to_PCM(NeAACDecHandle hDecoder, + real_t **input, void *sample_buffer, uint8_t channels, + uint16_t frame_len, uint8_t format) +{ + uint8_t ch; + uint16_t i; + int16_t *short_sample_buffer = (int16_t*)sample_buffer; + int32_t *int_sample_buffer = (int32_t*)sample_buffer; + + /* Copy output to a standard PCM buffer */ + for (ch = 0; ch < channels; ch++) + { + switch (format) + { + case FAAD_FMT_16BIT: + for(i = 0; i < frame_len; i++) + { + int32_t tmp = get_sample(input, ch, i, hDecoder->downMatrix, hDecoder->upMatrix, + hDecoder->internal_channel); + if (tmp >= 0) + { + tmp += (1 << (REAL_BITS-1)); + if (tmp >= REAL_CONST(32767)) + { + tmp = REAL_CONST(32767); + } + } else { + tmp += -(1 << (REAL_BITS-1)); + if (tmp <= REAL_CONST(-32768)) + { + tmp = REAL_CONST(-32768); + } + } + tmp >>= REAL_BITS; + short_sample_buffer[(i*channels)+ch] = (int16_t)tmp; + } + break; + case FAAD_FMT_24BIT: + for(i = 0; i < frame_len; i++) + { + int32_t tmp = get_sample(input, ch, i, hDecoder->downMatrix, hDecoder->upMatrix, + hDecoder->internal_channel); + if (tmp >= 0) + { + tmp += (1 << (REAL_BITS-9)); + tmp >>= (REAL_BITS-8); + if (tmp >= 8388607) + { + tmp = 8388607; + } + } else { + tmp += -(1 << (REAL_BITS-9)); + tmp >>= (REAL_BITS-8); + if (tmp <= -8388608) + { + tmp = -8388608; + } + } + int_sample_buffer[(i*channels)+ch] = (int32_t)tmp; + } + break; + case FAAD_FMT_32BIT: + for(i = 0; i < frame_len; i++) + { + int32_t tmp = get_sample(input, ch, i, hDecoder->downMatrix, hDecoder->upMatrix, + hDecoder->internal_channel); + if (tmp >= 0) + { + tmp += (1 << (16-REAL_BITS-1)); + tmp <<= (16-REAL_BITS); + } else { + tmp += -(1 << (16-REAL_BITS-1)); + tmp <<= (16-REAL_BITS); + } + int_sample_buffer[(i*channels)+ch] = (int32_t)tmp; + } + break; + case FAAD_FMT_FIXED: + for(i = 0; i < frame_len; i++) + { + real_t tmp = get_sample(input, ch, i, hDecoder->downMatrix, hDecoder->upMatrix, + hDecoder->internal_channel); + int_sample_buffer[(i*channels)+ch] = (int32_t)tmp; + } + break; + } + } + + return sample_buffer; +} + +#endif diff --git a/lib/rbcodec/codecs/libfaad/output.h b/lib/rbcodec/codecs/libfaad/output.h new file mode 100644 index 0000000000..9fe8356541 --- /dev/null +++ b/lib/rbcodec/codecs/libfaad/output.h @@ -0,0 +1,45 @@ +/* +** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding +** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +** +** Any non-GPL usage of this software or parts of this software is strictly +** forbidden. +** +** Commercial non-GPL licensing of this software is possible. +** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** +** $Id$ +**/ + +#ifndef __OUTPUT_H__ +#define __OUTPUT_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +void* output_to_PCM(NeAACDecHandle hDecoder, + real_t **input, + void *samplebuffer, + uint8_t channels, + uint16_t frame_len, + uint8_t format); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/lib/rbcodec/codecs/libfaad/pns.c b/lib/rbcodec/codecs/libfaad/pns.c new file mode 100644 index 0000000000..b75cf9f1ed --- /dev/null +++ b/lib/rbcodec/codecs/libfaad/pns.c @@ -0,0 +1,263 @@ +/* +** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding +** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +** +** Any non-GPL usage of this software or parts of this software is strictly +** forbidden. +** +** Commercial non-GPL licensing of this software is possible. +** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** +** $Id$ +**/ + +#include "common.h" +#include "structs.h" + +#include "pns.h" + + +/* static function declarations */ +static void gen_rand_vector(real_t *spec, int16_t scale_factor, uint16_t size, + uint8_t sub); + + +#ifdef FIXED_POINT + +#define step(shift) \ + if ((0x40000000l >> shift) + root <= value) \ + { \ + value -= (0x40000000l >> shift) + root; \ + root = (root >> 1) | (0x40000000l >> shift); \ + } else { \ + root = root >> 1; \ + } + +/* fixed point square root approximation */ +/* !!!! ONLY WORKS FOR EVEN %REAL_BITS% !!!! */ +static real_t fp_sqrt(real_t value) +{ + real_t root = 0; + + step( 0); step( 2); step( 4); step( 6); + step( 8); step(10); step(12); step(14); + step(16); step(18); step(20); step(22); + step(24); step(26); step(28); step(30); + + if (root < value) + ++root; + + root <<= (REAL_BITS/2); + + return root; +} + +static real_t pow2_table[] = +{ + COEF_CONST(1.0), + COEF_CONST(1.18920711500272), + COEF_CONST(1.41421356237310), + COEF_CONST(1.68179283050743) +}; +#endif + +/* The function gen_rand_vector(addr, size) generates a vector of length + with signed random values of average energy MEAN_NRG per random + value. A suitable random number generator can be realized using one + multiplication/accumulation per random value. +*/ +static INLINE void gen_rand_vector(real_t *spec, int16_t scale_factor, uint16_t size, + uint8_t sub) +{ +#ifndef FIXED_POINT + uint16_t i; + real_t energy = 0.0; + + real_t scale = (real_t)1.0/(real_t)size; + + for (i = 0; i < size; i++) + { + real_t tmp = scale*(real_t)(int32_t)random_int(); + spec[i] = tmp; + energy += tmp*tmp; + } + + scale = (real_t)1.0/(real_t)sqrt(energy); + scale *= (real_t)pow(2.0, 0.25 * scale_factor); + for (i = 0; i < size; i++) + { + spec[i] *= scale; + } +#else + uint16_t i; + real_t energy = 0, scale; + int32_t exp, frac; + + for (i = 0; i < size; i++) + { + /* this can be replaced by a 16 bit random generator!!!! */ + real_t tmp = (int32_t)random_int(); + if (tmp < 0) + tmp = -(tmp & ((1<<(REAL_BITS-1))-1)); + else + tmp = (tmp & ((1<<(REAL_BITS-1))-1)); + + energy += MUL_R(tmp,tmp); + + spec[i] = tmp; + } + + energy = fp_sqrt(energy); + if (energy > 0) + { + scale = DIV_R(REAL_CONST(1), energy); + + exp = scale_factor >> 2; + frac = scale_factor & 3; + + /* IMDCT pre-scaling */ + exp -= sub; + + if (exp < 0) + scale >>= -exp; + else + scale <<= exp; + + if (frac) + scale = MUL_C(scale, pow2_table[frac]); + + for (i = 0; i < size; i++) + { + spec[i] = MUL_R(spec[i], scale); + } + } +#endif +} + +void pns_decode(ic_stream *ics_left, ic_stream *ics_right, + real_t *spec_left, real_t *spec_right, uint16_t frame_len, + uint8_t channel_pair, uint8_t object_type) +{ + uint8_t g, sfb, b; + uint16_t size, offs; + + uint8_t group = 0; + uint16_t nshort = frame_len >> 3; + + uint8_t sub = 0; + +#ifdef FIXED_POINT + /* IMDCT scaling */ + if (object_type == LD) + { + sub = 9 /*9*/; + } else { + if (ics_left->window_sequence == EIGHT_SHORT_SEQUENCE) + sub = 7 /*7*/; + else + sub = 10 /*10*/; + } +#endif + + for (g = 0; g < ics_left->num_window_groups; g++) + { + /* Do perceptual noise substitution decoding */ + for (b = 0; b < ics_left->window_group_length[g]; b++) + { + for (sfb = 0; sfb < ics_left->max_sfb; sfb++) + { + if (is_noise(ics_left, g, sfb)) + { +#ifdef LTP_DEC + /* Simultaneous use of LTP and PNS is not prevented in the + syntax. If both LTP, and PNS are enabled on the same + scalefactor band, PNS takes precedence, and no prediction + is applied to this band. + */ + ics_left->ltp.long_used[sfb] = 0; + ics_left->ltp2.long_used[sfb] = 0; +#endif + +#ifdef MAIN_DEC + /* For scalefactor bands coded using PNS the corresponding + predictors are switched to "off". + */ + ics_left->pred.prediction_used[sfb] = 0; +#endif + + offs = ics_left->swb_offset[sfb]; + size = ics_left->swb_offset[sfb+1] - offs; + + /* Generate random vector */ + gen_rand_vector(&spec_left[(group*nshort)+offs], + ics_left->scale_factors[g][sfb], size, sub); + } + +/* From the spec: + If the same scalefactor band and group is coded by perceptual noise + substitution in both channels of a channel pair, the correlation of + the noise signal can be controlled by means of the ms_used field: While + the default noise generation process works independently for each channel + (separate generation of random vectors), the same random vector is used + for both channels if ms_used[] is set for a particular scalefactor band + and group. In this case, no M/S stereo coding is carried out (because M/S + stereo coding and noise substitution coding are mutually exclusive). + If the same scalefactor band and group is coded by perceptual noise + substitution in only one channel of a channel pair the setting of ms_used[] + is not evaluated. +*/ + if (channel_pair) + { + if (is_noise(ics_right, g, sfb)) + { + if (((ics_left->ms_mask_present == 1) && + (ics_left->ms_used[g][sfb])) || + (ics_left->ms_mask_present == 2)) + { + uint16_t c; + + offs = ics_right->swb_offset[sfb]; + size = ics_right->swb_offset[sfb+1] - offs; + + for (c = 0; c < size; c++) + { + spec_right[(group*nshort) + offs + c] = + spec_left[(group*nshort) + offs + c]; + } + } else /*if (ics_left->ms_mask_present == 0)*/ { +#ifdef LTP_DEC + ics_right->ltp.long_used[sfb] = 0; + ics_right->ltp2.long_used[sfb] = 0; +#endif +#ifdef MAIN_DEC + ics_right->pred.prediction_used[sfb] = 0; +#endif + + offs = ics_right->swb_offset[sfb]; + size = ics_right->swb_offset[sfb+1] - offs; + + /* Generate random vector */ + gen_rand_vector(&spec_right[(group*nshort)+offs], + ics_right->scale_factors[g][sfb], size, sub); + } + } + } + } /* sfb */ + group++; + } /* b */ + } /* g */ +} diff --git a/lib/rbcodec/codecs/libfaad/pns.h b/lib/rbcodec/codecs/libfaad/pns.h new file mode 100644 index 0000000000..e789f5708a --- /dev/null +++ b/lib/rbcodec/codecs/libfaad/pns.h @@ -0,0 +1,53 @@ +/* +** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding +** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +** +** Any non-GPL usage of this software or parts of this software is strictly +** forbidden. +** +** Commercial non-GPL licensing of this software is possible. +** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** +** $Id$ +**/ + +#ifndef __PNS_H__ +#define __PNS_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "syntax.h" + +#define NOISE_OFFSET 90 + +void pns_decode(ic_stream *ics_left, ic_stream *ics_right, + real_t *spec_left, real_t *spec_right, uint16_t frame_len, + uint8_t channel_pair, uint8_t object_type); + +static INLINE uint8_t is_noise(ic_stream *ics, uint8_t group, uint8_t sfb) +{ + if (ics->sfb_cb[group][sfb] == NOISE_HCB) + return 1; + return 0; +} + +#ifdef __cplusplus +} +#endif +#endif diff --git a/lib/rbcodec/codecs/libfaad/ps_dec.c b/lib/rbcodec/codecs/libfaad/ps_dec.c new file mode 100644 index 0000000000..3fed4e6a0a --- /dev/null +++ b/lib/rbcodec/codecs/libfaad/ps_dec.c @@ -0,0 +1,1938 @@ +/* +** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR and PS decoding +** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +** +** Any non-GPL usage of this software or parts of this software is strictly +** forbidden. +** +** Commercial non-GPL licensing of this software is possible. +** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** +** $Id$ +**/ + +#include "common.h" + +#ifdef PS_DEC + +#include +#include "ps_dec.h" +#include "ps_tables.h" + +/* constants */ +#define NEGATE_IPD_MASK (0x1000) +#define DECAY_SLOPE FRAC_CONST(0.05) +#define COEF_SQRT2 COEF_CONST(1.4142135623731) + +/* tables */ +/* filters are mirrored in coef 6, second half left out */ +static const real_t p8_13_20[7] = +{ + FRAC_CONST(0.00746082949812), + FRAC_CONST(0.02270420949825), + FRAC_CONST(0.04546865930473), + FRAC_CONST(0.07266113929591), + FRAC_CONST(0.09885108575264), + FRAC_CONST(0.11793710567217), + FRAC_CONST(0.125) +}; + +static const real_t p2_13_20[7] = +{ + FRAC_CONST(0.0), + FRAC_CONST(0.01899487526049), + FRAC_CONST(0.0), + FRAC_CONST(-0.07293139167538), + FRAC_CONST(0.0), + FRAC_CONST(0.30596630545168), + FRAC_CONST(0.5) +}; + +static const real_t p12_13_34[7] = +{ + FRAC_CONST(0.04081179924692), + FRAC_CONST(0.03812810994926), + FRAC_CONST(0.05144908135699), + FRAC_CONST(0.06399831151592), + FRAC_CONST(0.07428313801106), + FRAC_CONST(0.08100347892914), + FRAC_CONST(0.08333333333333) +}; + +static const real_t p8_13_34[7] = +{ + FRAC_CONST(0.01565675600122), + FRAC_CONST(0.03752716391991), + FRAC_CONST(0.05417891378782), + FRAC_CONST(0.08417044116767), + FRAC_CONST(0.10307344158036), + FRAC_CONST(0.12222452249753), + FRAC_CONST(0.125) +}; + +static const real_t p4_13_34[7] = +{ + FRAC_CONST(-0.05908211155639), + FRAC_CONST(-0.04871498374946), + FRAC_CONST(0.0), + FRAC_CONST(0.07778723915851), + FRAC_CONST(0.16486303567403), + FRAC_CONST(0.23279856662996), + FRAC_CONST(0.25) +}; + +#ifdef PARAM_32KHZ +static const uint8_t delay_length_d[2][NO_ALLPASS_LINKS] = { + { 1, 2, 3 } /* d_24kHz */, + { 3, 4, 5 } /* d_48kHz */ +}; +#else +static const uint8_t delay_length_d[NO_ALLPASS_LINKS] = { + 3, 4, 5 /* d_48kHz */ +}; +#endif +static const real_t filter_a[NO_ALLPASS_LINKS] = { /* a(m) = exp(-d_48kHz(m)/7) */ + FRAC_CONST(0.65143905753106), + FRAC_CONST(0.56471812200776), + FRAC_CONST(0.48954165955695) +}; + +static const uint8_t group_border20[10+12 + 1] = +{ + 6, 7, 0, 1, 2, 3, /* 6 subqmf subbands */ + 9, 8, /* 2 subqmf subbands */ + 10, 11, /* 2 subqmf subbands */ + 3, 4, 5, 6, 7, 8, 9, 11, 14, 18, 23, 35, 64 +}; + +static const uint8_t group_border34[32+18 + 1] = +{ + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, /* 12 subqmf subbands */ + 12, 13, 14, 15, 16, 17, 18, 19, /* 8 subqmf subbands */ + 20, 21, 22, 23, /* 4 subqmf subbands */ + 24, 25, 26, 27, /* 4 subqmf subbands */ + 28, 29, 30, 31, /* 4 subqmf subbands */ + 32-27, 33-27, 34-27, 35-27, 36-27, 37-27, 38-27, 40-27, 42-27, 44-27, 46-27, 48-27, 51-27, 54-27, 57-27, 60-27, 64-27, 68-27, 91-27 +}; + +static const uint16_t map_group2bk20[10+12] = +{ + (NEGATE_IPD_MASK | 1), (NEGATE_IPD_MASK | 0), + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 +}; + +static const uint16_t map_group2bk34[32+18] = +{ + 0, 1, 2, 3, 4, 5, 6, 6, 7, (NEGATE_IPD_MASK | 2), (NEGATE_IPD_MASK | 1), (NEGATE_IPD_MASK | 0), + 10, 10, 4, 5, 6, 7, 8, 9, + 10, 11, 12, 9, + 14, 11, 12, 13, + 14, 15, 16, 13, + 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33 +}; + + +/* static function declarations */ +static void ps_data_decode(ps_info *ps); +static void hybrid_init(hyb_info *hyb); +static void channel_filter2(hyb_info *hyb, uint8_t frame_len, const real_t *filter, + qmf_t *buffer, qmf_t X_hybrid[32][12]); +static INLINE void DCT3_4_unscaled(real_t *y, real_t *x); +static void channel_filter8(hyb_info *hyb, uint8_t frame_len, const real_t *filter, + qmf_t *buffer, qmf_t X_hybrid[32][12]); +static void hybrid_analysis(hyb_info *hyb, qmf_t X[32][64], qmf_t X_hybrid[32][32], + uint8_t use34); +static void hybrid_synthesis(hyb_info *hyb, qmf_t X[32][64], qmf_t X_hybrid[32][32], + uint8_t use34); +static int8_t delta_clip(int8_t i, int8_t min, int8_t max); +static void delta_decode(uint8_t enable, int8_t *index, int8_t *index_prev, + uint8_t dt_flag, uint8_t nr_par, uint8_t stride, + int8_t min_index, int8_t max_index); +static void delta_modulo_decode(uint8_t enable, int8_t *index, int8_t *index_prev, + uint8_t dt_flag, uint8_t nr_par, uint8_t stride, + int8_t log2modulo); +static void map20indexto34(int8_t *index, uint8_t bins); +#ifdef PS_LOW_POWER +static void map34indexto20(int8_t *index, uint8_t bins); +#endif +static void ps_data_decode(ps_info *ps); +static void ps_decorrelate(ps_info *ps, + qmf_t X_left[MAX_NTSRPS][64], + qmf_t X_right[MAX_NTSRPS][64], + qmf_t X_hybrid_left[32][32], + qmf_t X_hybrid_right[32][32]); +static void ps_mix_phase(ps_info *ps, + qmf_t X_left[MAX_NTSRPS][64], + qmf_t X_right[MAX_NTSRPS][64], + qmf_t X_hybrid_left[32][32], + qmf_t X_hybrid_right[32][32]); + +/* */ + + +static void hybrid_init(hyb_info *hyb) +{ + hyb->resolution34[0] = 12; + hyb->resolution34[1] = 8; + hyb->resolution34[2] = 4; + hyb->resolution34[3] = 4; + hyb->resolution34[4] = 4; + + hyb->resolution20[0] = 8; + hyb->resolution20[1] = 2; + hyb->resolution20[2] = 2; + + hyb->frame_len = 32; + + memset(hyb->work , 0, sizeof(hyb->work)); + memset(hyb->buffer, 0, sizeof(hyb->buffer)); + memset(hyb->temp , 0, sizeof(hyb->temp)); +} + +/* real filter, size 2 */ +static void channel_filter2(hyb_info *hyb, uint8_t frame_len, const real_t *filter, + qmf_t *buffer, qmf_t X_hybrid[32][12]) +{ + uint8_t i; + + (void)hyb; + for (i = 0; i < frame_len; i++) + { + real_t r0 = MUL_F(filter[0],(QMF_RE(buffer[0+i]) + QMF_RE(buffer[12+i]))); + real_t r1 = MUL_F(filter[1],(QMF_RE(buffer[1+i]) + QMF_RE(buffer[11+i]))); + real_t r2 = MUL_F(filter[2],(QMF_RE(buffer[2+i]) + QMF_RE(buffer[10+i]))); + real_t r3 = MUL_F(filter[3],(QMF_RE(buffer[3+i]) + QMF_RE(buffer[9+i]))); + real_t r4 = MUL_F(filter[4],(QMF_RE(buffer[4+i]) + QMF_RE(buffer[8+i]))); + real_t r5 = MUL_F(filter[5],(QMF_RE(buffer[5+i]) + QMF_RE(buffer[7+i]))); + real_t r6 = MUL_F(filter[6],QMF_RE(buffer[6+i])); + real_t i0 = MUL_F(filter[0],(QMF_IM(buffer[0+i]) + QMF_IM(buffer[12+i]))); + real_t i1 = MUL_F(filter[1],(QMF_IM(buffer[1+i]) + QMF_IM(buffer[11+i]))); + real_t i2 = MUL_F(filter[2],(QMF_IM(buffer[2+i]) + QMF_IM(buffer[10+i]))); + real_t i3 = MUL_F(filter[3],(QMF_IM(buffer[3+i]) + QMF_IM(buffer[9+i]))); + real_t i4 = MUL_F(filter[4],(QMF_IM(buffer[4+i]) + QMF_IM(buffer[8+i]))); + real_t i5 = MUL_F(filter[5],(QMF_IM(buffer[5+i]) + QMF_IM(buffer[7+i]))); + real_t i6 = MUL_F(filter[6],QMF_IM(buffer[6+i])); + + /* q = 0 */ + QMF_RE(X_hybrid[i][0]) = r0 + r1 + r2 + r3 + r4 + r5 + r6; + QMF_IM(X_hybrid[i][0]) = i0 + i1 + i2 + i3 + i4 + i5 + i6; + + /* q = 1 */ + QMF_RE(X_hybrid[i][1]) = r0 - r1 + r2 - r3 + r4 - r5 + r6; + QMF_IM(X_hybrid[i][1]) = i0 - i1 + i2 - i3 + i4 - i5 + i6; + } +} + +/* complex filter, size 4 */ +static void channel_filter4(hyb_info *hyb, uint8_t frame_len, const real_t *filter, + qmf_t *buffer, qmf_t X_hybrid[32][12]) +{ + uint8_t i; + real_t input_re1[2], input_re2[2], input_im1[2], input_im2[2]; + + (void)hyb; + for (i = 0; i < frame_len; i++) + { + input_re1[0] = -MUL_F(filter[2], (QMF_RE(buffer[i+2]) + QMF_RE(buffer[i+10]))) + + MUL_F(filter[6], QMF_RE(buffer[i+6])); + input_re1[1] = MUL_F(FRAC_CONST(-0.70710678118655), + (MUL_F(filter[1], (QMF_RE(buffer[i+1]) + QMF_RE(buffer[i+11]))) + + MUL_F(filter[3], (QMF_RE(buffer[i+3]) + QMF_RE(buffer[i+9]))) - + MUL_F(filter[5], (QMF_RE(buffer[i+5]) + QMF_RE(buffer[i+7]))))); + + input_im1[0] = MUL_F(filter[0], (QMF_IM(buffer[i+0]) - QMF_IM(buffer[i+12]))) - + MUL_F(filter[4], (QMF_IM(buffer[i+4]) - QMF_IM(buffer[i+8]))); + input_im1[1] = MUL_F(FRAC_CONST(0.70710678118655), + (MUL_F(filter[1], (QMF_IM(buffer[i+1]) - QMF_IM(buffer[i+11]))) - + MUL_F(filter[3], (QMF_IM(buffer[i+3]) - QMF_IM(buffer[i+9]))) - + MUL_F(filter[5], (QMF_IM(buffer[i+5]) - QMF_IM(buffer[i+7]))))); + + input_re2[0] = MUL_F(filter[0], (QMF_RE(buffer[i+0]) - QMF_RE(buffer[i+12]))) - + MUL_F(filter[4], (QMF_RE(buffer[i+4]) - QMF_RE(buffer[i+8]))); + input_re2[1] = MUL_F(FRAC_CONST(0.70710678118655), + (MUL_F(filter[1], (QMF_RE(buffer[i+1]) - QMF_RE(buffer[i+11]))) - + MUL_F(filter[3], (QMF_RE(buffer[i+3]) - QMF_RE(buffer[i+9]))) - + MUL_F(filter[5], (QMF_RE(buffer[i+5]) - QMF_RE(buffer[i+7]))))); + + input_im2[0] = -MUL_F(filter[2], (QMF_IM(buffer[i+2]) + QMF_IM(buffer[i+10]))) + + MUL_F(filter[6], QMF_IM(buffer[i+6])); + input_im2[1] = MUL_F(FRAC_CONST(-0.70710678118655), + (MUL_F(filter[1], (QMF_IM(buffer[i+1]) + QMF_IM(buffer[i+11]))) + + MUL_F(filter[3], (QMF_IM(buffer[i+3]) + QMF_IM(buffer[i+9]))) - + MUL_F(filter[5], (QMF_IM(buffer[i+5]) + QMF_IM(buffer[i+7]))))); + + /* q == 0 */ + QMF_RE(X_hybrid[i][0]) = input_re1[0] + input_re1[1] + input_im1[0] + input_im1[1]; + QMF_IM(X_hybrid[i][0]) = -input_re2[0] - input_re2[1] + input_im2[0] + input_im2[1]; + + /* q == 1 */ + QMF_RE(X_hybrid[i][1]) = input_re1[0] - input_re1[1] - input_im1[0] + input_im1[1]; + QMF_IM(X_hybrid[i][1]) = input_re2[0] - input_re2[1] + input_im2[0] - input_im2[1]; + + /* q == 2 */ + QMF_RE(X_hybrid[i][2]) = input_re1[0] - input_re1[1] + input_im1[0] - input_im1[1]; + QMF_IM(X_hybrid[i][2]) = -input_re2[0] + input_re2[1] + input_im2[0] - input_im2[1]; + + /* q == 3 */ + QMF_RE(X_hybrid[i][3]) = input_re1[0] + input_re1[1] - input_im1[0] - input_im1[1]; + QMF_IM(X_hybrid[i][3]) = input_re2[0] + input_re2[1] + input_im2[0] + input_im2[1]; + } +} + +static INLINE void DCT3_4_unscaled(real_t *y, real_t *x) +{ + real_t f0, f1, f2, f3, f4, f5, f6, f7, f8; + + f0 = MUL_F(x[2], FRAC_CONST(0.7071067811865476)); + f1 = x[0] - f0; + f2 = x[0] + f0; + f3 = x[1] + x[3]; + f4 = MUL_C(x[1], COEF_CONST(1.3065629648763766)); + f5 = MUL_F(f3, FRAC_CONST(-0.9238795325112866)); + f6 = MUL_F(x[3], FRAC_CONST(-0.5411961001461967)); + f7 = f4 + f5; + f8 = f6 - f5; + y[3] = f2 - f8; + y[0] = f2 + f8; + y[2] = f1 - f7; + y[1] = f1 + f7; +} + +/* complex filter, size 8 */ +static void channel_filter8(hyb_info *hyb, uint8_t frame_len, const real_t *filter, + qmf_t *buffer, qmf_t X_hybrid[32][12]) +{ + uint8_t i, n; + real_t input_re1[4], input_re2[4], input_im1[4], input_im2[4]; + real_t x[4]; + + (void)hyb; + for (i = 0; i < frame_len; i++) + { + input_re1[0] = MUL_F(filter[6],QMF_RE(buffer[6+i])); + input_re1[1] = MUL_F(filter[5],(QMF_RE(buffer[5+i]) + QMF_RE(buffer[7+i]))); + input_re1[2] = -MUL_F(filter[0],(QMF_RE(buffer[0+i]) + QMF_RE(buffer[12+i]))) + MUL_F(filter[4],(QMF_RE(buffer[4+i]) + QMF_RE(buffer[8+i]))); + input_re1[3] = -MUL_F(filter[1],(QMF_RE(buffer[1+i]) + QMF_RE(buffer[11+i]))) + MUL_F(filter[3],(QMF_RE(buffer[3+i]) + QMF_RE(buffer[9+i]))); + + input_im1[0] = MUL_F(filter[5],(QMF_IM(buffer[7+i]) - QMF_IM(buffer[5+i]))); + input_im1[1] = MUL_F(filter[0],(QMF_IM(buffer[12+i]) - QMF_IM(buffer[0+i]))) + MUL_F(filter[4],(QMF_IM(buffer[8+i]) - QMF_IM(buffer[4+i]))); + input_im1[2] = MUL_F(filter[1],(QMF_IM(buffer[11+i]) - QMF_IM(buffer[1+i]))) + MUL_F(filter[3],(QMF_IM(buffer[9+i]) - QMF_IM(buffer[3+i]))); + input_im1[3] = MUL_F(filter[2],(QMF_IM(buffer[10+i]) - QMF_IM(buffer[2+i]))); + + for (n = 0; n < 4; n++) + { + x[n] = input_re1[n] - input_im1[3-n]; + } + DCT3_4_unscaled(x, x); + QMF_RE(X_hybrid[i][7]) = x[0]; + QMF_RE(X_hybrid[i][5]) = x[2]; + QMF_RE(X_hybrid[i][3]) = x[3]; + QMF_RE(X_hybrid[i][1]) = x[1]; + + for (n = 0; n < 4; n++) + { + x[n] = input_re1[n] + input_im1[3-n]; + } + DCT3_4_unscaled(x, x); + QMF_RE(X_hybrid[i][6]) = x[1]; + QMF_RE(X_hybrid[i][4]) = x[3]; + QMF_RE(X_hybrid[i][2]) = x[2]; + QMF_RE(X_hybrid[i][0]) = x[0]; + + input_im2[0] = MUL_F(filter[6],QMF_IM(buffer[6+i])); + input_im2[1] = MUL_F(filter[5],(QMF_IM(buffer[5+i]) + QMF_IM(buffer[7+i]))); + input_im2[2] = -MUL_F(filter[0],(QMF_IM(buffer[0+i]) + QMF_IM(buffer[12+i]))) + MUL_F(filter[4],(QMF_IM(buffer[4+i]) + QMF_IM(buffer[8+i]))); + input_im2[3] = -MUL_F(filter[1],(QMF_IM(buffer[1+i]) + QMF_IM(buffer[11+i]))) + MUL_F(filter[3],(QMF_IM(buffer[3+i]) + QMF_IM(buffer[9+i]))); + + input_re2[0] = MUL_F(filter[5],(QMF_RE(buffer[7+i]) - QMF_RE(buffer[5+i]))); + input_re2[1] = MUL_F(filter[0],(QMF_RE(buffer[12+i]) - QMF_RE(buffer[0+i]))) + MUL_F(filter[4],(QMF_RE(buffer[8+i]) - QMF_RE(buffer[4+i]))); + input_re2[2] = MUL_F(filter[1],(QMF_RE(buffer[11+i]) - QMF_RE(buffer[1+i]))) + MUL_F(filter[3],(QMF_RE(buffer[9+i]) - QMF_RE(buffer[3+i]))); + input_re2[3] = MUL_F(filter[2],(QMF_RE(buffer[10+i]) - QMF_RE(buffer[2+i]))); + + for (n = 0; n < 4; n++) + { + x[n] = input_im2[n] + input_re2[3-n]; + } + DCT3_4_unscaled(x, x); + QMF_IM(X_hybrid[i][7]) = x[0]; + QMF_IM(X_hybrid[i][5]) = x[2]; + QMF_IM(X_hybrid[i][3]) = x[3]; + QMF_IM(X_hybrid[i][1]) = x[1]; + + for (n = 0; n < 4; n++) + { + x[n] = input_im2[n] - input_re2[3-n]; + } + DCT3_4_unscaled(x, x); + QMF_IM(X_hybrid[i][6]) = x[1]; + QMF_IM(X_hybrid[i][4]) = x[3]; + QMF_IM(X_hybrid[i][2]) = x[2]; + QMF_IM(X_hybrid[i][0]) = x[0]; + } +} + +static INLINE void DCT3_6_unscaled(real_t *y, real_t *x) +{ + real_t f0, f1, f2, f3, f4, f5, f6, f7; + + f0 = MUL_F(x[3], FRAC_CONST(0.70710678118655)); + f1 = x[0] + f0; + f2 = x[0] - f0; + f3 = MUL_F((x[1] - x[5]), FRAC_CONST(0.70710678118655)); + f4 = MUL_F(x[2], FRAC_CONST(0.86602540378444)) + MUL_F(x[4], FRAC_CONST(0.5)); + f5 = f4 - x[4]; + f6 = MUL_F(x[1], FRAC_CONST(0.96592582628907)) + MUL_F(x[5], FRAC_CONST(0.25881904510252)); + f7 = f6 - f3; + y[0] = f1 + f6 + f4; + y[1] = f2 + f3 - x[4]; + y[2] = f7 + f2 - f5; + y[3] = f1 - f7 - f5; + y[4] = f1 - f3 - x[4]; + y[5] = f2 - f6 + f4; +} + +/* complex filter, size 12 */ +static void channel_filter12(hyb_info *hyb, uint8_t frame_len, const real_t *filter, + qmf_t *buffer, qmf_t X_hybrid[32][12]) +{ + uint8_t i, n; + real_t input_re1[6], input_re2[6], input_im1[6], input_im2[6]; + real_t out_re1[6], out_re2[6], out_im1[6], out_im2[6]; + + (void)hyb; + for (i = 0; i < frame_len; i++) + { + for (n = 0; n < 6; n++) + { + if (n == 0) + { + input_re1[0] = MUL_F(QMF_RE(buffer[6+i]), filter[6]); + input_re2[0] = MUL_F(QMF_IM(buffer[6+i]), filter[6]); + } else { + input_re1[6-n] = MUL_F((QMF_RE(buffer[n+i]) + QMF_RE(buffer[12-n+i])), filter[n]); + input_re2[6-n] = MUL_F((QMF_IM(buffer[n+i]) + QMF_IM(buffer[12-n+i])), filter[n]); + } + input_im2[n] = MUL_F((QMF_RE(buffer[n+i]) - QMF_RE(buffer[12-n+i])), filter[n]); + input_im1[n] = MUL_F((QMF_IM(buffer[n+i]) - QMF_IM(buffer[12-n+i])), filter[n]); + } + + DCT3_6_unscaled(out_re1, input_re1); + DCT3_6_unscaled(out_re2, input_re2); + + DCT3_6_unscaled(out_im1, input_im1); + DCT3_6_unscaled(out_im2, input_im2); + + for (n = 0; n < 6; n += 2) + { + QMF_RE(X_hybrid[i][n]) = out_re1[n] - out_im1[n]; + QMF_IM(X_hybrid[i][n]) = out_re2[n] + out_im2[n]; + QMF_RE(X_hybrid[i][n+1]) = out_re1[n+1] + out_im1[n+1]; + QMF_IM(X_hybrid[i][n+1]) = out_re2[n+1] - out_im2[n+1]; + + QMF_RE(X_hybrid[i][10-n]) = out_re1[n+1] - out_im1[n+1]; + QMF_IM(X_hybrid[i][10-n]) = out_re2[n+1] + out_im2[n+1]; + QMF_RE(X_hybrid[i][11-n]) = out_re1[n] + out_im1[n]; + QMF_IM(X_hybrid[i][11-n]) = out_re2[n] - out_im2[n]; + } + } +} + +/* Hybrid analysis: further split up QMF subbands + * to improve frequency resolution + */ +static void hybrid_analysis(hyb_info *hyb, qmf_t X[32][64], qmf_t X_hybrid[32][32], + uint8_t use34) +{ + uint8_t k, n, band; + uint8_t offset = 0; + uint8_t qmf_bands = (use34) ? 5 : 3; + uint8_t *resolution = (use34) ? hyb->resolution34 : hyb->resolution20; + + for (band = 0; band < qmf_bands; band++) + { + /* build working buffer */ + memcpy(hyb->work, hyb->buffer[band], 12 * sizeof(qmf_t)); + + /* add new samples */ + for (n = 0; n < hyb->frame_len; n++) + { + QMF_RE(hyb->work[12 + n]) = QMF_RE(X[n + 6 /*delay*/][band]); + QMF_IM(hyb->work[12 + n]) = QMF_IM(X[n + 6 /*delay*/][band]); + } + + /* store samples */ + memcpy(hyb->buffer[band], hyb->work + hyb->frame_len, 12 * sizeof(qmf_t)); + + + switch(resolution[band]) + { + case 2: + /* Type B real filter, Q[p] = 2 */ + channel_filter2(hyb, hyb->frame_len, p2_13_20, hyb->work, hyb->temp); + break; + case 4: + /* Type A complex filter, Q[p] = 4 */ + channel_filter4(hyb, hyb->frame_len, p4_13_34, hyb->work, hyb->temp); + break; + case 8: + /* Type A complex filter, Q[p] = 8 */ + channel_filter8(hyb, hyb->frame_len, (use34) ? p8_13_34 : p8_13_20, + hyb->work, hyb->temp); + break; + case 12: + /* Type A complex filter, Q[p] = 12 */ + channel_filter12(hyb, hyb->frame_len, p12_13_34, hyb->work, hyb->temp); + break; + } + + for (n = 0; n < hyb->frame_len; n++) + { + for (k = 0; k < resolution[band]; k++) + { + QMF_RE(X_hybrid[n][offset + k]) = QMF_RE(hyb->temp[n][k]); + QMF_IM(X_hybrid[n][offset + k]) = QMF_IM(hyb->temp[n][k]); + } + } + offset += resolution[band]; + } + + /* group hybrid channels */ + if (!use34) + { + for (n = 0; n < 32 /*30?*/; n++) + { + QMF_RE(X_hybrid[n][3]) += QMF_RE(X_hybrid[n][4]); + QMF_IM(X_hybrid[n][3]) += QMF_IM(X_hybrid[n][4]); + QMF_RE(X_hybrid[n][4]) = 0; + QMF_IM(X_hybrid[n][4]) = 0; + + QMF_RE(X_hybrid[n][2]) += QMF_RE(X_hybrid[n][5]); + QMF_IM(X_hybrid[n][2]) += QMF_IM(X_hybrid[n][5]); + QMF_RE(X_hybrid[n][5]) = 0; + QMF_IM(X_hybrid[n][5]) = 0; + } + } +} + +static void hybrid_synthesis(hyb_info *hyb, qmf_t X[32][64], qmf_t X_hybrid[32][32], + uint8_t use34) +{ + uint8_t k, n, band; + uint8_t offset = 0; + uint8_t qmf_bands = (use34) ? 5 : 3; + uint8_t *resolution = (use34) ? hyb->resolution34 : hyb->resolution20; + + for(band = 0; band < qmf_bands; band++) + { + for (n = 0; n < hyb->frame_len; n++) + { + QMF_RE(X[n][band]) = 0; + QMF_IM(X[n][band]) = 0; + + for (k = 0; k < resolution[band]; k++) + { + QMF_RE(X[n][band]) += QMF_RE(X_hybrid[n][offset + k]); + QMF_IM(X[n][band]) += QMF_IM(X_hybrid[n][offset + k]); + } + } + offset += resolution[band]; + } +} + +/* limits the value i to the range [min,max] */ +static int8_t delta_clip(int8_t i, int8_t min, int8_t max) +{ + if (i < min) + return min; + else if (i > max) + return max; + else + return i; +} + +//int iid = 0; + +/* delta decode array */ +static void delta_decode(uint8_t enable, int8_t *index, int8_t *index_prev, + uint8_t dt_flag, uint8_t nr_par, uint8_t stride, + int8_t min_index, int8_t max_index) +{ + int8_t i; + + if (enable == 1) + { + if (dt_flag == 0) + { + /* delta coded in frequency direction */ + index[0] = 0 + index[0]; + index[0] = delta_clip(index[0], min_index, max_index); + + for (i = 1; i < nr_par; i++) + { + index[i] = index[i-1] + index[i]; + index[i] = delta_clip(index[i], min_index, max_index); + } + } else { + /* delta coded in time direction */ + for (i = 0; i < nr_par; i++) + { + //int8_t tmp2; + //int8_t tmp = index[i]; + + //printf("%d %d\n", index_prev[i*stride], index[i]); + //printf("%d\n", index[i]); + + index[i] = index_prev[i*stride] + index[i]; + //tmp2 = index[i]; + index[i] = delta_clip(index[i], min_index, max_index); + + //if (iid) + //{ + // if (index[i] == 7) + // { + // printf("%d %d %d\n", index_prev[i*stride], tmp, tmp2); + // } + //} + } + } + } else { + /* set indices to zero */ + for (i = 0; i < nr_par; i++) + { + index[i] = 0; + } + } + + /* coarse */ + if (stride == 2) + { + for (i = (nr_par<<1)-1; i > 0; i--) + { + index[i] = index[i>>1]; + } + } +} + +/* delta modulo decode array */ +/* in: log2 value of the modulo value to allow using AND instead of MOD */ +static void delta_modulo_decode(uint8_t enable, int8_t *index, int8_t *index_prev, + uint8_t dt_flag, uint8_t nr_par, uint8_t stride, + int8_t log2modulo) +{ + int8_t i; + + if (enable == 1) + { + if (dt_flag == 0) + { + /* delta coded in frequency direction */ + index[0] = 0 + index[0]; + index[0] &= log2modulo; + + for (i = 1; i < nr_par; i++) + { + index[i] = index[i-1] + index[i]; + index[i] &= log2modulo; + } + } else { + /* delta coded in time direction */ + for (i = 0; i < nr_par; i++) + { + index[i] = index_prev[i*stride] + index[i]; + index[i] &= log2modulo; + } + } + } else { + /* set indices to zero */ + for (i = 0; i < nr_par; i++) + { + index[i] = 0; + } + } + + /* coarse */ + if (stride == 2) + { + index[0] = 0; + for (i = (nr_par<<1)-1; i > 0; i--) + { + index[i] = index[i>>1]; + } + } +} + +#ifdef PS_LOW_POWER +static void map34indexto20(int8_t *index, uint8_t bins) +{ + index[0] = (2*index[0]+index[1])/3; + index[1] = (index[1]+2*index[2])/3; + index[2] = (2*index[3]+index[4])/3; + index[3] = (index[4]+2*index[5])/3; + index[4] = (index[6]+index[7])/2; + index[5] = (index[8]+index[9])/2; + index[6] = index[10]; + index[7] = index[11]; + index[8] = (index[12]+index[13])/2; + index[9] = (index[14]+index[15])/2; + index[10] = index[16]; + + if (bins == 34) + { + index[11] = index[17]; + index[12] = index[18]; + index[13] = index[19]; + index[14] = (index[20]+index[21])/2; + index[15] = (index[22]+index[23])/2; + index[16] = (index[24]+index[25])/2; + index[17] = (index[26]+index[27])/2; + index[18] = (index[28]+index[29]+index[30]+index[31])/4; + index[19] = (index[32]+index[33])/2; + } +} +#endif + +static void map20indexto34(int8_t *index, uint8_t bins) +{ + index[0] = index[0]; + index[1] = (index[0] + index[1])/2; + index[2] = index[1]; + index[3] = index[2]; + index[4] = (index[2] + index[3])/2; + index[5] = index[3]; + index[6] = index[4]; + index[7] = index[4]; + index[8] = index[5]; + index[9] = index[5]; + index[10] = index[6]; + index[11] = index[7]; + index[12] = index[8]; + index[13] = index[8]; + index[14] = index[9]; + index[15] = index[9]; + index[16] = index[10]; + + if (bins == 34) + { + index[17] = index[11]; + index[18] = index[12]; + index[19] = index[13]; + index[20] = index[14]; + index[21] = index[14]; + index[22] = index[15]; + index[23] = index[15]; + index[24] = index[16]; + index[25] = index[16]; + index[26] = index[17]; + index[27] = index[17]; + index[28] = index[18]; + index[29] = index[18]; + index[30] = index[18]; + index[31] = index[18]; + index[32] = index[19]; + index[33] = index[19]; + } +} + +/* parse the bitstream data decoded in ps_data() */ +static void ps_data_decode(ps_info *ps) +{ + uint8_t env, bin; + + /* ps data not available, use data from previous frame */ + if (ps->ps_data_available == 0) + { + ps->num_env = 0; + } + + for (env = 0; env < ps->num_env; env++) + { + int8_t *iid_index_prev; + int8_t *icc_index_prev; + int8_t *ipd_index_prev; + int8_t *opd_index_prev; + + int8_t num_iid_steps = (ps->iid_mode < 3) ? 7 : 15 /*fine quant*/; + + if (env == 0) + { + /* take last envelope from previous frame */ + iid_index_prev = ps->iid_index_prev; + icc_index_prev = ps->icc_index_prev; + ipd_index_prev = ps->ipd_index_prev; + opd_index_prev = ps->opd_index_prev; + } else { + /* take index values from previous envelope */ + iid_index_prev = ps->iid_index[env - 1]; + icc_index_prev = ps->icc_index[env - 1]; + ipd_index_prev = ps->ipd_index[env - 1]; + opd_index_prev = ps->opd_index[env - 1]; + } + +// iid = 1; + /* delta decode iid parameters */ + delta_decode(ps->enable_iid, ps->iid_index[env], iid_index_prev, + ps->iid_dt[env], ps->nr_iid_par, + (ps->iid_mode == 0 || ps->iid_mode == 3) ? 2 : 1, + -num_iid_steps, num_iid_steps); +// iid = 0; + + /* delta decode icc parameters */ + delta_decode(ps->enable_icc, ps->icc_index[env], icc_index_prev, + ps->icc_dt[env], ps->nr_icc_par, + (ps->icc_mode == 0 || ps->icc_mode == 3) ? 2 : 1, + 0, 7); + + /* delta modulo decode ipd parameters */ + delta_modulo_decode(ps->enable_ipdopd, ps->ipd_index[env], ipd_index_prev, + ps->ipd_dt[env], ps->nr_ipdopd_par, 1, /*log2(8)*/ 3); + + /* delta modulo decode opd parameters */ + delta_modulo_decode(ps->enable_ipdopd, ps->opd_index[env], opd_index_prev, + ps->opd_dt[env], ps->nr_ipdopd_par, 1, /*log2(8)*/ 3); + } + + /* handle error case */ + if (ps->num_env == 0) + { + /* force to 1 */ + ps->num_env = 1; + + if (ps->enable_iid) + { + for (bin = 0; bin < 34; bin++) + ps->iid_index[0][bin] = ps->iid_index_prev[bin]; + } else { + for (bin = 0; bin < 34; bin++) + ps->iid_index[0][bin] = 0; + } + + if (ps->enable_icc) + { + for (bin = 0; bin < 34; bin++) + ps->icc_index[0][bin] = ps->icc_index_prev[bin]; + } else { + for (bin = 0; bin < 34; bin++) + ps->icc_index[0][bin] = 0; + } + + if (ps->enable_ipdopd) + { + for (bin = 0; bin < 17; bin++) + { + ps->ipd_index[0][bin] = ps->ipd_index_prev[bin]; + ps->opd_index[0][bin] = ps->opd_index_prev[bin]; + } + } else { + for (bin = 0; bin < 17; bin++) + { + ps->ipd_index[0][bin] = 0; + ps->opd_index[0][bin] = 0; + } + } + } + + /* update previous indices */ + for (bin = 0; bin < 34; bin++) + ps->iid_index_prev[bin] = ps->iid_index[ps->num_env-1][bin]; + for (bin = 0; bin < 34; bin++) + ps->icc_index_prev[bin] = ps->icc_index[ps->num_env-1][bin]; + for (bin = 0; bin < 17; bin++) + { + ps->ipd_index_prev[bin] = ps->ipd_index[ps->num_env-1][bin]; + ps->opd_index_prev[bin] = ps->opd_index[ps->num_env-1][bin]; + } + + ps->ps_data_available = 0; + + if (ps->frame_class == 0) + { + ps->border_position[0] = 0; + for (env = 1; env < ps->num_env; env++) + { + ps->border_position[env] = (env * 32 /* 30 for 960? */) / ps->num_env; + } + ps->border_position[ps->num_env] = 32 /* 30 for 960? */; + } else { + ps->border_position[0] = 0; + + if (ps->border_position[ps->num_env] < 32 /* 30 for 960? */) + { + ps->num_env++; + ps->border_position[ps->num_env] = 32 /* 30 for 960? */; + for (bin = 0; bin < 34; bin++) + { + ps->iid_index[ps->num_env][bin] = ps->iid_index[ps->num_env-1][bin]; + ps->icc_index[ps->num_env][bin] = ps->icc_index[ps->num_env-1][bin]; + } + for (bin = 0; bin < 17; bin++) + { + ps->ipd_index[ps->num_env][bin] = ps->ipd_index[ps->num_env-1][bin]; + ps->opd_index[ps->num_env][bin] = ps->opd_index[ps->num_env-1][bin]; + } + } + + for (env = 1; env < ps->num_env; env++) + { + int8_t thr = 32 /* 30 for 960? */ - (ps->num_env - env); + + if (ps->border_position[env] > thr) + { + ps->border_position[env] = thr; + } else { + thr = ps->border_position[env-1]+1; + if (ps->border_position[env] < thr) + { + ps->border_position[env] = thr; + } + } + } + } + + /* make sure that the indices of all parameters can be mapped + * to the same hybrid synthesis filterbank + */ +#ifdef PS_LOW_POWER + for (env = 0; env < ps->num_env; env++) + { + if (ps->iid_mode == 2 || ps->iid_mode == 5) + map34indexto20(ps->iid_index[env], 34); + if (ps->icc_mode == 2 || ps->icc_mode == 5) + map34indexto20(ps->icc_index[env], 34); + + /* disable ipd/opd */ + for (bin = 0; bin < 17; bin++) + { + ps->aaIpdIndex[env][bin] = 0; + ps->aaOpdIndex[env][bin] = 0; + } + } +#else + if (ps->use34hybrid_bands) + { + for (env = 0; env < ps->num_env; env++) + { + if (ps->iid_mode != 2 && ps->iid_mode != 5) + map20indexto34(ps->iid_index[env], 34); + if (ps->icc_mode != 2 && ps->icc_mode != 5) + map20indexto34(ps->icc_index[env], 34); + if (ps->ipd_mode != 2 && ps->ipd_mode != 5) + { + map20indexto34(ps->ipd_index[env], 17); + map20indexto34(ps->opd_index[env], 17); + } + } + } +#endif + +#if 0 + for (env = 0; env < ps->num_env; env++) + { + printf("iid[env:%d]:", env); + for (bin = 0; bin < 34; bin++) + { + printf(" %d", ps->iid_index[env][bin]); + } + printf("\n"); + } + for (env = 0; env < ps->num_env; env++) + { + printf("icc[env:%d]:", env); + for (bin = 0; bin < 34; bin++) + { + printf(" %d", ps->icc_index[env][bin]); + } + printf("\n"); + } + for (env = 0; env < ps->num_env; env++) + { + printf("ipd[env:%d]:", env); + for (bin = 0; bin < 17; bin++) + { + printf(" %d", ps->ipd_index[env][bin]); + } + printf("\n"); + } + for (env = 0; env < ps->num_env; env++) + { + printf("opd[env:%d]:", env); + for (bin = 0; bin < 17; bin++) + { + printf(" %d", ps->opd_index[env][bin]); + } + printf("\n"); + } + printf("\n"); +#endif +} + +/* decorrelate the mono signal using an allpass filter */ +static void ps_decorrelate(ps_info *ps, + qmf_t X_left[MAX_NTSRPS][64], + qmf_t X_right[MAX_NTSRPS][64], + qmf_t X_hybrid_left[32][32], + qmf_t X_hybrid_right[32][32]) +{ + uint8_t gr, n, m, bk; + uint8_t temp_delay = 0; + uint8_t sb, maxsb; + const complex_t *Phi_Fract_SubQmf; + uint8_t temp_delay_ser[NO_ALLPASS_LINKS]; + real_t P_SmoothPeakDecayDiffNrg, nrg; + static real_t P[32][34]; + static real_t G_TransientRatio[32][34]; + complex_t inputLeft; + + memset(&G_TransientRatio, 0, sizeof(G_TransientRatio)); + + /* chose hybrid filterbank: 20 or 34 band case */ + if (ps->use34hybrid_bands) + { + Phi_Fract_SubQmf = Phi_Fract_SubQmf34; + } else{ + Phi_Fract_SubQmf = Phi_Fract_SubQmf20; + } + + /* clear the energy values */ + for (n = 0; n < 32; n++) + { + for (bk = 0; bk < 34; bk++) + { + P[n][bk] = 0; + } + } + + /* calculate the energy in each parameter band b(k) */ + for (gr = 0; gr < ps->num_groups; gr++) + { + /* select the parameter index b(k) to which this group belongs */ + bk = (~NEGATE_IPD_MASK) & ps->map_group2bk[gr]; + + /* select the upper subband border for this group */ + maxsb = (gr < ps->num_hybrid_groups) ? ps->group_border[gr]+1 : ps->group_border[gr+1]; + + for (sb = ps->group_border[gr]; sb < maxsb; sb++) + { + for (n = ps->border_position[0]; n < ps->border_position[ps->num_env]; n++) + { +#ifdef FIXED_POINT + uint32_t in_re, in_im; +#endif + + /* input from hybrid subbands or QMF subbands */ + if (gr < ps->num_hybrid_groups) + { + RE(inputLeft) = QMF_RE(X_hybrid_left[n][sb]); + IM(inputLeft) = QMF_IM(X_hybrid_left[n][sb]); + } else { + RE(inputLeft) = QMF_RE(X_left[n][sb]); + IM(inputLeft) = QMF_IM(X_left[n][sb]); + } + + /* accumulate energy */ +#ifdef FIXED_POINT + /* NOTE: all input is scaled by 2^(-5) because of fixed point QMF + * meaning that P will be scaled by 2^(-10) compared to floating point version + */ + in_re = ((abs(RE(inputLeft))+(1<<(REAL_BITS-1)))>>REAL_BITS); + in_im = ((abs(IM(inputLeft))+(1<<(REAL_BITS-1)))>>REAL_BITS); + P[n][bk] += in_re*in_re + in_im*in_im; +#else + P[n][bk] += MUL_R(RE(inputLeft),RE(inputLeft)) + MUL_R(IM(inputLeft),IM(inputLeft)); +#endif + } + } + } + +#if 0 + for (n = 0; n < 32; n++) + { + for (bk = 0; bk < 34; bk++) + { +#ifdef FIXED_POINT + printf("%d %d: %d\n", n, bk, P[n][bk] /*/(float)REAL_PRECISION*/); +#else + printf("%d %d: %f\n", n, bk, P[n][bk]/1024.0); +#endif + } + } +#endif + + /* calculate transient reduction ratio for each parameter band b(k) */ + for (bk = 0; bk < ps->nr_par_bands; bk++) + { + for (n = ps->border_position[0]; n < ps->border_position[ps->num_env]; n++) + { + const real_t gamma = COEF_CONST(1.5); + + ps->P_PeakDecayNrg[bk] = MUL_F(ps->P_PeakDecayNrg[bk], ps->alpha_decay); + if (ps->P_PeakDecayNrg[bk] < P[n][bk]) + ps->P_PeakDecayNrg[bk] = P[n][bk]; + + /* apply smoothing filter to peak decay energy */ + P_SmoothPeakDecayDiffNrg = ps->P_SmoothPeakDecayDiffNrg_prev[bk]; + P_SmoothPeakDecayDiffNrg += MUL_F((ps->P_PeakDecayNrg[bk] - P[n][bk] - ps->P_SmoothPeakDecayDiffNrg_prev[bk]), ps->alpha_smooth); + ps->P_SmoothPeakDecayDiffNrg_prev[bk] = P_SmoothPeakDecayDiffNrg; + + /* apply smoothing filter to energy */ + nrg = ps->P_prev[bk]; + nrg += MUL_F((P[n][bk] - ps->P_prev[bk]), ps->alpha_smooth); + ps->P_prev[bk] = nrg; + + /* calculate transient ratio */ + if (MUL_C(P_SmoothPeakDecayDiffNrg, gamma) <= nrg) + { + G_TransientRatio[n][bk] = REAL_CONST(1.0); + } else { + G_TransientRatio[n][bk] = DIV_R(nrg, (MUL_C(P_SmoothPeakDecayDiffNrg, gamma))); + } + } + } + +#if 0 + for (n = 0; n < 32; n++) + { + for (bk = 0; bk < 34; bk++) + { +#ifdef FIXED_POINT + printf("%d %d: %f\n", n, bk, G_TransientRatio[n][bk]/(float)REAL_PRECISION); +#else + printf("%d %d: %f\n", n, bk, G_TransientRatio[n][bk]); +#endif + } + } +#endif + + /* apply stereo decorrelation filter to the signal */ + for (gr = 0; gr < ps->num_groups; gr++) + { + if (gr < ps->num_hybrid_groups) + maxsb = ps->group_border[gr] + 1; + else + maxsb = ps->group_border[gr + 1]; + + /* QMF channel */ + for (sb = ps->group_border[gr]; sb < maxsb; sb++) + { + real_t g_DecaySlope; + real_t g_DecaySlope_filt[NO_ALLPASS_LINKS]; + + /* g_DecaySlope: [0..1] */ + if (gr < ps->num_hybrid_groups || sb <= ps->decay_cutoff) + { + g_DecaySlope = FRAC_CONST(1.0); + } else { + int8_t decay = ps->decay_cutoff - sb; + if (decay <= -20 /* -1/DECAY_SLOPE */) + { + g_DecaySlope = 0; + } else { + /* decay(int)*decay_slope(frac) = g_DecaySlope(frac) */ + g_DecaySlope = FRAC_CONST(1.0) + DECAY_SLOPE * decay; + } + } + + /* calculate g_DecaySlope_filt for every m multiplied by filter_a[m] */ + for (m = 0; m < NO_ALLPASS_LINKS; m++) + { + g_DecaySlope_filt[m] = MUL_F(g_DecaySlope, filter_a[m]); + } + + + /* set delay indices */ + temp_delay = ps->saved_delay; + for (n = 0; n < NO_ALLPASS_LINKS; n++) + temp_delay_ser[n] = ps->delay_buf_index_ser[n]; + + for (n = ps->border_position[0]; n < ps->border_position[ps->num_env]; n++) + { + complex_t tmp, tmp0, R0; + + if (gr < ps->num_hybrid_groups) + { + /* hybrid filterbank input */ + RE(inputLeft) = QMF_RE(X_hybrid_left[n][sb]); + IM(inputLeft) = QMF_IM(X_hybrid_left[n][sb]); + } else { + /* QMF filterbank input */ + RE(inputLeft) = QMF_RE(X_left[n][sb]); + IM(inputLeft) = QMF_IM(X_left[n][sb]); + } + + if (sb > ps->nr_allpass_bands && gr >= ps->num_hybrid_groups) + { + /* delay */ + + /* never hybrid subbands here, always QMF subbands */ + RE(tmp) = RE(ps->delay_Qmf[ps->delay_buf_index_delay[sb]][sb]); + IM(tmp) = IM(ps->delay_Qmf[ps->delay_buf_index_delay[sb]][sb]); + RE(R0) = RE(tmp); + IM(R0) = IM(tmp); + RE(ps->delay_Qmf[ps->delay_buf_index_delay[sb]][sb]) = RE(inputLeft); + IM(ps->delay_Qmf[ps->delay_buf_index_delay[sb]][sb]) = IM(inputLeft); + } else { + /* allpass filter */ + uint8_t m; + complex_t Phi_Fract; + + /* fetch parameters */ + if (gr < ps->num_hybrid_groups) + { + /* select data from the hybrid subbands */ + RE(tmp0) = RE(ps->delay_SubQmf[temp_delay][sb]); + IM(tmp0) = IM(ps->delay_SubQmf[temp_delay][sb]); + + RE(ps->delay_SubQmf[temp_delay][sb]) = RE(inputLeft); + IM(ps->delay_SubQmf[temp_delay][sb]) = IM(inputLeft); + + RE(Phi_Fract) = RE(Phi_Fract_SubQmf[sb]); + IM(Phi_Fract) = IM(Phi_Fract_SubQmf[sb]); + } else { + /* select data from the QMF subbands */ + RE(tmp0) = RE(ps->delay_Qmf[temp_delay][sb]); + IM(tmp0) = IM(ps->delay_Qmf[temp_delay][sb]); + + RE(ps->delay_Qmf[temp_delay][sb]) = RE(inputLeft); + IM(ps->delay_Qmf[temp_delay][sb]) = IM(inputLeft); + + RE(Phi_Fract) = RE(Phi_Fract_Qmf[sb]); + IM(Phi_Fract) = IM(Phi_Fract_Qmf[sb]); + } + + /* z^(-2) * Phi_Fract[k] */ + ComplexMult(&RE(tmp), &IM(tmp), RE(tmp0), IM(tmp0), RE(Phi_Fract), IM(Phi_Fract)); + + RE(R0) = RE(tmp); + IM(R0) = IM(tmp); + for (m = 0; m < NO_ALLPASS_LINKS; m++) + { + complex_t Q_Fract_allpass, tmp2; + + /* fetch parameters */ + if (gr < ps->num_hybrid_groups) + { + /* select data from the hybrid subbands */ + RE(tmp0) = RE(ps->delay_SubQmf_ser[m][temp_delay_ser[m]][sb]); + IM(tmp0) = IM(ps->delay_SubQmf_ser[m][temp_delay_ser[m]][sb]); + + if (ps->use34hybrid_bands) + { + RE(Q_Fract_allpass) = RE(Q_Fract_allpass_SubQmf34[sb][m]); + IM(Q_Fract_allpass) = IM(Q_Fract_allpass_SubQmf34[sb][m]); + } else { + RE(Q_Fract_allpass) = RE(Q_Fract_allpass_SubQmf20[sb][m]); + IM(Q_Fract_allpass) = IM(Q_Fract_allpass_SubQmf20[sb][m]); + } + } else { + /* select data from the QMF subbands */ + RE(tmp0) = RE(ps->delay_Qmf_ser[m][temp_delay_ser[m]][sb]); + IM(tmp0) = IM(ps->delay_Qmf_ser[m][temp_delay_ser[m]][sb]); + + RE(Q_Fract_allpass) = RE(Q_Fract_allpass_Qmf[sb][m]); + IM(Q_Fract_allpass) = IM(Q_Fract_allpass_Qmf[sb][m]); + } + + /* delay by a fraction */ + /* z^(-d(m)) * Q_Fract_allpass[k,m] */ + ComplexMult(&RE(tmp), &IM(tmp), RE(tmp0), IM(tmp0), RE(Q_Fract_allpass), IM(Q_Fract_allpass)); + + /* -a(m) * g_DecaySlope[k] */ + RE(tmp) += -MUL_F(g_DecaySlope_filt[m], RE(R0)); + IM(tmp) += -MUL_F(g_DecaySlope_filt[m], IM(R0)); + + /* -a(m) * g_DecaySlope[k] * Q_Fract_allpass[k,m] * z^(-d(m)) */ + RE(tmp2) = RE(R0) + MUL_F(g_DecaySlope_filt[m], RE(tmp)); + IM(tmp2) = IM(R0) + MUL_F(g_DecaySlope_filt[m], IM(tmp)); + + /* store sample */ + if (gr < ps->num_hybrid_groups) + { + RE(ps->delay_SubQmf_ser[m][temp_delay_ser[m]][sb]) = RE(tmp2); + IM(ps->delay_SubQmf_ser[m][temp_delay_ser[m]][sb]) = IM(tmp2); + } else { + RE(ps->delay_Qmf_ser[m][temp_delay_ser[m]][sb]) = RE(tmp2); + IM(ps->delay_Qmf_ser[m][temp_delay_ser[m]][sb]) = IM(tmp2); + } + + /* store for next iteration (or as output value if last iteration) */ + RE(R0) = RE(tmp); + IM(R0) = IM(tmp); + } + } + + /* select b(k) for reading the transient ratio */ + bk = (~NEGATE_IPD_MASK) & ps->map_group2bk[gr]; + + /* duck if a past transient is found */ + RE(R0) = MUL_R(G_TransientRatio[n][bk], RE(R0)); + IM(R0) = MUL_R(G_TransientRatio[n][bk], IM(R0)); + + if (gr < ps->num_hybrid_groups) + { + /* hybrid */ + QMF_RE(X_hybrid_right[n][sb]) = RE(R0); + QMF_IM(X_hybrid_right[n][sb]) = IM(R0); + } else { + /* QMF */ + QMF_RE(X_right[n][sb]) = RE(R0); + QMF_IM(X_right[n][sb]) = IM(R0); + } + + /* Update delay buffer index */ + if (++temp_delay >= 2) + { + temp_delay = 0; + } + + /* update delay indices */ + if (sb > ps->nr_allpass_bands && gr >= ps->num_hybrid_groups) + { + /* delay_D depends on the samplerate, it can hold the values 14 and 1 */ + if (++ps->delay_buf_index_delay[sb] >= ps->delay_D[sb]) + { + ps->delay_buf_index_delay[sb] = 0; + } + } + + for (m = 0; m < NO_ALLPASS_LINKS; m++) + { + if (++temp_delay_ser[m] >= ps->num_sample_delay_ser[m]) + { + temp_delay_ser[m] = 0; + } + } + } + } + } + + /* update delay indices */ + ps->saved_delay = temp_delay; + for (m = 0; m < NO_ALLPASS_LINKS; m++) + ps->delay_buf_index_ser[m] = temp_delay_ser[m]; +} + +#ifdef FIXED_POINT +#define step(shift) \ + if ((0x40000000l >> shift) + root <= value) \ + { \ + value -= (0x40000000l >> shift) + root; \ + root = (root >> 1) | (0x40000000l >> shift); \ + } else { \ + root = root >> 1; \ + } + +/* fixed point square root approximation */ +static real_t ps_sqrt(real_t value) +{ + real_t root = 0; + + step( 0); step( 2); step( 4); step( 6); + step( 8); step(10); step(12); step(14); + step(16); step(18); step(20); step(22); + step(24); step(26); step(28); step(30); + + if (root < value) + ++root; + + root <<= (REAL_BITS/2); + + return root; +} +#else +#define ps_sqrt(A) sqrt(A) +#endif + +static const real_t ipdopd_cos_tab[] = { + FRAC_CONST(1.000000000000000), + FRAC_CONST(0.707106781186548), + FRAC_CONST(0.000000000000000), + FRAC_CONST(-0.707106781186547), + FRAC_CONST(-1.000000000000000), + FRAC_CONST(-0.707106781186548), + FRAC_CONST(-0.000000000000000), + FRAC_CONST(0.707106781186547), + FRAC_CONST(1.000000000000000) +}; + +static const real_t ipdopd_sin_tab[] = { + FRAC_CONST(0.000000000000000), + FRAC_CONST(0.707106781186547), + FRAC_CONST(1.000000000000000), + FRAC_CONST(0.707106781186548), + FRAC_CONST(0.000000000000000), + FRAC_CONST(-0.707106781186547), + FRAC_CONST(-1.000000000000000), + FRAC_CONST(-0.707106781186548), + FRAC_CONST(-0.000000000000000) +}; + +static void ps_mix_phase(ps_info *ps, + qmf_t X_left[MAX_NTSRPS][64], + qmf_t X_right[MAX_NTSRPS][64], + qmf_t X_hybrid_left[32][32], + qmf_t X_hybrid_right[32][32]) +{ + uint8_t n; + uint8_t gr; + uint8_t bk = 0; + uint8_t sb, maxsb; + uint8_t env; + uint8_t nr_ipdopd_par; + complex_t h11 = {0,0}, h12 = {0,0}, h21 = {0,0}, h22 = {0,0}; + complex_t H11 = {0,0}, H12 = {0,0}, H21 = {0,0}, H22 = {0,0}; + complex_t deltaH11= {0,0}, deltaH12 = {0,0}, deltaH21= {0,0}, deltaH22= {0,0}; + complex_t tempLeft; + complex_t tempRight; + complex_t phaseLeft; + complex_t phaseRight; + real_t L; + const real_t *sf_iid; + uint8_t no_iid_steps; + + if (ps->iid_mode >= 3) + { + no_iid_steps = 15; + sf_iid = sf_iid_fine; + } else { + no_iid_steps = 7; + sf_iid = sf_iid_normal; + } + + if (ps->ipd_mode == 0 || ps->ipd_mode == 3) + { + nr_ipdopd_par = 11; /* resolution */ + } else { + nr_ipdopd_par = ps->nr_ipdopd_par; + } + + for (gr = 0; gr < ps->num_groups; gr++) + { + bk = (~NEGATE_IPD_MASK) & ps->map_group2bk[gr]; + + /* use one channel per group in the subqmf domain */ + maxsb = (gr < ps->num_hybrid_groups) ? ps->group_border[gr] + 1 : ps->group_border[gr + 1]; + + for (env = 0; env < ps->num_env; env++) + { + if (ps->icc_mode < 3) + { + /* type 'A' mixing as described in 8.6.4.6.2.1 */ + real_t c_1, c_2; + real_t cosa, sina; + real_t cosb, sinb; + real_t ab1, ab2; + real_t ab3, ab4; + + /* + c_1 = sqrt(2.0 / (1.0 + pow(10.0, quant_iid[no_iid_steps + iid_index] / 10.0))); + c_2 = sqrt(2.0 / (1.0 + pow(10.0, quant_iid[no_iid_steps - iid_index] / 10.0))); + alpha = 0.5 * acos(quant_rho[icc_index]); + beta = alpha * ( c_1 - c_2 ) / sqrt(2.0); + */ + + //printf("%d\n", ps->iid_index[env][bk]); + + /* calculate the scalefactors c_1 and c_2 from the intensity differences */ + c_1 = sf_iid[no_iid_steps + ps->iid_index[env][bk]]; + c_2 = sf_iid[no_iid_steps - ps->iid_index[env][bk]]; + + /* calculate alpha and beta using the ICC parameters */ + cosa = cos_alphas[ps->icc_index[env][bk]]; + sina = sin_alphas[ps->icc_index[env][bk]]; + + if (ps->iid_mode >= 3) + { + if (ps->iid_index[env][bk] < 0) + { + cosb = cos_betas_fine[-ps->iid_index[env][bk]][ps->icc_index[env][bk]]; + sinb = -sin_betas_fine[-ps->iid_index[env][bk]][ps->icc_index[env][bk]]; + } else { + cosb = cos_betas_fine[ps->iid_index[env][bk]][ps->icc_index[env][bk]]; + sinb = sin_betas_fine[ps->iid_index[env][bk]][ps->icc_index[env][bk]]; + } + } else { + if (ps->iid_index[env][bk] < 0) + { + cosb = cos_betas_normal[-ps->iid_index[env][bk]][ps->icc_index[env][bk]]; + sinb = -sin_betas_normal[-ps->iid_index[env][bk]][ps->icc_index[env][bk]]; + } else { + cosb = cos_betas_normal[ps->iid_index[env][bk]][ps->icc_index[env][bk]]; + sinb = sin_betas_normal[ps->iid_index[env][bk]][ps->icc_index[env][bk]]; + } + } + + ab1 = MUL_C(cosb, cosa); + ab2 = MUL_C(sinb, sina); + ab3 = MUL_C(sinb, cosa); + ab4 = MUL_C(cosb, sina); + + /* h_xy: COEF */ + RE(h11) = MUL_C(c_2, (ab1 - ab2)); + RE(h12) = MUL_C(c_1, (ab1 + ab2)); + RE(h21) = MUL_C(c_2, (ab3 + ab4)); + RE(h22) = MUL_C(c_1, (ab3 - ab4)); + } else { + /* type 'B' mixing as described in 8.6.4.6.2.2 */ + real_t sina, cosa; + real_t cosg, sing; + + /* + real_t c, rho, mu, alpha, gamma; + uint8_t i; + + i = ps->iid_index[env][bk]; + c = (real_t)pow(10.0, ((i)?(((i>0)?1:-1)*quant_iid[((i>0)?i:-i)-1]):0.)/20.0); + rho = quant_rho[ps->icc_index[env][bk]]; + + if (rho == 0.0f && c == 1.) + { + alpha = (real_t)M_PI/4.0f; + rho = 0.05f; + } else { + if (rho <= 0.05f) + { + rho = 0.05f; + } + alpha = 0.5f*(real_t)atan( (2.0f*c*rho) / (c*c-1.0f) ); + + if (alpha < 0.) + { + alpha += (real_t)M_PI/2.0f; + } + if (rho < 0.) + { + alpha += (real_t)M_PI; + } + } + mu = c+1.0f/c; + mu = 1+(4.0f*rho*rho-4.0f)/(mu*mu); + gamma = (real_t)atan(sqrt((1.0f-sqrt(mu))/(1.0f+sqrt(mu)))); + */ + + if (ps->iid_mode >= 3) + { + uint8_t abs_iid = abs(ps->iid_index[env][bk]); + + cosa = sincos_alphas_B_fine[no_iid_steps + ps->iid_index[env][bk]][ps->icc_index[env][bk]]; + sina = sincos_alphas_B_fine[30 - (no_iid_steps + ps->iid_index[env][bk])][ps->icc_index[env][bk]]; + cosg = cos_gammas_fine[abs_iid][ps->icc_index[env][bk]]; + sing = sin_gammas_fine[abs_iid][ps->icc_index[env][bk]]; + } else { + uint8_t abs_iid = abs(ps->iid_index[env][bk]); + + cosa = sincos_alphas_B_normal[no_iid_steps + ps->iid_index[env][bk]][ps->icc_index[env][bk]]; + sina = sincos_alphas_B_normal[14 - (no_iid_steps + ps->iid_index[env][bk])][ps->icc_index[env][bk]]; + cosg = cos_gammas_normal[abs_iid][ps->icc_index[env][bk]]; + sing = sin_gammas_normal[abs_iid][ps->icc_index[env][bk]]; + } + + RE(h11) = MUL_C(COEF_SQRT2, MUL_C(cosa, cosg)); + RE(h12) = MUL_C(COEF_SQRT2, MUL_C(sina, cosg)); + RE(h21) = MUL_C(COEF_SQRT2, MUL_C(-cosa, sing)); + RE(h22) = MUL_C(COEF_SQRT2, MUL_C(sina, sing)); + } + + /* calculate phase rotation parameters H_xy */ + /* note that the imaginary part of these parameters are only calculated when + IPD and OPD are enabled + */ + if ((ps->enable_ipdopd) && (bk < nr_ipdopd_par)) + { + int8_t i; + real_t xxyy, ppqq; + real_t yq, xp, xq, py, tmp; + + /* ringbuffer index */ + i = ps->phase_hist; + + /* previous value */ +#ifdef FIXED_POINT + /* divide by 4, shift right 2 bits */ + RE(tempLeft) = RE(ps->ipd_prev[bk][i]) >> 2; + IM(tempLeft) = IM(ps->ipd_prev[bk][i]) >> 2; + RE(tempRight) = RE(ps->opd_prev[bk][i]) >> 2; + IM(tempRight) = IM(ps->opd_prev[bk][i]) >> 2; +#else + RE(tempLeft) = MUL_F(RE(ps->ipd_prev[bk][i]), FRAC_CONST(0.25)); + IM(tempLeft) = MUL_F(IM(ps->ipd_prev[bk][i]), FRAC_CONST(0.25)); + RE(tempRight) = MUL_F(RE(ps->opd_prev[bk][i]), FRAC_CONST(0.25)); + IM(tempRight) = MUL_F(IM(ps->opd_prev[bk][i]), FRAC_CONST(0.25)); +#endif + + /* save current value */ + RE(ps->ipd_prev[bk][i]) = ipdopd_cos_tab[abs(ps->ipd_index[env][bk])]; + IM(ps->ipd_prev[bk][i]) = ipdopd_sin_tab[abs(ps->ipd_index[env][bk])]; + RE(ps->opd_prev[bk][i]) = ipdopd_cos_tab[abs(ps->opd_index[env][bk])]; + IM(ps->opd_prev[bk][i]) = ipdopd_sin_tab[abs(ps->opd_index[env][bk])]; + + /* add current value */ + RE(tempLeft) += RE(ps->ipd_prev[bk][i]); + IM(tempLeft) += IM(ps->ipd_prev[bk][i]); + RE(tempRight) += RE(ps->opd_prev[bk][i]); + IM(tempRight) += IM(ps->opd_prev[bk][i]); + + /* ringbuffer index */ + if (i == 0) + { + i = 2; + } + i--; + + /* get value before previous */ +#ifdef FIXED_POINT + /* dividing by 2, shift right 1 bit */ + RE(tempLeft) += (RE(ps->ipd_prev[bk][i]) >> 1); + IM(tempLeft) += (IM(ps->ipd_prev[bk][i]) >> 1); + RE(tempRight) += (RE(ps->opd_prev[bk][i]) >> 1); + IM(tempRight) += (IM(ps->opd_prev[bk][i]) >> 1); +#else + RE(tempLeft) += MUL_F(RE(ps->ipd_prev[bk][i]), FRAC_CONST(0.5)); + IM(tempLeft) += MUL_F(IM(ps->ipd_prev[bk][i]), FRAC_CONST(0.5)); + RE(tempRight) += MUL_F(RE(ps->opd_prev[bk][i]), FRAC_CONST(0.5)); + IM(tempRight) += MUL_F(IM(ps->opd_prev[bk][i]), FRAC_CONST(0.5)); +#endif + +#if 0 /* original code */ + ipd = (float)atan2(IM(tempLeft), RE(tempLeft)); + opd = (float)atan2(IM(tempRight), RE(tempRight)); + + /* phase rotation */ + RE(phaseLeft) = (float)cos(opd); + IM(phaseLeft) = (float)sin(opd); + opd -= ipd; + RE(phaseRight) = (float)cos(opd); + IM(phaseRight) = (float)sin(opd); +#else + // x = IM(tempLeft) + // y = RE(tempLeft) + // p = IM(tempRight) + // q = RE(tempRight) + // cos(atan2(x,y)) = 1/sqrt(1 + (x*x)/(y*y)) + // sin(atan2(x,y)) = x/(y*sqrt(1 + (x*x)/(y*y))) + // cos(atan2(x,y)-atan2(p,q)) = (y*q+x*p)/(y*q * sqrt(1 + (x*x)/(y*y)) * sqrt(1 + (p*p)/(q*q))); + // sin(atan2(x,y)-atan2(p,q)) = (x*q-p*y)/(y*q * sqrt(1 + (x*x)/(y*y)) * sqrt(1 + (p*p)/(q*q))); + + /* (x*x)/(y*y) (REAL > 0) */ + xxyy = DIV_R(MUL_C(IM(tempLeft),IM(tempLeft)), MUL_C(RE(tempLeft),RE(tempLeft))); + ppqq = DIV_R(MUL_C(IM(tempRight),IM(tempRight)), MUL_C(RE(tempRight),RE(tempRight))); + + /* 1 + (x*x)/(y*y) (REAL > 1) */ + xxyy += REAL_CONST(1); + ppqq += REAL_CONST(1); + + /* 1 / sqrt(1 + (x*x)/(y*y)) (FRAC <= 1) */ + xxyy = DIV_R(FRAC_CONST(1), ps_sqrt(xxyy)); + ppqq = DIV_R(FRAC_CONST(1), ps_sqrt(ppqq)); + + /* COEF */ + yq = MUL_C(RE(tempLeft), RE(tempRight)); + xp = MUL_C(IM(tempLeft), IM(tempRight)); + xq = MUL_C(IM(tempLeft), RE(tempRight)); + py = MUL_C(RE(tempLeft), IM(tempRight)); + + RE(phaseLeft) = xxyy; + IM(phaseLeft) = MUL_R(xxyy, (DIV_R(IM(tempLeft), RE(tempLeft)))); + + tmp = DIV_C(MUL_F(xxyy, ppqq), yq); + + /* MUL_C(FRAC,COEF) = FRAC */ + RE(phaseRight) = MUL_C(tmp, (yq+xp)); + IM(phaseRight) = MUL_C(tmp, (xq-py)); +#endif + + /* MUL_F(COEF, FRAC) = COEF */ + IM(h11) = MUL_F(RE(h11), IM(phaseLeft)); + IM(h12) = MUL_F(RE(h12), IM(phaseRight)); + IM(h21) = MUL_F(RE(h21), IM(phaseLeft)); + IM(h22) = MUL_F(RE(h22), IM(phaseRight)); + + RE(h11) = MUL_F(RE(h11), RE(phaseLeft)); + RE(h12) = MUL_F(RE(h12), RE(phaseRight)); + RE(h21) = MUL_F(RE(h21), RE(phaseLeft)); + RE(h22) = MUL_F(RE(h22), RE(phaseRight)); + } + + /* length of the envelope n_e+1 - n_e (in time samples) */ + /* 0 < L <= 32: integer */ + L = (real_t)(ps->border_position[env + 1] - ps->border_position[env]); + + /* obtain final H_xy by means of linear interpolation */ + RE(deltaH11) = (RE(h11) - RE(ps->h11_prev[gr])) / L; + RE(deltaH12) = (RE(h12) - RE(ps->h12_prev[gr])) / L; + RE(deltaH21) = (RE(h21) - RE(ps->h21_prev[gr])) / L; + RE(deltaH22) = (RE(h22) - RE(ps->h22_prev[gr])) / L; + + RE(H11) = RE(ps->h11_prev[gr]); + RE(H12) = RE(ps->h12_prev[gr]); + RE(H21) = RE(ps->h21_prev[gr]); + RE(H22) = RE(ps->h22_prev[gr]); + + RE(ps->h11_prev[gr]) = RE(h11); + RE(ps->h12_prev[gr]) = RE(h12); + RE(ps->h21_prev[gr]) = RE(h21); + RE(ps->h22_prev[gr]) = RE(h22); + + /* only calculate imaginary part when needed */ + if ((ps->enable_ipdopd) && (bk < nr_ipdopd_par)) + { + /* obtain final H_xy by means of linear interpolation */ + IM(deltaH11) = (IM(h11) - IM(ps->h11_prev[gr])) / L; + IM(deltaH12) = (IM(h12) - IM(ps->h12_prev[gr])) / L; + IM(deltaH21) = (IM(h21) - IM(ps->h21_prev[gr])) / L; + IM(deltaH22) = (IM(h22) - IM(ps->h22_prev[gr])) / L; + + IM(H11) = IM(ps->h11_prev[gr]); + IM(H12) = IM(ps->h12_prev[gr]); + IM(H21) = IM(ps->h21_prev[gr]); + IM(H22) = IM(ps->h22_prev[gr]); + + if ((NEGATE_IPD_MASK & ps->map_group2bk[gr]) != 0) + { + IM(deltaH11) = -IM(deltaH11); + IM(deltaH12) = -IM(deltaH12); + IM(deltaH21) = -IM(deltaH21); + IM(deltaH22) = -IM(deltaH22); + + IM(H11) = -IM(H11); + IM(H12) = -IM(H12); + IM(H21) = -IM(H21); + IM(H22) = -IM(H22); + } + + IM(ps->h11_prev[gr]) = IM(h11); + IM(ps->h12_prev[gr]) = IM(h12); + IM(ps->h21_prev[gr]) = IM(h21); + IM(ps->h22_prev[gr]) = IM(h22); + } + + /* apply H_xy to the current envelope band of the decorrelated subband */ + for (n = ps->border_position[env]; n < ps->border_position[env + 1]; n++) + { + /* addition finalises the interpolation over every n */ + RE(H11) += RE(deltaH11); + RE(H12) += RE(deltaH12); + RE(H21) += RE(deltaH21); + RE(H22) += RE(deltaH22); + if ((ps->enable_ipdopd) && (bk < nr_ipdopd_par)) + { + IM(H11) += IM(deltaH11); + IM(H12) += IM(deltaH12); + IM(H21) += IM(deltaH21); + IM(H22) += IM(deltaH22); + } + + /* channel is an alias to the subband */ + for (sb = ps->group_border[gr]; sb < maxsb; sb++) + { + complex_t inLeft, inRight; + + /* load decorrelated samples */ + if (gr < ps->num_hybrid_groups) + { + RE(inLeft) = RE(X_hybrid_left[n][sb]); + IM(inLeft) = IM(X_hybrid_left[n][sb]); + RE(inRight) = RE(X_hybrid_right[n][sb]); + IM(inRight) = IM(X_hybrid_right[n][sb]); + } else { + RE(inLeft) = RE(X_left[n][sb]); + IM(inLeft) = IM(X_left[n][sb]); + RE(inRight) = RE(X_right[n][sb]); + IM(inRight) = IM(X_right[n][sb]); + } + + /* apply mixing */ + RE(tempLeft) = MUL_C(RE(H11), RE(inLeft)) + MUL_C(RE(H21), RE(inRight)); + IM(tempLeft) = MUL_C(RE(H11), IM(inLeft)) + MUL_C(RE(H21), IM(inRight)); + RE(tempRight) = MUL_C(RE(H12), RE(inLeft)) + MUL_C(RE(H22), RE(inRight)); + IM(tempRight) = MUL_C(RE(H12), IM(inLeft)) + MUL_C(RE(H22), IM(inRight)); + + /* only perform imaginary operations when needed */ + if ((ps->enable_ipdopd) && (bk < nr_ipdopd_par)) + { + /* apply rotation */ + RE(tempLeft) -= MUL_C(IM(H11), IM(inLeft)) + MUL_C(IM(H21), IM(inRight)); + IM(tempLeft) += MUL_C(IM(H11), RE(inLeft)) + MUL_C(IM(H21), RE(inRight)); + RE(tempRight) -= MUL_C(IM(H12), IM(inLeft)) + MUL_C(IM(H22), IM(inRight)); + IM(tempRight) += MUL_C(IM(H12), RE(inLeft)) + MUL_C(IM(H22), RE(inRight)); + } + + /* store final samples */ + if (gr < ps->num_hybrid_groups) + { + RE(X_hybrid_left[n][sb]) = RE(tempLeft); + IM(X_hybrid_left[n][sb]) = IM(tempLeft); + RE(X_hybrid_right[n][sb]) = RE(tempRight); + IM(X_hybrid_right[n][sb]) = IM(tempRight); + } else { + RE(X_left[n][sb]) = RE(tempLeft); + IM(X_left[n][sb]) = IM(tempLeft); + RE(X_right[n][sb]) = RE(tempRight); + IM(X_right[n][sb]) = IM(tempRight); + } + } + } + + /* shift phase smoother's circular buffer index */ + ps->phase_hist++; + if (ps->phase_hist == 2) + { + ps->phase_hist = 0; + } + } + } +} + +void ps_init(ps_info *ps) +{ + uint8_t i; + uint8_t short_delay_band; + + hybrid_init(&ps->hyb); + + ps->ps_data_available = 0; + + /* delay stuff*/ + ps->saved_delay = 0; + + for (i = 0; i < 64; i++) + { + ps->delay_buf_index_delay[i] = 0; + } + + for (i = 0; i < NO_ALLPASS_LINKS; i++) + { + ps->delay_buf_index_ser[i] = 0; +#ifdef PARAM_32KHZ + if (sr_index <= 5) /* >= 32 kHz*/ + { + ps->num_sample_delay_ser[i] = delay_length_d[1][i]; + } else { + ps->num_sample_delay_ser[i] = delay_length_d[0][i]; + } +#else + /* THESE ARE CONSTANTS NOW */ + ps->num_sample_delay_ser[i] = delay_length_d[i]; +#endif + } + +#ifdef PARAM_32KHZ + if (sr_index <= 5) /* >= 32 kHz*/ + { + short_delay_band = 35; + ps->nr_allpass_bands = 22; + ps->alpha_decay = FRAC_CONST(0.76592833836465); + ps->alpha_smooth = FRAC_CONST(0.25); + } else { + short_delay_band = 64; + ps->nr_allpass_bands = 45; + ps->alpha_decay = FRAC_CONST(0.58664621951003); + ps->alpha_smooth = FRAC_CONST(0.6); + } +#else + /* THESE ARE CONSTANTS NOW */ + short_delay_band = 35; + ps->nr_allpass_bands = 22; + ps->alpha_decay = FRAC_CONST(0.76592833836465); + ps->alpha_smooth = FRAC_CONST(0.25); +#endif + + /* THESE ARE CONSTANT NOW IF PS IS INDEPENDANT OF SAMPLERATE */ + for (i = 0; i < short_delay_band; i++) + { + ps->delay_D[i] = 14; + } + for (i = short_delay_band; i < 64; i++) + { + ps->delay_D[i] = 1; + } + + /* mixing and phase */ + for (i = 0; i < 50; i++) + { + RE(ps->h11_prev[i]) = 1; + IM(ps->h12_prev[i]) = 1; + RE(ps->h11_prev[i]) = 1; + IM(ps->h12_prev[i]) = 1; + } + + ps->phase_hist = 0; + + for (i = 0; i < 20; i++) + { + RE(ps->ipd_prev[i][0]) = 0; + IM(ps->ipd_prev[i][0]) = 0; + RE(ps->ipd_prev[i][1]) = 0; + IM(ps->ipd_prev[i][1]) = 0; + RE(ps->opd_prev[i][0]) = 0; + IM(ps->opd_prev[i][0]) = 0; + RE(ps->opd_prev[i][1]) = 0; + IM(ps->opd_prev[i][1]) = 0; + } +} + +/* main Parametric Stereo decoding function */ +uint8_t ps_decode(ps_info *ps, + qmf_t X_left[MAX_NTSRPS][64], + qmf_t X_right[MAX_NTSRPS][64]) +{ + static qmf_t X_hybrid_left[32][32]; + static qmf_t X_hybrid_right[32][32]; + + memset(&X_hybrid_left , 0, sizeof(X_hybrid_left)); + memset(&X_hybrid_right, 0, sizeof(X_hybrid_right)); + + /* delta decoding of the bitstream data */ + ps_data_decode(ps); + + /* set up some parameters depending on filterbank type */ + if (ps->use34hybrid_bands) + { + ps->group_border = (uint8_t*)group_border34; + ps->map_group2bk = (uint16_t*)map_group2bk34; + ps->num_groups = 32+18; + ps->num_hybrid_groups = 32; + ps->nr_par_bands = 34; + ps->decay_cutoff = 5; + } else { + ps->group_border = (uint8_t*)group_border20; + ps->map_group2bk = (uint16_t*)map_group2bk20; + ps->num_groups = 10+12; + ps->num_hybrid_groups = 10; + ps->nr_par_bands = 20; + ps->decay_cutoff = 3; + } + + /* Perform further analysis on the lowest subbands to get a higher + * frequency resolution + */ + hybrid_analysis(&ps->hyb, X_left, X_hybrid_left, ps->use34hybrid_bands); + + /* decorrelate mono signal */ + ps_decorrelate(ps, X_left, X_right, X_hybrid_left, X_hybrid_right); + + /* apply mixing and phase parameters */ + ps_mix_phase(ps, X_left, X_right, X_hybrid_left, X_hybrid_right); + + /* hybrid synthesis, to rebuild the SBR QMF matrices */ + hybrid_synthesis(&ps->hyb, X_left, X_hybrid_left, ps->use34hybrid_bands); + + hybrid_synthesis(&ps->hyb, X_right, X_hybrid_right, ps->use34hybrid_bands); + + return 0; +} + +#endif + diff --git a/lib/rbcodec/codecs/libfaad/ps_dec.h b/lib/rbcodec/codecs/libfaad/ps_dec.h new file mode 100644 index 0000000000..14e4bd54e6 --- /dev/null +++ b/lib/rbcodec/codecs/libfaad/ps_dec.h @@ -0,0 +1,162 @@ +/* +** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding +** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +** +** Any non-GPL usage of this software or parts of this software is strictly +** forbidden. +** +** Commercial non-GPL licensing of this software is possible. +** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** +** $Id$ +**/ + +#ifndef __PS_DEC_H__ +#define __PS_DEC_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "bits.h" + +#define EXTENSION_ID_PS 2 + +#define MAX_PS_ENVELOPES 5 +#define NO_ALLPASS_LINKS 3 + +#define MAX_NTSRPS 38 /* max number_time_slots * rate + 6 (delay) */ + +typedef struct +{ + uint8_t frame_len; + uint8_t resolution20[3]; + uint8_t resolution34[5]; + + qmf_t work[32+12]; + qmf_t buffer[5][32]; + qmf_t temp[32][12]; +} hyb_info; + +typedef struct +{ + /* bitstream parameters */ + uint8_t enable_iid; + uint8_t enable_icc; + uint8_t enable_ext; + + uint8_t iid_mode; + uint8_t icc_mode; + uint8_t nr_iid_par; + uint8_t nr_ipdopd_par; + uint8_t nr_icc_par; + + uint8_t frame_class; + uint8_t num_env; + + uint8_t border_position[MAX_PS_ENVELOPES+1]; + + uint8_t iid_dt[MAX_PS_ENVELOPES]; + uint8_t icc_dt[MAX_PS_ENVELOPES]; + + uint8_t enable_ipdopd; + uint8_t ipd_mode; + uint8_t ipd_dt[MAX_PS_ENVELOPES]; + uint8_t opd_dt[MAX_PS_ENVELOPES]; + + /* indices */ + int8_t iid_index_prev[34]; + int8_t icc_index_prev[34]; + int8_t ipd_index_prev[17]; + int8_t opd_index_prev[17]; + int8_t iid_index[MAX_PS_ENVELOPES][34]; + int8_t icc_index[MAX_PS_ENVELOPES][34]; + int8_t ipd_index[MAX_PS_ENVELOPES][17]; + int8_t opd_index[MAX_PS_ENVELOPES][17]; + + int8_t ipd_index_1[17]; + int8_t opd_index_1[17]; + int8_t ipd_index_2[17]; + int8_t opd_index_2[17]; + + /* ps data was correctly read */ + uint8_t ps_data_available; + + /* a header has been read */ + uint8_t header_read; + + /* hybrid filterbank parameters */ + hyb_info hyb; + uint8_t use34hybrid_bands; + + /**/ + uint8_t num_groups; + uint8_t num_hybrid_groups; + uint8_t nr_par_bands; + uint8_t nr_allpass_bands; + uint8_t decay_cutoff; + + uint8_t *group_border; + uint16_t *map_group2bk; + + /* filter delay handling */ + uint8_t saved_delay; + uint8_t delay_buf_index_ser[NO_ALLPASS_LINKS]; + uint8_t num_sample_delay_ser[NO_ALLPASS_LINKS]; + uint8_t delay_D[64]; + uint8_t delay_buf_index_delay[64]; + + complex_t delay_Qmf[14][64]; /* 14 samples delay max, 64 QMF channels */ + complex_t delay_SubQmf[2][32]; /* 2 samples delay max (SubQmf is always allpass filtered) */ + complex_t delay_Qmf_ser[NO_ALLPASS_LINKS][5][64]; /* 5 samples delay max (table 8.34), 64 QMF channels */ + complex_t delay_SubQmf_ser[NO_ALLPASS_LINKS][5][32]; /* 5 samples delay max (table 8.34) */ + + /* transients */ + real_t alpha_decay; + real_t alpha_smooth; + + real_t P_PeakDecayNrg[34]; + real_t P_prev[34]; + real_t P_SmoothPeakDecayDiffNrg_prev[34]; + + /* mixing and phase */ + complex_t h11_prev[50]; + complex_t h12_prev[50]; + complex_t h21_prev[50]; + complex_t h22_prev[50]; + uint8_t phase_hist; + complex_t ipd_prev[20][2]; + complex_t opd_prev[20][2]; + +} ps_info; + +/* ps_syntax.c */ +uint16_t ps_data(ps_info *ps, bitfile *ld, uint8_t *header); + +/* ps_dec.c */ +void ps_init(ps_info *ps); + +uint8_t ps_decode(ps_info *ps, + qmf_t X_left[MAX_NTSRPS][64], + qmf_t X_right[MAX_NTSRPS][64]); + + +#ifdef __cplusplus +} +#endif +#endif + diff --git a/lib/rbcodec/codecs/libfaad/ps_syntax.c b/lib/rbcodec/codecs/libfaad/ps_syntax.c new file mode 100644 index 0000000000..290d7e5523 --- /dev/null +++ b/lib/rbcodec/codecs/libfaad/ps_syntax.c @@ -0,0 +1,546 @@ +/* +** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR and PS decoding +** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +** +** Any non-GPL usage of this software or parts of this software is strictly +** forbidden. +** +** Commercial non-GPL licensing of this software is possible. +** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** +** $Id$ +**/ + +#include "common.h" + +#ifdef PS_DEC + +#include "bits.h" +#include "ps_dec.h" + +/* type definitaions */ +typedef const int8_t (*ps_huff_tab)[2]; + +/* static data tables */ +static const uint8_t nr_iid_par_tab[] = { + 10, 20, 34, 10, 20, 34, 0, 0 +}; +static const uint8_t nr_ipdopd_par_tab[] = { + 5, 11, 17, 5, 11, 17, 0, 0 +}; +static const uint8_t nr_icc_par_tab[] = { + 10, 20, 34, 10, 20, 34, 0, 0 +}; +static const uint8_t num_env_tab[][4] = { + { 0, 1, 2, 4 }, + { 1, 2, 3, 4 } +}; + +/* binary lookup huffman tables */ +static const int8_t f_huff_iid_def[][2] = { + { /*0*/ -31, 1 }, /* index 0: 1 bits: x */ + { 2, 3 }, /* index 1: 2 bits: 1x */ + { /*1*/ -30, /*-1*/ -32 }, /* index 2: 3 bits: 10x */ + { 4, 5 }, /* index 3: 3 bits: 11x */ + { /*2*/ -29, /*-2*/ -33 }, /* index 4: 4 bits: 110x */ + { 6, 7 }, /* index 5: 4 bits: 111x */ + { /*3*/ -28, /*-3*/ -34 }, /* index 6: 5 bits: 1110x */ + { 8, 9 }, /* index 7: 5 bits: 1111x */ + { /*-4*/ -35, /*4*/ -27 }, /* index 8: 6 bits: 11110x */ + { /*5*/ -26, 10 }, /* index 9: 6 bits: 11111x */ + { /*-5*/ -36, 11 }, /* index 10: 7 bits: 111111x */ + { /*6*/ -25, 12 }, /* index 11: 8 bits: 1111111x */ + { /*-6*/ -37, 13 }, /* index 12: 9 bits: 11111111x */ + { /*-7*/ -38, 14 }, /* index 13: 10 bits: 111111111x */ + { /*7*/ -24, 15 }, /* index 14: 11 bits: 1111111111x */ + { 16, 17 }, /* index 15: 12 bits: 11111111111x */ + { /*8*/ -23, /*-8*/ -39 }, /* index 16: 13 bits: 111111111110x */ + { 18, 19 }, /* index 17: 13 bits: 111111111111x */ + { /*9*/ -22, /*10*/ -21 }, /* index 18: 14 bits: 1111111111110x */ + { 20, 21 }, /* index 19: 14 bits: 1111111111111x */ + { /*-9*/ -40, /*11*/ -20 }, /* index 20: 15 bits: 11111111111110x */ + { 22, 23 }, /* index 21: 15 bits: 11111111111111x */ + { /*-10*/ -41, 24 }, /* index 22: 16 bits: 111111111111110x */ + { 25, 26 }, /* index 23: 16 bits: 111111111111111x */ + { /*-11*/ -42, /*-14*/ -45 }, /* index 24: 17 bits: 1111111111111101x */ + { /*-13*/ -44, /*-12*/ -43 }, /* index 25: 17 bits: 1111111111111110x */ + { /*12*/ -19, 27 }, /* index 26: 17 bits: 1111111111111111x */ + { /*13*/ -18, /*14*/ -17 } /* index 27: 18 bits: 11111111111111111x */ +}; + +static const int8_t t_huff_iid_def[][2] = { + { /*0*/ -31, 1 }, /* index 0: 1 bits: x */ + { /*-1*/ -32, 2 }, /* index 1: 2 bits: 1x */ + { /*1*/ -30, 3 }, /* index 2: 3 bits: 11x */ + { /*-2*/ -33, 4 }, /* index 3: 4 bits: 111x */ + { /*2*/ -29, 5 }, /* index 4: 5 bits: 1111x */ + { /*-3*/ -34, 6 }, /* index 5: 6 bits: 11111x */ + { /*3*/ -28, 7 }, /* index 6: 7 bits: 111111x */ + { /*-4*/ -35, 8 }, /* index 7: 8 bits: 1111111x */ + { /*4*/ -27, 9 }, /* index 8: 9 bits: 11111111x */ + { /*-5*/ -36, 10 }, /* index 9: 10 bits: 111111111x */ + { /*5*/ -26, 11 }, /* index 10: 11 bits: 1111111111x */ + { /*-6*/ -37, 12 }, /* index 11: 12 bits: 11111111111x */ + { /*6*/ -25, 13 }, /* index 12: 13 bits: 111111111111x */ + { /*7*/ -24, 14 }, /* index 13: 14 bits: 1111111111111x */ + { /*-7*/ -38, 15 }, /* index 14: 15 bits: 11111111111111x */ + { 16, 17 }, /* index 15: 16 bits: 111111111111111x */ + { /*8*/ -23, /*-8*/ -39 }, /* index 16: 17 bits: 1111111111111110x */ + { 18, 19 }, /* index 17: 17 bits: 1111111111111111x */ + { 20, 21 }, /* index 18: 18 bits: 11111111111111110x */ + { 22, 23 }, /* index 19: 18 bits: 11111111111111111x */ + { /*9*/ -22, /*-14*/ -45 }, /* index 20: 19 bits: 111111111111111100x */ + { /*-13*/ -44, /*-12*/ -43 }, /* index 21: 19 bits: 111111111111111101x */ + { 24, 25 }, /* index 22: 19 bits: 111111111111111110x */ + { 26, 27 }, /* index 23: 19 bits: 111111111111111111x */ + { /*-11*/ -42, /*-10*/ -41 }, /* index 24: 20 bits: 1111111111111111100x */ + { /*-9*/ -40, /*10*/ -21 }, /* index 25: 20 bits: 1111111111111111101x */ + { /*11*/ -20, /*12*/ -19 }, /* index 26: 20 bits: 1111111111111111110x */ + { /*13*/ -18, /*14*/ -17 } /* index 27: 20 bits: 1111111111111111111x */ +}; + +static const int8_t f_huff_iid_fine[][2] = { + { 1, /*0*/ -31 }, /* index 0: 1 bits: x */ + { 2, 3 }, /* index 1: 2 bits: 0x */ + { 4, /*-1*/ -32 }, /* index 2: 3 bits: 00x */ + { /*1*/ -30, 5 }, /* index 3: 3 bits: 01x */ + { /*-2*/ -33, /*2*/ -29 }, /* index 4: 4 bits: 000x */ + { 6, 7 }, /* index 5: 4 bits: 011x */ + { /*-3*/ -34, /*3*/ -28 }, /* index 6: 5 bits: 0110x */ + { 8, 9 }, /* index 7: 5 bits: 0111x */ + { /*-4*/ -35, /*4*/ -27 }, /* index 8: 6 bits: 01110x */ + { 10, 11 }, /* index 9: 6 bits: 01111x */ + { /*-5*/ -36, /*5*/ -26 }, /* index 10: 7 bits: 011110x */ + { 12, 13 }, /* index 11: 7 bits: 011111x */ + { /*-6*/ -37, /*6*/ -25 }, /* index 12: 8 bits: 0111110x */ + { 14, 15 }, /* index 13: 8 bits: 0111111x */ + { /*7*/ -24, 16 }, /* index 14: 9 bits: 01111110x */ + { 17, 18 }, /* index 15: 9 bits: 01111111x */ + { 19, /*-8*/ -39 }, /* index 16: 10 bits: 011111101x */ + { /*8*/ -23, 20 }, /* index 17: 10 bits: 011111110x */ + { 21, /*-7*/ -38 }, /* index 18: 10 bits: 011111111x */ + { /*10*/ -21, 22 }, /* index 19: 11 bits: 0111111010x */ + { 23, /*-9*/ -40 }, /* index 20: 11 bits: 0111111101x */ + { /*9*/ -22, 24 }, /* index 21: 11 bits: 0111111110x */ + { /*-11*/ -42, /*11*/ -20 }, /* index 22: 12 bits: 01111110101x */ + { 25, 26 }, /* index 23: 12 bits: 01111111010x */ + { 27, /*-10*/ -41 }, /* index 24: 12 bits: 01111111101x */ + { 28, /*-12*/ -43 }, /* index 25: 13 bits: 011111110100x */ + { /*12*/ -19, 29 }, /* index 26: 13 bits: 011111110101x */ + { 30, 31 }, /* index 27: 13 bits: 011111111010x */ + { 32, /*-14*/ -45 }, /* index 28: 14 bits: 0111111101000x */ + { /*14*/ -17, 33 }, /* index 29: 14 bits: 0111111101011x */ + { 34, /*-13*/ -44 }, /* index 30: 14 bits: 0111111110100x */ + { /*13*/ -18, 35 }, /* index 31: 14 bits: 0111111110101x */ + { 36, 37 }, /* index 32: 15 bits: 01111111010000x */ + { 38, /*-15*/ -46 }, /* index 33: 15 bits: 01111111010111x */ + { /*15*/ -16, 39 }, /* index 34: 15 bits: 01111111101000x */ + { 40, 41 }, /* index 35: 15 bits: 01111111101011x */ + { 42, 43 }, /* index 36: 16 bits: 011111110100000x */ + { /*-17*/ -48, /*17*/ -14 }, /* index 37: 16 bits: 011111110100001x */ + { 44, 45 }, /* index 38: 16 bits: 011111110101110x */ + { 46, 47 }, /* index 39: 16 bits: 011111111010001x */ + { 48, 49 }, /* index 40: 16 bits: 011111111010110x */ + { /*-16*/ -47, /*16*/ -15 }, /* index 41: 16 bits: 011111111010111x */ + { /*-21*/ -52, /*21*/ -10 }, /* index 42: 17 bits: 0111111101000000x */ + { /*-19*/ -50, /*19*/ -12 }, /* index 43: 17 bits: 0111111101000001x */ + { /*-18*/ -49, /*18*/ -13 }, /* index 44: 17 bits: 0111111101011100x */ + { 50, 51 }, /* index 45: 17 bits: 0111111101011101x */ + { 52, 53 }, /* index 46: 17 bits: 0111111110100010x */ + { 54, 55 }, /* index 47: 17 bits: 0111111110100011x */ + { 56, 57 }, /* index 48: 17 bits: 0111111110101100x */ + { 58, 59 }, /* index 49: 17 bits: 0111111110101101x */ + { /*-26*/ -57, /*-25*/ -56 }, /* index 50: 18 bits: 01111111010111010x */ + { /*-28*/ -59, /*-27*/ -58 }, /* index 51: 18 bits: 01111111010111011x */ + { /*-22*/ -53, /*22*/ -9 }, /* index 52: 18 bits: 01111111101000100x */ + { /*-24*/ -55, /*-23*/ -54 }, /* index 53: 18 bits: 01111111101000101x */ + { /*25*/ -6, /*26*/ -5 }, /* index 54: 18 bits: 01111111101000110x */ + { /*23*/ -8, /*24*/ -7 }, /* index 55: 18 bits: 01111111101000111x */ + { /*29*/ -2, /*30*/ -1 }, /* index 56: 18 bits: 01111111101011000x */ + { /*27*/ -4, /*28*/ -3 }, /* index 57: 18 bits: 01111111101011001x */ + { /*-30*/ -61, /*-29*/ -60 }, /* index 58: 18 bits: 01111111101011010x */ + { /*-20*/ -51, /*20*/ -11 } /* index 59: 18 bits: 01111111101011011x */ +}; + +static const int8_t t_huff_iid_fine[][2] = { + { 1, /*0*/ -31 }, /* index 0: 1 bits: x */ + { /*1*/ -30, 2 }, /* index 1: 2 bits: 0x */ + { 3, /*-1*/ -32 }, /* index 2: 3 bits: 01x */ + { 4, 5 }, /* index 3: 4 bits: 010x */ + { 6, 7 }, /* index 4: 5 bits: 0100x */ + { /*-2*/ -33, /*2*/ -29 }, /* index 5: 5 bits: 0101x */ + { 8, /*-3*/ -34 }, /* index 6: 6 bits: 01000x */ + { /*3*/ -28, 9 }, /* index 7: 6 bits: 01001x */ + { /*-4*/ -35, /*4*/ -27 }, /* index 8: 7 bits: 010000x */ + { 10, 11 }, /* index 9: 7 bits: 010011x */ + { /*5*/ -26, 12 }, /* index 10: 8 bits: 0100110x */ + { 13, 14 }, /* index 11: 8 bits: 0100111x */ + { /*-6*/ -37, /*6*/ -25 }, /* index 12: 9 bits: 01001101x */ + { 15, 16 }, /* index 13: 9 bits: 01001110x */ + { 17, /*-5*/ -36 }, /* index 14: 9 bits: 01001111x */ + { 18, /*-7*/ -38 }, /* index 15: 10 bits: 010011100x */ + { /*7*/ -24, 19 }, /* index 16: 10 bits: 010011101x */ + { 20, 21 }, /* index 17: 10 bits: 010011110x */ + { /*9*/ -22, 22 }, /* index 18: 11 bits: 0100111000x */ + { 23, 24 }, /* index 19: 11 bits: 0100111011x */ + { /*-8*/ -39, /*8*/ -23 }, /* index 20: 11 bits: 0100111100x */ + { 25, 26 }, /* index 21: 11 bits: 0100111101x */ + { /*11*/ -20, 27 }, /* index 22: 12 bits: 01001110001x */ + { 28, 29 }, /* index 23: 12 bits: 01001110110x */ + { /*-10*/ -41, /*10*/ -21 }, /* index 24: 12 bits: 01001110111x */ + { 30, 31 }, /* index 25: 12 bits: 01001111010x */ + { 32, /*-9*/ -40 }, /* index 26: 12 bits: 01001111011x */ + { 33, /*-13*/ -44 }, /* index 27: 13 bits: 010011100011x */ + { /*13*/ -18, 34 }, /* index 28: 13 bits: 010011101100x */ + { 35, 36 }, /* index 29: 13 bits: 010011101101x */ + { 37, /*-12*/ -43 }, /* index 30: 13 bits: 010011110100x */ + { /*12*/ -19, 38 }, /* index 31: 13 bits: 010011110101x */ + { 39, /*-11*/ -42 }, /* index 32: 13 bits: 010011110110x */ + { 40, 41 }, /* index 33: 14 bits: 0100111000110x */ + { 42, 43 }, /* index 34: 14 bits: 0100111011001x */ + { 44, 45 }, /* index 35: 14 bits: 0100111011010x */ + { 46, /*-15*/ -46 }, /* index 36: 14 bits: 0100111011011x */ + { /*15*/ -16, 47 }, /* index 37: 14 bits: 0100111101000x */ + { /*-14*/ -45, /*14*/ -17 }, /* index 38: 14 bits: 0100111101011x */ + { 48, 49 }, /* index 39: 14 bits: 0100111101100x */ + { /*-21*/ -52, /*-20*/ -51 }, /* index 40: 15 bits: 01001110001100x */ + { /*18*/ -13, /*19*/ -12 }, /* index 41: 15 bits: 01001110001101x */ + { /*-19*/ -50, /*-18*/ -49 }, /* index 42: 15 bits: 01001110110010x */ + { 50, 51 }, /* index 43: 15 bits: 01001110110011x */ + { 52, 53 }, /* index 44: 15 bits: 01001110110100x */ + { 54, 55 }, /* index 45: 15 bits: 01001110110101x */ + { 56, /*-17*/ -48 }, /* index 46: 15 bits: 01001110110110x */ + { /*17*/ -14, 57 }, /* index 47: 15 bits: 01001111010001x */ + { 58, /*-16*/ -47 }, /* index 48: 15 bits: 01001111011000x */ + { /*16*/ -15, 59 }, /* index 49: 15 bits: 01001111011001x */ + { /*-26*/ -57, /*26*/ -5 }, /* index 50: 16 bits: 010011101100110x */ + { /*-28*/ -59, /*-27*/ -58 }, /* index 51: 16 bits: 010011101100111x */ + { /*29*/ -2, /*30*/ -1 }, /* index 52: 16 bits: 010011101101000x */ + { /*27*/ -4, /*28*/ -3 }, /* index 53: 16 bits: 010011101101001x */ + { /*-30*/ -61, /*-29*/ -60 }, /* index 54: 16 bits: 010011101101010x */ + { /*-25*/ -56, /*25*/ -6 }, /* index 55: 16 bits: 010011101101011x */ + { /*-24*/ -55, /*24*/ -7 }, /* index 56: 16 bits: 010011101101100x */ + { /*-23*/ -54, /*23*/ -8 }, /* index 57: 16 bits: 010011110100011x */ + { /*-22*/ -53, /*22*/ -9 }, /* index 58: 16 bits: 010011110110000x */ + { /*20*/ -11, /*21*/ -10 } /* index 59: 16 bits: 010011110110011x */ +}; + +static const int8_t f_huff_icc[][2] = { + { /*0*/ -31, 1 }, /* index 0: 1 bits: x */ + { /*1*/ -30, 2 }, /* index 1: 2 bits: 1x */ + { /*-1*/ -32, 3 }, /* index 2: 3 bits: 11x */ + { /*2*/ -29, 4 }, /* index 3: 4 bits: 111x */ + { /*-2*/ -33, 5 }, /* index 4: 5 bits: 1111x */ + { /*3*/ -28, 6 }, /* index 5: 6 bits: 11111x */ + { /*-3*/ -34, 7 }, /* index 6: 7 bits: 111111x */ + { /*4*/ -27, 8 }, /* index 7: 8 bits: 1111111x */ + { /*5*/ -26, 9 }, /* index 8: 9 bits: 11111111x */ + { /*-4*/ -35, 10 }, /* index 9: 10 bits: 111111111x */ + { /*6*/ -25, 11 }, /* index 10: 11 bits: 1111111111x */ + { /*-5*/ -36, 12 }, /* index 11: 12 bits: 11111111111x */ + { /*7*/ -24, 13 }, /* index 12: 13 bits: 111111111111x */ + { /*-6*/ -37, /*-7*/ -38 } /* index 13: 14 bits: 1111111111111x */ +}; + +static const int8_t t_huff_icc[][2] = { + { /*0*/ -31, 1 }, /* index 0: 1 bits: x */ + { /*1*/ -30, 2 }, /* index 1: 2 bits: 1x */ + { /*-1*/ -32, 3 }, /* index 2: 3 bits: 11x */ + { /*2*/ -29, 4 }, /* index 3: 4 bits: 111x */ + { /*-2*/ -33, 5 }, /* index 4: 5 bits: 1111x */ + { /*3*/ -28, 6 }, /* index 5: 6 bits: 11111x */ + { /*-3*/ -34, 7 }, /* index 6: 7 bits: 111111x */ + { /*4*/ -27, 8 }, /* index 7: 8 bits: 1111111x */ + { /*-4*/ -35, 9 }, /* index 8: 9 bits: 11111111x */ + { /*5*/ -26, 10 }, /* index 9: 10 bits: 111111111x */ + { /*-5*/ -36, 11 }, /* index 10: 11 bits: 1111111111x */ + { /*6*/ -25, 12 }, /* index 11: 12 bits: 11111111111x */ + { /*-6*/ -37, 13 }, /* index 12: 13 bits: 111111111111x */ + { /*-7*/ -38, /*7*/ -24 } /* index 13: 14 bits: 1111111111111x */ +}; + +static const int8_t f_huff_ipd[][2] = { + { 1, /*0*/ -31 }, /* index 0: 1 bits: x */ + { 2, 3 }, /* index 1: 2 bits: 0x */ + { /*1*/ -30, 4 }, /* index 2: 3 bits: 00x */ + { 5, 6 }, /* index 3: 3 bits: 01x */ + { /*4*/ -27, /*5*/ -26 }, /* index 4: 4 bits: 001x */ + { /*3*/ -28, /*6*/ -25 }, /* index 5: 4 bits: 010x */ + { /*2*/ -29, /*7*/ -24 } /* index 6: 4 bits: 011x */ +}; + +static const int8_t t_huff_ipd[][2] = { + { 1, /*0*/ -31 }, /* index 0: 1 bits: x */ + { 2, 3 }, /* index 1: 2 bits: 0x */ + { 4, 5 }, /* index 2: 3 bits: 00x */ + { /*1*/ -30, /*7*/ -24 }, /* index 3: 3 bits: 01x */ + { /*5*/ -26, 6 }, /* index 4: 4 bits: 000x */ + { /*2*/ -29, /*6*/ -25 }, /* index 5: 4 bits: 001x */ + { /*4*/ -27, /*3*/ -28 } /* index 6: 5 bits: 0001x */ +}; + +static const int8_t f_huff_opd[][2] = { + { 1, /*0*/ -31 }, /* index 0: 1 bits: x */ + { 2, 3 }, /* index 1: 2 bits: 0x */ + { /*7*/ -24, /*1*/ -30 }, /* index 2: 3 bits: 00x */ + { 4, 5 }, /* index 3: 3 bits: 01x */ + { /*3*/ -28, /*6*/ -25 }, /* index 4: 4 bits: 010x */ + { /*2*/ -29, 6 }, /* index 5: 4 bits: 011x */ + { /*5*/ -26, /*4*/ -27 } /* index 6: 5 bits: 0111x */ +}; + +static const int8_t t_huff_opd[][2] = { + { 1, /*0*/ -31 }, /* index 0: 1 bits: x */ + { 2, 3 }, /* index 1: 2 bits: 0x */ + { 4, 5 }, /* index 2: 3 bits: 00x */ + { /*1*/ -30, /*7*/ -24 }, /* index 3: 3 bits: 01x */ + { /*5*/ -26, 6 }, /* index 4: 4 bits: 000x */ + { /*2*/ -29, /*6*/ -25 }, /* index 5: 4 bits: 001x */ + { /*4*/ -27, /*3*/ -28 } /* index 6: 5 bits: 0001x */ +}; + +/* static function declarations */ +static uint16_t ps_extension(ps_info *ps, bitfile *ld, + const uint8_t ps_extension_id, + const uint16_t num_bits_left); +static void huff_data(bitfile *ld, const uint8_t dt, const uint8_t nr_par, + ps_huff_tab t_huff, ps_huff_tab f_huff, int8_t *par); +static INLINE int8_t ps_huff_dec(bitfile *ld, ps_huff_tab t_huff); + + +uint16_t ps_data(ps_info *ps, bitfile *ld, uint8_t *header) +{ + uint8_t tmp, n; + uint16_t bits = (uint16_t)faad_get_processed_bits(ld); + + *header = 0; + + /* check for new PS header */ + if (faad_get1bit(ld + DEBUGVAR(1,1000,"ps_data(): enable_ps_header"))) + { + *header = 1; + + ps->header_read = 1; + + ps->use34hybrid_bands = 0; + + /* Inter-channel Intensity Difference (IID) parameters enabled */ + ps->enable_iid = (uint8_t)faad_get1bit(ld + DEBUGVAR(1,1001,"ps_data(): enable_iid")); + + if (ps->enable_iid) + { + ps->iid_mode = (uint8_t)faad_getbits(ld, 3 + DEBUGVAR(1,1002,"ps_data(): iid_mode")); + + ps->nr_iid_par = nr_iid_par_tab[ps->iid_mode]; + ps->nr_ipdopd_par = nr_ipdopd_par_tab[ps->iid_mode]; + + if (ps->iid_mode == 2 || ps->iid_mode == 5) + ps->use34hybrid_bands = 1; + + /* IPD freq res equal to IID freq res */ + ps->ipd_mode = ps->iid_mode; + } + + /* Inter-channel Coherence (ICC) parameters enabled */ + ps->enable_icc = (uint8_t)faad_get1bit(ld + DEBUGVAR(1,1003,"ps_data(): enable_icc")); + + if (ps->enable_icc) + { + ps->icc_mode = (uint8_t)faad_getbits(ld, 3 + DEBUGVAR(1,1004,"ps_data(): icc_mode")); + + ps->nr_icc_par = nr_icc_par_tab[ps->icc_mode]; + + if (ps->icc_mode == 2 || ps->icc_mode == 5) + ps->use34hybrid_bands = 1; + } + + /* PS extension layer enabled */ + ps->enable_ext = (uint8_t)faad_get1bit(ld + DEBUGVAR(1,1005,"ps_data(): enable_ext")); + } + + /* we are here, but no header has been read yet */ + if (ps->header_read == 0) + return 1; + + ps->frame_class = (uint8_t)faad_get1bit(ld + DEBUGVAR(1,1006,"ps_data(): frame_class")); + tmp = (uint8_t)faad_getbits(ld, 2 + DEBUGVAR(1,1007,"ps_data(): num_env_idx")); + + ps->num_env = num_env_tab[ps->frame_class][tmp]; + + if (ps->frame_class) + { + for (n = 1; n < ps->num_env+1; n++) + { + ps->border_position[n] = (uint8_t)faad_getbits(ld, 5 + DEBUGVAR(1,1008,"ps_data(): border_position")); + } + } + + if (ps->enable_iid) + { + for (n = 0; n < ps->num_env; n++) + { + ps->iid_dt[n] = (uint8_t)faad_get1bit(ld + DEBUGVAR(1,1009,"ps_data(): iid_dt")); + + /* iid_data */ + if (ps->iid_mode < 3) + { + huff_data(ld, ps->iid_dt[n], ps->nr_iid_par, t_huff_iid_def, + f_huff_iid_def, ps->iid_index[n]); + } else { + huff_data(ld, ps->iid_dt[n], ps->nr_iid_par, t_huff_iid_fine, + f_huff_iid_fine, ps->iid_index[n]); + } + } + } + + if (ps->enable_icc) + { + for (n = 0; n < ps->num_env; n++) + { + ps->icc_dt[n] = (uint8_t)faad_get1bit(ld + DEBUGVAR(1,1010,"ps_data(): icc_dt")); + + /* icc_data */ + huff_data(ld, ps->icc_dt[n], ps->nr_icc_par, t_huff_icc, + f_huff_icc, ps->icc_index[n]); + } + } + + if (ps->enable_ext) + { + uint16_t num_bits_left; + uint16_t cnt = (uint16_t)faad_getbits(ld, 4 + DEBUGVAR(1,1011,"ps_data(): ps_extension_size")); + if (cnt == 15) + { + cnt += (uint16_t)faad_getbits(ld, 8 + DEBUGVAR(1,1012,"ps_data(): esc_count")); + } + + num_bits_left = 8 * cnt; + while (num_bits_left > 7) + { + uint8_t ps_extension_id = (uint8_t)faad_getbits(ld, 2 + DEBUGVAR(1,1013,"ps_data(): ps_extension_size")); + + num_bits_left -= 2; + num_bits_left -= ps_extension(ps, ld, ps_extension_id, num_bits_left); + } + + faad_getbits(ld, num_bits_left + DEBUGVAR(1,1014,"ps_data(): fill_bits")); + } + + bits = (uint16_t)faad_get_processed_bits(ld) - bits; + + ps->ps_data_available = 1; + + return bits; +} + +static uint16_t ps_extension(ps_info *ps, bitfile *ld, + const uint8_t ps_extension_id, + const uint16_t num_bits_left) +{ + uint8_t n; + uint16_t bits = (uint16_t)faad_get_processed_bits(ld); + + (void)num_bits_left; + if (ps_extension_id == 0) + { + ps->enable_ipdopd = (uint8_t)faad_get1bit(ld + DEBUGVAR(1,1015,"ps_extension(): enable_ipdopd")); + + if (ps->enable_ipdopd) + { + for (n = 0; n < ps->num_env; n++) + { + ps->ipd_dt[n] = (uint8_t)faad_get1bit(ld + DEBUGVAR(1,1016,"ps_extension(): ipd_dt")); + + /* ipd_data */ + huff_data(ld, ps->ipd_dt[n], ps->nr_ipdopd_par, t_huff_ipd, + f_huff_ipd, ps->ipd_index[n]); + + ps->opd_dt[n] = (uint8_t)faad_get1bit(ld + DEBUGVAR(1,1017,"ps_extension(): opd_dt")); + + /* opd_data */ + huff_data(ld, ps->opd_dt[n], ps->nr_ipdopd_par, t_huff_opd, + f_huff_opd, ps->opd_index[n]); + } + } + faad_get1bit(ld + DEBUGVAR(1,1018,"ps_extension(): reserved_ps")); + } + + /* return number of bits read */ + bits = (uint16_t)faad_get_processed_bits(ld) - bits; + + return bits; +} + +/* read huffman data coded in either the frequency or the time direction */ +static void huff_data(bitfile *ld, const uint8_t dt, const uint8_t nr_par, + ps_huff_tab t_huff, ps_huff_tab f_huff, int8_t *par) +{ + uint8_t n; + + if (dt) + { + /* coded in time direction */ + for (n = 0; n < nr_par; n++) + { + par[n] = ps_huff_dec(ld, t_huff); + } + } else { + /* coded in frequency direction */ + par[0] = ps_huff_dec(ld, f_huff); + + for (n = 1; n < nr_par; n++) + { + par[n] = ps_huff_dec(ld, f_huff); + } + } +} + +/* binary search huffman decoding */ +static INLINE int8_t ps_huff_dec(bitfile *ld, ps_huff_tab t_huff) +{ + uint8_t bit; + int16_t index = 0; + + while (index >= 0) + { + bit = (uint8_t)faad_get1bit(ld); + index = t_huff[index][bit]; + } + + return index + 31; +} + +#endif diff --git a/lib/rbcodec/codecs/libfaad/ps_tables.h b/lib/rbcodec/codecs/libfaad/ps_tables.h new file mode 100644 index 0000000000..83cd20abbf --- /dev/null +++ b/lib/rbcodec/codecs/libfaad/ps_tables.h @@ -0,0 +1,547 @@ +/* +** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding +** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +** +** Any non-GPL usage of this software or parts of this software is strictly +** forbidden. +** +** Commercial non-GPL licensing of this software is possible. +** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** +** $Id$ +**/ + +#ifndef __PS_TABLES_H__ +#define __PS_TABLES_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _MSC_VER +#pragma warning(disable:4305) +#pragma warning(disable:4244) +#endif + +#if 0 +#if 0 +float f_center_20[12] = { + 0.5/4, 1.5/4, 2.5/4, 3.5/4, + 4.5/4*0, 5.5/4*0, -1.5/4, -0.5/4, + 3.5/2, 2.5/2, 4.5/2, 5.5/2 +}; +#else +float f_center_20[12] = { + 0.5/8, 1.5/8, 2.5/8, 3.5/8, + 4.5/8*0, 5.5/8*0, -1.5/8, -0.5/8, + 3.5/4, 2.5/4, 4.5/4, 5.5/4 +}; +#endif + +float f_center_34[32] = { + 1/12, 3/12, 5/12, 7/12, + 9/12, 11/12, 13/12, 15/12, + 17/12, -5/12, -3/12, -1/12, + 17/8, 19/8, 5/8, 7/8, + 9/8, 11/8, 13/8, 15/8, + 9/4, 11/4, 13/4, 7/4, + 17/4, 11/4, 13/4, 15/4, + 17/4, 19/4, 21/4, 15/4 +}; + +static const real_t frac_delay_q[] = { + FRAC_CONST(0.43), + FRAC_CONST(0.75), + FRAC_CONST(0.347) +}; +#endif + +/* RE(ps->Phi_Fract_Qmf[j]) = (float)cos(M_PI*(j+0.5)*(0.39)); */ +/* IM(ps->Phi_Fract_Qmf[j]) = (float)sin(M_PI*(j+0.5)*(0.39)); */ +static const complex_t Phi_Fract_Qmf[] = { + { FRAC_CONST(0.8181497455), FRAC_CONST(0.5750052333) }, + { FRAC_CONST(-0.2638730407), FRAC_CONST(0.9645574093) }, + { FRAC_CONST(-0.9969173074), FRAC_CONST(0.0784590989) }, + { FRAC_CONST(-0.4115143716), FRAC_CONST(-0.9114032984) }, + { FRAC_CONST(0.7181262970), FRAC_CONST(-0.6959127784) }, + { FRAC_CONST(0.8980275989), FRAC_CONST(0.4399391711) }, + { FRAC_CONST(-0.1097343117), FRAC_CONST(0.9939609766) }, + { FRAC_CONST(-0.9723699093), FRAC_CONST(0.2334453613) }, + { FRAC_CONST(-0.5490227938), FRAC_CONST(-0.8358073831) }, + { FRAC_CONST(0.6004202366), FRAC_CONST(-0.7996846437) }, + { FRAC_CONST(0.9557930231), FRAC_CONST(0.2940403223) }, + { FRAC_CONST(0.0471064523), FRAC_CONST(0.9988898635) }, + { FRAC_CONST(-0.9238795042), FRAC_CONST(0.3826834261) }, + { FRAC_CONST(-0.6730124950), FRAC_CONST(-0.7396311164) }, + { FRAC_CONST(0.4679298103), FRAC_CONST(-0.8837656379) }, + { FRAC_CONST(0.9900236726), FRAC_CONST(0.1409012377) }, + { FRAC_CONST(0.2027872950), FRAC_CONST(0.9792228341) }, + { FRAC_CONST(-0.8526401520), FRAC_CONST(0.5224985480) }, + { FRAC_CONST(-0.7804304361), FRAC_CONST(-0.6252426505) }, + { FRAC_CONST(0.3239174187), FRAC_CONST(-0.9460853338) }, + { FRAC_CONST(0.9998766184), FRAC_CONST(-0.0157073177) }, + { FRAC_CONST(0.3534748554), FRAC_CONST(0.9354440570) }, + { FRAC_CONST(-0.7604059577), FRAC_CONST(0.6494480371) }, + { FRAC_CONST(-0.8686315417), FRAC_CONST(-0.4954586625) }, + { FRAC_CONST(0.1719291061), FRAC_CONST(-0.9851093292) }, + { FRAC_CONST(0.9851093292), FRAC_CONST(-0.1719291061) }, + { FRAC_CONST(0.4954586625), FRAC_CONST(0.8686315417) }, + { FRAC_CONST(-0.6494480371), FRAC_CONST(0.7604059577) }, + { FRAC_CONST(-0.9354440570), FRAC_CONST(-0.3534748554) }, + { FRAC_CONST(0.0157073177), FRAC_CONST(-0.9998766184) }, + { FRAC_CONST(0.9460853338), FRAC_CONST(-0.3239174187) }, + { FRAC_CONST(0.6252426505), FRAC_CONST(0.7804304361) }, + { FRAC_CONST(-0.5224985480), FRAC_CONST(0.8526401520) }, + { FRAC_CONST(-0.9792228341), FRAC_CONST(-0.2027872950) }, + { FRAC_CONST(-0.1409012377), FRAC_CONST(-0.9900236726) }, + { FRAC_CONST(0.8837656379), FRAC_CONST(-0.4679298103) }, + { FRAC_CONST(0.7396311164), FRAC_CONST(0.6730124950) }, + { FRAC_CONST(-0.3826834261), FRAC_CONST(0.9238795042) }, + { FRAC_CONST(-0.9988898635), FRAC_CONST(-0.0471064523) }, + { FRAC_CONST(-0.2940403223), FRAC_CONST(-0.9557930231) }, + { FRAC_CONST(0.7996846437), FRAC_CONST(-0.6004202366) }, + { FRAC_CONST(0.8358073831), FRAC_CONST(0.5490227938) }, + { FRAC_CONST(-0.2334453613), FRAC_CONST(0.9723699093) }, + { FRAC_CONST(-0.9939609766), FRAC_CONST(0.1097343117) }, + { FRAC_CONST(-0.4399391711), FRAC_CONST(-0.8980275989) }, + { FRAC_CONST(0.6959127784), FRAC_CONST(-0.7181262970) }, + { FRAC_CONST(0.9114032984), FRAC_CONST(0.4115143716) }, + { FRAC_CONST(-0.0784590989), FRAC_CONST(0.9969173074) }, + { FRAC_CONST(-0.9645574093), FRAC_CONST(0.2638730407) }, + { FRAC_CONST(-0.5750052333), FRAC_CONST(-0.8181497455) }, + { FRAC_CONST(0.5750052333), FRAC_CONST(-0.8181497455) }, + { FRAC_CONST(0.9645574093), FRAC_CONST(0.2638730407) }, + { FRAC_CONST(0.0784590989), FRAC_CONST(0.9969173074) }, + { FRAC_CONST(-0.9114032984), FRAC_CONST(0.4115143716) }, + { FRAC_CONST(-0.6959127784), FRAC_CONST(-0.7181262970) }, + { FRAC_CONST(0.4399391711), FRAC_CONST(-0.8980275989) }, + { FRAC_CONST(0.9939609766), FRAC_CONST(0.1097343117) }, + { FRAC_CONST(0.2334453613), FRAC_CONST(0.9723699093) }, + { FRAC_CONST(-0.8358073831), FRAC_CONST(0.5490227938) }, + { FRAC_CONST(-0.7996846437), FRAC_CONST(-0.6004202366) }, + { FRAC_CONST(0.2940403223), FRAC_CONST(-0.9557930231) }, + { FRAC_CONST(0.9988898635), FRAC_CONST(-0.0471064523) }, + { FRAC_CONST(0.3826834261), FRAC_CONST(0.9238795042) }, + { FRAC_CONST(-0.7396311164), FRAC_CONST(0.6730124950) } +}; + +/* RE(Phi_Fract_SubQmf20[j]) = (float)cos(M_PI*f_center_20[j]*0.39); */ +/* IM(Phi_Fract_SubQmf20[j]) = (float)sin(M_PI*f_center_20[j]*0.39); */ +static const complex_t Phi_Fract_SubQmf20[] = { + { FRAC_CONST(0.9882950187), FRAC_CONST(0.1525546312) }, + { FRAC_CONST(0.8962930441), FRAC_CONST(0.4434623122) }, + { FRAC_CONST(0.7208535671), FRAC_CONST(0.6930873394) }, + { FRAC_CONST(0.4783087075), FRAC_CONST(0.8781917691) }, + { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, + { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, + { FRAC_CONST(0.8962930441), FRAC_CONST(-0.4434623122) }, + { FRAC_CONST(0.9882950187), FRAC_CONST(-0.1525546312) }, + { FRAC_CONST(-0.5424415469), FRAC_CONST(0.8400935531) }, + { FRAC_CONST(0.0392598175), FRAC_CONST(0.9992290139) }, + { FRAC_CONST(-0.9268565774), FRAC_CONST(0.3754155636) }, + { FRAC_CONST(-0.9741733670), FRAC_CONST(-0.2258012742) } +}; + +/* RE(Phi_Fract_SubQmf34[j]) = (float)cos(M_PI*f_center_34[j]*0.39); */ +/* IM(Phi_Fract_SubQmf34[j]) = (float)sin(M_PI*f_center_34[j]*0.39); */ +static const complex_t Phi_Fract_SubQmf34[] = { + { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, + { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, + { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, + { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, + { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, + { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, + { FRAC_CONST(0.3387379348), FRAC_CONST(0.9408807755) }, + { FRAC_CONST(0.3387379348), FRAC_CONST(0.9408807755) }, + { FRAC_CONST(0.3387379348), FRAC_CONST(0.9408807755) }, + { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, + { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, + { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, + { FRAC_CONST(-0.7705132365), FRAC_CONST(0.6374239922) }, + { FRAC_CONST(-0.7705132365), FRAC_CONST(0.6374239922) }, + { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, + { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, + { FRAC_CONST(0.3387379348), FRAC_CONST(0.9408807755) }, + { FRAC_CONST(0.3387379348), FRAC_CONST(0.9408807755) }, + { FRAC_CONST(0.3387379348), FRAC_CONST(0.9408807755) }, + { FRAC_CONST(0.3387379348), FRAC_CONST(0.9408807755) }, + { FRAC_CONST(-0.7705132365), FRAC_CONST(0.6374239922) }, + { FRAC_CONST(-0.7705132365), FRAC_CONST(0.6374239922) }, + { FRAC_CONST(-0.8607420325), FRAC_CONST(-0.5090414286) }, + { FRAC_CONST(0.3387379348), FRAC_CONST(0.9408807755) }, + { FRAC_CONST(0.1873813123), FRAC_CONST(-0.9822872281) }, + { FRAC_CONST(-0.7705132365), FRAC_CONST(0.6374239922) }, + { FRAC_CONST(-0.8607420325), FRAC_CONST(-0.5090414286) }, + { FRAC_CONST(-0.8607420325), FRAC_CONST(-0.5090414286) }, + { FRAC_CONST(0.1873813123), FRAC_CONST(-0.9822872281) }, + { FRAC_CONST(0.1873813123), FRAC_CONST(-0.9822872281) }, + { FRAC_CONST(0.9876883626), FRAC_CONST(-0.1564344615) }, + { FRAC_CONST(-0.8607420325), FRAC_CONST(-0.5090414286) } +}; + +/* RE(Q_Fract_allpass_Qmf[j][i]) = (float)cos(M_PI*(j+0.5)*(frac_delay_q[i])); */ +/* IM(Q_Fract_allpass_Qmf[j][i]) = (float)sin(M_PI*(j+0.5)*(frac_delay_q[i])); */ +static const complex_t Q_Fract_allpass_Qmf[][3] = { + { { FRAC_CONST(0.7804303765), FRAC_CONST(0.6252426505) }, { FRAC_CONST(0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(0.8550928831), FRAC_CONST(0.5184748173) } }, + { { FRAC_CONST(-0.4399392009), FRAC_CONST(0.8980275393) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(-0.0643581524), FRAC_CONST(0.9979268909) } }, + { { FRAC_CONST(-0.9723699093), FRAC_CONST(-0.2334454209) }, { FRAC_CONST(0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(-0.9146071672), FRAC_CONST(0.4043435752) } }, + { { FRAC_CONST(0.0157073960), FRAC_CONST(-0.9998766184) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(-0.7814115286), FRAC_CONST(-0.6240159869) } }, + { { FRAC_CONST(0.9792228341), FRAC_CONST(-0.2027871907) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(0.1920081824), FRAC_CONST(-0.9813933372) } }, + { { FRAC_CONST(0.4115142524), FRAC_CONST(0.9114032984) }, { FRAC_CONST(0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(0.9589683414), FRAC_CONST(-0.2835132182) } }, + { { FRAC_CONST(-0.7996847630), FRAC_CONST(0.6004201174) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(0.6947838664), FRAC_CONST(0.7192186117) } }, + { { FRAC_CONST(-0.7604058385), FRAC_CONST(-0.6494481564) }, { FRAC_CONST(0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(-0.3164770305), FRAC_CONST(0.9486001730) } }, + { { FRAC_CONST(0.4679299891), FRAC_CONST(-0.8837655187) }, { FRAC_CONST(0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(-0.9874414206), FRAC_CONST(0.1579856575) } }, + { { FRAC_CONST(0.9645573497), FRAC_CONST(0.2638732493) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(-0.5966450572), FRAC_CONST(-0.8025052547) } }, + { { FRAC_CONST(-0.0471066870), FRAC_CONST(0.9988898635) }, { FRAC_CONST(0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(0.4357025325), FRAC_CONST(-0.9000906944) } }, + { { FRAC_CONST(-0.9851093888), FRAC_CONST(0.1719288528) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(0.9995546937), FRAC_CONST(-0.0298405960) } }, + { { FRAC_CONST(-0.3826831877), FRAC_CONST(-0.9238796234) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(0.4886211455), FRAC_CONST(0.8724960685) } }, + { { FRAC_CONST(0.8181498647), FRAC_CONST(-0.5750049949) }, { FRAC_CONST(0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(-0.5477093458), FRAC_CONST(0.8366686702) } }, + { { FRAC_CONST(0.7396308780), FRAC_CONST(0.6730127335) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(-0.9951074123), FRAC_CONST(-0.0987988561) } }, + { { FRAC_CONST(-0.4954589605), FRAC_CONST(0.8686313629) }, { FRAC_CONST(0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(-0.3725017905), FRAC_CONST(-0.9280315042) } }, + { { FRAC_CONST(-0.9557929039), FRAC_CONST(-0.2940406799) }, { FRAC_CONST(0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(0.6506417990), FRAC_CONST(-0.7593847513) } }, + { { FRAC_CONST(0.0784594864), FRAC_CONST(-0.9969173074) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(0.9741733670), FRAC_CONST(0.2258014232) } }, + { { FRAC_CONST(0.9900237322), FRAC_CONST(-0.1409008205) }, { FRAC_CONST(0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(0.2502108514), FRAC_CONST(0.9681913853) } }, + { { FRAC_CONST(0.3534744382), FRAC_CONST(0.9354441762) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(-0.7427945137), FRAC_CONST(0.6695194840) } }, + { { FRAC_CONST(-0.8358076215), FRAC_CONST(0.5490224361) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(-0.9370992780), FRAC_CONST(-0.3490629196) } }, + { { FRAC_CONST(-0.7181259394), FRAC_CONST(-0.6959131360) }, { FRAC_CONST(0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(-0.1237744763), FRAC_CONST(-0.9923103452) } }, + { { FRAC_CONST(0.5224990249), FRAC_CONST(-0.8526399136) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(0.8226406574), FRAC_CONST(-0.5685616732) } }, + { { FRAC_CONST(0.9460852146), FRAC_CONST(0.3239179254) }, { FRAC_CONST(0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(0.8844994903), FRAC_CONST(0.4665412009) } }, + { { FRAC_CONST(-0.1097348556), FRAC_CONST(0.9939609170) }, { FRAC_CONST(0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(-0.0047125919), FRAC_CONST(0.9999889135) } }, + { { FRAC_CONST(-0.9939610362), FRAC_CONST(0.1097337380) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(-0.8888573647), FRAC_CONST(0.4581840038) } }, + { { FRAC_CONST(-0.3239168525), FRAC_CONST(-0.9460855722) }, { FRAC_CONST(0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(-0.8172453642), FRAC_CONST(-0.5762898922) } }, + { { FRAC_CONST(0.8526405096), FRAC_CONST(-0.5224980116) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(0.1331215799), FRAC_CONST(-0.9910997152) } }, + { { FRAC_CONST(0.6959123611), FRAC_CONST(0.7181267142) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(0.9403476119), FRAC_CONST(-0.3402152061) } }, + { { FRAC_CONST(-0.5490233898), FRAC_CONST(0.8358070254) }, { FRAC_CONST(0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(0.7364512086), FRAC_CONST(0.6764906645) } }, + { { FRAC_CONST(-0.9354437590), FRAC_CONST(-0.3534754813) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(-0.2593250275), FRAC_CONST(0.9657900929) } }, + { { FRAC_CONST(0.1409019381), FRAC_CONST(-0.9900235534) }, { FRAC_CONST(0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(-0.9762582779), FRAC_CONST(0.2166097313) } }, + { { FRAC_CONST(0.9969173670), FRAC_CONST(-0.0784583688) }, { FRAC_CONST(0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(-0.6434556246), FRAC_CONST(-0.7654833794) } }, + { { FRAC_CONST(0.2940396070), FRAC_CONST(0.9557932615) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(0.3812320232), FRAC_CONST(-0.9244794250) } }, + { { FRAC_CONST(-0.8686318994), FRAC_CONST(0.4954580069) }, { FRAC_CONST(0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(0.9959943891), FRAC_CONST(-0.0894154981) } }, + { { FRAC_CONST(-0.6730118990), FRAC_CONST(-0.7396316528) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(0.5397993922), FRAC_CONST(0.8417937160) } }, + { { FRAC_CONST(0.5750059485), FRAC_CONST(-0.8181492686) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(-0.4968227744), FRAC_CONST(0.8678520322) } }, + { { FRAC_CONST(0.9238792062), FRAC_CONST(0.3826842010) }, { FRAC_CONST(0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(-0.9992290139), FRAC_CONST(-0.0392601527) } }, + { { FRAC_CONST(-0.1719299555), FRAC_CONST(0.9851091504) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(-0.4271997511), FRAC_CONST(-0.9041572809) } }, + { { FRAC_CONST(-0.9988899231), FRAC_CONST(0.0471055657) }, { FRAC_CONST(0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(0.6041822433), FRAC_CONST(-0.7968461514) } }, + { { FRAC_CONST(-0.2638721764), FRAC_CONST(-0.9645576477) }, { FRAC_CONST(0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(0.9859085083), FRAC_CONST(0.1672853529) } }, + { { FRAC_CONST(0.8837660551), FRAC_CONST(-0.4679289758) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(0.3075223565), FRAC_CONST(0.9515408874) } }, + { { FRAC_CONST(0.6494473219), FRAC_CONST(0.7604066133) }, { FRAC_CONST(0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(-0.7015317082), FRAC_CONST(0.7126382589) } }, + { { FRAC_CONST(-0.6004210114), FRAC_CONST(0.7996840477) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(-0.9562535882), FRAC_CONST(-0.2925389707) } }, + { { FRAC_CONST(-0.9114028811), FRAC_CONST(-0.4115152657) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(-0.1827499419), FRAC_CONST(-0.9831594229) } }, + { { FRAC_CONST(0.2027882934), FRAC_CONST(-0.9792225957) }, { FRAC_CONST(0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(0.7872582674), FRAC_CONST(-0.6166234016) } }, + { { FRAC_CONST(0.9998766780), FRAC_CONST(-0.0157062728) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(0.9107555747), FRAC_CONST(0.4129458666) } }, + { { FRAC_CONST(0.2334443331), FRAC_CONST(0.9723701477) }, { FRAC_CONST(0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(0.0549497530), FRAC_CONST(0.9984891415) } }, + { { FRAC_CONST(-0.8980280757), FRAC_CONST(0.4399381876) }, { FRAC_CONST(0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(-0.8599416018), FRAC_CONST(0.5103924870) } }, + { { FRAC_CONST(-0.6252418160), FRAC_CONST(-0.7804310918) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(-0.8501682281), FRAC_CONST(-0.5265110731) } }, + { { FRAC_CONST(0.6252435446), FRAC_CONST(-0.7804297209) }, { FRAC_CONST(0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(0.0737608299), FRAC_CONST(-0.9972759485) } }, + { { FRAC_CONST(0.8980270624), FRAC_CONST(0.4399402142) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(0.9183775187), FRAC_CONST(-0.3957053721) } }, + { { FRAC_CONST(-0.2334465086), FRAC_CONST(0.9723696709) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(0.7754954696), FRAC_CONST(0.6313531399) } }, + { { FRAC_CONST(-0.9998766184), FRAC_CONST(-0.0157085191) }, { FRAC_CONST(0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(-0.2012493610), FRAC_CONST(0.9795400500) } }, + { { FRAC_CONST(-0.2027861029), FRAC_CONST(-0.9792230725) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(-0.9615978599), FRAC_CONST(0.2744622827) } }, + { { FRAC_CONST(0.9114037752), FRAC_CONST(-0.4115132093) }, { FRAC_CONST(0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(-0.6879743338), FRAC_CONST(-0.7257350087) } }, + { { FRAC_CONST(0.6004192233), FRAC_CONST(0.7996854186) }, { FRAC_CONST(0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(0.3254036009), FRAC_CONST(-0.9455752373) } }, + { { FRAC_CONST(-0.6494490504), FRAC_CONST(0.7604051232) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(0.9888865948), FRAC_CONST(-0.1486719251) } }, + { { FRAC_CONST(-0.8837650418), FRAC_CONST(-0.4679309726) }, { FRAC_CONST(0.9238795042), FRAC_CONST(-0.3826834261) }, { FRAC_CONST(0.5890548825), FRAC_CONST(0.8080930114) } }, + { { FRAC_CONST(0.2638743520), FRAC_CONST(-0.9645570517) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(0.9238795042) }, { FRAC_CONST(-0.4441666007), FRAC_CONST(0.8959442377) } }, + { { FRAC_CONST(0.9988898039), FRAC_CONST(0.0471078083) }, { FRAC_CONST(-0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(-0.9997915030), FRAC_CONST(0.0204183888) } }, + { { FRAC_CONST(0.1719277352), FRAC_CONST(0.9851095676) }, { FRAC_CONST(0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(-0.4803760946), FRAC_CONST(-0.8770626187) } }, + { { FRAC_CONST(-0.9238800406), FRAC_CONST(0.3826821446) }, { FRAC_CONST(-0.9238795042), FRAC_CONST(0.3826834261) }, { FRAC_CONST(0.5555707216), FRAC_CONST(-0.8314692974) } }, + { { FRAC_CONST(-0.5750041008), FRAC_CONST(-0.8181505203) }, { FRAC_CONST(0.3826834261), FRAC_CONST(-0.9238795042) }, { FRAC_CONST(0.9941320419), FRAC_CONST(0.1081734300) } } +}; + +/* RE(Q_Fract_allpass_SubQmf20[j][i]) = (float)cos(M_PI*f_center_20[j]*frac_delay_q[i]); */ +/* IM(Q_Fract_allpass_SubQmf20[j][i]) = (float)sin(M_PI*f_center_20[j]*frac_delay_q[i]); */ +static const complex_t Q_Fract_allpass_SubQmf20[][3] = { + { { FRAC_CONST(0.9857769012), FRAC_CONST(0.1680592746) }, { FRAC_CONST(0.9569403529), FRAC_CONST(0.2902846634) }, { FRAC_CONST(0.9907300472), FRAC_CONST(0.1358452588) } }, + { { FRAC_CONST(0.8744080663), FRAC_CONST(0.4851911962) }, { FRAC_CONST(0.6343932748), FRAC_CONST(0.7730104327) }, { FRAC_CONST(0.9175986052), FRAC_CONST(0.3975082636) } }, + { { FRAC_CONST(0.6642524004), FRAC_CONST(0.7475083470) }, { FRAC_CONST(0.0980171412), FRAC_CONST(0.9951847196) }, { FRAC_CONST(0.7767338753), FRAC_CONST(0.6298289299) } }, + { { FRAC_CONST(0.3790524006), FRAC_CONST(0.9253752232) }, { FRAC_CONST(-0.4713967443), FRAC_CONST(0.8819212914) }, { FRAC_CONST(0.5785340071), FRAC_CONST(0.8156582713) } }, + { { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) } }, + { { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) } }, + { { FRAC_CONST(0.8744080663), FRAC_CONST(-0.4851911962) }, { FRAC_CONST(0.6343932748), FRAC_CONST(-0.7730104327) }, { FRAC_CONST(0.9175986052), FRAC_CONST(-0.3975082636) } }, + { { FRAC_CONST(0.9857769012), FRAC_CONST(-0.1680592746) }, { FRAC_CONST(0.9569403529), FRAC_CONST(-0.2902846634) }, { FRAC_CONST(0.9907300472), FRAC_CONST(-0.1358452588) } }, + { { FRAC_CONST(-0.7126385570), FRAC_CONST(0.7015314102) }, { FRAC_CONST(-0.5555702448), FRAC_CONST(-0.8314695954) }, { FRAC_CONST(-0.3305967748), FRAC_CONST(0.9437720776) } }, + { { FRAC_CONST(-0.1175374240), FRAC_CONST(0.9930684566) }, { FRAC_CONST(-0.9807852507), FRAC_CONST(0.1950903237) }, { FRAC_CONST(0.2066311091), FRAC_CONST(0.9784189463) } }, + { { FRAC_CONST(-0.9947921634), FRAC_CONST(0.1019244045) }, { FRAC_CONST(0.5555702448), FRAC_CONST(-0.8314695954) }, { FRAC_CONST(-0.7720130086), FRAC_CONST(0.6356067061) } }, + { { FRAC_CONST(-0.8400934935), FRAC_CONST(-0.5424416065) }, { FRAC_CONST(0.9807852507), FRAC_CONST(0.1950903237) }, { FRAC_CONST(-0.9896889329), FRAC_CONST(0.1432335079) } } +}; + +/* RE(Q_Fract_allpass_SubQmf34[j][i]) = (float)cos(M_PI*f_center_34[j]*frac_delay_q[i]); */ +/* IM(Q_Fract_allpass_SubQmf34[j][i]) = (float)sin(M_PI*f_center_34[j]*frac_delay_q[i]); */ +static const complex_t Q_Fract_allpass_SubQmf34[][3] = { + { { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) } }, + { { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) } }, + { { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) } }, + { { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) } }, + { { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) } }, + { { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) } }, + { { FRAC_CONST(0.2181432247), FRAC_CONST(0.9759167433) }, { FRAC_CONST(-0.7071067691), FRAC_CONST(0.7071067691) }, { FRAC_CONST(0.4623677433), FRAC_CONST(0.8866882324) } }, + { { FRAC_CONST(0.2181432247), FRAC_CONST(0.9759167433) }, { FRAC_CONST(-0.7071067691), FRAC_CONST(0.7071067691) }, { FRAC_CONST(0.4623677433), FRAC_CONST(0.8866882324) } }, + { { FRAC_CONST(0.2181432247), FRAC_CONST(0.9759167433) }, { FRAC_CONST(-0.7071067691), FRAC_CONST(0.7071067691) }, { FRAC_CONST(0.4623677433), FRAC_CONST(0.8866882324) } }, + { { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) } }, + { { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) } }, + { { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) } }, + { { FRAC_CONST(-0.9048270583), FRAC_CONST(0.4257792532) }, { FRAC_CONST(-0.0000000000), FRAC_CONST(-1.0000000000) }, { FRAC_CONST(-0.5724321604), FRAC_CONST(0.8199520707) } }, + { { FRAC_CONST(-0.9048270583), FRAC_CONST(0.4257792532) }, { FRAC_CONST(-0.0000000000), FRAC_CONST(-1.0000000000) }, { FRAC_CONST(-0.5724321604), FRAC_CONST(0.8199520707) } }, + { { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) } }, + { { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(1.0000000000), FRAC_CONST(0.0000000000) } }, + { { FRAC_CONST(0.2181432247), FRAC_CONST(0.9759167433) }, { FRAC_CONST(-0.7071067691), FRAC_CONST(0.7071067691) }, { FRAC_CONST(0.4623677433), FRAC_CONST(0.8866882324) } }, + { { FRAC_CONST(0.2181432247), FRAC_CONST(0.9759167433) }, { FRAC_CONST(-0.7071067691), FRAC_CONST(0.7071067691) }, { FRAC_CONST(0.4623677433), FRAC_CONST(0.8866882324) } }, + { { FRAC_CONST(0.2181432247), FRAC_CONST(0.9759167433) }, { FRAC_CONST(-0.7071067691), FRAC_CONST(0.7071067691) }, { FRAC_CONST(0.4623677433), FRAC_CONST(0.8866882324) } }, + { { FRAC_CONST(0.2181432247), FRAC_CONST(0.9759167433) }, { FRAC_CONST(-0.7071067691), FRAC_CONST(0.7071067691) }, { FRAC_CONST(0.4623677433), FRAC_CONST(0.8866882324) } }, + { { FRAC_CONST(-0.9048270583), FRAC_CONST(0.4257792532) }, { FRAC_CONST(-0.0000000000), FRAC_CONST(-1.0000000000) }, { FRAC_CONST(-0.5724321604), FRAC_CONST(0.8199520707) } }, + { { FRAC_CONST(-0.9048270583), FRAC_CONST(0.4257792532) }, { FRAC_CONST(-0.0000000000), FRAC_CONST(-1.0000000000) }, { FRAC_CONST(-0.5724321604), FRAC_CONST(0.8199520707) } }, + { { FRAC_CONST(-0.6129069924), FRAC_CONST(-0.7901550531) }, { FRAC_CONST(0.7071067691), FRAC_CONST(0.7071067691) }, { FRAC_CONST(-0.9917160273), FRAC_CONST(-0.1284494549) } }, + { { FRAC_CONST(0.2181432247), FRAC_CONST(0.9759167433) }, { FRAC_CONST(-0.7071067691), FRAC_CONST(0.7071067691) }, { FRAC_CONST(0.4623677433), FRAC_CONST(0.8866882324) } }, + { { FRAC_CONST(0.6374240518), FRAC_CONST(-0.7705131769) }, { FRAC_CONST(-1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(-0.3446428776), FRAC_CONST(-0.9387338758) } }, + { { FRAC_CONST(-0.9048270583), FRAC_CONST(0.4257792532) }, { FRAC_CONST(-0.0000000000), FRAC_CONST(-1.0000000000) }, { FRAC_CONST(-0.5724321604), FRAC_CONST(0.8199520707) } }, + { { FRAC_CONST(-0.6129069924), FRAC_CONST(-0.7901550531) }, { FRAC_CONST(0.7071067691), FRAC_CONST(0.7071067691) }, { FRAC_CONST(-0.9917160273), FRAC_CONST(-0.1284494549) } }, + { { FRAC_CONST(-0.6129069924), FRAC_CONST(-0.7901550531) }, { FRAC_CONST(0.7071067691), FRAC_CONST(0.7071067691) }, { FRAC_CONST(-0.9917160273), FRAC_CONST(-0.1284494549) } }, + { { FRAC_CONST(0.6374240518), FRAC_CONST(-0.7705131769) }, { FRAC_CONST(-1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(-0.3446428776), FRAC_CONST(-0.9387338758) } }, + { { FRAC_CONST(0.6374240518), FRAC_CONST(-0.7705131769) }, { FRAC_CONST(-1.0000000000), FRAC_CONST(0.0000000000) }, { FRAC_CONST(-0.3446428776), FRAC_CONST(-0.9387338758) } }, + { { FRAC_CONST(0.8910064697), FRAC_CONST(0.4539906085) }, { FRAC_CONST(0.7071067691), FRAC_CONST(-0.7071067691) }, { FRAC_CONST(0.6730125546), FRAC_CONST(-0.7396310568) } }, + { { FRAC_CONST(-0.6129069924), FRAC_CONST(-0.7901550531) }, { FRAC_CONST(0.7071067691), FRAC_CONST(0.7071067691) }, { FRAC_CONST(-0.9917160273), FRAC_CONST(-0.1284494549) } } +}; + +#if 0 +static float quant_rho[8] = +{ + FRAC_CONST(1.0), FRAC_CONST(0.937), FRAC_CONST(0.84118), FRAC_CONST(0.60092), + FRAC_CONST(0.36764), FRAC_CONST(0.0), FRAC_CONST(-0.589), FRAC_CONST(-1.0) +}; + +static const uint8_t quant_iid_normal[7] = +{ + 2, 4, 7, 10, 14, 18, 25 +}; + +static const uint8_t quant_iid_fine[15] = +{ + 2, 4, 6, 8, 10, 13, 16, 19, 22, 25, 30, 35, 40, 45, 50 +}; +#endif + +static const real_t cos_alphas[] = { + COEF_CONST(1.0000000000), COEF_CONST(0.9841239700), COEF_CONST(0.9594738210), + COEF_CONST(0.8946843079), COEF_CONST(0.8269340931), COEF_CONST(0.7071067812), + COEF_CONST(0.4533210856), COEF_CONST(0.0000000000) +}; + +static const real_t sin_alphas[] = { + COEF_CONST(0.0000000000), COEF_CONST(0.1774824264), COEF_CONST(0.2817977763), + COEF_CONST(0.4466989918), COEF_CONST(0.5622988580), COEF_CONST(0.7071067812), + COEF_CONST(0.8913472911), COEF_CONST(1.0000000000) +}; + +static const real_t cos_betas_normal[][8] = { + { COEF_CONST(1.0000000000), COEF_CONST(1.0000000000), COEF_CONST(1.0000000000), COEF_CONST(1.0000000000), COEF_CONST(1.0000000000), COEF_CONST(1.0000000000), COEF_CONST(1.0000000000), COEF_CONST(1.0000000000) }, + { COEF_CONST(1.0000000000), COEF_CONST(0.9995871699), COEF_CONST(0.9989419133), COEF_CONST(0.9972204583), COEF_CONST(0.9953790839), COEF_CONST(0.9920112747), COEF_CONST(0.9843408180), COEF_CONST(0.9681727381) }, + { COEF_CONST(1.0000000000), COEF_CONST(0.9984497744), COEF_CONST(0.9960279377), COEF_CONST(0.9895738413), COEF_CONST(0.9826814632), COEF_CONST(0.9701058164), COEF_CONST(0.9416098832), COEF_CONST(0.8822105900) }, + { COEF_CONST(1.0000000000), COEF_CONST(0.9959398908), COEF_CONST(0.9896038018), COEF_CONST(0.9727589768), COEF_CONST(0.9548355329), COEF_CONST(0.9223070404), COEF_CONST(0.8494349490), COEF_CONST(0.7013005535) }, + { COEF_CONST(1.0000000000), COEF_CONST(0.9932417400), COEF_CONST(0.9827071856), COEF_CONST(0.9547730996), COEF_CONST(0.9251668930), COEF_CONST(0.8717461589), COEF_CONST(0.7535520592), COEF_CONST(0.5198827312) }, + { COEF_CONST(1.0000000000), COEF_CONST(0.9902068095), COEF_CONST(0.9749613872), COEF_CONST(0.9346538534), COEF_CONST(0.8921231300), COEF_CONST(0.8158851259), COEF_CONST(0.6495964302), COEF_CONST(0.3313370772) }, + { COEF_CONST(1.0000000000), COEF_CONST(0.9880510933), COEF_CONST(0.9694670261), COEF_CONST(0.9204347876), COEF_CONST(0.8688622825), COEF_CONST(0.7768516704), COEF_CONST(0.5782161800), COEF_CONST(0.2069970356) }, + { COEF_CONST(1.0000000000), COEF_CONST(0.9858996945), COEF_CONST(0.9639898866), COEF_CONST(0.9063034786), COEF_CONST(0.8458214608), COEF_CONST(0.7384262300), COEF_CONST(0.5089811277), COEF_CONST(0.0905465944) } +}; + +static const real_t sin_betas_normal[][8] = { + { COEF_CONST(0.0000000000), COEF_CONST(0.0000000000), COEF_CONST(0.0000000000), COEF_CONST(0.0000000000), COEF_CONST(0.0000000000), COEF_CONST(0.0000000000), COEF_CONST(0.0000000000), COEF_CONST(0.0000000000) }, + { COEF_CONST(0.0000000000), COEF_CONST(-0.0287313368), COEF_CONST(-0.0459897147), COEF_CONST(-0.0745074328), COEF_CONST(-0.0960233266), COEF_CONST(-0.1261492408), COEF_CONST(-0.1762757894), COEF_CONST(-0.2502829383) }, + { COEF_CONST(0.0000000000), COEF_CONST(-0.0556601118), COEF_CONST(-0.0890412670), COEF_CONST(-0.1440264301), COEF_CONST(-0.1853028382), COEF_CONST(-0.2426823129), COEF_CONST(-0.3367058477), COEF_CONST(-0.4708550466) }, + { COEF_CONST(0.0000000000), COEF_CONST(-0.0900207420), COEF_CONST(-0.1438204281), COEF_CONST(-0.2318188366), COEF_CONST(-0.2971348264), COEF_CONST(-0.3864579191), COEF_CONST(-0.5276933461), COEF_CONST(-0.7128657193) }, + { COEF_CONST(0.0000000000), COEF_CONST(-0.1160639735), COEF_CONST(-0.1851663774), COEF_CONST(-0.2973353800), COEF_CONST(-0.3795605619), COEF_CONST(-0.4899577884), COEF_CONST(-0.6573882369), COEF_CONST(-0.8542376401) }, + { COEF_CONST(0.0000000000), COEF_CONST(-0.1396082894), COEF_CONST(-0.2223742196), COEF_CONST(-0.3555589603), COEF_CONST(-0.4517923427), COEF_CONST(-0.5782140273), COEF_CONST(-0.7602792104), COEF_CONST(-0.9435124489) }, + { COEF_CONST(0.0000000000), COEF_CONST(-0.1541266914), COEF_CONST(-0.2452217065), COEF_CONST(-0.3908961522), COEF_CONST(-0.4950538699), COEF_CONST(-0.6296836366), COEF_CONST(-0.8158836002), COEF_CONST(-0.9783415698) }, + { COEF_CONST(0.0000000000), COEF_CONST(-0.1673373610), COEF_CONST(-0.2659389001), COEF_CONST(-0.4226275012), COEF_CONST(-0.5334660781), COEF_CONST(-0.6743342664), COEF_CONST(-0.8607776784), COEF_CONST(-0.9958922202) } +}; + +static const real_t cos_betas_fine[][8] = { + { COEF_CONST(1.0000000000), COEF_CONST(1.0000000000), COEF_CONST(1.0000000000), COEF_CONST(1.0000000000), COEF_CONST(1.0000000000), COEF_CONST(1.0000000000), COEF_CONST(1.0000000000), COEF_CONST(1.0000000000) }, + { COEF_CONST(1.0000000000), COEF_CONST(0.9995871699), COEF_CONST(0.9989419133), COEF_CONST(0.9972204583), COEF_CONST(0.9953790839), COEF_CONST(0.9920112747), COEF_CONST(0.9843408180), COEF_CONST(0.9681727381) }, + { COEF_CONST(1.0000000000), COEF_CONST(0.9984497744), COEF_CONST(0.9960279377), COEF_CONST(0.9895738413), COEF_CONST(0.9826814632), COEF_CONST(0.9701058164), COEF_CONST(0.9416098832), COEF_CONST(0.8822105900) }, + { COEF_CONST(1.0000000000), COEF_CONST(0.9968361371), COEF_CONST(0.9918968104), COEF_CONST(0.9787540479), COEF_CONST(0.9647515190), COEF_CONST(0.9392903010), COEF_CONST(0.8820167114), COEF_CONST(0.7645325390) }, + { COEF_CONST(1.0000000000), COEF_CONST(0.9950262915), COEF_CONST(0.9872675041), COEF_CONST(0.9666584578), COEF_CONST(0.9447588606), COEF_CONST(0.9050918405), COEF_CONST(0.8165997379), COEF_CONST(0.6383824796) }, + { COEF_CONST(1.0000000000), COEF_CONST(0.9932417400), COEF_CONST(0.9827071856), COEF_CONST(0.9547730996), COEF_CONST(0.9251668930), COEF_CONST(0.8717461589), COEF_CONST(0.7535520592), COEF_CONST(0.5198827312) }, + { COEF_CONST(1.0000000000), COEF_CONST(0.9908827998), COEF_CONST(0.9766855904), COEF_CONST(0.9391249214), COEF_CONST(0.8994531782), COEF_CONST(0.8282352693), COEF_CONST(0.6723983174), COEF_CONST(0.3719473225) }, + { COEF_CONST(1.0000000000), COEF_CONST(0.9890240165), COEF_CONST(0.9719459866), COEF_CONST(0.9268448110), COEF_CONST(0.8793388536), COEF_CONST(0.7944023271), COEF_CONST(0.6101812098), COEF_CONST(0.2621501145) }, + { COEF_CONST(1.0000000000), COEF_CONST(0.9876350461), COEF_CONST(0.9684073447), COEF_CONST(0.9176973944), COEF_CONST(0.8643930070), COEF_CONST(0.7693796058), COEF_CONST(0.5646720713), COEF_CONST(0.1838899556) }, + { COEF_CONST(1.0000000000), COEF_CONST(0.9866247085), COEF_CONST(0.9658349704), COEF_CONST(0.9110590761), COEF_CONST(0.8535668048), COEF_CONST(0.7513165426), COEF_CONST(0.5320914819), COEF_CONST(0.1289530943) }, + { COEF_CONST(1.0000000000), COEF_CONST(0.9858996945), COEF_CONST(0.9639898866), COEF_CONST(0.9063034786), COEF_CONST(0.8458214608), COEF_CONST(0.7384262300), COEF_CONST(0.5089811277), COEF_CONST(0.0905465944) }, + { COEF_CONST(1.0000000000), COEF_CONST(0.9851245614), COEF_CONST(0.9620180268), COEF_CONST(0.9012265590), COEF_CONST(0.8375623272), COEF_CONST(0.7247108045), COEF_CONST(0.4845204297), COEF_CONST(0.0504115003) }, + { COEF_CONST(1.0000000000), COEF_CONST(0.9846869856), COEF_CONST(0.9609052357), COEF_CONST(0.8983639533), COEF_CONST(0.8329098386), COEF_CONST(0.7169983441), COEF_CONST(0.4708245354), COEF_CONST(0.0281732509) }, + { COEF_CONST(1.0000000000), COEF_CONST(0.9844406325), COEF_CONST(0.9602788522), COEF_CONST(0.8967533934), COEF_CONST(0.8302936455), COEF_CONST(0.7126658102), COEF_CONST(0.4631492839), COEF_CONST(0.0157851140) }, + { COEF_CONST(1.0000000000), COEF_CONST(0.9843020502), COEF_CONST(0.9599265269), COEF_CONST(0.8958477331), COEF_CONST(0.8288229094), COEF_CONST(0.7102315840), COEF_CONST(0.4588429315), COEF_CONST(0.0088578059) }, + { COEF_CONST(1.0000000000), COEF_CONST(0.9842241136), COEF_CONST(0.9597283916), COEF_CONST(0.8953385094), COEF_CONST(0.8279961409), COEF_CONST(0.7088635748), COEF_CONST(0.4564246834), COEF_CONST(0.0049751355) } +}; + +static const real_t sin_betas_fine[][8] = { + { COEF_CONST(0.0000000000), COEF_CONST(0.0000000000), COEF_CONST(0.0000000000), COEF_CONST(0.0000000000), COEF_CONST(0.0000000000), COEF_CONST(0.0000000000), COEF_CONST(0.0000000000), COEF_CONST(0.0000000000) }, + { COEF_CONST(0.0000000000), COEF_CONST(-0.0287313368), COEF_CONST(-0.0459897147), COEF_CONST(-0.0745074328), COEF_CONST(-0.0960233266), COEF_CONST(-0.1261492408), COEF_CONST(-0.1762757894), COEF_CONST(-0.2502829383) }, + { COEF_CONST(0.0000000000), COEF_CONST(-0.0556601118), COEF_CONST(-0.0890412670), COEF_CONST(-0.1440264301), COEF_CONST(-0.1853028382), COEF_CONST(-0.2426823129), COEF_CONST(-0.3367058477), COEF_CONST(-0.4708550466) }, + { COEF_CONST(0.0000000000), COEF_CONST(-0.0794840594), COEF_CONST(-0.1270461238), COEF_CONST(-0.2050378347), COEF_CONST(-0.2631625097), COEF_CONST(-0.3431234916), COEF_CONST(-0.4712181245), COEF_CONST(-0.6445851354) }, + { COEF_CONST(0.0000000000), COEF_CONST(-0.0996126459), COEF_CONST(-0.1590687758), COEF_CONST(-0.2560691819), COEF_CONST(-0.3277662204), COEF_CONST(-0.4252161335), COEF_CONST(-0.5772043556), COEF_CONST(-0.7697193058) }, + { COEF_CONST(0.0000000000), COEF_CONST(-0.1160639735), COEF_CONST(-0.1851663774), COEF_CONST(-0.2973353800), COEF_CONST(-0.3795605619), COEF_CONST(-0.4899577884), COEF_CONST(-0.6573882369), COEF_CONST(-0.8542376401) }, + { COEF_CONST(0.0000000000), COEF_CONST(-0.1347266752), COEF_CONST(-0.2146747714), COEF_CONST(-0.3435758752), COEF_CONST(-0.4370171396), COEF_CONST(-0.5603805303), COEF_CONST(-0.7401895046), COEF_CONST(-0.9282538388) }, + { COEF_CONST(0.0000000000), COEF_CONST(-0.1477548470), COEF_CONST(-0.2352041647), COEF_CONST(-0.3754446647), COEF_CONST(-0.4761965776), COEF_CONST(-0.6073919186), COEF_CONST(-0.7922618830), COEF_CONST(-0.9650271071) }, + { COEF_CONST(0.0000000000), COEF_CONST(-0.1567705832), COEF_CONST(-0.2493736450), COEF_CONST(-0.3972801182), COEF_CONST(-0.5028167951), COEF_CONST(-0.6387918458), COEF_CONST(-0.8253153651), COEF_CONST(-0.9829468369) }, + { COEF_CONST(0.0000000000), COEF_CONST(-0.1630082348), COEF_CONST(-0.2591578860), COEF_CONST(-0.4122758299), COEF_CONST(-0.5209834064), COEF_CONST(-0.6599420072), COEF_CONST(-0.8466868694), COEF_CONST(-0.9916506943) }, + { COEF_CONST(0.0000000000), COEF_CONST(-0.1673373610), COEF_CONST(-0.2659389001), COEF_CONST(-0.4226275012), COEF_CONST(-0.5334660781), COEF_CONST(-0.6743342664), COEF_CONST(-0.8607776784), COEF_CONST(-0.9958922202) }, + { COEF_CONST(0.0000000000), COEF_CONST(-0.1718417832), COEF_CONST(-0.2729859267), COEF_CONST(-0.4333482310), COEF_CONST(-0.5463417868), COEF_CONST(-0.6890531546), COEF_CONST(-0.8747799456), COEF_CONST(-0.9987285320) }, + { COEF_CONST(0.0000000000), COEF_CONST(-0.1743316967), COEF_CONST(-0.2768774604), COEF_CONST(-0.4392518725), COEF_CONST(-0.5534087104), COEF_CONST(-0.6970748701), COEF_CONST(-0.8822268738), COEF_CONST(-0.9996030552) }, + { COEF_CONST(0.0000000000), COEF_CONST(-0.1757175038), COEF_CONST(-0.2790421580), COEF_CONST(-0.4425306221), COEF_CONST(-0.5573261722), COEF_CONST(-0.7015037013), COEF_CONST(-0.8862802834), COEF_CONST(-0.9998754073) }, + { COEF_CONST(0.0000000000), COEF_CONST(-0.1764921355), COEF_CONST(-0.2802517850), COEF_CONST(-0.4443611583), COEF_CONST(-0.5595110229), COEF_CONST(-0.7039681080), COEF_CONST(-0.8885173967), COEF_CONST(-0.9999607689) }, + { COEF_CONST(0.0000000000), COEF_CONST(-0.1769262394), COEF_CONST(-0.2809295540), COEF_CONST(-0.4453862969), COEF_CONST(-0.5607337966), COEF_CONST(-0.7053456119), COEF_CONST(-0.8897620516), COEF_CONST(-0.9999876239) } +}; + +static const real_t sincos_alphas_B_normal[][8] = { + { COEF_CONST(0.0561454100), COEF_CONST(0.0526385859), COEF_CONST(0.0472937334), COEF_CONST(0.0338410641), COEF_CONST(0.0207261065), COEF_CONST(0.0028205635), COEF_CONST(0.0028205635), COEF_CONST(0.0028205635) }, + { COEF_CONST(0.1249065138), COEF_CONST(0.1173697697), COEF_CONST(0.1057888284), COEF_CONST(0.0761985131), COEF_CONST(0.0468732723), COEF_CONST(0.0063956103), COEF_CONST(0.0063956103), COEF_CONST(0.0063956103) }, + { COEF_CONST(0.1956693050), COEF_CONST(0.1846090179), COEF_CONST(0.1673645109), COEF_CONST(0.1220621836), COEF_CONST(0.0757362479), COEF_CONST(0.0103882630), COEF_CONST(0.0103882630), COEF_CONST(0.0103882630) }, + { COEF_CONST(0.3015113269), COEF_CONST(0.2870525790), COEF_CONST(0.2637738799), COEF_CONST(0.1984573949), COEF_CONST(0.1260749909), COEF_CONST(0.0175600126), COEF_CONST(0.0175600126), COEF_CONST(0.0175600126) }, + { COEF_CONST(0.4078449476), COEF_CONST(0.3929852420), COEF_CONST(0.3680589270), COEF_CONST(0.2911029124), COEF_CONST(0.1934512363), COEF_CONST(0.0278686716), COEF_CONST(0.0278686716), COEF_CONST(0.0278686716) }, + { COEF_CONST(0.5336171261), COEF_CONST(0.5226637762), COEF_CONST(0.5033652606), COEF_CONST(0.4349162672), COEF_CONST(0.3224682122), COEF_CONST(0.0521999036), COEF_CONST(0.0521999036), COEF_CONST(0.0521999036) }, + { COEF_CONST(0.6219832023), COEF_CONST(0.6161847276), COEF_CONST(0.6057251063), COEF_CONST(0.5654342668), COEF_CONST(0.4826149915), COEF_CONST(0.1058044758), COEF_CONST(0.1058044758), COEF_CONST(0.1058044758) }, + { COEF_CONST(0.7071067657), COEF_CONST(0.7071067657), COEF_CONST(0.7071067657), COEF_CONST(0.7071067657), COEF_CONST(0.7071067657), COEF_CONST(0.7071067657), COEF_CONST(0.7071067657), COEF_CONST(0.7071067657) }, + { COEF_CONST(0.7830305572), COEF_CONST(0.7876016373), COEF_CONST(0.7956739618), COEF_CONST(0.8247933372), COEF_CONST(0.8758325942), COEF_CONST(0.9943869542), COEF_CONST(0.9943869542), COEF_CONST(0.9943869542) }, + { COEF_CONST(0.8457261833), COEF_CONST(0.8525388778), COEF_CONST(0.8640737401), COEF_CONST(0.9004708933), COEF_CONST(0.9465802987), COEF_CONST(0.9986366532), COEF_CONST(0.9986366532), COEF_CONST(0.9986366532) }, + { COEF_CONST(0.9130511848), COEF_CONST(0.9195447612), COEF_CONST(0.9298024282), COEF_CONST(0.9566917233), COEF_CONST(0.9811098801), COEF_CONST(0.9996115928), COEF_CONST(0.9996115928), COEF_CONST(0.9996115928) }, + { COEF_CONST(0.9534625907), COEF_CONST(0.9579148236), COEF_CONST(0.9645845234), COEF_CONST(0.9801095128), COEF_CONST(0.9920207064), COEF_CONST(0.9998458099), COEF_CONST(0.9998458099), COEF_CONST(0.9998458099) }, + { COEF_CONST(0.9806699215), COEF_CONST(0.9828120260), COEF_CONST(0.9858950861), COEF_CONST(0.9925224431), COEF_CONST(0.9971278825), COEF_CONST(0.9999460406), COEF_CONST(0.9999460406), COEF_CONST(0.9999460406) }, + { COEF_CONST(0.9921685024), COEF_CONST(0.9930882705), COEF_CONST(0.9943886135), COEF_CONST(0.9970926648), COEF_CONST(0.9989008403), COEF_CONST(0.9999795479), COEF_CONST(0.9999795479), COEF_CONST(0.9999795479) }, + { COEF_CONST(0.9984226014), COEF_CONST(0.9986136287), COEF_CONST(0.9988810254), COEF_CONST(0.9994272242), COEF_CONST(0.9997851906), COEF_CONST(0.9999960221), COEF_CONST(0.9999960221), COEF_CONST(0.9999960221) } +}; + +static const real_t sincos_alphas_B_fine[][8] = { + { COEF_CONST(0.0031622158), COEF_CONST(0.0029630181), COEF_CONST(0.0026599892), COEF_CONST(0.0019002704), COEF_CONST(0.0011626042), COEF_CONST(0.0001580278), COEF_CONST(0.0001580278), COEF_CONST(0.0001580278) }, + { COEF_CONST(0.0056232673), COEF_CONST(0.0052689825), COEF_CONST(0.0047302825), COEF_CONST(0.0033791756), COEF_CONST(0.0020674015), COEF_CONST(0.0002811710), COEF_CONST(0.0002811710), COEF_CONST(0.0002811710) }, + { COEF_CONST(0.0099994225), COEF_CONST(0.0093696693), COEF_CONST(0.0084117414), COEF_CONST(0.0060093796), COEF_CONST(0.0036766009), COEF_CONST(0.0005000392), COEF_CONST(0.0005000392), COEF_CONST(0.0005000392) }, + { COEF_CONST(0.0177799194), COEF_CONST(0.0166607102), COEF_CONST(0.0149581377), COEF_CONST(0.0106875809), COEF_CONST(0.0065392545), COEF_CONST(0.0008893767), COEF_CONST(0.0008893767), COEF_CONST(0.0008893767) }, + { COEF_CONST(0.0316069684), COEF_CONST(0.0296211579), COEF_CONST(0.0265987295), COEF_CONST(0.0190113813), COEF_CONST(0.0116349973), COEF_CONST(0.0015826974), COEF_CONST(0.0015826974), COEF_CONST(0.0015826974) }, + { COEF_CONST(0.0561454100), COEF_CONST(0.0526385859), COEF_CONST(0.0472937334), COEF_CONST(0.0338410641), COEF_CONST(0.0207261065), COEF_CONST(0.0028205635), COEF_CONST(0.0028205635), COEF_CONST(0.0028205635) }, + { COEF_CONST(0.0791834041), COEF_CONST(0.0742798103), COEF_CONST(0.0667907269), COEF_CONST(0.0478705292), COEF_CONST(0.0293500747), COEF_CONST(0.0039966755), COEF_CONST(0.0039966755), COEF_CONST(0.0039966755) }, + { COEF_CONST(0.1115021177), COEF_CONST(0.1047141985), COEF_CONST(0.0943053154), COEF_CONST(0.0678120561), COEF_CONST(0.0416669150), COEF_CONST(0.0056813213), COEF_CONST(0.0056813213), COEF_CONST(0.0056813213) }, + { COEF_CONST(0.1565355066), COEF_CONST(0.1473258371), COEF_CONST(0.1330924027), COEF_CONST(0.0963282233), COEF_CONST(0.0594509113), COEF_CONST(0.0081277946), COEF_CONST(0.0081277946), COEF_CONST(0.0081277946) }, + { COEF_CONST(0.2184643682), COEF_CONST(0.2064579524), COEF_CONST(0.1876265439), COEF_CONST(0.1375744167), COEF_CONST(0.0856896681), COEF_CONST(0.0117817338), COEF_CONST(0.0117817338), COEF_CONST(0.0117817338) }, + { COEF_CONST(0.3015113269), COEF_CONST(0.2870525790), COEF_CONST(0.2637738799), COEF_CONST(0.1984573949), COEF_CONST(0.1260749909), COEF_CONST(0.0175600126), COEF_CONST(0.0175600126), COEF_CONST(0.0175600126) }, + { COEF_CONST(0.3698741335), COEF_CONST(0.3547727297), COEF_CONST(0.3298252076), COEF_CONST(0.2556265829), COEF_CONST(0.1665990017), COEF_CONST(0.0236344541), COEF_CONST(0.0236344541), COEF_CONST(0.0236344541) }, + { COEF_CONST(0.4480623975), COEF_CONST(0.4339410024), COEF_CONST(0.4098613774), COEF_CONST(0.3322709108), COEF_CONST(0.2266784729), COEF_CONST(0.0334094131), COEF_CONST(0.0334094131), COEF_CONST(0.0334094131) }, + { COEF_CONST(0.5336171261), COEF_CONST(0.5226637762), COEF_CONST(0.5033652606), COEF_CONST(0.4349162672), COEF_CONST(0.3224682122), COEF_CONST(0.0521999036), COEF_CONST(0.0521999036), COEF_CONST(0.0521999036) }, + { COEF_CONST(0.6219832023), COEF_CONST(0.6161847276), COEF_CONST(0.6057251063), COEF_CONST(0.5654342668), COEF_CONST(0.4826149915), COEF_CONST(0.1058044758), COEF_CONST(0.1058044758), COEF_CONST(0.1058044758) }, + { COEF_CONST(0.7071067657), COEF_CONST(0.7071067657), COEF_CONST(0.7071067657), COEF_CONST(0.7071067657), COEF_CONST(0.7071067657), COEF_CONST(0.7071067657), COEF_CONST(0.7071067657), COEF_CONST(0.7071067657) }, + { COEF_CONST(0.7830305572), COEF_CONST(0.7876016373), COEF_CONST(0.7956739618), COEF_CONST(0.8247933372), COEF_CONST(0.8758325942), COEF_CONST(0.9943869542), COEF_CONST(0.9943869542), COEF_CONST(0.9943869542) }, + { COEF_CONST(0.8457261833), COEF_CONST(0.8525388778), COEF_CONST(0.8640737401), COEF_CONST(0.9004708933), COEF_CONST(0.9465802987), COEF_CONST(0.9986366532), COEF_CONST(0.9986366532), COEF_CONST(0.9986366532) }, + { COEF_CONST(0.8940022267), COEF_CONST(0.9009412572), COEF_CONST(0.9121477564), COEF_CONST(0.9431839770), COEF_CONST(0.9739696219), COEF_CONST(0.9994417480), COEF_CONST(0.9994417480), COEF_CONST(0.9994417480) }, + { COEF_CONST(0.9290818561), COEF_CONST(0.9349525662), COEF_CONST(0.9440420138), COEF_CONST(0.9667755833), COEF_CONST(0.9860247275), COEF_CONST(0.9997206664), COEF_CONST(0.9997206664), COEF_CONST(0.9997206664) }, + { COEF_CONST(0.9534625907), COEF_CONST(0.9579148236), COEF_CONST(0.9645845234), COEF_CONST(0.9801095128), COEF_CONST(0.9920207064), COEF_CONST(0.9998458099), COEF_CONST(0.9998458099), COEF_CONST(0.9998458099) }, + { COEF_CONST(0.9758449068), COEF_CONST(0.9784554646), COEF_CONST(0.9822404252), COEF_CONST(0.9904914275), COEF_CONST(0.9963218730), COEF_CONST(0.9999305926), COEF_CONST(0.9999305926), COEF_CONST(0.9999305926) }, + { COEF_CONST(0.9876723320), COEF_CONST(0.9890880155), COEF_CONST(0.9911036356), COEF_CONST(0.9953496173), COEF_CONST(0.9982312259), COEF_CONST(0.9999669685), COEF_CONST(0.9999669685), COEF_CONST(0.9999669685) }, + { COEF_CONST(0.9937641889), COEF_CONST(0.9945023501), COEF_CONST(0.9955433130), COEF_CONST(0.9976981117), COEF_CONST(0.9991315558), COEF_CONST(0.9999838610), COEF_CONST(0.9999838610), COEF_CONST(0.9999838610) }, + { COEF_CONST(0.9968600642), COEF_CONST(0.9972374385), COEF_CONST(0.9977670024), COEF_CONST(0.9988535464), COEF_CONST(0.9995691924), COEF_CONST(0.9999920129), COEF_CONST(0.9999920129), COEF_CONST(0.9999920129) }, + { COEF_CONST(0.9984226014), COEF_CONST(0.9986136287), COEF_CONST(0.9988810254), COEF_CONST(0.9994272242), COEF_CONST(0.9997851906), COEF_CONST(0.9999960221), COEF_CONST(0.9999960221), COEF_CONST(0.9999960221) }, + { COEF_CONST(0.9995003746), COEF_CONST(0.9995611974), COEF_CONST(0.9996461891), COEF_CONST(0.9998192657), COEF_CONST(0.9999323103), COEF_CONST(0.9999987475), COEF_CONST(0.9999987475), COEF_CONST(0.9999987475) }, + { COEF_CONST(0.9998419236), COEF_CONST(0.9998611991), COEF_CONST(0.9998881193), COEF_CONST(0.9999428861), COEF_CONST(0.9999786185), COEF_CONST(0.9999996045), COEF_CONST(0.9999996045), COEF_CONST(0.9999996045) }, + { COEF_CONST(0.9999500038), COEF_CONST(0.9999561034), COEF_CONST(0.9999646206), COEF_CONST(0.9999819429), COEF_CONST(0.9999932409), COEF_CONST(0.9999998750), COEF_CONST(0.9999998750), COEF_CONST(0.9999998750) }, + { COEF_CONST(0.9999841890), COEF_CONST(0.9999861183), COEF_CONST(0.9999888121), COEF_CONST(0.9999942902), COEF_CONST(0.9999978628), COEF_CONST(0.9999999605), COEF_CONST(0.9999999605), COEF_CONST(0.9999999605) }, + { COEF_CONST(0.9999950000), COEF_CONST(0.9999956102), COEF_CONST(0.9999964621), COEF_CONST(0.9999981945), COEF_CONST(0.9999993242), COEF_CONST(0.9999999875), COEF_CONST(0.9999999875), COEF_CONST(0.9999999875) } +}; + +static const real_t cos_gammas_normal[][8] = { + { COEF_CONST(1.0000000000), COEF_CONST(0.9841239707), COEF_CONST(0.9594738226), COEF_CONST(0.8946843024), COEF_CONST(0.8269341029), COEF_CONST(0.7245688486), COEF_CONST(0.7245688486), COEF_CONST(0.7245688486) }, + { COEF_CONST(1.0000000000), COEF_CONST(0.9849690570), COEF_CONST(0.9617776789), COEF_CONST(0.9020941550), COEF_CONST(0.8436830391), COEF_CONST(0.7846832804), COEF_CONST(0.7846832804), COEF_CONST(0.7846832804) }, + { COEF_CONST(1.0000000000), COEF_CONST(0.9871656089), COEF_CONST(0.9676774734), COEF_CONST(0.9199102884), COEF_CONST(0.8785067015), COEF_CONST(0.8464232214), COEF_CONST(0.8464232214), COEF_CONST(0.8464232214) }, + { COEF_CONST(1.0000000000), COEF_CONST(0.9913533967), COEF_CONST(0.9786000177), COEF_CONST(0.9496063381), COEF_CONST(0.9277157252), COEF_CONST(0.9133354077), COEF_CONST(0.9133354077), COEF_CONST(0.9133354077) }, + { COEF_CONST(1.0000000000), COEF_CONST(0.9948924435), COEF_CONST(0.9875319180), COEF_CONST(0.9716329849), COEF_CONST(0.9604805241), COEF_CONST(0.9535949574), COEF_CONST(0.9535949574), COEF_CONST(0.9535949574) }, + { COEF_CONST(1.0000000000), COEF_CONST(0.9977406278), COEF_CONST(0.9945423840), COEF_CONST(0.9878736667), COEF_CONST(0.9833980494), COEF_CONST(0.9807207440), COEF_CONST(0.9807207440), COEF_CONST(0.9807207440) }, + { COEF_CONST(1.0000000000), COEF_CONST(0.9990607067), COEF_CONST(0.9977417734), COEF_CONST(0.9950323970), COEF_CONST(0.9932453273), COEF_CONST(0.9921884740), COEF_CONST(0.9921884740), COEF_CONST(0.9921884740) }, + { COEF_CONST(1.0000000000), COEF_CONST(0.9998081748), COEF_CONST(0.9995400312), COEF_CONST(0.9989936459), COEF_CONST(0.9986365356), COEF_CONST(0.9984265591), COEF_CONST(0.9984265591), COEF_CONST(0.9984265591) } +}; + +static const real_t cos_gammas_fine[][8] = { + { COEF_CONST(1.0000000000), COEF_CONST(0.9841239707), COEF_CONST(0.9594738226), COEF_CONST(0.8946843024), COEF_CONST(0.8269341029), COEF_CONST(0.7245688486), COEF_CONST(0.7245688486), COEF_CONST(0.7245688486) }, + { COEF_CONST(1.0000000000), COEF_CONST(0.9849690570), COEF_CONST(0.9617776789), COEF_CONST(0.9020941550), COEF_CONST(0.8436830391), COEF_CONST(0.7846832804), COEF_CONST(0.7846832804), COEF_CONST(0.7846832804) }, + { COEF_CONST(1.0000000000), COEF_CONST(0.9871656089), COEF_CONST(0.9676774734), COEF_CONST(0.9199102884), COEF_CONST(0.8785067015), COEF_CONST(0.8464232214), COEF_CONST(0.8464232214), COEF_CONST(0.8464232214) }, + { COEF_CONST(1.0000000000), COEF_CONST(0.9899597309), COEF_CONST(0.9750098690), COEF_CONST(0.9402333855), COEF_CONST(0.9129698759), COEF_CONST(0.8943765944), COEF_CONST(0.8943765944), COEF_CONST(0.8943765944) }, + { COEF_CONST(1.0000000000), COEF_CONST(0.9926607607), COEF_CONST(0.9819295710), COEF_CONST(0.9580160104), COEF_CONST(0.9404993670), COEF_CONST(0.9293004472), COEF_CONST(0.9293004472), COEF_CONST(0.9293004472) }, + { COEF_CONST(1.0000000000), COEF_CONST(0.9948924435), COEF_CONST(0.9875319180), COEF_CONST(0.9716329849), COEF_CONST(0.9604805241), COEF_CONST(0.9535949574), COEF_CONST(0.9535949574), COEF_CONST(0.9535949574) }, + { COEF_CONST(1.0000000000), COEF_CONST(0.9972074644), COEF_CONST(0.9932414270), COEF_CONST(0.9849197629), COEF_CONST(0.9792926592), COEF_CONST(0.9759092525), COEF_CONST(0.9759092525), COEF_CONST(0.9759092525) }, + { COEF_CONST(1.0000000000), COEF_CONST(0.9985361982), COEF_CONST(0.9964742028), COEF_CONST(0.9922136306), COEF_CONST(0.9893845420), COEF_CONST(0.9877041371), COEF_CONST(0.9877041371), COEF_CONST(0.9877041371) }, + { COEF_CONST(1.0000000000), COEF_CONST(0.9992494366), COEF_CONST(0.9981967170), COEF_CONST(0.9960386625), COEF_CONST(0.9946185834), COEF_CONST(0.9937800239), COEF_CONST(0.9937800239), COEF_CONST(0.9937800239) }, + { COEF_CONST(1.0000000000), COEF_CONST(0.9996194722), COEF_CONST(0.9990869422), COEF_CONST(0.9979996269), COEF_CONST(0.9972873651), COEF_CONST(0.9968679747), COEF_CONST(0.9968679747), COEF_CONST(0.9968679747) }, + { COEF_CONST(1.0000000000), COEF_CONST(0.9998081748), COEF_CONST(0.9995400312), COEF_CONST(0.9989936459), COEF_CONST(0.9986365356), COEF_CONST(0.9984265591), COEF_CONST(0.9984265591), COEF_CONST(0.9984265591) }, + { COEF_CONST(1.0000000000), COEF_CONST(0.9999390971), COEF_CONST(0.9998540271), COEF_CONST(0.9996809352), COEF_CONST(0.9995679735), COEF_CONST(0.9995016284), COEF_CONST(0.9995016284), COEF_CONST(0.9995016284) }, + { COEF_CONST(1.0000000000), COEF_CONST(0.9999807170), COEF_CONST(0.9999537862), COEF_CONST(0.9998990191), COEF_CONST(0.9998632947), COEF_CONST(0.9998423208), COEF_CONST(0.9998423208), COEF_CONST(0.9998423208) }, + { COEF_CONST(1.0000000000), COEF_CONST(0.9999938979), COEF_CONST(0.9999853814), COEF_CONST(0.9999680568), COEF_CONST(0.9999567596), COEF_CONST(0.9999501270), COEF_CONST(0.9999501270), COEF_CONST(0.9999501270) }, + { COEF_CONST(1.0000000000), COEF_CONST(0.9999980703), COEF_CONST(0.9999953731), COEF_CONST(0.9999898968), COEF_CONST(0.9999863277), COEF_CONST(0.9999842265), COEF_CONST(0.9999842265), COEF_CONST(0.9999842265) }, + { COEF_CONST(1.0000000000), COEF_CONST(0.9999993891), COEF_CONST(0.9999985397), COEF_CONST(0.9999968037), COEF_CONST(0.9999956786), COEF_CONST(0.9999950155), COEF_CONST(0.9999950155), COEF_CONST(0.9999950155) } +}; + +static const real_t sin_gammas_normal[][8] = { + { COEF_CONST(0.0000000000), COEF_CONST(0.1774824223), COEF_CONST(0.2817977711), COEF_CONST(0.4466990028), COEF_CONST(0.5622988435), COEF_CONST(0.6892024258), COEF_CONST(0.6892024258), COEF_CONST(0.6892024258) }, + { COEF_CONST(0.0000000000), COEF_CONST(0.1727308798), COEF_CONST(0.2738315110), COEF_CONST(0.4315392630), COEF_CONST(0.5368416242), COEF_CONST(0.6198968861), COEF_CONST(0.6198968861), COEF_CONST(0.6198968861) }, + { COEF_CONST(0.0000000000), COEF_CONST(0.1596999079), COEF_CONST(0.2521910140), COEF_CONST(0.3921288836), COEF_CONST(0.4777300236), COEF_CONST(0.5325107795), COEF_CONST(0.5325107795), COEF_CONST(0.5325107795) }, + { COEF_CONST(0.0000000000), COEF_CONST(0.1312190642), COEF_CONST(0.2057717310), COEF_CONST(0.3134450552), COEF_CONST(0.3732874674), COEF_CONST(0.4072080955), COEF_CONST(0.4072080955), COEF_CONST(0.4072080955) }, + { COEF_CONST(0.0000000000), COEF_CONST(0.1009407043), COEF_CONST(0.1574189028), COEF_CONST(0.2364938532), COEF_CONST(0.2783471983), COEF_CONST(0.3010924396), COEF_CONST(0.3010924396), COEF_CONST(0.3010924396) }, + { COEF_CONST(0.0000000000), COEF_CONST(0.0671836269), COEF_CONST(0.1043333428), COEF_CONST(0.1552598422), COEF_CONST(0.1814615013), COEF_CONST(0.1954144885), COEF_CONST(0.1954144885), COEF_CONST(0.1954144885) }, + { COEF_CONST(0.0000000000), COEF_CONST(0.0433324862), COEF_CONST(0.0671666110), COEF_CONST(0.0995516398), COEF_CONST(0.1160332699), COEF_CONST(0.1247478739), COEF_CONST(0.1247478739), COEF_CONST(0.1247478739) }, + { COEF_CONST(0.0000000000), COEF_CONST(0.0195860576), COEF_CONST(0.0303269852), COEF_CONST(0.0448519274), COEF_CONST(0.0522022017), COEF_CONST(0.0560750040), COEF_CONST(0.0560750040), COEF_CONST(0.0560750040) } +}; + +static const real_t sin_gammas_fine[][8] = { + { COEF_CONST(0.0000000000), COEF_CONST(0.1774824223), COEF_CONST(0.2817977711), COEF_CONST(0.4466990028), COEF_CONST(0.5622988435), COEF_CONST(0.6892024258), COEF_CONST(0.6892024258), COEF_CONST(0.6892024258) }, + { COEF_CONST(0.0000000000), COEF_CONST(0.1727308798), COEF_CONST(0.2738315110), COEF_CONST(0.4315392630), COEF_CONST(0.5368416242), COEF_CONST(0.6198968861), COEF_CONST(0.6198968861), COEF_CONST(0.6198968861) }, + { COEF_CONST(0.0000000000), COEF_CONST(0.1596999079), COEF_CONST(0.2521910140), COEF_CONST(0.3921288836), COEF_CONST(0.4777300236), COEF_CONST(0.5325107795), COEF_CONST(0.5325107795), COEF_CONST(0.5325107795) }, + { COEF_CONST(0.0000000000), COEF_CONST(0.1413496768), COEF_CONST(0.2221615526), COEF_CONST(0.3405307340), COEF_CONST(0.4080269669), COEF_CONST(0.4473147744), COEF_CONST(0.4473147744), COEF_CONST(0.4473147744) }, + { COEF_CONST(0.0000000000), COEF_CONST(0.1209322714), COEF_CONST(0.1892467110), COEF_CONST(0.2867147079), COEF_CONST(0.3397954394), COEF_CONST(0.3693246252), COEF_CONST(0.3693246252), COEF_CONST(0.3693246252) }, + { COEF_CONST(0.0000000000), COEF_CONST(0.1009407043), COEF_CONST(0.1574189028), COEF_CONST(0.2364938532), COEF_CONST(0.2783471983), COEF_CONST(0.3010924396), COEF_CONST(0.3010924396), COEF_CONST(0.3010924396) }, + { COEF_CONST(0.0000000000), COEF_CONST(0.0746811420), COEF_CONST(0.1160666523), COEF_CONST(0.1730117353), COEF_CONST(0.2024497161), COEF_CONST(0.2181768341), COEF_CONST(0.2181768341), COEF_CONST(0.2181768341) }, + { COEF_CONST(0.0000000000), COEF_CONST(0.0540875291), COEF_CONST(0.0838997203), COEF_CONST(0.1245476266), COEF_CONST(0.1453211203), COEF_CONST(0.1563346972), COEF_CONST(0.1563346972), COEF_CONST(0.1563346972) }, + { COEF_CONST(0.0000000000), COEF_CONST(0.0387371058), COEF_CONST(0.0600276114), COEF_CONST(0.0889212171), COEF_CONST(0.1036044086), COEF_CONST(0.1113609634), COEF_CONST(0.1113609634), COEF_CONST(0.1113609634) }, + { COEF_CONST(0.0000000000), COEF_CONST(0.0275846110), COEF_CONST(0.0427233177), COEF_CONST(0.0632198125), COEF_CONST(0.0736064637), COEF_CONST(0.0790837596), COEF_CONST(0.0790837596), COEF_CONST(0.0790837596) }, + { COEF_CONST(0.0000000000), COEF_CONST(0.0195860576), COEF_CONST(0.0303269852), COEF_CONST(0.0448519274), COEF_CONST(0.0522022017), COEF_CONST(0.0560750040), COEF_CONST(0.0560750040), COEF_CONST(0.0560750040) }, + { COEF_CONST(0.0000000000), COEF_CONST(0.0110363955), COEF_CONST(0.0170857974), COEF_CONST(0.0252592108), COEF_CONST(0.0293916021), COEF_CONST(0.0315673054), COEF_CONST(0.0315673054), COEF_CONST(0.0315673054) }, + { COEF_CONST(0.0000000000), COEF_CONST(0.0062101284), COEF_CONST(0.0096138203), COEF_CONST(0.0142109649), COEF_CONST(0.0165345659), COEF_CONST(0.0177576316), COEF_CONST(0.0177576316), COEF_CONST(0.0177576316) }, + { COEF_CONST(0.0000000000), COEF_CONST(0.0034934509), COEF_CONST(0.0054071189), COEF_CONST(0.0079928316), COEF_CONST(0.0092994041), COEF_CONST(0.0099871631), COEF_CONST(0.0099871631), COEF_CONST(0.0099871631) }, + { COEF_CONST(0.0000000000), COEF_CONST(0.0019645397), COEF_CONST(0.0030419905), COEF_CONST(0.0044951511), COEF_CONST(0.0052291853), COEF_CONST(0.0056166498), COEF_CONST(0.0056166498), COEF_CONST(0.0056166498) }, + { COEF_CONST(0.0000000000), COEF_CONST(0.0011053943), COEF_CONST(0.0017089869), COEF_CONST(0.0025283670), COEF_CONST(0.0029398552), COEF_CONST(0.0031573685), COEF_CONST(0.0031573685), COEF_CONST(0.0031573685) } +}; + +static const real_t sf_iid_normal[] = { + COEF_CONST(1.4119827747), COEF_CONST(1.4031381607), COEF_CONST(1.3868767023), + COEF_CONST(1.3483997583), COEF_CONST(1.2912493944), COEF_CONST(1.1960374117), + COEF_CONST(1.1073724031), COEF_CONST(1.0000000000), COEF_CONST(0.8796171546), + COEF_CONST(0.7546485662), COEF_CONST(0.5767799020), COEF_CONST(0.4264014363), + COEF_CONST(0.2767182887), COEF_CONST(0.1766446233), COEF_CONST(0.0794016272) +}; + +static const real_t sf_iid_fine[] = { + COEF_CONST(1.4142065048), COEF_CONST(1.4141912460), COEF_CONST(1.4141428471), + COEF_CONST(1.4139900208), COEF_CONST(1.4135069847), COEF_CONST(1.4119827747), + COEF_CONST(1.4097729921), COEF_CONST(1.4053947926), COEF_CONST(1.3967796564), + COEF_CONST(1.3800530434), COEF_CONST(1.3483997583), COEF_CONST(1.3139201403), + COEF_CONST(1.2643101215), COEF_CONST(1.1960374117), COEF_CONST(1.1073724031), + COEF_CONST(1.0000000000), COEF_CONST(0.8796171546), COEF_CONST(0.7546485662), + COEF_CONST(0.6336560845), COEF_CONST(0.5230810642), COEF_CONST(0.4264014363), + COEF_CONST(0.3089554012), COEF_CONST(0.2213746458), COEF_CONST(0.1576878875), + COEF_CONST(0.1119822487), COEF_CONST(0.0794016272), COEF_CONST(0.0446990170), + COEF_CONST(0.0251446925), COEF_CONST(0.0141414283), COEF_CONST(0.0079525812), + COEF_CONST(0.0044721137) +}; + +#ifdef __cplusplus + +#endif +#endif + diff --git a/lib/rbcodec/codecs/libfaad/pulse.c b/lib/rbcodec/codecs/libfaad/pulse.c new file mode 100644 index 0000000000..d75877db70 --- /dev/null +++ b/lib/rbcodec/codecs/libfaad/pulse.c @@ -0,0 +1,56 @@ +/* +** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding +** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +** +** Any non-GPL usage of this software or parts of this software is strictly +** forbidden. +** +** Commercial non-GPL licensing of this software is possible. +** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** +** $Id$ +**/ + +#include "common.h" +#include "structs.h" + +#include "syntax.h" +#include "pulse.h" + +uint8_t pulse_decode(ic_stream *ics, int16_t *spec_data, uint16_t framelen) +{ + uint8_t i; + uint16_t k; + pulse_info *pul = &(ics->pul); + + k = ics->swb_offset[pul->pulse_start_sfb]; + + for (i = 0; i <= pul->number_pulse; i++) + { + k += pul->pulse_offset[i]; + + if (k >= framelen) + return 15; /* should not be possible */ + + if (spec_data[k] > 0) + spec_data[k] += pul->pulse_amp[i]; + else + spec_data[k] -= pul->pulse_amp[i]; + } + + return 0; +} diff --git a/lib/rbcodec/codecs/libfaad/pulse.h b/lib/rbcodec/codecs/libfaad/pulse.h new file mode 100644 index 0000000000..84d7fd38d8 --- /dev/null +++ b/lib/rbcodec/codecs/libfaad/pulse.h @@ -0,0 +1,40 @@ +/* +** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding +** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +** +** Any non-GPL usage of this software or parts of this software is strictly +** forbidden. +** +** Commercial non-GPL licensing of this software is possible. +** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** +** $Id$ +**/ + +#ifndef __PULSE_H__ +#define __PULSE_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +uint8_t pulse_decode(ic_stream *ics, int16_t *spec_coef, uint16_t framelen); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/lib/rbcodec/codecs/libfaad/rvlc.c b/lib/rbcodec/codecs/libfaad/rvlc.c new file mode 100644 index 0000000000..5b17edd06c --- /dev/null +++ b/lib/rbcodec/codecs/libfaad/rvlc.c @@ -0,0 +1,530 @@ +/* +** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding +** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +** +** Any non-GPL usage of this software or parts of this software is strictly +** forbidden. +** +** Commercial non-GPL licensing of this software is possible. +** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** +** $Id$ +**/ + +/* RVLC scalefactor decoding + * + * RVLC works like this: + * 1. Only symmetric huffman codewords are used + * 2. Total length of the scalefactor data is stored in the bitsream + * 3. Scalefactors are DPCM coded + * 4. Next to the starting value for DPCM the ending value is also stored + * + * With all this it is possible to read the scalefactor data from 2 sides. + * If there is a bit error in the scalefactor data it is possible to start + * decoding from the other end of the data, to find all but 1 scalefactor. + */ + +#include "common.h" +#include "structs.h" + +#include + +#include "syntax.h" +#include "bits.h" +#include "rvlc.h" + + +#ifdef ERROR_RESILIENCE + +//#define PRINT_RVLC + +/* static function declarations */ +static uint8_t rvlc_decode_sf_forward(ic_stream *ics, + bitfile *ld_sf, + bitfile *ld_esc, + uint8_t *is_used); +#if 0 +static uint8_t rvlc_decode_sf_reverse(ic_stream *ics, + bitfile *ld_sf, + bitfile *ld_esc, + uint8_t is_used); +#endif +static int8_t rvlc_huffman_sf(bitfile *ld_sf, bitfile *ld_esc, + int8_t direction); +static int8_t rvlc_huffman_esc(bitfile *ld_esc, int8_t direction); + + +uint8_t rvlc_scale_factor_data(ic_stream *ics, bitfile *ld) +{ + uint8_t bits = 9; + + ics->sf_concealment = faad_get1bit(ld + DEBUGVAR(1,149,"rvlc_scale_factor_data(): sf_concealment")); + ics->rev_global_gain = (uint8_t)faad_getbits(ld, 8 + DEBUGVAR(1,150,"rvlc_scale_factor_data(): rev_global_gain")); + + if (ics->window_sequence == EIGHT_SHORT_SEQUENCE) + bits = 11; + + /* the number of bits used for the huffman codewords */ + ics->length_of_rvlc_sf = (uint16_t)faad_getbits(ld, bits + DEBUGVAR(1,151,"rvlc_scale_factor_data(): length_of_rvlc_sf")); + + if (ics->noise_used) + { + ics->dpcm_noise_nrg = (uint16_t)faad_getbits(ld, 9 + DEBUGVAR(1,152,"rvlc_scale_factor_data(): dpcm_noise_nrg")); + + ics->length_of_rvlc_sf -= 9; + } + + ics->sf_escapes_present = faad_get1bit(ld + DEBUGVAR(1,153,"rvlc_scale_factor_data(): sf_escapes_present")); + + if (ics->sf_escapes_present) + { + ics->length_of_rvlc_escapes = (uint8_t)faad_getbits(ld, 8 + DEBUGVAR(1,154,"rvlc_scale_factor_data(): length_of_rvlc_escapes")); + } + + if (ics->noise_used) + { + ics->dpcm_noise_last_position = (uint16_t)faad_getbits(ld, 9 + DEBUGVAR(1,155,"rvlc_scale_factor_data(): dpcm_noise_last_position")); + } + + return 0; +} + +uint8_t rvlc_decode_scale_factors(ic_stream *ics, bitfile *ld) +{ + uint8_t result; + uint8_t intensity_used = 0; + uint8_t *rvlc_sf_buffer = NULL; + uint8_t *rvlc_esc_buffer = NULL; + bitfile ld_rvlc_sf, ld_rvlc_esc; +// bitfile ld_rvlc_sf_rev, ld_rvlc_esc_rev; + + if (ics->length_of_rvlc_sf > 0) + { + /* We read length_of_rvlc_sf bits here to put it in a + seperate bitfile. + */ + rvlc_sf_buffer = faad_getbitbuffer(ld, ics->length_of_rvlc_sf + DEBUGVAR(1,156,"rvlc_decode_scale_factors(): bitbuffer: length_of_rvlc_sf")); + + faad_initbits(&ld_rvlc_sf, (void*)rvlc_sf_buffer, bit2byte(ics->length_of_rvlc_sf)); +// faad_initbits_rev(&ld_rvlc_sf_rev, (void*)rvlc_sf_buffer, +// ics->length_of_rvlc_sf); + } + + if (ics->sf_escapes_present) + { + /* We read length_of_rvlc_escapes bits here to put it in a + seperate bitfile. + */ + rvlc_esc_buffer = faad_getbitbuffer(ld, ics->length_of_rvlc_escapes + DEBUGVAR(1,157,"rvlc_decode_scale_factors(): bitbuffer: length_of_rvlc_escapes")); + + faad_initbits(&ld_rvlc_esc, (void*)rvlc_esc_buffer, bit2byte(ics->length_of_rvlc_escapes)); +// faad_initbits_rev(&ld_rvlc_esc_rev, (void*)rvlc_esc_buffer, +// ics->length_of_rvlc_escapes); + } + + /* decode the rvlc scale factors and escapes */ + result = rvlc_decode_sf_forward(ics, &ld_rvlc_sf, + &ld_rvlc_esc, &intensity_used); +// result = rvlc_decode_sf_reverse(ics, &ld_rvlc_sf_rev, +// &ld_rvlc_esc_rev, intensity_used); + + + if (rvlc_esc_buffer) faad_free(rvlc_esc_buffer); + if (rvlc_sf_buffer) faad_free(rvlc_sf_buffer); + + if (ics->length_of_rvlc_sf > 0) + faad_endbits(&ld_rvlc_sf); + if (ics->sf_escapes_present) + faad_endbits(&ld_rvlc_esc); + + return result; +} + +static uint8_t rvlc_decode_sf_forward(ic_stream *ics, bitfile *ld_sf, bitfile *ld_esc, + uint8_t *intensity_used) +{ + int8_t g, sfb; + int8_t t = 0; + int8_t error = 0; + int8_t noise_pcm_flag = 1; + + int16_t scale_factor = ics->global_gain; + int16_t is_position = 0; + int16_t noise_energy = ics->global_gain - 90 - 256; + +#ifdef PRINT_RVLC + printf("\nglobal_gain: %d\n", ics->global_gain); +#endif + + for (g = 0; g < ics->num_window_groups; g++) + { + for (sfb = 0; sfb < ics->max_sfb; sfb++) + { + if (error) + { + ics->scale_factors[g][sfb] = 0; + } else { + switch (ics->sfb_cb[g][sfb]) + { + case ZERO_HCB: /* zero book */ + ics->scale_factors[g][sfb] = 0; + break; + case INTENSITY_HCB: /* intensity books */ + case INTENSITY_HCB2: + + *intensity_used = 1; + + /* decode intensity position */ + t = rvlc_huffman_sf(ld_sf, ld_esc, +1); + + is_position += t; + ics->scale_factors[g][sfb] = is_position; + + break; + case NOISE_HCB: /* noise books */ + + /* decode noise energy */ + if (noise_pcm_flag) + { + int16_t n = ics->dpcm_noise_nrg; + noise_pcm_flag = 0; + noise_energy += n; + } else { + t = rvlc_huffman_sf(ld_sf, ld_esc, +1); + noise_energy += t; + } + + ics->scale_factors[g][sfb] = noise_energy; + + break; + default: /* spectral books */ + + /* decode scale factor */ + t = rvlc_huffman_sf(ld_sf, ld_esc, +1); + + scale_factor += t; + if (scale_factor < 0) + return 4; + + ics->scale_factors[g][sfb] = scale_factor; + + break; + } +#ifdef PRINT_RVLC + printf("%3d:%4d%4d\n", sfb, ics->sfb_cb[g][sfb], + ics->scale_factors[g][sfb]); +#endif + if (t == 99) + { + error = 1; + } + } + } + } +#ifdef PRINT_RVLC + printf("\n\n"); +#endif + + return 0; +} + +#if 0 // not used right now, doesn't work correctly yet +static uint8_t rvlc_decode_sf_reverse(ic_stream *ics, bitfile *ld_sf, bitfile *ld_esc, + uint8_t intensity_used) +{ + int8_t g, sfb; + int8_t t = 0; + int8_t error = 0; + int8_t noise_pcm_flag = 1, is_pcm_flag = 1, sf_pcm_flag = 1; + + int16_t scale_factor = ics->rev_global_gain; + int16_t is_position = 0; + int16_t noise_energy = ics->rev_global_gain; + +#ifdef PRINT_RVLC + printf("\nrev_global_gain: %d\n", ics->rev_global_gain); +#endif + + if (intensity_used) + { + is_position = rvlc_huffman_sf(ld_sf, ld_esc, -1); +#ifdef PRINT_RVLC + printf("is_position: %d\n", is_position); +#endif + } + + for (g = ics->num_window_groups-1; g >= 0; g--) + { + for (sfb = ics->max_sfb-1; sfb >= 0; sfb--) + { + if (error) + { + ics->scale_factors[g][sfb] = 0; + } else { + switch (ics->sfb_cb[g][sfb]) + { + case ZERO_HCB: /* zero book */ + ics->scale_factors[g][sfb] = 0; + break; + case INTENSITY_HCB: /* intensity books */ + case INTENSITY_HCB2: + + if (is_pcm_flag) + { + is_pcm_flag = 0; + ics->scale_factors[g][sfb] = is_position; + } else { + t = rvlc_huffman_sf(ld_sf, ld_esc, -1); + is_position -= t; + + ics->scale_factors[g][sfb] = (uint8_t)is_position; + } + break; + case NOISE_HCB: /* noise books */ + + /* decode noise energy */ + if (noise_pcm_flag) + { + noise_pcm_flag = 0; + noise_energy = ics->dpcm_noise_last_position; + } else { + t = rvlc_huffman_sf(ld_sf, ld_esc, -1); + noise_energy -= t; + } + + ics->scale_factors[g][sfb] = (uint8_t)noise_energy; + break; + default: /* spectral books */ + + if (sf_pcm_flag || (sfb == 0)) + { + sf_pcm_flag = 0; + if (sfb == 0) + scale_factor = ics->global_gain; + } else { + /* decode scale factor */ + t = rvlc_huffman_sf(ld_sf, ld_esc, -1); + scale_factor -= t; + } + + if (scale_factor < 0) + return 4; + + ics->scale_factors[g][sfb] = (uint8_t)scale_factor; + break; + } +#ifdef PRINT_RVLC + printf("%3d:%4d%4d\n", sfb, ics->sfb_cb[g][sfb], + ics->scale_factors[g][sfb]); +#endif + if (t == 99) + { + error = 1; + } + } + } + } + +#ifdef PRINT_RVLC + printf("\n\n"); +#endif + + return 0; +} +#endif + +/* index == 99 means not allowed codeword */ +static rvlc_huff_table book_rvlc[] = { + /*index length codeword */ + { 0, 1, 0 }, /* 0 */ + { -1, 3, 5 }, /* 101 */ + { 1, 3, 7 }, /* 111 */ + { -2, 4, 9 }, /* 1001 */ + { -3, 5, 17 }, /* 10001 */ + { 2, 5, 27 }, /* 11011 */ + { -4, 6, 33 }, /* 100001 */ + { 99, 6, 50 }, /* 110010 */ + { 3, 6, 51 }, /* 110011 */ + { 99, 6, 52 }, /* 110100 */ + { -7, 7, 65 }, /* 1000001 */ + { 99, 7, 96 }, /* 1100000 */ + { 99, 7, 98 }, /* 1100010 */ + { 7, 7, 99 }, /* 1100011 */ + { 4, 7, 107 }, /* 1101011 */ + { -5, 8, 129 }, /* 10000001 */ + { 99, 8, 194 }, /* 11000010 */ + { 5, 8, 195 }, /* 11000011 */ + { 99, 8, 212 }, /* 11010100 */ + { 99, 9, 256 }, /* 100000000 */ + { -6, 9, 257 }, /* 100000001 */ + { 99, 9, 426 }, /* 110101010 */ + { 6, 9, 427 }, /* 110101011 */ + { 99, 10, 0 } /* Shouldn't come this far */ +}; + +static rvlc_huff_table book_escape[] = { + /*index length codeword */ + { 1, 2, 0 }, + { 0, 2, 2 }, + { 3, 3, 2 }, + { 2, 3, 6 }, + { 4, 4, 14 }, + { 7, 5, 13 }, + { 6, 5, 15 }, + { 5, 5, 31 }, + { 11, 6, 24 }, + { 10, 6, 25 }, + { 9, 6, 29 }, + { 8, 6, 61 }, + { 13, 7, 56 }, + { 12, 7, 120 }, + { 15, 8, 114 }, + { 14, 8, 242 }, + { 17, 9, 230 }, + { 16, 9, 486 }, + { 19, 10, 463 }, + { 18, 10, 974 }, + { 22, 11, 925 }, + { 20, 11, 1950 }, + { 21, 11, 1951 }, + { 23, 12, 1848 }, + { 25, 13, 3698 }, + { 24, 14, 7399 }, + { 26, 15, 14797 }, + { 49, 19, 236736 }, + { 50, 19, 236737 }, + { 51, 19, 236738 }, + { 52, 19, 236739 }, + { 53, 19, 236740 }, + { 27, 20, 473482 }, + { 28, 20, 473483 }, + { 29, 20, 473484 }, + { 30, 20, 473485 }, + { 31, 20, 473486 }, + { 32, 20, 473487 }, + { 33, 20, 473488 }, + { 34, 20, 473489 }, + { 35, 20, 473490 }, + { 36, 20, 473491 }, + { 37, 20, 473492 }, + { 38, 20, 473493 }, + { 39, 20, 473494 }, + { 40, 20, 473495 }, + { 41, 20, 473496 }, + { 42, 20, 473497 }, + { 43, 20, 473498 }, + { 44, 20, 473499 }, + { 45, 20, 473500 }, + { 46, 20, 473501 }, + { 47, 20, 473502 }, + { 48, 20, 473503 }, + { 99, 21, 0 } /* Shouldn't come this far */ +}; + +static int8_t rvlc_huffman_sf(bitfile *ld_sf, bitfile *ld_esc, + int8_t direction) +{ + uint8_t i, j; + int8_t index; + uint32_t cw; + rvlc_huff_table *h = book_rvlc; + + i = h->len; + if (direction > 0) + cw = faad_getbits(ld_sf, i DEBUGVAR(1,0,"")); + else + cw = faad_getbits_rev(ld_sf, i DEBUGVAR(1,0,"")); + + while ((cw != h->cw) + && (i < 10)) + { + h++; + j = h->len-i; + i += j; + cw <<= j; + if (direction > 0) + cw |= faad_getbits(ld_sf, j DEBUGVAR(1,0,"")); + else + cw |= faad_getbits_rev(ld_sf, j DEBUGVAR(1,0,"")); + } + + index = h->index; + + if (index == +ESC_VAL) + { + int8_t esc = rvlc_huffman_esc(ld_esc, direction); + if (esc == 99) + return 99; + index += esc; +#ifdef PRINT_RVLC + printf("esc: %d - ", esc); +#endif + } + if (index == -ESC_VAL) + { + int8_t esc = rvlc_huffman_esc(ld_esc, direction); + if (esc == 99) + return 99; + index -= esc; +#ifdef PRINT_RVLC + printf("esc: %d - ", esc); +#endif + } + + return index; +} + +static int8_t rvlc_huffman_esc(bitfile *ld, + int8_t direction) +{ + uint8_t i, j; + uint32_t cw; + rvlc_huff_table *h = book_escape; + + i = h->len; + if (direction > 0) + cw = faad_getbits(ld, i DEBUGVAR(1,0,"")); + else + cw = faad_getbits_rev(ld, i DEBUGVAR(1,0,"")); + + while ((cw != h->cw) + && (i < 21)) + { + h++; + j = h->len-i; + i += j; + cw <<= j; + if (direction > 0) + cw |= faad_getbits(ld, j DEBUGVAR(1,0,"")); + else + cw |= faad_getbits_rev(ld, j DEBUGVAR(1,0,"")); + } + + return h->index; +} + +#endif + diff --git a/lib/rbcodec/codecs/libfaad/rvlc.h b/lib/rbcodec/codecs/libfaad/rvlc.h new file mode 100644 index 0000000000..b17246a452 --- /dev/null +++ b/lib/rbcodec/codecs/libfaad/rvlc.h @@ -0,0 +1,53 @@ +/* +** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding +** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +** +** Any non-GPL usage of this software or parts of this software is strictly +** forbidden. +** +** Commercial non-GPL licensing of this software is possible. +** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** +** $Id$ +**/ + +#ifndef __RVLC_SCF_H__ +#define __RVLC_SCF_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct +{ + int8_t index; + uint8_t len; + uint32_t cw; +} rvlc_huff_table; + + +#define ESC_VAL 7 + + +uint8_t rvlc_scale_factor_data(ic_stream *ics, bitfile *ld); +uint8_t rvlc_decode_scale_factors(ic_stream *ics, bitfile *ld); + + +#ifdef __cplusplus +} +#endif +#endif diff --git a/lib/rbcodec/codecs/libfaad/sbr_dct.c b/lib/rbcodec/codecs/libfaad/sbr_dct.c new file mode 100644 index 0000000000..e9c56c3a18 --- /dev/null +++ b/lib/rbcodec/codecs/libfaad/sbr_dct.c @@ -0,0 +1,1990 @@ +/* +** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding +** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +** +** Any non-GPL usage of this software or parts of this software is strictly +** forbidden. +** +** Commercial non-GPL licensing of this software is possible. +** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** +** $Id$ +**/ + +#include "common.h" +#include "../lib/fft.h" +#include "../lib/mdct_lookup.h" + + +#ifdef SBR_DEC + +#ifdef _MSC_VER +#pragma warning(disable:4305) +#pragma warning(disable:4244) +#endif + + +#include "sbr_dct.h" + +void DCT4_32(real_t *y, real_t *x) +{ + real_t f0, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10; + real_t f11, f12, f13, f14, f15, f16, f17, f18, f19, f20; + real_t f21, f22, f23, f24, f25, f26, f27, f28, f29, f30; + real_t f31, f32, f33, f34, f35, f36, f37, f38, f39, f40; + real_t f41, f42, f43, f44, f45, f46, f47, f48, f49, f50; + real_t f51, f52, f53, f54, f55, f56, f57, f58, f59, f60; + real_t f61, f62, f63, f64, f65, f66, f67, f68, f69, f70; + real_t f71, f72, f73, f74, f75, f76, f77, f78, f79, f80; + real_t f81, f82, f83, f84, f85, f86, f87, f88, f89, f90; + real_t f91, f92, f93, f94, f95, f96, f97, f98, f99, f100; + real_t f101, f102, f103, f104, f105, f106, f107, f108, f109, f110; + real_t f111, f112, f113, f114, f115, f116, f117, f118, f119, f120; + real_t f121, f122, f123, f124, f125, f126, f127, f128, f129, f130; + real_t f131, f132, f133, f134, f135, f136, f137, f138, f139, f140; + real_t f141, f142, f143, f144, f145, f146, f147, f148, f149, f150; + real_t f151, f152, f153, f154, f155, f156, f157, f158, f159, f160; + real_t f161, f162, f163, f164, f165, f166, f167, f168, f169, f170; + real_t f171, f172, f173, f174, f175, f176, f177, f178, f179, f180; + real_t f181, f182, f183, f184, f185, f186, f187, f188, f189, f190; + real_t f191, f192, f193, f194, f195, f196, f197, f198, f199, f200; + real_t f201, f202, f203, f204, f205, f206, f207, f208, f209, f210; + real_t f211, f212, f213, f214, f215, f216, f217, f218, f219, f220; + real_t f221, f222, f223, f224, f225, f226, f227, f228, f229, f230; + real_t f231, f232, f233, f234, f235, f236, f237, f238, f239, f240; + real_t f241, f242, f243, f244, f245, f246, f247, f248, f249, f250; + real_t f251, f252, f253, f254, f255, f256, f257, f258, f259, f260; + real_t f261, f262, f263, f264, f265, f266, f267, f268, f269, f270; + real_t f271, f272, f273, f274, f275, f276, f277, f278, f279, f280; + real_t f281, f282, f283, f284, f285, f286, f287, f288, f289, f290; + real_t f291, f292, f293, f294, f295, f296, f297, f298, f299, f300; + real_t f301, f302, f303, f304, f305, f306, f307, f310, f311, f312; + real_t f313, f316, f317, f318, f319, f322, f323, f324, f325, f328; + real_t f329, f330, f331, f334, f335, f336, f337, f340, f341, f342; + real_t f343, f346, f347, f348, f349, f352, f353, f354, f355, f358; + real_t f359, f360, f361, f364, f365, f366, f367, f370, f371, f372; + real_t f373, f376, f377, f378, f379, f382, f383, f384, f385, f388; + real_t f389, f390, f391, f394, f395, f396, f397; + + f0 = x[15] - x[16]; + f1 = x[15] + x[16]; + f2 = MUL_F(FRAC_CONST(0.7071067811865476), f1); + f3 = MUL_F(FRAC_CONST(0.7071067811865476), f0); + f4 = x[8] - x[23]; + f5 = x[8] + x[23]; + f6 = MUL_F(FRAC_CONST(0.7071067811865476), f5); + f7 = MUL_F(FRAC_CONST(0.7071067811865476), f4); + f8 = x[12] - x[19]; + f9 = x[12] + x[19]; + f10 = MUL_F(FRAC_CONST(0.7071067811865476), f9); + f11 = MUL_F(FRAC_CONST(0.7071067811865476), f8); + f12 = x[11] - x[20]; + f13 = x[11] + x[20]; + f14 = MUL_F(FRAC_CONST(0.7071067811865476), f13); + f15 = MUL_F(FRAC_CONST(0.7071067811865476), f12); + f16 = x[14] - x[17]; + f17 = x[14] + x[17]; + f18 = MUL_F(FRAC_CONST(0.7071067811865476), f17); + f19 = MUL_F(FRAC_CONST(0.7071067811865476), f16); + f20 = x[9] - x[22]; + f21 = x[9] + x[22]; + f22 = MUL_F(FRAC_CONST(0.7071067811865476), f21); + f23 = MUL_F(FRAC_CONST(0.7071067811865476), f20); + f24 = x[13] - x[18]; + f25 = x[13] + x[18]; + f26 = MUL_F(FRAC_CONST(0.7071067811865476), f25); + f27 = MUL_F(FRAC_CONST(0.7071067811865476), f24); + f28 = x[10] - x[21]; + f29 = x[10] + x[21]; + f30 = MUL_F(FRAC_CONST(0.7071067811865476), f29); + f31 = MUL_F(FRAC_CONST(0.7071067811865476), f28); + f32 = x[0] - f2; + f33 = x[0] + f2; + f34 = x[31] - f3; + f35 = x[31] + f3; + f36 = x[7] - f6; + f37 = x[7] + f6; + f38 = x[24] - f7; + f39 = x[24] + f7; + f40 = x[3] - f10; + f41 = x[3] + f10; + f42 = x[28] - f11; + f43 = x[28] + f11; + f44 = x[4] - f14; + f45 = x[4] + f14; + f46 = x[27] - f15; + f47 = x[27] + f15; + f48 = x[1] - f18; + f49 = x[1] + f18; + f50 = x[30] - f19; + f51 = x[30] + f19; + f52 = x[6] - f22; + f53 = x[6] + f22; + f54 = x[25] - f23; + f55 = x[25] + f23; + f56 = x[2] - f26; + f57 = x[2] + f26; + f58 = x[29] - f27; + f59 = x[29] + f27; + f60 = x[5] - f30; + f61 = x[5] + f30; + f62 = x[26] - f31; + f63 = x[26] + f31; + f64 = f39 + f37; + f65 = MUL_F(FRAC_CONST(-0.5411961001461969), f39); + f66 = MUL_F(FRAC_CONST(0.9238795325112867), f64); + f67 = MUL_C(COEF_CONST(1.3065629648763766), f37); + f68 = f65 + f66; + f69 = f67 - f66; + f70 = f38 + f36; + f71 = MUL_C(COEF_CONST(1.3065629648763770), f38); + f72 = MUL_F(FRAC_CONST(-0.3826834323650904), f70); + f73 = MUL_F(FRAC_CONST(0.5411961001461961), f36); + f74 = f71 + f72; + f75 = f73 - f72; + f76 = f47 + f45; + f77 = MUL_F(FRAC_CONST(-0.5411961001461969), f47); + f78 = MUL_F(FRAC_CONST(0.9238795325112867), f76); + f79 = MUL_C(COEF_CONST(1.3065629648763766), f45); + f80 = f77 + f78; + f81 = f79 - f78; + f82 = f46 + f44; + f83 = MUL_C(COEF_CONST(1.3065629648763770), f46); + f84 = MUL_F(FRAC_CONST(-0.3826834323650904), f82); + f85 = MUL_F(FRAC_CONST(0.5411961001461961), f44); + f86 = f83 + f84; + f87 = f85 - f84; + f88 = f55 + f53; + f89 = MUL_F(FRAC_CONST(-0.5411961001461969), f55); + f90 = MUL_F(FRAC_CONST(0.9238795325112867), f88); + f91 = MUL_C(COEF_CONST(1.3065629648763766), f53); + f92 = f89 + f90; + f93 = f91 - f90; + f94 = f54 + f52; + f95 = MUL_C(COEF_CONST(1.3065629648763770), f54); + f96 = MUL_F(FRAC_CONST(-0.3826834323650904), f94); + f97 = MUL_F(FRAC_CONST(0.5411961001461961), f52); + f98 = f95 + f96; + f99 = f97 - f96; + f100 = f63 + f61; + f101 = MUL_F(FRAC_CONST(-0.5411961001461969), f63); + f102 = MUL_F(FRAC_CONST(0.9238795325112867), f100); + f103 = MUL_C(COEF_CONST(1.3065629648763766), f61); + f104 = f101 + f102; + f105 = f103 - f102; + f106 = f62 + f60; + f107 = MUL_C(COEF_CONST(1.3065629648763770), f62); + f108 = MUL_F(FRAC_CONST(-0.3826834323650904), f106); + f109 = MUL_F(FRAC_CONST(0.5411961001461961), f60); + f110 = f107 + f108; + f111 = f109 - f108; + f112 = f33 - f68; + f113 = f33 + f68; + f114 = f35 - f69; + f115 = f35 + f69; + f116 = f32 - f74; + f117 = f32 + f74; + f118 = f34 - f75; + f119 = f34 + f75; + f120 = f41 - f80; + f121 = f41 + f80; + f122 = f43 - f81; + f123 = f43 + f81; + f124 = f40 - f86; + f125 = f40 + f86; + f126 = f42 - f87; + f127 = f42 + f87; + f128 = f49 - f92; + f129 = f49 + f92; + f130 = f51 - f93; + f131 = f51 + f93; + f132 = f48 - f98; + f133 = f48 + f98; + f134 = f50 - f99; + f135 = f50 + f99; + f136 = f57 - f104; + f137 = f57 + f104; + f138 = f59 - f105; + f139 = f59 + f105; + f140 = f56 - f110; + f141 = f56 + f110; + f142 = f58 - f111; + f143 = f58 + f111; + f144 = f123 + f121; + f145 = MUL_F(FRAC_CONST(-0.7856949583871021), f123); + f146 = MUL_F(FRAC_CONST(0.9807852804032304), f144); + f147 = MUL_C(COEF_CONST(1.1758756024193588), f121); + f148 = f145 + f146; + f149 = f147 - f146; + f150 = f127 + f125; + f151 = MUL_F(FRAC_CONST(0.2758993792829431), f127); + f152 = MUL_F(FRAC_CONST(0.5555702330196022), f150); + f153 = MUL_C(COEF_CONST(1.3870398453221475), f125); + f154 = f151 + f152; + f155 = f153 - f152; + f156 = f122 + f120; + f157 = MUL_C(COEF_CONST(1.1758756024193591), f122); + f158 = MUL_F(FRAC_CONST(-0.1950903220161287), f156); + f159 = MUL_F(FRAC_CONST(0.7856949583871016), f120); + f160 = f157 + f158; + f161 = f159 - f158; + f162 = f126 + f124; + f163 = MUL_C(COEF_CONST(1.3870398453221473), f126); + f164 = MUL_F(FRAC_CONST(-0.8314696123025455), f162); + f165 = MUL_F(FRAC_CONST(-0.2758993792829436), f124); + f166 = f163 + f164; + f167 = f165 - f164; + f168 = f139 + f137; + f169 = MUL_F(FRAC_CONST(-0.7856949583871021), f139); + f170 = MUL_F(FRAC_CONST(0.9807852804032304), f168); + f171 = MUL_C(COEF_CONST(1.1758756024193588), f137); + f172 = f169 + f170; + f173 = f171 - f170; + f174 = f143 + f141; + f175 = MUL_F(FRAC_CONST(0.2758993792829431), f143); + f176 = MUL_F(FRAC_CONST(0.5555702330196022), f174); + f177 = MUL_C(COEF_CONST(1.3870398453221475), f141); + f178 = f175 + f176; + f179 = f177 - f176; + f180 = f138 + f136; + f181 = MUL_C(COEF_CONST(1.1758756024193591), f138); + f182 = MUL_F(FRAC_CONST(-0.1950903220161287), f180); + f183 = MUL_F(FRAC_CONST(0.7856949583871016), f136); + f184 = f181 + f182; + f185 = f183 - f182; + f186 = f142 + f140; + f187 = MUL_C(COEF_CONST(1.3870398453221473), f142); + f188 = MUL_F(FRAC_CONST(-0.8314696123025455), f186); + f189 = MUL_F(FRAC_CONST(-0.2758993792829436), f140); + f190 = f187 + f188; + f191 = f189 - f188; + f192 = f113 - f148; + f193 = f113 + f148; + f194 = f115 - f149; + f195 = f115 + f149; + f196 = f117 - f154; + f197 = f117 + f154; + f198 = f119 - f155; + f199 = f119 + f155; + f200 = f112 - f160; + f201 = f112 + f160; + f202 = f114 - f161; + f203 = f114 + f161; + f204 = f116 - f166; + f205 = f116 + f166; + f206 = f118 - f167; + f207 = f118 + f167; + f208 = f129 - f172; + f209 = f129 + f172; + f210 = f131 - f173; + f211 = f131 + f173; + f212 = f133 - f178; + f213 = f133 + f178; + f214 = f135 - f179; + f215 = f135 + f179; + f216 = f128 - f184; + f217 = f128 + f184; + f218 = f130 - f185; + f219 = f130 + f185; + f220 = f132 - f190; + f221 = f132 + f190; + f222 = f134 - f191; + f223 = f134 + f191; + f224 = f211 + f209; + f225 = MUL_F(FRAC_CONST(-0.8971675863426361), f211); + f226 = MUL_F(FRAC_CONST(0.9951847266721968), f224); + f227 = MUL_C(COEF_CONST(1.0932018670017576), f209); + f228 = f225 + f226; + f229 = f227 - f226; + f230 = f215 + f213; + f231 = MUL_F(FRAC_CONST(-0.4105245275223571), f215); + f232 = MUL_F(FRAC_CONST(0.8819212643483549), f230); + f233 = MUL_C(COEF_CONST(1.3533180011743529), f213); + f234 = f231 + f232; + f235 = f233 - f232; + f236 = f219 + f217; + f237 = MUL_F(FRAC_CONST(0.1386171691990915), f219); + f238 = MUL_F(FRAC_CONST(0.6343932841636455), f236); + f239 = MUL_C(COEF_CONST(1.4074037375263826), f217); + f240 = f237 + f238; + f241 = f239 - f238; + f242 = f223 + f221; + f243 = MUL_F(FRAC_CONST(0.6666556584777466), f223); + f244 = MUL_F(FRAC_CONST(0.2902846772544623), f242); + f245 = MUL_C(COEF_CONST(1.2472250129866711), f221); + f246 = f243 + f244; + f247 = f245 - f244; + f248 = f210 + f208; + f249 = MUL_C(COEF_CONST(1.0932018670017574), f210); + f250 = MUL_F(FRAC_CONST(-0.0980171403295605), f248); + f251 = MUL_F(FRAC_CONST(0.8971675863426364), f208); + f252 = f249 + f250; + f253 = f251 - f250; + f254 = f214 + f212; + f255 = MUL_C(COEF_CONST(1.3533180011743529), f214); + f256 = MUL_F(FRAC_CONST(-0.4713967368259979), f254); + f257 = MUL_F(FRAC_CONST(0.4105245275223569), f212); + f258 = f255 + f256; + f259 = f257 - f256; + f260 = f218 + f216; + f261 = MUL_C(COEF_CONST(1.4074037375263826), f218); + f262 = MUL_F(FRAC_CONST(-0.7730104533627369), f260); + f263 = MUL_F(FRAC_CONST(-0.1386171691990913), f216); + f264 = f261 + f262; + f265 = f263 - f262; + f266 = f222 + f220; + f267 = MUL_C(COEF_CONST(1.2472250129866711), f222); + f268 = MUL_F(FRAC_CONST(-0.9569403357322089), f266); + f269 = MUL_F(FRAC_CONST(-0.6666556584777469), f220); + f270 = f267 + f268; + f271 = f269 - f268; + f272 = f193 - f228; + f273 = f193 + f228; + f274 = f195 - f229; + f275 = f195 + f229; + f276 = f197 - f234; + f277 = f197 + f234; + f278 = f199 - f235; + f279 = f199 + f235; + f280 = f201 - f240; + f281 = f201 + f240; + f282 = f203 - f241; + f283 = f203 + f241; + f284 = f205 - f246; + f285 = f205 + f246; + f286 = f207 - f247; + f287 = f207 + f247; + f288 = f192 - f252; + f289 = f192 + f252; + f290 = f194 - f253; + f291 = f194 + f253; + f292 = f196 - f258; + f293 = f196 + f258; + f294 = f198 - f259; + f295 = f198 + f259; + f296 = f200 - f264; + f297 = f200 + f264; + f298 = f202 - f265; + f299 = f202 + f265; + f300 = f204 - f270; + f301 = f204 + f270; + f302 = f206 - f271; + f303 = f206 + f271; + f304 = f275 + f273; + f305 = MUL_F(FRAC_CONST(-0.9751575901732920), f275); + f306 = MUL_F(FRAC_CONST(0.9996988186962043), f304); + f307 = MUL_C(COEF_CONST(1.0242400472191164), f273); + y[0] = f305 + f306; + y[31] = f307 - f306; + f310 = f279 + f277; + f311 = MUL_F(FRAC_CONST(-0.8700688593994936), f279); + f312 = MUL_F(FRAC_CONST(0.9924795345987100), f310); + f313 = MUL_C(COEF_CONST(1.1148902097979263), f277); + y[2] = f311 + f312; + y[29] = f313 - f312; + f316 = f283 + f281; + f317 = MUL_F(FRAC_CONST(-0.7566008898816587), f283); + f318 = MUL_F(FRAC_CONST(0.9757021300385286), f316); + f319 = MUL_C(COEF_CONST(1.1948033701953984), f281); + y[4] = f317 + f318; + y[27] = f319 - f318; + f322 = f287 + f285; + f323 = MUL_F(FRAC_CONST(-0.6358464401941451), f287); + f324 = MUL_F(FRAC_CONST(0.9495281805930367), f322); + f325 = MUL_C(COEF_CONST(1.2632099209919283), f285); + y[6] = f323 + f324; + y[25] = f325 - f324; + f328 = f291 + f289; + f329 = MUL_F(FRAC_CONST(-0.5089684416985408), f291); + f330 = MUL_F(FRAC_CONST(0.9142097557035307), f328); + f331 = MUL_C(COEF_CONST(1.3194510697085207), f289); + y[8] = f329 + f330; + y[23] = f331 - f330; + f334 = f295 + f293; + f335 = MUL_F(FRAC_CONST(-0.3771887988789273), f295); + f336 = MUL_F(FRAC_CONST(0.8700869911087114), f334); + f337 = MUL_C(COEF_CONST(1.3629851833384954), f293); + y[10] = f335 + f336; + y[21] = f337 - f336; + f340 = f299 + f297; + f341 = MUL_F(FRAC_CONST(-0.2417766217337384), f299); + f342 = MUL_F(FRAC_CONST(0.8175848131515837), f340); + f343 = MUL_C(COEF_CONST(1.3933930045694289), f297); + y[12] = f341 + f342; + y[19] = f343 - f342; + f346 = f303 + f301; + f347 = MUL_F(FRAC_CONST(-0.1040360035527077), f303); + f348 = MUL_F(FRAC_CONST(0.7572088465064845), f346); + f349 = MUL_C(COEF_CONST(1.4103816894602612), f301); + y[14] = f347 + f348; + y[17] = f349 - f348; + f352 = f274 + f272; + f353 = MUL_F(FRAC_CONST(0.0347065382144002), f274); + f354 = MUL_F(FRAC_CONST(0.6895405447370668), f352); + f355 = MUL_C(COEF_CONST(1.4137876276885337), f272); + y[16] = f353 + f354; + y[15] = f355 - f354; + f358 = f278 + f276; + f359 = MUL_F(FRAC_CONST(0.1731148370459795), f278); + f360 = MUL_F(FRAC_CONST(0.6152315905806268), f358); + f361 = MUL_C(COEF_CONST(1.4035780182072330), f276); + y[18] = f359 + f360; + y[13] = f361 - f360; + f364 = f282 + f280; + f365 = MUL_F(FRAC_CONST(0.3098559453626100), f282); + f366 = MUL_F(FRAC_CONST(0.5349976198870972), f364); + f367 = MUL_C(COEF_CONST(1.3798511851368043), f280); + y[20] = f365 + f366; + y[11] = f367 - f366; + f370 = f286 + f284; + f371 = MUL_F(FRAC_CONST(0.4436129715409088), f286); + f372 = MUL_F(FRAC_CONST(0.4496113296546065), f370); + f373 = MUL_C(COEF_CONST(1.3428356308501219), f284); + y[22] = f371 + f372; + y[9] = f373 - f372; + f376 = f290 + f288; + f377 = MUL_F(FRAC_CONST(0.5730977622997509), f290); + f378 = MUL_F(FRAC_CONST(0.3598950365349881), f376); + f379 = MUL_C(COEF_CONST(1.2928878353697271), f288); + y[24] = f377 + f378; + y[7] = f379 - f378; + f382 = f294 + f292; + f383 = MUL_F(FRAC_CONST(0.6970633083205415), f294); + f384 = MUL_F(FRAC_CONST(0.2667127574748984), f382); + f385 = MUL_C(COEF_CONST(1.2304888232703382), f292); + y[26] = f383 + f384; + y[5] = f385 - f384; + f388 = f298 + f296; + f389 = MUL_F(FRAC_CONST(0.8143157536286401), f298); + f390 = MUL_F(FRAC_CONST(0.1709618887603012), f388); + f391 = MUL_C(COEF_CONST(1.1562395311492424), f296); + y[28] = f389 + f390; + y[3] = f391 - f390; + f394 = f302 + f300; + f395 = MUL_F(FRAC_CONST(0.9237258930790228), f302); + f396 = MUL_F(FRAC_CONST(0.0735645635996674), f394); + f397 = MUL_C(COEF_CONST(1.0708550202783576), f300); + y[30] = f395 + f396; + y[1] = f397 - f396; +} + +#ifdef SBR_LOW_POWER + +void DCT2_16_unscaled(real_t *y, real_t *x) +{ + real_t f0, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10; + real_t f11, f12, f13, f14, f15, f16, f17, f18, f19, f20; + real_t f21, f22, f23, f24, f25, f26, f27, f28, f31, f32; + real_t f33, f34, f37, f38, f39, f40, f41, f42, f43, f44; + real_t f45, f46, f47, f48, f49, f51, f53, f54, f57, f58; + real_t f59, f60, f61, f62, f63, f64, f65, f66, f67, f68; + real_t f69, f70, f71, f72, f73, f74, f75, f76, f77, f78; + real_t f79, f80, f81, f82, f83, f84, f85, f86, f87, f88; + real_t f89, f90, f91, f92, f95, f96, f97, f98, f101, f102; + real_t f103, f104, f107, f108, f109, f110; + + f0 = x[0] - x[15]; + f1 = x[0] + x[15]; + f2 = x[1] - x[14]; + f3 = x[1] + x[14]; + f4 = x[2] - x[13]; + f5 = x[2] + x[13]; + f6 = x[3] - x[12]; + f7 = x[3] + x[12]; + f8 = x[4] - x[11]; + f9 = x[4] + x[11]; + f10 = x[5] - x[10]; + f11 = x[5] + x[10]; + f12 = x[6] - x[9]; + f13 = x[6] + x[9]; + f14 = x[7] - x[8]; + f15 = x[7] + x[8]; + f16 = f1 - f15; + f17 = f1 + f15; + f18 = f3 - f13; + f19 = f3 + f13; + f20 = f5 - f11; + f21 = f5 + f11; + f22 = f7 - f9; + f23 = f7 + f9; + f24 = f17 - f23; + f25 = f17 + f23; + f26 = f19 - f21; + f27 = f19 + f21; + f28 = f25 - f27; + y[0] = f25 + f27; + y[8] = MUL_F(f28, FRAC_CONST(0.7071067811865476)); + f31 = f24 + f26; + f32 = MUL_C(f24, COEF_CONST(1.3065629648763766)); + f33 = MUL_F(f31, FRAC_CONST(-0.9238795325112866)); + f34 = MUL_F(f26, FRAC_CONST(-0.5411961001461967)); + y[12] = f32 + f33; + y[4] = f34 - f33; + f37 = f16 + f22; + f38 = MUL_C(f16, COEF_CONST(1.1758756024193588)); + f39 = MUL_F(f37, FRAC_CONST(-0.9807852804032304)); + f40 = MUL_F(f22, FRAC_CONST(-0.7856949583871021)); + f41 = f38 + f39; + f42 = f40 - f39; + f43 = f18 + f20; + f44 = MUL_C(f18, COEF_CONST(1.3870398453221473)); + f45 = MUL_F(f43, FRAC_CONST(-0.8314696123025455)); + f46 = MUL_F(f20, FRAC_CONST(-0.2758993792829436)); + f47 = f44 + f45; + f48 = f46 - f45; + f49 = f42 - f48; + y[2] = f42 + f48; + f51 = MUL_F(f49, FRAC_CONST(0.7071067811865476)); + y[14] = f41 - f47; + f53 = f41 + f47; + f54 = MUL_F(f53, FRAC_CONST(0.7071067811865476)); + y[10] = f51 - f54; + y[6] = f51 + f54; + f57 = f2 - f4; + f58 = f2 + f4; + f59 = f6 - f8; + f60 = f6 + f8; + f61 = f10 - f12; + f62 = f10 + f12; + f63 = MUL_F(f60, FRAC_CONST(0.7071067811865476)); + f64 = f0 - f63; + f65 = f0 + f63; + f66 = f58 + f62; + f67 = MUL_C(f58, COEF_CONST(1.3065629648763766)); + f68 = MUL_F(f66, FRAC_CONST(-0.9238795325112866)); + f69 = MUL_F(f62, FRAC_CONST(-0.5411961001461967)); + f70 = f67 + f68; + f71 = f69 - f68; + f72 = f65 - f71; + f73 = f65 + f71; + f74 = f64 - f70; + f75 = f64 + f70; + f76 = MUL_F(f59, FRAC_CONST(0.7071067811865476)); + f77 = f14 - f76; + f78 = f14 + f76; + f79 = f61 + f57; + f80 = MUL_C(f61, COEF_CONST(1.3065629648763766)); + f81 = MUL_F(f79, FRAC_CONST(-0.9238795325112866)); + f82 = MUL_F(f57, FRAC_CONST(-0.5411961001461967)); + f83 = f80 + f81; + f84 = f82 - f81; + f85 = f78 - f84; + f86 = f78 + f84; + f87 = f77 - f83; + f88 = f77 + f83; + f89 = f86 + f73; + f90 = MUL_F(f86, FRAC_CONST(-0.8971675863426361)); + f91 = MUL_F(f89, FRAC_CONST(0.9951847266721968)); + f92 = MUL_C(f73, COEF_CONST(1.0932018670017576)); + y[1] = f90 + f91; + y[15] = f92 - f91; + f95 = f75 - f88; + f96 = MUL_F(f88, FRAC_CONST(-0.6666556584777466)); + f97 = MUL_F(f95, FRAC_CONST(0.9569403357322089)); + f98 = MUL_C(f75, COEF_CONST(1.2472250129866713)); + y[3] = f97 - f96; + y[13] = f98 - f97; + f101 = f87 + f74; + f102 = MUL_F(f87, FRAC_CONST(-0.4105245275223571)); + f103 = MUL_F(f101, FRAC_CONST(0.8819212643483549)); + f104 = MUL_C(f74, COEF_CONST(1.3533180011743529)); + y[5] = f102 + f103; + y[11] = f104 - f103; + f107 = f72 - f85; + f108 = MUL_F(f85, FRAC_CONST(-0.1386171691990915)); + f109 = MUL_F(f107, FRAC_CONST(0.7730104533627370)); + f110 = MUL_C(f72, COEF_CONST(1.4074037375263826)); + y[7] = f109 - f108; + y[9] = f110 - f109; +} + +void DCT4_16(real_t *y, real_t *x) +{ + real_t f0, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10; + real_t f11, f12, f13, f14, f15, f16, f17, f18, f19, f20; + real_t f21, f22, f23, f24, f25, f26, f27, f28, f29, f30; + real_t f31, f32, f33, f34, f35, f36, f37, f38, f39, f40; + real_t f41, f42, f43, f44, f45, f46, f47, f48, f49, f50; + real_t f51, f52, f53, f54, f55, f56, f57, f58, f59, f60; + real_t f61, f62, f63, f64, f65, f66, f67, f68, f69, f70; + real_t f71, f72, f73, f74, f75, f76, f77, f78, f79, f80; + real_t f81, f82, f83, f84, f85, f86, f87, f88, f89, f90; + real_t f91, f92, f93, f94, f95, f96, f97, f98, f99, f100; + real_t f101, f102, f103, f104, f105, f106, f107, f108, f109, f110; + real_t f111, f112, f113, f114, f115, f116, f117, f118, f119, f120; + real_t f121, f122, f123, f124, f125, f126, f127, f128, f130, f132; + real_t f134, f136, f138, f140, f142, f144, f145, f148, f149, f152; + real_t f153, f156, f157; + + f0 = x[0] + x[15]; + f1 = MUL_C(COEF_CONST(1.0478631305325901), x[0]); + f2 = MUL_F(FRAC_CONST(-0.9987954562051724), f0); + f3 = MUL_F(FRAC_CONST(-0.9497277818777548), x[15]); + f4 = f1 + f2; + f5 = f3 - f2; + f6 = x[2] + x[13]; + f7 = MUL_C(COEF_CONST(1.2130114330978077), x[2]); + f8 = MUL_F(FRAC_CONST(-0.9700312531945440), f6); + f9 = MUL_F(FRAC_CONST(-0.7270510732912803), x[13]); + f10 = f7 + f8; + f11 = f9 - f8; + f12 = x[4] + x[11]; + f13 = MUL_C(COEF_CONST(1.3315443865537255), x[4]); + f14 = MUL_F(FRAC_CONST(-0.9039892931234433), f12); + f15 = MUL_F(FRAC_CONST(-0.4764341996931612), x[11]); + f16 = f13 + f14; + f17 = f15 - f14; + f18 = x[6] + x[9]; + f19 = MUL_C(COEF_CONST(1.3989068359730781), x[6]); + f20 = MUL_F(FRAC_CONST(-0.8032075314806453), f18); + f21 = MUL_F(FRAC_CONST(-0.2075082269882124), x[9]); + f22 = f19 + f20; + f23 = f21 - f20; + f24 = x[8] + x[7]; + f25 = MUL_C(COEF_CONST(1.4125100802019777), x[8]); + f26 = MUL_F(FRAC_CONST(-0.6715589548470187), f24); + f27 = MUL_F(FRAC_CONST(0.0693921705079402), x[7]); + f28 = f25 + f26; + f29 = f27 - f26; + f30 = x[10] + x[5]; + f31 = MUL_C(COEF_CONST(1.3718313541934939), x[10]); + f32 = MUL_F(FRAC_CONST(-0.5141027441932219), f30); + f33 = MUL_F(FRAC_CONST(0.3436258658070501), x[5]); + f34 = f31 + f32; + f35 = f33 - f32; + f36 = x[12] + x[3]; + f37 = MUL_C(COEF_CONST(1.2784339185752409), x[12]); + f38 = MUL_F(FRAC_CONST(-0.3368898533922200), f36); + f39 = MUL_F(FRAC_CONST(0.6046542117908008), x[3]); + f40 = f37 + f38; + f41 = f39 - f38; + f42 = x[14] + x[1]; + f43 = MUL_C(COEF_CONST(1.1359069844201433), x[14]); + f44 = MUL_F(FRAC_CONST(-0.1467304744553624), f42); + f45 = MUL_F(FRAC_CONST(0.8424460355094185), x[1]); + f46 = f43 + f44; + f47 = f45 - f44; + f48 = f5 - f29; + f49 = f5 + f29; + f50 = f4 - f28; + f51 = f4 + f28; + f52 = f11 - f35; + f53 = f11 + f35; + f54 = f10 - f34; + f55 = f10 + f34; + f56 = f17 - f41; + f57 = f17 + f41; + f58 = f16 - f40; + f59 = f16 + f40; + f60 = f23 - f47; + f61 = f23 + f47; + f62 = f22 - f46; + f63 = f22 + f46; + f64 = f48 + f50; + f65 = MUL_C(COEF_CONST(1.1758756024193588), f48); + f66 = MUL_F(FRAC_CONST(-0.9807852804032304), f64); + f67 = MUL_F(FRAC_CONST(-0.7856949583871021), f50); + f68 = f65 + f66; + f69 = f67 - f66; + f70 = f52 + f54; + f71 = MUL_C(COEF_CONST(1.3870398453221475), f52); + f72 = MUL_F(FRAC_CONST(-0.5555702330196022), f70); + f73 = MUL_F(FRAC_CONST(0.2758993792829431), f54); + f74 = f71 + f72; + f75 = f73 - f72; + f76 = f56 + f58; + f77 = MUL_F(FRAC_CONST(0.7856949583871022), f56); + f78 = MUL_F(FRAC_CONST(0.1950903220161283), f76); + f79 = MUL_C(COEF_CONST(1.1758756024193586), f58); + f80 = f77 + f78; + f81 = f79 - f78; + f82 = f60 + f62; + f83 = MUL_F(FRAC_CONST(-0.2758993792829430), f60); + f84 = MUL_F(FRAC_CONST(0.8314696123025452), f82); + f85 = MUL_C(COEF_CONST(1.3870398453221475), f62); + f86 = f83 + f84; + f87 = f85 - f84; + f88 = f49 - f57; + f89 = f49 + f57; + f90 = f51 - f59; + f91 = f51 + f59; + f92 = f53 - f61; + f93 = f53 + f61; + f94 = f55 - f63; + f95 = f55 + f63; + f96 = f69 - f81; + f97 = f69 + f81; + f98 = f68 - f80; + f99 = f68 + f80; + f100 = f75 - f87; + f101 = f75 + f87; + f102 = f74 - f86; + f103 = f74 + f86; + f104 = f88 + f90; + f105 = MUL_C(COEF_CONST(1.3065629648763766), f88); + f106 = MUL_F(FRAC_CONST(-0.9238795325112866), f104); + f107 = MUL_F(FRAC_CONST(-0.5411961001461967), f90); + f108 = f105 + f106; + f109 = f107 - f106; + f110 = f92 + f94; + f111 = MUL_F(FRAC_CONST(0.5411961001461969), f92); + f112 = MUL_F(FRAC_CONST(0.3826834323650898), f110); + f113 = MUL_C(COEF_CONST(1.3065629648763766), f94); + f114 = f111 + f112; + f115 = f113 - f112; + f116 = f96 + f98; + f117 = MUL_C(COEF_CONST(1.3065629648763766), f96); + f118 = MUL_F(FRAC_CONST(-0.9238795325112866), f116); + f119 = MUL_F(FRAC_CONST(-0.5411961001461967), f98); + f120 = f117 + f118; + f121 = f119 - f118; + f122 = f100 + f102; + f123 = MUL_F(FRAC_CONST(0.5411961001461969), f100); + f124 = MUL_F(FRAC_CONST(0.3826834323650898), f122); + f125 = MUL_C(COEF_CONST(1.3065629648763766), f102); + f126 = f123 + f124; + f127 = f125 - f124; + f128 = f89 - f93; + y[0] = f89 + f93; + f130 = f91 - f95; + y[15] = f91 + f95; + f132 = f109 - f115; + y[3] = f109 + f115; + f134 = f108 - f114; + y[12] = f108 + f114; + f136 = f97 - f101; + y[1] = f97 + f101; + f138 = f99 - f103; + y[14] = f99 + f103; + f140 = f121 - f127; + y[2] = f121 + f127; + f142 = f120 - f126; + y[13] = f120 + f126; + f144 = f128 - f130; + f145 = f128 + f130; + y[8] = MUL_F(FRAC_CONST(0.7071067811865474), f144); + y[7] = MUL_F(FRAC_CONST(0.7071067811865474), f145); + f148 = f132 - f134; + f149 = f132 + f134; + y[11] = MUL_F(FRAC_CONST(0.7071067811865474), f148); + y[4] = MUL_F(FRAC_CONST(0.7071067811865474), f149); + f152 = f136 - f138; + f153 = f136 + f138; + y[9] = MUL_F(FRAC_CONST(0.7071067811865474), f152); + y[6] = MUL_F(FRAC_CONST(0.7071067811865474), f153); + f156 = f140 - f142; + f157 = f140 + f142; + y[10] = MUL_F(FRAC_CONST(0.7071067811865474), f156); + y[5] = MUL_F(FRAC_CONST(0.7071067811865474), f157); +} + +void DCT3_32_unscaled(real_t *y, real_t *x) +{ + real_t f0, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10; + real_t f11, f12, f13, f14, f15, f16, f17, f18, f19, f20; + real_t f21, f22, f23, f24, f25, f26, f27, f28, f29, f30; + real_t f31, f32, f33, f34, f35, f36, f37, f38, f39, f40; + real_t f41, f42, f43, f44, f45, f46, f47, f48, f49, f50; + real_t f51, f52, f53, f54, f55, f56, f57, f58, f59, f60; + real_t f61, f62, f63, f64, f65, f66, f67, f68, f69, f70; + real_t f71, f72, f73, f74, f75, f76, f77, f78, f79, f80; + real_t f81, f82, f83, f84, f85, f86, f87, f88, f89, f90; + real_t f91, f92, f93, f94, f95, f96, f97, f98, f99, f100; + real_t f101, f102, f103, f104, f105, f106, f107, f108, f109, f110; + real_t f111, f112, f113, f114, f115, f116, f117, f118, f119, f120; + real_t f121, f122, f123, f124, f125, f126, f127, f128, f129, f130; + real_t f131, f132, f133, f134, f135, f136, f137, f138, f139, f140; + real_t f141, f142, f143, f144, f145, f146, f147, f148, f149, f150; + real_t f151, f152, f153, f154, f155, f156, f157, f158, f159, f160; + real_t f161, f162, f163, f164, f165, f166, f167, f168, f169, f170; + real_t f171, f172, f173, f174, f175, f176, f177, f178, f179, f180; + real_t f181, f182, f183, f184, f185, f186, f187, f188, f189, f190; + real_t f191, f192, f193, f194, f195, f196, f197, f198, f199, f200; + real_t f201, f202, f203, f204, f205, f206, f207, f208, f209, f210; + real_t f211, f212, f213, f214, f215, f216, f217, f218, f219, f220; + real_t f221, f222, f223, f224, f225, f226, f227, f228, f229, f230; + real_t f231, f232, f233, f234, f235, f236, f237, f238, f239, f240; + real_t f241, f242, f243, f244, f245, f246, f247, f248, f249, f250; + real_t f251, f252, f253, f254, f255, f256, f257, f258, f259, f260; + real_t f261, f262, f263, f264, f265, f266, f267, f268, f269, f270; + real_t f271, f272; + + f0 = MUL_F(x[16], FRAC_CONST(0.7071067811865476)); + f1 = x[0] - f0; + f2 = x[0] + f0; + f3 = x[8] + x[24]; + f4 = MUL_C(x[8], COEF_CONST(1.3065629648763766)); + f5 = MUL_F(f3, FRAC_CONST((-0.9238795325112866))); + f6 = MUL_F(x[24], FRAC_CONST((-0.5411961001461967))); + f7 = f4 + f5; + f8 = f6 - f5; + f9 = f2 - f8; + f10 = f2 + f8; + f11 = f1 - f7; + f12 = f1 + f7; + f13 = x[4] + x[28]; + f14 = MUL_C(x[4], COEF_CONST(1.1758756024193588)); + f15 = MUL_F(f13, FRAC_CONST((-0.9807852804032304))); + f16 = MUL_F(x[28], FRAC_CONST((-0.7856949583871021))); + f17 = f14 + f15; + f18 = f16 - f15; + f19 = x[12] + x[20]; + f20 = MUL_C(x[12], COEF_CONST(1.3870398453221473)); + f21 = MUL_F(f19, FRAC_CONST((-0.8314696123025455))); + f22 = MUL_F(x[20], FRAC_CONST((-0.2758993792829436))); + f23 = f20 + f21; + f24 = f22 - f21; + f25 = f18 - f24; + f26 = f18 + f24; + f27 = MUL_F(f25, FRAC_CONST(0.7071067811865476)); + f28 = f17 - f23; + f29 = f17 + f23; + f30 = MUL_F(f29, FRAC_CONST(0.7071067811865476)); + f31 = f27 - f30; + f32 = f27 + f30; + f33 = f10 - f26; + f34 = f10 + f26; + f35 = f12 - f32; + f36 = f12 + f32; + f37 = f11 - f31; + f38 = f11 + f31; + f39 = f9 - f28; + f40 = f9 + f28; + f41 = x[2] + x[30]; + f42 = MUL_C(x[2], COEF_CONST(1.0932018670017569)); + f43 = MUL_F(f41, FRAC_CONST((-0.9951847266721969))); + f44 = MUL_F(x[30], FRAC_CONST((-0.8971675863426368))); + f45 = f42 + f43; + f46 = f44 - f43; + f47 = x[6] + x[26]; + f48 = MUL_C(x[6], COEF_CONST(1.2472250129866711)); + f49 = MUL_F(f47, FRAC_CONST((-0.9569403357322089))); + f50 = MUL_F(x[26], FRAC_CONST((-0.6666556584777469))); + f51 = f48 + f49; + f52 = f50 - f49; + f53 = x[10] + x[22]; + f54 = MUL_C(x[10], COEF_CONST(1.3533180011743526)); + f55 = MUL_F(f53, FRAC_CONST((-0.8819212643483551))); + f56 = MUL_F(x[22], FRAC_CONST((-0.4105245275223575))); + f57 = f54 + f55; + f58 = f56 - f55; + f59 = x[14] + x[18]; + f60 = MUL_C(x[14], COEF_CONST(1.4074037375263826)); + f61 = MUL_F(f59, FRAC_CONST((-0.7730104533627369))); + f62 = MUL_F(x[18], FRAC_CONST((-0.1386171691990913))); + f63 = f60 + f61; + f64 = f62 - f61; + f65 = f46 - f64; + f66 = f46 + f64; + f67 = f52 - f58; + f68 = f52 + f58; + f69 = f66 - f68; + f70 = f66 + f68; + f71 = MUL_F(f69, FRAC_CONST(0.7071067811865476)); + f72 = f65 + f67; + f73 = MUL_C(f65, COEF_CONST(1.3065629648763766)); + f74 = MUL_F(f72, FRAC_CONST((-0.9238795325112866))); + f75 = MUL_F(f67, FRAC_CONST((-0.5411961001461967))); + f76 = f73 + f74; + f77 = f75 - f74; + f78 = f45 - f63; + f79 = f45 + f63; + f80 = f51 - f57; + f81 = f51 + f57; + f82 = f79 + f81; + f83 = MUL_C(f79, COEF_CONST(1.3065629648763770)); + f84 = MUL_F(f82, FRAC_CONST((-0.3826834323650904))); + f85 = MUL_F(f81, FRAC_CONST(0.5411961001461961)); + f86 = f83 + f84; + f87 = f85 - f84; + f88 = f78 - f80; + f89 = f78 + f80; + f90 = MUL_F(f89, FRAC_CONST(0.7071067811865476)); + f91 = f77 - f87; + f92 = f77 + f87; + f93 = f71 - f90; + f94 = f71 + f90; + f95 = f76 - f86; + f96 = f76 + f86; + f97 = f34 - f70; + f98 = f34 + f70; + f99 = f36 - f92; + f100 = f36 + f92; + f101 = f38 - f91; + f102 = f38 + f91; + f103 = f40 - f94; + f104 = f40 + f94; + f105 = f39 - f93; + f106 = f39 + f93; + f107 = f37 - f96; + f108 = f37 + f96; + f109 = f35 - f95; + f110 = f35 + f95; + f111 = f33 - f88; + f112 = f33 + f88; + f113 = x[1] + x[31]; + f114 = MUL_C(x[1], COEF_CONST(1.0478631305325901)); + f115 = MUL_F(f113, FRAC_CONST((-0.9987954562051724))); + f116 = MUL_F(x[31], FRAC_CONST((-0.9497277818777548))); + f117 = f114 + f115; + f118 = f116 - f115; + f119 = x[5] + x[27]; + f120 = MUL_C(x[5], COEF_CONST(1.2130114330978077)); + f121 = MUL_F(f119, FRAC_CONST((-0.9700312531945440))); + f122 = MUL_F(x[27], FRAC_CONST((-0.7270510732912803))); + f123 = f120 + f121; + f124 = f122 - f121; + f125 = x[9] + x[23]; + f126 = MUL_C(x[9], COEF_CONST(1.3315443865537255)); + f127 = MUL_F(f125, FRAC_CONST((-0.9039892931234433))); + f128 = MUL_F(x[23], FRAC_CONST((-0.4764341996931612))); + f129 = f126 + f127; + f130 = f128 - f127; + f131 = x[13] + x[19]; + f132 = MUL_C(x[13], COEF_CONST(1.3989068359730781)); + f133 = MUL_F(f131, FRAC_CONST((-0.8032075314806453))); + f134 = MUL_F(x[19], FRAC_CONST((-0.2075082269882124))); + f135 = f132 + f133; + f136 = f134 - f133; + f137 = x[17] + x[15]; + f138 = MUL_C(x[17], COEF_CONST(1.4125100802019777)); + f139 = MUL_F(f137, FRAC_CONST((-0.6715589548470187))); + f140 = MUL_F(x[15], FRAC_CONST(0.0693921705079402)); + f141 = f138 + f139; + f142 = f140 - f139; + f143 = x[21] + x[11]; + f144 = MUL_C(x[21], COEF_CONST(1.3718313541934939)); + f145 = MUL_F(f143, FRAC_CONST((-0.5141027441932219))); + f146 = MUL_F(x[11], FRAC_CONST(0.3436258658070501)); + f147 = f144 + f145; + f148 = f146 - f145; + f149 = x[25] + x[7]; + f150 = MUL_C(x[25], COEF_CONST(1.2784339185752409)); + f151 = MUL_F(f149, FRAC_CONST((-0.3368898533922200))); + f152 = MUL_F(x[7], FRAC_CONST(0.6046542117908008)); + f153 = f150 + f151; + f154 = f152 - f151; + f155 = x[29] + x[3]; + f156 = MUL_C(x[29], COEF_CONST(1.1359069844201433)); + f157 = MUL_F(f155, FRAC_CONST((-0.1467304744553624))); + f158 = MUL_F(x[3], FRAC_CONST(0.8424460355094185)); + f159 = f156 + f157; + f160 = f158 - f157; + f161 = f118 - f142; + f162 = f118 + f142; + f163 = f117 - f141; + f164 = f117 + f141; + f165 = f124 - f148; + f166 = f124 + f148; + f167 = f123 - f147; + f168 = f123 + f147; + f169 = f130 - f154; + f170 = f130 + f154; + f171 = f129 - f153; + f172 = f129 + f153; + f173 = f136 - f160; + f174 = f136 + f160; + f175 = f135 - f159; + f176 = f135 + f159; + f177 = f161 + f163; + f178 = MUL_C(f161, COEF_CONST(1.1758756024193588)); + f179 = MUL_F(f177, FRAC_CONST((-0.9807852804032304))); + f180 = MUL_F(f163, FRAC_CONST((-0.7856949583871021))); + f181 = f178 + f179; + f182 = f180 - f179; + f183 = f165 + f167; + f184 = MUL_C(f165, COEF_CONST(1.3870398453221475)); + f185 = MUL_F(f183, FRAC_CONST((-0.5555702330196022))); + f186 = MUL_F(f167, FRAC_CONST(0.2758993792829431)); + f187 = f184 + f185; + f188 = f186 - f185; + f189 = f169 + f171; + f190 = MUL_F(f169, FRAC_CONST(0.7856949583871022)); + f191 = MUL_F(f189, FRAC_CONST(0.1950903220161283)); + f192 = MUL_C(f171, COEF_CONST(1.1758756024193586)); + f193 = f190 + f191; + f194 = f192 - f191; + f195 = f173 + f175; + f196 = MUL_F(f173, FRAC_CONST((-0.2758993792829430))); + f197 = MUL_F(f195, FRAC_CONST(0.8314696123025452)); + f198 = MUL_C(f175, COEF_CONST(1.3870398453221475)); + f199 = f196 + f197; + f200 = f198 - f197; + f201 = f162 - f170; + f202 = f162 + f170; + f203 = f164 - f172; + f204 = f164 + f172; + f205 = f166 - f174; + f206 = f166 + f174; + f207 = f168 - f176; + f208 = f168 + f176; + f209 = f182 - f194; + f210 = f182 + f194; + f211 = f181 - f193; + f212 = f181 + f193; + f213 = f188 - f200; + f214 = f188 + f200; + f215 = f187 - f199; + f216 = f187 + f199; + f217 = f201 + f203; + f218 = MUL_C(f201, COEF_CONST(1.3065629648763766)); + f219 = MUL_F(f217, FRAC_CONST((-0.9238795325112866))); + f220 = MUL_F(f203, FRAC_CONST((-0.5411961001461967))); + f221 = f218 + f219; + f222 = f220 - f219; + f223 = f205 + f207; + f224 = MUL_F(f205, FRAC_CONST(0.5411961001461969)); + f225 = MUL_F(f223, FRAC_CONST(0.3826834323650898)); + f226 = MUL_C(f207, COEF_CONST(1.3065629648763766)); + f227 = f224 + f225; + f228 = f226 - f225; + f229 = f209 + f211; + f230 = MUL_C(f209, COEF_CONST(1.3065629648763766)); + f231 = MUL_F(f229, FRAC_CONST((-0.9238795325112866))); + f232 = MUL_F(f211, FRAC_CONST((-0.5411961001461967))); + f233 = f230 + f231; + f234 = f232 - f231; + f235 = f213 + f215; + f236 = MUL_F(f213, FRAC_CONST(0.5411961001461969)); + f237 = MUL_F(f235, FRAC_CONST(0.3826834323650898)); + f238 = MUL_C(f215, COEF_CONST(1.3065629648763766)); + f239 = f236 + f237; + f240 = f238 - f237; + f241 = f202 - f206; + f242 = f202 + f206; + f243 = f204 - f208; + f244 = f204 + f208; + f245 = f222 - f228; + f246 = f222 + f228; + f247 = f221 - f227; + f248 = f221 + f227; + f249 = f210 - f214; + f250 = f210 + f214; + f251 = f212 - f216; + f252 = f212 + f216; + f253 = f234 - f240; + f254 = f234 + f240; + f255 = f233 - f239; + f256 = f233 + f239; + f257 = f241 - f243; + f258 = f241 + f243; + f259 = MUL_F(f257, FRAC_CONST(0.7071067811865474)); + f260 = MUL_F(f258, FRAC_CONST(0.7071067811865474)); + f261 = f245 - f247; + f262 = f245 + f247; + f263 = MUL_F(f261, FRAC_CONST(0.7071067811865474)); + f264 = MUL_F(f262, FRAC_CONST(0.7071067811865474)); + f265 = f249 - f251; + f266 = f249 + f251; + f267 = MUL_F(f265, FRAC_CONST(0.7071067811865474)); + f268 = MUL_F(f266, FRAC_CONST(0.7071067811865474)); + f269 = f253 - f255; + f270 = f253 + f255; + f271 = MUL_F(f269, FRAC_CONST(0.7071067811865474)); + f272 = MUL_F(f270, FRAC_CONST(0.7071067811865474)); + y[31] = f98 - f242; + y[0] = f98 + f242; + y[30] = f100 - f250; + y[1] = f100 + f250; + y[29] = f102 - f254; + y[2] = f102 + f254; + y[28] = f104 - f246; + y[3] = f104 + f246; + y[27] = f106 - f264; + y[4] = f106 + f264; + y[26] = f108 - f272; + y[5] = f108 + f272; + y[25] = f110 - f268; + y[6] = f110 + f268; + y[24] = f112 - f260; + y[7] = f112 + f260; + y[23] = f111 - f259; + y[8] = f111 + f259; + y[22] = f109 - f267; + y[9] = f109 + f267; + y[21] = f107 - f271; + y[10] = f107 + f271; + y[20] = f105 - f263; + y[11] = f105 + f263; + y[19] = f103 - f248; + y[12] = f103 + f248; + y[18] = f101 - f256; + y[13] = f101 + f256; + y[17] = f99 - f252; + y[14] = f99 + f252; + y[16] = f97 - f244; + y[15] = f97 + f244; +} + +void DCT2_32_unscaled(real_t *y, real_t *x) +{ + real_t f0, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10; + real_t f11, f12, f13, f14, f15, f16, f17, f18, f19, f20; + real_t f21, f22, f23, f24, f25, f26, f27, f28, f29, f30; + real_t f31, f32, f33, f34, f35, f36, f37, f38, f39, f40; + real_t f41, f42, f43, f44, f45, f46, f47, f48, f49, f50; + real_t f51, f52, f53, f54, f55, f56, f57, f58, f59, f60; + real_t f63, f64, f65, f66, f69, f70, f71, f72, f73, f74; + real_t f75, f76, f77, f78, f79, f80, f81, f83, f85, f86; + real_t f89, f90, f91, f92, f93, f94, f95, f96, f97, f98; + real_t f99, f100, f101, f102, f103, f104, f105, f106, f107, f108; + real_t f109, f110, f111, f112, f113, f114, f115, f116, f117, f118; + real_t f119, f120, f121, f122, f123, f124, f127, f128, f129, f130; + real_t f133, f134, f135, f136, f139, f140, f141, f142, f145, f146; + real_t f147, f148, f149, f150, f151, f152, f153, f154, f155, f156; + real_t f157, f158, f159, f160, f161, f162, f163, f164, f165, f166; + real_t f167, f168, f169, f170, f171, f172, f173, f174, f175, f176; + real_t f177, f178, f179, f180, f181, f182, f183, f184, f185, f186; + real_t f187, f188, f189, f190, f191, f192, f193, f194, f195, f196; + real_t f197, f198, f199, f200, f201, f202, f203, f204, f205, f206; + real_t f207, f208, f209, f210, f211, f212, f213, f214, f215, f216; + real_t f217, f218, f219, f220, f221, f222, f223, f224, f225, f226; + real_t f227, f228, f229, f230, f231, f232, f233, f234, f235, f236; + real_t f237, f238, f239, f240, f241, f242, f243, f244, f247, f248; + real_t f249, f250, f253, f254, f255, f256, f259, f260, f261, f262; + real_t f265, f266, f267, f268, f271, f272, f273, f274, f277, f278; + real_t f279, f280, f283, f284, f285, f286; + + f0 = x[0] - x[31]; + f1 = x[0] + x[31]; + f2 = x[1] - x[30]; + f3 = x[1] + x[30]; + f4 = x[2] - x[29]; + f5 = x[2] + x[29]; + f6 = x[3] - x[28]; + f7 = x[3] + x[28]; + f8 = x[4] - x[27]; + f9 = x[4] + x[27]; + f10 = x[5] - x[26]; + f11 = x[5] + x[26]; + f12 = x[6] - x[25]; + f13 = x[6] + x[25]; + f14 = x[7] - x[24]; + f15 = x[7] + x[24]; + f16 = x[8] - x[23]; + f17 = x[8] + x[23]; + f18 = x[9] - x[22]; + f19 = x[9] + x[22]; + f20 = x[10] - x[21]; + f21 = x[10] + x[21]; + f22 = x[11] - x[20]; + f23 = x[11] + x[20]; + f24 = x[12] - x[19]; + f25 = x[12] + x[19]; + f26 = x[13] - x[18]; + f27 = x[13] + x[18]; + f28 = x[14] - x[17]; + f29 = x[14] + x[17]; + f30 = x[15] - x[16]; + f31 = x[15] + x[16]; + f32 = f1 - f31; + f33 = f1 + f31; + f34 = f3 - f29; + f35 = f3 + f29; + f36 = f5 - f27; + f37 = f5 + f27; + f38 = f7 - f25; + f39 = f7 + f25; + f40 = f9 - f23; + f41 = f9 + f23; + f42 = f11 - f21; + f43 = f11 + f21; + f44 = f13 - f19; + f45 = f13 + f19; + f46 = f15 - f17; + f47 = f15 + f17; + f48 = f33 - f47; + f49 = f33 + f47; + f50 = f35 - f45; + f51 = f35 + f45; + f52 = f37 - f43; + f53 = f37 + f43; + f54 = f39 - f41; + f55 = f39 + f41; + f56 = f49 - f55; + f57 = f49 + f55; + f58 = f51 - f53; + f59 = f51 + f53; + f60 = f57 - f59; + y[0] = f57 + f59; + y[16] = MUL_F(FRAC_CONST(0.7071067811865476), f60); + f63 = f56 + f58; + f64 = MUL_C(COEF_CONST(1.3065629648763766), f56); + f65 = MUL_F(FRAC_CONST(-0.9238795325112866), f63); + f66 = MUL_F(FRAC_CONST(-0.5411961001461967), f58); + y[24] = f64 + f65; + y[8] = f66 - f65; + f69 = f48 + f54; + f70 = MUL_C(COEF_CONST(1.1758756024193588), f48); + f71 = MUL_F(FRAC_CONST(-0.9807852804032304), f69); + f72 = MUL_F(FRAC_CONST(-0.7856949583871021), f54); + f73 = f70 + f71; + f74 = f72 - f71; + f75 = f50 + f52; + f76 = MUL_C(COEF_CONST(1.3870398453221473), f50); + f77 = MUL_F(FRAC_CONST(-0.8314696123025455), f75); + f78 = MUL_F(FRAC_CONST(-0.2758993792829436), f52); + f79 = f76 + f77; + f80 = f78 - f77; + f81 = f74 - f80; + y[4] = f74 + f80; + f83 = MUL_F(FRAC_CONST(0.7071067811865476), f81); + y[28] = f73 - f79; + f85 = f73 + f79; + f86 = MUL_F(FRAC_CONST(0.7071067811865476), f85); + y[20] = f83 - f86; + y[12] = f83 + f86; + f89 = f34 - f36; + f90 = f34 + f36; + f91 = f38 - f40; + f92 = f38 + f40; + f93 = f42 - f44; + f94 = f42 + f44; + f95 = MUL_F(FRAC_CONST(0.7071067811865476), f92); + f96 = f32 - f95; + f97 = f32 + f95; + f98 = f90 + f94; + f99 = MUL_C(COEF_CONST(1.3065629648763766), f90); + f100 = MUL_F(FRAC_CONST(-0.9238795325112866), f98); + f101 = MUL_F(FRAC_CONST(-0.5411961001461967), f94); + f102 = f99 + f100; + f103 = f101 - f100; + f104 = f97 - f103; + f105 = f97 + f103; + f106 = f96 - f102; + f107 = f96 + f102; + f108 = MUL_F(FRAC_CONST(0.7071067811865476), f91); + f109 = f46 - f108; + f110 = f46 + f108; + f111 = f93 + f89; + f112 = MUL_C(COEF_CONST(1.3065629648763766), f93); + f113 = MUL_F(FRAC_CONST(-0.9238795325112866), f111); + f114 = MUL_F(FRAC_CONST(-0.5411961001461967), f89); + f115 = f112 + f113; + f116 = f114 - f113; + f117 = f110 - f116; + f118 = f110 + f116; + f119 = f109 - f115; + f120 = f109 + f115; + f121 = f118 + f105; + f122 = MUL_F(FRAC_CONST(-0.8971675863426361), f118); + f123 = MUL_F(FRAC_CONST(0.9951847266721968), f121); + f124 = MUL_C(COEF_CONST(1.0932018670017576), f105); + y[2] = f122 + f123; + y[30] = f124 - f123; + f127 = f107 - f120; + f128 = MUL_F(FRAC_CONST(-0.6666556584777466), f120); + f129 = MUL_F(FRAC_CONST(0.9569403357322089), f127); + f130 = MUL_C(COEF_CONST(1.2472250129866713), f107); + y[6] = f129 - f128; + y[26] = f130 - f129; + f133 = f119 + f106; + f134 = MUL_F(FRAC_CONST(-0.4105245275223571), f119); + f135 = MUL_F(FRAC_CONST(0.8819212643483549), f133); + f136 = MUL_C(COEF_CONST(1.3533180011743529), f106); + y[10] = f134 + f135; + y[22] = f136 - f135; + f139 = f104 - f117; + f140 = MUL_F(FRAC_CONST(-0.1386171691990915), f117); + f141 = MUL_F(FRAC_CONST(0.7730104533627370), f139); + f142 = MUL_C(COEF_CONST(1.4074037375263826), f104); + y[14] = f141 - f140; + y[18] = f142 - f141; + f145 = f2 - f4; + f146 = f2 + f4; + f147 = f6 - f8; + f148 = f6 + f8; + f149 = f10 - f12; + f150 = f10 + f12; + f151 = f14 - f16; + f152 = f14 + f16; + f153 = f18 - f20; + f154 = f18 + f20; + f155 = f22 - f24; + f156 = f22 + f24; + f157 = f26 - f28; + f158 = f26 + f28; + f159 = MUL_F(FRAC_CONST(0.7071067811865476), f152); + f160 = f0 - f159; + f161 = f0 + f159; + f162 = f148 + f156; + f163 = MUL_C(COEF_CONST(1.3065629648763766), f148); + f164 = MUL_F(FRAC_CONST(-0.9238795325112866), f162); + f165 = MUL_F(FRAC_CONST(-0.5411961001461967), f156); + f166 = f163 + f164; + f167 = f165 - f164; + f168 = f161 - f167; + f169 = f161 + f167; + f170 = f160 - f166; + f171 = f160 + f166; + f172 = f146 + f158; + f173 = MUL_C(COEF_CONST(1.1758756024193588), f146); + f174 = MUL_F(FRAC_CONST(-0.9807852804032304), f172); + f175 = MUL_F(FRAC_CONST(-0.7856949583871021), f158); + f176 = f173 + f174; + f177 = f175 - f174; + f178 = f150 + f154; + f179 = MUL_C(COEF_CONST(1.3870398453221473), f150); + f180 = MUL_F(FRAC_CONST(-0.8314696123025455), f178); + f181 = MUL_F(FRAC_CONST(-0.2758993792829436), f154); + f182 = f179 + f180; + f183 = f181 - f180; + f184 = f177 - f183; + f185 = f177 + f183; + f186 = MUL_F(FRAC_CONST(0.7071067811865476), f184); + f187 = f176 - f182; + f188 = f176 + f182; + f189 = MUL_F(FRAC_CONST(0.7071067811865476), f188); + f190 = f186 - f189; + f191 = f186 + f189; + f192 = f169 - f185; + f193 = f169 + f185; + f194 = f171 - f191; + f195 = f171 + f191; + f196 = f170 - f190; + f197 = f170 + f190; + f198 = f168 - f187; + f199 = f168 + f187; + f200 = MUL_F(FRAC_CONST(0.7071067811865476), f151); + f201 = f30 - f200; + f202 = f30 + f200; + f203 = f155 + f147; + f204 = MUL_C(COEF_CONST(1.3065629648763766), f155); + f205 = MUL_F(FRAC_CONST(-0.9238795325112866), f203); + f206 = MUL_F(FRAC_CONST(-0.5411961001461967), f147); + f207 = f204 + f205; + f208 = f206 - f205; + f209 = f202 - f208; + f210 = f202 + f208; + f211 = f201 - f207; + f212 = f201 + f207; + f213 = f157 + f145; + f214 = MUL_C(COEF_CONST(1.1758756024193588), f157); + f215 = MUL_F(FRAC_CONST(-0.9807852804032304), f213); + f216 = MUL_F(FRAC_CONST(-0.7856949583871021), f145); + f217 = f214 + f215; + f218 = f216 - f215; + f219 = f153 + f149; + f220 = MUL_C(COEF_CONST(1.3870398453221473), f153); + f221 = MUL_F(FRAC_CONST(-0.8314696123025455), f219); + f222 = MUL_F(FRAC_CONST(-0.2758993792829436), f149); + f223 = f220 + f221; + f224 = f222 - f221; + f225 = f218 - f224; + f226 = f218 + f224; + f227 = MUL_F(FRAC_CONST(0.7071067811865476), f225); + f228 = f217 - f223; + f229 = f217 + f223; + f230 = MUL_F(FRAC_CONST(0.7071067811865476), f229); + f231 = f227 - f230; + f232 = f227 + f230; + f233 = f210 - f226; + f234 = f210 + f226; + f235 = f212 - f232; + f236 = f212 + f232; + f237 = f211 - f231; + f238 = f211 + f231; + f239 = f209 - f228; + f240 = f209 + f228; + f241 = f234 + f193; + f242 = MUL_F(FRAC_CONST(-0.9497277818777543), f234); + f243 = MUL_F(FRAC_CONST(0.9987954562051724), f241); + f244 = MUL_C(COEF_CONST(1.0478631305325905), f193); + y[1] = f242 + f243; + y[31] = f244 - f243; + f247 = f195 - f236; + f248 = MUL_F(FRAC_CONST(-0.8424460355094192), f236); + f249 = MUL_F(FRAC_CONST(0.9891765099647810), f247); + f250 = MUL_C(COEF_CONST(1.1359069844201428), f195); + y[3] = f249 - f248; + y[29] = f250 - f249; + f253 = f238 + f197; + f254 = MUL_F(FRAC_CONST(-0.7270510732912801), f238); + f255 = MUL_F(FRAC_CONST(0.9700312531945440), f253); + f256 = MUL_C(COEF_CONST(1.2130114330978079), f197); + y[5] = f254 + f255; + y[27] = f256 - f255; + f259 = f199 - f240; + f260 = MUL_F(FRAC_CONST(-0.6046542117908007), f240); + f261 = MUL_F(FRAC_CONST(0.9415440651830208), f259); + f262 = MUL_C(COEF_CONST(1.2784339185752409), f199); + y[7] = f261 - f260; + y[25] = f262 - f261; + f265 = f239 + f198; + f266 = MUL_F(FRAC_CONST(-0.4764341996931611), f239); + f267 = MUL_F(FRAC_CONST(0.9039892931234433), f265); + f268 = MUL_C(COEF_CONST(1.3315443865537255), f198); + y[9] = f266 + f267; + y[23] = f268 - f267; + f271 = f196 - f237; + f272 = MUL_F(FRAC_CONST(-0.3436258658070505), f237); + f273 = MUL_F(FRAC_CONST(0.8577286100002721), f271); + f274 = MUL_C(COEF_CONST(1.3718313541934939), f196); + y[11] = f273 - f272; + y[21] = f274 - f273; + f277 = f235 + f194; + f278 = MUL_F(FRAC_CONST(-0.2075082269882114), f235); + f279 = MUL_F(FRAC_CONST(0.8032075314806448), f277); + f280 = MUL_C(COEF_CONST(1.3989068359730783), f194); + y[13] = f278 + f279; + y[19] = f280 - f279; + f283 = f192 - f233; + f284 = MUL_F(FRAC_CONST(-0.0693921705079408), f233); + f285 = MUL_F(FRAC_CONST(0.7409511253549591), f283); + f286 = MUL_C(COEF_CONST(1.4125100802019774), f192); + y[15] = f285 - f284; + y[17] = f286 - f285; +} + +#else /* #ifdef SBR_LOW_POWER */ + +/* table for pre-processing within dct4_kernel() */ +static const real_t dct4_pre_tab[] ICONST_ATTR MEM_ALIGN_ATTR = { + COEF_CONST(0.999924719333649), COEF_CONST(-1.01219630241394), COEF_CONST(-0.987653195858002), + COEF_CONST(0.998118102550507), COEF_CONST(-1.05943882465363), COEF_CONST(-0.936797380447388), + COEF_CONST(0.993906974792480), COEF_CONST(-1.10412919521332), COEF_CONST(-0.883684754371643), + COEF_CONST(0.987301409244537), COEF_CONST(-1.14615952968597), COEF_CONST(-0.828443288803101), + COEF_CONST(0.978317379951477), COEF_CONST(-1.18542873859405), COEF_CONST(-0.771206021308899), + COEF_CONST(0.966976463794708), COEF_CONST(-1.22184216976166), COEF_CONST(-0.712110757827759), + COEF_CONST(0.953306019306183), COEF_CONST(-1.25531196594238), COEF_CONST(-0.651300072669983), + COEF_CONST(0.937339007854462), COEF_CONST(-1.28575766086578), COEF_CONST(-0.588920354843140), + COEF_CONST(0.919113874435425), COEF_CONST(-1.31310594081879), COEF_CONST(-0.525121808052063), + COEF_CONST(0.898674488067627), COEF_CONST(-1.33729076385498), COEF_CONST(-0.460058242082596), + COEF_CONST(0.876070082187653), COEF_CONST(-1.35825383663177), COEF_CONST(-0.393886327743530), + COEF_CONST(0.851355195045471), COEF_CONST(-1.37594485282898), COEF_CONST(-0.326765477657318), + COEF_CONST(0.824589252471924), COEF_CONST(-1.39032101631165), COEF_CONST(-0.258857429027557), + COEF_CONST(0.795836925506592), COEF_CONST(-1.40134787559509), COEF_CONST(-0.190325915813446), + COEF_CONST(0.765167236328125), COEF_CONST(-1.40899872779846), COEF_CONST(-0.121335685253143), + COEF_CONST(0.732654273509979), COEF_CONST(-1.41325521469116), COEF_CONST(-0.052053272724152), + COEF_CONST(0.698376238346100), COEF_CONST(-1.41410708427429), COEF_CONST( 0.017354607582092), + COEF_CONST(0.662415742874146), COEF_CONST(-1.41155219078064), COEF_CONST( 0.086720645427704), + COEF_CONST(0.624859452247620), COEF_CONST(-1.40559673309326), COEF_CONST( 0.155877828598022), + COEF_CONST(0.585797846317291), COEF_CONST(-1.39625501632690), COEF_CONST( 0.224659323692322), + COEF_CONST(0.545324981212616), COEF_CONST(-1.38354969024658), COEF_CONST( 0.292899727821350), + COEF_CONST(0.503538429737091), COEF_CONST(-1.36751127243042), COEF_CONST( 0.360434412956238), + COEF_CONST(0.460538715124130), COEF_CONST(-1.34817838668823), COEF_CONST( 0.427100926637650), + COEF_CONST(0.416429549455643), COEF_CONST(-1.32559752464294), COEF_CONST( 0.492738455533981), + COEF_CONST(0.371317148208618), COEF_CONST(-1.29982328414917), COEF_CONST( 0.557188928127289), + COEF_CONST(0.325310230255127), COEF_CONST(-1.27091765403748), COEF_CONST( 0.620297133922577), + COEF_CONST(0.278519600629807), COEF_CONST(-1.23895013332367), COEF_CONST( 0.681910991668701), + COEF_CONST(0.231058135628700), COEF_CONST(-1.20399808883667), COEF_CONST( 0.741881847381592), + COEF_CONST(0.183039888739586), COEF_CONST(-1.16614532470703), COEF_CONST( 0.800065577030182), + COEF_CONST(0.134580686688423), COEF_CONST(-1.12548339366913), COEF_CONST( 0.856321990489960), + COEF_CONST(0.085797272622585), COEF_CONST(-1.08210992813110), COEF_CONST( 0.910515367984772), + COEF_CONST(0.036807164549828), COEF_CONST(-1.03612959384918), COEF_CONST( 0.962515234947205) +}; + +/* table for post-processing within dct4_kernel() */ +static const real_t dct4_post_tab[] ICONST_ATTR MEM_ALIGN_ATTR = { + COEF_CONST(1 ), COEF_CONST(-1 ), COEF_CONST(-1 ), + COEF_CONST(0.998795449733734), COEF_CONST(-1.04786312580109), COEF_CONST(-0.949727773666382), + COEF_CONST(0.995184719562531), COEF_CONST(-1.09320187568665), COEF_CONST(-0.897167563438416), + COEF_CONST(0.989176511764526), COEF_CONST(-1.13590693473816), COEF_CONST(-0.842446029186249), + COEF_CONST(0.980785250663757), COEF_CONST(-1.17587554454803), COEF_CONST(-0.785694956779480), + COEF_CONST(0.970031261444092), COEF_CONST(-1.21301150321960), COEF_CONST(-0.727051079273224), + COEF_CONST(0.956940352916718), COEF_CONST(-1.24722504615784), COEF_CONST(-0.666655659675598), + COEF_CONST(0.941544055938721), COEF_CONST(-1.27843391895294), COEF_CONST(-0.604654192924500), + COEF_CONST(0.923879504203796), COEF_CONST(-1.30656290054321), COEF_CONST(-0.541196048259735), + COEF_CONST(0.903989315032959), COEF_CONST(-1.33154439926148), COEF_CONST(-0.476434230804443), + COEF_CONST(0.881921231746674), COEF_CONST(-1.35331797599793), COEF_CONST(-0.410524487495422), + COEF_CONST(0.857728600502014), COEF_CONST(-1.37183141708374), COEF_CONST(-0.343625843524933), + COEF_CONST(0.831469595432281), COEF_CONST(-1.38703989982605), COEF_CONST(-0.275899350643158), + COEF_CONST(0.803207516670227), COEF_CONST(-1.39890682697296), COEF_CONST(-0.207508206367493), + COEF_CONST(0.773010432720184), COEF_CONST(-1.40740370750427), COEF_CONST(-0.138617098331451), + COEF_CONST(0.740951120853424), COEF_CONST(-1.41251015663147), COEF_CONST(-0.069392144680023), + COEF_CONST(0.707106769084930), COEF_CONST( 0 ), COEF_CONST( 0 ), + COEF_CONST(0.671558916568756), COEF_CONST(-1.41251015663147), COEF_CONST( 0.069392263889313), + COEF_CONST(0.634393274784088), COEF_CONST(-1.40740370750427), COEF_CONST( 0.138617157936096), + COEF_CONST(0.595699310302734), COEF_CONST(-1.39890682697296), COEF_CONST( 0.207508206367493), + COEF_CONST(0.555570185184479), COEF_CONST(-1.38703989982605), COEF_CONST( 0.275899469852448), + COEF_CONST(0.514102697372437), COEF_CONST(-1.37183141708374), COEF_CONST( 0.343625962734222), + COEF_CONST(0.471396654844284), COEF_CONST(-1.35331797599793), COEF_CONST( 0.410524636507034), + COEF_CONST(0.427555114030838), COEF_CONST(-1.33154439926148), COEF_CONST( 0.476434201002121), + COEF_CONST(0.382683426141739), COEF_CONST(-1.30656290054321), COEF_CONST( 0.541196107864380), + COEF_CONST(0.336889833211899), COEF_CONST(-1.27843391895294), COEF_CONST( 0.604654192924500), + COEF_CONST(0.290284633636475), COEF_CONST(-1.24722504615784), COEF_CONST( 0.666655719280243), + COEF_CONST(0.242980122566223), COEF_CONST(-1.21301138401031), COEF_CONST( 0.727051138877869), + COEF_CONST(0.195090234279633), COEF_CONST(-1.17587554454803), COEF_CONST( 0.785695075988770), + COEF_CONST(0.146730497479439), COEF_CONST(-1.13590705394745), COEF_CONST( 0.842446029186249), + COEF_CONST(0.098017133772373), COEF_CONST(-1.09320187568665), COEF_CONST( 0.897167563438416), + COEF_CONST(0.049067649990320), COEF_CONST(-1.04786312580109), COEF_CONST( 0.949727773666382) +}; + +// Table adapted from codeclib to fit into IRAM +static const uint32_t dct4_revtab[32] ICONST_ATTR MEM_ALIGN_ATTR = { + 0, 24, 12, 22, 6, 30, 11, 19, 3, 27, 15, 21, 5, 29, 9, 17, + 1, 25, 13, 23, 7, 31, 10, 18, 2, 26, 14, 20, 4, 28, 8, 16}; + +// Bufferfly used in dct4_kernel()'s pre- and post-processing +#define BUTTERFLY_DCT4(out1, out2, real_part, imag_part, tab, tabidx) \ + x_re = real_part; \ + x_im = imag_part; \ + tmp = MUL_C(x_re + x_im, tab[tabidx++]); \ + out1 = MUL_C(x_re , tab[tabidx++]) + tmp; \ + out2 = MUL_C(x_im , tab[tabidx++]) + tmp; + +/* size 64 only! */ +void dct4_kernel(real_t *real, real_t *imag) +{ + uint32_t i, idx, tabidx; + real_t x_re, x_im, tmp; + FFTComplex xc[32]; /* used for calling codeclib's fft implementation */ + + /* Step 2: modulate and pre-rotate for codeclib's fft implementation */ + // 3*32=96 multiplications + // 3*32=96 additions + for (i = 0, tabidx = 0; i < 32; i++) + { + idx = dct4_revtab[i]; + BUTTERFLY_DCT4(xc[idx].im, xc[idx].re, real[i], imag[i], dct4_pre_tab, tabidx); + } + + /* Step 3: FFT (codeclib's implementation) */ + ff_fft_calc_c(5, xc); + + /* Step 4: modulate + reordering */ + // 3*30+2=92 multiplications + // 3*30+2=92 additions + imag[0] = xc[0].im; + real[0] = xc[0].re; + for (i = 1, tabidx = 3*1; i < 16; i++) + { + idx = 32-i; + BUTTERFLY_DCT4(imag[i], real[i], xc[idx].re, xc[idx].im, dct4_post_tab, tabidx); + } + // i = 16, idx = 16 = reorder_tab[16]; + x_re = xc[16].re; + x_im = xc[16].im; + imag[16] = MUL_C(x_im - x_re, COEF_CONST(0.707106769084930)); + real[16] = MUL_C(x_re + x_im, COEF_CONST(0.707106769084930)); + for (i = 17, tabidx = 3*17; i < 32; i++) + { + idx = 32-i; + BUTTERFLY_DCT4(imag[i], real[i], xc[idx].re, xc[idx].im, dct4_post_tab, tabidx); + } +} + +void DST4_32(real_t *y, real_t *x) +{ + real_t f0, f1, f2, f3, f4, f5, f6, f7, f8, f9; + real_t f10, f11, f12, f13, f14, f15, f16, f17, f18, f19; + real_t f20, f21, f22, f23, f24, f25, f26, f27, f28, f29; + real_t f30, f31, f32, f33, f34, f35, f36, f37, f38, f39; + real_t f40, f41, f42, f43, f44, f45, f46, f47, f48, f49; + real_t f50, f51, f52, f53, f54, f55, f56, f57, f58, f59; + real_t f60, f61, f62, f63, f64, f65, f66, f67, f68, f69; + real_t f70, f71, f72, f73, f74, f75, f76, f77, f78, f79; + real_t f80, f81, f82, f83, f84, f85, f86, f87, f88, f89; + real_t f90, f91, f92, f93, f94, f95, f96, f97, f98, f99; + real_t f100, f101, f102, f103, f104, f105, f106, f107, f108, f109; + real_t f110, f111, f112, f113, f114, f115, f116, f117, f118, f119; + real_t f120, f121, f122, f123, f124, f125, f126, f127, f128, f129; + real_t f130, f131, f132, f133, f134, f135, f136, f137, f138, f139; + real_t f140, f141, f142, f143, f144, f145, f146, f147, f148, f149; + real_t f150, f151, f152, f153, f154, f155, f156, f157, f158, f159; + real_t f160, f161, f162, f163, f164, f165, f166, f167, f168, f169; + real_t f170, f171, f172, f173, f174, f175, f176, f177, f178, f179; + real_t f180, f181, f182, f183, f184, f185, f186, f187, f188, f189; + real_t f190, f191, f192, f193, f194, f195, f196, f197, f198, f199; + real_t f200, f201, f202, f203, f204, f205, f206, f207, f208, f209; + real_t f210, f211, f212, f213, f214, f215, f216, f217, f218, f219; + real_t f220, f221, f222, f223, f224, f225, f226, f227, f228, f229; + real_t f230, f231, f232, f233, f234, f235, f236, f237, f238, f239; + real_t f240, f241, f242, f243, f244, f245, f246, f247, f248, f249; + real_t f250, f251, f252, f253, f254, f255, f256, f257, f258, f259; + real_t f260, f261, f262, f263, f264, f265, f266, f267, f268, f269; + real_t f270, f271, f272, f273, f274, f275, f276, f277, f278, f279; + real_t f280, f281, f282, f283, f284, f285, f286, f287, f288, f289; + real_t f290, f291, f292, f293, f294, f295, f296, f297, f298, f299; + real_t f300, f301, f302, f303, f304, f305, f306, f307, f308, f309; + real_t f310, f311, f312, f313, f314, f315, f316, f317, f318, f319; + real_t f320, f321, f322, f323, f324, f325, f326, f327, f328, f329; + real_t f330, f331, f332, f333, f334, f335; + + f0 = x[0] - x[1]; + f1 = x[2] - x[1]; + f2 = x[2] - x[3]; + f3 = x[4] - x[3]; + f4 = x[4] - x[5]; + f5 = x[6] - x[5]; + f6 = x[6] - x[7]; + f7 = x[8] - x[7]; + f8 = x[8] - x[9]; + f9 = x[10] - x[9]; + f10 = x[10] - x[11]; + f11 = x[12] - x[11]; + f12 = x[12] - x[13]; + f13 = x[14] - x[13]; + f14 = x[14] - x[15]; + f15 = x[16] - x[15]; + f16 = x[16] - x[17]; + f17 = x[18] - x[17]; + f18 = x[18] - x[19]; + f19 = x[20] - x[19]; + f20 = x[20] - x[21]; + f21 = x[22] - x[21]; + f22 = x[22] - x[23]; + f23 = x[24] - x[23]; + f24 = x[24] - x[25]; + f25 = x[26] - x[25]; + f26 = x[26] - x[27]; + f27 = x[28] - x[27]; + f28 = x[28] - x[29]; + f29 = x[30] - x[29]; + f30 = x[30] - x[31]; + f31 = MUL_F(FRAC_CONST(0.7071067811865476), f15); + f32 = x[0] - f31; + f33 = x[0] + f31; + f34 = f7 + f23; + f35 = MUL_C(COEF_CONST(1.3065629648763766), f7); + f36 = MUL_F(FRAC_CONST(-0.9238795325112866), f34); + f37 = MUL_F(FRAC_CONST(-0.5411961001461967), f23); + f38 = f35 + f36; + f39 = f37 - f36; + f40 = f33 - f39; + f41 = f33 + f39; + f42 = f32 - f38; + f43 = f32 + f38; + f44 = f11 - f19; + f45 = f11 + f19; + f46 = MUL_F(FRAC_CONST(0.7071067811865476), f45); + f47 = f3 - f46; + f48 = f3 + f46; + f49 = MUL_F(FRAC_CONST(0.7071067811865476), f44); + f50 = f49 - f27; + f51 = f49 + f27; + f52 = f51 + f48; + f53 = MUL_F(FRAC_CONST(-0.7856949583871021), f51); + f54 = MUL_F(FRAC_CONST(0.9807852804032304), f52); + f55 = MUL_C(COEF_CONST(1.1758756024193588), f48); + f56 = f53 + f54; + f57 = f55 - f54; + f58 = f50 + f47; + f59 = MUL_F(FRAC_CONST(-0.2758993792829430), f50); + f60 = MUL_F(FRAC_CONST(0.8314696123025452), f58); + f61 = MUL_C(COEF_CONST(1.3870398453221475), f47); + f62 = f59 + f60; + f63 = f61 - f60; + f64 = f41 - f56; + f65 = f41 + f56; + f66 = f43 - f62; + f67 = f43 + f62; + f68 = f42 - f63; + f69 = f42 + f63; + f70 = f40 - f57; + f71 = f40 + f57; + f72 = f5 - f9; + f73 = f5 + f9; + f74 = f13 - f17; + f75 = f13 + f17; + f76 = f21 - f25; + f77 = f21 + f25; + f78 = MUL_F(FRAC_CONST(0.7071067811865476), f75); + f79 = f1 - f78; + f80 = f1 + f78; + f81 = f73 + f77; + f82 = MUL_C(COEF_CONST(1.3065629648763766), f73); + f83 = MUL_F(FRAC_CONST(-0.9238795325112866), f81); + f84 = MUL_F(FRAC_CONST(-0.5411961001461967), f77); + f85 = f82 + f83; + f86 = f84 - f83; + f87 = f80 - f86; + f88 = f80 + f86; + f89 = f79 - f85; + f90 = f79 + f85; + f91 = MUL_F(FRAC_CONST(0.7071067811865476), f74); + f92 = f29 - f91; + f93 = f29 + f91; + f94 = f76 + f72; + f95 = MUL_C(COEF_CONST(1.3065629648763766), f76); + f96 = MUL_F(FRAC_CONST(-0.9238795325112866), f94); + f97 = MUL_F(FRAC_CONST(-0.5411961001461967), f72); + f98 = f95 + f96; + f99 = f97 - f96; + f100 = f93 - f99; + f101 = f93 + f99; + f102 = f92 - f98; + f103 = f92 + f98; + f104 = f101 + f88; + f105 = MUL_F(FRAC_CONST(-0.8971675863426361), f101); + f106 = MUL_F(FRAC_CONST(0.9951847266721968), f104); + f107 = MUL_C(COEF_CONST(1.0932018670017576), f88); + f108 = f105 + f106; + f109 = f107 - f106; + f110 = f90 - f103; + f111 = MUL_F(FRAC_CONST(-0.6666556584777466), f103); + f112 = MUL_F(FRAC_CONST(0.9569403357322089), f110); + f113 = MUL_C(COEF_CONST(1.2472250129866713), f90); + f114 = f112 - f111; + f115 = f113 - f112; + f116 = f102 + f89; + f117 = MUL_F(FRAC_CONST(-0.4105245275223571), f102); + f118 = MUL_F(FRAC_CONST(0.8819212643483549), f116); + f119 = MUL_C(COEF_CONST(1.3533180011743529), f89); + f120 = f117 + f118; + f121 = f119 - f118; + f122 = f87 - f100; + f123 = MUL_F(FRAC_CONST(-0.1386171691990915), f100); + f124 = MUL_F(FRAC_CONST(0.7730104533627370), f122); + f125 = MUL_C(COEF_CONST(1.4074037375263826), f87); + f126 = f124 - f123; + f127 = f125 - f124; + f128 = f65 - f108; + f129 = f65 + f108; + f130 = f67 - f114; + f131 = f67 + f114; + f132 = f69 - f120; + f133 = f69 + f120; + f134 = f71 - f126; + f135 = f71 + f126; + f136 = f70 - f127; + f137 = f70 + f127; + f138 = f68 - f121; + f139 = f68 + f121; + f140 = f66 - f115; + f141 = f66 + f115; + f142 = f64 - f109; + f143 = f64 + f109; + f144 = f0 + f30; + f145 = MUL_C(COEF_CONST(1.0478631305325901), f0); + f146 = MUL_F(FRAC_CONST(-0.9987954562051724), f144); + f147 = MUL_F(FRAC_CONST(-0.9497277818777548), f30); + f148 = f145 + f146; + f149 = f147 - f146; + f150 = f4 + f26; + f151 = MUL_F(FRAC_CONST(1.2130114330978077), f4); + f152 = MUL_F(FRAC_CONST(-0.9700312531945440), f150); + f153 = MUL_F(FRAC_CONST(-0.7270510732912803), f26); + f154 = f151 + f152; + f155 = f153 - f152; + f156 = f8 + f22; + f157 = MUL_C(COEF_CONST(1.3315443865537255), f8); + f158 = MUL_F(FRAC_CONST(-0.9039892931234433), f156); + f159 = MUL_F(FRAC_CONST(-0.4764341996931612), f22); + f160 = f157 + f158; + f161 = f159 - f158; + f162 = f12 + f18; + f163 = MUL_C(COEF_CONST(1.3989068359730781), f12); + f164 = MUL_F(FRAC_CONST(-0.8032075314806453), f162); + f165 = MUL_F(FRAC_CONST(-0.2075082269882124), f18); + f166 = f163 + f164; + f167 = f165 - f164; + f168 = f16 + f14; + f169 = MUL_C(COEF_CONST(1.4125100802019777), f16); + f170 = MUL_F(FRAC_CONST(-0.6715589548470187), f168); + f171 = MUL_F(FRAC_CONST(0.0693921705079402), f14); + f172 = f169 + f170; + f173 = f171 - f170; + f174 = f20 + f10; + f175 = MUL_C(COEF_CONST(1.3718313541934939), f20); + f176 = MUL_F(FRAC_CONST(-0.5141027441932219), f174); + f177 = MUL_F(FRAC_CONST(0.3436258658070501), f10); + f178 = f175 + f176; + f179 = f177 - f176; + f180 = f24 + f6; + f181 = MUL_C(COEF_CONST(1.2784339185752409), f24); + f182 = MUL_F(FRAC_CONST(-0.3368898533922200), f180); + f183 = MUL_F(FRAC_CONST(0.6046542117908008), f6); + f184 = f181 + f182; + f185 = f183 - f182; + f186 = f28 + f2; + f187 = MUL_C(COEF_CONST(1.1359069844201433), f28); + f188 = MUL_F(FRAC_CONST(-0.1467304744553624), f186); + f189 = MUL_F(FRAC_CONST(0.8424460355094185), f2); + f190 = f187 + f188; + f191 = f189 - f188; + f192 = f149 - f173; + f193 = f149 + f173; + f194 = f148 - f172; + f195 = f148 + f172; + f196 = f155 - f179; + f197 = f155 + f179; + f198 = f154 - f178; + f199 = f154 + f178; + f200 = f161 - f185; + f201 = f161 + f185; + f202 = f160 - f184; + f203 = f160 + f184; + f204 = f167 - f191; + f205 = f167 + f191; + f206 = f166 - f190; + f207 = f166 + f190; + f208 = f192 + f194; + f209 = MUL_C(COEF_CONST(1.1758756024193588), f192); + f210 = MUL_F(FRAC_CONST(-0.9807852804032304), f208); + f211 = MUL_F(FRAC_CONST(-0.7856949583871021), f194); + f212 = f209 + f210; + f213 = f211 - f210; + f214 = f196 + f198; + f215 = MUL_C(COEF_CONST(1.3870398453221475), f196); + f216 = MUL_F(FRAC_CONST(-0.5555702330196022), f214); + f217 = MUL_F(FRAC_CONST(0.2758993792829431), f198); + f218 = f215 + f216; + f219 = f217 - f216; + f220 = f200 + f202; + f221 = MUL_F(FRAC_CONST(0.7856949583871022), f200); + f222 = MUL_F(FRAC_CONST(0.1950903220161283), f220); + f223 = MUL_C(COEF_CONST(1.1758756024193586), f202); + f224 = f221 + f222; + f225 = f223 - f222; + f226 = f204 + f206; + f227 = MUL_F(FRAC_CONST(-0.2758993792829430), f204); + f228 = MUL_F(FRAC_CONST(0.8314696123025452), f226); + f229 = MUL_C(COEF_CONST(1.3870398453221475), f206); + f230 = f227 + f228; + f231 = f229 - f228; + f232 = f193 - f201; + f233 = f193 + f201; + f234 = f195 - f203; + f235 = f195 + f203; + f236 = f197 - f205; + f237 = f197 + f205; + f238 = f199 - f207; + f239 = f199 + f207; + f240 = f213 - f225; + f241 = f213 + f225; + f242 = f212 - f224; + f243 = f212 + f224; + f244 = f219 - f231; + f245 = f219 + f231; + f246 = f218 - f230; + f247 = f218 + f230; + f248 = f232 + f234; + f249 = MUL_C(COEF_CONST(1.3065629648763766), f232); + f250 = MUL_F(FRAC_CONST(-0.9238795325112866), f248); + f251 = MUL_F(FRAC_CONST(-0.5411961001461967), f234); + f252 = f249 + f250; + f253 = f251 - f250; + f254 = f236 + f238; + f255 = MUL_F(FRAC_CONST(0.5411961001461969), f236); + f256 = MUL_F(FRAC_CONST(0.3826834323650898), f254); + f257 = MUL_C(COEF_CONST(1.3065629648763766), f238); + f258 = f255 + f256; + f259 = f257 - f256; + f260 = f240 + f242; + f261 = MUL_C(COEF_CONST(1.3065629648763766), f240); + f262 = MUL_F(FRAC_CONST(-0.9238795325112866), f260); + f263 = MUL_F(FRAC_CONST(-0.5411961001461967), f242); + f264 = f261 + f262; + f265 = f263 - f262; + f266 = f244 + f246; + f267 = MUL_F(FRAC_CONST(0.5411961001461969), f244); + f268 = MUL_F(FRAC_CONST(0.3826834323650898), f266); + f269 = MUL_C(COEF_CONST(1.3065629648763766), f246); + f270 = f267 + f268; + f271 = f269 - f268; + f272 = f233 - f237; + f273 = f233 + f237; + f274 = f235 - f239; + f275 = f235 + f239; + f276 = f253 - f259; + f277 = f253 + f259; + f278 = f252 - f258; + f279 = f252 + f258; + f280 = f241 - f245; + f281 = f241 + f245; + f282 = f243 - f247; + f283 = f243 + f247; + f284 = f265 - f271; + f285 = f265 + f271; + f286 = f264 - f270; + f287 = f264 + f270; + f288 = f272 - f274; + f289 = f272 + f274; + f290 = MUL_F(FRAC_CONST(0.7071067811865474), f288); + f291 = MUL_F(FRAC_CONST(0.7071067811865474), f289); + f292 = f276 - f278; + f293 = f276 + f278; + f294 = MUL_F(FRAC_CONST(0.7071067811865474), f292); + f295 = MUL_F(FRAC_CONST(0.7071067811865474), f293); + f296 = f280 - f282; + f297 = f280 + f282; + f298 = MUL_F(FRAC_CONST(0.7071067811865474), f296); + f299 = MUL_F(FRAC_CONST(0.7071067811865474), f297); + f300 = f284 - f286; + f301 = f284 + f286; + f302 = MUL_F(FRAC_CONST(0.7071067811865474), f300); + f303 = MUL_F(FRAC_CONST(0.7071067811865474), f301); + f304 = f129 - f273; + f305 = f129 + f273; + f306 = f131 - f281; + f307 = f131 + f281; + f308 = f133 - f285; + f309 = f133 + f285; + f310 = f135 - f277; + f311 = f135 + f277; + f312 = f137 - f295; + f313 = f137 + f295; + f314 = f139 - f303; + f315 = f139 + f303; + f316 = f141 - f299; + f317 = f141 + f299; + f318 = f143 - f291; + f319 = f143 + f291; + f320 = f142 - f290; + f321 = f142 + f290; + f322 = f140 - f298; + f323 = f140 + f298; + f324 = f138 - f302; + f325 = f138 + f302; + f326 = f136 - f294; + f327 = f136 + f294; + f328 = f134 - f279; + f329 = f134 + f279; + f330 = f132 - f287; + f331 = f132 + f287; + f332 = f130 - f283; + f333 = f130 + f283; + f334 = f128 - f275; + f335 = f128 + f275; + y[31] = MUL_F(FRAC_CONST(0.5001506360206510), f305); + y[30] = MUL_F(FRAC_CONST(0.5013584524464084), f307); + y[29] = MUL_F(FRAC_CONST(0.5037887256810443), f309); + y[28] = MUL_F(FRAC_CONST(0.5074711720725553), f311); + y[27] = MUL_F(FRAC_CONST(0.5124514794082247), f313); + y[26] = MUL_F(FRAC_CONST(0.5187927131053328), f315); + y[25] = MUL_F(FRAC_CONST(0.5265773151542700), f317); + y[24] = MUL_F(FRAC_CONST(0.5359098169079920), f319); + y[23] = MUL_F(FRAC_CONST(0.5469204379855088), f321); + y[22] = MUL_F(FRAC_CONST(0.5597698129470802), f323); + y[21] = MUL_F(FRAC_CONST(0.5746551840326600), f325); + y[20] = MUL_F(FRAC_CONST(0.5918185358574165), f327); + y[19] = MUL_F(FRAC_CONST(0.6115573478825099), f329); + y[18] = MUL_F(FRAC_CONST(0.6342389366884031), f331); + y[17] = MUL_F(FRAC_CONST(0.6603198078137061), f333); + y[16] = MUL_F(FRAC_CONST(0.6903721282002123), f335); + y[15] = MUL_F(FRAC_CONST(0.7251205223771985), f334); + y[14] = MUL_F(FRAC_CONST(0.7654941649730891), f332); + y[13] = MUL_F(FRAC_CONST(0.8127020908144905), f330); + y[12] = MUL_F(FRAC_CONST(0.8683447152233481), f328); + y[11] = MUL_F(FRAC_CONST(0.9345835970364075), f326); + y[10] = MUL_C(COEF_CONST(1.0144082649970547), f324); + y[9] = MUL_C(COEF_CONST(1.1120716205797176), f322); + y[8] = MUL_C(COEF_CONST(1.2338327379765710), f320); + y[7] = MUL_C(COEF_CONST(1.3892939586328277), f318); + y[6] = MUL_C(COEF_CONST(1.5939722833856311), f316); + y[5] = MUL_C(COEF_CONST(1.8746759800084078), f314); + y[4] = MUL_C(COEF_CONST(2.2820500680051619), f312); + y[3] = MUL_C(COEF_CONST(2.9246284281582162), f310); + y[2] = MUL_C(COEF_CONST(4.0846110781292477), f308); + y[1] = MUL_C(COEF_CONST(6.7967507116736332), f306); + y[0] = MUL_R(REAL_CONST(20.3738781672314530), f304); +} + +#endif /* #ifdef SBR_LOW_POWER */ + +#endif /* #ifdef SBR_DEC */ diff --git a/lib/rbcodec/codecs/libfaad/sbr_dct.h b/lib/rbcodec/codecs/libfaad/sbr_dct.h new file mode 100644 index 0000000000..95394df307 --- /dev/null +++ b/lib/rbcodec/codecs/libfaad/sbr_dct.h @@ -0,0 +1,49 @@ +/* +** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding +** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +** +** Any non-GPL usage of this software or parts of this software is strictly +** forbidden. +** +** Commercial non-GPL licensing of this software is possible. +** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** +** $Id$ +**/ + +#ifndef __SBR_DCT_H__ +#define __SBR_DCT_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +void dct4_kernel(real_t *real, real_t *imag); + +void DCT3_32_unscaled(real_t *y, real_t *x); +void DCT4_32(real_t *y, real_t *x); +void DST4_32(real_t *y, real_t *x); +void DCT2_32_unscaled(real_t *y, real_t *x); +void DCT4_16(real_t *y, real_t *x); +void DCT2_16_unscaled(real_t *y, real_t *x); + + +#ifdef __cplusplus +} +#endif +#endif + diff --git a/lib/rbcodec/codecs/libfaad/sbr_dec.c b/lib/rbcodec/codecs/libfaad/sbr_dec.c new file mode 100644 index 0000000000..21e8e028a1 --- /dev/null +++ b/lib/rbcodec/codecs/libfaad/sbr_dec.c @@ -0,0 +1,597 @@ +/* +** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding +** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +** +** Any non-GPL usage of this software or parts of this software is strictly +** forbidden. +** +** Commercial non-GPL licensing of this software is possible. +** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** +** $Id$ +**/ + + +#include "common.h" +#include "structs.h" + +#ifdef SBR_DEC + +#include +#include + +#include "syntax.h" +#include "bits.h" +#include "sbr_syntax.h" +#include "sbr_qmf.h" +#include "sbr_hfgen.h" +#include "sbr_hfadj.h" + +/* type definitons */ +typedef struct { +#if (defined(PS_DEC) || defined(DRM_PS)) + /* In case of PS_DEC or DRM_PS we need larger buffer data when calling + * ps_decode() or drm_ps_decode(). */ + qmf_t X_L[MAX_NTSRPS][64]; + qmf_t X_R[MAX_NTSRPS][64]; +#else + /* No PS functions called. Keep using MAX_NTSR as array size. */ + qmf_t X_L[MAX_NTSR][64]; + qmf_t X_R[MAX_NTSR][64]; +#endif +} XLR_t; + +/* static variables */ +static XLR_t *p_XLR = NULL; +#if defined(FAAD_STATIC_ALLOC) || defined(HAVE_FAAD_XLR_IN_IRAM) +static XLR_t s_XLR IBSS_ATTR_FAAD_XLR MEM_ALIGN_ATTR; +#endif +#if defined(FAAD_STATIC_ALLOC) +static sbr_info s_sbr[MAX_SYNTAX_ELEMENTS]; +#endif +#ifdef SBR_LOW_POWER +static real_t deg[64] MEM_ALIGN_ATTR; +#endif + +/* static function declarations */ +static uint8_t sbr_save_prev_data(sbr_info *sbr, uint8_t ch); +static void sbr_save_matrix(sbr_info *sbr, uint8_t ch); + + +sbr_info *sbrDecodeInit(uint16_t framelength, uint8_t id_aac, uint8_t id_ele, + uint32_t sample_rate, uint8_t downSampledSBR, + uint8_t IsDRM) +{ + (void)downSampledSBR; +#ifndef DRM + (void)IsDRM; +#endif + + /* Allocate sbr_info. */ +#if defined(FAAD_STATIC_ALLOC) + sbr_info *sbr = &s_sbr[id_ele]; +#else + (void)id_ele; + sbr_info *sbr = (sbr_info*)faad_malloc(sizeof(sbr_info)); + if (sbr == NULL) + { + /* could not allocate memory */ + return NULL; + } +#endif + memset(sbr, 0, sizeof(sbr_info)); + +#ifdef PS_DEC + /* initialize PS variables */ + ps_init(&sbr->ps); +#endif + + /* Allocate XLR temporary variable. Use static allocation if either + * FAAD_STATIC_ALLOC is set or XLR fits to IRAM. */ +#if defined(FAAD_STATIC_ALLOC) || defined(HAVE_FAAD_XLR_IN_IRAM) + p_XLR = &s_XLR; +#else + p_XLR = (XLR_t*)faad_malloc(sizeof(XLR_t)); + if (p_XLR == NULL) + { + /* could not allocate memory */ + return NULL; + } +#endif + memset(p_XLR, 0, sizeof(XLR_t)); + + /* save id of the parent element */ + sbr->id_aac = id_aac; + sbr->sample_rate = sample_rate; + + sbr->bs_freq_scale = 2; + sbr->bs_alter_scale = 1; + sbr->bs_noise_bands = 2; + sbr->bs_limiter_bands = 2; + sbr->bs_limiter_gains = 2; + sbr->bs_interpol_freq = 1; + sbr->bs_smoothing_mode = 1; + sbr->bs_start_freq = 5; + sbr->bs_amp_res = 1; + sbr->bs_samplerate_mode = 1; + sbr->prevEnvIsShort[0] = -1; + sbr->prevEnvIsShort[1] = -1; + sbr->header_count = 0; + sbr->Reset = 1; + +#ifdef DRM + sbr->Is_DRM_SBR = IsDRM; +#endif + sbr->tHFGen = T_HFGEN; + sbr->tHFAdj = T_HFADJ; + + sbr->bsco = 0; + sbr->bsco_prev = 0; + sbr->M_prev = 0; + sbr->frame_len = framelength; + + /* force sbr reset */ + sbr->bs_start_freq_prev = -1; + + if (framelength == 960) + { + sbr->numTimeSlotsRate = RATE * NO_TIME_SLOTS_960; + sbr->numTimeSlots = NO_TIME_SLOTS_960; + } else { + sbr->numTimeSlotsRate = RATE * NO_TIME_SLOTS; + sbr->numTimeSlots = NO_TIME_SLOTS; + } + + sbr->GQ_ringbuf_index[0] = 0; + sbr->GQ_ringbuf_index[1] = 0; + + memset(sbr->qmfa, 0, 2*sizeof(qmfa_info)); + memset(sbr->qmfs, 0, 2*sizeof(qmfs_info)); + + memset(sbr->Xsbr[0], 0, (sbr->numTimeSlotsRate+sbr->tHFGen)*64 * sizeof(qmf_t)); + memset(sbr->Xsbr[1], 0, (sbr->numTimeSlotsRate+sbr->tHFGen)*64 * sizeof(qmf_t)); + + return sbr; +} + +static uint8_t sbr_save_prev_data(sbr_info *sbr, uint8_t ch) +{ + uint8_t i; + + /* save data for next frame */ + sbr->kx_prev = sbr->kx; + sbr->M_prev = sbr->M; + sbr->bsco_prev = sbr->bsco; + + sbr->L_E_prev[ch] = sbr->L_E[ch]; + + /* sbr->L_E[ch] can become 0 on files with bit errors */ + if (sbr->L_E[ch] <= 0) + return 19; + + sbr->f_prev[ch] = sbr->f[ch][sbr->L_E[ch] - 1]; + for (i = 0; i < MAX_M; i++) + { + sbr->E_prev[ch][i] = sbr->E[ch][i][sbr->L_E[ch] - 1]; + sbr->Q_prev[ch][i] = sbr->Q[ch][i][sbr->L_Q[ch] - 1]; + } + + for (i = 0; i < MAX_M; i++) + { + sbr->bs_add_harmonic_prev[ch][i] = sbr->bs_add_harmonic[ch][i]; + } + sbr->bs_add_harmonic_flag_prev[ch] = sbr->bs_add_harmonic_flag[ch]; + + if (sbr->l_A[ch] == sbr->L_E[ch]) + sbr->prevEnvIsShort[ch] = 0; + else + sbr->prevEnvIsShort[ch] = -1; + + return 0; +} + +static void sbr_save_matrix(sbr_info *sbr, uint8_t ch) +{ + uint8_t i; + + for (i = 0; i < sbr->tHFGen; i++) + { + memmove(sbr->Xsbr[ch][i], sbr->Xsbr[ch][i+sbr->numTimeSlotsRate], 64 * sizeof(qmf_t)); + } + for (i = sbr->tHFGen; i < MAX_NTSRHFG; i++) + { + memset(sbr->Xsbr[ch][i], 0, 64 * sizeof(qmf_t)); + } +} + +static void sbr_process_channel(sbr_info *sbr, real_t *channel_buf, qmf_t X[MAX_NTSR][64], + uint8_t ch, uint8_t dont_process, + const uint8_t downSampledSBR) +{ + int16_t k, l; + + (void)downSampledSBR; +#ifdef DRM + if (sbr->Is_DRM_SBR) + { + sbr->bsco = max((int32_t)sbr->maxAACLine*32/(int32_t)sbr->frame_len - (int32_t)sbr->kx, 0); + } else { +#endif + sbr->bsco = 0; +#ifdef DRM + } +#endif + + +//#define PRE_QMF_PRINT +#ifdef PRE_QMF_PRINT + { + int i; + for (i = 0; i < 1024; i++) + { + printf("%d\n", channel_buf[i]); + } + } +#endif + + + /* subband analysis */ + if (dont_process) + sbr_qmf_analysis_32(sbr, &sbr->qmfa[ch], channel_buf, sbr->Xsbr[ch], sbr->tHFGen, 32); + else + sbr_qmf_analysis_32(sbr, &sbr->qmfa[ch], channel_buf, sbr->Xsbr[ch], sbr->tHFGen, sbr->kx); + + if (!dont_process) + { +#if 1 + /* insert high frequencies here */ + /* hf generation using patching */ + hf_generation(sbr, sbr->Xsbr[ch], sbr->Xsbr[ch] +#ifdef SBR_LOW_POWER + ,deg +#endif + ,ch); +#endif + +#ifdef SBR_LOW_POWER + for (l = sbr->t_E[ch][0]; l < sbr->t_E[ch][sbr->L_E[ch]]; l++) + { + for (k = 0; k < sbr->kx; k++) + { + QMF_RE(sbr->Xsbr[ch][sbr->tHFAdj + l][k]) = 0; + } + } +#endif + +#if 1 + /* hf adjustment */ + hf_adjustment(sbr, sbr->Xsbr[ch] +#ifdef SBR_LOW_POWER + ,deg +#endif + ,ch); +#endif + } + + if ((sbr->just_seeked != 0) || dont_process) + { + for (l = 0; l < sbr->numTimeSlotsRate; l++) + { + for (k = 0; k < 32; k++) + { + QMF_RE(X[l][k]) = QMF_RE(sbr->Xsbr[ch][l + sbr->tHFAdj][k]); +#ifndef SBR_LOW_POWER + QMF_IM(X[l][k]) = QMF_IM(sbr->Xsbr[ch][l + sbr->tHFAdj][k]); +#endif + } + for (k = 32; k < 64; k++) + { + QMF_RE(X[l][k]) = 0; +#ifndef SBR_LOW_POWER + QMF_IM(X[l][k]) = 0; +#endif + } + } + } else { + for (l = 0; l < sbr->numTimeSlotsRate; l++) + { + uint8_t kx_band, M_band, bsco_band; + + if (l < sbr->t_E[ch][0]) + { + kx_band = sbr->kx_prev; + M_band = sbr->M_prev; + bsco_band = sbr->bsco_prev; + } else { + kx_band = sbr->kx; + M_band = sbr->M; + bsco_band = sbr->bsco; + } + +#ifndef SBR_LOW_POWER + for (k = 0; k < kx_band + bsco_band; k++) + { + QMF_RE(X[l][k]) = QMF_RE(sbr->Xsbr[ch][l + sbr->tHFAdj][k]); + QMF_IM(X[l][k]) = QMF_IM(sbr->Xsbr[ch][l + sbr->tHFAdj][k]); + } + for (k = kx_band + bsco_band; k < kx_band + M_band; k++) + { + QMF_RE(X[l][k]) = QMF_RE(sbr->Xsbr[ch][l + sbr->tHFAdj][k]); + QMF_IM(X[l][k]) = QMF_IM(sbr->Xsbr[ch][l + sbr->tHFAdj][k]); + } + for (k = max(kx_band + bsco_band, kx_band + M_band); k < 64; k++) + { + QMF_RE(X[l][k]) = 0; + QMF_IM(X[l][k]) = 0; + } +#else + for (k = 0; k < kx_band + bsco_band; k++) + { + QMF_RE(X[l][k]) = QMF_RE(sbr->Xsbr[ch][l + sbr->tHFAdj][k]); + } + for (k = kx_band + bsco_band; k < min(kx_band + M_band, 63); k++) + { + QMF_RE(X[l][k]) = QMF_RE(sbr->Xsbr[ch][l + sbr->tHFAdj][k]); + } + for (k = max(kx_band + bsco_band, kx_band + M_band); k < 64; k++) + { + QMF_RE(X[l][k]) = 0; + } + QMF_RE(X[l][kx_band - 1 + bsco_band]) += + QMF_RE(sbr->Xsbr[ch][l + sbr->tHFAdj][kx_band - 1 + bsco_band]); +#endif + } + } +} + +uint8_t sbrDecodeCoupleFrame(sbr_info *sbr, real_t *left_chan, real_t *right_chan, + const uint8_t just_seeked, const uint8_t downSampledSBR) +{ + uint8_t dont_process = 0; + uint8_t ret = 0; + + if (sbr == NULL) + return 20; + + /* case can occur due to bit errors */ + if (sbr->id_aac != ID_CPE) + return 21; + + if (sbr->ret || (sbr->header_count == 0)) + { + /* don't process just upsample */ + dont_process = 1; + + /* Re-activate reset for next frame */ + if (sbr->ret && sbr->Reset) + sbr->bs_start_freq_prev = -1; + } + + if (just_seeked) + { + sbr->just_seeked = 1; + } else { + sbr->just_seeked = 0; + } + + sbr_process_channel(sbr, left_chan, p_XLR->X_L, 0, dont_process, downSampledSBR); + /* subband synthesis */ + if (downSampledSBR) + { + sbr_qmf_synthesis_32(sbr, &sbr->qmfs[0], p_XLR->X_L, left_chan); + } else { + sbr_qmf_synthesis_64(sbr, &sbr->qmfs[0], p_XLR->X_L, left_chan); + } + + sbr_process_channel(sbr, right_chan, p_XLR->X_R, 1, dont_process, downSampledSBR); + /* subband synthesis */ + if (downSampledSBR) + { + sbr_qmf_synthesis_32(sbr, &sbr->qmfs[1], p_XLR->X_R, right_chan); + } else { + sbr_qmf_synthesis_64(sbr, &sbr->qmfs[1], p_XLR->X_R, right_chan); + } + + if (sbr->bs_header_flag) + sbr->just_seeked = 0; + + if (sbr->header_count != 0 && sbr->ret == 0) + { + ret = sbr_save_prev_data(sbr, 0); + if (ret) return ret; + ret = sbr_save_prev_data(sbr, 1); + if (ret) return ret; + } + + sbr_save_matrix(sbr, 0); + sbr_save_matrix(sbr, 1); + + sbr->frame++; + +//#define POST_QMF_PRINT +#ifdef POST_QMF_PRINT + { + int i; + for (i = 0; i < 2048; i++) + { + printf("%d\n", left_chan[i]); + } + for (i = 0; i < 2048; i++) + { + printf("%d\n", right_chan[i]); + } + } +#endif + + return 0; +} + +uint8_t sbrDecodeSingleFrame(sbr_info *sbr, real_t *channel, + const uint8_t just_seeked, const uint8_t downSampledSBR) +{ + uint8_t dont_process = 0; + uint8_t ret = 0; + + if (sbr == NULL) + return 20; + + /* case can occur due to bit errors */ + if (sbr->id_aac != ID_SCE && sbr->id_aac != ID_LFE) + return 21; + + if (sbr->ret || (sbr->header_count == 0)) + { + /* don't process just upsample */ + dont_process = 1; + + /* Re-activate reset for next frame */ + if (sbr->ret && sbr->Reset) + sbr->bs_start_freq_prev = -1; + } + + if (just_seeked) + { + sbr->just_seeked = 1; + } else { + sbr->just_seeked = 0; + } + + sbr_process_channel(sbr, channel, p_XLR->X_L, 0, dont_process, downSampledSBR); + /* subband synthesis */ + if (downSampledSBR) + { + sbr_qmf_synthesis_32(sbr, &sbr->qmfs[0], p_XLR->X_L, channel); + } else { + sbr_qmf_synthesis_64(sbr, &sbr->qmfs[0], p_XLR->X_L, channel); + } + + if (sbr->bs_header_flag) + sbr->just_seeked = 0; + + if (sbr->header_count != 0 && sbr->ret == 0) + { + ret = sbr_save_prev_data(sbr, 0); + if (ret) return ret; + } + + sbr_save_matrix(sbr, 0); + + sbr->frame++; + +//#define POST_QMF_PRINT +#ifdef POST_QMF_PRINT + { + int i; + for (i = 0; i < 2048; i++) + { + printf("%d\n", channel[i]); + } + } +#endif + + return 0; +} + + +#if (defined(PS_DEC) || defined(DRM_PS)) +uint8_t sbrDecodeSingleFramePS(sbr_info *sbr, real_t *left_channel, real_t *right_channel, + const uint8_t just_seeked, const uint8_t downSampledSBR) +{ + uint8_t l, k; + uint8_t dont_process = 0; + uint8_t ret = 0; + + memset(p_XLR->X_L, 0, sizeof(*p_XLR->X_L)); + memset(p_XLR->X_R, 0, sizeof(*p_XLR->X_R)); + if (sbr == NULL) + return 20; + + /* case can occur due to bit errors */ + if (sbr->id_aac != ID_SCE && sbr->id_aac != ID_LFE) + return 21; + + if (sbr->ret || (sbr->header_count == 0)) + { + /* don't process just upsample */ + dont_process = 1; + + /* Re-activate reset for next frame */ + if (sbr->ret && sbr->Reset) + sbr->bs_start_freq_prev = -1; + } + + if (just_seeked) + { + sbr->just_seeked = 1; + } else { + sbr->just_seeked = 0; + } + + sbr_process_channel(sbr, left_channel, p_XLR->X_L, 0, dont_process, downSampledSBR); + + /* copy some extra data for PS */ + for (l = 32; l < 38; l++) + { + for (k = 0; k < 5; k++) + { + QMF_RE(p_XLR->X_L[l][k]) = QMF_RE(sbr->Xsbr[0][sbr->tHFAdj+l][k]); + QMF_IM(p_XLR->X_L[l][k]) = QMF_IM(sbr->Xsbr[0][sbr->tHFAdj+l][k]); + } + } + + /* perform parametric stereo */ +#ifdef DRM_PS + if (sbr->Is_DRM_SBR) + { + drm_ps_decode(sbr->drm_ps, (sbr->ret > 0), sbr->sample_rate, p_XLR->X_L, p_XLR->X_R); + } else { +#endif +#ifdef PS_DEC + ps_decode(&sbr->ps, p_XLR->X_L, p_XLR->X_R); +#endif +#ifdef DRM_PS + } +#endif + + /* subband synthesis */ + if (downSampledSBR) + { + sbr_qmf_synthesis_32(sbr, &sbr->qmfs[0], p_XLR->X_L, left_channel); + sbr_qmf_synthesis_32(sbr, &sbr->qmfs[1], p_XLR->X_R, right_channel); + } else { + sbr_qmf_synthesis_64(sbr, &sbr->qmfs[0], p_XLR->X_L, left_channel); + sbr_qmf_synthesis_64(sbr, &sbr->qmfs[1], p_XLR->X_R, right_channel); + } + + if (sbr->bs_header_flag) + sbr->just_seeked = 0; + + if (sbr->header_count != 0 && sbr->ret == 0) + { + ret = sbr_save_prev_data(sbr, 0); + if (ret) return ret; + } + + sbr_save_matrix(sbr, 0); + + sbr->frame++; + + return 0; +} +#endif + +#endif diff --git a/lib/rbcodec/codecs/libfaad/sbr_dec.h b/lib/rbcodec/codecs/libfaad/sbr_dec.h new file mode 100644 index 0000000000..89fe72b7e9 --- /dev/null +++ b/lib/rbcodec/codecs/libfaad/sbr_dec.h @@ -0,0 +1,242 @@ +/* +** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding +** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +** +** Any non-GPL usage of this software or parts of this software is strictly +** forbidden. +** +** Commercial non-GPL licensing of this software is possible. +** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** +** $Id$ +**/ + +#ifndef __SBR_DEC_H__ +#define __SBR_DEC_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef PS_DEC +#include "ps_dec.h" +#endif +#ifdef DRM_PS +#include "drm_dec.h" +#endif + +#define MAX_NTSRHFG 40 /* maximum of number_time_slots * rate + HFGen. 16*2+8 */ +#define MAX_NTSR 32 /* max number_time_slots * rate, ok for DRM and not DRM mode */ + +/* MAX_M: maximum value for M */ +#define MAX_M 49 +/* MAX_L_E: maximum value for L_E */ +#define MAX_L_E 5 + +typedef struct { + real_t x[2*32*10]; + int16_t x_index; +} qmfa_info; + +typedef struct { + real_t v[2*64*20]; /* Size was "(downSampledSBR)?32:64". We use 64 now. */ + int16_t v_index; +} qmfs_info; + +typedef struct +{ + uint32_t sample_rate; + uint32_t maxAACLine; + + uint8_t rate; + uint8_t just_seeked; + uint8_t ret; + + uint8_t amp_res[2]; + + uint8_t k0; + uint8_t kx; + uint8_t M; + uint8_t N_master; + uint8_t N_high; + uint8_t N_low; + uint8_t N_Q; + uint8_t N_L[4]; + uint8_t n[2]; + + uint8_t f_master[64]; + uint8_t f_table_res[2][64]; + uint8_t f_table_noise[64]; + uint8_t f_table_lim[4][64]; +#ifdef SBR_LOW_POWER + uint8_t f_group[5][64]; + uint8_t N_G[5]; +#endif + + uint8_t table_map_k_to_g[64]; + + uint8_t abs_bord_lead[2]; + uint8_t abs_bord_trail[2]; + uint8_t n_rel_lead[2]; + uint8_t n_rel_trail[2]; + + uint8_t L_E[2]; + uint8_t L_E_prev[2]; + uint8_t L_Q[2]; + + uint8_t t_E[2][MAX_L_E+1]; + uint8_t t_Q[2][3]; + uint8_t f[2][MAX_L_E+1]; + uint8_t f_prev[2]; + + real_t G_temp_prev[2][5][64]; + real_t Q_temp_prev[2][5][64]; + int8_t GQ_ringbuf_index[2]; + + int16_t E[2][64][MAX_L_E]; + int16_t E_prev[2][64]; +#ifndef FIXED_POINT + real_t E_orig[2][64][MAX_L_E]; +#endif + real_t E_curr[2][64][MAX_L_E]; + int32_t Q[2][64][2]; +#ifndef FIXED_POINT + real_t Q_div[2][64][2]; + real_t Q_div2[2][64][2]; +#endif + int32_t Q_prev[2][64]; + + int8_t l_A[2]; + int8_t l_A_prev[2]; + + uint8_t bs_invf_mode[2][MAX_L_E]; + uint8_t bs_invf_mode_prev[2][MAX_L_E]; + real_t bwArray[2][64]; + real_t bwArray_prev[2][64]; + + uint8_t noPatches; + uint8_t patchNoSubbands[64]; + uint8_t patchStartSubband[64]; + + uint8_t bs_add_harmonic[2][64]; + uint8_t bs_add_harmonic_prev[2][64]; + + uint16_t index_noise_prev[2]; + uint8_t psi_is_prev[2]; + + uint8_t bs_start_freq_prev; + uint8_t bs_stop_freq_prev; + uint8_t bs_xover_band_prev; + uint8_t bs_freq_scale_prev; + uint8_t bs_alter_scale_prev; + uint8_t bs_noise_bands_prev; + + int8_t prevEnvIsShort[2]; + + int8_t kx_prev; + uint8_t bsco; + uint8_t bsco_prev; + uint8_t M_prev; + uint16_t frame_len; + + uint8_t Reset; + uint32_t frame; + uint32_t header_count; + + uint8_t id_aac; + qmfa_info qmfa[2] MEM_ALIGN_ATTR; + qmfs_info qmfs[2] MEM_ALIGN_ATTR; + + qmf_t Xsbr[2][MAX_NTSRHFG][64] MEM_ALIGN_ATTR; + +#ifdef DRM + uint8_t Is_DRM_SBR; +#ifdef DRM_PS + drm_ps_info *drm_ps; +#endif +#endif + + uint8_t numTimeSlotsRate; + uint8_t numTimeSlots; + uint8_t tHFGen; + uint8_t tHFAdj; + +#ifdef PS_DEC + ps_info ps; +#endif +#if (defined(PS_DEC) || defined(DRM_PS)) + uint8_t ps_used; +#endif + + /* to get it compiling */ + /* we'll see during the coding of all the tools, whether + these are all used or not. + */ + uint8_t bs_header_flag; + uint8_t bs_crc_flag; + uint16_t bs_sbr_crc_bits; + uint8_t bs_protocol_version; + uint8_t bs_amp_res; + uint8_t bs_start_freq; + uint8_t bs_stop_freq; + uint8_t bs_xover_band; + uint8_t bs_freq_scale; + uint8_t bs_alter_scale; + uint8_t bs_noise_bands; + uint8_t bs_limiter_bands; + uint8_t bs_limiter_gains; + uint8_t bs_interpol_freq; + uint8_t bs_smoothing_mode; + uint8_t bs_samplerate_mode; + uint8_t bs_add_harmonic_flag[2]; + uint8_t bs_add_harmonic_flag_prev[2]; + uint8_t bs_extended_data; + uint8_t bs_extension_id; + uint8_t bs_extension_data; + uint8_t bs_coupling; + uint8_t bs_frame_class[2]; + uint8_t bs_rel_bord[2][9]; + uint8_t bs_rel_bord_0[2][9]; + uint8_t bs_rel_bord_1[2][9]; + uint8_t bs_pointer[2]; + uint8_t bs_abs_bord_0[2]; + uint8_t bs_abs_bord_1[2]; + uint8_t bs_num_rel_0[2]; + uint8_t bs_num_rel_1[2]; + uint8_t bs_df_env[2][9]; + uint8_t bs_df_noise[2][3]; +} sbr_info; + +sbr_info *sbrDecodeInit(uint16_t framelength, uint8_t id_aac, uint8_t id_ele, + uint32_t sample_rate, uint8_t downSampledSBR, + uint8_t IsDRM); + +uint8_t sbrDecodeCoupleFrame(sbr_info *sbr, real_t *left_chan, real_t *right_chan, + const uint8_t just_seeked, const uint8_t downSampledSBR); +uint8_t sbrDecodeSingleFrame(sbr_info *sbr, real_t *channel, + const uint8_t just_seeked, const uint8_t downSampledSBR); +#if (defined(PS_DEC) || defined(DRM_PS)) +uint8_t sbrDecodeSingleFramePS(sbr_info *sbr, real_t *left_channel, real_t *right_channel, + const uint8_t just_seeked, const uint8_t downSampledSBR); +#endif + + +#ifdef __cplusplus +} +#endif +#endif + diff --git a/lib/rbcodec/codecs/libfaad/sbr_e_nf.c b/lib/rbcodec/codecs/libfaad/sbr_e_nf.c new file mode 100644 index 0000000000..ea2cbb8e35 --- /dev/null +++ b/lib/rbcodec/codecs/libfaad/sbr_e_nf.c @@ -0,0 +1,507 @@ +/* +** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding +** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +** +** Any non-GPL usage of this software or parts of this software is strictly +** forbidden. +** +** Commercial non-GPL licensing of this software is possible. +** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** +** $Id$ +**/ + +#include "common.h" +#include "structs.h" + +#ifdef SBR_DEC + +#include + +#include "sbr_syntax.h" +#include "sbr_e_nf.h" + +void extract_envelope_data(sbr_info *sbr, uint8_t ch) +{ + uint8_t l, k; + + for (l = 0; l < sbr->L_E[ch]; l++) + { + if (sbr->bs_df_env[ch][l] == 0) + { + for (k = 1; k < sbr->n[sbr->f[ch][l]]; k++) + { + sbr->E[ch][k][l] = sbr->E[ch][k - 1][l] + sbr->E[ch][k][l]; + if (sbr->E[ch][k][l] < 0) + sbr->E[ch][k][l] = 0; + } + + } else { /* bs_df_env == 1 */ + + uint8_t g = (l == 0) ? sbr->f_prev[ch] : sbr->f[ch][l-1]; + int16_t E_prev; + + if (sbr->f[ch][l] == g) + { + for (k = 0; k < sbr->n[sbr->f[ch][l]]; k++) + { + if (l == 0) + E_prev = sbr->E_prev[ch][k]; + else + E_prev = sbr->E[ch][k][l - 1]; + + sbr->E[ch][k][l] = E_prev + sbr->E[ch][k][l]; + } + + } else if ((g == 1) && (sbr->f[ch][l] == 0)) { + uint8_t i; + + for (k = 0; k < sbr->n[sbr->f[ch][l]]; k++) + { + for (i = 0; i < sbr->N_high; i++) + { + if (sbr->f_table_res[HI_RES][i] == sbr->f_table_res[LO_RES][k]) + { + if (l == 0) + E_prev = sbr->E_prev[ch][i]; + else + E_prev = sbr->E[ch][i][l - 1]; + + sbr->E[ch][k][l] = E_prev + sbr->E[ch][k][l]; + } + } + } + + } else if ((g == 0) && (sbr->f[ch][l] == 1)) { + uint8_t i; + + for (k = 0; k < sbr->n[sbr->f[ch][l]]; k++) + { + for (i = 0; i < sbr->N_low; i++) + { + if ((sbr->f_table_res[LO_RES][i] <= sbr->f_table_res[HI_RES][k]) && + (sbr->f_table_res[HI_RES][k] < sbr->f_table_res[LO_RES][i + 1])) + { + if (l == 0) + E_prev = sbr->E_prev[ch][i]; + else + E_prev = sbr->E[ch][i][l - 1]; + + sbr->E[ch][k][l] = E_prev + sbr->E[ch][k][l]; + } + } + } + } + } + } +} + +void extract_noise_floor_data(sbr_info *sbr, uint8_t ch) +{ + uint8_t l, k; + + for (l = 0; l < sbr->L_Q[ch]; l++) + { + if (sbr->bs_df_noise[ch][l] == 0) + { + for (k = 1; k < sbr->N_Q; k++) + { + sbr->Q[ch][k][l] = sbr->Q[ch][k][l] + sbr->Q[ch][k-1][l]; + } + } else { + if (l == 0) + { + for (k = 0; k < sbr->N_Q; k++) + { + sbr->Q[ch][k][l] = sbr->Q_prev[ch][k] + sbr->Q[ch][k][0]; + } + } else { + for (k = 0; k < sbr->N_Q; k++) + { + sbr->Q[ch][k][l] = sbr->Q[ch][k][l - 1] + sbr->Q[ch][k][l]; + } + } + } + } +} + +#ifndef FIXED_POINT + +/* table for Q_div values when no coupling */ +static const real_t Q_div_tab[31] = { + FRAC_CONST(0.0153846), FRAC_CONST(0.030303), + FRAC_CONST(0.0588235), FRAC_CONST(0.111111), + FRAC_CONST(0.2), FRAC_CONST(0.333333), + FRAC_CONST(0.5), FRAC_CONST(0.666667), + FRAC_CONST(0.8), FRAC_CONST(0.888889), + FRAC_CONST(0.941176), FRAC_CONST(0.969697), + FRAC_CONST(0.984615), FRAC_CONST(0.992248), + FRAC_CONST(0.996109), FRAC_CONST(0.998051), + FRAC_CONST(0.999024), FRAC_CONST(0.999512), + FRAC_CONST(0.999756), FRAC_CONST(0.999878), + FRAC_CONST(0.999939), FRAC_CONST(0.999969), + FRAC_CONST(0.999985), FRAC_CONST(0.999992), + FRAC_CONST(0.999996), FRAC_CONST(0.999998), + FRAC_CONST(0.999999), FRAC_CONST(1), + FRAC_CONST(1), FRAC_CONST(1), + FRAC_CONST(1) +}; + +static const real_t Q_div_tab_left[31][13] = { + { FRAC_CONST(0.969704), FRAC_CONST(0.888985), FRAC_CONST(0.667532), FRAC_CONST(0.336788), FRAC_CONST(0.117241), FRAC_CONST(0.037594), FRAC_CONST(0.0153846), FRAC_CONST(0.00967118), FRAC_CONST(0.00823245), FRAC_CONST(0.00787211), FRAC_CONST(0.00778198), FRAC_CONST(0.00775945), FRAC_CONST(0.00775382) }, + { FRAC_CONST(0.984619), FRAC_CONST(0.94123), FRAC_CONST(0.800623), FRAC_CONST(0.503876), FRAC_CONST(0.209877), FRAC_CONST(0.0724638), FRAC_CONST(0.030303), FRAC_CONST(0.0191571), FRAC_CONST(0.0163305), FRAC_CONST(0.0156212), FRAC_CONST(0.0154438), FRAC_CONST(0.0153994), FRAC_CONST(0.0153883) }, + { FRAC_CONST(0.99225), FRAC_CONST(0.969726), FRAC_CONST(0.889273), FRAC_CONST(0.670103), FRAC_CONST(0.346939), FRAC_CONST(0.135135), FRAC_CONST(0.0588235), FRAC_CONST(0.037594), FRAC_CONST(0.0321361), FRAC_CONST(0.0307619), FRAC_CONST(0.0304178), FRAC_CONST(0.0303317), FRAC_CONST(0.0303102) }, + { FRAC_CONST(0.99611), FRAC_CONST(0.98463), FRAC_CONST(0.941392), FRAC_CONST(0.802469), FRAC_CONST(0.515152), FRAC_CONST(0.238095), FRAC_CONST(0.111111), FRAC_CONST(0.0724638), FRAC_CONST(0.0622711), FRAC_CONST(0.0596878), FRAC_CONST(0.0590397), FRAC_CONST(0.0588776), FRAC_CONST(0.058837) }, + { FRAC_CONST(0.998051), FRAC_CONST(0.992256), FRAC_CONST(0.969811), FRAC_CONST(0.890411), FRAC_CONST(0.68), FRAC_CONST(0.384615), FRAC_CONST(0.2), FRAC_CONST(0.135135), FRAC_CONST(0.117241), FRAC_CONST(0.112652), FRAC_CONST(0.111497), FRAC_CONST(0.111208), FRAC_CONST(0.111135) }, + { FRAC_CONST(0.999025), FRAC_CONST(0.996113), FRAC_CONST(0.984674), FRAC_CONST(0.942029), FRAC_CONST(0.809524), FRAC_CONST(0.555556), FRAC_CONST(0.333333), FRAC_CONST(0.238095), FRAC_CONST(0.209877), FRAC_CONST(0.202492), FRAC_CONST(0.200625), FRAC_CONST(0.200156), FRAC_CONST(0.200039) }, + { FRAC_CONST(0.999512), FRAC_CONST(0.998053), FRAC_CONST(0.992278), FRAC_CONST(0.970149), FRAC_CONST(0.894737), FRAC_CONST(0.714286), FRAC_CONST(0.5), FRAC_CONST(0.384615), FRAC_CONST(0.346939), FRAC_CONST(0.336788), FRAC_CONST(0.3342), FRAC_CONST(0.33355), FRAC_CONST(0.333388) }, + { FRAC_CONST(0.999756), FRAC_CONST(0.999025), FRAC_CONST(0.996124), FRAC_CONST(0.984848), FRAC_CONST(0.944444), FRAC_CONST(0.833333), FRAC_CONST(0.666667), FRAC_CONST(0.555556), FRAC_CONST(0.515152), FRAC_CONST(0.503876), FRAC_CONST(0.500975), FRAC_CONST(0.500244), FRAC_CONST(0.500061) }, + { FRAC_CONST(0.999878), FRAC_CONST(0.999512), FRAC_CONST(0.998058), FRAC_CONST(0.992366), FRAC_CONST(0.971429), FRAC_CONST(0.909091), FRAC_CONST(0.8), FRAC_CONST(0.714286), FRAC_CONST(0.68), FRAC_CONST(0.670103), FRAC_CONST(0.667532), FRAC_CONST(0.666884), FRAC_CONST(0.666721) }, + { FRAC_CONST(0.999939), FRAC_CONST(0.999756), FRAC_CONST(0.999028), FRAC_CONST(0.996169), FRAC_CONST(0.985507), FRAC_CONST(0.952381), FRAC_CONST(0.888889), FRAC_CONST(0.833333), FRAC_CONST(0.809524), FRAC_CONST(0.802469), FRAC_CONST(0.800623), FRAC_CONST(0.800156), FRAC_CONST(0.800039) }, + { FRAC_CONST(0.999969), FRAC_CONST(0.999878), FRAC_CONST(0.999514), FRAC_CONST(0.998081), FRAC_CONST(0.992701), FRAC_CONST(0.97561), FRAC_CONST(0.941176), FRAC_CONST(0.909091), FRAC_CONST(0.894737), FRAC_CONST(0.890411), FRAC_CONST(0.889273), FRAC_CONST(0.888985), FRAC_CONST(0.888913) }, + { FRAC_CONST(0.999985), FRAC_CONST(0.999939), FRAC_CONST(0.999757), FRAC_CONST(0.999039), FRAC_CONST(0.996337), FRAC_CONST(0.987654), FRAC_CONST(0.969697), FRAC_CONST(0.952381), FRAC_CONST(0.944444), FRAC_CONST(0.942029), FRAC_CONST(0.941392), FRAC_CONST(0.94123), FRAC_CONST(0.94119) }, + { FRAC_CONST(0.999992), FRAC_CONST(0.99997), FRAC_CONST(0.999878), FRAC_CONST(0.999519), FRAC_CONST(0.998165), FRAC_CONST(0.993789), FRAC_CONST(0.984615), FRAC_CONST(0.97561), FRAC_CONST(0.971429), FRAC_CONST(0.970149), FRAC_CONST(0.969811), FRAC_CONST(0.969726), FRAC_CONST(0.969704) }, + { FRAC_CONST(0.999996), FRAC_CONST(0.999985), FRAC_CONST(0.999939), FRAC_CONST(0.99976), FRAC_CONST(0.999082), FRAC_CONST(0.996885), FRAC_CONST(0.992248), FRAC_CONST(0.987654), FRAC_CONST(0.985507), FRAC_CONST(0.984848), FRAC_CONST(0.984674), FRAC_CONST(0.98463), FRAC_CONST(0.984619) }, + { FRAC_CONST(0.999998), FRAC_CONST(0.999992), FRAC_CONST(0.99997), FRAC_CONST(0.99988), FRAC_CONST(0.999541), FRAC_CONST(0.99844), FRAC_CONST(0.996109), FRAC_CONST(0.993789), FRAC_CONST(0.992701), FRAC_CONST(0.992366), FRAC_CONST(0.992278), FRAC_CONST(0.992256), FRAC_CONST(0.99225) }, + { FRAC_CONST(0.999999), FRAC_CONST(0.999996), FRAC_CONST(0.999985), FRAC_CONST(0.99994), FRAC_CONST(0.99977), FRAC_CONST(0.999219), FRAC_CONST(0.998051), FRAC_CONST(0.996885), FRAC_CONST(0.996337), FRAC_CONST(0.996169), FRAC_CONST(0.996124), FRAC_CONST(0.996113), FRAC_CONST(0.99611) }, + { FRAC_CONST(1), FRAC_CONST(0.999998), FRAC_CONST(0.999992), FRAC_CONST(0.99997), FRAC_CONST(0.999885), FRAC_CONST(0.99961), FRAC_CONST(0.999024), FRAC_CONST(0.99844), FRAC_CONST(0.998165), FRAC_CONST(0.998081), FRAC_CONST(0.998058), FRAC_CONST(0.998053), FRAC_CONST(0.998051) }, + { FRAC_CONST(1), FRAC_CONST(0.999999), FRAC_CONST(0.999996), FRAC_CONST(0.999985), FRAC_CONST(0.999943), FRAC_CONST(0.999805), FRAC_CONST(0.999512), FRAC_CONST(0.999219), FRAC_CONST(0.999082), FRAC_CONST(0.999039), FRAC_CONST(0.999028), FRAC_CONST(0.999025), FRAC_CONST(0.999025) }, + { FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(0.999998), FRAC_CONST(0.999992), FRAC_CONST(0.999971), FRAC_CONST(0.999902), FRAC_CONST(0.999756), FRAC_CONST(0.99961), FRAC_CONST(0.999541), FRAC_CONST(0.999519), FRAC_CONST(0.999514), FRAC_CONST(0.999512), FRAC_CONST(0.999512) }, + { FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(0.999999), FRAC_CONST(0.999996), FRAC_CONST(0.999986), FRAC_CONST(0.999951), FRAC_CONST(0.999878), FRAC_CONST(0.999805), FRAC_CONST(0.99977), FRAC_CONST(0.99976), FRAC_CONST(0.999757), FRAC_CONST(0.999756), FRAC_CONST(0.999756) }, + { FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(0.999998), FRAC_CONST(0.999993), FRAC_CONST(0.999976), FRAC_CONST(0.999939), FRAC_CONST(0.999902), FRAC_CONST(0.999885), FRAC_CONST(0.99988), FRAC_CONST(0.999878), FRAC_CONST(0.999878), FRAC_CONST(0.999878) }, + { FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(0.999999), FRAC_CONST(0.999996), FRAC_CONST(0.999988), FRAC_CONST(0.999969), FRAC_CONST(0.999951), FRAC_CONST(0.999943), FRAC_CONST(0.99994), FRAC_CONST(0.999939), FRAC_CONST(0.999939), FRAC_CONST(0.999939) }, + { FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(0.999998), FRAC_CONST(0.999994), FRAC_CONST(0.999985), FRAC_CONST(0.999976), FRAC_CONST(0.999971), FRAC_CONST(0.99997), FRAC_CONST(0.99997), FRAC_CONST(0.99997), FRAC_CONST(0.999969) }, + { FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(0.999999), FRAC_CONST(0.999997), FRAC_CONST(0.999992), FRAC_CONST(0.999988), FRAC_CONST(0.999986), FRAC_CONST(0.999985), FRAC_CONST(0.999985), FRAC_CONST(0.999985), FRAC_CONST(0.999985) }, + { FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(0.999998), FRAC_CONST(0.999996), FRAC_CONST(0.999994), FRAC_CONST(0.999993), FRAC_CONST(0.999992), FRAC_CONST(0.999992), FRAC_CONST(0.999992), FRAC_CONST(0.999992) }, + { FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(0.999999), FRAC_CONST(0.999998), FRAC_CONST(0.999997), FRAC_CONST(0.999996), FRAC_CONST(0.999996), FRAC_CONST(0.999996), FRAC_CONST(0.999996), FRAC_CONST(0.999996) }, + { FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(0.999999), FRAC_CONST(0.999998), FRAC_CONST(0.999998), FRAC_CONST(0.999998), FRAC_CONST(0.999998), FRAC_CONST(0.999998), FRAC_CONST(0.999998) }, + { FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(0.999999), FRAC_CONST(0.999999), FRAC_CONST(0.999999), FRAC_CONST(0.999999), FRAC_CONST(0.999999), FRAC_CONST(0.999999) }, + { FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1) }, + { FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1) }, + { FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1) } +}; + +static const real_t Q_div_tab_right[31][13] = { + { FRAC_CONST(0.00775382), FRAC_CONST(0.00775945), FRAC_CONST(0.00778198), FRAC_CONST(0.00787211), FRAC_CONST(0.00823245), FRAC_CONST(0.00967118), FRAC_CONST(0.0153846), FRAC_CONST(0.037594), FRAC_CONST(0.117241), FRAC_CONST(0.336788), FRAC_CONST(0.667532), FRAC_CONST(0.888985), FRAC_CONST(0.969704) }, + { FRAC_CONST(0.0153883), FRAC_CONST(0.0153994), FRAC_CONST(0.0154438), FRAC_CONST(0.0156212), FRAC_CONST(0.0163305), FRAC_CONST(0.0191571), FRAC_CONST(0.030303), FRAC_CONST(0.0724638), FRAC_CONST(0.209877), FRAC_CONST(0.503876), FRAC_CONST(0.800623), FRAC_CONST(0.94123), FRAC_CONST(0.984619) }, + { FRAC_CONST(0.0303102), FRAC_CONST(0.0303317), FRAC_CONST(0.0304178), FRAC_CONST(0.0307619), FRAC_CONST(0.0321361), FRAC_CONST(0.037594), FRAC_CONST(0.0588235), FRAC_CONST(0.135135), FRAC_CONST(0.346939), FRAC_CONST(0.670103), FRAC_CONST(0.889273), FRAC_CONST(0.969726), FRAC_CONST(0.99225) }, + { FRAC_CONST(0.058837), FRAC_CONST(0.0588776), FRAC_CONST(0.0590397), FRAC_CONST(0.0596878), FRAC_CONST(0.0622711), FRAC_CONST(0.0724638), FRAC_CONST(0.111111), FRAC_CONST(0.238095), FRAC_CONST(0.515152), FRAC_CONST(0.802469), FRAC_CONST(0.941392), FRAC_CONST(0.98463), FRAC_CONST(0.99611) }, + { FRAC_CONST(0.111135), FRAC_CONST(0.111208), FRAC_CONST(0.111497), FRAC_CONST(0.112652), FRAC_CONST(0.117241), FRAC_CONST(0.135135), FRAC_CONST(0.2), FRAC_CONST(0.384615), FRAC_CONST(0.68), FRAC_CONST(0.890411), FRAC_CONST(0.969811), FRAC_CONST(0.992256), FRAC_CONST(0.998051) }, + { FRAC_CONST(0.200039), FRAC_CONST(0.200156), FRAC_CONST(0.200625), FRAC_CONST(0.202492), FRAC_CONST(0.209877), FRAC_CONST(0.238095), FRAC_CONST(0.333333), FRAC_CONST(0.555556), FRAC_CONST(0.809524), FRAC_CONST(0.942029), FRAC_CONST(0.984674), FRAC_CONST(0.996113), FRAC_CONST(0.999025) }, + { FRAC_CONST(0.333388), FRAC_CONST(0.33355), FRAC_CONST(0.3342), FRAC_CONST(0.336788), FRAC_CONST(0.346939), FRAC_CONST(0.384615), FRAC_CONST(0.5), FRAC_CONST(0.714286), FRAC_CONST(0.894737), FRAC_CONST(0.970149), FRAC_CONST(0.992278), FRAC_CONST(0.998053), FRAC_CONST(0.999512) }, + { FRAC_CONST(0.500061), FRAC_CONST(0.500244), FRAC_CONST(0.500975), FRAC_CONST(0.503876), FRAC_CONST(0.515152), FRAC_CONST(0.555556), FRAC_CONST(0.666667), FRAC_CONST(0.833333), FRAC_CONST(0.944444), FRAC_CONST(0.984848), FRAC_CONST(0.996124), FRAC_CONST(0.999025), FRAC_CONST(0.999756) }, + { FRAC_CONST(0.666721), FRAC_CONST(0.666884), FRAC_CONST(0.667532), FRAC_CONST(0.670103), FRAC_CONST(0.68), FRAC_CONST(0.714286), FRAC_CONST(0.8), FRAC_CONST(0.909091), FRAC_CONST(0.971429), FRAC_CONST(0.992366), FRAC_CONST(0.998058), FRAC_CONST(0.999512), FRAC_CONST(0.999878) }, + { FRAC_CONST(0.800039), FRAC_CONST(0.800156), FRAC_CONST(0.800623), FRAC_CONST(0.802469), FRAC_CONST(0.809524), FRAC_CONST(0.833333), FRAC_CONST(0.888889), FRAC_CONST(0.952381), FRAC_CONST(0.985507), FRAC_CONST(0.996169), FRAC_CONST(0.999028), FRAC_CONST(0.999756), FRAC_CONST(0.999939) }, + { FRAC_CONST(0.888913), FRAC_CONST(0.888985), FRAC_CONST(0.889273), FRAC_CONST(0.890411), FRAC_CONST(0.894737), FRAC_CONST(0.909091), FRAC_CONST(0.941176), FRAC_CONST(0.97561), FRAC_CONST(0.992701), FRAC_CONST(0.998081), FRAC_CONST(0.999514), FRAC_CONST(0.999878), FRAC_CONST(0.999969) }, + { FRAC_CONST(0.94119), FRAC_CONST(0.94123), FRAC_CONST(0.941392), FRAC_CONST(0.942029), FRAC_CONST(0.944444), FRAC_CONST(0.952381), FRAC_CONST(0.969697), FRAC_CONST(0.987654), FRAC_CONST(0.996337), FRAC_CONST(0.999039), FRAC_CONST(0.999757), FRAC_CONST(0.999939), FRAC_CONST(0.999985) }, + { FRAC_CONST(0.969704), FRAC_CONST(0.969726), FRAC_CONST(0.969811), FRAC_CONST(0.970149), FRAC_CONST(0.971429), FRAC_CONST(0.97561), FRAC_CONST(0.984615), FRAC_CONST(0.993789), FRAC_CONST(0.998165), FRAC_CONST(0.999519), FRAC_CONST(0.999878), FRAC_CONST(0.99997), FRAC_CONST(0.999992) }, + { FRAC_CONST(0.984619), FRAC_CONST(0.98463), FRAC_CONST(0.984674), FRAC_CONST(0.984848), FRAC_CONST(0.985507), FRAC_CONST(0.987654), FRAC_CONST(0.992248), FRAC_CONST(0.996885), FRAC_CONST(0.999082), FRAC_CONST(0.99976), FRAC_CONST(0.999939), FRAC_CONST(0.999985), FRAC_CONST(0.999996) }, + { FRAC_CONST(0.99225), FRAC_CONST(0.992256), FRAC_CONST(0.992278), FRAC_CONST(0.992366), FRAC_CONST(0.992701), FRAC_CONST(0.993789), FRAC_CONST(0.996109), FRAC_CONST(0.99844), FRAC_CONST(0.999541), FRAC_CONST(0.99988), FRAC_CONST(0.99997), FRAC_CONST(0.999992), FRAC_CONST(0.999998) }, + { FRAC_CONST(0.99611), FRAC_CONST(0.996113), FRAC_CONST(0.996124), FRAC_CONST(0.996169), FRAC_CONST(0.996337), FRAC_CONST(0.996885), FRAC_CONST(0.998051), FRAC_CONST(0.999219), FRAC_CONST(0.99977), FRAC_CONST(0.99994), FRAC_CONST(0.999985), FRAC_CONST(0.999996), FRAC_CONST(0.999999) }, + { FRAC_CONST(0.998051), FRAC_CONST(0.998053), FRAC_CONST(0.998058), FRAC_CONST(0.998081), FRAC_CONST(0.998165), FRAC_CONST(0.99844), FRAC_CONST(0.999024), FRAC_CONST(0.99961), FRAC_CONST(0.999885), FRAC_CONST(0.99997), FRAC_CONST(0.999992), FRAC_CONST(0.999998), FRAC_CONST(1) }, + { FRAC_CONST(0.999025), FRAC_CONST(0.999025), FRAC_CONST(0.999028), FRAC_CONST(0.999039), FRAC_CONST(0.999082), FRAC_CONST(0.999219), FRAC_CONST(0.999512), FRAC_CONST(0.999805), FRAC_CONST(0.999943), FRAC_CONST(0.999985), FRAC_CONST(0.999996), FRAC_CONST(0.999999), FRAC_CONST(1) }, + { FRAC_CONST(0.999512), FRAC_CONST(0.999512), FRAC_CONST(0.999514), FRAC_CONST(0.999519), FRAC_CONST(0.999541), FRAC_CONST(0.99961), FRAC_CONST(0.999756), FRAC_CONST(0.999902), FRAC_CONST(0.999971), FRAC_CONST(0.999992), FRAC_CONST(0.999998), FRAC_CONST(1), FRAC_CONST(1) }, + { FRAC_CONST(0.999756), FRAC_CONST(0.999756), FRAC_CONST(0.999757), FRAC_CONST(0.99976), FRAC_CONST(0.99977), FRAC_CONST(0.999805), FRAC_CONST(0.999878), FRAC_CONST(0.999951), FRAC_CONST(0.999986), FRAC_CONST(0.999996), FRAC_CONST(0.999999), FRAC_CONST(1), FRAC_CONST(1) }, + { FRAC_CONST(0.999878), FRAC_CONST(0.999878), FRAC_CONST(0.999878), FRAC_CONST(0.99988), FRAC_CONST(0.999885), FRAC_CONST(0.999902), FRAC_CONST(0.999939), FRAC_CONST(0.999976), FRAC_CONST(0.999993), FRAC_CONST(0.999998), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1) }, + { FRAC_CONST(0.999939), FRAC_CONST(0.999939), FRAC_CONST(0.999939), FRAC_CONST(0.99994), FRAC_CONST(0.999943), FRAC_CONST(0.999951), FRAC_CONST(0.999969), FRAC_CONST(0.999988), FRAC_CONST(0.999996), FRAC_CONST(0.999999), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1) }, + { FRAC_CONST(0.999969), FRAC_CONST(0.99997), FRAC_CONST(0.99997), FRAC_CONST(0.99997), FRAC_CONST(0.999971), FRAC_CONST(0.999976), FRAC_CONST(0.999985), FRAC_CONST(0.999994), FRAC_CONST(0.999998), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1) }, + { FRAC_CONST(0.999985), FRAC_CONST(0.999985), FRAC_CONST(0.999985), FRAC_CONST(0.999985), FRAC_CONST(0.999986), FRAC_CONST(0.999988), FRAC_CONST(0.999992), FRAC_CONST(0.999997), FRAC_CONST(0.999999), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1) }, + { FRAC_CONST(0.999992), FRAC_CONST(0.999992), FRAC_CONST(0.999992), FRAC_CONST(0.999992), FRAC_CONST(0.999993), FRAC_CONST(0.999994), FRAC_CONST(0.999996), FRAC_CONST(0.999998), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1) }, + { FRAC_CONST(0.999996), FRAC_CONST(0.999996), FRAC_CONST(0.999996), FRAC_CONST(0.999996), FRAC_CONST(0.999996), FRAC_CONST(0.999997), FRAC_CONST(0.999998), FRAC_CONST(0.999999), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1) }, + { FRAC_CONST(0.999998), FRAC_CONST(0.999998), FRAC_CONST(0.999998), FRAC_CONST(0.999998), FRAC_CONST(0.999998), FRAC_CONST(0.999998), FRAC_CONST(0.999999), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1) }, + { FRAC_CONST(0.999999), FRAC_CONST(0.999999), FRAC_CONST(0.999999), FRAC_CONST(0.999999), FRAC_CONST(0.999999), FRAC_CONST(0.999999), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1) }, + { FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1) }, + { FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1) }, + { FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1), FRAC_CONST(1) } +}; + +/* calculates 1/(1+Q) */ +/* [0..1] */ +static real_t calc_Q_div(sbr_info *sbr, uint8_t ch, uint8_t m, uint8_t l) +{ + if (sbr->bs_coupling) + { + /* left channel */ + if ((sbr->Q[0][m][l] < 0 || sbr->Q[0][m][l] > 30) || + (sbr->Q[1][m][l] < 0 || sbr->Q[1][m][l] > 24 /* 2*panOffset(1) */)) + { + return 0; + } else { + /* the pan parameter is always even */ + if (ch == 0) + { + return Q_div_tab_left[sbr->Q[0][m][l]][sbr->Q[1][m][l] >> 1]; + } else { + return Q_div_tab_right[sbr->Q[0][m][l]][sbr->Q[1][m][l] >> 1]; + } + } + } else { + /* no coupling */ + if (sbr->Q[ch][m][l] < 0 || sbr->Q[ch][m][l] > 30) + { + return 0; + } else { + return Q_div_tab[sbr->Q[ch][m][l]]; + } + } +} + +/* table for Q_div2 values when no coupling */ +static const real_t Q_div2_tab[31] = { + FRAC_CONST(0.984615), FRAC_CONST(0.969697), + FRAC_CONST(0.941176), FRAC_CONST(0.888889), + FRAC_CONST(0.8), FRAC_CONST(0.666667), + FRAC_CONST(0.5), FRAC_CONST(0.333333), + FRAC_CONST(0.2), FRAC_CONST(0.111111), + FRAC_CONST(0.0588235), FRAC_CONST(0.030303), + FRAC_CONST(0.0153846), FRAC_CONST(0.00775194), + FRAC_CONST(0.00389105), FRAC_CONST(0.00194932), + FRAC_CONST(0.00097561), FRAC_CONST(0.000488043), + FRAC_CONST(0.000244081), FRAC_CONST(0.000122055), + FRAC_CONST(6.10314E-005), FRAC_CONST(3.05166E-005), + FRAC_CONST(1.52586E-005), FRAC_CONST(7.62934E-006), + FRAC_CONST(3.81468E-006), FRAC_CONST(1.90734E-006), + FRAC_CONST(9.53673E-007), FRAC_CONST(4.76837E-007), + FRAC_CONST(2.38419E-007), FRAC_CONST(1.19209E-007), + FRAC_CONST(5.96046E-008) +}; + +static const real_t Q_div2_tab_left[31][13] = { + { FRAC_CONST(0.0302959), FRAC_CONST(0.111015), FRAC_CONST(0.332468), FRAC_CONST(0.663212), FRAC_CONST(0.882759), FRAC_CONST(0.962406), FRAC_CONST(0.984615), FRAC_CONST(0.990329), FRAC_CONST(0.991768), FRAC_CONST(0.992128), FRAC_CONST(0.992218), FRAC_CONST(0.992241), FRAC_CONST(0.992246) }, + { FRAC_CONST(0.0153809), FRAC_CONST(0.0587695), FRAC_CONST(0.199377), FRAC_CONST(0.496124), FRAC_CONST(0.790123), FRAC_CONST(0.927536), FRAC_CONST(0.969697), FRAC_CONST(0.980843), FRAC_CONST(0.98367), FRAC_CONST(0.984379), FRAC_CONST(0.984556), FRAC_CONST(0.984601), FRAC_CONST(0.984612) }, + { FRAC_CONST(0.00775006), FRAC_CONST(0.0302744), FRAC_CONST(0.110727), FRAC_CONST(0.329897), FRAC_CONST(0.653061), FRAC_CONST(0.864865), FRAC_CONST(0.941176), FRAC_CONST(0.962406), FRAC_CONST(0.967864), FRAC_CONST(0.969238), FRAC_CONST(0.969582), FRAC_CONST(0.969668), FRAC_CONST(0.96969) }, + { FRAC_CONST(0.0038901), FRAC_CONST(0.0153698), FRAC_CONST(0.0586081), FRAC_CONST(0.197531), FRAC_CONST(0.484848), FRAC_CONST(0.761905), FRAC_CONST(0.888889), FRAC_CONST(0.927536), FRAC_CONST(0.937729), FRAC_CONST(0.940312), FRAC_CONST(0.94096), FRAC_CONST(0.941122), FRAC_CONST(0.941163) }, + { FRAC_CONST(0.00194884), FRAC_CONST(0.00774443), FRAC_CONST(0.0301887), FRAC_CONST(0.109589), FRAC_CONST(0.32), FRAC_CONST(0.615385), FRAC_CONST(0.8), FRAC_CONST(0.864865), FRAC_CONST(0.882759), FRAC_CONST(0.887348), FRAC_CONST(0.888503), FRAC_CONST(0.888792), FRAC_CONST(0.888865) }, + { FRAC_CONST(0.000975372), FRAC_CONST(0.00388727), FRAC_CONST(0.0153257), FRAC_CONST(0.057971), FRAC_CONST(0.190476), FRAC_CONST(0.444444), FRAC_CONST(0.666667), FRAC_CONST(0.761905), FRAC_CONST(0.790123), FRAC_CONST(0.797508), FRAC_CONST(0.799375), FRAC_CONST(0.799844), FRAC_CONST(0.799961) }, + { FRAC_CONST(0.000487924), FRAC_CONST(0.00194742), FRAC_CONST(0.00772201), FRAC_CONST(0.0298507), FRAC_CONST(0.105263), FRAC_CONST(0.285714), FRAC_CONST(0.5), FRAC_CONST(0.615385), FRAC_CONST(0.653061), FRAC_CONST(0.663212), FRAC_CONST(0.6658), FRAC_CONST(0.66645), FRAC_CONST(0.666612) }, + { FRAC_CONST(0.000244021), FRAC_CONST(0.000974659), FRAC_CONST(0.00387597), FRAC_CONST(0.0151515), FRAC_CONST(0.0555556), FRAC_CONST(0.166667), FRAC_CONST(0.333333), FRAC_CONST(0.444444), FRAC_CONST(0.484848), FRAC_CONST(0.496124), FRAC_CONST(0.499025), FRAC_CONST(0.499756), FRAC_CONST(0.499939) }, + { FRAC_CONST(0.000122026), FRAC_CONST(0.000487567), FRAC_CONST(0.00194175), FRAC_CONST(0.00763359), FRAC_CONST(0.0285714), FRAC_CONST(0.0909091), FRAC_CONST(0.2), FRAC_CONST(0.285714), FRAC_CONST(0.32), FRAC_CONST(0.329897), FRAC_CONST(0.332468), FRAC_CONST(0.333116), FRAC_CONST(0.333279) }, + { FRAC_CONST(6.10165E-005), FRAC_CONST(0.000243843), FRAC_CONST(0.000971817), FRAC_CONST(0.00383142), FRAC_CONST(0.0144928), FRAC_CONST(0.047619), FRAC_CONST(0.111111), FRAC_CONST(0.166667), FRAC_CONST(0.190476), FRAC_CONST(0.197531), FRAC_CONST(0.199377), FRAC_CONST(0.199844), FRAC_CONST(0.199961) }, + { FRAC_CONST(3.05092E-005), FRAC_CONST(0.000121936), FRAC_CONST(0.000486145), FRAC_CONST(0.00191939), FRAC_CONST(0.00729927), FRAC_CONST(0.0243902), FRAC_CONST(0.0588235), FRAC_CONST(0.0909091), FRAC_CONST(0.105263), FRAC_CONST(0.109589), FRAC_CONST(0.110727), FRAC_CONST(0.111015), FRAC_CONST(0.111087) }, + { FRAC_CONST(1.52548E-005), FRAC_CONST(6.09719E-005), FRAC_CONST(0.000243132), FRAC_CONST(0.000960615), FRAC_CONST(0.003663), FRAC_CONST(0.0123457), FRAC_CONST(0.030303), FRAC_CONST(0.047619), FRAC_CONST(0.0555556), FRAC_CONST(0.057971), FRAC_CONST(0.0586081), FRAC_CONST(0.0587695), FRAC_CONST(0.05881) }, + { FRAC_CONST(7.62747E-006), FRAC_CONST(3.04869E-005), FRAC_CONST(0.000121581), FRAC_CONST(0.000480538), FRAC_CONST(0.00183486), FRAC_CONST(0.00621118), FRAC_CONST(0.0153846), FRAC_CONST(0.0243902), FRAC_CONST(0.0285714), FRAC_CONST(0.0298507), FRAC_CONST(0.0301887), FRAC_CONST(0.0302744), FRAC_CONST(0.0302959) }, + { FRAC_CONST(3.81375E-006), FRAC_CONST(1.52437E-005), FRAC_CONST(6.0794E-005), FRAC_CONST(0.000240327), FRAC_CONST(0.000918274), FRAC_CONST(0.00311526), FRAC_CONST(0.00775194), FRAC_CONST(0.0123457), FRAC_CONST(0.0144928), FRAC_CONST(0.0151515), FRAC_CONST(0.0153257), FRAC_CONST(0.0153698), FRAC_CONST(0.0153809) }, + { FRAC_CONST(1.90688E-006), FRAC_CONST(7.62189E-006), FRAC_CONST(3.03979E-005), FRAC_CONST(0.000120178), FRAC_CONST(0.000459348), FRAC_CONST(0.00156006), FRAC_CONST(0.00389105), FRAC_CONST(0.00621118), FRAC_CONST(0.00729927), FRAC_CONST(0.00763359), FRAC_CONST(0.00772201), FRAC_CONST(0.00774443), FRAC_CONST(0.00775006) }, + { FRAC_CONST(9.53441E-007), FRAC_CONST(3.81096E-006), FRAC_CONST(1.51992E-005), FRAC_CONST(6.00925E-005), FRAC_CONST(0.000229727), FRAC_CONST(0.00078064), FRAC_CONST(0.00194932), FRAC_CONST(0.00311526), FRAC_CONST(0.003663), FRAC_CONST(0.00383142), FRAC_CONST(0.00387597), FRAC_CONST(0.00388727), FRAC_CONST(0.0038901) }, + { FRAC_CONST(4.76721E-007), FRAC_CONST(1.90548E-006), FRAC_CONST(7.59965E-006), FRAC_CONST(3.00472E-005), FRAC_CONST(0.000114877), FRAC_CONST(0.000390472), FRAC_CONST(0.00097561), FRAC_CONST(0.00156006), FRAC_CONST(0.00183486), FRAC_CONST(0.00191939), FRAC_CONST(0.00194175), FRAC_CONST(0.00194742), FRAC_CONST(0.00194884) }, + { FRAC_CONST(2.3836E-007), FRAC_CONST(9.52743E-007), FRAC_CONST(3.79984E-006), FRAC_CONST(1.50238E-005), FRAC_CONST(5.74416E-005), FRAC_CONST(0.000195274), FRAC_CONST(0.000488043), FRAC_CONST(0.00078064), FRAC_CONST(0.000918274), FRAC_CONST(0.000960615), FRAC_CONST(0.000971817), FRAC_CONST(0.000974659), FRAC_CONST(0.000975372) }, + { FRAC_CONST(1.1918E-007), FRAC_CONST(4.76372E-007), FRAC_CONST(1.89992E-006), FRAC_CONST(7.51196E-006), FRAC_CONST(2.87216E-005), FRAC_CONST(9.76467E-005), FRAC_CONST(0.000244081), FRAC_CONST(0.000390472), FRAC_CONST(0.000459348), FRAC_CONST(0.000480538), FRAC_CONST(0.000486145), FRAC_CONST(0.000487567), FRAC_CONST(0.000487924) }, + { FRAC_CONST(5.95901E-008), FRAC_CONST(2.38186E-007), FRAC_CONST(9.49963E-007), FRAC_CONST(3.756E-006), FRAC_CONST(1.4361E-005), FRAC_CONST(4.88257E-005), FRAC_CONST(0.000122055), FRAC_CONST(0.000195274), FRAC_CONST(0.000229727), FRAC_CONST(0.000240327), FRAC_CONST(0.000243132), FRAC_CONST(0.000243843), FRAC_CONST(0.000244021) }, + { FRAC_CONST(2.9795E-008), FRAC_CONST(1.19093E-007), FRAC_CONST(4.74982E-007), FRAC_CONST(1.878E-006), FRAC_CONST(7.18056E-006), FRAC_CONST(2.44135E-005), FRAC_CONST(6.10314E-005), FRAC_CONST(9.76467E-005), FRAC_CONST(0.000114877), FRAC_CONST(0.000120178), FRAC_CONST(0.000121581), FRAC_CONST(0.000121936), FRAC_CONST(0.000122026) }, + { FRAC_CONST(1.48975E-008), FRAC_CONST(5.95465E-008), FRAC_CONST(2.37491E-007), FRAC_CONST(9.39002E-007), FRAC_CONST(3.59029E-006), FRAC_CONST(1.22069E-005), FRAC_CONST(3.05166E-005), FRAC_CONST(4.88257E-005), FRAC_CONST(5.74416E-005), FRAC_CONST(6.00925E-005), FRAC_CONST(6.0794E-005), FRAC_CONST(6.09719E-005), FRAC_CONST(6.10165E-005) }, + { FRAC_CONST(7.44876E-009), FRAC_CONST(2.97732E-008), FRAC_CONST(1.18745E-007), FRAC_CONST(4.69501E-007), FRAC_CONST(1.79515E-006), FRAC_CONST(6.10348E-006), FRAC_CONST(1.52586E-005), FRAC_CONST(2.44135E-005), FRAC_CONST(2.87216E-005), FRAC_CONST(3.00472E-005), FRAC_CONST(3.03979E-005), FRAC_CONST(3.04869E-005), FRAC_CONST(3.05092E-005) }, + { FRAC_CONST(3.72438E-009), FRAC_CONST(1.48866E-008), FRAC_CONST(5.93727E-008), FRAC_CONST(2.34751E-007), FRAC_CONST(8.97575E-007), FRAC_CONST(3.05175E-006), FRAC_CONST(7.62934E-006), FRAC_CONST(1.22069E-005), FRAC_CONST(1.4361E-005), FRAC_CONST(1.50238E-005), FRAC_CONST(1.51992E-005), FRAC_CONST(1.52437E-005), FRAC_CONST(1.52548E-005) }, + { FRAC_CONST(1.86219E-009), FRAC_CONST(7.44331E-009), FRAC_CONST(2.96864E-008), FRAC_CONST(1.17375E-007), FRAC_CONST(4.48788E-007), FRAC_CONST(1.52588E-006), FRAC_CONST(3.81468E-006), FRAC_CONST(6.10348E-006), FRAC_CONST(7.18056E-006), FRAC_CONST(7.51196E-006), FRAC_CONST(7.59965E-006), FRAC_CONST(7.62189E-006), FRAC_CONST(7.62747E-006) }, + { FRAC_CONST(9.31095E-010), FRAC_CONST(3.72166E-009), FRAC_CONST(1.48432E-008), FRAC_CONST(5.86876E-008), FRAC_CONST(2.24394E-007), FRAC_CONST(7.62939E-007), FRAC_CONST(1.90734E-006), FRAC_CONST(3.05175E-006), FRAC_CONST(3.59029E-006), FRAC_CONST(3.756E-006), FRAC_CONST(3.79984E-006), FRAC_CONST(3.81096E-006), FRAC_CONST(3.81375E-006) }, + { FRAC_CONST(4.65548E-010), FRAC_CONST(1.86083E-009), FRAC_CONST(7.42159E-009), FRAC_CONST(2.93438E-008), FRAC_CONST(1.12197E-007), FRAC_CONST(3.8147E-007), FRAC_CONST(9.53673E-007), FRAC_CONST(1.52588E-006), FRAC_CONST(1.79515E-006), FRAC_CONST(1.878E-006), FRAC_CONST(1.89992E-006), FRAC_CONST(1.90548E-006), FRAC_CONST(1.90688E-006) }, + { FRAC_CONST(2.32774E-010), FRAC_CONST(9.30414E-010), FRAC_CONST(3.71079E-009), FRAC_CONST(1.46719E-008), FRAC_CONST(5.60985E-008), FRAC_CONST(1.90735E-007), FRAC_CONST(4.76837E-007), FRAC_CONST(7.62939E-007), FRAC_CONST(8.97575E-007), FRAC_CONST(9.39002E-007), FRAC_CONST(9.49963E-007), FRAC_CONST(9.52743E-007), FRAC_CONST(9.53441E-007) }, + { FRAC_CONST(1.16387E-010), FRAC_CONST(4.65207E-010), FRAC_CONST(1.8554E-009), FRAC_CONST(7.33596E-009), FRAC_CONST(2.80492E-008), FRAC_CONST(9.53674E-008), FRAC_CONST(2.38419E-007), FRAC_CONST(3.8147E-007), FRAC_CONST(4.48788E-007), FRAC_CONST(4.69501E-007), FRAC_CONST(4.74982E-007), FRAC_CONST(4.76372E-007), FRAC_CONST(4.76721E-007) }, + { FRAC_CONST(5.81935E-011), FRAC_CONST(2.32603E-010), FRAC_CONST(9.27699E-010), FRAC_CONST(3.66798E-009), FRAC_CONST(1.40246E-008), FRAC_CONST(4.76837E-008), FRAC_CONST(1.19209E-007), FRAC_CONST(1.90735E-007), FRAC_CONST(2.24394E-007), FRAC_CONST(2.34751E-007), FRAC_CONST(2.37491E-007), FRAC_CONST(2.38186E-007), FRAC_CONST(2.3836E-007) }, + { FRAC_CONST(2.90967E-011), FRAC_CONST(1.16302E-010), FRAC_CONST(4.63849E-010), FRAC_CONST(1.83399E-009), FRAC_CONST(7.01231E-009), FRAC_CONST(2.38419E-008), FRAC_CONST(5.96046E-008), FRAC_CONST(9.53674E-008), FRAC_CONST(1.12197E-007), FRAC_CONST(1.17375E-007), FRAC_CONST(1.18745E-007), FRAC_CONST(1.19093E-007), FRAC_CONST(1.1918E-007) } +}; + +static const real_t Q_div2_tab_right[31][13] = { + { FRAC_CONST(0.992246), FRAC_CONST(0.992241), FRAC_CONST(0.992218), FRAC_CONST(0.992128), FRAC_CONST(0.991768), FRAC_CONST(0.990329), FRAC_CONST(0.984615), FRAC_CONST(0.962406), FRAC_CONST(0.882759), FRAC_CONST(0.663212), FRAC_CONST(0.332468), FRAC_CONST(0.111015), FRAC_CONST(0.0302959) }, + { FRAC_CONST(0.984612), FRAC_CONST(0.984601), FRAC_CONST(0.984556), FRAC_CONST(0.984379), FRAC_CONST(0.98367), FRAC_CONST(0.980843), FRAC_CONST(0.969697), FRAC_CONST(0.927536), FRAC_CONST(0.790123), FRAC_CONST(0.496124), FRAC_CONST(0.199377), FRAC_CONST(0.0587695), FRAC_CONST(0.0153809) }, + { FRAC_CONST(0.96969), FRAC_CONST(0.969668), FRAC_CONST(0.969582), FRAC_CONST(0.969238), FRAC_CONST(0.967864), FRAC_CONST(0.962406), FRAC_CONST(0.941176), FRAC_CONST(0.864865), FRAC_CONST(0.653061), FRAC_CONST(0.329897), FRAC_CONST(0.110727), FRAC_CONST(0.0302744), FRAC_CONST(0.00775006) }, + { FRAC_CONST(0.941163), FRAC_CONST(0.941122), FRAC_CONST(0.94096), FRAC_CONST(0.940312), FRAC_CONST(0.937729), FRAC_CONST(0.927536), FRAC_CONST(0.888889), FRAC_CONST(0.761905), FRAC_CONST(0.484848), FRAC_CONST(0.197531), FRAC_CONST(0.0586081), FRAC_CONST(0.0153698), FRAC_CONST(0.0038901) }, + { FRAC_CONST(0.888865), FRAC_CONST(0.888792), FRAC_CONST(0.888503), FRAC_CONST(0.887348), FRAC_CONST(0.882759), FRAC_CONST(0.864865), FRAC_CONST(0.8), FRAC_CONST(0.615385), FRAC_CONST(0.32), FRAC_CONST(0.109589), FRAC_CONST(0.0301887), FRAC_CONST(0.00774443), FRAC_CONST(0.00194884) }, + { FRAC_CONST(0.799961), FRAC_CONST(0.799844), FRAC_CONST(0.799375), FRAC_CONST(0.797508), FRAC_CONST(0.790123), FRAC_CONST(0.761905), FRAC_CONST(0.666667), FRAC_CONST(0.444444), FRAC_CONST(0.190476), FRAC_CONST(0.057971), FRAC_CONST(0.0153257), FRAC_CONST(0.00388727), FRAC_CONST(0.000975372) }, + { FRAC_CONST(0.666612), FRAC_CONST(0.66645), FRAC_CONST(0.6658), FRAC_CONST(0.663212), FRAC_CONST(0.653061), FRAC_CONST(0.615385), FRAC_CONST(0.5), FRAC_CONST(0.285714), FRAC_CONST(0.105263), FRAC_CONST(0.0298507), FRAC_CONST(0.00772201), FRAC_CONST(0.00194742), FRAC_CONST(0.000487924) }, + { FRAC_CONST(0.499939), FRAC_CONST(0.499756), FRAC_CONST(0.499025), FRAC_CONST(0.496124), FRAC_CONST(0.484848), FRAC_CONST(0.444444), FRAC_CONST(0.333333), FRAC_CONST(0.166667), FRAC_CONST(0.0555556), FRAC_CONST(0.0151515), FRAC_CONST(0.00387597), FRAC_CONST(0.000974659), FRAC_CONST(0.000244021) }, + { FRAC_CONST(0.333279), FRAC_CONST(0.333116), FRAC_CONST(0.332468), FRAC_CONST(0.329897), FRAC_CONST(0.32), FRAC_CONST(0.285714), FRAC_CONST(0.2), FRAC_CONST(0.0909091), FRAC_CONST(0.0285714), FRAC_CONST(0.00763359), FRAC_CONST(0.00194175), FRAC_CONST(0.000487567), FRAC_CONST(0.000122026) }, + { FRAC_CONST(0.199961), FRAC_CONST(0.199844), FRAC_CONST(0.199377), FRAC_CONST(0.197531), FRAC_CONST(0.190476), FRAC_CONST(0.166667), FRAC_CONST(0.111111), FRAC_CONST(0.047619), FRAC_CONST(0.0144928), FRAC_CONST(0.00383142), FRAC_CONST(0.000971817), FRAC_CONST(0.000243843), FRAC_CONST(6.10165E-005) }, + { FRAC_CONST(0.111087), FRAC_CONST(0.111015), FRAC_CONST(0.110727), FRAC_CONST(0.109589), FRAC_CONST(0.105263), FRAC_CONST(0.0909091), FRAC_CONST(0.0588235), FRAC_CONST(0.0243902), FRAC_CONST(0.00729927), FRAC_CONST(0.00191939), FRAC_CONST(0.000486145), FRAC_CONST(0.000121936), FRAC_CONST(3.05092E-005) }, + { FRAC_CONST(0.05881), FRAC_CONST(0.0587695), FRAC_CONST(0.0586081), FRAC_CONST(0.057971), FRAC_CONST(0.0555556), FRAC_CONST(0.047619), FRAC_CONST(0.030303), FRAC_CONST(0.0123457), FRAC_CONST(0.003663), FRAC_CONST(0.000960615), FRAC_CONST(0.000243132), FRAC_CONST(6.09719E-005), FRAC_CONST(1.52548E-005) }, + { FRAC_CONST(0.0302959), FRAC_CONST(0.0302744), FRAC_CONST(0.0301887), FRAC_CONST(0.0298507), FRAC_CONST(0.0285714), FRAC_CONST(0.0243902), FRAC_CONST(0.0153846), FRAC_CONST(0.00621118), FRAC_CONST(0.00183486), FRAC_CONST(0.000480538), FRAC_CONST(0.000121581), FRAC_CONST(3.04869E-005), FRAC_CONST(7.62747E-006) }, + { FRAC_CONST(0.0153809), FRAC_CONST(0.0153698), FRAC_CONST(0.0153257), FRAC_CONST(0.0151515), FRAC_CONST(0.0144928), FRAC_CONST(0.0123457), FRAC_CONST(0.00775194), FRAC_CONST(0.00311526), FRAC_CONST(0.000918274), FRAC_CONST(0.000240327), FRAC_CONST(6.0794E-005), FRAC_CONST(1.52437E-005), FRAC_CONST(3.81375E-006) }, + { FRAC_CONST(0.00775006), FRAC_CONST(0.00774443), FRAC_CONST(0.00772201), FRAC_CONST(0.00763359), FRAC_CONST(0.00729927), FRAC_CONST(0.00621118), FRAC_CONST(0.00389105), FRAC_CONST(0.00156006), FRAC_CONST(0.000459348), FRAC_CONST(0.000120178), FRAC_CONST(3.03979E-005), FRAC_CONST(7.62189E-006), FRAC_CONST(1.90688E-006) }, + { FRAC_CONST(0.0038901), FRAC_CONST(0.00388727), FRAC_CONST(0.00387597), FRAC_CONST(0.00383142), FRAC_CONST(0.003663), FRAC_CONST(0.00311526), FRAC_CONST(0.00194932), FRAC_CONST(0.00078064), FRAC_CONST(0.000229727), FRAC_CONST(6.00925E-005), FRAC_CONST(1.51992E-005), FRAC_CONST(3.81096E-006), FRAC_CONST(9.53441E-007) }, + { FRAC_CONST(0.00194884), FRAC_CONST(0.00194742), FRAC_CONST(0.00194175), FRAC_CONST(0.00191939), FRAC_CONST(0.00183486), FRAC_CONST(0.00156006), FRAC_CONST(0.00097561), FRAC_CONST(0.000390472), FRAC_CONST(0.000114877), FRAC_CONST(3.00472E-005), FRAC_CONST(7.59965E-006), FRAC_CONST(1.90548E-006), FRAC_CONST(4.76721E-007) }, + { FRAC_CONST(0.000975372), FRAC_CONST(0.000974659), FRAC_CONST(0.000971817), FRAC_CONST(0.000960615), FRAC_CONST(0.000918274), FRAC_CONST(0.00078064), FRAC_CONST(0.000488043), FRAC_CONST(0.000195274), FRAC_CONST(5.74416E-005), FRAC_CONST(1.50238E-005), FRAC_CONST(3.79984E-006), FRAC_CONST(9.52743E-007), FRAC_CONST(2.3836E-007) }, + { FRAC_CONST(0.000487924), FRAC_CONST(0.000487567), FRAC_CONST(0.000486145), FRAC_CONST(0.000480538), FRAC_CONST(0.000459348), FRAC_CONST(0.000390472), FRAC_CONST(0.000244081), FRAC_CONST(9.76467E-005), FRAC_CONST(2.87216E-005), FRAC_CONST(7.51196E-006), FRAC_CONST(1.89992E-006), FRAC_CONST(4.76372E-007), FRAC_CONST(1.1918E-007) }, + { FRAC_CONST(0.000244021), FRAC_CONST(0.000243843), FRAC_CONST(0.000243132), FRAC_CONST(0.000240327), FRAC_CONST(0.000229727), FRAC_CONST(0.000195274), FRAC_CONST(0.000122055), FRAC_CONST(4.88257E-005), FRAC_CONST(1.4361E-005), FRAC_CONST(3.756E-006), FRAC_CONST(9.49963E-007), FRAC_CONST(2.38186E-007), FRAC_CONST(5.95901E-008) }, + { FRAC_CONST(0.000122026), FRAC_CONST(0.000121936), FRAC_CONST(0.000121581), FRAC_CONST(0.000120178), FRAC_CONST(0.000114877), FRAC_CONST(9.76467E-005), FRAC_CONST(6.10314E-005), FRAC_CONST(2.44135E-005), FRAC_CONST(7.18056E-006), FRAC_CONST(1.878E-006), FRAC_CONST(4.74982E-007), FRAC_CONST(1.19093E-007), FRAC_CONST(2.9795E-008) }, + { FRAC_CONST(6.10165E-005), FRAC_CONST(6.09719E-005), FRAC_CONST(6.0794E-005), FRAC_CONST(6.00925E-005), FRAC_CONST(5.74416E-005), FRAC_CONST(4.88257E-005), FRAC_CONST(3.05166E-005), FRAC_CONST(1.22069E-005), FRAC_CONST(3.59029E-006), FRAC_CONST(9.39002E-007), FRAC_CONST(2.37491E-007), FRAC_CONST(5.95465E-008), FRAC_CONST(1.48975E-008) }, + { FRAC_CONST(3.05092E-005), FRAC_CONST(3.04869E-005), FRAC_CONST(3.03979E-005), FRAC_CONST(3.00472E-005), FRAC_CONST(2.87216E-005), FRAC_CONST(2.44135E-005), FRAC_CONST(1.52586E-005), FRAC_CONST(6.10348E-006), FRAC_CONST(1.79515E-006), FRAC_CONST(4.69501E-007), FRAC_CONST(1.18745E-007), FRAC_CONST(2.97732E-008), FRAC_CONST(7.44876E-009) }, + { FRAC_CONST(1.52548E-005), FRAC_CONST(1.52437E-005), FRAC_CONST(1.51992E-005), FRAC_CONST(1.50238E-005), FRAC_CONST(1.4361E-005), FRAC_CONST(1.22069E-005), FRAC_CONST(7.62934E-006), FRAC_CONST(3.05175E-006), FRAC_CONST(8.97575E-007), FRAC_CONST(2.34751E-007), FRAC_CONST(5.93727E-008), FRAC_CONST(1.48866E-008), FRAC_CONST(3.72438E-009) }, + { FRAC_CONST(7.62747E-006), FRAC_CONST(7.62189E-006), FRAC_CONST(7.59965E-006), FRAC_CONST(7.51196E-006), FRAC_CONST(7.18056E-006), FRAC_CONST(6.10348E-006), FRAC_CONST(3.81468E-006), FRAC_CONST(1.52588E-006), FRAC_CONST(4.48788E-007), FRAC_CONST(1.17375E-007), FRAC_CONST(2.96864E-008), FRAC_CONST(7.44331E-009), FRAC_CONST(1.86219E-009) }, + { FRAC_CONST(3.81375E-006), FRAC_CONST(3.81096E-006), FRAC_CONST(3.79984E-006), FRAC_CONST(3.756E-006), FRAC_CONST(3.59029E-006), FRAC_CONST(3.05175E-006), FRAC_CONST(1.90734E-006), FRAC_CONST(7.62939E-007), FRAC_CONST(2.24394E-007), FRAC_CONST(5.86876E-008), FRAC_CONST(1.48432E-008), FRAC_CONST(3.72166E-009), FRAC_CONST(9.31095E-010) }, + { FRAC_CONST(1.90688E-006), FRAC_CONST(1.90548E-006), FRAC_CONST(1.89992E-006), FRAC_CONST(1.878E-006), FRAC_CONST(1.79515E-006), FRAC_CONST(1.52588E-006), FRAC_CONST(9.53673E-007), FRAC_CONST(3.8147E-007), FRAC_CONST(1.12197E-007), FRAC_CONST(2.93438E-008), FRAC_CONST(7.42159E-009), FRAC_CONST(1.86083E-009), FRAC_CONST(4.65548E-010) }, + { FRAC_CONST(9.53441E-007), FRAC_CONST(9.52743E-007), FRAC_CONST(9.49963E-007), FRAC_CONST(9.39002E-007), FRAC_CONST(8.97575E-007), FRAC_CONST(7.62939E-007), FRAC_CONST(4.76837E-007), FRAC_CONST(1.90735E-007), FRAC_CONST(5.60985E-008), FRAC_CONST(1.46719E-008), FRAC_CONST(3.71079E-009), FRAC_CONST(9.30414E-010), FRAC_CONST(2.32774E-010) }, + { FRAC_CONST(4.76721E-007), FRAC_CONST(4.76372E-007), FRAC_CONST(4.74982E-007), FRAC_CONST(4.69501E-007), FRAC_CONST(4.48788E-007), FRAC_CONST(3.8147E-007), FRAC_CONST(2.38419E-007), FRAC_CONST(9.53674E-008), FRAC_CONST(2.80492E-008), FRAC_CONST(7.33596E-009), FRAC_CONST(1.8554E-009), FRAC_CONST(4.65207E-010), FRAC_CONST(1.16387E-010) }, + { FRAC_CONST(2.3836E-007), FRAC_CONST(2.38186E-007), FRAC_CONST(2.37491E-007), FRAC_CONST(2.34751E-007), FRAC_CONST(2.24394E-007), FRAC_CONST(1.90735E-007), FRAC_CONST(1.19209E-007), FRAC_CONST(4.76837E-008), FRAC_CONST(1.40246E-008), FRAC_CONST(3.66798E-009), FRAC_CONST(9.27699E-010), FRAC_CONST(2.32603E-010), FRAC_CONST(5.81935E-011) }, + { FRAC_CONST(1.1918E-007), FRAC_CONST(1.19093E-007), FRAC_CONST(1.18745E-007), FRAC_CONST(1.17375E-007), FRAC_CONST(1.12197E-007), FRAC_CONST(9.53674E-008), FRAC_CONST(5.96046E-008), FRAC_CONST(2.38419E-008), FRAC_CONST(7.01231E-009), FRAC_CONST(1.83399E-009), FRAC_CONST(4.63849E-010), FRAC_CONST(1.16302E-010), FRAC_CONST(2.90967E-011) } +}; + +/* calculates Q/(1+Q) */ +/* [0..1] */ +static real_t calc_Q_div2(sbr_info *sbr, uint8_t ch, uint8_t m, uint8_t l) +{ + if (sbr->bs_coupling) + { + if ((sbr->Q[0][m][l] < 0 || sbr->Q[0][m][l] > 30) || + (sbr->Q[1][m][l] < 0 || sbr->Q[1][m][l] > 24 /* 2*panOffset(1) */)) + { + return 0; + } else { + /* the pan parameter is always even */ + if (ch == 0) + { + return Q_div2_tab_left[sbr->Q[0][m][l]][sbr->Q[1][m][l] >> 1]; + } else { + return Q_div2_tab_right[sbr->Q[0][m][l]][sbr->Q[1][m][l] >> 1]; + } + } + } else { + /* no coupling */ + if (sbr->Q[ch][m][l] < 0 || sbr->Q[ch][m][l] > 30) + { + return 0; + } else { + return Q_div2_tab[sbr->Q[ch][m][l]]; + } + } +} + +static const real_t E_deq_tab[64] = { + 64.0f, 128.0f, 256.0f, 512.0f, 1024.0f, 2048.0f, 4096.0f, 8192.0f, + 16384.0f, 32768.0f, 65536.0f, 131072.0f, 262144.0f, 524288.0f, 1.04858E+006f, 2.09715E+006f, + 4.1943E+006f, 8.38861E+006f, 1.67772E+007f, 3.35544E+007f, 6.71089E+007f, 1.34218E+008f, 2.68435E+008f, 5.36871E+008f, + 1.07374E+009f, 2.14748E+009f, 4.29497E+009f, 8.58993E+009f, 1.71799E+010f, 3.43597E+010f, 6.87195E+010f, 1.37439E+011f, + 2.74878E+011f, 5.49756E+011f, 1.09951E+012f, 2.19902E+012f, 4.39805E+012f, 8.79609E+012f, 1.75922E+013f, 3.51844E+013f, + 7.03687E+013f, 1.40737E+014f, 2.81475E+014f, 5.6295E+014f, 1.1259E+015f, 2.2518E+015f, 4.5036E+015f, 9.0072E+015f, + 1.80144E+016f, 3.60288E+016f, 7.20576E+016f, 1.44115E+017f, 2.8823E+017f, 5.76461E+017f, 1.15292E+018f, 2.30584E+018f, + 4.61169E+018f, 9.22337E+018f, 1.84467E+019f, 3.68935E+019f, 7.3787E+019f, 1.47574E+020f, 2.95148E+020f, 5.90296E+020f +}; + +void envelope_noise_dequantisation(sbr_info *sbr, uint8_t ch) +{ + if (sbr->bs_coupling == 0) + { + int16_t exp; + uint8_t l, k; + uint8_t amp = (sbr->amp_res[ch]) ? 0 : 1; + + for (l = 0; l < sbr->L_E[ch]; l++) + { + for (k = 0; k < sbr->n[sbr->f[ch][l]]; k++) + { + /* +6 for the *64 and -10 for the /32 in the synthesis QMF (fixed) + * since this is a energy value: (x/32)^2 = (x^2)/1024 + */ + /* exp = (sbr->E[ch][k][l] >> amp) + 6; */ + exp = (sbr->E[ch][k][l] >> amp); + + if ((exp < 0) || (exp >= 64)) + { + sbr->E_orig[ch][k][l] = 0; + } else { + sbr->E_orig[ch][k][l] = E_deq_tab[exp]; + + /* save half the table size at the cost of 1 multiply */ + if (amp && (sbr->E[ch][k][l] & 1)) + { + sbr->E_orig[ch][k][l] = MUL_C(sbr->E_orig[ch][k][l], COEF_CONST(1.414213562)); + } + } + } + } + + for (l = 0; l < sbr->L_Q[ch]; l++) + { + for (k = 0; k < sbr->N_Q; k++) + { + sbr->Q_div[ch][k][l] = calc_Q_div(sbr, ch, k, l); + sbr->Q_div2[ch][k][l] = calc_Q_div2(sbr, ch, k, l); + } + } + } +} + +static const real_t E_pan_tab[25] = { + FRAC_CONST(0.000244081), FRAC_CONST(0.000488043), + FRAC_CONST(0.00097561), FRAC_CONST(0.00194932), + FRAC_CONST(0.00389105), FRAC_CONST(0.00775194), + FRAC_CONST(0.0153846), FRAC_CONST(0.030303), + FRAC_CONST(0.0588235), FRAC_CONST(0.111111), + FRAC_CONST(0.2), FRAC_CONST(0.333333), + FRAC_CONST(0.5), FRAC_CONST(0.666667), + FRAC_CONST(0.8), FRAC_CONST(0.888889), + FRAC_CONST(0.941176), FRAC_CONST(0.969697), + FRAC_CONST(0.984615), FRAC_CONST(0.992248), + FRAC_CONST(0.996109), FRAC_CONST(0.998051), + FRAC_CONST(0.999024), FRAC_CONST(0.999512), + FRAC_CONST(0.999756) +}; + +void unmap_envelope_noise(sbr_info *sbr) +{ + real_t tmp; + int16_t exp0, exp1; + uint8_t l, k; + uint8_t amp0 = (sbr->amp_res[0]) ? 0 : 1; + uint8_t amp1 = (sbr->amp_res[1]) ? 0 : 1; + + for (l = 0; l < sbr->L_E[0]; l++) + { + for (k = 0; k < sbr->n[sbr->f[0][l]]; k++) + { + /* +6: * 64 ; +1: * 2 ; */ + exp0 = (sbr->E[0][k][l] >> amp0) + 1; + + /* UN_MAP removed: (x / 4096) same as (x >> 12) */ + /* E[1] is always even so no need for compensating the divide by 2 with + * an extra multiplication + */ + /* exp1 = (sbr->E[1][k][l] >> amp1) - 12; */ + exp1 = (sbr->E[1][k][l] >> amp1); + + if ((exp0 < 0) || (exp0 >= 64) || + (exp1 < 0) || (exp1 > 24)) + { + sbr->E_orig[1][k][l] = 0; + sbr->E_orig[0][k][l] = 0; + } else { + tmp = E_deq_tab[exp0]; + if (amp0 && (sbr->E[0][k][l] & 1)) + { + tmp = MUL_C(tmp, COEF_CONST(1.414213562)); + } + + /* panning */ + sbr->E_orig[0][k][l] = MUL_F(tmp, E_pan_tab[exp1]); + sbr->E_orig[1][k][l] = MUL_F(tmp, E_pan_tab[24 - exp1]); + } + } + } + + for (l = 0; l < sbr->L_Q[0]; l++) + { + for (k = 0; k < sbr->N_Q; k++) + { + sbr->Q_div[0][k][l] = calc_Q_div(sbr, 0, k, l); + sbr->Q_div[1][k][l] = calc_Q_div(sbr, 1, k, l); + sbr->Q_div2[0][k][l] = calc_Q_div2(sbr, 0, k, l); + sbr->Q_div2[1][k][l] = calc_Q_div2(sbr, 1, k, l); + } + } +} + +#endif + +#endif diff --git a/lib/rbcodec/codecs/libfaad/sbr_e_nf.h b/lib/rbcodec/codecs/libfaad/sbr_e_nf.h new file mode 100644 index 0000000000..6c8b30f06d --- /dev/null +++ b/lib/rbcodec/codecs/libfaad/sbr_e_nf.h @@ -0,0 +1,47 @@ +/* +** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding +** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +** +** Any non-GPL usage of this software or parts of this software is strictly +** forbidden. +** +** Commercial non-GPL licensing of this software is possible. +** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** +** $Id$ +**/ + +#ifndef __SBR_E_NF_H__ +#define __SBR_E_NF_H__ + +#ifdef __cplusplus +extern "C" { +#endif + + +void extract_envelope_data(sbr_info *sbr, uint8_t ch); +void extract_noise_floor_data(sbr_info *sbr, uint8_t ch); +#ifndef FIXED_POINT +void envelope_noise_dequantisation(sbr_info *sbr, uint8_t ch); +void unmap_envelope_noise(sbr_info *sbr); +#endif + +#ifdef __cplusplus +} +#endif +#endif + diff --git a/lib/rbcodec/codecs/libfaad/sbr_fbt.c b/lib/rbcodec/codecs/libfaad/sbr_fbt.c new file mode 100644 index 0000000000..c685c710d5 --- /dev/null +++ b/lib/rbcodec/codecs/libfaad/sbr_fbt.c @@ -0,0 +1,762 @@ +/* +** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding +** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +** +** Any non-GPL usage of this software or parts of this software is strictly +** forbidden. +** +** Commercial non-GPL licensing of this software is possible. +** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** +** $Id$ +**/ + +/* Calculate frequency band tables */ + +#include "common.h" +#include "structs.h" + +#ifdef SBR_DEC + +#include + +#include "sbr_syntax.h" +#include "sbr_fbt.h" + +/* static function declarations */ +static int32_t find_bands(uint8_t warp, uint8_t bands, uint8_t a0, uint8_t a1); + + +/* calculate the start QMF channel for the master frequency band table */ +/* parameter is also called k0 */ +uint8_t qmf_start_channel(uint8_t bs_start_freq, uint8_t bs_samplerate_mode, + uint32_t sample_rate) +{ + static const uint8_t startMinTable[12] = { 7, 7, 10, 11, 12, 16, 16, + 17, 24, 32, 35, 48 }; + static const uint8_t offsetIndexTable[12] = { 5, 5, 4, 4, 4, 3, 2, 1, 0, + 6, 6, 6 }; + static const int8_t offset[7][16] = { + { -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7 }, + { -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 13 }, + { -5, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 13, 16 }, + { -6, -4, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 13, 16 }, + { -4, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 13, 16, 20 }, + { -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 13, 16, 20, 24 }, + { 0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 13, 16, 20, 24, 28, 33 } + }; + uint8_t startMin = startMinTable[get_sr_index(sample_rate)]; + uint8_t offsetIndex = offsetIndexTable[get_sr_index(sample_rate)]; + +#if 0 /* replaced with table (startMinTable) */ + if (sample_rate >= 64000) + { + startMin = (uint8_t)((5000.*128.)/(float)sample_rate + 0.5); + } else if (sample_rate < 32000) { + startMin = (uint8_t)((3000.*128.)/(float)sample_rate + 0.5); + } else { + startMin = (uint8_t)((4000.*128.)/(float)sample_rate + 0.5); + } +#endif + + if (bs_samplerate_mode) + { + return startMin + offset[offsetIndex][bs_start_freq]; + +#if 0 /* replaced by offsetIndexTable */ + switch (sample_rate) + { + case 16000: + return startMin + offset[0][bs_start_freq]; + case 22050: + return startMin + offset[1][bs_start_freq]; + case 24000: + return startMin + offset[2][bs_start_freq]; + case 32000: + return startMin + offset[3][bs_start_freq]; + default: + if (sample_rate > 64000) + { + return startMin + offset[5][bs_start_freq]; + } else { /* 44100 <= sample_rate <= 64000 */ + return startMin + offset[4][bs_start_freq]; + } + } +#endif + } else { + return startMin + offset[6][bs_start_freq]; + } +} + +static int longcmp(const void *a, const void *b) +{ + return ((int)(*(int32_t*)a - *(int32_t*)b)); +} + +/* calculate the stop QMF channel for the master frequency band table */ +/* parameter is also called k2 */ +uint8_t qmf_stop_channel(uint8_t bs_stop_freq, uint32_t sample_rate, + uint8_t k0) +{ + if (bs_stop_freq == 15) + { + return min(64, k0 * 3); + } else if (bs_stop_freq == 14) { + return min(64, k0 * 2); + } else { + static const uint8_t stopMinTable[12] = { 13, 15, 20, 21, 23, + 32, 32, 35, 48, 64, 70, 96 }; + static const int8_t offset[12][14] = { + { 0, 2, 4, 6, 8, 11, 14, 18, 22, 26, 31, 37, 44, 51 }, + { 0, 2, 4, 6, 8, 11, 14, 18, 22, 26, 31, 36, 42, 49 }, + { 0, 2, 4, 6, 8, 11, 14, 17, 21, 25, 29, 34, 39, 44 }, + { 0, 2, 4, 6, 8, 11, 14, 17, 20, 24, 28, 33, 38, 43 }, + { 0, 2, 4, 6, 8, 11, 14, 17, 20, 24, 28, 32, 36, 41 }, + { 0, 2, 4, 6, 8, 10, 12, 14, 17, 20, 23, 26, 29, 32 }, + { 0, 2, 4, 6, 8, 10, 12, 14, 17, 20, 23, 26, 29, 32 }, + { 0, 1, 3, 5, 7, 9, 11, 13, 15, 17, 20, 23, 26, 29 }, + { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 16 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, -1, -2, -3, -4, -5, -6, -6, -6, -6, -6, -6, -6, -6 }, + { 0, -3, -6, -9, -12, -15, -18, -20, -22, -24, -26, -28, -30, -32 } + }; +#if 0 + uint8_t i; + int32_t stopDk[13], stopDk_t[14], k2; +#endif + uint8_t stopMin = stopMinTable[get_sr_index(sample_rate)]; + +#if 0 /* replaced by table lookup */ + if (sample_rate >= 64000) + { + stopMin = (uint8_t)((10000.*128.)/(float)sample_rate + 0.5); + } else if (sample_rate < 32000) { + stopMin = (uint8_t)((6000.*128.)/(float)sample_rate + 0.5); + } else { + stopMin = (uint8_t)((8000.*128.)/(float)sample_rate + 0.5); + } +#endif + +#if 0 /* replaced by table lookup */ + /* diverging power series */ + for (i = 0; i <= 13; i++) + { + stopDk_t[i] = (int32_t)(stopMin*pow(64.0/stopMin, i/13.0) + 0.5); + } + for (i = 0; i < 13; i++) + { + stopDk[i] = stopDk_t[i+1] - stopDk_t[i]; + } + + /* needed? */ + qsort(stopDk, 13, sizeof(stopDk[0]), longcmp); + + k2 = stopMin; + for (i = 0; i < bs_stop_freq; i++) + { + k2 += stopDk[i]; + } + return min(64, k2); +#endif + /* bs_stop_freq <= 13 */ + return min(64, stopMin + offset[get_sr_index(sample_rate)][min(bs_stop_freq, 13)]); + } + + return 0; +} + +/* calculate the master frequency table from k0, k2, bs_freq_scale + and bs_alter_scale + + version for bs_freq_scale = 0 +*/ +uint8_t master_frequency_table_fs0(sbr_info *sbr, uint8_t k0, uint8_t k2, + uint8_t bs_alter_scale) +{ + int8_t incr; + uint8_t k; + uint8_t dk; + uint32_t nrBands, k2Achieved; + int32_t k2Diff, vDk[64] = {0}; + + /* mft only defined for k2 > k0 */ + if (k2 <= k0) + { + sbr->N_master = 0; + return 1; + } + + dk = bs_alter_scale ? 2 : 1; + +#if 0 /* replaced by float-less design */ + nrBands = 2 * (int32_t)((float)(k2-k0)/(dk*2) + (-1+dk)/2.0f); +#else + if (bs_alter_scale) + { + nrBands = (((k2-k0+2)>>2)<<1); + } else { + nrBands = (((k2-k0)>>1)<<1); + } +#endif + nrBands = min(nrBands, 63); + if (nrBands <= 0) + return 1; + + k2Achieved = k0 + nrBands * dk; + k2Diff = k2 - k2Achieved; + for (k = 0; k < nrBands; k++) + vDk[k] = dk; + + if (k2Diff) + { + incr = (k2Diff > 0) ? -1 : 1; + k = (uint8_t) ((k2Diff > 0) ? (nrBands-1) : 0); + + while (k2Diff != 0) + { + vDk[k] -= incr; + k += incr; + k2Diff += incr; + } + } + + sbr->f_master[0] = k0; + for (k = 1; k <= nrBands; k++) + sbr->f_master[k] = (uint8_t)(sbr->f_master[k-1] + vDk[k-1]); + + sbr->N_master = (uint8_t)nrBands; + sbr->N_master = (min(sbr->N_master, 64)); + +#if 0 + printf("f_master[%d]: ", nrBands); + for (k = 0; k <= nrBands; k++) + { + printf("%d ", sbr->f_master[k]); + } + printf("\n"); +#endif + + return 0; +} + +/* + This function finds the number of bands using this formula: + bands * log(a1/a0)/log(2.0) + 0.5 +*/ +static int32_t find_bands(uint8_t warp, uint8_t bands, uint8_t a0, uint8_t a1) +{ +#ifdef FIXED_POINT + /* table with log2() values */ + static const real_t log2Table[65] = { + COEF_CONST(0.0), COEF_CONST(0.0), COEF_CONST(1.0000000000), COEF_CONST(1.5849625007), + COEF_CONST(2.0000000000), COEF_CONST(2.3219280949), COEF_CONST(2.5849625007), COEF_CONST(2.8073549221), + COEF_CONST(3.0000000000), COEF_CONST(3.1699250014), COEF_CONST(3.3219280949), COEF_CONST(3.4594316186), + COEF_CONST(3.5849625007), COEF_CONST(3.7004397181), COEF_CONST(3.8073549221), COEF_CONST(3.9068905956), + COEF_CONST(4.0000000000), COEF_CONST(4.0874628413), COEF_CONST(4.1699250014), COEF_CONST(4.2479275134), + COEF_CONST(4.3219280949), COEF_CONST(4.3923174228), COEF_CONST(4.4594316186), COEF_CONST(4.5235619561), + COEF_CONST(4.5849625007), COEF_CONST(4.6438561898), COEF_CONST(4.7004397181), COEF_CONST(4.7548875022), + COEF_CONST(4.8073549221), COEF_CONST(4.8579809951), COEF_CONST(4.9068905956), COEF_CONST(4.9541963104), + COEF_CONST(5.0000000000), COEF_CONST(5.0443941194), COEF_CONST(5.0874628413), COEF_CONST(5.1292830169), + COEF_CONST(5.1699250014), COEF_CONST(5.2094533656), COEF_CONST(5.2479275134), COEF_CONST(5.2854022189), + COEF_CONST(5.3219280949), COEF_CONST(5.3575520046), COEF_CONST(5.3923174228), COEF_CONST(5.4262647547), + COEF_CONST(5.4594316186), COEF_CONST(5.4918530963), COEF_CONST(5.5235619561), COEF_CONST(5.5545888517), + COEF_CONST(5.5849625007), COEF_CONST(5.6147098441), COEF_CONST(5.6438561898), COEF_CONST(5.6724253420), + COEF_CONST(5.7004397181), COEF_CONST(5.7279204546), COEF_CONST(5.7548875022), COEF_CONST(5.7813597135), + COEF_CONST(5.8073549221), COEF_CONST(5.8328900142), COEF_CONST(5.8579809951), COEF_CONST(5.8826430494), + COEF_CONST(5.9068905956), COEF_CONST(5.9307373376), COEF_CONST(5.9541963104), COEF_CONST(5.9772799235), + COEF_CONST(6.0) + }; + real_t r0 = log2Table[a0]; /* coef */ + real_t r1 = log2Table[a1]; /* coef */ + real_t r2 = (r1 - r0); /* coef */ + + if (warp) + r2 = MUL_C(r2, COEF_CONST(1.0/1.3)); + + /* convert r2 to real and then multiply and round */ + r2 = (r2 >> (COEF_BITS-REAL_BITS)) * bands + (1<<(REAL_BITS-1)); + + return (r2 >> REAL_BITS); +#else + real_t div = (real_t)log(2.0); + if (warp) div *= (real_t)1.3; + + return (int32_t)(bands * log((float)a1/(float)a0)/div + 0.5); +#endif +} + +static real_t find_initial_power(uint8_t bands, uint8_t a0, uint8_t a1) +{ +#ifdef FIXED_POINT + /* table with log() values */ + static const real_t logTable[65] = { + COEF_CONST(0.0), COEF_CONST(0.0), COEF_CONST(0.6931471806), COEF_CONST(1.0986122887), + COEF_CONST(1.3862943611), COEF_CONST(1.6094379124), COEF_CONST(1.7917594692), COEF_CONST(1.9459101491), + COEF_CONST(2.0794415417), COEF_CONST(2.1972245773), COEF_CONST(2.3025850930), COEF_CONST(2.3978952728), + COEF_CONST(2.4849066498), COEF_CONST(2.5649493575), COEF_CONST(2.6390573296), COEF_CONST(2.7080502011), + COEF_CONST(2.7725887222), COEF_CONST(2.8332133441), COEF_CONST(2.8903717579), COEF_CONST(2.9444389792), + COEF_CONST(2.9957322736), COEF_CONST(3.0445224377), COEF_CONST(3.0910424534), COEF_CONST(3.1354942159), + COEF_CONST(3.1780538303), COEF_CONST(3.2188758249), COEF_CONST(3.2580965380), COEF_CONST(3.2958368660), + COEF_CONST(3.3322045102), COEF_CONST(3.3672958300), COEF_CONST(3.4011973817), COEF_CONST(3.4339872045), + COEF_CONST(3.4657359028), COEF_CONST(3.4965075615), COEF_CONST(3.5263605246), COEF_CONST(3.5553480615), + COEF_CONST(3.5835189385), COEF_CONST(3.6109179126), COEF_CONST(3.6375861597), COEF_CONST(3.6635616461), + COEF_CONST(3.6888794541), COEF_CONST(3.7135720667), COEF_CONST(3.7376696183), COEF_CONST(3.7612001157), + COEF_CONST(3.7841896339), COEF_CONST(3.8066624898), COEF_CONST(3.8286413965), COEF_CONST(3.8501476017), + COEF_CONST(3.8712010109), COEF_CONST(3.8918202981), COEF_CONST(3.9120230054), COEF_CONST(3.9318256327), + COEF_CONST(3.9512437186), COEF_CONST(3.9702919136), COEF_CONST(3.9889840466), COEF_CONST(4.0073331852), + COEF_CONST(4.0253516907), COEF_CONST(4.0430512678), COEF_CONST(4.0604430105), COEF_CONST(4.0775374439), + COEF_CONST(4.0943445622), COEF_CONST(4.1108738642), COEF_CONST(4.1271343850), COEF_CONST(4.1431347264), + COEF_CONST(4.158883083) + }; + /* standard Taylor polynomial coefficients for exp(x) around 0 */ + /* a polynomial around x=1 is more precise, as most values are around 1.07, + but this is just fine already */ + static const real_t c1 = COEF_CONST(1.0); + static const real_t c2 = COEF_CONST(1.0/2.0); + static const real_t c3 = COEF_CONST(1.0/6.0); + static const real_t c4 = COEF_CONST(1.0/24.0); + + real_t r0 = logTable[a0]; /* coef */ + real_t r1 = logTable[a1]; /* coef */ + real_t r2 = (r1 - r0) / bands; /* coef */ + real_t rexp = c1 + MUL_C((c1 + MUL_C((c2 + MUL_C((c3 + MUL_C(c4,r2)), r2)), r2)), r2); + + return (rexp >> (COEF_BITS-REAL_BITS)); /* real */ +#else + return (real_t)pow((real_t)a1/(real_t)a0, 1.0/(real_t)bands); +#endif +} + +/* + version for bs_freq_scale > 0 +*/ +uint8_t master_frequency_table(sbr_info *sbr, uint8_t k0, uint8_t k2, + uint8_t bs_freq_scale, uint8_t bs_alter_scale) +{ + uint8_t k, bands, twoRegions; + uint8_t k1; + uint8_t nrBand0, nrBand1; + int32_t vDk0[64] = {0}, vDk1[64] = {0}; + int32_t vk0[64] = {0}, vk1[64] = {0}; + uint8_t temp1[] = { 6, 5, 4 }; + real_t q, qk; + int32_t A_1; +#ifdef FIXED_POINT + real_t rk2, rk0; +#endif + + (void)bs_alter_scale; + /* mft only defined for k2 > k0 */ + if (k2 <= k0) + { + sbr->N_master = 0; + return 1; + } + + bands = temp1[bs_freq_scale-1]; + +#ifdef FIXED_POINT + rk0 = (real_t)k0 << REAL_BITS; + rk2 = (real_t)k2 << REAL_BITS; + if (rk2 > MUL_C(rk0, COEF_CONST(2.2449))) +#else + if ((float)k2/(float)k0 > 2.2449) +#endif + { + twoRegions = 1; + k1 = k0 << 1; + } else { + twoRegions = 0; + k1 = k2; + } + + nrBand0 = (uint8_t)(2 * find_bands(0, bands, k0, k1)); + nrBand0 = min(nrBand0, 63); + if (nrBand0 <= 0) + return 1; + + q = find_initial_power(nrBand0, k0, k1); +#ifdef FIXED_POINT + qk = (real_t)k0 << REAL_BITS; + //A_1 = (int32_t)((qk + REAL_CONST(0.5)) >> REAL_BITS); + A_1 = k0; +#else + qk = REAL_CONST(k0); + A_1 = (int32_t)(qk + .5); +#endif + for (k = 0; k <= nrBand0; k++) + { + int32_t A_0 = A_1; +#ifdef FIXED_POINT + qk = MUL_R(qk,q); + A_1 = (int32_t)((qk + REAL_CONST(0.5)) >> REAL_BITS); +#else + qk *= q; + A_1 = (int32_t)(qk + 0.5); +#endif + vDk0[k] = A_1 - A_0; + } + + /* needed? */ + qsort(vDk0, nrBand0, sizeof(vDk0[0]), longcmp); + + vk0[0] = k0; + for (k = 1; k <= nrBand0; k++) + { + vk0[k] = vk0[k-1] + vDk0[k-1]; + if (vDk0[k-1] == 0) + return 1; + } + + if (!twoRegions) + { + for (k = 0; k <= nrBand0; k++) + sbr->f_master[k] = (uint8_t) vk0[k]; + + sbr->N_master = nrBand0; + sbr->N_master = min(sbr->N_master, 64); + return 0; + } + + nrBand1 = (uint8_t)(2 * find_bands(1 /* warped */, bands, k1, k2)); + nrBand1 = min(nrBand1, 63); + + q = find_initial_power(nrBand1, k1, k2); +#ifdef FIXED_POINT + qk = (real_t)k1 << REAL_BITS; + //A_1 = (int32_t)((qk + REAL_CONST(0.5)) >> REAL_BITS); + A_1 = k1; +#else + qk = REAL_CONST(k1); + A_1 = (int32_t)(qk + .5); +#endif + for (k = 0; k <= nrBand1 - 1; k++) + { + int32_t A_0 = A_1; +#ifdef FIXED_POINT + qk = MUL_R(qk,q); + A_1 = (int32_t)((qk + REAL_CONST(0.5)) >> REAL_BITS); +#else + qk *= q; + A_1 = (int32_t)(qk + 0.5); +#endif + vDk1[k] = A_1 - A_0; + } + + if (vDk1[0] < vDk0[nrBand0 - 1]) + { + int32_t change; + + /* needed? */ + qsort(vDk1, nrBand1 + 1, sizeof(vDk1[0]), longcmp); + change = vDk0[nrBand0 - 1] - vDk1[0]; + vDk1[0] = vDk0[nrBand0 - 1]; + vDk1[nrBand1 - 1] = vDk1[nrBand1 - 1] - change; + } + + /* needed? */ + qsort(vDk1, nrBand1, sizeof(vDk1[0]), longcmp); + vk1[0] = k1; + for (k = 1; k <= nrBand1; k++) + { + vk1[k] = vk1[k-1] + vDk1[k-1]; + if (vDk1[k-1] == 0) + return 1; + } + + sbr->N_master = nrBand0 + nrBand1; + sbr->N_master = min(sbr->N_master, 64); + for (k = 0; k <= nrBand0; k++) + { + sbr->f_master[k] = (uint8_t) vk0[k]; + } + for (k = nrBand0 + 1; k <= sbr->N_master; k++) + { + sbr->f_master[k] = (uint8_t) vk1[k - nrBand0]; + } + +#if 0 + printf("f_master[%d]: ", sbr->N_master); + for (k = 0; k <= sbr->N_master; k++) + { + printf("%d ", sbr->f_master[k]); + } + printf("\n"); +#endif + + return 0; +} + +/* calculate the derived frequency border tables from f_master */ +uint8_t derived_frequency_table(sbr_info *sbr, uint8_t bs_xover_band, + uint8_t k2) +{ + uint8_t k, i = 0; + uint32_t minus; + + /* The following relation shall be satisfied: bs_xover_band < N_Master */ + if (sbr->N_master <= bs_xover_band) + return 1; + + sbr->N_high = sbr->N_master - bs_xover_band; + sbr->N_low = (sbr->N_high>>1) + (sbr->N_high - ((sbr->N_high>>1)<<1)); + + sbr->n[0] = sbr->N_low; + sbr->n[1] = sbr->N_high; + + for (k = 0; k <= sbr->N_high; k++) + { + sbr->f_table_res[HI_RES][k] = sbr->f_master[k + bs_xover_band]; + } + + sbr->M = sbr->f_table_res[HI_RES][sbr->N_high] - sbr->f_table_res[HI_RES][0]; + sbr->kx = sbr->f_table_res[HI_RES][0]; + if (sbr->kx > 32) + return 1; + if (sbr->kx + sbr->M > 64) + return 1; + + minus = (sbr->N_high & 1) ? 1 : 0; + + for (k = 0; k <= sbr->N_low; k++) + { + if (k == 0) + i = 0; + else + i = (uint8_t)(2*k - minus); + sbr->f_table_res[LO_RES][k] = sbr->f_table_res[HI_RES][i]; + } + +#if 0 + printf("bs_freq_scale: %d\n", sbr->bs_freq_scale); + printf("bs_limiter_bands: %d\n", sbr->bs_limiter_bands); + printf("f_table_res[HI_RES][%d]: ", sbr->N_high); + for (k = 0; k <= sbr->N_high; k++) + { + printf("%d ", sbr->f_table_res[HI_RES][k]); + } + printf("\n"); +#endif +#if 0 + printf("f_table_res[LO_RES][%d]: ", sbr->N_low); + for (k = 0; k <= sbr->N_low; k++) + { + printf("%d ", sbr->f_table_res[LO_RES][k]); + } + printf("\n"); +#endif + + sbr->N_Q = 0; + if (sbr->bs_noise_bands == 0) + { + sbr->N_Q = 1; + } else { +#if 0 + sbr->N_Q = max(1, (int32_t)(sbr->bs_noise_bands*(log(k2/(float)sbr->kx)/log(2.0)) + 0.5)); +#else + sbr->N_Q = (uint8_t)(max(1, find_bands(0, sbr->bs_noise_bands, sbr->kx, k2))); +#endif + sbr->N_Q = min(5, sbr->N_Q); + } + + for (k = 0; k <= sbr->N_Q; k++) + { + if (k == 0) + { + i = 0; + } else { + /* i = i + (int32_t)((sbr->N_low - i)/(sbr->N_Q + 1 - k)); */ + i = i + (sbr->N_low - i)/(sbr->N_Q + 1 - k); + } + sbr->f_table_noise[k] = sbr->f_table_res[LO_RES][i]; + } + + /* build table for mapping k to g in hf patching */ + for (k = 0; k < 64; k++) + { + uint8_t g; + for (g = 0; g < sbr->N_Q; g++) + { + if ((sbr->f_table_noise[g] <= k) && + (k < sbr->f_table_noise[g+1])) + { + sbr->table_map_k_to_g[k] = g; + break; + } + } + } + +#if 0 + printf("f_table_noise[%d]: ", sbr->N_Q); + for (k = 0; k <= sbr->N_Q; k++) + { + printf("%d ", sbr->f_table_noise[k] - sbr->kx); + } + printf("\n"); +#endif + + return 0; +} + +/* TODO: blegh, ugly */ +/* Modified to calculate for all possible bs_limiter_bands always + * This reduces the number calls to this functions needed (now only on + * header reset) + */ +void limiter_frequency_table(sbr_info *sbr) +{ +#if 0 + static const real_t limiterBandsPerOctave[] = { REAL_CONST(1.2), + REAL_CONST(2), REAL_CONST(3) }; +#else + static const real_t limiterBandsCompare[] = { REAL_CONST(1.327152), + REAL_CONST(1.185093), REAL_CONST(1.119872) }; +#endif + uint8_t k, s; + int8_t nrLim; +#if 0 + real_t limBands; +#endif + + sbr->f_table_lim[0][0] = sbr->f_table_res[LO_RES][0] - sbr->kx; + sbr->f_table_lim[0][1] = sbr->f_table_res[LO_RES][sbr->N_low] - sbr->kx; + sbr->N_L[0] = 1; + +#if 0 + printf("f_table_lim[%d][%d]: ", 0, sbr->N_L[0]); + for (k = 0; k <= sbr->N_L[0]; k++) + { + printf("%d ", sbr->f_table_lim[0][k]); + } + printf("\n"); +#endif + + for (s = 1; s < 4; s++) + { + int32_t limTable[100 /*TODO*/] = {0}; + uint8_t patchBorders[64/*??*/] = {0}; + +#if 0 + limBands = limiterBandsPerOctave[s - 1]; +#endif + + patchBorders[0] = sbr->kx; + for (k = 1; k <= sbr->noPatches; k++) + { + patchBorders[k] = patchBorders[k-1] + sbr->patchNoSubbands[k-1]; + } + + for (k = 0; k <= sbr->N_low; k++) + { + limTable[k] = sbr->f_table_res[LO_RES][k]; + } + for (k = 1; k < sbr->noPatches; k++) + { + limTable[k+sbr->N_low] = patchBorders[k]; + } + + /* needed */ + qsort(limTable, sbr->noPatches + sbr->N_low, sizeof(limTable[0]), longcmp); + k = 1; + nrLim = sbr->noPatches + sbr->N_low - 1; + + if (nrLim < 0) // TODO: BIG FAT PROBLEM + return; + +restart: + if (k <= nrLim) + { + real_t nOctaves; + + if (limTable[k-1] != 0) +#if 0 + nOctaves = REAL_CONST(log((float)limTable[k]/(float)limTable[k-1])/log(2.0)); +#else +#ifdef FIXED_POINT + nOctaves = DIV_R((limTable[k]<noPatches; i++) + { + if (limTable[k] == patchBorders[i]) + found = 1; + } + if (found) + { + found2 = 0; + for (i = 0; i <= sbr->noPatches; i++) + { + if (limTable[k-1] == patchBorders[i]) + found2 = 1; + } + if (found2) + { + k++; + goto restart; + } else { + /* remove (k-1)th element */ + limTable[k-1] = sbr->f_table_res[LO_RES][sbr->N_low]; + qsort(limTable, sbr->noPatches + sbr->N_low, sizeof(limTable[0]), longcmp); + nrLim--; + goto restart; + } + } + } + /* remove kth element */ + limTable[k] = sbr->f_table_res[LO_RES][sbr->N_low]; + qsort(limTable, nrLim, sizeof(limTable[0]), longcmp); + nrLim--; + goto restart; + } else { + k++; + goto restart; + } + } + + sbr->N_L[s] = nrLim; + for (k = 0; k <= nrLim; k++) + { + sbr->f_table_lim[s][k] = limTable[k] - sbr->kx; + } + +#if 0 + printf("f_table_lim[%d][%d]: ", s, sbr->N_L[s]); + for (k = 0; k <= sbr->N_L[s]; k++) + { + printf("%d ", sbr->f_table_lim[s][k]); + } + printf("\n"); +#endif + } +} + +#endif diff --git a/lib/rbcodec/codecs/libfaad/sbr_fbt.h b/lib/rbcodec/codecs/libfaad/sbr_fbt.h new file mode 100644 index 0000000000..ac25335268 --- /dev/null +++ b/lib/rbcodec/codecs/libfaad/sbr_fbt.h @@ -0,0 +1,52 @@ +/* +** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding +** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +** +** Any non-GPL usage of this software or parts of this software is strictly +** forbidden. +** +** Commercial non-GPL licensing of this software is possible. +** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** +** $Id$ +**/ + +#ifndef __SBR_FBT_H__ +#define __SBR_FBT_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +uint8_t qmf_start_channel(uint8_t bs_start_freq, uint8_t bs_samplerate_mode, + uint32_t sample_rate); +uint8_t qmf_stop_channel(uint8_t bs_stop_freq, uint32_t sample_rate, + uint8_t k0); +uint8_t master_frequency_table_fs0(sbr_info *sbr, uint8_t k0, uint8_t k2, + uint8_t bs_alter_scale); +uint8_t master_frequency_table(sbr_info *sbr, uint8_t k0, uint8_t k2, + uint8_t bs_freq_scale, uint8_t bs_alter_scale); +uint8_t derived_frequency_table(sbr_info *sbr, uint8_t bs_xover_band, + uint8_t k2); +void limiter_frequency_table(sbr_info *sbr); + + +#ifdef __cplusplus +} +#endif +#endif + diff --git a/lib/rbcodec/codecs/libfaad/sbr_hfadj.c b/lib/rbcodec/codecs/libfaad/sbr_hfadj.c new file mode 100644 index 0000000000..b562bf904a --- /dev/null +++ b/lib/rbcodec/codecs/libfaad/sbr_hfadj.c @@ -0,0 +1,1631 @@ +/* +** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding +** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +** +** Any non-GPL usage of this software or parts of this software is strictly +** forbidden. +** +** Commercial non-GPL licensing of this software is possible. +** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** +** $Id$ +**/ + +/* High Frequency adjustment */ + +#include "common.h" +#include "structs.h" + +#ifdef SBR_DEC + +#include "sbr_syntax.h" +#include "sbr_hfadj.h" + +#include "sbr_noise.h" + +#ifdef FIXED_POINT +#define REAL_UPSCALE(A) ((A)<>REAL_BITS) +#else +#define REAL_UPSCALE(A) (A) +#define REAL_DOWNSCALE(A) (A) +#endif + +/* static function declarations */ +static void estimate_current_envelope(sbr_info *sbr, sbr_hfadj_info *adj, + qmf_t Xsbr[MAX_NTSRHFG][64], uint8_t ch); +static void calculate_gain(sbr_info *sbr, sbr_hfadj_info *adj, uint8_t ch); +#ifdef SBR_LOW_POWER +static void calc_gain_groups(sbr_info *sbr, sbr_hfadj_info *adj, real_t *deg, uint8_t ch); +static void aliasing_reduction(sbr_info *sbr, sbr_hfadj_info *adj, real_t *deg, uint8_t ch); +#endif +static void hf_assembly(sbr_info *sbr, sbr_hfadj_info *adj, qmf_t Xsbr[MAX_NTSRHFG][64], uint8_t ch); + + +void hf_adjustment(sbr_info *sbr, qmf_t Xsbr[MAX_NTSRHFG][64] +#ifdef SBR_LOW_POWER + ,real_t *deg /* aliasing degree */ +#endif + ,uint8_t ch) +{ + sbr_hfadj_info adj MEM_ALIGN_ATTR; + + memset(&adj,0,sizeof(adj)); + if (sbr->bs_frame_class[ch] == FIXFIX) + { + sbr->l_A[ch] = -1; + } else if (sbr->bs_frame_class[ch] == VARFIX) { + if (sbr->bs_pointer[ch] > 1) + sbr->l_A[ch] = -1; + else + sbr->l_A[ch] = sbr->bs_pointer[ch] - 1; + } else { + if (sbr->bs_pointer[ch] == 0) + sbr->l_A[ch] = -1; + else + sbr->l_A[ch] = sbr->L_E[ch] + 1 - sbr->bs_pointer[ch]; + } + + estimate_current_envelope(sbr, &adj, Xsbr, ch); + + calculate_gain(sbr, &adj, ch); + +#ifdef SBR_LOW_POWER + calc_gain_groups(sbr, &adj, deg, ch); + aliasing_reduction(sbr, &adj, deg, ch); +#endif + + hf_assembly(sbr, &adj, Xsbr, ch); +} + +static uint8_t get_S_mapped(sbr_info *sbr, uint8_t ch, uint8_t l, uint8_t current_band) +{ + if (sbr->f[ch][l] == HI_RES) + { + /* in case of using f_table_high we just have 1 to 1 mapping + * from bs_add_harmonic[l][k] + */ + if ((l >= sbr->l_A[ch]) || + (sbr->bs_add_harmonic_prev[ch][current_band] && sbr->bs_add_harmonic_flag_prev[ch])) + { + return sbr->bs_add_harmonic[ch][current_band]; + } + } else { + uint8_t b, lb, ub; + + /* in case of f_table_low we check if any of the HI_RES bands + * within this LO_RES band has bs_add_harmonic[l][k] turned on + * (note that borders in the LO_RES table are also present in + * the HI_RES table) + */ + + /* find first HI_RES band in current LO_RES band */ + lb = 2 * (current_band ) - ((sbr->N_high & 1) ? 1 : 0); + /* find first HI_RES band in next LO_RES band */ + ub = 2 * (current_band+1) - ((sbr->N_high & 1) ? 1 : 0); + + /* check all HI_RES bands in current LO_RES band for sinusoid */ + for (b = lb; b < ub; b++) + { + if ((l >= sbr->l_A[ch]) || + (sbr->bs_add_harmonic_prev[ch][b] && sbr->bs_add_harmonic_flag_prev[ch])) + { + if (sbr->bs_add_harmonic[ch][b] == 1) + return 1; + } + } + } + + return 0; +} + +static void estimate_current_envelope(sbr_info *sbr, sbr_hfadj_info *adj, + qmf_t Xsbr[MAX_NTSRHFG][64], uint8_t ch) +{ + uint8_t m, l, j, k, k_l, k_h, p; + real_t nrg, div, tmp; + + (void)adj; + if (sbr->bs_interpol_freq == 1) + { + for (l = 0; l < sbr->L_E[ch]; l++) + { + uint8_t i, l_i, u_i; + + l_i = sbr->t_E[ch][l]; + u_i = sbr->t_E[ch][l+1]; + + div = (real_t)(u_i - l_i); + + for (m = 0; m < sbr->M; m++) + { + nrg = 0; + + for (i = l_i + sbr->tHFAdj; i < u_i + sbr->tHFAdj; i++) + { + tmp = QMF_RE(Xsbr[i][m + sbr->kx]); + nrg += MUL_R(tmp, REAL_DOWNSCALE(tmp)); +#ifndef SBR_LOW_POWER + tmp = QMF_IM(Xsbr[i][m + sbr->kx]); + nrg += MUL_R(tmp, REAL_DOWNSCALE(tmp)); +#endif + } + + sbr->E_curr[ch][m][l] = nrg / div; +#ifdef SBR_LOW_POWER + sbr->E_curr[ch][m][l] *= 2; +#endif + } + } + } else { + for (l = 0; l < sbr->L_E[ch]; l++) + { + for (p = 0; p < sbr->n[sbr->f[ch][l]]; p++) + { + k_l = sbr->f_table_res[sbr->f[ch][l]][p]; + k_h = sbr->f_table_res[sbr->f[ch][l]][p+1]; + + for (k = k_l; k < k_h; k++) + { + uint8_t i, l_i, u_i; + nrg = 0; + + l_i = sbr->t_E[ch][l]; + u_i = sbr->t_E[ch][l+1]; + + div = (real_t)((u_i - l_i)*(k_h - k_l)); + + for (i = l_i + sbr->tHFAdj; i < u_i + sbr->tHFAdj; i++) + { + for (j = k_l; j < k_h; j++) + { + tmp = QMF_RE(Xsbr[i][j]); + nrg += MUL_R(tmp, REAL_DOWNSCALE(tmp)); +#ifndef SBR_LOW_POWER + tmp = QMF_IM(Xsbr[i][j]); + nrg += MUL_R(tmp, REAL_DOWNSCALE(tmp)); +#endif + } + } + + sbr->E_curr[ch][k - sbr->kx][l] = nrg / div; +#ifdef SBR_LOW_POWER + sbr->E_curr[ch][k - sbr->kx][l] *= 2; +#endif + } + } + } + } +} + +#ifdef FIXED_POINT +#define EPS (1) /* smallest number available in fixed point */ +#else +#define EPS (1e-12) +#endif + + + +#ifdef FIXED_POINT + +/* log2 values of [0..63] */ +static const real_t log2_int_tab[] = { + LOG2_MIN_INF , REAL_CONST(0.000000000000000), REAL_CONST(1.000000000000000), REAL_CONST(1.584962500721156), + REAL_CONST(2.000000000000000), REAL_CONST(2.321928094887362), REAL_CONST(2.584962500721156), REAL_CONST(2.807354922057604), + REAL_CONST(3.000000000000000), REAL_CONST(3.169925001442313), REAL_CONST(3.321928094887363), REAL_CONST(3.459431618637297), + REAL_CONST(3.584962500721156), REAL_CONST(3.700439718141092), REAL_CONST(3.807354922057604), REAL_CONST(3.906890595608519), + REAL_CONST(4.000000000000000), REAL_CONST(4.087462841250339), REAL_CONST(4.169925001442312), REAL_CONST(4.247927513443585), + REAL_CONST(4.321928094887362), REAL_CONST(4.392317422778761), REAL_CONST(4.459431618637297), REAL_CONST(4.523561956057013), + REAL_CONST(4.584962500721156), REAL_CONST(4.643856189774724), REAL_CONST(4.700439718141093), REAL_CONST(4.754887502163468), + REAL_CONST(4.807354922057604), REAL_CONST(4.857980995127572), REAL_CONST(4.906890595608519), REAL_CONST(4.954196310386875), + REAL_CONST(5.000000000000000), REAL_CONST(5.044394119358453), REAL_CONST(5.087462841250340), REAL_CONST(5.129283016944966), + REAL_CONST(5.169925001442312), REAL_CONST(5.209453365628949), REAL_CONST(5.247927513443585), REAL_CONST(5.285402218862248), + REAL_CONST(5.321928094887363), REAL_CONST(5.357552004618084), REAL_CONST(5.392317422778761), REAL_CONST(5.426264754702098), + REAL_CONST(5.459431618637297), REAL_CONST(5.491853096329675), REAL_CONST(5.523561956057013), REAL_CONST(5.554588851677637), + REAL_CONST(5.584962500721156), REAL_CONST(5.614709844115208), REAL_CONST(5.643856189774724), REAL_CONST(5.672425341971495), + REAL_CONST(5.700439718141093), REAL_CONST(5.727920454563200), REAL_CONST(5.754887502163469), REAL_CONST(5.781359713524660), + REAL_CONST(5.807354922057605), REAL_CONST(5.832890014164742), REAL_CONST(5.857980995127572), REAL_CONST(5.882643049361842), + REAL_CONST(5.906890595608518), REAL_CONST(5.930737337562887), REAL_CONST(5.954196310386876), REAL_CONST(5.977279923499916) +}; + +static const real_t pan_log2_tab[] = { + REAL_CONST(1.000000000000000), REAL_CONST(0.584962500721156), REAL_CONST(0.321928094887362), REAL_CONST(0.169925001442312), REAL_CONST(0.087462841250339), + REAL_CONST(0.044394119358453), REAL_CONST(0.022367813028455), REAL_CONST(0.011227255423254), REAL_CONST(0.005624549193878), REAL_CONST(0.002815015607054), + REAL_CONST(0.001408194392808), REAL_CONST(0.000704269011247), REAL_CONST(0.000352177480301), REAL_CONST(0.000176099486443), REAL_CONST(0.000088052430122), + REAL_CONST(0.000044026886827), REAL_CONST(0.000022013611360), REAL_CONST(0.000011006847667) +}; + +static real_t find_log2_E(sbr_info *sbr, uint8_t k, uint8_t l, uint8_t ch) +{ + /* check for coupled energy/noise data */ + if (sbr->bs_coupling == 1) + { + uint8_t amp0 = (sbr->amp_res[0]) ? 0 : 1; + uint8_t amp1 = (sbr->amp_res[1]) ? 0 : 1; + real_t tmp = (7 << REAL_BITS) + (sbr->E[0][k][l] << (REAL_BITS-amp0)); + real_t pan; + + /* E[1] should always be even so shifting is OK */ + uint8_t E = sbr->E[1][k][l] >> amp1; + + if (ch == 0) + { + if (E > 12) + { + /* negative */ + pan = pan_log2_tab[-12 + E]; + } else { + /* positive */ + pan = pan_log2_tab[12 - E] + ((12 - E)<amp_res[ch]) ? 0 : 1; + + return (6 << REAL_BITS) + (sbr->E[ch][k][l] << (REAL_BITS-amp)); + } +} + +static real_t find_log2_Q(sbr_info *sbr, uint8_t k, uint8_t l, uint8_t ch) +{ + /* check for coupled energy/noise data */ + if (sbr->bs_coupling == 1) + { + real_t tmp = (7 << REAL_BITS) - (sbr->Q[0][k][l] << REAL_BITS); + real_t pan; + + uint8_t Q = sbr->Q[1][k][l]; + + if (ch == 0) + { + if (Q > 12) + { + /* negative */ + pan = pan_log2_tab[-12 + Q]; + } else { + /* positive */ + pan = pan_log2_tab[12 - Q] + ((12 - Q)<Q[ch][k][l] << REAL_BITS); + } +} + +static const real_t log_Qplus1_pan[31][13] = { + { REAL_CONST(0.044383447617292), REAL_CONST(0.169768601655960), REAL_CONST(0.583090126514435), REAL_CONST(1.570089221000671), REAL_CONST(3.092446088790894), REAL_CONST(4.733354568481445), REAL_CONST(6.022367954254150), REAL_CONST(6.692092418670654), REAL_CONST(6.924463272094727), REAL_CONST(6.989034175872803), REAL_CONST(7.005646705627441), REAL_CONST(7.009829998016357), REAL_CONST(7.010877609252930) }, + { REAL_CONST(0.022362394258380), REAL_CONST(0.087379962205887), REAL_CONST(0.320804953575134), REAL_CONST(0.988859415054321), REAL_CONST(2.252387046813965), REAL_CONST(3.786596298217773), REAL_CONST(5.044394016265869), REAL_CONST(5.705977916717529), REAL_CONST(5.936291694641113), REAL_CONST(6.000346660614014), REAL_CONST(6.016829967498779), REAL_CONST(6.020981311798096), REAL_CONST(6.022020816802979) }, + { REAL_CONST(0.011224525049329), REAL_CONST(0.044351425021887), REAL_CONST(0.169301137328148), REAL_CONST(0.577544987201691), REAL_CONST(1.527246952056885), REAL_CONST(2.887525320053101), REAL_CONST(4.087462902069092), REAL_CONST(4.733354568481445), REAL_CONST(4.959661006927490), REAL_CONST(5.022709369659424), REAL_CONST(5.038940429687500), REAL_CONST(5.043028831481934), REAL_CONST(5.044052600860596) }, + { REAL_CONST(0.005623178556561), REAL_CONST(0.022346137091517), REAL_CONST(0.087132595479488), REAL_CONST(0.317482173442841), REAL_CONST(0.956931233406067), REAL_CONST(2.070389270782471), REAL_CONST(3.169924974441528), REAL_CONST(3.786596298217773), REAL_CONST(4.005294322967529), REAL_CONST(4.066420555114746), REAL_CONST(4.082170009613037), REAL_CONST(4.086137294769287), REAL_CONST(4.087131500244141) }, + { REAL_CONST(0.002814328996465), REAL_CONST(0.011216334067285), REAL_CONST(0.044224001467228), REAL_CONST(0.167456731200218), REAL_CONST(0.556393325328827), REAL_CONST(1.378511548042297), REAL_CONST(2.321928024291992), REAL_CONST(2.887525320053101), REAL_CONST(3.092446088790894), REAL_CONST(3.150059700012207), REAL_CONST(3.164926528930664), REAL_CONST(3.168673276901245), REAL_CONST(3.169611930847168) }, + { REAL_CONST(0.001407850766554), REAL_CONST(0.005619067233056), REAL_CONST(0.022281449288130), REAL_CONST(0.086156636476517), REAL_CONST(0.304854571819305), REAL_CONST(0.847996890544891), REAL_CONST(1.584962487220764), REAL_CONST(2.070389270782471), REAL_CONST(2.252387046813965), REAL_CONST(2.304061651229858), REAL_CONST(2.317430257797241), REAL_CONST(2.320801734924316), REAL_CONST(2.321646213531494) }, + { REAL_CONST(0.000704097095877), REAL_CONST(0.002812269143760), REAL_CONST(0.011183738708496), REAL_CONST(0.043721374124289), REAL_CONST(0.160464659333229), REAL_CONST(0.485426813364029), REAL_CONST(1.000000000000000), REAL_CONST(1.378511548042297), REAL_CONST(1.527246952056885), REAL_CONST(1.570089221000671), REAL_CONST(1.581215262413025), REAL_CONST(1.584023833274841), REAL_CONST(1.584727644920349) }, + { REAL_CONST(0.000352177477907), REAL_CONST(0.001406819908880), REAL_CONST(0.005602621007711), REAL_CONST(0.022026389837265), REAL_CONST(0.082462236285210), REAL_CONST(0.263034462928772), REAL_CONST(0.584962487220764), REAL_CONST(0.847996890544891), REAL_CONST(0.956931233406067), REAL_CONST(0.988859415054321), REAL_CONST(0.997190535068512), REAL_CONST(0.999296069145203), REAL_CONST(0.999823868274689) }, + { REAL_CONST(0.000176099492819), REAL_CONST(0.000703581434209), REAL_CONST(0.002804030198604), REAL_CONST(0.011055230163038), REAL_CONST(0.041820213198662), REAL_CONST(0.137503549456596), REAL_CONST(0.321928083896637), REAL_CONST(0.485426813364029), REAL_CONST(0.556393325328827), REAL_CONST(0.577544987201691), REAL_CONST(0.583090126514435), REAL_CONST(0.584493279457092), REAL_CONST(0.584845066070557) }, + { REAL_CONST(0.000088052431238), REAL_CONST(0.000351833587047), REAL_CONST(0.001402696361765), REAL_CONST(0.005538204684854), REAL_CONST(0.021061634644866), REAL_CONST(0.070389263331890), REAL_CONST(0.169925004243851), REAL_CONST(0.263034462928772), REAL_CONST(0.304854571819305), REAL_CONST(0.317482173442841), REAL_CONST(0.320804953575134), REAL_CONST(0.321646571159363), REAL_CONST(0.321857661008835) }, + { REAL_CONST(0.000044026888645), REAL_CONST(0.000175927518285), REAL_CONST(0.000701518612914), REAL_CONST(0.002771759871393), REAL_CONST(0.010569252073765), REAL_CONST(0.035623874515295), REAL_CONST(0.087462842464447), REAL_CONST(0.137503549456596), REAL_CONST(0.160464659333229), REAL_CONST(0.167456731200218), REAL_CONST(0.169301137328148), REAL_CONST(0.169768601655960), REAL_CONST(0.169885858893394) }, + { REAL_CONST(0.000022013611670), REAL_CONST(0.000088052431238), REAL_CONST(0.000350801943569), REAL_CONST(0.001386545598507), REAL_CONST(0.005294219125062), REAL_CONST(0.017921976745129), REAL_CONST(0.044394120573997), REAL_CONST(0.070389263331890), REAL_CONST(0.082462236285210), REAL_CONST(0.086156636476517), REAL_CONST(0.087132595479488), REAL_CONST(0.087379962205887), REAL_CONST(0.087442122399807) }, + { REAL_CONST(0.000011006847672), REAL_CONST(0.000044026888645), REAL_CONST(0.000175411638338), REAL_CONST(0.000693439331371), REAL_CONST(0.002649537986144), REAL_CONST(0.008988817222416), REAL_CONST(0.022367812693119), REAL_CONST(0.035623874515295), REAL_CONST(0.041820213198662), REAL_CONST(0.043721374124289), REAL_CONST(0.044224001467228), REAL_CONST(0.044351425021887), REAL_CONST(0.044383447617292) }, + { REAL_CONST(0.000005503434295), REAL_CONST(0.000022013611670), REAL_CONST(0.000087708482170), REAL_CONST(0.000346675369656), REAL_CONST(0.001325377263129), REAL_CONST(0.004501323681325), REAL_CONST(0.011227255687118), REAL_CONST(0.017921976745129), REAL_CONST(0.021061634644866), REAL_CONST(0.022026389837265), REAL_CONST(0.022281449288130), REAL_CONST(0.022346137091517), REAL_CONST(0.022362394258380) }, + { REAL_CONST(0.000002751719876), REAL_CONST(0.000011006847672), REAL_CONST(0.000043854910473), REAL_CONST(0.000173348103999), REAL_CONST(0.000662840844598), REAL_CONST(0.002252417383716), REAL_CONST(0.005624548997730), REAL_CONST(0.008988817222416), REAL_CONST(0.010569252073765), REAL_CONST(0.011055230163038), REAL_CONST(0.011183738708496), REAL_CONST(0.011216334067285), REAL_CONST(0.011224525049329) }, + { REAL_CONST(0.000001375860506), REAL_CONST(0.000005503434295), REAL_CONST(0.000022013611670), REAL_CONST(0.000086676649516), REAL_CONST(0.000331544462824), REAL_CONST(0.001126734190620), REAL_CONST(0.002815015614033), REAL_CONST(0.004501323681325), REAL_CONST(0.005294219125062), REAL_CONST(0.005538204684854), REAL_CONST(0.005602621007711), REAL_CONST(0.005619067233056), REAL_CONST(0.005623178556561) }, + { REAL_CONST(0.000000687930424), REAL_CONST(0.000002751719876), REAL_CONST(0.000011006847672), REAL_CONST(0.000043338975956), REAL_CONST(0.000165781748365), REAL_CONST(0.000563477107789), REAL_CONST(0.001408194424585), REAL_CONST(0.002252417383716), REAL_CONST(0.002649537986144), REAL_CONST(0.002771759871393), REAL_CONST(0.002804030198604), REAL_CONST(0.002812269143760), REAL_CONST(0.002814328996465) }, + { REAL_CONST(0.000000343965269), REAL_CONST(0.000001375860506), REAL_CONST(0.000005503434295), REAL_CONST(0.000021669651687), REAL_CONST(0.000082893253420), REAL_CONST(0.000281680084299), REAL_CONST(0.000704268983100), REAL_CONST(0.001126734190620), REAL_CONST(0.001325377263129), REAL_CONST(0.001386545598507), REAL_CONST(0.001402696361765), REAL_CONST(0.001406819908880), REAL_CONST(0.001407850766554) }, + { REAL_CONST(0.000000171982634), REAL_CONST(0.000000687930424), REAL_CONST(0.000002751719876), REAL_CONST(0.000010834866771), REAL_CONST(0.000041447223339), REAL_CONST(0.000140846910654), REAL_CONST(0.000352177477907), REAL_CONST(0.000563477107789), REAL_CONST(0.000662840844598), REAL_CONST(0.000693439331371), REAL_CONST(0.000701518612914), REAL_CONST(0.000703581434209), REAL_CONST(0.000704097095877) }, + { REAL_CONST(0.000000000000000), REAL_CONST(0.000000343965269), REAL_CONST(0.000001375860506), REAL_CONST(0.000005503434295), REAL_CONST(0.000020637769921), REAL_CONST(0.000070511166996), REAL_CONST(0.000176099492819), REAL_CONST(0.000281680084299), REAL_CONST(0.000331544462824), REAL_CONST(0.000346675369656), REAL_CONST(0.000350801943569), REAL_CONST(0.000351833587047), REAL_CONST(0.000352177477907) }, + { REAL_CONST(0.000000000000000), REAL_CONST(0.000000171982634), REAL_CONST(0.000000687930424), REAL_CONST(0.000002751719876), REAL_CONST(0.000010318922250), REAL_CONST(0.000035256012779), REAL_CONST(0.000088052431238), REAL_CONST(0.000140846910654), REAL_CONST(0.000165781748365), REAL_CONST(0.000173348103999), REAL_CONST(0.000175411638338), REAL_CONST(0.000175927518285), REAL_CONST(0.000176099492819) }, + { REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000343965269), REAL_CONST(0.000001375860506), REAL_CONST(0.000005159470220), REAL_CONST(0.000017542124624), REAL_CONST(0.000044026888645), REAL_CONST(0.000070511166996), REAL_CONST(0.000082893253420), REAL_CONST(0.000086676649516), REAL_CONST(0.000087708482170), REAL_CONST(0.000088052431238), REAL_CONST(0.000088052431238) }, + { REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000171982634), REAL_CONST(0.000000687930424), REAL_CONST(0.000002579737384), REAL_CONST(0.000008771088687), REAL_CONST(0.000022013611670), REAL_CONST(0.000035256012779), REAL_CONST(0.000041447223339), REAL_CONST(0.000043338975956), REAL_CONST(0.000043854910473), REAL_CONST(0.000044026888645), REAL_CONST(0.000044026888645) }, + { REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000343965269), REAL_CONST(0.000001375860506), REAL_CONST(0.000004471542070), REAL_CONST(0.000011006847672), REAL_CONST(0.000017542124624), REAL_CONST(0.000020637769921), REAL_CONST(0.000021669651687), REAL_CONST(0.000022013611670), REAL_CONST(0.000022013611670), REAL_CONST(0.000022013611670) }, + { REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000171982634), REAL_CONST(0.000000687930424), REAL_CONST(0.000002235772627), REAL_CONST(0.000005503434295), REAL_CONST(0.000008771088687), REAL_CONST(0.000010318922250), REAL_CONST(0.000010834866771), REAL_CONST(0.000011006847672), REAL_CONST(0.000011006847672), REAL_CONST(0.000011006847672) }, + { REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000343965269), REAL_CONST(0.000001031895522), REAL_CONST(0.000002751719876), REAL_CONST(0.000004471542070), REAL_CONST(0.000005159470220), REAL_CONST(0.000005503434295), REAL_CONST(0.000005503434295), REAL_CONST(0.000005503434295), REAL_CONST(0.000005503434295) }, + { REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000171982634), REAL_CONST(0.000000515947875), REAL_CONST(0.000001375860506), REAL_CONST(0.000002235772627), REAL_CONST(0.000002579737384), REAL_CONST(0.000002751719876), REAL_CONST(0.000002751719876), REAL_CONST(0.000002751719876), REAL_CONST(0.000002751719876) }, + { REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000343965269), REAL_CONST(0.000000687930424), REAL_CONST(0.000001031895522), REAL_CONST(0.000001375860506), REAL_CONST(0.000001375860506), REAL_CONST(0.000001375860506), REAL_CONST(0.000001375860506), REAL_CONST(0.000001375860506) }, + { REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000171982634), REAL_CONST(0.000000343965269), REAL_CONST(0.000000515947875), REAL_CONST(0.000000687930424), REAL_CONST(0.000000687930424), REAL_CONST(0.000000687930424), REAL_CONST(0.000000687930424), REAL_CONST(0.000000687930424) }, + { REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000171982634), REAL_CONST(0.000000343965269), REAL_CONST(0.000000343965269), REAL_CONST(0.000000343965269), REAL_CONST(0.000000343965269), REAL_CONST(0.000000343965269), REAL_CONST(0.000000343965269) }, + { REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000171982634), REAL_CONST(0.000000171982634), REAL_CONST(0.000000171982634), REAL_CONST(0.000000171982634), REAL_CONST(0.000000171982634), REAL_CONST(0.000000171982634) } +}; + +static const real_t log_Qplus1[31] = { + REAL_CONST(6.022367813028454), REAL_CONST(5.044394119358453), REAL_CONST(4.087462841250339), + REAL_CONST(3.169925001442313), REAL_CONST(2.321928094887362), REAL_CONST(1.584962500721156), + REAL_CONST(1.000000000000000), REAL_CONST(0.584962500721156), REAL_CONST(0.321928094887362), + REAL_CONST(0.169925001442312), REAL_CONST(0.087462841250339), REAL_CONST(0.044394119358453), + REAL_CONST(0.022367813028455), REAL_CONST(0.011227255423254), REAL_CONST(0.005624549193878), + REAL_CONST(0.002815015607054), REAL_CONST(0.001408194392808), REAL_CONST(0.000704269011247), + REAL_CONST(0.000352177480301), REAL_CONST(0.000176099486443), REAL_CONST(0.000088052430122), + REAL_CONST(0.000044026886827), REAL_CONST(0.000022013611360), REAL_CONST(0.000011006847667), + REAL_CONST(0.000005503434331), REAL_CONST(0.000002751719790), REAL_CONST(0.000001375860551), + REAL_CONST(0.000000687930439), REAL_CONST(0.000000343965261), REAL_CONST(0.000000171982641), + REAL_CONST(0.000000000000000) +}; + +static real_t find_log2_Qplus1(sbr_info *sbr, uint8_t k, uint8_t l, uint8_t ch) +{ + /* check for coupled energy/noise data */ + if (sbr->bs_coupling == 1) + { + if ((sbr->Q[0][k][l] >= 0) && (sbr->Q[0][k][l] <= 30) && + (sbr->Q[1][k][l] >= 0) && (sbr->Q[1][k][l] <= 24)) + { + if (ch == 0) + { + return log_Qplus1_pan[sbr->Q[0][k][l]][sbr->Q[1][k][l] >> 1]; + } else { + return log_Qplus1_pan[sbr->Q[0][k][l]][12 - (sbr->Q[1][k][l] >> 1)]; + } + } else { + return 0; + } + } else { + if (sbr->Q[ch][k][l] >= 0 && sbr->Q[ch][k][l] <= 30) + { + return log_Qplus1[sbr->Q[ch][k][l]]; + } else { + return 0; + } + } +} + +static void calculate_gain(sbr_info *sbr, sbr_hfadj_info *adj, uint8_t ch) +{ + /* log2 values of limiter gains */ + static real_t limGain[] = { + REAL_CONST(-1.0), REAL_CONST(0.0), REAL_CONST(1.0), REAL_CONST(33.219) + }; + uint8_t m, l, k; + + uint8_t current_t_noise_band = 0; + uint8_t S_mapped; + + real_t Q_M_lim[MAX_M] MEM_ALIGN_ATTR; + real_t G_lim[MAX_M] MEM_ALIGN_ATTR; + real_t G_boost MEM_ALIGN_ATTR; + real_t S_M[MAX_M] MEM_ALIGN_ATTR; + + for (l = 0; l < sbr->L_E[ch]; l++) + { + uint8_t current_f_noise_band = 0; + uint8_t current_res_band = 0; + uint8_t current_res_band2 = 0; + uint8_t current_hi_res_band = 0; + + real_t delta = (l == sbr->l_A[ch] || l == sbr->prevEnvIsShort[ch]) ? 0 : 1; + + S_mapped = get_S_mapped(sbr, ch, l, current_res_band2); + + if (sbr->t_E[ch][l+1] > sbr->t_Q[ch][current_t_noise_band+1]) + { + current_t_noise_band++; + } + + for (k = 0; k < sbr->N_L[sbr->bs_limiter_bands]; k++) + { + real_t Q_M = 0; + real_t G_max; + real_t den = 0; + real_t acc1 = 0; + real_t acc2 = 0; + uint8_t current_res_band_size = 0; + uint8_t Q_M_size = 0; + + uint8_t ml1, ml2; + + /* bounds of current limiter bands */ + ml1 = sbr->f_table_lim[sbr->bs_limiter_bands][k]; + ml2 = sbr->f_table_lim[sbr->bs_limiter_bands][k+1]; + + + /* calculate the accumulated E_orig and E_curr over the limiter band */ + for (m = ml1; m < ml2; m++) + { + if ((m + sbr->kx) < sbr->f_table_res[sbr->f[ch][l]][current_res_band+1]) + { + current_res_band_size++; + } else { + acc1 += pow2_int(-REAL_CONST(10) + log2_int_tab[current_res_band_size] + find_log2_E(sbr, current_res_band, l, ch)); + + current_res_band++; + current_res_band_size = 1; + } + + acc2 += sbr->E_curr[ch][m][l]; + } + acc1 += pow2_int(-REAL_CONST(10) + log2_int_tab[current_res_band_size] + find_log2_E(sbr, current_res_band, l, ch)); + + + if (acc1 == 0) + acc1 = LOG2_MIN_INF; + else + acc1 = log2_int(acc1); + + + /* calculate the maximum gain */ + /* ratio of the energy of the original signal and the energy + * of the HF generated signal + */ + G_max = acc1 - log2_int(acc2) + limGain[sbr->bs_limiter_gains]; + G_max = min(G_max, limGain[3]); + + + for (m = ml1; m < ml2; m++) + { + real_t G; + real_t E_curr, E_orig; + real_t Q_orig, Q_orig_plus1; + uint8_t S_index_mapped; + + + /* check if m is on a noise band border */ + if ((m + sbr->kx) == sbr->f_table_noise[current_f_noise_band+1]) + { + /* step to next noise band */ + current_f_noise_band++; + } + + + /* check if m is on a resolution band border */ + if ((m + sbr->kx) == sbr->f_table_res[sbr->f[ch][l]][current_res_band2+1]) + { + /* accumulate a whole range of equal Q_Ms */ + if (Q_M_size > 0) + den += pow2_int(log2_int_tab[Q_M_size] + Q_M); + Q_M_size = 0; + + /* step to next resolution band */ + current_res_band2++; + + /* if we move to a new resolution band, we should check if we are + * going to add a sinusoid in this band + */ + S_mapped = get_S_mapped(sbr, ch, l, current_res_band2); + } + + + /* check if m is on a HI_RES band border */ + if ((m + sbr->kx) == sbr->f_table_res[HI_RES][current_hi_res_band+1]) + { + /* step to next HI_RES band */ + current_hi_res_band++; + } + + + /* find S_index_mapped + * S_index_mapped can only be 1 for the m in the middle of the + * current HI_RES band + */ + S_index_mapped = 0; + if ((l >= sbr->l_A[ch]) || + (sbr->bs_add_harmonic_prev[ch][current_hi_res_band] && sbr->bs_add_harmonic_flag_prev[ch])) + { + /* find the middle subband of the HI_RES frequency band */ + if ((m + sbr->kx) == (sbr->f_table_res[HI_RES][current_hi_res_band+1] + sbr->f_table_res[HI_RES][current_hi_res_band]) >> 1) + S_index_mapped = sbr->bs_add_harmonic[ch][current_hi_res_band]; + } + + + /* find bitstream parameters */ + if (sbr->E_curr[ch][m][l] == 0) + E_curr = LOG2_MIN_INF; + else + E_curr = log2_int(sbr->E_curr[ch][m][l]); + E_orig = -REAL_CONST(10) + find_log2_E(sbr, current_res_band2, l, ch); + + + Q_orig = find_log2_Q(sbr, current_f_noise_band, current_t_noise_band, ch); + Q_orig_plus1 = find_log2_Qplus1(sbr, current_f_noise_band, current_t_noise_band, ch); + + + /* Q_M only depends on E_orig and Q_div2: + * since N_Q <= N_Low <= N_High we only need to recalculate Q_M on + * a change of current res band (HI or LO) + */ + Q_M = E_orig + Q_orig - Q_orig_plus1; + + + /* S_M only depends on E_orig, Q_div and S_index_mapped: + * S_index_mapped can only be non-zero once per HI_RES band + */ + if (S_index_mapped == 0) + { + S_M[m] = LOG2_MIN_INF; /* -inf */ + } else { + S_M[m] = E_orig - Q_orig_plus1; + + /* accumulate sinusoid part of the total energy */ + den += pow2_int(S_M[m]); + } + + + /* calculate gain */ + /* ratio of the energy of the original signal and the energy + * of the HF generated signal + */ + /* E_curr here is officially E_curr+1 so the log2() of that can never be < 0 */ + /* scaled by -10 */ + G = E_orig - max(-REAL_CONST(10), E_curr); + if ((S_mapped == 0) && (delta == 1)) + { + /* G = G * 1/(1+Q) */ + G -= Q_orig_plus1; + } else if (S_mapped == 1) { + /* G = G * Q/(1+Q) */ + G += Q_orig - Q_orig_plus1; + } + + + /* limit the additional noise energy level */ + /* and apply the limiter */ + if (G_max > G) + { + Q_M_lim[m] = Q_M; + G_lim[m] = G; + + if ((S_index_mapped == 0) && (l != sbr->l_A[ch])) + { + Q_M_size++; + } + } else { + /* G > G_max */ + Q_M_lim[m] = Q_M + G_max - G; + G_lim[m] = G_max; + + /* accumulate limited Q_M */ + if ((S_index_mapped == 0) && (l != sbr->l_A[ch])) + { + den += pow2_int(Q_M_lim[m]); + } + } + + + /* accumulate the total energy */ + /* E_curr changes for every m so we do need to accumulate every m */ + den += pow2_int(E_curr + G_lim[m]); + } + + /* accumulate last range of equal Q_Ms */ + if (Q_M_size > 0) + { + den += pow2_int(log2_int_tab[Q_M_size] + Q_M); + } + + + /* calculate the final gain */ + /* G_boost: [0..2.51188643] */ + G_boost = acc1 - log2_int(den /*+ EPS*/); + G_boost = min(G_boost, REAL_CONST(1.328771237) /* log2(1.584893192 ^ 2) */); + + + for (m = ml1; m < ml2; m++) + { + /* apply compensation to gain, noise floor sf's and sinusoid levels */ +#ifndef SBR_LOW_POWER + adj->G_lim_boost[l][m] = pow2_fix((G_lim[m] + G_boost) >> 1); +#else + /* sqrt() will be done after the aliasing reduction to save a + * few multiplies + */ + adj->G_lim_boost[l][m] = pow2_fix(G_lim[m] + G_boost); +#endif + adj->Q_M_lim_boost[l][m] = pow2_fix((Q_M_lim[m] + G_boost) >> 1); + + if (S_M[m] != LOG2_MIN_INF) + { + adj->S_M_boost[l][m] = pow2_int((S_M[m] + G_boost) >> 1); + } else { + adj->S_M_boost[l][m] = 0; + } + } + } + } +} + +#else + +//#define LOG2_TEST + +#ifdef LOG2_TEST + +#define LOG2_MIN_INF -100000 + +__inline float pow2(float val) +{ + return pow(2.0, val); +} +__inline float log2(float val) +{ + return log(val)/log(2.0); +} + +#define RB 14 + +float QUANTISE2REAL(float val) +{ + __int32 ival = (__int32)(val * (1<bs_coupling == 1) + { + real_t amp0 = (sbr->amp_res[0]) ? 1.0 : 0.5; + real_t amp1 = (sbr->amp_res[1]) ? 1.0 : 0.5; + float tmp = QUANTISE2REAL(7.0 + (real_t)sbr->E[0][k][l] * amp0); + float pan; + + int E = (int)(sbr->E[1][k][l] * amp1); + + if (ch == 0) + { + if (E > 12) + { + /* negative */ + pan = QUANTISE2REAL(pan_log2_tab[-12 + E]); + } else { + /* positive */ + pan = QUANTISE2REAL(pan_log2_tab[12 - E] + (12 - E)); + } + } else { + if (E < 12) + { + /* negative */ + pan = QUANTISE2REAL(pan_log2_tab[-E + 12]); + } else { + /* positive */ + pan = QUANTISE2REAL(pan_log2_tab[E - 12] + (E - 12)); + } + } + + /* tmp / pan in log2 */ + return QUANTISE2REAL(tmp - pan); + } else { + real_t amp = (sbr->amp_res[ch]) ? 1.0 : 0.5; + + return QUANTISE2REAL(6.0 + (real_t)sbr->E[ch][k][l] * amp); + } +} + +static real_t find_log2_Q(sbr_info *sbr, uint8_t k, uint8_t l, uint8_t ch) +{ + /* check for coupled energy/noise data */ + if (sbr->bs_coupling == 1) + { + float tmp = QUANTISE2REAL(7.0 - (real_t)sbr->Q[0][k][l]); + float pan; + + int Q = (int)(sbr->Q[1][k][l]); + + if (ch == 0) + { + if (Q > 12) + { + /* negative */ + pan = QUANTISE2REAL(pan_log2_tab[-12 + Q]); + } else { + /* positive */ + pan = QUANTISE2REAL(pan_log2_tab[12 - Q] + (12 - Q)); + } + } else { + if (Q < 12) + { + /* negative */ + pan = QUANTISE2REAL(pan_log2_tab[-Q + 12]); + } else { + /* positive */ + pan = QUANTISE2REAL(pan_log2_tab[Q - 12] + (Q - 12)); + } + } + + /* tmp / pan in log2 */ + return QUANTISE2REAL(tmp - pan); + } else { + return QUANTISE2REAL(6.0 - (real_t)sbr->Q[ch][k][l]); + } +} + +static const real_t log_Qplus1_pan[31][13] = { + { REAL_CONST(0.044383447617292), REAL_CONST(0.169768601655960), REAL_CONST(0.583090126514435), REAL_CONST(1.570089221000671), REAL_CONST(3.092446088790894), REAL_CONST(4.733354568481445), REAL_CONST(6.022367954254150), REAL_CONST(6.692092418670654), REAL_CONST(6.924463272094727), REAL_CONST(6.989034175872803), REAL_CONST(7.005646705627441), REAL_CONST(7.009829998016357), REAL_CONST(7.010877609252930) }, + { REAL_CONST(0.022362394258380), REAL_CONST(0.087379962205887), REAL_CONST(0.320804953575134), REAL_CONST(0.988859415054321), REAL_CONST(2.252387046813965), REAL_CONST(3.786596298217773), REAL_CONST(5.044394016265869), REAL_CONST(5.705977916717529), REAL_CONST(5.936291694641113), REAL_CONST(6.000346660614014), REAL_CONST(6.016829967498779), REAL_CONST(6.020981311798096), REAL_CONST(6.022020816802979) }, + { REAL_CONST(0.011224525049329), REAL_CONST(0.044351425021887), REAL_CONST(0.169301137328148), REAL_CONST(0.577544987201691), REAL_CONST(1.527246952056885), REAL_CONST(2.887525320053101), REAL_CONST(4.087462902069092), REAL_CONST(4.733354568481445), REAL_CONST(4.959661006927490), REAL_CONST(5.022709369659424), REAL_CONST(5.038940429687500), REAL_CONST(5.043028831481934), REAL_CONST(5.044052600860596) }, + { REAL_CONST(0.005623178556561), REAL_CONST(0.022346137091517), REAL_CONST(0.087132595479488), REAL_CONST(0.317482173442841), REAL_CONST(0.956931233406067), REAL_CONST(2.070389270782471), REAL_CONST(3.169924974441528), REAL_CONST(3.786596298217773), REAL_CONST(4.005294322967529), REAL_CONST(4.066420555114746), REAL_CONST(4.082170009613037), REAL_CONST(4.086137294769287), REAL_CONST(4.087131500244141) }, + { REAL_CONST(0.002814328996465), REAL_CONST(0.011216334067285), REAL_CONST(0.044224001467228), REAL_CONST(0.167456731200218), REAL_CONST(0.556393325328827), REAL_CONST(1.378511548042297), REAL_CONST(2.321928024291992), REAL_CONST(2.887525320053101), REAL_CONST(3.092446088790894), REAL_CONST(3.150059700012207), REAL_CONST(3.164926528930664), REAL_CONST(3.168673276901245), REAL_CONST(3.169611930847168) }, + { REAL_CONST(0.001407850766554), REAL_CONST(0.005619067233056), REAL_CONST(0.022281449288130), REAL_CONST(0.086156636476517), REAL_CONST(0.304854571819305), REAL_CONST(0.847996890544891), REAL_CONST(1.584962487220764), REAL_CONST(2.070389270782471), REAL_CONST(2.252387046813965), REAL_CONST(2.304061651229858), REAL_CONST(2.317430257797241), REAL_CONST(2.320801734924316), REAL_CONST(2.321646213531494) }, + { REAL_CONST(0.000704097095877), REAL_CONST(0.002812269143760), REAL_CONST(0.011183738708496), REAL_CONST(0.043721374124289), REAL_CONST(0.160464659333229), REAL_CONST(0.485426813364029), REAL_CONST(1.000000000000000), REAL_CONST(1.378511548042297), REAL_CONST(1.527246952056885), REAL_CONST(1.570089221000671), REAL_CONST(1.581215262413025), REAL_CONST(1.584023833274841), REAL_CONST(1.584727644920349) }, + { REAL_CONST(0.000352177477907), REAL_CONST(0.001406819908880), REAL_CONST(0.005602621007711), REAL_CONST(0.022026389837265), REAL_CONST(0.082462236285210), REAL_CONST(0.263034462928772), REAL_CONST(0.584962487220764), REAL_CONST(0.847996890544891), REAL_CONST(0.956931233406067), REAL_CONST(0.988859415054321), REAL_CONST(0.997190535068512), REAL_CONST(0.999296069145203), REAL_CONST(0.999823868274689) }, + { REAL_CONST(0.000176099492819), REAL_CONST(0.000703581434209), REAL_CONST(0.002804030198604), REAL_CONST(0.011055230163038), REAL_CONST(0.041820213198662), REAL_CONST(0.137503549456596), REAL_CONST(0.321928083896637), REAL_CONST(0.485426813364029), REAL_CONST(0.556393325328827), REAL_CONST(0.577544987201691), REAL_CONST(0.583090126514435), REAL_CONST(0.584493279457092), REAL_CONST(0.584845066070557) }, + { REAL_CONST(0.000088052431238), REAL_CONST(0.000351833587047), REAL_CONST(0.001402696361765), REAL_CONST(0.005538204684854), REAL_CONST(0.021061634644866), REAL_CONST(0.070389263331890), REAL_CONST(0.169925004243851), REAL_CONST(0.263034462928772), REAL_CONST(0.304854571819305), REAL_CONST(0.317482173442841), REAL_CONST(0.320804953575134), REAL_CONST(0.321646571159363), REAL_CONST(0.321857661008835) }, + { REAL_CONST(0.000044026888645), REAL_CONST(0.000175927518285), REAL_CONST(0.000701518612914), REAL_CONST(0.002771759871393), REAL_CONST(0.010569252073765), REAL_CONST(0.035623874515295), REAL_CONST(0.087462842464447), REAL_CONST(0.137503549456596), REAL_CONST(0.160464659333229), REAL_CONST(0.167456731200218), REAL_CONST(0.169301137328148), REAL_CONST(0.169768601655960), REAL_CONST(0.169885858893394) }, + { REAL_CONST(0.000022013611670), REAL_CONST(0.000088052431238), REAL_CONST(0.000350801943569), REAL_CONST(0.001386545598507), REAL_CONST(0.005294219125062), REAL_CONST(0.017921976745129), REAL_CONST(0.044394120573997), REAL_CONST(0.070389263331890), REAL_CONST(0.082462236285210), REAL_CONST(0.086156636476517), REAL_CONST(0.087132595479488), REAL_CONST(0.087379962205887), REAL_CONST(0.087442122399807) }, + { REAL_CONST(0.000011006847672), REAL_CONST(0.000044026888645), REAL_CONST(0.000175411638338), REAL_CONST(0.000693439331371), REAL_CONST(0.002649537986144), REAL_CONST(0.008988817222416), REAL_CONST(0.022367812693119), REAL_CONST(0.035623874515295), REAL_CONST(0.041820213198662), REAL_CONST(0.043721374124289), REAL_CONST(0.044224001467228), REAL_CONST(0.044351425021887), REAL_CONST(0.044383447617292) }, + { REAL_CONST(0.000005503434295), REAL_CONST(0.000022013611670), REAL_CONST(0.000087708482170), REAL_CONST(0.000346675369656), REAL_CONST(0.001325377263129), REAL_CONST(0.004501323681325), REAL_CONST(0.011227255687118), REAL_CONST(0.017921976745129), REAL_CONST(0.021061634644866), REAL_CONST(0.022026389837265), REAL_CONST(0.022281449288130), REAL_CONST(0.022346137091517), REAL_CONST(0.022362394258380) }, + { REAL_CONST(0.000002751719876), REAL_CONST(0.000011006847672), REAL_CONST(0.000043854910473), REAL_CONST(0.000173348103999), REAL_CONST(0.000662840844598), REAL_CONST(0.002252417383716), REAL_CONST(0.005624548997730), REAL_CONST(0.008988817222416), REAL_CONST(0.010569252073765), REAL_CONST(0.011055230163038), REAL_CONST(0.011183738708496), REAL_CONST(0.011216334067285), REAL_CONST(0.011224525049329) }, + { REAL_CONST(0.000001375860506), REAL_CONST(0.000005503434295), REAL_CONST(0.000022013611670), REAL_CONST(0.000086676649516), REAL_CONST(0.000331544462824), REAL_CONST(0.001126734190620), REAL_CONST(0.002815015614033), REAL_CONST(0.004501323681325), REAL_CONST(0.005294219125062), REAL_CONST(0.005538204684854), REAL_CONST(0.005602621007711), REAL_CONST(0.005619067233056), REAL_CONST(0.005623178556561) }, + { REAL_CONST(0.000000687930424), REAL_CONST(0.000002751719876), REAL_CONST(0.000011006847672), REAL_CONST(0.000043338975956), REAL_CONST(0.000165781748365), REAL_CONST(0.000563477107789), REAL_CONST(0.001408194424585), REAL_CONST(0.002252417383716), REAL_CONST(0.002649537986144), REAL_CONST(0.002771759871393), REAL_CONST(0.002804030198604), REAL_CONST(0.002812269143760), REAL_CONST(0.002814328996465) }, + { REAL_CONST(0.000000343965269), REAL_CONST(0.000001375860506), REAL_CONST(0.000005503434295), REAL_CONST(0.000021669651687), REAL_CONST(0.000082893253420), REAL_CONST(0.000281680084299), REAL_CONST(0.000704268983100), REAL_CONST(0.001126734190620), REAL_CONST(0.001325377263129), REAL_CONST(0.001386545598507), REAL_CONST(0.001402696361765), REAL_CONST(0.001406819908880), REAL_CONST(0.001407850766554) }, + { REAL_CONST(0.000000171982634), REAL_CONST(0.000000687930424), REAL_CONST(0.000002751719876), REAL_CONST(0.000010834866771), REAL_CONST(0.000041447223339), REAL_CONST(0.000140846910654), REAL_CONST(0.000352177477907), REAL_CONST(0.000563477107789), REAL_CONST(0.000662840844598), REAL_CONST(0.000693439331371), REAL_CONST(0.000701518612914), REAL_CONST(0.000703581434209), REAL_CONST(0.000704097095877) }, + { REAL_CONST(0.000000000000000), REAL_CONST(0.000000343965269), REAL_CONST(0.000001375860506), REAL_CONST(0.000005503434295), REAL_CONST(0.000020637769921), REAL_CONST(0.000070511166996), REAL_CONST(0.000176099492819), REAL_CONST(0.000281680084299), REAL_CONST(0.000331544462824), REAL_CONST(0.000346675369656), REAL_CONST(0.000350801943569), REAL_CONST(0.000351833587047), REAL_CONST(0.000352177477907) }, + { REAL_CONST(0.000000000000000), REAL_CONST(0.000000171982634), REAL_CONST(0.000000687930424), REAL_CONST(0.000002751719876), REAL_CONST(0.000010318922250), REAL_CONST(0.000035256012779), REAL_CONST(0.000088052431238), REAL_CONST(0.000140846910654), REAL_CONST(0.000165781748365), REAL_CONST(0.000173348103999), REAL_CONST(0.000175411638338), REAL_CONST(0.000175927518285), REAL_CONST(0.000176099492819) }, + { REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000343965269), REAL_CONST(0.000001375860506), REAL_CONST(0.000005159470220), REAL_CONST(0.000017542124624), REAL_CONST(0.000044026888645), REAL_CONST(0.000070511166996), REAL_CONST(0.000082893253420), REAL_CONST(0.000086676649516), REAL_CONST(0.000087708482170), REAL_CONST(0.000088052431238), REAL_CONST(0.000088052431238) }, + { REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000171982634), REAL_CONST(0.000000687930424), REAL_CONST(0.000002579737384), REAL_CONST(0.000008771088687), REAL_CONST(0.000022013611670), REAL_CONST(0.000035256012779), REAL_CONST(0.000041447223339), REAL_CONST(0.000043338975956), REAL_CONST(0.000043854910473), REAL_CONST(0.000044026888645), REAL_CONST(0.000044026888645) }, + { REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000343965269), REAL_CONST(0.000001375860506), REAL_CONST(0.000004471542070), REAL_CONST(0.000011006847672), REAL_CONST(0.000017542124624), REAL_CONST(0.000020637769921), REAL_CONST(0.000021669651687), REAL_CONST(0.000022013611670), REAL_CONST(0.000022013611670), REAL_CONST(0.000022013611670) }, + { REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000171982634), REAL_CONST(0.000000687930424), REAL_CONST(0.000002235772627), REAL_CONST(0.000005503434295), REAL_CONST(0.000008771088687), REAL_CONST(0.000010318922250), REAL_CONST(0.000010834866771), REAL_CONST(0.000011006847672), REAL_CONST(0.000011006847672), REAL_CONST(0.000011006847672) }, + { REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000343965269), REAL_CONST(0.000001031895522), REAL_CONST(0.000002751719876), REAL_CONST(0.000004471542070), REAL_CONST(0.000005159470220), REAL_CONST(0.000005503434295), REAL_CONST(0.000005503434295), REAL_CONST(0.000005503434295), REAL_CONST(0.000005503434295) }, + { REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000171982634), REAL_CONST(0.000000515947875), REAL_CONST(0.000001375860506), REAL_CONST(0.000002235772627), REAL_CONST(0.000002579737384), REAL_CONST(0.000002751719876), REAL_CONST(0.000002751719876), REAL_CONST(0.000002751719876), REAL_CONST(0.000002751719876) }, + { REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000343965269), REAL_CONST(0.000000687930424), REAL_CONST(0.000001031895522), REAL_CONST(0.000001375860506), REAL_CONST(0.000001375860506), REAL_CONST(0.000001375860506), REAL_CONST(0.000001375860506), REAL_CONST(0.000001375860506) }, + { REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000171982634), REAL_CONST(0.000000343965269), REAL_CONST(0.000000515947875), REAL_CONST(0.000000687930424), REAL_CONST(0.000000687930424), REAL_CONST(0.000000687930424), REAL_CONST(0.000000687930424), REAL_CONST(0.000000687930424) }, + { REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000171982634), REAL_CONST(0.000000343965269), REAL_CONST(0.000000343965269), REAL_CONST(0.000000343965269), REAL_CONST(0.000000343965269), REAL_CONST(0.000000343965269), REAL_CONST(0.000000343965269) }, + { REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000000000000), REAL_CONST(0.000000171982634), REAL_CONST(0.000000171982634), REAL_CONST(0.000000171982634), REAL_CONST(0.000000171982634), REAL_CONST(0.000000171982634), REAL_CONST(0.000000171982634) } +}; + +static const real_t log_Qplus1[31] = { + REAL_CONST(6.022367813028454), REAL_CONST(5.044394119358453), REAL_CONST(4.087462841250339), + REAL_CONST(3.169925001442313), REAL_CONST(2.321928094887362), REAL_CONST(1.584962500721156), + REAL_CONST(1.000000000000000), REAL_CONST(0.584962500721156), REAL_CONST(0.321928094887362), + REAL_CONST(0.169925001442312), REAL_CONST(0.087462841250339), REAL_CONST(0.044394119358453), + REAL_CONST(0.022367813028455), REAL_CONST(0.011227255423254), REAL_CONST(0.005624549193878), + REAL_CONST(0.002815015607054), REAL_CONST(0.001408194392808), REAL_CONST(0.000704269011247), + REAL_CONST(0.000352177480301), REAL_CONST(0.000176099486443), REAL_CONST(0.000088052430122), + REAL_CONST(0.000044026886827), REAL_CONST(0.000022013611360), REAL_CONST(0.000011006847667), + REAL_CONST(0.000005503434331), REAL_CONST(0.000002751719790), REAL_CONST(0.000001375860551), + REAL_CONST(0.000000687930439), REAL_CONST(0.000000343965261), REAL_CONST(0.000000171982641), + REAL_CONST(0.000000000000000) +}; + +static real_t find_log2_Qplus1(sbr_info *sbr, uint8_t k, uint8_t l, uint8_t ch) +{ + /* check for coupled energy/noise data */ + if (sbr->bs_coupling == 1) + { + if ((sbr->Q[0][k][l] >= 0) && (sbr->Q[0][k][l] <= 30) && + (sbr->Q[1][k][l] >= 0) && (sbr->Q[1][k][l] <= 24)) + { + if (ch == 0) + { + return QUANTISE2REAL(log_Qplus1_pan[sbr->Q[0][k][l]][sbr->Q[1][k][l] >> 1]); + } else { + return QUANTISE2REAL(log_Qplus1_pan[sbr->Q[0][k][l]][12 - (sbr->Q[1][k][l] >> 1)]); + } + } else { + return 0; + } + } else { + if (sbr->Q[ch][k][l] >= 0 && sbr->Q[ch][k][l] <= 30) + { + return QUANTISE2REAL(log_Qplus1[sbr->Q[ch][k][l]]); + } else { + return 0; + } + } +} + +static void calculate_gain(sbr_info *sbr, sbr_hfadj_info *adj, uint8_t ch) +{ + /* log2 values of limiter gains */ + static real_t limGain[] = { -1.0, 0.0, 1.0, 33.219 }; + uint8_t m, l, k; + + uint8_t current_t_noise_band = 0; + uint8_t S_mapped; + + real_t Q_M_lim[MAX_M] MEM_ALIGN_ATTR; + real_t G_lim[MAX_M] MEM_ALIGN_ATTR; + real_t G_boost MEM_ALIGN_ATTR; + real_t S_M[MAX_M] MEM_ALIGN_ATTR; + + for (l = 0; l < sbr->L_E[ch]; l++) + { + uint8_t current_f_noise_band = 0; + uint8_t current_res_band = 0; + uint8_t current_res_band2 = 0; + uint8_t current_hi_res_band = 0; + + real_t delta = (l == sbr->l_A[ch] || l == sbr->prevEnvIsShort[ch]) ? 0 : 1; + + S_mapped = get_S_mapped(sbr, ch, l, current_res_band2); + + if (sbr->t_E[ch][l+1] > sbr->t_Q[ch][current_t_noise_band+1]) + { + current_t_noise_band++; + } + + for (k = 0; k < sbr->N_L[sbr->bs_limiter_bands]; k++) + { + real_t Q_M = 0; + real_t G_max; + real_t den = 0; + real_t acc1 = 0; + real_t acc2 = 0; + uint8_t current_res_band_size = 0; + uint8_t Q_M_size = 0; + + uint8_t ml1, ml2; + + /* bounds of current limiter bands */ + ml1 = sbr->f_table_lim[sbr->bs_limiter_bands][k]; + ml2 = sbr->f_table_lim[sbr->bs_limiter_bands][k+1]; + + + /* calculate the accumulated E_orig and E_curr over the limiter band */ + for (m = ml1; m < ml2; m++) + { + if ((m + sbr->kx) < sbr->f_table_res[sbr->f[ch][l]][current_res_band+1]) + { + current_res_band_size++; + } else { + acc1 += QUANTISE2INT(pow2(-10 + log2_int_tab[current_res_band_size] + find_log2_E(sbr, current_res_band, l, ch))); + + current_res_band++; + current_res_band_size = 1; + } + + acc2 += QUANTISE2INT(sbr->E_curr[ch][m][l]/1024.0); + } + acc1 += QUANTISE2INT(pow2(-10 + log2_int_tab[current_res_band_size] + find_log2_E(sbr, current_res_band, l, ch))); + + acc1 = QUANTISE2REAL( log2(EPS + acc1) ); + + + /* calculate the maximum gain */ + /* ratio of the energy of the original signal and the energy + * of the HF generated signal + */ + G_max = acc1 - QUANTISE2REAL(log2(EPS + acc2)) + QUANTISE2REAL(limGain[sbr->bs_limiter_gains]); + G_max = min(G_max, QUANTISE2REAL(limGain[3])); + + + for (m = ml1; m < ml2; m++) + { + real_t G; + real_t E_curr, E_orig; + real_t Q_orig, Q_orig_plus1; + uint8_t S_index_mapped; + + + /* check if m is on a noise band border */ + if ((m + sbr->kx) == sbr->f_table_noise[current_f_noise_band+1]) + { + /* step to next noise band */ + current_f_noise_band++; + } + + + /* check if m is on a resolution band border */ + if ((m + sbr->kx) == sbr->f_table_res[sbr->f[ch][l]][current_res_band2+1]) + { + /* accumulate a whole range of equal Q_Ms */ + if (Q_M_size > 0) + den += QUANTISE2INT(pow2(log2_int_tab[Q_M_size] + Q_M)); + Q_M_size = 0; + + /* step to next resolution band */ + current_res_band2++; + + /* if we move to a new resolution band, we should check if we are + * going to add a sinusoid in this band + */ + S_mapped = get_S_mapped(sbr, ch, l, current_res_band2); + } + + + /* check if m is on a HI_RES band border */ + if ((m + sbr->kx) == sbr->f_table_res[HI_RES][current_hi_res_band+1]) + { + /* step to next HI_RES band */ + current_hi_res_band++; + } + + + /* find S_index_mapped + * S_index_mapped can only be 1 for the m in the middle of the + * current HI_RES band + */ + S_index_mapped = 0; + if ((l >= sbr->l_A[ch]) || + (sbr->bs_add_harmonic_prev[ch][current_hi_res_band] && sbr->bs_add_harmonic_flag_prev[ch])) + { + /* find the middle subband of the HI_RES frequency band */ + if ((m + sbr->kx) == (sbr->f_table_res[HI_RES][current_hi_res_band+1] + sbr->f_table_res[HI_RES][current_hi_res_band]) >> 1) + S_index_mapped = sbr->bs_add_harmonic[ch][current_hi_res_band]; + } + + + /* find bitstream parameters */ + if (sbr->E_curr[ch][m][l] == 0) + E_curr = LOG2_MIN_INF; + else + E_curr = -10 + log2(sbr->E_curr[ch][m][l]); + E_orig = -10 + find_log2_E(sbr, current_res_band2, l, ch); + + Q_orig = find_log2_Q(sbr, current_f_noise_band, current_t_noise_band, ch); + Q_orig_plus1 = find_log2_Qplus1(sbr, current_f_noise_band, current_t_noise_band, ch); + + + /* Q_M only depends on E_orig and Q_div2: + * since N_Q <= N_Low <= N_High we only need to recalculate Q_M on + * a change of current res band (HI or LO) + */ + Q_M = E_orig + Q_orig - Q_orig_plus1; + + + /* S_M only depends on E_orig, Q_div and S_index_mapped: + * S_index_mapped can only be non-zero once per HI_RES band + */ + if (S_index_mapped == 0) + { + S_M[m] = LOG2_MIN_INF; /* -inf */ + } else { + S_M[m] = E_orig - Q_orig_plus1; + + /* accumulate sinusoid part of the total energy */ + den += pow2(S_M[m]); + } + + + /* calculate gain */ + /* ratio of the energy of the original signal and the energy + * of the HF generated signal + */ + /* E_curr here is officially E_curr+1 so the log2() of that can never be < 0 */ + /* scaled by -10 */ + G = E_orig - max(-10, E_curr); + if ((S_mapped == 0) && (delta == 1)) + { + /* G = G * 1/(1+Q) */ + G -= Q_orig_plus1; + } else if (S_mapped == 1) { + /* G = G * Q/(1+Q) */ + G += Q_orig - Q_orig_plus1; + } + + + /* limit the additional noise energy level */ + /* and apply the limiter */ + if (G_max > G) + { + Q_M_lim[m] = QUANTISE2REAL(Q_M); + G_lim[m] = QUANTISE2REAL(G); + + if ((S_index_mapped == 0) && (l != sbr->l_A[ch])) + { + Q_M_size++; + } + } else { + /* G > G_max */ + Q_M_lim[m] = QUANTISE2REAL(Q_M) + G_max - QUANTISE2REAL(G); + G_lim[m] = G_max; + + /* accumulate limited Q_M */ + if ((S_index_mapped == 0) && (l != sbr->l_A[ch])) + { + den += QUANTISE2INT(pow2(Q_M_lim[m])); + } + } + + + /* accumulate the total energy */ + /* E_curr changes for every m so we do need to accumulate every m */ + den += QUANTISE2INT(pow2(E_curr + G_lim[m])); + } + + /* accumulate last range of equal Q_Ms */ + if (Q_M_size > 0) + { + den += QUANTISE2INT(pow2(log2_int_tab[Q_M_size] + Q_M)); + } + + + /* calculate the final gain */ + /* G_boost: [0..2.51188643] */ + G_boost = acc1 - QUANTISE2REAL(log2(den + EPS)); + G_boost = min(G_boost, QUANTISE2REAL(1.328771237) /* log2(1.584893192 ^ 2) */); + + + for (m = ml1; m < ml2; m++) + { + /* apply compensation to gain, noise floor sf's and sinusoid levels */ +#ifndef SBR_LOW_POWER + adj->G_lim_boost[l][m] = QUANTISE2REAL(pow2((G_lim[m] + G_boost) / 2.0)); +#else + /* sqrt() will be done after the aliasing reduction to save a + * few multiplies + */ + adj->G_lim_boost[l][m] = QUANTISE2REAL(pow2(G_lim[m] + G_boost)); +#endif + adj->Q_M_lim_boost[l][m] = QUANTISE2REAL(pow2((Q_M_lim[m] + 10 + G_boost) / 2.0)); + + if (S_M[m] != LOG2_MIN_INF) + { + adj->S_M_boost[l][m] = QUANTISE2REAL(pow2((S_M[m] + 10 + G_boost) / 2.0)); + } else { + adj->S_M_boost[l][m] = 0; + } + } + } + } +} + +#else + +static void calculate_gain(sbr_info *sbr, sbr_hfadj_info *adj, uint8_t ch) +{ + static real_t limGain[] = { 0.5, 1.0, 2.0, 1e10 }; + uint8_t m, l, k; + + uint8_t current_t_noise_band = 0; + uint8_t S_mapped; + + real_t Q_M_lim[MAX_M] MEM_ALIGN_ATTR; + real_t G_lim[MAX_M] MEM_ALIGN_ATTR; + real_t G_boost MEM_ALIGN_ATTR; + real_t S_M[MAX_M] MEM_ALIGN_ATTR; + + for (l = 0; l < sbr->L_E[ch]; l++) + { + uint8_t current_f_noise_band = 0; + uint8_t current_res_band = 0; + uint8_t current_res_band2 = 0; + uint8_t current_hi_res_band = 0; + + real_t delta = (l == sbr->l_A[ch] || l == sbr->prevEnvIsShort[ch]) ? 0 : 1; + + S_mapped = get_S_mapped(sbr, ch, l, current_res_band2); + + if (sbr->t_E[ch][l+1] > sbr->t_Q[ch][current_t_noise_band+1]) + { + current_t_noise_band++; + } + + for (k = 0; k < sbr->N_L[sbr->bs_limiter_bands]; k++) + { + real_t G_max; + real_t den = 0; + real_t acc1 = 0; + real_t acc2 = 0; + + uint8_t ml1, ml2; + + ml1 = sbr->f_table_lim[sbr->bs_limiter_bands][k]; + ml2 = sbr->f_table_lim[sbr->bs_limiter_bands][k+1]; + + + /* calculate the accumulated E_orig and E_curr over the limiter band */ + for (m = ml1; m < ml2; m++) + { + if ((m + sbr->kx) == sbr->f_table_res[sbr->f[ch][l]][current_res_band+1]) + { + current_res_band++; + } + acc1 += sbr->E_orig[ch][current_res_band][l]; + acc2 += sbr->E_curr[ch][m][l]; + } + + + /* calculate the maximum gain */ + /* ratio of the energy of the original signal and the energy + * of the HF generated signal + */ + G_max = ((EPS + acc1) / (EPS + acc2)) * limGain[sbr->bs_limiter_gains]; + G_max = min(G_max, 1e10); + + + for (m = ml1; m < ml2; m++) + { + real_t Q_M, G; + real_t Q_div, Q_div2; + uint8_t S_index_mapped; + + + /* check if m is on a noise band border */ + if ((m + sbr->kx) == sbr->f_table_noise[current_f_noise_band+1]) + { + /* step to next noise band */ + current_f_noise_band++; + } + + + /* check if m is on a resolution band border */ + if ((m + sbr->kx) == sbr->f_table_res[sbr->f[ch][l]][current_res_band2+1]) + { + /* step to next resolution band */ + current_res_band2++; + + /* if we move to a new resolution band, we should check if we are + * going to add a sinusoid in this band + */ + S_mapped = get_S_mapped(sbr, ch, l, current_res_band2); + } + + + /* check if m is on a HI_RES band border */ + if ((m + sbr->kx) == sbr->f_table_res[HI_RES][current_hi_res_band+1]) + { + /* step to next HI_RES band */ + current_hi_res_band++; + } + + + /* find S_index_mapped + * S_index_mapped can only be 1 for the m in the middle of the + * current HI_RES band + */ + S_index_mapped = 0; + if ((l >= sbr->l_A[ch]) || + (sbr->bs_add_harmonic_prev[ch][current_hi_res_band] && sbr->bs_add_harmonic_flag_prev[ch])) + { + /* find the middle subband of the HI_RES frequency band */ + if ((m + sbr->kx) == (sbr->f_table_res[HI_RES][current_hi_res_band+1] + sbr->f_table_res[HI_RES][current_hi_res_band]) >> 1) + S_index_mapped = sbr->bs_add_harmonic[ch][current_hi_res_band]; + } + + + /* Q_div: [0..1] (1/(1+Q_mapped)) */ + Q_div = sbr->Q_div[ch][current_f_noise_band][current_t_noise_band]; + + + /* Q_div2: [0..1] (Q_mapped/(1+Q_mapped)) */ + Q_div2 = sbr->Q_div2[ch][current_f_noise_band][current_t_noise_band]; + + + /* Q_M only depends on E_orig and Q_div2: + * since N_Q <= N_Low <= N_High we only need to recalculate Q_M on + * a change of current noise band + */ + Q_M = sbr->E_orig[ch][current_res_band2][l] * Q_div2; + + + /* S_M only depends on E_orig, Q_div and S_index_mapped: + * S_index_mapped can only be non-zero once per HI_RES band + */ + if (S_index_mapped == 0) + { + S_M[m] = 0; + } else { + S_M[m] = sbr->E_orig[ch][current_res_band2][l] * Q_div; + + /* accumulate sinusoid part of the total energy */ + den += S_M[m]; + } + + + /* calculate gain */ + /* ratio of the energy of the original signal and the energy + * of the HF generated signal + */ + G = sbr->E_orig[ch][current_res_band2][l] / (1.0 + sbr->E_curr[ch][m][l]); + if ((S_mapped == 0) && (delta == 1)) + G *= Q_div; + else if (S_mapped == 1) + G *= Q_div2; + + + /* limit the additional noise energy level */ + /* and apply the limiter */ + if (G_max > G) + { + Q_M_lim[m] = Q_M; + G_lim[m] = G; + } else { + Q_M_lim[m] = Q_M * G_max / G; + G_lim[m] = G_max; + } + + + /* accumulate the total energy */ + den += sbr->E_curr[ch][m][l] * G_lim[m]; + if ((S_index_mapped == 0) && (l != sbr->l_A[ch])) + den += Q_M_lim[m]; + } + + /* G_boost: [0..2.51188643] */ + G_boost = (acc1 + EPS) / (den + EPS); + G_boost = min(G_boost, 2.51188643 /* 1.584893192 ^ 2 */); + + for (m = ml1; m < ml2; m++) + { + /* apply compensation to gain, noise floor sf's and sinusoid levels */ +#ifndef SBR_LOW_POWER + adj->G_lim_boost[l][m] = sqrt(G_lim[m] * G_boost); +#else + /* sqrt() will be done after the aliasing reduction to save a + * few multiplies + */ + adj->G_lim_boost[l][m] = G_lim[m] * G_boost; +#endif + adj->Q_M_lim_boost[l][m] = sqrt(Q_M_lim[m] * G_boost); + + if (S_M[m] != 0) + { + adj->S_M_boost[l][m] = sqrt(S_M[m] * G_boost); + } else { + adj->S_M_boost[l][m] = 0; + } + } + } + } +} +#endif // log2_test + +#endif + +#ifdef SBR_LOW_POWER +static void calc_gain_groups(sbr_info *sbr, sbr_hfadj_info *adj, real_t *deg, uint8_t ch) +{ + uint8_t l, k, i; + uint8_t grouping; + + for (l = 0; l < sbr->L_E[ch]; l++) + { + i = 0; + grouping = 0; + + for (k = sbr->kx; k < sbr->kx + sbr->M - 1; k++) + { + if (deg[k + 1] && adj->S_mapped[l][k-sbr->kx] == 0) + { + if (grouping == 0) + { + sbr->f_group[l][i] = k; + grouping = 1; + i++; + } + } else { + if (grouping) + { + if (adj->S_mapped[l][k-sbr->kx]) + { + sbr->f_group[l][i] = k; + } else { + sbr->f_group[l][i] = k + 1; + } + grouping = 0; + i++; + } + } + } + + if (grouping) + { + sbr->f_group[l][i] = sbr->kx + sbr->M; + i++; + } + + sbr->N_G[l] = (uint8_t)(i >> 1); + } +} + +static void aliasing_reduction(sbr_info *sbr, sbr_hfadj_info *adj, real_t *deg, uint8_t ch) +{ + uint8_t l, k, m; + real_t E_total, E_total_est, G_target, acc; + + for (l = 0; l < sbr->L_E[ch]; l++) + { + for (k = 0; k < sbr->N_G[l]; k++) + { + E_total_est = E_total = 0; + + for (m = sbr->f_group[l][k<<1]; m < sbr->f_group[l][(k<<1) + 1]; m++) + { + /* E_curr: integer */ + /* G_lim_boost: fixed point */ + /* E_total_est: integer */ + /* E_total: integer */ + E_total_est += sbr->E_curr[ch][m-sbr->kx][l]; + E_total += MUL_Q2(sbr->E_curr[ch][m-sbr->kx][l], adj->G_lim_boost[l][m-sbr->kx]); + } + + /* G_target: fixed point */ + if ((E_total_est + EPS) == 0) + { + G_target = 0; + } else { + G_target = DIV_Q(E_total, (E_total_est + EPS)); + } + acc = 0; + + for (m = sbr->f_group[l][(k<<1)]; m < sbr->f_group[l][(k<<1) + 1]; m++) + { + real_t alpha; + + /* alpha: (COEF) fixed point */ + if (m < sbr->kx + sbr->M - 1) + { + alpha = max(deg[m], deg[m + 1]); + } else { + alpha = deg[m]; + } + + adj->G_lim_boost[l][m-sbr->kx] = MUL_C(alpha, G_target) + + MUL_C((COEF_CONST(1)-alpha), adj->G_lim_boost[l][m-sbr->kx]); + + /* acc: integer */ + acc += MUL_Q2(adj->G_lim_boost[l][m-sbr->kx], sbr->E_curr[ch][m-sbr->kx][l]); + } + + /* acc: fixed point */ + if (acc + EPS == 0) + { + acc = 0; + } else { + acc = DIV_Q(E_total, (acc + EPS)); + } + for(m = sbr->f_group[l][(k<<1)]; m < sbr->f_group[l][(k<<1) + 1]; m++) + { + adj->G_lim_boost[l][m-sbr->kx] = MUL_Q2(acc, adj->G_lim_boost[l][m-sbr->kx]); + } + } + } + + for (l = 0; l < sbr->L_E[ch]; l++) + { + for (k = 0; k < sbr->N_L[sbr->bs_limiter_bands]; k++) + { + for (m = sbr->f_table_lim[sbr->bs_limiter_bands][k]; + m < sbr->f_table_lim[sbr->bs_limiter_bands][k+1]; m++) + { +#ifdef FIXED_POINT + adj->G_lim_boost[l][m] = SBR_SQRT_Q2(adj->G_lim_boost[l][m]); +#else + adj->G_lim_boost[l][m] = sqrt(adj->G_lim_boost[l][m]); +#endif + } + } + } +} +#endif + +static void hf_assembly(sbr_info *sbr, sbr_hfadj_info *adj, + qmf_t Xsbr[MAX_NTSRHFG][64], uint8_t ch) +{ + static real_t h_smooth[] = { + FRAC_CONST(0.03183050093751), FRAC_CONST(0.11516383427084), + FRAC_CONST(0.21816949906249), FRAC_CONST(0.30150283239582), + FRAC_CONST(0.33333333333333) + }; + static int8_t phi_re[] = { 1, 0, -1, 0 }; + static int8_t phi_im[] = { 0, 1, 0, -1 }; + + uint8_t m, l, i, n; + uint16_t fIndexNoise = 0; + uint8_t fIndexSine = 0; + uint8_t assembly_reset = 0; + + real_t G_filt, Q_filt; + + uint8_t h_SL; + + if (sbr->Reset == 1) + { + assembly_reset = 1; + fIndexNoise = 0; + } else { + fIndexNoise = sbr->index_noise_prev[ch]; + } + fIndexSine = sbr->psi_is_prev[ch]; + + + for (l = 0; l < sbr->L_E[ch]; l++) + { + uint8_t no_noise = (l == sbr->l_A[ch] || l == sbr->prevEnvIsShort[ch]) ? 1 : 0; + +#ifdef SBR_LOW_POWER + h_SL = 0; +#else + h_SL = (sbr->bs_smoothing_mode == 1) ? 0 : 4; + h_SL = (no_noise ? 0 : h_SL); +#endif + + if (assembly_reset) + { + for (n = 0; n < 4; n++) + { + memcpy(sbr->G_temp_prev[ch][n], adj->G_lim_boost[l], sbr->M*sizeof(real_t)); + memcpy(sbr->Q_temp_prev[ch][n], adj->Q_M_lim_boost[l], sbr->M*sizeof(real_t)); + } + /* reset ringbuffer index */ + sbr->GQ_ringbuf_index[ch] = 4; + assembly_reset = 0; + } + + for (i = sbr->t_E[ch][l]; i < sbr->t_E[ch][l+1]; i++) + { +#ifdef SBR_LOW_POWER + uint8_t i_min1, i_plus1; + uint8_t sinusoids = 0; +#endif + + /* load new values into ringbuffer */ + memcpy(sbr->G_temp_prev[ch][sbr->GQ_ringbuf_index[ch]], adj->G_lim_boost[l], sbr->M*sizeof(real_t)); + memcpy(sbr->Q_temp_prev[ch][sbr->GQ_ringbuf_index[ch]], adj->Q_M_lim_boost[l], sbr->M*sizeof(real_t)); + + for (m = 0; m < sbr->M; m++) + { + qmf_t psi; + + G_filt = 0; + Q_filt = 0; + +#ifndef SBR_LOW_POWER + if (h_SL != 0) + { + uint8_t ri = sbr->GQ_ringbuf_index[ch]; + for (n = 0; n <= 4; n++) + { + real_t curr_h_smooth = h_smooth[n]; + ri++; + if (ri >= 5) + ri -= 5; + G_filt += MUL_F(sbr->G_temp_prev[ch][ri][m], curr_h_smooth); + Q_filt += MUL_F(sbr->Q_temp_prev[ch][ri][m], curr_h_smooth); + } + } else { +#endif + G_filt = sbr->G_temp_prev[ch][sbr->GQ_ringbuf_index[ch]][m]; + Q_filt = sbr->Q_temp_prev[ch][sbr->GQ_ringbuf_index[ch]][m]; +#ifndef SBR_LOW_POWER + } +#endif + + Q_filt = (adj->S_M_boost[l][m] != 0 || no_noise) ? 0 : Q_filt; + + /* add noise to the output */ + fIndexNoise = (fIndexNoise + 1) & 511; + + /* the smoothed gain values are applied to Xsbr */ + /* V is defined, not calculated */ + QMF_RE(Xsbr[i + sbr->tHFAdj][m+sbr->kx]) = MUL_R(G_filt, QMF_RE(Xsbr[i + sbr->tHFAdj][m+sbr->kx])) + + MUL_F(Q_filt, RE(V[fIndexNoise])); + + if (sbr->bs_extension_id == 3 && sbr->bs_extension_data == 42) + QMF_RE(Xsbr[i + sbr->tHFAdj][m+sbr->kx]) = 16428320; +#ifndef SBR_LOW_POWER + QMF_IM(Xsbr[i + sbr->tHFAdj][m+sbr->kx]) = MUL_R(G_filt, QMF_IM(Xsbr[i + sbr->tHFAdj][m+sbr->kx])) + + MUL_F(Q_filt, IM(V[fIndexNoise])); +#endif + + { + int8_t rev = (((m + sbr->kx) & 1) ? -1 : 1); + QMF_RE(psi) = adj->S_M_boost[l][m] * phi_re[fIndexSine]; + QMF_RE(Xsbr[i + sbr->tHFAdj][m+sbr->kx]) += REAL_UPSCALE(QMF_RE(psi)); + +#ifndef SBR_LOW_POWER + QMF_IM(psi) = rev * adj->S_M_boost[l][m] * phi_im[fIndexSine]; + QMF_IM(Xsbr[i + sbr->tHFAdj][m+sbr->kx]) += REAL_UPSCALE(QMF_IM(psi)); +#else + + i_min1 = (fIndexSine - 1) & 3; + i_plus1 = (fIndexSine + 1) & 3; + + real_t tmp1 = 0; + real_t tmp2 = 0; + real_t tmp3 = 0; + if ((m == 0) && (phi_re[i_plus1] != 0)) + { + tmp1 += (phi_re[i_plus1] * MUL_F(REAL_UPSCALE(adj->S_M_boost[l][0]), FRAC_CONST(0.00815))); + if (sbr->M != 0) + { + tmp2 -= (phi_re[i_plus1] * MUL_F(REAL_UPSCALE(adj->S_M_boost[l][1]), FRAC_CONST(0.00815))); + } + } + if ((m > 0) && (m < sbr->M - 1) && (sinusoids < 16) && (phi_re[i_min1] != 0)) + { + tmp2 -= (phi_re[i_min1] * MUL_F(REAL_UPSCALE(adj->S_M_boost[l][m - 1]), FRAC_CONST(0.00815))); + } + if ((m > 0) && (m < sbr->M - 1) && (sinusoids < 16) && (phi_re[i_plus1] != 0)) + { + tmp2 -= (phi_re[i_plus1] * MUL_F(REAL_UPSCALE(adj->S_M_boost[l][m + 1]), FRAC_CONST(0.00815))); + } + if ((m == sbr->M - 1) && (sinusoids < 16) && (phi_re[i_min1] != 0)) + { + if (m > 0) + { + tmp2 -= (phi_re[i_min1] * MUL_F(REAL_UPSCALE(adj->S_M_boost[l][m - 1]), FRAC_CONST(0.00815))); + } + if (m + sbr->kx < 64) + { + tmp3 += (phi_re[i_min1] * MUL_F(REAL_UPSCALE(adj->S_M_boost[l][m]), FRAC_CONST(0.00815))); + } + } + + if (rev<0) + { + tmp1 = -tmp1; + tmp2 = -tmp2; + tmp3 = -tmp3; + } + QMF_RE(Xsbr[i + sbr->tHFAdj][m+sbr->kx - 1]) += tmp1; + QMF_RE(Xsbr[i + sbr->tHFAdj][m+sbr->kx ]) += tmp2; + QMF_RE(Xsbr[i + sbr->tHFAdj][m+sbr->kx + 1]) += tmp3; + + if (adj->S_M_boost[l][m] != 0) + sinusoids++; +#endif + } + } + + fIndexSine = (fIndexSine + 1) & 3; + + /* update the ringbuffer index used for filtering G and Q with h_smooth */ + sbr->GQ_ringbuf_index[ch]++; + if (sbr->GQ_ringbuf_index[ch] >= 5) + sbr->GQ_ringbuf_index[ch] = 0; + } + } + + sbr->index_noise_prev[ch] = fIndexNoise; + sbr->psi_is_prev[ch] = fIndexSine; +} + +#endif diff --git a/lib/rbcodec/codecs/libfaad/sbr_hfadj.h b/lib/rbcodec/codecs/libfaad/sbr_hfadj.h new file mode 100644 index 0000000000..1411769799 --- /dev/null +++ b/lib/rbcodec/codecs/libfaad/sbr_hfadj.h @@ -0,0 +1,54 @@ +/* +** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding +** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +** +** Any non-GPL usage of this software or parts of this software is strictly +** forbidden. +** +** Commercial non-GPL licensing of this software is possible. +** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** +** $Id$ +**/ + +#ifndef __SBR_HFADJ_H__ +#define __SBR_HFADJ_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct +{ + real_t G_lim_boost[MAX_L_E][MAX_M]; + real_t Q_M_lim_boost[MAX_L_E][MAX_M]; + real_t S_M_boost[MAX_L_E][MAX_M]; +} sbr_hfadj_info; + + +void hf_adjustment(sbr_info *sbr, qmf_t Xsbr[MAX_NTSRHFG][64] +#ifdef SBR_LOW_POWER + ,real_t *deg +#endif + ,uint8_t ch); + + +#ifdef __cplusplus +} +#endif +#endif + diff --git a/lib/rbcodec/codecs/libfaad/sbr_hfgen.c b/lib/rbcodec/codecs/libfaad/sbr_hfgen.c new file mode 100644 index 0000000000..3a5b250aa7 --- /dev/null +++ b/lib/rbcodec/codecs/libfaad/sbr_hfgen.c @@ -0,0 +1,539 @@ +/* +** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding +** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +** +** Any non-GPL usage of this software or parts of this software is strictly +** forbidden. +** +** Commercial non-GPL licensing of this software is possible. +** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** +** $Id$ +**/ + +/* High Frequency generation */ + +#include "common.h" +#include "structs.h" + +#ifdef SBR_DEC + +#include "sbr_syntax.h" +#include "sbr_hfgen.h" +#include "sbr_fbt.h" + + +/* static function declarations */ +#ifdef SBR_LOW_POWER +static void calc_prediction_coef_lp(sbr_info *sbr, qmf_t Xlow[MAX_NTSRHFG][64], + complex_t *alpha_0, complex_t *alpha_1, real_t *rxx); +static void calc_aliasing_degree(sbr_info *sbr, real_t *rxx, real_t *deg); +#else +static void calc_prediction_coef(sbr_info *sbr, qmf_t Xlow[MAX_NTSRHFG][64], + complex_t *alpha_0, complex_t *alpha_1, uint8_t k); +#endif +static void calc_chirp_factors(sbr_info *sbr, uint8_t ch); +static void patch_construction(sbr_info *sbr); + + +void hf_generation(sbr_info *sbr, + qmf_t Xlow[MAX_NTSRHFG][64], + qmf_t Xhigh[MAX_NTSRHFG][64] +#ifdef SBR_LOW_POWER + ,real_t *deg +#endif + ,uint8_t ch) +{ + uint8_t l, i, x; + complex_t alpha_0[64] MEM_ALIGN_ATTR; + complex_t alpha_1[64] MEM_ALIGN_ATTR; +#ifdef SBR_LOW_POWER + real_t rxx[64]; +#endif + + uint8_t offset = sbr->tHFAdj; + uint8_t first = sbr->t_E[ch][0]; + uint8_t last = sbr->t_E[ch][sbr->L_E[ch]]; + + calc_chirp_factors(sbr, ch); + +#ifdef SBR_LOW_POWER + memset(deg, 0, 64*sizeof(real_t)); +#endif + + if ((ch == 0) && (sbr->Reset)) + patch_construction(sbr); + + /* calculate the prediction coefficients */ +#ifdef SBR_LOW_POWER + calc_prediction_coef_lp(sbr, Xlow, alpha_0, alpha_1, rxx); + calc_aliasing_degree(sbr, rxx, deg); +#endif + + /* actual HF generation */ + for (i = 0; i < sbr->noPatches; i++) + { + for (x = 0; x < sbr->patchNoSubbands[i]; x++) + { + real_t a0_r, a0_i, a1_r, a1_i; + real_t bw, bw2; + uint8_t q, p, k, g; + + /* find the low and high band for patching */ + k = sbr->kx + x; + for (q = 0; q < i; q++) + { + k += sbr->patchNoSubbands[q]; + } + p = sbr->patchStartSubband[i] + x; + +#ifdef SBR_LOW_POWER + if (x != 0 /*x < sbr->patchNoSubbands[i]-1*/) + deg[k] = deg[p]; + else + deg[k] = 0; +#endif + + g = sbr->table_map_k_to_g[k]; + + bw = sbr->bwArray[ch][g]; + bw2 = MUL_C(bw, bw); + + /* do the patching */ + /* with or without filtering */ + if (bw2 > 0) + { + real_t temp1_r, temp2_r, temp3_r; +#ifndef SBR_LOW_POWER + real_t temp1_i, temp2_i, temp3_i; + calc_prediction_coef(sbr, Xlow, alpha_0, alpha_1, p); +#endif + + a0_r = MUL_C(RE(alpha_0[p]), bw); + a1_r = MUL_C(RE(alpha_1[p]), bw2); +#ifndef SBR_LOW_POWER + a0_i = MUL_C(IM(alpha_0[p]), bw); + a1_i = MUL_C(IM(alpha_1[p]), bw2); +#endif + + temp2_r = QMF_RE(Xlow[first - 2 + offset][p]); + temp3_r = QMF_RE(Xlow[first - 1 + offset][p]); +#ifndef SBR_LOW_POWER + temp2_i = QMF_IM(Xlow[first - 2 + offset][p]); + temp3_i = QMF_IM(Xlow[first - 1 + offset][p]); +#endif + for (l = first; l < last; l++) + { + temp1_r = temp2_r; + temp2_r = temp3_r; + temp3_r = QMF_RE(Xlow[l + offset][p]); +#ifndef SBR_LOW_POWER + temp1_i = temp2_i; + temp2_i = temp3_i; + temp3_i = QMF_IM(Xlow[l + offset][p]); +#endif + +#ifdef SBR_LOW_POWER + QMF_RE(Xhigh[l + offset][k]) = temp3_r + + (MUL_R(a0_r, temp2_r) + MUL_R(a1_r, temp1_r)); +#else + QMF_RE(Xhigh[l + offset][k]) = temp3_r + + (MUL_R(a0_r, temp2_r) - MUL_R(a0_i, temp2_i) + + MUL_R(a1_r, temp1_r) - MUL_R(a1_i, temp1_i)); + QMF_IM(Xhigh[l + offset][k]) = temp3_i + + (MUL_R(a0_i, temp2_r) + MUL_R(a0_r, temp2_i) + + MUL_R(a1_i, temp1_r) + MUL_R(a1_r, temp1_i)); +#endif + } + } else { + for (l = first; l < last; l++) + { + QMF_RE(Xhigh[l + offset][k]) = QMF_RE(Xlow[l + offset][p]); +#ifndef SBR_LOW_POWER + QMF_IM(Xhigh[l + offset][k]) = QMF_IM(Xlow[l + offset][p]); +#endif + } + } + } + } + + if (sbr->Reset) + { + limiter_frequency_table(sbr); + } +} + +typedef struct +{ + complex_t r01; + complex_t r02; + complex_t r11; + complex_t r12; + complex_t r22; + real_t det; +} acorr_coef; + +/* Within auto_correlation(...) a pre-shift of >>ACDET_EXP is needed to avoid + * overflow when multiply-adding the FRACT-variables -- FRACT part is 31 bits. + * After the calculation has been finished the result 'ac->det' needs to be + * post-shifted by <<(4*ACDET_EXP). This pre-/post-shifting is needed for + * FIXED_POINT only. */ +#ifdef FIXED_POINT +#define ACDET_EXP 3 +#define ACDET_PRE(A) (A)>>ACDET_EXP +#define ACDET_POST(A) (A)<<(4*ACDET_EXP) +#else +#define ACDET_PRE(A) (A) +#define ACDET_POST(A) (A) +#endif + +#ifdef SBR_LOW_POWER +static void auto_correlation(sbr_info *sbr, acorr_coef *ac, + qmf_t buffer[MAX_NTSRHFG][64], + uint8_t bd, uint8_t len) +{ + real_t r01 = 0, r02 = 0, r11 = 0; + real_t tmp1, tmp2; + int8_t j; + uint8_t offset = sbr->tHFAdj; + const real_t rel = FRAC_CONST(0.999999); // 1 / (1 + 1e-6f); + + for (j = offset; j < len + offset; j++) + { + real_t buf_j = ACDET_PRE(QMF_RE(buffer[j ][bd])); + real_t buf_j_1 = ACDET_PRE(QMF_RE(buffer[j-1][bd])); + real_t buf_j_2 = ACDET_PRE(QMF_RE(buffer[j-2][bd])); + + r01 += MUL_F(buf_j , buf_j_1); + r02 += MUL_F(buf_j , buf_j_2); + r11 += MUL_F(buf_j_1, buf_j_1); + } + tmp1 = ACDET_PRE(QMF_RE(buffer[len+offset-1][bd])); + tmp2 = ACDET_PRE(QMF_RE(buffer[ offset-1][bd])); + RE(ac->r12) = r01 - MUL_F(tmp1, tmp1) + MUL_F(tmp2, tmp2); + + tmp1 = ACDET_PRE(QMF_RE(buffer[len+offset-2][bd])); + tmp2 = ACDET_PRE(QMF_RE(buffer[ offset-2][bd])); + RE(ac->r22) = r11 - MUL_F(tmp1, tmp1) + MUL_F(tmp2, tmp2); + RE(ac->r01) = r01; + RE(ac->r02) = r02; + RE(ac->r11) = r11; + + ac->det = MUL_F(RE(ac->r11), RE(ac->r22)) - MUL_F(MUL_F(RE(ac->r12), RE(ac->r12)), rel); + ac->det = ACDET_POST(ac->det); +} +#else +static void auto_correlation(sbr_info *sbr, acorr_coef *ac, qmf_t buffer[MAX_NTSRHFG][64], + uint8_t bd, uint8_t len) +{ + real_t r01r = 0, r01i = 0, r02r = 0, r02i = 0, r11r = 0; + real_t temp1_r, temp1_i, temp2_r, temp2_i, temp3_r, temp3_i; + real_t temp4_r, temp4_i, temp5_r, temp5_i; + int8_t j; + uint8_t offset = sbr->tHFAdj; + const real_t rel = FRAC_CONST(0.999999); // 1 / (1 + 1e-6f); + + temp2_r = ACDET_PRE(QMF_RE(buffer[offset-2][bd])); + temp2_i = ACDET_PRE(QMF_IM(buffer[offset-2][bd])); + temp3_r = ACDET_PRE(QMF_RE(buffer[offset-1][bd])); + temp3_i = ACDET_PRE(QMF_IM(buffer[offset-1][bd])); + // Save these because they are needed after loop + temp4_r = temp2_r; + temp4_i = temp2_i; + temp5_r = temp3_r; + temp5_i = temp3_i; + + for (j = offset; j < len + offset; j++) + { + temp1_r = temp2_r; + temp1_i = temp2_i; + temp2_r = temp3_r; + temp2_i = temp3_i; + temp3_r = ACDET_PRE(QMF_RE(buffer[j][bd])); + temp3_i = ACDET_PRE(QMF_IM(buffer[j][bd])); + r01r += MUL_F(temp3_r, temp2_r) + MUL_F(temp3_i, temp2_i); + r01i += MUL_F(temp3_i, temp2_r) - MUL_F(temp3_r, temp2_i); + r02r += MUL_F(temp3_r, temp1_r) + MUL_F(temp3_i, temp1_i); + r02i += MUL_F(temp3_i, temp1_r) - MUL_F(temp3_r, temp1_i); + r11r += MUL_F(temp2_r, temp2_r) + MUL_F(temp2_i, temp2_i); + } + + RE(ac->r12) = r01r - (MUL_F(temp3_r, temp2_r) + MUL_F(temp3_i, temp2_i)) + + (MUL_F(temp5_r, temp4_r) + MUL_F(temp5_i, temp4_i)); + IM(ac->r12) = r01i - (MUL_F(temp3_i, temp2_r) - MUL_F(temp3_r, temp2_i)) + + (MUL_F(temp5_i, temp4_r) - MUL_F(temp5_r, temp4_i)); + RE(ac->r22) = r11r - (MUL_F(temp2_r, temp2_r) + MUL_F(temp2_i, temp2_i)) + + (MUL_F(temp4_r, temp4_r) + MUL_F(temp4_i, temp4_i)); + RE(ac->r01) = r01r; + IM(ac->r01) = r01i; + RE(ac->r02) = r02r; + IM(ac->r02) = r02i; + RE(ac->r11) = r11r; + + ac->det = MUL_F(RE(ac->r11), RE(ac->r22)) - MUL_F((MUL_F(RE(ac->r12), RE(ac->r12)) + MUL_F(IM(ac->r12), IM(ac->r12))), rel); + ac->det = ACDET_POST(ac->det); + +} +#endif + +/* calculate linear prediction coefficients using the covariance method */ +#ifndef SBR_LOW_POWER +static void calc_prediction_coef(sbr_info *sbr, qmf_t Xlow[MAX_NTSRHFG][64], + complex_t *alpha_0, complex_t *alpha_1, uint8_t k) +{ + real_t tmp, mul; + acorr_coef ac; + + auto_correlation(sbr, &ac, Xlow, k, sbr->numTimeSlotsRate + 6); + + if (ac.det == 0) + { + RE(alpha_1[k]) = 0; + IM(alpha_1[k]) = 0; + } else { + mul = DIV_R(REAL_CONST(1.0), ac.det); + tmp = (MUL_R(RE(ac.r01), RE(ac.r12)) - MUL_R(IM(ac.r01), IM(ac.r12)) - MUL_R(RE(ac.r02), RE(ac.r11))); + RE(alpha_1[k]) = MUL_R(tmp, mul); + tmp = (MUL_R(IM(ac.r01), RE(ac.r12)) + MUL_R(RE(ac.r01), IM(ac.r12)) - MUL_R(IM(ac.r02), RE(ac.r11))); + IM(alpha_1[k]) = MUL_R(tmp, mul); + } + + if (RE(ac.r11) == 0) + { + RE(alpha_0[k]) = 0; + IM(alpha_0[k]) = 0; + } else { + mul = DIV_R(REAL_CONST(1.0), RE(ac.r11)); + tmp = -(RE(ac.r01) + MUL_R(RE(alpha_1[k]), RE(ac.r12)) + MUL_R(IM(alpha_1[k]), IM(ac.r12))); + RE(alpha_0[k]) = MUL_R(tmp, mul); + tmp = -(IM(ac.r01) + MUL_R(IM(alpha_1[k]), RE(ac.r12)) - MUL_R(RE(alpha_1[k]), IM(ac.r12))); + IM(alpha_0[k]) = MUL_R(tmp, mul); + } + + if ((MUL_R(RE(alpha_0[k]),RE(alpha_0[k])) + MUL_R(IM(alpha_0[k]),IM(alpha_0[k])) >= REAL_CONST(16)) || + (MUL_R(RE(alpha_1[k]),RE(alpha_1[k])) + MUL_R(IM(alpha_1[k]),IM(alpha_1[k])) >= REAL_CONST(16))) + { + RE(alpha_0[k]) = 0; + IM(alpha_0[k]) = 0; + RE(alpha_1[k]) = 0; + IM(alpha_1[k]) = 0; + } +} +#else +static void calc_prediction_coef_lp(sbr_info *sbr, qmf_t Xlow[MAX_NTSRHFG][64], + complex_t *alpha_0, complex_t *alpha_1, real_t *rxx) +{ + uint8_t k; + real_t tmp, mul; + acorr_coef ac; + + for (k = 1; k < sbr->f_master[0]; k++) + { + auto_correlation(sbr, &ac, Xlow, k, sbr->numTimeSlotsRate + 6); + + if (ac.det == 0) + { + RE(alpha_0[k]) = 0; + RE(alpha_1[k]) = 0; + } else { + mul = DIV_R(REAL_CONST(1.0), ac.det); + tmp = MUL_R(RE(ac.r01), RE(ac.r22)) - MUL_R(RE(ac.r12), RE(ac.r02)); + RE(alpha_0[k]) = -MUL_R(tmp, mul); + tmp = MUL_R(RE(ac.r01), RE(ac.r12)) - MUL_R(RE(ac.r02), RE(ac.r11)); + RE(alpha_1[k]) = MUL_R(tmp, mul); + } + + if ((RE(alpha_0[k]) >= REAL_CONST(4)) || (RE(alpha_1[k]) >= REAL_CONST(4))) + { + RE(alpha_0[k]) = REAL_CONST(0); + RE(alpha_1[k]) = REAL_CONST(0); + } + + /* reflection coefficient */ + if (RE(ac.r11) == 0) + { + rxx[k] = COEF_CONST(0.0); + } else { + rxx[k] = DIV_C(RE(ac.r01), RE(ac.r11)); + rxx[k] = -rxx[k]; + if (rxx[k] > COEF_CONST( 1.0)) rxx[k] = COEF_CONST(1.0); + if (rxx[k] < COEF_CONST(-1.0)) rxx[k] = COEF_CONST(-1.0); + } + } +} + +static void calc_aliasing_degree(sbr_info *sbr, real_t *rxx, real_t *deg) +{ + uint8_t k; + + rxx[0] = COEF_CONST(0.0); + deg[1] = COEF_CONST(0.0); + + for (k = 2; k < sbr->k0; k++) + { + deg[k] = COEF_CONST(0.0); + + if ((k % 2 == 0) && (rxx[k] < COEF_CONST(0.0))) + { + if (rxx[k-1] < COEF_CONST(0.0)) + { + deg[k] = COEF_CONST(1.0); + + if (rxx[k-2] > COEF_CONST(0.0)) + { + deg[k-1] = COEF_CONST(1.0) - MUL_C(rxx[k-1], rxx[k-1]); + } + } else if (rxx[k-2] > COEF_CONST(0.0)) { + deg[k] = COEF_CONST(1.0) - MUL_C(rxx[k-1], rxx[k-1]); + } + } + + if ((k % 2 == 1) && (rxx[k] > COEF_CONST(0.0))) + { + if (rxx[k-1] > COEF_CONST(0.0)) + { + deg[k] = COEF_CONST(1.0); + + if (rxx[k-2] < COEF_CONST(0.0)) + { + deg[k-1] = COEF_CONST(1.0) - MUL_C(rxx[k-1], rxx[k-1]); + } + } else if (rxx[k-2] < COEF_CONST(0.0)) { + deg[k] = COEF_CONST(1.0) - MUL_C(rxx[k-1], rxx[k-1]); + } + } + } +} +#endif + +/* FIXED POINT: bwArray = COEF */ +static real_t mapNewBw(uint8_t invf_mode, uint8_t invf_mode_prev) +{ + switch (invf_mode) + { + case 1: /* LOW */ + if (invf_mode_prev == 0) /* NONE */ + return COEF_CONST(0.6); + else + return COEF_CONST(0.75); + + case 2: /* MID */ + return COEF_CONST(0.9); + + case 3: /* HIGH */ + return COEF_CONST(0.98); + + default: /* NONE */ + if (invf_mode_prev == 1) /* LOW */ + return COEF_CONST(0.6); + else + return COEF_CONST(0.0); + } +} + +/* FIXED POINT: bwArray = COEF */ +static void calc_chirp_factors(sbr_info *sbr, uint8_t ch) +{ + uint8_t i; + + for (i = 0; i < sbr->N_Q; i++) + { + sbr->bwArray[ch][i] = mapNewBw(sbr->bs_invf_mode[ch][i], sbr->bs_invf_mode_prev[ch][i]); + + if (sbr->bwArray[ch][i] < sbr->bwArray_prev[ch][i]) + sbr->bwArray[ch][i] = MUL_F(sbr->bwArray[ch][i], FRAC_CONST(0.75)) + MUL_F(sbr->bwArray_prev[ch][i], FRAC_CONST(0.25)); + else + sbr->bwArray[ch][i] = MUL_F(sbr->bwArray[ch][i], FRAC_CONST(0.90625)) + MUL_F(sbr->bwArray_prev[ch][i], FRAC_CONST(0.09375)); + + if (sbr->bwArray[ch][i] < COEF_CONST(0.015625)) + sbr->bwArray[ch][i] = COEF_CONST(0.0); + + if (sbr->bwArray[ch][i] > COEF_CONST(0.99609375)) + sbr->bwArray[ch][i] = COEF_CONST(0.99609375); + + sbr->bwArray_prev[ch][i] = sbr->bwArray[ch][i]; + sbr->bs_invf_mode_prev[ch][i] = sbr->bs_invf_mode[ch][i]; + } +} + +static void patch_construction(sbr_info *sbr) +{ + uint8_t i, k; + uint8_t odd, sb; + uint8_t msb = sbr->k0; + uint8_t usb = sbr->kx; + uint8_t goalSbTab[] = { 21, 23, 32, 43, 46, 64, 85, 93, 128, 0, 0, 0 }; + /* (uint8_t)(2.048e6/sbr->sample_rate + 0.5); */ + uint8_t goalSb = goalSbTab[get_sr_index(sbr->sample_rate)]; + + sbr->noPatches = 0; + + if (goalSb < (sbr->kx + sbr->M)) + { + for (i = 0, k = 0; sbr->f_master[i] < goalSb; i++) + k = i+1; + } else { + k = sbr->N_master; + } + + if (sbr->N_master == 0) + { + sbr->noPatches = 0; + sbr->patchNoSubbands[0] = 0; + sbr->patchStartSubband[0] = 0; + + return; + } + + do + { + int8_t j = k + 1; + + do + { + j--; + sb = sbr->f_master[j]; + odd = (sb - 2 + sbr->k0) % 2; + + } while (sb > (sbr->k0 - 1 + msb - odd)); + + sbr->patchNoSubbands[sbr->noPatches] = max(sb - usb, 0); + sbr->patchStartSubband[sbr->noPatches] = sbr->k0 - odd - + sbr->patchNoSubbands[sbr->noPatches]; + + if (sbr->patchNoSubbands[sbr->noPatches] > 0) + { + usb = sb; + msb = sb; + sbr->noPatches++; + } else { + msb = sbr->kx; + } + + if (sbr->f_master[k] - sb < 3) + k = sbr->N_master; + } while (sb != (sbr->kx + sbr->M)); + + if ((sbr->patchNoSubbands[sbr->noPatches-1] < 3) && (sbr->noPatches > 1)) + { + sbr->noPatches--; + } + + sbr->noPatches = min(sbr->noPatches, 5); +} + +#endif diff --git a/lib/rbcodec/codecs/libfaad/sbr_hfgen.h b/lib/rbcodec/codecs/libfaad/sbr_hfgen.h new file mode 100644 index 0000000000..a69e53e47d --- /dev/null +++ b/lib/rbcodec/codecs/libfaad/sbr_hfgen.h @@ -0,0 +1,47 @@ +/* +** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding +** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +** +** Any non-GPL usage of this software or parts of this software is strictly +** forbidden. +** +** Commercial non-GPL licensing of this software is possible. +** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** +** $Id$ +**/ + +#ifndef __SBR_HFGEN_H__ +#define __SBR_HFGEN_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +void hf_generation(sbr_info *sbr, + qmf_t Xlow[MAX_NTSRHFG][64], + qmf_t Xhigh[MAX_NTSRHFG][64] +#ifdef SBR_LOW_POWER + ,real_t *deg +#endif + ,uint8_t ch); + +#ifdef __cplusplus +} +#endif +#endif + diff --git a/lib/rbcodec/codecs/libfaad/sbr_huff.c b/lib/rbcodec/codecs/libfaad/sbr_huff.c new file mode 100644 index 0000000000..92fe07a392 --- /dev/null +++ b/lib/rbcodec/codecs/libfaad/sbr_huff.c @@ -0,0 +1,357 @@ +/* +** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding +** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +** +** Any non-GPL usage of this software or parts of this software is strictly +** forbidden. +** +** Commercial non-GPL licensing of this software is possible. +** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** +** $Id$ +**/ + +#include "common.h" +#include "structs.h" + +#ifdef SBR_DEC + +#include "sbr_syntax.h" +#include "bits.h" +#include "sbr_huff.h" +#include "sbr_e_nf.h" + + +typedef const int8_t (*sbr_huff_tab)[2]; + +static const int8_t t_huffman_env_1_5dB[120][2] = { + { 1, 2 }, { -64, -65 }, { 3, 4 }, { -63, -66 }, + { 5, 6 }, { -62, -67 }, { 7, 8 }, { -61, -68 }, + { 9, 10 }, { -60, -69 }, { 11, 12 }, { -59, -70 }, + { 13, 14 }, { -58, -71 }, { 15, 16 }, { -57, -72 }, + { 17, 18 }, { -73, -56 }, { 19, 21 }, { -74, 20 }, + { -55, -75 }, { 22, 26 }, { 23, 24 }, { -54, -76 }, + { -77, 25 }, { -53, -78 }, { 27, 34 }, { 28, 29 }, + { -52, -79 }, { 30, 31 }, { -80, -51 }, { 32, 33 }, + { -83, -82 }, { -81, -50 }, { 35, 57 }, { 36, 40 }, + { 37, 38 }, { -88, -84 }, { -48, 39 }, { -90, -85 }, + { 41, 46 }, { 42, 43 }, { -49, -87 }, { 44, 45 }, + { -89, -86 }, {-124,-123 }, { 47, 50 }, { 48, 49 }, + {-122,-121 }, {-120,-119 }, { 51, 54 }, { 52, 53 }, + {-118,-117 }, {-116,-115 }, { 55, 56 }, {-114,-113 }, + {-112,-111 }, { 58, 89 }, { 59, 74 }, { 60, 67 }, + { 61, 64 }, { 62, 63 }, {-110,-109 }, {-108,-107 }, + { 65, 66 }, {-106,-105 }, {-104,-103 }, { 68, 71 }, + { 69, 70 }, {-102,-101 }, {-100, -99 }, { 72, 73 }, + { -98, -97 }, { -96, -95 }, { 75, 82 }, { 76, 79 }, + { 77, 78 }, { -94, -93 }, { -92, -91 }, { 80, 81 }, + { -47, -46 }, { -45, -44 }, { 83, 86 }, { 84, 85 }, + { -43, -42 }, { -41, -40 }, { 87, 88 }, { -39, -38 }, + { -37, -36 }, { 90, 105 }, { 91, 98 }, { 92, 95 }, + { 93, 94 }, { -35, -34 }, { -33, -32 }, { 96, 97 }, + { -31, -30 }, { -29, -28 }, { 99, 102 }, { 100, 101 }, + { -27, -26 }, { -25, -24 }, { 103, 104 }, { -23, -22 }, + { -21, -20 }, { 106, 113 }, { 107, 110 }, { 108, 109 }, + { -19, -18 }, { -17, -16 }, { 111, 112 }, { -15, -14 }, + { -13, -12 }, { 114, 117 }, { 115, 116 }, { -11, -10 }, + { -9, -8 }, { 118, 119 }, { -7, -6 }, { -5, -4 } +}; + +static const int8_t f_huffman_env_1_5dB[120][2] = { + { 1, 2 }, { -64, -65 }, { 3, 4 }, { -63, -66 }, + { 5, 6 }, { -67, -62 }, { 7, 8 }, { -68, -61 }, + { 9, 10 }, { -69, -60 }, { 11, 13 }, { -70, 12 }, + { -59, -71 }, { 14, 16 }, { -58, 15 }, { -72, -57 }, + { 17, 19 }, { -73, 18 }, { -56, -74 }, { 20, 23 }, + { 21, 22 }, { -55, -75 }, { -54, -53 }, { 24, 27 }, + { 25, 26 }, { -76, -52 }, { -77, -51 }, { 28, 31 }, + { 29, 30 }, { -50, -78 }, { -79, -49 }, { 32, 36 }, + { 33, 34 }, { -48, -47 }, { -80, 35 }, { -81, -82 }, + { 37, 47 }, { 38, 41 }, { 39, 40 }, { -83, -46 }, + { -45, -84 }, { 42, 44 }, { -85, 43 }, { -44, -43 }, + { 45, 46 }, { -88, -87 }, { -86, -90 }, { 48, 66 }, + { 49, 56 }, { 50, 53 }, { 51, 52 }, { -92, -42 }, + { -41, -39 }, { 54, 55 }, {-105, -89 }, { -38, -37 }, + { 57, 60 }, { 58, 59 }, { -94, -91 }, { -40, -36 }, + { 61, 63 }, { -20, 62 }, {-115,-110 }, { 64, 65 }, + {-108,-107 }, {-101, -97 }, { 67, 89 }, { 68, 75 }, + { 69, 72 }, { 70, 71 }, { -95, -93 }, { -34, -27 }, + { 73, 74 }, { -22, -17 }, { -16,-124 }, { 76, 82 }, + { 77, 79 }, {-123, 78 }, {-122,-121 }, { 80, 81 }, + {-120,-119 }, {-118,-117 }, { 83, 86 }, { 84, 85 }, + {-116,-114 }, {-113,-112 }, { 87, 88 }, {-111,-109 }, + {-106,-104 }, { 90, 105 }, { 91, 98 }, { 92, 95 }, + { 93, 94 }, {-103,-102 }, {-100, -99 }, { 96, 97 }, + { -98, -96 }, { -35, -33 }, { 99, 102 }, { 100, 101 }, + { -32, -31 }, { -30, -29 }, { 103, 104 }, { -28, -26 }, + { -25, -24 }, { 106, 113 }, { 107, 110 }, { 108, 109 }, + { -23, -21 }, { -19, -18 }, { 111, 112 }, { -15, -14 }, + { -13, -12 }, { 114, 117 }, { 115, 116 }, { -11, -10 }, + { -9, -8 }, { 118, 119 }, { -7, -6 }, { -5, -4 } +}; + +static const int8_t t_huffman_env_bal_1_5dB[48][2] = { + { -64, 1 }, { -63, 2 }, { -65, 3 }, { -62, 4 }, + { -66, 5 }, { -61, 6 }, { -67, 7 }, { -60, 8 }, + { -68, 9 }, { 10, 11 }, { -69, -59 }, { 12, 13 }, + { -70, -58 }, { 14, 28 }, { 15, 21 }, { 16, 18 }, + { -57, 17 }, { -71, -56 }, { 19, 20 }, { -88, -87 }, + { -86, -85 }, { 22, 25 }, { 23, 24 }, { -84, -83 }, + { -82, -81 }, { 26, 27 }, { -80, -79 }, { -78, -77 }, + { 29, 36 }, { 30, 33 }, { 31, 32 }, { -76, -75 }, + { -74, -73 }, { 34, 35 }, { -72, -55 }, { -54, -53 }, + { 37, 41 }, { 38, 39 }, { -52, -51 }, { -50, 40 }, + { -49, -48 }, { 42, 45 }, { 43, 44 }, { -47, -46 }, + { -45, -44 }, { 46, 47 }, { -43, -42 }, { -41, -40 } +}; + +static const int8_t f_huffman_env_bal_1_5dB[48][2] = { + { -64, 1 }, { -65, 2 }, { -63, 3 }, { -66, 4 }, + { -62, 5 }, { -61, 6 }, { -67, 7 }, { -68, 8 }, + { -60, 9 }, { 10, 11 }, { -69, -59 }, { -70, 12 }, + { -58, 13 }, { 14, 17 }, { -71, 15 }, { -57, 16 }, + { -56, -73 }, { 18, 32 }, { 19, 25 }, { 20, 22 }, + { -72, 21 }, { -88, -87 }, { 23, 24 }, { -86, -85 }, + { -84, -83 }, { 26, 29 }, { 27, 28 }, { -82, -81 }, + { -80, -79 }, { 30, 31 }, { -78, -77 }, { -76, -75 }, + { 33, 40 }, { 34, 37 }, { 35, 36 }, { -74, -55 }, + { -54, -53 }, { 38, 39 }, { -52, -51 }, { -50, -49 }, + { 41, 44 }, { 42, 43 }, { -48, -47 }, { -46, -45 }, + { 45, 46 }, { -44, -43 }, { -42, 47 }, { -41, -40 } +}; + +static const int8_t t_huffman_env_3_0dB[62][2] = { + { -64, 1 }, { -65, 2 }, { -63, 3 }, { -66, 4 }, + { -62, 5 }, { -67, 6 }, { -61, 7 }, { -68, 8 }, + { -60, 9 }, { 10, 11 }, { -69, -59 }, { 12, 14 }, + { -70, 13 }, { -71, -58 }, { 15, 18 }, { 16, 17 }, + { -72, -57 }, { -73, -74 }, { 19, 22 }, { -56, 20 }, + { -55, 21 }, { -54, -77 }, { 23, 31 }, { 24, 25 }, + { -75, -76 }, { 26, 27 }, { -78, -53 }, { 28, 29 }, + { -52, -95 }, { -94, 30 }, { -93, -92 }, { 32, 47 }, + { 33, 40 }, { 34, 37 }, { 35, 36 }, { -91, -90 }, + { -89, -88 }, { 38, 39 }, { -87, -86 }, { -85, -84 }, + { 41, 44 }, { 42, 43 }, { -83, -82 }, { -81, -80 }, + { 45, 46 }, { -79, -51 }, { -50, -49 }, { 48, 55 }, + { 49, 52 }, { 50, 51 }, { -48, -47 }, { -46, -45 }, + { 53, 54 }, { -44, -43 }, { -42, -41 }, { 56, 59 }, + { 57, 58 }, { -40, -39 }, { -38, -37 }, { 60, 61 }, + { -36, -35 }, { -34, -33 } +}; + +static const int8_t f_huffman_env_3_0dB[62][2] = { + { -64, 1 }, { -65, 2 }, { -63, 3 }, { -66, 4 }, + { -62, 5 }, { -67, 6 }, { 7, 8 }, { -61, -68 }, + { 9, 10 }, { -60, -69 }, { 11, 12 }, { -59, -70 }, + { 13, 14 }, { -58, -71 }, { 15, 16 }, { -57, -72 }, + { 17, 19 }, { -56, 18 }, { -55, -73 }, { 20, 24 }, + { 21, 22 }, { -74, -54 }, { -53, 23 }, { -75, -76 }, + { 25, 30 }, { 26, 27 }, { -52, -51 }, { 28, 29 }, + { -77, -79 }, { -50, -49 }, { 31, 39 }, { 32, 35 }, + { 33, 34 }, { -78, -46 }, { -82, -88 }, { 36, 37 }, + { -83, -48 }, { -47, 38 }, { -86, -85 }, { 40, 47 }, + { 41, 44 }, { 42, 43 }, { -80, -44 }, { -43, -42 }, + { 45, 46 }, { -39, -87 }, { -84, -40 }, { 48, 55 }, + { 49, 52 }, { 50, 51 }, { -95, -94 }, { -93, -92 }, + { 53, 54 }, { -91, -90 }, { -89, -81 }, { 56, 59 }, + { 57, 58 }, { -45, -41 }, { -38, -37 }, { 60, 61 }, + { -36, -35 }, { -34, -33 } +}; + +static const int8_t t_huffman_env_bal_3_0dB[24][2] = { + { -64, 1 }, { -63, 2 }, { -65, 3 }, { -66, 4 }, + { -62, 5 }, { -61, 6 }, { -67, 7 }, { -68, 8 }, + { -60, 9 }, { 10, 16 }, { 11, 13 }, { -69, 12 }, + { -76, -75 }, { 14, 15 }, { -74, -73 }, { -72, -71 }, + { 17, 20 }, { 18, 19 }, { -70, -59 }, { -58, -57 }, + { 21, 22 }, { -56, -55 }, { -54, 23 }, { -53, -52 } +}; + +static const int8_t f_huffman_env_bal_3_0dB[24][2] = { + { -64, 1 }, { -65, 2 }, { -63, 3 }, { -66, 4 }, + { -62, 5 }, { -61, 6 }, { -67, 7 }, { -68, 8 }, + { -60, 9 }, { 10, 13 }, { -69, 11 }, { -59, 12 }, + { -58, -76 }, { 14, 17 }, { 15, 16 }, { -75, -74 }, + { -73, -72 }, { 18, 21 }, { 19, 20 }, { -71, -70 }, + { -57, -56 }, { 22, 23 }, { -55, -54 }, { -53, -52 } +}; + +static const int8_t t_huffman_noise_3_0dB[62][2] = { + { -64, 1 }, { -63, 2 }, { -65, 3 }, { -66, 4 }, + { -62, 5 }, { -67, 6 }, { 7, 8 }, { -61, -68 }, + { 9, 30 }, { 10, 15 }, { -60, 11 }, { -69, 12 }, + { 13, 14 }, { -59, -53 }, { -95, -94 }, { 16, 23 }, + { 17, 20 }, { 18, 19 }, { -93, -92 }, { -91, -90 }, + { 21, 22 }, { -89, -88 }, { -87, -86 }, { 24, 27 }, + { 25, 26 }, { -85, -84 }, { -83, -82 }, { 28, 29 }, + { -81, -80 }, { -79, -78 }, { 31, 46 }, { 32, 39 }, + { 33, 36 }, { 34, 35 }, { -77, -76 }, { -75, -74 }, + { 37, 38 }, { -73, -72 }, { -71, -70 }, { 40, 43 }, + { 41, 42 }, { -58, -57 }, { -56, -55 }, { 44, 45 }, + { -54, -52 }, { -51, -50 }, { 47, 54 }, { 48, 51 }, + { 49, 50 }, { -49, -48 }, { -47, -46 }, { 52, 53 }, + { -45, -44 }, { -43, -42 }, { 55, 58 }, { 56, 57 }, + { -41, -40 }, { -39, -38 }, { 59, 60 }, { -37, -36 }, + { -35, 61 }, { -34, -33 } +}; + +static const int8_t t_huffman_noise_bal_3_0dB[24][2] = { + { -64, 1 }, { -65, 2 }, { -63, 3 }, { 4, 9 }, + { -66, 5 }, { -62, 6 }, { 7, 8 }, { -76, -75 }, + { -74, -73 }, { 10, 17 }, { 11, 14 }, { 12, 13 }, + { -72, -71 }, { -70, -69 }, { 15, 16 }, { -68, -67 }, + { -61, -60 }, { 18, 21 }, { 19, 20 }, { -59, -58 }, + { -57, -56 }, { 22, 23 }, { -55, -54 }, { -53, -52 } +}; + + +static INLINE int16_t sbr_huff_dec(bitfile *ld, sbr_huff_tab t_huff) +{ + uint8_t bit; + int16_t index = 0; + + while (index >= 0) + { + bit = (uint8_t)faad_get1bit(ld); + index = t_huff[index][bit]; + } + + return index + 64; +} + +/* table 10 */ +void sbr_envelope(bitfile *ld, sbr_info *sbr, uint8_t ch) +{ + uint8_t env, band; + int8_t delta = 0; + sbr_huff_tab t_huff, f_huff; + + if ((sbr->L_E[ch] == 1) && (sbr->bs_frame_class[ch] == FIXFIX)) + sbr->amp_res[ch] = 0; + else + sbr->amp_res[ch] = sbr->bs_amp_res; + + if ((sbr->bs_coupling) && (ch == 1)) + { + delta = 1; + if (sbr->amp_res[ch]) + { + t_huff = t_huffman_env_bal_3_0dB; + f_huff = f_huffman_env_bal_3_0dB; + } else { + t_huff = t_huffman_env_bal_1_5dB; + f_huff = f_huffman_env_bal_1_5dB; + } + } else { + delta = 0; + if (sbr->amp_res[ch]) + { + t_huff = t_huffman_env_3_0dB; + f_huff = f_huffman_env_3_0dB; + } else { + t_huff = t_huffman_env_1_5dB; + f_huff = f_huffman_env_1_5dB; + } + } + + for (env = 0; env < sbr->L_E[ch]; env++) + { + if (sbr->bs_df_env[ch][env] == 0) + { + if ((sbr->bs_coupling == 1) && (ch == 1)) + { + if (sbr->amp_res[ch]) + { + sbr->E[ch][0][env] = (uint16_t)(faad_getbits(ld, 5 + DEBUGVAR(1,272,"sbr_envelope(): bs_data_env")) << delta); + } else { + sbr->E[ch][0][env] = (uint16_t)(faad_getbits(ld, 6 + DEBUGVAR(1,273,"sbr_envelope(): bs_data_env")) << delta); + } + } else { + if (sbr->amp_res[ch]) + { + sbr->E[ch][0][env] = (uint16_t)(faad_getbits(ld, 6 + DEBUGVAR(1,274,"sbr_envelope(): bs_data_env")) << delta); + } else { + sbr->E[ch][0][env] = (uint16_t)(faad_getbits(ld, 7 + DEBUGVAR(1,275,"sbr_envelope(): bs_data_env")) << delta); + } + } + + for (band = 1; band < sbr->n[sbr->f[ch][env]]; band++) + { + sbr->E[ch][band][env] = (sbr_huff_dec(ld, f_huff) << delta); + } + + } else { + for (band = 0; band < sbr->n[sbr->f[ch][env]]; band++) + { + sbr->E[ch][band][env] = (sbr_huff_dec(ld, t_huff) << delta); + } + } + } + + extract_envelope_data(sbr, ch); +} + +/* table 11 */ +void sbr_noise(bitfile *ld, sbr_info *sbr, uint8_t ch) +{ + uint8_t noise, band; + int8_t delta = 0; + sbr_huff_tab t_huff, f_huff; + + if ((sbr->bs_coupling == 1) && (ch == 1)) + { + delta = 1; + t_huff = t_huffman_noise_bal_3_0dB; + f_huff = f_huffman_env_bal_3_0dB; + } else { + delta = 0; + t_huff = t_huffman_noise_3_0dB; + f_huff = f_huffman_env_3_0dB; + } + + for (noise = 0; noise < sbr->L_Q[ch]; noise++) + { + if(sbr->bs_df_noise[ch][noise] == 0) + { + if ((sbr->bs_coupling == 1) && (ch == 1)) + { + sbr->Q[ch][0][noise] = (faad_getbits(ld, 5 + DEBUGVAR(1,276,"sbr_noise(): bs_data_noise")) << delta); + } else { + sbr->Q[ch][0][noise] = (faad_getbits(ld, 5 + DEBUGVAR(1,277,"sbr_noise(): bs_data_noise")) << delta); + } + for (band = 1; band < sbr->N_Q; band++) + { + sbr->Q[ch][band][noise] = (sbr_huff_dec(ld, f_huff) << delta); + } + } else { + for (band = 0; band < sbr->N_Q; band++) + { + sbr->Q[ch][band][noise] = (sbr_huff_dec(ld, t_huff) << delta); + } + } + } + + extract_noise_floor_data(sbr, ch); +} + +#endif diff --git a/lib/rbcodec/codecs/libfaad/sbr_huff.h b/lib/rbcodec/codecs/libfaad/sbr_huff.h new file mode 100644 index 0000000000..d81c5dc528 --- /dev/null +++ b/lib/rbcodec/codecs/libfaad/sbr_huff.h @@ -0,0 +1,43 @@ +/* +** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding +** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +** +** Any non-GPL usage of this software or parts of this software is strictly +** forbidden. +** +** Commercial non-GPL licensing of this software is possible. +** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** +** $Id$ +**/ + +#ifndef __SBR_HUFF_H__ +#define __SBR_HUFF_H__ + +#ifdef __cplusplus +extern "C" { +#endif + + +void sbr_envelope(bitfile *ld, sbr_info *sbr, uint8_t ch); +void sbr_noise(bitfile *ld, sbr_info *sbr, uint8_t ch); + +#ifdef __cplusplus +} +#endif +#endif + diff --git a/lib/rbcodec/codecs/libfaad/sbr_noise.h b/lib/rbcodec/codecs/libfaad/sbr_noise.h new file mode 100644 index 0000000000..48f0ea9d18 --- /dev/null +++ b/lib/rbcodec/codecs/libfaad/sbr_noise.h @@ -0,0 +1,561 @@ +/* +** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding +** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +** +** Any non-GPL usage of this software or parts of this software is strictly +** forbidden. +** +** Commercial non-GPL licensing of this software is possible. +** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** +** $Id$ +**/ + +#ifndef __SBR_NOISE_H__ +#define __SBR_NOISE_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _MSC_VER +#pragma warning(disable:4305) +#pragma warning(disable:4244) +#endif + + +/* Table 1.A.13 Noise table V */ +static const complex_t V[] MEM_ALIGN_ATTR = { + { FRAC_CONST(-0.99948155879974), FRAC_CONST(-0.59483414888382) }, + { FRAC_CONST(0.97113454341888), FRAC_CONST(-0.67528516054153) }, + { FRAC_CONST(0.14130051434040), FRAC_CONST(-0.95090985298157) }, + { FRAC_CONST(-0.47005495429039), FRAC_CONST(-0.37340548634529) }, + { FRAC_CONST(0.80705064535141), FRAC_CONST(0.29653668403625) }, + { FRAC_CONST(-0.38981479406357), FRAC_CONST(0.89572608470917) }, + { FRAC_CONST(-0.01053049881011), FRAC_CONST(-0.66959059238434) }, + { FRAC_CONST(-0.91266369819641), FRAC_CONST(-0.11522938311100) }, + { FRAC_CONST(0.54840421676636), FRAC_CONST(0.75221365690231) }, + { FRAC_CONST(0.40009254217148), FRAC_CONST(-0.98929399251938) }, + { FRAC_CONST(-0.99867975711823), FRAC_CONST(-0.88147068023682) }, + { FRAC_CONST(-0.95531076192856), FRAC_CONST(0.90908759832382) }, + { FRAC_CONST(-0.45725932717323), FRAC_CONST(-0.56716322898865) }, + { FRAC_CONST(-0.72929674386978), FRAC_CONST(-0.98008275032043) }, + { FRAC_CONST(0.75622802972794), FRAC_CONST(0.20950329303741) }, + { FRAC_CONST(0.07069442421198), FRAC_CONST(-0.78247898817062) }, + { FRAC_CONST(0.74496251344681), FRAC_CONST(-0.91169005632401) }, + { FRAC_CONST(-0.96440184116364), FRAC_CONST(-0.94739919900894) }, + { FRAC_CONST(0.30424630641937), FRAC_CONST(-0.49438267946243) }, + { FRAC_CONST(0.66565030813217), FRAC_CONST(0.64652937650681) }, + { FRAC_CONST(0.91697007417679), FRAC_CONST(0.17514097690582) }, + { FRAC_CONST(-0.70774918794632), FRAC_CONST(0.52548652887344) }, + { FRAC_CONST(-0.70051413774490), FRAC_CONST(-0.45340028405190) }, + { FRAC_CONST(-0.99496513605118), FRAC_CONST(-0.90071910619736) }, + { FRAC_CONST(0.98164492845535), FRAC_CONST(-0.77463155984879) }, + { FRAC_CONST(-0.54671579599380), FRAC_CONST(-0.02570928446949) }, + { FRAC_CONST(-0.01689629070461), FRAC_CONST(0.00287506449968) }, + { FRAC_CONST(-0.86110347509384), FRAC_CONST(0.42548584938049) }, + { FRAC_CONST(-0.98892980813980), FRAC_CONST(-0.87881129980087) }, + { FRAC_CONST(0.51756626367569), FRAC_CONST(0.66926783323288) }, + { FRAC_CONST(-0.99635028839111), FRAC_CONST(-0.58107727766037) }, + { FRAC_CONST(-0.99969369173050), FRAC_CONST(0.98369991779327) }, + { FRAC_CONST(0.55266261100769), FRAC_CONST(0.59449058771133) }, + { FRAC_CONST(0.34581178426743), FRAC_CONST(0.94879418611526) }, + { FRAC_CONST(0.62664210796356), FRAC_CONST(-0.74402970075607) }, + { FRAC_CONST(-0.77149701118469), FRAC_CONST(-0.33883658051491) }, + { FRAC_CONST(-0.91592246294022), FRAC_CONST(0.03687901422381) }, + { FRAC_CONST(-0.76285493373871), FRAC_CONST(-0.91371870040894) }, + { FRAC_CONST(0.79788339138031), FRAC_CONST(-0.93180972337723) }, + { FRAC_CONST(0.54473078250885), FRAC_CONST(-0.11919206380844) }, + { FRAC_CONST(-0.85639280080795), FRAC_CONST(0.42429855465889) }, + { FRAC_CONST(-0.92882400751114), FRAC_CONST(0.27871808409691) }, + { FRAC_CONST(-0.11708371341228), FRAC_CONST(-0.99800843000412) }, + { FRAC_CONST(0.21356749534607), FRAC_CONST(-0.90716296434402) }, + { FRAC_CONST(-0.76191693544388), FRAC_CONST(0.99768120050430) }, + { FRAC_CONST(0.98111045360565), FRAC_CONST(-0.95854461193085) }, + { FRAC_CONST(-0.85913270711899), FRAC_CONST(0.95766568183899) }, + { FRAC_CONST(-0.93307244777679), FRAC_CONST(0.49431759119034) }, + { FRAC_CONST(0.30485755205154), FRAC_CONST(-0.70540034770966) }, + { FRAC_CONST(0.85289651155472), FRAC_CONST(0.46766132116318) }, + { FRAC_CONST(0.91328084468842), FRAC_CONST(-0.99839597940445) }, + { FRAC_CONST(-0.05890199914575), FRAC_CONST(0.70741826295853) }, + { FRAC_CONST(0.28398686647415), FRAC_CONST(0.34633556008339) }, + { FRAC_CONST(0.95258164405823), FRAC_CONST(-0.54893416166306) }, + { FRAC_CONST(-0.78566324710846), FRAC_CONST(-0.75568538904190) }, + { FRAC_CONST(-0.95789498090744), FRAC_CONST(-0.20423194766045) }, + { FRAC_CONST(0.82411158084869), FRAC_CONST(0.96654617786407) }, + { FRAC_CONST(-0.65185445547104), FRAC_CONST(-0.88734990358353) }, + { FRAC_CONST(-0.93643605709076), FRAC_CONST(0.99870789051056) }, + { FRAC_CONST(0.91427159309387), FRAC_CONST(-0.98290503025055) }, + { FRAC_CONST(-0.70395684242249), FRAC_CONST(0.58796799182892) }, + { FRAC_CONST(0.00563771976158), FRAC_CONST(0.61768198013306) }, + { FRAC_CONST(0.89065051078796), FRAC_CONST(0.52783352136612) }, + { FRAC_CONST(-0.68683707714081), FRAC_CONST(0.80806946754456) }, + { FRAC_CONST(0.72165340185165), FRAC_CONST(-0.69259858131409) }, + { FRAC_CONST(-0.62928247451782), FRAC_CONST(0.13627037405968) }, + { FRAC_CONST(0.29938435554504), FRAC_CONST(-0.46051329374313) }, + { FRAC_CONST(-0.91781955957413), FRAC_CONST(-0.74012714624405) }, + { FRAC_CONST(0.99298715591431), FRAC_CONST(0.40816611051559) }, + { FRAC_CONST(0.82368296384811), FRAC_CONST(-0.74036049842834) }, + { FRAC_CONST(-0.98512834310532), FRAC_CONST(-0.99972331523895) }, + { FRAC_CONST(-0.95915371179581), FRAC_CONST(-0.99237799644470) }, + { FRAC_CONST(-0.21411126852036), FRAC_CONST(-0.93424820899963) }, + { FRAC_CONST(-0.68821477890015), FRAC_CONST(-0.26892307400703) }, + { FRAC_CONST(0.91851997375488), FRAC_CONST(0.09358228743076) }, + { FRAC_CONST(-0.96062767505646), FRAC_CONST(0.36099094152451) }, + { FRAC_CONST(0.51646184921265), FRAC_CONST(-0.71373331546783) }, + { FRAC_CONST(0.61130720376968), FRAC_CONST(0.46950140595436) }, + { FRAC_CONST(0.47336128354073), FRAC_CONST(-0.27333179116249) }, + { FRAC_CONST(0.90998309850693), FRAC_CONST(0.96715664863586) }, + { FRAC_CONST(0.44844800233841), FRAC_CONST(0.99211573600769) }, + { FRAC_CONST(0.66614890098572), FRAC_CONST(0.96590173244476) }, + { FRAC_CONST(0.74922239780426), FRAC_CONST(-0.89879858493805) }, + { FRAC_CONST(-0.99571585655212), FRAC_CONST(0.52785521745682) }, + { FRAC_CONST(0.97401082515717), FRAC_CONST(-0.16855870187283) }, + { FRAC_CONST(0.72683745622635), FRAC_CONST(-0.48060774803162) }, + { FRAC_CONST(0.95432192087173), FRAC_CONST(0.68849605321884) }, + { FRAC_CONST(-0.72962206602097), FRAC_CONST(-0.76608443260193) }, + { FRAC_CONST(-0.85359477996826), FRAC_CONST(0.88738125562668) }, + { FRAC_CONST(-0.81412428617477), FRAC_CONST(-0.97480767965317) }, + { FRAC_CONST(-0.87930774688721), FRAC_CONST(0.74748307466507) }, + { FRAC_CONST(-0.71573328971863), FRAC_CONST(-0.98570609092712) }, + { FRAC_CONST(0.83524298667908), FRAC_CONST(0.83702534437180) }, + { FRAC_CONST(-0.48086065053940), FRAC_CONST(-0.98848503828049) }, + { FRAC_CONST(0.97139126062393), FRAC_CONST(0.80093622207642) }, + { FRAC_CONST(0.51992827653885), FRAC_CONST(0.80247628688812) }, + { FRAC_CONST(-0.00848591234535), FRAC_CONST(-0.76670128107071) }, + { FRAC_CONST(-0.70294374227524), FRAC_CONST(0.55359911918640) }, + { FRAC_CONST(-0.95894426107407), FRAC_CONST(-0.43265503644943) }, + { FRAC_CONST(0.97079253196716), FRAC_CONST(0.09325857460499) }, + { FRAC_CONST(-0.92404294013977), FRAC_CONST(0.85507702827454) }, + { FRAC_CONST(-0.69506472349167), FRAC_CONST(0.98633414506912) }, + { FRAC_CONST(0.26559203863144), FRAC_CONST(0.73314309120178) }, + { FRAC_CONST(0.28038442134857), FRAC_CONST(0.14537914097309) }, + { FRAC_CONST(-0.74138122797012), FRAC_CONST(0.99310338497162) }, + { FRAC_CONST(-0.01752796024084), FRAC_CONST(-0.82616633176804) }, + { FRAC_CONST(-0.55126774311066), FRAC_CONST(-0.98898541927338) }, + { FRAC_CONST(0.97960901260376), FRAC_CONST(-0.94021445512772) }, + { FRAC_CONST(-0.99196308851242), FRAC_CONST(0.67019015550613) }, + { FRAC_CONST(-0.67684930562973), FRAC_CONST(0.12631492316723) }, + { FRAC_CONST(0.09140039235353), FRAC_CONST(-0.20537731051445) }, + { FRAC_CONST(-0.71658962965012), FRAC_CONST(-0.97788202762604) }, + { FRAC_CONST(0.81014639139175), FRAC_CONST(0.53722649812698) }, + { FRAC_CONST(0.40616992115974), FRAC_CONST(-0.26469007134438) }, + { FRAC_CONST(-0.67680186033249), FRAC_CONST(0.94502049684525) }, + { FRAC_CONST(0.86849772930145), FRAC_CONST(-0.18333598971367) }, + { FRAC_CONST(-0.99500381946564), FRAC_CONST(-0.02634122036397) }, + { FRAC_CONST(0.84329187870026), FRAC_CONST(0.10406957566738) }, + { FRAC_CONST(-0.09215968847275), FRAC_CONST(0.69540011882782) }, + { FRAC_CONST(0.99956172704697), FRAC_CONST(-0.12358541786671) }, + { FRAC_CONST(-0.79732781648636), FRAC_CONST(-0.91582524776459) }, + { FRAC_CONST(0.96349972486496), FRAC_CONST(0.96640455722809) }, + { FRAC_CONST(-0.79942780733109), FRAC_CONST(0.64323902130127) }, + { FRAC_CONST(-0.11566039919853), FRAC_CONST(0.28587844967842) }, + { FRAC_CONST(-0.39922955632210), FRAC_CONST(0.94129604101181) }, + { FRAC_CONST(0.99089199304581), FRAC_CONST(-0.92062628269196) }, + { FRAC_CONST(0.28631284832954), FRAC_CONST(-0.91035044193268) }, + { FRAC_CONST(-0.83302724361420), FRAC_CONST(-0.67330408096313) }, + { FRAC_CONST(0.95404446125031), FRAC_CONST(0.49162766337395) }, + { FRAC_CONST(-0.06449863314629), FRAC_CONST(0.03250560909510) }, + { FRAC_CONST(-0.99575054645538), FRAC_CONST(0.42389783263206) }, + { FRAC_CONST(-0.65501141548157), FRAC_CONST(0.82546114921570) }, + { FRAC_CONST(-0.81254440546036), FRAC_CONST(-0.51627236604691) }, + { FRAC_CONST(-0.99646371603012), FRAC_CONST(0.84490531682968) }, + { FRAC_CONST(0.00287840608507), FRAC_CONST(0.64768260717392) }, + { FRAC_CONST(0.70176988840103), FRAC_CONST(-0.20453028380871) }, + { FRAC_CONST(0.96361881494522), FRAC_CONST(0.40706968307495) }, + { FRAC_CONST(-0.68883758783340), FRAC_CONST(0.91338956356049) }, + { FRAC_CONST(-0.34875586628914), FRAC_CONST(0.71472293138504) }, + { FRAC_CONST(0.91980081796646), FRAC_CONST(0.66507452726364) }, + { FRAC_CONST(-0.99009048938751), FRAC_CONST(0.85868018865585) }, + { FRAC_CONST(0.68865793943405), FRAC_CONST(0.55660319328308) }, + { FRAC_CONST(-0.99484401941299), FRAC_CONST(-0.20052559673786) }, + { FRAC_CONST(0.94214510917664), FRAC_CONST(-0.99696427583694) }, + { FRAC_CONST(-0.67414629459381), FRAC_CONST(0.49548220634460) }, + { FRAC_CONST(-0.47339352965355), FRAC_CONST(-0.85904330015182) }, + { FRAC_CONST(0.14323651790619), FRAC_CONST(-0.94145596027374) }, + { FRAC_CONST(-0.29268294572830), FRAC_CONST(0.05759225040674) }, + { FRAC_CONST(0.43793860077858), FRAC_CONST(-0.78904968500137) }, + { FRAC_CONST(-0.36345127224922), FRAC_CONST(0.64874434471130) }, + { FRAC_CONST(-0.08750604838133), FRAC_CONST(0.97686946392059) }, + { FRAC_CONST(-0.96495270729065), FRAC_CONST(-0.53960305452347) }, + { FRAC_CONST(0.55526942014694), FRAC_CONST(0.78891521692276) }, + { FRAC_CONST(0.73538213968277), FRAC_CONST(0.96452075242996) }, + { FRAC_CONST(-0.30889773368835), FRAC_CONST(-0.80664390325546) }, + { FRAC_CONST(0.03574995696545), FRAC_CONST(-0.97325617074966) }, + { FRAC_CONST(0.98720687627792), FRAC_CONST(0.48409134149551) }, + { FRAC_CONST(-0.81689298152924), FRAC_CONST(-0.90827703475952) }, + { FRAC_CONST(0.67866861820221), FRAC_CONST(0.81284505128860) }, + { FRAC_CONST(-0.15808570384979), FRAC_CONST(0.85279554128647) }, + { FRAC_CONST(0.80723392963409), FRAC_CONST(-0.24717418849468) }, + { FRAC_CONST(0.47788757085800), FRAC_CONST(-0.46333149075508) }, + { FRAC_CONST(0.96367555856705), FRAC_CONST(0.38486748933792) }, + { FRAC_CONST(-0.99143874645233), FRAC_CONST(-0.24945276975632) }, + { FRAC_CONST(0.83081877231598), FRAC_CONST(-0.94780850410461) }, + { FRAC_CONST(-0.58753192424774), FRAC_CONST(0.01290772389621) }, + { FRAC_CONST(0.95538109540939), FRAC_CONST(-0.85557049512863) }, + { FRAC_CONST(-0.96490919589996), FRAC_CONST(-0.64020973443985) }, + { FRAC_CONST(-0.97327101230621), FRAC_CONST(0.12378127872944) }, + { FRAC_CONST(0.91400367021561), FRAC_CONST(0.57972472906113) }, + { FRAC_CONST(-0.99925839900970), FRAC_CONST(0.71084845066071) }, + { FRAC_CONST(-0.86875903606415), FRAC_CONST(-0.20291699469090) }, + { FRAC_CONST(-0.26240035891533), FRAC_CONST(-0.68264555931091) }, + { FRAC_CONST(-0.24664412438869), FRAC_CONST(-0.87642270326614) }, + { FRAC_CONST(0.02416275814176), FRAC_CONST(0.27192914485931) }, + { FRAC_CONST(0.82068622112274), FRAC_CONST(-0.85087788105011) }, + { FRAC_CONST(0.88547372817993), FRAC_CONST(-0.89636802673340) }, + { FRAC_CONST(-0.18173077702522), FRAC_CONST(-0.26152145862579) }, + { FRAC_CONST(0.09355476498604), FRAC_CONST(0.54845124483109) }, + { FRAC_CONST(-0.54668414592743), FRAC_CONST(0.95980775356293) }, + { FRAC_CONST(0.37050989270210), FRAC_CONST(-0.59910142421722) }, + { FRAC_CONST(-0.70373594760895), FRAC_CONST(0.91227668523788) }, + { FRAC_CONST(-0.34600785374641), FRAC_CONST(-0.99441426992416) }, + { FRAC_CONST(-0.68774479627609), FRAC_CONST(-0.30238837003708) }, + { FRAC_CONST(-0.26843291521072), FRAC_CONST(0.83115667104721) }, + { FRAC_CONST(0.49072334170341), FRAC_CONST(-0.45359709858894) }, + { FRAC_CONST(0.38975992798805), FRAC_CONST(0.95515358448029) }, + { FRAC_CONST(-0.97757124900818), FRAC_CONST(0.05305894464254) }, + { FRAC_CONST(-0.17325553297997), FRAC_CONST(-0.92770671844482) }, + { FRAC_CONST(0.99948036670685), FRAC_CONST(0.58285546302795) }, + { FRAC_CONST(-0.64946246147156), FRAC_CONST(0.68645507097244) }, + { FRAC_CONST(-0.12016920745373), FRAC_CONST(-0.57147324085236) }, + { FRAC_CONST(-0.58947455883026), FRAC_CONST(-0.34847131371498) }, + { FRAC_CONST(-0.41815140843391), FRAC_CONST(0.16276422142982) }, + { FRAC_CONST(0.99885648488998), FRAC_CONST(0.11136095225811) }, + { FRAC_CONST(-0.56649613380432), FRAC_CONST(-0.90494865179062) }, + { FRAC_CONST(0.94138020277023), FRAC_CONST(0.35281917452812) }, + { FRAC_CONST(-0.75725078582764), FRAC_CONST(0.53650552034378) }, + { FRAC_CONST(0.20541973412037), FRAC_CONST(-0.94435143470764) }, + { FRAC_CONST(0.99980372190475), FRAC_CONST(0.79835915565491) }, + { FRAC_CONST(0.29078277945518), FRAC_CONST(0.35393777489662) }, + { FRAC_CONST(-0.62858772277832), FRAC_CONST(0.38765692710876) }, + { FRAC_CONST(0.43440905213356), FRAC_CONST(-0.98546332120895) }, + { FRAC_CONST(-0.98298585414886), FRAC_CONST(0.21021524071693) }, + { FRAC_CONST(0.19513028860092), FRAC_CONST(-0.94239830970764) }, + { FRAC_CONST(-0.95476663112640), FRAC_CONST(0.98364555835724) }, + { FRAC_CONST(0.93379634618759), FRAC_CONST(-0.70881992578506) }, + { FRAC_CONST(-0.85235410928726), FRAC_CONST(-0.08342348039150) }, + { FRAC_CONST(-0.86425095796585), FRAC_CONST(-0.45795026421547) }, + { FRAC_CONST(0.38879778981209), FRAC_CONST(0.97274428606033) }, + { FRAC_CONST(0.92045122385025), FRAC_CONST(-0.62433654069901) }, + { FRAC_CONST(0.89162534475327), FRAC_CONST(0.54950958490372) }, + { FRAC_CONST(-0.36834338307381), FRAC_CONST(0.96458297967911) }, + { FRAC_CONST(0.93891763687134), FRAC_CONST(-0.89968353509903) }, + { FRAC_CONST(0.99267655611038), FRAC_CONST(-0.03757034242153) }, + { FRAC_CONST(-0.94063472747803), FRAC_CONST(0.41332337260246) }, + { FRAC_CONST(0.99740225076675), FRAC_CONST(-0.16830494999886) }, + { FRAC_CONST(-0.35899412631989), FRAC_CONST(-0.46633225679398) }, + { FRAC_CONST(0.05237237364054), FRAC_CONST(-0.25640362501144) }, + { FRAC_CONST(0.36703583598137), FRAC_CONST(-0.38653266429901) }, + { FRAC_CONST(0.91653180122375), FRAC_CONST(-0.30587628483772) }, + { FRAC_CONST(0.69000804424286), FRAC_CONST(0.90952169895172) }, + { FRAC_CONST(-0.38658750057220), FRAC_CONST(0.99501574039459) }, + { FRAC_CONST(-0.29250815510750), FRAC_CONST(0.37444993853569) }, + { FRAC_CONST(-0.60182201862335), FRAC_CONST(0.86779648065567) }, + { FRAC_CONST(-0.97418588399887), FRAC_CONST(0.96468526124954) }, + { FRAC_CONST(0.88461571931839), FRAC_CONST(0.57508403062820) }, + { FRAC_CONST(0.05198933184147), FRAC_CONST(0.21269661188126) }, + { FRAC_CONST(-0.53499621152878), FRAC_CONST(0.97241556644440) }, + { FRAC_CONST(-0.49429559707642), FRAC_CONST(0.98183864355087) }, + { FRAC_CONST(-0.98935145139694), FRAC_CONST(-0.40249159932137) }, + { FRAC_CONST(-0.98081380128860), FRAC_CONST(-0.72856897115707) }, + { FRAC_CONST(-0.27338150143623), FRAC_CONST(0.99950921535492) }, + { FRAC_CONST(0.06310802698135), FRAC_CONST(-0.54539585113525) }, + { FRAC_CONST(-0.20461677014828), FRAC_CONST(-0.14209978282452) }, + { FRAC_CONST(0.66223841905594), FRAC_CONST(0.72528582811356) }, + { FRAC_CONST(-0.84764343500137), FRAC_CONST(0.02372316829860) }, + { FRAC_CONST(-0.89039862155914), FRAC_CONST(0.88866579532623) }, + { FRAC_CONST(0.95903307199478), FRAC_CONST(0.76744925975800) }, + { FRAC_CONST(0.73504126071930), FRAC_CONST(-0.03747203201056) }, + { FRAC_CONST(-0.31744435429573), FRAC_CONST(-0.36834111809731) }, + { FRAC_CONST(-0.34110826253891), FRAC_CONST(0.40211221575737) }, + { FRAC_CONST(0.47803884744644), FRAC_CONST(-0.39423218369484) }, + { FRAC_CONST(0.98299193382263), FRAC_CONST(0.01989791356027) }, + { FRAC_CONST(-0.30963072180748), FRAC_CONST(-0.18076720833778) }, + { FRAC_CONST(0.99992591142654), FRAC_CONST(-0.26281872391701) }, + { FRAC_CONST(-0.93149733543396), FRAC_CONST(-0.98313164710999) }, + { FRAC_CONST(0.99923473596573), FRAC_CONST(-0.80142992734909) }, + { FRAC_CONST(-0.26024168729782), FRAC_CONST(-0.75999760627747) }, + { FRAC_CONST(-0.35712513327599), FRAC_CONST(0.19298963248730) }, + { FRAC_CONST(-0.99899083375931), FRAC_CONST(0.74645155668259) }, + { FRAC_CONST(0.86557173728943), FRAC_CONST(0.55593866109848) }, + { FRAC_CONST(0.33408042788506), FRAC_CONST(0.86185956001282) }, + { FRAC_CONST(0.99010735750198), FRAC_CONST(0.04602397605777) }, + { FRAC_CONST(-0.66694271564484), FRAC_CONST(-0.91643613576889) }, + { FRAC_CONST(0.64016789197922), FRAC_CONST(0.15649530291557) }, + { FRAC_CONST(0.99570536613464), FRAC_CONST(0.45844584703445) }, + { FRAC_CONST(-0.63431465625763), FRAC_CONST(0.21079117059708) }, + { FRAC_CONST(-0.07706847041845), FRAC_CONST(-0.89581435918808) }, + { FRAC_CONST(0.98590087890625), FRAC_CONST(0.88241720199585) }, + { FRAC_CONST(0.80099332332611), FRAC_CONST(-0.36851897835732) }, + { FRAC_CONST(0.78368133306503), FRAC_CONST(0.45506998896599) }, + { FRAC_CONST(0.08707806468010), FRAC_CONST(0.80938994884491) }, + { FRAC_CONST(-0.86811882257462), FRAC_CONST(0.39347308874130) }, + { FRAC_CONST(-0.39466530084610), FRAC_CONST(-0.66809433698654) }, + { FRAC_CONST(0.97875326871872), FRAC_CONST(-0.72467839717865) }, + { FRAC_CONST(-0.95038563013077), FRAC_CONST(0.89563220739365) }, + { FRAC_CONST(0.17005239427090), FRAC_CONST(0.54683053493500) }, + { FRAC_CONST(-0.76910793781281), FRAC_CONST(-0.96226614713669) }, + { FRAC_CONST(0.99743282794952), FRAC_CONST(0.42697158455849) }, + { FRAC_CONST(0.95437383651733), FRAC_CONST(0.97002321481705) }, + { FRAC_CONST(0.99578905105591), FRAC_CONST(-0.54106825590134) }, + { FRAC_CONST(0.28058260679245), FRAC_CONST(-0.85361421108246) }, + { FRAC_CONST(0.85256522893906), FRAC_CONST(-0.64567607641220) }, + { FRAC_CONST(-0.50608539581299), FRAC_CONST(-0.65846014022827) }, + { FRAC_CONST(-0.97210735082626), FRAC_CONST(-0.23095212876797) }, + { FRAC_CONST(0.95424050092697), FRAC_CONST(-0.99240148067474) }, + { FRAC_CONST(-0.96926569938660), FRAC_CONST(0.73775655031204) }, + { FRAC_CONST(0.30872163176537), FRAC_CONST(0.41514959931374) }, + { FRAC_CONST(-0.24523839354515), FRAC_CONST(0.63206630945206) }, + { FRAC_CONST(-0.33813264966011), FRAC_CONST(-0.38661777973175) }, + { FRAC_CONST(-0.05826828256249), FRAC_CONST(-0.06940773874521) }, + { FRAC_CONST(-0.22898460924625), FRAC_CONST(0.97054851055145) }, + { FRAC_CONST(-0.18509915471077), FRAC_CONST(0.47565764188766) }, + { FRAC_CONST(-0.10488238185644), FRAC_CONST(-0.87769949436188) }, + { FRAC_CONST(-0.71886587142944), FRAC_CONST(0.78030979633331) }, + { FRAC_CONST(0.99793875217438), FRAC_CONST(0.90041309595108) }, + { FRAC_CONST(0.57563304901123), FRAC_CONST(-0.91034334897995) }, + { FRAC_CONST(0.28909647464752), FRAC_CONST(0.96307784318924) }, + { FRAC_CONST(0.42188999056816), FRAC_CONST(0.48148649930954) }, + { FRAC_CONST(0.93335050344467), FRAC_CONST(-0.43537023663521) }, + { FRAC_CONST(-0.97087377309799), FRAC_CONST(0.86636447906494) }, + { FRAC_CONST(0.36722871661186), FRAC_CONST(0.65291655063629) }, + { FRAC_CONST(-0.81093025207520), FRAC_CONST(0.08778370171785) }, + { FRAC_CONST(-0.26240602135658), FRAC_CONST(-0.92774093151093) }, + { FRAC_CONST(0.83996498584747), FRAC_CONST(0.55839848518372) }, + { FRAC_CONST(-0.99909615516663), FRAC_CONST(-0.96024608612061) }, + { FRAC_CONST(0.74649465084076), FRAC_CONST(0.12144893407822) }, + { FRAC_CONST(-0.74774593114853), FRAC_CONST(-0.26898062229156) }, + { FRAC_CONST(0.95781666040421), FRAC_CONST(-0.79047924280167) }, + { FRAC_CONST(0.95472306013107), FRAC_CONST(-0.08588775992393) }, + { FRAC_CONST(0.48708331584930), FRAC_CONST(0.99999040365219) }, + { FRAC_CONST(0.46332037448883), FRAC_CONST(0.10964126139879) }, + { FRAC_CONST(-0.76497006416321), FRAC_CONST(0.89210927486420) }, + { FRAC_CONST(0.57397389411926), FRAC_CONST(0.35289704799652) }, + { FRAC_CONST(0.75374317169189), FRAC_CONST(0.96705216169357) }, + { FRAC_CONST(-0.59174400568008), FRAC_CONST(-0.89405369758606) }, + { FRAC_CONST(0.75087904930115), FRAC_CONST(-0.29612672328949) }, + { FRAC_CONST(-0.98607856035233), FRAC_CONST(0.25034910440445) }, + { FRAC_CONST(-0.40761056542397), FRAC_CONST(-0.90045571327209) }, + { FRAC_CONST(0.66929268836975), FRAC_CONST(0.98629492521286) }, + { FRAC_CONST(-0.97463697195053), FRAC_CONST(-0.00190223299433) }, + { FRAC_CONST(0.90145510435104), FRAC_CONST(0.99781388044357) }, + { FRAC_CONST(-0.87259286642075), FRAC_CONST(0.99233585596085) }, + { FRAC_CONST(-0.91529458761215), FRAC_CONST(-0.15698707103729) }, + { FRAC_CONST(-0.03305738791823), FRAC_CONST(-0.37205263972282) }, + { FRAC_CONST(0.07223051041365), FRAC_CONST(-0.88805001974106) }, + { FRAC_CONST(0.99498009681702), FRAC_CONST(0.97094357013702) }, + { FRAC_CONST(-0.74904936552048), FRAC_CONST(0.99985486268997) }, + { FRAC_CONST(0.04585228487849), FRAC_CONST(0.99812334775925) }, + { FRAC_CONST(-0.89054954051971), FRAC_CONST(-0.31791913509369) }, + { FRAC_CONST(-0.83782142400742), FRAC_CONST(0.97637635469437) }, + { FRAC_CONST(0.33454805612564), FRAC_CONST(-0.86231517791748) }, + { FRAC_CONST(-0.99707579612732), FRAC_CONST(0.93237990140915) }, + { FRAC_CONST(-0.22827528417110), FRAC_CONST(0.18874759972095) }, + { FRAC_CONST(0.67248046398163), FRAC_CONST(-0.03646211326122) }, + { FRAC_CONST(-0.05146538093686), FRAC_CONST(-0.92599701881409) }, + { FRAC_CONST(0.99947297573090), FRAC_CONST(0.93625229597092) }, + { FRAC_CONST(0.66951125860214), FRAC_CONST(0.98905825614929) }, + { FRAC_CONST(-0.99602955579758), FRAC_CONST(-0.44654715061188) }, + { FRAC_CONST(0.82104903459549), FRAC_CONST(0.99540740251541) }, + { FRAC_CONST(0.99186509847641), FRAC_CONST(0.72022998332977) }, + { FRAC_CONST(-0.65284591913223), FRAC_CONST(0.52186721563339) }, + { FRAC_CONST(0.93885445594788), FRAC_CONST(-0.74895310401917) }, + { FRAC_CONST(0.96735250949860), FRAC_CONST(0.90891814231873) }, + { FRAC_CONST(-0.22225968539715), FRAC_CONST(0.57124030590057) }, + { FRAC_CONST(-0.44132784008980), FRAC_CONST(-0.92688840627670) }, + { FRAC_CONST(-0.85694974660873), FRAC_CONST(0.88844531774521) }, + { FRAC_CONST(0.91783040761948), FRAC_CONST(-0.46356892585754) }, + { FRAC_CONST(0.72556972503662), FRAC_CONST(-0.99899554252625) }, + { FRAC_CONST(-0.99711579084396), FRAC_CONST(0.58211559057236) }, + { FRAC_CONST(0.77638977766037), FRAC_CONST(0.94321835041046) }, + { FRAC_CONST(0.07717324048281), FRAC_CONST(0.58638399839401) }, + { FRAC_CONST(-0.56049829721451), FRAC_CONST(0.82522302865982) }, + { FRAC_CONST(0.98398894071579), FRAC_CONST(0.39467439055443) }, + { FRAC_CONST(0.47546947002411), FRAC_CONST(0.68613046407700) }, + { FRAC_CONST(0.65675091743469), FRAC_CONST(0.18331636488438) }, + { FRAC_CONST(0.03273375332355), FRAC_CONST(-0.74933111667633) }, + { FRAC_CONST(-0.38684144616127), FRAC_CONST(0.51337349414825) }, + { FRAC_CONST(-0.97346270084381), FRAC_CONST(-0.96549361944199) }, + { FRAC_CONST(-0.53282153606415), FRAC_CONST(-0.91423267126083) }, + { FRAC_CONST(0.99817311763763), FRAC_CONST(0.61133575439453) }, + { FRAC_CONST(-0.50254499912262), FRAC_CONST(-0.88829338550568) }, + { FRAC_CONST(0.01995873264968), FRAC_CONST(0.85223513841629) }, + { FRAC_CONST(0.99930381774902), FRAC_CONST(0.94578897953033) }, + { FRAC_CONST(0.82907766103745), FRAC_CONST(-0.06323442608118) }, + { FRAC_CONST(-0.58660709857941), FRAC_CONST(0.96840775012970) }, + { FRAC_CONST(-0.17573736608028), FRAC_CONST(-0.48166921734810) }, + { FRAC_CONST(0.83434289693832), FRAC_CONST(-0.13023450970650) }, + { FRAC_CONST(0.05946491286159), FRAC_CONST(0.20511047542095) }, + { FRAC_CONST(0.81505483388901), FRAC_CONST(-0.94685947895050) }, + { FRAC_CONST(-0.44976380467415), FRAC_CONST(0.40894573926926) }, + { FRAC_CONST(-0.89746475219727), FRAC_CONST(0.99846577644348) }, + { FRAC_CONST(0.39677256345749), FRAC_CONST(-0.74854665994644) }, + { FRAC_CONST(-0.07588948309422), FRAC_CONST(0.74096214771271) }, + { FRAC_CONST(0.76343196630478), FRAC_CONST(0.41746628284454) }, + { FRAC_CONST(-0.74490106105804), FRAC_CONST(0.94725912809372) }, + { FRAC_CONST(0.64880120754242), FRAC_CONST(0.41336661577225) }, + { FRAC_CONST(0.62319535017014), FRAC_CONST(-0.93098312616348) }, + { FRAC_CONST(0.42215818166733), FRAC_CONST(-0.07712787389755) }, + { FRAC_CONST(0.02704554051161), FRAC_CONST(-0.05417517945170) }, + { FRAC_CONST(0.80001771450043), FRAC_CONST(0.91542196273804) }, + { FRAC_CONST(-0.79351830482483), FRAC_CONST(-0.36208897829056) }, + { FRAC_CONST(0.63872361183167), FRAC_CONST(0.08128252625465) }, + { FRAC_CONST(0.52890521287918), FRAC_CONST(0.60048872232437) }, + { FRAC_CONST(0.74238550662994), FRAC_CONST(0.04491915181279) }, + { FRAC_CONST(0.99096131324768), FRAC_CONST(-0.19451183080673) }, + { FRAC_CONST(-0.80412328243256), FRAC_CONST(-0.88513815402985) }, + { FRAC_CONST(-0.64612615108490), FRAC_CONST(0.72198677062988) }, + { FRAC_CONST(0.11657770723104), FRAC_CONST(-0.83662831783295) }, + { FRAC_CONST(-0.95053184032440), FRAC_CONST(-0.96939903497696) }, + { FRAC_CONST(-0.62228870391846), FRAC_CONST(0.82767260074615) }, + { FRAC_CONST(0.03004475869238), FRAC_CONST(-0.99738895893097) }, + { FRAC_CONST(-0.97987216711044), FRAC_CONST(0.36526128649712) }, + { FRAC_CONST(-0.99986982345581), FRAC_CONST(-0.36021611094475) }, + { FRAC_CONST(0.89110648632050), FRAC_CONST(-0.97894251346588) }, + { FRAC_CONST(0.10407960414886), FRAC_CONST(0.77357792854309) }, + { FRAC_CONST(0.95964735746384), FRAC_CONST(-0.35435819625854) }, + { FRAC_CONST(0.50843232870102), FRAC_CONST(0.96107691526413) }, + { FRAC_CONST(0.17006334662437), FRAC_CONST(-0.76854026317596) }, + { FRAC_CONST(0.25872674584389), FRAC_CONST(0.99893301725388) }, + { FRAC_CONST(-0.01115998718888), FRAC_CONST(0.98496019840240) }, + { FRAC_CONST(-0.79598701000214), FRAC_CONST(0.97138410806656) }, + { FRAC_CONST(-0.99264711141586), FRAC_CONST(-0.99542820453644) }, + { FRAC_CONST(-0.99829661846161), FRAC_CONST(0.01877138763666) }, + { FRAC_CONST(-0.70801013708115), FRAC_CONST(0.33680686354637) }, + { FRAC_CONST(-0.70467054843903), FRAC_CONST(0.93272775411606) }, + { FRAC_CONST(0.99846023321152), FRAC_CONST(-0.98725748062134) }, + { FRAC_CONST(-0.63364970684052), FRAC_CONST(-0.16473594307899) }, + { FRAC_CONST(-0.16258217394352), FRAC_CONST(-0.95939123630524) }, + { FRAC_CONST(-0.43645593523979), FRAC_CONST(-0.94805032014847) }, + { FRAC_CONST(-0.99848473072052), FRAC_CONST(0.96245169639587) }, + { FRAC_CONST(-0.16796459257603), FRAC_CONST(-0.98987513780594) }, + { FRAC_CONST(-0.87979227304459), FRAC_CONST(-0.71725726127625) }, + { FRAC_CONST(0.44183099269867), FRAC_CONST(-0.93568974733353) }, + { FRAC_CONST(0.93310177326202), FRAC_CONST(-0.99913311004639) }, + { FRAC_CONST(-0.93941932916641), FRAC_CONST(-0.56409376859665) }, + { FRAC_CONST(-0.88590002059937), FRAC_CONST(0.47624599933624) }, + { FRAC_CONST(0.99971461296082), FRAC_CONST(-0.83889955282211) }, + { FRAC_CONST(-0.75376385450363), FRAC_CONST(0.00814643409103) }, + { FRAC_CONST(0.93887686729431), FRAC_CONST(-0.11284527927637) }, + { FRAC_CONST(0.85126435756683), FRAC_CONST(0.52349251508713) }, + { FRAC_CONST(0.39701420068741), FRAC_CONST(0.81779634952545) }, + { FRAC_CONST(-0.37024465203285), FRAC_CONST(-0.87071657180786) }, + { FRAC_CONST(-0.36024826765060), FRAC_CONST(0.34655734896660) }, + { FRAC_CONST(-0.93388813734055), FRAC_CONST(-0.84476542472839) }, + { FRAC_CONST(-0.65298801660538), FRAC_CONST(-0.18439576029778) }, + { FRAC_CONST(0.11960318684578), FRAC_CONST(0.99899345636368) }, + { FRAC_CONST(0.94292563199997), FRAC_CONST(0.83163905143738) }, + { FRAC_CONST(0.75081145763397), FRAC_CONST(-0.35533222556114) }, + { FRAC_CONST(0.56721979379654), FRAC_CONST(-0.24076835811138) }, + { FRAC_CONST(0.46857765316963), FRAC_CONST(-0.30140233039856) }, + { FRAC_CONST(0.97312313318253), FRAC_CONST(-0.99548190832138) }, + { FRAC_CONST(-0.38299977779388), FRAC_CONST(0.98516911268234) }, + { FRAC_CONST(0.41025799512863), FRAC_CONST(0.02116736955941) }, + { FRAC_CONST(0.09638062119484), FRAC_CONST(0.04411984235048) }, + { FRAC_CONST(-0.85283249616623), FRAC_CONST(0.91475564241409) }, + { FRAC_CONST(0.88866806030273), FRAC_CONST(-0.99735265970230) }, + { FRAC_CONST(-0.48202428221703), FRAC_CONST(-0.96805608272552) }, + { FRAC_CONST(0.27572581171989), FRAC_CONST(0.58634752035141) }, + { FRAC_CONST(-0.65889132022858), FRAC_CONST(0.58835631608963) }, + { FRAC_CONST(0.98838084936142), FRAC_CONST(0.99994349479675) }, + { FRAC_CONST(-0.20651349425316), FRAC_CONST(0.54593044519424) }, + { FRAC_CONST(-0.62126415967941), FRAC_CONST(-0.59893679618835) }, + { FRAC_CONST(0.20320105552673), FRAC_CONST(-0.86879181861877) }, + { FRAC_CONST(-0.97790551185608), FRAC_CONST(0.96290808916092) }, + { FRAC_CONST(0.11112534999847), FRAC_CONST(0.21484763920307) }, + { FRAC_CONST(-0.41368338465691), FRAC_CONST(0.28216838836670) }, + { FRAC_CONST(0.24133038520813), FRAC_CONST(0.51294362545013) }, + { FRAC_CONST(-0.66393411159515), FRAC_CONST(-0.08249679952860) }, + { FRAC_CONST(-0.53697830438614), FRAC_CONST(-0.97649902105331) }, + { FRAC_CONST(-0.97224736213684), FRAC_CONST(0.22081333398819) }, + { FRAC_CONST(0.87392479181290), FRAC_CONST(-0.12796173989773) }, + { FRAC_CONST(0.19050361216068), FRAC_CONST(0.01602615416050) }, + { FRAC_CONST(-0.46353441476822), FRAC_CONST(-0.95249038934708) }, + { FRAC_CONST(-0.07064096629620), FRAC_CONST(-0.94479805231094) }, + { FRAC_CONST(-0.92444086074829), FRAC_CONST(-0.10457590222359) }, + { FRAC_CONST(-0.83822596073151), FRAC_CONST(-0.01695043221116) }, + { FRAC_CONST(0.75214684009552), FRAC_CONST(-0.99955683946609) }, + { FRAC_CONST(-0.42102998495102), FRAC_CONST(0.99720942974091) }, + { FRAC_CONST(-0.72094786167145), FRAC_CONST(-0.35008960962296) }, + { FRAC_CONST(0.78843313455582), FRAC_CONST(0.52851396799088) }, + { FRAC_CONST(0.97394025325775), FRAC_CONST(-0.26695942878723) }, + { FRAC_CONST(0.99206465482712), FRAC_CONST(-0.57010120153427) }, + { FRAC_CONST(0.76789611577988), FRAC_CONST(-0.76519358158112) }, + { FRAC_CONST(-0.82002419233322), FRAC_CONST(-0.73530179262161) }, + { FRAC_CONST(0.81924992799759), FRAC_CONST(0.99698424339294) }, + { FRAC_CONST(-0.26719850301743), FRAC_CONST(0.68903368711472) }, + { FRAC_CONST(-0.43311259150505), FRAC_CONST(0.85321813821793) }, + { FRAC_CONST(0.99194979667664), FRAC_CONST(0.91876250505447) }, + { FRAC_CONST(-0.80691999197006), FRAC_CONST(-0.32627540826797) }, + { FRAC_CONST(0.43080005049706), FRAC_CONST(-0.21919095516205) }, + { FRAC_CONST(0.67709493637085), FRAC_CONST(-0.95478075742722) }, + { FRAC_CONST(0.56151771545410), FRAC_CONST(-0.70693808794022) }, + { FRAC_CONST(0.10831862688065), FRAC_CONST(-0.08628837019205) }, + { FRAC_CONST(0.91229414939880), FRAC_CONST(-0.65987348556519) }, + { FRAC_CONST(-0.48972892761230), FRAC_CONST(0.56289243698120) }, + { FRAC_CONST(-0.89033657312393), FRAC_CONST(-0.71656566858292) }, + { FRAC_CONST(0.65269446372986), FRAC_CONST(0.65916007757187) }, + { FRAC_CONST(0.67439478635788), FRAC_CONST(-0.81684380769730) }, + { FRAC_CONST(-0.47770830988884), FRAC_CONST(-0.16789555549622) }, + { FRAC_CONST(-0.99715977907181), FRAC_CONST(-0.93565785884857) }, + { FRAC_CONST(-0.90889590978622), FRAC_CONST(0.62034398317337) }, + { FRAC_CONST(-0.06618622690439), FRAC_CONST(-0.23812216520309) }, + { FRAC_CONST(0.99430269002914), FRAC_CONST(0.18812555074692) }, + { FRAC_CONST(0.97686403989792), FRAC_CONST(-0.28664535284042) }, + { FRAC_CONST(0.94813650846481), FRAC_CONST(-0.97506642341614) }, + { FRAC_CONST(-0.95434498786926), FRAC_CONST(-0.79607981443405) }, + { FRAC_CONST(-0.49104782938957), FRAC_CONST(0.32895213365555) }, + { FRAC_CONST(0.99881172180176), FRAC_CONST(0.88993984460831) }, + { FRAC_CONST(0.50449168682098), FRAC_CONST(-0.85995072126389) }, + { FRAC_CONST(0.47162890434265), FRAC_CONST(-0.18680204451084) }, + { FRAC_CONST(-0.62081581354141), FRAC_CONST(0.75000673532486) }, + { FRAC_CONST(-0.43867015838623), FRAC_CONST(0.99998068809509) }, + { FRAC_CONST(0.98630565404892), FRAC_CONST(-0.53578901290894) }, + { FRAC_CONST(-0.61510360240936), FRAC_CONST(-0.89515018463135) }, + { FRAC_CONST(-0.03841517493129), FRAC_CONST(-0.69888818264008) }, + { FRAC_CONST(-0.30102157592773), FRAC_CONST(-0.07667808979750) }, + { FRAC_CONST(0.41881284117699), FRAC_CONST(0.02188098989427) }, + { FRAC_CONST(-0.86135452985764), FRAC_CONST(0.98947483301163) }, + { FRAC_CONST(0.67226862907410), FRAC_CONST(-0.13494388759136) }, + { FRAC_CONST(-0.70737397670746), FRAC_CONST(-0.76547348499298) }, + { FRAC_CONST(0.94044947624207), FRAC_CONST(0.09026201069355) }, + { FRAC_CONST(-0.82386350631714), FRAC_CONST(0.08924768865108) }, + { FRAC_CONST(-0.32070666551590), FRAC_CONST(0.50143420696259) }, + { FRAC_CONST(0.57593160867691), FRAC_CONST(-0.98966425657272) }, + { FRAC_CONST(-0.36326017975807), FRAC_CONST(0.07440242916346) }, + { FRAC_CONST(0.99979043006897), FRAC_CONST(-0.14130286872387) }, + { FRAC_CONST(-0.92366021871567), FRAC_CONST(-0.97979295253754) }, + { FRAC_CONST(-0.44607177376747), FRAC_CONST(-0.54233253002167) }, + { FRAC_CONST(0.44226801395416), FRAC_CONST(0.71326756477356) }, + { FRAC_CONST(0.03671907261014), FRAC_CONST(0.63606387376785) }, + { FRAC_CONST(0.52175426483154), FRAC_CONST(-0.85396826267242) }, + { FRAC_CONST(-0.94701141119003), FRAC_CONST(-0.01826348155737) }, + { FRAC_CONST(-0.98759609460831), FRAC_CONST(0.82288712263107) }, + { FRAC_CONST(0.87434792518616), FRAC_CONST(0.89399492740631) }, + { FRAC_CONST(-0.93412041664124), FRAC_CONST(0.41374051570892) }, + { FRAC_CONST(0.96063941717148), FRAC_CONST(0.93116706609726) }, + { FRAC_CONST(0.97534251213074), FRAC_CONST(0.86150932312012) }, + { FRAC_CONST(0.99642467498779), FRAC_CONST(0.70190042257309) }, + { FRAC_CONST(-0.94705086946487), FRAC_CONST(-0.29580041766167) }, + { FRAC_CONST(0.91599804162979), FRAC_CONST(-0.98147833347321) } +}; + +#ifdef __cplusplus + +#endif +#endif + diff --git a/lib/rbcodec/codecs/libfaad/sbr_qmf.c b/lib/rbcodec/codecs/libfaad/sbr_qmf.c new file mode 100644 index 0000000000..5f8203e5b1 --- /dev/null +++ b/lib/rbcodec/codecs/libfaad/sbr_qmf.c @@ -0,0 +1,561 @@ +/* +** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding +** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +** +** Any non-GPL usage of this software or parts of this software is strictly +** forbidden. +** +** Commercial non-GPL licensing of this software is possible. +** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** +** $Id$ +**/ + +#include "common.h" +#include "structs.h" + +#ifdef SBR_DEC + + +#include +#include +#include "sbr_dct.h" +#include "sbr_qmf.h" +#include "sbr_qmf_c.h" +#include "sbr_syntax.h" + +#ifdef FIXED_POINT + #define FAAD_SYNTHESIS_SCALE(X) ((X)>>1) + #define FAAD_ANALYSIS_SCALE1(X) ((X)>>4) + #define FAAD_ANALYSIS_SCALE2(X) ((X)) + #define FAAD_ANALYSIS_SCALE3(X) ((X)) +#else + #define FAAD_SYNTHESIS_SCALE(X) ((X)/64.0f) + #define FAAD_ANALYSIS_SCALE1(X) ((X)) + #define FAAD_ANALYSIS_SCALE2(X) (2.0f*(X)) + #define FAAD_ANALYSIS_SCALE3(X) ((X)/32.0f) +#endif + + +void sbr_qmf_analysis_32(sbr_info *sbr, qmfa_info *qmfa, const real_t *input, + qmf_t X[MAX_NTSR][64], uint8_t offset, uint8_t kx) +{ + real_t u[64] MEM_ALIGN_ATTR; +#ifndef SBR_LOW_POWER + real_t real[32] MEM_ALIGN_ATTR; + real_t imag[32] MEM_ALIGN_ATTR; +#else + real_t y[32] MEM_ALIGN_ATTR; +#endif + qmf_t *pX; + uint32_t in = 0; + uint32_t l, idx0, idx1; + + /* qmf subsample l */ + for (l = 0; l < sbr->numTimeSlotsRate; l++) + { + int32_t n; + + /* shift input buffer x */ + /* input buffer is not shifted anymore, x is implemented as double ringbuffer */ + //memmove(qmfa->x + 32, qmfa->x, (320-32)*sizeof(real_t)); + + /* add new samples to input buffer x */ + idx0 = qmfa->x_index + 31; idx1 = idx0 + 320; + for (n = 0; n < 32; n+=4) + { + qmfa->x[idx0--] = qmfa->x[idx1--] = (input[in++]); + qmfa->x[idx0--] = qmfa->x[idx1--] = (input[in++]); + qmfa->x[idx0--] = qmfa->x[idx1--] = (input[in++]); + qmfa->x[idx0--] = qmfa->x[idx1--] = (input[in++]); + } + + /* window and summation to create array u */ + for (n = 0; n < 32; n++) + { + idx0 = qmfa->x_index + n; idx1 = n * 20; + u[n] = FAAD_ANALYSIS_SCALE1( + MUL_F(qmfa->x[idx0 ], qmf_c[idx1 ]) + + MUL_F(qmfa->x[idx0 + 64], qmf_c[idx1 + 2]) + + MUL_F(qmfa->x[idx0 + 128], qmf_c[idx1 + 4]) + + MUL_F(qmfa->x[idx0 + 192], qmf_c[idx1 + 6]) + + MUL_F(qmfa->x[idx0 + 256], qmf_c[idx1 + 8])); + } + for (n = 32; n < 64; n++) + { + idx0 = qmfa->x_index + n; idx1 = n * 20 - 639; + u[n] = FAAD_ANALYSIS_SCALE1( + MUL_F(qmfa->x[idx0 ], qmf_c[idx1 ]) + + MUL_F(qmfa->x[idx0 + 64], qmf_c[idx1 + 2]) + + MUL_F(qmfa->x[idx0 + 128], qmf_c[idx1 + 4]) + + MUL_F(qmfa->x[idx0 + 192], qmf_c[idx1 + 6]) + + MUL_F(qmfa->x[idx0 + 256], qmf_c[idx1 + 8])); + } + + /* update ringbuffer index */ + qmfa->x_index -= 32; + if (qmfa->x_index < 0) + qmfa->x_index = (320-32); + + /* calculate 32 subband samples by introducing X */ +#ifdef SBR_LOW_POWER + y[0] = u[48]; + for (n = 1; n < 16; n++) + y[n] = u[n+48] + u[48-n]; + for (n = 16; n < 32; n++) + y[n] = -u[n-16] + u[48-n]; + + DCT3_32_unscaled(u, y); + + for (n = 0; n < 32; n++) + { + if (n < kx) + { + QMF_RE(X[l + offset][n]) = FAAD_ANALYSIS_SCALE2(u[n]); + } else { + QMF_RE(X[l + offset][n]) = 0; + } + } +#else /* #ifdef SBR_LOW_POWER */ + + // Reordering of data moved from DCT_IV to here + idx0 = 30; idx1 = 63; + imag[31] = u[ 1]; real[ 0] = u[ 0]; + for (n = 1; n < 31; n+=3) + { + imag[idx0--] = u[n+1]; real[n ] = -u[idx1--]; + imag[idx0--] = u[n+2]; real[n+1] = -u[idx1--]; + imag[idx0--] = u[n+3]; real[n+2] = -u[idx1--]; + } + imag[ 0] = u[32]; real[31] = -u[33]; + + // dct4_kernel is DCT_IV without reordering which is done before and after FFT + dct4_kernel(real, imag); + + // Reordering of data moved from DCT_IV to here + /* Step 1: Calculate all non-zero pairs */ + pX = X[l + offset]; + for (n = 0; n < kx/2; n++) { + idx0 = 2*n; idx1 = idx0 + 1; + QMF_RE(pX[idx0]) = FAAD_ANALYSIS_SCALE2( real[n ]); + QMF_IM(pX[idx0]) = FAAD_ANALYSIS_SCALE2( imag[n ]); + QMF_RE(pX[idx1]) = FAAD_ANALYSIS_SCALE2(-imag[31-n]); + QMF_IM(pX[idx1]) = FAAD_ANALYSIS_SCALE2(-real[31-n]); + } + /* Step 2: Calculate a single pair with half zero'ed */ + if (kx&1) { + idx0 = 2*n; idx1 = idx0 + 1; + QMF_RE(pX[idx0]) = FAAD_ANALYSIS_SCALE2( real[n]); + QMF_IM(pX[idx0]) = FAAD_ANALYSIS_SCALE2( imag[n]); + QMF_RE(pX[idx1]) = QMF_IM(pX[idx1]) = 0; + n++; + } + /* Step 3: All other are zero'ed */ + for (; n < 16; n++) { + idx0 = 2*n; idx1 = idx0 + 1; + QMF_RE(pX[idx0]) = QMF_IM(pX[idx0]) = 0; + QMF_RE(pX[idx1]) = QMF_IM(pX[idx1]) = 0; + } +#endif /* #ifdef SBR_LOW_POWER */ + } +} + +#ifdef SBR_LOW_POWER + +void sbr_qmf_synthesis_32(sbr_info *sbr, qmfs_info *qmfs, qmf_t X[MAX_NTSR][64], + real_t *output) +{ + real_t x[16] MEM_ALIGN_ATTR; + real_t y[16] MEM_ALIGN_ATTR; + int16_t n, k, out = 0; + uint8_t l; + + /* qmf subsample l */ + for (l = 0; l < sbr->numTimeSlotsRate; l++) + { + /* shift buffers */ + /* we are not shifting v, it is a double ringbuffer */ + //memmove(qmfs->v + 64, qmfs->v, (640-64)*sizeof(real_t)); + + /* calculate 64 samples */ + for (k = 0; k < 16; k++) + { + y[k] = FAAD_ANALYSIS_SCALE3((QMF_RE(X[l][k]) - QMF_RE(X[l][31-k]))); + x[k] = FAAD_ANALYSIS_SCALE3((QMF_RE(X[l][k]) + QMF_RE(X[l][31-k]))); + } + + /* even n samples */ + DCT2_16_unscaled(x, x); + /* odd n samples */ + DCT4_16(y, y); + + for (n = 8; n < 24; n++) + { + qmfs->v[qmfs->v_index + n*2 ] = qmfs->v[qmfs->v_index + 640 + n*2 ] = x[n-8]; + qmfs->v[qmfs->v_index + n*2+1] = qmfs->v[qmfs->v_index + 640 + n*2+1] = y[n-8]; + } + for (n = 0; n < 16; n++) + { + qmfs->v[qmfs->v_index + n] = qmfs->v[qmfs->v_index + 640 + n] = qmfs->v[qmfs->v_index + 32-n]; + } + qmfs->v[qmfs->v_index + 48] = qmfs->v[qmfs->v_index + 640 + 48] = 0; + for (n = 1; n < 16; n++) + { + qmfs->v[qmfs->v_index + 48+n] = qmfs->v[qmfs->v_index + 640 + 48+n] = -qmfs->v[qmfs->v_index + 48-n]; + } + + /* calculate 32 output samples and window */ + for (k = 0; k < 32; k++) + { + output[out++] = MUL_F(qmfs->v[qmfs->v_index + k], qmf_c[ 2*k*10]) + + MUL_F(qmfs->v[qmfs->v_index + 96 + k], qmf_c[1 + 2*k*10]) + + MUL_F(qmfs->v[qmfs->v_index + 128 + k], qmf_c[2 + 2*k*10]) + + MUL_F(qmfs->v[qmfs->v_index + 224 + k], qmf_c[3 + 2*k*10]) + + MUL_F(qmfs->v[qmfs->v_index + 256 + k], qmf_c[4 + 2*k*10]) + + MUL_F(qmfs->v[qmfs->v_index + 352 + k], qmf_c[5 + 2*k*10]) + + MUL_F(qmfs->v[qmfs->v_index + 384 + k], qmf_c[6 + 2*k*10]) + + MUL_F(qmfs->v[qmfs->v_index + 480 + k], qmf_c[7 + 2*k*10]) + + MUL_F(qmfs->v[qmfs->v_index + 512 + k], qmf_c[8 + 2*k*10]) + + MUL_F(qmfs->v[qmfs->v_index + 608 + k], qmf_c[9 + 2*k*10]); + } + + /* update the ringbuffer index */ + qmfs->v_index -= 64; + if (qmfs->v_index < 0) + qmfs->v_index = (640-64); + } +} + +void sbr_qmf_synthesis_64(sbr_info *sbr, qmfs_info *qmfs, qmf_t X[MAX_NTSR][64], + real_t *output) +{ + real_t x[64] MEM_ALIGN_ATTR; + real_t y[64] MEM_ALIGN_ATTR; + int16_t n, k, out = 0; + uint8_t l; + + + /* qmf subsample l */ + for (l = 0; l < sbr->numTimeSlotsRate; l++) + { + /* shift buffers */ + /* we are not shifting v, it is a double ringbuffer */ + //memmove(qmfs->v + 128, qmfs->v, (1280-128)*sizeof(real_t)); + + /* calculate 128 samples */ + for (k = 0; k < 32; k++) + { + y[k] = FAAD_ANALYSIS_SCALE3((QMF_RE(X[l][k]) - QMF_RE(X[l][63-k]))); + x[k] = FAAD_ANALYSIS_SCALE3((QMF_RE(X[l][k]) + QMF_RE(X[l][63-k]))); + } + + /* even n samples */ + DCT2_32_unscaled(x, x); + /* odd n samples */ + DCT4_32(y, y); + + for (n = 16; n < 48; n++) + { + qmfs->v[qmfs->v_index + n*2] = qmfs->v[qmfs->v_index + 1280 + n*2 ] = x[n-16]; + qmfs->v[qmfs->v_index + n*2+1] = qmfs->v[qmfs->v_index + 1280 + n*2+1] = y[n-16]; + } + for (n = 0; n < 32; n++) + { + qmfs->v[qmfs->v_index + n] = qmfs->v[qmfs->v_index + 1280 + n] = qmfs->v[qmfs->v_index + 64-n]; + } + qmfs->v[qmfs->v_index + 96] = qmfs->v[qmfs->v_index + 1280 + 96] = 0; + for (n = 1; n < 32; n++) + { + qmfs->v[qmfs->v_index + 96+n] = qmfs->v[qmfs->v_index + 1280 + 96+n] = -qmfs->v[qmfs->v_index + 96-n]; + } + + /* calculate 64 output samples and window */ + for (k = 0; k < 64; k++) + { + output[out++] = MUL_F(qmfs->v[qmfs->v_index + k], qmf_c[ k*10]) + + MUL_F(qmfs->v[qmfs->v_index + 192 + k], qmf_c[1 + k*10]) + + MUL_F(qmfs->v[qmfs->v_index + 256 + k], qmf_c[2 + k*10]) + + MUL_F(qmfs->v[qmfs->v_index + 256 + 192 + k], qmf_c[3 + k*10]) + + MUL_F(qmfs->v[qmfs->v_index + 512 + k], qmf_c[4 + k*10]) + + MUL_F(qmfs->v[qmfs->v_index + 512 + 192 + k], qmf_c[5 + k*10]) + + MUL_F(qmfs->v[qmfs->v_index + 768 + k], qmf_c[6 + k*10]) + + MUL_F(qmfs->v[qmfs->v_index + 768 + 192 + k], qmf_c[7 + k*10]) + + MUL_F(qmfs->v[qmfs->v_index + 1024 + k], qmf_c[8 + k*10]) + + MUL_F(qmfs->v[qmfs->v_index + 1024 + 192 + k], qmf_c[9 + k*10]); + } + + /* update the ringbuffer index */ + qmfs->v_index -= 128; + if (qmfs->v_index < 0) + qmfs->v_index = (1280-128); + } +} +#else /* #ifdef SBR_LOW_POWER */ + +static const complex_t qmf32_pre_twiddle[] = +{ + { FRAC_CONST(0.999924701839145), FRAC_CONST(-0.012271538285720) }, + { FRAC_CONST(0.999322384588350), FRAC_CONST(-0.036807222941359) }, + { FRAC_CONST(0.998118112900149), FRAC_CONST(-0.061320736302209) }, + { FRAC_CONST(0.996312612182778), FRAC_CONST(-0.085797312344440) }, + { FRAC_CONST(0.993906970002356), FRAC_CONST(-0.110222207293883) }, + { FRAC_CONST(0.990902635427780), FRAC_CONST(-0.134580708507126) }, + { FRAC_CONST(0.987301418157858), FRAC_CONST(-0.158858143333861) }, + { FRAC_CONST(0.983105487431216), FRAC_CONST(-0.183039887955141) }, + { FRAC_CONST(0.978317370719628), FRAC_CONST(-0.207111376192219) }, + { FRAC_CONST(0.972939952205560), FRAC_CONST(-0.231058108280671) }, + { FRAC_CONST(0.966976471044852), FRAC_CONST(-0.254865659604515) }, + { FRAC_CONST(0.960430519415566), FRAC_CONST(-0.278519689385053) }, + { FRAC_CONST(0.953306040354194), FRAC_CONST(-0.302005949319228) }, + { FRAC_CONST(0.945607325380521), FRAC_CONST(-0.325310292162263) }, + { FRAC_CONST(0.937339011912575), FRAC_CONST(-0.348418680249435) }, + { FRAC_CONST(0.928506080473216), FRAC_CONST(-0.371317193951838) }, + { FRAC_CONST(0.919113851690058), FRAC_CONST(-0.393992040061048) }, + { FRAC_CONST(0.909167983090522), FRAC_CONST(-0.416429560097637) }, + { FRAC_CONST(0.898674465693954), FRAC_CONST(-0.438616238538528) }, + { FRAC_CONST(0.887639620402854), FRAC_CONST(-0.460538710958240) }, + { FRAC_CONST(0.876070094195407), FRAC_CONST(-0.482183772079123) }, + { FRAC_CONST(0.863972856121587), FRAC_CONST(-0.503538383725718) }, + { FRAC_CONST(0.851355193105265), FRAC_CONST(-0.524589682678469) }, + { FRAC_CONST(0.838224705554838), FRAC_CONST(-0.545324988422046) }, + { FRAC_CONST(0.824589302785025), FRAC_CONST(-0.565731810783613) }, + { FRAC_CONST(0.810457198252595), FRAC_CONST(-0.585797857456439) }, + { FRAC_CONST(0.795836904608884), FRAC_CONST(-0.605511041404326) }, + { FRAC_CONST(0.780737228572094), FRAC_CONST(-0.624859488142386) }, + { FRAC_CONST(0.765167265622459), FRAC_CONST(-0.643831542889791) }, + { FRAC_CONST(0.749136394523459), FRAC_CONST(-0.662415777590172) }, + { FRAC_CONST(0.732654271672413), FRAC_CONST(-0.680600997795453) }, + { FRAC_CONST(0.715730825283819), FRAC_CONST(-0.698376249408973) } +}; + +#define FAAD_CMPLX_PRETWIDDLE_SUB(k) \ + (MUL_F(QMF_RE(X[l][k]), RE(qmf32_pre_twiddle[k])) - \ + MUL_F(QMF_IM(X[l][k]), IM(qmf32_pre_twiddle[k]))) + +#define FAAD_CMPLX_PRETWIDDLE_ADD(k) \ + (MUL_F(QMF_IM(X[l][k]), RE(qmf32_pre_twiddle[k])) + \ + MUL_F(QMF_RE(X[l][k]), IM(qmf32_pre_twiddle[k]))) + +void sbr_qmf_synthesis_32(sbr_info *sbr, qmfs_info *qmfs, qmf_t X[MAX_NTSR][64], + real_t *output) +{ + real_t x1[32] MEM_ALIGN_ATTR; + real_t x2[32] MEM_ALIGN_ATTR; + int32_t n, k, idx0, idx1, out = 0; + uint32_t l; + + /* qmf subsample l */ + for (l = 0; l < sbr->numTimeSlotsRate; l++) + { + /* shift buffer v */ + /* buffer is not shifted, we are using a ringbuffer */ + //memmove(qmfs->v + 64, qmfs->v, (640-64)*sizeof(real_t)); + + /* calculate 64 samples */ + /* complex pre-twiddle */ + for (k = 0; k < 32;) + { + x1[k] = FAAD_CMPLX_PRETWIDDLE_SUB(k); x2[k] = FAAD_CMPLX_PRETWIDDLE_ADD(k); k++; + x1[k] = FAAD_CMPLX_PRETWIDDLE_SUB(k); x2[k] = FAAD_CMPLX_PRETWIDDLE_ADD(k); k++; + x1[k] = FAAD_CMPLX_PRETWIDDLE_SUB(k); x2[k] = FAAD_CMPLX_PRETWIDDLE_ADD(k); k++; + x1[k] = FAAD_CMPLX_PRETWIDDLE_SUB(k); x2[k] = FAAD_CMPLX_PRETWIDDLE_ADD(k); k++; + } + + /* transform */ + DCT4_32(x1, x1); + DST4_32(x2, x2); + + idx0 = qmfs->v_index; + idx1 = qmfs->v_index + 63; + for (n = 0; n < 32; n+=2) + { + qmfs->v[idx0] = qmfs->v[idx0 + 640] = -x1[n ] + x2[n ]; idx0++; + qmfs->v[idx1] = qmfs->v[idx1 + 640] = x1[n ] + x2[n ]; idx1--; + qmfs->v[idx0] = qmfs->v[idx0 + 640] = -x1[n+1] + x2[n+1]; idx0++; + qmfs->v[idx1] = qmfs->v[idx1 + 640] = x1[n+1] + x2[n+1]; idx1--; + } + + /* calculate 32 output samples and window */ + for (k = 0; k < 32; k++) + { + idx0 = qmfs->v_index + k; idx1 = 2*k*10; + output[out++] = FAAD_SYNTHESIS_SCALE( + MUL_F(qmfs->v[idx0 ], qmf_c[idx1 ]) + + MUL_F(qmfs->v[idx0 + 96], qmf_c[idx1+1]) + + MUL_F(qmfs->v[idx0 + 128], qmf_c[idx1+2]) + + MUL_F(qmfs->v[idx0 + 224], qmf_c[idx1+3]) + + MUL_F(qmfs->v[idx0 + 256], qmf_c[idx1+4]) + + MUL_F(qmfs->v[idx0 + 352], qmf_c[idx1+5]) + + MUL_F(qmfs->v[idx0 + 384], qmf_c[idx1+6]) + + MUL_F(qmfs->v[idx0 + 480], qmf_c[idx1+7]) + + MUL_F(qmfs->v[idx0 + 512], qmf_c[idx1+8]) + + MUL_F(qmfs->v[idx0 + 608], qmf_c[idx1+9])); + } + + /* update ringbuffer index */ + qmfs->v_index -= 64; + if (qmfs->v_index < 0) + qmfs->v_index = (640 - 64); + } +} + +void sbr_qmf_synthesis_64(sbr_info *sbr, qmfs_info *qmfs, qmf_t X[MAX_NTSR][64], + real_t *output) +{ + real_t real1[32] MEM_ALIGN_ATTR; + real_t imag1[32] MEM_ALIGN_ATTR; + real_t real2[32] MEM_ALIGN_ATTR; + real_t imag2[32] MEM_ALIGN_ATTR; + qmf_t *pX; + real_t *p_buf_1, *p_buf_3; + int32_t n, k, idx0, idx1, out = 0; + uint32_t l; + + /* qmf subsample l */ + for (l = 0; l < sbr->numTimeSlotsRate; l++) + { + /* shift buffer v */ + /* buffer is not shifted, we use double ringbuffer */ + //memmove(qmfs->v + 128, qmfs->v, (1280-128)*sizeof(real_t)); + + /* calculate 128 samples */ + pX = X[l]; + for (k = 0; k < 32; k++) + { + idx0 = 2*k; idx1 = idx0+1; + real1[ k] = QMF_RE(pX[idx0]); imag2[ k] = QMF_IM(pX[idx0]); + imag1[31-k] = QMF_RE(pX[idx1]); real2[31-k] = QMF_IM(pX[idx1]); + } + + // dct4_kernel is DCT_IV without reordering which is done before and after FFT + dct4_kernel(real1, imag1); + dct4_kernel(real2, imag2); + + p_buf_1 = qmfs->v + qmfs->v_index; + p_buf_3 = p_buf_1 + 1280; + + idx0 = 0; idx1 = 127; + for (n = 0; n < 32; n++) + { + p_buf_1[idx0] = p_buf_3[idx0] = real2[ n] - real1[ n]; idx0++; + p_buf_1[idx1] = p_buf_3[idx1] = real2[ n] + real1[ n]; idx1--; + p_buf_1[idx0] = p_buf_3[idx0] = imag2[31-n] + imag1[31-n]; idx0++; + p_buf_1[idx1] = p_buf_3[idx1] = imag2[31-n] - imag1[31-n]; idx1--; + } + + p_buf_1 = qmfs->v + qmfs->v_index; + + /* calculate 64 output samples and window */ +#ifdef CPU_ARM + const real_t *qtab = qmf_c; + real_t *pbuf = p_buf_1; + for (k = 0; k < 64; k++, pbuf++) + { + real_t *pout = &output[out++]; + asm volatile ( + "ldmia %[qtab]!, { r0-r3 } \n\t" + "ldr r4, [%[pbuf]] \n\t" + "ldr r7, [%[pbuf], #192*4] \n\t" + "smull r5, r6, r4, r0 \n\t" + "ldr r4, [%[pbuf], #256*4] \n\t" + "smlal r5, r6, r7, r1 \n\t" + "ldr r7, [%[pbuf], #448*4] \n\t" + "smlal r5, r6, r4, r2 \n\t" + "ldr r4, [%[pbuf], #512*4] \n\t" + "smlal r5, r6, r7, r3 \n\t" + + "ldmia %[qtab]!, { r0-r3 } \n\t" + "ldr r7, [%[pbuf], #704*4] \n\t" + "smlal r5, r6, r4, r0 \n\t" + "ldr r4, [%[pbuf], #768*4] \n\t" + "smlal r5, r6, r7, r1 \n\t" + "ldr r7, [%[pbuf], #960*4] \n\t" + "smlal r5, r6, r4, r2 \n\t" + "mov r2, #1024*4 \n\t" + + "ldmia %[qtab]!, { r0-r1 } \n\t" + "ldr r4, [%[pbuf], r2] \n\t" + "smlal r5, r6, r7, r3 \n\t" + "mov r2, #1216*4 \n\t" + "ldr r7, [%[pbuf], r2] \n\t" + "smlal r5, r6, r4, r0 \n\t" + "smlal r5, r6, r7, r1 \n\t" + + "str r6, [%[pout]] \n" + : [qtab] "+r" (qtab) + : [pbuf] "r" (pbuf), [pout] "r" (pout) + : "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", "memory"); + } +#elif defined CPU_COLDFIRE + const real_t *qtab = qmf_c; + real_t *pbuf = p_buf_1; + for (k = 0; k < 64; k++, pbuf++) + { + real_t *pout = &output[out++]; + asm volatile ( + "move.l (%[pbuf]), %%d5 \n" + + "movem.l (%[qtab]), %%d0-%%d4 \n" + "mac.l %%d0, %%d5, (192*4, %[pbuf]), %%d5, %%acc0 \n" + "mac.l %%d1, %%d5, (256*4, %[pbuf]), %%d5, %%acc0 \n" + "mac.l %%d2, %%d5, (448*4, %[pbuf]), %%d5, %%acc0 \n" + "mac.l %%d3, %%d5, (512*4, %[pbuf]), %%d5, %%acc0 \n" + "mac.l %%d4, %%d5, (704*4, %[pbuf]), %%d5, %%acc0 \n" + "lea.l (20, %[qtab]), %[qtab] \n" + + "movem.l (%[qtab]), %%d0-%%d4 \n" + "mac.l %%d0, %%d5, (768*4, %[pbuf]), %%d5, %%acc0 \n" + "mac.l %%d1, %%d5, (960*4, %[pbuf]), %%d5, %%acc0 \n" + "mac.l %%d2, %%d5, (1024*4, %[pbuf]), %%d5, %%acc0 \n" + "mac.l %%d3, %%d5, (1216*4, %[pbuf]), %%d5, %%acc0 \n" + "mac.l %%d4, %%d5, %%acc0 \n" + "lea.l (20, %[qtab]), %[qtab] \n" + + "movclr.l %%acc0, %%d0 \n" + "move.l %%d0, (%[pout]) \n" + : [qtab] "+a" (qtab) + : [pbuf] "a" (pbuf), + [pout] "a" (pout) + : "d0", "d1", "d2", "d3", "d4", "d5", "memory"); + } +#else + for (k = 0; k < 64; k++) + { + idx0 = k*10; + output[out++] = FAAD_SYNTHESIS_SCALE( + MUL_F(p_buf_1[k ], qmf_c[idx0 ]) + + MUL_F(p_buf_1[k+ 192 ], qmf_c[idx0+1]) + + MUL_F(p_buf_1[k+ 256 ], qmf_c[idx0+2]) + + MUL_F(p_buf_1[k+ 256+192], qmf_c[idx0+3]) + + MUL_F(p_buf_1[k+ 512 ], qmf_c[idx0+4]) + + MUL_F(p_buf_1[k+ 512+192], qmf_c[idx0+5]) + + MUL_F(p_buf_1[k+ 768 ], qmf_c[idx0+6]) + + MUL_F(p_buf_1[k+ 768+192], qmf_c[idx0+7]) + + MUL_F(p_buf_1[k+1024 ], qmf_c[idx0+8]) + + MUL_F(p_buf_1[k+1024+192], qmf_c[idx0+9])); + } +#endif + + /* update ringbuffer index */ + qmfs->v_index -= 128; + if (qmfs->v_index < 0) + qmfs->v_index = (1280 - 128); + } +} +#endif /* #ifdef SBR_LOW_POWER */ + +#endif /* #ifdef SBR_DEC */ diff --git a/lib/rbcodec/codecs/libfaad/sbr_qmf.h b/lib/rbcodec/codecs/libfaad/sbr_qmf.h new file mode 100644 index 0000000000..87bfe5a9ef --- /dev/null +++ b/lib/rbcodec/codecs/libfaad/sbr_qmf.h @@ -0,0 +1,47 @@ +/* +** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding +** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +** +** Any non-GPL usage of this software or parts of this software is strictly +** forbidden. +** +** Commercial non-GPL licensing of this software is possible. +** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** +** $Id$ +**/ + +#ifndef __SBR_QMF_H__ +#define __SBR_QMF_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +void sbr_qmf_analysis_32(sbr_info *sbr, qmfa_info *qmfa, const real_t *input, + qmf_t X[MAX_NTSR][64], uint8_t offset, uint8_t kx); +void sbr_qmf_synthesis_32(sbr_info *sbr, qmfs_info *qmfs, qmf_t X[MAX_NTSR][64], + real_t *output); +void sbr_qmf_synthesis_64(sbr_info *sbr, qmfs_info *qmfs, qmf_t X[MAX_NTSR][64], + real_t *output); + + +#ifdef __cplusplus +} +#endif +#endif + diff --git a/lib/rbcodec/codecs/libfaad/sbr_qmf_c.h b/lib/rbcodec/codecs/libfaad/sbr_qmf_c.h new file mode 100644 index 0000000000..0ceb487bec --- /dev/null +++ b/lib/rbcodec/codecs/libfaad/sbr_qmf_c.h @@ -0,0 +1,172 @@ +/* +** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding +** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +** +** Any non-GPL usage of this software or parts of this software is strictly +** forbidden. +** +** Commercial non-GPL licensing of this software is possible. +** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** +** $Id$ +**/ + +#ifndef __SBR_QMF_C_H__ +#define __SBR_QMF_C_H__ + +#ifdef __cplusplus +extern "C" { +#endif + + +#ifdef _MSC_VER +#pragma warning(disable:4305) +#pragma warning(disable:4244) +#endif +static const real_t qmf_c[640] ICONST_ATTR_FAAD_LARGE_IRAM MEM_ALIGN_ATTR = { + FRAC_CONST( 0.00000000000000), FRAC_CONST( 0.00262017586902), FRAC_CONST( 0.01327182200351), FRAC_CONST( 0.07035330735093), FRAC_CONST( 0.36115899031355), + FRAC_CONST( 0.85373856005937), FRAC_CONST(-0.36115899031355), FRAC_CONST( 0.07035330735093), FRAC_CONST(-0.01327182200351), FRAC_CONST( 0.00262017586902), + FRAC_CONST(-0.00055252865047), FRAC_CONST( 0.00278704643465), FRAC_CONST( 0.01439046660792), FRAC_CONST( 0.06896640131951), FRAC_CONST( 0.37237955463061), + FRAC_CONST( 0.85357205739107), FRAC_CONST(-0.34999141229310), FRAC_CONST( 0.07158263647903), FRAC_CONST(-0.01218499959508), FRAC_CONST( 0.00246256169126), + FRAC_CONST(-0.00056176925738), FRAC_CONST( 0.00294694477165), FRAC_CONST( 0.01554055533423), FRAC_CONST( 0.06745250215166), FRAC_CONST( 0.38363500139043), + FRAC_CONST( 0.85310209497017), FRAC_CONST(-0.33887226938665), FRAC_CONST( 0.07267746427299), FRAC_CONST(-0.01113155480321), FRAC_CONST( 0.00230172547746), + FRAC_CONST(-0.00049475180896), FRAC_CONST( 0.00311254206525), FRAC_CONST( 0.01673247129989), FRAC_CONST( 0.06576906686508), FRAC_CONST( 0.39492117615675), + FRAC_CONST( 0.85230470352147), FRAC_CONST(-0.32781137272105), FRAC_CONST( 0.07364060057620), FRAC_CONST(-0.01011502154986), FRAC_CONST( 0.00214615835557), + FRAC_CONST(-0.00048752279712), FRAC_CONST( 0.00327396134847), FRAC_CONST( 0.01794333813443), FRAC_CONST( 0.06394448059633), FRAC_CONST( 0.40623176767625), + FRAC_CONST( 0.85119715249343), FRAC_CONST(-0.31682789136456), FRAC_CONST( 0.07446643947564), FRAC_CONST(-0.00913253296085), FRAC_CONST( 0.00198411407369), + FRAC_CONST(-0.00048937912498), FRAC_CONST( 0.00344188741828), FRAC_CONST( 0.01918724313698), FRAC_CONST( 0.06196027790387), FRAC_CONST( 0.41756968968409), + FRAC_CONST( 0.84978051984268), FRAC_CONST(-0.30590985751916), FRAC_CONST( 0.07515762552870), FRAC_CONST(-0.00817982333726), FRAC_CONST( 0.00183482654224), + FRAC_CONST(-0.00050407143497), FRAC_CONST( 0.00360082681231), FRAC_CONST( 0.02045317933555), FRAC_CONST( 0.05981665708090), FRAC_CONST( 0.42891199207373), + FRAC_CONST( 0.84803157770763), FRAC_CONST(-0.29507167170646), FRAC_CONST( 0.07573057565061), FRAC_CONST(-0.00726158168517), FRAC_CONST( 0.00168680832531), + FRAC_CONST(-0.00052265642972), FRAC_CONST( 0.00376039229104), FRAC_CONST( 0.02174675502535), FRAC_CONST( 0.05751526919867), FRAC_CONST( 0.44025537543665), + FRAC_CONST( 0.84598184698206), FRAC_CONST(-0.28432141891085), FRAC_CONST( 0.07617483218536), FRAC_CONST(-0.00637922932685), FRAC_CONST( 0.00154432198471), + FRAC_CONST(-0.00054665656337), FRAC_CONST( 0.00392074323703), FRAC_CONST( 0.02306801692862), FRAC_CONST( 0.05504600343009), FRAC_CONST( 0.45159965356824), + FRAC_CONST( 0.84362382812005), FRAC_CONST(-0.27366340405625), FRAC_CONST( 0.07650507183194), FRAC_CONST(-0.00553372111088), FRAC_CONST( 0.00139024948272), + FRAC_CONST(-0.00056778025613), FRAC_CONST( 0.00408197531935), FRAC_CONST( 0.02441609920285), FRAC_CONST( 0.05240938217366), FRAC_CONST( 0.46293080852757), + FRAC_CONST( 0.84095413924722), FRAC_CONST(-0.26310532994603), FRAC_CONST( 0.07672049241746), FRAC_CONST(-0.00472225962400), FRAC_CONST( 0.00125778846475), + FRAC_CONST(-0.00058709304852), FRAC_CONST( 0.00422642692270), FRAC_CONST( 0.02578758475467), FRAC_CONST( 0.04959786763445), FRAC_CONST( 0.47424532146115), + FRAC_CONST( 0.83797173378865), FRAC_CONST(-0.25264803095722), FRAC_CONST( 0.07682300113923), FRAC_CONST(-0.00394011240522), FRAC_CONST( 0.00112501551307), + FRAC_CONST(-0.00061327473938), FRAC_CONST( 0.00437307196781), FRAC_CONST( 0.02718594296329), FRAC_CONST( 0.04663033051701), FRAC_CONST( 0.48552530911099), + FRAC_CONST( 0.83469373618402), FRAC_CONST(-0.24230168845974), FRAC_CONST( 0.07681739756964), FRAC_CONST(-0.00319337783900), FRAC_CONST( 0.00098859883015), + FRAC_CONST(-0.00063124935319), FRAC_CONST( 0.00452098527825), FRAC_CONST( 0.02860721736385), FRAC_CONST( 0.04347687821958), FRAC_CONST( 0.49677082545707), + FRAC_CONST( 0.83110384571520), FRAC_CONST(-0.23206908706791), FRAC_CONST( 0.07670934904245), FRAC_CONST(-0.00248267236449), FRAC_CONST( 0.00086084433262), + FRAC_CONST(-0.00065403333621), FRAC_CONST( 0.00466064606118), FRAC_CONST( 0.03005026574279), FRAC_CONST( 0.04014582784127), FRAC_CONST( 0.50798175000434), + FRAC_CONST( 0.82722753473360), FRAC_CONST(-0.22196526964149), FRAC_CONST( 0.07649921704119), FRAC_CONST(-0.00180394725893), FRAC_CONST( 0.00074580258865), + FRAC_CONST(-0.00067776907764), FRAC_CONST( 0.00479325608498), FRAC_CONST( 0.03150176087389), FRAC_CONST( 0.03664181168133), FRAC_CONST( 0.51912349702391), + FRAC_CONST( 0.82304198905409), FRAC_CONST(-0.21197358538056), FRAC_CONST( 0.07619924793396), FRAC_CONST(-0.00115681355227), FRAC_CONST( 0.00062393761391), + FRAC_CONST(-0.00069416146273), FRAC_CONST( 0.00491376035745), FRAC_CONST( 0.03297540810337), FRAC_CONST( 0.03295839306691), FRAC_CONST( 0.53022408956855), + FRAC_CONST( 0.81857760046468), FRAC_CONST(-0.20212501768103), FRAC_CONST( 0.07580083586584), FRAC_CONST(-0.00054642808664), FRAC_CONST( 0.00051073884952), + FRAC_CONST(-0.00071577364744), FRAC_CONST( 0.00503930226013), FRAC_CONST( 0.03446209487686), FRAC_CONST( 0.02908240060125), FRAC_CONST( 0.54125534487322), + FRAC_CONST( 0.81381912706217), FRAC_CONST(-0.19239667457267), FRAC_CONST( 0.07531373362019), FRAC_CONST(2.760451905e-005 ), FRAC_CONST( 0.0004026540216), + FRAC_CONST(-0.00072550431222), FRAC_CONST( 0.00514073539032), FRAC_CONST( 0.03596975605542), FRAC_CONST( 0.02503075618909), FRAC_CONST( 0.55220512585061), + FRAC_CONST( 0.80876950044491), FRAC_CONST(-0.18281725485142), FRAC_CONST( 0.07474525581194), FRAC_CONST( 0.00058322642480), FRAC_CONST( 0.00029495311041), + FRAC_CONST(-0.00074409418541), FRAC_CONST( 0.00524611661324), FRAC_CONST( 0.03748128504252), FRAC_CONST( 0.02079970728622), FRAC_CONST( 0.5630789140137), + FRAC_CONST( 0.80344857518505), FRAC_CONST(-0.17338081721706), FRAC_CONST( 0.07410036424342), FRAC_CONST( 0.00109023290512), FRAC_CONST( 0.00020430170688), + FRAC_CONST(-0.00074905980532), FRAC_CONST( 0.00534716811982), FRAC_CONST( 0.03900536794745), FRAC_CONST( 0.01637012582228), FRAC_CONST( 0.57385241316923), + FRAC_CONST( 0.79784664137700), FRAC_CONST(-0.16409588556669), FRAC_CONST( 0.07336202550803), FRAC_CONST( 0.00157846825768), FRAC_CONST( 0.00010943831274), + FRAC_CONST(-0.00076813719270), FRAC_CONST( 0.00541967759307), FRAC_CONST( 0.04053491705584), FRAC_CONST( 0.01176238327857), FRAC_CONST( 0.58454032354679), + FRAC_CONST( 0.79197358416424), FRAC_CONST(-0.15496070710605), FRAC_CONST( 0.07256825833083), FRAC_CONST( 0.00202741761850), FRAC_CONST(1.349497418e-005 ), + FRAC_CONST(-0.00077248485949), FRAC_CONST( 0.00548760401507), FRAC_CONST( 0.04206490946367), FRAC_CONST( 0.00696368621617), FRAC_CONST( 0.59511230862496), + FRAC_CONST( 0.78583531203920), FRAC_CONST(-0.14597664911870), FRAC_CONST( 0.07170026731102), FRAC_CONST( 0.00245085400321), FRAC_CONST(-6.173344072e-005), + FRAC_CONST(-0.00078343322877), FRAC_CONST( 0.00554757145088), FRAC_CONST( 0.04360975421304), FRAC_CONST( 0.00197656014503), FRAC_CONST( 0.60557835389180), + FRAC_CONST( 0.77942875190216), FRAC_CONST(-0.13715517611934), FRAC_CONST( 0.07076287107266), FRAC_CONST( 0.00284467578623), FRAC_CONST(-0.00014463809349), + FRAC_CONST(-0.00077798694927), FRAC_CONST( 0.00559380230045), FRAC_CONST( 0.04514884056413), FRAC_CONST(-0.00320868968304), FRAC_CONST( 0.61591099320291), + FRAC_CONST( 0.77277808813327), FRAC_CONST(-0.12850028503878), FRAC_CONST( 0.06976302447127), FRAC_CONST( 0.00320918858098), FRAC_CONST(-0.00020983373440), + FRAC_CONST(-0.00078036647100), FRAC_CONST( 0.00562206432097), FRAC_CONST( 0.04668430272642), FRAC_CONST(-0.00857117491366), FRAC_CONST( 0.62612426956055), + FRAC_CONST( 0.76586748650939), FRAC_CONST(-0.12000779846800), FRAC_CONST( 0.06870438283512), FRAC_CONST( 0.00354012465507), FRAC_CONST(-0.00028969811748), + FRAC_CONST(-0.00078014496257), FRAC_CONST( 0.00564551969164), FRAC_CONST( 0.04821657200672), FRAC_CONST(-0.01412888273558), FRAC_CONST( 0.63619801077286), + FRAC_CONST( 0.75870807608242), FRAC_CONST(-0.11168269317730), FRAC_CONST( 0.06760759851228), FRAC_CONST( 0.00384564081246), FRAC_CONST(-0.00035011758756), + FRAC_CONST(-0.00077579773310), FRAC_CONST( 0.00563891995151), FRAC_CONST( 0.04973857556014), FRAC_CONST(-0.01988341292573), FRAC_CONST( 0.64612696959461), + FRAC_CONST( 0.75131374561237), FRAC_CONST(-0.10353295311463), FRAC_CONST( 0.06643675122104), FRAC_CONST( 0.00412516423270), FRAC_CONST(-0.00040951214522), + FRAC_CONST(-0.00076307935757), FRAC_CONST( 0.00562661141932), FRAC_CONST( 0.05125561555216), FRAC_CONST(-0.02582272888064), FRAC_CONST( 0.65590163024671), + FRAC_CONST( 0.74368278636488), FRAC_CONST(-0.09555333528914), FRAC_CONST( 0.06522471064380), FRAC_CONST( 0.00438018617447), FRAC_CONST(-0.00046063254803), + FRAC_CONST(-0.00075300014201), FRAC_CONST( 0.00559171286630), FRAC_CONST( 0.05276307465207), FRAC_CONST(-0.03195312745332), FRAC_CONST( 0.66551398801627), + FRAC_CONST( 0.73582117582769), FRAC_CONST(-0.08775475365593), FRAC_CONST( 0.06397158980681), FRAC_CONST( 0.00460395301471), FRAC_CONST(-0.00051455722108), + FRAC_CONST(-0.00073193571525), FRAC_CONST( 0.00554043639400), FRAC_CONST( 0.05424527683589), FRAC_CONST(-0.03827765720822), FRAC_CONST( 0.67496631901712), + FRAC_CONST( 0.72774489002994), FRAC_CONST(-0.08013729344279), FRAC_CONST( 0.06268578081172), FRAC_CONST( 0.00481094690600), FRAC_CONST(-0.00055645763906), + FRAC_CONST(-0.00072153919876), FRAC_CONST( 0.00547537830770), FRAC_CONST( 0.05571736482138), FRAC_CONST(-0.04478068215856), FRAC_CONST( 0.68423532934598), + FRAC_CONST( 0.71944626349561), FRAC_CONST(-0.07269433008129), FRAC_CONST( 0.06134551717207), FRAC_CONST( 0.00498396877629), FRAC_CONST(-0.00059461189330), + FRAC_CONST(-0.00069179375372), FRAC_CONST( 0.00538389758970), FRAC_CONST( 0.05716164501299), FRAC_CONST(-0.05148041767934), FRAC_CONST( 0.69332823767032), + FRAC_CONST( 0.71094104263095), FRAC_CONST(-0.06544098531359), FRAC_CONST( 0.05998374801761), FRAC_CONST( 0.00513822754514), FRAC_CONST(-0.00063415949025), + FRAC_CONST(-0.00066504150893), FRAC_CONST( 0.00527157587272), FRAC_CONST( 0.05859156836260), FRAC_CONST(-0.05837053268336), FRAC_CONST( 0.70223887193539), + FRAC_CONST( 0.70223887193539), FRAC_CONST(-0.05837053268336), FRAC_CONST( 0.05859156836260), FRAC_CONST( 0.00527157587272), FRAC_CONST(-0.00066504150893), + FRAC_CONST(-0.00063415949025), FRAC_CONST( 0.00513822754514), FRAC_CONST( 0.05998374801761), FRAC_CONST(-0.06544098531359), FRAC_CONST( 0.71094104263095), + FRAC_CONST( 0.69332823767032), FRAC_CONST(-0.05148041767934), FRAC_CONST( 0.05716164501299), FRAC_CONST( 0.00538389758970), FRAC_CONST(-0.00069179375372), + FRAC_CONST(-0.00059461189330), FRAC_CONST( 0.00498396877629), FRAC_CONST( 0.06134551717207), FRAC_CONST(-0.07269433008129), FRAC_CONST( 0.71944626349561), + FRAC_CONST( 0.68423532934598), FRAC_CONST(-0.04478068215856), FRAC_CONST( 0.05571736482138), FRAC_CONST( 0.00547537830770), FRAC_CONST(-0.00072153919876), + FRAC_CONST(-0.00055645763906), FRAC_CONST( 0.00481094690600), FRAC_CONST( 0.06268578081172), FRAC_CONST(-0.08013729344279), FRAC_CONST( 0.72774489002994), + FRAC_CONST( 0.67496631901712), FRAC_CONST(-0.03827765720822), FRAC_CONST( 0.05424527683589), FRAC_CONST( 0.00554043639400), FRAC_CONST(-0.00073193571525), + FRAC_CONST(-0.00051455722108), FRAC_CONST( 0.00460395301471), FRAC_CONST( 0.06397158980681), FRAC_CONST(-0.08775475365593), FRAC_CONST( 0.73582117582769), + FRAC_CONST( 0.66551398801627), FRAC_CONST(-0.03195312745332), FRAC_CONST( 0.05276307465207), FRAC_CONST( 0.00559171286630), FRAC_CONST(-0.00075300014201), + FRAC_CONST(-0.00046063254803), FRAC_CONST( 0.00438018617447), FRAC_CONST( 0.06522471064380), FRAC_CONST(-0.09555333528914), FRAC_CONST( 0.74368278636488), + FRAC_CONST( 0.65590163024671), FRAC_CONST(-0.02582272888064), FRAC_CONST( 0.05125561555216), FRAC_CONST( 0.00562661141932), FRAC_CONST(-0.00076307935757), + FRAC_CONST(-0.00040951214522), FRAC_CONST( 0.00412516423270), FRAC_CONST( 0.06643675122104), FRAC_CONST(-0.10353295311463), FRAC_CONST( 0.75131374561237), + FRAC_CONST( 0.64612696959461), FRAC_CONST(-0.01988341292573), FRAC_CONST( 0.04973857556014), FRAC_CONST( 0.00563891995151), FRAC_CONST(-0.00077579773310), + FRAC_CONST(-0.00035011758756), FRAC_CONST( 0.00384564081246), FRAC_CONST( 0.06760759851228), FRAC_CONST(-0.11168269317730), FRAC_CONST( 0.75870807608242), + FRAC_CONST( 0.63619801077286), FRAC_CONST(-0.01412888273558), FRAC_CONST( 0.04821657200672), FRAC_CONST( 0.00564551969164), FRAC_CONST(-0.00078014496257), + FRAC_CONST(-0.00028969811748), FRAC_CONST( 0.00354012465507), FRAC_CONST( 0.06870438283512), FRAC_CONST(-0.12000779846800), FRAC_CONST( 0.76586748650939), + FRAC_CONST( 0.62612426956055), FRAC_CONST(-0.00857117491366), FRAC_CONST( 0.04668430272642), FRAC_CONST( 0.00562206432097), FRAC_CONST(-0.00078036647100), + FRAC_CONST(-0.00020983373440), FRAC_CONST( 0.00320918858098), FRAC_CONST( 0.06976302447127), FRAC_CONST(-0.12850028503878), FRAC_CONST( 0.77277808813327), + FRAC_CONST( 0.61591099320291), FRAC_CONST(-0.00320868968304), FRAC_CONST( 0.04514884056413), FRAC_CONST( 0.00559380230045), FRAC_CONST(-0.00077798694927), + FRAC_CONST(-0.00014463809349), FRAC_CONST( 0.00284467578623), FRAC_CONST( 0.07076287107266), FRAC_CONST(-0.13715517611934), FRAC_CONST( 0.77942875190216), + FRAC_CONST( 0.60557835389180), FRAC_CONST( 0.00197656014503), FRAC_CONST( 0.04360975421304), FRAC_CONST( 0.00554757145088), FRAC_CONST(-0.00078343322877), + FRAC_CONST(-6.173344072e-005), FRAC_CONST( 0.00245085400321), FRAC_CONST( 0.07170026731102), FRAC_CONST(-0.14597664911870), FRAC_CONST( 0.78583531203920), + FRAC_CONST( 0.59511230862496), FRAC_CONST( 0.00696368621617), FRAC_CONST( 0.04206490946367), FRAC_CONST( 0.00548760401507), FRAC_CONST(-0.00077248485949), + FRAC_CONST(1.349497418e-005 ), FRAC_CONST( 0.00202741761850), FRAC_CONST( 0.07256825833083), FRAC_CONST(-0.15496070710605), FRAC_CONST( 0.79197358416424), + FRAC_CONST( 0.58454032354679), FRAC_CONST( 0.01176238327857), FRAC_CONST( 0.04053491705584), FRAC_CONST( 0.00541967759307), FRAC_CONST(-0.00076813719270), + FRAC_CONST( 0.00010943831274), FRAC_CONST( 0.00157846825768), FRAC_CONST( 0.07336202550803), FRAC_CONST(-0.16409588556669), FRAC_CONST( 0.79784664137700), + FRAC_CONST( 0.57385241316923), FRAC_CONST( 0.01637012582228), FRAC_CONST( 0.03900536794745), FRAC_CONST( 0.00534716811982), FRAC_CONST(-0.00074905980532), + FRAC_CONST( 0.00020430170688), FRAC_CONST( 0.00109023290512), FRAC_CONST( 0.07410036424342), FRAC_CONST(-0.17338081721706), FRAC_CONST( 0.80344857518505), + FRAC_CONST( 0.56307891401370), FRAC_CONST( 0.02079970728622), FRAC_CONST( 0.03748128504252), FRAC_CONST( 0.00524611661324), FRAC_CONST(-0.00074409418541), + FRAC_CONST( 0.00029495311041), FRAC_CONST( 0.00058322642480), FRAC_CONST( 0.07474525581194), FRAC_CONST(-0.18281725485142), FRAC_CONST( 0.80876950044491), + FRAC_CONST( 0.55220512585061), FRAC_CONST( 0.02503075618909), FRAC_CONST( 0.03596975605542), FRAC_CONST( 0.00514073539032), FRAC_CONST(-0.00072550431222), + FRAC_CONST( 0.00040265402160), FRAC_CONST(2.760451905e-005 ), FRAC_CONST( 0.07531373362019), FRAC_CONST(-0.19239667457267), FRAC_CONST( 0.81381912706217), + FRAC_CONST( 0.54125534487322), FRAC_CONST( 0.02908240060125), FRAC_CONST( 0.03446209487686), FRAC_CONST( 0.00503930226013), FRAC_CONST(-0.00071577364744), + FRAC_CONST( 0.00051073884952), FRAC_CONST(-0.00054642808664), FRAC_CONST( 0.07580083586584), FRAC_CONST(-0.20212501768103), FRAC_CONST( 0.81857760046468), + FRAC_CONST( 0.53022408956855), FRAC_CONST( 0.03295839306691), FRAC_CONST( 0.03297540810337), FRAC_CONST( 0.00491376035745), FRAC_CONST(-0.00069416146273), + FRAC_CONST( 0.00062393761391), FRAC_CONST(-0.00115681355227), FRAC_CONST( 0.07619924793396), FRAC_CONST(-0.21197358538056), FRAC_CONST( 0.82304198905409), + FRAC_CONST( 0.51912349702391), FRAC_CONST( 0.03664181168133), FRAC_CONST( 0.03150176087389), FRAC_CONST( 0.00479325608498), FRAC_CONST(-0.00067776907764), + FRAC_CONST( 0.00074580258865), FRAC_CONST(-0.00180394725893), FRAC_CONST( 0.07649921704119), FRAC_CONST(-0.22196526964149), FRAC_CONST( 0.82722753473360), + FRAC_CONST( 0.50798175000434), FRAC_CONST( 0.04014582784127), FRAC_CONST( 0.03005026574279), FRAC_CONST( 0.00466064606118), FRAC_CONST(-0.00065403333621), + FRAC_CONST( 0.00086084433262), FRAC_CONST(-0.00248267236449), FRAC_CONST( 0.07670934904245), FRAC_CONST(-0.23206908706791), FRAC_CONST( 0.83110384571520), + FRAC_CONST( 0.49677082545707), FRAC_CONST( 0.04347687821958), FRAC_CONST( 0.02860721736385), FRAC_CONST( 0.00452098527825), FRAC_CONST(-0.00063124935319), + FRAC_CONST( 0.00098859883015), FRAC_CONST(-0.00319337783900), FRAC_CONST( 0.07681739756964), FRAC_CONST(-0.24230168845974), FRAC_CONST( 0.83469373618402), + FRAC_CONST( 0.48552530911099), FRAC_CONST( 0.04663033051701), FRAC_CONST( 0.02718594296329), FRAC_CONST( 0.00437307196781), FRAC_CONST(-0.00061327473938), + FRAC_CONST( 0.00112501551307), FRAC_CONST(-0.00394011240522), FRAC_CONST( 0.07682300113923), FRAC_CONST(-0.25264803095722), FRAC_CONST( 0.83797173378865), + FRAC_CONST( 0.47424532146115), FRAC_CONST( 0.04959786763445), FRAC_CONST( 0.02578758475467), FRAC_CONST( 0.00422642692270), FRAC_CONST(-0.00058709304852), + FRAC_CONST( 0.00125778846475), FRAC_CONST(-0.00472225962400), FRAC_CONST( 0.07672049241746), FRAC_CONST(-0.26310532994603), FRAC_CONST( 0.84095413924722), + FRAC_CONST( 0.46293080852757), FRAC_CONST( 0.05240938217366), FRAC_CONST( 0.02441609920285), FRAC_CONST( 0.00408197531935), FRAC_CONST(-0.00056778025613), + FRAC_CONST( 0.00139024948272), FRAC_CONST(-0.00553372111088), FRAC_CONST( 0.07650507183194), FRAC_CONST(-0.27366340405625), FRAC_CONST( 0.84362382812005), + FRAC_CONST( 0.45159965356824), FRAC_CONST( 0.05504600343009), FRAC_CONST( 0.02306801692862), FRAC_CONST( 0.00392074323703), FRAC_CONST(-0.00054665656337), + FRAC_CONST( 0.00154432198471), FRAC_CONST(-0.00637922932685), FRAC_CONST( 0.07617483218536), FRAC_CONST(-0.28432141891085), FRAC_CONST( 0.84598184698206), + FRAC_CONST( 0.44025537543665), FRAC_CONST( 0.05751526919867), FRAC_CONST( 0.02174675502535), FRAC_CONST( 0.00376039229104), FRAC_CONST(-0.00052265642972), + FRAC_CONST( 0.00168680832531), FRAC_CONST(-0.00726158168517), FRAC_CONST( 0.07573057565061), FRAC_CONST(-0.29507167170646), FRAC_CONST( 0.84803157770763), + FRAC_CONST( 0.42891199207373), FRAC_CONST( 0.05981665708090), FRAC_CONST( 0.02045317933555), FRAC_CONST( 0.00360082681231), FRAC_CONST(-0.00050407143497), + FRAC_CONST( 0.00183482654224), FRAC_CONST(-0.00817982333726), FRAC_CONST( 0.07515762552870), FRAC_CONST(-0.30590985751916), FRAC_CONST( 0.84978051984268), + FRAC_CONST( 0.41756968968409), FRAC_CONST( 0.06196027790387), FRAC_CONST( 0.01918724313698), FRAC_CONST( 0.00344188741828), FRAC_CONST(-0.00048937912498), + FRAC_CONST( 0.00198411407369), FRAC_CONST(-0.00913253296085), FRAC_CONST( 0.07446643947564), FRAC_CONST(-0.31682789136456), FRAC_CONST( 0.85119715249343), + FRAC_CONST( 0.40623176767625), FRAC_CONST( 0.06394448059633), FRAC_CONST( 0.01794333813443), FRAC_CONST( 0.00327396134847), FRAC_CONST(-0.00048752279712), + FRAC_CONST( 0.00214615835557), FRAC_CONST(-0.01011502154986), FRAC_CONST( 0.07364060057620), FRAC_CONST(-0.32781137272105), FRAC_CONST( 0.85230470352147), + FRAC_CONST( 0.39492117615675), FRAC_CONST( 0.06576906686508), FRAC_CONST( 0.01673247129989), FRAC_CONST( 0.00311254206525), FRAC_CONST(-0.00049475180896), + FRAC_CONST( 0.00230172547746), FRAC_CONST(-0.01113155480321), FRAC_CONST( 0.07267746427299), FRAC_CONST(-0.33887226938665), FRAC_CONST( 0.85310209497017), + FRAC_CONST( 0.38363500139043), FRAC_CONST( 0.06745250215166), FRAC_CONST( 0.01554055533423), FRAC_CONST( 0.00294694477165), FRAC_CONST(-0.00056176925738), + FRAC_CONST( 0.00246256169126), FRAC_CONST(-0.01218499959508), FRAC_CONST( 0.07158263647903), FRAC_CONST(-0.34999141229310), FRAC_CONST( 0.85357205739107), + FRAC_CONST( 0.37237955463061), FRAC_CONST( 0.06896640131951), FRAC_CONST( 0.01439046660792), FRAC_CONST( 0.00278704643465), FRAC_CONST(-0.00055252865047) +}; + +#endif + diff --git a/lib/rbcodec/codecs/libfaad/sbr_syntax.c b/lib/rbcodec/codecs/libfaad/sbr_syntax.c new file mode 100644 index 0000000000..519a37b137 --- /dev/null +++ b/lib/rbcodec/codecs/libfaad/sbr_syntax.c @@ -0,0 +1,868 @@ +/* +** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding +** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +** +** Any non-GPL usage of this software or parts of this software is strictly +** forbidden. +** +** Commercial non-GPL licensing of this software is possible. +** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** +** $Id$ +**/ + +#include "common.h" +#include "structs.h" + +#ifdef SBR_DEC + +#include "sbr_syntax.h" +#include "syntax.h" +#include "sbr_huff.h" +#include "sbr_fbt.h" +#include "sbr_tf_grid.h" +#include "sbr_e_nf.h" +#include "bits.h" +#ifdef PS_DEC +#include "ps_dec.h" +#endif +#ifdef DRM_PS +#include "drm_dec.h" +#endif +#include "analysis.h" + +/* static function declarations */ +static void sbr_header(bitfile *ld, sbr_info *sbr); +static uint8_t calc_sbr_tables(sbr_info *sbr, uint8_t start_freq, uint8_t stop_freq, + uint8_t samplerate_mode, uint8_t freq_scale, + uint8_t alter_scale, uint8_t xover_band); +static uint8_t sbr_data(bitfile *ld, sbr_info *sbr); +static uint16_t sbr_extension(bitfile *ld, sbr_info *sbr, + uint8_t bs_extension_id, uint16_t num_bits_left); +static uint8_t sbr_single_channel_element(bitfile *ld, sbr_info *sbr); +static uint8_t sbr_channel_pair_element(bitfile *ld, sbr_info *sbr); +static uint8_t sbr_grid(bitfile *ld, sbr_info *sbr, uint8_t ch); +static void sbr_dtdf(bitfile *ld, sbr_info *sbr, uint8_t ch); +static void invf_mode(bitfile *ld, sbr_info *sbr, uint8_t ch); +static void sinusoidal_coding(bitfile *ld, sbr_info *sbr, uint8_t ch); + + +static void sbr_reset(sbr_info *sbr) +{ +#if 0 + printf("%d\n", sbr->bs_start_freq_prev); + printf("%d\n", sbr->bs_stop_freq_prev); + printf("%d\n", sbr->bs_freq_scale_prev); + printf("%d\n", sbr->bs_alter_scale_prev); + printf("%d\n", sbr->bs_xover_band_prev); + printf("%d\n\n", sbr->bs_noise_bands_prev); +#endif + + /* if these are different from the previous frame: Reset = 1 */ + if ((sbr->bs_start_freq != sbr->bs_start_freq_prev) || + (sbr->bs_stop_freq != sbr->bs_stop_freq_prev) || + (sbr->bs_freq_scale != sbr->bs_freq_scale_prev) || + (sbr->bs_alter_scale != sbr->bs_alter_scale_prev) || + (sbr->bs_xover_band != sbr->bs_xover_band_prev) || + (sbr->bs_noise_bands != sbr->bs_noise_bands_prev)) + { + sbr->Reset = 1; + } else { + sbr->Reset = 0; + } + + sbr->bs_start_freq_prev = sbr->bs_start_freq; + sbr->bs_stop_freq_prev = sbr->bs_stop_freq; + sbr->bs_freq_scale_prev = sbr->bs_freq_scale; + sbr->bs_alter_scale_prev = sbr->bs_alter_scale; + sbr->bs_xover_band_prev = sbr->bs_xover_band; + sbr->bs_noise_bands_prev = sbr->bs_noise_bands; +} + +static uint8_t calc_sbr_tables(sbr_info *sbr, uint8_t start_freq, uint8_t stop_freq, + uint8_t samplerate_mode, uint8_t freq_scale, + uint8_t alter_scale, uint8_t xover_band) +{ + uint8_t result = 0; + uint8_t k2; + + /* calculate the Master Frequency Table */ + sbr->k0 = qmf_start_channel(start_freq, samplerate_mode, sbr->sample_rate); + k2 = qmf_stop_channel(stop_freq, sbr->sample_rate, sbr->k0); + + /* check k0 and k2 */ + if (sbr->sample_rate >= 48000) + { + if ((k2 - sbr->k0) > 32) + result += 1; + } else if (sbr->sample_rate <= 32000) { + if ((k2 - sbr->k0) > 48) + result += 1; + } else { /* (sbr->sample_rate == 44100) */ + if ((k2 - sbr->k0) > 45) + result += 1; + } + + if (freq_scale == 0) + { + result += master_frequency_table_fs0(sbr, sbr->k0, k2, alter_scale); + } else { + result += master_frequency_table(sbr, sbr->k0, k2, freq_scale, alter_scale); + } + result += derived_frequency_table(sbr, xover_band, k2); + + result = (result > 0) ? 1 : 0; + + return result; +} + +/* table 2 */ +uint8_t sbr_extension_data(bitfile *ld, sbr_info *sbr, uint16_t cnt) +{ + uint8_t result = 0; + uint16_t num_align_bits = 0; + uint16_t num_sbr_bits = (uint16_t)faad_get_processed_bits(ld); + + uint8_t saved_start_freq, saved_samplerate_mode; + uint8_t saved_stop_freq, saved_freq_scale; + uint8_t saved_alter_scale, saved_xover_band; + +#ifdef DRM + if (!sbr->Is_DRM_SBR) +#endif + { + uint8_t bs_extension_type = (uint8_t)faad_getbits(ld, 4 + DEBUGVAR(1,198,"sbr_bitstream(): bs_extension_type")); + + if (bs_extension_type == EXT_SBR_DATA_CRC) + { + sbr->bs_sbr_crc_bits = (uint16_t)faad_getbits(ld, 10 + DEBUGVAR(1,199,"sbr_bitstream(): bs_sbr_crc_bits")); + } + } + + /* save old header values, in case the new ones are corrupted */ + saved_start_freq = sbr->bs_start_freq; + saved_samplerate_mode = sbr->bs_samplerate_mode; + saved_stop_freq = sbr->bs_stop_freq; + saved_freq_scale = sbr->bs_freq_scale; + saved_alter_scale = sbr->bs_alter_scale; + saved_xover_band = sbr->bs_xover_band; + + sbr->bs_header_flag = faad_get1bit(ld + DEBUGVAR(1,200,"sbr_bitstream(): bs_header_flag")); + + if (sbr->bs_header_flag) + sbr_header(ld, sbr); + + /* Reset? */ + sbr_reset(sbr); + + /* first frame should have a header */ + //if (!(sbr->frame == 0 && sbr->bs_header_flag == 0)) + if (sbr->header_count != 0) + { + if (sbr->Reset || (sbr->bs_header_flag && sbr->just_seeked)) + { + uint8_t rt = calc_sbr_tables(sbr, sbr->bs_start_freq, sbr->bs_stop_freq, + sbr->bs_samplerate_mode, sbr->bs_freq_scale, + sbr->bs_alter_scale, sbr->bs_xover_band); + + /* if an error occured with the new header values revert to the old ones */ + if (rt > 0) + { + calc_sbr_tables(sbr, saved_start_freq, saved_stop_freq, + saved_samplerate_mode, saved_freq_scale, + saved_alter_scale, saved_xover_band); + } + } + + if (result == 0) + { + result = sbr_data(ld, sbr); + + /* sbr_data() returning an error means that there was an error in + envelope_time_border_vector(). + In this case the old time border vector is saved and all the previous + data normally read after sbr_grid() is saved. + */ + /* to be on the safe side, calculate old sbr tables in case of error */ + if ((result > 0) && + (sbr->Reset || (sbr->bs_header_flag && sbr->just_seeked))) + { + calc_sbr_tables(sbr, saved_start_freq, saved_stop_freq, + saved_samplerate_mode, saved_freq_scale, + saved_alter_scale, saved_xover_band); + } + + /* we should be able to safely set result to 0 now */ + result = 0; + } + } else { + result = 1; + } + +#ifdef DRM + if (!sbr->Is_DRM_SBR) +#endif + { + num_sbr_bits = (uint16_t)faad_get_processed_bits(ld) - num_sbr_bits; + + /* check if we read more bits then were available for sbr */ + if (8*cnt < num_sbr_bits) + return 1; + + /* -4 does not apply, bs_extension_type is re-read in this function */ + num_align_bits = 8*cnt /*- 4*/ - num_sbr_bits; + + while (num_align_bits > 7) + { + faad_getbits(ld, 8 + DEBUGVAR(1,999,"sbr_bitstream(): num_align_bits")); + num_align_bits -= 8; + } + faad_getbits(ld, num_align_bits + DEBUGVAR(1,999,"sbr_bitstream(): num_align_bits")); + } + + return result; +} + +/* table 3 */ +static void sbr_header(bitfile *ld, sbr_info *sbr) +{ + uint8_t bs_header_extra_1, bs_header_extra_2; + + sbr->header_count++; + + sbr->bs_amp_res = faad_get1bit(ld + DEBUGVAR(1,203,"sbr_header(): bs_amp_res")); + + /* bs_start_freq and bs_stop_freq must define a fequency band that does + not exceed 48 channels */ + sbr->bs_start_freq = (uint8_t)faad_getbits(ld, 4 + DEBUGVAR(1,204,"sbr_header(): bs_start_freq")); + sbr->bs_stop_freq = (uint8_t)faad_getbits(ld, 4 + DEBUGVAR(1,205,"sbr_header(): bs_stop_freq")); + sbr->bs_xover_band = (uint8_t)faad_getbits(ld, 3 + DEBUGVAR(1,206,"sbr_header(): bs_xover_band")); + faad_getbits(ld, 2 + DEBUGVAR(1,207,"sbr_header(): bs_reserved_bits_hdr")); + bs_header_extra_1 = (uint8_t)faad_get1bit(ld + DEBUGVAR(1,208,"sbr_header(): bs_header_extra_1")); + bs_header_extra_2 = (uint8_t)faad_get1bit(ld + DEBUGVAR(1,209,"sbr_header(): bs_header_extra_2")); + + if (bs_header_extra_1) + { + sbr->bs_freq_scale = (uint8_t)faad_getbits(ld, 2 + DEBUGVAR(1,211,"sbr_header(): bs_freq_scale")); + sbr->bs_alter_scale = (uint8_t)faad_get1bit(ld + DEBUGVAR(1,212,"sbr_header(): bs_alter_scale")); + sbr->bs_noise_bands = (uint8_t)faad_getbits(ld, 2 + DEBUGVAR(1,213,"sbr_header(): bs_noise_bands")); + } else { + /* Default values */ + sbr->bs_freq_scale = 2; + sbr->bs_alter_scale = 1; + sbr->bs_noise_bands = 2; + } + + if (bs_header_extra_2) + { + sbr->bs_limiter_bands = (uint8_t)faad_getbits(ld, 2 + DEBUGVAR(1,214,"sbr_header(): bs_limiter_bands")); + sbr->bs_limiter_gains = (uint8_t)faad_getbits(ld, 2 + DEBUGVAR(1,215,"sbr_header(): bs_limiter_gains")); + sbr->bs_interpol_freq = (uint8_t)faad_get1bit(ld + DEBUGVAR(1,216,"sbr_header(): bs_interpol_freq")); + sbr->bs_smoothing_mode = (uint8_t)faad_get1bit(ld + DEBUGVAR(1,217,"sbr_header(): bs_smoothing_mode")); + } else { + /* Default values */ + sbr->bs_limiter_bands = 2; + sbr->bs_limiter_gains = 2; + sbr->bs_interpol_freq = 1; + sbr->bs_smoothing_mode = 1; + } + +#if 0 + /* print the header to screen */ + printf("bs_amp_res: %d\n", sbr->bs_amp_res); + printf("bs_start_freq: %d\n", sbr->bs_start_freq); + printf("bs_stop_freq: %d\n", sbr->bs_stop_freq); + printf("bs_xover_band: %d\n", sbr->bs_xover_band); + if (bs_header_extra_1) + { + printf("bs_freq_scale: %d\n", sbr->bs_freq_scale); + printf("bs_alter_scale: %d\n", sbr->bs_alter_scale); + printf("bs_noise_bands: %d\n", sbr->bs_noise_bands); + } + if (bs_header_extra_2) + { + printf("bs_limiter_bands: %d\n", sbr->bs_limiter_bands); + printf("bs_limiter_gains: %d\n", sbr->bs_limiter_gains); + printf("bs_interpol_freq: %d\n", sbr->bs_interpol_freq); + printf("bs_smoothing_mode: %d\n", sbr->bs_smoothing_mode); + } + printf("\n"); +#endif +} + +/* table 4 */ +static uint8_t sbr_data(bitfile *ld, sbr_info *sbr) +{ + uint8_t result; +#if 0 + sbr->bs_samplerate_mode = faad_get1bit(ld + DEBUGVAR(1,219,"sbr_data(): bs_samplerate_mode")); +#endif + + sbr->rate = (sbr->bs_samplerate_mode) ? 2 : 1; + + switch (sbr->id_aac) + { + case ID_SCE: + if ((result = sbr_single_channel_element(ld, sbr)) > 0) + return result; + break; + case ID_CPE: + if ((result = sbr_channel_pair_element(ld, sbr)) > 0) + return result; + break; + } + + return 0; +} + +/* table 5 */ +static uint8_t sbr_single_channel_element(bitfile *ld, sbr_info *sbr) +{ + uint8_t result; + + if (faad_get1bit(ld + DEBUGVAR(1,220,"sbr_single_channel_element(): bs_data_extra"))) + { + faad_getbits(ld, 4 + DEBUGVAR(1,221,"sbr_single_channel_element(): bs_reserved_bits_data")); + } + +#ifdef DRM + /* bs_coupling, from sbr_channel_pair_base_element(bs_amp_res) */ + if (sbr->Is_DRM_SBR) + faad_get1bit(ld); +#endif + + if ((result = sbr_grid(ld, sbr, 0)) > 0) + return result; + sbr_dtdf(ld, sbr, 0); + invf_mode(ld, sbr, 0); + sbr_envelope(ld, sbr, 0); + sbr_noise(ld, sbr, 0); + +#ifndef FIXED_POINT + envelope_noise_dequantisation(sbr, 0); +#endif + + memset(sbr->bs_add_harmonic[0], 0, 64*sizeof(uint8_t)); + + sbr->bs_add_harmonic_flag[0] = faad_get1bit(ld + DEBUGVAR(1,223,"sbr_single_channel_element(): bs_add_harmonic_flag[0]")); + if (sbr->bs_add_harmonic_flag[0]) + sinusoidal_coding(ld, sbr, 0); + + sbr->bs_extended_data = faad_get1bit(ld + DEBUGVAR(1,224,"sbr_single_channel_element(): bs_extended_data[0]")); + + if (sbr->bs_extended_data) + { + uint16_t nr_bits_left; +#if (defined(PS_DEC) || defined(DRM_PS)) + uint8_t ps_ext_read = 0; +#endif + uint16_t cnt = (uint16_t)faad_getbits(ld, 4 + DEBUGVAR(1,225,"sbr_single_channel_element(): bs_extension_size")); + if (cnt == 15) + { + cnt += (uint16_t)faad_getbits(ld, 8 + DEBUGVAR(1,226,"sbr_single_channel_element(): bs_esc_count")); + } + + nr_bits_left = 8 * cnt; + while (nr_bits_left > 7) + { + uint16_t tmp_nr_bits = 0; + + sbr->bs_extension_id = (uint8_t)faad_getbits(ld, 2 + DEBUGVAR(1,227,"sbr_single_channel_element(): bs_extension_id")); + tmp_nr_bits += 2; + + /* allow only 1 PS extension element per extension data */ +#if (defined(PS_DEC) || defined(DRM_PS)) +#if (defined(PS_DEC) && defined(DRM_PS)) + if (sbr->bs_extension_id == EXTENSION_ID_PS || sbr->bs_extension_id == DRM_PARAMETRIC_STEREO) +#else +#ifdef PS_DEC + if (sbr->bs_extension_id == EXTENSION_ID_PS) +#else +#ifdef DRM_PS + if (sbr->bs_extension_id == DRM_PARAMETRIC_STEREO) +#endif +#endif +#endif + { + if (ps_ext_read == 0) + { + ps_ext_read = 1; + } else { + /* to be safe make it 3, will switch to "default" + * in sbr_extension() */ + sbr->bs_extension_id = 3; + } + } +#endif + + tmp_nr_bits += sbr_extension(ld, sbr, sbr->bs_extension_id, nr_bits_left); + + /* check if the data read is bigger than the number of available bits */ + if (tmp_nr_bits > nr_bits_left) + return 1; + + nr_bits_left -= tmp_nr_bits; + } + + /* Corrigendum */ + if (nr_bits_left > 0) + { + faad_getbits(ld, nr_bits_left + DEBUGVAR(1,280,"sbr_single_channel_element(): nr_bits_left")); + } + } + + return 0; +} + +/* table 6 */ +static uint8_t sbr_channel_pair_element(bitfile *ld, sbr_info *sbr) +{ + uint8_t n, result; + + if (faad_get1bit(ld + DEBUGVAR(1,228,"sbr_single_channel_element(): bs_data_extra"))) + { + faad_getbits(ld, 4 + DEBUGVAR(1,228,"sbr_channel_pair_element(): bs_reserved_bits_data")); + faad_getbits(ld, 4 + DEBUGVAR(1,228,"sbr_channel_pair_element(): bs_reserved_bits_data")); + } + + sbr->bs_coupling = faad_get1bit(ld + DEBUGVAR(1,228,"sbr_channel_pair_element(): bs_coupling")); + + if (sbr->bs_coupling) + { + if ((result = sbr_grid(ld, sbr, 0)) > 0) + return result; + + /* need to copy some data from left to right */ + sbr->bs_frame_class[1] = sbr->bs_frame_class[0]; + sbr->L_E[1] = sbr->L_E[0]; + sbr->L_Q[1] = sbr->L_Q[0]; + sbr->bs_pointer[1] = sbr->bs_pointer[0]; + + for (n = 0; n <= sbr->L_E[0]; n++) + { + sbr->t_E[1][n] = sbr->t_E[0][n]; + sbr->f[1][n] = sbr->f[0][n]; + } + for (n = 0; n <= sbr->L_Q[0]; n++) + sbr->t_Q[1][n] = sbr->t_Q[0][n]; + + sbr_dtdf(ld, sbr, 0); + sbr_dtdf(ld, sbr, 1); + invf_mode(ld, sbr, 0); + + /* more copying */ + for (n = 0; n < sbr->N_Q; n++) + sbr->bs_invf_mode[1][n] = sbr->bs_invf_mode[0][n]; + + sbr_envelope(ld, sbr, 0); + sbr_noise(ld, sbr, 0); + sbr_envelope(ld, sbr, 1); + sbr_noise(ld, sbr, 1); + + memset(sbr->bs_add_harmonic[0], 0, 64*sizeof(uint8_t)); + memset(sbr->bs_add_harmonic[1], 0, 64*sizeof(uint8_t)); + + sbr->bs_add_harmonic_flag[0] = faad_get1bit(ld + DEBUGVAR(1,231,"sbr_channel_pair_element(): bs_add_harmonic_flag[0]")); + if (sbr->bs_add_harmonic_flag[0]) + sinusoidal_coding(ld, sbr, 0); + + sbr->bs_add_harmonic_flag[1] = faad_get1bit(ld + DEBUGVAR(1,232,"sbr_channel_pair_element(): bs_add_harmonic_flag[1]")); + if (sbr->bs_add_harmonic_flag[1]) + sinusoidal_coding(ld, sbr, 1); + } else { + uint8_t saved_t_E[6] = {0}, saved_t_Q[3] = {0}; + uint8_t saved_L_E = sbr->L_E[0]; + uint8_t saved_L_Q = sbr->L_Q[0]; + uint8_t saved_frame_class = sbr->bs_frame_class[0]; + + for (n = 0; n < saved_L_E; n++) + saved_t_E[n] = sbr->t_E[0][n]; + for (n = 0; n < saved_L_Q; n++) + saved_t_Q[n] = sbr->t_Q[0][n]; + + if ((result = sbr_grid(ld, sbr, 0)) > 0) + return result; + if ((result = sbr_grid(ld, sbr, 1)) > 0) + { + /* restore first channel data as well */ + sbr->bs_frame_class[0] = saved_frame_class; + sbr->L_E[0] = saved_L_E; + sbr->L_Q[0] = saved_L_Q; + for (n = 0; n < 6; n++) + sbr->t_E[0][n] = saved_t_E[n]; + for (n = 0; n < 3; n++) + sbr->t_Q[0][n] = saved_t_Q[n]; + + return result; + } + sbr_dtdf(ld, sbr, 0); + sbr_dtdf(ld, sbr, 1); + invf_mode(ld, sbr, 0); + invf_mode(ld, sbr, 1); + sbr_envelope(ld, sbr, 0); + sbr_envelope(ld, sbr, 1); + sbr_noise(ld, sbr, 0); + sbr_noise(ld, sbr, 1); + + memset(sbr->bs_add_harmonic[0], 0, 64*sizeof(uint8_t)); + memset(sbr->bs_add_harmonic[1], 0, 64*sizeof(uint8_t)); + + sbr->bs_add_harmonic_flag[0] = faad_get1bit(ld + DEBUGVAR(1,239,"sbr_channel_pair_element(): bs_add_harmonic_flag[0]")); + if (sbr->bs_add_harmonic_flag[0]) + sinusoidal_coding(ld, sbr, 0); + + sbr->bs_add_harmonic_flag[1] = faad_get1bit(ld + DEBUGVAR(1,240,"sbr_channel_pair_element(): bs_add_harmonic_flag[1]")); + if (sbr->bs_add_harmonic_flag[1]) + sinusoidal_coding(ld, sbr, 1); + } +#ifndef FIXED_POINT + envelope_noise_dequantisation(sbr, 0); + envelope_noise_dequantisation(sbr, 1); + + if (sbr->bs_coupling) + unmap_envelope_noise(sbr); +#endif + + sbr->bs_extended_data = faad_get1bit(ld + DEBUGVAR(1,233,"sbr_channel_pair_element(): bs_extended_data[0]")); + if (sbr->bs_extended_data) + { + uint16_t nr_bits_left; + uint16_t cnt = (uint16_t)faad_getbits(ld, 4 + DEBUGVAR(1,234,"sbr_channel_pair_element(): bs_extension_size")); + if (cnt == 15) + { + cnt += (uint16_t)faad_getbits(ld, 8 + DEBUGVAR(1,235,"sbr_channel_pair_element(): bs_esc_count")); + } + + nr_bits_left = 8 * cnt; + while (nr_bits_left > 7) + { + uint16_t tmp_nr_bits = 0; + + sbr->bs_extension_id = (uint8_t)faad_getbits(ld, 2 + DEBUGVAR(1,236,"sbr_channel_pair_element(): bs_extension_id")); + tmp_nr_bits += 2; + tmp_nr_bits += sbr_extension(ld, sbr, sbr->bs_extension_id, nr_bits_left); + + /* check if the data read is bigger than the number of available bits */ + if (tmp_nr_bits > nr_bits_left) + return 1; + + nr_bits_left -= tmp_nr_bits; + } + + /* Corrigendum */ + if (nr_bits_left > 0) + { + faad_getbits(ld, nr_bits_left + DEBUGVAR(1,280,"sbr_channel_pair_element(): nr_bits_left")); + } + } + + return 0; +} + +/* integer log[2](x): input range [0,10) */ +static int8_t sbr_log2(const int8_t val) +{ + int8_t log2tab[] = { 0, 0, 1, 2, 2, 3, 3, 3, 3, 4 }; + if (val < 10 && val >= 0) + return log2tab[val]; + else + return 0; +} + + +/* table 7 */ +static uint8_t sbr_grid(bitfile *ld, sbr_info *sbr, uint8_t ch) +{ + uint8_t i, env, rel, result; + uint8_t bs_abs_bord, bs_abs_bord_1; + uint8_t bs_num_env = 0; + uint8_t saved_L_E = sbr->L_E[ch]; + uint8_t saved_L_Q = sbr->L_Q[ch]; + uint8_t saved_frame_class = sbr->bs_frame_class[ch]; + + sbr->bs_frame_class[ch] = (uint8_t)faad_getbits(ld, 2 + DEBUGVAR(1,248,"sbr_grid(): bs_frame_class")); + + switch (sbr->bs_frame_class[ch]) + { + case FIXFIX: + i = (uint8_t)faad_getbits(ld, 2 + DEBUGVAR(1,249,"sbr_grid(): bs_num_env_raw")); + + bs_num_env = min(1 << i, 5); + + i = (uint8_t)faad_get1bit(ld + DEBUGVAR(1,250,"sbr_grid(): bs_freq_res_flag")); + for (env = 0; env < bs_num_env; env++) + sbr->f[ch][env] = i; + + sbr->abs_bord_lead[ch] = 0; + sbr->abs_bord_trail[ch] = sbr->numTimeSlots; + sbr->n_rel_lead[ch] = bs_num_env - 1; + sbr->n_rel_trail[ch] = 0; + break; + + case FIXVAR: + bs_abs_bord = (uint8_t)faad_getbits(ld, 2 + DEBUGVAR(1,251,"sbr_grid(): bs_abs_bord")) + sbr->numTimeSlots; + bs_num_env = (uint8_t)faad_getbits(ld, 2 + DEBUGVAR(1,252,"sbr_grid(): bs_num_env")) + 1; + + for (rel = 0; rel < bs_num_env-1; rel++) + { + sbr->bs_rel_bord[ch][rel] = 2 * (uint8_t)faad_getbits(ld, 2 + DEBUGVAR(1,253,"sbr_grid(): bs_rel_bord")) + 2; + } + i = sbr_log2(bs_num_env + 1); + sbr->bs_pointer[ch] = (uint8_t)faad_getbits(ld, i + DEBUGVAR(1,254,"sbr_grid(): bs_pointer")); + + for (env = 0; env < bs_num_env; env++) + { + sbr->f[ch][bs_num_env - env - 1] = (uint8_t)faad_get1bit(ld + DEBUGVAR(1,255,"sbr_grid(): bs_freq_res")); + } + + sbr->abs_bord_lead[ch] = 0; + sbr->abs_bord_trail[ch] = bs_abs_bord; + sbr->n_rel_lead[ch] = 0; + sbr->n_rel_trail[ch] = bs_num_env - 1; + break; + + case VARFIX: + bs_abs_bord = (uint8_t)faad_getbits(ld, 2 + DEBUGVAR(1,256,"sbr_grid(): bs_abs_bord")); + bs_num_env = (uint8_t)faad_getbits(ld, 2 + DEBUGVAR(1,257,"sbr_grid(): bs_num_env")) + 1; + + for (rel = 0; rel < bs_num_env-1; rel++) + { + sbr->bs_rel_bord[ch][rel] = 2 * (uint8_t)faad_getbits(ld, 2 + DEBUGVAR(1,258,"sbr_grid(): bs_rel_bord")) + 2; + } + i = sbr_log2(bs_num_env + 1); + sbr->bs_pointer[ch] = (uint8_t)faad_getbits(ld, i + DEBUGVAR(1,259,"sbr_grid(): bs_pointer")); + + for (env = 0; env < bs_num_env; env++) + { + sbr->f[ch][env] = (uint8_t)faad_get1bit(ld + DEBUGVAR(1,260,"sbr_grid(): bs_freq_res")); + } + + sbr->abs_bord_lead[ch] = bs_abs_bord; + sbr->abs_bord_trail[ch] = sbr->numTimeSlots; + sbr->n_rel_lead[ch] = bs_num_env - 1; + sbr->n_rel_trail[ch] = 0; + break; + + case VARVAR: + bs_abs_bord = (uint8_t)faad_getbits(ld, 2 + DEBUGVAR(1,261,"sbr_grid(): bs_abs_bord_0")); + bs_abs_bord_1 = (uint8_t)faad_getbits(ld, 2 + DEBUGVAR(1,262,"sbr_grid(): bs_abs_bord_1")) + sbr->numTimeSlots; + sbr->bs_num_rel_0[ch] = (uint8_t)faad_getbits(ld, 2 + DEBUGVAR(1,263,"sbr_grid(): bs_num_rel_0")); + sbr->bs_num_rel_1[ch] = (uint8_t)faad_getbits(ld, 2 + DEBUGVAR(1,264,"sbr_grid(): bs_num_rel_1")); + + bs_num_env = min(5, sbr->bs_num_rel_0[ch] + sbr->bs_num_rel_1[ch] + 1); + + for (rel = 0; rel < sbr->bs_num_rel_0[ch]; rel++) + { + sbr->bs_rel_bord_0[ch][rel] = 2 * (uint8_t)faad_getbits(ld, 2 + DEBUGVAR(1,265,"sbr_grid(): bs_rel_bord")) + 2; + } + for(rel = 0; rel < sbr->bs_num_rel_1[ch]; rel++) + { + sbr->bs_rel_bord_1[ch][rel] = 2 * (uint8_t)faad_getbits(ld, 2 + DEBUGVAR(1,266,"sbr_grid(): bs_rel_bord")) + 2; + } + i = sbr_log2(sbr->bs_num_rel_0[ch] + sbr->bs_num_rel_1[ch] + 2); + sbr->bs_pointer[ch] = (uint8_t)faad_getbits(ld, i + DEBUGVAR(1,267,"sbr_grid(): bs_pointer")); + + for (env = 0; env < bs_num_env; env++) + { + sbr->f[ch][env] = (uint8_t)faad_get1bit(ld + DEBUGVAR(1,268,"sbr_grid(): bs_freq_res")); + } + + sbr->abs_bord_lead[ch] = bs_abs_bord; + sbr->abs_bord_trail[ch] = bs_abs_bord_1; + sbr->n_rel_lead[ch] = sbr->bs_num_rel_0[ch]; + sbr->n_rel_trail[ch] = sbr->bs_num_rel_1[ch]; + break; + } + + if (sbr->bs_frame_class[ch] == VARVAR) + sbr->L_E[ch] = min(bs_num_env, 5); + else + sbr->L_E[ch] = min(bs_num_env, 4); + + if (sbr->L_E[ch] <= 0) + return 1; + + if (sbr->L_E[ch] > 1) + sbr->L_Q[ch] = 2; + else + sbr->L_Q[ch] = 1; + + /* TODO: this code can probably be integrated into the code above! */ + if ((result = envelope_time_border_vector(sbr, ch)) > 0) + { + sbr->bs_frame_class[ch] = saved_frame_class; + sbr->L_E[ch] = saved_L_E; + sbr->L_Q[ch] = saved_L_Q; + return result; + } + noise_floor_time_border_vector(sbr, ch); + +#if 0 + for (env = 0; env < bs_num_env; env++) + { + printf("freq_res[ch:%d][env:%d]: %d\n", ch, env, sbr->f[ch][env]); + } +#endif + + return 0; +} + +/* table 8 */ +static void sbr_dtdf(bitfile *ld, sbr_info *sbr, uint8_t ch) +{ + uint8_t i; + + for (i = 0; i < sbr->L_E[ch]; i++) + { + sbr->bs_df_env[ch][i] = faad_get1bit(ld + DEBUGVAR(1,269,"sbr_dtdf(): bs_df_env")); + } + + for (i = 0; i < sbr->L_Q[ch]; i++) + { + sbr->bs_df_noise[ch][i] = faad_get1bit(ld + DEBUGVAR(1,270,"sbr_dtdf(): bs_df_noise")); + } +} + +/* table 9 */ +static void invf_mode(bitfile *ld, sbr_info *sbr, uint8_t ch) +{ + uint8_t n; + + for (n = 0; n < sbr->N_Q; n++) + { + sbr->bs_invf_mode[ch][n] = (uint8_t)faad_getbits(ld, 2 + DEBUGVAR(1,271,"invf_mode(): bs_invf_mode")); + } +} + +static uint16_t sbr_extension(bitfile *ld, sbr_info *sbr, + uint8_t bs_extension_id, uint16_t num_bits_left) +{ +#ifdef PS_DEC + uint8_t header; + uint16_t ret; +#endif + + (void)num_bits_left; + switch (bs_extension_id) + { +#ifdef PS_DEC + case EXTENSION_ID_PS: + ret = ps_data(&sbr->ps, ld, &header); + + /* enable PS if and only if: a header has been decoded */ + if (sbr->ps_used == 0 && header == 1) + { + sbr->ps_used = 1; + } + + return ret; +#endif +#ifdef DRM_PS + case DRM_PARAMETRIC_STEREO: + sbr->ps_used = 1; + if (!sbr->drm_ps) + { + sbr->drm_ps = drm_ps_init(); + } + return drm_ps_data(sbr->drm_ps, ld); +#endif + default: + sbr->bs_extension_data = (uint8_t)faad_getbits(ld, 6 + DEBUGVAR(1,279,"sbr_single_channel_element(): bs_extension_data")); + return 6; + } +} + +/* table 12 */ +static void sinusoidal_coding(bitfile *ld, sbr_info *sbr, uint8_t ch) +{ + uint8_t n; + + for (n = 0; n < sbr->N_high; n++) + { + sbr->bs_add_harmonic[ch][n] = faad_get1bit(ld + DEBUGVAR(1,278,"sinusoidal_coding(): bs_add_harmonic")); + } +} + + +#endif /* SBR_DEC */ diff --git a/lib/rbcodec/codecs/libfaad/sbr_syntax.h b/lib/rbcodec/codecs/libfaad/sbr_syntax.h new file mode 100644 index 0000000000..33aecaaf73 --- /dev/null +++ b/lib/rbcodec/codecs/libfaad/sbr_syntax.h @@ -0,0 +1,64 @@ +/* +** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding +** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +** +** Any non-GPL usage of this software or parts of this software is strictly +** forbidden. +** +** Commercial non-GPL licensing of this software is possible. +** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** +** $Id$ +**/ + +#ifndef __SBR_SYNTAX_H__ +#define __SBR_SYNTAX_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "bits.h" + +#define T_HFGEN 8 +#define T_HFADJ 2 + +#define EXT_SBR_DATA 13 +#define EXT_SBR_DATA_CRC 14 + +#define FIXFIX 0 +#define FIXVAR 1 +#define VARFIX 2 +#define VARVAR 3 + +#define LO_RES 0 +#define HI_RES 1 + +#define NO_TIME_SLOTS_960 15 +#define NO_TIME_SLOTS 16 +#define RATE 2 + +#define NOISE_FLOOR_OFFSET 6 + + +uint8_t sbr_extension_data(bitfile *ld, sbr_info *sbr, uint16_t cnt); + +#ifdef __cplusplus +} +#endif +#endif /* __SBR_SYNTAX_H__ */ + diff --git a/lib/rbcodec/codecs/libfaad/sbr_tf_grid.c b/lib/rbcodec/codecs/libfaad/sbr_tf_grid.c new file mode 100644 index 0000000000..2c21173490 --- /dev/null +++ b/lib/rbcodec/codecs/libfaad/sbr_tf_grid.c @@ -0,0 +1,259 @@ +/* +** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding +** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +** +** Any non-GPL usage of this software or parts of this software is strictly +** forbidden. +** +** Commercial non-GPL licensing of this software is possible. +** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** +** $Id$ +**/ + +/* Time/Frequency grid */ + +#include "common.h" +#include "structs.h" + +#ifdef SBR_DEC + +#include + +#include "sbr_syntax.h" +#include "sbr_tf_grid.h" + + +/* static function declarations */ +#if 0 +static int16_t rel_bord_lead(sbr_info *sbr, uint8_t ch, uint8_t l); +static int16_t rel_bord_trail(sbr_info *sbr, uint8_t ch, uint8_t l); +#endif +static uint8_t middleBorder(sbr_info *sbr, uint8_t ch); + + +/* function constructs new time border vector */ +/* first build into temp vector to be able to use previous vector on error */ +uint8_t envelope_time_border_vector(sbr_info *sbr, uint8_t ch) +{ + uint8_t l, temp; + int8_t border; + uint8_t t_E_temp[6] = {0}; + + t_E_temp[0] = sbr->rate * sbr->abs_bord_lead[ch]; + t_E_temp[sbr->L_E[ch]] = sbr->rate * sbr->abs_bord_trail[ch]; + + switch (sbr->bs_frame_class[ch]) + { + case FIXFIX: + switch (sbr->L_E[ch]) + { + case 4: + temp = (int) (sbr->numTimeSlots / 4); + t_E_temp[3] = sbr->rate * 3 * temp; + t_E_temp[2] = sbr->rate * 2 * temp; + t_E_temp[1] = sbr->rate * temp; + break; + case 2: + t_E_temp[1] = sbr->rate * (int) (sbr->numTimeSlots / 2); + break; + default: + break; + } + break; + + case FIXVAR: + if (sbr->L_E[ch] > 1) + { + int8_t i = sbr->L_E[ch]; + border = sbr->abs_bord_trail[ch]; + + for (l = 0; l < (sbr->L_E[ch] - 1); l++) + { + if (border < sbr->bs_rel_bord[ch][l]) + return 1; + + border -= sbr->bs_rel_bord[ch][l]; + t_E_temp[--i] = sbr->rate * border; + } + } + break; + + case VARFIX: + if (sbr->L_E[ch] > 1) + { + int8_t i = 1; + border = sbr->abs_bord_lead[ch]; + + for (l = 0; l < (sbr->L_E[ch] - 1); l++) + { + border += sbr->bs_rel_bord[ch][l]; + + if (sbr->rate * border + sbr->tHFAdj > sbr->numTimeSlotsRate+sbr->tHFGen) + return 1; + + t_E_temp[i++] = sbr->rate * border; + } + } + break; + + case VARVAR: + if (sbr->bs_num_rel_0[ch]) + { + int8_t i = 1; + border = sbr->abs_bord_lead[ch]; + + for (l = 0; l < sbr->bs_num_rel_0[ch]; l++) + { + border += sbr->bs_rel_bord_0[ch][l]; + + if (sbr->rate * border + sbr->tHFAdj > sbr->numTimeSlotsRate+sbr->tHFGen) + return 1; + + t_E_temp[i++] = sbr->rate * border; + } + } + + if (sbr->bs_num_rel_1[ch]) + { + int8_t i = sbr->L_E[ch]; + border = sbr->abs_bord_trail[ch]; + + for (l = 0; l < sbr->bs_num_rel_1[ch]; l++) + { + if (border < sbr->bs_rel_bord_1[ch][l]) + return 1; + + border -= sbr->bs_rel_bord_1[ch][l]; + t_E_temp[--i] = sbr->rate * border; + } + } + break; + } + + /* no error occured, we can safely use this t_E vector */ + for (l = 0; l < 6; l++) + { + sbr->t_E[ch][l] = t_E_temp[l]; + } + + return 0; +} + +void noise_floor_time_border_vector(sbr_info *sbr, uint8_t ch) +{ + sbr->t_Q[ch][0] = sbr->t_E[ch][0]; + + if (sbr->L_E[ch] == 1) + { + sbr->t_Q[ch][1] = sbr->t_E[ch][1]; + sbr->t_Q[ch][2] = 0; + } else { + uint8_t index = middleBorder(sbr, ch); + sbr->t_Q[ch][1] = sbr->t_E[ch][index]; + sbr->t_Q[ch][2] = sbr->t_E[ch][sbr->L_E[ch]]; + } +} + +#if 0 +static int16_t rel_bord_lead(sbr_info *sbr, uint8_t ch, uint8_t l) +{ + uint8_t i; + int16_t acc = 0; + + switch (sbr->bs_frame_class[ch]) + { + case FIXFIX: + return sbr->numTimeSlots/sbr->L_E[ch]; + case FIXVAR: + return 0; + case VARFIX: + for (i = 0; i < l; i++) + { + acc += sbr->bs_rel_bord[ch][i]; + } + return acc; + case VARVAR: + for (i = 0; i < l; i++) + { + acc += sbr->bs_rel_bord_0[ch][i]; + } + return acc; + } + + return 0; +} + +static int16_t rel_bord_trail(sbr_info *sbr, uint8_t ch, uint8_t l) +{ + uint8_t i; + int16_t acc = 0; + + switch (sbr->bs_frame_class[ch]) + { + case FIXFIX: + case VARFIX: + return 0; + case FIXVAR: + for (i = 0; i < l; i++) + { + acc += sbr->bs_rel_bord[ch][i]; + } + return acc; + case VARVAR: + for (i = 0; i < l; i++) + { + acc += sbr->bs_rel_bord_1[ch][i]; + } + return acc; + } + + return 0; +} +#endif + +static uint8_t middleBorder(sbr_info *sbr, uint8_t ch) +{ + int8_t retval = 0; + + switch (sbr->bs_frame_class[ch]) + { + case FIXFIX: + retval = sbr->L_E[ch]/2; + break; + case VARFIX: + if (sbr->bs_pointer[ch] == 0) + retval = 1; + else if (sbr->bs_pointer[ch] == 1) + retval = sbr->L_E[ch] - 1; + else + retval = sbr->bs_pointer[ch] - 1; + break; + case FIXVAR: + case VARVAR: + if (sbr->bs_pointer[ch] > 1) + retval = sbr->L_E[ch] + 1 - sbr->bs_pointer[ch]; + else + retval = sbr->L_E[ch] - 1; + break; + } + + return (retval > 0) ? retval : 0; +} + + +#endif diff --git a/lib/rbcodec/codecs/libfaad/sbr_tf_grid.h b/lib/rbcodec/codecs/libfaad/sbr_tf_grid.h new file mode 100644 index 0000000000..b7a6b32290 --- /dev/null +++ b/lib/rbcodec/codecs/libfaad/sbr_tf_grid.h @@ -0,0 +1,44 @@ +/* +** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding +** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +** +** Any non-GPL usage of this software or parts of this software is strictly +** forbidden. +** +** Commercial non-GPL licensing of this software is possible. +** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** +** $Id$ +**/ + +#ifndef __SBR_TF_GRID_H__ +#define __SBR_TF_GRID_H__ + +#ifdef __cplusplus +extern "C" { +#endif + + +uint8_t envelope_time_border_vector(sbr_info *sbr, uint8_t ch); +void noise_floor_time_border_vector(sbr_info *sbr, uint8_t ch); + + +#ifdef __cplusplus +} +#endif +#endif + diff --git a/lib/rbcodec/codecs/libfaad/sine_win.h b/lib/rbcodec/codecs/libfaad/sine_win.h new file mode 100644 index 0000000000..3e042f15f7 --- /dev/null +++ b/lib/rbcodec/codecs/libfaad/sine_win.h @@ -0,0 +1,4301 @@ +/* +** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding +** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +** +** Any non-GPL usage of this software or parts of this software is strictly +** forbidden. +** +** Commercial non-GPL licensing of this software is possible. +** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** +** $Id$ +**/ + +#ifndef __SINE_WIN_H__ +#define __SINE_WIN_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _MSC_VER +#pragma warning(disable:4305) +#pragma warning(disable:4244) +#endif + +static const real_t sine_long_1024[] ICONST_ATTR MEM_ALIGN_ATTR = +{ + FRAC_CONST(0.00076699031874270449), + FRAC_CONST(0.002300969151425805), + FRAC_CONST(0.0038349425697062275), + FRAC_CONST(0.0053689069639963425), + FRAC_CONST(0.0069028587247297558), + FRAC_CONST(0.0084367942423697988), + FRAC_CONST(0.0099707099074180308), + FRAC_CONST(0.011504602110422714), + FRAC_CONST(0.013038467241987334), + FRAC_CONST(0.014572301692779064), + FRAC_CONST(0.016106101853537287), + FRAC_CONST(0.017639864115082053), + FRAC_CONST(0.019173584868322623), + FRAC_CONST(0.020707260504265895), + FRAC_CONST(0.022240887414024961), + FRAC_CONST(0.023774461988827555), + FRAC_CONST(0.025307980620024571), + FRAC_CONST(0.026841439699098531), + FRAC_CONST(0.028374835617672099), + FRAC_CONST(0.029908164767516555), + FRAC_CONST(0.031441423540560301), + FRAC_CONST(0.032974608328897335), + FRAC_CONST(0.03450771552479575), + FRAC_CONST(0.036040741520706229), + FRAC_CONST(0.037573682709270494), + FRAC_CONST(0.039106535483329888), + FRAC_CONST(0.040639296235933736), + FRAC_CONST(0.042171961360347947), + FRAC_CONST(0.043704527250063421), + FRAC_CONST(0.04523699029880459), + FRAC_CONST(0.046769346900537863), + FRAC_CONST(0.048301593449480144), + FRAC_CONST(0.049833726340107277), + FRAC_CONST(0.051365741967162593), + FRAC_CONST(0.052897636725665324), + FRAC_CONST(0.054429407010919133), + FRAC_CONST(0.055961049218520569), + FRAC_CONST(0.057492559744367566), + FRAC_CONST(0.059023934984667931), + FRAC_CONST(0.060555171335947788), + FRAC_CONST(0.062086265195060088), + FRAC_CONST(0.063617212959193106), + FRAC_CONST(0.065148011025878833), + FRAC_CONST(0.066678655793001557), + FRAC_CONST(0.068209143658806329), + FRAC_CONST(0.069739471021907307), + FRAC_CONST(0.071269634281296401), + FRAC_CONST(0.072799629836351673), + FRAC_CONST(0.074329454086845756), + FRAC_CONST(0.075859103432954447), + FRAC_CONST(0.077388574275265049), + FRAC_CONST(0.078917863014784942), + FRAC_CONST(0.080446966052950014), + FRAC_CONST(0.081975879791633066), + FRAC_CONST(0.083504600633152432), + FRAC_CONST(0.085033124980280275), + FRAC_CONST(0.08656144923625117), + FRAC_CONST(0.088089569804770507), + FRAC_CONST(0.089617483090022959), + FRAC_CONST(0.091145185496681005), + FRAC_CONST(0.09267267342991331), + FRAC_CONST(0.094199943295393204), + FRAC_CONST(0.095726991499307162), + FRAC_CONST(0.097253814448363271), + FRAC_CONST(0.098780408549799623), + FRAC_CONST(0.10030677021139286), + FRAC_CONST(0.10183289584146653), + FRAC_CONST(0.10335878184889961), + FRAC_CONST(0.10488442464313497), + FRAC_CONST(0.10640982063418768), + FRAC_CONST(0.10793496623265365), + FRAC_CONST(0.10945985784971798), + FRAC_CONST(0.11098449189716339), + FRAC_CONST(0.11250886478737869), + FRAC_CONST(0.1140329729333672), + FRAC_CONST(0.11555681274875526), + FRAC_CONST(0.11708038064780059), + FRAC_CONST(0.11860367304540072), + FRAC_CONST(0.1201266863571015), + FRAC_CONST(0.12164941699910553), + FRAC_CONST(0.12317186138828048), + FRAC_CONST(0.12469401594216764), + FRAC_CONST(0.12621587707899035), + FRAC_CONST(0.12773744121766231), + FRAC_CONST(0.12925870477779614), + FRAC_CONST(0.13077966417971171), + FRAC_CONST(0.13230031584444465), + FRAC_CONST(0.13382065619375472), + FRAC_CONST(0.13534068165013421), + FRAC_CONST(0.13686038863681638), + FRAC_CONST(0.13837977357778389), + FRAC_CONST(0.13989883289777721), + FRAC_CONST(0.14141756302230302), + FRAC_CONST(0.14293596037764267), + FRAC_CONST(0.14445402139086047), + FRAC_CONST(0.14597174248981221), + FRAC_CONST(0.14748912010315357), + FRAC_CONST(0.14900615066034845), + FRAC_CONST(0.1505228305916774), + FRAC_CONST(0.15203915632824605), + FRAC_CONST(0.15355512430199345), + FRAC_CONST(0.15507073094570051), + FRAC_CONST(0.15658597269299843), + FRAC_CONST(0.15810084597837698), + FRAC_CONST(0.15961534723719306), + FRAC_CONST(0.16112947290567881), + FRAC_CONST(0.16264321942095031), + FRAC_CONST(0.16415658322101581), + FRAC_CONST(0.16566956074478412), + FRAC_CONST(0.16718214843207294), + FRAC_CONST(0.16869434272361733), + FRAC_CONST(0.17020614006107807), + FRAC_CONST(0.17171753688704997), + FRAC_CONST(0.17322852964507032), + FRAC_CONST(0.1747391147796272), + FRAC_CONST(0.17624928873616788), + FRAC_CONST(0.17775904796110717), + FRAC_CONST(0.17926838890183575), + FRAC_CONST(0.18077730800672859), + FRAC_CONST(0.1822858017251533), + FRAC_CONST(0.18379386650747845), + FRAC_CONST(0.1853014988050819), + FRAC_CONST(0.18680869507035927), + FRAC_CONST(0.18831545175673212), + FRAC_CONST(0.18982176531865641), + FRAC_CONST(0.1913276322116309), + FRAC_CONST(0.19283304889220523), + FRAC_CONST(0.1943380118179886), + FRAC_CONST(0.19584251744765785), + FRAC_CONST(0.19734656224096592), + FRAC_CONST(0.19885014265875009), + FRAC_CONST(0.20035325516294045), + FRAC_CONST(0.20185589621656805), + FRAC_CONST(0.20335806228377332), + FRAC_CONST(0.20485974982981442), + FRAC_CONST(0.20636095532107551), + FRAC_CONST(0.20786167522507507), + FRAC_CONST(0.20936190601047416), + FRAC_CONST(0.21086164414708486), + FRAC_CONST(0.21236088610587842), + FRAC_CONST(0.21385962835899375), + FRAC_CONST(0.21535786737974555), + FRAC_CONST(0.21685559964263262), + FRAC_CONST(0.21835282162334632), + FRAC_CONST(0.2198495297987787), + FRAC_CONST(0.22134572064703081), + FRAC_CONST(0.22284139064742112), + FRAC_CONST(0.2243365362804936), + FRAC_CONST(0.22583115402802617), + FRAC_CONST(0.22732524037303886), + FRAC_CONST(0.22881879179980222), + FRAC_CONST(0.23031180479384544), + FRAC_CONST(0.23180427584196478), + FRAC_CONST(0.23329620143223159), + FRAC_CONST(0.23478757805400097), + FRAC_CONST(0.23627840219791957), + FRAC_CONST(0.23776867035593419), + FRAC_CONST(0.23925837902129998), + FRAC_CONST(0.24074752468858843), + FRAC_CONST(0.24223610385369601), + FRAC_CONST(0.24372411301385216), + FRAC_CONST(0.24521154866762754), + FRAC_CONST(0.24669840731494241), + FRAC_CONST(0.24818468545707478), + FRAC_CONST(0.24967037959666857), + FRAC_CONST(0.25115548623774192), + FRAC_CONST(0.25264000188569552), + FRAC_CONST(0.25412392304732062), + FRAC_CONST(0.25560724623080738), + FRAC_CONST(0.25708996794575312), + FRAC_CONST(0.25857208470317034), + FRAC_CONST(0.26005359301549519), + FRAC_CONST(0.26153448939659552), + FRAC_CONST(0.263014770361779), + FRAC_CONST(0.26449443242780163), + FRAC_CONST(0.26597347211287559), + FRAC_CONST(0.26745188593667762), + FRAC_CONST(0.26892967042035726), + FRAC_CONST(0.27040682208654482), + FRAC_CONST(0.27188333745935972), + FRAC_CONST(0.27335921306441868), + FRAC_CONST(0.27483444542884394), + FRAC_CONST(0.27630903108127108), + FRAC_CONST(0.27778296655185769), + FRAC_CONST(0.27925624837229118), + FRAC_CONST(0.28072887307579719), + FRAC_CONST(0.28220083719714756), + FRAC_CONST(0.28367213727266843), + FRAC_CONST(0.28514276984024867), + FRAC_CONST(0.28661273143934779), + FRAC_CONST(0.28808201861100413), + FRAC_CONST(0.28955062789784303), + FRAC_CONST(0.29101855584408509), + FRAC_CONST(0.29248579899555388), + FRAC_CONST(0.29395235389968466), + FRAC_CONST(0.29541821710553201), + FRAC_CONST(0.29688338516377827), + FRAC_CONST(0.2983478546267414), + FRAC_CONST(0.29981162204838335), + FRAC_CONST(0.30127468398431795), + FRAC_CONST(0.30273703699181914), + FRAC_CONST(0.30419867762982911), + FRAC_CONST(0.30565960245896612), + FRAC_CONST(0.3071198080415331), + FRAC_CONST(0.30857929094152509), + FRAC_CONST(0.31003804772463789), + FRAC_CONST(0.31149607495827591), + FRAC_CONST(0.3129533692115602), + FRAC_CONST(0.31440992705533666), + FRAC_CONST(0.31586574506218396), + FRAC_CONST(0.31732081980642174), + FRAC_CONST(0.31877514786411848), + FRAC_CONST(0.32022872581309986), + FRAC_CONST(0.32168155023295658), + FRAC_CONST(0.32313361770505233), + FRAC_CONST(0.32458492481253215), + FRAC_CONST(0.32603546814033024), + FRAC_CONST(0.327485244275178), + FRAC_CONST(0.3289342498056122), + FRAC_CONST(0.33038248132198278), + FRAC_CONST(0.33182993541646111), + FRAC_CONST(0.33327660868304793), + FRAC_CONST(0.33472249771758122), + FRAC_CONST(0.33616759911774452), + FRAC_CONST(0.33761190948307462), + FRAC_CONST(0.33905542541496964), + FRAC_CONST(0.34049814351669716), + FRAC_CONST(0.34194006039340219), + FRAC_CONST(0.34338117265211504), + FRAC_CONST(0.34482147690175929), + FRAC_CONST(0.34626096975316001), + FRAC_CONST(0.34769964781905138), + FRAC_CONST(0.34913750771408497), + FRAC_CONST(0.35057454605483751), + FRAC_CONST(0.35201075945981908), + FRAC_CONST(0.35344614454948081), + FRAC_CONST(0.35488069794622279), + FRAC_CONST(0.35631441627440241), + FRAC_CONST(0.3577472961603419), + FRAC_CONST(0.3591793342323365), + FRAC_CONST(0.36061052712066227), + FRAC_CONST(0.36204087145758418), + FRAC_CONST(0.36347036387736376), + FRAC_CONST(0.36489900101626732), + FRAC_CONST(0.36632677951257359), + FRAC_CONST(0.36775369600658198), + FRAC_CONST(0.36917974714062002), + FRAC_CONST(0.37060492955905167), + FRAC_CONST(0.37202923990828501), + FRAC_CONST(0.3734526748367803), + FRAC_CONST(0.37487523099505754), + FRAC_CONST(0.37629690503570479), + FRAC_CONST(0.37771769361338564), + FRAC_CONST(0.37913759338484732), + FRAC_CONST(0.38055660100892852), + FRAC_CONST(0.38197471314656722), + FRAC_CONST(0.38339192646080866), + FRAC_CONST(0.38480823761681288), + FRAC_CONST(0.38622364328186298), + FRAC_CONST(0.38763814012537273), + FRAC_CONST(0.38905172481889438), + FRAC_CONST(0.39046439403612659), + FRAC_CONST(0.39187614445292235), + FRAC_CONST(0.3932869727472964), + FRAC_CONST(0.39469687559943356), + FRAC_CONST(0.39610584969169627), + FRAC_CONST(0.39751389170863233), + FRAC_CONST(0.39892099833698291), + FRAC_CONST(0.40032716626569009), + FRAC_CONST(0.40173239218590501), + FRAC_CONST(0.4031366727909953), + FRAC_CONST(0.404540004776553), + FRAC_CONST(0.40594238484040251), + FRAC_CONST(0.40734380968260797), + FRAC_CONST(0.40874427600548136), + FRAC_CONST(0.41014378051359024), + FRAC_CONST(0.41154231991376522), + FRAC_CONST(0.41293989091510808), + FRAC_CONST(0.4143364902289991), + FRAC_CONST(0.41573211456910536), + FRAC_CONST(0.41712676065138787), + FRAC_CONST(0.4185204251941097), + FRAC_CONST(0.41991310491784362), + FRAC_CONST(0.42130479654547964), + FRAC_CONST(0.42269549680223295), + FRAC_CONST(0.42408520241565156), + FRAC_CONST(0.4254739101156238), + FRAC_CONST(0.42686161663438643), + FRAC_CONST(0.42824831870653196), + FRAC_CONST(0.42963401306901638), + FRAC_CONST(0.43101869646116703), + FRAC_CONST(0.43240236562469014), + FRAC_CONST(0.43378501730367852), + FRAC_CONST(0.43516664824461926), + FRAC_CONST(0.4365472551964012), + FRAC_CONST(0.43792683491032286), + FRAC_CONST(0.43930538414009995), + FRAC_CONST(0.4406828996418729), + FRAC_CONST(0.4420593781742147), + FRAC_CONST(0.44343481649813848), + FRAC_CONST(0.44480921137710488), + FRAC_CONST(0.44618255957703007), + FRAC_CONST(0.44755485786629301), + FRAC_CONST(0.44892610301574326), + FRAC_CONST(0.45029629179870861), + FRAC_CONST(0.45166542099100249), + FRAC_CONST(0.45303348737093158), + FRAC_CONST(0.45440048771930358), + FRAC_CONST(0.45576641881943464), + FRAC_CONST(0.45713127745715698), + FRAC_CONST(0.45849506042082627), + FRAC_CONST(0.45985776450132954), + FRAC_CONST(0.46121938649209238), + FRAC_CONST(0.46257992318908681), + FRAC_CONST(0.46393937139083852), + FRAC_CONST(0.4652977278984346), + FRAC_CONST(0.46665498951553092), + FRAC_CONST(0.46801115304835983), + FRAC_CONST(0.46936621530573752), + FRAC_CONST(0.4707201730990716), + FRAC_CONST(0.47207302324236866), + FRAC_CONST(0.47342476255224153), + FRAC_CONST(0.47477538784791712), + FRAC_CONST(0.47612489595124358), + FRAC_CONST(0.47747328368669806), + FRAC_CONST(0.47882054788139389), + FRAC_CONST(0.48016668536508839), + FRAC_CONST(0.48151169297018986), + FRAC_CONST(0.48285556753176567), + FRAC_CONST(0.48419830588754903), + FRAC_CONST(0.48553990487794696), + FRAC_CONST(0.48688036134604734), + FRAC_CONST(0.48821967213762679), + FRAC_CONST(0.48955783410115744), + FRAC_CONST(0.49089484408781509), + FRAC_CONST(0.49223069895148602), + FRAC_CONST(0.49356539554877477), + FRAC_CONST(0.49489893073901126), + FRAC_CONST(0.49623130138425825), + FRAC_CONST(0.49756250434931915), + FRAC_CONST(0.49889253650174459), + FRAC_CONST(0.50022139471184068), + FRAC_CONST(0.50154907585267539), + FRAC_CONST(0.50287557680008699), + FRAC_CONST(0.50420089443269034), + FRAC_CONST(0.50552502563188539), + FRAC_CONST(0.50684796728186321), + FRAC_CONST(0.5081697162696146), + FRAC_CONST(0.50949026948493636), + FRAC_CONST(0.51080962382043904), + FRAC_CONST(0.51212777617155469), + FRAC_CONST(0.51344472343654346), + FRAC_CONST(0.5147604625165012), + FRAC_CONST(0.51607499031536663), + FRAC_CONST(0.51738830373992906), + FRAC_CONST(0.51870039969983495), + FRAC_CONST(0.52001127510759604), + FRAC_CONST(0.52132092687859566), + FRAC_CONST(0.52262935193109661), + FRAC_CONST(0.5239365471862486), + FRAC_CONST(0.52524250956809471), + FRAC_CONST(0.52654723600357944), + FRAC_CONST(0.52785072342255523), + FRAC_CONST(0.52915296875779061), + FRAC_CONST(0.53045396894497632), + FRAC_CONST(0.53175372092273332), + FRAC_CONST(0.53305222163261945), + FRAC_CONST(0.53434946801913752), + FRAC_CONST(0.53564545702974109), + FRAC_CONST(0.53694018561484291), + FRAC_CONST(0.5382336507278217), + FRAC_CONST(0.53952584932502889), + FRAC_CONST(0.54081677836579667), + FRAC_CONST(0.54210643481244392), + FRAC_CONST(0.5433948156302848), + FRAC_CONST(0.54468191778763453), + FRAC_CONST(0.54596773825581757), + FRAC_CONST(0.54725227400917409), + FRAC_CONST(0.54853552202506739), + FRAC_CONST(0.54981747928389091), + FRAC_CONST(0.55109814276907543), + FRAC_CONST(0.55237750946709607), + FRAC_CONST(0.55365557636747931), + FRAC_CONST(0.55493234046281037), + FRAC_CONST(0.55620779874873993), + FRAC_CONST(0.55748194822399155), + FRAC_CONST(0.55875478589036831), + FRAC_CONST(0.56002630875276038), + FRAC_CONST(0.56129651381915147), + FRAC_CONST(0.56256539810062656), + FRAC_CONST(0.56383295861137817), + FRAC_CONST(0.56509919236871398), + FRAC_CONST(0.56636409639306384), + FRAC_CONST(0.56762766770798623), + FRAC_CONST(0.56888990334017586), + FRAC_CONST(0.5701508003194703), + FRAC_CONST(0.57141035567885723), + FRAC_CONST(0.57266856645448116), + FRAC_CONST(0.57392542968565075), + FRAC_CONST(0.57518094241484508), + FRAC_CONST(0.57643510168772183), + FRAC_CONST(0.5776879045531228), + FRAC_CONST(0.57893934806308178), + FRAC_CONST(0.58018942927283168), + FRAC_CONST(0.58143814524081017), + FRAC_CONST(0.58268549302866846), + FRAC_CONST(0.58393146970127618), + FRAC_CONST(0.58517607232673041), + FRAC_CONST(0.5864192979763605), + FRAC_CONST(0.58766114372473666), + FRAC_CONST(0.58890160664967572), + FRAC_CONST(0.59014068383224882), + FRAC_CONST(0.59137837235678758), + FRAC_CONST(0.59261466931089113), + FRAC_CONST(0.59384957178543363), + FRAC_CONST(0.59508307687456996), + FRAC_CONST(0.59631518167574371), + FRAC_CONST(0.59754588328969316), + FRAC_CONST(0.59877517882045872), + FRAC_CONST(0.60000306537538894), + FRAC_CONST(0.6012295400651485), + FRAC_CONST(0.60245460000372375), + FRAC_CONST(0.60367824230843037), + FRAC_CONST(0.60490046409991982), + FRAC_CONST(0.60612126250218612), + FRAC_CONST(0.60734063464257293), + FRAC_CONST(0.60855857765177945), + FRAC_CONST(0.60977508866386843), + FRAC_CONST(0.61099016481627166), + FRAC_CONST(0.61220380324979795), + FRAC_CONST(0.61341600110863859), + FRAC_CONST(0.61462675554037505), + FRAC_CONST(0.61583606369598509), + FRAC_CONST(0.61704392272984976), + FRAC_CONST(0.61825032979976025), + FRAC_CONST(0.61945528206692402), + FRAC_CONST(0.62065877669597214), + FRAC_CONST(0.62186081085496536), + FRAC_CONST(0.62306138171540126), + FRAC_CONST(0.62426048645222065), + FRAC_CONST(0.62545812224381436), + FRAC_CONST(0.62665428627202935), + FRAC_CONST(0.62784897572217646), + FRAC_CONST(0.629042187783036), + FRAC_CONST(0.63023391964686437), + FRAC_CONST(0.63142416850940186), + FRAC_CONST(0.63261293156987741), + FRAC_CONST(0.63380020603101728), + FRAC_CONST(0.63498598909904946), + FRAC_CONST(0.63617027798371217), + FRAC_CONST(0.63735306989825913), + FRAC_CONST(0.63853436205946679), + FRAC_CONST(0.63971415168764045), + FRAC_CONST(0.64089243600662138), + FRAC_CONST(0.64206921224379254), + FRAC_CONST(0.64324447763008585), + FRAC_CONST(0.64441822939998838), + FRAC_CONST(0.64559046479154869), + FRAC_CONST(0.64676118104638392), + FRAC_CONST(0.64793037540968534), + FRAC_CONST(0.64909804513022595), + FRAC_CONST(0.65026418746036585), + FRAC_CONST(0.65142879965605982), + FRAC_CONST(0.65259187897686244), + FRAC_CONST(0.65375342268593606), + FRAC_CONST(0.65491342805005603), + FRAC_CONST(0.6560718923396176), + FRAC_CONST(0.65722881282864254), + FRAC_CONST(0.65838418679478505), + FRAC_CONST(0.65953801151933866), + FRAC_CONST(0.6606902842872423), + FRAC_CONST(0.66184100238708687), + FRAC_CONST(0.66299016311112147), + FRAC_CONST(0.66413776375526001), + FRAC_CONST(0.66528380161908718), + FRAC_CONST(0.66642827400586524), + FRAC_CONST(0.66757117822254031), + FRAC_CONST(0.66871251157974798), + FRAC_CONST(0.66985227139182102), + FRAC_CONST(0.67099045497679422), + FRAC_CONST(0.67212705965641173), + FRAC_CONST(0.67326208275613297), + FRAC_CONST(0.67439552160513905), + FRAC_CONST(0.67552737353633852), + FRAC_CONST(0.67665763588637495), + FRAC_CONST(0.6777863059956315), + FRAC_CONST(0.67891338120823841), + FRAC_CONST(0.68003885887207893), + FRAC_CONST(0.68116273633879543), + FRAC_CONST(0.68228501096379557), + FRAC_CONST(0.68340568010625868), + FRAC_CONST(0.6845247411291423), + FRAC_CONST(0.68564219139918747), + FRAC_CONST(0.68675802828692589), + FRAC_CONST(0.68787224916668555), + FRAC_CONST(0.68898485141659704), + FRAC_CONST(0.69009583241859995), + FRAC_CONST(0.69120518955844845), + FRAC_CONST(0.69231292022571822), + FRAC_CONST(0.69341902181381176), + FRAC_CONST(0.69452349171996552), + FRAC_CONST(0.69562632734525487), + FRAC_CONST(0.6967275260946012), + FRAC_CONST(0.69782708537677729), + FRAC_CONST(0.69892500260441415), + FRAC_CONST(0.70002127519400625), + FRAC_CONST(0.70111590056591866), + FRAC_CONST(0.70220887614439187), + FRAC_CONST(0.70330019935754873), + FRAC_CONST(0.70438986763740041), + FRAC_CONST(0.7054778784198521), + FRAC_CONST(0.70656422914470951), + FRAC_CONST(0.70764891725568435), + FRAC_CONST(0.70873194020040065), + FRAC_CONST(0.70981329543040084), + FRAC_CONST(0.71089298040115168), + FRAC_CONST(0.71197099257204999), + FRAC_CONST(0.71304732940642923), + FRAC_CONST(0.71412198837156471), + FRAC_CONST(0.71519496693868001), + FRAC_CONST(0.71626626258295312), + FRAC_CONST(0.71733587278352173), + FRAC_CONST(0.71840379502348972), + FRAC_CONST(0.71947002678993299), + FRAC_CONST(0.72053456557390527), + FRAC_CONST(0.72159740887044366), + FRAC_CONST(0.72265855417857561), + FRAC_CONST(0.72371799900132339), + FRAC_CONST(0.72477574084571128), + FRAC_CONST(0.72583177722277037), + FRAC_CONST(0.72688610564754497), + FRAC_CONST(0.72793872363909862), + FRAC_CONST(0.72898962872051931), + FRAC_CONST(0.73003881841892615), + FRAC_CONST(0.73108629026547423), + FRAC_CONST(0.73213204179536129), + FRAC_CONST(0.73317607054783274), + FRAC_CONST(0.73421837406618817), + FRAC_CONST(0.73525894989778673), + FRAC_CONST(0.73629779559405306), + FRAC_CONST(0.73733490871048279), + FRAC_CONST(0.73837028680664851), + FRAC_CONST(0.73940392744620576), + FRAC_CONST(0.74043582819689802), + FRAC_CONST(0.74146598663056329), + FRAC_CONST(0.74249440032313918), + FRAC_CONST(0.74352106685466912), + FRAC_CONST(0.74454598380930725), + FRAC_CONST(0.74556914877532543), + FRAC_CONST(0.74659055934511731), + FRAC_CONST(0.74761021311520515), + FRAC_CONST(0.74862810768624533), + FRAC_CONST(0.74964424066303348), + FRAC_CONST(0.75065860965451059), + FRAC_CONST(0.75167121227376843), + FRAC_CONST(0.75268204613805523), + FRAC_CONST(0.75369110886878121), + FRAC_CONST(0.75469839809152439), + FRAC_CONST(0.75570391143603588), + FRAC_CONST(0.75670764653624567), + FRAC_CONST(0.75770960103026808), + FRAC_CONST(0.75870977256040739), + FRAC_CONST(0.75970815877316344), + FRAC_CONST(0.76070475731923692), + FRAC_CONST(0.76169956585353527), + FRAC_CONST(0.76269258203517787), + FRAC_CONST(0.76368380352750187), + FRAC_CONST(0.76467322799806714), + FRAC_CONST(0.76566085311866239), + FRAC_CONST(0.76664667656531038), + FRAC_CONST(0.76763069601827327), + FRAC_CONST(0.76861290916205827), + FRAC_CONST(0.76959331368542294), + FRAC_CONST(0.7705719072813807), + FRAC_CONST(0.7715486876472063), + FRAC_CONST(0.77252365248444133), + FRAC_CONST(0.77349679949889905), + FRAC_CONST(0.77446812640067086), + FRAC_CONST(0.77543763090413043), + FRAC_CONST(0.77640531072794039), + FRAC_CONST(0.7773711635950562), + FRAC_CONST(0.77833518723273309), + FRAC_CONST(0.7792973793725303), + FRAC_CONST(0.78025773775031659), + FRAC_CONST(0.78121626010627609), + FRAC_CONST(0.7821729441849129), + FRAC_CONST(0.78312778773505731), + FRAC_CONST(0.78408078850986995), + FRAC_CONST(0.78503194426684808), + FRAC_CONST(0.78598125276783015), + FRAC_CONST(0.7869287117790017), + FRAC_CONST(0.78787431907090011), + FRAC_CONST(0.78881807241842017), + FRAC_CONST(0.78975996960081907), + FRAC_CONST(0.79070000840172161), + FRAC_CONST(0.79163818660912577), + FRAC_CONST(0.79257450201540758), + FRAC_CONST(0.79350895241732666), + FRAC_CONST(0.79444153561603059), + FRAC_CONST(0.79537224941706119), + FRAC_CONST(0.79630109163035911), + FRAC_CONST(0.7972280600702687), + FRAC_CONST(0.79815315255554375), + FRAC_CONST(0.79907636690935235), + FRAC_CONST(0.79999770095928191), + FRAC_CONST(0.8009171525373443), + FRAC_CONST(0.80183471947998131), + FRAC_CONST(0.80275039962806916), + FRAC_CONST(0.80366419082692409), + FRAC_CONST(0.804576090926307), + FRAC_CONST(0.80548609778042912), + FRAC_CONST(0.80639420924795624), + FRAC_CONST(0.80730042319201445), + FRAC_CONST(0.80820473748019472), + FRAC_CONST(0.80910714998455813), + FRAC_CONST(0.81000765858164114), + FRAC_CONST(0.81090626115245967), + FRAC_CONST(0.81180295558251536), + FRAC_CONST(0.81269773976179949), + FRAC_CONST(0.81359061158479851), + FRAC_CONST(0.81448156895049861), + FRAC_CONST(0.81537060976239129), + FRAC_CONST(0.81625773192847739), + FRAC_CONST(0.81714293336127297), + FRAC_CONST(0.81802621197781344), + FRAC_CONST(0.81890756569965895), + FRAC_CONST(0.81978699245289899), + FRAC_CONST(0.82066449016815746), + FRAC_CONST(0.82154005678059761), + FRAC_CONST(0.82241369022992639), + FRAC_CONST(0.82328538846040011), + FRAC_CONST(0.82415514942082857), + FRAC_CONST(0.82502297106458022), + FRAC_CONST(0.82588885134958678), + FRAC_CONST(0.82675278823834852), + FRAC_CONST(0.8276147796979384), + FRAC_CONST(0.82847482370000713), + FRAC_CONST(0.82933291822078825), + FRAC_CONST(0.83018906124110237), + FRAC_CONST(0.83104325074636232), + FRAC_CONST(0.83189548472657759), + FRAC_CONST(0.83274576117635946), + FRAC_CONST(0.83359407809492514), + FRAC_CONST(0.83444043348610319), + FRAC_CONST(0.83528482535833737), + FRAC_CONST(0.83612725172469216), + FRAC_CONST(0.83696771060285702), + FRAC_CONST(0.83780620001515094), + FRAC_CONST(0.8386427179885273), + FRAC_CONST(0.83947726255457855), + FRAC_CONST(0.84030983174954077), + FRAC_CONST(0.84114042361429808), + FRAC_CONST(0.84196903619438768), + FRAC_CONST(0.84279566754000412), + FRAC_CONST(0.84362031570600404), + FRAC_CONST(0.84444297875191066), + FRAC_CONST(0.84526365474191822), + FRAC_CONST(0.84608234174489694), + FRAC_CONST(0.84689903783439735), + FRAC_CONST(0.84771374108865427), + FRAC_CONST(0.84852644959059265), + FRAC_CONST(0.84933716142783067), + FRAC_CONST(0.85014587469268521), + FRAC_CONST(0.85095258748217573), + FRAC_CONST(0.85175729789802912), + FRAC_CONST(0.85256000404668397), + FRAC_CONST(0.85336070403929543), + FRAC_CONST(0.85415939599173873), + FRAC_CONST(0.85495607802461482), + FRAC_CONST(0.85575074826325392), + FRAC_CONST(0.85654340483771996), + FRAC_CONST(0.85733404588281559), + FRAC_CONST(0.85812266953808602), + FRAC_CONST(0.8589092739478239), + FRAC_CONST(0.85969385726107261), + FRAC_CONST(0.86047641763163207), + FRAC_CONST(0.86125695321806206), + FRAC_CONST(0.86203546218368721), + FRAC_CONST(0.86281194269660033), + FRAC_CONST(0.86358639292966799), + FRAC_CONST(0.86435881106053403), + FRAC_CONST(0.86512919527162369), + FRAC_CONST(0.86589754375014882), + FRAC_CONST(0.86666385468811102), + FRAC_CONST(0.86742812628230692), + FRAC_CONST(0.86819035673433131), + FRAC_CONST(0.86895054425058238), + FRAC_CONST(0.86970868704226556), + FRAC_CONST(0.87046478332539767), + FRAC_CONST(0.8712188313208109), + FRAC_CONST(0.8719708292541577), + FRAC_CONST(0.8727207753559143), + FRAC_CONST(0.87346866786138488), + FRAC_CONST(0.8742145050107063), + FRAC_CONST(0.87495828504885154), + FRAC_CONST(0.8757000062256346), + FRAC_CONST(0.87643966679571361), + FRAC_CONST(0.87717726501859594), + FRAC_CONST(0.87791279915864173), + FRAC_CONST(0.87864626748506813), + FRAC_CONST(0.87937766827195318), + FRAC_CONST(0.88010699979824036), + FRAC_CONST(0.88083426034774204), + FRAC_CONST(0.88155944820914378), + FRAC_CONST(0.8822825616760086), + FRAC_CONST(0.88300359904678072), + FRAC_CONST(0.88372255862478966), + FRAC_CONST(0.8844394387182537), + FRAC_CONST(0.88515423764028511), + FRAC_CONST(0.88586695370889279), + FRAC_CONST(0.88657758524698704), + FRAC_CONST(0.88728613058238315), + FRAC_CONST(0.88799258804780556), + FRAC_CONST(0.88869695598089171), + FRAC_CONST(0.88939923272419552), + FRAC_CONST(0.89009941662519221), + FRAC_CONST(0.89079750603628149), + FRAC_CONST(0.89149349931479138), + FRAC_CONST(0.89218739482298248), + FRAC_CONST(0.89287919092805168), + FRAC_CONST(0.89356888600213602), + FRAC_CONST(0.89425647842231604), + FRAC_CONST(0.89494196657062075), + FRAC_CONST(0.89562534883403), + FRAC_CONST(0.89630662360447966), + FRAC_CONST(0.89698578927886397), + FRAC_CONST(0.89766284425904075), + FRAC_CONST(0.89833778695183419), + FRAC_CONST(0.89901061576903907), + FRAC_CONST(0.89968132912742393), + FRAC_CONST(0.9003499254487356), + FRAC_CONST(0.90101640315970233), + FRAC_CONST(0.90168076069203773), + FRAC_CONST(0.9023429964824442), + FRAC_CONST(0.90300310897261704), + FRAC_CONST(0.90366109660924798), + FRAC_CONST(0.90431695784402832), + FRAC_CONST(0.90497069113365325), + FRAC_CONST(0.90562229493982516), + FRAC_CONST(0.90627176772925766), + FRAC_CONST(0.90691910797367803), + FRAC_CONST(0.90756431414983252), + FRAC_CONST(0.9082073847394887), + FRAC_CONST(0.90884831822943912), + FRAC_CONST(0.90948711311150543), + FRAC_CONST(0.91012376788254157), + FRAC_CONST(0.91075828104443757), + FRAC_CONST(0.91139065110412232), + FRAC_CONST(0.91202087657356823), + FRAC_CONST(0.9126489559697939), + FRAC_CONST(0.91327488781486776), + FRAC_CONST(0.91389867063591168), + FRAC_CONST(0.91452030296510445), + FRAC_CONST(0.91513978333968526), + FRAC_CONST(0.91575711030195672), + FRAC_CONST(0.91637228239928914), + FRAC_CONST(0.91698529818412289), + FRAC_CONST(0.91759615621397295), + FRAC_CONST(0.9182048550514309), + FRAC_CONST(0.91881139326416994), + FRAC_CONST(0.91941576942494696), + FRAC_CONST(0.92001798211160657), + FRAC_CONST(0.92061802990708386), + FRAC_CONST(0.92121591139940873), + FRAC_CONST(0.92181162518170812), + FRAC_CONST(0.92240516985220988), + FRAC_CONST(0.92299654401424625), + FRAC_CONST(0.92358574627625656), + FRAC_CONST(0.9241727752517912), + FRAC_CONST(0.92475762955951391), + FRAC_CONST(0.9253403078232062), + FRAC_CONST(0.92592080867176996), + FRAC_CONST(0.92649913073923051), + FRAC_CONST(0.9270752726647401), + FRAC_CONST(0.92764923309258118), + FRAC_CONST(0.92822101067216944), + FRAC_CONST(0.92879060405805702), + FRAC_CONST(0.9293580119099355), + FRAC_CONST(0.92992323289263956), + FRAC_CONST(0.93048626567614978), + FRAC_CONST(0.93104710893559517), + FRAC_CONST(0.93160576135125783), + FRAC_CONST(0.93216222160857432), + FRAC_CONST(0.93271648839814025), + FRAC_CONST(0.93326856041571205), + FRAC_CONST(0.93381843636221096), + FRAC_CONST(0.9343661149437259), + FRAC_CONST(0.93491159487151609), + FRAC_CONST(0.93545487486201462), + FRAC_CONST(0.9359959536368313), + FRAC_CONST(0.9365348299227555), + FRAC_CONST(0.93707150245175919), + FRAC_CONST(0.93760596996099999), + FRAC_CONST(0.93813823119282436), + FRAC_CONST(0.93866828489477017), + FRAC_CONST(0.9391961298195699), + FRAC_CONST(0.93972176472515334), + FRAC_CONST(0.94024518837465088), + FRAC_CONST(0.94076639953639607), + FRAC_CONST(0.94128539698392866), + FRAC_CONST(0.94180217949599765), + FRAC_CONST(0.94231674585656378), + FRAC_CONST(0.94282909485480271), + FRAC_CONST(0.94333922528510772), + FRAC_CONST(0.94384713594709269), + FRAC_CONST(0.94435282564559475), + FRAC_CONST(0.94485629319067721), + FRAC_CONST(0.94535753739763229), + FRAC_CONST(0.94585655708698391), + FRAC_CONST(0.94635335108449059), + FRAC_CONST(0.946847918221148), + FRAC_CONST(0.94734025733319194), + FRAC_CONST(0.94783036726210101), + FRAC_CONST(0.94831824685459909), + FRAC_CONST(0.94880389496265838), + FRAC_CONST(0.94928731044350201), + FRAC_CONST(0.94976849215960668), + FRAC_CONST(0.95024743897870523), + FRAC_CONST(0.95072414977378961), + FRAC_CONST(0.95119862342311323), + FRAC_CONST(0.95167085881019386), + FRAC_CONST(0.95214085482381583), + FRAC_CONST(0.95260861035803324), + FRAC_CONST(0.9530741243121722), + FRAC_CONST(0.95353739559083328), + FRAC_CONST(0.95399842310389449), + FRAC_CONST(0.95445720576651349), + FRAC_CONST(0.95491374249913052), + FRAC_CONST(0.95536803222747024), + FRAC_CONST(0.95582007388254542), + FRAC_CONST(0.95626986640065814), + FRAC_CONST(0.95671740872340305), + FRAC_CONST(0.9571626997976701), + FRAC_CONST(0.95760573857564624), + FRAC_CONST(0.9580465240148186), + FRAC_CONST(0.9584850550779761), + FRAC_CONST(0.95892133073321306), + FRAC_CONST(0.95935534995393079), + FRAC_CONST(0.9597871117188399), + FRAC_CONST(0.96021661501196343), + FRAC_CONST(0.96064385882263847), + FRAC_CONST(0.96106884214551935), + FRAC_CONST(0.961491563980579), + FRAC_CONST(0.9619120233331121), + FRAC_CONST(0.9623302192137374), + FRAC_CONST(0.96274615063839941), + FRAC_CONST(0.96315981662837136), + FRAC_CONST(0.96357121621025721), + FRAC_CONST(0.96398034841599411), + FRAC_CONST(0.96438721228285429), + FRAC_CONST(0.9647918068534479), + FRAC_CONST(0.96519413117572472), + FRAC_CONST(0.96559418430297683), + FRAC_CONST(0.96599196529384057), + FRAC_CONST(0.96638747321229879), + FRAC_CONST(0.96678070712768327), + FRAC_CONST(0.96717166611467664), + FRAC_CONST(0.96756034925331436), + FRAC_CONST(0.9679467556289878), + FRAC_CONST(0.9683308843324453), + FRAC_CONST(0.96871273445979478), + FRAC_CONST(0.9690923051125061), + FRAC_CONST(0.96946959539741295), + FRAC_CONST(0.96984460442671483), + FRAC_CONST(0.97021733131797916), + FRAC_CONST(0.97058777519414363), + FRAC_CONST(0.97095593518351797), + FRAC_CONST(0.97132181041978616), + FRAC_CONST(0.97168540004200854), + FRAC_CONST(0.9720467031946235), + FRAC_CONST(0.97240571902744977), + FRAC_CONST(0.97276244669568857), + FRAC_CONST(0.97311688535992513), + FRAC_CONST(0.97346903418613095), + FRAC_CONST(0.9738188923456661), + FRAC_CONST(0.97416645901528032), + FRAC_CONST(0.97451173337711572), + FRAC_CONST(0.97485471461870843), + FRAC_CONST(0.97519540193299037), + FRAC_CONST(0.97553379451829136), + FRAC_CONST(0.97586989157834103), + FRAC_CONST(0.97620369232227056), + FRAC_CONST(0.97653519596461447), + FRAC_CONST(0.97686440172531264), + FRAC_CONST(0.97719130882971228), + FRAC_CONST(0.97751591650856928), + FRAC_CONST(0.97783822399805043), + FRAC_CONST(0.97815823053973505), + FRAC_CONST(0.97847593538061683), + FRAC_CONST(0.97879133777310567), + FRAC_CONST(0.97910443697502925), + FRAC_CONST(0.97941523224963478), + FRAC_CONST(0.97972372286559117), + FRAC_CONST(0.98002990809698998), + FRAC_CONST(0.98033378722334796), + FRAC_CONST(0.98063535952960812), + FRAC_CONST(0.98093462430614164), + FRAC_CONST(0.98123158084874973), + FRAC_CONST(0.98152622845866466), + FRAC_CONST(0.9818185664425525), + FRAC_CONST(0.98210859411251361), + FRAC_CONST(0.98239631078608469), + FRAC_CONST(0.98268171578624086), + FRAC_CONST(0.98296480844139644), + FRAC_CONST(0.98324558808540707), + FRAC_CONST(0.98352405405757126), + FRAC_CONST(0.98380020570263149), + FRAC_CONST(0.98407404237077645), + FRAC_CONST(0.9843455634176419), + FRAC_CONST(0.9846147682043126), + FRAC_CONST(0.9848816560973237), + FRAC_CONST(0.98514622646866223), + FRAC_CONST(0.98540847869576842), + FRAC_CONST(0.98566841216153755), + FRAC_CONST(0.98592602625432113), + FRAC_CONST(0.98618132036792827), + FRAC_CONST(0.98643429390162707), + FRAC_CONST(0.98668494626014669), + FRAC_CONST(0.98693327685367771), + FRAC_CONST(0.98717928509787434), + FRAC_CONST(0.98742297041385541), + FRAC_CONST(0.98766433222820571), + FRAC_CONST(0.98790336997297779), + FRAC_CONST(0.98814008308569257), + FRAC_CONST(0.98837447100934128), + FRAC_CONST(0.98860653319238645), + FRAC_CONST(0.98883626908876354), + FRAC_CONST(0.98906367815788154), + FRAC_CONST(0.98928875986462517), + FRAC_CONST(0.98951151367935519), + FRAC_CONST(0.98973193907791057), + FRAC_CONST(0.98995003554160899), + FRAC_CONST(0.9901658025572484), + FRAC_CONST(0.99037923961710816), + FRAC_CONST(0.99059034621895015), + FRAC_CONST(0.99079912186602037), + FRAC_CONST(0.99100556606704937), + FRAC_CONST(0.99120967833625406), + FRAC_CONST(0.99141145819333854), + FRAC_CONST(0.99161090516349537), + FRAC_CONST(0.99180801877740643), + FRAC_CONST(0.99200279857124452), + FRAC_CONST(0.99219524408667392), + FRAC_CONST(0.99238535487085167), + FRAC_CONST(0.99257313047642881), + FRAC_CONST(0.99275857046155114), + FRAC_CONST(0.99294167438986047), + FRAC_CONST(0.99312244183049558), + FRAC_CONST(0.99330087235809328), + FRAC_CONST(0.99347696555278919), + FRAC_CONST(0.99365072100021912), + FRAC_CONST(0.99382213829151966), + FRAC_CONST(0.99399121702332938), + FRAC_CONST(0.99415795679778973), + FRAC_CONST(0.99432235722254581), + FRAC_CONST(0.9944844179107476), + FRAC_CONST(0.99464413848105071), + FRAC_CONST(0.99480151855761711), + FRAC_CONST(0.99495655777011638), + FRAC_CONST(0.99510925575372611), + FRAC_CONST(0.99525961214913339), + FRAC_CONST(0.9954076266025349), + FRAC_CONST(0.99555329876563847), + FRAC_CONST(0.99569662829566352), + FRAC_CONST(0.99583761485534161), + FRAC_CONST(0.99597625811291779), + FRAC_CONST(0.99611255774215113), + FRAC_CONST(0.99624651342231552), + FRAC_CONST(0.99637812483820021), + FRAC_CONST(0.99650739168011082), + FRAC_CONST(0.9966343136438699), + FRAC_CONST(0.996758890430818), + FRAC_CONST(0.99688112174781385), + FRAC_CONST(0.99700100730723529), + FRAC_CONST(0.99711854682697998), + FRAC_CONST(0.99723374003046616), + FRAC_CONST(0.99734658664663323), + FRAC_CONST(0.99745708640994191), + FRAC_CONST(0.99756523906037575), + FRAC_CONST(0.997671044343441), + FRAC_CONST(0.99777450201016782), + FRAC_CONST(0.99787561181711015), + FRAC_CONST(0.99797437352634699), + FRAC_CONST(0.99807078690548234), + FRAC_CONST(0.99816485172764624), + FRAC_CONST(0.99825656777149518), + FRAC_CONST(0.99834593482121237), + FRAC_CONST(0.99843295266650844), + FRAC_CONST(0.99851762110262221), + FRAC_CONST(0.99859993993032037), + FRAC_CONST(0.99867990895589909), + FRAC_CONST(0.99875752799118334), + FRAC_CONST(0.99883279685352799), + FRAC_CONST(0.99890571536581829), + FRAC_CONST(0.99897628335646982), + FRAC_CONST(0.99904450065942929), + FRAC_CONST(0.99911036711417489), + FRAC_CONST(0.99917388256571638), + FRAC_CONST(0.99923504686459585), + FRAC_CONST(0.99929385986688779), + FRAC_CONST(0.99935032143419944), + FRAC_CONST(0.9994044314336713), + FRAC_CONST(0.99945618973797734), + FRAC_CONST(0.99950559622532531), + FRAC_CONST(0.99955265077945699), + FRAC_CONST(0.99959735328964838), + FRAC_CONST(0.9996397036507102), + FRAC_CONST(0.99967970176298793), + FRAC_CONST(0.99971734753236219), + FRAC_CONST(0.99975264087024884), + FRAC_CONST(0.99978558169359921), + FRAC_CONST(0.99981616992490041), + FRAC_CONST(0.99984440549217524), + FRAC_CONST(0.99987028832898295), + FRAC_CONST(0.99989381837441849), + FRAC_CONST(0.99991499557311347), + FRAC_CONST(0.999933819875236), + FRAC_CONST(0.99995029123649048), + FRAC_CONST(0.99996440961811828), + FRAC_CONST(0.99997617498689761), + FRAC_CONST(0.9999855873151432), + FRAC_CONST(0.99999264658070719), + FRAC_CONST(0.99999735276697821), + FRAC_CONST(0.99999970586288223) +}; + +#ifdef ALLOW_SMALL_FRAMELENGTH +static const real_t sine_long_960[] MEM_ALIGN_ATTR = +{ + FRAC_CONST(0.00081812299560725323), + FRAC_CONST(0.0024543667964602917), + FRAC_CONST(0.0040906040262347889), + FRAC_CONST(0.0057268303042312674), + FRAC_CONST(0.0073630412497795667), + FRAC_CONST(0.0089992324822505774), + FRAC_CONST(0.010635399621067975), + FRAC_CONST(0.012271538285719924), + FRAC_CONST(0.013907644095770845), + FRAC_CONST(0.015543712670873098), + FRAC_CONST(0.017179739630778748), + FRAC_CONST(0.018815720595351273), + FRAC_CONST(0.020451651184577292), + FRAC_CONST(0.022087527018578291), + FRAC_CONST(0.023723343717622358), + FRAC_CONST(0.025359096902135895), + FRAC_CONST(0.02699478219271537), + FRAC_CONST(0.028630395210139003), + FRAC_CONST(0.030265931575378519), + FRAC_CONST(0.031901386909610863), + FRAC_CONST(0.033536756834229922), + FRAC_CONST(0.035172036970858266), + FRAC_CONST(0.036807222941358832), + FRAC_CONST(0.038442310367846677), + FRAC_CONST(0.040077294872700696), + FRAC_CONST(0.041712172078575326), + FRAC_CONST(0.043346937608412288), + FRAC_CONST(0.044981587085452281), + FRAC_CONST(0.046616116133246711), + FRAC_CONST(0.048250520375669431), + FRAC_CONST(0.049884795436928406), + FRAC_CONST(0.051518936941577477), + FRAC_CONST(0.053152940514528055), + FRAC_CONST(0.05478680178106083), + FRAC_CONST(0.056420516366837495), + FRAC_CONST(0.05805407989791244), + FRAC_CONST(0.059687488000744485), + FRAC_CONST(0.061320736302208578), + FRAC_CONST(0.062953820429607482), + FRAC_CONST(0.064586736010683557), + FRAC_CONST(0.066219478673630344), + FRAC_CONST(0.06785204404710439), + FRAC_CONST(0.069484427760236861), + FRAC_CONST(0.071116625442645326), + FRAC_CONST(0.072748632724445372), + FRAC_CONST(0.07438044523626236), + FRAC_CONST(0.076012058609243122), + FRAC_CONST(0.077643468475067631), + FRAC_CONST(0.079274670465960706), + FRAC_CONST(0.080905660214703745), + FRAC_CONST(0.082536433354646319), + FRAC_CONST(0.084166985519717977), + FRAC_CONST(0.085797312344439894), + FRAC_CONST(0.08742740946393647), + FRAC_CONST(0.089057272513947183), + FRAC_CONST(0.090686897130838162), + FRAC_CONST(0.092316278951613845), + FRAC_CONST(0.093945413613928788), + FRAC_CONST(0.095574296756099186), + FRAC_CONST(0.097202924017114667), + FRAC_CONST(0.098831291036649963), + FRAC_CONST(0.10045939345507648), + FRAC_CONST(0.10208722691347409), + FRAC_CONST(0.10371478705364276), + FRAC_CONST(0.10534206951811415), + FRAC_CONST(0.10696906995016341), + FRAC_CONST(0.10859578399382072), + FRAC_CONST(0.11022220729388306), + FRAC_CONST(0.11184833549592579), + FRAC_CONST(0.11347416424631435), + FRAC_CONST(0.11509968919221586), + FRAC_CONST(0.11672490598161089), + FRAC_CONST(0.11834981026330495), + FRAC_CONST(0.11997439768694031), + FRAC_CONST(0.12159866390300751), + FRAC_CONST(0.12322260456285709), + FRAC_CONST(0.12484621531871121), + FRAC_CONST(0.12646949182367517), + FRAC_CONST(0.12809242973174936), + FRAC_CONST(0.12971502469784052), + FRAC_CONST(0.13133727237777362), + FRAC_CONST(0.13295916842830346), + FRAC_CONST(0.13458070850712617), + FRAC_CONST(0.13620188827289101), + FRAC_CONST(0.1378227033852118), + FRAC_CONST(0.13944314950467873), + FRAC_CONST(0.14106322229286994), + FRAC_CONST(0.14268291741236291), + FRAC_CONST(0.14430223052674654), + FRAC_CONST(0.1459211573006321), + FRAC_CONST(0.14753969339966552), + FRAC_CONST(0.14915783449053857), + FRAC_CONST(0.15077557624100058), + FRAC_CONST(0.15239291431987001), + FRAC_CONST(0.1540098443970461), + FRAC_CONST(0.15562636214352044), + FRAC_CONST(0.15724246323138855), + FRAC_CONST(0.15885814333386142), + FRAC_CONST(0.16047339812527725), + FRAC_CONST(0.16208822328111283), + FRAC_CONST(0.16370261447799525), + FRAC_CONST(0.16531656739371339), + FRAC_CONST(0.16693007770722967), + FRAC_CONST(0.16854314109869134), + FRAC_CONST(0.17015575324944232), + FRAC_CONST(0.17176790984203447), + FRAC_CONST(0.17337960656023954), + FRAC_CONST(0.1749908390890603), + FRAC_CONST(0.17660160311474243), + FRAC_CONST(0.17821189432478593), + FRAC_CONST(0.17982170840795647), + FRAC_CONST(0.18143104105429744), + FRAC_CONST(0.18303988795514095), + FRAC_CONST(0.1846482448031197), + FRAC_CONST(0.18625610729217834), + FRAC_CONST(0.1878634711175852), + FRAC_CONST(0.18947033197594348), + FRAC_CONST(0.19107668556520319), + FRAC_CONST(0.19268252758467228), + FRAC_CONST(0.19428785373502844), + FRAC_CONST(0.19589265971833042), + FRAC_CONST(0.19749694123802966), + FRAC_CONST(0.19910069399898173), + FRAC_CONST(0.20070391370745785), + FRAC_CONST(0.20230659607115639), + FRAC_CONST(0.20390873679921437), + FRAC_CONST(0.20551033160221882), + FRAC_CONST(0.20711137619221856), + FRAC_CONST(0.2087118662827353), + FRAC_CONST(0.21031179758877552), + FRAC_CONST(0.21191116582684155), + FRAC_CONST(0.21350996671494335), + FRAC_CONST(0.21510819597260972), + FRAC_CONST(0.21670584932089998), + FRAC_CONST(0.2183029224824154), + FRAC_CONST(0.21989941118131037), + FRAC_CONST(0.22149531114330431), + FRAC_CONST(0.22309061809569264), + FRAC_CONST(0.22468532776735861), + FRAC_CONST(0.22627943588878449), + FRAC_CONST(0.22787293819206314), + FRAC_CONST(0.22946583041090929), + FRAC_CONST(0.23105810828067114), + FRAC_CONST(0.23264976753834157), + FRAC_CONST(0.23424080392256985), + FRAC_CONST(0.2358312131736727), + FRAC_CONST(0.23742099103364595), + FRAC_CONST(0.23901013324617584), + FRAC_CONST(0.24059863555665045), + FRAC_CONST(0.24218649371217096), + FRAC_CONST(0.24377370346156332), + FRAC_CONST(0.24536026055538934), + FRAC_CONST(0.24694616074595824), + FRAC_CONST(0.24853139978733788), + FRAC_CONST(0.25011597343536629), + FRAC_CONST(0.25169987744766298), + FRAC_CONST(0.25328310758364025), + FRAC_CONST(0.25486565960451457), + FRAC_CONST(0.25644752927331788), + FRAC_CONST(0.25802871235490898), + FRAC_CONST(0.25960920461598508), + FRAC_CONST(0.26118900182509258), + FRAC_CONST(0.26276809975263904), + FRAC_CONST(0.264346494170904), + FRAC_CONST(0.26592418085405067), + FRAC_CONST(0.26750115557813692), + FRAC_CONST(0.2690774141211269), + FRAC_CONST(0.27065295226290209), + FRAC_CONST(0.2722277657852728), + FRAC_CONST(0.27380185047198918), + FRAC_CONST(0.27537520210875299), + FRAC_CONST(0.2769478164832283), + FRAC_CONST(0.27851968938505312), + FRAC_CONST(0.28009081660585067), + FRAC_CONST(0.28166119393924061), + FRAC_CONST(0.28323081718085019), + FRAC_CONST(0.28479968212832563), + FRAC_CONST(0.28636778458134327), + FRAC_CONST(0.28793512034162105), + FRAC_CONST(0.2895016852129294), + FRAC_CONST(0.29106747500110264), + FRAC_CONST(0.29263248551405047), + FRAC_CONST(0.2941967125617686), + FRAC_CONST(0.29576015195635058), + FRAC_CONST(0.29732279951199847), + FRAC_CONST(0.29888465104503475), + FRAC_CONST(0.30044570237391266), + FRAC_CONST(0.30200594931922808), + FRAC_CONST(0.30356538770373032), + FRAC_CONST(0.30512401335233358), + FRAC_CONST(0.30668182209212791), + FRAC_CONST(0.3082388097523906), + FRAC_CONST(0.30979497216459695), + FRAC_CONST(0.31135030516243201), + FRAC_CONST(0.3129048045818012), + FRAC_CONST(0.31445846626084178), + FRAC_CONST(0.31601128603993378), + FRAC_CONST(0.31756325976171151), + FRAC_CONST(0.31911438327107416), + FRAC_CONST(0.32066465241519732), + FRAC_CONST(0.32221406304354389), + FRAC_CONST(0.3237626110078754), + FRAC_CONST(0.32531029216226293), + FRAC_CONST(0.32685710236309828), + FRAC_CONST(0.32840303746910487), + FRAC_CONST(0.32994809334134939), + FRAC_CONST(0.3314922658432522), + FRAC_CONST(0.33303555084059877), + FRAC_CONST(0.33457794420155085), + FRAC_CONST(0.33611944179665709), + FRAC_CONST(0.33766003949886464), + FRAC_CONST(0.33919973318352969), + FRAC_CONST(0.34073851872842903), + FRAC_CONST(0.34227639201377064), + FRAC_CONST(0.34381334892220483), + FRAC_CONST(0.34534938533883547), + FRAC_CONST(0.34688449715123082), + FRAC_CONST(0.34841868024943456), + FRAC_CONST(0.34995193052597684), + FRAC_CONST(0.35148424387588523), + FRAC_CONST(0.3530156161966958), + FRAC_CONST(0.35454604338846402), + FRAC_CONST(0.35607552135377557), + FRAC_CONST(0.35760404599775775), + FRAC_CONST(0.35913161322809023), + FRAC_CONST(0.36065821895501554), + FRAC_CONST(0.36218385909135092), + FRAC_CONST(0.36370852955249849), + FRAC_CONST(0.36523222625645668), + FRAC_CONST(0.36675494512383078), + FRAC_CONST(0.36827668207784414), + FRAC_CONST(0.36979743304434909), + FRAC_CONST(0.37131719395183754), + FRAC_CONST(0.37283596073145214), + FRAC_CONST(0.37435372931699717), + FRAC_CONST(0.37587049564494951), + FRAC_CONST(0.37738625565446909), + FRAC_CONST(0.37890100528741022), + FRAC_CONST(0.38041474048833229), + FRAC_CONST(0.38192745720451066), + FRAC_CONST(0.38343915138594736), + FRAC_CONST(0.38494981898538222), + FRAC_CONST(0.38645945595830333), + FRAC_CONST(0.38796805826295838), + FRAC_CONST(0.38947562186036483), + FRAC_CONST(0.39098214271432141), + FRAC_CONST(0.39248761679141814), + FRAC_CONST(0.3939920400610481), + FRAC_CONST(0.39549540849541737), + FRAC_CONST(0.39699771806955625), + FRAC_CONST(0.39849896476132979), + FRAC_CONST(0.39999914455144892), + FRAC_CONST(0.40149825342348083), + FRAC_CONST(0.4029962873638599), + FRAC_CONST(0.40449324236189854), + FRAC_CONST(0.40598911440979762), + FRAC_CONST(0.40748389950265762), + FRAC_CONST(0.40897759363848879), + FRAC_CONST(0.41047019281822261), + FRAC_CONST(0.41196169304572178), + FRAC_CONST(0.4134520903277914), + FRAC_CONST(0.41494138067418929), + FRAC_CONST(0.41642956009763715), + FRAC_CONST(0.41791662461383078), + FRAC_CONST(0.41940257024145089), + FRAC_CONST(0.42088739300217382), + FRAC_CONST(0.42237108892068231), + FRAC_CONST(0.42385365402467584), + FRAC_CONST(0.42533508434488143), + FRAC_CONST(0.42681537591506419), + FRAC_CONST(0.42829452477203828), + FRAC_CONST(0.42977252695567697), + FRAC_CONST(0.43124937850892364), + FRAC_CONST(0.4327250754778022), + FRAC_CONST(0.43419961391142781), + FRAC_CONST(0.43567298986201736), + FRAC_CONST(0.43714519938489987), + FRAC_CONST(0.43861623853852766), + FRAC_CONST(0.44008610338448595), + FRAC_CONST(0.44155478998750436), + FRAC_CONST(0.44302229441546676), + FRAC_CONST(0.4444886127394222), + FRAC_CONST(0.44595374103359531), + FRAC_CONST(0.44741767537539667), + FRAC_CONST(0.44888041184543348), + FRAC_CONST(0.45034194652752002), + FRAC_CONST(0.45180227550868812), + FRAC_CONST(0.45326139487919759), + FRAC_CONST(0.45471930073254679), + FRAC_CONST(0.45617598916548296), + FRAC_CONST(0.45763145627801283), + FRAC_CONST(0.45908569817341294), + FRAC_CONST(0.46053871095824001), + FRAC_CONST(0.46199049074234161), + FRAC_CONST(0.46344103363886635), + FRAC_CONST(0.46489033576427435), + FRAC_CONST(0.46633839323834758), + FRAC_CONST(0.46778520218420055), + FRAC_CONST(0.46923075872829029), + FRAC_CONST(0.47067505900042683), + FRAC_CONST(0.47211809913378361), + FRAC_CONST(0.47355987526490806), + FRAC_CONST(0.47500038353373153), + FRAC_CONST(0.47643962008357982), + FRAC_CONST(0.47787758106118372), + FRAC_CONST(0.47931426261668875), + FRAC_CONST(0.48074966090366611), + FRAC_CONST(0.48218377207912272), + FRAC_CONST(0.48361659230351117), + FRAC_CONST(0.48504811774074069), + FRAC_CONST(0.48647834455818684), + FRAC_CONST(0.48790726892670194), + FRAC_CONST(0.48933488702062544), + FRAC_CONST(0.49076119501779414), + FRAC_CONST(0.49218618909955225), + FRAC_CONST(0.4936098654507618), + FRAC_CONST(0.49503222025981269), + FRAC_CONST(0.49645324971863303), + FRAC_CONST(0.49787295002269943), + FRAC_CONST(0.49929131737104687), + FRAC_CONST(0.50070834796627917), + FRAC_CONST(0.50212403801457872), + FRAC_CONST(0.50353838372571758), + FRAC_CONST(0.50495138131306638), + FRAC_CONST(0.50636302699360547), + FRAC_CONST(0.50777331698793449), + FRAC_CONST(0.50918224752028263), + FRAC_CONST(0.51058981481851906), + FRAC_CONST(0.51199601511416237), + FRAC_CONST(0.51340084464239111), + FRAC_CONST(0.51480429964205421), + FRAC_CONST(0.51620637635567967), + FRAC_CONST(0.51760707102948678), + FRAC_CONST(0.51900637991339404), + FRAC_CONST(0.5204042992610306), + FRAC_CONST(0.52180082532974559), + FRAC_CONST(0.5231959543806185), + FRAC_CONST(0.52458968267846895), + FRAC_CONST(0.52598200649186677), + FRAC_CONST(0.52737292209314235), + FRAC_CONST(0.52876242575839572), + FRAC_CONST(0.53015051376750777), + FRAC_CONST(0.53153718240414882), + FRAC_CONST(0.53292242795578992), + FRAC_CONST(0.53430624671371152), + FRAC_CONST(0.53568863497301467), + FRAC_CONST(0.5370695890326298), + FRAC_CONST(0.5384491051953274), + FRAC_CONST(0.53982717976772743), + FRAC_CONST(0.54120380906030963), + FRAC_CONST(0.54257898938742311), + FRAC_CONST(0.54395271706729609), + FRAC_CONST(0.54532498842204646), + FRAC_CONST(0.54669579977769045), + FRAC_CONST(0.54806514746415402), + FRAC_CONST(0.54943302781528081), + FRAC_CONST(0.55079943716884383), + FRAC_CONST(0.55216437186655387), + FRAC_CONST(0.55352782825406999), + FRAC_CONST(0.55488980268100907), + FRAC_CONST(0.55625029150095584), + FRAC_CONST(0.55760929107147217), + FRAC_CONST(0.55896679775410718), + FRAC_CONST(0.56032280791440714), + FRAC_CONST(0.56167731792192455), + FRAC_CONST(0.56303032415022869), + FRAC_CONST(0.56438182297691453), + FRAC_CONST(0.56573181078361312), + FRAC_CONST(0.56708028395600085), + FRAC_CONST(0.56842723888380908), + FRAC_CONST(0.56977267196083425), + FRAC_CONST(0.57111657958494688), + FRAC_CONST(0.5724589581581021), + FRAC_CONST(0.57379980408634845), + FRAC_CONST(0.57513911377983773), + FRAC_CONST(0.57647688365283478), + FRAC_CONST(0.57781311012372738), + FRAC_CONST(0.57914778961503466), + FRAC_CONST(0.58048091855341843), + FRAC_CONST(0.5818124933696911), + FRAC_CONST(0.58314251049882604), + FRAC_CONST(0.58447096637996743), + FRAC_CONST(0.58579785745643886), + FRAC_CONST(0.5871231801757536), + FRAC_CONST(0.58844693098962408), + FRAC_CONST(0.58976910635397084), + FRAC_CONST(0.59108970272893235), + FRAC_CONST(0.59240871657887517), + FRAC_CONST(0.59372614437240179), + FRAC_CONST(0.59504198258236196), + FRAC_CONST(0.5963562276858605), + FRAC_CONST(0.59766887616426767), + FRAC_CONST(0.5989799245032289), + FRAC_CONST(0.60028936919267273), + FRAC_CONST(0.60159720672682204), + FRAC_CONST(0.60290343360420195), + FRAC_CONST(0.60420804632765002), + FRAC_CONST(0.60551104140432543), + FRAC_CONST(0.60681241534571839), + FRAC_CONST(0.60811216466765883), + FRAC_CONST(0.60941028589032709), + FRAC_CONST(0.61070677553826169), + FRAC_CONST(0.61200163014036979), + FRAC_CONST(0.61329484622993602), + FRAC_CONST(0.6145864203446314), + FRAC_CONST(0.61587634902652377), + FRAC_CONST(0.61716462882208556), + FRAC_CONST(0.61845125628220421), + FRAC_CONST(0.61973622796219074), + FRAC_CONST(0.6210195404217892), + FRAC_CONST(0.62230119022518593), + FRAC_CONST(0.62358117394101897), + FRAC_CONST(0.62485948814238634), + FRAC_CONST(0.62613612940685637), + FRAC_CONST(0.62741109431647646), + FRAC_CONST(0.62868437945778133), + FRAC_CONST(0.62995598142180387), + FRAC_CONST(0.6312258968040827), + FRAC_CONST(0.63249412220467238), + FRAC_CONST(0.63376065422815175), + FRAC_CONST(0.63502548948363347), + FRAC_CONST(0.63628862458477287), + FRAC_CONST(0.63755005614977711), + FRAC_CONST(0.63880978080141437), + FRAC_CONST(0.6400677951670225), + FRAC_CONST(0.6413240958785188), + FRAC_CONST(0.64257867957240766), + FRAC_CONST(0.6438315428897915), + FRAC_CONST(0.64508268247637779), + FRAC_CONST(0.64633209498248945), + FRAC_CONST(0.64757977706307335), + FRAC_CONST(0.64882572537770888), + FRAC_CONST(0.65006993659061751), + FRAC_CONST(0.65131240737067142), + FRAC_CONST(0.65255313439140239), + FRAC_CONST(0.65379211433101081), + FRAC_CONST(0.65502934387237444), + FRAC_CONST(0.6562648197030575), + FRAC_CONST(0.65749853851531959), + FRAC_CONST(0.65873049700612374), + FRAC_CONST(0.65996069187714679), + FRAC_CONST(0.66118911983478657), + FRAC_CONST(0.66241577759017178), + FRAC_CONST(0.66364066185917048), + FRAC_CONST(0.66486376936239888), + FRAC_CONST(0.66608509682523009), + FRAC_CONST(0.66730464097780284), + FRAC_CONST(0.66852239855503071), + FRAC_CONST(0.66973836629660977), + FRAC_CONST(0.67095254094702894), + FRAC_CONST(0.67216491925557675), + FRAC_CONST(0.67337549797635199), + FRAC_CONST(0.67458427386827102), + FRAC_CONST(0.67579124369507693), + FRAC_CONST(0.67699640422534846), + FRAC_CONST(0.67819975223250772), + FRAC_CONST(0.6794012844948305), + FRAC_CONST(0.68060099779545302), + FRAC_CONST(0.68179888892238183), + FRAC_CONST(0.6829949546685018), + FRAC_CONST(0.68418919183158522), + FRAC_CONST(0.68538159721429948), + FRAC_CONST(0.6865721676242168), + FRAC_CONST(0.68776089987382172), + FRAC_CONST(0.68894779078052026), + FRAC_CONST(0.69013283716664853), + FRAC_CONST(0.69131603585948032), + FRAC_CONST(0.69249738369123692), + FRAC_CONST(0.69367687749909468), + FRAC_CONST(0.69485451412519361), + FRAC_CONST(0.69603029041664599), + FRAC_CONST(0.6972042032255451), + FRAC_CONST(0.6983762494089728), + FRAC_CONST(0.69954642582900894), + FRAC_CONST(0.70071472935273893), + FRAC_CONST(0.70188115685226271), + FRAC_CONST(0.703045705204703), + FRAC_CONST(0.70420837129221303), + FRAC_CONST(0.70536915200198613), + FRAC_CONST(0.70652804422626281), + FRAC_CONST(0.70768504486233985), + FRAC_CONST(0.70884015081257845), + FRAC_CONST(0.70999335898441229), + FRAC_CONST(0.711144666290356), + FRAC_CONST(0.71229406964801356), + FRAC_CONST(0.71344156598008623), + FRAC_CONST(0.71458715221438096), + FRAC_CONST(0.71573082528381871), + FRAC_CONST(0.71687258212644234), + FRAC_CONST(0.7180124196854254), + FRAC_CONST(0.71915033490907943), + FRAC_CONST(0.72028632475086318), + FRAC_CONST(0.72142038616938997), + FRAC_CONST(0.72255251612843596), + FRAC_CONST(0.72368271159694852), + FRAC_CONST(0.72481096954905444), + FRAC_CONST(0.72593728696406756), + FRAC_CONST(0.72706166082649704), + FRAC_CONST(0.72818408812605595), + FRAC_CONST(0.72930456585766834), + FRAC_CONST(0.73042309102147851), + FRAC_CONST(0.73153966062285747), + FRAC_CONST(0.73265427167241282), + FRAC_CONST(0.73376692118599507), + FRAC_CONST(0.73487760618470677), + FRAC_CONST(0.73598632369490979), + FRAC_CONST(0.73709307074823405), + FRAC_CONST(0.73819784438158409), + FRAC_CONST(0.73930064163714881), + FRAC_CONST(0.74040145956240788), + FRAC_CONST(0.74150029521014049), + FRAC_CONST(0.74259714563843304), + FRAC_CONST(0.74369200791068657), + FRAC_CONST(0.74478487909562552), + FRAC_CONST(0.74587575626730485), + FRAC_CONST(0.74696463650511791), + FRAC_CONST(0.74805151689380456), + FRAC_CONST(0.74913639452345926), + FRAC_CONST(0.75021926648953785), + FRAC_CONST(0.75130012989286621), + FRAC_CONST(0.7523789818396478), + FRAC_CONST(0.75345581944147111), + FRAC_CONST(0.75453063981531809), + FRAC_CONST(0.75560344008357094), + FRAC_CONST(0.75667421737402052), + FRAC_CONST(0.7577429688198738), + FRAC_CONST(0.75880969155976163), + FRAC_CONST(0.75987438273774599), + FRAC_CONST(0.76093703950332836), + FRAC_CONST(0.76199765901145666), + FRAC_CONST(0.76305623842253345), + FRAC_CONST(0.76411277490242291), + FRAC_CONST(0.76516726562245885), + FRAC_CONST(0.76621970775945258), + FRAC_CONST(0.76727009849569949), + FRAC_CONST(0.76831843501898767), + FRAC_CONST(0.76936471452260458), + FRAC_CONST(0.77040893420534517), + FRAC_CONST(0.77145109127151923), + FRAC_CONST(0.77249118293095853), + FRAC_CONST(0.77352920639902467), + FRAC_CONST(0.77456515889661659), + FRAC_CONST(0.77559903765017746), + FRAC_CONST(0.7766308398917029), + FRAC_CONST(0.77766056285874774), + FRAC_CONST(0.77868820379443371), + FRAC_CONST(0.77971375994745684), + FRAC_CONST(0.78073722857209438), + FRAC_CONST(0.7817586069282132), + FRAC_CONST(0.78277789228127592), + FRAC_CONST(0.78379508190234881), + FRAC_CONST(0.78481017306810918), + FRAC_CONST(0.78582316306085265), + FRAC_CONST(0.78683404916849986), + FRAC_CONST(0.78784282868460476), + FRAC_CONST(0.78884949890836087), + FRAC_CONST(0.78985405714460888), + FRAC_CONST(0.7908565007038445), + FRAC_CONST(0.79185682690222425), + FRAC_CONST(0.79285503306157412), + FRAC_CONST(0.79385111650939566), + FRAC_CONST(0.79484507457887377), + FRAC_CONST(0.79583690460888357), + FRAC_CONST(0.79682660394399751), + FRAC_CONST(0.79781416993449272), + FRAC_CONST(0.79879959993635785), + FRAC_CONST(0.7997828913113002), + FRAC_CONST(0.80076404142675273), + FRAC_CONST(0.80174304765588156), + FRAC_CONST(0.80271990737759213), + FRAC_CONST(0.80369461797653707), + FRAC_CONST(0.80466717684312306), + FRAC_CONST(0.80563758137351682), + FRAC_CONST(0.80660582896965372), + FRAC_CONST(0.80757191703924336), + FRAC_CONST(0.80853584299577752), + FRAC_CONST(0.80949760425853612), + FRAC_CONST(0.81045719825259477), + FRAC_CONST(0.81141462240883167), + FRAC_CONST(0.81236987416393436), + FRAC_CONST(0.81332295096040608), + FRAC_CONST(0.81427385024657373), + FRAC_CONST(0.81522256947659355), + FRAC_CONST(0.81616910611045879), + FRAC_CONST(0.817113457614006), + FRAC_CONST(0.81805562145892186), + FRAC_CONST(0.81899559512275044), + FRAC_CONST(0.81993337608889916), + FRAC_CONST(0.82086896184664637), + FRAC_CONST(0.8218023498911472), + FRAC_CONST(0.82273353772344116), + FRAC_CONST(0.82366252285045805), + FRAC_CONST(0.82458930278502529), + FRAC_CONST(0.82551387504587381), + FRAC_CONST(0.82643623715764558), + FRAC_CONST(0.82735638665089983), + FRAC_CONST(0.82827432106211907), + FRAC_CONST(0.82919003793371693), + FRAC_CONST(0.83010353481404364), + FRAC_CONST(0.83101480925739324), + FRAC_CONST(0.83192385882400965), + FRAC_CONST(0.83283068108009373), + FRAC_CONST(0.8337352735978093), + FRAC_CONST(0.83463763395529011), + FRAC_CONST(0.83553775973664579), + FRAC_CONST(0.83643564853196872), + FRAC_CONST(0.83733129793734051), + FRAC_CONST(0.83822470555483797), + FRAC_CONST(0.83911586899254031), + FRAC_CONST(0.84000478586453453), + FRAC_CONST(0.84089145379092289), + FRAC_CONST(0.84177587039782842), + FRAC_CONST(0.84265803331740163), + FRAC_CONST(0.84353794018782702), + FRAC_CONST(0.844415588653329), + FRAC_CONST(0.8452909763641786), + FRAC_CONST(0.84616410097669936), + FRAC_CONST(0.84703496015327406), + FRAC_CONST(0.84790355156235053), + FRAC_CONST(0.84876987287844818), + FRAC_CONST(0.8496339217821639), + FRAC_CONST(0.85049569596017938), + FRAC_CONST(0.85135519310526508), + FRAC_CONST(0.85221241091628896), + FRAC_CONST(0.85306734709822085), + FRAC_CONST(0.85391999936213903), + FRAC_CONST(0.85477036542523732), + FRAC_CONST(0.85561844301082923), + FRAC_CONST(0.85646422984835635), + FRAC_CONST(0.85730772367339259), + FRAC_CONST(0.85814892222765116), + FRAC_CONST(0.85898782325899026), + FRAC_CONST(0.85982442452141961), + FRAC_CONST(0.86065872377510555), + FRAC_CONST(0.86149071878637817), + FRAC_CONST(0.8623204073277364), + FRAC_CONST(0.86314778717785412), + FRAC_CONST(0.8639728561215867), + FRAC_CONST(0.86479561194997623), + FRAC_CONST(0.86561605246025763), + FRAC_CONST(0.86643417545586487), + FRAC_CONST(0.8672499787464365), + FRAC_CONST(0.86806346014782154), + FRAC_CONST(0.8688746174820855), + FRAC_CONST(0.86968344857751589), + FRAC_CONST(0.87048995126862883), + FRAC_CONST(0.87129412339617363), + FRAC_CONST(0.87209596280713941), + FRAC_CONST(0.8728954673547612), + FRAC_CONST(0.87369263489852422), + FRAC_CONST(0.87448746330417149), + FRAC_CONST(0.87527995044370765), + FRAC_CONST(0.8760700941954066), + FRAC_CONST(0.87685789244381551), + FRAC_CONST(0.87764334307976144), + FRAC_CONST(0.87842644400035663), + FRAC_CONST(0.8792071931090043), + FRAC_CONST(0.87998558831540408), + FRAC_CONST(0.88076162753555787), + FRAC_CONST(0.88153530869177488), + FRAC_CONST(0.88230662971267804), + FRAC_CONST(0.88307558853320878), + FRAC_CONST(0.88384218309463292), + FRAC_CONST(0.8846064113445461), + FRAC_CONST(0.88536827123687933), + FRAC_CONST(0.88612776073190425), + FRAC_CONST(0.88688487779623937), + FRAC_CONST(0.88763962040285393), + FRAC_CONST(0.8883919865310751), + FRAC_CONST(0.88914197416659235), + FRAC_CONST(0.88988958130146301), + FRAC_CONST(0.8906348059341177), + FRAC_CONST(0.89137764606936609), + FRAC_CONST(0.89211809971840139), + FRAC_CONST(0.89285616489880615), + FRAC_CONST(0.89359183963455813), + FRAC_CONST(0.89432512195603453), + FRAC_CONST(0.89505600990001799), + FRAC_CONST(0.89578450150970124), + FRAC_CONST(0.8965105948346932), + FRAC_CONST(0.89723428793102367), + FRAC_CONST(0.89795557886114807), + FRAC_CONST(0.89867446569395382), + FRAC_CONST(0.89939094650476448), + FRAC_CONST(0.90010501937534515), + FRAC_CONST(0.900816682393908), + FRAC_CONST(0.90152593365511691), + FRAC_CONST(0.90223277126009283), + FRAC_CONST(0.90293719331641886), + FRAC_CONST(0.90363919793814496), + FRAC_CONST(0.90433878324579353), + FRAC_CONST(0.90503594736636439), + FRAC_CONST(0.90573068843333915), + FRAC_CONST(0.90642300458668679), + FRAC_CONST(0.90711289397286898), + FRAC_CONST(0.90780035474484411), + FRAC_CONST(0.90848538506207266), + FRAC_CONST(0.90916798309052227), + FRAC_CONST(0.90984814700267291), + FRAC_CONST(0.9105258749775208), + FRAC_CONST(0.91120116520058425), + FRAC_CONST(0.91187401586390815), + FRAC_CONST(0.91254442516606893), + FRAC_CONST(0.9132123913121788), + FRAC_CONST(0.91387791251389161), + FRAC_CONST(0.91454098698940678), + FRAC_CONST(0.91520161296347435), + FRAC_CONST(0.91585978866739981), + FRAC_CONST(0.91651551233904871), + FRAC_CONST(0.91716878222285148), + FRAC_CONST(0.91781959656980805), + FRAC_CONST(0.91846795363749245), + FRAC_CONST(0.91911385169005766), + FRAC_CONST(0.9197572889982405), + FRAC_CONST(0.9203982638393654), + FRAC_CONST(0.92103677449734989), + FRAC_CONST(0.92167281926270861), + FRAC_CONST(0.92230639643255874), + FRAC_CONST(0.92293750431062316), + FRAC_CONST(0.92356614120723612), + FRAC_CONST(0.92419230543934783), + FRAC_CONST(0.92481599533052783), + FRAC_CONST(0.92543720921097061), + FRAC_CONST(0.92605594541749991), + FRAC_CONST(0.92667220229357261), + FRAC_CONST(0.92728597818928349), + FRAC_CONST(0.9278972714613698), + FRAC_CONST(0.92850608047321548), + FRAC_CONST(0.9291124035948557), + FRAC_CONST(0.92971623920298097), + FRAC_CONST(0.93031758568094147), + FRAC_CONST(0.93091644141875196), + FRAC_CONST(0.93151280481309506), + FRAC_CONST(0.93210667426732674), + FRAC_CONST(0.93269804819147983), + FRAC_CONST(0.93328692500226818), + FRAC_CONST(0.93387330312309147), + FRAC_CONST(0.93445718098403896), + FRAC_CONST(0.93503855702189376), + FRAC_CONST(0.9356174296801375), + FRAC_CONST(0.93619379740895381), + FRAC_CONST(0.93676765866523259), + FRAC_CONST(0.93733901191257496), + FRAC_CONST(0.93790785562129597), + FRAC_CONST(0.93847418826842988), + FRAC_CONST(0.93903800833773399), + FRAC_CONST(0.93959931431969212), + FRAC_CONST(0.94015810471151917), + FRAC_CONST(0.94071437801716529), + FRAC_CONST(0.94126813274731924), + FRAC_CONST(0.94181936741941319), + FRAC_CONST(0.94236808055762578), + FRAC_CONST(0.94291427069288691), + FRAC_CONST(0.94345793636288133), + FRAC_CONST(0.94399907611205225), + FRAC_CONST(0.9445376884916058), + FRAC_CONST(0.94507377205951448), + FRAC_CONST(0.94560732538052128), + FRAC_CONST(0.94613834702614352), + FRAC_CONST(0.94666683557467624), + FRAC_CONST(0.94719278961119657), + FRAC_CONST(0.94771620772756759), + FRAC_CONST(0.94823708852244104), + FRAC_CONST(0.94875543060126255), + FRAC_CONST(0.94927123257627433), + FRAC_CONST(0.94978449306651924), + FRAC_CONST(0.95029521069784428), + FRAC_CONST(0.9508033841029051), + FRAC_CONST(0.95130901192116835), + FRAC_CONST(0.9518120927989161), + FRAC_CONST(0.95231262538924943), + FRAC_CONST(0.95281060835209208), + FRAC_CONST(0.95330604035419386), + FRAC_CONST(0.95379892006913403), + FRAC_CONST(0.95428924617732525), + FRAC_CONST(0.95477701736601728), + FRAC_CONST(0.95526223232929941), + FRAC_CONST(0.95574488976810545), + FRAC_CONST(0.95622498839021619), + FRAC_CONST(0.95670252691026292), + FRAC_CONST(0.95717750404973156), + FRAC_CONST(0.95764991853696524), + FRAC_CONST(0.95811976910716812), + FRAC_CONST(0.95858705450240911), + FRAC_CONST(0.95905177347162429), + FRAC_CONST(0.95951392477062125), + FRAC_CONST(0.95997350716208196), + FRAC_CONST(0.96043051941556579), + FRAC_CONST(0.96088496030751369), + FRAC_CONST(0.96133682862125036), + FRAC_CONST(0.96178612314698864), + FRAC_CONST(0.96223284268183173), + FRAC_CONST(0.9626769860297768), + FRAC_CONST(0.96311855200171881), + FRAC_CONST(0.96355753941545252), + FRAC_CONST(0.96399394709567654), + FRAC_CONST(0.96442777387399625), + FRAC_CONST(0.96485901858892686), + FRAC_CONST(0.96528768008589627), + FRAC_CONST(0.96571375721724895), + FRAC_CONST(0.96613724884224783), + FRAC_CONST(0.96655815382707866), + FRAC_CONST(0.96697647104485207), + FRAC_CONST(0.96739219937560694), + FRAC_CONST(0.96780533770631338), + FRAC_CONST(0.96821588493087585), + FRAC_CONST(0.9686238399501359), + FRAC_CONST(0.96902920167187501), + FRAC_CONST(0.96943196901081796), + FRAC_CONST(0.96983214088863534), + FRAC_CONST(0.9702297162339466), + FRAC_CONST(0.97062469398232287), + FRAC_CONST(0.97101707307629004), + FRAC_CONST(0.97140685246533098), + FRAC_CONST(0.97179403110588902), + FRAC_CONST(0.97217860796137046), + FRAC_CONST(0.97256058200214734), + FRAC_CONST(0.97293995220556007), + FRAC_CONST(0.97331671755592064), + FRAC_CONST(0.97369087704451474), + FRAC_CONST(0.97406242966960455), + FRAC_CONST(0.97443137443643235), + FRAC_CONST(0.97479771035722163), + FRAC_CONST(0.97516143645118103), + FRAC_CONST(0.97552255174450631), + FRAC_CONST(0.97588105527038305), + FRAC_CONST(0.97623694606898959), + FRAC_CONST(0.97659022318749911), + FRAC_CONST(0.97694088568008242), + FRAC_CONST(0.97728893260791039), + FRAC_CONST(0.97763436303915685), + FRAC_CONST(0.97797717604900047), + FRAC_CONST(0.97831737071962765), + FRAC_CONST(0.97865494614023485), + FRAC_CONST(0.97898990140703124), + FRAC_CONST(0.97932223562324061), + FRAC_CONST(0.97965194789910426), + FRAC_CONST(0.9799790373518833), + FRAC_CONST(0.98030350310586067), + FRAC_CONST(0.98062534429234405), + FRAC_CONST(0.98094456004966768), + FRAC_CONST(0.98126114952319499), + FRAC_CONST(0.98157511186532054), + FRAC_CONST(0.98188644623547261), + FRAC_CONST(0.98219515180011563), + FRAC_CONST(0.98250122773275184), + FRAC_CONST(0.98280467321392362), + FRAC_CONST(0.98310548743121629), + FRAC_CONST(0.98340366957925973), + FRAC_CONST(0.98369921885973044), + FRAC_CONST(0.98399213448135414), + FRAC_CONST(0.98428241565990748), + FRAC_CONST(0.98457006161822058), + FRAC_CONST(0.98485507158617835), + FRAC_CONST(0.98513744480072363), + FRAC_CONST(0.98541718050585803), + FRAC_CONST(0.98569427795264519), + FRAC_CONST(0.98596873639921168), + FRAC_CONST(0.98624055511074971), + FRAC_CONST(0.98650973335951875), + FRAC_CONST(0.98677627042484772), + FRAC_CONST(0.98704016559313645), + FRAC_CONST(0.98730141815785832), + FRAC_CONST(0.98756002741956173), + FRAC_CONST(0.9878159926858715), + FRAC_CONST(0.98806931327149194), + FRAC_CONST(0.98831998849820735), + FRAC_CONST(0.98856801769488489), + FRAC_CONST(0.98881340019747566), + FRAC_CONST(0.98905613534901682), + FRAC_CONST(0.98929622249963345), + FRAC_CONST(0.98953366100653983), + FRAC_CONST(0.98976845023404181), + FRAC_CONST(0.99000058955353776), + FRAC_CONST(0.99023007834352106), + FRAC_CONST(0.99045691598958097), + FRAC_CONST(0.99068110188440506), + FRAC_CONST(0.99090263542778001), + FRAC_CONST(0.99112151602659404), + FRAC_CONST(0.99133774309483769), + FRAC_CONST(0.99155131605360625), + FRAC_CONST(0.99176223433110056), + FRAC_CONST(0.99197049736262888), + FRAC_CONST(0.99217610459060845), + FRAC_CONST(0.99237905546456673), + FRAC_CONST(0.99257934944114334), + FRAC_CONST(0.99277698598409092), + FRAC_CONST(0.99297196456427694), + FRAC_CONST(0.99316428465968509), + FRAC_CONST(0.99335394575541669), + FRAC_CONST(0.99354094734369169), + FRAC_CONST(0.99372528892385081), + FRAC_CONST(0.99390697000235606), + FRAC_CONST(0.99408599009279242), + FRAC_CONST(0.99426234871586938), + FRAC_CONST(0.99443604539942176), + FRAC_CONST(0.99460707967841133), + FRAC_CONST(0.99477545109492771), + FRAC_CONST(0.99494115919819004), + FRAC_CONST(0.99510420354454787), + FRAC_CONST(0.99526458369748239), + FRAC_CONST(0.99542229922760772), + FRAC_CONST(0.99557734971267187), + FRAC_CONST(0.9957297347375581), + FRAC_CONST(0.99587945389428578), + FRAC_CONST(0.99602650678201154), + FRAC_CONST(0.99617089300703077), + FRAC_CONST(0.996312612182778), + FRAC_CONST(0.99645166392982831), + FRAC_CONST(0.99658804787589839), + FRAC_CONST(0.99672176365584741), + FRAC_CONST(0.99685281091167788), + FRAC_CONST(0.99698118929253687), + FRAC_CONST(0.99710689845471678), + FRAC_CONST(0.99722993806165661), + FRAC_CONST(0.99735030778394196), + FRAC_CONST(0.99746800729930707), + FRAC_CONST(0.99758303629263489), + FRAC_CONST(0.99769539445595812), + FRAC_CONST(0.99780508148846014), + FRAC_CONST(0.99791209709647588), + FRAC_CONST(0.99801644099349218), + FRAC_CONST(0.99811811290014918), + FRAC_CONST(0.9982171125442405), + FRAC_CONST(0.9983134396607144), + FRAC_CONST(0.99840709399167404), + FRAC_CONST(0.99849807528637868), + FRAC_CONST(0.99858638330124405), + FRAC_CONST(0.99867201779984294), + FRAC_CONST(0.99875497855290607), + FRAC_CONST(0.99883526533832245), + FRAC_CONST(0.99891287794114036), + FRAC_CONST(0.99898781615356746), + FRAC_CONST(0.99906007977497147), + FRAC_CONST(0.99912966861188113), + FRAC_CONST(0.99919658247798593), + FRAC_CONST(0.99926082119413751), + FRAC_CONST(0.99932238458834954), + FRAC_CONST(0.999381272495798), + FRAC_CONST(0.99943748475882255), + FRAC_CONST(0.9994910212269259), + FRAC_CONST(0.99954188175677483), + FRAC_CONST(0.99959006621220048), + FRAC_CONST(0.99963557446419837), + FRAC_CONST(0.99967840639092931), + FRAC_CONST(0.99971856187771946), + FRAC_CONST(0.99975604081706027), + FRAC_CONST(0.99979084310860955), + FRAC_CONST(0.99982296865919107), + FRAC_CONST(0.99985241738279484), + FRAC_CONST(0.99987918920057806), + FRAC_CONST(0.99990328404086426), + FRAC_CONST(0.9999247018391445), + FRAC_CONST(0.99994344253807688), + FRAC_CONST(0.99995950608748674), + FRAC_CONST(0.99997289244436727), + FRAC_CONST(0.99998360157287902), + FRAC_CONST(0.9999916334443506), + FRAC_CONST(0.99999698803727821), + FRAC_CONST(0.99999966533732598) +}; +#endif + +static const real_t sine_short_128[] ICONST_ATTR MEM_ALIGN_ATTR = +{ + FRAC_CONST(0.0061358846491544753), + FRAC_CONST(0.01840672990580482), + FRAC_CONST(0.030674803176636626), + FRAC_CONST(0.04293825693494082), + FRAC_CONST(0.055195244349689934), + FRAC_CONST(0.067443919563664051), + FRAC_CONST(0.079682437971430126), + FRAC_CONST(0.091908956497132724), + FRAC_CONST(0.10412163387205459), + FRAC_CONST(0.11631863091190475), + FRAC_CONST(0.12849811079379317), + FRAC_CONST(0.14065823933284921), + FRAC_CONST(0.15279718525844344), + FRAC_CONST(0.16491312048996989), + FRAC_CONST(0.17700422041214875), + FRAC_CONST(0.18906866414980619), + FRAC_CONST(0.2011046348420919), + FRAC_CONST(0.21311031991609136), + FRAC_CONST(0.22508391135979283), + FRAC_CONST(0.2370236059943672), + FRAC_CONST(0.24892760574572015), + FRAC_CONST(0.26079411791527551), + FRAC_CONST(0.27262135544994898), + FRAC_CONST(0.28440753721127188), + FRAC_CONST(0.29615088824362379), + FRAC_CONST(0.30784964004153487), + FRAC_CONST(0.31950203081601569), + FRAC_CONST(0.33110630575987643), + FRAC_CONST(0.34266071731199438), + FRAC_CONST(0.35416352542049034), + FRAC_CONST(0.36561299780477385), + FRAC_CONST(0.37700741021641826), + FRAC_CONST(0.38834504669882625), + FRAC_CONST(0.39962419984564679), + FRAC_CONST(0.41084317105790391), + FRAC_CONST(0.42200027079979968), + FRAC_CONST(0.43309381885315196), + FRAC_CONST(0.4441221445704292), + FRAC_CONST(0.45508358712634384), + FRAC_CONST(0.46597649576796618), + FRAC_CONST(0.47679923006332209), + FRAC_CONST(0.487550160148436), + FRAC_CONST(0.49822766697278187), + FRAC_CONST(0.50883014254310699), + FRAC_CONST(0.51935599016558964), + FRAC_CONST(0.52980362468629461), + FRAC_CONST(0.54017147272989285), + FRAC_CONST(0.55045797293660481), + FRAC_CONST(0.56066157619733603), + FRAC_CONST(0.57078074588696726), + FRAC_CONST(0.58081395809576453), + FRAC_CONST(0.59075970185887416), + FRAC_CONST(0.60061647938386897), + FRAC_CONST(0.61038280627630948), + FRAC_CONST(0.6200572117632891), + FRAC_CONST(0.62963823891492698), + FRAC_CONST(0.63912444486377573), + FRAC_CONST(0.64851440102211244), + FRAC_CONST(0.65780669329707864), + FRAC_CONST(0.66699992230363747), + FRAC_CONST(0.67609270357531592), + FRAC_CONST(0.68508366777270036), + FRAC_CONST(0.693971460889654), + FRAC_CONST(0.7027547444572253), + FRAC_CONST(0.71143219574521643), + FRAC_CONST(0.72000250796138165), + FRAC_CONST(0.7284643904482252), + FRAC_CONST(0.73681656887736979), + FRAC_CONST(0.74505778544146595), + FRAC_CONST(0.75318679904361241), + FRAC_CONST(0.76120238548426178), + FRAC_CONST(0.76910333764557959), + FRAC_CONST(0.77688846567323244), + FRAC_CONST(0.78455659715557524), + FRAC_CONST(0.79210657730021239), + FRAC_CONST(0.79953726910790501), + FRAC_CONST(0.80684755354379922), + FRAC_CONST(0.8140363297059483), + FRAC_CONST(0.82110251499110465), + FRAC_CONST(0.8280450452577558), + FRAC_CONST(0.83486287498638001), + FRAC_CONST(0.84155497743689833), + FRAC_CONST(0.84812034480329712), + FRAC_CONST(0.85455798836540053), + FRAC_CONST(0.86086693863776731), + FRAC_CONST(0.86704624551569265), + FRAC_CONST(0.87309497841829009), + FRAC_CONST(0.87901222642863341), + FRAC_CONST(0.88479709843093779), + FRAC_CONST(0.89044872324475788), + FRAC_CONST(0.89596624975618511), + FRAC_CONST(0.90134884704602203), + FRAC_CONST(0.90659570451491533), + FRAC_CONST(0.91170603200542988), + FRAC_CONST(0.9166790599210427), + FRAC_CONST(0.9215140393420419), + FRAC_CONST(0.92621024213831127), + FRAC_CONST(0.93076696107898371), + FRAC_CONST(0.9351835099389475), + FRAC_CONST(0.93945922360218992), + FRAC_CONST(0.94359345816196039), + FRAC_CONST(0.94758559101774109), + FRAC_CONST(0.95143502096900834), + FRAC_CONST(0.95514116830577067), + FRAC_CONST(0.9587034748958716), + FRAC_CONST(0.96212140426904158), + FRAC_CONST(0.9653944416976894), + FRAC_CONST(0.96852209427441727), + FRAC_CONST(0.97150389098625178), + FRAC_CONST(0.97433938278557586), + FRAC_CONST(0.97702814265775439), + FRAC_CONST(0.97956976568544052), + FRAC_CONST(0.98196386910955524), + FRAC_CONST(0.98421009238692903), + FRAC_CONST(0.98630809724459867), + FRAC_CONST(0.98825756773074946), + FRAC_CONST(0.99005821026229712), + FRAC_CONST(0.99170975366909953), + FRAC_CONST(0.9932119492347945), + FRAC_CONST(0.99456457073425542), + FRAC_CONST(0.99576741446765982), + FRAC_CONST(0.99682029929116567), + FRAC_CONST(0.99772306664419164), + FRAC_CONST(0.99847558057329477), + FRAC_CONST(0.99907772775264536), + FRAC_CONST(0.99952941750109314), + FRAC_CONST(0.9998305817958234), + FRAC_CONST(0.99998117528260111) +}; + +#ifdef ALLOW_SMALL_FRAMELENGTH +static const real_t sine_short_120[] MEM_ALIGN_ATTR = +{ + FRAC_CONST(0.0065449379673518581), + FRAC_CONST(0.019633692460628301), + FRAC_CONST(0.032719082821776137), + FRAC_CONST(0.045798866936520771), + FRAC_CONST(0.058870803651189033), + FRAC_CONST(0.071932653156719387), + FRAC_CONST(0.084982177372441667), + FRAC_CONST(0.09801714032956059), + FRAC_CONST(0.11103530855427769), + FRAC_CONST(0.12403445145048532), + FRAC_CONST(0.13701234168196802), + FRAC_CONST(0.14996675555404498), + FRAC_CONST(0.16289547339458874), + FRAC_CONST(0.17579627993435451), + FRAC_CONST(0.18866696468655525), + FRAC_CONST(0.2015053223256171), + FRAC_CONST(0.21430915306505074), + FRAC_CONST(0.2270762630343732), + FRAC_CONST(0.23980446465501654), + FRAC_CONST(0.25249157701515795), + FRAC_CONST(0.26513542624340797), + FRAC_CONST(0.27773384588129219), + FRAC_CONST(0.29028467725446233), + FRAC_CONST(0.3027857698425746), + FRAC_CONST(0.31523498164776964), + FRAC_CONST(0.32763017956169349), + FRAC_CONST(0.33996923973099424), + FRAC_CONST(0.35225004792123354), + FRAC_CONST(0.36447049987914965), + FRAC_CONST(0.37662850169321077), + FRAC_CONST(0.38872197015239557), + FRAC_CONST(0.40074883310314097), + FRAC_CONST(0.41270702980439467), + FRAC_CONST(0.42459451128071307), + FRAC_CONST(0.43640924067334208), + FRAC_CONST(0.44814919358922256), + FRAC_CONST(0.45981235844785984), + FRAC_CONST(0.47139673682599764), + FRAC_CONST(0.48290034380003727), + FRAC_CONST(0.49432120828614462), + FRAC_CONST(0.50565737337798455), + FRAC_CONST(0.51690689668202761), + FRAC_CONST(0.52806785065036799), + FRAC_CONST(0.53913832291100017), + FRAC_CONST(0.55011641659549337), + FRAC_CONST(0.56100025066400983), + FRAC_CONST(0.57178796022761225), + FRAC_CONST(0.58247769686780215), + FRAC_CONST(0.59306762895323706), + FRAC_CONST(0.60355594195357143), + FRAC_CONST(0.61394083875036642), + FRAC_CONST(0.62422053994501758), + FRAC_CONST(0.63439328416364549), + FRAC_CONST(0.64445732835889735), + FRAC_CONST(0.65441094810861034), + FRAC_CONST(0.66425243791128175), + FRAC_CONST(0.67398011147829784), + FRAC_CONST(0.68359230202287125), + FRAC_CONST(0.69308736254563585), + FRAC_CONST(0.70246366611685174), + FRAC_CONST(0.71171960615517138), + FRAC_CONST(0.72085359670291882), + FRAC_CONST(0.7298640726978356), + FRAC_CONST(0.73874949024124625), + FRAC_CONST(0.74750832686259672), + FRAC_CONST(0.75613908178032285), + FRAC_CONST(0.76464027615900032), + FRAC_CONST(0.77301045336273699), + FRAC_CONST(0.78124817920475853), + FRAC_CONST(0.78935204219315003), + FRAC_CONST(0.79732065377270711), + FRAC_CONST(0.80515264856285829), + FRAC_CONST(0.81284668459161513), + FRAC_CONST(0.82040144352551359), + FRAC_CONST(0.82781563089550203), + FRAC_CONST(0.83508797631874299), + FRAC_CONST(0.84221723371628654), + FRAC_CONST(0.84920218152657889), + FRAC_CONST(0.85604162291477137), + FRAC_CONST(0.86273438597779184), + FRAC_CONST(0.86927932394514362), + FRAC_CONST(0.87567531537539967), + FRAC_CONST(0.88192126434835494), + FRAC_CONST(0.88801610065280734), + FRAC_CONST(0.89395877996993212), + FRAC_CONST(0.8997482840522214), + FRAC_CONST(0.90538362089795521), + FRAC_CONST(0.91086382492117568), + FRAC_CONST(0.91618795711713596), + FRAC_CONST(0.92135510522319242), + FRAC_CONST(0.9263643838751181), + FRAC_CONST(0.93121493475880346), + FRAC_CONST(0.93590592675732565), + FRAC_CONST(0.94043655609335486), + FRAC_CONST(0.94480604646687805), + FRAC_CONST(0.94901364918821385), + FRAC_CONST(0.95305864330629697), + FRAC_CONST(0.95694033573220882), + FRAC_CONST(0.9606580613579353), + FRAC_CONST(0.96421118317032928), + FRAC_CONST(0.96759909236025976), + FRAC_CONST(0.9708212084269281), + FRAC_CONST(0.97387697927733363), + FRAC_CONST(0.97676588132087239), + FRAC_CONST(0.97948741955905139), + FRAC_CONST(0.98204112767030394), + FRAC_CONST(0.98442656808989171), + FRAC_CONST(0.98664333208487898), + FRAC_CONST(0.98869103982416728), + FRAC_CONST(0.99056934044357725), + FRAC_CONST(0.99227791210596705), + FRAC_CONST(0.99381646205637808), + FRAC_CONST(0.99518472667219682), + FRAC_CONST(0.99638247150832537), + FRAC_CONST(0.99740949133735191), + FRAC_CONST(0.99826561018471593), + FRAC_CONST(0.99895068135886012), + FRAC_CONST(0.99946458747636568), + FRAC_CONST(0.99980724048206482), + FRAC_CONST(0.99997858166412923) +}; +#endif + +#ifdef LD_DEC +static const real_t sine_mid_512[] MEM_ALIGN_ATTR = +{ + FRAC_CONST(0.0015339801862847655), + FRAC_CONST(0.0046019261204485705), + FRAC_CONST(0.007669828739531097), + FRAC_CONST(0.010737659167264491), + FRAC_CONST(0.013805388528060391), + FRAC_CONST(0.01687298794728171), + FRAC_CONST(0.019940428551514441), + FRAC_CONST(0.023007681468839369), + FRAC_CONST(0.026074717829103901), + FRAC_CONST(0.029141508764193722), + FRAC_CONST(0.032208025408304586), + FRAC_CONST(0.035274238898213947), + FRAC_CONST(0.038340120373552694), + FRAC_CONST(0.041405640977076739), + FRAC_CONST(0.044470771854938668), + FRAC_CONST(0.047535484156959303), + FRAC_CONST(0.050599749036899282), + FRAC_CONST(0.05366353765273052), + FRAC_CONST(0.056726821166907748), + FRAC_CONST(0.059789570746639868), + FRAC_CONST(0.062851757564161406), + FRAC_CONST(0.065913352797003805), + FRAC_CONST(0.068974327628266746), + FRAC_CONST(0.072034653246889332), + FRAC_CONST(0.075094300847921305), + FRAC_CONST(0.078153241632794232), + FRAC_CONST(0.081211446809592441), + FRAC_CONST(0.084268887593324071), + FRAC_CONST(0.087325535206192059), + FRAC_CONST(0.090381360877864983), + FRAC_CONST(0.093436335845747787), + FRAC_CONST(0.096490431355252593), + FRAC_CONST(0.099543618660069319), + FRAC_CONST(0.10259586902243628), + FRAC_CONST(0.10564715371341062), + FRAC_CONST(0.10869744401313872), + FRAC_CONST(0.11174671121112659), + FRAC_CONST(0.11479492660651008), + FRAC_CONST(0.11784206150832498), + FRAC_CONST(0.12088808723577708), + FRAC_CONST(0.12393297511851216), + FRAC_CONST(0.12697669649688587), + FRAC_CONST(0.13001922272223335), + FRAC_CONST(0.13306052515713906), + FRAC_CONST(0.1361005751757062), + FRAC_CONST(0.1391393441638262), + FRAC_CONST(0.14217680351944803), + FRAC_CONST(0.14521292465284746), + FRAC_CONST(0.14824767898689603), + FRAC_CONST(0.15128103795733022), + FRAC_CONST(0.1543129730130201), + FRAC_CONST(0.15734345561623825), + FRAC_CONST(0.16037245724292828), + FRAC_CONST(0.16339994938297323), + FRAC_CONST(0.1664259035404641), + FRAC_CONST(0.16945029123396796), + FRAC_CONST(0.17247308399679595), + FRAC_CONST(0.17549425337727143), + FRAC_CONST(0.17851377093899751), + FRAC_CONST(0.18153160826112497), + FRAC_CONST(0.18454773693861962), + FRAC_CONST(0.1875621285825296), + FRAC_CONST(0.19057475482025274), + FRAC_CONST(0.19358558729580361), + FRAC_CONST(0.19659459767008022), + FRAC_CONST(0.19960175762113097), + FRAC_CONST(0.20260703884442113), + FRAC_CONST(0.20561041305309924), + FRAC_CONST(0.20861185197826349), + FRAC_CONST(0.21161132736922755), + FRAC_CONST(0.21460881099378676), + FRAC_CONST(0.21760427463848364), + FRAC_CONST(0.22059769010887351), + FRAC_CONST(0.22358902922978999), + FRAC_CONST(0.22657826384561), + FRAC_CONST(0.22956536582051887), + FRAC_CONST(0.23255030703877524), + FRAC_CONST(0.23553305940497549), + FRAC_CONST(0.23851359484431842), + FRAC_CONST(0.24149188530286933), + FRAC_CONST(0.24446790274782415), + FRAC_CONST(0.24744161916777327), + FRAC_CONST(0.25041300657296522), + FRAC_CONST(0.25338203699557016), + FRAC_CONST(0.25634868248994291), + FRAC_CONST(0.25931291513288623), + FRAC_CONST(0.26227470702391359), + FRAC_CONST(0.26523403028551179), + FRAC_CONST(0.26819085706340318), + FRAC_CONST(0.27114515952680801), + FRAC_CONST(0.27409690986870638), + FRAC_CONST(0.2770460803060999), + FRAC_CONST(0.27999264308027322), + FRAC_CONST(0.28293657045705539), + FRAC_CONST(0.28587783472708062), + FRAC_CONST(0.28881640820604948), + FRAC_CONST(0.29175226323498926), + FRAC_CONST(0.29468537218051433), + FRAC_CONST(0.2976157074350862), + FRAC_CONST(0.30054324141727345), + FRAC_CONST(0.30346794657201132), + FRAC_CONST(0.30638979537086092), + FRAC_CONST(0.30930876031226873), + FRAC_CONST(0.31222481392182488), + FRAC_CONST(0.31513792875252244), + FRAC_CONST(0.31804807738501495), + FRAC_CONST(0.32095523242787521), + FRAC_CONST(0.32385936651785285), + FRAC_CONST(0.32676045232013173), + FRAC_CONST(0.32965846252858749), + FRAC_CONST(0.33255336986604422), + FRAC_CONST(0.3354451470845316), + FRAC_CONST(0.33833376696554113), + FRAC_CONST(0.34121920232028236), + FRAC_CONST(0.34410142598993881), + FRAC_CONST(0.34698041084592368), + FRAC_CONST(0.34985612979013492), + FRAC_CONST(0.35272855575521073), + FRAC_CONST(0.35559766170478385), + FRAC_CONST(0.35846342063373654), + FRAC_CONST(0.36132580556845428), + FRAC_CONST(0.36418478956707989), + FRAC_CONST(0.36704034571976718), + FRAC_CONST(0.3698924471489341), + FRAC_CONST(0.37274106700951576), + FRAC_CONST(0.37558617848921722), + FRAC_CONST(0.37842775480876556), + FRAC_CONST(0.38126576922216238), + FRAC_CONST(0.38410019501693504), + FRAC_CONST(0.38693100551438858), + FRAC_CONST(0.38975817406985641), + FRAC_CONST(0.39258167407295147), + FRAC_CONST(0.39540147894781635), + FRAC_CONST(0.39821756215337356), + FRAC_CONST(0.40102989718357562), + FRAC_CONST(0.40383845756765407), + FRAC_CONST(0.40664321687036903), + FRAC_CONST(0.40944414869225759), + FRAC_CONST(0.41224122666988289), + FRAC_CONST(0.41503442447608163), + FRAC_CONST(0.41782371582021227), + FRAC_CONST(0.42060907444840251), + FRAC_CONST(0.42339047414379605), + FRAC_CONST(0.42616788872679962), + FRAC_CONST(0.42894129205532949), + FRAC_CONST(0.43171065802505726), + FRAC_CONST(0.43447596056965565), + FRAC_CONST(0.43723717366104409), + FRAC_CONST(0.43999427130963326), + FRAC_CONST(0.44274722756457002), + FRAC_CONST(0.44549601651398174), + FRAC_CONST(0.44824061228521989), + FRAC_CONST(0.45098098904510386), + FRAC_CONST(0.45371712100016387), + FRAC_CONST(0.45644898239688392), + FRAC_CONST(0.45917654752194409), + FRAC_CONST(0.46189979070246273), + FRAC_CONST(0.46461868630623782), + FRAC_CONST(0.46733320874198842), + FRAC_CONST(0.47004333245959562), + FRAC_CONST(0.47274903195034279), + FRAC_CONST(0.47545028174715587), + FRAC_CONST(0.47814705642484301), + FRAC_CONST(0.48083933060033396), + FRAC_CONST(0.48352707893291874), + FRAC_CONST(0.48621027612448642), + FRAC_CONST(0.48888889691976317), + FRAC_CONST(0.4915629161065499), + FRAC_CONST(0.49423230851595967), + FRAC_CONST(0.49689704902265447), + FRAC_CONST(0.49955711254508184), + FRAC_CONST(0.50221247404571079), + FRAC_CONST(0.50486310853126759), + FRAC_CONST(0.50750899105297087), + FRAC_CONST(0.51015009670676681), + FRAC_CONST(0.51278640063356296), + FRAC_CONST(0.51541787801946293), + FRAC_CONST(0.51804450409599934), + FRAC_CONST(0.52066625414036716), + FRAC_CONST(0.52328310347565643), + FRAC_CONST(0.52589502747108463), + FRAC_CONST(0.52850200154222848), + FRAC_CONST(0.531104001151255), + FRAC_CONST(0.53370100180715296), + FRAC_CONST(0.53629297906596318), + FRAC_CONST(0.53887990853100842), + FRAC_CONST(0.54146176585312344), + FRAC_CONST(0.54403852673088382), + FRAC_CONST(0.54661016691083486), + FRAC_CONST(0.54917666218771966), + FRAC_CONST(0.55173798840470734), + FRAC_CONST(0.55429412145362), + FRAC_CONST(0.5568450372751601), + FRAC_CONST(0.55939071185913614), + FRAC_CONST(0.56193112124468947), + FRAC_CONST(0.5644662415205195), + FRAC_CONST(0.56699604882510868), + FRAC_CONST(0.56952051934694714), + FRAC_CONST(0.57203962932475705), + FRAC_CONST(0.57455335504771576), + FRAC_CONST(0.57706167285567944), + FRAC_CONST(0.57956455913940563), + FRAC_CONST(0.58206199034077544), + FRAC_CONST(0.58455394295301533), + FRAC_CONST(0.58704039352091797), + FRAC_CONST(0.58952131864106394), + FRAC_CONST(0.59199669496204099), + FRAC_CONST(0.59446649918466443), + FRAC_CONST(0.5969307080621965), + FRAC_CONST(0.59938929840056454), + FRAC_CONST(0.60184224705858003), + FRAC_CONST(0.60428953094815596), + FRAC_CONST(0.60673112703452448), + FRAC_CONST(0.60916701233645321), + FRAC_CONST(0.61159716392646191), + FRAC_CONST(0.61402155893103838), + FRAC_CONST(0.61644017453085365), + FRAC_CONST(0.61885298796097632), + FRAC_CONST(0.62125997651108755), + FRAC_CONST(0.62366111752569453), + FRAC_CONST(0.62605638840434352), + FRAC_CONST(0.62844576660183271), + FRAC_CONST(0.63082922962842447), + FRAC_CONST(0.63320675505005719), + FRAC_CONST(0.63557832048855611), + FRAC_CONST(0.63794390362184406), + FRAC_CONST(0.64030348218415167), + FRAC_CONST(0.64265703396622686), + FRAC_CONST(0.64500453681554393), + FRAC_CONST(0.64734596863651206), + FRAC_CONST(0.64968130739068319), + FRAC_CONST(0.6520105310969595), + FRAC_CONST(0.65433361783180044), + FRAC_CONST(0.65665054572942894), + FRAC_CONST(0.65896129298203732), + FRAC_CONST(0.66126583783999227), + FRAC_CONST(0.66356415861203977), + FRAC_CONST(0.66585623366550972), + FRAC_CONST(0.66814204142651845), + FRAC_CONST(0.67042156038017309), + FRAC_CONST(0.67269476907077286), + FRAC_CONST(0.67496164610201193), + FRAC_CONST(0.67722217013718033), + FRAC_CONST(0.67947631989936497), + FRAC_CONST(0.68172407417164971), + FRAC_CONST(0.6839654117973154), + FRAC_CONST(0.68620031168003859), + FRAC_CONST(0.68842875278409044), + FRAC_CONST(0.6906507141345346), + FRAC_CONST(0.69286617481742463), + FRAC_CONST(0.69507511398000088), + FRAC_CONST(0.69727751083088652), + FRAC_CONST(0.69947334464028377), + FRAC_CONST(0.70166259474016845), + FRAC_CONST(0.70384524052448494), + FRAC_CONST(0.70602126144933974), + FRAC_CONST(0.70819063703319529), + FRAC_CONST(0.71035334685706231), + FRAC_CONST(0.71250937056469232), + FRAC_CONST(0.71465868786276898), + FRAC_CONST(0.71680127852109954), + FRAC_CONST(0.71893712237280438), + FRAC_CONST(0.72106619931450811), + FRAC_CONST(0.72318848930652735), + FRAC_CONST(0.72530397237306066), + FRAC_CONST(0.72741262860237577), + FRAC_CONST(0.7295144381469969), + FRAC_CONST(0.73160938122389252), + FRAC_CONST(0.73369743811466026), + FRAC_CONST(0.73577858916571348), + FRAC_CONST(0.73785281478846598), + FRAC_CONST(0.73992009545951609), + FRAC_CONST(0.74198041172083096), + FRAC_CONST(0.74403374417992918), + FRAC_CONST(0.74608007351006378), + FRAC_CONST(0.74811938045040349), + FRAC_CONST(0.75015164580621496), + FRAC_CONST(0.7521768504490427), + FRAC_CONST(0.75419497531688917), + FRAC_CONST(0.75620600141439454), + FRAC_CONST(0.75820990981301528), + FRAC_CONST(0.76020668165120242), + FRAC_CONST(0.7621962981345789), + FRAC_CONST(0.76417874053611667), + FRAC_CONST(0.76615399019631281), + FRAC_CONST(0.76812202852336531), + FRAC_CONST(0.7700828369933479), + FRAC_CONST(0.77203639715038441), + FRAC_CONST(0.77398269060682279), + FRAC_CONST(0.77592169904340758), + FRAC_CONST(0.77785340420945304), + FRAC_CONST(0.77977778792301444), + FRAC_CONST(0.78169483207105939), + FRAC_CONST(0.7836045186096382), + FRAC_CONST(0.78550682956405393), + FRAC_CONST(0.78740174702903132), + FRAC_CONST(0.78928925316888565), + FRAC_CONST(0.79116933021769009), + FRAC_CONST(0.79304196047944364), + FRAC_CONST(0.79490712632823701), + FRAC_CONST(0.79676481020841872), + FRAC_CONST(0.79861499463476082), + FRAC_CONST(0.80045766219262271), + FRAC_CONST(0.80229279553811572), + FRAC_CONST(0.8041203773982657), + FRAC_CONST(0.80594039057117628), + FRAC_CONST(0.80775281792619036), + FRAC_CONST(0.80955764240405126), + FRAC_CONST(0.81135484701706373), + FRAC_CONST(0.81314441484925359), + FRAC_CONST(0.81492632905652662), + FRAC_CONST(0.81670057286682785), + FRAC_CONST(0.81846712958029866), + FRAC_CONST(0.82022598256943469), + FRAC_CONST(0.82197711527924155), + FRAC_CONST(0.82372051122739132), + FRAC_CONST(0.82545615400437744), + FRAC_CONST(0.82718402727366902), + FRAC_CONST(0.82890411477186487), + FRAC_CONST(0.8306164003088462), + FRAC_CONST(0.83232086776792968), + FRAC_CONST(0.83401750110601813), + FRAC_CONST(0.8357062843537526), + FRAC_CONST(0.83738720161566194), + FRAC_CONST(0.83906023707031263), + FRAC_CONST(0.84072537497045807), + FRAC_CONST(0.84238259964318596), + FRAC_CONST(0.84403189549006641), + FRAC_CONST(0.84567324698729907), + FRAC_CONST(0.84730663868585832), + FRAC_CONST(0.84893205521163961), + FRAC_CONST(0.85054948126560337), + FRAC_CONST(0.85215890162391983), + FRAC_CONST(0.8537603011381113), + FRAC_CONST(0.85535366473519603), + FRAC_CONST(0.85693897741782865), + FRAC_CONST(0.85851622426444274), + FRAC_CONST(0.86008539042939014), + FRAC_CONST(0.8616464611430813), + FRAC_CONST(0.86319942171212416), + FRAC_CONST(0.86474425751946238), + FRAC_CONST(0.86628095402451299), + FRAC_CONST(0.86780949676330321), + FRAC_CONST(0.86932987134860673), + FRAC_CONST(0.87084206347007886), + FRAC_CONST(0.87234605889439154), + FRAC_CONST(0.87384184346536675), + FRAC_CONST(0.87532940310411078), + FRAC_CONST(0.87680872380914576), + FRAC_CONST(0.87827979165654146), + FRAC_CONST(0.87974259280004741), + FRAC_CONST(0.88119711347122198), + FRAC_CONST(0.88264333997956279), + FRAC_CONST(0.88408125871263499), + FRAC_CONST(0.88551085613619995), + FRAC_CONST(0.88693211879434208), + FRAC_CONST(0.88834503330959624), + FRAC_CONST(0.88974958638307289), + FRAC_CONST(0.89114576479458318), + FRAC_CONST(0.89253355540276469), + FRAC_CONST(0.89391294514520325), + FRAC_CONST(0.89528392103855758), + FRAC_CONST(0.89664647017868015), + FRAC_CONST(0.89800057974073988), + FRAC_CONST(0.89934623697934146), + FRAC_CONST(0.90068342922864686), + FRAC_CONST(0.90201214390249307), + FRAC_CONST(0.90333236849451182), + FRAC_CONST(0.90464409057824624), + FRAC_CONST(0.90594729780726846), + FRAC_CONST(0.90724197791529593), + FRAC_CONST(0.90852811871630612), + FRAC_CONST(0.90980570810465222), + FRAC_CONST(0.91107473405517625), + FRAC_CONST(0.91233518462332275), + FRAC_CONST(0.91358704794525081), + FRAC_CONST(0.91483031223794609), + FRAC_CONST(0.91606496579933161), + FRAC_CONST(0.91729099700837791), + FRAC_CONST(0.91850839432521225), + FRAC_CONST(0.91971714629122736), + FRAC_CONST(0.92091724152918952), + FRAC_CONST(0.92210866874334507), + FRAC_CONST(0.92329141671952764), + FRAC_CONST(0.9244654743252626), + FRAC_CONST(0.92563083050987272), + FRAC_CONST(0.92678747430458175), + FRAC_CONST(0.92793539482261789), + FRAC_CONST(0.92907458125931575), + FRAC_CONST(0.93020502289221907), + FRAC_CONST(0.93132670908118043), + FRAC_CONST(0.93243962926846236), + FRAC_CONST(0.93354377297883617), + FRAC_CONST(0.93463912981968078), + FRAC_CONST(0.93572568948108037), + FRAC_CONST(0.93680344173592156), + FRAC_CONST(0.93787237643998989), + FRAC_CONST(0.93893248353206449), + FRAC_CONST(0.93998375303401394), + FRAC_CONST(0.94102617505088926), + FRAC_CONST(0.94205973977101731), + FRAC_CONST(0.94308443746609349), + FRAC_CONST(0.94410025849127266), + FRAC_CONST(0.94510719328526061), + FRAC_CONST(0.94610523237040334), + FRAC_CONST(0.94709436635277722), + FRAC_CONST(0.94807458592227623), + FRAC_CONST(0.94904588185270056), + FRAC_CONST(0.950008245001843), + FRAC_CONST(0.95096166631157508), + FRAC_CONST(0.95190613680793223), + FRAC_CONST(0.95284164760119872), + FRAC_CONST(0.95376818988599033), + FRAC_CONST(0.95468575494133834), + FRAC_CONST(0.95559433413077111), + FRAC_CONST(0.95649391890239499), + FRAC_CONST(0.95738450078897586), + FRAC_CONST(0.95826607140801767), + FRAC_CONST(0.95913862246184189), + FRAC_CONST(0.96000214573766585), + FRAC_CONST(0.96085663310767966), + FRAC_CONST(0.96170207652912254), + FRAC_CONST(0.96253846804435916), + FRAC_CONST(0.96336579978095405), + FRAC_CONST(0.96418406395174572), + FRAC_CONST(0.96499325285492032), + FRAC_CONST(0.96579335887408357), + FRAC_CONST(0.96658437447833312), + FRAC_CONST(0.96736629222232851), + FRAC_CONST(0.96813910474636233), + FRAC_CONST(0.96890280477642887), + FRAC_CONST(0.96965738512429245), + FRAC_CONST(0.9704028386875555), + FRAC_CONST(0.97113915844972509), + FRAC_CONST(0.9718663374802794), + FRAC_CONST(0.97258436893473221), + FRAC_CONST(0.97329324605469825), + FRAC_CONST(0.97399296216795583), + FRAC_CONST(0.97468351068851067), + FRAC_CONST(0.97536488511665687), + FRAC_CONST(0.97603707903903902), + FRAC_CONST(0.97670008612871184), + FRAC_CONST(0.97735390014519996), + FRAC_CONST(0.97799851493455714), + FRAC_CONST(0.9786339244294231), + FRAC_CONST(0.97926012264908202), + FRAC_CONST(0.97987710369951764), + FRAC_CONST(0.98048486177346938), + FRAC_CONST(0.98108339115048659), + FRAC_CONST(0.98167268619698311), + FRAC_CONST(0.98225274136628937), + FRAC_CONST(0.98282355119870524), + FRAC_CONST(0.98338511032155118), + FRAC_CONST(0.98393741344921892), + FRAC_CONST(0.98448045538322093), + FRAC_CONST(0.98501423101223984), + FRAC_CONST(0.98553873531217606), + FRAC_CONST(0.98605396334619544), + FRAC_CONST(0.98655991026477541), + FRAC_CONST(0.98705657130575097), + FRAC_CONST(0.98754394179435923), + FRAC_CONST(0.98802201714328353), + FRAC_CONST(0.98849079285269659), + FRAC_CONST(0.98895026451030299), + FRAC_CONST(0.98940042779138038), + FRAC_CONST(0.98984127845882053), + FRAC_CONST(0.99027281236316911), + FRAC_CONST(0.99069502544266463), + FRAC_CONST(0.99110791372327678), + FRAC_CONST(0.9915114733187439), + FRAC_CONST(0.99190570043060933), + FRAC_CONST(0.99229059134825737), + FRAC_CONST(0.99266614244894802), + FRAC_CONST(0.99303235019785141), + FRAC_CONST(0.99338921114808065), + FRAC_CONST(0.9937367219407246), + FRAC_CONST(0.99407487930487937), + FRAC_CONST(0.9944036800576791), + FRAC_CONST(0.9947231211043257), + FRAC_CONST(0.99503319943811863), + FRAC_CONST(0.99533391214048228), + FRAC_CONST(0.99562525638099431), + FRAC_CONST(0.99590722941741172), + FRAC_CONST(0.99617982859569687), + FRAC_CONST(0.99644305135004263), + FRAC_CONST(0.99669689520289606), + FRAC_CONST(0.99694135776498216), + FRAC_CONST(0.99717643673532619), + FRAC_CONST(0.9974021299012753), + FRAC_CONST(0.99761843513851955), + FRAC_CONST(0.99782535041111164), + FRAC_CONST(0.99802287377148624), + FRAC_CONST(0.99821100336047819), + FRAC_CONST(0.99838973740734016), + FRAC_CONST(0.99855907422975931), + FRAC_CONST(0.99871901223387294), + FRAC_CONST(0.99886954991428356), + FRAC_CONST(0.99901068585407338), + FRAC_CONST(0.99914241872481691), + FRAC_CONST(0.99926474728659442), + FRAC_CONST(0.99937767038800285), + FRAC_CONST(0.99948118696616695), + FRAC_CONST(0.99957529604674922), + FRAC_CONST(0.99965999674395922), + FRAC_CONST(0.99973528826056168), + FRAC_CONST(0.99980116988788426), + FRAC_CONST(0.99985764100582386), + FRAC_CONST(0.9999047010828529), + FRAC_CONST(0.99994234967602391), + FRAC_CONST(0.99997058643097414), + FRAC_CONST(0.9999894110819284), + FRAC_CONST(0.99999882345170188) +}; + +#ifdef ALLOW_SMALL_FRAMELENGTH +static const real_t sine_mid_480[] MEM_ALIGN_ATTR = +{ + FRAC_CONST(0.0016362454436240478), + FRAC_CONST(0.00490871880799799), + FRAC_CONST(0.0081811396039371282), + FRAC_CONST(0.011453472786443779), + FRAC_CONST(0.014725683311458524), + FRAC_CONST(0.017997736136235509), + FRAC_CONST(0.021269596219717739), + FRAC_CONST(0.024541228522912285), + FRAC_CONST(0.027812598009265607), + FRAC_CONST(0.03108366964503869), + FRAC_CONST(0.034354408399682276), + FRAC_CONST(0.037624779246211978), + FRAC_CONST(0.04089474716158345), + FRAC_CONST(0.044164277127067358), + FRAC_CONST(0.047433334128624507), + FRAC_CONST(0.050701883157280733), + FRAC_CONST(0.053969889209501881), + FRAC_CONST(0.057237317287568618), + FRAC_CONST(0.060504132399951269), + FRAC_CONST(0.063770299561684493), + FRAC_CONST(0.06703578379474201), + FRAC_CONST(0.070300550128411174), + FRAC_CONST(0.073564563599667426), + FRAC_CONST(0.076827789253548759), + FRAC_CONST(0.080090192143530081), + FRAC_CONST(0.083351737331897449), + FRAC_CONST(0.086612389890122182), + FRAC_CONST(0.089872114899234967), + FRAC_CONST(0.093130877450199795), + FRAC_CONST(0.096388642644287828), + FRAC_CONST(0.09964537559345106), + FRAC_CONST(0.1029010414206961), + FRAC_CONST(0.10615560526045748), + FRAC_CONST(0.10940903225897117), + FRAC_CONST(0.11266128757464781), + FRAC_CONST(0.11591233637844581), + FRAC_CONST(0.11916214385424433), + FRAC_CONST(0.1224106751992162), + FRAC_CONST(0.12565789562420052), + FRAC_CONST(0.12890377035407541), + FRAC_CONST(0.13214826462813015), + FRAC_CONST(0.13539134370043773), + FRAC_CONST(0.13863297284022669), + FRAC_CONST(0.14187311733225325), + FRAC_CONST(0.14511174247717309), + FRAC_CONST(0.14834881359191271), + FRAC_CONST(0.15158429601004111), + FRAC_CONST(0.15481815508214106), + FRAC_CONST(0.1580503561761798), + FRAC_CONST(0.16128086467788047), + FRAC_CONST(0.16450964599109233), + FRAC_CONST(0.16773666553816149), + FRAC_CONST(0.17096188876030122), + FRAC_CONST(0.17418528111796186), + FRAC_CONST(0.17740680809120093), + FRAC_CONST(0.18062643518005275), + FRAC_CONST(0.18384412790489776), + FRAC_CONST(0.18705985180683199), + FRAC_CONST(0.19027357244803589), + FRAC_CONST(0.19348525541214331), + FRAC_CONST(0.19669486630460997), + FRAC_CONST(0.19990237075308173), + FRAC_CONST(0.20310773440776286), + FRAC_CONST(0.20631092294178383), + FRAC_CONST(0.20951190205156878), + FRAC_CONST(0.21271063745720317), + FRAC_CONST(0.21590709490280058), + FRAC_CONST(0.2191012401568698), + FRAC_CONST(0.22229303901268133), + FRAC_CONST(0.22548245728863364), + FRAC_CONST(0.22866946082861941), + FRAC_CONST(0.23185401550239115), + FRAC_CONST(0.23503608720592667), + FRAC_CONST(0.23821564186179459), + FRAC_CONST(0.24139264541951888), + FRAC_CONST(0.24456706385594387), + FRAC_CONST(0.24773886317559846), + FRAC_CONST(0.25090800941106001), + FRAC_CONST(0.25407446862331851), + FRAC_CONST(0.25723820690213967), + FRAC_CONST(0.26039919036642817), + FRAC_CONST(0.26355738516459076), + FRAC_CONST(0.26671275747489837), + FRAC_CONST(0.2698652735058486), + FRAC_CONST(0.27301489949652735), + FRAC_CONST(0.27616160171697068), + FRAC_CONST(0.27930534646852595), + FRAC_CONST(0.28244610008421245), + FRAC_CONST(0.2855838289290823), + FRAC_CONST(0.28871849940058025), + FRAC_CONST(0.29185007792890405), + FRAC_CONST(0.29497853097736348), + FRAC_CONST(0.2981038250427398), + FRAC_CONST(0.30122592665564446), + FRAC_CONST(0.30434480238087736), + FRAC_CONST(0.30746041881778519), + FRAC_CONST(0.31057274260061901), + FRAC_CONST(0.31368174039889146), + FRAC_CONST(0.31678737891773395), + FRAC_CONST(0.31988962489825296), + FRAC_CONST(0.32298844511788638), + FRAC_CONST(0.32608380639075912), + FRAC_CONST(0.32917567556803889), + FRAC_CONST(0.33226401953829071), + FRAC_CONST(0.33534880522783189), + FRAC_CONST(0.33842999960108583), + FRAC_CONST(0.34150756966093632), + FRAC_CONST(0.34458148244908043), + FRAC_CONST(0.34765170504638188), + FRAC_CONST(0.35071820457322322), + FRAC_CONST(0.35378094818985806), + FRAC_CONST(0.35683990309676283), + FRAC_CONST(0.35989503653498811), + FRAC_CONST(0.36294631578650921), + FRAC_CONST(0.36599370817457672), + FRAC_CONST(0.36903718106406647), + FRAC_CONST(0.37207670186182878), + FRAC_CONST(0.37511223801703802), + FRAC_CONST(0.37814375702154046), + FRAC_CONST(0.38117122641020335), + FRAC_CONST(0.38419461376126157), + FRAC_CONST(0.38721388669666562), + FRAC_CONST(0.39022901288242801), + FRAC_CONST(0.39323996002896966), + FRAC_CONST(0.39624669589146555), + FRAC_CONST(0.39924918827019029), + FRAC_CONST(0.40224740501086254), + FRAC_CONST(0.40524131400498986), + FRAC_CONST(0.40823088319021217), + FRAC_CONST(0.41121608055064529), + FRAC_CONST(0.41419687411722372), + FRAC_CONST(0.41717323196804335), + FRAC_CONST(0.42014512222870243), + FRAC_CONST(0.42311251307264408), + FRAC_CONST(0.42607537272149631), + FRAC_CONST(0.4290336694454126), + FRAC_CONST(0.43198737156341183), + FRAC_CONST(0.43493644744371707), + FRAC_CONST(0.43788086550409511), + FRAC_CONST(0.44082059421219388), + FRAC_CONST(0.44375560208588088), + FRAC_CONST(0.44668585769357955), + FRAC_CONST(0.4496113296546066), + FRAC_CONST(0.45253198663950756), + FRAC_CONST(0.45544779737039259), + FRAC_CONST(0.45835873062127125), + FRAC_CONST(0.46126475521838717), + FRAC_CONST(0.46416584004055156), + FRAC_CONST(0.46706195401947659), + FRAC_CONST(0.46995306614010829), + FRAC_CONST(0.47283914544095862), + FRAC_CONST(0.47572016101443682), + FRAC_CONST(0.47859608200718085), + FRAC_CONST(0.4814668776203872), + FRAC_CONST(0.48433251711014125), + FRAC_CONST(0.4871929697877464), + FRAC_CONST(0.49004820502005247), + FRAC_CONST(0.49289819222978404), + FRAC_CONST(0.49574290089586776), + FRAC_CONST(0.49858230055375902), + FRAC_CONST(0.50141636079576901), + FRAC_CONST(0.50424505127138919), + FRAC_CONST(0.50706834168761705), + FRAC_CONST(0.50988620180928057), + FRAC_CONST(0.51269860145936175), + FRAC_CONST(0.51550551051931948), + FRAC_CONST(0.51830689892941317), + FRAC_CONST(0.5211027366890234), + FRAC_CONST(0.52389299385697385), + FRAC_CONST(0.52667764055185196), + FRAC_CONST(0.52945664695232897), + FRAC_CONST(0.53222998329747884), + FRAC_CONST(0.53499761988709726), + FRAC_CONST(0.53775952708201991), + FRAC_CONST(0.54051567530443978), + FRAC_CONST(0.54326603503822357), + FRAC_CONST(0.54601057682922816), + FRAC_CONST(0.54874927128561579), + FRAC_CONST(0.55148208907816942), + FRAC_CONST(0.55420900094060566), + FRAC_CONST(0.55692997766988939), + FRAC_CONST(0.559644990126546), + FRAC_CONST(0.56235400923497314), + FRAC_CONST(0.56505700598375252), + FRAC_CONST(0.56775395142596052), + FRAC_CONST(0.57044481667947822), + FRAC_CONST(0.57312957292730071), + FRAC_CONST(0.57580819141784534), + FRAC_CONST(0.57848064346525996), + FRAC_CONST(0.58114690044973039), + FRAC_CONST(0.58380693381778626), + FRAC_CONST(0.58646071508260733), + FRAC_CONST(0.58910821582432815), + FRAC_CONST(0.5917494076903429), + FRAC_CONST(0.5943842623956086), + FRAC_CONST(0.59701275172294799), + FRAC_CONST(0.59963484752335228), + FRAC_CONST(0.60225052171628191), + FRAC_CONST(0.60485974628996786), + FRAC_CONST(0.60746249330171098), + FRAC_CONST(0.61005873487818185), + FRAC_CONST(0.61264844321571899), + FRAC_CONST(0.61523159058062682), + FRAC_CONST(0.61780814930947225), + FRAC_CONST(0.62037809180938108), + FRAC_CONST(0.62294139055833397), + FRAC_CONST(0.6254980181054608), + FRAC_CONST(0.62804794707133416), + FRAC_CONST(0.63059115014826372), + FRAC_CONST(0.63312760010058777), + FRAC_CONST(0.63565726976496484), + FRAC_CONST(0.63818013205066515), + FRAC_CONST(0.64069615993986073), + FRAC_CONST(0.64320532648791406), + FRAC_CONST(0.64570760482366729), + FRAC_CONST(0.64820296814972966), + FRAC_CONST(0.65069138974276486), + FRAC_CONST(0.65317284295377676), + FRAC_CONST(0.65564730120839498), + FRAC_CONST(0.65811473800715958), + FRAC_CONST(0.660575126925805), + FRAC_CONST(0.66302844161554231), + FRAC_CONST(0.6654746558033422), + FRAC_CONST(0.66791374329221598), + FRAC_CONST(0.67034567796149647), + FRAC_CONST(0.67277043376711676), + FRAC_CONST(0.67518798474189046), + FRAC_CONST(0.67759830499578866), + FRAC_CONST(0.68000136871621808), + FRAC_CONST(0.68239715016829683), + FRAC_CONST(0.6847856236951303), + FRAC_CONST(0.68716676371808583), + FRAC_CONST(0.68954054473706683), + FRAC_CONST(0.69190694133078579), + FRAC_CONST(0.69426592815703603), + FRAC_CONST(0.69661747995296419), + FRAC_CONST(0.69896157153533944), + FRAC_CONST(0.70129817780082437), + FRAC_CONST(0.7036272737262429), + FRAC_CONST(0.70594883436884903), + FRAC_CONST(0.70826283486659336), + FRAC_CONST(0.71056925043838959), + FRAC_CONST(0.71286805638437978), + FRAC_CONST(0.71515922808619936), + FRAC_CONST(0.71744274100723993), + FRAC_CONST(0.71971857069291278), + FRAC_CONST(0.7219866927709101), + FRAC_CONST(0.72424708295146689), + FRAC_CONST(0.72649971702762028), + FRAC_CONST(0.72874457087546896), + FRAC_CONST(0.73098162045443171), + FRAC_CONST(0.73321084180750484), + FRAC_CONST(0.73543221106151868), + FRAC_CONST(0.73764570442739286), + FRAC_CONST(0.73985129820039208), + FRAC_CONST(0.74204896876037885), + FRAC_CONST(0.7442386925720671), + FRAC_CONST(0.74642044618527381), + FRAC_CONST(0.74859420623517081), + FRAC_CONST(0.75075994944253421), + FRAC_CONST(0.75291765261399446), + FRAC_CONST(0.75506729264228367), + FRAC_CONST(0.75720884650648446), + FRAC_CONST(0.75934229127227548), + FRAC_CONST(0.76146760409217706), + FRAC_CONST(0.76358476220579641), + FRAC_CONST(0.7656937429400712), + FRAC_CONST(0.76779452370951196), + FRAC_CONST(0.76988708201644451), + FRAC_CONST(0.77197139545125026), + FRAC_CONST(0.7740474416926072), + FRAC_CONST(0.77611519850772781), + FRAC_CONST(0.77817464375259782), + FRAC_CONST(0.78022575537221317), + FRAC_CONST(0.78226851140081632), + FRAC_CONST(0.78430288996213138), + FRAC_CONST(0.78632886926959822), + FRAC_CONST(0.78834642762660623), + FRAC_CONST(0.79035554342672631), + FRAC_CONST(0.79235619515394229), + FRAC_CONST(0.79434836138288134), + FRAC_CONST(0.79633202077904397), + FRAC_CONST(0.79830715209903147), + FRAC_CONST(0.8002737341907743), + FRAC_CONST(0.80223174599375802), + FRAC_CONST(0.80418116653924954), + FRAC_CONST(0.80612197495052085), + FRAC_CONST(0.80805415044307316), + FRAC_CONST(0.80997767232485907), + FRAC_CONST(0.81189251999650469), + FRAC_CONST(0.81379867295152986), + FRAC_CONST(0.81569611077656778), + FRAC_CONST(0.81758481315158371), + FRAC_CONST(0.81946475985009259), + FRAC_CONST(0.82133593073937561), + FRAC_CONST(0.82319830578069586), + FRAC_CONST(0.82505186502951278), + FRAC_CONST(0.82689658863569615), + FRAC_CONST(0.82873245684373809), + FRAC_CONST(0.83055944999296494), + FRAC_CONST(0.83237754851774781), + FRAC_CONST(0.83418673294771239), + FRAC_CONST(0.83598698390794668), + FRAC_CONST(0.83777828211920935), + FRAC_CONST(0.83956060839813562), + FRAC_CONST(0.84133394365744296), + FRAC_CONST(0.84309826890613537), + FRAC_CONST(0.84485356524970701), + FRAC_CONST(0.84659981389034411), + FRAC_CONST(0.84833699612712676), + FRAC_CONST(0.85006509335622882), + FRAC_CONST(0.8517840870711173), + FRAC_CONST(0.85349395886275037), + FRAC_CONST(0.85519469041977514), + FRAC_CONST(0.85688626352872277), + FRAC_CONST(0.85856866007420429), + FRAC_CONST(0.86024186203910447), + FRAC_CONST(0.86190585150477417), + FRAC_CONST(0.86356061065122347), + FRAC_CONST(0.86520612175731115), + FRAC_CONST(0.86684236720093533), + FRAC_CONST(0.86846932945922151), + FRAC_CONST(0.87008699110871135), + FRAC_CONST(0.87169533482554817), + FRAC_CONST(0.87329434338566281), + FRAC_CONST(0.87488399966495822), + FRAC_CONST(0.87646428663949283), + FRAC_CONST(0.87803518738566277), + FRAC_CONST(0.87959668508038291), + FRAC_CONST(0.88114876300126743), + FRAC_CONST(0.88269140452680916), + FRAC_CONST(0.8842245931365561), + FRAC_CONST(0.88574831241129048), + FRAC_CONST(0.88726254603320276), + FRAC_CONST(0.88876727778606746), + FRAC_CONST(0.89026249155541637), + FRAC_CONST(0.8917481713287112), + FRAC_CONST(0.89322430119551532), + FRAC_CONST(0.89469086534766362), + FRAC_CONST(0.89614784807943237), + FRAC_CONST(0.89759523378770689), + FRAC_CONST(0.89903300697214927), + FRAC_CONST(0.9004611522353636), + FRAC_CONST(0.90187965428306172), + FRAC_CONST(0.90328849792422594), + FRAC_CONST(0.90468766807127299), + FRAC_CONST(0.90607714974021469), + FRAC_CONST(0.90745692805081868), + FRAC_CONST(0.90882698822676755), + FRAC_CONST(0.91018731559581767), + FRAC_CONST(0.91153789558995579), + FRAC_CONST(0.91287871374555518), + FRAC_CONST(0.91420975570353069), + FRAC_CONST(0.9155310072094921), + FRAC_CONST(0.91684245411389753), + FRAC_CONST(0.91814408237220391), + FRAC_CONST(0.91943587804501858), + FRAC_CONST(0.92071782729824769), + FRAC_CONST(0.92198991640324446), + FRAC_CONST(0.92325213173695675), + FRAC_CONST(0.92450445978207241), + FRAC_CONST(0.92574688712716402), + FRAC_CONST(0.92697940046683291), + FRAC_CONST(0.92820198660185149), + FRAC_CONST(0.92941463243930444), + FRAC_CONST(0.93061732499272909), + FRAC_CONST(0.93181005138225426), + FRAC_CONST(0.93299279883473885), + FRAC_CONST(0.93416555468390772), + FRAC_CONST(0.93532830637048769), + FRAC_CONST(0.93648104144234268), + FRAC_CONST(0.93762374755460598), + FRAC_CONST(0.93875641246981323), + FRAC_CONST(0.93987902405803303), + FRAC_CONST(0.94099157029699743), + FRAC_CONST(0.94209403927222979), + FRAC_CONST(0.94318641917717327), + FRAC_CONST(0.9442686983133165), + FRAC_CONST(0.94534086509031956), + FRAC_CONST(0.9464029080261378), + FRAC_CONST(0.94745481574714419), + FRAC_CONST(0.94849657698825252), + FRAC_CONST(0.94952818059303667), + FRAC_CONST(0.95054961551385087), + FRAC_CONST(0.95156087081194762), + FRAC_CONST(0.95256193565759528), + FRAC_CONST(0.95355279933019343), + FRAC_CONST(0.9545334512183884), + FRAC_CONST(0.95550388082018611), + FRAC_CONST(0.95646407774306541), + FRAC_CONST(0.95741403170408834), + FRAC_CONST(0.95835373253001133), + FRAC_CONST(0.95928317015739362), + FRAC_CONST(0.96020233463270466), + FRAC_CONST(0.96111121611243155), + FRAC_CONST(0.96200980486318388), + FRAC_CONST(0.96289809126179782), + FRAC_CONST(0.96377606579543984), + FRAC_CONST(0.96464371906170809), + FRAC_CONST(0.96550104176873297), + FRAC_CONST(0.96634802473527726), + FRAC_CONST(0.96718465889083372), + FRAC_CONST(0.96801093527572268), + FRAC_CONST(0.96882684504118799), + FRAC_CONST(0.96963237944949143), + FRAC_CONST(0.97042752987400682), + FRAC_CONST(0.97121228779931179), + FRAC_CONST(0.97198664482127939), + FRAC_CONST(0.97275059264716823), + FRAC_CONST(0.97350412309571066), + FRAC_CONST(0.97424722809720088), + FRAC_CONST(0.97497989969358168), + FRAC_CONST(0.97570213003852857), + FRAC_CONST(0.97641391139753486), + FRAC_CONST(0.97711523614799412), + FRAC_CONST(0.97780609677928154), + FRAC_CONST(0.97848648589283505), + FRAC_CONST(0.97915639620223371), + FRAC_CONST(0.9798158205332762), + FRAC_CONST(0.98046475182405801), + FRAC_CONST(0.98110318312504607), + FRAC_CONST(0.98173110759915416), + FRAC_CONST(0.98234851852181571), + FRAC_CONST(0.98295540928105563), + FRAC_CONST(0.9835517733775615), + FRAC_CONST(0.98413760442475307), + FRAC_CONST(0.98471289614885038), + FRAC_CONST(0.98527764238894122), + FRAC_CONST(0.98583183709704714), + FRAC_CONST(0.98637547433818806), + FRAC_CONST(0.98690854829044583), + FRAC_CONST(0.98743105324502667), + FRAC_CONST(0.98794298360632238), + FRAC_CONST(0.98844433389196995), + FRAC_CONST(0.98893509873291074), + FRAC_CONST(0.98941527287344755), + FRAC_CONST(0.98988485117130098), + FRAC_CONST(0.99034382859766479), + FRAC_CONST(0.99079220023725967), + FRAC_CONST(0.99122996128838525), + FRAC_CONST(0.9916571070629725), + FRAC_CONST(0.99207363298663342), + FRAC_CONST(0.99247953459870997), + FRAC_CONST(0.99287480755232194), + FRAC_CONST(0.99325944761441354), + FRAC_CONST(0.99363345066579889), + FRAC_CONST(0.99399681270120555), + FRAC_CONST(0.99434952982931812), + FRAC_CONST(0.9946915982728195), + FRAC_CONST(0.99502301436843166), + FRAC_CONST(0.99534377456695422), + FRAC_CONST(0.9956538754333033), + FRAC_CONST(0.99595331364654771), + FRAC_CONST(0.99624208599994479), + FRAC_CONST(0.99652018940097464), + FRAC_CONST(0.99678762087137318), + FRAC_CONST(0.99704437754716424), + FRAC_CONST(0.99729045667869021), + FRAC_CONST(0.99752585563064111), + FRAC_CONST(0.99775057188208349), + FRAC_CONST(0.9979646030264866), + FRAC_CONST(0.99816794677174903), + FRAC_CONST(0.9983606009402225), + FRAC_CONST(0.99854256346873571), + FRAC_CONST(0.99871383240861611), + FRAC_CONST(0.99887440592571108), + FRAC_CONST(0.99902428230040718), + FRAC_CONST(0.99916345992764877), + FRAC_CONST(0.99929193731695531), + FRAC_CONST(0.99940971309243731), + FRAC_CONST(0.99951678599281069), + FRAC_CONST(0.99961315487141078), + FRAC_CONST(0.99969881869620425), + FRAC_CONST(0.99977377654980037), + FRAC_CONST(0.99983802762946083), + FRAC_CONST(0.99989157124710804), + FRAC_CONST(0.9999344068293331), + FRAC_CONST(0.99996653391740109), + FRAC_CONST(0.99998795216725689), + FRAC_CONST(0.99999866134952808) +}; +#endif + +static const real_t ld_mid_512[] MEM_ALIGN_ATTR = +{ + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0.0061358846491544753), + FRAC_CONST(0.01840672990580482), + FRAC_CONST(0.030674803176636626), + FRAC_CONST(0.04293825693494082), + FRAC_CONST(0.055195244349689934), + FRAC_CONST(0.067443919563664051), + FRAC_CONST(0.079682437971430126), + FRAC_CONST(0.091908956497132724), + FRAC_CONST(0.10412163387205459), + FRAC_CONST(0.11631863091190475), + FRAC_CONST(0.12849811079379317), + FRAC_CONST(0.14065823933284921), + FRAC_CONST(0.15279718525844344), + FRAC_CONST(0.16491312048996989), + FRAC_CONST(0.17700422041214875), + FRAC_CONST(0.18906866414980619), + FRAC_CONST(0.2011046348420919), + FRAC_CONST(0.21311031991609136), + FRAC_CONST(0.22508391135979283), + FRAC_CONST(0.2370236059943672), + FRAC_CONST(0.24892760574572015), + FRAC_CONST(0.26079411791527551), + FRAC_CONST(0.27262135544994898), + FRAC_CONST(0.28440753721127188), + FRAC_CONST(0.29615088824362379), + FRAC_CONST(0.30784964004153487), + FRAC_CONST(0.31950203081601569), + FRAC_CONST(0.33110630575987643), + FRAC_CONST(0.34266071731199438), + FRAC_CONST(0.35416352542049034), + FRAC_CONST(0.36561299780477385), + FRAC_CONST(0.37700741021641826), + FRAC_CONST(0.38834504669882625), + FRAC_CONST(0.39962419984564679), + FRAC_CONST(0.41084317105790391), + FRAC_CONST(0.42200027079979968), + FRAC_CONST(0.43309381885315196), + FRAC_CONST(0.4441221445704292), + FRAC_CONST(0.45508358712634384), + FRAC_CONST(0.46597649576796618), + FRAC_CONST(0.47679923006332209), + FRAC_CONST(0.487550160148436), + FRAC_CONST(0.49822766697278187), + FRAC_CONST(0.50883014254310699), + FRAC_CONST(0.51935599016558964), + FRAC_CONST(0.52980362468629461), + FRAC_CONST(0.54017147272989285), + FRAC_CONST(0.55045797293660481), + FRAC_CONST(0.56066157619733603), + FRAC_CONST(0.57078074588696726), + FRAC_CONST(0.58081395809576453), + FRAC_CONST(0.59075970185887416), + FRAC_CONST(0.60061647938386897), + FRAC_CONST(0.61038280627630948), + FRAC_CONST(0.6200572117632891), + FRAC_CONST(0.62963823891492698), + FRAC_CONST(0.63912444486377573), + FRAC_CONST(0.64851440102211244), + FRAC_CONST(0.65780669329707864), + FRAC_CONST(0.66699992230363747), + FRAC_CONST(0.67609270357531592), + FRAC_CONST(0.68508366777270036), + FRAC_CONST(0.693971460889654), + FRAC_CONST(0.7027547444572253), + FRAC_CONST(0.71143219574521643), + FRAC_CONST(0.72000250796138165), + FRAC_CONST(0.7284643904482252), + FRAC_CONST(0.73681656887736979), + FRAC_CONST(0.74505778544146595), + FRAC_CONST(0.75318679904361241), + FRAC_CONST(0.76120238548426178), + FRAC_CONST(0.76910333764557959), + FRAC_CONST(0.77688846567323244), + FRAC_CONST(0.78455659715557524), + FRAC_CONST(0.79210657730021239), + FRAC_CONST(0.79953726910790501), + FRAC_CONST(0.80684755354379922), + FRAC_CONST(0.8140363297059483), + FRAC_CONST(0.82110251499110465), + FRAC_CONST(0.8280450452577558), + FRAC_CONST(0.83486287498638001), + FRAC_CONST(0.84155497743689833), + FRAC_CONST(0.84812034480329712), + FRAC_CONST(0.85455798836540053), + FRAC_CONST(0.86086693863776731), + FRAC_CONST(0.86704624551569265), + FRAC_CONST(0.87309497841829009), + FRAC_CONST(0.87901222642863341), + FRAC_CONST(0.88479709843093779), + FRAC_CONST(0.89044872324475788), + FRAC_CONST(0.89596624975618511), + FRAC_CONST(0.90134884704602203), + FRAC_CONST(0.90659570451491533), + FRAC_CONST(0.91170603200542988), + FRAC_CONST(0.9166790599210427), + FRAC_CONST(0.9215140393420419), + FRAC_CONST(0.92621024213831127), + FRAC_CONST(0.93076696107898371), + FRAC_CONST(0.9351835099389475), + FRAC_CONST(0.93945922360218992), + FRAC_CONST(0.94359345816196039), + FRAC_CONST(0.94758559101774109), + FRAC_CONST(0.95143502096900834), + FRAC_CONST(0.95514116830577067), + FRAC_CONST(0.9587034748958716), + FRAC_CONST(0.96212140426904158), + FRAC_CONST(0.9653944416976894), + FRAC_CONST(0.96852209427441727), + FRAC_CONST(0.97150389098625178), + FRAC_CONST(0.97433938278557586), + FRAC_CONST(0.97702814265775439), + FRAC_CONST(0.97956976568544052), + FRAC_CONST(0.98196386910955524), + FRAC_CONST(0.98421009238692903), + FRAC_CONST(0.98630809724459867), + FRAC_CONST(0.98825756773074946), + FRAC_CONST(0.99005821026229712), + FRAC_CONST(0.99170975366909953), + FRAC_CONST(0.9932119492347945), + FRAC_CONST(0.99456457073425542), + FRAC_CONST(0.99576741446765982), + FRAC_CONST(0.99682029929116567), + FRAC_CONST(0.99772306664419164), + FRAC_CONST(0.99847558057329477), + FRAC_CONST(0.99907772775264536), + FRAC_CONST(0.99952941750109314), + FRAC_CONST(0.9998305817958234), + FRAC_CONST(0.99998117528260111), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1) +}; + +#ifdef ALLOW_SMALL_FRAMELENGTH +static const real_t ld_mid_480[] MEM_ALIGN_ATTR = +{ + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0), + FRAC_CONST(0.0065449379673518581), + FRAC_CONST(0.019633692460628301), + FRAC_CONST(0.032719082821776137), + FRAC_CONST(0.045798866936520771), + FRAC_CONST(0.058870803651189033), + FRAC_CONST(0.071932653156719387), + FRAC_CONST(0.084982177372441667), + FRAC_CONST(0.09801714032956059), + FRAC_CONST(0.11103530855427769), + FRAC_CONST(0.12403445145048532), + FRAC_CONST(0.13701234168196802), + FRAC_CONST(0.14996675555404498), + FRAC_CONST(0.16289547339458874), + FRAC_CONST(0.17579627993435451), + FRAC_CONST(0.18866696468655525), + FRAC_CONST(0.2015053223256171), + FRAC_CONST(0.21430915306505074), + FRAC_CONST(0.2270762630343732), + FRAC_CONST(0.23980446465501654), + FRAC_CONST(0.25249157701515795), + FRAC_CONST(0.26513542624340797), + FRAC_CONST(0.27773384588129219), + FRAC_CONST(0.29028467725446233), + FRAC_CONST(0.3027857698425746), + FRAC_CONST(0.31523498164776964), + FRAC_CONST(0.32763017956169349), + FRAC_CONST(0.33996923973099424), + FRAC_CONST(0.35225004792123354), + FRAC_CONST(0.36447049987914965), + FRAC_CONST(0.37662850169321077), + FRAC_CONST(0.38872197015239557), + FRAC_CONST(0.40074883310314097), + FRAC_CONST(0.41270702980439467), + FRAC_CONST(0.42459451128071307), + FRAC_CONST(0.43640924067334208), + FRAC_CONST(0.44814919358922256), + FRAC_CONST(0.45981235844785984), + FRAC_CONST(0.47139673682599764), + FRAC_CONST(0.48290034380003727), + FRAC_CONST(0.49432120828614462), + FRAC_CONST(0.50565737337798455), + FRAC_CONST(0.51690689668202761), + FRAC_CONST(0.52806785065036799), + FRAC_CONST(0.53913832291100017), + FRAC_CONST(0.55011641659549337), + FRAC_CONST(0.56100025066400983), + FRAC_CONST(0.57178796022761225), + FRAC_CONST(0.58247769686780215), + FRAC_CONST(0.59306762895323706), + FRAC_CONST(0.60355594195357143), + FRAC_CONST(0.61394083875036642), + FRAC_CONST(0.62422053994501758), + FRAC_CONST(0.63439328416364549), + FRAC_CONST(0.64445732835889735), + FRAC_CONST(0.65441094810861034), + FRAC_CONST(0.66425243791128175), + FRAC_CONST(0.67398011147829784), + FRAC_CONST(0.68359230202287125), + FRAC_CONST(0.69308736254563585), + FRAC_CONST(0.70246366611685174), + FRAC_CONST(0.71171960615517138), + FRAC_CONST(0.72085359670291882), + FRAC_CONST(0.7298640726978356), + FRAC_CONST(0.73874949024124625), + FRAC_CONST(0.74750832686259672), + FRAC_CONST(0.75613908178032285), + FRAC_CONST(0.76464027615900032), + FRAC_CONST(0.77301045336273699), + FRAC_CONST(0.78124817920475853), + FRAC_CONST(0.78935204219315003), + FRAC_CONST(0.79732065377270711), + FRAC_CONST(0.80515264856285829), + FRAC_CONST(0.81284668459161513), + FRAC_CONST(0.82040144352551359), + FRAC_CONST(0.82781563089550203), + FRAC_CONST(0.83508797631874299), + FRAC_CONST(0.84221723371628654), + FRAC_CONST(0.84920218152657889), + FRAC_CONST(0.85604162291477137), + FRAC_CONST(0.86273438597779184), + FRAC_CONST(0.86927932394514362), + FRAC_CONST(0.87567531537539967), + FRAC_CONST(0.88192126434835494), + FRAC_CONST(0.88801610065280734), + FRAC_CONST(0.89395877996993212), + FRAC_CONST(0.8997482840522214), + FRAC_CONST(0.90538362089795521), + FRAC_CONST(0.91086382492117568), + FRAC_CONST(0.91618795711713596), + FRAC_CONST(0.92135510522319242), + FRAC_CONST(0.9263643838751181), + FRAC_CONST(0.93121493475880346), + FRAC_CONST(0.93590592675732565), + FRAC_CONST(0.94043655609335486), + FRAC_CONST(0.94480604646687805), + FRAC_CONST(0.94901364918821385), + FRAC_CONST(0.95305864330629697), + FRAC_CONST(0.95694033573220882), + FRAC_CONST(0.9606580613579353), + FRAC_CONST(0.96421118317032928), + FRAC_CONST(0.96759909236025976), + FRAC_CONST(0.9708212084269281), + FRAC_CONST(0.97387697927733363), + FRAC_CONST(0.97676588132087239), + FRAC_CONST(0.97948741955905139), + FRAC_CONST(0.98204112767030394), + FRAC_CONST(0.98442656808989171), + FRAC_CONST(0.98664333208487898), + FRAC_CONST(0.98869103982416728), + FRAC_CONST(0.99056934044357725), + FRAC_CONST(0.99227791210596705), + FRAC_CONST(0.99381646205637808), + FRAC_CONST(0.99518472667219682), + FRAC_CONST(0.99638247150832537), + FRAC_CONST(0.99740949133735191), + FRAC_CONST(0.99826561018471593), + FRAC_CONST(0.99895068135886012), + FRAC_CONST(0.99946458747636568), + FRAC_CONST(0.99980724048206482), + FRAC_CONST(0.99997858166412923), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1), + FRAC_CONST(1) +}; +#endif +#endif + +#ifdef __cplusplus +} +#endif +#endif diff --git a/lib/rbcodec/codecs/libfaad/specrec.c b/lib/rbcodec/codecs/libfaad/specrec.c new file mode 100644 index 0000000000..200239bddc --- /dev/null +++ b/lib/rbcodec/codecs/libfaad/specrec.c @@ -0,0 +1,1092 @@ +/* +** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding +** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +** +** Any non-GPL usage of this software or parts of this software is strictly +** forbidden. +** +** Commercial non-GPL licensing of this software is possible. +** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** +** $Id$ +**/ + +/* + Spectral reconstruction: + - grouping/sectioning + - inverse quantization + - applying scalefactors +*/ + +#include "common.h" +#include "structs.h" + +#include +#include +#include "specrec.h" +#include "filtbank.h" +#include "syntax.h" +#include "iq_table.h" +#include "ms.h" +#include "is.h" +#include "pns.h" +#include "tns.h" +#include "drc.h" +#include "lt_predict.h" +#include "ic_predict.h" +#ifdef SSR_DEC +#include "ssr.h" +#include "ssr_fb.h" +#endif + +/* static function declarations */ +static uint8_t quant_to_spec(NeAACDecHandle hDecoder, + ic_stream *ics, int16_t *quant_data, + real_t *spec_data, uint16_t frame_len); + + +#ifdef LD_DEC +static const uint8_t num_swb_512_window[] = +{ + 0, 0, 0, 36, 36, 37, 31, 31, 0, 0, 0, 0 +}; +static const uint8_t num_swb_480_window[] = +{ + 0, 0, 0, 35, 35, 37, 30, 30, 0, 0, 0, 0 +}; +#endif + +static const uint8_t num_swb_960_window[] ICONST_ATTR = +{ + 40, 40, 45, 49, 49, 49, 46, 46, 42, 42, 42, 40 +}; + +static const uint8_t num_swb_1024_window[] ICONST_ATTR = +{ + 41, 41, 47, 49, 49, 51, 47, 47, 43, 43, 43, 40 +}; + +static const uint8_t num_swb_128_window[] ICONST_ATTR = +{ + 12, 12, 12, 14, 14, 14, 15, 15, 15, 15, 15, 15 +}; + +static const uint16_t swb_offset_1024_96[] = +{ + 0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, + 64, 72, 80, 88, 96, 108, 120, 132, 144, 156, 172, 188, 212, 240, + 276, 320, 384, 448, 512, 576, 640, 704, 768, 832, 896, 960, 1024 +}; + +static const uint16_t swb_offset_128_96[] = +{ + 0, 4, 8, 12, 16, 20, 24, 32, 40, 48, 64, 92, 128 +}; + +static const uint16_t swb_offset_1024_64[] = +{ + 0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, + 64, 72, 80, 88, 100, 112, 124, 140, 156, 172, 192, 216, 240, 268, + 304, 344, 384, 424, 464, 504, 544, 584, 624, 664, 704, 744, 784, 824, + 864, 904, 944, 984, 1024 +}; + +static const uint16_t swb_offset_128_64[] = +{ + 0, 4, 8, 12, 16, 20, 24, 32, 40, 48, 64, 92, 128 +}; + +static const uint16_t swb_offset_1024_48[] ICONST_ATTR = +{ + 0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 48, 56, 64, 72, + 80, 88, 96, 108, 120, 132, 144, 160, 176, 196, 216, 240, 264, 292, + 320, 352, 384, 416, 448, 480, 512, 544, 576, 608, 640, 672, 704, 736, + 768, 800, 832, 864, 896, 928, 1024 +}; + +#ifdef LD_DEC +static const uint16_t swb_offset_512_48[] = +{ + 0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 68, 76, 84, + 92, 100, 112, 124, 136, 148, 164, 184, 208, 236, 268, 300, 332, 364, 396, + 428, 460, 512 +}; + +static const uint16_t swb_offset_480_48[] = +{ + 0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 64, 72 ,80 ,88, + 96, 108, 120, 132, 144, 156, 172, 188, 212, 240, 272, 304, 336, 368, 400, + 432, 480 +}; +#endif + +static const uint16_t swb_offset_128_48[] ICONST_ATTR = +{ + 0, 4, 8, 12, 16, 20, 28, 36, 44, 56, 68, 80, 96, 112, 128 +}; + +static const uint16_t swb_offset_1024_32[] ICONST_ATTR = +{ + 0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 48, 56, 64, 72, + 80, 88, 96, 108, 120, 132, 144, 160, 176, 196, 216, 240, 264, 292, + 320, 352, 384, 416, 448, 480, 512, 544, 576, 608, 640, 672, 704, 736, + 768, 800, 832, 864, 896, 928, 960, 992, 1024 +}; + +#ifdef LD_DEC +static const uint16_t swb_offset_512_32[] = +{ + 0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 64, 72, 80, + 88, 96, 108, 120, 132, 144, 160, 176, 192, 212, 236, 260, 288, 320, 352, + 384, 416, 448, 480, 512 +}; + +static const uint16_t swb_offset_480_32[] = +{ + 0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64, 72, 80, + 88, 96, 104, 112, 124, 136, 148, 164, 180, 200, 224, 256, 288, 320, 352, + 384, 416, 448, 480 +}; +#endif + +static const uint16_t swb_offset_1024_24[] ICONST_ATTR = +{ + 0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 52, 60, 68, + 76, 84, 92, 100, 108, 116, 124, 136, 148, 160, 172, 188, 204, 220, + 240, 260, 284, 308, 336, 364, 396, 432, 468, 508, 552, 600, 652, 704, + 768, 832, 896, 960, 1024 +}; + +#ifdef LD_DEC +static const uint16_t swb_offset_512_24[] = +{ + 0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 52, 60, 68, + 80, 92, 104, 120, 140, 164, 192, 224, 256, 288, 320, 352, 384, 416, + 448, 480, 512 +}; + +static const uint16_t swb_offset_480_24[] = +{ + 0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 52, 60, 68, 80, 92, 104, 120, + 140, 164, 192, 224, 256, 288, 320, 352, 384, 416, 448, 480 +}; +#endif + +static const uint16_t swb_offset_128_24[] ICONST_ATTR = +{ + 0, 4, 8, 12, 16, 20, 24, 28, 36, 44, 52, 64, 76, 92, 108, 128 +}; + +static const uint16_t swb_offset_1024_16[] ICONST_ATTR = +{ + 0, 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 100, 112, 124, + 136, 148, 160, 172, 184, 196, 212, 228, 244, 260, 280, 300, 320, 344, + 368, 396, 424, 456, 492, 532, 572, 616, 664, 716, 772, 832, 896, 960, 1024 +}; + +static const uint16_t swb_offset_128_16[] ICONST_ATTR = +{ + 0, 4, 8, 12, 16, 20, 24, 28, 32, 40, 48, 60, 72, 88, 108, 128 +}; + +static const uint16_t swb_offset_1024_8[] ICONST_ATTR = +{ + 0, 12, 24, 36, 48, 60, 72, 84, 96, 108, 120, 132, 144, 156, 172, + 188, 204, 220, 236, 252, 268, 288, 308, 328, 348, 372, 396, 420, 448, + 476, 508, 544, 580, 620, 664, 712, 764, 820, 880, 944, 1024 +}; + +static const uint16_t swb_offset_128_8[] ICONST_ATTR = +{ + 0, 4, 8, 12, 16, 20, 24, 28, 36, 44, 52, 60, 72, 88, 108, 128 +}; + +static const uint16_t *const swb_offset_1024_window[] ICONST_ATTR = +{ + swb_offset_1024_96, /* 96000 */ + swb_offset_1024_96, /* 88200 */ + swb_offset_1024_64, /* 64000 */ + swb_offset_1024_48, /* 48000 */ + swb_offset_1024_48, /* 44100 */ + swb_offset_1024_32, /* 32000 */ + swb_offset_1024_24, /* 24000 */ + swb_offset_1024_24, /* 22050 */ + swb_offset_1024_16, /* 16000 */ + swb_offset_1024_16, /* 12000 */ + swb_offset_1024_16, /* 11025 */ + swb_offset_1024_8 /* 8000 */ +}; + +#ifdef LD_DEC +static const uint16_t *swb_offset_512_window[] = +{ + 0, /* 96000 */ + 0, /* 88200 */ + 0, /* 64000 */ + swb_offset_512_48, /* 48000 */ + swb_offset_512_48, /* 44100 */ + swb_offset_512_32, /* 32000 */ + swb_offset_512_24, /* 24000 */ + swb_offset_512_24, /* 22050 */ + 0, /* 16000 */ + 0, /* 12000 */ + 0, /* 11025 */ + 0 /* 8000 */ +}; + +static const uint16_t *swb_offset_480_window[] = +{ + 0, /* 96000 */ + 0, /* 88200 */ + 0, /* 64000 */ + swb_offset_480_48, /* 48000 */ + swb_offset_480_48, /* 44100 */ + swb_offset_480_32, /* 32000 */ + swb_offset_480_24, /* 24000 */ + swb_offset_480_24, /* 22050 */ + 0, /* 16000 */ + 0, /* 12000 */ + 0, /* 11025 */ + 0 /* 8000 */ +}; +#endif + +static const uint16_t *const swb_offset_128_window[] ICONST_ATTR = +{ + swb_offset_128_96, /* 96000 */ + swb_offset_128_96, /* 88200 */ + swb_offset_128_64, /* 64000 */ + swb_offset_128_48, /* 48000 */ + swb_offset_128_48, /* 44100 */ + swb_offset_128_48, /* 32000 */ + swb_offset_128_24, /* 24000 */ + swb_offset_128_24, /* 22050 */ + swb_offset_128_16, /* 16000 */ + swb_offset_128_16, /* 12000 */ + swb_offset_128_16, /* 11025 */ + swb_offset_128_8 /* 8000 */ +}; + +#define bit_set(A, B) ((A) & (1<<(B))) + +/* static variables */ +/* used by reconstruct_single_channel() and reconstruct_channel_pair() */ +static real_t spec_coef1[FRAME_LEN] IBSS_ATTR MEM_ALIGN_ATTR; +static real_t spec_coef2[FRAME_LEN] IBSS_ATTR MEM_ALIGN_ATTR; + +/* 4.5.2.3.4 */ +/* + - determine the number of windows in a window_sequence named num_windows + - determine the number of window_groups named num_window_groups + - determine the number of windows in each group named window_group_length[g] + - determine the total number of scalefactor window bands named num_swb for + the actual window type + - determine swb_offset[swb], the offset of the first coefficient in + scalefactor window band named swb of the window actually used + - determine sect_sfb_offset[g][section],the offset of the first coefficient + in section named section. This offset depends on window_sequence and + scale_factor_grouping and is needed to decode the spectral_data(). +*/ +uint8_t window_grouping_info(NeAACDecHandle hDecoder, ic_stream *ics) +{ + uint8_t i, g; + + uint8_t sf_index = hDecoder->sf_index; + + switch (ics->window_sequence) { + case ONLY_LONG_SEQUENCE: + case LONG_START_SEQUENCE: + case LONG_STOP_SEQUENCE: + ics->num_windows = 1; + ics->num_window_groups = 1; + ics->window_group_length[ics->num_window_groups-1] = 1; +#ifdef LD_DEC + if (hDecoder->object_type == LD) + { + if (hDecoder->frameLength == 512) + ics->num_swb = num_swb_512_window[sf_index]; + else /* if (hDecoder->frameLength == 480) */ + ics->num_swb = num_swb_480_window[sf_index]; + } else { +#endif + if (hDecoder->frameLength == 1024) + ics->num_swb = num_swb_1024_window[sf_index]; + else /* if (hDecoder->frameLength == 960) */ + ics->num_swb = num_swb_960_window[sf_index]; +#ifdef LD_DEC + } +#endif + + /* preparation of sect_sfb_offset for long blocks */ + /* also copy the last value! */ +#ifdef LD_DEC + if (hDecoder->object_type == LD) + { + if (hDecoder->frameLength == 512) + { + for (i = 0; i < ics->num_swb; i++) + { + ics->sect_sfb_offset[0][i] = swb_offset_512_window[sf_index][i]; + ics->swb_offset[i] = swb_offset_512_window[sf_index][i]; + } + } else /* if (hDecoder->frameLength == 480) */ { + for (i = 0; i < ics->num_swb; i++) + { + ics->sect_sfb_offset[0][i] = swb_offset_480_window[sf_index][i]; + ics->swb_offset[i] = swb_offset_480_window[sf_index][i]; + } + } + ics->sect_sfb_offset[0][ics->num_swb] = hDecoder->frameLength; + ics->swb_offset[ics->num_swb] = hDecoder->frameLength; + } else { +#endif + for (i = 0; i < ics->num_swb; i++) + { + ics->sect_sfb_offset[0][i] = swb_offset_1024_window[sf_index][i]; + ics->swb_offset[i] = swb_offset_1024_window[sf_index][i]; + } + ics->sect_sfb_offset[0][ics->num_swb] = hDecoder->frameLength; + ics->swb_offset[ics->num_swb] = hDecoder->frameLength; +#ifdef LD_DEC + } +#endif + return 0; + case EIGHT_SHORT_SEQUENCE: + ics->num_windows = 8; + ics->num_window_groups = 1; + ics->window_group_length[ics->num_window_groups-1] = 1; + ics->num_swb = num_swb_128_window[sf_index]; + + for (i = 0; i < ics->num_swb; i++) + ics->swb_offset[i] = swb_offset_128_window[sf_index][i]; + ics->swb_offset[ics->num_swb] = hDecoder->frameLength/8; + + for (i = 0; i < ics->num_windows-1; i++) { + if (bit_set(ics->scale_factor_grouping, 6-i) == 0) + { + ics->num_window_groups += 1; + ics->window_group_length[ics->num_window_groups-1] = 1; + } else { + ics->window_group_length[ics->num_window_groups-1] += 1; + } + } + + /* preparation of sect_sfb_offset for short blocks */ + for (g = 0; g < ics->num_window_groups; g++) + { + uint16_t width; + uint8_t sect_sfb = 0; + uint16_t offset = 0; + + for (i = 0; i < ics->num_swb; i++) + { + if (i+1 == ics->num_swb) + { + width = (hDecoder->frameLength/8) - swb_offset_128_window[sf_index][i]; + } else { + width = swb_offset_128_window[sf_index][i+1] - + swb_offset_128_window[sf_index][i]; + } + width *= ics->window_group_length[g]; + ics->sect_sfb_offset[g][sect_sfb++] = offset; + offset += width; + } + ics->sect_sfb_offset[g][sect_sfb] = offset; + } + return 0; + default: + return 1; + } +} + +/* iquant() */ +/* output = sign(input)*abs(input)^(4/3) */ +/**/ +static INLINE real_t iquant(int16_t q, const real_t *tab, uint8_t *error) +{ +#ifndef BIG_IQ_TABLE +/* For FIXED_POINT the iq_table is prescaled by 3 bits (iq_table[]/8) */ +/* BIG_IQ_TABLE allows you to use the full 8192 value table, if this is not + * defined a 1026 value table and interpolation will be used + */ + static const real_t errcorr[] = { + REAL_CONST(0), REAL_CONST(1.0/8.0), REAL_CONST(2.0/8.0), REAL_CONST(3.0/8.0), + REAL_CONST(4.0/8.0), REAL_CONST(5.0/8.0), REAL_CONST(6.0/8.0), REAL_CONST(7.0/8.0), + REAL_CONST(0) + }; + real_t x1, x2; + + int16_t sgn = 1; + + if (q < 0) + { + q = -q; + sgn = -1; + } + + if (q < IQ_TABLE_SIZE) + { +//#define IQUANT_PRINT +#ifdef IQUANT_PRINT + //printf("0x%.8X\n", sgn * tab[q]); + printf("%d\n", sgn * tab[q]); +#endif + return sgn * tab[q]; + } + + if (q >= 8192) + { + *error = 17; + return 0; + } + + /* linear interpolation */ + x1 = tab[q>>3]; + x2 = tab[(q>>3) + 1]; + return sgn * 16 * (MUL_R(errcorr[q&7],(x2-x1)) + x1); +#else /* #ifndef BIG_IQ_TABLE */ + if (q < 0) + { + /* tab contains a value for all possible q [0,8192] */ + if (LIKELY(-q < IQ_TABLE_SIZE)) + return -tab[-q]; + + *error = 17; + return 0; + } else { + /* tab contains a value for all possible q [0,8192] */ + if (LIKELY(q < IQ_TABLE_SIZE)) + return tab[q]; + + *error = 17; + return 0; + } +#endif +} + +#ifndef FIXED_POINT +static const real_t pow2sf_tab[] = { + 2.9802322387695313E-008, 5.9604644775390625E-008, 1.1920928955078125E-007, + 2.384185791015625E-007, 4.76837158203125E-007, 9.5367431640625E-007, + 1.9073486328125E-006, 3.814697265625E-006, 7.62939453125E-006, + 1.52587890625E-005, 3.0517578125E-005, 6.103515625E-005, + 0.0001220703125, 0.000244140625, 0.00048828125, + 0.0009765625, 0.001953125, 0.00390625, + 0.0078125, 0.015625, 0.03125, + 0.0625, 0.125, 0.25, + 0.5, 1.0, 2.0, + 4.0, 8.0, 16.0, 32.0, + 64.0, 128.0, 256.0, + 512.0, 1024.0, 2048.0, + 4096.0, 8192.0, 16384.0, + 32768.0, 65536.0, 131072.0, + 262144.0, 524288.0, 1048576.0, + 2097152.0, 4194304.0, 8388608.0, + 16777216.0, 33554432.0, 67108864.0, + 134217728.0, 268435456.0, 536870912.0, + 1073741824.0, 2147483648.0, 4294967296.0, + 8589934592.0, 17179869184.0, 34359738368.0, + 68719476736.0, 137438953472.0, 274877906944.0 +}; +#endif + +/* quant_to_spec: perform dequantisation and scaling + * and in case of short block it also does the deinterleaving + */ +/* + For ONLY_LONG_SEQUENCE windows (num_window_groups = 1, + window_group_length[0] = 1) the spectral data is in ascending spectral + order. + For the EIGHT_SHORT_SEQUENCE window, the spectral order depends on the + grouping in the following manner: + - Groups are ordered sequentially + - Within a group, a scalefactor band consists of the spectral data of all + grouped SHORT_WINDOWs for the associated scalefactor window band. To + clarify via example, the length of a group is in the range of one to eight + SHORT_WINDOWs. + - If there are eight groups each with length one (num_window_groups = 8, + window_group_length[0..7] = 1), the result is a sequence of eight spectra, + each in ascending spectral order. + - If there is only one group with length eight (num_window_groups = 1, + window_group_length[0] = 8), the result is that spectral data of all eight + SHORT_WINDOWs is interleaved by scalefactor window bands. + - Within a scalefactor window band, the coefficients are in ascending + spectral order. +*/ +static const real_t pow2_table[] ICONST_ATTR = +{ + COEF_CONST(1.0), + COEF_CONST(1.1892071150027210667174999705605), /* 2^0.25 */ + COEF_CONST(1.4142135623730950488016887242097), /* 2^0.50 */ + COEF_CONST(1.6817928305074290860622509524664) /* 2^0.75 */ +}; +static uint8_t quant_to_spec(NeAACDecHandle hDecoder, + ic_stream *ics, int16_t *quant_data, + real_t *spec_data, uint16_t frame_len) +{ + const real_t *tab = iq_table; + + (void)frame_len; + uint8_t g, sfb, win; + uint16_t width, bin, k, gindex, wa, wb; + uint8_t error = 0; /* Init error flag */ + real_t scf; + + k = 0; + gindex = 0; + + for (g = 0; g < ics->num_window_groups; g++) + { + uint16_t j = 0; + uint16_t gincrease = 0; + uint16_t win_inc = ics->swb_offset[ics->num_swb]; + + for (sfb = 0; sfb < ics->num_swb; sfb++) + { + int32_t exp, frac; + + width = ics->swb_offset[sfb+1] - ics->swb_offset[sfb]; + + /* this could be scalefactor for IS or PNS, those can be negative or bigger then 255 */ + /* just ignore them */ + if (ics->scale_factors[g][sfb] < 0 || ics->scale_factors[g][sfb] > 255) + { + exp = 0; + frac = 0; + } else { + /* ics->scale_factors[g][sfb] must be between 0 and 255 */ + exp = (ics->scale_factors[g][sfb] /* - 100 */) >> 2; + /* frac must always be > 0 */ + frac = (ics->scale_factors[g][sfb] /* - 100 */) & 3; + } + +#ifdef FIXED_POINT + exp -= 25; + /* IMDCT pre-scaling */ + if (hDecoder->object_type == LD) + { + exp -= 6 /*9*/; + } else { + if (ics->window_sequence == EIGHT_SHORT_SEQUENCE) + exp -= 4 /*7*/; + else + exp -= 7 /*10*/; + } +#endif + + wa = gindex + j; + +#ifndef FIXED_POINT + scf = pow2sf_tab[exp/*+25*/] * pow2_table[frac]; +#else + scf = pow2_table[frac]; +#endif + + for (win = 0; win < ics->window_group_length[g]; win++) + { + for (bin = 0; bin < width; bin += 4) + { +#ifndef FIXED_POINT + wb = wa + bin; + + spec_data[wb+0] = iquant(quant_data[k+0], tab, &error) * scf; + spec_data[wb+1] = iquant(quant_data[k+1], tab, &error) * scf; + spec_data[wb+2] = iquant(quant_data[k+2], tab, &error) * scf; + spec_data[wb+3] = iquant(quant_data[k+3], tab, &error) * scf; + +#else + wb = wa + bin; + + if (exp>=0) + { + spec_data[wb+0] = MUL_C((iquant(quant_data[k+0], tab, &error)<< exp), scf); + spec_data[wb+1] = MUL_C((iquant(quant_data[k+1], tab, &error)<< exp), scf); + spec_data[wb+2] = MUL_C((iquant(quant_data[k+2], tab, &error)<< exp), scf); + spec_data[wb+3] = MUL_C((iquant(quant_data[k+3], tab, &error)<< exp), scf); + } else { + spec_data[wb+0] = MUL_C((iquant(quant_data[k+0], tab, &error)>>-exp), scf); + spec_data[wb+1] = MUL_C((iquant(quant_data[k+1], tab, &error)>>-exp), scf); + spec_data[wb+2] = MUL_C((iquant(quant_data[k+2], tab, &error)>>-exp), scf); + spec_data[wb+3] = MUL_C((iquant(quant_data[k+3], tab, &error)>>-exp), scf); + } +//#define SCFS_PRINT +#ifdef SCFS_PRINT + printf("%d\n", spec_data[gindex+(win*win_inc)+j+bin+0]); + printf("%d\n", spec_data[gindex+(win*win_inc)+j+bin+1]); + printf("%d\n", spec_data[gindex+(win*win_inc)+j+bin+2]); + printf("%d\n", spec_data[gindex+(win*win_inc)+j+bin+3]); + //printf("0x%.8X\n", spec_data[gindex+(win*win_inc)+j+bin+0]); + //printf("0x%.8X\n", spec_data[gindex+(win*win_inc)+j+bin+1]); + //printf("0x%.8X\n", spec_data[gindex+(win*win_inc)+j+bin+2]); + //printf("0x%.8X\n", spec_data[gindex+(win*win_inc)+j+bin+3]); +#endif +#endif + + gincrease += 4; + k += 4; + } + wa += win_inc; + } + j += width; + } + gindex += gincrease; + } + + return error; +} + +static uint8_t allocate_single_channel(NeAACDecHandle hDecoder, uint8_t channel, + uint8_t output_channels) +{ + (void)output_channels; + (void)hDecoder; + (void)channel; + return 0; +} + +static uint8_t allocate_channel_pair(NeAACDecHandle hDecoder, + uint8_t channel, uint8_t paired_channel) +{ + (void)paired_channel; + (void)hDecoder; + (void)channel; + return 0; +} + +uint8_t reconstruct_single_channel(NeAACDecHandle hDecoder, ic_stream *ics, + element *sce, int16_t *spec_data) +{ + uint8_t retval, output_channels; + +#ifdef PROFILE + int64_t count = faad_get_ts(); +#endif + + + /* always allocate 2 channels, PS can always "suddenly" turn up */ +#if (defined(PS_DEC) || defined(DRM_PS)) + output_channels = 2; +#else + output_channels = 1; +#endif + + if (hDecoder->element_output_channels[hDecoder->fr_ch_ele] == 0) + { + /* element_output_channels not set yet */ + hDecoder->element_output_channels[hDecoder->fr_ch_ele] = output_channels; + } else if (hDecoder->element_output_channels[hDecoder->fr_ch_ele] != output_channels) { + /* element inconsistency */ + return 21; + } + + if (hDecoder->element_alloced[hDecoder->fr_ch_ele] == 0) + { + retval = allocate_single_channel(hDecoder, sce->channel, output_channels); + if (retval > 0) + return retval; + + hDecoder->element_alloced[hDecoder->fr_ch_ele] = 1; + } + + + /* dequantisation and scaling */ + retval = quant_to_spec(hDecoder, ics, spec_data, spec_coef1, hDecoder->frameLength); + if (retval > 0) + return retval; + +#ifdef PROFILE + count = faad_get_ts() - count; + hDecoder->requant_cycles += count; +#endif + + + /* pns decoding */ + pns_decode(ics, NULL, spec_coef1, NULL, hDecoder->frameLength, 0, hDecoder->object_type); + +#ifdef MAIN_DEC + /* MAIN object type prediction */ + if (hDecoder->object_type == MAIN) + { + /* intra channel prediction */ + ic_prediction(ics, spec_coef1, hDecoder->pred_stat[sce->channel], hDecoder->frameLength, + hDecoder->sf_index); + + /* In addition, for scalefactor bands coded by perceptual + noise substitution the predictors belonging to the + corresponding spectral coefficients are reset. + */ + pns_reset_pred_state(ics, hDecoder->pred_stat[sce->channel]); + } +#endif + +#ifdef LTP_DEC + if (is_ltp_ot(hDecoder->object_type)) + { +#ifdef LD_DEC + if (hDecoder->object_type == LD) + { + if (ics->ltp.data_present) + { + if (ics->ltp.lag_update) + hDecoder->ltp_lag[sce->channel] = ics->ltp.lag; + } + ics->ltp.lag = hDecoder->ltp_lag[sce->channel]; + } +#endif + + /* long term prediction */ + lt_prediction(ics, &(ics->ltp), spec_coef1, hDecoder->lt_pred_stat[sce->channel], hDecoder->fb, + ics->window_shape, hDecoder->window_shape_prev[sce->channel], + hDecoder->sf_index, hDecoder->object_type, hDecoder->frameLength); + } +#endif + + /* tns decoding */ + tns_decode_frame(ics, &(ics->tns), hDecoder->sf_index, hDecoder->object_type, + spec_coef1, hDecoder->frameLength); + + /* drc decoding */ + if (hDecoder->drc->present) + { + if (!hDecoder->drc->exclude_mask[sce->channel] || !hDecoder->drc->excluded_chns_present) + drc_decode(hDecoder->drc, spec_coef1); + } + + /* filter bank */ +#ifdef SSR_DEC + if (hDecoder->object_type != SSR) + { +#endif + ifilter_bank(ics->window_sequence,ics->window_shape, + hDecoder->window_shape_prev[sce->channel],spec_coef1, + hDecoder->time_out[sce->channel], hDecoder->fb_intermed[sce->channel], + hDecoder->object_type, hDecoder->frameLength); +#ifdef SSR_DEC + } else { + ssr_decode(&(ics->ssr), hDecoder->fb, ics->window_sequence, ics->window_shape, + hDecoder->window_shape_prev[sce->channel], spec_coef1, hDecoder->time_out[sce->channel], + hDecoder->ssr_overlap[sce->channel], hDecoder->ipqf_buffer[sce->channel], hDecoder->prev_fmd[sce->channel], + hDecoder->frameLength); + } +#endif + + /* save window shape for next frame */ + hDecoder->window_shape_prev[sce->channel] = ics->window_shape; + +#ifdef LTP_DEC + if (is_ltp_ot(hDecoder->object_type)) + { + lt_update_state(hDecoder->lt_pred_stat[sce->channel], hDecoder->time_out[sce->channel], + hDecoder->fb_intermed[sce->channel], hDecoder->frameLength, hDecoder->object_type); + } +#endif + +#ifdef SBR_DEC + if (((hDecoder->sbr_present_flag == 1) || (hDecoder->forceUpSampling == 1)) + && hDecoder->sbr_alloced[hDecoder->fr_ch_ele]) + { + uint8_t ele = hDecoder->fr_ch_ele; + uint8_t ch = sce->channel; + + /* following case can happen when forceUpSampling == 1 */ + if (hDecoder->sbr[ele] == NULL) + { + hDecoder->sbr[ele] = sbrDecodeInit(hDecoder->frameLength, + hDecoder->element_id[ele], ele, + 2*get_sample_rate(hDecoder->sf_index), + hDecoder->downSampledSBR, 0); +#ifndef FAAD_STATIC_ALLOC + if (hDecoder->sbr[ele] == NULL) + { + /* could not allocate memory */ + return 28; + } +#endif + } + + if (sce->ics1.window_sequence == EIGHT_SHORT_SEQUENCE) + hDecoder->sbr[ele]->maxAACLine = 8*sce->ics1.swb_offset[max(sce->ics1.max_sfb-1, 0)]; + else + hDecoder->sbr[ele]->maxAACLine = sce->ics1.swb_offset[max(sce->ics1.max_sfb-1, 0)]; + + /* check if any of the PS tools is used */ +#if (defined(PS_DEC) || defined(DRM_PS)) + if (hDecoder->ps_used[ele] == 0) + { +#endif + retval = sbrDecodeSingleFrame(hDecoder->sbr[ele], hDecoder->time_out[ch], + hDecoder->postSeekResetFlag, hDecoder->downSampledSBR); +#if (defined(PS_DEC) || defined(DRM_PS)) + } else { + retval = sbrDecodeSingleFramePS(hDecoder->sbr[ele], hDecoder->time_out[ch], + hDecoder->time_out[ch+1], hDecoder->postSeekResetFlag, + hDecoder->downSampledSBR); + } +#endif + if (retval > 0) + return retval; + } else if (((hDecoder->sbr_present_flag == 1) || (hDecoder->forceUpSampling == 1)) + && !hDecoder->sbr_alloced[hDecoder->fr_ch_ele]) + { + return 23; + } +#endif + + /* copy L to R when no PS is used */ +#if (defined(PS_DEC) || defined(DRM_PS)) + if ((hDecoder->ps_used[hDecoder->fr_ch_ele] == 0)) + { + uint8_t ele = hDecoder->fr_ch_ele; + uint8_t ch = sce->channel; + uint16_t frame_size = (hDecoder->sbr_alloced[ele]) ? 2 : 1; + frame_size *= hDecoder->frameLength*sizeof(real_t); + + memcpy(hDecoder->time_out[ch+1], hDecoder->time_out[ch], frame_size); + } +#endif + + return 0; +} + +uint8_t reconstruct_channel_pair(NeAACDecHandle hDecoder, ic_stream *ics1, ic_stream *ics2, + element *cpe, int16_t *spec_data1, int16_t *spec_data2) +{ + uint8_t retval; + +#ifdef PROFILE + int64_t count = faad_get_ts(); +#endif + if (hDecoder->element_alloced[hDecoder->fr_ch_ele] == 0) + { + retval = allocate_channel_pair(hDecoder, cpe->channel, (uint8_t)cpe->paired_channel); + if (retval > 0) + return retval; + + hDecoder->element_alloced[hDecoder->fr_ch_ele] = 1; + } + + /* dequantisation and scaling */ + retval = quant_to_spec(hDecoder, ics1, spec_data1, spec_coef1, hDecoder->frameLength); + if (retval > 0) + return retval; + retval = quant_to_spec(hDecoder, ics2, spec_data2, spec_coef2, hDecoder->frameLength); + if (retval > 0) + return retval; + +#ifdef PROFILE + count = faad_get_ts() - count; + hDecoder->requant_cycles += count; +#endif + + + /* pns decoding */ + if (ics1->ms_mask_present) + { + pns_decode(ics1, ics2, spec_coef1, spec_coef2, hDecoder->frameLength, 1, hDecoder->object_type); + } else { + pns_decode(ics1, NULL, spec_coef1, NULL, hDecoder->frameLength, 0, hDecoder->object_type); + pns_decode(ics2, NULL, spec_coef2, NULL, hDecoder->frameLength, 0, hDecoder->object_type); + } + + /* mid/side decoding */ + ms_decode(ics1, ics2, spec_coef1, spec_coef2, hDecoder->frameLength); + +#if 0 + { + int i; + for (i = 0; i < 1024; i++) + { + //printf("%d\n", spec_coef1[i]); + printf("0x%.8X\n", spec_coef1[i]); + } + for (i = 0; i < 1024; i++) + { + //printf("%d\n", spec_coef2[i]); + printf("0x%.8X\n", spec_coef2[i]); + } + } +#endif + + /* intensity stereo decoding */ + is_decode(ics1, ics2, spec_coef1, spec_coef2, hDecoder->frameLength); + +#if 0 + { + int i; + for (i = 0; i < 1024; i++) + { + printf("%d\n", spec_coef1[i]); + //printf("0x%.8X\n", spec_coef1[i]); + } + for (i = 0; i < 1024; i++) + { + printf("%d\n", spec_coef2[i]); + //printf("0x%.8X\n", spec_coef2[i]); + } + } +#endif + +#ifdef MAIN_DEC + /* MAIN object type prediction */ + if (hDecoder->object_type == MAIN) + { + /* intra channel prediction */ + ic_prediction(ics1, spec_coef1, hDecoder->pred_stat[cpe->channel], hDecoder->frameLength, + hDecoder->sf_index); + ic_prediction(ics2, spec_coef2, hDecoder->pred_stat[cpe->paired_channel], hDecoder->frameLength, + hDecoder->sf_index); + + /* In addition, for scalefactor bands coded by perceptual + noise substitution the predictors belonging to the + corresponding spectral coefficients are reset. + */ + pns_reset_pred_state(ics1, hDecoder->pred_stat[cpe->channel]); + pns_reset_pred_state(ics2, hDecoder->pred_stat[cpe->paired_channel]); + } +#endif + +#ifdef LTP_DEC + if (is_ltp_ot(hDecoder->object_type)) + { + ltp_info *ltp1 = &(ics1->ltp); + ltp_info *ltp2 = (cpe->common_window) ? &(ics2->ltp2) : &(ics2->ltp); +#ifdef LD_DEC + if (hDecoder->object_type == LD) + { + if (ltp1->data_present) + { + if (ltp1->lag_update) + hDecoder->ltp_lag[cpe->channel] = ltp1->lag; + } + ltp1->lag = hDecoder->ltp_lag[cpe->channel]; + if (ltp2->data_present) + { + if (ltp2->lag_update) + hDecoder->ltp_lag[cpe->paired_channel] = ltp2->lag; + } + ltp2->lag = hDecoder->ltp_lag[cpe->paired_channel]; + } +#endif + + /* long term prediction */ + lt_prediction(ics1, ltp1, spec_coef1, hDecoder->lt_pred_stat[cpe->channel], hDecoder->fb, + ics1->window_shape, hDecoder->window_shape_prev[cpe->channel], + hDecoder->sf_index, hDecoder->object_type, hDecoder->frameLength); + lt_prediction(ics2, ltp2, spec_coef2, hDecoder->lt_pred_stat[cpe->paired_channel], hDecoder->fb, + ics2->window_shape, hDecoder->window_shape_prev[cpe->paired_channel], + hDecoder->sf_index, hDecoder->object_type, hDecoder->frameLength); + } +#endif + + /* tns decoding */ + tns_decode_frame(ics1, &(ics1->tns), hDecoder->sf_index, hDecoder->object_type, + spec_coef1, hDecoder->frameLength); + tns_decode_frame(ics2, &(ics2->tns), hDecoder->sf_index, hDecoder->object_type, + spec_coef2, hDecoder->frameLength); + + /* drc decoding */ + if (hDecoder->drc->present) + { + if (!hDecoder->drc->exclude_mask[cpe->channel] || !hDecoder->drc->excluded_chns_present) + drc_decode(hDecoder->drc, spec_coef1); + if (!hDecoder->drc->exclude_mask[cpe->paired_channel] || !hDecoder->drc->excluded_chns_present) + drc_decode(hDecoder->drc, spec_coef2); + } + + /* filter bank */ +#ifdef SSR_DEC + if (hDecoder->object_type != SSR) + { +#endif + ifilter_bank(ics1->window_sequence,ics1->window_shape, + hDecoder->window_shape_prev[cpe->channel],spec_coef1, + hDecoder->time_out[cpe->channel], hDecoder->fb_intermed[cpe->channel], + hDecoder->object_type, hDecoder->frameLength); + ifilter_bank(ics2->window_sequence,ics2->window_shape, + hDecoder->window_shape_prev[cpe->paired_channel], spec_coef2, + hDecoder->time_out[cpe->paired_channel], hDecoder->fb_intermed[cpe->paired_channel], + hDecoder->object_type, hDecoder->frameLength); +#ifdef SSR_DEC + } else { + ssr_decode(&(ics1->ssr), hDecoder->fb, ics1->window_sequence, ics1->window_shape, + hDecoder->window_shape_prev[cpe->channel], spec_coef1, hDecoder->time_out[cpe->channel], + hDecoder->ssr_overlap[cpe->channel], hDecoder->ipqf_buffer[cpe->channel], + hDecoder->prev_fmd[cpe->channel], hDecoder->frameLength); + ssr_decode(&(ics2->ssr), hDecoder->fb, ics2->window_sequence, ics2->window_shape, + hDecoder->window_shape_prev[cpe->paired_channel], spec_coef2, hDecoder->time_out[cpe->paired_channel], + hDecoder->ssr_overlap[cpe->paired_channel], hDecoder->ipqf_buffer[cpe->paired_channel], + hDecoder->prev_fmd[cpe->paired_channel], hDecoder->frameLength); + } +#endif + + /* save window shape for next frame */ + hDecoder->window_shape_prev[cpe->channel] = ics1->window_shape; + hDecoder->window_shape_prev[cpe->paired_channel] = ics2->window_shape; + +#ifdef LTP_DEC + if (is_ltp_ot(hDecoder->object_type)) + { + lt_update_state(hDecoder->lt_pred_stat[cpe->channel], hDecoder->time_out[cpe->channel], + hDecoder->fb_intermed[cpe->channel], hDecoder->frameLength, hDecoder->object_type); + lt_update_state(hDecoder->lt_pred_stat[cpe->paired_channel], hDecoder->time_out[cpe->paired_channel], + hDecoder->fb_intermed[cpe->paired_channel], hDecoder->frameLength, hDecoder->object_type); + } +#endif + +#ifdef SBR_DEC + if (((hDecoder->sbr_present_flag == 1) || (hDecoder->forceUpSampling == 1)) + && hDecoder->sbr_alloced[hDecoder->fr_ch_ele]) + { + uint8_t ele = hDecoder->fr_ch_ele; + uint8_t ch0 = cpe->channel; + uint8_t ch1 = cpe->paired_channel; + + /* following case can happen when forceUpSampling == 1 */ + if (hDecoder->sbr[ele] == NULL) + { + hDecoder->sbr[ele] = sbrDecodeInit(hDecoder->frameLength, + hDecoder->element_id[ele], ele, + 2*get_sample_rate(hDecoder->sf_index), + hDecoder->downSampledSBR, 0); +#ifndef FAAD_STATIC_ALLOC + if (hDecoder->sbr[ele] == NULL) + { + /* could not allocate memory */ + return 28; + } +#endif + } + + if (cpe->ics1.window_sequence == EIGHT_SHORT_SEQUENCE) + hDecoder->sbr[ele]->maxAACLine = 8*cpe->ics1.swb_offset[max(cpe->ics1.max_sfb-1, 0)]; + else + hDecoder->sbr[ele]->maxAACLine = cpe->ics1.swb_offset[max(cpe->ics1.max_sfb-1, 0)]; + + retval = sbrDecodeCoupleFrame(hDecoder->sbr[ele], + hDecoder->time_out[ch0], hDecoder->time_out[ch1], + hDecoder->postSeekResetFlag, hDecoder->downSampledSBR); + if (retval > 0) + return retval; + } else if (((hDecoder->sbr_present_flag == 1) || (hDecoder->forceUpSampling == 1)) + && !hDecoder->sbr_alloced[hDecoder->fr_ch_ele]) + { + return 23; + } +#endif + + return 0; +} diff --git a/lib/rbcodec/codecs/libfaad/specrec.h b/lib/rbcodec/codecs/libfaad/specrec.h new file mode 100644 index 0000000000..c3540ac973 --- /dev/null +++ b/lib/rbcodec/codecs/libfaad/specrec.h @@ -0,0 +1,46 @@ +/* +** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding +** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +** +** Any non-GPL usage of this software or parts of this software is strictly +** forbidden. +** +** Commercial non-GPL licensing of this software is possible. +** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** +** $Id$ +**/ + +#ifndef __SPECREC_H__ +#define __SPECREC_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "syntax.h" + +uint8_t window_grouping_info(NeAACDecHandle hDecoder, ic_stream *ics); +uint8_t reconstruct_channel_pair(NeAACDecHandle hDecoder, ic_stream *ics1, ic_stream *ics2, + element *cpe, int16_t *spec_data1, int16_t *spec_data2); +uint8_t reconstruct_single_channel(NeAACDecHandle hDecoder, ic_stream *ics, element *sce, + int16_t *spec_data); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/lib/rbcodec/codecs/libfaad/structs.h b/lib/rbcodec/codecs/libfaad/structs.h new file mode 100644 index 0000000000..a6114f412a --- /dev/null +++ b/lib/rbcodec/codecs/libfaad/structs.h @@ -0,0 +1,473 @@ +/* +** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding +** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +** +** Any non-GPL usage of this software or parts of this software is strictly +** forbidden. +** +** Commercial non-GPL licensing of this software is possible. +** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** +** $Id$ +**/ + +#ifndef __STRUCTS_H__ +#define __STRUCTS_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +//#include "cfft.h" +#ifdef SBR_DEC +#include "sbr_dec.h" +#endif + +#define MAX_CHANNELS 2 /* Was 64, but we need to limit RAM usage */ +#define MAX_SYNTAX_ELEMENTS 1 /* Was 48, but we need to limit RAM usage */ +#define MAX_WINDOW_GROUPS 8 +#define MAX_SFB 51 +#define MAX_LTP_SFB 40 +#define MAX_LTP_SFB_S 8 +#define FRAME_LEN 1024 + +#define DRC_MAX_CHANNELS 64 /* Should be the same as MAX_CHANNELS, but the DRC code expects 64 */ + +/* used to save the prediction state */ +typedef struct { + int16_t r[2]; + int16_t COR[2]; + int16_t VAR[2]; +} pred_state; + +typedef struct { + uint16_t N; + //cfft_info *cfft; + complex_t *sincos; +#ifdef PROFILE + int64_t cycles; + int64_t fft_cycles; +#endif +} mdct_info; + +typedef struct +{ + const real_t *long_window[2]; + const real_t *short_window[2]; +#ifdef LD_DEC + const real_t *ld_window[2]; +#endif + + mdct_info *mdct256; +#ifdef LD_DEC + mdct_info *mdct1024; +#endif + mdct_info *mdct2048; +#ifdef PROFILE + int64_t cycles; +#endif +} fb_info; + +typedef struct +{ + uint8_t present; + + uint8_t num_bands; + uint8_t pce_instance_tag; + uint8_t excluded_chns_present; + uint8_t band_top[17]; + uint8_t prog_ref_level; + uint8_t dyn_rng_sgn[17]; + uint8_t dyn_rng_ctl[17]; + uint8_t exclude_mask[DRC_MAX_CHANNELS]; + uint8_t additional_excluded_chns[DRC_MAX_CHANNELS/7]; + + real_t ctrl1; + real_t ctrl2; +} drc_info; + +typedef struct +{ + uint8_t element_instance_tag; + uint8_t object_type; + uint8_t sf_index; + uint8_t num_front_channel_elements; + uint8_t num_side_channel_elements; + uint8_t num_back_channel_elements; + uint8_t num_lfe_channel_elements; + uint8_t num_assoc_data_elements; + uint8_t num_valid_cc_elements; + uint8_t mono_mixdown_present; + uint8_t mono_mixdown_element_number; + uint8_t stereo_mixdown_present; + uint8_t stereo_mixdown_element_number; + uint8_t matrix_mixdown_idx_present; + uint8_t pseudo_surround_enable; + uint8_t matrix_mixdown_idx; + uint8_t front_element_is_cpe[16]; + uint8_t front_element_tag_select[16]; + uint8_t side_element_is_cpe[16]; + uint8_t side_element_tag_select[16]; + uint8_t back_element_is_cpe[16]; + uint8_t back_element_tag_select[16]; + uint8_t lfe_element_tag_select[16]; + uint8_t assoc_data_element_tag_select[16]; + uint8_t cc_element_is_ind_sw[16]; + uint8_t valid_cc_element_tag_select[16]; + + uint8_t channels; + + uint8_t comment_field_bytes; + uint8_t comment_field_data[257]; + + /* extra added values */ + uint8_t num_front_channels; + uint8_t num_side_channels; + uint8_t num_back_channels; + uint8_t num_lfe_channels; + uint8_t sce_channel[16]; + uint8_t cpe_channel[16]; +} program_config; + +typedef struct +{ + uint16_t syncword; + uint8_t id; + uint8_t layer; + uint8_t protection_absent; + uint8_t profile; + uint8_t sf_index; + uint8_t private_bit; + uint8_t channel_configuration; + uint8_t original; + uint8_t home; + uint8_t emphasis; + uint8_t copyright_identification_bit; + uint8_t copyright_identification_start; + uint16_t aac_frame_length; + uint16_t adts_buffer_fullness; + uint8_t no_raw_data_blocks_in_frame; + uint16_t crc_check; + + /* control param */ + uint8_t old_format; +} adts_header; + +typedef struct +{ + uint8_t copyright_id_present; + int8_t copyright_id[10]; + uint8_t original_copy; + uint8_t home; + uint8_t bitstream_type; + uint32_t bitrate; + uint8_t num_program_config_elements; + uint32_t adif_buffer_fullness; + + /* maximum of 16 PCEs */ + program_config pce[16]; +} adif_header; + +#ifdef LTP_DEC +typedef struct +{ + uint8_t last_band; + uint8_t data_present; + uint16_t lag; + uint8_t lag_update; + uint8_t coef; + uint8_t long_used[MAX_SFB]; + uint8_t short_used[8]; + uint8_t short_lag_present[8]; + uint8_t short_lag[8]; +} ltp_info; +#endif + +#ifdef MAIN_DEC +typedef struct +{ + uint8_t limit; + uint8_t predictor_reset; + uint8_t predictor_reset_group_number; + uint8_t prediction_used[MAX_SFB]; +} pred_info; +#endif + +typedef struct +{ + uint8_t number_pulse; + uint8_t pulse_start_sfb; + uint8_t pulse_offset[4]; + uint8_t pulse_amp[4]; +} pulse_info; + +typedef struct +{ + uint8_t n_filt[8]; + uint8_t coef_res[8]; + uint8_t length[8][4]; + uint8_t order[8][4]; + uint8_t direction[8][4]; + uint8_t coef_compress[8][4]; + uint8_t coef[8][4][32]; +} tns_info; + +#ifdef SSR_DEC +typedef struct +{ + uint8_t max_band; + + uint8_t adjust_num[4][8]; + uint8_t alevcode[4][8][8]; + uint8_t aloccode[4][8][8]; +} ssr_info; +#endif + +typedef struct +{ + uint8_t max_sfb; + + uint8_t num_swb; + uint8_t num_window_groups; + uint8_t num_windows; + uint8_t window_sequence; + uint8_t window_group_length[8]; + uint8_t window_shape; + uint8_t scale_factor_grouping; + uint16_t sect_sfb_offset[8][15*8]; + uint16_t swb_offset[52]; + + uint8_t sect_cb[8][15*8]; + uint16_t sect_start[8][15*8]; + uint16_t sect_end[8][15*8]; + uint8_t sfb_cb[8][8*15]; + uint8_t num_sec[8]; /* number of sections in a group */ + + uint8_t global_gain; + int16_t scale_factors[8][51]; /* [0..255] */ + + uint8_t ms_mask_present; + uint8_t ms_used[MAX_WINDOW_GROUPS][MAX_SFB]; + + uint8_t noise_used; + + uint8_t pulse_data_present; + uint8_t tns_data_present; + uint8_t gain_control_data_present; + uint8_t predictor_data_present; + + pulse_info pul; + tns_info tns; +#ifdef MAIN_DEC + pred_info pred; +#endif +#ifdef LTP_DEC + ltp_info ltp; + ltp_info ltp2; +#endif +#ifdef SSR_DEC + ssr_info ssr; +#endif + +#ifdef ERROR_RESILIENCE + /* ER HCR data */ + uint16_t length_of_reordered_spectral_data; + uint8_t length_of_longest_codeword; + /* ER RLVC data */ + uint8_t sf_concealment; + uint8_t rev_global_gain; + uint16_t length_of_rvlc_sf; + uint16_t dpcm_noise_nrg; + uint8_t sf_escapes_present; + uint8_t length_of_rvlc_escapes; + uint16_t dpcm_noise_last_position; +#endif +} ic_stream; /* individual channel stream */ + +typedef struct +{ + uint8_t channel; + int16_t paired_channel; + + uint8_t element_instance_tag; + uint8_t common_window; + + ic_stream ics1; + ic_stream ics2; +} element; /* syntax element (SCE, CPE, LFE) */ + +typedef struct mp4AudioSpecificConfig +{ + /* Audio Specific Info */ + /*uint8_t*/ unsigned char objectTypeIndex; + /*uint8_t*/ unsigned char samplingFrequencyIndex; + /*uint32_t*/ unsigned long samplingFrequency; + /*uint8_t*/ unsigned char channelsConfiguration; + + /* GA Specific Info */ + /*uint8_t*/ unsigned char frameLengthFlag; + /*uint8_t*/ unsigned char dependsOnCoreCoder; + /*uint16_t*/ unsigned short coreCoderDelay; + /*uint8_t*/ unsigned char extensionFlag; + /*uint8_t*/ unsigned char aacSectionDataResilienceFlag; + /*uint8_t*/ unsigned char aacScalefactorDataResilienceFlag; + /*uint8_t*/ unsigned char aacSpectralDataResilienceFlag; + /*uint8_t*/ unsigned char epConfig; + + /*uint8_t*/ signed char sbr_present_flag; + /*uint8_t*/ char forceUpSampling; + /*uint8_t*/ char downSampledSBR; +} mp4AudioSpecificConfig; + +typedef struct NeAACDecConfiguration +{ + /*uint8_t*/ unsigned char defObjectType; + /*uint32_t*/ unsigned long defSampleRate; + /*uint8_t*/ unsigned char outputFormat; + /*uint8_t*/ unsigned char downMatrix; + /*uint8_t*/ unsigned char useOldADTSFormat; + /*uint8_t*/ unsigned char dontUpSampleImplicitSBR; +} NeAACDecConfiguration, *NeAACDecConfigurationPtr; + +typedef struct NeAACDecFrameInfo +{ + /*uint32_t*/ unsigned long bytesconsumed; + /*uint32_t*/ unsigned long samples; + /*uint8_t*/ unsigned char channels; + /*uint8_t*/ unsigned char error; + /*uint32_t*/ unsigned long samplerate; + + /* SBR: 0: off, 1: on; normal, 2: on; downsampled */ + /*uint8_t*/ unsigned char sbr; + + /* MPEG-4 ObjectType */ + /*uint8_t*/ unsigned char object_type; + + /* AAC header type; MP4 will be signalled as RAW also */ + /*uint8_t*/ unsigned char header_type; + + /* multichannel configuration */ + /*uint8_t*/ unsigned char num_front_channels; + /*uint8_t*/ unsigned char num_side_channels; + /*uint8_t*/ unsigned char num_back_channels; + /*uint8_t*/ unsigned char num_lfe_channels; + /*uint8_t*/ unsigned char channel_position[MAX_CHANNELS]; + + /* PS: 0: off, 1: on */ + /*uint8_t*/ unsigned char ps; +} NeAACDecFrameInfo; + +typedef struct +{ + uint8_t adts_header_present; + uint8_t adif_header_present; + uint8_t sf_index; + uint8_t object_type; + uint8_t channelConfiguration; +#ifdef ERROR_RESILIENCE + uint8_t aacSectionDataResilienceFlag; + uint8_t aacScalefactorDataResilienceFlag; + uint8_t aacSpectralDataResilienceFlag; +#endif + uint16_t frameLength; + uint8_t postSeekResetFlag; + + uint32_t frame; + + uint8_t downMatrix; + uint8_t upMatrix; + uint8_t first_syn_ele; + uint8_t has_lfe; + /* number of channels in current frame */ + uint8_t fr_channels; + /* number of elements in current frame */ + uint8_t fr_ch_ele; + + /* element_output_channels: + determines the number of channels the element will output + */ + uint8_t element_output_channels[MAX_SYNTAX_ELEMENTS]; + /* element_alloced: + determines whether the data needed for the element is allocated or not + */ + uint8_t element_alloced[MAX_SYNTAX_ELEMENTS]; + /* alloced_channels: + determines the number of channels where output data is allocated for + */ + uint8_t alloced_channels; + + uint8_t window_shape_prev[MAX_CHANNELS]; +#ifdef LTP_DEC + uint16_t ltp_lag[MAX_CHANNELS]; +#endif + fb_info *fb; + drc_info *drc; + + real_t *time_out[MAX_CHANNELS]; + real_t *fb_intermed[MAX_CHANNELS]; + +#ifdef SBR_DEC + int8_t sbr_present_flag; + int8_t forceUpSampling; + int8_t downSampledSBR; + /* determines whether SBR data is allocated for the gives element */ + uint8_t sbr_alloced[MAX_SYNTAX_ELEMENTS]; + + sbr_info *sbr[MAX_SYNTAX_ELEMENTS]; +#endif +#if (defined(PS_DEC) || defined(DRM_PS)) + uint8_t ps_used[MAX_SYNTAX_ELEMENTS]; + uint8_t ps_used_global; +#endif + +#ifdef SSR_DEC + real_t *ssr_overlap[MAX_CHANNELS]; + real_t *prev_fmd[MAX_CHANNELS]; + real_t ipqf_buffer[MAX_CHANNELS][4][96/4]; +#endif + +#ifdef MAIN_DEC + pred_state *pred_stat[MAX_CHANNELS]; +#endif +#ifdef LTP_DEC + int16_t *lt_pred_stat[MAX_CHANNELS]; +#endif + + /* Program Config Element */ + uint8_t pce_set; + program_config pce; + uint8_t element_id[MAX_CHANNELS]; + uint8_t internal_channel[MAX_CHANNELS]; + + /* Configuration data */ + NeAACDecConfiguration config; + +#ifdef PROFILE + int64_t cycles; + int64_t spectral_cycles; + int64_t output_cycles; + int64_t scalefac_cycles; + int64_t requant_cycles; +#endif +} NeAACDecStruct, *NeAACDecHandle; + + + +#ifdef __cplusplus +} +#endif +#endif diff --git a/lib/rbcodec/codecs/libfaad/syntax.c b/lib/rbcodec/codecs/libfaad/syntax.c new file mode 100644 index 0000000000..d3d7f9e3d4 --- /dev/null +++ b/lib/rbcodec/codecs/libfaad/syntax.c @@ -0,0 +1,2368 @@ +/* +** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding +** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +** +** Any non-GPL usage of this software or parts of this software is strictly +** forbidden. +** +** Commercial non-GPL licensing of this software is possible. +** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** +** $Id$ +**/ + +/* + Reads the AAC bitstream as defined in 14496-3 (MPEG-4 Audio) +*/ + +#include "common.h" +#include "structs.h" + +#include +#include + +#include "decoder.h" +#include "syntax.h" +#include "specrec.h" +#include "huffman.h" +#include "bits.h" +#include "pulse.h" +#include "analysis.h" +#include "drc.h" +#ifdef ERROR_RESILIENCE +#include "rvlc.h" +#endif +#ifdef SBR_DEC +#include "sbr_syntax.h" +#endif + + +/* static function declarations */ +static void decode_sce_lfe(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hInfo, bitfile *ld, + uint8_t id_syn_ele); +static void decode_cpe(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hInfo, bitfile *ld, + uint8_t id_syn_ele); +static uint8_t single_lfe_channel_element(NeAACDecHandle hDecoder, bitfile *ld, + uint8_t channel, uint8_t *tag); +static uint8_t channel_pair_element(NeAACDecHandle hDecoder, bitfile *ld, + uint8_t channel, uint8_t *tag); +#ifdef COUPLING_DEC +static uint8_t coupling_channel_element(NeAACDecHandle hDecoder, bitfile *ld); +#endif +static uint16_t data_stream_element(NeAACDecHandle hDecoder, bitfile *ld); +static uint8_t program_config_element(program_config *pce, bitfile *ld); +static uint8_t fill_element(NeAACDecHandle hDecoder, bitfile *ld, drc_info *drc +#ifdef SBR_DEC + ,uint8_t sbr_ele +#endif + ); +static uint8_t individual_channel_stream(NeAACDecHandle hDecoder, element *ele, + bitfile *ld, ic_stream *ics, uint8_t scal_flag, + int16_t *spec_data); +static uint8_t ics_info(NeAACDecHandle hDecoder, ic_stream *ics, bitfile *ld, + uint8_t common_window); +static uint8_t section_data(NeAACDecHandle hDecoder, ic_stream *ics, bitfile *ld); +static uint8_t scale_factor_data(NeAACDecHandle hDecoder, ic_stream *ics, bitfile *ld); +#ifdef SSR_DEC +static void gain_control_data(bitfile *ld, ic_stream *ics); +#endif +static uint8_t spectral_data(NeAACDecHandle hDecoder, ic_stream *ics, bitfile *ld, + int16_t *spectral_data); +static uint16_t extension_payload(bitfile *ld, drc_info *drc, uint16_t count); +static uint8_t pulse_data(ic_stream *ics, pulse_info *pul, bitfile *ld); +static void tns_data(ic_stream *ics, tns_info *tns, bitfile *ld); +#ifdef LTP_DEC +static uint8_t ltp_data(NeAACDecHandle hDecoder, ic_stream *ics, ltp_info *ltp, bitfile *ld); +#endif +static uint8_t adts_fixed_header(adts_header *adts, bitfile *ld); +static void adts_variable_header(adts_header *adts, bitfile *ld); +static void adts_error_check(adts_header *adts, bitfile *ld); +static uint8_t dynamic_range_info(bitfile *ld, drc_info *drc); +static uint8_t excluded_channels(bitfile *ld, drc_info *drc); +#ifdef SCALABLE_DEC +static int8_t aac_scalable_main_header(NeAACDecHandle hDecoder, ic_stream *ics1, ic_stream *ics2, + bitfile *ld, uint8_t this_layer_stereo); +#endif + + +/* Table 4.4.1 */ +int8_t GASpecificConfig(bitfile *ld, mp4AudioSpecificConfig *mp4ASC, + program_config *pce_out) +{ + program_config pce; + + /* 1024 or 960 */ + mp4ASC->frameLengthFlag = faad_get1bit(ld + DEBUGVAR(1,138,"GASpecificConfig(): FrameLengthFlag")); +#ifndef ALLOW_SMALL_FRAMELENGTH + if (mp4ASC->frameLengthFlag == 1) + return -3; +#endif + + mp4ASC->dependsOnCoreCoder = faad_get1bit(ld + DEBUGVAR(1,139,"GASpecificConfig(): DependsOnCoreCoder")); + if (mp4ASC->dependsOnCoreCoder == 1) + { + mp4ASC->coreCoderDelay = (uint16_t)faad_getbits(ld, 14 + DEBUGVAR(1,140,"GASpecificConfig(): CoreCoderDelay")); + } + + mp4ASC->extensionFlag = faad_get1bit(ld DEBUGVAR(1,141,"GASpecificConfig(): ExtensionFlag")); + if (mp4ASC->channelsConfiguration == 0) + { + if (program_config_element(&pce, ld)) + return -3; + //mp4ASC->channelsConfiguration = pce.channels; + + if (pce_out != NULL) + memcpy(pce_out, &pce, sizeof(program_config)); + + /* + if (pce.num_valid_cc_elements) + return -3; + */ + } + +#ifdef ERROR_RESILIENCE + if (mp4ASC->extensionFlag == 1) + { + /* Error resilience not supported yet */ + if (mp4ASC->objectTypeIndex >= ER_OBJECT_START) + { + mp4ASC->aacSectionDataResilienceFlag = faad_get1bit(ld + DEBUGVAR(1,144,"GASpecificConfig(): aacSectionDataResilienceFlag")); + mp4ASC->aacScalefactorDataResilienceFlag = faad_get1bit(ld + DEBUGVAR(1,145,"GASpecificConfig(): aacScalefactorDataResilienceFlag")); + mp4ASC->aacSpectralDataResilienceFlag = faad_get1bit(ld + DEBUGVAR(1,146,"GASpecificConfig(): aacSpectralDataResilienceFlag")); + + /* 1 bit: extensionFlag3 */ + } + } +#endif + + return 0; +} + +/* Table 4.4.2 */ +/* An MPEG-4 Audio decoder is only required to follow the Program + Configuration Element in GASpecificConfig(). The decoder shall ignore + any Program Configuration Elements that may occur in raw data blocks. + PCEs transmitted in raw data blocks cannot be used to convey decoder + configuration information. +*/ +static uint8_t program_config_element(program_config *pce, bitfile *ld) +{ + uint8_t i; + + memset(pce, 0, sizeof(program_config)); + + pce->channels = 0; + + pce->element_instance_tag = (uint8_t)faad_getbits(ld, 4 + DEBUGVAR(1,10,"program_config_element(): element_instance_tag")); + + pce->object_type = (uint8_t)faad_getbits(ld, 2 + DEBUGVAR(1,11,"program_config_element(): object_type")); + pce->sf_index = (uint8_t)faad_getbits(ld, 4 + DEBUGVAR(1,12,"program_config_element(): sf_index")); + pce->num_front_channel_elements = (uint8_t)faad_getbits(ld, 4 + DEBUGVAR(1,13,"program_config_element(): num_front_channel_elements")); + pce->num_side_channel_elements = (uint8_t)faad_getbits(ld, 4 + DEBUGVAR(1,14,"program_config_element(): num_side_channel_elements")); + pce->num_back_channel_elements = (uint8_t)faad_getbits(ld, 4 + DEBUGVAR(1,15,"program_config_element(): num_back_channel_elements")); + pce->num_lfe_channel_elements = (uint8_t)faad_getbits(ld, 2 + DEBUGVAR(1,16,"program_config_element(): num_lfe_channel_elements")); + pce->num_assoc_data_elements = (uint8_t)faad_getbits(ld, 3 + DEBUGVAR(1,17,"program_config_element(): num_assoc_data_elements")); + pce->num_valid_cc_elements = (uint8_t)faad_getbits(ld, 4 + DEBUGVAR(1,18,"program_config_element(): num_valid_cc_elements")); + + pce->mono_mixdown_present = faad_get1bit(ld + DEBUGVAR(1,19,"program_config_element(): mono_mixdown_present")); + if (pce->mono_mixdown_present == 1) + { + pce->mono_mixdown_element_number = (uint8_t)faad_getbits(ld, 4 + DEBUGVAR(1,20,"program_config_element(): mono_mixdown_element_number")); + } + + pce->stereo_mixdown_present = faad_get1bit(ld + DEBUGVAR(1,21,"program_config_element(): stereo_mixdown_present")); + if (pce->stereo_mixdown_present == 1) + { + pce->stereo_mixdown_element_number = (uint8_t)faad_getbits(ld, 4 + DEBUGVAR(1,22,"program_config_element(): stereo_mixdown_element_number")); + } + + pce->matrix_mixdown_idx_present = faad_get1bit(ld + DEBUGVAR(1,23,"program_config_element(): matrix_mixdown_idx_present")); + if (pce->matrix_mixdown_idx_present == 1) + { + pce->matrix_mixdown_idx = (uint8_t)faad_getbits(ld, 2 + DEBUGVAR(1,24,"program_config_element(): matrix_mixdown_idx")); + pce->pseudo_surround_enable = faad_get1bit(ld + DEBUGVAR(1,25,"program_config_element(): pseudo_surround_enable")); + } + + for (i = 0; i < pce->num_front_channel_elements; i++) + { + pce->front_element_is_cpe[i] = faad_get1bit(ld + DEBUGVAR(1,26,"program_config_element(): front_element_is_cpe")); + pce->front_element_tag_select[i] = (uint8_t)faad_getbits(ld, 4 + DEBUGVAR(1,27,"program_config_element(): front_element_tag_select")); + + if (pce->front_element_is_cpe[i] & 1) + { + pce->cpe_channel[pce->front_element_tag_select[i]] = pce->channels; + pce->num_front_channels += 2; + pce->channels += 2; + } else { + pce->sce_channel[pce->front_element_tag_select[i]] = pce->channels; + pce->num_front_channels++; + pce->channels++; + } + } + + for (i = 0; i < pce->num_side_channel_elements; i++) + { + pce->side_element_is_cpe[i] = faad_get1bit(ld + DEBUGVAR(1,28,"program_config_element(): side_element_is_cpe")); + pce->side_element_tag_select[i] = (uint8_t)faad_getbits(ld, 4 + DEBUGVAR(1,29,"program_config_element(): side_element_tag_select")); + + if (pce->side_element_is_cpe[i] & 1) + { + pce->cpe_channel[pce->side_element_tag_select[i]] = pce->channels; + pce->num_side_channels += 2; + pce->channels += 2; + } else { + pce->sce_channel[pce->side_element_tag_select[i]] = pce->channels; + pce->num_side_channels++; + pce->channels++; + } + } + + for (i = 0; i < pce->num_back_channel_elements; i++) + { + pce->back_element_is_cpe[i] = faad_get1bit(ld + DEBUGVAR(1,30,"program_config_element(): back_element_is_cpe")); + pce->back_element_tag_select[i] = (uint8_t)faad_getbits(ld, 4 + DEBUGVAR(1,31,"program_config_element(): back_element_tag_select")); + + if (pce->back_element_is_cpe[i] & 1) + { + pce->cpe_channel[pce->back_element_tag_select[i]] = pce->channels; + pce->channels += 2; + pce->num_back_channels += 2; + } else { + pce->sce_channel[pce->back_element_tag_select[i]] = pce->channels; + pce->num_back_channels++; + pce->channels++; + } + } + + for (i = 0; i < pce->num_lfe_channel_elements; i++) + { + pce->lfe_element_tag_select[i] = (uint8_t)faad_getbits(ld, 4 + DEBUGVAR(1,32,"program_config_element(): lfe_element_tag_select")); + + pce->sce_channel[pce->lfe_element_tag_select[i]] = pce->channels; + pce->num_lfe_channels++; + pce->channels++; + } + + for (i = 0; i < pce->num_assoc_data_elements; i++) + pce->assoc_data_element_tag_select[i] = (uint8_t)faad_getbits(ld, 4 + DEBUGVAR(1,33,"program_config_element(): assoc_data_element_tag_select")); + + for (i = 0; i < pce->num_valid_cc_elements; i++) + { + pce->cc_element_is_ind_sw[i] = faad_get1bit(ld + DEBUGVAR(1,34,"program_config_element(): cc_element_is_ind_sw")); + pce->valid_cc_element_tag_select[i] = (uint8_t)faad_getbits(ld, 4 + DEBUGVAR(1,35,"program_config_element(): valid_cc_element_tag_select")); + } + + faad_byte_align(ld); + + pce->comment_field_bytes = (uint8_t)faad_getbits(ld, 8 + DEBUGVAR(1,36,"program_config_element(): comment_field_bytes")); + + for (i = 0; i < pce->comment_field_bytes; i++) + { + pce->comment_field_data[i] = (uint8_t)faad_getbits(ld, 8 + DEBUGVAR(1,37,"program_config_element(): comment_field_data")); + } + pce->comment_field_data[i] = 0; + + if (pce->channels > MAX_CHANNELS) + return 22; + + return 0; +} + +static void decode_sce_lfe(NeAACDecHandle hDecoder, + NeAACDecFrameInfo *hInfo, bitfile *ld, + uint8_t id_syn_ele) +{ + uint8_t channels = hDecoder->fr_channels; + uint8_t tag = 0; + + if (channels+1 > MAX_CHANNELS) + { + hInfo->error = 12; + return; + } + if (hDecoder->fr_ch_ele+1 > MAX_SYNTAX_ELEMENTS) + { + hInfo->error = 13; + return; + } + + /* for SCE hDecoder->element_output_channels[] is not set here because this + can become 2 when some form of Parametric Stereo coding is used + */ + + /* save the syntax element id */ + hDecoder->element_id[hDecoder->fr_ch_ele] = id_syn_ele; + + /* decode the element */ + hInfo->error = single_lfe_channel_element(hDecoder, ld, channels, &tag); + + /* map output channels position to internal data channels */ + if (hDecoder->element_output_channels[hDecoder->fr_ch_ele] == 2) + { + /* this might be faulty when pce_set is true */ + hDecoder->internal_channel[channels] = channels; + hDecoder->internal_channel[channels+1] = channels+1; + } else { + if (hDecoder->pce_set) + hDecoder->internal_channel[hDecoder->pce.sce_channel[tag]] = channels; + else + hDecoder->internal_channel[channels] = channels; + } + + hDecoder->fr_channels += hDecoder->element_output_channels[hDecoder->fr_ch_ele]; + hDecoder->fr_ch_ele++; +} + +static void decode_cpe(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hInfo, bitfile *ld, + uint8_t id_syn_ele) +{ + uint8_t channels = hDecoder->fr_channels; + uint8_t tag = 0; + + if (channels+2 > MAX_CHANNELS) + { + hInfo->error = 12; + return; + } + if (hDecoder->fr_ch_ele+1 > MAX_SYNTAX_ELEMENTS) + { + hInfo->error = 13; + return; + } + + /* for CPE the number of output channels is always 2 */ + if (hDecoder->element_output_channels[hDecoder->fr_ch_ele] == 0) + { + /* element_output_channels not set yet */ + hDecoder->element_output_channels[hDecoder->fr_ch_ele] = 2; + } else if (hDecoder->element_output_channels[hDecoder->fr_ch_ele] != 2) { + /* element inconsistency */ + hInfo->error = 21; + return; + } + + /* save the syntax element id */ + hDecoder->element_id[hDecoder->fr_ch_ele] = id_syn_ele; + + /* decode the element */ + hInfo->error = channel_pair_element(hDecoder, ld, channels, &tag); + + /* map output channel position to internal data channels */ + if (hDecoder->pce_set) + { + hDecoder->internal_channel[hDecoder->pce.cpe_channel[tag]] = channels; + hDecoder->internal_channel[hDecoder->pce.cpe_channel[tag]+1] = channels+1; + } else { + hDecoder->internal_channel[channels] = channels; + hDecoder->internal_channel[channels+1] = channels+1; + } + + hDecoder->fr_channels += 2; + hDecoder->fr_ch_ele++; +} + +void raw_data_block(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hInfo, + bitfile *ld, program_config *pce, drc_info *drc) +{ + uint8_t id_syn_ele; + + hDecoder->fr_channels = 0; + hDecoder->fr_ch_ele = 0; + hDecoder->first_syn_ele = 25; + hDecoder->has_lfe = 0; + +#ifdef ERROR_RESILIENCE + if (hDecoder->object_type < ER_OBJECT_START) + { +#endif + /* Table 4.4.3: raw_data_block() */ + while ((id_syn_ele = (uint8_t)faad_getbits(ld, LEN_SE_ID + DEBUGVAR(1,4,"NeAACDecDecode(): id_syn_ele"))) != ID_END) + { + switch (id_syn_ele) { + case ID_SCE: + if (hDecoder->first_syn_ele == 25) hDecoder->first_syn_ele = id_syn_ele; + decode_sce_lfe(hDecoder, hInfo, ld, id_syn_ele); + if (hInfo->error > 0) + return; + break; + case ID_CPE: + if (hDecoder->first_syn_ele == 25) hDecoder->first_syn_ele = id_syn_ele; + decode_cpe(hDecoder, hInfo, ld, id_syn_ele); + if (hInfo->error > 0) + return; + break; + case ID_LFE: + hDecoder->has_lfe++; + decode_sce_lfe(hDecoder, hInfo, ld, id_syn_ele); + if (hInfo->error > 0) + return; + break; + case ID_CCE: /* not implemented yet, but skip the bits */ +#ifdef COUPLING_DEC + hInfo->error = coupling_channel_element(hDecoder, ld); +#else + hInfo->error = 6; +#endif + if (hInfo->error > 0) + return; + break; + case ID_DSE: + data_stream_element(hDecoder, ld); + break; + case ID_PCE: + /* 14496-4: 5.6.4.1.2.1.3: */ + /* program_configuration_element()'s in access units shall be ignored */ + program_config_element(pce, ld); + //if ((hInfo->error = program_config_element(pce, ld)) > 0) + // return; + //hDecoder->pce_set = 1; + break; + case ID_FIL: + /* one sbr_info describes a channel_element not a channel! */ + /* if we encounter SBR data here: error */ + /* SBR data will be read directly in the SCE/LFE/CPE element */ + if ((hInfo->error = fill_element(hDecoder, ld, drc +#ifdef SBR_DEC + , INVALID_SBR_ELEMENT +#endif + )) > 0) + return; + break; + } + } +#ifdef ERROR_RESILIENCE + } else { + /* Table 262: er_raw_data_block() */ + switch (hDecoder->channelConfiguration) + { + case 1: + decode_sce_lfe(hDecoder, hInfo, ld, ID_SCE); + if (hInfo->error > 0) + return; + break; + case 2: + decode_cpe(hDecoder, hInfo, ld, ID_CPE); + if (hInfo->error > 0) + return; + break; + case 3: + decode_sce_lfe(hDecoder, hInfo, ld, ID_SCE); + decode_cpe(hDecoder, hInfo, ld, ID_CPE); + if (hInfo->error > 0) + return; + break; + case 4: + decode_sce_lfe(hDecoder, hInfo, ld, ID_SCE); + decode_cpe(hDecoder, hInfo, ld, ID_CPE); + decode_sce_lfe(hDecoder, hInfo, ld, ID_SCE); + if (hInfo->error > 0) + return; + break; + case 5: + decode_sce_lfe(hDecoder, hInfo, ld, ID_SCE); + decode_cpe(hDecoder, hInfo, ld, ID_CPE); + decode_cpe(hDecoder, hInfo, ld, ID_CPE); + if (hInfo->error > 0) + return; + break; + case 6: + decode_sce_lfe(hDecoder, hInfo, ld, ID_SCE); + decode_cpe(hDecoder, hInfo, ld, ID_CPE); + decode_cpe(hDecoder, hInfo, ld, ID_CPE); + decode_sce_lfe(hDecoder, hInfo, ld, ID_LFE); + if (hInfo->error > 0) + return; + break; + case 7: /* 8 channels */ + decode_sce_lfe(hDecoder, hInfo, ld, ID_SCE); + decode_cpe(hDecoder, hInfo, ld, ID_CPE); + decode_cpe(hDecoder, hInfo, ld, ID_CPE); + decode_cpe(hDecoder, hInfo, ld, ID_CPE); + decode_sce_lfe(hDecoder, hInfo, ld, ID_LFE); + if (hInfo->error > 0) + return; + break; + default: + hInfo->error = 7; + return; + } +#if 0 + cnt = bits_to_decode() / 8; + while (cnt >= 1) + { + cnt -= extension_payload(cnt); + } +#endif + } +#endif + + /* new in corrigendum 14496-3:2002 */ +#ifdef DRM + if (hDecoder->object_type != DRM_ER_LC) +#endif + { + faad_byte_align(ld); + } + + return; +} + +/* Table 4.4.4 and */ +/* Table 4.4.9 */ +int16_t spec_data[FRAME_LEN] MEM_ALIGN_ATTR = {0}; +element sce; +static uint8_t single_lfe_channel_element(NeAACDecHandle hDecoder, bitfile *ld, + uint8_t channel, uint8_t *tag) +{ + uint8_t retval = 0; + ic_stream *ics = &(sce.ics1); + + memset(spec_data,0,sizeof(spec_data)); + memset(&sce,0,sizeof(sce)); + sce.element_instance_tag = (uint8_t)faad_getbits(ld, LEN_TAG + DEBUGVAR(1,38,"single_lfe_channel_element(): element_instance_tag")); + + *tag = sce.element_instance_tag; + sce.channel = channel; + sce.paired_channel = -1; + + retval = individual_channel_stream(hDecoder, &sce, ld, ics, 0, spec_data); + if (retval > 0) + return retval; + +#ifdef SBR_DEC + /* check if next bitstream element is a fill element */ + /* if so, read it now so SBR decoding can be done in case of a file with SBR */ + if (faad_showbits(ld, LEN_SE_ID) == ID_FIL) + { + faad_flushbits(ld, LEN_SE_ID); + + /* one sbr_info describes a channel_element not a channel! */ + if ((retval = fill_element(hDecoder, ld, hDecoder->drc, hDecoder->fr_ch_ele)) > 0) + { + return retval; + } + } +#endif + + /* noiseless coding is done, spectral reconstruction is done now */ + retval = reconstruct_single_channel(hDecoder, ics, &sce, spec_data); + if (retval > 0) + return retval; + + return 0; +} + +/* Table 4.4.5 */ + +int16_t spec_data1[FRAME_LEN] IBSS_ATTR MEM_ALIGN_ATTR; +int16_t spec_data2[FRAME_LEN] IBSS_ATTR MEM_ALIGN_ATTR; +element cpe; +static uint8_t channel_pair_element(NeAACDecHandle hDecoder, bitfile *ld, + uint8_t channels, uint8_t *tag) +{ + ic_stream *ics1 = &(cpe.ics1); + ic_stream *ics2 = &(cpe.ics2); + uint8_t result; + + memset(spec_data1,0,sizeof(spec_data1)); + memset(spec_data2,0,sizeof(spec_data2)); + memset(&cpe,0,sizeof(cpe)); + cpe.channel = channels; + cpe.paired_channel = channels+1; + + cpe.element_instance_tag = (uint8_t)faad_getbits(ld, LEN_TAG + DEBUGVAR(1,39,"channel_pair_element(): element_instance_tag")); + *tag = cpe.element_instance_tag; + + if ((cpe.common_window = faad_get1bit(ld + DEBUGVAR(1,40,"channel_pair_element(): common_window"))) & 1) + { + /* both channels have common ics information */ + if ((result = ics_info(hDecoder, ics1, ld, cpe.common_window)) > 0) + return result; + + ics1->ms_mask_present = (uint8_t)faad_getbits(ld, 2 + DEBUGVAR(1,41,"channel_pair_element(): ms_mask_present")); + if (ics1->ms_mask_present == 1) + { + uint8_t g, sfb; + for (g = 0; g < ics1->num_window_groups; g++) + { + for (sfb = 0; sfb < ics1->max_sfb; sfb++) + { + ics1->ms_used[g][sfb] = faad_get1bit(ld + DEBUGVAR(1,42,"channel_pair_element(): faad_get1bit")); + } + } + } + +#ifdef ERROR_RESILIENCE + if ((hDecoder->object_type >= ER_OBJECT_START) && (ics1->predictor_data_present)) + { + if (( +#ifdef LTP_DEC + ics1->ltp.data_present = +#endif + faad_get1bit(ld DEBUGVAR(1,50,"channel_pair_element(): ltp.data_present"))) & 1) + { +#ifdef LTP_DEC + if ((result = ltp_data(hDecoder, ics1, &(ics1->ltp), ld)) > 0) + { + return result; + } +#else + return 26; +#endif + } + } +#endif + + memcpy(ics2, ics1, sizeof(ic_stream)); + } else { + ics1->ms_mask_present = 0; + } + + if ((result = individual_channel_stream(hDecoder, &cpe, ld, ics1, + 0, spec_data1)) > 0) + { + return result; + } + +#ifdef ERROR_RESILIENCE + if (cpe.common_window && (hDecoder->object_type >= ER_OBJECT_START) && + (ics1->predictor_data_present)) + { + if (( +#ifdef LTP_DEC + ics1->ltp2.data_present = +#endif + faad_get1bit(ld DEBUGVAR(1,50,"channel_pair_element(): ltp.data_present"))) & 1) + { +#ifdef LTP_DEC + if ((result = ltp_data(hDecoder, ics1, &(ics1->ltp2), ld)) > 0) + { + return result; + } +#else + return 26; +#endif + } + } +#endif + + if ((result = individual_channel_stream(hDecoder, &cpe, ld, ics2, + 0, spec_data2)) > 0) + { + return result; + } + +#ifdef SBR_DEC + /* check if next bitstream element is a fill element */ + /* if so, read it now so SBR decoding can be done in case of a file with SBR */ + if (faad_showbits(ld, LEN_SE_ID) == ID_FIL) + { + faad_flushbits(ld, LEN_SE_ID); + + /* one sbr_info describes a channel_element not a channel! */ + if ((result = fill_element(hDecoder, ld, hDecoder->drc, hDecoder->fr_ch_ele)) > 0) + { + return result; + } + } +#endif + + /* noiseless coding is done, spectral reconstruction is done now */ + if ((result = reconstruct_channel_pair(hDecoder, ics1, ics2, &cpe, + spec_data1, spec_data2)) > 0) + { + return result; + } + + return 0; +} + +/* Table 4.4.6 */ +static uint8_t ics_info(NeAACDecHandle hDecoder, ic_stream *ics, bitfile *ld, + uint8_t common_window) +{ + uint8_t retval = 0; + + /* ics->ics_reserved_bit = */ faad_get1bit(ld + DEBUGVAR(1,43,"ics_info(): ics_reserved_bit")); + ics->window_sequence = (uint8_t)faad_getbits(ld, 2 + DEBUGVAR(1,44,"ics_info(): window_sequence")); + ics->window_shape = faad_get1bit(ld + DEBUGVAR(1,45,"ics_info(): window_shape")); + + if (ics->window_sequence == EIGHT_SHORT_SEQUENCE) + { + ics->max_sfb = (uint8_t)faad_getbits(ld, 4 + DEBUGVAR(1,46,"ics_info(): max_sfb (short)")); + ics->scale_factor_grouping = (uint8_t)faad_getbits(ld, 7 + DEBUGVAR(1,47,"ics_info(): scale_factor_grouping")); + } else { + ics->max_sfb = (uint8_t)faad_getbits(ld, 6 + DEBUGVAR(1,48,"ics_info(): max_sfb (long)")); + } + + /* get the grouping information */ + if ((retval = window_grouping_info(hDecoder, ics)) > 0) + return retval; + + /* should be an error */ + /* check the range of max_sfb */ + if (ics->max_sfb > ics->num_swb) + return 16; + + if (ics->window_sequence != EIGHT_SHORT_SEQUENCE) + { + if ((ics->predictor_data_present = faad_get1bit(ld + DEBUGVAR(1,49,"ics_info(): predictor_data_present"))) & 1) + { + if (hDecoder->object_type == MAIN) /* MPEG2 style AAC predictor */ + { + uint8_t sfb; + + uint8_t limit = min(ics->max_sfb, max_pred_sfb(hDecoder->sf_index)); +#ifdef MAIN_DEC + ics->pred.limit = limit; +#endif + + if (( +#ifdef MAIN_DEC + ics->pred.predictor_reset = +#endif + faad_get1bit(ld DEBUGVAR(1,53,"ics_info(): pred.predictor_reset"))) & 1) + { +#ifdef MAIN_DEC + ics->pred.predictor_reset_group_number = + (uint8_t) +#endif + faad_getbits(ld, 5 DEBUGVAR(1,54,"ics_info(): pred.predictor_reset_group_number")); + } + + for (sfb = 0; sfb < limit; sfb++) + { +#ifdef MAIN_DEC + ics->pred.prediction_used[sfb] = +#endif + faad_get1bit(ld DEBUGVAR(1,55,"ics_info(): pred.prediction_used")); + } + } +#ifdef LTP_DEC + else { /* Long Term Prediction */ + if (hDecoder->object_type < ER_OBJECT_START) + { + if ((ics->ltp.data_present = faad_get1bit(ld + DEBUGVAR(1,50,"ics_info(): ltp.data_present"))) & 1) + { + if ((retval = ltp_data(hDecoder, ics, &(ics->ltp), ld)) > 0) + { + return retval; + } + } + if (common_window) + { + if ((ics->ltp2.data_present = faad_get1bit(ld + DEBUGVAR(1,51,"ics_info(): ltp2.data_present"))) & 1) + { + if ((retval = ltp_data(hDecoder, ics, &(ics->ltp2), ld)) > 0) + { + return retval; + } + } + } + } +#ifdef ERROR_RESILIENCE + if (!common_window && (hDecoder->object_type >= ER_OBJECT_START)) + { + if ((ics->ltp.data_present = faad_get1bit(ld + DEBUGVAR(1,50,"ics_info(): ltp.data_present"))) & 1) + { + ltp_data(hDecoder, ics, &(ics->ltp), ld); + } + } +#endif + } +#else + (void) common_window; +#endif + } + } + + return retval; +} + +/* Table 4.4.7 */ +static uint8_t pulse_data(ic_stream *ics, pulse_info *pul, bitfile *ld) +{ + uint8_t i; + + pul->number_pulse = (uint8_t)faad_getbits(ld, 2 + DEBUGVAR(1,56,"pulse_data(): number_pulse")); + pul->pulse_start_sfb = (uint8_t)faad_getbits(ld, 6 + DEBUGVAR(1,57,"pulse_data(): pulse_start_sfb")); + + /* check the range of pulse_start_sfb */ + if (pul->pulse_start_sfb > ics->num_swb) + return 16; + + for (i = 0; i < pul->number_pulse+1; i++) + { + pul->pulse_offset[i] = (uint8_t)faad_getbits(ld, 5 + DEBUGVAR(1,58,"pulse_data(): pulse_offset")); +#if 0 + printf("%d\n", pul->pulse_offset[i]); +#endif + pul->pulse_amp[i] = (uint8_t)faad_getbits(ld, 4 + DEBUGVAR(1,59,"pulse_data(): pulse_amp")); +#if 0 + printf("%d\n", pul->pulse_amp[i]); +#endif + } + + return 0; +} + +#ifdef COUPLING_DEC +/* Table 4.4.8: Currently just for skipping the bits... */ +static uint8_t coupling_channel_element(NeAACDecHandle hDecoder, bitfile *ld) +{ + uint8_t c, result = 0; + uint8_t ind_sw_cce_flag = 0; + uint8_t num_gain_element_lists = 0; + uint8_t num_coupled_elements = 0; + + element el_empty = {0}; + ic_stream ics_empty = {0}; + static int16_t sh_data[FRAME_LEN]; + + c = faad_getbits(ld, LEN_TAG + DEBUGVAR(1,900,"coupling_channel_element(): element_instance_tag")); + + ind_sw_cce_flag = faad_get1bit(ld + DEBUGVAR(1,901,"coupling_channel_element(): ind_sw_cce_flag")); + num_coupled_elements = faad_getbits(ld, 3 + DEBUGVAR(1,902,"coupling_channel_element(): num_coupled_elements")); + + for (c = 0; c < num_coupled_elements + 1; c++) + { + uint8_t cc_target_is_cpe, cc_target_tag_select; + + num_gain_element_lists++; + + cc_target_is_cpe = faad_get1bit(ld + DEBUGVAR(1,903,"coupling_channel_element(): cc_target_is_cpe")); + cc_target_tag_select = faad_getbits(ld, 4 + DEBUGVAR(1,904,"coupling_channel_element(): cc_target_tag_select")); + + if (cc_target_is_cpe) + { + uint8_t cc_l = faad_get1bit(ld + DEBUGVAR(1,905,"coupling_channel_element(): cc_l")); + uint8_t cc_r = faad_get1bit(ld + DEBUGVAR(1,906,"coupling_channel_element(): cc_r")); + + if (cc_l && cc_r) + num_gain_element_lists++; + } + } + + faad_get1bit(ld + DEBUGVAR(1,907,"coupling_channel_element(): cc_domain")); + faad_get1bit(ld + DEBUGVAR(1,908,"coupling_channel_element(): gain_element_sign")); + faad_getbits(ld, 2 + DEBUGVAR(1,909,"coupling_channel_element(): gain_element_scale")); + + if ((result = individual_channel_stream(hDecoder, &el_empty, ld, &ics_empty, + 0, sh_data)) > 0) + { + return result; + } + + for (c = 1; c < num_gain_element_lists; c++) + { + uint8_t cge; + + if (ind_sw_cce_flag) + { + cge = 1; + } else { + cge = faad_get1bit(ld + DEBUGVAR(1,910,"coupling_channel_element(): common_gain_element_present")); + } + + if (cge) + { + huffman_scale_factor(ld); + } else { + uint8_t g, sfb; + + for (g = 0; g < ics_empty.num_window_groups; g++) + { + for (sfb = 0; sfb < ics_empty.max_sfb; sfb++) + { + if (ics_empty.sfb_cb[g][sfb] != ZERO_HCB) + huffman_scale_factor(ld); + } + } + } + } + + return 0; +} +#endif + +/* Table 4.4.10 */ +static uint16_t data_stream_element(NeAACDecHandle hDecoder, bitfile *ld) +{ + uint8_t byte_aligned; + uint16_t i, count; + + (void)hDecoder; + + /* element_instance_tag = */ faad_getbits(ld, LEN_TAG + DEBUGVAR(1,60,"data_stream_element(): element_instance_tag")); + byte_aligned = faad_get1bit(ld + DEBUGVAR(1,61,"data_stream_element(): byte_aligned")); + count = (uint16_t)faad_getbits(ld, 8 + DEBUGVAR(1,62,"data_stream_element(): count")); + if (count == 255) + { + count += (uint16_t)faad_getbits(ld, 8 + DEBUGVAR(1,63,"data_stream_element(): extra count")); + } + if (byte_aligned) + faad_byte_align(ld); + + for (i = 0; i < count; i++) + { + faad_getbits(ld, LEN_BYTE + DEBUGVAR(1,64,"data_stream_element(): data_stream_byte")); + } + + return count; +} + +/* Table 4.4.11 */ +static uint8_t fill_element(NeAACDecHandle hDecoder, bitfile *ld, drc_info *drc +#ifdef SBR_DEC + ,uint8_t sbr_ele +#endif + ) +{ + uint16_t count; +#ifdef SBR_DEC + uint8_t bs_extension_type; +#endif + + count = (uint16_t)faad_getbits(ld, 4 + DEBUGVAR(1,65,"fill_element(): count")); + if (count == 15) + { + count += (uint16_t)faad_getbits(ld, 8 + DEBUGVAR(1,66,"fill_element(): extra count")) - 1; + } + + if (count > 0) + { +#ifdef SBR_DEC + bs_extension_type = (uint8_t)faad_showbits(ld, 4); + + if ((bs_extension_type == EXT_SBR_DATA) || + (bs_extension_type == EXT_SBR_DATA_CRC)) + { + if (sbr_ele == INVALID_SBR_ELEMENT) + return 24; + + if (!hDecoder->sbr[sbr_ele]) + { + hDecoder->sbr[sbr_ele] = sbrDecodeInit(hDecoder->frameLength, + hDecoder->element_id[sbr_ele], sbr_ele, + 2*get_sample_rate(hDecoder->sf_index), + hDecoder->downSampledSBR, 0); +#ifndef FAAD_STATIC_ALLOC + if (hDecoder->sbr[sbr_ele] == NULL) + { + /* could not allocate memory */ + return 28; + } +#endif + } + + hDecoder->sbr_present_flag = 1; + + /* parse the SBR data */ + hDecoder->sbr[sbr_ele]->ret = sbr_extension_data(ld, hDecoder->sbr[sbr_ele], count); + +#if 0 + if (hDecoder->sbr[sbr_ele]->ret > 0) + { + printf("%s\n", NeAACDecGetErrorMessage(hDecoder->sbr[sbr_ele]->ret)); + } +#endif + +#if (defined(PS_DEC) || defined(DRM_PS)) + if (hDecoder->sbr[sbr_ele]->ps_used) + { + hDecoder->ps_used[sbr_ele] = 1; + + /* set element independent flag to 1 as well */ + hDecoder->ps_used_global = 1; + } +#endif + } else { +#else + (void)hDecoder; +#endif + while (count > 0) + { + count -= extension_payload(ld, drc, count); + } +#ifdef SBR_DEC + } +#endif + } + + return 0; +} + +/* Table 4.4.12 */ +#ifdef SSR_DEC +static void gain_control_data(bitfile *ld, ic_stream *ics) +{ + uint8_t bd, wd, ad; + ssr_info *ssr = &(ics->ssr); + + ssr->max_band = (uint8_t)faad_getbits(ld, 2 + DEBUGVAR(1,1000,"gain_control_data(): max_band")); + + if (ics->window_sequence == ONLY_LONG_SEQUENCE) + { + for (bd = 1; bd <= ssr->max_band; bd++) + { + for (wd = 0; wd < 1; wd++) + { + ssr->adjust_num[bd][wd] = (uint8_t)faad_getbits(ld, 3 + DEBUGVAR(1,1001,"gain_control_data(): adjust_num")); + + for (ad = 0; ad < ssr->adjust_num[bd][wd]; ad++) + { + ssr->alevcode[bd][wd][ad] = (uint8_t)faad_getbits(ld, 4 + DEBUGVAR(1,1002,"gain_control_data(): alevcode")); + ssr->aloccode[bd][wd][ad] = (uint8_t)faad_getbits(ld, 5 + DEBUGVAR(1,1003,"gain_control_data(): aloccode")); + } + } + } + } else if (ics->window_sequence == LONG_START_SEQUENCE) { + for (bd = 1; bd <= ssr->max_band; bd++) + { + for (wd = 0; wd < 2; wd++) + { + ssr->adjust_num[bd][wd] = (uint8_t)faad_getbits(ld, 3 + DEBUGVAR(1,1001,"gain_control_data(): adjust_num")); + + for (ad = 0; ad < ssr->adjust_num[bd][wd]; ad++) + { + ssr->alevcode[bd][wd][ad] = (uint8_t)faad_getbits(ld, 4 + DEBUGVAR(1,1002,"gain_control_data(): alevcode")); + if (wd == 0) + { + ssr->aloccode[bd][wd][ad] = (uint8_t)faad_getbits(ld, 4 + DEBUGVAR(1,1003,"gain_control_data(): aloccode")); + } else { + ssr->aloccode[bd][wd][ad] = (uint8_t)faad_getbits(ld, 2 + DEBUGVAR(1,1003,"gain_control_data(): aloccode")); + } + } + } + } + } else if (ics->window_sequence == EIGHT_SHORT_SEQUENCE) { + for (bd = 1; bd <= ssr->max_band; bd++) + { + for (wd = 0; wd < 8; wd++) + { + ssr->adjust_num[bd][wd] = (uint8_t)faad_getbits(ld, 3 + DEBUGVAR(1,1001,"gain_control_data(): adjust_num")); + + for (ad = 0; ad < ssr->adjust_num[bd][wd]; ad++) + { + ssr->alevcode[bd][wd][ad] = (uint8_t)faad_getbits(ld, 4 + DEBUGVAR(1,1002,"gain_control_data(): alevcode")); + ssr->aloccode[bd][wd][ad] = (uint8_t)faad_getbits(ld, 2 + DEBUGVAR(1,1003,"gain_control_data(): aloccode")); + } + } + } + } else if (ics->window_sequence == LONG_STOP_SEQUENCE) { + for (bd = 1; bd <= ssr->max_band; bd++) + { + for (wd = 0; wd < 2; wd++) + { + ssr->adjust_num[bd][wd] = (uint8_t)faad_getbits(ld, 3 + DEBUGVAR(1,1001,"gain_control_data(): adjust_num")); + + for (ad = 0; ad < ssr->adjust_num[bd][wd]; ad++) + { + ssr->alevcode[bd][wd][ad] = (uint8_t)faad_getbits(ld, 4 + DEBUGVAR(1,1002,"gain_control_data(): alevcode")); + + if (wd == 0) + { + ssr->aloccode[bd][wd][ad] = (uint8_t)faad_getbits(ld, 4 + DEBUGVAR(1,1003,"gain_control_data(): aloccode")); + } else { + ssr->aloccode[bd][wd][ad] = (uint8_t)faad_getbits(ld, 5 + DEBUGVAR(1,1003,"gain_control_data(): aloccode")); + } + } + } + } + } +} +#endif + +#ifdef SCALABLE_DEC +int16_t spec_data1[FRAME_LEN] MEM_ALIGN_ATTR; +int16_t spec_data2[FRAME_LEN] MEM_ALIGN_ATTR; +/* Table 4.4.13 ASME */ +void aac_scalable_main_element(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hInfo, + bitfile *ld, program_config *pce, drc_info *drc) +{ + uint8_t retval = 0; + uint8_t channels = hDecoder->fr_channels = 0; + uint8_t ch; + uint8_t this_layer_stereo = (hDecoder->channelConfiguration > 1) ? 1 : 0; + element cpe = {0}; + ic_stream *ics1 = &(cpe.ics1); + ic_stream *ics2 = &(cpe.ics2); + int16_t *spec_data; + + memset(spec_data1,0,sizeof(spec_data1)); + memset(spec_data2,0,sizeof(spec_data2)); + hDecoder->fr_ch_ele = 0; + + hInfo->error = aac_scalable_main_header(hDecoder, ics1, ics2, ld, this_layer_stereo); + if (hInfo->error > 0) + return; + + cpe.common_window = 1; + if (this_layer_stereo) + { + hDecoder->element_id[0] = ID_CPE; + if (hDecoder->element_output_channels[hDecoder->fr_ch_ele] == 0) + hDecoder->element_output_channels[hDecoder->fr_ch_ele] = 2; + } else { + hDecoder->element_id[0] = ID_SCE; + } + + for (ch = 0; ch < (this_layer_stereo ? 2 : 1); ch++) + { + ic_stream *ics; + if (ch == 0) + { + ics = ics1; + spec_data = spec_data1; + } else { + ics = ics2; + spec_data = spec_data2; + } + + hInfo->error = individual_channel_stream(hDecoder, &cpe, ld, ics, 1, spec_data); + if (hInfo->error > 0) + return; + } + +#ifdef DRM +#ifdef SBR_DEC + /* In case of DRM we need to read the SBR info before channel reconstruction */ + if ((hDecoder->sbr_present_flag == 1) && (hDecoder->object_type == DRM_ER_LC)) + { + bitfile ld_sbr = {0}; + uint32_t i; + uint16_t count = 0; + uint8_t *revbuffer; + uint8_t *prevbufstart; + uint8_t *pbufend; + + /* all forward bitreading should be finished at this point */ + uint32_t bitsconsumed = faad_get_processed_bits(ld); + uint32_t buffer_size = faad_origbitbuffer_size(ld); + uint8_t *buffer = (uint8_t*)faad_origbitbuffer(ld); + + if (bitsconsumed + 8 > buffer_size*8) + { + hInfo->error = 14; + return; + } + + if (!hDecoder->sbr[0]) + { + hDecoder->sbr[0] = sbrDecodeInit(hDecoder->frameLength, hDecoder->element_id[0], + 2*get_sample_rate(hDecoder->sf_index), 0 /* ds SBR */, 1); +#ifndef FAAD_STATIC_ALLOC + if (hDecoder->sbr[0] == NULL) + { + /* could not allocate memory */ + hInfo->error = 28; + return; + } +#endif + } + + /* Reverse bit reading of SBR data in DRM audio frame */ + revbuffer = (uint8_t*)faad_malloc(buffer_size*sizeof(uint8_t)); + if (revbuffer == NULL) + { + /* could not allocate memory */ + hInfo->error = 28; + return; + } + prevbufstart = revbuffer; + pbufend = &buffer[buffer_size - 1]; + for (i = 0; i < buffer_size; i++) + *prevbufstart++ = tabFlipbits[*pbufend--]; + + /* Set SBR data */ + /* consider 8 bits from AAC-CRC */ + count = (uint16_t)bit2byte(buffer_size*8 - bitsconsumed); + faad_initbits(&ld_sbr, revbuffer, count); + + hDecoder->sbr[0]->sample_rate = get_sample_rate(hDecoder->sf_index); + hDecoder->sbr[0]->sample_rate *= 2; + + faad_getbits(&ld_sbr, 8); /* Skip 8-bit CRC */ + + hDecoder->sbr[0]->ret = sbr_extension_data(&ld_sbr, hDecoder->sbr[0], count); +#if (defined(PS_DEC) || defined(DRM_PS)) + if (hDecoder->sbr[0]->ps_used) + { + hDecoder->ps_used[0] = 1; + hDecoder->ps_used_global = 1; + } +#endif + + /* check CRC */ + /* no need to check it if there was already an error */ + if (hDecoder->sbr[0]->ret == 0) + hDecoder->sbr[0]->ret = (uint8_t)faad_check_CRC(&ld_sbr, (uint16_t)faad_get_processed_bits(&ld_sbr) - 8); + + /* SBR data was corrupted, disable it until the next header */ + if (hDecoder->sbr[0]->ret != 0) + { + hDecoder->sbr[0]->header_count = 0; + } + + faad_endbits(&ld_sbr); + + if (revbuffer) + faad_free(revbuffer); + } +#endif +#endif + + if (this_layer_stereo) + { + hInfo->error = reconstruct_channel_pair(hDecoder, ics1, ics2, &cpe, spec_data1, spec_data2); + if (hInfo->error > 0) + return; + } else { + hInfo->error = reconstruct_single_channel(hDecoder, ics1, &cpe, spec_data1); + if (hInfo->error > 0) + return; + } + + /* map output channels position to internal data channels */ + if (hDecoder->element_output_channels[hDecoder->fr_ch_ele] == 2) + { + /* this might be faulty when pce_set is true */ + hDecoder->internal_channel[channels] = channels; + hDecoder->internal_channel[channels+1] = channels+1; + } else { + hDecoder->internal_channel[channels] = channels; + } + + hDecoder->fr_channels += hDecoder->element_output_channels[hDecoder->fr_ch_ele]; + hDecoder->fr_ch_ele++; + + return; +} + +/* Table 4.4.15 */ +static int8_t aac_scalable_main_header(NeAACDecHandle hDecoder, ic_stream *ics1, ic_stream *ics2, + bitfile *ld, uint8_t this_layer_stereo) +{ + uint8_t retval = 0; + uint8_t ch; + ic_stream *ics; + + /* ics1->ics_reserved_bit = */ faad_get1bit(ld + DEBUGVAR(1,300,"aac_scalable_main_header(): ics_reserved_bits")); + ics1->window_sequence = (uint8_t)faad_getbits(ld, 2 + DEBUGVAR(1,301,"aac_scalable_main_header(): window_sequence")); + ics1->window_shape = faad_get1bit(ld + DEBUGVAR(1,302,"aac_scalable_main_header(): window_shape")); + + if (ics1->window_sequence == EIGHT_SHORT_SEQUENCE) + { + ics1->max_sfb = (uint8_t)faad_getbits(ld, 4 + DEBUGVAR(1,303,"aac_scalable_main_header(): max_sfb (short)")); + ics1->scale_factor_grouping = (uint8_t)faad_getbits(ld, 7 + DEBUGVAR(1,304,"aac_scalable_main_header(): scale_factor_grouping")); + } else { + ics1->max_sfb = (uint8_t)faad_getbits(ld, 6 + DEBUGVAR(1,305,"aac_scalable_main_header(): max_sfb (long)")); + } + + /* get the grouping information */ + if ((retval = window_grouping_info(hDecoder, ics1)) > 0) + return retval; + + /* should be an error */ + /* check the range of max_sfb */ + if (ics1->max_sfb > ics1->num_swb) + return 16; + + if (this_layer_stereo) + { + ics1->ms_mask_present = (uint8_t)faad_getbits(ld, 2 + DEBUGVAR(1,306,"aac_scalable_main_header(): ms_mask_present")); + if (ics1->ms_mask_present == 1) + { + uint8_t g, sfb; + for (g = 0; g < ics1->num_window_groups; g++) + { + for (sfb = 0; sfb < ics1->max_sfb; sfb++) + { + ics1->ms_used[g][sfb] = faad_get1bit(ld + DEBUGVAR(1,307,"aac_scalable_main_header(): faad_get1bit")); + } + } + } + + memcpy(ics2, ics1, sizeof(ic_stream)); + } else { + ics1->ms_mask_present = 0; + } + + if (0) + { + faad_get1bit(ld + DEBUGVAR(1,308,"aac_scalable_main_header(): tns_channel_mono_layer")); + } + + for (ch = 0; ch < (this_layer_stereo ? 2 : 1); ch++) + { + if (ch == 0) + ics = ics1; + else + ics = ics2; + + if ( 1 /*!tvq_layer_pesent || (tns_aac_tvq_en[ch] == 1)*/) + { + if ((ics->tns_data_present = faad_get1bit(ld + DEBUGVAR(1,309,"aac_scalable_main_header(): tns_data_present"))) & 1) + { +#ifdef DRM + /* different order of data units in DRM */ + if (hDecoder->object_type != DRM_ER_LC) +#endif + { + tns_data(ics, &(ics->tns), ld); + } + } + } +#if 0 + if (0 /*core_flag || tvq_layer_pesent*/) + { + if ((ch==0) || ((ch==1) && (core_stereo || tvq_stereo)) + diff_control_data(); + if (mono_stereo_flag) + diff_control_data_lr(); + } else { +#endif + if (( +#ifdef LTP_DEC + ics->ltp.data_present = +#endif + faad_get1bit(ld DEBUGVAR(1,310,"aac_scalable_main_header(): ltp.data_present"))) & 1) + { +#ifdef LTP_DEC + if ((retval = ltp_data(hDecoder, ics, &(ics->ltp), ld)) > 0) + { + return retval; + } +#else + return 26; +#endif + } +#if 0 + } +#endif + } + + return 0; +} +#endif + +/* Table 4.4.24 */ +static uint8_t individual_channel_stream(NeAACDecHandle hDecoder, element *ele, + bitfile *ld, ic_stream *ics, uint8_t scal_flag, + int16_t *spec_data) +{ + uint8_t result; + + ics->global_gain = (uint8_t)faad_getbits(ld, 8 + DEBUGVAR(1,67,"individual_channel_stream(): global_gain")); + + if (!ele->common_window && !scal_flag) + { + if ((result = ics_info(hDecoder, ics, ld, ele->common_window)) > 0) + return result; + } + + if ((result = section_data(hDecoder, ics, ld)) > 0) + return result; + + if ((result = scale_factor_data(hDecoder, ics, ld)) > 0) + return result; + + if (!scal_flag) + { + /** + ** NOTE: It could be that pulse data is available in scalable AAC too, + ** as said in Amendment 1, this could be only the case for ER AAC, + ** though. (have to check this out later) + **/ + /* get pulse data */ + if ((ics->pulse_data_present = faad_get1bit(ld + DEBUGVAR(1,68,"individual_channel_stream(): pulse_data_present"))) & 1) + { + if ((result = pulse_data(ics, &(ics->pul), ld)) > 0) + return result; + } + + /* get tns data */ + if ((ics->tns_data_present = faad_get1bit(ld + DEBUGVAR(1,69,"individual_channel_stream(): tns_data_present"))) & 1) + { +#ifdef ERROR_RESILIENCE + if (hDecoder->object_type < ER_OBJECT_START) +#endif + tns_data(ics, &(ics->tns), ld); + } + + /* get gain control data */ + if ((ics->gain_control_data_present = faad_get1bit(ld + DEBUGVAR(1,70,"individual_channel_stream(): gain_control_data_present"))) & 1) + { +#ifdef SSR_DEC + if (hDecoder->object_type != SSR) + return 1; + else + gain_control_data(ld, ics); +#else + return 1; +#endif + } + } + +#ifdef ERROR_RESILIENCE + if (hDecoder->aacSpectralDataResilienceFlag) + { + ics->length_of_reordered_spectral_data = (uint16_t)faad_getbits(ld, 14 + DEBUGVAR(1,147,"individual_channel_stream(): length_of_reordered_spectral_data")); + + if (hDecoder->channelConfiguration == 2) + { + if (ics->length_of_reordered_spectral_data > 6144) + ics->length_of_reordered_spectral_data = 6144; + } else { + if (ics->length_of_reordered_spectral_data > 12288) + ics->length_of_reordered_spectral_data = 12288; + } + + ics->length_of_longest_codeword = (uint8_t)faad_getbits(ld, 6 + DEBUGVAR(1,148,"individual_channel_stream(): length_of_longest_codeword")); + if (ics->length_of_longest_codeword >= 49) + ics->length_of_longest_codeword = 49; + } + + /* RVLC spectral data is put here */ + if (hDecoder->aacScalefactorDataResilienceFlag) + { + if ((result = rvlc_decode_scale_factors(ics, ld)) > 0) + return result; + } + + if (hDecoder->object_type >= ER_OBJECT_START) + { + if (ics->tns_data_present) + tns_data(ics, &(ics->tns), ld); + } + +#ifdef DRM + /* CRC check */ + if (hDecoder->object_type == DRM_ER_LC) + if ((result = (uint8_t)faad_check_CRC(ld, (uint16_t)faad_get_processed_bits(ld) - 8)) > 0) + return result; +#endif + + if (hDecoder->aacSpectralDataResilienceFlag) + { + /* error resilient spectral data decoding */ + if ((result = reordered_spectral_data(hDecoder, ics, ld, spec_data)) > 0) + { + return result; + } + } else { +#endif + /* decode the spectral data */ + if ((result = spectral_data(hDecoder, ics, ld, spec_data)) > 0) + { + return result; + } +#ifdef ERROR_RESILIENCE + } +#endif + + /* pulse coding reconstruction */ + if (ics->pulse_data_present) + { + if (ics->window_sequence != EIGHT_SHORT_SEQUENCE) + { + if ((result = pulse_decode(ics, spec_data, hDecoder->frameLength)) > 0) + return result; + } else { + return 2; /* pulse coding not allowed for short blocks */ + } + } + + return 0; +} + +/* Table 4.4.25 */ +static uint8_t section_data(NeAACDecHandle hDecoder, ic_stream *ics, bitfile *ld) +{ + uint8_t g; + uint8_t sect_esc_val, sect_bits; + + if (ics->window_sequence == EIGHT_SHORT_SEQUENCE) + sect_bits = 3; + else + sect_bits = 5; + sect_esc_val = (1<max_sfb); + printf(" sect top cb\n"); +#endif + + for (g = 0; g < ics->num_window_groups; g++) + { + uint8_t k = 0; + uint8_t i = 0; + + while (k < ics->max_sfb) + { +#ifdef ERROR_RESILIENCE + uint8_t vcb11 = 0; +#endif + uint8_t sfb; + uint8_t sect_len_incr; + uint16_t sect_len = 0; + uint8_t sect_cb_bits = 4; + + /* if "faad_getbits" detects error and returns "0", "k" is never + incremented and we cannot leave the while loop */ + if ((ld->error != 0) || (ld->no_more_reading)) + return 14; + +#ifdef ERROR_RESILIENCE + if (hDecoder->aacSectionDataResilienceFlag) + sect_cb_bits = 5; +#else + (void) hDecoder; +#endif + + ics->sect_cb[g][i] = (uint8_t)faad_getbits(ld, sect_cb_bits + DEBUGVAR(1,71,"section_data(): sect_cb")); + +#if 0 + printf("%d\n", ics->sect_cb[g][i]); +#endif + + if (ics->sect_cb[g][i] == NOISE_HCB) + ics->noise_used = 1; + +#ifdef ERROR_RESILIENCE + if (hDecoder->aacSectionDataResilienceFlag) + { + if ((ics->sect_cb[g][i] == 11) || + ((ics->sect_cb[g][i] >= 16) && (ics->sect_cb[g][i] <= 32))) + { + vcb11 = 1; + } + } + if (vcb11) + { + sect_len_incr = 1; + } else { +#endif + sect_len_incr = (uint8_t)faad_getbits(ld, sect_bits + DEBUGVAR(1,72,"section_data(): sect_len_incr")); +#ifdef ERROR_RESILIENCE + } +#endif + while ((sect_len_incr == sect_esc_val) /* && + (k+sect_len < ics->max_sfb)*/) + { + sect_len += sect_len_incr; + sect_len_incr = (uint8_t)faad_getbits(ld, sect_bits + DEBUGVAR(1,72,"section_data(): sect_len_incr")); + } + + sect_len += sect_len_incr; + + ics->sect_start[g][i] = k; + ics->sect_end[g][i] = k + sect_len; + +#if 0 + printf("%d\n", ics->sect_start[g][i]); +#endif +#if 0 + printf("%d\n", ics->sect_end[g][i]); +#endif + + if (k + sect_len >= 8*15) + return 15; + if (i >= 8*15) + return 15; + + for (sfb = k; sfb < k + sect_len; sfb++) + { + ics->sfb_cb[g][sfb] = ics->sect_cb[g][i]; +#if 0 + printf("%d\n", ics->sfb_cb[g][sfb]); +#endif + } + +#if 0 + printf(" %6d %6d %6d\n", + i, + ics->sect_end[g][i], + ics->sect_cb[g][i]); +#endif + + k += sect_len; + i++; + } + ics->num_sec[g] = i; +#if 0 + printf("%d\n", ics->num_sec[g]); +#endif + } + +#if 0 + printf("\n"); +#endif + + return 0; +} + +/* + * decode_scale_factors() + * decodes the scalefactors from the bitstream + */ +/* + * All scalefactors (and also the stereo positions and pns energies) are + * transmitted using Huffman coded DPCM relative to the previous active + * scalefactor (respectively previous stereo position or previous pns energy, + * see subclause 4.6.2 and 4.6.3). The first active scalefactor is + * differentially coded relative to the global gain. + */ +static uint8_t decode_scale_factors(ic_stream *ics, bitfile *ld) +{ + uint8_t g, sfb; + int16_t t; + int8_t noise_pcm_flag = 1; + + int16_t scale_factor = ics->global_gain; + int16_t is_position = 0; + int16_t noise_energy = ics->global_gain - 90; + + for (g = 0; g < ics->num_window_groups; g++) + { + for (sfb = 0; sfb < ics->max_sfb; sfb++) + { + switch (ics->sfb_cb[g][sfb]) + { + case ZERO_HCB: /* zero book */ + ics->scale_factors[g][sfb] = 0; +//#define SF_PRINT +#ifdef SF_PRINT + printf("%d\n", ics->scale_factors[g][sfb]); +#endif + break; + case INTENSITY_HCB: /* intensity books */ + case INTENSITY_HCB2: + + /* decode intensity position */ + t = huffman_scale_factor(ld); + is_position += (t - 60); + ics->scale_factors[g][sfb] = is_position; +#ifdef SF_PRINT + printf("%d\n", ics->scale_factors[g][sfb]); +#endif + + break; + case NOISE_HCB: /* noise books */ + + /* decode noise energy */ + if (noise_pcm_flag) + { + noise_pcm_flag = 0; + t = (int16_t)faad_getbits(ld, 9 + DEBUGVAR(1,73,"scale_factor_data(): first noise")) - 256; + } else { + t = huffman_scale_factor(ld); + t -= 60; + } + noise_energy += t; + ics->scale_factors[g][sfb] = noise_energy; +#ifdef SF_PRINT + printf("%d\n", ics->scale_factors[g][sfb]); +#endif + + break; + default: /* spectral books */ + + /* ics->scale_factors[g][sfb] must be between 0 and 255 */ + + ics->scale_factors[g][sfb] = 0; + + /* decode scale factor */ + t = huffman_scale_factor(ld); + scale_factor += (t - 60); + if (scale_factor < 0 || scale_factor > 255) + return 4; + ics->scale_factors[g][sfb] = scale_factor; +#ifdef SF_PRINT + printf("%d\n", ics->scale_factors[g][sfb]); +#endif + + break; + } + } + } + + return 0; +} + +/* Table 4.4.26 */ +static uint8_t scale_factor_data(NeAACDecHandle hDecoder, ic_stream *ics, bitfile *ld) +{ + uint8_t ret = 0; +#ifdef PROFILE + int64_t count = faad_get_ts(); +#endif + +#ifdef ERROR_RESILIENCE + if (!hDecoder->aacScalefactorDataResilienceFlag) + { +#else + (void) hDecoder; +#endif + ret = decode_scale_factors(ics, ld); +#ifdef ERROR_RESILIENCE + } else { + /* In ER AAC the parameters for RVLC are seperated from the actual + data that holds the scale_factors. + Strangely enough, 2 parameters for HCR are put inbetween them. + */ + ret = rvlc_scale_factor_data(ics, ld); + } +#endif + +#ifdef PROFILE + count = faad_get_ts() - count; + hDecoder->scalefac_cycles += count; +#endif + + return ret; +} + +/* Table 4.4.27 */ +static void tns_data(ic_stream *ics, tns_info *tns, bitfile *ld) +{ + uint8_t w, filt, i, start_coef_bits = 0; + int8_t coef_bits; + uint8_t n_filt_bits = 2; + uint8_t length_bits = 6; + uint8_t order_bits = 5; + + if (ics->window_sequence == EIGHT_SHORT_SEQUENCE) + { + n_filt_bits = 1; + length_bits = 4; + order_bits = 3; + } + + for (w = 0; w < ics->num_windows; w++) + { + tns->n_filt[w] = (uint8_t)faad_getbits(ld, n_filt_bits + DEBUGVAR(1,74,"tns_data(): n_filt")); +#if 0 + printf("%d\n", tns->n_filt[w]); +#endif + + if (tns->n_filt[w]) + { + if ((tns->coef_res[w] = faad_get1bit(ld + DEBUGVAR(1,75,"tns_data(): coef_res"))) & 1) + { + start_coef_bits = 4; + } else { + start_coef_bits = 3; + } +#if 0 + printf("%d\n", tns->coef_res[w]); +#endif + } + + for (filt = 0; filt < tns->n_filt[w]; filt++) + { + tns->length[w][filt] = (uint8_t)faad_getbits(ld, length_bits + DEBUGVAR(1,76,"tns_data(): length")); +#if 0 + printf("%d\n", tns->length[w][filt]); +#endif + tns->order[w][filt] = (uint8_t)faad_getbits(ld, order_bits + DEBUGVAR(1,77,"tns_data(): order")); +#if 0 + printf("%d\n", tns->order[w][filt]); +#endif + if (tns->order[w][filt]) + { + tns->direction[w][filt] = faad_get1bit(ld + DEBUGVAR(1,78,"tns_data(): direction")); +#if 0 + printf("%d\n", tns->direction[w][filt]); +#endif + tns->coef_compress[w][filt] = faad_get1bit(ld + DEBUGVAR(1,79,"tns_data(): coef_compress")); +#if 0 + printf("%d\n", tns->coef_compress[w][filt]); +#endif + + coef_bits = start_coef_bits - tns->coef_compress[w][filt]; + for (i = 0; i < tns->order[w][filt]; i++) + { + tns->coef[w][filt][i] = (uint8_t)faad_getbits(ld, coef_bits + DEBUGVAR(1,80,"tns_data(): coef")); +#if 0 + printf("%d\n", tns->coef[w][filt][i]); +#endif + } + } + } + } +} + +#ifdef LTP_DEC +/* Table 4.4.28 */ +static uint8_t ltp_data(NeAACDecHandle hDecoder, ic_stream *ics, ltp_info *ltp, bitfile *ld) +{ + uint8_t sfb, w; + + ltp->lag = 0; + +#ifdef LD_DEC + if (hDecoder->object_type == LD) + { + ltp->lag_update = (uint8_t)faad_getbits(ld, 1 + DEBUGVAR(1,142,"ltp_data(): lag_update")); + + if (ltp->lag_update) + { + ltp->lag = (uint16_t)faad_getbits(ld, 10 + DEBUGVAR(1,81,"ltp_data(): lag")); + } + } else { +#endif + ltp->lag = (uint16_t)faad_getbits(ld, 11 + DEBUGVAR(1,81,"ltp_data(): lag")); +#ifdef LD_DEC + } +#endif + + /* Check length of lag */ + if (ltp->lag > (hDecoder->frameLength << 1)) + return 18; + + ltp->coef = (uint8_t)faad_getbits(ld, 3 + DEBUGVAR(1,82,"ltp_data(): coef")); + + if (ics->window_sequence == EIGHT_SHORT_SEQUENCE) + { + for (w = 0; w < ics->num_windows; w++) + { + if ((ltp->short_used[w] = faad_get1bit(ld + DEBUGVAR(1,83,"ltp_data(): short_used"))) & 1) + { + ltp->short_lag_present[w] = faad_get1bit(ld + DEBUGVAR(1,84,"ltp_data(): short_lag_present")); + if (ltp->short_lag_present[w]) + { + ltp->short_lag[w] = (uint8_t)faad_getbits(ld, 4 + DEBUGVAR(1,85,"ltp_data(): short_lag")); + } + } + } + } else { + ltp->last_band = (ics->max_sfb < MAX_LTP_SFB ? ics->max_sfb : MAX_LTP_SFB); + + for (sfb = 0; sfb < ltp->last_band; sfb++) + { + ltp->long_used[sfb] = faad_get1bit(ld + DEBUGVAR(1,86,"ltp_data(): long_used")); + } + } + + return 0; +} +#endif + +/* Table 4.4.29 */ +static uint8_t spectral_data(NeAACDecHandle hDecoder, ic_stream *ics, bitfile *ld, + int16_t *spectral_data) +{ + int8_t i; + uint8_t g; + uint16_t inc, k, p = 0; + uint8_t groups = 0; + uint8_t sect_cb; + uint8_t result; + uint16_t nshort = hDecoder->frameLength/8; + +#ifdef PROFILE + int64_t count = faad_get_ts(); +#endif + + for(g = 0; g < ics->num_window_groups; g++) + { + p = groups*nshort; + + for (i = 0; i < ics->num_sec[g]; i++) + { + sect_cb = ics->sect_cb[g][i]; + + inc = (sect_cb >= FIRST_PAIR_HCB) ? 2 : 4; + + switch (sect_cb) + { + case ZERO_HCB: + case NOISE_HCB: + case INTENSITY_HCB: + case INTENSITY_HCB2: +//#define SD_PRINT +#ifdef SD_PRINT + { + int j; + for (j = ics->sect_sfb_offset[g][ics->sect_start[g][i]]; j < ics->sect_sfb_offset[g][ics->sect_end[g][i]]; j++) + { + printf("%d\n", 0); + } + } +#endif +//#define SFBO_PRINT +#ifdef SFBO_PRINT + printf("%d\n", ics->sect_sfb_offset[g][ics->sect_start[g][i]]); +#endif + p += (ics->sect_sfb_offset[g][ics->sect_end[g][i]] - + ics->sect_sfb_offset[g][ics->sect_start[g][i]]); + break; + default: +#ifdef SFBO_PRINT + printf("%d\n", ics->sect_sfb_offset[g][ics->sect_start[g][i]]); +#endif + for (k = ics->sect_sfb_offset[g][ics->sect_start[g][i]]; + k < ics->sect_sfb_offset[g][ics->sect_end[g][i]]; k += inc) + { + if ((result = huffman_spectral_data(sect_cb, ld, &spectral_data[p])) > 0) + return result; +#ifdef SD_PRINT + { + int j; + for (j = p; j < p+inc; j++) + { + printf("%d\n", spectral_data[j]); + } + } +#endif + p += inc; + } + break; + } + } + groups += ics->window_group_length[g]; + } + +#ifdef PROFILE + count = faad_get_ts() - count; + hDecoder->spectral_cycles += count; +#endif + + return 0; +} + +/* Table 4.4.30 */ +static uint16_t extension_payload(bitfile *ld, drc_info *drc, uint16_t count) +{ + uint16_t i, n, dataElementLength; + uint8_t dataElementLengthPart; + uint8_t align = 4, data_element_version, loopCounter; + + uint8_t extension_type = (uint8_t)faad_getbits(ld, 4 + DEBUGVAR(1,87,"extension_payload(): extension_type")); + + switch (extension_type) + { + case EXT_DYNAMIC_RANGE: + drc->present = 1; + n = dynamic_range_info(ld, drc); + return n; + case EXT_FILL_DATA: + /* fill_nibble = */ faad_getbits(ld, 4 + DEBUGVAR(1,136,"extension_payload(): fill_nibble")); /* must be "0000" */ + for (i = 0; i < count-1; i++) + { + /* fill_byte[i] = */ faad_getbits(ld, 8 + DEBUGVAR(1,88,"extension_payload(): fill_byte")); /* must be "10100101" */ + } + return count; + case EXT_DATA_ELEMENT: + data_element_version = (uint8_t)faad_getbits(ld, 4 + DEBUGVAR(1,400,"extension_payload(): data_element_version")); + switch (data_element_version) + { + case ANC_DATA: + loopCounter = 0; + dataElementLength = 0; + do { + dataElementLengthPart = (uint8_t)faad_getbits(ld, 8 + DEBUGVAR(1,401,"extension_payload(): dataElementLengthPart")); + dataElementLength += dataElementLengthPart; + loopCounter++; + } while (dataElementLengthPart == 255); + + for (i = 0; i < dataElementLength; i++) + { + /* data_element_byte[i] = */ faad_getbits(ld, 8 + DEBUGVAR(1,402,"extension_payload(): data_element_byte")); + return (dataElementLength+loopCounter+1); + } + default: + align = 0; + } + case EXT_FIL: + default: + faad_getbits(ld, align + DEBUGVAR(1,88,"extension_payload(): fill_nibble")); + for (i = 0; i < count-1; i++) + { + /* other_bits[i] = */ faad_getbits(ld, 8 + DEBUGVAR(1,89,"extension_payload(): fill_bit")); + } + return count; + } +} + +/* Table 4.4.31 */ +static uint8_t dynamic_range_info(bitfile *ld, drc_info *drc) +{ + uint8_t i, n = 1; + uint8_t band_incr; + + drc->num_bands = 1; + + if (faad_get1bit(ld + DEBUGVAR(1,90,"dynamic_range_info(): has instance_tag")) & 1) + { + drc->pce_instance_tag = (uint8_t)faad_getbits(ld, 4 + DEBUGVAR(1,91,"dynamic_range_info(): pce_instance_tag")); + /* drc->drc_tag_reserved_bits = */ faad_getbits(ld, 4 + DEBUGVAR(1,92,"dynamic_range_info(): drc_tag_reserved_bits")); + n++; + } + + drc->excluded_chns_present = faad_get1bit(ld + DEBUGVAR(1,93,"dynamic_range_info(): excluded_chns_present")); + if (drc->excluded_chns_present == 1) + { + n += excluded_channels(ld, drc); + } + + if (faad_get1bit(ld + DEBUGVAR(1,94,"dynamic_range_info(): has bands data")) & 1) + { + band_incr = (uint8_t)faad_getbits(ld, 4 + DEBUGVAR(1,95,"dynamic_range_info(): band_incr")); + /* drc->drc_bands_reserved_bits = */ faad_getbits(ld, 4 + DEBUGVAR(1,96,"dynamic_range_info(): drc_bands_reserved_bits")); + n++; + drc->num_bands += band_incr; + + for (i = 0; i < drc->num_bands; i++) + { + drc->band_top[i] = (uint8_t)faad_getbits(ld, 8 + DEBUGVAR(1,97,"dynamic_range_info(): band_top")); + n++; + } + } + + if (faad_get1bit(ld + DEBUGVAR(1,98,"dynamic_range_info(): has prog_ref_level")) & 1) + { + drc->prog_ref_level = (uint8_t)faad_getbits(ld, 7 + DEBUGVAR(1,99,"dynamic_range_info(): prog_ref_level")); + /* drc->prog_ref_level_reserved_bits = */ faad_get1bit(ld + DEBUGVAR(1,100,"dynamic_range_info(): prog_ref_level_reserved_bits")); + n++; + } + + for (i = 0; i < drc->num_bands; i++) + { + drc->dyn_rng_sgn[i] = faad_get1bit(ld + DEBUGVAR(1,101,"dynamic_range_info(): dyn_rng_sgn")); + drc->dyn_rng_ctl[i] = (uint8_t)faad_getbits(ld, 7 + DEBUGVAR(1,102,"dynamic_range_info(): dyn_rng_ctl")); + n++; + } + + return n; +} + +/* Table 4.4.32 */ +static uint8_t excluded_channels(bitfile *ld, drc_info *drc) +{ + uint8_t i, n = 0; + uint8_t num_excl_chan = 7; + + for (i = 0; i < 7; i++) + { + drc->exclude_mask[i] = faad_get1bit(ld + DEBUGVAR(1,103,"excluded_channels(): exclude_mask")); + } + n++; + + while ((drc->additional_excluded_chns[n-1] = faad_get1bit(ld + DEBUGVAR(1,104,"excluded_channels(): additional_excluded_chns"))) == 1) + { + for (i = num_excl_chan; i < num_excl_chan+7; i++) + { + drc->exclude_mask[i] = faad_get1bit(ld + DEBUGVAR(1,105,"excluded_channels(): exclude_mask")); + } + n++; + num_excl_chan += 7; + } + + return n; +} + +/* Annex A: Audio Interchange Formats */ + +/* Table 1.A.2 */ +void get_adif_header(adif_header *adif, bitfile *ld) +{ + uint8_t i; + + /* adif_id[0] = */ faad_getbits(ld, 8 + DEBUGVAR(1,106,"get_adif_header(): adif_id[0]")); + /* adif_id[1] = */ faad_getbits(ld, 8 + DEBUGVAR(1,107,"get_adif_header(): adif_id[1]")); + /* adif_id[2] = */ faad_getbits(ld, 8 + DEBUGVAR(1,108,"get_adif_header(): adif_id[2]")); + /* adif_id[3] = */ faad_getbits(ld, 8 + DEBUGVAR(1,109,"get_adif_header(): adif_id[3]")); + adif->copyright_id_present = faad_get1bit(ld + DEBUGVAR(1,110,"get_adif_header(): copyright_id_present")); + if(adif->copyright_id_present) + { + for (i = 0; i < 72/8; i++) + { + adif->copyright_id[i] = (int8_t)faad_getbits(ld, 8 + DEBUGVAR(1,111,"get_adif_header(): copyright_id")); + } + adif->copyright_id[i] = 0; + } + adif->original_copy = faad_get1bit(ld + DEBUGVAR(1,112,"get_adif_header(): original_copy")); + adif->home = faad_get1bit(ld + DEBUGVAR(1,113,"get_adif_header(): home")); + adif->bitstream_type = faad_get1bit(ld + DEBUGVAR(1,114,"get_adif_header(): bitstream_type")); + adif->bitrate = faad_getbits(ld, 23 + DEBUGVAR(1,115,"get_adif_header(): bitrate")); + adif->num_program_config_elements = (uint8_t)faad_getbits(ld, 4 + DEBUGVAR(1,116,"get_adif_header(): num_program_config_elements")); + + for (i = 0; i < adif->num_program_config_elements + 1; i++) + { + if(adif->bitstream_type == 0) + { + adif->adif_buffer_fullness = faad_getbits(ld, 20 + DEBUGVAR(1,117,"get_adif_header(): adif_buffer_fullness")); + } else { + adif->adif_buffer_fullness = 0; + } + + program_config_element(&adif->pce[i], ld); + } +} + +/* Table 1.A.5 */ +uint8_t adts_frame(adts_header *adts, bitfile *ld) +{ + /* faad_byte_align(ld); */ + if (adts_fixed_header(adts, ld)) + return 5; + adts_variable_header(adts, ld); + adts_error_check(adts, ld); + + return 0; +} + +/* Table 1.A.6 */ +static uint8_t adts_fixed_header(adts_header *adts, bitfile *ld) +{ + uint16_t i; + uint8_t sync_err = 1; + + /* try to recover from sync errors */ + for (i = 0; i < 768; i++) + { + adts->syncword = (uint16_t)faad_showbits(ld, 12); + if (adts->syncword != 0xFFF) + { + faad_getbits(ld, 8 + DEBUGVAR(0,0,"")); + } else { + sync_err = 0; + faad_getbits(ld, 12 + DEBUGVAR(1,118,"adts_fixed_header(): syncword")); + break; + } + } + if (sync_err) + return 5; + + adts->id = faad_get1bit(ld + DEBUGVAR(1,119,"adts_fixed_header(): id")); + adts->layer = (uint8_t)faad_getbits(ld, 2 + DEBUGVAR(1,120,"adts_fixed_header(): layer")); + adts->protection_absent = faad_get1bit(ld + DEBUGVAR(1,121,"adts_fixed_header(): protection_absent")); + adts->profile = (uint8_t)faad_getbits(ld, 2 + DEBUGVAR(1,122,"adts_fixed_header(): profile")); + adts->sf_index = (uint8_t)faad_getbits(ld, 4 + DEBUGVAR(1,123,"adts_fixed_header(): sf_index")); + adts->private_bit = faad_get1bit(ld + DEBUGVAR(1,124,"adts_fixed_header(): private_bit")); + adts->channel_configuration = (uint8_t)faad_getbits(ld, 3 + DEBUGVAR(1,125,"adts_fixed_header(): channel_configuration")); + adts->original = faad_get1bit(ld + DEBUGVAR(1,126,"adts_fixed_header(): original")); + adts->home = faad_get1bit(ld + DEBUGVAR(1,127,"adts_fixed_header(): home")); + + if (adts->old_format == 1) + { + /* Removed in corrigendum 14496-3:2002 */ + if (adts->id == 0) + { + adts->emphasis = (uint8_t)faad_getbits(ld, 2 + DEBUGVAR(1,128,"adts_fixed_header(): emphasis")); + } + } + + return 0; +} + +/* Table 1.A.7 */ +static void adts_variable_header(adts_header *adts, bitfile *ld) +{ + adts->copyright_identification_bit = faad_get1bit(ld + DEBUGVAR(1,129,"adts_variable_header(): copyright_identification_bit")); + adts->copyright_identification_start = faad_get1bit(ld + DEBUGVAR(1,130,"adts_variable_header(): copyright_identification_start")); + adts->aac_frame_length = (uint16_t)faad_getbits(ld, 13 + DEBUGVAR(1,131,"adts_variable_header(): aac_frame_length")); + adts->adts_buffer_fullness = (uint16_t)faad_getbits(ld, 11 + DEBUGVAR(1,132,"adts_variable_header(): adts_buffer_fullness")); + adts->no_raw_data_blocks_in_frame = (uint8_t)faad_getbits(ld, 2 + DEBUGVAR(1,133,"adts_variable_header(): no_raw_data_blocks_in_frame")); +} + +/* Table 1.A.8 */ +static void adts_error_check(adts_header *adts, bitfile *ld) +{ + if (adts->protection_absent == 0) + { + adts->crc_check = (uint16_t)faad_getbits(ld, 16 + DEBUGVAR(1,134,"adts_error_check(): crc_check")); + } +} diff --git a/lib/rbcodec/codecs/libfaad/syntax.h b/lib/rbcodec/codecs/libfaad/syntax.h new file mode 100644 index 0000000000..f9efde7d9b --- /dev/null +++ b/lib/rbcodec/codecs/libfaad/syntax.h @@ -0,0 +1,124 @@ +/* +** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding +** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +** +** Any non-GPL usage of this software or parts of this software is strictly +** forbidden. +** +** Commercial non-GPL licensing of this software is possible. +** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** +** $Id$ +**/ + +#ifndef __SYNTAX_H__ +#define __SYNTAX_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "decoder.h" +#include "bits.h" + +#define MAIN 1 +#define LC 2 +#define SSR 3 +#define LTP 4 +#define HE_AAC 5 +#define LD 23 +#define ER_LC 17 +#define ER_LTP 19 +#define DRM_ER_LC 27 /* special object type for DRM */ + +/* header types */ +#define RAW 0 +#define ADIF 1 +#define ADTS 2 + +/* SBR signalling */ +#define NO_SBR 0 +#define SBR_UPSAMPLED 1 +#define SBR_DOWNSAMPLED 2 +#define NO_SBR_UPSAMPLED 3 + +/* DRM channel definitions */ +#define DRMCH_MONO 1 +#define DRMCH_STEREO 2 +#define DRMCH_SBR_MONO 3 +#define DRMCH_SBR_STEREO 4 +#define DRMCH_SBR_PS_STEREO 5 + + +/* First object type that has ER */ +#define ER_OBJECT_START 17 + + +/* Bitstream */ +#define LEN_SE_ID 3 +#define LEN_TAG 4 +#define LEN_BYTE 8 + +#define EXT_FIL 0 +#define EXT_FILL_DATA 1 +#define EXT_DATA_ELEMENT 2 +#define EXT_DYNAMIC_RANGE 11 +#define ANC_DATA 0 + +/* Syntax elements */ +#define ID_SCE 0x0 +#define ID_CPE 0x1 +#define ID_CCE 0x2 +#define ID_LFE 0x3 +#define ID_DSE 0x4 +#define ID_PCE 0x5 +#define ID_FIL 0x6 +#define ID_END 0x7 + +#define ONLY_LONG_SEQUENCE 0x0 +#define LONG_START_SEQUENCE 0x1 +#define EIGHT_SHORT_SEQUENCE 0x2 +#define LONG_STOP_SEQUENCE 0x3 + +#define ZERO_HCB 0 +#define FIRST_PAIR_HCB 5 +#define ESC_HCB 11 +#define QUAD_LEN 4 +#define PAIR_LEN 2 +#define NOISE_HCB 13 +#define INTENSITY_HCB2 14 +#define INTENSITY_HCB 15 + +#define INVALID_SBR_ELEMENT 255 + +int8_t GASpecificConfig(bitfile *ld, mp4AudioSpecificConfig *mp4ASC, + program_config *pce); + +uint8_t adts_frame(adts_header *adts, bitfile *ld); +void get_adif_header(adif_header *adif, bitfile *ld); +void raw_data_block(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hInfo, + bitfile *ld, program_config *pce, drc_info *drc); +uint8_t reordered_spectral_data(NeAACDecHandle hDecoder, ic_stream *ics, bitfile *ld, + int16_t *spectral_data); +void aac_scalable_main_element(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hInfo, + bitfile *ld, program_config *pce, drc_info *drc); + + +#ifdef __cplusplus +} +#endif +#endif diff --git a/lib/rbcodec/codecs/libfaad/tns.c b/lib/rbcodec/codecs/libfaad/tns.c new file mode 100644 index 0000000000..a2bec86519 --- /dev/null +++ b/lib/rbcodec/codecs/libfaad/tns.c @@ -0,0 +1,312 @@ +/* +** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding +** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +** +** Any non-GPL usage of this software or parts of this software is strictly +** forbidden. +** +** Commercial non-GPL licensing of this software is possible. +** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** +** $Id$ +**/ + +#include "common.h" +#include "structs.h" + +#include "syntax.h" +#include "tns.h" + + +/* static function declarations */ +static void tns_decode_coef(uint8_t order, uint8_t coef_res_bits, uint8_t coef_compress, + uint8_t *coef, real_t *a); +static void tns_ar_filter(real_t *spectrum, uint16_t size, int8_t inc, real_t *lpc, + int8_t order); +#ifdef LTP_DEC +static void tns_ma_filter(real_t *spectrum, uint16_t size, int8_t inc, real_t *lpc, + int8_t order); +#endif + + +#ifdef _MSC_VER +#pragma warning(disable:4305) +#pragma warning(disable:4244) +#endif +static real_t tns_coef_0_3[] = +{ + COEF_CONST(0.0), COEF_CONST(0.4338837391), COEF_CONST(0.7818314825), COEF_CONST(0.9749279122), + COEF_CONST(-0.9848077530), COEF_CONST(-0.8660254038), COEF_CONST(-0.6427876097), COEF_CONST(-0.3420201433), + COEF_CONST(-0.4338837391), COEF_CONST(-0.7818314825), COEF_CONST(-0.9749279122), COEF_CONST(-0.9749279122), + COEF_CONST(-0.9848077530), COEF_CONST(-0.8660254038), COEF_CONST(-0.6427876097), COEF_CONST(-0.3420201433) +}; +static real_t tns_coef_0_4[] = +{ + COEF_CONST(0.0), COEF_CONST(0.2079116908), COEF_CONST(0.4067366431), COEF_CONST(0.5877852523), + COEF_CONST(0.7431448255), COEF_CONST(0.8660254038), COEF_CONST(0.9510565163), COEF_CONST(0.9945218954), + COEF_CONST(-0.9957341763), COEF_CONST(-0.9618256432), COEF_CONST(-0.8951632914), COEF_CONST(-0.7980172273), + COEF_CONST(-0.6736956436), COEF_CONST(-0.5264321629), COEF_CONST(-0.3612416662), COEF_CONST(-0.1837495178) +}; +static real_t tns_coef_1_3[] = +{ + COEF_CONST(0.0), COEF_CONST(0.4338837391), COEF_CONST(-0.6427876097), COEF_CONST(-0.3420201433), + COEF_CONST(0.9749279122), COEF_CONST(0.7818314825), COEF_CONST(-0.6427876097), COEF_CONST(-0.3420201433), + COEF_CONST(-0.4338837391), COEF_CONST(-0.7818314825), COEF_CONST(-0.6427876097), COEF_CONST(-0.3420201433), + COEF_CONST(-0.7818314825), COEF_CONST(-0.4338837391), COEF_CONST(-0.6427876097), COEF_CONST(-0.3420201433) +}; +static real_t tns_coef_1_4[] = +{ + COEF_CONST(0.0), COEF_CONST(0.2079116908), COEF_CONST(0.4067366431), COEF_CONST(0.5877852523), + COEF_CONST(-0.6736956436), COEF_CONST(-0.5264321629), COEF_CONST(-0.3612416662), COEF_CONST(-0.1837495178), + COEF_CONST(0.9945218954), COEF_CONST(0.9510565163), COEF_CONST(0.8660254038), COEF_CONST(0.7431448255), + COEF_CONST(-0.6736956436), COEF_CONST(-0.5264321629), COEF_CONST(-0.3612416662), COEF_CONST(-0.1837495178) +}; + + +/* TNS decoding for one channel and frame */ +void tns_decode_frame(ic_stream *ics, tns_info *tns, uint8_t sr_index, + uint8_t object_type, real_t *spec, uint16_t frame_len) +{ + uint8_t w, f, tns_order; + int8_t inc; + int16_t size; + uint16_t bottom, top, start, end; + uint16_t nshort = frame_len/8; + real_t lpc[TNS_MAX_ORDER+1]; + + if (!ics->tns_data_present) + return; + + for (w = 0; w < ics->num_windows; w++) + { + bottom = ics->num_swb; + + for (f = 0; f < tns->n_filt[w]; f++) + { + top = bottom; + bottom = max(top - tns->length[w][f], 0); + tns_order = min(tns->order[w][f], TNS_MAX_ORDER); + if (!tns_order) + continue; + + tns_decode_coef(tns_order, tns->coef_res[w]+3, + tns->coef_compress[w][f], tns->coef[w][f], lpc); + + start = min(bottom, max_tns_sfb(sr_index, object_type, (ics->window_sequence == EIGHT_SHORT_SEQUENCE))); + start = min(start, ics->max_sfb); + start = ics->swb_offset[start]; + + end = min(top, max_tns_sfb(sr_index, object_type, (ics->window_sequence == EIGHT_SHORT_SEQUENCE))); + end = min(end, ics->max_sfb); + end = ics->swb_offset[end]; + + size = end - start; + if (size <= 0) + continue; + + if (tns->direction[w][f]) + { + inc = -1; + start = end - 1; + } else { + inc = 1; + } + + tns_ar_filter(&spec[(w*nshort)+start], size, inc, lpc, tns_order); + } + } +} + +#ifdef LTP_DEC +/* TNS encoding for one channel and frame */ +void tns_encode_frame(ic_stream *ics, tns_info *tns, uint8_t sr_index, + uint8_t object_type, real_t *spec, uint16_t frame_len) +{ + uint8_t w, f, tns_order; + int8_t inc; + int16_t size; + uint16_t bottom, top, start, end; + uint16_t nshort = frame_len/8; + real_t lpc[TNS_MAX_ORDER+1]; + + if (!ics->tns_data_present) + return; + + for (w = 0; w < ics->num_windows; w++) + { + bottom = ics->num_swb; + + for (f = 0; f < tns->n_filt[w]; f++) + { + top = bottom; + bottom = max(top - tns->length[w][f], 0); + tns_order = min(tns->order[w][f], TNS_MAX_ORDER); + if (!tns_order) + continue; + + tns_decode_coef(tns_order, tns->coef_res[w]+3, + tns->coef_compress[w][f], tns->coef[w][f], lpc); + + start = min(bottom, max_tns_sfb(sr_index, object_type, (ics->window_sequence == EIGHT_SHORT_SEQUENCE))); + start = min(start, ics->max_sfb); + start = ics->swb_offset[start]; + + end = min(top, max_tns_sfb(sr_index, object_type, (ics->window_sequence == EIGHT_SHORT_SEQUENCE))); + end = min(end, ics->max_sfb); + end = ics->swb_offset[end]; + + size = end - start; + if (size <= 0) + continue; + + if (tns->direction[w][f]) + { + inc = -1; + start = end - 1; + } else { + inc = 1; + } + + tns_ma_filter(&spec[(w*nshort)+start], size, inc, lpc, tns_order); + } + } +} +#endif + +/* Decoder transmitted coefficients for one TNS filter */ +static void tns_decode_coef(uint8_t order, uint8_t coef_res_bits, uint8_t coef_compress, + uint8_t *coef, real_t *a) +{ + uint8_t i, m; + real_t tmp2[TNS_MAX_ORDER+1], b[TNS_MAX_ORDER+1]; + + /* Conversion to signed integer */ + for (i = 0; i < order; i++) + { + if (coef_compress == 0) + { + if (coef_res_bits == 3) + { + tmp2[i] = tns_coef_0_3[coef[i]]; + } else { + tmp2[i] = tns_coef_0_4[coef[i]]; + } + } else { + if (coef_res_bits == 3) + { + tmp2[i] = tns_coef_1_3[coef[i]]; + } else { + tmp2[i] = tns_coef_1_4[coef[i]]; + } + } + } + + /* Conversion to LPC coefficients */ + a[0] = COEF_CONST(1.0); + for (m = 1; m <= order; m++) + { + for (i = 1; i < m; i++) /* loop only while i + Copyright (C) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! + + diff --git a/lib/rbcodec/codecs/libffmpegFLAC/README b/lib/rbcodec/codecs/libffmpegFLAC/README new file mode 100644 index 0000000000..9bc0f6ed8a --- /dev/null +++ b/lib/rbcodec/codecs/libffmpegFLAC/README @@ -0,0 +1,19 @@ +FFmpeg README +------------- + +1) Documentation +---------------- + +* Read the documentation in the doc/ directory. + +2) Licensing +------------ + +* Read the file COPYING. ffmpeg and the associated libraries EXCEPT + liba52 and libpostproc are licensed under the Lesser GNU General + Public License. + +* liba52 and libpostproc are distributed under the GNU General Public + License and their compilation and use is optional in ffmpeg. + +Fabrice Bellard. \ No newline at end of file diff --git a/lib/rbcodec/codecs/libffmpegFLAC/README.rockbox b/lib/rbcodec/codecs/libffmpegFLAC/README.rockbox new file mode 100644 index 0000000000..850cdfcb7d --- /dev/null +++ b/lib/rbcodec/codecs/libffmpegFLAC/README.rockbox @@ -0,0 +1,46 @@ +Library: libffmpegFLAC +Imported: 2005-10-26 by Dave Chapman + +This directory contains a FLAC decoder based on the flac.c (and a small +number of other files) from the ffmpeg project. + +LICENSING INFORMATION + +ffmpeg is licensed under the Lesser GNU General Public License and the +file flac.c is Copyright 2003 Alex Beregszaszi. + +IMPORT DETAILS + +The decoder is based on ffmpeg-cvs from 26 October 2005. + +The file libavcodec/flac.c was renamed to decoder.c and all ffmpeg +related code was removed. It was also heavily modified to remove +debugging information and unused experiemental code. + +It was also changed to provide output as 32-bit integers (with the +data left-shifted to 28 bit accuracy). The original flac.c provided +16-bit output. + +In order to minimise memory usage, a small number of hard-coded limits +are present in decoder.h - mainly limiting the supported blocksize +(number of samples in a frame) to 4608. This is the default value +used by the reference FLAC encoder at all standard compression +settings. + + +TESTING + +A test program is contained in the file main.c and this should compile +in any Unix-like environment using the command "make -f Makefile.test". + +Running "test file.flac" will decode the audio data to a WAV file +called "test.wav" in the current directory. This has been tested with +16-bit and 24-bit mono and stereo FLAC files. + +This can be used to test the accuracy of the decoder by comparing the +md5sum of the WAV file produced by this decoder with a WAV file +produced by the official libFLAC decoder. + +This test program could be extended to perform an internal md5sum +calculation and comparing that against the md5sum stored in the FLAC +file's header. diff --git a/lib/rbcodec/codecs/libffmpegFLAC/SOURCES b/lib/rbcodec/codecs/libffmpegFLAC/SOURCES new file mode 100644 index 0000000000..63094b30a6 --- /dev/null +++ b/lib/rbcodec/codecs/libffmpegFLAC/SOURCES @@ -0,0 +1,7 @@ +decoder.c +shndec.c +#if defined(CPU_COLDFIRE) +coldfire.S +#elif defined(CPU_ARM) +arm.S +#endif diff --git a/lib/rbcodec/codecs/libffmpegFLAC/arm.S b/lib/rbcodec/codecs/libffmpegFLAC/arm.S new file mode 100644 index 0000000000..8adca77ce5 --- /dev/null +++ b/lib/rbcodec/codecs/libffmpegFLAC/arm.S @@ -0,0 +1,271 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2006 by Thom Johansen + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include "config.h" + +/* The following is an assembler optimised version of the LPC filtering + routines needed for FLAC decoding. It is optimised for use with ARM + processors. + All LPC filtering up to order 9 is done in specially optimised unrolled + loops, while every order above this is handled by a slower default routine. + */ +#ifdef USE_IRAM + .section .icode,"ax",%progbits +#else + .text +#endif + .global lpc_decode_arm +lpc_decode_arm: + stmdb sp!, { r4-r11, lr } + ldr r4, [sp, #36] + /* r0 = blocksize, r1 = qlevel, r2 = pred_order + r3 = data, r4 = coeffs + */ + + /* the data pointer always lags behind history pointer by 'pred_order' + samples. since we have one loop for each order, we can hard code this + and free a register by not saving data pointer. + */ + sub r3, r3, r2, lsl #2 @ r3 = history + cmp r0, #0 @ no samples to process + beq .exit + cmp r2, #9 @ check if order is too high for unrolled loops + addls pc, pc, r2, lsl #2 @ jump to our unrolled decode loop if it exists +@ jumptable: + b .default @ order too high, go to default routine + b .exit @ zero order filter isn't possible, exit function + b .order1 + b .order2 + b .order3 + b .order4 + b .order5 + b .order6 + b .order7 + b .order8 + +@ last jump table entry coincides with target, so leave it out +.order9: + ldmia r4, { r5-r12, r14 } @ fetch coefs +.loop9: + ldr r4, [r3], #4 @ load first history sample + mul r2, r4, r14 @ multiply with last coef + ldr r4, [r3], #4 @ rinse and repeat while accumulating sum in r2 + mla r2, r4, r12, r2 + ldr r4, [r3], #4 + mla r2, r4, r11, r2 + ldr r4, [r3], #4 + mla r2, r4, r10, r2 + ldr r4, [r3], #4 + mla r2, r4, r9, r2 + ldr r4, [r3], #4 + mla r2, r4, r8, r2 + ldr r4, [r3], #4 + mla r2, r4, r7, r2 + ldr r4, [r3], #4 + mla r2, r4, r6, r2 + ldr r4, [r3], #4 + mla r2, r4, r5, r2 + ldr r4, [r3] @ r4 = residual + add r2, r4, r2, asr r1 @ shift sum by qlevel bits and add residual + str r2, [r3], #-8*4 @ save result and wrap history pointer back + subs r0, r0, #1 @ check if we're done + bne .loop9 @ nope, jump back + b .exit + +.order8: + ldmia r4, { r5-r12 } +.loop8: + @ we have more registers to spare here, so start block reading + ldmia r3!, { r4, r14 } + mul r2, r4, r12 + mla r2, r14, r11, r2 + ldmia r3!, { r4, r14 } + mla r2, r4, r10, r2 + mla r2, r14, r9, r2 + ldmia r3!, { r4, r14 } + mla r2, r4, r8, r2 + mla r2, r14, r7, r2 + ldmia r3!, { r4, r14 } + mla r2, r4, r6, r2 + mla r2, r14, r5, r2 + ldr r4, [r3] + add r2, r4, r2, asr r1 + str r2, [r3], #-7*4 + subs r0, r0, #1 + bne .loop8 + b .exit + +.order7: + ldmia r4, { r5-r11 } +.loop7: + ldmia r3!, { r4, r12, r14 } + mul r2, r4, r11 + mla r2, r12, r10, r2 + mla r2, r14, r9, r2 + ldmia r3!, { r4, r12, r14 } + mla r2, r4, r8, r2 + mla r2, r12, r7, r2 + mla r2, r14, r6, r2 + ldr r4, [r3], #4 + mla r2, r4, r5, r2 + ldr r4, [r3] + add r2, r4, r2, asr r1 + str r2, [r3], #-6*4 + subs r0, r0, #1 + bne .loop7 + b .exit + +.order6: + ldmia r4, { r5-r10 } +.loop6: + ldmia r3!, { r4, r11-r12, r14 } + mul r2, r4, r10 + mla r2, r11, r9, r2 + mla r2, r12, r8, r2 + mla r2, r14, r7, r2 + ldmia r3!, { r4, r11 } + mla r2, r4, r6, r2 + mla r2, r11, r5, r2 + ldr r4, [r3] + add r2, r4, r2, asr r1 + str r2, [r3], #-5*4 + subs r0, r0, #1 + bne .loop6 + b .exit + +.order5: + ldmia r4, { r5-r9 } +.loop5: + ldmia r3!, { r4, r10-r12, r14 } + mul r2, r4, r9 + mla r2, r10, r8, r2 + mla r2, r11, r7, r2 + mla r2, r12, r6, r2 + mla r2, r14, r5, r2 + ldr r4, [r3] + add r2, r4, r2, asr r1 + str r2, [r3], #-4*4 + subs r0, r0, #1 + bne .loop5 + b .exit + +.order4: + ldmia r4, { r5-r8 } +.loop4: + ldmia r3!, { r4, r11-r12, r14 } + mul r2, r4, r8 + mla r2, r11, r7, r2 + mla r2, r12, r6, r2 + mla r2, r14, r5, r2 + ldr r4, [r3] + add r2, r4, r2, asr r1 + str r2, [r3], #-3*4 + subs r0, r0, #1 + bne .loop4 + b .exit + +.order3: + ldmia r4, { r5-r7 } +.loop3: + ldmia r3!, { r4, r12, r14 } + mul r2, r4, r7 + mla r2, r12, r6, r2 + mla r2, r14, r5, r2 + ldr r4, [r3] + add r2, r4, r2, asr r1 + str r2, [r3], #-2*4 + subs r0, r0, #1 + bne .loop3 + b .exit + +.order2: + ldmia r4, { r5-r6 } +.loop2: + ldmia r3!, { r4, r14 } + mul r2, r4, r6 + mla r2, r14, r5, r2 + ldr r4, [r3] + add r2, r4, r2, asr r1 + str r2, [r3], #-1*4 + subs r0, r0, #1 + bne .loop2 + b .exit + +.order1: + ldr r5, [r4] @ load the one coef we need + ldr r4, [r3], #4 @ load one history sample, r3 now points to residual +.loop1: + mul r2, r4, r5 @ multiply coef by history sample + ldr r4, [r3] @ load residual + add r4, r4, r2, asr r1 @ add result to residual + str r4, [r3], #4 @ place r3 at next residual, we already have + subs r0, r0, #1 @ the current sample in r4 for the next iteration + bne .loop1 + b .exit + +.default: + /* we do the filtering in an unrolled by 4 loop as far as we can, and then + do the rest by jump table. */ + add r5, r4, r2, lsl #2 @ need to start in the other end of coefs + mov r7, r2, lsr #2 @ r7 = coefs/4 + mov r14, #0 @ init accumulator +.dloop1: + ldmdb r5!, { r8-r11 } + ldmia r3!, { r6, r12 } + mla r14, r6, r11, r14 + mla r14, r12, r10, r14 + ldmia r3!, { r6, r12 } + mla r14, r6, r9, r14 + mla r14, r12, r8, r14 + subs r7, r7, #1 + bne .dloop1 + + and r7, r2, #3 @ get remaining samples to be filtered + add pc, pc, r7, lsl #2 @ jump into accumulator chain +@ jumptable: + b .dsave @ padding + b .dsave + b .oneleft + b .twoleft +@ implicit .threeleft + ldr r12, [r5, #-4]! + ldr r8, [r3], #4 + mla r14, r12, r8, r14 +.twoleft: + ldr r12, [r5, #-4]! + ldr r8, [r3], #4 + mla r14, r12, r8, r14 +.oneleft: + ldr r12, [r5, #-4]! + ldr r8, [r3], #4 + mla r14, r12, r8, r14 + +.dsave: + ldr r12, [r3] @ load residual + add r14, r12, r14, asr r1 @ shift sum by qlevel bits and add residual + str r14, [r3], #4 @ store result + sub r3, r3, r2, lsl #2 @ and wrap history pointer back to next first pos + subs r0, r0, #1 @ are we done? + bne .default @ no, prepare for next sample + +.exit: + ldmpc regs=r4-r11 + diff --git a/lib/rbcodec/codecs/libffmpegFLAC/arm.h b/lib/rbcodec/codecs/libffmpegFLAC/arm.h new file mode 100644 index 0000000000..39080d7f75 --- /dev/null +++ b/lib/rbcodec/codecs/libffmpegFLAC/arm.h @@ -0,0 +1,8 @@ +#ifndef _FLAC_ARM_H +#define _FLAC_ARM_H + +#include "bitstream.h" + +void lpc_decode_arm(int blocksize, int qlevel, int pred_order, int32_t* data, int* coeffs); + +#endif diff --git a/lib/rbcodec/codecs/libffmpegFLAC/bitstream.h b/lib/rbcodec/codecs/libffmpegFLAC/bitstream.h new file mode 100644 index 0000000000..5fc3460c8e --- /dev/null +++ b/lib/rbcodec/codecs/libffmpegFLAC/bitstream.h @@ -0,0 +1,79 @@ +/** + * @file bitstream.h + * bitstream api header. + */ + +#ifndef BITSTREAM_H +#define BITSTREAM_H + +#include +#include "ffmpeg_get_bits.h" + +#ifndef BUILD_STANDALONE + #include + #include +#else + #include + #define IBSS_ATTR + #define ICONST_ATTR + #define ICODE_ATTR +#endif + +#if (CONFIG_CPU == MCF5250) || (CONFIG_CPU == PP5022) || (CONFIG_CPU == PP5024) +#define ICODE_ATTR_FLAC ICODE_ATTR +#define IBSS_ATTR_FLAC IBSS_ATTR +/* Enough IRAM to move additional data to it. */ +#define IBSS_ATTR_FLAC_LARGE_IRAM IBSS_ATTR +#define IBSS_ATTR_FLAC_XLARGE_IRAM + +#elif defined(CPU_S5L870X) +#define ICODE_ATTR_FLAC ICODE_ATTR +#define IBSS_ATTR_FLAC IBSS_ATTR +/* Enough IRAM to move even more additional data to it. */ +#define IBSS_ATTR_FLAC_LARGE_IRAM IBSS_ATTR +#define IBSS_ATTR_FLAC_XLARGE_IRAM IBSS_ATTR + +#else +#define ICODE_ATTR_FLAC ICODE_ATTR +#define IBSS_ATTR_FLAC IBSS_ATTR +/* Not enough IRAM available. */ +#define IBSS_ATTR_FLAC_LARGE_IRAM +#define IBSS_ATTR_FLAC_XLARGE_IRAM +#endif + +/* Endian conversion routines for standalone compilation */ +#ifdef BUILD_STANDALONE + #ifdef BUILD_BIGENDIAN + #define betoh32(x) (x) + #define letoh32(x) swap32(x) + #else + #define letoh32(x) (x) + #define betoh32(x) swap32(x) + #endif + + /* Taken from rockbox/firmware/export/system.h */ + + static inline unsigned short swap16(unsigned short value) + /* + result[15..8] = value[ 7..0]; + result[ 7..0] = value[15..8]; + */ + { + return (value >> 8) | (value << 8); + } + + static inline unsigned long swap32(unsigned long value) + /* + result[31..24] = value[ 7.. 0]; + result[23..16] = value[15.. 8]; + result[15.. 8] = value[23..16]; + result[ 7.. 0] = value[31..24]; + */ + { + unsigned long hi = swap16(value >> 16); + unsigned long lo = swap16(value & 0xffff); + return (lo << 16) | hi; + } +#endif + +#endif /* BITSTREAM_H */ diff --git a/lib/rbcodec/codecs/libffmpegFLAC/coldfire.S b/lib/rbcodec/codecs/libffmpegFLAC/coldfire.S new file mode 100644 index 0000000000..efbb907874 --- /dev/null +++ b/lib/rbcodec/codecs/libffmpegFLAC/coldfire.S @@ -0,0 +1,535 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2005 by Thom Johansen + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +/* The following are assembler optimised version of the LPC filtering + routines needed for FLAC decoding. They is optimised for use with the + MCF5249 processor, or any other similar ColdFire core with the EMAC unit. + */ + +/* This routine deals with sample widths 16 and lower. All LPC filtering up to + order 10 is done in specially optimised unrolled loops, while every order + above this is handled by a slower default routine. + */ + .section .icode,"ax",@progbits + .global lpc_decode_emac + .align 2 +lpc_decode_emac: + lea.l (-44, %sp), %sp + movem.l %d2-%d7/%a2-%a6, (%sp) + movem.l (44+4, %sp), %d0-%d2/%a0-%a1 + /* d0 = blocksize, d1 = qlevel, d2 = pred_order + a0 = data, a1 = coeffs + */ + + /* the data pointer always lags behind history pointer by 'pred_order' + samples. since we have one loop for each order, we can hard code this + and free a register by not saving data pointer. + */ + move.l %d2, %d3 + neg.l %d3 + lea.l (%a0, %d3.l*4), %a0 | history + clr.l %d3 + move.l %d3, %macsr | we'll need integer mode for this + tst.l %d0 + jeq .exit | zero samples to process, exit + moveq.l #10, %d3 + cmp.l %d3, %d2 + jgt .default | order is over 10, jump to default case + jmp.l (2, %pc, %d2.l*4) | jump to loop corresponding to pred_order +| jumptable: + bra.w .exit | zero order filter isn't possible, exit function + bra.w .order1 + bra.w .order2 + bra.w .order3 + bra.w .order4 + bra.w .order5 + bra.w .order6 + bra.w .order7 + bra.w .order8 + bra.w .order9 + +| last jump table entry coincides with target, so leave it out +.order10: + movem.l (%a1), %d3-%d7/%a1-%a5 | load lpc coefs + move.l (%a0)+, %a6 | load first history sample +1: + mac.l %a6, %a5, (%a0)+, %a6, %acc0 + mac.l %a6, %a4, (%a0)+, %a6, %acc0 + mac.l %a6, %a3, (%a0)+, %a6, %acc0 + mac.l %a6, %a2, (%a0)+, %a6, %acc0 + mac.l %a6, %a1, (%a0)+, %a6, %acc0 + mac.l %a6, %d7, (%a0)+, %a6, %acc0 + mac.l %a6, %d6, (%a0)+, %a6, %acc0 + mac.l %a6, %d5, (%a0)+, %a6, %acc0 + mac.l %a6, %d4, (%a0)+, %a6, %acc0 + mac.l %a6, %d3, (-9*4, %a0), %a6, %acc0 | load for the next iteration + movclr.l %acc0, %d2 | get sum + asr.l %d1, %d2 | shift sum by qlevel bits + add.l %d2, (%a0) | add residual and save + lea.l (-8*4, %a0), %a0 | point history back at second element + subq.l #1, %d0 | decrement sample count + jne 1b | are we done? + jra .exit + +.order9: + movem.l (%a1), %d4-%d7/%a1-%a5 + move.l (%a0)+, %a6 +1: + mac.l %a6, %a5, (%a0)+, %a6, %acc0 + mac.l %a6, %a4, (%a0)+, %a6, %acc0 + mac.l %a6, %a3, (%a0)+, %a6, %acc0 + mac.l %a6, %a2, (%a0)+, %a6, %acc0 + mac.l %a6, %a1, (%a0)+, %a6, %acc0 + mac.l %a6, %d7, (%a0)+, %a6, %acc0 + mac.l %a6, %d6, (%a0)+, %a6, %acc0 + mac.l %a6, %d5, (%a0)+, %a6, %acc0 + mac.l %a6, %d4, (-8*4, %a0), %a6, %acc0 + movclr.l %acc0, %d2 + asr.l %d1, %d2 + add.l %d2, (%a0) + lea.l (-7*4, %a0), %a0 + subq.l #1, %d0 + jne 1b + jra .exit + +.order8: + movem.l (%a1), %d5-%d7/%a1-%a5 + move.l (%a0)+, %a6 +1: + mac.l %a6, %a5, (%a0)+, %a6, %acc0 + mac.l %a6, %a4, (%a0)+, %a6, %acc0 + mac.l %a6, %a3, (%a0)+, %a6, %acc0 + mac.l %a6, %a2, (%a0)+, %a6, %acc0 + mac.l %a6, %a1, (%a0)+, %a6, %acc0 + mac.l %a6, %d7, (%a0)+, %a6, %acc0 + mac.l %a6, %d6, (%a0)+, %a6, %acc0 + mac.l %a6, %d5, (-7*4, %a0), %a6, %acc0 + movclr.l %acc0, %d2 + asr.l %d1, %d2 + add.l %d2, (%a0) + lea.l (-6*4, %a0), %a0 + subq.l #1, %d0 + jne 1b + jra .exit + +.order7: + movem.l (%a1), %d6-%d7/%a1-%a5 + move.l (%a0)+, %a6 +1: + mac.l %a6, %a5, (%a0)+, %a6, %acc0 + mac.l %a6, %a4, (%a0)+, %a6, %acc0 + mac.l %a6, %a3, (%a0)+, %a6, %acc0 + mac.l %a6, %a2, (%a0)+, %a6, %acc0 + mac.l %a6, %a1, (%a0)+, %a6, %acc0 + mac.l %a6, %d7, (%a0)+, %a6, %acc0 + mac.l %a6, %d6, (-6*4, %a0), %a6, %acc0 + movclr.l %acc0, %d2 + asr.l %d1, %d2 + add.l %d2, (%a0) + lea.l (-5*4, %a0), %a0 + subq.l #1, %d0 + jne 1b + jra .exit + +.order6: + movem.l (%a1), %d7/%a1-%a5 + move.l (%a0)+, %a6 +1: + mac.l %a6, %a5, (%a0)+, %a6, %acc0 + mac.l %a6, %a4, (%a0)+, %a6, %acc0 + mac.l %a6, %a3, (%a0)+, %a6, %acc0 + mac.l %a6, %a2, (%a0)+, %a6, %acc0 + mac.l %a6, %a1, (%a0)+, %a6, %acc0 + mac.l %a6, %d7, (-5*4, %a0), %a6, %acc0 + movclr.l %acc0, %d2 + asr.l %d1, %d2 + add.l %d2, (%a0) + lea.l (-4*4, %a0), %a0 + subq.l #1, %d0 + jne 1b + jra .exit + +.order5: + movem.l (%a1), %a1-%a5 + move.l (%a0)+, %a6 +1: + mac.l %a6, %a5, (%a0)+, %a6, %acc0 + mac.l %a6, %a4, (%a0)+, %a6, %acc0 + mac.l %a6, %a3, (%a0)+, %a6, %acc0 + mac.l %a6, %a2, (%a0)+, %a6, %acc0 + mac.l %a6, %a1, (-4*4, %a0), %a6, %acc0 + movclr.l %acc0, %d2 + asr.l %d1, %d2 + add.l %d2, (%a0) + lea.l (-3*4, %a0), %a0 + subq.l #1, %d0 + jne 1b + jra .exit + +.order4: + movem.l (%a1), %a2-%a5 + move.l (%a0)+, %a6 +1: + mac.l %a6, %a5, (%a0)+, %a6, %acc0 + mac.l %a6, %a4, (%a0)+, %a6, %acc0 + mac.l %a6, %a3, (%a0)+, %a6, %acc0 + mac.l %a6, %a2, (-3*4, %a0), %a6, %acc0 + movclr.l %acc0, %d2 + asr.l %d1, %d2 + add.l %d2, (%a0) + subq.l #8, %a0 + subq.l #1, %d0 + jne 1b + jra .exit + +.order3: + movem.l (%a1), %a3-%a5 + move.l (%a0)+, %a6 +1: + mac.l %a6, %a5, (%a0)+, %a6, %acc0 + mac.l %a6, %a4, (%a0)+, %a6, %acc0 + mac.l %a6, %a3, (-2*4, %a0), %a6, %acc0 + movclr.l %acc0, %d2 + asr.l %d1, %d2 + add.l %d2, (%a0) + subq.l #4, %a0 + subq.l #1, %d0 + jne 1b + jra .exit + +.order2: + movem.l (%a1), %a4-%a5 + move.l (%a0)+, %a6 +1: + mac.l %a6, %a5, (%a0)+, %a6, %acc0 + mac.l %a6, %a4, %acc0 | data for next iteration is already loaded + movclr.l %acc0, %d2 + asr.l %d1, %d2 + add.l %d2, (%a0) + subq.l #1, %d0 + jne 1b + jra .exit + +.order1: + | no point in using mac here + move.l (%a1), %a5 +1: + move.l %a5, %d2 + muls.l (%a0)+, %d2 + asr.l %d1, %d2 + add.l %d2, (%a0) + subq.l #1, %d0 + jne 1b + jra .exit + +.default: + /* we do the filtering in an unrolled by 4 loop as far as we can, and then + do the rest by jump table. */ + lea.l (%a1, %d2.l*4), %a2 | need to start in the other end of coefs + move.l %a0, %a3 | working copy of history pointer + move.l %d2, %d3 + lsr.l #2, %d3 | coefs/4, num of iterations needed in next loop + move.l (%a3)+, %a5 | preload data for loop +1: + lea.l (-4*4, %a2), %a2 | move lpc coef pointer four samples backwards + movem.l (%a2), %d4-%d7 | load four coefs + mac.l %a5, %d7, (%a3)+, %a5, %acc0 + mac.l %a5, %d6, (%a3)+, %a5, %acc0 + mac.l %a5, %d5, (%a3)+, %a5, %acc0 + mac.l %a5, %d4, (%a3)+, %a5, %acc0 + subq.l #1, %d3 | any more unrolled loop operations left? + jne 1b + + moveq.l #3, %d3 | mask 0x00000003 + and.l %d2, %d3 | get the remaining samples to be filtered + jmp.l (2, %pc, %d3*2) | then jump into mac.l chain +| jumptable: + bra.b 3f | none left + bra.b 2f | one left + bra.b 1f | two left +| three left + move.l -(%a2), %d4 + mac.l %a5, %d4, (%a3)+, %a5, %acc0 +1: + move.l -(%a2), %d4 + mac.l %a5, %d4, (%a3)+, %a5, %acc0 +2: + move.l -(%a2), %d4 + mac.l %a5, %d4, (%a3)+, %a5, %acc0 +3: + movclr.l %acc0, %d3 | get result + asr.l %d1, %d3 | shift qlevel bits right + add.l %a5, %d3 | add residual, which is in a5 by now + move.l %d3, -(%a3) | save, a3 is also one past save location + addq.l #4, %a0 | increment history pointer + subq.l #1, %d0 | decrement sample count + jne .default | are we done? + jra .exit | if so, fall through to exit + + +/* This routine deals with sample widths 24 and lower. All LPC filtering up to + order 8 is done in specially optimised unrolled loops, while every order + above this is handled by a slower default routine. + */ + .global lpc_decode_emac_wide + .align 2 +lpc_decode_emac_wide: + lea.l (-44, %sp), %sp + movem.l %d2-%d7/%a2-%a6, (%sp) + movem.l (44+4, %sp), %d0-%d1/%d3/%a0-%a1 + /* d0 = blocksize, d1 = qlevel, d3 = pred_order + a0 = data, a1 = coeffs + */ + + /* the data pointer always lags behind history pointer by 'pred_order' + samples. since we have one loop for each order, we can hard code this + and free a register by not saving data pointer. + */ + move.l %d3, %d2 + neg.l %d2 + lea.l (%a0, %d2.l*4), %a0 | history + clr.l %d2 + move.l %d2, %macsr | we'll need integer mode for this + tst.l %d0 + jeq .exit | zero samples to process, exit + moveq.l #32, %d2 + sub.l %d1, %d2 | calculate shift amount for extension byte + moveq.l #8, %d4 + cmp.l %d4, %d3 + jgt .wdefault | order is over 8, jump to default case + jmp.l (2, %pc, %d3.l*4) | jump to loop corresponding to pred_order +| jumptable: + bra.w .exit | zero order filter isn't possible, exit function + bra.w .worder1 + bra.w .worder2 + bra.w .worder3 + bra.w .worder4 + bra.w .worder5 + bra.w .worder6 + bra.w .worder7 + +| last jump table entry coincides with target, so leave it out +.worder8: + movem.l (%a1), %d5-%d7/%a1-%a5 | load lpc coefs + move.l (%a0)+, %a6 | load first history sample +1: + mac.l %a6, %a5, (%a0)+, %a6, %acc0 + mac.l %a6, %a4, (%a0)+, %a6, %acc0 + mac.l %a6, %a3, (%a0)+, %a6, %acc0 + mac.l %a6, %a2, (%a0)+, %a6, %acc0 + mac.l %a6, %a1, (%a0)+, %a6, %acc0 + mac.l %a6, %d7, (%a0)+, %a6, %acc0 + mac.l %a6, %d6, (%a0)+, %a6, %acc0 + mac.l %a6, %d5, (-7*4, %a0), %a6, %acc0 | load for the next iteration + move.l %accext01, %d4 | get top 8 bits of sum + movclr.l %acc0, %d3 | then botten 32 bits + lsr.l %d1, %d3 | shift bottom bits qlevel bits right + asl.l %d2, %d4 | shift top bits 32 - qlevel bits left + or.l %d4, %d3 | now combine results + add.l %d3, (%a0) | add residual and save + lea.l (-6*4, %a0), %a0 | point history back at second element + subq.l #1, %d0 | decrement sample count + jne 1b | are we done? + jra .exit + +.worder7: + movem.l (%a1), %d6-%d7/%a1-%a5 + move.l (%a0)+, %a6 +1: + mac.l %a6, %a5, (%a0)+, %a6, %acc0 + mac.l %a6, %a4, (%a0)+, %a6, %acc0 + mac.l %a6, %a3, (%a0)+, %a6, %acc0 + mac.l %a6, %a2, (%a0)+, %a6, %acc0 + mac.l %a6, %a1, (%a0)+, %a6, %acc0 + mac.l %a6, %d7, (%a0)+, %a6, %acc0 + mac.l %a6, %d6, (-6*4, %a0), %a6, %acc0 + move.l %accext01, %d4 + movclr.l %acc0, %d3 + lsr.l %d1, %d3 + asl.l %d2, %d4 + or.l %d4, %d3 + add.l %d3, (%a0) + lea.l (-5*4, %a0), %a0 + subq.l #1, %d0 + jne 1b + jra .exit + +.worder6: + movem.l (%a1), %d7/%a1-%a5 + move.l (%a0)+, %a6 +1: + mac.l %a6, %a5, (%a0)+, %a6, %acc0 + mac.l %a6, %a4, (%a0)+, %a6, %acc0 + mac.l %a6, %a3, (%a0)+, %a6, %acc0 + mac.l %a6, %a2, (%a0)+, %a6, %acc0 + mac.l %a6, %a1, (%a0)+, %a6, %acc0 + mac.l %a6, %d7, (-5*4, %a0), %a6, %acc0 + move.l %accext01, %d4 + movclr.l %acc0, %d3 + lsr.l %d1, %d3 + asl.l %d2, %d4 + or.l %d4, %d3 + add.l %d3, (%a0) + lea.l (-4*4, %a0), %a0 + subq.l #1, %d0 + jne 1b + jra .exit + +.worder5: + movem.l (%a1), %a1-%a5 + move.l (%a0)+, %a6 +1: + mac.l %a6, %a5, (%a0)+, %a6, %acc0 + mac.l %a6, %a4, (%a0)+, %a6, %acc0 + mac.l %a6, %a3, (%a0)+, %a6, %acc0 + mac.l %a6, %a2, (%a0)+, %a6, %acc0 + mac.l %a6, %a1, (-4*4, %a0), %a6, %acc0 + move.l %accext01, %d4 + movclr.l %acc0, %d3 + lsr.l %d1, %d3 + asl.l %d2, %d4 + or.l %d4, %d3 + add.l %d3, (%a0) + lea.l (-3*4, %a0), %a0 + subq.l #1, %d0 + jne 1b + jra .exit + +.worder4: + movem.l (%a1), %a2-%a5 + move.l (%a0)+, %a6 +1: + mac.l %a6, %a5, (%a0)+, %a6, %acc0 + mac.l %a6, %a4, (%a0)+, %a6, %acc0 + mac.l %a6, %a3, (%a0)+, %a6, %acc0 + mac.l %a6, %a2, (-3*4, %a0), %a6, %acc0 + move.l %accext01, %d4 + movclr.l %acc0, %d3 + lsr.l %d1, %d3 + asl.l %d2, %d4 + or.l %d4, %d3 + add.l %d3, (%a0) + subq.l #8, %a0 + subq.l #1, %d0 + jne 1b + jra .exit + +.worder3: + movem.l (%a1), %a3-%a5 + move.l (%a0)+, %a6 +1: + mac.l %a6, %a5, (%a0)+, %a6, %acc0 + mac.l %a6, %a4, (%a0)+, %a6, %acc0 + mac.l %a6, %a3, (-2*4, %a0), %a6, %acc0 + move.l %accext01, %d4 + movclr.l %acc0, %d3 + lsr.l %d1, %d3 + asl.l %d2, %d4 + or.l %d4, %d3 + add.l %d3, (%a0) + subq.l #4, %a0 + subq.l #1, %d0 + jne 1b + jra .exit + +.worder2: + movem.l (%a1), %a4-%a5 + move.l (%a0)+, %a6 +1: + mac.l %a6, %a5, (%a0)+, %a6, %acc0 + mac.l %a6, %a4, %acc0 | data for next iteration is already loaded + move.l %accext01, %d4 + movclr.l %acc0, %d3 + lsr.l %d1, %d3 + asl.l %d2, %d4 + or.l %d4, %d3 + add.l %d3, (%a0) + subq.l #1, %d0 + jne 1b + jra .exit + +.worder1: + move.l (%a1), %a5 + move.l (%a0)+, %a6 +1: + mac.l %a6, %a5, (%a0), %a6, %acc0 + move.l %accext01, %d4 + movclr.l %acc0, %d3 + lsr.l %d1, %d3 + asl.l %d2, %d4 + or.l %d4, %d3 + add.l %a6, %d3 | residual is already in a6 + move.l %d3, (%a0)+ + subq.l #1, %d0 + jne 1b + jra .exit + +.wdefault: + /* we do the filtering in an unrolled by 4 loop as far as we can, and then + do the rest by jump table. */ + lea.l (%a1, %d3.l*4), %a2 | need to start in the other end of coefs + move.l %a0, %a3 | working copy of history pointer + move.l %d3, %d4 + lsr.l #2, %d4 | coefs/4, num of iterations needed in next loop + move.l (%a3)+, %a5 | preload data for loop +1: + lea.l (-4*4, %a2), %a2 | move lpc coef pointer four samples backwards + movem.l (%a2), %d5-%d7/%a4 | load four coefs + mac.l %a5, %a4, (%a3)+, %a5, %acc0 + mac.l %a5, %d7, (%a3)+, %a5, %acc0 + mac.l %a5, %d6, (%a3)+, %a5, %acc0 + mac.l %a5, %d5, (%a3)+, %a5, %acc0 + subq.l #1, %d4 | any more unrolled loop operations left? + jne 1b + + moveq.l #3, %d4 | mask 0x00000003 + and.l %d3, %d4 | get the remaining samples to be filtered + jmp.l (2, %pc, %d4*2) | then jump into mac.l chain +| jumptable: + bra.b 3f | none left + bra.b 2f | one left + bra.b 1f | two left +| three left + move.l -(%a2), %d4 + mac.l %a5, %d4, (%a3)+, %a5, %acc0 +1: + move.l -(%a2), %d4 + mac.l %a5, %d4, (%a3)+, %a5, %acc0 +2: + move.l -(%a2), %d4 + mac.l %a5, %d4, (%a3)+, %a5, %acc0 +3: + move.l %accext01, %d5 | get high 32 bits of result + movclr.l %acc0, %d4 | get low 32 bits of result + lsr.l %d1, %d4 | shift qlevel bits right + asl.l %d2, %d5 | shift 32 - qlevel bits left + or.l %d5, %d4 | combine top and low bits after shift + add.l %a5, %d4 | add residual, which is in a5 by now + move.l %d4, -(%a3) | save, a3 is also one past save location + addq.l #4, %a0 | increment history pointer + subq.l #1, %d0 | decrement sample count + jne .wdefault | are we done? + | if so, fall through to exit + +.exit: + movem.l (%sp), %d2-%d7/%a2-%a6 + lea.l (44, %sp), %sp + rts diff --git a/lib/rbcodec/codecs/libffmpegFLAC/coldfire.h b/lib/rbcodec/codecs/libffmpegFLAC/coldfire.h new file mode 100644 index 0000000000..d6f0996935 --- /dev/null +++ b/lib/rbcodec/codecs/libffmpegFLAC/coldfire.h @@ -0,0 +1,11 @@ +#ifndef _FLAC_COLDFIRE_H +#define _FLAC_COLDFIRE_H + +#include "bitstream.h" + +void lpc_decode_emac(int blocksize, int qlevel, int pred_order, int32_t* data, + int* coeffs); +void lpc_decode_emac_wide(int blocksize, int qlevel, int pred_order, + int32_t* data, int* coeffs); + +#endif diff --git a/lib/rbcodec/codecs/libffmpegFLAC/decoder.c b/lib/rbcodec/codecs/libffmpegFLAC/decoder.c new file mode 100644 index 0000000000..2e92c4b90d --- /dev/null +++ b/lib/rbcodec/codecs/libffmpegFLAC/decoder.c @@ -0,0 +1,627 @@ +/* + * FLAC (Free Lossless Audio Codec) decoder + * Copyright (c) 2003 Alex Beregszaszi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/** + * @file flac.c + * FLAC (Free Lossless Audio Codec) decoder + * @author Alex Beregszaszi + * + * For more information on the FLAC format, visit: + * http://flac.sourceforge.net/ + * + * This decoder can be used in 1 of 2 ways: Either raw FLAC data can be fed + * through, starting from the initial 'fLaC' signature; or by passing the + * 34-byte streaminfo structure through avctx->extradata[_size] followed + * by data starting with the 0xFFF8 marker. + */ + +#include +#include +#ifndef BUILD_STANDALONE +#include "codeclib.h" +#endif + +#include "bitstream.h" +#include "golomb.h" + +#include "decoder.h" + +#if defined(CPU_COLDFIRE) +#include "coldfire.h" +#elif defined(CPU_ARM) +#include "arm.h" +#endif + +static const int sample_rate_table[] ICONST_ATTR = +{ 0, 88200, 176400, 192000, + 8000, 16000, 22050, 24000, 32000, 44100, 48000, 96000, + 0, 0, 0, 0 }; + +static const int sample_size_table[] ICONST_ATTR = +{ 0, 8, 12, 0, 16, 20, 24, 0 }; + +static const int blocksize_table[] ICONST_ATTR = { + 0, 192, 576<<0, 576<<1, 576<<2, 576<<3, 0, 0, +256<<0, 256<<1, 256<<2, 256<<3, 256<<4, 256<<5, 256<<6, 256<<7 +}; + +static const uint8_t table_crc8[256] ICONST_ATTR = { + 0x00, 0x07, 0x0e, 0x09, 0x1c, 0x1b, 0x12, 0x15, + 0x38, 0x3f, 0x36, 0x31, 0x24, 0x23, 0x2a, 0x2d, + 0x70, 0x77, 0x7e, 0x79, 0x6c, 0x6b, 0x62, 0x65, + 0x48, 0x4f, 0x46, 0x41, 0x54, 0x53, 0x5a, 0x5d, + 0xe0, 0xe7, 0xee, 0xe9, 0xfc, 0xfb, 0xf2, 0xf5, + 0xd8, 0xdf, 0xd6, 0xd1, 0xc4, 0xc3, 0xca, 0xcd, + 0x90, 0x97, 0x9e, 0x99, 0x8c, 0x8b, 0x82, 0x85, + 0xa8, 0xaf, 0xa6, 0xa1, 0xb4, 0xb3, 0xba, 0xbd, + 0xc7, 0xc0, 0xc9, 0xce, 0xdb, 0xdc, 0xd5, 0xd2, + 0xff, 0xf8, 0xf1, 0xf6, 0xe3, 0xe4, 0xed, 0xea, + 0xb7, 0xb0, 0xb9, 0xbe, 0xab, 0xac, 0xa5, 0xa2, + 0x8f, 0x88, 0x81, 0x86, 0x93, 0x94, 0x9d, 0x9a, + 0x27, 0x20, 0x29, 0x2e, 0x3b, 0x3c, 0x35, 0x32, + 0x1f, 0x18, 0x11, 0x16, 0x03, 0x04, 0x0d, 0x0a, + 0x57, 0x50, 0x59, 0x5e, 0x4b, 0x4c, 0x45, 0x42, + 0x6f, 0x68, 0x61, 0x66, 0x73, 0x74, 0x7d, 0x7a, + 0x89, 0x8e, 0x87, 0x80, 0x95, 0x92, 0x9b, 0x9c, + 0xb1, 0xb6, 0xbf, 0xb8, 0xad, 0xaa, 0xa3, 0xa4, + 0xf9, 0xfe, 0xf7, 0xf0, 0xe5, 0xe2, 0xeb, 0xec, + 0xc1, 0xc6, 0xcf, 0xc8, 0xdd, 0xda, 0xd3, 0xd4, + 0x69, 0x6e, 0x67, 0x60, 0x75, 0x72, 0x7b, 0x7c, + 0x51, 0x56, 0x5f, 0x58, 0x4d, 0x4a, 0x43, 0x44, + 0x19, 0x1e, 0x17, 0x10, 0x05, 0x02, 0x0b, 0x0c, + 0x21, 0x26, 0x2f, 0x28, 0x3d, 0x3a, 0x33, 0x34, + 0x4e, 0x49, 0x40, 0x47, 0x52, 0x55, 0x5c, 0x5b, + 0x76, 0x71, 0x78, 0x7f, 0x6a, 0x6d, 0x64, 0x63, + 0x3e, 0x39, 0x30, 0x37, 0x22, 0x25, 0x2c, 0x2b, + 0x06, 0x01, 0x08, 0x0f, 0x1a, 0x1d, 0x14, 0x13, + 0xae, 0xa9, 0xa0, 0xa7, 0xb2, 0xb5, 0xbc, 0xbb, + 0x96, 0x91, 0x98, 0x9f, 0x8a, 0x8d, 0x84, 0x83, + 0xde, 0xd9, 0xd0, 0xd7, 0xc2, 0xc5, 0xcc, 0xcb, + 0xe6, 0xe1, 0xe8, 0xef, 0xfa, 0xfd, 0xf4, 0xf3 +}; + +static int64_t get_utf8(GetBitContext *gb) ICODE_ATTR_FLAC; +static int64_t get_utf8(GetBitContext *gb) +{ + uint64_t val; + int ones=0, bytes; + + while(get_bits1(gb)) + ones++; + + if (ones==0) bytes=0; + else if(ones==1) return -1; + else bytes= ones - 1; + + val= get_bits(gb, 7-ones); + while(bytes--){ + const int tmp = get_bits(gb, 8); + + if((tmp>>6) != 2) + return -2; + val<<=6; + val|= tmp&0x3F; + } + return val; +} + +static int get_crc8(const uint8_t *buf, int count) ICODE_ATTR_FLAC; +static int get_crc8(const uint8_t *buf, int count) +{ + int crc=0; + int i; + + for(i=0; igb, 2); + if (method_type > 1){ + //fprintf(stderr,"illegal residual coding method %d\n", method_type); + return -3; + } + + rice_order = get_bits(&s->gb, 4); + + samples= s->blocksize >> rice_order; + + sample= + i= pred_order; + for (partition = 0; partition < (1 << rice_order); partition++) + { + tmp = get_bits(&s->gb, method_type == 0 ? 4 : 5); + if (tmp == (method_type == 0 ? 15 : 31)) + { + //fprintf(stderr,"fixed len partition\n"); + tmp = get_bits(&s->gb, 5); + for (; i < samples; i++, sample++) + decoded[sample] = get_sbits(&s->gb, tmp); + } + else + { + for (; i < samples; i++, sample++){ + decoded[sample] = get_sr_golomb_flac(&s->gb, tmp, INT_MAX, 0); + } + } + i= 0; + } + + return 0; +} + +static int decode_subframe_fixed(FLACContext *s, int32_t* decoded, int pred_order) ICODE_ATTR_FLAC; +static int decode_subframe_fixed(FLACContext *s, int32_t* decoded, int pred_order) +{ + const int blocksize = s->blocksize; + int a, b, c, d, i; + + /* warm up samples */ + for (i = 0; i < pred_order; i++) + { + decoded[i] = get_sbits(&s->gb, s->curr_bps); + } + + if (decode_residuals(s, decoded, pred_order) < 0) + return -4; + + a = decoded[pred_order-1]; + b = a - decoded[pred_order-2]; + c = b - decoded[pred_order-2] + decoded[pred_order-3]; + d = c - decoded[pred_order-2] + 2*decoded[pred_order-3] - decoded[pred_order-4]; + + switch(pred_order) + { + case 0: + break; + case 1: + for (i = pred_order; i < blocksize; i++) + decoded[i] = a += decoded[i]; + break; + case 2: + for (i = pred_order; i < blocksize; i++) + decoded[i] = a += b += decoded[i]; + break; + case 3: + for (i = pred_order; i < blocksize; i++) + decoded[i] = a += b += c += decoded[i]; + break; + case 4: + for (i = pred_order; i < blocksize; i++) + decoded[i] = a += b += c += d += decoded[i]; + break; + default: + return -5; + } + + return 0; +} + +static int decode_subframe_lpc(FLACContext *s, int32_t* decoded, int pred_order) ICODE_ATTR_FLAC; +static int decode_subframe_lpc(FLACContext *s, int32_t* decoded, int pred_order) +{ + int sum, i, j; + int64_t wsum; + int coeff_prec, qlevel; + int coeffs[pred_order]; + + /* warm up samples */ + for (i = 0; i < pred_order; i++) + { + decoded[i] = get_sbits(&s->gb, s->curr_bps); + } + + coeff_prec = get_bits(&s->gb, 4) + 1; + if (coeff_prec == 16) + { + //fprintf(stderr,"invalid coeff precision\n"); + return -6; + } + qlevel = get_sbits(&s->gb, 5); + if (qlevel < 0) + { + //fprintf(stderr,"qlevel %d not supported, maybe buggy stream\n", qlevel); + return -7; + } + + for (i = 0; i < pred_order; i++) + { + coeffs[i] = get_sbits(&s->gb, coeff_prec); + } + + if (decode_residuals(s, decoded, pred_order) < 0) + return -8; + + if ((s->bps + coeff_prec + av_log2(pred_order)) <= 32) { + #if defined(CPU_COLDFIRE) + (void)sum; + lpc_decode_emac(s->blocksize - pred_order, qlevel, pred_order, + decoded + pred_order, coeffs); + #elif defined(CPU_ARM) + (void)sum; + lpc_decode_arm(s->blocksize - pred_order, qlevel, pred_order, + decoded + pred_order, coeffs); + #else + for (i = pred_order; i < s->blocksize; i++) + { + sum = 0; + for (j = 0; j < pred_order; j++) + sum += coeffs[j] * decoded[i-j-1]; + decoded[i] += sum >> qlevel; + } + #endif + } else { + #if defined(CPU_COLDFIRE) + (void)wsum; + (void)j; + lpc_decode_emac_wide(s->blocksize - pred_order, qlevel, pred_order, + decoded + pred_order, coeffs); + #else + for (i = pred_order; i < s->blocksize; i++) + { + wsum = 0; + for (j = 0; j < pred_order; j++) + wsum += (int64_t)coeffs[j] * (int64_t)decoded[i-j-1]; + decoded[i] += wsum >> qlevel; + } + #endif + } + + return 0; +} + +static inline int decode_subframe(FLACContext *s, int channel, int32_t* decoded) +{ + int type, wasted = 0; + int i, tmp; + + s->curr_bps = s->bps; + if(channel == 0){ + if(s->decorrelation == RIGHT_SIDE) + s->curr_bps++; + }else{ + if(s->decorrelation == LEFT_SIDE || s->decorrelation == MID_SIDE) + s->curr_bps++; + } + + if (get_bits1(&s->gb)) + { + //fprintf(stderr,"invalid subframe padding\n"); + return -9; + } + type = get_bits(&s->gb, 6); +// wasted = get_bits1(&s->gb); + +// if (wasted) +// { +// while (!get_bits1(&s->gb)) +// wasted++; +// if (wasted) +// wasted++; +// s->curr_bps -= wasted; +// } +#if 0 + wasted= 16 - av_log2(show_bits(&s->gb, 17)); + skip_bits(&s->gb, wasted+1); + s->curr_bps -= wasted; +#else + if (get_bits1(&s->gb)) + { + wasted = 1; + while (!get_bits1(&s->gb)) + wasted++; + s->curr_bps -= wasted; + //fprintf(stderr,"%d wasted bits\n", wasted); + } +#endif +//FIXME use av_log2 for types + if (type == 0) + { + //fprintf(stderr,"coding type: constant\n"); + tmp = get_sbits(&s->gb, s->curr_bps); + for (i = 0; i < s->blocksize; i++) + decoded[i] = tmp; + } + else if (type == 1) + { + //fprintf(stderr,"coding type: verbatim\n"); + for (i = 0; i < s->blocksize; i++) + decoded[i] = get_sbits(&s->gb, s->curr_bps); + } + else if ((type >= 8) && (type <= 12)) + { + //fprintf(stderr,"coding type: fixed\n"); + if (decode_subframe_fixed(s, decoded, type & ~0x8) < 0) + return -10; + } + else if (type >= 32) + { + //fprintf(stderr,"coding type: lpc\n"); + if (decode_subframe_lpc(s, decoded, (type & ~0x20)+1) < 0) + return -11; + } + else + { + //fprintf(stderr,"Unknown coding type: %d\n",type); + return -12; + } + + if (wasted) + { + int i; + for (i = 0; i < s->blocksize; i++) + decoded[i] <<= wasted; + } + + return 0; +} + +static int decode_frame(FLACContext *s, + void (*yield)(void)) ICODE_ATTR_FLAC; +static int decode_frame(FLACContext *s, + void (*yield)(void)) +{ + int blocksize_code, sample_rate_code, sample_size_code, assignment, crc8; + int decorrelation, bps, blocksize, samplerate; + int res, ch; + + blocksize_code = get_bits(&s->gb, 4); + + sample_rate_code = get_bits(&s->gb, 4); + + assignment = get_bits(&s->gb, 4); /* channel assignment */ + if (assignment < 8 && s->channels == assignment+1) + decorrelation = INDEPENDENT; + else if (assignment >=8 && assignment < 11 && s->channels == 2) + decorrelation = LEFT_SIDE + assignment - 8; + else + { + return -13; + } + + sample_size_code = get_bits(&s->gb, 3); + if(sample_size_code == 0) + bps= s->bps; + else if((sample_size_code != 3) && (sample_size_code != 7)) + bps = sample_size_table[sample_size_code]; + else + { + return -14; + } + + if (get_bits1(&s->gb)) + { + return -15; + } + + /* Get the samplenumber of the first sample in this block */ + s->samplenumber=get_utf8(&s->gb); + + /* samplenumber actually contains the frame number for streams + with a constant block size - so we multiply by blocksize to + get the actual sample number */ + if (s->min_blocksize == s->max_blocksize) { + s->samplenumber*=s->min_blocksize; + } + +#if 0 + if (/*((blocksize_code == 6) || (blocksize_code == 7)) &&*/ + (s->min_blocksize != s->max_blocksize)){ + }else{ + } +#endif + + if (blocksize_code == 0) + blocksize = s->min_blocksize; + else if (blocksize_code == 6) + blocksize = get_bits(&s->gb, 8)+1; + else if (blocksize_code == 7) + blocksize = get_bits(&s->gb, 16)+1; + else + blocksize = blocksize_table[blocksize_code]; + + if(blocksize > s->max_blocksize){ + return -16; + } + + if (sample_rate_code == 0){ + samplerate= s->samplerate; + }else if ((sample_rate_code < 12)) + samplerate = sample_rate_table[sample_rate_code]; + else if (sample_rate_code == 12) + samplerate = get_bits(&s->gb, 8) * 1000; + else if (sample_rate_code == 13) + samplerate = get_bits(&s->gb, 16); + else if (sample_rate_code == 14) + samplerate = get_bits(&s->gb, 16) * 10; + else{ + return -17; + } + + skip_bits(&s->gb, 8); + crc8= get_crc8(s->gb.buffer, get_bits_count(&s->gb)/8); + if(crc8){ + return -18; + } + + s->blocksize = blocksize; + s->samplerate = samplerate; + s->bps = bps; + s->decorrelation= decorrelation; + + for (ch=0; chchannels; ++ch) { + yield(); + if ((res=decode_subframe(s, ch, s->decoded[ch])) < 0) + return res-100; + } + + yield(); + align_get_bits(&s->gb); + + /* frame footer */ + skip_bits(&s->gb, 16); /* data crc */ + + return 0; +} + +static int flac_downmix(FLACContext *s) ICODE_ATTR_FLAC; +static int flac_downmix(FLACContext *s) +{ + int32_t *FL, *FR, *FC, *SB, *RL, *RR; + int32_t *outL = s->decoded[0]; + int32_t *outR = s->decoded[1]; + int i, scale=FLAC_OUTPUT_DEPTH-s->bps; + + switch(s->channels) + { + case 3: /* 3.0 channel order: FL FR FC */ + FL = s->decoded[0]; + FR = s->decoded[1]; + FC = s->decoded[2]; + /* LF = 0.66 LF + 0.33 FC + LR = 0.66 LR + 0.33 FC */ + for (i=0; iblocksize; ++i) { + int32_t a = *(FL)*2 + *(FC); + int32_t b = *(FR)*2 + *(FC); + *outL++ = ((a + (a<<2))>>4) << scale; /* 1/3 ~= 5>>4 */ + *outR++ = ((b + (b<<2))>>4) << scale; /* 1/3 ~= 5>>4 */ + FL++; FR++; FC++; + } + break; + case 4: /* 4.0 channel order: FL FR RL RR */ + FL = s->decoded[0]; + FR = s->decoded[1]; + RL = s->decoded[2]; + RR = s->decoded[3]; + /* LF = 0.50 LF + 0.50 RL + 0.00 RR + LR = 0.50 LR + 0.00 RL + 0.50 RR */ + for (i=0; iblocksize; ++i) { + int32_t a = *(FL) + *(RL); + int32_t b = *(FR) + *(RR); + *outL++ = (a>>1) << scale; + *outR++ = (b>>1) << scale; + FL++; FR++; RL++; RR++; + } + break; + case 5: /* 5.0 channel order: FL FR FC RL RR */ + FL = s->decoded[0]; + FR = s->decoded[1]; + FC = s->decoded[2]; + RL = s->decoded[3]; + RR = s->decoded[4]; + /* LF = 0.40 LF + 0.20 FC + 0.40 RL + 0.00 RR + LR = 0.40 LR + 0.20 FC + 0.00 RL + 0.40 RR */ + for (i=0; iblocksize; ++i) { + int32_t a = *(FL)*2 + *(FC) + *(RL)*2; + int32_t b = *(FR)*2 + *(FC) + *(RR)*2; + *outL++ = ((a + (a<<1))>>4) << scale; /* 3>>4 ~= 1/5 */ + *outR++ = ((b + (b<<1))>>4) << scale; /* 3>>4 ~= 1/5 */ + FL++; FR++; FC++; RL++; RR++; + } + break; + case 6: /* 5.1 channel order: FL FR FC SUB RL RR */ + FL = s->decoded[0]; + FR = s->decoded[1]; + FC = s->decoded[2]; + SB = s->decoded[3]; + RL = s->decoded[4]; + RR = s->decoded[5]; + /* LF = 0.33 LF + 0.16 SUB + 0.16 FC + 0.33 RL + 0.00 RR + LR = 0.33 LR + 0.16 SUB + 0.16 FC + 0.00 RL + 0.33 RR */ + for (i=0; iblocksize; ++i) { + int32_t a = *(FL)*2 + *(SB) + *(FC) + *(RL)*2; + int32_t b = *(FR)*2 + *(SB) + *(FC) + *(RR)*2; + *outL++ = ((a + (a<<2))>>5) << scale; /* 5>>5 ~= 1/6 */ + *outR++ = ((b + (b<<2))>>5) << scale; /* 5>>5 ~= 1/6 */ + FL++; FR++; SB++; FC++; RL++; RR++; + } + break; + default: /* 1.0 and 2.0 do not need downmix, other formats unknown. */ + return -501; + break; + } + return 0; +} + +int flac_decode_frame(FLACContext *s, + uint8_t *buf, int buf_size, + void (*yield)(void)) +{ + int tmp; + int i; + int framesize; + int scale; + + init_get_bits(&s->gb, buf, buf_size*8); + + tmp = get_bits(&s->gb, 16); + if ((tmp & 0xFFFE) != 0xFFF8){ + return -41; + } + + if ((framesize=decode_frame(s,yield)) < 0){ + s->bitstream_size=0; + s->bitstream_index=0; + return framesize; + } + + yield(); + +#define DECORRELATE(left, right)\ + for (i = 0; i < s->blocksize; i++) {\ + int32_t a = s->decoded[0][i];\ + int32_t b = s->decoded[1][i];\ + s->decoded[0][i] = (left) << scale;\ + s->decoded[1][i] = (right) << scale;\ + }\ + + scale=FLAC_OUTPUT_DEPTH-s->bps; + switch(s->decorrelation) + { + case INDEPENDENT: + if (s->channels <= 2) { + DECORRELATE(a, b) /* Always decorrelate exactly the two supported channels. */ + } else { + if ((tmp=flac_downmix(s)) != 0) + return tmp; + } + break; + case LEFT_SIDE: + DECORRELATE(a, a-b) + break; + case RIGHT_SIDE: + DECORRELATE(a+b, b) + break; + case MID_SIDE: + DECORRELATE( (a-=b>>1) + b, a) + break; + } + + s->framesize = (get_bits_count(&s->gb)+7)>>3; + + return 0; +} diff --git a/lib/rbcodec/codecs/libffmpegFLAC/decoder.h b/lib/rbcodec/codecs/libffmpegFLAC/decoder.h new file mode 100644 index 0000000000..677a21ac98 --- /dev/null +++ b/lib/rbcodec/codecs/libffmpegFLAC/decoder.h @@ -0,0 +1,49 @@ +#ifndef _FLAC_DECODER_H +#define _FLAC_DECODER_H + +#include "bitstream.h" + +#define MAX_CHANNELS 6 /* Maximum supported channels, only left/right will be played back */ +#define MAX_BLOCKSIZE 4608 /* Maxsize in samples of one uncompressed frame */ +#define MAX_FRAMESIZE 65536 /* Maxsize in bytes of one compressed frame */ + +#define FLAC_OUTPUT_DEPTH 29 /* Provide samples left-shifted to 28 bits+sign */ + +enum decorrelation_type { + INDEPENDENT, + LEFT_SIDE, + RIGHT_SIDE, + MID_SIDE, +}; + +typedef struct FLACContext { + GetBitContext gb; + + int min_blocksize, max_blocksize; + int min_framesize, max_framesize; + int samplerate, channels; + int blocksize/*, last_blocksize*/; + int bps, curr_bps; + unsigned long samplenumber; + unsigned long totalsamples; + enum decorrelation_type decorrelation; + + int filesize; + int length; + int bitrate; + int metadatalength; + + int bitstream_size; + int bitstream_index; + + int sample_skip; + int framesize; + + int32_t *decoded[MAX_CHANNELS]; +} FLACContext; + +int flac_decode_frame(FLACContext *s, + uint8_t *buf, int buf_size, + void (*yield)(void)) ICODE_ATTR_FLAC; + +#endif diff --git a/lib/rbcodec/codecs/libffmpegFLAC/golomb.h b/lib/rbcodec/codecs/libffmpegFLAC/golomb.h new file mode 100644 index 0000000000..197b78ee1c --- /dev/null +++ b/lib/rbcodec/codecs/libffmpegFLAC/golomb.h @@ -0,0 +1,110 @@ +/* + * exp golomb vlc stuff + * Copyright (c) 2003 Michael Niedermayer + * Copyright (c) 2004 Alex Beregszaszi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include +#include "codeclib.h" + +/** + * @file golomb.h + * @brief + * exp golomb vlc stuff + * @author Michael Niedermayer and Alex Beregszaszi + */ + + +/** + * read unsigned golomb rice code (jpegls). + */ +static inline int get_ur_golomb_jpegls(GetBitContext *gb, int k, int limit, int esc_len){ + unsigned int buf; + int log; + + OPEN_READER(re, gb); + UPDATE_CACHE(re, gb); + buf=GET_CACHE(re, gb); + + log= av_log2(buf); + + if(log - k >= 32-MIN_CACHE_BITS+(MIN_CACHE_BITS==32) && 32-log < limit){ + buf >>= log - k; + buf += (30-log)<>1) ^ -(v&1); +} + +/** + * read unsigned golomb rice code (shorten). + */ +#define get_ur_golomb_shorten(gb, k) get_ur_golomb_jpegls(gb, k, INT_MAX, 0) +/* +static inline unsigned int get_ur_golomb_shorten(GetBitContext *gb, int k){ + return get_ur_golomb_jpegls(gb, k, INT_MAX, 0); +} +*/ + +/** + * read signed golomb rice code (shorten). + */ +static inline int get_sr_golomb_shorten(GetBitContext* gb, int k) +{ + int uvar = get_ur_golomb_jpegls(gb, k + 1, INT_MAX, 0); + if (uvar & 1) + return ~(uvar >> 1); + else + return uvar >> 1; +} diff --git a/lib/rbcodec/codecs/libffmpegFLAC/libffmpegFLAC.make b/lib/rbcodec/codecs/libffmpegFLAC/libffmpegFLAC.make new file mode 100644 index 0000000000..7ae7e96b26 --- /dev/null +++ b/lib/rbcodec/codecs/libffmpegFLAC/libffmpegFLAC.make @@ -0,0 +1,18 @@ +# __________ __ ___. +# Open \______ \ ____ ____ | | _\_ |__ _______ ___ +# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / +# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < +# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ +# \/ \/ \/ \/ \/ +# $Id$ +# + +# libffmpegFLAC +FFMPEGFLACLIB := $(CODECDIR)/libffmpegFLAC.a +FFMPEGFLACLIB_SRC := $(call preprocess, $(RBCODECLIB_DIR)/codecs/libffmpegFLAC/SOURCES) +FFMPEGFLACLIB_OBJ := $(call c2obj, $(FFMPEGFLACLIB_SRC)) +OTHER_SRC += $(FFMPEGFLACLIB_SRC) + +$(FFMPEGFLACLIB): $(FFMPEGFLACLIB_OBJ) + $(SILENT)$(shell rm -f $@) + $(call PRINTS,AR $(@F))$(AR) rcs $@ $^ >/dev/null diff --git a/lib/rbcodec/codecs/libffmpegFLAC/shndec.c b/lib/rbcodec/codecs/libffmpegFLAC/shndec.c new file mode 100644 index 0000000000..40e7211b87 --- /dev/null +++ b/lib/rbcodec/codecs/libffmpegFLAC/shndec.c @@ -0,0 +1,481 @@ +/* + * Shorten decoder + * Copyright (c) 2005 Jeff Muizelaar + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/** + * @file shorten.c + * Shorten decoder + * @author Jeff Muizelaar + * + */ + +#include "bitstream.h" +#include "golomb.h" +#include "shndec.h" +#include "codeclib.h" + +#define ULONGSIZE 2 + +#define WAVE_FORMAT_PCM 0x0001 + +#define TYPESIZE 4 +#define CHANSIZE 0 +#define LPCQSIZE 2 +#define ENERGYSIZE 3 +#define BITSHIFTSIZE 2 + +#define TYPE_S16HL 3 /* signed 16 bit shorts: high-low */ +#define TYPE_S16LH 5 /* signed 16 bit shorts: low-high */ + +#define NWRAP 3 +#define NSKIPSIZE 1 + +#define LPCQUANT 5 +#define V2LPCQOFFSET (1 << LPCQUANT) + +#define FNSIZE 2 + +#define VERBATIM_CKSIZE_SIZE 5 +#define VERBATIM_BYTE_SIZE 8 +#define CANONICAL_HEADER_SIZE 44 + +#define MKTAG(a,b,c,d) (a | (b << 8) | (c << 16) | (d << 24)) + +#define get_le16(gb) bswap_16(get_bits_long(gb, 16)) +#define get_le32(gb) bswap_32(get_bits_long(gb, 32)) + +/* converts fourcc string to int */ +static unsigned int ff_get_fourcc(const char *s){ + //assert( strlen(s)==4 ); + return (s[0]) + (s[1]<<8) + (s[2]<<16) + (s[3]<<24); +} + +static unsigned int get_uint(ShortenContext *s, int k) +{ + if (s->version != 0) + k = get_ur_golomb_shorten(&s->gb, ULONGSIZE); + return get_ur_golomb_shorten(&s->gb, k); +} + +#if defined(CPU_COLDFIRE) +static inline void coldfire_lshift_samples(int n, int shift, int32_t *samples) +{ +/* + for (i = 0; i < n; i++) + samples[i] =<< shift; +*/ + asm volatile ( + "move.l %[n], %%d0 \n" /* d0 = loop counter */ + "asr.l #2, %%d0 \n" + "beq 1f \n" + "2:" /* main loop (unroll by 4) */ + "movem.l (%[x]), %%d4-%%d7 \n" + "asl.l %[s], %%d4 \n" + "asl.l %[s], %%d5 \n" + "asl.l %[s], %%d6 \n" + "asl.l %[s], %%d7 \n" + "movem.l %%d4-%%d7, (%[x]) \n" + "lea.l (16, %[x]), %[x] \n" + + "subq.l #1, %%d0 \n" + "bne 2b \n" + "1:" /* any loops left? */ + "and.l #3, %[n] \n" + "beq 4f \n" + "3:" /* remaining loops */ + "move.l (%[x]), %%d4 \n" + "asl.l %[s], %%d4 \n" + "move.l %%d4, (%[x])+ \n" + + "subq.l #1, %[n] \n" + "bne 3b \n" + "4:" /* exit */ + : [n] "+d" (n), + [x] "+a" (samples) + : [s] "d" (shift) + : "%d0", "%d4", "%d5", "%d6", "%d7", "cc", "memory" + ); +} +#endif + +static inline void fix_bitshift(ShortenContext *s, int32_t *samples) +{ + int i; + + /* Wrapped samples don't get bitshifted, so we'll do them during + the next iteration. */ + if (s->bitshift != 0) { +#if defined(CPU_COLDFIRE) + coldfire_lshift_samples(s->blocksize, s->bitshift, samples - s->nwrap); +#else + for (i = -s->nwrap; i < (s->blocksize - s->nwrap); i++) + samples[i] <<= s->bitshift; +#endif + } + + /* Also, when we have to remember to fix the wrapped samples when + the bitshift changes.*/ + if (s->bitshift != s->last_bitshift) { + if (s->last_bitshift != 0) + for (i = -s->nwrap; i < 0; i++) + samples[i] <<= s->last_bitshift; + + s->last_bitshift = s->bitshift; + } +} + +static inline void decode_subframe_lpc(ShortenContext *s, int32_t *decoded, + int residual_size, int pred_order) +{ + int sum, i, j; + int coeffs[MAX_PRED_ORDER]; + + for (i=0; igb, LPCQUANT); + } + + for (i=0; i < s->blocksize; i++) { + sum = s->lpcqoffset; + for (j=0; jgb, residual_size) + (sum >> LPCQUANT); + } +} + +static inline int shorten_decode_frame(ShortenContext *s, int32_t *decoded, + int32_t *offset) +{ + int i; + int32_t sum; + + int cmd = get_ur_golomb_shorten(&s->gb, FNSIZE); + switch (cmd) { + case FN_ZERO: + case FN_DIFF0: + case FN_DIFF1: + case FN_DIFF2: + case FN_DIFF3: + case FN_QLPC: + { + int residual_size = 0; + int32_t coffset; + if (cmd != FN_ZERO) { + residual_size = get_ur_golomb_shorten(&s->gb, ENERGYSIZE); + /* this is a hack as version 0 differed in defintion of + get_sr_golomb_shorten */ + if (s->version == 0) + residual_size--; + } + + if (s->nmean == 0) { + coffset = offset[0]; + } else { + sum = (s->version < 2) ? 0 : s->nmean / 2; + for (i=0; inmean; i++) + sum += offset[i]; + + coffset = sum / s->nmean; + if (s->version >= 2) + coffset >>= FFMIN(1, s->bitshift); + } + + switch (cmd) { + case FN_ZERO: + for (i=0; iblocksize; i++) + decoded[i] = 0; + break; + + case FN_DIFF0: + for (i=0; iblocksize; i++) + decoded[i] = + get_sr_golomb_shorten(&s->gb, residual_size) + + coffset; + break; + + case FN_DIFF1: + for (i=0; iblocksize; i++) + decoded[i] = + get_sr_golomb_shorten(&s->gb, residual_size) + + decoded[i - 1]; + break; + + case FN_DIFF2: + for (i=0; iblocksize; i++) + decoded[i] = + get_sr_golomb_shorten(&s->gb, residual_size) + + 2*decoded[i-1] - decoded[i-2]; + break; + + case FN_DIFF3: + for (i=0; iblocksize; i++) + decoded[i] = + get_sr_golomb_shorten(&s->gb, residual_size) + + 3*decoded[i-1] - 3*decoded[i-2] + decoded[i-3]; + break; + + case FN_QLPC: + { + int pred_order = get_ur_golomb_shorten(&s->gb, LPCQSIZE); + for (i=0; iblocksize; i++) + decoded[i] += coffset; + } + } + } + + if (s->nmean > 0) { + sum = (s->version < 2) ? 0 : s->blocksize / 2; + for (i=0; iblocksize; i++) + sum += decoded[i]; + + for (i=1; inmean; i++) + offset[i-1] = offset[i]; + + if (s->version < 2) { + offset[s->nmean - 1] = sum / s->blocksize; + } else { + offset[s->nmean - 1] = + (sum / s->blocksize) << s->bitshift; + } + } + + fix_bitshift(s, decoded); + break; + } + + case FN_VERBATIM: + i = get_ur_golomb_shorten(&s->gb, VERBATIM_CKSIZE_SIZE); + while (i--) + get_ur_golomb_shorten(&s->gb, VERBATIM_BYTE_SIZE); + break; + + case FN_BITSHIFT: + s->bitshift = get_ur_golomb_shorten(&s->gb, BITSHIFTSIZE); + break; + + case FN_BLOCKSIZE: + s->blocksize = get_uint(s, av_log2(s->blocksize)); + break; + + case FN_QUIT: + break; + + default: + return FN_ERROR; + break; + } + + return cmd; +} + +int shorten_decode_frames(ShortenContext *s, int *nsamples, + int32_t *decoded0, int32_t *decoded1, + int32_t *offset0, int32_t *offset1, + uint8_t *buf, int buf_size, + void (*yield)(void)) +{ + int32_t *decoded, *offset; + int cmd; + + *nsamples = 0; + + init_get_bits(&s->gb, buf, buf_size*8); + get_bits(&s->gb, s->bitindex); + + int n = 0; + while (n < NUM_DEC_LOOPS) { + int chan = n%2; + if (chan == 0) { + decoded = decoded0 + s->nwrap + *nsamples; + offset = offset0; + } else { + decoded = decoded1 + s->nwrap + *nsamples; + offset = offset1; + } + + yield(); + + cmd = shorten_decode_frame(s, decoded, offset); + + if (cmd == FN_VERBATIM || cmd == FN_BITSHIFT || cmd == FN_BLOCKSIZE) { + continue; + } else if (cmd == FN_QUIT || cmd == FN_ERROR) { + break; + } + + *nsamples += chan * s->blocksize; + n++; + } + + if (*nsamples) { + /* Wrap the samples for the next loop */ + int i; + for (i = 0; i < s->nwrap; i++) { + decoded0[i] = decoded0[*nsamples + i]; + decoded1[i] = decoded1[*nsamples + i]; + } + + /* Scale the samples for the pcmbuf */ + int scale = SHN_OUTPUT_DEPTH - s->bits_per_sample; +#if defined(CPU_COLDFIRE) + coldfire_lshift_samples(*nsamples, scale, decoded0 + s->nwrap); + coldfire_lshift_samples(*nsamples, scale, decoded1 + s->nwrap); +#else + for (i = 0; i < *nsamples; i++) { + decoded0[i + s->nwrap] <<= scale; + decoded1[i + s->nwrap] <<= scale; + } +#endif + } + + return cmd; +} + +static int decode_wave_header(ShortenContext *s, + uint8_t *header, + int header_size) +{ + GetBitContext hb; + int len; + + init_get_bits(&hb, header, header_size*8); + if (get_le32(&hb) != MKTAG('R','I','F','F')) { + return -8; + } + + int chunk_size = get_le32(&hb); + + if (get_le32(&hb) != MKTAG('W','A','V','E')) { + return -9; + } + + while (get_le32(&hb) != MKTAG('f','m','t',' ')) { + len = get_le32(&hb); + skip_bits(&hb, 8*len); + } + + len = get_le32(&hb); + if (len < 16) { + return -10; + } + + if (get_le16(&hb) != WAVE_FORMAT_PCM ) { + return -11; + } + + s->channels = get_le16(&hb); + if (s->channels > MAX_CHANNELS) { + return -3; + } + + s->sample_rate = get_le32(&hb); + + skip_bits(&hb, 32); + //s->bit_rate = 8*get_le32(&hb); + + int block_align = get_le16(&hb); + s->totalsamples = (chunk_size - 36) / block_align; + + s->bits_per_sample = get_le16(&hb); + if (s->bits_per_sample != 16) { + return -12; + } + + len -= 16; + if (len > 0) { + return len; + } + + return 0; +} + +int shorten_init(ShortenContext* s, uint8_t *buf, int buf_size) +{ + int i; + + s->blocksize = DEFAULT_BLOCK_SIZE; + s->channels = 1; + s->nmean = -1; + + init_get_bits(&s->gb, buf, buf_size*8); + get_bits(&s->gb, s->bitindex); + + /* shorten signature */ + if (get_bits_long(&s->gb, 32) != bswap_32(ff_get_fourcc("ajkg"))) { + return -1; + } + + s->version = get_bits(&s->gb, 8); + + int internal_ftype = get_uint(s, TYPESIZE); + if ((internal_ftype != TYPE_S16HL) && (internal_ftype != TYPE_S16LH)) { + return -2; + } + + s->channels = get_uint(s, CHANSIZE); + if (s->channels > MAX_CHANNELS) { + return -3; + } + + /* get blocksize if version > 0 */ + int maxnlpc = 0; + if (s->version > 0) { + s->blocksize = get_uint(s, av_log2(DEFAULT_BLOCK_SIZE)); + maxnlpc = get_uint(s, LPCQSIZE); + s->nmean = get_uint(s, 0); + + int skip_bytes = get_uint(s, NSKIPSIZE); + for (i=0; igb, 8); + } + } + + if (s->nmean > MAX_NMEAN) { + return -4; + } + + s->nwrap = FFMAX(NWRAP, maxnlpc); + if (s->nwrap > MAX_NWRAP) { + return -5; + } + + if (s->version > 1) + s->lpcqoffset = V2LPCQOFFSET; + + if (get_ur_golomb_shorten(&s->gb, FNSIZE) != FN_VERBATIM) { + return -6; + } + + uint8_t header[MAX_HEADER_SIZE]; + int header_size = get_ur_golomb_shorten(&s->gb, VERBATIM_CKSIZE_SIZE); + if (header_size >= MAX_HEADER_SIZE || header_size < CANONICAL_HEADER_SIZE) { + return -7; + } + + for (i=0; igb, VERBATIM_BYTE_SIZE); + + s->header_bits = s->gb.index; + + return decode_wave_header(s, header, header_size); +} diff --git a/lib/rbcodec/codecs/libffmpegFLAC/shndec.h b/lib/rbcodec/codecs/libffmpegFLAC/shndec.h new file mode 100644 index 0000000000..068f4faf28 --- /dev/null +++ b/lib/rbcodec/codecs/libffmpegFLAC/shndec.h @@ -0,0 +1,52 @@ +#include "bitstream.h" + +#define SHN_OUTPUT_DEPTH 29 /* 28 bits + sign */ + +#define MAX_CHANNELS 2 +#define MAX_PRED_ORDER 16 +#define MAX_NWRAP MAX_PRED_ORDER +#define MAX_NMEAN 4 + +/* NUM_DEC_LOOPS should be even number */ +#define NUM_DEC_LOOPS 26 +#define DEFAULT_BLOCK_SIZE 256 +#define MAX_HEADER_SIZE DEFAULT_BLOCK_SIZE*4 +#define MAX_BUFFER_SIZE 2*DEFAULT_BLOCK_SIZE*NUM_DEC_LOOPS +#define MAX_DECODE_SIZE ((DEFAULT_BLOCK_SIZE*NUM_DEC_LOOPS/2) + MAX_NWRAP) +#define MAX_OFFSET_SIZE MAX_NMEAN + +#define FN_DIFF0 0 +#define FN_DIFF1 1 +#define FN_DIFF2 2 +#define FN_DIFF3 3 +#define FN_QUIT 4 +#define FN_BLOCKSIZE 5 +#define FN_BITSHIFT 6 +#define FN_QLPC 7 +#define FN_ZERO 8 +#define FN_VERBATIM 9 +#define FN_ERROR 10 + +typedef struct ShortenContext { + GetBitContext gb; + int32_t lpcqoffset; + uint32_t totalsamples; + int header_bits; + int channels; + int sample_rate; + int bits_per_sample; + int version; + int bitshift; + int last_bitshift; + int nmean; + int nwrap; + int blocksize; + int bitindex; +} ShortenContext; + +int shorten_init(ShortenContext* s, uint8_t *buf, int buf_size); +int shorten_decode_frames(ShortenContext *s, int *nsamples, + int32_t *decoded0, int32_t *decoded1, + int32_t *offset0, int32_t *offset1, + uint8_t *buf, int buf_size, + void (*yield)(void)) ICODE_ATTR; diff --git a/lib/rbcodec/codecs/libgme/2413tone.h b/lib/rbcodec/codecs/libgme/2413tone.h new file mode 100644 index 0000000000..c0922c1225 --- /dev/null +++ b/lib/rbcodec/codecs/libgme/2413tone.h @@ -0,0 +1,20 @@ +/* YM2413 tone by okazaki@angel.ne.jp */ +0x49,0x4c,0x4c,0x32,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x61,0x61,0x1e,0x17,0xf0,0x7f,0x00,0x17,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x13,0x41,0x16,0x0e,0xfd,0xf4,0x23,0x23,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x03,0x01,0x9a,0x04,0xf3,0xf3,0x13,0xf3,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x11,0x61,0x0e,0x07,0xfa,0x64,0x70,0x17,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x22,0x21,0x1e,0x06,0xf0,0x76,0x00,0x28,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x21,0x22,0x16,0x05,0xf0,0x71,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x21,0x61,0x1d,0x07,0x82,0x80,0x17,0x17,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x23,0x21,0x2d,0x16,0x90,0x90,0x00,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x21,0x21,0x1b,0x06,0x64,0x65,0x10,0x17,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x21,0x21,0x0b,0x1a,0x85,0xa0,0x70,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x23,0x01,0x83,0x10,0xff,0xb4,0x10,0xf4,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x97,0xc1,0x20,0x07,0xff,0xf4,0x22,0x22,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x61,0x00,0x0c,0x05,0xc2,0xf6,0x40,0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x01,0x01,0x56,0x03,0x94,0xc2,0x03,0x12,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x21,0x01,0x89,0x03,0xf1,0xe4,0xf0,0x23,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x07,0x21,0x14,0x00,0xee,0xf8,0xff,0xf8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x01,0x31,0x00,0x00,0xf8,0xf7,0xf8,0xf7,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x25,0x11,0x00,0x00,0xf8,0xfa,0xf8,0x55,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 diff --git a/lib/rbcodec/codecs/libgme/281btone.h b/lib/rbcodec/codecs/libgme/281btone.h new file mode 100644 index 0000000000..83f63bff00 --- /dev/null +++ b/lib/rbcodec/codecs/libgme/281btone.h @@ -0,0 +1,20 @@ +/* YMF281B tone by Chabin */ +0x49,0x4c,0x4c,0x32,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x62,0x21,0x1a,0x07,0xf0,0x6f,0x00,0x16,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x10,0x44,0x02,0xf6,0xf4,0x54,0x23,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x03,0x01,0x97,0x04,0xf3,0xf3,0x13,0xf3,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x01,0x61,0x0a,0x0f,0xfa,0x64,0x70,0x17,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x22,0x21,0x1e,0x06,0xf0,0x76,0x00,0x28,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x61,0x8a,0x0e,0xc0,0x61,0x00,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x21,0x61,0x1b,0x07,0x84,0x80,0x17,0x17,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x37,0x32,0xc9,0x01,0x66,0x64,0x40,0x28,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x01,0x21,0x06,0x03,0xa5,0x71,0x51,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x06,0x11,0x5e,0x07,0xf3,0xf2,0xf6,0x11,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x20,0x18,0x06,0xf5,0xf3,0x20,0x26,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x97,0x41,0x20,0x07,0xff,0xf4,0x22,0x22,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x65,0x61,0x15,0x00,0xf7,0xf3,0x16,0xf4,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x01,0x31,0x0e,0x07,0xfa,0xf3,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x48,0x61,0x09,0x07,0xf1,0x94,0xf0,0xf5,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x07,0x21,0x14,0x00,0xee,0xf8,0xff,0xf8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x01,0x31,0x00,0x00,0xf8,0xf7,0xf8,0xf7,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x25,0x11,0x00,0x00,0xf8,0xfa,0xf8,0x55,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 diff --git a/lib/rbcodec/codecs/libgme/AYSOURCES b/lib/rbcodec/codecs/libgme/AYSOURCES new file mode 100644 index 0000000000..f2b52a51d9 --- /dev/null +++ b/lib/rbcodec/codecs/libgme/AYSOURCES @@ -0,0 +1,7 @@ +ay_apu.c +ay_cpu.c +ay_emu.c +blip_buffer.c +multi_buffer.c +track_filter.c +z80_cpu.c diff --git a/lib/rbcodec/codecs/libgme/EMU2413SOURCES b/lib/rbcodec/codecs/libgme/EMU2413SOURCES new file mode 100644 index 0000000000..901c49eccf --- /dev/null +++ b/lib/rbcodec/codecs/libgme/EMU2413SOURCES @@ -0,0 +1,4 @@ +sms_apu.c +sms_fm_apu.c +emu2413.c +ym2413_emu.c diff --git a/lib/rbcodec/codecs/libgme/GBSSOURCES b/lib/rbcodec/codecs/libgme/GBSSOURCES new file mode 100644 index 0000000000..a839a2156e --- /dev/null +++ b/lib/rbcodec/codecs/libgme/GBSSOURCES @@ -0,0 +1,9 @@ +gb_apu.c +gb_cpu.c +gbs_cpu.c +gb_oscs.c +gbs_emu.c +blip_buffer.c +multi_buffer.c +rom_data.c +track_filter.c diff --git a/lib/rbcodec/codecs/libgme/HESSOURCES b/lib/rbcodec/codecs/libgme/HESSOURCES new file mode 100644 index 0000000000..d529388978 --- /dev/null +++ b/lib/rbcodec/codecs/libgme/HESSOURCES @@ -0,0 +1,8 @@ +hes_apu.c +hes_apu_adpcm.c +hes_cpu.c +hes_emu.c +blip_buffer.c +multi_buffer.c +rom_data.c +track_filter.c diff --git a/lib/rbcodec/codecs/libgme/KSSSOURCES b/lib/rbcodec/codecs/libgme/KSSSOURCES new file mode 100644 index 0000000000..bde213364b --- /dev/null +++ b/lib/rbcodec/codecs/libgme/KSSSOURCES @@ -0,0 +1,12 @@ +ay_apu.c +kss_cpu.c +kss_emu.c +kss_scc_apu.c +opl_apu.c +z80_cpu.c +blip_buffer.c +multi_buffer.c +rom_data.c +emu8950.c +emuadpcm.c +track_filter.c diff --git a/lib/rbcodec/codecs/libgme/NSFSOURCES b/lib/rbcodec/codecs/libgme/NSFSOURCES new file mode 100644 index 0000000000..60537ff8e4 --- /dev/null +++ b/lib/rbcodec/codecs/libgme/NSFSOURCES @@ -0,0 +1,15 @@ +nes_apu.c +nes_cpu.c +nes_fds_apu.c +nes_fme7_apu.c +nes_namco_apu.c +nes_oscs.c +nes_vrc6_apu.c +nes_vrc7_apu.c +nsf_cpu.c +nsf_emu.c +nsfe_info.c +blip_buffer.c +multi_buffer.c +rom_data.c +track_filter.c diff --git a/lib/rbcodec/codecs/libgme/SGCSOURCES b/lib/rbcodec/codecs/libgme/SGCSOURCES new file mode 100644 index 0000000000..d0e8abc2b7 --- /dev/null +++ b/lib/rbcodec/codecs/libgme/SGCSOURCES @@ -0,0 +1,7 @@ +sgc_cpu.c +sgc_emu.c +z80_cpu.c +blip_buffer.c +multi_buffer.c +rom_data.c +track_filter.c diff --git a/lib/rbcodec/codecs/libgme/VGMSOURCES b/lib/rbcodec/codecs/libgme/VGMSOURCES new file mode 100644 index 0000000000..bb57e16e82 --- /dev/null +++ b/lib/rbcodec/codecs/libgme/VGMSOURCES @@ -0,0 +1,10 @@ +blip_buffer.c +multi_buffer.c +resampler.c +vgm_emu.c +ym2612_emu.c +track_filter.c +inflate/bbfuncs.c +inflate/inflate.c +inflate/mallocer.c +inflate/mbreader.c diff --git a/lib/rbcodec/codecs/libgme/ay_apu.c b/lib/rbcodec/codecs/libgme/ay_apu.c new file mode 100644 index 0000000000..c84e92d43d --- /dev/null +++ b/lib/rbcodec/codecs/libgme/ay_apu.c @@ -0,0 +1,413 @@ +// Game_Music_Emu 0.6-pre. http://www.slack.net/~ant/ + +#include "ay_apu.h" + +/* Copyright (C) 2006-2008 Shay Green. This module is free software; you +can redistribute it and/or modify it under the terms of the GNU Lesser +General Public License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. This +module is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +details. You should have received a copy of the GNU Lesser General Public +License along with this module; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ + +#include "blargg_source.h" + +// Emulation inaccuracies: +// * Noise isn't run when not in use +// * Changes to envelope and noise periods are delayed until next reload +// * Super-sonic tone should attenuate output to about 60%, not 50% + +// Tones above this frequency are treated as disabled tone at half volume. +// Power of two is more efficient (avoids division). +int const inaudible_freq = 16384; + +int const period_factor = 16; + +static byte const amp_table [16] = +{ +#define ENTRY( n ) (byte) (n * ay_amp_range + 0.5) + // With channels tied together and 1K resistor to ground (as datasheet recommends), + // output nearly matches logarithmic curve as claimed. Approx. 1.5 dB per step. + ENTRY(0.000000),ENTRY(0.007813),ENTRY(0.011049),ENTRY(0.015625), + ENTRY(0.022097),ENTRY(0.031250),ENTRY(0.044194),ENTRY(0.062500), + ENTRY(0.088388),ENTRY(0.125000),ENTRY(0.176777),ENTRY(0.250000), + ENTRY(0.353553),ENTRY(0.500000),ENTRY(0.707107),ENTRY(1.000000), + + /* + // Measured from an AY-3-8910A chip with date code 8611. + + // Direct voltages without any load (very linear) + ENTRY(0.000000),ENTRY(0.046237),ENTRY(0.064516),ENTRY(0.089785), + ENTRY(0.124731),ENTRY(0.173118),ENTRY(0.225806),ENTRY(0.329032), + ENTRY(0.360215),ENTRY(0.494624),ENTRY(0.594624),ENTRY(0.672043), + ENTRY(0.766129),ENTRY(0.841935),ENTRY(0.926882),ENTRY(1.000000), + // With only some load + ENTRY(0.000000),ENTRY(0.011940),ENTRY(0.017413),ENTRY(0.024876), + ENTRY(0.036318),ENTRY(0.054229),ENTRY(0.072637),ENTRY(0.122388), + ENTRY(0.174129),ENTRY(0.239303),ENTRY(0.323881),ENTRY(0.410945), + ENTRY(0.527363),ENTRY(0.651741),ENTRY(0.832338),ENTRY(1.000000), + */ +#undef ENTRY +}; + +static byte const modes [8] = +{ +#define MODE( a0,a1, b0,b1, c0,c1 ) \ + (a0 | a1<<1 | b0<<2 | b1<<3 | c0<<4 | c1<<5) + MODE( 1,0, 1,0, 1,0 ), + MODE( 1,0, 0,0, 0,0 ), + MODE( 1,0, 0,1, 1,0 ), + MODE( 1,0, 1,1, 1,1 ), + MODE( 0,1, 0,1, 0,1 ), + MODE( 0,1, 1,1, 1,1 ), + MODE( 0,1, 1,0, 0,1 ), + MODE( 0,1, 0,0, 0,0 ), +}; + +static void set_output( struct Ay_Apu* this, struct Blip_Buffer* b ) +{ + int i; + for ( i = 0; i < ay_osc_count; ++i ) + Ay_apu_set_output( this, i, b ); +} + +void Ay_apu_init( struct Ay_Apu* this ) +{ + Synth_init( &this->synth_ ); + + // build full table of the upper 8 envelope waveforms + int m; + for ( m = 8; m--; ) + { + byte* out = this->env_modes [m]; + int x, y, flags = modes [m]; + for ( x = 3; --x >= 0; ) + { + int amp = flags & 1; + int end = flags >> 1 & 1; + int step = end - amp; + amp *= 15; + for ( y = 16; --y >= 0; ) + { + *out++ = amp_table [amp]; + amp += step; + } + flags >>= 2; + } + } + + set_output( this, NULL ); + Ay_apu_volume( this, (int)FP_ONE_VOLUME ); + Ay_apu_reset( this ); +} + +void Ay_apu_reset( struct Ay_Apu* this ) +{ + this->addr_ = 0; + this->last_time = 0; + this->noise_delay = 0; + this->noise_lfsr = 1; + + struct osc_t* osc; + for ( osc = &this->oscs [ay_osc_count]; osc != this->oscs; ) + { + osc--; + osc->period = period_factor; + osc->delay = 0; + osc->last_amp = 0; + osc->phase = 0; + } + + int i; + for ( i = sizeof this->regs; --i >= 0; ) + this->regs [i] = 0; + this->regs [7] = 0xFF; + write_data_( this, 13, 0 ); +} + +int Ay_apu_read( struct Ay_Apu* this ) +{ + static byte const masks [ay_reg_count] = { + 0xFF, 0x0F, 0xFF, 0x0F, 0xFF, 0x0F, 0x1F, 0x3F, + 0x1F, 0x1F, 0x1F, 0xFF, 0xFF, 0x0F, 0x00, 0x00 + }; + return this->regs [this->addr_] & masks [this->addr_]; +} + +void write_data_( struct Ay_Apu* this, int addr, int data ) +{ + assert( (unsigned) addr < ay_reg_count ); + + /* if ( (unsigned) addr >= 14 ) + dprintf( "Wrote to I/O port %02X\n", (int) addr ); */ + + // envelope mode + if ( addr == 13 ) + { + if ( !(data & 8) ) // convert modes 0-7 to proper equivalents + data = (data & 4) ? 15 : 9; + this->env_wave = this->env_modes [data - 7]; + this->env_pos = -48; + this->env_delay = 0; // will get set to envelope period in run_until() + } + this->regs [addr] = data; + + // handle period changes accurately + int i = addr >> 1; + if ( i < ay_osc_count ) + { + blip_time_t period = (this->regs [i * 2 + 1] & 0x0F) * (0x100 * period_factor) + + this->regs [i * 2] * period_factor; + if ( !period ) + period = period_factor; + + // adjust time of next timer expiration based on change in period + struct osc_t* osc = &this->oscs [i]; + if ( (osc->delay += period - osc->period) < 0 ) + osc->delay = 0; + osc->period = period; + } + + // TODO: same as above for envelope timer, and it also has a divide by two after it +} + +int const noise_off = 0x08; +int const tone_off = 0x01; + +void run_until( struct Ay_Apu* this, blip_time_t final_end_time ) +{ + require( final_end_time >= this->last_time ); + + // noise period and initial values + blip_time_t const noise_period_factor = period_factor * 2; // verified + blip_time_t noise_period = (this->regs [6] & 0x1F) * noise_period_factor; + if ( !noise_period ) + noise_period = noise_period_factor; + blip_time_t const old_noise_delay = this->noise_delay; + unsigned const old_noise_lfsr = this->noise_lfsr; + + // envelope period + blip_time_t const env_period_factor = period_factor * 2; // verified + blip_time_t env_period = (this->regs [12] * 0x100 + this->regs [11]) * env_period_factor; + if ( !env_period ) + env_period = env_period_factor; // same as period 1 on my AY chip + if ( !this->env_delay ) + this->env_delay = env_period; + + // run each osc separately + int index; + for ( index = 0; index < ay_osc_count; index++ ) + { + struct osc_t* const osc = &this->oscs [index]; + int osc_mode = this->regs [7] >> index; + + // output + struct Blip_Buffer* const osc_output = osc->output; + if ( !osc_output ) + continue; + Blip_set_modified( osc_output ); + + // period + int half_vol = 0; + blip_time_t inaudible_period = (unsigned) (Blip_clock_rate( osc_output ) + + inaudible_freq) / (unsigned) (inaudible_freq * 2); + if ( osc->period <= inaudible_period && !(osc_mode & tone_off) ) + { + half_vol = 1; // Actually around 60%, but 50% is close enough + osc_mode |= tone_off; + } + + // envelope + blip_time_t start_time = this->last_time; + blip_time_t end_time = final_end_time; + int const vol_mode = this->regs [0x08 + index]; + int volume = amp_table [vol_mode & 0x0F] >> half_vol; + int osc_env_pos = this->env_pos; + if ( vol_mode & 0x10 ) + { + volume = this->env_wave [osc_env_pos] >> half_vol; + // use envelope only if it's a repeating wave or a ramp that hasn't finished + if ( !(this->regs [13] & 1) || osc_env_pos < -32 ) + { + end_time = start_time + this->env_delay; + if ( end_time >= final_end_time ) + end_time = final_end_time; + + //if ( !(regs [12] | regs [11]) ) + // dprintf( "Used envelope period 0\n" ); + } + else if ( !volume ) + { + osc_mode = noise_off | tone_off; + } + } + else if ( !volume ) + { + osc_mode = noise_off | tone_off; + } + + // tone time + blip_time_t const period = osc->period; + blip_time_t time = start_time + osc->delay; + if ( osc_mode & tone_off ) // maintain tone's phase when off + { + int count = (final_end_time - time + period - 1) / period; + time += count * period; + osc->phase ^= count & 1; + } + + // noise time + blip_time_t ntime = final_end_time; + unsigned noise_lfsr = 1; + if ( !(osc_mode & noise_off) ) + { + ntime = start_time + old_noise_delay; + noise_lfsr = old_noise_lfsr; + //if ( (regs [6] & 0x1F) == 0 ) + // dprintf( "Used noise period 0\n" ); + } + + // The following efficiently handles several cases (least demanding first): + // * Tone, noise, and envelope disabled, where channel acts as 4-bit DAC + // * Just tone or just noise, envelope disabled + // * Envelope controlling tone and/or noise + // * Tone and noise disabled, envelope enabled with high frequency + // * Tone and noise together + // * Tone and noise together with envelope + + // this loop only runs one iteration if envelope is disabled. If envelope + // is being used as a waveform (tone and noise disabled), this loop will + // still be reasonably efficient since the bulk of it will be skipped. + while ( 1 ) + { + // current amplitude + int amp = 0; + if ( (osc_mode | osc->phase) & 1 & (osc_mode >> 3 | noise_lfsr) ) + amp = volume; + { + int delta = amp - osc->last_amp; + if ( delta ) + { + osc->last_amp = amp; + Synth_offset( &this->synth_, start_time, delta, osc_output ); + } + } + + // Run wave and noise interleved with each catching up to the other. + // If one or both are disabled, their "current time" will be past end time, + // so there will be no significant performance hit. + if ( ntime < end_time || time < end_time ) + { + // Since amplitude was updated above, delta will always be +/- volume, + // so we can avoid using last_amp every time to calculate the delta. + int delta = amp * 2 - volume; + int delta_non_zero = delta != 0; + int phase = osc->phase | (osc_mode & tone_off); assert( tone_off == 0x01 ); + do + { + // run noise + blip_time_t end = end_time; + if ( end_time > time ) end = time; + if ( phase & delta_non_zero ) + { + while ( ntime <= end ) // must advance *past* time to avoid hang + { + int changed = noise_lfsr + 1; + noise_lfsr = (-(noise_lfsr & 1) & 0x12000) ^ (noise_lfsr >> 1); + if ( changed & 2 ) + { + delta = -delta; + Synth_offset( &this->synth_, ntime, delta, osc_output ); + } + ntime += noise_period; + } + } + else + { + // 20 or more noise periods on average for some music + int remain = end - ntime; + int count = remain / noise_period; + if ( remain >= 0 ) + ntime += noise_period + count * noise_period; + } + + // run tone + end = end_time; + if ( end_time > ntime ) end = ntime; + if ( noise_lfsr & delta_non_zero ) + { + while ( time < end ) + { + delta = -delta; + Synth_offset( &this->synth_, time, delta, osc_output ); + time += period; + + // alternate (less-efficient) implementation + //phase ^= 1; + } + phase = (unsigned) (-delta) >> (CHAR_BIT * sizeof (unsigned) - 1); + check( phase == (delta > 0) ); + } + else + { + // loop usually runs less than once + //SUB_CASE_COUNTER( (time < end) * (end - time + period - 1) / period ); + + while ( time < end ) + { + time += period; + phase ^= 1; + } + } + } + while ( time < end_time || ntime < end_time ); + + osc->last_amp = (delta + volume) >> 1; + if ( !(osc_mode & tone_off) ) + osc->phase = phase; + } + + if ( end_time >= final_end_time ) + break; // breaks first time when envelope is disabled + + // next envelope step + if ( ++osc_env_pos >= 0 ) + osc_env_pos -= 32; + volume = this->env_wave [osc_env_pos] >> half_vol; + + start_time = end_time; + end_time += env_period; + if ( end_time > final_end_time ) + end_time = final_end_time; + } + osc->delay = time - final_end_time; + + if ( !(osc_mode & noise_off) ) + { + this->noise_delay = ntime - final_end_time; + this->noise_lfsr = noise_lfsr; + } + } + + // TODO: optimized saw wave envelope? + + // maintain envelope phase + blip_time_t remain = final_end_time - this->last_time - this->env_delay; + if ( remain >= 0 ) + { + int count = (remain + env_period) / env_period; + this->env_pos += count; + if ( this->env_pos >= 0 ) + this->env_pos = (this->env_pos & 31) - 32; + remain -= count * env_period; + assert( -remain <= env_period ); + } + this->env_delay = -remain; + assert( this->env_delay > 0 ); + assert( this->env_pos < 0 ); + + this->last_time = final_end_time; +} diff --git a/lib/rbcodec/codecs/libgme/ay_apu.h b/lib/rbcodec/codecs/libgme/ay_apu.h new file mode 100644 index 0000000000..3df6ba1118 --- /dev/null +++ b/lib/rbcodec/codecs/libgme/ay_apu.h @@ -0,0 +1,79 @@ +// AY-3-8910 sound chip ulator + +// Game_Music_Emu 0.6-pre +#ifndef AY_APU_H +#define AY_APU_H + +#include "blargg_common.h" +#include "blargg_source.h" +#include "blip_buffer.h" + +// Number of registers +enum { ay_reg_count = 16 }; +enum { ay_osc_count = 3 }; +enum { ay_amp_range = 255 }; + +struct osc_t +{ + blip_time_t period; + blip_time_t delay; + short last_amp; + short phase; + struct Blip_Buffer* output; +}; + +struct Ay_Apu { + struct osc_t oscs [ay_osc_count]; + + blip_time_t last_time; + byte addr_; + byte regs [ay_reg_count]; + + blip_time_t noise_delay; + unsigned noise_lfsr; + + blip_time_t env_delay; + byte const* env_wave; + int env_pos; + byte env_modes [8] [48]; // values already passed through volume table + + struct Blip_Synth synth_; // used by Ay_Core for beeper sound +}; + +void Ay_apu_init( struct Ay_Apu* this ); + +// Writes to address register +static inline void Ay_apu_write_addr( struct Ay_Apu* this, int data ) { this->addr_ = data & 0x0F; } + +// Emulates to time t, then writes to current data register +void run_until( struct Ay_Apu* this, blip_time_t final_end_time );; +void write_data_( struct Ay_Apu* this, int addr, int data ); +static inline void Ay_apu_write_data( struct Ay_Apu* this, blip_time_t t, int data ) { run_until( this, t ); write_data_( this, this->addr_, data ); } + +// Reads from current data register +int Ay_apu_read( struct Ay_Apu* this ); + +// Resets sound chip +void Ay_apu_reset( struct Ay_Apu* this ); + +// Sets overall volume, where 1.0 is normal +static inline void Ay_apu_volume( struct Ay_Apu* this, int v ) { Synth_volume( &this->synth_, (v*7)/10 /ay_osc_count/ay_amp_range ); } + +static inline void Ay_apu_set_output( struct Ay_Apu* this, int i, struct Blip_Buffer* out ) +{ + assert( (unsigned) i < ay_osc_count ); + this->oscs [i].output = out; +} + +// Emulates to time t, then subtracts t from the current time. +// OK if previous write call had time slightly after t. +static inline void Ay_apu_end_frame( struct Ay_Apu* this, blip_time_t time ) +{ + if ( time > this->last_time ) + run_until( this, time ); + + this->last_time -= time; + assert( this->last_time >= 0 ); +} + +#endif diff --git a/lib/rbcodec/codecs/libgme/ay_cpu.c b/lib/rbcodec/codecs/libgme/ay_cpu.c new file mode 100644 index 0000000000..5fbfe7c1ea --- /dev/null +++ b/lib/rbcodec/codecs/libgme/ay_cpu.c @@ -0,0 +1,59 @@ +// Game_Music_Emu 0.6-pre. http://www.slack.net/~ant/ + +#include "ay_emu.h" + +#include "blargg_endian.h" +//#include "z80_cpu_log.h" + +/* Copyright (C) 2006-2008 Shay Green. This module is free software; you +can redistribute it and/or modify it under the terms of the GNU Lesser +General Public License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. This +module is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +details. You should have received a copy of the GNU Lesser General Public +License along with this module; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ + +#include "blargg_source.h" + +void cpu_out( struct Ay_Emu* this, cpu_time_t time, addr_t addr, int data ) +{ + if ( (addr & 0xFF) == 0xFE ) + { + check( !cpc_mode ); + this->spectrum_mode = !this->cpc_mode; + + // beeper_mask and last_beeper are 0 if (cpc_mode || !beeper_output) + if ( (data &= this->beeper_mask) != this->last_beeper ) + { + this->last_beeper = data; + int delta = -this->beeper_delta; + this->beeper_delta = delta; + struct Blip_Buffer* bb = this->beeper_output; + Blip_set_modified( bb ); + Synth_offset( &this->apu.synth_, time, delta, bb ); + } + } + else + { + cpu_out_( this, time, addr, data ); + } +} + +#define OUT_PORT( addr, data ) cpu_out( this, TIME(), addr, data ) +#define IN_PORT( addr ) 0xFF // cpu in +#define FLAT_MEM mem + +#define CPU_BEGIN \ +bool run_cpu( struct Ay_Emu* this, cpu_time_t end_time ) \ +{\ + struct Z80_Cpu* cpu = &this->cpu; \ + Z80_set_end_time( cpu, end_time ); \ + byte* const mem = this->mem.ram; // cache + + #include "z80_cpu_run.h" + + return warning; +} diff --git a/lib/rbcodec/codecs/libgme/ay_emu.c b/lib/rbcodec/codecs/libgme/ay_emu.c new file mode 100644 index 0000000000..92faba4929 --- /dev/null +++ b/lib/rbcodec/codecs/libgme/ay_emu.c @@ -0,0 +1,599 @@ +// Game_Music_Emu 0.6-pre. http://www.slack.net/~ant/ + +#include "ay_emu.h" + +#include "blargg_endian.h" + +/* Copyright (C) 2006-2009 Shay Green. This module is free software; you +can redistribute it and/or modify it under the terms of the GNU Lesser +General Public License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. This +module is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +details. You should have received a copy of the GNU Lesser General Public +License along with this module; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ + +#include "blargg_source.h" + +const char* const gme_wrong_file_type = "Wrong file type for this emulator"; + +// TODO: probably don't need detailed errors as to why file is corrupt + +int const spectrum_clock = 3546900; // 128K Spectrum +int const spectrum_period = 70908; + +//int const spectrum_clock = 3500000; // 48K Spectrum +//int const spectrum_period = 69888; + +int const cpc_clock = 2000000; + +static void clear_track_vars( struct Ay_Emu *this ) +{ + this->current_track = -1; + track_stop( &this->track_filter ); +} + +void Ay_init( struct Ay_Emu *this ) +{ + this->sample_rate = 0; + this->mute_mask_ = 0; + this->tempo = (int)FP_ONE_TEMPO; + this->gain = (int)FP_ONE_GAIN; + this->track_count = 0; + + // defaults + this->tfilter = *track_get_setup( &this->track_filter ); + this->tfilter.max_initial = 2; + this->tfilter.lookahead = 6; + this->track_filter.silence_ignored_ = false; + + this->beeper_output = NULL; + disable_beeper( this ); + + Ay_apu_init( &this->apu ); + Z80_init( &this->cpu ); + + // clears fields + this->voice_count = 0; + this->voice_types = 0; + clear_track_vars( this ); +} + +// Track info + +// Given pointer to 2-byte offset of data, returns pointer to data, or NULL if +// offset is 0 or there is less than min_size bytes of data available. +static byte const* get_data( struct file_t const* file, byte const ptr [], int min_size ) +{ + int offset = (int16_t) get_be16( ptr ); + int pos = ptr - (byte const*) file->header; + int size = file->end - (byte const*) file->header; + assert( (unsigned) pos <= (unsigned) size - 2 ); + int limit = size - min_size; + if ( limit < 0 || !offset || (unsigned) (pos + offset) > (unsigned) limit ) + return NULL; + return ptr + offset; +} + +static blargg_err_t parse_header( byte const in [], int size, struct file_t* out ) +{ + if ( size < header_size ) + return gme_wrong_file_type; + + out->header = (struct header_t const*) in; + out->end = in + size; + struct header_t const* h = (struct header_t const*) in; + if ( memcmp( h->tag, "ZXAYEMUL", 8 ) ) + return gme_wrong_file_type; + + out->tracks = get_data( out, h->track_info, (h->max_track + 1) * 4 ); + if ( !out->tracks ) + return "missing track data"; + + return 0; +} + +// Setup + +static void change_clock_rate( struct Ay_Emu *this, int rate ) +{ + this->clock_rate_ = rate; + Buffer_clock_rate( &this->stereo_buf, rate ); +} + +blargg_err_t Ay_load_mem( struct Ay_Emu *this, byte const in [], long size ) +{ + // Unload + this->voice_count = 0; + this->track_count = 0; + this->m3u.size = 0; + clear_track_vars( this ); + + assert( offsetof (struct header_t,track_info [2]) == header_size ); + + RETURN_ERR( parse_header( in, size, &this->file ) ); + + /* if ( file.header->vers > 2 ) + warning( "Unknown file version" ); */ + + this->voice_count = ay_osc_count + 1; // +1 for beeper + static int const types [ay_osc_count + 1] = { + wave_type+0, wave_type+1, wave_type+2, mixed_type+1 + }; + this->voice_types = types; + + Ay_apu_volume( &this->apu, this->gain); + + // Setup buffer + change_clock_rate( this, spectrum_clock ); + RETURN_ERR( Buffer_set_channel_count( &this->stereo_buf, this->voice_count, this->voice_types ) ); + this->buf_changed_count = Buffer_channels_changed_count( &this->stereo_buf ); + + Sound_set_tempo( this, this->tempo ); + Sound_mute_voices( this, this->mute_mask_ ); + + this->track_count = this->file.header->max_track + 1; + return 0; +} + +static void set_beeper_output( struct Ay_Emu *this, struct Blip_Buffer* b ) +{ + this->beeper_output = b; + if ( b && !this->cpc_mode ) + this->beeper_mask = 0x10; + else + disable_beeper( this ); +} + +static void set_voice( struct Ay_Emu *this, int i, struct Blip_Buffer* center ) +{ + if ( i >= ay_osc_count ) + set_beeper_output( this, center ); + else + Ay_apu_set_output( &this->apu, i, center ); +} + +static blargg_err_t run_clocks( struct Ay_Emu *this, blip_time_t* duration, int msec ) +{ +#if defined(ROCKBOX) + (void) msec; +#endif + + cpu_time_t *end = duration; + struct Z80_Cpu* cpu = &this->cpu; + Z80_set_time( cpu, 0 ); + + // Since detection of CPC mode will halve clock rate during the frame + // and thus generate up to twice as much sound, we must generate half + // as much until mode is known. + if ( !(this->spectrum_mode | this->cpc_mode) ) + *end /= 2; + + while ( Z80_time( cpu ) < *end ) + { + run_cpu( this, min( *end, this->next_play ) ); + + if ( Z80_time( cpu ) >= this->next_play ) + { + // next frame + this->next_play += this->play_period; + + if ( cpu->r.iff1 ) + { + // interrupt enabled + + if ( this->mem.ram [cpu->r.pc] == 0x76 ) + cpu->r.pc++; // advance past HALT instruction + + cpu->r.iff1 = 0; + cpu->r.iff2 = 0; + + this->mem.ram [--cpu->r.sp] = (byte) (cpu->r.pc >> 8); + this->mem.ram [--cpu->r.sp] = (byte) (cpu->r.pc); + + // fixed interrupt + cpu->r.pc = 0x38; + Z80_adjust_time( cpu, 12 ); + + if ( cpu->r.im == 2 ) + { + // vectored interrupt + addr_t addr = cpu->r.i * 0x100 + 0xFF; + cpu->r.pc = this->mem.ram [(addr + 1) & 0xFFFF] * 0x100 + this->mem.ram [addr]; + Z80_adjust_time( cpu, 6 ); + } + } + } + } + + // End time frame + *end = Z80_time( cpu ); + this->next_play -= *end; + check( this->next_play >= 0 ); + Z80_adjust_time( cpu, -*end ); + Ay_apu_end_frame( &this->apu, *end ); + return 0; +} + +// Emulation + +void cpu_out_( struct Ay_Emu *this, cpu_time_t time, addr_t addr, int data ) +{ + // Spectrum + if ( !this->cpc_mode ) + { + switch ( addr & 0xFEFF ) + { + case 0xFEFD: + this->spectrum_mode = true; + Ay_apu_write_addr( &this->apu, data ); + return; + + case 0xBEFD: + this->spectrum_mode = true; + Ay_apu_write_data( &this->apu, time, data ); + return; + } + } + + // CPC + if ( !this->spectrum_mode ) + { + switch ( addr >> 8 ) + { + case 0xF6: + switch ( data & 0xC0 ) + { + case 0xC0: + Ay_apu_write_addr( &this->apu, this->cpc_latch ); + goto enable_cpc; + + case 0x80: + Ay_apu_write_data( &this->apu, time, this->cpc_latch ); + goto enable_cpc; + } + break; + + case 0xF4: + this->cpc_latch = data; + goto enable_cpc; + } + } + + /* dprintf( "Unmapped OUT: $%04X <- $%02X\n", addr, data ); */ + return; + +enable_cpc: + if ( !this->cpc_mode ) + { + this->cpc_mode = true; + disable_beeper( this ); + + change_clock_rate( this, cpc_clock ); + Sound_set_tempo( this, this->tempo ); + } +} + +blargg_err_t Ay_set_sample_rate( struct Ay_Emu *this, int rate ) +{ + require( !this->sample_rate ); // sample rate can't be changed once set + Buffer_init( &this->stereo_buf ); + RETURN_ERR( Buffer_set_sample_rate( &this->stereo_buf, rate, 1000 / 20 ) ); + + // Set buffer bass + Buffer_bass_freq( &this->stereo_buf, 160 ); + + this->sample_rate = rate; + RETURN_ERR( track_init( &this->track_filter, this ) ); + this->tfilter.max_silence = 6 * stereo * this->sample_rate; + return 0; +} + +void Sound_mute_voice( struct Ay_Emu *this, int index, bool mute ) +{ + require( (unsigned) index < (unsigned) this->voice_count ); + int bit = 1 << index; + int mask = this->mute_mask_ | bit; + if ( !mute ) + mask ^= bit; + Sound_mute_voices( this, mask ); +} + +void Sound_mute_voices( struct Ay_Emu *this, int mask ) +{ + require( this->sample_rate ); // sample rate must be set first + this->mute_mask_ = mask; + + int i; + for ( i = this->voice_count; i--; ) + { + if ( mask & (1 << i) ) + { + set_voice( this, i, 0 ); + } + else + { + struct channel_t ch = Buffer_channel( &this->stereo_buf, i ); + assert( (ch.center && ch.left && ch.right) || + (!ch.center && !ch.left && !ch.right) ); // all or nothing + set_voice( this, i, ch.center ); + } + } +} + +void Sound_set_tempo( struct Ay_Emu *this, int t ) +{ + require( this->sample_rate ); // sample rate must be set first + int const min = (int)(FP_ONE_TEMPO*0.02); + int const max = (int)(FP_ONE_TEMPO*4.00); + if ( t < min ) t = min; + if ( t > max ) t = max; + this->tempo = t; + + int p = spectrum_period; + if ( this->clock_rate_ != spectrum_clock ) + p = this->clock_rate_ / 50; + + this->play_period = (blip_time_t) ((p * FP_ONE_TEMPO) / t); +} + +blargg_err_t Ay_start_track( struct Ay_Emu *this, int track ) +{ + clear_track_vars( this ); + + // Remap track if playlist available + if ( this->m3u.size > 0 ) { + struct entry_t* e = &this->m3u.entries[track]; + track = e->track; + } + + this->current_track = track; + Buffer_clear( &this->stereo_buf ); + + byte* const mem = this->mem.ram; + + memset( mem + 0x0000, 0xC9, 0x100 ); // fill RST vectors with RET + memset( mem + 0x0100, 0xFF, 0x4000 - 0x100 ); + memset( mem + ram_addr, 0x00, mem_size - ram_addr ); + + // locate data blocks + byte const* const data = get_data( &this->file, this->file.tracks + track * 4 + 2, 14 ); + if ( !data ) + return "file data missing"; + + byte const* const more_data = get_data( &this->file, data + 10, 6 ); + if ( !more_data ) + return "file data missing"; + + byte const* blocks = get_data( &this->file, data + 12, 8 ); + if ( !blocks ) + return "file data missing"; + + // initial addresses + unsigned addr = get_be16( blocks ); + if ( !addr ) + return "file data missing"; + + unsigned init = get_be16( more_data + 2 ); + if ( !init ) + init = addr; + + // copy blocks into memory + do + { + blocks += 2; + unsigned len = get_be16( blocks ); blocks += 2; + if ( addr + len > mem_size ) + { + /* warning( "Bad data block size" ); */ + len = mem_size - addr; + } + check( len ); + byte const* in = get_data( &this->file, blocks, 0 ); blocks += 2; + if ( len > (unsigned) (this->file.end - in) ) + { + /* warning( "File data missing" ); */ + len = this->file.end - in; + } + + memcpy( mem + addr, in, len ); + + if ( this->file.end - blocks < 8 ) + { + /* warning( "File data missing" ); */ + break; + } + } + while ( (addr = get_be16( blocks )) != 0 ); + + // copy and configure driver + static byte const passive [] = { + 0xF3, // DI + 0xCD, 0, 0, // CALL init + 0xED, 0x5E, // LOOP: IM 2 + 0xFB, // EI + 0x76, // HALT + 0x18, 0xFA // JR LOOP + }; + static byte const active [] = { + 0xF3, // DI + 0xCD, 0, 0, // CALL init + 0xED, 0x56, // LOOP: IM 1 + 0xFB, // EI + 0x76, // HALT + 0xCD, 0, 0, // CALL play + 0x18, 0xF7 // JR LOOP + }; + memcpy( mem, passive, sizeof passive ); + int const play_addr = get_be16( more_data + 4 ); + if ( play_addr ) + { + memcpy( mem, active, sizeof active ); + mem [ 9] = play_addr; + mem [10] = play_addr >> 8; + } + mem [2] = init; + mem [3] = init >> 8; + + mem [0x38] = 0xFB; // Put EI at interrupt vector (followed by RET) + + // start at spectrum speed + change_clock_rate( this, spectrum_clock ); + Sound_set_tempo( this, this->tempo ); + + struct registers_t r; + memset( &r, 0, sizeof(struct registers_t) ); + + r.sp = get_be16( more_data ); + r.b.a = r.b.b = r.b.d = r.b.h = data [8]; + r.b.flags = r.b.c = r.b.e = r.b.l = data [9]; + r.alt.w = r.w; + r.ix = r.iy = r.w.hl; + + memset( this->mem.padding1, 0xFF, sizeof this->mem.padding1 ); + + int const mirrored = 0x80; // this much is mirrored after end of memory + memset( this->mem.ram + mem_size + mirrored, 0xFF, sizeof this->mem.ram - mem_size - mirrored ); + memcpy( this->mem.ram + mem_size, this->mem.ram, mirrored ); // some code wraps around (ugh) + + Z80_reset( &this->cpu, this->mem.padding1, this->mem.padding1 ); + Z80_map_mem( &this->cpu, 0, mem_size, this->mem.ram, this->mem.ram ); + this->cpu.r = r; + + this->beeper_delta = (int) ((ay_amp_range*4)/5); + this->last_beeper = 0; + this->next_play = this->play_period; + this->spectrum_mode = false; + this->cpc_mode = false; + this->cpc_latch = 0; + set_beeper_output( this, this->beeper_output ); + Ay_apu_reset( &this->apu ); + + // a few tunes rely on channels having tone enabled at the beginning + Ay_apu_write_addr( &this->apu, 7 ); + Ay_apu_write_data( &this->apu, 0, 0x38 ); + + // convert filter times to samples + struct setup_t s = this->tfilter; + s.max_initial *= this->sample_rate * stereo; + #ifdef GME_DISABLE_SILENCE_LOOKAHEAD + s.lookahead = 1; + #endif + track_setup( &this->track_filter, &s ); + + return track_start( &this->track_filter ); +} + +// Tell/Seek + +static int msec_to_samples( int msec, int sample_rate ) +{ + int sec = msec / 1000; + msec -= sec * 1000; + return (sec * sample_rate + msec * sample_rate / 1000) * stereo; +} + +int Track_tell( struct Ay_Emu *this ) +{ + int rate = this->sample_rate * stereo; + int sec = track_sample_count( &this->track_filter ) / rate; + return sec * 1000 + (track_sample_count( &this->track_filter ) - sec * rate) * 1000 / rate; +} + +blargg_err_t Track_seek( struct Ay_Emu *this, int msec ) +{ + int time = msec_to_samples( msec, this->sample_rate ); + if ( time < track_sample_count( &this->track_filter ) ) + RETURN_ERR( Ay_start_track( this, this->current_track ) ); + return Track_skip( this, time - track_sample_count( &this->track_filter ) ); +} + +blargg_err_t skip_( void *emu, int count ) +{ + struct Ay_Emu* this = (struct Ay_Emu*) emu; + + // for long skip, mute sound + const int threshold = 32768; + if ( count > threshold ) + { + int saved_mute = this->mute_mask_; + Sound_mute_voices( this, ~0 ); + + int n = count - threshold/2; + n &= ~(2048-1); // round to multiple of 2048 + count -= n; + RETURN_ERR( skippy_( &this->track_filter, n ) ); + + Sound_mute_voices( this, saved_mute ); + } + + return skippy_( &this->track_filter, count ); +} + +blargg_err_t Track_skip( struct Ay_Emu *this, int count ) +{ + require( this->current_track >= 0 ); // start_track() must have been called already + return track_skip( &this->track_filter, count ); +} + +int Track_get_length( struct Ay_Emu* this, int n ) +{ + int length = 0; + + byte const* track_info = get_data( &this->file, this->file.tracks + n * 4 + 2, 6 ); + if ( track_info ) + length = get_be16( track_info + 4 ) * (1000 / 50); // frames to msec + + if ( (this->m3u.size > 0) && (n < this->m3u.size) ) { + struct entry_t* entry = &this->m3u.entries [n]; + length = entry->length; + } + + if ( length <= 0 ) + length = 120 * 1000; /* 2 minutes */ + + return length; +} + +void Track_set_fade( struct Ay_Emu *this, int start_msec, int length_msec ) +{ + track_set_fade( &this->track_filter, msec_to_samples( start_msec, this->sample_rate ), + length_msec * this->sample_rate / (1000 / stereo) ); +} + +blargg_err_t Ay_play( struct Ay_Emu *this, int out_count, sample_t* out ) +{ + require( this->current_track >= 0 ); + require( out_count % stereo == 0 ); + return track_play( &this->track_filter, out_count, out ); +} + +blargg_err_t play_( void *emu, int count, sample_t* out ) +{ + struct Ay_Emu* this = (struct Ay_Emu*) emu; + + int remain = count; + while ( remain ) + { + Buffer_disable_immediate_removal( &this->stereo_buf ); + remain -= Buffer_read_samples( &this->stereo_buf, &out [count - remain], remain ); + if ( remain ) + { + if ( this->buf_changed_count != Buffer_channels_changed_count( &this->stereo_buf ) ) + { + this->buf_changed_count = Buffer_channels_changed_count( &this->stereo_buf ); + + // Remute voices + Sound_mute_voices( this, this->mute_mask_ ); + } + int msec = Buffer_length( &this->stereo_buf ); + blip_time_t clocks_emulated = msec * this->clock_rate_ / 1000 - 100; + RETURN_ERR( run_clocks( this, &clocks_emulated, msec ) ); + assert( clocks_emulated ); + Buffer_end_frame( &this->stereo_buf, clocks_emulated ); + } + } + return 0; +} diff --git a/lib/rbcodec/codecs/libgme/ay_emu.h b/lib/rbcodec/codecs/libgme/ay_emu.h new file mode 100644 index 0000000000..7334167876 --- /dev/null +++ b/lib/rbcodec/codecs/libgme/ay_emu.h @@ -0,0 +1,169 @@ +// Sinclair Spectrum AY music file emulator + +// Game_Music_Emu 0.6-pre +#ifndef AY_EMU_H +#define AY_EMU_H + +#include "blargg_source.h" + +#include "multi_buffer.h" +#include "z80_cpu.h" +#include "ay_apu.h" +#include "m3u_playlist.h" +#include "track_filter.h" + +// 64K memory to load code and data into before starting track. Caller +// must parse the AY file. +enum { mem_size = 0x10000 }; +enum { ram_addr = 0x4000 }; // where official RAM starts + +// AY file header +enum { header_size = 0x14 }; +struct header_t +{ + byte tag [8]; + byte vers; + byte player; + byte unused [2]; + byte author [2]; + byte comment [2]; + byte max_track; + byte first_track; + byte track_info [2]; +}; + +struct file_t { + struct header_t const* header; + byte const* tracks; + byte const* end; // end of file data +}; + +struct mem_t { + uint8_t padding1 [0x100]; + uint8_t ram [mem_size + 0x100]; +}; + +struct Ay_Emu { + struct file_t file; + + struct Blip_Buffer* beeper_output; + int beeper_delta; + int last_beeper; + int beeper_mask; + + addr_t play_addr; + cpu_time_t play_period; + cpu_time_t next_play; + + int cpc_latch; + bool spectrum_mode; + bool cpc_mode; + + // general + int voice_count; + int const* voice_types; + int mute_mask_; + int tempo; + int gain; + + int sample_rate; + + // track-specific + int current_track; + int track_count; + + int clock_rate_; + unsigned buf_changed_count; + + // M3u Playlist + struct M3u_Playlist m3u; + + // large items + struct setup_t tfilter; + struct Track_Filter track_filter; + + struct Ay_Apu apu; + struct Multi_Buffer stereo_buf; // NULL if using custom buffer + struct Z80_Cpu cpu; + struct mem_t mem; +}; + +// Basic functionality (see Gme_File.h for file loading/track info functions) +void Ay_init( struct Ay_Emu* this ); + +blargg_err_t Ay_load_mem( struct Ay_Emu* this, byte const in [], long size ); + +// Set output sample rate. Must be called only once before loading file. +blargg_err_t Ay_set_sample_rate( struct Ay_Emu* this, int sample_rate ); + +// Start a track, where 0 is the first track. Also clears warning string. +blargg_err_t Ay_start_track( struct Ay_Emu* this, int track ); + +// Generate 'count' samples info 'buf'. Output is in stereo. Any emulation +// errors set warning string, and major errors also end track. +blargg_err_t Ay_play( struct Ay_Emu* this, int count, sample_t* buf ); + + +// Track status/control + +// Number of milliseconds (1000 msec = 1 second) played since beginning of track +int Track_tell( struct Ay_Emu* this ); + +// Seek to new time in track. Seeking backwards or far forward can take a while. +blargg_err_t Track_seek( struct Ay_Emu* this, int msec ); + +// Skip n samples +blargg_err_t Track_skip( struct Ay_Emu* this, int n ); + +// Set start time and length of track fade out. Once fade ends track_ended() returns +// true. Fade time can be changed while track is playing. +void Track_set_fade( struct Ay_Emu* this, int start_msec, int length_msec ); + +// True if a track has reached its end +static inline bool Track_ended( struct Ay_Emu* this ) +{ + return track_ended( &this->track_filter ); +} + +// Disables automatic end-of-track detection and skipping of silence at beginning +static inline void Track_ignore_silence( struct Ay_Emu* this, bool disable ) +{ + this->track_filter.silence_ignored_ = disable; +} + +// Get track length in milliseconds +int Track_get_length( struct Ay_Emu* this, int n ); + +// Sound customization + +// Adjust song tempo, where 1.0 = normal, 0.5 = half speed, 2.0 = double speed. +// Track length as returned by track_info() assumes a tempo of 1.0. +void Sound_set_tempo( struct Ay_Emu* this, int t ); + +// Mute/unmute voice i, where voice 0 is first voice +void Sound_mute_voice( struct Ay_Emu* this, int index, bool mute ); + +// Set muting state of all voices at once using a bit mask, where -1 mutes them all, +// 0 unmutes them all, 0x01 mutes just the first voice, etc. +void Sound_mute_voices( struct Ay_Emu* this, int mask ); + +// Change overall output amplitude, where 1.0 results in minimal clamping. +// Must be called before set_sample_rate(). +static inline void Sound_set_gain( struct Ay_Emu* this, int g ) +{ + assert( !this->sample_rate ); // you must set gain before setting sample rate + this->gain = g; +} + +// Emulation (You shouldn't touch these) +void cpu_out( struct Ay_Emu* this, cpu_time_t, addr_t, int data ); +void cpu_out_( struct Ay_Emu* this, cpu_time_t, addr_t, int data ); +bool run_cpu( struct Ay_Emu* this, cpu_time_t end ); + +static inline void disable_beeper( struct Ay_Emu *this ) +{ + this->beeper_mask = 0; + this->last_beeper = 0; +} + +#endif diff --git a/lib/rbcodec/codecs/libgme/blargg_common.h b/lib/rbcodec/codecs/libgme/blargg_common.h new file mode 100644 index 0000000000..74cc227eed --- /dev/null +++ b/lib/rbcodec/codecs/libgme/blargg_common.h @@ -0,0 +1,160 @@ +// Sets up common environment for Shay Green's libraries. +// To change configuration options, modify blargg_config.h, not this file. + +#ifndef BLARGG_COMMON_H +#define BLARGG_COMMON_H + +#include +#include +#include +#include + +#undef BLARGG_COMMON_H +// allow blargg_config.h to #include blargg_common.h +#include "blargg_config.h" +#include "blargg_source.h" +#ifndef BLARGG_COMMON_H +#define BLARGG_COMMON_H + +#if defined(ROCKBOX) +#include "codeclib.h" +#endif + +// common defines +#define FP_ONE_CLOCK (1LL << 12) +#define FP_ONE_TEMPO (1LL << 24) +#define FP_ONE_GAIN (1LL << 24) +#define FP_ONE_VOLUME FP_ONE_GAIN + +// IRAM configuration +#if (CONFIG_CPU == MCF5250) +#define EMU2413_CALC_ICODE + +#elif (CONFIG_CPU == PP5022) || (CONFIG_CPU == PP5024) +#define EMU2413_CALC_ICODE ICODE_ATTR + +#elif defined(CPU_S5L870X) +#define EMU2413_CALC_ICODE + +#else +#define EMU2413_CALC_ICODE + +#endif + +// BLARGG_RESTRICT: equivalent to C99's restrict, where supported +#if __GNUC__ >= 3 || _MSC_VER >= 1100 + #define BLARGG_RESTRICT __restrict +#else + #define BLARGG_RESTRICT +#endif + +// STATIC_CAST(T,expr): Used in place of static_cast (expr) +#ifndef STATIC_CAST + #define STATIC_CAST(T,expr) ((T) (expr)) +#endif + +// blargg_err_t (0 on success, otherwise error string) +#ifndef blargg_err_t + typedef const char* blargg_err_t; +#endif + +#define BLARGG_4CHAR( a, b, c, d ) \ + ((a&0xFF)*0x1000000L + (b&0xFF)*0x10000L + (c&0xFF)*0x100L + (d&0xFF)) + +// BOOST_STATIC_ASSERT( expr ): Generates compile error if expr is 0. +#ifndef BOOST_STATIC_ASSERT + #ifdef _MSC_VER + // MSVC6 (_MSC_VER < 1300) fails for use of __LINE__ when /Zl is specified + #define BOOST_STATIC_ASSERT( expr ) \ + void blargg_failed_( int (*arg) [2 / (int) !!(expr) - 1] ) + #else + // Some other compilers fail when declaring same function multiple times in class, + // so differentiate them by line + #define BOOST_STATIC_ASSERT( expr ) \ + void blargg_failed_( int (*arg) [2 / !!(expr) - 1] [__LINE__] ) + #endif +#endif + +// BLARGG_COMPILER_HAS_BOOL: If 0, provides bool support for old compiler. If 1, +// compiler is assumed to support bool. If undefined, availability is determined. +#ifndef BLARGG_COMPILER_HAS_BOOL + #if defined (__MWERKS__) + #if !__option(bool) + #define BLARGG_COMPILER_HAS_BOOL 0 + #endif + #elif defined (_MSC_VER) + #if _MSC_VER < 1100 + #define BLARGG_COMPILER_HAS_BOOL 0 + #endif + #elif defined (__GNUC__) + // supports bool + #elif __cplusplus < 199711 + #define BLARGG_COMPILER_HAS_BOOL 0 + #endif +#endif +#if defined (BLARGG_COMPILER_HAS_BOOL) && !BLARGG_COMPILER_HAS_BOOL + // If you get errors here, modify your blargg_config.h file + typedef int bool; + static bool true = 1; + static bool false = 0; +#endif + +/* My code depends on int being at least 32 bits. Almost everything these days +uses at least 32-bit ints, so it's hard to even find a system with 16-bit ints +to test with. The issue can't be gotten around by using a suitable blargg_int +everywhere either, because int is often converted to implicitly when doing +arithmetic on smaller types. */ +#if UINT_MAX < 0xFFFFFFFF + #error "int must be at least 32 bits" +#endif + +// int8_t etc. + + +// ROCKBOX: If defined, use for int_8_t etc +#if defined (ROCKBOX) + #include +// HAVE_STDINT_H: If defined, use for int8_t etc. +#elif defined (HAVE_STDINT_H) + #include + #define BOOST + +// HAVE_INTTYPES_H: If defined, use for int8_t etc. +#elif defined (HAVE_INTTYPES_H) + #include + #define BOOST + +#else + #if UCHAR_MAX == 0xFF && SCHAR_MAX == 0x7F + typedef signed char int8_t; + typedef unsigned char uint8_t; + #else + // No suitable 8-bit type available + typedef struct see_blargg_common_h int8_t; + typedef struct see_blargg_common_h uint8_t; + #endif + + #if USHRT_MAX == 0xFFFF + typedef short int16_t; + typedef unsigned short uint16_t; + #else + // No suitable 16-bit type available + typedef struct see_blargg_common_h int16_t; + typedef struct see_blargg_common_h uint16_t; + #endif + + #if ULONG_MAX == 0xFFFFFFFF + typedef long int32_t; + typedef unsigned long uint32_t; + #elif UINT_MAX == 0xFFFFFFFF + typedef int int32_t; + typedef unsigned int uint32_t; + #else + // No suitable 32-bit type available + typedef struct see_blargg_common_h int32_t; + typedef struct see_blargg_common_h uint32_t; + #endif +#endif + +#endif +#endif diff --git a/lib/rbcodec/codecs/libgme/blargg_config.h b/lib/rbcodec/codecs/libgme/blargg_config.h new file mode 100644 index 0000000000..398913d1fe --- /dev/null +++ b/lib/rbcodec/codecs/libgme/blargg_config.h @@ -0,0 +1,42 @@ +// Library configuration. Modify this file as necessary. + +#ifndef BLARGG_CONFIG_H +#define BLARGG_CONFIG_H + +// Uncomment to enable platform-specific optimizations +//#define BLARGG_NONPORTABLE 1 + +// Uncomment if automatic byte-order determination doesn't work +#ifdef ROCKBOX_BIG_ENDIAN + #define BLARGG_BIG_ENDIAN 1 +#endif + +// Uncomment if you get errors in the bool section of blargg_common.h +#define BLARGG_COMPILER_HAS_BOOL 1 + +// Uncomment to use fast gb apu implementation +// #define GB_APU_FAST 1 + +// Uncomment to remove agb emulation support +// #define GB_APU_NO_AGB 1 + +// Uncomment to emulate only nes apu +// #define NSF_EMU_APU_ONLY 1 + +// Uncomment to remove vrc7 apu support +// #define NSF_EMU_NO_VRC7 1 + +// Uncomment to remove fmopl apu support +// #define KSS_EMU_NO_FMOPL 1 + +// To handle undefined reference to assert +#define NDEBUG 1 + +// Use standard config.h if present +#define HAVE_CONFIG_H 1 + +#ifdef HAVE_CONFIG_H + #include "config.h" +#endif + +#endif diff --git a/lib/rbcodec/codecs/libgme/blargg_endian.h b/lib/rbcodec/codecs/libgme/blargg_endian.h new file mode 100644 index 0000000000..dce5cb2048 --- /dev/null +++ b/lib/rbcodec/codecs/libgme/blargg_endian.h @@ -0,0 +1,168 @@ +// CPU Byte Order Utilities + +// Game_Music_Emu 0.5.2 +#ifndef BLARGG_ENDIAN +#define BLARGG_ENDIAN + +#include "blargg_common.h" + +// BLARGG_CPU_CISC: Defined if CPU has very few general-purpose registers (< 16) +#if defined (_M_IX86) || defined (_M_IA64) || defined (__i486__) || \ + defined (__x86_64__) || defined (__ia64__) || defined (__i386__) + #define BLARGG_CPU_X86 1 + #define BLARGG_CPU_CISC 1 +#endif + +#if defined (__powerpc__) || defined (__ppc__) || defined (__POWERPC__) || defined (__powerc) + #define BLARGG_CPU_POWERPC 1 +#endif + +// BLARGG_BIG_ENDIAN, BLARGG_LITTLE_ENDIAN: Determined automatically, otherwise only +// one may be #defined to 1. Only needed if something actually depends on byte order. +#if !defined (BLARGG_BIG_ENDIAN) && !defined (BLARGG_LITTLE_ENDIAN) +#ifdef __GLIBC__ + // GCC handles this for us + #include + #if __BYTE_ORDER == __LITTLE_ENDIAN + #define BLARGG_LITTLE_ENDIAN 1 + #elif __BYTE_ORDER == __BIG_ENDIAN + #define BLARGG_BIG_ENDIAN 1 + #endif +#else + +#if defined (LSB_FIRST) || defined (__LITTLE_ENDIAN__) || defined (BLARGG_CPU_X86) || \ + (defined (LITTLE_ENDIAN) && LITTLE_ENDIAN+0 != 1234) + #define BLARGG_LITTLE_ENDIAN 1 +#endif + +#if defined (MSB_FIRST) || defined (__BIG_ENDIAN__) || defined (WORDS_BIGENDIAN) || \ + defined (__mips__) || defined (__sparc__) || defined (BLARGG_CPU_POWERPC) || \ + (defined (BIG_ENDIAN) && BIG_ENDIAN+0 != 4321) + #define BLARGG_BIG_ENDIAN 1 +#else + // No endian specified; assume little-endian, since it's most common + #define BLARGG_LITTLE_ENDIAN 1 +#endif +#endif +#endif + +#if defined (BLARGG_LITTLE_ENDIAN) && defined(BLARGG_BIG_ENDIAN) + #undef BLARGG_LITTLE_ENDIAN + #undef BLARGG_BIG_ENDIAN +#endif + +static inline void blargg_verify_byte_order( void ) +{ + #ifndef NDEBUG + #if BLARGG_BIG_ENDIAN + volatile int i = 1; + assert( *(volatile char*) &i == 0 ); + #elif BLARGG_LITTLE_ENDIAN + volatile int i = 1; + assert( *(volatile char*) &i != 0 ); + #endif + #endif +} + +static inline unsigned get_le16( void const* p ) +{ + return (unsigned) ((unsigned char const*) p) [1] << 8 | + (unsigned) ((unsigned char const*) p) [0]; +} + +static inline unsigned get_be16( void const* p ) +{ + return (unsigned) ((unsigned char const*) p) [0] << 8 | + (unsigned) ((unsigned char const*) p) [1]; +} + +static inline unsigned get_le32( void const* p ) +{ + return (unsigned) ((unsigned char const*) p) [3] << 24 | + (unsigned) ((unsigned char const*) p) [2] << 16 | + (unsigned) ((unsigned char const*) p) [1] << 8 | + (unsigned) ((unsigned char const*) p) [0]; +} + +static inline unsigned get_be32( void const* p ) +{ + return (unsigned) ((unsigned char const*) p) [0] << 24 | + (unsigned) ((unsigned char const*) p) [1] << 16 | + (unsigned) ((unsigned char const*) p) [2] << 8 | + (unsigned) ((unsigned char const*) p) [3]; +} + +static inline void set_le16( void* p, unsigned n ) +{ + ((unsigned char*) p) [1] = (unsigned char) (n >> 8); + ((unsigned char*) p) [0] = (unsigned char) n; +} + +static inline void set_be16( void* p, unsigned n ) +{ + ((unsigned char*) p) [0] = (unsigned char) (n >> 8); + ((unsigned char*) p) [1] = (unsigned char) n; +} + +static inline void set_le32( void* p, unsigned n ) +{ + ((unsigned char*) p) [0] = (unsigned char) n; + ((unsigned char*) p) [1] = (unsigned char) (n >> 8); + ((unsigned char*) p) [2] = (unsigned char) (n >> 16); + ((unsigned char*) p) [3] = (unsigned char) (n >> 24); +} + +static inline void set_be32( void* p, unsigned n ) +{ + ((unsigned char*) p) [3] = (unsigned char) n; + ((unsigned char*) p) [2] = (unsigned char) (n >> 8); + ((unsigned char*) p) [1] = (unsigned char) (n >> 16); + ((unsigned char*) p) [0] = (unsigned char) (n >> 24); +} + +#if defined(BLARGG_NONPORTABLE) + // Optimized implementation if byte order is known + #if defined(BLARGG_LITTLE_ENDIAN) + #define GET_LE16( addr ) (*(BOOST::uint16_t*) (addr)) + #define GET_LE32( addr ) (*(BOOST::uint32_t*) (addr)) + #define SET_LE16( addr, data ) (void) (*(BOOST::uint16_t*) (addr) = (data)) + #define SET_LE32( addr, data ) (void) (*(BOOST::uint32_t*) (addr) = (data)) + #elif defined(BLARGG_BIG_ENDIAN) + #define GET_BE16( addr ) (*(BOOST::uint16_t*) (addr)) + #define GET_BE32( addr ) (*(BOOST::uint32_t*) (addr)) + #define SET_BE16( addr, data ) (void) (*(BOOST::uint16_t*) (addr) = (data)) + #define SET_BE32( addr, data ) (void) (*(BOOST::uint32_t*) (addr) = (data)) + #endif + + #if defined(BLARGG_CPU_POWERPC) && defined (__MWERKS__) + // PowerPC has special byte-reversed instructions + // to do: assumes that PowerPC is running in big-endian mode + // to do: implement for other compilers which don't support these macros + #define GET_LE16( addr ) (__lhbrx( (addr), 0 )) + #define GET_LE32( addr ) (__lwbrx( (addr), 0 )) + #define SET_LE16( addr, data ) (__sthbrx( (data), (addr), 0 )) + #define SET_LE32( addr, data ) (__stwbrx( (data), (addr), 0 )) + #endif +#endif + +#ifndef GET_LE16 + #define GET_LE16( addr ) get_le16( addr ) + #define SET_LE16( addr, data ) set_le16( addr, data ) +#endif + +#ifndef GET_LE32 + #define GET_LE32( addr ) get_le32( addr ) + #define SET_LE32( addr, data ) set_le32( addr, data ) +#endif + +#ifndef GET_BE16 + #define GET_BE16( addr ) get_be16( addr ) + #define SET_BE16( addr, data ) set_be16( addr, data ) +#endif + +#ifndef GET_BE32 + #define GET_BE32( addr ) get_be32( addr ) + #define SET_BE32( addr, data ) set_be32( addr, data ) +#endif + +#endif diff --git a/lib/rbcodec/codecs/libgme/blargg_source.h b/lib/rbcodec/codecs/libgme/blargg_source.h new file mode 100644 index 0000000000..ab8e1b072b --- /dev/null +++ b/lib/rbcodec/codecs/libgme/blargg_source.h @@ -0,0 +1,76 @@ +// Included at the beginning of library source files, after all other #include lines +#ifndef BLARGG_SOURCE_H +#define BLARGG_SOURCE_H + +// If debugging is enabled and expr is false, abort program. Meant for checking +// caller-supplied parameters and operations that are outside the control of the +// module. A failed requirement indicates a bug outside the module. +// void require( bool expr ); +#if defined(ROCKBOX) +#undef assert +#define assert( expr ) +#undef require +#define require( expr ) +#else +#undef require +#define require( expr ) assert( expr ) +#endif + +// Like printf() except output goes to debug log file. Might be defined to do +// nothing (not even evaluate its arguments). +// void dprintf( const char* format, ... ); +#if defined(ROCKBOX) +#define dprintf DEBUGF +#else +static inline void blargg_dprintf_( const char* fmt, ... ) { } +#undef dprintf +#define dprintf (1) ? (void) 0 : blargg_dprintf_ +#endif + +// If enabled, evaluate expr and if false, make debug log entry with source file +// and line. Meant for finding situations that should be examined further, but that +// don't indicate a problem. In all cases, execution continues normally. +#undef check +#define check( expr ) ((void) 0) + +/* If expr yields non-NULL error string, returns it from current function, +otherwise continues normally. */ +#undef RETURN_ERR +#define RETURN_ERR( expr ) \ + do {\ + blargg_err_t blargg_return_err_ = (expr);\ + if ( blargg_return_err_ )\ + return blargg_return_err_;\ + } while ( 0 ) + +/* If ptr is NULL, returns out-of-memory error, otherwise continues normally. */ +#undef CHECK_ALLOC +#define CHECK_ALLOC( ptr ) \ + do {\ + if ( !(ptr) )\ + return "Out of memory";\ + } while ( 0 ) + +#ifndef max + #define max(a,b) (((a) > (b)) ? (a) : (b)) +#endif + +#ifndef min + #define min(a,b) (((a) < (b)) ? (a) : (b)) +#endif + +// typedef unsigned char byte; +typedef unsigned char blargg_byte; +#undef byte +#define byte blargg_byte + +// deprecated +#define BLARGG_CHECK_ALLOC CHECK_ALLOC +#define BLARGG_RETURN_ERR RETURN_ERR + +// BLARGG_SOURCE_BEGIN: If defined, #included, allowing redefition of dprintf and check +#ifdef BLARGG_SOURCE_BEGIN + #include BLARGG_SOURCE_BEGIN +#endif + +#endif diff --git a/lib/rbcodec/codecs/libgme/blip_buffer.c b/lib/rbcodec/codecs/libgme/blip_buffer.c new file mode 100644 index 0000000000..ba0a6558d2 --- /dev/null +++ b/lib/rbcodec/codecs/libgme/blip_buffer.c @@ -0,0 +1,225 @@ +// Blip_Buffer 0.4.1. http://www.slack.net/~ant/ + +#include "blip_buffer.h" + +#include +#include +#include +#include + +/* Copyright (C) 2003-2006 Shay Green. This module is free software; you +can redistribute it and/or modify it under the terms of the GNU Lesser +General Public License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. This +module is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +details. You should have received a copy of the GNU Lesser General Public +License along with this module; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ + +#include "blargg_source.h" + +void Blip_init( struct Blip_Buffer* this ) +{ + this->factor_ = UINT_MAX/2 + 1;; + this->buffer_center_ = NULL; + this->buffer_size_ = 0; + this->sample_rate_ = 0; + this->bass_shift_ = 0; + this->clock_rate_ = 0; + this->bass_freq_ = 16; + this->length_ = 0; + + // assumptions code makes about implementation-defined features + #ifndef NDEBUG + // right shift of negative value preserves sign + buf_t_ i = -0x7FFFFFFE; + assert( (i >> 1) == -0x3FFFFFFF ); + + // casting to short truncates to 16 bits and sign-extends + i = 0x18000; + assert( (short) i == -0x8000 ); + #endif + + Blip_clear( this ); +} + +void Blip_clear( struct Blip_Buffer* this ) +{ + bool const entire_buffer = true; + + this->offset_ = 0; + this->reader_accum_ = 0; + this->modified = false; + + if ( this->buffer_ ) + { + int count = (entire_buffer ? this->buffer_size_ : Blip_samples_avail( this )); + memset( this->buffer_, 0, (count + blip_buffer_extra_) * sizeof (delta_t) ); + } +} + +blargg_err_t Blip_set_sample_rate( struct Blip_Buffer* this, int new_rate, int msec ) +{ + // Limit to maximum size that resampled time can represent + int max_size = (((blip_resampled_time_t) -1) >> BLIP_BUFFER_ACCURACY) - + blip_buffer_extra_ - 64; // TODO: -64 isn't needed + int new_size = (new_rate * (msec + 1) + 999) / 1000; + if ( new_size > max_size ) + new_size = max_size; + + // Resize buffer + if ( this->buffer_size_ != new_size ) { + this->buffer_center_ = this->buffer_ + BLIP_MAX_QUALITY/2; + this->buffer_size_ = new_size; + } + + // update things based on the sample rate + this->sample_rate_ = new_rate; + this->length_ = new_size * 1000 / new_rate - 1; + if ( this->clock_rate_ ) + Blip_set_clock_rate( this, this->clock_rate_ ); + Blip_bass_freq( this, this->bass_freq_ ); + + Blip_clear( this ); + + return 0; // success +} + +blip_resampled_time_t Blip_clock_rate_factor( struct Blip_Buffer* this, int rate ) +{ + int factor = (int) ( this->sample_rate_ * (1LL << BLIP_BUFFER_ACCURACY) / rate); + assert( factor > 0 || !this->sample_rate_ ); // fails if clock/output ratio is too large + return (blip_resampled_time_t) factor; +} + +void Blip_bass_freq( struct Blip_Buffer* this, int freq ) +{ + this->bass_freq_ = freq; + int shift = 31; + if ( freq > 0 && this->sample_rate_ ) + { + shift = 13; + int f = (freq << 16) / this->sample_rate_; + while ( (f >>= 1) && --shift ) { } + } + this->bass_shift_ = shift; +} + +void Blip_end_frame( struct Blip_Buffer* this, blip_time_t t ) +{ + this->offset_ += t * this->factor_; + assert( Blip_samples_avail( this ) <= (int) this->buffer_size_ ); // time outside buffer length +} + +int Blip_count_samples( struct Blip_Buffer* this, blip_time_t t ) +{ + blip_resampled_time_t last_sample = Blip_resampled_time( this, t ) >> BLIP_BUFFER_ACCURACY; + blip_resampled_time_t first_sample = this->offset_ >> BLIP_BUFFER_ACCURACY; + return (int) (last_sample - first_sample); +} + +blip_time_t Blip_count_clocks( struct Blip_Buffer* this, int count ) +{ + if ( count > this->buffer_size_ ) + count = this->buffer_size_; + blip_resampled_time_t time = (blip_resampled_time_t) count << BLIP_BUFFER_ACCURACY; + return (blip_time_t) ((time - this->offset_ + this->factor_ - 1) / this->factor_); +} + +void Blip_remove_samples( struct Blip_Buffer* this, int count ) +{ + if ( count ) + { + Blip_remove_silence( this, count ); + + // copy remaining samples to beginning and clear old samples + int remain = Blip_samples_avail( this ) + blip_buffer_extra_; + memmove( this->buffer_, this->buffer_ + count, remain * sizeof *this->buffer_ ); + memset( this->buffer_ + remain, 0, count * sizeof *this->buffer_ ); + } +} + +int Blip_read_samples( struct Blip_Buffer* this, blip_sample_t out_ [], int max_samples, bool stereo ) +{ + int count = Blip_samples_avail( this ); + if ( count > max_samples ) + count = max_samples; + + if ( count ) + { + int const bass = this->bass_shift_; + delta_t const* reader = this->buffer_ + count; + int reader_sum = this->reader_accum_; + + blip_sample_t* BLARGG_RESTRICT out = out_ + count; + if ( stereo ) + out += count; + int offset = -count; + + if ( !stereo ) + { + do + { + int s = reader_sum >> delta_bits; + + reader_sum -= reader_sum >> bass; + reader_sum += reader [offset]; + + BLIP_CLAMP( s, s ); + out [offset] = (blip_sample_t) s; + } + while ( ++offset ); + } + else + { + do + { + int s = reader_sum >> delta_bits; + + reader_sum -= reader_sum >> bass; + reader_sum += reader [offset]; + + BLIP_CLAMP( s, s ); + out [offset * 2] = (blip_sample_t) s; + } + while ( ++offset ); + } + + this->reader_accum_ = reader_sum; + + Blip_remove_samples( this, count ); + } + return count; +} + +void Blip_mix_samples( struct Blip_Buffer* this, blip_sample_t const in [], int count ) +{ + delta_t* out = this->buffer_center_ + (this->offset_ >> BLIP_BUFFER_ACCURACY); + + int const sample_shift = blip_sample_bits - 16; + int prev = 0; + while ( --count >= 0 ) + { + int s = *in++ << sample_shift; + *out += s - prev; + prev = s; + ++out; + } + *out -= prev; +} + +// Blip_Synth + +void volume_unit( struct Blip_Synth* this, int new_unit ) +{ + this->delta_factor = (int) (new_unit * (1LL << blip_sample_bits) / FP_ONE_VOLUME); +} + +void Synth_init( struct Blip_Synth* this ) +{ + this->buf = 0; + this->last_amp = 0; + this->delta_factor = 0; +} diff --git a/lib/rbcodec/codecs/libgme/blip_buffer.h b/lib/rbcodec/codecs/libgme/blip_buffer.h new file mode 100644 index 0000000000..5fe1f4b9c6 --- /dev/null +++ b/lib/rbcodec/codecs/libgme/blip_buffer.h @@ -0,0 +1,335 @@ +// Band-limited sound synthesis buffer + +// Blip_Buffer 0.4.1 +#ifndef BLIP_BUFFER_H +#define BLIP_BUFFER_H + +#include "blargg_common.h" + +typedef unsigned blip_resampled_time_t; +typedef int blip_time_t; +typedef int clocks_t; + +// Output samples are 16-bit signed, with a range of -32768 to 32767 +typedef short blip_sample_t; + +static int const blip_default_length = 1000 / 4; // Default Blip_Buffer length (1/4 second) + +#ifndef BLIP_MAX_QUALITY + #define BLIP_MAX_QUALITY 2 +#endif + +#ifndef BLIP_BUFFER_ACCURACY + #define BLIP_BUFFER_ACCURACY 16 +#endif + +// linear interpolation needs 8 bits +#ifndef BLIP_PHASE_BITS + #define BLIP_PHASE_BITS 8 +#endif + +static int const blip_res = 1 << BLIP_PHASE_BITS; +static int const blip_buffer_extra_ = BLIP_MAX_QUALITY + 2; + +// Properties of fixed-point sample position +typedef unsigned ufixed_t; // unsigned for more range, optimized shifts +enum { fixed_bits = BLIP_BUFFER_ACCURACY }; // bits in fraction +enum { fixed_unit = 1 << fixed_bits }; // 1.0 samples + +// Deltas in buffer are fixed-point with this many fraction bits. +// Less than 16 for extra range. +enum { delta_bits = 14 }; + +// Pointer to first committed delta sample +typedef int delta_t; + +// Maximun buffer size (48Khz, 50 ms) +enum { blip_buffer_max = 2466 }; + +struct Blip_Buffer { + unsigned factor_; + ufixed_t offset_; + delta_t* buffer_center_; + int buffer_size_; + int reader_accum_; + int bass_shift_; + int bass_freq_; + int sample_rate_; + int clock_rate_; + int length_; + bool modified; + + delta_t buffer_ [blip_buffer_max]; +}; + +// Blip_Buffer_ implementation +static inline ufixed_t to_fixed( struct Blip_Buffer *this, clocks_t t ) +{ + return t * this->factor_ + this->offset_; +} + +static inline delta_t* delta_at( struct Blip_Buffer *this, ufixed_t f ) +{ + assert( (f >> fixed_bits) < (unsigned) this->buffer_size_ ); + return this->buffer_center_ + (f >> fixed_bits); +} + +// Number of samples available for reading with read_samples() +static inline int Blip_samples_avail( struct Blip_Buffer* this ) +{ + return (int) (this->offset_ >> BLIP_BUFFER_ACCURACY); +} + +static inline void Blip_remove_silence( struct Blip_Buffer* this, int count ) +{ + assert( count <= Blip_samples_avail( this ) ); // tried to remove more samples than available + this->offset_ -= (blip_resampled_time_t) count << BLIP_BUFFER_ACCURACY; +} + +// Initializes Blip_Buffer structure +void Blip_init( struct Blip_Buffer* this ); + +// Sets output sample rate and resizes and clears sample buffer +blargg_err_t Blip_set_sample_rate( struct Blip_Buffer* this, int samples_per_sec, int msec_length ); + +// Current output sample rate +static inline int Blip_sample_rate( struct Blip_Buffer* this ) +{ + return this->sample_rate_; +} + +// Sets number of source time units per second +blip_resampled_time_t Blip_clock_rate_factor( struct Blip_Buffer* this, int clock_rate ); +static inline void Blip_set_clock_rate( struct Blip_Buffer* this, int clocks_per_sec ) +{ + this->factor_ = Blip_clock_rate_factor( this, this->clock_rate_ = clocks_per_sec ); +} + +// Number of source time units per second +static inline int Blip_clock_rate( struct Blip_Buffer* this ) +{ + return this->clock_rate_; +} + +static inline int Blip_length( struct Blip_Buffer* this ) +{ + return this->length_; +} + +// Clears buffer and removes all samples +void Blip_clear( struct Blip_Buffer* this ); + +// Use Blip_Synth to add waveform to buffer + +// Resamples to time t, then subtracts t from current time. Appends result of resampling +// to buffer for reading. +void Blip_end_frame( struct Blip_Buffer* this, blip_time_t time ) ICODE_ATTR; + + +// Reads at most n samples to out [0 to n-1] and returns number actually read. If stereo +// is true, writes to out [0], out [2], out [4] etc. instead. +int Blip_read_samples( struct Blip_Buffer* this, blip_sample_t out [], int n, bool stereo ) ICODE_ATTR; + + +// More features + +// Sets flag that tells some Multi_Buffer types that sound was added to buffer, +// so they know that it needs to be mixed in. Only needs to be called once +// per time frame that sound was added. Not needed if not using Multi_Buffer. +static inline void Blip_set_modified( struct Blip_Buffer* this ) { this->modified = true; } + +// Set frequency high-pass filter frequency, where higher values reduce bass more +void Blip_bass_freq( struct Blip_Buffer* this, int frequency ); + + +// Low-level features + +// Removes the first n samples +void Blip_remove_samples( struct Blip_Buffer* this, int n ) ICODE_ATTR; + +// Returns number of clocks needed until n samples will be available. +// If buffer cannot even hold n samples, returns number of clocks +// until buffer becomes full. +blip_time_t Blip_count_clocks( struct Blip_Buffer* this, int count ) ICODE_ATTR; + +// Number of samples that should be mixed before calling Blip_end_frame( t ) +int Blip_count_samples( struct Blip_Buffer* this, blip_time_t t ) ICODE_ATTR; + +// Mixes n samples into buffer +void Blip_mix_samples( struct Blip_Buffer* this, blip_sample_t const in [], int n ) ICODE_ATTR; + + +// Resampled time (sorry, poor documentation right now) + +// Resampled time is fixed-point, in terms of output samples. + +// Converts clock count to resampled time +static inline blip_resampled_time_t Blip_resampled_duration( struct Blip_Buffer* this, int t ) +{ + return t * this->factor_; +} + +// Converts clock time since beginning of current time frame to resampled time +static inline blip_resampled_time_t Blip_resampled_time( struct Blip_Buffer* this, blip_time_t t ) +{ + return t * this->factor_ + this->offset_; +} + + +// Range specifies the greatest expected change in amplitude. Calculate it +// by finding the difference between the maximum and minimum expected +// amplitudes (max - min). + +typedef char coeff_t; + +struct Blip_Synth { + int delta_factor; + int last_amp; + struct Blip_Buffer* buf; +}; + +// Blip_Synth_ +void volume_unit( struct Blip_Synth* this, int new_unit ); + +// Initializes Blip_Synth structure +void Synth_init( struct Blip_Synth* this ); + +// Sets volume of amplitude delta unit +static inline void Synth_volume( struct Blip_Synth* this, int v ) +{ + volume_unit( this, v ); // new_unit = 1 / range * v +} + + +// Low-level interface + +// (in >> sh & mask) * mul +#define BLIP_SH_AND_MUL( in, sh, mask, mul ) \ +((int) (in) / ((1U << (sh)) / (mul)) & (unsigned) ((mask) * (mul))) + +// (T*) ptr + (off >> sh) +#define BLIP_PTR_OFF_SH( T, ptr, off, sh ) \ + ((T*) (BLIP_SH_AND_MUL( off, sh, -1, sizeof (T) ) + (char*) (ptr))) + +// Works directly in terms of fractional output samples. Use resampled time functions in Blip_Buffer +// to convert clock counts to resampled time. +static inline void Synth_offset_resampled( struct Blip_Synth* this, blip_resampled_time_t time, + int delta, struct Blip_Buffer* blip_buf ) +{ + int const half_width = 1; + + delta_t* BLARGG_RESTRICT buf = delta_at( blip_buf, time ); + delta *= this->delta_factor; + + int const phase_shift = BLIP_BUFFER_ACCURACY - BLIP_PHASE_BITS; + int const phase = (half_width & (half_width - 1)) ? + (int) BLIP_SH_AND_MUL( time, phase_shift, blip_res - 1, sizeof (coeff_t) ) * half_width : + (int) BLIP_SH_AND_MUL( time, phase_shift, blip_res - 1, sizeof (coeff_t) * half_width ); + + int left = buf [0] + delta; + + // Kind of crappy, but doing shift after multiply results in overflow. + // Alternate way of delaying multiply by delta_factor results in worse + // sub-sample resolution. + int right = (delta >> BLIP_PHASE_BITS) * phase; + #ifdef BLIP_BUFFER_NOINTERP + // TODO: remove? (just a hack to see how it sounds) + right = 0; + #endif + left -= right; + right += buf [1]; + + buf [0] = left; + buf [1] = right; +} + +// Update amplitude of waveform at given time. Using this requires a separate +// Blip_Synth for each waveform. +static inline void Synth_update( struct Blip_Synth* this, blip_time_t t, int amp ) +{ + int delta = amp - this->last_amp; + this->last_amp = amp; + Synth_offset_resampled( this, to_fixed(this->buf, t), delta, this->buf ); +} + +// Adds amplitude transition at time t. Delta can be positive or negative. +// The actual change in amplitude is delta * volume. +static inline void Synth_offset_inline( struct Blip_Synth* this, blip_time_t t, int delta, struct Blip_Buffer* buf ) +{ + Synth_offset_resampled( this, to_fixed(buf, t), delta, buf ); +} + +#define Synth_offset( synth, time, delta, buf ) Synth_offset_inline( synth, time, delta, buf ) + +// Number of bits in raw sample that covers normal output range. Less than 32 bits to give +// extra amplitude range. That is, +// +1 << (blip_sample_bits-1) = +1.0 +// -1 << (blip_sample_bits-1) = -1.0 +static int const blip_sample_bits = 30; + +// Optimized reading from Blip_Buffer, for use in custom sample output + +// Begin reading from buffer. Name should be unique to the current block. +#define BLIP_READER_BEGIN( name, blip_buffer ) \ + const delta_t* BLARGG_RESTRICT name##_reader_buf = (blip_buffer).buffer_;\ + int name##_reader_accum = (blip_buffer).reader_accum_ + +// Get value to pass to BLIP_READER_NEXT() +#define BLIP_READER_BASS( blip_buffer ) ((blip_buffer).bass_shift_) + +// Constant value to use instead of BLIP_READER_BASS(), for slightly more optimal +// code at the cost of having no bass_freq() functionality +static int const blip_reader_default_bass = 9; + +// Current sample +#define BLIP_READER_READ( name ) (name##_reader_accum >> (blip_sample_bits - 16)) + +// Current raw sample in full internal resolution +#define BLIP_READER_READ_RAW( name ) (name##_reader_accum) + +// Advance to next sample +#define BLIP_READER_NEXT( name, bass ) \ + (void) (name##_reader_accum += *name##_reader_buf++ - (name##_reader_accum >> (bass))) + +// End reading samples from buffer. The number of samples read must now be removed +// using Blip_remove_samples(). +#define BLIP_READER_END( name, blip_buffer ) \ + (void) ((blip_buffer).reader_accum_ = name##_reader_accum) + +#define BLIP_READER_ADJ_( name, offset ) (name##_reader_buf += offset) + +#define BLIP_READER_NEXT_IDX_( name, bass, idx ) {\ + name##_reader_accum -= name##_reader_accum >> (bass);\ + name##_reader_accum += name##_reader_buf [(idx)];\ +} + +#define BLIP_READER_NEXT_RAW_IDX_( name, bass, idx ) {\ + name##_reader_accum -= name##_reader_accum >> (bass);\ + name##_reader_accum +=\ + *(delta_t const*) ((char const*) name##_reader_buf + (idx));\ +} + +//// BLIP_CLAMP + +#if defined(CPU_ARM) && (ARM_ARCH >= 6) + #define BLIP_CLAMP( sample, out ) \ + ({ \ + asm ("ssat %0, #16, %1" \ + : "=r" ( out ) : "r"( sample ) ); \ + out; \ + }) +#else + #if defined (_M_IX86) || defined (_M_IA64) || defined (__i486__) || \ + defined (__x86_64__) || defined (__ia64__) || defined (__i386__) + #define BLIP_X86 1 + #define BLIP_CLAMP_( in ) in < -0x8000 || 0x7FFF < in + #else + #define BLIP_CLAMP_( in ) (blip_sample_t) in != in + #endif + + // Clamp sample to blip_sample_t range + #define BLIP_CLAMP( sample, out )\ + { if ( BLIP_CLAMP_( (sample) ) ) (out) = ((sample) >> 31) ^ 0x7FFF; } +#endif + +#endif diff --git a/lib/rbcodec/codecs/libgme/emu2413.c b/lib/rbcodec/codecs/libgme/emu2413.c new file mode 100644 index 0000000000..01075821cb --- /dev/null +++ b/lib/rbcodec/codecs/libgme/emu2413.c @@ -0,0 +1,1981 @@ +/*********************************************************************************** + + emu2413.c -- YM2413 emulator written by Mitsutaka Okazaki 2001 + + 2001 01-08 : Version 0.10 -- 1st version. + 2001 01-15 : Version 0.20 -- semi-public version. + 2001 01-16 : Version 0.30 -- 1st public version. + 2001 01-17 : Version 0.31 -- Fixed bassdrum problem. + : Version 0.32 -- LPF implemented. + 2001 01-18 : Version 0.33 -- Fixed the drum problem, refine the mix-down method. + -- Fixed the LFO bug. + 2001 01-24 : Version 0.35 -- Fixed the drum problem, + support undocumented EG behavior. + 2001 02-02 : Version 0.38 -- Improved the performance. + Fixed the hi-hat and cymbal model. + Fixed the default percussive datas. + Noise reduction. + Fixed the feedback problem. + 2001 03-03 : Version 0.39 -- Fixed some drum bugs. + Improved the performance. + 2001 03-04 : Version 0.40 -- Improved the feedback. + Change the default table size. + Clock and Rate can be changed during play. + 2001 06-24 : Version 0.50 -- Improved the hi-hat and the cymbal tone. + Added VRC7 patch (OPLL_reset_patch is changed). + Fixed OPLL_reset() bug. + Added OPLL_setMask, OPLL_getMask and OPLL_toggleMask. + Added OPLL_writeIO. + 2001 09-28 : Version 0.51 -- Removed the noise table. + 2002 01-28 : Version 0.52 -- Added Stereo mode. + 2002 02-07 : Version 0.53 -- Fixed some drum bugs. + 2002 02-20 : Version 0.54 -- Added the best quality mode. + 2002 03-02 : Version 0.55 -- Removed OPLL_init & OPLL_close. + 2002 05-30 : Version 0.60 -- Fixed HH&CYM generator and all voice datas. + 2004 04-10 : Version 0.61 -- Added YMF281B tone (defined by Chabin). + + 2011 03-22 : --------------- Modified by gama to use precalculated tables. + + References: + fmopl.c -- 1999,2000 written by Tatsuyuki Satoh (MAME development). + fmopl.c(fixed) -- (C) 2002 Jarek Burczynski. + s_opl.c -- 2001 written by Mamiya (NEZplug development). + fmgen.cpp -- 1999,2000 written by cisc. + fmpac.ill -- 2000 created by NARUTO. + MSX-Datapack + YMU757 data sheet + YM2143 data sheet + +**************************************************************************************/ +#include +#include +#include +#include +#include "emu2413.h" + +#include "emutables.h" +#if !defined(ROCKBOX) + #define EMU2413_CALCUL_TABLES +#else + #define EMU2413_COMPACTION + #include "emutables.h" +#endif + +#if defined(EMU2413_COMPACTION) && !defined(ROCKBOX) +#define OPLL_TONE_NUM 1 +static unsigned char default_inst[OPLL_TONE_NUM][(16 + 3) * 16] = { + { +#include "2413tone.h" + } +}; +#else +#define OPLL_TONE_NUM 3 +static unsigned char default_inst[OPLL_TONE_NUM][(16 + 3) * 16] = { + { +#include "2413tone.h" + }, + { +#include "vrc7tone.h" + }, + { +#include "281btone.h" + } +}; +#endif + +/* Size of Sintable ( 8 -- 18 can be used. 9 recommended.) */ +#define PG_BITS 9 +#define PG_WIDTH (1<>(b)) + +/* Leave the lower b bit(s). */ +#define LOWBITS(c,b) ((c)&((1<<(b))-1)) + +/* Expand x which is s bits to d bits. */ +#define EXPAND_BITS(x,s,d) ((x)<<((d)-(s))) + +/* Expand x which is s bits to d bits and fill expanded bits '1' */ +#define EXPAND_BITS_X(x,s,d) (((x)<<((d)-(s)))|((1<<((d)-(s)))-1)) + +/* Adjust envelope speed which depends on sampling rate. */ +#define RATE_ADJUST(x) (rate==49716?(e_uint32)x:(e_uint32)(((long long)(x)*clk/rate+36)/72)) + +#define MOD(o,x) (&(o)->slot[(x)<<1]) +#define CAR(o,x) (&(o)->slot[((x)<<1)|1]) + +#define BIT(s,b) (((s)>>(b))&1) + +/* Input clock */ +static e_uint32 clk = 844451141; +/* Sampling rate */ +static e_uint32 rate = 3354932; + +/* WaveTable for each envelope amp */ +static e_uint16 fullsintable[PG_WIDTH]; +static e_uint16 halfsintable[PG_WIDTH]; + +static e_uint16 *waveform[2] = { fullsintable, halfsintable }; + +/* LFO Table */ +#ifdef EMU2413_CALCUL_TABLES + static e_int32 pmtable[PM_PG_WIDTH]; + static e_int32 amtable[AM_PG_WIDTH]; + #define PMTABLE(x) pmtable[x] + #define AMTABLE(x) amtable[x] +#else + #define PMTABLE(x) (e_int32)pm_coeff[x] + #if (PM_PG_WIDTH != 256) + #error PM_PG_WIDTH must be set to 256 if EMU2413_CALCUL_TABLES is not defined + #endif + #define AMTABLE(x) (e_int32)am_coeff[x] + #if (AM_PG_WIDTH != 256) + #error AM_PG_WIDTH must be set to 256 if EMU2413_CALCUL_TABLES is not defined + #endif +#endif + +/* Phase delta for LFO */ +static e_uint32 pm_dphase; +static e_uint32 am_dphase; + +/* dB to Liner table */ +static e_int16 DB2LIN_TABLE[(DB_MUTE + DB_MUTE) * 2]; + +/* Liner to Log curve conversion table (for Attack rate). */ +#ifdef EMU2413_CALCUL_TABLES + static e_uint16 ar_adjust_table[1 << EG_BITS]; + #define AR_ADJUST_TABLE(x) ar_adjust_table[x] +#else + #define AR_ADJUST_TABLE(x) ar_adjust_coeff[x] + #if (EG_BITS != 7) + #error EG_BITS must be set to 7 if EMU2413_CALCUL_TABLES is not defined + #endif +#endif + +/* Empty voice data */ +static OPLL_PATCH null_patch = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + +/* Basic voice Data */ +static OPLL_PATCH default_patch[OPLL_TONE_NUM][(16 + 3) * 2]; + +/* Definition of envelope mode */ +enum OPLL_EG_STATE +{ READY, ATTACK, DECAY, SUSHOLD, SUSTINE, RELEASE, SETTLE, FINISH }; + +/* Phase incr table for Attack */ +static e_uint32 dphaseARTable[16][16]; +/* Phase incr table for Decay and Release */ +static e_uint32 dphaseDRTable[16][16]; + +/* KSL + TL Table */ +e_uint8 tllTable[16][8][1 << TL_BITS][4]; +static e_int32 rksTable[2][8][2]; + +/* We may not have too much SRAM in rockbox */ +#if !defined(ROCKBOX) +/* Phase incr table for PG */ +static e_uint32 dphaseTable[512][8][16]; +#endif + +/*************************************************** + + Create tables + +****************************************************/ +#ifdef EMU2413_CALCUL_TABLES +INLINE static e_int32 +Min (e_int32 i, e_int32 j) +{ + if (i < j) + return i; + else + return j; +} + +/* Table for AR to LogCurve. */ +static void +makeAdjustTable (void) +{ + e_int32 i; + + ar_adjust_table[0] = (1 << EG_BITS) - 1; + for (i = 1; i < (1<= DB_MUTE) DB2LIN_TABLE[i] = 0; + DB2LIN_TABLE[i + DB_MUTE + DB_MUTE] = (e_int16) (-DB2LIN_TABLE[i]); + } +} + +#ifdef EMU2413_CALCUL_TABLES +/* Liner(+0.0 - +1.0) to dB((1<> (20 - DP_BITS)); +} +#endif + +static void +makeTllTable (void) +{ +/* Multiplication owith 8 to have an integer result. This allows to remove floating point operation. */ +#define dB2(x) (int)((x)*2*8) + + static int kltable[16] = { + dB2 ( 0.000), dB2 ( 9.000), dB2 (12.000), dB2 (13.875), dB2 (15.000), dB2 (16.125), dB2 (16.875), dB2 (17.625), + dB2 (18.000), dB2 (18.750), dB2 (19.125), dB2 (19.500), dB2 (19.875), dB2 (20.250), dB2 (20.625), dB2 (21.000) + }; + + e_int32 tmp; + e_int32 fnum, block, TL, KL; + + for (fnum = 0; fnum < 16; fnum++) + for (block = 0; block < 8; block++) + for (TL = 0; TL < 64; TL++) + for (KL = 0; KL < 4; KL++) + { + if (KL == 0) + { + tllTable[fnum][block][TL][KL] = TL2EG (TL); + } + else + { + tmp = (e_int32) ((kltable[fnum] - dB2 (3.000) * (7 - block))/8); + if (tmp <= 0) + tllTable[fnum][block][TL][KL] = TL2EG (TL); + else + /* tllTable[fnum][block][TL][KL] = (e_uint32) ((tmp >> (3 - KL)) / EG_STEP) + TL2EG (TL); */ + tllTable[fnum][block][TL][KL] = (e_uint32) ((tmp << KL) / (int)(EG_STEP*8)) + TL2EG (TL); + } + } +} + +#ifdef USE_SPEC_ENV_SPEED +static double attacktime[16][4] = { + {0, 0, 0, 0}, + {1730.15, 1400.60, 1153.43, 988.66}, + {865.08, 700.30, 576.72, 494.33}, + {432.54, 350.15, 288.36, 247.16}, + {216.27, 175.07, 144.18, 123.58}, + {108.13, 87.54, 72.09, 61.79}, + {54.07, 43.77, 36.04, 30.90}, + {27.03, 21.88, 18.02, 15.45}, + {13.52, 10.94, 9.01, 7.72}, + {6.76, 5.47, 4.51, 3.86}, + {3.38, 2.74, 2.25, 1.93}, + {1.69, 1.37, 1.13, 0.97}, + {0.84, 0.70, 0.60, 0.54}, + {0.50, 0.42, 0.34, 0.30}, + {0.28, 0.22, 0.18, 0.14}, + {0.00, 0.00, 0.00, 0.00} +}; + +static double decaytime[16][4] = { + {0, 0, 0, 0}, + {20926.60, 16807.20, 14006.00, 12028.60}, + {10463.30, 8403.58, 7002.98, 6014.32}, + {5231.64, 4201.79, 3501.49, 3007.16}, + {2615.82, 2100.89, 1750.75, 1503.58}, + {1307.91, 1050.45, 875.37, 751.79}, + {653.95, 525.22, 437.69, 375.90}, + {326.98, 262.61, 218.84, 187.95}, + {163.49, 131.31, 109.42, 93.97}, + {81.74, 65.65, 54.71, 46.99}, + {40.87, 32.83, 27.36, 23.49}, + {20.44, 16.41, 13.68, 11.75}, + {10.22, 8.21, 6.84, 5.87}, + {5.11, 4.10, 3.42, 2.94}, + {2.55, 2.05, 1.71, 1.47}, + {1.27, 1.27, 1.27, 1.27} +}; +#endif + +/* Rate Table for Attack */ +static void +makeDphaseARTable (void) +{ + e_int32 AR, Rks, RM, RL; + +#ifdef USE_SPEC_ENV_SPEED + e_uint32 attacktable[16][4]; + + for (RM = 0; RM < 16; RM++) + for (RL = 0; RL < 4; RL++) + { + if (RM == 0) + attacktable[RM][RL] = 0; + else if (RM == 15) + attacktable[RM][RL] = EG_DP_WIDTH; + else + attacktable[RM][RL] = (e_uint32) ((double) (1 << EG_DP_BITS) / (attacktime[RM][RL] * 3579545 / 72000)); + + } +#endif + + for (AR = 0; AR < 16; AR++) + for (Rks = 0; Rks < 16; Rks++) + { + RM = AR + (Rks >> 2); + RL = Rks & 3; + if (RM > 15) + RM = 15; + switch (AR) + { + case 0: + dphaseARTable[AR][Rks] = 0; + break; + case 15: + dphaseARTable[AR][Rks] = 0;/*EG_DP_WIDTH;*/ + break; + default: +#ifdef USE_SPEC_ENV_SPEED + dphaseARTable[AR][Rks] = RATE_ADJUST (attacktable[RM][RL]); +#else + dphaseARTable[AR][Rks] = RATE_ADJUST ((3 * (RL + 4) << (RM + 1))); +#endif + break; + } + } +} + +/* Rate Table for Decay and Release */ +static void +makeDphaseDRTable (void) +{ + e_int32 DR, Rks, RM, RL; + +#ifdef USE_SPEC_ENV_SPEED + e_uint32 decaytable[16][4]; + + for (RM = 0; RM < 16; RM++) + for (RL = 0; RL < 4; RL++) + if (RM == 0) + decaytable[RM][RL] = 0; + else + decaytable[RM][RL] = (e_uint32) ((double) (1 << EG_DP_BITS) / (decaytime[RM][RL] * 3579545 / 72000)); +#endif + + for (DR = 0; DR < 16; DR++) + for (Rks = 0; Rks < 16; Rks++) + { + RM = DR + (Rks >> 2); + RL = Rks & 3; + if (RM > 15) + RM = 15; + switch (DR) + { + case 0: + dphaseDRTable[DR][Rks] = 0; + break; + default: +#ifdef USE_SPEC_ENV_SPEED + dphaseDRTable[DR][Rks] = RATE_ADJUST (decaytable[RM][RL]); +#else + dphaseDRTable[DR][Rks] = RATE_ADJUST ((RL + 4) << (RM - 1)); +#endif + break; + } + } +} + +static void +makeRksTable (void) +{ + + e_int32 fnum8, block, KR; + + for (fnum8 = 0; fnum8 < 2; fnum8++) + for (block = 0; block < 8; block++) + for (KR = 0; KR < 2; KR++) + { + if (KR != 0) + rksTable[fnum8][block][KR] = (block << 1) + fnum8; + else + rksTable[fnum8][block][KR] = block >> 1; + } +} + +void +OPLL_dump2patch (const e_uint8 * dump, OPLL_PATCH * patch) +{ + patch[0].AM = (dump[0] >> 7) & 1; + patch[1].AM = (dump[1] >> 7) & 1; + patch[0].PM = (dump[0] >> 6) & 1; + patch[1].PM = (dump[1] >> 6) & 1; + patch[0].EG = (dump[0] >> 5) & 1; + patch[1].EG = (dump[1] >> 5) & 1; + patch[0].KR = (dump[0] >> 4) & 1; + patch[1].KR = (dump[1] >> 4) & 1; + patch[0].ML = (dump[0]) & 15; + patch[1].ML = (dump[1]) & 15; + patch[0].KL = (dump[2] >> 6) & 3; + patch[1].KL = (dump[3] >> 6) & 3; + patch[0].TL = (dump[2]) & 63; + patch[0].FB = (dump[3]) & 7; + patch[0].WF = (dump[3] >> 3) & 1; + patch[1].WF = (dump[3] >> 4) & 1; + patch[0].AR = (dump[4] >> 4) & 15; + patch[1].AR = (dump[5] >> 4) & 15; + patch[0].DR = (dump[4]) & 15; + patch[1].DR = (dump[5]) & 15; + patch[0].SL = (dump[6] >> 4) & 15; + patch[1].SL = (dump[7] >> 4) & 15; + patch[0].RR = (dump[6]) & 15; + patch[1].RR = (dump[7]) & 15; +} + +void +OPLL_getDefaultPatch (e_int32 type, e_int32 num, OPLL_PATCH * patch) +{ + OPLL_dump2patch (default_inst[type] + num * 16, patch); +} + +static void +makeDefaultPatch ( void ) +{ + e_int32 i, j; + + for (i = 0; i < OPLL_TONE_NUM; i++) + for (j = 0; j < 19; j++) + OPLL_getDefaultPatch (i, j, &default_patch[i][j * 2]); + +} + +void +OPLL_setPatch (OPLL * opll, const e_uint8 * dump) +{ + OPLL_PATCH patch[2]; + int i; + + for (i = 0; i < 19; i++) + { + OPLL_dump2patch (dump + i * 16, patch); + memcpy (&opll->patch[i*2+0], &patch[0], sizeof (OPLL_PATCH)); + memcpy (&opll->patch[i*2+1], &patch[1], sizeof (OPLL_PATCH)); + } +} + +void +OPLL_patch2dump (const OPLL_PATCH * patch, e_uint8 * dump) +{ + dump[0] = (e_uint8) ((patch[0].AM << 7) + (patch[0].PM << 6) + (patch[0].EG << 5) + (patch[0].KR << 4) + patch[0].ML); + dump[1] = (e_uint8) ((patch[1].AM << 7) + (patch[1].PM << 6) + (patch[1].EG << 5) + (patch[1].KR << 4) + patch[1].ML); + dump[2] = (e_uint8) ((patch[0].KL << 6) + patch[0].TL); + dump[3] = (e_uint8) ((patch[1].KL << 6) + (patch[1].WF << 4) + (patch[0].WF << 3) + patch[0].FB); + dump[4] = (e_uint8) ((patch[0].AR << 4) + patch[0].DR); + dump[5] = (e_uint8) ((patch[1].AR << 4) + patch[1].DR); + dump[6] = (e_uint8) ((patch[0].SL << 4) + patch[0].RR); + dump[7] = (e_uint8) ((patch[1].SL << 4) + patch[1].RR); + dump[8] = 0; + dump[9] = 0; + dump[10] = 0; + dump[11] = 0; + dump[12] = 0; + dump[13] = 0; + dump[14] = 0; + dump[15] = 0; +} + +/************************************************************ + + Calc Parameters + +************************************************************/ + +INLINE static e_uint32 +calc_eg_dphase (OPLL_SLOT * slot) +{ + + switch (slot->eg_mode) + { + case ATTACK: + return dphaseARTable[slot->patch->AR][slot->rks]; + + case DECAY: + return dphaseDRTable[slot->patch->DR][slot->rks]; + + case SUSHOLD: + return 0; + + case SUSTINE: + return dphaseDRTable[slot->patch->RR][slot->rks]; + + case RELEASE: + if (slot->sustine) + return dphaseDRTable[5][slot->rks]; + else if (slot->patch->EG) + return dphaseDRTable[slot->patch->RR][slot->rks]; + else + return dphaseDRTable[7][slot->rks]; + + case SETTLE: + return dphaseDRTable[15][0]; + + case FINISH: + return 0; + + default: + return 0; + } +} + +/************************************************************* + + OPLL internal interfaces + +*************************************************************/ +#define SLOT_BD1 12 +#define SLOT_BD2 13 +#define SLOT_HH 14 +#define SLOT_SD 15 +#define SLOT_TOM 16 +#define SLOT_CYM 17 + +/* We will set this dinamically, but not sure if this affects playback */ +#if defined(ROCKBOX) +INLINE static void +UPDATE_PG(OPLL_SLOT * slot) +{ + static const e_uint32 mltable[16] = + { 1, 1 * 2, 2 * 2, 3 * 2, 4 * 2, 5 * 2, 6 * 2, 7 * 2, 8 * 2, 9 * 2, 10 * 2, 10 * 2, 12 * 2, 12 * 2, 15 * 2, 15 * 2 }; + + slot->dphase = RATE_ADJUST (((slot->fnum * mltable[slot->patch->ML]) << slot->block) >> (20 - DP_BITS)); +} +#else +#define UPDATE_PG(S) (S)->dphase = dphaseTable[(S)->fnum][(S)->block][(S)->patch->ML] +#endif + +#define UPDATE_TLL(S)\ +(((S)->type==0)?\ +((S)->tll = tllTable[((S)->fnum)>>5][(S)->block][(S)->patch->TL][(S)->patch->KL]):\ +((S)->tll = tllTable[((S)->fnum)>>5][(S)->block][(S)->volume][(S)->patch->KL])) +#define UPDATE_RKS(S) (S)->rks = rksTable[((S)->fnum)>>8][(S)->block][(S)->patch->KR] +#define UPDATE_WF(S) (S)->sintbl = waveform[(S)->patch->WF] +#define UPDATE_EG(S) (S)->eg_dphase = calc_eg_dphase(S) +#define UPDATE_ALL(S)\ + UPDATE_PG(S);\ + UPDATE_TLL(S);\ + UPDATE_RKS(S);\ + UPDATE_WF(S); \ + UPDATE_EG(S) /* EG should be updated last. */ + + +/* Slot key on */ +INLINE static void +slotOn (OPLL_SLOT * slot) +{ + slot->eg_mode = ATTACK; + slot->eg_phase = 0; + slot->phase = 0; + UPDATE_EG(slot); +} + +/* Slot key on without reseting the phase */ +INLINE static void +slotOn2 (OPLL_SLOT * slot) +{ + slot->eg_mode = ATTACK; + slot->eg_phase = 0; + UPDATE_EG(slot); +} + +/* Slot key off */ +INLINE static void +slotOff (OPLL_SLOT * slot) +{ + if (slot->eg_mode == ATTACK) + slot->eg_phase = EXPAND_BITS (AR_ADJUST_TABLE(HIGHBITS (slot->eg_phase, EG_DP_BITS - EG_BITS)), EG_BITS, EG_DP_BITS); + slot->eg_mode = RELEASE; + UPDATE_EG(slot); +} + +/* Channel key on */ +INLINE static void +keyOn (OPLL * opll, e_int32 i) +{ + if (!opll->slot_on_flag[i * 2]) + slotOn (MOD(opll,i)); + if (!opll->slot_on_flag[i * 2 + 1]) + slotOn (CAR(opll,i)); + opll->key_status[i] = 1; +} + +/* Channel key off */ +INLINE static void +keyOff (OPLL * opll, e_int32 i) +{ + if (opll->slot_on_flag[i * 2 + 1]) + slotOff (CAR(opll,i)); + opll->key_status[i] = 0; +} + +INLINE static void +keyOn_BD (OPLL * opll) +{ + keyOn (opll, 6); +} +INLINE static void +keyOn_SD (OPLL * opll) +{ + if (!opll->slot_on_flag[SLOT_SD]) + slotOn (CAR(opll,7)); +} +INLINE static void +keyOn_TOM (OPLL * opll) +{ + if (!opll->slot_on_flag[SLOT_TOM]) + slotOn (MOD(opll,8)); +} +INLINE static void +keyOn_HH (OPLL * opll) +{ + if (!opll->slot_on_flag[SLOT_HH]) + slotOn2 (MOD(opll,7)); +} +INLINE static void +keyOn_CYM (OPLL * opll) +{ + if (!opll->slot_on_flag[SLOT_CYM]) + slotOn2 (CAR(opll,8)); +} + +/* Drum key off */ +INLINE static void +keyOff_BD (OPLL * opll) +{ + keyOff (opll, 6); +} +INLINE static void +keyOff_SD (OPLL * opll) +{ + if (opll->slot_on_flag[SLOT_SD]) + slotOff (CAR(opll,7)); +} +INLINE static void +keyOff_TOM (OPLL * opll) +{ + if (opll->slot_on_flag[SLOT_TOM]) + slotOff (MOD(opll,8)); +} +INLINE static void +keyOff_HH (OPLL * opll) +{ + if (opll->slot_on_flag[SLOT_HH]) + slotOff (MOD(opll,7)); +} +INLINE static void +keyOff_CYM (OPLL * opll) +{ + if (opll->slot_on_flag[SLOT_CYM]) + slotOff (CAR(opll,8)); +} + +/* Change a voice */ +INLINE static void +setPatch (OPLL * opll, e_int32 i, e_int32 num) +{ + opll->patch_number[i] = num; + MOD(opll,i)->patch = &opll->patch[num * 2 + 0]; + CAR(opll,i)->patch = &opll->patch[num * 2 + 1]; +} + +/* Change a rhythm voice */ +INLINE static void +setSlotPatch (OPLL_SLOT * slot, OPLL_PATCH * patch) +{ + slot->patch = patch; +} + +/* Set sustine parameter */ +INLINE static void +setSustine (OPLL * opll, e_int32 c, e_int32 sustine) +{ + CAR(opll,c)->sustine = sustine; + if (MOD(opll,c)->type) + MOD(opll,c)->sustine = sustine; +} + +/* Volume : 6bit ( Volume register << 2 ) */ +INLINE static void +setVolume (OPLL * opll, e_int32 c, e_int32 volume) +{ + CAR(opll,c)->volume = volume; +} + +INLINE static void +setSlotVolume (OPLL_SLOT * slot, e_int32 volume) +{ + slot->volume = volume; +} + +/* Set F-Number ( fnum : 9bit ) */ +INLINE static void +setFnumber (OPLL * opll, e_int32 c, e_int32 fnum) +{ + CAR(opll,c)->fnum = fnum; + MOD(opll,c)->fnum = fnum; +} + +/* Set Block data (block : 3bit ) */ +INLINE static void +setBlock (OPLL * opll, e_int32 c, e_int32 block) +{ + CAR(opll,c)->block = block; + MOD(opll,c)->block = block; +} + +/* Change Rhythm Mode */ +INLINE static void +update_rhythm_mode (OPLL * opll) +{ + if (opll->patch_number[6] & 0x10) + { + if (!(opll->slot_on_flag[SLOT_BD2] | (opll->reg[0x0e] & 32))) + { + opll->slot[SLOT_BD1].eg_mode = FINISH; + opll->slot[SLOT_BD2].eg_mode = FINISH; + setPatch (opll, 6, opll->reg[0x36] >> 4); + } + } + else if (opll->reg[0x0e] & 32) + { + opll->patch_number[6] = 16; + opll->slot[SLOT_BD1].eg_mode = FINISH; + opll->slot[SLOT_BD2].eg_mode = FINISH; + setSlotPatch (&opll->slot[SLOT_BD1], &opll->patch[16 * 2 + 0]); + setSlotPatch (&opll->slot[SLOT_BD2], &opll->patch[16 * 2 + 1]); + } + + if (opll->patch_number[7] & 0x10) + { + if (!((opll->slot_on_flag[SLOT_HH] && opll->slot_on_flag[SLOT_SD]) | (opll->reg[0x0e] & 32))) + { + opll->slot[SLOT_HH].type = 0; + opll->slot[SLOT_HH].eg_mode = FINISH; + opll->slot[SLOT_SD].eg_mode = FINISH; + setPatch (opll, 7, opll->reg[0x37] >> 4); + } + } + else if (opll->reg[0x0e] & 32) + { + opll->patch_number[7] = 17; + opll->slot[SLOT_HH].type = 1; + opll->slot[SLOT_HH].eg_mode = FINISH; + opll->slot[SLOT_SD].eg_mode = FINISH; + setSlotPatch (&opll->slot[SLOT_HH], &opll->patch[17 * 2 + 0]); + setSlotPatch (&opll->slot[SLOT_SD], &opll->patch[17 * 2 + 1]); + } + + if (opll->patch_number[8] & 0x10) + { + if (!((opll->slot_on_flag[SLOT_CYM] && opll->slot_on_flag[SLOT_TOM]) | (opll->reg[0x0e] & 32))) + { + opll->slot[SLOT_TOM].type = 0; + opll->slot[SLOT_TOM].eg_mode = FINISH; + opll->slot[SLOT_CYM].eg_mode = FINISH; + setPatch (opll, 8, opll->reg[0x38] >> 4); + } + } + else if (opll->reg[0x0e] & 32) + { + opll->patch_number[8] = 18; + opll->slot[SLOT_TOM].type = 1; + opll->slot[SLOT_TOM].eg_mode = FINISH; + opll->slot[SLOT_CYM].eg_mode = FINISH; + setSlotPatch (&opll->slot[SLOT_TOM], &opll->patch[18 * 2 + 0]); + setSlotPatch (&opll->slot[SLOT_CYM], &opll->patch[18 * 2 + 1]); + } +} + +INLINE static void +update_key_status (OPLL * opll) +{ + int ch; + + for (ch = 0; ch < 9; ch++) + opll->slot_on_flag[ch * 2] = opll->slot_on_flag[ch * 2 + 1] = (opll->reg[0x20 + ch]) & 0x10; + + if (opll->reg[0x0e] & 32) + { + opll->slot_on_flag[SLOT_BD1] |= (opll->reg[0x0e] & 0x10); + opll->slot_on_flag[SLOT_BD2] |= (opll->reg[0x0e] & 0x10); + opll->slot_on_flag[SLOT_SD] |= (opll->reg[0x0e] & 0x08); + opll->slot_on_flag[SLOT_HH] |= (opll->reg[0x0e] & 0x01); + opll->slot_on_flag[SLOT_TOM] |= (opll->reg[0x0e] & 0x04); + opll->slot_on_flag[SLOT_CYM] |= (opll->reg[0x0e] & 0x02); + } +} + +void +OPLL_copyPatch (OPLL * opll, e_int32 num, OPLL_PATCH * patch) +{ + memcpy (&opll->patch[num], patch, sizeof (OPLL_PATCH)); +} + +/*********************************************************** + + Initializing + +***********************************************************/ + +static void +OPLL_SLOT_reset (OPLL_SLOT * slot, int type) +{ + slot->type = type; + slot->sintbl = waveform[0]; + slot->phase = 0; + slot->dphase = 0; + slot->output[0] = 0; + slot->output[1] = 0; + slot->feedback = 0; + slot->eg_mode = FINISH; + slot->eg_phase = EG_DP_WIDTH; + slot->eg_dphase = 0; + slot->rks = 0; + slot->tll = 0; + slot->sustine = 0; + slot->fnum = 0; + slot->block = 0; + slot->volume = 0; + slot->pgout = 0; + slot->egout = 0; + slot->patch = &null_patch; +} + +static void +internal_refresh (void) +{ +#if !defined(ROCKBOX) + makeDphaseTable (); +#endif + makeDphaseARTable (); + makeDphaseDRTable (); + pm_dphase = (e_uint32) RATE_ADJUST ((int)(PM_SPEED * PM_DP_WIDTH) / (clk / 72)); + am_dphase = (e_uint32) RATE_ADJUST ((int)(AM_SPEED * AM_DP_WIDTH) / (clk / 72)); +} + +static void +maketables (e_uint32 c, e_uint32 r) +{ + if (c != clk) + { + clk = c; +#ifdef EMU2413_CALCUL_TABLES + makePmTable (); + makeAmTable (); + makeAdjustTable (); +#endif + makeDB2LinTable (); + makeTllTable (); + makeRksTable (); + makeSinTable (); + makeDefaultPatch (); + } + + if (r != rate) + { + rate = r; + internal_refresh (); + } +} + +void +OPLL_new (OPLL *opll, e_uint32 clk, e_uint32 rate) +{ + e_int32 i; + + maketables (clk, rate); + + memset(opll, 0, sizeof (OPLL)); + for (i = 0; i < 19 * 2; i++) + memcpy(&opll->patch[i],&null_patch,sizeof(OPLL_PATCH)); + + opll->mask = 0; + + OPLL_reset (opll); + OPLL_reset_patch (opll, 0); +} + + +void +OPLL_delete (OPLL * opll) +{ + (void) opll; +} + + +/* Reset patch datas by system default. */ +void +OPLL_reset_patch (OPLL * opll, e_int32 type) +{ + e_int32 i; + + for (i = 0; i < 19 * 2; i++) + OPLL_copyPatch (opll, i, &default_patch[type % OPLL_TONE_NUM][i]); +} + +/* Reset whole of OPLL except patch datas. */ +void +OPLL_reset (OPLL * opll) +{ + e_int32 i; + + if (!opll) + return; + + opll->adr = 0; + opll->out = 0; + + opll->pm_phase = 0; + opll->am_phase = 0; + + opll->noise_seed = 0xffff; + opll->mask = 0; + + for (i = 0; i <18; i++) + OPLL_SLOT_reset(&opll->slot[i], i%2); + + for (i = 0; i < 9; i++) + { + opll->key_status[i] = 0; + setPatch (opll, i, 0); + } + + for (i = 0; i < 0x40; i++) + OPLL_writeReg (opll, i, 0); + +#ifndef EMU2413_COMPACTION + opll->realstep = (e_uint32) ((1 << 31) / rate); + opll->opllstep = (e_uint32) ((1 << 31) / (clk / 72)); + opll->oplltime = 0; + for (i = 0; i < 14; i++) + opll->pan[i] = 2; + opll->sprev[0] = opll->sprev[1] = 0; + opll->snext[0] = opll->snext[1] = 0; +#endif +} + +/* Force Refresh (When external program changes some parameters). */ +void +OPLL_forceRefresh (OPLL * opll) +{ + e_int32 i; + + if (opll == NULL) + return; + + for (i = 0; i < 9; i++) + setPatch(opll,i,opll->patch_number[i]); + + for (i = 0; i < 18; i++) + { + UPDATE_PG (&opll->slot[i]); + UPDATE_RKS (&opll->slot[i]); + UPDATE_TLL (&opll->slot[i]); + UPDATE_WF (&opll->slot[i]); + UPDATE_EG (&opll->slot[i]); + } +} + +void +OPLL_set_rate (OPLL * opll, e_uint32 r) +{ + if (rate == r) return; + if (opll->quality) + rate = 49716; + else + rate = r; + internal_refresh (); + rate = r; +} + +void +OPLL_set_quality (OPLL * opll, e_uint32 q) +{ + opll->quality = q; + OPLL_set_rate (opll, rate); +} + +/********************************************************* + + Generate wave data + +*********************************************************/ +/* Convert Amp(0 to EG_HEIGHT) to Phase(0 to 2PI). */ +#if ( SLOT_AMP_BITS - PG_BITS ) > 0 +#define wave2_2pi(e) ( (e) >> ( SLOT_AMP_BITS - PG_BITS )) +#else +#define wave2_2pi(e) ( (e) << ( PG_BITS - SLOT_AMP_BITS )) +#endif + +/* Convert Amp(0 to EG_HEIGHT) to Phase(0 to 4PI). */ +#if ( SLOT_AMP_BITS - PG_BITS - 1 ) == 0 +#define wave2_4pi(e) (e) +#elif ( SLOT_AMP_BITS - PG_BITS - 1 ) > 0 +#define wave2_4pi(e) ( (e) >> ( SLOT_AMP_BITS - PG_BITS - 1 )) +#else +#define wave2_4pi(e) ( (e) << ( 1 + PG_BITS - SLOT_AMP_BITS )) +#endif + +/* Convert Amp(0 to EG_HEIGHT) to Phase(0 to 8PI). */ +#if ( SLOT_AMP_BITS - PG_BITS - 2 ) == 0 +#define wave2_8pi(e) (e) +#elif ( SLOT_AMP_BITS - PG_BITS - 2 ) > 0 +#define wave2_8pi(e) ( (e) >> ( SLOT_AMP_BITS - PG_BITS - 2 )) +#else +#define wave2_8pi(e) ( (e) << ( 2 + PG_BITS - SLOT_AMP_BITS )) +#endif + +/* Update AM, PM unit */ +INLINE static void +update_ampm (OPLL * opll) +{ + opll->pm_phase = (opll->pm_phase + pm_dphase) & (PM_DP_WIDTH - 1); + opll->am_phase = (opll->am_phase + am_dphase) & (AM_DP_WIDTH - 1); + opll->lfo_am = AMTABLE(HIGHBITS (opll->am_phase, AM_DP_BITS - AM_PG_BITS)); + opll->lfo_pm = PMTABLE(HIGHBITS (opll->pm_phase, PM_DP_BITS - PM_PG_BITS)); +} + +/* PG */ +INLINE static void +calc_phase (OPLL_SLOT * slot, e_int32 lfo) +{ + if (slot->patch->PM) + slot->phase += (slot->dphase * lfo) >> PM_AMP_BITS; + else + slot->phase += slot->dphase; + + slot->phase &= (DP_WIDTH - 1); + + slot->pgout = HIGHBITS (slot->phase, DP_BASE_BITS); +} + +/* Update Noise unit */ +INLINE static void +update_noise (OPLL * opll) +{ + if(opll->noise_seed&1) opll->noise_seed ^= 0x8003020; + opll->noise_seed >>= 1; +} + +/* EG */ +INLINE static void +calc_envelope (OPLL_SLOT * slot, e_int32 lfo) +{ +#define S2E(x) (SL2EG((e_int32)(x/SL_STEP))<<(EG_DP_BITS-EG_BITS)) + + static e_uint32 SL[16] = { + S2E (0.0), S2E (3.0), S2E (6.0), S2E (9.0), S2E (12.0), S2E (15.0), S2E (18.0), S2E (21.0), + S2E (24.0), S2E (27.0), S2E (30.0), S2E (33.0), S2E (36.0), S2E (39.0), S2E (42.0), S2E (48.0) + }; + + e_uint32 egout; + + switch (slot->eg_mode) + { + case ATTACK: + egout = AR_ADJUST_TABLE(HIGHBITS (slot->eg_phase, EG_DP_BITS - EG_BITS)); + slot->eg_phase += slot->eg_dphase; + if((EG_DP_WIDTH & slot->eg_phase)||(slot->patch->AR==15)) + { + egout = 0; + slot->eg_phase = 0; + slot->eg_mode = DECAY; + UPDATE_EG (slot); + } + break; + + case DECAY: + egout = HIGHBITS (slot->eg_phase, EG_DP_BITS - EG_BITS); + slot->eg_phase += slot->eg_dphase; + if (slot->eg_phase >= SL[slot->patch->SL]) + { + if (slot->patch->EG) + { + slot->eg_phase = SL[slot->patch->SL]; + slot->eg_mode = SUSHOLD; + UPDATE_EG (slot); + } + else + { + slot->eg_phase = SL[slot->patch->SL]; + slot->eg_mode = SUSTINE; + UPDATE_EG (slot); + } + } + break; + + case SUSHOLD: + egout = HIGHBITS (slot->eg_phase, EG_DP_BITS - EG_BITS); + if (slot->patch->EG == 0) + { + slot->eg_mode = SUSTINE; + UPDATE_EG (slot); + } + break; + + case SUSTINE: + case RELEASE: + egout = HIGHBITS (slot->eg_phase, EG_DP_BITS - EG_BITS); + slot->eg_phase += slot->eg_dphase; + if (egout >= (1 << EG_BITS)) + { + slot->eg_mode = FINISH; + egout = (1 << EG_BITS) - 1; + } + break; + + case SETTLE: + egout = HIGHBITS (slot->eg_phase, EG_DP_BITS - EG_BITS); + slot->eg_phase += slot->eg_dphase; + if (egout >= (1 << EG_BITS)) + { + slot->eg_mode = ATTACK; + egout = (1 << EG_BITS) - 1; + UPDATE_EG(slot); + } + break; + + case FINISH: + egout = (1 << EG_BITS) - 1; + break; + + default: + egout = (1 << EG_BITS) - 1; + break; + } + + if (slot->patch->AM) + egout = EG2DB (egout + slot->tll) + lfo; + else + egout = EG2DB (egout + slot->tll); + + if (egout >= DB_MUTE) + egout = DB_MUTE - 1; + + slot->egout = egout | 3; +} + +/* CARRIOR */ +INLINE static e_int32 +calc_slot_car (OPLL_SLOT * slot, e_int32 fm) +{ + if (slot->egout >= (DB_MUTE - 1)) + { + slot->output[0] = 0; + } + else + { + slot->output[0] = DB2LIN_TABLE[slot->sintbl[(slot->pgout+wave2_8pi(fm))&(PG_WIDTH-1)] + slot->egout]; + } + + slot->output[1] = (slot->output[1] + slot->output[0]) >> 1; + return slot->output[1]; +} + +/* MODULATOR */ +INLINE static e_int32 +calc_slot_mod (OPLL_SLOT * slot) +{ + e_int32 fm; + + slot->output[1] = slot->output[0]; + + if (slot->egout >= (DB_MUTE - 1)) + { + slot->output[0] = 0; + } + else if (slot->patch->FB != 0) + { + fm = wave2_4pi (slot->feedback) >> (7 - slot->patch->FB); + slot->output[0] = DB2LIN_TABLE[slot->sintbl[(slot->pgout+fm)&(PG_WIDTH-1)] + slot->egout]; + } + else + { + slot->output[0] = DB2LIN_TABLE[slot->sintbl[slot->pgout] + slot->egout]; + } + + slot->feedback = (slot->output[1] + slot->output[0]) >> 1; + + return slot->feedback; + +} + +/* TOM */ +INLINE static e_int32 +calc_slot_tom (OPLL_SLOT * slot) +{ + if (slot->egout >= (DB_MUTE - 1)) + return 0; + + return DB2LIN_TABLE[slot->sintbl[slot->pgout] + slot->egout]; + +} + +/* SNARE */ +INLINE static e_int32 +calc_slot_snare (OPLL_SLOT * slot, e_uint32 noise) +{ + if(slot->egout>=(DB_MUTE-1)) + return 0; + + if(BIT(slot->pgout,7)) + return DB2LIN_TABLE[(noise?DB_POS(0):DB_POS(15))+slot->egout]; + else + return DB2LIN_TABLE[(noise?DB_NEG(0):DB_NEG(15))+slot->egout]; +} + +/* + TOP-CYM + */ +INLINE static e_int32 +calc_slot_cym (OPLL_SLOT * slot, e_uint32 pgout_hh) +{ + e_uint32 dbout; + + if (slot->egout >= (DB_MUTE - 1)) + return 0; + else if( + /* the same as fmopl.c */ + ((BIT(pgout_hh,PG_BITS-8)^BIT(pgout_hh,PG_BITS-1))|BIT(pgout_hh,PG_BITS-7)) ^ + /* different from fmopl.c */ + (BIT(slot->pgout,PG_BITS-7)&!BIT(slot->pgout,PG_BITS-5)) + ) + dbout = DB_NEG(3); + else + dbout = DB_POS(3); + + return DB2LIN_TABLE[dbout + slot->egout]; +} + +/* + HI-HAT +*/ +INLINE static e_int32 +calc_slot_hat (OPLL_SLOT *slot, e_int32 pgout_cym, e_uint32 noise) +{ + e_uint32 dbout; + + if (slot->egout >= (DB_MUTE - 1)) + return 0; + else if( + /* the same as fmopl.c */ + ((BIT(slot->pgout,PG_BITS-8)^BIT(slot->pgout,PG_BITS-1))|BIT(slot->pgout,PG_BITS-7)) ^ + /* different from fmopl.c */ + (BIT(pgout_cym,PG_BITS-7)&!BIT(pgout_cym,PG_BITS-5)) + ) + { + if(noise) + dbout = DB_NEG(12); + else + dbout = DB_NEG(24); + } + else + { + if(noise) + dbout = DB_POS(12); + else + dbout = DB_POS(24); + } + + return DB2LIN_TABLE[dbout + slot->egout]; +} + +static e_int16 +calc (OPLL * opll) EMU2413_CALC_ICODE; +static e_int16 +calc (OPLL * opll) +{ + e_int32 i; + + update_ampm (opll); + update_noise (opll); + + for (i = 0; i < 18; i++) + { + calc_phase(&opll->slot[i],opll->lfo_pm); + calc_envelope(&opll->slot[i],opll->lfo_am); + } + + e_uint32 channel_mask = opll->mask; + for (i = 0; i < 9; i++) { + if (CAR(opll,i)->eg_mode != FINISH) + channel_mask |= (1 << i); + } + + e_int32 mix = 0; + + /* CH6 */ + if (opll->patch_number[6] & 0x10) { + if (channel_mask & OPLL_MASK_CH (6)) { + mix += calc_slot_car (CAR(opll,6), calc_slot_mod(MOD(opll,6))); + channel_mask &= ~(1 << 6); + } + } + + /* CH7 */ + if (opll->patch_number[7] & 0x10) { + if (MOD(opll,7)->eg_mode != FINISH) + mix += calc_slot_hat (MOD(opll,7), CAR(opll,8)->pgout, opll->noise_seed&1); + if (channel_mask & OPLL_MASK_SD) { + mix -= calc_slot_snare (CAR(opll,7), opll->noise_seed&1); + channel_mask &= ~OPLL_MASK_SD; + } + } + + /* CH8 */ + if (opll->patch_number[8] & 0x10) { + if (MOD(opll,8)->eg_mode != FINISH) + mix += calc_slot_tom (MOD(opll,8)); + if (channel_mask & OPLL_MASK_CYM) { + mix -= calc_slot_cym (CAR(opll,8), MOD(opll,7)->pgout); + channel_mask &= ~OPLL_MASK_CYM; + } + } + + mix <<= 1; + + opll->current_mask = channel_mask; + for (i = 0; channel_mask; channel_mask >>= 1, ++i) { + if (channel_mask & 1) { + mix += calc_slot_car (CAR(opll,i), calc_slot_mod(MOD(opll,i))); + } + } + + return (e_int16) mix << 3; +} + +void +OPLL_set_internal_mute(OPLL * opll, e_uint32 mute) +{ + opll->internal_mute = mute; +} + +e_uint32 +OPLL_is_internal_muted(OPLL * opll) +{ + return opll->internal_mute; +} + +static e_uint32 +check_mute_helper(OPLL * opll) +{ + for (int i = 0; i < 6; i++) { + /* if (ch[i].car.eg_mode != FINISH) return 0; */ + if (!(opll->current_mask & OPLL_MASK_CH (i)) && (CAR(opll,i)->eg_mode != FINISH)) return 0; + } + + if (!(opll->reg[0x0e] & 0x20)) { + for(int i = 6; i < 9; i++) { + /* if (ch[i].car.eg_mode != FINISH) return 0; */ + if (!(opll->current_mask & OPLL_MASK_CH (i)) && (CAR(opll,i)->eg_mode != FINISH)) return 0; + } + } else { + /* if (ch[6].car.eg_mode != FINISH) return false; + if (ch[7].mod.eg_mode != FINISH) return false; + if (ch[7].car.eg_mode != FINISH) return false; + if (ch[8].mod.eg_mode != FINISH) return false; + if (ch[8].car.eg_mode != FINISH) return false; */ + if (!(opll->current_mask & OPLL_MASK_CH (6)) && (CAR(opll,6)->eg_mode != FINISH)) return 0; + if (!(opll->current_mask & OPLL_MASK_CH (7)) && (MOD(opll,7)->eg_mode != FINISH)) return 0; + if (!(opll->current_mask & OPLL_MASK_CH (7)) && (CAR(opll,7)->eg_mode != FINISH)) return 0; + if (!(opll->current_mask & OPLL_MASK_CH (8)) && (MOD(opll,8)->eg_mode != FINISH)) return 0; + if (!(opll->current_mask & OPLL_MASK_CH (8)) && (CAR(opll,8)->eg_mode != FINISH)) return 0; + } + + return 1; /* nothing is playing, then mute */ +} + +static void +check_mute(OPLL * opll) +{ + OPLL_set_internal_mute (opll, check_mute_helper (opll)); +} + +EMU2413_API e_int16 *OPLL_update_buffer(OPLL * opll, e_uint32 length) +{ + e_int16* buf = opll->buffer; + while (length--) { + *(buf++) = calc (opll); + } + check_mute (opll); + + return opll->buffer; +} + +#ifdef EMU2413_COMPACTION +e_int16 +OPLL_calc (OPLL * opll) +{ + return calc (opll); +} +#else +e_int16 +OPLL_calc (OPLL * opll) +{ + if (!opll->quality) + return calc (opll); + + while (opll->realstep > opll->oplltime) + { + opll->oplltime += opll->opllstep; + opll->prev = opll->next; + opll->next = calc (opll); + } + + opll->oplltime -= opll->realstep; + opll->out = (e_int16) (((double) opll->next * (opll->opllstep - opll->oplltime) + + (double) opll->prev * opll->oplltime) / opll->opllstep); + + return (e_int16) opll->out; +} +#endif + +e_uint32 +OPLL_setMask (OPLL * opll, e_uint32 mask) +{ + e_uint32 ret; + + if (opll) + { + ret = opll->mask; + opll->mask = mask; + return ret; + } + else + return 0; +} + +e_uint32 +OPLL_toggleMask (OPLL * opll, e_uint32 mask) +{ + e_uint32 ret; + + if (opll) + { + ret = opll->mask; + opll->mask ^= mask; + return ret; + } + else + return 0; +} + +/**************************************************** + + I/O Ctrl + +*****************************************************/ + +void +OPLL_writeReg (OPLL * opll, e_uint32 reg, e_uint32 data) +{ + e_int32 i, v, ch; + + data = data & 0xff; + reg = reg & 0x3f; + opll->reg[reg] = (e_uint8) data; + + switch (reg) + { + case 0x00: + opll->patch[0].AM = (data >> 7) & 1; + opll->patch[0].PM = (data >> 6) & 1; + opll->patch[0].EG = (data >> 5) & 1; + opll->patch[0].KR = (data >> 4) & 1; + opll->patch[0].ML = (data) & 15; + for (i = 0; i < 9; i++) + { + if (opll->patch_number[i] == 0) + { + UPDATE_PG (MOD(opll,i)); + UPDATE_RKS (MOD(opll,i)); + UPDATE_EG (MOD(opll,i)); + } + } + break; + + case 0x01: + opll->patch[1].AM = (data >> 7) & 1; + opll->patch[1].PM = (data >> 6) & 1; + opll->patch[1].EG = (data >> 5) & 1; + opll->patch[1].KR = (data >> 4) & 1; + opll->patch[1].ML = (data) & 15; + for (i = 0; i < 9; i++) + { + if (opll->patch_number[i] == 0) + { + UPDATE_PG (CAR(opll,i)); + UPDATE_RKS (CAR(opll,i)); + UPDATE_EG (CAR(opll,i)); + } + } + break; + + case 0x02: + opll->patch[0].KL = (data >> 6) & 3; + opll->patch[0].TL = (data) & 63; + for (i = 0; i < 9; i++) + { + if (opll->patch_number[i] == 0) + { + UPDATE_TLL(MOD(opll,i)); + } + } + break; + + case 0x03: + opll->patch[1].KL = (data >> 6) & 3; + opll->patch[1].WF = (data >> 4) & 1; + opll->patch[0].WF = (data >> 3) & 1; + opll->patch[0].FB = (data) & 7; + for (i = 0; i < 9; i++) + { + if (opll->patch_number[i] == 0) + { + UPDATE_WF(MOD(opll,i)); + UPDATE_WF(CAR(opll,i)); + } + } + break; + + case 0x04: + opll->patch[0].AR = (data >> 4) & 15; + opll->patch[0].DR = (data) & 15; + for (i = 0; i < 9; i++) + { + if (opll->patch_number[i] == 0) + { + UPDATE_EG (MOD(opll,i)); + } + } + break; + + case 0x05: + opll->patch[1].AR = (data >> 4) & 15; + opll->patch[1].DR = (data) & 15; + for (i = 0; i < 9; i++) + { + if (opll->patch_number[i] == 0) + { + UPDATE_EG(CAR(opll,i)); + } + } + break; + + case 0x06: + opll->patch[0].SL = (data >> 4) & 15; + opll->patch[0].RR = (data) & 15; + for (i = 0; i < 9; i++) + { + if (opll->patch_number[i] == 0) + { + UPDATE_EG (MOD(opll,i)); + } + } + break; + + case 0x07: + opll->patch[1].SL = (data >> 4) & 15; + opll->patch[1].RR = (data) & 15; + for (i = 0; i < 9; i++) + { + if (opll->patch_number[i] == 0) + { + UPDATE_EG (CAR(opll,i)); + } + } + break; + + case 0x0e: + update_rhythm_mode (opll); + if (data & 32) + { + if (data & 0x10) + keyOn_BD (opll); + else + keyOff_BD (opll); + if (data & 0x8) + keyOn_SD (opll); + else + keyOff_SD (opll); + if (data & 0x4) + keyOn_TOM (opll); + else + keyOff_TOM (opll); + if (data & 0x2) + keyOn_CYM (opll); + else + keyOff_CYM (opll); + if (data & 0x1) + keyOn_HH (opll); + else + keyOff_HH (opll); + } + update_key_status (opll); + + UPDATE_ALL (MOD(opll,6)); + UPDATE_ALL (CAR(opll,6)); + UPDATE_ALL (MOD(opll,7)); + UPDATE_ALL (CAR(opll,7)); + UPDATE_ALL (MOD(opll,8)); + UPDATE_ALL (CAR(opll,8)); + + break; + + case 0x0f: + break; + + case 0x10: + case 0x11: + case 0x12: + case 0x13: + case 0x14: + case 0x15: + case 0x16: + case 0x17: + case 0x18: + ch = reg - 0x10; + setFnumber (opll, ch, data + ((opll->reg[0x20 + ch] & 1) << 8)); + UPDATE_ALL (MOD(opll,ch)); + UPDATE_ALL (CAR(opll,ch)); + break; + + case 0x20: + case 0x21: + case 0x22: + case 0x23: + case 0x24: + case 0x25: + case 0x26: + case 0x27: + case 0x28: + ch = reg - 0x20; + setFnumber (opll, ch, ((data & 1) << 8) + opll->reg[0x10 + ch]); + setBlock (opll, ch, (data >> 1) & 7); + setSustine (opll, ch, (data >> 5) & 1); + if (data & 0x10) + keyOn (opll, ch); + else + keyOff (opll, ch); + UPDATE_ALL (MOD(opll,ch)); + UPDATE_ALL (CAR(opll,ch)); + update_key_status (opll); + update_rhythm_mode (opll); + break; + + case 0x30: + case 0x31: + case 0x32: + case 0x33: + case 0x34: + case 0x35: + case 0x36: + case 0x37: + case 0x38: + i = (data >> 4) & 15; + v = data & 15; + if ((opll->reg[0x0e] & 32) && (reg >= 0x36)) + { + switch (reg) + { + case 0x37: + setSlotVolume (MOD(opll,7), i << 2); + break; + case 0x38: + setSlotVolume (MOD(opll,8), i << 2); + break; + default: + break; + } + } + else + { + setPatch (opll, reg - 0x30, i); + } + setVolume (opll, reg - 0x30, v << 2); + UPDATE_ALL (MOD(opll,reg - 0x30)); + UPDATE_ALL (CAR(opll,reg - 0x30)); + break; + + default: + break; + + } +} + +void +OPLL_writeIO (OPLL * opll, e_uint32 adr, e_uint32 val) +{ + if (adr & 1) + OPLL_writeReg (opll, opll->adr, val); + else + opll->adr = val; +} + +e_uint32 +OPLL_read(OPLL * opll, e_uint32 a) +{ + if( !(a&1) ) + { + /* status port */ + return opll->status; + } + return 0xff; +} + +#ifndef EMU2413_COMPACTION +/* STEREO MODE (OPT) */ +void +OPLL_set_pan (OPLL * opll, e_uint32 ch, e_uint32 pan) +{ + opll->pan[ch & 15] = pan & 3; +} + +static void +calc_stereo (OPLL * opll, e_int32 out[2]) +{ + e_int32 b[4] = { 0, 0, 0, 0 }; /* Ignore, Right, Left, Center */ + e_int32 r[4] = { 0, 0, 0, 0 }; /* Ignore, Right, Left, Center */ + e_int32 i; + + update_ampm (opll); + update_noise (opll); + + for(i=0;i<18;i++) + { + calc_phase(&opll->slot[i],opll->lfo_pm); + calc_envelope(&opll->slot[i],opll->lfo_am); + } + + for (i = 0; i < 6; i++) + if (!(opll->mask & OPLL_MASK_CH (i)) && (CAR(opll,i)->eg_mode != FINISH)) + b[opll->pan[i]] += calc_slot_car (CAR(opll,i), calc_slot_mod (MOD(opll,i))); + + + if (opll->patch_number[6] <= 15) + { + if (!(opll->mask & OPLL_MASK_CH (6)) && (CAR(opll,6)->eg_mode != FINISH)) + b[opll->pan[6]] += calc_slot_car (CAR(opll,6), calc_slot_mod (MOD(opll,6))); + } + else + { + if (!(opll->mask & OPLL_MASK_BD) && (CAR(opll,6)->eg_mode != FINISH)) + r[opll->pan[9]] += calc_slot_car (CAR(opll,6), calc_slot_mod (MOD(opll,6))); + } + + if (opll->patch_number[7] <= 15) + { + if (!(opll->mask & OPLL_MASK_CH (7)) && (CAR (opll,7)->eg_mode != FINISH)) + b[opll->pan[7]] += calc_slot_car (CAR (opll,7), calc_slot_mod (MOD (opll,7))); + } + else + { + if (!(opll->mask & OPLL_MASK_HH) && (MOD (opll,7)->eg_mode != FINISH)) + r[opll->pan[10]] += calc_slot_hat (MOD (opll,7), CAR(opll,8)->pgout, opll->noise_seed&1); + if (!(opll->mask & OPLL_MASK_SD) && (CAR (opll,7)->eg_mode != FINISH)) + r[opll->pan[11]] -= calc_slot_snare (CAR (opll,7), opll->noise_seed&1); + } + + if (opll->patch_number[8] <= 15) + { + if (!(opll->mask & OPLL_MASK_CH (8)) && (CAR (opll,8)->eg_mode != FINISH)) + b[opll->pan[8]] += calc_slot_car (CAR (opll,8), calc_slot_mod (MOD (opll,8))); + } + else + { + if (!(opll->mask & OPLL_MASK_TOM) && (MOD (opll,8)->eg_mode != FINISH)) + r[opll->pan[12]] += calc_slot_tom (MOD (opll,8)); + if (!(opll->mask & OPLL_MASK_CYM) && (CAR (opll,8)->eg_mode != FINISH)) + r[opll->pan[13]] -= calc_slot_cym (CAR (opll,8), MOD(opll,7)->pgout); + } + + out[1] = (b[1] + b[3] + ((r[1] + r[3]) << 1)) <<3; + out[0] = (b[2] + b[3] + ((r[2] + r[3]) << 1)) <<3; +} + +void +OPLL_calc_stereo (OPLL * opll, e_int32 out[2]) +{ + if (!opll->quality) + { + calc_stereo (opll, out); + return; + } + + while (opll->realstep > opll->oplltime) + { + opll->oplltime += opll->opllstep; + opll->sprev[0] = opll->snext[0]; + opll->sprev[1] = opll->snext[1]; + calc_stereo (opll, opll->snext); + } + + opll->oplltime -= opll->realstep; + out[0] = (e_int16) (((double) opll->snext[0] * (opll->opllstep - opll->oplltime) + + (double) opll->sprev[0] * opll->oplltime) / opll->opllstep); + out[1] = (e_int16) (((double) opll->snext[1] * (opll->opllstep - opll->oplltime) + + (double) opll->sprev[1] * opll->oplltime) / opll->opllstep); +} +#endif /* EMU2413_COMPACTION */ diff --git a/lib/rbcodec/codecs/libgme/emu2413.h b/lib/rbcodec/codecs/libgme/emu2413.h new file mode 100644 index 0000000000..254f042957 --- /dev/null +++ b/lib/rbcodec/codecs/libgme/emu2413.h @@ -0,0 +1,164 @@ +#ifndef _EMU2413_H_ +#define _EMU2413_H_ + +#include "blargg_common.h" +#include "emutypes.h" + +#ifdef EMU2413_DLL_EXPORTS + #define EMU2413_API __declspec(dllexport) +#elif defined(EMU2413_DLL_IMPORTS) + #define EMU2413_API __declspec(dllimport) +#else + #define EMU2413_API +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#define AUDIO_MONO_BUFFER_SIZE 1024 + +#define PI 3.14159265358979323846 + +enum OPLL_TONE_ENUM {OPLL_2413_TONE=0, OPLL_VRC7_TONE=1, OPLL_281B_TONE=2} ; + +/* voice data */ +typedef struct __OPLL_PATCH { + e_uint32 TL,FB,EG,ML,AR,DR,SL,RR,KR,KL,AM,PM,WF ; +} OPLL_PATCH ; + +/* slot */ +typedef struct __OPLL_SLOT { + + OPLL_PATCH *patch; + + e_int32 type ; /* 0 : modulator 1 : carrier */ + + /* OUTPUT */ + e_int32 feedback ; + e_int32 output[2] ; /* Output value of slot */ + + /* for Phase Generator (PG) */ + e_uint16 *sintbl ; /* Wavetable */ + e_uint32 phase ; /* Phase */ + e_uint32 dphase ; /* Phase increment amount */ + e_uint32 pgout ; /* output */ + + /* for Envelope Generator (EG) */ + e_int32 fnum ; /* F-Number */ + e_int32 block ; /* Block */ + e_int32 volume ; /* Current volume */ + e_int32 sustine ; /* Sustine 1 = ON, 0 = OFF */ + e_uint32 tll ; /* Total Level + Key scale level*/ + e_uint32 rks ; /* Key scale offset (Rks) */ + e_int32 eg_mode ; /* Current state */ + e_uint32 eg_phase ; /* Phase */ + e_uint32 eg_dphase ; /* Phase increment amount */ + e_uint32 egout ; /* output */ + +} OPLL_SLOT ; + +/* Mask */ +#define OPLL_MASK_CH(x) (1<<(x)) +#define OPLL_MASK_HH (1<<(9)) +#define OPLL_MASK_CYM (1<<(10)) +#define OPLL_MASK_TOM (1<<(11)) +#define OPLL_MASK_SD (1<<(12)) +#define OPLL_MASK_BD (1<<(13)) +#define OPLL_MASK_RHYTHM ( OPLL_MASK_HH | OPLL_MASK_CYM | OPLL_MASK_TOM | OPLL_MASK_SD | OPLL_MASK_BD ) + +/* opll */ +typedef struct __OPLL { + + e_uint32 adr ; + e_int32 out ; + +#ifndef EMU2413_COMPACTION + e_uint32 realstep ; + e_uint32 oplltime ; + e_uint32 opllstep ; + e_int32 prev, next ; + e_int32 sprev[2],snext[2]; + e_uint32 pan[16]; +#endif + + /* Register */ + e_uint8 reg[0x40] ; + e_int32 slot_on_flag[18] ; + + /* Pitch Modulator */ + e_uint32 pm_phase ; + e_int32 lfo_pm ; + + /* Amp Modulator */ + e_int32 am_phase ; + e_int32 lfo_am ; + + e_uint32 quality; + + /* Noise Generator */ + e_uint32 noise_seed ; + + /* Channel Data */ + e_int32 patch_number[9]; + e_int32 key_status[9] ; + + /* Slot */ + OPLL_SLOT slot[18] ; + + /* Voice Data */ + OPLL_PATCH patch[19*2] ; + e_int32 patch_update[2] ; /* flag for check patch update */ + + e_uint32 mask ; + e_uint32 current_mask; + e_uint32 status; + + e_uint32 internal_mute; + e_int16 buffer[AUDIO_MONO_BUFFER_SIZE]; +} OPLL ; + +/* Create Object */ +EMU2413_API void OPLL_new(OPLL *, e_uint32 clk, e_uint32 rate) ; +EMU2413_API void OPLL_delete(OPLL *) ; + +/* Setup */ +EMU2413_API void OPLL_reset(OPLL *) ; +EMU2413_API void OPLL_reset_patch(OPLL *, e_int32) ; +EMU2413_API void OPLL_set_rate(OPLL *opll, e_uint32 r) ; +EMU2413_API void OPLL_set_quality(OPLL *opll, e_uint32 q) ; +EMU2413_API void OPLL_set_pan(OPLL *, e_uint32 ch, e_uint32 pan); +EMU2413_API void OPLL_set_internal_mute(OPLL *, e_uint32 mute); +EMU2413_API e_uint32 OPLL_is_internal_muted(OPLL *); + +/* Port/Register access */ +EMU2413_API void OPLL_writeIO(OPLL *, e_uint32 reg, e_uint32 val); +EMU2413_API void OPLL_writeReg(OPLL *, e_uint32 reg, e_uint32 val); +EMU2413_API e_uint32 OPLL_read(OPLL *, e_uint32 port); + +/* Synthsize */ +EMU2413_API e_int16 OPLL_calc(OPLL *) EMU2413_CALC_ICODE; +EMU2413_API void OPLL_calc_stereo(OPLL *, e_int32 out[2]) ; +EMU2413_API e_int16 *OPLL_update_buffer(OPLL *, e_uint32 length) ; + +/* Misc */ +EMU2413_API void OPLL_setPatch(OPLL *, const e_uint8 *dump) ; +EMU2413_API void OPLL_copyPatch(OPLL *, e_int32, OPLL_PATCH *) ; +EMU2413_API void OPLL_forceRefresh(OPLL *) ; +/* Utility */ +EMU2413_API void OPLL_dump2patch(const e_uint8 *dump, OPLL_PATCH *patch) ; +EMU2413_API void OPLL_patch2dump(const OPLL_PATCH *patch, e_uint8 *dump) ; +EMU2413_API void OPLL_getDefaultPatch(e_int32 type, e_int32 num, OPLL_PATCH *) ; + +/* Channel Mask */ +EMU2413_API e_uint32 OPLL_setMask(OPLL *, e_uint32 mask) ; +EMU2413_API e_uint32 OPLL_toggleMask(OPLL *, e_uint32 mask) ; + +#define dump2patch OPLL_dump2patch + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/lib/rbcodec/codecs/libgme/emu8950.c b/lib/rbcodec/codecs/libgme/emu8950.c new file mode 100644 index 0000000000..2f8a32044f --- /dev/null +++ b/lib/rbcodec/codecs/libgme/emu8950.c @@ -0,0 +1,1206 @@ +/* + * This file is based on: + * Y8950.cc -- Y8950 emulator from the openMSX team + * ported to c by gama + * + * The openMSX version is based on: + * emu8950.c -- Y8950 emulator written by Mitsutaka Okazaki 2001 + * heavily rewritten to fit openMSX structure + */ + +#include +#include "emu8950.h" + +#ifdef _MSC_VER +#pragma warning( disable : 4355 ) +#endif + +#if !defined(ROCKBOX) + #define EMU8950_CALCUL_TABLES +#else + #include "opltables.h" +#endif + +// dB to Liner table +static short dB2LinTab[(2*DB_MUTE)*2]; +// Dynamic range +static unsigned int dphaseNoiseTable[1024][8]; +// LFO Table +int pmtable[2][PM_PG_WIDTH]; +int amtable[2][AM_PG_WIDTH]; + +/** WaveTable for each envelope amp. */ +static int sintable[PG_WIDTH]; + /** Phase incr table for Attack. */ +static unsigned int dphaseARTable[16][16]; +/** Phase incr table for Decay and Release. */ +static unsigned int dphaseDRTable[16][16]; +/** KSL + TL Table. */ +#if !defined(ROCKBOX) +static unsigned char tllTable[16][8][1<> b; +} +// Leave the lower b bits +inline static int LOWBITS(int c, int b) +{ + return c & ((1<> 1; + #else + AR_ADJUST_TABLE[i] = ar_adjust_coeff[i-1]; + #endif +} + +// Table for dB(0 -- (1<> (21 - DP_BITS)), sampleRate, clockRate); +} +#endif + +#if !defined(ROCKBOX) +static void makeTllTable(void) +{ + #define dB2(x) (int)((x)*2) + static int kltable[16] = { + dB2( 0.000),dB2( 9.000),dB2(12.000),dB2(13.875), + dB2(15.000),dB2(16.125),dB2(16.875),dB2(17.625), + dB2(18.000),dB2(18.750),dB2(19.125),dB2(19.500), + dB2(19.875),dB2(20.250),dB2(20.625),dB2(21.000) + }; + + int fnum, block, TL, KL; + for (fnum=0; fnum<16; fnum++) + for (block=0; block<8; block++) + for (TL=0; TL<64; TL++) + for (KL=0; KL<4; KL++) { + if (KL==0) { + tllTable[fnum][block][TL][KL] = (ALIGN(TL, TL_STEP, EG_STEP) ) >> 1; + } else { + int tmp = kltable[fnum] - dB2(3.000) * (7 - block); + if (tmp <= 0) + tllTable[fnum][block][TL][KL] = (ALIGN(TL, TL_STEP, EG_STEP) ) >> 1; + else + tllTable[fnum][block][TL][KL] = ((int)((tmp>>(3-KL))/EG_STEP) + ALIGN(TL, TL_STEP, EG_STEP) ) >> 1; + } + } +} +#endif + +// Rate Table for Attack +static void makeDphaseARTable(int sampleRate, int clockRate) +{ + int AR, Rks; + for (AR=0; AR<16; AR++) + for (Rks=0; Rks<16; Rks++) { + int RM = AR + (Rks>>2); + int RL = Rks&3; + if (RM>15) RM=15; + switch (AR) { + case 0: + dphaseARTable[AR][Rks] = 0; + break; + case 15: + dphaseARTable[AR][Rks] = EG_DP_WIDTH; + break; + default: + dphaseARTable[AR][Rks] = rate_adjust((3*(RL+4) << (RM+1)), sampleRate, clockRate); + break; + } + } +} + +// Rate Table for Decay +static void makeDphaseDRTable(int sampleRate, int clockRate) +{ + int DR, Rks; + for (DR=0; DR<16; DR++) + for (Rks=0; Rks<16; Rks++) { + int RM = DR + (Rks>>2); + int RL = Rks&3; + if (RM>15) RM=15; + switch (DR) { + case 0: + dphaseDRTable[DR][Rks] = 0; + break; + default: + dphaseDRTable[DR][Rks] = rate_adjust((RL+4) << (RM-1), sampleRate, clockRate); + break; + } + } +} + +static void makeRksTable(void) +{ + int fnum9, block, KR; + for (fnum9=0; fnum9<2; fnum9++) + for (block=0; block<8; block++) + for (KR=0; KR<2; KR++) { + rksTable[fnum9][block][KR] = (KR != 0) ? + (block<<1) + fnum9: + block>>1; + } +} + +//**********************************************************// +// // +// Patch // +// // +//**********************************************************// + + +void patchReset(struct Patch* patch) +{ + patch->AM = patch->PM = patch->EG = false; + patch->KR = patch->ML = patch->KL = patch->TL = + patch->FB = patch->AR = patch->DR = patch->SL = patch->RR = 0; +} + + +//**********************************************************// +// // +// Slot // +// // +//**********************************************************// + + +static inline void slotUpdatePG(struct Slot* slot) +{ +#if defined(ROCKBOX) + static const int mltable[16] = { + 1,1*2,2*2,3*2,4*2,5*2,6*2,7*2,8*2,9*2,10*2,10*2,12*2,12*2,15*2,15*2 + }; + + slot->dphase = ((slot->fnum * mltable[slot->patch.ML]) << slot->block) >> (21 - DP_BITS); +#else + slot->dphase = dphaseTable[slot->fnum][slot->block][slot->patch.ML]; +#endif +} + +static inline void slotUpdateTLL(struct Slot* slot) +{ + slot->tll = (int)(tllTable[slot->fnum>>6][slot->block][slot->patch.TL][slot->patch.KL]) << 1; +} + +static inline void slotUpdateRKS(struct Slot* slot) +{ + slot->rks = rksTable[slot->fnum>>9][slot->block][slot->patch.KR]; +} + +static inline void slotUpdateEG(struct Slot* slot) +{ + switch (slot->eg_mode) { + case ATTACK: + slot->eg_dphase = dphaseARTable[slot->patch.AR][slot->rks]; + break; + case DECAY: + slot->eg_dphase = dphaseDRTable[slot->patch.DR][slot->rks]; + break; + case SUSTINE: + slot->eg_dphase = dphaseDRTable[slot->patch.RR][slot->rks]; + break; + case RELEASE: + slot->eg_dphase = slot->patch.EG ? + dphaseDRTable[slot->patch.RR][slot->rks]: + dphaseDRTable[7] [slot->rks]; + break; + case SUSHOLD: + case FINISH: + slot->eg_dphase = 0; + break; + } +} + +static inline void slotUpdateAll(struct Slot* slot) +{ + slotUpdatePG(slot); + slotUpdateTLL(slot); + slotUpdateRKS(slot); + slotUpdateEG(slot); // EG should be last +} + +void slotReset(struct Slot* slot) +{ + slot->phase = 0; + slot->dphase = 0; + slot->output[0] = 0; + slot->output[1] = 0; + slot->feedback = 0; + slot->eg_mode = FINISH; + slot->eg_phase = EG_DP_WIDTH; + slot->eg_dphase = 0; + slot->rks = 0; + slot->tll = 0; + slot->fnum = 0; + slot->block = 0; + slot->pgout = 0; + slot->egout = 0; + slot->slotStatus = false; + patchReset(&slot->patch); + slotUpdateAll(slot); +} + +// Slot key on +static inline void slotOn(struct Slot* slot) +{ + if (!slot->slotStatus) { + slot->slotStatus = true; + slot->eg_mode = ATTACK; + slot->phase = 0; + slot->eg_phase = 0; + } +} + +// Slot key off +static inline void slotOff(struct Slot* slot) +{ + if (slot->slotStatus) { + slot->slotStatus = false; + if (slot->eg_mode == ATTACK) + slot->eg_phase = EXPAND_BITS(AR_ADJUST_TABLE[HIGHBITS(slot->eg_phase, EG_DP_BITS-EG_BITS)], EG_BITS, EG_DP_BITS); + slot->eg_mode = RELEASE; + } +} + + +//**********************************************************// +// // +// OPLChannel // +// // +//**********************************************************// + + +void channelReset(struct OPLChannel* ch) +{ + slotReset(&ch->mod); + slotReset(&ch->car); + ch->alg = false; +} + +// Set F-Number ( fnum : 10bit ) +static void channelSetFnumber(struct OPLChannel* ch, int fnum) +{ + ch->car.fnum = fnum; + ch->mod.fnum = fnum; +} + +// Set Block data (block : 3bit ) +static void channelSetBlock(struct OPLChannel* ch, int block) +{ + ch->car.block = block; + ch->mod.block = block; +} + +// OPLChannel key on +static void keyOn(struct OPLChannel* ch) +{ + slotOn(&ch->mod); + slotOn(&ch->car); +} + +// OPLChannel key off +static void keyOff(struct OPLChannel* ch) +{ + slotOff(&ch->mod); + slotOff(&ch->car); +} + + +//**********************************************************// +// // +// Y8950 // +// // +//**********************************************************// + +void OPL_init(struct Y8950* this, byte* ramBank, int sampleRam) +{ + this->clockRate = CLK_FREQ; + + ADPCM_init(&this->adpcm, this, ramBank, sampleRam); + + makePmTable(); + makeAmTable(); + + makeAdjustTable(); + makeDB2LinTable(); +#if !defined(ROCKBOX) + makeTllTable(); +#endif + makeRksTable(); + makeSinTable(); + + int i; + for (i=0; i<9; i++) { + // TODO cleanup + this->slot[i*2+0] = &(this->ch[i].mod); + this->slot[i*2+1] = &(this->ch[i].car); + this->ch[i].mod.plfo_am = &this->lfo_am; + this->ch[i].mod.plfo_pm = &this->lfo_pm; + this->ch[i].car.plfo_am = &this->lfo_am; + this->ch[i].car.plfo_pm = &this->lfo_pm; + } + + OPL_reset(this); +} + +void OPL_setSampleRate(struct Y8950* this, int sampleRate, int clockRate) +{ + this->clockRate = clockRate; + ADPCM_setSampleRate(&this->adpcm, sampleRate, clockRate); + +#if !defined(ROCKBOX) + makeDphaseTable(sampleRate, clockRate); +#endif + makeDphaseARTable(sampleRate, clockRate); + makeDphaseDRTable(sampleRate, clockRate); + makeDphaseNoiseTable(sampleRate, clockRate); + this->pm_dphase = rate_adjust( (int)(PM_SPEED * PM_DP_WIDTH) / (clockRate/72), sampleRate, clockRate); + this->am_dphase = rate_adjust( (int)(AM_SPEED * AM_DP_WIDTH) / (clockRate/72), sampleRate, clockRate); +} + +// Reset whole of opl except patch datas. +void OPL_reset(struct Y8950* this) +{ + int i; + for (i=0; i<9; i++) + channelReset(&this->ch[i]); + this->output[0] = 0; + this->output[1] = 0; + + + this->dacSampleVolume = 0; + this->dacOldSampleVolume = 0; + this->dacSampleVolumeSum = 0; + this->dacCtrlVolume = 0; + this->dacDaVolume = 0; + this->dacEnabled = 0; + + this->rythm_mode = false; + this->am_mode = 0; + this->pm_mode = 0; + this->pm_phase = 0; + this->am_phase = 0; + this->noise_seed = 0xffff; + this->noiseA = 0; + this->noiseB = 0; + this->noiseA_phase = 0; + this->noiseB_phase = 0; + this->noiseA_dphase = 0; + this->noiseB_dphase = 0; + + for (i = 0; i < 0x100; ++i) + this->reg[i] = 0x00; + + this->reg[0x04] = 0x18; + this->reg[0x19] = 0x0F; // fixes 'Thunderbirds are Go' + this->status = 0x00; + this->statusMask = 0; + /* irq.reset(); */ + + ADPCM_reset(&this->adpcm); + OPL_setInternalMute(this, true); // muted +} + + +// Drum key on +static inline void keyOn_BD(struct Y8950* this) { keyOn(&this->ch[6]); } +static inline void keyOn_HH(struct Y8950* this) { slotOn(&this->ch[7].mod); } +static inline void keyOn_SD(struct Y8950* this) { slotOn(&this->ch[7].car); } +static inline void keyOn_TOM(struct Y8950* this) { slotOn(&this->ch[8].mod); } +static inline void keyOn_CYM(struct Y8950* this) { slotOn(&this->ch[8].car); } + +// Drum key off +static inline void keyOff_BD(struct Y8950* this) { keyOff(&this->ch[6]); } +static inline void keyOff_HH(struct Y8950* this) { slotOff(&this->ch[7].mod); } +static inline void keyOff_SD(struct Y8950* this) { slotOff(&this->ch[7].car); } +static inline void keyOff_TOM(struct Y8950* this){ slotOff(&this->ch[8].mod); } +static inline void keyOff_CYM(struct Y8950* this){ slotOff(&this->ch[8].car); } + +// Change Rhythm Mode +static inline void setRythmMode(struct Y8950* this, int data) +{ + bool newMode = (data & 32) != 0; + if (this->rythm_mode != newMode) { + this->rythm_mode = newMode; + if (!this->rythm_mode) { + // ON->OFF + this->ch[6].mod.eg_mode = FINISH; // BD1 + this->ch[6].mod.slotStatus = false; + this->ch[6].car.eg_mode = FINISH; // BD2 + this->ch[6].car.slotStatus = false; + this->ch[7].mod.eg_mode = FINISH; // HH + this->ch[7].mod.slotStatus = false; + this->ch[7].car.eg_mode = FINISH; // SD + this->ch[7].car.slotStatus = false; + this->ch[8].mod.eg_mode = FINISH; // TOM + this->ch[8].mod.slotStatus = false; + this->ch[8].car.eg_mode = FINISH; // CYM + this->ch[8].car.slotStatus = false; + } + } +} + +//********************************************************// +// // +// Generate wave data // +// // +//********************************************************// + +// Convert Amp(0 to EG_HEIGHT) to Phase(0 to 4PI). +inline static int wave2_4pi(int e) +{ + int shift = SLOT_AMP_BITS - PG_BITS - 1; + if (shift > 0) + return e >> shift; + else + return e << -shift; +} + +// Convert Amp(0 to EG_HEIGHT) to Phase(0 to 8PI). +inline static int wave2_8pi(int e) +{ + int shift = SLOT_AMP_BITS - PG_BITS - 2; + if (shift > 0) + return e >> shift; + else + return e << -shift; +} + +static inline void update_noise(struct Y8950* this) +{ + if (this->noise_seed & 1) + this->noise_seed ^= 0x24000; + this->noise_seed >>= 1; + this->whitenoise = this->noise_seed&1 ? DB_POS(6) : DB_NEG(6); + + this->noiseA_phase += this->noiseA_dphase; + this->noiseB_phase += this->noiseB_dphase; + + this->noiseA_phase &= (0x40<<11) - 1; + if ((this->noiseA_phase>>11)==0x3f) + this->noiseA_phase = 0; + this->noiseA = this->noiseA_phase&(0x03<<11)?DB_POS(6):DB_NEG(6); + + this->noiseB_phase &= (0x10<<11) - 1; + this->noiseB = this->noiseB_phase&(0x0A<<11)?DB_POS(6):DB_NEG(6); +} + +static inline void update_ampm(struct Y8950* this) +{ + this->pm_phase = (this->pm_phase + this->pm_dphase)&(PM_DP_WIDTH - 1); + this->am_phase = (this->am_phase + this->am_dphase)&(AM_DP_WIDTH - 1); + this->lfo_am = amtable[this->am_mode][HIGHBITS(this->am_phase, AM_DP_BITS - AM_PG_BITS)]; + this->lfo_pm = pmtable[this->pm_mode][HIGHBITS(this->pm_phase, PM_DP_BITS - PM_PG_BITS)]; +} + +static inline void calc_phase(struct Slot* slot) +{ + if (slot->patch.PM) + slot->phase += (slot->dphase * (*slot->plfo_pm)) >> PM_AMP_BITS; + else + slot->phase += slot->dphase; + slot->phase &= (DP_WIDTH - 1); + slot->pgout = HIGHBITS(slot->phase, DP_BASE_BITS); +} + +static inline void calc_envelope(struct Slot* slot) +{ + #define S2E(x) (ALIGN((unsigned int)(x/SL_STEP),SL_STEP,EG_STEP)<<(EG_DP_BITS-EG_BITS)) + static unsigned int SL[16] = { + S2E( 0), S2E( 3), S2E( 6), S2E( 9), S2E(12), S2E(15), S2E(18), S2E(21), + S2E(24), S2E(27), S2E(30), S2E(33), S2E(36), S2E(39), S2E(42), S2E(93) + }; + + switch (slot->eg_mode) { + case ATTACK: + slot->eg_phase += slot->eg_dphase; + if (EG_DP_WIDTH & slot->eg_phase) { + slot->egout = 0; + slot->eg_phase= 0; + slot->eg_mode = DECAY; + slotUpdateEG(slot); + } else { + slot->egout = AR_ADJUST_TABLE[HIGHBITS(slot->eg_phase, EG_DP_BITS - EG_BITS)]; + } + break; + + case DECAY: + slot->eg_phase += slot->eg_dphase; + slot->egout = HIGHBITS(slot->eg_phase, EG_DP_BITS - EG_BITS); + if (slot->eg_phase >= SL[slot->patch.SL]) { + if (slot->patch.EG) { + slot->eg_phase = SL[slot->patch.SL]; + slot->eg_mode = SUSHOLD; + slotUpdateEG(slot); + } else { + slot->eg_phase = SL[slot->patch.SL]; + slot->eg_mode = SUSTINE; + slotUpdateEG(slot); + } + slot->egout = HIGHBITS(slot->eg_phase, EG_DP_BITS - EG_BITS); + } + break; + + case SUSHOLD: + slot->egout = HIGHBITS(slot->eg_phase, EG_DP_BITS - EG_BITS); + if (!slot->patch.EG) { + slot->eg_mode = SUSTINE; + slotUpdateEG(slot); + } + break; + + case SUSTINE: + case RELEASE: + slot->eg_phase += slot->eg_dphase; + slot->egout = HIGHBITS(slot->eg_phase, EG_DP_BITS - EG_BITS); + if (slot->egout >= (1<eg_mode = FINISH; + slot->egout = (1<egout = (1<patch.AM) + slot->egout = ALIGN(slot->egout+slot->tll,EG_STEP,DB_STEP) + (*slot->plfo_am); + else + slot->egout = ALIGN(slot->egout+slot->tll,EG_STEP,DB_STEP); + if (slot->egout >= DB_MUTE) + slot->egout = DB_MUTE-1; +} + +inline static int calc_slot_car(struct Slot* slot, int fm) +{ + calc_envelope(slot); + calc_phase(slot); + if (slot->egout>=(DB_MUTE-1)) + return 0; + return dB2LinTab[sintable[(slot->pgout+wave2_8pi(fm))&(PG_WIDTH-1)] + slot->egout]; +} + +inline static int calc_slot_mod(struct Slot* slot) +{ + slot->output[1] = slot->output[0]; + calc_envelope(slot); + calc_phase(slot); + + if (slot->egout>=(DB_MUTE-1)) { + slot->output[0] = 0; + } else if (slot->patch.FB!=0) { + int fm = wave2_4pi(slot->feedback) >> (7-slot->patch.FB); + slot->output[0] = dB2LinTab[sintable[(slot->pgout+fm)&(PG_WIDTH-1)] + slot->egout]; + } else + slot->output[0] = dB2LinTab[sintable[slot->pgout] + slot->egout]; + + slot->feedback = (slot->output[1] + slot->output[0])>>1; + return slot->feedback; +} + +// TOM +inline static int calc_slot_tom(struct Slot* slot) +{ + calc_envelope(slot); + calc_phase(slot); + if (slot->egout>=(DB_MUTE-1)) + return 0; + return dB2LinTab[sintable[slot->pgout] + slot->egout]; +} + +// SNARE +inline static int calc_slot_snare(struct Slot* slot, int whitenoise) +{ + calc_envelope(slot); + calc_phase(slot); + if (slot->egout>=(DB_MUTE-1)) + return 0; + if (slot->pgout & (1<<(PG_BITS-1))) { + return (dB2LinTab[slot->egout] + dB2LinTab[slot->egout+whitenoise]) >> 1; + } else { + return (dB2LinTab[2*DB_MUTE + slot->egout] + dB2LinTab[slot->egout+whitenoise]) >> 1; + } +} + +// TOP-CYM +inline static int calc_slot_cym(struct Slot* slot, int a, int b) +{ + calc_envelope(slot); + if (slot->egout>=(DB_MUTE-1)) { + return 0; + } else { + return (dB2LinTab[slot->egout+a] + dB2LinTab[slot->egout+b]) >> 1; + } +} + +// HI-HAT +inline static int calc_slot_hat(struct Slot* slot, int a, int b, int whitenoise) +{ + calc_envelope(slot); + if (slot->egout>=(DB_MUTE-1)) { + return 0; + } else { + return (dB2LinTab[slot->egout+whitenoise] + dB2LinTab[slot->egout+a] + dB2LinTab[slot->egout+b]) >>2; + } +} + + +static inline int calcSample(struct Y8950* this, int channelMask) +{ + // while muted update_ampm() and update_noise() aren't called, probably ok + update_ampm(this); + update_noise(this); + + int mix = 0; + + if (this->rythm_mode) { + // TODO wasn't in original source either + calc_phase(&this->ch[7].mod); + calc_phase(&this->ch[8].car); + + if (channelMask & (1 << 6)) + mix += calc_slot_car(&this->ch[6].car, calc_slot_mod(&this->ch[6].mod)); + if (this->ch[7].mod.eg_mode != FINISH) + mix += calc_slot_hat(&this->ch[7].mod, this->noiseA, this->noiseB, this->whitenoise); + if (channelMask & (1 << 7)) + mix += calc_slot_snare(&this->ch[7].car, this->whitenoise); + if (this->ch[8].mod.eg_mode != FINISH) + mix += calc_slot_tom(&this->ch[8].mod); + if (channelMask & (1 << 8)) + mix += calc_slot_cym(&this->ch[8].car, this->noiseA, this->noiseB); + + channelMask &= (1<< 6) - 1; + mix *= 2; + } + struct OPLChannel *cp; + for (cp = this->ch; channelMask; channelMask >>=1, cp++) { + if (channelMask & 1) { + if (cp->alg) + mix += calc_slot_car(&cp->car, 0) + + calc_slot_mod(&cp->mod); + else + mix += calc_slot_car(&cp->car, + calc_slot_mod(&cp->mod)); + } + } + + mix += ADPCM_calcSample(&this->adpcm); + + return (mix*this->maxVolume) >> (DB2LIN_AMP_BITS - 1); +} + +static bool checkMuteHelper(struct Y8950* this) +{ + int i; + struct OPLChannel *ch = this->ch; + for (i = 0; i < 6; i++) { + if (ch[i].car.eg_mode != FINISH) return false; + } + if (!this->rythm_mode) { + for(i = 6; i < 9; i++) { + if (ch[i].car.eg_mode != FINISH) return false; + } + } else { + if (ch[6].car.eg_mode != FINISH) return false; + if (ch[7].mod.eg_mode != FINISH) return false; + if (ch[7].car.eg_mode != FINISH) return false; + if (ch[8].mod.eg_mode != FINISH) return false; + if (ch[8].car.eg_mode != FINISH) return false; + } + + return ADPCM_muted(&this->adpcm); +} + +static void checkMute(struct Y8950* this) +{ + bool mute = checkMuteHelper(this); + //PRT_DEBUG("Y8950: muted " << mute); + OPL_setInternalMute(this, mute); +} + +int* OPL_updateBuffer(struct Y8950* this, int length) +{ + //PRT_DEBUG("Y8950: update buffer"); + + if (OPL_isInternalMuted(this) && !this->dacEnabled) { + return 0; + } + + this->dacCtrlVolume = this->dacSampleVolume - this->dacOldSampleVolume + 0x3fe7 * this->dacCtrlVolume / 0x4000; + this->dacOldSampleVolume = this->dacSampleVolume; + + int channelMask = 0, i; + struct OPLChannel *ch = this->ch; + for (i = 9; i--; ) { + channelMask <<= 1; + if (ch[i].car.eg_mode != FINISH) channelMask |= 1; + } + + int* buf = this->buffer; + while (length--) { + int sample = calcSample(this, channelMask); + + this->dacCtrlVolume = 0x3fe7 * this->dacCtrlVolume / 0x4000; + this->dacDaVolume += 2 * (this->dacCtrlVolume - this->dacDaVolume) / 3; + sample += 48 * this->dacDaVolume; + *(buf++) = sample; + } + + this->dacEnabled = this->dacDaVolume; + + checkMute(this); + return this->buffer; +} + +void OPL_setInternalVolume(struct Y8950* this, short newVolume) +{ + this->maxVolume = newVolume; +} + +//**************************************************// +// // +// I/O Ctrl // +// // +//**************************************************// + +void OPL_writeReg(struct Y8950* this, byte rg, byte data) +{ + //PRT_DEBUG("Y8950 write " << (int)rg << " " << (int)data); + int stbl[32] = { + 0, 2, 4, 1, 3, 5,-1,-1, + 6, 8,10, 7, 9,11,-1,-1, + 12,14,16,13,15,17,-1,-1, + -1,-1,-1,-1,-1,-1,-1,-1 + }; + + //TODO only for registers that influence sound + //TODO also ADPCM + + switch (rg & 0xe0) { + case 0x00: { + switch (rg) { + case 0x01: // TEST + // TODO + // Y8950 MSX-AUDIO Test register $01 (write only) + // + // Bit Description + // + // 7 Reset LFOs - seems to force the LFOs to their initial values (eg. + // maximum amplitude, zero phase deviation) + // + // 6 something to do with ADPCM - bit 0 of the status register is + // affected by setting this bit (PCM BSY) + // + // 5 No effect? - Waveform select enable in YM3812 OPL2 so seems + // reasonable that this bit wouldn't have been used in OPL + // + // 4 No effect? + // + // 3 Faster LFOs - increases the frequencies of the LFOs and (maybe) + // the timers (cf. YM2151 test register) + // + // 2 Reset phase generators - No phase generator output, but envelope + // generators still work (can hear a transient when they are gated) + // + // 1 No effect? + // + // 0 Reset envelopes - Envelope generator outputs forced to maximum, + // so all enabled voices sound at maximum + this->reg[rg] = data; + break; + + case 0x02: // TIMER1 (reso. 80us) + this->reg[rg] = data; + break; + + case 0x03: // TIMER2 (reso. 320us) + this->reg[rg] = data; + break; + + case 0x04: // FLAG CONTROL + if (data & R04_IRQ_RESET) { + OPL_resetStatus(this, 0x78); // reset all flags + } else { + OPL_changeStatusMask(this, (~data) & 0x78); + this->reg[rg] = data; + } + break; + + case 0x06: // (KEYBOARD OUT) + this->reg[rg] = data; + break; + + case 0x07: // START/REC/MEM DATA/REPEAT/SP-OFF/-/-/RESET + case 0x08: // CSM/KEY BOARD SPLIT/-/-/SAMPLE/DA AD/64K/ROM + case 0x09: // START ADDRESS (L) + case 0x0A: // START ADDRESS (H) + case 0x0B: // STOP ADDRESS (L) + case 0x0C: // STOP ADDRESS (H) + case 0x0D: // PRESCALE (L) + case 0x0E: // PRESCALE (H) + case 0x0F: // ADPCM-DATA + case 0x10: // DELTA-N (L) + case 0x11: // DELTA-N (H) + case 0x12: // ENVELOP CONTROL + case 0x1A: // PCM-DATA + this->reg[rg] = data; + ADPCM_writeReg(&this->adpcm, rg, data); + break; + + case 0x15: // DAC-DATA (bit9-2) + this->reg[rg] = data; + if (this->reg[0x08] & 0x04) { + static int damp[] = { 256, 279, 304, 332, 362, 395, 431, 470 }; + int sample = (short)(256 * this->reg[0x15] + this->reg[0x16]) * 128 / damp[this->reg[0x17]]; + this->dacSampleVolume = sample; + this->dacEnabled = 1; + } + break; + case 0x16: // (bit1-0) + this->reg[rg] = data & 0xC0; + break; + case 0x17: // (exponent) + this->reg[rg] = data & 0x07; + break; + + case 0x18: // I/O-CONTROL (bit3-0) + // TODO + // 0 -> input + // 1 -> output + this->reg[rg] = data; + break; + + case 0x19: // I/O-DATA (bit3-0) + // TODO + this->reg[rg] = data; + break; + } + + break; + } + case 0x20: { + int s = stbl[rg&0x1f]; + if (s >= 0) { + this->slot[s]->patch.AM = (data>>7)&1; + this->slot[s]->patch.PM = (data>>6)&1; + this->slot[s]->patch.EG = (data>>5)&1; + this->slot[s]->patch.KR = (data>>4)&1; + this->slot[s]->patch.ML = (data)&15; + slotUpdateAll(this->slot[s]); + } + this->reg[rg] = data; + break; + } + case 0x40: { + int s = stbl[rg&0x1f]; + if (s >= 0) { + this->slot[s]->patch.KL = (data>>6)&3; + this->slot[s]->patch.TL = (data)&63; + slotUpdateAll(this->slot[s]); + } + this->reg[rg] = data; + break; + } + case 0x60: { + int s = stbl[rg&0x1f]; + if (s >= 0) { + this->slot[s]->patch.AR = (data>>4)&15; + this->slot[s]->patch.DR = (data)&15; + slotUpdateEG(this->slot[s]); + } + this->reg[rg] = data; + break; + } + case 0x80: { + int s = stbl[rg&0x1f]; + if (s >= 0) { + this->slot[s]->patch.SL = (data>>4)&15; + this->slot[s]->patch.RR = (data)&15; + slotUpdateEG(this->slot[s]); + } + this->reg[rg] = data; + break; + } + case 0xa0: { + if (rg==0xbd) { + this->am_mode = (data>>7)&1; + this->pm_mode = (data>>6)&1; + + setRythmMode(this, data); + if (this->rythm_mode) { + if (data&0x10) keyOn_BD(this); else keyOff_BD(this); + if (data&0x08) keyOn_SD(this); else keyOff_SD(this); + if (data&0x04) keyOn_TOM(this); else keyOff_TOM(this); + if (data&0x02) keyOn_CYM(this); else keyOff_CYM(this); + if (data&0x01) keyOn_HH(this); else keyOff_HH(this); + } + slotUpdateAll(&this->ch[6].mod); + slotUpdateAll(&this->ch[6].car); + slotUpdateAll(&this->ch[7].mod); + slotUpdateAll(&this->ch[7].car); + slotUpdateAll(&this->ch[8].mod); + slotUpdateAll(&this->ch[8].car); + + this->reg[rg] = data; + break; + } + if ((rg&0xf) > 8) { + // 0xa9-0xaf 0xb9-0xbf + break; + } + if (!(rg&0x10)) { + // 0xa0-0xa8 + int c = rg-0xa0; + int fNum = data + ((this->reg[rg+0x10]&3)<<8); + int block = (this->reg[rg+0x10]>>2)&7; + channelSetFnumber(&this->ch[c], fNum); + switch (c) { + case 7: this->noiseA_dphase = dphaseNoiseTable[fNum][block]; + break; + case 8: this->noiseB_dphase = dphaseNoiseTable[fNum][block]; + break; + } + slotUpdateAll(&this->ch[c].car); + slotUpdateAll(&this->ch[c].mod); + this->reg[rg] = data; + } else { + // 0xb0-0xb8 + int c = rg-0xb0; + int fNum = ((data&3)<<8) + this->reg[rg-0x10]; + int block = (data>>2)&7; + channelSetFnumber(&this->ch[c], fNum); + channelSetBlock(&this->ch[c], block); + switch (c) { + case 7: this->noiseA_dphase = dphaseNoiseTable[fNum][block]; + break; + case 8: this->noiseB_dphase = dphaseNoiseTable[fNum][block]; + break; + } + if (data&0x20) + keyOn(&this->ch[c]); + else + keyOff(&this->ch[c]); + slotUpdateAll(&this->ch[c].mod); + slotUpdateAll(&this->ch[c].car); + this->reg[rg] = data; + } + break; + } + case 0xc0: { + if (rg > 0xc8) + break; + int c = rg-0xC0; + this->slot[c*2]->patch.FB = (data>>1)&7; + this->ch[c].alg = data&1; + this->reg[rg] = data; + } + } + + //TODO only for registers that influence sound + checkMute(this); +} + +byte OPL_readReg(struct Y8950* this, byte rg) +{ + byte result; + switch (rg) { + case 0x05: // (KEYBOARD IN) + result = 0xff; + break; + + case 0x0f: // ADPCM-DATA + case 0x13: // ??? + case 0x14: // ??? + case 0x1a: // PCM-DATA + result = ADPCM_readReg(&this->adpcm, rg); + break; + + case 0x19: // I/O DATA TODO + /* result = ~(switchGetAudio() ? 0 : 0x04); */ + result = 0; + break; + default: + result = 255; + } + //PRT_DEBUG("Y8950 read " << (int)rg<<" "<<(int)result); + return result; +} + +byte OPL_readStatus(struct Y8950* this) +{ + OPL_setStatus(this, STATUS_BUF_RDY); // temp hack + byte tmp = this->status & (0x80 | this->statusMask); + //PRT_DEBUG("Y8950 read status " << (int)tmp); + return tmp | 0x06; // bit 1 and 2 are always 1 +} + + +void OPL_setStatus(struct Y8950* this, byte flags) +{ + this->status |= flags; + if (this->status & this->statusMask) { + this->status |= 0x80; + /* irq.set(); */ + } +} +void OPL_resetStatus(struct Y8950* this, byte flags) +{ + this->status &= ~flags; + if (!(this->status & this->statusMask)) { + this->status &= 0x7f; + /* irq.reset(); */ + } +} +void OPL_changeStatusMask(struct Y8950* this, byte newMask) +{ + this->statusMask = newMask; + this->status &= this->statusMask; + if (this->status) { + this->status |= 0x80; + /* irq.set(); */ + } else { + this->status &= 0x7f; + /* irq.reset(); */ + } +} diff --git a/lib/rbcodec/codecs/libgme/emu8950.h b/lib/rbcodec/codecs/libgme/emu8950.h new file mode 100644 index 0000000000..02169050d2 --- /dev/null +++ b/lib/rbcodec/codecs/libgme/emu8950.h @@ -0,0 +1,248 @@ +#ifndef __Y8950_HH__ +#define __Y8950_HH__ + +#include "blargg_common.h" +#include "emuadpcm.h" + +#define AUDIO_MONO_BUFFER_SIZE 1024 + +// Dynamic range of envelope +static const double EG_STEP = 0.1875; +#define EG_BITS 9 +#define EG_MUTE (1< + int *plfo_pm; + int *plfo_am; +}; + +void slotReset(struct Slot* slot); + + +struct OPLChannel { + bool alg; + struct Slot mod, car; +}; + +void channelReset(struct OPLChannel* ch); + + +struct Y8950 +{ + int adr; + int output[2]; + // Register + byte reg[0x100]; + bool rythm_mode; + // Pitch Modulator + int pm_mode; + unsigned int pm_phase; + // Amp Modulator + int am_mode; + unsigned int am_phase; + + // Noise Generator + int noise_seed; + int whitenoise; + int noiseA; + int noiseB; + unsigned int noiseA_phase; + unsigned int noiseB_phase; + unsigned int noiseA_dphase; + unsigned int noiseB_dphase; + + // Channel & Slot + struct OPLChannel ch[9]; + struct Slot *slot[18]; + + unsigned int pm_dphase; + int lfo_pm; + unsigned int am_dphase; + int lfo_am; + + int maxVolume; + bool internalMuted; + + int clockRate; + + /** STATUS Register. */ + byte status; + /** bit=0 -> masked. */ + byte statusMask; + /* MsxAudioIRQHelper irq; */ + + // ADPCM + struct Y8950Adpcm adpcm; + + /** 13-bit (exponential) DAC. */ + /* DACSound16S dac13; */ + + // DAC stuff + int dacSampleVolume; + int dacOldSampleVolume; + int dacSampleVolumeSum; + int dacCtrlVolume; + int dacDaVolume; + int dacEnabled; + + // Internal buffer + int buffer[AUDIO_MONO_BUFFER_SIZE]; +}; + +void OPL_init(struct Y8950* this_, byte* ramBank, int sampleRam); + +void OPL_reset(struct Y8950* this_); +void OPL_writeReg(struct Y8950* this_, byte reg, byte data); +byte OPL_readReg(struct Y8950* this_, byte reg); +byte OPL_readStatus(struct Y8950* this_); +static inline void OPL_setInternalMute(struct Y8950* this_, bool muted) { this_->internalMuted = muted; } +static inline bool OPL_isInternalMuted(struct Y8950* this_) { return this_->internalMuted; } + +void OPL_setSampleRate(struct Y8950* this_, int sampleRate, int clockRate); +int* OPL_updateBuffer(struct Y8950* this_, int length); + +// SoundDevice +void OPL_setInternalVolume(struct Y8950* this_, short maxVolume); + +void OPL_setStatus(struct Y8950* this_, byte flags); +void OPL_resetStatus(struct Y8950* this_, byte flags); +void OPL_changeStatusMask(struct Y8950* this_, byte newMask); + + +// Adjust envelope speed which depends on sampling rate +static inline unsigned int rate_adjust(int x, int rate, int clk) +{ + unsigned int tmp = (long long)x * clk / 72 / rate; +// assert (tmp <= 4294967295U); + return tmp; +} + +#endif diff --git a/lib/rbcodec/codecs/libgme/emuadpcm.c b/lib/rbcodec/codecs/libgme/emuadpcm.c new file mode 100644 index 0000000000..b426a74de5 --- /dev/null +++ b/lib/rbcodec/codecs/libgme/emuadpcm.c @@ -0,0 +1,297 @@ +/* + * This file is based on: + * Y8950Adpcm.cc -- Y8950 ADPCM emulator from the openMSX team + * ported to c by gama + * + * The openMSX version is based on: + * emuadpcm.c -- Y8950 ADPCM emulator written by Mitsutaka Okazaki 2001 + * heavily rewritten to fit openMSX structure + */ + +#include + +#include "emuadpcm.h" +#include "emu8950.h" + +// Relative volume between ADPCM part and FM part, +// value experimentally found by Manuel Bilderbeek +const int ADPCM_VOLUME = 356; + +// Bitmask for register 0x07 +static const int R07_RESET = 0x01; +//static const int R07 = 0x02;. // not used +//static const int R07 = 0x04;. // not used +const int R07_SP_OFF = 0x08; +const int R07_REPEAT = 0x10; +const int R07_MEMORY_DATA = 0x20; +const int R07_REC = 0x40; +const int R07_START = 0x80; + +//Bitmask for register 0x08 +const int R08_ROM = 0x01; +const int R08_64K = 0x02; +const int R08_DA_AD = 0x04; +const int R08_SAMPL = 0x08; +//const int R08 = 0x10;. // not used +//const int R08 = 0x20;. // not used +const int R08_NOTE_SET = 0x40; +const int R08_CSM = 0x80; + +const int DMAX = 0x6000; +const int DMIN = 0x7F; +const int DDEF = 0x7F; + +const int DECODE_MAX = 32767; +const int DECODE_MIN = -32768; + +#define GETA_BITS 14 +#define MAX_STEP (1<<(16+GETA_BITS)) + + +//**************************************************// +// // +// Helper functions // +// // +//**************************************************// + +static int CLAP(int min, int x, int max) +{ + return (x < min) ? min : ((max < x) ? max : x); +} + +//**********************************************************// +// // +// Y8950Adpcm // +// // +//**********************************************************// + + +void ADPCM_init(struct Y8950Adpcm* this_, struct Y8950* y8950_, byte* ramBank, int sampleRam) + +{ + this_->y8950 = y8950_; + this_->ramBank = ramBank; + this_->ramSize = sampleRam; + memset(this_->ramBank, 0xFF, this_->ramSize); + this_->volume = 0; +} + +void restart(struct Y8950Adpcm* this_); +void ADPCM_reset(struct Y8950Adpcm* this_) +{ + this_->playing = false; + this_->startAddr = 0; + this_->stopAddr = 7; + this_->memPntr = 0; + this_->delta = 0; + this_->step = 0; + this_->addrMask = (1 << 19) - 1; + this_->reg7 = 0; + this_->reg15 = 0; + ADPCM_writeReg(this_, 0x12, 255); // volume + restart(this_); +} + +void ADPCM_setSampleRate(struct Y8950Adpcm* this_, int sr, int clk) +{ + this_->sampleRate = sr; + this_->clockRate = clk; +} + +bool ADPCM_muted(struct Y8950Adpcm* this_) +{ + return (!this_->playing) || (this_->reg7 & R07_SP_OFF); +} + +//**************************************************// +// // +// I/O Ctrl // +// // +//**************************************************// + +void restart(struct Y8950Adpcm* this_) +{ + this_->playAddr = this_->startAddr & this_->addrMask; + this_->nowStep = MAX_STEP - this_->step; + this_->out = this_->output = 0; + this_->diff = DDEF; + this_->nextLeveling = 0; + this_->sampleStep = 0; + this_->volumeWStep = (int)((long long)this_->volume * this_->step / MAX_STEP); +} + +void ADPCM_writeReg(struct Y8950Adpcm* this_, byte rg, byte data) +{ + switch (rg) { + case 0x07: // START/REC/MEM DATA/REPEAT/SP-OFF/-/-/RESET + this_->reg7 = data; + if (this_->reg7 & R07_RESET) { + this_->playing = false; + } else if (data & R07_START) { + this_->playing = true; + restart(this_); + } + break; + + case 0x08: // CSM/KEY BOARD SPLIT/-/-/SAMPLE/DA AD/64K/ROM + this_->romBank = data & R08_ROM; + this_->addrMask = data & R08_64K ? (1<<17)-1 : (1<<19)-1; + break; + + case 0x09: // START ADDRESS (L) + this_->startAddr = (this_->startAddr & 0x7F800) | (data << 3); + this_->memPntr = 0; + break; + case 0x0A: // START ADDRESS (H) + this_->startAddr = (this_->startAddr & 0x007F8) | (data << 11); + this_->memPntr = 0; + break; + + case 0x0B: // STOP ADDRESS (L) + this_->stopAddr = (this_->stopAddr & 0x7F807) | (data << 3); + break; + case 0x0C: // STOP ADDRESS (H) + this_->stopAddr = (this_->stopAddr & 0x007FF) | (data << 11); + break; + + + case 0x0F: // ADPCM-DATA + // TODO check this + //if ((reg7 & R07_REC) && (reg7 & R07_MEMORY_DATA)) { + { + int tmp = ((this_->startAddr + this_->memPntr) & this_->addrMask) / 2; + tmp = (tmp < this_->ramSize) ? tmp : (tmp & (this_->ramSize - 1)); + if (!this_->romBank) { + this_->ramBank[tmp] = data; + } + //PRT_DEBUG("Y8950Adpcm: mem " << tmp << " " << (int)data); + this_->memPntr += 2; + if ((this_->startAddr + this_->memPntr) > this_->stopAddr) { + OPL_setStatus(this_->y8950, STATUS_EOS); + } + } + OPL_setStatus(this_->y8950, STATUS_BUF_RDY); + break; + + case 0x10: // DELTA-N (L) + this_->delta = (this_->delta & 0xFF00) | data; + this_->step = rate_adjust(this_->delta<sampleRate, this_->clockRate); + this_->volumeWStep = (int)((long long)this_->volume * this_->step / MAX_STEP); + break; + case 0x11: // DELTA-N (H) + this_->delta = (this_->delta & 0x00FF) | (data << 8); + this_->step = rate_adjust(this_->delta<sampleRate, this_->clockRate); + this_->volumeWStep = (int)((long long)this_->volume * this_->step / MAX_STEP); + break; + + case 0x12: { // ENVELOP CONTROL + int oldVol = this_->volume; + this_->volume = (data * ADPCM_VOLUME) >> 8; + if (oldVol != 0) { + this_->output = (int)(((long long)this_->output * this_->volume) / oldVol); + this_->sampleStep = (int)(((long long)this_->sampleStep * this_->volume) / oldVol); + } + this_->volumeWStep = (int)((long long)this_->volume * this_->step / MAX_STEP); + break; + } + case 0x0D: // PRESCALE (L) + case 0x0E: // PRESCALE (H) + case 0x15: // DAC-DATA (bit9-2) + case 0x16: // (bit1-0) + case 0x17: // (exponent) + case 0x1A: // PCM-DATA + // not implemented + break; + } +} + +byte ADPCM_readReg(struct Y8950Adpcm* this_, byte rg) +{ + byte result; + switch (rg) { + case 0x0F: { // ADPCM-DATA + // TODO don't advance pointer when playing??? + int adr = ((this_->startAddr + this_->memPntr) & this_->addrMask) / 2; + if (this_->romBank || (adr >= this_->ramSize)) { + result = 0xFF; + } else { + result = this_->ramBank[adr]; + } + this_->memPntr += 2; + if ((this_->startAddr + this_->memPntr) > this_->stopAddr) { + OPL_setStatus(this_->y8950, STATUS_EOS); + } + break; + } + case 0x13: // TODO check + result = this_->out & 0xFF; + break; + case 0x14: // TODO check + result = this_->out / 256; + break; + default: + result = 255; + } + //PRT_DEBUG("Y8950Adpcm: read "<<(int)rg<<" "<<(int)result); + return result; +} + +int ADPCM_calcSample(struct Y8950Adpcm* this_) +{ + // This table values are from ymdelta.c by Tatsuyuki Satoh. + static const int F1[16] = { 1, 3, 5, 7, 9, 11, 13, 15, + -1, -3, -5, -7, -9, -11, -13, -15}; + static const int F2[16] = {57, 57, 57, 57, 77, 102, 128, 153, + 57, 57, 57, 57, 77, 102, 128, 153}; + + if (ADPCM_muted(this_)) { + return 0; + } + this_->nowStep += this_->step; + if (this_->nowStep >= MAX_STEP) { + int nowLeveling; + do { + this_->nowStep -= MAX_STEP; + unsigned long val; + if (!(this_->playAddr & 1)) { + // n-th nibble + int tmp = this_->playAddr / 2; + if (this_->romBank || (tmp >= this_->ramSize)) { + this_->reg15 = 0xFF; + } else { + this_->reg15 = this_->ramBank[tmp]; + } + val = this_->reg15 >> 4; + } else { + // (n+1)-th nibble + val = this_->reg15 & 0x0F; + } + int prevOut = this_->out; + this_->out = CLAP(DECODE_MIN, this_->out + (this_->diff * F1[val]) / 8, + DECODE_MAX); + this_->diff = CLAP(DMIN, (this_->diff * F2[val]) / 64, DMAX); + int deltaNext = this_->out - prevOut; + nowLeveling = this_->nextLeveling; + this_->nextLeveling = prevOut + deltaNext / 2; + + this_->playAddr++; + if (this_->playAddr > this_->stopAddr) { + if (this_->reg7 & R07_REPEAT) { + restart(this_); + } else { + this_->playing = false; + //y8950.setStatus(Y8950::STATUS_EOS); + } + } + } while (this_->nowStep >= MAX_STEP); + this_->sampleStep = (this_->nextLeveling - nowLeveling) * this_->volumeWStep; + this_->output = nowLeveling * this_->volume; + + /* TODO: Used fixed point math here */ + #if !defined(ROCKBOX) + this_->output += (int)(((long long)this_->sampleStep * this_->nowStep) / this_->step); + #endif + } + this_->output += this_->sampleStep; + return this_->output >> 12; +} diff --git a/lib/rbcodec/codecs/libgme/emuadpcm.h b/lib/rbcodec/codecs/libgme/emuadpcm.h new file mode 100644 index 0000000000..0fc39a1709 --- /dev/null +++ b/lib/rbcodec/codecs/libgme/emuadpcm.h @@ -0,0 +1,52 @@ +#ifndef __Y8950ADPCM_HH__ +#define __Y8950ADPCM_HH__ + +#include "blargg_common.h" +#include "blargg_source.h" +#include "msxtypes.h" + +typedef unsigned short word; +typedef unsigned __int64 uint64; +struct Y8950; + +struct Y8950Adpcm +{ + struct Y8950* y8950; + + int sampleRate; + int clockRate; + + int ramSize; + int startAddr; + int stopAddr; + int playAddr; + int addrMask; + int memPntr; + bool romBank; + byte* ramBank; + + bool playing; + int volume; + word delta; + unsigned int nowStep, step; + int out, output; + int diff; + int nextLeveling; + int sampleStep; + int volumeWStep; + + byte reg7; + byte reg15; +}; + + +void ADPCM_init(struct Y8950Adpcm* this_, struct Y8950* y8950, byte* ramBank, int sampleRam); +void ADPCM_reset(struct Y8950Adpcm* this_); +void ADPCM_setSampleRate(struct Y8950Adpcm* this_, int sr, int clk); +bool ADPCM_muted(struct Y8950Adpcm* this_); +void ADPCM_writeReg(struct Y8950Adpcm* this_, byte rg, byte data); +byte ADPCM_readReg(struct Y8950Adpcm* this_, byte rg); +int ADPCM_calcSample(struct Y8950Adpcm* this_); + + +#endif diff --git a/lib/rbcodec/codecs/libgme/emutables.h b/lib/rbcodec/codecs/libgme/emutables.h new file mode 100644 index 0000000000..739c8c390a --- /dev/null +++ b/lib/rbcodec/codecs/libgme/emutables.h @@ -0,0 +1,210 @@ +#ifndef _EMUTABLES_H_ +#define _EMUTABLES_H_ + +/* Precalculated emu2413 tables for use in Rockbox, + Calculated for 44Khz sampling rate */ + +#include "emutypes.h" + +static const e_uint16 sin_coeff[] = { + 255, 203, 171, 152, 139, 129, 120, + 113, 107, 102, 97, 92, 88, 85, + 81, 78, 75, 72, 70, 67, 65, + 63, 61, 59, 57, 55, 53, 52, + 50, 48, 47, 45, 44, 43, 41, + 40, 39, 38, 37, 35, 34, 33, + 32, 31, 30, 29, 28, 28, 27, + 26, 25, 24, 23, 23, 22, 21, + 21, 20, 19, 19, 18, 17, 17, + 16, 16, 15, 14, 14, 13, 13, + 12, 12, 11, 11, 11, 10, 10, + 9, 9, 8, 8, 8, 7, 7, + 7, 6, 6, 6, 5, 5, 5, + 4, 4, 4, 4, 3, 3, 3, + 3, 2, 2, 2, 2, 2, 2, + 1, 1, 1, 1, 1, 1, 1, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, +}; + +static const e_int16 pm_coeff[] = { + 256, 256, 256, 256, 256, 256, 256, + 256, 256, 256, 256, 256, 256, 256, + 256, 256, 256, 256, 256, 256, 256, + 256, 256, 256, 256, 256, 256, 256, + 256, 256, 256, 256, 257, 257, 257, + 257, 257, 257, 257, 257, 257, 257, + 257, 257, 257, 257, 257, 257, 257, + 257, 257, 257, 257, 257, 257, 257, + 257, 257, 257, 257, 257, 257, 257, + 258, 258, 258, 257, 257, 257, 257, + 257, 257, 257, 257, 257, 257, 257, + 257, 257, 257, 257, 257, 257, 257, + 257, 257, 257, 257, 257, 257, 257, + 257, 257, 257, 257, 257, 257, 256, + 256, 256, 256, 256, 256, 256, 256, + 256, 256, 256, 256, 256, 256, 256, + 256, 256, 256, 256, 256, 256, 256, + 256, 256, 256, 256, 256, 256, 256, + 256, 256, 256, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 254, + 254, 254, 254, 254, 254, 254, 254, + 254, 254, 254, 254, 254, 254, 254, + 254, 254, 254, 254, 254, 254, 254, + 254, 254, 254, 254, 254, 254, 254, + 254, 254, 254, 253, 254, 254, 254, + 254, 254, 254, 254, 254, 254, 254, + 254, 254, 254, 254, 254, 254, 254, + 254, 254, 254, 254, 254, 254, 254, + 254, 254, 254, 254, 254, 254, 254, + 254, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, +}; + +static const e_int8 am_coeff[] = { + 13, 13, 13, 13, 13, 14, 14, + 14, 14, 14, 15, 15, 15, 15, + 15, 16, 16, 16, 16, 16, 17, + 17, 17, 17, 17, 18, 18, 18, + 18, 18, 19, 19, 19, 19, 19, + 20, 20, 20, 20, 20, 21, 21, + 21, 21, 21, 22, 22, 22, 22, + 22, 23, 23, 23, 23, 23, 24, + 24, 24, 24, 24, 25, 25, 25, + 25, 26, 25, 25, 25, 25, 24, + 24, 24, 24, 24, 23, 23, 23, + 23, 23, 22, 22, 22, 22, 22, + 21, 21, 21, 21, 21, 20, 20, + 20, 20, 20, 19, 19, 19, 19, + 19, 18, 18, 18, 18, 18, 17, + 17, 17, 17, 17, 16, 16, 16, + 16, 16, 15, 15, 15, 15, 15, + 14, 14, 14, 14, 14, 13, 13, + 13, 13, 13, 12, 12, 12, 12, + 11, 11, 11, 11, 11, 10, 10, + 10, 10, 10, 9, 9, 9, 9, + 9, 8, 8, 8, 8, 8, 7, + 7, 7, 7, 7, 6, 6, 6, + 6, 6, 5, 5, 5, 5, 5, + 4, 4, 4, 4, 4, 3, 3, + 3, 3, 3, 2, 2, 2, 2, + 2, 1, 1, 1, 1, 1, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 1, 1, 1, 1, 1, 2, + 2, 2, 2, 2, 3, 3, 3, + 3, 3, 4, 4, 4, 4, 4, + 5, 5, 5, 5, 5, 6, 6, + 6, 6, 6, 7, 7, 7, 7, + 7, 8, 8, 8, 8, 8, 9, + 9, 9, 9, 9, 10, 10, 10, + 10, 10, 11, 11, 11, 11, 11, + 12, 12, 12, 12, +}; + +static const e_int16 db2lin_coeff[] = { + 255, 249, 244, 239, 233, 228, 224, + 219, 214, 209, 205, 201, 196, 192, + 188, 184, 180, 176, 172, 169, 165, + 162, 158, 155, 151, 148, 145, 142, + 139, 136, 133, 130, 127, 125, 122, + 119, 117, 114, 112, 109, 107, 105, + 102, 100, 98, 96, 94, 92, 90, + 88, 86, 84, 82, 81, 79, 77, + 76, 74, 72, 71, 69, 68, 66, + 65, 64, 62, 61, 60, 58, 57, + 56, 55, 53, 52, 51, 50, 49, + 48, 47, 46, 45, 44, 43, 42, + 41, 40, 39, 38, 38, 37, 36, + 35, 34, 34, 33, 32, 32, 31, + 30, 30, 29, 28, 28, 27, 27, + 26, 25, 25, 24, 24, 23, 23, + 22, 22, 21, 21, 20, 20, 19, + 19, 19, 18, 18, 17, 17, 17, + 16, 16, 16, 15, 15, 15, 14, + 14, 14, 13, 13, 13, 12, 12, + 12, 12, 11, 11, 11, 11, 10, + 10, 10, 10, 10, 9, 9, 9, + 9, 8, 8, 8, 8, 8, 8, + 7, 7, 7, 7, 7, 7, 6, + 6, 6, 6, 6, 6, 6, 5, + 5, 5, 5, 5, 5, 5, 5, + 5, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, + 2, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, +}; + +static const e_uint16 ar_adjust_coeff[] = { + 127, 108, 98, 90, 84, 80, 75, + 72, 69, 66, 64, 61, 59, 57, + 56, 54, 52, 51, 49, 48, 47, + 45, 44, 43, 42, 41, 40, 39, + 38, 37, 36, 36, 35, 34, 33, + 33, 32, 31, 30, 30, 29, 29, + 28, 27, 27, 26, 26, 25, 24, + 24, 23, 23, 22, 22, 21, 21, + 21, 20, 20, 19, 19, 18, 18, + 17, 17, 17, 16, 16, 15, 15, + 15, 14, 14, 14, 13, 13, 13, + 12, 12, 12, 11, 11, 11, 10, + 10, 10, 9, 9, 9, 9, 8, + 8, 8, 7, 7, 7, 7, 6, + 6, 6, 6, 5, 5, 5, 4, + 4, 4, 4, 4, 3, 3, 3, + 3, 2, 2, 2, 2, 1, 1, + 1, 1, 1, 0, 0, 0, 0, + 0, +}; + +#endif diff --git a/lib/rbcodec/codecs/libgme/emutypes.h b/lib/rbcodec/codecs/libgme/emutypes.h new file mode 100644 index 0000000000..bc523db072 --- /dev/null +++ b/lib/rbcodec/codecs/libgme/emutypes.h @@ -0,0 +1,41 @@ +#ifndef _EMUTYPES_H_ +#define _EMUTYPES_H_ + +#if defined(_MSC_VER) +#define INLINE __forceinline +#elif defined(__GNUC__) +#define INLINE __inline__ +#elif defined(_MWERKS_) +#define INLINE inline +#else +#define INLINE +#endif + +#if defined(EMU_DLL_IMPORTS) +#define EMU2149_DLL_IMPORTS +#define EMU2212_DLL_IMPORTS +#define EMU2413_DLL_IMPORTS +#define EMU8950_DLL_IMPORTS +#define EMU76489_DLL_IMPORTS +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +typedef unsigned int e_uint; +typedef signed int e_int; + +typedef unsigned char e_uint8 ; +typedef signed char e_int8 ; + +typedef unsigned short e_uint16 ; +typedef signed short e_int16 ; + +typedef unsigned int e_uint32 ; +typedef signed int e_int32 ; + +#ifdef __cplusplus +} +#endif +#endif diff --git a/lib/rbcodec/codecs/libgme/gb_apu.c b/lib/rbcodec/codecs/libgme/gb_apu.c new file mode 100644 index 0000000000..e8bf3afcf5 --- /dev/null +++ b/lib/rbcodec/codecs/libgme/gb_apu.c @@ -0,0 +1,410 @@ +// Gb_Snd_Emu 0.1.4. http://www.slack.net/~ant/ + +#include "gb_apu.h" + +//#include "gb_apu_logger.h" + +/* Copyright (C) 2003-2008 Shay Green. This module is free software; you +can redistribute it and/or modify it under the terms of the GNU Lesser +General Public License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. This +module is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +details. You should have received a copy of the GNU Lesser General Public +License along with this module; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ + +#include "blargg_source.h" + +int const vol_reg = 0xFF24; +int const stereo_reg = 0xFF25; +int const status_reg = 0xFF26; +int const wave_ram = 0xFF30; + +int const power_mask = 0x80; + +static inline int calc_output( struct Gb_Apu* this, int osc ) +{ + int bits = this->regs [stereo_reg - io_addr] >> osc; + return (bits >> 3 & 2) | (bits & 1); +} + +void Apu_set_output( struct Gb_Apu* this, int i, struct Blip_Buffer* center, struct Blip_Buffer* left, struct Blip_Buffer* right ) +{ + // Must be silent (all NULL), mono (left and right NULL), or stereo (none NULL) + require( !center || (center && !left && !right) || (center && left && right) ); + require( (unsigned) i < osc_count ); // fails if you pass invalid osc index + + if ( !center || !left || !right ) + { + left = center; + right = center; + } + + struct Gb_Osc* o = this->oscs [i]; + o->outputs [1] = right; + o->outputs [2] = left; + o->outputs [3] = center; + o->output = o->outputs [calc_output( this, i )]; +} + +static void synth_volume( struct Gb_Apu* this, int iv ) +{ + int v = (this->volume_ * 6) / 10 / osc_count / 15 /*steps*/ / 8 /*master vol range*/ * iv; + Synth_volume( &this->synth, v ); +} + +static void apply_volume( struct Gb_Apu* this ) +{ + // TODO: Doesn't handle differing left and right volumes (panning). + // Not worth the complexity. + int data = this->regs [vol_reg - io_addr]; + int left = data >> 4 & 7; + int right = data & 7; + //if ( data & 0x88 ) dprintf( "Vin: %02X\n", data & 0x88 ); + //if ( left != right ) dprintf( "l: %d r: %d\n", left, right ); + synth_volume( this, max( left, right ) + 1 ); +} + +void Apu_volume( struct Gb_Apu* this, int v ) +{ + if ( this->volume_ != v ) + { + this->volume_ = v; + apply_volume( this ); + } +} + +static void reset_regs( struct Gb_Apu* this ) +{ + int i; + for ( i = 0; i < 0x20; i++ ) + this->regs [i] = 0; + + Sweep_reset ( &this->square1 ); + Square_reset( &this->square2 ); + Wave_reset ( &this->wave ); + Noise_reset ( &this->noise ); + + apply_volume( this ); +} + +static void reset_lengths( struct Gb_Apu* this ) +{ + this->square1.osc.length_ctr = 64; + this->square2.osc.length_ctr = 64; + this->wave .osc.length_ctr = 256; + this->noise .osc.length_ctr = 64; +} + +void Apu_reduce_clicks( struct Gb_Apu* this, bool reduce ) +{ + this->reduce_clicks_ = reduce; + + // Click reduction makes DAC off generate same output as volume 0 + int dac_off_amp = 0; + if ( reduce && this->wave.osc.mode != mode_agb ) // AGB already eliminates clicks + dac_off_amp = -dac_bias; + + int i; + for ( i = 0; i < osc_count; i++ ) + this->oscs [i]->dac_off_amp = dac_off_amp; + + // AGB always eliminates clicks on wave channel using same method + if ( this->wave.osc.mode == mode_agb ) + this->wave.osc.dac_off_amp = -dac_bias; +} + +void Apu_reset( struct Gb_Apu* this, enum gb_mode_t mode, bool agb_wave ) +{ + // Hardware mode + if ( agb_wave ) + mode = mode_agb; // using AGB wave features implies AGB hardware + this->wave.agb_mask = agb_wave ? 0xFF : 0; + int i; + for ( i = 0; i < osc_count; i++ ) + this->oscs [i]->mode = mode; + Apu_reduce_clicks( this, this->reduce_clicks_ ); + + // Reset state + this->frame_time = 0; + this->last_time = 0; + this->frame_phase = 0; + + reset_regs( this ); + reset_lengths( this ); + + // Load initial wave RAM + static byte const initial_wave [2] [16] = { + {0x84,0x40,0x43,0xAA,0x2D,0x78,0x92,0x3C,0x60,0x59,0x59,0xB0,0x34,0xB8,0x2E,0xDA}, + {0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF}, + }; + int b; + for ( b = 2; --b >= 0; ) + { + // Init both banks (does nothing if not in AGB mode) + // TODO: verify that this works + Apu_write_register( this, 0, 0xFF1A, b * 0x40 ); + unsigned i; + for ( i = 0; i < sizeof initial_wave [0]; i++ ) + Apu_write_register( this, 0, i + wave_ram, initial_wave [(mode != mode_dmg)] [i] ); + } +} + +void Apu_set_tempo( struct Gb_Apu* this, int t ) +{ + this->frame_period = 4194304 / 512; // 512 Hz + if ( t != (int)FP_ONE_TEMPO ) + this->frame_period = t ? (blip_time_t) ((this->frame_period * FP_ONE_TEMPO) / t) : (blip_time_t) (0); +} + +void Apu_init( struct Gb_Apu* this ) +{ + this->wave.wave_ram = &this->regs [wave_ram - io_addr]; + + Synth_init( &this->synth ); + + this->oscs [0] = &this->square1.osc; + this->oscs [1] = &this->square2.osc; + this->oscs [2] = &this->wave.osc; + this->oscs [3] = &this->noise.osc; + + int i; + for ( i = osc_count; --i >= 0; ) + { + struct Gb_Osc* o = this->oscs [i]; + o->regs = &this->regs [i * 5]; + o->output = NULL; + o->outputs [0] = NULL; + o->outputs [1] = NULL; + o->outputs [2] = NULL; + o->outputs [3] = NULL; + o->synth = &this->synth; + } + + this->reduce_clicks_ = false; + Apu_set_tempo( this, (int)FP_ONE_TEMPO ); + this->volume_ = (int)FP_ONE_VOLUME; + Apu_reset( this, mode_cgb, false ); +} + +static void run_until_( struct Gb_Apu* this, blip_time_t end_time ) +{ + if ( !this->frame_period ) + this->frame_time += end_time - this->last_time; + + while ( true ) + { + // run oscillators + blip_time_t time = end_time; + if ( time > this->frame_time ) + time = this->frame_time; + + Square_run( &this->square1, this->last_time, time ); + Square_run( &this->square2, this->last_time, time ); + Wave_run ( &this->wave, this->last_time, time ); + Noise_run ( &this->noise, this->last_time, time ); + this->last_time = time; + + if ( time == end_time ) + break; + + // run frame sequencer + assert( this->frame_period ); + this->frame_time += this->frame_period * clk_mul; + switch ( this->frame_phase++ ) + { + case 2: + case 6: + // 128 Hz + clock_sweep( &this->square1 ); + case 0: + case 4: + // 256 Hz + Osc_clock_length( &this->square1.osc ); + Osc_clock_length( &this->square2.osc); + Osc_clock_length( &this->wave.osc); + Osc_clock_length( &this->noise.osc); + break; + + case 7: + // 64 Hz + this->frame_phase = 0; + Square_clock_envelope( &this->square1 ); + Square_clock_envelope( &this->square2 ); + Noise_clock_envelope( &this->noise ); + } + } +} + +static inline void run_until( struct Gb_Apu* this, blip_time_t time ) +{ + require( time >= this->last_time ); // end_time must not be before previous time + if ( time > this->last_time ) + run_until_( this, time ); +} + +void Apu_end_frame( struct Gb_Apu* this, blip_time_t end_time ) +{ + #ifdef LOG_FRAME + LOG_FRAME( end_time ); + #endif + + if ( end_time > this->last_time ) + run_until( this, end_time ); + + this->frame_time -= end_time; + assert( this->frame_time >= 0 ); + + this->last_time -= end_time; + assert( this->last_time >= 0 ); +} + +static void silence_osc( struct Gb_Apu* this, struct Gb_Osc* o ) +{ + int delta = -o->last_amp; + if ( this->reduce_clicks_ ) + delta += o->dac_off_amp; + + if ( delta ) + { + o->last_amp = o->dac_off_amp; + if ( o->output ) + { + Blip_set_modified( o->output ); + Synth_offset( &this->synth, this->last_time, delta, o->output ); + } + } +} + +static void apply_stereo( struct Gb_Apu* this ) +{ + int i; + for ( i = osc_count; --i >= 0; ) + { + struct Gb_Osc* o = this->oscs [i]; + struct Blip_Buffer* out = o->outputs [calc_output( this, i )]; + if ( o->output != out ) + { + silence_osc( this, o ); + o->output = out; + } + } +} + +void Apu_write_register( struct Gb_Apu* this, blip_time_t time, int addr, int data ) +{ + require( (unsigned) data < 0x100 ); + + int reg = addr - io_addr; + if ( (unsigned) reg >= io_size ) + { + require( false ); + return; + } + + #ifdef LOG_WRITE + LOG_WRITE( time, addr, data ); + #endif + + if ( addr < status_reg && !(this->regs [status_reg - io_addr] & power_mask) ) + { + // Power is off + + // length counters can only be written in DMG mode + if ( this->wave.osc.mode != mode_dmg || (reg != 1 && reg != 5+1 && reg != 10+1 && reg != 15+1) ) + return; + + if ( reg < 10 ) + data &= 0x3F; // clear square duty + } + + run_until( this, time ); + + if ( addr >= wave_ram ) + { + Wave_write( &this->wave, addr, data ); + } + else + { + int old_data = this->regs [reg]; + this->regs [reg] = data; + + if ( addr < vol_reg ) + { + // Oscillator + write_osc( this, reg, old_data, data ); + } + else if ( addr == vol_reg && data != old_data ) + { + // Master volume + int i; + for ( i = osc_count; --i >= 0; ) + silence_osc( this, this->oscs [i] ); + + apply_volume( this ); + } + else if ( addr == stereo_reg ) + { + // Stereo panning + apply_stereo( this ); + } + else if ( addr == status_reg && (data ^ old_data) & power_mask ) + { + // Power control + this->frame_phase = 0; + int i; + for ( i = osc_count; --i >= 0; ) + silence_osc( this, this->oscs [i] ); + + reset_regs( this ); + if ( this->wave.osc.mode != mode_dmg ) + reset_lengths( this ); + + this->regs [status_reg - io_addr] = data; + } + } +} + +int Apu_read_register( struct Gb_Apu* this, blip_time_t time, int addr ) +{ + if ( addr >= status_reg ) + run_until( this, time ); + + int reg = addr - io_addr; + if ( (unsigned) reg >= io_size ) + { + require( false ); + return 0; + } + + if ( addr >= wave_ram ) + return Wave_read( &this->wave, addr ); + + // Value read back has some bits always set + static byte const masks [] = { + 0x80,0x3F,0x00,0xFF,0xBF, + 0xFF,0x3F,0x00,0xFF,0xBF, + 0x7F,0xFF,0x9F,0xFF,0xBF, + 0xFF,0xFF,0x00,0x00,0xBF, + 0x00,0x00,0x70, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF + }; + int mask = masks [reg]; + if ( this->wave.agb_mask && (reg == 10 || reg == 12) ) + mask = 0x1F; // extra implemented bits in wave regs on AGB + int data = this->regs [reg] | mask; + + // Status register + if ( addr == status_reg ) + { + data &= 0xF0; + data |= (int) this->square1.osc.enabled << 0; + data |= (int) this->square2.osc.enabled << 1; + data |= (int) this->wave .osc.enabled << 2; + data |= (int) this->noise .osc.enabled << 3; + } + + return data; +} diff --git a/lib/rbcodec/codecs/libgme/gb_apu.h b/lib/rbcodec/codecs/libgme/gb_apu.h new file mode 100644 index 0000000000..69307b9840 --- /dev/null +++ b/lib/rbcodec/codecs/libgme/gb_apu.h @@ -0,0 +1,85 @@ +// Nintendo Game Boy sound hardware emulator with save state support + +// Gb_Snd_Emu 0.1.4 +#ifndef GB_APU_H +#define GB_APU_H + +#include "gb_oscs.h" + +// Clock rate sound hardware runs at +enum { clock_rate = 4194304 * GB_APU_OVERCLOCK }; + +// Registers are at io_addr to io_addr+io_size-1 +enum { io_addr = 0xFF10 }; +enum { io_size = 0x30 }; +enum { regs_size = io_size + 0x10 }; + +enum gb_mode_t { + mode_dmg, // Game Boy monochrome + mode_cgb, // Game Boy Color + mode_agb // Game Boy Advance +}; + +// 0: Square 1, 1: Square 2, 2: Wave, 3: Noise +enum { osc_count = 4 }; // 0 <= chan < osc_count + +struct Gb_Apu { + struct Gb_Osc* oscs [osc_count]; + blip_time_t last_time; // time sound emulator has been run to + blip_time_t frame_period; // clocks between each frame sequencer step + int volume_; + bool reduce_clicks_; + + struct Gb_Square square1; + struct Gb_Square square2; + struct Gb_Wave wave; + struct Gb_Noise noise; + blip_time_t frame_time; // time of next frame sequencer action + int frame_phase; // phase of next frame sequencer step + + uint8_t regs [regs_size];// last values written to registers + + // large objects after everything else + struct Blip_Synth synth; +}; + +// Basics + +// Initializes apu +void Apu_init( struct Gb_Apu* this ); + +// Emulates to time t, then writes data to addr +void Apu_write_register( struct Gb_Apu* this, blip_time_t t, int addr, int data ); + +// Emulates to time t, then subtracts t from the current time. +// OK if previous write call had time slightly after t. +void Apu_end_frame( struct Gb_Apu* this,blip_time_t t ); + +// More features + +// Emulates to time t, then reads from addr +int Apu_read_register( struct Gb_Apu* this, blip_time_t t, int addr ); + +// Resets hardware to state after power, BEFORE boot ROM runs. Mode selects +// sound hardware. If agb_wave is true, enables AGB's extra wave features. +void Apu_reset( struct Gb_Apu* this, enum gb_mode_t mode, bool agb_wave ); + +// Same as set_output(), but for a particular channel +void Apu_set_output( struct Gb_Apu* this, int chan, struct Blip_Buffer* center, + struct Blip_Buffer* left, struct Blip_Buffer* right ); + +// Sets overall volume, where 1.0 is normal +void Apu_volume( struct Gb_Apu* this, int v ); + +// If true, reduces clicking by disabling DAC biasing. Note that this reduces +// emulation accuracy, since the clicks are authentic. +void Apu_reduce_clicks( struct Gb_Apu* this, bool reduce ); + +// Sets frame sequencer rate, where 1.0 is normal. Meant for adjusting the +// tempo in a music player. +void Apu_set_tempo( struct Gb_Apu* this, int t ); + + +void write_osc( struct Gb_Apu* this, int reg, int old_data, int data ); + +#endif diff --git a/lib/rbcodec/codecs/libgme/gb_cpu.c b/lib/rbcodec/codecs/libgme/gb_cpu.c new file mode 100644 index 0000000000..4b2df63a17 --- /dev/null +++ b/lib/rbcodec/codecs/libgme/gb_cpu.c @@ -0,0 +1,53 @@ +// Game_Music_Emu 0.6-pre. http://www.slack.net/~ant/ + +#include "gb_cpu.h" + +#include "blargg_endian.h" + +/* Copyright (C) 2003-2008 Shay Green. This module is free software; you +can redistribute it and/or modify it under the terms of the GNU Lesser +General Public License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. This +module is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +details. You should have received a copy of the GNU Lesser General Public +License along with this module; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ + +#include "blargg_source.h" + +static inline void set_code_page( struct Gb_Cpu* this, int i, void* p ) +{ + byte* p2 = STATIC_CAST(byte*,p) - GB_CPU_OFFSET( i * page_size ); + this->cpu_state_.code_map [i] = p2; + this->cpu_state->code_map [i] = p2; +} + +void Cpu_reset( struct Gb_Cpu* this, void* unmapped ) +{ + check( this->cpu_state == &this->cpu_state_ ); + this->cpu_state = &this->cpu_state_; + + this->cpu_state_.time = 0; + + int i; + for ( i = 0; i < page_count + 1; ++i ) + set_code_page( this, i, unmapped ); + + memset( &this->r, 0, sizeof this->r ); + + blargg_verify_byte_order(); +} + +void Cpu_map_code( struct Gb_Cpu* this, addr_t start, int size, void* data ) +{ + // address range must begin and end on page boundaries + require( start % page_size == 0 ); + require( size % page_size == 0 ); + require( start + size <= mem_size ); + + int offset; + for ( offset = 0; offset < size; offset += page_size ) + set_code_page( this, (start + offset) >> page_bits, STATIC_CAST(char*,data) + offset ); +} diff --git a/lib/rbcodec/codecs/libgme/gb_cpu.h b/lib/rbcodec/codecs/libgme/gb_cpu.h new file mode 100644 index 0000000000..37b22141d7 --- /dev/null +++ b/lib/rbcodec/codecs/libgme/gb_cpu.h @@ -0,0 +1,80 @@ +// Nintendo Game Boy CPU emulator + +// Game_Music_Emu 0.6-pre +#ifndef GB_CPU_H +#define GB_CPU_H + +#include "blargg_common.h" +#include "blargg_source.h" + +typedef int addr_t; + +// Emulator reads this many bytes past end of a page +enum { cpu_padding = 8 }; +enum { mem_size = 0x10000 }; +enum { page_bits = 13 }; +enum { page_size = 1 << page_bits }; +enum { page_count = mem_size >> page_bits }; + +// Game Boy Z-80 registers. NOT kept updated during emulation. +struct core_regs_t { + uint16_t bc, de, hl, fa; +}; + +struct registers_t { + int pc; // more than 16 bits to allow overflow detection + uint16_t sp; + + struct core_regs_t rp; +}; + +struct cpu_state_t { + byte* code_map [page_count + 1]; + int time; +}; + +struct Gb_Cpu { + // Base address for RST vectors, to simplify GBS player (normally 0) + addr_t rst_base; + + struct registers_t r; + struct cpu_state_t* cpu_state; // points to state_ or a local copy within run() + struct cpu_state_t cpu_state_; +}; + +// Initializes Gb cpu +static inline void Cpu_init( struct Gb_Cpu* this ) +{ + this->rst_base = 0; + this->cpu_state = &this->cpu_state_; +} + +// Clears registers and map all pages to unmapped +void Cpu_reset( struct Gb_Cpu* this, void* unmapped ); + +// Maps code memory (memory accessed via the program counter). Start and size +// must be multiple of page_size. +void Cpu_map_code( struct Gb_Cpu* this, addr_t start, int size, void* code ); + +// Current time. +static inline int Cpu_time( struct Gb_Cpu* this ) { return this->cpu_state->time; } + +// Changes time. Must not be called during emulation. +// Should be negative, because emulation stops once it becomes >= 0. +static inline void Cpu_set_time( struct Gb_Cpu* this, int t ) { this->cpu_state->time = t; } + +#define GB_CPU_PAGE( addr ) ((unsigned) (addr) >> page_bits) + +#ifdef BLARGG_NONPORTABLE + #define GB_CPU_OFFSET( addr ) (addr) +#else + #define GB_CPU_OFFSET( addr ) ((addr) & (page_size - 1)) +#endif + +// Accesses emulated memory as CPU does +static inline uint8_t* Cpu_get_code( struct Gb_Cpu* this, addr_t addr ) +{ + return this->cpu_state_.code_map [GB_CPU_PAGE( addr )] + GB_CPU_OFFSET( addr ); +} + +#endif diff --git a/lib/rbcodec/codecs/libgme/gb_cpu_run.h b/lib/rbcodec/codecs/libgme/gb_cpu_run.h new file mode 100644 index 0000000000..1ea8b59249 --- /dev/null +++ b/lib/rbcodec/codecs/libgme/gb_cpu_run.h @@ -0,0 +1,1187 @@ +// Game_Music_Emu 0.6-pre. http://www.slack.net/~ant/ + +#if 0 +/* Define these macros in the source file before #including this file. +- Parameters might be expressions, so they are best evaluated only once, +though they NEVER have side-effects, so multiple evaluation is OK. +- Output parameters might be a multiple-assignment expression like "a=x", +so they must NOT be parenthesized. +- Macros "returning" void may use a {} statement block. */ + + // 0 <= addr <= 0xFFFF + page_size + // time functions can be used + int READ_MEM( addr_t ); + void WRITE_MEM( addr_t, int data ); + + // Access of 0xFF00 + offset + // 0 <= offset <= 0xFF + int READ_IO( int offset ); + void WRITE_IO( int offset, int data ); + + // Often-used instructions use this instead of READ_MEM + void READ_FAST( addr_t, int& out ); + +// The following can be used within macros: + + // Current time + cpu_time_t TIME(); +#endif + +/* Copyright (C) 2003-2009 Shay Green. This module is free software; you +can redistribute it and/or modify it under the terms of the GNU Lesser +General Public License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. This +module is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +details. You should have received a copy of the GNU Lesser General Public +License along with this module; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ + +// Common instructions: +// +// 365880 FA LD A,(nn) +// 355863 20 JR NZ +// 313655 21 LD HL,nn +// 274580 28 JR Z +// 252878 FE CP n +// 230541 7E LD A,(HL) +// 226209 2A LD A,(HL+) +// 217467 CD CALL +// 212034 C9 RET +// 208376 CB CB prefix +// +// 27486 CB 7E BIT 7,(HL) +// 15925 CB 76 BIT 6,(HL) +// 13035 CB 19 RR C +// 11557 CB 7F BIT 7,A +// 10898 CB 37 SWAP A +// 10208 CB 66 BIT 4,(HL) + +// Allows MWCW debugger to step through code properly +#ifdef CPU_BEGIN + CPU_BEGIN +#endif + +#define TIME() s.time + +#define CODE_PAGE( addr ) s.code_map [GB_CPU_PAGE( addr )] +#define READ_CODE( addr ) (CODE_PAGE( addr ) [GB_CPU_OFFSET( addr )]) + +// Flags with hex value for clarity when used as mask. +// Stored in indicated variable during emulation. +int const z80 = 0x80; // cz +int const n40 = 0x40; // ph +int const h20 = 0x20; // ph +int const c10 = 0x10; // cz + +#define SET_FLAGS( in )\ +{\ + cz = ((in) << 4 & 0x100) + (~(in) >> 7 & 1);\ + ph = (~(in) << 2 & 0x100) + ((in) >> 1 & 0x10);\ +} + +// random bits in cz to catch misuse of them +#define SET_FLAGS_DEBUG( in )\ +{\ + cz = ((in) << 4 & 0x100) | (rand() & ~0x1FF) | ((in) & 0x80 ? 0 : (rand() & 0xFF) | 1);\ + ph = (~(in) << 2 & 0x100) | (((in) >> 1 & 0x10) ^ BYTE( cz ));\ +} + +#define GET_FLAGS( out )\ +{\ + out = (cz >> 4 & c10);\ + out += ~ph >> 2 & n40;\ + out += (ph ^ cz) << 1 & h20;\ + if ( !BYTE( cz ) )\ + out += z80;\ +} + +#define CC_NZ() ( BYTE( cz )) +#define CC_Z() (!BYTE( cz )) +#define CC_NC() (!(cz & 0x100)) +#define CC_C() ( cz & 0x100 ) + +// Truncation +#define BYTE( n ) ((uint8_t ) (n)) /* (unsigned) n & 0xFF */ +#define SBYTE( n ) ((int8_t ) (n)) /* (BYTE( n ) ^ 0x80) - 0x80 */ +#define WORD( n ) ((uint16_t) (n)) /* (unsigned) n & 0xFFFF */ + +{ + struct cpu_state_t s; + cpu->cpu_state = &s; + memcpy( &s, &cpu->cpu_state_, sizeof s ); + + union { + struct { + #ifdef BLARGG_BIG_ENDIAN + byte b, c, d, e, h, l, flags, a; + #else + byte c, b, e, d, l, h, a, flags; + #endif + } rg; // individual registers + struct core_regs_t rp; // pairs + + byte r8_ [8]; // indexed registers (use R8 macro due to endian dependence) + uint16_t r16 [4]; // indexed pairs + } reg; + BOOST_STATIC_ASSERT( sizeof reg.rg == 8 && sizeof reg.rp == 8 ); + + #ifdef BLARGG_BIG_ENDIAN + #define R8( n ) (reg.r8_ [n]) + #elif BLARGG_LITTLE_ENDIAN + #define R8( n ) (reg.r8_ [(n) ^ 1]) + #else + // Be sure "blargg_endian.h" has been #included in the file that #includes this + #error "Byte order of CPU must be known" + #endif + + #define R16( n ) (reg.r16 [n]) + #define RG (reg.rg) + #define RP (reg.rp) + + RP = cpu->r.rp; + int pc = cpu->r.pc; + int sp = cpu->r.sp; + int ph; + int cz; + SET_FLAGS( RG.flags ); + + int time = s.time; + +loop: + + check( (unsigned) pc < 0x10000 + 1 ); // +1 so emulator can catch wrap-around + check( (unsigned) sp < 0x10000 ); + + byte const* instr = CODE_PAGE( pc ); + int op; + + if ( GB_CPU_OFFSET(~0) == ~0 ) + { + op = instr [pc]; + pc++; + instr += pc; + } + else + { + instr += GB_CPU_OFFSET( pc ); + op = *instr++; + pc++; + } + +#define GET_ADDR() GET_LE16( instr ) + + static byte const instr_times [256*2] = { + // 0 1 2 3 4 5 6 7 8 9 A B C D E F + 4,12, 8, 8, 4, 4, 8, 4,20, 8, 8, 8, 4, 4, 8, 4,// 0 + 4,12, 8, 8, 4, 4, 8, 4,12, 8, 8, 8, 4, 4, 8, 4,// 1 + 8,12, 8, 8, 4, 4, 8, 4, 8, 8, 8, 8, 4, 4, 8, 4,// 2 + 8,12, 8, 8,12,12,12, 4, 8, 8, 8, 8, 4, 4, 8, 4,// 3 + 4, 4, 4, 4, 4, 4, 8, 4, 4, 4, 4, 4, 4, 4, 8, 4,// 4 + 4, 4, 4, 4, 4, 4, 8, 4, 4, 4, 4, 4, 4, 4, 8, 4,// 5 + 4, 4, 4, 4, 4, 4, 8, 4, 4, 4, 4, 4, 4, 4, 8, 4,// 6 + 8, 8, 8, 8, 8, 8, 0, 8, 4, 4, 4, 4, 4, 4, 8, 4,// 7 + 4, 4, 4, 4, 4, 4, 8, 4, 4, 4, 4, 4, 4, 4, 8, 4,// 8 + 4, 4, 4, 4, 4, 4, 8, 4, 4, 4, 4, 4, 4, 4, 8, 4,// 9 + 4, 4, 4, 4, 4, 4, 8, 4, 4, 4, 4, 4, 4, 4, 8, 4,// A + 4, 4, 4, 4, 4, 4, 8, 4, 4, 4, 4, 4, 4, 4, 8, 4,// B + 8,12,16,16,12,16, 8,16, 8,16,16, 0,12,24, 8,16,// C + 8,12,16, 0,12,16, 8,16, 8,16,16, 0,12, 0, 8,16,// D + 12,12, 8, 0, 0,16, 8,16,16, 4,16, 0, 0, 0, 8,16,// E + 12,12, 8, 4, 0,16, 8,16,12, 8,16, 4, 0, 0, 8,16,// F + + // CB prefixed + // 0 1 2 3 4 5 6 7 8 9 A B C D E F + 8, 8, 8, 8, 8, 8,16, 8, 8, 8, 8, 8, 8, 8,16, 8,// 0 + 8, 8, 8, 8, 8, 8,16, 8, 8, 8, 8, 8, 8, 8,16, 8,// 1 + 8, 8, 8, 8, 8, 8,16, 8, 8, 8, 8, 8, 8, 8,16, 8,// 2 + 8, 8, 8, 8, 8, 8,16, 8, 8, 8, 8, 8, 8, 8,16, 8,// 3 + 8, 8, 8, 8, 8, 8,12, 8, 8, 8, 8, 8, 8, 8,12, 8,// 4 + 8, 8, 8, 8, 8, 8,12, 8, 8, 8, 8, 8, 8, 8,12, 8,// 5 + 8, 8, 8, 8, 8, 8,12, 8, 8, 8, 8, 8, 8, 8,12, 8,// 6 + 8, 8, 8, 8, 8, 8,12, 8, 8, 8, 8, 8, 8, 8,12, 8,// 7 + 8, 8, 8, 8, 8, 8,16, 8, 8, 8, 8, 8, 8, 8,16, 8,// 8 + 8, 8, 8, 8, 8, 8,16, 8, 8, 8, 8, 8, 8, 8,16, 8,// 9 + 8, 8, 8, 8, 8, 8,16, 8, 8, 8, 8, 8, 8, 8,16, 8,// A + 8, 8, 8, 8, 8, 8,16, 8, 8, 8, 8, 8, 8, 8,16, 8,// B + 8, 8, 8, 8, 8, 8,16, 8, 8, 8, 8, 8, 8, 8,16, 8,// C + 8, 8, 8, 8, 8, 8,16, 8, 8, 8, 8, 8, 8, 8,16, 8,// D + 8, 8, 8, 8, 8, 8,16, 8, 8, 8, 8, 8, 8, 8,16, 8,// E + 8, 8, 8, 8, 8, 8,16, 8, 8, 8, 8, 8, 8, 8,16, 8,// F + }; + + if ( time >= 0 ) + goto stop; + + time += instr_times [op]; + + int data; + data = *instr; + s.time = time; + + #ifdef CPU_INSTR_HOOK + { CPU_INSTR_HOOK( (pc-1), (instr-1), rg.a, rp.bc, rp.de, rp.hl, sp ); } + #endif + + switch ( op ) + { + +// TODO: more efficient way to handle negative branch that wraps PC around +#define BRANCH_( cond, clocks )\ +{\ + pc++;\ + if ( !(cond) )\ + goto loop;\ + pc = WORD( pc + SBYTE( data ) );\ + time += clocks;\ + goto loop;\ +} + +#define BRANCH( cond ) BRANCH_( cond, 4 ) + +// Most Common + + case 0x20: // JR NZ + BRANCH( CC_NZ() ) + + case 0x21: // LD HL,IMM (common) + RP.hl = GET_ADDR(); + pc += 2; + goto loop; + + case 0x28: // JR Z + BRANCH( CC_Z() ) + + case 0xF2: // LD A,(0xFF00+C) + READ_IO( this, RG.c, RG.a ); + goto loop; + + case 0xF0: // LD A,(0xFF00+imm) + pc++; + READ_IO( this, data, RG.a ); + goto loop; + + { + int temp; + case 0x0A: // LD A,(BC) + temp = RP.bc; + goto ld_a_ind_comm; + + case 0x3A: // LD A,(HL-) + temp = RP.hl; + RP.hl = temp - 1; + goto ld_a_ind_comm; + + case 0x1A: // LD A,(DE) + temp = RP.de; + goto ld_a_ind_comm; + + case 0x2A: // LD A,(HL+) (common) + temp = RP.hl; + RP.hl = temp + 1; + goto ld_a_ind_comm; + + case 0xFA: // LD A,IND16 (common) + temp = GET_ADDR(); + pc += 2; + ld_a_ind_comm: + READ_FAST( this, temp, RG.a ); + goto loop; + } + + { + int temp; + case 0xBE: // CP (HL) + temp = READ_MEM( this, RP.hl ); + goto cmp_comm; + + case 0xB8: // CP B + case 0xB9: // CP C + case 0xBA: // CP D + case 0xBB: // CP E + case 0xBC: // CP H + case 0xBD: // CP L + case 0xBF: // CP A + temp = R8( op & 7 ); + cmp_comm: + ph = RG.a ^ temp; // N=1 H=* + cz = RG.a - temp; // C=* Z=* + goto loop; + } + + case 0xFE: // CP IMM + pc++; + ph = RG.a ^ data; // N=1 H=* + cz = RG.a - data; // C=* Z=* + goto loop; + + case 0x46: // LD B,(HL) + case 0x4E: // LD C,(HL) + case 0x56: // LD D,(HL) + case 0x5E: // LD E,(HL) + case 0x66: // LD H,(HL) + case 0x6E: // LD L,(HL) + case 0x7E:{// LD A,(HL) + int addr = RP.hl; + READ_FAST( this, addr, R8( op >> 3 & 7 ) ); + goto loop; + } + + case 0xC4: // CNZ (next-most-common) + pc += 2; + if ( CC_Z() ) + goto loop; + call: + time += 12; + pc -= 2; + case 0xCD: // CALL (most-common) + data = pc + 2; + pc = GET_ADDR(); + push: { + int addr = WORD( sp - 1 ); + WRITE_MEM( this, addr, (data >> 8) ); + sp = WORD( sp - 2 ); + WRITE_MEM( this, sp, data ); + goto loop; + } + + case 0xC8: // RET Z (next-most-common) + if ( CC_NZ() ) + goto loop; + ret: + time += 12; + case 0xD9: // RETI + case 0xC9:{// RET (most common) + pc = READ_MEM( this, sp ); + int addr = sp + 1; + sp = WORD( sp + 2 ); + pc += 0x100 * READ_MEM( this, addr ); + goto loop; + } + + case 0x00: // NOP + case 0x40: // LD B,B + case 0x49: // LD C,C + case 0x52: // LD D,D + case 0x5B: // LD E,E + case 0x64: // LD H,H + case 0x6D: // LD L,L + case 0x7F: // LD A,A + goto loop; + +// CB Instructions + + case 0xCB: + time += (instr_times + 256) [data]; + pc++; + // now data is the opcode + switch ( data ) { + + case 0x46: // BIT b,(HL) + case 0x4E: + case 0x56: + case 0x5E: + case 0x66: + case 0x6E: + case 0x76: + case 0x7E: { + int addr = RP.hl; + READ_FAST( this, addr, op ); + goto bit_comm; + } + + case 0x40: case 0x41: case 0x42: case 0x43: // BIT b,r + case 0x44: case 0x45: case 0x47: case 0x48: + case 0x49: case 0x4A: case 0x4B: case 0x4C: + case 0x4D: case 0x4F: case 0x50: case 0x51: + case 0x52: case 0x53: case 0x54: case 0x55: + case 0x57: case 0x58: case 0x59: case 0x5A: + case 0x5B: case 0x5C: case 0x5D: case 0x5F: + case 0x60: case 0x61: case 0x62: case 0x63: + case 0x64: case 0x65: case 0x67: case 0x68: + case 0x69: case 0x6A: case 0x6B: case 0x6C: + case 0x6D: case 0x6F: case 0x70: case 0x71: + case 0x72: case 0x73: case 0x74: case 0x75: + case 0x77: case 0x78: case 0x79: case 0x7A: + case 0x7B: case 0x7C: case 0x7D: case 0x7F: + op = R8( data & 7 ); + bit_comm: + ph = op >> (data >> 3 & 7) & 1; + cz = (cz & 0x100) + ph; + ph ^= 0x110; // N=0 H=1 + goto loop; + + case 0x86: // RES b,(HL) + case 0x8E: + case 0x96: + case 0x9E: + case 0xA6: + case 0xAE: + case 0xB6: + case 0xBE: { + int temp = READ_MEM( this, RP.hl ); + temp &= ~(1 << (data >> 3 & 7)); + WRITE_MEM( this, RP.hl, temp ); + goto loop; + } + + case 0xC6: // SET b,(HL) + case 0xCE: + case 0xD6: + case 0xDE: + case 0xE6: + case 0xEE: + case 0xF6: + case 0xFE: { + int temp = READ_MEM( this, RP.hl ); + temp |= 1 << (data >> 3 & 7); + WRITE_MEM( this, RP.hl, temp ); + goto loop; + } + + case 0xC0: case 0xC1: case 0xC2: case 0xC3: // SET b,r + case 0xC4: case 0xC5: case 0xC7: case 0xC8: + case 0xC9: case 0xCA: case 0xCB: case 0xCC: + case 0xCD: case 0xCF: case 0xD0: case 0xD1: + case 0xD2: case 0xD3: case 0xD4: case 0xD5: + case 0xD7: case 0xD8: case 0xD9: case 0xDA: + case 0xDB: case 0xDC: case 0xDD: case 0xDF: + case 0xE0: case 0xE1: case 0xE2: case 0xE3: + case 0xE4: case 0xE5: case 0xE7: case 0xE8: + case 0xE9: case 0xEA: case 0xEB: case 0xEC: + case 0xED: case 0xEF: case 0xF0: case 0xF1: + case 0xF2: case 0xF3: case 0xF4: case 0xF5: + case 0xF7: case 0xF8: case 0xF9: case 0xFA: + case 0xFB: case 0xFC: case 0xFD: case 0xFF: + R8( data & 7 ) |= 1 << (data >> 3 & 7); + goto loop; + + case 0x80: case 0x81: case 0x82: case 0x83: // RES b,r + case 0x84: case 0x85: case 0x87: case 0x88: + case 0x89: case 0x8A: case 0x8B: case 0x8C: + case 0x8D: case 0x8F: case 0x90: case 0x91: + case 0x92: case 0x93: case 0x94: case 0x95: + case 0x97: case 0x98: case 0x99: case 0x9A: + case 0x9B: case 0x9C: case 0x9D: case 0x9F: + case 0xA0: case 0xA1: case 0xA2: case 0xA3: + case 0xA4: case 0xA5: case 0xA7: case 0xA8: + case 0xA9: case 0xAA: case 0xAB: case 0xAC: + case 0xAD: case 0xAF: case 0xB0: case 0xB1: + case 0xB2: case 0xB3: case 0xB4: case 0xB5: + case 0xB7: case 0xB8: case 0xB9: case 0xBA: + case 0xBB: case 0xBC: case 0xBD: case 0xBF: + R8( data & 7 ) &= ~(1 << (data >> 3 & 7)); + goto loop; + + case 0x36: // SWAP (HL) + op = READ_MEM( this, RP.hl ); + goto swap_comm; + + case 0x30: // SWAP B + case 0x31: // SWAP C + case 0x32: // SWAP D + case 0x33: // SWAP E + case 0x34: // SWAP H + case 0x35: // SWAP L + case 0x37: // SWAP A + op = R8( data & 7 ); + swap_comm: + op = (op >> 4) + (op << 4); + cz = BYTE( op ); + ph = cz + 0x100; + if ( data == 0x36 ) + goto write_hl_op_ff; + R8( data & 7 ) = op; + goto loop; + +// Shift/Rotate + + case 0x26: // SLA (HL) + cz = 0; + case 0x16: // RL (HL) + cz = (cz >> 8 & 1) + (READ_MEM( this, RP.hl ) << 1); + goto rl_hl_common; + + case 0x06: // RLC (HL) + cz = READ_MEM( this, RP.hl ); + cz = (cz << 1) + (cz >> 7 & 1); + rl_hl_common: + // Z=* C=* + ph = cz | 0x100; // N=0 H=0 + WRITE_MEM( this, RP.hl, cz ); + goto loop; + + case 0x20: case 0x21: case 0x22: case 0x23: case 0x24: case 0x25: case 0x27: // SLA r + cz = 0; + case 0x10: case 0x11: case 0x12: case 0x13: case 0x14: case 0x15: case 0x17: // RL r + cz = (cz >> 8 & 1) + (R8( data & 7 ) << 1); + goto rl_common; + + case 0x00: case 0x01: case 0x02: case 0x03: case 0x04: case 0x05: case 0x07: // RLC r + cz = R8( data & 7 ); + cz = (cz << 1) + (cz >> 7 & 1); + rl_common: + // Z=* C=* + ph = cz | 0x100; // N=0 H=0 + R8( data & 7 ) = cz; + goto loop; + + case 0x0E: // RRC (HL) + cz = READ_MEM( this, RP.hl ); + cz += cz << 8 & 0x100; + goto rr_hl_common; + + case 0x2E: // SRA (HL) + cz = READ_MEM( this, RP.hl ); + cz += cz << 1 & 0x100; + goto rr_hl_common; + + case 0x3E: // SRL (HL) + cz = 0; + case 0x1E: // RR (HL) + cz = (cz & 0x100) + READ_MEM( this, RP.hl ); + rr_hl_common: + cz = (cz << 8) + (cz >> 1); // Z=* C=* + ph = cz | 0x100; // N=0 H=0 + WRITE_MEM( this, RP.hl, cz ); + goto loop; + + case 0x08: case 0x09: case 0x0A: case 0x0B: case 0x0C: case 0x0D: case 0x0F: // RRC r + cz = R8( data & 7 ); + cz += cz << 8 & 0x100; + goto rr_common; + + case 0x28: case 0x29: case 0x2A: case 0x2B: case 0x2C: case 0x2D: case 0x2F: // SRA r + cz = R8( data & 7 ); + cz += cz << 1 & 0x100; + goto rr_common; + + case 0x38: case 0x39: case 0x3A: case 0x3B: case 0x3C: case 0x3D: case 0x3F: // SRL r + cz = 0; + case 0x18: case 0x19: case 0x1A: case 0x1B: case 0x1C: case 0x1D: case 0x1F: // RR r + cz = (cz & 0x100) + R8( data & 7 ); + rr_common: + cz = (cz << 8) + (cz >> 1); // Z=* C=* + ph = cz | 0x100; // N=0 H=0 + R8( data & 7 ) = cz; + goto loop; + + } // CB op + assert( false ); // unhandled CB op + + case 0x07: // RLCA + cz = RG.a >> 7; + goto rlc_common; + case 0x17: // RLA + cz = cz >> 8 & 1; + rlc_common: + cz += RG.a << 1; + ph = cz | 0x100; + RG.a = BYTE( cz ); + cz |= 1; + goto loop; + + case 0x0F: // RRCA + ph = RG.a << 8; + goto rrc_common; + case 0x1F: // RRA + ph = cz; + rrc_common: + cz = (RG.a << 8) + 1; // Z=0 C=* + RG.a = ((ph & 0x100) + RG.a) >> 1; + ph = 0x100; // N=0 H=0 + goto loop; + +// Load + + case 0x70: // LD (HL),B + case 0x71: // LD (HL),C + case 0x72: // LD (HL),D + case 0x73: // LD (HL),E + case 0x74: // LD (HL),H + case 0x75: // LD (HL),L + case 0x77: // LD (HL),A + op = R8( op & 7 ); + write_hl_op_ff: + WRITE_MEM( this, RP.hl, op ); + goto loop; + + case 0x41: case 0x42: case 0x43: case 0x44: case 0x45: case 0x47: // LD r,r + case 0x48: case 0x4A: case 0x4B: case 0x4C: case 0x4D: case 0x4F: + case 0x50: case 0x51: case 0x53: case 0x54: case 0x55: case 0x57: + case 0x58: case 0x59: case 0x5A: case 0x5C: case 0x5D: case 0x5F: + case 0x60: case 0x61: case 0x62: case 0x63: case 0x65: case 0x67: + case 0x68: case 0x69: case 0x6A: case 0x6B: case 0x6C: case 0x6F: + case 0x78: case 0x79: case 0x7A: case 0x7B: case 0x7C: case 0x7D: + R8( op >> 3 & 7 ) = R8( op & 7 ); + goto loop; + + case 0x08: // LD IND16,SP + data = GET_ADDR(); + pc += 2; + WRITE_MEM( this, data, sp ); + data++; + WRITE_MEM( this, data, (sp >> 8) ); + goto loop; + + case 0xF9: // LD SP,HL + sp = RP.hl; + goto loop; + + case 0x31: // LD SP,IMM + sp = GET_ADDR(); + pc += 2; + goto loop; + + case 0x01: // LD BC,IMM + case 0x11: // LD DE,IMM + R16( (unsigned) op >> 4 ) = GET_ADDR(); + pc += 2; + goto loop; + + case 0xE2: // LD (0xFF00+C),A + WRITE_IO( this, RG.c, RG.a ); + goto loop; + + case 0xE0: // LD (0xFF00+imm),A + pc++; + WRITE_IO( this, data, RG.a ); + goto loop; + + { + int temp; + case 0x32: // LD (HL-),A + temp = RP.hl; + RP.hl = temp - 1; + goto write_data_rg_a; + + case 0x02: // LD (BC),A + temp = RP.bc; + goto write_data_rg_a; + + case 0x12: // LD (DE),A + temp = RP.de; + goto write_data_rg_a; + + case 0x22: // LD (HL+),A + temp = RP.hl; + RP.hl = temp + 1; + goto write_data_rg_a; + + case 0xEA: // LD IND16,A (common) + temp = GET_ADDR(); + pc += 2; + write_data_rg_a: + WRITE_MEM( this, temp, RG.a ); + goto loop; + } + + case 0x06: // LD B,IMM + RG.b = data; + pc++; + goto loop; + + case 0x0E: // LD C,IMM + RG.c = data; + pc++; + goto loop; + + case 0x16: // LD D,IMM + RG.d = data; + pc++; + goto loop; + + case 0x1E: // LD E,IMM + RG.e = data; + pc++; + goto loop; + + case 0x26: // LD H,IMM + RG.h = data; + pc++; + goto loop; + + case 0x2E: // LD L,IMM + RG.l = data; + pc++; + goto loop; + + case 0x36: // LD (HL),IMM + WRITE_MEM( this, RP.hl, data ); + pc++; + goto loop; + + case 0x3E: // LD A,IMM + RG.a = data; + pc++; + goto loop; + +// Increment/decrement + + case 0x03: // INC BC + case 0x13: // INC DE + case 0x23: // INC HL + R16( (unsigned) op >> 4 )++; + goto loop; + + case 0x33: // INC SP + sp = WORD( sp + 1 ); + goto loop; + + case 0x0B: // DEC BC + case 0x1B: // DEC DE + case 0x2B: // DEC HL + R16( (unsigned) op >> 4 )--; + goto loop; + + case 0x3B: // DEC SP + sp = WORD( sp - 1 ); + goto loop; + + case 0x34: // INC (HL) + op = RP.hl; + data = READ_MEM( this, op ); + data++; + WRITE_MEM( this, op, data ); + goto inc_comm; + + case 0x04: // INC B + case 0x0C: // INC C (common) + case 0x14: // INC D + case 0x1C: // INC E + case 0x24: // INC H + case 0x2C: // INC L + case 0x3C: // INC A + op = op >> 3 & 7; + data = R8( op ) + 1; + R8( op ) = data; + inc_comm: + ph = data - 0x101; // N=0 H=* + cz = (cz & 0x100) + BYTE( data ); // C=- Z=* + goto loop; + + case 0x35: // DEC (HL) + op = RP.hl; + data = READ_MEM( this, op ); + data--; + WRITE_MEM( this, op, data ); + goto dec_comm; + + case 0x05: // DEC B + case 0x0D: // DEC C + case 0x15: // DEC D + case 0x1D: // DEC E + case 0x25: // DEC H + case 0x2D: // DEC L + case 0x3D: // DEC A + op = op >> 3 & 7; + data = R8( op ) - 1; + R8( op ) = data; + dec_comm: + ph = data + 1; // N=1 H=* + cz = (cz & 0x100) + BYTE( data ); // C=- Z=* + goto loop; + +// Add 16-bit + + case 0xF8: // LD HL,SP+n + case 0xE8:{// ADD SP,n + pc++; + int t = WORD( sp + SBYTE( data ) ); + cz = ((BYTE( sp ) + data) & 0x100) + 1; // Z=0 C=* + ph = (sp ^ data ^ t) | 0x100; // N=0 H=* + if ( op == 0xF8 ) + { + RP.hl = t; + goto loop; + } + sp = t; + goto loop; + } + + case 0x39: // ADD HL,SP + data = sp; + goto add_hl_comm; + + case 0x09: // ADD HL,BC + case 0x19: // ADD HL,DE + case 0x29: // ADD HL,HL + data = R16( (unsigned) op >> 4 ); + add_hl_comm: + ph = RP.hl ^ data; + data += RP.hl; + RP.hl = WORD( data ); + ph ^= data; + cz = BYTE( cz ) + (data >> 8 & 0x100); // C=* Z=- + ph = ((ph >> 8) ^ cz) | 0x100; // N=0 H=* + goto loop; + + case 0x86: // ADD (HL) + data = READ_MEM( this, RP.hl ); + goto add_comm; + + case 0x80: // ADD B + case 0x81: // ADD C + case 0x82: // ADD D + case 0x83: // ADD E + case 0x84: // ADD H + case 0x85: // ADD L + case 0x87: // ADD A + data = R8( op & 7 ); + goto add_comm; + + case 0xC6: // ADD IMM + pc++; + add_comm: + ph = (RG.a ^ data) | 0x100; // N=1 H=* + cz = RG.a + data; // C=* Z=* + RG.a = cz; + goto loop; + +// Add/Subtract + + case 0x8E: // ADC (HL) + data = READ_MEM( this, RP.hl ); + goto adc_comm; + + case 0x88: // ADC B + case 0x89: // ADC C + case 0x8A: // ADC D + case 0x8B: // ADC E + case 0x8C: // ADC H + case 0x8D: // ADC L + case 0x8F: // ADC A + data = R8( op & 7 ); + goto adc_comm; + + case 0xCE: // ADC IMM + pc++; + adc_comm: + ph = (RG.a ^ data) | 0x100; // N=1 H=* + cz = RG.a + data + (cz >> 8 & 1); // C=* Z=* + RG.a = cz; + goto loop; + + case 0x96: // SUB (HL) + data = READ_MEM( this, RP.hl ); + goto sub_comm; + + case 0x90: // SUB B + case 0x91: // SUB C + case 0x92: // SUB D + case 0x93: // SUB E + case 0x94: // SUB H + case 0x95: // SUB L + case 0x97: // SUB A + data = R8( op & 7 ); + goto sub_comm; + + case 0xD6: // SUB IMM + pc++; + sub_comm: + ph = RG.a ^ data; // N=1 H=* + cz = RG.a - data; // C=* Z=* + RG.a = cz; + goto loop; + + case 0x9E: // SBC (HL) + data = READ_MEM( this, RP.hl ); + goto sbc_comm; + + case 0x98: // SBC B + case 0x99: // SBC C + case 0x9A: // SBC D + case 0x9B: // SBC E + case 0x9C: // SBC H + case 0x9D: // SBC L + case 0x9F: // SBC A + data = R8( op & 7 ); + goto sbc_comm; + + case 0xDE: // SBC IMM + pc++; + sbc_comm: + ph = RG.a ^ data; // N=1 H=* + cz = RG.a - data - (cz >> 8 & 1); // C=* Z=* + RG.a = cz; + goto loop; + +// Logical + + case 0xA0: // AND B + case 0xA1: // AND C + case 0xA2: // AND D + case 0xA3: // AND E + case 0xA4: // AND H + case 0xA5: // AND L + data = R8( op & 7 ); + goto and_comm; + + case 0xA6: // AND (HL) + data = READ_MEM( this, RP.hl ); + goto and_comm; + case 0xE6: // AND IMM + pc++; + and_comm: + cz = RG.a & data; // C=0 Z=* + ph = ~cz; // N=0 H=1 + RG.a = cz; + goto loop; + + case 0xA7: // AND A + cz = RG.a; // C=0 Z=* + ph = ~RG.a; // N=0 H=1 + goto loop; + + case 0xB0: // OR B + case 0xB1: // OR C + case 0xB2: // OR D + case 0xB3: // OR E + case 0xB4: // OR H + case 0xB5: // OR L + data = R8( op & 7 ); + goto or_comm; + + case 0xB6: // OR (HL) + data = READ_MEM( this, RP.hl ); + goto or_comm; + case 0xF6: // OR IMM + pc++; + or_comm: + cz = RG.a | data; // C=0 Z=* + ph = cz | 0x100; // N=0 H=0 + RG.a = cz; + goto loop; + + case 0xB7: // OR A + cz = RG.a; // C=0 Z=* + ph = RG.a + 0x100; // N=0 H=0 + goto loop; + + case 0xA8: // XOR B + case 0xA9: // XOR C + case 0xAA: // XOR D + case 0xAB: // XOR E + case 0xAC: // XOR H + case 0xAD: // XOR L + data = R8( op & 7 ); + goto xor_comm; + + case 0xAE: // XOR (HL) + data = READ_MEM( this, RP.hl ); + pc--; + case 0xEE: // XOR IMM + pc++; + xor_comm: + cz = RG.a ^ data; // C=0 Z=* + ph = cz + 0x100; // N=0 H=0 + RG.a = cz; + goto loop; + + case 0xAF: // XOR A + RG.a = 0; + cz = 0; // C=0 Z=* + ph = 0x100; // N=0 H=0 + goto loop; + +// Stack + + case 0xF1: // POP AF + case 0xC1: // POP BC + case 0xD1: // POP DE + case 0xE1: // POP HL (common) + data = READ_MEM( this, sp ); + R16( op >> 4 & 3 ) = data + 0x100 * READ_MEM( this, (sp + 1) ); + sp = WORD( sp + 2 ); + if ( op != 0xF1 ) + goto loop; + + SET_FLAGS( RG.a ); + RG.a = RG.flags; + goto loop; + + case 0xC5: // PUSH BC + data = RP.bc; + goto push; + + case 0xD5: // PUSH DE + data = RP.de; + goto push; + + case 0xE5: // PUSH HL + data = RP.hl; + goto push; + + case 0xF5: // PUSH AF + GET_FLAGS( data ); + data += RG.a << 8; + goto push; + +// Flow control + + case 0xFF: case 0xC7: case 0xCF: case 0xD7: // RST + case 0xDF: case 0xE7: case 0xEF: case 0xF7: + data = pc; + pc = (op & 0x38) + cpu->rst_base; + goto push; + + case 0xCC: // CALL Z + pc += 2; + if ( CC_Z() ) + goto call; + goto loop; + + case 0xD4: // CALL NC + pc += 2; + if ( CC_NC() ) + goto call; + goto loop; + + case 0xDC: // CALL C + pc += 2; + if ( CC_C() ) + goto call; + goto loop; + + case 0xC0: // RET NZ + if ( CC_NZ() ) + goto ret; + goto loop; + + case 0xD0: // RET NC + if ( CC_NC() ) + goto ret; + goto loop; + + case 0xD8: // RET C + if ( CC_C() ) + goto ret; + goto loop; + + case 0x18: // JR + BRANCH_( true, 0 ) + + case 0x30: // JR NC + BRANCH( CC_NC() ) + + case 0x38: // JR C + BRANCH( CC_C() ) + + case 0xE9: // LD PC,HL + pc = RP.hl; + goto loop; + + case 0xC3: // JP (next-most-common) + pc = GET_ADDR(); + goto loop; + + case 0xC2: // JP NZ + pc += 2; + if ( CC_NZ() ) + goto jp_taken; + time -= 4; + goto loop; + + case 0xCA: // JP Z (most common) + pc += 2; + if ( CC_Z() ) + goto jp_taken; + time -= 4; + goto loop; + + jp_taken: + pc -= 2; + pc = GET_ADDR(); + goto loop; + + case 0xD2: // JP NC + pc += 2; + if ( CC_NC() ) + goto jp_taken; + time -= 4; + goto loop; + + case 0xDA: // JP C + pc += 2; + if ( CC_C() ) + goto jp_taken; + time -= 4; + goto loop; + +// Flags + + case 0x2F: // CPL + RG.a = ~RG.a; + ph = BYTE( ~cz ); // N=1 H=1 + goto loop; + + case 0x3F: // CCF + ph = cz | 0x100; // N=0 H=0 + cz ^= 0x100; // C=* Z=- + goto loop; + + case 0x37: // SCF + ph = cz | 0x100; // N=0 H=0 + cz |= 0x100; // C=1 Z=- + goto loop; + + case 0xF3: // DI + goto loop; + + case 0xFB: // EI + goto loop; + + case 0x27:{// DAA + unsigned a = RG.a; + int h = ph ^ cz; + if ( ph & 0x100 ) + { + if ( (h & 0x10) || (a & 0x0F) > 9 ) + a += 6; + + if ( (cz & 0x100) || a > 0x9F ) + a += 0x60; + } + else + { + if ( h & 0x10 ) + a = (a - 6) & 0xFF; + + if ( cz & 0x100 ) + a -= 0x60; + } + cz = (cz & 0x100) | a; // C=- Z=* + RG.a = a; + ph = (ph & 0x100) + BYTE( a ); // N=- H=0 + goto loop; + } + +// Special + + case 0x76: // HALT + case 0x10: // STOP + case 0xD3: case 0xDB: case 0xDD: // Illegal + case 0xE3: case 0xE4: case 0xEB: case 0xEC: case 0xED: // (all freeze cpu) + case 0xF4: case 0xFC: case 0xFD: + goto stop; + } + + // If this fails then an opcode isn't handled above + assert( false ); + +stop: + pc--; + + // copy state back + cpu->cpu_state_.time = time; + cpu->r.pc = pc; + cpu->r.sp = sp; + { + int t; + GET_FLAGS( t ); + RG.flags = t; + } + cpu->cpu_state = &cpu->cpu_state_; + cpu->r.rp = RP; +} diff --git a/lib/rbcodec/codecs/libgme/gb_oscs.c b/lib/rbcodec/codecs/libgme/gb_oscs.c new file mode 100644 index 0000000000..09bb98238e --- /dev/null +++ b/lib/rbcodec/codecs/libgme/gb_oscs.c @@ -0,0 +1,787 @@ +// Gb_Snd_Emu 0.1.4. http://www.slack.net/~ant/ + +#include "gb_apu.h" + +/* Copyright (C) 2003-2008 Shay Green. This module is free software; you +can redistribute it and/or modify it under the terms of the GNU Lesser +General Public License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. This +module is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +details. You should have received a copy of the GNU Lesser General Public +License along with this module; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ + +#include "blargg_source.h" + +int const cgb_02 = 0; // enables bug in early CGB units that causes problems in some games +int const cgb_05 = 0; // enables CGB-05 zombie behavior + +int const trigger_mask = 0x80; +int const length_enabled = 0x40; + +void Osc_reset( struct Gb_Osc* this ) +{ + this->output = NULL; + this->last_amp = 0; + this->delay = 0; + this->phase = 0; + this->enabled = false; +} + +static inline void Osc_update_amp( struct Gb_Osc* this, blip_time_t time, int new_amp ) +{ + Blip_set_modified( this->output ); + int delta = new_amp - this->last_amp; + if ( delta ) + { + this->last_amp = new_amp; + Synth_offset( this->synth, time, delta, this->output ); + } +} + +// Units + +void Osc_clock_length( struct Gb_Osc* this ) +{ + if ( (this->regs [4] & length_enabled) && this->length_ctr ) + { + if ( --this->length_ctr <= 0 ) + this->enabled = false; + } +} + +void Noise_clock_envelope( struct Gb_Noise* this ) +{ + if ( this->env_enabled && --this->env_delay <= 0 && Noise_reload_env_timer( this ) ) + { + int v = this->volume + (this->osc.regs [2] & 0x08 ? +1 : -1); + if ( 0 <= v && v <= 15 ) + this->volume = v; + else + this->env_enabled = false; + } +} + +void Square_clock_envelope( struct Gb_Square* this ) +{ + if ( this->env_enabled && --this->env_delay <= 0 && Square_reload_env_timer( this ) ) + { + int v = this->volume + (this->osc.regs [2] & 0x08 ? +1 : -1); + if ( 0 <= v && v <= 15 ) + this->volume = v; + else + this->env_enabled = false; + } +} + +static inline void reload_sweep_timer( struct Gb_Square* this ) +{ + this->sweep_delay = (this->osc.regs [0] & period_mask) >> 4; + if ( !this->sweep_delay ) + this->sweep_delay = 8; +} + +static void calc_sweep( struct Gb_Square* this, bool update ) +{ + struct Gb_Osc* osc = &this->osc; + int const shift = osc->regs [0] & shift_mask; + int const delta = this->sweep_freq >> shift; + this->sweep_neg = (osc->regs [0] & 0x08) != 0; + int const freq = this->sweep_freq + (this->sweep_neg ? -delta : delta); + + if ( freq > 0x7FF ) + { + osc->enabled = false; + } + else if ( shift && update ) + { + this->sweep_freq = freq; + + osc->regs [3] = freq & 0xFF; + osc->regs [4] = (osc->regs [4] & ~0x07) | (freq >> 8 & 0x07); + } +} + +void clock_sweep( struct Gb_Square* this ) +{ + if ( --this->sweep_delay <= 0 ) + { + reload_sweep_timer( this ); + if ( this->sweep_enabled && (this->osc.regs [0] & period_mask) ) + { + calc_sweep( this, true ); + calc_sweep( this, false ); + } + } +} + +int wave_access( struct Gb_Wave* this, int addr ) +{ + if ( this->osc.enabled ) + { + addr = this->osc.phase & (wave_bank_size - 1); + if ( this->osc.mode == mode_dmg ) + { + addr++; + if ( this->osc.delay > clk_mul ) + return -1; // can only access within narrow time window while playing + } + addr >>= 1; + } + return addr & 0x0F; +} + +// write_register + +static int write_trig( struct Gb_Osc* this, int frame_phase, int max_len, int old_data ) +{ + int data = this->regs [4]; + + if ( (frame_phase & 1) && !(old_data & length_enabled) && this->length_ctr ) + { + if ( (data & length_enabled) || cgb_02 ) + this->length_ctr--; + } + + if ( data & trigger_mask ) + { + this->enabled = true; + if ( !this->length_ctr ) + { + this->length_ctr = max_len; + if ( (frame_phase & 1) && (data & length_enabled) ) + this->length_ctr--; + } + } + + if ( !this->length_ctr ) + this->enabled = false; + + return data & trigger_mask; +} + +static inline void Noise_zombie_volume( struct Gb_Noise* this, int old, int data ) +{ + int v = this->volume; + if ( this->osc.mode == mode_agb || cgb_05 ) + { + // CGB-05 behavior, very close to AGB behavior as well + if ( (old ^ data) & 8 ) + { + if ( !(old & 8) ) + { + v++; + if ( old & 7 ) + v++; + } + + v = 16 - v; + } + else if ( (old & 0x0F) == 8 ) + { + v++; + } + } + else + { + // CGB-04&02 behavior, very close to MGB behavior as well + if ( !(old & 7) && this->env_enabled ) + v++; + else if ( !(old & 8) ) + v += 2; + + if ( (old ^ data) & 8 ) + v = 16 - v; + } + this->volume = v & 0x0F; +} + +static inline void Square_zombie_volume( struct Gb_Square* this, int old, int data ) +{ + int v = this->volume; + if ( this->osc.mode == mode_agb || cgb_05 ) + { + // CGB-05 behavior, very close to AGB behavior as well + if ( (old ^ data) & 8 ) + { + if ( !(old & 8) ) + { + v++; + if ( old & 7 ) + v++; + } + + v = 16 - v; + } + else if ( (old & 0x0F) == 8 ) + { + v++; + } + } + else + { + // CGB-04&02 behavior, very close to MGB behavior as well + if ( !(old & 7) && this->env_enabled ) + v++; + else if ( !(old & 8) ) + v += 2; + + if ( (old ^ data) & 8 ) + v = 16 - v; + } + this->volume = v & 0x0F; +} + +static bool Square_write_register( struct Gb_Square* this, int frame_phase, int reg, int old_data, int data ) +{ + int const max_len = 64; + + switch ( reg ) + { + case 1: + this->osc.length_ctr = max_len - (data & (max_len - 1)); + break; + + case 2: + if ( !Square_dac_enabled( this ) ) + this->osc.enabled = false; + + Square_zombie_volume( this, old_data, data ); + + if ( (data & 7) && this->env_delay == 8 ) + { + this->env_delay = 1; + Square_clock_envelope( this ); // TODO: really happens at next length clock + } + break; + + case 4: + if ( write_trig( &this->osc, frame_phase, max_len, old_data ) ) + { + this->volume = this->osc.regs [2] >> 4; + Square_reload_env_timer( this ); + this->env_enabled = true; + if ( frame_phase == 7 ) + this->env_delay++; + if ( !Square_dac_enabled( this ) ) + this->osc.enabled = false; + this->osc.delay = (this->osc.delay & (4 * clk_mul - 1)) + Square_period( this ); + return true; + } + } + + return false; +} + +static inline void Noise_write_register( struct Gb_Noise* this, int frame_phase, int reg, int old_data, int data ) +{ + int const max_len = 64; + + switch ( reg ) + { + case 1: + this->osc.length_ctr = max_len - (data & (max_len - 1)); + break; + + case 2: + if ( !Noise_dac_enabled( this ) ) + this->osc.enabled = false; + + Noise_zombie_volume( this, old_data, data ); + + if ( (data & 7) && this->env_delay == 8 ) + { + this->env_delay = 1; + Noise_clock_envelope( this ); // TODO: really happens at next length clock + } + break; + + case 4: + if ( write_trig( &this->osc, frame_phase, max_len, old_data ) ) + { + this->volume = this->osc.regs [2] >> 4; + Noise_reload_env_timer( this ); + this->env_enabled = true; + if ( frame_phase == 7 ) + this->env_delay++; + if ( !Noise_dac_enabled( this ) ) + this->osc.enabled = false; + + this->osc.phase = 0x7FFF; + this->osc.delay += 8 * clk_mul; + } + } +} + +static inline void Sweep_write_register( struct Gb_Square* this, int frame_phase, int reg, int old_data, int data ) +{ + if ( reg == 0 && this->sweep_enabled && this->sweep_neg && !(data & 0x08) ) + this->osc.enabled = false; // sweep negate disabled after used + + if ( Square_write_register( this, frame_phase, reg, old_data, data ) ) + { + this->sweep_freq = Osc_frequency( &this->osc ); + this->sweep_neg = false; + reload_sweep_timer( this ); + this->sweep_enabled = (this->osc.regs [0] & (period_mask | shift_mask)) != 0; + if ( this->osc.regs [0] & shift_mask ) + calc_sweep( this, false ); + } +} + +static void corrupt_wave( struct Gb_Wave* this ) +{ + int pos = ((this->osc.phase + 1) & (wave_bank_size - 1)) >> 1; + if ( pos < 4 ) + this->wave_ram [0] = this->wave_ram [pos]; + else { + int i; + for ( i = 4; --i >= 0; ) + this->wave_ram [i] = this->wave_ram [(pos & ~3) + i]; + } +} + +static inline void Wave_write_register( struct Gb_Wave* this, int frame_phase, int reg, int old_data, int data ) +{ + int const max_len = 256; + + switch ( reg ) + { + case 0: + if ( !Wave_dac_enabled( this ) ) + this->osc.enabled = false; + break; + + case 1: + this->osc.length_ctr = max_len - data; + break; + + case 4: + { + bool was_enabled = this->osc.enabled; + if ( write_trig( &this->osc, frame_phase, max_len, old_data ) ) + { + if ( !Wave_dac_enabled( this ) ) + this->osc.enabled = false; + else if ( this->osc.mode == mode_dmg && was_enabled && + (unsigned) (this->osc.delay - 2 * clk_mul) < 2 * clk_mul ) + corrupt_wave( this ); + + this->osc.phase = 0; + this->osc.delay = Wave_period( this ) + 6 * clk_mul; + } + } + } +} + +void write_osc( struct Gb_Apu* this, int reg, int old_data, int data ) +{ + int index = (reg * 3 + 3) >> 4; // avoids divide + assert( index == reg / 5 ); + reg -= index * 5; + switch ( index ) + { + case 0: Sweep_write_register ( &this->square1, this->frame_phase, reg, old_data, data ); break; + case 1: Square_write_register( &this->square2, this->frame_phase, reg, old_data, data ); break; + case 2: Wave_write_register ( &this->wave, this->frame_phase, reg, old_data, data ); break; + case 3: Noise_write_register ( &this->noise, this->frame_phase, reg, old_data, data ); break; + } +} + +// Synthesis + +void Square_run( struct Gb_Square* this, blip_time_t time, blip_time_t end_time ) +{ + // Calc duty and phase + static byte const duty_offsets [4] = { 1, 1, 3, 7 }; + static byte const duties [4] = { 1, 2, 4, 6 }; + + struct Gb_Osc* osc = &this->osc; + int const duty_code = osc->regs [1] >> 6; + int duty_offset = duty_offsets [duty_code]; + int duty = duties [duty_code]; + if ( osc->mode == mode_agb ) + { + // AGB uses inverted duty + duty_offset -= duty; + duty = 8 - duty; + } + int ph = (osc->phase + duty_offset) & 7; + + // Determine what will be generated + int vol = 0; + struct Blip_Buffer* const out = osc->output; + if ( out ) + { + int amp = osc->dac_off_amp; + if ( Square_dac_enabled( this ) ) + { + if ( osc->enabled ) + vol = this->volume; + + amp = -dac_bias; + if ( osc->mode == mode_agb ) + amp = -(vol >> 1); + + // Play inaudible frequencies as constant amplitude + if ( Osc_frequency( osc ) >= 0x7FA && osc->delay < 32 * clk_mul ) + { + amp += (vol * duty) >> 3; + vol = 0; + } + + if ( ph < duty ) + { + amp += vol; + vol = -vol; + } + } + Osc_update_amp( osc, time, amp ); + } + + // Generate wave + time += osc->delay; + if ( time < end_time ) + { + int const per = Square_period( this ); + if ( !vol ) + { + #ifdef GB_APU_FAST + time = end_time; + #else + // Maintain phase when not playing + int count = (end_time - time + per - 1) / per; + ph += count; // will be masked below + time += (blip_time_t) count * per; + #endif + } + else + { + // Output amplitude transitions + int delta = vol; + do + { + ph = (ph + 1) & 7; + if ( ph == 0 || ph == duty ) + { + Synth_offset_inline( osc->synth, time, delta, out ); + delta = -delta; + } + time += per; + } + while ( time < end_time ); + + if ( delta != vol ) + osc->last_amp -= delta; + } + osc->phase = (ph - duty_offset) & 7; + } + osc->delay = time - end_time; +} + +#ifndef GB_APU_FAST +// Quickly runs LFSR for a large number of clocks. For use when noise is generating +// no sound. +static unsigned run_lfsr( unsigned s, unsigned mask, int count ) +{ + bool const optimized = true; // set to false to use only unoptimized loop in middle + + // optimization used in several places: + // ((s & (1 << b)) << n) ^ ((s & (1 << b)) << (n + 1)) = (s & (1 << b)) * (3 << n) + + if ( mask == 0x4000 && optimized ) + { + if ( count >= 32767 ) + count %= 32767; + + // Convert from Fibonacci to Galois configuration, + // shifted left 1 bit + s ^= (s & 1) * 0x8000; + + // Each iteration is equivalent to clocking LFSR 255 times + while ( (count -= 255) > 0 ) + s ^= ((s & 0xE) << 12) ^ ((s & 0xE) << 11) ^ (s >> 3); + count += 255; + + // Each iteration is equivalent to clocking LFSR 15 times + // (interesting similarity to single clocking below) + while ( (count -= 15) > 0 ) + s ^= ((s & 2) * (3 << 13)) ^ (s >> 1); + count += 15; + + // Remaining singles + while ( --count >= 0 ) + s = ((s & 2) * (3 << 13)) ^ (s >> 1); + + // Convert back to Fibonacci configuration + s &= 0x7FFF; + } + else if ( count < 8 || !optimized ) + { + // won't fully replace upper 8 bits, so have to do the unoptimized way + while ( --count >= 0 ) + s = (s >> 1 | mask) ^ (mask & -((s - 1) & 2)); + } + else + { + if ( count > 127 ) + { + count %= 127; + if ( !count ) + count = 127; // must run at least once + } + + // Need to keep one extra bit of history + s = s << 1 & 0xFF; + + // Convert from Fibonacci to Galois configuration, + // shifted left 2 bits + s ^= (s & 2) * 0x80; + + // Each iteration is equivalent to clocking LFSR 7 times + // (interesting similarity to single clocking below) + while ( (count -= 7) > 0 ) + s ^= ((s & 4) * (3 << 5)) ^ (s >> 1); + count += 7; + + // Remaining singles + while ( --count >= 0 ) + s = ((s & 4) * (3 << 5)) ^ (s >> 1); + + // Convert back to Fibonacci configuration and + // repeat last 8 bits above significant 7 + s = (s << 7 & 0x7F80) | (s >> 1 & 0x7F); + } + + return s; +} +#endif + +void Noise_run( struct Gb_Noise* this, blip_time_t time, blip_time_t end_time ) +{ + // Determine what will be generated + int vol = 0; + struct Gb_Osc* osc = &this->osc; + struct Blip_Buffer* const out = osc->output; + if ( out ) + { + int amp = osc->dac_off_amp; + if ( Noise_dac_enabled( this ) ) + { + if ( osc->enabled ) + vol = this->volume; + + amp = -dac_bias; + if ( osc->mode == mode_agb ) + amp = -(vol >> 1); + + if ( !(osc->phase & 1) ) + { + amp += vol; + vol = -vol; + } + } + + // AGB negates final output + if ( osc->mode == mode_agb ) + { + vol = -vol; + amp = -amp; + } + + Osc_update_amp( osc, time, amp ); + } + + // Run timer and calculate time of next LFSR clock + static byte const period1s [8] = { 1, 2, 4, 6, 8, 10, 12, 14 }; + int const period1 = period1s [osc->regs [3] & 7] * clk_mul; + + #ifdef GB_APU_FAST + time += delay; + #else + { + int extra = (end_time - time) - osc->delay; + int const per2 = period2( this, 8 ); + time += osc->delay + ((this->divider ^ (per2 >> 1)) & (per2 - 1)) * period1; + + int count = (extra < 0 ? 0 : (extra + period1 - 1) / period1); + this->divider = (this->divider - count) & period2_mask; + osc->delay = count * period1 - extra; + } + #endif + + // Generate wave + if ( time < end_time ) + { + unsigned const mask = lfsr_mask( this ); + unsigned bits = osc->phase; + + int per = period2( this, period1 * 8 ); + #ifdef GB_APU_FAST + // Noise can be THE biggest time hog; adjust as necessary + int const min_period = 24; + if ( per < min_period ) + per = min_period; + #endif + if ( period2_index( this ) >= 0xE ) + { + time = end_time; + } + else if ( !vol ) + { + #ifdef GB_APU_FAST + time = end_time; + #else + // Maintain phase when not playing + int count = (end_time - time + per - 1) / per; + time += (blip_time_t) count * per; + bits = run_lfsr( bits, ~mask, count ); + #endif + } + else + { + struct Blip_Synth* synth = osc->synth; // cache + + // Output amplitude transitions + int delta = -vol; + do + { + unsigned changed = bits + 1; + bits = bits >> 1 & mask; + if ( changed & 2 ) + { + bits |= ~mask; + delta = -delta; + Synth_offset_inline( synth, time, delta, out ); + } + time += per; + } + while ( time < end_time ); + + if ( delta == vol ) + osc->last_amp += delta; + } + osc->phase = bits; + } + + #ifdef GB_APU_FAST + osc->delay = time - end_time; + #endif +} + +void Wave_run( struct Gb_Wave* this, blip_time_t time, blip_time_t end_time ) +{ + // Calc volume +#ifdef GB_APU_NO_AGB + static byte const shifts [4] = { 4+4, 0+4, 1+4, 2+4 }; + int const volume_idx = this->regs [2] >> 5 & 3; + int const volume_shift = shifts [volume_idx]; + int const volume_mul = 1; +#else + static byte const volumes [8] = { 0, 4, 2, 1, 3, 3, 3, 3 }; + int const volume_shift = 2 + 4; + int const volume_idx = this->osc.regs [2] >> 5 & (this->agb_mask | 3); // 2 bits on DMG/CGB, 3 on AGB + int const volume_mul = volumes [volume_idx]; +#endif + + // Determine what will be generated + int playing = false; + struct Gb_Osc* osc = &this->osc; + struct Blip_Buffer* out = osc->output; + if ( out ) + { + int amp = osc->dac_off_amp; + if ( Wave_dac_enabled( this ) ) + { + // Play inaudible frequencies as constant amplitude + amp = 8 << 4; // really depends on average of all samples in wave + + // if delay is larger, constant amplitude won't start yet + if ( Osc_frequency( osc ) <= 0x7FB || osc->delay > 15 * clk_mul ) + { + if ( volume_mul && volume_shift != 4+4 ) + playing = (int) osc->enabled; + + amp = (this->sample_buf << (osc->phase << 2 & 4) & 0xF0) * playing; + } + + amp = ((amp * volume_mul) >> volume_shift) - dac_bias; + } + Osc_update_amp( osc, time, amp ); + } + + // Generate wave + time += osc->delay; + if ( time < end_time ) + { + byte const* wave = this->wave_ram; + + // wave size and bank + #ifdef GB_APU_NO_AGB + int const wave_mask = 0x1F; + int const swap_banks = 0; + #else + int const size20_mask = 0x20; + int const flags = osc->regs [0] & this->agb_mask; + int const wave_mask = (flags & size20_mask) | 0x1F; + int swap_banks = 0; + if ( flags & bank40_mask ) + { + swap_banks = flags & size20_mask; + wave += wave_bank_size/2 - (swap_banks >> 1); + } + #endif + + int ph = osc->phase ^ swap_banks; + ph = (ph + 1) & wave_mask; // pre-advance + + int const per = Wave_period( this ); + if ( !playing ) + { + #ifdef GB_APU_FAST + time = end_time; + #else + // Maintain phase when not playing + int count = (end_time - time + per - 1) / per; + ph += count; // will be masked below + time += (blip_time_t) count * per; + #endif + } + else + { + struct Blip_Synth* synth = osc->synth; // cache + + // Output amplitude transitions + int lamp = osc->last_amp + dac_bias; + do + { + // Extract nibble + int nibble = wave [ph >> 1] << (ph << 2 & 4) & 0xF0; + ph = (ph + 1) & wave_mask; + + // Scale by volume + int amp = (nibble * volume_mul) >> volume_shift; + + int delta = amp - lamp; + if ( delta ) + { + lamp = amp; + Synth_offset_inline( synth, time, delta, out ); + } + time += per; + } + while ( time < end_time ); + osc->last_amp = lamp - dac_bias; + } + ph = (ph - 1) & wave_mask; // undo pre-advance and mask position + + // Keep track of last byte read + if ( osc->enabled ) + this->sample_buf = wave [ph >> 1]; + + osc->phase = ph ^ swap_banks; // undo swapped banks + } + osc->delay = time - end_time; +} diff --git a/lib/rbcodec/codecs/libgme/gb_oscs.h b/lib/rbcodec/codecs/libgme/gb_oscs.h new file mode 100644 index 0000000000..3c8dfef51f --- /dev/null +++ b/lib/rbcodec/codecs/libgme/gb_oscs.h @@ -0,0 +1,187 @@ +// Private oscillators used by Gb_Apu + +// Gb_Snd_Emu 0.1.4 +#ifndef GB_OSCS_H +#define GB_OSCS_H + +#include "blargg_common.h" +#include "blip_buffer.h" + +#ifndef GB_APU_OVERCLOCK + #define GB_APU_OVERCLOCK 1 +#endif + +#if GB_APU_OVERCLOCK & (GB_APU_OVERCLOCK - 1) + #error "GB_APU_OVERCLOCK must be a power of 2" +#endif + +enum { clk_mul = GB_APU_OVERCLOCK }; +enum { dac_bias = 7 }; + +struct Gb_Osc { + struct Blip_Buffer* outputs [4];// NULL, right, left, center + struct Blip_Buffer* output; // where to output sound + uint8_t* regs; // osc's 5 registers + int mode; // mode_dmg, mode_cgb, mode_agb + int dac_off_amp;// amplitude when DAC is off + int last_amp; // current amplitude in Blip_Buffer + + struct Blip_Synth* synth; + + int delay; // clocks until frequency timer expires + int length_ctr; // length counter + unsigned phase; // waveform phase (or equivalent) + bool enabled; // internal enabled flag +}; + +// 11-bit frequency in NRx3 and NRx4 +static inline int Osc_frequency( struct Gb_Osc* this ) { return (this->regs [4] & 7) * 0x100 + this->regs [3]; } + +void Osc_clock_length( struct Gb_Osc* this ); +void Osc_reset( struct Gb_Osc* this ); + +// Square + +enum { period_mask = 0x70 }; +enum { shift_mask = 0x07 }; + +struct Gb_Square { + struct Gb_Osc osc; + + int env_delay; + int volume; + bool env_enabled; + + // Sweep square + int sweep_freq; + int sweep_delay; + bool sweep_enabled; + bool sweep_neg; +}; + +void Square_run( struct Gb_Square* this, blip_time_t, blip_time_t ); +void Square_clock_envelope( struct Gb_Square* this ); + +static inline void Square_reset( struct Gb_Square* this ) +{ + this->env_delay = 0; + this->volume = 0; + Osc_reset( &this->osc ); + this->osc.delay = 0x40000000; // TODO: something less hacky (never clocked until first trigger) +} +// Frequency timer period +static inline int Square_period( struct Gb_Square* this ) { return (2048 - Osc_frequency( &this->osc )) * (4 * clk_mul); } +static inline int Square_dac_enabled( struct Gb_Square* this) { return this->osc.regs [2] & 0xF8; } +static inline int Square_reload_env_timer( struct Gb_Square* this ) +{ + int raw = this->osc.regs [2] & 7; + this->env_delay = (raw ? raw : 8); + return raw; +} + +// Sweep square + +void clock_sweep( struct Gb_Square* this ); + +static inline void Sweep_reset( struct Gb_Square* this ) +{ + this->sweep_freq = 0; + this->sweep_delay = 0; + this->sweep_enabled = false; + this->sweep_neg = false; + + this->env_delay = 0; + this->volume = 0; + Osc_reset( &this->osc ); + this->osc.delay = 0x40000000; // TODO: something less hacky (never clocked until first trigger) +} + +// Noise + +enum { period2_mask = 0x1FFFF }; + +struct Gb_Noise { + struct Gb_Osc osc; + + int env_delay; + int volume; + bool env_enabled; + + int divider; // noise has more complex frequency divider setup +}; + +void Noise_run( struct Gb_Noise* this, blip_time_t, blip_time_t ); + +static inline void Noise_reset( struct Gb_Noise* this ) +{ + this->divider = 0; + + this->env_delay = 0; + this->volume = 0; + Osc_reset( &this->osc ); + this->osc.delay = 4 * clk_mul; // TODO: remove? +} + +void Noise_clock_envelope( struct Gb_Noise* this ); + +// Non-zero if DAC is enabled +static inline int Noise_dac_enabled( struct Gb_Noise* this) { return this->osc.regs [2] & 0xF8; } +static inline int Noise_reload_env_timer( struct Gb_Noise* this ) +{ + int raw = this->osc.regs [2] & 7; + this->env_delay = (raw ? raw : 8); + return raw; +} + +static inline int period2_index( struct Gb_Noise* this ) { return this->osc.regs [3] >> 4; } +static inline int period2( struct Gb_Noise* this, int base ) { return base << period2_index( this ); } +static inline unsigned lfsr_mask( struct Gb_Noise* this ) { return (this->osc.regs [3] & 0x08) ? ~0x4040 : ~0x4000; } + +// Wave + +enum { bank40_mask = 0x40 }; +enum { wave_bank_size = 32 }; + +struct Gb_Wave { + struct Gb_Osc osc; + + int sample_buf; // last wave RAM byte read (hardware has this as well) + + int agb_mask; // 0xFF if AGB features enabled, 0 otherwise + uint8_t* wave_ram; // 32 bytes (64 nybbles), stored in APU +}; + +void Wave_run( struct Gb_Wave* this, blip_time_t, blip_time_t ); + +static inline void Wave_reset( struct Gb_Wave* this ) +{ + this->sample_buf = 0; + Osc_reset( &this->osc ); +} + +// Frequency timer period +static inline int Wave_period( struct Gb_Wave* this ) { return (2048 - Osc_frequency( &this->osc )) * (2 * clk_mul); } + +// Non-zero if DAC is enabled +static inline int Wave_dac_enabled( struct Gb_Wave* this ) { return this->osc.regs [0] & 0x80; } + +static inline uint8_t* wave_bank( struct Gb_Wave* this ) { return &this->wave_ram [(~this->osc.regs [0] & bank40_mask) >> 2 & this->agb_mask]; } + +// Wave index that would be accessed, or -1 if no access would occur +int wave_access( struct Gb_Wave* this, int addr ); + +// Reads/writes wave RAM +static inline int Wave_read( struct Gb_Wave* this, int addr ) +{ + int index = wave_access( this, addr ); + return (index < 0 ? 0xFF : wave_bank( this ) [index]); +} + +static inline void Wave_write( struct Gb_Wave* this, int addr, int data ) +{ + int index = wave_access( this, addr ); + if ( index >= 0 ) + wave_bank( this ) [index] = data;; +} + +#endif diff --git a/lib/rbcodec/codecs/libgme/gbs_cpu.c b/lib/rbcodec/codecs/libgme/gbs_cpu.c new file mode 100644 index 0000000000..1015dd5358 --- /dev/null +++ b/lib/rbcodec/codecs/libgme/gbs_cpu.c @@ -0,0 +1,120 @@ +// Game_Music_Emu 0.6-pre. http://www.slack.net/~ant/ + +#include "gbs_emu.h" +#include "blargg_endian.h" + +/* Copyright (C) 2003-2009 Shay Green. This module is free software; you +can redistribute it and/or modify it under the terms of the GNU Lesser +General Public License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. This +module is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +details. You should have received a copy of the GNU Lesser General Public +License along with this module; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ + +#include "blargg_source.h" + +#ifndef LOG_MEM + #define LOG_MEM( addr, str, data ) data +#endif + +int read_mem( struct Gbs_Emu* this, addr_t addr ) +{ + int result = *Cpu_get_code( &this->cpu, addr ); + if ( (unsigned) (addr - io_addr) < io_size ) + result = Apu_read_register( &this->apu, Time( this ), addr ); + + return LOG_MEM( addr, ">", result ); +} + +static inline void write_io_inline( struct Gbs_Emu* this, int offset, int data, int base ) +{ + if ( (unsigned) (offset - (io_addr - base)) < io_size ) + Apu_write_register( &this->apu, Time( this ), offset + base, data & 0xFF ); + else if ( (unsigned) (offset - (0xFF06 - base)) < 2 ) + update_timer( this ); + else if ( offset == io_base - base ) + this->ram [base - ram_addr + offset] = 0; // keep joypad return value 0 + else + this->ram [base - ram_addr + offset] = 0xFF; +} + +void write_mem( struct Gbs_Emu* this, addr_t addr, int data ) +{ + (void) LOG_MEM( addr, "<", data ); + + int offset = addr - ram_addr; + if ( (unsigned) offset < 0x10000 - ram_addr ) + { + this->ram [offset] = data; + + offset -= 0xE000 - ram_addr; + if ( (unsigned) offset < 0x1F80 ) + write_io_inline( this, offset, data, 0xE000 ); + } + else if ( (unsigned) (offset - (0x2000 - ram_addr)) < 0x2000 ) + { + set_bank( this, data & 0xFF ); + } +#ifndef NDEBUG + else if ( unsigned (addr - 0x8000) < 0x2000 || unsigned (addr - 0xE000) < 0x1F00 ) + { + /* dprintf( "Unmapped write $%04X\n", (unsigned) addr ); */ + } +#endif +} + +static void write_io_( struct Gbs_Emu* this, int offset, int data ) +{ + write_io_inline( this, offset, data, io_base ); +} + +static inline void write_io( struct Gbs_Emu* this, int offset, int data ) +{ + (void) LOG_MEM( offset + io_base, "<", data ); + + this->ram [io_base - ram_addr + offset] = data; + if ( (unsigned) offset < 0x80 ) + write_io_( this, offset, data ); +} + +static int read_io( struct Gbs_Emu* this, int offset ) +{ + int const io_base = 0xFF00; + int result = this->ram [io_base - ram_addr + offset]; + + if ( (unsigned) (offset - (io_addr - io_base)) < io_size ) + { + result = Apu_read_register( &this->apu, Time( this ), offset + io_base ); + (void) LOG_MEM( offset + io_base, ">", result ); + } + else + { + check( result == read_mem( offset + io_base ) ); + } + return result; +} + +#define READ_FAST( emu, addr, out ) \ +{\ + out = READ_CODE( addr );\ + if ( (unsigned) (addr - io_addr) < io_size )\ + out = LOG_MEM( addr, ">", Apu_read_register( &emu->apu, TIME() + emu->end_time, addr ) );\ + else\ + check( out == Read_mem( emu, addr ) );\ +} + +#define READ_MEM( emu, addr ) read_mem( emu, addr ) +#define WRITE_MEM( emu, addr, data ) write_mem( emu, addr, data ) + +#define WRITE_IO( emu, addr, data ) write_io( emu, addr, data ) +#define READ_IO( emu, addr, out ) out = read_io( emu, addr ) + +#define CPU_BEGIN \ +void run_cpu( struct Gbs_Emu* this )\ +{ \ + struct Gb_Cpu* cpu = &this->cpu; + #include "gb_cpu_run.h" +} diff --git a/lib/rbcodec/codecs/libgme/gbs_emu.c b/lib/rbcodec/codecs/libgme/gbs_emu.c new file mode 100644 index 0000000000..7a6d484673 --- /dev/null +++ b/lib/rbcodec/codecs/libgme/gbs_emu.c @@ -0,0 +1,452 @@ +// Game_Music_Emu 0.5.2. http://www.slack.net/~ant/ + +#include "gbs_emu.h" + +#include "blargg_endian.h" + +/* Copyright (C) 2003-2006 Shay Green. this module is free software; you +can redistribute it and/or modify it under the terms of the GNU Lesser +General Public License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. this +module is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +details. You should have received a copy of the GNU Lesser General Public +License along with this module; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ + +#include "blargg_source.h" + +const char gme_wrong_file_type [] = "Wrong file type for this emulator"; + +int const idle_addr = 0xF00D; +int const tempo_unit = 16; + +static void clear_track_vars( struct Gbs_Emu* this ) +{ + this->current_track_ = -1; + track_stop( &this->track_filter ); +} + +void Gbs_init( struct Gbs_Emu* this ) +{ + this->sample_rate_ = 0; + this->mute_mask_ = 0; + this->tempo_ = (int)(FP_ONE_TEMPO); + + // Unload + this->header.timer_mode = 0; + + // defaults + this->tfilter = *track_get_setup( &this->track_filter ); + this->tfilter.max_initial = 21; + this->tfilter.lookahead = 6; + this->track_filter.silence_ignored_ = false; + + Sound_set_gain( this, (int)(FP_ONE_GAIN*1.2) ); + + Rom_init( &this->rom, 0x4000 ); + + Apu_init( &this->apu ); + Cpu_init( &this->cpu ); + + this->tempo = tempo_unit; + this->sound_hardware = sound_gbs; + + // Reduce apu sound clicks? + Apu_reduce_clicks( &this->apu, true ); + + // clears fields + this->voice_count_ = 0; + this->voice_types_ = 0; + clear_track_vars( this ); +} + +static blargg_err_t check_gbs_header( void const* header ) +{ + if ( memcmp( header, "GBS", 3 ) ) + return gme_wrong_file_type; + return 0; +} + +// Setup + +blargg_err_t Gbs_load_mem( struct Gbs_Emu* this, void* data, long size ) +{ + // Unload + this->header.timer_mode = 0; + this->voice_count_ = 0; + this->track_count = 0; + this->m3u.size = 0; + clear_track_vars( this ); + + assert( offsetof (struct header_t,copyright [32]) == header_size ); + RETURN_ERR( Rom_load( &this->rom, data, size, header_size, &this->header, 0 ) ); + + RETURN_ERR( check_gbs_header( &this->header ) ); + + /* Ignore warnings? */ + /*if ( header_.vers != 1 ) + warning( "Unknown file version" ); + + if ( header_.timer_mode & 0x78 ) + warning( "Invalid timer mode" ); */ + + /* unsigned load_addr = get_le16( this->header.load_addr ); */ + /* if ( (header_.load_addr [1] | header_.init_addr [1] | header_.play_addr [1]) > 0x7F || + load_addr < 0x400 ) + warning( "Invalid load/init/play address" ); */ + + unsigned load_addr = get_le16( this->header.load_addr ); + /* if ( (this->header.load_addr [1] | this->header.init_addr [1] | this->header.play_addr [1]) > 0x7F || + load_addr < 0x400 ) + warning( "Invalid load/init/play address" ); */ + + this->cpu.rst_base = load_addr; + Rom_set_addr( &this->rom, load_addr ); + + this->voice_count_ = osc_count; + static int const types [osc_count] = { + wave_type+1, wave_type+2, wave_type+3, mixed_type+1 + }; + this->voice_types_ = types; + + Apu_volume( &this->apu, this->gain_ ); + + // Change clock rate & setup buffer + this->clock_rate_ = 4194304; + Buffer_clock_rate( &this->stereo_buf, 4194304 ); + RETURN_ERR( Buffer_set_channel_count( &this->stereo_buf, this->voice_count_, this->voice_types_ ) ); + this->buf_changed_count = Buffer_channels_changed_count( &this->stereo_buf ); + + // Post load + Sound_set_tempo( this, this->tempo_ ); + Sound_mute_voices( this, this->mute_mask_ ); + + // Set track count + this->track_count = this->header.track_count; + return 0; +} + +// Emulation + +// see gb_cpu_io.h for read/write functions + +void set_bank( struct Gbs_Emu* this, int n ) +{ + addr_t addr = mask_addr( n * this->rom.bank_size, this->rom.mask ); + if ( addr == 0 && this->rom.size > this->rom.bank_size ) + addr = this->rom.bank_size; // MBC1&2 behavior, bank 0 acts like bank 1 + Cpu_map_code( &this->cpu, this->rom.bank_size, this->rom.bank_size, Rom_at_addr( &this->rom, addr ) ); +} + +void update_timer( struct Gbs_Emu* this ) +{ + this->play_period = 70224 / tempo_unit; /// 59.73 Hz + + if ( this->header.timer_mode & 0x04 ) + { + // Using custom rate + static byte const rates [4] = { 6, 0, 2, 4 }; + // TODO: emulate double speed CPU mode rather than halving timer rate + int double_speed = this->header.timer_mode >> 7; + int shift = rates [this->ram [hi_page + 7] & 3] - double_speed; + this->play_period = (256 - this->ram [hi_page + 6]) << shift; + } + + this->play_period *= this->tempo; +} + +// Jumps to routine, given pointer to address in file header. Pushes idle_addr +// as return address, NOT old PC. +void jsr_then_stop( struct Gbs_Emu* this, byte const addr [] ) +{ + check( this->cpu.r.sp == get_le16( this->header.stack_ptr ) ); + this->cpu.r.pc = get_le16( addr ); + write_mem( this, --this->cpu.r.sp, idle_addr >> 8 ); + write_mem( this, --this->cpu.r.sp, idle_addr ); +} + +static blargg_err_t run_until( struct Gbs_Emu* this, int end ) +{ + this->end_time = end; + Cpu_set_time( &this->cpu, Cpu_time( &this->cpu ) - end ); + while ( true ) + { + run_cpu( this ); + if ( Cpu_time( &this->cpu ) >= 0 ) + break; + + if ( this->cpu.r.pc == idle_addr ) + { + if ( this->next_play > this->end_time ) + { + Cpu_set_time( &this->cpu, 0 ); + break; + } + + if ( Cpu_time( &this->cpu ) < this->next_play - this->end_time ) + Cpu_set_time( &this->cpu, this->next_play - this->end_time ); + this->next_play += this->play_period; + jsr_then_stop( this, this->header.play_addr ); + } + else if ( this->cpu.r.pc > 0xFFFF ) + { + /* warning( "PC wrapped around\n" ); */ + this->cpu.r.pc &= 0xFFFF; + } + else + { + /* warning( "Emulation error (illegal/unsupported instruction)" ); */ + this->cpu.r.pc = (this->cpu.r.pc + 1) & 0xFFFF; + Cpu_set_time( &this->cpu, Cpu_time( &this->cpu ) + 6 ); + } + } + + return 0; +} + +static blargg_err_t end_frame( struct Gbs_Emu* this, int end ) +{ + RETURN_ERR( run_until( this, end ) ); + + this->next_play -= end; + if ( this->next_play < 0 ) // happens when play routine takes too long + { + #if !defined(GBS_IGNORE_STARVED_PLAY) + check( false ); + #endif + this->next_play = 0; + } + + Apu_end_frame( &this->apu, end ); + + return 0; +} + +blargg_err_t run_clocks( struct Gbs_Emu* this, blip_time_t duration ) +{ + return end_frame( this, duration ); +} + +blargg_err_t play_( void* emu, int count, sample_t* out ) +{ + struct Gbs_Emu* this = (struct Gbs_Emu*) emu; + + int remain = count; + while ( remain ) + { + Buffer_disable_immediate_removal( &this->stereo_buf ); + remain -= Buffer_read_samples( &this->stereo_buf, &out [count - remain], remain ); + if ( remain ) + { + if ( this->buf_changed_count != Buffer_channels_changed_count( &this->stereo_buf ) ) + { + this->buf_changed_count = Buffer_channels_changed_count( &this->stereo_buf ); + + // Remute voices + Sound_mute_voices( this, this->mute_mask_ ); + } + int msec = Buffer_length( &this->stereo_buf ); + blip_time_t clocks_emulated = msec * this->clock_rate_ / 1000 - 100; + RETURN_ERR( run_clocks( this, clocks_emulated ) ); + assert( clocks_emulated ); + Buffer_end_frame( &this->stereo_buf, clocks_emulated ); + } + } + return 0; +} + +blargg_err_t Gbs_set_sample_rate( struct Gbs_Emu* this, int rate ) +{ + require( !this->sample_rate_ ); // sample rate can't be changed once set + Buffer_init( &this->stereo_buf ); + RETURN_ERR( Buffer_set_sample_rate( &this->stereo_buf, rate, 1000 / 20 ) ); + + // Set bass frequency + Buffer_bass_freq( &this->stereo_buf, 300 ); + + this->sample_rate_ = rate; + RETURN_ERR( track_init( &this->track_filter, this ) ); + this->tfilter.max_silence = 6 * stereo * this->sample_rate_; + return 0; +} + + +// Sound + +void Sound_mute_voice( struct Gbs_Emu* this, int index, bool mute ) +{ + require( (unsigned) index < (unsigned) this->voice_count_ ); + int bit = 1 << index; + int mask = this->mute_mask_ | bit; + if ( !mute ) + mask ^= bit; + Sound_mute_voices( this, mask ); +} + +void Sound_mute_voices( struct Gbs_Emu* this, int mask ) +{ + require( this->sample_rate_ ); // sample rate must be set first + this->mute_mask_ = mask; + + int i; + for ( i = this->voice_count_; i--; ) + { + if ( mask & (1 << i) ) + { + Apu_set_output( &this->apu, i, 0, 0, 0 ); + } + else + { + struct channel_t ch = Buffer_channel( &this->stereo_buf, i ); + assert( (ch.center && ch.left && ch.right) || + (!ch.center && !ch.left && !ch.right) ); // all or nothing + Apu_set_output( &this->apu, i, ch.center, ch.left, ch.right ); + } + } +} + +void Sound_set_tempo( struct Gbs_Emu* this, int t ) +{ + require( this->sample_rate_ ); // sample rate must be set first + int const min = (int)(FP_ONE_TEMPO*0.02); + int const max = (int)(FP_ONE_TEMPO*4.00); + if ( t < min ) t = min; + if ( t > max ) t = max; + this->tempo_ = t; + + this->tempo = (int) ((tempo_unit * FP_ONE_TEMPO) / t); + Apu_set_tempo( &this->apu, t ); + update_timer( this ); +} + +blargg_err_t Gbs_start_track( struct Gbs_Emu* this, int track ) +{ + clear_track_vars( this ); + + // Remap track if playlist available + if ( this->m3u.size > 0 ) { + struct entry_t* e = &this->m3u.entries[track]; + track = e->track; + } + + this->current_track_ = track; + Buffer_clear( &this->stereo_buf ); + + // Reset APU to state expected by most rips + static byte const sound_data [] = { + 0x80, 0xBF, 0x00, 0x00, 0xB8, // square 1 DAC disabled + 0x00, 0x3F, 0x00, 0x00, 0xB8, // square 2 DAC disabled + 0x7F, 0xFF, 0x9F, 0x00, 0xB8, // wave DAC disabled + 0x00, 0xFF, 0x00, 0x00, 0xB8, // noise DAC disabled + 0x77, 0xFF, 0x80, // max volume, all chans in center, power on + }; + + enum sound_t mode = this->sound_hardware; + if ( mode == sound_gbs ) + mode = (this->header.timer_mode & 0x80) ? sound_cgb : sound_dmg; + + Apu_reset( &this->apu, (enum gb_mode_t) mode, false ); + Apu_write_register( &this->apu, 0, 0xFF26, 0x80 ); // power on + int i; + for ( i = 0; i < (int) sizeof sound_data; i++ ) + Apu_write_register( &this->apu, 0, i + io_addr, sound_data [i] ); + Apu_end_frame( &this->apu, 1 ); // necessary to get click out of the way */ + + memset( this->ram, 0, 0x4000 ); + memset( this->ram + 0x4000, 0xFF, 0x1F80 ); + memset( this->ram + 0x5F80, 0, sizeof this->ram - 0x5F80 ); + this->ram [hi_page] = 0; // joypad reads back as 0 + this->ram [idle_addr - ram_addr] = 0xED; // illegal instruction + this->ram [hi_page + 6] = this->header.timer_modulo; + this->ram [hi_page + 7] = this->header.timer_mode; + + Cpu_reset( &this->cpu, this->rom.unmapped ); + Cpu_map_code( &this->cpu, ram_addr, 0x10000 - ram_addr, this->ram ); + Cpu_map_code( &this->cpu, 0, this->rom.bank_size, Rom_at_addr( &this->rom, 0 ) ); + set_bank( this, this->rom.size > this->rom.bank_size ); + + update_timer( this ); + this->next_play = this->play_period; + this->cpu.r.rp.fa = track; + this->cpu.r.sp = get_le16( this->header.stack_ptr ); + this->cpu_time = 0; + jsr_then_stop( this, this->header.init_addr ); + + // convert filter times to samples + struct setup_t s = this->tfilter; + s.max_initial *= this->sample_rate_ * stereo; + #ifdef GME_DISABLE_SILENCE_LOOKAHEAD + s.lookahead = 1; + #endif + track_setup( &this->track_filter, &s ); + + return track_start( &this->track_filter ); +} + + +// Track + +static int msec_to_samples( int msec, int sample_rate ) +{ + int sec = msec / 1000; + msec -= sec * 1000; + return (sec * sample_rate + msec * sample_rate / 1000) * stereo; +} + +int Track_tell( struct Gbs_Emu* this ) +{ + int rate = this->sample_rate_ * stereo; + int sec = track_sample_count( &this->track_filter ) / rate; + return sec * 1000 + (track_sample_count( &this->track_filter ) - sec * rate) * 1000 / rate; +} + +blargg_err_t Track_seek( struct Gbs_Emu* this, int msec ) +{ + int time = msec_to_samples( msec, this->sample_rate_ ); + if ( time < track_sample_count( &this->track_filter ) ) + RETURN_ERR( Gbs_start_track( this, this->current_track_ ) ); + return Track_skip( this, time - track_sample_count( &this->track_filter ) ); +} + +blargg_err_t skip_( void* emu, int count ) +{ + struct Gbs_Emu* this = (struct Gbs_Emu*) emu; + + // for long skip, mute sound + const int threshold = 32768; + if ( count > threshold ) + { + int saved_mute = this->mute_mask_; + Sound_mute_voices( this, ~0 ); + + int n = count - threshold/2; + n &= ~(2048-1); // round to multiple of 2048 + count -= n; + RETURN_ERR( skippy_( &this->track_filter, n ) ); + + Sound_mute_voices( this, saved_mute ); + } + + return skippy_( &this->track_filter, count ); +} + +blargg_err_t Track_skip( struct Gbs_Emu* this, int count ) +{ + require( this->current_track_ >= 0 ); // start_track() must have been called already + return track_skip( &this->track_filter, count ); +} + +void Track_set_fade( struct Gbs_Emu* this, int start_msec, int length_msec ) +{ + track_set_fade( &this->track_filter, msec_to_samples( start_msec, this->sample_rate_ ), + length_msec * this->sample_rate_ / (1000 / stereo) ); +} + +blargg_err_t Gbs_play( struct Gbs_Emu* this, int out_count, sample_t* out ) +{ + require( this->current_track_ >= 0 ); + require( out_count % stereo == 0 ); + return track_play( &this->track_filter, out_count, out ); +} diff --git a/lib/rbcodec/codecs/libgme/gbs_emu.h b/lib/rbcodec/codecs/libgme/gbs_emu.h new file mode 100644 index 0000000000..72671b4658 --- /dev/null +++ b/lib/rbcodec/codecs/libgme/gbs_emu.h @@ -0,0 +1,192 @@ +// Nintendo Game Boy GBS music file emulator + +// Game_Music_Emu 0.5.2 +#ifndef GBS_EMU_H +#define GBS_EMU_H + +#include "rom_data.h" +#include "multi_buffer.h" +#include "gb_apu.h" +#include "gb_cpu.h" +#include "m3u_playlist.h" +#include "track_filter.h" + +enum { joypad_addr = 0xFF00 }; +enum { ram_addr = 0xA000 }; +enum { hi_page = 0xFF00 - ram_addr }; +enum { io_base = 0xFF00 }; + +// Selects which sound hardware to use. AGB hardware is cleaner than the +// others. Doesn't take effect until next start_track(). +enum sound_t { + sound_dmg = mode_dmg, // Game Boy monochrome + sound_cgb = mode_cgb, // Game Boy Color + sound_agb = mode_agb, // Game Boy Advance + sound_gbs // Use DMG/CGB based on GBS (default) +}; + +// GBS file header +enum { header_size = 112 }; +struct header_t +{ + char tag [3]; + byte vers; + byte track_count; + byte first_track; + byte load_addr [2]; + byte init_addr [2]; + byte play_addr [2]; + byte stack_ptr [2]; + byte timer_modulo; + byte timer_mode; + char game [32]; + char author [32]; + char copyright [32]; +}; + +struct Gbs_Emu { + enum sound_t sound_hardware; + + int tempo; + + // timer + blip_time_t cpu_time; + blip_time_t end_time; + blip_time_t play_period; + blip_time_t next_play; + + // Sound + int clock_rate_; + int sample_rate_; + unsigned buf_changed_count; + int voice_count_; + int const* voice_types_; + int mute_mask_; + int gain_; + int tempo_; + + // track-specific + byte track_count; + int current_track_; + + // Larger items at the end + // Header for currently loaded file + struct header_t header; + + // M3u Playlist + struct M3u_Playlist m3u; + + struct setup_t tfilter; + struct Track_Filter track_filter; + + struct Gb_Apu apu; + struct Gb_Cpu cpu; + struct Multi_Buffer stereo_buf; + + // rom & ram + struct Rom_Data rom; + byte ram [0x4000 + 0x2000 + cpu_padding]; +}; + + +// Basic functionality +// Initializes Gbs_Emu structure +void Gbs_init( struct Gbs_Emu* this ); + +// Stops (clear) Gbs_Emu structure +void Gbs_stop( struct Gbs_Emu* this ); + +// Loads a file from memory +blargg_err_t Gbs_load_mem( struct Gbs_Emu* this, void* data, long size ); + +// Set output sample rate. Must be called only once before loading file. +blargg_err_t Gbs_set_sample_rate( struct Gbs_Emu* this, int sample_rate ); + +// Start a track, where 0 is the first track. Also clears warning string. +blargg_err_t Gbs_start_track( struct Gbs_Emu* this, int ); + +// Generate 'count' samples info 'buf'. Output is in stereo. Any emulation +// errors set warning string, and major errors also end track. +blargg_err_t Gbs_play( struct Gbs_Emu* this, int count, sample_t* buf ); + +// Track status/control +// Number of milliseconds (1000 msec = 1 second) played since beginning of track +int Track_tell( struct Gbs_Emu* this ); + +// Seek to new time in track. Seeking backwards or far forward can take a while. +blargg_err_t Track_seek( struct Gbs_Emu* this, int msec ); + +// Skip n samples +blargg_err_t Track_skip( struct Gbs_Emu* this, int n ); + +// Set start time and length of track fade out. Once fade ends track_ended() returns +// true. Fade time can be changed while track is playing. +void Track_set_fade( struct Gbs_Emu* this, int start_msec, int length_msec ); + +// True if a track has reached its end +static inline bool Track_ended( struct Gbs_Emu* this ) +{ + return track_ended( &this->track_filter ); +} + +// Disables automatic end-of-track detection and skipping of silence at beginning +static inline void Track_ignore_silence( struct Gbs_Emu* this, bool disable ) +{ + this->track_filter.silence_ignored_ = disable; +} + +// Get track length in milliseconds +static inline int Track_get_length( struct Gbs_Emu* this, int n ) +{ + int length = 120 * 1000; /* 2 minutes */ + if ( (this->m3u.size > 0) && (n < this->m3u.size) ) { + struct entry_t* entry = &this->m3u.entries [n]; + length = entry->length; + } + + return length; +} + + +// Sound customization +// Adjust song tempo, where 1.0 = normal, 0.5 = half speed, 2.0 = double speed. +// Track length as returned by track_info() assumes a tempo of 1.0. +void Sound_set_tempo( struct Gbs_Emu* this, int ); + +// Mute/unmute voice i, where voice 0 is first voice +void Sound_mute_voice( struct Gbs_Emu* this, int index, bool mute ); + +// Set muting state of all voices at once using a bit mask, where -1 mutes them all, +// 0 unmutes them all, 0x01 mutes just the first voice, etc. +void Sound_mute_voices( struct Gbs_Emu* this, int mask ); + +// Change overall output amplitude, where 1.0 results in minimal clamping. +// Must be called before set_sample_rate(). +static inline void Sound_set_gain( struct Gbs_Emu* this, int g ) +{ + assert( !this->sample_rate_ ); // you must set gain before setting sample rate + this->gain_ = g; +} + +// Emulation (You shouldn't touch these) + +blargg_err_t run_clocks( struct Gbs_Emu* this, blip_time_t duration ); +void set_bank( struct Gbs_Emu* this, int ); +void update_timer( struct Gbs_Emu* this ); + +// Runs CPU until time becomes >= 0 +void run_cpu( struct Gbs_Emu* this ); + +// Reads/writes memory and I/O +int read_mem( struct Gbs_Emu* this, addr_t addr ); +void write_mem( struct Gbs_Emu* this, addr_t addr, int data ); + +// Current time +static inline blip_time_t Time( struct Gbs_Emu* this ) +{ + return Cpu_time( &this->cpu ) + this->end_time; +} + +void jsr_then_stop( struct Gbs_Emu* this, byte const [] ); + +#endif diff --git a/lib/rbcodec/codecs/libgme/gme.h b/lib/rbcodec/codecs/libgme/gme.h new file mode 100644 index 0000000000..d6803704ce --- /dev/null +++ b/lib/rbcodec/codecs/libgme/gme.h @@ -0,0 +1,18 @@ +/* Game music emulator library C interface (also usable from C++) */ + +/* Game_Music_Emu 0.5.2 */ +#ifndef GME_H +#define GME_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Error string returned by library functions, or NULL if no error (success) */ +typedef const char* gme_err_t; + +#ifdef __cplusplus + } +#endif + +#endif diff --git a/lib/rbcodec/codecs/libgme/hes_apu.c b/lib/rbcodec/codecs/libgme/hes_apu.c new file mode 100644 index 0000000000..a9cd32c8aa --- /dev/null +++ b/lib/rbcodec/codecs/libgme/hes_apu.c @@ -0,0 +1,371 @@ +// Game_Music_Emu 0.5.2. http://www.slack.net/~ant/ + +#include "hes_apu.h" +#include + +/* Copyright (C) 2006 Shay Green. This module is free software; you +can redistribute it and/or modify it under the terms of the GNU Lesser +General Public License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. This +module is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +details. You should have received a copy of the GNU Lesser General Public +License along with this module; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ + +#include "blargg_source.h" + +enum { center_waves = 1 }; // reduces asymmetry and clamping when starting notes + +static void balance_changed( struct Hes_Apu* this, struct Hes_Osc* osc ) +{ + static short const log_table [32] = { // ~1.5 db per step + #define ENTRY( factor ) (short) (factor * amp_range / 31.0 + 0.5) + ENTRY( 0.000000 ),ENTRY( 0.005524 ),ENTRY( 0.006570 ),ENTRY( 0.007813 ), + ENTRY( 0.009291 ),ENTRY( 0.011049 ),ENTRY( 0.013139 ),ENTRY( 0.015625 ), + ENTRY( 0.018581 ),ENTRY( 0.022097 ),ENTRY( 0.026278 ),ENTRY( 0.031250 ), + ENTRY( 0.037163 ),ENTRY( 0.044194 ),ENTRY( 0.052556 ),ENTRY( 0.062500 ), + ENTRY( 0.074325 ),ENTRY( 0.088388 ),ENTRY( 0.105112 ),ENTRY( 0.125000 ), + ENTRY( 0.148651 ),ENTRY( 0.176777 ),ENTRY( 0.210224 ),ENTRY( 0.250000 ), + ENTRY( 0.297302 ),ENTRY( 0.353553 ),ENTRY( 0.420448 ),ENTRY( 0.500000 ), + ENTRY( 0.594604 ),ENTRY( 0.707107 ),ENTRY( 0.840896 ),ENTRY( 1.000000 ), + #undef ENTRY + }; + + int vol = (osc->control & 0x1F) - 0x1E * 2; + + int left = vol + (osc->balance >> 3 & 0x1E) + (this->balance >> 3 & 0x1E); + if ( left < 0 ) left = 0; + + int right = vol + (osc->balance << 1 & 0x1E) + (this->balance << 1 & 0x1E); + if ( right < 0 ) right = 0; + + // optimizing for the common case of being centered also allows easy + // panning using Effects_Buffer + + // Separate balance into center volume and additional on either left or right + osc->output [0] = osc->outputs [0]; // center + osc->output [1] = osc->outputs [2]; // right + int base = log_table [left ]; + int side = log_table [right] - base; + if ( side < 0 ) + { + base += side; + side = -side; + osc->output [1] = osc->outputs [1]; // left + } + + // Optimize when output is far left, center, or far right + if ( !base || osc->output [0] == osc->output [1] ) + { + base += side; + side = 0; + osc->output [0] = osc->output [1]; + osc->output [1] = NULL; + osc->last_amp [1] = 0; + } + + if ( center_waves ) + { + // TODO: this can leave a non-zero level in a buffer (minor) + osc->last_amp [0] += (base - osc->volume [0]) * 16; + osc->last_amp [1] += (side - osc->volume [1]) * 16; + } + + osc->volume [0] = base; + osc->volume [1] = side; +} + +void Apu_init( struct Hes_Apu* this ) +{ + struct Hes_Osc* osc = &this->oscs [osc_count]; + do + { + osc--; + osc->output [0] = NULL; + osc->output [1] = NULL; + osc->outputs [0] = NULL; + osc->outputs [1] = NULL; + osc->outputs [2] = NULL; + } + while ( osc != this->oscs ); + + Apu_reset( this ); +} + +void Apu_reset( struct Hes_Apu* this ) +{ + this->latch = 0; + this->balance = 0xFF; + + struct Hes_Osc* osc = &this->oscs [osc_count]; + do + { + osc--; + memset( osc, 0, offsetof (struct Hes_Osc,outputs) ); + osc->lfsr = 1; + osc->control = 0x40; + osc->balance = 0xFF; + } + while ( osc != this->oscs ); + + // Only last two oscs support noise + this->oscs [osc_count - 2].lfsr = 0x200C3; // equivalent to 1 in Fibonacci LFSR + this->oscs [osc_count - 1].lfsr = 0x200C3; +} + +void Apu_osc_output( struct Hes_Apu* this, int i, struct Blip_Buffer* center, struct Blip_Buffer* left, struct Blip_Buffer* right ) +{ + // Must be silent (all NULL), mono (left and right NULL), or stereo (none NULL) + require( !center || (center && !left && !right) || (center && left && right) ); + require( (unsigned) i < osc_count ); // fails if you pass invalid osc index + + if ( !center || !left || !right ) + { + left = center; + right = center; + } + + struct Hes_Osc* o = &this->oscs [i]; + o->outputs [0] = center; + o->outputs [1] = right; + o->outputs [2] = left; + balance_changed( this, o ); +} + +static void run_osc( struct Hes_Osc* o, struct Blip_Synth* syn, blip_time_t end_time ) +{ + int vol0 = o->volume [0]; + int vol1 = o->volume [1]; + int dac = o->dac; + + struct Blip_Buffer* out0 = o->output [0]; // cache often-used values + struct Blip_Buffer* out1 = o->output [1]; + if ( !(o->control & 0x80) ) + out0 = NULL; + + if ( out0 ) + { + // Update amplitudes + if ( out1 ) + { + int delta = dac * vol1 - o->last_amp [1]; + if ( delta ) + { + Synth_offset( syn, o->last_time, delta, out1 ); + Blip_set_modified( out1 ); + } + } + int delta = dac * vol0 - o->last_amp [0]; + if ( delta ) + { + Synth_offset( syn, o->last_time, delta, out0 ); + Blip_set_modified( out0 ); + } + + // Don't generate if silent + if ( !(vol0 | vol1) ) + out0 = NULL; + } + + // Generate noise + int noise = 0; + if ( o->lfsr ) + { + noise = o->noise & 0x80; + + blip_time_t time = o->last_time + o->noise_delay; + if ( time < end_time ) + { + int period = (~o->noise & 0x1F) * 128; + if ( !period ) + period = 64; + + if ( noise && out0 ) + { + unsigned lfsr = o->lfsr; + do + { + int new_dac = -(lfsr & 1); + lfsr = (lfsr >> 1) ^ (0x30061 & new_dac); + + int delta = (new_dac &= 0x1F) - dac; + if ( delta ) + { + dac = new_dac; + Synth_offset( syn, time, delta * vol0, out0 ); + if ( out1 ) + Synth_offset( syn, time, delta * vol1, out1 ); + } + time += period; + } + while ( time < end_time ); + + if ( !lfsr ) + { + lfsr = 1; + check( false ); + } + o->lfsr = lfsr; + + Blip_set_modified( out0 ); + if ( out1 ) + Blip_set_modified( out1 ); + } + else + { + // Maintain phase when silent + int count = (end_time - time + period - 1) / period; + time += count * period; + + // not worth it + //while ( count-- ) + // o->lfsr = (o->lfsr >> 1) ^ (0x30061 * (o->lfsr & 1)); + } + } + o->noise_delay = time - end_time; + } + + // Generate wave + blip_time_t time = o->last_time + o->delay; + if ( time < end_time ) + { + int phase = (o->phase + 1) & 0x1F; // pre-advance for optimal inner loop + int period = o->period * 2; + + if ( period >= 14 && out0 && !((o->control & 0x40) | noise) ) + { + do + { + int new_dac = o->wave [phase]; + phase = (phase + 1) & 0x1F; + int delta = new_dac - dac; + if ( delta ) + { + dac = new_dac; + Synth_offset( syn, time, delta * vol0, out0 ); + if ( out1 ) + Synth_offset( syn, time, delta * vol1, out1 ); + } + time += period; + } + while ( time < end_time ); + Blip_set_modified( out0 ); + if ( out1 ) + Blip_set_modified( out1 ); + } + else + { + // Maintain phase when silent + int count = end_time - time; + if ( !period ) + period = 1; + count = (count + period - 1) / period; + + phase += count; // phase will be masked below + time += count * period; + } + + // TODO: Find whether phase increments even when both volumes are zero. + // CAN'T simply check for out0 being non-NULL, since it could be NULL + // if channel is muted in player, but still has non-zero volume. + // City Hunter breaks when this check is removed. + if ( !(o->control & 0x40) && (vol0 | vol1) ) + o->phase = (phase - 1) & 0x1F; // undo pre-advance + } + o->delay = time - end_time; + check( o->delay >= 0 ); + + o->last_time = end_time; + o->dac = dac; + o->last_amp [0] = dac * vol0; + o->last_amp [1] = dac * vol1; +} + +void Apu_write_data( struct Hes_Apu* this, blip_time_t time, int addr, int data ) +{ + if ( addr == 0x800 ) + { + this->latch = data & 7; + } + else if ( addr == 0x801 ) + { + if ( this->balance != data ) + { + this->balance = data; + + struct Hes_Osc* osc = &this->oscs [osc_count]; + do + { + osc--; + run_osc( osc, &this->synth, time ); + balance_changed( this, this->oscs ); + } + while ( osc != this->oscs ); + } + } + else if ( this->latch < osc_count ) + { + struct Hes_Osc* osc = &this->oscs [this->latch]; + run_osc( osc, &this->synth, time ); + switch ( addr ) + { + case 0x802: + osc->period = (osc->period & 0xF00) | data; + break; + + case 0x803: + osc->period = (osc->period & 0x0FF) | ((data & 0x0F) << 8); + break; + + case 0x804: + if ( osc->control & 0x40 & ~data ) + osc->phase = 0; + osc->control = data; + balance_changed( this, osc ); + break; + + case 0x805: + osc->balance = data; + balance_changed( this, osc ); + break; + + case 0x806: + data &= 0x1F; + if ( !(osc->control & 0x40) ) + { + osc->wave [osc->phase] = data; + osc->phase = (osc->phase + 1) & 0x1F; + } + else if ( osc->control & 0x80 ) + { + osc->dac = data; + } + break; + + case 0x807: + osc->noise = data; + break; + + case 0x809: + if ( !(data & 0x80) && (data & 0x03) != 0 ) { + dprintf( "HES LFO not supported\n" ); + } + } + } +} + +void Apu_end_frame( struct Hes_Apu* this, blip_time_t end_time ) +{ + struct Hes_Osc* osc = &this->oscs [osc_count]; + do + { + osc--; + if ( end_time > osc->last_time ) + run_osc( osc, &this->synth, end_time ); + assert( osc->last_time >= end_time ); + osc->last_time -= end_time; + } + while ( osc != this->oscs ); +} diff --git a/lib/rbcodec/codecs/libgme/hes_apu.h b/lib/rbcodec/codecs/libgme/hes_apu.h new file mode 100644 index 0000000000..0265e6a3ad --- /dev/null +++ b/lib/rbcodec/codecs/libgme/hes_apu.h @@ -0,0 +1,66 @@ +// Turbo Grafx 16 (PC Engine) PSG sound chip emulator + +// Game_Music_Emu 0.5.2 +#ifndef HES_APU_H +#define HES_APU_H + +#include "blargg_common.h" +#include "blargg_source.h" +#include "blip_buffer.h" + +enum { amp_range = 0x8000 }; +enum { osc_count = 6 }; // 0 <= chan < osc_count + +// Registers are at io_addr to io_addr+io_size-1 +enum { apu_io_addr = 0x0800 }; +enum { apu_io_size = 10 }; + +struct Hes_Osc +{ + byte wave [32]; + int delay; + int period; + int phase; + + int noise_delay; + byte noise; + unsigned lfsr; + + byte control; + byte balance; + byte dac; + short volume [2]; + int last_amp [2]; + + blip_time_t last_time; + struct Blip_Buffer* output [2]; + struct Blip_Buffer* outputs [3]; +}; + +void Osc_run_until( struct Hes_Osc* this, struct Blip_Synth* synth, blip_time_t ); + +struct Hes_Apu { + + int latch; + int balance; + struct Blip_Synth synth; + struct Hes_Osc oscs [osc_count]; +}; + +// Init HES apu sound chip +void Apu_init( struct Hes_Apu* this ); + +// Reset HES apu couns chip +void Apu_reset( struct Hes_Apu* this ); + +void Apu_osc_output( struct Hes_Apu* this, int index, struct Blip_Buffer* center, struct Blip_Buffer* left, struct Blip_Buffer* right ); + +// Emulates to time t, then writes data to addr +void Apu_write_data( struct Hes_Apu* this, blip_time_t, int addr, int data ); + +// Emulates to time t, then subtracts t from the current time. +// OK if previous write call had time slightly after t. +void Apu_end_frame( struct Hes_Apu* this, blip_time_t ); + +static inline void Apu_volume( struct Hes_Apu* this, int v ) { Synth_volume( &this->synth, (v*9)/5 / osc_count / amp_range ); } +#endif diff --git a/lib/rbcodec/codecs/libgme/hes_apu_adpcm.c b/lib/rbcodec/codecs/libgme/hes_apu_adpcm.c new file mode 100644 index 0000000000..de9b894f5d --- /dev/null +++ b/lib/rbcodec/codecs/libgme/hes_apu_adpcm.c @@ -0,0 +1,297 @@ +// Game_Music_Emu 0.6-pre. http://www.slack.net/~ant/ + +#include "hes_apu_adpcm.h" + +/* Copyright (C) 2006-2008 Shay Green. This module is free software; you +can redistribute it and/or modify it under the terms of the GNU Lesser +General Public License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. This +module is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +details. You should have received a copy of the GNU Lesser General Public +License along with this module; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ + + +void Adpcm_init( struct Hes_Apu_Adpcm* this ) +{ + this->output = NULL; + memset( &this->state, 0, sizeof( this->state ) ); + Adpcm_reset( this ); +} + +void Adpcm_reset( struct Hes_Apu_Adpcm* this ) +{ + this->last_time = 0; + this->next_timer = 0; + this->last_amp = 0; + + memset( &this->state.pcmbuf, 0, sizeof(this->state.pcmbuf) ); + memset( &this->state.port, 0, sizeof(this->state.port) ); + + this->state.ad_sample = 0; + this->state.ad_ref_index = 0; + + this->state.addr = 0; + this->state.freq = 0; + this->state.writeptr = 0; + this->state.readptr = 0; + this->state.playflag = 0; + this->state.repeatflag = 0; + this->state.length = 0; + this->state.volume = 0xFF; + this->state.fadetimer = 0; + this->state.fadecount = 0; +} + +static short stepsize[49] = { + 16, 17, 19, 21, 23, 25, 28, + 31, 34, 37, 41, 45, 50, 55, + 60, 66, 73, 80, 88, 97, 107, + 118, 130, 143, 157, 173, 190, 209, + 230, 253, 279, 307, 337, 371, 408, + 449, 494, 544, 598, 658, 724, 796, + 876, 963,1060,1166,1282,1411,1552 +}; + +static int Adpcm_decode( struct Hes_Apu_Adpcm* this,int code ); +static int Adpcm_decode( struct Hes_Apu_Adpcm* this,int code ) +{ + struct State* state = &this->state; + int step = stepsize[state->ad_ref_index]; + int delta; + int c = code & 7; +#if 1 + delta = 0; + if ( c & 4 ) delta += step; + step >>= 1; + if ( c & 2 ) delta += step; + step >>= 1; + if ( c & 1 ) delta += step; + step >>= 1; + delta += step; +#else + delta = ( ( c + c + 1 ) * step ) / 8; // maybe faster, but introduces rounding +#endif + if ( c != code ) + { + state->ad_sample -= delta; + if ( state->ad_sample < -2048 ) + state->ad_sample = -2048; + } + else + { + state->ad_sample += delta; + if ( state->ad_sample > 2047 ) + state->ad_sample = 2047; + } + + static int const steps [8] = { + -1, -1, -1, -1, 2, 4, 6, 8 + }; + state->ad_ref_index += steps [c]; + if ( state->ad_ref_index < 0 ) + state->ad_ref_index = 0; + else if ( state->ad_ref_index > 48 ) + state->ad_ref_index = 48; + + return state->ad_sample; +} + +static void Adpcm_run_until( struct Hes_Apu_Adpcm* this, blip_time_t end_time ); +static void Adpcm_run_until( struct Hes_Apu_Adpcm* this, blip_time_t end_time ) +{ + struct State* state = &this->state; + int volume = state->volume; + int fadetimer = state->fadetimer; + int fadecount = state->fadecount; + int last_time = this->last_time; + int next_timer = this->next_timer; + int last_amp = this->last_amp; + + struct Blip_Buffer* output = this->output; // cache often-used values + + while ( state->playflag && last_time < end_time ) + { + while ( last_time >= next_timer ) + { + if ( fadetimer ) + { + if ( fadecount > 0 ) + { + fadecount--; + volume = 0xFF * fadecount / fadetimer; + } + else if ( fadecount < 0 ) + { + fadecount++; + volume = 0xFF - ( 0xFF * fadecount / fadetimer ); + } + } + next_timer += 7159; // 7159091/1000; + } + int amp; + if ( state->ad_low_nibble ) + { + amp = Adpcm_decode( this, state->pcmbuf[ state->playptr ] & 0x0F ); + state->ad_low_nibble = false; + state->playptr++; + state->playedsamplecount++; + if ( state->playedsamplecount == state->playlength ) + { + state->playflag = 0; + } + } + else + { + amp = Adpcm_decode( this, state->pcmbuf[ state->playptr ] >> 4 ); + state->ad_low_nibble = true; + } + amp = amp * volume / 0xFF; + int delta = amp - last_amp; + if ( output && delta ) + { + last_amp = amp; + Synth_offset_inline( &this->synth, last_time, delta, output ); + } + last_time += state->freq; + } + + if ( !state->playflag ) + { + while ( next_timer <= end_time ) next_timer += 7159; // 7159091/1000 + last_time = end_time; + } + + this->last_time = last_time; + this->next_timer = next_timer; + this->last_amp = last_amp; + state->volume = volume; + state->fadetimer = fadetimer; + state->fadecount = fadecount; +} + +void Adpcm_write_data( struct Hes_Apu_Adpcm* this, blip_time_t time, int addr, int data ) +{ + if ( time > this->last_time ) Adpcm_run_until( this, time ); + struct State* state = &this->state; + + data &= 0xFF; + state->port[ addr & 15 ] = data; + switch ( addr & 15 ) + { + case 8: + state->addr &= 0xFF00; + state->addr |= data; + break; + case 9: + state->addr &= 0xFF; + state->addr |= data << 8; + break; + case 10: + state->pcmbuf[ state->writeptr++ ] = data; + state->playlength ++; + break; + case 11: + dprintf("ADPCM DMA 0x%02X", data); + break; + case 13: + if ( data & 0x80 ) + { + state->addr = 0; + state->freq = 0; + state->writeptr = 0; + state->readptr = 0; + state->playflag = 0; + state->repeatflag = 0; + state->length = 0; + state->volume = 0xFF; + } + if ( ( data & 3 ) == 3 ) + { + state->writeptr = state->addr; + } + if ( data & 8 ) + { + state->readptr = state->addr ? state->addr - 1 : state->addr; + } + if ( data & 0x10 ) + { + state->length = state->addr; + } + state->repeatflag = data & 0x20; + state->playflag = data & 0x40; + if ( state->playflag ) + { + state->playptr = state->readptr; + state->playlength = state->length + 1; + state->playedsamplecount = 0; + state->ad_sample = 0; + state->ad_low_nibble = false; + } + break; + case 14: + state->freq = 7159091 / ( 32000 / ( 16 - ( data & 15 ) ) ); + break; + case 15: + switch ( data & 15 ) + { + case 0: + case 8: + case 12: + state->fadetimer = -100; + state->fadecount = state->fadetimer; + break; + case 10: + state->fadetimer = 5000; + state->fadecount = state->fadetimer; + break; + case 14: + state->fadetimer = 1500; + state->fadecount = state->fadetimer; + break; + } + break; + } +} + +int Adpcm_read_data( struct Hes_Apu_Adpcm* this, blip_time_t time, int addr ) +{ + if ( time > this->last_time ) Adpcm_run_until( this, time ); + + struct State* state = &this->state; + switch ( addr & 15 ) + { + case 10: + return state->pcmbuf [state->readptr++]; + case 11: + return state->port [11] & ~1; + case 12: + if (!state->playflag) + { + state->port [12] |= 1; + state->port [12] &= ~8; + } + else + { + state->port [12] &= ~1; + state->port [12] |= 8; + } + return state->port [12]; + case 13: + return state->port [13]; + } + + return 0xFF; +} + +void Adpcm_end_frame( struct Hes_Apu_Adpcm* this, blip_time_t end_time ) +{ + Adpcm_run_until( this, end_time ); + this->last_time -= end_time; + this->next_timer -= end_time; + check( last_time >= 0 ); + if ( this->output ) + Blip_set_modified( this->output ); +} diff --git a/lib/rbcodec/codecs/libgme/hes_apu_adpcm.h b/lib/rbcodec/codecs/libgme/hes_apu_adpcm.h new file mode 100644 index 0000000000..afe160bb9c --- /dev/null +++ b/lib/rbcodec/codecs/libgme/hes_apu_adpcm.h @@ -0,0 +1,89 @@ +// Turbo Grafx 16 (PC Engine) ADPCM sound chip emulator + +// Game_Music_Emu 0.6-pre +#ifndef HES_APU_ADPCM_H +#define HES_APU_ADPCM_H + +#include "blargg_source.h" +#include "blargg_common.h" +#include "blip_buffer.h" + +enum { adpcm_amp_range = 2048 }; +enum { adpcm_osc_count = 1 }; // 0 <= chan < osc_count + +// Registers are at io_addr to io_addr+io_size-1 +enum { adpcm_io_addr = 0x1800 }; +enum { adpcm_io_size = 0x400 }; + +struct State +{ + byte pcmbuf [0x10000]; + byte port [0x10]; + int ad_sample; + int ad_ref_index; + bool ad_low_nibble; + int freq; + unsigned short addr; + unsigned short writeptr; + unsigned short readptr; + unsigned short playptr; + byte playflag; + byte repeatflag; + int length; + int playlength; + int playedsamplecount; + int volume; + int fadetimer; + int fadecount; +}; + +struct Hes_Apu_Adpcm { + struct State state; + struct Blip_Synth synth; + + struct Blip_Buffer* output; + blip_time_t last_time; + int next_timer; + int last_amp; +}; + +// Init HES adpcm sound chip +void Adpcm_init( struct Hes_Apu_Adpcm* this ); + +// Rest HES adpcm sound chip +void Adpcm_reset( struct Hes_Apu_Adpcm* this ); + +// Sets buffer(s) to generate sound into, or 0 to mute. If only center is not 0, +// output is mono. +static inline void Adpcm_set_output( struct Hes_Apu_Adpcm* this, int chan, struct Blip_Buffer* center, struct Blip_Buffer* left, struct Blip_Buffer* right ) +{ + // Must be silent (all NULL), mono (left and right NULL), or stereo (none NULL) + require( !center || (center && !left && !right) || (center && left && right) ); + require( (unsigned) chan < adpcm_osc_count ); // fails if you pass invalid osc index + +#if defined(ROCKBOX) + (void) chan; +#endif + + if ( !center || !left || !right ) + { + left = center; + right = center; + } + + this->output = center; +} + +// Emulates to time t, then writes data to addr +void Adpcm_write_data( struct Hes_Apu_Adpcm* this, blip_time_t t, int addr, int data ); + +// Emulates to time t, then reads from addr +int Adpcm_read_data( struct Hes_Apu_Adpcm* this, blip_time_t t, int addr ); + +// Emulates to time t, then subtracts t from the current time. +// OK if previous write call had time slightly after t. +void Adpcm_end_frame( struct Hes_Apu_Adpcm* this,blip_time_t t ); + +// Sets overall volume, where 1.0 is normal +static inline void Adpcm_volume( struct Hes_Apu_Adpcm* this, int v ) { Synth_volume( &this->synth, (v*3)/5 / adpcm_osc_count / adpcm_amp_range ); } +#endif diff --git a/lib/rbcodec/codecs/libgme/hes_cpu.c b/lib/rbcodec/codecs/libgme/hes_cpu.c new file mode 100644 index 0000000000..6b833b3b98 --- /dev/null +++ b/lib/rbcodec/codecs/libgme/hes_cpu.c @@ -0,0 +1,121 @@ +// Game_Music_Emu 0.5.2. http://www.slack.net/~ant/ + +#include "hes_emu.h" + +#include "blargg_endian.h" + +//#include "hes_cpu_log.h" + +/* Copyright (C) 2003-2006 Shay Green. This module is free software; you +can redistribute it and/or modify it under the terms of the GNU Lesser +General Public License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. This +module is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +details. You should have received a copy of the GNU Lesser General Public +License along with this module; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ + +#include "blargg_source.h" +#define PAGE HES_CPU_PAGE + +int read_mem( struct Hes_Emu* this, hes_addr_t addr ) +{ + check( addr < 0x10000 ); + int result = *Cpu_get_code( &this->cpu, addr ); + if ( this->cpu.mmr [PAGE( addr )] == 0xFF ) + result = read_mem_( this, addr ); + return result; +} + +void write_mem( struct Hes_Emu* this, hes_addr_t addr, int data ) +{ + check( addr < 0x10000 ); + byte* out = this->write_pages [PAGE( addr )]; + if ( out ) + out [addr & (page_size - 1)] = data; + else if ( this->cpu.mmr [PAGE( addr )] == 0xFF ) + write_mem_( this, addr, data ); +} + +void set_mmr( struct Hes_Emu* this, int page, int bank ) +{ + this->write_pages [page] = 0; + byte* data = Rom_at_addr( &this->rom, bank * page_size ); + if ( bank >= 0x80 ) + { + data = 0; + switch ( bank ) + { + case 0xF8: + data = this->ram; + break; + + case 0xF9: + case 0xFA: + case 0xFB: + data = &this->sgx [(bank - 0xF9) * page_size]; + break; + + default: + /* if ( bank != 0xFF ) + dprintf( "Unmapped bank $%02X\n", bank ); */ + data = this->rom.unmapped; + goto end; + } + + this->write_pages [page] = data; + } +end: + Cpu_set_mmr( &this->cpu, page, bank, data ); +} + +#define READ_FAST( addr, out ) \ +{\ + out = READ_CODE( addr );\ + if ( cpu->mmr [PAGE( addr )] == 0xFF )\ + {\ + FLUSH_TIME();\ + out = read_mem_( this, addr );\ + CACHE_TIME();\ + }\ +} + +#define WRITE_FAST( addr, data ) \ +{\ + int page = PAGE( addr );\ + byte* out = this->write_pages [page];\ + addr &= page_size - 1;\ + if ( out )\ + {\ + out [addr] = data;\ + }\ + else if ( cpu->mmr [page] == 0xFF )\ + {\ + FLUSH_TIME();\ + write_mem_( this, addr, data );\ + CACHE_TIME();\ + }\ +} + +#define READ_LOW( addr ) (this->ram [addr]) +#define WRITE_LOW( addr, data ) (this->ram [addr] = data) +#define READ_MEM( addr ) read_mem( this, addr ) +#define WRITE_MEM( addr, data ) write_mem( this, addr, data ) +#define WRITE_VDP( addr, data ) write_vdp( this, addr, data ) +#define CPU_DONE( result_out ) { FLUSH_TIME(); result_out = cpu_done( this ); CACHE_TIME(); } +#define SET_MMR( reg, bank ) set_mmr( this, reg, bank ) + +#define IDLE_ADDR idle_addr + +#define CPU_BEGIN \ +bool run_cpu( struct Hes_Emu* this, hes_time_t end_time )\ +{\ + struct Hes_Cpu* cpu = &this->cpu;\ + Cpu_set_end_time( cpu, end_time ); + + #include "hes_cpu_run.h" + + return illegal_encountered; +} diff --git a/lib/rbcodec/codecs/libgme/hes_cpu.h b/lib/rbcodec/codecs/libgme/hes_cpu.h new file mode 100644 index 0000000000..0429eeaba0 --- /dev/null +++ b/lib/rbcodec/codecs/libgme/hes_cpu.h @@ -0,0 +1,132 @@ +// PC Engine CPU emulator for use with HES music files + +// Game_Music_Emu 0.6-pre +#ifndef HES_CPU_H +#define HES_CPU_H + +#include "blargg_common.h" +#include "blargg_source.h" + +typedef int hes_time_t; // clock cycle count +typedef int hes_addr_t; // 16-bit address + +struct Hes_Emu; + +enum { future_time = INT_MAX/2 + 1 }; +enum { page_bits = 13 }; +enum { page_size = 1 << page_bits }; +enum { page_count = 0x10000 / page_size }; + +// Can read this many bytes past end of a page +enum { cpu_padding = 8 }; +enum { irq_inhibit_mask = 0x04 }; +enum { idle_addr = 0x1FFF }; + +// Cpu state +struct cpu_state_t { + byte const* code_map [page_count + 1]; + hes_time_t base; + int time; +}; + +// NOT kept updated during emulation. +struct registers_t { + uint16_t pc; + byte a; + byte x; + byte y; + byte flags; + byte sp; +}; + +struct Hes_Cpu { + struct registers_t r; + + hes_time_t irq_time_; + hes_time_t end_time_; + + struct cpu_state_t* cpu_state; // points to state_ or a local copy within run() + struct cpu_state_t cpu_state_; + + // page mapping registers + uint8_t mmr [page_count + 1]; + uint8_t ram [page_size]; +}; + +// Init cpu state +static inline void Cpu_init( struct Hes_Cpu* this ) +{ + this->cpu_state = &this->cpu_state_; +} + +// Reset hes cpu +void Cpu_reset( struct Hes_Cpu* this ); + +// Set end_time and run CPU from current time. Returns true if any illegal +// instructions were encountered. +bool Cpu_run( struct Hes_Emu* this, hes_time_t end_time ); + +// Time of ning of next instruction to be executed +static inline hes_time_t Cpu_time( struct Hes_Cpu* this ) +{ + return this->cpu_state->time + this->cpu_state->base; +} + +static inline void Cpu_set_time( struct Hes_Cpu* this, hes_time_t t ) { this->cpu_state->time = t - this->cpu_state->base; } +static inline void Cpu_adjust_time( struct Hes_Cpu* this, int delta ) { this->cpu_state->time += delta; } + +#define HES_CPU_PAGE( addr ) ((unsigned) (addr) >> page_bits) + +#ifdef BLARGG_NONPORTABLE + #define HES_CPU_OFFSET( addr ) (addr) +#else + #define HES_CPU_OFFSET( addr ) ((addr) & (page_size - 1)) +#endif + +static inline uint8_t const* Cpu_get_code( struct Hes_Cpu* this, hes_addr_t addr ) +{ + return this->cpu_state_.code_map [HES_CPU_PAGE( addr )] + HES_CPU_OFFSET( addr ); +} + +static inline void update_end_time( struct Hes_Cpu* this, hes_time_t end, hes_time_t irq ) +{ + if ( end > irq && !(this->r.flags & irq_inhibit_mask) ) + end = irq; + + this->cpu_state->time += this->cpu_state->base - end; + this->cpu_state->base = end; +} + +static inline hes_time_t Cpu_end_time( struct Hes_Cpu* this ) { return this->end_time_; } + +static inline void Cpu_set_irq_time( struct Hes_Cpu* this, hes_time_t t ) +{ + this->irq_time_ = t; + update_end_time( this, this->end_time_, t ); +} + +static inline void Cpu_set_end_time( struct Hes_Cpu* this, hes_time_t t ) +{ + this->end_time_ = t; + update_end_time( this, t, this->irq_time_ ); +} + +static inline void Cpu_end_frame( struct Hes_Cpu* this, hes_time_t t ) +{ + assert( this->cpu_state == &this->cpu_state_ ); + this->cpu_state_.base -= t; + if ( this->irq_time_ < future_time ) this->irq_time_ -= t; + if ( this->end_time_ < future_time ) this->end_time_ -= t; +} + +static inline void Cpu_set_mmr( struct Hes_Cpu* this, int reg, int bank, void const* code ) +{ + assert( (unsigned) reg <= page_count ); // allow page past end to be set + assert( (unsigned) bank < 0x100 ); + this->mmr [reg] = bank; + byte const* p = STATIC_CAST(byte const*,code) - HES_CPU_OFFSET( reg << page_bits ); + this->cpu_state->code_map [reg] = p; + this->cpu_state_.code_map [reg] = p; +} + +#endif diff --git a/lib/rbcodec/codecs/libgme/hes_cpu_run.h b/lib/rbcodec/codecs/libgme/hes_cpu_run.h new file mode 100644 index 0000000000..bfba2b6109 --- /dev/null +++ b/lib/rbcodec/codecs/libgme/hes_cpu_run.h @@ -0,0 +1,1344 @@ +// Game_Music_Emu 0.6-pre. http://www.slack.net/~ant/ + +#if 0 +/* Define these macros in the source file before #including this file. +- Parameters might be expressions, so they are best evaluated only once, +though they NEVER have side-effects, so multiple evaluation is OK. +- Output parameters might be a multiple-assignment expression like "a=x", +so they must NOT be parenthesized. +- Except where noted, time() and related functions will NOT work +correctly inside a macro. TIME() is always correct, and FLUSH_TIME() and +CACHE_TIME() allow the time changing functions to work. +- Macros "returning" void may use a {} statement block. */ + + // 0 <= addr <= 0xFFFF + page_size + // time functions can be used + int READ_MEM( addr_t ); + void WRITE_MEM( addr_t, int data ); + + // 0 <= addr <= 0x1FF + int READ_LOW( addr_t ); + void WRITE_LOW( addr_t, int data ); + + // 0 <= addr <= 0xFFFF + page_size + // Used by common instructions. + int READ_FAST( addr_t, int& out ); + void WRITE_FAST( addr_t, int data ); + + // 0 <= addr <= 2 + // ST0, ST1, ST2 instructions + void WRITE_VDP( int addr, int data ); + +// The following can be used within macros: + + // Current time + hes_time_t TIME(); + + // Allows use of time functions + void FLUSH_TIME(); + + // Must be used before end of macro if FLUSH_TIME() was used earlier + void CACHE_TIME(); + +// Configuration (optional; commented behavior if defined) + + // Expanded just before beginning of code, to help debugger + #define CPU_BEGIN void my_run_cpu() { +#endif + +/* Copyright (C) 2003-2008 Shay Green. This module is free software; you +can redistribute it and/or modify it under the terms of the GNU Lesser +General Public License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. This +module is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +details. You should have received a copy of the GNU Lesser General Public +License along with this module; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ + +// TODO: support T flag, including clearing it at appropriate times? + +// all zero-page should really use whatever is at page 1, but that would +// reduce efficiency quite a bit +int const ram_addr = 0x2000; + +void Cpu_reset( struct Hes_Cpu* this ) +{ + check( this->cpu_state == &this->cpu_state_ ); + this->cpu_state = &this->cpu_state_; + + this->cpu_state_.time = 0; + this->cpu_state_.base = 0; + this->irq_time_ = future_time; + this->end_time_ = future_time; + + this->r.flags = 0x04; + this->r.sp = 0; + this->r.pc = 0; + this->r.a = 0; + this->r.x = 0; + this->r.y = 0; + + // Be sure "blargg_endian.h" has been #included + blargg_verify_byte_order(); +} + +// Allows MWCW debugger to step through code properly +#ifdef CPU_BEGIN + CPU_BEGIN +#endif + +// Time +#define TIME() (s_time + s.base) +#define FLUSH_TIME() {s.time = s_time;} +#define CACHE_TIME() {s_time = s.time;} + +// Memory +#define READ_STACK READ_LOW +#define WRITE_STACK WRITE_LOW + +#define CODE_PAGE( addr ) s.code_map [HES_CPU_PAGE( addr )] +#define CODE_OFFSET( addr ) HES_CPU_OFFSET( addr ) +#define READ_CODE( addr ) CODE_PAGE( addr ) [CODE_OFFSET( addr )] + +// Stack +#define SET_SP( v ) (sp = ((v) + 1) | 0x100) +#define GET_SP() ((sp - 1) & 0xFF) +#define SP( o ) ((sp + (o - (o>0)*0x100)) | 0x100) + +// Truncation +#define BYTE( n ) ((uint8_t ) (n)) /* (unsigned) n & 0xFF */ +#define SBYTE( n ) ((int8_t ) (n)) /* (BYTE( n ) ^ 0x80) - 0x80 */ +#define WORD( n ) ((uint16_t) (n)) /* (unsigned) n & 0xFFFF */ + +// Flags with hex value for clarity when used as mask. +// Stored in indicated variable during emulation. +int const n80 = 0x80; // nz +int const v40 = 0x40; // flags +//int const t20 = 0x20; +int const b10 = 0x10; +int const d08 = 0x08; // flags +int const i04 = 0x04; // flags +int const z02 = 0x02; // nz +int const c01 = 0x01; // c + +#define IS_NEG (nz & 0x8080) + +#define GET_FLAGS( out ) \ +{\ + out = flags & (v40 | d08 | i04);\ + out += ((nz >> 8) | nz) & n80;\ + out += c >> 8 & c01;\ + if ( !BYTE( nz ) )\ + out += z02;\ +} + +#define SET_FLAGS( in ) \ +{\ + flags = in & (v40 | d08 | i04);\ + c = nz = in << 8;\ + nz += ~in & z02;\ +} + +bool illegal_encountered = false; +{ + struct cpu_state_t s = cpu->cpu_state_; + cpu->cpu_state = &s; + // even on x86, using s.time in place of s_time was slower + int s_time = s.time; + + // registers + int pc = cpu->r.pc; + int a = cpu->r.a; + int x = cpu->r.x; + int y = cpu->r.y; + int sp; + SET_SP( cpu->r.sp ); + + // Flags + int flags; + int c; // carry set if (c & 0x100) != 0 + int nz; // Z set if (nz & 0xFF) == 0, N set if (nz & 0x8080) != 0 + { + int temp = cpu->r.flags; + SET_FLAGS( temp ); + } + +loop: + + #ifndef NDEBUG + { + hes_time_t correct = cpu->end_time_; + if ( !(flags & i04) && correct > cpu->irq_time_ ) + correct = cpu->irq_time_; + check( s.base == correct ); + /* + static int count; + if ( count == 1844 ) Debugger(); + if ( s.base != correct ) dprintf( "%ld\n", count ); + count++; + */ + } + #endif + + // Check all values + check( (unsigned) sp - 0x100 < 0x100 ); + check( (unsigned) pc < 0x10000 + 0x100 ); // +0x100 so emulator can catch wrap-around + check( (unsigned) a < 0x100 ); + check( (unsigned) x < 0x100 ); + check( (unsigned) y < 0x100 ); + + // Read instruction + byte const* instr = CODE_PAGE( pc ); + int opcode; + + if ( CODE_OFFSET(~0) == ~0 ) + { + opcode = instr [pc]; + pc++; + instr += pc; + } + else + { + instr += CODE_OFFSET( pc ); + opcode = *instr++; + pc++; + } + + // TODO: each reference lists slightly different timing values, ugh + static byte const clock_table [256] = + {// 0 1 2 3 4 5 6 7 8 9 A B C D E F + 1,7,3, 4,6,4,6,7,3,2,2,2,7,5,7,4,// 0 + 2,7,7, 4,6,4,6,7,2,5,2,2,7,5,7,4,// 1 + 7,7,3, 4,4,4,6,7,4,2,2,2,5,5,7,4,// 2 + 2,7,7, 2,4,4,6,7,2,5,2,2,5,5,7,4,// 3 + 7,7,3, 4,8,4,6,7,3,2,2,2,4,5,7,4,// 4 + 2,7,7, 5,2,4,6,7,2,5,3,2,2,5,7,4,// 5 + 7,7,2, 2,4,4,6,7,4,2,2,2,7,5,7,4,// 6 + 2,7,7,17,4,4,6,7,2,5,4,2,7,5,7,4,// 7 + 4,7,2, 7,4,4,4,7,2,2,2,2,5,5,5,4,// 8 + 2,7,7, 8,4,4,4,7,2,5,2,2,5,5,5,4,// 9 + 2,7,2, 7,4,4,4,7,2,2,2,2,5,5,5,4,// A + 2,7,7, 8,4,4,4,7,2,5,2,2,5,5,5,4,// B + 2,7,2,17,4,4,6,7,2,2,2,2,5,5,7,4,// C + 2,7,7,17,2,4,6,7,2,5,3,2,2,5,7,4,// D + 2,7,2,17,4,4,6,7,2,2,2,2,5,5,7,4,// E + 2,7,7,17,2,4,6,7,2,5,4,2,2,5,7,4 // F + }; // 0x00 was 8 + + // Update time + if ( s_time >= 0 ) + goto out_of_time; + + #ifdef HES_CPU_LOG_H + log_cpu( "new", pc - 1, opcode, instr [0], instr [1], instr [2], + instr [3], instr [4], instr [5], a, x, y ); + //log_opcode( opcode ); + #endif + + s_time += clock_table [opcode]; + + int data; + data = *instr; + + switch ( opcode ) + { +// Macros + +#define GET_MSB() (instr [1]) +#define ADD_PAGE( out ) (pc++, out = data + 0x100 * GET_MSB()); +#define GET_ADDR() GET_LE16( instr ) + +// TODO: is the penalty really always added? the original 6502 was much better +//#define PAGE_PENALTY( lsb ) (void) (s_time += (lsb) >> 8) +#define PAGE_PENALTY( lsb ) + +// Branch + +// TODO: more efficient way to handle negative branch that wraps PC around +#define BRANCH_( cond, adj )\ +{\ + pc++;\ + if ( !(cond) ) goto loop;\ + pc = (uint16_t) (pc + SBYTE( data ));\ + s_time += adj;\ + goto loop;\ +} + +#define BRANCH( cond ) BRANCH_( cond, 2 ) + + case 0xF0: // BEQ + BRANCH( !BYTE( nz ) ); + + case 0xD0: // BNE + BRANCH( BYTE( nz ) ); + + case 0x10: // BPL + BRANCH( !IS_NEG ); + + case 0x90: // BCC + BRANCH( !(c & 0x100) ) + + case 0x30: // BMI + BRANCH( IS_NEG ) + + case 0x50: // BVC + BRANCH( !(flags & v40) ) + + case 0x70: // BVS + BRANCH( flags & v40 ) + + case 0xB0: // BCS + BRANCH( c & 0x100 ) + + case 0x80: // BRA + branch_taken: + BRANCH_( true, 0 ); + + case 0xFF: + #ifdef IDLE_ADDR + if ( pc == IDLE_ADDR + 1 ) + goto idle_done; + #endif + + pc = (uint16_t) pc; + + case 0x0F: // BBRn + case 0x1F: + case 0x2F: + case 0x3F: + case 0x4F: + case 0x5F: + case 0x6F: + case 0x7F: + case 0x8F: // BBSn + case 0x9F: + case 0xAF: + case 0xBF: + case 0xCF: + case 0xDF: + case 0xEF: { + // Make two copies of bits, one negated + int t = 0x101 * READ_LOW( data ); + t ^= 0xFF; + pc++; + data = GET_MSB(); + BRANCH( t & (1 << (opcode >> 4)) ) + } + + case 0x4C: // JMP abs + pc = GET_ADDR(); + goto loop; + + case 0x7C: // JMP (ind+X) + data += x; + case 0x6C:{// JMP (ind) + data += 0x100 * GET_MSB(); + pc = GET_LE16( &READ_CODE( data ) ); + goto loop; + } + +// Subroutine + + case 0x44: // BSR + WRITE_STACK( SP( -1 ), pc >> 8 ); + sp = SP( -2 ); + WRITE_STACK( sp, pc ); + goto branch_taken; + + case 0x20: { // JSR + int temp = pc + 1; + pc = GET_ADDR(); + WRITE_STACK( SP( -1 ), temp >> 8 ); + sp = SP( -2 ); + WRITE_STACK( sp, temp ); + goto loop; + } + + case 0x60: // RTS + pc = 1 + READ_STACK( sp ); + pc += 0x100 * READ_STACK( SP( 1 ) ); + sp = SP( 2 ); + goto loop; + + case 0x00: // BRK + goto handle_brk; + +// Common + + case 0xBD:{// LDA abs,X + PAGE_PENALTY( data + x ); + int addr = GET_ADDR() + x; + pc += 2; + READ_FAST( addr, nz ); + a = nz; + goto loop; + } + + case 0x9D:{// STA abs,X + int addr = GET_ADDR() + x; + pc += 2; + WRITE_FAST( addr, a ); + goto loop; + } + + case 0x95: // STA zp,x + data = BYTE( data + x ); + case 0x85: // STA zp + pc++; + WRITE_LOW( data, a ); + goto loop; + + case 0xAE:{// LDX abs + int addr = GET_ADDR(); + pc += 2; + READ_FAST( addr, nz ); + x = nz; + goto loop; + } + + case 0xA5: // LDA zp + a = nz = READ_LOW( data ); + pc++; + goto loop; + +// Load/store + + { + int addr; + case 0x91: // STA (ind),Y + addr = 0x100 * READ_LOW( BYTE( data + 1 ) ); + addr += READ_LOW( data ) + y; + pc++; + goto sta_ptr; + + case 0x81: // STA (ind,X) + data = BYTE( data + x ); + case 0x92: // STA (ind) + addr = 0x100 * READ_LOW( BYTE( data + 1 ) ); + addr += READ_LOW( data ); + pc++; + goto sta_ptr; + + case 0x99: // STA abs,Y + data += y; + case 0x8D: // STA abs + addr = data + 0x100 * GET_MSB(); + pc += 2; + sta_ptr: + WRITE_FAST( addr, a ); + goto loop; + } + + { + int addr; + case 0xA1: // LDA (ind,X) + data = BYTE( data + x ); + case 0xB2: // LDA (ind) + addr = 0x100 * READ_LOW( BYTE( data + 1 ) ); + addr += READ_LOW( data ); + pc++; + goto a_nz_read_addr; + + case 0xB1:// LDA (ind),Y + addr = READ_LOW( data ) + y; + PAGE_PENALTY( addr ); + addr += 0x100 * READ_LOW( BYTE( data + 1 ) ); + pc++; + goto a_nz_read_addr; + + case 0xB9: // LDA abs,Y + data += y; + PAGE_PENALTY( data ); + case 0xAD: // LDA abs + addr = data + 0x100 * GET_MSB(); + pc += 2; + a_nz_read_addr: + READ_FAST( addr, nz ); + a = nz; + goto loop; + } + + case 0xBE:{// LDX abs,y + PAGE_PENALTY( data + y ); + int addr = GET_ADDR() + y; + pc += 2; + FLUSH_TIME(); + x = nz = READ_MEM( addr ); + CACHE_TIME(); + goto loop; + } + + case 0xB5: // LDA zp,x + a = nz = READ_LOW( BYTE( data + x ) ); + pc++; + goto loop; + + case 0xA9: // LDA #imm + pc++; + a = data; + nz = data; + goto loop; + +// Bit operations + + case 0x3C: // BIT abs,x + data += x; + case 0x2C:{// BIT abs + int addr; + ADD_PAGE( addr ); + FLUSH_TIME(); + nz = READ_MEM( addr ); + CACHE_TIME(); + goto bit_common; + } + case 0x34: // BIT zp,x + data = BYTE( data + x ); + case 0x24: // BIT zp + data = READ_LOW( data ); + case 0x89: // BIT imm + nz = data; + bit_common: + pc++; + flags = (flags & ~v40) + (nz & v40); + if ( nz & a ) + goto loop; // Z should be clear, and nz must be non-zero if nz & a is + nz <<= 8; // set Z flag without affecting N flag + goto loop; + + { + int addr; + + case 0xB3: // TST abs,x + addr = GET_MSB() + x; + goto tst_abs; + + case 0x93: // TST abs + addr = GET_MSB(); + tst_abs: + addr += 0x100 * instr [2]; + pc++; + FLUSH_TIME(); + nz = READ_MEM( addr ); + CACHE_TIME(); + goto tst_common; + } + + case 0xA3: // TST zp,x + nz = READ_LOW( BYTE( GET_MSB() + x ) ); + goto tst_common; + + case 0x83: // TST zp + nz = READ_LOW( GET_MSB() ); + tst_common: + pc += 2; + flags = (flags & ~v40) + (nz & v40); + if ( nz & data ) + goto loop; // Z should be clear, and nz must be non-zero if nz & data is + nz <<= 8; // set Z flag without affecting N flag + goto loop; + + { + int addr; + case 0x0C: // TSB abs + case 0x1C: // TRB abs + addr = GET_ADDR(); + pc++; + goto txb_addr; + + // TODO: everyone lists different behaviors for the flags flags, ugh + case 0x04: // TSB zp + case 0x14: // TRB zp + addr = data + ram_addr; + txb_addr: + FLUSH_TIME(); + nz = a | READ_MEM( addr ); + if ( opcode & 0x10 ) + nz ^= a; // bits from a will already be set, so this clears them + flags = (flags & ~v40) + (nz & v40); + pc++; + WRITE_MEM( addr, nz ); + CACHE_TIME(); + goto loop; + } + + case 0x07: // RMBn + case 0x17: + case 0x27: + case 0x37: + case 0x47: + case 0x57: + case 0x67: + case 0x77: + pc++; + READ_LOW( data ) &= ~(1 << (opcode >> 4)); + goto loop; + + case 0x87: // SMBn + case 0x97: + case 0xA7: + case 0xB7: + case 0xC7: + case 0xD7: + case 0xE7: + case 0xF7: + pc++; + READ_LOW( data ) |= 1 << ((opcode >> 4) - 8); + goto loop; + +// Load/store + + case 0x9E: // STZ abs,x + data += x; + case 0x9C: // STZ abs + ADD_PAGE( data ); + pc++; + FLUSH_TIME(); + WRITE_MEM( data, 0 ); + CACHE_TIME(); + goto loop; + + case 0x74: // STZ zp,x + data = BYTE( data + x ); + case 0x64: // STZ zp + pc++; + WRITE_LOW( data, 0 ); + goto loop; + + case 0x94: // STY zp,x + data = BYTE( data + x ); + case 0x84: // STY zp + pc++; + WRITE_LOW( data, y ); + goto loop; + + case 0x96: // STX zp,y + data = BYTE( data + y ); + case 0x86: // STX zp + pc++; + WRITE_LOW( data, x ); + goto loop; + + case 0xB6: // LDX zp,y + data = BYTE( data + y ); + case 0xA6: // LDX zp + data = READ_LOW( data ); + case 0xA2: // LDX #imm + pc++; + x = data; + nz = data; + goto loop; + + case 0xB4: // LDY zp,x + data = BYTE( data + x ); + case 0xA4: // LDY zp + data = READ_LOW( data ); + case 0xA0: // LDY #imm + pc++; + y = data; + nz = data; + goto loop; + + case 0xBC: // LDY abs,X + data += x; + PAGE_PENALTY( data ); + case 0xAC:{// LDY abs + int addr = data + 0x100 * GET_MSB(); + pc += 2; + FLUSH_TIME(); + y = nz = READ_MEM( addr ); + CACHE_TIME(); + goto loop; + } + + { + int temp; + case 0x8C: // STY abs + temp = y; + if ( 0 ) + case 0x8E: // STX abs + temp = x; + int addr = GET_ADDR(); + pc += 2; + FLUSH_TIME(); + WRITE_MEM( addr, temp ); + CACHE_TIME(); + goto loop; + } + +// Compare + + case 0xEC:{// CPX abs + int addr = GET_ADDR(); + pc++; + FLUSH_TIME(); + data = READ_MEM( addr ); + CACHE_TIME(); + goto cpx_data; + } + + case 0xE4: // CPX zp + data = READ_LOW( data ); + case 0xE0: // CPX #imm + cpx_data: + nz = x - data; + pc++; + c = ~nz; + nz = BYTE( nz ); + goto loop; + + case 0xCC:{// CPY abs + int addr = GET_ADDR(); + pc++; + FLUSH_TIME(); + data = READ_MEM( addr ); + CACHE_TIME(); + goto cpy_data; + } + + case 0xC4: // CPY zp + data = READ_LOW( data ); + case 0xC0: // CPY #imm + cpy_data: + nz = y - data; + pc++; + c = ~nz; + nz = BYTE( nz ); + goto loop; + +// Logical + +#define ARITH_ADDR_MODES( op )\ + case op - 0x04: /* (ind,x) */\ + data = BYTE( data + x );\ + case op + 0x0D: /* (ind) */\ + data = 0x100 * READ_LOW( BYTE( data + 1 ) ) + READ_LOW( data );\ + goto ptr##op;\ + case op + 0x0C:{/* (ind),y */\ + int temp = READ_LOW( data ) + y;\ + PAGE_PENALTY( temp );\ + data = temp + 0x100 * READ_LOW( BYTE( data + 1 ) );\ + goto ptr##op;\ + }\ + case op + 0x10: /* zp,X */\ + data = BYTE( data + x );\ + case op + 0x00: /* zp */\ + data = READ_LOW( data );\ + goto imm##op;\ + case op + 0x14: /* abs,Y */\ + data += y;\ + goto ind##op;\ + case op + 0x18: /* abs,X */\ + data += x;\ + ind##op:\ + PAGE_PENALTY( data );\ + case op + 0x08: /* abs */\ + ADD_PAGE( data );\ + ptr##op:\ + FLUSH_TIME();\ + data = READ_MEM( data );\ + CACHE_TIME();\ + case op + 0x04: /* imm */\ + imm##op: + + ARITH_ADDR_MODES( 0xC5 ) // CMP + nz = a - data; + pc++; + c = ~nz; + nz = BYTE( nz ); + goto loop; + + ARITH_ADDR_MODES( 0x25 ) // AND + nz = (a &= data); + pc++; + goto loop; + + ARITH_ADDR_MODES( 0x45 ) // EOR + nz = (a ^= data); + pc++; + goto loop; + + ARITH_ADDR_MODES( 0x05 ) // ORA + nz = (a |= data); + pc++; + goto loop; + +// Add/subtract + + ARITH_ADDR_MODES( 0xE5 ) // SBC + data ^= 0xFF; + goto adc_imm; + + ARITH_ADDR_MODES( 0x65 ) // ADC + adc_imm: { + /* if ( flags & d08 ) + dprintf( "Decimal mode not supported\n" ); */ + int carry = c >> 8 & 1; + int ov = (a ^ 0x80) + carry + SBYTE( data ); + flags = (flags & ~v40) + (ov >> 2 & v40); + c = nz = a + data + carry; + pc++; + a = BYTE( nz ); + goto loop; + } + +// Shift/rotate + + case 0x4A: // LSR A + c = 0; + case 0x6A: // ROR A + nz = c >> 1 & 0x80; + c = a << 8; + nz += a >> 1; + a = nz; + goto loop; + + case 0x0A: // ASL A + nz = a << 1; + c = nz; + a = BYTE( nz ); + goto loop; + + case 0x2A: { // ROL A + nz = a << 1; + int temp = c >> 8 & 1; + c = nz; + nz += temp; + a = BYTE( nz ); + goto loop; + } + + case 0x5E: // LSR abs,X + data += x; + case 0x4E: // LSR abs + c = 0; + case 0x6E: // ROR abs + ror_abs: { + ADD_PAGE( data ); + FLUSH_TIME(); + int temp = READ_MEM( data ); + nz = (c >> 1 & 0x80) + (temp >> 1); + c = temp << 8; + goto rotate_common; + } + + case 0x3E: // ROL abs,X + data += x; + goto rol_abs; + + case 0x1E: // ASL abs,X + data += x; + case 0x0E: // ASL abs + c = 0; + case 0x2E: // ROL abs + rol_abs: + ADD_PAGE( data ); + nz = c >> 8 & 1; + FLUSH_TIME(); + nz += (c = READ_MEM( data ) << 1); + rotate_common: + pc++; + WRITE_MEM( data, BYTE( nz ) ); + CACHE_TIME(); + goto loop; + + case 0x7E: // ROR abs,X + data += x; + goto ror_abs; + + case 0x76: // ROR zp,x + data = BYTE( data + x ); + goto ror_zp; + + case 0x56: // LSR zp,x + data = BYTE( data + x ); + case 0x46: // LSR zp + c = 0; + case 0x66: // ROR zp + ror_zp: { + int temp = READ_LOW( data ); + nz = (c >> 1 & 0x80) + (temp >> 1); + c = temp << 8; + goto write_nz_zp; + } + + case 0x36: // ROL zp,x + data = BYTE( data + x ); + goto rol_zp; + + case 0x16: // ASL zp,x + data = BYTE( data + x ); + case 0x06: // ASL zp + c = 0; + case 0x26: // ROL zp + rol_zp: + nz = c >> 8 & 1; + nz += (c = READ_LOW( data ) << 1); + goto write_nz_zp; + +// Increment/decrement + +#define INC_DEC( reg, n ) reg = BYTE( nz = reg + n ); goto loop; + + case 0x1A: // INA + INC_DEC( a, +1 ) + + case 0xE8: // INX + INC_DEC( x, +1 ) + + case 0xC8: // INY + INC_DEC( y, +1 ) + + case 0x3A: // DEA + INC_DEC( a, -1 ) + + case 0xCA: // DEX + INC_DEC( x, -1 ) + + case 0x88: // DEY + INC_DEC( y, -1 ) + + case 0xF6: // INC zp,x + data = BYTE( data + x ); + case 0xE6: // INC zp + nz = 1; + goto add_nz_zp; + + case 0xD6: // DEC zp,x + data = BYTE( data + x ); + case 0xC6: // DEC zp + nz = -1; + add_nz_zp: + nz += READ_LOW( data ); + write_nz_zp: + pc++; + WRITE_LOW( data, nz ); + goto loop; + + case 0xFE: // INC abs,x + data = x + GET_ADDR(); + goto inc_ptr; + + case 0xEE: // INC abs + data = GET_ADDR(); + inc_ptr: + nz = 1; + goto inc_common; + + case 0xDE: // DEC abs,x + data = x + GET_ADDR(); + goto dec_ptr; + + case 0xCE: // DEC abs + data = GET_ADDR(); + dec_ptr: + nz = -1; + inc_common: + FLUSH_TIME(); + pc += 2; + nz += READ_MEM( data ); + WRITE_MEM( data, BYTE( nz ) ); + CACHE_TIME(); + goto loop; + +// Transfer + + case 0xA8: // TAY + y = nz = a; + goto loop; + + case 0x98: // TYA + a = nz = y; + goto loop; + + case 0xAA: // TAX + x = nz = a; + goto loop; + + case 0x8A: // TXA + a = nz = x; + goto loop; + + case 0x9A: // TXS + SET_SP( x ); // verified (no flag change) + goto loop; + + case 0xBA: // TSX + x = nz = GET_SP(); + goto loop; + + #define SWAP_REGS( r1, r2 ) {\ + int t = r1;\ + r1 = r2;\ + r2 = t;\ + goto loop;\ + } + + case 0x02: // SXY + SWAP_REGS( x, y ); + + case 0x22: // SAX + SWAP_REGS( a, x ); + + case 0x42: // SAY + SWAP_REGS( a, y ); + + case 0x62: // CLA + a = 0; + goto loop; + + case 0x82: // CLX + x = 0; + goto loop; + + case 0xC2: // CLY + y = 0; + goto loop; + +// Stack + + case 0x48: // PHA + sp = SP( -1 ); + WRITE_STACK( sp, a ); + goto loop; + + case 0x68: // PLA + a = nz = READ_STACK( sp ); + sp = SP( 1 ); + goto loop; + + case 0xDA: // PHX + sp = SP( -1 ); + WRITE_STACK( sp, x ); + goto loop; + + case 0x5A: // PHY + sp = SP( -1 ); + WRITE_STACK( sp, y ); + goto loop; + + case 0x40:{// RTI + pc = READ_STACK( SP( 1 ) ); + pc += READ_STACK( SP( 2 ) ) * 0x100; + int temp = READ_STACK( sp ); + sp = SP( 3 ); + data = flags; + SET_FLAGS( temp ); + cpu->r.flags = flags; // update externally-visible I flag + if ( (data ^ flags) & i04 ) + { + hes_time_t new_time = cpu->end_time_; + if ( !(flags & i04) && new_time > cpu->irq_time_ ) + new_time = cpu->irq_time_; + int delta = s.base - new_time; + s.base = new_time; + s_time += delta; + } + goto loop; + } + + case 0xFA: // PLX + x = nz = READ_STACK( sp ); + sp = SP( 1 ); + goto loop; + + case 0x7A: // PLY + y = nz = READ_STACK( sp ); + sp = SP( 1 ); + goto loop; + + case 0x28:{// PLP + int temp = READ_STACK( sp ); + sp = SP( 1 ); + int changed = flags ^ temp; + SET_FLAGS( temp ); + if ( !(changed & i04) ) + goto loop; // I flag didn't change + if ( flags & i04 ) + goto handle_sei; + goto handle_cli; + } + + case 0x08:{// PHP + int temp; + GET_FLAGS( temp ); + sp = SP( -1 ); + WRITE_STACK( sp, temp | b10 ); + goto loop; + } + +// Flags + + case 0x38: // SEC + c = 0x100; + goto loop; + + case 0x18: // CLC + c = 0; + goto loop; + + case 0xB8: // CLV + flags &= ~v40; + goto loop; + + case 0xD8: // CLD + flags &= ~d08; + goto loop; + + case 0xF8: // SED + flags |= d08; + goto loop; + + case 0x58: // CLI + if ( !(flags & i04) ) + goto loop; + flags &= ~i04; + handle_cli: { + //dprintf( "CLI at %d\n", TIME ); + cpu->r.flags = flags; // update externally-visible I flag + int delta = s.base - cpu->irq_time_; + if ( delta <= 0 ) + { + if ( TIME() < cpu->irq_time_ ) + goto loop; + goto delayed_cli; + } + s.base = cpu->irq_time_; + s_time += delta; + if ( s_time < 0 ) + goto loop; + + if ( delta >= s_time + 1 ) + { + // delayed irq until after next instruction + s.base += s_time + 1; + s_time = -1; + cpu->irq_time_ = s.base; // TODO: remove, as only to satisfy debug check in loop + goto loop; + } + + // TODO: implement + delayed_cli: + dprintf( "Delayed CLI not supported\n" ); + goto loop; + } + + case 0x78: // SEI + if ( flags & i04 ) + goto loop; + flags |= i04; + handle_sei: { + cpu->r.flags = flags; // update externally-visible I flag + int delta = s.base - cpu->end_time_; + s.base = cpu->end_time_; + s_time += delta; + if ( s_time < 0 ) + goto loop; + + dprintf( "Delayed SEI not supported\n" ); + goto loop; + } + +// Special + + case 0x53:{// TAM + int bits = data; // avoid using data across function call + pc++; + for ( int i = 0; i < 8; i++ ) + if ( bits & (1 << i) ) + SET_MMR( i, a ); + goto loop; + } + + case 0x43:{// TMA + pc++; + byte const* in = cpu->mmr; + do + { + if ( data & 1 ) + a = *in; + in++; + } + while ( (data >>= 1) != 0 ); + goto loop; + } + + case 0x03: // ST0 + case 0x13: // ST1 + case 0x23:{// ST2 + int addr = opcode >> 4; + if ( addr ) + addr++; + pc++; + FLUSH_TIME(); + WRITE_VDP( addr, data ); + CACHE_TIME(); + goto loop; + } + + case 0xEA: // NOP + goto loop; + + case 0x54: // CSL + dprintf( "CSL not supported\n" ); + illegal_encountered = true; + goto loop; + + case 0xD4: // CSH + goto loop; + + case 0xF4: { // SET + //int operand = GET_MSB(); + dprintf( "SET not handled\n" ); + //switch ( data ) + //{ + //} + illegal_encountered = true; + goto loop; + } + +// Block transfer + + { + int in_alt; + int in_inc; + int out_alt; + int out_inc; + + case 0xE3: // TIA + in_alt = 0; + goto bxfer_alt; + + case 0xF3: // TAI + in_alt = 1; + bxfer_alt: + in_inc = in_alt ^ 1; + out_alt = in_inc; + out_inc = in_alt; + goto bxfer; + + case 0xD3: // TIN + in_inc = 1; + out_inc = 0; + goto bxfer_no_alt; + + case 0xC3: // TDD + in_inc = -1; + out_inc = -1; + goto bxfer_no_alt; + + case 0x73: // TII + in_inc = 1; + out_inc = 1; + bxfer_no_alt: + in_alt = 0; + out_alt = 0; + bxfer: + { + int in = GET_LE16( instr + 0 ); + int out = GET_LE16( instr + 2 ); + int count = GET_LE16( instr + 4 ); + if ( !count ) + count = 0x10000; + pc += 6; + WRITE_STACK( SP( -1 ), y ); + WRITE_STACK( SP( -2 ), a ); + WRITE_STACK( SP( -3 ), x ); + FLUSH_TIME(); + do + { + // TODO: reads from $0800-$1400 in I/O page should do I/O + int t = READ_MEM( in ); + in = WORD( in + in_inc ); + s.time += 6; + if ( in_alt ) + in_inc = -in_inc; + WRITE_MEM( out, t ); + out = WORD( out + out_inc ); + if ( out_alt ) + out_inc = -out_inc; + } + while ( --count ); + CACHE_TIME(); + goto loop; + } + } + +// Illegal + + default: + check( (unsigned) opcode <= 0xFF ); + dprintf( "Illegal opcode $%02X at $%04X\n", (int) opcode, (int) pc - 1 ); + illegal_encountered = true; + goto loop; + } + assert( false ); // catch missing 'goto loop' or accidental 'break' + + int result_; +handle_brk: + pc++; + result_ = 6; + +interrupt: + { + s_time += 7; + + // Save PC and read vector + WRITE_STACK( SP( -1 ), pc >> 8 ); + WRITE_STACK( SP( -2 ), pc ); + pc = GET_LE16( &READ_CODE( 0xFFF0 ) + result_ ); + + // Save flags + int temp; + GET_FLAGS( temp ); + if ( result_ == 6 ) + temp |= b10; // BRK sets B bit + sp = SP( -3 ); + WRITE_STACK( sp, temp ); + + // Update I flag in externally-visible flags + flags &= ~d08; + cpu->r.flags = (flags |= i04); + + // Update time + int delta = s.base - cpu->end_time_; + if ( delta >= 0 ) + goto loop; + s_time += delta; + s.base = cpu->end_time_; + goto loop; + } + +idle_done: + s_time = 0; + +out_of_time: + pc--; + + // Optional action that triggers interrupt or changes irq/end time + #ifdef CPU_DONE + { + CPU_DONE( result_ ); + if ( result_ >= 0 ) + goto interrupt; + if ( s_time < 0 ) + goto loop; + } + #endif + + // Flush cached state + cpu->r.pc = pc; + cpu->r.sp = GET_SP(); + cpu->r.a = a; + cpu->r.x = x; + cpu->r.y = y; + + int temp; + GET_FLAGS( temp ); + cpu->r.flags = temp; + + cpu->cpu_state_.base = s.base; + cpu->cpu_state_.time = s_time; + cpu->cpu_state = &cpu->cpu_state_; +} diff --git a/lib/rbcodec/codecs/libgme/hes_emu.c b/lib/rbcodec/codecs/libgme/hes_emu.c new file mode 100644 index 0000000000..d6bafea334 --- /dev/null +++ b/lib/rbcodec/codecs/libgme/hes_emu.c @@ -0,0 +1,644 @@ +// Game_Music_Emu 0.5.2. http://www.slack.net/~ant/ + +#include "hes_emu.h" + +#include "blargg_endian.h" +#include "blargg_source.h" + +/* Copyright (C) 2006 Shay Green. This module is free software; you +can redistribute it and/or modify it under the terms of the GNU Lesser +General Public License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. This +module is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +details. You should have received a copy of the GNU Lesser General Public +License along with this module; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ + +int const timer_mask = 0x04; +int const vdp_mask = 0x02; +int const i_flag_mask = 0x04; +int const unmapped = 0xFF; + +int const period_60hz = 262 * 455; // scanlines * clocks per scanline + +const char gme_wrong_file_type [] = "Wrong file type for this emulator"; + +static void clear_track_vars( struct Hes_Emu* this ) +{ + this->current_track_ = -1; + track_stop( &this->track_filter ); +} + +void Hes_init( struct Hes_Emu* this ) +{ + this->sample_rate_ = 0; + this->mute_mask_ = 0; + this->tempo_ = (int)(FP_ONE_TEMPO); + + // defaults + this->tfilter = *track_get_setup( &this->track_filter ); + this->tfilter.max_initial = 2; + this->tfilter.lookahead = 6; + this->track_filter.silence_ignored_ = false; + + this->timer.raw_load = 0; + Sound_set_gain( this, (int)(FP_ONE_GAIN*1.11) ); + + Rom_init( &this->rom, 0x2000 ); + + Apu_init( &this->apu ); + Adpcm_init( &this->adpcm ); + Cpu_init( &this->cpu ); + + /* Set default track count */ + this->track_count = 255; + + // clears fields + this->voice_count_ = 0; + this->voice_types_ = 0; + clear_track_vars( this ); +} + +static blargg_err_t check_hes_header( void const* header ) +{ + if ( memcmp( header, "HESM", 4 ) ) + return gme_wrong_file_type; + return 0; +} + +// Setup + +blargg_err_t Hes_load_mem( struct Hes_Emu* this, void* data, long size ) +{ + // Unload + this->voice_count_ = 0; + this->track_count = 255; + this->m3u.size = 0; + clear_track_vars( this ); + + assert( offsetof (struct header_t,unused [4]) == header_size ); + RETURN_ERR( Rom_load( &this->rom, data, size, header_size, &this->header, unmapped ) ); + + RETURN_ERR( check_hes_header( this->header.tag ) ); + + /* if ( header_.vers != 0 ) + warning( "Unknown file version" ); + + if ( memcmp( header_.data_tag, "DATA", 4 ) ) + warning( "Data header missing" ); + + if ( memcmp( header_.unused, "\0\0\0\0", 4 ) ) + warning( "Unknown header data" ); */ + + // File spec supports multiple blocks, but I haven't found any, and + // many files have bad sizes in the only block, so it's simpler to + // just try to load the damn data as best as possible. + + int addr = get_le32( this->header.addr ); + /* int rom_size = get_le32( this->header.size ); */ + int const rom_max = 0x100000; + if ( (unsigned) addr >= (unsigned) rom_max ) + { + /* warning( "Invalid address" ); */ + addr &= rom_max - 1; + } + /* if ( (unsigned) (addr + size) > (unsigned) rom_max ) + warning( "Invalid size" ); + + if ( rom_size != rom.file_size() ) + { + if ( size <= rom.file_size() - 4 && !memcmp( rom.begin() + size, "DATA", 4 ) ) + warning( "Multiple DATA not supported" ); + else if ( size < rom.file_size() ) + warning( "Extra file data" ); + else + warning( "Missing file data" ); + } */ + + Rom_set_addr( &this->rom, addr ); + + this->voice_count_ = osc_count + adpcm_osc_count; + static int const types [osc_count + adpcm_osc_count] = { + wave_type+0, wave_type+1, wave_type+2, wave_type+3, mixed_type+0, mixed_type+1, mixed_type+2 + }; + this->voice_types_ = types; + + Apu_volume( &this->apu, this->gain_ ); + Adpcm_volume( &this->adpcm, this->gain_ ); + + // Setup buffer + this->clock_rate_ = 7159091; + Buffer_clock_rate( &this->stereo_buf, 7159091 ); + RETURN_ERR( Buffer_set_channel_count( &this->stereo_buf, this->voice_count_, this->voice_types_ ) ); + this->buf_changed_count = Buffer_channels_changed_count( &this->stereo_buf ); + + Sound_set_tempo( this, this->tempo_ ); + Sound_mute_voices( this, this->mute_mask_ ); + + return 0; +} + +// Emulation + +static void recalc_timer_load( struct Hes_Emu* this ) +{ + this->timer.load = this->timer.raw_load * this->timer_base + 1; +} + +// Hardware + +void run_until( struct Hes_Emu* this, hes_time_t present ) +{ + while ( this->vdp.next_vbl < present ) + this->vdp.next_vbl += this->play_period; + + hes_time_t elapsed = present - this->timer.last_time; + if ( elapsed > 0 ) + { + if ( this->timer.enabled ) + { + this->timer.count -= elapsed; + if ( this->timer.count <= 0 ) + this->timer.count += this->timer.load; + } + this->timer.last_time = present; + } +} + +void write_vdp( struct Hes_Emu* this, int addr, int data ) +{ + switch ( addr ) + { + case 0: + this->vdp.latch = data & 0x1F; + break; + + case 2: + if ( this->vdp.latch == 5 ) + { + /* if ( data & 0x04 ) + warning( "Scanline interrupt unsupported" ); */ + run_until( this, Cpu_time( &this->cpu ) ); + this->vdp.control = data; + irq_changed( this ); + } + /* else + { + dprintf( "VDP not supported: $%02X <- $%02X\n", vdp.latch, data ); + } */ + break; + + case 3: + /* dprintf( "VDP MSB not supported: $%02X <- $%02X\n", vdp.latch, data ); */ + break; + } +} + +void write_mem_( struct Hes_Emu* this, hes_addr_t addr, int data ) +{ + hes_time_t time = Cpu_time( &this->cpu ); + if ( (unsigned) (addr - apu_io_addr) < apu_io_size ) + { + // Avoid going way past end when a long block xfer is writing to I/O space. + // Not a problem for other registers below because they don't write to + // Blip_Buffer. + hes_time_t t = min( time, Cpu_end_time( &this->cpu ) + 8 ); + Apu_write_data( &this->apu, t, addr, data ); + return; + } + if ( (unsigned) (addr - adpcm_io_addr) < adpcm_io_size ) + { + hes_time_t t = min( time, Cpu_end_time( &this->cpu ) + 6 ); + Adpcm_write_data( &this->adpcm, t, addr, data ); + return; + } + + switch ( addr ) + { + case 0x0000: + case 0x0002: + case 0x0003: + write_vdp( this, addr, data ); + return; + + case 0x0C00: { + run_until( this, time ); + this->timer.raw_load = (data & 0x7F) + 1; + recalc_timer_load( this ); + this->timer.count = this->timer.load; + break; + } + + case 0x0C01: + data &= 1; + if ( this->timer.enabled == data ) + return; + run_until( this, time ); + this->timer.enabled = data; + if ( data ) + this->timer.count = this->timer.load; + break; + + case 0x1402: + run_until( this, time ); + this->irq.disables = data; + /* if ( (data & 0xF8) && (data & 0xF8) != 0xF8 ) // flag questionable values + dprintf( "Int mask: $%02X\n", data ); */ + break; + + case 0x1403: + run_until( this, time ); + if ( this->timer.enabled ) + this->timer.count = this->timer.load; + this->timer.fired = false; + break; + +#ifndef NDEBUG + case 0x1000: // I/O port + case 0x0402: // palette + case 0x0403: + case 0x0404: + case 0x0405: + return; + + default: + /* dprintf( "unmapped write $%04X <- $%02X\n", addr, data ); */ + return; +#endif + } + + irq_changed( this ); +} + +int read_mem_( struct Hes_Emu* this, hes_addr_t addr ) +{ + hes_time_t time = Cpu_time( &this->cpu ); + addr &= page_size - 1; + switch ( addr ) + { + case 0x0000: + if ( this->irq.vdp > time ) + return 0; + this->irq.vdp = future_time; + run_until( this, time ); + irq_changed( this ); + return 0x20; + + /* case 0x0002: + case 0x0003: + dprintf( "VDP read not supported: %d\n", addr ); + return 0; */ + + case 0x0C01: + //return timer.enabled; // TODO: remove? + case 0x0C00: + run_until( this, time ); + /* dprintf( "Timer count read\n" ); */ + return (unsigned) (this->timer.count - 1) / this->timer_base; + + case 0x1402: + return this->irq.disables; + + case 0x1403: + { + int status = 0; + if ( this->irq.timer <= time ) status |= timer_mask; + if ( this->irq.vdp <= time ) status |= vdp_mask; + return status; + } + + case 0x180A: + case 0x180B: + case 0x180C: + case 0x180D: + return Adpcm_read_data( &this->adpcm, time, addr ); + + #ifndef NDEBUG + case 0x1000: // I/O port + //case 0x180C: // CD-ROM + //case 0x180D: + break; + + /* default: + dprintf( "unmapped read $%04X\n", addr ); */ + #endif + } + + return unmapped; +} + +void irq_changed( struct Hes_Emu* this ) +{ + hes_time_t present = Cpu_time( &this->cpu ); + + if ( this->irq.timer > present ) + { + this->irq.timer = future_time; + if ( this->timer.enabled && !this->timer.fired ) + this->irq.timer = present + this->timer.count; + } + + if ( this->irq.vdp > present ) + { + this->irq.vdp = future_time; + if ( this->vdp.control & 0x08 ) + this->irq.vdp = this->vdp.next_vbl; + } + + hes_time_t time = future_time; + if ( !(this->irq.disables & timer_mask) ) time = this->irq.timer; + if ( !(this->irq.disables & vdp_mask) ) time = min( time, this->irq.vdp ); + + Cpu_set_irq_time( &this->cpu, time ); +} + +int cpu_done( struct Hes_Emu* this ) +{ + check( Cpu_time( &this->cpu ) >= Cpu_end_time( &this->cpu ) || + (!(this->cpu.r.flags & i_flag_mask) && Cpu_time( &this->cpu ) >= Cpu_irq_time( &this->cpu )) ); + + if ( !(this->cpu.r.flags & i_flag_mask) ) + { + hes_time_t present = Cpu_time( &this->cpu ); + + if ( this->irq.timer <= present && !(this->irq.disables & timer_mask) ) + { + this->timer.fired = true; + this->irq.timer = future_time; + irq_changed( this ); // overkill, but not worth writing custom code + return 0x0A; + } + + if ( this->irq.vdp <= present && !(this->irq.disables & vdp_mask) ) + { + // work around for bugs with music not acknowledging VDP + //run_until( present ); + //irq.vdp = cpu.future_time; + //irq_changed(); + return 0x08; + } + } + return -1; +} + +static void adjust_time( hes_time_t* time, hes_time_t delta ) +{ + if ( *time < future_time ) + { + *time -= delta; + if ( *time < 0 ) + *time = 0; + } +} + +static blargg_err_t end_frame( struct Hes_Emu* this, hes_time_t duration ) +{ + /* if ( run_cpu( this, duration ) ) + warning( "Emulation error (illegal instruction)" ); */ + run_cpu( this, duration ); + + check( Cpu_time( &this->cpu ) >= duration ); + //check( time() - duration < 20 ); // Txx instruction could cause going way over + + run_until( this, duration ); + + // end time frame + this->timer.last_time -= duration; + this->vdp.next_vbl -= duration; + Cpu_end_frame( &this->cpu, duration ); + adjust_time( &this->irq.timer, duration ); + adjust_time( &this->irq.vdp, duration ); + Apu_end_frame( &this->apu, duration ); + Adpcm_end_frame( &this->adpcm, duration ); + + return 0; +} + +static blargg_err_t run_clocks( struct Hes_Emu* this, blip_time_t* duration_ ) +{ + return end_frame( this, *duration_ ); +} + +blargg_err_t play_( void *emu, int count, sample_t out [] ) +{ + struct Hes_Emu* this = (struct Hes_Emu*) emu; + + int remain = count; + while ( remain ) + { + Buffer_disable_immediate_removal( &this->stereo_buf ); + remain -= Buffer_read_samples( &this->stereo_buf, &out [count - remain], remain ); + if ( remain ) + { + if ( this->buf_changed_count != Buffer_channels_changed_count( &this->stereo_buf ) ) + { + this->buf_changed_count = Buffer_channels_changed_count( &this->stereo_buf ); + + // Remute voices + Sound_mute_voices( this, this->mute_mask_ ); + } + int msec = Buffer_length( &this->stereo_buf ); + blip_time_t clocks_emulated = msec * this->clock_rate_ / 1000 - 100; + RETURN_ERR( run_clocks( this, &clocks_emulated ) ); + assert( clocks_emulated ); + Buffer_end_frame( &this->stereo_buf, clocks_emulated ); + } + } + return 0; +} + +// Music emu + +blargg_err_t Hes_set_sample_rate( struct Hes_Emu* this, int rate ) +{ + require( !this->sample_rate_ ); // sample rate can't be changed once set + Buffer_init( &this->stereo_buf ); + RETURN_ERR( Buffer_set_sample_rate( &this->stereo_buf, rate, 1000 / 20 ) ); + + // Set bass frequency + Buffer_bass_freq( &this->stereo_buf, 60 ); + + this->sample_rate_ = rate; + RETURN_ERR( track_init( &this->track_filter, this ) ); + this->tfilter.max_silence = 6 * stereo * this->sample_rate_; + return 0; +} + +void Sound_mute_voice( struct Hes_Emu* this, int index, bool mute ) +{ + require( (unsigned) index < (unsigned) this->voice_count_ ); + int bit = 1 << index; + int mask = this->mute_mask_ | bit; + if ( !mute ) + mask ^= bit; + Sound_mute_voices( this, mask ); +} + +void Sound_mute_voices( struct Hes_Emu* this, int mask ) +{ + require( this->sample_rate_ ); // sample rate must be set first + this->mute_mask_ = mask; + + // Set adpcm voice + struct channel_t ch = Buffer_channel( &this->stereo_buf, this->voice_count_ ); + if ( mask & (1 << this->voice_count_ ) ) + Adpcm_set_output( &this->adpcm, 0, 0, 0, 0 ); + else + Adpcm_set_output( &this->adpcm, 0, ch.center, ch.left, ch.right ); + + // Set apu voices + int i = this->voice_count_ - 1; + for ( ; i--; ) + { + if ( mask & (1 << i) ) + { + Apu_osc_output( &this->apu, i, 0, 0, 0 ); + } + else + { + struct channel_t ch = Buffer_channel( &this->stereo_buf, i ); + assert( (ch.center && ch.left && ch.right) || + (!ch.center && !ch.left && !ch.right) ); // all or nothing + Apu_osc_output( &this->apu, i, ch.center, ch.left, ch.right ); + } + } +} + +void Sound_set_tempo( struct Hes_Emu* this, int t ) +{ + require( this->sample_rate_ ); // sample rate must be set first + int const min = (int)(FP_ONE_TEMPO*0.02); + int const max = (int)(FP_ONE_TEMPO*4.00); + if ( t < min ) t = min; + if ( t > max ) t = max; + this->play_period = (hes_time_t) ((period_60hz*FP_ONE_TEMPO) / t); + this->timer_base = (int) ((1024*FP_ONE_TEMPO) / t); + recalc_timer_load( this ); + this->tempo_ = t; +} + +blargg_err_t Hes_start_track( struct Hes_Emu* this, int track ) +{ + clear_track_vars( this ); + + // Remap track if playlist available + if ( this->m3u.size > 0 ) { + struct entry_t* e = &this->m3u.entries[track]; + track = e->track; + } + + this->current_track_ = track; + + Buffer_clear( &this->stereo_buf ); + + memset( this->ram, 0, sizeof this->ram ); // some HES music relies on zero fill + memset( this->sgx, 0, sizeof this->sgx ); + + Apu_reset( &this->apu ); + Adpcm_reset( &this->adpcm ); + Cpu_reset( &this->cpu ); + + unsigned i; + for ( i = 0; i < sizeof this->header.banks; i++ ) + set_mmr( this, i, this->header.banks [i] ); + set_mmr( this, page_count, 0xFF ); // unmapped beyond end of address space + + this->irq.disables = timer_mask | vdp_mask; + this->irq.timer = future_time; + this->irq.vdp = future_time; + + this->timer.enabled = false; + this->timer.raw_load= 0x80; + this->timer.count = this->timer.load; + this->timer.fired = false; + this->timer.last_time = 0; + + this->vdp.latch = 0; + this->vdp.control = 0; + this->vdp.next_vbl = 0; + + this->ram [0x1FF] = (idle_addr - 1) >> 8; + this->ram [0x1FE] = (idle_addr - 1) & 0xFF; + this->cpu.r.sp = 0xFD; + this->cpu.r.pc = get_le16( this->header.init_addr ); + this->cpu.r.a = track; + + recalc_timer_load( this ); + + // convert filter times to samples + struct setup_t s = this->tfilter; + s.max_initial *= this->sample_rate_ * stereo; + #ifdef GME_DISABLE_SILENCE_LOOKAHEAD + s.lookahead = 1; + #endif + track_setup( &this->track_filter, &s ); + + return track_start( &this->track_filter ); +} + +// Tell/Seek + +static int msec_to_samples( int msec, int sample_rate ) +{ + int sec = msec / 1000; + msec -= sec * 1000; + return (sec * sample_rate + msec * sample_rate / 1000) * stereo; +} + +int Track_tell( struct Hes_Emu* this ) +{ + int rate = this->sample_rate_ * stereo; + int sec = track_sample_count( &this->track_filter ) / rate; + return sec * 1000 + (track_sample_count( &this->track_filter ) - sec * rate) * 1000 / rate; +} + +blargg_err_t Track_seek( struct Hes_Emu* this, int msec ) +{ + int time = msec_to_samples( msec, this->sample_rate_ ); + if ( time < track_sample_count( &this->track_filter ) ) + RETURN_ERR( Hes_start_track( this, this->current_track_ ) ); + return Track_skip( this, time - track_sample_count( &this->track_filter ) ); +} + +blargg_err_t skip_( void* emu, int count ) +{ + struct Hes_Emu* this = (struct Hes_Emu*) emu; + + // for long skip, mute sound + const int threshold = 32768; + if ( count > threshold ) + { + int saved_mute = this->mute_mask_; + Sound_mute_voices( this, ~0 ); + + int n = count - threshold/2; + n &= ~(2048-1); // round to multiple of 2048 + count -= n; + RETURN_ERR( skippy_( &this->track_filter, n ) ); + + Sound_mute_voices( this, saved_mute ); + } + + return skippy_( &this->track_filter, count ); +} + +blargg_err_t Track_skip( struct Hes_Emu* this, int count ) +{ + require( this->current_track_ >= 0 ); // start_track() must have been called already + return track_skip( &this->track_filter, count ); +} + +void Track_set_fade( struct Hes_Emu* this, int start_msec, int length_msec ) +{ + track_set_fade( &this->track_filter, msec_to_samples( start_msec, this->sample_rate_ ), + length_msec * this->sample_rate_ / (1000 / stereo) ); +} + +blargg_err_t Hes_play( struct Hes_Emu* this, int out_count, sample_t* out ) +{ + require( this->current_track_ >= 0 ); + require( out_count % stereo == 0 ); + return track_play( &this->track_filter, out_count, out ); +} diff --git a/lib/rbcodec/codecs/libgme/hes_emu.h b/lib/rbcodec/codecs/libgme/hes_emu.h new file mode 100644 index 0000000000..a1dd048498 --- /dev/null +++ b/lib/rbcodec/codecs/libgme/hes_emu.h @@ -0,0 +1,195 @@ +// TurboGrafx-16/PC Engine HES music file emulator + +// Game_Music_Emu 0.5.2 +#ifndef HES_EMU_H +#define HES_EMU_H + +#include "blargg_source.h" + +#include "multi_buffer.h" +#include "rom_data.h" +#include "hes_apu.h" +#include "hes_apu_adpcm.h" +#include "hes_cpu.h" +#include "m3u_playlist.h" +#include "track_filter.h" + +// HES file header +enum { info_offset = 0x20 }; +enum { header_size = 0x20 }; +struct header_t +{ + byte tag [4]; + byte vers; + byte first_track; + byte init_addr [2]; + byte banks [8]; + byte data_tag [4]; + byte size [4]; + byte addr [4]; + byte unused [4]; +}; + + +struct timer_t { + hes_time_t last_time; + int count; + int load; + int raw_load; + byte enabled; + byte fired; +}; + +struct vdp_t { + hes_time_t next_vbl; + byte latch; + byte control; +}; + +struct irq_t { + hes_time_t timer; + hes_time_t vdp; + byte disables; +}; + +struct Hes_Emu { + hes_time_t play_period; + int timer_base; + + struct timer_t timer; + struct vdp_t vdp; + struct irq_t irq; + + // Sound + int clock_rate_; + int sample_rate_; + unsigned buf_changed_count; + int voice_count_; + int const* voice_types_; + int mute_mask_; + int tempo_; + int gain_; + + // track-specific + byte track_count; + int current_track_; + + // Larger files at the end + // Header for currently loaded file + struct header_t header; + + // M3u Playlist + struct M3u_Playlist m3u; + + struct setup_t tfilter; + struct Track_Filter track_filter; + + // Hes Cpu + struct Hes_Cpu cpu; + struct Rom_Data rom; + + struct Hes_Apu apu; + struct Hes_Apu_Adpcm adpcm; + + struct Multi_Buffer stereo_buf; + + // rom & ram + byte* write_pages [page_count + 1]; // 0 if unmapped or I/O space + byte ram [page_size]; + byte sgx [3 * page_size + cpu_padding]; +}; + + +// Basic functionality +// Initializes Hes_Emu structure +void Hes_init( struct Hes_Emu* this ); + +// Stops (clear) Hes_Emu structure +void Hes_stop( struct Hes_Emu* this ); + +// Loads a file from memory +blargg_err_t Hes_load_mem( struct Hes_Emu* this, void* data, long size ); + +// Set output sample rate. Must be called only once before loading file. +blargg_err_t Hes_set_sample_rate( struct Hes_Emu* this, int sample_rate ); + +// Start a track, where 0 is the first track. Also clears warning string. +blargg_err_t Hes_start_track( struct Hes_Emu* this, int ); + +// Generate 'count' samples info 'buf'. Output is in stereo. Any emulation +// errors set warning string, and major errors also end track. +blargg_err_t Hes_play( struct Hes_Emu* this, int count, sample_t* buf ); + +// Track status/control +// Number of milliseconds (1000 msec = 1 second) played since ning of track +int Track_tell( struct Hes_Emu* this ); + +// Seek to new time in track. Seeking backwards or far forward can take a while. +blargg_err_t Track_seek( struct Hes_Emu* this, int msec ); + +// Skip n samples +blargg_err_t Track_skip( struct Hes_Emu* this, int n ); + +// Set start time and length of track fade out. Once fade ends track_ended() returns +// true. Fade time can be changed while track is playing. +void Track_set_fade( struct Hes_Emu* this, int start_msec, int length_msec ); + +// True if a track has reached its end +static inline bool Track_ended( struct Hes_Emu* this ) +{ + return track_ended( &this->track_filter ); +} + +// Disables automatic end-of-track detection and skipping of silence at beginning +static inline void Track_ignore_silence( struct Hes_Emu* this, bool disable ) +{ + this->track_filter.silence_ignored_ = disable; +} + +// Get track length in milliseconds +static inline int Track_get_length( struct Hes_Emu* this, int n ) +{ + int length = 120 * 1000; /* 2 minutes */ + if ( (this->m3u.size > 0) && (n < this->m3u.size) ) { + struct entry_t* entry = &this->m3u.entries [n]; + length = entry->length; + } + + return length; +} + + +// Sound customization +// Adjust song tempo, where 1.0 = normal, 0.5 = half speed, 2.0 = double speed. +// Track length as returned by track_info() assumes a tempo of 1.0. +void Sound_set_tempo( struct Hes_Emu* this, int ); + +// Mute/unmute voice i, where voice 0 is first voice +void Sound_mute_voice( struct Hes_Emu* this, int index, bool mute ); + +// Set muting state of all voices at once using a bit mask, where -1 mutes them all, +// 0 unmutes them all, 0x01 mutes just the first voice, etc. +void Sound_mute_voices( struct Hes_Emu* this, int mask ); + +// Change overall output amplitude, where 1.0 results in minimal clamping. +// Must be called before set_sample_rate(). +static inline void Sound_set_gain( struct Hes_Emu* this, int g ) +{ + assert( !this->sample_rate_ ); // you must set gain before setting sample rate + this->gain_ = g; +} + +// Emulation (You shouldn't touch these) + +void irq_changed( struct Hes_Emu* this ); +void run_until( struct Hes_Emu* this, hes_time_t ); +bool run_cpu( struct Hes_Emu* this, hes_time_t end ); +int read_mem_( struct Hes_Emu* this, hes_addr_t ); +int read_mem( struct Hes_Emu* this, hes_addr_t ); +void write_mem_( struct Hes_Emu* this, hes_addr_t, int data ); +void write_mem( struct Hes_Emu* this, hes_addr_t, int ); +void write_vdp( struct Hes_Emu* this, int addr, int data ); +void set_mmr( struct Hes_Emu* this, int reg, int bank ); +int cpu_done( struct Hes_Emu* this ); + +#endif diff --git a/lib/rbcodec/codecs/libgme/inflate/bbfuncs.c b/lib/rbcodec/codecs/libgme/inflate/bbfuncs.c new file mode 100644 index 0000000000..3b23c3b6db --- /dev/null +++ b/lib/rbcodec/codecs/libgme/inflate/bbfuncs.c @@ -0,0 +1,147 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include "bbfuncs.h" + +#if defined(ROCKBOX) +#include "codeclib.h" +#endif + +void error_die(const char* msg) +{ + (void)msg; +} + +void error_msg(const char* msg) +{ + (void)msg; +} + +size_t safe_read(struct mbreader_t *md, void *buf, size_t count) +{ + ssize_t n; + + do { + n = mbread(md, buf, count); + } while (n < 0&&n!=-1); + + return n; +} + +/* + * Read all of the supplied buffer from a file This does multiple reads as + *necessary. Returns the amount read, or -1 on an error. A short read is + *returned on an end of file. + */ +ssize_t full_read(struct mbreader_t *md, void *buf, size_t len) +{ + ssize_t cc; + ssize_t total; + + total = 0; + + while (len) + { + cc = safe_read(md, buf, len); + + if (cc < 0) + return cc; /* read() returns -1 on failure. */ + + if (cc == 0) + break; + + buf = ((char *)buf) + cc; + total += cc; + len -= cc; + } + + return total; +} + +/* Die with an error message if we can't read the entire buffer. */ +void xread(struct mbreader_t *md, void *buf, ssize_t count) +{ + if (count) + { + ssize_t size = full_read(md, buf, count); + if (size != count) + error_die("short read"); + } +} + +/* Die with an error message if we can't read one character. */ +unsigned char xread_char(struct mbreader_t *md) +{ + unsigned char tmp; + + xread(md, &tmp, 1); + + return tmp; +} + +void check_header_gzip(struct mbreader_t *src_md) +{ + union { + unsigned char raw[8]; + struct { + unsigned char method; + unsigned char flags; + unsigned int mtime; + unsigned char xtra_flags; + unsigned char os_flags; + } formatted; + } header; + + xread(src_md, header.raw, 8); + + /* Check the compression method */ + if (header.formatted.method != 8) + error_die("Unknown compression method"); + + if (header.formatted.flags & 0x04) + { + /* bit 2 set: extra field present */ + unsigned char extra_short; + + extra_short = xread_char(src_md) + (xread_char(src_md) << 8); + while (extra_short > 0) + { + /* Ignore extra field */ + xread_char(src_md); + extra_short--; + } + } + + /* Discard original name if any */ + if (header.formatted.flags & 0x08) + /* bit 3 set: original file name present */ + while(xread_char(src_md) != 0) ; + + /* Discard file comment if any */ + if (header.formatted.flags & 0x10) + /* bit 4 set: file comment present */ + while(xread_char(src_md) != 0) ; + + /* Read the header checksum */ + if (header.formatted.flags & 0x02) + { + xread_char(src_md); + xread_char(src_md); + } +} diff --git a/lib/rbcodec/codecs/libgme/inflate/bbfuncs.h b/lib/rbcodec/codecs/libgme/inflate/bbfuncs.h new file mode 100644 index 0000000000..fe03ec1a3c --- /dev/null +++ b/lib/rbcodec/codecs/libgme/inflate/bbfuncs.h @@ -0,0 +1,33 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#ifndef BBFUNCS_H +#define BBFUNCS_H + +#include "mbreader.h" + +void error_die(const char* msg); +void error_msg(const char* msg); +size_t safe_read(struct mbreader_t *md, void *buf, size_t count); +ssize_t full_read(struct mbreader_t *md, void *buf, size_t len); +void xread(struct mbreader_t *md, void *buf, ssize_t count); +unsigned char xread_char(struct mbreader_t *md); +void check_header_gzip(struct mbreader_t *md); + +#endif diff --git a/lib/rbcodec/codecs/libgme/inflate/inflate.c b/lib/rbcodec/codecs/libgme/inflate/inflate.c new file mode 100644 index 0000000000..130abe89be --- /dev/null +++ b/lib/rbcodec/codecs/libgme/inflate/inflate.c @@ -0,0 +1,1156 @@ +/* + * gunzip implementation for wikiviewer (c) Frederik M.J.V., 2006. + * some bug fixes by Adam Gashlin gunzip implementation for busybox + * + * Based on GNU gzip v1.2.4 Copyright (C) 1992-1993 Jean-loup Gailly. + * + * Originally adjusted for busybox by Sven Rudolph + * based on gzip sources + * + * Adjusted further by Erik Andersen to support files as + *well as stdin/stdout, and to generally behave itself wrt command line + *handling. + * + * General cleanup to better adhere to the style guide and make use of standard + *busybox functions by Glenn McGrath + * + * read_gz interface + associated hacking by Laurence Anderson + * + * Fixed huft_build() so decoding end-of-block code does not grab more bits than + *necessary (this is required by unzip applet), added inflate_cleanup() to free + *leaked bytebuffer memory (used in unzip.c), and some minor style guide + *cleanups by Ed Clark + * + * gzip (GNU zip) -- compress files with zip algorithm and 'compress' interface + *Copyright (C) 1992-1993 Jean-loup Gailly The unzip code was written and put in + *the public domain by Mark Adler. Portions of the lzw code are derived from the + *public domain 'compress' + * written by Spencer Thomas, Joe Orost, James Woods, Jim McKie, Steve Davies, + *Ken Turkowski, Dave Mack and Peter Jannesen. + * + * + * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. + */ + +#include +#ifndef NULL +#define NULL 0 +#endif +#define ENABLE_DESKTOP 0 +#define USE_DESKTOP(...) +#include "mallocer.h" +#include "bbfuncs.h" +#include "inflate.h" + +#define TRIM_FILE_ON_ERROR 1 + +typedef struct huft_s { + unsigned char e; /* number of extra bits or operation */ + unsigned char b; /* number of bits in this code or subcode */ + union { + unsigned short n; /* literal, length base, or distance base */ + struct huft_s *t; /* pointer to next level of table */ + } v; +} huft_t; + +/*static void *mainmembuf;*/ +static void *huftbuffer1; +static void *huftbuffer2; + +#define HUFT_MMP1 8 +#define HUFT_MMP2 9 + +static struct mbreader_t *gunzip_src_md; +static unsigned int gunzip_bytes_out; /* number of output bytes */ +static unsigned int gunzip_outbuf_count; /* bytes in output buffer */ + +/* gunzip_window size--must be a power of two, and at least 32K for zip's + deflate method */ +enum { + gunzip_wsize = 0x8000 +}; + +static unsigned char *gunzip_window; +static uint32_t ifl_total; + +static uint32_t gunzip_crc; + +/* If BMAX needs to be larger than 16, then h and x[] should be ulg. */ +#define BMAX 16 /* maximum bit length of any code (16 for explode) */ +#define N_MAX 288 /* maximum number of codes in any set */ + +/* bitbuffer */ +static unsigned int gunzip_bb; /* bit buffer */ +static unsigned char gunzip_bk; /* bits in bit buffer */ + +/* These control the size of the bytebuffer */ +static unsigned int bytebuffer_max = 0x8000; +static unsigned char *bytebuffer = NULL; +static unsigned int bytebuffer_offset = 0; +static unsigned int bytebuffer_size = 0; + +static const unsigned short mask_bits[] = { + 0x0000, 0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f, 0x00ff, + 0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff +}; + +/* Copy lengths for literal codes 257..285 */ +static const unsigned short cplens[] = { + 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51, 59, + 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0 +}; + +/* note: see note #13 above about the 258 in this list. */ +/* Extra bits for literal codes 257..285 */ +static const unsigned char cplext[] = { + 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, + 5, 5, 5, 0, 99, 99 +}; /* 99==invalid */ + +/* Copy offsets for distance codes 0..29 */ +static const unsigned short cpdist[] = { + 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513, + 769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577 +}; + +/* Extra bits for distance codes */ +static const unsigned char cpdext[] = { + 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, + 11, 11, 12, 12, 13, 13 +}; + +/* Tables for deflate from PKZIP's appnote.txt. */ +/* Order of the bit length code lengths */ +static const unsigned char border[] = { + 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 +}; + +static const uint32_t crc_table[256]= { + 0,1996959894,-301047508,-1727442502,124634137,1886057615, + -379345611,-1637575261,249268274,2044508324,-522852066, + -1747789432,162941995,2125561021,-407360249,-1866523247, + 498536548,1789927666,-205950648,-2067906082,450548861, + 1843258603,-187386543,-2083289657,325883990,1684777152, + -43845254,-1973040660,335633487,1661365465,-99664541, + -1928851979,997073096,1281953886,-715111964,-1570279054, + 1006888145,1258607687,-770865667,-1526024853,901097722, + 1119000684,-608450090,-1396901568,853044451,1172266101, + -589951537,-1412350631,651767980,1373503546,-925412992, + -1076862698,565507253,1454621731,-809855591,-1195530993, + 671266974,1594198024,-972236366,-1324619484,795835527, + 1483230225,-1050600021,-1234817731,1994146192,31158534, + -1731059524,-271249366,1907459465,112637215,-1614814043, + -390540237,2013776290,251722036,-1777751922,-519137256, + 2137656763,141376813,-1855689577,-429695999,1802195444, + 476864866,-2056965928,-228458418,1812370925,453092731, + -2113342271,-183516073,1706088902,314042704,-1950435094, + -54949764,1658658271,366619977,-1932296973,-69972891, + 1303535960,984961486,-1547960204,-725929758,1256170817, + 1037604311,-1529756563,-740887301,1131014506,879679996, + -1385723834,-631195440,1141124467,855842277,-1442165665, + -586318647,1342533948,654459306,-1106571248,-921952122, + 1466479909,544179635,-1184443383,-832445281,1591671054, + 702138776,-1328506846,-942167884,1504918807,783551873, + -1212326853,-1061524307,-306674912,-1698712650,62317068, + 1957810842,-355121351,-1647151185,81470997,1943803523, + -480048366,-1805370492,225274430,2053790376,-468791541, + -1828061283,167816743,2097651377,-267414716,-2029476910, + 503444072,1762050814,-144550051,-2140837941,426522225, + 1852507879,-19653770,-1982649376,282753626,1742555852, + -105259153,-1900089351,397917763,1622183637,-690576408, + -1580100738,953729732,1340076626,-776247311,-1497606297, + 1068828381,1219638859,-670225446,-1358292148,906185462, + 1090812512,-547295293,-1469587627,829329135,1181335161, + -882789492,-1134132454,628085408,1382605366,-871598187, + -1156888829,570562233,1426400815,-977650754,-1296233688, + 733239954,1555261956,-1026031705,-1244606671,752459403, + 1541320221,-1687895376,-328994266,1969922972,40735498, + -1677130071,-351390145,1913087877,83908371,-1782625662, + -491226604,2075208622,213261112,-1831694693,-438977011, + 2094854071,198958881,-2032938284,-237706686,1759359992, + 534414190,-2118248755,-155638181,1873836001,414664567, + -2012718362,-15766928,1711684554,285281116,-1889165569, + -127750551,1634467795,376229701,-1609899400,-686959890, + 1308918612,956543938,-1486412191,-799009033,1231636301, + 1047427035,-1362007478,-640263460,1088359270,936918000, + -1447252397,-558129467,1202900863,817233897,-1111625188, + -893730166,1404277552,615818150,-1160759803,-841546093, + 1423857449,601450431,-1285129682,-1000256840,1567103746, + 711928724,-1274298825,-1022587231,1510334235,755167117 +}; + +static unsigned int fill_bitbuffer(unsigned int bitbuffer, unsigned int *current, + const unsigned int required) +{ + while (*current < required) + { + if (bytebuffer_offset >= bytebuffer_size) + { + /* Leave the first 4 bytes empty so we can always unwind the + bitbuffer to the front of the bytebuffer, leave 4 bytes free at + end of tail so we can easily top up buffer in + check_trailer_gzip() */ + if (1 > (bytebuffer_size = safe_read(gunzip_src_md, &bytebuffer[4], + bytebuffer_max - 8))) + error_die("unexpected end of file"); + + bytebuffer_size += 4; + bytebuffer_offset = 4; + } + + bitbuffer |= ((unsigned int) bytebuffer[bytebuffer_offset]) << *current; + bytebuffer_offset++; + *current += 8; + } + return(bitbuffer); +} + +/* + * Free the malloc'ed tables built by huft_build(), which makes a linked list of + *the tables it made, with the links in a dummy first entry of each table. + * t: table to free + */ +static int huft_free(huft_t * t,unsigned char bufnum) +{ + wpw_reset_mempool(bufnum); + if(t==0) + { + } + + return 0; +} + +/* Given a list of code lengths and a maximum table size, make a set of tables + to decode that set of codes. Return zero on success, one if the given code + set is incomplete (the tables are still built in this case), two if the input + is invalid (all zero length codes or an oversubscribed set of lengths), and + three if not enough memory. + * + * b: code lengths in bits (all assumed <= BMAX) n: number of codes + *(assumed <= N_MAX) s: number of simple-valued codes (0..s-1) d: list of + *base values for non-simple codes e: list of extra bits for non-simple codes + *t: result: starting table m: maximum lookup bits, returns actual bufnum: + *the number of the memory pool to fetch memory from + */ +static +int huft_build(unsigned int *b, const unsigned int n, + const unsigned int s, const unsigned short *d, + const unsigned char *e, huft_t ** t, unsigned int *m, + unsigned char bufnum) +{ + unsigned a=0; /* counter for codes of length k */ + unsigned c[BMAX + 1]; /* bit length count table */ + unsigned eob_len=0; /* length of end-of-block code (value 256) */ + unsigned f=0; /* i repeats in table every f entries */ + int g=0; /* maximum code length */ + int htl=0; /* table level */ + unsigned i=0; /* counter, current code */ + unsigned j=0; /* counter */ + int k=0; /* number of bits in current code */ + unsigned *p; /* pointer into c[], b[], or v[] */ + huft_t *q; /* points to current table */ + huft_t r; /* table entry for structure assignment */ + huft_t *u[BMAX]; /* table stack */ + unsigned v[N_MAX]; /* values in order of bit length */ + int ws[BMAX+1]; /* bits decoded stack */ + int w=0; /* bits decoded */ + unsigned x[BMAX + 1]; /* bit offsets, then code stack */ + unsigned *xp; /* pointer into x */ + int y=0; /* number of dummy codes added */ + unsigned z=0; /* number of entries in current table */ + + /* Length of EOB code, if any */ + eob_len = n > 256 ? b[256] : BMAX; + + /* Generate counts for each bit length */ + memset((void *)c, 0, sizeof(c)); + p = b; + i = n; + do { + c[*p]++; /* assume all entries <= BMAX */ + p++; /* Can't combine with above line (Solaris bug) */ + } while (--i); + if (c[0] == n) /* null input--all zero length codes */ + { + *t = (huft_t *) NULL; + *m = 0; + return 2; + } + + /* Find minimum and maximum length, bound *m by those */ + for (j = 1; (c[j] == 0) && (j <= BMAX); j++) ; + + k = j; /* minimum code length */ + for (i = BMAX; (c[i] == 0) && i; i--) ; + + g = i; /* maximum code length */ + *m = (*m < j) ? j : ((*m > i) ? i : *m); + + /* Adjust last length count to fill out codes, if needed */ + for (y = 1 << j; j < i; j++, y <<= 1) + { + if ((y -= c[j]) < 0) + return 2; /* bad input: more codes than bits */ + } + + if ((y -= c[i]) < 0) + return 2; + + c[i] += y; + + /* Generate starting offsets into the value table for each length */ + x[1] = j = 0; + p = c + 1; + xp = x + 2; + while (--i) /* note that i == g from above */ + { + *xp++ = (j += *p++); + } + + /* Make a table of values in order of bit lengths */ + p = b; + i = 0; + do { + if ((j = *p++) != 0) + v[x[j]++] = i; + } while (++i < n); + + /* Generate the Huffman codes and for each, make the table entries */ + x[0] = i = 0; /* first Huffman code is zero */ + p = v; /* grab values in bit order */ + htl = -1; /* no tables yet--level -1 */ + w = ws[0] = 0; /* bits decoded */ + u[0] = (huft_t *) NULL; /* just to keep compilers happy */ + q = (huft_t *) NULL; /* ditto */ + z = 0; /* ditto */ + + /* go through the bit lengths (k already is bits in shortest code) */ + for (; k <= g; k++) + { + a = c[k]; + while (a--) + { + /* here i is the Huffman code of length k bits for value *p */ + /* make tables up to required level */ + while (k > ws[htl + 1]) + { + w = ws[++htl]; + + /* compute minimum size table less than or equal to *m bits */ + z = (z = g - w) > *m ? *m : z; /* upper limit on table size */ + if ((f = 1 << (j = k - w)) > a + 1) /* try a k-w bit table */ + { /* too few codes for k-w bit table */ + f -= a + 1; /* deduct codes from patterns left */ + xp = c + k; + while (++j < z) /* try smaller tables up to z bits */ + { + if ((f <<= 1) <= *++xp) + break; /* enough codes to use up j bits */ + + f -= *xp; /* else deduct codes from patterns */ + } + } + + j = ((unsigned)(w + j) > eob_len && (unsigned)w < eob_len) + ? eob_len - w : j; /* make EOB code end at table */ + z = 1 << j; /* table entries for j-bit table */ + ws[htl+1] = w + j; /* set bits decoded in stack */ + + /* allocate and link in new table */ + q = (huft_t *) wpw_malloc(bufnum,(z + 1) * sizeof(huft_t)); + if(q==0) + return 3; + + *t = q + 1; /* link to list for huft_free() */ + t = &(q->v.t); + u[htl] = ++q; /* table starts after link */ + + /* connect to last table, if there is one */ + if (htl) + { + x[htl] = i; /* save pattern for backing up */ + + /* bits to dump before this table */ + r.b = (unsigned char) (w - ws[htl - 1]); + r.e = (unsigned char) (16 + j); /* bits in this table */ + r.v.t = q; /* pointer to this table */ + j = (i & ((1 << w) - 1)) >> ws[htl - 1]; + u[htl - 1][j] = r; /* connect to last table */ + } + } + + /* set up table entry in r */ + r.b = (unsigned char) (k - w); + if (p >= v + n) + r.e = 99; /* out of values--invalid code */ + else if (*p < s) + { + r.e = (unsigned char) (*p < 256 ? 16 : 15); /* 256 is EOB + code */ + r.v.n = (unsigned short) (*p++); /* simple code is just the + value */ + } + else + { + r.e = (unsigned char) e[*p - s]; /* non-simple--look up in lists + */ + r.v.n = d[*p++ - s]; + } + + /* fill code-like entries with r */ + f = 1 << (k - w); + for (j = i >> w; j < z; j += f) + { + q[j] = r; + } + + /* backwards increment the k-bit code i */ + for (j = 1 << (k - 1); i &j; j >>= 1) + { + i ^= j; + } + i ^= j; + + /* backup over finished tables */ + while ((i & ((1 << w) - 1)) != x[htl]) + { + w = ws[--htl]; + } + } + } + + /* return actual size of base table */ + *m = ws[1]; + + /* Return true (1) if we were given an incomplete table */ + return y != 0 && g != 1; +} + +/* + * inflate (decompress) the codes in a deflated (compressed) block. Return an + *error code or zero if it all goes ok. + * + * tl, td: literal/length and distance decoder tables bl, bd: number of bits + *decoded by tl[] and td[] + */ +static int inflate_codes_resumeCopy = 0; +static int inflate_codes(huft_t * my_tl, huft_t * my_td, + const unsigned int my_bl, const unsigned int my_bd, + int setup) +{ + static unsigned int e; /* table entry flag/number of extra bits */ + static unsigned int n, d; /* length and index for copy */ + static unsigned int w; /* current gunzip_window position */ + static huft_t *t; /* pointer to table entry */ + static unsigned int ml, md; /* masks for bl and bd bits */ + static unsigned int b; /* bit buffer */ + static unsigned int k; /* number of bits in bit buffer */ + static huft_t *tl, *td; + static unsigned int bl, bd; + + if (setup) /* 1st time we are called, copy in variables */ + { + tl = my_tl; + td = my_td; + bl = my_bl; + bd = my_bd; + /* make local copies of globals */ + b = gunzip_bb; /* initialize bit buffer */ + k = gunzip_bk; + w = gunzip_outbuf_count; /* initialize gunzip_window position + */ + + /* inflate the coded data */ + ml = mask_bits[bl]; /* precompute masks for speed */ + md = mask_bits[bd]; + return 0; /* Don't actually do anything the first time */ + } + + if (inflate_codes_resumeCopy) goto do_copy; + + while (1) /* do until end of block */ + { + b = fill_bitbuffer(b, &k, bl); + if ((e = (t = tl + ((unsigned) b & ml))->e) > 16) + do { + if (e == 99) + error_die("inflate_codes error 1"); + + b >>= t->b; + k -= t->b; + e -= 16; + b = fill_bitbuffer(b, &k, e); + } while ((e = + (t = t->v.t + ((unsigned) b & mask_bits[e]))->e) > 16); + + b >>= t->b; + k -= t->b; + if (e == 16) /* then it's a literal */ + { + gunzip_window[w++] = (unsigned char) t->v.n; + if (w == gunzip_wsize) + { + gunzip_outbuf_count = (w); + w = 0; + return 1; /* We have a block to read */ + } + } + else /* it's an EOB or a length */ + { /* exit if end of block */ + if (e == 15) + break; + + /* get length of block to copy */ + b = fill_bitbuffer(b, &k, e); + n = t->v.n + ((unsigned) b & mask_bits[e]); + b >>= e; + k -= e; + + /* decode distance of block to copy */ + b = fill_bitbuffer(b, &k, bd); + if ((e = (t = td + ((unsigned) b & md))->e) > 16) + do { + if (e == 99) + error_die("inflate_codes error 2"); + + b >>= t->b; + k -= t->b; + e -= 16; + b = fill_bitbuffer(b, &k, e); + } while ((e = + (t = + t->v.t + ((unsigned) b & mask_bits[e]))->e) > 16); + + b >>= t->b; + k -= t->b; + b = fill_bitbuffer(b, &k, e); + d = w - t->v.n - ((unsigned) b & mask_bits[e]); + b >>= e; + k -= e; + + /* do the copy */ +do_copy: do { + n -= (e = + (e = + gunzip_wsize - ((d &= gunzip_wsize - 1) > w ? d : w)) > n ? n : e); + /* copy to new buffer to prevent possible overwrite */ + if (w - d >= e) /* (this test assumes unsigned comparison) + */ + { + memcpy(gunzip_window + w, gunzip_window + d, e); + w += e; + d += e; + } + else + { + /* do it slow to avoid memcpy() overlap */ + /* !NOMEMCPY */ + do { + gunzip_window[w++] = gunzip_window[d++]; + } while (--e); + } + + if (w == gunzip_wsize) + { + gunzip_outbuf_count = (w); + if (n) inflate_codes_resumeCopy = 1; + else inflate_codes_resumeCopy = 0; + + w = 0; + return 1; + } + } while (n); + inflate_codes_resumeCopy = 0; + } + } + + /* restore the globals from the locals */ + gunzip_outbuf_count = w; /* restore global gunzip_window pointer */ + gunzip_bb = b; /* restore global bit buffer */ + gunzip_bk = k; + + /* normally just after call to inflate_codes, but save code by putting it + here */ + /* free the decoding tables, return */ + huft_free(tl,HUFT_MMP1); + huft_free(td,HUFT_MMP2); + + /* done */ + return 0; +} + +static int inflate_stored(int my_n, int my_b_stored, int my_k_stored, int setup) +{ + static unsigned int n, b_stored, k_stored, w; + if (setup) + { + n = my_n; + b_stored = my_b_stored; + k_stored = my_k_stored; + w = gunzip_outbuf_count; /* initialize gunzip_window position */ + return 0; /* Don't do anything first time */ + } + + /* read and output the compressed data */ + while (n--) + { + b_stored = fill_bitbuffer(b_stored, &k_stored, 8); + gunzip_window[w++] = (unsigned char) b_stored; + if (w == gunzip_wsize) + { + gunzip_outbuf_count = (w); + w = 0; + b_stored >>= 8; + k_stored -= 8; + return 1; /* We have a block */ + } + + b_stored >>= 8; + k_stored -= 8; + } + + /* restore the globals from the locals */ + gunzip_outbuf_count = w; /* restore global gunzip_window pointer */ + gunzip_bb = b_stored; /* restore global bit buffer */ + gunzip_bk = k_stored; + return 0; /* Finished */ +} + +/* + * decompress an inflated block e: last block flag + * + * GLOBAL VARIABLES: bb, kk, + */ +/* Return values: -1 = inflate_stored, -2 = inflate_codes */ +static int inflate_block(int *e) +{ + unsigned t; /* block type */ + unsigned int b; /* bit buffer */ + unsigned int k; /* number of bits in bit buffer */ + + /* make local bit buffer */ + + b = gunzip_bb; + k = gunzip_bk; + + /* read in last block bit */ + b = fill_bitbuffer(b, &k, 1); + *e = (int) b & 1; + b >>= 1; + k -= 1; + + /* read in block type */ + b = fill_bitbuffer(b, &k, 2); + t = (unsigned) b & 3; + b >>= 2; + k -= 2; + + /* restore the global bit buffer */ + gunzip_bb = b; + gunzip_bk = k; + + /* inflate that block type */ + switch (t) + { + case 0: /* Inflate stored */ + { + unsigned int n=0; /* number of bytes in block */ + + /* make local copies of globals */ + unsigned int b_stored=gunzip_bb; /* bit buffer */ + unsigned int k_stored=gunzip_bk; /* number of bits in bit buffer */ + + /* go to byte boundary */ + n = k_stored & 7; + b_stored >>= n; + k_stored -= n; + + /* get the length and its complement */ + b_stored = fill_bitbuffer(b_stored, &k_stored, 16); + n = ((unsigned) b_stored & 0xffff); + b_stored >>= 16; + k_stored -= 16; + + b_stored = fill_bitbuffer(b_stored, &k_stored, 16); + if (n != (unsigned) ((~b_stored) & 0xffff)) + return 1; /* error in compressed data */ + + b_stored >>= 16; + k_stored -= 16; + + inflate_stored(n, b_stored, k_stored, 1); /* Setup inflate_stored */ + return -1; + } + case 1: /* Inflate fixed decompress an inflated type 1 (fixed + Huffman codes) block. We should either replace this + with a custom decoder, or at least precompute the + Huffman tables. + */ + { + int i; /* temporary variable */ + huft_t *tl; /* literal/length code table */ + huft_t *td; /* distance code table */ + unsigned int bl; /* lookup bits for tl */ + unsigned int bd; /* lookup bits for td */ + unsigned int l[288]; /* length list for huft_build */ + + /* set up literal table */ + for (i = 0; i < 144; i++) + { + l[i] = 8; + } + for (; i < 256; i++) + { + l[i] = 9; + } + for (; i < 280; i++) + { + l[i] = 7; + } + for (; i < 288; i++) /* make a complete, but wrong code set */ + { + l[i] = 8; + } + bl = 7; + if ((i = huft_build(l, 288, 257, cplens, cplext, &tl, &bl,HUFT_MMP1)) != 0) + return i; + + /* set up distance table */ + for (i = 0; i < 30; i++) /* make an incomplete code set */ + { + l[i] = 5; + } + bd = 5; + if ((i = huft_build(l, 30, 0, cpdist, cpdext, &td, &bd,HUFT_MMP2)) > 1) + { + huft_free(tl,HUFT_MMP1); + return i; + } + + /* decompress until an end-of-block code */ + inflate_codes(tl, td, bl, bd, 1); /* Setup inflate_codes */ + + /* huft_free code moved into inflate_codes */ + + return -2; + } + case 2: /* Inflate dynamic */ + { + const int dbits = 6; /* bits in base distance lookup table */ + const int lbits = 9; /* bits in base literal/length lookup table */ + + huft_t *tl; /* literal/length code table */ + huft_t *td; /* distance code table */ + unsigned int i; /* temporary variables */ + unsigned int j; + unsigned int l; /* last length */ + unsigned int m; /* mask for bit lengths table */ + unsigned int n; /* number of lengths to get */ + unsigned int bl; /* lookup bits for tl */ + unsigned int bd; /* lookup bits for td */ + unsigned int nb; /* number of bit length codes */ + unsigned int nl; /* number of literal/length codes */ + unsigned int nd; /* number of distance codes */ + + unsigned int ll[286 + 30]; /* literal/length and distance code + lengths */ + unsigned int b_dynamic; /* bit buffer */ + unsigned int k_dynamic; /* number of bits in bit buffer */ + + /* make local bit buffer */ + b_dynamic = gunzip_bb; + k_dynamic = gunzip_bk; + + /* read in table lengths */ + b_dynamic = fill_bitbuffer(b_dynamic, &k_dynamic, 5); + nl = 257 + ((unsigned int) b_dynamic & 0x1f); /* number of + literal/length codes + */ + + b_dynamic >>= 5; + k_dynamic -= 5; + b_dynamic = fill_bitbuffer(b_dynamic, &k_dynamic, 5); + nd = 1 + ((unsigned int) b_dynamic & 0x1f); /* number of distance + codes */ + + b_dynamic >>= 5; + k_dynamic -= 5; + b_dynamic = fill_bitbuffer(b_dynamic, &k_dynamic, 4); + nb = 4 + ((unsigned int) b_dynamic & 0xf); /* number of bit length + codes */ + + b_dynamic >>= 4; + k_dynamic -= 4; + if (nl > 286 || nd > 30) + return 1; /* bad lengths */ + + /* read in bit-length-code lengths */ + for (j = 0; j < nb; j++) + { + b_dynamic = fill_bitbuffer(b_dynamic, &k_dynamic, 3); + ll[border[j]] = (unsigned int) b_dynamic & 7; + b_dynamic >>= 3; + k_dynamic -= 3; + } + for (; j < 19; j++) + { + ll[border[j]] = 0; + } + + /* build decoding table for trees--single level, 7 bit lookup */ + bl = 7; + i = huft_build(ll, 19, 19, NULL, NULL, &tl, &bl,HUFT_MMP1); + if (i != 0) + { + if (i == 1) + huft_free(tl,HUFT_MMP1); + + return i; /* incomplete code set */ + } + + /* read in literal and distance code lengths */ + n = nl + nd; + m = mask_bits[bl]; + i = l = 0; + while ((unsigned int) i < n) + { + b_dynamic = fill_bitbuffer(b_dynamic, &k_dynamic, (unsigned int)bl); + j = (td = tl + ((unsigned int) b_dynamic & m))->b; + b_dynamic >>= j; + k_dynamic -= j; + j = td->v.n; + if (j < 16) /* length of code in bits (0..15) */ + ll[i++] = l = j; /* save last length in l */ + else if (j == 16) /* repeat last length 3 to 6 times */ + { + b_dynamic = fill_bitbuffer(b_dynamic, &k_dynamic, 2); + j = 3 + ((unsigned int) b_dynamic & 3); + b_dynamic >>= 2; + k_dynamic -= 2; + if ((unsigned int) i + j > n) + return 1; + + while (j--) + { + ll[i++] = l; + } + } + else if (j == 17) /* 3 to 10 zero length codes */ + { + b_dynamic = fill_bitbuffer(b_dynamic, &k_dynamic, 3); + j = 3 + ((unsigned int) b_dynamic & 7); + b_dynamic >>= 3; + k_dynamic -= 3; + if ((unsigned int) i + j > n) + return 1; + + while (j--) + { + ll[i++] = 0; + } + l = 0; + } + else /* j == 18: 11 to 138 zero length codes */ + { + b_dynamic = fill_bitbuffer(b_dynamic, &k_dynamic, 7); + j = 11 + ((unsigned int) b_dynamic & 0x7f); + b_dynamic >>= 7; + k_dynamic -= 7; + if ((unsigned int) i + j > n) + return 1; + + while (j--) + { + ll[i++] = 0; + } + l = 0; + } + } + + /* free decoding table for trees */ + huft_free(tl,HUFT_MMP1); + + /* restore the global bit buffer */ + gunzip_bb = b_dynamic; + gunzip_bk = k_dynamic; + + /* build the decoding tables for literal/length and distance codes */ + bl = lbits; + + if ((i = huft_build(ll, nl, 257, cplens, cplext, &tl, &bl,HUFT_MMP1)) != 0) + { + if (i == 1) + { + error_die("Incomplete literal tree"); + huft_free(tl,HUFT_MMP1); + } + + return i; /* incomplete code set */ + } + + bd = dbits; + if ((i = huft_build(ll + nl, nd, 0, cpdist, cpdext, &td, &bd,HUFT_MMP2)) != 0) + { + if (i == 1) + { + error_die("incomplete distance tree"); + huft_free(td,HUFT_MMP2); + } + + huft_free(tl,HUFT_MMP1); + return i; /* incomplete code set */ + } + + /* decompress until an end-of-block code */ + inflate_codes(tl, td, bl, bd, 1); /* Setup inflate_codes */ + + /* huft_free code moved into inflate_codes */ + + return -2; + } + default: + /* bad block type */ + error_die("bad block type"); + } + return 0; +} + +static void calculate_gunzip_crc(void) +{ + unsigned int n; + for (n = 0; n < gunzip_outbuf_count; n++) + { + gunzip_crc = crc_table[((int) gunzip_crc ^ (gunzip_window[n])) & 0xff] + ^ (gunzip_crc >> 8); + } + gunzip_bytes_out += gunzip_outbuf_count; +} + +static int inflate_get_next_window_method = -1; /* Method == -1 for stored, -2 + for codes */ +static int inflate_get_next_window_e = 0; +static int inflate_get_next_window_needAnotherBlock = 1; + +static int inflate_get_next_window(void) +{ + gunzip_outbuf_count = 0; + + while(1) + { + int ret=0; + if (inflate_get_next_window_needAnotherBlock) + { + if(inflate_get_next_window_e) + { + calculate_gunzip_crc(); + inflate_get_next_window_e = 0; + inflate_get_next_window_needAnotherBlock = 1; + return 0; + } /* Last block */ + + inflate_get_next_window_method = inflate_block(&inflate_get_next_window_e); + inflate_get_next_window_needAnotherBlock = 0; + } + + switch (inflate_get_next_window_method) + { + case -1: ret = inflate_stored(0,0,0,0); + break; + case -2: ret = inflate_codes(0,0,0,0,0); + break; + default: + error_die("inflate error"); + } + + if (ret == 1) + { + calculate_gunzip_crc(); + return 1; /* More data left */ + } + else inflate_get_next_window_needAnotherBlock = 1; /* End of that + block */ + } + /* Doesnt get here */ +} + +/* Initialise bytebuffer, be careful not to overfill the buffer */ +static void inflate_init(unsigned int bufsize) +{ + /* Set the bytebuffer size, default is same as gunzip_wsize */ + bytebuffer_max = bufsize + 8; + bytebuffer_offset = 4; + bytebuffer_size = 0; +} + +static void inflate_cleanup(void) +{ + /* free(bytebuffer); */ +} + +USE_DESKTOP(long long) static int +inflate_unzip(struct mbreader_t *in,char* outbuffer,uint32_t outbuflen) +{ + USE_DESKTOP(long long total = 0; ) + typedef void (*sig_type)(int); + + /* Allocate all global buffers (for DYN_ALLOC option) */ + gunzip_outbuf_count = 0; + gunzip_bytes_out = 0; + gunzip_src_md = in; + + /* initialize gunzip_window, bit buffer */ + gunzip_bk = 0; + gunzip_bb = 0; + + /* Create the crc table */ + gunzip_crc = ~0; + + /* Allocate space for buffer */ + while(1) + { + int ret = inflate_get_next_window(); + if((signed int)outbuflen-(signed int)gunzip_outbuf_count<0) + { + error_msg("write_error"); + #ifdef TRIM_FILE_ON_ERROR + return USE_DESKTOP(total) + 0; + #else + return -1; + #endif + } + + memcpy(outbuffer,gunzip_window,gunzip_outbuf_count); + outbuffer+=sizeof(char)*gunzip_outbuf_count; + ifl_total+=sizeof(char)*gunzip_outbuf_count; + outbuflen-=gunzip_outbuf_count; + USE_DESKTOP(total += gunzip_outbuf_count; ) + if (ret == 0) break; + } + + /* Store unused bytes in a global buffer so calling applets can access it */ + if (gunzip_bk >= 8) + { + /* Undo too much lookahead. The next read will be byte aligned so we can + discard unused bits in the last meaningful byte. */ + bytebuffer_offset--; + bytebuffer[bytebuffer_offset] = gunzip_bb & 0xff; + gunzip_bb >>= 8; + gunzip_bk -= 8; + } + + return USE_DESKTOP(total) + 0; +} + +USE_DESKTOP(long long) static int +inflate_gunzip(struct mbreader_t *in,char* outbuffer,uint32_t outbuflen) +{ + uint32_t stored_crc = 0; + unsigned int count; + USE_DESKTOP(long long total = ) inflate_unzip(in, outbuffer,outbuflen); + + USE_DESKTOP(if (total < 0) return total; + + ) + + /* top up the input buffer with the rest of the trailer */ + count = bytebuffer_size - bytebuffer_offset; + if (count < 8) + { + xread(in, &bytebuffer[bytebuffer_size], 8 - count); + bytebuffer_size += 8 - count; + } + + for (count = 0; count != 4; count++) + { + stored_crc |= (bytebuffer[bytebuffer_offset] << (count * 8)); + bytebuffer_offset++; + } + + /* Validate decompression - crc */ + if (stored_crc != (~gunzip_crc)) + { + error_msg("crc error"); + + #ifdef TRIM_FILE_ON_ERROR + return USE_DESKTOP(total) + 0; + #else + return -1; + #endif + } + + /* Validate decompression - size */ + if ((signed int)gunzip_bytes_out != + (bytebuffer[bytebuffer_offset] | (bytebuffer[bytebuffer_offset+1] << 8) | + (bytebuffer[bytebuffer_offset+2] << 16) | (bytebuffer[bytebuffer_offset+3] << 24))) + { + error_msg("incorrect length"); + return -1; + } + + return USE_DESKTOP(total) + 0; +} + +/*An allocated memory buffer at least 0x13100 (72448) bytes long*/ +uint32_t decompress(const char *inbuffer,uint32_t inbuflen,char* outbuffer,uint32_t outbuflen,uint32_t offset,char* membuf) +{ + signed char status=0; + int exitcode=0; + struct mbreader_t src_md; + ifl_total=0; + /* reset statics */ + inflate_codes_resumeCopy = 0; + inflate_get_next_window_method = -1; /* Method == -1 for stored, -2 for + codes */ + inflate_get_next_window_e = 0; + inflate_get_next_window_needAnotherBlock = 1; + /* init */ + inflate_init(0x8000-8); + /*Memory init*/ + huftbuffer1=membuf; + huftbuffer2=membuf+0x2A00; + gunzip_window=membuf+0x2A00+0xA00; + bytebuffer=membuf+0x2A00+0xA00+0x8000; + wpw_init_mempool_pdm(HUFT_MMP1,(unsigned char*)huftbuffer1,0x2A00); + wpw_init_mempool_pdm(HUFT_MMP2,(unsigned char*)huftbuffer2,0xA00); + + /* Initialize memory buffer reader */ + src_md.ptr = inbuffer; + src_md.size = inbuflen; + src_md.offset = offset; + + if ((exitcode=xread_char(&src_md)) == 0x1f) + { + unsigned char magic2; + magic2 = xread_char(&src_md); + if (magic2 == 0x8b) + { + check_header_gzip(&src_md); /* FIXME: xfunc? _or_die? */ + status = inflate_gunzip(&src_md, outbuffer,outbuflen); + } + else + { + error_msg("invalid magic"); + exitcode = -1; + } + + if (status < 0) + { + error_msg("error inflating"); + exitcode = -1; + } + } + else + { + error_msg("invalid magic"); + exitcode = -1; + } + + inflate_cleanup(); + wpw_destroy_mempool(HUFT_MMP1); + wpw_destroy_mempool(HUFT_MMP2); + + if(exitcode==-1) + return 0; + + return ifl_total; +} diff --git a/lib/rbcodec/codecs/libgme/inflate/inflate.h b/lib/rbcodec/codecs/libgme/inflate/inflate.h new file mode 100644 index 0000000000..05164621b9 --- /dev/null +++ b/lib/rbcodec/codecs/libgme/inflate/inflate.h @@ -0,0 +1,30 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#ifndef INFLATE_H +#define INFLATE_H +#include + +#if defined(ROCKBOX) +#include "codeclib.h" +#endif + +uint32_t decompress(const char *inbuffer,uint32_t inbuflen,char* outbuffer,uint32_t outbuflen, + uint32_t offset,char* membuf); +#endif diff --git a/lib/rbcodec/codecs/libgme/inflate/mallocer.c b/lib/rbcodec/codecs/libgme/inflate/mallocer.c new file mode 100644 index 0000000000..41abedd09f --- /dev/null +++ b/lib/rbcodec/codecs/libgme/inflate/mallocer.c @@ -0,0 +1,86 @@ + +/* + Based on the wiki viewer mallocer + Copyright (C) 2005 Dave Chapman + + @ Modified to decompress memory buffer by gama + */ + +#include "mallocer.h" +#include "codeclib.h" + +unsigned char* mallocbuffer[MEMPOOL_MAX]; +long memory_ptr[MEMPOOL_MAX]; +size_t buffersize[MEMPOOL_MAX]; + +int wpw_init_mempool(unsigned char mempool) +{ + memory_ptr[mempool] = 0; + mallocbuffer[mempool] = (unsigned char *)ci->codec_get_buffer(&buffersize[mempool]); + // memset(mallocbuf[mempool], 0, bufsize[mempool]); + return 0; +} + +int wpw_init_mempool_pdm(unsigned char mempool, + unsigned char* mem,long memsize) +{ + memory_ptr[mempool] = 0; + mallocbuffer[mempool] = mem; + buffersize[mempool]=memsize; + return 0; +} + +void wpw_reset_mempool(unsigned char mempool) +{ + memory_ptr[mempool]=0; +} + +void wpw_destroy_mempool(unsigned char mempool) +{ + memory_ptr[mempool] = 0; + mallocbuffer[mempool] =0; + buffersize[mempool]=0; +} + +long wpw_available(unsigned char mempool) +{ + return buffersize[mempool]-memory_ptr[mempool]; +} + +void* wpw_malloc(unsigned char mempool,size_t size) +{ + void* x; + + if (memory_ptr[mempool] + size > buffersize[mempool] ) + return NULL; + + x=&mallocbuffer[mempool][memory_ptr[mempool]]; + memory_ptr[mempool]+=(size+3)&~3; /* Keep memory 32-bit aligned */ + + return(x); +} + +void* wpw_calloc(unsigned char mempool,size_t nmemb, size_t size) +{ + void* x; + x = wpw_malloc(mempool,nmemb*size); + if (x == NULL) + return NULL; + + memset(x,0,nmemb*size); + return(x); +} + +void wpw_free(unsigned char mempool,void* ptr) +{ + (void)ptr; + (void)mempool; +} + +void* wpw_realloc(unsigned char mempool,void* ptr, size_t size) +{ + void* x; + (void)ptr; + x = wpw_malloc(mempool,size); + return(x); +} diff --git a/lib/rbcodec/codecs/libgme/inflate/mallocer.h b/lib/rbcodec/codecs/libgme/inflate/mallocer.h new file mode 100644 index 0000000000..091643443c --- /dev/null +++ b/lib/rbcodec/codecs/libgme/inflate/mallocer.h @@ -0,0 +1,16 @@ + +#define MEMPOOL_MAX 10 +#include +#include + +int wpw_init_mempool(unsigned char mempool); +int wpw_init_mempool_pdm(unsigned char mempool, + unsigned char* mem,long memsize); + +void wpw_reset_mempool(unsigned char mempool); +void wpw_destroy_mempool(unsigned char mempool); +void* wpw_malloc(unsigned char mempool,size_t size); +void* wpw_calloc(unsigned char mempool,size_t nmemb, size_t size); +void wpw_free(unsigned char mempool,void* ptr); +void* wpw_realloc(unsigned char mempool,void* ptr, size_t size); +long wpw_available(unsigned char mempool); diff --git a/lib/rbcodec/codecs/libgme/inflate/mbreader.c b/lib/rbcodec/codecs/libgme/inflate/mbreader.c new file mode 100644 index 0000000000..825787927c --- /dev/null +++ b/lib/rbcodec/codecs/libgme/inflate/mbreader.c @@ -0,0 +1,16 @@ + +/* Memory buffer reader, simulates file read + @ gama +*/ + +#include "mbreader.h" + +int mbread(struct mbreader_t *md, void *buf, size_t n) +{ + if (!md) return -1; + size_t read_bytes = (md->offset+n) > md->size ? + md->size-md->offset : n; + memcpy(buf,md->ptr + md->offset,read_bytes); + md->offset += read_bytes; + return read_bytes; +} diff --git a/lib/rbcodec/codecs/libgme/inflate/mbreader.h b/lib/rbcodec/codecs/libgme/inflate/mbreader.h new file mode 100644 index 0000000000..d345c0c424 --- /dev/null +++ b/lib/rbcodec/codecs/libgme/inflate/mbreader.h @@ -0,0 +1,15 @@ + +#ifndef MBREADER_H +#define MBREADER_H + +#include "codeclib.h" + +struct mbreader_t { + const char *ptr; + size_t size; + size_t offset; +}; + +int mbread(struct mbreader_t *md, void *buf, size_t n); + +#endif diff --git a/lib/rbcodec/codecs/libgme/kss_cpu.c b/lib/rbcodec/codecs/libgme/kss_cpu.c new file mode 100644 index 0000000000..20601e608f --- /dev/null +++ b/lib/rbcodec/codecs/libgme/kss_cpu.c @@ -0,0 +1,35 @@ +// Game_Music_Emu 0.6-pre. http://www.slack.net/~ant/ + +#include "kss_emu.h" + +#include "blargg_endian.h" +//#include "z80_cpu_log.h" + +/* Copyright (C) 2006-2008 Shay Green. This module is free software; you +can redistribute it and/or modify it under the terms of the GNU Lesser +General Public License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. This +module is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +details. You should have received a copy of the GNU Lesser General Public +License along with this module; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ + +#include "blargg_source.h" + +#define OUT_PORT( addr, data ) cpu_out( this, TIME(), addr, data ) +#define IN_PORT( addr ) cpu_in( this, TIME(), addr ) +#define WRITE_MEM( addr, data ) {FLUSH_TIME(); cpu_write( this, addr, data );} +#define IDLE_ADDR idle_addr + +#define CPU_BEGIN \ +bool run_cpu( struct Kss_Emu* this, kss_time_t end_time )\ +{\ + struct Z80_Cpu *cpu = &this->cpu; \ + Z80_set_end_time( cpu, end_time ); + + #include "z80_cpu_run.h" + + return warning; +} diff --git a/lib/rbcodec/codecs/libgme/kss_emu.c b/lib/rbcodec/codecs/libgme/kss_emu.c new file mode 100644 index 0000000000..ba80ef613e --- /dev/null +++ b/lib/rbcodec/codecs/libgme/kss_emu.c @@ -0,0 +1,714 @@ +// Game_Music_Emu 0.6-pre. http://www.slack.net/~ant/ + +#include "kss_emu.h" + +#include "blargg_endian.h" + +/* Copyright (C) 2006 Shay Green. This module is free software; you +can redistribute it and/or modify it under the terms of the GNU Lesser +General Public License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. This +module is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +details. You should have received a copy of the GNU Lesser General Public +License along with this module; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ + +#include "blargg_source.h" + +int const clock_rate = 3579545; + +const char gme_wrong_file_type [] = "Wrong file type for this emulator"; + +static void clear_track_vars( struct Kss_Emu* this ) +{ + this->current_track = -1; + track_stop( &this->track_filter ); +} + +static blargg_err_t init_opl_apu( enum opl_type_t type, struct Opl_Apu* out ) +{ + blip_time_t const period = 72; + int const rate = clock_rate / period; + return Opl_init( out, rate * period, rate, period, type ); +} + +void Kss_init( struct Kss_Emu* this ) +{ + this->sample_rate = 0; + this->mute_mask_ = 0; + this->tempo = (int)(FP_ONE_TEMPO); + this->gain = (int)FP_ONE_GAIN; + this->chip_flags = 0; + + // defaults + this->tfilter = *track_get_setup( &this->track_filter ); + this->tfilter.max_initial = 2; + this->tfilter.lookahead = 6; + this->track_filter.silence_ignored_ = false; + + memset( this->unmapped_read, 0xFF, sizeof this->unmapped_read ); + + // Init all stuff + Buffer_init( &this->stereo_buf ); + + Z80_init( &this->cpu ); + Rom_init( &this->rom, page_size ); + + // Initialize all apus just once (?) + Sms_apu_init( &this->sms.psg); + Ay_apu_init( &this->msx.psg ); + Scc_init( &this->msx.scc ); + +#ifndef KSS_EMU_NO_FMOPL + init_opl_apu( type_smsfmunit, &this->sms.fm ); + init_opl_apu( type_msxmusic, &this->msx.music ); + init_opl_apu( type_msxaudio, &this->msx.audio ); +#endif + + this->voice_count = 0; + this->voice_types = 0; + clear_track_vars( this ); +} + +// Track info + +static blargg_err_t check_kss_header( void const* header ) +{ + if ( memcmp( header, "KSCC", 4 ) && memcmp( header, "KSSX", 4 ) ) + return gme_wrong_file_type; + return 0; +} + +// Setup + +static void update_gain_( struct Kss_Emu* this ) +{ + int g = this->gain; + if ( msx_music_enabled( this ) || msx_audio_enabled( this ) + || sms_fm_enabled( this ) ) + { + g = (g*3) / 4; //g *= 0.75; + } + else + { + if ( this->scc_accessed ) + g = (g*6) / 5; //g *= 1.2; + } + + if ( sms_psg_enabled( this ) ) Sms_apu_volume( &this->sms.psg, g ); + if ( sms_fm_enabled( this ) ) Opl_volume( &this->sms.fm, g ); + if ( msx_psg_enabled( this ) ) Ay_apu_volume( &this->msx.psg, g ); + if ( msx_scc_enabled( this ) ) Scc_volume( &this->msx.scc, g ); + if ( msx_music_enabled( this ) ) Opl_volume( &this->msx.music, g ); + if ( msx_audio_enabled( this ) ) Opl_volume( &this->msx.audio, g ); +} + +static void update_gain( struct Kss_Emu* this ) +{ + if ( this->scc_accessed ) + { + /* dprintf( "SCC accessed\n" ); */ + update_gain_( this ); + } +} + +blargg_err_t Kss_load_mem( struct Kss_Emu* this, const void* data, long size ) +{ + /* warning( core.warning() ); */ + memset( &this->header, 0, sizeof this->header ); + assert( offsetof (header_t,msx_audio_vol) == header_size - 1 ); + RETURN_ERR( Rom_load( &this->rom, data, size, header_base_size, &this->header, 0 ) ); + + RETURN_ERR( check_kss_header( this->header.tag ) ); + + this->chip_flags = 0; + this->header.last_track [0] = 255; + if ( this->header.tag [3] == 'C' ) + { + if ( this->header.extra_header ) + { + this->header.extra_header = 0; + /* warning( "Unknown data in header" ); */ + } + if ( this->header.device_flags & ~0x0F ) + { + this->header.device_flags &= 0x0F; + /* warning( "Unknown data in header" ); */ + } + } + else if ( this->header.extra_header ) + { + if ( this->header.extra_header != header_ext_size ) + { + this->header.extra_header = 0; + /* warning( "Invalid extra_header_size" ); */ + } + else + { + memcpy( this->header.data_size, this->rom.file_data, header_ext_size ); + } + } + + #ifndef NDEBUG + { + int ram_mode = this->header.device_flags & 0x84; // MSX + if ( this->header.device_flags & 0x02 ) // SMS + ram_mode = (this->header.device_flags & 0x88); + + if ( ram_mode ) + blargg_dprintf_( "RAM not supported\n" ); // TODO: support + } + #endif + + this->track_count = get_le16( this->header.last_track ) + 1; + this->m3u.size = 0; + + this->scc_enabled = false; + if ( this->header.device_flags & 0x02 ) // Sega Master System + { + int const osc_count = sms_osc_count + opl_osc_count; + + // sms.psg + this->voice_count = sms_osc_count; + static int const types [sms_osc_count + opl_osc_count] = { + wave_type+1, wave_type+3, wave_type+2, mixed_type+1, wave_type+0 + }; + this->voice_types = types; + this->chip_flags |= sms_psg_flag; + + // sms.fm + if ( this->header.device_flags & 0x01 ) + { + this->voice_count = osc_count; + this->chip_flags |= sms_fm_flag; + } + } + else // MSX + { + int const osc_count = ay_osc_count + opl_osc_count; + + // msx.psg + this->voice_count = ay_osc_count; + static int const types [ay_osc_count + opl_osc_count] = { + wave_type+1, wave_type+3, wave_type+2, wave_type+0 + }; + this->voice_types = types; + this->chip_flags |= msx_psg_flag; + + /* if ( this->header.device_flags & 0x10 ) + warning( "MSX stereo not supported" ); */ + + // msx.music + if ( this->header.device_flags & 0x01 ) + { + this->voice_count = osc_count; + this->chip_flags |= msx_music_flag; + } + + #ifndef KSS_EMU_NO_FMOPL + // msx.audio + if ( this->header.device_flags & 0x08 ) + { + this->voice_count = osc_count; + this->chip_flags |= msx_audio_flag; + } + #endif + + if ( !(this->header.device_flags & 0x80) ) + { + if ( !(this->header.device_flags & 0x84) ) + this->scc_enabled = scc_enabled_true; + + // msx.scc + this->chip_flags |= msx_scc_flag; + this->voice_count = ay_osc_count + scc_osc_count; + static int const types [ay_osc_count + scc_osc_count] = { + wave_type+1, wave_type+3, wave_type+2, + wave_type+0, wave_type+4, wave_type+5, wave_type+6, wave_type+7, + }; + this->voice_types = types; + } + } + + this->tfilter.lookahead = 6; + if ( sms_fm_enabled( this ) || msx_music_enabled( this ) || msx_audio_enabled( this ) ) + { + if ( !Opl_supported() ) + ; /* warning( "FM sound not supported" ); */ + else + this->tfilter.lookahead = 3; // Opl_Apu is really slow + } + + this->clock_rate_ = clock_rate; + Buffer_clock_rate( &this->stereo_buf, clock_rate ); + RETURN_ERR( Buffer_set_channel_count( &this->stereo_buf, this->voice_count, this->voice_types ) ); + this->buf_changed_count = Buffer_channels_changed_count( &this->stereo_buf ); + + Sound_set_tempo( this, this->tempo ); + Sound_mute_voices( this, this->mute_mask_ ); + return 0; +} + +static void set_voice( struct Kss_Emu* this, int i, struct Blip_Buffer* center, struct Blip_Buffer* left, struct Blip_Buffer* right ) +{ + if ( sms_psg_enabled( this ) ) // Sega Master System + { + i -= sms_osc_count; + if ( i < 0 ) + { + Sms_apu_set_output( &this->sms.psg, i + sms_osc_count, center, left, right ); + return; + } + + if ( sms_fm_enabled( this ) && i < opl_osc_count ) + Opl_set_output( &this->sms.fm, center ); + } + else if ( msx_psg_enabled( this ) ) // MSX + { + i -= ay_osc_count; + if ( i < 0 ) + { + Ay_apu_set_output( &this->msx.psg, i + ay_osc_count, center ); + return; + } + + if ( msx_scc_enabled( this ) && i < scc_osc_count ) Scc_set_output( &this->msx.scc, i, center ); + if ( msx_music_enabled( this ) && i < opl_osc_count ) Opl_set_output( &this->msx.music, center ); + if ( msx_audio_enabled( this ) && i < opl_osc_count ) Opl_set_output( &this->msx.audio, center ); + } +} + +// Emulation + +void jsr( struct Kss_Emu* this, byte const addr [] ) +{ + this->ram [--this->cpu.r.sp] = idle_addr >> 8; + this->ram [--this->cpu.r.sp] = idle_addr & 0xFF; + this->cpu.r.pc = get_le16( addr ); +} + +static void set_bank( struct Kss_Emu* this, int logical, int physical ) +{ + int const bank_size = (16 * 1024L) >> (this->header.bank_mode >> 7 & 1); + + int addr = 0x8000; + if ( logical && bank_size == 8 * 1024 ) + addr = 0xA000; + + physical -= this->header.first_bank; + if ( (unsigned) physical >= (unsigned) this->bank_count ) + { + byte* data = this->ram + addr; + Z80_map_mem( &this->cpu, addr, bank_size, data, data ); + } + else + { + int offset, phys = physical * bank_size; + for ( offset = 0; offset < bank_size; offset += page_size ) + Z80_map_mem( &this->cpu, addr + offset, page_size, + this->unmapped_write, Rom_at_addr( &this->rom, phys + offset ) ); + + } +} + +void cpu_write( struct Kss_Emu* this, addr_t addr, int data ) +{ + *Z80_write( &this->cpu, addr ) = data; + if ( (addr & this->scc_enabled) == 0x8000 ) { + // TODO: SCC+ support + + data &= 0xFF; + switch ( addr ) + { + case 0x9000: + set_bank( this, 0, data ); + return; + + case 0xB000: + set_bank( this, 1, data ); + return; + + case 0xBFFE: // selects between mapping areas (we just always enable both) + if ( data == 0 || data == 0x20 ) + return; + } + + int scc_addr = (addr & 0xDFFF) - 0x9800; + if ( msx_scc_enabled( this ) && (unsigned) scc_addr < 0xB0 ) + { + this->scc_accessed = true; + //if ( (unsigned) (scc_addr - 0x90) < 0x10 ) + // scc_addr -= 0x10; // 0x90-0x9F mirrors to 0x80-0x8F + if ( scc_addr < scc_reg_count ) + Scc_write( &this->msx.scc, Z80_time( &this->cpu ), addr, data ); + return; + } + } +} + +void cpu_out( struct Kss_Emu* this, kss_time_t time, kss_addr_t addr, int data ) +{ + data &= 0xFF; + switch ( addr & 0xFF ) + { + case 0xA0: + if ( msx_psg_enabled( this ) ) + Ay_apu_write_addr( &this->msx.psg, data ); + return; + + case 0xA1: + if ( msx_psg_enabled( this ) ) + Ay_apu_write_data( &this->msx.psg, time, data ); + return; + + case 0x06: + if ( sms_psg_enabled( this ) && (this->header.device_flags & 0x04) ) + { + Sms_apu_write_ggstereo( &this->sms.psg, time, data ); + return; + } + break; + + case 0x7E: + case 0x7F: + if ( sms_psg_enabled( this ) ) + { + Sms_apu_write_data( &this->sms.psg, time, data ); + return; + } + break; + + #define OPL_WRITE_HANDLER( base, name, opl )\ + case base : if ( name##_enabled( this ) ) { Opl_write_addr( opl, data ); return; } break;\ + case base+1: if ( name##_enabled( this ) ) { Opl_write_data( opl, time, data ); return; } break; + + OPL_WRITE_HANDLER( 0x7C, msx_music, &this->msx.music ) + OPL_WRITE_HANDLER( 0xC0, msx_audio, &this->msx.audio ) + OPL_WRITE_HANDLER( 0xF0, sms_fm, &this->sms.fm ) + + case 0xFE: + set_bank( this, 0, data ); + return; + + #ifndef NDEBUG + case 0xA8: // PPI + return; + #endif + } + + /* cpu_out( time, addr, data ); */ +} + +int cpu_in( struct Kss_Emu* this, kss_time_t time, kss_addr_t addr ) +{ + switch ( addr & 0xFF ) + { + case 0xC0: + case 0xC1: + if ( msx_audio_enabled( this ) ) + return Opl_read( &this->msx.audio, time, addr & 1 ); + break; + + case 0xA2: + if ( msx_psg_enabled( this ) ) + return Ay_apu_read( &this->msx.psg ); + break; + + #ifndef NDEBUG + case 0xA8: // PPI + return 0; + #endif + } + + /* return cpu_in( time, addr ); */ + return 0xFF; +} + +static blargg_err_t run_clocks( struct Kss_Emu* this, blip_time_t* duration_ ) +{ + blip_time_t duration = *duration_; + RETURN_ERR( end_frame( this, duration ) ); + + if ( sms_psg_enabled( this ) ) Sms_apu_end_frame( &this->sms.psg, duration ); + if ( sms_fm_enabled( this ) ) Opl_end_frame( &this->sms.fm, duration ); + if ( msx_psg_enabled( this ) ) Ay_apu_end_frame( &this->msx.psg, duration ); + if ( msx_scc_enabled( this ) ) Scc_end_frame( &this->msx.scc, duration ); + if ( msx_music_enabled( this ) ) Opl_end_frame( &this->msx.music, duration ); + if ( msx_audio_enabled( this ) ) Opl_end_frame( &this->msx.audio, duration ); + + return 0; +} + +blargg_err_t end_frame( struct Kss_Emu* this, kss_time_t end ) +{ + while ( Z80_time( &this->cpu ) < end ) + { + kss_time_t next = min( end, this->next_play ); + run_cpu( this, next ); + if ( this->cpu.r.pc == idle_addr ) + Z80_set_time( &this->cpu, next ); + + if ( Z80_time( &this->cpu ) >= this->next_play ) + { + this->next_play += this->play_period; + if ( this->cpu.r.pc == idle_addr ) + { + if ( !this->gain_updated ) + { + this->gain_updated = true; + update_gain( this ); + } + + jsr( this, this->header.play_addr ); + } + } + } + + this->next_play -= end; + check( this->next_play >= 0 ); + Z80_adjust_time( &this->cpu, -end ); + + return 0; +} + +// MUSIC + +blargg_err_t Kss_set_sample_rate( struct Kss_Emu* this, int rate ) +{ + require( !this->sample_rate ); // sample rate can't be changed once set + RETURN_ERR( Buffer_set_sample_rate( &this->stereo_buf, rate, 1000 / 20 ) ); + + // Set bass frequency + Buffer_bass_freq( &this->stereo_buf, 180 ); + + this->sample_rate = rate; + RETURN_ERR( track_init( &this->track_filter, this ) ); + this->tfilter.max_silence = 6 * stereo * this->sample_rate; + return 0; +} + +void Sound_mute_voice( struct Kss_Emu* this, int index, bool mute ) +{ + require( (unsigned) index < (unsigned) this->voice_count ); + int bit = 1 << index; + int mask = this->mute_mask_ | bit; + if ( !mute ) + mask ^= bit; + Sound_mute_voices( this, mask ); +} + +void Sound_mute_voices( struct Kss_Emu* this, int mask ) +{ + require( this->sample_rate ); // sample rate must be set first + this->mute_mask_ = mask; + + int i; + for ( i = this->voice_count; i--; ) + { + if ( mask & (1 << i) ) + { + set_voice( this, i, 0, 0, 0 ); + } + else + { + struct channel_t ch = Buffer_channel( &this->stereo_buf, i ); + assert( (ch.center && ch.left && ch.right) || + (!ch.center && !ch.left && !ch.right) ); // all or nothing + set_voice( this, i, ch.center, ch.left, ch.right ); + } + } +} + +void Sound_set_tempo( struct Kss_Emu* this, int t ) +{ + require( this->sample_rate ); // sample rate must be set first + int const min = (int)(FP_ONE_TEMPO*0.02); + int const max = (int)(FP_ONE_TEMPO*4.00); + if ( t < min ) t = min; + if ( t > max ) t = max; + this->tempo = t; + + blip_time_t period = + (this->header.device_flags & 0x40 ? clock_rate / 50 : clock_rate / 60); + this->play_period = (blip_time_t) ((period * FP_ONE_TEMPO) / t); +} + +blargg_err_t Kss_start_track( struct Kss_Emu* this, int track ) +{ + clear_track_vars( this ); + + // Remap track if playlist available + if ( this->m3u.size > 0 ) { + struct entry_t* e = &this->m3u.entries[track]; + track = e->track; + } + + this->current_track = track; + + Buffer_clear( &this->stereo_buf ); + + if ( sms_psg_enabled( this ) ) Sms_apu_reset( &this->sms.psg, 0, 0 ); + if ( sms_fm_enabled( this ) ) Opl_reset( &this->sms.fm ); + if ( msx_psg_enabled( this ) ) Ay_apu_reset( &this->msx.psg ); + if ( msx_scc_enabled( this ) ) Scc_reset( &this->msx.scc ); + if ( msx_music_enabled( this ) ) Opl_reset( &this->msx.music ); + if ( msx_audio_enabled( this ) ) Opl_reset( &this->msx.audio ); + + this->scc_accessed = false; + update_gain_( this ); + + memset( this->ram, 0xC9, 0x4000 ); + memset( this->ram + 0x4000, 0, sizeof this->ram - 0x4000 ); + + // copy driver code to lo RAM + static byte const bios [] = { + 0xD3, 0xA0, 0xF5, 0x7B, 0xD3, 0xA1, 0xF1, 0xC9, // $0001: WRTPSG + 0xD3, 0xA0, 0xDB, 0xA2, 0xC9 // $0009: RDPSG + }; + static byte const vectors [] = { + 0xC3, 0x01, 0x00, // $0093: WRTPSG vector + 0xC3, 0x09, 0x00, // $0096: RDPSG vector + }; + memcpy( this->ram + 0x01, bios, sizeof bios ); + memcpy( this->ram + 0x93, vectors, sizeof vectors ); + + // copy non-banked data into RAM + int load_addr = get_le16( this->header.load_addr ); + int orig_load_size = get_le16( this->header.load_size ); + int load_size = min( orig_load_size, (int) this->rom.file_size ); + load_size = min( load_size, (int) mem_size - load_addr ); + /* if ( load_size != orig_load_size ) + warning( "Excessive data size" ); */ + memcpy( this->ram + load_addr, this->rom.file_data + this->header.extra_header, load_size ); + + Rom_set_addr( &this->rom, -load_size - this->header.extra_header ); + + // check available bank data + int const bank_size = (16 * 1024L) >> (this->header.bank_mode >> 7 & 1); + int max_banks = (this->rom.file_size - load_size + bank_size - 1) / bank_size; + this->bank_count = this->header.bank_mode & 0x7F; + if ( this->bank_count > max_banks ) + { + this->bank_count = max_banks; + /* warning( "Bank data missing" ); */ + } + //dprintf( "load_size : $%X\n", load_size ); + //dprintf( "bank_size : $%X\n", bank_size ); + //dprintf( "bank_count: %d (%d claimed)\n", bank_count, this->header.bank_mode & 0x7F ); + + this->ram [idle_addr] = 0xFF; + Z80_reset( &this->cpu, this->unmapped_write, this->unmapped_read ); + Z80_map_mem( &this->cpu, 0, mem_size, this->ram, this->ram ); + + this->cpu.r.sp = 0xF380; + this->cpu.r.b.a = track; + this->cpu.r.b.h = 0; + this->next_play = this->play_period; + this->gain_updated = false; + jsr( this, this->header.init_addr ); + + // convert filter times to samples + struct setup_t s = this->tfilter; + s.max_initial *= this->sample_rate * stereo; + #ifdef GME_DISABLE_SILENCE_LOOKAHEAD + s.lookahead = 1; + #endif + track_setup( &this->track_filter, &s ); + + return track_start( &this->track_filter ); +} + +// Tell/Seek + +static int msec_to_samples( int msec, int sample_rate ) +{ + int sec = msec / 1000; + msec -= sec * 1000; + return (sec * sample_rate + msec * sample_rate / 1000) * stereo; +} + +int Track_tell( struct Kss_Emu* this ) +{ + int rate = this->sample_rate * stereo; + int sec = track_sample_count( &this->track_filter ) / rate; + return sec * 1000 + (track_sample_count( &this->track_filter ) - sec * rate) * 1000 / rate; +} + +blargg_err_t Track_seek( struct Kss_Emu* this, int msec ) +{ + int time = msec_to_samples( msec, this->sample_rate ); + if ( time < track_sample_count( &this->track_filter ) ) + RETURN_ERR( Kss_start_track( this, this->current_track ) ); + return Track_skip( this, time - track_sample_count( &this->track_filter ) ); +} + +blargg_err_t skip_( void *emu, int count ) +{ + struct Kss_Emu* this = (struct Kss_Emu*) emu; + + // for long skip, mute sound + const int threshold = 32768; + if ( count > threshold ) + { + int saved_mute = this->mute_mask_; + Sound_mute_voices( this, ~0 ); + + int n = count - threshold/2; + n &= ~(2048-1); // round to multiple of 2048 + count -= n; + RETURN_ERR( skippy_( &this->track_filter, n ) ); + + Sound_mute_voices( this, saved_mute ); + } + + return skippy_( &this->track_filter, count ); +} + +blargg_err_t Track_skip( struct Kss_Emu* this, int count ) +{ + require( this->current_track >= 0 ); // start_track() must have been called already + return track_skip( &this->track_filter, count ); +} + +void Track_set_fade( struct Kss_Emu* this, int start_msec, int length_msec ) +{ + track_set_fade( &this->track_filter, msec_to_samples( start_msec, this->sample_rate ), + length_msec * this->sample_rate / (1000 / stereo) ); +} + +blargg_err_t Kss_play( struct Kss_Emu* this, int out_count, sample_t* out ) +{ + require( this->current_track >= 0 ); + require( out_count % stereo == 0 ); + return track_play( &this->track_filter, out_count, out ); +} + +blargg_err_t play_( void *emu, int count, sample_t* out ) +{ + struct Kss_Emu* this = (struct Kss_Emu*) emu; + + int remain = count; + while ( remain ) + { + Buffer_disable_immediate_removal( &this->stereo_buf ); + remain -= Buffer_read_samples( &this->stereo_buf, &out [count - remain], remain ); + if ( remain ) + { + if ( this->buf_changed_count != Buffer_channels_changed_count( &this->stereo_buf ) ) + { + this->buf_changed_count = Buffer_channels_changed_count( &this->stereo_buf ); + + // Remute voices + Sound_mute_voices( this, this->mute_mask_ ); + } + int msec = Buffer_length( &this->stereo_buf ); + blip_time_t clocks_emulated = msec * this->clock_rate_ / 1000 - 100; + RETURN_ERR( run_clocks( this, &clocks_emulated ) ); + assert( clocks_emulated ); + Buffer_end_frame( &this->stereo_buf, clocks_emulated ); + } + } + return 0; +} diff --git a/lib/rbcodec/codecs/libgme/kss_emu.h b/lib/rbcodec/codecs/libgme/kss_emu.h new file mode 100644 index 0000000000..382e4b807b --- /dev/null +++ b/lib/rbcodec/codecs/libgme/kss_emu.h @@ -0,0 +1,223 @@ +// MSX computer KSS music file emulator + +// Game_Music_Emu 0.5.5 +#ifndef KSS_EMU_H +#define KSS_EMU_H + +#include "gme.h" +#include "blargg_common.h" + +#include "rom_data.h" +#include "multi_buffer.h" + +#include "kss_scc_apu.h" +#include "z80_cpu.h" +#include "sms_apu.h" +#include "ay_apu.h" +#include "opl_apu.h" +#include "m3u_playlist.h" +#include "track_filter.h" + +typedef int kss_time_t; +typedef int kss_addr_t; +typedef struct Z80_Cpu Kss_Cpu; + +// Sound chip flags +enum { + sms_psg_flag = 1 << 0, + sms_fm_flag = 1 << 1, + msx_psg_flag = 1 << 2, + msx_scc_flag = 1 << 3, + msx_music_flag = 1 << 4, + msx_audio_flag = 1 << 5 +}; + +enum { idle_addr = 0xFFFF }; +enum { scc_enabled_true = 0xC000 }; +enum { mem_size = 0x10000 }; + +// KSS file header +enum { header_size = 0x20 }; +enum { header_base_size = 0x10 }; +enum { header_ext_size = header_size - header_base_size }; + +struct header_t +{ + byte tag [4]; + byte load_addr [2]; + byte load_size [2]; + byte init_addr [2]; + byte play_addr [2]; + byte first_bank; + byte bank_mode; + byte extra_header; + byte device_flags; + + // KSSX extended data, if extra_header==0x10 + byte data_size [4]; + byte unused [4]; + byte first_track [2]; + byte last_track [2]; // if no extended data, we set this to 0xFF + byte psg_vol; + byte scc_vol; + byte msx_music_vol; + byte msx_audio_vol; +}; + +struct sms_t { + struct Sms_Apu psg; + struct Opl_Apu fm; +}; + +struct msx_t { + struct Ay_Apu psg; + struct Scc_Apu scc; + struct Opl_Apu music; + struct Opl_Apu audio; +}; + +struct Kss_Emu { + struct header_t header; + + int chip_flags; + bool scc_accessed; + bool gain_updated; + + unsigned scc_enabled; // 0 or 0xC000 + int bank_count; + + blip_time_t play_period; + blip_time_t next_play; + int ay_latch; + + // general + int voice_count; + int const* voice_types; + int mute_mask_; + int tempo; + int gain; + + int sample_rate; + + // track-specific + int track_count; + int current_track; + + int clock_rate_; + unsigned buf_changed_count; + + // M3u Playlist + struct M3u_Playlist m3u; + + struct setup_t tfilter; + struct Track_Filter track_filter; + + struct sms_t sms; + struct msx_t msx; + + Kss_Cpu cpu; + struct Multi_Buffer stereo_buf; // NULL if using custom buffer + struct Rom_Data rom; + + byte unmapped_read [0x100]; + byte unmapped_write [page_size]; + byte ram [mem_size + cpu_padding]; +}; + +// Basic functionality (see Gme_File.h for file loading/track info functions) + +void Kss_init( struct Kss_Emu* this ); +blargg_err_t Kss_load_mem( struct Kss_Emu* this, const void* data, long size ); +blargg_err_t end_frame( struct Kss_Emu* this, kss_time_t ); + +// Set output sample rate. Must be called only once before loading file. +blargg_err_t Kss_set_sample_rate( struct Kss_Emu* this, int sample_rate ); + +// Start a track, where 0 is the first track. Also clears warning string. +blargg_err_t Kss_start_track( struct Kss_Emu* this, int track ); + +// Generate 'count' samples info 'buf'. Output is in stereo. Any emulation +// errors set warning string, and major errors also end track. +blargg_err_t Kss_play( struct Kss_Emu* this, int count, sample_t* buf ); + +// Track status/control + +// Number of milliseconds (1000 msec = 1 second) played since beginning of track +int Track_tell( struct Kss_Emu* this ); + +// Seek to new time in track. Seeking backwards or far forward can take a while. +blargg_err_t Track_seek( struct Kss_Emu* this, int msec ); + +// Skip n samples +blargg_err_t Track_skip( struct Kss_Emu* this, int n ); + +// Set start time and length of track fade out. Once fade ends track_ended() returns +// true. Fade time can be changed while track is playing. +void Track_set_fade( struct Kss_Emu* this, int start_msec, int length_msec ); + +// True if a track has reached its end +static inline bool Track_ended( struct Kss_Emu* this ) +{ + return track_ended( &this->track_filter ); +} + +// Disables automatic end-of-track detection and skipping of silence at beginning +static inline void Track_ignore_silence( struct Kss_Emu* this, bool disable ) +{ + this->track_filter.silence_ignored_ = disable; +} + +// Get track length in milliseconds +static inline int Track_get_length( struct Kss_Emu* this, int n ) +{ + int length = 0; + + if ( (this->m3u.size > 0) && (n < this->m3u.size) ) { + struct entry_t* entry = &this->m3u.entries [n]; + length = entry->length; + } + + if ( length <= 0 ) + length = 120 * 1000; /* 2 minutes */ + + return length; +} + +// Sound customization + +// Adjust song tempo, where 1.0 = normal, 0.5 = half speed, 2.0 = double speed. +// Track length as returned by track_info() assumes a tempo of 1.0. +void Sound_set_tempo( struct Kss_Emu* this, int t ); + +// Mute/unmute voice i, where voice 0 is first voice +void Sound_mute_voice( struct Kss_Emu* this, int index, bool mute ); + +// Set muting state of all voices at once using a bit mask, where -1 mutes them all, +// 0 unmutes them all, 0x01 mutes just the first voice, etc. +void Sound_mute_voices( struct Kss_Emu* this, int mask ); + +// Change overall output amplitude, where 1.0 results in minimal clamping. +// Must be called before set_sample_rate(). +static inline void Sound_set_gain( struct Kss_Emu* this, int g ) +{ + assert( !this->sample_rate ); // you must set gain before setting sample rate + this->gain = g; +} + +// Emulation (You shouldn't touch these +void cpu_write( struct Kss_Emu* this, kss_addr_t, int ); +int cpu_in( struct Kss_Emu* this, kss_time_t, kss_addr_t ); +void cpu_out( struct Kss_Emu* this, kss_time_t, kss_addr_t, int ); + +void cpu_write_( struct Kss_Emu* this, kss_addr_t addr, int data ); +bool run_cpu( struct Kss_Emu* this, kss_time_t end ); +void jsr( struct Kss_Emu* this, byte const addr [] ); + +static inline int sms_psg_enabled( struct Kss_Emu* this ) { return this->chip_flags & sms_psg_flag; } +static inline int sms_fm_enabled( struct Kss_Emu* this ) { return this->chip_flags & sms_fm_flag; } +static inline int msx_psg_enabled( struct Kss_Emu* this ) { return this->chip_flags & msx_psg_flag; } +static inline int msx_scc_enabled( struct Kss_Emu* this ) { return this->chip_flags & msx_scc_flag; } +static inline int msx_music_enabled( struct Kss_Emu* this ) { return this->chip_flags & msx_music_flag;} +static inline int msx_audio_enabled( struct Kss_Emu* this ) { return this->chip_flags & msx_audio_flag;} + +#endif diff --git a/lib/rbcodec/codecs/libgme/kss_scc_apu.c b/lib/rbcodec/codecs/libgme/kss_scc_apu.c new file mode 100644 index 0000000000..1bec9b7f0e --- /dev/null +++ b/lib/rbcodec/codecs/libgme/kss_scc_apu.c @@ -0,0 +1,166 @@ +// Game_Music_Emu 0.6-pre. http://www.slack.net/~ant/ + +#include "kss_scc_apu.h" + +/* Copyright (C) 2006-2008 Shay Green. This module is free software; you +can redistribute it and/or modify it under the terms of the GNU Lesser +General Public License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. This +module is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +details. You should have received a copy of the GNU Lesser General Public +License along with this module; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ + +#include "blargg_source.h" + +// Tones above this frequency are treated as disabled tone at half volume. +// Power of two is more efficient (avoids division). +extern int const inaudible_freq; + +int const wave_size = 0x20; + +static void set_output( struct Scc_Apu* this, struct Blip_Buffer* buf ) +{ + int i; + for ( i = 0; i < scc_osc_count; ++i ) + Scc_set_output( this, i, buf ); +} + +void Scc_volume( struct Scc_Apu* this, int v ) +{ + Synth_volume( &this->synth, (v/2 - (v*7)/100) / scc_osc_count / scc_amp_range ); +} + +void Scc_reset( struct Scc_Apu* this ) +{ + this->last_time = 0; + + int i; + for ( i = scc_osc_count; --i >= 0; ) + memset( &this->oscs [i], 0, offsetof (struct scc_osc_t,output) ); + + memset( this->regs, 0, sizeof this->regs ); +} + +void Scc_init( struct Scc_Apu* this ) +{ + Synth_init( &this->synth); + + set_output( this, NULL ); + Scc_volume( this, (int)FP_ONE_VOLUME ); + Scc_reset( this ); +} + +static void run_until( struct Scc_Apu* this, blip_time_t end_time ) +{ + int index; + for ( index = 0; index < scc_osc_count; index++ ) + { + struct scc_osc_t* osc = &this->oscs [index]; + + struct Blip_Buffer* const output = osc->output; + if ( !output ) + continue; + + blip_time_t period = (this->regs [0xA0 + index * 2 + 1] & 0x0F) * 0x100 + + this->regs [0xA0 + index * 2] + 1; + int volume = 0; + if ( this->regs [0xAF] & (1 << index) ) + { + blip_time_t inaudible_period = (unsigned) (Blip_clock_rate( output ) + + inaudible_freq * 32) / (unsigned) (inaudible_freq * 16); + if ( period > inaudible_period ) + volume = (this->regs [0xAA + index] & 0x0F) * (scc_amp_range / 256 / 15); + } + + int8_t const* wave = (int8_t*) this->regs + index * wave_size; + /*if ( index == osc_count - 1 ) + wave -= wave_size; // last two oscs share same wave RAM*/ + + { + int delta = wave [osc->phase] * volume - osc->last_amp; + if ( delta ) + { + osc->last_amp += delta; + Blip_set_modified( output ); + Synth_offset( &this->synth, this->last_time, delta, output ); + } + } + + blip_time_t time = this->last_time + osc->delay; + if ( time < end_time ) + { + int phase = osc->phase; + if ( !volume ) + { + // maintain phase + int count = (end_time - time + period - 1) / period; + phase += count; // will be masked below + time += count * period; + } + else + { + int last_wave = wave [phase]; + phase = (phase + 1) & (wave_size - 1); // pre-advance for optimal inner loop + do + { + int delta = wave [phase] - last_wave; + phase = (phase + 1) & (wave_size - 1); + if ( delta ) + { + last_wave += delta; + Synth_offset_inline( &this->synth, time, delta * volume, output ); + } + time += period; + } + while ( time < end_time ); + + osc->last_amp = last_wave * volume; + Blip_set_modified( output ); + phase--; // undo pre-advance + } + osc->phase = phase & (wave_size - 1); + } + osc->delay = time - end_time; + } + this->last_time = end_time; +} + +void Scc_write( struct Scc_Apu* this, blip_time_t time, int addr, int data ) +{ + //assert( (unsigned) addr < reg_count ); + assert( ( addr >= 0x9800 && addr <= 0x988F ) || ( addr >= 0xB800 && addr <= 0xB8AF ) ); + run_until( this, time ); + + addr -= 0x9800; + if ( ( unsigned ) addr < 0x90 ) + { + if ( ( unsigned ) addr < 0x60 ) + this->regs [addr] = data; + else if ( ( unsigned ) addr < 0x80 ) + { + this->regs [addr] = this->regs[addr + 0x20] = data; + } + else if ( ( unsigned ) addr < 0x90 ) + { + this->regs [addr + 0x20] = data; + } + } + else + { + addr -= 0xB800 - 0x9800; + if ( ( unsigned ) addr < 0xB0 ) + this->regs [addr] = data; + } +} + +void Scc_end_frame( struct Scc_Apu* this, blip_time_t end_time ) +{ + if ( end_time > this->last_time ) + run_until( this, end_time ); + + this->last_time -= end_time; + assert( this->last_time >= 0 ); +} diff --git a/lib/rbcodec/codecs/libgme/kss_scc_apu.h b/lib/rbcodec/codecs/libgme/kss_scc_apu.h new file mode 100644 index 0000000000..a6962469ac --- /dev/null +++ b/lib/rbcodec/codecs/libgme/kss_scc_apu.h @@ -0,0 +1,51 @@ +// Konami SCC sound chip emulator + +// Game_Music_Emu 0.6-pre +#ifndef KSS_SCC_APU_H +#define KSS_SCC_APU_H + +#include "blargg_common.h" +#include "blip_buffer.h" + +enum { scc_reg_count = 0xB0 }; // 0 <= reg < reg_count +enum { scc_osc_count = 5 }; +enum { scc_amp_range = 0x8000 }; + +struct scc_osc_t +{ + int delay; + int phase; + int last_amp; + struct Blip_Buffer* output; +}; + +struct Scc_Apu { + struct scc_osc_t oscs [scc_osc_count]; + blip_time_t last_time; + unsigned char regs [scc_reg_count]; + + struct Blip_Synth synth; +}; + +void Scc_init( struct Scc_Apu* this ); + +// Resets sound chip +void Scc_reset( struct Scc_Apu* this ); + +// Set overall volume, where 1.0 is normal +void Scc_volume( struct Scc_Apu* this, int v ); + +static inline void Scc_set_output( struct Scc_Apu* this, int index, struct Blip_Buffer* b ) +{ + assert( (unsigned) index < scc_osc_count ); + this->oscs [index].output = b; +} + +// Emulates to time t, then writes data to reg +void Scc_write( struct Scc_Apu* this, blip_time_t time, int addr, int data ); + +// Emulates to time t, then subtracts t from the current time. +// OK if previous write call had time slightly after t. +void Scc_end_frame( struct Scc_Apu* this, blip_time_t end_time ); + +#endif diff --git a/lib/rbcodec/codecs/libgme/libay.make b/lib/rbcodec/codecs/libgme/libay.make new file mode 100644 index 0000000000..135ad041d3 --- /dev/null +++ b/lib/rbcodec/codecs/libgme/libay.make @@ -0,0 +1,10 @@ + +# libay +AYLIB := $(CODECDIR)/libay.a +AYLIB_SRC := $(call preprocess, $(RBCODECLIB_DIR)/codecs/libgme/AYSOURCES) +AYLIB_OBJ := $(call c2obj, $(AYLIB_SRC)) +OTHER_SRC += $(AYLIB_SRC) + +$(AYLIB): $(AYLIB_OBJ) + $(SILENT)$(shell rm -f $@) + $(call PRINTS,AR $(@F))$(AR) rcs $@ $^ >/dev/null diff --git a/lib/rbcodec/codecs/libgme/libemu2413.make b/lib/rbcodec/codecs/libgme/libemu2413.make new file mode 100644 index 0000000000..4d596dd93e --- /dev/null +++ b/lib/rbcodec/codecs/libgme/libemu2413.make @@ -0,0 +1,10 @@ + +# libemu2413 +EMU2413LIB := $(CODECDIR)/libemu2413.a +EMU2413LIB_SRC := $(call preprocess, $(RBCODECLIB_DIR)/codecs/libgme/EMU2413SOURCES) +EMU2413LIB_OBJ := $(call c2obj, $(EMU2413LIB_SRC)) +OTHER_SRC += $(EMU2413LIB_SRC) + +$(EMU2413LIB): $(EMU2413LIB_OBJ) + $(SILENT)$(shell rm -f $@) + $(call PRINTS,AR $(@F))$(AR) rcs $@ $^ >/dev/null diff --git a/lib/rbcodec/codecs/libgme/libgbs.make b/lib/rbcodec/codecs/libgme/libgbs.make new file mode 100644 index 0000000000..c6f872d6be --- /dev/null +++ b/lib/rbcodec/codecs/libgme/libgbs.make @@ -0,0 +1,10 @@ + +# libgbs +GBSLIB := $(CODECDIR)/libgbs.a +GBSLIB_SRC := $(call preprocess, $(RBCODECLIB_DIR)/codecs/libgme/GBSSOURCES) +GBSLIB_OBJ := $(call c2obj, $(GBSLIB_SRC)) +OTHER_SRC += $(GBSLIB_SRC) + +$(GBSLIB): $(GBSLIB_OBJ) + $(SILENT)$(shell rm -f $@) + $(call PRINTS,AR $(@F))$(AR) rcs $@ $^ >/dev/null diff --git a/lib/rbcodec/codecs/libgme/libhes.make b/lib/rbcodec/codecs/libgme/libhes.make new file mode 100644 index 0000000000..1d99f6a192 --- /dev/null +++ b/lib/rbcodec/codecs/libgme/libhes.make @@ -0,0 +1,10 @@ + +# libhes +HESLIB := $(CODECDIR)/libhes.a +HESLIB_SRC := $(call preprocess, $(RBCODECLIB_DIR)/codecs/libgme/HESSOURCES) +HESLIB_OBJ := $(call c2obj, $(HESLIB_SRC)) +OTHER_SRC += $(HESLIB_SRC) + +$(HESLIB): $(HESLIB_OBJ) + $(SILENT)$(shell rm -f $@) + $(call PRINTS,AR $(@F))$(AR) rcs $@ $^ >/dev/null diff --git a/lib/rbcodec/codecs/libgme/libkss.make b/lib/rbcodec/codecs/libgme/libkss.make new file mode 100644 index 0000000000..fc12bc22b4 --- /dev/null +++ b/lib/rbcodec/codecs/libgme/libkss.make @@ -0,0 +1,10 @@ + +# libkss +KSSLIB := $(CODECDIR)/libkss.a +KSSLIB_SRC := $(call preprocess, $(RBCODECLIB_DIR)/codecs/libgme/KSSSOURCES) +KSSLIB_OBJ := $(call c2obj, $(KSSLIB_SRC)) +OTHER_SRC += $(KSSLIB_SRC) + +$(KSSLIB): $(KSSLIB_OBJ) + $(SILENT)$(shell rm -f $@) + $(call PRINTS,AR $(@F))$(AR) rcs $@ $^ >/dev/null diff --git a/lib/rbcodec/codecs/libgme/libnsf.make b/lib/rbcodec/codecs/libgme/libnsf.make new file mode 100644 index 0000000000..1e7d56b88a --- /dev/null +++ b/lib/rbcodec/codecs/libgme/libnsf.make @@ -0,0 +1,10 @@ + +# libnsf +NSFLIB := $(CODECDIR)/libnsf.a +NSFLIB_SRC := $(call preprocess, $(RBCODECLIB_DIR)/codecs/libgme/NSFSOURCES) +NSFLIB_OBJ := $(call c2obj, $(NSFLIB_SRC)) +OTHER_SRC += $(NSFLIB_SRC) + +$(NSFLIB): $(NSFLIB_OBJ) + $(SILENT)$(shell rm -f $@) + $(call PRINTS,AR $(@F))$(AR) rcs $@ $^ >/dev/null diff --git a/lib/rbcodec/codecs/libgme/libsgc.make b/lib/rbcodec/codecs/libgme/libsgc.make new file mode 100644 index 0000000000..3caa3abd05 --- /dev/null +++ b/lib/rbcodec/codecs/libgme/libsgc.make @@ -0,0 +1,10 @@ + +# libsgc +SGCLIB := $(CODECDIR)/libsgc.a +SGCLIB_SRC := $(call preprocess, $(RBCODECLIB_DIR)/codecs/libgme/SGCSOURCES) +SGCLIB_OBJ := $(call c2obj, $(SGCLIB_SRC)) +OTHER_SRC += $(SGCLIB_SRC) + +$(SGCLIB): $(SGCLIB_OBJ) + $(SILENT)$(shell rm -f $@) + $(call PRINTS,AR $(@F))$(AR) rcs $@ $^ >/dev/null diff --git a/lib/rbcodec/codecs/libgme/libvgm.make b/lib/rbcodec/codecs/libgme/libvgm.make new file mode 100644 index 0000000000..24efc6ae3d --- /dev/null +++ b/lib/rbcodec/codecs/libgme/libvgm.make @@ -0,0 +1,10 @@ + +# libvgm +VGMLIB := $(CODECDIR)/libvgm.a +VGMLIB_SRC := $(call preprocess, $(RBCODECLIB_DIR)/codecs/libgme/VGMSOURCES) +VGMLIB_OBJ := $(call c2obj, $(VGMLIB_SRC)) +OTHER_SRC += $(VGMLIB_SRC) + +$(VGMLIB): $(VGMLIB_OBJ) + $(SILENT)$(shell rm -f $@) + $(call PRINTS,AR $(@F))$(AR) rcs $@ $^ >/dev/null diff --git a/lib/rbcodec/codecs/libgme/m3u_playlist.h b/lib/rbcodec/codecs/libgme/m3u_playlist.h new file mode 100644 index 0000000000..06a5d3024b --- /dev/null +++ b/lib/rbcodec/codecs/libgme/m3u_playlist.h @@ -0,0 +1,31 @@ +// M3U entries parser, with support for subtrack information + +// Game_Music_Emu 0.5.2 +#ifndef M3U_PLAYLIST_H +#define M3U_PLAYILST_H + +#include "blargg_common.h" + +struct entry_t +{ + unsigned char track; // 1-based + int length; // milliseconds +}; + +/* Short version of the m3u playlist */ +struct M3u_Playlist +{ + unsigned char size; + struct entry_t *entries; +}; + +static inline void M3u_load_data(struct M3u_Playlist* this, void *addr) +{ + if( addr == NULL ) return; + /* m3u entries data must be at offset 100, + the first 99 bytes are used by metadata info */ + this->size = *(unsigned char *)(addr + 99); + this->entries = (struct entry_t *)(addr+100); +} + +#endif diff --git a/lib/rbcodec/codecs/libgme/msxtypes.h b/lib/rbcodec/codecs/libgme/msxtypes.h new file mode 100644 index 0000000000..6224e0760c --- /dev/null +++ b/lib/rbcodec/codecs/libgme/msxtypes.h @@ -0,0 +1,36 @@ +#ifndef MSX_TYPES +#define MSX_TYPES + +#ifdef __cplusplus +extern "C" { +#endif + + +#ifdef __GNUC__ +#define __int64 long long +#endif + +#ifdef _WIN32 +#define DIR_SEPARATOR "\\" +#else +#define DIR_SEPARATOR "/" +#endif + +/* So far, only support for MSVC types + */ +typedef unsigned char UInt8; +#ifndef __CARBON__ +typedef unsigned short UInt16; +typedef unsigned int UInt32; +typedef unsigned __int64 UInt64; +#endif +typedef signed char Int8; +typedef signed short Int16; +typedef signed int Int32; + +#ifdef __cplusplus +} +#endif + + +#endif diff --git a/lib/rbcodec/codecs/libgme/multi_buffer.c b/lib/rbcodec/codecs/libgme/multi_buffer.c new file mode 100644 index 0000000000..554778c3de --- /dev/null +++ b/lib/rbcodec/codecs/libgme/multi_buffer.c @@ -0,0 +1,286 @@ +// Multi_Buffer 0.4.1. http://www.slack.net/~ant/ + +#include "multi_buffer.h" + +/* Copyright (C) 2003-2006 Shay Green. This module is free software; you +can redistribute it and/or modify it under the terms of the GNU Lesser +General Public License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. This +module is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +details. You should have received a copy of the GNU Lesser General Public +License along with this module; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ + +#include "blargg_source.h" + +// Tracked_Blip_Buffer + +int const blip_buffer_extra = 32; // TODO: explain why this value + +void Tracked_init( struct Tracked_Blip_Buffer* this ) +{ + Blip_init( &this->blip ); + this->last_non_silence = 0; +} + +void Tracked_clear( struct Tracked_Blip_Buffer* this ) +{ + this->last_non_silence = 0; + Blip_clear( &this->blip ); +} + +void Tracked_end_frame( struct Tracked_Blip_Buffer* this, blip_time_t t ) +{ + Blip_end_frame( &this->blip, t ); + if ( this->blip.modified ) + { + this->blip.modified = false; + this->last_non_silence = Blip_samples_avail( &this->blip ) + blip_buffer_extra; + } +} + +unsigned Tracked_non_silent( struct Tracked_Blip_Buffer* this ) +{ + return this->last_non_silence | unsettled( &this->blip ); +} + +static inline void remove_( struct Tracked_Blip_Buffer* this, int n ) +{ + if ( (this->last_non_silence -= n) < 0 ) + this->last_non_silence = 0; +} + +void Tracked_remove_silence( struct Tracked_Blip_Buffer* this, int n ) +{ + remove_( this, n ); + Blip_remove_silence( &this->blip, n ); +} + +void Tracked_remove_samples( struct Tracked_Blip_Buffer* this, int n ) +{ + remove_( this, n ); + Blip_remove_samples( &this->blip, n ); +} + +void Tracked_remove_all_samples( struct Tracked_Blip_Buffer* this ) +{ + int avail = Blip_samples_avail( &this->blip ); + if ( !Tracked_non_silent( this ) ) + Tracked_remove_silence( this, avail ); + else + Tracked_remove_samples( this, avail ); +} + +int Tracked_read_samples( struct Tracked_Blip_Buffer* this, blip_sample_t out [], int count ) +{ + count = Blip_read_samples( &this->blip, out, count, false ); + remove_( this, count ); + return count; +} + +// Stereo_Mixer + +// mixers use a single index value to improve performance on register-challenged processors +// offset goes from negative to zero + +void Mixer_init( struct Stereo_Mixer* this ) +{ + this->samples_read = 0; +} + +static void mix_mono( struct Stereo_Mixer* this, blip_sample_t out_ [], int count ) +{ + int const bass = this->bufs [2]->blip.bass_shift_; + delta_t const* center = this->bufs [2]->blip.buffer_ + this->samples_read; + int center_sum = this->bufs [2]->blip.reader_accum_; + + typedef blip_sample_t stereo_blip_sample_t [stereo]; + stereo_blip_sample_t* BLARGG_RESTRICT out = (stereo_blip_sample_t*) out_ + count; + int offset = -count; + do + { + int s = center_sum >> delta_bits; + + center_sum -= center_sum >> bass; + center_sum += center [offset]; + + BLIP_CLAMP( s, s ); + + out [offset] [0] = (blip_sample_t) s; + out [offset] [1] = (blip_sample_t) s; + } + while ( ++offset ); + + this->bufs [2]->blip.reader_accum_ = center_sum; +} + +static void mix_stereo( struct Stereo_Mixer* this, blip_sample_t out_ [], int count ) +{ + blip_sample_t* BLARGG_RESTRICT out = out_ + count * stereo; + // do left + center and right + center separately to reduce register load + struct Tracked_Blip_Buffer* const* buf = &this->bufs [2]; + while ( true ) // loop runs twice + { + --buf; + --out; + + int const bass = this->bufs [2]->blip.bass_shift_; + delta_t const* side = (*buf)->blip.buffer_ + this->samples_read; + delta_t const* center = this->bufs [2]->blip.buffer_ + this->samples_read; + + int side_sum = (*buf)->blip.reader_accum_; + int center_sum = this->bufs [2]->blip.reader_accum_; + + int offset = -count; + do + { + int s = (center_sum + side_sum) >> delta_bits; + + side_sum -= side_sum >> bass; + center_sum -= center_sum >> bass; + + side_sum += side [offset]; + center_sum += center [offset]; + + BLIP_CLAMP( s, s ); + + ++offset; // before write since out is decremented to slightly before end + out [offset * stereo] = (blip_sample_t) s; + } + while ( offset ); + + (*buf)->blip.reader_accum_ = side_sum; + + if ( buf != this->bufs ) + continue; + + // only end center once + this->bufs [2]->blip.reader_accum_ = center_sum; + break; + } +} + +void Mixer_read_pairs( struct Stereo_Mixer* this, blip_sample_t out [], int count ) +{ + // TODO: if caller never marks buffers as modified, uses mono + // except that buffer isn't cleared, so caller can encounter + // subtle problems and not realize the cause. + this->samples_read += count; + if ( Tracked_non_silent( this->bufs [0] ) | Tracked_non_silent( this->bufs [1] ) ) + mix_stereo( this, out, count ); + else + mix_mono( this, out, count ); +} + +// Multi_Buffer + +void Buffer_init( struct Multi_Buffer* this ) +{ + int const spf = 2; + + Tracked_init( &this->bufs [0] ); + Tracked_init( &this->bufs [1] ); + Tracked_init( &this->bufs [2] ); + + Mixer_init( &this->mixer ); + + this->length_ = 0; + this->sample_rate_ = 0; + this->channels_changed_count_ = 1; + this->channel_types_ = NULL; + this->channel_count_ = 0; + this->samples_per_frame_ = spf; + this->immediate_removal_ = true; + + this->mixer.bufs [2] = &this->bufs [2]; + this->mixer.bufs [0] = &this->bufs [0]; + this->mixer.bufs [1] = &this->bufs [1]; + + this->chan.center = &this->bufs [2].blip; + this->chan.left = &this->bufs [0].blip; + this->chan.right = &this->bufs [1].blip; +} + +blargg_err_t Buffer_set_sample_rate( struct Multi_Buffer* this, int rate, int msec ) +{ + int i; + for ( i = bufs_size; --i >= 0; ) + RETURN_ERR( Blip_set_sample_rate( &this->bufs [i].blip, rate, msec ) ); + + this->sample_rate_ = Blip_sample_rate( &this->bufs [0].blip ); + this->length_ = Blip_length( &this->bufs [0].blip ); + return 0; +} + +void Buffer_clock_rate( struct Multi_Buffer* this, int rate ) +{ + int i; + for ( i = bufs_size; --i >= 0; ) + Blip_set_clock_rate( &this->bufs [i].blip, rate ); +} + +void Buffer_bass_freq( struct Multi_Buffer* this, int bass ) +{ + int i; + for ( i = bufs_size; --i >= 0; ) + Blip_bass_freq( &this->bufs [i].blip, bass ); +} + +blargg_err_t Buffer_set_channel_count( struct Multi_Buffer* this, int n, int const* types ) +{ + this->channel_count_ = n; + this->channel_types_ = types; + return 0; +} + +struct channel_t Buffer_channel( struct Multi_Buffer* this, int i ) +{ + (void) i; + return this->chan; +} + +void Buffer_clear( struct Multi_Buffer* this ) +{ + int i; + this->mixer.samples_read = 0; + for ( i = bufs_size; --i >= 0; ) + Tracked_clear( &this->bufs [i] ); +} + +void Buffer_end_frame( struct Multi_Buffer* this, blip_time_t clock_count ) +{ + int i; + for ( i = bufs_size; --i >= 0; ) + Tracked_end_frame( &this->bufs [i], clock_count ); +} + +int Buffer_read_samples( struct Multi_Buffer* this, blip_sample_t out [], int out_size ) +{ + require( (out_size & 1) == 0 ); // must read an even number of samples + out_size = min( out_size, Buffer_samples_avail( this ) ); + + int pair_count = (int) (out_size >> 1); + if ( pair_count ) + { + Mixer_read_pairs( &this->mixer, out, pair_count ); + + if ( Buffer_samples_avail( this ) <= 0 || this->immediate_removal_ ) + { + int i; + for ( i = bufs_size; --i >= 0; ) + { + buf_t* b = &this->bufs [i]; + // TODO: might miss non-silence settling since it checks END of last read + if ( !Tracked_non_silent( b ) ) + Tracked_remove_silence( b, this->mixer.samples_read ); + else + Tracked_remove_samples( b, this->mixer.samples_read ); + } + this->mixer.samples_read = 0; + } + } + + return out_size; +} diff --git a/lib/rbcodec/codecs/libgme/multi_buffer.h b/lib/rbcodec/codecs/libgme/multi_buffer.h new file mode 100644 index 0000000000..e5efa5a230 --- /dev/null +++ b/lib/rbcodec/codecs/libgme/multi_buffer.h @@ -0,0 +1,114 @@ +// Multi-channel sound buffer interface, stereo and effects buffers + +// Blip_Buffer 0.4.1 +#ifndef MULTI_BUFFER_H +#define MULTI_BUFFER_H + +#include "blargg_common.h" +#include "blip_buffer.h" + +// Get indexed channel, from 0 to channel count - 1 +struct channel_t { + struct Blip_Buffer* center; + struct Blip_Buffer* left; + struct Blip_Buffer* right; +}; + +enum { type_index_mask = 0xFF }; +enum { wave_type = 0x100, noise_type = 0x200, mixed_type = wave_type | noise_type }; +enum { stereo = 2 }; +enum { bufs_size = 3 }; + +// Tracked_Blip_Buffer +struct Tracked_Blip_Buffer { + struct Blip_Buffer blip; + int last_non_silence; +}; + +void Tracked_init( struct Tracked_Blip_Buffer* this ); +unsigned Tracked_non_silent( struct Tracked_Blip_Buffer* this ); +void Tracked_remove_all_samples( struct Tracked_Blip_Buffer * this ); +int Tracked_read_samples( struct Tracked_Blip_Buffer* this, blip_sample_t [], int ); +void Tracked_remove_silence( struct Tracked_Blip_Buffer* this, int ); +void Tracked_remove_samples( struct Tracked_Blip_Buffer* this, int ); +void Tracked_clear( struct Tracked_Blip_Buffer* this ); +void Tracked_end_frame( struct Tracked_Blip_Buffer* this, blip_time_t ); + +static inline delta_t unsettled( struct Blip_Buffer* this ) +{ + return this->reader_accum_ >> delta_bits; +} + +// Stereo Mixer +struct Stereo_Mixer { + struct Tracked_Blip_Buffer* bufs [3]; + int samples_read; +}; + +void Mixer_init( struct Stereo_Mixer* this ); +void Mixer_read_pairs( struct Stereo_Mixer* this, blip_sample_t out [], int count ); + +typedef struct Tracked_Blip_Buffer buf_t; + +// Multi_Buffer +struct Multi_Buffer { + unsigned channels_changed_count_; + int sample_rate_; + int length_; + int channel_count_; + int samples_per_frame_; + int const *channel_types_; + bool immediate_removal_; + + buf_t bufs [bufs_size]; + struct Stereo_Mixer mixer; + struct channel_t chan; +}; + +blargg_err_t Buffer_set_channel_count( struct Multi_Buffer* this, int n, int const* types ); + +// Buffers used for all channels +static inline struct Blip_Buffer* center( struct Multi_Buffer* this ) { return &this->bufs [2].blip; } +static inline struct Blip_Buffer* left( struct Multi_Buffer* this ) { return &this->bufs [0].blip; } +static inline struct Blip_Buffer* right( struct Multi_Buffer* this ) { return &this->bufs [1].blip; } + +// Initializes Multi_Buffer structure +void Buffer_init( struct Multi_Buffer* this ); + +blargg_err_t Buffer_set_sample_rate( struct Multi_Buffer* this, int, int msec ); +void Buffer_clock_rate( struct Multi_Buffer* this, int ); +void Buffer_bass_freq( struct Multi_Buffer* this, int ); +void Buffer_clear( struct Multi_Buffer* this ); +void Buffer_end_frame( struct Multi_Buffer* this, blip_time_t ) ICODE_ATTR; + +static inline int Buffer_length( struct Multi_Buffer* this ) +{ + return this->length_; +} + +// Count of changes to channel configuration. Incremented whenever +// a change is made to any of the Blip_Buffers for any channel. +static inline unsigned Buffer_channels_changed_count( struct Multi_Buffer* this ) +{ + return this->channels_changed_count_; +} + +static inline void Buffer_disable_immediate_removal( struct Multi_Buffer* this ) +{ + this->immediate_removal_ = false; +} + +static inline int Buffer_sample_rate( struct Multi_Buffer* this ) +{ + return this->sample_rate_; +} + +static inline int Buffer_samples_avail( struct Multi_Buffer* this ) +{ + return (Blip_samples_avail(&this->bufs [0].blip) - this->mixer.samples_read) * 2; +} + +int Buffer_read_samples( struct Multi_Buffer* this, blip_sample_t*, int ) ICODE_ATTR; +struct channel_t Buffer_channel( struct Multi_Buffer* this, int i ); + +#endif diff --git a/lib/rbcodec/codecs/libgme/nes_apu.c b/lib/rbcodec/codecs/libgme/nes_apu.c new file mode 100644 index 0000000000..b6c88bc7e7 --- /dev/null +++ b/lib/rbcodec/codecs/libgme/nes_apu.c @@ -0,0 +1,397 @@ +// Nes_Snd_Emu 0.1.8. http://www.slack.net/~ant/ + +#include "nes_apu.h" + +/* Copyright (C) 2003-2006 Shay Green. This module is free software; you +can redistribute it and/or modify it under the terms of the GNU Lesser +General Public License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. This +module is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +details. You should have received a copy of the GNU Lesser General Public +License along with this module; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ + +#include "blargg_source.h" + +int const amp_range = 15; + +void Apu_init( struct Nes_Apu* this ) +{ + this->tempo_ = (int)(FP_ONE_TEMPO); + this->dmc.apu = this; + this->dmc.prg_reader = NULL; + this->irq_notifier_ = NULL; + + Synth_init( &this->square_synth ); + Synth_init( &this->triangle.synth ); + Synth_init( &this->noise.synth ); + Synth_init( &this->dmc.synth ); + + Square_set_synth( &this->square1, &this->square_synth ); + Square_set_synth( &this->square2, &this->square_synth ); + + this->oscs [0] = &this->square1.osc; + this->oscs [1] = &this->square2.osc; + this->oscs [2] = &this->triangle.osc; + this->oscs [3] = &this->noise.osc; + this->oscs [4] = &this->dmc.osc; + + Apu_output( this, NULL ); + this->dmc.nonlinear = false; + Apu_volume( this, (int)FP_ONE_VOLUME ); + Apu_reset( this, false, 0 ); +} + +#if 0 +// sq and tnd must use a fixed point frac where 1.0 = FP_ONE_VOLUME +void Apu_enable_nonlinear_( struct Nes_Apu* this, int sq, int tnd ) +{ + this->dmc.nonlinear = true; + Synth_volume( &this->square_synth, sq ); + + Synth_volume( &this->triangle.synth, (int)((long long)(FP_ONE_VOLUME * 2.752) * tnd / FP_ONE_VOLUME) ); + Synth_volume( &this->noise.synth , (int)((long long)(FP_ONE_VOLUME * 1.849) * tnd / FP_ONE_VOLUME) ); + Synth_volume( &this->dmc.synth , tnd ); + + this->square1 .osc.last_amp = 0; + this->square2 .osc.last_amp = 0; + this->triangle.osc.last_amp = 0; + this->noise .osc.last_amp = 0; + this->dmc .osc.last_amp = 0; +} +#endif + +void Apu_volume( struct Nes_Apu* this, int v ) +{ + if ( !this->dmc.nonlinear ) + { + Synth_volume( &this->square_synth, (int)((long long)((0.125 / 1.11) * FP_ONE_VOLUME) * v / amp_range / FP_ONE_VOLUME) ); // was 0.1128 1.108 + Synth_volume( &this->triangle.synth,(int)((long long)((0.150 / 1.11) * FP_ONE_VOLUME) * v / amp_range / FP_ONE_VOLUME) ); // was 0.12765 1.175 + Synth_volume( &this->noise.synth, (int)((long long)((0.095 / 1.11) * FP_ONE_VOLUME) * v / amp_range / FP_ONE_VOLUME) ); // was 0.0741 1.282 + Synth_volume( &this->dmc.synth, (int)((long long)((0.450 / 1.11) * FP_ONE_VOLUME) * v / 2048 / FP_ONE_VOLUME) ); // was 0.42545 1.058 + } +} + +void Apu_output( struct Nes_Apu* this, struct Blip_Buffer* buffer ) +{ + int i; + for ( i = 0; i < apu_osc_count; i++ ) + Apu_osc_output( this, i, buffer ); +} + +void Apu_set_tempo( struct Nes_Apu* this, int t ) +{ + this->tempo_ = t; + this->frame_period = (this->dmc.pal_mode ? 8314 : 7458); + if ( t != (int)FP_ONE_TEMPO ) + this->frame_period = (int) ((this->frame_period * FP_ONE_TEMPO) / t) & ~1; // must be even +} + +void Apu_reset( struct Nes_Apu* this, bool pal_mode, int initial_dmc_dac ) +{ + this->dmc.pal_mode = pal_mode; + Apu_set_tempo( this, this->tempo_ ); + + Square_reset( &this->square1 ); + Square_reset( &this->square2 ); + Triangle_reset( &this->triangle ); + Noise_reset( &this->noise ); + Dmc_reset( &this->dmc ); + + this->last_time = 0; + this->last_dmc_time = 0; + this->osc_enables = 0; + this->irq_flag = false; + this->earliest_irq_ = apu_no_irq; + this->frame_delay = 1; + Apu_write_register( this, 0, 0x4017, 0x00 ); + Apu_write_register( this, 0, 0x4015, 0x00 ); + + addr_t addr; + for ( addr = apu_io_addr; addr <= 0x4013; addr++ ) + Apu_write_register( this, 0, addr, (addr & 3) ? 0x00 : 0x10 ); + + this->dmc.dac = initial_dmc_dac; + if ( !this->dmc.nonlinear ) + this->triangle.osc.last_amp = 15; + if ( !this->dmc.nonlinear ) // TODO: remove? + this->dmc.osc.last_amp = initial_dmc_dac; // prevent output transition +} + +void Apu_irq_changed( struct Nes_Apu* this ) +{ + nes_time_t new_irq = this->dmc.next_irq; + if ( this->dmc.irq_flag | this->irq_flag ) { + new_irq = 0; + } + else if ( new_irq > this->next_irq ) { + new_irq = this->next_irq; + } + + if ( new_irq != this->earliest_irq_ ) { + this->earliest_irq_ = new_irq; + if ( this->irq_notifier_ ) + this->irq_notifier_( this->irq_data ); + } +} + +// frames + +void Apu_run_until( struct Nes_Apu* this, nes_time_t end_time ) +{ + require( end_time >= this->last_dmc_time ); + if ( end_time > Apu_next_dmc_read_time( this ) ) + { + nes_time_t start = this->last_dmc_time; + this->last_dmc_time = end_time; + Dmc_run( &this->dmc, start, end_time ); + } +} + +static void run_until_( struct Nes_Apu* this, nes_time_t end_time ) +{ + require( end_time >= this->last_time ); + + if ( end_time == this->last_time ) + return; + + if ( this->last_dmc_time < end_time ) + { + nes_time_t start = this->last_dmc_time; + this->last_dmc_time = end_time; + Dmc_run( &this->dmc, start, end_time ); + } + + while ( true ) + { + // earlier of next frame time or end time + nes_time_t time = this->last_time + this->frame_delay; + if ( time > end_time ) + time = end_time; + this->frame_delay -= time - this->last_time; + + // run oscs to present + Square_run( &this->square1, this->last_time, time ); + Square_run( &this->square2, this->last_time, time ); + Triangle_run( &this->triangle, this->last_time, time ); + Noise_run( &this->noise, this->last_time, time ); + this->last_time = time; + + if ( time == end_time ) + break; // no more frames to run + + // take frame-specific actions + this->frame_delay = this->frame_period; + switch ( this->frame++ ) + { + case 0: + if ( !(this->frame_mode & 0xC0) ) { + this->next_irq = time + this->frame_period * 4 + 2; + this->irq_flag = true; + } + // fall through + case 2: + // clock length and sweep on frames 0 and 2 + Osc_clock_length( &this->square1.osc, 0x20 ); + Osc_clock_length( &this->square2.osc, 0x20 ); + Osc_clock_length( &this->noise.osc, 0x20 ); + Osc_clock_length( &this->triangle.osc, 0x80 ); // different bit for halt flag on triangle + + Square_clock_sweep( &this->square1, -1 ); + Square_clock_sweep( &this->square2, 0 ); + + // frame 2 is slightly shorter in mode 1 + if ( this->dmc.pal_mode && this->frame == 3 ) + this->frame_delay -= 2; + break; + + case 1: + // frame 1 is slightly shorter in mode 0 + if ( !this->dmc.pal_mode ) + this->frame_delay -= 2; + break; + + case 3: + this->frame = 0; + + // frame 3 is almost twice as long in mode 1 + if ( this->frame_mode & 0x80 ) + this->frame_delay += this->frame_period - (this->dmc.pal_mode ? 2 : 6); + break; + } + + // clock envelopes and linear counter every frame + Triangle_clock_linear_counter( &this->triangle ); + Square_clock_envelope( &this->square1 ); + Square_clock_envelope( &this->square2 ); + Noise_clock_envelope( &this->noise ); + } +} + +static inline void zero_apu_osc( struct Nes_Osc* osc, struct Blip_Synth* synth, nes_time_t time ) +{ + struct Blip_Buffer* output = osc->output; + int last_amp = osc->last_amp; + osc->last_amp = 0; + if ( output && last_amp ) + Synth_offset( synth, time, -osc->last_amp, output ); +} + +void Apu_end_frame( struct Nes_Apu* this, nes_time_t end_time ) +{ + if ( end_time > this->last_time ) + run_until_( this, end_time ); + + if ( this->dmc.nonlinear ) + { + zero_apu_osc( &this->square1.osc, this->square1.synth, this->last_time ); + zero_apu_osc( &this->square2.osc, this->square2.synth, this->last_time ); + zero_apu_osc( &this->triangle.osc, &this->triangle.synth, this->last_time ); + zero_apu_osc( &this->noise.osc, &this->noise.synth, this->last_time ); + zero_apu_osc( &this->dmc.osc, &this->dmc.synth, this->last_time ); + } + + // make times relative to new frame + this->last_time -= end_time; + require( this->last_time >= 0 ); + + this->last_dmc_time -= end_time; + require( this->last_dmc_time >= 0 ); + + if ( this->next_irq != apu_no_irq ) { + this->next_irq -= end_time; + check( this->next_irq >= 0 ); + } + if ( this->dmc.next_irq != apu_no_irq ) { + this->dmc.next_irq -= end_time; + check( this->dmc.next_irq >= 0 ); + } + if ( this->earliest_irq_ != apu_no_irq ) { + this->earliest_irq_ -= end_time; + if ( this->earliest_irq_ < 0 ) + this->earliest_irq_ = 0; + } +} + +// registers + +static const unsigned char length_table [0x20] = { + 0x0A, 0xFE, 0x14, 0x02, 0x28, 0x04, 0x50, 0x06, + 0xA0, 0x08, 0x3C, 0x0A, 0x0E, 0x0C, 0x1A, 0x0E, + 0x0C, 0x10, 0x18, 0x12, 0x30, 0x14, 0x60, 0x16, + 0xC0, 0x18, 0x48, 0x1A, 0x10, 0x1C, 0x20, 0x1E +}; + +void Apu_write_register( struct Nes_Apu* this, nes_time_t time, addr_t addr, int data ) +{ + require( addr > 0x20 ); // addr must be actual address (i.e. 0x40xx) + require( (unsigned) data <= 0xFF ); + + // Ignore addresses outside range + if ( (unsigned) (addr - apu_io_addr) >= apu_io_size ) + return; + + run_until_( this, time ); + + if ( addr < 0x4014 ) + { + // Write to channel + int osc_index = (addr - apu_io_addr) >> 2; + struct Nes_Osc* osc = this->oscs [osc_index]; + + int reg = addr & 3; + osc->regs [reg] = data; + osc->reg_written [reg] = true; + + if ( osc_index == 4 ) + { + // handle DMC specially + Dmc_write_register( &this->dmc, reg, data ); + } + else if ( reg == 3 ) + { + // load length counter + if ( (this->osc_enables >> osc_index) & 1 ) + osc->length_counter = length_table [(data >> 3) & 0x1F]; + + // reset square phase + if ( osc_index == 0 ) this->square1.phase = square_phase_range - 1; + else if ( osc_index == 1 ) this->square2.phase = square_phase_range - 1; + } + } + else if ( addr == 0x4015 ) + { + // Channel enables + int i; + for ( i = apu_osc_count; i--; ) + if ( !((data >> i) & 1) ) + this->oscs [i]->length_counter = 0; + + bool recalc_irq = this->dmc.irq_flag; + this->dmc.irq_flag = false; + + int old_enables = this->osc_enables; + this->osc_enables = data; + if ( !(data & 0x10) ) { + this->dmc.next_irq = apu_no_irq; + recalc_irq = true; + } + else if ( !(old_enables & 0x10) ) { + Dmc_start( &this->dmc ); // dmc just enabled + } + + if ( recalc_irq ) + Apu_irq_changed( this ); + } + else if ( addr == 0x4017 ) + { + // Frame mode + this->frame_mode = data; + + bool irq_enabled = !(data & 0x40); + this->irq_flag &= irq_enabled; + this->next_irq = apu_no_irq; + + // mode 1 + this->frame_delay = (this->frame_delay & 1); + this->frame = 0; + + if ( !(data & 0x80) ) + { + // mode 0 + this->frame = 1; + this->frame_delay += this->frame_period; + if ( irq_enabled ) + this->next_irq = time + this->frame_delay + this->frame_period * 3 + 1; + } + + Apu_irq_changed( this ); + } +} + +int Apu_read_status( struct Nes_Apu* this, nes_time_t time ) +{ + run_until_( this, time - 1 ); + + int result = (this->dmc.irq_flag << 7) | (this->irq_flag << 6); + + int i; + for ( i = 0; i < apu_osc_count; i++ ) + if ( this->oscs [i]->length_counter ) + result |= 1 << i; + + run_until_( this, time ); + + if ( this->irq_flag ) + { + result |= 0x40; + this->irq_flag = false; + Apu_irq_changed( this ); + } + + //debug_printf( "%6d/%d Read $4015->$%02X\n", frame_delay, frame, result ); + + return result; +} diff --git a/lib/rbcodec/codecs/libgme/nes_apu.h b/lib/rbcodec/codecs/libgme/nes_apu.h new file mode 100644 index 0000000000..152ec94a17 --- /dev/null +++ b/lib/rbcodec/codecs/libgme/nes_apu.h @@ -0,0 +1,137 @@ +// NES 2A03 APU sound chip emulator + +// Nes_Snd_Emu 0.2.0-pre +#ifndef NES_APU_H +#define NES_APU_H + +#include "blargg_common.h" +#include "nes_oscs.h" + +enum { apu_status_addr = 0x4015 }; +enum { apu_osc_count = 5 }; +enum { apu_no_irq = INT_MAX/2 + 1 }; +enum { apu_irq_waiting = 0 }; + +enum { apu_io_addr = 0x4000 }; +enum { apu_io_size = 0x18 }; + +struct apu_state_t; + +struct Nes_Apu { + int tempo_; + nes_time_t last_time; // has been run until this time in current frame + nes_time_t last_dmc_time; + nes_time_t earliest_irq_; + nes_time_t next_irq; + int frame_period; + int frame_delay; // cycles until frame counter runs next + int frame; // current frame (0-3) + int osc_enables; + int frame_mode; + bool irq_flag; + + void (*irq_notifier_)( void* user_data ); + void* irq_data; + + Synth square_synth; // shared by squares + + struct Nes_Osc* oscs [apu_osc_count]; + struct Nes_Square square1; + struct Nes_Square square2; + struct Nes_Noise noise; + struct Nes_Triangle triangle; + struct Nes_Dmc dmc; +}; + +// Init Nes apu +void Apu_init( struct Nes_Apu* this ); + +// Set buffer to generate all sound into, or disable sound if NULL +void Apu_output( struct Nes_Apu* this, struct Blip_Buffer* ); + +// All time values are the number of cpu clock cycles relative to the +// beginning of the current time frame. Before resetting the cpu clock +// count, call end_frame( last_cpu_time ). + +// Write to register (0x4000-0x4017, except 0x4014 and 0x4016) +void Apu_write_register( struct Nes_Apu* this, nes_time_t, addr_t, int data ); + +// Read from status register at 0x4015 +int Apu_read_status( struct Nes_Apu* this, nes_time_t ); + +// Run all oscillators up to specified time, end current time frame, then +// start a new time frame at time 0. Time frames have no effect on emulation +// and each can be whatever length is convenient. +void Apu_end_frame( struct Nes_Apu* this, nes_time_t ); + +// Additional optional features (can be ignored without any problem) + +// Reset internal frame counter, registers, and all oscillators. +// Use PAL timing if pal_timing is true, otherwise use NTSC timing. +// Set the DMC oscillator's initial DAC value to initial_dmc_dac without +// any audible click. +void Apu_reset( struct Nes_Apu* this, bool pal_mode, int initial_dmc_dac ); + +// Adjust frame period +void Apu_set_tempo( struct Nes_Apu* this, int ); + +// Set overall volume (default is 1.0) +void Apu_volume( struct Nes_Apu* this, int ); + +// Run DMC until specified time, so that any DMC memory reads can be +// accounted for (i.e. inserting cpu wait states). +void Apu_run_until( struct Nes_Apu* this, nes_time_t ); + +// Set sound output of specific oscillator to buffer. If buffer is NULL, +// the specified oscillator is muted and emulation accuracy is reduced. +// The oscillators are indexed as follows: 0) Square 1, 1) Square 2, +// 2) Triangle, 3) Noise, 4) DMC. +static inline void Apu_osc_output( struct Nes_Apu* this, int osc, struct Blip_Buffer* buf ) +{ + assert( (unsigned) osc < apu_osc_count ); + this->oscs [osc]->output = buf; +} + +// Set memory reader callback used by DMC oscillator to fetch samples. +// When callback is invoked, 'user_data' is passed unchanged as the +// first parameter. +static inline void Apu_dmc_reader( struct Nes_Apu* this, int (*func)( void*, addr_t ), void* user_data ) +{ + this->dmc.prg_reader_data = user_data; + this->dmc.prg_reader = func; +} + +// Set IRQ time callback that is invoked when the time of earliest IRQ +// may have changed, or NULL to disable. When callback is invoked, +// 'user_data' is passed unchanged as the first parameter. +static inline void Apu_irq_notifier( struct Nes_Apu* this, void (*func)( void* user_data ), void* user_data ) +{ + this->irq_notifier_ = func; + this->irq_data = user_data; +} + +// Count number of DMC reads that would occur if 'run_until( t )' were executed. +// If last_read is not NULL, set *last_read to the earliest time that +// 'count_dmc_reads( time )' would result in the same result. +static inline int Apu_count_dmc_reads( struct Nes_Apu* this, nes_time_t time, nes_time_t* last_read ) +{ + return Dmc_count_reads( &this->dmc, time, last_read ); +} + +static inline nes_time_t Dmc_next_read_time( struct Nes_Dmc* this ) +{ + if ( this->osc.length_counter == 0 ) + return apu_no_irq; // not reading + + return this->apu->last_dmc_time + this->osc.delay + (this->bits_remain - 1) * this->period; +} + +// Time when next DMC memory read will occur +static inline nes_time_t Apu_next_dmc_read_time( struct Nes_Apu* this ) { return Dmc_next_read_time( &this->dmc ); } +void Apu_irq_changed( struct Nes_Apu* this ); + +#if 0 +// Experimental +void Apu_enable_nonlinear_( struct Nes_Apu* this, int sq, int tnd ); +#endif +#endif diff --git a/lib/rbcodec/codecs/libgme/nes_cpu.c b/lib/rbcodec/codecs/libgme/nes_cpu.c new file mode 100644 index 0000000000..20925918c2 --- /dev/null +++ b/lib/rbcodec/codecs/libgme/nes_cpu.c @@ -0,0 +1,62 @@ +// Game_Music_Emu 0.6-pre. http://www.slack.net/~ant/ + +#include "nes_cpu.h" + +#include "blargg_endian.h" + +/* Copyright (C) 2003-2008 Shay Green. This module is free software; you +can redistribute it and/or modify it under the terms of the GNU Lesser +General Public License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. This +module is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +details. You should have received a copy of the GNU Lesser General Public +License along with this module; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ + +#include "blargg_source.h" + +static inline void set_code_page( struct Nes_Cpu* this, int i, void const* p ) +{ + byte const* p2 = STATIC_CAST(byte const*,p) - NES_CPU_OFFSET( i * page_size ); + this->cpu_state->code_map [i] = p2; + this->cpu_state_.code_map [i] = p2; +} + +void Cpu_map_code( struct Nes_Cpu* this, addr_t start, int size, void const* data, int mirror_size ) +{ + // address range must begin and end on page boundaries + require( start % page_size == 0 ); + require( size % page_size == 0 ); + require( start + size <= 0x10000 ); + require( mirror_size % page_size == 0 ); + + int offset; + for ( offset = 0; offset < size; offset += page_size ) + set_code_page( this, NES_CPU_PAGE( start + offset ), + STATIC_CAST(char const*,data) + (offset & ((unsigned) mirror_size - 1)) ); +} + +void Cpu_reset( struct Nes_Cpu* this, void const* unmapped_page ) +{ + check( this->cpu_state == &this->cpu_state_ ); + this->cpu_state = &this->cpu_state_; + + this->r.flags = irq_inhibit_mask; + this->r.sp = 0xFF; + this->r.pc = 0; + this->r.a = 0; + this->r.x = 0; + this->r.y = 0; + + this->cpu_state_.time = 0; + this->cpu_state_.base = 0; + this->irq_time = future_time; + this->end_time = future_time; + + set_code_page( this, page_count, unmapped_page ); + Cpu_map_code( this, 0, 0x10000, unmapped_page, page_size ); + + blargg_verify_byte_order(); +} diff --git a/lib/rbcodec/codecs/libgme/nes_cpu.h b/lib/rbcodec/codecs/libgme/nes_cpu.h new file mode 100644 index 0000000000..e4538cd00c --- /dev/null +++ b/lib/rbcodec/codecs/libgme/nes_cpu.h @@ -0,0 +1,109 @@ +// NES cpu emulator + +// Game_Music_Emu 0.6-pre +#ifndef NES_CPU_H +#define NES_CPU_H + +#include "blargg_common.h" +#include "blargg_source.h" + +typedef int nes_time_t; +typedef int addr_t; + +enum { page_bits = 11 }; +enum { page_size = 1 << page_bits }; +enum { page_count = 0x10000 >> page_bits }; + +// Unmapped page should be filled with this +enum { halt_opcode = 0x22 }; + +enum { future_time = INT_MAX/2 + 1 }; +enum { irq_inhibit_mask = 0x04 }; + +// Can read this many bytes past end of a page +enum { cpu_padding = 8 }; + +struct registers_t { + uint16_t pc; + uint8_t a; + uint8_t x; + uint8_t y; + uint8_t flags; + uint8_t sp; +}; + +struct cpu_state_t { + uint8_t const* code_map [page_count + 1]; + nes_time_t base; + int time; +}; + +struct Nes_Cpu { + // NES 6502 registers. NOT kept updated during emulation. + struct registers_t r; + nes_time_t irq_time; + nes_time_t end_time; + + struct cpu_state_t* cpu_state; // points to cpu_state_ or a local copy + struct cpu_state_t cpu_state_; +}; + +static inline void Cpu_init( struct Nes_Cpu* this ) +{ + this->cpu_state = &this->cpu_state_; +} + +// Clears registers and maps all pages to unmapped_page +void Cpu_reset( struct Nes_Cpu* this, void const* unmapped_page ); + +// Maps code memory (memory accessed via the program counter). Start and size +// must be multiple of page_size. If mirror_size is non-zero, the first +// mirror_size bytes are repeated over the range. mirror_size must be a +// multiple of page_size. +void Cpu_map_code( struct Nes_Cpu* this, addr_t start, int size, void const* code, int mirror_size ); + +// Time of beginning of next instruction to be executed +static inline nes_time_t Cpu_time( struct Nes_Cpu* this ) { return this->cpu_state->time + this->cpu_state->base; } +static inline void Cpu_set_time( struct Nes_Cpu* this, nes_time_t t ) { this->cpu_state->time = t - this->cpu_state->base; } +static inline void Cpu_adjust_time( struct Nes_Cpu* this, int delta ) { this->cpu_state->time += delta; } + +// Clocks past end (negative if before) +static inline int Cpu_time_past_end( struct Nes_Cpu* this ) { return this->cpu_state->time; } + +#define NES_CPU_PAGE( addr ) ((unsigned) (addr) >> page_bits) + +#ifdef BLARGG_NONPORTABLE + #define NES_CPU_OFFSET( addr ) (addr) +#else + #define NES_CPU_OFFSET( addr ) ((addr) & (page_size - 1)) +#endif + +// Accesses emulated memory as cpu does +static inline uint8_t const* Cpu_get_code( struct Nes_Cpu* this, addr_t addr ) +{ + return this->cpu_state_.code_map [NES_CPU_PAGE( addr )] + NES_CPU_OFFSET( addr ); +} + +static inline void Cpu_update_end_time( struct Nes_Cpu* this, nes_time_t end, nes_time_t irq ) +{ + if ( end > irq && !(this->r.flags & irq_inhibit_mask) ) + end = irq; + + this->cpu_state->time += this->cpu_state->base - end; + this->cpu_state->base = end; +} + +// Time of next IRQ +static inline void Cpu_set_irq_time( struct Nes_Cpu* this, nes_time_t t ) +{ + this->irq_time = t; + Cpu_update_end_time( this, this->end_time, t ); +} + +static inline void Cpu_set_end_time( struct Nes_Cpu* this, nes_time_t t ) +{ + this->end_time = t; + Cpu_update_end_time( this, t, this->irq_time ); +} + +#endif diff --git a/lib/rbcodec/codecs/libgme/nes_cpu_run.h b/lib/rbcodec/codecs/libgme/nes_cpu_run.h new file mode 100644 index 0000000000..fd1fea9659 --- /dev/null +++ b/lib/rbcodec/codecs/libgme/nes_cpu_run.h @@ -0,0 +1,1122 @@ +// NES 6502 cpu emulator run function + +#if 0 +/* Define these macros in the source file before #including this file. +- Parameters might be expressions, so they are best evaluated only once, +though they NEVER have side-effects, so multiple evaluation is OK. +- Output parameters might be a multiple-assignment expression like "a=x", +so they must NOT be parenthesized. +- Except where noted, time() and related functions will NOT work +correctly inside a macro. TIME() is always correct, and FLUSH_TIME() and +CACHE_TIME() allow the time changing functions to work. +- Macros "returning" void may use a {} statement block. */ + + // 0 <= addr <= 0xFFFF + page_size + // time functions can be used + int READ_MEM( addr_t ); + void WRITE_MEM( addr_t, int data ); + // 0 <= READ_MEM() <= 0xFF + + // 0 <= addr <= 0x1FF + int READ_LOW( addr_t ); + void WRITE_LOW( addr_t, int data ); + // 0 <= READ_LOW() <= 0xFF + + // Often-used instructions attempt these before using a normal memory access. + // Optional; defaults to READ_MEM() and WRITE_MEM() + bool CAN_READ_FAST( addr_t ); // if true, uses result of READ_FAST + void READ_FAST( addr_t, int& out ); // ALWAYS called BEFORE CAN_READ_FAST + bool CAN_WRITE_FAST( addr_t ); // if true, uses WRITE_FAST instead of WRITE_MEM + void WRITE_FAST( addr_t, int data ); + + // Used by instructions most often used to access the NES PPU (LDA abs and BIT abs). + // Optional; defaults to READ_MEM. + void READ_PPU( addr_t, int& out ); + // 0 <= out <= 0xFF + +// The following can be used within macros: + + // Current time + time_t TIME(); + + // Allows use of time functions + void FLUSH_TIME(); + + // Must be used before end of macro if FLUSH_TIME() was used earlier + void CACHE_TIME(); + +// Configuration (optional; commented behavior if defined) + + // Emulates dummy reads for indexed instructions + #define NES_CPU_DUMMY_READS 1 + + // Optimizes as if map_code( 0, 0x10000 + cpu_padding, FLAT_MEM ) is always in effect + #define FLAT_MEM my_mem_array + + // Expanded just before beginning of code, to help debugger + #define CPU_BEGIN void my_run_cpu() { + +#endif + +/* Copyright (C) 2003-2008 Shay Green. This module is free software; you +can redistribute it and/or modify it under the terms of the GNU Lesser +General Public License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. This +module is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +details. You should have received a copy of the GNU Lesser General Public +License along with this module; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ + +// Allows MWCW debugger to step through code properly +#ifdef CPU_BEGIN + CPU_BEGIN +#endif + +// Time +#define TIME() (s_time + s.base) +#define FLUSH_TIME() {s.time = s_time - time_offset;} +#define CACHE_TIME() {s_time = s.time + time_offset;} + +// Defaults +#ifndef CAN_WRITE_FAST + #define CAN_WRITE_FAST( addr ) 0 + #define WRITE_FAST( addr, data ) +#endif + +#ifndef CAN_READ_FAST + #define CAN_READ_FAST( addr ) 0 + #define READ_FAST( addr, out ) +#endif + +#ifndef READ_PPU + #define READ_PPU( addr, out )\ + {\ + FLUSH_TIME();\ + out = READ_MEM( addr );\ + CACHE_TIME();\ + } +#endif + +#define READ_STACK READ_LOW +#define WRITE_STACK WRITE_LOW + +// Dummy reads +#ifdef NES_CPU_DUMMY_READS + // TODO: optimize time handling + #define DUMMY_READ( addr, idx ) \ + if ( (addr & 0xFF) < idx )\ + {\ + int const time_offset = 1;\ + FLUSH_TIME();\ + READ_MEM( (addr - 0x100) );\ + CACHE_TIME();\ + } +#else + #define DUMMY_READ( addr, idx ) +#endif + +// Code +#ifdef FLAT_MEM + #define CODE_PAGE( addr ) (FLAT_MEM) + #define CODE_OFFSET( addr ) (addr) +#else + #define CODE_PAGE( addr ) (s.code_map [NES_CPU_PAGE( addr )]) + #define CODE_OFFSET( addr ) NES_CPU_OFFSET( addr ) +#endif +#define READ_CODE( addr ) (CODE_PAGE( addr ) [CODE_OFFSET( addr )]) + +// Stack +#define SET_SP( v ) (sp = ((v) + 1) | 0x100) +#define GET_SP() ((sp - 1) & 0xFF) +#define SP( o ) ((sp + (o - (o>0)*0x100)) | 0x100) + +// Truncation +#define BYTE( n ) ((uint8_t ) (n)) /* (unsigned) n & 0xFF */ +#define SBYTE( n ) ((int8_t ) (n)) /* (BYTE( n ) ^ 0x80) - 0x80 */ +#define WORD( n ) ((uint16_t) (n)) /* (unsigned) n & 0xFFFF */ + +// Flags with hex value for clarity when used as mask. +// Stored in indicated variable during emulation. +int const n80 = 0x80; // nz +int const v40 = 0x40; // flags +int const r20 = 0x20; +int const b10 = 0x10; +int const d08 = 0x08; // flags +int const i04 = 0x04; // flags +int const z02 = 0x02; // nz +int const c01 = 0x01; // c + +#define IS_NEG (nz & 0x8080) + +#define GET_FLAGS( out ) \ +{\ + out = flags & (v40 | d08 | i04);\ + out += ((nz >> 8) | nz) & n80;\ + out += c >> 8 & c01;\ + if ( !BYTE( nz ) )\ + out += z02;\ +} + +#define SET_FLAGS( in ) \ +{\ + flags = in & (v40 | d08 | i04);\ + c = nz = in << 8;\ + nz += ~in & z02;\ +} + +{ + int const time_offset = 0; + + // Local state + struct cpu_state_t s; + #ifdef FLAT_MEM + s.base = cpu->cpu_state_.base; + #else + s = cpu->cpu_state_; + #endif + cpu->cpu_state = &s; + int s_time = cpu->cpu_state_.time; // helps even on x86 + + // Registers + int pc = cpu->r.pc; + int a = cpu->r.a; + int x = cpu->r.x; + int y = cpu->r.y; + int sp; + SET_SP( cpu->r.sp ); + + // Flags + int flags; + int c; // carry set if (c & 0x100) != 0 + int nz; // Z set if (nz & 0xFF) == 0, N set if (nz & 0x8080) != 0 + { + int temp = cpu->r.flags; + SET_FLAGS( temp ); + } + +loop: + + // Check all values + check( (unsigned) sp - 0x100 < 0x100 ); + check( (unsigned) pc < 0x10000 ); + check( (unsigned) a < 0x100 ); + check( (unsigned) x < 0x100 ); + check( (unsigned) y < 0x100 ); + + // Read instruction + byte const* instr = CODE_PAGE( pc ); + int opcode; + + if ( CODE_OFFSET(~0) == ~0 ) + { + opcode = instr [pc]; + pc++; + instr += pc; + } + else + { + instr += CODE_OFFSET( pc ); + opcode = *instr++; + pc++; + } + + // local to function in case it helps optimizer + static byte const clock_table [256] = + {// 0 1 2 3 4 5 6 7 8 9 A B C D E F + 0,6,2,8,3,3,5,5,3,2,2,2,4,4,6,6,// 0 + 2,5,2,8,4,4,6,6,2,4,2,7,4,4,7,7,// 1 + 6,6,0,8,3,3,5,5,4,2,2,2,4,4,6,6,// 2 + 2,5,2,8,4,4,6,6,2,4,2,7,4,4,7,7,// 3 + 6,6,2,8,3,3,5,5,3,2,2,2,3,4,6,6,// 4 + 2,5,2,8,4,4,6,6,2,4,2,7,4,4,7,7,// 5 + 6,6,2,8,3,3,5,5,4,2,2,2,5,4,6,6,// 6 + 2,5,2,8,4,4,6,6,2,4,2,7,4,4,7,7,// 7 + 2,6,2,6,3,3,3,3,2,2,2,2,4,4,4,4,// 8 + 2,6,2,6,4,4,4,4,2,5,2,5,5,5,5,5,// 9 + 2,6,2,6,3,3,3,3,2,2,2,2,4,4,4,4,// A + 2,5,2,5,4,4,4,4,2,4,2,4,4,4,4,4,// B + 2,6,2,8,3,3,5,5,2,2,2,2,4,4,6,6,// C + 2,5,2,8,4,4,6,6,2,4,2,7,4,4,7,7,// D + 2,6,2,8,3,3,5,5,2,2,2,2,4,4,6,6,// E + 2,5,2,8,4,4,6,6,2,4,2,7,4,4,7,7 // F + }; // 0x00 was 7 and 0x22 was 2 + + // Update time + if ( s_time >= 0 ) + goto out_of_time; + + #ifdef CPU_INSTR_HOOK + { CPU_INSTR_HOOK( (pc-1), (&instr [-1]), a, x, y, GET_SP(), TIME() ); } + #endif + + s_time += clock_table [opcode]; + + int data; + data = *instr; + + switch ( opcode ) + { + +// Macros + +#define GET_MSB() (instr [1]) +#define ADD_PAGE( out ) (pc++, out = data + 0x100 * GET_MSB()) +#define GET_ADDR() GET_LE16( instr ) + +#define PAGE_PENALTY( lsb ) s_time += (lsb) >> 8; + +#define INC_DEC( reg, n ) reg = BYTE( nz = reg + n ); goto loop; + +#define IND_Y( cross, out ) {\ + int temp = READ_LOW( data ) + y;\ + out = temp + 0x100 * READ_LOW( BYTE( data + 1 ) );\ + cross( temp );\ + } + +#define IND_X( out ) {\ + int temp = data + x;\ + out = 0x100 * READ_LOW( BYTE( temp + 1 ) ) + READ_LOW( BYTE( temp ) );\ + } + +#define ARITH_ADDR_MODES( op )\ +case op - 0x04: /* (ind,x) */\ + IND_X( data )\ + goto ptr##op;\ +case op + 0x0C: /* (ind),y */\ + IND_Y( PAGE_PENALTY, data )\ + goto ptr##op;\ +case op + 0x10: /* zp,X */\ + data = BYTE( data + x );\ +case op + 0x00: /* zp */\ + data = READ_LOW( data );\ + goto imm##op;\ +case op + 0x14: /* abs,Y */\ + data += y;\ + goto ind##op;\ +case op + 0x18: /* abs,X */\ + data += x;\ +ind##op:\ + PAGE_PENALTY( data );\ +case op + 0x08: /* abs */\ + ADD_PAGE( data );\ +ptr##op:\ + FLUSH_TIME();\ + data = READ_MEM( data );\ + CACHE_TIME();\ +case op + 0x04: /* imm */\ +imm##op: + +// TODO: more efficient way to handle negative branch that wraps PC around +#define BRANCH( cond )\ +{\ + ++pc;\ + if ( !(cond) ) goto loop;\ + s_time++;\ + int offset = SBYTE( data );\ + s_time += (BYTE(pc) + offset) >> 8 & 1;\ + pc = WORD( pc + offset );\ + goto loop;\ +} + +// Often-Used + + case 0xB5: // LDA zp,x + a = nz = READ_LOW( BYTE( data + x ) ); + pc++; + goto loop; + + case 0xA5: // LDA zp + a = nz = READ_LOW( data ); + pc++; + goto loop; + + case 0xD0: // BNE + BRANCH( BYTE( nz ) ); + + case 0x20: { // JSR + int temp = pc + 1; + pc = GET_ADDR(); + WRITE_STACK( SP( -1 ), temp >> 8 ); + sp = SP( -2 ); + WRITE_STACK( sp, temp ); + goto loop; + } + + case 0x4C: // JMP abs + pc = GET_ADDR(); + goto loop; + + case 0xE8: // INX + INC_DEC( x, 1 ) + + case 0x10: // BPL + BRANCH( !IS_NEG ) + + ARITH_ADDR_MODES( 0xC5 ) // CMP + nz = a - data; + pc++; + c = ~nz; + nz &= 0xFF; + goto loop; + + case 0x30: // BMI + BRANCH( IS_NEG ) + + case 0xF0: // BEQ + BRANCH( !BYTE( nz ) ); + + case 0x95: // STA zp,x + data = BYTE( data + x ); + case 0x85: // STA zp + pc++; + WRITE_LOW( data, a ); + goto loop; + + case 0xC8: // INY + INC_DEC( y, 1 ) + + case 0xA8: // TAY + y = a; + nz = a; + goto loop; + + case 0x98: // TYA + a = y; + nz = y; + goto loop; + + case 0xAD:{// LDA abs + int addr = GET_ADDR(); + pc += 2; + READ_PPU( addr, a = nz ); + goto loop; + } + + case 0x60: // RTS + pc = 1 + READ_STACK( sp ); + pc += 0x100 * READ_STACK( SP( 1 ) ); + sp = SP( 2 ); + goto loop; + + { + int addr; + + case 0x8D: // STA abs + addr = GET_ADDR(); + pc += 2; + if ( CAN_WRITE_FAST( addr ) ) + { + WRITE_FAST( addr, a ); + goto loop; + } + sta_ptr: + FLUSH_TIME(); + WRITE_MEM( addr, a ); + CACHE_TIME(); + goto loop; + + case 0x99: // STA abs,Y + addr = y + GET_ADDR(); + pc += 2; + if ( CAN_WRITE_FAST( addr ) ) + { + WRITE_FAST( addr, a ); + goto loop; + } + goto sta_abs_x; + + case 0x9D: // STA abs,X (slightly more common than STA abs) + addr = x + GET_ADDR(); + pc += 2; + if ( CAN_WRITE_FAST( addr ) ) + { + WRITE_FAST( addr, a ); + goto loop; + } + DUMMY_READ( addr, x ); + sta_abs_x: + FLUSH_TIME(); + WRITE_MEM( addr, a ); + CACHE_TIME(); + goto loop; + + case 0x91: // STA (ind),Y + #define NO_PAGE_PENALTY( lsb ) + IND_Y( NO_PAGE_PENALTY, addr ) + pc++; + DUMMY_READ( addr, y ); + goto sta_ptr; + + case 0x81: // STA (ind,X) + IND_X( addr ) + pc++; + goto sta_ptr; + + } + + case 0xA9: // LDA #imm + pc++; + a = data; + nz = data; + goto loop; + + // common read instructions + { + int addr; + + case 0xA1: // LDA (ind,X) + IND_X( addr ) + pc++; + goto a_nz_read_addr; + + case 0xB1:// LDA (ind),Y + addr = READ_LOW( data ) + y; + PAGE_PENALTY( addr ); + addr += 0x100 * READ_LOW( BYTE( data + 1 ) ); + pc++; + READ_FAST( addr, a = nz ); + if ( CAN_READ_FAST( addr ) ) + goto loop; + DUMMY_READ( addr, y ); + goto a_nz_read_addr; + + case 0xB9: // LDA abs,Y + PAGE_PENALTY( data + y ); + addr = GET_ADDR() + y; + pc += 2; + READ_FAST( addr, a = nz ); + if ( CAN_READ_FAST( addr ) ) + goto loop; + goto a_nz_read_addr; + + case 0xBD: // LDA abs,X + PAGE_PENALTY( data + x ); + addr = GET_ADDR() + x; + pc += 2; + READ_FAST( addr, a = nz ); + if ( CAN_READ_FAST( addr ) ) + goto loop; + DUMMY_READ( addr, x ); + a_nz_read_addr: + FLUSH_TIME(); + a = nz = READ_MEM( addr ); + CACHE_TIME(); + goto loop; + + } + +// Branch + + case 0x50: // BVC + BRANCH( !(flags & v40) ) + + case 0x70: // BVS + BRANCH( flags & v40 ) + + case 0xB0: // BCS + BRANCH( c & 0x100 ) + + case 0x90: // BCC + BRANCH( !(c & 0x100) ) + +// Load/store + + case 0x94: // STY zp,x + data = BYTE( data + x ); + case 0x84: // STY zp + pc++; + WRITE_LOW( data, y ); + goto loop; + + case 0x96: // STX zp,y + data = BYTE( data + y ); + case 0x86: // STX zp + pc++; + WRITE_LOW( data, x ); + goto loop; + + case 0xB6: // LDX zp,y + data = BYTE( data + y ); + case 0xA6: // LDX zp + data = READ_LOW( data ); + case 0xA2: // LDX #imm + pc++; + x = data; + nz = data; + goto loop; + + case 0xB4: // LDY zp,x + data = BYTE( data + x ); + case 0xA4: // LDY zp + data = READ_LOW( data ); + case 0xA0: // LDY #imm + pc++; + y = data; + nz = data; + goto loop; + + case 0xBC: // LDY abs,X + data += x; + PAGE_PENALTY( data ); + case 0xAC:{// LDY abs + int addr = data + 0x100 * GET_MSB(); + pc += 2; + FLUSH_TIME(); + y = nz = READ_MEM( addr ); + CACHE_TIME(); + goto loop; + } + + case 0xBE: // LDX abs,y + data += y; + PAGE_PENALTY( data ); + case 0xAE:{// LDX abs + int addr = data + 0x100 * GET_MSB(); + pc += 2; + FLUSH_TIME(); + x = nz = READ_MEM( addr ); + CACHE_TIME(); + goto loop; + } + + { + int temp; + case 0x8C: // STY abs + temp = y; + goto store_abs; + + case 0x8E: // STX abs + temp = x; + store_abs: + { + int addr = GET_ADDR(); + pc += 2; + if ( CAN_WRITE_FAST( addr ) ) + { + WRITE_FAST( addr, temp ); + goto loop; + } + FLUSH_TIME(); + WRITE_MEM( addr, temp ); + CACHE_TIME(); + goto loop; + } + } + +// Compare + + case 0xEC: {// CPX abs + int addr = GET_ADDR(); + pc++; + FLUSH_TIME(); + data = READ_MEM( addr ); + CACHE_TIME(); + goto cpx_data; + } + + case 0xE4: // CPX zp + data = READ_LOW( data ); + case 0xE0: // CPX #imm + cpx_data: + nz = x - data; + pc++; + c = ~nz; + nz &= 0xFF; + goto loop; + + case 0xCC:{// CPY abs + int addr = GET_ADDR(); + pc++; + FLUSH_TIME(); + data = READ_MEM( addr ); + CACHE_TIME(); + goto cpy_data; + } + + case 0xC4: // CPY zp + data = READ_LOW( data ); + case 0xC0: // CPY #imm + cpy_data: + nz = y - data; + pc++; + c = ~nz; + nz &= 0xFF; + goto loop; + +// Logical + + ARITH_ADDR_MODES( 0x25 ) // AND + nz = (a &= data); + pc++; + goto loop; + + ARITH_ADDR_MODES( 0x45 ) // EOR + nz = (a ^= data); + pc++; + goto loop; + + ARITH_ADDR_MODES( 0x05 ) // ORA + nz = (a |= data); + pc++; + goto loop; + + case 0x2C:{// BIT abs + int addr = GET_ADDR(); + pc += 2; + READ_PPU( addr, nz ); + flags = (flags & ~v40) + (nz & v40); + if ( a & nz ) + goto loop; + nz <<= 8; // result must be zero, even if N bit is set + goto loop; + } + + case 0x24: // BIT zp + nz = READ_LOW( data ); + pc++; + flags = (flags & ~v40) + (nz & v40); + if ( a & nz ) + goto loop; // Z should be clear, and nz must be non-zero if nz & a is + nz <<= 8; // set Z flag without affecting N flag + goto loop; + +// Add/subtract + + ARITH_ADDR_MODES( 0xE5 ) // SBC + case 0xEB: // unofficial equivalent + data ^= 0xFF; + goto adc_imm; + + ARITH_ADDR_MODES( 0x65 ) // ADC + adc_imm: { + int carry = c >> 8 & 1; + int ov = (a ^ 0x80) + carry + SBYTE( data ); + flags = (flags & ~v40) + (ov >> 2 & v40); + c = nz = a + data + carry; + pc++; + a = BYTE( nz ); + goto loop; + } + +// Shift/rotate + + case 0x4A: // LSR A + c = 0; + case 0x6A: // ROR A + nz = c >> 1 & 0x80; + c = a << 8; + nz += a >> 1; + a = nz; + goto loop; + + case 0x0A: // ASL A + nz = a << 1; + c = nz; + a = BYTE( nz ); + goto loop; + + case 0x2A: { // ROL A + nz = a << 1; + int temp = c >> 8 & 1; + c = nz; + nz += temp; + a = BYTE( nz ); + goto loop; + } + + case 0x5E: // LSR abs,X + data += x; + case 0x4E: // LSR abs + c = 0; + case 0x6E: // ROR abs + ror_abs: { + ADD_PAGE( data ); + FLUSH_TIME(); + int temp = READ_MEM( data ); + nz = (c >> 1 & 0x80) + (temp >> 1); + c = temp << 8; + goto rotate_common; + } + + case 0x3E: // ROL abs,X + data += x; + goto rol_abs; + + case 0x1E: // ASL abs,X + data += x; + case 0x0E: // ASL abs + c = 0; + case 0x2E: // ROL abs + rol_abs: + ADD_PAGE( data ); + nz = c >> 8 & 1; + FLUSH_TIME(); + nz += (c = READ_MEM( data ) << 1); + rotate_common: + pc++; + WRITE_MEM( data, BYTE( nz ) ); + CACHE_TIME(); + goto loop; + + case 0x7E: // ROR abs,X + data += x; + goto ror_abs; + + case 0x76: // ROR zp,x + data = BYTE( data + x ); + goto ror_zp; + + case 0x56: // LSR zp,x + data = BYTE( data + x ); + case 0x46: // LSR zp + c = 0; + case 0x66: // ROR zp + ror_zp: { + int temp = READ_LOW( data ); + nz = (c >> 1 & 0x80) + (temp >> 1); + c = temp << 8; + goto write_nz_zp; + } + + case 0x36: // ROL zp,x + data = BYTE( data + x ); + goto rol_zp; + + case 0x16: // ASL zp,x + data = BYTE( data + x ); + case 0x06: // ASL zp + c = 0; + case 0x26: // ROL zp + rol_zp: + nz = c >> 8 & 1; + nz += (c = READ_LOW( data ) << 1); + goto write_nz_zp; + +// Increment/decrement + + case 0xCA: // DEX + INC_DEC( x, -1 ) + + case 0x88: // DEY + INC_DEC( y, -1 ) + + case 0xF6: // INC zp,x + data = BYTE( data + x ); + case 0xE6: // INC zp + nz = 1; + goto add_nz_zp; + + case 0xD6: // DEC zp,x + data = BYTE( data + x ); + case 0xC6: // DEC zp + nz = -1; + add_nz_zp: + nz += READ_LOW( data ); + write_nz_zp: + pc++; + WRITE_LOW( data, nz ); + goto loop; + + case 0xFE: // INC abs,x + data = x + GET_ADDR(); + goto inc_ptr; + + case 0xEE: // INC abs + data = GET_ADDR(); + inc_ptr: + nz = 1; + goto inc_common; + + case 0xDE: // DEC abs,x + data = x + GET_ADDR(); + goto dec_ptr; + + case 0xCE: // DEC abs + data = GET_ADDR(); + dec_ptr: + nz = -1; + inc_common: + FLUSH_TIME(); + pc += 2; + nz += READ_MEM( data ); + WRITE_MEM( data, BYTE( nz ) ); + CACHE_TIME(); + goto loop; + +// Transfer + + case 0xAA: // TAX + x = nz = a; + goto loop; + + case 0x8A: // TXA + a = nz = x; + goto loop; + + case 0x9A: // TXS + SET_SP( x ); // verified (no flag change) + goto loop; + + case 0xBA: // TSX + x = nz = GET_SP(); + goto loop; + +// Stack + + case 0x48: // PHA + sp = SP( -1 ); + WRITE_STACK( sp, a ); + goto loop; + + case 0x68: // PLA + a = nz = READ_STACK( sp ); + sp = SP( 1 ); + goto loop; + + case 0x40:{// RTI + pc = READ_STACK( SP( 1 ) ); + pc += READ_STACK( SP( 2 ) ) * 0x100; + int temp = READ_STACK( sp ); + sp = SP( 3 ); + data = flags; + SET_FLAGS( temp ); + cpu->r.flags = flags; // update externally-visible I flag + int delta = s.base - cpu->irq_time; + if ( delta <= 0 ) goto loop; // end_time < irq_time + if ( flags & i04 ) goto loop; + s_time += delta; + s.base = cpu->irq_time; + goto loop; + } + + case 0x28:{// PLP + int temp = READ_STACK( sp ); + sp = SP( 1 ); + int changed = flags ^ temp; + SET_FLAGS( temp ); + if ( !(changed & i04) ) + goto loop; // I flag didn't change + if ( flags & i04 ) + goto handle_sei; + goto handle_cli; + } + + case 0x08:{// PHP + int temp; + GET_FLAGS( temp ); + sp = SP( -1 ); + WRITE_STACK( sp, temp | (b10 | r20) ); + goto loop; + } + + case 0x6C:{// JMP (ind) + data = GET_ADDR(); + byte const* page = CODE_PAGE( data ); + pc = page [CODE_OFFSET( data )]; + data = (data & 0xFF00) + ((data + 1) & 0xFF); + pc += page [CODE_OFFSET( data )] * 0x100; + goto loop; + } + + case 0x00: // BRK + goto handle_brk; + +// Flags + + case 0x38: // SEC + c = 0x100; + goto loop; + + case 0x18: // CLC + c = 0; + goto loop; + + case 0xB8: // CLV + flags &= ~v40; + goto loop; + + case 0xD8: // CLD + flags &= ~d08; + goto loop; + + case 0xF8: // SED + flags |= d08; + goto loop; + + case 0x58: // CLI + if ( !(flags & i04) ) + goto loop; + flags &= ~i04; + handle_cli: { + //dprintf( "CLI at %d\n", TIME ); + cpu->r.flags = flags; // update externally-visible I flag + int delta = s.base - cpu->irq_time; + if ( delta <= 0 ) + { + if ( TIME() < cpu->irq_time ) + goto loop; + goto delayed_cli; + } + s.base = cpu->irq_time; + s_time += delta; + if ( s_time < 0 ) + goto loop; + + if ( delta >= s_time + 1 ) + { + // delayed irq until after next instruction + s.base += s_time + 1; + s_time = -1; + goto loop; + } + + // TODO: implement + delayed_cli: + dprintf( "Delayed CLI not emulated\n" ); + goto loop; + } + + case 0x78: // SEI + if ( flags & i04 ) + goto loop; + flags |= i04; + handle_sei: { + cpu->r.flags = flags; // update externally-visible I flag + int delta = s.base - cpu->end_time; + s.base = cpu->end_time; + s_time += delta; + if ( s_time < 0 ) + goto loop; + + dprintf( "Delayed SEI not emulated\n" ); + goto loop; + } + +// Unofficial + + // SKW - skip word + case 0x1C: case 0x3C: case 0x5C: case 0x7C: case 0xDC: case 0xFC: + PAGE_PENALTY( data + x ); + case 0x0C: + pc++; + // SKB - skip byte + case 0x74: case 0x04: case 0x14: case 0x34: case 0x44: case 0x54: case 0x64: + case 0x80: case 0x82: case 0x89: case 0xC2: case 0xD4: case 0xE2: case 0xF4: + pc++; + goto loop; + + // NOP + case 0xEA: case 0x1A: case 0x3A: case 0x5A: case 0x7A: case 0xDA: case 0xFA: + goto loop; + + case halt_opcode: // HLT - halt processor + if ( pc-- > 0x10000 ) + { + // handle wrap-around (assumes caller has put page of HLT at 0x10000) + pc = WORD( pc ); + goto loop; + } + case 0x02: case 0x12: case 0x32: case 0x42: case 0x52: + case 0x62: case 0x72: case 0x92: case 0xB2: case 0xD2: case 0xF2: + goto stop; + +// Unimplemented + + case 0xFF: // force 256-entry jump table for optimization purposes + c |= 1; // compiler doesn't know that this won't affect anything + default: + check( (unsigned) opcode < 0x100 ); + + #ifdef UNIMPL_INSTR + UNIMPL_INSTR(); + #endif + + // At least skip over proper number of bytes instruction uses + static unsigned char const illop_lens [8] = { + 0x40, 0x40, 0x40, 0x80, 0x40, 0x40, 0x80, 0xA0 + }; + int opcode = instr [-1]; + int len = illop_lens [opcode >> 2 & 7] >> (opcode << 1 & 6) & 3; + if ( opcode == 0x9C ) + len = 2; + pc += len; + + // Account for extra clock + if ( (opcode >> 4) == 0x0B ) + { + if ( opcode == 0xB3 ) + data = READ_LOW( data ); + if ( opcode != 0xB7 ) + PAGE_PENALTY( data + y ); + } + goto loop; + } + assert( false ); // catch missing 'goto loop' or accidental 'break' + + int result_; +handle_brk: + pc++; + result_ = b10 | 4; + +#ifdef CPU_DONE +interrupt: +#endif + { + s_time += 7; + + // Save PC and read vector + WRITE_STACK( SP( -1 ), pc >> 8 ); + WRITE_STACK( SP( -2 ), pc ); + pc = GET_LE16( &READ_CODE( 0xFFFA ) + (result_ & 4) ); + + // Save flags + int temp; + GET_FLAGS( temp ); + temp |= r20 + (result_ & b10); // B flag set for BRK + sp = SP( -3 ); + WRITE_STACK( sp, temp ); + + // Update I flag in externally-visible flags + cpu->r.flags = (flags |= i04); + + // Update time + int delta = s.base - cpu->end_time; + if ( delta >= 0 ) + goto loop; + s_time += delta; + s.base = cpu->end_time; + goto loop; + } + +out_of_time: + pc--; + + // Optional action that triggers interrupt or changes irq/end time + #ifdef CPU_DONE + { + CPU_DONE( result_ ); + if ( result_ >= 0 ) + goto interrupt; + if ( s_time < 0 ) + goto loop; + } + #endif +stop: + + // Flush cached state + cpu->r.pc = pc; + cpu->r.sp = GET_SP(); + cpu->r.a = a; + cpu->r.x = x; + cpu->r.y = y; + + int temp; + GET_FLAGS( temp ); + cpu->r.flags = temp; + + cpu->cpu_state_.base = s.base; + cpu->cpu_state_.time = s_time; + cpu->cpu_state = &cpu->cpu_state_; +} diff --git a/lib/rbcodec/codecs/libgme/nes_fds_apu.c b/lib/rbcodec/codecs/libgme/nes_fds_apu.c new file mode 100644 index 0000000000..dc0775d5d3 --- /dev/null +++ b/lib/rbcodec/codecs/libgme/nes_fds_apu.c @@ -0,0 +1,291 @@ +// Game_Music_Emu 0.6-pre. http://www.slack.net/~ant/ + +#include "nes_fds_apu.h" + +/* Copyright (C) 2006 Shay Green. This module is free software; you +can redistribute it and/or modify it under the terms of the GNU Lesser +General Public License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. This +module is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +details. You should have received a copy of the GNU Lesser General Public +License along with this module; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ + +#include "blargg_source.h" + +int const fract_range = 65536; + +void Fds_init( struct Nes_Fds_Apu* this ) +{ + Synth_init( &this->synth ); + + this->lfo_tempo = lfo_base_tempo; + Fds_set_output( this, 0, NULL ); + Fds_volume( this, (int)FP_ONE_VOLUME ); + Fds_reset( this ); +} + +void Fds_reset( struct Nes_Fds_Apu* this ) +{ + memset( this->regs_, 0, sizeof this->regs_ ); + memset( this->mod_wave, 0, sizeof this->mod_wave ); + + this->last_time = 0; + this->env_delay = 0; + this->sweep_delay = 0; + this->wave_pos = 0; + this->last_amp = 0; + this->wave_fract = fract_range; + this->mod_fract = fract_range; + this->mod_pos = 0; + this->mod_write_pos = 0; + + static byte const initial_regs [0x0B] = { + 0x80, // disable envelope + 0, 0, 0xC0, // disable wave and lfo + 0x80, // disable sweep + 0, 0, 0x80, // disable modulation + 0, 0, 0xFF // LFO period // TODO: use 0xE8 as FDS ROM does? + }; + int i; + for ( i = 0; i < (int) sizeof initial_regs; i++ ) + { + // two writes to set both gain and period for envelope registers + Fds_write_( this, fds_io_addr + fds_wave_size + i, 0 ); + Fds_write_( this, fds_io_addr + fds_wave_size + i, initial_regs [i] ); + } +} + +void Fds_write_( struct Nes_Fds_Apu* this, unsigned addr, int data ) +{ + unsigned reg = addr - fds_io_addr; + if ( reg < fds_io_size ) + { + if ( reg < fds_wave_size ) + { + if ( *regs_nes (this, 0x4089) & 0x80 ) + this->regs_ [reg] = data & fds_wave_sample_max; + } + else + { + this->regs_ [reg] = data; + switch ( addr ) + { + case 0x4080: + if ( data & 0x80 ) + this->env_gain = data & 0x3F; + else + this->env_speed = (data & 0x3F) + 1; + break; + + case 0x4084: + if ( data & 0x80 ) + this->sweep_gain = data & 0x3F; + else + this->sweep_speed = (data & 0x3F) + 1; + break; + + case 0x4085: + this->mod_pos = this->mod_write_pos; + *regs_nes (this, 0x4085) = data & 0x7F; + break; + + case 0x4088: + if ( *regs_nes (this, 0x4087) & 0x80 ) + { + int pos = this->mod_write_pos; + data &= 0x07; + this->mod_wave [pos ] = data; + this->mod_wave [pos + 1] = data; + this->mod_write_pos = (pos + 2) & (fds_wave_size - 1); + this->mod_pos = (this->mod_pos + 2) & (fds_wave_size - 1); + } + break; + } + } + } +} + +void Fds_set_tempo( struct Nes_Fds_Apu* this, int t ) +{ + this->lfo_tempo = lfo_base_tempo; + if ( t != (int)FP_ONE_TEMPO ) + { + this->lfo_tempo = (int) ((lfo_base_tempo * FP_ONE_TEMPO) / t); + if ( this->lfo_tempo <= 0 ) + this->lfo_tempo = 1; + } +} + +void Fds_run_until( struct Nes_Fds_Apu* this, blip_time_t final_end_time ) +{ + int const wave_freq = (*regs_nes (this, 0x4083) & 0x0F) * 0x100 + *regs_nes (this, 0x4082); + struct Blip_Buffer* const output_ = this->output_; + if ( wave_freq && output_ && !((*regs_nes (this, 0x4089) | *regs_nes (this, 0x4083)) & 0x80) ) + { + Blip_set_modified( output_ ); + + // master_volume + #define MVOL_ENTRY( percent ) (fds_master_vol_max * percent + 50) / 100 + static unsigned char const master_volumes [4] = { + MVOL_ENTRY( 100 ), MVOL_ENTRY( 67 ), MVOL_ENTRY( 50 ), MVOL_ENTRY( 40 ) + }; + int const master_volume = master_volumes [*regs_nes (this, 0x4089) & 0x03]; + + // lfo_period + blip_time_t lfo_period = *regs_nes (this, 0x408A) * this->lfo_tempo; + if ( *regs_nes (this, 0x4083) & 0x40 ) + lfo_period = 0; + + // sweep setup + blip_time_t sweep_time = this->last_time + this->sweep_delay; + blip_time_t const sweep_period = lfo_period * this->sweep_speed; + if ( !sweep_period || *regs_nes (this, 0x4084) & 0x80 ) + sweep_time = final_end_time; + + // envelope setup + blip_time_t env_time = this->last_time + this->env_delay; + blip_time_t const env_period = lfo_period * this->env_speed; + if ( !env_period || *regs_nes (this, 0x4080) & 0x80 ) + env_time = final_end_time; + + // modulation + int mod_freq = 0; + if ( !(*regs_nes (this, 0x4087) & 0x80) ) + mod_freq = (*regs_nes (this, 0x4087) & 0x0F) * 0x100 + *regs_nes (this, 0x4086); + + blip_time_t end_time = this->last_time; + do + { + // sweep + if ( sweep_time <= end_time ) + { + sweep_time += sweep_period; + int mode = *regs_nes (this, 0x4084) >> 5 & 2; + int new_sweep_gain = this->sweep_gain + mode - 1; + if ( (unsigned) new_sweep_gain <= (unsigned) 0x80 >> mode ) + this->sweep_gain = new_sweep_gain; + else + *regs_nes (this, 0x4084) |= 0x80; // optimization only + } + + // envelope + if ( env_time <= end_time ) + { + env_time += env_period; + int mode = *regs_nes (this, 0x4080) >> 5 & 2; + int new_env_gain = this->env_gain + mode - 1; + if ( (unsigned) new_env_gain <= (unsigned) 0x80 >> mode ) + this->env_gain = new_env_gain; + else + *regs_nes (this, 0x4080) |= 0x80; // optimization only + } + + // new end_time + blip_time_t const start_time = end_time; + end_time = final_end_time; + if ( end_time > env_time ) end_time = env_time; + if ( end_time > sweep_time ) end_time = sweep_time; + + // frequency modulation + int freq = wave_freq; + if ( mod_freq ) + { + // time of next modulation clock + blip_time_t mod_time = start_time + (this->mod_fract + mod_freq - 1) / mod_freq; + if ( end_time > mod_time ) + end_time = mod_time; + + // run modulator up to next clock and save old sweep_bias + int sweep_bias = *regs_nes (this, 0x4085); + this->mod_fract -= (end_time - start_time) * mod_freq; + if ( this->mod_fract <= 0 ) + { + this->mod_fract += fract_range; + check( (unsigned) this->mod_fract <= fract_range ); + + static short const mod_table [8] = { 0, +1, +2, +4, 0, -4, -2, -1 }; + int mod = this->mod_wave [this->mod_pos]; + this->mod_pos = (this->mod_pos + 1) & (fds_wave_size - 1); + int new_sweep_bias = (sweep_bias + mod_table [mod]) & 0x7F; + if ( mod == 4 ) + new_sweep_bias = 0; + *regs_nes (this, 0x4085) = new_sweep_bias; + } + + // apply frequency modulation + sweep_bias = (sweep_bias ^ 0x40) - 0x40; + int factor = sweep_bias * this->sweep_gain; + int extra = factor & 0x0F; + factor >>= 4; + if ( extra ) + { + factor--; + if ( sweep_bias >= 0 ) + factor += 3; + } + if ( factor > 193 ) factor -= 258; + if ( factor < -64 ) factor += 256; + freq += (freq * factor) >> 6; + if ( freq <= 0 ) + continue; + } + + // wave + int wave_fract = this->wave_fract; + blip_time_t delay = (wave_fract + freq - 1) / freq; + blip_time_t time = start_time + delay; + + if ( time <= end_time ) + { + // at least one wave clock within start_time...end_time + + blip_time_t const min_delay = fract_range / freq; + int wave_pos = this->wave_pos; + + int volume = this->env_gain; + if ( volume > fds_vol_max ) + volume = fds_vol_max; + volume *= master_volume; + + int const min_fract = min_delay * freq; + + do + { + // clock wave + int amp = this->regs_ [wave_pos] * volume; + wave_pos = (wave_pos + 1) & (fds_wave_size - 1); + int delta = amp - this->last_amp; + if ( delta ) + { + this->last_amp = amp; + Synth_offset_inline( &this->synth, time, delta, output_ ); + } + + wave_fract += fract_range - delay * freq; + check( unsigned (fract_range - wave_fract) < freq ); + + // delay until next clock + delay = min_delay; + if ( wave_fract > min_fract ) + delay++; + check( delay && delay == (wave_fract + freq - 1) / freq ); + + time += delay; + } + while ( time <= end_time ); // TODO: using < breaks things, but <= is wrong + + this->wave_pos = wave_pos; + } + this->wave_fract = wave_fract - (end_time - (time - delay)) * freq; + check( this->wave_fract > 0 ); + } + while ( end_time < final_end_time ); + + this->env_delay = env_time - final_end_time; check( env_delay >= 0 ); + this->sweep_delay = sweep_time - final_end_time; check( sweep_delay >= 0 ); + } + this->last_time = final_end_time; +} diff --git a/lib/rbcodec/codecs/libgme/nes_fds_apu.h b/lib/rbcodec/codecs/libgme/nes_fds_apu.h new file mode 100644 index 0000000000..8dac3b721a --- /dev/null +++ b/lib/rbcodec/codecs/libgme/nes_fds_apu.h @@ -0,0 +1,116 @@ +// NES FDS sound chip emulator + +// Game_Music_Emu 0.6-pre +#ifndef NES_FDS_APU_H +#define NES_FDS_APU_H + +#include "blargg_common.h" +#include "blip_buffer.h" + +enum { lfo_base_tempo = 8 }; +enum { fds_osc_count = 1 }; + +enum { fds_io_addr = 0x4040 }; +enum { fds_io_size = 0x53 }; + +enum { fds_wave_size = 0x40 }; +enum { fds_master_vol_max = 10 }; +enum { fds_vol_max = 0x20 }; +enum { fds_wave_sample_max = 0x3F }; + +struct Nes_Fds_Apu { + unsigned char regs_ [fds_io_size];// last written value to registers + int lfo_tempo; // normally 8; adjusted by set_tempo() + + int env_delay; + int env_speed; + int env_gain; + + int sweep_delay; + int sweep_speed; + int sweep_gain; + + int wave_pos; + int last_amp; + blip_time_t wave_fract; + + int mod_fract; + int mod_pos; + int mod_write_pos; + unsigned char mod_wave [fds_wave_size]; + + // synthesis + blip_time_t last_time; + struct Blip_Buffer* output_; + struct Blip_Synth synth; +}; + +// init +void Fds_init( struct Nes_Fds_Apu* this ); +// setup +void Fds_set_tempo( struct Nes_Fds_Apu* this, int t ); + +// emulation +void Fds_reset( struct Nes_Fds_Apu* this ); + +static inline void Fds_volume( struct Nes_Fds_Apu* this, int v ) +{ + Synth_volume( &this->synth, (v*14) / 100 / fds_master_vol_max / fds_vol_max / fds_wave_sample_max ); +} + +static inline void Fds_set_output( struct Nes_Fds_Apu* this, int i, struct Blip_Buffer* b ) +{ +#if defined(ROCKBOX) + (void) i; +#endif + + assert( (unsigned) i < fds_osc_count ); + this->output_ = b; +} + +void Fds_run_until( struct Nes_Fds_Apu* this, blip_time_t ); +static inline void Fds_end_frame( struct Nes_Fds_Apu* this, blip_time_t end_time ) +{ + if ( end_time > this->last_time ) + Fds_run_until( this, end_time ); + this->last_time -= end_time; + assert( this->last_time >= 0 ); +} + +void Fds_write_( struct Nes_Fds_Apu* this, unsigned addr, int data ); +static inline void Fds_write( struct Nes_Fds_Apu* this, blip_time_t time, unsigned addr, int data ) +{ + Fds_run_until( this, time ); + Fds_write_( this, addr, data ); +} + +static inline int Fds_read( struct Nes_Fds_Apu* this, blip_time_t time, unsigned addr ) +{ + Fds_run_until( this, time ); + + int result = 0xFF; + switch ( addr ) + { + case 0x4090: + result = this->env_gain; + break; + + case 0x4092: + result = this->sweep_gain; + break; + + default: + { + unsigned i = addr - fds_io_addr; + if ( i < fds_wave_size ) + result = this->regs_ [i]; + } + } + + return result | 0x40; +} + +// allow access to registers by absolute address (i.e. 0x4080) +static inline unsigned char* regs_nes( struct Nes_Fds_Apu* this, unsigned addr ) { return &this->regs_ [addr - fds_io_addr]; } + +#endif diff --git a/lib/rbcodec/codecs/libgme/nes_fme7_apu.c b/lib/rbcodec/codecs/libgme/nes_fme7_apu.c new file mode 100644 index 0000000000..3e47e0b17c --- /dev/null +++ b/lib/rbcodec/codecs/libgme/nes_fme7_apu.c @@ -0,0 +1,136 @@ +// Game_Music_Emu 0.5.5. http://www.slack.net/~ant/ + +#include "nes_fme7_apu.h" + +#include + +/* Copyright (C) 2003-2006 Shay Green. This module is free software; you +can redistribute it and/or modify it under the terms of the GNU Lesser +General Public License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. This +module is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +details. You should have received a copy of the GNU Lesser General Public +License along with this module; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ + +#include "blargg_source.h" + +void Fme7_init( struct Nes_Fme7_Apu* this ) +{ + Synth_init( &this->synth ); + + Fme7_output( this, NULL ); + Fme7_volume( this, (int)FP_ONE_VOLUME ); + Fme7_reset( this ); +} + +void Fme7_reset( struct Nes_Fme7_Apu* this ) +{ + this->last_time = 0; + + int i; + for ( i = 0; i < fme7_osc_count; i++ ) + this->oscs [i].last_amp = 0; + + this->latch = 0; + memset( this->regs, 0, sizeof this->regs); + memset( this->phases, 0, sizeof this->phases ); + memset( this->delays, 0, sizeof this->delays ); +} + +static unsigned char const amp_table [16] = +{ + #define ENTRY( n ) (unsigned char) (n * amp_range + 0.5) + ENTRY(0.0000), ENTRY(0.0078), ENTRY(0.0110), ENTRY(0.0156), + ENTRY(0.0221), ENTRY(0.0312), ENTRY(0.0441), ENTRY(0.0624), + ENTRY(0.0883), ENTRY(0.1249), ENTRY(0.1766), ENTRY(0.2498), + ENTRY(0.3534), ENTRY(0.4998), ENTRY(0.7070), ENTRY(1.0000) + #undef ENTRY +}; + +void Fme7_run_until( struct Nes_Fme7_Apu* this, blip_time_t end_time ) +{ + require( end_time >= this->last_time ); + + int index; + for ( index = 0; index < fme7_osc_count; index++ ) + { + int mode = this->regs [7] >> index; + int vol_mode = this->regs [010 + index]; + int volume = amp_table [vol_mode & 0x0F]; + + struct Blip_Buffer* const osc_output = this->oscs [index].output; + if ( !osc_output ) + continue; + + // check for unsupported mode + #ifndef NDEBUG + if ( (mode & 011) <= 001 && vol_mode & 0x1F ) + debug_printf( "FME7 used unimplemented sound mode: %02X, vol_mode: %02X\n", + mode, vol_mode & 0x1F ); + #endif + + if ( (mode & 001) | (vol_mode & 0x10) ) + volume = 0; // noise and envelope aren't supported + + // period + int const period_factor = 16; + unsigned period = (this->regs [index * 2 + 1] & 0x0F) * 0x100 * period_factor + + this->regs [index * 2] * period_factor; + if ( period < 50 ) // around 22 kHz + { + volume = 0; + if ( !period ) // on my AY-3-8910A, period doesn't have extra one added + period = period_factor; + } + + // current amplitude + int amp = volume; + if ( !this->phases [index] ) + amp = 0; + + { + int delta = amp - this->oscs [index].last_amp; + if ( delta ) + { + this->oscs [index].last_amp = amp; + Blip_set_modified( osc_output ); + Synth_offset( &this->synth, this->last_time, delta, osc_output ); + } + } + + blip_time_t time = this->last_time + this->delays [index]; + if ( time < end_time ) + { + int delta = amp * 2 - volume; + Blip_set_modified( osc_output ); + if ( volume ) + { + do + { + delta = -delta; + Synth_offset_inline( &this->synth, time, delta, osc_output ); + time += period; + } + while ( time < end_time ); + + this->oscs [index].last_amp = (delta + volume) >> 1; + this->phases [index] = (delta > 0); + } + else + { + // maintain phase when silent + int count = (end_time - time + period - 1) / period; + this->phases [index] ^= count & 1; + time += count * period; + } + } + + this->delays [index] = time - end_time; + } + + this->last_time = end_time; +} + diff --git a/lib/rbcodec/codecs/libgme/nes_fme7_apu.h b/lib/rbcodec/codecs/libgme/nes_fme7_apu.h new file mode 100644 index 0000000000..c0eac4c765 --- /dev/null +++ b/lib/rbcodec/codecs/libgme/nes_fme7_apu.h @@ -0,0 +1,90 @@ +// Sunsoft FME-7 sound emulator + +// Game_Music_Emu 0.6-pre +#ifndef NES_FME7_APU_H +#define NES_FME7_APU_H + +#include "blargg_common.h" +#include "blip_buffer.h" + +enum { fme7_reg_count = 14 }; + +// Mask and addresses of registers +enum { fme7_addr_mask = 0xE000 }; +enum { fme7_data_addr = 0xE000 }; +enum { fme7_latch_addr = 0xC000 }; +enum { fme7_osc_count = 3 }; + +enum { amp_range = 192 }; // can be any value; this gives best error/quality tradeoff + +struct osc_t { + struct Blip_Buffer* output; + int last_amp; +}; + +// static unsigned char const amp_table [16]; + +struct Nes_Fme7_Apu { + // fme7 apu state + uint8_t regs [fme7_reg_count]; + uint8_t phases [3]; // 0 or 1 + uint8_t latch; + uint16_t delays [3]; // a, b, c + + struct osc_t oscs [fme7_osc_count]; + blip_time_t last_time; + + struct Blip_Synth synth; +}; + +// See Nes_Apu.h for reference +void Fme7_init( struct Nes_Fme7_Apu* this ); +void Fme7_reset( struct Nes_Fme7_Apu* this ); + +static inline void Fme7_volume( struct Nes_Fme7_Apu* this, int v ) +{ + Synth_volume( &this->synth, (v/2 - (v*3)/25) / amp_range ); // to do: fine-tune +} + +static inline void Fme7_osc_output( struct Nes_Fme7_Apu* this, int i, struct Blip_Buffer* buf ) +{ + assert( (unsigned) i < fme7_osc_count ); + this->oscs [i].output = buf; +} + +static inline void Fme7_output( struct Nes_Fme7_Apu* this, struct Blip_Buffer* buf ) +{ + int i; + for ( i = 0; i < fme7_osc_count; i++ ) + Fme7_osc_output( this, i, buf ); +} + +// (addr & addr_mask) == latch_addr +static inline void Fme7_write_latch( struct Nes_Fme7_Apu* this, int data ) { this->latch = data; } + +// (addr & addr_mask) == data_addr +void Fme7_run_until( struct Nes_Fme7_Apu* this, blip_time_t end_time ); +static inline void Fme7_write_data( struct Nes_Fme7_Apu* this, blip_time_t time, int data ) +{ + if ( (unsigned) this->latch >= fme7_reg_count ) + { + #ifdef debug_printf + debug_printf( "FME7 write to %02X (past end of sound registers)\n", (int) latch ); + #endif + return; + } + + Fme7_run_until( this, time ); + this->regs [this->latch] = data; +} + +static inline void Fme7_end_frame( struct Nes_Fme7_Apu* this, blip_time_t time ) +{ + if ( time > this->last_time ) + Fme7_run_until( this, time ); + + assert( this->last_time >= time ); + this->last_time -= time; +} + +#endif diff --git a/lib/rbcodec/codecs/libgme/nes_mmc5_apu.h b/lib/rbcodec/codecs/libgme/nes_mmc5_apu.h new file mode 100644 index 0000000000..b696b49e97 --- /dev/null +++ b/lib/rbcodec/codecs/libgme/nes_mmc5_apu.h @@ -0,0 +1,61 @@ +// NES MMC5 sound chip emulator + +// Nes_Snd_Emu 0.2.0-pre +#ifndef NES_MMC5_APU_H +#define NES_MMC5_APU_H + +#include "blargg_common.h" +#include "nes_apu.h" + +enum { mmc5_regs_addr = 0x5000 }; +enum { mmc5_regs_size = 0x16 }; +enum { mmc5_osc_count = 3 }; +enum { mmc5_exram_size = 1024 }; + +struct Nes_Mmc5_Apu { + struct Nes_Apu apu; + unsigned char exram [mmc5_exram_size]; +}; + +static inline void Mmc5_init( struct Nes_Mmc5_Apu* this ) +{ + Apu_init( &this->apu ); +} + +static inline void Mmc5_set_output( struct Nes_Mmc5_Apu* this, int i, struct Blip_Buffer* b ) +{ + // in: square 1, square 2, PCM + // out: square 1, square 2, skipped, skipped, PCM + if ( i > 1 ) + i += 2; + Apu_osc_output( &this->apu, i, b ); +} + +static inline void Mmc5_write_register( struct Nes_Mmc5_Apu* this, blip_time_t time, unsigned addr, int data ) +{ + switch ( addr ) + { + case 0x5015: // channel enables + data &= 0x03; // enable the square waves only + // fall through + case 0x5000: // Square 1 + case 0x5002: + case 0x5003: + case 0x5004: // Square 2 + case 0x5006: + case 0x5007: + case 0x5011: // DAC + Apu_write_register( &this->apu, time, addr - 0x1000, data ); + break; + + case 0x5010: // some things write to this for some reason + break; + +#ifdef BLARGG_DEBUG_H + default: + dprintf( "Unmapped MMC5 APU write: $%04X <- $%02X\n", addr, data ); +#endif + } +} + +#endif diff --git a/lib/rbcodec/codecs/libgme/nes_namco_apu.c b/lib/rbcodec/codecs/libgme/nes_namco_apu.c new file mode 100644 index 0000000000..34df200bb6 --- /dev/null +++ b/lib/rbcodec/codecs/libgme/nes_namco_apu.c @@ -0,0 +1,138 @@ +// Nes_Snd_Emu 0.1.8. http://www.slack.net/~ant/ + +#include "nes_namco_apu.h" + +/* Copyright (C) 2003-2006 Shay Green. This module is free software; you +can redistribute it and/or modify it under the terms of the GNU Lesser +General Public License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. This +module is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +details. You should have received a copy of the GNU Lesser General Public +License along with this module; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ + +#include "blargg_source.h" + +void Namco_init( struct Nes_Namco_Apu* this ) +{ + Synth_init( &this->synth ); + + Namco_output( this, NULL ); + Namco_volume( this, (int)FP_ONE_VOLUME ); + Namco_reset( this ); +} + +void Namco_reset( struct Nes_Namco_Apu* this ) +{ + this->last_time = 0; + this->addr_reg = 0; + + int i; + for ( i = 0; i < namco_reg_count; i++ ) + this->reg [i] = 0; + + for ( i = 0; i < namco_osc_count; i++ ) + { + struct Namco_Osc* osc = &this->oscs [i]; + osc->delay = 0; + osc->last_amp = 0; + osc->wave_pos = 0; + } +} + +void Namco_output( struct Nes_Namco_Apu* this, struct Blip_Buffer* buf ) +{ + int i; + for ( i = 0; i < namco_osc_count; i++ ) + Namco_osc_output( this, i, buf ); +} + +void Namco_end_frame( struct Nes_Namco_Apu* this, blip_time_t time ) +{ + if ( time > this->last_time ) + Namco_run_until( this, time ); + + assert( this->last_time >= time ); + this->last_time -= time; +} + +void Namco_run_until( struct Nes_Namco_Apu* this, blip_time_t nes_end_time ) +{ + int active_oscs = (this->reg [0x7F] >> 4 & 7) + 1; + int i; + for ( i = namco_osc_count - active_oscs; i < namco_osc_count; i++ ) + { + struct Namco_Osc* osc = &this->oscs [i]; + struct Blip_Buffer* output = osc->output; + if ( !output ) + continue; + + blip_resampled_time_t time = + Blip_resampled_time( output, this->last_time ) + osc->delay; + blip_resampled_time_t end_time = Blip_resampled_time( output, nes_end_time ); + osc->delay = 0; + if ( time < end_time ) + { + const uint8_t* osc_reg = &this->reg [i * 8 + 0x40]; + if ( !(osc_reg [4] & 0xE0) ) + continue; + + int volume = osc_reg [7] & 15; + if ( !volume ) + continue; + + int freq = (osc_reg [4] & 3) * 0x10000 + osc_reg [2] * 0x100L + osc_reg [0]; + if ( freq < 64 * active_oscs ) + continue; // prevent low frequencies from excessively delaying freq changes + + int const master_clock_divider = 12; // NES time derived via divider of master clock + int const n106_divider = 45; // N106 then divides master clock by this + int const max_freq = 0x3FFFF; + int const lowest_freq_period = (max_freq + 1) * n106_divider / master_clock_divider; + // divide by 8 to avoid overflow + blip_resampled_time_t period = + Blip_resampled_duration( output, lowest_freq_period / 8 ) / freq * 8 * active_oscs; + + int wave_size = 32 - (osc_reg [4] >> 2 & 7) * 4; + if ( !wave_size ) + continue; + + int last_amp = osc->last_amp; + int wave_pos = osc->wave_pos; + + Blip_set_modified( output ); + + do + { + // read wave sample + int addr = wave_pos + osc_reg [6]; + int sample = this->reg [addr >> 1] >> (addr << 2 & 4); + wave_pos++; + sample = (sample & 15) * volume; + + // output impulse if amplitude changed + int delta = sample - last_amp; + if ( delta ) + { + last_amp = sample; + Synth_offset_resampled( &this->synth, time, delta, output ); + } + + // next sample + time += period; + if ( wave_pos >= wave_size ) + wave_pos = 0; + } + while ( time < end_time ); + + osc->wave_pos = wave_pos; + osc->last_amp = last_amp; + } + osc->delay = time - end_time; + } + + this->last_time = nes_end_time; +} + diff --git a/lib/rbcodec/codecs/libgme/nes_namco_apu.h b/lib/rbcodec/codecs/libgme/nes_namco_apu.h new file mode 100644 index 0000000000..c428c894c3 --- /dev/null +++ b/lib/rbcodec/codecs/libgme/nes_namco_apu.h @@ -0,0 +1,71 @@ +// Namco 106 sound chip emulator + +// Nes_Snd_Emu 0.1.8 +#ifndef NES_NAMCO_APU_H +#define NES_NAMCO_APU_H + +#include "blargg_common.h" +#include "blip_buffer.h" + +struct namco_state_t; + +enum { namco_osc_count = 8 }; +enum { namco_addr_reg_addr = 0xF800 }; +enum { namco_data_reg_addr = 0x4800 }; +enum { namco_reg_count = 0x80 }; + +struct Namco_Osc { + int delay; + struct Blip_Buffer* output; + short last_amp; + short wave_pos; +}; + +struct Nes_Namco_Apu { + struct Namco_Osc oscs [namco_osc_count]; + + blip_time_t last_time; + int addr_reg; + + uint8_t reg [namco_reg_count]; + + struct Blip_Synth synth; +}; + +// See Nes_Apu.h for reference. +void Namco_init( struct Nes_Namco_Apu* this ); +void Namco_output( struct Nes_Namco_Apu* this, struct Blip_Buffer* ); + +void Namco_reset( struct Nes_Namco_Apu* this ); +void Namco_end_frame( struct Nes_Namco_Apu* this, blip_time_t ); + +static inline uint8_t* namco_access( struct Nes_Namco_Apu* this ) +{ + int addr = this->addr_reg & 0x7F; + if ( this->addr_reg & 0x80 ) + this->addr_reg = (addr + 1) | 0x80; + return &this->reg [addr]; +} + +static inline void Namco_volume( struct Nes_Namco_Apu* this, int v ) { Synth_volume( &this->synth, v / 10 / namco_osc_count / 15 ); } + +// Write-only address register is at 0xF800 +static inline void Namco_write_addr( struct Nes_Namco_Apu* this, int v ) { this->addr_reg = v; } + +static inline int Namco_read_data( struct Nes_Namco_Apu* this ) { return *namco_access( this ); } + +static inline void Namco_osc_output( struct Nes_Namco_Apu* this, int i, struct Blip_Buffer* buf ) +{ + assert( (unsigned) i < namco_osc_count ); + this->oscs [i].output = buf; +} + +// Read/write data register is at 0x4800 +void Namco_run_until( struct Nes_Namco_Apu* this, blip_time_t ); +static inline void Namco_write_data( struct Nes_Namco_Apu* this, blip_time_t time, int data ) +{ + Namco_run_until( this, time ); + *namco_access( this ) = data; +} + +#endif diff --git a/lib/rbcodec/codecs/libgme/nes_oscs.c b/lib/rbcodec/codecs/libgme/nes_oscs.c new file mode 100644 index 0000000000..ac6e5759da --- /dev/null +++ b/lib/rbcodec/codecs/libgme/nes_oscs.c @@ -0,0 +1,592 @@ +// Nes_Snd_Emu 0.1.8. http://www.slack.net/~ant/ + +#include "nes_apu.h" + +/* Copyright (C) 2003-2006 Shay Green. This module is free software; you +can redistribute it and/or modify it under the terms of the GNU Lesser +General Public License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. This +module is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +details. You should have received a copy of the GNU Lesser General Public +License along with this module; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ + +#include "blargg_source.h" + +// Nes_Osc + +void Osc_clock_length( struct Nes_Osc* this, int halt_mask ) +{ + if ( this->length_counter && !(this->regs [0] & halt_mask) ) + this->length_counter--; +} + +// Nes_Square + +void Square_clock_envelope( struct Nes_Square* this ) +{ + struct Nes_Osc* osc = &this->osc; + int period = osc->regs [0] & 15; + if ( osc->reg_written [3] ) { + osc->reg_written [3] = false; + this->env_delay = period; + this->envelope = 15; + } + else if ( --this->env_delay < 0 ) { + this->env_delay = period; + if ( this->envelope | (osc->regs [0] & 0x20) ) + this->envelope = (this->envelope - 1) & 15; + } +} + +int Square_volume( struct Nes_Square* this ) +{ + struct Nes_Osc* osc = &this->osc; + return osc->length_counter == 0 ? 0 : (osc->regs [0] & 0x10) ? (osc->regs [0] & 15) : this->envelope; +} + +void Square_clock_sweep( struct Nes_Square* this, int negative_adjust ) +{ + struct Nes_Osc* osc = &this->osc; + int sweep = osc->regs [1]; + + if ( --this->sweep_delay < 0 ) + { + osc->reg_written [1] = true; + + int period = Osc_period( osc ); + int shift = sweep & shift_mask; + if ( shift && (sweep & 0x80) && period >= 8 ) + { + int offset = period >> shift; + + if ( sweep & negate_flag ) + offset = negative_adjust - offset; + + if ( period + offset < 0x800 ) + { + period += offset; + // rewrite period + osc->regs [2] = period & 0xFF; + osc->regs [3] = (osc->regs [3] & ~7) | ((period >> 8) & 7); + } + } + } + + if ( osc->reg_written [1] ) { + osc->reg_written [1] = false; + this->sweep_delay = (sweep >> 4) & 7; + } +} + +// TODO: clean up +static inline nes_time_t Square_maintain_phase( struct Nes_Square* this, nes_time_t time, nes_time_t end_time, + nes_time_t timer_period ) +{ + nes_time_t remain = end_time - time; + if ( remain > 0 ) + { + int count = (remain + timer_period - 1) / timer_period; + this->phase = (this->phase + count) & (square_phase_range - 1); + time += count * timer_period; + } + return time; +} + +void Square_run( struct Nes_Square* this, nes_time_t time, nes_time_t end_time ) +{ + struct Nes_Osc* osc = &this->osc; + const int period = Osc_period( osc ); + const int timer_period = (period + 1) * 2; + + if ( !osc->output ) + { + osc->delay = Square_maintain_phase( this, time + osc->delay, end_time, timer_period ) - end_time; + return; + } + + int offset = period >> (osc->regs [1] & shift_mask); + if ( osc->regs [1] & negate_flag ) + offset = 0; + + const int volume = Square_volume( this ); + if ( volume == 0 || period < 8 || (period + offset) >= 0x800 ) + { + if ( osc->last_amp ) { + Blip_set_modified( osc->output ); + Synth_offset( this->synth, time, -osc->last_amp, osc->output ); + osc->last_amp = 0; + } + + time += osc->delay; + time = Square_maintain_phase( this, time, end_time, timer_period ); + } + else + { + // handle duty select + int duty_select = (osc->regs [0] >> 6) & 3; + int duty = 1 << duty_select; // 1, 2, 4, 2 + int amp = 0; + if ( duty_select == 3 ) { + duty = 2; // negated 25% + amp = volume; + } + if ( this->phase < duty ) + amp ^= volume; + + Blip_set_modified( osc->output ); + { + int delta = Osc_update_amp( osc, amp ); + if ( delta ) + Synth_offset( this->synth, time, delta, osc->output ); + } + + time += osc->delay; + if ( time < end_time ) + { + struct Blip_Buffer* const output = osc->output; + Synth* synth = this->synth; + int delta = amp * 2 - volume; + int phase = this->phase; + + do { + phase = (phase + 1) & (square_phase_range - 1); + if ( phase == 0 || phase == duty ) { + delta = -delta; + Synth_offset_inline( synth, time, delta, output ); + } + time += timer_period; + } + while ( time < end_time ); + + osc->last_amp = (delta + volume) >> 1; + this->phase = phase; + } + } + + osc->delay = time - end_time; +} + +// Nes_Triangle + +void Triangle_clock_linear_counter( struct Nes_Triangle* this ) +{ + struct Nes_Osc* osc = &this->osc; + if ( osc->reg_written [3] ) + this->linear_counter = osc->regs [0] & 0x7F; + else if ( this->linear_counter ) + this->linear_counter--; + + if ( !(osc->regs [0] & 0x80) ) + osc->reg_written [3] = false; +} + +static inline int Triangle_calc_amp( struct Nes_Triangle* this ) +{ + int amp = Triangle_phase_range - this->phase; + if ( amp < 0 ) + amp = this->phase - (Triangle_phase_range + 1); + return amp; +} + +// TODO: clean up +static inline nes_time_t Triangle_maintain_phase( struct Nes_Triangle* this, nes_time_t time, nes_time_t end_time, + nes_time_t timer_period ) +{ + nes_time_t remain = end_time - time; + if ( remain > 0 ) + { + int count = (remain + timer_period - 1) / timer_period; + this->phase = ((unsigned) this->phase + 1 - count) & (Triangle_phase_range * 2 - 1); + this->phase++; + time += count * timer_period; + } + return time; +} + +void Triangle_run( struct Nes_Triangle* this, nes_time_t time, nes_time_t end_time ) +{ + struct Nes_Osc* osc = &this->osc; + const int timer_period = Osc_period( osc ) + 1; + if ( !osc->output ) + { + time += osc->delay; + osc->delay = 0; + if ( osc->length_counter && this->linear_counter && timer_period >= 3 ) + osc->delay = Triangle_maintain_phase( this, time, end_time, timer_period ) - end_time; + return; + } + + // to do: track phase when period < 3 + // to do: Output 7.5 on dac when period < 2? More accurate, but results in more clicks. + + int delta = Osc_update_amp( osc, Triangle_calc_amp( this ) ); + if ( delta ) + { + Blip_set_modified( osc->output ); + Synth_offset( &this->synth, time, delta, osc->output ); + } + + time += osc->delay; + if ( osc->length_counter == 0 || this->linear_counter == 0 || timer_period < 3 ) + { + time = end_time; + } + else if ( time < end_time ) + { + struct Blip_Buffer* const output = osc->output; + + int phase = this->phase; + int volume = 1; + if ( phase > Triangle_phase_range ) { + phase -= Triangle_phase_range; + volume = -volume; + } + Blip_set_modified( osc->output ); + + do { + if ( --phase == 0 ) { + phase = Triangle_phase_range; + volume = -volume; + } + else + { + Synth_offset_inline( &this->synth, time, volume, output ); + } + + time += timer_period; + } + while ( time < end_time ); + + if ( volume < 0 ) + phase += Triangle_phase_range; + this->phase = phase; + osc->last_amp = Triangle_calc_amp( this ); + } + osc->delay = time - end_time; +} + +// Nes_Dmc + +void Dmc_reset( struct Nes_Dmc* this ) +{ + this->address = 0; + this->dac = 0; + this->buf = 0; + this->bits_remain = 1; + this->bits = 0; + this->buf_full = false; + this->silence = true; + this->next_irq = apu_no_irq; + this->irq_flag = false; + this->irq_enabled = false; + + Osc_reset( &this->osc ); + this->period = 0x1AC; +} + +void Dmc_recalc_irq( struct Nes_Dmc* this ) +{ + struct Nes_Osc* osc = &this->osc; + nes_time_t irq = apu_no_irq; + if ( this->irq_enabled && osc->length_counter ) + irq = this->apu->last_dmc_time + osc->delay + + ((osc->length_counter - 1) * 8 + this->bits_remain - 1) * (nes_time_t) (this->period) + 1; + if ( irq != this->next_irq ) { + this->next_irq = irq; + Apu_irq_changed( this->apu ); + } +} + +int Dmc_count_reads( struct Nes_Dmc* this, nes_time_t time, nes_time_t* last_read ) +{ + struct Nes_Osc* osc = &this->osc; + if ( last_read ) + *last_read = time; + + if ( osc->length_counter == 0 ) + return 0; // not reading + + nes_time_t first_read = Dmc_next_read_time( this ); + nes_time_t avail = time - first_read; + if ( avail <= 0 ) + return 0; + + int count = (avail - 1) / (this->period * 8) + 1; + if ( !(osc->regs [0] & loop_flag) && count > osc->length_counter ) + count = osc->length_counter; + + if ( last_read ) + { + *last_read = first_read + (count - 1) * (this->period * 8) + 1; + check( *last_read <= time ); + check( count == count_reads( *last_read, NULL ) ); + check( count - 1 == count_reads( *last_read - 1, NULL ) ); + } + + return count; +} + +static short const dmc_period_table [2] [16] = { + {428, 380, 340, 320, 286, 254, 226, 214, // NTSC + 190, 160, 142, 128, 106, 84, 72, 54}, + + {398, 354, 316, 298, 276, 236, 210, 198, // PAL + 176, 148, 132, 118, 98, 78, 66, 50} +}; + +static inline void Dmc_reload_sample( struct Nes_Dmc* this ) +{ + this->address = 0x4000 + this->osc.regs [2] * 0x40; + this->osc.length_counter = this->osc.regs [3] * 0x10 + 1; +} + +static int const dmc_table [128] = +{ + 0, 24, 48, 71, 94, 118, 141, 163, 186, 209, 231, 253, 275, 297, 319, 340, + 361, 383, 404, 425, 445, 466, 486, 507, 527, 547, 567, 587, 606, 626, 645, 664, + 683, 702, 721, 740, 758, 777, 795, 813, 832, 850, 867, 885, 903, 920, 938, 955, + 972, 989,1006,1023,1040,1056,1073,1089,1105,1122,1138,1154,1170,1185,1201,1217, +1232,1248,1263,1278,1293,1308,1323,1338,1353,1368,1382,1397,1411,1425,1440,1454, +1468,1482,1496,1510,1523,1537,1551,1564,1578,1591,1604,1618,1631,1644,1657,1670, +1683,1695,1708,1721,1733,1746,1758,1771,1783,1795,1807,1819,1831,1843,1855,1867, +1879,1890,1902,1914,1925,1937,1948,1959,1971,1982,1993,2004,2015,2026,2037,2048, +}; + +static inline int update_amp_nonlinear( struct Nes_Dmc* this, int in ) +{ + if ( !this->nonlinear ) + in = dmc_table [in]; + int delta = in - this->osc.last_amp; + this->osc.last_amp = in; + return delta; +} + +void Dmc_write_register( struct Nes_Dmc* this, int addr, int data ) +{ + if ( addr == 0 ) + { + this->period = dmc_period_table [this->pal_mode] [data & 15]; + this->irq_enabled = (data & 0xC0) == 0x80; // enabled only if loop disabled + this->irq_flag &= this->irq_enabled; + Dmc_recalc_irq( this ); + } + else if ( addr == 1 ) + { + this->dac = data & 0x7F; + } +} + +void Dmc_start( struct Nes_Dmc* this ) +{ + Dmc_reload_sample( this ); + Dmc_fill_buffer( this ); + Dmc_recalc_irq( this ); +} + +void Dmc_fill_buffer( struct Nes_Dmc* this ) +{ + if ( !this->buf_full && this->osc.length_counter ) + { + require( this->prg_reader ); // prg_reader must be set + this->buf = this->prg_reader( this->prg_reader_data, 0x8000u + this->address ); + this->address = (this->address + 1) & 0x7FFF; + this->buf_full = true; + if ( --this->osc.length_counter == 0 ) + { + if ( this->osc.regs [0] & loop_flag ) { + Dmc_reload_sample( this ); + } + else { + this->apu->osc_enables &= ~0x10; + this->irq_flag = this->irq_enabled; + this->next_irq = apu_no_irq; + Apu_irq_changed( this->apu ); + } + } + } +} + +void Dmc_run( struct Nes_Dmc* this, nes_time_t time, nes_time_t end_time ) +{ + struct Nes_Osc* osc = &this->osc; + int delta = update_amp_nonlinear( this, this->dac ); + if ( !osc->output ) + { + this->silence = true; + } + else if ( delta ) + { + Blip_set_modified( osc->output ); + Synth_offset( &this->synth, time, delta, osc->output ); + } + + time += osc->delay; + if ( time < end_time ) + { + int bits_remain = this->bits_remain; + if ( this->silence && !this->buf_full ) + { + int count = (end_time - time + this->period - 1) / this->period; + bits_remain = (bits_remain - 1 + 8 - (count % 8)) % 8 + 1; + time += count * this->period; + } + else + { + struct Blip_Buffer* const output = osc->output; + const int period = this->period; + int bits = this->bits; + int dac = this->dac; + if ( output ) + Blip_set_modified( output ); + + do + { + if ( !this->silence ) + { + int step = (bits & 1) * 4 - 2; + bits >>= 1; + if ( (unsigned) (dac + step) <= 0x7F ) { + dac += step; + Synth_offset_inline( &this->synth, time, update_amp_nonlinear( this, dac ), output ); + } + } + + time += period; + + if ( --bits_remain == 0 ) + { + bits_remain = 8; + if ( !this->buf_full ) { + this->silence = true; + } + else + { + this->silence = false; + bits = this->buf; + this->buf_full = false; + if ( !output ) + this->silence = true; + Dmc_fill_buffer( this ); + } + } + } + while ( time < end_time ); + + this->dac = dac; + //osc->last_amp = dac; + this->bits = bits; + } + this->bits_remain = bits_remain; + } + osc->delay = time - end_time; +} + +// Nes_Noise + +static short const noise_period_table [16] = { + 0x004, 0x008, 0x010, 0x020, 0x040, 0x060, 0x080, 0x0A0, + 0x0CA, 0x0FE, 0x17C, 0x1FC, 0x2FA, 0x3F8, 0x7F2, 0xFE4 +}; + +void Noise_clock_envelope( struct Nes_Noise* this ) +{ + struct Nes_Osc* osc = &this->osc; + int period = osc->regs [0] & 15; + if ( osc->reg_written [3] ) { + osc->reg_written [3] = false; + this->env_delay = period; + this->envelope = 15; + } + else if ( --this->env_delay < 0 ) { + this->env_delay = period; + if ( this->envelope | (osc->regs [0] & 0x20) ) + this->envelope = (this->envelope - 1) & 15; + } +} + +int Noise_volume( struct Nes_Noise* this ) +{ + struct Nes_Osc* osc = &this->osc; + return osc->length_counter == 0 ? 0 : (osc->regs [0] & 0x10) ? (osc->regs [0] & 15) : this->envelope; +} + +void Noise_run( struct Nes_Noise* this, nes_time_t time, nes_time_t end_time ) +{ + struct Nes_Osc* osc = &this->osc; + int period = noise_period_table [osc->regs [2] & 15]; + + if ( !osc->output ) + { + // TODO: clean up + time += osc->delay; + osc->delay = time + (end_time - time + period - 1) / period * period - end_time; + return; + } + + const int volume = Noise_volume( this ); + int amp = (this->noise & 1) ? volume : 0; + { + int delta = Osc_update_amp( osc, amp ); + if ( delta ) + { + Blip_set_modified( osc->output ); + Synth_offset( &this->synth, time, delta, osc->output ); + } + } + + time += osc->delay; + if ( time < end_time ) + { + const int mode_flag = 0x80; + + if ( !volume ) + { + // round to next multiple of period + time += (end_time - time + period - 1) / period * period; + + // approximate noise cycling while muted, by shuffling up noise register + // to do: precise muted noise cycling? + if ( !(osc->regs [2] & mode_flag) ) { + int feedback = (this->noise << 13) ^ (this->noise << 14); + this->noise = (feedback & 0x4000) | (this->noise >> 1); + } + } + else + { + struct Blip_Buffer* const output = osc->output; + + // using resampled time avoids conversion in synth.offset() + blip_resampled_time_t rperiod = Blip_resampled_duration( output, period ); + blip_resampled_time_t rtime = Blip_resampled_time( output, time ); + + int noise = this->noise; + int delta = amp * 2 - volume; + const int tap = (osc->regs [2] & mode_flag ? 8 : 13); + Blip_set_modified( output ); + + do { + int feedback = (noise << tap) ^ (noise << 14); + time += period; + + if ( (noise + 1) & 2 ) { + // bits 0 and 1 of noise differ + delta = -delta; + Synth_offset_resampled( &this->synth, rtime, delta, output ); + } + + rtime += rperiod; + noise = (feedback & 0x4000) | (noise >> 1); + } + while ( time < end_time ); + + osc->last_amp = (delta + volume) >> 1; + this->noise = noise; + } + } + + osc->delay = time - end_time; +} + diff --git a/lib/rbcodec/codecs/libgme/nes_oscs.h b/lib/rbcodec/codecs/libgme/nes_oscs.h new file mode 100644 index 0000000000..1eeb302e6c --- /dev/null +++ b/lib/rbcodec/codecs/libgme/nes_oscs.h @@ -0,0 +1,164 @@ +// Private oscillators used by Nes_Apu + +// Nes_Snd_Emu 0.1.8 +#ifndef NES_OSCS_H +#define NES_OSCS_H + +#include "blargg_common.h" +#include "blip_buffer.h" +#include "nes_cpu.h" + +struct Nes_Apu; + +struct Nes_Osc +{ + unsigned char regs [4]; + bool reg_written [4]; + struct Blip_Buffer* output; + int length_counter;// length counter (0 if unused by oscillator) + int delay; // delay until next (potential) transition + int last_amp; // last amplitude oscillator was outputting +}; + +void Osc_clock_length( struct Nes_Osc* this, int halt_mask ); +static inline int Osc_period( struct Nes_Osc* this ) +{ + return (this->regs [3] & 7) * 0x100 + (this->regs [2] & 0xFF); +} + +static inline void Osc_reset( struct Nes_Osc* this ) +{ + this->delay = 0; + this->last_amp = 0; +} + +static inline int Osc_update_amp( struct Nes_Osc* this, int amp ) +{ + int delta = amp - this->last_amp; + this->last_amp = amp; + return delta; +} + +// Nes_Square + +enum { negate_flag = 0x08 }; +enum { shift_mask = 0x07 }; +enum { square_phase_range = 8 }; + +typedef struct Blip_Synth Synth; + +struct Nes_Square +{ + struct Nes_Osc osc; + int envelope; + int env_delay; + int phase; + int sweep_delay; + + Synth* synth; // shared between squares +}; + +static inline void Square_set_synth( struct Nes_Square* this, Synth* s ) { this->synth = s; } + +void Square_clock_sweep( struct Nes_Square* this, int adjust ); +void Square_run( struct Nes_Square* this, nes_time_t, nes_time_t ); + +static inline void Square_reset( struct Nes_Square* this ) +{ + this->sweep_delay = 0; + this->envelope = 0; + this->env_delay = 0; + Osc_reset( &this->osc ); +} + +void Square_clock_envelope( struct Nes_Square* this ); +int Square_volume( struct Nes_Square* this ); + +// Nes_Triangle + +enum { Triangle_phase_range = 16 }; + +struct Nes_Triangle +{ + struct Nes_Osc osc; + + int phase; + int linear_counter; + struct Blip_Synth synth; +}; + +void Triangle_run( struct Nes_Triangle* this, nes_time_t, nes_time_t ); +void Triangle_clock_linear_counter( struct Nes_Triangle* this ); + +static inline void Triangle_reset( struct Nes_Triangle* this ) +{ + this->linear_counter = 0; + this->phase = 1; + Osc_reset( &this->osc ); +} + +// Nes_Noise +struct Nes_Noise +{ + struct Nes_Osc osc; + + int envelope; + int env_delay; + int noise; + struct Blip_Synth synth; +}; + +void Noise_clock_envelope( struct Nes_Noise* this ); +int Noise_volume( struct Nes_Noise* this ); +void Noise_run( struct Nes_Noise* this, nes_time_t, nes_time_t ); + +static inline void Noise_reset( struct Nes_Noise* this ) +{ + this->noise = 1 << 14; + this->envelope = 0; + this->env_delay = 0; + Osc_reset( &this->osc ); +} + +// Nes_Dmc + +enum { loop_flag = 0x40 }; + +struct Nes_Dmc +{ + struct Nes_Osc osc; + + int address; // address of next byte to read + int period; + int buf; + int bits_remain; + int bits; + bool buf_full; + bool silence; + + int dac; + + nes_time_t next_irq; + bool irq_enabled; + bool irq_flag; + bool pal_mode; + bool nonlinear; + + int (*prg_reader)( void*, int ); // needs to be initialized to prg read function + void* prg_reader_data; + + struct Nes_Apu* apu; + + struct Blip_Synth synth; +}; + +void Dmc_start( struct Nes_Dmc* this ); +void Dmc_write_register( struct Nes_Dmc* this, int, int ); +void Dmc_run( struct Nes_Dmc* this, nes_time_t, nes_time_t ); +void Dmc_recalc_irq( struct Nes_Dmc* this ); +void Dmc_fill_buffer( struct Nes_Dmc* this ); +void Dmc_reset( struct Nes_Dmc* this ); + +int Dmc_count_reads( struct Nes_Dmc* this, nes_time_t, nes_time_t* ); + +#endif diff --git a/lib/rbcodec/codecs/libgme/nes_vrc6_apu.c b/lib/rbcodec/codecs/libgme/nes_vrc6_apu.c new file mode 100644 index 0000000000..99a9ae3fed --- /dev/null +++ b/lib/rbcodec/codecs/libgme/nes_vrc6_apu.c @@ -0,0 +1,192 @@ + // Nes_Snd_Emu 0.1.8. http://www.slack.net/~ant/ + +#include "nes_vrc6_apu.h" + +/* Copyright (C) 2003-2006 Shay Green. This module is free software; you +can redistribute it and/or modify it under the terms of the GNU Lesser +General Public License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. This +module is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +details. You should have received a copy of the GNU Lesser General Public +License along with this module; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ + +#include "blargg_source.h" + +void Vrc6_init( struct Nes_Vrc6_Apu* this ) +{ + Synth_init( &this->saw_synth ); + Synth_init( &this->square_synth ); + + Vrc6_output( this, NULL ); + Vrc6_volume( this, (int)FP_ONE_VOLUME ); + Vrc6_reset( this ); +} + +void Vrc6_reset( struct Nes_Vrc6_Apu* this ) +{ + this->last_time = 0; + int i; + for ( i = 0; i < vrc6_osc_count; i++ ) + { + struct Vrc6_Osc* osc = &this->oscs [i]; + int j; + for ( j = 0; j < vrc6_reg_count; j++ ) + osc->regs [j] = 0; + osc->delay = 0; + osc->last_amp = 0; + osc->phase = 1; + osc->amp = 0; + } +} + +void Vrc6_output( struct Nes_Vrc6_Apu* this, struct Blip_Buffer* buf ) +{ + int i; + for ( i = 0; i < vrc6_osc_count; i++ ) + Vrc6_osc_output( this, i, buf ); +} + +void run_square( struct Nes_Vrc6_Apu* this, struct Vrc6_Osc* osc, blip_time_t end_time ); +void run_saw( struct Nes_Vrc6_Apu* this, blip_time_t end_time ); +static void Vrc6_run_until( struct Nes_Vrc6_Apu* this, blip_time_t time ) +{ + require( time >= this->last_time ); + run_square( this, &this->oscs [0], time ); + run_square( this, &this->oscs [1], time ); + run_saw( this, time ); + this->last_time = time; +} + +void Vrc6_write_osc( struct Nes_Vrc6_Apu* this, blip_time_t time, int osc_index, int reg, int data ) +{ + require( (unsigned) osc_index < vrc6_osc_count ); + require( (unsigned) reg < vrc6_reg_count ); + + Vrc6_run_until( this, time ); + this->oscs [osc_index].regs [reg] = data; +} + +void Vrc6_end_frame( struct Nes_Vrc6_Apu* this, blip_time_t time ) +{ + if ( time > this->last_time ) + Vrc6_run_until( this, time ); + + assert( this->last_time >= time ); + this->last_time -= time; +} + +void run_square( struct Nes_Vrc6_Apu* this, struct Vrc6_Osc* osc, blip_time_t end_time ) +{ + struct Blip_Buffer* output = osc->output; + if ( !output ) + return; + + int volume = osc->regs [0] & 15; + if ( !(osc->regs [2] & 0x80) ) + volume = 0; + + int gate = osc->regs [0] & 0x80; + int duty = ((osc->regs [0] >> 4) & 7) + 1; + int delta = ((gate || osc->phase < duty) ? volume : 0) - osc->last_amp; + blip_time_t time = this->last_time; + if ( delta ) + { + osc->last_amp += delta; + Blip_set_modified( output ); + Synth_offset( &this->square_synth, time, delta, output ); + } + + time += osc->delay; + osc->delay = 0; + int period = Vrc6_osc_period( osc ); + if ( volume && !gate && period > 4 ) + { + if ( time < end_time ) + { + int phase = osc->phase; + Blip_set_modified( output ); + + do + { + phase++; + if ( phase == 16 ) + { + phase = 0; + osc->last_amp = volume; + Synth_offset( &this->square_synth, time, volume, output ); + } + if ( phase == duty ) + { + osc->last_amp = 0; + Synth_offset( &this->square_synth, time, -volume, output ); + } + time += period; + } + while ( time < end_time ); + + osc->phase = phase; + } + osc->delay = time - end_time; + } +} + +void run_saw( struct Nes_Vrc6_Apu* this, blip_time_t end_time ) +{ + struct Vrc6_Osc* osc = &this->oscs [2]; + struct Blip_Buffer* output = osc->output; + if ( !output ) + return; + Blip_set_modified( output ); + + int amp = osc->amp; + int amp_step = osc->regs [0] & 0x3F; + blip_time_t time = this->last_time; + int last_amp = osc->last_amp; + if ( !(osc->regs [2] & 0x80) || !(amp_step | amp) ) + { + osc->delay = 0; + int delta = (amp >> 3) - last_amp; + last_amp = amp >> 3; + Synth_offset( &this->saw_synth, time, delta, output ); + } + else + { + time += osc->delay; + if ( time < end_time ) + { + int period = Vrc6_osc_period( osc ) * 2; + int phase = osc->phase; + + do + { + if ( --phase == 0 ) + { + phase = 7; + amp = 0; + } + + int delta = (amp >> 3) - last_amp; + if ( delta ) + { + last_amp = amp >> 3; + Synth_offset( &this->saw_synth, time, delta, output ); + } + + time += period; + amp = (amp + amp_step) & 0xFF; + } + while ( time < end_time ); + + osc->phase = phase; + osc->amp = amp; + } + + osc->delay = time - end_time; + } + + osc->last_amp = last_amp; +} + diff --git a/lib/rbcodec/codecs/libgme/nes_vrc6_apu.h b/lib/rbcodec/codecs/libgme/nes_vrc6_apu.h new file mode 100644 index 0000000000..57b8a42a79 --- /dev/null +++ b/lib/rbcodec/codecs/libgme/nes_vrc6_apu.h @@ -0,0 +1,62 @@ +// Konami VRC6 sound chip emulator + +// Nes_Snd_Emu 0.2.0-pre +#ifndef NES_VRC6_APU_H +#define NES_VRC6_APU_H + +#include "blargg_common.h" +#include "blip_buffer.h" + +enum { vrc6_osc_count = 3 }; +enum { vrc6_reg_count = 3 }; +enum { vrc6_base_addr = 0x9000 }; +enum { vrc6_addr_step = 0x1000 }; + +struct Vrc6_Osc +{ + uint8_t regs [3]; + struct Blip_Buffer* output; + int delay; + int last_amp; + int phase; + int amp; // only used by saw +}; + +static inline int Vrc6_osc_period( struct Vrc6_Osc* this ) +{ + return (this->regs [2] & 0x0F) * 0x100 + this->regs [1] + 1; +} + +struct Nes_Vrc6_Apu { + struct Vrc6_Osc oscs [vrc6_osc_count]; + blip_time_t last_time; + + struct Blip_Synth saw_synth; + struct Blip_Synth square_synth; +}; + +// See Nes_Apu.h for reference +void Vrc6_init( struct Nes_Vrc6_Apu* this ); +void Vrc6_reset( struct Nes_Vrc6_Apu* this ); +void Vrc6_output( struct Nes_Vrc6_Apu* this, struct Blip_Buffer* ); +void Vrc6_end_frame( struct Nes_Vrc6_Apu* this, blip_time_t ); + +// Oscillator 0 write-only registers are at $9000-$9002 +// Oscillator 1 write-only registers are at $A000-$A002 +// Oscillator 2 write-only registers are at $B000-$B002 +void Vrc6_write_osc( struct Nes_Vrc6_Apu* this, blip_time_t, int osc, int reg, int data ); + +static inline void Vrc6_osc_output( struct Nes_Vrc6_Apu* this, int i, struct Blip_Buffer* buf ) +{ + assert( (unsigned) i < vrc6_osc_count ); + this->oscs [i].output = buf; +} + +static inline void Vrc6_volume( struct Nes_Vrc6_Apu* this, int v ) +{ + long long const factor = (long long)(FP_ONE_VOLUME * 0.0967 * 2); + Synth_volume( &this->saw_synth, (int)(v * factor / 31 / FP_ONE_VOLUME) ); + Synth_volume( &this->square_synth, (int)(v * factor / 2 / 15 / FP_ONE_VOLUME) ); +} + +#endif diff --git a/lib/rbcodec/codecs/libgme/nes_vrc7_apu.c b/lib/rbcodec/codecs/libgme/nes_vrc7_apu.c new file mode 100644 index 0000000000..8d3c2e88a6 --- /dev/null +++ b/lib/rbcodec/codecs/libgme/nes_vrc7_apu.c @@ -0,0 +1,88 @@ + +#include "nes_vrc7_apu.h" +#include "blargg_source.h" + +int const period = 36; // NES CPU clocks per FM clock + +void Vrc7_init( struct Nes_Vrc7_Apu* this ) +{ + Synth_init( &this->synth ); + + OPLL_new ( &this->opll, 3579545, 3579545 / 72 ); + OPLL_reset_patch( &this->opll, OPLL_VRC7_TONE ); + + this->osc.output = 0; + this->osc.last_amp = 0; + this->mask = 0; + + Vrc7_volume( this, (int)FP_ONE_VOLUME ); + Vrc7_reset( this ); +} + +void Vrc7_reset( struct Nes_Vrc7_Apu* this ) +{ + this->addr = 0; + this->next_time = 0; + this->osc.last_amp = 0; + + OPLL_reset (&this->opll); + OPLL_setMask(&this->opll, this->mask); +} + +void Vrc7_set_rate( struct Nes_Vrc7_Apu* this, int r ) +{ + OPLL_set_quality( &this->opll, r < 44100 ? 0 : 1 ); +} + +void Vrc7_write_reg( struct Nes_Vrc7_Apu* this, int data ) +{ + this->addr = data; +} + +void Vrc7_run_until( struct Nes_Vrc7_Apu* this, blip_time_t end_time ); +void Vrc7_write_data( struct Nes_Vrc7_Apu* this, blip_time_t time, int data ) +{ + if ( time > this->next_time ) + Vrc7_run_until( this, time ); + + OPLL_writeIO( &this->opll, 0, this->addr ); + OPLL_writeIO( &this->opll, 1, data ); +} + +void Vrc7_end_frame( struct Nes_Vrc7_Apu* this, blip_time_t time ) +{ + if ( time > this->next_time ) + Vrc7_run_until( this, time ); + + this->next_time -= time; + assert( this->next_time >= 0 ); + + if ( this->osc.output ) + Blip_set_modified( this->osc.output ); +} + +void Vrc7_run_until( struct Nes_Vrc7_Apu* this, blip_time_t end_time ) +{ + require( end_time > this->next_time ); + + blip_time_t time = this->next_time; + OPLL* opll = &this->opll; // cache + struct Blip_Buffer* const output = this-> osc.output; + if ( output ) + { + do + { + int amp = OPLL_calc( opll ) << 1; + int delta = amp - this->osc.last_amp; + if ( delta ) + { + this->osc.last_amp = amp; + Synth_offset_inline( &this->synth, time, delta, output ); + } + time += period; + } + while ( time < end_time ); + } + + this->next_time = time; +} diff --git a/lib/rbcodec/codecs/libgme/nes_vrc7_apu.h b/lib/rbcodec/codecs/libgme/nes_vrc7_apu.h new file mode 100644 index 0000000000..1f45a435db --- /dev/null +++ b/lib/rbcodec/codecs/libgme/nes_vrc7_apu.h @@ -0,0 +1,52 @@ +// Konami VRC7 sound chip emulator + +#ifndef NES_VRC7_APU_H +#define NES_VRC7_APU_H + +#include "blargg_common.h" +#include "blip_buffer.h" + +#include "emu2413.h" + +enum { vrc7_osc_count = 6 }; + +struct vrc7_osc_t { + struct Blip_Buffer* output; + int last_amp; +}; + +struct Nes_Vrc7_Apu { + OPLL opll; + int addr; + blip_time_t next_time; + struct vrc7_osc_t osc; + struct Blip_Synth synth; + e_uint32 mask; +}; + +// See Nes_Apu.h for reference +void Vrc7_init( struct Nes_Vrc7_Apu* this ); +void Vrc7_reset( struct Nes_Vrc7_Apu* this ); +void Vrc7_set_rate( struct Nes_Vrc7_Apu* this, int r ); +void Vrc7_end_frame( struct Nes_Vrc7_Apu* this, blip_time_t ); + +void Vrc7_write_reg( struct Nes_Vrc7_Apu* this, int reg ); +void Vrc7_write_data( struct Nes_Vrc7_Apu* this, blip_time_t, int data ); + +void output_changed( struct Nes_Vrc7_Apu* this ); +static inline void Vrc7_set_output( struct Nes_Vrc7_Apu* this, int i, struct Blip_Buffer* buf ) +{ + assert( (unsigned) i < vrc7_osc_count ); + this->mask |= 1 << i; + + // Will use OPLL_setMask to mute voices + if ( buf ) { + this->mask ^= 1 << i; + this->osc.output = buf; + } +} + +// DB2LIN_AMP_BITS == 11, * 2 +static inline void Vrc7_volume( struct Nes_Vrc7_Apu* this, int v ) { Synth_volume( &this->synth, v / 3 / 4096 ); } + +#endif diff --git a/lib/rbcodec/codecs/libgme/nsf_cpu.c b/lib/rbcodec/codecs/libgme/nsf_cpu.c new file mode 100644 index 0000000000..1f44bd3c3c --- /dev/null +++ b/lib/rbcodec/codecs/libgme/nsf_cpu.c @@ -0,0 +1,115 @@ +// Normal cpu for NSF emulator + +// Game_Music_Emu 0.6-pre. http://www.slack.net/~ant/ + +#include "nsf_emu.h" + +#include "blargg_endian.h" + +#ifdef BLARGG_DEBUG_H + //#define CPU_LOG_START 1000000 + //#include "nes_cpu_log.h" + #undef LOG_MEM +#endif + +/* Copyright (C) 2003-2008 Shay Green. This module is free software; you +can redistribute it and/or modify it under the terms of the GNU Lesser +General Public License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. This +module is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +details. You should have received a copy of the GNU Lesser General Public +License along with this module; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ + +#include "blargg_source.h" + +#ifndef LOG_MEM + #define LOG_MEM( addr, str, data ) data +#endif + +int read_mem( struct Nsf_Emu* this, addr_t addr ) +{ + int result = this->low_ram [addr & (low_ram_size-1)]; // also handles wrap-around + if ( addr & 0xE000 ) + { + result = *Cpu_get_code( &this->cpu, addr ); + if ( addr < sram_addr ) + { + if ( addr == apu_status_addr ) + result = Apu_read_status( &this->apu, Cpu_time( &this->cpu ) ); + else + result = cpu_read( this, addr ); + } + } + return LOG_MEM( addr, ">", result ); +} + +void write_mem( struct Nsf_Emu* this, addr_t addr, int data ) +{ + (void) LOG_MEM( addr, "<", data ); + + int offset = addr - sram_addr; + if ( (unsigned) offset < sram_size ) + { + sram( this ) [offset] = data; + } + else + { + // after sram because cpu handles most low_ram accesses internally already + int temp = addr & (low_ram_size-1); // also handles wrap-around + if ( !(addr & 0xE000) ) + { + this->low_ram [temp] = data; + } + else + { + int bank = addr - banks_addr; + if ( (unsigned) bank < bank_count ) + { + write_bank( this, bank, data ); + } + else if ( (unsigned) (addr - apu_io_addr) < apu_io_size ) + { + Apu_write_register( &this->apu, Cpu_time( &this->cpu ), addr, data ); + } + else + { + #ifndef NSF_EMU_APU_ONLY + // 0x8000-0xDFFF is writable + int i = addr - 0x8000; + if ( fds_enabled( this ) && (unsigned) i < fdsram_size ) + fdsram( this ) [i] = data; + else + #endif + cpu_write( this, addr, data ); + } + } + } +} + +#define READ_LOW( addr ) (LOG_MEM( addr, ">", this->low_ram [addr] )) +#define WRITE_LOW( addr, data ) (LOG_MEM( addr, "<", this->low_ram [addr] = data )) + +#define CAN_WRITE_FAST( addr ) (addr < low_ram_size) +#define WRITE_FAST WRITE_LOW + +// addr < 0x2000 || addr >= 0x8000 +#define CAN_READ_FAST( addr ) ((addr ^ 0x8000) < 0xA000) +#define READ_FAST( addr, out ) (LOG_MEM( addr, ">", out = READ_CODE( addr ) )) + +#define READ_MEM( addr ) read_mem( this, addr ) +#define WRITE_MEM( addr, data ) write_mem( this, addr, data ) + +#define CPU_BEGIN \ +bool run_cpu_until( struct Nsf_Emu* this, nes_time_t end ) \ +{ \ + struct Nes_Cpu* cpu = &this->cpu; \ + Cpu_set_end_time( cpu, end ); \ + if ( *Cpu_get_code( cpu, cpu->r.pc ) != halt_opcode ) \ + { + #include "nes_cpu_run.h" + } + return Cpu_time_past_end( cpu ) < 0; +} diff --git a/lib/rbcodec/codecs/libgme/nsf_emu.c b/lib/rbcodec/codecs/libgme/nsf_emu.c new file mode 100644 index 0000000000..d9fc4e031d --- /dev/null +++ b/lib/rbcodec/codecs/libgme/nsf_emu.c @@ -0,0 +1,921 @@ +// Game_Music_Emu 0.6-pre. http://www.slack.net/~ant/ + +#include "nsf_emu.h" +#include "multi_buffer.h" + +#include "blargg_endian.h" + +/* Copyright (C) 2003-2006 Shay Green. This module is free software; you +can redistribute it and/or modify it under the terms of the GNU Lesser +General Public License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. This +module is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +details. You should have received a copy of the GNU Lesser General Public +License along with this module; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ + +#include "blargg_source.h" + +const char gme_wrong_file_type [] = "Wrong file type for this emulator"; + +// number of frames until play interrupts init +int const initial_play_delay = 7; // KikiKaikai needed this to work +int const bank_size = 0x1000; +int const rom_addr = 0x8000; + +static void clear_track_vars( struct Nsf_Emu* this ) +{ + this->current_track = -1; + track_stop( &this->track_filter ); +} + +static int pcm_read( void* emu, int addr ) +{ + return *Cpu_get_code( &((struct Nsf_Emu*) emu)->cpu, addr ); +} + +void Nsf_init( struct Nsf_Emu* this ) +{ + this->sample_rate = 0; + this->mute_mask_ = 0; + this->tempo = (int)(FP_ONE_TEMPO); + this->gain = (int)(FP_ONE_GAIN); + + // defaults + this->tfilter = *track_get_setup( &this->track_filter ); + this->tfilter.max_initial = 2; + this->tfilter.lookahead = 6; + this->track_filter.silence_ignored_ = false; + + // Set sound gain + Sound_set_gain( this, (int)(FP_ONE_GAIN*1.2) ); + + // Init rom + Rom_init( &this->rom, bank_size ); + + // Init & clear nsfe info + Info_init( &this->info ); + Info_unload( &this->info ); // TODO: extremely hacky! + + Cpu_init( &this->cpu ); + Apu_init( &this->apu ); + Apu_dmc_reader( &this->apu, pcm_read, this ); + + // Unload + this->voice_count = 0; + memset( this->voice_types, 0, sizeof this->voice_types ); + clear_track_vars( this ); +} + +// Setup + +static void append_voices( struct Nsf_Emu* this, int const types [], int count ) +{ + assert( this->voice_count + count < max_voices ); + int i; + for ( i = 0; i < count; i++ ) { + this->voice_types [this->voice_count + i] = types [i]; + } + this->voice_count += count; +} + +static blargg_err_t init_sound( struct Nsf_Emu* this ) +{ +/* if ( header_.chip_flags & ~(fds_flag | namco_flag | vrc6_flag | fme7_flag) ) + warning( "Uses unsupported audio expansion hardware" ); **/ + + { + static int const types [apu_osc_count] = { + wave_type+1, wave_type+2, mixed_type+1, noise_type+0, mixed_type+1 + }; + append_voices( this, types, apu_osc_count ); + } + + int adjusted_gain = (this->gain * 4) / 3; + + #ifdef NSF_EMU_APU_ONLY + { + if ( this->header_.chip_flags ) + set_warning( "Uses unsupported audio expansion hardware" ); + } + #else + { + if ( vrc6_enabled( this ) ) + { + Vrc6_init( &this->vrc6 ); + adjusted_gain = (adjusted_gain*3) / 4; + + static int const types [vrc6_osc_count] = { + wave_type+3, wave_type+4, wave_type+5, + }; + append_voices( this, types, vrc6_osc_count ); + } + + if ( fme7_enabled( this ) ) + { + Fme7_init( &this->fme7 ); + adjusted_gain = (adjusted_gain*3) / 4; + + static int const types [fme7_osc_count] = { + wave_type+3, wave_type+4, wave_type+5, + }; + append_voices( this, types, fme7_osc_count ); + } + + if ( mmc5_enabled( this ) ) + { + Mmc5_init( &this->mmc5 ); + adjusted_gain = (adjusted_gain*3) / 4; + + + static int const types [mmc5_osc_count] = { + wave_type+3, wave_type+4, mixed_type+2 + }; + append_voices( this, types, mmc5_osc_count ); + } + + if ( fds_enabled( this ) ) + { + Fds_init( &this->fds ); + adjusted_gain = (adjusted_gain*3) / 4; + + static int const types [fds_osc_count] = { + wave_type+0 + }; + append_voices( this, types, fds_osc_count ); + } + + if ( namco_enabled( this ) ) + { + Namco_init( &this->namco ); + adjusted_gain = (adjusted_gain*3) / 4; + + static int const types [namco_osc_count] = { + wave_type+3, wave_type+4, wave_type+5, wave_type+ 6, + wave_type+7, wave_type+8, wave_type+9, wave_type+10, + }; + append_voices( this, types, namco_osc_count ); + } + + #ifndef NSF_EMU_NO_VRC7 + if ( vrc7_enabled( this ) ) + { + + Vrc7_init( &this->vrc7 ); + Vrc7_set_rate( &this->vrc7, this->sample_rate ); + + adjusted_gain = (adjusted_gain*3) / 4; + + static int const types [vrc7_osc_count] = { + wave_type+3, wave_type+4, wave_type+5, wave_type+6, + wave_type+7, wave_type+8 + }; + append_voices( this, types, vrc7_osc_count ); + } + + if ( vrc7_enabled( this ) ) Vrc7_volume( &this->vrc7, adjusted_gain ); + #endif + if ( namco_enabled( this ) ) Namco_volume( &this->namco, adjusted_gain ); + if ( vrc6_enabled( this ) ) Vrc6_volume( &this->vrc6, adjusted_gain ); + if ( fme7_enabled( this ) ) Fme7_volume( &this->fme7, adjusted_gain ); + if ( mmc5_enabled( this ) ) Apu_volume( &this->mmc5.apu, adjusted_gain ); + if ( fds_enabled( this ) ) Fds_volume( &this->fds, adjusted_gain ); + } + #endif + + if ( adjusted_gain > this->gain ) + adjusted_gain = this->gain; + + Apu_volume( &this->apu, adjusted_gain ); + + return 0; +} + +// Header stuff +static bool valid_tag( struct header_t* this ) +{ + return 0 == memcmp( this->tag, "NESM\x1A", 5 ); +} + +// True if file supports only PAL speed +static bool pal_only( struct header_t* this ) +{ + return (this->speed_flags & 3) == 1; +} + +static int clock_rate( struct header_t* this ) +{ + return pal_only( this ) ? (int)1662607.125 : (int)1789772.727272727; +} + +static int play_period( struct header_t* this ) +{ + // NTSC + int clocks = 29780; + int value = 0x411A; + byte const* rate_ptr = this->ntsc_speed; + + // PAL + if ( pal_only( this ) ) + { + clocks = 33247; + value = 0x4E20; + rate_ptr = this->pal_speed; + } + + // Default rate + int rate = get_le16( rate_ptr ); + if ( rate == 0 ) + rate = value; + + // Custom rate + if ( rate != value ) + clocks = (int) ((1LL * rate * clock_rate( this )) / 1000000); + + return clocks; +} + +// Gets address, given pointer to it in file header. If zero, returns rom_addr. +addr_t get_addr( byte const in [] ) +{ + addr_t addr = get_le16( in ); + if ( addr == 0 ) + addr = rom_addr; + return addr; +} + +static blargg_err_t check_nsf_header( struct header_t* h ) +{ + if ( !valid_tag( h ) ) + return gme_wrong_file_type; + return 0; +} + +blargg_err_t Nsf_load_mem( struct Nsf_Emu* this, void* data, long size ) +{ + // Unload + Info_unload( &this->info ); // TODO: extremely hacky! + this->m3u.size = 0; + + this->voice_count = 0; + clear_track_vars( this ); + + assert( offsetof (struct header_t,unused [4]) == header_size ); + + if ( !memcmp( data, "NESM\x1A", 5 ) ) { + Nsf_disable_playlist( this, true ); + + RETURN_ERR( Rom_load( &this->rom, data, size, header_size, &this->header, 0 ) ); + return Nsf_post_load( this ); + } + + blargg_err_t err = Info_load( &this->info, data, size, this ); + Nsf_disable_playlist( this, false ); + return err; +} + +blargg_err_t Nsf_post_load( struct Nsf_Emu* this ) +{ + RETURN_ERR( check_nsf_header( &this->header ) ); + + /* if ( header_.vers != 1 ) + warning( "Unknown file version" ); */ + + // set up data + addr_t load_addr = get_addr( this->header.load_addr ); + /* if ( load_addr < (fds_enabled() ? sram_addr : rom_addr) ) + warning( "Load address is too low" ); */ + + Rom_set_addr( &this->rom, load_addr % this->rom.bank_size ); + + /* if ( header_.vers != 1 ) + warning( "Unknown file version" ); */ + + set_play_period( this, play_period( &this->header ) ); + + // sound and memory + blargg_err_t err = init_sound( this ); + if ( err ) + return err; + + // Set track_count + this->track_count = this->header.track_count; + + // Change clock rate & setup buffer + this->clock_rate__ = clock_rate( &this->header ); + Buffer_clock_rate( &this->stereo_buf, this->clock_rate__ ); + RETURN_ERR( Buffer_set_channel_count( &this->stereo_buf, this->voice_count, this->voice_types ) ); + this->buf_changed_count = Buffer_channels_changed_count( &this->stereo_buf ); + + // Post load + Sound_set_tempo( this, this->tempo ); + Sound_mute_voices( this, this->mute_mask_ ); + return 0; +} + +void Nsf_disable_playlist( struct Nsf_Emu* this, bool b ) +{ + Info_disable_playlist( &this->info, b ); + this->track_count = this->info.track_count; +} + +void Nsf_clear_playlist( struct Nsf_Emu* this ) +{ + Nsf_disable_playlist( this, true ); +} + +void write_bank( struct Nsf_Emu* this, int bank, int data ) +{ + // Find bank in ROM + int offset = mask_addr( data * this->rom.bank_size, this->rom.mask ); + /* if ( offset >= rom.size() ) + warning( "invalid bank" ); */ + void const* rom_data = Rom_at_addr( &this->rom, offset ); + + #ifndef NSF_EMU_APU_ONLY + if ( bank < bank_count - fds_banks && fds_enabled( this ) ) + { + // TODO: FDS bank switching is kind of hacky, might need to + // treat ROM as RAM so changes won't get lost when switching. + byte* out = sram( this ); + if ( bank >= fds_banks ) + { + out = fdsram( this ); + bank -= fds_banks; + } + memcpy( &out [bank * this->rom.bank_size], rom_data, this->rom.bank_size ); + return; + } + #endif + + if ( bank >= fds_banks ) + Cpu_map_code( &this->cpu, (bank + 6) * this->rom.bank_size, this->rom.bank_size, rom_data, false ); +} + +static void map_memory( struct Nsf_Emu* this ) +{ + // Map standard things + Cpu_reset( &this->cpu, unmapped_code( this ) ); + Cpu_map_code( &this->cpu, 0, 0x2000, this->low_ram, low_ram_size ); // mirrored four times + Cpu_map_code( &this->cpu, sram_addr, sram_size, sram( this ), 0 ); + + // Determine initial banks + byte banks [bank_count]; + static byte const zero_banks [sizeof this->header.banks] = { 0 }; + if ( memcmp( this->header.banks, zero_banks, sizeof zero_banks ) ) + { + banks [0] = this->header.banks [6]; + banks [1] = this->header.banks [7]; + memcpy( banks + fds_banks, this->header.banks, sizeof this->header.banks ); + } + else + { + // No initial banks, so assign them based on load_addr + int i, first_bank = (get_addr( this->header.load_addr ) - sram_addr) / this->rom.bank_size; + unsigned total_banks = this->rom.size / this->rom.bank_size; + for ( i = bank_count; --i >= 0; ) + { + int bank = i - first_bank; + if ( (unsigned) bank >= total_banks ) + bank = 0; + banks [i] = bank; + } + } + + // Map banks + int i; + for ( i = (fds_enabled( this ) ? 0 : fds_banks); i < bank_count; ++i ) + write_bank( this, i, banks [i] ); + + // Map FDS RAM + if ( fds_enabled( this ) ) + Cpu_map_code( &this->cpu, rom_addr, fdsram_size, fdsram( this ), 0 ); +} + +static void set_voice( struct Nsf_Emu* this, int i, struct Blip_Buffer* buf, struct Blip_Buffer* left, struct Blip_Buffer* right) +{ +#if defined(ROCKBOX) + (void) left; + (void) right; +#endif + + if ( i < apu_osc_count ) + { + Apu_osc_output( &this->apu, i, buf ); + return; + } + i -= apu_osc_count; + + #ifndef NSF_EMU_APU_ONLY + { + if ( vrc6_enabled( this ) && (i -= vrc6_osc_count) < 0 ) + { + Vrc6_osc_output( &this->vrc6, i + vrc6_osc_count, buf ); + return; + } + + if ( fme7_enabled( this ) && (i -= fme7_osc_count) < 0 ) + { + Fme7_osc_output( &this->fme7, i + fme7_osc_count, buf ); + return; + } + + if ( mmc5_enabled( this ) && (i -= mmc5_osc_count) < 0 ) + { + Mmc5_set_output( &this->mmc5, i + mmc5_osc_count, buf ); + return; + } + + if ( fds_enabled( this ) && (i -= fds_osc_count) < 0 ) + { + Fds_set_output( &this->fds, i + fds_osc_count, buf ); + return; + } + + if ( namco_enabled( this ) && (i -= namco_osc_count) < 0 ) + { + Namco_osc_output( &this->namco, i + namco_osc_count, buf ); + return; + } + + #ifndef NSF_EMU_NO_VRC7 + if ( vrc7_enabled( this ) && (i -= vrc7_osc_count) < 0 ) + { + Vrc7_set_output( &this->vrc7, i + vrc7_osc_count, buf ); + return; + } + #endif + } + #endif +} + +// Emulation + +// Music Emu + +blargg_err_t Nsf_set_sample_rate( struct Nsf_Emu* this, int rate ) +{ + require( !this->sample_rate ); // sample rate can't be changed once set + Buffer_init( &this->stereo_buf ); + RETURN_ERR( Buffer_set_sample_rate( &this->stereo_buf, rate, 1000 / 20 ) ); + + // Set bass frequency + Buffer_bass_freq( &this->stereo_buf, 80 ); + + this->sample_rate = rate; + RETURN_ERR( track_init( &this->track_filter, this ) ); + this->tfilter.max_silence = 6 * stereo * this->sample_rate; + return 0; +} + +void Sound_mute_voice( struct Nsf_Emu* this, int index, bool mute ) +{ + require( (unsigned) index < (unsigned) this->voice_count ); + int bit = 1 << index; + int mask = this->mute_mask_ | bit; + if ( !mute ) + mask ^= bit; + Sound_mute_voices( this, mask ); +} + +void Sound_mute_voices( struct Nsf_Emu* this, int mask ) +{ + require( this->sample_rate ); // sample rate must be set first + this->mute_mask_ = mask; + + int i; + for ( i = this->voice_count; i--; ) + { + if ( mask & (1 << i) ) + { + set_voice( this, i, 0, 0, 0 ); + } + else + { + struct channel_t ch = Buffer_channel( &this->stereo_buf, i ); + assert( (ch.center && ch.left && ch.right) || + (!ch.center && !ch.left && !ch.right) ); // all or nothing + set_voice( this, i, ch.center, ch.left, ch.right ); + } + } +} + +void Sound_set_tempo( struct Nsf_Emu* this, int t ) +{ + require( this->sample_rate ); // sample rate must be set first + int const min = (int)(FP_ONE_TEMPO*0.02); + int const max = (int)(FP_ONE_TEMPO*4.00); + if ( t < min ) t = min; + if ( t > max ) t = max; + this->tempo = t; + + set_play_period( this, (int) ((play_period( &this->header ) * FP_ONE_TEMPO) / t) ); + + Apu_set_tempo( &this->apu, t ); + +#ifndef NSF_EMU_APU_ONLY + if ( fds_enabled( this ) ) + Fds_set_tempo( &this->fds, t ); +#endif +} + +static inline void push_byte( struct Nsf_Emu* this, int b ) +{ + this->low_ram [0x100 + this->cpu.r.sp--] = b; +} + +// Jumps to routine, given pointer to address in file header. Pushes idle_addr +// as return address, NOT old PC. +static void jsr_then_stop( struct Nsf_Emu* this, byte const addr [] ) +{ + this->cpu.r.pc = get_addr( addr ); + push_byte( this, (idle_addr - 1) >> 8 ); + push_byte( this, (idle_addr - 1) ); +} + +int cpu_read( struct Nsf_Emu* this, addr_t addr ) +{ + #ifndef NSF_EMU_APU_ONLY + { + if ( namco_enabled( this ) && addr == namco_data_reg_addr ) + return Namco_read_data( &this->namco ); + + if ( fds_enabled( this ) && (unsigned) (addr - fds_io_addr) < fds_io_size ) + return Fds_read( &this->fds, Cpu_time( &this->cpu ), addr ); + + if ( mmc5_enabled( this ) ) { + int i = addr - 0x5C00; + if ( (unsigned) i < mmc5_exram_size ) + return this->mmc5.exram [i]; + + int m = addr - 0x5205; + if ( (unsigned) m < 2 ) + return (this->mmc5_mul [0] * this->mmc5_mul [1]) >> (m * 8) & 0xFF; + } + } + #endif + + /* Unmapped read */ + return addr >> 8; +} + +void cpu_write( struct Nsf_Emu* this, addr_t addr, int data ) +{ + #ifndef NSF_EMU_APU_ONLY + { + if ( fds_enabled( this) && (unsigned) (addr - fds_io_addr) < fds_io_size ) + { + Fds_write( &this->fds, Cpu_time( &this->cpu ), addr, data ); + return; + } + + if ( namco_enabled( this) ) + { + if ( addr == namco_addr_reg_addr ) + { + Namco_write_addr( &this->namco, data ); + return; + } + + if ( addr == namco_data_reg_addr ) + { + Namco_write_data( &this->namco, Cpu_time( &this->cpu ), data ); + return; + } + } + + if ( vrc6_enabled( this) ) + { + int reg = addr & (vrc6_addr_step - 1); + int osc = (unsigned) (addr - vrc6_base_addr) / vrc6_addr_step; + if ( (unsigned) osc < vrc6_osc_count && (unsigned) reg < vrc6_reg_count ) + { + Vrc6_write_osc( &this->vrc6, Cpu_time( &this->cpu ), osc, reg, data ); + return; + } + } + + if ( fme7_enabled( this) && addr >= fme7_latch_addr ) + { + switch ( addr & fme7_addr_mask ) + { + case fme7_latch_addr: + Fme7_write_latch( &this->fme7, data ); + return; + + case fme7_data_addr: + Fme7_write_data( &this->fme7, Cpu_time( &this->cpu ), data ); + return; + } + } + + if ( mmc5_enabled( this) ) + { + if ( (unsigned) (addr - mmc5_regs_addr) < mmc5_regs_size ) + { + Mmc5_write_register( &this->mmc5, Cpu_time( &this->cpu ), addr, data ); + return; + } + + int m = addr - 0x5205; + if ( (unsigned) m < 2 ) + { + this->mmc5_mul [m] = data; + return; + } + + int i = addr - 0x5C00; + if ( (unsigned) i < mmc5_exram_size ) + { + this->mmc5.exram [i] = data; + return; + } + } + + #ifndef NSF_EMU_NO_VRC7 + if ( vrc7_enabled( this) ) + { + if ( addr == 0x9010 ) + { + Vrc7_write_reg( &this->vrc7, data ); + return; + } + + if ( (unsigned) (addr - 0x9028) <= 0x08 ) + { + Vrc7_write_data( &this->vrc7, Cpu_time( &this->cpu ), data ); + return; + } + } + #endif + } + #endif + + // Unmapped_write +} + +blargg_err_t Nsf_start_track( struct Nsf_Emu* this, int track ) +{ + clear_track_vars( this ); + + // Remap track if playlist available + if ( this->m3u.size > 0 ) { + struct entry_t* e = &this->m3u.entries[track]; + track = e->track; + } + else track = Info_remap_track( &this->info, track ); + + this->current_track = track; + Buffer_clear( &this->stereo_buf ); + + #ifndef NSF_EMU_APU_ONLY + if ( mmc5_enabled( this ) ) + { + this->mmc5_mul [0] = 0; + this->mmc5_mul [1] = 0; + memset( this->mmc5.exram, 0, mmc5_exram_size ); + } + + if ( fds_enabled( this ) ) Fds_reset( &this->fds ); + if ( namco_enabled( this ) ) Namco_reset( &this->namco ); + if ( vrc6_enabled( this ) ) Vrc6_reset( &this->vrc6 ); + if ( fme7_enabled( this ) ) Fme7_reset( &this->fme7 ); + if ( mmc5_enabled( this ) ) Apu_reset( &this->mmc5.apu, false, 0 ); + #ifndef NSF_EMU_NO_VRC7 + if ( vrc7_enabled( this ) ) Vrc7_reset( &this->vrc7 ); + #endif + #endif + + int speed_flags = 0; + #ifdef NSF_EMU_EXTRA_FLAGS + speed_flags = this->header.speed_flags; + #endif + + Apu_reset( &this->apu, pal_only( &this->header ), (speed_flags & 0x20) ? 0x3F : 0 ); + Apu_write_register( &this->apu, 0, 0x4015, 0x0F ); + Apu_write_register( &this->apu, 0, 0x4017, (speed_flags & 0x10) ? 0x80 : 0 ); + + memset( unmapped_code( this ), halt_opcode, unmapped_size ); + memset( this->low_ram, 0, low_ram_size ); + memset( sram( this ), 0, sram_size ); + + map_memory( this ); + + // Arrange time of first call to play routine + this->play_extra = 0; + this->next_play = this->play_period; + + this->play_delay = initial_play_delay; + this->saved_state.pc = idle_addr; + + // Setup for call to init routine + this->cpu.r.a = track; + this->cpu.r.x = pal_only( &this->header ); + this->cpu.r.sp = 0xFF; + jsr_then_stop( this, this->header.init_addr ); + /* if ( this->cpu.r.pc < get_addr( header.load_addr ) ) + warning( "Init address < load address" ); */ + + // convert filter times to samples + struct setup_t s = this->tfilter; + s.max_initial *= this->sample_rate * stereo; + #ifdef GME_DISABLE_SILENCE_LOOKAHEAD + s.lookahead = 1; + #endif + track_setup( &this->track_filter, &s ); + + return track_start( &this->track_filter ); +} + +void run_once( struct Nsf_Emu* this, nes_time_t end ) +{ + // Emulate until next play call if possible + if ( run_cpu_until( this, min( this->next_play, end ) ) ) + { + // Halt instruction encountered + + if ( this->cpu.r.pc != idle_addr ) + { + // special_event( "illegal instruction" ); + Cpu_set_time( &this->cpu, this->cpu.end_time ); + return; + } + + // Init/play routine returned + this->play_delay = 1; // play can now be called regularly + + if ( this->saved_state.pc == idle_addr ) + { + // nothing to run + nes_time_t t = this->cpu.end_time; + if ( Cpu_time( &this->cpu ) < t ) + Cpu_set_time( &this->cpu, t ); + } + else + { + // continue init routine that was interrupted by play routine + this->cpu.r = this->saved_state; + this->saved_state.pc = idle_addr; + } + } + + if ( Cpu_time( &this->cpu ) >= this->next_play ) + { + // Calculate time of next call to play routine + this->play_extra ^= 1; // extra clock every other call + this->next_play += this->play_period + this->play_extra; + + // Call routine if ready + if ( this->play_delay && !--this->play_delay ) + { + // Save state if init routine is still running + if ( this->cpu.r.pc != idle_addr ) + { + check( this->saved_state.pc == idle_addr ); + this->saved_state = this->cpu.r; + // special_event( "play called during init" ); + } + + jsr_then_stop( this, this->header.play_addr ); + } + } +} + +void run_until( struct Nsf_Emu* this, nes_time_t end ) +{ + while ( Cpu_time( &this->cpu ) < end ) + run_once( this, end ); +} + +static void end_frame( struct Nsf_Emu* this, nes_time_t end ) +{ + if ( Cpu_time( &this->cpu ) < end ) + run_until( this, end ); + Cpu_adjust_time( &this->cpu, -end ); + + // Localize to new time frame + this->next_play -= end; + check( this->next_play >= 0 ); + if ( this->next_play < 0 ) + this->next_play = 0; + + Apu_end_frame( &this->apu, end ); + + #ifndef NSF_EMU_APU_ONLY + if ( fds_enabled( this ) ) Fds_end_frame( &this->fds, end ); + if ( fme7_enabled( this ) ) Fme7_end_frame( &this->fme7, end ); + if ( mmc5_enabled( this ) ) Apu_end_frame( &this->mmc5.apu, end ); + if ( namco_enabled( this ) ) Namco_end_frame( &this->namco, end ); + if ( vrc6_enabled( this ) ) Vrc6_end_frame( &this->vrc6, end ); + #ifndef NSF_EMU_NO_VRC7 + if ( vrc7_enabled( this ) ) Vrc7_end_frame( &this->vrc7, end ); + #endif + #endif +} + +// Tell/Seek + +static int msec_to_samples( int msec, int sample_rate ) +{ + int sec = msec / 1000; + msec -= sec * 1000; + return (sec * sample_rate + msec * sample_rate / 1000) * stereo; +} + +int Track_tell( struct Nsf_Emu* this ) +{ + int rate = this->sample_rate * stereo; + int sec = track_sample_count( &this->track_filter ) / rate; + return sec * 1000 + (track_sample_count( &this->track_filter ) - sec * rate) * 1000 / rate; +} + +blargg_err_t Track_seek( struct Nsf_Emu* this, int msec ) +{ + int time = msec_to_samples( msec, this->sample_rate ); + if ( time < track_sample_count( &this->track_filter ) ) + RETURN_ERR( Nsf_start_track( this, this->current_track ) ); + return Track_skip( this, time - track_sample_count( &this->track_filter ) ); +} + +blargg_err_t Track_skip( struct Nsf_Emu* this, int count ) +{ + require( this->current_track >= 0 ); // start_track() must have been called already + return track_skip( &this->track_filter, count ); +} + +blargg_err_t skip_( void *emu, int count ) +{ + struct Nsf_Emu* this = (struct Nsf_Emu*) emu; + + // for long skip, mute sound + const int threshold = 32768; + if ( count > threshold ) + { + int saved_mute = this->mute_mask_; + Sound_mute_voices( this, ~0 ); + + int n = count - threshold/2; + n &= ~(2048-1); // round to multiple of 2048 + count -= n; + RETURN_ERR( skippy_( &this->track_filter, n ) ); + + Sound_mute_voices( this, saved_mute ); + } + + return skippy_( &this->track_filter, count ); +} + +// Fading + +void Track_set_fade( struct Nsf_Emu* this, int start_msec, int length_msec ) +{ + track_set_fade( &this->track_filter, msec_to_samples( start_msec, this->sample_rate ), + length_msec * this->sample_rate / (1000 / stereo) ); +} + +blargg_err_t Nsf_play( struct Nsf_Emu* this, int out_count, sample_t* out ) +{ + require( this->current_track >= 0 ); + require( out_count % stereo == 0 ); + return track_play( &this->track_filter, out_count, out ); +} + +blargg_err_t play_( void* emu, int count, sample_t* out ) +{ + struct Nsf_Emu* this = (struct Nsf_Emu*) emu; + + int remain = count; + while ( remain ) + { + Buffer_disable_immediate_removal( &this->stereo_buf ); + remain -= Buffer_read_samples( &this->stereo_buf, &out [count - remain], remain ); + if ( remain ) + { + if ( this->buf_changed_count != Buffer_channels_changed_count( &this->stereo_buf ) ) + { + this->buf_changed_count = Buffer_channels_changed_count( &this->stereo_buf ); + + // Remute voices + Sound_mute_voices( this, this->mute_mask_ ); + } + int msec = Buffer_length( &this->stereo_buf ); + blip_time_t clocks_emulated = msec * this->clock_rate__ / 1000 - 100; + RETURN_ERR( run_clocks( this, &clocks_emulated, msec ) ); + assert( clocks_emulated ); + Buffer_end_frame( &this->stereo_buf, clocks_emulated ); + } + } + return 0; +} + +blargg_err_t run_clocks( struct Nsf_Emu* this, blip_time_t* duration, int msec ) +{ +#if defined(ROCKBOX) + (void) msec; +#endif + + end_frame( this, *duration ); + return 0; +} diff --git a/lib/rbcodec/codecs/libgme/nsf_emu.h b/lib/rbcodec/codecs/libgme/nsf_emu.h new file mode 100644 index 0000000000..00bdad4a4e --- /dev/null +++ b/lib/rbcodec/codecs/libgme/nsf_emu.h @@ -0,0 +1,261 @@ +// Nintendo NES/Famicom NSF music file emulator + +// Game_Music_Emu 0.5.5 +#ifndef NSF_EMU_H +#define NSF_EMU_H + +#include "rom_data.h" +#include "multi_buffer.h" +#include "nes_apu.h" +#include "nes_cpu.h" +#include "nsfe_info.h" +#include "m3u_playlist.h" +#include "track_filter.h" + +#ifndef NSF_EMU_APU_ONLY + #include "nes_namco_apu.h" + #include "nes_vrc6_apu.h" + #include "nes_fme7_apu.h" + #include "nes_fds_apu.h" + #include "nes_mmc5_apu.h" + #ifndef NSF_EMU_NO_VRC7 + #include "nes_vrc7_apu.h" + #endif +#endif + +// Sound chip flags +enum { + vrc6_flag = 1 << 0, + vrc7_flag = 1 << 1, + fds_flag = 1 << 2, + mmc5_flag = 1 << 3, + namco_flag = 1 << 4, + fme7_flag = 1 << 5 +}; + +enum { fds_banks = 2 }; +enum { bank_count = fds_banks + 8 }; + +enum { rom_begin = 0x8000 }; +enum { bank_select_addr = 0x5FF8 }; +enum { mem_size = 0x10000 }; + +// cpu sits here when waiting for next call to play routine +enum { idle_addr = 0x5FF6 }; +enum { banks_addr = idle_addr }; +enum { badop_addr = bank_select_addr }; + +enum { low_ram_size = 0x800 }; +enum { sram_size = 0x2000 }; +enum { fdsram_size = 0x6000 }; +enum { fdsram_offset = 0x2000 + page_size + 8 }; +enum { sram_addr = 0x6000 }; +enum { unmapped_size= page_size + 8 }; +enum { max_voices = 32 }; + +// NSF file header +enum { header_size = 0x80 }; +struct header_t +{ + char tag [5]; + byte vers; + byte track_count; + byte first_track; + byte load_addr [2]; + byte init_addr [2]; + byte play_addr [2]; + char game [32]; + char author [32]; + char copyright [32]; + byte ntsc_speed [2]; + byte banks [8]; + byte pal_speed [2]; + byte speed_flags; + byte chip_flags; + byte unused [4]; +}; + +struct Nsf_Emu { + // Play routine timing + nes_time_t next_play; + nes_time_t play_period; + int play_extra; + int play_delay; + struct registers_t saved_state; // of interrupted init routine + + // general + int voice_count; + int voice_types [32]; + int mute_mask_; + int tempo; + int gain; + + int sample_rate; + + // track-specific + int track_count; + int current_track; + + int clock_rate__; + unsigned buf_changed_count; + + // M3u Playlist + struct M3u_Playlist m3u; + + // Larger items at the end + #ifndef NSF_EMU_APU_ONLY + byte mmc5_mul [2]; + + struct Nes_Fds_Apu fds; + struct Nes_Mmc5_Apu mmc5; + struct Nes_Namco_Apu namco; + struct Nes_Vrc6_Apu vrc6; + struct Nes_Fme7_Apu fme7; + #ifndef NSF_EMU_NO_VRC7 + struct Nes_Vrc7_Apu vrc7; + #endif + #endif + + struct Nes_Cpu cpu; + struct Nes_Apu apu; + + // Header for currently loaded file + struct header_t header; + + struct setup_t tfilter; + struct Track_Filter track_filter; + + struct Multi_Buffer stereo_buf; + struct Rom_Data rom; + + // Extended nsf info + struct Nsfe_Info info; + + byte high_ram[fdsram_size + fdsram_offset]; + byte low_ram [low_ram_size]; +}; + +// Basic functionality (see Gme_File.h for file loading/track info functions) + +void Nsf_init( struct Nsf_Emu* this ); +blargg_err_t Nsf_load_mem( struct Nsf_Emu* this, void* data, long size ); +blargg_err_t Nsf_post_load( struct Nsf_Emu* this ); + +// Set output sample rate. Must be called only once before loading file. +blargg_err_t Nsf_set_sample_rate( struct Nsf_Emu* this, int sample_rate ); + +// Start a track, where 0 is the first track. Also clears warning string. +blargg_err_t Nsf_start_track( struct Nsf_Emu* this , int ); + +// Generate 'count' samples info 'buf'. Output is in stereo. Any emulation +// errors set warning string, and major errors also end track. +blargg_err_t Nsf_play( struct Nsf_Emu* this, int count, sample_t* buf ); + +void Nsf_clear_playlist( struct Nsf_Emu* this ); +void Nsf_disable_playlist( struct Nsf_Emu* this, bool b ); // use clear_playlist() + +// Track status/control + +// Number of milliseconds (1000 msec = 1 second) played since beginning of track +int Track_tell( struct Nsf_Emu* this ); + +// Seek to new time in track. Seeking backwards or far forward can take a while. +blargg_err_t Track_seek( struct Nsf_Emu* this, int msec ); + +// Skip n samples +blargg_err_t Track_skip( struct Nsf_Emu* this, int n ); + +// Set start time and length of track fade out. Once fade ends track_ended() returns +// true. Fade time can be changed while track is playing. +void Track_set_fade( struct Nsf_Emu* this, int start_msec, int length_msec ); + +// True if a track has reached its end +static inline bool Track_ended( struct Nsf_Emu* this ) +{ + return track_ended( &this->track_filter ); +} + +// Disables automatic end-of-track detection and skipping of silence at beginning +static inline void Track_ignore_silence( struct Nsf_Emu* this, bool disable ) +{ + this->track_filter.silence_ignored_ = disable; +} + +// Get track length in milliseconds +int Track_length( struct Nsf_Emu* this, int n ); + +// Sound customization + +// Adjust song tempo, where 1.0 = normal, 0.5 = half speed, 2.0 = double speed. +// Track length as returned by track_info() assumes a tempo of 1.0. +void Sound_set_tempo( struct Nsf_Emu* this, int t ); + +// Mute/unmute voice i, where voice 0 is first voice +void Sound_mute_voice( struct Nsf_Emu* this, int index, bool mute ); + +// Set muting state of all voices at once using a bit mask, where -1 mutes them all, +// 0 unmutes them all, 0x01 mutes just the first voice, etc. +void Sound_mute_voices( struct Nsf_Emu* this, int mask ); + +// Change overall output amplitude, where 1.0 results in minimal clamping. +// Must be called before set_sample_rate(). +static inline void Sound_set_gain( struct Nsf_Emu* this, int g ) +{ + assert( !this->sample_rate ); // you must set gain before setting sample rate + this->gain = g; +} + +// Emulation (You shouldn't touch these) + +blargg_err_t run_clocks( struct Nsf_Emu* this, blip_time_t* duration, int ); + +void write_bank( struct Nsf_Emu* this, int index, int data ); +int cpu_read( struct Nsf_Emu* this, addr_t ); +void cpu_write( struct Nsf_Emu* this, addr_t, int ); +addr_t get_addr( byte const [] ); +bool run_cpu_until( struct Nsf_Emu* this, nes_time_t end ); + +// Sets clocks between calls to play routine to p + 1/2 clock +static inline void set_play_period( struct Nsf_Emu* this, int p ) { this->play_period = p; } + +// Time play routine will next be called +static inline nes_time_t play_time( struct Nsf_Emu* this ) { return this->next_play; } + +// Emulates to at least time t. Might emulate a few clocks extra. +void run_until( struct Nsf_Emu* this, nes_time_t t ); + +// Runs cpu to at least time t and returns false, or returns true +// if it encounters illegal instruction (halt). +bool run_cpu_until( struct Nsf_Emu* this, nes_time_t t ); + +// cpu calls through to these to access memory (except instructions) +int read_mem( struct Nsf_Emu* this, addr_t ); +void write_mem( struct Nsf_Emu* this, addr_t, int ); + +// Address of play routine +static inline addr_t play_addr( struct Nsf_Emu* this ) { return get_addr( this->header.play_addr ); } + +// Same as run_until, except emulation stops for any event (routine returned, +// play routine called, illegal instruction). +void run_once( struct Nsf_Emu* this, nes_time_t ); + +// Reads byte as cpu would when executing code. Only works for RAM/ROM, +// NOT I/O like sound chips. +int read_code( struct Nsf_Emu* this, addr_t addr ); + +static inline byte* fdsram( struct Nsf_Emu* this ) { return &this->high_ram [fdsram_offset]; } +static inline byte* sram( struct Nsf_Emu* this ) { return this->high_ram; } +static inline byte* unmapped_code( struct Nsf_Emu* this ) { return &this->high_ram [sram_size]; } + +#ifndef NSF_EMU_APU_ONLY + static inline int fds_enabled( struct Nsf_Emu* this ) { return this->header.chip_flags & fds_flag; } + static inline int vrc6_enabled( struct Nsf_Emu* this ) { return this->header.chip_flags & vrc6_flag; } + #ifndef NSF_EMU_NO_VRC7 + static inline int vrc7_enabled( struct Nsf_Emu* this ) { return this->header.chip_flags & vrc7_flag; } + #endif + static inline int mmc5_enabled( struct Nsf_Emu* this ) { return this->header.chip_flags & mmc5_flag; } + static inline int namco_enabled( struct Nsf_Emu* this ) { return this->header.chip_flags & namco_flag; } + static inline int fme7_enabled( struct Nsf_Emu* this ) { return this->header.chip_flags & fme7_flag; } +#endif + +#endif diff --git a/lib/rbcodec/codecs/libgme/nsfe_info.c b/lib/rbcodec/codecs/libgme/nsfe_info.c new file mode 100644 index 0000000000..337b1e580a --- /dev/null +++ b/lib/rbcodec/codecs/libgme/nsfe_info.c @@ -0,0 +1,272 @@ +// Game_Music_Emu 0.5.5. http://www.slack.net/~ant/ + +#include "nsf_emu.h" + +#include "blargg_endian.h" +#include + +/* Copyright (C) 2005-2006 Shay Green. This module is free software; you +can redistribute it and/or modify it under the terms of the GNU Lesser +General Public License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. This +module is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +details. You should have received a copy of the GNU Lesser General Public +License along with this module; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ + +#include "blargg_source.h" + +void Info_init( struct Nsfe_Info* this ) +{ + this->playlist_disabled = false; +} + +void Info_unload( struct Nsfe_Info* this ) +{ + memset(this->playlist, 0, 256); + memset(this->track_times, 0, 256 * sizeof(int32_t)); + + this->playlist_size = 0; + this->track_times_size = 0; +} + +// TODO: if no playlist, treat as if there is a playlist that is just 1,2,3,4,5... ? +void Info_disable_playlist( struct Nsfe_Info* this, bool b ) +{ + this->playlist_disabled = b; + this->track_count = this->playlist_size; + if ( !this->track_count || this->playlist_disabled ) + this->track_count = this->actual_track_count_; +} + +int Info_remap_track( struct Nsfe_Info* this, int track ) +{ + if ( !this->playlist_disabled && (unsigned) track < (unsigned) this->playlist_size ) + track = this->playlist [track]; + return track; +} + +const char eof_error [] = "Unexpected end of file"; + +// Read n bytes from memory buffer +static blargg_err_t in_read( void* dst, long bytes, void* data, long* offset, long size ) +{ + if ((*offset + bytes) > size) return eof_error; + + memcpy(dst, (char*) data + *offset, bytes); + *offset += bytes; + return 0; +} + +static blargg_err_t in_skip( long bytes, long *offset, long size ) +{ + if ((*offset + bytes) > size) return eof_error; + + *offset += bytes; + return 0; +} + +// Skip n bytes from memory buffer + +// Read multiple strings and separate into individual strings +static int read_strs( void* data, long bytes, long* offset, long size, + const char* strs [4] ) +{ + char* chars = (char*) data + *offset; + chars [bytes - 1] = 0; // in case last string doesn't have terminator + + if ( in_skip( bytes, offset, size) ) + return -1; + + int count = 0, i; + for ( i = 0; i < bytes; i++ ) + { + strs [count] = &chars [i]; + while ( i < bytes && chars [i] ) + i++; + + count++; + if (count >= 4) + break; + } + + return count; +} + +struct nsfe_info_t +{ + byte load_addr [2]; + byte init_addr [2]; + byte play_addr [2]; + byte speed_flags; + byte chip_flags; + byte track_count; + byte first_track; + byte unused [6]; +}; + +blargg_err_t Info_load( struct Nsfe_Info* this, void* data, long size, struct Nsf_Emu* nsf_emu ) +{ + long offset = 0; + int const nsfe_info_size = 16; + assert( offsetof (struct nsfe_info_t,unused [6]) == nsfe_info_size ); + + // check header + byte signature [4]; + blargg_err_t err = in_read( signature, sizeof signature, data, &offset, size ); + if ( err ) + return (err == eof_error ? gme_wrong_file_type : err); + if ( memcmp( signature, "NSFE", 4 ) ) { + } + + // free previous info + /* TODO: clear track_names */ + memset(this->playlist, 0, 256); + memset(this->track_times, 0, 256 * sizeof(int32_t)); + + this->playlist_size = 0; + this->track_times_size = 0; + + // default nsf header + static const struct header_t base_header = + { + {'N','E','S','M','\x1A'},// tag + 1, // version + 1, 1, // track count, first track + {0,0},{0,0},{0,0}, // addresses + "","","", // strings + {0x1A, 0x41}, // NTSC rate + {0,0,0,0,0,0,0,0}, // banks + {0x20, 0x4E}, // PAL rate + 0, 0, // flags + {0,0,0,0} // unused + }; + + memcpy( &nsf_emu->header, &base_header, sizeof base_header ); + + // parse tags + int phase = 0; + while ( phase != 3 ) + { + // read size and tag + byte block_header [2] [4]; + RETURN_ERR( in_read( block_header, sizeof block_header, data, &offset, size ) ); + + int chunk_size = get_le32( block_header [0] ); + int tag = get_le32( block_header [1] ); + + switch ( tag ) + { + case BLARGG_4CHAR('O','F','N','I'): { + check( phase == 0 ); + if ( chunk_size < 8 ) + return "Corrupt file"; + + struct nsfe_info_t finfo; + finfo.track_count = 1; + finfo.first_track = 0; + + RETURN_ERR( in_read( &finfo, min( chunk_size, nsfe_info_size ), + (char*) data, &offset, size ) ); + + if ( chunk_size > nsfe_info_size ) + RETURN_ERR( in_skip( chunk_size - nsfe_info_size, &offset, size ) ); + + phase = 1; + nsf_emu->header.speed_flags = finfo.speed_flags; + nsf_emu->header.chip_flags = finfo.chip_flags; + nsf_emu->header.track_count = finfo.track_count; + this->actual_track_count_ = finfo.track_count; + nsf_emu->header.first_track = finfo.first_track; + memcpy( nsf_emu->header.load_addr, finfo.load_addr, 2 * 3 ); + break; + } + + case BLARGG_4CHAR('K','N','A','B'): + if ( chunk_size > (int) sizeof nsf_emu->header.banks ) + return "Corrupt file"; + RETURN_ERR( in_read( nsf_emu->header.banks, chunk_size, data, &offset, size ) ); + break; + + case BLARGG_4CHAR('h','t','u','a'): { + const char* strs [4]; + int n = read_strs( data, chunk_size, &offset, size, strs ); + if ( n < 0 ) + return eof_error; + break; + } + + case BLARGG_4CHAR('e','m','i','t'): + this->track_times_size = chunk_size / 4; + RETURN_ERR( in_read( this->track_times, this->track_times_size * 4, data, &offset, size ) ); + break; + + case BLARGG_4CHAR('l','b','l','t'): + RETURN_ERR( in_skip( chunk_size, &offset, size ) ); + break; + + case BLARGG_4CHAR('t','s','l','p'): + this->playlist_size = chunk_size; + RETURN_ERR( in_read( &this->playlist [0], chunk_size, data, &offset, size ) ); + break; + + case BLARGG_4CHAR('A','T','A','D'): { + check( phase == 1 ); + phase = 2; + if ( !nsf_emu ) + { + RETURN_ERR( in_skip( chunk_size, &offset, size ) ); + } + else + { + // Avoid unexpected end of file + if ( (offset + chunk_size) > size ) + return eof_error; + + RETURN_ERR( Rom_load( &nsf_emu->rom, (char*) data + offset, chunk_size, 0, 0, 0 ) ); + RETURN_ERR( Nsf_post_load( nsf_emu ) ); + offset += chunk_size; + } + break; + } + + case BLARGG_4CHAR('D','N','E','N'): + check( phase == 2 ); + phase = 3; + break; + + default: + // tags that can be skipped start with a lowercase character + check( islower( (tag >> 24) & 0xFF ) ); + RETURN_ERR( in_skip( chunk_size, &offset, size ) ); + break; + } + } + + return 0; +} + +int Track_length( struct Nsf_Emu* this, int n ) +{ + int length = 0; + if ( (this->m3u.size > 0) && (n < this->m3u.size) ) { + struct entry_t* entry = &this->m3u.entries [n]; + length = entry->length; + } + else if ( (this->info.playlist_size > 0) && (n < this->info.playlist_size) ) { + int remapped = Info_remap_track( &this->info, n ); + if ( (unsigned) remapped < (unsigned) this->info.track_times_size ) + length = (int32_t) get_le32( &this->info.track_times [remapped] ); + } + else if( (unsigned) n < (unsigned) this->info.track_times_size ) + length = (int32_t) get_le32( &this->info.track_times [n] ); + + /* Length will be 2,30 minutes for one track songs, + and 1,45 minutes for multitrack songs */ + if ( length <= 0 ) + length = (this->track_count > 1 ? 105 : 150) * 1000; + + return length; +} diff --git a/lib/rbcodec/codecs/libgme/nsfe_info.h b/lib/rbcodec/codecs/libgme/nsfe_info.h new file mode 100644 index 0000000000..9dcde7b68a --- /dev/null +++ b/lib/rbcodec/codecs/libgme/nsfe_info.h @@ -0,0 +1,30 @@ +// Nintendo NES/Famicom NSFE file info parser + +// Game_Music_Emu 0.5.5 +#ifndef NSFE_INFO_H +#define NSFE_INFO_H + +#include "blargg_common.h" + +struct Nsf_Emu; + +// Allows reading info from NSFE file without creating emulator +struct Nsfe_Info { + int playlist_size; + int track_times_size; + int track_count; + int actual_track_count_; + bool playlist_disabled; + + unsigned char playlist [256]; + int32_t track_times [256]; +}; + +void Info_init( struct Nsfe_Info* this ); +blargg_err_t Info_load( struct Nsfe_Info* this, void *data, long size, struct Nsf_Emu* ); +void Info_disable_playlist( struct Nsfe_Info* this, bool b ); +int Info_remap_track( struct Nsfe_Info* this, int i ); +void Info_unload( struct Nsfe_Info* this ); + + +#endif diff --git a/lib/rbcodec/codecs/libgme/opl_apu.c b/lib/rbcodec/codecs/libgme/opl_apu.c new file mode 100644 index 0000000000..b573baef11 --- /dev/null +++ b/lib/rbcodec/codecs/libgme/opl_apu.c @@ -0,0 +1,198 @@ +#include "opl_apu.h" + +#include "blargg_source.h" + +/* NOTE: Removed unused chips ~ gama */ + +blargg_err_t Opl_init( struct Opl_Apu* this, long clock, long rate, blip_time_t period, enum opl_type_t type ) +{ + Synth_init( &this->synth ); + + this->type_ = type; + this->clock_ = clock; + this->rate_ = rate; + this->period_ = period; + Opl_set_output( this, 0 ); + Opl_volume( this, (int)FP_ONE_VOLUME ); + + switch (type) + { + case type_opll: + case type_msxmusic: + case type_smsfmunit: + OPLL_new ( &this->opll, clock, rate ); + OPLL_reset_patch( &this->opll, OPLL_2413_TONE ); + break; + case type_vrc7: + OPLL_new ( &this->opll, clock, rate ); + OPLL_reset_patch( &this->opll, OPLL_VRC7_TONE ); + break; + case type_msxaudio: + OPL_init( &this->opl, this->opl_memory, sizeof this->opl_memory ); + OPL_setSampleRate( &this->opl, rate, clock ); + OPL_setInternalVolume(&this->opl, 1 << 13); + break; + } + + Opl_reset( this ); + return 0; +} + +void Opl_shutdown( struct Opl_Apu* this ) +{ + switch (this->type_) + { + case type_opll: + case type_msxmusic: + case type_smsfmunit: + case type_vrc7: + OPLL_delete( &this->opll ); + break; + case type_msxaudio: break; + } +} + +void Opl_reset( struct Opl_Apu* this ) +{ + this->addr = 0; + this->next_time = 0; + this->last_amp = 0; + + switch (this->type_) + { + case type_opll: + case type_msxmusic: + case type_smsfmunit: + case type_vrc7: + OPLL_reset( &this->opll ); + OPLL_setMask( &this->opll, 0 ); + break; + case type_msxaudio: + OPL_reset( &this->opl ); + break; + } +} + +static void run_until( struct Opl_Apu* this, blip_time_t end_time ); +void Opl_write_data( struct Opl_Apu* this, blip_time_t time, int data ) +{ + run_until( this, time ); + switch (this->type_) + { + case type_opll: + case type_msxmusic: + case type_smsfmunit: + case type_vrc7: + OPLL_writeIO( &this->opll, 0, this->addr ); + OPLL_writeIO( &this->opll, 1, data ); + break; + case type_msxaudio: + OPL_writeReg( &this->opl, this->addr, data ); + break; + } +} + +int Opl_read( struct Opl_Apu* this, blip_time_t time, int port ) +{ + run_until( this, time ); + switch (this->type_) + { + case type_opll: + case type_msxmusic: + case type_smsfmunit: + case type_vrc7: + return OPLL_read( &this->opll, port ); + case type_msxaudio: + return OPL_readStatus( &this->opl ); + } + + return 0; +} + +void Opl_end_frame( struct Opl_Apu* this, blip_time_t time ) +{ + run_until( this, time ); + this->next_time -= time; + + if ( this->output_ ) + Blip_set_modified( this->output_ ); +} + +static void run_until( struct Opl_Apu* this, blip_time_t end_time ) +{ + if ( end_time > this->next_time ) + { + blip_time_t time_delta = end_time - this->next_time; + blip_time_t time = this->next_time; + unsigned count = time_delta / this->period_ + 1; + switch (this->type_) + { + case type_opll: + case type_msxmusic: + case type_smsfmunit: + case type_vrc7: + { + OPLL* opll = &this->opll; // cache + struct Blip_Buffer* const output = this->output_; + while ( count > 0 ) + { + unsigned todo = count; + if ( todo > 1024 ) todo = 1024; + short *buffer = OPLL_update_buffer(opll, todo); + + if ( output && buffer ) + { + int last_amp = this->last_amp; + unsigned i; + for ( i = 0; i < todo; i++ ) + { + int amp = buffer [i]; + int delta = amp - last_amp; + if ( delta ) + { + last_amp = amp; + Synth_offset_inline( &this->synth, time, delta, output ); + } + time += this->period_; + } + this->last_amp = last_amp; + } + count -= todo; + } + } + break; + case type_msxaudio: + { + struct Y8950* opl = &this->opl; + struct Blip_Buffer* const output = this->output_; + while ( count > 0 ) + { + unsigned todo = count; + if ( todo > 1024 ) todo = 1024; + int *buffer = OPL_updateBuffer(opl, todo); + + if ( output && buffer ) + { + int last_amp = this->last_amp; + unsigned i; + for ( i = 0; i < todo; i++ ) + { + int amp = buffer [i]; + int delta = amp - last_amp; + if ( delta ) + { + last_amp = amp; + Synth_offset_inline( &this->synth, time, delta, output ); + } + time += this->period_; + } + this->last_amp = last_amp; + } + count -= todo; + } + } + break; + } + this->next_time = time; + } +} diff --git a/lib/rbcodec/codecs/libgme/opl_apu.h b/lib/rbcodec/codecs/libgme/opl_apu.h new file mode 100644 index 0000000000..76fa766492 --- /dev/null +++ b/lib/rbcodec/codecs/libgme/opl_apu.h @@ -0,0 +1,63 @@ +#ifndef OPL_APU_H +#define OPL_APU_H + +#include "blargg_common.h" +#include "blargg_source.h" +#include "blip_buffer.h" + +#include "emu8950.h" +#include "emu2413.h" + +enum opl_type_t { type_opll = 0x10, type_msxmusic = 0x11, type_smsfmunit = 0x12, + type_vrc7 = 0x13, type_msxaudio = 0x21 }; + +enum { opl_osc_count = 1 }; + +struct Opl_Apu { + struct Blip_Buffer* output_; + enum opl_type_t type_; + + blip_time_t next_time; + int last_amp; + int addr; + + long clock_; + long rate_; + blip_time_t period_; + + struct Blip_Synth synth; + + // OPL chips + struct Y8950 opl; + OPLL opll; + + unsigned char regs[ 0x100 ]; + unsigned char opl_memory[ 32768 ]; +}; + +blargg_err_t Opl_init( struct Opl_Apu* this, long clock, long rate, blip_time_t period, enum opl_type_t type ); +void Opl_shutdown( struct Opl_Apu* this ); + +void Opl_reset( struct Opl_Apu* this ); +static inline void Opl_volume( struct Opl_Apu* this, int v ) { Synth_volume( &this->synth, v / (4096 * 6) ); } + +static inline void Opl_osc_output( struct Opl_Apu* this, int i, struct Blip_Buffer* buf ) +{ +#if defined(ROCKBOX) + (void) i; +#endif + assert( (unsigned) i < opl_osc_count ); + this->output_ = buf; +} + +static inline void Opl_set_output( struct Opl_Apu* this, struct Blip_Buffer* buf ) { Opl_osc_output( this, 0, buf ); } +void Opl_end_frame( struct Opl_Apu* this, blip_time_t ); + +static inline void Opl_write_addr( struct Opl_Apu* this, int data ) { this->addr = data; } +void Opl_write_data( struct Opl_Apu* this, blip_time_t, int data ); + +int Opl_read( struct Opl_Apu* this, blip_time_t, int port ); + +static inline bool Opl_supported( void ) { return true; } + +#endif diff --git a/lib/rbcodec/codecs/libgme/opltables.h b/lib/rbcodec/codecs/libgme/opltables.h new file mode 100644 index 0000000000..50fc0a86c6 --- /dev/null +++ b/lib/rbcodec/codecs/libgme/opltables.h @@ -0,0 +1,242 @@ +#ifndef _OPLTABLES_H_ +#define _OPLTABLES_H_ + +/* Precalculated emu8950 tables for use in Rockbox, + Calculated for 44Khz sampling rate */ + +static const short ar_adjust_coeff[] = { + 255, 227, 210, 198, 189, 181, 175, 170, 165, 161, 157, + 153, 150, 147, 144, 141, 139, 136, 134, 132, 130, 128, + 126, 125, 123, 121, 120, 118, 117, 115, 114, 113, 112, + 110, 109, 108, 107, 106, 105, 104, 103, 102, 101, 100, + 99, 98, 97, 96, 95, 94, 94, 93, 92, 91, 91, + 90, 89, 88, 88, 87, 86, 86, 85, 84, 84, 83, + 82, 82, 81, 81, 80, 79, 79, 78, 78, 77, 77, + 76, 76, 75, 75, 74, 74, 73, 73, 72, 72, 71, + 71, 70, 70, 69, 69, 69, 68, 68, 67, 67, 66, + 66, 66, 65, 65, 64, 64, 64, 63, 63, 62, 62, + 62, 61, 61, 61, 60, 60, 60, 59, 59, 59, 58, + 58, 58, 57, 57, 57, 56, 56, 56, 55, 55, 55, + 54, 54, 54, 53, 53, 53, 53, 52, 52, 52, 51, + 51, 51, 50, 50, 50, 50, 49, 49, 49, 49, 48, + 48, 48, 48, 47, 47, 47, 46, 46, 46, 46, 45, + 45, 45, 45, 44, 44, 44, 44, 44, 43, 43, 43, + 43, 42, 42, 42, 42, 41, 41, 41, 41, 41, 40, + 40, 40, 40, 39, 39, 39, 39, 39, 38, 38, 38, + 38, 38, 37, 37, 37, 37, 37, 36, 36, 36, 36, + 36, 35, 35, 35, 35, 35, 34, 34, 34, 34, 34, + 33, 33, 33, 33, 33, 33, 32, 32, 32, 32, 32, + 31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, + 30, 29, 29, 29, 29, 29, 29, 28, 28, 28, 28, + 28, 28, 27, 27, 27, 27, 27, 27, 26, 26, 26, + 26, 26, 26, 26, 25, 25, 25, 25, 25, 25, 25, + 24, 24, 24, 24, 24, 24, 23, 23, 23, 23, 23, + 23, 23, 22, 22, 22, 22, 22, 22, 22, 21, 21, + 21, 21, 21, 21, 21, 21, 20, 20, 20, 20, 20, + 20, 20, 19, 19, 19, 19, 19, 19, 19, 19, 18, + 18, 18, 18, 18, 18, 18, 18, 17, 17, 17, 17, + 17, 17, 17, 17, 16, 16, 16, 16, 16, 16, 16, + 16, 15, 15, 15, 15, 15, 15, 15, 15, 14, 14, + 14, 14, 14, 14, 14, 14, 14, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 8, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0 +}; + +static const short db2lin_coeff[] = { + 2047, 2003, 1960, 1918, 1877, 1837, 1798, 1759, 1722, 1685, 1649, + 1614, 1579, 1546, 1513, 1480, 1449, 1418, 1387, 1358, 1329, 1300, + 1273, 1245, 1219, 1193, 1167, 1142, 1118, 1094, 1071, 1048, 1025, + 1004, 982, 961, 941, 920, 901, 882, 863, 844, 826, 809, + 791, 774, 758, 742, 726, 710, 695, 680, 666, 651, 638, + 624, 611, 598, 585, 572, 560, 548, 536, 525, 514, 503, + 492, 481, 471, 461, 451, 442, 432, 423, 414, 405, 396, + 388, 380, 371, 364, 356, 348, 341, 333, 326, 319, 312, + 306, 299, 293, 287, 280, 274, 269, 263, 257, 252, 246, + 241, 236, 231, 226, 221, 216, 212, 207, 203, 198, 194, + 190, 186, 182, 178, 174, 170, 167, 163, 160, 156, 153, + 150, 147, 143, 140, 137, 134, 131, 129, 126, 123, 121, + 118, 115, 113, 111, 108, 106, 104, 101, 99, 97, 95, + 93, 91, 89, 87, 85, 83, 82, 80, 78, 76, 75, + 73, 72, 70, 69, 67, 66, 64, 63, 61, 60, 59, + 58, 56, 55, 54, 53, 52, 51, 49, 48, 47, 46, + 45, 44, 43, 42, 42, 41, 40, 39, 38, 37, 36, + 36, 35, 34, 33, 33, 32, 31, 31, 30, 29, 29, + 28, 27, 27, 26, 26, 25, 25, 24, 23, 23, 22, + 22, 21, 21, 21, 20, 20, 19, 19, 18, 18, 18, + 17, 17, 16, 16, 16, 15, 15, 15, 14, 14, 14, + 13, 13, 13, 13, 12, 12, 12, 12, 11, 11, 11, + 11, 10, 10, 10, 10, 9, 9, 9, 9, 9, 8, + 8, 8, 8, 8, 7, 7, 7, 7, 7, 7, 7, + 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, + 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0 +}; + +static const short sin_coeff[] = { + 511, 235, 203, 185, 171, 161, 152, 145, 139, 134, 129, + 124, 120, 117, 113, 110, 107, 104, 102, 99, 97, 95, + 92, 90, 88, 87, 85, 83, 81, 80, 78, 77, 75, + 74, 72, 71, 70, 69, 67, 66, 65, 64, 63, 62, + 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 52, + 51, 50, 49, 48, 48, 47, 46, 45, 45, 44, 43, + 43, 42, 41, 41, 40, 39, 39, 38, 38, 37, 37, + 36, 35, 35, 34, 34, 33, 33, 32, 32, 31, 31, + 30, 30, 29, 29, 28, 28, 28, 27, 27, 26, 26, + 25, 25, 25, 24, 24, 23, 23, 23, 22, 22, 22, + 21, 21, 21, 20, 20, 20, 19, 19, 19, 18, 18, + 18, 17, 17, 17, 16, 16, 16, 16, 15, 15, 15, + 14, 14, 14, 14, 13, 13, 13, 13, 12, 12, 12, + 12, 11, 11, 11, 11, 11, 10, 10, 10, 10, 9, + 9, 9, 9, 9, 8, 8, 8, 8, 8, 7, 7, + 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 5, + 5, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, + 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, +}; + +static const short pm0_coeff[] = { + 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, + 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, + 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, + 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, + 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, + 256, 256, 257, 257, 257, 257, 257, 257, 257, 257, 257, + 257, 257, 257, 257, 257, 257, 256, 256, 256, 256, 256, + 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, + 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, + 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, + 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, + 256, 256, 256, 256, 256, 256, 256, 256, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 254, + 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, + 254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, +}; + +static const short pm1_coeff[] = { + 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, + 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 257, + 257, 257, 257, 257, 257, 257, 257, 257, 257, 257, 257, + 257, 257, 257, 257, 257, 257, 257, 257, 257, 257, 257, + 257, 257, 257, 257, 257, 257, 257, 257, 257, 257, 257, + 257, 258, 258, 258, 258, 258, 258, 258, 258, 258, 258, + 258, 258, 258, 258, 258, 258, 258, 257, 257, 257, 257, + 257, 257, 257, 257, 257, 257, 257, 257, 257, 257, 257, + 257, 257, 257, 257, 257, 257, 257, 257, 257, 257, 257, + 257, 257, 257, 257, 257, 257, 257, 257, 257, 256, 256, + 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, + 256, 256, 256, 256, 256, 256, 256, 256, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 254, 254, 254, 254, 254, + 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, + 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, + 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 253, + 253, 253, 253, 253, 253, 253, 253, 253, 253, 253, 253, + 253, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, + 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, + 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, + 254, 254, 254, 254, 254, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, +}; + +static const short am0_coeff[] = { + 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, +}; + +static const short am1_coeff[] = { + 12, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, + 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 19, + 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, + 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, + 24, 24, 24, 24, 24, 24, 24, 24, 25, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 24, 24, 24, 24, 24, 24, 24, 24, 23, 23, 23, + 23, 23, 23, 22, 22, 22, 22, 22, 21, 21, 21, + 21, 20, 20, 20, 20, 19, 19, 19, 19, 18, 18, + 18, 17, 17, 17, 17, 16, 16, 16, 15, 15, 15, + 14, 14, 14, 14, 13, 13, 13, 12, 12, 12, 11, + 11, 11, 10, 10, 10, 9, 9, 9, 9, 8, 8, + 8, 7, 7, 7, 7, 6, 6, 6, 5, 5, 5, + 5, 4, 4, 4, 4, 3, 3, 3, 3, 3, 2, + 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, + 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, + 5, 5, 5, 6, 6, 6, 7, 7, 7, 7, 8, + 8, 8, 9, 9, 9, 9, 10, 10, 10, 11, 11, + 11, 12, 12, +}; + +#endif diff --git a/lib/rbcodec/codecs/libgme/resampler.c b/lib/rbcodec/codecs/libgme/resampler.c new file mode 100644 index 0000000000..c4f42a9794 --- /dev/null +++ b/lib/rbcodec/codecs/libgme/resampler.c @@ -0,0 +1,218 @@ +// Game_Music_Emu 0.5.5. http://www.slack.net/~ant/ + +#include "resampler.h" + +#include +#include + +/* Copyright (C) 2003-2006 Shay Green. This module is free software; you +can redistribute it and/or modify it under the terms of the GNU Lesser +General Public License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. This +module is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +details. You should have received a copy of the GNU Lesser General Public +License along with this module; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ + +#include "blargg_source.h" + +// TODO: fix this. hack since resampler holds back some output. +unsigned const resampler_extra = 34; + +enum { shift = 14 }; +int const unit = 1 << shift; + +blargg_err_t Resampler_setup( struct Resampler* this, int fm_rate, int fm_gain, int rate, int gain ) +{ + this->gain_ = (int)( ((1LL << gain_bits) * fm_gain * gain) / FP_ONE_GAIN ); + this->step = (int)( ((1LL << shift) * fm_rate) / rate + 1); + this->rate_ = this->step; + return 0; +} + +blargg_err_t Resampler_reset( struct Resampler* this, int pairs ) +{ + // expand allocations a bit + this->sample_buffer_size = (pairs + (pairs >> 2)) * 2; + Resampler_resize( this, pairs ); + this->resampler_size = this->oversamples_per_frame + (this->oversamples_per_frame >> 2); + + this->buffer_size = this->resampler_size; + this->pos = 0; + this->write_pos = 0; + + Resampler_clear( this ); + return 0; +} + +void Resampler_resize( struct Resampler* this, int pairs ) +{ + int new_sample_buf_size = pairs * 2; + if ( this->sample_buf_size != new_sample_buf_size ) + { + if ( new_sample_buf_size > this->sample_buffer_size ) + { + check(false); + return; + } + + this->sample_buf_size = new_sample_buf_size; + this->oversamples_per_frame = (int) ((pairs * this->rate_ * 2LL) / unit) + 2; + Resampler_clear( this ); + } +} + +static void mix_samples( struct Resampler* this, struct Blip_Buffer* blip_buf, dsample_t out_ [] ) +{ + int const bass = BLIP_READER_BASS( *blip_buf ); + BLIP_READER_BEGIN( sn, *blip_buf ); + + int count = this->sample_buf_size >> 1; + BLIP_READER_ADJ_( sn, count ); + + typedef dsample_t stereo_dsample_t [2]; + stereo_dsample_t* BLARGG_RESTRICT out = (stereo_dsample_t*) out_ + count; + stereo_dsample_t const* BLARGG_RESTRICT in = + (stereo_dsample_t const*) this->sample_buf + count; + int offset = -count; + int const gain = this->gain_; + do + { + int s = BLIP_READER_READ_RAW( sn ) >> (blip_sample_bits - 16); + BLIP_READER_NEXT_IDX_( sn, bass, offset ); + + int l = (in [offset] [0] * gain >> gain_bits) + s; + int r = (in [offset] [1] * gain >> gain_bits) + s; + + BLIP_CLAMP( l, l ); + out [offset] [0] = (blip_sample_t) l; + + BLIP_CLAMP( r, r ); + out [offset] [1] = (blip_sample_t) r; + } + while ( ++offset ); + + BLIP_READER_END( sn, *blip_buf ); +} + +static dsample_t const* resample_( struct Resampler* this, dsample_t** out_, + dsample_t const* out_end, dsample_t const in [], int in_size ) +{ + in_size -= write_offset; + if ( in_size > 0 ) + { + dsample_t* BLARGG_RESTRICT out = *out_; + dsample_t const* const in_end = in + in_size; + + int const step = this->step; + int pos = this->pos; + + // TODO: IIR filter, then linear resample + // TODO: detect skipped sample, allowing merging of IIR and resample? + + do + { + #define INTERP( i, out )\ + out = (in [0 + i] * (unit - pos) + ((in [2 + i] + in [4 + i] + in [6 + i]) << shift) +\ + in [8 + i] * pos) >> (shift + 2); + + int out_0; + INTERP( 0, out_0 ) + INTERP( 1, out [0] = out_0; out [1] ) + out += stereo; + + pos += step; + in += ((unsigned) pos >> shift) * stereo; + pos &= unit - 1; + } + while ( in < in_end && out < out_end ); + + this->pos = pos; + *out_ = out; + } + return in; +} + +static inline int resample_wrapper( struct Resampler* this, dsample_t out [], int* out_size, + dsample_t const in [], int in_size ) +{ + assert( Resampler_rate( this ) ); + + dsample_t* out_ = out; + int result = resample_( this, &out_, out + *out_size, in, in_size ) - in; + assert( out_ <= out + *out_size ); + assert( result <= in_size ); + + *out_size = out_ - out; + return result; +} + +static int skip_input( struct Resampler* this, int count ) +{ + this->write_pos -= count; + if ( this->write_pos < 0 ) // occurs when downsampling + { + count += this->write_pos; + this->write_pos = 0; + } + memmove( this->buf, &this->buf [count], this->write_pos * sizeof this->buf [0] ); + return count; +} + +static void play_frame_( struct Resampler* this, struct Blip_Buffer* blip_buf, dsample_t* out ) +{ + int pair_count = this->sample_buf_size >> 1; + blip_time_t blip_time = Blip_count_clocks( blip_buf, pair_count ); + int sample_count = this->oversamples_per_frame - this->write_pos + resampler_extra; + + int new_count = this->callback( this->callback_data, blip_time, sample_count, &this->buf [this->write_pos] ); + assert( new_count < this->resampler_size ); + + Blip_end_frame( blip_buf, blip_time ); + assert( Blip_samples_avail( blip_buf ) == pair_count ); + + this->write_pos += new_count; + assert( (unsigned) this->write_pos <= this->buffer_size ); + + int count = this->sample_buf_size; + if ( count ) + skip_input( this, resample_wrapper( this, this->sample_buf, &count, this->buf, this->write_pos ) ); + assert( count == this->sample_buf_size ); + + mix_samples( this, blip_buf, out ); + Blip_remove_samples( blip_buf, pair_count ); +} + +void Resampler_play( struct Resampler* this, int count, dsample_t* out, struct Blip_Buffer* blip_buf ) +{ + // empty extra buffer + int remain = this->sample_buf_size - this->buf_pos; + if ( remain ) + { + if ( remain > count ) + remain = count; + count -= remain; + memcpy( out, &this->sample_buf [this->buf_pos], remain * sizeof *out ); + out += remain; + this->buf_pos += remain; + } + + // entire frames + while ( count >= this->sample_buf_size ) + { + play_frame_( this, blip_buf, out ); + out += this->sample_buf_size; + count -= this->sample_buf_size; + } + + // extra + if ( count ) + { + play_frame_( this, blip_buf, this->sample_buf ); + this->buf_pos = count; + memcpy( out, this->sample_buf, count * sizeof *out ); + out += count; + } +} diff --git a/lib/rbcodec/codecs/libgme/resampler.h b/lib/rbcodec/codecs/libgme/resampler.h new file mode 100644 index 0000000000..3f3710a54a --- /dev/null +++ b/lib/rbcodec/codecs/libgme/resampler.h @@ -0,0 +1,75 @@ +// Combination of Downsampler and Blip_Buffer mixing. Used by Sega FM emulators. + +// Game_Music_Emu 0.5.5 +#ifndef RESAMPLER_H +#define RESAMPLER_H + +#include "blargg_common.h" +#include "multi_buffer.h" + +typedef short dsample_t; + +enum { max_buf_size = 3960 }; +enum { max_resampler_size = 5942 }; +enum { write_offset = 8 * stereo }; +enum { gain_bits = 14 }; + +struct Resampler { + int (*callback)( void*, blip_time_t, int, dsample_t* ); + void* callback_data; + + int sample_buffer_size; + int sample_buf_size; + int oversamples_per_frame; + int buf_pos; + int resampler_size; + int gain_; + + int buffer_size; + int write_pos; + + int pos; + int step; + + int rate_; + + dsample_t sample_buf [max_buf_size]; + dsample_t buf [max_resampler_size]; // Internal resampler +}; + +static inline void Resampler_init( struct Resampler* this ) +{ + this->pos = 0; + this->write_pos = 0; + this->rate_ = 0; + this->sample_buf_size = 0; + this->sample_buffer_size = 0; + this->oversamples_per_frame = 0; +} + +blargg_err_t Resampler_reset( struct Resampler* this, int max_pairs ); +void Resampler_resize( struct Resampler* this, int pairs_per_frame ); +void Resampler_play( struct Resampler* this, int count, dsample_t* out, struct Blip_Buffer* ); + +static inline void Resampler_set_callback(struct Resampler* this, int (*func)( void*, blip_time_t, int, dsample_t* ), void* user_data ) +{ + this->callback = func; + this->callback_data = user_data; +} + +blargg_err_t Resampler_setup( struct Resampler* this, int fm_rate, int fm_gain, int rate, int gain ); + +static inline void Resampler_clear( struct Resampler* this ) +{ + this->buf_pos = this->sample_buf_size; + + this->pos = 0; + this->write_pos = 0; +} + +static inline int Resampler_rate( struct Resampler* this ) +{ + return this->rate_; +} + +#endif diff --git a/lib/rbcodec/codecs/libgme/rom_data.c b/lib/rbcodec/codecs/libgme/rom_data.c new file mode 100644 index 0000000000..9c36a99d2d --- /dev/null +++ b/lib/rbcodec/codecs/libgme/rom_data.c @@ -0,0 +1,68 @@ +// Game_Music_Emu 0.5.2. http://www.slack.net/~ant/ + +#include "rom_data.h" + +/* Copyright (C) 2003-2006 Shay Green. This module is free software; you +can redistribute it and/or modify it under the terms of the GNU Lesser +General Public License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. This +module is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +details. You should have received a copy of the GNU Lesser General Public +License along with this module; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ + +#include +#include "blargg_source.h" + +// Rom_Data + +blargg_err_t Rom_load( struct Rom_Data* this, const void* data, long size, + int header_size, void* header_out, int fill ) +{ + int file_offset = this->pad_size; + + this->rom_addr = 0; + this->mask = 0; + this->size = 0; + + if ( size <= header_size ) // <= because there must be data after header + return gme_wrong_file_type; + + // Read header + memcpy( header_out, data, header_size ); + + this->file_size = size - header_size; + this->file_data = (byte*) data + header_size; + + memset( this->unmapped, fill, this->rom_size ); + memcpy( &this->unmapped [file_offset], this->file_data, + this->file_size < this->pad_size ? this->file_size : this->pad_size ); + + return 0; +} + +void Rom_set_addr( struct Rom_Data* this, int addr ) +{ + this->rom_addr = addr - this->bank_size - pad_extra; + + int rounded = (addr + this->file_size + this->bank_size - 1) / this->bank_size * this->bank_size; + if ( rounded <= 0 ) + { + rounded = 0; + } + else + { + int shift = 0; + unsigned int max_addr = (unsigned int) (rounded - 1); + while ( max_addr >> shift ) + shift++; + this->mask = (1L << shift) - 1; + } + + if ( addr < 0 ) + addr = 0; + this->size = rounded; + this->rsize_ = rounded - this->rom_addr + pad_extra; +} diff --git a/lib/rbcodec/codecs/libgme/rom_data.h b/lib/rbcodec/codecs/libgme/rom_data.h new file mode 100644 index 0000000000..b8bc54cd3f --- /dev/null +++ b/lib/rbcodec/codecs/libgme/rom_data.h @@ -0,0 +1,83 @@ +// Common aspects of emulators which use rom data + +// Game_Music_Emu 0.5.2 +#ifndef ROM_DATA_H +#define ROM_DATA_H + +#include "blargg_common.h" +#include "blargg_source.h" + +// ROM data handler, used by several Classic_Emu derivitives. Loads file data +// with padding on both sides, allowing direct use in bank mapping. The main purpose +// is to allow all file data to be loaded with only one read() call (for efficiency). + +extern const char gme_wrong_file_type []; // declared in gme.h + +enum { pad_extra = 8 }; +enum { max_bank_size = 0x4000 }; +enum { max_pad_size = max_bank_size + pad_extra }; +enum { max_rom_size = 2 * max_pad_size }; + +struct Rom_Data { + byte* file_data; + unsigned file_size; + + int rom_addr; + int bank_size; + int rom_size; + unsigned pad_size; + int mask; + int size; // TODO: eliminate + int rsize_; + + // Unmapped space + byte unmapped [max_rom_size]; +}; + +// Initialize rom +static inline void Rom_init( struct Rom_Data* this, int bank_size ) +{ + this->bank_size = bank_size; + this->pad_size = this->bank_size + pad_extra; + this->rom_size = 2 * this->pad_size; +} + +// Load file data, using already-loaded header 'h' if not NULL. Copy header +// from loaded file data into *out and fill unmapped bytes with 'fill'. +blargg_err_t Rom_load( struct Rom_Data* this, const void* data, long size, int header_size, void* header_out, int fill ); + +// Set address that file data should start at +void Rom_set_addr( struct Rom_Data* this, int addr ); + +// Mask address to nearest power of two greater than size() +static inline int mask_addr( int addr, int mask ) +{ + #ifdef check + check( addr <= mask ); + #endif + return addr & mask; +} + +// Pointer to page starting at addr. Returns unmapped() if outside data. +static inline byte* Rom_at_addr( struct Rom_Data* this, int addr ) +{ + unsigned offset = mask_addr( addr, this->mask ) - this->rom_addr; + if ( offset > (unsigned) (this->rsize_ - this->pad_size) ) + offset = 0; // unmapped + + if ( offset < this->pad_size ) return &this->unmapped [offset]; + else return &this->file_data [offset - this->pad_size]; +} + + +#ifndef GME_APU_HOOK + #define GME_APU_HOOK( emu, addr, data ) ((void) 0) +#endif + +#ifndef GME_FRAME_HOOK + #define GME_FRAME_HOOK( emu ) ((void) 0) +#else + #define GME_FRAME_HOOK_DEFINED 1 +#endif + +#endif diff --git a/lib/rbcodec/codecs/libgme/sgc_cpu.c b/lib/rbcodec/codecs/libgme/sgc_cpu.c new file mode 100644 index 0000000000..d23c01499b --- /dev/null +++ b/lib/rbcodec/codecs/libgme/sgc_cpu.c @@ -0,0 +1,36 @@ +// Game_Music_Emu 0.6-pre. http://www.slack.net/~ant/ + +#include "sgc_emu.h" + +#include "blargg_endian.h" +//#include "z80_cpu_log.h" + +/* Copyright (C) 2009 Shay Green. This module is free software; you +can redistribute it and/or modify it under the terms of the GNU Lesser +General Public License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. This +module is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +details. You should have received a copy of the GNU Lesser General Public +License along with this module; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ + +#include "blargg_source.h" + +#define OUT_PORT( addr, data ) cpu_out( this, TIME(), addr, data ) +#define IN_PORT( addr ) 0 // cpu in +#define WRITE_MEM( addr, data ) cpu_write( this, addr, data ) +#define IDLE_ADDR this->idle_addr +#define RST_BASE this->vectors_addr + +#define CPU_BEGIN \ +bool run_cpu( struct Sgc_Emu* this, cpu_time_t end_time )\ +{\ + Sgc_Cpu* cpu = &this->cpu; \ + Z80_set_end_time( cpu, end_time ); + + #include "z80_cpu_run.h" + + return warning; +} diff --git a/lib/rbcodec/codecs/libgme/sgc_emu.c b/lib/rbcodec/codecs/libgme/sgc_emu.c new file mode 100644 index 0000000000..267f2c9271 --- /dev/null +++ b/lib/rbcodec/codecs/libgme/sgc_emu.c @@ -0,0 +1,480 @@ +// Game_Music_Emu 0.6-pre. http://www.slack.net/~ant/ + +#include "sgc_emu.h" + +/* Copyright (C) 2009 Shay Green. This module is free software; you +can redistribute it and/or modify it under the terms of the GNU Lesser +General Public License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. This +module is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +details. You should have received a copy of the GNU Lesser General Public +License aint with this module; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ + +#include "blargg_source.h" + +int const osc_count = sms_osc_count + fm_apu_osc_count; + +const char gme_wrong_file_type [] = "Wrong file type for this emulator"; + +static void clear_track_vars( struct Sgc_Emu* this ) +{ + this->current_track = -1; + track_stop( &this->track_filter ); +} + +void Sgc_init( struct Sgc_Emu* this ) +{ + assert( offsetof (struct header_t,copyright [32]) == header_size ); + + this->sample_rate = 0; + this->mute_mask_ = 0; + this->tempo = (int)FP_ONE_TEMPO; + this->gain = (int)FP_ONE_GAIN; + + // defaults + this->tfilter = *track_get_setup( &this->track_filter ); + this->tfilter.max_initial = 2; + this->tfilter.lookahead = 6; + this->track_filter.silence_ignored_ = false; + + Sms_apu_init( &this->apu ); + Fm_apu_create( &this->fm_apu ); + + Rom_init( &this->rom, 0x4000 ); + Z80_init( &this->cpu ); + + Sound_set_gain( this, (int)(FP_ONE_GAIN*1.2) ); + + // Unload + this->voice_count = 0; + this->voice_types = 0; + clear_track_vars( this ); +} + +// Setup + +blargg_err_t Sgc_load_mem( struct Sgc_Emu* this, const void* data, long size ) +{ + RETURN_ERR( Rom_load( &this->rom, data, size, header_size, &this->header, 0 ) ); + + if ( !valid_tag( &this->header ) ) + return gme_wrong_file_type; + + /* if ( header.vers != 1 ) + warning( "Unknown file version" ); */ + + /* if ( header.system > 2 ) + warning( "Unknown system" ); */ + + addr_t load_addr = get_le16( this->header.load_addr ); + /* if ( load_addr < 0x400 ) + set_warning( "Invalid load address" ); */ + + Rom_set_addr( &this->rom, load_addr ); + this->play_period = clock_rate( this ) / 60; + + if ( sega_mapping( this ) && Fm_apu_supported() ) + RETURN_ERR( Fm_apu_init( &this->fm_apu, clock_rate( this ), clock_rate( this ) / 72 ) ); + + this->m3u.size = 0; + this->track_count = this->header.song_count; + this->voice_count = sega_mapping( this ) ? osc_count : sms_osc_count; + static int const types [sms_osc_count + fm_apu_osc_count] = { + wave_type+1, wave_type+2, wave_type+3, mixed_type+1, mixed_type+2 + }; + this->voice_types = types; + + Sms_apu_volume( &this->apu, this->gain ); + Fm_apu_volume( &this->fm_apu, this->gain ); + + // Setup buffer + this->clock_rate_ = clock_rate( this ); + Buffer_clock_rate( &this->stereo_buf, clock_rate( this ) ); + RETURN_ERR( Buffer_set_channel_count( &this->stereo_buf, this->voice_count, this->voice_types ) ); + this->buf_changed_count = Buffer_channels_changed_count( &this->stereo_buf ); + + Sound_set_tempo( this, this->tempo ); + Sound_mute_voices( this, this->mute_mask_ ); + return 0; +} + +static void Sound_set_voice( struct Sgc_Emu* this, int i, struct Blip_Buffer* c, struct Blip_Buffer* l, struct Blip_Buffer* r ) +{ + if ( i < sms_osc_count ) + Sms_apu_set_output( &this->apu, i, c, l, r ); + else + Fm_apu_set_output( &this->fm_apu, c ); +} + +static blargg_err_t run_clocks( struct Sgc_Emu* this, blip_time_t* duration, int msec ) +{ +#if defined(ROCKBOX) + (void) msec; +#endif + + cpu_time_t t = *duration; + while ( Z80_time( &this->cpu ) < t ) + { + cpu_time_t next = min( t, this->next_play ); + if ( run_cpu( this, next ) ) + { + /* warning( "Unsupported CPU instruction" ); */ + Z80_set_time( &this->cpu, next ); + } + + if ( this->cpu.r.pc == this->idle_addr ) + Z80_set_time( &this->cpu, next ); + + if ( Z80_time( &this->cpu ) >= this->next_play ) + { + this->next_play += this->play_period; + if ( this->cpu.r.pc == this->idle_addr ) + jsr( this, this->header.play_addr ); + } + } + + this->next_play -= t; + check( this->next_play >= 0 ); + Z80_adjust_time( &this->cpu, -t ); + + Sms_apu_end_frame( &this->apu, t ); + if ( sega_mapping( this ) && this->fm_accessed ) + { + if ( Fm_apu_supported() ) + Fm_apu_end_frame( &this->fm_apu, t ); + /* else + warning( "FM sound not supported" ); */ + } + + return 0; +} + +// Emulation + +void cpu_out( struct Sgc_Emu* this, cpu_time_t time, addr_t addr, int data ) +{ + int port = addr & 0xFF; + + if ( sega_mapping( this ) ) + { + switch ( port ) + { + case 0x06: + Sms_apu_write_ggstereo( &this->apu, time, data ); + return; + + case 0x7E: + case 0x7F: + Sms_apu_write_data( &this->apu, time, data ); /* dprintf( "$7E<-%02X\n", data ); */ + return; + + case 0xF0: + this->fm_accessed = true; + if ( Fm_apu_supported() ) + Fm_apu_write_addr( &this->fm_apu, data );//, dprintf( "$F0<-%02X\n", data ); + return; + + case 0xF1: + this->fm_accessed = true; + if ( Fm_apu_supported() ) + Fm_apu_write_data( &this->fm_apu, time, data );//, dprintf( "$F1<-%02X\n", data ); + return; + } + } + else if ( port >= 0xE0 ) + { + Sms_apu_write_data( &this->apu, time, data ); + return; + } +} + +void jsr( struct Sgc_Emu* this, byte addr [2] ) +{ + *Z80_write( &this->cpu, --this->cpu.r.sp ) = this->idle_addr >> 8; + *Z80_write( &this->cpu, --this->cpu.r.sp ) = this->idle_addr & 0xFF; + this->cpu.r.pc = get_le16( addr ); +} + +static void set_bank( struct Sgc_Emu* this, int bank, void const* data ) +{ + //dprintf( "map bank %d to %p\n", bank, (byte*) data - rom.at_addr( 0 ) ); + Z80_map_mem( &this->cpu, bank * this->rom.bank_size, this->rom.bank_size, this->unmapped_write, data ); +} + +void cpu_write( struct Sgc_Emu* this, addr_t addr, int data ) +{ + if ( (addr ^ 0xFFFC) > 3 || !sega_mapping( this ) ) + { + *Z80_write( &this->cpu, addr ) = data; + return; + } + + switch ( addr ) + { + case 0xFFFC: + Z80_map_mem_rw( &this->cpu, 2 * this->rom.bank_size, this->rom.bank_size, this->ram2 ); + if ( data & 0x08 ) + break; + + this->bank2 = this->ram2; + // FALL THROUGH + + case 0xFFFF: { + bool rom_mapped = (Z80_read( &this->cpu, 2 * this->rom.bank_size ) == this->bank2); + this->bank2 = Rom_at_addr( &this->rom, data * this->rom.bank_size ); + if ( rom_mapped ) + set_bank( this, 2, this->bank2 ); + break; + } + + case 0xFFFD: + set_bank( this, 0, Rom_at_addr( &this->rom, data * this->rom.bank_size ) ); + break; + + case 0xFFFE: + set_bank( this, 1, Rom_at_addr( &this->rom, data * this->rom.bank_size ) ); + break; + } +} + +blargg_err_t Sgc_set_sample_rate( struct Sgc_Emu* this, int rate ) +{ + require( !this->sample_rate ); // sample rate can't be changed once set + Buffer_init( &this->stereo_buf ); + Buffer_set_sample_rate( &this->stereo_buf, rate, 1000 / 20 ); + + // Set buffer bass + Buffer_bass_freq( &this->stereo_buf, 80 ); + + this->sample_rate = rate; + RETURN_ERR( track_init( &this->track_filter, this ) ); + this->tfilter.max_silence = 6 * stereo * this->sample_rate; + return 0; +} + +void Sound_mute_voice( struct Sgc_Emu* this, int index, bool mute ) +{ + require( (unsigned) index < (unsigned) this->voice_count ); + int bit = 1 << index; + int mask = this->mute_mask_ | bit; + if ( !mute ) + mask ^= bit; + Sound_mute_voices( this, mask ); +} + +void Sound_mute_voices( struct Sgc_Emu* this, int mask ) +{ + require( this->sample_rate ); // sample rate must be set first + this->mute_mask_ = mask; + + int i; + for ( i = this->voice_count; i--; ) + { + if ( mask & (1 << i) ) + { + Sound_set_voice( this, i, 0, 0, 0 ); + } + else + { + struct channel_t ch = Buffer_channel( &this->stereo_buf, i ); + assert( (ch.center && ch.left && ch.right) || + (!ch.center && !ch.left && !ch.right) ); // all or nothing + Sound_set_voice( this, i, ch.center, ch.left, ch.right ); + } + } +} + +void Sound_set_tempo( struct Sgc_Emu* this, int t ) +{ + require( this->sample_rate ); // sample rate must be set first + int const min = (int)(FP_ONE_TEMPO*0.02); + int const max = (int)(FP_ONE_TEMPO*4.00); + if ( t < min ) t = min; + if ( t > max ) t = max; + this->tempo = t; + + this->play_period = (int) ((clock_rate( this ) * FP_ONE_TEMPO) / (this->header.rate ? 50 : 60) / t); +} + +blargg_err_t Sgc_start_track( struct Sgc_Emu* this, int track ) +{ + clear_track_vars( this ); + + // Remap track if playlist available + if ( this->m3u.size > 0 ) { + struct entry_t* e = &this->m3u.entries[track]; + track = e->track; + } + + this->current_track = track; + + if ( sega_mapping( this ) ) + { + Sms_apu_reset( &this->apu, 0, 0 ); + Fm_apu_reset( &this->fm_apu ); + this->fm_accessed = false; + } + else + { + Sms_apu_reset( &this->apu, 0x0003, 15 ); + } + + memset( this->ram , 0, sizeof this->ram ); + memset( this->ram2, 0, sizeof this->ram2 ); + memset( this->vectors, 0xFF, sizeof this->vectors ); + Z80_reset( &this->cpu, this->unmapped_write, this->rom.unmapped ); + + if ( sega_mapping( this ) ) + { + this->vectors_addr = 0x10000 - page_size; + this->idle_addr = this->vectors_addr; + int i; + for ( i = 1; i < 8; ++i ) + { + this->vectors [i*8 + 0] = 0xC3; // JP addr + this->vectors [i*8 + 1] = this->header.rst_addrs [i - 1] & 0xff; + this->vectors [i*8 + 2] = this->header.rst_addrs [i - 1] >> 8; + } + + Z80_map_mem_rw( &this->cpu, 0xC000, 0x2000, this->ram ); + Z80_map_mem( &this->cpu, this->vectors_addr, page_size, this->unmapped_write, this->vectors ); + + this->bank2 = NULL; + for ( i = 0; i < 4; ++i ) + cpu_write( this, 0xFFFC + i, this->header.mapping [i] ); + } + else + { + if ( !this->coleco_bios ) + return "Coleco BIOS not set"; /* BLARGG_ERR( BLARGG_ERR_CALLER, "Coleco BIOS not set" ); */ + + this->vectors_addr = 0; + Z80_map_mem( &this->cpu, 0, 0x2000, this->unmapped_write, this->coleco_bios ); + int i; + for ( i = 0; i < 8; ++i ) + Z80_map_mem_rw( &this->cpu, 0x6000 + i*0x400, 0x400, this->ram ); + + this->idle_addr = 0x2000; + Z80_map_mem( &this->cpu, 0x2000, page_size, this->unmapped_write, this->vectors ); + + for ( i = 0; i < 0x8000 / this->rom.bank_size; ++i ) + { + int addr = 0x8000 + i*this->rom.bank_size; + Z80_map_mem( &this->cpu, addr, this->rom.bank_size, this->unmapped_write, Rom_at_addr( &this->rom, addr ) ); + } + } + + this->cpu.r.sp = get_le16( this->header.stack_ptr ); + this->cpu.r.b.a = track; + this->next_play = this->play_period; + + jsr( this, this->header.init_addr ); + + Buffer_clear( &this->stereo_buf ); + + // convert filter times to samples + struct setup_t s = this->tfilter; + s.max_initial *= this->sample_rate * stereo; + #ifdef GME_DISABLE_SILENCE_LOOKAHEAD + s.lookahead = 1; + #endif + track_setup( &this->track_filter, &s ); + + return track_start( &this->track_filter ); +} + +// Tell/Seek + +static int msec_to_samples( int msec, int sample_rate ) +{ + int sec = msec / 1000; + msec -= sec * 1000; + return (sec * sample_rate + msec * sample_rate / 1000) * stereo; +} + +int Track_tell( struct Sgc_Emu* this ) +{ + int rate = this->sample_rate * stereo; + int sec = track_sample_count( &this->track_filter ) / rate; + return sec * 1000 + (track_sample_count( &this->track_filter ) - sec * rate) * 1000 / rate; +} + +blargg_err_t Track_seek( struct Sgc_Emu* this, int msec ) +{ + int time = msec_to_samples( msec, this->sample_rate ); + if ( time < track_sample_count( &this->track_filter ) ) + RETURN_ERR( Sgc_start_track( this, this->current_track ) ); + return Track_skip( this, time - track_sample_count( &this->track_filter ) ); +} + +blargg_err_t Track_skip( struct Sgc_Emu* this, int count ) +{ + require( this->current_track >= 0 ); // start_track() must have been called already + return track_skip( &this->track_filter, count ); +} + +blargg_err_t skip_( void* emu, int count ) +{ + struct Sgc_Emu* this = (struct Sgc_Emu*) emu; + + // for long skip, mute sound + const int threshold = 32768; + if ( count > threshold ) + { + int saved_mute = this->mute_mask_; + Sound_mute_voices( this, ~0 ); + + int n = count - threshold/2; + n &= ~(2048-1); // round to multiple of 2048 + count -= n; + RETURN_ERR( skippy_( &this->track_filter, n ) ); + + Sound_mute_voices( this, saved_mute ); + } + + return skippy_( &this->track_filter, count ); +} + +void Track_set_fade( struct Sgc_Emu* this, int start_msec, int length_msec ) +{ + track_set_fade( &this->track_filter, msec_to_samples( start_msec, this->sample_rate ), + length_msec * this->sample_rate / (1000 / stereo) ); +} + +blargg_err_t Sgc_play( struct Sgc_Emu* this, int out_count, sample_t* out ) +{ + require( this->current_track >= 0 ); + require( out_count % stereo == 0 ); + return track_play( &this->track_filter, out_count, out ); +} + +blargg_err_t play_( void* emu, int count, sample_t out [] ) +{ + struct Sgc_Emu* this = (struct Sgc_Emu*) emu; + + int remain = count; + while ( remain ) + { + Buffer_disable_immediate_removal( &this->stereo_buf ); + remain -= Buffer_read_samples( &this->stereo_buf, &out [count - remain], remain ); + if ( remain ) + { + if ( this->buf_changed_count != Buffer_channels_changed_count( &this->stereo_buf ) ) + { + this->buf_changed_count = Buffer_channels_changed_count( &this->stereo_buf ); + + // Remute voices + Sound_mute_voices( this, this->mute_mask_ ); + } + int msec = Buffer_length( &this->stereo_buf ); + blip_time_t clocks_emulated = msec * this->clock_rate_ / 1000 - 100; + RETURN_ERR( run_clocks( this, &clocks_emulated, msec ) ); + assert( clocks_emulated ); + Buffer_end_frame( &this->stereo_buf, clocks_emulated ); + } + } + return 0; +} diff --git a/lib/rbcodec/codecs/libgme/sgc_emu.h b/lib/rbcodec/codecs/libgme/sgc_emu.h new file mode 100644 index 0000000000..83cde1e6ae --- /dev/null +++ b/lib/rbcodec/codecs/libgme/sgc_emu.h @@ -0,0 +1,195 @@ +// Sega/Game Gear/Coleco SGC music file emulator + +// Game_Music_Emu 0.6-pre +#ifndef SGC_EMU_H +#define SGC_EMU_H + +#include "blargg_common.h" +#include "multi_buffer.h" + +#include "rom_data.h" +#include "z80_cpu.h" +#include "sms_fm_apu.h" +#include "sms_apu.h" +#include "m3u_playlist.h" +#include "track_filter.h" + +typedef struct Z80_Cpu Sgc_Cpu; + +// SGC file header +enum { header_size = 0xA0 }; +struct header_t +{ + char tag [4]; // "SGC\x1A" + byte vers; // 0x01 + byte rate; // 0=NTSC 1=PAL + byte reserved1 [2]; + byte load_addr [2]; + byte init_addr [2]; + byte play_addr [2]; + byte stack_ptr [2]; + byte reserved2 [2]; + byte rst_addrs [7*2]; + byte mapping [4]; // Used by Sega only + byte first_song; // Song to start playing first + byte song_count; + byte first_effect; + byte last_effect; + byte system; // 0=Master System 1=Game Gear 2=Colecovision + byte reserved3 [23]; + char game [32]; // strings can be 32 chars, NOT terminated + char author [32]; + char copyright [32]; +}; + +// True if header has valid file signature +static inline bool valid_tag( struct header_t* h ) +{ + return 0 == memcmp( h->tag, "SGC\x1A", 4 ); +} + +static inline int effect_count( struct header_t* h ) { return h->last_effect ? h->last_effect - h->first_effect + 1 : 0; } + +struct Sgc_Emu { + bool fm_accessed; + + cpu_time_t play_period; + cpu_time_t next_play; + void const* bank2; // ROM selected for bank 2, in case RAM is currently hiding it + addr_t vectors_addr; // RST vectors start here + addr_t idle_addr; // return address for init/play routines + void* coleco_bios; + + // general + int voice_count; + int const* voice_types; + int mute_mask_; + int tempo; + int gain; + + int sample_rate; + + // track-specific + int current_track; + int track_count; + + int clock_rate_; + unsigned buf_changed_count; + + // M3u Playlist + struct M3u_Playlist m3u; + struct header_t header; + + struct setup_t tfilter; + struct Track_Filter track_filter; + + struct Multi_Buffer stereo_buf; + + struct Sms_Apu apu; + struct Sms_Fm_Apu fm_apu; + + Sgc_Cpu cpu; + + // large items + struct Rom_Data rom; + byte vectors [page_size + page_padding]; + byte unmapped_write [0x4000]; + byte ram [0x2000 + page_padding]; + byte ram2 [0x4000 + page_padding]; +}; + +// Basic functionality (see Gme_File.h for file loading/track info functions) + +void Sgc_init( struct Sgc_Emu* this ); + +blargg_err_t Sgc_load_mem( struct Sgc_Emu* this, const void* data, long size ); + +static inline int clock_rate( struct Sgc_Emu* this ) { return this->header.rate ? 3546893 : 3579545; } + +// 0x2000 bytes +static inline void set_coleco_bios( struct Sgc_Emu* this, void* p ) { this->coleco_bios = p; } + +// Set output sample rate. Must be called only once before loading file. +blargg_err_t Sgc_set_sample_rate( struct Sgc_Emu* this, int sample_rate ); + +// Start a track, where 0 is the first track. Also clears warning string. +blargg_err_t Sgc_start_track( struct Sgc_Emu* this, int track ); + +// Generate 'count' samples info 'buf'. Output is in stereo. Any emulation +// errors set warning string, and major errors also end track. +blargg_err_t Sgc_play( struct Sgc_Emu* this, int count, sample_t* buf ); + +// Track status/control + +// Number of milliseconds (1000 msec = 1 second) played since beginning of track +int Track_tell( struct Sgc_Emu* this ); + +// Seek to new time in track. Seeking backwards or far forward can take a while. +blargg_err_t Track_seek( struct Sgc_Emu* this, int msec ); + +// Skip n samples +blargg_err_t Track_skip( struct Sgc_Emu* this, int n ); + +// Set start time and length of track fade out. Once fade ends track_ended() returns +// true. Fade time can be changed while track is playing. +void Track_set_fade( struct Sgc_Emu* this, int start_msec, int length_msec ); + +// True if a track has reached its end +static inline bool Track_ended( struct Sgc_Emu* this ) +{ + return track_ended( &this->track_filter ); +} + +// Disables automatic end-of-track detection and skipping of silence at beginning +static inline void Track_ignore_silence( struct Sgc_Emu* this, bool disable ) +{ + this->track_filter.silence_ignored_ = disable; +} + +// Get track length in milliseconds +static inline int Track_get_length( struct Sgc_Emu* this, int n ) +{ + int length = 120 * 1000; /* 2 minutes */ + if ( (this->m3u.size > 0) && (n < this->m3u.size) ) { + struct entry_t* entry = &this->m3u.entries [n]; + length = entry->length; + } + + return length; +} + +// Sound customization + +// Adjust song tempo, where 1.0 = normal, 0.5 = half speed, 2.0 = double speed. +// Track length as returned by track_info() assumes a tempo of 1.0. +void Sound_set_tempo( struct Sgc_Emu* this, int t ); + +// Mute/unmute voice i, where voice 0 is first voice +void Sound_mute_voice( struct Sgc_Emu* this, int index, bool mute ); + +// Set muting state of all voices at once using a bit mask, where -1 mutes them all, +// 0 unmutes them all, 0x01 mutes just the first voice, etc. +void Sound_mute_voices( struct Sgc_Emu* this, int mask ); + +// Change overall output amplitude, where 1.0 results in minimal clamping. +// Must be called before set_sample_rate(). +static inline void Sound_set_gain( struct Sgc_Emu* this, int g ) +{ + assert( !this->sample_rate ); // you must set gain before setting sample rate + this->gain = g; +} + +// True if Master System or Game Gear +static inline bool sega_mapping( struct Sgc_Emu* this ) +{ + return this->header.system <= 1; +} + +// Emulation (You shouldn't touch these) + +bool run_cpu( struct Sgc_Emu* this, cpu_time_t end_time ); +void cpu_out( struct Sgc_Emu* this, cpu_time_t time, addr_t addr, int data ); +void cpu_write( struct Sgc_Emu* this, addr_t addr, int data ); +void jsr( struct Sgc_Emu* this, byte addr [2] ); + +#endif diff --git a/lib/rbcodec/codecs/libgme/sms_apu.c b/lib/rbcodec/codecs/libgme/sms_apu.c new file mode 100644 index 0000000000..379fcf1cbf --- /dev/null +++ b/lib/rbcodec/codecs/libgme/sms_apu.c @@ -0,0 +1,306 @@ +// Sms_Snd_Emu 0.1.1. http://www.slack.net/~ant/ + +#include "sms_apu.h" + +/* Copyright (C) 2003-2008 Shay Green. This module is free software; you +can redistribute it and/or modify it under the terms of the GNU Lesser +General Public License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. This +module is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +details. You should have received a copy of the GNU Lesser General Public +License along with this module; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ + +#include "blargg_source.h" + +int const noise_osc = 3; + +void Sms_apu_volume( struct Sms_Apu* this, int vol ) +{ + vol = (vol - (vol*3)/20) / sms_osc_count / 64; + Synth_volume( &this->synth, vol ); +} + +static inline int calc_output( struct Sms_Apu* this, int i ) +{ + int flags = this->ggstereo >> i; + return (flags >> 3 & 2) | (flags & 1); +} + +void Sms_apu_set_output( struct Sms_Apu* this, int i, struct Blip_Buffer* center, struct Blip_Buffer* left, struct Blip_Buffer* right ) +{ +#if defined(ROCKBOX) + (void) left; + (void) right; +#endif + + // Must be silent (all NULL), mono (left and right NULL), or stereo (none NULL) + require( !center || (center && !left && !right) || (center && left && right) ); + require( (unsigned) i < sms_osc_count ); // fails if you pass invalid osc index + + if ( center ) + { + unsigned const divisor = 16384 * 16 * 2; + this->min_tone_period = ((unsigned) Blip_clock_rate( center ) + divisor/2) / divisor; + } + + if ( !center || !left || !right ) + { + left = center; + right = center; + } + + struct Osc* o = &this->oscs [i]; + o->outputs [0] = NULL; + o->outputs [1] = right; + o->outputs [2] = left; + o->outputs [3] = center; + o->output = o->outputs [calc_output( this, i )]; +} + +static inline unsigned fibonacci_to_galois_lfsr( unsigned fibonacci, int width ) +{ + unsigned galois = 0; + while ( --width >= 0 ) + { + galois = (galois << 1) | (fibonacci & 1); + fibonacci >>= 1; + } + return galois; +} + +void Sms_apu_reset( struct Sms_Apu* this, unsigned feedback, int noise_width ) +{ + this->last_time = 0; + this->latch = 0; + this->ggstereo = 0; + + // Calculate noise feedback values + if ( !feedback || !noise_width ) + { + feedback = 0x0009; + noise_width = 16; + } + this->looped_feedback = 1 << (noise_width - 1); + this->noise_feedback = fibonacci_to_galois_lfsr( feedback, noise_width ); + + // Reset oscs + int i; + for ( i = sms_osc_count; --i >= 0; ) + { + struct Osc* o = &this->oscs [i]; + o->output = NULL; + o->last_amp = 0; + o->delay = 0; + o->phase = 0; + o->period = 0; + o->volume = 15; // silent + } + + this->oscs [noise_osc].phase = 0x8000; + Sms_apu_write_ggstereo( this, 0, 0xFF ); +} + +void Sms_apu_init( struct Sms_Apu* this ) +{ + this->min_tone_period = 7; + + Synth_init( &this->synth ); + + // Clear outputs to NULL FIRST + this->ggstereo = 0; + + int i; + for ( i = sms_osc_count; --i >= 0; ) + Sms_apu_set_output( this, i, NULL, NULL, NULL ); + + Sms_apu_volume( this, (int)FP_ONE_VOLUME ); + Sms_apu_reset( this, 0, 0 ); +} + +static void run_until( struct Sms_Apu* this, blip_time_t end_time ) +{ + require( end_time >= this->last_time ); + if ( end_time <= this->last_time ) + return; + + // Synthesize each oscillator + int idx; + for ( idx = sms_osc_count; --idx >= 0; ) + { + struct Osc* osc = &this->oscs [idx]; + int vol = 0; + int amp = 0; + + // Determine what will be generated + struct Blip_Buffer* const out = osc->output; + if ( out ) + { + // volumes [i] ~= 64 * pow( 1.26, 15 - i ) / pow( 1.26, 15 ) + static unsigned char const volumes [16] = { + 64, 50, 40, 32, 25, 20, 16, 13, 10, 8, 6, 5, 4, 3, 2, 0 + }; + + vol = volumes [osc->volume]; + amp = (osc->phase & 1) * vol; + + // Square freq above 16 kHz yields constant amplitude at half volume + if ( idx != noise_osc && osc->period < this->min_tone_period ) + { + amp = vol >> 1; + vol = 0; + } + + // Update amplitude + int delta = amp - osc->last_amp; + if ( delta ) + { + osc->last_amp = amp; + Synth_offset( &this->synth, this->last_time, delta, out ); + Blip_set_modified( out ); + } + } + + // Generate wave + blip_time_t time = this->last_time + osc->delay; + if ( time < end_time ) + { + // Calculate actual period + int period = osc->period; + if ( idx == noise_osc ) + { + period = 0x20 << (period & 3); + if ( period == 0x100 ) + period = this->oscs [2].period * 2; + } + period *= 0x10; + if ( !period ) + period = 0x10; + + // Maintain phase when silent + int phase = osc->phase; + if ( !vol ) + { + int count = (end_time - time + period - 1) / period; + time += count * period; + if ( idx != noise_osc ) // TODO: maintain noise LFSR phase? + phase ^= count & 1; + } + else + { + int delta = amp * 2 - vol; + + if ( idx != noise_osc ) + { + // Square + do + { + delta = -delta; + Synth_offset( &this->synth, time, delta, out ); + time += period; + } + while ( time < end_time ); + phase = (delta >= 0); + } + else + { + // Noise + unsigned const feedback = (osc->period & 4 ? this->noise_feedback : this->looped_feedback); + do + { + unsigned changed = phase + 1; + phase = ((phase & 1) * feedback) ^ (phase >> 1); + if ( changed & 2 ) // true if bits 0 and 1 differ + { + delta = -delta; + Synth_offset_inline( &this->synth, time, delta, out ); + } + time += period; + } + while ( time < end_time ); + check( phase ); + } + osc->last_amp = (phase & 1) * vol; + Blip_set_modified( out ); + } + osc->phase = phase; + } + osc->delay = time - end_time; + } + this->last_time = end_time; +} + +void Sms_apu_write_ggstereo( struct Sms_Apu* this, blip_time_t time, int data ) +{ + require( (unsigned) data <= 0xFF ); + + run_until( this, time ); + this->ggstereo = data; + + int i; + for ( i = sms_osc_count; --i >= 0; ) + { + struct Osc* osc = &this->oscs [i]; + + struct Blip_Buffer* old = osc->output; + osc->output = osc->outputs [calc_output( this, i )]; + if ( osc->output != old ) + { + int delta = -osc->last_amp; + if ( delta ) + { + osc->last_amp = 0; + if ( old ) + { + Blip_set_modified( old ); + Synth_offset( &this->synth, this->last_time, delta, old ); + } + } + } + } +} + +void Sms_apu_write_data( struct Sms_Apu* this, blip_time_t time, int data ) +{ + require( (unsigned) data <= 0xFF ); + + run_until( this, time ); + + if ( data & 0x80 ) + this->latch = data; + + // We want the raw values written so our save state format can be + // as close to hardware as possible and unspecific to any emulator. + int idx = this->latch >> 5 & 3; + struct Osc* osc = &this->oscs [idx]; + if ( this->latch & 0x10 ) + { + osc->volume = data & 0x0F; + } + else + { + if ( idx == noise_osc ) + osc->phase = 0x8000; // reset noise LFSR + + // Replace high 6 bits/low 4 bits of register with data + int lo = osc->period; + int hi = data << 4; + if ( idx == noise_osc || (data & 0x80) ) + { + hi = lo; + lo = data; + } + osc->period = (hi & 0x3F0) | (lo & 0x00F); + } +} + +void Sms_apu_end_frame( struct Sms_Apu* this, blip_time_t end_time ) +{ + if ( end_time > this->last_time ) + run_until( this, end_time ); + + this->last_time -= end_time; + assert( this->last_time >= 0 ); +} diff --git a/lib/rbcodec/codecs/libgme/sms_apu.h b/lib/rbcodec/codecs/libgme/sms_apu.h new file mode 100644 index 0000000000..6dd65591ce --- /dev/null +++ b/lib/rbcodec/codecs/libgme/sms_apu.h @@ -0,0 +1,63 @@ +// Sega Master System SN76489 PSG sound chip emulator + +// Sms_Snd_Emu 0.1.2 +#ifndef SMS_APU_H +#define SMS_APU_H + +#include "blargg_common.h" +#include "blip_buffer.h" + +// 0: Square 1, 1: Square 2, 2: Square 3, 3: Noise +enum { sms_osc_count = 4 }; // 0 <= chan < osc_count + +struct Osc +{ + struct Blip_Buffer* outputs [4]; // NULL, right, left, center + struct Blip_Buffer* output; + int last_amp; + + int volume; + int period; + int delay; + unsigned phase; +}; + +struct Sms_Apu { + struct Osc oscs [sms_osc_count]; + int ggstereo; + int latch; + + blip_time_t last_time; + int min_tone_period; + unsigned noise_feedback; + unsigned looped_feedback; + struct Blip_Synth synth; +}; + +// Basics + +void Sms_apu_init( struct Sms_Apu* this ); + +// Sets buffer(s) to generate sound into, or 0 to mute. If only center is not 0, +// output is mono. +void Sms_apu_set_output( struct Sms_Apu* this, int i, struct Blip_Buffer* center, struct Blip_Buffer* left, struct Blip_Buffer* right); + +// Emulates to time t, then writes data to Game Gear left/right assignment byte +void Sms_apu_write_ggstereo( struct Sms_Apu* this, blip_time_t t, int data ); + +// Emulates to time t, then writes data +void Sms_apu_write_data( struct Sms_Apu* this, blip_time_t t, int data ); + +// Emulates to time t, then subtracts t from the current time. +// OK if previous write call had time slightly after t. +void Sms_apu_end_frame( struct Sms_Apu* this, blip_time_t t ); + +// More features + +// Resets sound chip and sets noise feedback bits and width +void Sms_apu_reset( struct Sms_Apu* this, unsigned noise_feedback, int noise_width ); + +// Sets overall volume, where 1.0 is normal +void Sms_apu_volume( struct Sms_Apu* this, int vol ); + +#endif diff --git a/lib/rbcodec/codecs/libgme/sms_fm_apu.c b/lib/rbcodec/codecs/libgme/sms_fm_apu.c new file mode 100644 index 0000000000..ee5ce48932 --- /dev/null +++ b/lib/rbcodec/codecs/libgme/sms_fm_apu.c @@ -0,0 +1,82 @@ +#include "sms_fm_apu.h" + +#include "blargg_source.h" + +void Fm_apu_create( struct Sms_Fm_Apu* this ) +{ + Synth_init( &this->synth ); + Ym2413_init( &this->apu ); +} + +blargg_err_t Fm_apu_init( struct Sms_Fm_Apu* this, int clock_rate, int sample_rate ) +{ + this->period_ = (blip_time_t) (clock_rate / sample_rate); + CHECK_ALLOC( !Ym2413_set_rate( &this->apu, sample_rate, clock_rate ) ); + + Fm_apu_set_output( this, 0 ); + Fm_apu_volume( this, (int)FP_ONE_VOLUME ); + Fm_apu_reset( this ); + return 0; +} + +void Fm_apu_reset( struct Sms_Fm_Apu* this ) +{ + this->addr = 0; + this->next_time = 0; + this->last_amp = 0; + + Ym2413_reset( &this->apu ); +} + +void fm_run_until( struct Sms_Fm_Apu* this, blip_time_t end_time ); +void Fm_apu_write_data( struct Sms_Fm_Apu* this, blip_time_t time, int data ) +{ + if ( time > this->next_time ) + fm_run_until( this, time ); + + Ym2413_write( &this->apu, this->addr, data ); +} + +void fm_run_until( struct Sms_Fm_Apu* this, blip_time_t end_time ) +{ + assert( end_time > this->next_time ); + + struct Blip_Buffer* const output = this->output_; + if ( !output ) + { + this->next_time = end_time; + return; + } + + blip_time_t time = this->next_time; + struct Ym2413_Emu* emu = &this->apu; + do + { + short samples [2]; + Ym2413_run( emu, 1, samples ); + int amp = (samples [0] + samples [1]) >> 1; + + int delta = amp - this->last_amp; + if ( delta ) + { + this->last_amp = amp; + Synth_offset_inline( &this->synth, time, delta, output ); + } + time += this->period_; + } + while ( time < end_time ); + + this->next_time = time; +} + +void Fm_apu_end_frame( struct Sms_Fm_Apu* this, blip_time_t time ) +{ + if ( time > this->next_time ) + fm_run_until( this, time ); + + this->next_time -= time; + assert( this->next_time >= 0 ); + + if ( this->output_ ) + Blip_set_modified( this->output_ ); +} diff --git a/lib/rbcodec/codecs/libgme/sms_fm_apu.h b/lib/rbcodec/codecs/libgme/sms_fm_apu.h new file mode 100644 index 0000000000..921db6cef1 --- /dev/null +++ b/lib/rbcodec/codecs/libgme/sms_fm_apu.h @@ -0,0 +1,43 @@ +#ifndef SMS_FM_APU_H +#define SMS_FM_APU_H + +#include "blargg_common.h" +#include "blip_buffer.h" +#include "ym2413_emu.h" + +enum { fm_apu_osc_count = 1 }; + +struct Sms_Fm_Apu { + struct Blip_Buffer* output_; + blip_time_t next_time; + int last_amp; + int addr; + + int clock_; + int rate_; + blip_time_t period_; + + struct Blip_Synth synth; + struct Ym2413_Emu apu; +}; + +void Fm_apu_create( struct Sms_Fm_Apu* this ); + +static inline bool Fm_apu_supported( void ) { return Ym2413_supported(); } +blargg_err_t Fm_apu_init( struct Sms_Fm_Apu* this, int clock_rate, int sample_rate ); + +static inline void Fm_apu_set_output( struct Sms_Fm_Apu* this, struct Blip_Buffer* b ) +{ + this->output_ = b; +} + +static inline void Fm_apu_volume( struct Sms_Fm_Apu* this, int v ) { Synth_volume( &this->synth, (v*2) / 5 / 4096 ); } + +void Fm_apu_reset( struct Sms_Fm_Apu* this ); + +static inline void Fm_apu_write_addr( struct Sms_Fm_Apu* this, int data ) { this->addr = data; } +void Fm_apu_write_data( struct Sms_Fm_Apu* this, blip_time_t, int data ); + +void Fm_apu_end_frame( struct Sms_Fm_Apu* this, blip_time_t t ); + +#endif diff --git a/lib/rbcodec/codecs/libgme/track_filter.c b/lib/rbcodec/codecs/libgme/track_filter.c new file mode 100644 index 0000000000..d0d75f2ded --- /dev/null +++ b/lib/rbcodec/codecs/libgme/track_filter.c @@ -0,0 +1,294 @@ +// Game_Music_Emu 0.6-pre. http://www.slack.net/~ant/ + +#include "track_filter.h" + +/* Copyright (C) 2003-2008 Shay Green. This module is free software; you +can redistribute it and/or modify it under the terms of the GNU Lesser +General Public License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. This +module is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +details. You should have received a copy of the GNU Lesser General Public +License along with this module; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ + +#include "blargg_source.h" + +int const fade_block_size = 512; +int const fade_shift = 8; // fade ends with gain at 1.0 / (1 << fade_shift) +int const silence_threshold = 8; + +void track_create( struct Track_Filter* this ) +{ + this->emu_ = NULL; + this->setup_.max_initial = 0; + this->setup_.lookahead = 0; + this->setup_.max_silence = indefinite_count; + this->silence_ignored_ = false; + track_stop( this ); +} + +blargg_err_t track_init( struct Track_Filter* this, void* emu ) +{ + this->emu_ = emu; + return 0; +} + +static void clear_time_vars( struct Track_Filter* this ) +{ + this->emu_time = this->buf_remain; + this->out_time = 0; + this->silence_time = 0; + this->silence_count = 0; +} + +void track_stop( struct Track_Filter* this ) +{ + this->emu_track_ended_ = true; + this->track_ended_ = true; + this->fade_start = indefinite_count; + this->fade_step = 1; + this->buf_remain = 0; + this->emu_error = NULL; + clear_time_vars( this ); +} + +blargg_err_t track_start( struct Track_Filter* this ) +{ + this->emu_error = NULL; + track_stop( this ); + + this->emu_track_ended_ = false; + this->track_ended_ = false; + + if ( !this->silence_ignored_ ) + { + // play until non-silence or end of track + while ( this->emu_time < this->setup_.max_initial ) + { + fill_buf( this ); + if ( this->buf_remain | this->emu_track_ended_ ) + break; + } + } + + clear_time_vars( this ); + return this->emu_error; +} + +static void end_track_if_error( struct Track_Filter* this, blargg_err_t err ) +{ + if ( err ) + { + this->emu_error = err; + this->emu_track_ended_ = true; + } +} + +blargg_err_t track_skip( struct Track_Filter* this, int count ) +{ + this->emu_error = NULL; + this->out_time += count; + + // remove from silence and buf first + { + int n = min( count, this->silence_count ); + this->silence_count -= n; + count -= n; + + n = min( count, this->buf_remain ); + this->buf_remain -= n; + count -= n; + } + + if ( count && !this->emu_track_ended_ ) + { + this->emu_time += count; + this->silence_time = this->emu_time; // would otherwise be invalid + end_track_if_error( this, skip_( this->emu_, count ) ); + } + + if ( !(this->silence_count | this->buf_remain) ) // caught up to emulator, so update track ended + this->track_ended_ |= this->emu_track_ended_; + + return this->emu_error; +} + +blargg_err_t skippy_( struct Track_Filter* this, int count ) +{ + while ( count && !this->emu_track_ended_ ) + { + int n = buf_size; + if ( n > count ) + n = count; + count -= n; + RETURN_ERR( play_( this->emu_, n, this->buf ) ); + } + return 0; +} + +// Fading + +void track_set_fade( struct Track_Filter* this, int start, int length ) +{ + this->fade_start = start; + this->fade_step = length / (fade_block_size * fade_shift); + if ( this->fade_step < 1 ) + this->fade_step = 1; +} + +static bool is_fading( struct Track_Filter* this ) +{ + return this->out_time >= this->fade_start && this->fade_start != indefinite_count; +} + +// unit / pow( 2.0, (double) x / step ) +static int int_log( int x, int step, int unit ) +{ + int shift = x / step; + int fraction = (x - shift * step) * unit / step; + return ((unit - fraction) + (fraction >> 1)) >> shift; +} + +static void handle_fade( struct Track_Filter* this, sample_t out [], int out_count ) +{ + int i; + for ( i = 0; i < out_count; i += fade_block_size ) + { + int const shift = 14; + int const unit = 1 << shift; + int gain = int_log( (this->out_time + i - this->fade_start) / fade_block_size, + this->fade_step, unit ); + if ( gain < (unit >> fade_shift) ) + this->track_ended_ = this->emu_track_ended_ = true; + + sample_t* io = &out [i]; + for ( int count = min( fade_block_size, out_count - i ); count; --count ) + { + *io = (sample_t) ((*io * gain) >> shift); + ++io; + } + } +} + +// Silence detection + +static void emu_play( struct Track_Filter* this, sample_t out [], int count ) +{ + this->emu_time += count; + if ( !this->emu_track_ended_ ) + end_track_if_error( this, play_( this->emu_, count, out ) ); + else + memset( out, 0, count * sizeof *out ); +} + +// number of consecutive silent samples at end +static int count_silence( sample_t begin [], int size ) +{ + sample_t first = *begin; + *begin = silence_threshold * 2; // sentinel + sample_t* p = begin + size; + while ( (unsigned) (*--p + silence_threshold) <= (unsigned) silence_threshold * 2 ) { } + *begin = first; + return size - (p - begin); +} + +// fill internal buffer and check it for silence +void fill_buf( struct Track_Filter* this ) +{ + assert( !this->buf_remain ); + if ( !this->emu_track_ended_ ) + { + emu_play( this, this->buf, buf_size ); + int silence = count_silence( this->buf, buf_size ); + if ( silence < buf_size ) + { + this->silence_time = this->emu_time - silence; + this->buf_remain = buf_size; + return; + } + } + this->silence_count += buf_size; +} + +blargg_err_t track_play( struct Track_Filter* this, int out_count, sample_t out [] ) +{ + this->emu_error = NULL; + if ( this->track_ended_ ) + { + memset( out, 0, out_count * sizeof *out ); + } + else + { + assert( this->emu_time >= this->out_time ); + + // prints nifty graph of how far ahead we are when searching for silence + //dprintf( "%*s \n", int ((emu_time - out_time) * 7 / 44100), "*" ); + + // use any remaining silence samples + int pos = 0; + if ( this->silence_count ) + { + if ( !this->silence_ignored_ ) + { + // during a run of silence, run emulator at >=2x speed so it gets ahead + int ahead_time = this->setup_.lookahead * (this->out_time + out_count - this->silence_time) + + this->silence_time; + while ( this->emu_time < ahead_time && !(this->buf_remain | this->emu_track_ended_) ) + fill_buf( this ); + + // end track if sufficient silence has been found + if ( this->emu_time - this->silence_time > this->setup_.max_silence ) + { + this->track_ended_ = this->emu_track_ended_ = true; + this->silence_count = out_count; + this->buf_remain = 0; + } + } + + // fill from remaining silence + pos = min( this->silence_count, out_count ); + memset( out, 0, pos * sizeof *out ); + this->silence_count -= pos; + } + + // use any remaining samples from buffer + if ( this->buf_remain ) + { + int n = min( this->buf_remain, (int) (out_count - pos) ); + memcpy( out + pos, this->buf + (buf_size - this->buf_remain), n * sizeof *out ); + this->buf_remain -= n; + pos += n; + } + + // generate remaining samples normally + int remain = out_count - pos; + if ( remain ) + { + emu_play( this, out + pos, remain ); + this->track_ended_ |= this->emu_track_ended_; + + if ( this->silence_ignored_ && !is_fading( this ) ) + { + // if left unupdated, ahead_time could become too large + this->silence_time = this->emu_time; + } + else + { + // check end for a new run of silence + int silence = count_silence( out + pos, remain ); + if ( silence < remain ) + this->silence_time = this->emu_time - silence; + + if ( this->emu_time - this->silence_time >= buf_size ) + fill_buf( this ); // cause silence detection on next play() + } + } + + if ( is_fading( this ) ) + handle_fade( this, out, out_count ); + } + this->out_time += out_count; + return this->emu_error; +} diff --git a/lib/rbcodec/codecs/libgme/track_filter.h b/lib/rbcodec/codecs/libgme/track_filter.h new file mode 100644 index 0000000000..3689be9620 --- /dev/null +++ b/lib/rbcodec/codecs/libgme/track_filter.h @@ -0,0 +1,90 @@ +// Removes silence from beginning of track, fades end of track. Also looks ahead +// for excessive silence, and if found, ends track. + +// Game_Music_Emu 0.6-pre +#ifndef TRACK_FILTER_H +#define TRACK_FILTER_H + +#include "blargg_common.h" + +typedef short sample_t; +typedef int sample_count_t; + +enum { indefinite_count = INT_MAX/2 + 1 }; +enum { buf_size = 2048 }; + +struct setup_t { + sample_count_t max_initial; // maximum silence to strip from beginning of track + sample_count_t max_silence; // maximum silence in middle of track without it ending + int lookahead; // internal speed when looking ahead for silence (2=200% etc.) +}; + +struct Track_Filter { + void* emu_; + struct setup_t setup_; + const char* emu_error; + bool silence_ignored_; + + // Timing + int out_time; // number of samples played since start of track + int emu_time; // number of samples emulator has generated since start of track + int emu_track_ended_; // emulator has reached end of track + volatile int track_ended_; + + // Fading + int fade_start; + int fade_step; + + // Silence detection + int silence_time; // absolute number of samples where most recent silence began + int silence_count; // number of samples of silence to play before using buf + int buf_remain; // number of samples left in silence buffer + sample_t buf [buf_size]; +}; + +// Initializes filter. Must be done once before using object. +blargg_err_t track_init( struct Track_Filter* this, void* ); +void track_create( struct Track_Filter* this ); + +// Gets/sets setup +static inline struct setup_t const* track_get_setup( struct Track_Filter* this ) { return &this->setup_; } +static inline void track_setup( struct Track_Filter* this, struct setup_t const* s ) { this->setup_ = *s; } + +// Disables automatic end-of-track detection and skipping of silence at beginning +static inline void track_ignore_silence( struct Track_Filter* this, bool disable ) { this->silence_ignored_ = disable; } + +// Clears state and skips initial silence in track +blargg_err_t track_start( struct Track_Filter* this ); + +// Sets time that fade starts, and how long until track ends. +void track_set_fade( struct Track_Filter* this, sample_count_t start, sample_count_t length ); + +// Generates n samples into buf +blargg_err_t track_play( struct Track_Filter* this, int n, sample_t buf [] ); + +// Skips n samples +blargg_err_t track_skip( struct Track_Filter* this, int n ); + +// Number of samples played/skipped since start_track() +static inline int track_sample_count( struct Track_Filter* this ) { return this->out_time; } + +// True if track ended. Causes are end of source samples, end of fade, +// or excessive silence. +static inline bool track_ended( struct Track_Filter* this ) { return this->track_ended_; } + +// Clears state +void track_stop( struct Track_Filter* this ); + +// For use by callbacks + +// Sets internal "track ended" flag and stops generation of further source samples +static inline void track_set_end( struct Track_Filter* this ) { this->emu_track_ended_ = true; } + +// For use by skip_() callback +blargg_err_t skippy_( struct Track_Filter* this, int count ); +void fill_buf( struct Track_Filter* this ); + +// Skip and play callbacks +blargg_err_t skip_( void* emu, int count ); +blargg_err_t play_( void* emu, int count, sample_t out [] ); +#endif diff --git a/lib/rbcodec/codecs/libgme/vgm_emu.c b/lib/rbcodec/codecs/libgme/vgm_emu.c new file mode 100644 index 0000000000..4b8953ccf4 --- /dev/null +++ b/lib/rbcodec/codecs/libgme/vgm_emu.c @@ -0,0 +1,858 @@ +// Game_Music_Emu 0.5.5. http://www.slack.net/~ant/ + +#include "vgm_emu.h" + +#include "blargg_endian.h" +#include +#include + +/* Copyright (C) 2003-2006 Shay Green. This module is free software; you +can redistribute it and/or modify it under the terms of the GNU Lesser +General Public License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. This +module is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +details. You should have received a copy of the GNU Lesser General Public +License along with this module; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ + +#include "blargg_source.h" + +const char* const gme_wrong_file_type = "Wrong file type for this emulator"; + +int const fm_gain = 3; // FM emulators are internally quieter to avoid 16-bit overflow + +// VGM commands (Spec v1.50) +enum { + cmd_gg_stereo = 0x4F, + cmd_psg = 0x50, + cmd_ym2413 = 0x51, + cmd_ym2612_port0 = 0x52, + cmd_ym2612_port1 = 0x53, + cmd_ym2151 = 0x54, + cmd_delay = 0x61, + cmd_delay_735 = 0x62, + cmd_delay_882 = 0x63, + cmd_byte_delay = 0x64, + cmd_end = 0x66, + cmd_data_block = 0x67, + cmd_short_delay = 0x70, + cmd_pcm_delay = 0x80, + cmd_pcm_seek = 0xE0, + + pcm_block_type = 0x00, + ym2612_dac_port = 0x2A, + ym2612_dac_pan_port = 0xB6 +}; + +static void clear_track_vars( struct Vgm_Emu* this ) +{ + this->current_track = -1; + track_stop( &this->track_filter ); +} + +int play_frame( struct Vgm_Emu* this, blip_time_t blip_time, int sample_count, sample_t* buf ); +static int play_frame_( void* data, blip_time_t blip_time, int sample_count, short int* buf ) +{ + return play_frame( (struct Vgm_Emu*) data, blip_time, sample_count, buf ); +} + +void Vgm_init( struct Vgm_Emu* this ) +{ + this->sample_rate = 0; + this->mute_mask_ = 0; + this->tempo = (int)(FP_ONE_TEMPO); + + // defaults + this->tfilter = *track_get_setup( &this->track_filter ); + this->tfilter.max_initial = 2; + this->tfilter.lookahead = 1; + this->track_filter.silence_ignored_ = false; + + // Disable oversampling by default + this->disable_oversampling = true; + this->psg_rate = 0; + + Sms_apu_init( &this->psg ); + Synth_init( &this->pcm ); + + Buffer_init( &this->stereo_buf ); + Blip_init( &this->blip_buf ); + + // Init fm chips + Ym2413_init( &this->ym2413 ); + Ym2612_init( &this->ym2612 ); + + // Init resampler + Resampler_init( &this->resampler ); + Resampler_set_callback( &this->resampler, play_frame_, this ); + + // Set sound gain, a value too high + // will cause saturation + Sound_set_gain(this, (int)(FP_ONE_GAIN*0.7)); + + // Unload + this->voice_count = 0; + this->voice_types = 0; + clear_track_vars( this ); +} + +// Track info + +static byte const* skip_gd3_str( byte const* in, byte const* end ) +{ + while ( end - in >= 2 ) + { + in += 2; + if ( !(in [-2] | in [-1]) ) + break; + } + return in; +} + +static byte const* get_gd3_str( byte const* in, byte const* end, char* field ) +{ + byte const* mid = skip_gd3_str( in, end ); + int i, len = (mid - in) / 2 - 1; + if ( field && len > 0 ) + { + len = min( len, (int) gme_max_field ); + field [len] = 0; + for ( i = 0; i < len; i++ ) + field [i] = (in [i * 2 + 1] ? '?' : in [i * 2]); // TODO: convert to utf-8 + } + return mid; +} + +static byte const* get_gd3_pair( byte const* in, byte const* end, char* field ) +{ + return skip_gd3_str( get_gd3_str( in, end, field ), end ); +} + +static void parse_gd3( byte const* in, byte const* end, struct track_info_t* out ) +{ + in = get_gd3_pair( in, end, out->song ); + in = get_gd3_pair( in, end, out->game ); + in = get_gd3_pair( in, end, NULL ); // Skip system + in = get_gd3_pair( in, end, out->author ); +} + +int const gd3_header_size = 12; + +static int check_gd3_header( byte const* h, int remain ) +{ + if ( remain < gd3_header_size ) return 0; + if ( memcmp( h, "Gd3 ", 4 ) ) return 0; + if ( get_le32( h + 4 ) >= 0x200 ) return 0; + + int gd3_size = get_le32( h + 8 ); + if ( gd3_size > remain - gd3_header_size ) + gd3_size = remain - gd3_header_size; + return gd3_size; +} + +static byte const* gd3_data( struct Vgm_Emu* this, int* size ) +{ + if ( size ) + *size = 0; + + int gd3_offset = get_le32( header( this )->gd3_offset ) - 0x2C; + if ( gd3_offset < 0 ) + return 0; + + byte const* gd3 = this->file_begin + header_size + gd3_offset; + int gd3_size = check_gd3_header( gd3, this->file_end - gd3 ); + if ( !gd3_size ) + return 0; + + if ( size ) + *size = gd3_size + gd3_header_size; + + return gd3; +} + +static void get_vgm_length( struct header_t const* h, struct track_info_t* out ) +{ + int length = get_le32( h->track_duration ) * 10 / 441; + if ( length > 0 ) + { + int loop = get_le32( h->loop_duration ); + if ( loop > 0 && get_le32( h->loop_offset ) ) + { + out->loop_length = loop * 10 / 441; + out->intro_length = length - out->loop_length; + } + else + { + out->length = length; // 1000 / 44100 (VGM files used 44100 as timebase) + out->intro_length = length; // make it clear that track is no longer than length + out->loop_length = 0; + } + } +} + +static blargg_err_t track_info( struct Vgm_Emu* this, struct track_info_t* out ) +{ + memset(out, 0, sizeof *out); + get_vgm_length( header( this ), out ); + + int size; + byte const* gd3 = gd3_data( this, &size ); + if ( gd3 ) + parse_gd3( gd3 + gd3_header_size, gd3 + size, out ); + + return 0; +} + +static blargg_err_t check_vgm_header( struct header_t* h ) +{ + if ( memcmp( h->tag, "Vgm ", 4 ) ) + return gme_wrong_file_type; + return 0; +} + +static void set_voice( struct Vgm_Emu* this, int i, struct Blip_Buffer* c, struct Blip_Buffer* l, struct Blip_Buffer* r ) +{ + if ( i < sms_osc_count ) { + Sms_apu_set_output( &this->psg, i, c, l, r ); + } +} + +blargg_err_t setup_fm( struct Vgm_Emu* this ); +blargg_err_t Vgm_load_mem( struct Vgm_Emu* this, byte const* new_data, long new_size, bool parse_info ) +{ + // Unload + this->voice_count = 0; + clear_track_vars( this ); + + // Clear info + memset( &this->info, 0, sizeof this->info ); + + assert( offsetof (struct header_t,unused2 [8]) == header_size ); + + if ( new_size <= header_size ) + return gme_wrong_file_type; + + // Reset data pointers + this->file_begin = new_data; + this->file_end = new_data + new_size; + + struct header_t* h = (struct header_t*) new_data; + RETURN_ERR( check_vgm_header( h ) ); + check( get_le32( h.version ) <= 0x150 ); + + // If this was VGZ file gd3 parse info + if ( parse_info ) { + track_info( this, &this->info ); + + // If file was trimmed add an + // incomplete token to the game tag + if ( get_le32( h->data_size ) > (unsigned) new_size ) { + *((char *) this->file_end) = cmd_end; + strcat(this->info.game, "(Trimmed VGZ file)" ); + } + } + + // Get loop + this->loop_begin = this->file_end; + + // If file was trimmed don't loop + if ( get_le32( h->loop_offset ) && get_le32( h->data_size ) <= (unsigned) new_size ) + this->loop_begin = &new_data [get_le32( h->loop_offset ) + offsetof (struct header_t,loop_offset)]; + + // PSG rate + this->psg_rate = get_le32( h->psg_rate ); + if ( !this->psg_rate ) + this->psg_rate = 3579545; + + Blip_set_clock_rate( &this->blip_buf, this->psg_rate ); + + // Disable FM + this->fm_rate = 0; + Ym2612_enable( &this->ym2612, false ); + Ym2413_enable( &this->ym2413, false ); + + this->voice_count = sms_osc_count; + static int const types [8] = { + wave_type+1, wave_type+2, wave_type+3, noise_type+1, + 0, 0, 0, 0 + }; + this->voice_types = types; + + RETURN_ERR( setup_fm( this ) ); + + // do after FM in case output buffer is changed + // setup buffer + this->clock_rate_ = this->psg_rate; + Buffer_clock_rate( &this->stereo_buf, this->psg_rate ); + RETURN_ERR( Buffer_set_channel_count( &this->stereo_buf, this->voice_count, this->voice_types ) ); + this->buf_changed_count = Buffer_channels_changed_count( &this->stereo_buf ); + + // Post load + Sound_set_tempo( this, this->tempo ); + Sound_mute_voices( this, this->mute_mask_ ); + + // so we can start playback + this->current_track = 0; + return 0; +} + +void update_fm_rates( struct Vgm_Emu* this, int* ym2413_rate, int* ym2612_rate ); +static blargg_err_t init_fm( struct Vgm_Emu* this, int* rate ) +{ + int ym2612_rate = get_le32( header( this )->ym2612_rate ); + int ym2413_rate = get_le32( header( this )->ym2413_rate ); + if ( ym2413_rate && get_le32( header( this )->version ) < 0x110 ) + update_fm_rates( this, &ym2413_rate, &ym2612_rate ); + + if ( ym2612_rate ) + { + if ( !*rate ) + *rate = ym2612_rate / 144; + RETURN_ERR( Ym2612_set_rate( &this->ym2612, *rate, ym2612_rate ) ); + Ym2612_enable( &this->ym2612, true ); + } + else if ( ym2413_rate ) + { + if ( !*rate ) + *rate = ym2413_rate / 72; + int result = Ym2413_set_rate( &this->ym2413, *rate, ym2413_rate ); + if ( result == 2 ) + return "YM2413 FM sound not supported"; + CHECK_ALLOC( !result ); + Ym2413_enable( &this->ym2413, true ); + } + + this->fm_rate = *rate; + + return 0; +} + +blargg_err_t setup_fm( struct Vgm_Emu* this ) +{ + int fm_rate = 0; + if ( !this->disable_oversampling ) + fm_rate = (this->sample_rate * 3) / 2; // oversample factor = 1.5 + RETURN_ERR( init_fm( this, &fm_rate ) ); + + if ( uses_fm( this ) ) + { + this->voice_count = 8; + RETURN_ERR( Resampler_setup( &this->resampler, fm_rate, fm_gain, this->sample_rate, this->gain ) ); + RETURN_ERR( Resampler_reset( &this->resampler, Blip_length( &this->blip_buf ) * this->sample_rate / 1000 ) ); + Sms_apu_volume( &this->psg, ((this->gain/5)-(this->gain*5)/1000) * fm_gain ); + } + else + { + Sms_apu_volume( &this->psg, this->gain ); + } + + return 0; +} + +// Emulation + +blip_time_t run( struct Vgm_Emu* this, vgm_time_t end_time ); +static blip_time_t run_psg( struct Vgm_Emu* this, int msec ) +{ + blip_time_t t = run( this, msec * this->vgm_rate / 1000 ); + Sms_apu_end_frame( &this->psg, t ); + return t; +} + +static void check_end( struct Vgm_Emu* this ) +{ + if( this->pos >= this->file_end ) + track_set_end( &this->track_filter ); +} + +static blargg_err_t run_clocks( struct Vgm_Emu* this, blip_time_t* time_io, int msec ) +{ + check_end( this ); + *time_io = run_psg( this, msec ); + return 0; +} + +blargg_err_t play_( void *emu, int count, sample_t out [] ) +{ + struct Vgm_Emu* this = (struct Vgm_Emu*) emu; + + if ( !uses_fm( this ) ) { + int remain = count; + while ( remain ) + { + Buffer_disable_immediate_removal( &this->stereo_buf ); + remain -= Buffer_read_samples( &this->stereo_buf, &out [count - remain], remain ); + if ( remain ) + { + if ( this->buf_changed_count != Buffer_channels_changed_count( &this->stereo_buf ) ) + { + this->buf_changed_count = Buffer_channels_changed_count( &this->stereo_buf ); + + // Remute voices + Sound_mute_voices( this, this->mute_mask_ ); + } + int msec = Buffer_length( &this->stereo_buf ); + blip_time_t clocks_emulated = msec * this->clock_rate_ / 1000 - 100; + RETURN_ERR( run_clocks( this, &clocks_emulated, msec ) ); + assert( clocks_emulated ); + Buffer_end_frame( &this->stereo_buf, clocks_emulated ); + } + } + + return 0; + } + + Resampler_play( &this->resampler, count, out, &this->blip_buf ); + return 0; +} + +// Vgm_Emu_impl + +static inline int command_len( int command ) +{ + static byte const lens [0x10] = { + // 0 1 2 3 4 5 6 7 8 9 A B C D E F + 1,1,1,2,2,3,1,1,1,1,3,3,4,4,5,5 + }; + int len = lens [command >> 4]; + check( len != 1 ); + return len; +} + +static inline fm_time_t to_fm_time( struct Vgm_Emu* this, vgm_time_t t ) +{ + return (t * this->fm_time_factor + this->fm_time_offset) >> fm_time_bits; +} + +static inline blip_time_t to_psg_time( struct Vgm_Emu* this, vgm_time_t t ) +{ + return (t * this->blip_time_factor) >> blip_time_bits; +} + +static void write_pcm( struct Vgm_Emu* this, vgm_time_t vgm_time, int amp ) +{ + check( amp >= 0 ); + blip_time_t blip_time = to_psg_time( this, vgm_time ); + int old = this->dac_amp; + int delta = amp - old; + this->dac_amp = amp; + Blip_set_modified( &this->blip_buf ); + if ( old >= 0 ) // first write is ignored, to avoid click + Synth_offset_inline( &this->pcm, blip_time, delta, &this->blip_buf ); + else + this->dac_amp |= this->dac_disabled; +} + +blip_time_t run( struct Vgm_Emu* this, vgm_time_t end_time ) +{ + vgm_time_t vgm_time = this->vgm_time; + byte const* pos = this->pos; + /* if ( pos > this->file_end ) + { + warning( "Stream lacked end event" ); + } */ + + while ( vgm_time < end_time && pos < this->file_end ) + { + // TODO: be sure there are enough bytes left in stream for particular command + // so we don't read past end + switch ( *pos++ ) + { + case cmd_end: + pos = this->loop_begin; // if not looped, loop_begin == data_end + break; + + case cmd_delay_735: + vgm_time += 735; + break; + + case cmd_delay_882: + vgm_time += 882; + break; + + case cmd_gg_stereo: + Sms_apu_write_ggstereo( &this->psg, to_psg_time( this, vgm_time ), *pos++ ); + break; + + case cmd_psg: + Sms_apu_write_data( &this->psg, to_psg_time( this, vgm_time ), *pos++ ); + break; + + case cmd_delay: + vgm_time += pos [1] * 0x100 + pos [0]; + pos += 2; + break; + + case cmd_byte_delay: + vgm_time += *pos++; + break; + + case cmd_ym2413: + if ( Ym2413_run_until( &this->ym2413, to_fm_time( this, vgm_time ) ) ) + Ym2413_write( &this->ym2413, pos [0], pos [1] ); + pos += 2; + break; + + case cmd_ym2612_port0: + if ( pos [0] == ym2612_dac_port ) + { + write_pcm( this, vgm_time, pos [1] ); + } + else if ( Ym2612_run_until( &this->ym2612, to_fm_time( this, vgm_time ) ) ) + { + if ( pos [0] == 0x2B ) + { + this->dac_disabled = (pos [1] >> 7 & 1) - 1; + this->dac_amp |= this->dac_disabled; + } + Ym2612_write0( &this->ym2612, pos [0], pos [1] ); + } + pos += 2; + break; + + case cmd_ym2612_port1: + if ( Ym2612_run_until( &this->ym2612, to_fm_time( this, vgm_time ) ) ) + Ym2612_write1( &this->ym2612, pos [0], pos [1] ); + pos += 2; + break; + + case cmd_data_block: { + check( *pos == cmd_end ); + int type = pos [1]; + int size = get_le32( pos + 2 ); + pos += 6; + if ( type == pcm_block_type ) + this->pcm_data = pos; + pos += size; + break; + } + + case cmd_pcm_seek: + this->pcm_pos = this->pcm_data + pos [3] * 0x1000000 + pos [2] * 0x10000 + + pos [1] * 0x100 + pos [0]; + pos += 4; + break; + + default: { + int cmd = pos [-1]; + switch ( cmd & 0xF0 ) + { + case cmd_pcm_delay: + write_pcm( this, vgm_time, *this->pcm_pos++ ); + vgm_time += cmd & 0x0F; + break; + + case cmd_short_delay: + vgm_time += (cmd & 0x0F) + 1; + break; + + case 0x50: + pos += 2; + break; + + default: + pos += command_len( cmd ) - 1; + /* warning( "Unknown stream event" ); */ + } + } + } + } + vgm_time -= end_time; + this->pos = pos; + this->vgm_time = vgm_time; + + return to_psg_time( this, end_time ); +} + +int play_frame( struct Vgm_Emu* this, blip_time_t blip_time, int sample_count, blip_sample_t out [] ) +{ + check_end( this); + + // to do: timing is working mostly by luck + int min_pairs = (unsigned) sample_count / 2; + int vgm_time = (min_pairs << fm_time_bits) / this->fm_time_factor - 1; + assert( to_fm_time( this, vgm_time ) <= min_pairs ); + int pairs; + while ( (pairs = to_fm_time( this, vgm_time )) < min_pairs ) + vgm_time++; + //debug_printf( "pairs: %d, min_pairs: %d\n", pairs, min_pairs ); + + if ( Ym2612_enabled( &this->ym2612 ) ) + { + Ym2612_begin_frame( &this->ym2612, out ); + memset( out, 0, pairs * stereo * sizeof *out ); + } + else if ( Ym2413_enabled( &this->ym2413 ) ) + { + Ym2413_begin_frame( &this->ym2413, out ); + } + + run( this, vgm_time ); + Ym2612_run_until( &this->ym2612, pairs ); + Ym2413_run_until( &this->ym2413, pairs ); + + this->fm_time_offset = (vgm_time * this->fm_time_factor + this->fm_time_offset) - (pairs << fm_time_bits); + + Sms_apu_end_frame( &this->psg, blip_time ); + + return pairs * stereo; +} + +// Update pre-1.10 header FM rates by scanning commands +void update_fm_rates( struct Vgm_Emu* this, int* ym2413_rate, int* ym2612_rate ) +{ + byte const* p = this->file_begin + 0x40; + while ( p < this->file_end ) + { + switch ( *p ) + { + case cmd_end: + return; + + case cmd_psg: + case cmd_byte_delay: + p += 2; + break; + + case cmd_delay: + p += 3; + break; + + case cmd_data_block: + p += 7 + get_le32( p + 3 ); + break; + + case cmd_ym2413: + *ym2612_rate = 0; + return; + + case cmd_ym2612_port0: + case cmd_ym2612_port1: + *ym2612_rate = *ym2413_rate; + *ym2413_rate = 0; + return; + + case cmd_ym2151: + *ym2413_rate = 0; + *ym2612_rate = 0; + return; + + default: + p += command_len( *p ); + } + } +} + + +// Music Emu + +blargg_err_t Vgm_set_sample_rate( struct Vgm_Emu* this, int rate ) +{ + require( !this->sample_rate ); // sample rate can't be changed once set + RETURN_ERR( Blip_set_sample_rate( &this->blip_buf, rate, 1000 / 30 ) ); + RETURN_ERR( Buffer_set_sample_rate( &this->stereo_buf, rate, 1000 / 20 ) ); + + // Set bass frequency + Buffer_bass_freq( &this->stereo_buf, 80 ); + + this->sample_rate = rate; + RETURN_ERR( track_init( &this->track_filter, this ) ); + this->tfilter.max_silence = 6 * stereo * this->sample_rate; + return 0; +} + +void Sound_mute_voice( struct Vgm_Emu* this, int index, bool mute ) +{ + require( (unsigned) index < (unsigned) this->voice_count ); + int bit = 1 << index; + int mask = this->mute_mask_ | bit; + if ( !mute ) + mask ^= bit; + Sound_mute_voices( this, mask ); +} + +void Sound_mute_voices( struct Vgm_Emu* this, int mask ) +{ + require( this->sample_rate ); // sample rate must be set first + this->mute_mask_ = mask; + + int i; + for ( i = this->voice_count; i--; ) + { + if ( mask & (1 << i) ) + { + set_voice( this, i, 0, 0, 0 ); + } + else + { + struct channel_t ch = Buffer_channel( &this->stereo_buf, i ); + assert( (ch.center && ch.left && ch.right) || + (!ch.center && !ch.left && !ch.right) ); // all or nothing + set_voice( this, i, ch.center, ch.left, ch.right ); + } + } + + // TODO: what was this for? + //core.pcm.output( &core.blip_buf ); + + // TODO: silence PCM if FM isn't used? + if ( uses_fm( this ) ) + { + for ( i = sms_osc_count; --i >= 0; ) + Sms_apu_set_output( &this->psg, i, ( mask & 0x80 ) ? 0 : &this->blip_buf, NULL, NULL ); + if ( Ym2612_enabled( &this->ym2612 ) ) + { + Synth_volume( &this->pcm, (mask & 0x40) ? 0 : (int)((long long)(0.1115*FP_ONE_VOLUME) / 256 * fm_gain * this->gain / FP_ONE_VOLUME) ); + Ym2612_mute_voices( &this->ym2612, mask ); + } + + if ( Ym2413_enabled( &this->ym2413 ) ) + { + int m = mask & 0x3F; + if ( mask & 0x20 ) + m |= 0x01E0; // channels 5-8 + if ( mask & 0x40 ) + m |= 0x3E00; + Ym2413_mute_voices( &this->ym2413, m ); + } + } +} + +void Sound_set_tempo( struct Vgm_Emu* this, int t ) +{ + require( this->sample_rate ); // sample rate must be set first + int const min = (int)(FP_ONE_TEMPO*0.02); + int const max = (int)(FP_ONE_TEMPO*4.00); + if ( t < min ) t = min; + if ( t > max ) t = max; + this->tempo = t; + + if ( this->file_begin ) + { + this->vgm_rate = (long) ((44100LL * t) / FP_ONE_TEMPO); + this->blip_time_factor = (int) (((1LL << blip_time_bits) * Blip_clock_rate( &this->blip_buf )) / this->vgm_rate); + //debug_printf( "blip_time_factor: %ld\n", blip_time_factor ); + //debug_printf( "vgm_rate: %ld\n", vgm_rate ); + // TODO: remove? calculates vgm_rate more accurately (above differs at most by one Hz only) + //blip_time_factor = (long) floor( double (1L << blip_time_bits) * psg_rate / 44100 / t + 0.5 ); + //vgm_rate = (long) floor( double (1L << blip_time_bits) * psg_rate / blip_time_factor + 0.5 ); + + this->fm_time_factor = 2 + (int) ((this->fm_rate * (1LL << fm_time_bits)) / this->vgm_rate); + } +} + +blargg_err_t Vgm_start_track( struct Vgm_Emu* this ) +{ + clear_track_vars( this ); + + Sms_apu_reset( &this->psg, get_le16( header( this )->noise_feedback ), header( this )->noise_width ); + + this->dac_disabled = -1; + this->pos = this->file_begin + header_size; + this->pcm_data = this->pos; + this->pcm_pos = this->pos; + this->dac_amp = -1; + this->vgm_time = 0; + if ( get_le32( header( this )->version ) >= 0x150 ) + { + int data_offset = get_le32( header( this )->data_offset ); + check( data_offset ); + if ( data_offset ) + this->pos += data_offset + offsetof (struct header_t,data_offset) - 0x40; + } + + if ( uses_fm( this ) ) + { + if ( Ym2413_enabled( &this->ym2413 ) ) + Ym2413_reset( &this->ym2413 ); + + if ( Ym2612_enabled( &this->ym2612 ) ) + Ym2612_reset( &this->ym2612 ); + + Blip_clear( &this->blip_buf ); + Resampler_clear( &this->resampler ); + } + + this->fm_time_offset = 0; + + Buffer_clear( &this->stereo_buf ); + + // convert filter times to samples + struct setup_t s = this->tfilter; + s.max_initial *= this->sample_rate * stereo; + #ifdef GME_DISABLE_SILENCE_LOOKAHEAD + s.lookahead = 1; + #endif + track_setup( &this->track_filter, &s ); + + return track_start( &this->track_filter ); +} + +// Tell/Seek + +static int msec_to_samples( int msec, int sample_rate ) +{ + int sec = msec / 1000; + msec -= sec * 1000; + return (sec * sample_rate + msec * sample_rate / 1000) * stereo; +} + +int Track_tell( struct Vgm_Emu* this ) +{ + int rate = this->sample_rate * stereo; + int sec = track_sample_count( &this->track_filter ) / rate; + return sec * 1000 + (track_sample_count( &this->track_filter ) - sec * rate) * 1000 / rate; +} + +blargg_err_t Track_seek( struct Vgm_Emu* this, int msec ) +{ + int time = msec_to_samples( msec, this->sample_rate ); + if ( time < track_sample_count( &this->track_filter ) ) + RETURN_ERR( Vgm_start_track( this ) ); + return Track_skip( this, time - track_sample_count( &this->track_filter ) ); +} + +blargg_err_t Track_skip( struct Vgm_Emu* this, int count ) +{ + require( this->current_track >= 0 ); // start_track() must have been called already + return track_skip( &this->track_filter, count ); +} + +blargg_err_t skip_( void* emu, int count ) +{ + struct Vgm_Emu* this = (struct Vgm_Emu*) emu; + + // for long skip, mute sound + const int threshold = 32768; + if ( count > threshold ) + { + int saved_mute = this->mute_mask_; + Sound_mute_voices( this, ~0 ); + + int n = count - threshold/2; + n &= ~(2048-1); // round to multiple of 2048 + count -= n; + RETURN_ERR( skippy_( &this->track_filter, n ) ); + + Sound_mute_voices( this, saved_mute ); + } + + return skippy_( &this->track_filter, count ); +} + +// Fading + +void Track_set_fade( struct Vgm_Emu* this, int start_msec, int length_msec ) +{ + track_set_fade( &this->track_filter, msec_to_samples( start_msec, this->sample_rate ), + length_msec * this->sample_rate / (1000 / stereo) ); +} + +blargg_err_t Vgm_play( struct Vgm_Emu* this, int out_count, sample_t* out ) +{ + require( this->current_track >= 0 ); + require( out_count % stereo == 0 ); + return track_play( &this->track_filter, out_count, out ); +} diff --git a/lib/rbcodec/codecs/libgme/vgm_emu.h b/lib/rbcodec/codecs/libgme/vgm_emu.h new file mode 100644 index 0000000000..8c39482008 --- /dev/null +++ b/lib/rbcodec/codecs/libgme/vgm_emu.h @@ -0,0 +1,206 @@ +// Sega Master System/Mark III, Sega Genesis/Mega Drive, BBC Micro VGM music file emulator + +// Game_Music_Emu 0.6-pre +#ifndef VGM_EMU_H +#define VGM_EMU_H + +#include "blargg_common.h" +#include "blargg_source.h" + +#include "track_filter.h" +#include "resampler.h" +#include "multi_buffer.h" +#include "ym2413_emu.h" +#include "ym2612_emu.h" +#include "sms_apu.h" + +typedef int vgm_time_t; +typedef int fm_time_t; + +enum { fm_time_bits = 12 }; +enum { blip_time_bits = 12 }; + +// VGM header format +enum { header_size = 0x40 }; +struct header_t +{ + char tag [4]; + byte data_size [4]; + byte version [4]; + byte psg_rate [4]; + byte ym2413_rate [4]; + byte gd3_offset [4]; + byte track_duration [4]; + byte loop_offset [4]; + byte loop_duration [4]; + byte frame_rate [4]; + byte noise_feedback [2]; + byte noise_width; + byte unused1; + byte ym2612_rate [4]; + byte ym2151_rate [4]; + byte data_offset [4]; + byte unused2 [8]; +}; + +enum { gme_max_field = 63 }; +struct track_info_t +{ + /* times in milliseconds; -1 if unknown */ + int length; + int intro_length; + int loop_length; + + /* empty string if not available */ + char game [64]; + char song [96]; + char author [64]; +}; + +// Emulates VGM music using SN76489/SN76496 PSG, YM2612, and YM2413 FM sound chips. +// Supports custom sound buffer and frequency equalization when VGM uses just the PSG. +// FM sound chips can be run at their proper rates, or slightly higher to reduce +// aliasing on high notes. Currently YM2413 support requires that you supply a +// YM2413 sound chip emulator. I can provide one I've modified to work with the library. +struct Vgm_Emu { + int fm_rate; + int psg_rate; + int vgm_rate; + bool disable_oversampling; + + int fm_time_offset; + int fm_time_factor; + + int blip_time_factor; + + byte const* file_begin; + byte const* file_end; + + vgm_time_t vgm_time; + byte const* loop_begin; + byte const* pos; + + byte const* pcm_data; + byte const* pcm_pos; + int dac_amp; + int dac_disabled; // -1 if disabled + + // general + int current_track; + int clock_rate_; + unsigned buf_changed_count; + int max_initial_silence; + int voice_count; + int const *voice_types; + int mute_mask_; + int tempo; + int gain; + + int sample_rate; + + // larger items at the end + struct track_info_t info; + + struct setup_t tfilter; + struct Track_Filter track_filter; + + struct Ym2612_Emu ym2612; + struct Ym2413_Emu ym2413; + + struct Sms_Apu psg; + struct Blip_Synth pcm; + struct Blip_Buffer blip_buf; + + struct Resampler resampler; + struct Multi_Buffer stereo_buf; +}; + +void Vgm_init( struct Vgm_Emu* this ); + +// Disable running FM chips at higher than normal rate. Will result in slightly +// more aliasing of high notes. +static inline void Vgm_disable_oversampling( struct Vgm_Emu* this, bool disable ) { this->disable_oversampling = disable; } + +// Header for currently loaded file +static inline struct header_t *header( struct Vgm_Emu* this ) { return (struct header_t*) this->file_begin; } + +// Basic functionality (see Gme_File.h for file loading/track info functions) +blargg_err_t Vgm_load_mem( struct Vgm_Emu* this, byte const* new_data, long new_size, bool parse_info ); + +// True if any FM chips are used by file. Always false until init_fm() +// is called. +static inline bool uses_fm( struct Vgm_Emu* this ) { return Ym2612_enabled( &this->ym2612 ) || Ym2413_enabled( &this->ym2413 ); } + +// Set output sample rate. Must be called only once before loading file. +blargg_err_t Vgm_set_sample_rate( struct Vgm_Emu* this, int sample_rate ); + +// Start a track, where 0 is the first track. Also clears warning string. +blargg_err_t Vgm_start_track( struct Vgm_Emu* this ); + +// Generate 'count' samples info 'buf'. Output is in stereo. Any emulation +// errors set warning string, and major errors also end track. +blargg_err_t Vgm_play( struct Vgm_Emu* this, int count, sample_t* buf ); + +// Track status/control + +// Number of milliseconds (1000 msec = 1 second) played since beginning of track +int Track_tell( struct Vgm_Emu* this ); + +// Seek to new time in track. Seeking backwards or far forward can take a while. +blargg_err_t Track_seek( struct Vgm_Emu* this, int msec ); + +// Skip n samples +blargg_err_t Track_skip( struct Vgm_Emu* this, int n ); + +// Set start time and length of track fade out. Once fade ends track_ended() returns +// true. Fade time can be changed while track is playing. +void Track_set_fade( struct Vgm_Emu* this, int start_msec, int length_msec ); + +// True if a track has reached its end +static inline bool Track_ended( struct Vgm_Emu* this ) +{ + return track_ended( &this->track_filter ); +} + +// Disables automatic end-of-track detection and skipping of silence at beginning +static inline void Track_ignore_silence( struct Vgm_Emu* this, bool disable ) +{ + this->track_filter.silence_ignored_ = disable; +} + +// Get track length in milliseconds +static inline int Track_get_length( struct Vgm_Emu* this ) +{ + int length = this->info.length; + if ( length <= 0 ) + { + length = this->info.intro_length + 2 * this->info.loop_length; // intro + 2 loops + if ( length <= 0 ) + length = 150 * 1000; // 2.5 minutes + } + + return length; +} + +// Sound customization + +// Adjust song tempo, where 1.0 = normal, 0.5 = half speed, 2.0 = double speed. +// Track length as returned by track_info() assumes a tempo of 1.0. +void Sound_set_tempo( struct Vgm_Emu* this, int t ); + +// Mute/unmute voice i, where voice 0 is first voice +void Sound_mute_voice( struct Vgm_Emu* this, int index, bool mute ); + +// Set muting state of all voices at once using a bit mask, where -1 mutes them all, +// 0 unmutes them all, 0x01 mutes just the first voice, etc. +void Sound_mute_voices( struct Vgm_Emu* this, int mask ); + +// Change overall output amplitude, where 1.0 results in minimal clamping. +// Must be called before set_sample_rate(). +static inline void Sound_set_gain( struct Vgm_Emu* this, int g ) +{ + assert( !this->sample_rate ); // you must set gain before setting sample rate + this->gain = g; +} + +#endif diff --git a/lib/rbcodec/codecs/libgme/vrc7tone.h b/lib/rbcodec/codecs/libgme/vrc7tone.h new file mode 100644 index 0000000000..c589335c3c --- /dev/null +++ b/lib/rbcodec/codecs/libgme/vrc7tone.h @@ -0,0 +1,20 @@ +/* VRC7 TONES by okazaki@angel.ne.jp */ +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x33,0x01,0x09,0x0e,0x94,0x90,0x40,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x13,0x41,0x0f,0x0d,0xce,0xd3,0x43,0x13,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x01,0x12,0x1b,0x06,0xff,0xd2,0x00,0x32,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x61,0x61,0x1b,0x07,0xaf,0x63,0x20,0x28,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x22,0x21,0x1e,0x06,0xf0,0x76,0x08,0x28,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x66,0x21,0x15,0x00,0x93,0x94,0x20,0xf8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x21,0x61,0x1c,0x07,0x82,0x81,0x10,0x17,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x23,0x21,0x20,0x1f,0xc0,0x71,0x07,0x47,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x25,0x31,0x26,0x05,0x64,0x41,0x18,0xf8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x17,0x21,0x28,0x07,0xff,0x83,0x02,0xf8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x97,0x81,0x25,0x07,0xcf,0xc8,0x02,0x14,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x21,0x21,0x54,0x0f,0x80,0x7f,0x07,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x01,0x01,0x56,0x03,0xd3,0xb2,0x43,0x58,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x31,0x21,0x0c,0x03,0x82,0xc0,0x40,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x21,0x01,0x0c,0x03,0xd4,0xd3,0x40,0x84,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x07,0x21,0x14,0x00,0xee,0xf8,0xff,0xf8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x01,0x31,0x00,0x00,0xf8,0xf7,0xf8,0xf7,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x25,0x11,0x00,0x00,0xf8,0xfa,0xf8,0x55,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 diff --git a/lib/rbcodec/codecs/libgme/ym2413_emu.c b/lib/rbcodec/codecs/libgme/ym2413_emu.c new file mode 100644 index 0000000000..d9ada431ca --- /dev/null +++ b/lib/rbcodec/codecs/libgme/ym2413_emu.c @@ -0,0 +1,45 @@ +// Game_Music_Emu 0.5.5. http://www.slack.net/~ant/ + +#include "ym2413_emu.h" + +void Ym2413_init( struct Ym2413_Emu* this ) +{ + this->last_time = disabled_time; this->out = 0; +} + +int Ym2413_set_rate( struct Ym2413_Emu* this, int sample_rate, int clock_rate ) +{ + OPLL_new ( &this->opll, clock_rate, sample_rate ); + OPLL_reset_patch( &this->opll, OPLL_2413_TONE ); + + Ym2413_reset( this ); + return 0; +} + +void Ym2413_reset( struct Ym2413_Emu* this ) +{ + OPLL_reset( &this->opll ); + OPLL_setMask( &this->opll, 0 ); +} + +void Ym2413_write( struct Ym2413_Emu* this, int addr, int data ) +{ + OPLL_writeIO( &this->opll, 0, addr ); + OPLL_writeIO( &this->opll, 1, data ); +} + +void Ym2413_mute_voices( struct Ym2413_Emu* this, int mask ) +{ + OPLL_setMask( &this->opll, mask ); +} + +void Ym2413_run( struct Ym2413_Emu* this, int pair_count, short* out ) +{ + while ( pair_count-- ) + { + int s = OPLL_calc( &this->opll ) << 1; + out [0] = s; + out [1] = s; + out += 2; + } +} diff --git a/lib/rbcodec/codecs/libgme/ym2413_emu.h b/lib/rbcodec/codecs/libgme/ym2413_emu.h new file mode 100644 index 0000000000..8f52b04fbd --- /dev/null +++ b/lib/rbcodec/codecs/libgme/ym2413_emu.h @@ -0,0 +1,61 @@ +// YM2413 FM sound chip emulator interface + +// Game_Music_Emu 0.6-pre +#ifndef YM2413_EMU_H +#define YM2413_EMU_H + +#include "blargg_common.h" +#include "emu2413.h" + +enum { out_chan_count = 2 }; // stereo +enum { channel_count = 14 }; +enum { disabled_time = -1 }; + +struct Ym2413_Emu { + OPLL opll; + + // Impl + int last_time; + short* out; +}; + +void Ym2413_init( struct Ym2413_Emu* this ); + +static inline bool Ym2413_supported( void ) { return true; } + +// Sets output sample rate and chip clock rates, in Hz. Returns non-zero +// if error. +int Ym2413_set_rate( struct Ym2413_Emu* this, int sample_rate, int clock_rate ); + +// Resets to power-up state +void Ym2413_reset( struct Ym2413_Emu* this ); + +// Mutes voice n if bit n (1 << n) of mask is set +void Ym2413_mute_voices( struct Ym2413_Emu* this, int mask ); + +// Writes data to addr +void Ym2413_write( struct Ym2413_Emu* this, int addr, int data ); + +// Runs and writes pair_count*2 samples to output +void Ym2413_run( struct Ym2413_Emu* this, int pair_count, short* out ); + +static inline void Ym2413_enable( struct Ym2413_Emu* this, bool b ) { this->last_time = b ? 0 : disabled_time; } +static inline bool Ym2413_enabled( struct Ym2413_Emu* this ) { return this->last_time != disabled_time; } +static inline void Ym2413_begin_frame( struct Ym2413_Emu* this, short* buf ) { this->out = buf; this->last_time = 0; } + +static inline int Ym2413_run_until( struct Ym2413_Emu* this, int time ) +{ + int count = time - this->last_time; + if ( count > 0 ) + { + if ( this->last_time < 0 ) + return false; + this->last_time = time; + short* p = this->out; + this->out += count * out_chan_count; + Ym2413_run( this, count, p ); + } + return true; +} + +#endif diff --git a/lib/rbcodec/codecs/libgme/ym2612_emu.c b/lib/rbcodec/codecs/libgme/ym2612_emu.c new file mode 100644 index 0000000000..60df30a33c --- /dev/null +++ b/lib/rbcodec/codecs/libgme/ym2612_emu.c @@ -0,0 +1,1374 @@ +// Game_Music_Emu $vers. http://www.slack.net/~ant/ + +// Based on Gens 2.10 ym2612.c + +#include +#include +#include +#include +#include + +#include "ym2612_emu.h" + +/* Copyright (C) 2002 Stéphane Dallongeville (gens AT consolemul.com) */ +/* Copyright (C) 2004-2007 Shay Green. This module is free software; you +can redistribute it and/or modify it under the terms of the GNU Lesser +General Public License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. This +module is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +details. You should have received a copy of the GNU Lesser General Public +License along with this module; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ + +// This is mostly the original source in its C style and all. +// +// Somewhat optimized and simplified. Uses a template to generate the many +// variants of Update_Chan. Rewrote header file. In need of full rewrite by +// someone more familiar with FM sound and the YM2612. Has some inaccuracies +// compared to the Sega Genesis sound, particularly being mixed at such a +// high sample accuracy (the Genesis sounds like it has only 8 bit samples). +// - Shay + +// Ported again to c by gama. +// Not sure if performance is better than the original c version. + +#if !defined(YM2612_CALCUL_TABLES) + #include "ymtables.h" +#endif + +#ifdef YM2612_CALCUL_TABLES + #define FREQ_TAB_LOOKUP g->LFO_FREQ_TAB + #define ENV_TAB_LOOKUP g->LFO_ENV_TAB +#else + #define FREQ_TAB_LOOKUP lfo_freq_coeff + #define ENV_TAB_LOOKUP lfo_env_coeff +#endif + +const int output_bits = 14; + +static const unsigned char DT_DEF_TAB [4 * 32] = +{ +// FD = 0 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + +// FD = 1 + 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, + 2, 3, 3, 3, 4, 4, 4, 5, 5, 6, 6, 7, 8, 8, 8, 8, + +// FD = 2 + 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, + 5, 6, 6, 7, 8, 8, 9, 10, 11, 12, 13, 14, 16, 16, 16, 16, + +// FD = 3 + 2, 2, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 6, 6, 7, + 8 , 8, 9, 10, 11, 12, 13, 14, 16, 17, 19, 20, 22, 22, 22, 22 +}; + +static const unsigned char FKEY_TAB [16] = +{ + 0, 0, 0, 0, + 0, 0, 0, 1, + 2, 3, 3, 3, + 3, 3, 3, 3 +}; + +static const unsigned char LFO_AMS_TAB [4] = +{ + 31, 4, 1, 0 +}; + +static const unsigned char LFO_FMS_TAB [8] = +{ + LFO_FMS_BASE * 0, LFO_FMS_BASE * 1, + LFO_FMS_BASE * 2, LFO_FMS_BASE * 3, + LFO_FMS_BASE * 4, LFO_FMS_BASE * 6, + LFO_FMS_BASE * 12, LFO_FMS_BASE * 24 +}; + +int in0, in1, in2, in3; // current phase calculation +// int en0, en1, en2, en3; // current enveloppe calculation + +static inline void set_seg( struct slot_t* s, int seg ) +{ + s->env_xor = 0; + s->env_max = INT_MAX; + s->SEG = seg; + if ( seg & 4 ) + { + s->env_xor = ENV_MASK; + s->env_max = ENV_MASK; + } +} + +static inline void YM2612_Special_Update(void) { } + +static void KEY_ON( struct channel_* ch, struct tables_t *g, int nsl ) +{ + struct slot_t *SL = &(ch->SLOT [nsl]); // on recupere le bon pointeur de slot + + if (SL->Ecurp == RELEASE) // la touche est-elle rel'chee ? + { + SL->Fcnt = 0; + + // Fix Ecco 2 splash sound + + SL->Ecnt = (g->DECAY_TO_ATTACK [g->ENV_TAB [SL->Ecnt >> ENV_LBITS]] + ENV_ATTACK) & SL->ChgEnM; + SL->ChgEnM = ~0; + +// SL->Ecnt = g.DECAY_TO_ATTACK [g.ENV_TAB [SL->Ecnt >> ENV_LBITS]] + ENV_ATTACK; +// SL->Ecnt = 0; + + SL->Einc = SL->EincA; + SL->Ecmp = ENV_DECAY; + SL->Ecurp = ATTACK; + } +} + + +static void KEY_OFF( struct channel_* ch, struct tables_t *g, int nsl ) +{ + struct slot_t *SL = &(ch->SLOT [nsl]); // on recupere le bon pointeur de slot + + if (SL->Ecurp != RELEASE) // la touche est-elle appuyee ? + { + if (SL->Ecnt < ENV_DECAY) // attack phase ? + { + SL->Ecnt = (g->ENV_TAB [SL->Ecnt >> ENV_LBITS] << ENV_LBITS) + ENV_DECAY; + } + + SL->Einc = SL->EincR; + SL->Ecmp = ENV_END; + SL->Ecurp = RELEASE; + } +} + + +static int SLOT_SET( struct Ym2612_Impl* impl, int Adr, int data ) +{ + int nch = Adr & 3; + if ( nch == 3 ) + return 1; + + struct tables_t *g = &impl->g; + struct state_t *YM2612 = &impl->YM2612; + struct channel_* ch = &YM2612->CHANNEL [nch + (Adr & 0x100 ? 3 : 0)]; + struct slot_t* sl = &ch->SLOT [(Adr >> 2) & 3]; + + switch ( Adr & 0xF0 ) + { + case 0x30: + if ( (sl->MUL = (data & 0x0F)) != 0 ) sl->MUL <<= 1; + else sl->MUL = 1; + + sl->DT = (int*) g->DT_TAB [(data >> 4) & 7]; + + ch->SLOT [0].Finc = -1; + + break; + + case 0x40: + sl->TL = data & 0x7F; + + // SOR2 do a lot of TL adjustement and this fix R.Shinobi jump sound... + YM2612_Special_Update(); + +#if ((ENV_HBITS - 7) < 0) + sl->TLL = sl->TL >> (7 - ENV_HBITS); +#else + sl->TLL = sl->TL << (ENV_HBITS - 7); +#endif + + break; + + case 0x50: + sl->KSR_S = 3 - (data >> 6); + + ch->SLOT [0].Finc = -1; + + if (data &= 0x1F) sl->AR = (int*) &g->AR_TAB [data << 1]; + else sl->AR = (int*) &g->NULL_RATE [0]; + + sl->EincA = sl->AR [sl->KSR]; + if (sl->Ecurp == ATTACK) sl->Einc = sl->EincA; + break; + + case 0x60: + if ( (sl->AMSon = (data & 0x80)) != 0 ) sl->AMS = ch->AMS; + else sl->AMS = 31; + + if (data &= 0x1F) sl->DR = (int*) &g->DR_TAB [data << 1]; + else sl->DR = (int*) &g->NULL_RATE [0]; + + sl->EincD = sl->DR [sl->KSR]; + if (sl->Ecurp == DECAY) sl->Einc = sl->EincD; + break; + + case 0x70: + if (data &= 0x1F) sl->SR = (int*) &g->DR_TAB [data << 1]; + else sl->SR = (int*) &g->NULL_RATE [0]; + + sl->EincS = sl->SR [sl->KSR]; + if ((sl->Ecurp == SUBSTAIN) && (sl->Ecnt < ENV_END)) sl->Einc = sl->EincS; + break; + + case 0x80: + sl->SLL = g->SL_TAB [data >> 4]; + + sl->RR = (int*) &g->DR_TAB [((data & 0xF) << 2) + 2]; + + sl->EincR = sl->RR [sl->KSR]; + if ((sl->Ecurp == RELEASE) && (sl->Ecnt < ENV_END)) sl->Einc = sl->EincR; + break; + + case 0x90: + // SSG-EG envelope shapes : + /* + E At Al H + + 1 0 0 0 \\\\ + 1 0 0 1 \___ + 1 0 1 0 \/\/ + 1 0 1 1 \ + 1 1 0 0 //// + 1 1 0 1 / + 1 1 1 0 /\/\ + 1 1 1 1 /___ + + E = SSG-EG enable + At = Start negate + Al = Altern + H = Hold */ + + set_seg( sl, (data & 8) ? (data & 0x0F) : 0 ); + break; + } + + return 0; +} + + +static int CHANNEL_SET( struct state_t* YM2612, int Adr, int data ) +{ + int num = Adr & 3; + if ( num == 3 ) + return 1; + + struct channel_* ch = &YM2612->CHANNEL [num + (Adr & 0x100 ? 3 : 0)]; + + switch ( Adr & 0xFC ) + { + case 0xA0: + YM2612_Special_Update(); + + ch->FNUM [0] = (ch->FNUM [0] & 0x700) + data; + ch->KC [0] = (ch->FOCT [0] << 2) | FKEY_TAB [ch->FNUM [0] >> 7]; + + ch->SLOT [0].Finc = -1; + break; + + case 0xA4: + YM2612_Special_Update(); + + ch->FNUM [0] = (ch->FNUM [0] & 0x0FF) + ((data & 0x07) << 8); + ch->FOCT [0] = (data & 0x38) >> 3; + ch->KC [0] = (ch->FOCT [0] << 2) | FKEY_TAB [ch->FNUM [0] >> 7]; + + ch->SLOT [0].Finc = -1; + break; + + case 0xA8: + if ( Adr < 0x100 ) + { + num++; + + YM2612_Special_Update(); + + YM2612->CHANNEL [2].FNUM [num] = (YM2612->CHANNEL [2].FNUM [num] & 0x700) + data; + YM2612->CHANNEL [2].KC [num] = (YM2612->CHANNEL [2].FOCT [num] << 2) | + FKEY_TAB [YM2612->CHANNEL [2].FNUM [num] >> 7]; + + YM2612->CHANNEL [2].SLOT [0].Finc = -1; + } + break; + + case 0xAC: + if ( Adr < 0x100 ) + { + num++; + + YM2612_Special_Update(); + + YM2612->CHANNEL [2].FNUM [num] = (YM2612->CHANNEL [2].FNUM [num] & 0x0FF) + ((data & 0x07) << 8); + YM2612->CHANNEL [2].FOCT [num] = (data & 0x38) >> 3; + YM2612->CHANNEL [2].KC [num] = (YM2612->CHANNEL [2].FOCT [num] << 2) | + FKEY_TAB [YM2612->CHANNEL [2].FNUM [num] >> 7]; + + YM2612->CHANNEL [2].SLOT [0].Finc = -1; + } + break; + + case 0xB0: + if ( ch->ALGO != (data & 7) ) + { + // Fix VectorMan 2 heli sound (level 1) + YM2612_Special_Update(); + + ch->ALGO = data & 7; + + ch->SLOT [0].ChgEnM = 0; + ch->SLOT [1].ChgEnM = 0; + ch->SLOT [2].ChgEnM = 0; + ch->SLOT [3].ChgEnM = 0; + } + + ch->FB = 9 - ((data >> 3) & 7); // Real thing ? + +// if (ch->FB = ((data >> 3) & 7)) ch->FB = 9 - ch->FB; // Thunder force 4 (music stage 8), Gynoug, Aladdin bug sound... +// else ch->FB = 31; + break; + + case 0xB4: { + YM2612_Special_Update(); + + ch->LEFT = 0 - ((data >> 7) & 1); + ch->RIGHT = 0 - ((data >> 6) & 1); + + ch->AMS = LFO_AMS_TAB [(data >> 4) & 3]; + ch->FMS = LFO_FMS_TAB [data & 7]; + + int i; + for ( i = 0; i < 4; i++ ) + { + struct slot_t* sl = &ch->SLOT [i]; + sl->AMS = (sl->AMSon ? ch->AMS : 31); + } + break; + } + } + + return 0; +} + + +static int YM_SET( struct Ym2612_Impl* impl, int Adr, int data ) +{ + struct state_t* YM2612 = &impl->YM2612; + struct tables_t* g = &impl->g; + switch ( Adr ) + { + case 0x22: + if (data & 8) // LFO enable + { + // Cool Spot music 1, LFO modified severals time which + // distord the sound, have to check that on a real genesis... + + g->LFOinc = g->LFO_INC_TAB [data & 7]; + } + else + { + g->LFOinc = g->LFOcnt = 0; + } + break; + + case 0x24: + YM2612->TimerA = (YM2612->TimerA & 0x003) | (((int) data) << 2); + + if (YM2612->TimerAL != (1024 - YM2612->TimerA) << 12) + { + YM2612->TimerAcnt = YM2612->TimerAL = (1024 - YM2612->TimerA) << 12; + } + break; + + case 0x25: + YM2612->TimerA = (YM2612->TimerA & 0x3FC) | (data & 3); + + if (YM2612->TimerAL != (1024 - YM2612->TimerA) << 12) + { + YM2612->TimerAcnt = YM2612->TimerAL = (1024 - YM2612->TimerA) << 12; + } + break; + + case 0x26: + YM2612->TimerB = data; + + if (YM2612->TimerBL != (256 - YM2612->TimerB) << (4 + 12)) + { + YM2612->TimerBcnt = YM2612->TimerBL = (256 - YM2612->TimerB) << (4 + 12); + } + break; + + case 0x27: + // Parametre divers + // b7 = CSM MODE + // b6 = 3 slot mode + // b5 = reset b + // b4 = reset a + // b3 = timer enable b + // b2 = timer enable a + // b1 = load b + // b0 = load a + + if ((data ^ YM2612->Mode) & 0x40) + { + // We changed the channel 2 mode, so recalculate phase step + // This fix the punch sound in Street of Rage 2 + + YM2612_Special_Update(); + + YM2612->CHANNEL [2].SLOT [0].Finc = -1; // recalculate phase step + } + +// if ((data & 2) && (YM2612->Status & 2)) YM2612->TimerBcnt = YM2612->TimerBL; +// if ((data & 1) && (YM2612->Status & 1)) YM2612->TimerAcnt = YM2612->TimerAL; + +// YM2612->Status &= (~data >> 4); // Reset du Status au cas ou c'est demande + YM2612->Status &= (~data >> 4) & (data >> 2); // Reset Status + + YM2612->Mode = data; + break; + + case 0x28: { + int nch = data & 3; + if ( nch == 3 ) + return 1; + if ( data & 4 ) + nch += 3; + struct channel_* ch = &YM2612->CHANNEL [nch]; + + YM2612_Special_Update(); + + if (data & 0x10) KEY_ON(ch, g, S0); // On appuie sur la touche pour le slot 1 + else KEY_OFF(ch, g, S0); // On rel'che la touche pour le slot 1 + if (data & 0x20) KEY_ON(ch, g, S1); // On appuie sur la touche pour le slot 3 + else KEY_OFF(ch, g, S1); // On rel'che la touche pour le slot 3 + if (data & 0x40) KEY_ON(ch, g, S2); // On appuie sur la touche pour le slot 2 + else KEY_OFF(ch, g, S2); // On rel'che la touche pour le slot 2 + if (data & 0x80) KEY_ON(ch, g, S3); // On appuie sur la touche pour le slot 4 + else KEY_OFF(ch, g, S3); // On rel'che la touche pour le slot 4 + break; + } + + case 0x2B: + if (YM2612->DAC ^ (data & 0x80)) YM2612_Special_Update(); + + YM2612->DAC = data & 0x80; // activation/desactivation du DAC + break; + } + + return 0; +} + +void impl_reset( struct Ym2612_Impl* impl ); +static void impl_set_rate( struct Ym2612_Impl* impl, int sample_rate, int clock_rate ) +{ + assert( sample_rate ); + assert( !clock_rate || clock_rate > sample_rate ); + + int i; + + // 144 = 12 * (prescale * 2) = 12 * 6 * 2 + // prescale set to 6 by default + + int Frequency = (clock_rate ? (int)((FP_ONE_CLOCK * clock_rate) / sample_rate / 144) : (int)FP_ONE_CLOCK); + if ( abs( Frequency - FP_ONE_CLOCK ) < 1 ) + Frequency = FP_ONE_CLOCK; + impl->YM2612.TimerBase = Frequency; + + /* double Frequence = (double)Frequency / FP_ONE_CLOCK; */ + + // Tableau TL : + // [0 - 4095] = +output [4095 - ...] = +output overflow (fill with 0) + // [12288 - 16383] = -output [16384 - ...] = -output overflow (fill with 0) + +#ifdef YM2612_USE_TL_TAB + for ( i = 0; i < TL_LENGHT; i++ ) + { + if (i >= PG_CUT_OFF) // YM2612 cut off sound after 78 dB (14 bits output ?) + { + impl->g.TL_TAB [TL_LENGHT + i] = impl->g.TL_TAB [i] = 0; + } + else + { + // Decibel -> Voltage + #ifdef YM2612_CALCUL_TABLES + impl->g.TL_TAB [i] = (int) (MAX_OUT / pow( 10.0, ENV_STEP / 20.0f * i )); + #else + impl->g.TL_TAB [i] = tl_coeff [i]; + #endif + impl->g.TL_TAB [TL_LENGHT + i] = -impl->g.TL_TAB [i]; + } + } +#endif + + // Tableau SIN : + // impl->g.SIN_TAB [x] [y] = sin(x) * y; + // x = phase and y = volume + + impl->g.SIN_TAB [0] = impl->g.SIN_TAB [SIN_LENGHT / 2] = PG_CUT_OFF; + + for ( i = 1; i <= SIN_LENGHT / 4; i++ ) + { + // Sinus in dB + #ifdef YM2612_CALCUL_TABLES + double x = 20 * log10( 1 / sin( 2.0 * PI * i / SIN_LENGHT ) ); // convert to dB + + int j = (int) (x / ENV_STEP); // Get TL range + + if (j > PG_CUT_OFF) j = (int) PG_CUT_OFF; + #else + int j = sindb_coeff [i-1]; + #endif + + impl->g.SIN_TAB [i] = impl->g.SIN_TAB [(SIN_LENGHT / 2) - i] = j; + impl->g.SIN_TAB [(SIN_LENGHT / 2) + i] = impl->g.SIN_TAB [SIN_LENGHT - i] = TL_LENGHT + j; + } + + #ifdef YM2612_CALCUL_TABLES + // Tableau LFO (LFO wav) : + for ( i = 0; i < LFO_LENGHT; i++ ) + { + double x = 1 + sin( 2.0 * PI * i * (1.0 / LFO_LENGHT) ); // Sinus + x *= 11.8 / ENV_STEP / 2; // ajusted to MAX enveloppe modulation + + impl->g.LFO_ENV_TAB [i] = (int) x; + + x = sin( 2.0 * PI * i * (1.0 / LFO_LENGHT) ); // Sinus + x *= (1 << (LFO_HBITS - 1)) - 1; + + impl->g.LFO_FREQ_TAB [i] = (int) x; + } + #endif + + // Tableau Enveloppe : + // impl->g.ENV_TAB [0] -> impl->g.ENV_TAB [ENV_LENGHT - 1] = attack curve + // impl->g.ENV_TAB [ENV_LENGHT] -> impl->g.ENV_TAB [2 * ENV_LENGHT - 1] = decay curve + + for ( i = 0; i < ENV_LENGHT; i++ ) + { + // Attack curve (x^8 - music level 2 Vectorman 2) + #if defined(ROCKBOX) + int k; + int prescale = (31 - 2*ENV_HBITS); /* used to gain higher precision */ + int x = ENV_LENGHT * (1 << prescale); + for ( k = 0; k < 8; ++k) + { + x = ( x * ((ENV_LENGHT - 1) - i) ) / ENV_LENGHT; + } + x >>= prescale; + #else + double x = pow( ((ENV_LENGHT - 1) - i) / (double) ENV_LENGHT, 8.0 ); + x *= ENV_LENGHT; + #endif + + impl->g.ENV_TAB [i] = (int) x; + + // Decay curve (just linear) + impl->g.ENV_TAB [ENV_LENGHT + i] = i; + } + for ( i = 0; i < 8; i++ ) + impl->g.ENV_TAB [i + ENV_LENGHT * 2] = 0; + + impl->g.ENV_TAB [ENV_END >> ENV_LBITS] = ENV_LENGHT - 1; // for the stopped state + + // Tableau pour la conversion Attack -> Decay and Decay -> Attack + + int j = ENV_LENGHT - 1; + for ( i = 0; i < ENV_LENGHT; i++ ) + { + while ( j && impl->g.ENV_TAB [j] < i ) + j--; + + impl->g.DECAY_TO_ATTACK [i] = j << ENV_LBITS; + } + + // Tableau pour le Substain Level + + for ( i = 0; i < 15; i++ ) + { + int x = i * 3 * (int)( (1 << ENV_LBITS) / ENV_STEP); // 3 and not 6 (Mickey Mania first music for test) + + impl->g.SL_TAB [i] = x + ENV_DECAY; + } + + impl->g.SL_TAB [15] = ((ENV_LENGHT - 1) << ENV_LBITS) + ENV_DECAY; // special case : volume off + + // Tableau Frequency Step + + { + // * 1 / 2 because MUL = value * 2 + #if SIN_LBITS + SIN_HBITS - (21 - 7) < 0 + /* double const factor = Frequence / 2.0 / (1 << ((21 - 7) - SIN_LBITS - SIN_HBITS)); */ + int const factor = (int)(Frequency / 2 / (1 << ((21 - 7) - SIN_LBITS - SIN_HBITS)) / FP_ONE_CLOCK); + #else + /* double const factor = Frequence / 2.0 * (1 << (SIN_LBITS + SIN_HBITS - (21 - 7))); */ + int const factor = (int)(Frequency / 2 * (1 << (SIN_LBITS + SIN_HBITS - (21 - 7))) / FP_ONE_CLOCK); + #endif + for ( i = 0; i < 2048; i++ ) + { + impl->g.FINC_TAB [i] = i * factor; + } + } + + // Tableaux Attack & Decay Rate + + for ( i = 0; i < 4; i++ ) + { + impl->g.AR_TAB [i] = 0; + impl->g.DR_TAB [i] = 0; + } + + for ( i = 0; i < 60; i++ ) + { + long long x = + (4LL + ((i & 3))) * // bits 0-1 : 4*(x1.00, x1.25, x1.50, x1.75) + (ENV_LENGHT << ENV_LBITS) * // on ajuste pour le tableau impl->g.ENV_TAB + Frequency * + (1 << (i >> 2)) / // bits 2-5 : shift bits (x2^0 - x2^15) + FP_ONE_CLOCK / 4; + + long long x_AR = x / AR_RATE; + long long x_DR = x / DR_RATE; + + impl->g.AR_TAB [i + 4] = (unsigned int) ( x_AR > ((1LL<<32) - 1) ? ((1LL<<32) - 1) : x_AR ); + impl->g.DR_TAB [i + 4] = (unsigned int) ( x_DR > ((1LL<<32) - 1) ? ((1LL<<32) - 1) : x_DR ); + } + + for ( i = 64; i < 96; i++ ) + { + impl->g.AR_TAB [i] = impl->g.AR_TAB [63]; + impl->g.DR_TAB [i] = impl->g.DR_TAB [63]; + + impl->g.NULL_RATE [i - 64] = 0; + } + + for ( i = 96; i < 128; i++ ) + impl->g.AR_TAB [i] = 0; + + // Tableau Detune + { + #if SIN_LBITS + SIN_HBITS - 21 < 0 + /* double const factor = 1.0 / (1 << (21 - SIN_LBITS - SIN_HBITS)) * Frequence; */ + int const factor = Frequency / (1 << (21 - SIN_LBITS - SIN_HBITS)) / FP_ONE_CLOCK; + #else + /* double const factor = (1 << (SIN_LBITS + SIN_HBITS - 21)) * Frequence; */ + int const factor = Frequency * (1 << (SIN_LBITS + SIN_HBITS - 21)) / FP_ONE_CLOCK; + #endif + for ( i = 0; i < 4; i++ ) + { + int j; + for ( j = 0; j < 32; j++ ) + { + /* double y = DT_DEF_TAB [(i << 5) + j] * factor; */ + int y = DT_DEF_TAB [(i << 5) + j] * factor; + + impl->g.DT_TAB [i + 0] [j] = (int) y; + impl->g.DT_TAB [i + 4] [j] = (int) -y; + } + } + } + + // Tableau LFO + impl->g.LFO_INC_TAB [0] = (int) (3.98 * (1 << (LFO_HBITS + LFO_LBITS))) / sample_rate; + impl->g.LFO_INC_TAB [1] = (int) (5.56 * (1 << (LFO_HBITS + LFO_LBITS))) / sample_rate; + impl->g.LFO_INC_TAB [2] = (int) (6.02 * (1 << (LFO_HBITS + LFO_LBITS))) / sample_rate; + impl->g.LFO_INC_TAB [3] = (int) (6.37 * (1 << (LFO_HBITS + LFO_LBITS))) / sample_rate; + impl->g.LFO_INC_TAB [4] = (int) (6.88 * (1 << (LFO_HBITS + LFO_LBITS))) / sample_rate; + impl->g.LFO_INC_TAB [5] = (int) (9.63 * (1 << (LFO_HBITS + LFO_LBITS))) / sample_rate; + impl->g.LFO_INC_TAB [6] = (int) (48.1 * (1 << (LFO_HBITS + LFO_LBITS))) / sample_rate; + impl->g.LFO_INC_TAB [7] = (int) (72.2 * (1 << (LFO_HBITS + LFO_LBITS))) / sample_rate; + + impl_reset( impl ); +} + +const char* Ym2612_set_rate( struct Ym2612_Emu* this, int sample_rate, int clock_rate ) +{ +// Only set rates if necessary +#if defined(ROCKBOX) + static int last_sample_rate = 0, last_clock_rate = 0; + if (last_sample_rate == sample_rate && last_clock_rate == clock_rate) return 0; +#endif + memset( &this->impl.YM2612, 0, sizeof this->impl.YM2612 ); + impl_set_rate( &this->impl, sample_rate, clock_rate ); + + return 0; +} + +static inline void write0( struct Ym2612_Impl* impl, int opn_addr, int data ) +{ + assert( (unsigned) data <= 0xFF ); + + if ( opn_addr < 0x30 ) + { + impl->YM2612.REG [0] [opn_addr] = data; + YM_SET( impl, opn_addr, data ); + } + else if ( impl->YM2612.REG [0] [opn_addr] != data ) + { + impl->YM2612.REG [0] [opn_addr] = data; + + if ( opn_addr < 0xA0 ) + SLOT_SET( impl, opn_addr, data ); + else + CHANNEL_SET( &impl->YM2612, opn_addr, data ); + } +} + +static inline void write1( struct Ym2612_Impl* impl, int opn_addr, int data ) +{ + assert( (unsigned) data <= 0xFF ); + + if ( opn_addr >= 0x30 && impl->YM2612.REG [1] [opn_addr] != data ) + { + impl->YM2612.REG [1] [opn_addr] = data; + + if ( opn_addr < 0xA0 ) + SLOT_SET( impl, opn_addr + 0x100, data ); + else + CHANNEL_SET( &impl->YM2612, opn_addr + 0x100, data ); + } +} + +void impl_reset( struct Ym2612_Impl* impl ) +{ + impl->g.LFOcnt = 0; + impl->YM2612.TimerA = 0; + impl->YM2612.TimerAL = 0; + impl->YM2612.TimerAcnt = 0; + impl->YM2612.TimerB = 0; + impl->YM2612.TimerBL = 0; + impl->YM2612.TimerBcnt = 0; + impl->YM2612.DAC = 0; + + impl->YM2612.Status = 0; + + int i; + for ( i = 0; i < ym2612_channel_count; i++ ) + { + struct channel_* ch = &impl->YM2612.CHANNEL [i]; + + ch->LEFT = ~0; + ch->RIGHT = ~0; + ch->ALGO = 0; + ch->FB = 31; + ch->FMS = 0; + ch->AMS = 0; + + int j; + for ( j = 0 ;j < 4 ; j++ ) + { + ch->S0_OUT [j] = 0; + ch->FNUM [j] = 0; + ch->FOCT [j] = 0; + ch->KC [j] = 0; + + ch->SLOT [j].Fcnt = 0; + ch->SLOT [j].Finc = 0; + ch->SLOT [j].Ecnt = ENV_END; // Put it at the end of Decay phase... + ch->SLOT [j].Einc = 0; + ch->SLOT [j].Ecmp = 0; + ch->SLOT [j].Ecurp = RELEASE; + + ch->SLOT [j].ChgEnM = 0; + } + } + + for ( i = 0; i < 0x100; i++ ) + { + impl->YM2612.REG [0] [i] = -1; + impl->YM2612.REG [1] [i] = -1; + } + + for ( i = 0xB6; i >= 0xB4; i-- ) + { + write0( impl, i, 0xC0 ); + write1( impl, i, 0xC0 ); + } + + for ( i = 0xB2; i >= 0x22; i-- ) + { + write0( impl, i, 0 ); + write1( impl, i, 0 ); + } + + write0( impl, 0x2A, 0x80 ); +} + +void Ym2612_reset( struct Ym2612_Emu* this ) +{ + impl_reset( &this->impl ); +} + +void Ym2612_write0( struct Ym2612_Emu* this, int addr, int data ) +{ + write0( &this->impl, addr, data ); +} + +void Ym2612_write1( struct Ym2612_Emu* this, int addr, int data ) +{ + write1( &this->impl, addr, data ); +} + +void Ym2612_mute_voices( struct Ym2612_Emu* this, int mask ) { this->impl.mute_mask = mask; } + +static void update_envelope_( struct slot_t* sl ) +{ + switch ( sl->Ecurp ) + { + case 0: + // Env_Attack_Next + + // Verified with Gynoug even in HQ (explode SFX) + sl->Ecnt = ENV_DECAY; + + sl->Einc = sl->EincD; + sl->Ecmp = sl->SLL; + sl->Ecurp = DECAY; + break; + + case 1: + // Env_Decay_Next + + // Verified with Gynoug even in HQ (explode SFX) + sl->Ecnt = sl->SLL; + + sl->Einc = sl->EincS; + sl->Ecmp = ENV_END; + sl->Ecurp = SUBSTAIN; + break; + + case 2: + // Env_Substain_Next(slot_t *SL) + if (sl->SEG & 8) // SSG envelope type + { + int release = sl->SEG & 1; + + if ( !release ) + { + // re KEY ON + + // sl->Fcnt = 0; + // sl->ChgEnM = ~0; + + sl->Ecnt = 0; + sl->Einc = sl->EincA; + sl->Ecmp = ENV_DECAY; + sl->Ecurp = ATTACK; + } + + set_seg( sl, (sl->SEG << 1) & 4 ); + + if ( !release ) + break; + } + // fall through + + case 3: + // Env_Release_Next + sl->Ecnt = ENV_END; + sl->Einc = 0; + sl->Ecmp = ENV_END + 1; + break; + + // default: no op + } +} + +static inline void update_envelope( struct slot_t* sl ) +{ + int ecmp = sl->Ecmp; + if ( (sl->Ecnt += sl->Einc) >= ecmp ) + update_envelope_( sl ); +} + + +typedef void (*ym2612_update_chan_t)( struct tables_t*, struct channel_*, short*, int ); + +#define GET_CURRENT_PHASE \ +int in0 = ch->SLOT[S0].Fcnt; \ +int in1 = ch->SLOT[S1].Fcnt; \ +int in2 = ch->SLOT[S2].Fcnt; \ +int in3 = ch->SLOT[S3].Fcnt; \ + +#define GET_CURRENT_LFO \ +int YM2612_LFOinc = g->LFOinc; \ +int YM2612_LFOcnt = g->LFOcnt + YM2612_LFOinc; + +#define CALC_EN( x ) \ + int temp##x = ENV_TAB [ch->SLOT [S##x].Ecnt >> ENV_LBITS] + ch->SLOT [S##x].TLL; \ + int en##x = ((temp##x ^ ch->SLOT [S##x].env_xor) + (env_LFO >> ch->SLOT [S##x].AMS)) & \ + ((temp##x - ch->SLOT [S##x].env_max) >> 31); + +#define GET_ENV \ +int const env_LFO = ENV_TAB_LOOKUP [YM2612_LFOcnt >> LFO_LBITS & LFO_MASK]; \ +short const* const ENV_TAB = g->ENV_TAB; \ +CALC_EN( 0 ) \ +CALC_EN( 1 ) \ +CALC_EN( 2 ) \ +CALC_EN( 3 ) + +#ifndef YM2612_USE_TL_TAB +static inline int tl_level( int i ) +{ + if (i >= (PG_CUT_OFF + TL_LENGHT)) { + return 0; + } else if (i >= TL_LENGHT) { + return -tl_coeff [i - TL_LENGHT]; + } else if (i >= PG_CUT_OFF) { + return 0; + } else + return tl_coeff [i]; +} +#define SINT( i, o ) (tl_level (g->SIN_TAB [(i)] + (o))) +#else +#define SINT( i, o ) (g->TL_TAB [g->SIN_TAB [(i)] + (o)]) +#endif + +#define DO_FEEDBACK \ +int CH_S0_OUT_0 = ch->S0_OUT [0]; \ +{ \ + int temp = in0 + ((CH_S0_OUT_0 + CH_S0_OUT_1) >> ch->FB); \ + CH_S0_OUT_1 = CH_S0_OUT_0; \ + CH_S0_OUT_0 = SINT( (temp >> SIN_LBITS) & SIN_MASK, en0 ); \ +} \ + +#define DO_LIMIT \ +CH_OUTd >>= MAX_OUT_BITS - output_bits + 2; \ + +#define UPDATE_PHASE_CYCLE \ +unsigned freq_LFO = ((FREQ_TAB_LOOKUP [YM2612_LFOcnt >> LFO_LBITS & LFO_MASK] * \ + ch->FMS) >> (LFO_HBITS - 1 + 1)) + (1 << (LFO_FMS_LBITS - 1)); \ +YM2612_LFOcnt += YM2612_LFOinc; \ +in0 += (ch->SLOT [S0].Finc * freq_LFO) >> (LFO_FMS_LBITS - 1); \ +in1 += (ch->SLOT [S1].Finc * freq_LFO) >> (LFO_FMS_LBITS - 1); \ +in2 += (ch->SLOT [S2].Finc * freq_LFO) >> (LFO_FMS_LBITS - 1); \ +in3 += (ch->SLOT [S3].Finc * freq_LFO) >> (LFO_FMS_LBITS - 1); + +#define UPDATE_ENV \ +int t0 = buf [0] + (CH_OUTd & ch->LEFT); \ +int t1 = buf [1] + (CH_OUTd & ch->RIGHT); \ +update_envelope( &ch->SLOT [0] ); \ +update_envelope( &ch->SLOT [1] ); \ +update_envelope( &ch->SLOT [2] ); \ +update_envelope( &ch->SLOT [3] ); + +#define DO_OUTPUT_0 \ +ch->S0_OUT [0] = CH_S0_OUT_0; \ +buf [0] = t0; \ +buf [1] = t1; \ +buf += 2; \ + +#define DO_OUTPUT_1 \ +ch->S0_OUT [1] = CH_S0_OUT_1; + +#define UPDATE_PHASE \ +ch->SLOT [S0].Fcnt = in0; \ +ch->SLOT [S1].Fcnt = in1; \ +ch->SLOT [S2].Fcnt = in2; \ +ch->SLOT [S3].Fcnt = in3; + +static void ym2612_update_chan0( struct tables_t* g, struct channel_* ch, + short* buf, int length ) +{ + int not_end = ch->SLOT [S3].Ecnt - ENV_END; + int CH_S0_OUT_1 = ch->S0_OUT [1]; + + GET_CURRENT_PHASE + GET_CURRENT_LFO + + if ( !not_end ) + return; + + do + { + GET_ENV + DO_FEEDBACK + + int CH_OUTd; + int temp = in1 + CH_S0_OUT_1; + temp = in2 + SINT( (temp >> SIN_LBITS) & SIN_MASK, en1 ); + temp = in3 + SINT( (temp >> SIN_LBITS) & SIN_MASK, en2 ); + CH_OUTd = SINT( (temp >> SIN_LBITS) & SIN_MASK, en3 ); + + DO_LIMIT + UPDATE_PHASE_CYCLE + UPDATE_ENV + DO_OUTPUT_0 + } + while ( --length ); + DO_OUTPUT_1 + UPDATE_PHASE +} + +static void ym2612_update_chan1( struct tables_t* g, struct channel_* ch, + short* buf, int length ) +{ + int not_end = ch->SLOT [S3].Ecnt - ENV_END; + int CH_S0_OUT_1 = ch->S0_OUT [1]; + + GET_CURRENT_PHASE + GET_CURRENT_LFO + + if ( !not_end ) + return; + + do + { + GET_ENV + DO_FEEDBACK + + int CH_OUTd; + int temp = in2 + CH_S0_OUT_1 + SINT( (in1 >> SIN_LBITS) & SIN_MASK, en1 ); + temp = in3 + SINT( (temp >> SIN_LBITS) & SIN_MASK, en2 ); + CH_OUTd = SINT( (temp >> SIN_LBITS) & SIN_MASK, en3 ); + + DO_LIMIT + UPDATE_PHASE_CYCLE + UPDATE_ENV + DO_OUTPUT_0 + } + while ( --length ); + DO_OUTPUT_1 + UPDATE_PHASE +} + +static void ym2612_update_chan2( struct tables_t* g, struct channel_* ch, + short* buf, int length ) +{ + int not_end = ch->SLOT [S3].Ecnt - ENV_END; + int CH_S0_OUT_1 = ch->S0_OUT [1]; + + GET_CURRENT_PHASE + GET_CURRENT_LFO + + if ( !not_end ) + return; + + do + { + GET_ENV + DO_FEEDBACK + + int CH_OUTd; + int temp = in2 + SINT( (in1 >> SIN_LBITS) & SIN_MASK, en1 ); + temp = in3 + CH_S0_OUT_1 + SINT( (temp >> SIN_LBITS) & SIN_MASK, en2 ); + CH_OUTd = SINT( (temp >> SIN_LBITS) & SIN_MASK, en3 ); + + DO_LIMIT + UPDATE_PHASE_CYCLE + UPDATE_ENV + DO_OUTPUT_0 + } + while ( --length ); + DO_OUTPUT_1 + UPDATE_PHASE +} + +static void ym2612_update_chan3( struct tables_t* g, struct channel_* ch, + short* buf, int length ) +{ + int not_end = ch->SLOT [S3].Ecnt - ENV_END; + int CH_S0_OUT_1 = ch->S0_OUT [1]; + + GET_CURRENT_PHASE + GET_CURRENT_LFO + + if ( !not_end ) + return; + + do + { + GET_ENV + DO_FEEDBACK + + int CH_OUTd; + int temp = in1 + CH_S0_OUT_1; + temp = in3 + SINT( (temp >> SIN_LBITS) & SIN_MASK, en1 ) + + SINT( (in2 >> SIN_LBITS) & SIN_MASK, en2 ); + CH_OUTd = SINT( (temp >> SIN_LBITS) & SIN_MASK, en3 ); + + DO_LIMIT + UPDATE_PHASE_CYCLE + UPDATE_ENV + DO_OUTPUT_0 + } + while ( --length ); + DO_OUTPUT_1 + UPDATE_PHASE +} + +static void ym2612_update_chan4( struct tables_t* g, struct channel_* ch, + short* buf, int length ) +{ + int not_end = ch->SLOT [S3].Ecnt - ENV_END; + not_end |= ch->SLOT [S1].Ecnt - ENV_END; + + int CH_S0_OUT_1 = ch->S0_OUT [1]; + + GET_CURRENT_PHASE + GET_CURRENT_LFO + + if ( !not_end ) + return; + + do + { + GET_ENV + DO_FEEDBACK + + int CH_OUTd; + int temp = in3 + SINT( (in2 >> SIN_LBITS) & SIN_MASK, en2 ); + CH_OUTd = SINT( (temp >> SIN_LBITS) & SIN_MASK, en3 ) + + SINT( ((in1 + CH_S0_OUT_1) >> SIN_LBITS) & SIN_MASK, en1 ); + + DO_LIMIT + UPDATE_PHASE_CYCLE + UPDATE_ENV + DO_OUTPUT_0 + } + while ( --length ); + DO_OUTPUT_1 + UPDATE_PHASE +} + +static void ym2612_update_chan5( struct tables_t* g, struct channel_* ch, + short* buf, int length ) +{ + int not_end = ch->SLOT [S3].Ecnt - ENV_END; + not_end |= ch->SLOT [S2].Ecnt - ENV_END; + not_end |= ch->SLOT [S1].Ecnt - ENV_END; + + int CH_S0_OUT_1 = ch->S0_OUT [1]; + + GET_CURRENT_PHASE + GET_CURRENT_LFO + + if ( !not_end ) + return; + + do + { + GET_ENV + DO_FEEDBACK + + int CH_OUTd; + int temp = CH_S0_OUT_1; + CH_OUTd = SINT( ((in3 + temp) >> SIN_LBITS) & SIN_MASK, en3 ) + + SINT( ((in1 + temp) >> SIN_LBITS) & SIN_MASK, en1 ) + + SINT( ((in2 + temp) >> SIN_LBITS) & SIN_MASK, en2 ); + + DO_LIMIT + UPDATE_PHASE_CYCLE + UPDATE_ENV + DO_OUTPUT_0 + } + while ( --length ); + DO_OUTPUT_1 + UPDATE_PHASE +} + +static void ym2612_update_chan6( struct tables_t* g, struct channel_* ch, + short* buf, int length ) +{ + int not_end = ch->SLOT [S3].Ecnt - ENV_END; + not_end |= ch->SLOT [S2].Ecnt - ENV_END; + not_end |= ch->SLOT [S1].Ecnt - ENV_END; + + int CH_S0_OUT_1 = ch->S0_OUT [1]; + + GET_CURRENT_PHASE + GET_CURRENT_LFO + + if ( !not_end ) + return; + + do + { + GET_ENV + DO_FEEDBACK + + int CH_OUTd; + CH_OUTd = SINT( (in3 >> SIN_LBITS) & SIN_MASK, en3 ) + + SINT( ((in1 + CH_S0_OUT_1) >> SIN_LBITS) & SIN_MASK, en1 ) + + SINT( (in2 >> SIN_LBITS) & SIN_MASK, en2 ); + + DO_LIMIT + UPDATE_PHASE_CYCLE + UPDATE_ENV + DO_OUTPUT_0 + } + while ( --length ); + DO_OUTPUT_1 + UPDATE_PHASE +} + +static void ym2612_update_chan7( struct tables_t* g, struct channel_* ch, + short* buf, int length ) +{ + int not_end = ch->SLOT [S3].Ecnt - ENV_END; + not_end |= ch->SLOT [S0].Ecnt - ENV_END; + not_end |= ch->SLOT [S2].Ecnt - ENV_END; + not_end |= ch->SLOT [S1].Ecnt - ENV_END; + + int CH_S0_OUT_1 = ch->S0_OUT [1]; + + GET_CURRENT_PHASE + GET_CURRENT_LFO + + if ( !not_end ) + return; + + do + { + GET_ENV + DO_FEEDBACK + + int CH_OUTd; + CH_OUTd = SINT( (in3 >> SIN_LBITS) & SIN_MASK, en3 ) + + SINT( (in1 >> SIN_LBITS) & SIN_MASK, en1 ) + + SINT( (in2 >> SIN_LBITS) & SIN_MASK, en2 ) + CH_S0_OUT_1; + + DO_LIMIT + UPDATE_PHASE_CYCLE + UPDATE_ENV + DO_OUTPUT_0 + } + while ( --length ); + DO_OUTPUT_1 + UPDATE_PHASE +} + +static void (*UPDATE_CHAN[8])(struct tables_t* g, struct channel_* ch, + short* buf, int length) = +{ + (void *)ym2612_update_chan0, + (void *)ym2612_update_chan1, + (void *)ym2612_update_chan2, + (void *)ym2612_update_chan3, + (void *)ym2612_update_chan4, + (void *)ym2612_update_chan5, + (void *)ym2612_update_chan6, + (void *)ym2612_update_chan7 +}; + +static void run_timer( struct Ym2612_Impl* impl, int length ) +{ + int const step = 6; + int remain = length; + do + { + int n = step; + if ( n > remain ) + n = remain; + remain -= n; + + int i = n * impl->YM2612.TimerBase; + if (impl->YM2612.Mode & 1) // Timer A ON ? + { + // if ((impl->YM2612.TimerAcnt -= 14073) <= 0) // 13879=NTSC (old: 14475=NTSC 14586=PAL) + if ((impl->YM2612.TimerAcnt -= i) <= 0) + { + // timer a overflow + + impl->YM2612.Status |= (impl->YM2612.Mode & 0x04) >> 2; + impl->YM2612.TimerAcnt += impl->YM2612.TimerAL; + + if (impl->YM2612.Mode & 0x80) + { + KEY_ON( &impl->YM2612.CHANNEL [2], &impl->g, 0 ); + KEY_ON( &impl->YM2612.CHANNEL [2], &impl->g, 1 ); + KEY_ON( &impl->YM2612.CHANNEL [2], &impl->g, 2 ); + KEY_ON( &impl->YM2612.CHANNEL [2], &impl->g, 3 ); + } + } + } + + if (impl->YM2612.Mode & 2) // Timer B ON ? + { + // if ((impl->YM2612.TimerBcnt -= 14073) <= 0) // 13879=NTSC (old: 14475=NTSC 14586=PAL) + if ((impl->YM2612.TimerBcnt -= i) <= 0) + { + // timer b overflow + impl->YM2612.Status |= (impl->YM2612.Mode & 0x08) >> 2; + impl->YM2612.TimerBcnt += impl->YM2612.TimerBL; + } + } + } + while ( remain > 0 ); +} + +static void impl_run( struct Ym2612_Impl* impl, int pair_count, short out [] ) +{ + if ( pair_count <= 0 ) + return; + + if ( impl->YM2612.Mode & 3 ) + run_timer( impl, pair_count ); + + // Mise à jour des pas des compteurs-frequences s'ils ont ete modifies + + int chi; + for ( chi = 0; chi < ym2612_channel_count; chi++ ) + { + struct channel_* ch = &impl->YM2612.CHANNEL [chi]; + if ( ch->SLOT [0].Finc != -1 ) + continue; + + int i2 = 0; + if ( chi == 2 && (impl->YM2612.Mode & 0x40) ) + i2 = 2; + + int i; + for ( i = 0; i < 4; i++ ) + { + // static int seq [4] = { 2, 1, 3, 0 }; + // if ( i2 ) i2 = seq [i]; + + struct slot_t* sl = &ch->SLOT [i]; + int finc = impl->g.FINC_TAB [ch->FNUM [i2]] >> (7 - ch->FOCT [i2]); + int ksr = ch->KC [i2] >> sl->KSR_S; // keycode attenuation + sl->Finc = (finc + sl->DT [ch->KC [i2]]) * sl->MUL; + if (sl->KSR != ksr) // si le KSR a change alors + { // les differents taux pour l'enveloppe sont mis à jour + sl->KSR = ksr; + + sl->EincA = sl->AR [ksr]; + sl->EincD = sl->DR [ksr]; + sl->EincS = sl->SR [ksr]; + sl->EincR = sl->RR [ksr]; + + if (sl->Ecurp == ATTACK) + { + sl->Einc = sl->EincA; + } + else if (sl->Ecurp == DECAY) + { + sl->Einc = sl->EincD; + } + else if (sl->Ecnt < ENV_END) + { + if (sl->Ecurp == SUBSTAIN) + sl->Einc = sl->EincS; + else if (sl->Ecurp == RELEASE) + sl->Einc = sl->EincR; + } + } + + if ( i2 ) + i2 = (i2 ^ 2) ^ (i2 >> 1); + } + } + + int i; + for ( i = 0; i < ym2612_channel_count; i++ ) + { + if ( !(impl->mute_mask & (1 << i)) && (i != 5 || !impl->YM2612.DAC) ) + UPDATE_CHAN [impl->YM2612.CHANNEL [i].ALGO]( &impl->g, &impl->YM2612.CHANNEL [i], out, pair_count ); + } + + impl->g.LFOcnt += impl->g.LFOinc * pair_count; +} + +void Ym2612_run( struct Ym2612_Emu* this, int pair_count, short out [] ) { impl_run( &this->impl, pair_count, out ); } diff --git a/lib/rbcodec/codecs/libgme/ym2612_emu.h b/lib/rbcodec/codecs/libgme/ym2612_emu.h new file mode 100644 index 0000000000..146d92a0a3 --- /dev/null +++ b/lib/rbcodec/codecs/libgme/ym2612_emu.h @@ -0,0 +1,248 @@ +// YM2612 FM sound chip emulator + +// Game_Music_Emu 0.6-pre +#ifndef YM2612_EMU_H +#define YM2612_EMU_H + +#include "blargg_common.h" + +#if !defined(ROCKBOX) + #define YM2612_CALCUL_TABLES +#endif + +#if MEMORYSIZE > 2 + #define YM2612_USE_TL_TAB +#endif + +enum { ym2612_out_chan_count = 2 }; // stereo +enum { ym2612_channel_count = 6 }; +enum { ym2612_disabled_time = -1 }; + +struct slot_t +{ + const int *DT; // parametre detune + int MUL; // parametre "multiple de frequence" + int TL; // Total Level = volume lorsque l'enveloppe est au plus haut + int TLL; // Total Level ajusted + int SLL; // Sustin Level (ajusted) = volume où l'enveloppe termine sa premiere phase de regression + int KSR_S; // Key Scale Rate Shift = facteur de prise en compte du KSL dans la variations de l'enveloppe + int KSR; // Key Scale Rate = cette valeur est calculee par rapport à la frequence actuelle, elle va influer + // sur les differents parametres de l'enveloppe comme l'attaque, le decay ... comme dans la realite ! + int SEG; // Type enveloppe SSG + int env_xor; + int env_max; + + const int *AR; // Attack Rate (table pointeur) = Taux d'attaque (AR [KSR]) + const int *DR; // Decay Rate (table pointeur) = Taux pour la regression (DR [KSR]) + const int *SR; // Sustin Rate (table pointeur) = Taux pour le maintien (SR [KSR]) + const int *RR; // Release Rate (table pointeur) = Taux pour le rel'chement (RR [KSR]) + int Fcnt; // Frequency Count = compteur-frequence pour determiner l'amplitude actuelle (SIN [Finc >> 16]) + int Finc; // frequency step = pas d'incrementation du compteur-frequence + // plus le pas est grand, plus la frequence est aïgu (ou haute) + int Ecurp; // Envelope current phase = cette variable permet de savoir dans quelle phase + // de l'enveloppe on se trouve, par exemple phase d'attaque ou phase de maintenue ... + // en fonction de la valeur de cette variable, on va appeler une fonction permettant + // de mettre à jour l'enveloppe courante. + int Ecnt; // Envelope counter = le compteur-enveloppe permet de savoir où l'on se trouve dans l'enveloppe + int Einc; // Envelope step courant + int Ecmp; // Envelope counter limite pour la prochaine phase + int EincA; // Envelope step for Attack = pas d'incrementation du compteur durant la phase d'attaque + // cette valeur est egal à AR [KSR] + int EincD; // Envelope step for Decay = pas d'incrementation du compteur durant la phase de regression + // cette valeur est egal à DR [KSR] + int EincS; // Envelope step for Sustain = pas d'incrementation du compteur durant la phase de maintenue + // cette valeur est egal à SR [KSR] + int EincR; // Envelope step for Release = pas d'incrementation du compteur durant la phase de rel'chement + // cette valeur est egal à RR [KSR] + int *OUTp; // pointeur of SLOT output = pointeur permettant de connecter la sortie de ce slot à l'entree + // d'un autre ou carrement à la sortie de la voie + int INd; // input data of the slot = donnees en entree du slot + int ChgEnM; // Change envelop mask. + int AMS; // AMS depth level of this SLOT = degre de modulation de l'amplitude par le LFO + int AMSon; // AMS enable flag = drapeau d'activation de l'AMS +}; + +struct channel_ +{ + int S0_OUT [4]; // anciennes sorties slot 0 (pour le feed back) + int LEFT; // LEFT enable flag + int RIGHT; // RIGHT enable flag + int ALGO; // Algorythm = determine les connections entre les operateurs + int FB; // shift count of self feed back = degre de "Feed-Back" du SLOT 1 (il est son unique entree) + int FMS; // Frequency Modulation Sensitivity of channel = degre de modulation de la frequence sur la voie par le LFO + int AMS; // Amplitude Modulation Sensitivity of channel = degre de modulation de l'amplitude sur la voie par le LFO + int FNUM [4]; // hauteur frequence de la voie (+ 3 pour le mode special) + int FOCT [4]; // octave de la voie (+ 3 pour le mode special) + int KC [4]; // Key Code = valeur fonction de la frequence (voir KSR pour les slots, KSR = KC >> KSR_S) + struct slot_t SLOT [4]; // four slot.operators = les 4 slots de la voie + int FFlag; // Frequency step recalculation flag +}; + +struct state_t +{ + int TimerBase; // TimerBase calculation + int Status; // YM2612 Status (timer overflow) + int TimerA; // timerA limit = valeur jusqu'à laquelle le timer A doit compter + int TimerAL; + int TimerAcnt; // timerA counter = valeur courante du Timer A + int TimerB; // timerB limit = valeur jusqu'à laquelle le timer B doit compter + int TimerBL; + int TimerBcnt; // timerB counter = valeur courante du Timer B + int Mode; // Mode actuel des voie 3 et 6 (normal / special) + int DAC; // DAC enabled flag + struct channel_ CHANNEL [ym2612_channel_count]; // Les 6 voies du YM2612 + int REG [2] [0x100]; // Sauvegardes des valeurs de tout les registres, c'est facultatif + // cela nous rend le debuggage plus facile +}; + +#undef PI +#define PI 3.14159265358979323846 + +#define ATTACK 0 +#define DECAY 1 +#define SUBSTAIN 2 +#define RELEASE 3 + +// SIN_LBITS <= 16 +// LFO_HBITS <= 16 +// (SIN_LBITS + SIN_HBITS) <= 26 +// (ENV_LBITS + ENV_HBITS) <= 28 +// (LFO_LBITS + LFO_HBITS) <= 28 + +#define SIN_HBITS 12 // Sinus phase counter int part +#define SIN_LBITS (26 - SIN_HBITS) // Sinus phase counter float part (best setting) + +#if (SIN_LBITS > 16) +#define SIN_LBITS 16 // Can't be greater than 16 bits +#endif + +#define ENV_HBITS 12 // Env phase counter int part +#define ENV_LBITS (28 - ENV_HBITS) // Env phase counter float part (best setting) + +#define LFO_HBITS 10 // LFO phase counter int part +#define LFO_LBITS (28 - LFO_HBITS) // LFO phase counter float part (best setting) + +#define SIN_LENGHT (1 << SIN_HBITS) +#define ENV_LENGHT (1 << ENV_HBITS) +#define LFO_LENGHT (1 << LFO_HBITS) + +#define TL_LENGHT (ENV_LENGHT * 3) // Env + TL scaling + LFO + +#define SIN_MASK (SIN_LENGHT - 1) +#define ENV_MASK (ENV_LENGHT - 1) +#define LFO_MASK (LFO_LENGHT - 1) + +#define ENV_STEP (96.0 / ENV_LENGHT) // ENV_MAX = 96 dB + +#define ENV_ATTACK ((ENV_LENGHT * 0) << ENV_LBITS) +#define ENV_DECAY ((ENV_LENGHT * 1) << ENV_LBITS) +#define ENV_END ((ENV_LENGHT * 2) << ENV_LBITS) + +#define MAX_OUT_BITS (SIN_HBITS + SIN_LBITS + 2) // Modulation = -4 <--> +4 +#define MAX_OUT ((1 << MAX_OUT_BITS) - 1) + +#define PG_CUT_OFF ((int) (78.0 / ENV_STEP)) +//#define ENV_CUT_OFF ((int) (68.0 / ENV_STEP)) + +#define AR_RATE 399128 +#define DR_RATE 5514396 + +//#define AR_RATE 426136 +//#define DR_RATE (AR_RATE * 12) + +#define LFO_FMS_LBITS 9 // FIXED (LFO_FMS_BASE gives somethink as 1) +#define LFO_FMS_BASE ((int) (0.05946309436 * 0.0338 * (double) (1 << LFO_FMS_LBITS))) + +#define S0 0 // Stupid typo of the YM2612 +#define S1 2 +#define S2 1 +#define S3 3 + +struct tables_t +{ + short SIN_TAB [SIN_LENGHT]; // SINUS TABLE (offset into TL TABLE) + int LFOcnt; // LFO counter = compteur-frequence pour le LFO + int LFOinc; // LFO step counter = pas d'incrementation du compteur-frequence du LFO + // plus le pas est grand, plus la frequence est grande + unsigned int AR_TAB [128]; // Attack rate table + unsigned int DR_TAB [96]; // Decay rate table + unsigned int DT_TAB [8] [32]; // Detune table + unsigned int SL_TAB [16]; // Substain level table + unsigned int NULL_RATE [32]; // Table for NULL rate + int LFO_INC_TAB [8]; // LFO step table + + short ENV_TAB [2 * ENV_LENGHT + 8]; // ENV CURVE TABLE (attack & decay) +#ifdef YM2612_CALCUL_TABLES + short LFO_ENV_TAB [LFO_LENGHT]; // LFO AMS TABLE (adjusted for 11.8 dB) + short LFO_FREQ_TAB [LFO_LENGHT]; // LFO FMS TABLE +#endif +#ifdef YM2612_USE_TL_TAB + int TL_TAB [TL_LENGHT * 2]; // TOTAL LEVEL TABLE (positif and minus) +#endif + unsigned int DECAY_TO_ATTACK [ENV_LENGHT]; // Conversion from decay to attack phase + unsigned int FINC_TAB [2048]; // Frequency step table +}; + +struct Ym2612_Impl +{ + struct state_t YM2612; + int mute_mask; + struct tables_t g; +}; + +void impl_reset( struct Ym2612_Impl* impl ); + +struct Ym2612_Emu { + struct Ym2612_Impl impl; + + // Impl + int last_time; + int sample_rate; + int clock_rate; + short* out; +}; + +static inline void Ym2612_init( struct Ym2612_Emu* this_ ) +{ + this_->last_time = ym2612_disabled_time; this_->out = 0; + this_->impl.mute_mask = 0; +} + +// Sets sample rate and chip clock rate, in Hz. Returns non-zero +// if error. If clock_rate=0, uses sample_rate*144 +const char* Ym2612_set_rate( struct Ym2612_Emu* this_, int sample_rate, int clock_rate ); + +// Resets to power-up state +void Ym2612_reset( struct Ym2612_Emu* this_ ); + +// Mutes voice n if bit n (1 << n) of mask is set +void Ym2612_mute_voices( struct Ym2612_Emu* this_, int mask ); + +// Writes addr to register 0 then data to register 1 +void Ym2612_write0( struct Ym2612_Emu* this_, int addr, int data ); + +// Writes addr to register 2 then data to register 3 +void Ym2612_write1( struct Ym2612_Emu* this_, int addr, int data ); + +// Runs and adds pair_count*2 samples into current output buffer contents +void Ym2612_run( struct Ym2612_Emu* this_, int pair_count, short* out ); + +static inline void Ym2612_enable( struct Ym2612_Emu* this_, bool b ) { this_->last_time = b ? 0 : ym2612_disabled_time; } +static inline bool Ym2612_enabled( struct Ym2612_Emu* this_ ) { return this_->last_time != ym2612_disabled_time; } +static inline void Ym2612_begin_frame( struct Ym2612_Emu* this_, short* buf ) { this_->out = buf; this_->last_time = 0; } + +static inline int Ym2612_run_until( struct Ym2612_Emu* this_, int time ) +{ + int count = time - this_->last_time; + if ( count > 0 ) + { + if ( this_->last_time < 0 ) + return false; + this_->last_time = time; + short* p = this_->out; + this_->out += count * ym2612_out_chan_count; + Ym2612_run( this_, count, p ); + } + return true; +} +#endif diff --git a/lib/rbcodec/codecs/libgme/ymtables.h b/lib/rbcodec/codecs/libgme/ymtables.h new file mode 100644 index 0000000000..c1619026b2 --- /dev/null +++ b/lib/rbcodec/codecs/libgme/ymtables.h @@ -0,0 +1,559 @@ +#ifndef _EMUTABLES_H_ +#define _EMUTABLES_H_ + +/* Precompiled ym2612 tables for use in Rockbox */ + +static const int tl_coeff[] = { + 268435455, 267712100, 266990695, 266271234, 265553712, 264838123, 264124462, 263412725, 262702906, 261994999, 261289000, + 260584903, 259882704, 259182396, 258483976, 257787438, 257092777, 256399988, 255709066, 255020006, 254332802, 253647450, + 252963945, 252282282, 251602456, 250924462, 250248294, 249573949, 248901421, 248230705, 247561797, 246894691, 246229383, + 245565867, 244904140, 244244195, 243586029, 242929637, 242275013, 241622154, 240971053, 240321708, 239674112, 239028261, + 238384150, 237741775, 237101131, 236462214, 235825018, 235189539, 234555773, 233923714, 233293359, 232664702, 232037740, + 231412466, 230788878, 230166970, 229546738, 228928178, 228311284, 227696052, 227082479, 226470558, 225860287, 225251660, + 224644674, 224039323, 223435603, 222833510, 222233039, 221634187, 221036948, 220441319, 219847295, 219254871, 218664044, + 218074809, 217487162, 216901098, 216316614, 215733704, 215152366, 214572594, 213994384, 213417732, 212842635, 212269087, + 211697084, 211126623, 210557699, 209990308, 209424446, 208860109, 208297293, 207735993, 207176206, 206617927, 206061153, + 205505879, 204952102, 204399816, 203849019, 203299706, 202751873, 202205517, 201660633, 201117217, 200575266, 200034774, + 199495740, 198958158, 198422024, 197887335, 197354088, 196822277, 196291899, 195762950, 195235427, 194709325, 194184641, + 193661370, 193139510, 192619056, 192100005, 191582352, 191066094, 190551228, 190037748, 189525653, 189014937, 188505598, + 187997631, 187491033, 186985800, 186481928, 185979414, 185478255, 184978446, 184479983, 183982864, 183487085, 182992641, + 182499530, 182007748, 181517291, 181028155, 180540338, 180053835, 179568643, 179084759, 178602178, 178120898, 177640915, + 177162225, 176684825, 176208712, 175733881, 175260330, 174788055, 174317053, 173847320, 173378853, 172911648, 172445702, + 171981012, 171517574, 171055385, 170594441, 170134740, 169676277, 169219049, 168763054, 168308287, 167854746, 167402427, + 166951327, 166501443, 166052770, 165605307, 165159050, 164713995, 164270139, 163827480, 163386013, 162945736, 162506646, + 162068738, 161632011, 161196460, 160762083, 160328877, 159896838, 159465963, 159036250, 158607694, 158180293, 157754044, + 157328943, 156904988, 156482176, 156060502, 155639965, 155220562, 154802288, 154385142, 153969119, 153554218, 153140435, + 152727766, 152316210, 151905763, 151496422, 151088184, 150681046, 150275005, 149870058, 149466203, 149063435, 148661753, + 148261154, 147861634, 147463190, 147065821, 146669522, 146274291, 145880125, 145487021, 145094976, 144703988, 144314054, + 143925170, 143537334, 143150543, 142764795, 142380086, 141996414, 141613775, 141232168, 140851589, 140472035, 140093505, + 139715994, 139339501, 138964022, 138589555, 138216097, 137843646, 137472198, 137101751, 136732302, 136363849, 135996388, + 135629918, 135264436, 134899938, 134536423, 134173887, 133812328, 133451743, 133092130, 132733486, 132375808, 132019095, + 131663342, 131308548, 130954711, 130601826, 130249893, 129898908, 129548869, 129199773, 128851618, 128504401, 128158119, + 127812771, 127468353, 127124864, 126782300, 126440659, 126099939, 125760137, 125421250, 125083277, 124746214, 124410060, + 124074812, 123740467, 123407023, 123074477, 122742828, 122412072, 122082208, 121753232, 121425143, 121097939, 120771615, + 120446172, 120121605, 119797912, 119475092, 119153142, 118832060, 118511843, 118192488, 117873994, 117556359, 117239579, + 116923653, 116608578, 116294353, 115980974, 115668439, 115356747, 115045894, 114735880, 114426700, 114118354, 113810839, + 113504152, 113198292, 112893256, 112589042, 112285648, 111983071, 111681310, 111380362, 111080225, 110780896, 110482375, + 110184657, 109887742, 109591627, 109296310, 109001789, 108708061, 108415125, 108122978, 107831619, 107541044, 107251253, + 106962243, 106674011, 106386556, 106099876, 105813968, 105528830, 105244461, 104960859, 104678020, 104395944, 104114628, + 103834069, 103554267, 103275219, 102996923, 102719377, 102442578, 102166526, 101891217, 101616650, 101342823, 101069734, + 100797381, 100525762, 100254875, 99984718, 99715288, 99446585, 99178606, 98911349, 98644812, 98378993, 98113891, + 97849503, 97585828, 97322863, 97060606, 96799057, 96538212, 96278070, 96018629, 95759887, 95501842, 95244493, + 94987837, 94731873, 94476599, 94222012, 93968112, 93714895, 93462361, 93210508, 92959333, 92708835, 92459012, + 92209863, 91961384, 91713575, 91466434, 91219959, 90974149, 90729000, 90484512, 90240683, 89997511, 89754994, + 89513131, 89271920, 89031358, 88791445, 88552178, 88313556, 88075578, 87838240, 87601542, 87365481, 87130057, + 86895267, 86661110, 86427584, 86194687, 85962418, 85730775, 85499756, 85269359, 85039583, 84810427, 84581888, + 84353965, 84126656, 83899959, 83673874, 83448397, 83223528, 82999266, 82775607, 82552551, 82330096, 82108241, + 81886984, 81666322, 81446256, 81226782, 81007900, 80789608, 80571904, 80354786, 80138254, 79922305, 79706938, + 79492151, 79277943, 79064313, 78851258, 78638777, 78426868, 78215531, 78004763, 77794564, 77584930, 77375862, + 77167357, 76959413, 76752031, 76545207, 76338940, 76133229, 75928072, 75723469, 75519416, 75315914, 75112960, + 74910552, 74708690, 74507373, 74306597, 74106363, 73906668, 73707512, 73508892, 73310807, 73113256, 72916237, + 72719749, 72523791, 72328361, 72133457, 71939079, 71745225, 71551892, 71359081, 71166789, 70975016, 70783759, + 70593018, 70402791, 70213076, 70023872, 69835179, 69646994, 69459315, 69272143, 69085475, 68899310, 68713647, + 68528484, 68343820, 68159653, 67975983, 67792808, 67610127, 67427937, 67246239, 67065030, 66884310, 66704076, + 66524328, 66345065, 66166285, 65987986, 65810168, 65632829, 65455968, 65279583, 65103674, 64928239, 64753277, + 64578786, 64404765, 64231213, 64058129, 63885511, 63713359, 63541670, 63370444, 63199679, 63029375, 62859529, + 62690141, 62521210, 62352734, 62184711, 62017142, 61850024, 61683357, 61517138, 61351368, 61186044, 61021166, + 60856731, 60692741, 60529192, 60366083, 60203414, 60041184, 59879391, 59718034, 59557111, 59396622, 59236566, + 59076941, 58917746, 58758980, 58600642, 58442730, 58285245, 58128183, 57971545, 57815329, 57659533, 57504158, + 57349201, 57194662, 57040539, 56886832, 56733539, 56580659, 56428190, 56276133, 56124486, 55973247, 55822415, + 55671990, 55521971, 55372355, 55223143, 55074333, 54925924, 54777915, 54630305, 54483092, 54336276, 54189856, + 54043830, 53898198, 53752959, 53608110, 53463652, 53319583, 53175903, 53032610, 52889702, 52747180, 52605042, + 52463287, 52321914, 52180922, 52040310, 51900076, 51760221, 51620743, 51481640, 51342912, 51204558, 51066577, + 50928968, 50791729, 50654860, 50518360, 50382228, 50246463, 50111064, 49976029, 49841359, 49707051, 49573105, + 49439520, 49306295, 49173429, 49040922, 48908771, 48776976, 48645537, 48514451, 48383719, 48253339, 48123311, + 47993633, 47864304, 47735324, 47606691, 47478405, 47350465, 47222869, 47095618, 46968709, 46842142, 46715916, + 46590031, 46464484, 46339276, 46214406, 46089871, 45965673, 45841809, 45718279, 45595082, 45472216, 45349682, + 45227478, 45105603, 44984057, 44862838, 44741946, 44621380, 44501139, 44381221, 44261627, 44142355, 44023404, + 43904774, 43786464, 43668472, 43550798, 43433442, 43316402, 43199677, 43083266, 42967170, 42851386, 42735914, + 42620753, 42505903, 42391362, 42277130, 42163206, 42049588, 41936277, 41823271, 41710570, 41598172, 41486077, + 41374285, 41262793, 41151602, 41040711, 40930118, 40819823, 40709826, 40600125, 40490720, 40381609, 40272793, + 40164269, 40056039, 39948099, 39840451, 39733093, 39626024, 39519243, 39412751, 39306545, 39200625, 39094991, + 38989642, 38884576, 38779794, 38675294, 38571075, 38467138, 38363480, 38260102, 38157002, 38054180, 37951635, + 37849367, 37747374, 37645656, 37544212, 37443042, 37342144, 37241518, 37141163, 37041078, 36941264, 36841718, + 36742440, 36643430, 36544687, 36446210, 36347998, 36250051, 36152368, 36054948, 35957790, 35860895, 35764260, + 35667886, 35571772, 35475916, 35380319, 35284980, 35189897, 35095071, 35000500, 34906184, 34812122, 34718314, + 34624758, 34531454, 34438402, 34345601, 34253050, 34160748, 34068695, 33976890, 33885332, 33794021, 33702956, + 33612137, 33521562, 33431231, 33341144, 33251299, 33161697, 33072336, 32983216, 32894336, 32805695, 32717294, + 32629130, 32541204, 32453515, 32366063, 32278846, 32191864, 32105116, 32018602, 31932322, 31846273, 31760457, + 31674872, 31589518, 31504393, 31419498, 31334832, 31250394, 31166183, 31082200, 30998442, 30914911, 30831604, + 30748522, 30665664, 30583029, 30500617, 30418426, 30336458, 30254710, 30173183, 30091875, 30010786, 29929916, + 29849263, 29768829, 29688610, 29608608, 29528822, 29449250, 29369893, 29290750, 29211820, 29133103, 29054598, + 28976304, 28898222, 28820350, 28742687, 28665234, 28587990, 28510954, 28434125, 28357503, 28281088, 28204879, + 28128875, 28053076, 27977482, 27902091, 27826903, 27751917, 27677134, 27602552, 27528172, 27453991, 27380011, + 27306230, 27232648, 27159264, 27086078, 27013089, 26940296, 26867700, 26795300, 26723094, 26651083, 26579267, + 26507643, 26436213, 26364975, 26293929, 26223075, 26152412, 26081939, 26011656, 25941562, 25871657, 25801940, + 25732412, 25663071, 25593916, 25524948, 25456166, 25387569, 25319157, 25250929, 25182886, 25115025, 25047348, + 24979852, 24912539, 24845407, 24778456, 24711686, 24645095, 24578684, 24512451, 24446397, 24380522, 24314823, + 24249302, 24183957, 24118789, 24053796, 23988978, 23924335, 23859866, 23795570, 23731448, 23667499, 23603722, + 23540117, 23476683, 23413421, 23350328, 23287406, 23224653, 23162070, 23099655, 23037408, 22975329, 22913417, + 22851673, 22790094, 22728681, 22667434, 22606352, 22545435, 22484682, 22424092, 22363666, 22303402, 22243301, + 22183362, 22123584, 22063968, 22004512, 21945216, 21886080, 21827104, 21768286, 21709627, 21651126, 21592783, + 21534597, 21476567, 21418694, 21360977, 21303416, 21246009, 21188758, 21131660, 21074717, 21017926, 20961289, + 20904805, 20848473, 20792292, 20736263, 20680385, 20624657, 20569080, 20513652, 20458374, 20403245, 20348264, + 20293432, 20238747, 20184209, 20129819, 20075575, 20021477, 19967525, 19913719, 19860057, 19806540, 19753167, + 19699938, 19646853, 19593910, 19541111, 19488453, 19435937, 19383563, 19331330, 19279238, 19227286, 19175474, + 19123802, 19072269, 19020875, 18969619, 18918502, 18867522, 18816680, 18765974, 18715405, 18664973, 18614676, + 18564515, 18514489, 18464598, 18414842, 18365219, 18315730, 18266375, 18217152, 18168062, 18119105, 18070279, + 18021585, 17973022, 17924590, 17876289, 17828118, 17780076, 17732164, 17684381, 17636727, 17589201, 17541803, + 17494533, 17447391, 17400375, 17353486, 17306724, 17260087, 17213577, 17167191, 17120930, 17074795, 17028783, + 16982896, 16937132, 16891491, 16845974, 16800579, 16755306, 16710155, 16665126, 16620219, 16575432, 16530766, + 16486221, 16441795, 16397490, 16353303, 16309236, 16265287, 16221457, 16177745, 16134151, 16090674, 16047314, + 16004072, 15960945, 15917935, 15875041, 15832263, 15789599, 15747051, 15704617, 15662298, 15620093, 15578001, + 15536023, 15494158, 15452406, 15410766, 15369239, 15327823, 15286519, 15245327, 15204245, 15163274, 15122414, + 15081663, 15041023, 15000491, 14960070, 14919757, 14879552, 14839456, 14799468, 14759588, 14719815, 14680150, + 14640591, 14601139, 14561793, 14522554, 14483420, 14444391, 14405468, 14366649, 14327935, 14289326, 14250820, + 14212418, 14174120, 14135925, 14097833, 14059843, 14021956, 13984171, 13946488, 13908906, 13871426, 13834047, + 13796768, 13759590, 13722512, 13685534, 13648655, 13611876, 13575196, 13538615, 13502132, 13465748, 13429462, + 13393273, 13357183, 13321189, 13285292, 13249492, 13213789, 13178182, 13142670, 13107255, 13071934, 13036709, + 13001579, 12966544, 12931603, 12896756, 12862003, 12827344, 12792778, 12758305, 12723925, 12689638, 12655443, + 12621341, 12587330, 12553411, 12519583, 12485846, 12452201, 12418646, 12385181, 12351807, 12318522, 12285327, + 12252222, 12219206, 12186279, 12153440, 12120690, 12088029, 12055455, 12022969, 11990571, 11958260, 11926036, + 11893899, 11861848, 11829884, 11798006, 11766214, 11734507, 11702886, 11671350, 11639900, 11608533, 11577252, + 11546055, 11514941, 11483912, 11452966, 11422104, 11391325, 11360628, 11330015, 11299484, 11269035, 11238668, + 11208384, 11178180, 11148058, 11118018, 11088058, 11058179, 11028380, 10998662, 10969024, 10939466, 10909987, + 10880588, 10851268, 10822027, 10792865, 10763781, 10734776, 10705849, 10677000, 10648228, 10619535, 10590918, + 10562379, 10533916, 10505530, 10477221, 10448988, 10420831, 10392750, 10364745, 10336815, 10308960, 10281180, + 10253476, 10225846, 10198290, 10170809, 10143401, 10116068, 10088808, 10061622, 10034509, 10007468, 9980501, + 9953607, 9926785, 9900035, 9873357, 9846752, 9820217, 9793755, 9767364, 9741043, 9714794, 9688616, + 9662508, 9636470, 9610503, 9584605, 9558778, 9533019, 9507331, 9481711, 9456161, 9430679, 9405266, + 9379922, 9354646, 9329438, 9304298, 9279225, 9254221, 9229283, 9204413, 9179610, 9154874, 9130204, + 9105601, 9081064, 9056593, 9032188, 9007849, 8983576, 8959368, 8935225, 8911147, 8887134, 8863186, + 8839302, 8815483, 8791728, 8768037, 8744409, 8720846, 8697346, 8673909, 8650535, 8627225, 8603977, + 8580792, 8557669, 8534608, 8511610, 8488674, 8465799, 8442987, 8420235, 8397545, 8374916, 8352348, + 8329841, 8307395, 8285009, 8262683, 8240418, 8218212, 8196067, 8173981, 8151954, 8129987, 8108079, + 8086230, 8064440, 8042709, 8021036, 7999422, 7977866, 7956368, 7934928, 7913545, 7892221, 7870954, + 7849744, 7828591, 7807495, 7786456, 7765474, 7744548, 7723679, 7702866, 7682109, 7661408, 7640763, + 7620173, 7599639, 7579160, 7558737, 7538368, 7518055, 7497796, 7477591, 7457441, 7437346, 7417304, + 7397317, 7377383, 7357503, 7337677, 7317904, 7298185, 7278518, 7258905, 7239344, 7219836, 7200381, + 7180978, 7161627, 7142329, 7123082, 7103888, 7084745, 7065654, 7046614, 7027625, 7008688, 6989802, + 6970966, 6952181, 6933447, 6914764, 6896130, 6877547, 6859014, 6840531, 6822098, 6803715, 6785381, + 6767096, 6748861, 6730675, 6712537, 6694449, 6676410, 6658419, 6640476, 6622582, 6604736, 6586938, + 6569188, 6551486, 6533832, 6516225, 6498666, 6481154, 6463689, 6446272, 6428901, 6411577, 6394299, + 6377069, 6359884, 6342746, 6325655, 6308609, 6291609, 6274655, 6257747, 6240884, 6224066, 6207294, + 6190568, 6173886, 6157249, 6140657, 6124110, 6107607, 6091149, 6074735, 6058365, 6042040, 6025758, + 6009521, 5993327, 5977177, 5961070, 5945007, 5928987, 5913010, 5897076, 5881185, 5865337, 5849532, + 5833769, 5818049, 5802371, 5786735, 5771141, 5755590, 5740080, 5724612, 5709186, 5693802, 5678459, + 5663157, 5647896, 5632677, 5617498, 5602361, 5587264, 5572208, 5557193, 5542218, 5527283, 5512389, + 5497534, 5482720, 5467946, 5453211, 5438517, 5423861, 5409246, 5394669, 5380132, 5365635, 5351176, + 5336756, 5322375, 5308033, 5293729, 5279464, 5265237, 5251049, 5236899, 5222787, 5208713, 5194677, + 5180679, 5166719, 5152796, 5138911, 5125063, 5111252, 5097479, 5083743, 5070044, 5056382, 5042756, + 5029167, 5015615, 5002100, 4988620, 4975178, 4961771, 4948400, 4935066, 4921767, 4908505, 4895278, + 4882086, 4868931, 4855810, 4842725, 4829676, 4816661, 4803682, 4790737, 4777827, 4764953, 4752112, + 4739307, 4726536, 4713799, 4701097, 4688429, 4675795, 4663195, 4650629, 4638097, 4625599, 4613134, + 4600703, 4588306, 4575941, 4563611, 4551313, 4539049, 4526817, 4514619, 4502453, 4490320, 4478220, + 4466153, 4454118, 4442115, 4430145, 4418207, 4406301, 4394428, 4382586, 4370776, 4358998, 4347252, + 4335538, 4323855, 4312203, 4300583, 4288994, 4277437, 4265910, 4254415, 4242950, 4231517, 4220114, + 4208742, 4197401, 4186090, 4174810, 4163560, 4152340, 4141151, 4129992, 4118863, 4107764, 4096694, + 4085655, 4074645, 4063665, 4052715, 4041794, 4030903, 4020041, 4009208, 3998404, 3987630, 3976884, + 3966168, 3955480, 3944821, 3934191, 3923590, 3913017, 3902472, 3891956, 3881469, 3871009, 3860578, + 3850175, 3839800, 3829453, 3819133, 3808842, 3798578, 3788342, 3778134, 3767953, 3757799, 3747673, + 3737574, 3727503, 3717458, 3707441, 3697450, 3687487, 3677550, 3667640, 3657757, 3647900, 3638070, + 3628267, 3618490, 3608739, 3599014, 3589316, 3579644, 3569998, 3560378, 3550783, 3541215, 3531673, + 3522156, 3512665, 3503199, 3493759, 3484344, 3474955, 3465591, 3456252, 3446939, 3437650, 3428387, + 3419148, 3409935, 3400746, 3391582, 3382443, 3373328, 3364238, 3355172, 3346131, 3337114, 3328122, + 3319153, 3310209, 3301289, 3292393, 3283521, 3274673, 3265849, 3257048, 3248271, 3239518, 3230789, + 3222083, 3213400, 3204741, 3196105, 3187493, 3178903, 3170337, 3161794, 3153274, 3144777, 3136302, + 3127851, 3119422, 3111016, 3102633, 3094272, 3085934, 3077619, 3069325, 3061054, 3052806, 3044579, + 3036375, 3028193, 3020033, 3011895, 3003779, 2995684, 2987612, 2979561, 2971532, 2963525, 2955539, + 2947575, 2939632, 2931710, 2923810, 2915931, 2908074, 2900237, 2892422, 2884628, 2876855, 2869102, + 2861371, 2853660, 2845971, 2838302, 2830653, 2823025, 2815418, 2807832, 2800265, 2792719, 2785194, + 2777689, 2770203, 2762739, 2755294, 2747869, 2740464, 2733080, 2725715, 2718370, 2711045, 2703739, + 2696453, 2689187, 2681941, 2674714, 2667506, 2660318, 2653149, 2646000, 2638870, 2631759, 2624667, + 2617594, 2610540, 2603506, 2596490, 2589493, 2582515, 2575556, 2568616, 2561694, 2554791, 2547907, + 2541041, 2534194, 2527365, 2520554, 2513762, 2506988, 2500233, 2493495, 2486776, 2480075, 2473392, + 2466727, 2460080, 2453450, 2446839, 2440246, 2433670, 2427112, 2420571, 2414049, 2407544, 2401056, + 2394586, 2388133, 2381698, 2375280, 2368879, 2362496, 2356130, 2349780, 2343448, 2337134, 2330836, + 2324555, 2318291, 2312044, 2305813, 2299600, 2293403, 2287223, 2281060, 2274913, 2268783, 2262669, + 2256572, 2250491, 2244427, 2238379, 2232347, 2226331, 2220332, 2214349, 2208382, 2202431, 2196496, + 2190577, 2184674, 2178787, 2172916, 2167060, 2161221, 2155397, 2149589, 2143796, 2138019, 2132258, + 2126512, 2120782, 2115067, 2109368, 2103683, 2098015, 2092361, 2086723, 2081100, 2075492, 2069899, + 2064321, 2058758, 2053211, 2047678, 2042160, 2036657, 2031169, 2025695, 2020237, 2014793, 2009364, + 2003949, 1998549, 1993163, 1987792, 1982436, 1977094, 1971766, 1966453, 1961154, 1955869, 1950599, + 1945342, 1940100, 1934872, 1929658, 1924458, 1919272, 1914101, 1908943, 1903799, 1898668, 1893552, + 1888450, 1883361, 1878286, 1873224, 1868176, 1863142, 1858122, 1853115, 1848121, 1843141, 1838174, + 1833221, 1828281, 1823354, 1818441, 1813540, 1808654, 1803780, 1798919, 1794072, 1789237, 1784416, + 1779607, 1774812, 1770029, 1765259, 1760502, 1755758, 1751027, 1746309, 1741603, 1736910, 1732229, + 1727561, 1722906, 1718263, 1713633, 1709015, 1704410, 1699817, 1695237, 1690669, 1686113, 1681569, + 1677038, 1672519, 1668012, 1663517, 1659034, 1654564, 1650105, 1645659, 1641224, 1636801, 1632391, + 1627992, 1623605, 1619230, 1614866, 1610515, 1606175, 1601847, 1597530, 1593225, 1588932, 1584650, + 1580380, 1576122, 1571874, 1567639, 1563414, 1559201, 1555000, 1550810, 1546631, 1542463, 1538306, + 1534161, 1530027, 1525904, 1521792, 1517691, 1513602, 1509523, 1505455, 1501399, 1497353, 1493318, + 1489294, 1485281, 1481278, 1477287, 1473306, 1469336, 1465376, 1461427, 1457489, 1453562, 1449645, + 1445738, 1441843, 1437957, 1434082, 1430218, 1426364, 1422520, 1418687, 1414864, 1411051, 1407249, + 1403457, 1399675, 1395903, 1392142, 1388390, 1384649, 1380918, 1377197, 1373486, 1369784, 1366093, + 1362412, 1358741, 1355079, 1351428, 1347786, 1344154, 1340532, 1336920, 1333317, 1329724, 1326141, + 1322567, 1319004, 1315449, 1311904, 1308369, 1304844, 1301327, 1297821, 1294323, 1290836, 1287357, + 1283888, 1280429, 1276978, 1273537, 1270105, 1266683, 1263269, 1259865, 1256470, 1253084, 1249708, + 1246340, 1242982, 1239632, 1236292, 1232960, 1229638, 1226324, 1223020, 1219724, 1216437, 1213159, + 1209890, 1206630, 1203378, 1200136, 1196902, 1193676, 1190460, 1187252, 1184052, 1180862, 1177680, + 1174506, 1171341, 1168185, 1165037, 1161897, 1158767, 1155644, 1152530, 1149424, 1146327, 1143238, + 1140157, 1137085, 1134021, 1130965, 1127917, 1124878, 1121846, 1118823, 1115809, 1112802, 1109803, + 1106813, 1103830, 1100855, 1097889, 1094931, 1091980, 1089037, 1086103, 1083176, 1080257, 1077346, + 1074443, 1071548, 1068660, 1065781, 1062909, 1060044, 1057188, 1054339, 1051498, 1048664, 1045839, + 1043020, 1040210, 1037407, 1034611, 1031823, 1029043, 1026270, 1023504, 1020746, 1017996, 1015252, + 1012517, 1009788, 1007067, 1004353, 1001647, 998948, 996256, 993571, 990894, 988224, 985561, + 982905, 980256, 977615, 974980, 972353, 969733, 967120, 964514, 961915, 959323, 956737, + 954159, 951588, 949024, 946467, 943916, 941373, 938836, 936306, 933783, 931267, 928757, + 926254, 923758, 921269, 918787, 916311, 913842, 911379, 908923, 906474, 904031, 901595, + 899166, 896743, 894326, 891916, 889513, 887116, 884725, 882341, 879963, 877592, 875227, + 872869, 870517, 868171, 865831, 863498, 861171, 858851, 856536, 854228, 851926, 849631, + 847341, 845058, 842781, 840510, 838245, 835986, 833733, 831487, 829246, 827011, 824783, + 822560, 820344, 818133, 815929, 813730, 811537, 809350, 807169, 804994, 802825, 800662, + 798504, 796352, 794206, 792066, 789932, 787803, 785680, 783563, 781452, 779346, 777246, + 775151, 773062, 770979, 768902, 766830, 764763, 762703, 760647, 758598, 756553, 754515, + 752482, 750454, 748432, 746415, 744403, 742397, 740397, 738402, 736412, 734428, 732448, + 730475, 728506, 726543, 724585, 722633, 720686, 718744, 716807, 714875, 712949, 711028, + 709112, 707201, 705295, 703394, 701499, 699609, 697723, 695843, 693968, 692098, 690233, + 688373, 686518, 684668, 682823, 680983, 679148, 677318, 675493, 673673, 671857, 670047, + 668241, 666441, 664645, 662854, 661067, 659286, 657510, 655738, 653971, 652208, 650451, + 648698, 646950, 645207, 643468, 641734, 640005, 638280, 636560, 634845, 633134, 631428, + 629727, 628030, 626337, 624650, 622966, 621288, 619613, 617944, 616279, 614618, 612962, + 611310, 609663, 608020, 606381, 604747, 603118, 601492, 599872, 598255, 596643, 595035, + 593432, 591833, 590238, 588647, 587061, 585479, 583901, 582328, 580759, 579194, 577633, + 576076, 574524, 572976, 571432, 569892, 568356, 566825, 565297, 563774, 562255, 560740, + 559229, 557722, 556219, 554720, 553225, 551734, 550248, 548765, 547286, 545811, 544341, + 542874, 541411, 539952, 538497, 537046, 535599, 534155, 532716, 531280, 529849, 528421, + 526997, 525577, 524161, 522748, 521340, 519935, 518534, 517136, 515743, 514353, 512967, + 511585, 510206, 508831, 507460, 506093, 504729, 503369, 502012, 500660, 499310, 497965, + 496623, 495285, 493950, 492619, 491292, 489968, 488648, 487331, 486018, 484708, 483402, + 482099, 480800, 479504, 478212, 476924, 475638, 474357, 473078, 471804, 470532, 469264, + 468000, 466739, 465481, 464227, 462976, 461728, 460484, 459243, 458005, 456771, 455540, + 454313, 453089, 451868, 450650, 449436, 448225, 447017, 445812, 444611, 443413, 442218, + 441026, 439838, 438653, 437470, 436292, 435116, 433943, 432774, 431608, 430445, 429285, + 428128, 426974, 425824, 424676, 423532, 422391, 421252, 420117, 418985, 417856, 416730, + 415607, 414487, 413370, 412256, 411146, 410038, 408933, 407831, 406732, 405636, 404543, + 403453, 402365, 401281, 400200, 399121, 398046, 396973, 395903, 394837, 393773, 392712, + 391653, 390598, 389545, 388496, 387449, 386405, 385363, 384325, 383289, 382257, 381226, + 380199, 379175, 378153, 377134, 376118, 375104, 374093, 373085, 372080, 371077, 370077, + 369080, 368085, 367094, 366104, 365118, 364134, 363153, 362174, 361198, 360225, 359254, + 358286, 357321, 356358, 355397, 354440, 353485, 352532, 351582, 350635, 349690, 348748, + 347808, 346871, 345936, 345004, 344074, 343147, 342222, 341300, 340380, 339463, 338548, + 337636, 336726, 335819, 334914, 334011, 333111, 332214, 331318, 330426, 329535, 328647, + 327762, 326878, 325997, 325119, 324243, 323369, 322498, 321629, 320762, 319898, 319036, + 318176, 317319, 316463, 315611, 314760, 313912, 313066, 312222, 311381, 310542, 309705, + 308871, 308038, 307208, 306380, 305555, 304731, 303910, 303091, 302275, 301460, 300648, + 299838, 299030, 298224, 297420, 296619, 295819, 295022, 294227, 293434, 292644, 291855, + 291069, 290284, 289502, 288722, 287944, 287168, 286394, 285622, 284853, 284085, 283320, + 282556, 281795, 281035, 280278, 279523, 278770, 278018, 277269, 276522, 275777, 275034, + 274293, 273553, 272816, 272081, 271348, 270617, 269888, 269160, 268435, 267712, 266990, + 266271, 265553, 264838, 264124, 263412, 262702, 261994, 261289, 260584, 259882, 259182, + 258483, 257787, 257092, 256399, 255709, 255020, 254332, 253647, 252963, 252282, 251602, + 250924, 250248, 249573, 248901, 248230, 247561, 246894, 246229, 245565, 244904, 244244, + 243586, 242929, 242275, 241622, 240971, 240321, 239674, 239028, 238384, 237741, 237101, + 236462, 235825, 235189, 234555, 233923, 233293, 232664, 232037, 231412, 230788, 230166, + 229546, 228928, 228311, 227696, 227082, 226470, 225860, 225251, 224644, 224039, 223435, + 222833, 222233, 221634, 221036, 220441, 219847, 219254, 218664, 218074, 217487, 216901, + 216316, 215733, 215152, 214572, 213994, 213417, 212842, 212269, 211697, 211126, 210557, + 209990, 209424, 208860, 208297, 207735, 207176, 206617, 206061, 205505, 204952, 204399, + 203849, 203299, 202751, 202205, 201660, 201117, 200575, 200034, 199495, 198958, 198422, + 197887, 197354, 196822, 196291, 195762, 195235, 194709, 194184, 193661, 193139, 192619, + 192100, 191582, 191066, 190551, 190037, 189525, 189014, 188505, 187997, 187491, 186985, + 186481, 185979, 185478, 184978, 184479, 183982, 183487, 182992, 182499, 182007, 181517, + 181028, 180540, 180053, 179568, 179084, 178602, 178120, 177640, 177162, 176684, 176208, + 175733, 175260, 174788, 174317, 173847, 173378, 172911, 172445, 171981, 171517, 171055, + 170594, 170134, 169676, 169219, 168763, 168308, 167854, 167402, 166951, 166501, 166052, + 165605, 165159, 164713, 164270, 163827, 163386, 162945, 162506, 162068, 161632, 161196, + 160762, 160328, 159896, 159465, 159036, 158607, 158180, 157754, 157328, 156904, 156482, + 156060, 155639, 155220, 154802, 154385, 153969, 153554, 153140, 152727, 152316, 151905, + 151496, 151088, 150681, 150275, 149870, 149466, 149063, 148661, 148261, 147861, 147463, + 147065, 146669, 146274, 145880, 145487, 145094, 144703, 144314, 143925, 143537, 143150, + 142764, 142380, 141996, 141613, 141232, 140851, 140472, 140093, 139715, 139339, 138964, + 138589, 138216, 137843, 137472, 137101, 136732, 136363, 135996, 135629, 135264, 134899, + 134536, 134173, 133812, 133451, 133092, 132733, 132375, 132019, 131663, 131308, 130954, + 130601, 130249, 129898, 129548, 129199, 128851, 128504, 128158, 127812, 127468, 127124, + 126782, 126440, 126099, 125760, 125421, 125083, 124746, 124410, 124074, 123740, 123407, + 123074, 122742, 122412, 122082, 121753, 121425, 121097, 120771, 120446, 120121, 119797, + 119475, 119153, 118832, 118511, 118192, 117873, 117556, 117239, 116923, 116608, 116294, + 115980, 115668, 115356, 115045, 114735, 114426, 114118, 113810, 113504, 113198, 112893, + 112589, 112285, 111983, 111681, 111380, 111080, 110780, 110482, 110184, 109887, 109591, + 109296, 109001, 108708, 108415, 108122, 107831, 107541, 107251, 106962, 106674, 106386, + 106099, 105813, 105528, 105244, 104960, 104678, 104395, 104114, 103834, 103554, 103275, + 102996, 102719, 102442, 102166, 101891, 101616, 101342, 101069, 100797, 100525, 100254, + 99984, 99715, 99446, 99178, 98911, 98644, 98378, 98113, 97849, 97585, 97322, + 97060, 96799, 96538, 96278, 96018, 95759, 95501, 95244, 94987, 94731, 94476, + 94222, 93968, 93714, 93462, 93210, 92959, 92708, 92459, 92209, 91961, 91713, + 91466, 91219, 90974, 90729, 90484, 90240, 89997, 89754, 89513, 89271, 89031, + 88791, 88552, 88313, 88075, 87838, 87601, 87365, 87130, 86895, 86661, 86427, + 86194, 85962, 85730, 85499, 85269, 85039, 84810, 84581, 84353, 84126, 83899, + 83673, 83448, 83223, 82999, 82775, 82552, 82330, 82108, 81886, 81666, 81446, + 81226, 81007, 80789, 80571, 80354, 80138, 79922, 79706, 79492, 79277, 79064, + 78851, 78638, 78426, 78215, 78004, 77794, 77584, 77375, 77167, 76959, 76752, + 76545, 76338, 76133, 75928, 75723, 75519, 75315, 75112, 74910, 74708, 74507, + 74306, 74106, 73906, 73707, 73508, 73310, 73113, 72916, 72719, 72523, 72328, + 72133, 71939, 71745, 71551, 71359, 71166, 70975, 70783, 70593, 70402, 70213, + 70023, 69835, 69646, 69459, 69272, 69085, 68899, 68713, 68528, 68343, 68159, + 67975, 67792, 67610, 67427, 67246, 67065, 66884, 66704, 66524, 66345, 66166, + 65987, 65810, 65632, 65455, 65279, 65103, 64928, 64753, 64578, 64404, 64231, + 64058, 63885, 63713, 63541, 63370, 63199, 63029, 62859, 62690, 62521, 62352, + 62184, 62017, 61850, 61683, 61517, 61351, 61186, 61021, 60856, 60692, 60529, + 60366, 60203, 60041, 59879, 59718, 59557, 59396, 59236, 59076, 58917, 58758, + 58600, 58442, 58285, 58128, 57971, 57815, 57659, 57504, 57349, 57194, 57040, + 56886, 56733, 56580, 56428, 56276, 56124, 55973, 55822, 55671, 55521, 55372, + 55223, 55074, 54925, 54777, 54630, 54483, 54336, 54189, 54043, 53898, 53752, + 53608, 53463, 53319, 53175, 53032, 52889, 52747, 52605, 52463, 52321, 52180, + 52040, 51900, 51760, 51620, 51481, 51342, 51204, 51066, 50928, 50791, 50654, + 50518, 50382, 50246, 50111, 49976, 49841, 49707, 49573, 49439, 49306, 49173, + 49040, 48908, 48776, 48645, 48514, 48383, 48253, 48123, 47993, 47864, 47735, + 47606, 47478, 47350, 47222, 47095, 46968, 46842, 46715, 46590, 46464, 46339, + 46214, 46089, 45965, 45841, 45718, 45595, 45472, 45349, 45227, 45105, 44984, + 44862, 44741, 44621, 44501, 44381, 44261, 44142, 44023, 43904, 43786, 43668, + 43550, 43433, 43316, 43199, 43083, 42967, 42851, 42735, 42620, 42505, 42391, + 42277, 42163, 42049, 41936, 41823, 41710, 41598, 41486, 41374, 41262, 41151, + 41040, 40930, 40819, 40709, 40600, 40490, 40381, 40272, 40164, 40056, 39948, + 39840, 39733, 39626, 39519, 39412, 39306, 39200, 39094, 38989, 38884, 38779, + 38675, 38571, 38467, 38363, 38260, 38157, 38054, 37951, 37849, 37747, 37645, + 37544, 37443, 37342, 37241, 37141, 37041, 36941, 36841, 36742, 36643, 36544, + 36446, 36347, 36250, 36152, 36054, 35957, 35860, 35764, 35667, 35571, 35475, + 35380, 35284, 35189, 35095, 35000, 34906, 34812, 34718, 34624, 34531, 34438, + 34345, 34253, 34160, 34068, 33976, 33885 +}; + +static const short sindb_coeff[] = { + 2401, 2144, 1994, 1887, 1804, 1737, 1680, 1630, 1587, 1548, 1512, 1480, 1450, + 1423, 1397, 1373, 1351, 1330, 1310, 1291, 1273, 1255, 1239, 1223, 1208, 1194, + 1180, 1166, 1153, 1141, 1128, 1117, 1105, 1094, 1084, 1073, 1063, 1053, 1043, + 1034, 1025, 1016, 1007, 999, 990, 982, 974, 967, 959, 952, 944, 937, + 930, 923, 916, 910, 903, 897, 890, 884, 878, 872, 866, 860, 855, + 849, 843, 838, 832, 827, 822, 817, 812, 807, 802, 797, 792, 787, + 783, 778, 773, 769, 764, 760, 756, 751, 747, 743, 739, 734, 730, + 726, 722, 718, 715, 711, 707, 703, 699, 696, 692, 688, 685, 681, + 678, 674, 671, 667, 664, 661, 657, 654, 651, 648, 644, 641, 638, + 635, 632, 629, 626, 623, 620, 617, 614, 611, 608, 605, 602, 599, + 597, 594, 591, 588, 586, 583, 580, 578, 575, 572, 570, 567, 565, + 562, 560, 557, 555, 552, 550, 547, 545, 542, 540, 538, 535, 533, + 531, 528, 526, 524, 522, 519, 517, 515, 513, 510, 508, 506, 504, + 502, 500, 498, 495, 493, 491, 489, 487, 485, 483, 481, 479, 477, + 475, 473, 471, 469, 467, 465, 464, 462, 460, 458, 456, 454, 452, + 450, 449, 447, 445, 443, 441, 440, 438, 436, 434, 433, 431, 429, + 427, 426, 424, 422, 421, 419, 417, 416, 414, 412, 411, 409, 408, + 406, 404, 403, 401, 400, 398, 396, 395, 393, 392, 390, 389, 387, + 386, 384, 383, 381, 380, 378, 377, 375, 374, 372, 371, 370, 368, + 367, 365, 364, 362, 361, 360, 358, 357, 355, 354, 353, 351, 350, + 349, 347, 346, 345, 343, 342, 341, 339, 338, 337, 336, 334, 333, + 332, 330, 329, 328, 327, 325, 324, 323, 322, 320, 319, 318, 317, + 316, 314, 313, 312, 311, 310, 308, 307, 306, 305, 304, 303, 301, + 300, 299, 298, 297, 296, 295, 293, 292, 291, 290, 289, 288, 287, + 286, 285, 284, 282, 281, 280, 279, 278, 277, 276, 275, 274, 273, + 272, 271, 270, 269, 268, 267, 266, 265, 264, 263, 262, 261, 260, + 259, 258, 257, 256, 255, 254, 253, 252, 251, 250, 249, 248, 247, + 246, 245, 244, 243, 242, 241, 240, 240, 239, 238, 237, 236, 235, + 234, 233, 232, 231, 230, 230, 229, 228, 227, 226, 225, 224, 223, + 222, 222, 221, 220, 219, 218, 217, 216, 216, 215, 214, 213, 212, + 211, 211, 210, 209, 208, 207, 206, 206, 205, 204, 203, 202, 202, + 201, 200, 199, 198, 198, 197, 196, 195, 195, 194, 193, 192, 191, + 191, 190, 189, 188, 188, 187, 186, 185, 185, 184, 183, 182, 182, + 181, 180, 180, 179, 178, 177, 177, 176, 175, 174, 174, 173, 172, + 172, 171, 170, 170, 169, 168, 167, 167, 166, 165, 165, 164, 163, + 163, 162, 161, 161, 160, 159, 159, 158, 157, 157, 156, 155, 155, + 154, 153, 153, 152, 151, 151, 150, 150, 149, 148, 148, 147, 146, + 146, 145, 145, 144, 143, 143, 142, 141, 141, 140, 140, 139, 138, + 138, 137, 137, 136, 135, 135, 134, 134, 133, 133, 132, 131, 131, + 130, 130, 129, 129, 128, 127, 127, 126, 126, 125, 125, 124, 123, + 123, 122, 122, 121, 121, 120, 120, 119, 119, 118, 117, 117, 116, + 116, 115, 115, 114, 114, 113, 113, 112, 112, 111, 111, 110, 110, + 109, 109, 108, 108, 107, 107, 106, 106, 105, 105, 104, 104, 103, + 103, 102, 102, 101, 101, 100, 100, 99, 99, 98, 98, 97, 97, + 96, 96, 95, 95, 94, 94, 94, 93, 93, 92, 92, 91, 91, + 90, 90, 89, 89, 89, 88, 88, 87, 87, 86, 86, 85, 85, + 85, 84, 84, 83, 83, 82, 82, 82, 81, 81, 80, 80, 79, + 79, 79, 78, 78, 77, 77, 77, 76, 76, 75, 75, 75, 74, + 74, 73, 73, 73, 72, 72, 71, 71, 71, 70, 70, 69, 69, + 69, 68, 68, 68, 67, 67, 66, 66, 66, 65, 65, 65, 64, + 64, 63, 63, 63, 62, 62, 62, 61, 61, 61, 60, 60, 59, + 59, 59, 58, 58, 58, 57, 57, 57, 56, 56, 56, 55, 55, + 55, 54, 54, 54, 53, 53, 53, 52, 52, 52, 51, 51, 51, + 50, 50, 50, 49, 49, 49, 49, 48, 48, 48, 47, 47, 47, + 46, 46, 46, 45, 45, 45, 45, 44, 44, 44, 43, 43, 43, + 43, 42, 42, 42, 41, 41, 41, 40, 40, 40, 40, 39, 39, + 39, 39, 38, 38, 38, 37, 37, 37, 37, 36, 36, 36, 36, + 35, 35, 35, 35, 34, 34, 34, 34, 33, 33, 33, 32, 32, + 32, 32, 31, 31, 31, 31, 31, 30, 30, 30, 30, 29, 29, + 29, 29, 28, 28, 28, 28, 27, 27, 27, 27, 27, 26, 26, + 26, 26, 25, 25, 25, 25, 25, 24, 24, 24, 24, 23, 23, + 23, 23, 23, 22, 22, 22, 22, 22, 21, 21, 21, 21, 21, + 20, 20, 20, 20, 20, 19, 19, 19, 19, 19, 19, 18, 18, + 18, 18, 18, 17, 17, 17, 17, 17, 17, 16, 16, 16, 16, + 16, 15, 15, 15, 15, 15, 15, 14, 14, 14, 14, 14, 14, + 13, 13, 13, 13, 13, 13, 13, 12, 12, 12, 12, 12, 12, + 11, 11, 11, 11, 11, 11, 11, 10, 10, 10, 10, 10, 10, + 10, 10, 9, 9, 9, 9, 9, 9, 9, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 7, 7, 7, 7, 7, 7, 7, 7, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 +}; + + +static const short lfo_freq_coeff[] = { + 0, 3, 6, 9, 12, 15, 18, 21, 25, 28, 31, 34, 37, + 40, 43, 46, 50, 53, 56, 59, 62, 65, 68, 71, 74, 78, + 81, 84, 87, 90, 93, 96, 99, 102, 105, 108, 111, 115, 118, + 121, 124, 127, 130, 133, 136, 139, 142, 145, 148, 151, 154, 157, + 160, 163, 166, 169, 172, 175, 178, 180, 183, 186, 189, 192, 195, + 198, 201, 204, 207, 209, 212, 215, 218, 221, 224, 226, 229, 232, + 235, 238, 240, 243, 246, 249, 251, 254, 257, 260, 262, 265, 268, + 270, 273, 276, 278, 281, 283, 286, 289, 291, 294, 296, 299, 301, + 304, 306, 309, 311, 314, 316, 319, 321, 324, 326, 328, 331, 333, + 336, 338, 340, 343, 345, 347, 350, 352, 354, 356, 359, 361, 363, + 365, 367, 370, 372, 374, 376, 378, 380, 382, 384, 386, 388, 391, + 393, 395, 396, 398, 400, 402, 404, 406, 408, 410, 412, 414, 415, + 417, 419, 421, 423, 424, 426, 428, 430, 431, 433, 435, 436, 438, + 439, 441, 443, 444, 446, 447, 449, 450, 452, 453, 455, 456, 457, + 459, 460, 461, 463, 464, 465, 467, 468, 469, 470, 472, 473, 474, + 475, 476, 477, 478, 480, 481, 482, 483, 484, 485, 486, 487, 488, + 488, 489, 490, 491, 492, 493, 494, 494, 495, 496, 497, 497, 498, + 499, 499, 500, 501, 501, 502, 502, 503, 504, 504, 504, 505, 505, + 506, 506, 507, 507, 507, 508, 508, 508, 509, 509, 509, 509, 510, + 510, 510, 510, 510, 510, 510, 510, 510, 510, 511, 510, 510, 510, + 510, 510, 510, 510, 510, 510, 510, 509, 509, 509, 509, 508, 508, + 508, 507, 507, 507, 506, 506, 505, 505, 504, 504, 504, 503, 502, + 502, 501, 501, 500, 499, 499, 498, 497, 497, 496, 495, 494, 494, + 493, 492, 491, 490, 489, 488, 488, 487, 486, 485, 484, 483, 482, + 481, 480, 478, 477, 476, 475, 474, 473, 472, 470, 469, 468, 467, + 465, 464, 463, 461, 460, 459, 457, 456, 455, 453, 452, 450, 449, + 447, 446, 444, 443, 441, 439, 438, 436, 435, 433, 431, 430, 428, + 426, 424, 423, 421, 419, 417, 415, 414, 412, 410, 408, 406, 404, + 402, 400, 398, 396, 395, 393, 391, 388, 386, 384, 382, 380, 378, + 376, 374, 372, 370, 367, 365, 363, 361, 359, 356, 354, 352, 350, + 347, 345, 343, 340, 338, 336, 333, 331, 328, 326, 324, 321, 319, + 316, 314, 311, 309, 306, 304, 301, 299, 296, 294, 291, 289, 286, + 283, 281, 278, 276, 273, 270, 268, 265, 262, 260, 257, 254, 251, + 249, 246, 243, 240, 238, 235, 232, 229, 226, 224, 221, 218, 215, + 212, 209, 207, 204, 201, 198, 195, 192, 189, 186, 183, 180, 178, + 175, 172, 169, 166, 163, 160, 157, 154, 151, 148, 145, 142, 139, + 136, 133, 130, 127, 124, 121, 118, 115, 111, 108, 105, 102, 99, + 96, 93, 90, 87, 84, 81, 78, 74, 71, 68, 65, 62, 59, + 56, 53, 50, 46, 43, 40, 37, 34, 31, 28, 25, 21, 18, + 15, 12, 9, 6, 3, 0, -3, -6, -9, -12, -15, -18, -21, + -25, -28, -31, -34, -37, -40, -43, -46, -50, -53, -56, -59, -62, + -65, -68, -71, -74, -78, -81, -84, -87, -90, -93, -96, -99, -102, + -105, -108, -111, -115, -118, -121, -124, -127, -130, -133, -136, -139, -142, + -145, -148, -151, -154, -157, -160, -163, -166, -169, -172, -175, -178, -180, + -183, -186, -189, -192, -195, -198, -201, -204, -207, -209, -212, -215, -218, + -221, -224, -226, -229, -232, -235, -238, -240, -243, -246, -249, -251, -254, + -257, -260, -262, -265, -268, -270, -273, -276, -278, -281, -283, -286, -289, + -291, -294, -296, -299, -301, -304, -306, -309, -311, -314, -316, -319, -321, + -324, -326, -328, -331, -333, -336, -338, -340, -343, -345, -347, -350, -352, + -354, -356, -359, -361, -363, -365, -367, -370, -372, -374, -376, -378, -380, + -382, -384, -386, -388, -391, -393, -395, -396, -398, -400, -402, -404, -406, + -408, -410, -412, -414, -415, -417, -419, -421, -423, -424, -426, -428, -430, + -431, -433, -435, -436, -438, -439, -441, -443, -444, -446, -447, -449, -450, + -452, -453, -455, -456, -457, -459, -460, -461, -463, -464, -465, -467, -468, + -469, -470, -472, -473, -474, -475, -476, -477, -478, -480, -481, -482, -483, + -484, -485, -486, -487, -488, -488, -489, -490, -491, -492, -493, -494, -494, + -495, -496, -497, -497, -498, -499, -499, -500, -501, -501, -502, -502, -503, + -504, -504, -504, -505, -505, -506, -506, -507, -507, -507, -508, -508, -508, + -509, -509, -509, -509, -510, -510, -510, -510, -510, -510, -510, -510, -510, + -510, -511, -510, -510, -510, -510, -510, -510, -510, -510, -510, -510, -509, + -509, -509, -509, -508, -508, -508, -507, -507, -507, -506, -506, -505, -505, + -504, -504, -504, -503, -502, -502, -501, -501, -500, -499, -499, -498, -497, + -497, -496, -495, -494, -494, -493, -492, -491, -490, -489, -488, -488, -487, + -486, -485, -484, -483, -482, -481, -480, -478, -477, -476, -475, -474, -473, + -472, -470, -469, -468, -467, -465, -464, -463, -461, -460, -459, -457, -456, + -455, -453, -452, -450, -449, -447, -446, -444, -443, -441, -439, -438, -436, + -435, -433, -431, -430, -428, -426, -424, -423, -421, -419, -417, -415, -414, + -412, -410, -408, -406, -404, -402, -400, -398, -396, -395, -393, -391, -388, + -386, -384, -382, -380, -378, -376, -374, -372, -370, -367, -365, -363, -361, + -359, -356, -354, -352, -350, -347, -345, -343, -340, -338, -336, -333, -331, + -328, -326, -324, -321, -319, -316, -314, -311, -309, -306, -304, -301, -299, + -296, -294, -291, -289, -286, -283, -281, -278, -276, -273, -270, -268, -265, + -262, -260, -257, -254, -251, -249, -246, -243, -240, -238, -235, -232, -229, + -226, -224, -221, -218, -215, -212, -209, -207, -204, -201, -198, -195, -192, + -189, -186, -183, -180, -178, -175, -172, -169, -166, -163, -160, -157, -154, + -151, -148, -145, -142, -139, -136, -133, -130, -127, -124, -121, -118, -115, + -111, -108, -105, -102, -99, -96, -93, -90, -87, -84, -81, -78, -74, + -71, -68, -65, -62, -59, -56, -53, -50, -46, -43, -40, -37, -34, + -31, -28, -25, -21, -18, -15, -12, -9, -6, -3 +}; + +static const short lfo_env_coeff[] = { + 251, 253, 254, 256, 257, 259, 260, 262, 264, 265, 267, 268, 270, + 271, 273, 274, 276, 277, 279, 281, 282, 284, 285, 287, 288, 290, + 291, 293, 294, 296, 297, 299, 300, 302, 303, 305, 306, 308, 309, + 311, 312, 314, 315, 317, 318, 320, 321, 323, 324, 326, 327, 329, + 330, 332, 333, 335, 336, 337, 339, 340, 342, 343, 345, 346, 348, + 349, 350, 352, 353, 355, 356, 357, 359, 360, 362, 363, 364, 366, + 367, 369, 370, 371, 373, 374, 375, 377, 378, 379, 381, 382, 383, + 385, 386, 387, 389, 390, 391, 392, 394, 395, 396, 397, 399, 400, + 401, 402, 404, 405, 406, 407, 409, 410, 411, 412, 413, 414, 416, + 417, 418, 419, 420, 421, 423, 424, 425, 426, 427, 428, 429, 430, + 431, 432, 434, 435, 436, 437, 438, 439, 440, 441, 442, 443, 444, + 445, 446, 447, 448, 449, 450, 451, 452, 453, 453, 454, 455, 456, + 457, 458, 459, 460, 461, 461, 462, 463, 464, 465, 466, 466, 467, + 468, 469, 469, 470, 471, 472, 473, 473, 474, 475, 475, 476, 477, + 477, 478, 479, 479, 480, 481, 481, 482, 483, 483, 484, 484, 485, + 486, 486, 487, 487, 488, 488, 489, 489, 490, 490, 491, 491, 492, + 492, 493, 493, 493, 494, 494, 495, 495, 495, 496, 496, 497, 497, + 497, 498, 498, 498, 498, 499, 499, 499, 500, 500, 500, 500, 500, + 501, 501, 501, 501, 501, 502, 502, 502, 502, 502, 502, 502, 502, + 503, 503, 503, 503, 503, 503, 503, 503, 503, 503, 503, 503, 503, + 503, 503, 503, 503, 503, 503, 502, 502, 502, 502, 502, 502, 502, + 502, 501, 501, 501, 501, 501, 500, 500, 500, 500, 500, 499, 499, + 499, 498, 498, 498, 498, 497, 497, 497, 496, 496, 495, 495, 495, + 494, 494, 493, 493, 493, 492, 492, 491, 491, 490, 490, 489, 489, + 488, 488, 487, 487, 486, 486, 485, 484, 484, 483, 483, 482, 481, + 481, 480, 479, 479, 478, 477, 477, 476, 475, 475, 474, 473, 473, + 472, 471, 470, 469, 469, 468, 467, 466, 466, 465, 464, 463, 462, + 461, 461, 460, 459, 458, 457, 456, 455, 454, 453, 453, 452, 451, + 450, 449, 448, 447, 446, 445, 444, 443, 442, 441, 440, 439, 438, + 437, 436, 435, 434, 432, 431, 430, 429, 428, 427, 426, 425, 424, + 423, 421, 420, 419, 418, 417, 416, 414, 413, 412, 411, 410, 409, + 407, 406, 405, 404, 402, 401, 400, 399, 397, 396, 395, 394, 392, + 391, 390, 389, 387, 386, 385, 383, 382, 381, 379, 378, 377, 375, + 374, 373, 371, 370, 369, 367, 366, 364, 363, 362, 360, 359, 357, + 356, 355, 353, 352, 350, 349, 348, 346, 345, 343, 342, 340, 339, + 337, 336, 335, 333, 332, 330, 329, 327, 326, 324, 323, 321, 320, + 318, 317, 315, 314, 312, 311, 309, 308, 306, 305, 303, 302, 300, + 299, 297, 296, 294, 293, 291, 290, 288, 287, 285, 284, 282, 281, + 279, 277, 276, 274, 273, 271, 270, 268, 267, 265, 264, 262, 260, + 259, 257, 256, 254, 253, 251, 250, 248, 247, 245, 244, 242, 240, + 239, 237, 236, 234, 233, 231, 230, 228, 227, 225, 223, 222, 220, + 219, 217, 216, 214, 213, 211, 210, 208, 207, 205, 204, 202, 201, + 199, 198, 196, 195, 193, 192, 190, 189, 187, 186, 184, 183, 181, + 180, 178, 177, 175, 174, 172, 171, 169, 168, 166, 165, 164, 162, + 161, 159, 158, 156, 155, 153, 152, 151, 149, 148, 146, 145, 144, + 142, 141, 139, 138, 137, 135, 134, 133, 131, 130, 129, 127, 126, + 124, 123, 122, 120, 119, 118, 117, 115, 114, 113, 111, 110, 109, + 108, 106, 105, 104, 103, 101, 100, 99, 98, 96, 95, 94, 93, + 92, 90, 89, 88, 87, 86, 84, 83, 82, 81, 80, 79, 78, + 77, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, + 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, + 50, 49, 48, 47, 46, 45, 45, 44, 43, 42, 41, 40, 39, + 39, 38, 37, 36, 35, 35, 34, 33, 32, 31, 31, 30, 29, + 29, 28, 27, 26, 26, 25, 24, 24, 23, 22, 22, 21, 20, + 20, 19, 19, 18, 17, 17, 16, 16, 15, 15, 14, 14, 13, + 13, 12, 12, 11, 11, 10, 10, 9, 9, 9, 8, 8, 7, + 7, 7, 6, 6, 6, 5, 5, 5, 4, 4, 4, 3, 3, + 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, + 2, 3, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, + 6, 7, 7, 7, 8, 8, 9, 9, 9, 10, 10, 11, 11, + 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, + 19, 19, 20, 20, 21, 22, 22, 23, 24, 24, 25, 26, 26, + 27, 28, 29, 29, 30, 31, 31, 32, 33, 34, 35, 35, 36, + 37, 38, 39, 39, 40, 41, 42, 43, 44, 45, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, + 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, + 74, 75, 77, 78, 79, 80, 81, 82, 83, 84, 86, 87, 88, + 89, 90, 92, 93, 94, 95, 96, 98, 99, 100, 101, 103, 104, + 105, 106, 108, 109, 110, 111, 113, 114, 115, 117, 118, 119, 120, + 122, 123, 124, 126, 127, 129, 130, 131, 133, 134, 135, 137, 138, + 139, 141, 142, 144, 145, 146, 148, 149, 151, 152, 153, 155, 156, + 158, 159, 161, 162, 164, 165, 166, 168, 169, 171, 172, 174, 175, + 177, 178, 180, 181, 183, 184, 186, 187, 189, 190, 192, 193, 195, + 196, 198, 199, 201, 202, 204, 205, 207, 208, 210, 211, 213, 214, + 216, 217, 219, 220, 222, 223, 225, 227, 228, 230, 231, 233, 234, + 236, 237, 239, 240, 242, 244, 245, 247, 248, 250 +}; + +#endif diff --git a/lib/rbcodec/codecs/libgme/z80_cpu.c b/lib/rbcodec/codecs/libgme/z80_cpu.c new file mode 100644 index 0000000000..a31236020e --- /dev/null +++ b/lib/rbcodec/codecs/libgme/z80_cpu.c @@ -0,0 +1,85 @@ +// Game_Music_Emu 0.6-pre. http://www.slack.net/~ant/ + +#include "z80_cpu.h" + +/* Copyright (C) 2006-2008 Shay Green. This module is free software; you +can redistribute it and/or modify it under the terms of the GNU Lesser +General Public License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. This +module is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +details. You should have received a copy of the GNU Lesser General Public +License along with this module; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ + +#include "blargg_source.h" + +// flags, named with hex value for clarity +int const S80 = 0x80; +int const Z40 = 0x40; +int const F20 = 0x20; +int const H10 = 0x10; +int const F08 = 0x08; +int const V04 = 0x04; +int const P04 = 0x04; +int const N02 = 0x02; +int const C01 = 0x01; + +void Z80_init( struct Z80_Cpu* this ) +{ + this->cpu_state = &this->cpu_state_; + + int i; + for ( i = 0x100; --i >= 0; ) + { + int p, even = 1; + for ( p = i; p; p >>= 1 ) + even ^= p; + int n = (i & (S80 | F20 | F08)) | ((even & 1) * P04); + this->szpc [i] = n; + this->szpc [i + 0x100] = n | C01; + } + this->szpc [0x000] |= Z40; + this->szpc [0x100] |= Z40; +} + +static inline void set_page( struct Z80_Cpu* this, int i, void* write, void const* read ) +{ + int offset = Z80_CPU_OFFSET( i * page_size ); + byte * write2 = STATIC_CAST(byte *,write) - offset; + byte const* read2 = STATIC_CAST(byte const*,read ) - offset; + this->cpu_state_.write [i] = write2; + this->cpu_state_.read [i] = read2; + this->cpu_state->write [i] = write2; + this->cpu_state->read [i] = read2; +} + +void Z80_reset( struct Z80_Cpu* this, void* unmapped_write, void const* unmapped_read ) +{ + check( this->cpu_state == &this->cpu_state_ ); + this->cpu_state = &this->cpu_state_; + this->cpu_state_.time = 0; + this->cpu_state_.base = 0; + this->end_time_ = 0; + + int i; + for ( i = 0; i < page_count + 1; i++ ) + set_page( this, i, unmapped_write, unmapped_read ); + + memset( &this->r, 0, sizeof this->r ); +} + +void Z80_map_mem( struct Z80_Cpu* this, addr_t start, int size, void* write, void const* read ) +{ + // address range must begin and end on page boundaries + require( start % page_size == 0 ); + require( size % page_size == 0 ); + require( start + size <= 0x10000 ); + + int offset; + for ( offset = 0; offset < size; offset += page_size ) + set_page( this, (start + offset) >> page_bits, + STATIC_CAST(char *,write) + offset, + STATIC_CAST(char const*,read ) + offset ); +} diff --git a/lib/rbcodec/codecs/libgme/z80_cpu.h b/lib/rbcodec/codecs/libgme/z80_cpu.h new file mode 100644 index 0000000000..341119b6b1 --- /dev/null +++ b/lib/rbcodec/codecs/libgme/z80_cpu.h @@ -0,0 +1,116 @@ +// Z80 CPU emulator + +// Game_Music_Emu 0.6-pre +#ifndef Z80_CPU_H +#define Z80_CPU_H + +#include "blargg_source.h" +#include "blargg_endian.h" + +typedef int cpu_time_t; +typedef int addr_t; + +enum { page_bits = 10 }; +enum { page_size = 1 << page_bits }; +enum { page_count = 0x10000 / page_size }; + +// Can read this far past end of memory +enum { cpu_padding = 0x100 }; + +// Can read this many bytes past end of a page +enum { page_padding = 4 }; + +#ifdef BLARGG_BIG_ENDIAN + struct regs_t { byte b,c, d,e, h,l, flags,a; }; +#else + struct regs_t { byte c,b, e,d, l,h, a,flags; }; +#endif +// BOOST_STATIC_ASSERT( sizeof (regs_t) == 8 ); + +struct pairs_t { uint16_t bc, de, hl, fa; }; + +// Registers are not updated until run() returns +struct registers_t { + uint16_t pc; + uint16_t sp; + uint16_t ix; + uint16_t iy; + union { + struct regs_t b; // b.b, b.c, b.d, b.e, b.h, b.l, b.flags, b.a + struct pairs_t w; // w.bc, w.de, w.hl. w.fa + }; + union { + struct regs_t b; + struct pairs_t w; + } alt; + byte iff1; + byte iff2; + byte r; + byte i; + byte im; +}; + +struct cpu_state_t { + byte const* read [page_count + 1]; + byte * write [page_count + 1]; + cpu_time_t base; + cpu_time_t time; +}; + +struct Z80_Cpu { + byte szpc [0x200]; + cpu_time_t end_time_; + + struct cpu_state_t* cpu_state; // points to cpu_state_ or a local copy within run() + struct cpu_state_t cpu_state_; + + struct registers_t r; +}; + +void Z80_init( struct Z80_Cpu* this ); + +// Clears registers and maps all pages to unmapped +void Z80_reset( struct Z80_Cpu* this, void* unmapped_write, void const* unmapped_read ); + +// TODO: split mapping out of CPU + +// Maps memory. Start and size must be multiple of page_size. +void Z80_map_mem( struct Z80_Cpu* this, addr_t addr, int size, void* write, void const* read ); + +// Time of beginning of next instruction +static inline cpu_time_t Z80_time( struct Z80_Cpu* this ) { return this->cpu_state->time + this->cpu_state->base; } + +// Alter current time +static inline void Z80_set_time( struct Z80_Cpu* this, cpu_time_t t ) { this->cpu_state->time = t - this->cpu_state->base; } +static inline void Z80_adjust_time( struct Z80_Cpu* this, int delta ) { this->cpu_state->time += delta; } + +#ifdef BLARGG_NONPORTABLE + #define Z80_CPU_OFFSET( addr ) (addr) +#else + #define Z80_CPU_OFFSET( addr ) ((addr) & (page_size - 1)) +#endif + +// Maps address to pointer to that byte +static inline byte* Z80_write( struct Z80_Cpu* this, addr_t addr ) +{ + return this->cpu_state->write [(unsigned) addr >> page_bits] + Z80_CPU_OFFSET( addr ); +} + +static inline byte const* Z80_read( struct Z80_Cpu* this, addr_t addr ) +{ + return this->cpu_state->read [(unsigned) addr >> page_bits] + Z80_CPU_OFFSET( addr ); +} + +static inline void Z80_map_mem_rw( struct Z80_Cpu* this, addr_t addr, int size, void* p ) +{ + Z80_map_mem( this, addr, size, p, p ); +} + +static inline void Z80_set_end_time( struct Z80_Cpu* this, cpu_time_t t ) +{ + cpu_time_t delta = this->cpu_state->base - t; + this->cpu_state->base = t; + this->cpu_state->time += delta; +} + +#endif diff --git a/lib/rbcodec/codecs/libgme/z80_cpu_run.h b/lib/rbcodec/codecs/libgme/z80_cpu_run.h new file mode 100644 index 0000000000..a453487bb0 --- /dev/null +++ b/lib/rbcodec/codecs/libgme/z80_cpu_run.h @@ -0,0 +1,1696 @@ +// Game_Music_Emu 0.6-pre. http://www.slack.net/~ant/ + +// Last validated with zexall 2009.12.05. +// Doesn't implement the R register or immediate interrupt after EI. +// Address wrap-around isn't completely correct, but is prevented from crashing emulator. +// 16-bit memory accesses are made directly to mapped memory, instead of using macro. + +#if 0 +/* Define these macros in the source file before #including this file. +- Parameters might be expressions, so they are best evaluated only once, +though they NEVER have side-effects, so multiple evaluation is OK. +- Output parameters might be a multiple-assignment expression like "a=x", +so they must NOT be parenthesized. +- Except where noted, time() and related functions will NOT work +correctly inside a macro. TIME() is always correct, and between FLUSH_TIME() and +CACHE_TIME() the normal time changing functions can be used. +- Macros "returning" void may use a {} statement block. */ + + // 0 <= addr <= 0xFFFF + 0x100 + // Optional; default uses whatever was set with map_mem() + int READ_MEM( addr_t ); + void WRITE_MEM( addr_t, int data ); + + // 0 <= port <= 0xFFFF (apparently upper 8 bits are output by hardware) + void OUT_PORT( int port, int data ); + int IN_PORT int port ); + + // Reference to Z80_Cpu object used for emulation + #define CPU cpu + +// The following can be used within macros: + + // Current time + time_t TIME(); + + // Allows use of time functions + void FLUSH_TIME(); + + // Must be used before end of macro if FLUSH_TIME() was used earlier + void CACHE_TIME(); + +// Configuration (optional; commented behavior if defined) + + // Optimizes as if map_mem( 0, 0x10000, FLAT_MEM, FLAT_MEM ) is always in effect + #define FLAT_MEM my_mem_array + + // If RST 7 ($FF) is encountered and PC = IDLE_ADDR, stops execution + #define IDLE_ADDR 0x1234 + + // Expanded just before beginning of code, to help debugger + #define CPU_BEGIN void my_run_cpu() { + +#endif + +/* Copyright (C) 2006-2008 Shay Green. This module is free software; you +can redistribute it and/or modify it under the terms of the GNU Lesser +General Public License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. This +module is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +details. You should have received a copy of the GNU Lesser General Public +License along with this module; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ + +#ifdef CPU_BEGIN + CPU_BEGIN +#endif + +#define R cpu->r + +// flags, named with hex value for clarity +int const S80 = 0x80; +int const Z40 = 0x40; +int const F20 = 0x20; +int const H10 = 0x10; +int const F08 = 0x08; +int const V04 = 0x04; +int const P04 = 0x04; +int const N02 = 0x02; +int const C01 = 0x01; + +#define SZ28P( n ) cpu->szpc [n] +#define SZ28PC( n ) cpu->szpc [n] +#define SZ28C( n ) (cpu->szpc [n] & ~P04) +#define SZ28( n ) SZ28C( n ) + +#define SET_R( n ) (void) (R.r = n) +#define GET_R() (R.r) + +// Time +#define TIME() (s_time + s.base) +#define FLUSH_TIME() {s.time = s_time;} +#define CACHE_TIME() {s_time = s.time;} + +// Memory +#define RW_MEM( addr, rw ) RW_PAGE( addr, rw ) [RW_OFFSET( addr )] +#define READ_CODE( addr ) RW_MEM( addr, read ) + +#ifdef FLAT_MEM + #define RW_PAGE( addr, rw ) FLAT_MEM + #define RW_OFFSET( addr ) (addr) + #define INSTR( off, addr ) READ_CODE( addr ) +#else + #define RW_PAGE( addr, rw ) s.rw [(unsigned) (addr) >> page_bits] + #define RW_OFFSET( addr ) Z80_CPU_OFFSET( addr ) + #define INSTR( off, addr ) instr [off] +#endif + +#ifndef READ_MEM + #define READ_MEM( addr ) RW_MEM( addr, read ) +#endif + +#ifndef WRITE_MEM + #define WRITE_MEM( addr, data ) (RW_MEM( addr, write ) = data) +#endif + +#define READ_WORD( addr ) GET_LE16( &RW_MEM( addr, read ) ) +#define WRITE_WORD( addr, data ) SET_LE16( &RW_MEM( addr, write ), data ) + +// Truncation +#define BYTE( n ) ((uint8_t ) (n)) /* (unsigned) n & 0xFF */ +#define SBYTE( n ) ((int8_t ) (n)) /* (BYTE( n ) ^ 0x80) - 0x80 */ +#define WORD( n ) ((uint16_t) (n)) /* (unsigned) n & 0xFFFF */ + +// Misc +#define CASE5( a, b, c, d, e ) case 0x##a:case 0x##b:case 0x##c:case 0x##d:case 0x##e +#define CASE6( a, b, c, d, e, f ) CASE5( a, b, c, d, e ): case 0x##f +#define CASE7( a, b, c, d, e, f, g ) CASE6( a, b, c, d, e, f ): case 0x##g +#define CASE8( a, b, c, d, e, f, g, h ) CASE7( a, b, c, d, e, f, g ): case 0x##h + +#ifdef BLARGG_BIG_ENDIAN + #define R8( n, offset ) ((r.r8_ - offset) [n]) +#elif BLARGG_LITTLE_ENDIAN + #define R8( n, offset ) ((r.r8_ - offset) [(n) ^ 1]) +#else + #error "Byte order of CPU must be known" +#endif + +#define R16( n, shift, offset ) (r.r16_ [((unsigned) (n) >> shift) - (offset >> shift)]) + +#define EX( x, y ) \ + {\ + int temp = x;\ + x = y;\ + y = temp;\ + } + +#define EXX( name ) \ + EX( R.alt.name, r.name ) + +bool warning = false; +{ + struct cpu_state_t s; + #ifdef FLAT_MEM + s.base = cpu->cpu_state_.base; + #else + s = cpu->cpu_state_; + #endif + cpu->cpu_state = &s; + + + union r_t { + struct regs_t b; + struct pairs_t w; + byte r8_ [8]; // indexed + uint16_t r16_ [4]; + } r; + r.b = R.b; + + cpu_time_t s_time = cpu->cpu_state_.time; + int pc = R.pc; + int sp = R.sp; + int ix = R.ix; // TODO: keep in memory for direct access? + int iy = R.iy; + int flags = R.b.flags; + + //goto loop; // confuses optimizer + s_time += 7; + pc -= 2; + +call_not_taken: + s_time -= 7; +jp_not_taken: + pc += 2; +loop: + + check( (unsigned) pc < 0x10000 + 1 ); // +1 so emulator can catch wrap-around + check( (unsigned) sp < 0x10000 ); + check( (unsigned) flags < 0x100 ); + check( (unsigned) ix < 0x10000 ); + check( (unsigned) iy < 0x10000 ); + + byte const* instr = RW_PAGE( pc, read ); + + int opcode; + + if ( RW_OFFSET( ~0 ) == ~0 ) + { + opcode = instr [RW_OFFSET( pc )]; + pc++; + instr += RW_OFFSET( pc ); + } + else + { + instr += RW_OFFSET( pc ); + opcode = *instr++; + pc++; + } + + static byte const clock_table [256 * 2] = { + // 0 1 2 3 4 5 6 7 8 9 A B C D E F + 4,10, 7, 6, 4, 4, 7, 4, 4,11, 7, 6, 4, 4, 7, 4, // 0 + 8,10, 7, 6, 4, 4, 7, 4,12,11, 7, 6, 4, 4, 7, 4, // 1 + 7,10,16, 6, 4, 4, 7, 4, 7,11,16, 6, 4, 4, 7, 4, // 2 + 7,10,13, 6,11,11,10, 4, 7,11,13, 6, 4, 4, 7, 4, // 3 + 4, 4, 4, 4, 4, 4, 7, 4, 4, 4, 4, 4, 4, 4, 7, 4, // 4 + 4, 4, 4, 4, 4, 4, 7, 4, 4, 4, 4, 4, 4, 4, 7, 4, // 5 + 4, 4, 4, 4, 4, 4, 7, 4, 4, 4, 4, 4, 4, 4, 7, 4, // 6 + 7, 7, 7, 7, 7, 7, 4, 7, 4, 4, 4, 4, 4, 4, 7, 4, // 7 + 4, 4, 4, 4, 4, 4, 7, 4, 4, 4, 4, 4, 4, 4, 7, 4, // 8 + 4, 4, 4, 4, 4, 4, 7, 4, 4, 4, 4, 4, 4, 4, 7, 4, // 9 + 4, 4, 4, 4, 4, 4, 7, 4, 4, 4, 4, 4, 4, 4, 7, 4, // A + 4, 4, 4, 4, 4, 4, 7, 4, 4, 4, 4, 4, 4, 4, 7, 4, // B + 11,10,10,10,17,11, 7,11,11,10,10, 8,17,17, 7,11, // C + 11,10,10,11,17,11, 7,11,11, 4,10,11,17, 8, 7,11, // D + 11,10,10,19,17,11, 7,11,11, 4,10, 4,17, 8, 7,11, // E + 11,10,10, 4,17,11, 7,11,11, 6,10, 4,17, 8, 7,11, // F + + // high four bits are $ED time - 8, low four bits are $DD/$FD time - 8 + //0 1 2 3 4 5 6 7 8 9 A B C D E F + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x06,0x0C,0x02,0x00,0x00,0x03,0x00,0x00,0x07,0x0C,0x02,0x00,0x00,0x03,0x00, + 0x00,0x00,0x00,0x00,0x0F,0x0F,0x0B,0x00,0x00,0x07,0x00,0x00,0x00,0x00,0x00,0x00, + 0x40,0x40,0x70,0xC0,0x00,0x60,0x0B,0x10,0x40,0x40,0x70,0xC0,0x00,0x60,0x0B,0x10, + 0x40,0x40,0x70,0xC0,0x00,0x60,0x0B,0x10,0x40,0x40,0x70,0xC0,0x00,0x60,0x0B,0x10, + 0x40,0x40,0x70,0xC0,0x00,0x60,0x0B,0xA0,0x40,0x40,0x70,0xC0,0x00,0x60,0x0B,0xA0, + 0x4B,0x4B,0x7B,0xCB,0x0B,0x6B,0x00,0x0B,0x40,0x40,0x70,0xC0,0x00,0x60,0x0B,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x0B,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0B,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x0B,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0B,0x00, + 0x80,0x80,0x80,0x80,0x00,0x00,0x0B,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x0B,0x00, + 0xD0,0xD0,0xD0,0xD0,0x00,0x00,0x0B,0x00,0xD0,0xD0,0xD0,0xD0,0x00,0x00,0x0B,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x06,0x00,0x0F,0x00,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00, + }; + + if ( s_time >= 0 ) + goto out_of_time; + s_time += clock_table [opcode]; + + #ifdef Z80_CPU_LOG_H + //log_opcode( opcode, READ_CODE( pc ) ); + z80_cpu_log( "log.txt", pc - 1, opcode, READ_CODE( pc ), + READ_CODE( pc + 1 ), READ_CODE( pc + 2 ) ); + z80_log_regs( r.b.a, r.w.bc, r.w.de, r.w.hl, sp, ix, iy ); + #endif + +#define GET_ADDR() GET_LE16( &INSTR( 0, pc ) ) + + int data; + data = INSTR( 0, pc ); + + switch ( opcode ) + { +// Common + + case 0x00: // NOP + CASE7( 40, 49, 52, 5B, 64, 6D, 7F ): // LD B,B etc. + goto loop; + + case 0x08:{// EX AF,AF' + EXX( b.a ); + EX( R.alt.b.flags, flags ); + goto loop; + } + + case 0xD3: // OUT (imm),A + pc++; + OUT_PORT( (data + r.b.a * 0x100), r.b.a ); + goto loop; + + case 0x2E: // LD L,imm + pc++; + r.b.l = data; + goto loop; + + case 0x3E: // LD A,imm + pc++; + r.b.a = data; + goto loop; + + case 0x3A:{// LD A,(addr) + int addr = GET_ADDR(); + pc += 2; + r.b.a = READ_MEM( addr ); + goto loop; + } + +// Conditional + +#define ZERO (flags & Z40) +#define CARRY (flags & C01) +#define EVEN (flags & P04) +#define MINUS (flags & S80) + +// JR +// TODO: more efficient way to handle negative branch that wraps PC around +#define JR_( cond, clocks ) {\ + pc++;\ + if ( !(cond) )\ + goto loop;\ + int offset = SBYTE( data );\ + pc = WORD( pc + offset );\ + s_time += clocks;\ + goto loop;\ +} + +#define JR( cond ) JR_( cond, 5 ) + + case 0x20: JR( !ZERO ) // JR NZ,disp + case 0x28: JR( ZERO ) // JR Z,disp + case 0x30: JR( !CARRY ) // JR NC,disp + case 0x38: JR( CARRY ) // JR C,disp + case 0x18: JR_( true,0) // JR disp + + case 0x10:{// DJNZ disp + int temp = r.b.b - 1; + r.b.b = temp; + JR( temp ) + } + +// JP +#define JP( cond ) \ + if ( !(cond) )\ + goto jp_not_taken;\ + pc = GET_ADDR();\ + goto loop; + + case 0xC2: JP( !ZERO ) // JP NZ,addr + case 0xCA: JP( ZERO ) // JP Z,addr + case 0xD2: JP( !CARRY ) // JP NC,addr + case 0xDA: JP( CARRY ) // JP C,addr + case 0xE2: JP( !EVEN ) // JP PO,addr + case 0xEA: JP( EVEN ) // JP PE,addr + case 0xF2: JP( !MINUS ) // JP P,addr + case 0xFA: JP( MINUS ) // JP M,addr + + case 0xC3: // JP addr + pc = GET_ADDR(); + goto loop; + + case 0xE9: // JP HL + pc = r.w.hl; + goto loop; + +// RET +#define RET( cond ) \ + if ( cond )\ + goto ret_taken;\ + s_time -= 6;\ + goto loop; + + case 0xC0: RET( !ZERO ) // RET NZ + case 0xC8: RET( ZERO ) // RET Z + case 0xD0: RET( !CARRY ) // RET NC + case 0xD8: RET( CARRY ) // RET C + case 0xE0: RET( !EVEN ) // RET PO + case 0xE8: RET( EVEN ) // RET PE + case 0xF0: RET( !MINUS ) // RET P + case 0xF8: RET( MINUS ) // RET M + + case 0xC9: // RET + ret_taken: + pc = READ_WORD( sp ); + sp = WORD( sp + 2 ); + goto loop; + +// CALL +#define CALL( cond ) \ + if ( cond )\ + goto call_taken;\ + goto call_not_taken; + + case 0xC4: CALL( !ZERO ) // CALL NZ,addr + case 0xCC: CALL( ZERO ) // CALL Z,addr + case 0xD4: CALL( !CARRY ) // CALL NC,addr + case 0xDC: CALL( CARRY ) // CALL C,addr + case 0xE4: CALL( !EVEN ) // CALL PO,addr + case 0xEC: CALL( EVEN ) // CALL PE,addr + case 0xF4: CALL( !MINUS ) // CALL P,addr + case 0xFC: CALL( MINUS ) // CALL M,addr + + case 0xCD:{// CALL addr + call_taken: { + int addr = pc + 2; + pc = GET_ADDR(); + sp = WORD( sp - 2 ); + WRITE_WORD( sp, addr ); + goto loop; + } + } + + case 0xFF: // RST + #ifdef IDLE_ADDR + if ( pc == IDLE_ADDR + 1 ) + goto hit_idle_addr; + #else + if ( pc > 0x10000 ) + { + pc = WORD( pc - 1 ); + s_time -= 11; + goto loop; + } + #endif + CASE7( C7, CF, D7, DF, E7, EF, F7 ): + data = pc; + pc = opcode & 0x38; + #ifdef RST_BASE + pc += RST_BASE; + #endif + goto push_data; + +// PUSH/POP + case 0xF5: // PUSH AF + data = r.b.a * 0x100u + flags; + goto push_data; + + case 0xC5: // PUSH BC + case 0xD5: // PUSH DE + case 0xE5: // PUSH HL + data = R16( opcode, 4, 0xC5 ); + push_data: + sp = WORD( sp - 2 ); + WRITE_WORD( sp, data ); + goto loop; + + case 0xF1: // POP AF + flags = READ_MEM( sp ); + r.b.a = READ_MEM( (sp + 1) ); + sp = WORD( sp + 2 ); + goto loop; + + case 0xC1: // POP BC + case 0xD1: // POP DE + case 0xE1: // POP HL + R16( opcode, 4, 0xC1 ) = READ_WORD( sp ); + sp = WORD( sp + 2 ); + goto loop; + +// ADC/ADD/SBC/SUB + case 0x96: // SUB (HL) + case 0x86: // ADD (HL) + flags &= ~C01; + case 0x9E: // SBC (HL) + case 0x8E: // ADC (HL) + data = READ_MEM( r.w.hl ); + goto adc_data; + + case 0xD6: // SUB A,imm + case 0xC6: // ADD imm + flags &= ~C01; + case 0xDE: // SBC A,imm + case 0xCE: // ADC imm + pc++; + goto adc_data; + + CASE7( 90, 91, 92, 93, 94, 95, 97 ): // SUB r + CASE7( 80, 81, 82, 83, 84, 85, 87 ): // ADD r + flags &= ~C01; + CASE7( 98, 99, 9A, 9B, 9C, 9D, 9F ): // SBC r + CASE7( 88, 89, 8A, 8B, 8C, 8D, 8F ): // ADC r + data = R8( opcode & 7, 0 ); + adc_data: { + int result = data + (flags & C01); + data ^= r.b.a; + flags = opcode >> 3 & N02; // bit 4 is set in subtract opcodes + if ( flags ) + result = -result; + result += r.b.a; + data ^= result; + flags +=(data & H10) + + ((data + 0x80) >> 6 & V04) + + SZ28C( result & 0x1FF ); + r.b.a = result; + goto loop; + } + +// CP + case 0xBE: // CP (HL) + data = READ_MEM( r.w.hl ); + goto cp_data; + + case 0xFE: // CP imm + pc++; + goto cp_data; + + CASE7( B8, B9, BA, BB, BC, BD, BF ): // CP r + data = R8( opcode, 0xB8 ); + cp_data: { + int result = r.b.a - data; + flags = N02 + (data & (F20 | F08)) + (result >> 8 & C01); + data ^= r.b.a; + flags +=(((result ^ r.b.a) & data) >> 5 & V04) + + (((data & H10) ^ result) & (S80 | H10)); + if ( BYTE( result ) ) + goto loop; + flags += Z40; + goto loop; + } + +// ADD HL,r.w + + case 0x39: // ADD HL,SP + data = sp; + goto add_hl_data; + + case 0x09: // ADD HL,BC + case 0x19: // ADD HL,DE + case 0x29: // ADD HL,HL + data = R16( opcode, 4, 0x09 ); + add_hl_data: { + int sum = r.w.hl + data; + data ^= r.w.hl; + r.w.hl = sum; + flags = (flags & (S80 | Z40 | V04)) + + (sum >> 16) + + (sum >> 8 & (F20 | F08)) + + ((data ^ sum) >> 8 & H10); + goto loop; + } + + case 0x27:{// DAA + int a = r.b.a; + if ( a > 0x99 ) + flags |= C01; + + int adjust = 0x60 * (flags & C01); + + if ( flags & H10 || (a & 0x0F) > 9 ) + adjust += 0x06; + + if ( flags & N02 ) + adjust = -adjust; + a += adjust; + + flags = (flags & (C01 | N02)) + + ((r.b.a ^ a) & H10) + + SZ28P( BYTE( a ) ); + r.b.a = a; + goto loop; + } + +// INC/DEC + case 0x34: // INC (HL) + data = READ_MEM( r.w.hl ) + 1; + WRITE_MEM( r.w.hl, data ); + goto inc_set_flags; + + CASE7( 04, 0C, 14, 1C, 24, 2C, 3C ): // INC r + data = ++R8( opcode >> 3, 0 ); + inc_set_flags: + flags = (flags & C01) + + (((data & 0x0F) - 1) & H10) + + SZ28( BYTE( data ) ); + if ( data != 0x80 ) + goto loop; + flags += V04; + goto loop; + + case 0x35: // DEC (HL) + data = READ_MEM( r.w.hl ) - 1; + WRITE_MEM( r.w.hl, data ); + goto dec_set_flags; + + CASE7( 05, 0D, 15, 1D, 25, 2D, 3D ): // DEC r + data = --R8( opcode >> 3, 0 ); + dec_set_flags: + flags = (flags & C01) + N02 + + (((data & 0x0F) + 1) & H10) + + SZ28( BYTE( data ) ); + if ( data != 0x7F ) + goto loop; + flags += V04; + goto loop; + + case 0x03: // INC BC + case 0x13: // INC DE + case 0x23: // INC HL + R16( opcode, 4, 0x03 )++; + goto loop; + + case 0x33: // INC SP + sp = WORD( sp + 1 ); + goto loop; + + case 0x0B: // DEC BC + case 0x1B: // DEC DE + case 0x2B: // DEC HL + R16( opcode, 4, 0x0B )--; + goto loop; + + case 0x3B: // DEC SP + sp = WORD( sp - 1 ); + goto loop; + +// AND + case 0xA6: // AND (HL) + data = READ_MEM( r.w.hl ); + goto and_data; + + case 0xE6: // AND imm + pc++; + goto and_data; + + CASE7( A0, A1, A2, A3, A4, A5, A7 ): // AND r + data = R8( opcode, 0xA0 ); + and_data: + r.b.a &= data; + flags = SZ28P( r.b.a ) + H10; + goto loop; + +// OR + case 0xB6: // OR (HL) + data = READ_MEM( r.w.hl ); + goto or_data; + + case 0xF6: // OR imm + pc++; + goto or_data; + + CASE7( B0, B1, B2, B3, B4, B5, B7 ): // OR r + data = R8( opcode, 0xB0 ); + or_data: + r.b.a |= data; + flags = SZ28P( r.b.a ); + goto loop; + +// XOR + case 0xAE: // XOR (HL) + data = READ_MEM( r.w.hl ); + goto xor_data; + + case 0xEE: // XOR imm + pc++; + goto xor_data; + + CASE7( A8, A9, AA, AB, AC, AD, AF ): // XOR r + data = R8( opcode, 0xA8 ); + xor_data: + r.b.a ^= data; + flags = SZ28P( r.b.a ); + goto loop; + +// LD + CASE7( 70, 71, 72, 73, 74, 75, 77 ): // LD (HL),r + WRITE_MEM( r.w.hl, R8( opcode, 0x70 ) ); + goto loop; + + CASE6( 41, 42, 43, 44, 45, 47 ): // LD B,r + CASE6( 48, 4A, 4B, 4C, 4D, 4F ): // LD C,r + CASE6( 50, 51, 53, 54, 55, 57 ): // LD D,r + CASE6( 58, 59, 5A, 5C, 5D, 5F ): // LD E,r + CASE6( 60, 61, 62, 63, 65, 67 ): // LD H,r + CASE6( 68, 69, 6A, 6B, 6C, 6F ): // LD L,r + CASE6( 78, 79, 7A, 7B, 7C, 7D ): // LD A,r + R8( opcode >> 3 & 7, 0 ) = R8( opcode & 7, 0 ); + goto loop; + + CASE5( 06, 0E, 16, 1E, 26 ): // LD r,imm + R8( opcode >> 3, 0 ) = data; + pc++; + goto loop; + + case 0x36: // LD (HL),imm + pc++; + WRITE_MEM( r.w.hl, data ); + goto loop; + + CASE7( 46, 4E, 56, 5E, 66, 6E, 7E ): // LD r,(HL) + R8( opcode >> 3, 8 ) = READ_MEM( r.w.hl ); + goto loop; + + case 0x01: // LD r.w,imm + case 0x11: + case 0x21: + R16( opcode, 4, 0x01 ) = GET_ADDR(); + pc += 2; + goto loop; + + case 0x31: // LD sp,imm + sp = GET_ADDR(); + pc += 2; + goto loop; + + case 0x2A:{// LD HL,(addr) + int addr = GET_ADDR(); + pc += 2; + r.w.hl = READ_WORD( addr ); + goto loop; + } + + case 0x32:{// LD (addr),A + int addr = GET_ADDR(); + pc += 2; + WRITE_MEM( addr, r.b.a ); + goto loop; + } + + case 0x22:{// LD (addr),HL + int addr = GET_ADDR(); + pc += 2; + WRITE_WORD( addr, r.w.hl ); + goto loop; + } + + case 0x02: // LD (BC),A + case 0x12: // LD (DE),A + WRITE_MEM( R16( opcode, 4, 0x02 ), r.b.a ); + goto loop; + + case 0x0A: // LD A,(BC) + case 0x1A: // LD A,(DE) + r.b.a = READ_MEM( R16( opcode, 4, 0x0A ) ); + goto loop; + + case 0xF9: // LD SP,HL + sp = r.w.hl; + goto loop; + +// Rotate + + case 0x07:{// RLCA + int temp = r.b.a; + temp = (temp << 1) + (temp >> 7); + flags = (flags & (S80 | Z40 | P04)) + + (temp & (F20 | F08 | C01)); + r.b.a = temp; + goto loop; + } + + case 0x0F:{// RRCA + int temp = r.b.a; + flags = (flags & (S80 | Z40 | P04)) + + (temp & C01); + temp = (temp << 7) + (temp >> 1); + flags += temp & (F20 | F08); + r.b.a = temp; + goto loop; + } + + case 0x17:{// RLA + int temp = (r.b.a << 1) + (flags & C01); + flags = (flags & (S80 | Z40 | P04)) + + (temp & (F20 | F08)) + + (temp >> 8); + r.b.a = temp; + goto loop; + } + + case 0x1F:{// RRA + int temp = (flags << 7) + (r.b.a >> 1); + flags = (flags & (S80 | Z40 | P04)) + + (temp & (F20 | F08)) + + (r.b.a & C01); + r.b.a = temp; + goto loop; + } + +// Misc + case 0x2F:{// CPL + int temp = ~r.b.a; + flags = (flags & (S80 | Z40 | P04 | C01)) + + (temp & (F20 | F08)) + + (H10 | N02); + r.b.a = temp; + goto loop; + } + + case 0x3F:{// CCF + flags = ((flags & (S80 | Z40 | P04 | C01)) ^ C01) + + (flags << 4 & H10) + + (r.b.a & (F20 | F08)); + goto loop; + } + + case 0x37: // SCF + flags = ((flags & (S80 | Z40 | P04)) | C01) + + (r.b.a & (F20 | F08)); + goto loop; + + case 0xDB: // IN A,(imm) + pc++; + r.b.a = IN_PORT( (data + r.b.a * 0x100) ); + goto loop; + + case 0xE3:{// EX (SP),HL + int temp = READ_WORD( sp ); + WRITE_WORD( sp, r.w.hl ); + r.w.hl = temp; + goto loop; + } + + case 0xEB: // EX DE,HL + EX( r.w.hl, r.w.de ); + goto loop; + + case 0xD9: // EXX DE,HL + EXX( w.bc ); + EXX( w.de ); + EXX( w.hl ); + goto loop; + + case 0xF3: // DI + R.iff1 = 0; + R.iff2 = 0; + goto loop; + + case 0xFB: // EI + R.iff1 = 1; + R.iff2 = 1; + // TODO: delayed effect + goto loop; + + case 0x76: // HALT + goto halt; + +//////////////////////////////////////// CB prefix + { + case 0xCB: + pc++; + switch ( data ) + { + + // Rotate left + + #define RLC( read, write ) {\ + int result = read;\ + result = BYTE( result << 1 ) + (result >> 7);\ + flags = SZ28P( result ) + (result & C01);\ + write;\ + goto loop;\ + } + + case 0x06: // RLC (HL) + s_time += 7; + data = r.w.hl; + rlc_data_addr: + RLC( READ_MEM( data ), WRITE_MEM( data, result ) ) + + CASE7( 00, 01, 02, 03, 04, 05, 07 ):{// RLC r + byte* reg = &R8( data, 0 ); + RLC( *reg, *reg = result ) + } + + #define RL( read, write ) {\ + int result = (read << 1) + (flags & C01);\ + flags = SZ28PC( result );\ + write;\ + goto loop;\ + } + + case 0x16: // RL (HL) + s_time += 7; + data = r.w.hl; + rl_data_addr: + RL( READ_MEM( data ), WRITE_MEM( data, result ) ) + + CASE7( 10, 11, 12, 13, 14, 15, 17 ):{// RL r + byte* reg = &R8( data, 0x10 ); + RL( *reg, *reg = result ) + } + + #define SLA( read, low_bit, write ) {\ + int result = (read << 1) + low_bit;\ + flags = SZ28PC( result );\ + write;\ + goto loop;\ + } + + case 0x26: // SLA (HL) + s_time += 7; + data = r.w.hl; + sla_data_addr: + SLA( READ_MEM( data ), 0, WRITE_MEM( data, result ) ) + + CASE7( 20, 21, 22, 23, 24, 25, 27 ):{// SLA r + byte* reg = &R8( data, 0x20 ); + SLA( *reg, 0, *reg = result ) + } + + case 0x36: // SLL (HL) + s_time += 7; + data = r.w.hl; + sll_data_addr: + SLA( READ_MEM( data ), 1, WRITE_MEM( data, result ) ) + + CASE7( 30, 31, 32, 33, 34, 35, 37 ):{// SLL r + byte* reg = &R8( data, 0x30 ); + SLA( *reg, 1, *reg = result ) + } + + // Rotate right + + #define RRC( read, write ) {\ + int result = read;\ + flags = result & C01;\ + result = BYTE( result << 7 ) + (result >> 1);\ + flags += SZ28P( result );\ + write;\ + goto loop;\ + } + + case 0x0E: // RRC (HL) + s_time += 7; + data = r.w.hl; + rrc_data_addr: + RRC( READ_MEM( data ), WRITE_MEM( data, result ) ) + + CASE7( 08, 09, 0A, 0B, 0C, 0D, 0F ):{// RRC r + byte* reg = &R8( data, 0x08 ); + RRC( *reg, *reg = result ) + } + + #define RR( read, write ) {\ + int result = read;\ + int temp = result & C01;\ + result = BYTE( flags << 7 ) + (result >> 1);\ + flags = SZ28P( result ) + temp;\ + write;\ + goto loop;\ + } + + case 0x1E: // RR (HL) + s_time += 7; + data = r.w.hl; + rr_data_addr: + RR( READ_MEM( data ), WRITE_MEM( data, result ) ) + + CASE7( 18, 19, 1A, 1B, 1C, 1D, 1F ):{// RR r + byte* reg = &R8( data, 0x18 ); + RR( *reg, *reg = result ) + } + + #define SRA( read, write ) {\ + int result = read;\ + flags = result & C01;\ + result = (result & 0x80) + (result >> 1);\ + flags += SZ28P( result );\ + write;\ + goto loop;\ + } + + case 0x2E: // SRA (HL) + data = r.w.hl; + s_time += 7; + sra_data_addr: + SRA( READ_MEM( data ), WRITE_MEM( data, result ) ) + + CASE7( 28, 29, 2A, 2B, 2C, 2D, 2F ):{// SRA r + byte* reg = &R8( data, 0x28 ); + SRA( *reg, *reg = result ) + } + + #define SRL( read, write ) {\ + int result = read;\ + flags = result & C01;\ + result >>= 1;\ + flags += SZ28P( result );\ + write;\ + goto loop;\ + } + + case 0x3E: // SRL (HL) + s_time += 7; + data = r.w.hl; + srl_data_addr: + SRL( READ_MEM( data ), WRITE_MEM( data, result ) ) + + CASE7( 38, 39, 3A, 3B, 3C, 3D, 3F ):{// SRL r + byte* reg = &R8( data, 0x38 ); + SRL( *reg, *reg = result ) + } + + // BIT + { + int temp; + CASE8( 46, 4E, 56, 5E, 66, 6E, 76, 7E ): // BIT b,(HL) + s_time += 4; + temp = READ_MEM( r.w.hl ); + flags &= C01; + goto bit_temp; + CASE7( 40, 41, 42, 43, 44, 45, 47 ): // BIT 0,r + CASE7( 48, 49, 4A, 4B, 4C, 4D, 4F ): // BIT 1,r + CASE7( 50, 51, 52, 53, 54, 55, 57 ): // BIT 2,r + CASE7( 58, 59, 5A, 5B, 5C, 5D, 5F ): // BIT 3,r + CASE7( 60, 61, 62, 63, 64, 65, 67 ): // BIT 4,r + CASE7( 68, 69, 6A, 6B, 6C, 6D, 6F ): // BIT 5,r + CASE7( 70, 71, 72, 73, 74, 75, 77 ): // BIT 6,r + CASE7( 78, 79, 7A, 7B, 7C, 7D, 7F ): // BIT 7,r + temp = R8( data & 7, 0 ); + flags = (flags & C01) + (temp & (F20 | F08)); + bit_temp: + temp = temp & (1 << (data >> 3 & 7)); + flags += (temp & S80) + H10; + flags += (unsigned) --temp >> 8 & (Z40 | P04); + goto loop; + } + + // SET/RES + CASE8( 86, 8E, 96, 9E, A6, AE, B6, BE ): // RES b,(HL) + CASE8( C6, CE, D6, DE, E6, EE, F6, FE ):{// SET b,(HL) + s_time += 7; + int temp = READ_MEM( r.w.hl ); + int bit = 1 << (data >> 3 & 7); + temp |= bit; // SET + if ( !(data & 0x40) ) + temp ^= bit; // RES + WRITE_MEM( r.w.hl, temp ); + goto loop; + } + + CASE7( C0, C1, C2, C3, C4, C5, C7 ): // SET 0,r + CASE7( C8, C9, CA, CB, CC, CD, CF ): // SET 1,r + CASE7( D0, D1, D2, D3, D4, D5, D7 ): // SET 2,r + CASE7( D8, D9, DA, DB, DC, DD, DF ): // SET 3,r + CASE7( E0, E1, E2, E3, E4, E5, E7 ): // SET 4,r + CASE7( E8, E9, EA, EB, EC, ED, EF ): // SET 5,r + CASE7( F0, F1, F2, F3, F4, F5, F7 ): // SET 6,r + CASE7( F8, F9, FA, FB, FC, FD, FF ): // SET 7,r + R8( data & 7, 0 ) |= 1 << (data >> 3 & 7); + goto loop; + + CASE7( 80, 81, 82, 83, 84, 85, 87 ): // RES 0,r + CASE7( 88, 89, 8A, 8B, 8C, 8D, 8F ): // RES 1,r + CASE7( 90, 91, 92, 93, 94, 95, 97 ): // RES 2,r + CASE7( 98, 99, 9A, 9B, 9C, 9D, 9F ): // RES 3,r + CASE7( A0, A1, A2, A3, A4, A5, A7 ): // RES 4,r + CASE7( A8, A9, AA, AB, AC, AD, AF ): // RES 5,r + CASE7( B0, B1, B2, B3, B4, B5, B7 ): // RES 6,r + CASE7( B8, B9, BA, BB, BC, BD, BF ): // RES 7,r + R8( data & 7, 0 ) &= ~(1 << (data >> 3 & 7)); + goto loop; + } + assert( false ); + } + +#undef GET_ADDR +#define GET_ADDR() GET_LE16( &INSTR( 1, pc ) ) + +//////////////////////////////////////// ED prefix + { + case 0xED: + pc++; + s_time += (clock_table + 256) [data] >> 4; + switch ( data ) + { + { + int temp; + case 0x72: // SBC HL,SP + case 0x7A: // ADC HL,SP + temp = sp; + if ( 0 ) + case 0x42: // SBC HL,BC + case 0x52: // SBC HL,DE + case 0x62: // SBC HL,HL + case 0x4A: // ADC HL,BC + case 0x5A: // ADC HL,DE + case 0x6A: // ADC HL,HL + temp = R16( data >> 3 & 6, 1, 0 ); + int sum = temp + (flags & C01); + flags = ~data >> 2 & N02; + if ( flags ) + sum = -sum; + sum += r.w.hl; + temp ^= r.w.hl; + temp ^= sum; + flags +=(sum >> 16 & C01) + + (temp >> 8 & H10) + + (sum >> 8 & (S80 | F20 | F08)) + + ((temp + 0x8000) >> 14 & V04); + r.w.hl = sum; + if ( WORD( sum ) ) + goto loop; + flags += Z40; + goto loop; + } + + CASE8( 40, 48, 50, 58, 60, 68, 70, 78 ):{// IN r,(C) + int temp = IN_PORT( r.w.bc ); + R8( data >> 3, 8 ) = temp; + flags = (flags & C01) + SZ28P( temp ); + goto loop; + } + + case 0x71: // OUT (C),0 + r.b.flags = 0; + CASE7( 41, 49, 51, 59, 61, 69, 79 ): // OUT (C),r + OUT_PORT( r.w.bc, R8( data >> 3, 8 ) ); + goto loop; + + { + int temp; + case 0x73: // LD (ADDR),SP + temp = sp; + if ( 0 ) + case 0x43: // LD (ADDR),BC + case 0x53: // LD (ADDR),DE + temp = R16( data, 4, 0x43 ); + int addr = GET_ADDR(); + pc += 2; + WRITE_WORD( addr, temp ); + goto loop; + } + + case 0x4B: // LD BC,(ADDR) + case 0x5B:{// LD DE,(ADDR) + int addr = GET_ADDR(); + pc += 2; + R16( data, 4, 0x4B ) = READ_WORD( addr ); + goto loop; + } + + case 0x7B:{// LD SP,(ADDR) + int addr = GET_ADDR(); + pc += 2; + sp = READ_WORD( addr ); + goto loop; + } + + case 0x67:{// RRD + int temp = READ_MEM( r.w.hl ); + WRITE_MEM( r.w.hl, ((r.b.a << 4) + (temp >> 4)) ); + temp = (r.b.a & 0xF0) + (temp & 0x0F); + flags = (flags & C01) + SZ28P( temp ); + r.b.a = temp; + goto loop; + } + + case 0x6F:{// RLD + int temp = READ_MEM( r.w.hl ); + WRITE_MEM( r.w.hl, ((temp << 4) + (r.b.a & 0x0F)) ); + temp = (r.b.a & 0xF0) + (temp >> 4); + flags = (flags & C01) + SZ28P( temp ); + r.b.a = temp; + goto loop; + } + + CASE8( 44, 4C, 54, 5C, 64, 6C, 74, 7C ): // NEG + opcode = 0x10; // flag to do SBC instead of ADC + flags &= ~C01; + data = r.b.a; + r.b.a = 0; + goto adc_data; + + { + int inc; + case 0xA9: // CPD + case 0xB9: // CPDR + inc = -1; + if ( 0 ) + case 0xA1: // CPI + case 0xB1: // CPIR + inc = +1; + int addr = r.w.hl; + r.w.hl = addr + inc; + int temp = READ_MEM( addr ); + + int result = r.b.a - temp; + flags = (flags & C01) + N02 + + ((((temp ^ r.b.a) & H10) ^ result) & (S80 | H10)); + + if ( !BYTE( result ) ) + flags += Z40; + result -= (flags & H10) >> 4; + flags += result & F08; + flags += result << 4 & F20; + if ( !--r.w.bc ) + goto loop; + + flags += V04; + if ( flags & Z40 || data < 0xB0 ) + goto loop; + + pc -= 2; + s_time += 5; + goto loop; + } + + { + int inc; + case 0xA8: // LDD + case 0xB8: // LDDR + inc = -1; + if ( 0 ) + case 0xA0: // LDI + case 0xB0: // LDIR + inc = +1; + int addr = r.w.hl; + r.w.hl = addr + inc; + int temp = READ_MEM( addr ); + + addr = r.w.de; + r.w.de = addr + inc; + WRITE_MEM( addr, temp ); + + temp += r.b.a; + flags = (flags & (S80 | Z40 | C01)) + + (temp & F08) + (temp << 4 & F20); + if ( !--r.w.bc ) + goto loop; + + flags += V04; + if ( data < 0xB0 ) + goto loop; + + pc -= 2; + s_time += 5; + goto loop; + } + + { + int inc; + case 0xAB: // OUTD + case 0xBB: // OTDR + inc = -1; + if ( 0 ) + case 0xA3: // OUTI + case 0xB3: // OTIR + inc = +1; + int addr = r.w.hl; + r.w.hl = addr + inc; + int temp = READ_MEM( addr ); + + int b = --r.b.b; + flags = (temp >> 6 & N02) + SZ28( b ); + if ( b && data >= 0xB0 ) + { + pc -= 2; + s_time += 5; + } + + OUT_PORT( r.w.bc, temp ); + goto loop; + } + + { + int inc; + case 0xAA: // IND + case 0xBA: // INDR + inc = -1; + if ( 0 ) + case 0xA2: // INI + case 0xB2: // INIR + inc = +1; + + int addr = r.w.hl; + r.w.hl = addr + inc; + + int temp = IN_PORT( r.w.bc ); + + int b = --r.b.b; + flags = (temp >> 6 & N02) + SZ28( b ); + if ( b && data >= 0xB0 ) + { + pc -= 2; + s_time += 5; + } + + WRITE_MEM( addr, temp ); + goto loop; + } + + case 0x47: // LD I,A + R.i = r.b.a; + goto loop; + + case 0x4F: // LD R,A + SET_R( r.b.a ); + dprintf( "LD R,A not supported\n" ); + warning = true; + goto loop; + + case 0x57: // LD A,I + r.b.a = R.i; + goto ld_ai_common; + + case 0x5F: // LD A,R + r.b.a = GET_R(); + dprintf( "LD A,R not supported\n" ); + warning = true; + ld_ai_common: + flags = (flags & C01) + SZ28( r.b.a ) + (R.iff2 << 2 & V04); + goto loop; + + CASE8( 45, 4D, 55, 5D, 65, 6D, 75, 7D ): // RETI/RETN + R.iff1 = R.iff2; + goto ret_taken; + + case 0x46: case 0x4E: case 0x66: case 0x6E: // IM 0 + R.im = 0; + goto loop; + + case 0x56: case 0x76: // IM 1 + R.im = 1; + goto loop; + + case 0x5E: case 0x7E: // IM 2 + R.im = 2; + goto loop; + + default: + dprintf( "Opcode $ED $%02X not supported\n", data ); + warning = true; + goto loop; + } + assert( false ); + } + +//////////////////////////////////////// DD/FD prefix + { + int ixy; + case 0xDD: + ixy = ix; + goto ix_prefix; + case 0xFD: + ixy = iy; + ix_prefix: + pc++; + int data2 = READ_CODE( pc ); + s_time += (clock_table + 256) [data] & 0x0F; + switch ( data ) + { + // TODO: more efficient way of avoid negative address + // TODO: avoid using this as argument to READ_MEM() since it is evaluated twice + #define IXY_DISP( ixy, disp ) WORD( (ixy ) + (disp)) + + #define SET_IXY( in ) if ( opcode == 0xDD ) ix = in; else iy = in; + + // ADD/ADC/SUB/SBC + + case 0x96: // SUB (IXY+disp) + case 0x86: // ADD (IXY+disp) + flags &= ~C01; + case 0x9E: // SBC (IXY+disp) + case 0x8E: // ADC (IXY+disp) + pc++; + opcode = data; + data = READ_MEM( IXY_DISP( ixy, SBYTE( data2 ) ) ); + goto adc_data; + + case 0x94: // SUB HXY + case 0x84: // ADD HXY + flags &= ~C01; + case 0x9C: // SBC HXY + case 0x8C: // ADC HXY + opcode = data; + data = ixy >> 8; + goto adc_data; + + case 0x95: // SUB LXY + case 0x85: // ADD LXY + flags &= ~C01; + case 0x9D: // SBC LXY + case 0x8D: // ADC LXY + opcode = data; + data = BYTE( ixy ); + goto adc_data; + + { + int temp; + case 0x39: // ADD IXY,SP + temp = sp; + goto add_ixy_data; + + case 0x29: // ADD IXY,HL + temp = ixy; + goto add_ixy_data; + + case 0x09: // ADD IXY,BC + case 0x19: // ADD IXY,DE + temp = R16( data, 4, 0x09 ); + add_ixy_data: { + int sum = ixy + temp; + temp ^= ixy; + ixy = WORD( sum ); + flags = (flags & (S80 | Z40 | V04)) + + (sum >> 16) + + (sum >> 8 & (F20 | F08)) + + ((temp ^ sum) >> 8 & H10); + goto set_ixy; + } + } + + // AND + case 0xA6: // AND (IXY+disp) + pc++; + data = READ_MEM( IXY_DISP( ixy, SBYTE( data2 ) ) ); + goto and_data; + + case 0xA4: // AND HXY + data = ixy >> 8; + goto and_data; + + case 0xA5: // AND LXY + data = BYTE( ixy ); + goto and_data; + + // OR + case 0xB6: // OR (IXY+disp) + pc++; + data = READ_MEM( IXY_DISP( ixy, SBYTE( data2 ) ) ); + goto or_data; + + case 0xB4: // OR HXY + data = ixy >> 8; + goto or_data; + + case 0xB5: // OR LXY + data = BYTE( ixy ); + goto or_data; + + // XOR + case 0xAE: // XOR (IXY+disp) + pc++; + data = READ_MEM( IXY_DISP( ixy, SBYTE( data2 ) ) ); + goto xor_data; + + case 0xAC: // XOR HXY + data = ixy >> 8; + goto xor_data; + + case 0xAD: // XOR LXY + data = BYTE( ixy ); + goto xor_data; + + // CP + case 0xBE: // CP (IXY+disp) + pc++; + data = READ_MEM( IXY_DISP( ixy, SBYTE( data2 ) ) ); + goto cp_data; + + case 0xBC: // CP HXY + data = ixy >> 8; + goto cp_data; + + case 0xBD: // CP LXY + data = BYTE( ixy ); + goto cp_data; + + // LD + CASE7( 70, 71, 72, 73, 74, 75, 77 ): // LD (IXY+disp),r + data = R8( data, 0x70 ); + if ( 0 ) + case 0x36: // LD (IXY+disp),imm + pc++, data = READ_CODE( pc ); + pc++; + WRITE_MEM( IXY_DISP( ixy, SBYTE( data2 ) ), data ); + goto loop; + + CASE5( 44, 4C, 54, 5C, 7C ): // LD r,HXY + R8( data >> 3, 8 ) = ixy >> 8; + goto loop; + + case 0x64: // LD HXY,HXY + case 0x6D: // LD LXY,LXY + goto loop; + + CASE5( 45, 4D, 55, 5D, 7D ): // LD r,LXY + R8( data >> 3, 8 ) = ixy; + goto loop; + + CASE7( 46, 4E, 56, 5E, 66, 6E, 7E ): // LD r,(IXY+disp) + pc++; + R8( data >> 3, 8 ) = READ_MEM( IXY_DISP( ixy, SBYTE( data2 ) ) ); + goto loop; + + case 0x26: // LD HXY,imm + pc++; + goto ld_hxy_data; + + case 0x65: // LD HXY,LXY + data2 = BYTE( ixy ); + goto ld_hxy_data; + + CASE5( 60, 61, 62, 63, 67 ): // LD HXY,r + data2 = R8( data, 0x60 ); + ld_hxy_data: + ixy = BYTE( ixy ) + (data2 << 8); + goto set_ixy; + + case 0x2E: // LD LXY,imm + pc++; + goto ld_lxy_data; + + case 0x6C: // LD LXY,HXY + data2 = ixy >> 8; + goto ld_lxy_data; + + CASE5( 68, 69, 6A, 6B, 6F ): // LD LXY,r + data2 = R8( data, 0x68 ); + ld_lxy_data: + ixy = (ixy & 0xFF00) + data2; + set_ixy: + if ( opcode == 0xDD ) + { + ix = ixy; + goto loop; + } + iy = ixy; + goto loop; + + case 0xF9: // LD SP,IXY + sp = ixy; + goto loop; + + case 0x22:{// LD (ADDR),IXY + int addr = GET_ADDR(); + pc += 2; + WRITE_WORD( addr, ixy ); + goto loop; + } + + case 0x21: // LD IXY,imm + ixy = GET_ADDR(); + pc += 2; + goto set_ixy; + + case 0x2A:{// LD IXY,(addr) + int addr = GET_ADDR(); + ixy = READ_WORD( addr ); + pc += 2; + goto set_ixy; + } + + // DD/FD CB prefix + case 0xCB: { + data = IXY_DISP( ixy, SBYTE( data2 ) ); + pc++; + data2 = READ_CODE( pc ); + pc++; + switch ( data2 ) + { + case 0x06: goto rlc_data_addr; // RLC (IXY) + case 0x16: goto rl_data_addr; // RL (IXY) + case 0x26: goto sla_data_addr; // SLA (IXY) + case 0x36: goto sll_data_addr; // SLL (IXY) + case 0x0E: goto rrc_data_addr; // RRC (IXY) + case 0x1E: goto rr_data_addr; // RR (IXY) + case 0x2E: goto sra_data_addr; // SRA (IXY) + case 0x3E: goto srl_data_addr; // SRL (IXY) + + CASE8( 46, 4E, 56, 5E, 66, 6E, 76, 7E ):{// BIT b,(IXY+disp) + int temp = READ_MEM( data ); + temp = temp & (1 << (data2 >> 3 & 7)); + flags = (flags & C01) + H10 + (temp & S80); + flags += (unsigned) --temp >> 8 & (Z40 | P04); + goto loop; + } + + CASE8( 86, 8E, 96, 9E, A6, AE, B6, BE ): // RES b,(IXY+disp) + CASE8( C6, CE, D6, DE, E6, EE, F6, FE ):{// SET b,(IXY+disp) + int temp = READ_MEM( data ); + int bit = 1 << (data2 >> 3 & 7); + temp |= bit; // SET + if ( !(data2 & 0x40) ) + temp ^= bit; // RES + WRITE_MEM( data, temp ); + goto loop; + } + + default: + dprintf( "Opcode $%02X $CB $%02X not supported\n", opcode, data2 ); + warning = true; + goto loop; + } + assert( false ); + } + + // INC/DEC + case 0x23: // INC IXY + ixy = WORD( ixy + 1 ); + goto set_ixy; + + case 0x2B: // DEC IXY + ixy = WORD( ixy - 1 ); + goto set_ixy; + + case 0x34: // INC (IXY+disp) + ixy = IXY_DISP( ixy, SBYTE( data2 ) ); + pc++; + data = READ_MEM( ixy ) + 1; + WRITE_MEM( ixy, data ); + goto inc_set_flags; + + case 0x35: // DEC (IXY+disp) + ixy = IXY_DISP( ixy, SBYTE( data2 ) ); + pc++; + data = READ_MEM( ixy ) - 1; + WRITE_MEM( ixy, data ); + goto dec_set_flags; + + case 0x24: // INC HXY + ixy = WORD( ixy + 0x100 ); + data = ixy >> 8; + goto inc_xy_common; + + case 0x2C: // INC LXY + data = BYTE( ixy + 1 ); + ixy = (ixy & 0xFF00) + data; + inc_xy_common: + if ( opcode == 0xDD ) + { + ix = ixy; + goto inc_set_flags; + } + iy = ixy; + goto inc_set_flags; + + case 0x25: // DEC HXY + ixy = WORD( ixy - 0x100 ); + data = ixy >> 8; + goto dec_xy_common; + + case 0x2D: // DEC LXY + data = BYTE( ixy - 1 ); + ixy = (ixy & 0xFF00) + data; + dec_xy_common: + if ( opcode == 0xDD ) + { + ix = ixy; + goto dec_set_flags; + } + iy = ixy; + goto dec_set_flags; + + // PUSH/POP + case 0xE5: // PUSH IXY + data = ixy; + goto push_data; + + case 0xE1:{// POP IXY + ixy = READ_WORD( sp ); + sp = WORD( sp + 2 ); + goto set_ixy; + } + + // Misc + + case 0xE9: // JP (IXY) + pc = ixy; + goto loop; + + case 0xE3:{// EX (SP),IXY + int temp = READ_WORD( sp ); + WRITE_WORD( sp, ixy ); + ixy = temp; + goto set_ixy; + } + + default: + dprintf( "Unnecessary DD/FD prefix encountered\n" ); + warning = true; + pc--; + goto loop; + } + assert( false ); + } + + } + dprintf( "Unhandled main opcode: $%02X\n", opcode ); + assert( false ); + +#ifdef IDLE_ADDR +hit_idle_addr: + s_time -= 11; + goto out_of_time; +#endif +halt: + s_time &= 3; // increment by multiple of 4 +out_of_time: + pc--; + + r.b.flags = flags; + R.ix = ix; + R.iy = iy; + R.sp = sp; + R.pc = pc; + R.b = r.b; + + cpu->cpu_state_.base = s.base; + cpu->cpu_state_.time = s_time; + cpu->cpu_state = &cpu->cpu_state_; +} diff --git a/lib/rbcodec/codecs/libm4a/SOURCES b/lib/rbcodec/codecs/libm4a/SOURCES new file mode 100644 index 0000000000..01b93bef01 --- /dev/null +++ b/lib/rbcodec/codecs/libm4a/SOURCES @@ -0,0 +1,2 @@ +m4a.c +demux.c diff --git a/lib/rbcodec/codecs/libm4a/demux.c b/lib/rbcodec/codecs/libm4a/demux.c new file mode 100644 index 0000000000..7b09074c52 --- /dev/null +++ b/lib/rbcodec/codecs/libm4a/demux.c @@ -0,0 +1,826 @@ +/* + * ALAC (Apple Lossless Audio Codec) decoder + * Copyright (c) 2005 David Hammerton + * All rights reserved. + * + * This is the quicktime container demuxer. + * + * http://crazney.net/programs/itunes/alac.html + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + */ + +#include +#include +#include + +#include "codeclib.h" + +#include "m4a.h" + +#undef DEBUGF +#if defined(DEBUG) +#define DEBUGF qtmovie->stream->ci->debugf +#else +#define DEBUGF(...) +#endif + +typedef struct +{ + stream_t *stream; + demux_res_t *res; +} qtmovie_t; + + +/* chunk handlers */ +static void read_chunk_ftyp(qtmovie_t *qtmovie, size_t chunk_len) +{ + fourcc_t type; + size_t size_remaining = chunk_len - 8; + + type = stream_read_uint32(qtmovie->stream); + size_remaining-=4; + if ((type != MAKEFOURCC('M','4','A',' ')) && + (type != MAKEFOURCC('m','4','a',' ')) && + (type != MAKEFOURCC('M','4','B',' ')) && + (type != MAKEFOURCC('m','p','4','2')) && + (type != MAKEFOURCC('3','g','p','6')) && + (type != MAKEFOURCC('q','t',' ',' ')) && + (type != MAKEFOURCC('i','s','o','m'))) + { + DEBUGF("not M4A file\n"); + return; + } + /* minor_ver = */ stream_read_uint32(qtmovie->stream); + size_remaining-=4; + + /* compatible brands */ + while (size_remaining) + { + /* unused */ + /*fourcc_t cbrand =*/ stream_read_uint32(qtmovie->stream); + size_remaining-=4; + } +} + +static uint32_t mp4ff_read_mp4_descr_length(stream_t* stream) +{ + uint8_t b; + uint8_t numBytes = 0; + uint32_t length = 0; + + do + { + b = stream_read_uint8(stream); + numBytes++; + length = (length << 7) | (b & 0x7F); + } while ((b & 0x80) && numBytes < 4); + + return length; +} + +/* The following function is based on mp4ff */ +static bool read_chunk_esds(qtmovie_t *qtmovie, size_t chunk_len) +{ + uint8_t tag; + uint32_t temp; + + (void)chunk_len; + /* version and flags */ + temp=stream_read_uint32(qtmovie->stream); + + /* get and verify ES_DescrTag */ + tag = stream_read_uint8(qtmovie->stream); + if (tag == 0x03) + { + /* read length */ + if (mp4ff_read_mp4_descr_length(qtmovie->stream) < 5 + 15) + { + return false; + } + /* skip 3 bytes */ + stream_skip(qtmovie->stream,3); + } else { + /* skip 2 bytes */ + stream_skip(qtmovie->stream,2); + } + + /* get and verify DecoderConfigDescrTab */ + if (stream_read_uint8(qtmovie->stream) != 0x04) + { + return false; + } + + /* read length */ + temp = mp4ff_read_mp4_descr_length(qtmovie->stream); + if (temp < 13) return false; + + /* audioType = */ stream_read_uint8(qtmovie->stream); + /* temp = */ stream_read_int32(qtmovie->stream);//0x15000414 ???? + /* maxBitrate = */ stream_read_int32(qtmovie->stream); + /* avgBitrate = */ stream_read_int32(qtmovie->stream); + + /* get and verify DecSpecificInfoTag */ + if (stream_read_uint8(qtmovie->stream) != 0x05) + { + return false; + } + + /* read length */ + qtmovie->res->codecdata_len = mp4ff_read_mp4_descr_length(qtmovie->stream); + if (qtmovie->res->codecdata_len > MAX_CODECDATA_SIZE) + { + DEBUGF("codecdata too large (%d) in esds\n", + (int)qtmovie->res->codecdata_len); + return false; + } + + stream_read(qtmovie->stream, qtmovie->res->codecdata_len, qtmovie->res->codecdata); + + /* will skip the remainder of the atom */ + return true; +} + +static bool read_chunk_stsd(qtmovie_t *qtmovie, size_t chunk_len) +{ + unsigned int i; + int j; + uint32_t numentries; + size_t size_remaining = chunk_len - 8; + bool got_codec_data = false; + + /* version */ + stream_read_uint8(qtmovie->stream); + size_remaining -= 1; + /* flags */ + stream_read_uint8(qtmovie->stream); + stream_read_uint8(qtmovie->stream); + stream_read_uint8(qtmovie->stream); + size_remaining -= 3; + + numentries = stream_read_uint32(qtmovie->stream); + size_remaining -= 4; + + /* if (numentries != 1) + { + DEBUGF("only expecting one entry in sample description atom!\n"); + return false; + } */ + + for (i = 0; i < numentries; i++) + { + uint32_t entry_size; + + uint32_t entry_remaining; + + entry_size = stream_read_uint32(qtmovie->stream); + qtmovie->res->format = stream_read_uint32(qtmovie->stream); + DEBUGF("format: %c%c%c%c\n",SPLITFOURCC(qtmovie->res->format)); + entry_remaining = entry_size; + entry_remaining -= 8; + + /* sound info: */ + + /* reserved + data reference index + sound version + reserved */ + stream_skip(qtmovie->stream, 6 + 2 + 2 + 6); + entry_remaining -= 6 + 2 + 2 + 6; + + qtmovie->res->num_channels = stream_read_uint16(qtmovie->stream); + qtmovie->res->sound_sample_size = stream_read_uint16(qtmovie->stream); + entry_remaining -= 4; + + /* packet size */ + stream_skip(qtmovie->stream, 2); + qtmovie->res->sound_sample_rate = stream_read_uint32(qtmovie->stream); + /* reserved size */ + stream_skip(qtmovie->stream, 2); + entry_remaining -= 8; + + /* remaining is codec data */ + + if ((qtmovie->res->format==MAKEFOURCC('a','l','a','c'))) { + if (qtmovie->stream->ci->id3->codectype!=AFMT_MP4_ALAC) { + return false; + } + + /* 12 = audio format atom, 8 = padding */ + qtmovie->res->codecdata_len = entry_remaining + 12 + 8; + if (qtmovie->res->codecdata_len > MAX_CODECDATA_SIZE) + { + DEBUGF("codecdata too large (%d) in stsd\n", + (int)qtmovie->res->codecdata_len); + return false; + } + + memset(qtmovie->res->codecdata, 0, qtmovie->res->codecdata_len); + /* audio format atom */ +#if 0 + /* The ALAC decoder skips these bytes, so there is no need to store them, + and this code isn't endian/alignment safe */ + ((unsigned int*)qtmovie->res->codecdata)[0] = 0x0c000000; + ((unsigned int*)qtmovie->res->codecdata)[1] = MAKEFOURCC('a','m','r','f'); + ((unsigned int*)qtmovie->res->codecdata)[2] = MAKEFOURCC('c','a','l','a'); +#endif + + stream_read(qtmovie->stream, + entry_remaining, + ((char*)qtmovie->res->codecdata) + 12); + entry_remaining -= entry_remaining; + got_codec_data = true; + + if (entry_remaining) + stream_skip(qtmovie->stream, entry_remaining); + + } else if (qtmovie->res->format==MAKEFOURCC('m','p','4','a')) { + if (qtmovie->stream->ci->id3->codectype!=AFMT_MP4_AAC && + qtmovie->stream->ci->id3->codectype!=AFMT_MP4_AAC_HE) { + return false; + } + + size_t sub_chunk_len; + fourcc_t sub_chunk_id; + + sub_chunk_len = stream_read_uint32(qtmovie->stream); + if (sub_chunk_len <= 1 || sub_chunk_len > entry_remaining) + { + DEBUGF("strange size (%lu) for chunk inside mp4a\n", + (unsigned long)sub_chunk_len); + return false; + } + + sub_chunk_id = stream_read_uint32(qtmovie->stream); + + if (sub_chunk_id != MAKEFOURCC('e','s','d','s')) + { + DEBUGF("Expected esds chunk inside mp4a, found %c%c%c%c\n",SPLITFOURCC(sub_chunk_id)); + return false; + } + + j=qtmovie->stream->ci->curpos+sub_chunk_len-8; + if (read_chunk_esds(qtmovie,sub_chunk_len)) { + if (j!=qtmovie->stream->ci->curpos) { + DEBUGF("curpos=%ld, j=%d - Skipping %ld bytes\n",qtmovie->stream->ci->curpos,j,j-qtmovie->stream->ci->curpos); + stream_skip(qtmovie->stream,j-qtmovie->stream->ci->curpos); + } + got_codec_data = true; + entry_remaining-=sub_chunk_len; + } else { + DEBUGF("Error reading esds\n"); + return false; + } + + DEBUGF("entry_remaining=%ld\n",(long)entry_remaining); + stream_skip(qtmovie->stream,entry_remaining); + + } else if (qtmovie->res->format==MAKEFOURCC('f','r','e','e')) { + /* Skip "filler" atom */ + stream_skip(qtmovie->stream,entry_remaining); + } else { + DEBUGF("expecting 'alac', 'mp4a' or 'free' data format, got %c%c%c%c\n", + SPLITFOURCC(qtmovie->res->format)); + return false; + } + } + return got_codec_data; +} + +static bool read_chunk_stts(qtmovie_t *qtmovie, size_t chunk_len) +{ + unsigned int i; + uint32_t numentries; + size_t size_remaining = chunk_len - 8; + + /* version */ + stream_read_uint8(qtmovie->stream); + size_remaining -= 1; + /* flags */ + stream_read_uint8(qtmovie->stream); + stream_read_uint8(qtmovie->stream); + stream_read_uint8(qtmovie->stream); + size_remaining -= 3; + + numentries = stream_read_uint32(qtmovie->stream); + size_remaining -= 4; + + qtmovie->res->num_time_to_samples = numentries; + qtmovie->res->time_to_sample = malloc(numentries * sizeof(*qtmovie->res->time_to_sample)); + + if (!qtmovie->res->time_to_sample) + { + DEBUGF("stts too large\n"); + return false; + } + + for (i = 0; i < numentries; i++) + { + qtmovie->res->time_to_sample[i].sample_count = stream_read_uint32(qtmovie->stream); + qtmovie->res->time_to_sample[i].sample_duration = stream_read_uint32(qtmovie->stream); + size_remaining -= 8; + } + + if (size_remaining) + { + DEBUGF("ehm, size remianing?\n"); + stream_skip(qtmovie->stream, size_remaining); + } + + return true; +} + +static bool read_chunk_stsz(qtmovie_t *qtmovie, size_t chunk_len) +{ + size_t size_remaining = chunk_len - 8; + + /* version */ + stream_read_uint8(qtmovie->stream); + size_remaining -= 1; + /* flags */ + stream_read_uint8(qtmovie->stream); + stream_read_uint8(qtmovie->stream); + stream_read_uint8(qtmovie->stream); + size_remaining -= 3; + + /* default sample size */ + if (stream_read_uint32(qtmovie->stream) != 0) + { + DEBUGF("i was expecting variable samples sizes\n"); + stream_read_uint32(qtmovie->stream); + size_remaining -= 4; + return true; + } + size_remaining -= 4; + + qtmovie->res->num_sample_byte_sizes = stream_read_uint32(qtmovie->stream); + size_remaining -= 4; + + if (size_remaining) + { + stream_skip(qtmovie->stream, size_remaining); + } + + return true; +} + +static bool read_chunk_stsc(qtmovie_t *qtmovie, size_t chunk_len) +{ + unsigned int i; + uint32_t numentries; + size_t size_remaining = chunk_len - 8; + + /* version + flags */ + stream_read_uint32(qtmovie->stream); + size_remaining -= 4; + + numentries = stream_read_uint32(qtmovie->stream); + size_remaining -= 4; + + qtmovie->res->num_sample_to_chunks = numentries; + qtmovie->res->sample_to_chunk = malloc(numentries * sizeof(sample_to_chunk_t)); + + if (!qtmovie->res->sample_to_chunk) + { + DEBUGF("stsc too large\n"); + return false; + } + + for (i = 0; i < numentries; i++) + { + qtmovie->res->sample_to_chunk[i].first_chunk = + stream_read_uint32(qtmovie->stream); + qtmovie->res->sample_to_chunk[i].num_samples = + stream_read_uint32(qtmovie->stream); + stream_read_uint32(qtmovie->stream); + size_remaining -= 12; + } + + if (size_remaining) + { + DEBUGF("ehm, size remianing?\n"); + stream_skip(qtmovie->stream, size_remaining); + } + + return true; +} + +static bool read_chunk_stco(qtmovie_t *qtmovie, size_t chunk_len) +{ + uint32_t i, k, old_i; + uint32_t numentries; + uint32_t idx = 0; + uint32_t frame; + uint32_t offset; + uint32_t old_first; + uint32_t new_first; + uint32_t old_frame; + size_t size_remaining = chunk_len - 8; + + /* version + flags */ + stream_read_uint32(qtmovie->stream); + size_remaining -= 4; + + numentries = stream_read_uint32(qtmovie->stream); + size_remaining -= 4; + + qtmovie->res->num_lookup_table = numentries; + qtmovie->res->lookup_table = malloc(numentries * sizeof(*qtmovie->res->lookup_table)); + + if (!qtmovie->res->lookup_table) + { + DEBUGF("stco too large to allocate lookup_table[]\n"); + return false; + } + + /* read first offset */ + offset = stream_read_uint32(qtmovie->stream); + size_remaining -= 4; + + /* Build up lookup table. The lookup table contains the sample index and + * byte position in the file for each chunk. This table is used to seek + * and resume (see m4a_seek() and m4a_seek_raw() in libm4a/m4a.c) and + * to skip empty chunks (see m4a_check_sample_offset() in codecs/aac.c and + * libm4a/m4a.c). + * The seek/resume precision is lower than using sample_byte_size[] and + * depends on numentries. Typically the resolution is ~1/10 of all frames + * which equals about 1/4-1/2 seconds. The loss of seek precision is + * accepted to be able to avoid allocation of the large sample_byte_size[] + * table. This reduces the memory consumption by a factor of 2 or even + * more. */ + i = 1; + old_i = 1; + frame = 0; + old_first = qtmovie->res->sample_to_chunk[0].first_chunk; + old_frame = qtmovie->res->sample_to_chunk[0].num_samples; + new_first = qtmovie->res->sample_to_chunk[1].first_chunk; + for (k = 1; k < numentries; ++k) + { + for (; i < qtmovie->res->num_sample_to_chunks; ++i) + { + if (i > old_i) + { + /* Only access sample_to_chunk[] if new data is required. */ + old_first = qtmovie->res->sample_to_chunk[i-1].first_chunk; + old_frame = qtmovie->res->sample_to_chunk[i-1].num_samples; + new_first = qtmovie->res->sample_to_chunk[i ].first_chunk; + old_i = i; + } + + if (new_first > k) + break; + + frame += (new_first - old_first) * old_frame; + } + frame += (k - old_first) * old_frame; + + qtmovie->res->lookup_table[idx].sample = frame; + qtmovie->res->lookup_table[idx].offset = offset; + idx++; + + frame -= (k - old_first) * old_frame; + + offset = stream_read_uint32(qtmovie->stream); + size_remaining -= 4; + } + /* zero-terminate the lookup table */ + qtmovie->res->lookup_table[idx].sample = 0; + qtmovie->res->lookup_table[idx].offset = 0; + + if (size_remaining) + { + DEBUGF("ehm, size remianing?\n"); + stream_skip(qtmovie->stream, size_remaining); + } + + return true; +} + +static bool read_chunk_stbl(qtmovie_t *qtmovie, size_t chunk_len) +{ + size_t size_remaining = chunk_len - 8; + + while (size_remaining) + { + size_t sub_chunk_len; + fourcc_t sub_chunk_id; + + sub_chunk_len = stream_read_uint32(qtmovie->stream); + if (sub_chunk_len <= 1 || sub_chunk_len > size_remaining) + { + DEBUGF("strange size (%lu) for chunk inside stbl\n", + (unsigned long)sub_chunk_len); + return false; + } + + sub_chunk_id = stream_read_uint32(qtmovie->stream); + + switch (sub_chunk_id) + { + case MAKEFOURCC('s','t','s','d'): + if (!read_chunk_stsd(qtmovie, sub_chunk_len)) { + return false; + } + break; + case MAKEFOURCC('s','t','t','s'): + if (!read_chunk_stts(qtmovie, sub_chunk_len)) + { + return false; + } + break; + case MAKEFOURCC('s','t','s','z'): + if (!read_chunk_stsz(qtmovie, sub_chunk_len)) + { + return false; + } + break; + case MAKEFOURCC('s','t','s','c'): + if (!read_chunk_stsc(qtmovie, sub_chunk_len)) + { + return false; + } + break; + case MAKEFOURCC('s','t','c','o'): + if (!read_chunk_stco(qtmovie, sub_chunk_len)) + { + return false; + } + break; + default: + /*DEBUGF("(stbl) unknown chunk id: %c%c%c%c\n", + SPLITFOURCC(sub_chunk_id));*/ + stream_skip(qtmovie->stream, sub_chunk_len - 8); + } + + size_remaining -= sub_chunk_len; + } + return true; +} + +static bool read_chunk_minf(qtmovie_t *qtmovie, size_t chunk_len) +{ + size_t size_remaining = chunk_len - 8; + uint32_t i; + + /* Check for smhd, only kind of minf we care about */ + + if ((i = stream_read_uint32(qtmovie->stream)) != 16) + { + DEBUGF("unexpected size in media info: %ld\n", (long)i); + stream_skip(qtmovie->stream, size_remaining-4); + return true; + } + + if (stream_read_uint32(qtmovie->stream) != MAKEFOURCC('s','m','h','d')) + { + DEBUGF("not a sound header! can't handle this.\n"); + return false; + } + + /* now skip the rest of the atom */ + stream_skip(qtmovie->stream, 16 - 8); + size_remaining -= 16; + + while (size_remaining) + { + size_t sub_chunk_len; + fourcc_t sub_chunk_id; + + sub_chunk_len = stream_read_uint32(qtmovie->stream); + + if (sub_chunk_len <= 1 || sub_chunk_len > size_remaining) + { + DEBUGF("strange size (%lu) for chunk inside minf\n", + (unsigned long)sub_chunk_len); + return false; + } + + sub_chunk_id = stream_read_uint32(qtmovie->stream); + + switch (sub_chunk_id) + { + case MAKEFOURCC('s','t','b','l'): + if (!read_chunk_stbl(qtmovie, sub_chunk_len)) { + return false; + } + break; + default: + /*DEBUGF("(minf) unknown chunk id: %c%c%c%c\n", + SPLITFOURCC(sub_chunk_id));*/ + stream_skip(qtmovie->stream, sub_chunk_len - 8); + break; + } + + size_remaining -= sub_chunk_len; + } + return true; +} + +static bool read_chunk_mdia(qtmovie_t *qtmovie, size_t chunk_len) +{ + size_t size_remaining = chunk_len - 8; + + while (size_remaining) + { + size_t sub_chunk_len; + fourcc_t sub_chunk_id; + + sub_chunk_len = stream_read_uint32(qtmovie->stream); + if (sub_chunk_len <= 1 || sub_chunk_len > size_remaining) + { + DEBUGF("strange size (%lu) for chunk inside mdia\n", + (unsigned long)sub_chunk_len); + return false; + } + + sub_chunk_id = stream_read_uint32(qtmovie->stream); + + switch (sub_chunk_id) + { + case MAKEFOURCC('m','i','n','f'): + if (!read_chunk_minf(qtmovie, sub_chunk_len)) { + return false; + } + break; + default: + /*DEBUGF("(mdia) unknown chunk id: %c%c%c%c\n", + SPLITFOURCC(sub_chunk_id));*/ + stream_skip(qtmovie->stream, sub_chunk_len - 8); + break; + } + + size_remaining -= sub_chunk_len; + } + return true; +} + +/* 'trak' - a movie track - contains other atoms */ +static bool read_chunk_trak(qtmovie_t *qtmovie, size_t chunk_len) +{ + size_t size_remaining = chunk_len - 8; + + while (size_remaining) + { + size_t sub_chunk_len; + fourcc_t sub_chunk_id; + + sub_chunk_len = stream_read_uint32(qtmovie->stream); + if (sub_chunk_len <= 1 || sub_chunk_len > size_remaining) + { + DEBUGF("strange size (%lu) for chunk inside trak\n", + (unsigned long)sub_chunk_len); + return false; + } + + sub_chunk_id = stream_read_uint32(qtmovie->stream); + + switch (sub_chunk_id) + { + case MAKEFOURCC('m','d','i','a'): + if (!read_chunk_mdia(qtmovie, sub_chunk_len)) { + return false; + } + break; + default: + /*DEBUGF("(trak) unknown chunk id: %c%c%c%c\n", + SPLITFOURCC(sub_chunk_id));*/ + stream_skip(qtmovie->stream, sub_chunk_len - 8); + break; + } + + size_remaining -= sub_chunk_len; + } + return true; +} + +/* 'moov' movie atom - contains other atoms */ +static bool read_chunk_moov(qtmovie_t *qtmovie, size_t chunk_len) +{ + size_t size_remaining = chunk_len - 8; + + while (size_remaining) + { + size_t sub_chunk_len; + fourcc_t sub_chunk_id; + + sub_chunk_len = stream_read_uint32(qtmovie->stream); + if (sub_chunk_len <= 1 || sub_chunk_len > size_remaining) + { + DEBUGF("strange size (%lu) for chunk inside moov\n", + (unsigned long)sub_chunk_len); + return false; + } + + sub_chunk_id = stream_read_uint32(qtmovie->stream); + + switch (sub_chunk_id) + { + case MAKEFOURCC('t','r','a','k'): + if (!read_chunk_trak(qtmovie, sub_chunk_len)) { + return false; + } + break; + default: + /*DEBUGF("(moov) unknown chunk id: %c%c%c%c\n", + SPLITFOURCC(sub_chunk_id));*/ + stream_skip(qtmovie->stream, sub_chunk_len - 8); + break; + } + + size_remaining -= sub_chunk_len; + } + return true; +} + +static void read_chunk_mdat(qtmovie_t *qtmovie, size_t chunk_len) +{ + size_t size_remaining = chunk_len - 8; + + qtmovie->res->mdat_len = size_remaining; +} + +int qtmovie_read(stream_t *file, demux_res_t *demux_res) +{ + qtmovie_t qtmovie; + + /* construct the stream */ + qtmovie.stream = file; + qtmovie.res = demux_res; + + /* read the chunks */ + while (1) + { + size_t chunk_len; + fourcc_t chunk_id; + + chunk_len = stream_read_uint32(qtmovie.stream); + if (stream_eof(qtmovie.stream)) + { + if(qtmovie.res->mdat_offset == 0 || qtmovie.res->format == 0) + return 0; + stream_seek(qtmovie.stream, qtmovie.res->mdat_offset); + return 1; + } + + if (chunk_len == 1) + { + //DEBUGF("need 64bit support\n"); + return 0; + } + chunk_id = stream_read_uint32(qtmovie.stream); + + //DEBUGF("Found a chunk %c%c%c%c, length=%d\n",SPLITFOURCC(chunk_id),chunk_len); + switch (chunk_id) + { + case MAKEFOURCC('f','t','y','p'): + read_chunk_ftyp(&qtmovie, chunk_len); + break; + case MAKEFOURCC('m','o','o','v'): + if (!read_chunk_moov(&qtmovie, chunk_len)) { + return 0; + } + break; + case MAKEFOURCC('m','d','a','t'): + /* There can be empty mdats before the real one. If so, skip them */ + if (chunk_len == 8) + break; + read_chunk_mdat(&qtmovie, chunk_len); + qtmovie.res->mdat_offset=stream_tell(qtmovie.stream); + /* If we've already seen the format, assume there's nothing + interesting after the mdat chunk (the file is "streamable"). + This avoids having to seek, which might cause rebuffering. */ + if(qtmovie.res->format > 0) + return 1; + stream_skip(qtmovie.stream, chunk_len - 8); + break; + + /* these following atoms can be skipped !!!! */ + case MAKEFOURCC('f','r','e','e'): + stream_skip(qtmovie.stream, chunk_len - 8); + break; + default: + //DEBUGF("(top) unknown chunk id: %c%c%c%c\n",SPLITFOURCC(chunk_id)); + return 0; + } + + } + return 0; +} + + diff --git a/lib/rbcodec/codecs/libm4a/libm4a.make b/lib/rbcodec/codecs/libm4a/libm4a.make new file mode 100644 index 0000000000..c25f63fa70 --- /dev/null +++ b/lib/rbcodec/codecs/libm4a/libm4a.make @@ -0,0 +1,18 @@ +# __________ __ ___. +# Open \______ \ ____ ____ | | _\_ |__ _______ ___ +# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / +# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < +# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ +# \/ \/ \/ \/ \/ +# $Id$ +# + +# libm4a +M4ALIB := $(CODECDIR)/libm4a.a +M4ALIB_SRC := $(call preprocess, $(RBCODECLIB_DIR)/codecs/libm4a/SOURCES) +M4ALIB_OBJ := $(call c2obj, $(M4ALIB_SRC)) +OTHER_SRC += $(M4ALIB_SRC) + +$(M4ALIB): $(M4ALIB_OBJ) + $(SILENT)$(shell rm -f $@) + $(call PRINTS,AR $(@F))$(AR) rcs $@ $^ >/dev/null diff --git a/lib/rbcodec/codecs/libm4a/m4a.c b/lib/rbcodec/codecs/libm4a/m4a.c new file mode 100644 index 0000000000..5fe778ac03 --- /dev/null +++ b/lib/rbcodec/codecs/libm4a/m4a.c @@ -0,0 +1,267 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2005 Dave Chapman, 2011 Andree Buschmann + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include +#include +#include "m4a.h" + +/* Implementation of the stream.h functions used by libalac */ + +#define _Swap32(v) do { \ + v = (((v) & 0x000000FF) << 0x18) | \ + (((v) & 0x0000FF00) << 0x08) | \ + (((v) & 0x00FF0000) >> 0x08) | \ + (((v) & 0xFF000000) >> 0x18); } while(0) + +#define _Swap16(v) do { \ + v = (((v) & 0x00FF) << 0x08) | \ + (((v) & 0xFF00) >> 0x08); } while (0) + +/* A normal read without any byte-swapping */ +void stream_read(stream_t *stream, size_t size, void *buf) +{ + stream->ci->read_filebuf(buf,size); + if (stream->ci->curpos >= stream->ci->filesize) { stream->eof=1; } +} + +int32_t stream_read_int32(stream_t *stream) +{ + int32_t v; + stream_read(stream, 4, &v); +#ifdef ROCKBOX_LITTLE_ENDIAN + _Swap32(v); +#endif + return v; +} + +int32_t stream_tell(stream_t *stream) +{ + return stream->ci->curpos; +} + +uint32_t stream_read_uint32(stream_t *stream) +{ + uint32_t v; + stream_read(stream, 4, &v); +#ifdef ROCKBOX_LITTLE_ENDIAN + _Swap32(v); +#endif + return v; +} + +uint16_t stream_read_uint16(stream_t *stream) +{ + uint16_t v; + stream_read(stream, 2, &v); +#ifdef ROCKBOX_LITTLE_ENDIAN + _Swap16(v); +#endif + return v; +} + +uint8_t stream_read_uint8(stream_t *stream) +{ + uint8_t v; + stream_read(stream, 1, &v); + return v; +} + +void stream_skip(stream_t *stream, size_t skip) +{ + stream->ci->advance_buffer(skip); +} + +void stream_seek(stream_t *stream, size_t offset) +{ + stream->ci->seek_buffer(offset); +} + +int stream_eof(stream_t *stream) +{ + return stream->eof; +} + +void stream_create(stream_t *stream,struct codec_api* ci) +{ + stream->ci=ci; + stream->eof=0; +} + +/* Check if there is a dedicated byte position contained for the given frame. + * Return this byte position in case of success or return -1. This allows to + * skip empty samples. + * During standard playback the search result (index i) will always increase. + * Therefor we save this index and let the caller set this value again as start + * index when calling m4a_check_sample_offset() for the next frame. This + * reduces the overall loop count significantly. */ +int m4a_check_sample_offset(demux_res_t *demux_res, uint32_t frame, uint32_t *start) +{ + uint32_t i = *start; + for (i=0; inum_lookup_table; ++i) + { + if (demux_res->lookup_table[i].sample > frame || + demux_res->lookup_table[i].offset == 0) + return -1; + if (demux_res->lookup_table[i].sample == frame) + break; + } + *start = i; + return demux_res->lookup_table[i].offset; +} + +/* Find the exact or preceding frame in lookup_table[]. Return both frame + * and byte position of this match. */ +static void gather_offset(demux_res_t *demux_res, uint32_t *frame, uint32_t *offset) +{ + uint32_t i = 0; + for (i=0; inum_lookup_table; ++i) + { + if (demux_res->lookup_table[i].offset == 0) + break; + if (demux_res->lookup_table[i].sample > *frame) + break; + } + i = (i>0) ? i-1 : 0; /* We want the last chunk _before_ *frame. */ + *frame = demux_res->lookup_table[i].sample; + *offset = demux_res->lookup_table[i].offset; +} + +/* Seek to desired sound sample location. Return 1 on success (and modify + * sound_samples_done and current_sample), 0 if failed. + * + * Find the sample (=frame) that contains the given sound sample, find a best + * fit for this sample in the lookup_table[], seek to the byte position. */ +unsigned int m4a_seek(demux_res_t* demux_res, stream_t* stream, + uint32_t sound_sample_loc, uint32_t* sound_samples_done, + int* current_sample) +{ + uint32_t i = 0; + uint32_t tmp_var, tmp_cnt, tmp_dur; + uint32_t new_sample = 0; /* Holds the amount of chunks/frames. */ + uint32_t new_sound_sample = 0; /* Sums up total amount of samples. */ + uint32_t new_pos; /* Holds the desired chunk/frame index. */ + + /* First check we have the appropriate metadata - we should always + * have it. + */ + if (!demux_res->num_time_to_samples || !demux_res->num_sample_byte_sizes) + { + return 0; + } + + /* Find the destination block from time_to_sample array */ + time_to_sample_t *tab = demux_res->time_to_sample; + while (i < demux_res->num_time_to_samples) + { + tmp_cnt = tab[i].sample_count; + tmp_dur = tab[i].sample_duration; + tmp_var = tmp_cnt * tmp_dur; + if (sound_sample_loc <= new_sound_sample + tmp_var) + { + tmp_var = (sound_sample_loc - new_sound_sample); + new_sample += tmp_var / tmp_dur; + new_sound_sample += tmp_var; + break; + } + new_sample += tmp_cnt; + new_sound_sample += tmp_var; + ++i; + } + + /* We know the new sample (=frame), now calculate the file position. */ + gather_offset(demux_res, &new_sample, &new_pos); + + /* We know the new file position, so let's try to seek to it */ + if (stream->ci->seek_buffer(new_pos)) + { + *sound_samples_done = new_sound_sample; + *current_sample = new_sample; + return 1; + } + + return 0; +} + +/* Seek to the sample containing file_loc. Return 1 on success (and modify + * sound_samples_done and current_sample), 0 if failed. + * + * Seeking uses the following arrays: + * + * 1) the lookup_table array contains the file offset for the first sample + * of each chunk. + * + * 2) the time_to_sample array contains the duration (in sound samples) + * of each sample of data. + * + * Locate the chunk containing location (using lookup_table), find the first + * sample of that chunk (using lookup_table). Then use time_to_sample to + * calculate the sound_samples_done value. + */ +unsigned int m4a_seek_raw(demux_res_t* demux_res, stream_t* stream, + uint32_t file_loc, uint32_t* sound_samples_done, + int* current_sample) +{ + uint32_t i; + uint32_t chunk_sample = 0; + uint32_t total_samples = 0; + uint32_t new_sound_sample = 0; + uint32_t tmp_dur; + uint32_t tmp_cnt; + uint32_t new_pos; + + /* We know the desired byte offset, search for the chunk right before. + * Return the associated sample to this chunk as chunk_sample. */ + for (i=0; i < demux_res->num_lookup_table; ++i) + { + if (demux_res->lookup_table[i].offset > file_loc) + break; + } + i = (i>0) ? i-1 : 0; /* We want the last chunk _before_ file_loc. */ + chunk_sample = demux_res->lookup_table[i].sample; + new_pos = demux_res->lookup_table[i].offset; + + /* Get sound sample offset. */ + i = 0; + time_to_sample_t *tab2 = demux_res->time_to_sample; + while (i < demux_res->num_time_to_samples) + { + tmp_dur = tab2[i].sample_duration; + tmp_cnt = tab2[i].sample_count; + total_samples += tmp_cnt; + new_sound_sample += tmp_cnt * tmp_dur; + if (chunk_sample <= total_samples) + { + new_sound_sample += (chunk_sample - total_samples) * tmp_dur; + break; + } + ++i; + } + + /* Go to the new file position. */ + if (stream->ci->seek_buffer(new_pos)) + { + *sound_samples_done = new_sound_sample; + *current_sample = chunk_sample; + return 1; + } + + return 0; +} diff --git a/lib/rbcodec/codecs/libm4a/m4a.h b/lib/rbcodec/codecs/libm4a/m4a.h new file mode 100644 index 0000000000..aa8e768045 --- /dev/null +++ b/lib/rbcodec/codecs/libm4a/m4a.h @@ -0,0 +1,138 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2005 Dave Chapman + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#ifndef _M4A_H +#define _M4A_H + +#include +#include + +/* AAC codecdata appears to always be less than 8 bytes - see + AudioSpecificConfig2 in libfaad/mp4.c + + ALAC codecdata appears to always be 44 bytes (see alac_set_info in + libalac/alac.c) but my test file contains 56 bytes. + + So we go safe and round up to 64 bytes - if we find more than this, + we give an error (even though we could possibly continue), so we + can increase this buffer. +*/ + +#define MAX_CODECDATA_SIZE 64 + +typedef struct { + struct codec_api* ci; + int eof; +} stream_t; + +typedef uint32_t fourcc_t; + +typedef struct +{ + uint32_t first_chunk; + uint32_t num_samples; +} sample_to_chunk_t; + +typedef struct +{ + uint32_t sample_count; + uint32_t sample_duration; +} time_to_sample_t; + +typedef struct +{ + uint32_t sample; + uint32_t offset; +} sample_offset_t; + +typedef struct +{ + uint16_t num_channels; + uint16_t sound_sample_size; + uint32_t sound_sample_rate; + fourcc_t format; + void *buf; + + sample_to_chunk_t *sample_to_chunk; + uint32_t num_sample_to_chunks; + + sample_offset_t *lookup_table; + uint32_t num_lookup_table; + + time_to_sample_t *time_to_sample; + uint32_t num_time_to_samples; + + uint32_t num_sample_byte_sizes; + + uint32_t codecdata_len; + uint8_t codecdata[MAX_CODECDATA_SIZE]; + + int mdat_offset; + uint32_t mdat_len; +#if 0 + void *mdat; +#endif +} demux_res_t; + +int qtmovie_read(stream_t *stream, demux_res_t *demux_res); + +#ifndef MAKEFOURCC +#define MAKEFOURCC(ch0, ch1, ch2, ch3) ( \ + ( (int32_t)(char)(ch0) << 24 ) | \ + ( (int32_t)(char)(ch1) << 16 ) | \ + ( (int32_t)(char)(ch2) << 8 ) | \ + ( (int32_t)(char)(ch3) ) ) +#endif + +#ifndef SLPITFOURCC +/* splits it into ch0, ch1, ch2, ch3 - use for printf's */ +#define SPLITFOURCC(code) \ + (char)((int32_t)code >> 24), \ + (char)((int32_t)code >> 16), \ + (char)((int32_t)code >> 8), \ + (char)code +#endif + +void stream_read(stream_t *stream, size_t len, void *buf); + +int32_t stream_tell(stream_t *stream); +int32_t stream_read_int32(stream_t *stream); +uint32_t stream_read_uint32(stream_t *stream); + +uint16_t stream_read_uint16(stream_t *stream); + +uint8_t stream_read_uint8(stream_t *stream); + +void stream_skip(stream_t *stream, size_t skip); +void stream_seek(stream_t *stream, size_t offset); + +int stream_eof(stream_t *stream); + +void stream_create(stream_t *stream,struct codec_api* ci); +unsigned int get_sample_offset(demux_res_t *demux_res, uint32_t sample); +unsigned int m4a_seek (demux_res_t* demux_res, stream_t* stream, + uint32_t sound_sample_loc, uint32_t* sound_samples_done, + int* current_sample); +unsigned int m4a_seek_raw (demux_res_t* demux_res, stream_t* stream, + uint32_t file_loc, uint32_t* sound_samples_done, int* current_sample); +int m4a_check_sample_offset(demux_res_t *demux_res, uint32_t frame, uint32_t *start); + +#endif /* STREAM_H */ diff --git a/lib/rbcodec/codecs/libmad/CHANGES b/lib/rbcodec/codecs/libmad/CHANGES new file mode 100644 index 0000000000..3fa57ef0cf --- /dev/null +++ b/lib/rbcodec/codecs/libmad/CHANGES @@ -0,0 +1,338 @@ + + libmad - MPEG audio decoder library + Copyright (C) 2000-2004 Underbit Technologies, Inc. + + $Id$ + +=============================================================================== + +Version 0.15.1 (beta) + + * Updated to autoconf 2.59, automake 1.8.2, libtool 1.5.2. + + * Replaced Layer III IMDCT routine with one based on a faster algorithm, + improving both speed and accuracy. + + * Improved portability of the Huffman table initialization. + + * Fixed a problem that could result in an assertion failure in layer3.c + due to an invalid Layer III free format bitrate. + + * Improved the robustness of Layer II bitrate/mode combinations, and added + a new MAD_ERROR_BADMODE error enum. The allowability of low-bitrate + stereo streams is influenced by the --enable-strict-iso option to + `configure'. + +Version 0.15.0 (beta) + + * Updated to autoconf 2.57, automake 1.7.5, libtool 1.4.3. + + * Added new mad_f_div() API routine. + + * Added a 64th entry to the Layer I/Layer II scalefactor table, for better + compatibility with existing streams. The --enable-strict-iso option to + `configure' can be used to disable use of this entry. + + * Modified the header decoding routine to allow the reserved emphasis + value, for better compatibility with existing streams. The + --enable-strict-iso option to `configure' can be used to restore the + previous behavior of reporting this value as an error. + + * Added new MAD_EMPHASIS_RESERVED enumeration constant. + + * Fixed a bug in the ARM version of mad_f_scale64() discovered by Andre + McCurdy. + + * Rewrote PowerPC assembly for minor gains. + + * Modified mad_timer_fraction() to avoid the possibility of division by + zero when 0 is passed as the second argument. + + * Fixed a non-fatal problem caused by attempting to designate ancillary + bits in Layer III after a decoding error. + + * Changed to build a shared library by default. + + * Changed to use native Cygwin build by default; give --host=mingw32 to + `configure' to use MinGW (and avoid a dependency on the Cygwin DLL). + +Version 0.14.2 (beta) + + * Changed Cygwin builds to use MinGW; resulting Win32 executables no + longer have a dependency on Cygwin DLLs. + + * Added a new mad_stream_errorstr() API function to libmad for retrieving + a string description of the current error condition. + +Version 0.14.1 (beta) + + * Updated config.guess and config.sub to latest upstream versions. + + * Enabled libtool versioning rather than release numbering. + + * Improved the documentation in minimad.c. + + * Several other small fixes. + +Version 0.14.0 (beta) + + * Added a 64-bit FPM negation operation to improve performance of subband + synthesis on some platforms. + + * Improved MSVC++ portability and added MSVC++ project files. + + * Added rounding to Layer III requantization for slightly better accuracy. + +Version 0.13.0 (beta) + + * Ancillary data is now properly extracted from Layer III streams. + + * Rewrote the Layer III joint stereo decoding routine to correct a major + MPEG-2 problem and a minor MPEG-1 problem decoding intensity stereo. + + * Eliminated the dependency on sign-extending right shifts for Layer I and + Layer II. + + * Renamed `private' field to `private_bits' for better C++ compatibility. + + * Gratuitously renamed `sfreq' field to `samplerate' and + MAD_ERROR_BADSAMPLEFREQ constant to MAD_ERROR_BADSAMPLERATE. + + * Added `samplerate' and `channels' fields to synth.pcm struct to allow + these to be different from the decoded frame, and for simpler access. + + * Added new mad_stream_options() and mad_decoder_options() API entries for + special runtime decoding options. + + * Added new MAD_OPTION_IGNORECRC and MAD_OPTION_HALFSAMPLERATE options. + + * Added new MAD_FLAG_FREEFORMAT indicator flag. + + * Fixed some bugs in the async decoder. + + * Added a new mad_timer_multiply() API routine. + + * Eliminated `+' from asm constraints under Intel for better compatibility + with some compilers. + + * Fixed a PIC-related problem in imdct_l_arm.S. + + * Eliminated a static variable to make libmad thread-safe. + +Version 0.12.5 (beta) + + * Modified Layer III requantization to occur during Huffman decoding for + significant performance gains. + + * Optimized short block IMDCT by eliminating redundant calculations. + + * Made several other Layer III performance improvements; added + ASO_INTERLEAVE1, ASO_INTERLEAVE2, and ASO_ZEROCHECK + architecture-specific options for best performance on various + architectures. + + * Optimized synthesis DCT to store result values as soon as they are + calculated. + +Version 0.12.4 (beta) + + * New PowerPC fixed-point assembly courtesy of David Blythe. + + * Reorganized fixed-point assembly routines for easier maintenance and + better performance. + + * Improved performance of subband synthesis through better indexing and + fewer local variables. + + * Added alias reduction for the lower two subbands of mixed short blocks, + per a report of ambiguity with ISO/IEC 11172-3 and for uniformity with + most other implementations. Also improved alias reduction performance + using multiply/accumulate. + + * Added --enable-strict-iso option to `configure' to override best + accepted practices such as the alias reduction for mixed short blocks. + + * Improved performance of Layer III IMDCT by using longer + multiply/accumulate runs where possible. + +Version 0.12.3 (beta) + + * Added MPEG 2.5 support. + + * Added preliminary support for parameterizing the binary point position + in the fixed-point representation. + + * Added multiply/accumulate optimization to the Layer III IMDCT for long + blocks. + + * Fixed a bug in the handling of Layer III mixed_block_flag. + + * Fixed a configure problem when multiple -O CFLAGS are present. + +Version 0.12.2 (beta) + + * Rearranged the synthesis polyphase filterbank memory vector for better + locality of reference, and rewrote mad_synth_frame() to accommodate, + resulting in improved performance. + + * Discovered a combination of compiler optimization flags that further + improve performance. + + * Changed some array references in layer3.c to pointer derefs. + +Version 0.12.1 (beta) + + * Resolved the intensity + MS joint stereo issue (a simple bug). + OPT_ISKLUGE is no longer considered to be a kluge. + + * Fixed another, hopefully last main_data memory bug. + + * Split part of struct mad_frame into struct mad_header for convenience + and size. + +Version 0.12.0 (alpha) + + * Changed the build environment to use automake and libtool. A libmad + shared library can now be built using the --enable-shared option to + `configure'. + + * Added another callback to MAD's high-level decoder API after the frame + header has been read but before the frame's audio data is decoded. + + * Streamlined header processing so that mad_frame_decode() can be called + with or without having already called mad_frame_header(). + + * Fixed some other header reading miscellany, including CRC handling and + free bitrate detection, and frame length verification with free + bitrates. + + * Fixed a problem with Layer III free bitrates > 320 kbps. The main_data + buffer size should now be large enough to handle any size frame, by + virtue of the maximum possible part2_3_length. + + * Further developed the async API; arbitrary messages can now be passed to + the subsidiary decoding process. + + * Streamlined timer.c and extended its interface. It now has support for + video frame/field lengths, including output support for drop-frame + encoding. + + * Replaced many constant integer preprocessor defines with enums. + +Version 0.11.4 (beta) + + * Fixed free format bitrate discovery. + + * Changed the timer implementation and extended its interface. + + * Integrated Nicolas Pitre's patch for pre-shifting at compile-time and + for better multiply/accumulate code output. + + * Applied Simon Burge's patch to imdct_l_arm.S for a.out compatibility. + + * Added -mtune=strongarm for all ARM targets. + +Version 0.11.3 (beta) + + * Added new --enable-speed and --enable-accuracy options for `configure' + to automatically select appropriate SSO/ASO options, et al. + + * Modified subband synthesis to use multiply/accumulate optimization (if + available) for better speed and/or accuracy. + + * Incorporated Andre McCurdy's changes for further rounding optimizations + in the rest of his code. + +Version 0.11.2 (beta) + + * Incorporated Nicolas Pitre's ARM assembly and parameterized scaling + changes. + + * Incorporated Andre McCurdy's ARM assembly optimization (used only if + --enable-aso is given to `configure' to enable architecture-specific + optimizations.) + + * Reduced FPM_INTEL assembly to two instructions. + + * Fixed accuracy problems with certain FPM modes in synth.c. + + * Improved the accuracy of FPM_APPROX. + + * Improved the accuracy of SSO. + + * Improved sync discovery by checking for a sync word in the following + frame. + + * Minor code clean-up. + + * Added experimental rules for generating a libmad.so shared library. + +Version 0.11.1 (beta) + + * Moved libmad code into a separate directory. + + * Changed SSO to be disabled by default, as output accuracy is deemed to + be more important than speed in the general case. + + * Fixed a bug in Layer III sanity checking that could cause a crash on + certain random data input. + + * Extended the Layer III requantization table from 8191 to 8206 as some + encoders are known to use these values, even though ISO/IEC 11172-3 + suggests the maximum should be 8191. + +Version 0.11.0 (beta) + + * Implemented MPEG-2 extension to Lower Sampling Frequencies. + + * Improved Layer III performance by avoiding IMDCT calculation when all + input samples are zero. + + * Significantly reduced size of Layer II tables. + +Version 0.10.3 (beta) + + * Improved SSO output quality. + + * Made portable to cygwin. + + * Localized memory references in III_huffdecode() for better performance. + +Version 0.10.2 (beta) + + * Rewrote Layer III long block 36-point IMDCT routine for better + performance. + + * Improved subband synthesis fixed-point games somewhat. + +Version 0.10.1 (beta) + + * Added a subband synthesis optimization (SSO) which involves modifying + the fixed-point multiplication method during windowing. This produces + subtle differences in the output but improves performance greatly. + + * Added I_STEREO and MS_STEREO flags to frame struct. + + * Eliminated privately-used CRCFAILED flag. + + * Fixed a bug where Layer III decoding could crash on some badly-formatted + (e.g. non-MPEG) bitstreams. + + * Miscellaneous code clean-up. + +Version 0.10.0 (beta) + + * Added SPARC fixed-point math support. + + * Revamped libmad API for better high- and low-level support. + + * Documented more of the code. + + * Changed sync semantics such that new stream buffers are assumed to be + sync-aligned. + + * Changed Layer III to dynamically allocate static memory so as not to + waste it (about 6.4K) when only decoding Layer I or Layer II. + +=============================================================================== + diff --git a/lib/rbcodec/codecs/libmad/COPYING b/lib/rbcodec/codecs/libmad/COPYING new file mode 100644 index 0000000000..d60c31a97a --- /dev/null +++ b/lib/rbcodec/codecs/libmad/COPYING @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/lib/rbcodec/codecs/libmad/COPYRIGHT b/lib/rbcodec/codecs/libmad/COPYRIGHT new file mode 100644 index 0000000000..ed91d2bac1 --- /dev/null +++ b/lib/rbcodec/codecs/libmad/COPYRIGHT @@ -0,0 +1,21 @@ + + libmad - MPEG audio decoder library + Copyright (C) 2000-2004 Underbit Technologies, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + If you would like to negotiate alternate licensing terms, you may do + so by contacting: Underbit Technologies, Inc. + diff --git a/lib/rbcodec/codecs/libmad/CREDITS b/lib/rbcodec/codecs/libmad/CREDITS new file mode 100644 index 0000000000..69016c201d --- /dev/null +++ b/lib/rbcodec/codecs/libmad/CREDITS @@ -0,0 +1,116 @@ + + libmad - MPEG audio decoder library + Copyright (C) 2000-2004 Underbit Technologies, Inc. + + $Id$ + +=============================================================================== + +AUTHOR + + Except where otherwise noted, all code was authored by: + + Robert Leslie + +CONTRIBUTORS + + Significant contributions have been incorporated with thanks to: + + Anonymous + 2002/03/15: frame.c + - Reported problem with use of reserved emphasis value. + 2003/08/31: layer12.c + - Suggested support for certain disallowed bitrate/mode + combinations. + + Niek Albers + 2003/04/21: layer3.c + - Reported runtime uninitialized use of `ptr' in designating + ancillary bits after a decoding error. + + Christian Biere + 2003/02/01: frame.c + - Reported assertion failure in layer3.c due to an + invalid/unsupported Layer III free format bitrate. + + David Blythe + 2001/01/30: fixed.h + - Provided initial PowerPC fixed-point assembly. + + Simon Burge + 2000/09/20: imdct_l_arm.S + - Suggested patch for a.out compatibility. + + Brian Cameron + 2003/07/02: huffman.c + - Suggested changes for improved portability. + + Joshua Haberman + 2001/08/10: decoder.c, huffman.c + - Suggested portability fixes. + + Timothy King + 2002/05/04: sf_table.dat, layer12.c + - Reported problem with use of (missing) scalefactor index 63. + + Felix von Leitner + 2003/01/21: fixed.h + - Suggested Intel scaling alternative for possible speedup. + + Andre McCurdy + 2000/08/10: imdct_l_arm.S + - ARM optimized assembly replacement for III_imdct_l(). + 2000/09/15: imdct_l_arm.S + - Applied Nicolas Pitre's rounding optimisation in all remaining + places. + 2001/02/10: layer3.c + - Inspiration for Huffman decoding and requantization rewrite, and + other miscellany. + 2001/03/24: imdct_l_arm.S + - Corrected PIC unsafe code. + 2002/02/16: fixed.h + - Discovered bug in ARM version of mad_f_scale64(). + + Haruhiko OGASAWARA + 2001/01/28: layer3.c + - Reported discrepancy in alias reduction for mixed short blocks. + + Brett Paterson + 2001/10/28: global.h + - Reported missing et al. under MS Embedded Visual C. + + Sean 'Shaleh' Perry + 2000/04/04: fixed.h + - Suggested use of size-dependent typedefs. + 2001/10/22: config.guess, config.sub + - Keep up to date for proper Debian packaging. + + Bertrand Petit + 2001/11/05: synth.h + - Suggested PCM channel enumeration constants. + 2001/11/05: stream.h + - Suggested MAD_ERROR_NONE enumeration constant. + 2001/11/05: stream.c + - Suggested mad_stream_errorstr() function. + + Nicolas Pitre + 2000/09/09: fixed.h + - Parameterized all scaling for correct use of all multiplication + methods within mad_synth_frame(). + - Rewrote the FPM_ARM version of mad_f_mul() so we have 64-bit + multiplication result, rounding and scaling with 3 instructions. + 2000/09/09: imdct_l_arm.S + - Optimized rounding + scaling operations. + 2000/09/17: synth.c + - Changed D[] run-time shifts to compile-time. + - Modified synthesis for better multiply/accumulate code output. + 2001/08/11: fixed.h, synth.c + - Suggested 64-bit FPM negation and negative term factorization + during synthesis. + 2001/08/11: fixed.h + - Suggested unrounded behavior for FPM_DEFAULT when OPT_SPEED. + 2001/11/19: fixed.c + - Suggested computation of any resampling ratio. + +=============================================================================== + diff --git a/lib/rbcodec/codecs/libmad/D.dat b/lib/rbcodec/codecs/libmad/D.dat new file mode 100644 index 0000000000..2bff1a8890 --- /dev/null +++ b/lib/rbcodec/codecs/libmad/D.dat @@ -0,0 +1,607 @@ +/* + * libmad - MPEG audio decoder library + * Copyright (C) 2000-2004 Underbit Technologies, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * $Id$ + */ + +/* + * These are the coefficients for the subband synthesis window. This is a + * reordered version of Table B.3 from ISO/IEC 11172-3. + * + * Every value is parameterized so that shift optimizations can be made at + * compile-time. For example, every value can be right-shifted 12 bits to + * minimize multiply instruction times without any loss of accuracy. + */ + + { PRESHIFT(0x00000000) /* 0.000000000 */, /* 0 */ + -PRESHIFT(0x0001d000) /* -0.000442505 */, + PRESHIFT(0x000d5000) /* 0.003250122 */, + -PRESHIFT(0x001cb000) /* -0.007003784 */, + PRESHIFT(0x007f5000) /* 0.031082153 */, + -PRESHIFT(0x01421000) /* -0.078628540 */, + PRESHIFT(0x019ae000) /* 0.100311279 */, + -PRESHIFT(0x09271000) /* -0.572036743 */, + PRESHIFT(0x1251e000) /* 1.144989014 */, + PRESHIFT(0x09271000) /* 0.572036743 */, + PRESHIFT(0x019ae000) /* 0.100311279 */, + PRESHIFT(0x01421000) /* 0.078628540 */, + PRESHIFT(0x007f5000) /* 0.031082153 */, + PRESHIFT(0x001cb000) /* 0.007003784 */, + PRESHIFT(0x000d5000) /* 0.003250122 */, + PRESHIFT(0x0001d000) /* 0.000442505 */, + + PRESHIFT(0x00000000) /* 0.000000000 */, + -PRESHIFT(0x0001d000) /* -0.000442505 */, + PRESHIFT(0x000d5000) /* 0.003250122 */, + -PRESHIFT(0x001cb000) /* -0.007003784 */, + PRESHIFT(0x007f5000) /* 0.031082153 */, + -PRESHIFT(0x01421000) /* -0.078628540 */, + PRESHIFT(0x019ae000) /* 0.100311279 */, + -PRESHIFT(0x09271000) /* -0.572036743 */, + PRESHIFT(0x1251e000) /* 1.144989014 */, + PRESHIFT(0x09271000) /* 0.572036743 */, + PRESHIFT(0x019ae000) /* 0.100311279 */, + PRESHIFT(0x01421000) /* 0.078628540 */, + PRESHIFT(0x007f5000) /* 0.031082153 */, + PRESHIFT(0x001cb000) /* 0.007003784 */, + PRESHIFT(0x000d5000) /* 0.003250122 */, + PRESHIFT(0x0001d000) /* 0.000442505 */ }, + + { -PRESHIFT(0x00001000) /* -0.000015259 */, /* 1 */ + -PRESHIFT(0x0001f000) /* -0.000473022 */, + PRESHIFT(0x000da000) /* 0.003326416 */, + -PRESHIFT(0x00207000) /* -0.007919312 */, + PRESHIFT(0x007d0000) /* 0.030517578 */, + -PRESHIFT(0x0158d000) /* -0.084182739 */, + PRESHIFT(0x01747000) /* 0.090927124 */, + -PRESHIFT(0x099a8000) /* -0.600219727 */, + PRESHIFT(0x124f0000) /* 1.144287109 */, + PRESHIFT(0x08b38000) /* 0.543823242 */, + PRESHIFT(0x01bde000) /* 0.108856201 */, + PRESHIFT(0x012b4000) /* 0.073059082 */, + PRESHIFT(0x0080f000) /* 0.031478882 */, + PRESHIFT(0x00191000) /* 0.006118774 */, + PRESHIFT(0x000d0000) /* 0.003173828 */, + PRESHIFT(0x0001a000) /* 0.000396729 */, + + -PRESHIFT(0x00001000) /* -0.000015259 */, + -PRESHIFT(0x0001f000) /* -0.000473022 */, + PRESHIFT(0x000da000) /* 0.003326416 */, + -PRESHIFT(0x00207000) /* -0.007919312 */, + PRESHIFT(0x007d0000) /* 0.030517578 */, + -PRESHIFT(0x0158d000) /* -0.084182739 */, + PRESHIFT(0x01747000) /* 0.090927124 */, + -PRESHIFT(0x099a8000) /* -0.600219727 */, + PRESHIFT(0x124f0000) /* 1.144287109 */, + PRESHIFT(0x08b38000) /* 0.543823242 */, + PRESHIFT(0x01bde000) /* 0.108856201 */, + PRESHIFT(0x012b4000) /* 0.073059082 */, + PRESHIFT(0x0080f000) /* 0.031478882 */, + PRESHIFT(0x00191000) /* 0.006118774 */, + PRESHIFT(0x000d0000) /* 0.003173828 */, + PRESHIFT(0x0001a000) /* 0.000396729 */ }, + + { -PRESHIFT(0x00001000) /* -0.000015259 */, /* 2 */ + -PRESHIFT(0x00023000) /* -0.000534058 */, + PRESHIFT(0x000de000) /* 0.003387451 */, + -PRESHIFT(0x00245000) /* -0.008865356 */, + PRESHIFT(0x007a0000) /* 0.029785156 */, + -PRESHIFT(0x016f7000) /* -0.089706421 */, + PRESHIFT(0x014a8000) /* 0.080688477 */, + -PRESHIFT(0x0a0d8000) /* -0.628295898 */, + PRESHIFT(0x12468000) /* 1.142211914 */, + PRESHIFT(0x083ff000) /* 0.515609741 */, + PRESHIFT(0x01dd8000) /* 0.116577148 */, + PRESHIFT(0x01149000) /* 0.067520142 */, + PRESHIFT(0x00820000) /* 0.031738281 */, + PRESHIFT(0x0015b000) /* 0.005294800 */, + PRESHIFT(0x000ca000) /* 0.003082275 */, + PRESHIFT(0x00018000) /* 0.000366211 */, + + -PRESHIFT(0x00001000) /* -0.000015259 */, + -PRESHIFT(0x00023000) /* -0.000534058 */, + PRESHIFT(0x000de000) /* 0.003387451 */, + -PRESHIFT(0x00245000) /* -0.008865356 */, + PRESHIFT(0x007a0000) /* 0.029785156 */, + -PRESHIFT(0x016f7000) /* -0.089706421 */, + PRESHIFT(0x014a8000) /* 0.080688477 */, + -PRESHIFT(0x0a0d8000) /* -0.628295898 */, + PRESHIFT(0x12468000) /* 1.142211914 */, + PRESHIFT(0x083ff000) /* 0.515609741 */, + PRESHIFT(0x01dd8000) /* 0.116577148 */, + PRESHIFT(0x01149000) /* 0.067520142 */, + PRESHIFT(0x00820000) /* 0.031738281 */, + PRESHIFT(0x0015b000) /* 0.005294800 */, + PRESHIFT(0x000ca000) /* 0.003082275 */, + PRESHIFT(0x00018000) /* 0.000366211 */ }, + + { -PRESHIFT(0x00001000) /* -0.000015259 */, /* 3 */ + -PRESHIFT(0x00026000) /* -0.000579834 */, + PRESHIFT(0x000e1000) /* 0.003433228 */, + -PRESHIFT(0x00285000) /* -0.009841919 */, + PRESHIFT(0x00765000) /* 0.028884888 */, + -PRESHIFT(0x0185d000) /* -0.095169067 */, + PRESHIFT(0x011d1000) /* 0.069595337 */, + -PRESHIFT(0x0a7fe000) /* -0.656219482 */, + PRESHIFT(0x12386000) /* 1.138763428 */, + PRESHIFT(0x07ccb000) /* 0.487472534 */, + PRESHIFT(0x01f9c000) /* 0.123474121 */, + PRESHIFT(0x00fdf000) /* 0.061996460 */, + PRESHIFT(0x00827000) /* 0.031845093 */, + PRESHIFT(0x00126000) /* 0.004486084 */, + PRESHIFT(0x000c4000) /* 0.002990723 */, + PRESHIFT(0x00015000) /* 0.000320435 */, + + -PRESHIFT(0x00001000) /* -0.000015259 */, + -PRESHIFT(0x00026000) /* -0.000579834 */, + PRESHIFT(0x000e1000) /* 0.003433228 */, + -PRESHIFT(0x00285000) /* -0.009841919 */, + PRESHIFT(0x00765000) /* 0.028884888 */, + -PRESHIFT(0x0185d000) /* -0.095169067 */, + PRESHIFT(0x011d1000) /* 0.069595337 */, + -PRESHIFT(0x0a7fe000) /* -0.656219482 */, + PRESHIFT(0x12386000) /* 1.138763428 */, + PRESHIFT(0x07ccb000) /* 0.487472534 */, + PRESHIFT(0x01f9c000) /* 0.123474121 */, + PRESHIFT(0x00fdf000) /* 0.061996460 */, + PRESHIFT(0x00827000) /* 0.031845093 */, + PRESHIFT(0x00126000) /* 0.004486084 */, + PRESHIFT(0x000c4000) /* 0.002990723 */, + PRESHIFT(0x00015000) /* 0.000320435 */ }, + + { -PRESHIFT(0x00001000) /* -0.000015259 */, /* 4 */ + -PRESHIFT(0x00029000) /* -0.000625610 */, + PRESHIFT(0x000e3000) /* 0.003463745 */, + -PRESHIFT(0x002c7000) /* -0.010848999 */, + PRESHIFT(0x0071e000) /* 0.027801514 */, + -PRESHIFT(0x019bd000) /* -0.100540161 */, + PRESHIFT(0x00ec0000) /* 0.057617187 */, + -PRESHIFT(0x0af15000) /* -0.683914185 */, + PRESHIFT(0x12249000) /* 1.133926392 */, + PRESHIFT(0x075a0000) /* 0.459472656 */, + PRESHIFT(0x0212c000) /* 0.129577637 */, + PRESHIFT(0x00e79000) /* 0.056533813 */, + PRESHIFT(0x00825000) /* 0.031814575 */, + PRESHIFT(0x000f4000) /* 0.003723145 */, + PRESHIFT(0x000be000) /* 0.002899170 */, + PRESHIFT(0x00013000) /* 0.000289917 */, + + -PRESHIFT(0x00001000) /* -0.000015259 */, + -PRESHIFT(0x00029000) /* -0.000625610 */, + PRESHIFT(0x000e3000) /* 0.003463745 */, + -PRESHIFT(0x002c7000) /* -0.010848999 */, + PRESHIFT(0x0071e000) /* 0.027801514 */, + -PRESHIFT(0x019bd000) /* -0.100540161 */, + PRESHIFT(0x00ec0000) /* 0.057617187 */, + -PRESHIFT(0x0af15000) /* -0.683914185 */, + PRESHIFT(0x12249000) /* 1.133926392 */, + PRESHIFT(0x075a0000) /* 0.459472656 */, + PRESHIFT(0x0212c000) /* 0.129577637 */, + PRESHIFT(0x00e79000) /* 0.056533813 */, + PRESHIFT(0x00825000) /* 0.031814575 */, + PRESHIFT(0x000f4000) /* 0.003723145 */, + PRESHIFT(0x000be000) /* 0.002899170 */, + PRESHIFT(0x00013000) /* 0.000289917 */ }, + + { -PRESHIFT(0x00001000) /* -0.000015259 */, /* 5 */ + -PRESHIFT(0x0002d000) /* -0.000686646 */, + PRESHIFT(0x000e4000) /* 0.003479004 */, + -PRESHIFT(0x0030b000) /* -0.011886597 */, + PRESHIFT(0x006cb000) /* 0.026535034 */, + -PRESHIFT(0x01b17000) /* -0.105819702 */, + PRESHIFT(0x00b77000) /* 0.044784546 */, + -PRESHIFT(0x0b619000) /* -0.711318970 */, + PRESHIFT(0x120b4000) /* 1.127746582 */, + PRESHIFT(0x06e81000) /* 0.431655884 */, + PRESHIFT(0x02288000) /* 0.134887695 */, + PRESHIFT(0x00d17000) /* 0.051132202 */, + PRESHIFT(0x0081b000) /* 0.031661987 */, + PRESHIFT(0x000c5000) /* 0.003005981 */, + PRESHIFT(0x000b7000) /* 0.002792358 */, + PRESHIFT(0x00011000) /* 0.000259399 */, + + -PRESHIFT(0x00001000) /* -0.000015259 */, + -PRESHIFT(0x0002d000) /* -0.000686646 */, + PRESHIFT(0x000e4000) /* 0.003479004 */, + -PRESHIFT(0x0030b000) /* -0.011886597 */, + PRESHIFT(0x006cb000) /* 0.026535034 */, + -PRESHIFT(0x01b17000) /* -0.105819702 */, + PRESHIFT(0x00b77000) /* 0.044784546 */, + -PRESHIFT(0x0b619000) /* -0.711318970 */, + PRESHIFT(0x120b4000) /* 1.127746582 */, + PRESHIFT(0x06e81000) /* 0.431655884 */, + PRESHIFT(0x02288000) /* 0.134887695 */, + PRESHIFT(0x00d17000) /* 0.051132202 */, + PRESHIFT(0x0081b000) /* 0.031661987 */, + PRESHIFT(0x000c5000) /* 0.003005981 */, + PRESHIFT(0x000b7000) /* 0.002792358 */, + PRESHIFT(0x00011000) /* 0.000259399 */ }, + + { -PRESHIFT(0x00001000) /* -0.000015259 */, /* 6 */ + -PRESHIFT(0x00031000) /* -0.000747681 */, + PRESHIFT(0x000e4000) /* 0.003479004 */, + -PRESHIFT(0x00350000) /* -0.012939453 */, + PRESHIFT(0x0066c000) /* 0.025085449 */, + -PRESHIFT(0x01c67000) /* -0.110946655 */, + PRESHIFT(0x007f5000) /* 0.031082153 */, + -PRESHIFT(0x0bd06000) /* -0.738372803 */, + PRESHIFT(0x11ec7000) /* 1.120223999 */, + PRESHIFT(0x06772000) /* 0.404083252 */, + PRESHIFT(0x023b3000) /* 0.139450073 */, + PRESHIFT(0x00bbc000) /* 0.045837402 */, + PRESHIFT(0x00809000) /* 0.031387329 */, + PRESHIFT(0x00099000) /* 0.002334595 */, + PRESHIFT(0x000b0000) /* 0.002685547 */, + PRESHIFT(0x00010000) /* 0.000244141 */, + + -PRESHIFT(0x00001000) /* -0.000015259 */, + -PRESHIFT(0x00031000) /* -0.000747681 */, + PRESHIFT(0x000e4000) /* 0.003479004 */, + -PRESHIFT(0x00350000) /* -0.012939453 */, + PRESHIFT(0x0066c000) /* 0.025085449 */, + -PRESHIFT(0x01c67000) /* -0.110946655 */, + PRESHIFT(0x007f5000) /* 0.031082153 */, + -PRESHIFT(0x0bd06000) /* -0.738372803 */, + PRESHIFT(0x11ec7000) /* 1.120223999 */, + PRESHIFT(0x06772000) /* 0.404083252 */, + PRESHIFT(0x023b3000) /* 0.139450073 */, + PRESHIFT(0x00bbc000) /* 0.045837402 */, + PRESHIFT(0x00809000) /* 0.031387329 */, + PRESHIFT(0x00099000) /* 0.002334595 */, + PRESHIFT(0x000b0000) /* 0.002685547 */, + PRESHIFT(0x00010000) /* 0.000244141 */ }, + + { -PRESHIFT(0x00002000) /* -0.000030518 */, /* 7 */ + -PRESHIFT(0x00035000) /* -0.000808716 */, + PRESHIFT(0x000e3000) /* 0.003463745 */, + -PRESHIFT(0x00397000) /* -0.014022827 */, + PRESHIFT(0x005ff000) /* 0.023422241 */, + -PRESHIFT(0x01dad000) /* -0.115921021 */, + PRESHIFT(0x0043a000) /* 0.016510010 */, + -PRESHIFT(0x0c3d9000) /* -0.765029907 */, + PRESHIFT(0x11c83000) /* 1.111373901 */, + PRESHIFT(0x06076000) /* 0.376800537 */, + PRESHIFT(0x024ad000) /* 0.143264771 */, + PRESHIFT(0x00a67000) /* 0.040634155 */, + PRESHIFT(0x007f0000) /* 0.031005859 */, + PRESHIFT(0x0006f000) /* 0.001693726 */, + PRESHIFT(0x000a9000) /* 0.002578735 */, + PRESHIFT(0x0000e000) /* 0.000213623 */, + + -PRESHIFT(0x00002000) /* -0.000030518 */, + -PRESHIFT(0x00035000) /* -0.000808716 */, + PRESHIFT(0x000e3000) /* 0.003463745 */, + -PRESHIFT(0x00397000) /* -0.014022827 */, + PRESHIFT(0x005ff000) /* 0.023422241 */, + -PRESHIFT(0x01dad000) /* -0.115921021 */, + PRESHIFT(0x0043a000) /* 0.016510010 */, + -PRESHIFT(0x0c3d9000) /* -0.765029907 */, + PRESHIFT(0x11c83000) /* 1.111373901 */, + PRESHIFT(0x06076000) /* 0.376800537 */, + PRESHIFT(0x024ad000) /* 0.143264771 */, + PRESHIFT(0x00a67000) /* 0.040634155 */, + PRESHIFT(0x007f0000) /* 0.031005859 */, + PRESHIFT(0x0006f000) /* 0.001693726 */, + PRESHIFT(0x000a9000) /* 0.002578735 */, + PRESHIFT(0x0000e000) /* 0.000213623 */ }, + + { -PRESHIFT(0x00002000) /* -0.000030518 */, /* 8 */ + -PRESHIFT(0x0003a000) /* -0.000885010 */, + PRESHIFT(0x000e0000) /* 0.003417969 */, + -PRESHIFT(0x003df000) /* -0.015121460 */, + PRESHIFT(0x00586000) /* 0.021575928 */, + -PRESHIFT(0x01ee6000) /* -0.120697021 */, + PRESHIFT(0x00046000) /* 0.001068115 */, + -PRESHIFT(0x0ca8d000) /* -0.791213989 */, + PRESHIFT(0x119e9000) /* 1.101211548 */, + PRESHIFT(0x05991000) /* 0.349868774 */, + PRESHIFT(0x02578000) /* 0.146362305 */, + PRESHIFT(0x0091a000) /* 0.035552979 */, + PRESHIFT(0x007d1000) /* 0.030532837 */, + PRESHIFT(0x00048000) /* 0.001098633 */, + PRESHIFT(0x000a1000) /* 0.002456665 */, + PRESHIFT(0x0000d000) /* 0.000198364 */, + + -PRESHIFT(0x00002000) /* -0.000030518 */, + -PRESHIFT(0x0003a000) /* -0.000885010 */, + PRESHIFT(0x000e0000) /* 0.003417969 */, + -PRESHIFT(0x003df000) /* -0.015121460 */, + PRESHIFT(0x00586000) /* 0.021575928 */, + -PRESHIFT(0x01ee6000) /* -0.120697021 */, + PRESHIFT(0x00046000) /* 0.001068115 */, + -PRESHIFT(0x0ca8d000) /* -0.791213989 */, + PRESHIFT(0x119e9000) /* 1.101211548 */, + PRESHIFT(0x05991000) /* 0.349868774 */, + PRESHIFT(0x02578000) /* 0.146362305 */, + PRESHIFT(0x0091a000) /* 0.035552979 */, + PRESHIFT(0x007d1000) /* 0.030532837 */, + PRESHIFT(0x00048000) /* 0.001098633 */, + PRESHIFT(0x000a1000) /* 0.002456665 */, + PRESHIFT(0x0000d000) /* 0.000198364 */ }, + + { -PRESHIFT(0x00002000) /* -0.000030518 */, /* 9 */ + -PRESHIFT(0x0003f000) /* -0.000961304 */, + PRESHIFT(0x000dd000) /* 0.003372192 */, + -PRESHIFT(0x00428000) /* -0.016235352 */, + PRESHIFT(0x00500000) /* 0.019531250 */, + -PRESHIFT(0x02011000) /* -0.125259399 */, + -PRESHIFT(0x003e6000) /* -0.015228271 */, + -PRESHIFT(0x0d11e000) /* -0.816864014 */, + PRESHIFT(0x116fc000) /* 1.089782715 */, + PRESHIFT(0x052c5000) /* 0.323318481 */, + PRESHIFT(0x02616000) /* 0.148773193 */, + PRESHIFT(0x007d6000) /* 0.030609131 */, + PRESHIFT(0x007aa000) /* 0.029937744 */, + PRESHIFT(0x00024000) /* 0.000549316 */, + PRESHIFT(0x0009a000) /* 0.002349854 */, + PRESHIFT(0x0000b000) /* 0.000167847 */, + + -PRESHIFT(0x00002000) /* -0.000030518 */, + -PRESHIFT(0x0003f000) /* -0.000961304 */, + PRESHIFT(0x000dd000) /* 0.003372192 */, + -PRESHIFT(0x00428000) /* -0.016235352 */, + PRESHIFT(0x00500000) /* 0.019531250 */, + -PRESHIFT(0x02011000) /* -0.125259399 */, + -PRESHIFT(0x003e6000) /* -0.015228271 */, + -PRESHIFT(0x0d11e000) /* -0.816864014 */, + PRESHIFT(0x116fc000) /* 1.089782715 */, + PRESHIFT(0x052c5000) /* 0.323318481 */, + PRESHIFT(0x02616000) /* 0.148773193 */, + PRESHIFT(0x007d6000) /* 0.030609131 */, + PRESHIFT(0x007aa000) /* 0.029937744 */, + PRESHIFT(0x00024000) /* 0.000549316 */, + PRESHIFT(0x0009a000) /* 0.002349854 */, + PRESHIFT(0x0000b000) /* 0.000167847 */ }, + + { -PRESHIFT(0x00002000) /* -0.000030518 */, /* 10 */ + -PRESHIFT(0x00044000) /* -0.001037598 */, + PRESHIFT(0x000d7000) /* 0.003280640 */, + -PRESHIFT(0x00471000) /* -0.017349243 */, + PRESHIFT(0x0046b000) /* 0.017257690 */, + -PRESHIFT(0x0212b000) /* -0.129562378 */, + -PRESHIFT(0x0084a000) /* -0.032379150 */, + -PRESHIFT(0x0d78a000) /* -0.841949463 */, + PRESHIFT(0x113be000) /* 1.077117920 */, + PRESHIFT(0x04c16000) /* 0.297210693 */, + PRESHIFT(0x02687000) /* 0.150497437 */, + PRESHIFT(0x0069c000) /* 0.025817871 */, + PRESHIFT(0x0077f000) /* 0.029281616 */, + PRESHIFT(0x00002000) /* 0.000030518 */, + PRESHIFT(0x00093000) /* 0.002243042 */, + PRESHIFT(0x0000a000) /* 0.000152588 */, + + -PRESHIFT(0x00002000) /* -0.000030518 */, + -PRESHIFT(0x00044000) /* -0.001037598 */, + PRESHIFT(0x000d7000) /* 0.003280640 */, + -PRESHIFT(0x00471000) /* -0.017349243 */, + PRESHIFT(0x0046b000) /* 0.017257690 */, + -PRESHIFT(0x0212b000) /* -0.129562378 */, + -PRESHIFT(0x0084a000) /* -0.032379150 */, + -PRESHIFT(0x0d78a000) /* -0.841949463 */, + PRESHIFT(0x113be000) /* 1.077117920 */, + PRESHIFT(0x04c16000) /* 0.297210693 */, + PRESHIFT(0x02687000) /* 0.150497437 */, + PRESHIFT(0x0069c000) /* 0.025817871 */, + PRESHIFT(0x0077f000) /* 0.029281616 */, + PRESHIFT(0x00002000) /* 0.000030518 */, + PRESHIFT(0x00093000) /* 0.002243042 */, + PRESHIFT(0x0000a000) /* 0.000152588 */ }, + + { -PRESHIFT(0x00003000) /* -0.000045776 */, /* 11 */ + -PRESHIFT(0x00049000) /* -0.001113892 */, + PRESHIFT(0x000d0000) /* 0.003173828 */, + -PRESHIFT(0x004ba000) /* -0.018463135 */, + PRESHIFT(0x003ca000) /* 0.014801025 */, + -PRESHIFT(0x02233000) /* -0.133590698 */, + -PRESHIFT(0x00ce4000) /* -0.050354004 */, + -PRESHIFT(0x0ddca000) /* -0.866363525 */, + PRESHIFT(0x1102f000) /* 1.063217163 */, + PRESHIFT(0x04587000) /* 0.271591187 */, + PRESHIFT(0x026cf000) /* 0.151596069 */, + PRESHIFT(0x0056c000) /* 0.021179199 */, + PRESHIFT(0x0074e000) /* 0.028533936 */, + -PRESHIFT(0x0001d000) /* -0.000442505 */, + PRESHIFT(0x0008b000) /* 0.002120972 */, + PRESHIFT(0x00009000) /* 0.000137329 */, + + -PRESHIFT(0x00003000) /* -0.000045776 */, + -PRESHIFT(0x00049000) /* -0.001113892 */, + PRESHIFT(0x000d0000) /* 0.003173828 */, + -PRESHIFT(0x004ba000) /* -0.018463135 */, + PRESHIFT(0x003ca000) /* 0.014801025 */, + -PRESHIFT(0x02233000) /* -0.133590698 */, + -PRESHIFT(0x00ce4000) /* -0.050354004 */, + -PRESHIFT(0x0ddca000) /* -0.866363525 */, + PRESHIFT(0x1102f000) /* 1.063217163 */, + PRESHIFT(0x04587000) /* 0.271591187 */, + PRESHIFT(0x026cf000) /* 0.151596069 */, + PRESHIFT(0x0056c000) /* 0.021179199 */, + PRESHIFT(0x0074e000) /* 0.028533936 */, + -PRESHIFT(0x0001d000) /* -0.000442505 */, + PRESHIFT(0x0008b000) /* 0.002120972 */, + PRESHIFT(0x00009000) /* 0.000137329 */ }, + + { -PRESHIFT(0x00003000) /* -0.000045776 */, /* 12 */ + -PRESHIFT(0x0004f000) /* -0.001205444 */, + PRESHIFT(0x000c8000) /* 0.003051758 */, + -PRESHIFT(0x00503000) /* -0.019577026 */, + PRESHIFT(0x0031a000) /* 0.012115479 */, + -PRESHIFT(0x02326000) /* -0.137298584 */, + -PRESHIFT(0x011b5000) /* -0.069168091 */, + -PRESHIFT(0x0e3dd000) /* -0.890090942 */, + PRESHIFT(0x10c54000) /* 1.048156738 */, + PRESHIFT(0x03f1b000) /* 0.246505737 */, + PRESHIFT(0x026ee000) /* 0.152069092 */, + PRESHIFT(0x00447000) /* 0.016708374 */, + PRESHIFT(0x00719000) /* 0.027725220 */, + -PRESHIFT(0x00039000) /* -0.000869751 */, + PRESHIFT(0x00084000) /* 0.002014160 */, + PRESHIFT(0x00008000) /* 0.000122070 */, + + -PRESHIFT(0x00003000) /* -0.000045776 */, + -PRESHIFT(0x0004f000) /* -0.001205444 */, + PRESHIFT(0x000c8000) /* 0.003051758 */, + -PRESHIFT(0x00503000) /* -0.019577026 */, + PRESHIFT(0x0031a000) /* 0.012115479 */, + -PRESHIFT(0x02326000) /* -0.137298584 */, + -PRESHIFT(0x011b5000) /* -0.069168091 */, + -PRESHIFT(0x0e3dd000) /* -0.890090942 */, + PRESHIFT(0x10c54000) /* 1.048156738 */, + PRESHIFT(0x03f1b000) /* 0.246505737 */, + PRESHIFT(0x026ee000) /* 0.152069092 */, + PRESHIFT(0x00447000) /* 0.016708374 */, + PRESHIFT(0x00719000) /* 0.027725220 */, + -PRESHIFT(0x00039000) /* -0.000869751 */, + PRESHIFT(0x00084000) /* 0.002014160 */, + PRESHIFT(0x00008000) /* 0.000122070 */ }, + + { -PRESHIFT(0x00004000) /* -0.000061035 */, /* 13 */ + -PRESHIFT(0x00055000) /* -0.001296997 */, + PRESHIFT(0x000bd000) /* 0.002883911 */, + -PRESHIFT(0x0054c000) /* -0.020690918 */, + PRESHIFT(0x0025d000) /* 0.009231567 */, + -PRESHIFT(0x02403000) /* -0.140670776 */, + -PRESHIFT(0x016ba000) /* -0.088775635 */, + -PRESHIFT(0x0e9be000) /* -0.913055420 */, + PRESHIFT(0x1082d000) /* 1.031936646 */, + PRESHIFT(0x038d4000) /* 0.221984863 */, + PRESHIFT(0x026e7000) /* 0.151962280 */, + PRESHIFT(0x0032e000) /* 0.012420654 */, + PRESHIFT(0x006df000) /* 0.026840210 */, + -PRESHIFT(0x00053000) /* -0.001266479 */, + PRESHIFT(0x0007d000) /* 0.001907349 */, + PRESHIFT(0x00007000) /* 0.000106812 */, + + -PRESHIFT(0x00004000) /* -0.000061035 */, + -PRESHIFT(0x00055000) /* -0.001296997 */, + PRESHIFT(0x000bd000) /* 0.002883911 */, + -PRESHIFT(0x0054c000) /* -0.020690918 */, + PRESHIFT(0x0025d000) /* 0.009231567 */, + -PRESHIFT(0x02403000) /* -0.140670776 */, + -PRESHIFT(0x016ba000) /* -0.088775635 */, + -PRESHIFT(0x0e9be000) /* -0.913055420 */, + PRESHIFT(0x1082d000) /* 1.031936646 */, + PRESHIFT(0x038d4000) /* 0.221984863 */, + PRESHIFT(0x026e7000) /* 0.151962280 */, + PRESHIFT(0x0032e000) /* 0.012420654 */, + PRESHIFT(0x006df000) /* 0.026840210 */, + -PRESHIFT(0x00053000) /* -0.001266479 */, + PRESHIFT(0x0007d000) /* 0.001907349 */, + PRESHIFT(0x00007000) /* 0.000106812 */ }, + + { -PRESHIFT(0x00004000) /* -0.000061035 */, /* 14 */ + -PRESHIFT(0x0005b000) /* -0.001388550 */, + PRESHIFT(0x000b1000) /* 0.002700806 */, + -PRESHIFT(0x00594000) /* -0.021789551 */, + PRESHIFT(0x00192000) /* 0.006134033 */, + -PRESHIFT(0x024c8000) /* -0.143676758 */, + -PRESHIFT(0x01bf2000) /* -0.109161377 */, + -PRESHIFT(0x0ef69000) /* -0.935195923 */, + PRESHIFT(0x103be000) /* 1.014617920 */, + PRESHIFT(0x032b4000) /* 0.198059082 */, + PRESHIFT(0x026bc000) /* 0.151306152 */, + PRESHIFT(0x00221000) /* 0.008316040 */, + PRESHIFT(0x006a2000) /* 0.025909424 */, + -PRESHIFT(0x0006a000) /* -0.001617432 */, + PRESHIFT(0x00075000) /* 0.001785278 */, + PRESHIFT(0x00007000) /* 0.000106812 */, + + -PRESHIFT(0x00004000) /* -0.000061035 */, + -PRESHIFT(0x0005b000) /* -0.001388550 */, + PRESHIFT(0x000b1000) /* 0.002700806 */, + -PRESHIFT(0x00594000) /* -0.021789551 */, + PRESHIFT(0x00192000) /* 0.006134033 */, + -PRESHIFT(0x024c8000) /* -0.143676758 */, + -PRESHIFT(0x01bf2000) /* -0.109161377 */, + -PRESHIFT(0x0ef69000) /* -0.935195923 */, + PRESHIFT(0x103be000) /* 1.014617920 */, + PRESHIFT(0x032b4000) /* 0.198059082 */, + PRESHIFT(0x026bc000) /* 0.151306152 */, + PRESHIFT(0x00221000) /* 0.008316040 */, + PRESHIFT(0x006a2000) /* 0.025909424 */, + -PRESHIFT(0x0006a000) /* -0.001617432 */, + PRESHIFT(0x00075000) /* 0.001785278 */, + PRESHIFT(0x00007000) /* 0.000106812 */ }, + + { -PRESHIFT(0x00005000) /* -0.000076294 */, /* 15 */ + -PRESHIFT(0x00061000) /* -0.001480103 */, + PRESHIFT(0x000a3000) /* 0.002487183 */, + -PRESHIFT(0x005da000) /* -0.022857666 */, + PRESHIFT(0x000b9000) /* 0.002822876 */, + -PRESHIFT(0x02571000) /* -0.146255493 */, + -PRESHIFT(0x0215c000) /* -0.130310059 */, + -PRESHIFT(0x0f4dc000) /* -0.956481934 */, + PRESHIFT(0x0ff0a000) /* 0.996246338 */, + PRESHIFT(0x02cbf000) /* 0.174789429 */, + PRESHIFT(0x0266e000) /* 0.150115967 */, + PRESHIFT(0x00120000) /* 0.004394531 */, + PRESHIFT(0x00662000) /* 0.024932861 */, + -PRESHIFT(0x0007f000) /* -0.001937866 */, + PRESHIFT(0x0006f000) /* 0.001693726 */, + PRESHIFT(0x00006000) /* 0.000091553 */, + + -PRESHIFT(0x00005000) /* -0.000076294 */, + -PRESHIFT(0x00061000) /* -0.001480103 */, + PRESHIFT(0x000a3000) /* 0.002487183 */, + -PRESHIFT(0x005da000) /* -0.022857666 */, + PRESHIFT(0x000b9000) /* 0.002822876 */, + -PRESHIFT(0x02571000) /* -0.146255493 */, + -PRESHIFT(0x0215c000) /* -0.130310059 */, + -PRESHIFT(0x0f4dc000) /* -0.956481934 */, + PRESHIFT(0x0ff0a000) /* 0.996246338 */, + PRESHIFT(0x02cbf000) /* 0.174789429 */, + PRESHIFT(0x0266e000) /* 0.150115967 */, + PRESHIFT(0x00120000) /* 0.004394531 */, + PRESHIFT(0x00662000) /* 0.024932861 */, + -PRESHIFT(0x0007f000) /* -0.001937866 */, + PRESHIFT(0x0006f000) /* 0.001693726 */, + PRESHIFT(0x00006000) /* 0.000091553 */ }, + + { -PRESHIFT(0x00005000) /* -0.000076294 */, /* 16 */ + -PRESHIFT(0x00068000) /* -0.001586914 */, + PRESHIFT(0x00092000) /* 0.002227783 */, + -PRESHIFT(0x0061f000) /* -0.023910522 */, + -PRESHIFT(0x0002d000) /* -0.000686646 */, + -PRESHIFT(0x025ff000) /* -0.148422241 */, + -PRESHIFT(0x026f7000) /* -0.152206421 */, + -PRESHIFT(0x0fa13000) /* -0.976852417 */, + PRESHIFT(0x0fa13000) /* 0.976852417 */, + PRESHIFT(0x026f7000) /* 0.152206421 */, + PRESHIFT(0x025ff000) /* 0.148422241 */, + PRESHIFT(0x0002d000) /* 0.000686646 */, + PRESHIFT(0x0061f000) /* 0.023910522 */, + -PRESHIFT(0x00092000) /* -0.002227783 */, + PRESHIFT(0x00068000) /* 0.001586914 */, + PRESHIFT(0x00005000) /* 0.000076294 */, + + -PRESHIFT(0x00005000) /* -0.000076294 */, + -PRESHIFT(0x00068000) /* -0.001586914 */, + PRESHIFT(0x00092000) /* 0.002227783 */, + -PRESHIFT(0x0061f000) /* -0.023910522 */, + -PRESHIFT(0x0002d000) /* -0.000686646 */, + -PRESHIFT(0x025ff000) /* -0.148422241 */, + -PRESHIFT(0x026f7000) /* -0.152206421 */, + -PRESHIFT(0x0fa13000) /* -0.976852417 */, + PRESHIFT(0x0fa13000) /* 0.976852417 */, + PRESHIFT(0x026f7000) /* 0.152206421 */, + PRESHIFT(0x025ff000) /* 0.148422241 */, + PRESHIFT(0x0002d000) /* 0.000686646 */, + PRESHIFT(0x0061f000) /* 0.023910522 */, + -PRESHIFT(0x00092000) /* -0.002227783 */, + PRESHIFT(0x00068000) /* 0.001586914 */, + PRESHIFT(0x00005000) /* 0.000076294 */ } diff --git a/lib/rbcodec/codecs/libmad/README b/lib/rbcodec/codecs/libmad/README new file mode 100644 index 0000000000..524a94b29d --- /dev/null +++ b/lib/rbcodec/codecs/libmad/README @@ -0,0 +1,241 @@ + + libmad - MPEG audio decoder library + Copyright (C) 2000-2004 Underbit Technologies, Inc. + + $Id$ + +=============================================================================== + +INTRODUCTION + + MAD (libmad) is a high-quality MPEG audio decoder. It currently supports + MPEG-1 and the MPEG-2 extension to Lower Sampling Frequencies, as well as + the so-called MPEG 2.5 format. All three audio layers (Layer I, Layer II, + and Layer III a.k.a. MP3) are fully implemented. + + MAD does not yet support MPEG-2 multichannel audio (although it should be + backward compatible with such streams) nor does it currently support AAC. + + MAD has the following special features: + + - 24-bit PCM output + - 100% fixed-point (integer) computation + - completely new implementation based on the ISO/IEC standards + - distributed under the terms of the GNU General Public License (GPL) + + Because MAD provides full 24-bit PCM output, applications using MAD are + able to produce high quality audio. Even when the output device supports + only 16-bit PCM, applications can use the extra resolution to increase the + audible dynamic range through the use of dithering or noise shaping. + + Because MAD uses integer computation rather than floating point, it is + well suited for architectures without a floating point unit. All + calculations are performed with a 32-bit fixed-point integer + representation. + + Because MAD is a new implementation of the ISO/IEC standards, it is + unencumbered by the errors of other implementations. MAD is NOT a + derivation of the ISO reference source or any other code. Considerable + effort has been expended to ensure a correct implementation, even in cases + where the standards are ambiguous or misleading. + + Because MAD is distributed under the terms of the GPL, its redistribution + is not generally restricted, so long as the terms of the GPL are followed. + This means MAD can be incorporated into other software as long as that + software is also distributed under the GPL. (Should this be undesirable, + alternate arrangements may be possible by contacting Underbit.) + +=============================================================================== + +ABOUT THE CODE + + The code is optimized and performs very well, although specific + improvements can still be made. The output from the decoder library + consists of 32-bit signed linear fixed-point values that can be easily + scaled for any size PCM output, up to 24 bits per sample. + + The API for libmad can be found in the `mad.h' header file. Note that this + file is automatically generated, and will not exist until after you have + built the library. + + There are two APIs available, one high-level, and the other low-level. + With the low-level API, each step of the decoding process must be handled + explicitly, offering the greatest amount of control. With the high-level + API, after callbacks are configured, a single routine will decode an + entire bitstream. + + The high-level API may either be used synchronously or asynchronously. If + used asynchronously, decoding will occur in a separate process. + Communication is possible with the decoding process by passing control + messages. + + The file `minimad.c' contains an example usage of the libmad API that + shows only the bare minimum required to implement a useful decoder. It + expects a regular file to be redirected to standard input, and it sends + decoded 16-bit signed little-endian PCM samples to standard output. If a + decoding error occurs, it is reported to standard error and decoding + continues. Note that the scale() routine in this code is only provided as + an example; it rounds MAD's high-resolution samples down to 16 bits, but + does not perform any dithering or noise shaping. It is therefore not + recommended to use this routine as-is in your own code if sound quality is + important. + +Integer Performance + + To get the best possible performance, it is recommended that an assembly + version of the fixed-point multiply and related routines be selected. + Several such assembly routines have been written for various CPUs. + + If an assembly version is not available, a fast approximation version will + be used. This will result in reduced accuracy of the decoder. + + Alternatively, if 64-bit integers are supported as a datatype by the + compiler, another version can be used that is much more accurate. + However, using an assembly version is generally much faster and just as + accurate. + + More information can be gathered from the `fixed.h' header file. + + MAD's CPU-intensive subband synthesis routine can be further optimized at + the expense of a slight loss in output accuracy due to a modified method + for fixed-point multiplication with a small windowing constant. While this + is helpful for performance and the output accuracy loss is generally + undetectable, it is disabled by default and must be explicitly enabled. + + Under some architectures, other special optimizations may also be + available. + +Audio Quality + + The output from MAD has been found to satisfy the ISO/IEC 11172-4 + computational accuracy requirements for compliance. In most + configurations, MAD is a Full Layer III ISO/IEC 11172-3 audio decoder as + defined by the standard. + + When the approximation version of the fixed-point multiply is used, MAD is + a limited accuracy ISO/IEC 11172-3 audio decoder as defined by the + standard. + + MAD can alternatively be configured to produce output with less or more + accuracy than the default, as a tradeoff with performance. + + MAD produces output samples with a precision greater than 24 bits. Because + most output formats use fewer bits, typically 16, it is recommended that a + dithering algorithm be used (rather than rounding or truncating) to obtain + the highest quality audio. However, dithering may unfavorably affect an + analytic examination of the output (such as compliance testing); you may + therefore wish to use rounding in this case instead. + +Portability Issues + + GCC is preferred to compile the code, but other compilers may also work. + The assembly code in `fixed.h' depends on the inline assembly features of + your compiler. If you're not using GCC or MSVC++, you can either write + your own assembly macros or use the default (low quality output) version. + + The union initialization of `huffman.c' may not be portable to all + platforms when GCC is not used. + + The code should not be sensitive to word sizes or byte ordering, however + it does assume A % B has the same sign as A. + +=============================================================================== + +BUILDING AND INSTALLING + +Windows Platforms + + MAD can be built under Windows using either MSVC++ or Cygwin. A MSVC++ + project file can be found under the `msvc++' subdirectory. + + To build libmad using Cygwin, you will first need to install the Cygwin + tools: + + http://www.cygwin.com/ + + You may then proceed with the following POSIX instructions within the + Cygwin shell. + + Note that by default Cygwin will build a library that depends on the + Cygwin DLL. You can use MinGW to build a library that does not depend on + the Cygwin DLL. To do so, give the option --host=mingw32 to `configure'. + +POSIX Platforms (including Cygwin) + + The code is distributed with a `configure' script that will generate for + you a `Makefile' and a `config.h' for your platform. See the file + `INSTALL' for generic instructions. + + The specific options you may want to give `configure' are: + + --enable-speed optimize for speed over accuracy + + --enable-accuracy optimize for accuracy over speed + + --disable-debugging do not compile with debugging support, and + use more optimizations + + --disable-shared do not build a shared library + + Note that you need not specify one of --enable-speed or --enable-accuracy; + in its default configuration, MAD is optimized for both. You should only + use one of these options if you wish to compromise speed or accuracy for + the other. + + By default the package will build a shared library if possible for your + platform. If you want only a static library, use --disable-shared. + + It is not normally necessary to use the following options, but you may + fine-tune the configuration with them if desired: + + --enable-fpm=ARCH use the ARCH-specific version of the + fixed-point math assembly routines + (current options are: intel, arm, mips, + sparc, ppc; also allowed are: 64bit, approx) + + --enable-sso use the subband synthesis optimization, + with reduced accuracy + + --disable-aso do not use certain architecture-specific + optimizations + + By default an appropriate fixed-point assembly routine will be selected + for the configured host type, if it can be determined. Thus if you are + cross-compiling for another architecture, you should be sure either to + give `configure' a host type argument (--host) or to use an explicit + --enable-fpm option. + + If an appropriate assembly routine cannot be determined, the default + approximation version will be used. In this case, use of an alternate + --enable-fpm is highly recommended. + +Experimenting and Developing + + Further options for `configure' that may be useful to developers and + experimenters are: + + --enable-debugging enable diagnostic debugging support and + debugging symbols + + --enable-profiling generate `gprof' profiling code + + --enable-experimental enable code using the EXPERIMENTAL + preprocessor define + +=============================================================================== + +COPYRIGHT + + Please read the `COPYRIGHT' file for copyright and warranty information. + Also, the file `COPYING' contains the full text of the GNU GPL. + + Send inquiries, comments, bug reports, suggestions, patches, etc. to: + + Underbit Technologies, Inc. + + See also the MAD home page on the Web: + + http://www.underbit.com/products/mad/ + +=============================================================================== + diff --git a/lib/rbcodec/codecs/libmad/README.rockbox b/lib/rbcodec/codecs/libmad/README.rockbox new file mode 100644 index 0000000000..faddc0d391 --- /dev/null +++ b/lib/rbcodec/codecs/libmad/README.rockbox @@ -0,0 +1,23 @@ +Library: libmad-0.15.1b (2004-02-17) +Imported: 2005-02-15 by Dave Chapman + + +This directory contains a local version of libmad for use by Rockbox +targets needing software MPEG audio decoding. + + +LICENSING INFORMATION + +libmad is (C) 2000-2004 Unibit Technologies, Inc. and licensed under +the terms of the GNU General Public License. See file "COPYRIGHT" in +this directory for more information. + + +IMPORT DETAILS + +The base version first imported into Rockbox was libmad-0.15.1b +(released on 2004-02-17), downloaded on 2005-02-15 from the files +section at http://sourceforge.net/projects/mad/ + +The autoconf/automake files were removed from the official source +tarball, as well as the "msvc++" subdirectory. diff --git a/lib/rbcodec/codecs/libmad/SOURCES b/lib/rbcodec/codecs/libmad/SOURCES new file mode 100644 index 0000000000..d81804ca38 --- /dev/null +++ b/lib/rbcodec/codecs/libmad/SOURCES @@ -0,0 +1,14 @@ +bit.c +frame.c +huffman.c +layer12.c +layer3.c +stream.c +synth.c +#if defined(CPU_COLDFIRE) +imdct_mcf5249.S +#endif +#if defined(CPU_ARM) +imdct_l_arm.S +synth_full_arm.S +#endif diff --git a/lib/rbcodec/codecs/libmad/TODO b/lib/rbcodec/codecs/libmad/TODO new file mode 100644 index 0000000000..a397655c6c --- /dev/null +++ b/lib/rbcodec/codecs/libmad/TODO @@ -0,0 +1,69 @@ + + libmad - MPEG audio decoder library + Copyright (C) 2000-2004 Underbit Technologies, Inc. + + $Id$ + +=============================================================================== + +libmad: + - more API layers (buffering, PCM samples, dithering, etc.) + - x86 performance optimization compiler flags + - function documentation, general docs + - finish async API + - parse system streams? + - MPEG-2 MC, AAC? + - logarithmic multiplication? + - multiple frame decoding for better locality of reference? + - frame serial numbers, Layer III frame continuity checks + +fixed.h: + - experiment with FPM_INTEL: + +# if 1 +# define mad_f_scale64(hi, lo) \ + ({ mad_fixed_t __result; \ + asm ("shrl %3,%1\n\t" \ + "shll %4,%2\n\t" \ + "orl %2,%1" \ + : "=rm" (__result) \ + : "0" (lo), "r" (hi), \ + "I" (MAD_F_SCALEBITS), "I" (32 - MAD_F_SCALEBITS) \ + : "cc"); \ + __result; \ + }) +# else +# define mad_f_scale64(hi, lo) \ + ({ mad_fixed64hi_t __hi_; \ + mad_fixed64lo_t __lo_; \ + mad_fixed_t __result; \ + asm ("sall %2,%1" \ + : "=r" (__hi_) \ + : "0" (hi), "I" (32 - MAD_F_SCALEBITS) \ + : "cc"); \ + asm ("shrl %2,%1" \ + : "=r" (__lo_) \ + : "0" (lo), "I" (MAD_F_SCALEBITS) \ + : "cc"); \ + asm ("orl %1,%2" \ + : "=rm" (__result) \ + : "r" (__hi_), "0" (__lo_) \ + : "cc"); \ + __result; \ + }) +# endif + +libmad Layer I: + - check frame length sanity + +libmad Layer II: + - check frame length sanity + +libmad Layer III: + - circular buffer + - optimize zero_part from Huffman decoding throughout + - MPEG 2.5 8000 Hz sf bands? mixed blocks? + - stereo->mono conversion optimization? + - enable frame-at-a-time decoding + - improve portability of huffman.c + diff --git a/lib/rbcodec/codecs/libmad/VERSION b/lib/rbcodec/codecs/libmad/VERSION new file mode 100644 index 0000000000..d4e8f64aa2 --- /dev/null +++ b/lib/rbcodec/codecs/libmad/VERSION @@ -0,0 +1,7 @@ +0.15.1b +configure.ac:24 +version.h:25-28 +msvc++/config.h:99,105,120 +msvc++/mad.h:41-44 + +Makefile.am:98-100 diff --git a/lib/rbcodec/codecs/libmad/bit.c b/lib/rbcodec/codecs/libmad/bit.c new file mode 100644 index 0000000000..c08806d385 --- /dev/null +++ b/lib/rbcodec/codecs/libmad/bit.c @@ -0,0 +1,218 @@ +/* + * libmad - MPEG audio decoder library + * Copyright (C) 2000-2004 Underbit Technologies, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * $Id$ + */ + +# ifdef HAVE_CONFIG_H +# include "config.h" +# endif + +# include "global.h" + +# ifdef HAVE_LIMITS_H +# include +# else +# undef CHAR_BIT +# define CHAR_BIT 8 +# endif + +# include "bit.h" + +/* + * This is the lookup table for computing the CRC-check word. + * As described in section 2.4.3.1 and depicted in Figure A.9 + * of ISO/IEC 11172-3, the generator polynomial is: + * + * G(X) = X^16 + X^15 + X^2 + 1 + */ +static +unsigned short const crc_table[256] = { + 0x0000, 0x8005, 0x800f, 0x000a, 0x801b, 0x001e, 0x0014, 0x8011, + 0x8033, 0x0036, 0x003c, 0x8039, 0x0028, 0x802d, 0x8027, 0x0022, + 0x8063, 0x0066, 0x006c, 0x8069, 0x0078, 0x807d, 0x8077, 0x0072, + 0x0050, 0x8055, 0x805f, 0x005a, 0x804b, 0x004e, 0x0044, 0x8041, + 0x80c3, 0x00c6, 0x00cc, 0x80c9, 0x00d8, 0x80dd, 0x80d7, 0x00d2, + 0x00f0, 0x80f5, 0x80ff, 0x00fa, 0x80eb, 0x00ee, 0x00e4, 0x80e1, + 0x00a0, 0x80a5, 0x80af, 0x00aa, 0x80bb, 0x00be, 0x00b4, 0x80b1, + 0x8093, 0x0096, 0x009c, 0x8099, 0x0088, 0x808d, 0x8087, 0x0082, + + 0x8183, 0x0186, 0x018c, 0x8189, 0x0198, 0x819d, 0x8197, 0x0192, + 0x01b0, 0x81b5, 0x81bf, 0x01ba, 0x81ab, 0x01ae, 0x01a4, 0x81a1, + 0x01e0, 0x81e5, 0x81ef, 0x01ea, 0x81fb, 0x01fe, 0x01f4, 0x81f1, + 0x81d3, 0x01d6, 0x01dc, 0x81d9, 0x01c8, 0x81cd, 0x81c7, 0x01c2, + 0x0140, 0x8145, 0x814f, 0x014a, 0x815b, 0x015e, 0x0154, 0x8151, + 0x8173, 0x0176, 0x017c, 0x8179, 0x0168, 0x816d, 0x8167, 0x0162, + 0x8123, 0x0126, 0x012c, 0x8129, 0x0138, 0x813d, 0x8137, 0x0132, + 0x0110, 0x8115, 0x811f, 0x011a, 0x810b, 0x010e, 0x0104, 0x8101, + + 0x8303, 0x0306, 0x030c, 0x8309, 0x0318, 0x831d, 0x8317, 0x0312, + 0x0330, 0x8335, 0x833f, 0x033a, 0x832b, 0x032e, 0x0324, 0x8321, + 0x0360, 0x8365, 0x836f, 0x036a, 0x837b, 0x037e, 0x0374, 0x8371, + 0x8353, 0x0356, 0x035c, 0x8359, 0x0348, 0x834d, 0x8347, 0x0342, + 0x03c0, 0x83c5, 0x83cf, 0x03ca, 0x83db, 0x03de, 0x03d4, 0x83d1, + 0x83f3, 0x03f6, 0x03fc, 0x83f9, 0x03e8, 0x83ed, 0x83e7, 0x03e2, + 0x83a3, 0x03a6, 0x03ac, 0x83a9, 0x03b8, 0x83bd, 0x83b7, 0x03b2, + 0x0390, 0x8395, 0x839f, 0x039a, 0x838b, 0x038e, 0x0384, 0x8381, + + 0x0280, 0x8285, 0x828f, 0x028a, 0x829b, 0x029e, 0x0294, 0x8291, + 0x82b3, 0x02b6, 0x02bc, 0x82b9, 0x02a8, 0x82ad, 0x82a7, 0x02a2, + 0x82e3, 0x02e6, 0x02ec, 0x82e9, 0x02f8, 0x82fd, 0x82f7, 0x02f2, + 0x02d0, 0x82d5, 0x82df, 0x02da, 0x82cb, 0x02ce, 0x02c4, 0x82c1, + 0x8243, 0x0246, 0x024c, 0x8249, 0x0258, 0x825d, 0x8257, 0x0252, + 0x0270, 0x8275, 0x827f, 0x027a, 0x826b, 0x026e, 0x0264, 0x8261, + 0x0220, 0x8225, 0x822f, 0x022a, 0x823b, 0x023e, 0x0234, 0x8231, + 0x8213, 0x0216, 0x021c, 0x8219, 0x0208, 0x820d, 0x8207, 0x0202 +}; + +# define CRC_POLY 0x8005 + +#if INT_MAX != 0x7fffffff +#warning current libmad bit handling is optimized for architectures using 32 bit integers +#endif + +/* + * NAME: bit->init() + * DESCRIPTION: initialize bit pointer struct + */ +void mad_bit_init(struct mad_bitptr *bitptr, unsigned char const *byte) +{ + bitptr->ptr = (uint32_t*)((uintptr_t)byte & ~3); + bitptr->readbit = ((uintptr_t)byte & 3) << 3; +} + +/* + * NAME: bit->length() + * DESCRIPTION: return number of bits between start and end points + */ +unsigned int mad_bit_length(struct mad_bitptr const *begin, + struct mad_bitptr const *end) +{ + return end->readbit - begin->readbit; +} + +/* rockbox: not used +unsigned char mad_bit_bitsleft(struct mad_bitptr const *bitptr) +{ + return 8 - (bitptr->readbit & 7); +} +*/ + +/* + * NAME: bit->nextbyte() + * DESCRIPTION: return pointer to next unprocessed byte + */ +unsigned char const *mad_bit_nextbyte(struct mad_bitptr const *bitptr) +{ + return (unsigned char const*)bitptr->ptr + ((bitptr->readbit + 7) >> 3); +} + +/* + * NAME: bit->skip() + * DESCRIPTION: advance bit pointer + */ +void mad_bit_skip(struct mad_bitptr *bitptr, unsigned int len) +{ + bitptr->readbit += len; +} + +/* + * NAME: bit->read() + * DESCRIPTION: read an arbitrary number of bits and return their UIMSBF value + */ + +uint32_t mad_bit_read(struct mad_bitptr *bitptr, unsigned int len) ICODE_ATTR; +uint32_t mad_bit_read(struct mad_bitptr *bitptr, unsigned int len) +{ + uint32_t *curr = &bitptr->ptr[bitptr->readbit>>5]; + + if(len) + { + uint32_t r = betoh32(curr[0]) << (bitptr->readbit & 31); + + if((bitptr->readbit & 31) + len > 32) + r += betoh32(curr[1]) >> (-bitptr->readbit & 31); + + bitptr->readbit += len; + return r >> (32 - len); + } + + return 0; +} + +# if 0 /* rockbox: not used */ +/* + * NAME: bit->write() + * DESCRIPTION: write an arbitrary number of bits + */ +void mad_bit_write(struct mad_bitptr *bitptr, unsigned int len, + uint32_t value) +{ + unsigned char *ptr; + + ptr = (unsigned char *) bitptr->byte; + + /* ... */ +} +# endif + +/* + * NAME: bit->crc() + * DESCRIPTION: compute CRC-check word + */ +unsigned short mad_bit_crc(struct mad_bitptr bitptr, unsigned int len, + unsigned short init) +{ + register unsigned int crc; + + for (crc = init; len >= 32; len -= 32) { + register uint32_t data; + + data = mad_bit_read(&bitptr, 32); + + crc = (crc << 8) ^ crc_table[((crc >> 8) ^ (data >> 24)) & 0xff]; + crc = (crc << 8) ^ crc_table[((crc >> 8) ^ (data >> 16)) & 0xff]; + crc = (crc << 8) ^ crc_table[((crc >> 8) ^ (data >> 8)) & 0xff]; + crc = (crc << 8) ^ crc_table[((crc >> 8) ^ (data >> 0)) & 0xff]; + } + + switch (len / 8) { + case 3: crc = (crc << 8) ^ + crc_table[((crc >> 8) ^ mad_bit_read(&bitptr, 8)) & 0xff]; + case 2: crc = (crc << 8) ^ + crc_table[((crc >> 8) ^ mad_bit_read(&bitptr, 8)) & 0xff]; + case 1: crc = (crc << 8) ^ + crc_table[((crc >> 8) ^ mad_bit_read(&bitptr, 8)) & 0xff]; + + len %= 8; + + case 0: break; + } + + while (len--) { + register unsigned int msb; + + msb = mad_bit_read(&bitptr, 1) ^ (crc >> 15); + + crc <<= 1; + if (msb & 1) + crc ^= CRC_POLY; + } + + return crc & 0xffff; +} diff --git a/lib/rbcodec/codecs/libmad/bit.h b/lib/rbcodec/codecs/libmad/bit.h new file mode 100644 index 0000000000..1c49522af5 --- /dev/null +++ b/lib/rbcodec/codecs/libmad/bit.h @@ -0,0 +1,50 @@ +/* + * libmad - MPEG audio decoder library + * Copyright (C) 2000-2004 Underbit Technologies, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * $Id$ + */ + +# ifndef LIBMAD_BIT_H +# define LIBMAD_BIT_H + +struct mad_bitptr { + uint32_t *ptr; + uint32_t readbit; +}; + +void mad_bit_init(struct mad_bitptr *, unsigned char const *); + +# define mad_bit_finish(bitptr) /* nothing */ + +unsigned int mad_bit_length(struct mad_bitptr const *, + struct mad_bitptr const *); + +/* rockbox: not used +unsigned char mad_bit_bitsleft(struct mad_bitptr const *bitptr); +*/ +unsigned char const *mad_bit_nextbyte(struct mad_bitptr const *); + +void mad_bit_skip(struct mad_bitptr *, unsigned int); +uint32_t mad_bit_read(struct mad_bitptr *, unsigned int); +/* rockbox: not used +void mad_bit_write(struct mad_bitptr *, unsigned int, uint32_t); +*/ + +unsigned short mad_bit_crc(struct mad_bitptr, unsigned int, unsigned short); + +# endif diff --git a/lib/rbcodec/codecs/libmad/dct32_arm.S b/lib/rbcodec/codecs/libmad/dct32_arm.S new file mode 100644 index 0000000000..440841bb5e --- /dev/null +++ b/lib/rbcodec/codecs/libmad/dct32_arm.S @@ -0,0 +1,328 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2007 by Tomasz Malesinski + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include "mad_iram.h" + + .global dct32 + + .section ICODE_SECTION_MPA_ARM,"ax",%progbits + +dct32: + stmdb sp!, {r4-r11, lr} + sub sp, sp, #144 + str r0, [sp, #12] + str r1, [sp, #8] + str r2, [sp, #4] + str r3, [sp] + add r0, sp, #16 + add r1, r0, #128 + ldr r2, =bitrev +.shuffle: + ldr r5, [sp, #12] + ldr r3, [r2], #4 + sub r4, r5, r3, lsl #4 + add r3, r5, r3, lsl #4 + ldr r6, [r3] + ldr r8, [r4, #124] + add r6, r6, r8 + sub r8, r6, r8, lsl #1 + ldr r7, [r3, #8] + ldr lr, [r4, #116] + add r7, r7, lr + sub lr, r7, lr, lsl #1 + ldr r10, [r3, #64] + ldr r9, [r4, #60] + add r10, r10, r9 + sub r9, r10, r9, lsl #1 + ldr r11, [r3, #72] + ldr r12, [r4, #52] + add r11, r11, r12 + sub r12, r11, r12, lsl #1 + add r6, r6, r10 + sub r10, r6, r10, lsl #1 + add r7, r7, r11 + sub r11, r7, r11, lsl #1 + add r8, r8, r12 + sub r12, r8, r12, lsl #1 + add lr, lr, r9 + sub r9, lr, r9, lsl #1 + stmia r0!, {r6, r7, r8, r9, r10, r11, r12, lr} + cmp r0, r1 + bne .shuffle + ldr r0, =189812531 + add r1, sp, #16 + add r3, r1, #128 +.l2: + add r2, r1, #32 + ldmia r2, {r4, r5, r8, r9} + ldmia r1, {r6, r7, r10, r11} + add r6, r6, r4 + sub r4, r6, r4, lsl #1 + add r7, r7, r5 + sub r5, r7, r5, lsl #1 + stmia r2!, {r4, r5} + stmia r1!, {r6, r7} + add r9, r9, r8 + sub r8, r9, r8, lsl #1 + smull r4, r6, r9, r0 + movs r4, r4, lsr #28 + adc r4, r4, r6, lsl #4 + smull r5, r6, r8, r0 + movs r5, r5, lsr #28 + adc r5, r5, r6, lsl #4 + add r10, r10, r4 + sub r4, r10, r4, lsl #1 + add r11, r11, r5 + sub r5, r11, r5, lsl #1 + stmia r2!, {r4, r5} + stmia r1!, {r10, r11} + ldmia r2, {r5, r6, r8, r11} + ldmia r1, {r4, r7, r9, r10} + add r4, r4, r6 + sub r6, r4, r6, lsl #1 + add r7, r7, r5 + sub r5, r7, r5, lsl #1 + stmia r2!, {r6, r7} + stmia r1!, {r4, r5} + add r11, r11, r8 + sub r8, r11, r8, lsl #1 + smull r5, r4, r8, r0 + movs r5, r5, lsr #28 + adc r5, r5, r4, lsl #4 + smull r6, r4, r11, r0 + movs r6, r6, lsr #28 + adc r6, r6, r4, lsl #4 + add r9, r9, r5 + sub r5, r9, r5, lsl #1 + sub r10, r10, r6 + add r6, r10, r6, lsl #1 + stmia r2!, {r5, r6} + stmia r1!, {r9, r10} + add r1, r1, #32 + cmp r1, r3 + bne .l2 + add r2, sp, #16 + add r3, r2, #64 + ldr r0, =sincos + add r1, r0, #128 +.lbut8: + ldmia r3, {r7, r8} + ldmia r0, {r9, r10} + add r0, r0, #16 + smull r6, r5, r7, r9 + smlal r6, r5, r10, r8 + movs r6, r6, lsr #28 + adc r6, r6, r5, lsl #4 + smull r10, r5, r7, r10 + rsb r9, r9, #0 + smlal r10, r5, r8, r9 + movs r10, r10, lsr #28 + adc r5, r10, r5, lsl #4 + ldmia r2, {r7, r8} + add r7, r7, r5 + sub r5, r7, r5, lsl #1 + add r8, r8, r6 + sub r6, r8, r6, lsl #1 + stmia r3!, {r5, r6} + stmia r2!, {r7, r8} + cmp r0, r1 + bne .lbut8 + add r1, sp, #16 + ldr r2, =sincos + ldr r3, =sincos2 + ldr r0, [sp, #8] + mov r0, r0, lsl #2 + ldr r4, [sp, #4] + add r4, r4, r0 + ldr r5, [sp] + add r5, r5, #480 + add r5, r5, r0 + mov r0, #0 +.l4: + rsb r12, r0, #16 + and r12, r12, #15 + add lr, sp, #16 + add r12, lr, r12, lsl #3 + ldmia r1!, {r10, r11} + ldmia r12, {r6, r7} + add r6, r6, r10 + sub r10, r6, r10, lsl #1 + add r11, r11, r7 + sub r7, r11, r7, lsl #1 + ldmia r2!, {r12, lr} + smull r9, r8, r11, r12 + smlal r9, r8, lr, r10 + movs r9, r9, lsr #28 + adc r9, r9, r8, lsl #4 + smull lr, r8, r11, lr + rsb r12, r12, #0 + smlal lr, r8, r10, r12 + movs lr, lr, lsr #28 + adc r8, lr, r8, lsl #4 + add r6, r6, r8 + sub r8, r6, r8, lsl #1 + add r7, r7, r9 + sub r9, r7, r9, lsl #1 + add lr, r3, #128 + ldmia lr, {r10, r11} + smull lr, r12, r8, r11 + smlal lr, r12, r9, r10 + movs lr, lr, lsr #28 + adc r12, lr, r12, lsl #4 + str r12, [r4], #32 + cmp r0, #0 + cmpne r0, #8 + beq .skip1 + smull lr, r12, r8, r10 + rsb r9, r9, #0 + smlal lr, r12, r9, r11 + movs lr, lr, lsr #28 + adc r12, lr, r12, lsl #4 + add lr, r5, r0, lsl #6 + str r12, [lr, #-512] +.skip1: + ldmia r3!, {r10, r11} + smull lr, r12, r7, r10 + smlal lr, r12, r6, r11 + movs lr, lr, lsr #28 + adc r12, lr, r12, lsl #4 + str r12, [r5], #-32 + cmp r0, #0 + cmpne r0, #8 + beq .skip2 + smull lr, r12, r6, r10 + rsb r7, r7, #0 + smlal lr, r12, r7, r11 + movs lr, lr, lsr #28 + adc r12, lr, r12, lsl #4 + sub lr, r4, r0, lsl #6 + str r12, [lr, #480] +.skip2: + add r0, r0, #1 + cmp r0, #9 + bne .l4 + add sp, sp, #144 + ldmpc regs=r4-r11 +bitrev: + .word 0x0 + .word 0x2 + .word 0x1 + .word 0x3 + +sincos: + .word 0x0 + .word 0x10000000 + .word -0x31f1708 + .word 0xfb14be8 + .word -0x61f78aa + .word 0xec835e8 + .word -0x8e39d9d + .word 0xd4db315 + .word -0xb504f33 + .word 0xb504f33 + .word -0xd4db315 + .word 0x8e39d9d + .word -0xec835e8 + .word 0x61f78aa + .word -0xfb14be8 + .word 0x31f1708 + .word -0x10000000 + .word 0x0 + .word -0xfb14be8 + .word -0x31f1708 + .word -0xec835e8 + .word -0x61f78aa + .word -0xd4db315 + .word -0x8e39d9d + .word -0xb504f33 + .word -0xb504f33 + .word -0x8e39d9d + .word -0xd4db315 + .word -0x61f78aa + .word -0xec835e8 + .word -0x31f1708 + .word -0xfb14be8 + +sincos2: + .word 0x0 + .word 0x8000000 + .word 0x647d98 + .word 0x7fd8879 + .word 0xc8bd36 + .word 0x7f62369 + .word 0x12c8107 + .word 0x7e9d560 + .word 0x18f8b84 + .word 0x7d8a5f4 + .word 0x1f19f98 + .word 0x7c29fbf + .word 0x25280c6 + .word 0x7a7d056 + .word 0x2b1f34f + .word 0x7884841 + .word 0x30fbc55 + .word 0x7641af4 + .word 0x36ba201 + .word 0x73b5ebd + .word 0x3c56ba7 + .word 0x70e2cbc + .word 0x41ce1e6 + .word 0x6dca0d1 + .word 0x471cece + .word 0x6a6d98a + .word 0x4c3fdff + .word 0x66cf812 + .word 0x5133cc9 + .word 0x62f201b + .word 0x55f5a4d + .word 0x5ed77c9 + .word 0x5a8279a + .word 0x5a8279a + .word 0x5ed77c9 + .word 0x55f5a4d + .word 0x62f201b + .word 0x5133cc9 + .word 0x66cf812 + .word 0x4c3fdff + .word 0x6a6d98a + .word 0x471cece + .word 0x6dca0d1 + .word 0x41ce1e6 + .word 0x70e2cbc + .word 0x3c56ba7 + .word 0x73b5ebd + .word 0x36ba201 + .word 0x7641af4 + .word 0x30fbc55 + .word 0x7884841 + .word 0x2b1f34f + .word 0x7a7d056 + .word 0x25280c6 + .word 0x7c29fbf + .word 0x1f19f98 + .word 0x7d8a5f4 + .word 0x18f8b84 + .word 0x7e9d560 + .word 0x12c8107 + .word 0x7f62369 + .word 0xc8bd36 + .word 0x7fd8879 + .word 0x647d98 diff --git a/lib/rbcodec/codecs/libmad/fixed.h b/lib/rbcodec/codecs/libmad/fixed.h new file mode 100644 index 0000000000..6015684644 --- /dev/null +++ b/lib/rbcodec/codecs/libmad/fixed.h @@ -0,0 +1,510 @@ +/* + * libmad - MPEG audio decoder library + * Copyright (C) 2000-2004 Underbit Technologies, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * $Id$ + */ + +# ifndef LIBMAD_FIXED_H +# define LIBMAD_FIXED_H + +#include + +typedef int32_t mad_fixed_t; + +typedef int32_t mad_fixed64hi_t; +typedef uint32_t mad_fixed64lo_t; + +# if defined(_MSC_VER) +# define mad_fixed64_t signed __int64 +# elif 1 || defined(__GNUC__) +# define mad_fixed64_t signed long long +# endif + +# if defined(FPM_FLOAT) +typedef double mad_sample_t; +# else +typedef mad_fixed_t mad_sample_t; +# endif + +/* + * Fixed-point format: 0xABBBBBBB + * A == whole part (sign + 3 bits) + * B == fractional part (28 bits) + * + * Values are signed two's complement, so the effective range is: + * 0x80000000 to 0x7fffffff + * -8.0 to +7.9999999962747097015380859375 + * + * The smallest representable value is: + * 0x00000001 == 0.0000000037252902984619140625 (i.e. about 3.725e-9) + * + * 28 bits of fractional accuracy represent about + * 8.6 digits of decimal accuracy. + * + * Fixed-point numbers can be added or subtracted as normal + * integers, but multiplication requires shifting the 64-bit result + * from 56 fractional bits back to 28 (and rounding.) + * + * Changing the definition of MAD_F_FRACBITS is only partially + * supported, and must be done with care. + */ + +# define MAD_F_FRACBITS 28 + +# if MAD_F_FRACBITS == 28 +# define MAD_F(x) ((mad_fixed_t) (x##L)) +# else +# if MAD_F_FRACBITS < 28 +# warning "MAD_F_FRACBITS < 28" +# define MAD_F(x) ((mad_fixed_t) \ + (((x##L) + \ + (1L << (28 - MAD_F_FRACBITS - 1))) >> \ + (28 - MAD_F_FRACBITS))) +# elif MAD_F_FRACBITS > 28 +# error "MAD_F_FRACBITS > 28 not currently supported" +# define MAD_F(x) ((mad_fixed_t) \ + ((x##L) << (MAD_F_FRACBITS - 28))) +# endif +# endif + +# define MAD_F_MIN ((mad_fixed_t) -0x80000000L) +# define MAD_F_MAX ((mad_fixed_t) +0x7fffffffL) + +# define MAD_F_ONE MAD_F(0x10000000) + +# define mad_f_tofixed(x) ((mad_fixed_t) \ + ((x) * (double) (1L << MAD_F_FRACBITS) + 0.5)) +# define mad_f_todouble(x) ((double) \ + ((x) / (double) (1L << MAD_F_FRACBITS))) + +# define mad_f_intpart(x) ((x) >> MAD_F_FRACBITS) +# define mad_f_fracpart(x) ((x) & ((1L << MAD_F_FRACBITS) - 1)) + /* (x should be positive) */ + +# define mad_f_fromint(x) ((x) << MAD_F_FRACBITS) + +# define mad_f_add(x, y) ((x) + (y)) +# define mad_f_sub(x, y) ((x) - (y)) + +# if defined(FPM_FLOAT) +# error "FPM_FLOAT not yet supported" + +# undef MAD_F +# define MAD_F(x) mad_f_todouble(x) + +# define mad_f_mul(x, y) ((x) * (y)) +# define mad_f_scale64 + +# elif defined(FPM_64BIT) + +/* + * This version should be the most accurate if 64-bit types are supported by + * the compiler, although it may not be the most efficient. + */ +# if defined(OPT_ACCURACY) +# define mad_f_mul(x, y) \ + ((mad_fixed_t) \ + ((((mad_fixed64_t) (x) * (y)) + \ + (1L << (MAD_F_SCALEBITS - 1))) >> MAD_F_SCALEBITS)) +# else +# define mad_f_mul(x, y) \ + ((mad_fixed_t) (((mad_fixed64_t) (x) * (y)) >> MAD_F_SCALEBITS)) +# endif + +# define MAD_F_SCALEBITS MAD_F_FRACBITS + +/* --- Intel --------------------------------------------------------------- */ + +# elif defined(FPM_INTEL) + +# if defined(_MSC_VER) +# pragma warning(push) +# pragma warning(disable: 4035) /* no return value */ +static __forceinline +mad_fixed_t mad_f_mul_inline(mad_fixed_t x, mad_fixed_t y) +{ + enum { + fracbits = MAD_F_FRACBITS + }; + + __asm { + mov eax, x + imul y + shrd eax, edx, fracbits + } + + /* implicit return of eax */ +} +# pragma warning(pop) + +# define mad_f_mul mad_f_mul_inline +# define mad_f_scale64 +# else +/* + * This Intel version is fast and accurate; the disposition of the least + * significant bit depends on OPT_ACCURACY via mad_f_scale64(). + */ +# define MAD_F_MLX(hi, lo, x, y) \ + asm ("imull %3" \ + : "=a" (lo), "=d" (hi) \ + : "%a" (x), "rm" (y) \ + : "cc") + +# if defined(OPT_ACCURACY) +/* + * This gives best accuracy but is not very fast. + */ +# define MAD_F_MLA(hi, lo, x, y) \ + ({ mad_fixed64hi_t __hi; \ + mad_fixed64lo_t __lo; \ + MAD_F_MLX(__hi, __lo, (x), (y)); \ + asm ("addl %2,%0\n\t" \ + "adcl %3,%1" \ + : "=rm" (lo), "=rm" (hi) \ + : "r" (__lo), "r" (__hi), "0" (lo), "1" (hi) \ + : "cc"); \ + }) +# endif /* OPT_ACCURACY */ + +# if defined(OPT_ACCURACY) +/* + * Surprisingly, this is faster than SHRD followed by ADC. + */ +# define mad_f_scale64(hi, lo) \ + ({ mad_fixed64hi_t __hi_; \ + mad_fixed64lo_t __lo_; \ + mad_fixed_t __result; \ + asm ("addl %4,%2\n\t" \ + "adcl %5,%3" \ + : "=rm" (__lo_), "=rm" (__hi_) \ + : "0" (lo), "1" (hi), \ + "ir" (1L << (MAD_F_SCALEBITS - 1)), "ir" (0) \ + : "cc"); \ + asm ("shrdl %3,%2,%1" \ + : "=rm" (__result) \ + : "0" (__lo_), "r" (__hi_), "I" (MAD_F_SCALEBITS) \ + : "cc"); \ + __result; \ + }) +# elif defined(OPT_INTEL) +/* + * Alternate Intel scaling that may or may not perform better. + */ +# define mad_f_scale64(hi, lo) \ + ({ mad_fixed_t __result; \ + asm ("shrl %3,%1\n\t" \ + "shll %4,%2\n\t" \ + "orl %2,%1" \ + : "=rm" (__result) \ + : "0" (lo), "r" (hi), \ + "I" (MAD_F_SCALEBITS), "I" (32 - MAD_F_SCALEBITS) \ + : "cc"); \ + __result; \ + }) +# else +# define mad_f_scale64(hi, lo) \ + ({ mad_fixed_t __result; \ + asm ("shrdl %3,%2,%1" \ + : "=rm" (__result) \ + : "0" (lo), "r" (hi), "I" (MAD_F_SCALEBITS) \ + : "cc"); \ + __result; \ + }) +# endif /* OPT_ACCURACY */ + +# define MAD_F_SCALEBITS MAD_F_FRACBITS +# endif + +/* --- ARM ----------------------------------------------------------------- */ + +# elif defined(FPM_ARM) + +/* + * This ARM V4 version is as accurate as FPM_64BIT but much faster. The + * least significant bit is properly rounded at no CPU cycle cost! + */ +# if 1 +/* + * This is faster than the default implementation via MAD_F_MLX() and + * mad_f_scale64(). + */ +# define mad_f_mul(x, y) \ + ({ mad_fixed64hi_t __hi; \ + mad_fixed64lo_t __lo; \ + mad_fixed_t __result; \ + asm ("smull %0, %1, %3, %4\n\t" \ + "movs %0, %0, lsr %5\n\t" \ + "adc %2, %0, %1, lsl %6" \ + : "=&r" (__lo), "=&r" (__hi), "=r" (__result) \ + : "%r" (x), "r" (y), \ + "M" (MAD_F_SCALEBITS), "M" (32 - MAD_F_SCALEBITS) \ + : "cc"); \ + __result; \ + }) +# endif + +# define MAD_F_MLX(hi, lo, x, y) \ + asm ("smull %0, %1, %2, %3" \ + : "=&r" (lo), "=&r" (hi) \ + : "%r" (x), "r" (y)) + +# define MAD_F_MLA(hi, lo, x, y) \ + asm ("smlal %0, %1, %2, %3" \ + : "+r" (lo), "+r" (hi) \ + : "%r" (x), "r" (y)) + +# define MAD_F_MLN(hi, lo) \ + asm ("rsbs %0, %2, #0\n\t" \ + "rsc %1, %3, #0" \ + : "=r" (lo), "=r" (hi) \ + : "0" (lo), "1" (hi) \ + : "cc") + +# define mad_f_scale64(hi, lo) \ + ({ mad_fixed_t __result; \ + asm ("movs %0, %1, lsr %3\n\t" \ + "adc %0, %0, %2, lsl %4" \ + : "=&r" (__result) \ + : "r" (lo), "r" (hi), \ + "M" (MAD_F_SCALEBITS), "M" (32 - MAD_F_SCALEBITS) \ + : "cc"); \ + __result; \ + }) + +# define MAD_F_SCALEBITS MAD_F_FRACBITS + +/* --- MIPS ---------------------------------------------------------------- */ + +# elif defined(FPM_MIPS) + +/* + * This MIPS version is fast and accurate; the disposition of the least + * significant bit depends on OPT_ACCURACY via mad_f_scale64(). + */ +# define MAD_F_MLX(hi, lo, x, y) \ + asm ("mult %2,%3" \ + : "=l" (lo), "=h" (hi) \ + : "%r" (x), "r" (y)) + +# if defined(HAVE_MADD_ASM) +# define MAD_F_MLA(hi, lo, x, y) \ + asm ("madd %2,%3" \ + : "+l" (lo), "+h" (hi) \ + : "%r" (x), "r" (y)) +# elif defined(HAVE_MADD16_ASM) +/* + * This loses significant accuracy due to the 16-bit integer limit in the + * multiply/accumulate instruction. + */ +# define MAD_F_ML0(hi, lo, x, y) \ + asm ("mult %2,%3" \ + : "=l" (lo), "=h" (hi) \ + : "%r" ((x) >> 12), "r" ((y) >> 16)) +# define MAD_F_MLA(hi, lo, x, y) \ + asm ("madd16 %2,%3" \ + : "+l" (lo), "+h" (hi) \ + : "%r" ((x) >> 12), "r" ((y) >> 16)) +# define MAD_F_MLZ(hi, lo) ((mad_fixed_t) (lo)) +# endif + +# if defined(OPT_SPEED) +# define mad_f_scale64(hi, lo) \ + ((mad_fixed_t) ((hi) << (32 - MAD_F_SCALEBITS))) +# define MAD_F_SCALEBITS MAD_F_FRACBITS +# endif + +/* --- SPARC --------------------------------------------------------------- */ + +# elif defined(FPM_SPARC) + +/* + * This SPARC V8 version is fast and accurate; the disposition of the least + * significant bit depends on OPT_ACCURACY via mad_f_scale64(). + */ +# define MAD_F_MLX(hi, lo, x, y) \ + asm ("smul %2, %3, %0\n\t" \ + "rd %%y, %1" \ + : "=r" (lo), "=r" (hi) \ + : "%r" (x), "rI" (y)) + +/* --- PowerPC ------------------------------------------------------------- */ + +# elif defined(FPM_PPC) + +/* + * This PowerPC version is fast and accurate; the disposition of the least + * significant bit depends on OPT_ACCURACY via mad_f_scale64(). + */ +# define MAD_F_MLX(hi, lo, x, y) \ + do { \ + asm ("mullw %0,%1,%2" \ + : "=r" (lo) \ + : "%r" (x), "r" (y)); \ + asm ("mulhw %0,%1,%2" \ + : "=r" (hi) \ + : "%r" (x), "r" (y)); \ + } \ + while (0) + +# if defined(OPT_ACCURACY) +/* + * This gives best accuracy but is not very fast. + */ +# define MAD_F_MLA(hi, lo, x, y) \ + ({ mad_fixed64hi_t __hi; \ + mad_fixed64lo_t __lo; \ + MAD_F_MLX(__hi, __lo, (x), (y)); \ + asm ("addc %0,%2,%3\n\t" \ + "adde %1,%4,%5" \ + : "=r" (lo), "=r" (hi) \ + : "%r" (lo), "r" (__lo), \ + "%r" (hi), "r" (__hi) \ + : "xer"); \ + }) +# endif + +# if defined(OPT_ACCURACY) +/* + * This is slower than the truncating version below it. + */ +# define mad_f_scale64(hi, lo) \ + ({ mad_fixed_t __result, __round; \ + asm ("rotrwi %0,%1,%2" \ + : "=r" (__result) \ + : "r" (lo), "i" (MAD_F_SCALEBITS)); \ + asm ("extrwi %0,%1,1,0" \ + : "=r" (__round) \ + : "r" (__result)); \ + asm ("insrwi %0,%1,%2,0" \ + : "+r" (__result) \ + : "r" (hi), "i" (MAD_F_SCALEBITS)); \ + asm ("add %0,%1,%2" \ + : "=r" (__result) \ + : "%r" (__result), "r" (__round)); \ + __result; \ + }) +# else +# define mad_f_scale64(hi, lo) \ + ({ mad_fixed_t __result; \ + asm ("rotrwi %0,%1,%2" \ + : "=r" (__result) \ + : "r" (lo), "i" (MAD_F_SCALEBITS)); \ + asm ("insrwi %0,%1,%2,0" \ + : "+r" (__result) \ + : "r" (hi), "i" (MAD_F_SCALEBITS)); \ + __result; \ + }) +# endif + +# define MAD_F_SCALEBITS MAD_F_FRACBITS + +# elif defined(FPM_COLDFIRE_EMAC) + +/* mad_f_mul using the Coldfire MCF5249 EMAC unit. Loses 3 bits of accuracy. + Note that we don't define any of the libmad accumulator macros, as + any functions that use these should have the relevant sections rewritten + in assembler to utilise the EMAC accumulators properly. + Assumes the default +/- 3.28 fixed point format + */ +#define mad_f_mul(x, y) \ +({ \ + mad_fixed64hi_t hi; \ + asm volatile("mac.l %[a], %[b], %%acc0\n\t" \ + "movclr.l %%acc0, %[hi]\n\t" \ + "asl.l #3, %[hi]" \ + : [hi] "=d" (hi) \ + : [a] "r" ((x)), [b] "r" ((y))); \ + hi; \ +}) +/* Define dummy mad_f_scale64 to prevent libmad from defining MAD_F_SCALEBITS + below. Having MAD_F_SCALEBITS defined screws up the PRESHIFT macro in synth.c + */ +#define mad_f_scale64(hi, lo) (lo) + +/* --- Default ------------------------------------------------------------- */ + +# elif defined(FPM_DEFAULT) + +/* + * This version is the most portable but it loses significant accuracy. + * Furthermore, accuracy is biased against the second argument, so care + * should be taken when ordering operands. + * + * The scale factors are constant as this is not used with SSO. + * + * Pre-rounding is required to stay within the limits of compliance. + */ +# if defined(OPT_SPEED) +# define mad_f_mul(x, y) (((x) >> 12) * ((y) >> 16)) +# else +# define mad_f_mul(x, y) ((((x) + (1L << 11)) >> 12) * \ + (((y) + (1L << 15)) >> 16)) +# endif + +/* ------------------------------------------------------------------------- */ + +# else +# error "no FPM selected" +# endif + +/* default implementations */ + +# if !defined(mad_f_mul) +# define mad_f_mul(x, y) \ + ({ register mad_fixed64hi_t __hi; \ + register mad_fixed64lo_t __lo; \ + MAD_F_MLX(__hi, __lo, (x), (y)); \ + mad_f_scale64(__hi, __lo); \ + }) +# endif + +# if !defined(MAD_F_MLA) +# define MAD_F_ML0(hi, lo, x, y) ((lo) = mad_f_mul((x), (y))) +# define MAD_F_MLA(hi, lo, x, y) ((lo) += mad_f_mul((x), (y))) +# define MAD_F_MLN(hi, lo) ((lo) = -(lo)) +# define MAD_F_MLZ(hi, lo) ((void) (hi), (mad_fixed_t) (lo)) +# endif + +# if !defined(MAD_F_ML0) +# define MAD_F_ML0(hi, lo, x, y) MAD_F_MLX((hi), (lo), (x), (y)) +# endif + +# if !defined(MAD_F_MLN) +# define MAD_F_MLN(hi, lo) ((hi) = ((lo) = -(lo)) ? ~(hi) : -(hi)) +# endif + +# if !defined(MAD_F_MLZ) +# define MAD_F_MLZ(hi, lo) mad_f_scale64((hi), (lo)) +# endif + +# if !defined(mad_f_scale64) +# if defined(OPT_ACCURACY) +# define mad_f_scale64(hi, lo) \ + ((((mad_fixed_t) \ + (((hi) << (32 - (MAD_F_SCALEBITS - 1))) | \ + ((lo) >> (MAD_F_SCALEBITS - 1)))) + 1) >> 1) +# else +# define mad_f_scale64(hi, lo) \ + ((mad_fixed_t) \ + (((hi) << (32 - MAD_F_SCALEBITS)) | \ + ((lo) >> MAD_F_SCALEBITS))) +# endif +# define MAD_F_SCALEBITS MAD_F_FRACBITS +# endif + +# endif diff --git a/lib/rbcodec/codecs/libmad/frame.c b/lib/rbcodec/codecs/libmad/frame.c new file mode 100644 index 0000000000..f17306285c --- /dev/null +++ b/lib/rbcodec/codecs/libmad/frame.c @@ -0,0 +1,499 @@ +/* + * libmad - MPEG audio decoder library + * Copyright (C) 2000-2004 Underbit Technologies, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * $Id$ + */ + +# ifdef HAVE_CONFIG_H +# include "config.h" +# endif + +# include "global.h" + +# include "bit.h" +# include "stream.h" +# include "frame.h" +# include "timer.h" +# include "layer12.h" +# include "layer3.h" +# include "codeclib.h" + +static +unsigned long const bitrate_table[5][15] = { + /* MPEG-1 */ + { 0, 32000, 64000, 96000, 128000, 160000, 192000, 224000, /* Layer I */ + 256000, 288000, 320000, 352000, 384000, 416000, 448000 }, + { 0, 32000, 48000, 56000, 64000, 80000, 96000, 112000, /* Layer II */ + 128000, 160000, 192000, 224000, 256000, 320000, 384000 }, + { 0, 32000, 40000, 48000, 56000, 64000, 80000, 96000, /* Layer III */ + 112000, 128000, 160000, 192000, 224000, 256000, 320000 }, + + /* MPEG-2 LSF */ + { 0, 32000, 48000, 56000, 64000, 80000, 96000, 112000, /* Layer I */ + 128000, 144000, 160000, 176000, 192000, 224000, 256000 }, + { 0, 8000, 16000, 24000, 32000, 40000, 48000, 56000, /* Layers */ + 64000, 80000, 96000, 112000, 128000, 144000, 160000 } /* II & III */ +}; + +static +unsigned int const samplerate_table[3] = { 44100, 48000, 32000 }; + +static +int (*const decoder_table[3])(struct mad_stream *, struct mad_frame *) = { + mad_layer_I, + mad_layer_II, + mad_layer_III +}; + +/* + * NAME: header->init() + * DESCRIPTION: initialize header struct + */ +void mad_header_init(struct mad_header *header) +{ + header->layer = 0; + header->mode = 0; + header->mode_extension = 0; + header->emphasis = 0; + + header->bitrate = 0; + header->samplerate = 0; + + header->crc_check = 0; + header->crc_target = 0; + + header->flags = 0; + header->private_bits = 0; +/* rockbox: not used + header->duration = mad_timer_zero; +*/ +} + +/* + * NAME: frame->init() + * DESCRIPTION: initialize frame struct + */ +void mad_frame_init(struct mad_frame *frame) +{ + mad_header_init(&frame->header); + + frame->options = 0; +/* rockbox: comment this to proper zero this array in mad_frame_mute(). overlap + * is linked to an array in ../mpa.c before calling this. + frame->overlap = 0; +*/ + mad_frame_mute(frame); +} + +/* + * NAME: frame->finish() + * DESCRIPTION: deallocate any dynamic memory associated with frame + */ +/* rockbox: unused +void mad_frame_finish(struct mad_frame *frame) +{ + mad_header_finish(&frame->header); + + if (frame->overlap) { + free(frame->overlap); + frame->overlap = 0; + } +} +*/ + +/* + * NAME: decode_header() + * DESCRIPTION: read header data and following CRC word + */ +static +int decode_header(struct mad_header *header, struct mad_stream *stream) +{ + unsigned int index; + + header->flags = 0; + header->private_bits = 0; + + /* header() */ + + /* syncword */ + mad_bit_skip(&stream->ptr, 11); + + /* MPEG 2.5 indicator (really part of syncword) */ + if (mad_bit_read(&stream->ptr, 1) == 0) + header->flags |= MAD_FLAG_MPEG_2_5_EXT; + + /* ID */ + if (mad_bit_read(&stream->ptr, 1) == 0) + header->flags |= MAD_FLAG_LSF_EXT; + else if (header->flags & MAD_FLAG_MPEG_2_5_EXT) { + stream->error = MAD_ERROR_LOSTSYNC; + return -1; + } + + /* layer */ + header->layer = 4 - mad_bit_read(&stream->ptr, 2); + + if (header->layer == 4) { + stream->error = MAD_ERROR_BADLAYER; + return -1; + } + + /* protection_bit */ + if (mad_bit_read(&stream->ptr, 1) == 0) { + header->flags |= MAD_FLAG_PROTECTION; + header->crc_check = mad_bit_crc(stream->ptr, 16, 0xffff); + } + + /* bitrate_index */ + index = mad_bit_read(&stream->ptr, 4); + + if (index == 15) { + stream->error = MAD_ERROR_BADBITRATE; + return -1; + } + + if (header->flags & MAD_FLAG_LSF_EXT) + header->bitrate = bitrate_table[3 + (header->layer >> 1)][index]; + else + header->bitrate = bitrate_table[header->layer - 1][index]; + + /* sampling_frequency */ + index = mad_bit_read(&stream->ptr, 2); + + if (index == 3) { + stream->error = MAD_ERROR_BADSAMPLERATE; + return -1; + } + + header->samplerate = samplerate_table[index]; + + if (header->flags & MAD_FLAG_LSF_EXT) { + header->samplerate /= 2; + + if (header->flags & MAD_FLAG_MPEG_2_5_EXT) + header->samplerate /= 2; + } + + /* padding_bit */ + if (mad_bit_read(&stream->ptr, 1)) + header->flags |= MAD_FLAG_PADDING; + + /* private_bit */ + if (mad_bit_read(&stream->ptr, 1)) + header->private_bits |= MAD_PRIVATE_HEADER; + + /* mode */ + header->mode = 3 - mad_bit_read(&stream->ptr, 2); + + /* mode_extension */ + header->mode_extension = mad_bit_read(&stream->ptr, 2); + + /* copyright */ + if (mad_bit_read(&stream->ptr, 1)) + header->flags |= MAD_FLAG_COPYRIGHT; + + /* original/copy */ + if (mad_bit_read(&stream->ptr, 1)) + header->flags |= MAD_FLAG_ORIGINAL; + + /* emphasis */ + header->emphasis = mad_bit_read(&stream->ptr, 2); + +# if defined(OPT_STRICT) + /* + * ISO/IEC 11172-3 says this is a reserved emphasis value, but + * streams exist which use it anyway. Since the value is not important + * to the decoder proper, we allow it unless OPT_STRICT is defined. + */ + if (header->emphasis == MAD_EMPHASIS_RESERVED) { + stream->error = MAD_ERROR_BADEMPHASIS; + return -1; + } +# endif + + /* error_check() */ + + /* crc_check */ + if (header->flags & MAD_FLAG_PROTECTION) + header->crc_target = mad_bit_read(&stream->ptr, 16); + + return 0; +} + +/* + * NAME: free_bitrate() + * DESCRIPTION: attempt to discover the bitstream's free bitrate + */ +static +int free_bitrate(struct mad_stream *stream, struct mad_header const *header) +{ + struct mad_bitptr keep_ptr; + unsigned long rate = 0; + unsigned int pad_slot, slots_per_frame; + unsigned char const *ptr = 0; + + keep_ptr = stream->ptr; + + pad_slot = (header->flags & MAD_FLAG_PADDING) ? 1 : 0; + slots_per_frame = (header->layer == MAD_LAYER_III && + (header->flags & MAD_FLAG_LSF_EXT)) ? 72 : 144; + + while (mad_stream_sync(stream) == 0) { + struct mad_stream peek_stream; + struct mad_header peek_header; + + peek_stream = *stream; + peek_header = *header; + + if (decode_header(&peek_header, &peek_stream) == 0 && + peek_header.layer == header->layer && + peek_header.samplerate == header->samplerate) { + unsigned int N; + + ptr = mad_bit_nextbyte(&stream->ptr); + + N = ptr - stream->this_frame; + + if (header->layer == MAD_LAYER_I) { + rate = (unsigned long) header->samplerate * + (N - 4 * pad_slot + 4) / 48 / 1000; + } + else { + rate = (unsigned long) header->samplerate * + (N - pad_slot + 1) / slots_per_frame / 1000; + } + + if (rate >= 8) + break; + } + + mad_bit_skip(&stream->ptr, 8); + } + + stream->ptr = keep_ptr; + + if (rate < 8 || (header->layer == MAD_LAYER_III && rate > 640)) { + stream->error = MAD_ERROR_LOSTSYNC; + return -1; + } + + stream->freerate = rate * 1000; + + return 0; +} + +/* + * NAME: header->decode() + * DESCRIPTION: read the next frame header from the stream + */ +int mad_header_decode(struct mad_header *header, struct mad_stream *stream) +{ + register unsigned char const *ptr, *end; + unsigned int pad_slot, N; + + ptr = stream->next_frame; + end = stream->bufend; + + if (ptr == 0) { + stream->error = MAD_ERROR_BUFPTR; + goto fail; + } + + /* stream skip */ + /* rockbox: not used + if (stream->skiplen) { + if (!stream->sync) + ptr = stream->this_frame; + + if (end - ptr < (long) stream->skiplen) { + stream->skiplen -= end - ptr; + stream->next_frame = end; + + stream->error = MAD_ERROR_BUFLEN; + goto fail; + } + + ptr += stream->skiplen; + stream->skiplen = 0; + + stream->sync = 1; + } + */ + + sync: + /* synchronize */ + if (stream->sync) { + if (end - ptr < MAD_BUFFER_GUARD) { + stream->next_frame = ptr; + + stream->error = MAD_ERROR_BUFLEN; + goto fail; + } + else if (!(ptr[0] == 0xff && (ptr[1] & 0xe0) == 0xe0)) { + /* mark point where frame sync word was expected */ + stream->this_frame = ptr; + stream->next_frame = ptr + 1; + + stream->error = MAD_ERROR_LOSTSYNC; + goto fail; + } + } + else { + mad_bit_init(&stream->ptr, ptr); + + if (mad_stream_sync(stream) == -1) { + if (end - stream->next_frame >= MAD_BUFFER_GUARD) + stream->next_frame = end - MAD_BUFFER_GUARD; + + stream->error = MAD_ERROR_BUFLEN; + goto fail; + } + + ptr = mad_bit_nextbyte(&stream->ptr); + } + + /* begin processing */ + stream->this_frame = ptr; + stream->next_frame = ptr + 1; /* possibly bogus sync word */ + + mad_bit_init(&stream->ptr, stream->this_frame); + + if (decode_header(header, stream) == -1) + goto fail; + + /* calculate frame duration */ + /* rockbox: not used + mad_timer_set(&header->duration, 0, + 32 * MAD_NSBSAMPLES(header), header->samplerate); + */ + + /* calculate free bit rate */ + if (header->bitrate == 0) { + if ((stream->freerate == 0 || !stream->sync || + (header->layer == MAD_LAYER_III && stream->freerate > 640000)) && + free_bitrate(stream, header) == -1) + goto fail; + + header->bitrate = stream->freerate; + header->flags |= MAD_FLAG_FREEFORMAT; + } + + /* calculate beginning of next frame */ + pad_slot = (header->flags & MAD_FLAG_PADDING) ? 1 : 0; + + if (header->layer == MAD_LAYER_I) + N = ((12 * header->bitrate / header->samplerate) + pad_slot) * 4; + else { + unsigned int slots_per_frame; + + slots_per_frame = (header->layer == MAD_LAYER_III && + (header->flags & MAD_FLAG_LSF_EXT)) ? 72 : 144; + + N = (slots_per_frame * header->bitrate / header->samplerate) + pad_slot; + } + + /* verify there is enough data left in buffer to decode this frame */ + if ((long)(N + MAD_BUFFER_GUARD) > end - stream->this_frame) { + stream->next_frame = stream->this_frame; + + stream->error = MAD_ERROR_BUFLEN; + goto fail; + } + + stream->next_frame = stream->this_frame + N; + + if (!stream->sync) { + /* check that a valid frame header follows this frame */ + + ptr = stream->next_frame; + if (!(ptr[0] == 0xff && (ptr[1] & 0xe0) == 0xe0)) { + ptr = stream->next_frame = stream->this_frame + 1; + goto sync; + } + + stream->sync = 1; + } + + header->flags |= MAD_FLAG_INCOMPLETE; + + return 0; + + fail: + stream->sync = 0; + + return -1; +} + +/* + * NAME: frame->decode() + * DESCRIPTION: decode a single frame from a bitstream + */ +int mad_frame_decode(struct mad_frame *frame, struct mad_stream *stream) +{ + frame->options = stream->options; + + /* header() */ + /* error_check() */ + + if (!(frame->header.flags & MAD_FLAG_INCOMPLETE) && + mad_header_decode(&frame->header, stream) == -1) + goto fail; + + /* audio_data() */ + + frame->header.flags &= ~MAD_FLAG_INCOMPLETE; + + if (decoder_table[frame->header.layer - 1](stream, frame) == -1) { + if (!MAD_RECOVERABLE(stream->error)) + stream->next_frame = stream->this_frame; + + goto fail; + } + + /* ancillary_data() */ + + if (frame->header.layer != MAD_LAYER_III) { + struct mad_bitptr next_frame; + + mad_bit_init(&next_frame, stream->next_frame); + + stream->anc_ptr = stream->ptr; + stream->anc_bitlen = mad_bit_length(&stream->ptr, &next_frame); + + mad_bit_finish(&next_frame); + } + + + + return 0; + + fail: + stream->anc_bitlen = 0; + return -1; +} + +/* + * NAME: frame->mute() + * DESCRIPTION: zero all subband values so the frame becomes silent + */ +void mad_frame_mute(struct mad_frame *frame) +{ + memset((*frame->sbsample_prev), 0, sizeof(*frame->sbsample_prev)); + memset((*frame->sbsample) , 0, sizeof(*frame->sbsample)); + memset((*frame->overlap) , 0, sizeof(*frame->overlap)); +} diff --git a/lib/rbcodec/codecs/libmad/frame.h b/lib/rbcodec/codecs/libmad/frame.h new file mode 100644 index 0000000000..b1c6e0289d --- /dev/null +++ b/lib/rbcodec/codecs/libmad/frame.h @@ -0,0 +1,124 @@ +/* + * libmad - MPEG audio decoder library + * Copyright (C) 2000-2004 Underbit Technologies, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * $Id$ + */ + +# ifndef LIBMAD_FRAME_H +# define LIBMAD_FRAME_H + +# include "fixed.h" +# include "timer.h" +# include "stream.h" + +enum mad_layer { + MAD_LAYER_I = 1, /* Layer I */ + MAD_LAYER_II = 2, /* Layer II */ + MAD_LAYER_III = 3 /* Layer III */ +}; + +enum mad_mode { + MAD_MODE_SINGLE_CHANNEL = 0, /* single channel */ + MAD_MODE_DUAL_CHANNEL = 1, /* dual channel */ + MAD_MODE_JOINT_STEREO = 2, /* joint (MS/intensity) stereo */ + MAD_MODE_STEREO = 3 /* normal LR stereo */ +}; + +enum mad_emphasis { + MAD_EMPHASIS_NONE = 0, /* no emphasis */ + MAD_EMPHASIS_50_15_US = 1, /* 50/15 microseconds emphasis */ + MAD_EMPHASIS_CCITT_J_17 = 3, /* CCITT J.17 emphasis */ + MAD_EMPHASIS_RESERVED = 2 /* unknown emphasis */ +}; + +struct mad_header { + enum mad_layer layer; /* audio layer (1, 2, or 3) */ + enum mad_mode mode; /* channel mode (see above) */ + int mode_extension; /* additional mode info */ + enum mad_emphasis emphasis; /* de-emphasis to use (see above) */ + + unsigned long bitrate; /* stream bitrate (bps) */ + unsigned int samplerate; /* sampling frequency (Hz) */ + + unsigned short crc_check; /* frame CRC accumulator */ + unsigned short crc_target; /* final target CRC checksum */ + + int flags; /* flags (see below) */ + int private_bits; /* private bits (see below) */ + +#if 0 /* rockbox: not used */ + mad_timer_t duration; /* audio playing time of frame */ +#endif +}; + +struct mad_frame { + struct mad_header header; /* MPEG audio header */ + int options; /* decoding options (from stream) */ + + mad_fixed_t (*sbsample)[2][36][32] MEM_ALIGN_ATTR; /* synthesis subband filter samples */ + mad_fixed_t (*sbsample_prev)[2][36][32] MEM_ALIGN_ATTR; /* synthesis subband filter samples + from previous frame only needed + when synthesis is on cop */ + + mad_fixed_t (*overlap)[2][32][18] MEM_ALIGN_ATTR; /* Layer III block overlap data */ +}; + +# define MAD_NCHANNELS(header) ((header)->mode ? 2 : 1) +# define MAD_NSBSAMPLES(header) \ + ((header)->layer == MAD_LAYER_I ? 12 : \ + (((header)->layer == MAD_LAYER_III && \ + ((header)->flags & MAD_FLAG_LSF_EXT)) ? 18 : 36)) + +enum { + MAD_FLAG_NPRIVATE_III = 0x0007, /* number of Layer III private bits */ + MAD_FLAG_INCOMPLETE = 0x0008, /* header but not data is decoded */ + + MAD_FLAG_PROTECTION = 0x0010, /* frame has CRC protection */ + MAD_FLAG_COPYRIGHT = 0x0020, /* frame is copyright */ + MAD_FLAG_ORIGINAL = 0x0040, /* frame is original (else copy) */ + MAD_FLAG_PADDING = 0x0080, /* frame has additional slot */ + + MAD_FLAG_I_STEREO = 0x0100, /* uses intensity joint stereo */ + MAD_FLAG_MS_STEREO = 0x0200, /* uses middle/side joint stereo */ + MAD_FLAG_FREEFORMAT = 0x0400, /* uses free format bitrate */ + + MAD_FLAG_LSF_EXT = 0x1000, /* lower sampling freq. extension */ + MAD_FLAG_MC_EXT = 0x2000, /* multichannel audio extension */ + MAD_FLAG_MPEG_2_5_EXT = 0x4000 /* MPEG 2.5 (unofficial) extension */ +}; + +enum { + MAD_PRIVATE_HEADER = 0x0100, /* header private bit */ + MAD_PRIVATE_III = 0x001f /* Layer III private bits (up to 5) */ +}; + +void mad_header_init(struct mad_header *); + +# define mad_header_finish(header) /* nothing */ + +int mad_header_decode(struct mad_header *, struct mad_stream *); + +void mad_frame_init(struct mad_frame *); +/* rockbox: not used +void mad_frame_finish(struct mad_frame *);*/ + +int mad_frame_decode(struct mad_frame *, struct mad_stream *); + +void mad_frame_mute(struct mad_frame *); + +# endif diff --git a/lib/rbcodec/codecs/libmad/global.h b/lib/rbcodec/codecs/libmad/global.h new file mode 100644 index 0000000000..50051f45b3 --- /dev/null +++ b/lib/rbcodec/codecs/libmad/global.h @@ -0,0 +1,72 @@ +/* + * libmad - MPEG audio decoder library + * Copyright (C) 2000-2004 Underbit Technologies, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * $Id$ + */ + +#include "codeclib.h" + +# ifndef LIBMAD_GLOBAL_H +# define LIBMAD_GLOBAL_H + +#include "mad_iram.h" + +#if defined(CPU_COLDFIRE) +#define FPM_COLDFIRE_EMAC +#elif defined(CPU_ARM) +#define FPM_ARM +#elif defined(CPU_MIPS) +#define FPM_MIPS +#else +#define FPM_DEFAULT +#endif + +/* conditional debugging */ + +# if defined(DEBUG) && defined(NDEBUG) +# error "cannot define both DEBUG and NDEBUG" +# endif + +# if defined(DEBUG) +# include +# endif + +/* conditional features */ + +# if defined(OPT_SPEED) && defined(OPT_ACCURACY) +# error "cannot optimize for both speed and accuracy" +# endif + +# if defined(OPT_SPEED) && !defined(OPT_SSO) +# define OPT_SSO +# endif + +# if defined(HAVE_UNISTD_H) && defined(HAVE_WAITPID) && \ + defined(HAVE_FCNTL) && defined(HAVE_PIPE) && defined(HAVE_FORK) +# define USE_ASYNC +# endif + +# if !defined(HAVE_ASSERT_H) +# if defined(NDEBUG) +# define assert(x) /* nothing */ +# else +# define assert(x) do { if (!(x)) abort(); } while (0) +# endif +# endif + +# endif diff --git a/lib/rbcodec/codecs/libmad/huffman.c b/lib/rbcodec/codecs/libmad/huffman.c new file mode 100644 index 0000000000..bec44434a7 --- /dev/null +++ b/lib/rbcodec/codecs/libmad/huffman.c @@ -0,0 +1,3109 @@ +/* + * libmad - MPEG audio decoder library + * Copyright (C) 2000-2004 Underbit Technologies, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * $Id$ + */ + +# ifdef HAVE_CONFIG_H +# include "config.h" +# endif + +# include "global.h" + +# include "huffman.h" + +/* + * These are the Huffman code words for Layer III. + * The data for these tables are derived from Table B.7 of ISO/IEC 11172-3. + * + * These tables support decoding up to 4 Huffman code bits at a time. + */ + +# if defined(__GNUC__) || \ + (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901) +# define PTR(offs, bits) { .ptr = { 0, bits, offs } } +# define V(v, w, x, y, hlen) { .value = { 1, hlen, v, w, x, y } } +# else +# define PTR(offs, bits) { { 0, bits, offs } } +# if defined(WORDS_BIGENDIAN) +# define V(v, w, x, y, hlen) { { 1, hlen, (v << 11) | (w << 10) | \ + (x << 9) | (y << 8) } } +# else +# define V(v, w, x, y, hlen) { { 1, hlen, (v << 0) | (w << 1) | \ + (x << 2) | (y << 3) } } +# endif +# endif + +static +union huffquad const hufftabA[] ICONST_ATTR_MPA_HUFFMAN = { + /* 0000 */ PTR(16, 2), + /* 0001 */ PTR(20, 2), + /* 0010 */ PTR(24, 1), + /* 0011 */ PTR(26, 1), + /* 0100 */ V(0, 0, 1, 0, 4), + /* 0101 */ V(0, 0, 0, 1, 4), + /* 0110 */ V(0, 1, 0, 0, 4), + /* 0111 */ V(1, 0, 0, 0, 4), + /* 1000 */ V(0, 0, 0, 0, 1), + /* 1001 */ V(0, 0, 0, 0, 1), + /* 1010 */ V(0, 0, 0, 0, 1), + /* 1011 */ V(0, 0, 0, 0, 1), + /* 1100 */ V(0, 0, 0, 0, 1), + /* 1101 */ V(0, 0, 0, 0, 1), + /* 1110 */ V(0, 0, 0, 0, 1), + /* 1111 */ V(0, 0, 0, 0, 1), + + /* 0000 ... */ + /* 00 */ V(1, 0, 1, 1, 2), /* 16 */ + /* 01 */ V(1, 1, 1, 1, 2), + /* 10 */ V(1, 1, 0, 1, 2), + /* 11 */ V(1, 1, 1, 0, 2), + + /* 0001 ... */ + /* 00 */ V(0, 1, 1, 1, 2), /* 20 */ + /* 01 */ V(0, 1, 0, 1, 2), + /* 10 */ V(1, 0, 0, 1, 1), + /* 11 */ V(1, 0, 0, 1, 1), + + /* 0010 ... */ + /* 0 */ V(0, 1, 1, 0, 1), /* 24 */ + /* 1 */ V(0, 0, 1, 1, 1), + + /* 0011 ... */ + /* 0 */ V(1, 0, 1, 0, 1), /* 26 */ + /* 1 */ V(1, 1, 0, 0, 1) +}; + +static +union huffquad const hufftabB[] ICONST_ATTR_MPA_HUFFMAN = { + /* 0000 */ V(1, 1, 1, 1, 4), + /* 0001 */ V(1, 1, 1, 0, 4), + /* 0010 */ V(1, 1, 0, 1, 4), + /* 0011 */ V(1, 1, 0, 0, 4), + /* 0100 */ V(1, 0, 1, 1, 4), + /* 0101 */ V(1, 0, 1, 0, 4), + /* 0110 */ V(1, 0, 0, 1, 4), + /* 0111 */ V(1, 0, 0, 0, 4), + /* 1000 */ V(0, 1, 1, 1, 4), + /* 1001 */ V(0, 1, 1, 0, 4), + /* 1010 */ V(0, 1, 0, 1, 4), + /* 1011 */ V(0, 1, 0, 0, 4), + /* 1100 */ V(0, 0, 1, 1, 4), + /* 1101 */ V(0, 0, 1, 0, 4), + /* 1110 */ V(0, 0, 0, 1, 4), + /* 1111 */ V(0, 0, 0, 0, 4) +}; + +# undef V +# undef PTR + +# if defined(__GNUC__) || \ + (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901) +# define PTR(offs, bits) { .ptr = { 0, bits, offs } } +# define V(x, y, hlen) { .value = { 1, hlen, x, y } } +# else +# define PTR(offs, bits) { { 0, bits, offs } } +# if defined(WORDS_BIGENDIAN) +# define V(x, y, hlen) { { 1, hlen, (x << 8) | (y << 4) } } +# else +# define V(x, y, hlen) { { 1, hlen, (x << 0) | (y << 4) } } +# endif +# endif + +static +union huffpair const hufftab0[] ICONST_ATTR_MPA_HUFFMAN = { + /* */ V(0, 0, 0) +}; + +static +union huffpair const hufftab1[] ICONST_ATTR_MPA_HUFFMAN = { + /* 000 */ V(1, 1, 3), + /* 001 */ V(0, 1, 3), + /* 010 */ V(1, 0, 2), + /* 011 */ V(1, 0, 2), + /* 100 */ V(0, 0, 1), + /* 101 */ V(0, 0, 1), + /* 110 */ V(0, 0, 1), + /* 111 */ V(0, 0, 1) +}; + +static +union huffpair const hufftab2[] ICONST_ATTR_MPA_HUFFMAN = { + /* 000 */ PTR(8, 3), + /* 001 */ V(1, 1, 3), + /* 010 */ V(0, 1, 3), + /* 011 */ V(1, 0, 3), + /* 100 */ V(0, 0, 1), + /* 101 */ V(0, 0, 1), + /* 110 */ V(0, 0, 1), + /* 111 */ V(0, 0, 1), + + /* 000 ... */ + /* 000 */ V(2, 2, 3), /* 8 */ + /* 001 */ V(0, 2, 3), + /* 010 */ V(1, 2, 2), + /* 011 */ V(1, 2, 2), + /* 100 */ V(2, 1, 2), + /* 101 */ V(2, 1, 2), + /* 110 */ V(2, 0, 2), + /* 111 */ V(2, 0, 2) +}; + +static +union huffpair const hufftab3[] ICONST_ATTR_MPA_HUFFMAN = { + /* 000 */ PTR(8, 3), + /* 001 */ V(1, 0, 3), + /* 010 */ V(1, 1, 2), + /* 011 */ V(1, 1, 2), + /* 100 */ V(0, 1, 2), + /* 101 */ V(0, 1, 2), + /* 110 */ V(0, 0, 2), + /* 111 */ V(0, 0, 2), + + /* 000 ... */ + /* 000 */ V(2, 2, 3), /* 8 */ + /* 001 */ V(0, 2, 3), + /* 010 */ V(1, 2, 2), + /* 011 */ V(1, 2, 2), + /* 100 */ V(2, 1, 2), + /* 101 */ V(2, 1, 2), + /* 110 */ V(2, 0, 2), + /* 111 */ V(2, 0, 2) +}; + +static +union huffpair const hufftab5[] ICONST_ATTR_MPA_HUFFMAN = { + /* 000 */ PTR(8, 4), + /* 001 */ V(1, 1, 3), + /* 010 */ V(0, 1, 3), + /* 011 */ V(1, 0, 3), + /* 100 */ V(0, 0, 1), + /* 101 */ V(0, 0, 1), + /* 110 */ V(0, 0, 1), + /* 111 */ V(0, 0, 1), + + /* 000 ... */ + /* 0000 */ PTR(24, 1), /* 8 */ + /* 0001 */ V(3, 2, 4), + /* 0010 */ V(3, 1, 3), + /* 0011 */ V(3, 1, 3), + /* 0100 */ V(1, 3, 4), + /* 0101 */ V(0, 3, 4), + /* 0110 */ V(3, 0, 4), + /* 0111 */ V(2, 2, 4), + /* 1000 */ V(1, 2, 3), + /* 1001 */ V(1, 2, 3), + /* 1010 */ V(2, 1, 3), + /* 1011 */ V(2, 1, 3), + /* 1100 */ V(0, 2, 3), + /* 1101 */ V(0, 2, 3), + /* 1110 */ V(2, 0, 3), + /* 1111 */ V(2, 0, 3), + + /* 000 0000 ... */ + /* 0 */ V(3, 3, 1), /* 24 */ + /* 1 */ V(2, 3, 1) +}; + +static +union huffpair const hufftab6[] ICONST_ATTR_MPA_HUFFMAN = { + /* 0000 */ PTR(16, 3), + /* 0001 */ PTR(24, 1), + /* 0010 */ PTR(26, 1), + /* 0011 */ V(1, 2, 4), + /* 0100 */ V(2, 1, 4), + /* 0101 */ V(2, 0, 4), + /* 0110 */ V(0, 1, 3), + /* 0111 */ V(0, 1, 3), + /* 1000 */ V(1, 1, 2), + /* 1001 */ V(1, 1, 2), + /* 1010 */ V(1, 1, 2), + /* 1011 */ V(1, 1, 2), + /* 1100 */ V(1, 0, 3), + /* 1101 */ V(1, 0, 3), + /* 1110 */ V(0, 0, 3), + /* 1111 */ V(0, 0, 3), + + /* 0000 ... */ + /* 000 */ V(3, 3, 3), /* 16 */ + /* 001 */ V(0, 3, 3), + /* 010 */ V(2, 3, 2), + /* 011 */ V(2, 3, 2), + /* 100 */ V(3, 2, 2), + /* 101 */ V(3, 2, 2), + /* 110 */ V(3, 0, 2), + /* 111 */ V(3, 0, 2), + + /* 0001 ... */ + /* 0 */ V(1, 3, 1), /* 24 */ + /* 1 */ V(3, 1, 1), + + /* 0010 ... */ + /* 0 */ V(2, 2, 1), /* 26 */ + /* 1 */ V(0, 2, 1) +}; + +static +union huffpair const hufftab7[] ICONST_ATTR_MPA_HUFFMAN = { + /* 0000 */ PTR(16, 4), + /* 0001 */ PTR(32, 4), + /* 0010 */ PTR(48, 2), + /* 0011 */ V(1, 1, 4), + /* 0100 */ V(0, 1, 3), + /* 0101 */ V(0, 1, 3), + /* 0110 */ V(1, 0, 3), + /* 0111 */ V(1, 0, 3), + /* 1000 */ V(0, 0, 1), + /* 1001 */ V(0, 0, 1), + /* 1010 */ V(0, 0, 1), + /* 1011 */ V(0, 0, 1), + /* 1100 */ V(0, 0, 1), + /* 1101 */ V(0, 0, 1), + /* 1110 */ V(0, 0, 1), + /* 1111 */ V(0, 0, 1), + + /* 0000 ... */ + /* 0000 */ PTR(52, 2), /* 16 */ + /* 0001 */ PTR(56, 1), + /* 0010 */ PTR(58, 1), + /* 0011 */ V(1, 5, 4), + /* 0100 */ V(5, 1, 4), + /* 0101 */ PTR(60, 1), + /* 0110 */ V(5, 0, 4), + /* 0111 */ PTR(62, 1), + /* 1000 */ V(2, 4, 4), + /* 1001 */ V(4, 2, 4), + /* 1010 */ V(1, 4, 3), + /* 1011 */ V(1, 4, 3), + /* 1100 */ V(4, 1, 3), + /* 1101 */ V(4, 1, 3), + /* 1110 */ V(4, 0, 3), + /* 1111 */ V(4, 0, 3), + + /* 0001 ... */ + /* 0000 */ V(0, 4, 4), /* 32 */ + /* 0001 */ V(2, 3, 4), + /* 0010 */ V(3, 2, 4), + /* 0011 */ V(0, 3, 4), + /* 0100 */ V(1, 3, 3), + /* 0101 */ V(1, 3, 3), + /* 0110 */ V(3, 1, 3), + /* 0111 */ V(3, 1, 3), + /* 1000 */ V(3, 0, 3), + /* 1001 */ V(3, 0, 3), + /* 1010 */ V(2, 2, 3), + /* 1011 */ V(2, 2, 3), + /* 1100 */ V(1, 2, 2), + /* 1101 */ V(1, 2, 2), + /* 1110 */ V(1, 2, 2), + /* 1111 */ V(1, 2, 2), + + /* 0010 ... */ + /* 00 */ V(2, 1, 1), /* 48 */ + /* 01 */ V(2, 1, 1), + /* 10 */ V(0, 2, 2), + /* 11 */ V(2, 0, 2), + + /* 0000 0000 ... */ + /* 00 */ V(5, 5, 2), /* 52 */ + /* 01 */ V(4, 5, 2), + /* 10 */ V(5, 4, 2), + /* 11 */ V(5, 3, 2), + + /* 0000 0001 ... */ + /* 0 */ V(3, 5, 1), /* 56 */ + /* 1 */ V(4, 4, 1), + + /* 0000 0010 ... */ + /* 0 */ V(2, 5, 1), /* 58 */ + /* 1 */ V(5, 2, 1), + + /* 0000 0101 ... */ + /* 0 */ V(0, 5, 1), /* 60 */ + /* 1 */ V(3, 4, 1), + + /* 0000 0111 ... */ + /* 0 */ V(4, 3, 1), /* 62 */ + /* 1 */ V(3, 3, 1) +}; + +# if 0 +/* this version saves 8 entries (16 bytes) at the expense of + an extra lookup in 4 out of 36 cases */ +static +union huffpair const hufftab8[] ICONST_ATTR_MPA_HUFFMAN = { + /* 0000 */ PTR(16, 4), + /* 0001 */ PTR(32, 2), + /* 0010 */ V(1, 2, 4), + /* 0011 */ V(2, 1, 4), + /* 0100 */ V(1, 1, 2), + /* 0101 */ V(1, 1, 2), + /* 0110 */ V(1, 1, 2), + /* 0111 */ V(1, 1, 2), + /* 1000 */ V(0, 1, 3), + /* 1001 */ V(0, 1, 3), + /* 1010 */ V(1, 0, 3), + /* 1011 */ V(1, 0, 3), + /* 1100 */ V(0, 0, 2), + /* 1101 */ V(0, 0, 2), + /* 1110 */ V(0, 0, 2), + /* 1111 */ V(0, 0, 2), + + /* 0000 ... */ + /* 0000 */ PTR(36, 3), /* 16 */ + /* 0001 */ PTR(44, 2), + /* 0010 */ PTR(48, 1), + /* 0011 */ V(1, 5, 4), + /* 0100 */ V(5, 1, 4), + /* 0101 */ PTR(50, 1), + /* 0110 */ PTR(52, 1), + /* 0111 */ V(2, 4, 4), + /* 1000 */ V(4, 2, 4), + /* 1001 */ V(1, 4, 4), + /* 1010 */ V(4, 1, 3), + /* 1011 */ V(4, 1, 3), + /* 1100 */ V(0, 4, 4), + /* 1101 */ V(4, 0, 4), + /* 1110 */ V(2, 3, 4), + /* 1111 */ V(3, 2, 4), + + /* 0001 ... */ + /* 00 */ PTR(54, 2), /* 32 */ + /* 01 */ V(2, 2, 2), + /* 10 */ V(0, 2, 2), + /* 11 */ V(2, 0, 2), + + /* 0000 0000 ... */ + /* 000 */ V(5, 5, 3), /* 36 */ + /* 001 */ V(5, 4, 3), + /* 010 */ V(4, 5, 2), + /* 011 */ V(4, 5, 2), + /* 100 */ V(5, 3, 1), + /* 101 */ V(5, 3, 1), + /* 110 */ V(5, 3, 1), + /* 111 */ V(5, 3, 1), + + /* 0000 0001 ... */ + /* 00 */ V(3, 5, 2), /* 44 */ + /* 01 */ V(4, 4, 2), + /* 10 */ V(2, 5, 1), + /* 11 */ V(2, 5, 1), + + /* 0000 0010 ... */ + /* 0 */ V(5, 2, 1), /* 48 */ + /* 1 */ V(0, 5, 1), + + /* 0000 0101 ... */ + /* 0 */ V(3, 4, 1), /* 50 */ + /* 1 */ V(4, 3, 1), + + /* 0000 0110 ... */ + /* 0 */ V(5, 0, 1), /* 52 */ + /* 1 */ V(3, 3, 1), + + /* 0001 00 ... */ + /* 00 */ V(1, 3, 2), /* 54 */ + /* 01 */ V(3, 1, 2), + /* 10 */ V(0, 3, 2), + /* 11 */ V(3, 0, 2), +}; +# else +static +union huffpair const hufftab8[] ICONST_ATTR_MPA_HUFFMAN = { + /* 0000 */ PTR(16, 4), + /* 0001 */ PTR(32, 4), + /* 0010 */ V(1, 2, 4), + /* 0011 */ V(2, 1, 4), + /* 0100 */ V(1, 1, 2), + /* 0101 */ V(1, 1, 2), + /* 0110 */ V(1, 1, 2), + /* 0111 */ V(1, 1, 2), + /* 1000 */ V(0, 1, 3), + /* 1001 */ V(0, 1, 3), + /* 1010 */ V(1, 0, 3), + /* 1011 */ V(1, 0, 3), + /* 1100 */ V(0, 0, 2), + /* 1101 */ V(0, 0, 2), + /* 1110 */ V(0, 0, 2), + /* 1111 */ V(0, 0, 2), + + /* 0000 ... */ + /* 0000 */ PTR(48, 3), /* 16 */ + /* 0001 */ PTR(56, 2), + /* 0010 */ PTR(60, 1), + /* 0011 */ V(1, 5, 4), + /* 0100 */ V(5, 1, 4), + /* 0101 */ PTR(62, 1), + /* 0110 */ PTR(64, 1), + /* 0111 */ V(2, 4, 4), + /* 1000 */ V(4, 2, 4), + /* 1001 */ V(1, 4, 4), + /* 1010 */ V(4, 1, 3), + /* 1011 */ V(4, 1, 3), + /* 1100 */ V(0, 4, 4), + /* 1101 */ V(4, 0, 4), + /* 1110 */ V(2, 3, 4), + /* 1111 */ V(3, 2, 4), + + /* 0001 ... */ + /* 0000 */ V(1, 3, 4), /* 32 */ + /* 0001 */ V(3, 1, 4), + /* 0010 */ V(0, 3, 4), + /* 0011 */ V(3, 0, 4), + /* 0100 */ V(2, 2, 2), + /* 0101 */ V(2, 2, 2), + /* 0110 */ V(2, 2, 2), + /* 0111 */ V(2, 2, 2), + /* 1000 */ V(0, 2, 2), + /* 1001 */ V(0, 2, 2), + /* 1010 */ V(0, 2, 2), + /* 1011 */ V(0, 2, 2), + /* 1100 */ V(2, 0, 2), + /* 1101 */ V(2, 0, 2), + /* 1110 */ V(2, 0, 2), + /* 1111 */ V(2, 0, 2), + + /* 0000 0000 ... */ + /* 000 */ V(5, 5, 3), /* 48 */ + /* 001 */ V(5, 4, 3), + /* 010 */ V(4, 5, 2), + /* 011 */ V(4, 5, 2), + /* 100 */ V(5, 3, 1), + /* 101 */ V(5, 3, 1), + /* 110 */ V(5, 3, 1), + /* 111 */ V(5, 3, 1), + + /* 0000 0001 ... */ + /* 00 */ V(3, 5, 2), /* 56 */ + /* 01 */ V(4, 4, 2), + /* 10 */ V(2, 5, 1), + /* 11 */ V(2, 5, 1), + + /* 0000 0010 ... */ + /* 0 */ V(5, 2, 1), /* 60 */ + /* 1 */ V(0, 5, 1), + + /* 0000 0101 ... */ + /* 0 */ V(3, 4, 1), /* 62 */ + /* 1 */ V(4, 3, 1), + + /* 0000 0110 ... */ + /* 0 */ V(5, 0, 1), /* 64 */ + /* 1 */ V(3, 3, 1) +}; +# endif + +static +union huffpair const hufftab9[] ICONST_ATTR_MPA_HUFFMAN = { + /* 0000 */ PTR(16, 4), + /* 0001 */ PTR(32, 3), + /* 0010 */ PTR(40, 2), + /* 0011 */ PTR(44, 2), + /* 0100 */ PTR(48, 1), + /* 0101 */ V(1, 2, 4), + /* 0110 */ V(2, 1, 4), + /* 0111 */ V(2, 0, 4), + /* 1000 */ V(1, 1, 3), + /* 1001 */ V(1, 1, 3), + /* 1010 */ V(0, 1, 3), + /* 1011 */ V(0, 1, 3), + /* 1100 */ V(1, 0, 3), + /* 1101 */ V(1, 0, 3), + /* 1110 */ V(0, 0, 3), + /* 1111 */ V(0, 0, 3), + + /* 0000 ... */ + /* 0000 */ PTR(50, 1), /* 16 */ + /* 0001 */ V(3, 5, 4), + /* 0010 */ V(5, 3, 4), + /* 0011 */ PTR(52, 1), + /* 0100 */ V(4, 4, 4), + /* 0101 */ V(2, 5, 4), + /* 0110 */ V(5, 2, 4), + /* 0111 */ V(1, 5, 4), + /* 1000 */ V(5, 1, 3), + /* 1001 */ V(5, 1, 3), + /* 1010 */ V(3, 4, 3), + /* 1011 */ V(3, 4, 3), + /* 1100 */ V(4, 3, 3), + /* 1101 */ V(4, 3, 3), + /* 1110 */ V(5, 0, 4), + /* 1111 */ V(0, 4, 4), + + /* 0001 ... */ + /* 000 */ V(2, 4, 3), /* 32 */ + /* 001 */ V(4, 2, 3), + /* 010 */ V(3, 3, 3), + /* 011 */ V(4, 0, 3), + /* 100 */ V(1, 4, 2), + /* 101 */ V(1, 4, 2), + /* 110 */ V(4, 1, 2), + /* 111 */ V(4, 1, 2), + + /* 0010 ... */ + /* 00 */ V(2, 3, 2), /* 40 */ + /* 01 */ V(3, 2, 2), + /* 10 */ V(1, 3, 1), + /* 11 */ V(1, 3, 1), + + /* 0011 ... */ + /* 00 */ V(3, 1, 1), /* 44 */ + /* 01 */ V(3, 1, 1), + /* 10 */ V(0, 3, 2), + /* 11 */ V(3, 0, 2), + + /* 0100 ... */ + /* 0 */ V(2, 2, 1), /* 48 */ + /* 1 */ V(0, 2, 1), + + /* 0000 0000 ... */ + /* 0 */ V(5, 5, 1), /* 50 */ + /* 1 */ V(4, 5, 1), + + /* 0000 0011 ... */ + /* 0 */ V(5, 4, 1), /* 52 */ + /* 1 */ V(0, 5, 1) +}; + +static +union huffpair const hufftab10[] ICONST_ATTR_MPA_HUFFMAN = { + /* 0000 */ PTR(16, 4), + /* 0001 */ PTR(32, 4), + /* 0010 */ PTR(48, 2), + /* 0011 */ V(1, 1, 4), + /* 0100 */ V(0, 1, 3), + /* 0101 */ V(0, 1, 3), + /* 0110 */ V(1, 0, 3), + /* 0111 */ V(1, 0, 3), + /* 1000 */ V(0, 0, 1), + /* 1001 */ V(0, 0, 1), + /* 1010 */ V(0, 0, 1), + /* 1011 */ V(0, 0, 1), + /* 1100 */ V(0, 0, 1), + /* 1101 */ V(0, 0, 1), + /* 1110 */ V(0, 0, 1), + /* 1111 */ V(0, 0, 1), + + /* 0000 ... */ + /* 0000 */ PTR(52, 3), /* 16 */ + /* 0001 */ PTR(60, 2), + /* 0010 */ PTR(64, 3), + /* 0011 */ PTR(72, 1), + /* 0100 */ PTR(74, 2), + /* 0101 */ PTR(78, 2), + /* 0110 */ PTR(82, 2), + /* 0111 */ V(1, 7, 4), + /* 1000 */ V(7, 1, 4), + /* 1001 */ PTR(86, 1), + /* 1010 */ PTR(88, 2), + /* 1011 */ PTR(92, 2), + /* 1100 */ V(1, 6, 4), + /* 1101 */ V(6, 1, 4), + /* 1110 */ V(6, 0, 4), + /* 1111 */ PTR(96, 1), + + /* 0001 ... */ + /* 0000 */ PTR(98, 1), /* 32 */ + /* 0001 */ PTR(100, 1), + /* 0010 */ V(1, 4, 4), + /* 0011 */ V(4, 1, 4), + /* 0100 */ V(4, 0, 4), + /* 0101 */ V(2, 3, 4), + /* 0110 */ V(3, 2, 4), + /* 0111 */ V(0, 3, 4), + /* 1000 */ V(1, 3, 3), + /* 1001 */ V(1, 3, 3), + /* 1010 */ V(3, 1, 3), + /* 1011 */ V(3, 1, 3), + /* 1100 */ V(3, 0, 3), + /* 1101 */ V(3, 0, 3), + /* 1110 */ V(2, 2, 3), + /* 1111 */ V(2, 2, 3), + + /* 0010 ... */ + /* 00 */ V(1, 2, 2), /* 48 */ + /* 01 */ V(2, 1, 2), + /* 10 */ V(0, 2, 2), + /* 11 */ V(2, 0, 2), + + /* 0000 0000 ... */ + /* 000 */ V(7, 7, 3), /* 52 */ + /* 001 */ V(6, 7, 3), + /* 010 */ V(7, 6, 3), + /* 011 */ V(5, 7, 3), + /* 100 */ V(7, 5, 3), + /* 101 */ V(6, 6, 3), + /* 110 */ V(4, 7, 2), + /* 111 */ V(4, 7, 2), + + /* 0000 0001 ... */ + /* 00 */ V(7, 4, 2), /* 60 */ + /* 01 */ V(5, 6, 2), + /* 10 */ V(6, 5, 2), + /* 11 */ V(3, 7, 2), + + /* 0000 0010 ... */ + /* 000 */ V(7, 3, 2), /* 64 */ + /* 001 */ V(7, 3, 2), + /* 010 */ V(4, 6, 2), + /* 011 */ V(4, 6, 2), + /* 100 */ V(5, 5, 3), + /* 101 */ V(5, 4, 3), + /* 110 */ V(6, 3, 2), + /* 111 */ V(6, 3, 2), + + /* 0000 0011 ... */ + /* 0 */ V(2, 7, 1), /* 72 */ + /* 1 */ V(7, 2, 1), + + /* 0000 0100 ... */ + /* 00 */ V(6, 4, 2), /* 74 */ + /* 01 */ V(0, 7, 2), + /* 10 */ V(7, 0, 1), + /* 11 */ V(7, 0, 1), + + /* 0000 0101 ... */ + /* 00 */ V(6, 2, 1), /* 78 */ + /* 01 */ V(6, 2, 1), + /* 10 */ V(4, 5, 2), + /* 11 */ V(3, 5, 2), + + /* 0000 0110 ... */ + /* 00 */ V(0, 6, 1), /* 82 */ + /* 01 */ V(0, 6, 1), + /* 10 */ V(5, 3, 2), + /* 11 */ V(4, 4, 2), + + /* 0000 1001 ... */ + /* 0 */ V(3, 6, 1), /* 86 */ + /* 1 */ V(2, 6, 1), + + /* 0000 1010 ... */ + /* 00 */ V(2, 5, 2), /* 88 */ + /* 01 */ V(5, 2, 2), + /* 10 */ V(1, 5, 1), + /* 11 */ V(1, 5, 1), + + /* 0000 1011 ... */ + /* 00 */ V(5, 1, 1), /* 92 */ + /* 01 */ V(5, 1, 1), + /* 10 */ V(3, 4, 2), + /* 11 */ V(4, 3, 2), + + /* 0000 1111 ... */ + /* 0 */ V(0, 5, 1), /* 96 */ + /* 1 */ V(5, 0, 1), + + /* 0001 0000 ... */ + /* 0 */ V(2, 4, 1), /* 98 */ + /* 1 */ V(4, 2, 1), + + /* 0001 0001 ... */ + /* 0 */ V(3, 3, 1), /* 100 */ + /* 1 */ V(0, 4, 1) +}; + +static +union huffpair const hufftab11[] ICONST_ATTR_MPA_HUFFMAN = { + /* 0000 */ PTR(16, 4), + /* 0001 */ PTR(32, 4), + /* 0010 */ PTR(48, 4), + /* 0011 */ PTR(64, 3), + /* 0100 */ V(1, 2, 4), + /* 0101 */ PTR(72, 1), + /* 0110 */ V(1, 1, 3), + /* 0111 */ V(1, 1, 3), + /* 1000 */ V(0, 1, 3), + /* 1001 */ V(0, 1, 3), + /* 1010 */ V(1, 0, 3), + /* 1011 */ V(1, 0, 3), + /* 1100 */ V(0, 0, 2), + /* 1101 */ V(0, 0, 2), + /* 1110 */ V(0, 0, 2), + /* 1111 */ V(0, 0, 2), + + /* 0000 ... */ + /* 0000 */ PTR(74, 2), /* 16 */ + /* 0001 */ PTR(78, 3), + /* 0010 */ PTR(86, 2), + /* 0011 */ PTR(90, 1), + /* 0100 */ PTR(92, 2), + /* 0101 */ V(2, 7, 4), + /* 0110 */ V(7, 2, 4), + /* 0111 */ PTR(96, 1), + /* 1000 */ V(7, 1, 3), + /* 1001 */ V(7, 1, 3), + /* 1010 */ V(1, 7, 4), + /* 1011 */ V(7, 0, 4), + /* 1100 */ V(3, 6, 4), + /* 1101 */ V(6, 3, 4), + /* 1110 */ V(6, 0, 4), + /* 1111 */ PTR(98, 1), + + /* 0001 ... */ + /* 0000 */ PTR(100, 1), /* 32 */ + /* 0001 */ V(1, 5, 4), + /* 0010 */ V(6, 2, 3), + /* 0011 */ V(6, 2, 3), + /* 0100 */ V(2, 6, 4), + /* 0101 */ V(0, 6, 4), + /* 0110 */ V(1, 6, 3), + /* 0111 */ V(1, 6, 3), + /* 1000 */ V(6, 1, 3), + /* 1001 */ V(6, 1, 3), + /* 1010 */ V(5, 1, 4), + /* 1011 */ V(3, 4, 4), + /* 1100 */ V(5, 0, 4), + /* 1101 */ PTR(102, 1), + /* 1110 */ V(2, 4, 4), + /* 1111 */ V(4, 2, 4), + + /* 0010 ... */ + /* 0000 */ V(1, 4, 4), /* 48 */ + /* 0001 */ V(4, 1, 4), + /* 0010 */ V(0, 4, 4), + /* 0011 */ V(4, 0, 4), + /* 0100 */ V(2, 3, 3), + /* 0101 */ V(2, 3, 3), + /* 0110 */ V(3, 2, 3), + /* 0111 */ V(3, 2, 3), + /* 1000 */ V(1, 3, 2), + /* 1001 */ V(1, 3, 2), + /* 1010 */ V(1, 3, 2), + /* 1011 */ V(1, 3, 2), + /* 1100 */ V(3, 1, 2), + /* 1101 */ V(3, 1, 2), + /* 1110 */ V(3, 1, 2), + /* 1111 */ V(3, 1, 2), + + /* 0011 ... */ + /* 000 */ V(0, 3, 3), /* 64 */ + /* 001 */ V(3, 0, 3), + /* 010 */ V(2, 2, 2), + /* 011 */ V(2, 2, 2), + /* 100 */ V(2, 1, 1), + /* 101 */ V(2, 1, 1), + /* 110 */ V(2, 1, 1), + /* 111 */ V(2, 1, 1), + + /* 0101 ... */ + /* 0 */ V(0, 2, 1), /* 72 */ + /* 1 */ V(2, 0, 1), + + /* 0000 0000 ... */ + /* 00 */ V(7, 7, 2), /* 74 */ + /* 01 */ V(6, 7, 2), + /* 10 */ V(7, 6, 2), + /* 11 */ V(7, 5, 2), + + /* 0000 0001 ... */ + /* 000 */ V(6, 6, 2), /* 78 */ + /* 001 */ V(6, 6, 2), + /* 010 */ V(4, 7, 2), + /* 011 */ V(4, 7, 2), + /* 100 */ V(7, 4, 2), + /* 101 */ V(7, 4, 2), + /* 110 */ V(5, 7, 3), + /* 111 */ V(5, 5, 3), + + /* 0000 0010 ... */ + /* 00 */ V(5, 6, 2), /* 86 */ + /* 01 */ V(6, 5, 2), + /* 10 */ V(3, 7, 1), + /* 11 */ V(3, 7, 1), + + /* 0000 0011 ... */ + /* 0 */ V(7, 3, 1), /* 90 */ + /* 1 */ V(4, 6, 1), + + /* 0000 0100 ... */ + /* 00 */ V(4, 5, 2), /* 92 */ + /* 01 */ V(5, 4, 2), + /* 10 */ V(3, 5, 2), + /* 11 */ V(5, 3, 2), + + /* 0000 0111 ... */ + /* 0 */ V(6, 4, 1), /* 96 */ + /* 1 */ V(0, 7, 1), + + /* 0000 1111 ... */ + /* 0 */ V(4, 4, 1), /* 98 */ + /* 1 */ V(2, 5, 1), + + /* 0001 0000 ... */ + /* 0 */ V(5, 2, 1), /* 100 */ + /* 1 */ V(0, 5, 1), + + /* 0001 1101 ... */ + /* 0 */ V(4, 3, 1), /* 102 */ + /* 1 */ V(3, 3, 1) +}; + +static +union huffpair const hufftab12[] ICONST_ATTR_MPA_HUFFMAN = { + /* 0000 */ PTR(16, 4), + /* 0001 */ PTR(32, 4), + /* 0010 */ PTR(48, 4), + /* 0011 */ PTR(64, 2), + /* 0100 */ PTR(68, 3), + /* 0101 */ PTR(76, 1), + /* 0110 */ V(1, 2, 4), + /* 0111 */ V(2, 1, 4), + /* 1000 */ PTR(78, 1), + /* 1001 */ V(0, 0, 4), + /* 1010 */ V(1, 1, 3), + /* 1011 */ V(1, 1, 3), + /* 1100 */ V(0, 1, 3), + /* 1101 */ V(0, 1, 3), + /* 1110 */ V(1, 0, 3), + /* 1111 */ V(1, 0, 3), + + /* 0000 ... */ + /* 0000 */ PTR(80, 2), /* 16 */ + /* 0001 */ PTR(84, 1), + /* 0010 */ PTR(86, 1), + /* 0011 */ PTR(88, 1), + /* 0100 */ V(5, 6, 4), + /* 0101 */ V(3, 7, 4), + /* 0110 */ PTR(90, 1), + /* 0111 */ V(2, 7, 4), + /* 1000 */ V(7, 2, 4), + /* 1001 */ V(4, 6, 4), + /* 1010 */ V(6, 4, 4), + /* 1011 */ V(1, 7, 4), + /* 1100 */ V(7, 1, 4), + /* 1101 */ PTR(92, 1), + /* 1110 */ V(3, 6, 4), + /* 1111 */ V(6, 3, 4), + + /* 0001 ... */ + /* 0000 */ V(4, 5, 4), /* 32 */ + /* 0001 */ V(5, 4, 4), + /* 0010 */ V(4, 4, 4), + /* 0011 */ PTR(94, 1), + /* 0100 */ V(2, 6, 3), + /* 0101 */ V(2, 6, 3), + /* 0110 */ V(6, 2, 3), + /* 0111 */ V(6, 2, 3), + /* 1000 */ V(6, 1, 3), + /* 1001 */ V(6, 1, 3), + /* 1010 */ V(1, 6, 4), + /* 1011 */ V(6, 0, 4), + /* 1100 */ V(3, 5, 4), + /* 1101 */ V(5, 3, 4), + /* 1110 */ V(2, 5, 4), + /* 1111 */ V(5, 2, 4), + + /* 0010 ... */ + /* 0000 */ V(1, 5, 3), /* 48 */ + /* 0001 */ V(1, 5, 3), + /* 0010 */ V(5, 1, 3), + /* 0011 */ V(5, 1, 3), + /* 0100 */ V(3, 4, 3), + /* 0101 */ V(3, 4, 3), + /* 0110 */ V(4, 3, 3), + /* 0111 */ V(4, 3, 3), + /* 1000 */ V(5, 0, 4), + /* 1001 */ V(0, 4, 4), + /* 1010 */ V(2, 4, 3), + /* 1011 */ V(2, 4, 3), + /* 1100 */ V(4, 2, 3), + /* 1101 */ V(4, 2, 3), + /* 1110 */ V(1, 4, 3), + /* 1111 */ V(1, 4, 3), + + /* 0011 ... */ + /* 00 */ V(3, 3, 2), /* 64 */ + /* 01 */ V(4, 1, 2), + /* 10 */ V(2, 3, 2), + /* 11 */ V(3, 2, 2), + + /* 0100 ... */ + /* 000 */ V(4, 0, 3), /* 68 */ + /* 001 */ V(0, 3, 3), + /* 010 */ V(3, 0, 2), + /* 011 */ V(3, 0, 2), + /* 100 */ V(1, 3, 1), + /* 101 */ V(1, 3, 1), + /* 110 */ V(1, 3, 1), + /* 111 */ V(1, 3, 1), + + /* 0101 ... */ + /* 0 */ V(3, 1, 1), /* 76 */ + /* 1 */ V(2, 2, 1), + + /* 1000 ... */ + /* 0 */ V(0, 2, 1), /* 78 */ + /* 1 */ V(2, 0, 1), + + /* 0000 0000 ... */ + /* 00 */ V(7, 7, 2), /* 80 */ + /* 01 */ V(6, 7, 2), + /* 10 */ V(7, 6, 1), + /* 11 */ V(7, 6, 1), + + /* 0000 0001 ... */ + /* 0 */ V(5, 7, 1), /* 84 */ + /* 1 */ V(7, 5, 1), + + /* 0000 0010 ... */ + /* 0 */ V(6, 6, 1), /* 86 */ + /* 1 */ V(4, 7, 1), + + /* 0000 0011 ... */ + /* 0 */ V(7, 4, 1), /* 88 */ + /* 1 */ V(6, 5, 1), + + /* 0000 0110 ... */ + /* 0 */ V(7, 3, 1), /* 90 */ + /* 1 */ V(5, 5, 1), + + /* 0000 1101 ... */ + /* 0 */ V(0, 7, 1), /* 92 */ + /* 1 */ V(7, 0, 1), + + /* 0001 0011 ... */ + /* 0 */ V(0, 6, 1), /* 94 */ + /* 1 */ V(0, 5, 1) +}; + +static +union huffpair const hufftab13[] ICONST_ATTR_MPA_HUFFMAN = { + /* 0000 */ PTR(16, 4), + /* 0001 */ PTR(32, 4), + /* 0010 */ PTR(48, 4), + /* 0011 */ PTR(64, 2), + /* 0100 */ V(1, 1, 4), + /* 0101 */ V(0, 1, 4), + /* 0110 */ V(1, 0, 3), + /* 0111 */ V(1, 0, 3), + /* 1000 */ V(0, 0, 1), + /* 1001 */ V(0, 0, 1), + /* 1010 */ V(0, 0, 1), + /* 1011 */ V(0, 0, 1), + /* 1100 */ V(0, 0, 1), + /* 1101 */ V(0, 0, 1), + /* 1110 */ V(0, 0, 1), + /* 1111 */ V(0, 0, 1), + + /* 0000 ... */ + /* 0000 */ PTR(68, 4), /* 16 */ + /* 0001 */ PTR(84, 4), + /* 0010 */ PTR(100, 4), + /* 0011 */ PTR(116, 4), + /* 0100 */ PTR(132, 4), + /* 0101 */ PTR(148, 4), + /* 0110 */ PTR(164, 3), + /* 0111 */ PTR(172, 3), + /* 1000 */ PTR(180, 3), + /* 1001 */ PTR(188, 3), + /* 1010 */ PTR(196, 3), + /* 1011 */ PTR(204, 3), + /* 1100 */ PTR(212, 1), + /* 1101 */ PTR(214, 2), + /* 1110 */ PTR(218, 3), + /* 1111 */ PTR(226, 1), + + /* 0001 ... */ + /* 0000 */ PTR(228, 2), /* 32 */ + /* 0001 */ PTR(232, 2), + /* 0010 */ PTR(236, 2), + /* 0011 */ PTR(240, 2), + /* 0100 */ V(8, 1, 4), + /* 0101 */ PTR(244, 1), + /* 0110 */ PTR(246, 1), + /* 0111 */ PTR(248, 1), + /* 1000 */ PTR(250, 2), + /* 1001 */ PTR(254, 1), + /* 1010 */ V(1, 5, 4), + /* 1011 */ V(5, 1, 4), + /* 1100 */ PTR(256, 1), + /* 1101 */ PTR(258, 1), + /* 1110 */ PTR(260, 1), + /* 1111 */ V(1, 4, 4), + + /* 0010 ... */ + /* 0000 */ V(4, 1, 3), /* 48 */ + /* 0001 */ V(4, 1, 3), + /* 0010 */ V(0, 4, 4), + /* 0011 */ V(4, 0, 4), + /* 0100 */ V(2, 3, 4), + /* 0101 */ V(3, 2, 4), + /* 0110 */ V(1, 3, 3), + /* 0111 */ V(1, 3, 3), + /* 1000 */ V(3, 1, 3), + /* 1001 */ V(3, 1, 3), + /* 1010 */ V(0, 3, 3), + /* 1011 */ V(0, 3, 3), + /* 1100 */ V(3, 0, 3), + /* 1101 */ V(3, 0, 3), + /* 1110 */ V(2, 2, 3), + /* 1111 */ V(2, 2, 3), + + /* 0011 ... */ + /* 00 */ V(1, 2, 2), /* 64 */ + /* 01 */ V(2, 1, 2), + /* 10 */ V(0, 2, 2), + /* 11 */ V(2, 0, 2), + + /* 0000 0000 ... */ + /* 0000 */ PTR(262, 4), /* 68 */ + /* 0001 */ PTR(278, 4), + /* 0010 */ PTR(294, 4), + /* 0011 */ PTR(310, 3), + /* 0100 */ PTR(318, 2), + /* 0101 */ PTR(322, 2), + /* 0110 */ PTR(326, 3), + /* 0111 */ PTR(334, 2), + /* 1000 */ PTR(338, 1), + /* 1001 */ PTR(340, 2), + /* 1010 */ PTR(344, 2), + /* 1011 */ PTR(348, 2), + /* 1100 */ PTR(352, 2), + /* 1101 */ PTR(356, 2), + /* 1110 */ V(1, 15, 4), + /* 1111 */ V(15, 1, 4), + + /* 0000 0001 ... */ + /* 0000 */ V(15, 0, 4), /* 84 */ + /* 0001 */ PTR(360, 1), + /* 0010 */ PTR(362, 1), + /* 0011 */ PTR(364, 1), + /* 0100 */ V(14, 2, 4), + /* 0101 */ PTR(366, 1), + /* 0110 */ V(1, 14, 4), + /* 0111 */ V(14, 1, 4), + /* 1000 */ PTR(368, 1), + /* 1001 */ PTR(370, 1), + /* 1010 */ PTR(372, 1), + /* 1011 */ PTR(374, 1), + /* 1100 */ PTR(376, 1), + /* 1101 */ PTR(378, 1), + /* 1110 */ V(12, 6, 4), + /* 1111 */ V(3, 13, 4), + + /* 0000 0010 ... */ + /* 0000 */ PTR(380, 1), /* 100 */ + /* 0001 */ V(2, 13, 4), + /* 0010 */ V(13, 2, 4), + /* 0011 */ V(1, 13, 4), + /* 0100 */ V(11, 7, 4), + /* 0101 */ PTR(382, 1), + /* 0110 */ PTR(384, 1), + /* 0111 */ V(12, 3, 4), + /* 1000 */ PTR(386, 1), + /* 1001 */ V(4, 11, 4), + /* 1010 */ V(13, 1, 3), + /* 1011 */ V(13, 1, 3), + /* 1100 */ V(0, 13, 4), + /* 1101 */ V(13, 0, 4), + /* 1110 */ V(8, 10, 4), + /* 1111 */ V(10, 8, 4), + + /* 0000 0011 ... */ + /* 0000 */ V(4, 12, 4), /* 116 */ + /* 0001 */ V(12, 4, 4), + /* 0010 */ V(6, 11, 4), + /* 0011 */ V(11, 6, 4), + /* 0100 */ V(3, 12, 3), + /* 0101 */ V(3, 12, 3), + /* 0110 */ V(2, 12, 3), + /* 0111 */ V(2, 12, 3), + /* 1000 */ V(12, 2, 3), + /* 1001 */ V(12, 2, 3), + /* 1010 */ V(5, 11, 3), + /* 1011 */ V(5, 11, 3), + /* 1100 */ V(11, 5, 4), + /* 1101 */ V(8, 9, 4), + /* 1110 */ V(1, 12, 3), + /* 1111 */ V(1, 12, 3), + + /* 0000 0100 ... */ + /* 0000 */ V(12, 1, 3), /* 132 */ + /* 0001 */ V(12, 1, 3), + /* 0010 */ V(9, 8, 4), + /* 0011 */ V(0, 12, 4), + /* 0100 */ V(12, 0, 3), + /* 0101 */ V(12, 0, 3), + /* 0110 */ V(11, 4, 4), + /* 0111 */ V(6, 10, 4), + /* 1000 */ V(10, 6, 4), + /* 1001 */ V(7, 9, 4), + /* 1010 */ V(3, 11, 3), + /* 1011 */ V(3, 11, 3), + /* 1100 */ V(11, 3, 3), + /* 1101 */ V(11, 3, 3), + /* 1110 */ V(8, 8, 4), + /* 1111 */ V(5, 10, 4), + + /* 0000 0101 ... */ + /* 0000 */ V(2, 11, 3), /* 148 */ + /* 0001 */ V(2, 11, 3), + /* 0010 */ V(10, 5, 4), + /* 0011 */ V(6, 9, 4), + /* 0100 */ V(10, 4, 3), + /* 0101 */ V(10, 4, 3), + /* 0110 */ V(7, 8, 4), + /* 0111 */ V(8, 7, 4), + /* 1000 */ V(9, 4, 3), + /* 1001 */ V(9, 4, 3), + /* 1010 */ V(7, 7, 4), + /* 1011 */ V(7, 6, 4), + /* 1100 */ V(11, 2, 2), + /* 1101 */ V(11, 2, 2), + /* 1110 */ V(11, 2, 2), + /* 1111 */ V(11, 2, 2), + + /* 0000 0110 ... */ + /* 000 */ V(1, 11, 2), /* 164 */ + /* 001 */ V(1, 11, 2), + /* 010 */ V(11, 1, 2), + /* 011 */ V(11, 1, 2), + /* 100 */ V(0, 11, 3), + /* 101 */ V(11, 0, 3), + /* 110 */ V(9, 6, 3), + /* 111 */ V(4, 10, 3), + + /* 0000 0111 ... */ + /* 000 */ V(3, 10, 3), /* 172 */ + /* 001 */ V(10, 3, 3), + /* 010 */ V(5, 9, 3), + /* 011 */ V(9, 5, 3), + /* 100 */ V(2, 10, 2), + /* 101 */ V(2, 10, 2), + /* 110 */ V(10, 2, 2), + /* 111 */ V(10, 2, 2), + + /* 0000 1000 ... */ + /* 000 */ V(1, 10, 2), /* 180 */ + /* 001 */ V(1, 10, 2), + /* 010 */ V(10, 1, 2), + /* 011 */ V(10, 1, 2), + /* 100 */ V(0, 10, 3), + /* 101 */ V(6, 8, 3), + /* 110 */ V(10, 0, 2), + /* 111 */ V(10, 0, 2), + + /* 0000 1001 ... */ + /* 000 */ V(8, 6, 3), /* 188 */ + /* 001 */ V(4, 9, 3), + /* 010 */ V(9, 3, 2), + /* 011 */ V(9, 3, 2), + /* 100 */ V(3, 9, 3), + /* 101 */ V(5, 8, 3), + /* 110 */ V(8, 5, 3), + /* 111 */ V(6, 7, 3), + + /* 0000 1010 ... */ + /* 000 */ V(2, 9, 2), /* 196 */ + /* 001 */ V(2, 9, 2), + /* 010 */ V(9, 2, 2), + /* 011 */ V(9, 2, 2), + /* 100 */ V(5, 7, 3), + /* 101 */ V(7, 5, 3), + /* 110 */ V(3, 8, 2), + /* 111 */ V(3, 8, 2), + + /* 0000 1011 ... */ + /* 000 */ V(8, 3, 2), /* 204 */ + /* 001 */ V(8, 3, 2), + /* 010 */ V(6, 6, 3), + /* 011 */ V(4, 7, 3), + /* 100 */ V(7, 4, 3), + /* 101 */ V(5, 6, 3), + /* 110 */ V(6, 5, 3), + /* 111 */ V(7, 3, 3), + + /* 0000 1100 ... */ + /* 0 */ V(1, 9, 1), /* 212 */ + /* 1 */ V(9, 1, 1), + + /* 0000 1101 ... */ + /* 00 */ V(0, 9, 2), /* 214 */ + /* 01 */ V(9, 0, 2), + /* 10 */ V(4, 8, 2), + /* 11 */ V(8, 4, 2), + + /* 0000 1110 ... */ + /* 000 */ V(7, 2, 2), /* 218 */ + /* 001 */ V(7, 2, 2), + /* 010 */ V(4, 6, 3), + /* 011 */ V(6, 4, 3), + /* 100 */ V(2, 8, 1), + /* 101 */ V(2, 8, 1), + /* 110 */ V(2, 8, 1), + /* 111 */ V(2, 8, 1), + + /* 0000 1111 ... */ + /* 0 */ V(8, 2, 1), /* 226 */ + /* 1 */ V(1, 8, 1), + + /* 0001 0000 ... */ + /* 00 */ V(3, 7, 2), /* 228 */ + /* 01 */ V(2, 7, 2), + /* 10 */ V(1, 7, 1), + /* 11 */ V(1, 7, 1), + + /* 0001 0001 ... */ + /* 00 */ V(7, 1, 1), /* 232 */ + /* 01 */ V(7, 1, 1), + /* 10 */ V(5, 5, 2), + /* 11 */ V(0, 7, 2), + + /* 0001 0010 ... */ + /* 00 */ V(7, 0, 2), /* 236 */ + /* 01 */ V(3, 6, 2), + /* 10 */ V(6, 3, 2), + /* 11 */ V(4, 5, 2), + + /* 0001 0011 ... */ + /* 00 */ V(5, 4, 2), /* 240 */ + /* 01 */ V(2, 6, 2), + /* 10 */ V(6, 2, 2), + /* 11 */ V(3, 5, 2), + + /* 0001 0101 ... */ + /* 0 */ V(0, 8, 1), /* 244 */ + /* 1 */ V(8, 0, 1), + + /* 0001 0110 ... */ + /* 0 */ V(1, 6, 1), /* 246 */ + /* 1 */ V(6, 1, 1), + + /* 0001 0111 ... */ + /* 0 */ V(0, 6, 1), /* 248 */ + /* 1 */ V(6, 0, 1), + + /* 0001 1000 ... */ + /* 00 */ V(5, 3, 2), /* 250 */ + /* 01 */ V(4, 4, 2), + /* 10 */ V(2, 5, 1), + /* 11 */ V(2, 5, 1), + + /* 0001 1001 ... */ + /* 0 */ V(5, 2, 1), /* 254 */ + /* 1 */ V(0, 5, 1), + + /* 0001 1100 ... */ + /* 0 */ V(3, 4, 1), /* 256 */ + /* 1 */ V(4, 3, 1), + + /* 0001 1101 ... */ + /* 0 */ V(5, 0, 1), /* 258 */ + /* 1 */ V(2, 4, 1), + + /* 0001 1110 ... */ + /* 0 */ V(4, 2, 1), /* 260 */ + /* 1 */ V(3, 3, 1), + + /* 0000 0000 0000 ... */ + /* 0000 */ PTR(388, 3), /* 262 */ + /* 0001 */ V(15, 15, 4), + /* 0010 */ V(14, 15, 4), + /* 0011 */ V(13, 15, 4), + /* 0100 */ V(14, 14, 4), + /* 0101 */ V(12, 15, 4), + /* 0110 */ V(13, 14, 4), + /* 0111 */ V(11, 15, 4), + /* 1000 */ V(15, 11, 4), + /* 1001 */ V(12, 14, 4), + /* 1010 */ V(13, 12, 4), + /* 1011 */ PTR(396, 1), + /* 1100 */ V(14, 12, 3), + /* 1101 */ V(14, 12, 3), + /* 1110 */ V(13, 13, 3), + /* 1111 */ V(13, 13, 3), + + /* 0000 0000 0001 ... */ + /* 0000 */ V(15, 10, 4), /* 278 */ + /* 0001 */ V(12, 13, 4), + /* 0010 */ V(11, 14, 3), + /* 0011 */ V(11, 14, 3), + /* 0100 */ V(14, 11, 3), + /* 0101 */ V(14, 11, 3), + /* 0110 */ V(9, 15, 3), + /* 0111 */ V(9, 15, 3), + /* 1000 */ V(15, 9, 3), + /* 1001 */ V(15, 9, 3), + /* 1010 */ V(14, 10, 3), + /* 1011 */ V(14, 10, 3), + /* 1100 */ V(11, 13, 3), + /* 1101 */ V(11, 13, 3), + /* 1110 */ V(13, 11, 3), + /* 1111 */ V(13, 11, 3), + + /* 0000 0000 0010 ... */ + /* 0000 */ V(8, 15, 3), /* 294 */ + /* 0001 */ V(8, 15, 3), + /* 0010 */ V(15, 8, 3), + /* 0011 */ V(15, 8, 3), + /* 0100 */ V(12, 12, 3), + /* 0101 */ V(12, 12, 3), + /* 0110 */ V(10, 14, 4), + /* 0111 */ V(9, 14, 4), + /* 1000 */ V(8, 14, 3), + /* 1001 */ V(8, 14, 3), + /* 1010 */ V(7, 15, 4), + /* 1011 */ V(7, 14, 4), + /* 1100 */ V(15, 7, 2), + /* 1101 */ V(15, 7, 2), + /* 1110 */ V(15, 7, 2), + /* 1111 */ V(15, 7, 2), + + /* 0000 0000 0011 ... */ + /* 000 */ V(13, 10, 2), /* 310 */ + /* 001 */ V(13, 10, 2), + /* 010 */ V(10, 13, 3), + /* 011 */ V(11, 12, 3), + /* 100 */ V(12, 11, 3), + /* 101 */ V(15, 6, 3), + /* 110 */ V(6, 15, 2), + /* 111 */ V(6, 15, 2), + + /* 0000 0000 0100 ... */ + /* 00 */ V(14, 8, 2), /* 318 */ + /* 01 */ V(5, 15, 2), + /* 10 */ V(9, 13, 2), + /* 11 */ V(13, 9, 2), + + /* 0000 0000 0101 ... */ + /* 00 */ V(15, 5, 2), /* 322 */ + /* 01 */ V(14, 7, 2), + /* 10 */ V(10, 12, 2), + /* 11 */ V(11, 11, 2), + + /* 0000 0000 0110 ... */ + /* 000 */ V(4, 15, 2), /* 326 */ + /* 001 */ V(4, 15, 2), + /* 010 */ V(15, 4, 2), + /* 011 */ V(15, 4, 2), + /* 100 */ V(12, 10, 3), + /* 101 */ V(14, 6, 3), + /* 110 */ V(15, 3, 2), + /* 111 */ V(15, 3, 2), + + /* 0000 0000 0111 ... */ + /* 00 */ V(3, 15, 1), /* 334 */ + /* 01 */ V(3, 15, 1), + /* 10 */ V(8, 13, 2), + /* 11 */ V(13, 8, 2), + + /* 0000 0000 1000 ... */ + /* 0 */ V(2, 15, 1), /* 338 */ + /* 1 */ V(15, 2, 1), + + /* 0000 0000 1001 ... */ + /* 00 */ V(6, 14, 2), /* 340 */ + /* 01 */ V(9, 12, 2), + /* 10 */ V(0, 15, 1), + /* 11 */ V(0, 15, 1), + + /* 0000 0000 1010 ... */ + /* 00 */ V(12, 9, 2), /* 344 */ + /* 01 */ V(5, 14, 2), + /* 10 */ V(10, 11, 1), + /* 11 */ V(10, 11, 1), + + /* 0000 0000 1011 ... */ + /* 00 */ V(7, 13, 2), /* 348 */ + /* 01 */ V(13, 7, 2), + /* 10 */ V(4, 14, 1), + /* 11 */ V(4, 14, 1), + + /* 0000 0000 1100 ... */ + /* 00 */ V(12, 8, 2), /* 352 */ + /* 01 */ V(13, 6, 2), + /* 10 */ V(3, 14, 1), + /* 11 */ V(3, 14, 1), + + /* 0000 0000 1101 ... */ + /* 00 */ V(11, 9, 1), /* 356 */ + /* 01 */ V(11, 9, 1), + /* 10 */ V(9, 11, 2), + /* 11 */ V(10, 10, 2), + + /* 0000 0001 0001 ... */ + /* 0 */ V(11, 10, 1), /* 360 */ + /* 1 */ V(14, 5, 1), + + /* 0000 0001 0010 ... */ + /* 0 */ V(14, 4, 1), /* 362 */ + /* 1 */ V(8, 12, 1), + + /* 0000 0001 0011 ... */ + /* 0 */ V(6, 13, 1), /* 364 */ + /* 1 */ V(14, 3, 1), + + /* 0000 0001 0101 ... */ + /* 0 */ V(2, 14, 1), /* 366 */ + /* 1 */ V(0, 14, 1), + + /* 0000 0001 1000 ... */ + /* 0 */ V(14, 0, 1), /* 368 */ + /* 1 */ V(5, 13, 1), + + /* 0000 0001 1001 ... */ + /* 0 */ V(13, 5, 1), /* 370 */ + /* 1 */ V(7, 12, 1), + + /* 0000 0001 1010 ... */ + /* 0 */ V(12, 7, 1), /* 372 */ + /* 1 */ V(4, 13, 1), + + /* 0000 0001 1011 ... */ + /* 0 */ V(8, 11, 1), /* 374 */ + /* 1 */ V(11, 8, 1), + + /* 0000 0001 1100 ... */ + /* 0 */ V(13, 4, 1), /* 376 */ + /* 1 */ V(9, 10, 1), + + /* 0000 0001 1101 ... */ + /* 0 */ V(10, 9, 1), /* 378 */ + /* 1 */ V(6, 12, 1), + + /* 0000 0010 0000 ... */ + /* 0 */ V(13, 3, 1), /* 380 */ + /* 1 */ V(7, 11, 1), + + /* 0000 0010 0101 ... */ + /* 0 */ V(5, 12, 1), /* 382 */ + /* 1 */ V(12, 5, 1), + + /* 0000 0010 0110 ... */ + /* 0 */ V(9, 9, 1), /* 384 */ + /* 1 */ V(7, 10, 1), + + /* 0000 0010 1000 ... */ + /* 0 */ V(10, 7, 1), /* 386 */ + /* 1 */ V(9, 7, 1), + + /* 0000 0000 0000 0000 ... */ + /* 000 */ V(15, 14, 3), /* 388 */ + /* 001 */ V(15, 12, 3), + /* 010 */ V(15, 13, 2), + /* 011 */ V(15, 13, 2), + /* 100 */ V(14, 13, 1), + /* 101 */ V(14, 13, 1), + /* 110 */ V(14, 13, 1), + /* 111 */ V(14, 13, 1), + + /* 0000 0000 0000 1011 ... */ + /* 0 */ V(10, 15, 1), /* 396 */ + /* 1 */ V(14, 9, 1) +}; + +static +union huffpair const hufftab15[] ICONST_ATTR_MPA_HUFFMAN = { + /* 0000 */ PTR(16, 4), + /* 0001 */ PTR(32, 4), + /* 0010 */ PTR(48, 4), + /* 0011 */ PTR(64, 4), + /* 0100 */ PTR(80, 4), + /* 0101 */ PTR(96, 3), + /* 0110 */ PTR(104, 3), + /* 0111 */ PTR(112, 2), + /* 1000 */ PTR(116, 1), + /* 1001 */ PTR(118, 1), + /* 1010 */ V(1, 1, 3), + /* 1011 */ V(1, 1, 3), + /* 1100 */ V(0, 1, 4), + /* 1101 */ V(1, 0, 4), + /* 1110 */ V(0, 0, 3), + /* 1111 */ V(0, 0, 3), + + /* 0000 ... */ + /* 0000 */ PTR(120, 4), /* 16 */ + /* 0001 */ PTR(136, 4), + /* 0010 */ PTR(152, 4), + /* 0011 */ PTR(168, 4), + /* 0100 */ PTR(184, 4), + /* 0101 */ PTR(200, 3), + /* 0110 */ PTR(208, 3), + /* 0111 */ PTR(216, 4), + /* 1000 */ PTR(232, 3), + /* 1001 */ PTR(240, 3), + /* 1010 */ PTR(248, 3), + /* 1011 */ PTR(256, 3), + /* 1100 */ PTR(264, 2), + /* 1101 */ PTR(268, 3), + /* 1110 */ PTR(276, 3), + /* 1111 */ PTR(284, 2), + + /* 0001 ... */ + /* 0000 */ PTR(288, 2), /* 32 */ + /* 0001 */ PTR(292, 2), + /* 0010 */ PTR(296, 2), + /* 0011 */ PTR(300, 2), + /* 0100 */ PTR(304, 2), + /* 0101 */ PTR(308, 2), + /* 0110 */ PTR(312, 2), + /* 0111 */ PTR(316, 2), + /* 1000 */ PTR(320, 1), + /* 1001 */ PTR(322, 1), + /* 1010 */ PTR(324, 1), + /* 1011 */ PTR(326, 2), + /* 1100 */ PTR(330, 1), + /* 1101 */ PTR(332, 1), + /* 1110 */ PTR(334, 2), + /* 1111 */ PTR(338, 1), + + /* 0010 ... */ + /* 0000 */ PTR(340, 1), /* 48 */ + /* 0001 */ PTR(342, 1), + /* 0010 */ V(9, 1, 4), + /* 0011 */ PTR(344, 1), + /* 0100 */ PTR(346, 1), + /* 0101 */ PTR(348, 1), + /* 0110 */ PTR(350, 1), + /* 0111 */ PTR(352, 1), + /* 1000 */ V(2, 8, 4), + /* 1001 */ V(8, 2, 4), + /* 1010 */ V(1, 8, 4), + /* 1011 */ V(8, 1, 4), + /* 1100 */ PTR(354, 1), + /* 1101 */ PTR(356, 1), + /* 1110 */ PTR(358, 1), + /* 1111 */ PTR(360, 1), + + /* 0011 ... */ + /* 0000 */ V(2, 7, 4), /* 64 */ + /* 0001 */ V(7, 2, 4), + /* 0010 */ V(6, 4, 4), + /* 0011 */ V(1, 7, 4), + /* 0100 */ V(5, 5, 4), + /* 0101 */ V(7, 1, 4), + /* 0110 */ PTR(362, 1), + /* 0111 */ V(3, 6, 4), + /* 1000 */ V(6, 3, 4), + /* 1001 */ V(4, 5, 4), + /* 1010 */ V(5, 4, 4), + /* 1011 */ V(2, 6, 4), + /* 1100 */ V(6, 2, 4), + /* 1101 */ V(1, 6, 4), + /* 1110 */ PTR(364, 1), + /* 1111 */ V(3, 5, 4), + + /* 0100 ... */ + /* 0000 */ V(6, 1, 3), /* 80 */ + /* 0001 */ V(6, 1, 3), + /* 0010 */ V(5, 3, 4), + /* 0011 */ V(4, 4, 4), + /* 0100 */ V(2, 5, 3), + /* 0101 */ V(2, 5, 3), + /* 0110 */ V(5, 2, 3), + /* 0111 */ V(5, 2, 3), + /* 1000 */ V(1, 5, 3), + /* 1001 */ V(1, 5, 3), + /* 1010 */ V(5, 1, 3), + /* 1011 */ V(5, 1, 3), + /* 1100 */ V(0, 5, 4), + /* 1101 */ V(5, 0, 4), + /* 1110 */ V(3, 4, 3), + /* 1111 */ V(3, 4, 3), + + /* 0101 ... */ + /* 000 */ V(4, 3, 3), /* 96 */ + /* 001 */ V(2, 4, 3), + /* 010 */ V(4, 2, 3), + /* 011 */ V(3, 3, 3), + /* 100 */ V(4, 1, 2), + /* 101 */ V(4, 1, 2), + /* 110 */ V(1, 4, 3), + /* 111 */ V(0, 4, 3), + + /* 0110 ... */ + /* 000 */ V(2, 3, 2), /* 104 */ + /* 001 */ V(2, 3, 2), + /* 010 */ V(3, 2, 2), + /* 011 */ V(3, 2, 2), + /* 100 */ V(4, 0, 3), + /* 101 */ V(0, 3, 3), + /* 110 */ V(1, 3, 2), + /* 111 */ V(1, 3, 2), + + /* 0111 ... */ + /* 00 */ V(3, 1, 2), /* 112 */ + /* 01 */ V(3, 0, 2), + /* 10 */ V(2, 2, 1), + /* 11 */ V(2, 2, 1), + + /* 1000 ... */ + /* 0 */ V(1, 2, 1), /* 116 */ + /* 1 */ V(2, 1, 1), + + /* 1001 ... */ + /* 0 */ V(0, 2, 1), /* 118 */ + /* 1 */ V(2, 0, 1), + + /* 0000 0000 ... */ + /* 0000 */ PTR(366, 1), /* 120 */ + /* 0001 */ PTR(368, 1), + /* 0010 */ V(14, 14, 4), + /* 0011 */ PTR(370, 1), + /* 0100 */ PTR(372, 1), + /* 0101 */ PTR(374, 1), + /* 0110 */ V(15, 11, 4), + /* 0111 */ PTR(376, 1), + /* 1000 */ V(13, 13, 4), + /* 1001 */ V(10, 15, 4), + /* 1010 */ V(15, 10, 4), + /* 1011 */ V(11, 14, 4), + /* 1100 */ V(14, 11, 4), + /* 1101 */ V(12, 13, 4), + /* 1110 */ V(13, 12, 4), + /* 1111 */ V(9, 15, 4), + + /* 0000 0001 ... */ + /* 0000 */ V(15, 9, 4), /* 136 */ + /* 0001 */ V(14, 10, 4), + /* 0010 */ V(11, 13, 4), + /* 0011 */ V(13, 11, 4), + /* 0100 */ V(8, 15, 4), + /* 0101 */ V(15, 8, 4), + /* 0110 */ V(12, 12, 4), + /* 0111 */ V(9, 14, 4), + /* 1000 */ V(14, 9, 4), + /* 1001 */ V(7, 15, 4), + /* 1010 */ V(15, 7, 4), + /* 1011 */ V(10, 13, 4), + /* 1100 */ V(13, 10, 4), + /* 1101 */ V(11, 12, 4), + /* 1110 */ V(6, 15, 4), + /* 1111 */ PTR(378, 1), + + /* 0000 0010 ... */ + /* 0000 */ V(12, 11, 3), /* 152 */ + /* 0001 */ V(12, 11, 3), + /* 0010 */ V(15, 6, 3), + /* 0011 */ V(15, 6, 3), + /* 0100 */ V(8, 14, 4), + /* 0101 */ V(14, 8, 4), + /* 0110 */ V(5, 15, 4), + /* 0111 */ V(9, 13, 4), + /* 1000 */ V(15, 5, 3), + /* 1001 */ V(15, 5, 3), + /* 1010 */ V(7, 14, 3), + /* 1011 */ V(7, 14, 3), + /* 1100 */ V(14, 7, 3), + /* 1101 */ V(14, 7, 3), + /* 1110 */ V(10, 12, 3), + /* 1111 */ V(10, 12, 3), + + /* 0000 0011 ... */ + /* 0000 */ V(12, 10, 3), /* 168 */ + /* 0001 */ V(12, 10, 3), + /* 0010 */ V(11, 11, 3), + /* 0011 */ V(11, 11, 3), + /* 0100 */ V(13, 9, 4), + /* 0101 */ V(8, 13, 4), + /* 0110 */ V(4, 15, 3), + /* 0111 */ V(4, 15, 3), + /* 1000 */ V(15, 4, 3), + /* 1001 */ V(15, 4, 3), + /* 1010 */ V(3, 15, 3), + /* 1011 */ V(3, 15, 3), + /* 1100 */ V(15, 3, 3), + /* 1101 */ V(15, 3, 3), + /* 1110 */ V(13, 8, 3), + /* 1111 */ V(13, 8, 3), + + /* 0000 0100 ... */ + /* 0000 */ V(14, 6, 3), /* 184 */ + /* 0001 */ V(14, 6, 3), + /* 0010 */ V(2, 15, 3), + /* 0011 */ V(2, 15, 3), + /* 0100 */ V(15, 2, 3), + /* 0101 */ V(15, 2, 3), + /* 0110 */ V(6, 14, 4), + /* 0111 */ V(15, 0, 4), + /* 1000 */ V(1, 15, 3), + /* 1001 */ V(1, 15, 3), + /* 1010 */ V(15, 1, 3), + /* 1011 */ V(15, 1, 3), + /* 1100 */ V(9, 12, 3), + /* 1101 */ V(9, 12, 3), + /* 1110 */ V(12, 9, 3), + /* 1111 */ V(12, 9, 3), + + /* 0000 0101 ... */ + /* 000 */ V(5, 14, 3), /* 200 */ + /* 001 */ V(10, 11, 3), + /* 010 */ V(11, 10, 3), + /* 011 */ V(14, 5, 3), + /* 100 */ V(7, 13, 3), + /* 101 */ V(13, 7, 3), + /* 110 */ V(4, 14, 3), + /* 111 */ V(14, 4, 3), + + /* 0000 0110 ... */ + /* 000 */ V(8, 12, 3), /* 208 */ + /* 001 */ V(12, 8, 3), + /* 010 */ V(3, 14, 3), + /* 011 */ V(6, 13, 3), + /* 100 */ V(13, 6, 3), + /* 101 */ V(14, 3, 3), + /* 110 */ V(9, 11, 3), + /* 111 */ V(11, 9, 3), + + /* 0000 0111 ... */ + /* 0000 */ V(2, 14, 3), /* 216 */ + /* 0001 */ V(2, 14, 3), + /* 0010 */ V(10, 10, 3), + /* 0011 */ V(10, 10, 3), + /* 0100 */ V(14, 2, 3), + /* 0101 */ V(14, 2, 3), + /* 0110 */ V(1, 14, 3), + /* 0111 */ V(1, 14, 3), + /* 1000 */ V(14, 1, 3), + /* 1001 */ V(14, 1, 3), + /* 1010 */ V(0, 14, 4), + /* 1011 */ V(14, 0, 4), + /* 1100 */ V(5, 13, 3), + /* 1101 */ V(5, 13, 3), + /* 1110 */ V(13, 5, 3), + /* 1111 */ V(13, 5, 3), + + /* 0000 1000 ... */ + /* 000 */ V(7, 12, 3), /* 232 */ + /* 001 */ V(12, 7, 3), + /* 010 */ V(4, 13, 3), + /* 011 */ V(8, 11, 3), + /* 100 */ V(13, 4, 2), + /* 101 */ V(13, 4, 2), + /* 110 */ V(11, 8, 3), + /* 111 */ V(9, 10, 3), + + /* 0000 1001 ... */ + /* 000 */ V(10, 9, 3), /* 240 */ + /* 001 */ V(6, 12, 3), + /* 010 */ V(12, 6, 3), + /* 011 */ V(3, 13, 3), + /* 100 */ V(13, 3, 2), + /* 101 */ V(13, 3, 2), + /* 110 */ V(13, 2, 2), + /* 111 */ V(13, 2, 2), + + /* 0000 1010 ... */ + /* 000 */ V(2, 13, 3), /* 248 */ + /* 001 */ V(0, 13, 3), + /* 010 */ V(1, 13, 2), + /* 011 */ V(1, 13, 2), + /* 100 */ V(7, 11, 2), + /* 101 */ V(7, 11, 2), + /* 110 */ V(11, 7, 2), + /* 111 */ V(11, 7, 2), + + /* 0000 1011 ... */ + /* 000 */ V(13, 1, 2), /* 256 */ + /* 001 */ V(13, 1, 2), + /* 010 */ V(5, 12, 3), + /* 011 */ V(13, 0, 3), + /* 100 */ V(12, 5, 2), + /* 101 */ V(12, 5, 2), + /* 110 */ V(8, 10, 2), + /* 111 */ V(8, 10, 2), + + /* 0000 1100 ... */ + /* 00 */ V(10, 8, 2), /* 264 */ + /* 01 */ V(4, 12, 2), + /* 10 */ V(12, 4, 2), + /* 11 */ V(6, 11, 2), + + /* 0000 1101 ... */ + /* 000 */ V(11, 6, 2), /* 268 */ + /* 001 */ V(11, 6, 2), + /* 010 */ V(9, 9, 3), + /* 011 */ V(0, 12, 3), + /* 100 */ V(3, 12, 2), + /* 101 */ V(3, 12, 2), + /* 110 */ V(12, 3, 2), + /* 111 */ V(12, 3, 2), + + /* 0000 1110 ... */ + /* 000 */ V(7, 10, 2), /* 276 */ + /* 001 */ V(7, 10, 2), + /* 010 */ V(10, 7, 2), + /* 011 */ V(10, 7, 2), + /* 100 */ V(10, 6, 2), + /* 101 */ V(10, 6, 2), + /* 110 */ V(12, 0, 3), + /* 111 */ V(0, 11, 3), + + /* 0000 1111 ... */ + /* 00 */ V(12, 2, 1), /* 284 */ + /* 01 */ V(12, 2, 1), + /* 10 */ V(2, 12, 2), + /* 11 */ V(5, 11, 2), + + /* 0001 0000 ... */ + /* 00 */ V(11, 5, 2), /* 288 */ + /* 01 */ V(1, 12, 2), + /* 10 */ V(8, 9, 2), + /* 11 */ V(9, 8, 2), + + /* 0001 0001 ... */ + /* 00 */ V(12, 1, 2), /* 292 */ + /* 01 */ V(4, 11, 2), + /* 10 */ V(11, 4, 2), + /* 11 */ V(6, 10, 2), + + /* 0001 0010 ... */ + /* 00 */ V(3, 11, 2), /* 296 */ + /* 01 */ V(7, 9, 2), + /* 10 */ V(11, 3, 1), + /* 11 */ V(11, 3, 1), + + /* 0001 0011 ... */ + /* 00 */ V(9, 7, 2), /* 300 */ + /* 01 */ V(8, 8, 2), + /* 10 */ V(2, 11, 2), + /* 11 */ V(5, 10, 2), + + /* 0001 0100 ... */ + /* 00 */ V(11, 2, 1), /* 304 */ + /* 01 */ V(11, 2, 1), + /* 10 */ V(10, 5, 2), + /* 11 */ V(1, 11, 2), + + /* 0001 0101 ... */ + /* 00 */ V(11, 1, 1), /* 308 */ + /* 01 */ V(11, 1, 1), + /* 10 */ V(11, 0, 2), + /* 11 */ V(6, 9, 2), + + /* 0001 0110 ... */ + /* 00 */ V(9, 6, 2), /* 312 */ + /* 01 */ V(4, 10, 2), + /* 10 */ V(10, 4, 2), + /* 11 */ V(7, 8, 2), + + /* 0001 0111 ... */ + /* 00 */ V(8, 7, 2), /* 316 */ + /* 01 */ V(3, 10, 2), + /* 10 */ V(10, 3, 1), + /* 11 */ V(10, 3, 1), + + /* 0001 1000 ... */ + /* 0 */ V(5, 9, 1), /* 320 */ + /* 1 */ V(9, 5, 1), + + /* 0001 1001 ... */ + /* 0 */ V(2, 10, 1), /* 322 */ + /* 1 */ V(10, 2, 1), + + /* 0001 1010 ... */ + /* 0 */ V(1, 10, 1), /* 324 */ + /* 1 */ V(10, 1, 1), + + /* 0001 1011 ... */ + /* 00 */ V(0, 10, 2), /* 326 */ + /* 01 */ V(10, 0, 2), + /* 10 */ V(6, 8, 1), + /* 11 */ V(6, 8, 1), + + /* 0001 1100 ... */ + /* 0 */ V(8, 6, 1), /* 330 */ + /* 1 */ V(4, 9, 1), + + /* 0001 1101 ... */ + /* 0 */ V(9, 4, 1), /* 332 */ + /* 1 */ V(3, 9, 1), + + /* 0001 1110 ... */ + /* 00 */ V(9, 3, 1), /* 334 */ + /* 01 */ V(9, 3, 1), + /* 10 */ V(7, 7, 2), + /* 11 */ V(0, 9, 2), + + /* 0001 1111 ... */ + /* 0 */ V(5, 8, 1), /* 338 */ + /* 1 */ V(8, 5, 1), + + /* 0010 0000 ... */ + /* 0 */ V(2, 9, 1), /* 340 */ + /* 1 */ V(6, 7, 1), + + /* 0010 0001 ... */ + /* 0 */ V(7, 6, 1), /* 342 */ + /* 1 */ V(9, 2, 1), + + /* 0010 0011 ... */ + /* 0 */ V(1, 9, 1), /* 344 */ + /* 1 */ V(9, 0, 1), + + /* 0010 0100 ... */ + /* 0 */ V(4, 8, 1), /* 346 */ + /* 1 */ V(8, 4, 1), + + /* 0010 0101 ... */ + /* 0 */ V(5, 7, 1), /* 348 */ + /* 1 */ V(7, 5, 1), + + /* 0010 0110 ... */ + /* 0 */ V(3, 8, 1), /* 350 */ + /* 1 */ V(8, 3, 1), + + /* 0010 0111 ... */ + /* 0 */ V(6, 6, 1), /* 352 */ + /* 1 */ V(4, 7, 1), + + /* 0010 1100 ... */ + /* 0 */ V(7, 4, 1), /* 354 */ + /* 1 */ V(0, 8, 1), + + /* 0010 1101 ... */ + /* 0 */ V(8, 0, 1), /* 356 */ + /* 1 */ V(5, 6, 1), + + /* 0010 1110 ... */ + /* 0 */ V(6, 5, 1), /* 358 */ + /* 1 */ V(3, 7, 1), + + /* 0010 1111 ... */ + /* 0 */ V(7, 3, 1), /* 360 */ + /* 1 */ V(4, 6, 1), + + /* 0011 0110 ... */ + /* 0 */ V(0, 7, 1), /* 362 */ + /* 1 */ V(7, 0, 1), + + /* 0011 1110 ... */ + /* 0 */ V(0, 6, 1), /* 364 */ + /* 1 */ V(6, 0, 1), + + /* 0000 0000 0000 ... */ + /* 0 */ V(15, 15, 1), /* 366 */ + /* 1 */ V(14, 15, 1), + + /* 0000 0000 0001 ... */ + /* 0 */ V(15, 14, 1), /* 368 */ + /* 1 */ V(13, 15, 1), + + /* 0000 0000 0011 ... */ + /* 0 */ V(15, 13, 1), /* 370 */ + /* 1 */ V(12, 15, 1), + + /* 0000 0000 0100 ... */ + /* 0 */ V(15, 12, 1), /* 372 */ + /* 1 */ V(13, 14, 1), + + /* 0000 0000 0101 ... */ + /* 0 */ V(14, 13, 1), /* 374 */ + /* 1 */ V(11, 15, 1), + + /* 0000 0000 0111 ... */ + /* 0 */ V(12, 14, 1), /* 376 */ + /* 1 */ V(14, 12, 1), + + /* 0000 0001 1111 ... */ + /* 0 */ V(10, 14, 1), /* 378 */ + /* 1 */ V(0, 15, 1) +}; + +static +union huffpair const hufftab16[] ICONST_ATTR_MPA_HUFFMAN = { + /* 0000 */ PTR(16, 4), + /* 0001 */ PTR(32, 4), + /* 0010 */ PTR(48, 4), + /* 0011 */ PTR(64, 2), + /* 0100 */ V(1, 1, 4), + /* 0101 */ V(0, 1, 4), + /* 0110 */ V(1, 0, 3), + /* 0111 */ V(1, 0, 3), + /* 1000 */ V(0, 0, 1), + /* 1001 */ V(0, 0, 1), + /* 1010 */ V(0, 0, 1), + /* 1011 */ V(0, 0, 1), + /* 1100 */ V(0, 0, 1), + /* 1101 */ V(0, 0, 1), + /* 1110 */ V(0, 0, 1), + /* 1111 */ V(0, 0, 1), + + /* 0000 ... */ + /* 0000 */ PTR(68, 3), /* 16 */ + /* 0001 */ PTR(76, 3), + /* 0010 */ PTR(84, 2), + /* 0011 */ V(15, 15, 4), + /* 0100 */ PTR(88, 2), + /* 0101 */ PTR(92, 1), + /* 0110 */ PTR(94, 4), + /* 0111 */ V(15, 2, 4), + /* 1000 */ PTR(110, 1), + /* 1001 */ V(1, 15, 4), + /* 1010 */ V(15, 1, 4), + /* 1011 */ PTR(112, 4), + /* 1100 */ PTR(128, 4), + /* 1101 */ PTR(144, 4), + /* 1110 */ PTR(160, 4), + /* 1111 */ PTR(176, 4), + + /* 0001 ... */ + /* 0000 */ PTR(192, 4), /* 32 */ + /* 0001 */ PTR(208, 3), + /* 0010 */ PTR(216, 3), + /* 0011 */ PTR(224, 3), + /* 0100 */ PTR(232, 3), + /* 0101 */ PTR(240, 3), + /* 0110 */ PTR(248, 3), + /* 0111 */ PTR(256, 3), + /* 1000 */ PTR(264, 2), + /* 1001 */ PTR(268, 2), + /* 1010 */ PTR(272, 1), + /* 1011 */ PTR(274, 2), + /* 1100 */ PTR(278, 2), + /* 1101 */ PTR(282, 1), + /* 1110 */ V(5, 1, 4), + /* 1111 */ PTR(284, 1), + + /* 0010 ... */ + /* 0000 */ PTR(286, 1), /* 48 */ + /* 0001 */ PTR(288, 1), + /* 0010 */ PTR(290, 1), + /* 0011 */ V(1, 4, 4), + /* 0100 */ V(4, 1, 4), + /* 0101 */ PTR(292, 1), + /* 0110 */ V(2, 3, 4), + /* 0111 */ V(3, 2, 4), + /* 1000 */ V(1, 3, 3), + /* 1001 */ V(1, 3, 3), + /* 1010 */ V(3, 1, 3), + /* 1011 */ V(3, 1, 3), + /* 1100 */ V(0, 3, 4), + /* 1101 */ V(3, 0, 4), + /* 1110 */ V(2, 2, 3), + /* 1111 */ V(2, 2, 3), + + /* 0011 ... */ + /* 00 */ V(1, 2, 2), /* 64 */ + /* 01 */ V(2, 1, 2), + /* 10 */ V(0, 2, 2), + /* 11 */ V(2, 0, 2), + + /* 0000 0000 ... */ + /* 000 */ V(14, 15, 3), /* 68 */ + /* 001 */ V(15, 14, 3), + /* 010 */ V(13, 15, 3), + /* 011 */ V(15, 13, 3), + /* 100 */ V(12, 15, 3), + /* 101 */ V(15, 12, 3), + /* 110 */ V(11, 15, 3), + /* 111 */ V(15, 11, 3), + + /* 0000 0001 ... */ + /* 000 */ V(10, 15, 2), /* 76 */ + /* 001 */ V(10, 15, 2), + /* 010 */ V(15, 10, 3), + /* 011 */ V(9, 15, 3), + /* 100 */ V(15, 9, 3), + /* 101 */ V(15, 8, 3), + /* 110 */ V(8, 15, 2), + /* 111 */ V(8, 15, 2), + + /* 0000 0010 ... */ + /* 00 */ V(7, 15, 2), /* 84 */ + /* 01 */ V(15, 7, 2), + /* 10 */ V(6, 15, 2), + /* 11 */ V(15, 6, 2), + + /* 0000 0100 ... */ + /* 00 */ V(5, 15, 2), /* 88 */ + /* 01 */ V(15, 5, 2), + /* 10 */ V(4, 15, 1), + /* 11 */ V(4, 15, 1), + + /* 0000 0101 ... */ + /* 0 */ V(15, 4, 1), /* 92 */ + /* 1 */ V(15, 3, 1), + + /* 0000 0110 ... */ + /* 0000 */ V(15, 0, 1), /* 94 */ + /* 0001 */ V(15, 0, 1), + /* 0010 */ V(15, 0, 1), + /* 0011 */ V(15, 0, 1), + /* 0100 */ V(15, 0, 1), + /* 0101 */ V(15, 0, 1), + /* 0110 */ V(15, 0, 1), + /* 0111 */ V(15, 0, 1), + /* 1000 */ V(3, 15, 2), + /* 1001 */ V(3, 15, 2), + /* 1010 */ V(3, 15, 2), + /* 1011 */ V(3, 15, 2), + /* 1100 */ PTR(294, 4), + /* 1101 */ PTR(310, 3), + /* 1110 */ PTR(318, 3), + /* 1111 */ PTR(326, 3), + + /* 0000 1000 ... */ + /* 0 */ V(2, 15, 1), /* 110 */ + /* 1 */ V(0, 15, 1), + + /* 0000 1011 ... */ + /* 0000 */ PTR(334, 2), /* 112 */ + /* 0001 */ PTR(338, 2), + /* 0010 */ PTR(342, 2), + /* 0011 */ PTR(346, 1), + /* 0100 */ PTR(348, 2), + /* 0101 */ PTR(352, 2), + /* 0110 */ PTR(356, 1), + /* 0111 */ PTR(358, 2), + /* 1000 */ PTR(362, 2), + /* 1001 */ PTR(366, 2), + /* 1010 */ PTR(370, 2), + /* 1011 */ V(14, 3, 4), + /* 1100 */ PTR(374, 1), + /* 1101 */ PTR(376, 1), + /* 1110 */ PTR(378, 1), + /* 1111 */ PTR(380, 1), + + /* 0000 1100 ... */ + /* 0000 */ PTR(382, 1), /* 128 */ + /* 0001 */ PTR(384, 1), + /* 0010 */ PTR(386, 1), + /* 0011 */ V(0, 13, 4), + /* 0100 */ PTR(388, 1), + /* 0101 */ PTR(390, 1), + /* 0110 */ PTR(392, 1), + /* 0111 */ V(3, 12, 4), + /* 1000 */ PTR(394, 1), + /* 1001 */ V(1, 12, 4), + /* 1010 */ V(12, 0, 4), + /* 1011 */ PTR(396, 1), + /* 1100 */ V(14, 2, 3), + /* 1101 */ V(14, 2, 3), + /* 1110 */ V(2, 14, 4), + /* 1111 */ V(1, 14, 4), + + /* 0000 1101 ... */ + /* 0000 */ V(13, 3, 4), /* 144 */ + /* 0001 */ V(2, 13, 4), + /* 0010 */ V(13, 2, 4), + /* 0011 */ V(13, 1, 4), + /* 0100 */ V(3, 11, 4), + /* 0101 */ PTR(398, 1), + /* 0110 */ V(1, 13, 3), + /* 0111 */ V(1, 13, 3), + /* 1000 */ V(12, 4, 4), + /* 1001 */ V(6, 11, 4), + /* 1010 */ V(12, 3, 4), + /* 1011 */ V(10, 7, 4), + /* 1100 */ V(2, 12, 3), + /* 1101 */ V(2, 12, 3), + /* 1110 */ V(12, 2, 4), + /* 1111 */ V(11, 5, 4), + + /* 0000 1110 ... */ + /* 0000 */ V(12, 1, 4), /* 160 */ + /* 0001 */ V(0, 12, 4), + /* 0010 */ V(4, 11, 4), + /* 0011 */ V(11, 4, 4), + /* 0100 */ V(6, 10, 4), + /* 0101 */ V(10, 6, 4), + /* 0110 */ V(11, 3, 3), + /* 0111 */ V(11, 3, 3), + /* 1000 */ V(5, 10, 4), + /* 1001 */ V(10, 5, 4), + /* 1010 */ V(2, 11, 3), + /* 1011 */ V(2, 11, 3), + /* 1100 */ V(11, 2, 3), + /* 1101 */ V(11, 2, 3), + /* 1110 */ V(1, 11, 3), + /* 1111 */ V(1, 11, 3), + + /* 0000 1111 ... */ + /* 0000 */ V(11, 1, 3), /* 176 */ + /* 0001 */ V(11, 1, 3), + /* 0010 */ V(0, 11, 4), + /* 0011 */ V(11, 0, 4), + /* 0100 */ V(6, 9, 4), + /* 0101 */ V(9, 6, 4), + /* 0110 */ V(4, 10, 4), + /* 0111 */ V(10, 4, 4), + /* 1000 */ V(7, 8, 4), + /* 1001 */ V(8, 7, 4), + /* 1010 */ V(10, 3, 3), + /* 1011 */ V(10, 3, 3), + /* 1100 */ V(3, 10, 4), + /* 1101 */ V(5, 9, 4), + /* 1110 */ V(2, 10, 3), + /* 1111 */ V(2, 10, 3), + + /* 0001 0000 ... */ + /* 0000 */ V(9, 5, 4), /* 192 */ + /* 0001 */ V(6, 8, 4), + /* 0010 */ V(10, 1, 3), + /* 0011 */ V(10, 1, 3), + /* 0100 */ V(8, 6, 4), + /* 0101 */ V(7, 7, 4), + /* 0110 */ V(9, 4, 3), + /* 0111 */ V(9, 4, 3), + /* 1000 */ V(4, 9, 4), + /* 1001 */ V(5, 7, 4), + /* 1010 */ V(6, 7, 3), + /* 1011 */ V(6, 7, 3), + /* 1100 */ V(10, 2, 2), + /* 1101 */ V(10, 2, 2), + /* 1110 */ V(10, 2, 2), + /* 1111 */ V(10, 2, 2), + + /* 0001 0001 ... */ + /* 000 */ V(1, 10, 2), /* 208 */ + /* 001 */ V(1, 10, 2), + /* 010 */ V(0, 10, 3), + /* 011 */ V(10, 0, 3), + /* 100 */ V(3, 9, 3), + /* 101 */ V(9, 3, 3), + /* 110 */ V(5, 8, 3), + /* 111 */ V(8, 5, 3), + + /* 0001 0010 ... */ + /* 000 */ V(2, 9, 2), /* 216 */ + /* 001 */ V(2, 9, 2), + /* 010 */ V(9, 2, 2), + /* 011 */ V(9, 2, 2), + /* 100 */ V(7, 6, 3), + /* 101 */ V(0, 9, 3), + /* 110 */ V(1, 9, 2), + /* 111 */ V(1, 9, 2), + + /* 0001 0011 ... */ + /* 000 */ V(9, 1, 2), /* 224 */ + /* 001 */ V(9, 1, 2), + /* 010 */ V(9, 0, 3), + /* 011 */ V(4, 8, 3), + /* 100 */ V(8, 4, 3), + /* 101 */ V(7, 5, 3), + /* 110 */ V(3, 8, 3), + /* 111 */ V(8, 3, 3), + + /* 0001 0100 ... */ + /* 000 */ V(6, 6, 3), /* 232 */ + /* 001 */ V(2, 8, 3), + /* 010 */ V(8, 2, 2), + /* 011 */ V(8, 2, 2), + /* 100 */ V(4, 7, 3), + /* 101 */ V(7, 4, 3), + /* 110 */ V(1, 8, 2), + /* 111 */ V(1, 8, 2), + + /* 0001 0101 ... */ + /* 000 */ V(8, 1, 2), /* 240 */ + /* 001 */ V(8, 1, 2), + /* 010 */ V(8, 0, 2), + /* 011 */ V(8, 0, 2), + /* 100 */ V(0, 8, 3), + /* 101 */ V(5, 6, 3), + /* 110 */ V(3, 7, 2), + /* 111 */ V(3, 7, 2), + + /* 0001 0110 ... */ + /* 000 */ V(7, 3, 2), /* 248 */ + /* 001 */ V(7, 3, 2), + /* 010 */ V(6, 5, 3), + /* 011 */ V(4, 6, 3), + /* 100 */ V(2, 7, 2), + /* 101 */ V(2, 7, 2), + /* 110 */ V(7, 2, 2), + /* 111 */ V(7, 2, 2), + + /* 0001 0111 ... */ + /* 000 */ V(6, 4, 3), /* 256 */ + /* 001 */ V(5, 5, 3), + /* 010 */ V(0, 7, 2), + /* 011 */ V(0, 7, 2), + /* 100 */ V(1, 7, 1), + /* 101 */ V(1, 7, 1), + /* 110 */ V(1, 7, 1), + /* 111 */ V(1, 7, 1), + + /* 0001 1000 ... */ + /* 00 */ V(7, 1, 1), /* 264 */ + /* 01 */ V(7, 1, 1), + /* 10 */ V(7, 0, 2), + /* 11 */ V(3, 6, 2), + + /* 0001 1001 ... */ + /* 00 */ V(6, 3, 2), /* 268 */ + /* 01 */ V(4, 5, 2), + /* 10 */ V(5, 4, 2), + /* 11 */ V(2, 6, 2), + + /* 0001 1010 ... */ + /* 0 */ V(6, 2, 1), /* 272 */ + /* 1 */ V(1, 6, 1), + + /* 0001 1011 ... */ + /* 00 */ V(6, 1, 1), /* 274 */ + /* 01 */ V(6, 1, 1), + /* 10 */ V(0, 6, 2), + /* 11 */ V(6, 0, 2), + + /* 0001 1100 ... */ + /* 00 */ V(5, 3, 1), /* 278 */ + /* 01 */ V(5, 3, 1), + /* 10 */ V(3, 5, 2), + /* 11 */ V(4, 4, 2), + + /* 0001 1101 ... */ + /* 0 */ V(2, 5, 1), /* 282 */ + /* 1 */ V(5, 2, 1), + + /* 0001 1111 ... */ + /* 0 */ V(1, 5, 1), /* 284 */ + /* 1 */ V(0, 5, 1), + + /* 0010 0000 ... */ + /* 0 */ V(3, 4, 1), /* 286 */ + /* 1 */ V(4, 3, 1), + + /* 0010 0001 ... */ + /* 0 */ V(5, 0, 1), /* 288 */ + /* 1 */ V(2, 4, 1), + + /* 0010 0010 ... */ + /* 0 */ V(4, 2, 1), /* 290 */ + /* 1 */ V(3, 3, 1), + + /* 0010 0101 ... */ + /* 0 */ V(0, 4, 1), /* 292 */ + /* 1 */ V(4, 0, 1), + + /* 0000 0110 1100 ... */ + /* 0000 */ V(12, 14, 4), /* 294 */ + /* 0001 */ PTR(400, 1), + /* 0010 */ V(13, 14, 3), + /* 0011 */ V(13, 14, 3), + /* 0100 */ V(14, 9, 3), + /* 0101 */ V(14, 9, 3), + /* 0110 */ V(14, 10, 4), + /* 0111 */ V(13, 9, 4), + /* 1000 */ V(14, 14, 2), + /* 1001 */ V(14, 14, 2), + /* 1010 */ V(14, 14, 2), + /* 1011 */ V(14, 14, 2), + /* 1100 */ V(14, 13, 3), + /* 1101 */ V(14, 13, 3), + /* 1110 */ V(14, 11, 3), + /* 1111 */ V(14, 11, 3), + + /* 0000 0110 1101 ... */ + /* 000 */ V(11, 14, 2), /* 310 */ + /* 001 */ V(11, 14, 2), + /* 010 */ V(12, 13, 2), + /* 011 */ V(12, 13, 2), + /* 100 */ V(13, 12, 3), + /* 101 */ V(13, 11, 3), + /* 110 */ V(10, 14, 2), + /* 111 */ V(10, 14, 2), + + /* 0000 0110 1110 ... */ + /* 000 */ V(12, 12, 2), /* 318 */ + /* 001 */ V(12, 12, 2), + /* 010 */ V(10, 13, 3), + /* 011 */ V(13, 10, 3), + /* 100 */ V(7, 14, 3), + /* 101 */ V(10, 12, 3), + /* 110 */ V(12, 10, 2), + /* 111 */ V(12, 10, 2), + + /* 0000 0110 1111 ... */ + /* 000 */ V(12, 9, 3), /* 326 */ + /* 001 */ V(7, 13, 3), + /* 010 */ V(5, 14, 2), + /* 011 */ V(5, 14, 2), + /* 100 */ V(11, 13, 1), + /* 101 */ V(11, 13, 1), + /* 110 */ V(11, 13, 1), + /* 111 */ V(11, 13, 1), + + /* 0000 1011 0000 ... */ + /* 00 */ V(9, 14, 1), /* 334 */ + /* 01 */ V(9, 14, 1), + /* 10 */ V(11, 12, 2), + /* 11 */ V(12, 11, 2), + + /* 0000 1011 0001 ... */ + /* 00 */ V(8, 14, 2), /* 338 */ + /* 01 */ V(14, 8, 2), + /* 10 */ V(9, 13, 2), + /* 11 */ V(14, 7, 2), + + /* 0000 1011 0010 ... */ + /* 00 */ V(11, 11, 2), /* 342 */ + /* 01 */ V(8, 13, 2), + /* 10 */ V(13, 8, 2), + /* 11 */ V(6, 14, 2), + + /* 0000 1011 0011 ... */ + /* 0 */ V(14, 6, 1), /* 346 */ + /* 1 */ V(9, 12, 1), + + /* 0000 1011 0100 ... */ + /* 00 */ V(10, 11, 2), /* 348 */ + /* 01 */ V(11, 10, 2), + /* 10 */ V(14, 5, 2), + /* 11 */ V(13, 7, 2), + + /* 0000 1011 0101 ... */ + /* 00 */ V(4, 14, 1), /* 352 */ + /* 01 */ V(4, 14, 1), + /* 10 */ V(14, 4, 2), + /* 11 */ V(8, 12, 2), + + /* 0000 1011 0110 ... */ + /* 0 */ V(12, 8, 1), /* 356 */ + /* 1 */ V(3, 14, 1), + + /* 0000 1011 0111 ... */ + /* 00 */ V(6, 13, 1), /* 358 */ + /* 01 */ V(6, 13, 1), + /* 10 */ V(13, 6, 2), + /* 11 */ V(9, 11, 2), + + /* 0000 1011 1000 ... */ + /* 00 */ V(11, 9, 2), /* 362 */ + /* 01 */ V(10, 10, 2), + /* 10 */ V(14, 1, 1), + /* 11 */ V(14, 1, 1), + + /* 0000 1011 1001 ... */ + /* 00 */ V(13, 4, 1), /* 366 */ + /* 01 */ V(13, 4, 1), + /* 10 */ V(11, 8, 2), + /* 11 */ V(10, 9, 2), + + /* 0000 1011 1010 ... */ + /* 00 */ V(7, 11, 1), /* 370 */ + /* 01 */ V(7, 11, 1), + /* 10 */ V(11, 7, 2), + /* 11 */ V(13, 0, 2), + + /* 0000 1011 1100 ... */ + /* 0 */ V(0, 14, 1), /* 374 */ + /* 1 */ V(14, 0, 1), + + /* 0000 1011 1101 ... */ + /* 0 */ V(5, 13, 1), /* 376 */ + /* 1 */ V(13, 5, 1), + + /* 0000 1011 1110 ... */ + /* 0 */ V(7, 12, 1), /* 378 */ + /* 1 */ V(12, 7, 1), + + /* 0000 1011 1111 ... */ + /* 0 */ V(4, 13, 1), /* 380 */ + /* 1 */ V(8, 11, 1), + + /* 0000 1100 0000 ... */ + /* 0 */ V(9, 10, 1), /* 382 */ + /* 1 */ V(6, 12, 1), + + /* 0000 1100 0001 ... */ + /* 0 */ V(12, 6, 1), /* 384 */ + /* 1 */ V(3, 13, 1), + + /* 0000 1100 0010 ... */ + /* 0 */ V(5, 12, 1), /* 386 */ + /* 1 */ V(12, 5, 1), + + /* 0000 1100 0100 ... */ + /* 0 */ V(8, 10, 1), /* 388 */ + /* 1 */ V(10, 8, 1), + + /* 0000 1100 0101 ... */ + /* 0 */ V(9, 9, 1), /* 390 */ + /* 1 */ V(4, 12, 1), + + /* 0000 1100 0110 ... */ + /* 0 */ V(11, 6, 1), /* 392 */ + /* 1 */ V(7, 10, 1), + + /* 0000 1100 1000 ... */ + /* 0 */ V(5, 11, 1), /* 394 */ + /* 1 */ V(8, 9, 1), + + /* 0000 1100 1011 ... */ + /* 0 */ V(9, 8, 1), /* 396 */ + /* 1 */ V(7, 9, 1), + + /* 0000 1101 0101 ... */ + /* 0 */ V(9, 7, 1), /* 398 */ + /* 1 */ V(8, 8, 1), + + /* 0000 0110 1100 0001 ... */ + /* 0 */ V(14, 12, 1), /* 400 */ + /* 1 */ V(13, 13, 1) +}; + +static +union huffpair const hufftab24[] ICONST_ATTR_MPA_HUFFMAN = { + /* 0000 */ PTR(16, 4), + /* 0001 */ PTR(32, 4), + /* 0010 */ PTR(48, 4), + /* 0011 */ V(15, 15, 4), + /* 0100 */ PTR(64, 4), + /* 0101 */ PTR(80, 4), + /* 0110 */ PTR(96, 4), + /* 0111 */ PTR(112, 4), + /* 1000 */ PTR(128, 4), + /* 1001 */ PTR(144, 4), + /* 1010 */ PTR(160, 3), + /* 1011 */ PTR(168, 2), + /* 1100 */ V(1, 1, 4), + /* 1101 */ V(0, 1, 4), + /* 1110 */ V(1, 0, 4), + /* 1111 */ V(0, 0, 4), + + /* 0000 ... */ + /* 0000 */ V(14, 15, 4), /* 16 */ + /* 0001 */ V(15, 14, 4), + /* 0010 */ V(13, 15, 4), + /* 0011 */ V(15, 13, 4), + /* 0100 */ V(12, 15, 4), + /* 0101 */ V(15, 12, 4), + /* 0110 */ V(11, 15, 4), + /* 0111 */ V(15, 11, 4), + /* 1000 */ V(15, 10, 3), + /* 1001 */ V(15, 10, 3), + /* 1010 */ V(10, 15, 4), + /* 1011 */ V(9, 15, 4), + /* 1100 */ V(15, 9, 3), + /* 1101 */ V(15, 9, 3), + /* 1110 */ V(15, 8, 3), + /* 1111 */ V(15, 8, 3), + + /* 0001 ... */ + /* 0000 */ V(8, 15, 4), /* 32 */ + /* 0001 */ V(7, 15, 4), + /* 0010 */ V(15, 7, 3), + /* 0011 */ V(15, 7, 3), + /* 0100 */ V(6, 15, 3), + /* 0101 */ V(6, 15, 3), + /* 0110 */ V(15, 6, 3), + /* 0111 */ V(15, 6, 3), + /* 1000 */ V(5, 15, 3), + /* 1001 */ V(5, 15, 3), + /* 1010 */ V(15, 5, 3), + /* 1011 */ V(15, 5, 3), + /* 1100 */ V(4, 15, 3), + /* 1101 */ V(4, 15, 3), + /* 1110 */ V(15, 4, 3), + /* 1111 */ V(15, 4, 3), + + /* 0010 ... */ + /* 0000 */ V(3, 15, 3), /* 48 */ + /* 0001 */ V(3, 15, 3), + /* 0010 */ V(15, 3, 3), + /* 0011 */ V(15, 3, 3), + /* 0100 */ V(2, 15, 3), + /* 0101 */ V(2, 15, 3), + /* 0110 */ V(15, 2, 3), + /* 0111 */ V(15, 2, 3), + /* 1000 */ V(15, 1, 3), + /* 1001 */ V(15, 1, 3), + /* 1010 */ V(1, 15, 4), + /* 1011 */ V(15, 0, 4), + /* 1100 */ PTR(172, 3), + /* 1101 */ PTR(180, 3), + /* 1110 */ PTR(188, 3), + /* 1111 */ PTR(196, 3), + + /* 0100 ... */ + /* 0000 */ PTR(204, 4), /* 64 */ + /* 0001 */ PTR(220, 3), + /* 0010 */ PTR(228, 3), + /* 0011 */ PTR(236, 3), + /* 0100 */ PTR(244, 2), + /* 0101 */ PTR(248, 2), + /* 0110 */ PTR(252, 2), + /* 0111 */ PTR(256, 2), + /* 1000 */ PTR(260, 2), + /* 1001 */ PTR(264, 2), + /* 1010 */ PTR(268, 2), + /* 1011 */ PTR(272, 2), + /* 1100 */ PTR(276, 2), + /* 1101 */ PTR(280, 3), + /* 1110 */ PTR(288, 2), + /* 1111 */ PTR(292, 2), + + /* 0101 ... */ + /* 0000 */ PTR(296, 2), /* 80 */ + /* 0001 */ PTR(300, 3), + /* 0010 */ PTR(308, 2), + /* 0011 */ PTR(312, 3), + /* 0100 */ PTR(320, 1), + /* 0101 */ PTR(322, 2), + /* 0110 */ PTR(326, 2), + /* 0111 */ PTR(330, 1), + /* 1000 */ PTR(332, 2), + /* 1001 */ PTR(336, 1), + /* 1010 */ PTR(338, 1), + /* 1011 */ PTR(340, 1), + /* 1100 */ PTR(342, 1), + /* 1101 */ PTR(344, 1), + /* 1110 */ PTR(346, 1), + /* 1111 */ PTR(348, 1), + + /* 0110 ... */ + /* 0000 */ PTR(350, 1), /* 96 */ + /* 0001 */ PTR(352, 1), + /* 0010 */ PTR(354, 1), + /* 0011 */ PTR(356, 1), + /* 0100 */ PTR(358, 1), + /* 0101 */ PTR(360, 1), + /* 0110 */ PTR(362, 1), + /* 0111 */ PTR(364, 1), + /* 1000 */ PTR(366, 1), + /* 1001 */ PTR(368, 1), + /* 1010 */ PTR(370, 2), + /* 1011 */ PTR(374, 1), + /* 1100 */ PTR(376, 2), + /* 1101 */ V(7, 3, 4), + /* 1110 */ PTR(380, 1), + /* 1111 */ V(7, 2, 4), + + /* 0111 ... */ + /* 0000 */ V(4, 6, 4), /* 112 */ + /* 0001 */ V(6, 4, 4), + /* 0010 */ V(5, 5, 4), + /* 0011 */ V(7, 1, 4), + /* 0100 */ V(3, 6, 4), + /* 0101 */ V(6, 3, 4), + /* 0110 */ V(4, 5, 4), + /* 0111 */ V(5, 4, 4), + /* 1000 */ V(2, 6, 4), + /* 1001 */ V(6, 2, 4), + /* 1010 */ V(1, 6, 4), + /* 1011 */ V(6, 1, 4), + /* 1100 */ PTR(382, 1), + /* 1101 */ V(3, 5, 4), + /* 1110 */ V(5, 3, 4), + /* 1111 */ V(4, 4, 4), + + /* 1000 ... */ + /* 0000 */ V(2, 5, 4), /* 128 */ + /* 0001 */ V(5, 2, 4), + /* 0010 */ V(1, 5, 4), + /* 0011 */ PTR(384, 1), + /* 0100 */ V(5, 1, 3), + /* 0101 */ V(5, 1, 3), + /* 0110 */ V(3, 4, 4), + /* 0111 */ V(4, 3, 4), + /* 1000 */ V(2, 4, 3), + /* 1001 */ V(2, 4, 3), + /* 1010 */ V(4, 2, 3), + /* 1011 */ V(4, 2, 3), + /* 1100 */ V(3, 3, 3), + /* 1101 */ V(3, 3, 3), + /* 1110 */ V(1, 4, 3), + /* 1111 */ V(1, 4, 3), + + /* 1001 ... */ + /* 0000 */ V(4, 1, 3), /* 144 */ + /* 0001 */ V(4, 1, 3), + /* 0010 */ V(0, 4, 4), + /* 0011 */ V(4, 0, 4), + /* 0100 */ V(2, 3, 3), + /* 0101 */ V(2, 3, 3), + /* 0110 */ V(3, 2, 3), + /* 0111 */ V(3, 2, 3), + /* 1000 */ V(1, 3, 2), + /* 1001 */ V(1, 3, 2), + /* 1010 */ V(1, 3, 2), + /* 1011 */ V(1, 3, 2), + /* 1100 */ V(3, 1, 2), + /* 1101 */ V(3, 1, 2), + /* 1110 */ V(3, 1, 2), + /* 1111 */ V(3, 1, 2), + + /* 1010 ... */ + /* 000 */ V(0, 3, 3), /* 160 */ + /* 001 */ V(3, 0, 3), + /* 010 */ V(2, 2, 2), + /* 011 */ V(2, 2, 2), + /* 100 */ V(1, 2, 1), + /* 101 */ V(1, 2, 1), + /* 110 */ V(1, 2, 1), + /* 111 */ V(1, 2, 1), + + /* 1011 ... */ + /* 00 */ V(2, 1, 1), /* 168 */ + /* 01 */ V(2, 1, 1), + /* 10 */ V(0, 2, 2), + /* 11 */ V(2, 0, 2), + + /* 0010 1100 ... */ + /* 000 */ V(0, 15, 1), /* 172 */ + /* 001 */ V(0, 15, 1), + /* 010 */ V(0, 15, 1), + /* 011 */ V(0, 15, 1), + /* 100 */ V(14, 14, 3), + /* 101 */ V(13, 14, 3), + /* 110 */ V(14, 13, 3), + /* 111 */ V(12, 14, 3), + + /* 0010 1101 ... */ + /* 000 */ V(14, 12, 3), /* 180 */ + /* 001 */ V(13, 13, 3), + /* 010 */ V(11, 14, 3), + /* 011 */ V(14, 11, 3), + /* 100 */ V(12, 13, 3), + /* 101 */ V(13, 12, 3), + /* 110 */ V(10, 14, 3), + /* 111 */ V(14, 10, 3), + + /* 0010 1110 ... */ + /* 000 */ V(11, 13, 3), /* 188 */ + /* 001 */ V(13, 11, 3), + /* 010 */ V(12, 12, 3), + /* 011 */ V(9, 14, 3), + /* 100 */ V(14, 9, 3), + /* 101 */ V(10, 13, 3), + /* 110 */ V(13, 10, 3), + /* 111 */ V(11, 12, 3), + + /* 0010 1111 ... */ + /* 000 */ V(12, 11, 3), /* 196 */ + /* 001 */ V(8, 14, 3), + /* 010 */ V(14, 8, 3), + /* 011 */ V(9, 13, 3), + /* 100 */ V(13, 9, 3), + /* 101 */ V(7, 14, 3), + /* 110 */ V(14, 7, 3), + /* 111 */ V(10, 12, 3), + + /* 0100 0000 ... */ + /* 0000 */ V(12, 10, 3), /* 204 */ + /* 0001 */ V(12, 10, 3), + /* 0010 */ V(11, 11, 3), + /* 0011 */ V(11, 11, 3), + /* 0100 */ V(8, 13, 3), + /* 0101 */ V(8, 13, 3), + /* 0110 */ V(13, 8, 3), + /* 0111 */ V(13, 8, 3), + /* 1000 */ V(0, 14, 4), + /* 1001 */ V(14, 0, 4), + /* 1010 */ V(0, 13, 3), + /* 1011 */ V(0, 13, 3), + /* 1100 */ V(14, 6, 2), + /* 1101 */ V(14, 6, 2), + /* 1110 */ V(14, 6, 2), + /* 1111 */ V(14, 6, 2), + + /* 0100 0001 ... */ + /* 000 */ V(6, 14, 3), /* 220 */ + /* 001 */ V(9, 12, 3), + /* 010 */ V(12, 9, 2), + /* 011 */ V(12, 9, 2), + /* 100 */ V(5, 14, 2), + /* 101 */ V(5, 14, 2), + /* 110 */ V(11, 10, 2), + /* 111 */ V(11, 10, 2), + + /* 0100 0010 ... */ + /* 000 */ V(14, 5, 2), /* 228 */ + /* 001 */ V(14, 5, 2), + /* 010 */ V(10, 11, 3), + /* 011 */ V(7, 13, 3), + /* 100 */ V(13, 7, 2), + /* 101 */ V(13, 7, 2), + /* 110 */ V(14, 4, 2), + /* 111 */ V(14, 4, 2), + + /* 0100 0011 ... */ + /* 000 */ V(8, 12, 2), /* 236 */ + /* 001 */ V(8, 12, 2), + /* 010 */ V(12, 8, 2), + /* 011 */ V(12, 8, 2), + /* 100 */ V(4, 14, 3), + /* 101 */ V(2, 14, 3), + /* 110 */ V(3, 14, 2), + /* 111 */ V(3, 14, 2), + + /* 0100 0100 ... */ + /* 00 */ V(6, 13, 2), /* 244 */ + /* 01 */ V(13, 6, 2), + /* 10 */ V(14, 3, 2), + /* 11 */ V(9, 11, 2), + + /* 0100 0101 ... */ + /* 00 */ V(11, 9, 2), /* 248 */ + /* 01 */ V(10, 10, 2), + /* 10 */ V(14, 2, 2), + /* 11 */ V(1, 14, 2), + + /* 0100 0110 ... */ + /* 00 */ V(14, 1, 2), /* 252 */ + /* 01 */ V(5, 13, 2), + /* 10 */ V(13, 5, 2), + /* 11 */ V(7, 12, 2), + + /* 0100 0111 ... */ + /* 00 */ V(12, 7, 2), /* 256 */ + /* 01 */ V(4, 13, 2), + /* 10 */ V(8, 11, 2), + /* 11 */ V(11, 8, 2), + + /* 0100 1000 ... */ + /* 00 */ V(13, 4, 2), /* 260 */ + /* 01 */ V(9, 10, 2), + /* 10 */ V(10, 9, 2), + /* 11 */ V(6, 12, 2), + + /* 0100 1001 ... */ + /* 00 */ V(12, 6, 2), /* 264 */ + /* 01 */ V(3, 13, 2), + /* 10 */ V(13, 3, 2), + /* 11 */ V(2, 13, 2), + + /* 0100 1010 ... */ + /* 00 */ V(13, 2, 2), /* 268 */ + /* 01 */ V(1, 13, 2), + /* 10 */ V(7, 11, 2), + /* 11 */ V(11, 7, 2), + + /* 0100 1011 ... */ + /* 00 */ V(13, 1, 2), /* 272 */ + /* 01 */ V(5, 12, 2), + /* 10 */ V(12, 5, 2), + /* 11 */ V(8, 10, 2), + + /* 0100 1100 ... */ + /* 00 */ V(10, 8, 2), /* 276 */ + /* 01 */ V(9, 9, 2), + /* 10 */ V(4, 12, 2), + /* 11 */ V(12, 4, 2), + + /* 0100 1101 ... */ + /* 000 */ V(6, 11, 2), /* 280 */ + /* 001 */ V(6, 11, 2), + /* 010 */ V(11, 6, 2), + /* 011 */ V(11, 6, 2), + /* 100 */ V(13, 0, 3), + /* 101 */ V(0, 12, 3), + /* 110 */ V(3, 12, 2), + /* 111 */ V(3, 12, 2), + + /* 0100 1110 ... */ + /* 00 */ V(12, 3, 2), /* 288 */ + /* 01 */ V(7, 10, 2), + /* 10 */ V(10, 7, 2), + /* 11 */ V(2, 12, 2), + + /* 0100 1111 ... */ + /* 00 */ V(12, 2, 2), /* 292 */ + /* 01 */ V(5, 11, 2), + /* 10 */ V(11, 5, 2), + /* 11 */ V(1, 12, 2), + + /* 0101 0000 ... */ + /* 00 */ V(8, 9, 2), /* 296 */ + /* 01 */ V(9, 8, 2), + /* 10 */ V(12, 1, 2), + /* 11 */ V(4, 11, 2), + + /* 0101 0001 ... */ + /* 000 */ V(12, 0, 3), /* 300 */ + /* 001 */ V(0, 11, 3), + /* 010 */ V(3, 11, 2), + /* 011 */ V(3, 11, 2), + /* 100 */ V(11, 0, 3), + /* 101 */ V(0, 10, 3), + /* 110 */ V(1, 10, 2), + /* 111 */ V(1, 10, 2), + + /* 0101 0010 ... */ + /* 00 */ V(11, 4, 1), /* 308 */ + /* 01 */ V(11, 4, 1), + /* 10 */ V(6, 10, 2), + /* 11 */ V(10, 6, 2), + + /* 0101 0011 ... */ + /* 000 */ V(7, 9, 2), /* 312 */ + /* 001 */ V(7, 9, 2), + /* 010 */ V(9, 7, 2), + /* 011 */ V(9, 7, 2), + /* 100 */ V(10, 0, 3), + /* 101 */ V(0, 9, 3), + /* 110 */ V(9, 0, 2), + /* 111 */ V(9, 0, 2), + + /* 0101 0100 ... */ + /* 0 */ V(11, 3, 1), /* 320 */ + /* 1 */ V(8, 8, 1), + + /* 0101 0101 ... */ + /* 00 */ V(2, 11, 2), /* 322 */ + /* 01 */ V(5, 10, 2), + /* 10 */ V(11, 2, 1), + /* 11 */ V(11, 2, 1), + + /* 0101 0110 ... */ + /* 00 */ V(10, 5, 2), /* 326 */ + /* 01 */ V(1, 11, 2), + /* 10 */ V(11, 1, 2), + /* 11 */ V(6, 9, 2), + + /* 0101 0111 ... */ + /* 0 */ V(9, 6, 1), /* 330 */ + /* 1 */ V(10, 4, 1), + + /* 0101 1000 ... */ + /* 00 */ V(4, 10, 2), /* 332 */ + /* 01 */ V(7, 8, 2), + /* 10 */ V(8, 7, 1), + /* 11 */ V(8, 7, 1), + + /* 0101 1001 ... */ + /* 0 */ V(3, 10, 1), /* 336 */ + /* 1 */ V(10, 3, 1), + + /* 0101 1010 ... */ + /* 0 */ V(5, 9, 1), /* 338 */ + /* 1 */ V(9, 5, 1), + + /* 0101 1011 ... */ + /* 0 */ V(2, 10, 1), /* 340 */ + /* 1 */ V(10, 2, 1), + + /* 0101 1100 ... */ + /* 0 */ V(10, 1, 1), /* 342 */ + /* 1 */ V(6, 8, 1), + + /* 0101 1101 ... */ + /* 0 */ V(8, 6, 1), /* 344 */ + /* 1 */ V(7, 7, 1), + + /* 0101 1110 ... */ + /* 0 */ V(4, 9, 1), /* 346 */ + /* 1 */ V(9, 4, 1), + + /* 0101 1111 ... */ + /* 0 */ V(3, 9, 1), /* 348 */ + /* 1 */ V(9, 3, 1), + + /* 0110 0000 ... */ + /* 0 */ V(5, 8, 1), /* 350 */ + /* 1 */ V(8, 5, 1), + + /* 0110 0001 ... */ + /* 0 */ V(2, 9, 1), /* 352 */ + /* 1 */ V(6, 7, 1), + + /* 0110 0010 ... */ + /* 0 */ V(7, 6, 1), /* 354 */ + /* 1 */ V(9, 2, 1), + + /* 0110 0011 ... */ + /* 0 */ V(1, 9, 1), /* 356 */ + /* 1 */ V(9, 1, 1), + + /* 0110 0100 ... */ + /* 0 */ V(4, 8, 1), /* 358 */ + /* 1 */ V(8, 4, 1), + + /* 0110 0101 ... */ + /* 0 */ V(5, 7, 1), /* 360 */ + /* 1 */ V(7, 5, 1), + + /* 0110 0110 ... */ + /* 0 */ V(3, 8, 1), /* 362 */ + /* 1 */ V(8, 3, 1), + + /* 0110 0111 ... */ + /* 0 */ V(6, 6, 1), /* 364 */ + /* 1 */ V(2, 8, 1), + + /* 0110 1000 ... */ + /* 0 */ V(8, 2, 1), /* 366 */ + /* 1 */ V(1, 8, 1), + + /* 0110 1001 ... */ + /* 0 */ V(4, 7, 1), /* 368 */ + /* 1 */ V(7, 4, 1), + + /* 0110 1010 ... */ + /* 00 */ V(8, 1, 1), /* 370 */ + /* 01 */ V(8, 1, 1), + /* 10 */ V(0, 8, 2), + /* 11 */ V(8, 0, 2), + + /* 0110 1011 ... */ + /* 0 */ V(5, 6, 1), /* 374 */ + /* 1 */ V(6, 5, 1), + + /* 0110 1100 ... */ + /* 00 */ V(1, 7, 1), /* 376 */ + /* 01 */ V(1, 7, 1), + /* 10 */ V(0, 7, 2), + /* 11 */ V(7, 0, 2), + + /* 0110 1110 ... */ + /* 0 */ V(3, 7, 1), /* 380 */ + /* 1 */ V(2, 7, 1), + + /* 0111 1100 ... */ + /* 0 */ V(0, 6, 1), /* 382 */ + /* 1 */ V(6, 0, 1), + + /* 1000 0011 ... */ + /* 0 */ V(0, 5, 1), /* 384 */ + /* 1 */ V(5, 0, 1) +}; + +# undef V +# undef PTR + +/* external tables */ + +union huffquad const *const mad_huff_quad_table[2] = { hufftabA, hufftabB }; + +struct hufftable const mad_huff_pair_table[32] = { + /* 0 */ { hufftab0, 0, 0 }, + /* 1 */ { hufftab1, 0, 3 }, + /* 2 */ { hufftab2, 0, 3 }, + /* 3 */ { hufftab3, 0, 3 }, + /* 4 */ { hufftab0, 0, 0 }, /* not used */ + /* 5 */ { hufftab5, 0, 3 }, + /* 6 */ { hufftab6, 0, 4 }, + /* 7 */ { hufftab7, 0, 4 }, + /* 8 */ { hufftab8, 0, 4 }, + /* 9 */ { hufftab9, 0, 4 }, + /* 10 */ { hufftab10, 0, 4 }, + /* 11 */ { hufftab11, 0, 4 }, + /* 12 */ { hufftab12, 0, 4 }, + /* 13 */ { hufftab13, 0, 4 }, + /* 14 */ { hufftab0, 0, 0 }, /* not used */ + /* 15 */ { hufftab15, 0, 4 }, + /* 16 */ { hufftab16, 1, 4 }, + /* 17 */ { hufftab16, 2, 4 }, + /* 18 */ { hufftab16, 3, 4 }, + /* 19 */ { hufftab16, 4, 4 }, + /* 20 */ { hufftab16, 6, 4 }, + /* 21 */ { hufftab16, 8, 4 }, + /* 22 */ { hufftab16, 10, 4 }, + /* 23 */ { hufftab16, 13, 4 }, + /* 24 */ { hufftab24, 4, 4 }, + /* 25 */ { hufftab24, 5, 4 }, + /* 26 */ { hufftab24, 6, 4 }, + /* 27 */ { hufftab24, 7, 4 }, + /* 28 */ { hufftab24, 8, 4 }, + /* 29 */ { hufftab24, 9, 4 }, + /* 30 */ { hufftab24, 11, 4 }, + /* 31 */ { hufftab24, 13, 4 } +}; diff --git a/lib/rbcodec/codecs/libmad/huffman.h b/lib/rbcodec/codecs/libmad/huffman.h new file mode 100644 index 0000000000..e4c1b35d93 --- /dev/null +++ b/lib/rbcodec/codecs/libmad/huffman.h @@ -0,0 +1,66 @@ +/* + * libmad - MPEG audio decoder library + * Copyright (C) 2000-2004 Underbit Technologies, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * $Id$ + */ + +# ifndef LIBMAD_HUFFMAN_H +# define LIBMAD_HUFFMAN_H + +union huffquad { + struct { + unsigned short final : 1; + unsigned short bits : 3; + unsigned short offset : 12; + } ptr; + struct { + unsigned short final : 1; + unsigned short hlen : 3; + unsigned short v : 1; + unsigned short w : 1; + unsigned short x : 1; + unsigned short y : 1; + } value; + unsigned short final : 1; +}; + +union huffpair { + struct { + unsigned short final : 1; + unsigned short bits : 3; + unsigned short offset : 12; + } ptr; + struct { + unsigned short final : 1; + unsigned short hlen : 3; + unsigned short x : 4; + unsigned short y : 4; + } value; + unsigned short final : 1; +}; + +struct hufftable { + union huffpair const *table; + unsigned short linbits; + unsigned short startbits; +}; + +extern union huffquad const *const mad_huff_quad_table[2]; +extern struct hufftable const mad_huff_pair_table[32]; + +# endif diff --git a/lib/rbcodec/codecs/libmad/imdct_l_arm.S b/lib/rbcodec/codecs/libmad/imdct_l_arm.S new file mode 100644 index 0000000000..b511ff169d --- /dev/null +++ b/lib/rbcodec/codecs/libmad/imdct_l_arm.S @@ -0,0 +1,1001 @@ +/***************************************************************************** +* Copyright (C) 2000-2001 Andre McCurdy +* +* This program is free software. you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation@ either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY, without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program@ if not, write to the Free Software +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +* +***************************************************************************** +* +* Notes: +* +* +***************************************************************************** +* +* $Id$ +* +* 2001/03/24: Andre McCurdy +* - Corrected PIC unsafe loading of address of 'imdct36_long_karray' +* +* 2000/09/20: Robert Leslie +* - Added a global symbol with leading underscore per suggestion of +* Simon Burge to support linking with the a.out format. +* +* 2000/09/15: Robert Leslie +* - Fixed a small bug where flags were changed before a conditional branch. +* +* 2000/09/15: Andre McCurdy +* - Applied Nicolas Pitre's rounding optimisation in all remaining places. +* +* 2000/09/09: Nicolas Pitre +* - Optimized rounding + scaling operations. +* +* 2000/08/09: Andre McCurdy +* - Original created. +* +****************************************************************************/ + +#include "config.h" + +/* + On entry: + + r0 = pointer to 18 element input array + r1 = pointer to 36 element output array + r2 = windowing block type + + + Stack frame created during execution of the function: + + Initial Holds: + Stack + pointer + minus: + + 0 + 4 lr + 8 r11 + 12 r10 + 16 r9 + 20 r8 + 24 r7 + 28 r6 + 32 r5 + 36 r4 + + 40 r2 : windowing block type + + 44 ct00 high + 48 ct00 low + 52 ct01 high + 56 ct01 low + 60 ct04 high + 64 ct04 low + 68 ct06 high + 72 ct06 low + 76 ct05 high + 80 ct05 low + 84 ct03 high + 88 ct03 low + 92 -ct05 high + 96 -ct05 low + 100 -ct07 high + 104 -ct07 low + 108 ct07 high + 112 ct07 low + 116 ct02 high + 120 ct02 low +*/ + +#define BLOCK_MODE_NORMAL 0 +#define BLOCK_MODE_START 1 +#define BLOCK_MODE_STOP 3 + + +#define X0 0x00 +#define X1 0x04 +#define X2 0x08 +#define X3 0x0C +#define X4 0x10 +#define X5 0x14 +#define X6 0x18 +#define X7 0x1c +#define X8 0x20 +#define X9 0x24 +#define X10 0x28 +#define X11 0x2c +#define X12 0x30 +#define X13 0x34 +#define X14 0x38 +#define X15 0x3c +#define X16 0x40 +#define X17 0x44 + +#define x0 0x00 +#define x1 0x04 +#define x2 0x08 +#define x3 0x0C +#define x4 0x10 +#define x5 0x14 +#define x6 0x18 +#define x7 0x1c +#define x8 0x20 +#define x9 0x24 +#define x10 0x28 +#define x11 0x2c +#define x12 0x30 +#define x13 0x34 +#define x14 0x38 +#define x15 0x3c +#define x16 0x40 +#define x17 0x44 +#define x18 0x48 +#define x19 0x4c +#define x20 0x50 +#define x21 0x54 +#define x22 0x58 +#define x23 0x5c +#define x24 0x60 +#define x25 0x64 +#define x26 0x68 +#define x27 0x6c +#define x28 0x70 +#define x29 0x74 +#define x30 0x78 +#define x31 0x7c +#define x32 0x80 +#define x33 0x84 +#define x34 0x88 +#define x35 0x8c + +#define K00 0x0ffc19fd +#define K01 0x00b2aa3e +#define K02 0x0fdcf549 +#define K03 0x0216a2a2 +#define K04 0x0f9ee890 +#define K05 0x03768962 +#define K06 0x0f426cb5 +#define K07 0x04cfb0e2 +#define K08 0x0ec835e8 +#define K09 0x061f78aa +#define K10 0x0e313245 +#define K11 0x07635284 +#define K12 0x0d7e8807 +#define K13 0x0898c779 +#define K14 0x0cb19346 +#define K15 0x09bd7ca0 +#define K16 0x0bcbe352 +#define K17 0x0acf37ad + +#define minus_K02 0xf0230ab7 + +#define WL0 0x00b2aa3e +#define WL1 0x0216a2a2 +#define WL2 0x03768962 +#define WL3 0x04cfb0e2 +#define WL4 0x061f78aa +#define WL5 0x07635284 +#define WL6 0x0898c779 +#define WL7 0x09bd7ca0 +#define WL8 0x0acf37ad +#define WL9 0x0bcbe352 +#define WL10 0x0cb19346 +#define WL11 0x0d7e8807 +#define WL12 0x0e313245 +#define WL13 0x0ec835e8 +#define WL14 0x0f426cb5 +#define WL15 0x0f9ee890 +#define WL16 0x0fdcf549 +#define WL17 0x0ffc19fd + + +@***************************************************************************** + + + .text + .align + + .global III_imdct_l + .global _III_imdct_l + +III_imdct_l: +_III_imdct_l: + + stmdb sp!, { r2, r4 - r11, lr } @ all callee saved regs, plus arg3 + + ldr r4, =K08 @ r4 = K08 + ldr r5, =K09 @ r5 = K09 + ldr r8, [r0, #X4] @ r8 = X4 + ldr r9, [r0, #X13] @ r9 = X13 + rsb r6, r4, #0 @ r6 = -K08 + rsb r7, r5, #0 @ r7 = -K09 + + smull r2, r3, r4, r8 @ r2..r3 = (X4 * K08) + smlal r2, r3, r5, r9 @ r2..r3 = (X4 * K08) + (X13 * K09) = ct01 + + smull r10, lr, r8, r5 @ r10..lr = (X4 * K09) + smlal r10, lr, r9, r6 @ r10..lr = (X4 * K09) + (X13 * -K08) = ct00 + + ldr r8, [r0, #X7] @ r8 = X7 + ldr r9, [r0, #X16] @ r9 = X16 + + stmdb sp!, { r2, r3, r10, lr } @ stack ct00_h, ct00_l, ct01_h, ct01_l + + add r8, r8, r9 @ r8 = (X7 + X16) + ldr r9, [r0, #X1] @ r9 = X1 + + smlal r2, r3, r6, r8 @ r2..r3 = ct01 + ((X7 + X16) * -K08) + smlal r2, r3, r7, r9 @ r2..r3 += (X1 * -K09) + + ldr r7, [r0, #X10] @ r7 = X10 + + rsbs r10, r10, #0 + rsc lr, lr, #0 @ r10..lr = -ct00 + + smlal r2, r3, r5, r7 @ r2..r3 += (X10 * K09) = ct06 + + smlal r10, lr, r9, r6 @ r10..lr = -ct00 + ( X1 * -K08) + smlal r10, lr, r8, r5 @ r10..lr += ((X7 + X16) * K09) + smlal r10, lr, r7, r4 @ r10..lr += ( X10 * K08) = ct04 + + stmdb sp!, { r2, r3, r10, lr } @ stack ct04_h, ct04_l, ct06_h, ct06_l + + @---- + + ldr r7, [r0, #X0] + ldr r8, [r0, #X11] + ldr r9, [r0, #X12] + sub r7, r7, r8 + sub r7, r7, r9 @ r7 = (X0 - X11 -X12) = ct14 + + ldr r9, [r0, #X3] + ldr r8, [r0, #X8] + ldr r11, [r0, #X15] + sub r8, r8, r9 + add r8, r8, r11 @ r8 = (X8 - X3 + X15) = ct16 + + add r11, r7, r8 @ r11 = ct14 + ct16 = ct18 + + smlal r2, r3, r6, r11 @ r2..r3 = ct06 + ((X0 - X11 - X3 + X15 + X8 - X12) * -K08) + + ldr r6, [r0, #X2] + ldr r9, [r0, #X9] + ldr r12, [r0, #X14] + sub r6, r6, r9 + sub r6, r6, r12 @ r6 = (X2 - X9 - X14) = ct15 + + ldr r9, [r0, #X5] + ldr r12, [r0, #X6] + sub r9, r9, r12 + ldr r12, [r0, #X17] + sub r9, r9, r12 @ r9 = (X5 - X6 - X17) = ct17 + + add r12, r9, r6 @ r12 = ct15 + ct17 = ct19 + + smlal r2, r3, r5, r12 @ r2..r3 += ((X2 - X9 + X5 - X6 - X17 - X14) * K09) + + smlal r10, lr, r11, r5 @ r10..lr = ct04 + (ct18 * K09) + smlal r10, lr, r12, r4 @ r10..lr = ct04 + (ct18 * K09) + (ct19 * K08) + + movs r2, r2, lsr #28 + adc r2, r2, r3, lsl #4 @ r2 = bits[59..28] of r2..r3 + str r2, [r1, #x22] @ store result x22 + + movs r10, r10, lsr #28 + adc r10, r10, lr, lsl #4 @ r10 = bits[59..28] of r10..lr + str r10, [r1, #x4] @ store result x4 + + @---- + + ldmia sp, { r2, r3, r4, r5 } @ r2..r3 = ct06, r4..r5 = ct04 (dont update sp) + + @ r2..r3 = ct06 + @ r4..r5 = ct04 + @ r6 = ct15 + @ r7 = ct14 + @ r8 = ct16 + @ r9 = ct17 + @ r10 = . + @ r11 = . + @ r12 = . + @ lr = . + + ldr r10, =K03 @ r10 = K03 + ldr lr, =K15 @ lr = K15 + + smlal r2, r3, r10, r7 @ r2..r3 = ct06 + (ct14 * K03) + smlal r4, r5, lr, r7 @ r4..r5 = ct04 + (ct14 * K15) + + ldr r12, =K14 @ r12 = K14 + rsb r10, r10, #0 @ r10 = -K03 + + smlal r2, r3, lr, r6 @ r2..r3 += (ct15 * K15) + smlal r4, r5, r10, r6 @ r4..r5 += (ct15 * -K03) + smlal r2, r3, r12, r8 @ r2..r3 += (ct16 * K14) + + ldr r11, =minus_K02 @ r11 = -K02 + rsb r12, r12, #0 @ r12 = -K14 + + smlal r4, r5, r12, r9 @ r4..r5 += (ct17 * -K14) + smlal r2, r3, r11, r9 @ r2..r3 += (ct17 * -K02) + smlal r4, r5, r11, r8 @ r4..r5 += (ct16 * -K02) + + movs r2, r2, lsr #28 + adc r2, r2, r3, lsl #4 @ r2 = bits[59..28] of r2..r3 + str r2, [r1, #x7] @ store result x7 + + movs r4, r4, lsr #28 + adc r4, r4, r5, lsl #4 @ r4 = bits[59..28] of r4..r5 + str r4, [r1, #x1] @ store result x1 + + @---- + + ldmia sp, { r2, r3, r4, r5 } @ r2..r3 = ct06, r4..r5 = ct04 (dont update sp) + + @ r2..r3 = ct06 + @ r4..r5 = ct04 + @ r6 = ct15 + @ r7 = ct14 + @ r8 = ct16 + @ r9 = ct17 + @ r10 = -K03 + @ r11 = -K02 + @ r12 = -K14 + @ lr = K15 + + rsbs r2, r2, #0 + rsc r3, r3, #0 @ r2..r3 = -ct06 + + smlal r2, r3, r12, r7 @ r2..r3 = -ct06 + (ct14 * -K14) + smlal r2, r3, r10, r8 @ r2..r3 += (ct16 * -K03) + + smlal r4, r5, r12, r6 @ r4..r5 = ct04 + (ct15 * -K14) + smlal r4, r5, r10, r9 @ r4..r5 += (ct17 * -K03) + smlal r4, r5, lr, r8 @ r4..r5 += (ct16 * K15) + smlal r4, r5, r11, r7 @ r4..r5 += (ct14 * -K02) + + rsb lr, lr, #0 @ lr = -K15 + rsb r11, r11, #0 @ r11 = K02 + + smlal r2, r3, lr, r9 @ r2..r3 += (ct17 * -K15) + smlal r2, r3, r11, r6 @ r2..r3 += (ct15 * K02) + + movs r4, r4, lsr #28 + adc r4, r4, r5, lsl #4 @ r4 = bits[59..28] of r4..r5 + str r4, [r1, #x25] @ store result x25 + + movs r2, r2, lsr #28 + adc r2, r2, r3, lsl #4 @ r2 = bits[59..28] of r2..r3 + str r2, [r1, #x19] @ store result x19 + + @---- + + ldr r2, [sp, #16] @ r2 = ct01_l + ldr r3, [sp, #20] @ r3 = ct01_h + + ldr r6, [r0, #X1] + ldr r8, [r0, #X7] + ldr r9, [r0, #X10] + ldr r7, [r0, #X16] + + rsbs r2, r2, #0 + rsc r3, r3, #0 @ r2..r3 = -ct01 + + mov r4, r2 + mov r5, r3 @ r4..r5 = -ct01 + + @ r2..r3 = -ct01 + @ r4..r5 = -ct01 + @ r6 = X1 + @ r7 = X16 + @ r8 = X7 + @ r9 = X10 + @ r10 = -K03 + @ r11 = K02 + @ r12 = -K14 + @ lr = -K15 + + smlal r4, r5, r12, r7 @ r4..r5 = -ct01 + (X16 * -K14) + smlal r2, r3, lr, r9 @ r2..r3 = -ct01 + (X10 * -K15) + + smlal r4, r5, r10, r8 @ r4..r5 += (X7 * -K03) + smlal r2, r3, r10, r7 @ r2..r3 += (X16 * -K03) + + smlal r4, r5, r11, r9 @ r4..r5 += (X10 * K02) + smlal r2, r3, r12, r8 @ r2..r3 += (X7 * -K14) + + rsb lr, lr, #0 @ lr = K15 + rsb r11, r11, #0 @ r11 = -K02 + + smlal r4, r5, lr, r6 @ r4..r5 += (X1 * K15) = ct05 + smlal r2, r3, r11, r6 @ r2..r3 += (X1 * -K02) = ct03 + + stmdb sp!, { r2, r3, r4, r5 } @ stack ct05_h, ct05_l, ct03_h, ct03_l + + rsbs r4, r4, #0 + rsc r5, r5, #0 @ r4..r5 = -ct05 + + stmdb sp!, { r4, r5 } @ stack -ct05_h, -ct05_l + + ldr r2, [sp, #48] @ r2 = ct00_l + ldr r3, [sp, #52] @ r3 = ct00_h + + rsb r10, r10, #0 @ r10 = K03 + + rsbs r4, r2, #0 + rsc r5, r3, #0 @ r4..r5 = -ct00 + + @ r2..r3 = ct00 + @ r4..r5 = -ct00 + @ r6 = X1 + @ r7 = X16 + @ r8 = X7 + @ r9 = X10 + @ r10 = K03 + @ r11 = -K02 + @ r12 = -K14 + @ lr = K15 + + smlal r4, r5, r10, r6 @ r4..r5 = -ct00 + (X1 * K03) + smlal r2, r3, r10, r9 @ r2..r3 = ct00 + (X10 * K03) + + smlal r4, r5, r12, r9 @ r4..r5 += (X10 * -K14) + smlal r2, r3, r12, r6 @ r2..r3 += (X1 * -K14) + + smlal r4, r5, r11, r7 @ r4..r5 += (X16 * -K02) + smlal r4, r5, lr, r8 @ r4..r5 += (X7 * K15) = ct07 + + rsb lr, lr, #0 @ lr = -K15 + rsb r11, r11, #0 @ r11 = K02 + + smlal r2, r3, r11, r8 @ r2..r3 += (X7 * K02) + smlal r2, r3, lr, r7 @ r2..r3 += (X16 * -K15) = ct02 + + rsbs r6, r4, #0 + rsc r7, r5, #0 @ r6..r7 = -ct07 + + stmdb sp!, { r2 - r7 } @ stack -ct07_h, -ct07_l, ct07_h, ct07_l, ct02_h, ct02_l + + + @---- + + add r2, pc, #(imdct36_long_karray-.-8) @ r2 = base address of Knn array (PIC safe ?) + + +loop: + ldr r12, [r0, #X0] + + ldmia r2!, { r5 - r11 } @ first 7 words from Karray element + + smull r3, r4, r5, r12 @ sum = (Kxx * X0) + ldr r12, [r0, #X2] + ldr r5, [r0, #X3] + smlal r3, r4, r6, r12 @ sum += (Kxx * X2) + ldr r12, [r0, #X5] + ldr r6, [r0, #X6] + smlal r3, r4, r7, r5 @ sum += (Kxx * X3) + smlal r3, r4, r8, r12 @ sum += (Kxx * X5) + ldr r12, [r0, #X8] + ldr r5, [r0, #X9] + smlal r3, r4, r9, r6 @ sum += (Kxx * X6) + smlal r3, r4, r10, r12 @ sum += (Kxx * X8) + smlal r3, r4, r11, r5 @ sum += (Kxx * X9) + + ldmia r2!, { r5 - r10 } @ final 6 words from Karray element + + ldr r11, [r0, #X11] + ldr r12, [r0, #X12] + smlal r3, r4, r5, r11 @ sum += (Kxx * X11) + ldr r11, [r0, #X14] + ldr r5, [r0, #X15] + smlal r3, r4, r6, r12 @ sum += (Kxx * X12) + smlal r3, r4, r7, r11 @ sum += (Kxx * X14) + ldr r11, [r0, #X17] + smlal r3, r4, r8, r5 @ sum += (Kxx * X15) + smlal r3, r4, r9, r11 @ sum += (Kxx * X17) + + add r5, sp, r10, lsr #16 @ create index back into stack for required ctxx + + ldmia r5, { r6, r7 } @ r6..r7 = ctxx + + mov r8, r10, lsl #16 @ push ctxx index off the top end + + adds r3, r3, r6 @ add low words + adc r4, r4, r7 @ add high words, with carry + movs r3, r3, lsr #28 + adc r3, r3, r4, lsl #4 @ r3 = bits[59..28] of r3..r4 + + str r3, [r1, r8, lsr #24] @ push completion flag off the bottom end + + movs r8, r8, lsl #8 @ push result location index off the top end + beq loop @ loop back if completion flag not set + b imdct_l_windowing @ branch to windowing stage if looping finished + +imdct36_long_karray: + + .word K17, -K13, K10, -K06, -K05, K01, -K00, K04, -K07, K11, K12, -K16, 0x00000000 + .word K13, K07, K16, K01, K10, -K05, K04, -K11, K00, -K17, K06, -K12, 0x00200800 + .word K11, K17, K05, K12, -K01, K06, -K07, K00, -K13, K04, -K16, K10, 0x00200c00 + .word K07, K00, -K12, K05, -K16, -K10, K11, -K17, K04, K13, K01, K06, 0x00001400 + .word K05, K10, -K00, -K17, K07, -K13, K12, K06, -K16, K01, -K11, -K04, 0x00181800 + .word K01, K05, -K07, -K11, K13, K17, -K16, -K12, K10, K06, -K04, -K00, 0x00102000 + .word -K16, K12, -K11, K07, K04, -K00, -K01, K05, -K06, K10, K13, -K17, 0x00284800 + .word -K12, K06, K17, -K00, -K11, K04, K05, -K10, K01, K16, -K07, -K13, 0x00085000 + .word -K10, K16, K04, -K13, -K00, K07, K06, -K01, -K12, -K05, K17, K11, 0x00105400 + .word -K06, -K01, K13, K04, K17, -K11, -K10, -K16, -K05, K12, K00, K07, 0x00185c00 + .word -K04, -K11, -K01, K16, K06, K12, K13, -K07, -K17, -K00, -K10, -K05, 0x00006000 + .word -K00, -K04, -K06, -K10, -K12, -K16, -K17, -K13, -K11, -K07, -K05, -K01, 0x00206801 + + + @---- + @------------------------------------------------------------------------- + @---- + +imdct_l_windowing: + + ldr r11, [sp, #80] @ fetch function parameter 3 from out of the stack + ldmia r1!, { r0, r2 - r9 } @ load 9 words from x0, update pointer + + @ r0 = x0 + @ r1 = &x[9] + @ r2 = x1 + @ r3 = x2 + @ r4 = x3 + @ r5 = x4 + @ r6 = x5 + @ r7 = x6 + @ r8 = x7 + @ r9 = x8 + @ r10 = . + @ r11 = window mode: (0 == normal), (1 == start block), (3 == stop block) + @ r12 = . + @ lr = . + + cmp r11, #BLOCK_MODE_STOP @ setup flags + rsb r10, r0, #0 @ r10 = -x0 (DONT change flags !!) + beq stop_block_x0_to_x17 + + + @ start and normal blocks are treated the same for x[0]..x[17] + +normal_block_x0_to_x17: + + ldr r12, =WL9 @ r12 = window_l[9] + + rsb r0, r9, #0 @ r0 = -x8 + rsb r9, r2, #0 @ r9 = -x1 + rsb r2, r8, #0 @ r2 = -x7 + rsb r8, r3, #0 @ r8 = -x2 + rsb r3, r7, #0 @ r3 = -x6 + rsb r7, r4, #0 @ r7 = -x3 + rsb r4, r6, #0 @ r4 = -x5 + rsb r6, r5, #0 @ r6 = -x4 + + @ r0 = -x8 + @ r1 = &x[9] + @ r2 = -x7 + @ r3 = -x6 + @ r4 = -x5 + @ r5 = . + @ r6 = -x4 + @ r7 = -x3 + @ r8 = -x2 + @ r9 = -x1 + @ r10 = -x0 + @ r11 = window mode: (0 == normal), (1 == start block), (3 == stop block) + @ r12 = window_l[9] + @ lr = . + + smull r5, lr, r12, r0 @ r5..lr = (window_l[9] * (x[9] == -x[8])) + ldr r12, =WL10 @ r12 = window_l[10] + movs r5, r5, lsr #28 + adc r0, r5, lr, lsl #4 @ r0 = bits[59..28] of windowed x9 + + smull r5, lr, r12, r2 @ r5..lr = (window_l[10] * (x[10] == -x[7])) + ldr r12, =WL11 @ r12 = window_l[11] + movs r5, r5, lsr #28 + adc r2, r5, lr, lsl #4 @ r2 = bits[59..28] of windowed x10 + + smull r5, lr, r12, r3 @ r5..lr = (window_l[11] * (x[11] == -x[6])) + ldr r12, =WL12 @ r12 = window_l[12] + movs r5, r5, lsr #28 + adc r3, r5, lr, lsl #4 @ r3 = bits[59..28] of windowed x11 + + smull r5, lr, r12, r4 @ r5..lr = (window_l[12] * (x[12] == -x[5])) + ldr r12, =WL13 @ r12 = window_l[13] + movs r5, r5, lsr #28 + adc r4, r5, lr, lsl #4 @ r4 = bits[59..28] of windowed x12 + + smull r5, lr, r12, r6 @ r5..lr = (window_l[13] * (x[13] == -x[4])) + ldr r12, =WL14 @ r12 = window_l[14] + movs r5, r5, lsr #28 + adc r6, r5, lr, lsl #4 @ r6 = bits[59..28] of windowed x13 + + smull r5, lr, r12, r7 @ r5..lr = (window_l[14] * (x[14] == -x[3])) + ldr r12, =WL15 @ r12 = window_l[15] + movs r5, r5, lsr #28 + adc r7, r5, lr, lsl #4 @ r7 = bits[59..28] of windowed x14 + + smull r5, lr, r12, r8 @ r5..lr = (window_l[15] * (x[15] == -x[2])) + ldr r12, =WL16 @ r12 = window_l[16] + movs r5, r5, lsr #28 + adc r8, r5, lr, lsl #4 @ r8 = bits[59..28] of windowed x15 + + smull r5, lr, r12, r9 @ r5..lr = (window_l[16] * (x[16] == -x[1])) + ldr r12, =WL17 @ r12 = window_l[17] + movs r5, r5, lsr #28 + adc r9, r5, lr, lsl #4 @ r9 = bits[59..28] of windowed x16 + + smull r5, lr, r12, r10 @ r5..lr = (window_l[17] * (x[17] == -x[0])) + ldr r12, =WL0 @ r12 = window_l[0] + movs r5, r5, lsr #28 + adc r10, r5, lr, lsl #4 @ r10 = bits[59..28] of windowed x17 + + + stmia r1, { r0, r2 - r4, r6 - r10 } @ store windowed x[9] .. x[17] + ldmdb r1!, { r0, r2 - r9 } @ load 9 words downto (and including) x0 + + + smull r10, lr, r12, r0 @ r10..lr = (window_l[0] * x[0]) + ldr r12, =WL1 @ r12 = window_l[1] + movs r10, r10, lsr #28 + adc r0, r10, lr, lsl #4 @ r0 = bits[59..28] of windowed x0 + + smull r10, lr, r12, r2 @ r10..lr = (window_l[1] * x[1]) + ldr r12, =WL2 @ r12 = window_l[2] + movs r10, r10, lsr #28 + adc r2, r10, lr, lsl #4 @ r2 = bits[59..28] of windowed x1 + + smull r10, lr, r12, r3 @ r10..lr = (window_l[2] * x[2]) + ldr r12, =WL3 @ r12 = window_l[3] + movs r10, r10, lsr #28 + adc r3, r10, lr, lsl #4 @ r3 = bits[59..28] of windowed x2 + + smull r10, lr, r12, r4 @ r10..lr = (window_l[3] * x[3]) + ldr r12, =WL4 @ r12 = window_l[4] + movs r10, r10, lsr #28 + adc r4, r10, lr, lsl #4 @ r4 = bits[59..28] of windowed x3 + + smull r10, lr, r12, r5 @ r10..lr = (window_l[4] * x[4]) + ldr r12, =WL5 @ r12 = window_l[5] + movs r10, r10, lsr #28 + adc r5, r10, lr, lsl #4 @ r5 = bits[59..28] of windowed x4 + + smull r10, lr, r12, r6 @ r10..lr = (window_l[5] * x[5]) + ldr r12, =WL6 @ r12 = window_l[6] + movs r10, r10, lsr #28 + adc r6, r10, lr, lsl #4 @ r6 = bits[59..28] of windowed x5 + + smull r10, lr, r12, r7 @ r10..lr = (window_l[6] * x[6]) + ldr r12, =WL7 @ r12 = window_l[7] + movs r10, r10, lsr #28 + adc r7, r10, lr, lsl #4 @ r7 = bits[59..28] of windowed x6 + + smull r10, lr, r12, r8 @ r10..lr = (window_l[7] * x[7]) + ldr r12, =WL8 @ r12 = window_l[8] + movs r10, r10, lsr #28 + adc r8, r10, lr, lsl #4 @ r8 = bits[59..28] of windowed x7 + + smull r10, lr, r12, r9 @ r10..lr = (window_l[8] * x[8]) + movs r10, r10, lsr #28 + adc r9, r10, lr, lsl #4 @ r9 = bits[59..28] of windowed x8 + + stmia r1, { r0, r2 - r9 } @ store windowed x[0] .. x[8] + + cmp r11, #BLOCK_MODE_START + beq start_block_x18_to_x35 + + + @---- + + +normal_block_x18_to_x35: + + ldr r11, =WL3 @ r11 = window_l[3] + ldr r12, =WL4 @ r12 = window_l[4] + + add r1, r1, #(18*4) @ r1 = &x[18] + + ldmia r1!, { r0, r2 - r4, r6 - r10 } @ load 9 words from x18, update pointer + + @ r0 = x18 + @ r1 = &x[27] + @ r2 = x19 + @ r3 = x20 + @ r4 = x21 + @ r5 = . + @ r6 = x22 + @ r7 = x23 + @ r8 = x24 + @ r9 = x25 + @ r10 = x26 + @ r11 = window_l[3] + @ r12 = window_l[4] + @ lr = . + + smull r5, lr, r12, r6 @ r5..lr = (window_l[4] * (x[22] == x[31])) + movs r5, r5, lsr #28 + adc r5, r5, lr, lsl #4 @ r5 = bits[59..28] of windowed x31 + + smull r6, lr, r11, r4 @ r5..lr = (window_l[3] * (x[21] == x[32])) + ldr r12, =WL5 @ r12 = window_l[5] + movs r6, r6, lsr #28 + adc r6, r6, lr, lsl #4 @ r6 = bits[59..28] of windowed x32 + + smull r4, lr, r12, r7 @ r4..lr = (window_l[5] * (x[23] == x[30])) + ldr r11, =WL1 @ r11 = window_l[1] + ldr r12, =WL2 @ r12 = window_l[2] + movs r4, r4, lsr #28 + adc r4, r4, lr, lsl #4 @ r4 = bits[59..28] of windowed x30 + + smull r7, lr, r12, r3 @ r7..lr = (window_l[2] * (x[20] == x[33])) + ldr r12, =WL6 @ r12 = window_l[6] + movs r7, r7, lsr #28 + adc r7, r7, lr, lsl #4 @ r7 = bits[59..28] of windowed x33 + + smull r3, lr, r12, r8 @ r3..lr = (window_l[6] * (x[24] == x[29])) + movs r3, r3, lsr #28 + adc r3, r3, lr, lsl #4 @ r3 = bits[59..28] of windowed x29 + + smull r8, lr, r11, r2 @ r7..lr = (window_l[1] * (x[19] == x[34])) + ldr r12, =WL7 @ r12 = window_l[7] + ldr r11, =WL8 @ r11 = window_l[8] + movs r8, r8, lsr #28 + adc r8, r8, lr, lsl #4 @ r8 = bits[59..28] of windowed x34 + + smull r2, lr, r12, r9 @ r7..lr = (window_l[7] * (x[25] == x[28])) + ldr r12, =WL0 @ r12 = window_l[0] + movs r2, r2, lsr #28 + adc r2, r2, lr, lsl #4 @ r2 = bits[59..28] of windowed x28 + + smull r9, lr, r12, r0 @ r3..lr = (window_l[0] * (x[18] == x[35])) + movs r9, r9, lsr #28 + adc r9, r9, lr, lsl #4 @ r9 = bits[59..28] of windowed x35 + + smull r0, lr, r11, r10 @ r7..lr = (window_l[8] * (x[26] == x[27])) + ldr r11, =WL16 @ r11 = window_l[16] + ldr r12, =WL17 @ r12 = window_l[17] + movs r0, r0, lsr #28 + adc r0, r0, lr, lsl #4 @ r0 = bits[59..28] of windowed x27 + + + stmia r1, { r0, r2 - r9 } @ store windowed x[27] .. x[35] + ldmdb r1!, { r0, r2 - r9 } @ load 9 words downto (and including) x18 + + + smull r10, lr, r12, r0 @ r10..lr = (window_l[17] * x[18]) + movs r10, r10, lsr #28 + adc r0, r10, lr, lsl #4 @ r0 = bits[59..28] of windowed x0 + + smull r10, lr, r11, r2 @ r10..lr = (window_l[16] * x[19]) + ldr r11, =WL14 @ r11 = window_l[14] + ldr r12, =WL15 @ r12 = window_l[15] + movs r10, r10, lsr #28 + adc r2, r10, lr, lsl #4 @ r2 = bits[59..28] of windowed x1 + + smull r10, lr, r12, r3 @ r10..lr = (window_l[15] * x[20]) + movs r10, r10, lsr #28 + adc r3, r10, lr, lsl #4 @ r3 = bits[59..28] of windowed x2 + + smull r10, lr, r11, r4 @ r10..lr = (window_l[14] * x[21]) + ldr r11, =WL12 @ r11 = window_l[12] + ldr r12, =WL13 @ r12 = window_l[13] + movs r10, r10, lsr #28 + adc r4, r10, lr, lsl #4 @ r4 = bits[59..28] of windowed x3 + + smull r10, lr, r12, r5 @ r10..lr = (window_l[13] * x[22]) + movs r10, r10, lsr #28 + adc r5, r10, lr, lsl #4 @ r5 = bits[59..28] of windowed x4 + + smull r10, lr, r11, r6 @ r10..lr = (window_l[12] * x[23]) + ldr r11, =WL10 @ r12 = window_l[10] + ldr r12, =WL11 @ r12 = window_l[11] + movs r10, r10, lsr #28 + adc r6, r10, lr, lsl #4 @ r6 = bits[59..28] of windowed x5 + + smull r10, lr, r12, r7 @ r10..lr = (window_l[11] * x[24]) + movs r10, r10, lsr #28 + adc r7, r10, lr, lsl #4 @ r7 = bits[59..28] of windowed x6 + + smull r10, lr, r11, r8 @ r10..lr = (window_l[10] * x[25]) + ldr r12, =WL9 @ r12 = window_l[9] + movs r10, r10, lsr #28 + adc r8, r10, lr, lsl #4 @ r8 = bits[59..28] of windowed x7 + + smull r10, lr, r12, r9 @ r10..lr = (window_l[9] * x[26]) + + movs r10, r10, lsr #28 + adc r9, r10, lr, lsl #4 @ r9 = bits[59..28] of windowed x8 + + stmia r1, { r0, r2 - r9 } @ store windowed x[18] .. x[26] + + @---- + @ NB there are 2 possible exits from this function - this is only one of them + @---- + + add sp, sp, #(21*4) @ return stack frame + ldmpc regs=r4-r11 @ restore callee saved regs, and return + + @---- + + +stop_block_x0_to_x17: + + @ r0 = x0 + @ r1 = &x[9] + @ r2 = x1 + @ r3 = x2 + @ r4 = x3 + @ r5 = x4 + @ r6 = x5 + @ r7 = x6 + @ r8 = x7 + @ r9 = x8 + @ r10 = -x0 + @ r11 = window mode: (0 == normal), (1 == start block), (3 == stop block) + @ r12 = . + @ lr = . + + rsb r0, r6, #0 @ r0 = -x5 + rsb r6, r2, #0 @ r6 = -x1 + rsb r2, r5, #0 @ r2 = -x4 + rsb r5, r3, #0 @ r5 = -x2 + rsb r3, r4, #0 @ r3 = -x3 + + add r1, r1, #(3*4) @ r1 = &x[12] + stmia r1, { r0, r2, r3, r5, r6, r10 } @ store unchanged x[12] .. x[17] + + ldr r0, =WL1 @ r0 = window_l[1] == window_s[0] + + rsb r10, r9, #0 @ r10 = -x8 + rsb r12, r8, #0 @ r12 = -x7 + rsb lr, r7, #0 @ lr = -x6 + + @ r0 = WL1 + @ r1 = &x[12] + @ r2 = . + @ r3 = . + @ r4 = . + @ r5 = . + @ r6 = . + @ r7 = x6 + @ r8 = x7 + @ r9 = x8 + @ r10 = -x8 + @ r11 = window mode: (0 == normal), (1 == start block), (3 == stop block) + @ r12 = -x7 + @ lr = -x6 + + smull r5, r6, r0, r7 @ r5..r6 = (window_l[1] * x[6]) + ldr r2, =WL4 @ r2 = window_l[4] == window_s[1] + movs r5, r5, lsr #28 + adc r7, r5, r6, lsl #4 @ r7 = bits[59..28] of windowed x6 + + smull r5, r6, r2, r8 @ r5..r6 = (window_l[4] * x[7]) + ldr r3, =WL7 @ r3 = window_l[7] == window_s[2] + movs r5, r5, lsr #28 + adc r8, r5, r6, lsl #4 @ r8 = bits[59..28] of windowed x7 + + smull r5, r6, r3, r9 @ r5..r6 = (window_l[7] * x[8]) + ldr r4, =WL10 @ r4 = window_l[10] == window_s[3] + movs r5, r5, lsr #28 + adc r9, r5, r6, lsl #4 @ r9 = bits[59..28] of windowed x8 + + smull r5, r6, r4, r10 @ r5..r6 = (window_l[10] * (x[9] == -x[8])) + ldr r0, =WL13 @ r0 = window_l[13] == window_s[4] + movs r5, r5, lsr #28 + adc r10, r5, r6, lsl #4 @ r10 = bits[59..28] of windowed x9 + + smull r5, r6, r0, r12 @ r5..r6 = (window_l[13] * (x[10] == -x[7])) + ldr r2, =WL16 @ r2 = window_l[16] == window_s[5] + movs r5, r5, lsr #28 + adc r12, r5, r6, lsl #4 @ r10 = bits[59..28] of windowed x9 + + smull r5, r6, r2, lr @ r5..r6 = (window_l[16] * (x[11] == -x[6])) + + ldr r0, =0x00 + + movs r5, r5, lsr #28 + adc lr, r5, r6, lsl #4 @ r10 = bits[59..28] of windowed x9 + + stmdb r1!, { r7 - r10, r12, lr } @ store windowed x[6] .. x[11] + + ldr r5, =0x00 + ldr r6, =0x00 + ldr r2, =0x00 + ldr r3, =0x00 + ldr r4, =0x00 + + stmdb r1!, { r0, r2 - r6 } @ store windowed x[0] .. x[5] + + b normal_block_x18_to_x35 + + + @---- + + +start_block_x18_to_x35: + + ldr r4, =WL1 @ r0 = window_l[1] == window_s[0] + + add r1, r1, #(24*4) @ r1 = &x[24] + + ldmia r1, { r0, r2, r3 } @ load 3 words from x24, dont update pointer + + @ r0 = x24 + @ r1 = &x[24] + @ r2 = x25 + @ r3 = x26 + @ r4 = WL1 + @ r5 = WL4 + @ r6 = WL7 + @ r7 = WL10 + @ r8 = WL13 + @ r9 = WL16 + @ r10 = . + @ r11 = . + @ r12 = . + @ lr = . + + ldr r5, =WL4 @ r5 = window_l[4] == window_s[1] + + smull r10, r11, r4, r0 @ r10..r11 = (window_l[1] * (x[24] == x[29])) + ldr r6, =WL7 @ r6 = window_l[7] == window_s[2] + movs r10, r10, lsr #28 + adc lr, r10, r11, lsl #4 @ lr = bits[59..28] of windowed x29 + + smull r10, r11, r5, r2 @ r10..r11 = (window_l[4] * (x[25] == x[28])) + ldr r7, =WL10 @ r7 = window_l[10] == window_s[3] + movs r10, r10, lsr #28 + adc r12, r10, r11, lsl #4 @ r12 = bits[59..28] of windowed x28 + + smull r10, r11, r6, r3 @ r10..r11 = (window_l[7] * (x[26] == x[27])) + ldr r8, =WL13 @ r8 = window_l[13] == window_s[4] + movs r10, r10, lsr #28 + adc r4, r10, r11, lsl #4 @ r4 = bits[59..28] of windowed x27 + + smull r10, r11, r7, r3 @ r10..r11 = (window_l[10] * x[26]) + ldr r9, =WL16 @ r9 = window_l[16] == window_s[5] + movs r10, r10, lsr #28 + adc r3, r10, r11, lsl #4 @ r3 = bits[59..28] of windowed x26 + + smull r10, r11, r8, r2 @ r10..r11 = (window_l[13] * x[25]) + ldr r5, =0x00 + movs r10, r10, lsr #28 + adc r2, r10, r11, lsl #4 @ r2 = bits[59..28] of windowed x25 + + smull r10, r11, r9, r0 @ r10..r11 = (window_l[16] * x[24]) + ldr r6, =0x00 + movs r10, r10, lsr #28 + adc r0, r10, r11, lsl #4 @ r0 = bits[59..28] of windowed x24 + + stmia r1!, { r0, r2, r3, r4, r12, lr } @ store windowed x[24] .. x[29] + + ldr r7, =0x00 + ldr r8, =0x00 + ldr r9, =0x00 + ldr r10, =0x00 + + stmia r1!, { r5 - r10 } @ store windowed x[30] .. x[35] + + @---- + @ NB there are 2 possible exits from this function - this is only one of them + @---- + + add sp, sp, #(21*4) @ return stack frame + ldmpc regs=r4-r11 @ restore callee saved regs, and return + + @---- + @END + @---- + diff --git a/lib/rbcodec/codecs/libmad/imdct_mcf5249.S b/lib/rbcodec/codecs/libmad/imdct_mcf5249.S new file mode 100644 index 0000000000..b5e2a12b0f --- /dev/null +++ b/lib/rbcodec/codecs/libmad/imdct_mcf5249.S @@ -0,0 +1,124 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2005 by Thom Johansen + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ +/* this will also be the home to III_imdct_l in the future */ + + .global III_imdct_s +III_imdct_s: + /* we need to save 9 registers and 36 samples of temp buffer */ + lea.l (-45*4, %sp), %sp + movem.l %d2-%d7/%a2-%a4, (36*4, %sp) + move.l (45*4 + 4, %sp), %a2 /* a2 = X */ + move.l %sp, %a3 + + /* IMDCT */ + + /* if additional precision is needed in this block, it is possible to + * get more low bits out of the accext01 register _before_ doing the + * movclrs. + */ + moveq.l #3, %d5 /* we do three outer loop iterations */ +.imdctloop: /* outer loop label */ + lea.l imdct_s, %a1 /* load pointer to imdct coefs in a1 */ + movem.l (%a2), %d0-%d4/%a0 /* load some input data in d0-d4/a0 */ + lea.l (6*4, %a2), %a2 + + clr.l %d7 /* clear loop variable */ + move.l (%a1)+, %a4 /* load imdct coef in a4 */ +.macloop: /* inner loop label */ + mac.l %d0, %a4, (%a1)+, %a4, %acc0 /* mac sequence */ + mac.l %d1, %a4, (%a1)+, %a4, %acc0 + mac.l %d2, %a4, (%a1)+, %a4, %acc0 + mac.l %d3, %a4, (%a1)+, %a4, %acc0 + mac.l %d4, %a4, (%a1)+, %a4, %acc0 + mac.l %a0, %a4, (%a1)+, %a4, %acc0 + movclr.l %acc0, %d6 /* get result, left shifted once */ + asl.l #3, %d6 /* one shift free, shift three more */ + move.l %d6, (%a3, %d7.l*4) /* yptr[i] = result */ + neg.l %d6 + neg.l %d7 + move.l %d6, (5*4, %a3, %d7.l*4) /* yptr[5 - i] = -result */ + mac.l %d0, %a4, (%a1)+, %a4, %acc0 /* mac sequence */ + mac.l %d1, %a4, (%a1)+, %a4, %acc0 + mac.l %d2, %a4, (%a1)+, %a4, %acc0 + mac.l %d3, %a4, (%a1)+, %a4, %acc0 + mac.l %d4, %a4, (%a1)+, %a4, %acc0 + mac.l %a0, %a4, (%a1)+, %a4, %acc0 + movclr.l %acc0, %d6 /* get result */ + asl.l #3, %d6 + move.l %d6, (11*4, %a3, %d7.l*4) /* yptr[11 - i] = result */ + neg.l %d7 + move.l %d6, (6*4, %a3, %d7.l*4) /* yptr[i + 6] = result */ + addq.l #1, %d7 /* increment inner loop variable */ + moveq.l #3, %d6 + cmp.l %d6, %d7 /* we do three inner loop iterations */ + jne .macloop + + lea.l (12*4, %a3), %a3 /* add pointer increment */ + subq.l #1, %d5 /* decrement outer loop variable */ + jne .imdctloop + + /* windowing, overlapping and concatenation */ + + move.l (45*4 + 8, %sp), %a2 /* a2 = z */ + move.l %sp, %a3 /* a3 = tmp buffer ptr */ + lea.l window_s, %a4 /* a4 = window coef pointer */ + + moveq.l #6, %d7 /* six iterations */ +.overlaploop: + clr.l (%a2) /* z[i + 0] = 0 */ + move.l (%a4), %d0 + move.l (%a3), %d2 + mac.l %d0, %d2, (6*4, %a4), %d1, %acc0 + move.l (6*4, %a3), %d2 + movclr.l %acc0, %d6 + asl.l #3, %d6 + move.l %d6, (6*4, %a2) /* z[i + 6] = result */ + + mac.l %d1, %d2, (12*4, %a3), %d2, %acc0 + mac.l %d0, %d2, (18*4, %a3), %d2, %acc0 + movclr.l %acc0, %d6 + asl.l #3, %d6 + move.l %d6, (12*4, %a2) /* z[i + 12] = result */ + + mac.l %d1, %d2, (24*4, %a3), %d2, %acc0 + mac.l %d0, %d2, (30*4, %a3), %d2, %acc0 + movclr.l %acc0, %d6 + asl.l #3, %d6 + move.l %d6, (18*4, %a2) /* z[i + 18] = result */ + + mac.l %d1, %d2, %acc0 + movclr.l %acc0, %d6 + asl.l #3, %d6 + move.l %d6, (24*4, %a2) /* z[i + 24] = result */ + + clr.l (30*4, %a2) /* z[i + 30] = 0 */ + addq.l #4, %a2 /* increment all pointers */ + addq.l #4, %a3 + addq.l #4, %a4 + subq.l #1, %d7 /* decrement loop counter */ + jne .overlaploop + /* fall through to exit if we're done */ + + /* clean up */ + movem.l (36*4, %sp), %d2-%d7/%a2-%a4 + lea.l (45*4, %sp), %sp + rts + diff --git a/lib/rbcodec/codecs/libmad/imdct_s.dat b/lib/rbcodec/codecs/libmad/imdct_s.dat new file mode 100644 index 0000000000..0f1f3c9b60 --- /dev/null +++ b/lib/rbcodec/codecs/libmad/imdct_s.dat @@ -0,0 +1,62 @@ +/* + * libmad - MPEG audio decoder library + * Copyright (C) 2000-2004 Underbit Technologies, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * $Id$ + */ + + /* 0 */ { MAD_F(0x09bd7ca0) /* 0.608761429 */, + -MAD_F(0x0ec835e8) /* -0.923879533 */, + -MAD_F(0x0216a2a2) /* -0.130526192 */, + MAD_F(0x0fdcf549) /* 0.991444861 */, + -MAD_F(0x061f78aa) /* -0.382683432 */, + -MAD_F(0x0cb19346) /* -0.793353340 */ }, + + /* 6 */ { -MAD_F(0x0cb19346) /* -0.793353340 */, + MAD_F(0x061f78aa) /* 0.382683432 */, + MAD_F(0x0fdcf549) /* 0.991444861 */, + MAD_F(0x0216a2a2) /* 0.130526192 */, + -MAD_F(0x0ec835e8) /* -0.923879533 */, + -MAD_F(0x09bd7ca0) /* -0.608761429 */ }, + + /* 1 */ { MAD_F(0x061f78aa) /* 0.382683432 */, + -MAD_F(0x0ec835e8) /* -0.923879533 */, + MAD_F(0x0ec835e8) /* 0.923879533 */, + -MAD_F(0x061f78aa) /* -0.382683432 */, + -MAD_F(0x061f78aa) /* -0.382683432 */, + MAD_F(0x0ec835e8) /* 0.923879533 */ }, + + /* 7 */ { -MAD_F(0x0ec835e8) /* -0.923879533 */, + -MAD_F(0x061f78aa) /* -0.382683432 */, + MAD_F(0x061f78aa) /* 0.382683432 */, + MAD_F(0x0ec835e8) /* 0.923879533 */, + MAD_F(0x0ec835e8) /* 0.923879533 */, + MAD_F(0x061f78aa) /* 0.382683432 */ }, + + /* 2 */ { MAD_F(0x0216a2a2) /* 0.130526192 */, + -MAD_F(0x061f78aa) /* -0.382683432 */, + MAD_F(0x09bd7ca0) /* 0.608761429 */, + -MAD_F(0x0cb19346) /* -0.793353340 */, + MAD_F(0x0ec835e8) /* 0.923879533 */, + -MAD_F(0x0fdcf549) /* -0.991444861 */ }, + + /* 8 */ { -MAD_F(0x0fdcf549) /* -0.991444861 */, + -MAD_F(0x0ec835e8) /* -0.923879533 */, + -MAD_F(0x0cb19346) /* -0.793353340 */, + -MAD_F(0x09bd7ca0) /* -0.608761429 */, + -MAD_F(0x061f78aa) /* -0.382683432 */, + -MAD_F(0x0216a2a2) /* -0.130526192 */ } diff --git a/lib/rbcodec/codecs/libmad/layer12.c b/lib/rbcodec/codecs/libmad/layer12.c new file mode 100644 index 0000000000..e00bb64530 --- /dev/null +++ b/lib/rbcodec/codecs/libmad/layer12.c @@ -0,0 +1,537 @@ +/* + * libmad - MPEG audio decoder library + * Copyright (C) 2000-2004 Underbit Technologies, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * $Id$ + */ + +# ifdef HAVE_CONFIG_H +# include "config.h" +# endif + +# include "global.h" + +# ifdef HAVE_LIMITS_H +# include +# else +# undef CHAR_BIT +# define CHAR_BIT 8 +# endif + +# include "fixed.h" +# include "bit.h" +# include "stream.h" +# include "frame.h" +# include "layer12.h" + +/* + * scalefactor table + * used in both Layer I and Layer II decoding + */ +static +mad_fixed_t const sf_table[64] ICONST_ATTR = { +# include "sf_table.dat" +}; + +/* --- Layer I ------------------------------------------------------------- */ + +/* linear scaling table */ +static +mad_fixed_t const linear_table[14] ICONST_ATTR = { + MAD_F(0x15555555), /* 2^2 / (2^2 - 1) == 1.33333333333333 */ + MAD_F(0x12492492), /* 2^3 / (2^3 - 1) == 1.14285714285714 */ + MAD_F(0x11111111), /* 2^4 / (2^4 - 1) == 1.06666666666667 */ + MAD_F(0x10842108), /* 2^5 / (2^5 - 1) == 1.03225806451613 */ + MAD_F(0x10410410), /* 2^6 / (2^6 - 1) == 1.01587301587302 */ + MAD_F(0x10204081), /* 2^7 / (2^7 - 1) == 1.00787401574803 */ + MAD_F(0x10101010), /* 2^8 / (2^8 - 1) == 1.00392156862745 */ + MAD_F(0x10080402), /* 2^9 / (2^9 - 1) == 1.00195694716243 */ + MAD_F(0x10040100), /* 2^10 / (2^10 - 1) == 1.00097751710655 */ + MAD_F(0x10020040), /* 2^11 / (2^11 - 1) == 1.00048851978505 */ + MAD_F(0x10010010), /* 2^12 / (2^12 - 1) == 1.00024420024420 */ + MAD_F(0x10008004), /* 2^13 / (2^13 - 1) == 1.00012208521548 */ + MAD_F(0x10004001), /* 2^14 / (2^14 - 1) == 1.00006103888177 */ + MAD_F(0x10002000) /* 2^15 / (2^15 - 1) == 1.00003051850948 */ +}; + +/* + * NAME: I_sample() + * DESCRIPTION: decode one requantized Layer I sample from a bitstream + */ +static inline +mad_fixed_t I_sample(struct mad_bitptr *ptr, unsigned int nb) +{ + mad_fixed_t sample; + + sample = mad_bit_read(ptr, nb); + + /* invert most significant bit, extend sign, then scale to fixed format */ + + sample ^= 1 << (nb - 1); + sample |= -(sample & (1 << (nb - 1))); + + sample <<= MAD_F_FRACBITS - (nb - 1); + + /* requantize the sample */ + + /* s'' = (2^nb / (2^nb - 1)) * (s''' + 2^(-nb + 1)) */ + + sample += MAD_F_ONE >> (nb - 1); + + return mad_f_mul(sample, linear_table[nb - 2]); + + /* s' = factor * s'' */ + /* (to be performed by caller) */ +} + +/* + * NAME: layer->I() + * DESCRIPTION: decode a single Layer I frame + */ +int mad_layer_I(struct mad_stream *stream, struct mad_frame *frame) +{ + struct mad_header *header = &frame->header; + unsigned int nch, bound, ch, s, sb, nb; + unsigned char allocation[2][32], scalefactor[2][32]; + + nch = MAD_NCHANNELS(header); + + bound = 32; + if (header->mode == MAD_MODE_JOINT_STEREO) { + header->flags |= MAD_FLAG_I_STEREO; + bound = 4 + header->mode_extension * 4; + } + + /* check CRC word */ + + if (header->flags & MAD_FLAG_PROTECTION) { + header->crc_check = + mad_bit_crc(stream->ptr, 4 * (bound * nch + (32 - bound)), + header->crc_check); + + if (header->crc_check != header->crc_target && + !(frame->options & MAD_OPTION_IGNORECRC)) { + stream->error = MAD_ERROR_BADCRC; + return -1; + } + } + + /* decode bit allocations */ + + for (sb = 0; sb < bound; ++sb) { + for (ch = 0; ch < nch; ++ch) { + nb = mad_bit_read(&stream->ptr, 4); + + if (nb == 15) { + stream->error = MAD_ERROR_BADBITALLOC; + return -1; + } + + allocation[ch][sb] = nb ? nb + 1 : 0; + } + } + + for (sb = bound; sb < 32; ++sb) { + nb = mad_bit_read(&stream->ptr, 4); + + if (nb == 15) { + stream->error = MAD_ERROR_BADBITALLOC; + return -1; + } + + allocation[0][sb] = + allocation[1][sb] = nb ? nb + 1 : 0; + } + + /* decode scalefactors */ + + for (sb = 0; sb < 32; ++sb) { + for (ch = 0; ch < nch; ++ch) { + if (allocation[ch][sb]) { + scalefactor[ch][sb] = mad_bit_read(&stream->ptr, 6); + +# if defined(OPT_STRICT) + /* + * Scalefactor index 63 does not appear in Table B.1 of + * ISO/IEC 11172-3. Nonetheless, other implementations accept it, + * so we only reject it if OPT_STRICT is defined. + */ + if (scalefactor[ch][sb] == 63) { + stream->error = MAD_ERROR_BADSCALEFACTOR; + return -1; + } +# endif + } + } + } + + /* decode samples */ + + for (s = 0; s < 12; ++s) { + for (sb = 0; sb < bound; ++sb) { + for (ch = 0; ch < nch; ++ch) { + nb = allocation[ch][sb]; + (*frame->sbsample)[ch][s][sb] = nb ? + mad_f_mul(I_sample(&stream->ptr, nb), + sf_table[scalefactor[ch][sb]]) : 0; + } + } + + for (sb = bound; sb < 32; ++sb) { + if ((nb = allocation[0][sb])) { + mad_fixed_t sample; + + sample = I_sample(&stream->ptr, nb); + + for (ch = 0; ch < nch; ++ch) { + (*frame->sbsample)[ch][s][sb] = + mad_f_mul(sample, sf_table[scalefactor[ch][sb]]); + } + } + else { + for (ch = 0; ch < nch; ++ch) + (*frame->sbsample)[ch][s][sb] = 0; + } + } + } + + return 0; +} + +/* --- Layer II ------------------------------------------------------------ */ + +/* possible quantization per subband table */ +static +struct { + unsigned int sblimit; + unsigned char const offsets[30]; +} const sbquant_table[5] = { + /* ISO/IEC 11172-3 Table B.2a */ + { 27, { 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 6, 3, 3, 3, 3, 3, /* 0 */ + 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0 } }, + /* ISO/IEC 11172-3 Table B.2b */ + { 30, { 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 6, 3, 3, 3, 3, 3, /* 1 */ + 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0 } }, + /* ISO/IEC 11172-3 Table B.2c */ + { 8, { 5, 5, 2, 2, 2, 2, 2, 2 } }, /* 2 */ + /* ISO/IEC 11172-3 Table B.2d */ + { 12, { 5, 5, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 } }, /* 3 */ + /* ISO/IEC 13818-3 Table B.1 */ + { 30, { 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, /* 4 */ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 } } +}; + +/* bit allocation table */ +static +struct { + unsigned short nbal; + unsigned short offset; +} const bitalloc_table[8] = { + { 2, 0 }, /* 0 */ + { 2, 3 }, /* 1 */ + { 3, 3 }, /* 2 */ + { 3, 1 }, /* 3 */ + { 4, 2 }, /* 4 */ + { 4, 3 }, /* 5 */ + { 4, 4 }, /* 6 */ + { 4, 5 } /* 7 */ +}; + +/* offsets into quantization class table */ +static +unsigned char const offset_table[6][15] = { + { 0, 1, 16 }, /* 0 */ + { 0, 1, 2, 3, 4, 5, 16 }, /* 1 */ + { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 }, /* 2 */ + { 0, 1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }, /* 3 */ + { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 16 }, /* 4 */ + { 0, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 } /* 5 */ +}; + +/* quantization class table */ +static +struct quantclass { + unsigned short nlevels; + unsigned char group; + unsigned char bits; + mad_fixed_t C; + mad_fixed_t D; +} const qc_table[17] ICONST_ATTR = { +# include "qc_table.dat" +}; + +/* + * NAME: II_samples() + * DESCRIPTION: decode three requantized Layer II samples from a bitstream + */ +static +void II_samples(struct mad_bitptr *ptr, + struct quantclass const *quantclass, + mad_fixed_t output[3]) +{ + unsigned int nb, s, sample[3]; + + if ((nb = quantclass->group)) { + unsigned int c, nlevels; + + /* degrouping */ + c = mad_bit_read(ptr, quantclass->bits); + nlevels = quantclass->nlevels; + + for (s = 0; s < 3; ++s) { + sample[s] = c % nlevels; + c /= nlevels; + } + } + else { + nb = quantclass->bits; + + for (s = 0; s < 3; ++s) + sample[s] = mad_bit_read(ptr, nb); + } + + for (s = 0; s < 3; ++s) { + mad_fixed_t requantized; + + /* invert most significant bit, extend sign, then scale to fixed format */ + + requantized = sample[s] ^ (1 << (nb - 1)); + requantized |= -(requantized & (1 << (nb - 1))); + + requantized <<= MAD_F_FRACBITS - (nb - 1); + + /* requantize the sample */ + + /* s'' = C * (s''' + D) */ + + output[s] = mad_f_mul(requantized + quantclass->D, quantclass->C); + + /* s' = factor * s'' */ + /* (to be performed by caller) */ + } +} + +/* + * NAME: layer->II() + * DESCRIPTION: decode a single Layer II frame + */ +int mad_layer_II(struct mad_stream *stream, struct mad_frame *frame) +{ + struct mad_header *header = &frame->header; + struct mad_bitptr start; + unsigned int index, sblimit, nbal, nch, bound, gr, ch, s, sb; + unsigned char const *offsets; + unsigned char allocation[2][32], scfsi[2][32], scalefactor[2][32][3]; + mad_fixed_t samples[3]; + + nch = MAD_NCHANNELS(header); + + if (header->flags & MAD_FLAG_LSF_EXT) + index = 4; + else if (header->flags & MAD_FLAG_FREEFORMAT) + goto freeformat; + else { + unsigned long bitrate_per_channel; + + bitrate_per_channel = header->bitrate; + if (nch == 2) { + bitrate_per_channel /= 2; + +# if defined(OPT_STRICT) + /* + * ISO/IEC 11172-3 allows only single channel mode for 32, 48, 56, and + * 80 kbps bitrates in Layer II, but some encoders ignore this + * restriction. We enforce it if OPT_STRICT is defined. + */ + if (bitrate_per_channel <= 28000 || bitrate_per_channel == 40000) { + stream->error = MAD_ERROR_BADMODE; + return -1; + } +# endif + } + else { /* nch == 1 */ + if (bitrate_per_channel > 192000) { + /* + * ISO/IEC 11172-3 does not allow single channel mode for 224, 256, + * 320, or 384 kbps bitrates in Layer II. + */ + stream->error = MAD_ERROR_BADMODE; + return -1; + } + } + + if (bitrate_per_channel <= 48000) + index = (header->samplerate == 32000) ? 3 : 2; + else if (bitrate_per_channel <= 80000) + index = 0; + else { + freeformat: + index = (header->samplerate == 48000) ? 0 : 1; + } + } + + sblimit = sbquant_table[index].sblimit; + offsets = sbquant_table[index].offsets; + + bound = 32; + if (header->mode == MAD_MODE_JOINT_STEREO) { + header->flags |= MAD_FLAG_I_STEREO; + bound = 4 + header->mode_extension * 4; + } + + if (bound > sblimit) + bound = sblimit; + + start = stream->ptr; + + /* decode bit allocations */ + + for (sb = 0; sb < bound; ++sb) { + nbal = bitalloc_table[offsets[sb]].nbal; + + for (ch = 0; ch < nch; ++ch) + allocation[ch][sb] = mad_bit_read(&stream->ptr, nbal); + } + + for (sb = bound; sb < sblimit; ++sb) { + nbal = bitalloc_table[offsets[sb]].nbal; + + allocation[0][sb] = + allocation[1][sb] = mad_bit_read(&stream->ptr, nbal); + } + + /* decode scalefactor selection info */ + + for (sb = 0; sb < sblimit; ++sb) { + for (ch = 0; ch < nch; ++ch) { + if (allocation[ch][sb]) + scfsi[ch][sb] = mad_bit_read(&stream->ptr, 2); + } + } + + /* check CRC word */ + + if (header->flags & MAD_FLAG_PROTECTION) { + header->crc_check = + mad_bit_crc(start, mad_bit_length(&start, &stream->ptr), + header->crc_check); + + if (header->crc_check != header->crc_target && + !(frame->options & MAD_OPTION_IGNORECRC)) { + stream->error = MAD_ERROR_BADCRC; + return -1; + } + } + + /* decode scalefactors */ + + for (sb = 0; sb < sblimit; ++sb) { + for (ch = 0; ch < nch; ++ch) { + if (allocation[ch][sb]) { + scalefactor[ch][sb][0] = mad_bit_read(&stream->ptr, 6); + + switch (scfsi[ch][sb]) { + case 2: + scalefactor[ch][sb][2] = + scalefactor[ch][sb][1] = + scalefactor[ch][sb][0]; + break; + + case 0: + scalefactor[ch][sb][1] = mad_bit_read(&stream->ptr, 6); + /* fall through */ + + case 1: + case 3: + scalefactor[ch][sb][2] = mad_bit_read(&stream->ptr, 6); + } + + if (scfsi[ch][sb] & 1) + scalefactor[ch][sb][1] = scalefactor[ch][sb][scfsi[ch][sb] - 1]; + +# if defined(OPT_STRICT) + /* + * Scalefactor index 63 does not appear in Table B.1 of + * ISO/IEC 11172-3. Nonetheless, other implementations accept it, + * so we only reject it if OPT_STRICT is defined. + */ + if (scalefactor[ch][sb][0] == 63 || + scalefactor[ch][sb][1] == 63 || + scalefactor[ch][sb][2] == 63) { + stream->error = MAD_ERROR_BADSCALEFACTOR; + return -1; + } +# endif + } + } + } + + /* decode samples */ + + for (gr = 0; gr < 12; ++gr) { + for (sb = 0; sb < bound; ++sb) { + for (ch = 0; ch < nch; ++ch) { + if ((index = allocation[ch][sb])) { + int off = bitalloc_table[offsets[sb]].offset; + index = offset_table[off][index - 1]; + + II_samples(&stream->ptr, &qc_table[index], samples); + + for (s = 0; s < 3; ++s) { + (*frame->sbsample)[ch][3 * gr + s][sb] = + mad_f_mul(samples[s], sf_table[scalefactor[ch][sb][gr / 4]]); + } + } + else { + for (s = 0; s < 3; ++s) + (*frame->sbsample)[ch][3 * gr + s][sb] = 0; + } + } + } + + for (sb = bound; sb < sblimit; ++sb) { + if ((index = allocation[0][sb])) { + int off = bitalloc_table[offsets[sb]].offset; + index = offset_table[off][index - 1]; + + II_samples(&stream->ptr, &qc_table[index], samples); + + for (ch = 0; ch < nch; ++ch) { + for (s = 0; s < 3; ++s) { + (*frame->sbsample)[ch][3 * gr + s][sb] = + mad_f_mul(samples[s], sf_table[scalefactor[ch][sb][gr / 4]]); + } + } + } + else { + for (ch = 0; ch < nch; ++ch) { + for (s = 0; s < 3; ++s) + (*frame->sbsample)[ch][3 * gr + s][sb] = 0; + } + } + } + + for (ch = 0; ch < nch; ++ch) { + for (s = 0; s < 3; ++s) { + for (sb = sblimit; sb < 32; ++sb) + (*frame->sbsample)[ch][3 * gr + s][sb] = 0; + } + } + } + + return 0; +} diff --git a/lib/rbcodec/codecs/libmad/layer12.h b/lib/rbcodec/codecs/libmad/layer12.h new file mode 100644 index 0000000000..3fe6bd8b0f --- /dev/null +++ b/lib/rbcodec/codecs/libmad/layer12.h @@ -0,0 +1,31 @@ +/* + * libmad - MPEG audio decoder library + * Copyright (C) 2000-2004 Underbit Technologies, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * $Id$ + */ + +# ifndef LIBMAD_LAYER12_H +# define LIBMAD_LAYER12_H + +# include "stream.h" +# include "frame.h" + +int mad_layer_I(struct mad_stream *, struct mad_frame *); +int mad_layer_II(struct mad_stream *, struct mad_frame *); + +# endif diff --git a/lib/rbcodec/codecs/libmad/layer3.c b/lib/rbcodec/codecs/libmad/layer3.c new file mode 100644 index 0000000000..ffb0fb20ff --- /dev/null +++ b/lib/rbcodec/codecs/libmad/layer3.c @@ -0,0 +1,3107 @@ +/* + * libmad - MPEG audio decoder library + * Copyright (C) 2000-2004 Underbit Technologies, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * $Id$ + */ + +# ifdef HAVE_CONFIG_H +# include "config.h" +# endif + +# include "global.h" + +# include + +# ifdef HAVE_ASSERT_H +# include +# endif + +# ifdef HAVE_LIMITS_H +# include +# else +# undef CHAR_BIT +# define CHAR_BIT 8 +# endif + +# include "fixed.h" +# include "bit.h" +# include "stream.h" +# include "frame.h" +# include "huffman.h" +# include "layer3.h" + +/* depending on the cpu "leftshift32" may be supported or not */ +# if defined(CPU_COLDFIRE) +#define MAXLSHIFT 32 +#else +#define MAXLSHIFT 31 +#endif + +/* --- Layer III ----------------------------------------------------------- */ + +enum { + count1table_select = 0x01, + scalefac_scale = 0x02, + preflag = 0x04, + mixed_block_flag = 0x08 +}; + +enum { + I_STEREO = 0x1, + MS_STEREO = 0x2 +}; + +struct sideinfo { + unsigned int main_data_begin; + unsigned int private_bits; + + unsigned char scfsi[2]; + + struct granule { + struct channel { + /* from side info */ + unsigned short part2_3_length; + unsigned short big_values; + unsigned short global_gain; + unsigned short scalefac_compress; + + unsigned char flags; + unsigned char block_type; + unsigned char table_select[3]; + unsigned char subblock_gain[3]; + unsigned char region0_count; + unsigned char region1_count; + + /* from main_data */ + unsigned char scalefac[39]; /* scalefac_l and/or scalefac_s */ + } ch[2]; + } gr[2]; +}; + +/* + * scalefactor bit lengths + * derived from section 2.4.2.7 of ISO/IEC 11172-3 + */ +static +struct { + unsigned char slen1; + unsigned char slen2; +} const sflen_table[16] = { + { 0, 0 }, { 0, 1 }, { 0, 2 }, { 0, 3 }, + { 3, 0 }, { 1, 1 }, { 1, 2 }, { 1, 3 }, + { 2, 1 }, { 2, 2 }, { 2, 3 }, { 3, 1 }, + { 3, 2 }, { 3, 3 }, { 4, 2 }, { 4, 3 } +}; + +/* + * number of LSF scalefactor band values + * derived from section 2.4.3.2 of ISO/IEC 13818-3 + */ +static +unsigned char const nsfb_table[6][3][4] = { + { { 6, 5, 5, 5 }, + { 9, 9, 9, 9 }, + { 6, 9, 9, 9 } }, + + { { 6, 5, 7, 3 }, + { 9, 9, 12, 6 }, + { 6, 9, 12, 6 } }, + + { { 11, 10, 0, 0 }, + { 18, 18, 0, 0 }, + { 15, 18, 0, 0 } }, + + { { 7, 7, 7, 0 }, + { 12, 12, 12, 0 }, + { 6, 15, 12, 0 } }, + + { { 6, 6, 6, 3 }, + { 12, 9, 9, 6 }, + { 6, 12, 9, 6 } }, + + { { 8, 8, 5, 0 }, + { 15, 12, 9, 0 }, + { 6, 18, 9, 0 } } +}; + +/* + * MPEG-1 scalefactor band widths + * derived from Table B.8 of ISO/IEC 11172-3 + */ +static +unsigned char const sfb_48000_long[] = { + 4, 4, 4, 4, 4, 4, 6, 6, 6, 8, 10, + 12, 16, 18, 22, 28, 34, 40, 46, 54, 54, 192 +}; + +static +unsigned char const sfb_44100_long[] = { + 4, 4, 4, 4, 4, 4, 6, 6, 8, 8, 10, + 12, 16, 20, 24, 28, 34, 42, 50, 54, 76, 158 +}; + +static +unsigned char const sfb_32000_long[] = { + 4, 4, 4, 4, 4, 4, 6, 6, 8, 10, 12, + 16, 20, 24, 30, 38, 46, 56, 68, 84, 102, 26 +}; + +static +unsigned char const sfb_48000_short[] = { + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 6, + 6, 6, 6, 6, 6, 10, 10, 10, 12, 12, 12, 14, 14, + 14, 16, 16, 16, 20, 20, 20, 26, 26, 26, 66, 66, 66 +}; + +static +unsigned char const sfb_44100_short[] = { + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 6, + 6, 6, 8, 8, 8, 10, 10, 10, 12, 12, 12, 14, 14, + 14, 18, 18, 18, 22, 22, 22, 30, 30, 30, 56, 56, 56 +}; + +static +unsigned char const sfb_32000_short[] = { + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 6, + 6, 6, 8, 8, 8, 12, 12, 12, 16, 16, 16, 20, 20, + 20, 26, 26, 26, 34, 34, 34, 42, 42, 42, 12, 12, 12 +}; + +static +unsigned char const sfb_48000_mixed[] = { + /* long */ 4, 4, 4, 4, 4, 4, 6, 6, + /* short */ 4, 4, 4, 6, 6, 6, 6, 6, 6, 10, + 10, 10, 12, 12, 12, 14, 14, 14, 16, 16, + 16, 20, 20, 20, 26, 26, 26, 66, 66, 66 +}; + +static +unsigned char const sfb_44100_mixed[] = { + /* long */ 4, 4, 4, 4, 4, 4, 6, 6, + /* short */ 4, 4, 4, 6, 6, 6, 8, 8, 8, 10, + 10, 10, 12, 12, 12, 14, 14, 14, 18, 18, + 18, 22, 22, 22, 30, 30, 30, 56, 56, 56 +}; + +static +unsigned char const sfb_32000_mixed[] = { + /* long */ 4, 4, 4, 4, 4, 4, 6, 6, + /* short */ 4, 4, 4, 6, 6, 6, 8, 8, 8, 12, + 12, 12, 16, 16, 16, 20, 20, 20, 26, 26, + 26, 34, 34, 34, 42, 42, 42, 12, 12, 12 +}; + +/* + * MPEG-2 scalefactor band widths + * derived from Table B.2 of ISO/IEC 13818-3 + */ +static +unsigned char const sfb_24000_long[] = { + 6, 6, 6, 6, 6, 6, 8, 10, 12, 14, 16, + 18, 22, 26, 32, 38, 46, 54, 62, 70, 76, 36 +}; + +static +unsigned char const sfb_22050_long[] = { + 6, 6, 6, 6, 6, 6, 8, 10, 12, 14, 16, + 20, 24, 28, 32, 38, 46, 52, 60, 68, 58, 54 +}; + +# define sfb_16000_long sfb_22050_long + +static +unsigned char const sfb_24000_short[] = { + 4, 4, 4, 4, 4, 4, 4, 4, 4, 6, 6, 6, 8, + 8, 8, 10, 10, 10, 12, 12, 12, 14, 14, 14, 18, 18, + 18, 24, 24, 24, 32, 32, 32, 44, 44, 44, 12, 12, 12 +}; + +static +unsigned char const sfb_22050_short[] = { + 4, 4, 4, 4, 4, 4, 4, 4, 4, 6, 6, 6, 6, + 6, 6, 8, 8, 8, 10, 10, 10, 14, 14, 14, 18, 18, + 18, 26, 26, 26, 32, 32, 32, 42, 42, 42, 18, 18, 18 +}; + +static +unsigned char const sfb_16000_short[] = { + 4, 4, 4, 4, 4, 4, 4, 4, 4, 6, 6, 6, 8, + 8, 8, 10, 10, 10, 12, 12, 12, 14, 14, 14, 18, 18, + 18, 24, 24, 24, 30, 30, 30, 40, 40, 40, 18, 18, 18 +}; + +static +unsigned char const sfb_24000_mixed[] = { + /* long */ 6, 6, 6, 6, 6, 6, + /* short */ 6, 6, 6, 8, 8, 8, 10, 10, 10, 12, + 12, 12, 14, 14, 14, 18, 18, 18, 24, 24, + 24, 32, 32, 32, 44, 44, 44, 12, 12, 12 +}; + +static +unsigned char const sfb_22050_mixed[] = { + /* long */ 6, 6, 6, 6, 6, 6, + /* short */ 6, 6, 6, 6, 6, 6, 8, 8, 8, 10, + 10, 10, 14, 14, 14, 18, 18, 18, 26, 26, + 26, 32, 32, 32, 42, 42, 42, 18, 18, 18 +}; + +static +unsigned char const sfb_16000_mixed[] = { + /* long */ 6, 6, 6, 6, 6, 6, + /* short */ 6, 6, 6, 8, 8, 8, 10, 10, 10, 12, + 12, 12, 14, 14, 14, 18, 18, 18, 24, 24, + 24, 30, 30, 30, 40, 40, 40, 18, 18, 18 +}; + +/* + * MPEG 2.5 scalefactor band widths + * derived from public sources + */ +# define sfb_12000_long sfb_16000_long +# define sfb_11025_long sfb_12000_long + +static +unsigned char const sfb_8000_long[] = { + 12, 12, 12, 12, 12, 12, 16, 20, 24, 28, 32, + 40, 48, 56, 64, 76, 90, 2, 2, 2, 2, 2 +}; + +# define sfb_12000_short sfb_16000_short +# define sfb_11025_short sfb_12000_short + +static +unsigned char const sfb_8000_short[] = { + 8, 8, 8, 8, 8, 8, 8, 8, 8, 12, 12, 12, 16, + 16, 16, 20, 20, 20, 24, 24, 24, 28, 28, 28, 36, 36, + 36, 2, 2, 2, 2, 2, 2, 2, 2, 2, 26, 26, 26 +}; + +# define sfb_12000_mixed sfb_16000_mixed +# define sfb_11025_mixed sfb_12000_mixed + +/* the 8000 Hz short block scalefactor bands do not break after + the first 36 frequency lines, so this is probably wrong */ +static +unsigned char const sfb_8000_mixed[] = { + /* long */ 12, 12, 12, + /* short */ 4, 4, 4, 8, 8, 8, 12, 12, 12, 16, 16, 16, + 20, 20, 20, 24, 24, 24, 28, 28, 28, 36, 36, 36, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 26, 26, 26 +}; + +static +struct { + unsigned char const *l; + unsigned char const *s; + unsigned char const *m; +} const sfbwidth_table[9] = { + { sfb_48000_long, sfb_48000_short, sfb_48000_mixed }, + { sfb_44100_long, sfb_44100_short, sfb_44100_mixed }, + { sfb_32000_long, sfb_32000_short, sfb_32000_mixed }, + { sfb_24000_long, sfb_24000_short, sfb_24000_mixed }, + { sfb_22050_long, sfb_22050_short, sfb_22050_mixed }, + { sfb_16000_long, sfb_16000_short, sfb_16000_mixed }, + { sfb_12000_long, sfb_12000_short, sfb_12000_mixed }, + { sfb_11025_long, sfb_11025_short, sfb_11025_mixed }, + { sfb_8000_long, sfb_8000_short, sfb_8000_mixed } +}; + +/* + * scalefactor band preemphasis (used only when preflag is set) + * derived from Table B.6 of ISO/IEC 11172-3 + */ +static +unsigned char const pretab[22] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 3, 3, 3, 2, 0 +}; + +/* + * table for requantization + * + * rq_table[x].mantissa * 2^(rq_table[x].exponent) = x^(4/3) + * + * format rq_table: bit31-27=exponent bit26-0=mantissa + */ +static +unsigned long const rq_table[8207] = { +# include "rq_table.dat" +}; + +/* + * fractional powers of two + * used for requantization and joint stereo decoding + * + * root_table[3 + x] = 2^(x/4) + */ +mad_fixed_t const root_table[7] ICONST_ATTR MEM_ALIGN_ATTR = { + MAD_F(0x09837f05) /* 2^(-3/4) == 0.59460355750136 */, + MAD_F(0x0b504f33) /* 2^(-2/4) == 0.70710678118655 */, + MAD_F(0x0d744fcd) /* 2^(-1/4) == 0.84089641525371 */, + MAD_F(0x10000000) /* 2^( 0/4) == 1.00000000000000 */, + MAD_F(0x1306fe0a) /* 2^(+1/4) == 1.18920711500272 */, + MAD_F(0x16a09e66) /* 2^(+2/4) == 1.41421356237310 */, + MAD_F(0x1ae89f99) /* 2^(+3/4) == 1.68179283050743 */ +}; + +/* + * coefficients for aliasing reduction + * derived from Table B.9 of ISO/IEC 11172-3 + * + * c[] = { -0.6, -0.535, -0.33, -0.185, -0.095, -0.041, -0.0142, -0.0037 } + * cs[i] = 1 / sqrt(1 + c[i]^2) + * ca[i] = c[i] / sqrt(1 + c[i]^2) + */ +mad_fixed_t const cs[8] ICONST_ATTR MEM_ALIGN_ATTR = { + +MAD_F(0x0db84a81) /* +0.857492926 */, +MAD_F(0x0e1b9d7f) /* +0.881741997 */, + +MAD_F(0x0f31adcf) /* +0.949628649 */, +MAD_F(0x0fbba815) /* +0.983314592 */, + +MAD_F(0x0feda417) /* +0.995517816 */, +MAD_F(0x0ffc8fc8) /* +0.999160558 */, + +MAD_F(0x0fff964c) /* +0.999899195 */, +MAD_F(0x0ffff8d3) /* +0.999993155 */ +}; + +mad_fixed_t const ca[8] ICONST_ATTR MEM_ALIGN_ATTR = { + -MAD_F(0x083b5fe7) /* -0.514495755 */, -MAD_F(0x078c36d2) /* -0.471731969 */, + -MAD_F(0x05039814) /* -0.313377454 */, -MAD_F(0x02e91dd1) /* -0.181913200 */, + -MAD_F(0x0183603a) /* -0.094574193 */, -MAD_F(0x00a7cb87) /* -0.040965583 */, + -MAD_F(0x003a2847) /* -0.014198569 */, -MAD_F(0x000f27b4) /* -0.003699975 */ +}; + +/* + * IMDCT coefficients for short blocks + * derived from section 2.4.3.4.10.2 of ISO/IEC 11172-3 + * + * imdct_s[i/even][k] = cos((PI / 24) * (2 * (i / 2) + 7) * (2 * k + 1)) + * imdct_s[i /odd][k] = cos((PI / 24) * (2 * (6 + (i-1)/2) + 7) * (2 * k + 1)) + */ +mad_fixed_t const imdct_s[6][6] ICONST_ATTR MEM_ALIGN_ATTR = { +# include "imdct_s.dat" +}; + +# if !defined(FPM_ARM) +/* + * windowing coefficients for long blocks + * derived from section 2.4.3.4.10.3 of ISO/IEC 11172-3 + * + * window_l[i] = sin((PI / 36) * (i + 1/2)) + */ +static +mad_fixed_t const window_l[36] ICONST_ATTR MEM_ALIGN_ATTR = { + MAD_F(0x00b2aa3e) /* 0.043619387 */, MAD_F(0x0216a2a2) /* 0.130526192 */, + MAD_F(0x03768962) /* 0.216439614 */, MAD_F(0x04cfb0e2) /* 0.300705800 */, + MAD_F(0x061f78aa) /* 0.382683432 */, MAD_F(0x07635284) /* 0.461748613 */, + MAD_F(0x0898c779) /* 0.537299608 */, MAD_F(0x09bd7ca0) /* 0.608761429 */, + MAD_F(0x0acf37ad) /* 0.675590208 */, MAD_F(0x0bcbe352) /* 0.737277337 */, + MAD_F(0x0cb19346) /* 0.793353340 */, MAD_F(0x0d7e8807) /* 0.843391446 */, + + MAD_F(0x0e313245) /* 0.887010833 */, MAD_F(0x0ec835e8) /* 0.923879533 */, + MAD_F(0x0f426cb5) /* 0.953716951 */, MAD_F(0x0f9ee890) /* 0.976296007 */, + MAD_F(0x0fdcf549) /* 0.991444861 */, MAD_F(0x0ffc19fd) /* 0.999048222 */, + MAD_F(0x0ffc19fd) /* 0.999048222 */, MAD_F(0x0fdcf549) /* 0.991444861 */, + MAD_F(0x0f9ee890) /* 0.976296007 */, MAD_F(0x0f426cb5) /* 0.953716951 */, + MAD_F(0x0ec835e8) /* 0.923879533 */, MAD_F(0x0e313245) /* 0.887010833 */, + + MAD_F(0x0d7e8807) /* 0.843391446 */, MAD_F(0x0cb19346) /* 0.793353340 */, + MAD_F(0x0bcbe352) /* 0.737277337 */, MAD_F(0x0acf37ad) /* 0.675590208 */, + MAD_F(0x09bd7ca0) /* 0.608761429 */, MAD_F(0x0898c779) /* 0.537299608 */, + MAD_F(0x07635284) /* 0.461748613 */, MAD_F(0x061f78aa) /* 0.382683432 */, + MAD_F(0x04cfb0e2) /* 0.300705800 */, MAD_F(0x03768962) /* 0.216439614 */, + MAD_F(0x0216a2a2) /* 0.130526192 */, MAD_F(0x00b2aa3e) /* 0.043619387 */, +}; +# endif /* FPM_ARM */ + +/* + * windowing coefficients for short blocks + * derived from section 2.4.3.4.10.3 of ISO/IEC 11172-3 + * + * window_s[i] = sin((PI / 12) * (i + 1/2)) + */ +mad_fixed_t const window_s[12] ICONST_ATTR MEM_ALIGN_ATTR = { + MAD_F(0x0216a2a2) /* 0.130526192 */, MAD_F(0x061f78aa) /* 0.382683432 */, + MAD_F(0x09bd7ca0) /* 0.608761429 */, MAD_F(0x0cb19346) /* 0.793353340 */, + MAD_F(0x0ec835e8) /* 0.923879533 */, MAD_F(0x0fdcf549) /* 0.991444861 */, + MAD_F(0x0fdcf549) /* 0.991444861 */, MAD_F(0x0ec835e8) /* 0.923879533 */, + MAD_F(0x0cb19346) /* 0.793353340 */, MAD_F(0x09bd7ca0) /* 0.608761429 */, + MAD_F(0x061f78aa) /* 0.382683432 */, MAD_F(0x0216a2a2) /* 0.130526192 */, +}; + +/* + * coefficients for intensity stereo processing + * derived from section 2.4.3.4.9.3 of ISO/IEC 11172-3 + * + * is_ratio[i] = tan(i * (PI / 12)) + * is_table[i] = is_ratio[i] / (1 + is_ratio[i]) + */ +static +mad_fixed_t const is_table[7] = { + MAD_F(0x00000000) /* 0.000000000 */, + MAD_F(0x0361962f) /* 0.211324865 */, + MAD_F(0x05db3d74) /* 0.366025404 */, + MAD_F(0x08000000) /* 0.500000000 */, + MAD_F(0x0a24c28c) /* 0.633974596 */, + MAD_F(0x0c9e69d1) /* 0.788675135 */, + MAD_F(0x10000000) /* 1.000000000 */ +}; + +/* + * coefficients for LSF intensity stereo processing + * derived from section 2.4.3.2 of ISO/IEC 13818-3 + * + * is_lsf_table[0][i] = (1 / sqrt(sqrt(2)))^(i + 1) + * is_lsf_table[1][i] = (1 / sqrt(2)) ^(i + 1) + */ +static +mad_fixed_t const is_lsf_table[2][15] = { + { + MAD_F(0x0d744fcd) /* 0.840896415 */, + MAD_F(0x0b504f33) /* 0.707106781 */, + MAD_F(0x09837f05) /* 0.594603558 */, + MAD_F(0x08000000) /* 0.500000000 */, + MAD_F(0x06ba27e6) /* 0.420448208 */, + MAD_F(0x05a8279a) /* 0.353553391 */, + MAD_F(0x04c1bf83) /* 0.297301779 */, + MAD_F(0x04000000) /* 0.250000000 */, + MAD_F(0x035d13f3) /* 0.210224104 */, + MAD_F(0x02d413cd) /* 0.176776695 */, + MAD_F(0x0260dfc1) /* 0.148650889 */, + MAD_F(0x02000000) /* 0.125000000 */, + MAD_F(0x01ae89fa) /* 0.105112052 */, + MAD_F(0x016a09e6) /* 0.088388348 */, + MAD_F(0x01306fe1) /* 0.074325445 */ + }, { + MAD_F(0x0b504f33) /* 0.707106781 */, + MAD_F(0x08000000) /* 0.500000000 */, + MAD_F(0x05a8279a) /* 0.353553391 */, + MAD_F(0x04000000) /* 0.250000000 */, + MAD_F(0x02d413cd) /* 0.176776695 */, + MAD_F(0x02000000) /* 0.125000000 */, + MAD_F(0x016a09e6) /* 0.088388348 */, + MAD_F(0x01000000) /* 0.062500000 */, + MAD_F(0x00b504f3) /* 0.044194174 */, + MAD_F(0x00800000) /* 0.031250000 */, + MAD_F(0x005a827a) /* 0.022097087 */, + MAD_F(0x00400000) /* 0.015625000 */, + MAD_F(0x002d413d) /* 0.011048543 */, + MAD_F(0x00200000) /* 0.007812500 */, + MAD_F(0x0016a09e) /* 0.005524272 */ + } +}; + +/* + * NAME: III_sideinfo() + * DESCRIPTION: decode frame side information from a bitstream + */ +static +enum mad_error III_sideinfo(struct mad_bitptr *ptr, unsigned int nch, + int lsf, struct sideinfo *si, + unsigned int *data_bitlen, + unsigned int *priv_bitlen) +{ + unsigned int ngr, gr, ch, i; + enum mad_error result = MAD_ERROR_NONE; + + *data_bitlen = 0; + *priv_bitlen = lsf ? ((nch == 1) ? 1 : 2) : ((nch == 1) ? 5 : 3); + + si->main_data_begin = mad_bit_read(ptr, lsf ? 8 : 9); + si->private_bits = mad_bit_read(ptr, *priv_bitlen); + + ngr = 1; + if (!lsf) { + ngr = 2; + + for (ch = 0; ch < nch; ++ch) + si->scfsi[ch] = mad_bit_read(ptr, 4); + } + + for (gr = 0; gr < ngr; ++gr) { + struct granule *granule = &si->gr[gr]; + + for (ch = 0; ch < nch; ++ch) { + struct channel *channel = &granule->ch[ch]; + + channel->part2_3_length = mad_bit_read(ptr, 12); + channel->big_values = mad_bit_read(ptr, 9); + channel->global_gain = mad_bit_read(ptr, 8); + channel->scalefac_compress = mad_bit_read(ptr, lsf ? 9 : 4); + + *data_bitlen += channel->part2_3_length; + + if (channel->big_values > 288 && result == 0) + result = MAD_ERROR_BADBIGVALUES; + + channel->flags = 0; + + /* window_switching_flag */ + if (mad_bit_read(ptr, 1)) { + channel->block_type = mad_bit_read(ptr, 2); + + if (channel->block_type == 0 && result == 0) + result = MAD_ERROR_BADBLOCKTYPE; + + if (!lsf && channel->block_type == 2 && si->scfsi[ch] && result == 0) + result = MAD_ERROR_BADSCFSI; + + channel->region0_count = 7; + channel->region1_count = 36; + + if (mad_bit_read(ptr, 1)) + channel->flags |= mixed_block_flag; + else if (channel->block_type == 2) + channel->region0_count = 8; + + for (i = 0; i < 2; ++i) + channel->table_select[i] = mad_bit_read(ptr, 5); + +# if defined(DEBUG) + channel->table_select[2] = 4; /* not used */ +# endif + + for (i = 0; i < 3; ++i) + channel->subblock_gain[i] = mad_bit_read(ptr, 3); + } + else { + channel->block_type = 0; + + for (i = 0; i < 3; ++i) + channel->table_select[i] = mad_bit_read(ptr, 5); + + channel->region0_count = mad_bit_read(ptr, 4); + channel->region1_count = mad_bit_read(ptr, 3); + } + + /* [preflag,] scalefac_scale, count1table_select */ + channel->flags |= mad_bit_read(ptr, lsf ? 2 : 3); + } + } + + return result; +} + +/* + * NAME: III_scalefactors_lsf() + * DESCRIPTION: decode channel scalefactors for LSF from a bitstream + */ +static +unsigned int III_scalefactors_lsf(struct mad_bitptr *ptr, + struct channel *channel, + struct channel *gr1ch, int mode_extension) +{ + struct mad_bitptr start; + unsigned int scalefac_compress, index, slen[4], part, n, i; + unsigned char const *nsfb; + + start = *ptr; + + scalefac_compress = channel->scalefac_compress; + index = (channel->block_type == 2) ? + ((channel->flags & mixed_block_flag) ? 2 : 1) : 0; + + if (!((mode_extension & I_STEREO) && gr1ch)) { + if (scalefac_compress < 400) { + slen[0] = (scalefac_compress >> 4) / 5; + slen[1] = (scalefac_compress >> 4) % 5; + slen[2] = (scalefac_compress % 16) >> 2; + slen[3] = scalefac_compress % 4; + + nsfb = nsfb_table[0][index]; + } + else if (scalefac_compress < 500) { + scalefac_compress -= 400; + + slen[0] = (scalefac_compress >> 2) / 5; + slen[1] = (scalefac_compress >> 2) % 5; + slen[2] = scalefac_compress % 4; + slen[3] = 0; + + nsfb = nsfb_table[1][index]; + } + else { + scalefac_compress -= 500; + + slen[0] = scalefac_compress / 3; + slen[1] = scalefac_compress % 3; + slen[2] = 0; + slen[3] = 0; + + channel->flags |= preflag; + + nsfb = nsfb_table[2][index]; + } + + n = 0; + for (part = 0; part < 4; ++part) { + for (i = 0; i < nsfb[part]; ++i) + channel->scalefac[n++] = mad_bit_read(ptr, slen[part]); + } + + while (n < 39) + channel->scalefac[n++] = 0; + } + else { /* (mode_extension & I_STEREO) && gr1ch (i.e. ch == 1) */ + scalefac_compress >>= 1; + + if (scalefac_compress < 180) { + slen[0] = scalefac_compress / 36; + slen[1] = (scalefac_compress % 36) / 6; + slen[2] = (scalefac_compress % 36) % 6; + slen[3] = 0; + + nsfb = nsfb_table[3][index]; + } + else if (scalefac_compress < 244) { + scalefac_compress -= 180; + + slen[0] = (scalefac_compress % 64) >> 4; + slen[1] = (scalefac_compress % 16) >> 2; + slen[2] = scalefac_compress % 4; + slen[3] = 0; + + nsfb = nsfb_table[4][index]; + } + else { + scalefac_compress -= 244; + + slen[0] = scalefac_compress / 3; + slen[1] = scalefac_compress % 3; + slen[2] = 0; + slen[3] = 0; + + nsfb = nsfb_table[5][index]; + } + + n = 0; + for (part = 0; part < 4; ++part) { + unsigned int max, is_pos; + + max = (1 << slen[part]) - 1; + + for (i = 0; i < nsfb[part]; ++i) { + is_pos = mad_bit_read(ptr, slen[part]); + + channel->scalefac[n] = is_pos; + gr1ch->scalefac[n++] = (is_pos == max); + } + } + + while (n < 39) { + channel->scalefac[n] = 0; + gr1ch->scalefac[n++] = 0; /* apparently not illegal */ + } + } + + return mad_bit_length(&start, ptr); +} + +/* + * NAME: III_scalefactors() + * DESCRIPTION: decode channel scalefactors of one granule from a bitstream + */ +static +unsigned int III_scalefactors(struct mad_bitptr *ptr, struct channel *channel, + struct channel const *gr0ch, unsigned int scfsi) +{ + struct mad_bitptr start; + unsigned int slen1, slen2, sfbi; + + start = *ptr; + + slen1 = sflen_table[channel->scalefac_compress].slen1; + slen2 = sflen_table[channel->scalefac_compress].slen2; + + if (channel->block_type == 2) { + unsigned int nsfb; + + sfbi = 0; + + nsfb = (channel->flags & mixed_block_flag) ? 8 + 3 * 3 : 6 * 3; + while (nsfb--) + channel->scalefac[sfbi++] = mad_bit_read(ptr, slen1); + + nsfb = 6 * 3; + while (nsfb--) + channel->scalefac[sfbi++] = mad_bit_read(ptr, slen2); + + nsfb = 1 * 3; + while (nsfb--) + channel->scalefac[sfbi++] = 0; + } + else { /* channel->block_type != 2 */ + if (scfsi & 0x8) { + for (sfbi = 0; sfbi < 6; ++sfbi) + channel->scalefac[sfbi] = gr0ch->scalefac[sfbi]; + } + else { + for (sfbi = 0; sfbi < 6; ++sfbi) + channel->scalefac[sfbi] = mad_bit_read(ptr, slen1); + } + + if (scfsi & 0x4) { + for (sfbi = 6; sfbi < 11; ++sfbi) + channel->scalefac[sfbi] = gr0ch->scalefac[sfbi]; + } + else { + for (sfbi = 6; sfbi < 11; ++sfbi) + channel->scalefac[sfbi] = mad_bit_read(ptr, slen1); + } + + if (scfsi & 0x2) { + for (sfbi = 11; sfbi < 16; ++sfbi) + channel->scalefac[sfbi] = gr0ch->scalefac[sfbi]; + } + else { + for (sfbi = 11; sfbi < 16; ++sfbi) + channel->scalefac[sfbi] = mad_bit_read(ptr, slen2); + } + + if (scfsi & 0x1) { + for (sfbi = 16; sfbi < 21; ++sfbi) + channel->scalefac[sfbi] = gr0ch->scalefac[sfbi]; + } + else { + for (sfbi = 16; sfbi < 21; ++sfbi) + channel->scalefac[sfbi] = mad_bit_read(ptr, slen2); + } + + channel->scalefac[21] = 0; + } + + return mad_bit_length(&start, ptr); +} + +/* + * The Layer III formula for requantization and scaling is defined by + * section 2.4.3.4.7.1 of ISO/IEC 11172-3, as follows: + * + * long blocks: + * xr[i] = sign(is[i]) * abs(is[i])^(4/3) * + * 2^((1/4) * (global_gain - 210)) * + * 2^-(scalefac_multiplier * + * (scalefac_l[sfb] + preflag * pretab[sfb])) + * + * short blocks: + * xr[i] = sign(is[i]) * abs(is[i])^(4/3) * + * 2^((1/4) * (global_gain - 210 - 8 * subblock_gain[w])) * + * 2^-(scalefac_multiplier * scalefac_s[sfb][w]) + * + * where: + * scalefac_multiplier = (scalefac_scale + 1) / 2 + * + * The routines III_exponents() and III_requantize() facilitate this + * calculation. + */ + +/* + * NAME: III_exponents() + * DESCRIPTION: calculate scalefactor exponents + */ +static +void III_exponents(struct channel const *channel, + unsigned char const *sfbwidth, signed int exponents[39]) +{ + signed int gain; + unsigned int scalefac_multiplier, sfbi; + + gain = (signed int) channel->global_gain - 210; + scalefac_multiplier = (channel->flags & scalefac_scale) ? 2 : 1; + + if (channel->block_type == 2) { + unsigned int l; + signed int gain0, gain1, gain2; + + sfbi = l = 0; + + if (channel->flags & mixed_block_flag) { + unsigned int premask; + + premask = (channel->flags & preflag) ? ~0 : 0; + + /* long block subbands 0-1 */ + + while (l < 36) { + exponents[sfbi] = gain - + (signed int) ((channel->scalefac[sfbi] + (pretab[sfbi] & premask)) << + scalefac_multiplier); + + l += sfbwidth[sfbi++]; + } + } + + /* this is probably wrong for 8000 Hz short/mixed blocks */ + + gain0 = gain - 8 * (signed int) channel->subblock_gain[0]; + gain1 = gain - 8 * (signed int) channel->subblock_gain[1]; + gain2 = gain - 8 * (signed int) channel->subblock_gain[2]; + + while (l < 576) { + exponents[sfbi + 0] = gain0 - + (signed int) (channel->scalefac[sfbi + 0] << scalefac_multiplier); + exponents[sfbi + 1] = gain1 - + (signed int) (channel->scalefac[sfbi + 1] << scalefac_multiplier); + exponents[sfbi + 2] = gain2 - + (signed int) (channel->scalefac[sfbi + 2] << scalefac_multiplier); + unsigned int w = sfbwidth[sfbi]; + l += 3 * w; + sfbi += 3; + } + } + else { /* channel->block_type != 2 */ + if (channel->flags & preflag) { + for (sfbi = 0; sfbi < 22; ++sfbi) { + exponents[sfbi] = gain - + (signed int) ((channel->scalefac[sfbi] + pretab[sfbi]) << + scalefac_multiplier); + } + } + else { + for (sfbi = 0; sfbi < 22; ++sfbi) { + exponents[sfbi] = gain - + (signed int) (channel->scalefac[sfbi] << scalefac_multiplier); + } + } + } +} + +/* + * NAME: III_requantize() + * DESCRIPTION: requantize one (positive) value + */ +static +mad_fixed_t III_requantize(unsigned int value, signed int exp) +{ + mad_fixed_t requantized; + signed int frac; + unsigned long power; + + frac = exp % 4; /* assumes sign(frac) == sign(exp) */ + exp /= 4; + + /* format rq_table: bit31-27=exponent bit26-0=mantissa */ + power = rq_table[value]; + requantized = power & 0x07ffffff; + exp += power >> 27; + + if (exp < 0) { + if (-exp >= (signed int) (sizeof(mad_fixed_t) * CHAR_BIT)) { + /* underflow */ + requantized = 0; + } + else { + requantized += 1L << (-exp - 1); + requantized >>= -exp; + } + } + else { + if (exp >= 5) { + /* overflow */ +# if defined(DEBUG) + fprintf(stderr, "requantize overflow (%f * 2^%d)\n", + mad_f_todouble(requantized), exp); +# endif + requantized = MAD_F_MAX; + } + else + requantized <<= exp; + } + + return frac ? mad_f_mul(requantized, root_table[3 + frac]) : requantized; +} + +/* we must take care that sz >= bits and sz < sizeof(long) lest bits == 0 */ +# if defined(CPU_ARM) +# define MASK(cache, sz, bits) \ + ({ unsigned long res; \ + asm ("mov %0, #1\n\t" \ + "rsb %0, %0, %0, lsl %3\n\t" \ + "and %0, %0, %1, lsr %2" \ + : "=&r" (res) : "r" (cache), "r" ((sz) - (bits)), "r" (bits)); \ + res; \ + }) +#else +# define MASK(cache, sz, bits) \ + (((cache) >> ((sz) - (bits))) & ((1 << (bits)) - 1)) +#endif +# define MASK1BIT(cache, sz) \ + ((cache) & (1 << ((sz) - 1))) + +/* + * NAME: III_huffdecode() + * DESCRIPTION: decode Huffman code words of one channel of one granule + */ +static +enum mad_error III_huffdecode(struct mad_bitptr *ptr, mad_fixed_t xrarr[576], + struct channel *channel, + unsigned char const *sfbwidth, + unsigned int part2_length) +{ + unsigned int bits; + signed int exponents[39], exp; + signed int const *expptr; + struct mad_bitptr peek; + signed int bits_left, cachesz; + register mad_fixed_t *xr; + mad_fixed_t const *sfbound; + register unsigned long bitcache; + + bits_left = (signed) channel->part2_3_length - (signed) part2_length; + if (bits_left < 0) + return MAD_ERROR_BADPART3LEN; + + III_exponents(channel, sfbwidth, exponents); + + peek = *ptr; + cachesz = 0; + sfbound = xr = xrarr; + mad_bit_skip(ptr, bits_left); + + /* big_values */ + { + int region; + struct hufftable const *entry; + union huffpair const *table; + unsigned int linbits, startbits, rcount; + mad_fixed_t reqcache[16]; + mad_fixed_t const *xr_end, *xr_big_val; + + rcount = 1; + expptr = &exponents[0]; + region = -1; + exp = 0x3210; /* start value */ + bitcache = 0; + linbits = startbits = 0; + table = NULL; + xr_big_val = xr + 2 * channel->big_values; + + while(xr < xr_big_val) + { + sfbound += *sfbwidth++; + xr_end = sfbound > xr_big_val ? xr_big_val : sfbound; + + /* change table if region boundary */ + if(--rcount == 0) + { + if(exp == 0x3210) + rcount = channel->region0_count + 1; + else + if(region == 0) + rcount = channel->region1_count + 1; + else + rcount = 0; /* all remaining */ + + entry = &mad_huff_pair_table[channel->table_select[++region]]; + table = entry->table; + linbits = entry->linbits; + startbits = entry->startbits; + + if(table == 0) + return MAD_ERROR_BADHUFFTABLE; + } + + if(exp != *expptr) + { + exp = *expptr; + /* clear cache */ + memset(reqcache, 0, sizeof(reqcache)); + } + + ++expptr; + + if(linbits) + { + for( ; xrfinal) + { + cachesz -= clumpsz; + clumpsz = pair->ptr.bits; + pair = &table[pair->ptr.offset + MASK(bitcache, cachesz, clumpsz)]; + } + + cachesz -= pair->value.hlen; + + /* x (0..14) */ + value = pair->value.x; + if(value == 0) + xr[0] = 0; + else + { + if(value == 15) + { + /* maxlinbits=13bit + sign(x,y)=2bit */ + if(cachesz < 15) + { + if(cachesz < 0) + return MAD_ERROR_BADHUFFDATA; /* cache underrun */ + + bits = MAXLSHIFT - cachesz; + bitcache = (bitcache << bits) | mad_bit_read(&peek, bits); + cachesz += bits; + } + + requantized = III_requantize(15+MASK(bitcache, cachesz, linbits), exp); + cachesz -= linbits; + } + else + { + if(reqcache[value]) + requantized = reqcache[value]; + else + requantized = reqcache[value] = III_requantize(value, exp); + } + + xr[0] = MASK1BIT(bitcache, cachesz--) ? -requantized : requantized; + } + + /* y (0..14) */ + value = pair->value.y; + if(value == 0) + xr[1] = 0; + else + { + if(value == 15) + { + /* maxlinbits=13bit + sign(y)=1bit */ + if(cachesz < 14) + { + if(cachesz < 0) + return MAD_ERROR_BADHUFFDATA; /* cache underrun */ + + bits = MAXLSHIFT - cachesz; + bitcache = (bitcache << bits) | mad_bit_read(&peek, bits); + cachesz += bits; + } + + requantized = III_requantize(15+MASK(bitcache, cachesz, linbits), exp); + cachesz -= linbits; + } + else + { + if(reqcache[value]) + requantized = reqcache[value]; + else + requantized = reqcache[value] = III_requantize(value, exp); + } + xr[1] = MASK1BIT(bitcache, cachesz--) ? -requantized : requantized; + } + } + } + else + { + for( ; xrfinal) + { + cachesz -= clumpsz; + + /* maxlookup=4bit + sign(x,y)=2bit */ + if(cachesz < 6) + { + if(cachesz < 0) + return MAD_ERROR_BADHUFFDATA; /* cache underrun */ + + bits = MAXLSHIFT - cachesz; + bitcache = (bitcache << bits) | mad_bit_read(&peek, bits); + cachesz += bits; + } + + clumpsz = pair->ptr.bits; + pair = &table[pair->ptr.offset + MASK(bitcache, cachesz, clumpsz)]; + } + + cachesz -= pair->value.hlen; + + /* x (0..1) */ + value = pair->value.x; + if(value == 0) + xr[0] = 0; + else + { + if(reqcache[value]) + requantized = reqcache[value]; + else + requantized = reqcache[value] = III_requantize(value, exp); + + xr[0] = MASK1BIT(bitcache, cachesz--) ? -requantized : requantized; + } + + /* y (0..1) */ + value = pair->value.y; + if(value == 0) + xr[1] = 0; + else + { + if(reqcache[value]) + requantized = reqcache[value]; + else + requantized = reqcache[value] = III_requantize(value, exp); + + xr[1] = MASK1BIT(bitcache, cachesz--) ? -requantized : requantized; + } + } + } + } + } + + bits_left = ptr->readbit - peek.readbit; + + if(bits_left + cachesz < 0) + return MAD_ERROR_BADHUFFDATA; /* big_values overrun */ + + /* count1 */ + { + union huffquad const *table; + register mad_fixed_t requantized; + + table = mad_huff_quad_table[channel->flags & count1table_select]; + + requantized = III_requantize(1, exp); + + while(xr <= &xrarr[572] && bits_left + cachesz > 0) + { + union huffquad const *quad; + + /* hcod (1..6) */ + if(cachesz < 10) + { + if(cachesz < 0) + return MAD_ERROR_BADHUFFDATA; /* cache underrun */ + + bits = MAXLSHIFT - cachesz; + bitcache = (bitcache << bits) | mad_bit_read(&peek, bits); + cachesz += bits; + bits_left -= bits; + } + + quad = &table[MASK(bitcache, cachesz, 4)]; + + /* quad tables guaranteed to have at most one extra lookup */ + if (!quad->final) { + cachesz -= 4; + + quad = &table[quad->ptr.offset + + MASK(bitcache, cachesz, quad->ptr.bits)]; + } + + cachesz -= quad->value.hlen; + + if (xr == sfbound) { + sfbound += *sfbwidth++; + + if (exp != *expptr) { + exp = *expptr; + requantized = III_requantize(1, exp); + } + + ++expptr; + } + + /* v (0..1) */ + xr[0] = quad->value.v ? + (MASK1BIT(bitcache, cachesz--) ? -requantized : requantized) : 0; + + /* w (0..1) */ + xr[1] = quad->value.w ? + (MASK1BIT(bitcache, cachesz--) ? -requantized : requantized) : 0; + + xr += 2; + + if (xr == sfbound) { + sfbound += *sfbwidth++; + + if (exp != *expptr) { + exp = *expptr; + requantized = III_requantize(1, exp); + } + + ++expptr; + } + + /* x (0..1) */ + xr[0] = quad->value.x ? + (MASK1BIT(bitcache, cachesz--) ? -requantized : requantized) : 0; + + /* y (0..1) */ + xr[1] = quad->value.y ? + (MASK1BIT(bitcache, cachesz--) ? -requantized : requantized) : 0; + + xr += 2; + } + + if(bits_left + cachesz < 0) + { + /* technically the bitstream is misformatted, but apparently + some encoders are just a bit sloppy with stuffing bits */ + xr -= 4; + } + } + + /* rzero */ + memset(xr, 0, (char*)&xrarr[576] - (char*)xr); + + return MAD_ERROR_NONE; +} + +# undef MASK +# undef MASK1BIT + +/* + * NAME: III_reorder() + * DESCRIPTION: reorder frequency lines of a short block into subband order + */ +static +void III_reorder(mad_fixed_t xr[576], struct channel const *channel, + unsigned char const sfbwidth[39]) +{ + mad_fixed_t tmp[32][3][6]; + unsigned int sb, l, f, w, sbw[3], sw[3]; + + /* this is probably wrong for 8000 Hz mixed blocks */ + + sb = 0; + if (channel->flags & mixed_block_flag) { + sb = 2; + + l = 0; + while (l < 36) + l += *sfbwidth++; + } + + for (w = 0; w < 3; ++w) { + sbw[w] = sb; + sw[w] = 0; + } + + f = *sfbwidth++; + w = 0; + + for (l = 18 * sb; l < 576; ++l) { + if (f-- == 0) { + f = *sfbwidth++ - 1; + w = (w + 1) % 3; + } + + unsigned int sbww = sbw[w]; + tmp[sbww][w][sw[w]++] = xr[l]; + + if (sw[w] == 6) { + sw[w] = 0; + ++sbw[w]; + } + } + + memcpy(&xr[18 * sb], &tmp[sb], (576 - 18 * sb) * sizeof(mad_fixed_t)); +} + +/* + * NAME: III_stereo() + * DESCRIPTION: perform joint stereo processing on a granule + */ +static +enum mad_error III_stereo(mad_fixed_t xr[2][576], + struct granule const *granule, + struct mad_header *header, + unsigned char const *sfbwidth) +{ + short modes[39]; + unsigned int sfbi, l, n, i; + + if (granule->ch[0].block_type != + granule->ch[1].block_type || + (granule->ch[0].flags & mixed_block_flag) != + (granule->ch[1].flags & mixed_block_flag)) + return MAD_ERROR_BADSTEREO; + + for (i = 0; i < 39; ++i) + modes[i] = header->mode_extension; + + /* intensity stereo */ + + if (header->mode_extension & I_STEREO) { + struct channel const *right_ch = &granule->ch[1]; + mad_fixed_t const *right_xr = xr[1]; + unsigned int is_pos; + + header->flags |= MAD_FLAG_I_STEREO; + + /* first determine which scalefactor bands are to be processed */ + + if (right_ch->block_type == 2) { + unsigned int lower, start, max, bound[3], w; + + lower = start = max = bound[0] = bound[1] = bound[2] = 0; + + sfbi = l = 0; + + if (right_ch->flags & mixed_block_flag) { + while (l < 36) { + n = sfbwidth[sfbi++]; + + for (i = 0; i < n; ++i) { + if (right_xr[i]) { + lower = sfbi; + break; + } + } + + right_xr += n; + l += n; + } + + start = sfbi; + } + + w = 0; + while (l < 576) { + n = sfbwidth[sfbi++]; + + for (i = 0; i < n; ++i) { + if (right_xr[i]) { + max = bound[w] = sfbi; + break; + } + } + + right_xr += n; + l += n; + w = (w + 1) % 3; + } + + if (max) + lower = start; + + /* long blocks */ + + for (i = 0; i < lower; ++i) + modes[i] = header->mode_extension & ~I_STEREO; + + /* short blocks */ + + w = 0; + for (i = start; i < max; ++i) { + if (i < bound[w]) + modes[i] = header->mode_extension & ~I_STEREO; + + w = (w + 1) % 3; + } + } + else { /* right_ch->block_type != 2 */ + unsigned int bound; + + bound = 0; + for (sfbi = l = 0; l < 576; l += n) { + n = sfbwidth[sfbi++]; + + for (i = 0; i < n; ++i) { + if (right_xr[i]) { + bound = sfbi; + break; + } + } + + right_xr += n; + } + + for (i = 0; i < bound; ++i) + modes[i] = header->mode_extension & ~I_STEREO; + } + + /* now do the actual processing */ + + if (header->flags & MAD_FLAG_LSF_EXT) { + unsigned char const *illegal_pos = granule[1].ch[1].scalefac; + mad_fixed_t const *lsf_scale; + + /* intensity_scale */ + lsf_scale = is_lsf_table[right_ch->scalefac_compress & 0x1]; + + for (sfbi = l = 0; l < 576; ++sfbi, l += n) { + n = sfbwidth[sfbi]; + + if (!(modes[sfbi] & I_STEREO)) + continue; + + if (illegal_pos[sfbi]) { + modes[sfbi] &= ~I_STEREO; + continue; + } + + is_pos = right_ch->scalefac[sfbi]; + + for (i = 0; i < n; ++i) { + register mad_fixed_t left; + + left = xr[0][l + i]; + + if (is_pos == 0) + xr[1][l + i] = left; + else { + register mad_fixed_t opposite; + + opposite = mad_f_mul(left, lsf_scale[(is_pos - 1) / 2]); + + if (is_pos & 1) { + xr[0][l + i] = opposite; + xr[1][l + i] = left; + } + else + xr[1][l + i] = opposite; + } + } + } + } + else { /* !(header->flags & MAD_FLAG_LSF_EXT) */ + for (sfbi = l = 0; l < 576; ++sfbi, l += n) { + n = sfbwidth[sfbi]; + + if (!(modes[sfbi] & I_STEREO)) + continue; + + is_pos = right_ch->scalefac[sfbi]; + + if (is_pos >= 7) { /* illegal intensity position */ + modes[sfbi] &= ~I_STEREO; + continue; + } + + for (i = 0; i < n; ++i) { + register mad_fixed_t left; + + left = xr[0][l + i]; + + xr[0][l + i] = mad_f_mul(left, is_table[ is_pos]); + xr[1][l + i] = mad_f_mul(left, is_table[6 - is_pos]); + } + } + } + } + + /* middle/side stereo */ + + if (header->mode_extension & MS_STEREO) { + register mad_fixed_t invsqrt2; + + header->flags |= MAD_FLAG_MS_STEREO; + + invsqrt2 = root_table[3 + -2]; + + for (sfbi = l = 0; l < 576; ++sfbi, l += n) { + n = sfbwidth[sfbi]; + + if (modes[sfbi] != MS_STEREO) + continue; + + for (i = 0; i < n; ++i) { + register mad_fixed_t m, s; + + m = xr[0][l + i]; + s = xr[1][l + i]; + + xr[0][l + i] = mad_f_mul(m + s, invsqrt2); /* l = (m + s) / sqrt(2) */ + xr[1][l + i] = mad_f_mul(m - s, invsqrt2); /* r = (m - s) / sqrt(2) */ + } + } + } + + return MAD_ERROR_NONE; +} + +#if defined(CPU_ARM) +void III_aliasreduce(mad_fixed_t xr[576], int lines); +#else +/* + * NAME: III_aliasreduce() + * DESCRIPTION: perform frequency line alias reduction + */ +static +void III_aliasreduce(mad_fixed_t xr[576], int lines) +{ + mad_fixed_t const *bound; + int i; + + bound = &xr[lines]; + for (xr += 18; xr < bound; xr += 18) { + for (i = 0; i < 8; ++i) { + register mad_fixed_t a, b; + register mad_fixed64hi_t hi; + register mad_fixed64lo_t lo; + + a = xr[-1 - i]; + b = xr[ i]; + +# if defined(CPU_COLDFIRE) + (void)hi, (void)lo; + asm volatile ("mac.l %[a], %[csi], %%acc0\n\t" + "msac.l %[b], %[cai], %%acc0\n\t" + "mac.l %[b], %[csi], %%acc1\n\t" + "mac.l %[a], %[cai], %%acc1\n\t" + "movclr.l %%acc0, %[a]\n\t" + "asl.l #3, %[a]\n\t" + "movclr.l %%acc1, %[b]\n\t" + "asl.l #3, %[b]\n\t" + : [a] "+d" (a), [b] "+d" (b) + : [csi] "r" (cs[i]), [cai] "r" (ca[i])); + xr[-1 - i] = a; + xr[ i] = b; +# else + MAD_F_ML0(hi, lo, a, cs[i]); + MAD_F_MLA(hi, lo, -b, ca[i]); + + xr[-1 - i] = MAD_F_MLZ(hi, lo); + + MAD_F_ML0(hi, lo, b, cs[i]); + MAD_F_MLA(hi, lo, a, ca[i]); + + xr[ i] = MAD_F_MLZ(hi, lo); +# endif + } + } +} +#endif + +# if defined(FPM_ARM) +void III_imdct_l(mad_fixed_t const [18], mad_fixed_t [36], unsigned int); +# else +/* + * NAME: imdct36 + * DESCRIPTION: perform X[18]->x[36] IMDCT + */ +# if defined(CPU_COLDFIRE) +/* emac optimized imdct36, it is very ugly and i hope to replace it soon. + * for now it is actually somewhat faster than the stock implementation. + */ +static inline +void imdct36(mad_fixed_t const X[18], mad_fixed_t x[36]) +{ + mad_fixed_t t[16]; + /* assumes FRACBITS = 28 */ + asm volatile ( + /* MAD_F_ML0(hi, lo, X[4], MAD_F(0x0ec835e8)); */ + /* MAD_F_MLA(hi, lo, X[13], MAD_F(0x061f78aa)); */ + /* t6 = MAD_F_MLZ(hi, lo); */ + "move.l (4*4, %[X]), %%d0\n" + "move.l #0x0ec835e8, %%d1\n" + "move.l #0x061f78aa, %%d2\n" + "mac.l %%d1, %%d0, (13*4, %[X]), %%d0, %%acc0\n" + "mac.l %%d2, %%d0, ( 1*4, %[X]), %%d0, %%acc0\n" + "move.l %%acc0, %%d7\n" + "asl.l #3, %%d7\n" + "move.l %%d7, (6*4, %[t])\n" + + /* MAD_F_ML0(hi, lo, (t14 = X[1] - X[10]), -MAD_F(0x0ec835e8)); */ + /* MAD_F_MLA(hi, lo, (t15 = X[7] + X[16]), MAD_F(0x061f78aa)); */ + /* t4 = MAD_F_MLZ(hi, lo); */ + /* MAD_F_MLA(hi, lo, t14, -MAD_F(0x061f78aa)); */ + /* MAD_F_MLA(hi, lo, t15, -MAD_F(0x0ec835e8)); */ + /* t0 = MAD_F_MLZ(hi, lo); */ + "sub.l (10*4, %[X]), %%d0\n" /* t14 */ + "msac.l %%d0, %%d1, %%acc1\n" + "msac.l %%d0, %%d2, (7*4, %[X]), %%d5, %%acc0\n" + "add.l (16*4, %[X]), %%d5\n" /* t15 */ + "mac.l %%d5, %%d2, %%acc1\n" + "msac.l %%d5, %%d1, ( %[X]), %%d5, %%acc0\n" + "movclr.l %%acc1, %%d6\n" + "asl.l #3, %%d6\n" /* t4 */ + "move.l %%d6, (4*4, %[t])\n" + "move.l %%acc0, %%d0\n" + "asl.l #3, %%d0\n" /* t0 */ + "move.l %%d0, (0*4, %[t])\n" + + /* MAD_F_MLA(hi, lo, (t8 =X[0]-X[11]-X[12]), MAD_F(0x0216a2a2)); */ + /* MAD_F_MLA(hi, lo, (t9 =X[2]-X[ 9]-X[14]), MAD_F(0x09bd7ca0)); */ + /* MAD_F_MLA(hi, lo, (t10=X[3]-X[ 8]-X[15]), -MAD_F(0x0cb19346)); */ + /* MAD_F_MLA(hi, lo, (t11=X[5]-X[ 6]-X[17]), -MAD_F(0x0fdcf549)); */ + /* x[10] = -(x[7] = MAD_F_MLZ(hi, lo)); */ + + /* MAD_F_ML0(hi, lo, t8, -MAD_F(0x0cb19346)); */ + /* MAD_F_MLA(hi, lo, t9, MAD_F(0x0fdcf549)); */ + /* MAD_F_MLA(hi, lo, t10, MAD_F(0x0216a2a2)); */ + /* MAD_F_MLA(hi, lo, t11, -MAD_F(0x09bd7ca0)); */ + /* x[19] = x[34] = MAD_F_MLZ(hi, lo) - t0; */ + + /* MAD_F_ML0(hi, lo, t8, MAD_F(0x09bd7ca0)); */ + /* MAD_F_MLA(hi, lo, t9, -MAD_F(0x0216a2a2)); */ + /* MAD_F_MLA(hi, lo, t10, MAD_F(0x0fdcf549)); */ + /* MAD_F_MLA(hi, lo, t11, -MAD_F(0x0cb19346)); */ + /* x[ 1] = MAD_F_MLZ(hi, lo); */ + + /* MAD_F_ML0(hi, lo, t8, -MAD_F(0x0fdcf549)); */ + /* MAD_F_MLA(hi, lo, t9, -MAD_F(0x0cb19346)); */ + /* MAD_F_MLA(hi, lo, t10, -MAD_F(0x09bd7ca0)); */ + /* MAD_F_MLA(hi, lo, t11, -MAD_F(0x0216a2a2)); */ + /* x[25] = MAD_F_MLZ(hi, lo); */ + + /* t12 = t8 - t10; */ + /* t13 = t9 + t11; */ + "move.l #0x0216a2a2, %%d1\n" + "move.l #0x0cb19346, %%d2\n" + "move.l #0x09bd7ca0, %%d3\n" + "move.l #0x0fdcf549, %%d4\n" + "sub.l (11*4, %[X]), %%d5\n" + "sub.l (12*4, %[X]), %%d5\n" + "mac.l %%d1, %%d5, %%acc0\n" + "msac.l %%d2, %%d5, %%acc1\n" + "mac.l %%d3, %%d5, %%acc2\n" + "msac.l %%d4, %%d5, (2*4, %[X]), %%d6, %%acc3\n" + "sub.l ( 9*4, %[X]), %%d6\n" + "sub.l (14*4, %[X]), %%d6\n" + "mac.l %%d3, %%d6, %%acc0\n" + "mac.l %%d4, %%d6, %%acc1\n" + "msac.l %%d1, %%d6, %%acc2\n" + "msac.l %%d2, %%d6, (3*4, %[X]), %%d7, %%acc3\n" + "sub.l ( 8*4, %[X]), %%d7\n" + "sub.l (15*4, %[X]), %%d7\n" + "sub.l %%d7, %%d5\n" /* d5: t12 */ + "move.l %%d5, (12*4, %[t])\n" + "msac.l %%d2, %%d7, %%acc0\n" + "mac.l %%d1, %%d7, %%acc1\n" + "mac.l %%d4, %%d7, %%acc2\n" + "msac.l %%d3, %%d7, (5*4, %[X]), %%d7, %%acc3\n" + "sub.l ( 6*4, %[X]), %%d7\n" + "sub.l (17*4, %[X]), %%d7\n" + "add.l %%d7, %%d6\n" /* d6: t13 */ + "move.l %%d6, (13*4, %[t])\n" + "msac.l %%d4, %%d7, %%acc0\n" + "msac.l %%d3, %%d7, %%acc1\n" + "msac.l %%d2, %%d7, %%acc2\n" + "msac.l %%d1, %%d7, (1*4, %[X]), %%d5, %%acc3\n" + + "movclr.l %%acc0, %%d7\n" + "asl.l #3, %%d7\n" + "move.l %%d7, (7*4, %[x])\n" + "neg.l %%d7\n" + "move.l %%d7, (10*4, %[x])\n" + + "movclr.l %%acc1, %%d7\n" + "asl.l #3, %%d7\n" + "sub.l %%d0, %%d7\n" + "move.l %%d7, (19*4, %[x])\n" + "move.l %%d7, (34*4, %[x])\n" + + "movclr.l %%acc2, %%d7\n" + "asl.l #3, %%d7\n" + "move.l %%d7, ( 1*4, %[x])\n" + + "movclr.l %%acc3, %%d7\n" + "asl.l #3, %%d7\n" + "move.l %%d7, (25*4, %[x])\n" + + /* MAD_F_ML0(hi, lo, X[1], -MAD_F(0x09bd7ca0)); */ + /* MAD_F_MLA(hi, lo, X[7], MAD_F(0x0216a2a2)); */ + /* MAD_F_MLA(hi, lo, X[10], -MAD_F(0x0fdcf549)); */ + /* MAD_F_MLA(hi, lo, X[16], MAD_F(0x0cb19346)); */ + /* t1 = MAD_F_MLZ(hi, lo) + t6; */ + + /* MAD_F_ML0(hi, lo, X[1], -MAD_F(0x0216a2a2)); */ + /* MAD_F_MLA(hi, lo, X[7], -MAD_F(0x09bd7ca0)); */ + /* MAD_F_MLA(hi, lo, X[10], MAD_F(0x0cb19346)); */ + /* MAD_F_MLA(hi, lo, X[16], MAD_F(0x0fdcf549)); */ + /* t3 = MAD_F_MLZ(hi, lo); */ + + /* MAD_F_ML0(hi, lo, X[1], -MAD_F(0x0fdcf549)); */ + /* MAD_F_MLA(hi, lo, X[7], -MAD_F(0x0cb19346)); */ + /* MAD_F_MLA(hi, lo, X[10], -MAD_F(0x09bd7ca0)); */ + /* MAD_F_MLA(hi, lo, X[16], -MAD_F(0x0216a2a2)); */ + /* t5 = MAD_F_MLZ(hi, lo) - t6; */ + "msac.l %%d3, %%d5, %%acc0\n" + "msac.l %%d1, %%d5, %%acc1\n" + "msac.l %%d4, %%d5, ( 7*4, %[X]), %%d5, %%acc2\n" + "mac.l %%d1, %%d5, %%acc0\n" + "msac.l %%d3, %%d5, %%acc1\n" + "msac.l %%d2, %%d5, (10*4, %[X]), %%d5, %%acc2\n" + "msac.l %%d4, %%d5, %%acc0\n" + "mac.l %%d2, %%d5, %%acc1\n" + "msac.l %%d3, %%d5, (16*4, %[X]), %%d5, %%acc2\n" + "mac.l %%d2, %%d5, %%acc0\n" + "mac.l %%d4, %%d5, %%acc1\n" + "msac.l %%d1, %%d5, ( 0*4, %[X]), %%d0, %%acc2\n" + + "movclr.l %%acc0, %%d7\n" + "asl.l #3, %%d7\n" + "add.l (6*4, %[t]), %%d7\n" /* t1 */ + + "movclr.l %%acc1, %%d5\n" + "asl.l #3, %%d5\n" /* t3 */ + + "movclr.l %%acc2, %%d6\n" + "asl.l #3, %%d6\n" + "sub.l (6*4, %[t]), %%d6\n" /* t5 */ + "move.l %%d6, (5*4, %[t])\n" + + /* MAD_F_ML0(hi, lo, X[0], MAD_F(0x03768962)); */ + /* MAD_F_MLA(hi, lo, X[2], MAD_F(0x0e313245)); */ + /* MAD_F_MLA(hi, lo, X[3], -MAD_F(0x0ffc19fd)); */ + /* MAD_F_MLA(hi, lo, X[5], -MAD_F(0x0acf37ad)); */ + /* MAD_F_MLA(hi, lo, X[6], MAD_F(0x04cfb0e2)); */ + /* MAD_F_MLA(hi, lo, X[8], -MAD_F(0x0898c779)); */ + /* MAD_F_MLA(hi, lo, X[9], MAD_F(0x0d7e8807)); */ + /* MAD_F_MLA(hi, lo, X[11], MAD_F(0x0f426cb5)); */ + /* MAD_F_MLA(hi, lo, X[12], -MAD_F(0x0bcbe352)); */ + /* MAD_F_MLA(hi, lo, X[14], MAD_F(0x00b2aa3e)); */ + /* MAD_F_MLA(hi, lo, X[15], -MAD_F(0x07635284)); */ + /* MAD_F_MLA(hi, lo, X[17], -MAD_F(0x0f9ee890)); */ + /* x[11] = -(x[6] = MAD_F_MLZ(hi, lo) + t1); */ + /* MAD_F_ML0(hi, lo, X[0], -MAD_F(0x0f426cb5)); */ + /* MAD_F_MLA(hi, lo, X[2], -MAD_F(0x00b2aa3e)); */ + /* MAD_F_MLA(hi, lo, X[3], MAD_F(0x0898c779)); */ + /* MAD_F_MLA(hi, lo, X[5], MAD_F(0x0f9ee890)); */ + /* MAD_F_MLA(hi, lo, X[6], MAD_F(0x0acf37ad)); */ + /* MAD_F_MLA(hi, lo, X[8], -MAD_F(0x07635284)); */ + /* MAD_F_MLA(hi, lo, X[9], -MAD_F(0x0e313245)); */ + /* MAD_F_MLA(hi, lo, X[11], -MAD_F(0x0bcbe352)); */ + /* MAD_F_MLA(hi, lo, X[12], -MAD_F(0x03768962)); */ + /* MAD_F_MLA(hi, lo, X[14], MAD_F(0x0d7e8807)); */ + /* MAD_F_MLA(hi, lo, X[15], MAD_F(0x0ffc19fd)); */ + /* MAD_F_MLA(hi, lo, X[17], MAD_F(0x04cfb0e2)); */ + /* x[23] = x[30] = MAD_F_MLZ(hi, lo) + t1; */ + /* MAD_F_ML0(hi, lo, X[0], -MAD_F(0x0bcbe352)); */ + /* MAD_F_MLA(hi, lo, X[2], MAD_F(0x0d7e8807)); */ + /* MAD_F_MLA(hi, lo, X[3], -MAD_F(0x07635284)); */ + /* MAD_F_MLA(hi, lo, X[5], MAD_F(0x04cfb0e2)); */ + /* MAD_F_MLA(hi, lo, X[6], MAD_F(0x0f9ee890)); */ + /* MAD_F_MLA(hi, lo, X[8], -MAD_F(0x0ffc19fd)); */ + /* MAD_F_MLA(hi, lo, X[9], -MAD_F(0x00b2aa3e)); */ + /* MAD_F_MLA(hi, lo, X[11], MAD_F(0x03768962)); */ + /* MAD_F_MLA(hi, lo, X[12], -MAD_F(0x0f426cb5)); */ + /* MAD_F_MLA(hi, lo, X[14], MAD_F(0x0e313245)); */ + /* MAD_F_MLA(hi, lo, X[15], MAD_F(0x0898c779)); */ + /* MAD_F_MLA(hi, lo, X[17], -MAD_F(0x0acf37ad)); */ + /* x[18] = x[35] = MAD_F_MLZ(hi, lo) - t1; */ + "move.l #0x03768962, %%d1\n" + "move.l #0x0f426cb5, %%d2\n" + "move.l #0x0bcbe352, %%d3\n" + "mac.l %%d1, %%d0, %%acc0\n" + "msac.l %%d2, %%d0, %%acc1\n" + "msac.l %%d3, %%d0, (11*4, %[X]), %%d0, %%acc2\n" + "mac.l %%d2, %%d0, %%acc0\n" + "msac.l %%d3, %%d0, %%acc1\n" + "mac.l %%d1, %%d0, (12*4, %[X]), %%d0, %%acc2\n" + "msac.l %%d3, %%d0, %%acc0\n" + "msac.l %%d1, %%d0, %%acc1\n" + "msac.l %%d2, %%d0, ( 2*4, %[X]), %%d0, %%acc2\n" + "move.l #0x0e313245, %%d1\n" + "move.l #0x00b2aa3e, %%d2\n" + "move.l #0x0d7e8807, %%d3\n" + "mac.l %%d1, %%d0, %%acc0\n" + "msac.l %%d2, %%d0, %%acc1\n" + "mac.l %%d3, %%d0, ( 9*4, %[X]), %%d0, %%acc2\n" + "mac.l %%d3, %%d0, %%acc0\n" + "msac.l %%d1, %%d0, %%acc1\n" + "msac.l %%d2, %%d0, (14*4, %[X]), %%d0, %%acc2\n" + "mac.l %%d2, %%d0, %%acc0\n" + "mac.l %%d3, %%d0, %%acc1\n" + "mac.l %%d1, %%d0, ( 3*4, %[X]), %%d0, %%acc2\n" + "move.l #0x0ffc19fd, %%d1\n" + "move.l #0x0898c779, %%d2\n" + "move.l #0x07635284, %%d3\n" + "msac.l %%d1, %%d0, %%acc0\n" + "mac.l %%d2, %%d0, %%acc1\n" + "msac.l %%d3, %%d0, ( 8*4, %[X]), %%d0, %%acc2\n" + "msac.l %%d2, %%d0, %%acc0\n" + "msac.l %%d3, %%d0, %%acc1\n" + "msac.l %%d1, %%d0, (15*4, %[X]), %%d0, %%acc2\n" + "msac.l %%d3, %%d0, %%acc0\n" + "mac.l %%d1, %%d0, %%acc1\n" + "mac.l %%d2, %%d0, ( 5*4, %[X]), %%d0, %%acc2\n" + "move.l #0x0acf37ad, %%d1\n" + "move.l #0x0f9ee890, %%d2\n" + "move.l #0x04cfb0e2, %%d3\n" + "msac.l %%d1, %%d0, %%acc0\n" + "mac.l %%d2, %%d0, %%acc1\n" + "mac.l %%d3, %%d0, ( 6*4, %[X]), %%d0, %%acc2\n" + "mac.l %%d3, %%d0, %%acc0\n" + "mac.l %%d1, %%d0, %%acc1\n" + "mac.l %%d2, %%d0, (17*4, %[X]), %%d0, %%acc2\n" + "msac.l %%d2, %%d0, %%acc0\n" + "mac.l %%d3, %%d0, %%acc1\n" + "msac.l %%d1, %%d0, ( 4*4, %[X]), %%d0, %%acc2\n" + + "movclr.l %%acc0, %%d6\n" + "asl.l #3, %%d6\n" + "add.l %%d7, %%d6\n" + "move.l %%d6, (6*4, %[x])\n" + "neg.l %%d6\n" + "move.l %%d6, (11*4, %[x])\n" + + "movclr.l %%acc1, %%d6\n" + "asl.l #3, %%d6\n" + "add.l %%d7, %%d6\n" + "move.l %%d6, (23*4, %[x])\n" + "move.l %%d6, (30*4, %[x])\n" + + "movclr.l %%acc2, %%d6\n" + "asl.l #3, %%d6\n" + "sub.l %%d7, %%d6\n" + "move.l %%d6, (18*4, %[x])\n" + "move.l %%d6, (35*4, %[x])\n" + + /* MAD_F_ML0(hi, lo, X[4], MAD_F(0x061f78aa)); */ + /* MAD_F_MLA(hi, lo, X[13], -MAD_F(0x0ec835e8)); */ + /* t3 += (t7 = MAD_F_MLZ(hi, lo)); */ + /* t4 -= t7; */ + "move.l #0x061f78aa, %%d1\n" + "mac.l %%d1, %%d0, (13*4, %[X]), %%d0, %%acc0\n" + "move.l #0x0ec835e8, %%d1\n" + "msac.l %%d1, %%d0, (1*4, %[X]), %%d0, %%acc0\n" + "move.l %%acc0, %%d6\n" + "asl.l #3, %%d6\n" /* t7 */ + "add.l %%d6, %%d5\n" /* t3 */ + "move.l (4*4, %[t]), %%d1\n" + "sub.l %%d6, %%d1\n" /* t4 */ + "move.l %%d1, (4*4, %[t])\n" + + /* MAD_F_MLA(hi, lo, X[1], -MAD_F(0x0cb19346)); */ + /* MAD_F_MLA(hi, lo, X[7], MAD_F(0x0fdcf549)); */ + /* MAD_F_MLA(hi, lo, X[10], MAD_F(0x0216a2a2)); */ + /* MAD_F_MLA(hi, lo, X[16], -MAD_F(0x09bd7ca0)); */ + /* t2 = MAD_F_MLZ(hi, lo); */ + "move.l #0x0cb19346, %%d1\n" + "msac.l %%d1, %%d0, ( 7*4, %[X]), %%d0, %%acc0\n" + "move.l #0x0fdcf549, %%d1\n" + "mac.l %%d1, %%d0, (10*4, %[X]), %%d0, %%acc0\n" + "move.l #0x0216a2a2, %%d1\n" + "mac.l %%d1, %%d0, (16*4, %[X]), %%d0, %%acc0\n" + "move.l #0x09bd7ca0, %%d1\n" + "msac.l %%d1, %%d0, ( %[X]), %%d0, %%acc0\n" + "move.l %%acc0, %%d7\n" + "asl.l #3, %%d7\n" /* t2 */ + + /* MAD_F_MLA(hi, lo, X[0], MAD_F(0x04cfb0e2)); */ + /* MAD_F_MLA(hi, lo, X[2], MAD_F(0x0ffc19fd)); */ + /* MAD_F_MLA(hi, lo, X[3], -MAD_F(0x0d7e8807)); */ + /* MAD_F_MLA(hi, lo, X[5], MAD_F(0x03768962)); */ + /* MAD_F_MLA(hi, lo, X[6], -MAD_F(0x0bcbe352)); */ + /* MAD_F_MLA(hi, lo, X[8], -MAD_F(0x0e313245)); */ + /* MAD_F_MLA(hi, lo, X[9], MAD_F(0x07635284)); */ + /* MAD_F_MLA(hi, lo, X[11], -MAD_F(0x0acf37ad)); */ + /* MAD_F_MLA(hi, lo, X[12], MAD_F(0x0f9ee890)); */ + /* MAD_F_MLA(hi, lo, X[14], MAD_F(0x0898c779)); */ + /* MAD_F_MLA(hi, lo, X[15], MAD_F(0x00b2aa3e)); */ + /* MAD_F_MLA(hi, lo, X[17], MAD_F(0x0f426cb5)); */ + /* x[12] = -(x[5] = MAD_F_MLZ(hi, lo)); */ + /* MAD_F_ML0(hi, lo, X[0], MAD_F(0x0acf37ad)); */ + /* MAD_F_MLA(hi, lo, X[2], -MAD_F(0x0898c779)); */ + /* MAD_F_MLA(hi, lo, X[3], MAD_F(0x0e313245)); */ + /* MAD_F_MLA(hi, lo, X[5], -MAD_F(0x0f426cb5)); */ + /* MAD_F_MLA(hi, lo, X[6], -MAD_F(0x03768962)); */ + /* MAD_F_MLA(hi, lo, X[8], MAD_F(0x00b2aa3e)); */ + /* MAD_F_MLA(hi, lo, X[9], -MAD_F(0x0ffc19fd)); */ + /* MAD_F_MLA(hi, lo, X[11], MAD_F(0x0f9ee890)); */ + /* MAD_F_MLA(hi, lo, X[12], -MAD_F(0x04cfb0e2)); */ + /* MAD_F_MLA(hi, lo, X[14], MAD_F(0x07635284)); */ + /* MAD_F_MLA(hi, lo, X[15], MAD_F(0x0d7e8807)); */ + /* MAD_F_MLA(hi, lo, X[17], -MAD_F(0x0bcbe352)); */ + /* x[17] = -(x[0] = MAD_F_MLZ(hi, lo) + t2); */ + /* MAD_F_ML0(hi, lo, X[0], -MAD_F(0x0f9ee890)); */ + /* MAD_F_MLA(hi, lo, X[2], -MAD_F(0x07635284)); */ + /* MAD_F_MLA(hi, lo, X[3], -MAD_F(0x00b2aa3e)); */ + /* MAD_F_MLA(hi, lo, X[5], MAD_F(0x0bcbe352)); */ + /* MAD_F_MLA(hi, lo, X[6], MAD_F(0x0f426cb5)); */ + /* MAD_F_MLA(hi, lo, X[8], MAD_F(0x0d7e8807)); */ + /* MAD_F_MLA(hi, lo, X[9], MAD_F(0x0898c779)); */ + /* MAD_F_MLA(hi, lo, X[11], -MAD_F(0x04cfb0e2)); */ + /* MAD_F_MLA(hi, lo, X[12], -MAD_F(0x0acf37ad)); */ + /* MAD_F_MLA(hi, lo, X[14], -MAD_F(0x0ffc19fd)); */ + /* MAD_F_MLA(hi, lo, X[15], -MAD_F(0x0e313245)); */ + /* MAD_F_MLA(hi, lo, X[17], -MAD_F(0x03768962)); */ + /* x[24] = x[29] = MAD_F_MLZ(hi, lo) + t2; */ + "move.l #0x0acf37ad, %%d1\n" + "move.l #0x0f9ee890, %%d2\n" + "move.l #0x04cfb0e2, %%d3\n" + "mac.l %%d3, %%d0, %%acc0\n" + "mac.l %%d1, %%d0, %%acc1\n" + "msac.l %%d2, %%d0, (11*4, %[X]), %%d0, %%acc2\n" + "msac.l %%d1, %%d0, %%acc0\n" + "mac.l %%d2, %%d0, %%acc1\n" + "msac.l %%d3, %%d0, (12*4, %[X]), %%d0, %%acc2\n" + "mac.l %%d2, %%d0, %%acc0\n" + "msac.l %%d3, %%d0, %%acc1\n" + "msac.l %%d1, %%d0, ( 2*4, %[X]), %%d0, %%acc2\n" + "move.l #0x0ffc19fd, %%d1\n" + "move.l #0x0898c779, %%d2\n" + "move.l #0x07635284, %%d3\n" + "mac.l %%d1, %%d0, %%acc0\n" + "msac.l %%d2, %%d0, %%acc1\n" + "msac.l %%d3, %%d0, ( 9*4, %[X]), %%d0, %%acc2\n" + "mac.l %%d3, %%d0, %%acc0\n" + "msac.l %%d1, %%d0, %%acc1\n" + "mac.l %%d2, %%d0, (14*4, %[X]), %%d0, %%acc2\n" + "mac.l %%d2, %%d0, %%acc0\n" + "mac.l %%d3, %%d0, %%acc1\n" + "msac.l %%d1, %%d0, ( 3*4, %[X]), %%d0, %%acc2\n" + "move.l #0x0e313245, %%d1\n" + "move.l #0x00b2aa3e, %%d2\n" + "move.l #0x0d7e8807, %%d3\n" + "msac.l %%d3, %%d0, %%acc0\n" + "mac.l %%d1, %%d0, %%acc1\n" + "msac.l %%d2, %%d0, ( 8*4, %[X]), %%d0, %%acc2\n" + "msac.l %%d1, %%d0, %%acc0\n" + "mac.l %%d2, %%d0, %%acc1\n" + "mac.l %%d3, %%d0, (15*4, %[X]), %%d0, %%acc2\n" + "mac.l %%d2, %%d0, %%acc0\n" + "mac.l %%d3, %%d0, %%acc1\n" + "msac.l %%d1, %%d0, ( 5*4, %[X]), %%d0, %%acc2\n" + "move.l #0x03768962, %%d1\n" + "move.l #0x0f426cb5, %%d2\n" + "move.l #0x0bcbe352, %%d3\n" + "mac.l %%d1, %%d0, %%acc0\n" + "msac.l %%d2, %%d0, %%acc1\n" + "mac.l %%d3, %%d0, ( 6*4, %[X]), %%d0, %%acc2\n" + "msac.l %%d3, %%d0, %%acc0\n" + "msac.l %%d1, %%d0, %%acc1\n" + "mac.l %%d2, %%d0, (17*4, %[X]), %%d0, %%acc2\n" + "mac.l %%d2, %%d0, %%acc0\n" + "msac.l %%d3, %%d0, %%acc1\n" + "msac.l %%d1, %%d0, ( %[X]), %%d0, %%acc2\n" + + "movclr.l %%acc0, %%d6\n" + "asl.l #3, %%d6\n" + "move.l %%d6, ( 5*4, %[x])\n" + "neg.l %%d6\n" + "move.l %%d6, (12*4, %[x])\n" + + "movclr.l %%acc1, %%d6\n" + "asl.l #3, %%d6\n" + "add.l %%d7, %%d6\n" + "move.l %%d6, ( %[x])\n" + "neg.l %%d6\n" + "move.l %%d6, (17*4, %[x])\n" + + "movclr.l %%acc2, %%d6\n" + "asl.l #3, %%d6\n" + "add.l %%d7, %%d6\n" + "move.l %%d6, (24*4, %[x])\n" + "move.l %%d6, (29*4, %[x])\n" + + /* MAD_F_ML0(hi, lo, X[0], MAD_F(0x00b2aa3e)); */ + /* MAD_F_MLA(hi, lo, X[2], MAD_F(0x03768962)); */ + /* MAD_F_MLA(hi, lo, X[3], -MAD_F(0x04cfb0e2)); */ + /* MAD_F_MLA(hi, lo, X[5], -MAD_F(0x07635284)); */ + /* MAD_F_MLA(hi, lo, X[6], MAD_F(0x0898c779)); */ + /* MAD_F_MLA(hi, lo, X[8], MAD_F(0x0acf37ad)); */ + /* MAD_F_MLA(hi, lo, X[9], -MAD_F(0x0bcbe352)); */ + /* MAD_F_MLA(hi, lo, X[11], -MAD_F(0x0d7e8807)); */ + /* MAD_F_MLA(hi, lo, X[12], MAD_F(0x0e313245)); */ + /* MAD_F_MLA(hi, lo, X[14], MAD_F(0x0f426cb5)); */ + /* MAD_F_MLA(hi, lo, X[15], -MAD_F(0x0f9ee890)); */ + /* MAD_F_MLA(hi, lo, X[17], -MAD_F(0x0ffc19fd)); */ + /* x[9] = -(x[8] = MAD_F_MLZ(hi, lo) + t3); */ + + /* MAD_F_ML0(hi, lo, X[0], -MAD_F(0x0e313245)); */ + /* MAD_F_MLA(hi, lo, X[2], MAD_F(0x0bcbe352)); */ + /* MAD_F_MLA(hi, lo, X[3], MAD_F(0x0f9ee890)); */ + /* MAD_F_MLA(hi, lo, X[5], -MAD_F(0x0898c779)); */ + /* MAD_F_MLA(hi, lo, X[6], -MAD_F(0x0ffc19fd)); */ + /* MAD_F_MLA(hi, lo, X[8], MAD_F(0x04cfb0e2)); */ + /* MAD_F_MLA(hi, lo, X[9], MAD_F(0x0f426cb5)); */ + /* MAD_F_MLA(hi, lo, X[11], -MAD_F(0x00b2aa3e)); */ + /* MAD_F_MLA(hi, lo, X[12], -MAD_F(0x0d7e8807)); */ + /* MAD_F_MLA(hi, lo, X[14], -MAD_F(0x03768962)); */ + /* MAD_F_MLA(hi, lo, X[15], MAD_F(0x0acf37ad)); */ + /* MAD_F_MLA(hi, lo, X[17], MAD_F(0x07635284)); */ + /* x[21] = x[32] = MAD_F_MLZ(hi, lo) + t3; */ + + /* MAD_F_ML0(hi, lo, X[0], -MAD_F(0x0d7e8807)); */ + /* MAD_F_MLA(hi, lo, X[2], MAD_F(0x0f426cb5)); */ + /* MAD_F_MLA(hi, lo, X[3], MAD_F(0x0acf37ad)); */ + /* MAD_F_MLA(hi, lo, X[5], -MAD_F(0x0ffc19fd)); */ + /* MAD_F_MLA(hi, lo, X[6], -MAD_F(0x07635284)); */ + /* MAD_F_MLA(hi, lo, X[8], MAD_F(0x0f9ee890)); */ + /* MAD_F_MLA(hi, lo, X[9], MAD_F(0x03768962)); */ + /* MAD_F_MLA(hi, lo, X[11], -MAD_F(0x0e313245)); */ + /* MAD_F_MLA(hi, lo, X[12], MAD_F(0x00b2aa3e)); */ + /* MAD_F_MLA(hi, lo, X[14], MAD_F(0x0bcbe352)); */ + /* MAD_F_MLA(hi, lo, X[15], -MAD_F(0x04cfb0e2)); */ + /* MAD_F_MLA(hi, lo, X[17], -MAD_F(0x0898c779)); */ + /* x[20] = x[33] = MAD_F_MLZ(hi, lo) - t3; */ + "move.l #0x0e313245, %%d1\n" + "move.l #0x00b2aa3e, %%d2\n" + "move.l #0x0d7e8807, %%d3\n" + "mac.l %%d2, %%d0, %%acc0\n" + "msac.l %%d1, %%d0, %%acc1\n" + "msac.l %%d3, %%d0, (11*4, %[X]), %%d0, %%acc2\n" + "msac.l %%d3, %%d0, %%acc0\n" + "msac.l %%d2, %%d0, %%acc1\n" + "msac.l %%d1, %%d0, (12*4, %[X]), %%d0, %%acc2\n" + "mac.l %%d1, %%d0, %%acc0\n" + "msac.l %%d3, %%d0, %%acc1\n" + "mac.l %%d2, %%d0, ( 2*4, %[X]), %%d0, %%acc2\n" + "move.l #0x03768962, %%d1\n" + "move.l #0x0f426cb5, %%d2\n" + "move.l #0x0bcbe352, %%d3\n" + "mac.l %%d1, %%d0, %%acc0\n" + "mac.l %%d3, %%d0, %%acc1\n" + "mac.l %%d2, %%d0, ( 9*4, %[X]), %%d0, %%acc2\n" + "msac.l %%d3, %%d0, %%acc0\n" + "mac.l %%d2, %%d0, %%acc1\n" + "mac.l %%d1, %%d0, (14*4, %[X]), %%d0, %%acc2\n" + "mac.l %%d2, %%d0, %%acc0\n" + "msac.l %%d1, %%d0, %%acc1\n" + "mac.l %%d3, %%d0, ( 3*4, %[X]), %%d0, %%acc2\n" + "move.l #0x0acf37ad, %%d1\n" + "move.l #0x0f9ee890, %%d2\n" + "move.l #0x04cfb0e2, %%d3\n" + "msac.l %%d3, %%d0, %%acc0\n" + "mac.l %%d2, %%d0, %%acc1\n" + "mac.l %%d1, %%d0, ( 8*4, %[X]), %%d0, %%acc2\n" + "mac.l %%d1, %%d0, %%acc0\n" + "mac.l %%d3, %%d0, %%acc1\n" + "mac.l %%d2, %%d0, (15*4, %[X]), %%d0, %%acc2\n" + "msac.l %%d2, %%d0, %%acc0\n" + "mac.l %%d1, %%d0, %%acc1\n" + "msac.l %%d3, %%d0, ( 5*4, %[X]), %%d0, %%acc2\n" + "move.l #0x0ffc19fd, %%d1\n" + "move.l #0x0898c779, %%d2\n" + "move.l #0x07635284, %%d3\n" + "msac.l %%d3, %%d0, %%acc0\n" + "msac.l %%d2, %%d0, %%acc1\n" + "msac.l %%d1, %%d0, ( 6*4, %[X]), %%d0, %%acc2\n" + "mac.l %%d2, %%d0, %%acc0\n" + "msac.l %%d1, %%d0, %%acc1\n" + "msac.l %%d3, %%d0, (17*4, %[X]), %%d0, %%acc2\n" + "msac.l %%d1, %%d0, %%acc0\n" + "mac.l %%d3, %%d0, %%acc1\n" + "msac.l %%d2, %%d0, (12*4, %[t]), %%d0, %%acc2\n" + + "movclr.l %%acc0, %%d6\n" + "asl.l #3, %%d6\n" + "add.l %%d5, %%d6\n" + "move.l %%d6, (8*4, %[x])\n" + "neg.l %%d6\n" + "move.l %%d6, (9*4, %[x])\n" + + "movclr.l %%acc1, %%d6\n" + "asl.l #3, %%d6\n" + "add.l %%d5, %%d6\n" + "move.l %%d6, (21*4, %[x])\n" + "move.l %%d6, (32*4, %[x])\n" + + "movclr.l %%acc2, %%d6\n" + "asl.l #3, %%d6\n" + "sub.l %%d5, %%d6\n" + "move.l %%d6, (20*4, %[x])\n" + "move.l %%d6, (33*4, %[x])\n" + + /* MAD_F_ML0(hi, lo, t12, -MAD_F(0x0ec835e8)); */ + /* MAD_F_MLA(hi, lo, t13, MAD_F(0x061f78aa)); */ + /* x[22] = x[31] = MAD_F_MLZ(hi, lo) + t0; */ + "move.l #0x0ec835e8, %%d1\n" + "move.l #0x061f78aa, %%d2\n" + "msac.l %%d1, %%d0, (13*4, %[t]), %%d3, %%acc0\n" + "mac.l %%d2, %%d3, ( 1*4, %[x]), %%d4, %%acc0\n" + "movclr.l %%acc0, %%d6\n" + "asl.l #3, %%d6\n" + "add.l (0*4, %[t]), %%d6\n" + "move.l %%d6, (22*4, %[x])\n" + "move.l %%d6, (31*4, %[x])\n" + + /* MAD_F_ML0(hi, lo, t12, MAD_F(0x061f78aa)); */ + /* MAD_F_MLA(hi, lo, t13, MAD_F(0x0ec835e8)); */ + /* x[13] = -(x[4] = MAD_F_MLZ(hi, lo) + t4); */ + /* x[16] = -(x[1] = x[1] + t4); */ + /* x[25] = x[28] = x[25] + t4; */ + "mac.l %%d2, %%d0, (4*4, %[t]), %%d2, %%acc0\n" + "mac.l %%d1, %%d3, ( %[X]), %%d0, %%acc0\n" + "movclr.l %%acc0, %%d6\n" + "asl.l #3, %%d6\n" + "add.l %%d2, %%d6\n" + "move.l %%d6, ( 4*4, %[x])\n" + "neg.l %%d6\n" + "move.l %%d6, (13*4, %[x])\n" + + "add.l %%d2, %%d4\n" + "move.l %%d4, ( 1*4, %[x])\n" + "neg.l %%d4\n" + "move.l %%d4, (16*4, %[x])\n" + + "move.l (25*4, %[x]), %%d4\n" + "add.l %%d2, %%d4\n" + "move.l %%d4, (25*4, %[x])\n" + "move.l %%d4, (28*4, %[x])\n" + + /* MAD_F_ML0(hi, lo, X[0], MAD_F(0x0898c779)); */ + /* MAD_F_MLA(hi, lo, X[2], MAD_F(0x04cfb0e2)); */ + /* MAD_F_MLA(hi, lo, X[3], MAD_F(0x0bcbe352)); */ + /* MAD_F_MLA(hi, lo, X[5], MAD_F(0x00b2aa3e)); */ + /* MAD_F_MLA(hi, lo, X[6], MAD_F(0x0e313245)); */ + /* MAD_F_MLA(hi, lo, X[8], -MAD_F(0x03768962)); */ + /* MAD_F_MLA(hi, lo, X[9], MAD_F(0x0f9ee890)); */ + /* MAD_F_MLA(hi, lo, X[11], -MAD_F(0x07635284)); */ + /* MAD_F_MLA(hi, lo, X[12], MAD_F(0x0ffc19fd)); */ + /* MAD_F_MLA(hi, lo, X[14], -MAD_F(0x0acf37ad)); */ + /* MAD_F_MLA(hi, lo, X[15], MAD_F(0x0f426cb5)); */ + /* MAD_F_MLA(hi, lo, X[17], -MAD_F(0x0d7e8807)); */ + /* x[15] = -(x[2] = MAD_F_MLZ(hi, lo) + t5); */ + /* MAD_F_ML0(hi, lo, X[0], MAD_F(0x07635284)); */ + /* MAD_F_MLA(hi, lo, X[2], MAD_F(0x0acf37ad)); */ + /* MAD_F_MLA(hi, lo, X[3], MAD_F(0x03768962)); */ + /* MAD_F_MLA(hi, lo, X[5], MAD_F(0x0d7e8807)); */ + /* MAD_F_MLA(hi, lo, X[6], -MAD_F(0x00b2aa3e)); */ + /* MAD_F_MLA(hi, lo, X[8], MAD_F(0x0f426cb5)); */ + /* MAD_F_MLA(hi, lo, X[9], -MAD_F(0x04cfb0e2)); */ + /* MAD_F_MLA(hi, lo, X[11], MAD_F(0x0ffc19fd)); */ + /* MAD_F_MLA(hi, lo, X[12], -MAD_F(0x0898c779)); */ + /* MAD_F_MLA(hi, lo, X[14], MAD_F(0x0f9ee890)); */ + /* MAD_F_MLA(hi, lo, X[15], -MAD_F(0x0bcbe352)); */ + /* MAD_F_MLA(hi, lo, X[17], MAD_F(0x0e313245)); */ + /* x[14] = -(x[3] = MAD_F_MLZ(hi, lo) + t5); */ + /* MAD_F_ML0(hi, lo, X[0], -MAD_F(0x0ffc19fd)); */ + /* MAD_F_MLA(hi, lo, X[2], -MAD_F(0x0f9ee890)); */ + /* MAD_F_MLA(hi, lo, X[3], -MAD_F(0x0f426cb5)); */ + /* MAD_F_MLA(hi, lo, X[5], -MAD_F(0x0e313245)); */ + /* MAD_F_MLA(hi, lo, X[6], -MAD_F(0x0d7e8807)); */ + /* MAD_F_MLA(hi, lo, X[8], -MAD_F(0x0bcbe352)); */ + /* MAD_F_MLA(hi, lo, X[9], -MAD_F(0x0acf37ad)); */ + /* MAD_F_MLA(hi, lo, X[11], -MAD_F(0x0898c779)); */ + /* MAD_F_MLA(hi, lo, X[12], -MAD_F(0x07635284)); */ + /* MAD_F_MLA(hi, lo, X[14], -MAD_F(0x04cfb0e2)); */ + /* MAD_F_MLA(hi, lo, X[15], -MAD_F(0x03768962)); */ + /* MAD_F_MLA(hi, lo, X[17], -MAD_F(0x00b2aa3e)); */ + /* x[26] = x[27] = MAD_F_MLZ(hi, lo) + t5; */ + "move.l #0x0ffc19fd, %%d1\n" + "move.l #0x0898c779, %%d2\n" + "move.l #0x07635284, %%d3\n" + "mac.l %%d2, %%d0, %%acc0\n" + "mac.l %%d3, %%d0, %%acc1\n" + "msac.l %%d1, %%d0, (11*4, %[X]), %%d0, %%acc2\n" + "msac.l %%d3, %%d0, %%acc0\n" + "mac.l %%d1, %%d0, %%acc1\n" + "msac.l %%d2, %%d0, (12*4, %[X]), %%d0, %%acc2\n" + "mac.l %%d1, %%d0, %%acc0\n" + "msac.l %%d2, %%d0, %%acc1\n" + "msac.l %%d3, %%d0, ( 2*4, %[X]), %%d0, %%acc2\n" + "move.l #0x0acf37ad, %%d1\n" + "move.l #0x0f9ee890, %%d2\n" + "move.l #0x04cfb0e2, %%d3\n" + "mac.l %%d3, %%d0, %%acc0\n" + "mac.l %%d1, %%d0, %%acc1\n" + "msac.l %%d2, %%d0, ( 9*4, %[X]), %%d0, %%acc2\n" + "mac.l %%d2, %%d0, %%acc0\n" + "msac.l %%d3, %%d0, %%acc1\n" + "msac.l %%d1, %%d0, (14*4, %[X]), %%d0, %%acc2\n" + "msac.l %%d1, %%d0, %%acc0\n" + "mac.l %%d2, %%d0, %%acc1\n" + "msac.l %%d3, %%d0, ( 3*4, %[X]), %%d0, %%acc2\n" + "move.l #0x03768962, %%d1\n" + "move.l #0x0f426cb5, %%d2\n" + "move.l #0x0bcbe352, %%d3\n" + "mac.l %%d3, %%d0, %%acc0\n" + "mac.l %%d1, %%d0, %%acc1\n" + "msac.l %%d2, %%d0, ( 8*4, %[X]), %%d0, %%acc2\n" + "msac.l %%d1, %%d0, %%acc0\n" + "mac.l %%d2, %%d0, %%acc1\n" + "msac.l %%d3, %%d0, (15*4, %[X]), %%d0, %%acc2\n" + "mac.l %%d2, %%d0, %%acc0\n" + "msac.l %%d3, %%d0, %%acc1\n" + "msac.l %%d1, %%d0, ( 5*4, %[X]), %%d0, %%acc2\n" + "move.l #0x0e313245, %%d1\n" + "move.l #0x00b2aa3e, %%d2\n" + "move.l #0x0d7e8807, %%d3\n" + "mac.l %%d2, %%d0, %%acc0\n" + "mac.l %%d3, %%d0, %%acc1\n" + "msac.l %%d1, %%d0, ( 6*4, %[X]), %%d0, %%acc2\n" + "mac.l %%d1, %%d0, %%acc0\n" + "msac.l %%d2, %%d0, %%acc1\n" + "msac.l %%d3, %%d0, (17*4, %[X]), %%d0, %%acc2\n" + "msac.l %%d3, %%d0, %%acc0\n" + "mac.l %%d1, %%d0, %%acc1\n" + "msac.l %%d2, %%d0, ( 5*4, %[t]), %%d6, %%acc2\n" + "movclr.l %%acc0, %%d7\n" + "asl.l #3, %%d7\n" + "add.l %%d6, %%d7\n" + "move.l %%d7, (2*4, %[x])\n" + "neg.l %%d7\n" + "move.l %%d7, (15*4, %[x])\n" + + "movclr.l %%acc1, %%d7\n" + "asl.l #3, %%d7\n" + "add.l %%d6, %%d7\n" + "move.l %%d7, (3*4, %[x])\n" + "neg.l %%d7\n" + "move.l %%d7, (14*4, %[x])\n" + + "movclr.l %%acc2, %%d7\n" + "asl.l #3, %%d7\n" + "add.l %%d6, %%d7\n" + "move.l %%d7, (26*4, %[x])\n" + "move.l %%d7, (27*4, %[x])\n" + + : : [X] "a" (X), [x] "a" (x), [t] "a" (t) + : "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7"); + /* pfew */ +} + +# else /* if defined(CPU_COLDFIRE) */ + +static inline +void imdct36(mad_fixed_t const X[18], mad_fixed_t x[36]) +{ + mad_fixed_t t0, t1, t2, t3, t4, t5, t6, t7; + mad_fixed_t t8, t9, t10, t11, t12, t13, t14, t15; + register mad_fixed64hi_t hi; + register mad_fixed64lo_t lo; + + MAD_F_ML0(hi, lo, (t14 = X[1] - X[10]), -MAD_F(0x0ec835e8)); + MAD_F_MLA(hi, lo, (t15 = X[7] + X[16]), MAD_F(0x061f78aa)); + t4 = MAD_F_MLZ(hi, lo); + + MAD_F_ML0(hi, lo, X[4], MAD_F(0x0ec835e8)); + MAD_F_MLA(hi, lo, X[13], MAD_F(0x061f78aa)); + t6 = MAD_F_MLZ(hi, lo); + + MAD_F_MLA(hi, lo, t14, -MAD_F(0x061f78aa)); + MAD_F_MLA(hi, lo, t15, -MAD_F(0x0ec835e8)); + t0 = MAD_F_MLZ(hi, lo); + + MAD_F_MLA(hi, lo, (t8 =X[0]-X[11]-X[12]), MAD_F(0x0216a2a2)); + MAD_F_MLA(hi, lo, (t9 =X[2]-X[ 9]-X[14]), MAD_F(0x09bd7ca0)); + MAD_F_MLA(hi, lo, (t10=X[3]-X[ 8]-X[15]), -MAD_F(0x0cb19346)); + MAD_F_MLA(hi, lo, (t11=X[5]-X[ 6]-X[17]), -MAD_F(0x0fdcf549)); + x[10] = -(x[7] = MAD_F_MLZ(hi, lo)); + + MAD_F_ML0(hi, lo, t8, -MAD_F(0x0cb19346)); + MAD_F_MLA(hi, lo, t9, MAD_F(0x0fdcf549)); + MAD_F_MLA(hi, lo, t10, MAD_F(0x0216a2a2)); + MAD_F_MLA(hi, lo, t11, -MAD_F(0x09bd7ca0)); + x[19] = x[34] = MAD_F_MLZ(hi, lo) - t0; + + MAD_F_ML0(hi, lo, t8, MAD_F(0x09bd7ca0)); + MAD_F_MLA(hi, lo, t9, -MAD_F(0x0216a2a2)); + MAD_F_MLA(hi, lo, t10, MAD_F(0x0fdcf549)); + MAD_F_MLA(hi, lo, t11, -MAD_F(0x0cb19346)); + x[ 1] = MAD_F_MLZ(hi, lo); + + MAD_F_ML0(hi, lo, t8, -MAD_F(0x0fdcf549)); + MAD_F_MLA(hi, lo, t9, -MAD_F(0x0cb19346)); + MAD_F_MLA(hi, lo, t10, -MAD_F(0x09bd7ca0)); + MAD_F_MLA(hi, lo, t11, -MAD_F(0x0216a2a2)); + x[25] = MAD_F_MLZ(hi, lo); + + t12 = t8 - t10; + t13 = t9 + t11; + + MAD_F_ML0(hi, lo, X[1], -MAD_F(0x09bd7ca0)); + MAD_F_MLA(hi, lo, X[7], MAD_F(0x0216a2a2)); + MAD_F_MLA(hi, lo, X[10], -MAD_F(0x0fdcf549)); + MAD_F_MLA(hi, lo, X[16], MAD_F(0x0cb19346)); + t1 = MAD_F_MLZ(hi, lo) + t6; + + MAD_F_ML0(hi, lo, X[1], -MAD_F(0x0216a2a2)); + MAD_F_MLA(hi, lo, X[7], -MAD_F(0x09bd7ca0)); + MAD_F_MLA(hi, lo, X[10], MAD_F(0x0cb19346)); + MAD_F_MLA(hi, lo, X[16], MAD_F(0x0fdcf549)); + t3 = MAD_F_MLZ(hi, lo); + + MAD_F_ML0(hi, lo, X[1], -MAD_F(0x0fdcf549)); + MAD_F_MLA(hi, lo, X[7], -MAD_F(0x0cb19346)); + MAD_F_MLA(hi, lo, X[10], -MAD_F(0x09bd7ca0)); + MAD_F_MLA(hi, lo, X[16], -MAD_F(0x0216a2a2)); + t5 = MAD_F_MLZ(hi, lo) - t6; + + MAD_F_ML0(hi, lo, X[0], MAD_F(0x03768962)); + MAD_F_MLA(hi, lo, X[2], MAD_F(0x0e313245)); + MAD_F_MLA(hi, lo, X[3], -MAD_F(0x0ffc19fd)); + MAD_F_MLA(hi, lo, X[5], -MAD_F(0x0acf37ad)); + MAD_F_MLA(hi, lo, X[6], MAD_F(0x04cfb0e2)); + MAD_F_MLA(hi, lo, X[8], -MAD_F(0x0898c779)); + MAD_F_MLA(hi, lo, X[9], MAD_F(0x0d7e8807)); + MAD_F_MLA(hi, lo, X[11], MAD_F(0x0f426cb5)); + MAD_F_MLA(hi, lo, X[12], -MAD_F(0x0bcbe352)); + MAD_F_MLA(hi, lo, X[14], MAD_F(0x00b2aa3e)); + MAD_F_MLA(hi, lo, X[15], -MAD_F(0x07635284)); + MAD_F_MLA(hi, lo, X[17], -MAD_F(0x0f9ee890)); + x[11] = -(x[6] = MAD_F_MLZ(hi, lo) + t1); + + MAD_F_ML0(hi, lo, X[0], -MAD_F(0x0f426cb5)); + MAD_F_MLA(hi, lo, X[2], -MAD_F(0x00b2aa3e)); + MAD_F_MLA(hi, lo, X[3], MAD_F(0x0898c779)); + MAD_F_MLA(hi, lo, X[5], MAD_F(0x0f9ee890)); + MAD_F_MLA(hi, lo, X[6], MAD_F(0x0acf37ad)); + MAD_F_MLA(hi, lo, X[8], -MAD_F(0x07635284)); + MAD_F_MLA(hi, lo, X[9], -MAD_F(0x0e313245)); + MAD_F_MLA(hi, lo, X[11], -MAD_F(0x0bcbe352)); + MAD_F_MLA(hi, lo, X[12], -MAD_F(0x03768962)); + MAD_F_MLA(hi, lo, X[14], MAD_F(0x0d7e8807)); + MAD_F_MLA(hi, lo, X[15], MAD_F(0x0ffc19fd)); + MAD_F_MLA(hi, lo, X[17], MAD_F(0x04cfb0e2)); + x[23] = x[30] = MAD_F_MLZ(hi, lo) + t1; + + MAD_F_ML0(hi, lo, X[0], -MAD_F(0x0bcbe352)); + MAD_F_MLA(hi, lo, X[2], MAD_F(0x0d7e8807)); + MAD_F_MLA(hi, lo, X[3], -MAD_F(0x07635284)); + MAD_F_MLA(hi, lo, X[5], MAD_F(0x04cfb0e2)); + MAD_F_MLA(hi, lo, X[6], MAD_F(0x0f9ee890)); + MAD_F_MLA(hi, lo, X[8], -MAD_F(0x0ffc19fd)); + MAD_F_MLA(hi, lo, X[9], -MAD_F(0x00b2aa3e)); + MAD_F_MLA(hi, lo, X[11], MAD_F(0x03768962)); + MAD_F_MLA(hi, lo, X[12], -MAD_F(0x0f426cb5)); + MAD_F_MLA(hi, lo, X[14], MAD_F(0x0e313245)); + MAD_F_MLA(hi, lo, X[15], MAD_F(0x0898c779)); + MAD_F_MLA(hi, lo, X[17], -MAD_F(0x0acf37ad)); + x[18] = x[35] = MAD_F_MLZ(hi, lo) - t1; + + MAD_F_ML0(hi, lo, X[4], MAD_F(0x061f78aa)); + MAD_F_MLA(hi, lo, X[13], -MAD_F(0x0ec835e8)); + t3+= (t7 = MAD_F_MLZ(hi, lo)); + t4-= t7; + + MAD_F_MLA(hi, lo, X[1], -MAD_F(0x0cb19346)); + MAD_F_MLA(hi, lo, X[7], MAD_F(0x0fdcf549)); + MAD_F_MLA(hi, lo, X[10], MAD_F(0x0216a2a2)); + MAD_F_MLA(hi, lo, X[16], -MAD_F(0x09bd7ca0)); + t2 = MAD_F_MLZ(hi, lo); + + MAD_F_MLA(hi, lo, X[0], MAD_F(0x04cfb0e2)); + MAD_F_MLA(hi, lo, X[2], MAD_F(0x0ffc19fd)); + MAD_F_MLA(hi, lo, X[3], -MAD_F(0x0d7e8807)); + MAD_F_MLA(hi, lo, X[5], MAD_F(0x03768962)); + MAD_F_MLA(hi, lo, X[6], -MAD_F(0x0bcbe352)); + MAD_F_MLA(hi, lo, X[8], -MAD_F(0x0e313245)); + MAD_F_MLA(hi, lo, X[9], MAD_F(0x07635284)); + MAD_F_MLA(hi, lo, X[11], -MAD_F(0x0acf37ad)); + MAD_F_MLA(hi, lo, X[12], MAD_F(0x0f9ee890)); + MAD_F_MLA(hi, lo, X[14], MAD_F(0x0898c779)); + MAD_F_MLA(hi, lo, X[15], MAD_F(0x00b2aa3e)); + MAD_F_MLA(hi, lo, X[17], MAD_F(0x0f426cb5)); + x[12] = -(x[5] = MAD_F_MLZ(hi, lo)); + + MAD_F_ML0(hi, lo, X[0], MAD_F(0x0acf37ad)); + MAD_F_MLA(hi, lo, X[2], -MAD_F(0x0898c779)); + MAD_F_MLA(hi, lo, X[3], MAD_F(0x0e313245)); + MAD_F_MLA(hi, lo, X[5], -MAD_F(0x0f426cb5)); + MAD_F_MLA(hi, lo, X[6], -MAD_F(0x03768962)); + MAD_F_MLA(hi, lo, X[8], MAD_F(0x00b2aa3e)); + MAD_F_MLA(hi, lo, X[9], -MAD_F(0x0ffc19fd)); + MAD_F_MLA(hi, lo, X[11], MAD_F(0x0f9ee890)); + MAD_F_MLA(hi, lo, X[12], -MAD_F(0x04cfb0e2)); + MAD_F_MLA(hi, lo, X[14], MAD_F(0x07635284)); + MAD_F_MLA(hi, lo, X[15], MAD_F(0x0d7e8807)); + MAD_F_MLA(hi, lo, X[17], -MAD_F(0x0bcbe352)); + x[17] = -(x[0] = MAD_F_MLZ(hi, lo) + t2); + + MAD_F_ML0(hi, lo, X[0], -MAD_F(0x0f9ee890)); + MAD_F_MLA(hi, lo, X[2], -MAD_F(0x07635284)); + MAD_F_MLA(hi, lo, X[3], -MAD_F(0x00b2aa3e)); + MAD_F_MLA(hi, lo, X[5], MAD_F(0x0bcbe352)); + MAD_F_MLA(hi, lo, X[6], MAD_F(0x0f426cb5)); + MAD_F_MLA(hi, lo, X[8], MAD_F(0x0d7e8807)); + MAD_F_MLA(hi, lo, X[9], MAD_F(0x0898c779)); + MAD_F_MLA(hi, lo, X[11], -MAD_F(0x04cfb0e2)); + MAD_F_MLA(hi, lo, X[12], -MAD_F(0x0acf37ad)); + MAD_F_MLA(hi, lo, X[14], -MAD_F(0x0ffc19fd)); + MAD_F_MLA(hi, lo, X[15], -MAD_F(0x0e313245)); + MAD_F_MLA(hi, lo, X[17], -MAD_F(0x03768962)); + x[24] = x[29] = MAD_F_MLZ(hi, lo) + t2; + + MAD_F_ML0(hi, lo, X[0], MAD_F(0x00b2aa3e)); + MAD_F_MLA(hi, lo, X[2], MAD_F(0x03768962)); + MAD_F_MLA(hi, lo, X[3], -MAD_F(0x04cfb0e2)); + MAD_F_MLA(hi, lo, X[5], -MAD_F(0x07635284)); + MAD_F_MLA(hi, lo, X[6], MAD_F(0x0898c779)); + MAD_F_MLA(hi, lo, X[8], MAD_F(0x0acf37ad)); + MAD_F_MLA(hi, lo, X[9], -MAD_F(0x0bcbe352)); + MAD_F_MLA(hi, lo, X[11], -MAD_F(0x0d7e8807)); + MAD_F_MLA(hi, lo, X[12], MAD_F(0x0e313245)); + MAD_F_MLA(hi, lo, X[14], MAD_F(0x0f426cb5)); + MAD_F_MLA(hi, lo, X[15], -MAD_F(0x0f9ee890)); + MAD_F_MLA(hi, lo, X[17], -MAD_F(0x0ffc19fd)); + x[9] = -(x[8] = MAD_F_MLZ(hi, lo) + t3); + + MAD_F_ML0(hi, lo, X[0], -MAD_F(0x0e313245)); + MAD_F_MLA(hi, lo, X[2], MAD_F(0x0bcbe352)); + MAD_F_MLA(hi, lo, X[3], MAD_F(0x0f9ee890)); + MAD_F_MLA(hi, lo, X[5], -MAD_F(0x0898c779)); + MAD_F_MLA(hi, lo, X[6], -MAD_F(0x0ffc19fd)); + MAD_F_MLA(hi, lo, X[8], MAD_F(0x04cfb0e2)); + MAD_F_MLA(hi, lo, X[9], MAD_F(0x0f426cb5)); + MAD_F_MLA(hi, lo, X[11], -MAD_F(0x00b2aa3e)); + MAD_F_MLA(hi, lo, X[12], -MAD_F(0x0d7e8807)); + MAD_F_MLA(hi, lo, X[14], -MAD_F(0x03768962)); + MAD_F_MLA(hi, lo, X[15], MAD_F(0x0acf37ad)); + MAD_F_MLA(hi, lo, X[17], MAD_F(0x07635284)); + x[21] = x[32] = MAD_F_MLZ(hi, lo) + t3; + + MAD_F_ML0(hi, lo, X[0], -MAD_F(0x0d7e8807)); + MAD_F_MLA(hi, lo, X[2], MAD_F(0x0f426cb5)); + MAD_F_MLA(hi, lo, X[3], MAD_F(0x0acf37ad)); + MAD_F_MLA(hi, lo, X[5], -MAD_F(0x0ffc19fd)); + MAD_F_MLA(hi, lo, X[6], -MAD_F(0x07635284)); + MAD_F_MLA(hi, lo, X[8], MAD_F(0x0f9ee890)); + MAD_F_MLA(hi, lo, X[9], MAD_F(0x03768962)); + MAD_F_MLA(hi, lo, X[11], -MAD_F(0x0e313245)); + MAD_F_MLA(hi, lo, X[12], MAD_F(0x00b2aa3e)); + MAD_F_MLA(hi, lo, X[14], MAD_F(0x0bcbe352)); + MAD_F_MLA(hi, lo, X[15], -MAD_F(0x04cfb0e2)); + MAD_F_MLA(hi, lo, X[17], -MAD_F(0x0898c779)); + x[20] = x[33] = MAD_F_MLZ(hi, lo) - t3; + + MAD_F_ML0(hi, lo, t12, -MAD_F(0x0ec835e8)); + MAD_F_MLA(hi, lo, t13, MAD_F(0x061f78aa)); + x[22] = x[31] = MAD_F_MLZ(hi, lo) + t0; + + MAD_F_ML0(hi, lo, t12, MAD_F(0x061f78aa)); + MAD_F_MLA(hi, lo, t13, MAD_F(0x0ec835e8)); + x[13] = -(x[4] = MAD_F_MLZ(hi, lo) + t4); + x[16] = -(x[1] = x[1] + t4); + x[25] = x[28] = x[25] + t4; + + MAD_F_ML0(hi, lo, X[0], MAD_F(0x0898c779)); + MAD_F_MLA(hi, lo, X[2], MAD_F(0x04cfb0e2)); + MAD_F_MLA(hi, lo, X[3], MAD_F(0x0bcbe352)); + MAD_F_MLA(hi, lo, X[5], MAD_F(0x00b2aa3e)); + MAD_F_MLA(hi, lo, X[6], MAD_F(0x0e313245)); + MAD_F_MLA(hi, lo, X[8], -MAD_F(0x03768962)); + MAD_F_MLA(hi, lo, X[9], MAD_F(0x0f9ee890)); + MAD_F_MLA(hi, lo, X[11], -MAD_F(0x07635284)); + MAD_F_MLA(hi, lo, X[12], MAD_F(0x0ffc19fd)); + MAD_F_MLA(hi, lo, X[14], -MAD_F(0x0acf37ad)); + MAD_F_MLA(hi, lo, X[15], MAD_F(0x0f426cb5)); + MAD_F_MLA(hi, lo, X[17], -MAD_F(0x0d7e8807)); + x[15] = -(x[2] = MAD_F_MLZ(hi, lo) + t5); + + MAD_F_ML0(hi, lo, X[0], MAD_F(0x07635284)); + MAD_F_MLA(hi, lo, X[2], MAD_F(0x0acf37ad)); + MAD_F_MLA(hi, lo, X[3], MAD_F(0x03768962)); + MAD_F_MLA(hi, lo, X[5], MAD_F(0x0d7e8807)); + MAD_F_MLA(hi, lo, X[6], -MAD_F(0x00b2aa3e)); + MAD_F_MLA(hi, lo, X[8], MAD_F(0x0f426cb5)); + MAD_F_MLA(hi, lo, X[9], -MAD_F(0x04cfb0e2)); + MAD_F_MLA(hi, lo, X[11], MAD_F(0x0ffc19fd)); + MAD_F_MLA(hi, lo, X[12], -MAD_F(0x0898c779)); + MAD_F_MLA(hi, lo, X[14], MAD_F(0x0f9ee890)); + MAD_F_MLA(hi, lo, X[15], -MAD_F(0x0bcbe352)); + MAD_F_MLA(hi, lo, X[17], MAD_F(0x0e313245)); + x[14] = -(x[3] = MAD_F_MLZ(hi, lo) + t5); + + MAD_F_ML0(hi, lo, X[0], -MAD_F(0x0ffc19fd)); + MAD_F_MLA(hi, lo, X[2], -MAD_F(0x0f9ee890)); + MAD_F_MLA(hi, lo, X[3], -MAD_F(0x0f426cb5)); + MAD_F_MLA(hi, lo, X[5], -MAD_F(0x0e313245)); + MAD_F_MLA(hi, lo, X[6], -MAD_F(0x0d7e8807)); + MAD_F_MLA(hi, lo, X[8], -MAD_F(0x0bcbe352)); + MAD_F_MLA(hi, lo, X[9], -MAD_F(0x0acf37ad)); + MAD_F_MLA(hi, lo, X[11], -MAD_F(0x0898c779)); + MAD_F_MLA(hi, lo, X[12], -MAD_F(0x07635284)); + MAD_F_MLA(hi, lo, X[14], -MAD_F(0x04cfb0e2)); + MAD_F_MLA(hi, lo, X[15], -MAD_F(0x03768962)); + MAD_F_MLA(hi, lo, X[17], -MAD_F(0x00b2aa3e)); + x[26] = x[27] = MAD_F_MLZ(hi, lo) + t5; +} +# endif /* CPU_COLDFIRE */ + +/* + * NAME: III_imdct_l() + * DESCRIPTION: perform IMDCT and windowing for long blocks + */ +static +void III_imdct_l(mad_fixed_t const X[18], mad_fixed_t z[36], + unsigned int block_type) +{ + unsigned int i; + + /* IMDCT */ + + imdct36(X, z); + + /* windowing */ + + switch (block_type) { + case 0: /* normal window */ +# if 1 + /* loop unrolled implementation */ + for (i = 0; i < 36; i += 4) { + z[i + 0] = mad_f_mul(z[i + 0], window_l[i + 0]); + z[i + 1] = mad_f_mul(z[i + 1], window_l[i + 1]); + z[i + 2] = mad_f_mul(z[i + 2], window_l[i + 2]); + z[i + 3] = mad_f_mul(z[i + 3], window_l[i + 3]); + } +# else + /* reference implementation */ + for (i = 0; i < 36; ++i) z[i] = mad_f_mul(z[i], window_l[i]); +# endif + break; + + case 1: /* start block */ + for (i = 0; i < 18; i += 3) { + z[i + 0] = mad_f_mul(z[i + 0], window_l[i + 0]); + z[i + 1] = mad_f_mul(z[i + 1], window_l[i + 1]); + z[i + 2] = mad_f_mul(z[i + 2], window_l[i + 2]); + } + /* (i = 18; i < 24; ++i) z[i] unchanged */ + for (i = 24; i < 30; ++i) z[i] = mad_f_mul(z[i], window_s[i - 18]); + for (i = 30; i < 36; ++i) z[i] = 0; + break; + + case 3: /* stop block */ + for (i = 0; i < 6; ++i) z[i] = 0; + for (i = 6; i < 12; ++i) z[i] = mad_f_mul(z[i], window_s[i - 6]); + /* (i = 12; i < 18; ++i) z[i] unchanged */ + for (i = 18; i < 36; i += 3) { + z[i + 0] = mad_f_mul(z[i + 0], window_l[i + 0]); + z[i + 1] = mad_f_mul(z[i + 1], window_l[i + 1]); + z[i + 2] = mad_f_mul(z[i + 2], window_l[i + 2]); + } + break; + } +} +# endif /* FPM_ARM */ + +/* + * NAME: III_imdct_s() + * DESCRIPTION: perform IMDCT and windowing for short blocks + */ + +# if defined(CPU_COLDFIRE) +void III_imdct_s(mad_fixed_t const X[18], mad_fixed_t z[36]); +#else + +static +void III_imdct_s(mad_fixed_t const X[18], mad_fixed_t z[36]) +{ + mad_fixed_t y[36], *yptr; + mad_fixed_t const *wptr; + int w, i; + register mad_fixed64hi_t hi; + register mad_fixed64lo_t lo; + + /* IMDCT */ + + yptr = &y[0]; + + for (w = 0; w < 3; ++w) { + register mad_fixed_t const (*s)[6]; + + s = imdct_s; + + for (i = 0; i < 3; ++i) { + MAD_F_ML0(hi, lo, X[0], (*s)[0]); + MAD_F_MLA(hi, lo, X[1], (*s)[1]); + MAD_F_MLA(hi, lo, X[2], (*s)[2]); + MAD_F_MLA(hi, lo, X[3], (*s)[3]); + MAD_F_MLA(hi, lo, X[4], (*s)[4]); + MAD_F_MLA(hi, lo, X[5], (*s)[5]); + + yptr[i + 0] = MAD_F_MLZ(hi, lo); + yptr[5 - i] = -yptr[i + 0]; + + ++s; + + MAD_F_ML0(hi, lo, X[0], (*s)[0]); + MAD_F_MLA(hi, lo, X[1], (*s)[1]); + MAD_F_MLA(hi, lo, X[2], (*s)[2]); + MAD_F_MLA(hi, lo, X[3], (*s)[3]); + MAD_F_MLA(hi, lo, X[4], (*s)[4]); + MAD_F_MLA(hi, lo, X[5], (*s)[5]); + + yptr[ i + 6] = MAD_F_MLZ(hi, lo); + yptr[11 - i] = yptr[i + 6]; + + ++s; + } + + yptr += 12; + X += 6; + } + + /* windowing, overlapping and concatenation */ + + yptr = &y[0]; + wptr = &window_s[0]; + + for (i = 0; i < 6; ++i) { + z[i + 0] = 0; + z[i + 6] = mad_f_mul(yptr[ 0 + 0], wptr[0]); + + MAD_F_ML0(hi, lo, yptr[ 0 + 6], wptr[6]); + MAD_F_MLA(hi, lo, yptr[12 + 0], wptr[0]); + + z[i + 12] = MAD_F_MLZ(hi, lo); + + MAD_F_ML0(hi, lo, yptr[12 + 6], wptr[6]); + MAD_F_MLA(hi, lo, yptr[24 + 0], wptr[0]); + + z[i + 18] = MAD_F_MLZ(hi, lo); + + z[i + 24] = mad_f_mul(yptr[24 + 6], wptr[6]); + z[i + 30] = 0; + + ++yptr; + ++wptr; + } +} + +#endif + +#ifdef CPU_ARM +void III_overlap(mad_fixed_t const output[36], mad_fixed_t overlap[18], + mad_fixed_t sample[18][32], unsigned int sb); +#else + +/* + * NAME: III_overlap() + * DESCRIPTION: perform overlap-add of windowed IMDCT outputs + */ +static +void III_overlap(mad_fixed_t const output[36], mad_fixed_t overlap[18], + mad_fixed_t sample[18][32], unsigned int sb) +{ + unsigned int i; + for (i = 0; i < 18; ++i) { + sample[i][sb] = output[i + 0] + overlap[i]; + overlap[i] = output[i + 18]; + } +} +#endif + +/* + * NAME: III_overlap_z() + * DESCRIPTION: perform "overlap-add" of zero IMDCT outputs + */ +static inline +void III_overlap_z(mad_fixed_t overlap[18], + mad_fixed_t sample[18][32], unsigned int sb) +{ + unsigned int i; + for (i = 0; i < 18; ++i) { + sample[i][sb] = overlap[i]; + overlap[i] = 0; + } +} + +/* + * NAME: III_freqinver() + * DESCRIPTION: perform subband frequency inversion for odd sample lines + */ +static +void III_freqinver(mad_fixed_t sample[18][32], unsigned int sb) +{ + unsigned int i; + for (i = 1; i < 18; i += 2) + sample[i][sb] = -sample[i][sb]; +} + +/* + * NAME: III_decode() + * DESCRIPTION: decode frame main_data + */ +static +enum mad_error III_decode(struct mad_bitptr *ptr, struct mad_frame *frame, + struct sideinfo *si, unsigned int nch) +{ + struct mad_header *header = &frame->header; + unsigned int sfreqi, ngr, gr; + + { + unsigned int sfreq; + + sfreq = header->samplerate; + if (header->flags & MAD_FLAG_MPEG_2_5_EXT) + sfreq *= 2; + + /* 48000 => 0, 44100 => 1, 32000 => 2, + 24000 => 3, 22050 => 4, 16000 => 5 */ + sfreqi = ((sfreq >> 7) & 0x000f) + + ((sfreq >> 15) & 0x0001) - 8; + + if (header->flags & MAD_FLAG_MPEG_2_5_EXT) + sfreqi += 3; + } + + /* scalefactors, Huffman decoding, requantization */ + + ngr = (header->flags & MAD_FLAG_LSF_EXT) ? 1 : 2; + + for (gr = 0; gr < ngr; ++gr) { + struct granule *granule = &si->gr[gr]; + unsigned char const *sfbwidth[2]; + mad_fixed_t xr[2][576]; + unsigned int ch; + enum mad_error error; + + for (ch = 0; ch < nch; ++ch) { + struct channel *channel = &granule->ch[ch]; + unsigned int part2_length; + + sfbwidth[ch] = sfbwidth_table[sfreqi].l; + if (channel->block_type == 2) { + sfbwidth[ch] = (channel->flags & mixed_block_flag) ? + sfbwidth_table[sfreqi].m : sfbwidth_table[sfreqi].s; + } + + if (header->flags & MAD_FLAG_LSF_EXT) { + part2_length = III_scalefactors_lsf(ptr, channel, + ch == 0 ? 0 : &si->gr[1].ch[1], + header->mode_extension); + } + else { + part2_length = III_scalefactors(ptr, channel, &si->gr[0].ch[ch], + gr == 0 ? 0 : si->scfsi[ch]); + } + + error = III_huffdecode(ptr, xr[ch], channel, sfbwidth[ch], part2_length); + if (error) + return error; + } + + /* joint stereo processing */ + + if (header->mode == MAD_MODE_JOINT_STEREO && header->mode_extension) { + error = III_stereo(xr, granule, header, sfbwidth[0]); + if (error) + return error; + } + + /* reordering, alias reduction, IMDCT, overlap-add, frequency inversion */ + + for (ch = 0; ch < nch; ++ch) { + struct channel const *channel = &granule->ch[ch]; + mad_fixed_t (*sample)[32] = &((*frame->sbsample)[ch][18 * gr]); + unsigned int sb, l, i, sblimit; + mad_fixed_t output[36]; + + if (channel->block_type == 2) { + III_reorder(xr[ch], channel, sfbwidth[ch]); + +# if !defined(OPT_STRICT) + /* + * According to ISO/IEC 11172-3, "Alias reduction is not applied for + * granules with block_type == 2 (short block)." However, other + * sources suggest alias reduction should indeed be performed on the + * lower two subbands of mixed blocks. Most other implementations do + * this, so by default we will too. + */ + if (channel->flags & mixed_block_flag) + III_aliasreduce(xr[ch], 36); +# endif + } + else + III_aliasreduce(xr[ch], 576); + + l = 0; + + /* subbands 0-1 */ + + if (channel->block_type != 2 || (channel->flags & mixed_block_flag)) { + unsigned int block_type; + + block_type = channel->block_type; + if (channel->flags & mixed_block_flag) + block_type = 0; + + /* long blocks */ + for (sb = 0; sb < 2; ++sb, l += 18) { + III_imdct_l(&xr[ch][l], output, block_type); + III_overlap(output, (*frame->overlap)[ch][sb], sample, sb); + } + } + else { + /* short blocks */ + for (sb = 0; sb < 2; ++sb, l += 18) { + III_imdct_s(&xr[ch][l], output); + III_overlap(output, (*frame->overlap)[ch][sb], sample, sb); + } + } + + III_freqinver(sample, 1); + + /* (nonzero) subbands 2-31 */ + +/* + i = 576; + while (i > 36 && xr[ch][i - 1] == 0) + --i; +*/ + + { + /* saves ~600k cycles */ + mad_fixed_t *p = &xr[ch][576]; + mad_fixed_t tmp = xr[ch][35]; + xr[ch][35] = 1; + while (!*--p); + xr[ch][35] = tmp; + i = p - &xr[ch][0] + 1; + } + sblimit = 32 - (576 - i) / 18; + + if (channel->block_type != 2) { + /* long blocks */ + for (sb = 2; sb < sblimit; ++sb, l += 18) { + III_imdct_l(&xr[ch][l], output, channel->block_type); + III_overlap(output, (*frame->overlap)[ch][sb], sample, sb); + + if (sb & 1) + III_freqinver(sample, sb); + } + } + else { + /* short blocks */ + for (sb = 2; sb < sblimit; ++sb, l += 18) { + III_imdct_s(&xr[ch][l], output); + III_overlap(output, (*frame->overlap)[ch][sb], sample, sb); + + if (sb & 1) + III_freqinver(sample, sb); + } + } + + /* remaining (zero) subbands */ + + for (sb = sblimit; sb < 32; ++sb) { + III_overlap_z((*frame->overlap)[ch][sb], sample, sb); + + if (sb & 1) + III_freqinver(sample, sb); + } + } + } + + return MAD_ERROR_NONE; +} + +/* + * NAME: layer->III() + * DESCRIPTION: decode a single Layer III frame + */ +int mad_layer_III(struct mad_stream *stream, struct mad_frame *frame) +{ + struct mad_header *header = &frame->header; + unsigned int nch, priv_bitlen, next_md_begin = 0; + unsigned int si_len, data_bitlen, md_len; + unsigned int frame_space, frame_used, frame_free; + struct mad_bitptr ptr; + struct sideinfo si; + enum mad_error error; + int result = 0; + +#if 0 /* rockbox: do not allocate */ + /* allocate Layer III dynamic structures */ + /* rockbox: not used. Both pointers are linked to an array in + * ../mpa.c before calling this. */ + if (stream->main_data == 0) { + stream->main_data = malloc(MAD_BUFFER_MDLEN); + if (stream->main_data == 0) { + stream->error = MAD_ERROR_NOMEM; + return -1; + } + } + + if (frame->overlap == 0) { + frame->overlap = calloc(2 * 32 * 18, sizeof(mad_fixed_t)); + if (frame->overlap == 0) { + stream->error = MAD_ERROR_NOMEM; + return -1; + } + } +#else + /* rockbox: This should not happen. Return with error. */ + if ((stream->main_data == 0) || (frame->overlap == 0)) { + stream->error = MAD_ERROR_NOMEM; + return -1; + } +#endif /* rockbox */ + + nch = MAD_NCHANNELS(header); + si_len = (header->flags & MAD_FLAG_LSF_EXT) ? + (nch == 1 ? 9 : 17) : (nch == 1 ? 17 : 32); + + /* check frame sanity */ + + if (stream->next_frame - mad_bit_nextbyte(&stream->ptr) < + (signed int) si_len) { + stream->error = MAD_ERROR_BADFRAMELEN; + stream->md_len = 0; + return -1; + } + + /* check CRC word */ + + if (header->flags & MAD_FLAG_PROTECTION) { + header->crc_check = + mad_bit_crc(stream->ptr, si_len * CHAR_BIT, header->crc_check); + + if (header->crc_check != header->crc_target && + !(frame->options & MAD_OPTION_IGNORECRC)) { + stream->error = MAD_ERROR_BADCRC; + result = -1; + } + } + + /* decode frame side information */ + + error = III_sideinfo(&stream->ptr, nch, header->flags & MAD_FLAG_LSF_EXT, + &si, &data_bitlen, &priv_bitlen); + if (error && result == 0) { + stream->error = error; + result = -1; + } + + header->flags |= priv_bitlen; + header->private_bits |= si.private_bits; + + /* find main_data of next frame */ + + { + struct mad_bitptr peek; + unsigned long header; + + mad_bit_init(&peek, stream->next_frame); + + header = mad_bit_read(&peek, 32); + if ((header & 0xffe60000L) /* syncword | layer */ == 0xffe20000L) { + if (!(header & 0x00010000L)) /* protection_bit */ + mad_bit_skip(&peek, 16); /* crc_check */ + + next_md_begin = + mad_bit_read(&peek, (header & 0x00080000L) /* ID */ ? 9 : 8); + } + + mad_bit_finish(&peek); + } + + /* find main_data of this frame */ + + frame_space = stream->next_frame - mad_bit_nextbyte(&stream->ptr); + + if (next_md_begin > si.main_data_begin + frame_space) + next_md_begin = 0; + + md_len = si.main_data_begin + frame_space - next_md_begin; + + frame_used = 0; + + if (si.main_data_begin == 0) { + ptr = stream->ptr; + stream->md_len = 0; + + frame_used = md_len; + } + else { + if (si.main_data_begin > stream->md_len) { + if (result == 0) { + stream->error = MAD_ERROR_BADDATAPTR; + result = -1; + } + } + else { + mad_bit_init(&ptr, + *stream->main_data + stream->md_len - si.main_data_begin); + + if (md_len > si.main_data_begin) { + assert(stream->md_len + md_len - + si.main_data_begin <= MAD_BUFFER_MDLEN); + + memcpy(*stream->main_data + stream->md_len, + mad_bit_nextbyte(&stream->ptr), + frame_used = md_len - si.main_data_begin); + stream->md_len += frame_used; + } + } + } + + frame_free = frame_space - frame_used; + + /* decode main_data */ + + if (result == 0) { + error = III_decode(&ptr, frame, &si, nch); + if (error) { + stream->error = error; + result = -1; + } + + /* designate ancillary bits */ + + stream->anc_ptr = ptr; + stream->anc_bitlen = md_len * CHAR_BIT - data_bitlen; + } + +# if 0 && defined(DEBUG) + fprintf(stderr, + "main_data_begin:%u, md_len:%u, frame_free:%u, " + "data_bitlen:%u, anc_bitlen: %u\n", + si.main_data_begin, md_len, frame_free, + data_bitlen, stream->anc_bitlen); +# endif + + /* preload main_data buffer with up to 511 bytes for next frame(s) */ + + if (frame_free >= next_md_begin) { + memcpy(*stream->main_data, + stream->next_frame - next_md_begin, next_md_begin); + stream->md_len = next_md_begin; + } + else { + if (md_len < si.main_data_begin) { + unsigned int extra; + + extra = si.main_data_begin - md_len; + if (extra + frame_free > next_md_begin) + extra = next_md_begin - frame_free; + + if (extra < stream->md_len) { + memmove(*stream->main_data, + *stream->main_data + stream->md_len - extra, extra); + stream->md_len = extra; + } + } + else + stream->md_len = 0; + + memcpy(*stream->main_data + stream->md_len, + stream->next_frame - frame_free, frame_free); + stream->md_len += frame_free; + } + + return result; +} diff --git a/lib/rbcodec/codecs/libmad/layer3.h b/lib/rbcodec/codecs/libmad/layer3.h new file mode 100644 index 0000000000..15948037e9 --- /dev/null +++ b/lib/rbcodec/codecs/libmad/layer3.h @@ -0,0 +1,30 @@ +/* + * libmad - MPEG audio decoder library + * Copyright (C) 2000-2004 Underbit Technologies, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * $Id$ + */ + +# ifndef LIBMAD_LAYER3_H +# define LIBMAD_LAYER3_H + +# include "stream.h" +# include "frame.h" + +int mad_layer_III(struct mad_stream *, struct mad_frame *); + +# endif diff --git a/lib/rbcodec/codecs/libmad/libmad.make b/lib/rbcodec/codecs/libmad/libmad.make new file mode 100644 index 0000000000..2a8c7b220f --- /dev/null +++ b/lib/rbcodec/codecs/libmad/libmad.make @@ -0,0 +1,66 @@ +# __________ __ ___. +# Open \______ \ ____ ____ | | _\_ |__ _______ ___ +# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / +# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < +# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ +# \/ \/ \/ \/ \/ +# $Id$ +# + +# we need to build two different mad libraries +# (one for codec, one for mpegplayer) +# so a little trickery is necessary + +# Extract optimization level ('-O') from compile flags. Will be set later. +MADFLAGS = $(filter-out -O%,$(CODECFLAGS)) -I$(RBCODECLIB_DIR)/codecs/libmad +MADFLAGS += -UDEBUG -DNDEBUG -DHAVE_LIMITS_H + +# libmad is faster on ARM-targets with -O1 than -O2 +ifeq ($(ARCH),arch_arm) + MADFLAGS += -O1 +else + MADFLAGS += -O2 +endif + +# MPEGplayer +MPEGMADFLAGS = $(MADFLAGS) -DMPEGPLAYER + +# libmad +MADLIB := $(CODECDIR)/libmad.a +MADLIB_SRC := $(call preprocess, $(RBCODECLIB_DIR)/codecs/libmad/SOURCES) +MADLIB_OBJ := $(call c2obj, $(MADLIB_SRC)) +OTHER_SRC += $(MADLIB_SRC) + +$(MADLIB): $(MADLIB_OBJ) + $(SILENT)$(shell rm -f $@) + $(call PRINTS,AR $(@F))$(AR) rcs $@ $^ >/dev/null + +# libmad-mpeg +MPEGMADLIB := $(CODECDIR)/libmad-mpeg.a +MPEGMADLIB_SRC := $(call preprocess, $(RBCODECLIB_DIR)/codecs/libmad/SOURCES) +MPEGMADLIB_OBJ := $(addsuffix .o,$(basename $(subst $(RBCODECLIB_DIR)/codecs/libmad,$(RBCODEC_BLD)/codecs/libmad-mpeg,$(MPEGMADLIB_SRC)))) + +$(MPEGMADLIB): $(MPEGMADLIB_OBJ) + $(call PRINTS,AR $(@F))$(AR) rcs $@ $^ >/dev/null + +# pattern rules + +$(CODECDIR)/libmad-mpeg/%.o : $(RBCODECLIB_DIR)/codecs/libmad/%.c + $(SILENT)mkdir -p $(dir $@) + $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<)) \ + $(CC) $(MPEGMADFLAGS) -c $< -o $@ + +$(CODECDIR)/libmad-mpeg/%.o : $(RBCODECLIB_DIR)/codecs/libmad/%.S + $(SILENT)mkdir -p $(dir $@) + $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<)) \ + $(CC) $(MPEGMADFLAGS) $(ASMFLAGS) -c $< -o $@ + +$(CODECDIR)/libmad/%.o: $(RBCODECLIB_DIR)/codecs/libmad/%.c + $(SILENT)mkdir -p $(dir $@) + $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<)) \ + $(CC) $(MADFLAGS) -c $< -o $@ + +$(CODECDIR)/libmad/%.o: $(RBCODECLIB_DIR)/codecs/libmad/%.S + $(SILENT)mkdir -p $(dir $@) + $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<)) \ + $(CC) $(MADFLAGS) $(ASMFLAGS) -c $< -o $@ diff --git a/lib/rbcodec/codecs/libmad/mad.h b/lib/rbcodec/codecs/libmad/mad.h new file mode 100644 index 0000000000..3ae0d88a0e --- /dev/null +++ b/lib/rbcodec/codecs/libmad/mad.h @@ -0,0 +1,31 @@ +/* + * libmad - MPEG audio decoder library + * Copyright (C) 2000-2004 Underbit Technologies, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * If you would like to negotiate alternate licensing terms, you may do + * so by contacting: Underbit Technologies, Inc. + */ + +#include + +#define FPM_DEFAULT + +#include "fixed.h" +#include "bit.h" +#include "stream.h" +#include "frame.h" +#include "synth.h" diff --git a/lib/rbcodec/codecs/libmad/mad_iram.h b/lib/rbcodec/codecs/libmad/mad_iram.h new file mode 100644 index 0000000000..ac0b64cca9 --- /dev/null +++ b/lib/rbcodec/codecs/libmad/mad_iram.h @@ -0,0 +1,57 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2007 Dave Chapman + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +/* Define how IRAM is used on the various targets. Note that this + file is included by both .c and .S files so must not contain any C + code. +*/ + +#ifndef _LIBMAD_IRAM_H +#define _LIBMAD_IRAM_H + +#include "config.h" + +#if (CONFIG_PLATFORM&PLATFORM_HOSTED) +#define ICODE_SECTION_MPA_ARM .text +#define IBSS_SECTION_MPA_ARM .bss +#define ICODE_ATTR_MPA_SYNTH +#define ICONST_ATTR_MPA_HUFFMAN +#else +/* Code performs slower in IRAM on PP502x and there is no space in + mpegplayer on the PP5002. S3C2440 doesn't have any IRAM available for + codecs */ +#if defined(CPU_PP502x) || (CONFIG_CPU == PP5002 && defined(MPEGPLAYER)) +#define ICODE_SECTION_MPA_ARM .text +#define ICODE_ATTR_MPA_SYNTH +#else +#define ICODE_SECTION_MPA_ARM .icode +#define ICODE_ATTR_MPA_SYNTH ICODE_ATTR +#endif + +#define IBSS_SECTION_MPA_ARM .ibss + +#ifndef ICONST_ATTR_MPA_HUFFMAN +#define ICONST_ATTR_MPA_HUFFMAN ICONST_ATTR +#endif + +#endif + +#endif /* MAD_IRAM_H */ diff --git a/lib/rbcodec/codecs/libmad/qc_table.dat b/lib/rbcodec/codecs/libmad/qc_table.dat new file mode 100644 index 0000000000..d28a207049 --- /dev/null +++ b/lib/rbcodec/codecs/libmad/qc_table.dat @@ -0,0 +1,77 @@ +/* + * libmad - MPEG audio decoder library + * Copyright (C) 2000-2004 Underbit Technologies, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * $Id$ + */ + +/* + * These are the Layer II classes of quantization. + * The table is derived from Table B.4 of ISO/IEC 11172-3. + */ + + { 3, 2, 5, + MAD_F(0x15555555) /* 1.33333333333 => 1.33333333209, e 0.00000000124 */, + MAD_F(0x08000000) /* 0.50000000000 => 0.50000000000, e 0.00000000000 */ }, + { 5, 3, 7, + MAD_F(0x1999999a) /* 1.60000000000 => 1.60000000149, e -0.00000000149 */, + MAD_F(0x08000000) /* 0.50000000000 => 0.50000000000, e 0.00000000000 */ }, + { 7, 0, 3, + MAD_F(0x12492492) /* 1.14285714286 => 1.14285714179, e 0.00000000107 */, + MAD_F(0x04000000) /* 0.25000000000 => 0.25000000000, e 0.00000000000 */ }, + { 9, 4, 10, + MAD_F(0x1c71c71c) /* 1.77777777777 => 1.77777777612, e 0.00000000165 */, + MAD_F(0x08000000) /* 0.50000000000 => 0.50000000000, e 0.00000000000 */ }, + { 15, 0, 4, + MAD_F(0x11111111) /* 1.06666666666 => 1.06666666642, e 0.00000000024 */, + MAD_F(0x02000000) /* 0.12500000000 => 0.12500000000, e 0.00000000000 */ }, + { 31, 0, 5, + MAD_F(0x10842108) /* 1.03225806452 => 1.03225806355, e 0.00000000097 */, + MAD_F(0x01000000) /* 0.06250000000 => 0.06250000000, e 0.00000000000 */ }, + { 63, 0, 6, + MAD_F(0x10410410) /* 1.01587301587 => 1.01587301493, e 0.00000000094 */, + MAD_F(0x00800000) /* 0.03125000000 => 0.03125000000, e 0.00000000000 */ }, + { 127, 0, 7, + MAD_F(0x10204081) /* 1.00787401575 => 1.00787401572, e 0.00000000003 */, + MAD_F(0x00400000) /* 0.01562500000 => 0.01562500000, e 0.00000000000 */ }, + { 255, 0, 8, + MAD_F(0x10101010) /* 1.00392156863 => 1.00392156839, e 0.00000000024 */, + MAD_F(0x00200000) /* 0.00781250000 => 0.00781250000, e 0.00000000000 */ }, + { 511, 0, 9, + MAD_F(0x10080402) /* 1.00195694716 => 1.00195694715, e 0.00000000001 */, + MAD_F(0x00100000) /* 0.00390625000 => 0.00390625000, e 0.00000000000 */ }, + { 1023, 0, 10, + MAD_F(0x10040100) /* 1.00097751711 => 1.00097751617, e 0.00000000094 */, + MAD_F(0x00080000) /* 0.00195312500 => 0.00195312500, e 0.00000000000 */ }, + { 2047, 0, 11, + MAD_F(0x10020040) /* 1.00048851979 => 1.00048851967, e 0.00000000012 */, + MAD_F(0x00040000) /* 0.00097656250 => 0.00097656250, e 0.00000000000 */ }, + { 4095, 0, 12, + MAD_F(0x10010010) /* 1.00024420024 => 1.00024420023, e 0.00000000001 */, + MAD_F(0x00020000) /* 0.00048828125 => 0.00048828125, e 0.00000000000 */ }, + { 8191, 0, 13, + MAD_F(0x10008004) /* 1.00012208522 => 1.00012208521, e 0.00000000001 */, + MAD_F(0x00010000) /* 0.00024414063 => 0.00024414062, e 0.00000000000 */ }, + { 16383, 0, 14, + MAD_F(0x10004001) /* 1.00006103888 => 1.00006103888, e -0.00000000000 */, + MAD_F(0x00008000) /* 0.00012207031 => 0.00012207031, e -0.00000000000 */ }, + { 32767, 0, 15, + MAD_F(0x10002000) /* 1.00003051851 => 1.00003051758, e 0.00000000093 */, + MAD_F(0x00004000) /* 0.00006103516 => 0.00006103516, e 0.00000000000 */ }, + { 65535, 0, 16, + MAD_F(0x10001000) /* 1.00001525902 => 1.00001525879, e 0.00000000023 */, + MAD_F(0x00002000) /* 0.00003051758 => 0.00003051758, e 0.00000000000 */ } diff --git a/lib/rbcodec/codecs/libmad/rq_table.dat b/lib/rbcodec/codecs/libmad/rq_table.dat new file mode 100644 index 0000000000..b3a37c13cd --- /dev/null +++ b/lib/rbcodec/codecs/libmad/rq_table.dat @@ -0,0 +1,8747 @@ +/* + * libmad - MPEG audio decoder library + * Copyright (C) 2000-2004 Underbit Technologies, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * $Id$ + */ + +/* + * This is the lookup table used to compute x^(4/3) for Layer III + * requantization. To maintain the best possible accuracy, the value is + * stored as a normalized mantissa with exponent. The requantization + * algorithm recombines these parts with appropriate scaling. + */ + + /* 0 */ 0x00000000 | (0 << 27) /* 0.000000000 */, + /* 1 */ 0x04000000 | (2 << 27) /* 0.250000000 */, + /* 2 */ 0x050a28be | (3 << 27) /* 0.314980262 */, + /* 3 */ 0x0453a5cd | (4 << 27) /* 0.270421794 */, + /* 4 */ 0x06597fa9 | (4 << 27) /* 0.396850263 */, + /* 5 */ 0x04466275 | (5 << 27) /* 0.267183742 */, + /* 6 */ 0x05738c72 | (5 << 27) /* 0.340710111 */, + /* 7 */ 0x06b1fc81 | (5 << 27) /* 0.418453696 */, + /* 8 */ 0x04000000 | (6 << 27) /* 0.250000000 */, + /* 9 */ 0x04ae20d7 | (6 << 27) /* 0.292511788 */, + /* 10 */ 0x0562d694 | (6 << 27) /* 0.336630420 */, + /* 11 */ 0x061dae96 | (6 << 27) /* 0.382246578 */, + /* 12 */ 0x06de47f4 | (6 << 27) /* 0.429267841 */, + /* 13 */ 0x07a44f7a | (6 << 27) /* 0.477614858 */, + /* 14 */ 0x0437be65 | (7 << 27) /* 0.263609310 */, + /* 15 */ 0x049fc824 | (7 << 27) /* 0.289009227 */, + + /* 16 */ 0x050a28be | (7 << 27) /* 0.314980262 */, + /* 17 */ 0x0576c6f5 | (7 << 27) /* 0.341498336 */, + /* 18 */ 0x05e58c0b | (7 << 27) /* 0.368541759 */, + /* 19 */ 0x06566361 | (7 << 27) /* 0.396090870 */, + /* 20 */ 0x06c93a2e | (7 << 27) /* 0.424127753 */, + /* 21 */ 0x073dff3e | (7 << 27) /* 0.452635998 */, + /* 22 */ 0x07b4a2bc | (7 << 27) /* 0.481600510 */, + /* 23 */ 0x04168b05 | (8 << 27) /* 0.255503674 */, + /* 24 */ 0x0453a5cd | (8 << 27) /* 0.270421794 */, + /* 25 */ 0x04919b6a | (8 << 27) /* 0.285548607 */, + /* 26 */ 0x04d065fb | (8 << 27) /* 0.300878507 */, + /* 27 */ 0x05100000 | (8 << 27) /* 0.316406250 */, + /* 28 */ 0x05506451 | (8 << 27) /* 0.332126919 */, + /* 29 */ 0x05918e15 | (8 << 27) /* 0.348035890 */, + /* 30 */ 0x05d378bb | (8 << 27) /* 0.364128809 */, + /* 31 */ 0x06161ff3 | (8 << 27) /* 0.380401563 */, + + /* 32 */ 0x06597fa9 | (8 << 27) /* 0.396850263 */, + /* 33 */ 0x069d9400 | (8 << 27) /* 0.413471222 */, + /* 34 */ 0x06e2594c | (8 << 27) /* 0.430260942 */, + /* 35 */ 0x0727cc11 | (8 << 27) /* 0.447216097 */, + /* 36 */ 0x076de8fc | (8 << 27) /* 0.464333519 */, + /* 37 */ 0x07b4ace3 | (8 << 27) /* 0.481610189 */, + /* 38 */ 0x07fc14bf | (8 << 27) /* 0.499043224 */, + /* 39 */ 0x04220ed7 | (9 << 27) /* 0.258314934 */, + /* 40 */ 0x04466275 | (9 << 27) /* 0.267183742 */, + /* 41 */ 0x046b03e7 | (9 << 27) /* 0.276126771 */, + /* 42 */ 0x048ff1e8 | (9 << 27) /* 0.285142811 */, + /* 43 */ 0x04b52b3f | (9 << 27) /* 0.294230696 */, + /* 44 */ 0x04daaec0 | (9 << 27) /* 0.303389310 */, + /* 45 */ 0x05007b49 | (9 << 27) /* 0.312617576 */, + /* 46 */ 0x05268fc6 | (9 << 27) /* 0.321914457 */, + /* 47 */ 0x054ceb2a | (9 << 27) /* 0.331278957 */, + + /* 48 */ 0x05738c72 | (9 << 27) /* 0.340710111 */, + /* 49 */ 0x059a72a5 | (9 << 27) /* 0.350206992 */, + /* 50 */ 0x05c19cd3 | (9 << 27) /* 0.359768701 */, + /* 51 */ 0x05e90a12 | (9 << 27) /* 0.369394372 */, + /* 52 */ 0x0610b982 | (9 << 27) /* 0.379083164 */, + /* 53 */ 0x0638aa48 | (9 << 27) /* 0.388834268 */, + /* 54 */ 0x0660db91 | (9 << 27) /* 0.398646895 */, + /* 55 */ 0x06894c90 | (9 << 27) /* 0.408520284 */, + /* 56 */ 0x06b1fc81 | (9 << 27) /* 0.418453696 */, + /* 57 */ 0x06daeaa1 | (9 << 27) /* 0.428446415 */, + /* 58 */ 0x07041636 | (9 << 27) /* 0.438497744 */, + /* 59 */ 0x072d7e8b | (9 << 27) /* 0.448607009 */, + /* 60 */ 0x075722ef | (9 << 27) /* 0.458773552 */, + /* 61 */ 0x078102b8 | (9 << 27) /* 0.468996735 */, + /* 62 */ 0x07ab1d3e | (9 << 27) /* 0.479275937 */, + /* 63 */ 0x07d571e0 | (9 << 27) /* 0.489610555 */, + + /* 64 */ 0x04000000 | (10 << 27) /* 0.250000000 */, + /* 65 */ 0x04156381 | (10 << 27) /* 0.255221850 */, + /* 66 */ 0x042ae32a | (10 << 27) /* 0.260470548 */, + /* 67 */ 0x04407eb1 | (10 << 27) /* 0.265745823 */, + /* 68 */ 0x045635cf | (10 << 27) /* 0.271047409 */, + /* 69 */ 0x046c083e | (10 << 27) /* 0.276375048 */, + /* 70 */ 0x0481f5bb | (10 << 27) /* 0.281728487 */, + /* 71 */ 0x0497fe03 | (10 << 27) /* 0.287107481 */, + /* 72 */ 0x04ae20d7 | (10 << 27) /* 0.292511788 */, + /* 73 */ 0x04c45df6 | (10 << 27) /* 0.297941173 */, + /* 74 */ 0x04dab524 | (10 << 27) /* 0.303395408 */, + /* 75 */ 0x04f12624 | (10 << 27) /* 0.308874267 */, + /* 76 */ 0x0507b0bc | (10 << 27) /* 0.314377532 */, + /* 77 */ 0x051e54b1 | (10 << 27) /* 0.319904987 */, + /* 78 */ 0x053511cb | (10 << 27) /* 0.325456423 */, + /* 79 */ 0x054be7d4 | (10 << 27) /* 0.331031635 */, + + /* 80 */ 0x0562d694 | (10 << 27) /* 0.336630420 */, + /* 81 */ 0x0579ddd8 | (10 << 27) /* 0.342252584 */, + /* 82 */ 0x0590fd6c | (10 << 27) /* 0.347897931 */, + /* 83 */ 0x05a8351c | (10 << 27) /* 0.353566275 */, + /* 84 */ 0x05bf84b8 | (10 << 27) /* 0.359257429 */, + /* 85 */ 0x05d6ec0e | (10 << 27) /* 0.364971213 */, + /* 86 */ 0x05ee6aef | (10 << 27) /* 0.370707448 */, + /* 87 */ 0x0606012b | (10 << 27) /* 0.376465960 */, + /* 88 */ 0x061dae96 | (10 << 27) /* 0.382246578 */, + /* 89 */ 0x06357302 | (10 << 27) /* 0.388049134 */, + /* 90 */ 0x064d4e43 | (10 << 27) /* 0.393873464 */, + /* 91 */ 0x0665402d | (10 << 27) /* 0.399719406 */, + /* 92 */ 0x067d4896 | (10 << 27) /* 0.405586801 */, + /* 93 */ 0x06956753 | (10 << 27) /* 0.411475493 */, + /* 94 */ 0x06ad9c3d | (10 << 27) /* 0.417385331 */, + /* 95 */ 0x06c5e72b | (10 << 27) /* 0.423316162 */, + + /* 96 */ 0x06de47f4 | (10 << 27) /* 0.429267841 */, + /* 97 */ 0x06f6be73 | (10 << 27) /* 0.435240221 */, + /* 98 */ 0x070f4a80 | (10 << 27) /* 0.441233161 */, + /* 99 */ 0x0727ebf7 | (10 << 27) /* 0.447246519 */, + /* 100 */ 0x0740a2b2 | (10 << 27) /* 0.453280160 */, + /* 101 */ 0x07596e8d | (10 << 27) /* 0.459333946 */, + /* 102 */ 0x07724f64 | (10 << 27) /* 0.465407744 */, + /* 103 */ 0x078b4514 | (10 << 27) /* 0.471501425 */, + /* 104 */ 0x07a44f7a | (10 << 27) /* 0.477614858 */, + /* 105 */ 0x07bd6e75 | (10 << 27) /* 0.483747918 */, + /* 106 */ 0x07d6a1e2 | (10 << 27) /* 0.489900479 */, + /* 107 */ 0x07efe9a1 | (10 << 27) /* 0.496072418 */, + /* 108 */ 0x0404a2c9 | (11 << 27) /* 0.251131807 */, + /* 109 */ 0x04115aca | (11 << 27) /* 0.254236974 */, + /* 110 */ 0x041e1cc4 | (11 << 27) /* 0.257351652 */, + /* 111 */ 0x042ae8a7 | (11 << 27) /* 0.260475783 */, + + /* 112 */ 0x0437be65 | (11 << 27) /* 0.263609310 */, + /* 113 */ 0x04449dee | (11 << 27) /* 0.266752177 */, + /* 114 */ 0x04518733 | (11 << 27) /* 0.269904329 */, + /* 115 */ 0x045e7a26 | (11 << 27) /* 0.273065710 */, + /* 116 */ 0x046b76b9 | (11 << 27) /* 0.276236269 */, + /* 117 */ 0x04787cdc | (11 << 27) /* 0.279415952 */, + /* 118 */ 0x04858c83 | (11 << 27) /* 0.282604707 */, + /* 119 */ 0x0492a59f | (11 << 27) /* 0.285802482 */, + /* 120 */ 0x049fc824 | (11 << 27) /* 0.289009227 */, + /* 121 */ 0x04acf402 | (11 << 27) /* 0.292224893 */, + /* 122 */ 0x04ba292e | (11 << 27) /* 0.295449429 */, + /* 123 */ 0x04c7679a | (11 << 27) /* 0.298682788 */, + /* 124 */ 0x04d4af3a | (11 << 27) /* 0.301924921 */, + /* 125 */ 0x04e20000 | (11 << 27) /* 0.305175781 */, + /* 126 */ 0x04ef59e0 | (11 << 27) /* 0.308435322 */, + /* 127 */ 0x04fcbcce | (11 << 27) /* 0.311703498 */, + + /* 128 */ 0x050a28be | (11 << 27) /* 0.314980262 */, + /* 129 */ 0x05179da4 | (11 << 27) /* 0.318265572 */, + /* 130 */ 0x05251b73 | (11 << 27) /* 0.321559381 */, + /* 131 */ 0x0532a220 | (11 << 27) /* 0.324861647 */, + /* 132 */ 0x054031a0 | (11 << 27) /* 0.328172327 */, + /* 133 */ 0x054dc9e7 | (11 << 27) /* 0.331491377 */, + /* 134 */ 0x055b6ae9 | (11 << 27) /* 0.334818756 */, + /* 135 */ 0x0569149c | (11 << 27) /* 0.338154423 */, + /* 136 */ 0x0576c6f5 | (11 << 27) /* 0.341498336 */, + /* 137 */ 0x058481e9 | (11 << 27) /* 0.344850455 */, + /* 138 */ 0x0592456d | (11 << 27) /* 0.348210741 */, + /* 139 */ 0x05a01176 | (11 << 27) /* 0.351579152 */, + /* 140 */ 0x05ade5fa | (11 << 27) /* 0.354955651 */, + /* 141 */ 0x05bbc2ef | (11 << 27) /* 0.358340200 */, + /* 142 */ 0x05c9a84a | (11 << 27) /* 0.361732758 */, + /* 143 */ 0x05d79601 | (11 << 27) /* 0.365133291 */, + + /* 144 */ 0x05e58c0b | (11 << 27) /* 0.368541759 */, + /* 145 */ 0x05f38a5d | (11 << 27) /* 0.371958126 */, + /* 146 */ 0x060190ee | (11 << 27) /* 0.375382356 */, + /* 147 */ 0x060f9fb3 | (11 << 27) /* 0.378814413 */, + /* 148 */ 0x061db6a5 | (11 << 27) /* 0.382254261 */, + /* 149 */ 0x062bd5b8 | (11 << 27) /* 0.385701865 */, + /* 150 */ 0x0639fce4 | (11 << 27) /* 0.389157191 */, + /* 151 */ 0x06482c1f | (11 << 27) /* 0.392620204 */, + /* 152 */ 0x06566361 | (11 << 27) /* 0.396090870 */, + /* 153 */ 0x0664a2a0 | (11 << 27) /* 0.399569155 */, + /* 154 */ 0x0672e9d4 | (11 << 27) /* 0.403055027 */, + /* 155 */ 0x068138f3 | (11 << 27) /* 0.406548452 */, + /* 156 */ 0x068f8ff5 | (11 << 27) /* 0.410049398 */, + /* 157 */ 0x069deed1 | (11 << 27) /* 0.413557833 */, + /* 158 */ 0x06ac557f | (11 << 27) /* 0.417073724 */, + /* 159 */ 0x06bac3f6 | (11 << 27) /* 0.420597041 */, + + /* 160 */ 0x06c93a2e | (11 << 27) /* 0.424127753 */, + /* 161 */ 0x06d7b81f | (11 << 27) /* 0.427665827 */, + /* 162 */ 0x06e63dc0 | (11 << 27) /* 0.431211234 */, + /* 163 */ 0x06f4cb09 | (11 << 27) /* 0.434763944 */, + /* 164 */ 0x07035ff3 | (11 << 27) /* 0.438323927 */, + /* 165 */ 0x0711fc75 | (11 << 27) /* 0.441891153 */, + /* 166 */ 0x0720a087 | (11 << 27) /* 0.445465593 */, + /* 167 */ 0x072f4c22 | (11 << 27) /* 0.449047217 */, + /* 168 */ 0x073dff3e | (11 << 27) /* 0.452635998 */, + /* 169 */ 0x074cb9d3 | (11 << 27) /* 0.456231906 */, + /* 170 */ 0x075b7bdb | (11 << 27) /* 0.459834914 */, + /* 171 */ 0x076a454c | (11 << 27) /* 0.463444993 */, + /* 172 */ 0x07791620 | (11 << 27) /* 0.467062117 */, + /* 173 */ 0x0787ee50 | (11 << 27) /* 0.470686258 */, + /* 174 */ 0x0796cdd4 | (11 << 27) /* 0.474317388 */, + /* 175 */ 0x07a5b4a5 | (11 << 27) /* 0.477955481 */, + + /* 176 */ 0x07b4a2bc | (11 << 27) /* 0.481600510 */, + /* 177 */ 0x07c39812 | (11 << 27) /* 0.485252449 */, + /* 178 */ 0x07d294a0 | (11 << 27) /* 0.488911273 */, + /* 179 */ 0x07e1985f | (11 << 27) /* 0.492576954 */, + /* 180 */ 0x07f0a348 | (11 << 27) /* 0.496249468 */, + /* 181 */ 0x07ffb554 | (11 << 27) /* 0.499928790 */, + /* 182 */ 0x0407673f | (12 << 27) /* 0.251807447 */, + /* 183 */ 0x040ef75e | (12 << 27) /* 0.253653877 */, + /* 184 */ 0x04168b05 | (12 << 27) /* 0.255503674 */, + /* 185 */ 0x041e2230 | (12 << 27) /* 0.257356825 */, + /* 186 */ 0x0425bcdd | (12 << 27) /* 0.259213318 */, + /* 187 */ 0x042d5b07 | (12 << 27) /* 0.261073141 */, + /* 188 */ 0x0434fcad | (12 << 27) /* 0.262936282 */, + /* 189 */ 0x043ca1c9 | (12 << 27) /* 0.264802730 */, + /* 190 */ 0x04444a5a | (12 << 27) /* 0.266672472 */, + /* 191 */ 0x044bf65d | (12 << 27) /* 0.268545497 */, + + /* 192 */ 0x0453a5cd | (12 << 27) /* 0.270421794 */, + /* 193 */ 0x045b58a9 | (12 << 27) /* 0.272301352 */, + /* 194 */ 0x04630eed | (12 << 27) /* 0.274184158 */, + /* 195 */ 0x046ac896 | (12 << 27) /* 0.276070203 */, + /* 196 */ 0x047285a2 | (12 << 27) /* 0.277959474 */, + /* 197 */ 0x047a460c | (12 << 27) /* 0.279851960 */, + /* 198 */ 0x048209d3 | (12 << 27) /* 0.281747652 */, + /* 199 */ 0x0489d0f4 | (12 << 27) /* 0.283646538 */, + /* 200 */ 0x04919b6a | (12 << 27) /* 0.285548607 */, + /* 201 */ 0x04996935 | (12 << 27) /* 0.287453849 */, + /* 202 */ 0x04a13a50 | (12 << 27) /* 0.289362253 */, + /* 203 */ 0x04a90eba | (12 << 27) /* 0.291273810 */, + /* 204 */ 0x04b0e66e | (12 << 27) /* 0.293188507 */, + /* 205 */ 0x04b8c16c | (12 << 27) /* 0.295106336 */, + /* 206 */ 0x04c09faf | (12 << 27) /* 0.297027285 */, + /* 207 */ 0x04c88135 | (12 << 27) /* 0.298951346 */, + + /* 208 */ 0x04d065fb | (12 << 27) /* 0.300878507 */, + /* 209 */ 0x04d84dff | (12 << 27) /* 0.302808759 */, + /* 210 */ 0x04e0393e | (12 << 27) /* 0.304742092 */, + /* 211 */ 0x04e827b6 | (12 << 27) /* 0.306678497 */, + /* 212 */ 0x04f01963 | (12 << 27) /* 0.308617963 */, + /* 213 */ 0x04f80e44 | (12 << 27) /* 0.310560480 */, + /* 214 */ 0x05000655 | (12 << 27) /* 0.312506041 */, + /* 215 */ 0x05080195 | (12 << 27) /* 0.314454634 */, + /* 216 */ 0x05100000 | (12 << 27) /* 0.316406250 */, + /* 217 */ 0x05180194 | (12 << 27) /* 0.318360880 */, + /* 218 */ 0x0520064f | (12 << 27) /* 0.320318516 */, + /* 219 */ 0x05280e2d | (12 << 27) /* 0.322279147 */, + /* 220 */ 0x0530192e | (12 << 27) /* 0.324242764 */, + /* 221 */ 0x0538274e | (12 << 27) /* 0.326209359 */, + /* 222 */ 0x0540388a | (12 << 27) /* 0.328178922 */, + /* 223 */ 0x05484ce2 | (12 << 27) /* 0.330151445 */, + + /* 224 */ 0x05506451 | (12 << 27) /* 0.332126919 */, + /* 225 */ 0x05587ed5 | (12 << 27) /* 0.334105334 */, + /* 226 */ 0x05609c6e | (12 << 27) /* 0.336086683 */, + /* 227 */ 0x0568bd17 | (12 << 27) /* 0.338070956 */, + /* 228 */ 0x0570e0cf | (12 << 27) /* 0.340058145 */, + /* 229 */ 0x05790793 | (12 << 27) /* 0.342048241 */, + /* 230 */ 0x05813162 | (12 << 27) /* 0.344041237 */, + /* 231 */ 0x05895e39 | (12 << 27) /* 0.346037122 */, + /* 232 */ 0x05918e15 | (12 << 27) /* 0.348035890 */, + /* 233 */ 0x0599c0f4 | (12 << 27) /* 0.350037532 */, + /* 234 */ 0x05a1f6d5 | (12 << 27) /* 0.352042040 */, + /* 235 */ 0x05aa2fb5 | (12 << 27) /* 0.354049405 */, + /* 236 */ 0x05b26b92 | (12 << 27) /* 0.356059619 */, + /* 237 */ 0x05baaa69 | (12 << 27) /* 0.358072674 */, + /* 238 */ 0x05c2ec39 | (12 << 27) /* 0.360088563 */, + /* 239 */ 0x05cb3100 | (12 << 27) /* 0.362107278 */, + + /* 240 */ 0x05d378bb | (12 << 27) /* 0.364128809 */, + /* 241 */ 0x05dbc368 | (12 << 27) /* 0.366153151 */, + /* 242 */ 0x05e41105 | (12 << 27) /* 0.368180294 */, + /* 243 */ 0x05ec6190 | (12 << 27) /* 0.370210231 */, + /* 244 */ 0x05f4b507 | (12 << 27) /* 0.372242955 */, + /* 245 */ 0x05fd0b68 | (12 << 27) /* 0.374278458 */, + /* 246 */ 0x060564b1 | (12 << 27) /* 0.376316732 */, + /* 247 */ 0x060dc0e0 | (12 << 27) /* 0.378357769 */, + /* 248 */ 0x06161ff3 | (12 << 27) /* 0.380401563 */, + /* 249 */ 0x061e81e8 | (12 << 27) /* 0.382448106 */, + /* 250 */ 0x0626e6bc | (12 << 27) /* 0.384497391 */, + /* 251 */ 0x062f4e6f | (12 << 27) /* 0.386549409 */, + /* 252 */ 0x0637b8fd | (12 << 27) /* 0.388604155 */, + /* 253 */ 0x06402666 | (12 << 27) /* 0.390661620 */, + /* 254 */ 0x064896a7 | (12 << 27) /* 0.392721798 */, + /* 255 */ 0x065109be | (12 << 27) /* 0.394784681 */, + + /* 256 */ 0x06597fa9 | (12 << 27) /* 0.396850263 */, + /* 257 */ 0x0661f867 | (12 << 27) /* 0.398918536 */, + /* 258 */ 0x066a73f5 | (12 << 27) /* 0.400989493 */, + /* 259 */ 0x0672f252 | (12 << 27) /* 0.403063128 */, + /* 260 */ 0x067b737c | (12 << 27) /* 0.405139433 */, + /* 261 */ 0x0683f771 | (12 << 27) /* 0.407218402 */, + /* 262 */ 0x068c7e2f | (12 << 27) /* 0.409300027 */, + /* 263 */ 0x069507b5 | (12 << 27) /* 0.411384303 */, + /* 264 */ 0x069d9400 | (12 << 27) /* 0.413471222 */, + /* 265 */ 0x06a6230f | (12 << 27) /* 0.415560778 */, + /* 266 */ 0x06aeb4e0 | (12 << 27) /* 0.417652964 */, + /* 267 */ 0x06b74971 | (12 << 27) /* 0.419747773 */, + /* 268 */ 0x06bfe0c0 | (12 << 27) /* 0.421845199 */, + /* 269 */ 0x06c87acc | (12 << 27) /* 0.423945235 */, + /* 270 */ 0x06d11794 | (12 << 27) /* 0.426047876 */, + /* 271 */ 0x06d9b714 | (12 << 27) /* 0.428153114 */, + + /* 272 */ 0x06e2594c | (12 << 27) /* 0.430260942 */, + /* 273 */ 0x06eafe3a | (12 << 27) /* 0.432371356 */, + /* 274 */ 0x06f3a5dc | (12 << 27) /* 0.434484348 */, + /* 275 */ 0x06fc5030 | (12 << 27) /* 0.436599912 */, + /* 276 */ 0x0704fd35 | (12 << 27) /* 0.438718042 */, + /* 277 */ 0x070dacea | (12 << 27) /* 0.440838732 */, + /* 278 */ 0x07165f4b | (12 << 27) /* 0.442961975 */, + /* 279 */ 0x071f1459 | (12 << 27) /* 0.445087765 */, + /* 280 */ 0x0727cc11 | (12 << 27) /* 0.447216097 */, + /* 281 */ 0x07308671 | (12 << 27) /* 0.449346964 */, + /* 282 */ 0x07394378 | (12 << 27) /* 0.451480360 */, + /* 283 */ 0x07420325 | (12 << 27) /* 0.453616280 */, + /* 284 */ 0x074ac575 | (12 << 27) /* 0.455754717 */, + /* 285 */ 0x07538a67 | (12 << 27) /* 0.457895665 */, + /* 286 */ 0x075c51fa | (12 << 27) /* 0.460039119 */, + /* 287 */ 0x07651c2c | (12 << 27) /* 0.462185072 */, + + /* 288 */ 0x076de8fc | (12 << 27) /* 0.464333519 */, + /* 289 */ 0x0776b867 | (12 << 27) /* 0.466484455 */, + /* 290 */ 0x077f8a6d | (12 << 27) /* 0.468637872 */, + /* 291 */ 0x07885f0b | (12 << 27) /* 0.470793767 */, + /* 292 */ 0x07913641 | (12 << 27) /* 0.472952132 */, + /* 293 */ 0x079a100c | (12 << 27) /* 0.475112962 */, + /* 294 */ 0x07a2ec6c | (12 << 27) /* 0.477276252 */, + /* 295 */ 0x07abcb5f | (12 << 27) /* 0.479441997 */, + /* 296 */ 0x07b4ace3 | (12 << 27) /* 0.481610189 */, + /* 297 */ 0x07bd90f6 | (12 << 27) /* 0.483780825 */, + /* 298 */ 0x07c67798 | (12 << 27) /* 0.485953899 */, + /* 299 */ 0x07cf60c7 | (12 << 27) /* 0.488129404 */, + /* 300 */ 0x07d84c81 | (12 << 27) /* 0.490307336 */, + /* 301 */ 0x07e13ac5 | (12 << 27) /* 0.492487690 */, + /* 302 */ 0x07ea2b92 | (12 << 27) /* 0.494670459 */, + /* 303 */ 0x07f31ee6 | (12 << 27) /* 0.496855639 */, + + /* 304 */ 0x07fc14bf | (12 << 27) /* 0.499043224 */, + /* 305 */ 0x0402868e | (13 << 27) /* 0.250616605 */, + /* 306 */ 0x040703ff | (13 << 27) /* 0.251712795 */, + /* 307 */ 0x040b82b0 | (13 << 27) /* 0.252810180 */, + /* 308 */ 0x041002a1 | (13 << 27) /* 0.253908756 */, + /* 309 */ 0x041483d1 | (13 << 27) /* 0.255008523 */, + /* 310 */ 0x04190640 | (13 << 27) /* 0.256109476 */, + /* 311 */ 0x041d89ed | (13 << 27) /* 0.257211614 */, + /* 312 */ 0x04220ed7 | (13 << 27) /* 0.258314934 */, + /* 313 */ 0x042694fe | (13 << 27) /* 0.259419433 */, + /* 314 */ 0x042b1c60 | (13 << 27) /* 0.260525110 */, + /* 315 */ 0x042fa4fe | (13 << 27) /* 0.261631960 */, + /* 316 */ 0x04342ed7 | (13 << 27) /* 0.262739982 */, + /* 317 */ 0x0438b9e9 | (13 << 27) /* 0.263849174 */, + /* 318 */ 0x043d4635 | (13 << 27) /* 0.264959533 */, + /* 319 */ 0x0441d3b9 | (13 << 27) /* 0.266071056 */, + + /* 320 */ 0x04466275 | (13 << 27) /* 0.267183742 */, + /* 321 */ 0x044af269 | (13 << 27) /* 0.268297587 */, + /* 322 */ 0x044f8393 | (13 << 27) /* 0.269412589 */, + /* 323 */ 0x045415f3 | (13 << 27) /* 0.270528746 */, + /* 324 */ 0x0458a989 | (13 << 27) /* 0.271646056 */, + /* 325 */ 0x045d3e53 | (13 << 27) /* 0.272764515 */, + /* 326 */ 0x0461d451 | (13 << 27) /* 0.273884123 */, + /* 327 */ 0x04666b83 | (13 << 27) /* 0.275004875 */, + /* 328 */ 0x046b03e7 | (13 << 27) /* 0.276126771 */, + /* 329 */ 0x046f9d7e | (13 << 27) /* 0.277249808 */, + /* 330 */ 0x04743847 | (13 << 27) /* 0.278373983 */, + /* 331 */ 0x0478d440 | (13 << 27) /* 0.279499294 */, + /* 332 */ 0x047d716a | (13 << 27) /* 0.280625739 */, + /* 333 */ 0x04820fc3 | (13 << 27) /* 0.281753315 */, + /* 334 */ 0x0486af4c | (13 << 27) /* 0.282882021 */, + /* 335 */ 0x048b5003 | (13 << 27) /* 0.284011853 */, + + /* 336 */ 0x048ff1e8 | (13 << 27) /* 0.285142811 */, + /* 337 */ 0x049494fb | (13 << 27) /* 0.286274891 */, + /* 338 */ 0x0499393a | (13 << 27) /* 0.287408091 */, + /* 339 */ 0x049ddea5 | (13 << 27) /* 0.288542409 */, + /* 340 */ 0x04a2853c | (13 << 27) /* 0.289677844 */, + /* 341 */ 0x04a72cfe | (13 << 27) /* 0.290814392 */, + /* 342 */ 0x04abd5ea | (13 << 27) /* 0.291952051 */, + /* 343 */ 0x04b08000 | (13 << 27) /* 0.293090820 */, + /* 344 */ 0x04b52b3f | (13 << 27) /* 0.294230696 */, + /* 345 */ 0x04b9d7a7 | (13 << 27) /* 0.295371678 */, + /* 346 */ 0x04be8537 | (13 << 27) /* 0.296513762 */, + /* 347 */ 0x04c333ee | (13 << 27) /* 0.297656947 */, + /* 348 */ 0x04c7e3cc | (13 << 27) /* 0.298801231 */, + /* 349 */ 0x04cc94d1 | (13 << 27) /* 0.299946611 */, + /* 350 */ 0x04d146fb | (13 << 27) /* 0.301093085 */, + /* 351 */ 0x04d5fa4b | (13 << 27) /* 0.302240653 */, + + /* 352 */ 0x04daaec0 | (13 << 27) /* 0.303389310 */, + /* 353 */ 0x04df6458 | (13 << 27) /* 0.304539056 */, + /* 354 */ 0x04e41b14 | (13 << 27) /* 0.305689888 */, + /* 355 */ 0x04e8d2f3 | (13 << 27) /* 0.306841804 */, + /* 356 */ 0x04ed8bf5 | (13 << 27) /* 0.307994802 */, + /* 357 */ 0x04f24618 | (13 << 27) /* 0.309148880 */, + /* 358 */ 0x04f7015d | (13 << 27) /* 0.310304037 */, + /* 359 */ 0x04fbbdc3 | (13 << 27) /* 0.311460269 */, + /* 360 */ 0x05007b49 | (13 << 27) /* 0.312617576 */, + /* 361 */ 0x050539ef | (13 << 27) /* 0.313775954 */, + /* 362 */ 0x0509f9b4 | (13 << 27) /* 0.314935403 */, + /* 363 */ 0x050eba98 | (13 << 27) /* 0.316095920 */, + /* 364 */ 0x05137c9a | (13 << 27) /* 0.317257503 */, + /* 365 */ 0x05183fba | (13 << 27) /* 0.318420150 */, + /* 366 */ 0x051d03f7 | (13 << 27) /* 0.319583859 */, + /* 367 */ 0x0521c950 | (13 << 27) /* 0.320748629 */, + + /* 368 */ 0x05268fc6 | (13 << 27) /* 0.321914457 */, + /* 369 */ 0x052b5757 | (13 << 27) /* 0.323081342 */, + /* 370 */ 0x05302003 | (13 << 27) /* 0.324249281 */, + /* 371 */ 0x0534e9ca | (13 << 27) /* 0.325418273 */, + /* 372 */ 0x0539b4ab | (13 << 27) /* 0.326588316 */, + /* 373 */ 0x053e80a6 | (13 << 27) /* 0.327759407 */, + /* 374 */ 0x05434db9 | (13 << 27) /* 0.328931546 */, + /* 375 */ 0x05481be5 | (13 << 27) /* 0.330104730 */, + /* 376 */ 0x054ceb2a | (13 << 27) /* 0.331278957 */, + /* 377 */ 0x0551bb85 | (13 << 27) /* 0.332454225 */, + /* 378 */ 0x05568cf8 | (13 << 27) /* 0.333630533 */, + /* 379 */ 0x055b5f81 | (13 << 27) /* 0.334807879 */, + /* 380 */ 0x05603321 | (13 << 27) /* 0.335986261 */, + /* 381 */ 0x056507d6 | (13 << 27) /* 0.337165677 */, + /* 382 */ 0x0569dda0 | (13 << 27) /* 0.338346125 */, + /* 383 */ 0x056eb47f | (13 << 27) /* 0.339527604 */, + + /* 384 */ 0x05738c72 | (13 << 27) /* 0.340710111 */, + /* 385 */ 0x05786578 | (13 << 27) /* 0.341893646 */, + /* 386 */ 0x057d3f92 | (13 << 27) /* 0.343078205 */, + /* 387 */ 0x05821abf | (13 << 27) /* 0.344263788 */, + /* 388 */ 0x0586f6fd | (13 << 27) /* 0.345450393 */, + /* 389 */ 0x058bd44e | (13 << 27) /* 0.346638017 */, + /* 390 */ 0x0590b2b0 | (13 << 27) /* 0.347826659 */, + /* 391 */ 0x05959222 | (13 << 27) /* 0.349016318 */, + /* 392 */ 0x059a72a5 | (13 << 27) /* 0.350206992 */, + /* 393 */ 0x059f5438 | (13 << 27) /* 0.351398678 */, + /* 394 */ 0x05a436da | (13 << 27) /* 0.352591376 */, + /* 395 */ 0x05a91a8c | (13 << 27) /* 0.353785083 */, + /* 396 */ 0x05adff4c | (13 << 27) /* 0.354979798 */, + /* 397 */ 0x05b2e51a | (13 << 27) /* 0.356175519 */, + /* 398 */ 0x05b7cbf5 | (13 << 27) /* 0.357372244 */, + /* 399 */ 0x05bcb3de | (13 << 27) /* 0.358569972 */, + + /* 400 */ 0x05c19cd3 | (13 << 27) /* 0.359768701 */, + /* 401 */ 0x05c686d5 | (13 << 27) /* 0.360968429 */, + /* 402 */ 0x05cb71e2 | (13 << 27) /* 0.362169156 */, + /* 403 */ 0x05d05dfb | (13 << 27) /* 0.363370878 */, + /* 404 */ 0x05d54b1f | (13 << 27) /* 0.364573594 */, + /* 405 */ 0x05da394d | (13 << 27) /* 0.365777304 */, + /* 406 */ 0x05df2885 | (13 << 27) /* 0.366982004 */, + /* 407 */ 0x05e418c7 | (13 << 27) /* 0.368187694 */, + /* 408 */ 0x05e90a12 | (13 << 27) /* 0.369394372 */, + /* 409 */ 0x05edfc66 | (13 << 27) /* 0.370602036 */, + /* 410 */ 0x05f2efc2 | (13 << 27) /* 0.371810684 */, + /* 411 */ 0x05f7e426 | (13 << 27) /* 0.373020316 */, + /* 412 */ 0x05fcd992 | (13 << 27) /* 0.374230929 */, + /* 413 */ 0x0601d004 | (13 << 27) /* 0.375442522 */, + /* 414 */ 0x0606c77d | (13 << 27) /* 0.376655093 */, + /* 415 */ 0x060bbffd | (13 << 27) /* 0.377868641 */, + + /* 416 */ 0x0610b982 | (13 << 27) /* 0.379083164 */, + /* 417 */ 0x0615b40c | (13 << 27) /* 0.380298661 */, + /* 418 */ 0x061aaf9c | (13 << 27) /* 0.381515130 */, + /* 419 */ 0x061fac2f | (13 << 27) /* 0.382732569 */, + /* 420 */ 0x0624a9c7 | (13 << 27) /* 0.383950977 */, + /* 421 */ 0x0629a863 | (13 << 27) /* 0.385170352 */, + /* 422 */ 0x062ea802 | (13 << 27) /* 0.386390694 */, + /* 423 */ 0x0633a8a3 | (13 << 27) /* 0.387611999 */, + /* 424 */ 0x0638aa48 | (13 << 27) /* 0.388834268 */, + /* 425 */ 0x063dacee | (13 << 27) /* 0.390057497 */, + /* 426 */ 0x0642b096 | (13 << 27) /* 0.391281687 */, + /* 427 */ 0x0647b53f | (13 << 27) /* 0.392506834 */, + /* 428 */ 0x064cbae9 | (13 << 27) /* 0.393732939 */, + /* 429 */ 0x0651c193 | (13 << 27) /* 0.394959999 */, + /* 430 */ 0x0656c93d | (13 << 27) /* 0.396188012 */, + /* 431 */ 0x065bd1e7 | (13 << 27) /* 0.397416978 */, + + /* 432 */ 0x0660db91 | (13 << 27) /* 0.398646895 */, + /* 433 */ 0x0665e639 | (13 << 27) /* 0.399877761 */, + /* 434 */ 0x066af1df | (13 << 27) /* 0.401109575 */, + /* 435 */ 0x066ffe84 | (13 << 27) /* 0.402342335 */, + /* 436 */ 0x06750c26 | (13 << 27) /* 0.403576041 */, + /* 437 */ 0x067a1ac6 | (13 << 27) /* 0.404810690 */, + /* 438 */ 0x067f2a62 | (13 << 27) /* 0.406046281 */, + /* 439 */ 0x06843afb | (13 << 27) /* 0.407282813 */, + /* 440 */ 0x06894c90 | (13 << 27) /* 0.408520284 */, + /* 441 */ 0x068e5f21 | (13 << 27) /* 0.409758693 */, + /* 442 */ 0x069372ae | (13 << 27) /* 0.410998038 */, + /* 443 */ 0x06988735 | (13 << 27) /* 0.412238319 */, + /* 444 */ 0x069d9cb7 | (13 << 27) /* 0.413479532 */, + /* 445 */ 0x06a2b333 | (13 << 27) /* 0.414721679 */, + /* 446 */ 0x06a7caa9 | (13 << 27) /* 0.415964756 */, + /* 447 */ 0x06ace318 | (13 << 27) /* 0.417208762 */, + + /* 448 */ 0x06b1fc81 | (13 << 27) /* 0.418453696 */, + /* 449 */ 0x06b716e2 | (13 << 27) /* 0.419699557 */, + /* 450 */ 0x06bc323b | (13 << 27) /* 0.420946343 */, + /* 451 */ 0x06c14e8d | (13 << 27) /* 0.422194054 */, + /* 452 */ 0x06c66bd6 | (13 << 27) /* 0.423442686 */, + /* 453 */ 0x06cb8a17 | (13 << 27) /* 0.424692240 */, + /* 454 */ 0x06d0a94e | (13 << 27) /* 0.425942714 */, + /* 455 */ 0x06d5c97c | (13 << 27) /* 0.427194106 */, + /* 456 */ 0x06daeaa1 | (13 << 27) /* 0.428446415 */, + /* 457 */ 0x06e00cbb | (13 << 27) /* 0.429699640 */, + /* 458 */ 0x06e52fca | (13 << 27) /* 0.430953779 */, + /* 459 */ 0x06ea53cf | (13 << 27) /* 0.432208832 */, + /* 460 */ 0x06ef78c8 | (13 << 27) /* 0.433464796 */, + /* 461 */ 0x06f49eb6 | (13 << 27) /* 0.434721671 */, + /* 462 */ 0x06f9c597 | (13 << 27) /* 0.435979455 */, + /* 463 */ 0x06feed6d | (13 << 27) /* 0.437238146 */, + + /* 464 */ 0x07041636 | (13 << 27) /* 0.438497744 */, + /* 465 */ 0x07093ff2 | (13 << 27) /* 0.439758248 */, + /* 466 */ 0x070e6aa0 | (13 << 27) /* 0.441019655 */, + /* 467 */ 0x07139641 | (13 << 27) /* 0.442281965 */, + /* 468 */ 0x0718c2d3 | (13 << 27) /* 0.443545176 */, + /* 469 */ 0x071df058 | (13 << 27) /* 0.444809288 */, + /* 470 */ 0x07231ecd | (13 << 27) /* 0.446074298 */, + /* 471 */ 0x07284e34 | (13 << 27) /* 0.447340205 */, + /* 472 */ 0x072d7e8b | (13 << 27) /* 0.448607009 */, + /* 473 */ 0x0732afd2 | (13 << 27) /* 0.449874708 */, + /* 474 */ 0x0737e209 | (13 << 27) /* 0.451143300 */, + /* 475 */ 0x073d1530 | (13 << 27) /* 0.452412785 */, + /* 476 */ 0x07424946 | (13 << 27) /* 0.453683161 */, + /* 477 */ 0x07477e4b | (13 << 27) /* 0.454954427 */, + /* 478 */ 0x074cb43e | (13 << 27) /* 0.456226581 */, + /* 479 */ 0x0751eb20 | (13 << 27) /* 0.457499623 */, + + /* 480 */ 0x075722ef | (13 << 27) /* 0.458773552 */, + /* 481 */ 0x075c5bac | (13 << 27) /* 0.460048365 */, + /* 482 */ 0x07619557 | (13 << 27) /* 0.461324062 */, + /* 483 */ 0x0766cfee | (13 << 27) /* 0.462600642 */, + /* 484 */ 0x076c0b72 | (13 << 27) /* 0.463878102 */, + /* 485 */ 0x077147e2 | (13 << 27) /* 0.465156443 */, + /* 486 */ 0x0776853e | (13 << 27) /* 0.466435663 */, + /* 487 */ 0x077bc385 | (13 << 27) /* 0.467715761 */, + /* 488 */ 0x078102b8 | (13 << 27) /* 0.468996735 */, + /* 489 */ 0x078642d6 | (13 << 27) /* 0.470278584 */, + /* 490 */ 0x078b83de | (13 << 27) /* 0.471561307 */, + /* 491 */ 0x0790c5d1 | (13 << 27) /* 0.472844904 */, + /* 492 */ 0x079608ae | (13 << 27) /* 0.474129372 */, + /* 493 */ 0x079b4c74 | (13 << 27) /* 0.475414710 */, + /* 494 */ 0x07a09124 | (13 << 27) /* 0.476700918 */, + /* 495 */ 0x07a5d6bd | (13 << 27) /* 0.477987994 */, + + /* 496 */ 0x07ab1d3e | (13 << 27) /* 0.479275937 */, + /* 497 */ 0x07b064a8 | (13 << 27) /* 0.480564746 */, + /* 498 */ 0x07b5acfb | (13 << 27) /* 0.481854420 */, + /* 499 */ 0x07baf635 | (13 << 27) /* 0.483144957 */, + /* 500 */ 0x07c04056 | (13 << 27) /* 0.484436356 */, + /* 501 */ 0x07c58b5f | (13 << 27) /* 0.485728617 */, + /* 502 */ 0x07cad74e | (13 << 27) /* 0.487021738 */, + /* 503 */ 0x07d02424 | (13 << 27) /* 0.488315717 */, + /* 504 */ 0x07d571e0 | (13 << 27) /* 0.489610555 */, + /* 505 */ 0x07dac083 | (13 << 27) /* 0.490906249 */, + /* 506 */ 0x07e0100a | (13 << 27) /* 0.492202799 */, + /* 507 */ 0x07e56078 | (13 << 27) /* 0.493500203 */, + /* 508 */ 0x07eab1ca | (13 << 27) /* 0.494798460 */, + /* 509 */ 0x07f00401 | (13 << 27) /* 0.496097570 */, + /* 510 */ 0x07f5571d | (13 << 27) /* 0.497397530 */, + /* 511 */ 0x07faab1c | (13 << 27) /* 0.498698341 */, + + /* 512 */ 0x04000000 | (14 << 27) /* 0.250000000 */, + /* 513 */ 0x0402aae3 | (14 << 27) /* 0.250651254 */, + /* 514 */ 0x04055638 | (14 << 27) /* 0.251302930 */, + /* 515 */ 0x040801ff | (14 << 27) /* 0.251955030 */, + /* 516 */ 0x040aae37 | (14 << 27) /* 0.252607552 */, + /* 517 */ 0x040d5ae0 | (14 << 27) /* 0.253260495 */, + /* 518 */ 0x041007fa | (14 << 27) /* 0.253913860 */, + /* 519 */ 0x0412b586 | (14 << 27) /* 0.254567645 */, + /* 520 */ 0x04156381 | (14 << 27) /* 0.255221850 */, + /* 521 */ 0x041811ee | (14 << 27) /* 0.255876475 */, + /* 522 */ 0x041ac0cb | (14 << 27) /* 0.256531518 */, + /* 523 */ 0x041d7018 | (14 << 27) /* 0.257186980 */, + /* 524 */ 0x04201fd5 | (14 << 27) /* 0.257842860 */, + /* 525 */ 0x0422d003 | (14 << 27) /* 0.258499157 */, + /* 526 */ 0x042580a0 | (14 << 27) /* 0.259155872 */, + /* 527 */ 0x042831ad | (14 << 27) /* 0.259813002 */, + + /* 528 */ 0x042ae32a | (14 << 27) /* 0.260470548 */, + /* 529 */ 0x042d9516 | (14 << 27) /* 0.261128510 */, + /* 530 */ 0x04304772 | (14 << 27) /* 0.261786886 */, + /* 531 */ 0x0432fa3d | (14 << 27) /* 0.262445676 */, + /* 532 */ 0x0435ad76 | (14 << 27) /* 0.263104880 */, + /* 533 */ 0x0438611f | (14 << 27) /* 0.263764497 */, + /* 534 */ 0x043b1536 | (14 << 27) /* 0.264424527 */, + /* 535 */ 0x043dc9bc | (14 << 27) /* 0.265084969 */, + /* 536 */ 0x04407eb1 | (14 << 27) /* 0.265745823 */, + /* 537 */ 0x04433414 | (14 << 27) /* 0.266407088 */, + /* 538 */ 0x0445e9e5 | (14 << 27) /* 0.267068763 */, + /* 539 */ 0x0448a024 | (14 << 27) /* 0.267730848 */, + /* 540 */ 0x044b56d1 | (14 << 27) /* 0.268393343 */, + /* 541 */ 0x044e0dec | (14 << 27) /* 0.269056248 */, + /* 542 */ 0x0450c575 | (14 << 27) /* 0.269719560 */, + /* 543 */ 0x04537d6b | (14 << 27) /* 0.270383281 */, + + /* 544 */ 0x045635cf | (14 << 27) /* 0.271047409 */, + /* 545 */ 0x0458ee9f | (14 << 27) /* 0.271711944 */, + /* 546 */ 0x045ba7dd | (14 << 27) /* 0.272376886 */, + /* 547 */ 0x045e6188 | (14 << 27) /* 0.273042234 */, + /* 548 */ 0x04611ba0 | (14 << 27) /* 0.273707988 */, + /* 549 */ 0x0463d625 | (14 << 27) /* 0.274374147 */, + /* 550 */ 0x04669116 | (14 << 27) /* 0.275040710 */, + /* 551 */ 0x04694c74 | (14 << 27) /* 0.275707677 */, + /* 552 */ 0x046c083e | (14 << 27) /* 0.276375048 */, + /* 553 */ 0x046ec474 | (14 << 27) /* 0.277042822 */, + /* 554 */ 0x04718116 | (14 << 27) /* 0.277710999 */, + /* 555 */ 0x04743e25 | (14 << 27) /* 0.278379578 */, + /* 556 */ 0x0476fb9f | (14 << 27) /* 0.279048558 */, + /* 557 */ 0x0479b984 | (14 << 27) /* 0.279717940 */, + /* 558 */ 0x047c77d6 | (14 << 27) /* 0.280387722 */, + /* 559 */ 0x047f3693 | (14 << 27) /* 0.281057905 */, + + /* 560 */ 0x0481f5bb | (14 << 27) /* 0.281728487 */, + /* 561 */ 0x0484b54e | (14 << 27) /* 0.282399469 */, + /* 562 */ 0x0487754c | (14 << 27) /* 0.283070849 */, + /* 563 */ 0x048a35b6 | (14 << 27) /* 0.283742628 */, + /* 564 */ 0x048cf68a | (14 << 27) /* 0.284414805 */, + /* 565 */ 0x048fb7c8 | (14 << 27) /* 0.285087379 */, + /* 566 */ 0x04927972 | (14 << 27) /* 0.285760350 */, + /* 567 */ 0x04953b85 | (14 << 27) /* 0.286433717 */, + /* 568 */ 0x0497fe03 | (14 << 27) /* 0.287107481 */, + /* 569 */ 0x049ac0eb | (14 << 27) /* 0.287781640 */, + /* 570 */ 0x049d843e | (14 << 27) /* 0.288456194 */, + /* 571 */ 0x04a047fa | (14 << 27) /* 0.289131142 */, + /* 572 */ 0x04a30c20 | (14 << 27) /* 0.289806485 */, + /* 573 */ 0x04a5d0af | (14 << 27) /* 0.290482221 */, + /* 574 */ 0x04a895a8 | (14 << 27) /* 0.291158351 */, + /* 575 */ 0x04ab5b0b | (14 << 27) /* 0.291834873 */, + + /* 576 */ 0x04ae20d7 | (14 << 27) /* 0.292511788 */, + /* 577 */ 0x04b0e70c | (14 << 27) /* 0.293189094 */, + /* 578 */ 0x04b3adaa | (14 << 27) /* 0.293866792 */, + /* 579 */ 0x04b674b1 | (14 << 27) /* 0.294544881 */, + /* 580 */ 0x04b93c21 | (14 << 27) /* 0.295223360 */, + /* 581 */ 0x04bc03fa | (14 << 27) /* 0.295902229 */, + /* 582 */ 0x04becc3b | (14 << 27) /* 0.296581488 */, + /* 583 */ 0x04c194e4 | (14 << 27) /* 0.297261136 */, + /* 584 */ 0x04c45df6 | (14 << 27) /* 0.297941173 */, + /* 585 */ 0x04c72771 | (14 << 27) /* 0.298621598 */, + /* 586 */ 0x04c9f153 | (14 << 27) /* 0.299302411 */, + /* 587 */ 0x04ccbb9d | (14 << 27) /* 0.299983611 */, + /* 588 */ 0x04cf864f | (14 << 27) /* 0.300665198 */, + /* 589 */ 0x04d25169 | (14 << 27) /* 0.301347172 */, + /* 590 */ 0x04d51ceb | (14 << 27) /* 0.302029532 */, + /* 591 */ 0x04d7e8d4 | (14 << 27) /* 0.302712277 */, + + /* 592 */ 0x04dab524 | (14 << 27) /* 0.303395408 */, + /* 593 */ 0x04dd81dc | (14 << 27) /* 0.304078923 */, + /* 594 */ 0x04e04efb | (14 << 27) /* 0.304762823 */, + /* 595 */ 0x04e31c81 | (14 << 27) /* 0.305447106 */, + /* 596 */ 0x04e5ea6e | (14 << 27) /* 0.306131773 */, + /* 597 */ 0x04e8b8c2 | (14 << 27) /* 0.306816823 */, + /* 598 */ 0x04eb877c | (14 << 27) /* 0.307502256 */, + /* 599 */ 0x04ee569d | (14 << 27) /* 0.308188071 */, + /* 600 */ 0x04f12624 | (14 << 27) /* 0.308874267 */, + /* 601 */ 0x04f3f612 | (14 << 27) /* 0.309560845 */, + /* 602 */ 0x04f6c666 | (14 << 27) /* 0.310247804 */, + /* 603 */ 0x04f99721 | (14 << 27) /* 0.310935143 */, + /* 604 */ 0x04fc6841 | (14 << 27) /* 0.311622862 */, + /* 605 */ 0x04ff39c7 | (14 << 27) /* 0.312310961 */, + /* 606 */ 0x05020bb3 | (14 << 27) /* 0.312999439 */, + /* 607 */ 0x0504de05 | (14 << 27) /* 0.313688296 */, + + /* 608 */ 0x0507b0bc | (14 << 27) /* 0.314377532 */, + /* 609 */ 0x050a83d8 | (14 << 27) /* 0.315067145 */, + /* 610 */ 0x050d575b | (14 << 27) /* 0.315757136 */, + /* 611 */ 0x05102b42 | (14 << 27) /* 0.316447504 */, + /* 612 */ 0x0512ff8e | (14 << 27) /* 0.317138249 */, + /* 613 */ 0x0515d440 | (14 << 27) /* 0.317829370 */, + /* 614 */ 0x0518a956 | (14 << 27) /* 0.318520867 */, + /* 615 */ 0x051b7ed1 | (14 << 27) /* 0.319212739 */, + /* 616 */ 0x051e54b1 | (14 << 27) /* 0.319904987 */, + /* 617 */ 0x05212af5 | (14 << 27) /* 0.320597609 */, + /* 618 */ 0x0524019e | (14 << 27) /* 0.321290606 */, + /* 619 */ 0x0526d8ab | (14 << 27) /* 0.321983976 */, + /* 620 */ 0x0529b01d | (14 << 27) /* 0.322677720 */, + /* 621 */ 0x052c87f2 | (14 << 27) /* 0.323371837 */, + /* 622 */ 0x052f602c | (14 << 27) /* 0.324066327 */, + /* 623 */ 0x053238ca | (14 << 27) /* 0.324761189 */, + + /* 624 */ 0x053511cb | (14 << 27) /* 0.325456423 */, + /* 625 */ 0x0537eb30 | (14 << 27) /* 0.326152028 */, + /* 626 */ 0x053ac4f9 | (14 << 27) /* 0.326848005 */, + /* 627 */ 0x053d9f25 | (14 << 27) /* 0.327544352 */, + /* 628 */ 0x054079b5 | (14 << 27) /* 0.328241070 */, + /* 629 */ 0x054354a8 | (14 << 27) /* 0.328938157 */, + /* 630 */ 0x05462ffe | (14 << 27) /* 0.329635614 */, + /* 631 */ 0x05490bb7 | (14 << 27) /* 0.330333440 */, + /* 632 */ 0x054be7d4 | (14 << 27) /* 0.331031635 */, + /* 633 */ 0x054ec453 | (14 << 27) /* 0.331730198 */, + /* 634 */ 0x0551a134 | (14 << 27) /* 0.332429129 */, + /* 635 */ 0x05547e79 | (14 << 27) /* 0.333128427 */, + /* 636 */ 0x05575c20 | (14 << 27) /* 0.333828093 */, + /* 637 */ 0x055a3a2a | (14 << 27) /* 0.334528126 */, + /* 638 */ 0x055d1896 | (14 << 27) /* 0.335228525 */, + /* 639 */ 0x055ff764 | (14 << 27) /* 0.335929290 */, + + /* 640 */ 0x0562d694 | (14 << 27) /* 0.336630420 */, + /* 641 */ 0x0565b627 | (14 << 27) /* 0.337331916 */, + /* 642 */ 0x0568961b | (14 << 27) /* 0.338033777 */, + /* 643 */ 0x056b7671 | (14 << 27) /* 0.338736002 */, + /* 644 */ 0x056e5729 | (14 << 27) /* 0.339438592 */, + /* 645 */ 0x05713843 | (14 << 27) /* 0.340141545 */, + /* 646 */ 0x057419be | (14 << 27) /* 0.340844862 */, + /* 647 */ 0x0576fb9a | (14 << 27) /* 0.341548541 */, + /* 648 */ 0x0579ddd8 | (14 << 27) /* 0.342252584 */, + /* 649 */ 0x057cc077 | (14 << 27) /* 0.342956988 */, + /* 650 */ 0x057fa378 | (14 << 27) /* 0.343661754 */, + /* 651 */ 0x058286d9 | (14 << 27) /* 0.344366882 */, + /* 652 */ 0x05856a9b | (14 << 27) /* 0.345072371 */, + /* 653 */ 0x05884ebe | (14 << 27) /* 0.345778221 */, + /* 654 */ 0x058b3342 | (14 << 27) /* 0.346484431 */, + /* 655 */ 0x058e1827 | (14 << 27) /* 0.347191002 */, + + /* 656 */ 0x0590fd6c | (14 << 27) /* 0.347897931 */, + /* 657 */ 0x0593e311 | (14 << 27) /* 0.348605221 */, + /* 658 */ 0x0596c917 | (14 << 27) /* 0.349312869 */, + /* 659 */ 0x0599af7d | (14 << 27) /* 0.350020876 */, + /* 660 */ 0x059c9643 | (14 << 27) /* 0.350729240 */, + /* 661 */ 0x059f7d6a | (14 << 27) /* 0.351437963 */, + /* 662 */ 0x05a264f0 | (14 << 27) /* 0.352147044 */, + /* 663 */ 0x05a54cd6 | (14 << 27) /* 0.352856481 */, + /* 664 */ 0x05a8351c | (14 << 27) /* 0.353566275 */, + /* 665 */ 0x05ab1dc2 | (14 << 27) /* 0.354276426 */, + /* 666 */ 0x05ae06c7 | (14 << 27) /* 0.354986932 */, + /* 667 */ 0x05b0f02b | (14 << 27) /* 0.355697795 */, + /* 668 */ 0x05b3d9f0 | (14 << 27) /* 0.356409012 */, + /* 669 */ 0x05b6c413 | (14 << 27) /* 0.357120585 */, + /* 670 */ 0x05b9ae95 | (14 << 27) /* 0.357832512 */, + /* 671 */ 0x05bc9977 | (14 << 27) /* 0.358544794 */, + + /* 672 */ 0x05bf84b8 | (14 << 27) /* 0.359257429 */, + /* 673 */ 0x05c27057 | (14 << 27) /* 0.359970419 */, + /* 674 */ 0x05c55c56 | (14 << 27) /* 0.360683761 */, + /* 675 */ 0x05c848b3 | (14 << 27) /* 0.361397456 */, + /* 676 */ 0x05cb356e | (14 << 27) /* 0.362111504 */, + /* 677 */ 0x05ce2289 | (14 << 27) /* 0.362825904 */, + /* 678 */ 0x05d11001 | (14 << 27) /* 0.363540655 */, + /* 679 */ 0x05d3fdd8 | (14 << 27) /* 0.364255759 */, + /* 680 */ 0x05d6ec0e | (14 << 27) /* 0.364971213 */, + /* 681 */ 0x05d9daa1 | (14 << 27) /* 0.365687018 */, + /* 682 */ 0x05dcc993 | (14 << 27) /* 0.366403174 */, + /* 683 */ 0x05dfb8e2 | (14 << 27) /* 0.367119680 */, + /* 684 */ 0x05e2a890 | (14 << 27) /* 0.367836535 */, + /* 685 */ 0x05e5989b | (14 << 27) /* 0.368553740 */, + /* 686 */ 0x05e88904 | (14 << 27) /* 0.369271294 */, + /* 687 */ 0x05eb79cb | (14 << 27) /* 0.369989197 */, + + /* 688 */ 0x05ee6aef | (14 << 27) /* 0.370707448 */, + /* 689 */ 0x05f15c70 | (14 << 27) /* 0.371426047 */, + /* 690 */ 0x05f44e4f | (14 << 27) /* 0.372144994 */, + /* 691 */ 0x05f7408b | (14 << 27) /* 0.372864289 */, + /* 692 */ 0x05fa3324 | (14 << 27) /* 0.373583930 */, + /* 693 */ 0x05fd261b | (14 << 27) /* 0.374303918 */, + /* 694 */ 0x0600196e | (14 << 27) /* 0.375024253 */, + /* 695 */ 0x06030d1e | (14 << 27) /* 0.375744934 */, + /* 696 */ 0x0606012b | (14 << 27) /* 0.376465960 */, + /* 697 */ 0x0608f595 | (14 << 27) /* 0.377187332 */, + /* 698 */ 0x060bea5c | (14 << 27) /* 0.377909049 */, + /* 699 */ 0x060edf7f | (14 << 27) /* 0.378631110 */, + /* 700 */ 0x0611d4fe | (14 << 27) /* 0.379353516 */, + /* 701 */ 0x0614cada | (14 << 27) /* 0.380076266 */, + /* 702 */ 0x0617c112 | (14 << 27) /* 0.380799360 */, + /* 703 */ 0x061ab7a6 | (14 << 27) /* 0.381522798 */, + + /* 704 */ 0x061dae96 | (14 << 27) /* 0.382246578 */, + /* 705 */ 0x0620a5e3 | (14 << 27) /* 0.382970701 */, + /* 706 */ 0x06239d8b | (14 << 27) /* 0.383695167 */, + /* 707 */ 0x0626958f | (14 << 27) /* 0.384419975 */, + /* 708 */ 0x06298def | (14 << 27) /* 0.385145124 */, + /* 709 */ 0x062c86aa | (14 << 27) /* 0.385870615 */, + /* 710 */ 0x062f7fc1 | (14 << 27) /* 0.386596448 */, + /* 711 */ 0x06327934 | (14 << 27) /* 0.387322621 */, + /* 712 */ 0x06357302 | (14 << 27) /* 0.388049134 */, + /* 713 */ 0x06386d2b | (14 << 27) /* 0.388775988 */, + /* 714 */ 0x063b67b0 | (14 << 27) /* 0.389503182 */, + /* 715 */ 0x063e6290 | (14 << 27) /* 0.390230715 */, + /* 716 */ 0x06415dcb | (14 << 27) /* 0.390958588 */, + /* 717 */ 0x06445960 | (14 << 27) /* 0.391686799 */, + /* 718 */ 0x06475551 | (14 << 27) /* 0.392415349 */, + /* 719 */ 0x064a519c | (14 << 27) /* 0.393144238 */, + + /* 720 */ 0x064d4e43 | (14 << 27) /* 0.393873464 */, + /* 721 */ 0x06504b44 | (14 << 27) /* 0.394603028 */, + /* 722 */ 0x0653489f | (14 << 27) /* 0.395332930 */, + /* 723 */ 0x06564655 | (14 << 27) /* 0.396063168 */, + /* 724 */ 0x06594465 | (14 << 27) /* 0.396793743 */, + /* 725 */ 0x065c42d0 | (14 << 27) /* 0.397524655 */, + /* 726 */ 0x065f4195 | (14 << 27) /* 0.398255903 */, + /* 727 */ 0x066240b4 | (14 << 27) /* 0.398987487 */, + /* 728 */ 0x0665402d | (14 << 27) /* 0.399719406 */, + /* 729 */ 0x06684000 | (14 << 27) /* 0.400451660 */, + /* 730 */ 0x066b402d | (14 << 27) /* 0.401184249 */, + /* 731 */ 0x066e40b3 | (14 << 27) /* 0.401917173 */, + /* 732 */ 0x06714194 | (14 << 27) /* 0.402650431 */, + /* 733 */ 0x067442ce | (14 << 27) /* 0.403384024 */, + /* 734 */ 0x06774462 | (14 << 27) /* 0.404117949 */, + /* 735 */ 0x067a464f | (14 << 27) /* 0.404852209 */, + + /* 736 */ 0x067d4896 | (14 << 27) /* 0.405586801 */, + /* 737 */ 0x06804b36 | (14 << 27) /* 0.406321726 */, + /* 738 */ 0x06834e2f | (14 << 27) /* 0.407056983 */, + /* 739 */ 0x06865181 | (14 << 27) /* 0.407792573 */, + /* 740 */ 0x0689552c | (14 << 27) /* 0.408528495 */, + /* 741 */ 0x068c5931 | (14 << 27) /* 0.409264748 */, + /* 742 */ 0x068f5d8e | (14 << 27) /* 0.410001332 */, + /* 743 */ 0x06926245 | (14 << 27) /* 0.410738247 */, + /* 744 */ 0x06956753 | (14 << 27) /* 0.411475493 */, + /* 745 */ 0x06986cbb | (14 << 27) /* 0.412213070 */, + /* 746 */ 0x069b727b | (14 << 27) /* 0.412950976 */, + /* 747 */ 0x069e7894 | (14 << 27) /* 0.413689213 */, + /* 748 */ 0x06a17f05 | (14 << 27) /* 0.414427779 */, + /* 749 */ 0x06a485cf | (14 << 27) /* 0.415166674 */, + /* 750 */ 0x06a78cf1 | (14 << 27) /* 0.415905897 */, + /* 751 */ 0x06aa946b | (14 << 27) /* 0.416645450 */, + + /* 752 */ 0x06ad9c3d | (14 << 27) /* 0.417385331 */, + /* 753 */ 0x06b0a468 | (14 << 27) /* 0.418125540 */, + /* 754 */ 0x06b3acea | (14 << 27) /* 0.418866076 */, + /* 755 */ 0x06b6b5c4 | (14 << 27) /* 0.419606940 */, + /* 756 */ 0x06b9bef6 | (14 << 27) /* 0.420348132 */, + /* 757 */ 0x06bcc880 | (14 << 27) /* 0.421089650 */, + /* 758 */ 0x06bfd261 | (14 << 27) /* 0.421831494 */, + /* 759 */ 0x06c2dc9a | (14 << 27) /* 0.422573665 */, + /* 760 */ 0x06c5e72b | (14 << 27) /* 0.423316162 */, + /* 761 */ 0x06c8f213 | (14 << 27) /* 0.424058985 */, + /* 762 */ 0x06cbfd52 | (14 << 27) /* 0.424802133 */, + /* 763 */ 0x06cf08e9 | (14 << 27) /* 0.425545607 */, + /* 764 */ 0x06d214d7 | (14 << 27) /* 0.426289405 */, + /* 765 */ 0x06d5211c | (14 << 27) /* 0.427033528 */, + /* 766 */ 0x06d82db8 | (14 << 27) /* 0.427777975 */, + /* 767 */ 0x06db3aaa | (14 << 27) /* 0.428522746 */, + + /* 768 */ 0x06de47f4 | (14 << 27) /* 0.429267841 */, + /* 769 */ 0x06e15595 | (14 << 27) /* 0.430013259 */, + /* 770 */ 0x06e4638d | (14 << 27) /* 0.430759001 */, + /* 771 */ 0x06e771db | (14 << 27) /* 0.431505065 */, + /* 772 */ 0x06ea807f | (14 << 27) /* 0.432251452 */, + /* 773 */ 0x06ed8f7b | (14 << 27) /* 0.432998162 */, + /* 774 */ 0x06f09ecc | (14 << 27) /* 0.433745193 */, + /* 775 */ 0x06f3ae75 | (14 << 27) /* 0.434492546 */, + /* 776 */ 0x06f6be73 | (14 << 27) /* 0.435240221 */, + /* 777 */ 0x06f9cec8 | (14 << 27) /* 0.435988217 */, + /* 778 */ 0x06fcdf72 | (14 << 27) /* 0.436736534 */, + /* 779 */ 0x06fff073 | (14 << 27) /* 0.437485172 */, + /* 780 */ 0x070301ca | (14 << 27) /* 0.438234130 */, + /* 781 */ 0x07061377 | (14 << 27) /* 0.438983408 */, + /* 782 */ 0x0709257a | (14 << 27) /* 0.439733006 */, + /* 783 */ 0x070c37d2 | (14 << 27) /* 0.440482924 */, + + /* 784 */ 0x070f4a80 | (14 << 27) /* 0.441233161 */, + /* 785 */ 0x07125d84 | (14 << 27) /* 0.441983717 */, + /* 786 */ 0x071570de | (14 << 27) /* 0.442734592 */, + /* 787 */ 0x0718848d | (14 << 27) /* 0.443485785 */, + /* 788 */ 0x071b9891 | (14 << 27) /* 0.444237296 */, + /* 789 */ 0x071eaceb | (14 << 27) /* 0.444989126 */, + /* 790 */ 0x0721c19a | (14 << 27) /* 0.445741273 */, + /* 791 */ 0x0724d69e | (14 << 27) /* 0.446493738 */, + /* 792 */ 0x0727ebf7 | (14 << 27) /* 0.447246519 */, + /* 793 */ 0x072b01a6 | (14 << 27) /* 0.447999618 */, + /* 794 */ 0x072e17a9 | (14 << 27) /* 0.448753033 */, + /* 795 */ 0x07312e01 | (14 << 27) /* 0.449506765 */, + /* 796 */ 0x073444ae | (14 << 27) /* 0.450260813 */, + /* 797 */ 0x07375bb0 | (14 << 27) /* 0.451015176 */, + /* 798 */ 0x073a7307 | (14 << 27) /* 0.451769856 */, + /* 799 */ 0x073d8ab2 | (14 << 27) /* 0.452524850 */, + + /* 800 */ 0x0740a2b2 | (14 << 27) /* 0.453280160 */, + /* 801 */ 0x0743bb06 | (14 << 27) /* 0.454035784 */, + /* 802 */ 0x0746d3af | (14 << 27) /* 0.454791723 */, + /* 803 */ 0x0749ecac | (14 << 27) /* 0.455547976 */, + /* 804 */ 0x074d05fe | (14 << 27) /* 0.456304543 */, + /* 805 */ 0x07501fa3 | (14 << 27) /* 0.457061423 */, + /* 806 */ 0x0753399d | (14 << 27) /* 0.457818618 */, + /* 807 */ 0x075653eb | (14 << 27) /* 0.458576125 */, + /* 808 */ 0x07596e8d | (14 << 27) /* 0.459333946 */, + /* 809 */ 0x075c8983 | (14 << 27) /* 0.460092079 */, + /* 810 */ 0x075fa4cc | (14 << 27) /* 0.460850524 */, + /* 811 */ 0x0762c06a | (14 << 27) /* 0.461609282 */, + /* 812 */ 0x0765dc5b | (14 << 27) /* 0.462368352 */, + /* 813 */ 0x0768f8a0 | (14 << 27) /* 0.463127733 */, + /* 814 */ 0x076c1538 | (14 << 27) /* 0.463887426 */, + /* 815 */ 0x076f3224 | (14 << 27) /* 0.464647430 */, + + /* 816 */ 0x07724f64 | (14 << 27) /* 0.465407744 */, + /* 817 */ 0x07756cf7 | (14 << 27) /* 0.466168370 */, + /* 818 */ 0x07788add | (14 << 27) /* 0.466929306 */, + /* 819 */ 0x077ba916 | (14 << 27) /* 0.467690552 */, + /* 820 */ 0x077ec7a3 | (14 << 27) /* 0.468452108 */, + /* 821 */ 0x0781e683 | (14 << 27) /* 0.469213973 */, + /* 822 */ 0x078505b5 | (14 << 27) /* 0.469976148 */, + /* 823 */ 0x0788253b | (14 << 27) /* 0.470738632 */, + /* 824 */ 0x078b4514 | (14 << 27) /* 0.471501425 */, + /* 825 */ 0x078e653f | (14 << 27) /* 0.472264527 */, + /* 826 */ 0x079185be | (14 << 27) /* 0.473027937 */, + /* 827 */ 0x0794a68f | (14 << 27) /* 0.473791655 */, + /* 828 */ 0x0797c7b2 | (14 << 27) /* 0.474555681 */, + /* 829 */ 0x079ae929 | (14 << 27) /* 0.475320014 */, + /* 830 */ 0x079e0af1 | (14 << 27) /* 0.476084655 */, + /* 831 */ 0x07a12d0c | (14 << 27) /* 0.476849603 */, + + /* 832 */ 0x07a44f7a | (14 << 27) /* 0.477614858 */, + /* 833 */ 0x07a7723a | (14 << 27) /* 0.478380420 */, + /* 834 */ 0x07aa954c | (14 << 27) /* 0.479146288 */, + /* 835 */ 0x07adb8b0 | (14 << 27) /* 0.479912463 */, + /* 836 */ 0x07b0dc67 | (14 << 27) /* 0.480678943 */, + /* 837 */ 0x07b4006f | (14 << 27) /* 0.481445729 */, + /* 838 */ 0x07b724ca | (14 << 27) /* 0.482212820 */, + /* 839 */ 0x07ba4976 | (14 << 27) /* 0.482980216 */, + /* 840 */ 0x07bd6e75 | (14 << 27) /* 0.483747918 */, + /* 841 */ 0x07c093c5 | (14 << 27) /* 0.484515924 */, + /* 842 */ 0x07c3b967 | (14 << 27) /* 0.485284235 */, + /* 843 */ 0x07c6df5a | (14 << 27) /* 0.486052849 */, + /* 844 */ 0x07ca059f | (14 << 27) /* 0.486821768 */, + /* 845 */ 0x07cd2c36 | (14 << 27) /* 0.487590991 */, + /* 846 */ 0x07d0531e | (14 << 27) /* 0.488360517 */, + /* 847 */ 0x07d37a57 | (14 << 27) /* 0.489130346 */, + + /* 848 */ 0x07d6a1e2 | (14 << 27) /* 0.489900479 */, + /* 849 */ 0x07d9c9be | (14 << 27) /* 0.490670914 */, + /* 850 */ 0x07dcf1ec | (14 << 27) /* 0.491441651 */, + /* 851 */ 0x07e01a6a | (14 << 27) /* 0.492212691 */, + /* 852 */ 0x07e3433a | (14 << 27) /* 0.492984033 */, + /* 853 */ 0x07e66c5a | (14 << 27) /* 0.493755677 */, + /* 854 */ 0x07e995cc | (14 << 27) /* 0.494527623 */, + /* 855 */ 0x07ecbf8e | (14 << 27) /* 0.495299870 */, + /* 856 */ 0x07efe9a1 | (14 << 27) /* 0.496072418 */, + /* 857 */ 0x07f31405 | (14 << 27) /* 0.496845266 */, + /* 858 */ 0x07f63eba | (14 << 27) /* 0.497618416 */, + /* 859 */ 0x07f969c0 | (14 << 27) /* 0.498391866 */, + /* 860 */ 0x07fc9516 | (14 << 27) /* 0.499165616 */, + /* 861 */ 0x07ffc0bc | (14 << 27) /* 0.499939666 */, + /* 862 */ 0x04017659 | (15 << 27) /* 0.250357008 */, + /* 863 */ 0x04030c7d | (15 << 27) /* 0.250744333 */, + + /* 864 */ 0x0404a2c9 | (15 << 27) /* 0.251131807 */, + /* 865 */ 0x0406393d | (15 << 27) /* 0.251519431 */, + /* 866 */ 0x0407cfd9 | (15 << 27) /* 0.251907204 */, + /* 867 */ 0x0409669d | (15 << 27) /* 0.252295127 */, + /* 868 */ 0x040afd89 | (15 << 27) /* 0.252683198 */, + /* 869 */ 0x040c949e | (15 << 27) /* 0.253071419 */, + /* 870 */ 0x040e2bda | (15 << 27) /* 0.253459789 */, + /* 871 */ 0x040fc33e | (15 << 27) /* 0.253848307 */, + /* 872 */ 0x04115aca | (15 << 27) /* 0.254236974 */, + /* 873 */ 0x0412f27e | (15 << 27) /* 0.254625790 */, + /* 874 */ 0x04148a5a | (15 << 27) /* 0.255014755 */, + /* 875 */ 0x0416225d | (15 << 27) /* 0.255403867 */, + /* 876 */ 0x0417ba89 | (15 << 27) /* 0.255793128 */, + /* 877 */ 0x041952dc | (15 << 27) /* 0.256182537 */, + /* 878 */ 0x041aeb57 | (15 << 27) /* 0.256572095 */, + /* 879 */ 0x041c83fa | (15 << 27) /* 0.256961800 */, + + /* 880 */ 0x041e1cc4 | (15 << 27) /* 0.257351652 */, + /* 881 */ 0x041fb5b6 | (15 << 27) /* 0.257741653 */, + /* 882 */ 0x04214ed0 | (15 << 27) /* 0.258131801 */, + /* 883 */ 0x0422e811 | (15 << 27) /* 0.258522097 */, + /* 884 */ 0x04248179 | (15 << 27) /* 0.258912540 */, + /* 885 */ 0x04261b0a | (15 << 27) /* 0.259303130 */, + /* 886 */ 0x0427b4c2 | (15 << 27) /* 0.259693868 */, + /* 887 */ 0x04294ea1 | (15 << 27) /* 0.260084752 */, + /* 888 */ 0x042ae8a7 | (15 << 27) /* 0.260475783 */, + /* 889 */ 0x042c82d6 | (15 << 27) /* 0.260866961 */, + /* 890 */ 0x042e1d2b | (15 << 27) /* 0.261258286 */, + /* 891 */ 0x042fb7a8 | (15 << 27) /* 0.261649758 */, + /* 892 */ 0x0431524c | (15 << 27) /* 0.262041376 */, + /* 893 */ 0x0432ed17 | (15 << 27) /* 0.262433140 */, + /* 894 */ 0x0434880a | (15 << 27) /* 0.262825051 */, + /* 895 */ 0x04362324 | (15 << 27) /* 0.263217107 */, + + /* 896 */ 0x0437be65 | (15 << 27) /* 0.263609310 */, + /* 897 */ 0x043959cd | (15 << 27) /* 0.264001659 */, + /* 898 */ 0x043af55d | (15 << 27) /* 0.264394153 */, + /* 899 */ 0x043c9113 | (15 << 27) /* 0.264786794 */, + /* 900 */ 0x043e2cf1 | (15 << 27) /* 0.265179580 */, + /* 901 */ 0x043fc8f6 | (15 << 27) /* 0.265572511 */, + /* 902 */ 0x04416522 | (15 << 27) /* 0.265965588 */, + /* 903 */ 0x04430174 | (15 << 27) /* 0.266358810 */, + /* 904 */ 0x04449dee | (15 << 27) /* 0.266752177 */, + /* 905 */ 0x04463a8f | (15 << 27) /* 0.267145689 */, + /* 906 */ 0x0447d756 | (15 << 27) /* 0.267539347 */, + /* 907 */ 0x04497445 | (15 << 27) /* 0.267933149 */, + /* 908 */ 0x044b115a | (15 << 27) /* 0.268327096 */, + /* 909 */ 0x044cae96 | (15 << 27) /* 0.268721187 */, + /* 910 */ 0x044e4bf9 | (15 << 27) /* 0.269115423 */, + /* 911 */ 0x044fe983 | (15 << 27) /* 0.269509804 */, + + /* 912 */ 0x04518733 | (15 << 27) /* 0.269904329 */, + /* 913 */ 0x0453250a | (15 << 27) /* 0.270298998 */, + /* 914 */ 0x0454c308 | (15 << 27) /* 0.270693811 */, + /* 915 */ 0x0456612d | (15 << 27) /* 0.271088768 */, + /* 916 */ 0x0457ff78 | (15 << 27) /* 0.271483869 */, + /* 917 */ 0x04599dea | (15 << 27) /* 0.271879114 */, + /* 918 */ 0x045b3c82 | (15 << 27) /* 0.272274503 */, + /* 919 */ 0x045cdb41 | (15 << 27) /* 0.272670035 */, + /* 920 */ 0x045e7a26 | (15 << 27) /* 0.273065710 */, + /* 921 */ 0x04601932 | (15 << 27) /* 0.273461530 */, + /* 922 */ 0x0461b864 | (15 << 27) /* 0.273857492 */, + /* 923 */ 0x046357bd | (15 << 27) /* 0.274253597 */, + /* 924 */ 0x0464f73c | (15 << 27) /* 0.274649846 */, + /* 925 */ 0x046696e2 | (15 << 27) /* 0.275046238 */, + /* 926 */ 0x046836ae | (15 << 27) /* 0.275442772 */, + /* 927 */ 0x0469d6a0 | (15 << 27) /* 0.275839449 */, + + /* 928 */ 0x046b76b9 | (15 << 27) /* 0.276236269 */, + /* 929 */ 0x046d16f7 | (15 << 27) /* 0.276633232 */, + /* 930 */ 0x046eb75c | (15 << 27) /* 0.277030337 */, + /* 931 */ 0x047057e8 | (15 << 27) /* 0.277427584 */, + /* 932 */ 0x0471f899 | (15 << 27) /* 0.277824973 */, + /* 933 */ 0x04739971 | (15 << 27) /* 0.278222505 */, + /* 934 */ 0x04753a6f | (15 << 27) /* 0.278620179 */, + /* 935 */ 0x0476db92 | (15 << 27) /* 0.279017995 */, + /* 936 */ 0x04787cdc | (15 << 27) /* 0.279415952 */, + /* 937 */ 0x047a1e4c | (15 << 27) /* 0.279814051 */, + /* 938 */ 0x047bbfe2 | (15 << 27) /* 0.280212292 */, + /* 939 */ 0x047d619e | (15 << 27) /* 0.280610675 */, + /* 940 */ 0x047f0380 | (15 << 27) /* 0.281009199 */, + /* 941 */ 0x0480a588 | (15 << 27) /* 0.281407864 */, + /* 942 */ 0x048247b6 | (15 << 27) /* 0.281806670 */, + /* 943 */ 0x0483ea0a | (15 << 27) /* 0.282205618 */, + + /* 944 */ 0x04858c83 | (15 << 27) /* 0.282604707 */, + /* 945 */ 0x04872f22 | (15 << 27) /* 0.283003936 */, + /* 946 */ 0x0488d1e8 | (15 << 27) /* 0.283403307 */, + /* 947 */ 0x048a74d3 | (15 << 27) /* 0.283802818 */, + /* 948 */ 0x048c17e3 | (15 << 27) /* 0.284202470 */, + /* 949 */ 0x048dbb1a | (15 << 27) /* 0.284602263 */, + /* 950 */ 0x048f5e76 | (15 << 27) /* 0.285002195 */, + /* 951 */ 0x049101f8 | (15 << 27) /* 0.285402269 */, + /* 952 */ 0x0492a59f | (15 << 27) /* 0.285802482 */, + /* 953 */ 0x0494496c | (15 << 27) /* 0.286202836 */, + /* 954 */ 0x0495ed5f | (15 << 27) /* 0.286603329 */, + /* 955 */ 0x04979177 | (15 << 27) /* 0.287003963 */, + /* 956 */ 0x049935b5 | (15 << 27) /* 0.287404737 */, + /* 957 */ 0x049ada19 | (15 << 27) /* 0.287805650 */, + /* 958 */ 0x049c7ea1 | (15 << 27) /* 0.288206703 */, + /* 959 */ 0x049e2350 | (15 << 27) /* 0.288607895 */, + + /* 960 */ 0x049fc824 | (15 << 27) /* 0.289009227 */, + /* 961 */ 0x04a16d1d | (15 << 27) /* 0.289410699 */, + /* 962 */ 0x04a3123b | (15 << 27) /* 0.289812309 */, + /* 963 */ 0x04a4b77f | (15 << 27) /* 0.290214059 */, + /* 964 */ 0x04a65ce8 | (15 << 27) /* 0.290615948 */, + /* 965 */ 0x04a80277 | (15 << 27) /* 0.291017976 */, + /* 966 */ 0x04a9a82b | (15 << 27) /* 0.291420143 */, + /* 967 */ 0x04ab4e04 | (15 << 27) /* 0.291822449 */, + /* 968 */ 0x04acf402 | (15 << 27) /* 0.292224893 */, + /* 969 */ 0x04ae9a26 | (15 << 27) /* 0.292627476 */, + /* 970 */ 0x04b0406e | (15 << 27) /* 0.293030197 */, + /* 971 */ 0x04b1e6dc | (15 << 27) /* 0.293433057 */, + /* 972 */ 0x04b38d6f | (15 << 27) /* 0.293836055 */, + /* 973 */ 0x04b53427 | (15 << 27) /* 0.294239192 */, + /* 974 */ 0x04b6db05 | (15 << 27) /* 0.294642466 */, + /* 975 */ 0x04b88207 | (15 << 27) /* 0.295045879 */, + + /* 976 */ 0x04ba292e | (15 << 27) /* 0.295449429 */, + /* 977 */ 0x04bbd07a | (15 << 27) /* 0.295853118 */, + /* 978 */ 0x04bd77ec | (15 << 27) /* 0.296256944 */, + /* 979 */ 0x04bf1f82 | (15 << 27) /* 0.296660907 */, + /* 980 */ 0x04c0c73d | (15 << 27) /* 0.297065009 */, + /* 981 */ 0x04c26f1d | (15 << 27) /* 0.297469248 */, + /* 982 */ 0x04c41722 | (15 << 27) /* 0.297873624 */, + /* 983 */ 0x04c5bf4c | (15 << 27) /* 0.298278137 */, + /* 984 */ 0x04c7679a | (15 << 27) /* 0.298682788 */, + /* 985 */ 0x04c9100d | (15 << 27) /* 0.299087576 */, + /* 986 */ 0x04cab8a6 | (15 << 27) /* 0.299492500 */, + /* 987 */ 0x04cc6163 | (15 << 27) /* 0.299897562 */, + /* 988 */ 0x04ce0a44 | (15 << 27) /* 0.300302761 */, + /* 989 */ 0x04cfb34b | (15 << 27) /* 0.300708096 */, + /* 990 */ 0x04d15c76 | (15 << 27) /* 0.301113568 */, + /* 991 */ 0x04d305c5 | (15 << 27) /* 0.301519176 */, + + /* 992 */ 0x04d4af3a | (15 << 27) /* 0.301924921 */, + /* 993 */ 0x04d658d2 | (15 << 27) /* 0.302330802 */, + /* 994 */ 0x04d80290 | (15 << 27) /* 0.302736820 */, + /* 995 */ 0x04d9ac72 | (15 << 27) /* 0.303142973 */, + /* 996 */ 0x04db5679 | (15 << 27) /* 0.303549263 */, + /* 997 */ 0x04dd00a4 | (15 << 27) /* 0.303955689 */, + /* 998 */ 0x04deaaf3 | (15 << 27) /* 0.304362251 */, + /* 999 */ 0x04e05567 | (15 << 27) /* 0.304768948 */, + /* 1000 */ 0x04e20000 | (15 << 27) /* 0.305175781 */, + /* 1001 */ 0x04e3aabd | (15 << 27) /* 0.305582750 */, + /* 1002 */ 0x04e5559e | (15 << 27) /* 0.305989854 */, + /* 1003 */ 0x04e700a3 | (15 << 27) /* 0.306397094 */, + /* 1004 */ 0x04e8abcd | (15 << 27) /* 0.306804470 */, + /* 1005 */ 0x04ea571c | (15 << 27) /* 0.307211980 */, + /* 1006 */ 0x04ec028e | (15 << 27) /* 0.307619626 */, + /* 1007 */ 0x04edae25 | (15 << 27) /* 0.308027406 */, + + /* 1008 */ 0x04ef59e0 | (15 << 27) /* 0.308435322 */, + /* 1009 */ 0x04f105bf | (15 << 27) /* 0.308843373 */, + /* 1010 */ 0x04f2b1c3 | (15 << 27) /* 0.309251558 */, + /* 1011 */ 0x04f45dea | (15 << 27) /* 0.309659879 */, + /* 1012 */ 0x04f60a36 | (15 << 27) /* 0.310068333 */, + /* 1013 */ 0x04f7b6a6 | (15 << 27) /* 0.310476923 */, + /* 1014 */ 0x04f9633a | (15 << 27) /* 0.310885647 */, + /* 1015 */ 0x04fb0ff2 | (15 << 27) /* 0.311294505 */, + /* 1016 */ 0x04fcbcce | (15 << 27) /* 0.311703498 */, + /* 1017 */ 0x04fe69ce | (15 << 27) /* 0.312112625 */, + /* 1018 */ 0x050016f3 | (15 << 27) /* 0.312521885 */, + /* 1019 */ 0x0501c43b | (15 << 27) /* 0.312931280 */, + /* 1020 */ 0x050371a7 | (15 << 27) /* 0.313340809 */, + /* 1021 */ 0x05051f37 | (15 << 27) /* 0.313750472 */, + /* 1022 */ 0x0506cceb | (15 << 27) /* 0.314160269 */, + /* 1023 */ 0x05087ac2 | (15 << 27) /* 0.314570199 */, + + /* 1024 */ 0x050a28be | (15 << 27) /* 0.314980262 */, + /* 1025 */ 0x050bd6de | (15 << 27) /* 0.315390460 */, + /* 1026 */ 0x050d8521 | (15 << 27) /* 0.315800790 */, + /* 1027 */ 0x050f3388 | (15 << 27) /* 0.316211255 */, + /* 1028 */ 0x0510e213 | (15 << 27) /* 0.316621852 */, + /* 1029 */ 0x051290c2 | (15 << 27) /* 0.317032582 */, + /* 1030 */ 0x05143f94 | (15 << 27) /* 0.317443446 */, + /* 1031 */ 0x0515ee8a | (15 << 27) /* 0.317854442 */, + /* 1032 */ 0x05179da4 | (15 << 27) /* 0.318265572 */, + /* 1033 */ 0x05194ce1 | (15 << 27) /* 0.318676834 */, + /* 1034 */ 0x051afc42 | (15 << 27) /* 0.319088229 */, + /* 1035 */ 0x051cabc7 | (15 << 27) /* 0.319499756 */, + /* 1036 */ 0x051e5b6f | (15 << 27) /* 0.319911417 */, + /* 1037 */ 0x05200b3a | (15 << 27) /* 0.320323209 */, + /* 1038 */ 0x0521bb2a | (15 << 27) /* 0.320735134 */, + /* 1039 */ 0x05236b3d | (15 << 27) /* 0.321147192 */, + + /* 1040 */ 0x05251b73 | (15 << 27) /* 0.321559381 */, + /* 1041 */ 0x0526cbcd | (15 << 27) /* 0.321971703 */, + /* 1042 */ 0x05287c4a | (15 << 27) /* 0.322384156 */, + /* 1043 */ 0x052a2cea | (15 << 27) /* 0.322796742 */, + /* 1044 */ 0x052bddae | (15 << 27) /* 0.323209460 */, + /* 1045 */ 0x052d8e96 | (15 << 27) /* 0.323622309 */, + /* 1046 */ 0x052f3fa1 | (15 << 27) /* 0.324035290 */, + /* 1047 */ 0x0530f0cf | (15 << 27) /* 0.324448403 */, + /* 1048 */ 0x0532a220 | (15 << 27) /* 0.324861647 */, + /* 1049 */ 0x05345395 | (15 << 27) /* 0.325275023 */, + /* 1050 */ 0x0536052d | (15 << 27) /* 0.325688530 */, + /* 1051 */ 0x0537b6e8 | (15 << 27) /* 0.326102168 */, + /* 1052 */ 0x053968c6 | (15 << 27) /* 0.326515938 */, + /* 1053 */ 0x053b1ac8 | (15 << 27) /* 0.326929839 */, + /* 1054 */ 0x053ccced | (15 << 27) /* 0.327343870 */, + /* 1055 */ 0x053e7f35 | (15 << 27) /* 0.327758033 */, + + /* 1056 */ 0x054031a0 | (15 << 27) /* 0.328172327 */, + /* 1057 */ 0x0541e42e | (15 << 27) /* 0.328586751 */, + /* 1058 */ 0x054396df | (15 << 27) /* 0.329001306 */, + /* 1059 */ 0x054549b4 | (15 << 27) /* 0.329415992 */, + /* 1060 */ 0x0546fcab | (15 << 27) /* 0.329830808 */, + /* 1061 */ 0x0548afc6 | (15 << 27) /* 0.330245755 */, + /* 1062 */ 0x054a6303 | (15 << 27) /* 0.330660832 */, + /* 1063 */ 0x054c1663 | (15 << 27) /* 0.331076039 */, + /* 1064 */ 0x054dc9e7 | (15 << 27) /* 0.331491377 */, + /* 1065 */ 0x054f7d8d | (15 << 27) /* 0.331906845 */, + /* 1066 */ 0x05513156 | (15 << 27) /* 0.332322443 */, + /* 1067 */ 0x0552e542 | (15 << 27) /* 0.332738170 */, + /* 1068 */ 0x05549951 | (15 << 27) /* 0.333154028 */, + /* 1069 */ 0x05564d83 | (15 << 27) /* 0.333570016 */, + /* 1070 */ 0x055801d8 | (15 << 27) /* 0.333986133 */, + /* 1071 */ 0x0559b64f | (15 << 27) /* 0.334402380 */, + + /* 1072 */ 0x055b6ae9 | (15 << 27) /* 0.334818756 */, + /* 1073 */ 0x055d1fa6 | (15 << 27) /* 0.335235262 */, + /* 1074 */ 0x055ed486 | (15 << 27) /* 0.335651898 */, + /* 1075 */ 0x05608988 | (15 << 27) /* 0.336068662 */, + /* 1076 */ 0x05623ead | (15 << 27) /* 0.336485556 */, + /* 1077 */ 0x0563f3f5 | (15 << 27) /* 0.336902579 */, + /* 1078 */ 0x0565a960 | (15 << 27) /* 0.337319732 */, + /* 1079 */ 0x05675eed | (15 << 27) /* 0.337737013 */, + /* 1080 */ 0x0569149c | (15 << 27) /* 0.338154423 */, + /* 1081 */ 0x056aca6f | (15 << 27) /* 0.338571962 */, + /* 1082 */ 0x056c8064 | (15 << 27) /* 0.338989630 */, + /* 1083 */ 0x056e367b | (15 << 27) /* 0.339407426 */, + /* 1084 */ 0x056fecb5 | (15 << 27) /* 0.339825351 */, + /* 1085 */ 0x0571a311 | (15 << 27) /* 0.340243405 */, + /* 1086 */ 0x05735990 | (15 << 27) /* 0.340661587 */, + /* 1087 */ 0x05751032 | (15 << 27) /* 0.341079898 */, + + /* 1088 */ 0x0576c6f5 | (15 << 27) /* 0.341498336 */, + /* 1089 */ 0x05787ddc | (15 << 27) /* 0.341916903 */, + /* 1090 */ 0x057a34e4 | (15 << 27) /* 0.342335598 */, + /* 1091 */ 0x057bec0f | (15 << 27) /* 0.342754421 */, + /* 1092 */ 0x057da35d | (15 << 27) /* 0.343173373 */, + /* 1093 */ 0x057f5acc | (15 << 27) /* 0.343592452 */, + /* 1094 */ 0x0581125e | (15 << 27) /* 0.344011659 */, + /* 1095 */ 0x0582ca12 | (15 << 27) /* 0.344430993 */, + /* 1096 */ 0x058481e9 | (15 << 27) /* 0.344850455 */, + /* 1097 */ 0x058639e2 | (15 << 27) /* 0.345270045 */, + /* 1098 */ 0x0587f1fd | (15 << 27) /* 0.345689763 */, + /* 1099 */ 0x0589aa3a | (15 << 27) /* 0.346109608 */, + /* 1100 */ 0x058b629a | (15 << 27) /* 0.346529580 */, + /* 1101 */ 0x058d1b1b | (15 << 27) /* 0.346949679 */, + /* 1102 */ 0x058ed3bf | (15 << 27) /* 0.347369906 */, + /* 1103 */ 0x05908c85 | (15 << 27) /* 0.347790260 */, + + /* 1104 */ 0x0592456d | (15 << 27) /* 0.348210741 */, + /* 1105 */ 0x0593fe77 | (15 << 27) /* 0.348631348 */, + /* 1106 */ 0x0595b7a3 | (15 << 27) /* 0.349052083 */, + /* 1107 */ 0x059770f1 | (15 << 27) /* 0.349472945 */, + /* 1108 */ 0x05992a61 | (15 << 27) /* 0.349893933 */, + /* 1109 */ 0x059ae3f3 | (15 << 27) /* 0.350315048 */, + /* 1110 */ 0x059c9da8 | (15 << 27) /* 0.350736290 */, + /* 1111 */ 0x059e577e | (15 << 27) /* 0.351157658 */, + /* 1112 */ 0x05a01176 | (15 << 27) /* 0.351579152 */, + /* 1113 */ 0x05a1cb90 | (15 << 27) /* 0.352000773 */, + /* 1114 */ 0x05a385cc | (15 << 27) /* 0.352422520 */, + /* 1115 */ 0x05a5402a | (15 << 27) /* 0.352844394 */, + /* 1116 */ 0x05a6faa9 | (15 << 27) /* 0.353266393 */, + /* 1117 */ 0x05a8b54b | (15 << 27) /* 0.353688519 */, + /* 1118 */ 0x05aa700e | (15 << 27) /* 0.354110771 */, + /* 1119 */ 0x05ac2af3 | (15 << 27) /* 0.354533148 */, + + /* 1120 */ 0x05ade5fa | (15 << 27) /* 0.354955651 */, + /* 1121 */ 0x05afa123 | (15 << 27) /* 0.355378281 */, + /* 1122 */ 0x05b15c6d | (15 << 27) /* 0.355801035 */, + /* 1123 */ 0x05b317d9 | (15 << 27) /* 0.356223916 */, + /* 1124 */ 0x05b4d367 | (15 << 27) /* 0.356646922 */, + /* 1125 */ 0x05b68f16 | (15 << 27) /* 0.357070053 */, + /* 1126 */ 0x05b84ae7 | (15 << 27) /* 0.357493310 */, + /* 1127 */ 0x05ba06da | (15 << 27) /* 0.357916692 */, + /* 1128 */ 0x05bbc2ef | (15 << 27) /* 0.358340200 */, + /* 1129 */ 0x05bd7f25 | (15 << 27) /* 0.358763832 */, + /* 1130 */ 0x05bf3b7c | (15 << 27) /* 0.359187590 */, + /* 1131 */ 0x05c0f7f5 | (15 << 27) /* 0.359611472 */, + /* 1132 */ 0x05c2b490 | (15 << 27) /* 0.360035480 */, + /* 1133 */ 0x05c4714c | (15 << 27) /* 0.360459613 */, + /* 1134 */ 0x05c62e2a | (15 << 27) /* 0.360883870 */, + /* 1135 */ 0x05c7eb29 | (15 << 27) /* 0.361308252 */, + + /* 1136 */ 0x05c9a84a | (15 << 27) /* 0.361732758 */, + /* 1137 */ 0x05cb658c | (15 << 27) /* 0.362157390 */, + /* 1138 */ 0x05cd22ef | (15 << 27) /* 0.362582145 */, + /* 1139 */ 0x05cee074 | (15 << 27) /* 0.363007026 */, + /* 1140 */ 0x05d09e1b | (15 << 27) /* 0.363432030 */, + /* 1141 */ 0x05d25be2 | (15 << 27) /* 0.363857159 */, + /* 1142 */ 0x05d419cb | (15 << 27) /* 0.364282412 */, + /* 1143 */ 0x05d5d7d5 | (15 << 27) /* 0.364707789 */, + /* 1144 */ 0x05d79601 | (15 << 27) /* 0.365133291 */, + /* 1145 */ 0x05d9544e | (15 << 27) /* 0.365558916 */, + /* 1146 */ 0x05db12bc | (15 << 27) /* 0.365984665 */, + /* 1147 */ 0x05dcd14c | (15 << 27) /* 0.366410538 */, + /* 1148 */ 0x05de8ffc | (15 << 27) /* 0.366836535 */, + /* 1149 */ 0x05e04ece | (15 << 27) /* 0.367262655 */, + /* 1150 */ 0x05e20dc1 | (15 << 27) /* 0.367688900 */, + /* 1151 */ 0x05e3ccd5 | (15 << 27) /* 0.368115267 */, + + /* 1152 */ 0x05e58c0b | (15 << 27) /* 0.368541759 */, + /* 1153 */ 0x05e74b61 | (15 << 27) /* 0.368968373 */, + /* 1154 */ 0x05e90ad9 | (15 << 27) /* 0.369395111 */, + /* 1155 */ 0x05eaca72 | (15 << 27) /* 0.369821973 */, + /* 1156 */ 0x05ec8a2b | (15 << 27) /* 0.370248957 */, + /* 1157 */ 0x05ee4a06 | (15 << 27) /* 0.370676065 */, + /* 1158 */ 0x05f00a02 | (15 << 27) /* 0.371103295 */, + /* 1159 */ 0x05f1ca1f | (15 << 27) /* 0.371530649 */, + /* 1160 */ 0x05f38a5d | (15 << 27) /* 0.371958126 */, + /* 1161 */ 0x05f54abc | (15 << 27) /* 0.372385725 */, + /* 1162 */ 0x05f70b3c | (15 << 27) /* 0.372813448 */, + /* 1163 */ 0x05f8cbdc | (15 << 27) /* 0.373241292 */, + /* 1164 */ 0x05fa8c9e | (15 << 27) /* 0.373669260 */, + /* 1165 */ 0x05fc4d81 | (15 << 27) /* 0.374097350 */, + /* 1166 */ 0x05fe0e84 | (15 << 27) /* 0.374525563 */, + /* 1167 */ 0x05ffcfa8 | (15 << 27) /* 0.374953898 */, + + /* 1168 */ 0x060190ee | (15 << 27) /* 0.375382356 */, + /* 1169 */ 0x06035254 | (15 << 27) /* 0.375810936 */, + /* 1170 */ 0x060513da | (15 << 27) /* 0.376239638 */, + /* 1171 */ 0x0606d582 | (15 << 27) /* 0.376668462 */, + /* 1172 */ 0x0608974a | (15 << 27) /* 0.377097408 */, + /* 1173 */ 0x060a5934 | (15 << 27) /* 0.377526476 */, + /* 1174 */ 0x060c1b3d | (15 << 27) /* 0.377955667 */, + /* 1175 */ 0x060ddd68 | (15 << 27) /* 0.378384979 */, + /* 1176 */ 0x060f9fb3 | (15 << 27) /* 0.378814413 */, + /* 1177 */ 0x0611621f | (15 << 27) /* 0.379243968 */, + /* 1178 */ 0x061324ac | (15 << 27) /* 0.379673646 */, + /* 1179 */ 0x0614e759 | (15 << 27) /* 0.380103444 */, + /* 1180 */ 0x0616aa27 | (15 << 27) /* 0.380533365 */, + /* 1181 */ 0x06186d16 | (15 << 27) /* 0.380963407 */, + /* 1182 */ 0x061a3025 | (15 << 27) /* 0.381393570 */, + /* 1183 */ 0x061bf354 | (15 << 27) /* 0.381823855 */, + + /* 1184 */ 0x061db6a5 | (15 << 27) /* 0.382254261 */, + /* 1185 */ 0x061f7a15 | (15 << 27) /* 0.382684788 */, + /* 1186 */ 0x06213da7 | (15 << 27) /* 0.383115436 */, + /* 1187 */ 0x06230158 | (15 << 27) /* 0.383546205 */, + /* 1188 */ 0x0624c52a | (15 << 27) /* 0.383977096 */, + /* 1189 */ 0x0626891d | (15 << 27) /* 0.384408107 */, + /* 1190 */ 0x06284d30 | (15 << 27) /* 0.384839239 */, + /* 1191 */ 0x062a1164 | (15 << 27) /* 0.385270492 */, + /* 1192 */ 0x062bd5b8 | (15 << 27) /* 0.385701865 */, + /* 1193 */ 0x062d9a2c | (15 << 27) /* 0.386133359 */, + /* 1194 */ 0x062f5ec1 | (15 << 27) /* 0.386564974 */, + /* 1195 */ 0x06312376 | (15 << 27) /* 0.386996709 */, + /* 1196 */ 0x0632e84b | (15 << 27) /* 0.387428565 */, + /* 1197 */ 0x0634ad41 | (15 << 27) /* 0.387860541 */, + /* 1198 */ 0x06367257 | (15 << 27) /* 0.388292637 */, + /* 1199 */ 0x0638378d | (15 << 27) /* 0.388724854 */, + + /* 1200 */ 0x0639fce4 | (15 << 27) /* 0.389157191 */, + /* 1201 */ 0x063bc25b | (15 << 27) /* 0.389589648 */, + /* 1202 */ 0x063d87f2 | (15 << 27) /* 0.390022225 */, + /* 1203 */ 0x063f4da9 | (15 << 27) /* 0.390454922 */, + /* 1204 */ 0x06411380 | (15 << 27) /* 0.390887739 */, + /* 1205 */ 0x0642d978 | (15 << 27) /* 0.391320675 */, + /* 1206 */ 0x06449f8f | (15 << 27) /* 0.391753732 */, + /* 1207 */ 0x064665c7 | (15 << 27) /* 0.392186908 */, + /* 1208 */ 0x06482c1f | (15 << 27) /* 0.392620204 */, + /* 1209 */ 0x0649f297 | (15 << 27) /* 0.393053619 */, + /* 1210 */ 0x064bb92f | (15 << 27) /* 0.393487154 */, + /* 1211 */ 0x064d7fe8 | (15 << 27) /* 0.393920808 */, + /* 1212 */ 0x064f46c0 | (15 << 27) /* 0.394354582 */, + /* 1213 */ 0x06510db8 | (15 << 27) /* 0.394788475 */, + /* 1214 */ 0x0652d4d0 | (15 << 27) /* 0.395222488 */, + /* 1215 */ 0x06549c09 | (15 << 27) /* 0.395656619 */, + + /* 1216 */ 0x06566361 | (15 << 27) /* 0.396090870 */, + /* 1217 */ 0x06582ad9 | (15 << 27) /* 0.396525239 */, + /* 1218 */ 0x0659f271 | (15 << 27) /* 0.396959728 */, + /* 1219 */ 0x065bba29 | (15 << 27) /* 0.397394336 */, + /* 1220 */ 0x065d8201 | (15 << 27) /* 0.397829062 */, + /* 1221 */ 0x065f49f9 | (15 << 27) /* 0.398263907 */, + /* 1222 */ 0x06611211 | (15 << 27) /* 0.398698871 */, + /* 1223 */ 0x0662da49 | (15 << 27) /* 0.399133954 */, + /* 1224 */ 0x0664a2a0 | (15 << 27) /* 0.399569155 */, + /* 1225 */ 0x06666b17 | (15 << 27) /* 0.400004475 */, + /* 1226 */ 0x066833ae | (15 << 27) /* 0.400439913 */, + /* 1227 */ 0x0669fc65 | (15 << 27) /* 0.400875470 */, + /* 1228 */ 0x066bc53c | (15 << 27) /* 0.401311145 */, + /* 1229 */ 0x066d8e32 | (15 << 27) /* 0.401746938 */, + /* 1230 */ 0x066f5748 | (15 << 27) /* 0.402182850 */, + /* 1231 */ 0x0671207e | (15 << 27) /* 0.402618879 */, + + /* 1232 */ 0x0672e9d4 | (15 << 27) /* 0.403055027 */, + /* 1233 */ 0x0674b349 | (15 << 27) /* 0.403491293 */, + /* 1234 */ 0x06767cde | (15 << 27) /* 0.403927676 */, + /* 1235 */ 0x06784692 | (15 << 27) /* 0.404364178 */, + /* 1236 */ 0x067a1066 | (15 << 27) /* 0.404800797 */, + /* 1237 */ 0x067bda5a | (15 << 27) /* 0.405237535 */, + /* 1238 */ 0x067da46d | (15 << 27) /* 0.405674390 */, + /* 1239 */ 0x067f6ea0 | (15 << 27) /* 0.406111362 */, + /* 1240 */ 0x068138f3 | (15 << 27) /* 0.406548452 */, + /* 1241 */ 0x06830365 | (15 << 27) /* 0.406985660 */, + /* 1242 */ 0x0684cdf6 | (15 << 27) /* 0.407422985 */, + /* 1243 */ 0x068698a8 | (15 << 27) /* 0.407860427 */, + /* 1244 */ 0x06886378 | (15 << 27) /* 0.408297987 */, + /* 1245 */ 0x068a2e68 | (15 << 27) /* 0.408735664 */, + /* 1246 */ 0x068bf978 | (15 << 27) /* 0.409173458 */, + /* 1247 */ 0x068dc4a7 | (15 << 27) /* 0.409611370 */, + + /* 1248 */ 0x068f8ff5 | (15 << 27) /* 0.410049398 */, + /* 1249 */ 0x06915b63 | (15 << 27) /* 0.410487544 */, + /* 1250 */ 0x069326f0 | (15 << 27) /* 0.410925806 */, + /* 1251 */ 0x0694f29c | (15 << 27) /* 0.411364185 */, + /* 1252 */ 0x0696be68 | (15 << 27) /* 0.411802681 */, + /* 1253 */ 0x06988a54 | (15 << 27) /* 0.412241294 */, + /* 1254 */ 0x069a565e | (15 << 27) /* 0.412680024 */, + /* 1255 */ 0x069c2288 | (15 << 27) /* 0.413118870 */, + /* 1256 */ 0x069deed1 | (15 << 27) /* 0.413557833 */, + /* 1257 */ 0x069fbb3a | (15 << 27) /* 0.413996912 */, + /* 1258 */ 0x06a187c1 | (15 << 27) /* 0.414436108 */, + /* 1259 */ 0x06a35468 | (15 << 27) /* 0.414875420 */, + /* 1260 */ 0x06a5212f | (15 << 27) /* 0.415314849 */, + /* 1261 */ 0x06a6ee14 | (15 << 27) /* 0.415754393 */, + /* 1262 */ 0x06a8bb18 | (15 << 27) /* 0.416194054 */, + /* 1263 */ 0x06aa883c | (15 << 27) /* 0.416633831 */, + + /* 1264 */ 0x06ac557f | (15 << 27) /* 0.417073724 */, + /* 1265 */ 0x06ae22e1 | (15 << 27) /* 0.417513734 */, + /* 1266 */ 0x06aff062 | (15 << 27) /* 0.417953859 */, + /* 1267 */ 0x06b1be03 | (15 << 27) /* 0.418394100 */, + /* 1268 */ 0x06b38bc2 | (15 << 27) /* 0.418834457 */, + /* 1269 */ 0x06b559a1 | (15 << 27) /* 0.419274929 */, + /* 1270 */ 0x06b7279e | (15 << 27) /* 0.419715518 */, + /* 1271 */ 0x06b8f5bb | (15 << 27) /* 0.420156222 */, + /* 1272 */ 0x06bac3f6 | (15 << 27) /* 0.420597041 */, + /* 1273 */ 0x06bc9251 | (15 << 27) /* 0.421037977 */, + /* 1274 */ 0x06be60cb | (15 << 27) /* 0.421479027 */, + /* 1275 */ 0x06c02f63 | (15 << 27) /* 0.421920193 */, + /* 1276 */ 0x06c1fe1b | (15 << 27) /* 0.422361475 */, + /* 1277 */ 0x06c3ccf1 | (15 << 27) /* 0.422802871 */, + /* 1278 */ 0x06c59be7 | (15 << 27) /* 0.423244383 */, + /* 1279 */ 0x06c76afb | (15 << 27) /* 0.423686010 */, + + /* 1280 */ 0x06c93a2e | (15 << 27) /* 0.424127753 */, + /* 1281 */ 0x06cb0981 | (15 << 27) /* 0.424569610 */, + /* 1282 */ 0x06ccd8f2 | (15 << 27) /* 0.425011582 */, + /* 1283 */ 0x06cea881 | (15 << 27) /* 0.425453669 */, + /* 1284 */ 0x06d07830 | (15 << 27) /* 0.425895871 */, + /* 1285 */ 0x06d247fe | (15 << 27) /* 0.426338188 */, + /* 1286 */ 0x06d417ea | (15 << 27) /* 0.426780620 */, + /* 1287 */ 0x06d5e7f5 | (15 << 27) /* 0.427223166 */, + /* 1288 */ 0x06d7b81f | (15 << 27) /* 0.427665827 */, + /* 1289 */ 0x06d98868 | (15 << 27) /* 0.428108603 */, + /* 1290 */ 0x06db58cf | (15 << 27) /* 0.428551493 */, + /* 1291 */ 0x06dd2955 | (15 << 27) /* 0.428994497 */, + /* 1292 */ 0x06def9fa | (15 << 27) /* 0.429437616 */, + /* 1293 */ 0x06e0cabe | (15 << 27) /* 0.429880849 */, + /* 1294 */ 0x06e29ba0 | (15 << 27) /* 0.430324197 */, + /* 1295 */ 0x06e46ca1 | (15 << 27) /* 0.430767659 */, + + /* 1296 */ 0x06e63dc0 | (15 << 27) /* 0.431211234 */, + /* 1297 */ 0x06e80efe | (15 << 27) /* 0.431654924 */, + /* 1298 */ 0x06e9e05b | (15 << 27) /* 0.432098728 */, + /* 1299 */ 0x06ebb1d6 | (15 << 27) /* 0.432542647 */, + /* 1300 */ 0x06ed8370 | (15 << 27) /* 0.432986678 */, + /* 1301 */ 0x06ef5529 | (15 << 27) /* 0.433430824 */, + /* 1302 */ 0x06f12700 | (15 << 27) /* 0.433875084 */, + /* 1303 */ 0x06f2f8f5 | (15 << 27) /* 0.434319457 */, + /* 1304 */ 0x06f4cb09 | (15 << 27) /* 0.434763944 */, + /* 1305 */ 0x06f69d3c | (15 << 27) /* 0.435208545 */, + /* 1306 */ 0x06f86f8d | (15 << 27) /* 0.435653259 */, + /* 1307 */ 0x06fa41fd | (15 << 27) /* 0.436098087 */, + /* 1308 */ 0x06fc148b | (15 << 27) /* 0.436543029 */, + /* 1309 */ 0x06fde737 | (15 << 27) /* 0.436988083 */, + /* 1310 */ 0x06ffba02 | (15 << 27) /* 0.437433251 */, + /* 1311 */ 0x07018ceb | (15 << 27) /* 0.437878533 */, + + /* 1312 */ 0x07035ff3 | (15 << 27) /* 0.438323927 */, + /* 1313 */ 0x07053319 | (15 << 27) /* 0.438769435 */, + /* 1314 */ 0x0707065d | (15 << 27) /* 0.439215056 */, + /* 1315 */ 0x0708d9c0 | (15 << 27) /* 0.439660790 */, + /* 1316 */ 0x070aad41 | (15 << 27) /* 0.440106636 */, + /* 1317 */ 0x070c80e1 | (15 << 27) /* 0.440552596 */, + /* 1318 */ 0x070e549f | (15 << 27) /* 0.440998669 */, + /* 1319 */ 0x0710287b | (15 << 27) /* 0.441444855 */, + /* 1320 */ 0x0711fc75 | (15 << 27) /* 0.441891153 */, + /* 1321 */ 0x0713d08d | (15 << 27) /* 0.442337564 */, + /* 1322 */ 0x0715a4c4 | (15 << 27) /* 0.442784088 */, + /* 1323 */ 0x07177919 | (15 << 27) /* 0.443230724 */, + /* 1324 */ 0x07194d8c | (15 << 27) /* 0.443677473 */, + /* 1325 */ 0x071b221e | (15 << 27) /* 0.444124334 */, + /* 1326 */ 0x071cf6ce | (15 << 27) /* 0.444571308 */, + /* 1327 */ 0x071ecb9b | (15 << 27) /* 0.445018394 */, + + /* 1328 */ 0x0720a087 | (15 << 27) /* 0.445465593 */, + /* 1329 */ 0x07227591 | (15 << 27) /* 0.445912903 */, + /* 1330 */ 0x07244ab9 | (15 << 27) /* 0.446360326 */, + /* 1331 */ 0x07262000 | (15 << 27) /* 0.446807861 */, + /* 1332 */ 0x0727f564 | (15 << 27) /* 0.447255509 */, + /* 1333 */ 0x0729cae7 | (15 << 27) /* 0.447703268 */, + /* 1334 */ 0x072ba087 | (15 << 27) /* 0.448151139 */, + /* 1335 */ 0x072d7646 | (15 << 27) /* 0.448599122 */, + /* 1336 */ 0x072f4c22 | (15 << 27) /* 0.449047217 */, + /* 1337 */ 0x0731221d | (15 << 27) /* 0.449495424 */, + /* 1338 */ 0x0732f835 | (15 << 27) /* 0.449943742 */, + /* 1339 */ 0x0734ce6c | (15 << 27) /* 0.450392173 */, + /* 1340 */ 0x0736a4c1 | (15 << 27) /* 0.450840715 */, + /* 1341 */ 0x07387b33 | (15 << 27) /* 0.451289368 */, + /* 1342 */ 0x073a51c4 | (15 << 27) /* 0.451738133 */, + /* 1343 */ 0x073c2872 | (15 << 27) /* 0.452187010 */, + + /* 1344 */ 0x073dff3e | (15 << 27) /* 0.452635998 */, + /* 1345 */ 0x073fd628 | (15 << 27) /* 0.453085097 */, + /* 1346 */ 0x0741ad30 | (15 << 27) /* 0.453534308 */, + /* 1347 */ 0x07438456 | (15 << 27) /* 0.453983630 */, + /* 1348 */ 0x07455b9a | (15 << 27) /* 0.454433063 */, + /* 1349 */ 0x074732fc | (15 << 27) /* 0.454882607 */, + /* 1350 */ 0x07490a7b | (15 << 27) /* 0.455332262 */, + /* 1351 */ 0x074ae218 | (15 << 27) /* 0.455782029 */, + /* 1352 */ 0x074cb9d3 | (15 << 27) /* 0.456231906 */, + /* 1353 */ 0x074e91ac | (15 << 27) /* 0.456681894 */, + /* 1354 */ 0x075069a3 | (15 << 27) /* 0.457131993 */, + /* 1355 */ 0x075241b7 | (15 << 27) /* 0.457582203 */, + /* 1356 */ 0x075419e9 | (15 << 27) /* 0.458032524 */, + /* 1357 */ 0x0755f239 | (15 << 27) /* 0.458482956 */, + /* 1358 */ 0x0757caa7 | (15 << 27) /* 0.458933498 */, + /* 1359 */ 0x0759a332 | (15 << 27) /* 0.459384151 */, + + /* 1360 */ 0x075b7bdb | (15 << 27) /* 0.459834914 */, + /* 1361 */ 0x075d54a1 | (15 << 27) /* 0.460285788 */, + /* 1362 */ 0x075f2d85 | (15 << 27) /* 0.460736772 */, + /* 1363 */ 0x07610687 | (15 << 27) /* 0.461187867 */, + /* 1364 */ 0x0762dfa6 | (15 << 27) /* 0.461639071 */, + /* 1365 */ 0x0764b8e3 | (15 << 27) /* 0.462090387 */, + /* 1366 */ 0x0766923e | (15 << 27) /* 0.462541812 */, + /* 1367 */ 0x07686bb6 | (15 << 27) /* 0.462993348 */, + /* 1368 */ 0x076a454c | (15 << 27) /* 0.463444993 */, + /* 1369 */ 0x076c1eff | (15 << 27) /* 0.463896749 */, + /* 1370 */ 0x076df8d0 | (15 << 27) /* 0.464348615 */, + /* 1371 */ 0x076fd2be | (15 << 27) /* 0.464800591 */, + /* 1372 */ 0x0771acca | (15 << 27) /* 0.465252676 */, + /* 1373 */ 0x077386f3 | (15 << 27) /* 0.465704872 */, + /* 1374 */ 0x0775613a | (15 << 27) /* 0.466157177 */, + /* 1375 */ 0x07773b9e | (15 << 27) /* 0.466609592 */, + + /* 1376 */ 0x07791620 | (15 << 27) /* 0.467062117 */, + /* 1377 */ 0x077af0bf | (15 << 27) /* 0.467514751 */, + /* 1378 */ 0x077ccb7c | (15 << 27) /* 0.467967495 */, + /* 1379 */ 0x077ea656 | (15 << 27) /* 0.468420349 */, + /* 1380 */ 0x0780814d | (15 << 27) /* 0.468873312 */, + /* 1381 */ 0x07825c62 | (15 << 27) /* 0.469326384 */, + /* 1382 */ 0x07843794 | (15 << 27) /* 0.469779566 */, + /* 1383 */ 0x078612e3 | (15 << 27) /* 0.470232857 */, + /* 1384 */ 0x0787ee50 | (15 << 27) /* 0.470686258 */, + /* 1385 */ 0x0789c9da | (15 << 27) /* 0.471139767 */, + /* 1386 */ 0x078ba581 | (15 << 27) /* 0.471593386 */, + /* 1387 */ 0x078d8146 | (15 << 27) /* 0.472047114 */, + /* 1388 */ 0x078f5d28 | (15 << 27) /* 0.472500951 */, + /* 1389 */ 0x07913927 | (15 << 27) /* 0.472954896 */, + /* 1390 */ 0x07931543 | (15 << 27) /* 0.473408951 */, + /* 1391 */ 0x0794f17d | (15 << 27) /* 0.473863115 */, + + /* 1392 */ 0x0796cdd4 | (15 << 27) /* 0.474317388 */, + /* 1393 */ 0x0798aa48 | (15 << 27) /* 0.474771769 */, + /* 1394 */ 0x079a86d9 | (15 << 27) /* 0.475226259 */, + /* 1395 */ 0x079c6388 | (15 << 27) /* 0.475680858 */, + /* 1396 */ 0x079e4053 | (15 << 27) /* 0.476135565 */, + /* 1397 */ 0x07a01d3c | (15 << 27) /* 0.476590381 */, + /* 1398 */ 0x07a1fa42 | (15 << 27) /* 0.477045306 */, + /* 1399 */ 0x07a3d765 | (15 << 27) /* 0.477500339 */, + /* 1400 */ 0x07a5b4a5 | (15 << 27) /* 0.477955481 */, + /* 1401 */ 0x07a79202 | (15 << 27) /* 0.478410731 */, + /* 1402 */ 0x07a96f7d | (15 << 27) /* 0.478866089 */, + /* 1403 */ 0x07ab4d14 | (15 << 27) /* 0.479321555 */, + /* 1404 */ 0x07ad2ac8 | (15 << 27) /* 0.479777130 */, + /* 1405 */ 0x07af089a | (15 << 27) /* 0.480232813 */, + /* 1406 */ 0x07b0e688 | (15 << 27) /* 0.480688604 */, + /* 1407 */ 0x07b2c494 | (15 << 27) /* 0.481144503 */, + + /* 1408 */ 0x07b4a2bc | (15 << 27) /* 0.481600510 */, + /* 1409 */ 0x07b68102 | (15 << 27) /* 0.482056625 */, + /* 1410 */ 0x07b85f64 | (15 << 27) /* 0.482512848 */, + /* 1411 */ 0x07ba3de4 | (15 << 27) /* 0.482969179 */, + /* 1412 */ 0x07bc1c80 | (15 << 27) /* 0.483425618 */, + /* 1413 */ 0x07bdfb39 | (15 << 27) /* 0.483882164 */, + /* 1414 */ 0x07bfda0f | (15 << 27) /* 0.484338818 */, + /* 1415 */ 0x07c1b902 | (15 << 27) /* 0.484795580 */, + /* 1416 */ 0x07c39812 | (15 << 27) /* 0.485252449 */, + /* 1417 */ 0x07c5773f | (15 << 27) /* 0.485709426 */, + /* 1418 */ 0x07c75689 | (15 << 27) /* 0.486166511 */, + /* 1419 */ 0x07c935ef | (15 << 27) /* 0.486623703 */, + /* 1420 */ 0x07cb1573 | (15 << 27) /* 0.487081002 */, + /* 1421 */ 0x07ccf513 | (15 << 27) /* 0.487538409 */, + /* 1422 */ 0x07ced4d0 | (15 << 27) /* 0.487995923 */, + /* 1423 */ 0x07d0b4aa | (15 << 27) /* 0.488453544 */, + + /* 1424 */ 0x07d294a0 | (15 << 27) /* 0.488911273 */, + /* 1425 */ 0x07d474b3 | (15 << 27) /* 0.489369108 */, + /* 1426 */ 0x07d654e4 | (15 << 27) /* 0.489827051 */, + /* 1427 */ 0x07d83530 | (15 << 27) /* 0.490285101 */, + /* 1428 */ 0x07da159a | (15 << 27) /* 0.490743258 */, + /* 1429 */ 0x07dbf620 | (15 << 27) /* 0.491201522 */, + /* 1430 */ 0x07ddd6c3 | (15 << 27) /* 0.491659892 */, + /* 1431 */ 0x07dfb783 | (15 << 27) /* 0.492118370 */, + /* 1432 */ 0x07e1985f | (15 << 27) /* 0.492576954 */, + /* 1433 */ 0x07e37958 | (15 << 27) /* 0.493035645 */, + /* 1434 */ 0x07e55a6e | (15 << 27) /* 0.493494443 */, + /* 1435 */ 0x07e73ba0 | (15 << 27) /* 0.493953348 */, + /* 1436 */ 0x07e91cef | (15 << 27) /* 0.494412359 */, + /* 1437 */ 0x07eafe5a | (15 << 27) /* 0.494871476 */, + /* 1438 */ 0x07ecdfe2 | (15 << 27) /* 0.495330701 */, + /* 1439 */ 0x07eec187 | (15 << 27) /* 0.495790031 */, + + /* 1440 */ 0x07f0a348 | (15 << 27) /* 0.496249468 */, + /* 1441 */ 0x07f28526 | (15 << 27) /* 0.496709012 */, + /* 1442 */ 0x07f46720 | (15 << 27) /* 0.497168662 */, + /* 1443 */ 0x07f64937 | (15 << 27) /* 0.497628418 */, + /* 1444 */ 0x07f82b6a | (15 << 27) /* 0.498088280 */, + /* 1445 */ 0x07fa0dba | (15 << 27) /* 0.498548248 */, + /* 1446 */ 0x07fbf026 | (15 << 27) /* 0.499008323 */, + /* 1447 */ 0x07fdd2af | (15 << 27) /* 0.499468503 */, + /* 1448 */ 0x07ffb554 | (15 << 27) /* 0.499928790 */, + /* 1449 */ 0x0400cc0b | (16 << 27) /* 0.250194591 */, + /* 1450 */ 0x0401bd7a | (16 << 27) /* 0.250424840 */, + /* 1451 */ 0x0402aef7 | (16 << 27) /* 0.250655143 */, + /* 1452 */ 0x0403a083 | (16 << 27) /* 0.250885498 */, + /* 1453 */ 0x0404921c | (16 << 27) /* 0.251115906 */, + /* 1454 */ 0x040583c4 | (16 << 27) /* 0.251346367 */, + /* 1455 */ 0x0406757a | (16 << 27) /* 0.251576880 */, + + /* 1456 */ 0x0407673f | (16 << 27) /* 0.251807447 */, + /* 1457 */ 0x04085911 | (16 << 27) /* 0.252038066 */, + /* 1458 */ 0x04094af1 | (16 << 27) /* 0.252268738 */, + /* 1459 */ 0x040a3ce0 | (16 << 27) /* 0.252499463 */, + /* 1460 */ 0x040b2edd | (16 << 27) /* 0.252730240 */, + /* 1461 */ 0x040c20e8 | (16 << 27) /* 0.252961071 */, + /* 1462 */ 0x040d1301 | (16 << 27) /* 0.253191953 */, + /* 1463 */ 0x040e0529 | (16 << 27) /* 0.253422889 */, + /* 1464 */ 0x040ef75e | (16 << 27) /* 0.253653877 */, + /* 1465 */ 0x040fe9a1 | (16 << 27) /* 0.253884918 */, + /* 1466 */ 0x0410dbf3 | (16 << 27) /* 0.254116011 */, + /* 1467 */ 0x0411ce53 | (16 << 27) /* 0.254347157 */, + /* 1468 */ 0x0412c0c1 | (16 << 27) /* 0.254578356 */, + /* 1469 */ 0x0413b33d | (16 << 27) /* 0.254809606 */, + /* 1470 */ 0x0414a5c7 | (16 << 27) /* 0.255040910 */, + /* 1471 */ 0x0415985f | (16 << 27) /* 0.255272266 */, + + /* 1472 */ 0x04168b05 | (16 << 27) /* 0.255503674 */, + /* 1473 */ 0x04177db9 | (16 << 27) /* 0.255735135 */, + /* 1474 */ 0x0418707c | (16 << 27) /* 0.255966648 */, + /* 1475 */ 0x0419634c | (16 << 27) /* 0.256198213 */, + /* 1476 */ 0x041a562a | (16 << 27) /* 0.256429831 */, + /* 1477 */ 0x041b4917 | (16 << 27) /* 0.256661501 */, + /* 1478 */ 0x041c3c11 | (16 << 27) /* 0.256893223 */, + /* 1479 */ 0x041d2f1a | (16 << 27) /* 0.257124998 */, + /* 1480 */ 0x041e2230 | (16 << 27) /* 0.257356825 */, + /* 1481 */ 0x041f1555 | (16 << 27) /* 0.257588704 */, + /* 1482 */ 0x04200888 | (16 << 27) /* 0.257820635 */, + /* 1483 */ 0x0420fbc8 | (16 << 27) /* 0.258052619 */, + /* 1484 */ 0x0421ef17 | (16 << 27) /* 0.258284654 */, + /* 1485 */ 0x0422e273 | (16 << 27) /* 0.258516742 */, + /* 1486 */ 0x0423d5de | (16 << 27) /* 0.258748882 */, + /* 1487 */ 0x0424c956 | (16 << 27) /* 0.258981074 */, + + /* 1488 */ 0x0425bcdd | (16 << 27) /* 0.259213318 */, + /* 1489 */ 0x0426b071 | (16 << 27) /* 0.259445614 */, + /* 1490 */ 0x0427a414 | (16 << 27) /* 0.259677962 */, + /* 1491 */ 0x042897c4 | (16 << 27) /* 0.259910362 */, + /* 1492 */ 0x04298b83 | (16 << 27) /* 0.260142814 */, + /* 1493 */ 0x042a7f4f | (16 << 27) /* 0.260375318 */, + /* 1494 */ 0x042b7329 | (16 << 27) /* 0.260607874 */, + /* 1495 */ 0x042c6711 | (16 << 27) /* 0.260840481 */, + /* 1496 */ 0x042d5b07 | (16 << 27) /* 0.261073141 */, + /* 1497 */ 0x042e4f0b | (16 << 27) /* 0.261305852 */, + /* 1498 */ 0x042f431d | (16 << 27) /* 0.261538616 */, + /* 1499 */ 0x0430373d | (16 << 27) /* 0.261771431 */, + /* 1500 */ 0x04312b6b | (16 << 27) /* 0.262004297 */, + /* 1501 */ 0x04321fa6 | (16 << 27) /* 0.262237216 */, + /* 1502 */ 0x043313f0 | (16 << 27) /* 0.262470186 */, + /* 1503 */ 0x04340847 | (16 << 27) /* 0.262703208 */, + + /* 1504 */ 0x0434fcad | (16 << 27) /* 0.262936282 */, + /* 1505 */ 0x0435f120 | (16 << 27) /* 0.263169407 */, + /* 1506 */ 0x0436e5a1 | (16 << 27) /* 0.263402584 */, + /* 1507 */ 0x0437da2f | (16 << 27) /* 0.263635813 */, + /* 1508 */ 0x0438cecc | (16 << 27) /* 0.263869093 */, + /* 1509 */ 0x0439c377 | (16 << 27) /* 0.264102425 */, + /* 1510 */ 0x043ab82f | (16 << 27) /* 0.264335808 */, + /* 1511 */ 0x043bacf5 | (16 << 27) /* 0.264569243 */, + /* 1512 */ 0x043ca1c9 | (16 << 27) /* 0.264802730 */, + /* 1513 */ 0x043d96ab | (16 << 27) /* 0.265036267 */, + /* 1514 */ 0x043e8b9b | (16 << 27) /* 0.265269857 */, + /* 1515 */ 0x043f8098 | (16 << 27) /* 0.265503498 */, + /* 1516 */ 0x044075a3 | (16 << 27) /* 0.265737190 */, + /* 1517 */ 0x04416abc | (16 << 27) /* 0.265970933 */, + /* 1518 */ 0x04425fe3 | (16 << 27) /* 0.266204728 */, + /* 1519 */ 0x04435518 | (16 << 27) /* 0.266438574 */, + + /* 1520 */ 0x04444a5a | (16 << 27) /* 0.266672472 */, + /* 1521 */ 0x04453fab | (16 << 27) /* 0.266906421 */, + /* 1522 */ 0x04463508 | (16 << 27) /* 0.267140421 */, + /* 1523 */ 0x04472a74 | (16 << 27) /* 0.267374472 */, + /* 1524 */ 0x04481fee | (16 << 27) /* 0.267608575 */, + /* 1525 */ 0x04491575 | (16 << 27) /* 0.267842729 */, + /* 1526 */ 0x044a0b0a | (16 << 27) /* 0.268076934 */, + /* 1527 */ 0x044b00ac | (16 << 27) /* 0.268311190 */, + /* 1528 */ 0x044bf65d | (16 << 27) /* 0.268545497 */, + /* 1529 */ 0x044cec1b | (16 << 27) /* 0.268779856 */, + /* 1530 */ 0x044de1e7 | (16 << 27) /* 0.269014265 */, + /* 1531 */ 0x044ed7c0 | (16 << 27) /* 0.269248726 */, + /* 1532 */ 0x044fcda8 | (16 << 27) /* 0.269483238 */, + /* 1533 */ 0x0450c39c | (16 << 27) /* 0.269717800 */, + /* 1534 */ 0x0451b99f | (16 << 27) /* 0.269952414 */, + /* 1535 */ 0x0452afaf | (16 << 27) /* 0.270187079 */, + + /* 1536 */ 0x0453a5cd | (16 << 27) /* 0.270421794 */, + /* 1537 */ 0x04549bf9 | (16 << 27) /* 0.270656561 */, + /* 1538 */ 0x04559232 | (16 << 27) /* 0.270891379 */, + /* 1539 */ 0x04568879 | (16 << 27) /* 0.271126247 */, + /* 1540 */ 0x04577ece | (16 << 27) /* 0.271361166 */, + /* 1541 */ 0x04587530 | (16 << 27) /* 0.271596136 */, + /* 1542 */ 0x04596ba0 | (16 << 27) /* 0.271831157 */, + /* 1543 */ 0x045a621e | (16 << 27) /* 0.272066229 */, + /* 1544 */ 0x045b58a9 | (16 << 27) /* 0.272301352 */, + /* 1545 */ 0x045c4f42 | (16 << 27) /* 0.272536525 */, + /* 1546 */ 0x045d45e9 | (16 << 27) /* 0.272771749 */, + /* 1547 */ 0x045e3c9d | (16 << 27) /* 0.273007024 */, + /* 1548 */ 0x045f335e | (16 << 27) /* 0.273242350 */, + /* 1549 */ 0x04602a2e | (16 << 27) /* 0.273477726 */, + /* 1550 */ 0x0461210b | (16 << 27) /* 0.273713153 */, + /* 1551 */ 0x046217f5 | (16 << 27) /* 0.273948630 */, + + /* 1552 */ 0x04630eed | (16 << 27) /* 0.274184158 */, + /* 1553 */ 0x046405f3 | (16 << 27) /* 0.274419737 */, + /* 1554 */ 0x0464fd06 | (16 << 27) /* 0.274655366 */, + /* 1555 */ 0x0465f427 | (16 << 27) /* 0.274891046 */, + /* 1556 */ 0x0466eb55 | (16 << 27) /* 0.275126776 */, + /* 1557 */ 0x0467e291 | (16 << 27) /* 0.275362557 */, + /* 1558 */ 0x0468d9db | (16 << 27) /* 0.275598389 */, + /* 1559 */ 0x0469d132 | (16 << 27) /* 0.275834270 */, + /* 1560 */ 0x046ac896 | (16 << 27) /* 0.276070203 */, + /* 1561 */ 0x046bc009 | (16 << 27) /* 0.276306185 */, + /* 1562 */ 0x046cb788 | (16 << 27) /* 0.276542218 */, + /* 1563 */ 0x046daf15 | (16 << 27) /* 0.276778302 */, + /* 1564 */ 0x046ea6b0 | (16 << 27) /* 0.277014435 */, + /* 1565 */ 0x046f9e58 | (16 << 27) /* 0.277250619 */, + /* 1566 */ 0x0470960e | (16 << 27) /* 0.277486854 */, + /* 1567 */ 0x04718dd1 | (16 << 27) /* 0.277723139 */, + + /* 1568 */ 0x047285a2 | (16 << 27) /* 0.277959474 */, + /* 1569 */ 0x04737d80 | (16 << 27) /* 0.278195859 */, + /* 1570 */ 0x0474756c | (16 << 27) /* 0.278432294 */, + /* 1571 */ 0x04756d65 | (16 << 27) /* 0.278668780 */, + /* 1572 */ 0x0476656b | (16 << 27) /* 0.278905316 */, + /* 1573 */ 0x04775d7f | (16 << 27) /* 0.279141902 */, + /* 1574 */ 0x047855a1 | (16 << 27) /* 0.279378538 */, + /* 1575 */ 0x04794dd0 | (16 << 27) /* 0.279615224 */, + /* 1576 */ 0x047a460c | (16 << 27) /* 0.279851960 */, + /* 1577 */ 0x047b3e56 | (16 << 27) /* 0.280088747 */, + /* 1578 */ 0x047c36ae | (16 << 27) /* 0.280325583 */, + /* 1579 */ 0x047d2f12 | (16 << 27) /* 0.280562470 */, + /* 1580 */ 0x047e2784 | (16 << 27) /* 0.280799406 */, + /* 1581 */ 0x047f2004 | (16 << 27) /* 0.281036393 */, + /* 1582 */ 0x04801891 | (16 << 27) /* 0.281273429 */, + /* 1583 */ 0x0481112b | (16 << 27) /* 0.281510516 */, + + /* 1584 */ 0x048209d3 | (16 << 27) /* 0.281747652 */, + /* 1585 */ 0x04830288 | (16 << 27) /* 0.281984838 */, + /* 1586 */ 0x0483fb4b | (16 << 27) /* 0.282222075 */, + /* 1587 */ 0x0484f41b | (16 << 27) /* 0.282459361 */, + /* 1588 */ 0x0485ecf8 | (16 << 27) /* 0.282696697 */, + /* 1589 */ 0x0486e5e3 | (16 << 27) /* 0.282934082 */, + /* 1590 */ 0x0487dedb | (16 << 27) /* 0.283171518 */, + /* 1591 */ 0x0488d7e1 | (16 << 27) /* 0.283409003 */, + /* 1592 */ 0x0489d0f4 | (16 << 27) /* 0.283646538 */, + /* 1593 */ 0x048aca14 | (16 << 27) /* 0.283884123 */, + /* 1594 */ 0x048bc341 | (16 << 27) /* 0.284121757 */, + /* 1595 */ 0x048cbc7c | (16 << 27) /* 0.284359441 */, + /* 1596 */ 0x048db5c4 | (16 << 27) /* 0.284597175 */, + /* 1597 */ 0x048eaf1a | (16 << 27) /* 0.284834959 */, + /* 1598 */ 0x048fa87d | (16 << 27) /* 0.285072792 */, + /* 1599 */ 0x0490a1ed | (16 << 27) /* 0.285310675 */, + + /* 1600 */ 0x04919b6a | (16 << 27) /* 0.285548607 */, + /* 1601 */ 0x049294f5 | (16 << 27) /* 0.285786589 */, + /* 1602 */ 0x04938e8d | (16 << 27) /* 0.286024621 */, + /* 1603 */ 0x04948833 | (16 << 27) /* 0.286262702 */, + /* 1604 */ 0x049581e5 | (16 << 27) /* 0.286500832 */, + /* 1605 */ 0x04967ba5 | (16 << 27) /* 0.286739012 */, + /* 1606 */ 0x04977573 | (16 << 27) /* 0.286977242 */, + /* 1607 */ 0x04986f4d | (16 << 27) /* 0.287215521 */, + /* 1608 */ 0x04996935 | (16 << 27) /* 0.287453849 */, + /* 1609 */ 0x049a632a | (16 << 27) /* 0.287692227 */, + /* 1610 */ 0x049b5d2c | (16 << 27) /* 0.287930654 */, + /* 1611 */ 0x049c573c | (16 << 27) /* 0.288169131 */, + /* 1612 */ 0x049d5159 | (16 << 27) /* 0.288407657 */, + /* 1613 */ 0x049e4b83 | (16 << 27) /* 0.288646232 */, + /* 1614 */ 0x049f45ba | (16 << 27) /* 0.288884857 */, + /* 1615 */ 0x04a03ffe | (16 << 27) /* 0.289123530 */, + + /* 1616 */ 0x04a13a50 | (16 << 27) /* 0.289362253 */, + /* 1617 */ 0x04a234af | (16 << 27) /* 0.289601026 */, + /* 1618 */ 0x04a32f1b | (16 << 27) /* 0.289839847 */, + /* 1619 */ 0x04a42995 | (16 << 27) /* 0.290078718 */, + /* 1620 */ 0x04a5241b | (16 << 27) /* 0.290317638 */, + /* 1621 */ 0x04a61eaf | (16 << 27) /* 0.290556607 */, + /* 1622 */ 0x04a71950 | (16 << 27) /* 0.290795626 */, + /* 1623 */ 0x04a813fe | (16 << 27) /* 0.291034693 */, + /* 1624 */ 0x04a90eba | (16 << 27) /* 0.291273810 */, + /* 1625 */ 0x04aa0982 | (16 << 27) /* 0.291512975 */, + /* 1626 */ 0x04ab0458 | (16 << 27) /* 0.291752190 */, + /* 1627 */ 0x04abff3b | (16 << 27) /* 0.291991453 */, + /* 1628 */ 0x04acfa2b | (16 << 27) /* 0.292230766 */, + /* 1629 */ 0x04adf528 | (16 << 27) /* 0.292470128 */, + /* 1630 */ 0x04aef032 | (16 << 27) /* 0.292709539 */, + /* 1631 */ 0x04afeb4a | (16 << 27) /* 0.292948998 */, + + /* 1632 */ 0x04b0e66e | (16 << 27) /* 0.293188507 */, + /* 1633 */ 0x04b1e1a0 | (16 << 27) /* 0.293428065 */, + /* 1634 */ 0x04b2dcdf | (16 << 27) /* 0.293667671 */, + /* 1635 */ 0x04b3d82b | (16 << 27) /* 0.293907326 */, + /* 1636 */ 0x04b4d384 | (16 << 27) /* 0.294147031 */, + /* 1637 */ 0x04b5ceea | (16 << 27) /* 0.294386784 */, + /* 1638 */ 0x04b6ca5e | (16 << 27) /* 0.294626585 */, + /* 1639 */ 0x04b7c5de | (16 << 27) /* 0.294866436 */, + /* 1640 */ 0x04b8c16c | (16 << 27) /* 0.295106336 */, + /* 1641 */ 0x04b9bd06 | (16 << 27) /* 0.295346284 */, + /* 1642 */ 0x04bab8ae | (16 << 27) /* 0.295586281 */, + /* 1643 */ 0x04bbb463 | (16 << 27) /* 0.295826327 */, + /* 1644 */ 0x04bcb024 | (16 << 27) /* 0.296066421 */, + /* 1645 */ 0x04bdabf3 | (16 << 27) /* 0.296306564 */, + /* 1646 */ 0x04bea7cf | (16 << 27) /* 0.296546756 */, + /* 1647 */ 0x04bfa3b8 | (16 << 27) /* 0.296786996 */, + + /* 1648 */ 0x04c09faf | (16 << 27) /* 0.297027285 */, + /* 1649 */ 0x04c19bb2 | (16 << 27) /* 0.297267623 */, + /* 1650 */ 0x04c297c2 | (16 << 27) /* 0.297508009 */, + /* 1651 */ 0x04c393df | (16 << 27) /* 0.297748444 */, + /* 1652 */ 0x04c49009 | (16 << 27) /* 0.297988927 */, + /* 1653 */ 0x04c58c41 | (16 << 27) /* 0.298229459 */, + /* 1654 */ 0x04c68885 | (16 << 27) /* 0.298470039 */, + /* 1655 */ 0x04c784d6 | (16 << 27) /* 0.298710668 */, + /* 1656 */ 0x04c88135 | (16 << 27) /* 0.298951346 */, + /* 1657 */ 0x04c97da0 | (16 << 27) /* 0.299192071 */, + /* 1658 */ 0x04ca7a18 | (16 << 27) /* 0.299432846 */, + /* 1659 */ 0x04cb769e | (16 << 27) /* 0.299673668 */, + /* 1660 */ 0x04cc7330 | (16 << 27) /* 0.299914539 */, + /* 1661 */ 0x04cd6fcf | (16 << 27) /* 0.300155459 */, + /* 1662 */ 0x04ce6c7b | (16 << 27) /* 0.300396426 */, + /* 1663 */ 0x04cf6935 | (16 << 27) /* 0.300637443 */, + + /* 1664 */ 0x04d065fb | (16 << 27) /* 0.300878507 */, + /* 1665 */ 0x04d162ce | (16 << 27) /* 0.301119620 */, + /* 1666 */ 0x04d25fae | (16 << 27) /* 0.301360781 */, + /* 1667 */ 0x04d35c9b | (16 << 27) /* 0.301601990 */, + /* 1668 */ 0x04d45995 | (16 << 27) /* 0.301843247 */, + /* 1669 */ 0x04d5569c | (16 << 27) /* 0.302084553 */, + /* 1670 */ 0x04d653b0 | (16 << 27) /* 0.302325907 */, + /* 1671 */ 0x04d750d1 | (16 << 27) /* 0.302567309 */, + /* 1672 */ 0x04d84dff | (16 << 27) /* 0.302808759 */, + /* 1673 */ 0x04d94b3a | (16 << 27) /* 0.303050257 */, + /* 1674 */ 0x04da4881 | (16 << 27) /* 0.303291804 */, + /* 1675 */ 0x04db45d6 | (16 << 27) /* 0.303533399 */, + /* 1676 */ 0x04dc4337 | (16 << 27) /* 0.303775041 */, + /* 1677 */ 0x04dd40a6 | (16 << 27) /* 0.304016732 */, + /* 1678 */ 0x04de3e21 | (16 << 27) /* 0.304258471 */, + /* 1679 */ 0x04df3ba9 | (16 << 27) /* 0.304500257 */, + + /* 1680 */ 0x04e0393e | (16 << 27) /* 0.304742092 */, + /* 1681 */ 0x04e136e0 | (16 << 27) /* 0.304983975 */, + /* 1682 */ 0x04e2348f | (16 << 27) /* 0.305225906 */, + /* 1683 */ 0x04e3324b | (16 << 27) /* 0.305467885 */, + /* 1684 */ 0x04e43013 | (16 << 27) /* 0.305709911 */, + /* 1685 */ 0x04e52de9 | (16 << 27) /* 0.305951986 */, + /* 1686 */ 0x04e62bcb | (16 << 27) /* 0.306194108 */, + /* 1687 */ 0x04e729ba | (16 << 27) /* 0.306436279 */, + /* 1688 */ 0x04e827b6 | (16 << 27) /* 0.306678497 */, + /* 1689 */ 0x04e925bf | (16 << 27) /* 0.306920763 */, + /* 1690 */ 0x04ea23d4 | (16 << 27) /* 0.307163077 */, + /* 1691 */ 0x04eb21f7 | (16 << 27) /* 0.307405438 */, + /* 1692 */ 0x04ec2026 | (16 << 27) /* 0.307647848 */, + /* 1693 */ 0x04ed1e62 | (16 << 27) /* 0.307890305 */, + /* 1694 */ 0x04ee1cab | (16 << 27) /* 0.308132810 */, + /* 1695 */ 0x04ef1b01 | (16 << 27) /* 0.308375362 */, + + /* 1696 */ 0x04f01963 | (16 << 27) /* 0.308617963 */, + /* 1697 */ 0x04f117d3 | (16 << 27) /* 0.308860611 */, + /* 1698 */ 0x04f2164f | (16 << 27) /* 0.309103306 */, + /* 1699 */ 0x04f314d8 | (16 << 27) /* 0.309346050 */, + /* 1700 */ 0x04f4136d | (16 << 27) /* 0.309588841 */, + /* 1701 */ 0x04f51210 | (16 << 27) /* 0.309831679 */, + /* 1702 */ 0x04f610bf | (16 << 27) /* 0.310074565 */, + /* 1703 */ 0x04f70f7b | (16 << 27) /* 0.310317499 */, + /* 1704 */ 0x04f80e44 | (16 << 27) /* 0.310560480 */, + /* 1705 */ 0x04f90d19 | (16 << 27) /* 0.310803509 */, + /* 1706 */ 0x04fa0bfc | (16 << 27) /* 0.311046586 */, + /* 1707 */ 0x04fb0aeb | (16 << 27) /* 0.311289710 */, + /* 1708 */ 0x04fc09e7 | (16 << 27) /* 0.311532881 */, + /* 1709 */ 0x04fd08ef | (16 << 27) /* 0.311776100 */, + /* 1710 */ 0x04fe0805 | (16 << 27) /* 0.312019366 */, + /* 1711 */ 0x04ff0727 | (16 << 27) /* 0.312262680 */, + + /* 1712 */ 0x05000655 | (16 << 27) /* 0.312506041 */, + /* 1713 */ 0x05010591 | (16 << 27) /* 0.312749449 */, + /* 1714 */ 0x050204d9 | (16 << 27) /* 0.312992905 */, + /* 1715 */ 0x0503042e | (16 << 27) /* 0.313236408 */, + /* 1716 */ 0x0504038f | (16 << 27) /* 0.313479959 */, + /* 1717 */ 0x050502fe | (16 << 27) /* 0.313723556 */, + /* 1718 */ 0x05060279 | (16 << 27) /* 0.313967202 */, + /* 1719 */ 0x05070200 | (16 << 27) /* 0.314210894 */, + /* 1720 */ 0x05080195 | (16 << 27) /* 0.314454634 */, + /* 1721 */ 0x05090136 | (16 << 27) /* 0.314698420 */, + /* 1722 */ 0x050a00e3 | (16 << 27) /* 0.314942255 */, + /* 1723 */ 0x050b009e | (16 << 27) /* 0.315186136 */, + /* 1724 */ 0x050c0065 | (16 << 27) /* 0.315430064 */, + /* 1725 */ 0x050d0039 | (16 << 27) /* 0.315674040 */, + /* 1726 */ 0x050e0019 | (16 << 27) /* 0.315918063 */, + /* 1727 */ 0x050f0006 | (16 << 27) /* 0.316162133 */, + + /* 1728 */ 0x05100000 | (16 << 27) /* 0.316406250 */, + /* 1729 */ 0x05110006 | (16 << 27) /* 0.316650414 */, + /* 1730 */ 0x05120019 | (16 << 27) /* 0.316894625 */, + /* 1731 */ 0x05130039 | (16 << 27) /* 0.317138884 */, + /* 1732 */ 0x05140065 | (16 << 27) /* 0.317383189 */, + /* 1733 */ 0x0515009e | (16 << 27) /* 0.317627541 */, + /* 1734 */ 0x051600e3 | (16 << 27) /* 0.317871941 */, + /* 1735 */ 0x05170135 | (16 << 27) /* 0.318116387 */, + /* 1736 */ 0x05180194 | (16 << 27) /* 0.318360880 */, + /* 1737 */ 0x051901ff | (16 << 27) /* 0.318605421 */, + /* 1738 */ 0x051a0277 | (16 << 27) /* 0.318850008 */, + /* 1739 */ 0x051b02fc | (16 << 27) /* 0.319094642 */, + /* 1740 */ 0x051c038d | (16 << 27) /* 0.319339323 */, + /* 1741 */ 0x051d042a | (16 << 27) /* 0.319584051 */, + /* 1742 */ 0x051e04d4 | (16 << 27) /* 0.319828826 */, + /* 1743 */ 0x051f058b | (16 << 27) /* 0.320073647 */, + + /* 1744 */ 0x0520064f | (16 << 27) /* 0.320318516 */, + /* 1745 */ 0x0521071f | (16 << 27) /* 0.320563431 */, + /* 1746 */ 0x052207fb | (16 << 27) /* 0.320808393 */, + /* 1747 */ 0x052308e4 | (16 << 27) /* 0.321053402 */, + /* 1748 */ 0x052409da | (16 << 27) /* 0.321298457 */, + /* 1749 */ 0x05250adc | (16 << 27) /* 0.321543560 */, + /* 1750 */ 0x05260bea | (16 << 27) /* 0.321788709 */, + /* 1751 */ 0x05270d06 | (16 << 27) /* 0.322033904 */, + /* 1752 */ 0x05280e2d | (16 << 27) /* 0.322279147 */, + /* 1753 */ 0x05290f62 | (16 << 27) /* 0.322524436 */, + /* 1754 */ 0x052a10a3 | (16 << 27) /* 0.322769771 */, + /* 1755 */ 0x052b11f0 | (16 << 27) /* 0.323015154 */, + /* 1756 */ 0x052c134a | (16 << 27) /* 0.323260583 */, + /* 1757 */ 0x052d14b0 | (16 << 27) /* 0.323506058 */, + /* 1758 */ 0x052e1623 | (16 << 27) /* 0.323751580 */, + /* 1759 */ 0x052f17a2 | (16 << 27) /* 0.323997149 */, + + /* 1760 */ 0x0530192e | (16 << 27) /* 0.324242764 */, + /* 1761 */ 0x05311ac6 | (16 << 27) /* 0.324488426 */, + /* 1762 */ 0x05321c6b | (16 << 27) /* 0.324734134 */, + /* 1763 */ 0x05331e1c | (16 << 27) /* 0.324979889 */, + /* 1764 */ 0x05341fda | (16 << 27) /* 0.325225690 */, + /* 1765 */ 0x053521a4 | (16 << 27) /* 0.325471538 */, + /* 1766 */ 0x0536237b | (16 << 27) /* 0.325717432 */, + /* 1767 */ 0x0537255e | (16 << 27) /* 0.325963372 */, + /* 1768 */ 0x0538274e | (16 << 27) /* 0.326209359 */, + /* 1769 */ 0x0539294a | (16 << 27) /* 0.326455392 */, + /* 1770 */ 0x053a2b52 | (16 << 27) /* 0.326701472 */, + /* 1771 */ 0x053b2d67 | (16 << 27) /* 0.326947598 */, + /* 1772 */ 0x053c2f89 | (16 << 27) /* 0.327193770 */, + /* 1773 */ 0x053d31b6 | (16 << 27) /* 0.327439989 */, + /* 1774 */ 0x053e33f1 | (16 << 27) /* 0.327686254 */, + /* 1775 */ 0x053f3637 | (16 << 27) /* 0.327932565 */, + + /* 1776 */ 0x0540388a | (16 << 27) /* 0.328178922 */, + /* 1777 */ 0x05413aea | (16 << 27) /* 0.328425326 */, + /* 1778 */ 0x05423d56 | (16 << 27) /* 0.328671776 */, + /* 1779 */ 0x05433fce | (16 << 27) /* 0.328918272 */, + /* 1780 */ 0x05444253 | (16 << 27) /* 0.329164814 */, + /* 1781 */ 0x054544e4 | (16 << 27) /* 0.329411403 */, + /* 1782 */ 0x05464781 | (16 << 27) /* 0.329658038 */, + /* 1783 */ 0x05474a2b | (16 << 27) /* 0.329904718 */, + /* 1784 */ 0x05484ce2 | (16 << 27) /* 0.330151445 */, + /* 1785 */ 0x05494fa4 | (16 << 27) /* 0.330398218 */, + /* 1786 */ 0x054a5273 | (16 << 27) /* 0.330645037 */, + /* 1787 */ 0x054b554e | (16 << 27) /* 0.330891903 */, + /* 1788 */ 0x054c5836 | (16 << 27) /* 0.331138814 */, + /* 1789 */ 0x054d5b2a | (16 << 27) /* 0.331385771 */, + /* 1790 */ 0x054e5e2b | (16 << 27) /* 0.331632774 */, + /* 1791 */ 0x054f6138 | (16 << 27) /* 0.331879824 */, + + /* 1792 */ 0x05506451 | (16 << 27) /* 0.332126919 */, + /* 1793 */ 0x05516776 | (16 << 27) /* 0.332374060 */, + /* 1794 */ 0x05526aa8 | (16 << 27) /* 0.332621247 */, + /* 1795 */ 0x05536de6 | (16 << 27) /* 0.332868480 */, + /* 1796 */ 0x05547131 | (16 << 27) /* 0.333115759 */, + /* 1797 */ 0x05557487 | (16 << 27) /* 0.333363084 */, + /* 1798 */ 0x055677ea | (16 << 27) /* 0.333610455 */, + /* 1799 */ 0x05577b5a | (16 << 27) /* 0.333857872 */, + /* 1800 */ 0x05587ed5 | (16 << 27) /* 0.334105334 */, + /* 1801 */ 0x0559825e | (16 << 27) /* 0.334352843 */, + /* 1802 */ 0x055a85f2 | (16 << 27) /* 0.334600397 */, + /* 1803 */ 0x055b8992 | (16 << 27) /* 0.334847997 */, + /* 1804 */ 0x055c8d3f | (16 << 27) /* 0.335095642 */, + /* 1805 */ 0x055d90f9 | (16 << 27) /* 0.335343334 */, + /* 1806 */ 0x055e94be | (16 << 27) /* 0.335591071 */, + /* 1807 */ 0x055f9890 | (16 << 27) /* 0.335838854 */, + + /* 1808 */ 0x05609c6e | (16 << 27) /* 0.336086683 */, + /* 1809 */ 0x0561a058 | (16 << 27) /* 0.336334557 */, + /* 1810 */ 0x0562a44f | (16 << 27) /* 0.336582477 */, + /* 1811 */ 0x0563a851 | (16 << 27) /* 0.336830443 */, + /* 1812 */ 0x0564ac60 | (16 << 27) /* 0.337078454 */, + /* 1813 */ 0x0565b07c | (16 << 27) /* 0.337326511 */, + /* 1814 */ 0x0566b4a3 | (16 << 27) /* 0.337574614 */, + /* 1815 */ 0x0567b8d7 | (16 << 27) /* 0.337822762 */, + /* 1816 */ 0x0568bd17 | (16 << 27) /* 0.338070956 */, + /* 1817 */ 0x0569c163 | (16 << 27) /* 0.338319195 */, + /* 1818 */ 0x056ac5bc | (16 << 27) /* 0.338567480 */, + /* 1819 */ 0x056bca20 | (16 << 27) /* 0.338815811 */, + /* 1820 */ 0x056cce91 | (16 << 27) /* 0.339064186 */, + /* 1821 */ 0x056dd30e | (16 << 27) /* 0.339312608 */, + /* 1822 */ 0x056ed798 | (16 << 27) /* 0.339561075 */, + /* 1823 */ 0x056fdc2d | (16 << 27) /* 0.339809587 */, + + /* 1824 */ 0x0570e0cf | (16 << 27) /* 0.340058145 */, + /* 1825 */ 0x0571e57d | (16 << 27) /* 0.340306748 */, + /* 1826 */ 0x0572ea37 | (16 << 27) /* 0.340555397 */, + /* 1827 */ 0x0573eefd | (16 << 27) /* 0.340804091 */, + /* 1828 */ 0x0574f3d0 | (16 << 27) /* 0.341052830 */, + /* 1829 */ 0x0575f8ae | (16 << 27) /* 0.341301615 */, + /* 1830 */ 0x0576fd99 | (16 << 27) /* 0.341550445 */, + /* 1831 */ 0x05780290 | (16 << 27) /* 0.341799321 */, + /* 1832 */ 0x05790793 | (16 << 27) /* 0.342048241 */, + /* 1833 */ 0x057a0ca3 | (16 << 27) /* 0.342297207 */, + /* 1834 */ 0x057b11be | (16 << 27) /* 0.342546219 */, + /* 1835 */ 0x057c16e6 | (16 << 27) /* 0.342795275 */, + /* 1836 */ 0x057d1c1a | (16 << 27) /* 0.343044377 */, + /* 1837 */ 0x057e2159 | (16 << 27) /* 0.343293524 */, + /* 1838 */ 0x057f26a6 | (16 << 27) /* 0.343542717 */, + /* 1839 */ 0x05802bfe | (16 << 27) /* 0.343791954 */, + + /* 1840 */ 0x05813162 | (16 << 27) /* 0.344041237 */, + /* 1841 */ 0x058236d2 | (16 << 27) /* 0.344290564 */, + /* 1842 */ 0x05833c4f | (16 << 27) /* 0.344539937 */, + /* 1843 */ 0x058441d8 | (16 << 27) /* 0.344789356 */, + /* 1844 */ 0x0585476c | (16 << 27) /* 0.345038819 */, + /* 1845 */ 0x05864d0d | (16 << 27) /* 0.345288327 */, + /* 1846 */ 0x058752ba | (16 << 27) /* 0.345537880 */, + /* 1847 */ 0x05885873 | (16 << 27) /* 0.345787479 */, + /* 1848 */ 0x05895e39 | (16 << 27) /* 0.346037122 */, + /* 1849 */ 0x058a640a | (16 << 27) /* 0.346286811 */, + /* 1850 */ 0x058b69e7 | (16 << 27) /* 0.346536545 */, + /* 1851 */ 0x058c6fd1 | (16 << 27) /* 0.346786323 */, + /* 1852 */ 0x058d75c6 | (16 << 27) /* 0.347036147 */, + /* 1853 */ 0x058e7bc8 | (16 << 27) /* 0.347286015 */, + /* 1854 */ 0x058f81d5 | (16 << 27) /* 0.347535929 */, + /* 1855 */ 0x059087ef | (16 << 27) /* 0.347785887 */, + + /* 1856 */ 0x05918e15 | (16 << 27) /* 0.348035890 */, + /* 1857 */ 0x05929447 | (16 << 27) /* 0.348285939 */, + /* 1858 */ 0x05939a84 | (16 << 27) /* 0.348536032 */, + /* 1859 */ 0x0594a0ce | (16 << 27) /* 0.348786170 */, + /* 1860 */ 0x0595a724 | (16 << 27) /* 0.349036353 */, + /* 1861 */ 0x0596ad86 | (16 << 27) /* 0.349286580 */, + /* 1862 */ 0x0597b3f4 | (16 << 27) /* 0.349536853 */, + /* 1863 */ 0x0598ba6e | (16 << 27) /* 0.349787170 */, + /* 1864 */ 0x0599c0f4 | (16 << 27) /* 0.350037532 */, + /* 1865 */ 0x059ac786 | (16 << 27) /* 0.350287939 */, + /* 1866 */ 0x059bce25 | (16 << 27) /* 0.350538391 */, + /* 1867 */ 0x059cd4cf | (16 << 27) /* 0.350788887 */, + /* 1868 */ 0x059ddb85 | (16 << 27) /* 0.351039428 */, + /* 1869 */ 0x059ee247 | (16 << 27) /* 0.351290014 */, + /* 1870 */ 0x059fe915 | (16 << 27) /* 0.351540645 */, + /* 1871 */ 0x05a0efef | (16 << 27) /* 0.351791320 */, + + /* 1872 */ 0x05a1f6d5 | (16 << 27) /* 0.352042040 */, + /* 1873 */ 0x05a2fdc7 | (16 << 27) /* 0.352292804 */, + /* 1874 */ 0x05a404c5 | (16 << 27) /* 0.352543613 */, + /* 1875 */ 0x05a50bcf | (16 << 27) /* 0.352794467 */, + /* 1876 */ 0x05a612e5 | (16 << 27) /* 0.353045365 */, + /* 1877 */ 0x05a71a07 | (16 << 27) /* 0.353296308 */, + /* 1878 */ 0x05a82135 | (16 << 27) /* 0.353547296 */, + /* 1879 */ 0x05a9286f | (16 << 27) /* 0.353798328 */, + /* 1880 */ 0x05aa2fb5 | (16 << 27) /* 0.354049405 */, + /* 1881 */ 0x05ab3707 | (16 << 27) /* 0.354300526 */, + /* 1882 */ 0x05ac3e65 | (16 << 27) /* 0.354551691 */, + /* 1883 */ 0x05ad45ce | (16 << 27) /* 0.354802901 */, + /* 1884 */ 0x05ae4d44 | (16 << 27) /* 0.355054156 */, + /* 1885 */ 0x05af54c6 | (16 << 27) /* 0.355305455 */, + /* 1886 */ 0x05b05c53 | (16 << 27) /* 0.355556799 */, + /* 1887 */ 0x05b163ed | (16 << 27) /* 0.355808187 */, + + /* 1888 */ 0x05b26b92 | (16 << 27) /* 0.356059619 */, + /* 1889 */ 0x05b37343 | (16 << 27) /* 0.356311096 */, + /* 1890 */ 0x05b47b00 | (16 << 27) /* 0.356562617 */, + /* 1891 */ 0x05b582c9 | (16 << 27) /* 0.356814182 */, + /* 1892 */ 0x05b68a9e | (16 << 27) /* 0.357065792 */, + /* 1893 */ 0x05b7927f | (16 << 27) /* 0.357317446 */, + /* 1894 */ 0x05b89a6c | (16 << 27) /* 0.357569145 */, + /* 1895 */ 0x05b9a265 | (16 << 27) /* 0.357820887 */, + /* 1896 */ 0x05baaa69 | (16 << 27) /* 0.358072674 */, + /* 1897 */ 0x05bbb27a | (16 << 27) /* 0.358324506 */, + /* 1898 */ 0x05bcba96 | (16 << 27) /* 0.358576381 */, + /* 1899 */ 0x05bdc2be | (16 << 27) /* 0.358828301 */, + /* 1900 */ 0x05becaf2 | (16 << 27) /* 0.359080265 */, + /* 1901 */ 0x05bfd332 | (16 << 27) /* 0.359332273 */, + /* 1902 */ 0x05c0db7e | (16 << 27) /* 0.359584326 */, + /* 1903 */ 0x05c1e3d6 | (16 << 27) /* 0.359836423 */, + + /* 1904 */ 0x05c2ec39 | (16 << 27) /* 0.360088563 */, + /* 1905 */ 0x05c3f4a9 | (16 << 27) /* 0.360340748 */, + /* 1906 */ 0x05c4fd24 | (16 << 27) /* 0.360592977 */, + /* 1907 */ 0x05c605ab | (16 << 27) /* 0.360845251 */, + /* 1908 */ 0x05c70e3e | (16 << 27) /* 0.361097568 */, + /* 1909 */ 0x05c816dd | (16 << 27) /* 0.361349929 */, + /* 1910 */ 0x05c91f87 | (16 << 27) /* 0.361602335 */, + /* 1911 */ 0x05ca283e | (16 << 27) /* 0.361854784 */, + /* 1912 */ 0x05cb3100 | (16 << 27) /* 0.362107278 */, + /* 1913 */ 0x05cc39ce | (16 << 27) /* 0.362359815 */, + /* 1914 */ 0x05cd42a8 | (16 << 27) /* 0.362612397 */, + /* 1915 */ 0x05ce4b8d | (16 << 27) /* 0.362865022 */, + /* 1916 */ 0x05cf547f | (16 << 27) /* 0.363117692 */, + /* 1917 */ 0x05d05d7c | (16 << 27) /* 0.363370405 */, + /* 1918 */ 0x05d16685 | (16 << 27) /* 0.363623163 */, + /* 1919 */ 0x05d26f9a | (16 << 27) /* 0.363875964 */, + + /* 1920 */ 0x05d378bb | (16 << 27) /* 0.364128809 */, + /* 1921 */ 0x05d481e7 | (16 << 27) /* 0.364381698 */, + /* 1922 */ 0x05d58b1f | (16 << 27) /* 0.364634632 */, + /* 1923 */ 0x05d69463 | (16 << 27) /* 0.364887608 */, + /* 1924 */ 0x05d79db3 | (16 << 27) /* 0.365140629 */, + /* 1925 */ 0x05d8a70f | (16 << 27) /* 0.365393694 */, + /* 1926 */ 0x05d9b076 | (16 << 27) /* 0.365646802 */, + /* 1927 */ 0x05dab9e9 | (16 << 27) /* 0.365899955 */, + /* 1928 */ 0x05dbc368 | (16 << 27) /* 0.366153151 */, + /* 1929 */ 0x05dcccf2 | (16 << 27) /* 0.366406390 */, + /* 1930 */ 0x05ddd689 | (16 << 27) /* 0.366659674 */, + /* 1931 */ 0x05dee02b | (16 << 27) /* 0.366913001 */, + /* 1932 */ 0x05dfe9d8 | (16 << 27) /* 0.367166372 */, + /* 1933 */ 0x05e0f392 | (16 << 27) /* 0.367419787 */, + /* 1934 */ 0x05e1fd57 | (16 << 27) /* 0.367673246 */, + /* 1935 */ 0x05e30728 | (16 << 27) /* 0.367926748 */, + + /* 1936 */ 0x05e41105 | (16 << 27) /* 0.368180294 */, + /* 1937 */ 0x05e51aed | (16 << 27) /* 0.368433883 */, + /* 1938 */ 0x05e624e1 | (16 << 27) /* 0.368687517 */, + /* 1939 */ 0x05e72ee1 | (16 << 27) /* 0.368941193 */, + /* 1940 */ 0x05e838ed | (16 << 27) /* 0.369194914 */, + /* 1941 */ 0x05e94304 | (16 << 27) /* 0.369448678 */, + /* 1942 */ 0x05ea4d27 | (16 << 27) /* 0.369702485 */, + /* 1943 */ 0x05eb5756 | (16 << 27) /* 0.369956336 */, + /* 1944 */ 0x05ec6190 | (16 << 27) /* 0.370210231 */, + /* 1945 */ 0x05ed6bd6 | (16 << 27) /* 0.370464169 */, + /* 1946 */ 0x05ee7628 | (16 << 27) /* 0.370718151 */, + /* 1947 */ 0x05ef8085 | (16 << 27) /* 0.370972177 */, + /* 1948 */ 0x05f08aee | (16 << 27) /* 0.371226245 */, + /* 1949 */ 0x05f19563 | (16 << 27) /* 0.371480358 */, + /* 1950 */ 0x05f29fe3 | (16 << 27) /* 0.371734513 */, + /* 1951 */ 0x05f3aa6f | (16 << 27) /* 0.371988712 */, + + /* 1952 */ 0x05f4b507 | (16 << 27) /* 0.372242955 */, + /* 1953 */ 0x05f5bfab | (16 << 27) /* 0.372497241 */, + /* 1954 */ 0x05f6ca5a | (16 << 27) /* 0.372751570 */, + /* 1955 */ 0x05f7d514 | (16 << 27) /* 0.373005943 */, + /* 1956 */ 0x05f8dfdb | (16 << 27) /* 0.373260359 */, + /* 1957 */ 0x05f9eaad | (16 << 27) /* 0.373514819 */, + /* 1958 */ 0x05faf58a | (16 << 27) /* 0.373769322 */, + /* 1959 */ 0x05fc0073 | (16 << 27) /* 0.374023868 */, + /* 1960 */ 0x05fd0b68 | (16 << 27) /* 0.374278458 */, + /* 1961 */ 0x05fe1669 | (16 << 27) /* 0.374533091 */, + /* 1962 */ 0x05ff2175 | (16 << 27) /* 0.374787767 */, + /* 1963 */ 0x06002c8d | (16 << 27) /* 0.375042486 */, + /* 1964 */ 0x060137b0 | (16 << 27) /* 0.375297249 */, + /* 1965 */ 0x060242df | (16 << 27) /* 0.375552055 */, + /* 1966 */ 0x06034e19 | (16 << 27) /* 0.375806904 */, + /* 1967 */ 0x0604595f | (16 << 27) /* 0.376061796 */, + + /* 1968 */ 0x060564b1 | (16 << 27) /* 0.376316732 */, + /* 1969 */ 0x0606700f | (16 << 27) /* 0.376571710 */, + /* 1970 */ 0x06077b77 | (16 << 27) /* 0.376826732 */, + /* 1971 */ 0x060886ec | (16 << 27) /* 0.377081797 */, + /* 1972 */ 0x0609926c | (16 << 27) /* 0.377336905 */, + /* 1973 */ 0x060a9df8 | (16 << 27) /* 0.377592057 */, + /* 1974 */ 0x060ba98f | (16 << 27) /* 0.377847251 */, + /* 1975 */ 0x060cb532 | (16 << 27) /* 0.378102489 */, + /* 1976 */ 0x060dc0e0 | (16 << 27) /* 0.378357769 */, + /* 1977 */ 0x060ecc9a | (16 << 27) /* 0.378613093 */, + /* 1978 */ 0x060fd860 | (16 << 27) /* 0.378868460 */, + /* 1979 */ 0x0610e431 | (16 << 27) /* 0.379123870 */, + /* 1980 */ 0x0611f00d | (16 << 27) /* 0.379379322 */, + /* 1981 */ 0x0612fbf5 | (16 << 27) /* 0.379634818 */, + /* 1982 */ 0x061407e9 | (16 << 27) /* 0.379890357 */, + /* 1983 */ 0x061513e8 | (16 << 27) /* 0.380145939 */, + + /* 1984 */ 0x06161ff3 | (16 << 27) /* 0.380401563 */, + /* 1985 */ 0x06172c09 | (16 << 27) /* 0.380657231 */, + /* 1986 */ 0x0618382b | (16 << 27) /* 0.380912942 */, + /* 1987 */ 0x06194458 | (16 << 27) /* 0.381168695 */, + /* 1988 */ 0x061a5091 | (16 << 27) /* 0.381424492 */, + /* 1989 */ 0x061b5cd5 | (16 << 27) /* 0.381680331 */, + /* 1990 */ 0x061c6925 | (16 << 27) /* 0.381936213 */, + /* 1991 */ 0x061d7581 | (16 << 27) /* 0.382192138 */, + /* 1992 */ 0x061e81e8 | (16 << 27) /* 0.382448106 */, + /* 1993 */ 0x061f8e5a | (16 << 27) /* 0.382704117 */, + /* 1994 */ 0x06209ad8 | (16 << 27) /* 0.382960171 */, + /* 1995 */ 0x0621a761 | (16 << 27) /* 0.383216267 */, + /* 1996 */ 0x0622b3f6 | (16 << 27) /* 0.383472406 */, + /* 1997 */ 0x0623c096 | (16 << 27) /* 0.383728588 */, + /* 1998 */ 0x0624cd42 | (16 << 27) /* 0.383984813 */, + /* 1999 */ 0x0625d9f9 | (16 << 27) /* 0.384241080 */, + + /* 2000 */ 0x0626e6bc | (16 << 27) /* 0.384497391 */, + /* 2001 */ 0x0627f38a | (16 << 27) /* 0.384753744 */, + /* 2002 */ 0x06290064 | (16 << 27) /* 0.385010139 */, + /* 2003 */ 0x062a0d49 | (16 << 27) /* 0.385266578 */, + /* 2004 */ 0x062b1a3a | (16 << 27) /* 0.385523059 */, + /* 2005 */ 0x062c2736 | (16 << 27) /* 0.385779582 */, + /* 2006 */ 0x062d343d | (16 << 27) /* 0.386036149 */, + /* 2007 */ 0x062e4150 | (16 << 27) /* 0.386292758 */, + /* 2008 */ 0x062f4e6f | (16 << 27) /* 0.386549409 */, + /* 2009 */ 0x06305b99 | (16 << 27) /* 0.386806104 */, + /* 2010 */ 0x063168ce | (16 << 27) /* 0.387062840 */, + /* 2011 */ 0x0632760f | (16 << 27) /* 0.387319620 */, + /* 2012 */ 0x0633835b | (16 << 27) /* 0.387576442 */, + /* 2013 */ 0x063490b2 | (16 << 27) /* 0.387833306 */, + /* 2014 */ 0x06359e15 | (16 << 27) /* 0.388090213 */, + /* 2015 */ 0x0636ab83 | (16 << 27) /* 0.388347163 */, + + /* 2016 */ 0x0637b8fd | (16 << 27) /* 0.388604155 */, + /* 2017 */ 0x0638c682 | (16 << 27) /* 0.388861190 */, + /* 2018 */ 0x0639d413 | (16 << 27) /* 0.389118267 */, + /* 2019 */ 0x063ae1af | (16 << 27) /* 0.389375386 */, + /* 2020 */ 0x063bef56 | (16 << 27) /* 0.389632548 */, + /* 2021 */ 0x063cfd09 | (16 << 27) /* 0.389889752 */, + /* 2022 */ 0x063e0ac7 | (16 << 27) /* 0.390146999 */, + /* 2023 */ 0x063f1891 | (16 << 27) /* 0.390404289 */, + /* 2024 */ 0x06402666 | (16 << 27) /* 0.390661620 */, + /* 2025 */ 0x06413446 | (16 << 27) /* 0.390918994 */, + /* 2026 */ 0x06424232 | (16 << 27) /* 0.391176411 */, + /* 2027 */ 0x06435029 | (16 << 27) /* 0.391433869 */, + /* 2028 */ 0x06445e2b | (16 << 27) /* 0.391691371 */, + /* 2029 */ 0x06456c39 | (16 << 27) /* 0.391948914 */, + /* 2030 */ 0x06467a52 | (16 << 27) /* 0.392206500 */, + /* 2031 */ 0x06478877 | (16 << 27) /* 0.392464128 */, + + /* 2032 */ 0x064896a7 | (16 << 27) /* 0.392721798 */, + /* 2033 */ 0x0649a4e2 | (16 << 27) /* 0.392979511 */, + /* 2034 */ 0x064ab328 | (16 << 27) /* 0.393237266 */, + /* 2035 */ 0x064bc17a | (16 << 27) /* 0.393495063 */, + /* 2036 */ 0x064ccfd8 | (16 << 27) /* 0.393752902 */, + /* 2037 */ 0x064dde40 | (16 << 27) /* 0.394010784 */, + /* 2038 */ 0x064eecb4 | (16 << 27) /* 0.394268707 */, + /* 2039 */ 0x064ffb33 | (16 << 27) /* 0.394526673 */, + /* 2040 */ 0x065109be | (16 << 27) /* 0.394784681 */, + /* 2041 */ 0x06521854 | (16 << 27) /* 0.395042732 */, + /* 2042 */ 0x065326f5 | (16 << 27) /* 0.395300824 */, + /* 2043 */ 0x065435a1 | (16 << 27) /* 0.395558959 */, + /* 2044 */ 0x06554459 | (16 << 27) /* 0.395817135 */, + /* 2045 */ 0x0656531c | (16 << 27) /* 0.396075354 */, + /* 2046 */ 0x065761ea | (16 << 27) /* 0.396333615 */, + /* 2047 */ 0x065870c4 | (16 << 27) /* 0.396591918 */, + + /* 2048 */ 0x06597fa9 | (16 << 27) /* 0.396850263 */, + /* 2049 */ 0x065a8e99 | (16 << 27) /* 0.397108650 */, + /* 2050 */ 0x065b9d95 | (16 << 27) /* 0.397367079 */, + /* 2051 */ 0x065cac9c | (16 << 27) /* 0.397625550 */, + /* 2052 */ 0x065dbbae | (16 << 27) /* 0.397884063 */, + /* 2053 */ 0x065ecacb | (16 << 27) /* 0.398142619 */, + /* 2054 */ 0x065fd9f4 | (16 << 27) /* 0.398401216 */, + /* 2055 */ 0x0660e928 | (16 << 27) /* 0.398659855 */, + /* 2056 */ 0x0661f867 | (16 << 27) /* 0.398918536 */, + /* 2057 */ 0x066307b1 | (16 << 27) /* 0.399177259 */, + /* 2058 */ 0x06641707 | (16 << 27) /* 0.399436024 */, + /* 2059 */ 0x06652668 | (16 << 27) /* 0.399694831 */, + /* 2060 */ 0x066635d4 | (16 << 27) /* 0.399953679 */, + /* 2061 */ 0x0667454c | (16 << 27) /* 0.400212570 */, + /* 2062 */ 0x066854ce | (16 << 27) /* 0.400471503 */, + /* 2063 */ 0x0669645c | (16 << 27) /* 0.400730477 */, + + /* 2064 */ 0x066a73f5 | (16 << 27) /* 0.400989493 */, + /* 2065 */ 0x066b839a | (16 << 27) /* 0.401248551 */, + /* 2066 */ 0x066c9349 | (16 << 27) /* 0.401507651 */, + /* 2067 */ 0x066da304 | (16 << 27) /* 0.401766793 */, + /* 2068 */ 0x066eb2ca | (16 << 27) /* 0.402025976 */, + /* 2069 */ 0x066fc29b | (16 << 27) /* 0.402285202 */, + /* 2070 */ 0x0670d278 | (16 << 27) /* 0.402544469 */, + /* 2071 */ 0x0671e25f | (16 << 27) /* 0.402803777 */, + /* 2072 */ 0x0672f252 | (16 << 27) /* 0.403063128 */, + /* 2073 */ 0x06740250 | (16 << 27) /* 0.403322520 */, + /* 2074 */ 0x0675125a | (16 << 27) /* 0.403581954 */, + /* 2075 */ 0x0676226e | (16 << 27) /* 0.403841430 */, + /* 2076 */ 0x0677328e | (16 << 27) /* 0.404100947 */, + /* 2077 */ 0x067842b9 | (16 << 27) /* 0.404360506 */, + /* 2078 */ 0x067952ef | (16 << 27) /* 0.404620107 */, + /* 2079 */ 0x067a6330 | (16 << 27) /* 0.404879749 */, + + /* 2080 */ 0x067b737c | (16 << 27) /* 0.405139433 */, + /* 2081 */ 0x067c83d4 | (16 << 27) /* 0.405399159 */, + /* 2082 */ 0x067d9436 | (16 << 27) /* 0.405658926 */, + /* 2083 */ 0x067ea4a4 | (16 << 27) /* 0.405918735 */, + /* 2084 */ 0x067fb51d | (16 << 27) /* 0.406178585 */, + /* 2085 */ 0x0680c5a2 | (16 << 27) /* 0.406438477 */, + /* 2086 */ 0x0681d631 | (16 << 27) /* 0.406698410 */, + /* 2087 */ 0x0682e6cb | (16 << 27) /* 0.406958385 */, + /* 2088 */ 0x0683f771 | (16 << 27) /* 0.407218402 */, + /* 2089 */ 0x06850822 | (16 << 27) /* 0.407478460 */, + /* 2090 */ 0x068618de | (16 << 27) /* 0.407738559 */, + /* 2091 */ 0x068729a5 | (16 << 27) /* 0.407998700 */, + /* 2092 */ 0x06883a77 | (16 << 27) /* 0.408258883 */, + /* 2093 */ 0x06894b55 | (16 << 27) /* 0.408519107 */, + /* 2094 */ 0x068a5c3d | (16 << 27) /* 0.408779372 */, + /* 2095 */ 0x068b6d31 | (16 << 27) /* 0.409039679 */, + + /* 2096 */ 0x068c7e2f | (16 << 27) /* 0.409300027 */, + /* 2097 */ 0x068d8f39 | (16 << 27) /* 0.409560417 */, + /* 2098 */ 0x068ea04e | (16 << 27) /* 0.409820848 */, + /* 2099 */ 0x068fb16e | (16 << 27) /* 0.410081321 */, + /* 2100 */ 0x0690c299 | (16 << 27) /* 0.410341834 */, + /* 2101 */ 0x0691d3cf | (16 << 27) /* 0.410602390 */, + /* 2102 */ 0x0692e511 | (16 << 27) /* 0.410862986 */, + /* 2103 */ 0x0693f65d | (16 << 27) /* 0.411123624 */, + /* 2104 */ 0x069507b5 | (16 << 27) /* 0.411384303 */, + /* 2105 */ 0x06961917 | (16 << 27) /* 0.411645024 */, + /* 2106 */ 0x06972a85 | (16 << 27) /* 0.411905785 */, + /* 2107 */ 0x06983bfe | (16 << 27) /* 0.412166588 */, + /* 2108 */ 0x06994d82 | (16 << 27) /* 0.412427433 */, + /* 2109 */ 0x069a5f11 | (16 << 27) /* 0.412688318 */, + /* 2110 */ 0x069b70ab | (16 << 27) /* 0.412949245 */, + /* 2111 */ 0x069c8250 | (16 << 27) /* 0.413210213 */, + + /* 2112 */ 0x069d9400 | (16 << 27) /* 0.413471222 */, + /* 2113 */ 0x069ea5bb | (16 << 27) /* 0.413732273 */, + /* 2114 */ 0x069fb781 | (16 << 27) /* 0.413993364 */, + /* 2115 */ 0x06a0c953 | (16 << 27) /* 0.414254497 */, + /* 2116 */ 0x06a1db2f | (16 << 27) /* 0.414515671 */, + /* 2117 */ 0x06a2ed16 | (16 << 27) /* 0.414776886 */, + /* 2118 */ 0x06a3ff09 | (16 << 27) /* 0.415038142 */, + /* 2119 */ 0x06a51106 | (16 << 27) /* 0.415299440 */, + /* 2120 */ 0x06a6230f | (16 << 27) /* 0.415560778 */, + /* 2121 */ 0x06a73522 | (16 << 27) /* 0.415822157 */, + /* 2122 */ 0x06a84741 | (16 << 27) /* 0.416083578 */, + /* 2123 */ 0x06a9596a | (16 << 27) /* 0.416345040 */, + /* 2124 */ 0x06aa6b9f | (16 << 27) /* 0.416606542 */, + /* 2125 */ 0x06ab7ddf | (16 << 27) /* 0.416868086 */, + /* 2126 */ 0x06ac9029 | (16 << 27) /* 0.417129671 */, + /* 2127 */ 0x06ada27f | (16 << 27) /* 0.417391297 */, + + /* 2128 */ 0x06aeb4e0 | (16 << 27) /* 0.417652964 */, + /* 2129 */ 0x06afc74b | (16 << 27) /* 0.417914672 */, + /* 2130 */ 0x06b0d9c2 | (16 << 27) /* 0.418176420 */, + /* 2131 */ 0x06b1ec43 | (16 << 27) /* 0.418438210 */, + /* 2132 */ 0x06b2fed0 | (16 << 27) /* 0.418700041 */, + /* 2133 */ 0x06b41168 | (16 << 27) /* 0.418961912 */, + /* 2134 */ 0x06b5240a | (16 << 27) /* 0.419223825 */, + /* 2135 */ 0x06b636b8 | (16 << 27) /* 0.419485778 */, + /* 2136 */ 0x06b74971 | (16 << 27) /* 0.419747773 */, + /* 2137 */ 0x06b85c34 | (16 << 27) /* 0.420009808 */, + /* 2138 */ 0x06b96f03 | (16 << 27) /* 0.420271884 */, + /* 2139 */ 0x06ba81dc | (16 << 27) /* 0.420534001 */, + /* 2140 */ 0x06bb94c1 | (16 << 27) /* 0.420796159 */, + /* 2141 */ 0x06bca7b0 | (16 << 27) /* 0.421058358 */, + /* 2142 */ 0x06bdbaaa | (16 << 27) /* 0.421320597 */, + /* 2143 */ 0x06becdb0 | (16 << 27) /* 0.421582878 */, + + /* 2144 */ 0x06bfe0c0 | (16 << 27) /* 0.421845199 */, + /* 2145 */ 0x06c0f3db | (16 << 27) /* 0.422107561 */, + /* 2146 */ 0x06c20702 | (16 << 27) /* 0.422369964 */, + /* 2147 */ 0x06c31a33 | (16 << 27) /* 0.422632407 */, + /* 2148 */ 0x06c42d6f | (16 << 27) /* 0.422894891 */, + /* 2149 */ 0x06c540b6 | (16 << 27) /* 0.423157416 */, + /* 2150 */ 0x06c65408 | (16 << 27) /* 0.423419982 */, + /* 2151 */ 0x06c76765 | (16 << 27) /* 0.423682588 */, + /* 2152 */ 0x06c87acc | (16 << 27) /* 0.423945235 */, + /* 2153 */ 0x06c98e3f | (16 << 27) /* 0.424207923 */, + /* 2154 */ 0x06caa1bd | (16 << 27) /* 0.424470652 */, + /* 2155 */ 0x06cbb545 | (16 << 27) /* 0.424733421 */, + /* 2156 */ 0x06ccc8d9 | (16 << 27) /* 0.424996230 */, + /* 2157 */ 0x06cddc77 | (16 << 27) /* 0.425259081 */, + /* 2158 */ 0x06cef020 | (16 << 27) /* 0.425521972 */, + /* 2159 */ 0x06d003d4 | (16 << 27) /* 0.425784903 */, + + /* 2160 */ 0x06d11794 | (16 << 27) /* 0.426047876 */, + /* 2161 */ 0x06d22b5e | (16 << 27) /* 0.426310889 */, + /* 2162 */ 0x06d33f32 | (16 << 27) /* 0.426573942 */, + /* 2163 */ 0x06d45312 | (16 << 27) /* 0.426837036 */, + /* 2164 */ 0x06d566fd | (16 << 27) /* 0.427100170 */, + /* 2165 */ 0x06d67af2 | (16 << 27) /* 0.427363345 */, + /* 2166 */ 0x06d78ef3 | (16 << 27) /* 0.427626561 */, + /* 2167 */ 0x06d8a2fe | (16 << 27) /* 0.427889817 */, + /* 2168 */ 0x06d9b714 | (16 << 27) /* 0.428153114 */, + /* 2169 */ 0x06dacb35 | (16 << 27) /* 0.428416451 */, + /* 2170 */ 0x06dbdf61 | (16 << 27) /* 0.428679828 */, + /* 2171 */ 0x06dcf398 | (16 << 27) /* 0.428943246 */, + /* 2172 */ 0x06de07d9 | (16 << 27) /* 0.429206704 */, + /* 2173 */ 0x06df1c26 | (16 << 27) /* 0.429470203 */, + /* 2174 */ 0x06e0307d | (16 << 27) /* 0.429733743 */, + /* 2175 */ 0x06e144df | (16 << 27) /* 0.429997322 */, + + /* 2176 */ 0x06e2594c | (16 << 27) /* 0.430260942 */, + /* 2177 */ 0x06e36dc4 | (16 << 27) /* 0.430524603 */, + /* 2178 */ 0x06e48246 | (16 << 27) /* 0.430788304 */, + /* 2179 */ 0x06e596d4 | (16 << 27) /* 0.431052045 */, + /* 2180 */ 0x06e6ab6c | (16 << 27) /* 0.431315826 */, + /* 2181 */ 0x06e7c00f | (16 << 27) /* 0.431579648 */, + /* 2182 */ 0x06e8d4bd | (16 << 27) /* 0.431843511 */, + /* 2183 */ 0x06e9e976 | (16 << 27) /* 0.432107413 */, + /* 2184 */ 0x06eafe3a | (16 << 27) /* 0.432371356 */, + /* 2185 */ 0x06ec1308 | (16 << 27) /* 0.432635339 */, + /* 2186 */ 0x06ed27e2 | (16 << 27) /* 0.432899362 */, + /* 2187 */ 0x06ee3cc6 | (16 << 27) /* 0.433163426 */, + /* 2188 */ 0x06ef51b4 | (16 << 27) /* 0.433427530 */, + /* 2189 */ 0x06f066ae | (16 << 27) /* 0.433691674 */, + /* 2190 */ 0x06f17bb3 | (16 << 27) /* 0.433955859 */, + /* 2191 */ 0x06f290c2 | (16 << 27) /* 0.434220083 */, + + /* 2192 */ 0x06f3a5dc | (16 << 27) /* 0.434484348 */, + /* 2193 */ 0x06f4bb01 | (16 << 27) /* 0.434748653 */, + /* 2194 */ 0x06f5d030 | (16 << 27) /* 0.435012998 */, + /* 2195 */ 0x06f6e56b | (16 << 27) /* 0.435277383 */, + /* 2196 */ 0x06f7fab0 | (16 << 27) /* 0.435541809 */, + /* 2197 */ 0x06f91000 | (16 << 27) /* 0.435806274 */, + /* 2198 */ 0x06fa255a | (16 << 27) /* 0.436070780 */, + /* 2199 */ 0x06fb3ac0 | (16 << 27) /* 0.436335326 */, + /* 2200 */ 0x06fc5030 | (16 << 27) /* 0.436599912 */, + /* 2201 */ 0x06fd65ab | (16 << 27) /* 0.436864538 */, + /* 2202 */ 0x06fe7b31 | (16 << 27) /* 0.437129204 */, + /* 2203 */ 0x06ff90c2 | (16 << 27) /* 0.437393910 */, + /* 2204 */ 0x0700a65d | (16 << 27) /* 0.437658657 */, + /* 2205 */ 0x0701bc03 | (16 << 27) /* 0.437923443 */, + /* 2206 */ 0x0702d1b4 | (16 << 27) /* 0.438188269 */, + /* 2207 */ 0x0703e76f | (16 << 27) /* 0.438453136 */, + + /* 2208 */ 0x0704fd35 | (16 << 27) /* 0.438718042 */, + /* 2209 */ 0x07061306 | (16 << 27) /* 0.438982988 */, + /* 2210 */ 0x070728e2 | (16 << 27) /* 0.439247975 */, + /* 2211 */ 0x07083ec9 | (16 << 27) /* 0.439513001 */, + /* 2212 */ 0x070954ba | (16 << 27) /* 0.439778067 */, + /* 2213 */ 0x070a6ab6 | (16 << 27) /* 0.440043173 */, + /* 2214 */ 0x070b80bc | (16 << 27) /* 0.440308320 */, + /* 2215 */ 0x070c96ce | (16 << 27) /* 0.440573506 */, + /* 2216 */ 0x070dacea | (16 << 27) /* 0.440838732 */, + /* 2217 */ 0x070ec310 | (16 << 27) /* 0.441103997 */, + /* 2218 */ 0x070fd942 | (16 << 27) /* 0.441369303 */, + /* 2219 */ 0x0710ef7e | (16 << 27) /* 0.441634649 */, + /* 2220 */ 0x071205c5 | (16 << 27) /* 0.441900034 */, + /* 2221 */ 0x07131c17 | (16 << 27) /* 0.442165460 */, + /* 2222 */ 0x07143273 | (16 << 27) /* 0.442430925 */, + /* 2223 */ 0x071548da | (16 << 27) /* 0.442696430 */, + + /* 2224 */ 0x07165f4b | (16 << 27) /* 0.442961975 */, + /* 2225 */ 0x071775c8 | (16 << 27) /* 0.443227559 */, + /* 2226 */ 0x07188c4f | (16 << 27) /* 0.443493184 */, + /* 2227 */ 0x0719a2e0 | (16 << 27) /* 0.443758848 */, + /* 2228 */ 0x071ab97d | (16 << 27) /* 0.444024552 */, + /* 2229 */ 0x071bd024 | (16 << 27) /* 0.444290296 */, + /* 2230 */ 0x071ce6d6 | (16 << 27) /* 0.444556079 */, + /* 2231 */ 0x071dfd92 | (16 << 27) /* 0.444821902 */, + /* 2232 */ 0x071f1459 | (16 << 27) /* 0.445087765 */, + /* 2233 */ 0x07202b2b | (16 << 27) /* 0.445353668 */, + /* 2234 */ 0x07214207 | (16 << 27) /* 0.445619610 */, + /* 2235 */ 0x072258ee | (16 << 27) /* 0.445885592 */, + /* 2236 */ 0x07236fe0 | (16 << 27) /* 0.446151614 */, + /* 2237 */ 0x072486dc | (16 << 27) /* 0.446417675 */, + /* 2238 */ 0x07259de3 | (16 << 27) /* 0.446683776 */, + /* 2239 */ 0x0726b4f4 | (16 << 27) /* 0.446949917 */, + + /* 2240 */ 0x0727cc11 | (16 << 27) /* 0.447216097 */, + /* 2241 */ 0x0728e338 | (16 << 27) /* 0.447482317 */, + /* 2242 */ 0x0729fa69 | (16 << 27) /* 0.447748576 */, + /* 2243 */ 0x072b11a5 | (16 << 27) /* 0.448014875 */, + /* 2244 */ 0x072c28ec | (16 << 27) /* 0.448281214 */, + /* 2245 */ 0x072d403d | (16 << 27) /* 0.448547592 */, + /* 2246 */ 0x072e5799 | (16 << 27) /* 0.448814010 */, + /* 2247 */ 0x072f6f00 | (16 << 27) /* 0.449080467 */, + /* 2248 */ 0x07308671 | (16 << 27) /* 0.449346964 */, + /* 2249 */ 0x07319ded | (16 << 27) /* 0.449613501 */, + /* 2250 */ 0x0732b573 | (16 << 27) /* 0.449880076 */, + /* 2251 */ 0x0733cd04 | (16 << 27) /* 0.450146692 */, + /* 2252 */ 0x0734e4a0 | (16 << 27) /* 0.450413347 */, + /* 2253 */ 0x0735fc46 | (16 << 27) /* 0.450680041 */, + /* 2254 */ 0x073713f7 | (16 << 27) /* 0.450946775 */, + /* 2255 */ 0x07382bb2 | (16 << 27) /* 0.451213548 */, + + /* 2256 */ 0x07394378 | (16 << 27) /* 0.451480360 */, + /* 2257 */ 0x073a5b49 | (16 << 27) /* 0.451747213 */, + /* 2258 */ 0x073b7324 | (16 << 27) /* 0.452014104 */, + /* 2259 */ 0x073c8b0a | (16 << 27) /* 0.452281035 */, + /* 2260 */ 0x073da2fa | (16 << 27) /* 0.452548005 */, + /* 2261 */ 0x073ebaf5 | (16 << 27) /* 0.452815015 */, + /* 2262 */ 0x073fd2fa | (16 << 27) /* 0.453082064 */, + /* 2263 */ 0x0740eb0a | (16 << 27) /* 0.453349152 */, + /* 2264 */ 0x07420325 | (16 << 27) /* 0.453616280 */, + /* 2265 */ 0x07431b4a | (16 << 27) /* 0.453883447 */, + /* 2266 */ 0x0744337a | (16 << 27) /* 0.454150653 */, + /* 2267 */ 0x07454bb4 | (16 << 27) /* 0.454417899 */, + /* 2268 */ 0x074663f8 | (16 << 27) /* 0.454685184 */, + /* 2269 */ 0x07477c48 | (16 << 27) /* 0.454952508 */, + /* 2270 */ 0x074894a2 | (16 << 27) /* 0.455219872 */, + /* 2271 */ 0x0749ad06 | (16 << 27) /* 0.455487275 */, + + /* 2272 */ 0x074ac575 | (16 << 27) /* 0.455754717 */, + /* 2273 */ 0x074bddee | (16 << 27) /* 0.456022198 */, + /* 2274 */ 0x074cf672 | (16 << 27) /* 0.456289719 */, + /* 2275 */ 0x074e0f01 | (16 << 27) /* 0.456557278 */, + /* 2276 */ 0x074f279a | (16 << 27) /* 0.456824877 */, + /* 2277 */ 0x0750403e | (16 << 27) /* 0.457092516 */, + /* 2278 */ 0x075158ec | (16 << 27) /* 0.457360193 */, + /* 2279 */ 0x075271a4 | (16 << 27) /* 0.457627909 */, + /* 2280 */ 0x07538a67 | (16 << 27) /* 0.457895665 */, + /* 2281 */ 0x0754a335 | (16 << 27) /* 0.458163460 */, + /* 2282 */ 0x0755bc0d | (16 << 27) /* 0.458431294 */, + /* 2283 */ 0x0756d4f0 | (16 << 27) /* 0.458699167 */, + /* 2284 */ 0x0757eddd | (16 << 27) /* 0.458967079 */, + /* 2285 */ 0x075906d5 | (16 << 27) /* 0.459235030 */, + /* 2286 */ 0x075a1fd7 | (16 << 27) /* 0.459503021 */, + /* 2287 */ 0x075b38e3 | (16 << 27) /* 0.459771050 */, + + /* 2288 */ 0x075c51fa | (16 << 27) /* 0.460039119 */, + /* 2289 */ 0x075d6b1c | (16 << 27) /* 0.460307226 */, + /* 2290 */ 0x075e8448 | (16 << 27) /* 0.460575373 */, + /* 2291 */ 0x075f9d7f | (16 << 27) /* 0.460843559 */, + /* 2292 */ 0x0760b6c0 | (16 << 27) /* 0.461111783 */, + /* 2293 */ 0x0761d00b | (16 << 27) /* 0.461380047 */, + /* 2294 */ 0x0762e961 | (16 << 27) /* 0.461648350 */, + /* 2295 */ 0x076402c1 | (16 << 27) /* 0.461916691 */, + /* 2296 */ 0x07651c2c | (16 << 27) /* 0.462185072 */, + /* 2297 */ 0x076635a2 | (16 << 27) /* 0.462453492 */, + /* 2298 */ 0x07674f22 | (16 << 27) /* 0.462721950 */, + /* 2299 */ 0x076868ac | (16 << 27) /* 0.462990448 */, + /* 2300 */ 0x07698240 | (16 << 27) /* 0.463258984 */, + /* 2301 */ 0x076a9be0 | (16 << 27) /* 0.463527560 */, + /* 2302 */ 0x076bb589 | (16 << 27) /* 0.463796174 */, + /* 2303 */ 0x076ccf3d | (16 << 27) /* 0.464064827 */, + + /* 2304 */ 0x076de8fc | (16 << 27) /* 0.464333519 */, + /* 2305 */ 0x076f02c5 | (16 << 27) /* 0.464602250 */, + /* 2306 */ 0x07701c98 | (16 << 27) /* 0.464871020 */, + /* 2307 */ 0x07713676 | (16 << 27) /* 0.465139829 */, + /* 2308 */ 0x0772505e | (16 << 27) /* 0.465408676 */, + /* 2309 */ 0x07736a51 | (16 << 27) /* 0.465677563 */, + /* 2310 */ 0x0774844e | (16 << 27) /* 0.465946488 */, + /* 2311 */ 0x07759e55 | (16 << 27) /* 0.466215452 */, + /* 2312 */ 0x0776b867 | (16 << 27) /* 0.466484455 */, + /* 2313 */ 0x0777d283 | (16 << 27) /* 0.466753496 */, + /* 2314 */ 0x0778ecaa | (16 << 27) /* 0.467022577 */, + /* 2315 */ 0x077a06db | (16 << 27) /* 0.467291696 */, + /* 2316 */ 0x077b2117 | (16 << 27) /* 0.467560854 */, + /* 2317 */ 0x077c3b5d | (16 << 27) /* 0.467830050 */, + /* 2318 */ 0x077d55ad | (16 << 27) /* 0.468099285 */, + /* 2319 */ 0x077e7008 | (16 << 27) /* 0.468368560 */, + + /* 2320 */ 0x077f8a6d | (16 << 27) /* 0.468637872 */, + /* 2321 */ 0x0780a4dc | (16 << 27) /* 0.468907224 */, + /* 2322 */ 0x0781bf56 | (16 << 27) /* 0.469176614 */, + /* 2323 */ 0x0782d9da | (16 << 27) /* 0.469446043 */, + /* 2324 */ 0x0783f469 | (16 << 27) /* 0.469715510 */, + /* 2325 */ 0x07850f02 | (16 << 27) /* 0.469985016 */, + /* 2326 */ 0x078629a5 | (16 << 27) /* 0.470254561 */, + /* 2327 */ 0x07874453 | (16 << 27) /* 0.470524145 */, + /* 2328 */ 0x07885f0b | (16 << 27) /* 0.470793767 */, + /* 2329 */ 0x078979ce | (16 << 27) /* 0.471063427 */, + /* 2330 */ 0x078a949a | (16 << 27) /* 0.471333126 */, + /* 2331 */ 0x078baf72 | (16 << 27) /* 0.471602864 */, + /* 2332 */ 0x078cca53 | (16 << 27) /* 0.471872641 */, + /* 2333 */ 0x078de53f | (16 << 27) /* 0.472142456 */, + /* 2334 */ 0x078f0035 | (16 << 27) /* 0.472412309 */, + /* 2335 */ 0x07901b36 | (16 << 27) /* 0.472682201 */, + + /* 2336 */ 0x07913641 | (16 << 27) /* 0.472952132 */, + /* 2337 */ 0x07925156 | (16 << 27) /* 0.473222101 */, + /* 2338 */ 0x07936c76 | (16 << 27) /* 0.473492108 */, + /* 2339 */ 0x079487a0 | (16 << 27) /* 0.473762155 */, + /* 2340 */ 0x0795a2d4 | (16 << 27) /* 0.474032239 */, + /* 2341 */ 0x0796be13 | (16 << 27) /* 0.474302362 */, + /* 2342 */ 0x0797d95c | (16 << 27) /* 0.474572524 */, + /* 2343 */ 0x0798f4af | (16 << 27) /* 0.474842724 */, + /* 2344 */ 0x079a100c | (16 << 27) /* 0.475112962 */, + /* 2345 */ 0x079b2b74 | (16 << 27) /* 0.475383239 */, + /* 2346 */ 0x079c46e7 | (16 << 27) /* 0.475653554 */, + /* 2347 */ 0x079d6263 | (16 << 27) /* 0.475923908 */, + /* 2348 */ 0x079e7dea | (16 << 27) /* 0.476194300 */, + /* 2349 */ 0x079f997b | (16 << 27) /* 0.476464731 */, + /* 2350 */ 0x07a0b516 | (16 << 27) /* 0.476735200 */, + /* 2351 */ 0x07a1d0bc | (16 << 27) /* 0.477005707 */, + + /* 2352 */ 0x07a2ec6c | (16 << 27) /* 0.477276252 */, + /* 2353 */ 0x07a40827 | (16 << 27) /* 0.477546836 */, + /* 2354 */ 0x07a523eb | (16 << 27) /* 0.477817459 */, + /* 2355 */ 0x07a63fba | (16 << 27) /* 0.478088119 */, + /* 2356 */ 0x07a75b93 | (16 << 27) /* 0.478358818 */, + /* 2357 */ 0x07a87777 | (16 << 27) /* 0.478629555 */, + /* 2358 */ 0x07a99364 | (16 << 27) /* 0.478900331 */, + /* 2359 */ 0x07aaaf5c | (16 << 27) /* 0.479171145 */, + /* 2360 */ 0x07abcb5f | (16 << 27) /* 0.479441997 */, + /* 2361 */ 0x07ace76b | (16 << 27) /* 0.479712887 */, + /* 2362 */ 0x07ae0382 | (16 << 27) /* 0.479983816 */, + /* 2363 */ 0x07af1fa3 | (16 << 27) /* 0.480254782 */, + /* 2364 */ 0x07b03bcf | (16 << 27) /* 0.480525787 */, + /* 2365 */ 0x07b15804 | (16 << 27) /* 0.480796831 */, + /* 2366 */ 0x07b27444 | (16 << 27) /* 0.481067912 */, + /* 2367 */ 0x07b3908e | (16 << 27) /* 0.481339032 */, + + /* 2368 */ 0x07b4ace3 | (16 << 27) /* 0.481610189 */, + /* 2369 */ 0x07b5c941 | (16 << 27) /* 0.481881385 */, + /* 2370 */ 0x07b6e5aa | (16 << 27) /* 0.482152620 */, + /* 2371 */ 0x07b8021d | (16 << 27) /* 0.482423892 */, + /* 2372 */ 0x07b91e9b | (16 << 27) /* 0.482695202 */, + /* 2373 */ 0x07ba3b22 | (16 << 27) /* 0.482966551 */, + /* 2374 */ 0x07bb57b4 | (16 << 27) /* 0.483237938 */, + /* 2375 */ 0x07bc7450 | (16 << 27) /* 0.483509362 */, + /* 2376 */ 0x07bd90f6 | (16 << 27) /* 0.483780825 */, + /* 2377 */ 0x07beada7 | (16 << 27) /* 0.484052326 */, + /* 2378 */ 0x07bfca61 | (16 << 27) /* 0.484323865 */, + /* 2379 */ 0x07c0e726 | (16 << 27) /* 0.484595443 */, + /* 2380 */ 0x07c203f5 | (16 << 27) /* 0.484867058 */, + /* 2381 */ 0x07c320cf | (16 << 27) /* 0.485138711 */, + /* 2382 */ 0x07c43db2 | (16 << 27) /* 0.485410402 */, + /* 2383 */ 0x07c55aa0 | (16 << 27) /* 0.485682131 */, + + /* 2384 */ 0x07c67798 | (16 << 27) /* 0.485953899 */, + /* 2385 */ 0x07c7949a | (16 << 27) /* 0.486225704 */, + /* 2386 */ 0x07c8b1a7 | (16 << 27) /* 0.486497547 */, + /* 2387 */ 0x07c9cebd | (16 << 27) /* 0.486769429 */, + /* 2388 */ 0x07caebde | (16 << 27) /* 0.487041348 */, + /* 2389 */ 0x07cc0909 | (16 << 27) /* 0.487313305 */, + /* 2390 */ 0x07cd263e | (16 << 27) /* 0.487585300 */, + /* 2391 */ 0x07ce437d | (16 << 27) /* 0.487857333 */, + /* 2392 */ 0x07cf60c7 | (16 << 27) /* 0.488129404 */, + /* 2393 */ 0x07d07e1b | (16 << 27) /* 0.488401513 */, + /* 2394 */ 0x07d19b79 | (16 << 27) /* 0.488673660 */, + /* 2395 */ 0x07d2b8e1 | (16 << 27) /* 0.488945845 */, + /* 2396 */ 0x07d3d653 | (16 << 27) /* 0.489218067 */, + /* 2397 */ 0x07d4f3cf | (16 << 27) /* 0.489490328 */, + /* 2398 */ 0x07d61156 | (16 << 27) /* 0.489762626 */, + /* 2399 */ 0x07d72ee6 | (16 << 27) /* 0.490034962 */, + + /* 2400 */ 0x07d84c81 | (16 << 27) /* 0.490307336 */, + /* 2401 */ 0x07d96a26 | (16 << 27) /* 0.490579748 */, + /* 2402 */ 0x07da87d5 | (16 << 27) /* 0.490852198 */, + /* 2403 */ 0x07dba58f | (16 << 27) /* 0.491124686 */, + /* 2404 */ 0x07dcc352 | (16 << 27) /* 0.491397211 */, + /* 2405 */ 0x07dde120 | (16 << 27) /* 0.491669774 */, + /* 2406 */ 0x07defef7 | (16 << 27) /* 0.491942375 */, + /* 2407 */ 0x07e01cd9 | (16 << 27) /* 0.492215014 */, + /* 2408 */ 0x07e13ac5 | (16 << 27) /* 0.492487690 */, + /* 2409 */ 0x07e258bc | (16 << 27) /* 0.492760404 */, + /* 2410 */ 0x07e376bc | (16 << 27) /* 0.493033156 */, + /* 2411 */ 0x07e494c6 | (16 << 27) /* 0.493305946 */, + /* 2412 */ 0x07e5b2db | (16 << 27) /* 0.493578773 */, + /* 2413 */ 0x07e6d0f9 | (16 << 27) /* 0.493851638 */, + /* 2414 */ 0x07e7ef22 | (16 << 27) /* 0.494124541 */, + /* 2415 */ 0x07e90d55 | (16 << 27) /* 0.494397481 */, + + /* 2416 */ 0x07ea2b92 | (16 << 27) /* 0.494670459 */, + /* 2417 */ 0x07eb49d9 | (16 << 27) /* 0.494943475 */, + /* 2418 */ 0x07ec682a | (16 << 27) /* 0.495216529 */, + /* 2419 */ 0x07ed8686 | (16 << 27) /* 0.495489620 */, + /* 2420 */ 0x07eea4eb | (16 << 27) /* 0.495762748 */, + /* 2421 */ 0x07efc35b | (16 << 27) /* 0.496035915 */, + /* 2422 */ 0x07f0e1d4 | (16 << 27) /* 0.496309119 */, + /* 2423 */ 0x07f20058 | (16 << 27) /* 0.496582360 */, + /* 2424 */ 0x07f31ee6 | (16 << 27) /* 0.496855639 */, + /* 2425 */ 0x07f43d7e | (16 << 27) /* 0.497128956 */, + /* 2426 */ 0x07f55c20 | (16 << 27) /* 0.497402310 */, + /* 2427 */ 0x07f67acc | (16 << 27) /* 0.497675702 */, + /* 2428 */ 0x07f79982 | (16 << 27) /* 0.497949132 */, + /* 2429 */ 0x07f8b842 | (16 << 27) /* 0.498222598 */, + /* 2430 */ 0x07f9d70c | (16 << 27) /* 0.498496103 */, + /* 2431 */ 0x07faf5e1 | (16 << 27) /* 0.498769645 */, + + /* 2432 */ 0x07fc14bf | (16 << 27) /* 0.499043224 */, + /* 2433 */ 0x07fd33a8 | (16 << 27) /* 0.499316841 */, + /* 2434 */ 0x07fe529a | (16 << 27) /* 0.499590496 */, + /* 2435 */ 0x07ff7197 | (16 << 27) /* 0.499864188 */, + /* 2436 */ 0x0400484f | (17 << 27) /* 0.250068959 */, + /* 2437 */ 0x0400d7d7 | (17 << 27) /* 0.250205842 */, + /* 2438 */ 0x04016764 | (17 << 27) /* 0.250342744 */, + /* 2439 */ 0x0401f6f7 | (17 << 27) /* 0.250479665 */, + /* 2440 */ 0x0402868e | (17 << 27) /* 0.250616605 */, + /* 2441 */ 0x0403162b | (17 << 27) /* 0.250753563 */, + /* 2442 */ 0x0403a5cc | (17 << 27) /* 0.250890540 */, + /* 2443 */ 0x04043573 | (17 << 27) /* 0.251027536 */, + /* 2444 */ 0x0404c51e | (17 << 27) /* 0.251164550 */, + /* 2445 */ 0x040554cf | (17 << 27) /* 0.251301583 */, + /* 2446 */ 0x0405e484 | (17 << 27) /* 0.251438635 */, + /* 2447 */ 0x0406743f | (17 << 27) /* 0.251575706 */, + + /* 2448 */ 0x040703ff | (17 << 27) /* 0.251712795 */, + /* 2449 */ 0x040793c3 | (17 << 27) /* 0.251849903 */, + /* 2450 */ 0x0408238d | (17 << 27) /* 0.251987029 */, + /* 2451 */ 0x0408b35b | (17 << 27) /* 0.252124174 */, + /* 2452 */ 0x0409432f | (17 << 27) /* 0.252261338 */, + /* 2453 */ 0x0409d308 | (17 << 27) /* 0.252398520 */, + /* 2454 */ 0x040a62e5 | (17 << 27) /* 0.252535721 */, + /* 2455 */ 0x040af2c8 | (17 << 27) /* 0.252672941 */, + /* 2456 */ 0x040b82b0 | (17 << 27) /* 0.252810180 */, + /* 2457 */ 0x040c129c | (17 << 27) /* 0.252947436 */, + /* 2458 */ 0x040ca28e | (17 << 27) /* 0.253084712 */, + /* 2459 */ 0x040d3284 | (17 << 27) /* 0.253222006 */, + /* 2460 */ 0x040dc280 | (17 << 27) /* 0.253359319 */, + /* 2461 */ 0x040e5281 | (17 << 27) /* 0.253496651 */, + /* 2462 */ 0x040ee286 | (17 << 27) /* 0.253634001 */, + /* 2463 */ 0x040f7291 | (17 << 27) /* 0.253771369 */, + + /* 2464 */ 0x041002a1 | (17 << 27) /* 0.253908756 */, + /* 2465 */ 0x041092b5 | (17 << 27) /* 0.254046162 */, + /* 2466 */ 0x041122cf | (17 << 27) /* 0.254183587 */, + /* 2467 */ 0x0411b2ed | (17 << 27) /* 0.254321030 */, + /* 2468 */ 0x04124311 | (17 << 27) /* 0.254458491 */, + /* 2469 */ 0x0412d339 | (17 << 27) /* 0.254595971 */, + /* 2470 */ 0x04136367 | (17 << 27) /* 0.254733470 */, + /* 2471 */ 0x0413f399 | (17 << 27) /* 0.254870987 */, + /* 2472 */ 0x041483d1 | (17 << 27) /* 0.255008523 */, + /* 2473 */ 0x0415140d | (17 << 27) /* 0.255146077 */, + /* 2474 */ 0x0415a44f | (17 << 27) /* 0.255283650 */, + /* 2475 */ 0x04163495 | (17 << 27) /* 0.255421241 */, + /* 2476 */ 0x0416c4e1 | (17 << 27) /* 0.255558851 */, + /* 2477 */ 0x04175531 | (17 << 27) /* 0.255696480 */, + /* 2478 */ 0x0417e586 | (17 << 27) /* 0.255834127 */, + /* 2479 */ 0x041875e1 | (17 << 27) /* 0.255971792 */, + + /* 2480 */ 0x04190640 | (17 << 27) /* 0.256109476 */, + /* 2481 */ 0x041996a4 | (17 << 27) /* 0.256247179 */, + /* 2482 */ 0x041a270d | (17 << 27) /* 0.256384900 */, + /* 2483 */ 0x041ab77b | (17 << 27) /* 0.256522639 */, + /* 2484 */ 0x041b47ef | (17 << 27) /* 0.256660397 */, + /* 2485 */ 0x041bd867 | (17 << 27) /* 0.256798174 */, + /* 2486 */ 0x041c68e4 | (17 << 27) /* 0.256935969 */, + /* 2487 */ 0x041cf966 | (17 << 27) /* 0.257073782 */, + /* 2488 */ 0x041d89ed | (17 << 27) /* 0.257211614 */, + /* 2489 */ 0x041e1a79 | (17 << 27) /* 0.257349465 */, + /* 2490 */ 0x041eab0a | (17 << 27) /* 0.257487334 */, + /* 2491 */ 0x041f3b9f | (17 << 27) /* 0.257625221 */, + /* 2492 */ 0x041fcc3a | (17 << 27) /* 0.257763127 */, + /* 2493 */ 0x04205cda | (17 << 27) /* 0.257901051 */, + /* 2494 */ 0x0420ed7f | (17 << 27) /* 0.258038994 */, + /* 2495 */ 0x04217e28 | (17 << 27) /* 0.258176955 */, + + /* 2496 */ 0x04220ed7 | (17 << 27) /* 0.258314934 */, + /* 2497 */ 0x04229f8a | (17 << 27) /* 0.258452932 */, + /* 2498 */ 0x04233043 | (17 << 27) /* 0.258590948 */, + /* 2499 */ 0x0423c100 | (17 << 27) /* 0.258728983 */, + /* 2500 */ 0x042451c3 | (17 << 27) /* 0.258867036 */, + /* 2501 */ 0x0424e28a | (17 << 27) /* 0.259005108 */, + /* 2502 */ 0x04257356 | (17 << 27) /* 0.259143198 */, + /* 2503 */ 0x04260428 | (17 << 27) /* 0.259281307 */, + /* 2504 */ 0x042694fe | (17 << 27) /* 0.259419433 */, + /* 2505 */ 0x042725d9 | (17 << 27) /* 0.259557579 */, + /* 2506 */ 0x0427b6b9 | (17 << 27) /* 0.259695742 */, + /* 2507 */ 0x0428479e | (17 << 27) /* 0.259833924 */, + /* 2508 */ 0x0428d888 | (17 << 27) /* 0.259972124 */, + /* 2509 */ 0x04296976 | (17 << 27) /* 0.260110343 */, + /* 2510 */ 0x0429fa6a | (17 << 27) /* 0.260248580 */, + /* 2511 */ 0x042a8b63 | (17 << 27) /* 0.260386836 */, + + /* 2512 */ 0x042b1c60 | (17 << 27) /* 0.260525110 */, + /* 2513 */ 0x042bad63 | (17 << 27) /* 0.260663402 */, + /* 2514 */ 0x042c3e6a | (17 << 27) /* 0.260801712 */, + /* 2515 */ 0x042ccf77 | (17 << 27) /* 0.260940041 */, + /* 2516 */ 0x042d6088 | (17 << 27) /* 0.261078388 */, + /* 2517 */ 0x042df19e | (17 << 27) /* 0.261216754 */, + /* 2518 */ 0x042e82b9 | (17 << 27) /* 0.261355137 */, + /* 2519 */ 0x042f13d9 | (17 << 27) /* 0.261493540 */, + /* 2520 */ 0x042fa4fe | (17 << 27) /* 0.261631960 */, + /* 2521 */ 0x04303628 | (17 << 27) /* 0.261770399 */, + /* 2522 */ 0x0430c757 | (17 << 27) /* 0.261908856 */, + /* 2523 */ 0x0431588b | (17 << 27) /* 0.262047331 */, + /* 2524 */ 0x0431e9c3 | (17 << 27) /* 0.262185825 */, + /* 2525 */ 0x04327b01 | (17 << 27) /* 0.262324337 */, + /* 2526 */ 0x04330c43 | (17 << 27) /* 0.262462867 */, + /* 2527 */ 0x04339d8a | (17 << 27) /* 0.262601416 */, + + /* 2528 */ 0x04342ed7 | (17 << 27) /* 0.262739982 */, + /* 2529 */ 0x0434c028 | (17 << 27) /* 0.262878568 */, + /* 2530 */ 0x0435517e | (17 << 27) /* 0.263017171 */, + /* 2531 */ 0x0435e2d9 | (17 << 27) /* 0.263155792 */, + /* 2532 */ 0x04367439 | (17 << 27) /* 0.263294432 */, + /* 2533 */ 0x0437059e | (17 << 27) /* 0.263433090 */, + /* 2534 */ 0x04379707 | (17 << 27) /* 0.263571767 */, + /* 2535 */ 0x04382876 | (17 << 27) /* 0.263710461 */, + /* 2536 */ 0x0438b9e9 | (17 << 27) /* 0.263849174 */, + /* 2537 */ 0x04394b61 | (17 << 27) /* 0.263987905 */, + /* 2538 */ 0x0439dcdf | (17 << 27) /* 0.264126655 */, + /* 2539 */ 0x043a6e61 | (17 << 27) /* 0.264265422 */, + /* 2540 */ 0x043affe8 | (17 << 27) /* 0.264404208 */, + /* 2541 */ 0x043b9174 | (17 << 27) /* 0.264543012 */, + /* 2542 */ 0x043c2305 | (17 << 27) /* 0.264681834 */, + /* 2543 */ 0x043cb49a | (17 << 27) /* 0.264820674 */, + + /* 2544 */ 0x043d4635 | (17 << 27) /* 0.264959533 */, + /* 2545 */ 0x043dd7d4 | (17 << 27) /* 0.265098410 */, + /* 2546 */ 0x043e6979 | (17 << 27) /* 0.265237305 */, + /* 2547 */ 0x043efb22 | (17 << 27) /* 0.265376218 */, + /* 2548 */ 0x043f8cd0 | (17 << 27) /* 0.265515149 */, + /* 2549 */ 0x04401e83 | (17 << 27) /* 0.265654099 */, + /* 2550 */ 0x0440b03b | (17 << 27) /* 0.265793066 */, + /* 2551 */ 0x044141f7 | (17 << 27) /* 0.265932052 */, + /* 2552 */ 0x0441d3b9 | (17 << 27) /* 0.266071056 */, + /* 2553 */ 0x04426580 | (17 << 27) /* 0.266210078 */, + /* 2554 */ 0x0442f74b | (17 << 27) /* 0.266349119 */, + /* 2555 */ 0x0443891b | (17 << 27) /* 0.266488177 */, + /* 2556 */ 0x04441af0 | (17 << 27) /* 0.266627254 */, + /* 2557 */ 0x0444acca | (17 << 27) /* 0.266766349 */, + /* 2558 */ 0x04453ea9 | (17 << 27) /* 0.266905462 */, + /* 2559 */ 0x0445d08d | (17 << 27) /* 0.267044593 */, + + /* 2560 */ 0x04466275 | (17 << 27) /* 0.267183742 */, + /* 2561 */ 0x0446f463 | (17 << 27) /* 0.267322909 */, + /* 2562 */ 0x04478655 | (17 << 27) /* 0.267462094 */, + /* 2563 */ 0x0448184c | (17 << 27) /* 0.267601298 */, + /* 2564 */ 0x0448aa48 | (17 << 27) /* 0.267740519 */, + /* 2565 */ 0x04493c49 | (17 << 27) /* 0.267879759 */, + /* 2566 */ 0x0449ce4f | (17 << 27) /* 0.268019017 */, + /* 2567 */ 0x044a6059 | (17 << 27) /* 0.268158293 */, + /* 2568 */ 0x044af269 | (17 << 27) /* 0.268297587 */, + /* 2569 */ 0x044b847d | (17 << 27) /* 0.268436899 */, + /* 2570 */ 0x044c1696 | (17 << 27) /* 0.268576229 */, + /* 2571 */ 0x044ca8b4 | (17 << 27) /* 0.268715577 */, + /* 2572 */ 0x044d3ad7 | (17 << 27) /* 0.268854943 */, + /* 2573 */ 0x044dccff | (17 << 27) /* 0.268994328 */, + /* 2574 */ 0x044e5f2b | (17 << 27) /* 0.269133730 */, + /* 2575 */ 0x044ef15d | (17 << 27) /* 0.269273150 */, + + /* 2576 */ 0x044f8393 | (17 << 27) /* 0.269412589 */, + /* 2577 */ 0x045015ce | (17 << 27) /* 0.269552045 */, + /* 2578 */ 0x0450a80e | (17 << 27) /* 0.269691520 */, + /* 2579 */ 0x04513a53 | (17 << 27) /* 0.269831013 */, + /* 2580 */ 0x0451cc9c | (17 << 27) /* 0.269970523 */, + /* 2581 */ 0x04525eeb | (17 << 27) /* 0.270110052 */, + /* 2582 */ 0x0452f13e | (17 << 27) /* 0.270249599 */, + /* 2583 */ 0x04538396 | (17 << 27) /* 0.270389163 */, + /* 2584 */ 0x045415f3 | (17 << 27) /* 0.270528746 */, + /* 2585 */ 0x0454a855 | (17 << 27) /* 0.270668347 */, + /* 2586 */ 0x04553abb | (17 << 27) /* 0.270807965 */, + /* 2587 */ 0x0455cd27 | (17 << 27) /* 0.270947602 */, + /* 2588 */ 0x04565f97 | (17 << 27) /* 0.271087257 */, + /* 2589 */ 0x0456f20c | (17 << 27) /* 0.271226930 */, + /* 2590 */ 0x04578486 | (17 << 27) /* 0.271366620 */, + /* 2591 */ 0x04581705 | (17 << 27) /* 0.271506329 */, + + /* 2592 */ 0x0458a989 | (17 << 27) /* 0.271646056 */, + /* 2593 */ 0x04593c11 | (17 << 27) /* 0.271785800 */, + /* 2594 */ 0x0459ce9e | (17 << 27) /* 0.271925563 */, + /* 2595 */ 0x045a6130 | (17 << 27) /* 0.272065343 */, + /* 2596 */ 0x045af3c7 | (17 << 27) /* 0.272205142 */, + /* 2597 */ 0x045b8663 | (17 << 27) /* 0.272344958 */, + /* 2598 */ 0x045c1903 | (17 << 27) /* 0.272484793 */, + /* 2599 */ 0x045caba9 | (17 << 27) /* 0.272624645 */, + /* 2600 */ 0x045d3e53 | (17 << 27) /* 0.272764515 */, + /* 2601 */ 0x045dd102 | (17 << 27) /* 0.272904403 */, + /* 2602 */ 0x045e63b6 | (17 << 27) /* 0.273044310 */, + /* 2603 */ 0x045ef66e | (17 << 27) /* 0.273184234 */, + /* 2604 */ 0x045f892b | (17 << 27) /* 0.273324176 */, + /* 2605 */ 0x04601bee | (17 << 27) /* 0.273464136 */, + /* 2606 */ 0x0460aeb5 | (17 << 27) /* 0.273604113 */, + /* 2607 */ 0x04614180 | (17 << 27) /* 0.273744109 */, + + /* 2608 */ 0x0461d451 | (17 << 27) /* 0.273884123 */, + /* 2609 */ 0x04626727 | (17 << 27) /* 0.274024154 */, + /* 2610 */ 0x0462fa01 | (17 << 27) /* 0.274164204 */, + /* 2611 */ 0x04638ce0 | (17 << 27) /* 0.274304271 */, + /* 2612 */ 0x04641fc4 | (17 << 27) /* 0.274444356 */, + /* 2613 */ 0x0464b2ac | (17 << 27) /* 0.274584459 */, + /* 2614 */ 0x0465459a | (17 << 27) /* 0.274724580 */, + /* 2615 */ 0x0465d88c | (17 << 27) /* 0.274864719 */, + /* 2616 */ 0x04666b83 | (17 << 27) /* 0.275004875 */, + /* 2617 */ 0x0466fe7f | (17 << 27) /* 0.275145050 */, + /* 2618 */ 0x0467917f | (17 << 27) /* 0.275285242 */, + /* 2619 */ 0x04682485 | (17 << 27) /* 0.275425452 */, + /* 2620 */ 0x0468b78f | (17 << 27) /* 0.275565681 */, + /* 2621 */ 0x04694a9e | (17 << 27) /* 0.275705926 */, + /* 2622 */ 0x0469ddb2 | (17 << 27) /* 0.275846190 */, + /* 2623 */ 0x046a70ca | (17 << 27) /* 0.275986472 */, + + /* 2624 */ 0x046b03e7 | (17 << 27) /* 0.276126771 */, + /* 2625 */ 0x046b970a | (17 << 27) /* 0.276267088 */, + /* 2626 */ 0x046c2a31 | (17 << 27) /* 0.276407423 */, + /* 2627 */ 0x046cbd5c | (17 << 27) /* 0.276547776 */, + /* 2628 */ 0x046d508d | (17 << 27) /* 0.276688147 */, + /* 2629 */ 0x046de3c2 | (17 << 27) /* 0.276828535 */, + /* 2630 */ 0x046e76fc | (17 << 27) /* 0.276968942 */, + /* 2631 */ 0x046f0a3b | (17 << 27) /* 0.277109366 */, + /* 2632 */ 0x046f9d7e | (17 << 27) /* 0.277249808 */, + /* 2633 */ 0x047030c7 | (17 << 27) /* 0.277390267 */, + /* 2634 */ 0x0470c414 | (17 << 27) /* 0.277530745 */, + /* 2635 */ 0x04715766 | (17 << 27) /* 0.277671240 */, + /* 2636 */ 0x0471eabc | (17 << 27) /* 0.277811753 */, + /* 2637 */ 0x04727e18 | (17 << 27) /* 0.277952284 */, + /* 2638 */ 0x04731178 | (17 << 27) /* 0.278092832 */, + /* 2639 */ 0x0473a4dd | (17 << 27) /* 0.278233399 */, + + /* 2640 */ 0x04743847 | (17 << 27) /* 0.278373983 */, + /* 2641 */ 0x0474cbb5 | (17 << 27) /* 0.278514584 */, + /* 2642 */ 0x04755f29 | (17 << 27) /* 0.278655204 */, + /* 2643 */ 0x0475f2a1 | (17 << 27) /* 0.278795841 */, + /* 2644 */ 0x0476861d | (17 << 27) /* 0.278936496 */, + /* 2645 */ 0x0477199f | (17 << 27) /* 0.279077169 */, + /* 2646 */ 0x0477ad25 | (17 << 27) /* 0.279217860 */, + /* 2647 */ 0x047840b0 | (17 << 27) /* 0.279358568 */, + /* 2648 */ 0x0478d440 | (17 << 27) /* 0.279499294 */, + /* 2649 */ 0x047967d5 | (17 << 27) /* 0.279640037 */, + /* 2650 */ 0x0479fb6e | (17 << 27) /* 0.279780799 */, + /* 2651 */ 0x047a8f0c | (17 << 27) /* 0.279921578 */, + /* 2652 */ 0x047b22af | (17 << 27) /* 0.280062375 */, + /* 2653 */ 0x047bb657 | (17 << 27) /* 0.280203189 */, + /* 2654 */ 0x047c4a03 | (17 << 27) /* 0.280344021 */, + /* 2655 */ 0x047cddb4 | (17 << 27) /* 0.280484871 */, + + /* 2656 */ 0x047d716a | (17 << 27) /* 0.280625739 */, + /* 2657 */ 0x047e0524 | (17 << 27) /* 0.280766624 */, + /* 2658 */ 0x047e98e4 | (17 << 27) /* 0.280907527 */, + /* 2659 */ 0x047f2ca8 | (17 << 27) /* 0.281048447 */, + /* 2660 */ 0x047fc071 | (17 << 27) /* 0.281189385 */, + /* 2661 */ 0x0480543e | (17 << 27) /* 0.281330341 */, + /* 2662 */ 0x0480e811 | (17 << 27) /* 0.281471315 */, + /* 2663 */ 0x04817be8 | (17 << 27) /* 0.281612306 */, + /* 2664 */ 0x04820fc3 | (17 << 27) /* 0.281753315 */, + /* 2665 */ 0x0482a3a4 | (17 << 27) /* 0.281894341 */, + /* 2666 */ 0x04833789 | (17 << 27) /* 0.282035386 */, + /* 2667 */ 0x0483cb73 | (17 << 27) /* 0.282176447 */, + /* 2668 */ 0x04845f62 | (17 << 27) /* 0.282317527 */, + /* 2669 */ 0x0484f355 | (17 << 27) /* 0.282458624 */, + /* 2670 */ 0x0485874d | (17 << 27) /* 0.282599738 */, + /* 2671 */ 0x04861b4a | (17 << 27) /* 0.282740871 */, + + /* 2672 */ 0x0486af4c | (17 << 27) /* 0.282882021 */, + /* 2673 */ 0x04874352 | (17 << 27) /* 0.283023188 */, + /* 2674 */ 0x0487d75d | (17 << 27) /* 0.283164373 */, + /* 2675 */ 0x04886b6d | (17 << 27) /* 0.283305576 */, + /* 2676 */ 0x0488ff82 | (17 << 27) /* 0.283446796 */, + /* 2677 */ 0x0489939b | (17 << 27) /* 0.283588034 */, + /* 2678 */ 0x048a27b9 | (17 << 27) /* 0.283729290 */, + /* 2679 */ 0x048abbdc | (17 << 27) /* 0.283870563 */, + /* 2680 */ 0x048b5003 | (17 << 27) /* 0.284011853 */, + /* 2681 */ 0x048be42f | (17 << 27) /* 0.284153161 */, + /* 2682 */ 0x048c7860 | (17 << 27) /* 0.284294487 */, + /* 2683 */ 0x048d0c96 | (17 << 27) /* 0.284435831 */, + /* 2684 */ 0x048da0d0 | (17 << 27) /* 0.284577192 */, + /* 2685 */ 0x048e350f | (17 << 27) /* 0.284718570 */, + /* 2686 */ 0x048ec953 | (17 << 27) /* 0.284859966 */, + /* 2687 */ 0x048f5d9b | (17 << 27) /* 0.285001380 */, + + /* 2688 */ 0x048ff1e8 | (17 << 27) /* 0.285142811 */, + /* 2689 */ 0x0490863a | (17 << 27) /* 0.285284259 */, + /* 2690 */ 0x04911a91 | (17 << 27) /* 0.285425726 */, + /* 2691 */ 0x0491aeec | (17 << 27) /* 0.285567209 */, + /* 2692 */ 0x0492434c | (17 << 27) /* 0.285708711 */, + /* 2693 */ 0x0492d7b0 | (17 << 27) /* 0.285850229 */, + /* 2694 */ 0x04936c1a | (17 << 27) /* 0.285991766 */, + /* 2695 */ 0x04940088 | (17 << 27) /* 0.286133319 */, + /* 2696 */ 0x049494fb | (17 << 27) /* 0.286274891 */, + /* 2697 */ 0x04952972 | (17 << 27) /* 0.286416480 */, + /* 2698 */ 0x0495bdee | (17 << 27) /* 0.286558086 */, + /* 2699 */ 0x0496526f | (17 << 27) /* 0.286699710 */, + /* 2700 */ 0x0496e6f5 | (17 << 27) /* 0.286841351 */, + /* 2701 */ 0x04977b7f | (17 << 27) /* 0.286983010 */, + /* 2702 */ 0x0498100e | (17 << 27) /* 0.287124686 */, + /* 2703 */ 0x0498a4a1 | (17 << 27) /* 0.287266380 */, + + /* 2704 */ 0x0499393a | (17 << 27) /* 0.287408091 */, + /* 2705 */ 0x0499cdd7 | (17 << 27) /* 0.287549820 */, + /* 2706 */ 0x049a6278 | (17 << 27) /* 0.287691566 */, + /* 2707 */ 0x049af71f | (17 << 27) /* 0.287833330 */, + /* 2708 */ 0x049b8bca | (17 << 27) /* 0.287975111 */, + /* 2709 */ 0x049c207a | (17 << 27) /* 0.288116909 */, + /* 2710 */ 0x049cb52e | (17 << 27) /* 0.288258725 */, + /* 2711 */ 0x049d49e7 | (17 << 27) /* 0.288400559 */, + /* 2712 */ 0x049ddea5 | (17 << 27) /* 0.288542409 */, + /* 2713 */ 0x049e7367 | (17 << 27) /* 0.288684278 */, + /* 2714 */ 0x049f082f | (17 << 27) /* 0.288826163 */, + /* 2715 */ 0x049f9cfa | (17 << 27) /* 0.288968067 */, + /* 2716 */ 0x04a031cb | (17 << 27) /* 0.289109987 */, + /* 2717 */ 0x04a0c6a0 | (17 << 27) /* 0.289251925 */, + /* 2718 */ 0x04a15b7a | (17 << 27) /* 0.289393881 */, + /* 2719 */ 0x04a1f059 | (17 << 27) /* 0.289535854 */, + + /* 2720 */ 0x04a2853c | (17 << 27) /* 0.289677844 */, + /* 2721 */ 0x04a31a24 | (17 << 27) /* 0.289819851 */, + /* 2722 */ 0x04a3af10 | (17 << 27) /* 0.289961876 */, + /* 2723 */ 0x04a44401 | (17 << 27) /* 0.290103919 */, + /* 2724 */ 0x04a4d8f7 | (17 << 27) /* 0.290245979 */, + /* 2725 */ 0x04a56df2 | (17 << 27) /* 0.290388056 */, + /* 2726 */ 0x04a602f1 | (17 << 27) /* 0.290530150 */, + /* 2727 */ 0x04a697f5 | (17 << 27) /* 0.290672262 */, + /* 2728 */ 0x04a72cfe | (17 << 27) /* 0.290814392 */, + /* 2729 */ 0x04a7c20b | (17 << 27) /* 0.290956538 */, + /* 2730 */ 0x04a8571d | (17 << 27) /* 0.291098703 */, + /* 2731 */ 0x04a8ec33 | (17 << 27) /* 0.291240884 */, + /* 2732 */ 0x04a9814e | (17 << 27) /* 0.291383083 */, + /* 2733 */ 0x04aa166e | (17 << 27) /* 0.291525299 */, + /* 2734 */ 0x04aaab93 | (17 << 27) /* 0.291667532 */, + /* 2735 */ 0x04ab40bc | (17 << 27) /* 0.291809783 */, + + /* 2736 */ 0x04abd5ea | (17 << 27) /* 0.291952051 */, + /* 2737 */ 0x04ac6b1c | (17 << 27) /* 0.292094337 */, + /* 2738 */ 0x04ad0053 | (17 << 27) /* 0.292236640 */, + /* 2739 */ 0x04ad958f | (17 << 27) /* 0.292378960 */, + /* 2740 */ 0x04ae2ad0 | (17 << 27) /* 0.292521297 */, + /* 2741 */ 0x04aec015 | (17 << 27) /* 0.292663652 */, + /* 2742 */ 0x04af555e | (17 << 27) /* 0.292806024 */, + /* 2743 */ 0x04afeaad | (17 << 27) /* 0.292948414 */, + /* 2744 */ 0x04b08000 | (17 << 27) /* 0.293090820 */, + /* 2745 */ 0x04b11557 | (17 << 27) /* 0.293233244 */, + /* 2746 */ 0x04b1aab4 | (17 << 27) /* 0.293375686 */, + /* 2747 */ 0x04b24015 | (17 << 27) /* 0.293518144 */, + /* 2748 */ 0x04b2d57a | (17 << 27) /* 0.293660620 */, + /* 2749 */ 0x04b36ae4 | (17 << 27) /* 0.293803113 */, + /* 2750 */ 0x04b40053 | (17 << 27) /* 0.293945624 */, + /* 2751 */ 0x04b495c7 | (17 << 27) /* 0.294088151 */, + + /* 2752 */ 0x04b52b3f | (17 << 27) /* 0.294230696 */, + /* 2753 */ 0x04b5c0bc | (17 << 27) /* 0.294373259 */, + /* 2754 */ 0x04b6563d | (17 << 27) /* 0.294515838 */, + /* 2755 */ 0x04b6ebc3 | (17 << 27) /* 0.294658435 */, + /* 2756 */ 0x04b7814e | (17 << 27) /* 0.294801049 */, + /* 2757 */ 0x04b816dd | (17 << 27) /* 0.294943680 */, + /* 2758 */ 0x04b8ac71 | (17 << 27) /* 0.295086329 */, + /* 2759 */ 0x04b9420a | (17 << 27) /* 0.295228995 */, + /* 2760 */ 0x04b9d7a7 | (17 << 27) /* 0.295371678 */, + /* 2761 */ 0x04ba6d49 | (17 << 27) /* 0.295514378 */, + /* 2762 */ 0x04bb02ef | (17 << 27) /* 0.295657095 */, + /* 2763 */ 0x04bb989a | (17 << 27) /* 0.295799830 */, + /* 2764 */ 0x04bc2e4a | (17 << 27) /* 0.295942582 */, + /* 2765 */ 0x04bcc3fe | (17 << 27) /* 0.296085351 */, + /* 2766 */ 0x04bd59b7 | (17 << 27) /* 0.296228138 */, + /* 2767 */ 0x04bdef74 | (17 << 27) /* 0.296370941 */, + + /* 2768 */ 0x04be8537 | (17 << 27) /* 0.296513762 */, + /* 2769 */ 0x04bf1afd | (17 << 27) /* 0.296656600 */, + /* 2770 */ 0x04bfb0c9 | (17 << 27) /* 0.296799455 */, + /* 2771 */ 0x04c04699 | (17 << 27) /* 0.296942327 */, + /* 2772 */ 0x04c0dc6d | (17 << 27) /* 0.297085217 */, + /* 2773 */ 0x04c17247 | (17 << 27) /* 0.297228124 */, + /* 2774 */ 0x04c20824 | (17 << 27) /* 0.297371048 */, + /* 2775 */ 0x04c29e07 | (17 << 27) /* 0.297513989 */, + /* 2776 */ 0x04c333ee | (17 << 27) /* 0.297656947 */, + /* 2777 */ 0x04c3c9da | (17 << 27) /* 0.297799922 */, + /* 2778 */ 0x04c45fca | (17 << 27) /* 0.297942915 */, + /* 2779 */ 0x04c4f5bf | (17 << 27) /* 0.298085925 */, + /* 2780 */ 0x04c58bb8 | (17 << 27) /* 0.298228951 */, + /* 2781 */ 0x04c621b6 | (17 << 27) /* 0.298371996 */, + /* 2782 */ 0x04c6b7b9 | (17 << 27) /* 0.298515057 */, + /* 2783 */ 0x04c74dc0 | (17 << 27) /* 0.298658135 */, + + /* 2784 */ 0x04c7e3cc | (17 << 27) /* 0.298801231 */, + /* 2785 */ 0x04c879dd | (17 << 27) /* 0.298944343 */, + /* 2786 */ 0x04c90ff2 | (17 << 27) /* 0.299087473 */, + /* 2787 */ 0x04c9a60c | (17 << 27) /* 0.299230620 */, + /* 2788 */ 0x04ca3c2a | (17 << 27) /* 0.299373784 */, + /* 2789 */ 0x04cad24d | (17 << 27) /* 0.299516965 */, + /* 2790 */ 0x04cb6874 | (17 << 27) /* 0.299660163 */, + /* 2791 */ 0x04cbfea0 | (17 << 27) /* 0.299803378 */, + /* 2792 */ 0x04cc94d1 | (17 << 27) /* 0.299946611 */, + /* 2793 */ 0x04cd2b06 | (17 << 27) /* 0.300089860 */, + /* 2794 */ 0x04cdc140 | (17 << 27) /* 0.300233127 */, + /* 2795 */ 0x04ce577f | (17 << 27) /* 0.300376411 */, + /* 2796 */ 0x04ceedc2 | (17 << 27) /* 0.300519711 */, + /* 2797 */ 0x04cf8409 | (17 << 27) /* 0.300663029 */, + /* 2798 */ 0x04d01a55 | (17 << 27) /* 0.300806364 */, + /* 2799 */ 0x04d0b0a6 | (17 << 27) /* 0.300949716 */, + + /* 2800 */ 0x04d146fb | (17 << 27) /* 0.301093085 */, + /* 2801 */ 0x04d1dd55 | (17 << 27) /* 0.301236472 */, + /* 2802 */ 0x04d273b4 | (17 << 27) /* 0.301379875 */, + /* 2803 */ 0x04d30a17 | (17 << 27) /* 0.301523295 */, + /* 2804 */ 0x04d3a07f | (17 << 27) /* 0.301666733 */, + /* 2805 */ 0x04d436eb | (17 << 27) /* 0.301810187 */, + /* 2806 */ 0x04d4cd5c | (17 << 27) /* 0.301953659 */, + /* 2807 */ 0x04d563d1 | (17 << 27) /* 0.302097147 */, + /* 2808 */ 0x04d5fa4b | (17 << 27) /* 0.302240653 */, + /* 2809 */ 0x04d690ca | (17 << 27) /* 0.302384175 */, + /* 2810 */ 0x04d7274d | (17 << 27) /* 0.302527715 */, + /* 2811 */ 0x04d7bdd5 | (17 << 27) /* 0.302671271 */, + /* 2812 */ 0x04d85461 | (17 << 27) /* 0.302814845 */, + /* 2813 */ 0x04d8eaf2 | (17 << 27) /* 0.302958436 */, + /* 2814 */ 0x04d98187 | (17 << 27) /* 0.303102044 */, + /* 2815 */ 0x04da1821 | (17 << 27) /* 0.303245668 */, + + /* 2816 */ 0x04daaec0 | (17 << 27) /* 0.303389310 */, + /* 2817 */ 0x04db4563 | (17 << 27) /* 0.303532969 */, + /* 2818 */ 0x04dbdc0a | (17 << 27) /* 0.303676645 */, + /* 2819 */ 0x04dc72b7 | (17 << 27) /* 0.303820337 */, + /* 2820 */ 0x04dd0967 | (17 << 27) /* 0.303964047 */, + /* 2821 */ 0x04dda01d | (17 << 27) /* 0.304107774 */, + /* 2822 */ 0x04de36d7 | (17 << 27) /* 0.304251517 */, + /* 2823 */ 0x04decd95 | (17 << 27) /* 0.304395278 */, + /* 2824 */ 0x04df6458 | (17 << 27) /* 0.304539056 */, + /* 2825 */ 0x04dffb20 | (17 << 27) /* 0.304682850 */, + /* 2826 */ 0x04e091ec | (17 << 27) /* 0.304826662 */, + /* 2827 */ 0x04e128bc | (17 << 27) /* 0.304970491 */, + /* 2828 */ 0x04e1bf92 | (17 << 27) /* 0.305114336 */, + /* 2829 */ 0x04e2566b | (17 << 27) /* 0.305258199 */, + /* 2830 */ 0x04e2ed4a | (17 << 27) /* 0.305402078 */, + /* 2831 */ 0x04e3842d | (17 << 27) /* 0.305545974 */, + + /* 2832 */ 0x04e41b14 | (17 << 27) /* 0.305689888 */, + /* 2833 */ 0x04e4b200 | (17 << 27) /* 0.305833818 */, + /* 2834 */ 0x04e548f1 | (17 << 27) /* 0.305977765 */, + /* 2835 */ 0x04e5dfe6 | (17 << 27) /* 0.306121729 */, + /* 2836 */ 0x04e676df | (17 << 27) /* 0.306265710 */, + /* 2837 */ 0x04e70dde | (17 << 27) /* 0.306409708 */, + /* 2838 */ 0x04e7a4e0 | (17 << 27) /* 0.306553723 */, + /* 2839 */ 0x04e83be7 | (17 << 27) /* 0.306697755 */, + /* 2840 */ 0x04e8d2f3 | (17 << 27) /* 0.306841804 */, + /* 2841 */ 0x04e96a04 | (17 << 27) /* 0.306985869 */, + /* 2842 */ 0x04ea0118 | (17 << 27) /* 0.307129952 */, + /* 2843 */ 0x04ea9832 | (17 << 27) /* 0.307274051 */, + /* 2844 */ 0x04eb2f50 | (17 << 27) /* 0.307418168 */, + /* 2845 */ 0x04ebc672 | (17 << 27) /* 0.307562301 */, + /* 2846 */ 0x04ec5d99 | (17 << 27) /* 0.307706451 */, + /* 2847 */ 0x04ecf4c5 | (17 << 27) /* 0.307850618 */, + + /* 2848 */ 0x04ed8bf5 | (17 << 27) /* 0.307994802 */, + /* 2849 */ 0x04ee2329 | (17 << 27) /* 0.308139003 */, + /* 2850 */ 0x04eeba63 | (17 << 27) /* 0.308283220 */, + /* 2851 */ 0x04ef51a0 | (17 << 27) /* 0.308427455 */, + /* 2852 */ 0x04efe8e2 | (17 << 27) /* 0.308571706 */, + /* 2853 */ 0x04f08029 | (17 << 27) /* 0.308715974 */, + /* 2854 */ 0x04f11774 | (17 << 27) /* 0.308860260 */, + /* 2855 */ 0x04f1aec4 | (17 << 27) /* 0.309004561 */, + /* 2856 */ 0x04f24618 | (17 << 27) /* 0.309148880 */, + /* 2857 */ 0x04f2dd71 | (17 << 27) /* 0.309293216 */, + /* 2858 */ 0x04f374cf | (17 << 27) /* 0.309437568 */, + /* 2859 */ 0x04f40c30 | (17 << 27) /* 0.309581938 */, + /* 2860 */ 0x04f4a397 | (17 << 27) /* 0.309726324 */, + /* 2861 */ 0x04f53b02 | (17 << 27) /* 0.309870727 */, + /* 2862 */ 0x04f5d271 | (17 << 27) /* 0.310015147 */, + /* 2863 */ 0x04f669e5 | (17 << 27) /* 0.310159583 */, + + /* 2864 */ 0x04f7015d | (17 << 27) /* 0.310304037 */, + /* 2865 */ 0x04f798da | (17 << 27) /* 0.310448507 */, + /* 2866 */ 0x04f8305c | (17 << 27) /* 0.310592994 */, + /* 2867 */ 0x04f8c7e2 | (17 << 27) /* 0.310737498 */, + /* 2868 */ 0x04f95f6c | (17 << 27) /* 0.310882018 */, + /* 2869 */ 0x04f9f6fb | (17 << 27) /* 0.311026556 */, + /* 2870 */ 0x04fa8e8f | (17 << 27) /* 0.311171110 */, + /* 2871 */ 0x04fb2627 | (17 << 27) /* 0.311315681 */, + /* 2872 */ 0x04fbbdc3 | (17 << 27) /* 0.311460269 */, + /* 2873 */ 0x04fc5564 | (17 << 27) /* 0.311604874 */, + /* 2874 */ 0x04fced0a | (17 << 27) /* 0.311749495 */, + /* 2875 */ 0x04fd84b4 | (17 << 27) /* 0.311894133 */, + /* 2876 */ 0x04fe1c62 | (17 << 27) /* 0.312038788 */, + /* 2877 */ 0x04feb415 | (17 << 27) /* 0.312183460 */, + /* 2878 */ 0x04ff4bcd | (17 << 27) /* 0.312328148 */, + /* 2879 */ 0x04ffe389 | (17 << 27) /* 0.312472854 */, + + /* 2880 */ 0x05007b49 | (17 << 27) /* 0.312617576 */, + /* 2881 */ 0x0501130e | (17 << 27) /* 0.312762314 */, + /* 2882 */ 0x0501aad8 | (17 << 27) /* 0.312907070 */, + /* 2883 */ 0x050242a6 | (17 << 27) /* 0.313051842 */, + /* 2884 */ 0x0502da78 | (17 << 27) /* 0.313196631 */, + /* 2885 */ 0x0503724f | (17 << 27) /* 0.313341437 */, + /* 2886 */ 0x05040a2b | (17 << 27) /* 0.313486259 */, + /* 2887 */ 0x0504a20b | (17 << 27) /* 0.313631098 */, + /* 2888 */ 0x050539ef | (17 << 27) /* 0.313775954 */, + /* 2889 */ 0x0505d1d8 | (17 << 27) /* 0.313920827 */, + /* 2890 */ 0x050669c5 | (17 << 27) /* 0.314065716 */, + /* 2891 */ 0x050701b7 | (17 << 27) /* 0.314210622 */, + /* 2892 */ 0x050799ae | (17 << 27) /* 0.314355545 */, + /* 2893 */ 0x050831a9 | (17 << 27) /* 0.314500484 */, + /* 2894 */ 0x0508c9a8 | (17 << 27) /* 0.314645440 */, + /* 2895 */ 0x050961ac | (17 << 27) /* 0.314790413 */, + + /* 2896 */ 0x0509f9b4 | (17 << 27) /* 0.314935403 */, + /* 2897 */ 0x050a91c1 | (17 << 27) /* 0.315080409 */, + /* 2898 */ 0x050b29d2 | (17 << 27) /* 0.315225432 */, + /* 2899 */ 0x050bc1e8 | (17 << 27) /* 0.315370472 */, + /* 2900 */ 0x050c5a02 | (17 << 27) /* 0.315515528 */, + /* 2901 */ 0x050cf221 | (17 << 27) /* 0.315660601 */, + /* 2902 */ 0x050d8a44 | (17 << 27) /* 0.315805690 */, + /* 2903 */ 0x050e226c | (17 << 27) /* 0.315950797 */, + /* 2904 */ 0x050eba98 | (17 << 27) /* 0.316095920 */, + /* 2905 */ 0x050f52c9 | (17 << 27) /* 0.316241059 */, + /* 2906 */ 0x050feafe | (17 << 27) /* 0.316386216 */, + /* 2907 */ 0x05108337 | (17 << 27) /* 0.316531388 */, + /* 2908 */ 0x05111b75 | (17 << 27) /* 0.316676578 */, + /* 2909 */ 0x0511b3b8 | (17 << 27) /* 0.316821784 */, + /* 2910 */ 0x05124bff | (17 << 27) /* 0.316967007 */, + /* 2911 */ 0x0512e44a | (17 << 27) /* 0.317112247 */, + + /* 2912 */ 0x05137c9a | (17 << 27) /* 0.317257503 */, + /* 2913 */ 0x051414ee | (17 << 27) /* 0.317402775 */, + /* 2914 */ 0x0514ad47 | (17 << 27) /* 0.317548065 */, + /* 2915 */ 0x051545a5 | (17 << 27) /* 0.317693371 */, + /* 2916 */ 0x0515de06 | (17 << 27) /* 0.317838693 */, + /* 2917 */ 0x0516766d | (17 << 27) /* 0.317984033 */, + /* 2918 */ 0x05170ed7 | (17 << 27) /* 0.318129388 */, + /* 2919 */ 0x0517a746 | (17 << 27) /* 0.318274761 */, + /* 2920 */ 0x05183fba | (17 << 27) /* 0.318420150 */, + /* 2921 */ 0x0518d832 | (17 << 27) /* 0.318565555 */, + /* 2922 */ 0x051970ae | (17 << 27) /* 0.318710978 */, + /* 2923 */ 0x051a092f | (17 << 27) /* 0.318856416 */, + /* 2924 */ 0x051aa1b5 | (17 << 27) /* 0.319001872 */, + /* 2925 */ 0x051b3a3f | (17 << 27) /* 0.319147344 */, + /* 2926 */ 0x051bd2cd | (17 << 27) /* 0.319292832 */, + /* 2927 */ 0x051c6b60 | (17 << 27) /* 0.319438338 */, + + /* 2928 */ 0x051d03f7 | (17 << 27) /* 0.319583859 */, + /* 2929 */ 0x051d9c92 | (17 << 27) /* 0.319729398 */, + /* 2930 */ 0x051e3532 | (17 << 27) /* 0.319874952 */, + /* 2931 */ 0x051ecdd7 | (17 << 27) /* 0.320020524 */, + /* 2932 */ 0x051f6680 | (17 << 27) /* 0.320166112 */, + /* 2933 */ 0x051fff2d | (17 << 27) /* 0.320311716 */, + /* 2934 */ 0x052097df | (17 << 27) /* 0.320457337 */, + /* 2935 */ 0x05213095 | (17 << 27) /* 0.320602975 */, + /* 2936 */ 0x0521c950 | (17 << 27) /* 0.320748629 */, + /* 2937 */ 0x0522620f | (17 << 27) /* 0.320894300 */, + /* 2938 */ 0x0522fad3 | (17 << 27) /* 0.321039987 */, + /* 2939 */ 0x0523939b | (17 << 27) /* 0.321185691 */, + /* 2940 */ 0x05242c68 | (17 << 27) /* 0.321331411 */, + /* 2941 */ 0x0524c538 | (17 << 27) /* 0.321477148 */, + /* 2942 */ 0x05255e0e | (17 << 27) /* 0.321622901 */, + /* 2943 */ 0x0525f6e8 | (17 << 27) /* 0.321768671 */, + + /* 2944 */ 0x05268fc6 | (17 << 27) /* 0.321914457 */, + /* 2945 */ 0x052728a9 | (17 << 27) /* 0.322060260 */, + /* 2946 */ 0x0527c190 | (17 << 27) /* 0.322206079 */, + /* 2947 */ 0x05285a7b | (17 << 27) /* 0.322351915 */, + /* 2948 */ 0x0528f36b | (17 << 27) /* 0.322497768 */, + /* 2949 */ 0x05298c5f | (17 << 27) /* 0.322643636 */, + /* 2950 */ 0x052a2558 | (17 << 27) /* 0.322789522 */, + /* 2951 */ 0x052abe55 | (17 << 27) /* 0.322935424 */, + /* 2952 */ 0x052b5757 | (17 << 27) /* 0.323081342 */, + /* 2953 */ 0x052bf05d | (17 << 27) /* 0.323227277 */, + /* 2954 */ 0x052c8968 | (17 << 27) /* 0.323373228 */, + /* 2955 */ 0x052d2277 | (17 << 27) /* 0.323519196 */, + /* 2956 */ 0x052dbb8a | (17 << 27) /* 0.323665180 */, + /* 2957 */ 0x052e54a2 | (17 << 27) /* 0.323811180 */, + /* 2958 */ 0x052eedbe | (17 << 27) /* 0.323957197 */, + /* 2959 */ 0x052f86de | (17 << 27) /* 0.324103231 */, + + /* 2960 */ 0x05302003 | (17 << 27) /* 0.324249281 */, + /* 2961 */ 0x0530b92d | (17 << 27) /* 0.324395347 */, + /* 2962 */ 0x0531525b | (17 << 27) /* 0.324541430 */, + /* 2963 */ 0x0531eb8d | (17 << 27) /* 0.324687530 */, + /* 2964 */ 0x053284c4 | (17 << 27) /* 0.324833646 */, + /* 2965 */ 0x05331dff | (17 << 27) /* 0.324979778 */, + /* 2966 */ 0x0533b73e | (17 << 27) /* 0.325125926 */, + /* 2967 */ 0x05345082 | (17 << 27) /* 0.325272091 */, + /* 2968 */ 0x0534e9ca | (17 << 27) /* 0.325418273 */, + /* 2969 */ 0x05358317 | (17 << 27) /* 0.325564471 */, + /* 2970 */ 0x05361c68 | (17 << 27) /* 0.325710685 */, + /* 2971 */ 0x0536b5be | (17 << 27) /* 0.325856916 */, + /* 2972 */ 0x05374f17 | (17 << 27) /* 0.326003163 */, + /* 2973 */ 0x0537e876 | (17 << 27) /* 0.326149427 */, + /* 2974 */ 0x053881d9 | (17 << 27) /* 0.326295707 */, + /* 2975 */ 0x05391b40 | (17 << 27) /* 0.326442003 */, + + /* 2976 */ 0x0539b4ab | (17 << 27) /* 0.326588316 */, + /* 2977 */ 0x053a4e1b | (17 << 27) /* 0.326734645 */, + /* 2978 */ 0x053ae78f | (17 << 27) /* 0.326880990 */, + /* 2979 */ 0x053b8108 | (17 << 27) /* 0.327027352 */, + /* 2980 */ 0x053c1a85 | (17 << 27) /* 0.327173730 */, + /* 2981 */ 0x053cb407 | (17 << 27) /* 0.327320125 */, + /* 2982 */ 0x053d4d8d | (17 << 27) /* 0.327466536 */, + /* 2983 */ 0x053de717 | (17 << 27) /* 0.327612963 */, + /* 2984 */ 0x053e80a6 | (17 << 27) /* 0.327759407 */, + /* 2985 */ 0x053f1a39 | (17 << 27) /* 0.327905867 */, + /* 2986 */ 0x053fb3d0 | (17 << 27) /* 0.328052344 */, + /* 2987 */ 0x05404d6c | (17 << 27) /* 0.328198837 */, + /* 2988 */ 0x0540e70c | (17 << 27) /* 0.328345346 */, + /* 2989 */ 0x054180b1 | (17 << 27) /* 0.328491871 */, + /* 2990 */ 0x05421a5a | (17 << 27) /* 0.328638413 */, + /* 2991 */ 0x0542b407 | (17 << 27) /* 0.328784971 */, + + /* 2992 */ 0x05434db9 | (17 << 27) /* 0.328931546 */, + /* 2993 */ 0x0543e76f | (17 << 27) /* 0.329078137 */, + /* 2994 */ 0x0544812a | (17 << 27) /* 0.329224744 */, + /* 2995 */ 0x05451ae9 | (17 << 27) /* 0.329371367 */, + /* 2996 */ 0x0545b4ac | (17 << 27) /* 0.329518007 */, + /* 2997 */ 0x05464e74 | (17 << 27) /* 0.329664663 */, + /* 2998 */ 0x0546e840 | (17 << 27) /* 0.329811336 */, + /* 2999 */ 0x05478211 | (17 << 27) /* 0.329958024 */, + /* 3000 */ 0x05481be5 | (17 << 27) /* 0.330104730 */, + /* 3001 */ 0x0548b5bf | (17 << 27) /* 0.330251451 */, + /* 3002 */ 0x05494f9c | (17 << 27) /* 0.330398189 */, + /* 3003 */ 0x0549e97e | (17 << 27) /* 0.330544943 */, + /* 3004 */ 0x054a8364 | (17 << 27) /* 0.330691713 */, + /* 3005 */ 0x054b1d4f | (17 << 27) /* 0.330838499 */, + /* 3006 */ 0x054bb73e | (17 << 27) /* 0.330985302 */, + /* 3007 */ 0x054c5132 | (17 << 27) /* 0.331132121 */, + + /* 3008 */ 0x054ceb2a | (17 << 27) /* 0.331278957 */, + /* 3009 */ 0x054d8526 | (17 << 27) /* 0.331425808 */, + /* 3010 */ 0x054e1f26 | (17 << 27) /* 0.331572676 */, + /* 3011 */ 0x054eb92b | (17 << 27) /* 0.331719560 */, + /* 3012 */ 0x054f5334 | (17 << 27) /* 0.331866461 */, + /* 3013 */ 0x054fed42 | (17 << 27) /* 0.332013377 */, + /* 3014 */ 0x05508754 | (17 << 27) /* 0.332160310 */, + /* 3015 */ 0x0551216b | (17 << 27) /* 0.332307260 */, + /* 3016 */ 0x0551bb85 | (17 << 27) /* 0.332454225 */, + /* 3017 */ 0x055255a4 | (17 << 27) /* 0.332601207 */, + /* 3018 */ 0x0552efc8 | (17 << 27) /* 0.332748205 */, + /* 3019 */ 0x055389f0 | (17 << 27) /* 0.332895219 */, + /* 3020 */ 0x0554241c | (17 << 27) /* 0.333042249 */, + /* 3021 */ 0x0554be4c | (17 << 27) /* 0.333189296 */, + /* 3022 */ 0x05555881 | (17 << 27) /* 0.333336359 */, + /* 3023 */ 0x0555f2ba | (17 << 27) /* 0.333483438 */, + + /* 3024 */ 0x05568cf8 | (17 << 27) /* 0.333630533 */, + /* 3025 */ 0x0557273a | (17 << 27) /* 0.333777645 */, + /* 3026 */ 0x0557c180 | (17 << 27) /* 0.333924772 */, + /* 3027 */ 0x05585bcb | (17 << 27) /* 0.334071916 */, + /* 3028 */ 0x0558f61a | (17 << 27) /* 0.334219076 */, + /* 3029 */ 0x0559906d | (17 << 27) /* 0.334366253 */, + /* 3030 */ 0x055a2ac5 | (17 << 27) /* 0.334513445 */, + /* 3031 */ 0x055ac521 | (17 << 27) /* 0.334660654 */, + /* 3032 */ 0x055b5f81 | (17 << 27) /* 0.334807879 */, + /* 3033 */ 0x055bf9e6 | (17 << 27) /* 0.334955120 */, + /* 3034 */ 0x055c944f | (17 << 27) /* 0.335102377 */, + /* 3035 */ 0x055d2ebd | (17 << 27) /* 0.335249651 */, + /* 3036 */ 0x055dc92e | (17 << 27) /* 0.335396941 */, + /* 3037 */ 0x055e63a5 | (17 << 27) /* 0.335544246 */, + /* 3038 */ 0x055efe1f | (17 << 27) /* 0.335691568 */, + /* 3039 */ 0x055f989e | (17 << 27) /* 0.335838906 */, + + /* 3040 */ 0x05603321 | (17 << 27) /* 0.335986261 */, + /* 3041 */ 0x0560cda8 | (17 << 27) /* 0.336133631 */, + /* 3042 */ 0x05616834 | (17 << 27) /* 0.336281018 */, + /* 3043 */ 0x056202c4 | (17 << 27) /* 0.336428421 */, + /* 3044 */ 0x05629d59 | (17 << 27) /* 0.336575840 */, + /* 3045 */ 0x056337f2 | (17 << 27) /* 0.336723275 */, + /* 3046 */ 0x0563d28f | (17 << 27) /* 0.336870726 */, + /* 3047 */ 0x05646d30 | (17 << 27) /* 0.337018193 */, + /* 3048 */ 0x056507d6 | (17 << 27) /* 0.337165677 */, + /* 3049 */ 0x0565a280 | (17 << 27) /* 0.337313176 */, + /* 3050 */ 0x05663d2f | (17 << 27) /* 0.337460692 */, + /* 3051 */ 0x0566d7e1 | (17 << 27) /* 0.337608224 */, + /* 3052 */ 0x05677298 | (17 << 27) /* 0.337755772 */, + /* 3053 */ 0x05680d54 | (17 << 27) /* 0.337903336 */, + /* 3054 */ 0x0568a814 | (17 << 27) /* 0.338050916 */, + /* 3055 */ 0x056942d8 | (17 << 27) /* 0.338198513 */, + + /* 3056 */ 0x0569dda0 | (17 << 27) /* 0.338346125 */, + /* 3057 */ 0x056a786d | (17 << 27) /* 0.338493753 */, + /* 3058 */ 0x056b133e | (17 << 27) /* 0.338641398 */, + /* 3059 */ 0x056bae13 | (17 << 27) /* 0.338789059 */, + /* 3060 */ 0x056c48ed | (17 << 27) /* 0.338936736 */, + /* 3061 */ 0x056ce3cb | (17 << 27) /* 0.339084429 */, + /* 3062 */ 0x056d7ead | (17 << 27) /* 0.339232138 */, + /* 3063 */ 0x056e1994 | (17 << 27) /* 0.339379863 */, + /* 3064 */ 0x056eb47f | (17 << 27) /* 0.339527604 */, + /* 3065 */ 0x056f4f6e | (17 << 27) /* 0.339675361 */, + /* 3066 */ 0x056fea62 | (17 << 27) /* 0.339823134 */, + /* 3067 */ 0x0570855a | (17 << 27) /* 0.339970924 */, + /* 3068 */ 0x05712056 | (17 << 27) /* 0.340118729 */, + /* 3069 */ 0x0571bb56 | (17 << 27) /* 0.340266550 */, + /* 3070 */ 0x0572565b | (17 << 27) /* 0.340414388 */, + /* 3071 */ 0x0572f164 | (17 << 27) /* 0.340562242 */, + + /* 3072 */ 0x05738c72 | (17 << 27) /* 0.340710111 */, + /* 3073 */ 0x05742784 | (17 << 27) /* 0.340857997 */, + /* 3074 */ 0x0574c29a | (17 << 27) /* 0.341005899 */, + /* 3075 */ 0x05755db4 | (17 << 27) /* 0.341153816 */, + /* 3076 */ 0x0575f8d3 | (17 << 27) /* 0.341301750 */, + /* 3077 */ 0x057693f6 | (17 << 27) /* 0.341449700 */, + /* 3078 */ 0x05772f1d | (17 << 27) /* 0.341597666 */, + /* 3079 */ 0x0577ca49 | (17 << 27) /* 0.341745648 */, + /* 3080 */ 0x05786578 | (17 << 27) /* 0.341893646 */, + /* 3081 */ 0x057900ad | (17 << 27) /* 0.342041659 */, + /* 3082 */ 0x05799be5 | (17 << 27) /* 0.342189689 */, + /* 3083 */ 0x057a3722 | (17 << 27) /* 0.342337735 */, + /* 3084 */ 0x057ad263 | (17 << 27) /* 0.342485797 */, + /* 3085 */ 0x057b6da8 | (17 << 27) /* 0.342633875 */, + /* 3086 */ 0x057c08f2 | (17 << 27) /* 0.342781969 */, + /* 3087 */ 0x057ca440 | (17 << 27) /* 0.342930079 */, + + /* 3088 */ 0x057d3f92 | (17 << 27) /* 0.343078205 */, + /* 3089 */ 0x057ddae9 | (17 << 27) /* 0.343226347 */, + /* 3090 */ 0x057e7644 | (17 << 27) /* 0.343374505 */, + /* 3091 */ 0x057f11a3 | (17 << 27) /* 0.343522679 */, + /* 3092 */ 0x057fad06 | (17 << 27) /* 0.343670869 */, + /* 3093 */ 0x0580486e | (17 << 27) /* 0.343819075 */, + /* 3094 */ 0x0580e3da | (17 << 27) /* 0.343967296 */, + /* 3095 */ 0x05817f4a | (17 << 27) /* 0.344115534 */, + /* 3096 */ 0x05821abf | (17 << 27) /* 0.344263788 */, + /* 3097 */ 0x0582b638 | (17 << 27) /* 0.344412058 */, + /* 3098 */ 0x058351b5 | (17 << 27) /* 0.344560343 */, + /* 3099 */ 0x0583ed36 | (17 << 27) /* 0.344708645 */, + /* 3100 */ 0x058488bc | (17 << 27) /* 0.344856963 */, + /* 3101 */ 0x05852446 | (17 << 27) /* 0.345005296 */, + /* 3102 */ 0x0585bfd4 | (17 << 27) /* 0.345153646 */, + /* 3103 */ 0x05865b67 | (17 << 27) /* 0.345302011 */, + + /* 3104 */ 0x0586f6fd | (17 << 27) /* 0.345450393 */, + /* 3105 */ 0x05879298 | (17 << 27) /* 0.345598790 */, + /* 3106 */ 0x05882e38 | (17 << 27) /* 0.345747203 */, + /* 3107 */ 0x0588c9dc | (17 << 27) /* 0.345895632 */, + /* 3108 */ 0x05896583 | (17 << 27) /* 0.346044077 */, + /* 3109 */ 0x058a0130 | (17 << 27) /* 0.346192538 */, + /* 3110 */ 0x058a9ce0 | (17 << 27) /* 0.346341015 */, + /* 3111 */ 0x058b3895 | (17 << 27) /* 0.346489508 */, + /* 3112 */ 0x058bd44e | (17 << 27) /* 0.346638017 */, + /* 3113 */ 0x058c700b | (17 << 27) /* 0.346786542 */, + /* 3114 */ 0x058d0bcd | (17 << 27) /* 0.346935082 */, + /* 3115 */ 0x058da793 | (17 << 27) /* 0.347083639 */, + /* 3116 */ 0x058e435d | (17 << 27) /* 0.347232211 */, + /* 3117 */ 0x058edf2b | (17 << 27) /* 0.347380799 */, + /* 3118 */ 0x058f7afe | (17 << 27) /* 0.347529403 */, + /* 3119 */ 0x059016d5 | (17 << 27) /* 0.347678023 */, + + /* 3120 */ 0x0590b2b0 | (17 << 27) /* 0.347826659 */, + /* 3121 */ 0x05914e8f | (17 << 27) /* 0.347975311 */, + /* 3122 */ 0x0591ea73 | (17 << 27) /* 0.348123979 */, + /* 3123 */ 0x0592865b | (17 << 27) /* 0.348272662 */, + /* 3124 */ 0x05932247 | (17 << 27) /* 0.348421362 */, + /* 3125 */ 0x0593be37 | (17 << 27) /* 0.348570077 */, + /* 3126 */ 0x05945a2c | (17 << 27) /* 0.348718808 */, + /* 3127 */ 0x0594f625 | (17 << 27) /* 0.348867555 */, + /* 3128 */ 0x05959222 | (17 << 27) /* 0.349016318 */, + /* 3129 */ 0x05962e24 | (17 << 27) /* 0.349165097 */, + /* 3130 */ 0x0596ca2a | (17 << 27) /* 0.349313892 */, + /* 3131 */ 0x05976634 | (17 << 27) /* 0.349462702 */, + /* 3132 */ 0x05980242 | (17 << 27) /* 0.349611528 */, + /* 3133 */ 0x05989e54 | (17 << 27) /* 0.349760370 */, + /* 3134 */ 0x05993a6b | (17 << 27) /* 0.349909228 */, + /* 3135 */ 0x0599d686 | (17 << 27) /* 0.350058102 */, + + /* 3136 */ 0x059a72a5 | (17 << 27) /* 0.350206992 */, + /* 3137 */ 0x059b0ec9 | (17 << 27) /* 0.350355897 */, + /* 3138 */ 0x059baaf1 | (17 << 27) /* 0.350504818 */, + /* 3139 */ 0x059c471d | (17 << 27) /* 0.350653756 */, + /* 3140 */ 0x059ce34d | (17 << 27) /* 0.350802708 */, + /* 3141 */ 0x059d7f81 | (17 << 27) /* 0.350951677 */, + /* 3142 */ 0x059e1bba | (17 << 27) /* 0.351100662 */, + /* 3143 */ 0x059eb7f7 | (17 << 27) /* 0.351249662 */, + /* 3144 */ 0x059f5438 | (17 << 27) /* 0.351398678 */, + /* 3145 */ 0x059ff07e | (17 << 27) /* 0.351547710 */, + /* 3146 */ 0x05a08cc7 | (17 << 27) /* 0.351696758 */, + /* 3147 */ 0x05a12915 | (17 << 27) /* 0.351845821 */, + /* 3148 */ 0x05a1c567 | (17 << 27) /* 0.351994901 */, + /* 3149 */ 0x05a261be | (17 << 27) /* 0.352143996 */, + /* 3150 */ 0x05a2fe18 | (17 << 27) /* 0.352293107 */, + /* 3151 */ 0x05a39a77 | (17 << 27) /* 0.352442233 */, + + /* 3152 */ 0x05a436da | (17 << 27) /* 0.352591376 */, + /* 3153 */ 0x05a4d342 | (17 << 27) /* 0.352740534 */, + /* 3154 */ 0x05a56fad | (17 << 27) /* 0.352889708 */, + /* 3155 */ 0x05a60c1d | (17 << 27) /* 0.353038898 */, + /* 3156 */ 0x05a6a891 | (17 << 27) /* 0.353188103 */, + /* 3157 */ 0x05a7450a | (17 << 27) /* 0.353337325 */, + /* 3158 */ 0x05a7e186 | (17 << 27) /* 0.353486562 */, + /* 3159 */ 0x05a87e07 | (17 << 27) /* 0.353635814 */, + /* 3160 */ 0x05a91a8c | (17 << 27) /* 0.353785083 */, + /* 3161 */ 0x05a9b715 | (17 << 27) /* 0.353934367 */, + /* 3162 */ 0x05aa53a2 | (17 << 27) /* 0.354083667 */, + /* 3163 */ 0x05aaf034 | (17 << 27) /* 0.354232983 */, + /* 3164 */ 0x05ab8cca | (17 << 27) /* 0.354382314 */, + /* 3165 */ 0x05ac2964 | (17 << 27) /* 0.354531662 */, + /* 3166 */ 0x05acc602 | (17 << 27) /* 0.354681025 */, + /* 3167 */ 0x05ad62a5 | (17 << 27) /* 0.354830403 */, + + /* 3168 */ 0x05adff4c | (17 << 27) /* 0.354979798 */, + /* 3169 */ 0x05ae9bf7 | (17 << 27) /* 0.355129208 */, + /* 3170 */ 0x05af38a6 | (17 << 27) /* 0.355278634 */, + /* 3171 */ 0x05afd559 | (17 << 27) /* 0.355428075 */, + /* 3172 */ 0x05b07211 | (17 << 27) /* 0.355577533 */, + /* 3173 */ 0x05b10ecd | (17 << 27) /* 0.355727006 */, + /* 3174 */ 0x05b1ab8d | (17 << 27) /* 0.355876494 */, + /* 3175 */ 0x05b24851 | (17 << 27) /* 0.356025999 */, + /* 3176 */ 0x05b2e51a | (17 << 27) /* 0.356175519 */, + /* 3177 */ 0x05b381e6 | (17 << 27) /* 0.356325054 */, + /* 3178 */ 0x05b41eb7 | (17 << 27) /* 0.356474606 */, + /* 3179 */ 0x05b4bb8c | (17 << 27) /* 0.356624173 */, + /* 3180 */ 0x05b55866 | (17 << 27) /* 0.356773756 */, + /* 3181 */ 0x05b5f543 | (17 << 27) /* 0.356923354 */, + /* 3182 */ 0x05b69225 | (17 << 27) /* 0.357072969 */, + /* 3183 */ 0x05b72f0b | (17 << 27) /* 0.357222598 */, + + /* 3184 */ 0x05b7cbf5 | (17 << 27) /* 0.357372244 */, + /* 3185 */ 0x05b868e3 | (17 << 27) /* 0.357521905 */, + /* 3186 */ 0x05b905d6 | (17 << 27) /* 0.357671582 */, + /* 3187 */ 0x05b9a2cd | (17 << 27) /* 0.357821275 */, + /* 3188 */ 0x05ba3fc8 | (17 << 27) /* 0.357970983 */, + /* 3189 */ 0x05badcc7 | (17 << 27) /* 0.358120707 */, + /* 3190 */ 0x05bb79ca | (17 << 27) /* 0.358270446 */, + /* 3191 */ 0x05bc16d2 | (17 << 27) /* 0.358420201 */, + /* 3192 */ 0x05bcb3de | (17 << 27) /* 0.358569972 */, + /* 3193 */ 0x05bd50ee | (17 << 27) /* 0.358719758 */, + /* 3194 */ 0x05bdee02 | (17 << 27) /* 0.358869560 */, + /* 3195 */ 0x05be8b1a | (17 << 27) /* 0.359019378 */, + /* 3196 */ 0x05bf2837 | (17 << 27) /* 0.359169211 */, + /* 3197 */ 0x05bfc558 | (17 << 27) /* 0.359319060 */, + /* 3198 */ 0x05c0627d | (17 << 27) /* 0.359468925 */, + /* 3199 */ 0x05c0ffa6 | (17 << 27) /* 0.359618805 */, + + /* 3200 */ 0x05c19cd3 | (17 << 27) /* 0.359768701 */, + /* 3201 */ 0x05c23a05 | (17 << 27) /* 0.359918612 */, + /* 3202 */ 0x05c2d73a | (17 << 27) /* 0.360068540 */, + /* 3203 */ 0x05c37474 | (17 << 27) /* 0.360218482 */, + /* 3204 */ 0x05c411b2 | (17 << 27) /* 0.360368440 */, + /* 3205 */ 0x05c4aef5 | (17 << 27) /* 0.360518414 */, + /* 3206 */ 0x05c54c3b | (17 << 27) /* 0.360668404 */, + /* 3207 */ 0x05c5e986 | (17 << 27) /* 0.360818409 */, + /* 3208 */ 0x05c686d5 | (17 << 27) /* 0.360968429 */, + /* 3209 */ 0x05c72428 | (17 << 27) /* 0.361118466 */, + /* 3210 */ 0x05c7c17f | (17 << 27) /* 0.361268517 */, + /* 3211 */ 0x05c85eda | (17 << 27) /* 0.361418585 */, + /* 3212 */ 0x05c8fc3a | (17 << 27) /* 0.361568668 */, + /* 3213 */ 0x05c9999e | (17 << 27) /* 0.361718766 */, + /* 3214 */ 0x05ca3706 | (17 << 27) /* 0.361868881 */, + /* 3215 */ 0x05cad472 | (17 << 27) /* 0.362019010 */, + + /* 3216 */ 0x05cb71e2 | (17 << 27) /* 0.362169156 */, + /* 3217 */ 0x05cc0f57 | (17 << 27) /* 0.362319316 */, + /* 3218 */ 0x05ccaccf | (17 << 27) /* 0.362469493 */, + /* 3219 */ 0x05cd4a4c | (17 << 27) /* 0.362619685 */, + /* 3220 */ 0x05cde7cd | (17 << 27) /* 0.362769892 */, + /* 3221 */ 0x05ce8552 | (17 << 27) /* 0.362920115 */, + /* 3222 */ 0x05cf22dc | (17 << 27) /* 0.363070354 */, + /* 3223 */ 0x05cfc069 | (17 << 27) /* 0.363220608 */, + /* 3224 */ 0x05d05dfb | (17 << 27) /* 0.363370878 */, + /* 3225 */ 0x05d0fb91 | (17 << 27) /* 0.363521163 */, + /* 3226 */ 0x05d1992b | (17 << 27) /* 0.363671464 */, + /* 3227 */ 0x05d236c9 | (17 << 27) /* 0.363821780 */, + /* 3228 */ 0x05d2d46c | (17 << 27) /* 0.363972112 */, + /* 3229 */ 0x05d37212 | (17 << 27) /* 0.364122459 */, + /* 3230 */ 0x05d40fbd | (17 << 27) /* 0.364272822 */, + /* 3231 */ 0x05d4ad6c | (17 << 27) /* 0.364423200 */, + + /* 3232 */ 0x05d54b1f | (17 << 27) /* 0.364573594 */, + /* 3233 */ 0x05d5e8d6 | (17 << 27) /* 0.364724004 */, + /* 3234 */ 0x05d68691 | (17 << 27) /* 0.364874429 */, + /* 3235 */ 0x05d72451 | (17 << 27) /* 0.365024869 */, + /* 3236 */ 0x05d7c215 | (17 << 27) /* 0.365175325 */, + /* 3237 */ 0x05d85fdc | (17 << 27) /* 0.365325796 */, + /* 3238 */ 0x05d8fda8 | (17 << 27) /* 0.365476283 */, + /* 3239 */ 0x05d99b79 | (17 << 27) /* 0.365626786 */, + /* 3240 */ 0x05da394d | (17 << 27) /* 0.365777304 */, + /* 3241 */ 0x05dad726 | (17 << 27) /* 0.365927837 */, + /* 3242 */ 0x05db7502 | (17 << 27) /* 0.366078386 */, + /* 3243 */ 0x05dc12e3 | (17 << 27) /* 0.366228950 */, + /* 3244 */ 0x05dcb0c8 | (17 << 27) /* 0.366379530 */, + /* 3245 */ 0x05dd4eb1 | (17 << 27) /* 0.366530125 */, + /* 3246 */ 0x05ddec9e | (17 << 27) /* 0.366680736 */, + /* 3247 */ 0x05de8a90 | (17 << 27) /* 0.366831362 */, + + /* 3248 */ 0x05df2885 | (17 << 27) /* 0.366982004 */, + /* 3249 */ 0x05dfc67f | (17 << 27) /* 0.367132661 */, + /* 3250 */ 0x05e0647d | (17 << 27) /* 0.367283334 */, + /* 3251 */ 0x05e1027f | (17 << 27) /* 0.367434022 */, + /* 3252 */ 0x05e1a085 | (17 << 27) /* 0.367584725 */, + /* 3253 */ 0x05e23e8f | (17 << 27) /* 0.367735444 */, + /* 3254 */ 0x05e2dc9e | (17 << 27) /* 0.367886179 */, + /* 3255 */ 0x05e37ab0 | (17 << 27) /* 0.368036929 */, + /* 3256 */ 0x05e418c7 | (17 << 27) /* 0.368187694 */, + /* 3257 */ 0x05e4b6e2 | (17 << 27) /* 0.368338475 */, + /* 3258 */ 0x05e55501 | (17 << 27) /* 0.368489271 */, + /* 3259 */ 0x05e5f324 | (17 << 27) /* 0.368640082 */, + /* 3260 */ 0x05e6914c | (17 << 27) /* 0.368790909 */, + /* 3261 */ 0x05e72f77 | (17 << 27) /* 0.368941752 */, + /* 3262 */ 0x05e7cda7 | (17 << 27) /* 0.369092610 */, + /* 3263 */ 0x05e86bda | (17 << 27) /* 0.369243483 */, + + /* 3264 */ 0x05e90a12 | (17 << 27) /* 0.369394372 */, + /* 3265 */ 0x05e9a84e | (17 << 27) /* 0.369545276 */, + /* 3266 */ 0x05ea468e | (17 << 27) /* 0.369696195 */, + /* 3267 */ 0x05eae4d3 | (17 << 27) /* 0.369847130 */, + /* 3268 */ 0x05eb831b | (17 << 27) /* 0.369998080 */, + /* 3269 */ 0x05ec2168 | (17 << 27) /* 0.370149046 */, + /* 3270 */ 0x05ecbfb8 | (17 << 27) /* 0.370300027 */, + /* 3271 */ 0x05ed5e0d | (17 << 27) /* 0.370451024 */, + /* 3272 */ 0x05edfc66 | (17 << 27) /* 0.370602036 */, + /* 3273 */ 0x05ee9ac3 | (17 << 27) /* 0.370753063 */, + /* 3274 */ 0x05ef3924 | (17 << 27) /* 0.370904105 */, + /* 3275 */ 0x05efd78a | (17 << 27) /* 0.371055163 */, + /* 3276 */ 0x05f075f3 | (17 << 27) /* 0.371206237 */, + /* 3277 */ 0x05f11461 | (17 << 27) /* 0.371357326 */, + /* 3278 */ 0x05f1b2d3 | (17 << 27) /* 0.371508430 */, + /* 3279 */ 0x05f25148 | (17 << 27) /* 0.371659549 */, + + /* 3280 */ 0x05f2efc2 | (17 << 27) /* 0.371810684 */, + /* 3281 */ 0x05f38e40 | (17 << 27) /* 0.371961834 */, + /* 3282 */ 0x05f42cc3 | (17 << 27) /* 0.372113000 */, + /* 3283 */ 0x05f4cb49 | (17 << 27) /* 0.372264181 */, + /* 3284 */ 0x05f569d3 | (17 << 27) /* 0.372415377 */, + /* 3285 */ 0x05f60862 | (17 << 27) /* 0.372566589 */, + /* 3286 */ 0x05f6a6f5 | (17 << 27) /* 0.372717816 */, + /* 3287 */ 0x05f7458b | (17 << 27) /* 0.372869058 */, + /* 3288 */ 0x05f7e426 | (17 << 27) /* 0.373020316 */, + /* 3289 */ 0x05f882c5 | (17 << 27) /* 0.373171589 */, + /* 3290 */ 0x05f92169 | (17 << 27) /* 0.373322877 */, + /* 3291 */ 0x05f9c010 | (17 << 27) /* 0.373474181 */, + /* 3292 */ 0x05fa5ebb | (17 << 27) /* 0.373625500 */, + /* 3293 */ 0x05fafd6b | (17 << 27) /* 0.373776834 */, + /* 3294 */ 0x05fb9c1e | (17 << 27) /* 0.373928184 */, + /* 3295 */ 0x05fc3ad6 | (17 << 27) /* 0.374079549 */, + + /* 3296 */ 0x05fcd992 | (17 << 27) /* 0.374230929 */, + /* 3297 */ 0x05fd7852 | (17 << 27) /* 0.374382325 */, + /* 3298 */ 0x05fe1716 | (17 << 27) /* 0.374533735 */, + /* 3299 */ 0x05feb5de | (17 << 27) /* 0.374685162 */, + /* 3300 */ 0x05ff54aa | (17 << 27) /* 0.374836603 */, + /* 3301 */ 0x05fff37b | (17 << 27) /* 0.374988060 */, + /* 3302 */ 0x0600924f | (17 << 27) /* 0.375139532 */, + /* 3303 */ 0x06013128 | (17 << 27) /* 0.375291019 */, + /* 3304 */ 0x0601d004 | (17 << 27) /* 0.375442522 */, + /* 3305 */ 0x06026ee5 | (17 << 27) /* 0.375594040 */, + /* 3306 */ 0x06030dca | (17 << 27) /* 0.375745573 */, + /* 3307 */ 0x0603acb3 | (17 << 27) /* 0.375897122 */, + /* 3308 */ 0x06044ba0 | (17 << 27) /* 0.376048685 */, + /* 3309 */ 0x0604ea91 | (17 << 27) /* 0.376200265 */, + /* 3310 */ 0x06058987 | (17 << 27) /* 0.376351859 */, + /* 3311 */ 0x06062880 | (17 << 27) /* 0.376503468 */, + + /* 3312 */ 0x0606c77d | (17 << 27) /* 0.376655093 */, + /* 3313 */ 0x0607667f | (17 << 27) /* 0.376806733 */, + /* 3314 */ 0x06080585 | (17 << 27) /* 0.376958389 */, + /* 3315 */ 0x0608a48f | (17 << 27) /* 0.377110059 */, + /* 3316 */ 0x0609439c | (17 << 27) /* 0.377261745 */, + /* 3317 */ 0x0609e2ae | (17 << 27) /* 0.377413446 */, + /* 3318 */ 0x060a81c4 | (17 << 27) /* 0.377565163 */, + /* 3319 */ 0x060b20df | (17 << 27) /* 0.377716894 */, + /* 3320 */ 0x060bbffd | (17 << 27) /* 0.377868641 */, + /* 3321 */ 0x060c5f1f | (17 << 27) /* 0.378020403 */, + /* 3322 */ 0x060cfe46 | (17 << 27) /* 0.378172181 */, + /* 3323 */ 0x060d9d70 | (17 << 27) /* 0.378323973 */, + /* 3324 */ 0x060e3c9f | (17 << 27) /* 0.378475781 */, + /* 3325 */ 0x060edbd1 | (17 << 27) /* 0.378627604 */, + /* 3326 */ 0x060f7b08 | (17 << 27) /* 0.378779442 */, + /* 3327 */ 0x06101a43 | (17 << 27) /* 0.378931296 */, + + /* 3328 */ 0x0610b982 | (17 << 27) /* 0.379083164 */, + /* 3329 */ 0x061158c5 | (17 << 27) /* 0.379235048 */, + /* 3330 */ 0x0611f80c | (17 << 27) /* 0.379386947 */, + /* 3331 */ 0x06129757 | (17 << 27) /* 0.379538862 */, + /* 3332 */ 0x061336a6 | (17 << 27) /* 0.379690791 */, + /* 3333 */ 0x0613d5fa | (17 << 27) /* 0.379842736 */, + /* 3334 */ 0x06147551 | (17 << 27) /* 0.379994696 */, + /* 3335 */ 0x061514ad | (17 << 27) /* 0.380146671 */, + /* 3336 */ 0x0615b40c | (17 << 27) /* 0.380298661 */, + /* 3337 */ 0x06165370 | (17 << 27) /* 0.380450666 */, + /* 3338 */ 0x0616f2d8 | (17 << 27) /* 0.380602687 */, + /* 3339 */ 0x06179243 | (17 << 27) /* 0.380754723 */, + /* 3340 */ 0x061831b3 | (17 << 27) /* 0.380906774 */, + /* 3341 */ 0x0618d127 | (17 << 27) /* 0.381058840 */, + /* 3342 */ 0x0619709f | (17 << 27) /* 0.381210921 */, + /* 3343 */ 0x061a101b | (17 << 27) /* 0.381363018 */, + + /* 3344 */ 0x061aaf9c | (17 << 27) /* 0.381515130 */, + /* 3345 */ 0x061b4f20 | (17 << 27) /* 0.381667257 */, + /* 3346 */ 0x061beea8 | (17 << 27) /* 0.381819399 */, + /* 3347 */ 0x061c8e34 | (17 << 27) /* 0.381971556 */, + /* 3348 */ 0x061d2dc5 | (17 << 27) /* 0.382123728 */, + /* 3349 */ 0x061dcd59 | (17 << 27) /* 0.382275916 */, + /* 3350 */ 0x061e6cf2 | (17 << 27) /* 0.382428118 */, + /* 3351 */ 0x061f0c8f | (17 << 27) /* 0.382580336 */, + /* 3352 */ 0x061fac2f | (17 << 27) /* 0.382732569 */, + /* 3353 */ 0x06204bd4 | (17 << 27) /* 0.382884817 */, + /* 3354 */ 0x0620eb7d | (17 << 27) /* 0.383037080 */, + /* 3355 */ 0x06218b2a | (17 << 27) /* 0.383189358 */, + /* 3356 */ 0x06222adb | (17 << 27) /* 0.383341652 */, + /* 3357 */ 0x0622ca90 | (17 << 27) /* 0.383493960 */, + /* 3358 */ 0x06236a49 | (17 << 27) /* 0.383646284 */, + /* 3359 */ 0x06240a06 | (17 << 27) /* 0.383798623 */, + + /* 3360 */ 0x0624a9c7 | (17 << 27) /* 0.383950977 */, + /* 3361 */ 0x0625498d | (17 << 27) /* 0.384103346 */, + /* 3362 */ 0x0625e956 | (17 << 27) /* 0.384255730 */, + /* 3363 */ 0x06268923 | (17 << 27) /* 0.384408129 */, + /* 3364 */ 0x062728f5 | (17 << 27) /* 0.384560544 */, + /* 3365 */ 0x0627c8ca | (17 << 27) /* 0.384712973 */, + /* 3366 */ 0x062868a4 | (17 << 27) /* 0.384865418 */, + /* 3367 */ 0x06290881 | (17 << 27) /* 0.385017878 */, + /* 3368 */ 0x0629a863 | (17 << 27) /* 0.385170352 */, + /* 3369 */ 0x062a4849 | (17 << 27) /* 0.385322842 */, + /* 3370 */ 0x062ae832 | (17 << 27) /* 0.385475347 */, + /* 3371 */ 0x062b8820 | (17 << 27) /* 0.385627867 */, + /* 3372 */ 0x062c2812 | (17 << 27) /* 0.385780402 */, + /* 3373 */ 0x062cc808 | (17 << 27) /* 0.385932953 */, + /* 3374 */ 0x062d6802 | (17 << 27) /* 0.386085518 */, + /* 3375 */ 0x062e0800 | (17 << 27) /* 0.386238098 */, + + /* 3376 */ 0x062ea802 | (17 << 27) /* 0.386390694 */, + /* 3377 */ 0x062f4808 | (17 << 27) /* 0.386543304 */, + /* 3378 */ 0x062fe812 | (17 << 27) /* 0.386695930 */, + /* 3379 */ 0x06308820 | (17 << 27) /* 0.386848570 */, + /* 3380 */ 0x06312832 | (17 << 27) /* 0.387001226 */, + /* 3381 */ 0x0631c849 | (17 << 27) /* 0.387153897 */, + /* 3382 */ 0x06326863 | (17 << 27) /* 0.387306582 */, + /* 3383 */ 0x06330881 | (17 << 27) /* 0.387459283 */, + /* 3384 */ 0x0633a8a3 | (17 << 27) /* 0.387611999 */, + /* 3385 */ 0x063448ca | (17 << 27) /* 0.387764730 */, + /* 3386 */ 0x0634e8f4 | (17 << 27) /* 0.387917476 */, + /* 3387 */ 0x06358923 | (17 << 27) /* 0.388070237 */, + /* 3388 */ 0x06362955 | (17 << 27) /* 0.388223013 */, + /* 3389 */ 0x0636c98c | (17 << 27) /* 0.388375804 */, + /* 3390 */ 0x063769c6 | (17 << 27) /* 0.388528610 */, + /* 3391 */ 0x06380a05 | (17 << 27) /* 0.388681431 */, + + /* 3392 */ 0x0638aa48 | (17 << 27) /* 0.388834268 */, + /* 3393 */ 0x06394a8e | (17 << 27) /* 0.388987119 */, + /* 3394 */ 0x0639ead9 | (17 << 27) /* 0.389139985 */, + /* 3395 */ 0x063a8b28 | (17 << 27) /* 0.389292866 */, + /* 3396 */ 0x063b2b7b | (17 << 27) /* 0.389445762 */, + /* 3397 */ 0x063bcbd1 | (17 << 27) /* 0.389598674 */, + /* 3398 */ 0x063c6c2c | (17 << 27) /* 0.389751600 */, + /* 3399 */ 0x063d0c8b | (17 << 27) /* 0.389904541 */, + /* 3400 */ 0x063dacee | (17 << 27) /* 0.390057497 */, + /* 3401 */ 0x063e4d55 | (17 << 27) /* 0.390210468 */, + /* 3402 */ 0x063eedc0 | (17 << 27) /* 0.390363455 */, + /* 3403 */ 0x063f8e2f | (17 << 27) /* 0.390516456 */, + /* 3404 */ 0x06402ea2 | (17 << 27) /* 0.390669472 */, + /* 3405 */ 0x0640cf19 | (17 << 27) /* 0.390822503 */, + /* 3406 */ 0x06416f94 | (17 << 27) /* 0.390975549 */, + /* 3407 */ 0x06421013 | (17 << 27) /* 0.391128611 */, + + /* 3408 */ 0x0642b096 | (17 << 27) /* 0.391281687 */, + /* 3409 */ 0x0643511d | (17 << 27) /* 0.391434778 */, + /* 3410 */ 0x0643f1a8 | (17 << 27) /* 0.391587884 */, + /* 3411 */ 0x06449237 | (17 << 27) /* 0.391741005 */, + /* 3412 */ 0x064532ca | (17 << 27) /* 0.391894141 */, + /* 3413 */ 0x0645d361 | (17 << 27) /* 0.392047292 */, + /* 3414 */ 0x064673fc | (17 << 27) /* 0.392200458 */, + /* 3415 */ 0x0647149c | (17 << 27) /* 0.392353638 */, + /* 3416 */ 0x0647b53f | (17 << 27) /* 0.392506834 */, + /* 3417 */ 0x064855e6 | (17 << 27) /* 0.392660045 */, + /* 3418 */ 0x0648f691 | (17 << 27) /* 0.392813271 */, + /* 3419 */ 0x06499740 | (17 << 27) /* 0.392966511 */, + /* 3420 */ 0x064a37f4 | (17 << 27) /* 0.393119767 */, + /* 3421 */ 0x064ad8ab | (17 << 27) /* 0.393273038 */, + /* 3422 */ 0x064b7966 | (17 << 27) /* 0.393426323 */, + /* 3423 */ 0x064c1a25 | (17 << 27) /* 0.393579623 */, + + /* 3424 */ 0x064cbae9 | (17 << 27) /* 0.393732939 */, + /* 3425 */ 0x064d5bb0 | (17 << 27) /* 0.393886269 */, + /* 3426 */ 0x064dfc7b | (17 << 27) /* 0.394039614 */, + /* 3427 */ 0x064e9d4b | (17 << 27) /* 0.394192974 */, + /* 3428 */ 0x064f3e1e | (17 << 27) /* 0.394346349 */, + /* 3429 */ 0x064fdef5 | (17 << 27) /* 0.394499739 */, + /* 3430 */ 0x06507fd0 | (17 << 27) /* 0.394653144 */, + /* 3431 */ 0x065120b0 | (17 << 27) /* 0.394806564 */, + /* 3432 */ 0x0651c193 | (17 << 27) /* 0.394959999 */, + /* 3433 */ 0x0652627a | (17 << 27) /* 0.395113448 */, + /* 3434 */ 0x06530366 | (17 << 27) /* 0.395266913 */, + /* 3435 */ 0x0653a455 | (17 << 27) /* 0.395420392 */, + /* 3436 */ 0x06544548 | (17 << 27) /* 0.395573886 */, + /* 3437 */ 0x0654e640 | (17 << 27) /* 0.395727395 */, + /* 3438 */ 0x0655873b | (17 << 27) /* 0.395880919 */, + /* 3439 */ 0x0656283a | (17 << 27) /* 0.396034458 */, + + /* 3440 */ 0x0656c93d | (17 << 27) /* 0.396188012 */, + /* 3441 */ 0x06576a45 | (17 << 27) /* 0.396341581 */, + /* 3442 */ 0x06580b50 | (17 << 27) /* 0.396495164 */, + /* 3443 */ 0x0658ac5f | (17 << 27) /* 0.396648763 */, + /* 3444 */ 0x06594d73 | (17 << 27) /* 0.396802376 */, + /* 3445 */ 0x0659ee8a | (17 << 27) /* 0.396956004 */, + /* 3446 */ 0x065a8fa5 | (17 << 27) /* 0.397109647 */, + /* 3447 */ 0x065b30c4 | (17 << 27) /* 0.397263305 */, + /* 3448 */ 0x065bd1e7 | (17 << 27) /* 0.397416978 */, + /* 3449 */ 0x065c730f | (17 << 27) /* 0.397570666 */, + /* 3450 */ 0x065d143a | (17 << 27) /* 0.397724368 */, + /* 3451 */ 0x065db569 | (17 << 27) /* 0.397878085 */, + /* 3452 */ 0x065e569c | (17 << 27) /* 0.398031818 */, + /* 3453 */ 0x065ef7d3 | (17 << 27) /* 0.398185565 */, + /* 3454 */ 0x065f990e | (17 << 27) /* 0.398339326 */, + /* 3455 */ 0x06603a4e | (17 << 27) /* 0.398493103 */, + + /* 3456 */ 0x0660db91 | (17 << 27) /* 0.398646895 */, + /* 3457 */ 0x06617cd8 | (17 << 27) /* 0.398800701 */, + /* 3458 */ 0x06621e23 | (17 << 27) /* 0.398954522 */, + /* 3459 */ 0x0662bf72 | (17 << 27) /* 0.399108358 */, + /* 3460 */ 0x066360c5 | (17 << 27) /* 0.399262209 */, + /* 3461 */ 0x0664021c | (17 << 27) /* 0.399416075 */, + /* 3462 */ 0x0664a377 | (17 << 27) /* 0.399569955 */, + /* 3463 */ 0x066544d6 | (17 << 27) /* 0.399723851 */, + /* 3464 */ 0x0665e639 | (17 << 27) /* 0.399877761 */, + /* 3465 */ 0x066687a0 | (17 << 27) /* 0.400031686 */, + /* 3466 */ 0x0667290b | (17 << 27) /* 0.400185625 */, + /* 3467 */ 0x0667ca79 | (17 << 27) /* 0.400339580 */, + /* 3468 */ 0x06686bec | (17 << 27) /* 0.400493549 */, + /* 3469 */ 0x06690d63 | (17 << 27) /* 0.400647534 */, + /* 3470 */ 0x0669aede | (17 << 27) /* 0.400801533 */, + /* 3471 */ 0x066a505d | (17 << 27) /* 0.400955546 */, + + /* 3472 */ 0x066af1df | (17 << 27) /* 0.401109575 */, + /* 3473 */ 0x066b9366 | (17 << 27) /* 0.401263618 */, + /* 3474 */ 0x066c34f1 | (17 << 27) /* 0.401417676 */, + /* 3475 */ 0x066cd67f | (17 << 27) /* 0.401571749 */, + /* 3476 */ 0x066d7812 | (17 << 27) /* 0.401725837 */, + /* 3477 */ 0x066e19a9 | (17 << 27) /* 0.401879939 */, + /* 3478 */ 0x066ebb43 | (17 << 27) /* 0.402034056 */, + /* 3479 */ 0x066f5ce2 | (17 << 27) /* 0.402188188 */, + /* 3480 */ 0x066ffe84 | (17 << 27) /* 0.402342335 */, + /* 3481 */ 0x0670a02a | (17 << 27) /* 0.402496497 */, + /* 3482 */ 0x067141d5 | (17 << 27) /* 0.402650673 */, + /* 3483 */ 0x0671e383 | (17 << 27) /* 0.402804864 */, + /* 3484 */ 0x06728535 | (17 << 27) /* 0.402959070 */, + /* 3485 */ 0x067326ec | (17 << 27) /* 0.403113291 */, + /* 3486 */ 0x0673c8a6 | (17 << 27) /* 0.403267526 */, + /* 3487 */ 0x06746a64 | (17 << 27) /* 0.403421776 */, + + /* 3488 */ 0x06750c26 | (17 << 27) /* 0.403576041 */, + /* 3489 */ 0x0675adec | (17 << 27) /* 0.403730320 */, + /* 3490 */ 0x06764fb6 | (17 << 27) /* 0.403884615 */, + /* 3491 */ 0x0676f184 | (17 << 27) /* 0.404038924 */, + /* 3492 */ 0x06779356 | (17 << 27) /* 0.404193247 */, + /* 3493 */ 0x0678352c | (17 << 27) /* 0.404347586 */, + /* 3494 */ 0x0678d706 | (17 << 27) /* 0.404501939 */, + /* 3495 */ 0x067978e4 | (17 << 27) /* 0.404656307 */, + /* 3496 */ 0x067a1ac6 | (17 << 27) /* 0.404810690 */, + /* 3497 */ 0x067abcac | (17 << 27) /* 0.404965087 */, + /* 3498 */ 0x067b5e95 | (17 << 27) /* 0.405119499 */, + /* 3499 */ 0x067c0083 | (17 << 27) /* 0.405273926 */, + /* 3500 */ 0x067ca275 | (17 << 27) /* 0.405428368 */, + /* 3501 */ 0x067d446a | (17 << 27) /* 0.405582824 */, + /* 3502 */ 0x067de664 | (17 << 27) /* 0.405737295 */, + /* 3503 */ 0x067e8861 | (17 << 27) /* 0.405891781 */, + + /* 3504 */ 0x067f2a62 | (17 << 27) /* 0.406046281 */, + /* 3505 */ 0x067fcc68 | (17 << 27) /* 0.406200796 */, + /* 3506 */ 0x06806e71 | (17 << 27) /* 0.406355326 */, + /* 3507 */ 0x0681107e | (17 << 27) /* 0.406509870 */, + /* 3508 */ 0x0681b28f | (17 << 27) /* 0.406664429 */, + /* 3509 */ 0x068254a4 | (17 << 27) /* 0.406819003 */, + /* 3510 */ 0x0682f6bd | (17 << 27) /* 0.406973592 */, + /* 3511 */ 0x068398da | (17 << 27) /* 0.407128195 */, + /* 3512 */ 0x06843afb | (17 << 27) /* 0.407282813 */, + /* 3513 */ 0x0684dd20 | (17 << 27) /* 0.407437445 */, + /* 3514 */ 0x06857f49 | (17 << 27) /* 0.407592093 */, + /* 3515 */ 0x06862176 | (17 << 27) /* 0.407746754 */, + /* 3516 */ 0x0686c3a6 | (17 << 27) /* 0.407901431 */, + /* 3517 */ 0x068765db | (17 << 27) /* 0.408056122 */, + /* 3518 */ 0x06880814 | (17 << 27) /* 0.408210828 */, + /* 3519 */ 0x0688aa50 | (17 << 27) /* 0.408365549 */, + + /* 3520 */ 0x06894c90 | (17 << 27) /* 0.408520284 */, + /* 3521 */ 0x0689eed5 | (17 << 27) /* 0.408675034 */, + /* 3522 */ 0x068a911d | (17 << 27) /* 0.408829798 */, + /* 3523 */ 0x068b3369 | (17 << 27) /* 0.408984577 */, + /* 3524 */ 0x068bd5b9 | (17 << 27) /* 0.409139371 */, + /* 3525 */ 0x068c780e | (17 << 27) /* 0.409294180 */, + /* 3526 */ 0x068d1a66 | (17 << 27) /* 0.409449003 */, + /* 3527 */ 0x068dbcc1 | (17 << 27) /* 0.409603840 */, + /* 3528 */ 0x068e5f21 | (17 << 27) /* 0.409758693 */, + /* 3529 */ 0x068f0185 | (17 << 27) /* 0.409913560 */, + /* 3530 */ 0x068fa3ed | (17 << 27) /* 0.410068441 */, + /* 3531 */ 0x06904658 | (17 << 27) /* 0.410223338 */, + /* 3532 */ 0x0690e8c8 | (17 << 27) /* 0.410378249 */, + /* 3533 */ 0x06918b3c | (17 << 27) /* 0.410533174 */, + /* 3534 */ 0x06922db3 | (17 << 27) /* 0.410688114 */, + /* 3535 */ 0x0692d02e | (17 << 27) /* 0.410843069 */, + + /* 3536 */ 0x069372ae | (17 << 27) /* 0.410998038 */, + /* 3537 */ 0x06941531 | (17 << 27) /* 0.411153022 */, + /* 3538 */ 0x0694b7b8 | (17 << 27) /* 0.411308021 */, + /* 3539 */ 0x06955a43 | (17 << 27) /* 0.411463034 */, + /* 3540 */ 0x0695fcd2 | (17 << 27) /* 0.411618062 */, + /* 3541 */ 0x06969f65 | (17 << 27) /* 0.411773104 */, + /* 3542 */ 0x069741fb | (17 << 27) /* 0.411928161 */, + /* 3543 */ 0x0697e496 | (17 << 27) /* 0.412083232 */, + /* 3544 */ 0x06988735 | (17 << 27) /* 0.412238319 */, + /* 3545 */ 0x069929d7 | (17 << 27) /* 0.412393419 */, + /* 3546 */ 0x0699cc7e | (17 << 27) /* 0.412548535 */, + /* 3547 */ 0x069a6f28 | (17 << 27) /* 0.412703664 */, + /* 3548 */ 0x069b11d6 | (17 << 27) /* 0.412858809 */, + /* 3549 */ 0x069bb489 | (17 << 27) /* 0.413013968 */, + /* 3550 */ 0x069c573f | (17 << 27) /* 0.413169142 */, + /* 3551 */ 0x069cf9f9 | (17 << 27) /* 0.413324330 */, + + /* 3552 */ 0x069d9cb7 | (17 << 27) /* 0.413479532 */, + /* 3553 */ 0x069e3f78 | (17 << 27) /* 0.413634750 */, + /* 3554 */ 0x069ee23e | (17 << 27) /* 0.413789982 */, + /* 3555 */ 0x069f8508 | (17 << 27) /* 0.413945228 */, + /* 3556 */ 0x06a027d5 | (17 << 27) /* 0.414100489 */, + /* 3557 */ 0x06a0caa7 | (17 << 27) /* 0.414255765 */, + /* 3558 */ 0x06a16d7c | (17 << 27) /* 0.414411055 */, + /* 3559 */ 0x06a21055 | (17 << 27) /* 0.414566359 */, + /* 3560 */ 0x06a2b333 | (17 << 27) /* 0.414721679 */, + /* 3561 */ 0x06a35614 | (17 << 27) /* 0.414877012 */, + /* 3562 */ 0x06a3f8f9 | (17 << 27) /* 0.415032361 */, + /* 3563 */ 0x06a49be2 | (17 << 27) /* 0.415187723 */, + /* 3564 */ 0x06a53ece | (17 << 27) /* 0.415343101 */, + /* 3565 */ 0x06a5e1bf | (17 << 27) /* 0.415498493 */, + /* 3566 */ 0x06a684b4 | (17 << 27) /* 0.415653899 */, + /* 3567 */ 0x06a727ac | (17 << 27) /* 0.415809320 */, + + /* 3568 */ 0x06a7caa9 | (17 << 27) /* 0.415964756 */, + /* 3569 */ 0x06a86da9 | (17 << 27) /* 0.416120206 */, + /* 3570 */ 0x06a910ad | (17 << 27) /* 0.416275670 */, + /* 3571 */ 0x06a9b3b5 | (17 << 27) /* 0.416431149 */, + /* 3572 */ 0x06aa56c1 | (17 << 27) /* 0.416586643 */, + /* 3573 */ 0x06aaf9d1 | (17 << 27) /* 0.416742151 */, + /* 3574 */ 0x06ab9ce5 | (17 << 27) /* 0.416897673 */, + /* 3575 */ 0x06ac3ffc | (17 << 27) /* 0.417053210 */, + /* 3576 */ 0x06ace318 | (17 << 27) /* 0.417208762 */, + /* 3577 */ 0x06ad8637 | (17 << 27) /* 0.417364328 */, + /* 3578 */ 0x06ae295b | (17 << 27) /* 0.417519909 */, + /* 3579 */ 0x06aecc82 | (17 << 27) /* 0.417675504 */, + /* 3580 */ 0x06af6fad | (17 << 27) /* 0.417831113 */, + /* 3581 */ 0x06b012dc | (17 << 27) /* 0.417986737 */, + /* 3582 */ 0x06b0b60f | (17 << 27) /* 0.418142376 */, + /* 3583 */ 0x06b15946 | (17 << 27) /* 0.418298029 */, + + /* 3584 */ 0x06b1fc81 | (17 << 27) /* 0.418453696 */, + /* 3585 */ 0x06b29fbf | (17 << 27) /* 0.418609378 */, + /* 3586 */ 0x06b34302 | (17 << 27) /* 0.418765075 */, + /* 3587 */ 0x06b3e648 | (17 << 27) /* 0.418920786 */, + /* 3588 */ 0x06b48992 | (17 << 27) /* 0.419076511 */, + /* 3589 */ 0x06b52ce0 | (17 << 27) /* 0.419232251 */, + /* 3590 */ 0x06b5d032 | (17 << 27) /* 0.419388005 */, + /* 3591 */ 0x06b67388 | (17 << 27) /* 0.419543774 */, + /* 3592 */ 0x06b716e2 | (17 << 27) /* 0.419699557 */, + /* 3593 */ 0x06b7ba3f | (17 << 27) /* 0.419855355 */, + /* 3594 */ 0x06b85da1 | (17 << 27) /* 0.420011167 */, + /* 3595 */ 0x06b90106 | (17 << 27) /* 0.420166994 */, + /* 3596 */ 0x06b9a470 | (17 << 27) /* 0.420322835 */, + /* 3597 */ 0x06ba47dd | (17 << 27) /* 0.420478690 */, + /* 3598 */ 0x06baeb4e | (17 << 27) /* 0.420634560 */, + /* 3599 */ 0x06bb8ec3 | (17 << 27) /* 0.420790445 */, + + /* 3600 */ 0x06bc323b | (17 << 27) /* 0.420946343 */, + /* 3601 */ 0x06bcd5b8 | (17 << 27) /* 0.421102257 */, + /* 3602 */ 0x06bd7939 | (17 << 27) /* 0.421258184 */, + /* 3603 */ 0x06be1cbd | (17 << 27) /* 0.421414127 */, + /* 3604 */ 0x06bec045 | (17 << 27) /* 0.421570083 */, + /* 3605 */ 0x06bf63d1 | (17 << 27) /* 0.421726054 */, + /* 3606 */ 0x06c00761 | (17 << 27) /* 0.421882040 */, + /* 3607 */ 0x06c0aaf5 | (17 << 27) /* 0.422038039 */, + /* 3608 */ 0x06c14e8d | (17 << 27) /* 0.422194054 */, + /* 3609 */ 0x06c1f229 | (17 << 27) /* 0.422350082 */, + /* 3610 */ 0x06c295c8 | (17 << 27) /* 0.422506125 */, + /* 3611 */ 0x06c3396c | (17 << 27) /* 0.422662183 */, + /* 3612 */ 0x06c3dd13 | (17 << 27) /* 0.422818255 */, + /* 3613 */ 0x06c480be | (17 << 27) /* 0.422974341 */, + /* 3614 */ 0x06c5246d | (17 << 27) /* 0.423130442 */, + /* 3615 */ 0x06c5c820 | (17 << 27) /* 0.423286557 */, + + /* 3616 */ 0x06c66bd6 | (17 << 27) /* 0.423442686 */, + /* 3617 */ 0x06c70f91 | (17 << 27) /* 0.423598830 */, + /* 3618 */ 0x06c7b34f | (17 << 27) /* 0.423754988 */, + /* 3619 */ 0x06c85712 | (17 << 27) /* 0.423911161 */, + /* 3620 */ 0x06c8fad8 | (17 << 27) /* 0.424067348 */, + /* 3621 */ 0x06c99ea2 | (17 << 27) /* 0.424223550 */, + /* 3622 */ 0x06ca4270 | (17 << 27) /* 0.424379765 */, + /* 3623 */ 0x06cae641 | (17 << 27) /* 0.424535996 */, + /* 3624 */ 0x06cb8a17 | (17 << 27) /* 0.424692240 */, + /* 3625 */ 0x06cc2df0 | (17 << 27) /* 0.424848499 */, + /* 3626 */ 0x06ccd1ce | (17 << 27) /* 0.425004772 */, + /* 3627 */ 0x06cd75af | (17 << 27) /* 0.425161060 */, + /* 3628 */ 0x06ce1994 | (17 << 27) /* 0.425317362 */, + /* 3629 */ 0x06cebd7d | (17 << 27) /* 0.425473678 */, + /* 3630 */ 0x06cf6169 | (17 << 27) /* 0.425630009 */, + /* 3631 */ 0x06d0055a | (17 << 27) /* 0.425786354 */, + + /* 3632 */ 0x06d0a94e | (17 << 27) /* 0.425942714 */, + /* 3633 */ 0x06d14d47 | (17 << 27) /* 0.426099088 */, + /* 3634 */ 0x06d1f143 | (17 << 27) /* 0.426255476 */, + /* 3635 */ 0x06d29543 | (17 << 27) /* 0.426411878 */, + /* 3636 */ 0x06d33947 | (17 << 27) /* 0.426568295 */, + /* 3637 */ 0x06d3dd4e | (17 << 27) /* 0.426724726 */, + /* 3638 */ 0x06d4815a | (17 << 27) /* 0.426881172 */, + /* 3639 */ 0x06d52569 | (17 << 27) /* 0.427037632 */, + /* 3640 */ 0x06d5c97c | (17 << 27) /* 0.427194106 */, + /* 3641 */ 0x06d66d93 | (17 << 27) /* 0.427350594 */, + /* 3642 */ 0x06d711ae | (17 << 27) /* 0.427507097 */, + /* 3643 */ 0x06d7b5cd | (17 << 27) /* 0.427663614 */, + /* 3644 */ 0x06d859f0 | (17 << 27) /* 0.427820146 */, + /* 3645 */ 0x06d8fe16 | (17 << 27) /* 0.427976692 */, + /* 3646 */ 0x06d9a240 | (17 << 27) /* 0.428133252 */, + /* 3647 */ 0x06da466f | (17 << 27) /* 0.428289826 */, + + /* 3648 */ 0x06daeaa1 | (17 << 27) /* 0.428446415 */, + /* 3649 */ 0x06db8ed6 | (17 << 27) /* 0.428603018 */, + /* 3650 */ 0x06dc3310 | (17 << 27) /* 0.428759635 */, + /* 3651 */ 0x06dcd74d | (17 << 27) /* 0.428916267 */, + /* 3652 */ 0x06dd7b8f | (17 << 27) /* 0.429072913 */, + /* 3653 */ 0x06de1fd4 | (17 << 27) /* 0.429229573 */, + /* 3654 */ 0x06dec41d | (17 << 27) /* 0.429386248 */, + /* 3655 */ 0x06df686a | (17 << 27) /* 0.429542937 */, + /* 3656 */ 0x06e00cbb | (17 << 27) /* 0.429699640 */, + /* 3657 */ 0x06e0b10f | (17 << 27) /* 0.429856357 */, + /* 3658 */ 0x06e15567 | (17 << 27) /* 0.430013089 */, + /* 3659 */ 0x06e1f9c4 | (17 << 27) /* 0.430169835 */, + /* 3660 */ 0x06e29e24 | (17 << 27) /* 0.430326595 */, + /* 3661 */ 0x06e34287 | (17 << 27) /* 0.430483370 */, + /* 3662 */ 0x06e3e6ef | (17 << 27) /* 0.430640159 */, + /* 3663 */ 0x06e48b5b | (17 << 27) /* 0.430796962 */, + + /* 3664 */ 0x06e52fca | (17 << 27) /* 0.430953779 */, + /* 3665 */ 0x06e5d43d | (17 << 27) /* 0.431110611 */, + /* 3666 */ 0x06e678b4 | (17 << 27) /* 0.431267457 */, + /* 3667 */ 0x06e71d2f | (17 << 27) /* 0.431424317 */, + /* 3668 */ 0x06e7c1ae | (17 << 27) /* 0.431581192 */, + /* 3669 */ 0x06e86630 | (17 << 27) /* 0.431738080 */, + /* 3670 */ 0x06e90ab7 | (17 << 27) /* 0.431894983 */, + /* 3671 */ 0x06e9af41 | (17 << 27) /* 0.432051900 */, + /* 3672 */ 0x06ea53cf | (17 << 27) /* 0.432208832 */, + /* 3673 */ 0x06eaf860 | (17 << 27) /* 0.432365778 */, + /* 3674 */ 0x06eb9cf6 | (17 << 27) /* 0.432522737 */, + /* 3675 */ 0x06ec418f | (17 << 27) /* 0.432679712 */, + /* 3676 */ 0x06ece62d | (17 << 27) /* 0.432836700 */, + /* 3677 */ 0x06ed8ace | (17 << 27) /* 0.432993703 */, + /* 3678 */ 0x06ee2f73 | (17 << 27) /* 0.433150720 */, + /* 3679 */ 0x06eed41b | (17 << 27) /* 0.433307751 */, + + /* 3680 */ 0x06ef78c8 | (17 << 27) /* 0.433464796 */, + /* 3681 */ 0x06f01d78 | (17 << 27) /* 0.433621856 */, + /* 3682 */ 0x06f0c22c | (17 << 27) /* 0.433778929 */, + /* 3683 */ 0x06f166e4 | (17 << 27) /* 0.433936017 */, + /* 3684 */ 0x06f20ba0 | (17 << 27) /* 0.434093120 */, + /* 3685 */ 0x06f2b060 | (17 << 27) /* 0.434250236 */, + /* 3686 */ 0x06f35523 | (17 << 27) /* 0.434407367 */, + /* 3687 */ 0x06f3f9eb | (17 << 27) /* 0.434564512 */, + /* 3688 */ 0x06f49eb6 | (17 << 27) /* 0.434721671 */, + /* 3689 */ 0x06f54385 | (17 << 27) /* 0.434878844 */, + /* 3690 */ 0x06f5e857 | (17 << 27) /* 0.435036032 */, + /* 3691 */ 0x06f68d2e | (17 << 27) /* 0.435193233 */, + /* 3692 */ 0x06f73208 | (17 << 27) /* 0.435350449 */, + /* 3693 */ 0x06f7d6e6 | (17 << 27) /* 0.435507679 */, + /* 3694 */ 0x06f87bc8 | (17 << 27) /* 0.435664924 */, + /* 3695 */ 0x06f920ae | (17 << 27) /* 0.435822182 */, + + /* 3696 */ 0x06f9c597 | (17 << 27) /* 0.435979455 */, + /* 3697 */ 0x06fa6a85 | (17 << 27) /* 0.436136741 */, + /* 3698 */ 0x06fb0f76 | (17 << 27) /* 0.436294042 */, + /* 3699 */ 0x06fbb46b | (17 << 27) /* 0.436451358 */, + /* 3700 */ 0x06fc5964 | (17 << 27) /* 0.436608687 */, + /* 3701 */ 0x06fcfe60 | (17 << 27) /* 0.436766031 */, + /* 3702 */ 0x06fda361 | (17 << 27) /* 0.436923388 */, + /* 3703 */ 0x06fe4865 | (17 << 27) /* 0.437080760 */, + /* 3704 */ 0x06feed6d | (17 << 27) /* 0.437238146 */, + /* 3705 */ 0x06ff9279 | (17 << 27) /* 0.437395547 */, + /* 3706 */ 0x07003788 | (17 << 27) /* 0.437552961 */, + /* 3707 */ 0x0700dc9c | (17 << 27) /* 0.437710389 */, + /* 3708 */ 0x070181b3 | (17 << 27) /* 0.437867832 */, + /* 3709 */ 0x070226ce | (17 << 27) /* 0.438025289 */, + /* 3710 */ 0x0702cbed | (17 << 27) /* 0.438182760 */, + /* 3711 */ 0x0703710f | (17 << 27) /* 0.438340245 */, + + /* 3712 */ 0x07041636 | (17 << 27) /* 0.438497744 */, + /* 3713 */ 0x0704bb60 | (17 << 27) /* 0.438655258 */, + /* 3714 */ 0x0705608e | (17 << 27) /* 0.438812785 */, + /* 3715 */ 0x070605c0 | (17 << 27) /* 0.438970327 */, + /* 3716 */ 0x0706aaf5 | (17 << 27) /* 0.439127883 */, + /* 3717 */ 0x0707502f | (17 << 27) /* 0.439285453 */, + /* 3718 */ 0x0707f56c | (17 << 27) /* 0.439443037 */, + /* 3719 */ 0x07089aad | (17 << 27) /* 0.439600635 */, + /* 3720 */ 0x07093ff2 | (17 << 27) /* 0.439758248 */, + /* 3721 */ 0x0709e53a | (17 << 27) /* 0.439915874 */, + /* 3722 */ 0x070a8a86 | (17 << 27) /* 0.440073515 */, + /* 3723 */ 0x070b2fd7 | (17 << 27) /* 0.440231170 */, + /* 3724 */ 0x070bd52a | (17 << 27) /* 0.440388839 */, + /* 3725 */ 0x070c7a82 | (17 << 27) /* 0.440546522 */, + /* 3726 */ 0x070d1fde | (17 << 27) /* 0.440704219 */, + /* 3727 */ 0x070dc53d | (17 << 27) /* 0.440861930 */, + + /* 3728 */ 0x070e6aa0 | (17 << 27) /* 0.441019655 */, + /* 3729 */ 0x070f1007 | (17 << 27) /* 0.441177395 */, + /* 3730 */ 0x070fb571 | (17 << 27) /* 0.441335148 */, + /* 3731 */ 0x07105ae0 | (17 << 27) /* 0.441492916 */, + /* 3732 */ 0x07110052 | (17 << 27) /* 0.441650697 */, + /* 3733 */ 0x0711a5c8 | (17 << 27) /* 0.441808493 */, + /* 3734 */ 0x07124b42 | (17 << 27) /* 0.441966303 */, + /* 3735 */ 0x0712f0bf | (17 << 27) /* 0.442124127 */, + /* 3736 */ 0x07139641 | (17 << 27) /* 0.442281965 */, + /* 3737 */ 0x07143bc6 | (17 << 27) /* 0.442439817 */, + /* 3738 */ 0x0714e14f | (17 << 27) /* 0.442597683 */, + /* 3739 */ 0x071586db | (17 << 27) /* 0.442755564 */, + /* 3740 */ 0x07162c6c | (17 << 27) /* 0.442913458 */, + /* 3741 */ 0x0716d200 | (17 << 27) /* 0.443071366 */, + /* 3742 */ 0x07177798 | (17 << 27) /* 0.443229289 */, + /* 3743 */ 0x07181d34 | (17 << 27) /* 0.443387226 */, + + /* 3744 */ 0x0718c2d3 | (17 << 27) /* 0.443545176 */, + /* 3745 */ 0x07196877 | (17 << 27) /* 0.443703141 */, + /* 3746 */ 0x071a0e1e | (17 << 27) /* 0.443861120 */, + /* 3747 */ 0x071ab3c9 | (17 << 27) /* 0.444019113 */, + /* 3748 */ 0x071b5977 | (17 << 27) /* 0.444177119 */, + /* 3749 */ 0x071bff2a | (17 << 27) /* 0.444335140 */, + /* 3750 */ 0x071ca4e0 | (17 << 27) /* 0.444493175 */, + /* 3751 */ 0x071d4a9a | (17 << 27) /* 0.444651224 */, + /* 3752 */ 0x071df058 | (17 << 27) /* 0.444809288 */, + /* 3753 */ 0x071e9619 | (17 << 27) /* 0.444967365 */, + /* 3754 */ 0x071f3bde | (17 << 27) /* 0.445125456 */, + /* 3755 */ 0x071fe1a8 | (17 << 27) /* 0.445283561 */, + /* 3756 */ 0x07208774 | (17 << 27) /* 0.445441680 */, + /* 3757 */ 0x07212d45 | (17 << 27) /* 0.445599814 */, + /* 3758 */ 0x0721d319 | (17 << 27) /* 0.445757961 */, + /* 3759 */ 0x072278f1 | (17 << 27) /* 0.445916122 */, + + /* 3760 */ 0x07231ecd | (17 << 27) /* 0.446074298 */, + /* 3761 */ 0x0723c4ad | (17 << 27) /* 0.446232487 */, + /* 3762 */ 0x07246a90 | (17 << 27) /* 0.446390690 */, + /* 3763 */ 0x07251077 | (17 << 27) /* 0.446548908 */, + /* 3764 */ 0x0725b662 | (17 << 27) /* 0.446707139 */, + /* 3765 */ 0x07265c51 | (17 << 27) /* 0.446865385 */, + /* 3766 */ 0x07270244 | (17 << 27) /* 0.447023644 */, + /* 3767 */ 0x0727a83a | (17 << 27) /* 0.447181918 */, + /* 3768 */ 0x07284e34 | (17 << 27) /* 0.447340205 */, + /* 3769 */ 0x0728f431 | (17 << 27) /* 0.447498507 */, + /* 3770 */ 0x07299a33 | (17 << 27) /* 0.447656822 */, + /* 3771 */ 0x072a4038 | (17 << 27) /* 0.447815152 */, + /* 3772 */ 0x072ae641 | (17 << 27) /* 0.447973495 */, + /* 3773 */ 0x072b8c4e | (17 << 27) /* 0.448131853 */, + /* 3774 */ 0x072c325e | (17 << 27) /* 0.448290224 */, + /* 3775 */ 0x072cd873 | (17 << 27) /* 0.448448609 */, + + /* 3776 */ 0x072d7e8b | (17 << 27) /* 0.448607009 */, + /* 3777 */ 0x072e24a7 | (17 << 27) /* 0.448765422 */, + /* 3778 */ 0x072ecac6 | (17 << 27) /* 0.448923850 */, + /* 3779 */ 0x072f70e9 | (17 << 27) /* 0.449082291 */, + /* 3780 */ 0x07301710 | (17 << 27) /* 0.449240746 */, + /* 3781 */ 0x0730bd3b | (17 << 27) /* 0.449399216 */, + /* 3782 */ 0x0731636a | (17 << 27) /* 0.449557699 */, + /* 3783 */ 0x0732099c | (17 << 27) /* 0.449716196 */, + /* 3784 */ 0x0732afd2 | (17 << 27) /* 0.449874708 */, + /* 3785 */ 0x0733560c | (17 << 27) /* 0.450033233 */, + /* 3786 */ 0x0733fc49 | (17 << 27) /* 0.450191772 */, + /* 3787 */ 0x0734a28b | (17 << 27) /* 0.450350325 */, + /* 3788 */ 0x073548d0 | (17 << 27) /* 0.450508892 */, + /* 3789 */ 0x0735ef18 | (17 << 27) /* 0.450667473 */, + /* 3790 */ 0x07369565 | (17 << 27) /* 0.450826068 */, + /* 3791 */ 0x07373bb5 | (17 << 27) /* 0.450984677 */, + + /* 3792 */ 0x0737e209 | (17 << 27) /* 0.451143300 */, + /* 3793 */ 0x07388861 | (17 << 27) /* 0.451301937 */, + /* 3794 */ 0x07392ebc | (17 << 27) /* 0.451460588 */, + /* 3795 */ 0x0739d51c | (17 << 27) /* 0.451619252 */, + /* 3796 */ 0x073a7b7f | (17 << 27) /* 0.451777931 */, + /* 3797 */ 0x073b21e5 | (17 << 27) /* 0.451936623 */, + /* 3798 */ 0x073bc850 | (17 << 27) /* 0.452095330 */, + /* 3799 */ 0x073c6ebe | (17 << 27) /* 0.452254050 */, + /* 3800 */ 0x073d1530 | (17 << 27) /* 0.452412785 */, + /* 3801 */ 0x073dbba6 | (17 << 27) /* 0.452571533 */, + /* 3802 */ 0x073e621f | (17 << 27) /* 0.452730295 */, + /* 3803 */ 0x073f089c | (17 << 27) /* 0.452889071 */, + /* 3804 */ 0x073faf1d | (17 << 27) /* 0.453047861 */, + /* 3805 */ 0x074055a2 | (17 << 27) /* 0.453206665 */, + /* 3806 */ 0x0740fc2a | (17 << 27) /* 0.453365483 */, + /* 3807 */ 0x0741a2b6 | (17 << 27) /* 0.453524315 */, + + /* 3808 */ 0x07424946 | (17 << 27) /* 0.453683161 */, + /* 3809 */ 0x0742efd9 | (17 << 27) /* 0.453842020 */, + /* 3810 */ 0x07439671 | (17 << 27) /* 0.454000894 */, + /* 3811 */ 0x07443d0c | (17 << 27) /* 0.454159781 */, + /* 3812 */ 0x0744e3aa | (17 << 27) /* 0.454318683 */, + /* 3813 */ 0x07458a4d | (17 << 27) /* 0.454477598 */, + /* 3814 */ 0x074630f3 | (17 << 27) /* 0.454636527 */, + /* 3815 */ 0x0746d79d | (17 << 27) /* 0.454795470 */, + /* 3816 */ 0x07477e4b | (17 << 27) /* 0.454954427 */, + /* 3817 */ 0x074824fc | (17 << 27) /* 0.455113397 */, + /* 3818 */ 0x0748cbb1 | (17 << 27) /* 0.455272382 */, + /* 3819 */ 0x0749726a | (17 << 27) /* 0.455431381 */, + /* 3820 */ 0x074a1927 | (17 << 27) /* 0.455590393 */, + /* 3821 */ 0x074abfe7 | (17 << 27) /* 0.455749419 */, + /* 3822 */ 0x074b66ab | (17 << 27) /* 0.455908459 */, + /* 3823 */ 0x074c0d73 | (17 << 27) /* 0.456067513 */, + + /* 3824 */ 0x074cb43e | (17 << 27) /* 0.456226581 */, + /* 3825 */ 0x074d5b0d | (17 << 27) /* 0.456385663 */, + /* 3826 */ 0x074e01e0 | (17 << 27) /* 0.456544759 */, + /* 3827 */ 0x074ea8b7 | (17 << 27) /* 0.456703868 */, + /* 3828 */ 0x074f4f91 | (17 << 27) /* 0.456862992 */, + /* 3829 */ 0x074ff66f | (17 << 27) /* 0.457022129 */, + /* 3830 */ 0x07509d51 | (17 << 27) /* 0.457181280 */, + /* 3831 */ 0x07514437 | (17 << 27) /* 0.457340445 */, + /* 3832 */ 0x0751eb20 | (17 << 27) /* 0.457499623 */, + /* 3833 */ 0x0752920d | (17 << 27) /* 0.457658816 */, + /* 3834 */ 0x075338fd | (17 << 27) /* 0.457818022 */, + /* 3835 */ 0x0753dff2 | (17 << 27) /* 0.457977243 */, + /* 3836 */ 0x075486ea | (17 << 27) /* 0.458136477 */, + /* 3837 */ 0x07552de6 | (17 << 27) /* 0.458295725 */, + /* 3838 */ 0x0755d4e5 | (17 << 27) /* 0.458454987 */, + /* 3839 */ 0x07567be8 | (17 << 27) /* 0.458614262 */, + + /* 3840 */ 0x075722ef | (17 << 27) /* 0.458773552 */, + /* 3841 */ 0x0757c9fa | (17 << 27) /* 0.458932855 */, + /* 3842 */ 0x07587108 | (17 << 27) /* 0.459092172 */, + /* 3843 */ 0x0759181a | (17 << 27) /* 0.459251503 */, + /* 3844 */ 0x0759bf30 | (17 << 27) /* 0.459410848 */, + /* 3845 */ 0x075a664a | (17 << 27) /* 0.459570206 */, + /* 3846 */ 0x075b0d67 | (17 << 27) /* 0.459729579 */, + /* 3847 */ 0x075bb488 | (17 << 27) /* 0.459888965 */, + /* 3848 */ 0x075c5bac | (17 << 27) /* 0.460048365 */, + /* 3849 */ 0x075d02d5 | (17 << 27) /* 0.460207779 */, + /* 3850 */ 0x075daa01 | (17 << 27) /* 0.460367206 */, + /* 3851 */ 0x075e5130 | (17 << 27) /* 0.460526648 */, + /* 3852 */ 0x075ef864 | (17 << 27) /* 0.460686103 */, + /* 3853 */ 0x075f9f9b | (17 << 27) /* 0.460845572 */, + /* 3854 */ 0x076046d6 | (17 << 27) /* 0.461005055 */, + /* 3855 */ 0x0760ee14 | (17 << 27) /* 0.461164552 */, + + /* 3856 */ 0x07619557 | (17 << 27) /* 0.461324062 */, + /* 3857 */ 0x07623c9d | (17 << 27) /* 0.461483586 */, + /* 3858 */ 0x0762e3e6 | (17 << 27) /* 0.461643124 */, + /* 3859 */ 0x07638b34 | (17 << 27) /* 0.461802676 */, + /* 3860 */ 0x07643285 | (17 << 27) /* 0.461962242 */, + /* 3861 */ 0x0764d9d9 | (17 << 27) /* 0.462121821 */, + /* 3862 */ 0x07658132 | (17 << 27) /* 0.462281414 */, + /* 3863 */ 0x0766288e | (17 << 27) /* 0.462441021 */, + /* 3864 */ 0x0766cfee | (17 << 27) /* 0.462600642 */, + /* 3865 */ 0x07677751 | (17 << 27) /* 0.462760276 */, + /* 3866 */ 0x07681eb9 | (17 << 27) /* 0.462919924 */, + /* 3867 */ 0x0768c624 | (17 << 27) /* 0.463079586 */, + /* 3868 */ 0x07696d92 | (17 << 27) /* 0.463239262 */, + /* 3869 */ 0x076a1505 | (17 << 27) /* 0.463398951 */, + /* 3870 */ 0x076abc7b | (17 << 27) /* 0.463558655 */, + /* 3871 */ 0x076b63f4 | (17 << 27) /* 0.463718372 */, + + /* 3872 */ 0x076c0b72 | (17 << 27) /* 0.463878102 */, + /* 3873 */ 0x076cb2f3 | (17 << 27) /* 0.464037847 */, + /* 3874 */ 0x076d5a78 | (17 << 27) /* 0.464197605 */, + /* 3875 */ 0x076e0200 | (17 << 27) /* 0.464357377 */, + /* 3876 */ 0x076ea98c | (17 << 27) /* 0.464517163 */, + /* 3877 */ 0x076f511c | (17 << 27) /* 0.464676962 */, + /* 3878 */ 0x076ff8b0 | (17 << 27) /* 0.464836776 */, + /* 3879 */ 0x0770a047 | (17 << 27) /* 0.464996603 */, + /* 3880 */ 0x077147e2 | (17 << 27) /* 0.465156443 */, + /* 3881 */ 0x0771ef80 | (17 << 27) /* 0.465316298 */, + /* 3882 */ 0x07729723 | (17 << 27) /* 0.465476166 */, + /* 3883 */ 0x07733ec9 | (17 << 27) /* 0.465636048 */, + /* 3884 */ 0x0773e672 | (17 << 27) /* 0.465795943 */, + /* 3885 */ 0x07748e20 | (17 << 27) /* 0.465955853 */, + /* 3886 */ 0x077535d1 | (17 << 27) /* 0.466115776 */, + /* 3887 */ 0x0775dd85 | (17 << 27) /* 0.466275713 */, + + /* 3888 */ 0x0776853e | (17 << 27) /* 0.466435663 */, + /* 3889 */ 0x07772cfa | (17 << 27) /* 0.466595627 */, + /* 3890 */ 0x0777d4ba | (17 << 27) /* 0.466755605 */, + /* 3891 */ 0x07787c7d | (17 << 27) /* 0.466915597 */, + /* 3892 */ 0x07792444 | (17 << 27) /* 0.467075602 */, + /* 3893 */ 0x0779cc0f | (17 << 27) /* 0.467235621 */, + /* 3894 */ 0x077a73dd | (17 << 27) /* 0.467395654 */, + /* 3895 */ 0x077b1baf | (17 << 27) /* 0.467555701 */, + /* 3896 */ 0x077bc385 | (17 << 27) /* 0.467715761 */, + /* 3897 */ 0x077c6b5f | (17 << 27) /* 0.467875835 */, + /* 3898 */ 0x077d133c | (17 << 27) /* 0.468035922 */, + /* 3899 */ 0x077dbb1d | (17 << 27) /* 0.468196023 */, + /* 3900 */ 0x077e6301 | (17 << 27) /* 0.468356138 */, + /* 3901 */ 0x077f0ae9 | (17 << 27) /* 0.468516267 */, + /* 3902 */ 0x077fb2d5 | (17 << 27) /* 0.468676409 */, + /* 3903 */ 0x07805ac5 | (17 << 27) /* 0.468836565 */, + + /* 3904 */ 0x078102b8 | (17 << 27) /* 0.468996735 */, + /* 3905 */ 0x0781aaaf | (17 << 27) /* 0.469156918 */, + /* 3906 */ 0x078252aa | (17 << 27) /* 0.469317115 */, + /* 3907 */ 0x0782faa8 | (17 << 27) /* 0.469477326 */, + /* 3908 */ 0x0783a2aa | (17 << 27) /* 0.469637550 */, + /* 3909 */ 0x07844aaf | (17 << 27) /* 0.469797788 */, + /* 3910 */ 0x0784f2b8 | (17 << 27) /* 0.469958040 */, + /* 3911 */ 0x07859ac5 | (17 << 27) /* 0.470118305 */, + /* 3912 */ 0x078642d6 | (17 << 27) /* 0.470278584 */, + /* 3913 */ 0x0786eaea | (17 << 27) /* 0.470438877 */, + /* 3914 */ 0x07879302 | (17 << 27) /* 0.470599183 */, + /* 3915 */ 0x07883b1e | (17 << 27) /* 0.470759503 */, + /* 3916 */ 0x0788e33d | (17 << 27) /* 0.470919836 */, + /* 3917 */ 0x07898b60 | (17 << 27) /* 0.471080184 */, + /* 3918 */ 0x078a3386 | (17 << 27) /* 0.471240545 */, + /* 3919 */ 0x078adbb0 | (17 << 27) /* 0.471400919 */, + + /* 3920 */ 0x078b83de | (17 << 27) /* 0.471561307 */, + /* 3921 */ 0x078c2c10 | (17 << 27) /* 0.471721709 */, + /* 3922 */ 0x078cd445 | (17 << 27) /* 0.471882125 */, + /* 3923 */ 0x078d7c7e | (17 << 27) /* 0.472042554 */, + /* 3924 */ 0x078e24ba | (17 << 27) /* 0.472202996 */, + /* 3925 */ 0x078eccfb | (17 << 27) /* 0.472363453 */, + /* 3926 */ 0x078f753e | (17 << 27) /* 0.472523923 */, + /* 3927 */ 0x07901d86 | (17 << 27) /* 0.472684406 */, + /* 3928 */ 0x0790c5d1 | (17 << 27) /* 0.472844904 */, + /* 3929 */ 0x07916e20 | (17 << 27) /* 0.473005414 */, + /* 3930 */ 0x07921672 | (17 << 27) /* 0.473165939 */, + /* 3931 */ 0x0792bec8 | (17 << 27) /* 0.473326477 */, + /* 3932 */ 0x07936722 | (17 << 27) /* 0.473487029 */, + /* 3933 */ 0x07940f80 | (17 << 27) /* 0.473647594 */, + /* 3934 */ 0x0794b7e1 | (17 << 27) /* 0.473808173 */, + /* 3935 */ 0x07956045 | (17 << 27) /* 0.473968765 */, + + /* 3936 */ 0x079608ae | (17 << 27) /* 0.474129372 */, + /* 3937 */ 0x0796b11a | (17 << 27) /* 0.474289991 */, + /* 3938 */ 0x0797598a | (17 << 27) /* 0.474450625 */, + /* 3939 */ 0x079801fd | (17 << 27) /* 0.474611272 */, + /* 3940 */ 0x0798aa74 | (17 << 27) /* 0.474771932 */, + /* 3941 */ 0x079952ee | (17 << 27) /* 0.474932606 */, + /* 3942 */ 0x0799fb6d | (17 << 27) /* 0.475093294 */, + /* 3943 */ 0x079aa3ef | (17 << 27) /* 0.475253995 */, + /* 3944 */ 0x079b4c74 | (17 << 27) /* 0.475414710 */, + /* 3945 */ 0x079bf4fd | (17 << 27) /* 0.475575439 */, + /* 3946 */ 0x079c9d8a | (17 << 27) /* 0.475736181 */, + /* 3947 */ 0x079d461b | (17 << 27) /* 0.475896936 */, + /* 3948 */ 0x079deeaf | (17 << 27) /* 0.476057705 */, + /* 3949 */ 0x079e9747 | (17 << 27) /* 0.476218488 */, + /* 3950 */ 0x079f3fe2 | (17 << 27) /* 0.476379285 */, + /* 3951 */ 0x079fe881 | (17 << 27) /* 0.476540095 */, + + /* 3952 */ 0x07a09124 | (17 << 27) /* 0.476700918 */, + /* 3953 */ 0x07a139ca | (17 << 27) /* 0.476861755 */, + /* 3954 */ 0x07a1e274 | (17 << 27) /* 0.477022606 */, + /* 3955 */ 0x07a28b22 | (17 << 27) /* 0.477183470 */, + /* 3956 */ 0x07a333d3 | (17 << 27) /* 0.477344348 */, + /* 3957 */ 0x07a3dc88 | (17 << 27) /* 0.477505239 */, + /* 3958 */ 0x07a48541 | (17 << 27) /* 0.477666144 */, + /* 3959 */ 0x07a52dfd | (17 << 27) /* 0.477827062 */, + /* 3960 */ 0x07a5d6bd | (17 << 27) /* 0.477987994 */, + /* 3961 */ 0x07a67f80 | (17 << 27) /* 0.478148940 */, + /* 3962 */ 0x07a72847 | (17 << 27) /* 0.478309899 */, + /* 3963 */ 0x07a7d112 | (17 << 27) /* 0.478470871 */, + /* 3964 */ 0x07a879e1 | (17 << 27) /* 0.478631857 */, + /* 3965 */ 0x07a922b3 | (17 << 27) /* 0.478792857 */, + /* 3966 */ 0x07a9cb88 | (17 << 27) /* 0.478953870 */, + /* 3967 */ 0x07aa7462 | (17 << 27) /* 0.479114897 */, + + /* 3968 */ 0x07ab1d3e | (17 << 27) /* 0.479275937 */, + /* 3969 */ 0x07abc61f | (17 << 27) /* 0.479436991 */, + /* 3970 */ 0x07ac6f03 | (17 << 27) /* 0.479598058 */, + /* 3971 */ 0x07ad17eb | (17 << 27) /* 0.479759139 */, + /* 3972 */ 0x07adc0d6 | (17 << 27) /* 0.479920233 */, + /* 3973 */ 0x07ae69c6 | (17 << 27) /* 0.480081341 */, + /* 3974 */ 0x07af12b8 | (17 << 27) /* 0.480242463 */, + /* 3975 */ 0x07afbbaf | (17 << 27) /* 0.480403598 */, + /* 3976 */ 0x07b064a8 | (17 << 27) /* 0.480564746 */, + /* 3977 */ 0x07b10da6 | (17 << 27) /* 0.480725908 */, + /* 3978 */ 0x07b1b6a7 | (17 << 27) /* 0.480887083 */, + /* 3979 */ 0x07b25fac | (17 << 27) /* 0.481048272 */, + /* 3980 */ 0x07b308b5 | (17 << 27) /* 0.481209475 */, + /* 3981 */ 0x07b3b1c1 | (17 << 27) /* 0.481370691 */, + /* 3982 */ 0x07b45ad0 | (17 << 27) /* 0.481531920 */, + /* 3983 */ 0x07b503e4 | (17 << 27) /* 0.481693163 */, + + /* 3984 */ 0x07b5acfb | (17 << 27) /* 0.481854420 */, + /* 3985 */ 0x07b65615 | (17 << 27) /* 0.482015690 */, + /* 3986 */ 0x07b6ff33 | (17 << 27) /* 0.482176973 */, + /* 3987 */ 0x07b7a855 | (17 << 27) /* 0.482338270 */, + /* 3988 */ 0x07b8517b | (17 << 27) /* 0.482499580 */, + /* 3989 */ 0x07b8faa4 | (17 << 27) /* 0.482660904 */, + /* 3990 */ 0x07b9a3d0 | (17 << 27) /* 0.482822242 */, + /* 3991 */ 0x07ba4d01 | (17 << 27) /* 0.482983592 */, + /* 3992 */ 0x07baf635 | (17 << 27) /* 0.483144957 */, + /* 3993 */ 0x07bb9f6c | (17 << 27) /* 0.483306335 */, + /* 3994 */ 0x07bc48a7 | (17 << 27) /* 0.483467726 */, + /* 3995 */ 0x07bcf1e6 | (17 << 27) /* 0.483629131 */, + /* 3996 */ 0x07bd9b28 | (17 << 27) /* 0.483790549 */, + /* 3997 */ 0x07be446e | (17 << 27) /* 0.483951980 */, + /* 3998 */ 0x07beedb8 | (17 << 27) /* 0.484113426 */, + /* 3999 */ 0x07bf9705 | (17 << 27) /* 0.484274884 */, + + /* 4000 */ 0x07c04056 | (17 << 27) /* 0.484436356 */, + /* 4001 */ 0x07c0e9aa | (17 << 27) /* 0.484597842 */, + /* 4002 */ 0x07c19302 | (17 << 27) /* 0.484759341 */, + /* 4003 */ 0x07c23c5e | (17 << 27) /* 0.484920853 */, + /* 4004 */ 0x07c2e5bd | (17 << 27) /* 0.485082379 */, + /* 4005 */ 0x07c38f20 | (17 << 27) /* 0.485243918 */, + /* 4006 */ 0x07c43887 | (17 << 27) /* 0.485405471 */, + /* 4007 */ 0x07c4e1f1 | (17 << 27) /* 0.485567037 */, + /* 4008 */ 0x07c58b5f | (17 << 27) /* 0.485728617 */, + /* 4009 */ 0x07c634d0 | (17 << 27) /* 0.485890210 */, + /* 4010 */ 0x07c6de45 | (17 << 27) /* 0.486051817 */, + /* 4011 */ 0x07c787bd | (17 << 27) /* 0.486213436 */, + /* 4012 */ 0x07c83139 | (17 << 27) /* 0.486375070 */, + /* 4013 */ 0x07c8dab9 | (17 << 27) /* 0.486536717 */, + /* 4014 */ 0x07c9843c | (17 << 27) /* 0.486698377 */, + /* 4015 */ 0x07ca2dc3 | (17 << 27) /* 0.486860051 */, + + /* 4016 */ 0x07cad74e | (17 << 27) /* 0.487021738 */, + /* 4017 */ 0x07cb80dc | (17 << 27) /* 0.487183438 */, + /* 4018 */ 0x07cc2a6e | (17 << 27) /* 0.487345152 */, + /* 4019 */ 0x07ccd403 | (17 << 27) /* 0.487506879 */, + /* 4020 */ 0x07cd7d9c | (17 << 27) /* 0.487668620 */, + /* 4021 */ 0x07ce2739 | (17 << 27) /* 0.487830374 */, + /* 4022 */ 0x07ced0d9 | (17 << 27) /* 0.487992142 */, + /* 4023 */ 0x07cf7a7d | (17 << 27) /* 0.488153923 */, + /* 4024 */ 0x07d02424 | (17 << 27) /* 0.488315717 */, + /* 4025 */ 0x07d0cdcf | (17 << 27) /* 0.488477525 */, + /* 4026 */ 0x07d1777e | (17 << 27) /* 0.488639346 */, + /* 4027 */ 0x07d22130 | (17 << 27) /* 0.488801181 */, + /* 4028 */ 0x07d2cae5 | (17 << 27) /* 0.488963029 */, + /* 4029 */ 0x07d3749f | (17 << 27) /* 0.489124890 */, + /* 4030 */ 0x07d41e5c | (17 << 27) /* 0.489286765 */, + /* 4031 */ 0x07d4c81c | (17 << 27) /* 0.489448653 */, + + /* 4032 */ 0x07d571e0 | (17 << 27) /* 0.489610555 */, + /* 4033 */ 0x07d61ba8 | (17 << 27) /* 0.489772470 */, + /* 4034 */ 0x07d6c573 | (17 << 27) /* 0.489934398 */, + /* 4035 */ 0x07d76f42 | (17 << 27) /* 0.490096340 */, + /* 4036 */ 0x07d81915 | (17 << 27) /* 0.490258295 */, + /* 4037 */ 0x07d8c2eb | (17 << 27) /* 0.490420263 */, + /* 4038 */ 0x07d96cc4 | (17 << 27) /* 0.490582245 */, + /* 4039 */ 0x07da16a2 | (17 << 27) /* 0.490744240 */, + /* 4040 */ 0x07dac083 | (17 << 27) /* 0.490906249 */, + /* 4041 */ 0x07db6a67 | (17 << 27) /* 0.491068271 */, + /* 4042 */ 0x07dc144f | (17 << 27) /* 0.491230306 */, + /* 4043 */ 0x07dcbe3b | (17 << 27) /* 0.491392355 */, + /* 4044 */ 0x07dd682a | (17 << 27) /* 0.491554417 */, + /* 4045 */ 0x07de121d | (17 << 27) /* 0.491716492 */, + /* 4046 */ 0x07debc13 | (17 << 27) /* 0.491878581 */, + /* 4047 */ 0x07df660d | (17 << 27) /* 0.492040683 */, + + /* 4048 */ 0x07e0100a | (17 << 27) /* 0.492202799 */, + /* 4049 */ 0x07e0ba0c | (17 << 27) /* 0.492364928 */, + /* 4050 */ 0x07e16410 | (17 << 27) /* 0.492527070 */, + /* 4051 */ 0x07e20e19 | (17 << 27) /* 0.492689225 */, + /* 4052 */ 0x07e2b824 | (17 << 27) /* 0.492851394 */, + /* 4053 */ 0x07e36234 | (17 << 27) /* 0.493013576 */, + /* 4054 */ 0x07e40c47 | (17 << 27) /* 0.493175772 */, + /* 4055 */ 0x07e4b65e | (17 << 27) /* 0.493337981 */, + /* 4056 */ 0x07e56078 | (17 << 27) /* 0.493500203 */, + /* 4057 */ 0x07e60a95 | (17 << 27) /* 0.493662438 */, + /* 4058 */ 0x07e6b4b7 | (17 << 27) /* 0.493824687 */, + /* 4059 */ 0x07e75edc | (17 << 27) /* 0.493986949 */, + /* 4060 */ 0x07e80904 | (17 << 27) /* 0.494149225 */, + /* 4061 */ 0x07e8b330 | (17 << 27) /* 0.494311514 */, + /* 4062 */ 0x07e95d60 | (17 << 27) /* 0.494473816 */, + /* 4063 */ 0x07ea0793 | (17 << 27) /* 0.494636131 */, + + /* 4064 */ 0x07eab1ca | (17 << 27) /* 0.494798460 */, + /* 4065 */ 0x07eb5c04 | (17 << 27) /* 0.494960802 */, + /* 4066 */ 0x07ec0642 | (17 << 27) /* 0.495123158 */, + /* 4067 */ 0x07ecb084 | (17 << 27) /* 0.495285526 */, + /* 4068 */ 0x07ed5ac9 | (17 << 27) /* 0.495447908 */, + /* 4069 */ 0x07ee0512 | (17 << 27) /* 0.495610304 */, + /* 4070 */ 0x07eeaf5e | (17 << 27) /* 0.495772712 */, + /* 4071 */ 0x07ef59ae | (17 << 27) /* 0.495935134 */, + /* 4072 */ 0x07f00401 | (17 << 27) /* 0.496097570 */, + /* 4073 */ 0x07f0ae58 | (17 << 27) /* 0.496260018 */, + /* 4074 */ 0x07f158b3 | (17 << 27) /* 0.496422480 */, + /* 4075 */ 0x07f20311 | (17 << 27) /* 0.496584955 */, + /* 4076 */ 0x07f2ad72 | (17 << 27) /* 0.496747444 */, + /* 4077 */ 0x07f357d8 | (17 << 27) /* 0.496909945 */, + /* 4078 */ 0x07f40240 | (17 << 27) /* 0.497072460 */, + /* 4079 */ 0x07f4acad | (17 << 27) /* 0.497234989 */, + + /* 4080 */ 0x07f5571d | (17 << 27) /* 0.497397530 */, + /* 4081 */ 0x07f60190 | (17 << 27) /* 0.497560085 */, + /* 4082 */ 0x07f6ac07 | (17 << 27) /* 0.497722653 */, + /* 4083 */ 0x07f75682 | (17 << 27) /* 0.497885235 */, + /* 4084 */ 0x07f80100 | (17 << 27) /* 0.498047829 */, + /* 4085 */ 0x07f8ab82 | (17 << 27) /* 0.498210437 */, + /* 4086 */ 0x07f95607 | (17 << 27) /* 0.498373058 */, + /* 4087 */ 0x07fa0090 | (17 << 27) /* 0.498535693 */, + /* 4088 */ 0x07faab1c | (17 << 27) /* 0.498698341 */, + /* 4089 */ 0x07fb55ac | (17 << 27) /* 0.498861002 */, + /* 4090 */ 0x07fc0040 | (17 << 27) /* 0.499023676 */, + /* 4091 */ 0x07fcaad7 | (17 << 27) /* 0.499186364 */, + /* 4092 */ 0x07fd5572 | (17 << 27) /* 0.499349064 */, + /* 4093 */ 0x07fe0010 | (17 << 27) /* 0.499511778 */, + /* 4094 */ 0x07feaab2 | (17 << 27) /* 0.499674506 */, + /* 4095 */ 0x07ff5557 | (17 << 27) /* 0.499837246 */, + + /* 4096 */ 0x04000000 | (18 << 27) /* 0.250000000 */, + /* 4097 */ 0x04005556 | (18 << 27) /* 0.250081384 */, + /* 4098 */ 0x0400aaae | (18 << 27) /* 0.250162774 */, + /* 4099 */ 0x04010008 | (18 << 27) /* 0.250244170 */, + /* 4100 */ 0x04015563 | (18 << 27) /* 0.250325574 */, + /* 4101 */ 0x0401aac1 | (18 << 27) /* 0.250406984 */, + /* 4102 */ 0x04020020 | (18 << 27) /* 0.250488400 */, + /* 4103 */ 0x04025581 | (18 << 27) /* 0.250569824 */, + /* 4104 */ 0x0402aae3 | (18 << 27) /* 0.250651254 */, + /* 4105 */ 0x04030048 | (18 << 27) /* 0.250732690 */, + /* 4106 */ 0x040355ae | (18 << 27) /* 0.250814133 */, + /* 4107 */ 0x0403ab16 | (18 << 27) /* 0.250895583 */, + /* 4108 */ 0x04040080 | (18 << 27) /* 0.250977039 */, + /* 4109 */ 0x040455eb | (18 << 27) /* 0.251058502 */, + /* 4110 */ 0x0404ab59 | (18 << 27) /* 0.251139971 */, + /* 4111 */ 0x040500c8 | (18 << 27) /* 0.251221448 */, + + /* 4112 */ 0x04055638 | (18 << 27) /* 0.251302930 */, + /* 4113 */ 0x0405abab | (18 << 27) /* 0.251384420 */, + /* 4114 */ 0x0406011f | (18 << 27) /* 0.251465916 */, + /* 4115 */ 0x04065696 | (18 << 27) /* 0.251547418 */, + /* 4116 */ 0x0406ac0e | (18 << 27) /* 0.251628927 */, + /* 4117 */ 0x04070187 | (18 << 27) /* 0.251710443 */, + /* 4118 */ 0x04075703 | (18 << 27) /* 0.251791965 */, + /* 4119 */ 0x0407ac80 | (18 << 27) /* 0.251873494 */, + /* 4120 */ 0x040801ff | (18 << 27) /* 0.251955030 */, + /* 4121 */ 0x04085780 | (18 << 27) /* 0.252036572 */, + /* 4122 */ 0x0408ad02 | (18 << 27) /* 0.252118121 */, + /* 4123 */ 0x04090287 | (18 << 27) /* 0.252199676 */, + /* 4124 */ 0x0409580d | (18 << 27) /* 0.252281238 */, + /* 4125 */ 0x0409ad95 | (18 << 27) /* 0.252362807 */, + /* 4126 */ 0x040a031e | (18 << 27) /* 0.252444382 */, + /* 4127 */ 0x040a58aa | (18 << 27) /* 0.252525963 */, + + /* 4128 */ 0x040aae37 | (18 << 27) /* 0.252607552 */, + /* 4129 */ 0x040b03c6 | (18 << 27) /* 0.252689147 */, + /* 4130 */ 0x040b5957 | (18 << 27) /* 0.252770748 */, + /* 4131 */ 0x040baee9 | (18 << 27) /* 0.252852356 */, + /* 4132 */ 0x040c047e | (18 << 27) /* 0.252933971 */, + /* 4133 */ 0x040c5a14 | (18 << 27) /* 0.253015592 */, + /* 4134 */ 0x040cafab | (18 << 27) /* 0.253097220 */, + /* 4135 */ 0x040d0545 | (18 << 27) /* 0.253178854 */, + /* 4136 */ 0x040d5ae0 | (18 << 27) /* 0.253260495 */, + /* 4137 */ 0x040db07d | (18 << 27) /* 0.253342143 */, + /* 4138 */ 0x040e061c | (18 << 27) /* 0.253423797 */, + /* 4139 */ 0x040e5bbd | (18 << 27) /* 0.253505457 */, + /* 4140 */ 0x040eb15f | (18 << 27) /* 0.253587125 */, + /* 4141 */ 0x040f0703 | (18 << 27) /* 0.253668799 */, + /* 4142 */ 0x040f5ca9 | (18 << 27) /* 0.253750479 */, + /* 4143 */ 0x040fb251 | (18 << 27) /* 0.253832166 */, + + /* 4144 */ 0x041007fa | (18 << 27) /* 0.253913860 */, + /* 4145 */ 0x04105da6 | (18 << 27) /* 0.253995560 */, + /* 4146 */ 0x0410b353 | (18 << 27) /* 0.254077266 */, + /* 4147 */ 0x04110901 | (18 << 27) /* 0.254158980 */, + /* 4148 */ 0x04115eb2 | (18 << 27) /* 0.254240700 */, + /* 4149 */ 0x0411b464 | (18 << 27) /* 0.254322426 */, + /* 4150 */ 0x04120a18 | (18 << 27) /* 0.254404159 */, + /* 4151 */ 0x04125fce | (18 << 27) /* 0.254485899 */, + /* 4152 */ 0x0412b586 | (18 << 27) /* 0.254567645 */, + /* 4153 */ 0x04130b3f | (18 << 27) /* 0.254649397 */, + /* 4154 */ 0x041360fa | (18 << 27) /* 0.254731157 */, + /* 4155 */ 0x0413b6b7 | (18 << 27) /* 0.254812922 */, + /* 4156 */ 0x04140c75 | (18 << 27) /* 0.254894695 */, + /* 4157 */ 0x04146236 | (18 << 27) /* 0.254976474 */, + /* 4158 */ 0x0414b7f8 | (18 << 27) /* 0.255058259 */, + /* 4159 */ 0x04150dbc | (18 << 27) /* 0.255140051 */, + + /* 4160 */ 0x04156381 | (18 << 27) /* 0.255221850 */, + /* 4161 */ 0x0415b949 | (18 << 27) /* 0.255303655 */, + /* 4162 */ 0x04160f12 | (18 << 27) /* 0.255385467 */, + /* 4163 */ 0x041664dd | (18 << 27) /* 0.255467285 */, + /* 4164 */ 0x0416baaa | (18 << 27) /* 0.255549110 */, + /* 4165 */ 0x04171078 | (18 << 27) /* 0.255630941 */, + /* 4166 */ 0x04176648 | (18 << 27) /* 0.255712779 */, + /* 4167 */ 0x0417bc1a | (18 << 27) /* 0.255794624 */, + /* 4168 */ 0x041811ee | (18 << 27) /* 0.255876475 */, + /* 4169 */ 0x041867c3 | (18 << 27) /* 0.255958332 */, + /* 4170 */ 0x0418bd9b | (18 << 27) /* 0.256040196 */, + /* 4171 */ 0x04191374 | (18 << 27) /* 0.256122067 */, + /* 4172 */ 0x0419694e | (18 << 27) /* 0.256203944 */, + /* 4173 */ 0x0419bf2b | (18 << 27) /* 0.256285828 */, + /* 4174 */ 0x041a1509 | (18 << 27) /* 0.256367718 */, + /* 4175 */ 0x041a6ae9 | (18 << 27) /* 0.256449615 */, + + /* 4176 */ 0x041ac0cb | (18 << 27) /* 0.256531518 */, + /* 4177 */ 0x041b16ae | (18 << 27) /* 0.256613428 */, + /* 4178 */ 0x041b6c94 | (18 << 27) /* 0.256695344 */, + /* 4179 */ 0x041bc27b | (18 << 27) /* 0.256777267 */, + /* 4180 */ 0x041c1863 | (18 << 27) /* 0.256859197 */, + /* 4181 */ 0x041c6e4e | (18 << 27) /* 0.256941133 */, + /* 4182 */ 0x041cc43a | (18 << 27) /* 0.257023076 */, + /* 4183 */ 0x041d1a28 | (18 << 27) /* 0.257105025 */, + /* 4184 */ 0x041d7018 | (18 << 27) /* 0.257186980 */, + /* 4185 */ 0x041dc60a | (18 << 27) /* 0.257268942 */, + /* 4186 */ 0x041e1bfd | (18 << 27) /* 0.257350911 */, + /* 4187 */ 0x041e71f2 | (18 << 27) /* 0.257432886 */, + /* 4188 */ 0x041ec7e9 | (18 << 27) /* 0.257514868 */, + /* 4189 */ 0x041f1de1 | (18 << 27) /* 0.257596856 */, + /* 4190 */ 0x041f73dc | (18 << 27) /* 0.257678851 */, + /* 4191 */ 0x041fc9d8 | (18 << 27) /* 0.257760852 */, + + /* 4192 */ 0x04201fd5 | (18 << 27) /* 0.257842860 */, + /* 4193 */ 0x042075d5 | (18 << 27) /* 0.257924875 */, + /* 4194 */ 0x0420cbd6 | (18 << 27) /* 0.258006895 */, + /* 4195 */ 0x042121d9 | (18 << 27) /* 0.258088923 */, + /* 4196 */ 0x042177de | (18 << 27) /* 0.258170957 */, + /* 4197 */ 0x0421cde5 | (18 << 27) /* 0.258252997 */, + /* 4198 */ 0x042223ed | (18 << 27) /* 0.258335044 */, + /* 4199 */ 0x042279f7 | (18 << 27) /* 0.258417097 */, + /* 4200 */ 0x0422d003 | (18 << 27) /* 0.258499157 */, + /* 4201 */ 0x04232611 | (18 << 27) /* 0.258581224 */, + /* 4202 */ 0x04237c20 | (18 << 27) /* 0.258663297 */, + /* 4203 */ 0x0423d231 | (18 << 27) /* 0.258745376 */, + /* 4204 */ 0x04242844 | (18 << 27) /* 0.258827462 */, + /* 4205 */ 0x04247e58 | (18 << 27) /* 0.258909555 */, + /* 4206 */ 0x0424d46e | (18 << 27) /* 0.258991654 */, + /* 4207 */ 0x04252a87 | (18 << 27) /* 0.259073760 */, + + /* 4208 */ 0x042580a0 | (18 << 27) /* 0.259155872 */, + /* 4209 */ 0x0425d6bc | (18 << 27) /* 0.259237990 */, + /* 4210 */ 0x04262cd9 | (18 << 27) /* 0.259320115 */, + /* 4211 */ 0x042682f8 | (18 << 27) /* 0.259402247 */, + /* 4212 */ 0x0426d919 | (18 << 27) /* 0.259484385 */, + /* 4213 */ 0x04272f3b | (18 << 27) /* 0.259566529 */, + /* 4214 */ 0x04278560 | (18 << 27) /* 0.259648680 */, + /* 4215 */ 0x0427db86 | (18 << 27) /* 0.259730838 */, + /* 4216 */ 0x042831ad | (18 << 27) /* 0.259813002 */, + /* 4217 */ 0x042887d7 | (18 << 27) /* 0.259895173 */, + /* 4218 */ 0x0428de02 | (18 << 27) /* 0.259977350 */, + /* 4219 */ 0x0429342f | (18 << 27) /* 0.260059533 */, + /* 4220 */ 0x04298a5e | (18 << 27) /* 0.260141723 */, + /* 4221 */ 0x0429e08e | (18 << 27) /* 0.260223920 */, + /* 4222 */ 0x042a36c0 | (18 << 27) /* 0.260306123 */, + /* 4223 */ 0x042a8cf4 | (18 << 27) /* 0.260388332 */, + + /* 4224 */ 0x042ae32a | (18 << 27) /* 0.260470548 */, + /* 4225 */ 0x042b3962 | (18 << 27) /* 0.260552771 */, + /* 4226 */ 0x042b8f9b | (18 << 27) /* 0.260635000 */, + /* 4227 */ 0x042be5d6 | (18 << 27) /* 0.260717235 */, + /* 4228 */ 0x042c3c12 | (18 << 27) /* 0.260799477 */, + /* 4229 */ 0x042c9251 | (18 << 27) /* 0.260881725 */, + /* 4230 */ 0x042ce891 | (18 << 27) /* 0.260963980 */, + /* 4231 */ 0x042d3ed3 | (18 << 27) /* 0.261046242 */, + /* 4232 */ 0x042d9516 | (18 << 27) /* 0.261128510 */, + /* 4233 */ 0x042deb5c | (18 << 27) /* 0.261210784 */, + /* 4234 */ 0x042e41a3 | (18 << 27) /* 0.261293065 */, + /* 4235 */ 0x042e97ec | (18 << 27) /* 0.261375352 */, + /* 4236 */ 0x042eee36 | (18 << 27) /* 0.261457646 */, + /* 4237 */ 0x042f4482 | (18 << 27) /* 0.261539946 */, + /* 4238 */ 0x042f9ad1 | (18 << 27) /* 0.261622253 */, + /* 4239 */ 0x042ff120 | (18 << 27) /* 0.261704566 */, + + /* 4240 */ 0x04304772 | (18 << 27) /* 0.261786886 */, + /* 4241 */ 0x04309dc5 | (18 << 27) /* 0.261869212 */, + /* 4242 */ 0x0430f41a | (18 << 27) /* 0.261951545 */, + /* 4243 */ 0x04314a71 | (18 << 27) /* 0.262033884 */, + /* 4244 */ 0x0431a0c9 | (18 << 27) /* 0.262116229 */, + /* 4245 */ 0x0431f723 | (18 << 27) /* 0.262198581 */, + /* 4246 */ 0x04324d7f | (18 << 27) /* 0.262280940 */, + /* 4247 */ 0x0432a3dd | (18 << 27) /* 0.262363305 */, + /* 4248 */ 0x0432fa3d | (18 << 27) /* 0.262445676 */, + /* 4249 */ 0x0433509e | (18 << 27) /* 0.262528054 */, + /* 4250 */ 0x0433a701 | (18 << 27) /* 0.262610438 */, + /* 4251 */ 0x0433fd65 | (18 << 27) /* 0.262692829 */, + /* 4252 */ 0x043453cc | (18 << 27) /* 0.262775227 */, + /* 4253 */ 0x0434aa34 | (18 << 27) /* 0.262857630 */, + /* 4254 */ 0x0435009d | (18 << 27) /* 0.262940040 */, + /* 4255 */ 0x04355709 | (18 << 27) /* 0.263022457 */, + + /* 4256 */ 0x0435ad76 | (18 << 27) /* 0.263104880 */, + /* 4257 */ 0x043603e5 | (18 << 27) /* 0.263187310 */, + /* 4258 */ 0x04365a56 | (18 << 27) /* 0.263269746 */, + /* 4259 */ 0x0436b0c9 | (18 << 27) /* 0.263352188 */, + /* 4260 */ 0x0437073d | (18 << 27) /* 0.263434637 */, + /* 4261 */ 0x04375db3 | (18 << 27) /* 0.263517093 */, + /* 4262 */ 0x0437b42a | (18 << 27) /* 0.263599554 */, + /* 4263 */ 0x04380aa4 | (18 << 27) /* 0.263682023 */, + /* 4264 */ 0x0438611f | (18 << 27) /* 0.263764497 */, + /* 4265 */ 0x0438b79c | (18 << 27) /* 0.263846979 */, + /* 4266 */ 0x04390e1a | (18 << 27) /* 0.263929466 */, + /* 4267 */ 0x0439649b | (18 << 27) /* 0.264011960 */, + /* 4268 */ 0x0439bb1d | (18 << 27) /* 0.264094461 */, + /* 4269 */ 0x043a11a1 | (18 << 27) /* 0.264176968 */, + /* 4270 */ 0x043a6826 | (18 << 27) /* 0.264259481 */, + /* 4271 */ 0x043abead | (18 << 27) /* 0.264342001 */, + + /* 4272 */ 0x043b1536 | (18 << 27) /* 0.264424527 */, + /* 4273 */ 0x043b6bc1 | (18 << 27) /* 0.264507060 */, + /* 4274 */ 0x043bc24d | (18 << 27) /* 0.264589599 */, + /* 4275 */ 0x043c18dc | (18 << 27) /* 0.264672145 */, + /* 4276 */ 0x043c6f6c | (18 << 27) /* 0.264754697 */, + /* 4277 */ 0x043cc5fd | (18 << 27) /* 0.264837255 */, + /* 4278 */ 0x043d1c91 | (18 << 27) /* 0.264919820 */, + /* 4279 */ 0x043d7326 | (18 << 27) /* 0.265002392 */, + /* 4280 */ 0x043dc9bc | (18 << 27) /* 0.265084969 */, + /* 4281 */ 0x043e2055 | (18 << 27) /* 0.265167554 */, + /* 4282 */ 0x043e76ef | (18 << 27) /* 0.265250144 */, + /* 4283 */ 0x043ecd8b | (18 << 27) /* 0.265332741 */, + /* 4284 */ 0x043f2429 | (18 << 27) /* 0.265415345 */, + /* 4285 */ 0x043f7ac8 | (18 << 27) /* 0.265497955 */, + /* 4286 */ 0x043fd169 | (18 << 27) /* 0.265580571 */, + /* 4287 */ 0x0440280c | (18 << 27) /* 0.265663194 */, + + /* 4288 */ 0x04407eb1 | (18 << 27) /* 0.265745823 */, + /* 4289 */ 0x0440d557 | (18 << 27) /* 0.265828459 */, + /* 4290 */ 0x04412bff | (18 << 27) /* 0.265911101 */, + /* 4291 */ 0x044182a9 | (18 << 27) /* 0.265993749 */, + /* 4292 */ 0x0441d955 | (18 << 27) /* 0.266076404 */, + /* 4293 */ 0x04423002 | (18 << 27) /* 0.266159065 */, + /* 4294 */ 0x044286b1 | (18 << 27) /* 0.266241733 */, + /* 4295 */ 0x0442dd61 | (18 << 27) /* 0.266324407 */, + /* 4296 */ 0x04433414 | (18 << 27) /* 0.266407088 */, + /* 4297 */ 0x04438ac8 | (18 << 27) /* 0.266489775 */, + /* 4298 */ 0x0443e17e | (18 << 27) /* 0.266572468 */, + /* 4299 */ 0x04443835 | (18 << 27) /* 0.266655168 */, + /* 4300 */ 0x04448eef | (18 << 27) /* 0.266737874 */, + /* 4301 */ 0x0444e5aa | (18 << 27) /* 0.266820587 */, + /* 4302 */ 0x04453c66 | (18 << 27) /* 0.266903306 */, + /* 4303 */ 0x04459325 | (18 << 27) /* 0.266986031 */, + + /* 4304 */ 0x0445e9e5 | (18 << 27) /* 0.267068763 */, + /* 4305 */ 0x044640a7 | (18 << 27) /* 0.267151501 */, + /* 4306 */ 0x0446976a | (18 << 27) /* 0.267234246 */, + /* 4307 */ 0x0446ee30 | (18 << 27) /* 0.267316997 */, + /* 4308 */ 0x044744f7 | (18 << 27) /* 0.267399755 */, + /* 4309 */ 0x04479bc0 | (18 << 27) /* 0.267482518 */, + /* 4310 */ 0x0447f28a | (18 << 27) /* 0.267565289 */, + /* 4311 */ 0x04484956 | (18 << 27) /* 0.267648065 */, + /* 4312 */ 0x0448a024 | (18 << 27) /* 0.267730848 */, + /* 4313 */ 0x0448f6f4 | (18 << 27) /* 0.267813638 */, + /* 4314 */ 0x04494dc5 | (18 << 27) /* 0.267896434 */, + /* 4315 */ 0x0449a498 | (18 << 27) /* 0.267979236 */, + /* 4316 */ 0x0449fb6d | (18 << 27) /* 0.268062045 */, + /* 4317 */ 0x044a5243 | (18 << 27) /* 0.268144860 */, + /* 4318 */ 0x044aa91c | (18 << 27) /* 0.268227681 */, + /* 4319 */ 0x044afff6 | (18 << 27) /* 0.268310509 */, + + /* 4320 */ 0x044b56d1 | (18 << 27) /* 0.268393343 */, + /* 4321 */ 0x044badaf | (18 << 27) /* 0.268476184 */, + /* 4322 */ 0x044c048e | (18 << 27) /* 0.268559031 */, + /* 4323 */ 0x044c5b6f | (18 << 27) /* 0.268641885 */, + /* 4324 */ 0x044cb251 | (18 << 27) /* 0.268724744 */, + /* 4325 */ 0x044d0935 | (18 << 27) /* 0.268807611 */, + /* 4326 */ 0x044d601b | (18 << 27) /* 0.268890483 */, + /* 4327 */ 0x044db703 | (18 << 27) /* 0.268973362 */, + /* 4328 */ 0x044e0dec | (18 << 27) /* 0.269056248 */, + /* 4329 */ 0x044e64d7 | (18 << 27) /* 0.269139139 */, + /* 4330 */ 0x044ebbc4 | (18 << 27) /* 0.269222037 */, + /* 4331 */ 0x044f12b3 | (18 << 27) /* 0.269304942 */, + /* 4332 */ 0x044f69a3 | (18 << 27) /* 0.269387853 */, + /* 4333 */ 0x044fc095 | (18 << 27) /* 0.269470770 */, + /* 4334 */ 0x04501788 | (18 << 27) /* 0.269553694 */, + /* 4335 */ 0x04506e7e | (18 << 27) /* 0.269636624 */, + + /* 4336 */ 0x0450c575 | (18 << 27) /* 0.269719560 */, + /* 4337 */ 0x04511c6e | (18 << 27) /* 0.269802503 */, + /* 4338 */ 0x04517368 | (18 << 27) /* 0.269885452 */, + /* 4339 */ 0x0451ca64 | (18 << 27) /* 0.269968408 */, + /* 4340 */ 0x04522162 | (18 << 27) /* 0.270051370 */, + /* 4341 */ 0x04527862 | (18 << 27) /* 0.270134338 */, + /* 4342 */ 0x0452cf63 | (18 << 27) /* 0.270217312 */, + /* 4343 */ 0x04532666 | (18 << 27) /* 0.270300293 */, + /* 4344 */ 0x04537d6b | (18 << 27) /* 0.270383281 */, + /* 4345 */ 0x0453d472 | (18 << 27) /* 0.270466275 */, + /* 4346 */ 0x04542b7a | (18 << 27) /* 0.270549275 */, + /* 4347 */ 0x04548284 | (18 << 27) /* 0.270632281 */, + /* 4348 */ 0x0454d98f | (18 << 27) /* 0.270715294 */, + /* 4349 */ 0x0455309c | (18 << 27) /* 0.270798313 */, + /* 4350 */ 0x045587ab | (18 << 27) /* 0.270881339 */, + /* 4351 */ 0x0455debc | (18 << 27) /* 0.270964371 */, + + /* 4352 */ 0x045635cf | (18 << 27) /* 0.271047409 */, + /* 4353 */ 0x04568ce3 | (18 << 27) /* 0.271130454 */, + /* 4354 */ 0x0456e3f9 | (18 << 27) /* 0.271213505 */, + /* 4355 */ 0x04573b10 | (18 << 27) /* 0.271296562 */, + /* 4356 */ 0x04579229 | (18 << 27) /* 0.271379626 */, + /* 4357 */ 0x0457e944 | (18 << 27) /* 0.271462696 */, + /* 4358 */ 0x04584061 | (18 << 27) /* 0.271545772 */, + /* 4359 */ 0x0458977f | (18 << 27) /* 0.271628855 */, + /* 4360 */ 0x0458ee9f | (18 << 27) /* 0.271711944 */, + /* 4361 */ 0x045945c1 | (18 << 27) /* 0.271795040 */, + /* 4362 */ 0x04599ce5 | (18 << 27) /* 0.271878142 */, + /* 4363 */ 0x0459f40a | (18 << 27) /* 0.271961250 */, + /* 4364 */ 0x045a4b31 | (18 << 27) /* 0.272044365 */, + /* 4365 */ 0x045aa259 | (18 << 27) /* 0.272127486 */, + /* 4366 */ 0x045af984 | (18 << 27) /* 0.272210613 */, + /* 4367 */ 0x045b50b0 | (18 << 27) /* 0.272293746 */, + + /* 4368 */ 0x045ba7dd | (18 << 27) /* 0.272376886 */, + /* 4369 */ 0x045bff0d | (18 << 27) /* 0.272460033 */, + /* 4370 */ 0x045c563e | (18 << 27) /* 0.272543185 */, + /* 4371 */ 0x045cad71 | (18 << 27) /* 0.272626344 */, + /* 4372 */ 0x045d04a5 | (18 << 27) /* 0.272709510 */, + /* 4373 */ 0x045d5bdc | (18 << 27) /* 0.272792681 */, + /* 4374 */ 0x045db313 | (18 << 27) /* 0.272875859 */, + /* 4375 */ 0x045e0a4d | (18 << 27) /* 0.272959044 */, + /* 4376 */ 0x045e6188 | (18 << 27) /* 0.273042234 */, + /* 4377 */ 0x045eb8c5 | (18 << 27) /* 0.273125431 */, + /* 4378 */ 0x045f1004 | (18 << 27) /* 0.273208635 */, + /* 4379 */ 0x045f6745 | (18 << 27) /* 0.273291844 */, + /* 4380 */ 0x045fbe87 | (18 << 27) /* 0.273375060 */, + /* 4381 */ 0x046015cb | (18 << 27) /* 0.273458283 */, + /* 4382 */ 0x04606d10 | (18 << 27) /* 0.273541511 */, + /* 4383 */ 0x0460c457 | (18 << 27) /* 0.273624747 */, + + /* 4384 */ 0x04611ba0 | (18 << 27) /* 0.273707988 */, + /* 4385 */ 0x046172eb | (18 << 27) /* 0.273791236 */, + /* 4386 */ 0x0461ca37 | (18 << 27) /* 0.273874490 */, + /* 4387 */ 0x04622185 | (18 << 27) /* 0.273957750 */, + /* 4388 */ 0x046278d5 | (18 << 27) /* 0.274041017 */, + /* 4389 */ 0x0462d026 | (18 << 27) /* 0.274124290 */, + /* 4390 */ 0x0463277a | (18 << 27) /* 0.274207569 */, + /* 4391 */ 0x04637ece | (18 << 27) /* 0.274290855 */, + /* 4392 */ 0x0463d625 | (18 << 27) /* 0.274374147 */, + /* 4393 */ 0x04642d7d | (18 << 27) /* 0.274457445 */, + /* 4394 */ 0x046484d7 | (18 << 27) /* 0.274540749 */, + /* 4395 */ 0x0464dc33 | (18 << 27) /* 0.274624060 */, + /* 4396 */ 0x04653390 | (18 << 27) /* 0.274707378 */, + /* 4397 */ 0x04658aef | (18 << 27) /* 0.274790701 */, + /* 4398 */ 0x0465e250 | (18 << 27) /* 0.274874031 */, + /* 4399 */ 0x046639b2 | (18 << 27) /* 0.274957367 */, + + /* 4400 */ 0x04669116 | (18 << 27) /* 0.275040710 */, + /* 4401 */ 0x0466e87c | (18 << 27) /* 0.275124059 */, + /* 4402 */ 0x04673fe3 | (18 << 27) /* 0.275207414 */, + /* 4403 */ 0x0467974d | (18 << 27) /* 0.275290775 */, + /* 4404 */ 0x0467eeb7 | (18 << 27) /* 0.275374143 */, + /* 4405 */ 0x04684624 | (18 << 27) /* 0.275457517 */, + /* 4406 */ 0x04689d92 | (18 << 27) /* 0.275540897 */, + /* 4407 */ 0x0468f502 | (18 << 27) /* 0.275624284 */, + /* 4408 */ 0x04694c74 | (18 << 27) /* 0.275707677 */, + /* 4409 */ 0x0469a3e7 | (18 << 27) /* 0.275791076 */, + /* 4410 */ 0x0469fb5c | (18 << 27) /* 0.275874482 */, + /* 4411 */ 0x046a52d3 | (18 << 27) /* 0.275957894 */, + /* 4412 */ 0x046aaa4b | (18 << 27) /* 0.276041312 */, + /* 4413 */ 0x046b01c5 | (18 << 27) /* 0.276124737 */, + /* 4414 */ 0x046b5941 | (18 << 27) /* 0.276208167 */, + /* 4415 */ 0x046bb0bf | (18 << 27) /* 0.276291605 */, + + /* 4416 */ 0x046c083e | (18 << 27) /* 0.276375048 */, + /* 4417 */ 0x046c5fbf | (18 << 27) /* 0.276458498 */, + /* 4418 */ 0x046cb741 | (18 << 27) /* 0.276541954 */, + /* 4419 */ 0x046d0ec5 | (18 << 27) /* 0.276625416 */, + /* 4420 */ 0x046d664b | (18 << 27) /* 0.276708885 */, + /* 4421 */ 0x046dbdd3 | (18 << 27) /* 0.276792360 */, + /* 4422 */ 0x046e155c | (18 << 27) /* 0.276875841 */, + /* 4423 */ 0x046e6ce7 | (18 << 27) /* 0.276959328 */, + /* 4424 */ 0x046ec474 | (18 << 27) /* 0.277042822 */, + /* 4425 */ 0x046f1c02 | (18 << 27) /* 0.277126322 */, + /* 4426 */ 0x046f7392 | (18 << 27) /* 0.277209829 */, + /* 4427 */ 0x046fcb24 | (18 << 27) /* 0.277293341 */, + /* 4428 */ 0x047022b8 | (18 << 27) /* 0.277376860 */, + /* 4429 */ 0x04707a4d | (18 << 27) /* 0.277460385 */, + /* 4430 */ 0x0470d1e4 | (18 << 27) /* 0.277543917 */, + /* 4431 */ 0x0471297c | (18 << 27) /* 0.277627455 */, + + /* 4432 */ 0x04718116 | (18 << 27) /* 0.277710999 */, + /* 4433 */ 0x0471d8b2 | (18 << 27) /* 0.277794549 */, + /* 4434 */ 0x04723050 | (18 << 27) /* 0.277878106 */, + /* 4435 */ 0x047287ef | (18 << 27) /* 0.277961669 */, + /* 4436 */ 0x0472df90 | (18 << 27) /* 0.278045238 */, + /* 4437 */ 0x04733733 | (18 << 27) /* 0.278128813 */, + /* 4438 */ 0x04738ed7 | (18 << 27) /* 0.278212395 */, + /* 4439 */ 0x0473e67d | (18 << 27) /* 0.278295983 */, + /* 4440 */ 0x04743e25 | (18 << 27) /* 0.278379578 */, + /* 4441 */ 0x047495ce | (18 << 27) /* 0.278463178 */, + /* 4442 */ 0x0474ed79 | (18 << 27) /* 0.278546785 */, + /* 4443 */ 0x04754526 | (18 << 27) /* 0.278630398 */, + /* 4444 */ 0x04759cd4 | (18 << 27) /* 0.278714018 */, + /* 4445 */ 0x0475f484 | (18 << 27) /* 0.278797643 */, + /* 4446 */ 0x04764c36 | (18 << 27) /* 0.278881275 */, + /* 4447 */ 0x0476a3ea | (18 << 27) /* 0.278964914 */, + + /* 4448 */ 0x0476fb9f | (18 << 27) /* 0.279048558 */, + /* 4449 */ 0x04775356 | (18 << 27) /* 0.279132209 */, + /* 4450 */ 0x0477ab0e | (18 << 27) /* 0.279215866 */, + /* 4451 */ 0x047802c8 | (18 << 27) /* 0.279299529 */, + /* 4452 */ 0x04785a84 | (18 << 27) /* 0.279383199 */, + /* 4453 */ 0x0478b242 | (18 << 27) /* 0.279466875 */, + /* 4454 */ 0x04790a01 | (18 << 27) /* 0.279550557 */, + /* 4455 */ 0x047961c2 | (18 << 27) /* 0.279634245 */, + /* 4456 */ 0x0479b984 | (18 << 27) /* 0.279717940 */, + /* 4457 */ 0x047a1149 | (18 << 27) /* 0.279801641 */, + /* 4458 */ 0x047a690f | (18 << 27) /* 0.279885348 */, + /* 4459 */ 0x047ac0d6 | (18 << 27) /* 0.279969061 */, + /* 4460 */ 0x047b18a0 | (18 << 27) /* 0.280052781 */, + /* 4461 */ 0x047b706b | (18 << 27) /* 0.280136507 */, + /* 4462 */ 0x047bc837 | (18 << 27) /* 0.280220239 */, + /* 4463 */ 0x047c2006 | (18 << 27) /* 0.280303978 */, + + /* 4464 */ 0x047c77d6 | (18 << 27) /* 0.280387722 */, + /* 4465 */ 0x047ccfa8 | (18 << 27) /* 0.280471473 */, + /* 4466 */ 0x047d277b | (18 << 27) /* 0.280555230 */, + /* 4467 */ 0x047d7f50 | (18 << 27) /* 0.280638994 */, + /* 4468 */ 0x047dd727 | (18 << 27) /* 0.280722764 */, + /* 4469 */ 0x047e2eff | (18 << 27) /* 0.280806540 */, + /* 4470 */ 0x047e86d9 | (18 << 27) /* 0.280890322 */, + /* 4471 */ 0x047edeb5 | (18 << 27) /* 0.280974110 */, + /* 4472 */ 0x047f3693 | (18 << 27) /* 0.281057905 */, + /* 4473 */ 0x047f8e72 | (18 << 27) /* 0.281141706 */, + /* 4474 */ 0x047fe653 | (18 << 27) /* 0.281225513 */, + /* 4475 */ 0x04803e35 | (18 << 27) /* 0.281309326 */, + /* 4476 */ 0x04809619 | (18 << 27) /* 0.281393146 */, + /* 4477 */ 0x0480edff | (18 << 27) /* 0.281476972 */, + /* 4478 */ 0x048145e7 | (18 << 27) /* 0.281560804 */, + /* 4479 */ 0x04819dd0 | (18 << 27) /* 0.281644643 */, + + /* 4480 */ 0x0481f5bb | (18 << 27) /* 0.281728487 */, + /* 4481 */ 0x04824da7 | (18 << 27) /* 0.281812338 */, + /* 4482 */ 0x0482a595 | (18 << 27) /* 0.281896195 */, + /* 4483 */ 0x0482fd85 | (18 << 27) /* 0.281980059 */, + /* 4484 */ 0x04835577 | (18 << 27) /* 0.282063928 */, + /* 4485 */ 0x0483ad6a | (18 << 27) /* 0.282147804 */, + /* 4486 */ 0x0484055f | (18 << 27) /* 0.282231686 */, + /* 4487 */ 0x04845d56 | (18 << 27) /* 0.282315574 */, + /* 4488 */ 0x0484b54e | (18 << 27) /* 0.282399469 */, + /* 4489 */ 0x04850d48 | (18 << 27) /* 0.282483370 */, + /* 4490 */ 0x04856544 | (18 << 27) /* 0.282567277 */, + /* 4491 */ 0x0485bd41 | (18 << 27) /* 0.282651190 */, + /* 4492 */ 0x04861540 | (18 << 27) /* 0.282735109 */, + /* 4493 */ 0x04866d40 | (18 << 27) /* 0.282819035 */, + /* 4494 */ 0x0486c543 | (18 << 27) /* 0.282902967 */, + /* 4495 */ 0x04871d47 | (18 << 27) /* 0.282986905 */, + + /* 4496 */ 0x0487754c | (18 << 27) /* 0.283070849 */, + /* 4497 */ 0x0487cd54 | (18 << 27) /* 0.283154800 */, + /* 4498 */ 0x0488255d | (18 << 27) /* 0.283238757 */, + /* 4499 */ 0x04887d67 | (18 << 27) /* 0.283322720 */, + /* 4500 */ 0x0488d574 | (18 << 27) /* 0.283406689 */, + /* 4501 */ 0x04892d82 | (18 << 27) /* 0.283490665 */, + /* 4502 */ 0x04898591 | (18 << 27) /* 0.283574646 */, + /* 4503 */ 0x0489dda3 | (18 << 27) /* 0.283658634 */, + /* 4504 */ 0x048a35b6 | (18 << 27) /* 0.283742628 */, + /* 4505 */ 0x048a8dca | (18 << 27) /* 0.283826629 */, + /* 4506 */ 0x048ae5e1 | (18 << 27) /* 0.283910635 */, + /* 4507 */ 0x048b3df9 | (18 << 27) /* 0.283994648 */, + /* 4508 */ 0x048b9612 | (18 << 27) /* 0.284078667 */, + /* 4509 */ 0x048bee2e | (18 << 27) /* 0.284162692 */, + /* 4510 */ 0x048c464b | (18 << 27) /* 0.284246723 */, + /* 4511 */ 0x048c9e69 | (18 << 27) /* 0.284330761 */, + + /* 4512 */ 0x048cf68a | (18 << 27) /* 0.284414805 */, + /* 4513 */ 0x048d4eac | (18 << 27) /* 0.284498855 */, + /* 4514 */ 0x048da6cf | (18 << 27) /* 0.284582911 */, + /* 4515 */ 0x048dfef5 | (18 << 27) /* 0.284666974 */, + /* 4516 */ 0x048e571c | (18 << 27) /* 0.284751042 */, + /* 4517 */ 0x048eaf44 | (18 << 27) /* 0.284835117 */, + /* 4518 */ 0x048f076f | (18 << 27) /* 0.284919198 */, + /* 4519 */ 0x048f5f9b | (18 << 27) /* 0.285003285 */, + /* 4520 */ 0x048fb7c8 | (18 << 27) /* 0.285087379 */, + /* 4521 */ 0x04900ff8 | (18 << 27) /* 0.285171479 */, + /* 4522 */ 0x04906829 | (18 << 27) /* 0.285255584 */, + /* 4523 */ 0x0490c05b | (18 << 27) /* 0.285339697 */, + /* 4524 */ 0x04911890 | (18 << 27) /* 0.285423815 */, + /* 4525 */ 0x049170c6 | (18 << 27) /* 0.285507939 */, + /* 4526 */ 0x0491c8fd | (18 << 27) /* 0.285592070 */, + /* 4527 */ 0x04922137 | (18 << 27) /* 0.285676207 */, + + /* 4528 */ 0x04927972 | (18 << 27) /* 0.285760350 */, + /* 4529 */ 0x0492d1ae | (18 << 27) /* 0.285844499 */, + /* 4530 */ 0x049329ed | (18 << 27) /* 0.285928655 */, + /* 4531 */ 0x0493822c | (18 << 27) /* 0.286012816 */, + /* 4532 */ 0x0493da6e | (18 << 27) /* 0.286096984 */, + /* 4533 */ 0x049432b1 | (18 << 27) /* 0.286181158 */, + /* 4534 */ 0x04948af6 | (18 << 27) /* 0.286265338 */, + /* 4535 */ 0x0494e33d | (18 << 27) /* 0.286349525 */, + /* 4536 */ 0x04953b85 | (18 << 27) /* 0.286433717 */, + /* 4537 */ 0x049593cf | (18 << 27) /* 0.286517916 */, + /* 4538 */ 0x0495ec1b | (18 << 27) /* 0.286602121 */, + /* 4539 */ 0x04964468 | (18 << 27) /* 0.286686332 */, + /* 4540 */ 0x04969cb7 | (18 << 27) /* 0.286770550 */, + /* 4541 */ 0x0496f508 | (18 << 27) /* 0.286854773 */, + /* 4542 */ 0x04974d5a | (18 << 27) /* 0.286939003 */, + /* 4543 */ 0x0497a5ae | (18 << 27) /* 0.287023239 */, + + /* 4544 */ 0x0497fe03 | (18 << 27) /* 0.287107481 */, + /* 4545 */ 0x0498565a | (18 << 27) /* 0.287191729 */, + /* 4546 */ 0x0498aeb3 | (18 << 27) /* 0.287275983 */, + /* 4547 */ 0x0499070e | (18 << 27) /* 0.287360244 */, + /* 4548 */ 0x04995f6a | (18 << 27) /* 0.287444511 */, + /* 4549 */ 0x0499b7c8 | (18 << 27) /* 0.287528784 */, + /* 4550 */ 0x049a1027 | (18 << 27) /* 0.287613063 */, + /* 4551 */ 0x049a6889 | (18 << 27) /* 0.287697348 */, + /* 4552 */ 0x049ac0eb | (18 << 27) /* 0.287781640 */, + /* 4553 */ 0x049b1950 | (18 << 27) /* 0.287865937 */, + /* 4554 */ 0x049b71b6 | (18 << 27) /* 0.287950241 */, + /* 4555 */ 0x049bca1e | (18 << 27) /* 0.288034551 */, + /* 4556 */ 0x049c2287 | (18 << 27) /* 0.288118867 */, + /* 4557 */ 0x049c7af2 | (18 << 27) /* 0.288203190 */, + /* 4558 */ 0x049cd35f | (18 << 27) /* 0.288287518 */, + /* 4559 */ 0x049d2bce | (18 << 27) /* 0.288371853 */, + + /* 4560 */ 0x049d843e | (18 << 27) /* 0.288456194 */, + /* 4561 */ 0x049ddcaf | (18 << 27) /* 0.288540541 */, + /* 4562 */ 0x049e3523 | (18 << 27) /* 0.288624894 */, + /* 4563 */ 0x049e8d98 | (18 << 27) /* 0.288709253 */, + /* 4564 */ 0x049ee60e | (18 << 27) /* 0.288793619 */, + /* 4565 */ 0x049f3e87 | (18 << 27) /* 0.288877990 */, + /* 4566 */ 0x049f9701 | (18 << 27) /* 0.288962368 */, + /* 4567 */ 0x049fef7c | (18 << 27) /* 0.289046752 */, + /* 4568 */ 0x04a047fa | (18 << 27) /* 0.289131142 */, + /* 4569 */ 0x04a0a079 | (18 << 27) /* 0.289215538 */, + /* 4570 */ 0x04a0f8f9 | (18 << 27) /* 0.289299941 */, + /* 4571 */ 0x04a1517c | (18 << 27) /* 0.289384349 */, + /* 4572 */ 0x04a1a9ff | (18 << 27) /* 0.289468764 */, + /* 4573 */ 0x04a20285 | (18 << 27) /* 0.289553185 */, + /* 4574 */ 0x04a25b0c | (18 << 27) /* 0.289637612 */, + /* 4575 */ 0x04a2b395 | (18 << 27) /* 0.289722045 */, + + /* 4576 */ 0x04a30c20 | (18 << 27) /* 0.289806485 */, + /* 4577 */ 0x04a364ac | (18 << 27) /* 0.289890930 */, + /* 4578 */ 0x04a3bd3a | (18 << 27) /* 0.289975382 */, + /* 4579 */ 0x04a415c9 | (18 << 27) /* 0.290059840 */, + /* 4580 */ 0x04a46e5a | (18 << 27) /* 0.290144304 */, + /* 4581 */ 0x04a4c6ed | (18 << 27) /* 0.290228774 */, + /* 4582 */ 0x04a51f81 | (18 << 27) /* 0.290313250 */, + /* 4583 */ 0x04a57818 | (18 << 27) /* 0.290397733 */, + /* 4584 */ 0x04a5d0af | (18 << 27) /* 0.290482221 */, + /* 4585 */ 0x04a62949 | (18 << 27) /* 0.290566716 */, + /* 4586 */ 0x04a681e4 | (18 << 27) /* 0.290651217 */, + /* 4587 */ 0x04a6da80 | (18 << 27) /* 0.290735724 */, + /* 4588 */ 0x04a7331f | (18 << 27) /* 0.290820237 */, + /* 4589 */ 0x04a78bbf | (18 << 27) /* 0.290904756 */, + /* 4590 */ 0x04a7e460 | (18 << 27) /* 0.290989281 */, + /* 4591 */ 0x04a83d03 | (18 << 27) /* 0.291073813 */, + + /* 4592 */ 0x04a895a8 | (18 << 27) /* 0.291158351 */, + /* 4593 */ 0x04a8ee4f | (18 << 27) /* 0.291242894 */, + /* 4594 */ 0x04a946f7 | (18 << 27) /* 0.291327444 */, + /* 4595 */ 0x04a99fa1 | (18 << 27) /* 0.291412001 */, + /* 4596 */ 0x04a9f84c | (18 << 27) /* 0.291496563 */, + /* 4597 */ 0x04aa50fa | (18 << 27) /* 0.291581131 */, + /* 4598 */ 0x04aaa9a8 | (18 << 27) /* 0.291665706 */, + /* 4599 */ 0x04ab0259 | (18 << 27) /* 0.291750286 */, + /* 4600 */ 0x04ab5b0b | (18 << 27) /* 0.291834873 */, + /* 4601 */ 0x04abb3bf | (18 << 27) /* 0.291919466 */, + /* 4602 */ 0x04ac0c74 | (18 << 27) /* 0.292004065 */, + /* 4603 */ 0x04ac652b | (18 << 27) /* 0.292088670 */, + /* 4604 */ 0x04acbde4 | (18 << 27) /* 0.292173281 */, + /* 4605 */ 0x04ad169e | (18 << 27) /* 0.292257899 */, + /* 4606 */ 0x04ad6f5a | (18 << 27) /* 0.292342522 */, + /* 4607 */ 0x04adc818 | (18 << 27) /* 0.292427152 */, + + /* 4608 */ 0x04ae20d7 | (18 << 27) /* 0.292511788 */, + /* 4609 */ 0x04ae7998 | (18 << 27) /* 0.292596430 */, + /* 4610 */ 0x04aed25a | (18 << 27) /* 0.292681078 */, + /* 4611 */ 0x04af2b1e | (18 << 27) /* 0.292765732 */, + /* 4612 */ 0x04af83e4 | (18 << 27) /* 0.292850392 */, + /* 4613 */ 0x04afdcac | (18 << 27) /* 0.292935058 */, + /* 4614 */ 0x04b03575 | (18 << 27) /* 0.293019731 */, + /* 4615 */ 0x04b08e40 | (18 << 27) /* 0.293104409 */, + /* 4616 */ 0x04b0e70c | (18 << 27) /* 0.293189094 */, + /* 4617 */ 0x04b13fda | (18 << 27) /* 0.293273785 */, + /* 4618 */ 0x04b198aa | (18 << 27) /* 0.293358482 */, + /* 4619 */ 0x04b1f17b | (18 << 27) /* 0.293443185 */, + /* 4620 */ 0x04b24a4e | (18 << 27) /* 0.293527894 */, + /* 4621 */ 0x04b2a322 | (18 << 27) /* 0.293612609 */, + /* 4622 */ 0x04b2fbf9 | (18 << 27) /* 0.293697331 */, + /* 4623 */ 0x04b354d1 | (18 << 27) /* 0.293782058 */, + + /* 4624 */ 0x04b3adaa | (18 << 27) /* 0.293866792 */, + /* 4625 */ 0x04b40685 | (18 << 27) /* 0.293951532 */, + /* 4626 */ 0x04b45f62 | (18 << 27) /* 0.294036278 */, + /* 4627 */ 0x04b4b840 | (18 << 27) /* 0.294121029 */, + /* 4628 */ 0x04b51120 | (18 << 27) /* 0.294205788 */, + /* 4629 */ 0x04b56a02 | (18 << 27) /* 0.294290552 */, + /* 4630 */ 0x04b5c2e6 | (18 << 27) /* 0.294375322 */, + /* 4631 */ 0x04b61bcb | (18 << 27) /* 0.294460098 */, + /* 4632 */ 0x04b674b1 | (18 << 27) /* 0.294544881 */, + /* 4633 */ 0x04b6cd99 | (18 << 27) /* 0.294629669 */, + /* 4634 */ 0x04b72683 | (18 << 27) /* 0.294714464 */, + /* 4635 */ 0x04b77f6f | (18 << 27) /* 0.294799265 */, + /* 4636 */ 0x04b7d85c | (18 << 27) /* 0.294884072 */, + /* 4637 */ 0x04b8314b | (18 << 27) /* 0.294968885 */, + /* 4638 */ 0x04b88a3b | (18 << 27) /* 0.295053704 */, + /* 4639 */ 0x04b8e32d | (18 << 27) /* 0.295138529 */, + + /* 4640 */ 0x04b93c21 | (18 << 27) /* 0.295223360 */, + /* 4641 */ 0x04b99516 | (18 << 27) /* 0.295308197 */, + /* 4642 */ 0x04b9ee0d | (18 << 27) /* 0.295393041 */, + /* 4643 */ 0x04ba4706 | (18 << 27) /* 0.295477890 */, + /* 4644 */ 0x04baa000 | (18 << 27) /* 0.295562746 */, + /* 4645 */ 0x04baf8fc | (18 << 27) /* 0.295647608 */, + /* 4646 */ 0x04bb51fa | (18 << 27) /* 0.295732476 */, + /* 4647 */ 0x04bbaaf9 | (18 << 27) /* 0.295817349 */, + /* 4648 */ 0x04bc03fa | (18 << 27) /* 0.295902229 */, + /* 4649 */ 0x04bc5cfc | (18 << 27) /* 0.295987115 */, + /* 4650 */ 0x04bcb600 | (18 << 27) /* 0.296072008 */, + /* 4651 */ 0x04bd0f06 | (18 << 27) /* 0.296156906 */, + /* 4652 */ 0x04bd680d | (18 << 27) /* 0.296241810 */, + /* 4653 */ 0x04bdc116 | (18 << 27) /* 0.296326721 */, + /* 4654 */ 0x04be1a21 | (18 << 27) /* 0.296411637 */, + /* 4655 */ 0x04be732d | (18 << 27) /* 0.296496560 */, + + /* 4656 */ 0x04becc3b | (18 << 27) /* 0.296581488 */, + /* 4657 */ 0x04bf254a | (18 << 27) /* 0.296666423 */, + /* 4658 */ 0x04bf7e5b | (18 << 27) /* 0.296751364 */, + /* 4659 */ 0x04bfd76e | (18 << 27) /* 0.296836311 */, + /* 4660 */ 0x04c03083 | (18 << 27) /* 0.296921264 */, + /* 4661 */ 0x04c08999 | (18 << 27) /* 0.297006223 */, + /* 4662 */ 0x04c0e2b0 | (18 << 27) /* 0.297091188 */, + /* 4663 */ 0x04c13bca | (18 << 27) /* 0.297176159 */, + /* 4664 */ 0x04c194e4 | (18 << 27) /* 0.297261136 */, + /* 4665 */ 0x04c1ee01 | (18 << 27) /* 0.297346120 */, + /* 4666 */ 0x04c2471f | (18 << 27) /* 0.297431109 */, + /* 4667 */ 0x04c2a03f | (18 << 27) /* 0.297516105 */, + /* 4668 */ 0x04c2f960 | (18 << 27) /* 0.297601106 */, + /* 4669 */ 0x04c35283 | (18 << 27) /* 0.297686114 */, + /* 4670 */ 0x04c3aba8 | (18 << 27) /* 0.297771128 */, + /* 4671 */ 0x04c404ce | (18 << 27) /* 0.297856147 */, + + /* 4672 */ 0x04c45df6 | (18 << 27) /* 0.297941173 */, + /* 4673 */ 0x04c4b720 | (18 << 27) /* 0.298026205 */, + /* 4674 */ 0x04c5104b | (18 << 27) /* 0.298111243 */, + /* 4675 */ 0x04c56978 | (18 << 27) /* 0.298196287 */, + /* 4676 */ 0x04c5c2a7 | (18 << 27) /* 0.298281337 */, + /* 4677 */ 0x04c61bd7 | (18 << 27) /* 0.298366393 */, + /* 4678 */ 0x04c67508 | (18 << 27) /* 0.298451456 */, + /* 4679 */ 0x04c6ce3c | (18 << 27) /* 0.298536524 */, + /* 4680 */ 0x04c72771 | (18 << 27) /* 0.298621598 */, + /* 4681 */ 0x04c780a7 | (18 << 27) /* 0.298706679 */, + /* 4682 */ 0x04c7d9df | (18 << 27) /* 0.298791765 */, + /* 4683 */ 0x04c83319 | (18 << 27) /* 0.298876858 */, + /* 4684 */ 0x04c88c55 | (18 << 27) /* 0.298961956 */, + /* 4685 */ 0x04c8e592 | (18 << 27) /* 0.299047061 */, + /* 4686 */ 0x04c93ed1 | (18 << 27) /* 0.299132172 */, + /* 4687 */ 0x04c99811 | (18 << 27) /* 0.299217288 */, + + /* 4688 */ 0x04c9f153 | (18 << 27) /* 0.299302411 */, + /* 4689 */ 0x04ca4a97 | (18 << 27) /* 0.299387540 */, + /* 4690 */ 0x04caa3dc | (18 << 27) /* 0.299472675 */, + /* 4691 */ 0x04cafd23 | (18 << 27) /* 0.299557816 */, + /* 4692 */ 0x04cb566b | (18 << 27) /* 0.299642963 */, + /* 4693 */ 0x04cbafb5 | (18 << 27) /* 0.299728116 */, + /* 4694 */ 0x04cc0901 | (18 << 27) /* 0.299813275 */, + /* 4695 */ 0x04cc624e | (18 << 27) /* 0.299898440 */, + /* 4696 */ 0x04ccbb9d | (18 << 27) /* 0.299983611 */, + /* 4697 */ 0x04cd14ee | (18 << 27) /* 0.300068789 */, + /* 4698 */ 0x04cd6e40 | (18 << 27) /* 0.300153972 */, + /* 4699 */ 0x04cdc794 | (18 << 27) /* 0.300239161 */, + /* 4700 */ 0x04ce20e9 | (18 << 27) /* 0.300324357 */, + /* 4701 */ 0x04ce7a40 | (18 << 27) /* 0.300409558 */, + /* 4702 */ 0x04ced399 | (18 << 27) /* 0.300494765 */, + /* 4703 */ 0x04cf2cf3 | (18 << 27) /* 0.300579979 */, + + /* 4704 */ 0x04cf864f | (18 << 27) /* 0.300665198 */, + /* 4705 */ 0x04cfdfad | (18 << 27) /* 0.300750424 */, + /* 4706 */ 0x04d0390c | (18 << 27) /* 0.300835656 */, + /* 4707 */ 0x04d0926d | (18 << 27) /* 0.300920893 */, + /* 4708 */ 0x04d0ebcf | (18 << 27) /* 0.301006137 */, + /* 4709 */ 0x04d14533 | (18 << 27) /* 0.301091387 */, + /* 4710 */ 0x04d19e99 | (18 << 27) /* 0.301176643 */, + /* 4711 */ 0x04d1f800 | (18 << 27) /* 0.301261904 */, + /* 4712 */ 0x04d25169 | (18 << 27) /* 0.301347172 */, + /* 4713 */ 0x04d2aad4 | (18 << 27) /* 0.301432446 */, + /* 4714 */ 0x04d30440 | (18 << 27) /* 0.301517726 */, + /* 4715 */ 0x04d35dae | (18 << 27) /* 0.301603012 */, + /* 4716 */ 0x04d3b71d | (18 << 27) /* 0.301688304 */, + /* 4717 */ 0x04d4108e | (18 << 27) /* 0.301773602 */, + /* 4718 */ 0x04d46a01 | (18 << 27) /* 0.301858906 */, + /* 4719 */ 0x04d4c375 | (18 << 27) /* 0.301944216 */, + + /* 4720 */ 0x04d51ceb | (18 << 27) /* 0.302029532 */, + /* 4721 */ 0x04d57662 | (18 << 27) /* 0.302114854 */, + /* 4722 */ 0x04d5cfdb | (18 << 27) /* 0.302200182 */, + /* 4723 */ 0x04d62956 | (18 << 27) /* 0.302285516 */, + /* 4724 */ 0x04d682d2 | (18 << 27) /* 0.302370856 */, + /* 4725 */ 0x04d6dc50 | (18 << 27) /* 0.302456203 */, + /* 4726 */ 0x04d735d0 | (18 << 27) /* 0.302541555 */, + /* 4727 */ 0x04d78f51 | (18 << 27) /* 0.302626913 */, + /* 4728 */ 0x04d7e8d4 | (18 << 27) /* 0.302712277 */, + /* 4729 */ 0x04d84258 | (18 << 27) /* 0.302797648 */, + /* 4730 */ 0x04d89bde | (18 << 27) /* 0.302883024 */, + /* 4731 */ 0x04d8f566 | (18 << 27) /* 0.302968406 */, + /* 4732 */ 0x04d94eef | (18 << 27) /* 0.303053794 */, + /* 4733 */ 0x04d9a87a | (18 << 27) /* 0.303139189 */, + /* 4734 */ 0x04da0207 | (18 << 27) /* 0.303224589 */, + /* 4735 */ 0x04da5b95 | (18 << 27) /* 0.303309995 */, + + /* 4736 */ 0x04dab524 | (18 << 27) /* 0.303395408 */, + /* 4737 */ 0x04db0eb6 | (18 << 27) /* 0.303480826 */, + /* 4738 */ 0x04db6849 | (18 << 27) /* 0.303566251 */, + /* 4739 */ 0x04dbc1dd | (18 << 27) /* 0.303651681 */, + /* 4740 */ 0x04dc1b73 | (18 << 27) /* 0.303737117 */, + /* 4741 */ 0x04dc750b | (18 << 27) /* 0.303822560 */, + /* 4742 */ 0x04dccea5 | (18 << 27) /* 0.303908008 */, + /* 4743 */ 0x04dd2840 | (18 << 27) /* 0.303993463 */, + /* 4744 */ 0x04dd81dc | (18 << 27) /* 0.304078923 */, + /* 4745 */ 0x04dddb7a | (18 << 27) /* 0.304164390 */, + /* 4746 */ 0x04de351a | (18 << 27) /* 0.304249862 */, + /* 4747 */ 0x04de8ebc | (18 << 27) /* 0.304335340 */, + /* 4748 */ 0x04dee85f | (18 << 27) /* 0.304420825 */, + /* 4749 */ 0x04df4203 | (18 << 27) /* 0.304506315 */, + /* 4750 */ 0x04df9baa | (18 << 27) /* 0.304591812 */, + /* 4751 */ 0x04dff552 | (18 << 27) /* 0.304677314 */, + + /* 4752 */ 0x04e04efb | (18 << 27) /* 0.304762823 */, + /* 4753 */ 0x04e0a8a6 | (18 << 27) /* 0.304848337 */, + /* 4754 */ 0x04e10253 | (18 << 27) /* 0.304933858 */, + /* 4755 */ 0x04e15c01 | (18 << 27) /* 0.305019384 */, + /* 4756 */ 0x04e1b5b1 | (18 << 27) /* 0.305104917 */, + /* 4757 */ 0x04e20f63 | (18 << 27) /* 0.305190455 */, + /* 4758 */ 0x04e26916 | (18 << 27) /* 0.305275999 */, + /* 4759 */ 0x04e2c2cb | (18 << 27) /* 0.305361550 */, + /* 4760 */ 0x04e31c81 | (18 << 27) /* 0.305447106 */, + /* 4761 */ 0x04e37639 | (18 << 27) /* 0.305532669 */, + /* 4762 */ 0x04e3cff3 | (18 << 27) /* 0.305618237 */, + /* 4763 */ 0x04e429ae | (18 << 27) /* 0.305703811 */, + /* 4764 */ 0x04e4836b | (18 << 27) /* 0.305789392 */, + /* 4765 */ 0x04e4dd29 | (18 << 27) /* 0.305874978 */, + /* 4766 */ 0x04e536e9 | (18 << 27) /* 0.305960571 */, + /* 4767 */ 0x04e590ab | (18 << 27) /* 0.306046169 */, + + /* 4768 */ 0x04e5ea6e | (18 << 27) /* 0.306131773 */, + /* 4769 */ 0x04e64433 | (18 << 27) /* 0.306217383 */, + /* 4770 */ 0x04e69df9 | (18 << 27) /* 0.306303000 */, + /* 4771 */ 0x04e6f7c1 | (18 << 27) /* 0.306388622 */, + /* 4772 */ 0x04e7518b | (18 << 27) /* 0.306474250 */, + /* 4773 */ 0x04e7ab56 | (18 << 27) /* 0.306559885 */, + /* 4774 */ 0x04e80523 | (18 << 27) /* 0.306645525 */, + /* 4775 */ 0x04e85ef2 | (18 << 27) /* 0.306731171 */, + /* 4776 */ 0x04e8b8c2 | (18 << 27) /* 0.306816823 */, + /* 4777 */ 0x04e91293 | (18 << 27) /* 0.306902481 */, + /* 4778 */ 0x04e96c67 | (18 << 27) /* 0.306988145 */, + /* 4779 */ 0x04e9c63b | (18 << 27) /* 0.307073816 */, + /* 4780 */ 0x04ea2012 | (18 << 27) /* 0.307159492 */, + /* 4781 */ 0x04ea79ea | (18 << 27) /* 0.307245174 */, + /* 4782 */ 0x04ead3c4 | (18 << 27) /* 0.307330862 */, + /* 4783 */ 0x04eb2d9f | (18 << 27) /* 0.307416556 */, + + /* 4784 */ 0x04eb877c | (18 << 27) /* 0.307502256 */, + /* 4785 */ 0x04ebe15b | (18 << 27) /* 0.307587962 */, + /* 4786 */ 0x04ec3b3b | (18 << 27) /* 0.307673674 */, + /* 4787 */ 0x04ec951c | (18 << 27) /* 0.307759392 */, + /* 4788 */ 0x04ecef00 | (18 << 27) /* 0.307845115 */, + /* 4789 */ 0x04ed48e5 | (18 << 27) /* 0.307930845 */, + /* 4790 */ 0x04eda2cb | (18 << 27) /* 0.308016581 */, + /* 4791 */ 0x04edfcb3 | (18 << 27) /* 0.308102323 */, + /* 4792 */ 0x04ee569d | (18 << 27) /* 0.308188071 */, + /* 4793 */ 0x04eeb088 | (18 << 27) /* 0.308273824 */, + /* 4794 */ 0x04ef0a75 | (18 << 27) /* 0.308359584 */, + /* 4795 */ 0x04ef6464 | (18 << 27) /* 0.308445350 */, + /* 4796 */ 0x04efbe54 | (18 << 27) /* 0.308531121 */, + /* 4797 */ 0x04f01846 | (18 << 27) /* 0.308616899 */, + /* 4798 */ 0x04f07239 | (18 << 27) /* 0.308702682 */, + /* 4799 */ 0x04f0cc2e | (18 << 27) /* 0.308788472 */, + + /* 4800 */ 0x04f12624 | (18 << 27) /* 0.308874267 */, + /* 4801 */ 0x04f1801d | (18 << 27) /* 0.308960068 */, + /* 4802 */ 0x04f1da16 | (18 << 27) /* 0.309045876 */, + /* 4803 */ 0x04f23412 | (18 << 27) /* 0.309131689 */, + /* 4804 */ 0x04f28e0f | (18 << 27) /* 0.309217508 */, + /* 4805 */ 0x04f2e80d | (18 << 27) /* 0.309303334 */, + /* 4806 */ 0x04f3420d | (18 << 27) /* 0.309389165 */, + /* 4807 */ 0x04f39c0f | (18 << 27) /* 0.309475002 */, + /* 4808 */ 0x04f3f612 | (18 << 27) /* 0.309560845 */, + /* 4809 */ 0x04f45017 | (18 << 27) /* 0.309646694 */, + /* 4810 */ 0x04f4aa1e | (18 << 27) /* 0.309732549 */, + /* 4811 */ 0x04f50426 | (18 << 27) /* 0.309818410 */, + /* 4812 */ 0x04f55e30 | (18 << 27) /* 0.309904277 */, + /* 4813 */ 0x04f5b83b | (18 << 27) /* 0.309990150 */, + /* 4814 */ 0x04f61248 | (18 << 27) /* 0.310076028 */, + /* 4815 */ 0x04f66c56 | (18 << 27) /* 0.310161913 */, + + /* 4816 */ 0x04f6c666 | (18 << 27) /* 0.310247804 */, + /* 4817 */ 0x04f72078 | (18 << 27) /* 0.310333700 */, + /* 4818 */ 0x04f77a8b | (18 << 27) /* 0.310419603 */, + /* 4819 */ 0x04f7d4a0 | (18 << 27) /* 0.310505511 */, + /* 4820 */ 0x04f82eb7 | (18 << 27) /* 0.310591426 */, + /* 4821 */ 0x04f888cf | (18 << 27) /* 0.310677346 */, + /* 4822 */ 0x04f8e2e9 | (18 << 27) /* 0.310763272 */, + /* 4823 */ 0x04f93d04 | (18 << 27) /* 0.310849205 */, + /* 4824 */ 0x04f99721 | (18 << 27) /* 0.310935143 */, + /* 4825 */ 0x04f9f13f | (18 << 27) /* 0.311021087 */, + /* 4826 */ 0x04fa4b5f | (18 << 27) /* 0.311107037 */, + /* 4827 */ 0x04faa581 | (18 << 27) /* 0.311192993 */, + /* 4828 */ 0x04faffa4 | (18 << 27) /* 0.311278955 */, + /* 4829 */ 0x04fb59c9 | (18 << 27) /* 0.311364923 */, + /* 4830 */ 0x04fbb3ef | (18 << 27) /* 0.311450897 */, + /* 4831 */ 0x04fc0e17 | (18 << 27) /* 0.311536877 */, + + /* 4832 */ 0x04fc6841 | (18 << 27) /* 0.311622862 */, + /* 4833 */ 0x04fcc26c | (18 << 27) /* 0.311708854 */, + /* 4834 */ 0x04fd1c99 | (18 << 27) /* 0.311794851 */, + /* 4835 */ 0x04fd76c7 | (18 << 27) /* 0.311880855 */, + /* 4836 */ 0x04fdd0f7 | (18 << 27) /* 0.311966864 */, + /* 4837 */ 0x04fe2b29 | (18 << 27) /* 0.312052880 */, + /* 4838 */ 0x04fe855c | (18 << 27) /* 0.312138901 */, + /* 4839 */ 0x04fedf91 | (18 << 27) /* 0.312224928 */, + /* 4840 */ 0x04ff39c7 | (18 << 27) /* 0.312310961 */, + /* 4841 */ 0x04ff93ff | (18 << 27) /* 0.312397000 */, + /* 4842 */ 0x04ffee38 | (18 << 27) /* 0.312483045 */, + /* 4843 */ 0x05004874 | (18 << 27) /* 0.312569096 */, + /* 4844 */ 0x0500a2b0 | (18 << 27) /* 0.312655153 */, + /* 4845 */ 0x0500fcef | (18 << 27) /* 0.312741216 */, + /* 4846 */ 0x0501572e | (18 << 27) /* 0.312827284 */, + /* 4847 */ 0x0501b170 | (18 << 27) /* 0.312913359 */, + + /* 4848 */ 0x05020bb3 | (18 << 27) /* 0.312999439 */, + /* 4849 */ 0x050265f8 | (18 << 27) /* 0.313085526 */, + /* 4850 */ 0x0502c03e | (18 << 27) /* 0.313171618 */, + /* 4851 */ 0x05031a86 | (18 << 27) /* 0.313257716 */, + /* 4852 */ 0x050374cf | (18 << 27) /* 0.313343820 */, + /* 4853 */ 0x0503cf1a | (18 << 27) /* 0.313429931 */, + /* 4854 */ 0x05042967 | (18 << 27) /* 0.313516047 */, + /* 4855 */ 0x050483b5 | (18 << 27) /* 0.313602168 */, + /* 4856 */ 0x0504de05 | (18 << 27) /* 0.313688296 */, + /* 4857 */ 0x05053856 | (18 << 27) /* 0.313774430 */, + /* 4858 */ 0x050592a9 | (18 << 27) /* 0.313860570 */, + /* 4859 */ 0x0505ecfd | (18 << 27) /* 0.313946715 */, + /* 4860 */ 0x05064754 | (18 << 27) /* 0.314032867 */, + /* 4861 */ 0x0506a1ab | (18 << 27) /* 0.314119024 */, + /* 4862 */ 0x0506fc04 | (18 << 27) /* 0.314205187 */, + /* 4863 */ 0x0507565f | (18 << 27) /* 0.314291357 */, + + /* 4864 */ 0x0507b0bc | (18 << 27) /* 0.314377532 */, + /* 4865 */ 0x05080b1a | (18 << 27) /* 0.314463713 */, + /* 4866 */ 0x05086579 | (18 << 27) /* 0.314549900 */, + /* 4867 */ 0x0508bfdb | (18 << 27) /* 0.314636092 */, + /* 4868 */ 0x05091a3d | (18 << 27) /* 0.314722291 */, + /* 4869 */ 0x050974a2 | (18 << 27) /* 0.314808496 */, + /* 4870 */ 0x0509cf08 | (18 << 27) /* 0.314894706 */, + /* 4871 */ 0x050a296f | (18 << 27) /* 0.314980923 */, + /* 4872 */ 0x050a83d8 | (18 << 27) /* 0.315067145 */, + /* 4873 */ 0x050ade43 | (18 << 27) /* 0.315153373 */, + /* 4874 */ 0x050b38af | (18 << 27) /* 0.315239607 */, + /* 4875 */ 0x050b931d | (18 << 27) /* 0.315325847 */, + /* 4876 */ 0x050bed8d | (18 << 27) /* 0.315412093 */, + /* 4877 */ 0x050c47fe | (18 << 27) /* 0.315498345 */, + /* 4878 */ 0x050ca271 | (18 << 27) /* 0.315584603 */, + /* 4879 */ 0x050cfce5 | (18 << 27) /* 0.315670866 */, + + /* 4880 */ 0x050d575b | (18 << 27) /* 0.315757136 */, + /* 4881 */ 0x050db1d2 | (18 << 27) /* 0.315843411 */, + /* 4882 */ 0x050e0c4b | (18 << 27) /* 0.315929693 */, + /* 4883 */ 0x050e66c5 | (18 << 27) /* 0.316015980 */, + /* 4884 */ 0x050ec141 | (18 << 27) /* 0.316102273 */, + /* 4885 */ 0x050f1bbf | (18 << 27) /* 0.316188572 */, + /* 4886 */ 0x050f763e | (18 << 27) /* 0.316274877 */, + /* 4887 */ 0x050fd0bf | (18 << 27) /* 0.316361187 */, + /* 4888 */ 0x05102b42 | (18 << 27) /* 0.316447504 */, + /* 4889 */ 0x051085c6 | (18 << 27) /* 0.316533826 */, + /* 4890 */ 0x0510e04b | (18 << 27) /* 0.316620155 */, + /* 4891 */ 0x05113ad3 | (18 << 27) /* 0.316706489 */, + /* 4892 */ 0x0511955b | (18 << 27) /* 0.316792829 */, + /* 4893 */ 0x0511efe6 | (18 << 27) /* 0.316879175 */, + /* 4894 */ 0x05124a72 | (18 << 27) /* 0.316965527 */, + /* 4895 */ 0x0512a4ff | (18 << 27) /* 0.317051885 */, + + /* 4896 */ 0x0512ff8e | (18 << 27) /* 0.317138249 */, + /* 4897 */ 0x05135a1f | (18 << 27) /* 0.317224618 */, + /* 4898 */ 0x0513b4b1 | (18 << 27) /* 0.317310994 */, + /* 4899 */ 0x05140f45 | (18 << 27) /* 0.317397375 */, + /* 4900 */ 0x051469da | (18 << 27) /* 0.317483762 */, + /* 4901 */ 0x0514c471 | (18 << 27) /* 0.317570155 */, + /* 4902 */ 0x05151f0a | (18 << 27) /* 0.317656554 */, + /* 4903 */ 0x051579a4 | (18 << 27) /* 0.317742959 */, + /* 4904 */ 0x0515d440 | (18 << 27) /* 0.317829370 */, + /* 4905 */ 0x05162edd | (18 << 27) /* 0.317915786 */, + /* 4906 */ 0x0516897c | (18 << 27) /* 0.318002209 */, + /* 4907 */ 0x0516e41c | (18 << 27) /* 0.318088637 */, + /* 4908 */ 0x05173ebe | (18 << 27) /* 0.318175071 */, + /* 4909 */ 0x05179962 | (18 << 27) /* 0.318261511 */, + /* 4910 */ 0x0517f407 | (18 << 27) /* 0.318347957 */, + /* 4911 */ 0x05184eae | (18 << 27) /* 0.318434409 */, + + /* 4912 */ 0x0518a956 | (18 << 27) /* 0.318520867 */, + /* 4913 */ 0x05190400 | (18 << 27) /* 0.318607330 */, + /* 4914 */ 0x05195eab | (18 << 27) /* 0.318693800 */, + /* 4915 */ 0x0519b958 | (18 << 27) /* 0.318780275 */, + /* 4916 */ 0x051a1407 | (18 << 27) /* 0.318866756 */, + /* 4917 */ 0x051a6eb7 | (18 << 27) /* 0.318953243 */, + /* 4918 */ 0x051ac969 | (18 << 27) /* 0.319039736 */, + /* 4919 */ 0x051b241c | (18 << 27) /* 0.319126235 */, + /* 4920 */ 0x051b7ed1 | (18 << 27) /* 0.319212739 */, + /* 4921 */ 0x051bd987 | (18 << 27) /* 0.319299250 */, + /* 4922 */ 0x051c3440 | (18 << 27) /* 0.319385766 */, + /* 4923 */ 0x051c8ef9 | (18 << 27) /* 0.319472288 */, + /* 4924 */ 0x051ce9b4 | (18 << 27) /* 0.319558816 */, + /* 4925 */ 0x051d4471 | (18 << 27) /* 0.319645350 */, + /* 4926 */ 0x051d9f2f | (18 << 27) /* 0.319731890 */, + /* 4927 */ 0x051df9ef | (18 << 27) /* 0.319818435 */, + + /* 4928 */ 0x051e54b1 | (18 << 27) /* 0.319904987 */, + /* 4929 */ 0x051eaf74 | (18 << 27) /* 0.319991544 */, + /* 4930 */ 0x051f0a38 | (18 << 27) /* 0.320078107 */, + /* 4931 */ 0x051f64ff | (18 << 27) /* 0.320164676 */, + /* 4932 */ 0x051fbfc6 | (18 << 27) /* 0.320251251 */, + /* 4933 */ 0x05201a90 | (18 << 27) /* 0.320337832 */, + /* 4934 */ 0x0520755b | (18 << 27) /* 0.320424419 */, + /* 4935 */ 0x0520d027 | (18 << 27) /* 0.320511011 */, + /* 4936 */ 0x05212af5 | (18 << 27) /* 0.320597609 */, + /* 4937 */ 0x052185c5 | (18 << 27) /* 0.320684213 */, + /* 4938 */ 0x0521e096 | (18 << 27) /* 0.320770823 */, + /* 4939 */ 0x05223b69 | (18 << 27) /* 0.320857439 */, + /* 4940 */ 0x0522963d | (18 << 27) /* 0.320944061 */, + /* 4941 */ 0x0522f113 | (18 << 27) /* 0.321030688 */, + /* 4942 */ 0x05234bea | (18 << 27) /* 0.321117322 */, + /* 4943 */ 0x0523a6c3 | (18 << 27) /* 0.321203961 */, + + /* 4944 */ 0x0524019e | (18 << 27) /* 0.321290606 */, + /* 4945 */ 0x05245c7a | (18 << 27) /* 0.321377257 */, + /* 4946 */ 0x0524b758 | (18 << 27) /* 0.321463913 */, + /* 4947 */ 0x05251237 | (18 << 27) /* 0.321550576 */, + /* 4948 */ 0x05256d18 | (18 << 27) /* 0.321637244 */, + /* 4949 */ 0x0525c7fb | (18 << 27) /* 0.321723919 */, + /* 4950 */ 0x052622df | (18 << 27) /* 0.321810599 */, + /* 4951 */ 0x05267dc4 | (18 << 27) /* 0.321897285 */, + /* 4952 */ 0x0526d8ab | (18 << 27) /* 0.321983976 */, + /* 4953 */ 0x05273394 | (18 << 27) /* 0.322070674 */, + /* 4954 */ 0x05278e7e | (18 << 27) /* 0.322157377 */, + /* 4955 */ 0x0527e96a | (18 << 27) /* 0.322244087 */, + /* 4956 */ 0x05284457 | (18 << 27) /* 0.322330802 */, + /* 4957 */ 0x05289f46 | (18 << 27) /* 0.322417523 */, + /* 4958 */ 0x0528fa37 | (18 << 27) /* 0.322504249 */, + /* 4959 */ 0x05295529 | (18 << 27) /* 0.322590982 */, + + /* 4960 */ 0x0529b01d | (18 << 27) /* 0.322677720 */, + /* 4961 */ 0x052a0b12 | (18 << 27) /* 0.322764465 */, + /* 4962 */ 0x052a6609 | (18 << 27) /* 0.322851215 */, + /* 4963 */ 0x052ac101 | (18 << 27) /* 0.322937971 */, + /* 4964 */ 0x052b1bfb | (18 << 27) /* 0.323024732 */, + /* 4965 */ 0x052b76f7 | (18 << 27) /* 0.323111500 */, + /* 4966 */ 0x052bd1f4 | (18 << 27) /* 0.323198273 */, + /* 4967 */ 0x052c2cf2 | (18 << 27) /* 0.323285052 */, + /* 4968 */ 0x052c87f2 | (18 << 27) /* 0.323371837 */, + /* 4969 */ 0x052ce2f4 | (18 << 27) /* 0.323458628 */, + /* 4970 */ 0x052d3df7 | (18 << 27) /* 0.323545425 */, + /* 4971 */ 0x052d98fc | (18 << 27) /* 0.323632227 */, + /* 4972 */ 0x052df403 | (18 << 27) /* 0.323719036 */, + /* 4973 */ 0x052e4f0b | (18 << 27) /* 0.323805850 */, + /* 4974 */ 0x052eaa14 | (18 << 27) /* 0.323892670 */, + /* 4975 */ 0x052f051f | (18 << 27) /* 0.323979496 */, + + /* 4976 */ 0x052f602c | (18 << 27) /* 0.324066327 */, + /* 4977 */ 0x052fbb3a | (18 << 27) /* 0.324153165 */, + /* 4978 */ 0x0530164a | (18 << 27) /* 0.324240008 */, + /* 4979 */ 0x0530715b | (18 << 27) /* 0.324326857 */, + /* 4980 */ 0x0530cc6e | (18 << 27) /* 0.324413712 */, + /* 4981 */ 0x05312783 | (18 << 27) /* 0.324500572 */, + /* 4982 */ 0x05318299 | (18 << 27) /* 0.324587439 */, + /* 4983 */ 0x0531ddb0 | (18 << 27) /* 0.324674311 */, + /* 4984 */ 0x053238ca | (18 << 27) /* 0.324761189 */, + /* 4985 */ 0x053293e4 | (18 << 27) /* 0.324848073 */, + /* 4986 */ 0x0532ef01 | (18 << 27) /* 0.324934963 */, + /* 4987 */ 0x05334a1e | (18 << 27) /* 0.325021858 */, + /* 4988 */ 0x0533a53e | (18 << 27) /* 0.325108760 */, + /* 4989 */ 0x0534005f | (18 << 27) /* 0.325195667 */, + /* 4990 */ 0x05345b81 | (18 << 27) /* 0.325282580 */, + /* 4991 */ 0x0534b6a5 | (18 << 27) /* 0.325369498 */, + + /* 4992 */ 0x053511cb | (18 << 27) /* 0.325456423 */, + /* 4993 */ 0x05356cf2 | (18 << 27) /* 0.325543353 */, + /* 4994 */ 0x0535c81b | (18 << 27) /* 0.325630290 */, + /* 4995 */ 0x05362345 | (18 << 27) /* 0.325717232 */, + /* 4996 */ 0x05367e71 | (18 << 27) /* 0.325804179 */, + /* 4997 */ 0x0536d99f | (18 << 27) /* 0.325891133 */, + /* 4998 */ 0x053734ce | (18 << 27) /* 0.325978092 */, + /* 4999 */ 0x05378ffe | (18 << 27) /* 0.326065057 */, + /* 5000 */ 0x0537eb30 | (18 << 27) /* 0.326152028 */, + /* 5001 */ 0x05384664 | (18 << 27) /* 0.326239005 */, + /* 5002 */ 0x0538a199 | (18 << 27) /* 0.326325988 */, + /* 5003 */ 0x0538fcd0 | (18 << 27) /* 0.326412976 */, + /* 5004 */ 0x05395808 | (18 << 27) /* 0.326499970 */, + /* 5005 */ 0x0539b342 | (18 << 27) /* 0.326586970 */, + /* 5006 */ 0x053a0e7d | (18 << 27) /* 0.326673976 */, + /* 5007 */ 0x053a69ba | (18 << 27) /* 0.326760988 */, + + /* 5008 */ 0x053ac4f9 | (18 << 27) /* 0.326848005 */, + /* 5009 */ 0x053b2039 | (18 << 27) /* 0.326935028 */, + /* 5010 */ 0x053b7b7b | (18 << 27) /* 0.327022057 */, + /* 5011 */ 0x053bd6be | (18 << 27) /* 0.327109092 */, + /* 5012 */ 0x053c3203 | (18 << 27) /* 0.327196132 */, + /* 5013 */ 0x053c8d49 | (18 << 27) /* 0.327283178 */, + /* 5014 */ 0x053ce891 | (18 << 27) /* 0.327370231 */, + /* 5015 */ 0x053d43da | (18 << 27) /* 0.327457288 */, + /* 5016 */ 0x053d9f25 | (18 << 27) /* 0.327544352 */, + /* 5017 */ 0x053dfa72 | (18 << 27) /* 0.327631421 */, + /* 5018 */ 0x053e55c0 | (18 << 27) /* 0.327718497 */, + /* 5019 */ 0x053eb10f | (18 << 27) /* 0.327805578 */, + /* 5020 */ 0x053f0c61 | (18 << 27) /* 0.327892665 */, + /* 5021 */ 0x053f67b3 | (18 << 27) /* 0.327979757 */, + /* 5022 */ 0x053fc308 | (18 << 27) /* 0.328066855 */, + /* 5023 */ 0x05401e5e | (18 << 27) /* 0.328153960 */, + + /* 5024 */ 0x054079b5 | (18 << 27) /* 0.328241070 */, + /* 5025 */ 0x0540d50e | (18 << 27) /* 0.328328185 */, + /* 5026 */ 0x05413068 | (18 << 27) /* 0.328415307 */, + /* 5027 */ 0x05418bc4 | (18 << 27) /* 0.328502434 */, + /* 5028 */ 0x0541e722 | (18 << 27) /* 0.328589567 */, + /* 5029 */ 0x05424281 | (18 << 27) /* 0.328676706 */, + /* 5030 */ 0x05429de2 | (18 << 27) /* 0.328763850 */, + /* 5031 */ 0x0542f944 | (18 << 27) /* 0.328851001 */, + /* 5032 */ 0x054354a8 | (18 << 27) /* 0.328938157 */, + /* 5033 */ 0x0543b00d | (18 << 27) /* 0.329025319 */, + /* 5034 */ 0x05440b74 | (18 << 27) /* 0.329112486 */, + /* 5035 */ 0x054466dd | (18 << 27) /* 0.329199660 */, + /* 5036 */ 0x0544c247 | (18 << 27) /* 0.329286839 */, + /* 5037 */ 0x05451db2 | (18 << 27) /* 0.329374024 */, + /* 5038 */ 0x0545791f | (18 << 27) /* 0.329461215 */, + /* 5039 */ 0x0545d48e | (18 << 27) /* 0.329548411 */, + + /* 5040 */ 0x05462ffe | (18 << 27) /* 0.329635614 */, + /* 5041 */ 0x05468b70 | (18 << 27) /* 0.329722822 */, + /* 5042 */ 0x0546e6e3 | (18 << 27) /* 0.329810036 */, + /* 5043 */ 0x05474258 | (18 << 27) /* 0.329897255 */, + /* 5044 */ 0x05479dce | (18 << 27) /* 0.329984481 */, + /* 5045 */ 0x0547f946 | (18 << 27) /* 0.330071712 */, + /* 5046 */ 0x054854c0 | (18 << 27) /* 0.330158949 */, + /* 5047 */ 0x0548b03b | (18 << 27) /* 0.330246191 */, + /* 5048 */ 0x05490bb7 | (18 << 27) /* 0.330333440 */, + /* 5049 */ 0x05496735 | (18 << 27) /* 0.330420694 */, + /* 5050 */ 0x0549c2b5 | (18 << 27) /* 0.330507954 */, + /* 5051 */ 0x054a1e36 | (18 << 27) /* 0.330595220 */, + /* 5052 */ 0x054a79b9 | (18 << 27) /* 0.330682491 */, + /* 5053 */ 0x054ad53d | (18 << 27) /* 0.330769768 */, + /* 5054 */ 0x054b30c3 | (18 << 27) /* 0.330857051 */, + /* 5055 */ 0x054b8c4b | (18 << 27) /* 0.330944340 */, + + /* 5056 */ 0x054be7d4 | (18 << 27) /* 0.331031635 */, + /* 5057 */ 0x054c435e | (18 << 27) /* 0.331118935 */, + /* 5058 */ 0x054c9eea | (18 << 27) /* 0.331206241 */, + /* 5059 */ 0x054cfa78 | (18 << 27) /* 0.331293553 */, + /* 5060 */ 0x054d5607 | (18 << 27) /* 0.331380870 */, + /* 5061 */ 0x054db197 | (18 << 27) /* 0.331468193 */, + /* 5062 */ 0x054e0d2a | (18 << 27) /* 0.331555522 */, + /* 5063 */ 0x054e68bd | (18 << 27) /* 0.331642857 */, + /* 5064 */ 0x054ec453 | (18 << 27) /* 0.331730198 */, + /* 5065 */ 0x054f1fe9 | (18 << 27) /* 0.331817544 */, + /* 5066 */ 0x054f7b82 | (18 << 27) /* 0.331904896 */, + /* 5067 */ 0x054fd71c | (18 << 27) /* 0.331992254 */, + /* 5068 */ 0x055032b7 | (18 << 27) /* 0.332079617 */, + /* 5069 */ 0x05508e54 | (18 << 27) /* 0.332166986 */, + /* 5070 */ 0x0550e9f3 | (18 << 27) /* 0.332254361 */, + /* 5071 */ 0x05514593 | (18 << 27) /* 0.332341742 */, + + /* 5072 */ 0x0551a134 | (18 << 27) /* 0.332429129 */, + /* 5073 */ 0x0551fcd8 | (18 << 27) /* 0.332516521 */, + /* 5074 */ 0x0552587c | (18 << 27) /* 0.332603919 */, + /* 5075 */ 0x0552b423 | (18 << 27) /* 0.332691323 */, + /* 5076 */ 0x05530fca | (18 << 27) /* 0.332778732 */, + /* 5077 */ 0x05536b74 | (18 << 27) /* 0.332866147 */, + /* 5078 */ 0x0553c71f | (18 << 27) /* 0.332953568 */, + /* 5079 */ 0x055422cb | (18 << 27) /* 0.333040995 */, + /* 5080 */ 0x05547e79 | (18 << 27) /* 0.333128427 */, + /* 5081 */ 0x0554da29 | (18 << 27) /* 0.333215865 */, + /* 5082 */ 0x055535da | (18 << 27) /* 0.333303309 */, + /* 5083 */ 0x0555918c | (18 << 27) /* 0.333390759 */, + /* 5084 */ 0x0555ed40 | (18 << 27) /* 0.333478214 */, + /* 5085 */ 0x055648f6 | (18 << 27) /* 0.333565675 */, + /* 5086 */ 0x0556a4ad | (18 << 27) /* 0.333653142 */, + /* 5087 */ 0x05570066 | (18 << 27) /* 0.333740615 */, + + /* 5088 */ 0x05575c20 | (18 << 27) /* 0.333828093 */, + /* 5089 */ 0x0557b7dc | (18 << 27) /* 0.333915577 */, + /* 5090 */ 0x05581399 | (18 << 27) /* 0.334003067 */, + /* 5091 */ 0x05586f58 | (18 << 27) /* 0.334090562 */, + /* 5092 */ 0x0558cb19 | (18 << 27) /* 0.334178063 */, + /* 5093 */ 0x055926db | (18 << 27) /* 0.334265570 */, + /* 5094 */ 0x0559829e | (18 << 27) /* 0.334353083 */, + /* 5095 */ 0x0559de63 | (18 << 27) /* 0.334440601 */, + /* 5096 */ 0x055a3a2a | (18 << 27) /* 0.334528126 */, + /* 5097 */ 0x055a95f2 | (18 << 27) /* 0.334615655 */, + /* 5098 */ 0x055af1bb | (18 << 27) /* 0.334703191 */, + /* 5099 */ 0x055b4d87 | (18 << 27) /* 0.334790732 */, + /* 5100 */ 0x055ba953 | (18 << 27) /* 0.334878279 */, + /* 5101 */ 0x055c0522 | (18 << 27) /* 0.334965832 */, + /* 5102 */ 0x055c60f1 | (18 << 27) /* 0.335053391 */, + /* 5103 */ 0x055cbcc3 | (18 << 27) /* 0.335140955 */, + + /* 5104 */ 0x055d1896 | (18 << 27) /* 0.335228525 */, + /* 5105 */ 0x055d746a | (18 << 27) /* 0.335316100 */, + /* 5106 */ 0x055dd040 | (18 << 27) /* 0.335403682 */, + /* 5107 */ 0x055e2c17 | (18 << 27) /* 0.335491269 */, + /* 5108 */ 0x055e87f0 | (18 << 27) /* 0.335578861 */, + /* 5109 */ 0x055ee3cb | (18 << 27) /* 0.335666460 */, + /* 5110 */ 0x055f3fa7 | (18 << 27) /* 0.335754064 */, + /* 5111 */ 0x055f9b85 | (18 << 27) /* 0.335841674 */, + /* 5112 */ 0x055ff764 | (18 << 27) /* 0.335929290 */, + /* 5113 */ 0x05605344 | (18 << 27) /* 0.336016911 */, + /* 5114 */ 0x0560af27 | (18 << 27) /* 0.336104538 */, + /* 5115 */ 0x05610b0a | (18 << 27) /* 0.336192171 */, + /* 5116 */ 0x056166f0 | (18 << 27) /* 0.336279809 */, + /* 5117 */ 0x0561c2d7 | (18 << 27) /* 0.336367453 */, + /* 5118 */ 0x05621ebf | (18 << 27) /* 0.336455103 */, + /* 5119 */ 0x05627aa9 | (18 << 27) /* 0.336542759 */, + + /* 5120 */ 0x0562d694 | (18 << 27) /* 0.336630420 */, + /* 5121 */ 0x05633281 | (18 << 27) /* 0.336718087 */, + /* 5122 */ 0x05638e70 | (18 << 27) /* 0.336805760 */, + /* 5123 */ 0x0563ea60 | (18 << 27) /* 0.336893439 */, + /* 5124 */ 0x05644651 | (18 << 27) /* 0.336981123 */, + /* 5125 */ 0x0564a244 | (18 << 27) /* 0.337068813 */, + /* 5126 */ 0x0564fe39 | (18 << 27) /* 0.337156508 */, + /* 5127 */ 0x05655a2f | (18 << 27) /* 0.337244209 */, + /* 5128 */ 0x0565b627 | (18 << 27) /* 0.337331916 */, + /* 5129 */ 0x05661220 | (18 << 27) /* 0.337419629 */, + /* 5130 */ 0x05666e1a | (18 << 27) /* 0.337507347 */, + /* 5131 */ 0x0566ca17 | (18 << 27) /* 0.337595071 */, + /* 5132 */ 0x05672614 | (18 << 27) /* 0.337682801 */, + /* 5133 */ 0x05678214 | (18 << 27) /* 0.337770537 */, + /* 5134 */ 0x0567de15 | (18 << 27) /* 0.337858278 */, + /* 5135 */ 0x05683a17 | (18 << 27) /* 0.337946025 */, + + /* 5136 */ 0x0568961b | (18 << 27) /* 0.338033777 */, + /* 5137 */ 0x0568f220 | (18 << 27) /* 0.338121535 */, + /* 5138 */ 0x05694e27 | (18 << 27) /* 0.338209299 */, + /* 5139 */ 0x0569aa30 | (18 << 27) /* 0.338297069 */, + /* 5140 */ 0x056a063a | (18 << 27) /* 0.338384844 */, + /* 5141 */ 0x056a6245 | (18 << 27) /* 0.338472625 */, + /* 5142 */ 0x056abe52 | (18 << 27) /* 0.338560412 */, + /* 5143 */ 0x056b1a61 | (18 << 27) /* 0.338648204 */, + /* 5144 */ 0x056b7671 | (18 << 27) /* 0.338736002 */, + /* 5145 */ 0x056bd283 | (18 << 27) /* 0.338823806 */, + /* 5146 */ 0x056c2e96 | (18 << 27) /* 0.338911616 */, + /* 5147 */ 0x056c8aab | (18 << 27) /* 0.338999431 */, + /* 5148 */ 0x056ce6c1 | (18 << 27) /* 0.339087252 */, + /* 5149 */ 0x056d42d9 | (18 << 27) /* 0.339175078 */, + /* 5150 */ 0x056d9ef2 | (18 << 27) /* 0.339262910 */, + /* 5151 */ 0x056dfb0d | (18 << 27) /* 0.339350748 */, + + /* 5152 */ 0x056e5729 | (18 << 27) /* 0.339438592 */, + /* 5153 */ 0x056eb347 | (18 << 27) /* 0.339526441 */, + /* 5154 */ 0x056f0f66 | (18 << 27) /* 0.339614296 */, + /* 5155 */ 0x056f6b87 | (18 << 27) /* 0.339702157 */, + /* 5156 */ 0x056fc7aa | (18 << 27) /* 0.339790023 */, + /* 5157 */ 0x057023cd | (18 << 27) /* 0.339877895 */, + /* 5158 */ 0x05707ff3 | (18 << 27) /* 0.339965773 */, + /* 5159 */ 0x0570dc1a | (18 << 27) /* 0.340053656 */, + /* 5160 */ 0x05713843 | (18 << 27) /* 0.340141545 */, + /* 5161 */ 0x0571946d | (18 << 27) /* 0.340229440 */, + /* 5162 */ 0x0571f098 | (18 << 27) /* 0.340317340 */, + /* 5163 */ 0x05724cc5 | (18 << 27) /* 0.340405246 */, + /* 5164 */ 0x0572a8f4 | (18 << 27) /* 0.340493158 */, + /* 5165 */ 0x05730524 | (18 << 27) /* 0.340581075 */, + /* 5166 */ 0x05736156 | (18 << 27) /* 0.340668999 */, + /* 5167 */ 0x0573bd89 | (18 << 27) /* 0.340756927 */, + + /* 5168 */ 0x057419be | (18 << 27) /* 0.340844862 */, + /* 5169 */ 0x057475f4 | (18 << 27) /* 0.340932802 */, + /* 5170 */ 0x0574d22c | (18 << 27) /* 0.341020748 */, + /* 5171 */ 0x05752e65 | (18 << 27) /* 0.341108699 */, + /* 5172 */ 0x05758aa0 | (18 << 27) /* 0.341196656 */, + /* 5173 */ 0x0575e6dc | (18 << 27) /* 0.341284619 */, + /* 5174 */ 0x0576431a | (18 << 27) /* 0.341372587 */, + /* 5175 */ 0x05769f59 | (18 << 27) /* 0.341460562 */, + /* 5176 */ 0x0576fb9a | (18 << 27) /* 0.341548541 */, + /* 5177 */ 0x057757dd | (18 << 27) /* 0.341636527 */, + /* 5178 */ 0x0577b421 | (18 << 27) /* 0.341724518 */, + /* 5179 */ 0x05781066 | (18 << 27) /* 0.341812515 */, + /* 5180 */ 0x05786cad | (18 << 27) /* 0.341900517 */, + /* 5181 */ 0x0578c8f5 | (18 << 27) /* 0.341988525 */, + /* 5182 */ 0x0579253f | (18 << 27) /* 0.342076539 */, + /* 5183 */ 0x0579818b | (18 << 27) /* 0.342164558 */, + + /* 5184 */ 0x0579ddd8 | (18 << 27) /* 0.342252584 */, + /* 5185 */ 0x057a3a27 | (18 << 27) /* 0.342340614 */, + /* 5186 */ 0x057a9677 | (18 << 27) /* 0.342428651 */, + /* 5187 */ 0x057af2c8 | (18 << 27) /* 0.342516693 */, + /* 5188 */ 0x057b4f1c | (18 << 27) /* 0.342604741 */, + /* 5189 */ 0x057bab70 | (18 << 27) /* 0.342692794 */, + /* 5190 */ 0x057c07c6 | (18 << 27) /* 0.342780853 */, + /* 5191 */ 0x057c641e | (18 << 27) /* 0.342868918 */, + /* 5192 */ 0x057cc077 | (18 << 27) /* 0.342956988 */, + /* 5193 */ 0x057d1cd2 | (18 << 27) /* 0.343045064 */, + /* 5194 */ 0x057d792e | (18 << 27) /* 0.343133146 */, + /* 5195 */ 0x057dd58c | (18 << 27) /* 0.343221233 */, + /* 5196 */ 0x057e31eb | (18 << 27) /* 0.343309326 */, + /* 5197 */ 0x057e8e4c | (18 << 27) /* 0.343397425 */, + /* 5198 */ 0x057eeaae | (18 << 27) /* 0.343485529 */, + /* 5199 */ 0x057f4712 | (18 << 27) /* 0.343573639 */, + + /* 5200 */ 0x057fa378 | (18 << 27) /* 0.343661754 */, + /* 5201 */ 0x057fffde | (18 << 27) /* 0.343749876 */, + /* 5202 */ 0x05805c47 | (18 << 27) /* 0.343838003 */, + /* 5203 */ 0x0580b8b1 | (18 << 27) /* 0.343926135 */, + /* 5204 */ 0x0581151c | (18 << 27) /* 0.344014273 */, + /* 5205 */ 0x05817189 | (18 << 27) /* 0.344102417 */, + /* 5206 */ 0x0581cdf7 | (18 << 27) /* 0.344190566 */, + /* 5207 */ 0x05822a67 | (18 << 27) /* 0.344278722 */, + /* 5208 */ 0x058286d9 | (18 << 27) /* 0.344366882 */, + /* 5209 */ 0x0582e34c | (18 << 27) /* 0.344455049 */, + /* 5210 */ 0x05833fc0 | (18 << 27) /* 0.344543221 */, + /* 5211 */ 0x05839c36 | (18 << 27) /* 0.344631398 */, + /* 5212 */ 0x0583f8ae | (18 << 27) /* 0.344719582 */, + /* 5213 */ 0x05845527 | (18 << 27) /* 0.344807771 */, + /* 5214 */ 0x0584b1a1 | (18 << 27) /* 0.344895965 */, + /* 5215 */ 0x05850e1e | (18 << 27) /* 0.344984165 */, + + /* 5216 */ 0x05856a9b | (18 << 27) /* 0.345072371 */, + /* 5217 */ 0x0585c71a | (18 << 27) /* 0.345160583 */, + /* 5218 */ 0x0586239b | (18 << 27) /* 0.345248800 */, + /* 5219 */ 0x0586801d | (18 << 27) /* 0.345337023 */, + /* 5220 */ 0x0586dca1 | (18 << 27) /* 0.345425251 */, + /* 5221 */ 0x05873926 | (18 << 27) /* 0.345513485 */, + /* 5222 */ 0x058795ac | (18 << 27) /* 0.345601725 */, + /* 5223 */ 0x0587f235 | (18 << 27) /* 0.345689970 */, + /* 5224 */ 0x05884ebe | (18 << 27) /* 0.345778221 */, + /* 5225 */ 0x0588ab49 | (18 << 27) /* 0.345866478 */, + /* 5226 */ 0x058907d6 | (18 << 27) /* 0.345954740 */, + /* 5227 */ 0x05896464 | (18 << 27) /* 0.346043008 */, + /* 5228 */ 0x0589c0f4 | (18 << 27) /* 0.346131281 */, + /* 5229 */ 0x058a1d85 | (18 << 27) /* 0.346219560 */, + /* 5230 */ 0x058a7a18 | (18 << 27) /* 0.346307845 */, + /* 5231 */ 0x058ad6ac | (18 << 27) /* 0.346396135 */, + + /* 5232 */ 0x058b3342 | (18 << 27) /* 0.346484431 */, + /* 5233 */ 0x058b8fd9 | (18 << 27) /* 0.346572733 */, + /* 5234 */ 0x058bec72 | (18 << 27) /* 0.346661040 */, + /* 5235 */ 0x058c490c | (18 << 27) /* 0.346749353 */, + /* 5236 */ 0x058ca5a8 | (18 << 27) /* 0.346837671 */, + /* 5237 */ 0x058d0246 | (18 << 27) /* 0.346925996 */, + /* 5238 */ 0x058d5ee4 | (18 << 27) /* 0.347014325 */, + /* 5239 */ 0x058dbb85 | (18 << 27) /* 0.347102661 */, + /* 5240 */ 0x058e1827 | (18 << 27) /* 0.347191002 */, + /* 5241 */ 0x058e74ca | (18 << 27) /* 0.347279348 */, + /* 5242 */ 0x058ed16f | (18 << 27) /* 0.347367700 */, + /* 5243 */ 0x058f2e15 | (18 << 27) /* 0.347456058 */, + /* 5244 */ 0x058f8abd | (18 << 27) /* 0.347544422 */, + /* 5245 */ 0x058fe766 | (18 << 27) /* 0.347632791 */, + /* 5246 */ 0x05904411 | (18 << 27) /* 0.347721165 */, + /* 5247 */ 0x0590a0be | (18 << 27) /* 0.347809546 */, + + /* 5248 */ 0x0590fd6c | (18 << 27) /* 0.347897931 */, + /* 5249 */ 0x05915a1b | (18 << 27) /* 0.347986323 */, + /* 5250 */ 0x0591b6cc | (18 << 27) /* 0.348074720 */, + /* 5251 */ 0x0592137e | (18 << 27) /* 0.348163123 */, + /* 5252 */ 0x05927032 | (18 << 27) /* 0.348251531 */, + /* 5253 */ 0x0592cce8 | (18 << 27) /* 0.348339945 */, + /* 5254 */ 0x0593299f | (18 << 27) /* 0.348428365 */, + /* 5255 */ 0x05938657 | (18 << 27) /* 0.348516790 */, + /* 5256 */ 0x0593e311 | (18 << 27) /* 0.348605221 */, + /* 5257 */ 0x05943fcd | (18 << 27) /* 0.348693657 */, + /* 5258 */ 0x05949c8a | (18 << 27) /* 0.348782099 */, + /* 5259 */ 0x0594f948 | (18 << 27) /* 0.348870547 */, + /* 5260 */ 0x05955608 | (18 << 27) /* 0.348959000 */, + /* 5261 */ 0x0595b2ca | (18 << 27) /* 0.349047459 */, + /* 5262 */ 0x05960f8c | (18 << 27) /* 0.349135923 */, + /* 5263 */ 0x05966c51 | (18 << 27) /* 0.349224393 */, + + /* 5264 */ 0x0596c917 | (18 << 27) /* 0.349312869 */, + /* 5265 */ 0x059725de | (18 << 27) /* 0.349401350 */, + /* 5266 */ 0x059782a7 | (18 << 27) /* 0.349489837 */, + /* 5267 */ 0x0597df72 | (18 << 27) /* 0.349578329 */, + /* 5268 */ 0x05983c3e | (18 << 27) /* 0.349666827 */, + /* 5269 */ 0x0598990c | (18 << 27) /* 0.349755331 */, + /* 5270 */ 0x0598f5db | (18 << 27) /* 0.349843840 */, + /* 5271 */ 0x059952ab | (18 << 27) /* 0.349932355 */, + /* 5272 */ 0x0599af7d | (18 << 27) /* 0.350020876 */, + /* 5273 */ 0x059a0c51 | (18 << 27) /* 0.350109402 */, + /* 5274 */ 0x059a6926 | (18 << 27) /* 0.350197933 */, + /* 5275 */ 0x059ac5fc | (18 << 27) /* 0.350286470 */, + /* 5276 */ 0x059b22d4 | (18 << 27) /* 0.350375013 */, + /* 5277 */ 0x059b7fae | (18 << 27) /* 0.350463562 */, + /* 5278 */ 0x059bdc89 | (18 << 27) /* 0.350552116 */, + /* 5279 */ 0x059c3965 | (18 << 27) /* 0.350640675 */, + + /* 5280 */ 0x059c9643 | (18 << 27) /* 0.350729240 */, + /* 5281 */ 0x059cf323 | (18 << 27) /* 0.350817811 */, + /* 5282 */ 0x059d5004 | (18 << 27) /* 0.350906388 */, + /* 5283 */ 0x059dace6 | (18 << 27) /* 0.350994970 */, + /* 5284 */ 0x059e09cb | (18 << 27) /* 0.351083557 */, + /* 5285 */ 0x059e66b0 | (18 << 27) /* 0.351172150 */, + /* 5286 */ 0x059ec397 | (18 << 27) /* 0.351260749 */, + /* 5287 */ 0x059f2080 | (18 << 27) /* 0.351349353 */, + /* 5288 */ 0x059f7d6a | (18 << 27) /* 0.351437963 */, + /* 5289 */ 0x059fda55 | (18 << 27) /* 0.351526579 */, + /* 5290 */ 0x05a03742 | (18 << 27) /* 0.351615200 */, + /* 5291 */ 0x05a09431 | (18 << 27) /* 0.351703827 */, + /* 5292 */ 0x05a0f121 | (18 << 27) /* 0.351792459 */, + /* 5293 */ 0x05a14e12 | (18 << 27) /* 0.351881097 */, + /* 5294 */ 0x05a1ab05 | (18 << 27) /* 0.351969740 */, + /* 5295 */ 0x05a207fa | (18 << 27) /* 0.352058389 */, + + /* 5296 */ 0x05a264f0 | (18 << 27) /* 0.352147044 */, + /* 5297 */ 0x05a2c1e7 | (18 << 27) /* 0.352235704 */, + /* 5298 */ 0x05a31ee1 | (18 << 27) /* 0.352324369 */, + /* 5299 */ 0x05a37bdb | (18 << 27) /* 0.352413041 */, + /* 5300 */ 0x05a3d8d7 | (18 << 27) /* 0.352501718 */, + /* 5301 */ 0x05a435d5 | (18 << 27) /* 0.352590400 */, + /* 5302 */ 0x05a492d4 | (18 << 27) /* 0.352679088 */, + /* 5303 */ 0x05a4efd4 | (18 << 27) /* 0.352767782 */, + /* 5304 */ 0x05a54cd6 | (18 << 27) /* 0.352856481 */, + /* 5305 */ 0x05a5a9da | (18 << 27) /* 0.352945186 */, + /* 5306 */ 0x05a606df | (18 << 27) /* 0.353033896 */, + /* 5307 */ 0x05a663e5 | (18 << 27) /* 0.353122612 */, + /* 5308 */ 0x05a6c0ed | (18 << 27) /* 0.353211333 */, + /* 5309 */ 0x05a71df7 | (18 << 27) /* 0.353300061 */, + /* 5310 */ 0x05a77b02 | (18 << 27) /* 0.353388793 */, + /* 5311 */ 0x05a7d80e | (18 << 27) /* 0.353477531 */, + + /* 5312 */ 0x05a8351c | (18 << 27) /* 0.353566275 */, + /* 5313 */ 0x05a8922c | (18 << 27) /* 0.353655024 */, + /* 5314 */ 0x05a8ef3c | (18 << 27) /* 0.353743779 */, + /* 5315 */ 0x05a94c4f | (18 << 27) /* 0.353832540 */, + /* 5316 */ 0x05a9a963 | (18 << 27) /* 0.353921306 */, + /* 5317 */ 0x05aa0678 | (18 << 27) /* 0.354010077 */, + /* 5318 */ 0x05aa638f | (18 << 27) /* 0.354098855 */, + /* 5319 */ 0x05aac0a8 | (18 << 27) /* 0.354187637 */, + /* 5320 */ 0x05ab1dc2 | (18 << 27) /* 0.354276426 */, + /* 5321 */ 0x05ab7add | (18 << 27) /* 0.354365220 */, + /* 5322 */ 0x05abd7fa | (18 << 27) /* 0.354454019 */, + /* 5323 */ 0x05ac3518 | (18 << 27) /* 0.354542824 */, + /* 5324 */ 0x05ac9238 | (18 << 27) /* 0.354631635 */, + /* 5325 */ 0x05acef5a | (18 << 27) /* 0.354720451 */, + /* 5326 */ 0x05ad4c7d | (18 << 27) /* 0.354809272 */, + /* 5327 */ 0x05ada9a1 | (18 << 27) /* 0.354898100 */, + + /* 5328 */ 0x05ae06c7 | (18 << 27) /* 0.354986932 */, + /* 5329 */ 0x05ae63ee | (18 << 27) /* 0.355075771 */, + /* 5330 */ 0x05aec117 | (18 << 27) /* 0.355164615 */, + /* 5331 */ 0x05af1e41 | (18 << 27) /* 0.355253464 */, + /* 5332 */ 0x05af7b6d | (18 << 27) /* 0.355342319 */, + /* 5333 */ 0x05afd89b | (18 << 27) /* 0.355431180 */, + /* 5334 */ 0x05b035c9 | (18 << 27) /* 0.355520046 */, + /* 5335 */ 0x05b092fa | (18 << 27) /* 0.355608917 */, + /* 5336 */ 0x05b0f02b | (18 << 27) /* 0.355697795 */, + /* 5337 */ 0x05b14d5f | (18 << 27) /* 0.355786677 */, + /* 5338 */ 0x05b1aa94 | (18 << 27) /* 0.355875566 */, + /* 5339 */ 0x05b207ca | (18 << 27) /* 0.355964460 */, + /* 5340 */ 0x05b26502 | (18 << 27) /* 0.356053359 */, + /* 5341 */ 0x05b2c23b | (18 << 27) /* 0.356142264 */, + /* 5342 */ 0x05b31f76 | (18 << 27) /* 0.356231175 */, + /* 5343 */ 0x05b37cb2 | (18 << 27) /* 0.356320091 */, + + /* 5344 */ 0x05b3d9f0 | (18 << 27) /* 0.356409012 */, + /* 5345 */ 0x05b4372f | (18 << 27) /* 0.356497940 */, + /* 5346 */ 0x05b4946f | (18 << 27) /* 0.356586872 */, + /* 5347 */ 0x05b4f1b2 | (18 << 27) /* 0.356675811 */, + /* 5348 */ 0x05b54ef5 | (18 << 27) /* 0.356764754 */, + /* 5349 */ 0x05b5ac3a | (18 << 27) /* 0.356853704 */, + /* 5350 */ 0x05b60981 | (18 << 27) /* 0.356942659 */, + /* 5351 */ 0x05b666c9 | (18 << 27) /* 0.357031619 */, + /* 5352 */ 0x05b6c413 | (18 << 27) /* 0.357120585 */, + /* 5353 */ 0x05b7215e | (18 << 27) /* 0.357209557 */, + /* 5354 */ 0x05b77eab | (18 << 27) /* 0.357298534 */, + /* 5355 */ 0x05b7dbf9 | (18 << 27) /* 0.357387516 */, + /* 5356 */ 0x05b83948 | (18 << 27) /* 0.357476504 */, + /* 5357 */ 0x05b89699 | (18 << 27) /* 0.357565498 */, + /* 5358 */ 0x05b8f3ec | (18 << 27) /* 0.357654497 */, + /* 5359 */ 0x05b95140 | (18 << 27) /* 0.357743502 */, + + /* 5360 */ 0x05b9ae95 | (18 << 27) /* 0.357832512 */, + /* 5361 */ 0x05ba0bec | (18 << 27) /* 0.357921528 */, + /* 5362 */ 0x05ba6945 | (18 << 27) /* 0.358010550 */, + /* 5363 */ 0x05bac69f | (18 << 27) /* 0.358099576 */, + /* 5364 */ 0x05bb23fa | (18 << 27) /* 0.358188609 */, + /* 5365 */ 0x05bb8157 | (18 << 27) /* 0.358277647 */, + /* 5366 */ 0x05bbdeb6 | (18 << 27) /* 0.358366690 */, + /* 5367 */ 0x05bc3c16 | (18 << 27) /* 0.358455739 */, + /* 5368 */ 0x05bc9977 | (18 << 27) /* 0.358544794 */, + /* 5369 */ 0x05bcf6da | (18 << 27) /* 0.358633854 */, + /* 5370 */ 0x05bd543e | (18 << 27) /* 0.358722920 */, + /* 5371 */ 0x05bdb1a4 | (18 << 27) /* 0.358811991 */, + /* 5372 */ 0x05be0f0b | (18 << 27) /* 0.358901067 */, + /* 5373 */ 0x05be6c74 | (18 << 27) /* 0.358990150 */, + /* 5374 */ 0x05bec9df | (18 << 27) /* 0.359079237 */, + /* 5375 */ 0x05bf274a | (18 << 27) /* 0.359168331 */, + + /* 5376 */ 0x05bf84b8 | (18 << 27) /* 0.359257429 */, + /* 5377 */ 0x05bfe226 | (18 << 27) /* 0.359346534 */, + /* 5378 */ 0x05c03f97 | (18 << 27) /* 0.359435644 */, + /* 5379 */ 0x05c09d08 | (18 << 27) /* 0.359524759 */, + /* 5380 */ 0x05c0fa7c | (18 << 27) /* 0.359613880 */, + /* 5381 */ 0x05c157f0 | (18 << 27) /* 0.359703006 */, + /* 5382 */ 0x05c1b566 | (18 << 27) /* 0.359792138 */, + /* 5383 */ 0x05c212de | (18 << 27) /* 0.359881276 */, + /* 5384 */ 0x05c27057 | (18 << 27) /* 0.359970419 */, + /* 5385 */ 0x05c2cdd2 | (18 << 27) /* 0.360059567 */, + /* 5386 */ 0x05c32b4e | (18 << 27) /* 0.360148721 */, + /* 5387 */ 0x05c388cb | (18 << 27) /* 0.360237881 */, + /* 5388 */ 0x05c3e64b | (18 << 27) /* 0.360327046 */, + /* 5389 */ 0x05c443cb | (18 << 27) /* 0.360416216 */, + /* 5390 */ 0x05c4a14d | (18 << 27) /* 0.360505392 */, + /* 5391 */ 0x05c4fed1 | (18 << 27) /* 0.360594574 */, + + /* 5392 */ 0x05c55c56 | (18 << 27) /* 0.360683761 */, + /* 5393 */ 0x05c5b9dc | (18 << 27) /* 0.360772953 */, + /* 5394 */ 0x05c61764 | (18 << 27) /* 0.360862152 */, + /* 5395 */ 0x05c674ed | (18 << 27) /* 0.360951355 */, + /* 5396 */ 0x05c6d278 | (18 << 27) /* 0.361040564 */, + /* 5397 */ 0x05c73005 | (18 << 27) /* 0.361129779 */, + /* 5398 */ 0x05c78d93 | (18 << 27) /* 0.361218999 */, + /* 5399 */ 0x05c7eb22 | (18 << 27) /* 0.361308225 */, + /* 5400 */ 0x05c848b3 | (18 << 27) /* 0.361397456 */, + /* 5401 */ 0x05c8a645 | (18 << 27) /* 0.361486693 */, + /* 5402 */ 0x05c903d9 | (18 << 27) /* 0.361575935 */, + /* 5403 */ 0x05c9616e | (18 << 27) /* 0.361665183 */, + /* 5404 */ 0x05c9bf05 | (18 << 27) /* 0.361754436 */, + /* 5405 */ 0x05ca1c9d | (18 << 27) /* 0.361843695 */, + /* 5406 */ 0x05ca7a37 | (18 << 27) /* 0.361932959 */, + /* 5407 */ 0x05cad7d2 | (18 << 27) /* 0.362022229 */, + + /* 5408 */ 0x05cb356e | (18 << 27) /* 0.362111504 */, + /* 5409 */ 0x05cb930d | (18 << 27) /* 0.362200785 */, + /* 5410 */ 0x05cbf0ac | (18 << 27) /* 0.362290071 */, + /* 5411 */ 0x05cc4e4d | (18 << 27) /* 0.362379362 */, + /* 5412 */ 0x05ccabf0 | (18 << 27) /* 0.362468660 */, + /* 5413 */ 0x05cd0994 | (18 << 27) /* 0.362557962 */, + /* 5414 */ 0x05cd6739 | (18 << 27) /* 0.362647271 */, + /* 5415 */ 0x05cdc4e0 | (18 << 27) /* 0.362736584 */, + /* 5416 */ 0x05ce2289 | (18 << 27) /* 0.362825904 */, + /* 5417 */ 0x05ce8033 | (18 << 27) /* 0.362915228 */, + /* 5418 */ 0x05ceddde | (18 << 27) /* 0.363004559 */, + /* 5419 */ 0x05cf3b8b | (18 << 27) /* 0.363093894 */, + /* 5420 */ 0x05cf9939 | (18 << 27) /* 0.363183236 */, + /* 5421 */ 0x05cff6e9 | (18 << 27) /* 0.363272582 */, + /* 5422 */ 0x05d0549a | (18 << 27) /* 0.363361935 */, + /* 5423 */ 0x05d0b24d | (18 << 27) /* 0.363451292 */, + + /* 5424 */ 0x05d11001 | (18 << 27) /* 0.363540655 */, + /* 5425 */ 0x05d16db7 | (18 << 27) /* 0.363630024 */, + /* 5426 */ 0x05d1cb6e | (18 << 27) /* 0.363719398 */, + /* 5427 */ 0x05d22927 | (18 << 27) /* 0.363808778 */, + /* 5428 */ 0x05d286e1 | (18 << 27) /* 0.363898163 */, + /* 5429 */ 0x05d2e49d | (18 << 27) /* 0.363987554 */, + /* 5430 */ 0x05d3425a | (18 << 27) /* 0.364076950 */, + /* 5431 */ 0x05d3a018 | (18 << 27) /* 0.364166352 */, + /* 5432 */ 0x05d3fdd8 | (18 << 27) /* 0.364255759 */, + /* 5433 */ 0x05d45b9a | (18 << 27) /* 0.364345171 */, + /* 5434 */ 0x05d4b95d | (18 << 27) /* 0.364434589 */, + /* 5435 */ 0x05d51721 | (18 << 27) /* 0.364524013 */, + /* 5436 */ 0x05d574e7 | (18 << 27) /* 0.364613442 */, + /* 5437 */ 0x05d5d2af | (18 << 27) /* 0.364702877 */, + /* 5438 */ 0x05d63078 | (18 << 27) /* 0.364792317 */, + /* 5439 */ 0x05d68e42 | (18 << 27) /* 0.364881762 */, + + /* 5440 */ 0x05d6ec0e | (18 << 27) /* 0.364971213 */, + /* 5441 */ 0x05d749db | (18 << 27) /* 0.365060669 */, + /* 5442 */ 0x05d7a7aa | (18 << 27) /* 0.365150131 */, + /* 5443 */ 0x05d8057a | (18 << 27) /* 0.365239599 */, + /* 5444 */ 0x05d8634c | (18 << 27) /* 0.365329072 */, + /* 5445 */ 0x05d8c11f | (18 << 27) /* 0.365418550 */, + /* 5446 */ 0x05d91ef4 | (18 << 27) /* 0.365508034 */, + /* 5447 */ 0x05d97cca | (18 << 27) /* 0.365597523 */, + /* 5448 */ 0x05d9daa1 | (18 << 27) /* 0.365687018 */, + /* 5449 */ 0x05da387a | (18 << 27) /* 0.365776518 */, + /* 5450 */ 0x05da9655 | (18 << 27) /* 0.365866024 */, + /* 5451 */ 0x05daf431 | (18 << 27) /* 0.365955536 */, + /* 5452 */ 0x05db520e | (18 << 27) /* 0.366045052 */, + /* 5453 */ 0x05dbafed | (18 << 27) /* 0.366134574 */, + /* 5454 */ 0x05dc0dce | (18 << 27) /* 0.366224102 */, + /* 5455 */ 0x05dc6baf | (18 << 27) /* 0.366313635 */, + + /* 5456 */ 0x05dcc993 | (18 << 27) /* 0.366403174 */, + /* 5457 */ 0x05dd2778 | (18 << 27) /* 0.366492718 */, + /* 5458 */ 0x05dd855e | (18 << 27) /* 0.366582267 */, + /* 5459 */ 0x05dde346 | (18 << 27) /* 0.366671822 */, + /* 5460 */ 0x05de412f | (18 << 27) /* 0.366761383 */, + /* 5461 */ 0x05de9f1a | (18 << 27) /* 0.366850949 */, + /* 5462 */ 0x05defd06 | (18 << 27) /* 0.366940520 */, + /* 5463 */ 0x05df5af3 | (18 << 27) /* 0.367030097 */, + /* 5464 */ 0x05dfb8e2 | (18 << 27) /* 0.367119680 */, + /* 5465 */ 0x05e016d3 | (18 << 27) /* 0.367209267 */, + /* 5466 */ 0x05e074c5 | (18 << 27) /* 0.367298861 */, + /* 5467 */ 0x05e0d2b8 | (18 << 27) /* 0.367388459 */, + /* 5468 */ 0x05e130ad | (18 << 27) /* 0.367478064 */, + /* 5469 */ 0x05e18ea4 | (18 << 27) /* 0.367567673 */, + /* 5470 */ 0x05e1ec9c | (18 << 27) /* 0.367657288 */, + /* 5471 */ 0x05e24a95 | (18 << 27) /* 0.367746909 */, + + /* 5472 */ 0x05e2a890 | (18 << 27) /* 0.367836535 */, + /* 5473 */ 0x05e3068c | (18 << 27) /* 0.367926167 */, + /* 5474 */ 0x05e3648a | (18 << 27) /* 0.368015804 */, + /* 5475 */ 0x05e3c289 | (18 << 27) /* 0.368105446 */, + /* 5476 */ 0x05e4208a | (18 << 27) /* 0.368195094 */, + /* 5477 */ 0x05e47e8c | (18 << 27) /* 0.368284747 */, + /* 5478 */ 0x05e4dc8f | (18 << 27) /* 0.368374406 */, + /* 5479 */ 0x05e53a94 | (18 << 27) /* 0.368464070 */, + /* 5480 */ 0x05e5989b | (18 << 27) /* 0.368553740 */, + /* 5481 */ 0x05e5f6a3 | (18 << 27) /* 0.368643415 */, + /* 5482 */ 0x05e654ac | (18 << 27) /* 0.368733096 */, + /* 5483 */ 0x05e6b2b7 | (18 << 27) /* 0.368822782 */, + /* 5484 */ 0x05e710c4 | (18 << 27) /* 0.368912473 */, + /* 5485 */ 0x05e76ed2 | (18 << 27) /* 0.369002170 */, + /* 5486 */ 0x05e7cce1 | (18 << 27) /* 0.369091873 */, + /* 5487 */ 0x05e82af2 | (18 << 27) /* 0.369181581 */, + + /* 5488 */ 0x05e88904 | (18 << 27) /* 0.369271294 */, + /* 5489 */ 0x05e8e718 | (18 << 27) /* 0.369361013 */, + /* 5490 */ 0x05e9452d | (18 << 27) /* 0.369450737 */, + /* 5491 */ 0x05e9a343 | (18 << 27) /* 0.369540467 */, + /* 5492 */ 0x05ea015c | (18 << 27) /* 0.369630202 */, + /* 5493 */ 0x05ea5f75 | (18 << 27) /* 0.369719942 */, + /* 5494 */ 0x05eabd90 | (18 << 27) /* 0.369809688 */, + /* 5495 */ 0x05eb1bad | (18 << 27) /* 0.369899440 */, + /* 5496 */ 0x05eb79cb | (18 << 27) /* 0.369989197 */, + /* 5497 */ 0x05ebd7ea | (18 << 27) /* 0.370078959 */, + /* 5498 */ 0x05ec360b | (18 << 27) /* 0.370168727 */, + /* 5499 */ 0x05ec942d | (18 << 27) /* 0.370258500 */, + /* 5500 */ 0x05ecf251 | (18 << 27) /* 0.370348279 */, + /* 5501 */ 0x05ed5076 | (18 << 27) /* 0.370438063 */, + /* 5502 */ 0x05edae9d | (18 << 27) /* 0.370527853 */, + /* 5503 */ 0x05ee0cc5 | (18 << 27) /* 0.370617648 */, + + /* 5504 */ 0x05ee6aef | (18 << 27) /* 0.370707448 */, + /* 5505 */ 0x05eec91a | (18 << 27) /* 0.370797254 */, + /* 5506 */ 0x05ef2746 | (18 << 27) /* 0.370887065 */, + /* 5507 */ 0x05ef8574 | (18 << 27) /* 0.370976882 */, + /* 5508 */ 0x05efe3a4 | (18 << 27) /* 0.371066704 */, + /* 5509 */ 0x05f041d5 | (18 << 27) /* 0.371156532 */, + /* 5510 */ 0x05f0a007 | (18 << 27) /* 0.371246365 */, + /* 5511 */ 0x05f0fe3b | (18 << 27) /* 0.371336203 */, + /* 5512 */ 0x05f15c70 | (18 << 27) /* 0.371426047 */, + /* 5513 */ 0x05f1baa7 | (18 << 27) /* 0.371515897 */, + /* 5514 */ 0x05f218df | (18 << 27) /* 0.371605751 */, + /* 5515 */ 0x05f27719 | (18 << 27) /* 0.371695612 */, + /* 5516 */ 0x05f2d554 | (18 << 27) /* 0.371785477 */, + /* 5517 */ 0x05f33390 | (18 << 27) /* 0.371875348 */, + /* 5518 */ 0x05f391cf | (18 << 27) /* 0.371965225 */, + /* 5519 */ 0x05f3f00e | (18 << 27) /* 0.372055107 */, + + /* 5520 */ 0x05f44e4f | (18 << 27) /* 0.372144994 */, + /* 5521 */ 0x05f4ac91 | (18 << 27) /* 0.372234887 */, + /* 5522 */ 0x05f50ad5 | (18 << 27) /* 0.372324785 */, + /* 5523 */ 0x05f5691b | (18 << 27) /* 0.372414689 */, + /* 5524 */ 0x05f5c761 | (18 << 27) /* 0.372504598 */, + /* 5525 */ 0x05f625aa | (18 << 27) /* 0.372594513 */, + /* 5526 */ 0x05f683f3 | (18 << 27) /* 0.372684433 */, + /* 5527 */ 0x05f6e23f | (18 << 27) /* 0.372774358 */, + /* 5528 */ 0x05f7408b | (18 << 27) /* 0.372864289 */, + /* 5529 */ 0x05f79ed9 | (18 << 27) /* 0.372954225 */, + /* 5530 */ 0x05f7fd29 | (18 << 27) /* 0.373044167 */, + /* 5531 */ 0x05f85b7a | (18 << 27) /* 0.373134114 */, + /* 5532 */ 0x05f8b9cc | (18 << 27) /* 0.373224066 */, + /* 5533 */ 0x05f91820 | (18 << 27) /* 0.373314024 */, + /* 5534 */ 0x05f97675 | (18 << 27) /* 0.373403987 */, + /* 5535 */ 0x05f9d4cc | (18 << 27) /* 0.373493956 */, + + /* 5536 */ 0x05fa3324 | (18 << 27) /* 0.373583930 */, + /* 5537 */ 0x05fa917e | (18 << 27) /* 0.373673910 */, + /* 5538 */ 0x05faefd9 | (18 << 27) /* 0.373763895 */, + /* 5539 */ 0x05fb4e36 | (18 << 27) /* 0.373853885 */, + /* 5540 */ 0x05fbac94 | (18 << 27) /* 0.373943881 */, + /* 5541 */ 0x05fc0af3 | (18 << 27) /* 0.374033882 */, + /* 5542 */ 0x05fc6954 | (18 << 27) /* 0.374123889 */, + /* 5543 */ 0x05fcc7b7 | (18 << 27) /* 0.374213901 */, + /* 5544 */ 0x05fd261b | (18 << 27) /* 0.374303918 */, + /* 5545 */ 0x05fd8480 | (18 << 27) /* 0.374393941 */, + /* 5546 */ 0x05fde2e7 | (18 << 27) /* 0.374483970 */, + /* 5547 */ 0x05fe414f | (18 << 27) /* 0.374574003 */, + /* 5548 */ 0x05fe9fb9 | (18 << 27) /* 0.374664042 */, + /* 5549 */ 0x05fefe24 | (18 << 27) /* 0.374754087 */, + /* 5550 */ 0x05ff5c91 | (18 << 27) /* 0.374844137 */, + /* 5551 */ 0x05ffbaff | (18 << 27) /* 0.374934192 */, + + /* 5552 */ 0x0600196e | (18 << 27) /* 0.375024253 */, + /* 5553 */ 0x060077df | (18 << 27) /* 0.375114319 */, + /* 5554 */ 0x0600d651 | (18 << 27) /* 0.375204391 */, + /* 5555 */ 0x060134c5 | (18 << 27) /* 0.375294468 */, + /* 5556 */ 0x0601933b | (18 << 27) /* 0.375384550 */, + /* 5557 */ 0x0601f1b1 | (18 << 27) /* 0.375474638 */, + /* 5558 */ 0x0602502a | (18 << 27) /* 0.375564731 */, + /* 5559 */ 0x0602aea3 | (18 << 27) /* 0.375654830 */, + /* 5560 */ 0x06030d1e | (18 << 27) /* 0.375744934 */, + /* 5561 */ 0x06036b9b | (18 << 27) /* 0.375835043 */, + /* 5562 */ 0x0603ca19 | (18 << 27) /* 0.375925158 */, + /* 5563 */ 0x06042898 | (18 << 27) /* 0.376015278 */, + /* 5564 */ 0x06048719 | (18 << 27) /* 0.376105404 */, + /* 5565 */ 0x0604e59c | (18 << 27) /* 0.376195535 */, + /* 5566 */ 0x0605441f | (18 << 27) /* 0.376285671 */, + /* 5567 */ 0x0605a2a5 | (18 << 27) /* 0.376375813 */, + + /* 5568 */ 0x0606012b | (18 << 27) /* 0.376465960 */, + /* 5569 */ 0x06065fb4 | (18 << 27) /* 0.376556113 */, + /* 5570 */ 0x0606be3d | (18 << 27) /* 0.376646271 */, + /* 5571 */ 0x06071cc8 | (18 << 27) /* 0.376736434 */, + /* 5572 */ 0x06077b55 | (18 << 27) /* 0.376826603 */, + /* 5573 */ 0x0607d9e3 | (18 << 27) /* 0.376916777 */, + /* 5574 */ 0x06083872 | (18 << 27) /* 0.377006957 */, + /* 5575 */ 0x06089703 | (18 << 27) /* 0.377097141 */, + /* 5576 */ 0x0608f595 | (18 << 27) /* 0.377187332 */, + /* 5577 */ 0x06095429 | (18 << 27) /* 0.377277528 */, + /* 5578 */ 0x0609b2be | (18 << 27) /* 0.377367729 */, + /* 5579 */ 0x060a1155 | (18 << 27) /* 0.377457935 */, + /* 5580 */ 0x060a6fed | (18 << 27) /* 0.377548147 */, + /* 5581 */ 0x060ace86 | (18 << 27) /* 0.377638364 */, + /* 5582 */ 0x060b2d21 | (18 << 27) /* 0.377728587 */, + /* 5583 */ 0x060b8bbe | (18 << 27) /* 0.377818815 */, + + /* 5584 */ 0x060bea5c | (18 << 27) /* 0.377909049 */, + /* 5585 */ 0x060c48fb | (18 << 27) /* 0.377999288 */, + /* 5586 */ 0x060ca79c | (18 << 27) /* 0.378089532 */, + /* 5587 */ 0x060d063e | (18 << 27) /* 0.378179781 */, + /* 5588 */ 0x060d64e1 | (18 << 27) /* 0.378270036 */, + /* 5589 */ 0x060dc387 | (18 << 27) /* 0.378360297 */, + /* 5590 */ 0x060e222d | (18 << 27) /* 0.378450563 */, + /* 5591 */ 0x060e80d5 | (18 << 27) /* 0.378540834 */, + /* 5592 */ 0x060edf7f | (18 << 27) /* 0.378631110 */, + /* 5593 */ 0x060f3e29 | (18 << 27) /* 0.378721392 */, + /* 5594 */ 0x060f9cd6 | (18 << 27) /* 0.378811680 */, + /* 5595 */ 0x060ffb83 | (18 << 27) /* 0.378901972 */, + /* 5596 */ 0x06105a33 | (18 << 27) /* 0.378992270 */, + /* 5597 */ 0x0610b8e3 | (18 << 27) /* 0.379082574 */, + /* 5598 */ 0x06111795 | (18 << 27) /* 0.379172883 */, + /* 5599 */ 0x06117649 | (18 << 27) /* 0.379263197 */, + + /* 5600 */ 0x0611d4fe | (18 << 27) /* 0.379353516 */, + /* 5601 */ 0x061233b4 | (18 << 27) /* 0.379443841 */, + /* 5602 */ 0x0612926c | (18 << 27) /* 0.379534172 */, + /* 5603 */ 0x0612f125 | (18 << 27) /* 0.379624507 */, + /* 5604 */ 0x06134fe0 | (18 << 27) /* 0.379714848 */, + /* 5605 */ 0x0613ae9c | (18 << 27) /* 0.379805195 */, + /* 5606 */ 0x06140d5a | (18 << 27) /* 0.379895547 */, + /* 5607 */ 0x06146c19 | (18 << 27) /* 0.379985904 */, + /* 5608 */ 0x0614cada | (18 << 27) /* 0.380076266 */, + /* 5609 */ 0x0615299c | (18 << 27) /* 0.380166634 */, + /* 5610 */ 0x0615885f | (18 << 27) /* 0.380257008 */, + /* 5611 */ 0x0615e724 | (18 << 27) /* 0.380347386 */, + /* 5612 */ 0x061645ea | (18 << 27) /* 0.380437770 */, + /* 5613 */ 0x0616a4b2 | (18 << 27) /* 0.380528160 */, + /* 5614 */ 0x0617037b | (18 << 27) /* 0.380618555 */, + /* 5615 */ 0x06176246 | (18 << 27) /* 0.380708955 */, + + /* 5616 */ 0x0617c112 | (18 << 27) /* 0.380799360 */, + /* 5617 */ 0x06181fdf | (18 << 27) /* 0.380889771 */, + /* 5618 */ 0x06187eae | (18 << 27) /* 0.380980187 */, + /* 5619 */ 0x0618dd7e | (18 << 27) /* 0.381070609 */, + /* 5620 */ 0x06193c50 | (18 << 27) /* 0.381161036 */, + /* 5621 */ 0x06199b24 | (18 << 27) /* 0.381251468 */, + /* 5622 */ 0x0619f9f8 | (18 << 27) /* 0.381341906 */, + /* 5623 */ 0x061a58ce | (18 << 27) /* 0.381432349 */, + /* 5624 */ 0x061ab7a6 | (18 << 27) /* 0.381522798 */, + /* 5625 */ 0x061b167f | (18 << 27) /* 0.381613251 */, + /* 5626 */ 0x061b7559 | (18 << 27) /* 0.381703711 */, + /* 5627 */ 0x061bd435 | (18 << 27) /* 0.381794175 */, + /* 5628 */ 0x061c3313 | (18 << 27) /* 0.381884645 */, + /* 5629 */ 0x061c91f1 | (18 << 27) /* 0.381975120 */, + /* 5630 */ 0x061cf0d2 | (18 << 27) /* 0.382065601 */, + /* 5631 */ 0x061d4fb3 | (18 << 27) /* 0.382156087 */, + + /* 5632 */ 0x061dae96 | (18 << 27) /* 0.382246578 */, + /* 5633 */ 0x061e0d7b | (18 << 27) /* 0.382337075 */, + /* 5634 */ 0x061e6c61 | (18 << 27) /* 0.382427577 */, + /* 5635 */ 0x061ecb48 | (18 << 27) /* 0.382518084 */, + /* 5636 */ 0x061f2a31 | (18 << 27) /* 0.382608597 */, + /* 5637 */ 0x061f891b | (18 << 27) /* 0.382699115 */, + /* 5638 */ 0x061fe807 | (18 << 27) /* 0.382789638 */, + /* 5639 */ 0x062046f4 | (18 << 27) /* 0.382880167 */, + /* 5640 */ 0x0620a5e3 | (18 << 27) /* 0.382970701 */, + /* 5641 */ 0x062104d3 | (18 << 27) /* 0.383061241 */, + /* 5642 */ 0x062163c4 | (18 << 27) /* 0.383151786 */, + /* 5643 */ 0x0621c2b7 | (18 << 27) /* 0.383242336 */, + /* 5644 */ 0x062221ab | (18 << 27) /* 0.383332891 */, + /* 5645 */ 0x062280a1 | (18 << 27) /* 0.383423452 */, + /* 5646 */ 0x0622df98 | (18 << 27) /* 0.383514018 */, + /* 5647 */ 0x06233e91 | (18 << 27) /* 0.383604590 */, + + /* 5648 */ 0x06239d8b | (18 << 27) /* 0.383695167 */, + /* 5649 */ 0x0623fc86 | (18 << 27) /* 0.383785749 */, + /* 5650 */ 0x06245b83 | (18 << 27) /* 0.383876337 */, + /* 5651 */ 0x0624ba82 | (18 << 27) /* 0.383966930 */, + /* 5652 */ 0x06251981 | (18 << 27) /* 0.384057528 */, + /* 5653 */ 0x06257883 | (18 << 27) /* 0.384148132 */, + /* 5654 */ 0x0625d785 | (18 << 27) /* 0.384238741 */, + /* 5655 */ 0x06263689 | (18 << 27) /* 0.384329355 */, + /* 5656 */ 0x0626958f | (18 << 27) /* 0.384419975 */, + /* 5657 */ 0x0626f496 | (18 << 27) /* 0.384510600 */, + /* 5658 */ 0x0627539e | (18 << 27) /* 0.384601230 */, + /* 5659 */ 0x0627b2a8 | (18 << 27) /* 0.384691866 */, + /* 5660 */ 0x062811b3 | (18 << 27) /* 0.384782507 */, + /* 5661 */ 0x062870c0 | (18 << 27) /* 0.384873153 */, + /* 5662 */ 0x0628cfce | (18 << 27) /* 0.384963805 */, + /* 5663 */ 0x06292ede | (18 << 27) /* 0.385054462 */, + + /* 5664 */ 0x06298def | (18 << 27) /* 0.385145124 */, + /* 5665 */ 0x0629ed01 | (18 << 27) /* 0.385235792 */, + /* 5666 */ 0x062a4c15 | (18 << 27) /* 0.385326465 */, + /* 5667 */ 0x062aab2a | (18 << 27) /* 0.385417143 */, + /* 5668 */ 0x062b0a41 | (18 << 27) /* 0.385507827 */, + /* 5669 */ 0x062b6959 | (18 << 27) /* 0.385598516 */, + /* 5670 */ 0x062bc873 | (18 << 27) /* 0.385689211 */, + /* 5671 */ 0x062c278e | (18 << 27) /* 0.385779910 */, + /* 5672 */ 0x062c86aa | (18 << 27) /* 0.385870615 */, + /* 5673 */ 0x062ce5c8 | (18 << 27) /* 0.385961326 */, + /* 5674 */ 0x062d44e8 | (18 << 27) /* 0.386052041 */, + /* 5675 */ 0x062da408 | (18 << 27) /* 0.386142762 */, + /* 5676 */ 0x062e032a | (18 << 27) /* 0.386233489 */, + /* 5677 */ 0x062e624e | (18 << 27) /* 0.386324221 */, + /* 5678 */ 0x062ec173 | (18 << 27) /* 0.386414958 */, + /* 5679 */ 0x062f209a | (18 << 27) /* 0.386505700 */, + + /* 5680 */ 0x062f7fc1 | (18 << 27) /* 0.386596448 */, + /* 5681 */ 0x062fdeeb | (18 << 27) /* 0.386687201 */, + /* 5682 */ 0x06303e16 | (18 << 27) /* 0.386777959 */, + /* 5683 */ 0x06309d42 | (18 << 27) /* 0.386868723 */, + /* 5684 */ 0x0630fc6f | (18 << 27) /* 0.386959492 */, + /* 5685 */ 0x06315b9e | (18 << 27) /* 0.387050266 */, + /* 5686 */ 0x0631bacf | (18 << 27) /* 0.387141045 */, + /* 5687 */ 0x06321a01 | (18 << 27) /* 0.387231830 */, + /* 5688 */ 0x06327934 | (18 << 27) /* 0.387322621 */, + /* 5689 */ 0x0632d869 | (18 << 27) /* 0.387413416 */, + /* 5690 */ 0x0633379f | (18 << 27) /* 0.387504217 */, + /* 5691 */ 0x063396d7 | (18 << 27) /* 0.387595023 */, + /* 5692 */ 0x0633f610 | (18 << 27) /* 0.387685835 */, + /* 5693 */ 0x0634554a | (18 << 27) /* 0.387776652 */, + /* 5694 */ 0x0634b486 | (18 << 27) /* 0.387867474 */, + /* 5695 */ 0x063513c3 | (18 << 27) /* 0.387958301 */, + + /* 5696 */ 0x06357302 | (18 << 27) /* 0.388049134 */, + /* 5697 */ 0x0635d242 | (18 << 27) /* 0.388139972 */, + /* 5698 */ 0x06363184 | (18 << 27) /* 0.388230816 */, + /* 5699 */ 0x063690c7 | (18 << 27) /* 0.388321665 */, + /* 5700 */ 0x0636f00b | (18 << 27) /* 0.388412519 */, + /* 5701 */ 0x06374f51 | (18 << 27) /* 0.388503378 */, + /* 5702 */ 0x0637ae99 | (18 << 27) /* 0.388594243 */, + /* 5703 */ 0x06380de1 | (18 << 27) /* 0.388685113 */, + /* 5704 */ 0x06386d2b | (18 << 27) /* 0.388775988 */, + /* 5705 */ 0x0638cc77 | (18 << 27) /* 0.388866869 */, + /* 5706 */ 0x06392bc4 | (18 << 27) /* 0.388957755 */, + /* 5707 */ 0x06398b12 | (18 << 27) /* 0.389048646 */, + /* 5708 */ 0x0639ea62 | (18 << 27) /* 0.389139542 */, + /* 5709 */ 0x063a49b4 | (18 << 27) /* 0.389230444 */, + /* 5710 */ 0x063aa906 | (18 << 27) /* 0.389321352 */, + /* 5711 */ 0x063b085a | (18 << 27) /* 0.389412264 */, + + /* 5712 */ 0x063b67b0 | (18 << 27) /* 0.389503182 */, + /* 5713 */ 0x063bc707 | (18 << 27) /* 0.389594105 */, + /* 5714 */ 0x063c265f | (18 << 27) /* 0.389685033 */, + /* 5715 */ 0x063c85b9 | (18 << 27) /* 0.389775967 */, + /* 5716 */ 0x063ce514 | (18 << 27) /* 0.389866906 */, + /* 5717 */ 0x063d4471 | (18 << 27) /* 0.389957850 */, + /* 5718 */ 0x063da3cf | (18 << 27) /* 0.390048800 */, + /* 5719 */ 0x063e032f | (18 << 27) /* 0.390139755 */, + /* 5720 */ 0x063e6290 | (18 << 27) /* 0.390230715 */, + /* 5721 */ 0x063ec1f2 | (18 << 27) /* 0.390321681 */, + /* 5722 */ 0x063f2156 | (18 << 27) /* 0.390412651 */, + /* 5723 */ 0x063f80bb | (18 << 27) /* 0.390503628 */, + /* 5724 */ 0x063fe022 | (18 << 27) /* 0.390594609 */, + /* 5725 */ 0x06403f8a | (18 << 27) /* 0.390685596 */, + /* 5726 */ 0x06409ef3 | (18 << 27) /* 0.390776588 */, + /* 5727 */ 0x0640fe5e | (18 << 27) /* 0.390867585 */, + + /* 5728 */ 0x06415dcb | (18 << 27) /* 0.390958588 */, + /* 5729 */ 0x0641bd38 | (18 << 27) /* 0.391049596 */, + /* 5730 */ 0x06421ca7 | (18 << 27) /* 0.391140609 */, + /* 5731 */ 0x06427c18 | (18 << 27) /* 0.391231627 */, + /* 5732 */ 0x0642db8a | (18 << 27) /* 0.391322651 */, + /* 5733 */ 0x06433afd | (18 << 27) /* 0.391413680 */, + /* 5734 */ 0x06439a72 | (18 << 27) /* 0.391504714 */, + /* 5735 */ 0x0643f9e9 | (18 << 27) /* 0.391595754 */, + /* 5736 */ 0x06445960 | (18 << 27) /* 0.391686799 */, + /* 5737 */ 0x0644b8d9 | (18 << 27) /* 0.391777849 */, + /* 5738 */ 0x06451854 | (18 << 27) /* 0.391868905 */, + /* 5739 */ 0x064577d0 | (18 << 27) /* 0.391959966 */, + /* 5740 */ 0x0645d74d | (18 << 27) /* 0.392051032 */, + /* 5741 */ 0x064636cc | (18 << 27) /* 0.392142103 */, + /* 5742 */ 0x0646964c | (18 << 27) /* 0.392233180 */, + /* 5743 */ 0x0646f5ce | (18 << 27) /* 0.392324262 */, + + /* 5744 */ 0x06475551 | (18 << 27) /* 0.392415349 */, + /* 5745 */ 0x0647b4d5 | (18 << 27) /* 0.392506442 */, + /* 5746 */ 0x0648145b | (18 << 27) /* 0.392597540 */, + /* 5747 */ 0x064873e3 | (18 << 27) /* 0.392688643 */, + /* 5748 */ 0x0648d36b | (18 << 27) /* 0.392779751 */, + /* 5749 */ 0x064932f6 | (18 << 27) /* 0.392870865 */, + /* 5750 */ 0x06499281 | (18 << 27) /* 0.392961984 */, + /* 5751 */ 0x0649f20e | (18 << 27) /* 0.393053108 */, + /* 5752 */ 0x064a519c | (18 << 27) /* 0.393144238 */, + /* 5753 */ 0x064ab12c | (18 << 27) /* 0.393235372 */, + /* 5754 */ 0x064b10be | (18 << 27) /* 0.393326513 */, + /* 5755 */ 0x064b7050 | (18 << 27) /* 0.393417658 */, + /* 5756 */ 0x064bcfe4 | (18 << 27) /* 0.393508809 */, + /* 5757 */ 0x064c2f7a | (18 << 27) /* 0.393599965 */, + /* 5758 */ 0x064c8f11 | (18 << 27) /* 0.393691126 */, + /* 5759 */ 0x064ceea9 | (18 << 27) /* 0.393782292 */, + + /* 5760 */ 0x064d4e43 | (18 << 27) /* 0.393873464 */, + /* 5761 */ 0x064dadde | (18 << 27) /* 0.393964641 */, + /* 5762 */ 0x064e0d7a | (18 << 27) /* 0.394055823 */, + /* 5763 */ 0x064e6d18 | (18 << 27) /* 0.394147011 */, + /* 5764 */ 0x064eccb8 | (18 << 27) /* 0.394238204 */, + /* 5765 */ 0x064f2c59 | (18 << 27) /* 0.394329402 */, + /* 5766 */ 0x064f8bfb | (18 << 27) /* 0.394420605 */, + /* 5767 */ 0x064feb9e | (18 << 27) /* 0.394511814 */, + /* 5768 */ 0x06504b44 | (18 << 27) /* 0.394603028 */, + /* 5769 */ 0x0650aaea | (18 << 27) /* 0.394694247 */, + /* 5770 */ 0x06510a92 | (18 << 27) /* 0.394785472 */, + /* 5771 */ 0x06516a3b | (18 << 27) /* 0.394876702 */, + /* 5772 */ 0x0651c9e6 | (18 << 27) /* 0.394967937 */, + /* 5773 */ 0x06522992 | (18 << 27) /* 0.395059177 */, + /* 5774 */ 0x06528940 | (18 << 27) /* 0.395150423 */, + /* 5775 */ 0x0652e8ef | (18 << 27) /* 0.395241673 */, + + /* 5776 */ 0x0653489f | (18 << 27) /* 0.395332930 */, + /* 5777 */ 0x0653a851 | (18 << 27) /* 0.395424191 */, + /* 5778 */ 0x06540804 | (18 << 27) /* 0.395515458 */, + /* 5779 */ 0x065467b9 | (18 << 27) /* 0.395606730 */, + /* 5780 */ 0x0654c76f | (18 << 27) /* 0.395698007 */, + /* 5781 */ 0x06552726 | (18 << 27) /* 0.395789289 */, + /* 5782 */ 0x065586df | (18 << 27) /* 0.395880577 */, + /* 5783 */ 0x0655e699 | (18 << 27) /* 0.395971870 */, + /* 5784 */ 0x06564655 | (18 << 27) /* 0.396063168 */, + /* 5785 */ 0x0656a612 | (18 << 27) /* 0.396154472 */, + /* 5786 */ 0x065705d0 | (18 << 27) /* 0.396245780 */, + /* 5787 */ 0x06576590 | (18 << 27) /* 0.396337094 */, + /* 5788 */ 0x0657c552 | (18 << 27) /* 0.396428414 */, + /* 5789 */ 0x06582514 | (18 << 27) /* 0.396519738 */, + /* 5790 */ 0x065884d9 | (18 << 27) /* 0.396611068 */, + /* 5791 */ 0x0658e49e | (18 << 27) /* 0.396702403 */, + + /* 5792 */ 0x06594465 | (18 << 27) /* 0.396793743 */, + /* 5793 */ 0x0659a42e | (18 << 27) /* 0.396885089 */, + /* 5794 */ 0x065a03f7 | (18 << 27) /* 0.396976440 */, + /* 5795 */ 0x065a63c3 | (18 << 27) /* 0.397067796 */, + /* 5796 */ 0x065ac38f | (18 << 27) /* 0.397159157 */, + /* 5797 */ 0x065b235d | (18 << 27) /* 0.397250524 */, + /* 5798 */ 0x065b832d | (18 << 27) /* 0.397341896 */, + /* 5799 */ 0x065be2fe | (18 << 27) /* 0.397433273 */, + /* 5800 */ 0x065c42d0 | (18 << 27) /* 0.397524655 */, + /* 5801 */ 0x065ca2a3 | (18 << 27) /* 0.397616043 */, + /* 5802 */ 0x065d0279 | (18 << 27) /* 0.397707436 */, + /* 5803 */ 0x065d624f | (18 << 27) /* 0.397798834 */, + /* 5804 */ 0x065dc227 | (18 << 27) /* 0.397890237 */, + /* 5805 */ 0x065e2200 | (18 << 27) /* 0.397981646 */, + /* 5806 */ 0x065e81db | (18 << 27) /* 0.398073059 */, + /* 5807 */ 0x065ee1b7 | (18 << 27) /* 0.398164479 */, + + /* 5808 */ 0x065f4195 | (18 << 27) /* 0.398255903 */, + /* 5809 */ 0x065fa174 | (18 << 27) /* 0.398347333 */, + /* 5810 */ 0x06600154 | (18 << 27) /* 0.398438767 */, + /* 5811 */ 0x06606136 | (18 << 27) /* 0.398530207 */, + /* 5812 */ 0x0660c119 | (18 << 27) /* 0.398621653 */, + /* 5813 */ 0x066120fd | (18 << 27) /* 0.398713103 */, + /* 5814 */ 0x066180e3 | (18 << 27) /* 0.398804559 */, + /* 5815 */ 0x0661e0cb | (18 << 27) /* 0.398896020 */, + /* 5816 */ 0x066240b4 | (18 << 27) /* 0.398987487 */, + /* 5817 */ 0x0662a09e | (18 << 27) /* 0.399078958 */, + /* 5818 */ 0x06630089 | (18 << 27) /* 0.399170435 */, + /* 5819 */ 0x06636077 | (18 << 27) /* 0.399261917 */, + /* 5820 */ 0x0663c065 | (18 << 27) /* 0.399353404 */, + /* 5821 */ 0x06642055 | (18 << 27) /* 0.399444897 */, + /* 5822 */ 0x06648046 | (18 << 27) /* 0.399536395 */, + /* 5823 */ 0x0664e039 | (18 << 27) /* 0.399627898 */, + + /* 5824 */ 0x0665402d | (18 << 27) /* 0.399719406 */, + /* 5825 */ 0x0665a022 | (18 << 27) /* 0.399810919 */, + /* 5826 */ 0x06660019 | (18 << 27) /* 0.399902438 */, + /* 5827 */ 0x06666011 | (18 << 27) /* 0.399993962 */, + /* 5828 */ 0x0666c00b | (18 << 27) /* 0.400085491 */, + /* 5829 */ 0x06672006 | (18 << 27) /* 0.400177026 */, + /* 5830 */ 0x06678003 | (18 << 27) /* 0.400268565 */, + /* 5831 */ 0x0667e000 | (18 << 27) /* 0.400360110 */, + /* 5832 */ 0x06684000 | (18 << 27) /* 0.400451660 */, + /* 5833 */ 0x0668a000 | (18 << 27) /* 0.400543216 */, + /* 5834 */ 0x06690003 | (18 << 27) /* 0.400634776 */, + /* 5835 */ 0x06696006 | (18 << 27) /* 0.400726342 */, + /* 5836 */ 0x0669c00b | (18 << 27) /* 0.400817913 */, + /* 5837 */ 0x066a2011 | (18 << 27) /* 0.400909489 */, + /* 5838 */ 0x066a8019 | (18 << 27) /* 0.401001071 */, + /* 5839 */ 0x066ae022 | (18 << 27) /* 0.401092657 */, + + /* 5840 */ 0x066b402d | (18 << 27) /* 0.401184249 */, + /* 5841 */ 0x066ba039 | (18 << 27) /* 0.401275847 */, + /* 5842 */ 0x066c0046 | (18 << 27) /* 0.401367449 */, + /* 5843 */ 0x066c6055 | (18 << 27) /* 0.401459057 */, + /* 5844 */ 0x066cc065 | (18 << 27) /* 0.401550670 */, + /* 5845 */ 0x066d2076 | (18 << 27) /* 0.401642288 */, + /* 5846 */ 0x066d8089 | (18 << 27) /* 0.401733911 */, + /* 5847 */ 0x066de09e | (18 << 27) /* 0.401825540 */, + /* 5848 */ 0x066e40b3 | (18 << 27) /* 0.401917173 */, + /* 5849 */ 0x066ea0cb | (18 << 27) /* 0.402008812 */, + /* 5850 */ 0x066f00e3 | (18 << 27) /* 0.402100457 */, + /* 5851 */ 0x066f60fd | (18 << 27) /* 0.402192106 */, + /* 5852 */ 0x066fc118 | (18 << 27) /* 0.402283761 */, + /* 5853 */ 0x06702135 | (18 << 27) /* 0.402375420 */, + /* 5854 */ 0x06708153 | (18 << 27) /* 0.402467086 */, + /* 5855 */ 0x0670e173 | (18 << 27) /* 0.402558756 */, + + /* 5856 */ 0x06714194 | (18 << 27) /* 0.402650431 */, + /* 5857 */ 0x0671a1b6 | (18 << 27) /* 0.402742112 */, + /* 5858 */ 0x067201da | (18 << 27) /* 0.402833798 */, + /* 5859 */ 0x067261ff | (18 << 27) /* 0.402925489 */, + /* 5860 */ 0x0672c226 | (18 << 27) /* 0.403017186 */, + /* 5861 */ 0x0673224e | (18 << 27) /* 0.403108887 */, + /* 5862 */ 0x06738277 | (18 << 27) /* 0.403200594 */, + /* 5863 */ 0x0673e2a2 | (18 << 27) /* 0.403292306 */, + /* 5864 */ 0x067442ce | (18 << 27) /* 0.403384024 */, + /* 5865 */ 0x0674a2fc | (18 << 27) /* 0.403475746 */, + /* 5866 */ 0x0675032b | (18 << 27) /* 0.403567474 */, + /* 5867 */ 0x0675635b | (18 << 27) /* 0.403659207 */, + /* 5868 */ 0x0675c38d | (18 << 27) /* 0.403750945 */, + /* 5869 */ 0x067623c0 | (18 << 27) /* 0.403842688 */, + /* 5870 */ 0x067683f4 | (18 << 27) /* 0.403934437 */, + /* 5871 */ 0x0676e42a | (18 << 27) /* 0.404026190 */, + + /* 5872 */ 0x06774462 | (18 << 27) /* 0.404117949 */, + /* 5873 */ 0x0677a49b | (18 << 27) /* 0.404209714 */, + /* 5874 */ 0x067804d5 | (18 << 27) /* 0.404301483 */, + /* 5875 */ 0x06786510 | (18 << 27) /* 0.404393258 */, + /* 5876 */ 0x0678c54d | (18 << 27) /* 0.404485037 */, + /* 5877 */ 0x0679258c | (18 << 27) /* 0.404576822 */, + /* 5878 */ 0x067985cb | (18 << 27) /* 0.404668613 */, + /* 5879 */ 0x0679e60c | (18 << 27) /* 0.404760408 */, + /* 5880 */ 0x067a464f | (18 << 27) /* 0.404852209 */, + /* 5881 */ 0x067aa693 | (18 << 27) /* 0.404944014 */, + /* 5882 */ 0x067b06d8 | (18 << 27) /* 0.405035825 */, + /* 5883 */ 0x067b671f | (18 << 27) /* 0.405127642 */, + /* 5884 */ 0x067bc767 | (18 << 27) /* 0.405219463 */, + /* 5885 */ 0x067c27b1 | (18 << 27) /* 0.405311290 */, + /* 5886 */ 0x067c87fc | (18 << 27) /* 0.405403122 */, + /* 5887 */ 0x067ce848 | (18 << 27) /* 0.405494959 */, + + /* 5888 */ 0x067d4896 | (18 << 27) /* 0.405586801 */, + /* 5889 */ 0x067da8e5 | (18 << 27) /* 0.405678648 */, + /* 5890 */ 0x067e0935 | (18 << 27) /* 0.405770501 */, + /* 5891 */ 0x067e6987 | (18 << 27) /* 0.405862359 */, + /* 5892 */ 0x067ec9da | (18 << 27) /* 0.405954222 */, + /* 5893 */ 0x067f2a2f | (18 << 27) /* 0.406046090 */, + /* 5894 */ 0x067f8a85 | (18 << 27) /* 0.406137963 */, + /* 5895 */ 0x067feadd | (18 << 27) /* 0.406229842 */, + /* 5896 */ 0x06804b36 | (18 << 27) /* 0.406321726 */, + /* 5897 */ 0x0680ab90 | (18 << 27) /* 0.406413615 */, + /* 5898 */ 0x06810beb | (18 << 27) /* 0.406505509 */, + /* 5899 */ 0x06816c49 | (18 << 27) /* 0.406597408 */, + /* 5900 */ 0x0681cca7 | (18 << 27) /* 0.406689313 */, + /* 5901 */ 0x06822d07 | (18 << 27) /* 0.406781223 */, + /* 5902 */ 0x06828d68 | (18 << 27) /* 0.406873138 */, + /* 5903 */ 0x0682edcb | (18 << 27) /* 0.406965058 */, + + /* 5904 */ 0x06834e2f | (18 << 27) /* 0.407056983 */, + /* 5905 */ 0x0683ae94 | (18 << 27) /* 0.407148914 */, + /* 5906 */ 0x06840efb | (18 << 27) /* 0.407240850 */, + /* 5907 */ 0x06846f63 | (18 << 27) /* 0.407332791 */, + /* 5908 */ 0x0684cfcd | (18 << 27) /* 0.407424737 */, + /* 5909 */ 0x06853038 | (18 << 27) /* 0.407516688 */, + /* 5910 */ 0x068590a4 | (18 << 27) /* 0.407608645 */, + /* 5911 */ 0x0685f112 | (18 << 27) /* 0.407700606 */, + /* 5912 */ 0x06865181 | (18 << 27) /* 0.407792573 */, + /* 5913 */ 0x0686b1f2 | (18 << 27) /* 0.407884545 */, + /* 5914 */ 0x06871264 | (18 << 27) /* 0.407976522 */, + /* 5915 */ 0x068772d7 | (18 << 27) /* 0.408068505 */, + /* 5916 */ 0x0687d34c | (18 << 27) /* 0.408160492 */, + /* 5917 */ 0x068833c2 | (18 << 27) /* 0.408252485 */, + /* 5918 */ 0x06889439 | (18 << 27) /* 0.408344483 */, + /* 5919 */ 0x0688f4b2 | (18 << 27) /* 0.408436486 */, + + /* 5920 */ 0x0689552c | (18 << 27) /* 0.408528495 */, + /* 5921 */ 0x0689b5a8 | (18 << 27) /* 0.408620508 */, + /* 5922 */ 0x068a1625 | (18 << 27) /* 0.408712527 */, + /* 5923 */ 0x068a76a4 | (18 << 27) /* 0.408804551 */, + /* 5924 */ 0x068ad724 | (18 << 27) /* 0.408896580 */, + /* 5925 */ 0x068b37a5 | (18 << 27) /* 0.408988614 */, + /* 5926 */ 0x068b9827 | (18 << 27) /* 0.409080653 */, + /* 5927 */ 0x068bf8ac | (18 << 27) /* 0.409172698 */, + /* 5928 */ 0x068c5931 | (18 << 27) /* 0.409264748 */, + /* 5929 */ 0x068cb9b8 | (18 << 27) /* 0.409356803 */, + /* 5930 */ 0x068d1a40 | (18 << 27) /* 0.409448863 */, + /* 5931 */ 0x068d7aca | (18 << 27) /* 0.409540928 */, + /* 5932 */ 0x068ddb54 | (18 << 27) /* 0.409632999 */, + /* 5933 */ 0x068e3be1 | (18 << 27) /* 0.409725074 */, + /* 5934 */ 0x068e9c6f | (18 << 27) /* 0.409817155 */, + /* 5935 */ 0x068efcfe | (18 << 27) /* 0.409909241 */, + + /* 5936 */ 0x068f5d8e | (18 << 27) /* 0.410001332 */, + /* 5937 */ 0x068fbe20 | (18 << 27) /* 0.410093428 */, + /* 5938 */ 0x06901eb4 | (18 << 27) /* 0.410185530 */, + /* 5939 */ 0x06907f48 | (18 << 27) /* 0.410277637 */, + /* 5940 */ 0x0690dfde | (18 << 27) /* 0.410369748 */, + /* 5941 */ 0x06914076 | (18 << 27) /* 0.410461865 */, + /* 5942 */ 0x0691a10f | (18 << 27) /* 0.410553988 */, + /* 5943 */ 0x069201a9 | (18 << 27) /* 0.410646115 */, + /* 5944 */ 0x06926245 | (18 << 27) /* 0.410738247 */, + /* 5945 */ 0x0692c2e2 | (18 << 27) /* 0.410830385 */, + /* 5946 */ 0x06932380 | (18 << 27) /* 0.410922528 */, + /* 5947 */ 0x06938420 | (18 << 27) /* 0.411014676 */, + /* 5948 */ 0x0693e4c1 | (18 << 27) /* 0.411106829 */, + /* 5949 */ 0x06944563 | (18 << 27) /* 0.411198987 */, + /* 5950 */ 0x0694a607 | (18 << 27) /* 0.411291151 */, + /* 5951 */ 0x069506ad | (18 << 27) /* 0.411383320 */, + + /* 5952 */ 0x06956753 | (18 << 27) /* 0.411475493 */, + /* 5953 */ 0x0695c7fc | (18 << 27) /* 0.411567672 */, + /* 5954 */ 0x069628a5 | (18 << 27) /* 0.411659857 */, + /* 5955 */ 0x06968950 | (18 << 27) /* 0.411752046 */, + /* 5956 */ 0x0696e9fc | (18 << 27) /* 0.411844240 */, + /* 5957 */ 0x06974aaa | (18 << 27) /* 0.411936440 */, + /* 5958 */ 0x0697ab59 | (18 << 27) /* 0.412028645 */, + /* 5959 */ 0x06980c09 | (18 << 27) /* 0.412120855 */, + /* 5960 */ 0x06986cbb | (18 << 27) /* 0.412213070 */, + /* 5961 */ 0x0698cd6e | (18 << 27) /* 0.412305290 */, + /* 5962 */ 0x06992e23 | (18 << 27) /* 0.412397516 */, + /* 5963 */ 0x06998ed9 | (18 << 27) /* 0.412489746 */, + /* 5964 */ 0x0699ef90 | (18 << 27) /* 0.412581982 */, + /* 5965 */ 0x069a5049 | (18 << 27) /* 0.412674223 */, + /* 5966 */ 0x069ab103 | (18 << 27) /* 0.412766469 */, + /* 5967 */ 0x069b11bf | (18 << 27) /* 0.412858720 */, + + /* 5968 */ 0x069b727b | (18 << 27) /* 0.412950976 */, + /* 5969 */ 0x069bd33a | (18 << 27) /* 0.413043238 */, + /* 5970 */ 0x069c33f9 | (18 << 27) /* 0.413135505 */, + /* 5971 */ 0x069c94ba | (18 << 27) /* 0.413227776 */, + /* 5972 */ 0x069cf57d | (18 << 27) /* 0.413320053 */, + /* 5973 */ 0x069d5641 | (18 << 27) /* 0.413412335 */, + /* 5974 */ 0x069db706 | (18 << 27) /* 0.413504623 */, + /* 5975 */ 0x069e17cc | (18 << 27) /* 0.413596915 */, + /* 5976 */ 0x069e7894 | (18 << 27) /* 0.413689213 */, + /* 5977 */ 0x069ed95e | (18 << 27) /* 0.413781515 */, + /* 5978 */ 0x069f3a28 | (18 << 27) /* 0.413873823 */, + /* 5979 */ 0x069f9af4 | (18 << 27) /* 0.413966136 */, + /* 5980 */ 0x069ffbc2 | (18 << 27) /* 0.414058454 */, + /* 5981 */ 0x06a05c91 | (18 << 27) /* 0.414150778 */, + /* 5982 */ 0x06a0bd61 | (18 << 27) /* 0.414243106 */, + /* 5983 */ 0x06a11e32 | (18 << 27) /* 0.414335440 */, + + /* 5984 */ 0x06a17f05 | (18 << 27) /* 0.414427779 */, + /* 5985 */ 0x06a1dfda | (18 << 27) /* 0.414520122 */, + /* 5986 */ 0x06a240b0 | (18 << 27) /* 0.414612471 */, + /* 5987 */ 0x06a2a187 | (18 << 27) /* 0.414704826 */, + /* 5988 */ 0x06a3025f | (18 << 27) /* 0.414797185 */, + /* 5989 */ 0x06a36339 | (18 << 27) /* 0.414889549 */, + /* 5990 */ 0x06a3c414 | (18 << 27) /* 0.414981919 */, + /* 5991 */ 0x06a424f1 | (18 << 27) /* 0.415074294 */, + /* 5992 */ 0x06a485cf | (18 << 27) /* 0.415166674 */, + /* 5993 */ 0x06a4e6ae | (18 << 27) /* 0.415259059 */, + /* 5994 */ 0x06a5478f | (18 << 27) /* 0.415351449 */, + /* 5995 */ 0x06a5a871 | (18 << 27) /* 0.415443844 */, + /* 5996 */ 0x06a60955 | (18 << 27) /* 0.415536244 */, + /* 5997 */ 0x06a66a3a | (18 << 27) /* 0.415628650 */, + /* 5998 */ 0x06a6cb20 | (18 << 27) /* 0.415721061 */, + /* 5999 */ 0x06a72c08 | (18 << 27) /* 0.415813476 */, + + /* 6000 */ 0x06a78cf1 | (18 << 27) /* 0.415905897 */, + /* 6001 */ 0x06a7eddb | (18 << 27) /* 0.415998324 */, + /* 6002 */ 0x06a84ec7 | (18 << 27) /* 0.416090755 */, + /* 6003 */ 0x06a8afb4 | (18 << 27) /* 0.416183191 */, + /* 6004 */ 0x06a910a3 | (18 << 27) /* 0.416275633 */, + /* 6005 */ 0x06a97193 | (18 << 27) /* 0.416368079 */, + /* 6006 */ 0x06a9d284 | (18 << 27) /* 0.416460531 */, + /* 6007 */ 0x06aa3377 | (18 << 27) /* 0.416552988 */, + /* 6008 */ 0x06aa946b | (18 << 27) /* 0.416645450 */, + /* 6009 */ 0x06aaf561 | (18 << 27) /* 0.416737917 */, + /* 6010 */ 0x06ab5657 | (18 << 27) /* 0.416830389 */, + /* 6011 */ 0x06abb750 | (18 << 27) /* 0.416922867 */, + /* 6012 */ 0x06ac1849 | (18 << 27) /* 0.417015349 */, + /* 6013 */ 0x06ac7944 | (18 << 27) /* 0.417107837 */, + /* 6014 */ 0x06acda41 | (18 << 27) /* 0.417200330 */, + /* 6015 */ 0x06ad3b3e | (18 << 27) /* 0.417292828 */, + + /* 6016 */ 0x06ad9c3d | (18 << 27) /* 0.417385331 */, + /* 6017 */ 0x06adfd3e | (18 << 27) /* 0.417477839 */, + /* 6018 */ 0x06ae5e40 | (18 << 27) /* 0.417570352 */, + /* 6019 */ 0x06aebf43 | (18 << 27) /* 0.417662871 */, + /* 6020 */ 0x06af2047 | (18 << 27) /* 0.417755394 */, + /* 6021 */ 0x06af814d | (18 << 27) /* 0.417847923 */, + /* 6022 */ 0x06afe255 | (18 << 27) /* 0.417940457 */, + /* 6023 */ 0x06b0435e | (18 << 27) /* 0.418032996 */, + /* 6024 */ 0x06b0a468 | (18 << 27) /* 0.418125540 */, + /* 6025 */ 0x06b10573 | (18 << 27) /* 0.418218089 */, + /* 6026 */ 0x06b16680 | (18 << 27) /* 0.418310643 */, + /* 6027 */ 0x06b1c78e | (18 << 27) /* 0.418403203 */, + /* 6028 */ 0x06b2289e | (18 << 27) /* 0.418495767 */, + /* 6029 */ 0x06b289af | (18 << 27) /* 0.418588337 */, + /* 6030 */ 0x06b2eac1 | (18 << 27) /* 0.418680911 */, + /* 6031 */ 0x06b34bd5 | (18 << 27) /* 0.418773491 */, + + /* 6032 */ 0x06b3acea | (18 << 27) /* 0.418866076 */, + /* 6033 */ 0x06b40e00 | (18 << 27) /* 0.418958666 */, + /* 6034 */ 0x06b46f18 | (18 << 27) /* 0.419051262 */, + /* 6035 */ 0x06b4d031 | (18 << 27) /* 0.419143862 */, + /* 6036 */ 0x06b5314c | (18 << 27) /* 0.419236467 */, + /* 6037 */ 0x06b59268 | (18 << 27) /* 0.419329078 */, + /* 6038 */ 0x06b5f385 | (18 << 27) /* 0.419421694 */, + /* 6039 */ 0x06b654a4 | (18 << 27) /* 0.419514314 */, + /* 6040 */ 0x06b6b5c4 | (18 << 27) /* 0.419606940 */, + /* 6041 */ 0x06b716e6 | (18 << 27) /* 0.419699571 */, + /* 6042 */ 0x06b77808 | (18 << 27) /* 0.419792208 */, + /* 6043 */ 0x06b7d92d | (18 << 27) /* 0.419884849 */, + /* 6044 */ 0x06b83a52 | (18 << 27) /* 0.419977495 */, + /* 6045 */ 0x06b89b79 | (18 << 27) /* 0.420070147 */, + /* 6046 */ 0x06b8fca1 | (18 << 27) /* 0.420162803 */, + /* 6047 */ 0x06b95dcb | (18 << 27) /* 0.420255465 */, + + /* 6048 */ 0x06b9bef6 | (18 << 27) /* 0.420348132 */, + /* 6049 */ 0x06ba2023 | (18 << 27) /* 0.420440803 */, + /* 6050 */ 0x06ba8150 | (18 << 27) /* 0.420533481 */, + /* 6051 */ 0x06bae280 | (18 << 27) /* 0.420626163 */, + /* 6052 */ 0x06bb43b0 | (18 << 27) /* 0.420718850 */, + /* 6053 */ 0x06bba4e2 | (18 << 27) /* 0.420811542 */, + /* 6054 */ 0x06bc0615 | (18 << 27) /* 0.420904240 */, + /* 6055 */ 0x06bc674a | (18 << 27) /* 0.420996942 */, + /* 6056 */ 0x06bcc880 | (18 << 27) /* 0.421089650 */, + /* 6057 */ 0x06bd29b7 | (18 << 27) /* 0.421182362 */, + /* 6058 */ 0x06bd8af0 | (18 << 27) /* 0.421275080 */, + /* 6059 */ 0x06bdec2a | (18 << 27) /* 0.421367803 */, + /* 6060 */ 0x06be4d66 | (18 << 27) /* 0.421460531 */, + /* 6061 */ 0x06beaea3 | (18 << 27) /* 0.421553264 */, + /* 6062 */ 0x06bf0fe1 | (18 << 27) /* 0.421646003 */, + /* 6063 */ 0x06bf7120 | (18 << 27) /* 0.421738746 */, + + /* 6064 */ 0x06bfd261 | (18 << 27) /* 0.421831494 */, + /* 6065 */ 0x06c033a4 | (18 << 27) /* 0.421924248 */, + /* 6066 */ 0x06c094e7 | (18 << 27) /* 0.422017007 */, + /* 6067 */ 0x06c0f62c | (18 << 27) /* 0.422109770 */, + /* 6068 */ 0x06c15773 | (18 << 27) /* 0.422202539 */, + /* 6069 */ 0x06c1b8bb | (18 << 27) /* 0.422295313 */, + /* 6070 */ 0x06c21a04 | (18 << 27) /* 0.422388092 */, + /* 6071 */ 0x06c27b4e | (18 << 27) /* 0.422480876 */, + /* 6072 */ 0x06c2dc9a | (18 << 27) /* 0.422573665 */, + /* 6073 */ 0x06c33de8 | (18 << 27) /* 0.422666460 */, + /* 6074 */ 0x06c39f36 | (18 << 27) /* 0.422759259 */, + /* 6075 */ 0x06c40086 | (18 << 27) /* 0.422852064 */, + /* 6076 */ 0x06c461d8 | (18 << 27) /* 0.422944873 */, + /* 6077 */ 0x06c4c32a | (18 << 27) /* 0.423037688 */, + /* 6078 */ 0x06c5247f | (18 << 27) /* 0.423130508 */, + /* 6079 */ 0x06c585d4 | (18 << 27) /* 0.423223333 */, + + /* 6080 */ 0x06c5e72b | (18 << 27) /* 0.423316162 */, + /* 6081 */ 0x06c64883 | (18 << 27) /* 0.423408997 */, + /* 6082 */ 0x06c6a9dd | (18 << 27) /* 0.423501838 */, + /* 6083 */ 0x06c70b38 | (18 << 27) /* 0.423594683 */, + /* 6084 */ 0x06c76c94 | (18 << 27) /* 0.423687533 */, + /* 6085 */ 0x06c7cdf2 | (18 << 27) /* 0.423780389 */, + /* 6086 */ 0x06c82f51 | (18 << 27) /* 0.423873249 */, + /* 6087 */ 0x06c890b1 | (18 << 27) /* 0.423966115 */, + /* 6088 */ 0x06c8f213 | (18 << 27) /* 0.424058985 */, + /* 6089 */ 0x06c95376 | (18 << 27) /* 0.424151861 */, + /* 6090 */ 0x06c9b4da | (18 << 27) /* 0.424244742 */, + /* 6091 */ 0x06ca1640 | (18 << 27) /* 0.424337628 */, + /* 6092 */ 0x06ca77a8 | (18 << 27) /* 0.424430519 */, + /* 6093 */ 0x06cad910 | (18 << 27) /* 0.424523415 */, + /* 6094 */ 0x06cb3a7a | (18 << 27) /* 0.424616316 */, + /* 6095 */ 0x06cb9be5 | (18 << 27) /* 0.424709222 */, + + /* 6096 */ 0x06cbfd52 | (18 << 27) /* 0.424802133 */, + /* 6097 */ 0x06cc5ec0 | (18 << 27) /* 0.424895050 */, + /* 6098 */ 0x06ccc030 | (18 << 27) /* 0.424987971 */, + /* 6099 */ 0x06cd21a0 | (18 << 27) /* 0.425080898 */, + /* 6100 */ 0x06cd8313 | (18 << 27) /* 0.425173829 */, + /* 6101 */ 0x06cde486 | (18 << 27) /* 0.425266766 */, + /* 6102 */ 0x06ce45fb | (18 << 27) /* 0.425359708 */, + /* 6103 */ 0x06cea771 | (18 << 27) /* 0.425452655 */, + /* 6104 */ 0x06cf08e9 | (18 << 27) /* 0.425545607 */, + /* 6105 */ 0x06cf6a62 | (18 << 27) /* 0.425638564 */, + /* 6106 */ 0x06cfcbdc | (18 << 27) /* 0.425731526 */, + /* 6107 */ 0x06d02d58 | (18 << 27) /* 0.425824493 */, + /* 6108 */ 0x06d08ed5 | (18 << 27) /* 0.425917465 */, + /* 6109 */ 0x06d0f053 | (18 << 27) /* 0.426010443 */, + /* 6110 */ 0x06d151d3 | (18 << 27) /* 0.426103425 */, + /* 6111 */ 0x06d1b354 | (18 << 27) /* 0.426196412 */, + + /* 6112 */ 0x06d214d7 | (18 << 27) /* 0.426289405 */, + /* 6113 */ 0x06d2765a | (18 << 27) /* 0.426382403 */, + /* 6114 */ 0x06d2d7e0 | (18 << 27) /* 0.426475405 */, + /* 6115 */ 0x06d33966 | (18 << 27) /* 0.426568413 */, + /* 6116 */ 0x06d39aee | (18 << 27) /* 0.426661426 */, + /* 6117 */ 0x06d3fc77 | (18 << 27) /* 0.426754444 */, + /* 6118 */ 0x06d45e02 | (18 << 27) /* 0.426847467 */, + /* 6119 */ 0x06d4bf8e | (18 << 27) /* 0.426940495 */, + /* 6120 */ 0x06d5211c | (18 << 27) /* 0.427033528 */, + /* 6121 */ 0x06d582aa | (18 << 27) /* 0.427126566 */, + /* 6122 */ 0x06d5e43a | (18 << 27) /* 0.427219609 */, + /* 6123 */ 0x06d645cc | (18 << 27) /* 0.427312657 */, + /* 6124 */ 0x06d6a75f | (18 << 27) /* 0.427405711 */, + /* 6125 */ 0x06d708f3 | (18 << 27) /* 0.427498769 */, + /* 6126 */ 0x06d76a88 | (18 << 27) /* 0.427591833 */, + /* 6127 */ 0x06d7cc1f | (18 << 27) /* 0.427684901 */, + + /* 6128 */ 0x06d82db8 | (18 << 27) /* 0.427777975 */, + /* 6129 */ 0x06d88f51 | (18 << 27) /* 0.427871054 */, + /* 6130 */ 0x06d8f0ec | (18 << 27) /* 0.427964137 */, + /* 6131 */ 0x06d95288 | (18 << 27) /* 0.428057226 */, + /* 6132 */ 0x06d9b426 | (18 << 27) /* 0.428150320 */, + /* 6133 */ 0x06da15c5 | (18 << 27) /* 0.428243419 */, + /* 6134 */ 0x06da7766 | (18 << 27) /* 0.428336523 */, + /* 6135 */ 0x06dad907 | (18 << 27) /* 0.428429632 */, + /* 6136 */ 0x06db3aaa | (18 << 27) /* 0.428522746 */, + /* 6137 */ 0x06db9c4f | (18 << 27) /* 0.428615865 */, + /* 6138 */ 0x06dbfdf5 | (18 << 27) /* 0.428708989 */, + /* 6139 */ 0x06dc5f9c | (18 << 27) /* 0.428802119 */, + /* 6140 */ 0x06dcc145 | (18 << 27) /* 0.428895253 */, + /* 6141 */ 0x06dd22ee | (18 << 27) /* 0.428988392 */, + /* 6142 */ 0x06dd849a | (18 << 27) /* 0.429081537 */, + /* 6143 */ 0x06dde646 | (18 << 27) /* 0.429174686 */, + + /* 6144 */ 0x06de47f4 | (18 << 27) /* 0.429267841 */, + /* 6145 */ 0x06dea9a4 | (18 << 27) /* 0.429361001 */, + /* 6146 */ 0x06df0b54 | (18 << 27) /* 0.429454165 */, + /* 6147 */ 0x06df6d06 | (18 << 27) /* 0.429547335 */, + /* 6148 */ 0x06dfceba | (18 << 27) /* 0.429640510 */, + /* 6149 */ 0x06e0306f | (18 << 27) /* 0.429733690 */, + /* 6150 */ 0x06e09225 | (18 << 27) /* 0.429826874 */, + /* 6151 */ 0x06e0f3dc | (18 << 27) /* 0.429920064 */, + /* 6152 */ 0x06e15595 | (18 << 27) /* 0.430013259 */, + /* 6153 */ 0x06e1b74f | (18 << 27) /* 0.430106459 */, + /* 6154 */ 0x06e2190b | (18 << 27) /* 0.430199664 */, + /* 6155 */ 0x06e27ac8 | (18 << 27) /* 0.430292875 */, + /* 6156 */ 0x06e2dc86 | (18 << 27) /* 0.430386090 */, + /* 6157 */ 0x06e33e46 | (18 << 27) /* 0.430479310 */, + /* 6158 */ 0x06e3a007 | (18 << 27) /* 0.430572535 */, + /* 6159 */ 0x06e401c9 | (18 << 27) /* 0.430665765 */, + + /* 6160 */ 0x06e4638d | (18 << 27) /* 0.430759001 */, + /* 6161 */ 0x06e4c552 | (18 << 27) /* 0.430852241 */, + /* 6162 */ 0x06e52718 | (18 << 27) /* 0.430945487 */, + /* 6163 */ 0x06e588e0 | (18 << 27) /* 0.431038737 */, + /* 6164 */ 0x06e5eaa9 | (18 << 27) /* 0.431131993 */, + /* 6165 */ 0x06e64c73 | (18 << 27) /* 0.431225253 */, + /* 6166 */ 0x06e6ae3f | (18 << 27) /* 0.431318519 */, + /* 6167 */ 0x06e7100c | (18 << 27) /* 0.431411790 */, + /* 6168 */ 0x06e771db | (18 << 27) /* 0.431505065 */, + /* 6169 */ 0x06e7d3ab | (18 << 27) /* 0.431598346 */, + /* 6170 */ 0x06e8357c | (18 << 27) /* 0.431691632 */, + /* 6171 */ 0x06e8974e | (18 << 27) /* 0.431784923 */, + /* 6172 */ 0x06e8f922 | (18 << 27) /* 0.431878218 */, + /* 6173 */ 0x06e95af8 | (18 << 27) /* 0.431971519 */, + /* 6174 */ 0x06e9bcce | (18 << 27) /* 0.432064825 */, + /* 6175 */ 0x06ea1ea6 | (18 << 27) /* 0.432158136 */, + + /* 6176 */ 0x06ea807f | (18 << 27) /* 0.432251452 */, + /* 6177 */ 0x06eae25a | (18 << 27) /* 0.432344773 */, + /* 6178 */ 0x06eb4436 | (18 << 27) /* 0.432438099 */, + /* 6179 */ 0x06eba614 | (18 << 27) /* 0.432531431 */, + /* 6180 */ 0x06ec07f2 | (18 << 27) /* 0.432624767 */, + /* 6181 */ 0x06ec69d2 | (18 << 27) /* 0.432718108 */, + /* 6182 */ 0x06eccbb4 | (18 << 27) /* 0.432811454 */, + /* 6183 */ 0x06ed2d97 | (18 << 27) /* 0.432904805 */, + /* 6184 */ 0x06ed8f7b | (18 << 27) /* 0.432998162 */, + /* 6185 */ 0x06edf160 | (18 << 27) /* 0.433091523 */, + /* 6186 */ 0x06ee5347 | (18 << 27) /* 0.433184889 */, + /* 6187 */ 0x06eeb52f | (18 << 27) /* 0.433278261 */, + /* 6188 */ 0x06ef1719 | (18 << 27) /* 0.433371637 */, + /* 6189 */ 0x06ef7904 | (18 << 27) /* 0.433465019 */, + /* 6190 */ 0x06efdaf0 | (18 << 27) /* 0.433558405 */, + /* 6191 */ 0x06f03cde | (18 << 27) /* 0.433651797 */, + + /* 6192 */ 0x06f09ecc | (18 << 27) /* 0.433745193 */, + /* 6193 */ 0x06f100bd | (18 << 27) /* 0.433838595 */, + /* 6194 */ 0x06f162ae | (18 << 27) /* 0.433932001 */, + /* 6195 */ 0x06f1c4a1 | (18 << 27) /* 0.434025413 */, + /* 6196 */ 0x06f22696 | (18 << 27) /* 0.434118830 */, + /* 6197 */ 0x06f2888b | (18 << 27) /* 0.434212251 */, + /* 6198 */ 0x06f2ea82 | (18 << 27) /* 0.434305678 */, + /* 6199 */ 0x06f34c7b | (18 << 27) /* 0.434399110 */, + /* 6200 */ 0x06f3ae75 | (18 << 27) /* 0.434492546 */, + /* 6201 */ 0x06f41070 | (18 << 27) /* 0.434585988 */, + /* 6202 */ 0x06f4726c | (18 << 27) /* 0.434679435 */, + /* 6203 */ 0x06f4d46a | (18 << 27) /* 0.434772887 */, + /* 6204 */ 0x06f53669 | (18 << 27) /* 0.434866344 */, + /* 6205 */ 0x06f59869 | (18 << 27) /* 0.434959806 */, + /* 6206 */ 0x06f5fa6b | (18 << 27) /* 0.435053272 */, + /* 6207 */ 0x06f65c6e | (18 << 27) /* 0.435146744 */, + + /* 6208 */ 0x06f6be73 | (18 << 27) /* 0.435240221 */, + /* 6209 */ 0x06f72079 | (18 << 27) /* 0.435333703 */, + /* 6210 */ 0x06f78280 | (18 << 27) /* 0.435427190 */, + /* 6211 */ 0x06f7e489 | (18 << 27) /* 0.435520682 */, + /* 6212 */ 0x06f84693 | (18 << 27) /* 0.435614179 */, + /* 6213 */ 0x06f8a89e | (18 << 27) /* 0.435707681 */, + /* 6214 */ 0x06f90aaa | (18 << 27) /* 0.435801188 */, + /* 6215 */ 0x06f96cb8 | (18 << 27) /* 0.435894700 */, + /* 6216 */ 0x06f9cec8 | (18 << 27) /* 0.435988217 */, + /* 6217 */ 0x06fa30d8 | (18 << 27) /* 0.436081739 */, + /* 6218 */ 0x06fa92ea | (18 << 27) /* 0.436175266 */, + /* 6219 */ 0x06faf4fe | (18 << 27) /* 0.436268799 */, + /* 6220 */ 0x06fb5712 | (18 << 27) /* 0.436362336 */, + /* 6221 */ 0x06fbb928 | (18 << 27) /* 0.436455878 */, + /* 6222 */ 0x06fc1b40 | (18 << 27) /* 0.436549425 */, + /* 6223 */ 0x06fc7d58 | (18 << 27) /* 0.436642977 */, + + /* 6224 */ 0x06fcdf72 | (18 << 27) /* 0.436736534 */, + /* 6225 */ 0x06fd418e | (18 << 27) /* 0.436830096 */, + /* 6226 */ 0x06fda3ab | (18 << 27) /* 0.436923664 */, + /* 6227 */ 0x06fe05c9 | (18 << 27) /* 0.437017236 */, + /* 6228 */ 0x06fe67e8 | (18 << 27) /* 0.437110813 */, + /* 6229 */ 0x06feca09 | (18 << 27) /* 0.437204395 */, + /* 6230 */ 0x06ff2c2b | (18 << 27) /* 0.437297982 */, + /* 6231 */ 0x06ff8e4f | (18 << 27) /* 0.437391575 */, + /* 6232 */ 0x06fff073 | (18 << 27) /* 0.437485172 */, + /* 6233 */ 0x0700529a | (18 << 27) /* 0.437578774 */, + /* 6234 */ 0x0700b4c1 | (18 << 27) /* 0.437672381 */, + /* 6235 */ 0x070116ea | (18 << 27) /* 0.437765994 */, + /* 6236 */ 0x07017914 | (18 << 27) /* 0.437859611 */, + /* 6237 */ 0x0701db40 | (18 << 27) /* 0.437953233 */, + /* 6238 */ 0x07023d6c | (18 << 27) /* 0.438046860 */, + /* 6239 */ 0x07029f9b | (18 << 27) /* 0.438140493 */, + + /* 6240 */ 0x070301ca | (18 << 27) /* 0.438234130 */, + /* 6241 */ 0x070363fb | (18 << 27) /* 0.438327772 */, + /* 6242 */ 0x0703c62d | (18 << 27) /* 0.438421419 */, + /* 6243 */ 0x07042861 | (18 << 27) /* 0.438515072 */, + /* 6244 */ 0x07048a96 | (18 << 27) /* 0.438608729 */, + /* 6245 */ 0x0704eccc | (18 << 27) /* 0.438702391 */, + /* 6246 */ 0x07054f04 | (18 << 27) /* 0.438796059 */, + /* 6247 */ 0x0705b13d | (18 << 27) /* 0.438889731 */, + /* 6248 */ 0x07061377 | (18 << 27) /* 0.438983408 */, + /* 6249 */ 0x070675b3 | (18 << 27) /* 0.439077090 */, + /* 6250 */ 0x0706d7f0 | (18 << 27) /* 0.439170778 */, + /* 6251 */ 0x07073a2e | (18 << 27) /* 0.439264470 */, + /* 6252 */ 0x07079c6e | (18 << 27) /* 0.439358167 */, + /* 6253 */ 0x0707feaf | (18 << 27) /* 0.439451869 */, + /* 6254 */ 0x070860f1 | (18 << 27) /* 0.439545577 */, + /* 6255 */ 0x0708c335 | (18 << 27) /* 0.439639289 */, + + /* 6256 */ 0x0709257a | (18 << 27) /* 0.439733006 */, + /* 6257 */ 0x070987c0 | (18 << 27) /* 0.439826728 */, + /* 6258 */ 0x0709ea08 | (18 << 27) /* 0.439920456 */, + /* 6259 */ 0x070a4c51 | (18 << 27) /* 0.440014188 */, + /* 6260 */ 0x070aae9b | (18 << 27) /* 0.440107925 */, + /* 6261 */ 0x070b10e7 | (18 << 27) /* 0.440201667 */, + /* 6262 */ 0x070b7334 | (18 << 27) /* 0.440295414 */, + /* 6263 */ 0x070bd583 | (18 << 27) /* 0.440389167 */, + /* 6264 */ 0x070c37d2 | (18 << 27) /* 0.440482924 */, + /* 6265 */ 0x070c9a23 | (18 << 27) /* 0.440576686 */, + /* 6266 */ 0x070cfc76 | (18 << 27) /* 0.440670453 */, + /* 6267 */ 0x070d5eca | (18 << 27) /* 0.440764225 */, + /* 6268 */ 0x070dc11f | (18 << 27) /* 0.440858002 */, + /* 6269 */ 0x070e2375 | (18 << 27) /* 0.440951784 */, + /* 6270 */ 0x070e85cd | (18 << 27) /* 0.441045572 */, + /* 6271 */ 0x070ee826 | (18 << 27) /* 0.441139364 */, + + /* 6272 */ 0x070f4a80 | (18 << 27) /* 0.441233161 */, + /* 6273 */ 0x070facdc | (18 << 27) /* 0.441326963 */, + /* 6274 */ 0x07100f39 | (18 << 27) /* 0.441420770 */, + /* 6275 */ 0x07107198 | (18 << 27) /* 0.441514582 */, + /* 6276 */ 0x0710d3f8 | (18 << 27) /* 0.441608399 */, + /* 6277 */ 0x07113659 | (18 << 27) /* 0.441702221 */, + /* 6278 */ 0x071198bb | (18 << 27) /* 0.441796048 */, + /* 6279 */ 0x0711fb1f | (18 << 27) /* 0.441889880 */, + /* 6280 */ 0x07125d84 | (18 << 27) /* 0.441983717 */, + /* 6281 */ 0x0712bfeb | (18 << 27) /* 0.442077559 */, + /* 6282 */ 0x07132253 | (18 << 27) /* 0.442171406 */, + /* 6283 */ 0x071384bc | (18 << 27) /* 0.442265257 */, + /* 6284 */ 0x0713e726 | (18 << 27) /* 0.442359114 */, + /* 6285 */ 0x07144992 | (18 << 27) /* 0.442452976 */, + /* 6286 */ 0x0714abff | (18 << 27) /* 0.442546843 */, + /* 6287 */ 0x07150e6e | (18 << 27) /* 0.442640715 */, + + /* 6288 */ 0x071570de | (18 << 27) /* 0.442734592 */, + /* 6289 */ 0x0715d34f | (18 << 27) /* 0.442828473 */, + /* 6290 */ 0x071635c1 | (18 << 27) /* 0.442922360 */, + /* 6291 */ 0x07169835 | (18 << 27) /* 0.443016252 */, + /* 6292 */ 0x0716faaa | (18 << 27) /* 0.443110148 */, + /* 6293 */ 0x07175d21 | (18 << 27) /* 0.443204050 */, + /* 6294 */ 0x0717bf99 | (18 << 27) /* 0.443297957 */, + /* 6295 */ 0x07182212 | (18 << 27) /* 0.443391868 */, + /* 6296 */ 0x0718848d | (18 << 27) /* 0.443485785 */, + /* 6297 */ 0x0718e709 | (18 << 27) /* 0.443579706 */, + /* 6298 */ 0x07194986 | (18 << 27) /* 0.443673633 */, + /* 6299 */ 0x0719ac04 | (18 << 27) /* 0.443767564 */, + /* 6300 */ 0x071a0e84 | (18 << 27) /* 0.443861501 */, + /* 6301 */ 0x071a7105 | (18 << 27) /* 0.443955442 */, + /* 6302 */ 0x071ad388 | (18 << 27) /* 0.444049389 */, + /* 6303 */ 0x071b360c | (18 << 27) /* 0.444143340 */, + + /* 6304 */ 0x071b9891 | (18 << 27) /* 0.444237296 */, + /* 6305 */ 0x071bfb18 | (18 << 27) /* 0.444331258 */, + /* 6306 */ 0x071c5d9f | (18 << 27) /* 0.444425224 */, + /* 6307 */ 0x071cc029 | (18 << 27) /* 0.444519195 */, + /* 6308 */ 0x071d22b3 | (18 << 27) /* 0.444613171 */, + /* 6309 */ 0x071d853f | (18 << 27) /* 0.444707153 */, + /* 6310 */ 0x071de7cc | (18 << 27) /* 0.444801139 */, + /* 6311 */ 0x071e4a5b | (18 << 27) /* 0.444895130 */, + /* 6312 */ 0x071eaceb | (18 << 27) /* 0.444989126 */, + /* 6313 */ 0x071f0f7c | (18 << 27) /* 0.445083127 */, + /* 6314 */ 0x071f720e | (18 << 27) /* 0.445177133 */, + /* 6315 */ 0x071fd4a2 | (18 << 27) /* 0.445271144 */, + /* 6316 */ 0x07203737 | (18 << 27) /* 0.445365160 */, + /* 6317 */ 0x072099ce | (18 << 27) /* 0.445459181 */, + /* 6318 */ 0x0720fc66 | (18 << 27) /* 0.445553206 */, + /* 6319 */ 0x07215eff | (18 << 27) /* 0.445647237 */, + + /* 6320 */ 0x0721c19a | (18 << 27) /* 0.445741273 */, + /* 6321 */ 0x07222436 | (18 << 27) /* 0.445835314 */, + /* 6322 */ 0x072286d3 | (18 << 27) /* 0.445929359 */, + /* 6323 */ 0x0722e971 | (18 << 27) /* 0.446023410 */, + /* 6324 */ 0x07234c11 | (18 << 27) /* 0.446117466 */, + /* 6325 */ 0x0723aeb2 | (18 << 27) /* 0.446211526 */, + /* 6326 */ 0x07241155 | (18 << 27) /* 0.446305592 */, + /* 6327 */ 0x072473f9 | (18 << 27) /* 0.446399662 */, + /* 6328 */ 0x0724d69e | (18 << 27) /* 0.446493738 */, + /* 6329 */ 0x07253944 | (18 << 27) /* 0.446587818 */, + /* 6330 */ 0x07259bec | (18 << 27) /* 0.446681903 */, + /* 6331 */ 0x0725fe95 | (18 << 27) /* 0.446775994 */, + /* 6332 */ 0x07266140 | (18 << 27) /* 0.446870089 */, + /* 6333 */ 0x0726c3ec | (18 << 27) /* 0.446964189 */, + /* 6334 */ 0x07272699 | (18 << 27) /* 0.447058294 */, + /* 6335 */ 0x07278947 | (18 << 27) /* 0.447152404 */, + + /* 6336 */ 0x0727ebf7 | (18 << 27) /* 0.447246519 */, + /* 6337 */ 0x07284ea8 | (18 << 27) /* 0.447340639 */, + /* 6338 */ 0x0728b15b | (18 << 27) /* 0.447434764 */, + /* 6339 */ 0x0729140f | (18 << 27) /* 0.447528894 */, + /* 6340 */ 0x072976c4 | (18 << 27) /* 0.447623029 */, + /* 6341 */ 0x0729d97a | (18 << 27) /* 0.447717169 */, + /* 6342 */ 0x072a3c32 | (18 << 27) /* 0.447811314 */, + /* 6343 */ 0x072a9eeb | (18 << 27) /* 0.447905463 */, + /* 6344 */ 0x072b01a6 | (18 << 27) /* 0.447999618 */, + /* 6345 */ 0x072b6461 | (18 << 27) /* 0.448093778 */, + /* 6346 */ 0x072bc71e | (18 << 27) /* 0.448187942 */, + /* 6347 */ 0x072c29dd | (18 << 27) /* 0.448282112 */, + /* 6348 */ 0x072c8c9d | (18 << 27) /* 0.448376286 */, + /* 6349 */ 0x072cef5e | (18 << 27) /* 0.448470466 */, + /* 6350 */ 0x072d5220 | (18 << 27) /* 0.448564650 */, + /* 6351 */ 0x072db4e4 | (18 << 27) /* 0.448658839 */, + + /* 6352 */ 0x072e17a9 | (18 << 27) /* 0.448753033 */, + /* 6353 */ 0x072e7a6f | (18 << 27) /* 0.448847233 */, + /* 6354 */ 0x072edd37 | (18 << 27) /* 0.448941437 */, + /* 6355 */ 0x072f4000 | (18 << 27) /* 0.449035646 */, + /* 6356 */ 0x072fa2ca | (18 << 27) /* 0.449129860 */, + /* 6357 */ 0x07300596 | (18 << 27) /* 0.449224079 */, + /* 6358 */ 0x07306863 | (18 << 27) /* 0.449318303 */, + /* 6359 */ 0x0730cb32 | (18 << 27) /* 0.449412531 */, + /* 6360 */ 0x07312e01 | (18 << 27) /* 0.449506765 */, + /* 6361 */ 0x073190d2 | (18 << 27) /* 0.449601004 */, + /* 6362 */ 0x0731f3a5 | (18 << 27) /* 0.449695247 */, + /* 6363 */ 0x07325678 | (18 << 27) /* 0.449789496 */, + /* 6364 */ 0x0732b94d | (18 << 27) /* 0.449883749 */, + /* 6365 */ 0x07331c23 | (18 << 27) /* 0.449978008 */, + /* 6366 */ 0x07337efb | (18 << 27) /* 0.450072271 */, + /* 6367 */ 0x0733e1d4 | (18 << 27) /* 0.450166540 */, + + /* 6368 */ 0x073444ae | (18 << 27) /* 0.450260813 */, + /* 6369 */ 0x0734a78a | (18 << 27) /* 0.450355091 */, + /* 6370 */ 0x07350a67 | (18 << 27) /* 0.450449374 */, + /* 6371 */ 0x07356d45 | (18 << 27) /* 0.450543662 */, + /* 6372 */ 0x0735d025 | (18 << 27) /* 0.450637955 */, + /* 6373 */ 0x07363306 | (18 << 27) /* 0.450732253 */, + /* 6374 */ 0x073695e8 | (18 << 27) /* 0.450826556 */, + /* 6375 */ 0x0736f8cb | (18 << 27) /* 0.450920864 */, + /* 6376 */ 0x07375bb0 | (18 << 27) /* 0.451015176 */, + /* 6377 */ 0x0737be96 | (18 << 27) /* 0.451109494 */, + /* 6378 */ 0x0738217e | (18 << 27) /* 0.451203817 */, + /* 6379 */ 0x07388467 | (18 << 27) /* 0.451298144 */, + /* 6380 */ 0x0738e751 | (18 << 27) /* 0.451392477 */, + /* 6381 */ 0x07394a3d | (18 << 27) /* 0.451486814 */, + /* 6382 */ 0x0739ad29 | (18 << 27) /* 0.451581156 */, + /* 6383 */ 0x073a1017 | (18 << 27) /* 0.451675503 */, + + /* 6384 */ 0x073a7307 | (18 << 27) /* 0.451769856 */, + /* 6385 */ 0x073ad5f8 | (18 << 27) /* 0.451864213 */, + /* 6386 */ 0x073b38ea | (18 << 27) /* 0.451958575 */, + /* 6387 */ 0x073b9bdd | (18 << 27) /* 0.452052942 */, + /* 6388 */ 0x073bfed2 | (18 << 27) /* 0.452147313 */, + /* 6389 */ 0x073c61c8 | (18 << 27) /* 0.452241690 */, + /* 6390 */ 0x073cc4bf | (18 << 27) /* 0.452336072 */, + /* 6391 */ 0x073d27b8 | (18 << 27) /* 0.452430458 */, + /* 6392 */ 0x073d8ab2 | (18 << 27) /* 0.452524850 */, + /* 6393 */ 0x073dedae | (18 << 27) /* 0.452619246 */, + /* 6394 */ 0x073e50aa | (18 << 27) /* 0.452713648 */, + /* 6395 */ 0x073eb3a8 | (18 << 27) /* 0.452808054 */, + /* 6396 */ 0x073f16a8 | (18 << 27) /* 0.452902465 */, + /* 6397 */ 0x073f79a8 | (18 << 27) /* 0.452996882 */, + /* 6398 */ 0x073fdcaa | (18 << 27) /* 0.453091303 */, + /* 6399 */ 0x07403fad | (18 << 27) /* 0.453185729 */, + + /* 6400 */ 0x0740a2b2 | (18 << 27) /* 0.453280160 */, + /* 6401 */ 0x074105b8 | (18 << 27) /* 0.453374595 */, + /* 6402 */ 0x074168bf | (18 << 27) /* 0.453469036 */, + /* 6403 */ 0x0741cbc8 | (18 << 27) /* 0.453563482 */, + /* 6404 */ 0x07422ed2 | (18 << 27) /* 0.453657932 */, + /* 6405 */ 0x074291dd | (18 << 27) /* 0.453752388 */, + /* 6406 */ 0x0742f4e9 | (18 << 27) /* 0.453846848 */, + /* 6407 */ 0x074357f7 | (18 << 27) /* 0.453941314 */, + /* 6408 */ 0x0743bb06 | (18 << 27) /* 0.454035784 */, + /* 6409 */ 0x07441e17 | (18 << 27) /* 0.454130259 */, + /* 6410 */ 0x07448129 | (18 << 27) /* 0.454224739 */, + /* 6411 */ 0x0744e43c | (18 << 27) /* 0.454319224 */, + /* 6412 */ 0x07454750 | (18 << 27) /* 0.454413714 */, + /* 6413 */ 0x0745aa66 | (18 << 27) /* 0.454508209 */, + /* 6414 */ 0x07460d7d | (18 << 27) /* 0.454602708 */, + /* 6415 */ 0x07467095 | (18 << 27) /* 0.454697213 */, + + /* 6416 */ 0x0746d3af | (18 << 27) /* 0.454791723 */, + /* 6417 */ 0x074736ca | (18 << 27) /* 0.454886237 */, + /* 6418 */ 0x074799e7 | (18 << 27) /* 0.454980756 */, + /* 6419 */ 0x0747fd04 | (18 << 27) /* 0.455075281 */, + /* 6420 */ 0x07486023 | (18 << 27) /* 0.455169810 */, + /* 6421 */ 0x0748c344 | (18 << 27) /* 0.455264344 */, + /* 6422 */ 0x07492665 | (18 << 27) /* 0.455358883 */, + /* 6423 */ 0x07498988 | (18 << 27) /* 0.455453427 */, + /* 6424 */ 0x0749ecac | (18 << 27) /* 0.455547976 */, + /* 6425 */ 0x074a4fd2 | (18 << 27) /* 0.455642529 */, + /* 6426 */ 0x074ab2f9 | (18 << 27) /* 0.455737088 */, + /* 6427 */ 0x074b1621 | (18 << 27) /* 0.455831652 */, + /* 6428 */ 0x074b794b | (18 << 27) /* 0.455926220 */, + /* 6429 */ 0x074bdc75 | (18 << 27) /* 0.456020793 */, + /* 6430 */ 0x074c3fa1 | (18 << 27) /* 0.456115372 */, + /* 6431 */ 0x074ca2cf | (18 << 27) /* 0.456209955 */, + + /* 6432 */ 0x074d05fe | (18 << 27) /* 0.456304543 */, + /* 6433 */ 0x074d692e | (18 << 27) /* 0.456399136 */, + /* 6434 */ 0x074dcc5f | (18 << 27) /* 0.456493733 */, + /* 6435 */ 0x074e2f92 | (18 << 27) /* 0.456588336 */, + /* 6436 */ 0x074e92c6 | (18 << 27) /* 0.456682944 */, + /* 6437 */ 0x074ef5fb | (18 << 27) /* 0.456777556 */, + /* 6438 */ 0x074f5932 | (18 << 27) /* 0.456872174 */, + /* 6439 */ 0x074fbc6a | (18 << 27) /* 0.456966796 */, + /* 6440 */ 0x07501fa3 | (18 << 27) /* 0.457061423 */, + /* 6441 */ 0x075082de | (18 << 27) /* 0.457156056 */, + /* 6442 */ 0x0750e61a | (18 << 27) /* 0.457250693 */, + /* 6443 */ 0x07514957 | (18 << 27) /* 0.457345335 */, + /* 6444 */ 0x0751ac96 | (18 << 27) /* 0.457439981 */, + /* 6445 */ 0x07520fd6 | (18 << 27) /* 0.457534633 */, + /* 6446 */ 0x07527317 | (18 << 27) /* 0.457629290 */, + /* 6447 */ 0x0752d659 | (18 << 27) /* 0.457723951 */, + + /* 6448 */ 0x0753399d | (18 << 27) /* 0.457818618 */, + /* 6449 */ 0x07539ce2 | (18 << 27) /* 0.457913289 */, + /* 6450 */ 0x07540029 | (18 << 27) /* 0.458007965 */, + /* 6451 */ 0x07546371 | (18 << 27) /* 0.458102646 */, + /* 6452 */ 0x0754c6ba | (18 << 27) /* 0.458197332 */, + /* 6453 */ 0x07552a04 | (18 << 27) /* 0.458292023 */, + /* 6454 */ 0x07558d50 | (18 << 27) /* 0.458386719 */, + /* 6455 */ 0x0755f09d | (18 << 27) /* 0.458481420 */, + /* 6456 */ 0x075653eb | (18 << 27) /* 0.458576125 */, + /* 6457 */ 0x0756b73b | (18 << 27) /* 0.458670836 */, + /* 6458 */ 0x07571a8c | (18 << 27) /* 0.458765551 */, + /* 6459 */ 0x07577dde | (18 << 27) /* 0.458860271 */, + /* 6460 */ 0x0757e131 | (18 << 27) /* 0.458954996 */, + /* 6461 */ 0x07584486 | (18 << 27) /* 0.459049726 */, + /* 6462 */ 0x0758a7dd | (18 << 27) /* 0.459144461 */, + /* 6463 */ 0x07590b34 | (18 << 27) /* 0.459239201 */, + + /* 6464 */ 0x07596e8d | (18 << 27) /* 0.459333946 */, + /* 6465 */ 0x0759d1e7 | (18 << 27) /* 0.459428695 */, + /* 6466 */ 0x075a3542 | (18 << 27) /* 0.459523450 */, + /* 6467 */ 0x075a989f | (18 << 27) /* 0.459618209 */, + /* 6468 */ 0x075afbfd | (18 << 27) /* 0.459712973 */, + /* 6469 */ 0x075b5f5d | (18 << 27) /* 0.459807742 */, + /* 6470 */ 0x075bc2bd | (18 << 27) /* 0.459902516 */, + /* 6471 */ 0x075c261f | (18 << 27) /* 0.459997295 */, + /* 6472 */ 0x075c8983 | (18 << 27) /* 0.460092079 */, + /* 6473 */ 0x075cece7 | (18 << 27) /* 0.460186867 */, + /* 6474 */ 0x075d504d | (18 << 27) /* 0.460281661 */, + /* 6475 */ 0x075db3b5 | (18 << 27) /* 0.460376459 */, + /* 6476 */ 0x075e171d | (18 << 27) /* 0.460471262 */, + /* 6477 */ 0x075e7a87 | (18 << 27) /* 0.460566071 */, + /* 6478 */ 0x075eddf2 | (18 << 27) /* 0.460660884 */, + /* 6479 */ 0x075f415f | (18 << 27) /* 0.460755701 */, + + /* 6480 */ 0x075fa4cc | (18 << 27) /* 0.460850524 */, + /* 6481 */ 0x0760083b | (18 << 27) /* 0.460945352 */, + /* 6482 */ 0x07606bac | (18 << 27) /* 0.461040184 */, + /* 6483 */ 0x0760cf1e | (18 << 27) /* 0.461135022 */, + /* 6484 */ 0x07613291 | (18 << 27) /* 0.461229864 */, + /* 6485 */ 0x07619605 | (18 << 27) /* 0.461324711 */, + /* 6486 */ 0x0761f97b | (18 << 27) /* 0.461419563 */, + /* 6487 */ 0x07625cf2 | (18 << 27) /* 0.461514420 */, + /* 6488 */ 0x0762c06a | (18 << 27) /* 0.461609282 */, + /* 6489 */ 0x076323e3 | (18 << 27) /* 0.461704149 */, + /* 6490 */ 0x0763875e | (18 << 27) /* 0.461799020 */, + /* 6491 */ 0x0763eadb | (18 << 27) /* 0.461893897 */, + /* 6492 */ 0x07644e58 | (18 << 27) /* 0.461988778 */, + /* 6493 */ 0x0764b1d7 | (18 << 27) /* 0.462083664 */, + /* 6494 */ 0x07651557 | (18 << 27) /* 0.462178555 */, + /* 6495 */ 0x076578d8 | (18 << 27) /* 0.462273451 */, + + /* 6496 */ 0x0765dc5b | (18 << 27) /* 0.462368352 */, + /* 6497 */ 0x07663fdf | (18 << 27) /* 0.462463257 */, + /* 6498 */ 0x0766a364 | (18 << 27) /* 0.462558168 */, + /* 6499 */ 0x076706eb | (18 << 27) /* 0.462653083 */, + /* 6500 */ 0x07676a73 | (18 << 27) /* 0.462748003 */, + /* 6501 */ 0x0767cdfc | (18 << 27) /* 0.462842928 */, + /* 6502 */ 0x07683187 | (18 << 27) /* 0.462937858 */, + /* 6503 */ 0x07689513 | (18 << 27) /* 0.463032793 */, + /* 6504 */ 0x0768f8a0 | (18 << 27) /* 0.463127733 */, + /* 6505 */ 0x07695c2e | (18 << 27) /* 0.463222678 */, + /* 6506 */ 0x0769bfbe | (18 << 27) /* 0.463317627 */, + /* 6507 */ 0x076a234f | (18 << 27) /* 0.463412581 */, + /* 6508 */ 0x076a86e2 | (18 << 27) /* 0.463507540 */, + /* 6509 */ 0x076aea75 | (18 << 27) /* 0.463602504 */, + /* 6510 */ 0x076b4e0a | (18 << 27) /* 0.463697473 */, + /* 6511 */ 0x076bb1a1 | (18 << 27) /* 0.463792447 */, + + /* 6512 */ 0x076c1538 | (18 << 27) /* 0.463887426 */, + /* 6513 */ 0x076c78d1 | (18 << 27) /* 0.463982409 */, + /* 6514 */ 0x076cdc6c | (18 << 27) /* 0.464077398 */, + /* 6515 */ 0x076d4007 | (18 << 27) /* 0.464172391 */, + /* 6516 */ 0x076da3a4 | (18 << 27) /* 0.464267389 */, + /* 6517 */ 0x076e0742 | (18 << 27) /* 0.464362392 */, + /* 6518 */ 0x076e6ae2 | (18 << 27) /* 0.464457399 */, + /* 6519 */ 0x076ece82 | (18 << 27) /* 0.464552412 */, + /* 6520 */ 0x076f3224 | (18 << 27) /* 0.464647430 */, + /* 6521 */ 0x076f95c8 | (18 << 27) /* 0.464742452 */, + /* 6522 */ 0x076ff96c | (18 << 27) /* 0.464837479 */, + /* 6523 */ 0x07705d12 | (18 << 27) /* 0.464932511 */, + /* 6524 */ 0x0770c0ba | (18 << 27) /* 0.465027548 */, + /* 6525 */ 0x07712462 | (18 << 27) /* 0.465122590 */, + /* 6526 */ 0x0771880c | (18 << 27) /* 0.465217637 */, + /* 6527 */ 0x0771ebb7 | (18 << 27) /* 0.465312688 */, + + /* 6528 */ 0x07724f64 | (18 << 27) /* 0.465407744 */, + /* 6529 */ 0x0772b312 | (18 << 27) /* 0.465502806 */, + /* 6530 */ 0x077316c1 | (18 << 27) /* 0.465597872 */, + /* 6531 */ 0x07737a71 | (18 << 27) /* 0.465692943 */, + /* 6532 */ 0x0773de23 | (18 << 27) /* 0.465788018 */, + /* 6533 */ 0x077441d6 | (18 << 27) /* 0.465883099 */, + /* 6534 */ 0x0774a58a | (18 << 27) /* 0.465978184 */, + /* 6535 */ 0x07750940 | (18 << 27) /* 0.466073275 */, + /* 6536 */ 0x07756cf7 | (18 << 27) /* 0.466168370 */, + /* 6537 */ 0x0775d0af | (18 << 27) /* 0.466263470 */, + /* 6538 */ 0x07763468 | (18 << 27) /* 0.466358575 */, + /* 6539 */ 0x07769823 | (18 << 27) /* 0.466453684 */, + /* 6540 */ 0x0776fbdf | (18 << 27) /* 0.466548799 */, + /* 6541 */ 0x07775f9d | (18 << 27) /* 0.466643918 */, + /* 6542 */ 0x0777c35c | (18 << 27) /* 0.466739043 */, + /* 6543 */ 0x0778271c | (18 << 27) /* 0.466834172 */, + + /* 6544 */ 0x07788add | (18 << 27) /* 0.466929306 */, + /* 6545 */ 0x0778ee9f | (18 << 27) /* 0.467024445 */, + /* 6546 */ 0x07795263 | (18 << 27) /* 0.467119588 */, + /* 6547 */ 0x0779b629 | (18 << 27) /* 0.467214737 */, + /* 6548 */ 0x077a19ef | (18 << 27) /* 0.467309890 */, + /* 6549 */ 0x077a7db7 | (18 << 27) /* 0.467405048 */, + /* 6550 */ 0x077ae180 | (18 << 27) /* 0.467500211 */, + /* 6551 */ 0x077b454b | (18 << 27) /* 0.467595379 */, + /* 6552 */ 0x077ba916 | (18 << 27) /* 0.467690552 */, + /* 6553 */ 0x077c0ce3 | (18 << 27) /* 0.467785729 */, + /* 6554 */ 0x077c70b2 | (18 << 27) /* 0.467880912 */, + /* 6555 */ 0x077cd481 | (18 << 27) /* 0.467976099 */, + /* 6556 */ 0x077d3852 | (18 << 27) /* 0.468071291 */, + /* 6557 */ 0x077d9c24 | (18 << 27) /* 0.468166488 */, + /* 6558 */ 0x077dfff8 | (18 << 27) /* 0.468261690 */, + /* 6559 */ 0x077e63cd | (18 << 27) /* 0.468356896 */, + + /* 6560 */ 0x077ec7a3 | (18 << 27) /* 0.468452108 */, + /* 6561 */ 0x077f2b7a | (18 << 27) /* 0.468547324 */, + /* 6562 */ 0x077f8f53 | (18 << 27) /* 0.468642545 */, + /* 6563 */ 0x077ff32d | (18 << 27) /* 0.468737771 */, + /* 6564 */ 0x07805708 | (18 << 27) /* 0.468833002 */, + /* 6565 */ 0x0780bae5 | (18 << 27) /* 0.468928237 */, + /* 6566 */ 0x07811ec3 | (18 << 27) /* 0.469023478 */, + /* 6567 */ 0x078182a2 | (18 << 27) /* 0.469118723 */, + /* 6568 */ 0x0781e683 | (18 << 27) /* 0.469213973 */, + /* 6569 */ 0x07824a64 | (18 << 27) /* 0.469309228 */, + /* 6570 */ 0x0782ae47 | (18 << 27) /* 0.469404488 */, + /* 6571 */ 0x0783122c | (18 << 27) /* 0.469499752 */, + /* 6572 */ 0x07837612 | (18 << 27) /* 0.469595022 */, + /* 6573 */ 0x0783d9f9 | (18 << 27) /* 0.469690296 */, + /* 6574 */ 0x07843de1 | (18 << 27) /* 0.469785575 */, + /* 6575 */ 0x0784a1ca | (18 << 27) /* 0.469880859 */, + + /* 6576 */ 0x078505b5 | (18 << 27) /* 0.469976148 */, + /* 6577 */ 0x078569a2 | (18 << 27) /* 0.470071442 */, + /* 6578 */ 0x0785cd8f | (18 << 27) /* 0.470166740 */, + /* 6579 */ 0x0786317e | (18 << 27) /* 0.470262043 */, + /* 6580 */ 0x0786956e | (18 << 27) /* 0.470357351 */, + /* 6581 */ 0x0786f95f | (18 << 27) /* 0.470452664 */, + /* 6582 */ 0x07875d52 | (18 << 27) /* 0.470547982 */, + /* 6583 */ 0x0787c146 | (18 << 27) /* 0.470643305 */, + /* 6584 */ 0x0788253b | (18 << 27) /* 0.470738632 */, + /* 6585 */ 0x07888932 | (18 << 27) /* 0.470833964 */, + /* 6586 */ 0x0788ed2a | (18 << 27) /* 0.470929301 */, + /* 6587 */ 0x07895123 | (18 << 27) /* 0.471024643 */, + /* 6588 */ 0x0789b51d | (18 << 27) /* 0.471119990 */, + /* 6589 */ 0x078a1919 | (18 << 27) /* 0.471215341 */, + /* 6590 */ 0x078a7d16 | (18 << 27) /* 0.471310698 */, + /* 6591 */ 0x078ae114 | (18 << 27) /* 0.471406059 */, + + /* 6592 */ 0x078b4514 | (18 << 27) /* 0.471501425 */, + /* 6593 */ 0x078ba915 | (18 << 27) /* 0.471596796 */, + /* 6594 */ 0x078c0d17 | (18 << 27) /* 0.471692171 */, + /* 6595 */ 0x078c711a | (18 << 27) /* 0.471787552 */, + /* 6596 */ 0x078cd51f | (18 << 27) /* 0.471882937 */, + /* 6597 */ 0x078d3925 | (18 << 27) /* 0.471978327 */, + /* 6598 */ 0x078d9d2d | (18 << 27) /* 0.472073722 */, + /* 6599 */ 0x078e0135 | (18 << 27) /* 0.472169122 */, + /* 6600 */ 0x078e653f | (18 << 27) /* 0.472264527 */, + /* 6601 */ 0x078ec94b | (18 << 27) /* 0.472359936 */, + /* 6602 */ 0x078f2d57 | (18 << 27) /* 0.472455350 */, + /* 6603 */ 0x078f9165 | (18 << 27) /* 0.472550769 */, + /* 6604 */ 0x078ff574 | (18 << 27) /* 0.472646193 */, + /* 6605 */ 0x07905985 | (18 << 27) /* 0.472741622 */, + /* 6606 */ 0x0790bd96 | (18 << 27) /* 0.472837055 */, + /* 6607 */ 0x079121a9 | (18 << 27) /* 0.472932493 */, + + /* 6608 */ 0x079185be | (18 << 27) /* 0.473027937 */, + /* 6609 */ 0x0791e9d3 | (18 << 27) /* 0.473123384 */, + /* 6610 */ 0x07924dea | (18 << 27) /* 0.473218837 */, + /* 6611 */ 0x0792b202 | (18 << 27) /* 0.473314295 */, + /* 6612 */ 0x0793161c | (18 << 27) /* 0.473409757 */, + /* 6613 */ 0x07937a37 | (18 << 27) /* 0.473505224 */, + /* 6614 */ 0x0793de53 | (18 << 27) /* 0.473600696 */, + /* 6615 */ 0x07944270 | (18 << 27) /* 0.473696173 */, + /* 6616 */ 0x0794a68f | (18 << 27) /* 0.473791655 */, + /* 6617 */ 0x07950aaf | (18 << 27) /* 0.473887141 */, + /* 6618 */ 0x07956ed0 | (18 << 27) /* 0.473982632 */, + /* 6619 */ 0x0795d2f2 | (18 << 27) /* 0.474078128 */, + /* 6620 */ 0x07963716 | (18 << 27) /* 0.474173629 */, + /* 6621 */ 0x07969b3b | (18 << 27) /* 0.474269135 */, + /* 6622 */ 0x0796ff62 | (18 << 27) /* 0.474364645 */, + /* 6623 */ 0x07976389 | (18 << 27) /* 0.474460161 */, + + /* 6624 */ 0x0797c7b2 | (18 << 27) /* 0.474555681 */, + /* 6625 */ 0x07982bdd | (18 << 27) /* 0.474651205 */, + /* 6626 */ 0x07989008 | (18 << 27) /* 0.474746735 */, + /* 6627 */ 0x0798f435 | (18 << 27) /* 0.474842270 */, + /* 6628 */ 0x07995863 | (18 << 27) /* 0.474937809 */, + /* 6629 */ 0x0799bc92 | (18 << 27) /* 0.475033353 */, + /* 6630 */ 0x079a20c3 | (18 << 27) /* 0.475128902 */, + /* 6631 */ 0x079a84f5 | (18 << 27) /* 0.475224456 */, + /* 6632 */ 0x079ae929 | (18 << 27) /* 0.475320014 */, + /* 6633 */ 0x079b4d5d | (18 << 27) /* 0.475415578 */, + /* 6634 */ 0x079bb193 | (18 << 27) /* 0.475511146 */, + /* 6635 */ 0x079c15ca | (18 << 27) /* 0.475606719 */, + /* 6636 */ 0x079c7a03 | (18 << 27) /* 0.475702296 */, + /* 6637 */ 0x079cde3c | (18 << 27) /* 0.475797879 */, + /* 6638 */ 0x079d4277 | (18 << 27) /* 0.475893466 */, + /* 6639 */ 0x079da6b4 | (18 << 27) /* 0.475989058 */, + + /* 6640 */ 0x079e0af1 | (18 << 27) /* 0.476084655 */, + /* 6641 */ 0x079e6f30 | (18 << 27) /* 0.476180257 */, + /* 6642 */ 0x079ed370 | (18 << 27) /* 0.476275863 */, + /* 6643 */ 0x079f37b2 | (18 << 27) /* 0.476371475 */, + /* 6644 */ 0x079f9bf5 | (18 << 27) /* 0.476467091 */, + /* 6645 */ 0x07a00039 | (18 << 27) /* 0.476562712 */, + /* 6646 */ 0x07a0647e | (18 << 27) /* 0.476658338 */, + /* 6647 */ 0x07a0c8c5 | (18 << 27) /* 0.476753968 */, + /* 6648 */ 0x07a12d0c | (18 << 27) /* 0.476849603 */, + /* 6649 */ 0x07a19156 | (18 << 27) /* 0.476945243 */, + /* 6650 */ 0x07a1f5a0 | (18 << 27) /* 0.477040888 */, + /* 6651 */ 0x07a259ec | (18 << 27) /* 0.477136538 */, + /* 6652 */ 0x07a2be39 | (18 << 27) /* 0.477232193 */, + /* 6653 */ 0x07a32287 | (18 << 27) /* 0.477327852 */, + /* 6654 */ 0x07a386d7 | (18 << 27) /* 0.477423516 */, + /* 6655 */ 0x07a3eb28 | (18 << 27) /* 0.477519185 */, + + /* 6656 */ 0x07a44f7a | (18 << 27) /* 0.477614858 */, + /* 6657 */ 0x07a4b3ce | (18 << 27) /* 0.477710537 */, + /* 6658 */ 0x07a51822 | (18 << 27) /* 0.477806220 */, + /* 6659 */ 0x07a57c78 | (18 << 27) /* 0.477901908 */, + /* 6660 */ 0x07a5e0d0 | (18 << 27) /* 0.477997601 */, + /* 6661 */ 0x07a64528 | (18 << 27) /* 0.478093299 */, + /* 6662 */ 0x07a6a982 | (18 << 27) /* 0.478189001 */, + /* 6663 */ 0x07a70ddd | (18 << 27) /* 0.478284708 */, + /* 6664 */ 0x07a7723a | (18 << 27) /* 0.478380420 */, + /* 6665 */ 0x07a7d698 | (18 << 27) /* 0.478476137 */, + /* 6666 */ 0x07a83af7 | (18 << 27) /* 0.478571858 */, + /* 6667 */ 0x07a89f57 | (18 << 27) /* 0.478667585 */, + /* 6668 */ 0x07a903b9 | (18 << 27) /* 0.478763316 */, + /* 6669 */ 0x07a9681c | (18 << 27) /* 0.478859052 */, + /* 6670 */ 0x07a9cc80 | (18 << 27) /* 0.478954793 */, + /* 6671 */ 0x07aa30e5 | (18 << 27) /* 0.479050538 */, + + /* 6672 */ 0x07aa954c | (18 << 27) /* 0.479146288 */, + /* 6673 */ 0x07aaf9b4 | (18 << 27) /* 0.479242043 */, + /* 6674 */ 0x07ab5e1e | (18 << 27) /* 0.479337803 */, + /* 6675 */ 0x07abc288 | (18 << 27) /* 0.479433568 */, + /* 6676 */ 0x07ac26f4 | (18 << 27) /* 0.479529337 */, + /* 6677 */ 0x07ac8b61 | (18 << 27) /* 0.479625111 */, + /* 6678 */ 0x07acefd0 | (18 << 27) /* 0.479720890 */, + /* 6679 */ 0x07ad543f | (18 << 27) /* 0.479816674 */, + /* 6680 */ 0x07adb8b0 | (18 << 27) /* 0.479912463 */, + /* 6681 */ 0x07ae1d23 | (18 << 27) /* 0.480008256 */, + /* 6682 */ 0x07ae8196 | (18 << 27) /* 0.480104054 */, + /* 6683 */ 0x07aee60b | (18 << 27) /* 0.480199857 */, + /* 6684 */ 0x07af4a81 | (18 << 27) /* 0.480295664 */, + /* 6685 */ 0x07afaef9 | (18 << 27) /* 0.480391477 */, + /* 6686 */ 0x07b01372 | (18 << 27) /* 0.480487294 */, + /* 6687 */ 0x07b077ec | (18 << 27) /* 0.480583116 */, + + /* 6688 */ 0x07b0dc67 | (18 << 27) /* 0.480678943 */, + /* 6689 */ 0x07b140e4 | (18 << 27) /* 0.480774774 */, + /* 6690 */ 0x07b1a561 | (18 << 27) /* 0.480870611 */, + /* 6691 */ 0x07b209e1 | (18 << 27) /* 0.480966452 */, + /* 6692 */ 0x07b26e61 | (18 << 27) /* 0.481062298 */, + /* 6693 */ 0x07b2d2e3 | (18 << 27) /* 0.481158148 */, + /* 6694 */ 0x07b33766 | (18 << 27) /* 0.481254004 */, + /* 6695 */ 0x07b39bea | (18 << 27) /* 0.481349864 */, + /* 6696 */ 0x07b4006f | (18 << 27) /* 0.481445729 */, + /* 6697 */ 0x07b464f6 | (18 << 27) /* 0.481541598 */, + /* 6698 */ 0x07b4c97e | (18 << 27) /* 0.481637473 */, + /* 6699 */ 0x07b52e08 | (18 << 27) /* 0.481733352 */, + /* 6700 */ 0x07b59292 | (18 << 27) /* 0.481829236 */, + /* 6701 */ 0x07b5f71e | (18 << 27) /* 0.481925125 */, + /* 6702 */ 0x07b65bac | (18 << 27) /* 0.482021019 */, + /* 6703 */ 0x07b6c03a | (18 << 27) /* 0.482116917 */, + + /* 6704 */ 0x07b724ca | (18 << 27) /* 0.482212820 */, + /* 6705 */ 0x07b7895b | (18 << 27) /* 0.482308728 */, + /* 6706 */ 0x07b7eded | (18 << 27) /* 0.482404640 */, + /* 6707 */ 0x07b85281 | (18 << 27) /* 0.482500558 */, + /* 6708 */ 0x07b8b716 | (18 << 27) /* 0.482596480 */, + /* 6709 */ 0x07b91bac | (18 << 27) /* 0.482692407 */, + /* 6710 */ 0x07b98044 | (18 << 27) /* 0.482788339 */, + /* 6711 */ 0x07b9e4dc | (18 << 27) /* 0.482884275 */, + /* 6712 */ 0x07ba4976 | (18 << 27) /* 0.482980216 */, + /* 6713 */ 0x07baae12 | (18 << 27) /* 0.483076162 */, + /* 6714 */ 0x07bb12ae | (18 << 27) /* 0.483172113 */, + /* 6715 */ 0x07bb774c | (18 << 27) /* 0.483268069 */, + /* 6716 */ 0x07bbdbeb | (18 << 27) /* 0.483364029 */, + /* 6717 */ 0x07bc408c | (18 << 27) /* 0.483459994 */, + /* 6718 */ 0x07bca52d | (18 << 27) /* 0.483555964 */, + /* 6719 */ 0x07bd09d0 | (18 << 27) /* 0.483651939 */, + + /* 6720 */ 0x07bd6e75 | (18 << 27) /* 0.483747918 */, + /* 6721 */ 0x07bdd31a | (18 << 27) /* 0.483843902 */, + /* 6722 */ 0x07be37c1 | (18 << 27) /* 0.483939891 */, + /* 6723 */ 0x07be9c69 | (18 << 27) /* 0.484035885 */, + /* 6724 */ 0x07bf0113 | (18 << 27) /* 0.484131883 */, + /* 6725 */ 0x07bf65bd | (18 << 27) /* 0.484227886 */, + /* 6726 */ 0x07bfca69 | (18 << 27) /* 0.484323894 */, + /* 6727 */ 0x07c02f16 | (18 << 27) /* 0.484419907 */, + /* 6728 */ 0x07c093c5 | (18 << 27) /* 0.484515924 */, + /* 6729 */ 0x07c0f875 | (18 << 27) /* 0.484611946 */, + /* 6730 */ 0x07c15d26 | (18 << 27) /* 0.484707973 */, + /* 6731 */ 0x07c1c1d8 | (18 << 27) /* 0.484804005 */, + /* 6732 */ 0x07c2268b | (18 << 27) /* 0.484900041 */, + /* 6733 */ 0x07c28b40 | (18 << 27) /* 0.484996083 */, + /* 6734 */ 0x07c2eff6 | (18 << 27) /* 0.485092128 */, + /* 6735 */ 0x07c354ae | (18 << 27) /* 0.485188179 */, + + /* 6736 */ 0x07c3b967 | (18 << 27) /* 0.485284235 */, + /* 6737 */ 0x07c41e21 | (18 << 27) /* 0.485380295 */, + /* 6738 */ 0x07c482dc | (18 << 27) /* 0.485476360 */, + /* 6739 */ 0x07c4e798 | (18 << 27) /* 0.485572430 */, + /* 6740 */ 0x07c54c56 | (18 << 27) /* 0.485668504 */, + /* 6741 */ 0x07c5b115 | (18 << 27) /* 0.485764583 */, + /* 6742 */ 0x07c615d6 | (18 << 27) /* 0.485860667 */, + /* 6743 */ 0x07c67a97 | (18 << 27) /* 0.485956756 */, + /* 6744 */ 0x07c6df5a | (18 << 27) /* 0.486052849 */, + /* 6745 */ 0x07c7441e | (18 << 27) /* 0.486148948 */, + /* 6746 */ 0x07c7a8e4 | (18 << 27) /* 0.486245051 */, + /* 6747 */ 0x07c80daa | (18 << 27) /* 0.486341158 */, + /* 6748 */ 0x07c87272 | (18 << 27) /* 0.486437271 */, + /* 6749 */ 0x07c8d73c | (18 << 27) /* 0.486533388 */, + /* 6750 */ 0x07c93c06 | (18 << 27) /* 0.486629510 */, + /* 6751 */ 0x07c9a0d2 | (18 << 27) /* 0.486725637 */, + + /* 6752 */ 0x07ca059f | (18 << 27) /* 0.486821768 */, + /* 6753 */ 0x07ca6a6d | (18 << 27) /* 0.486917905 */, + /* 6754 */ 0x07cacf3d | (18 << 27) /* 0.487014045 */, + /* 6755 */ 0x07cb340e | (18 << 27) /* 0.487110191 */, + /* 6756 */ 0x07cb98e0 | (18 << 27) /* 0.487206342 */, + /* 6757 */ 0x07cbfdb4 | (18 << 27) /* 0.487302497 */, + /* 6758 */ 0x07cc6288 | (18 << 27) /* 0.487398657 */, + /* 6759 */ 0x07ccc75e | (18 << 27) /* 0.487494821 */, + /* 6760 */ 0x07cd2c36 | (18 << 27) /* 0.487590991 */, + /* 6761 */ 0x07cd910e | (18 << 27) /* 0.487687165 */, + /* 6762 */ 0x07cdf5e8 | (18 << 27) /* 0.487783344 */, + /* 6763 */ 0x07ce5ac3 | (18 << 27) /* 0.487879528 */, + /* 6764 */ 0x07cebfa0 | (18 << 27) /* 0.487975716 */, + /* 6765 */ 0x07cf247d | (18 << 27) /* 0.488071909 */, + /* 6766 */ 0x07cf895c | (18 << 27) /* 0.488168107 */, + /* 6767 */ 0x07cfee3c | (18 << 27) /* 0.488264310 */, + + /* 6768 */ 0x07d0531e | (18 << 27) /* 0.488360517 */, + /* 6769 */ 0x07d0b801 | (18 << 27) /* 0.488456729 */, + /* 6770 */ 0x07d11ce5 | (18 << 27) /* 0.488552946 */, + /* 6771 */ 0x07d181ca | (18 << 27) /* 0.488649167 */, + /* 6772 */ 0x07d1e6b0 | (18 << 27) /* 0.488745394 */, + /* 6773 */ 0x07d24b98 | (18 << 27) /* 0.488841625 */, + /* 6774 */ 0x07d2b081 | (18 << 27) /* 0.488937860 */, + /* 6775 */ 0x07d3156c | (18 << 27) /* 0.489034101 */, + /* 6776 */ 0x07d37a57 | (18 << 27) /* 0.489130346 */, + /* 6777 */ 0x07d3df44 | (18 << 27) /* 0.489226596 */, + /* 6778 */ 0x07d44432 | (18 << 27) /* 0.489322851 */, + /* 6779 */ 0x07d4a922 | (18 << 27) /* 0.489419110 */, + /* 6780 */ 0x07d50e13 | (18 << 27) /* 0.489515375 */, + /* 6781 */ 0x07d57305 | (18 << 27) /* 0.489611643 */, + /* 6782 */ 0x07d5d7f8 | (18 << 27) /* 0.489707917 */, + /* 6783 */ 0x07d63cec | (18 << 27) /* 0.489804195 */, + + /* 6784 */ 0x07d6a1e2 | (18 << 27) /* 0.489900479 */, + /* 6785 */ 0x07d706d9 | (18 << 27) /* 0.489996766 */, + /* 6786 */ 0x07d76bd2 | (18 << 27) /* 0.490093059 */, + /* 6787 */ 0x07d7d0cb | (18 << 27) /* 0.490189356 */, + /* 6788 */ 0x07d835c6 | (18 << 27) /* 0.490285658 */, + /* 6789 */ 0x07d89ac2 | (18 << 27) /* 0.490381965 */, + /* 6790 */ 0x07d8ffc0 | (18 << 27) /* 0.490478277 */, + /* 6791 */ 0x07d964be | (18 << 27) /* 0.490574593 */, + /* 6792 */ 0x07d9c9be | (18 << 27) /* 0.490670914 */, + /* 6793 */ 0x07da2ebf | (18 << 27) /* 0.490767239 */, + /* 6794 */ 0x07da93c2 | (18 << 27) /* 0.490863570 */, + /* 6795 */ 0x07daf8c6 | (18 << 27) /* 0.490959905 */, + /* 6796 */ 0x07db5dcb | (18 << 27) /* 0.491056245 */, + /* 6797 */ 0x07dbc2d1 | (18 << 27) /* 0.491152589 */, + /* 6798 */ 0x07dc27d9 | (18 << 27) /* 0.491248939 */, + /* 6799 */ 0x07dc8ce1 | (18 << 27) /* 0.491345293 */, + + /* 6800 */ 0x07dcf1ec | (18 << 27) /* 0.491441651 */, + /* 6801 */ 0x07dd56f7 | (18 << 27) /* 0.491538015 */, + /* 6802 */ 0x07ddbc04 | (18 << 27) /* 0.491634383 */, + /* 6803 */ 0x07de2111 | (18 << 27) /* 0.491730756 */, + /* 6804 */ 0x07de8621 | (18 << 27) /* 0.491827134 */, + /* 6805 */ 0x07deeb31 | (18 << 27) /* 0.491923516 */, + /* 6806 */ 0x07df5043 | (18 << 27) /* 0.492019903 */, + /* 6807 */ 0x07dfb556 | (18 << 27) /* 0.492116295 */, + /* 6808 */ 0x07e01a6a | (18 << 27) /* 0.492212691 */, + /* 6809 */ 0x07e07f80 | (18 << 27) /* 0.492309093 */, + /* 6810 */ 0x07e0e496 | (18 << 27) /* 0.492405499 */, + /* 6811 */ 0x07e149ae | (18 << 27) /* 0.492501909 */, + /* 6812 */ 0x07e1aec8 | (18 << 27) /* 0.492598325 */, + /* 6813 */ 0x07e213e2 | (18 << 27) /* 0.492694745 */, + /* 6814 */ 0x07e278fe | (18 << 27) /* 0.492791170 */, + /* 6815 */ 0x07e2de1b | (18 << 27) /* 0.492887599 */, + + /* 6816 */ 0x07e3433a | (18 << 27) /* 0.492984033 */, + /* 6817 */ 0x07e3a859 | (18 << 27) /* 0.493080472 */, + /* 6818 */ 0x07e40d7a | (18 << 27) /* 0.493176916 */, + /* 6819 */ 0x07e4729c | (18 << 27) /* 0.493273365 */, + /* 6820 */ 0x07e4d7c0 | (18 << 27) /* 0.493369818 */, + /* 6821 */ 0x07e53ce4 | (18 << 27) /* 0.493466275 */, + /* 6822 */ 0x07e5a20a | (18 << 27) /* 0.493562738 */, + /* 6823 */ 0x07e60732 | (18 << 27) /* 0.493659205 */, + /* 6824 */ 0x07e66c5a | (18 << 27) /* 0.493755677 */, + /* 6825 */ 0x07e6d184 | (18 << 27) /* 0.493852154 */, + /* 6826 */ 0x07e736af | (18 << 27) /* 0.493948635 */, + /* 6827 */ 0x07e79bdb | (18 << 27) /* 0.494045122 */, + /* 6828 */ 0x07e80109 | (18 << 27) /* 0.494141612 */, + /* 6829 */ 0x07e86638 | (18 << 27) /* 0.494238108 */, + /* 6830 */ 0x07e8cb68 | (18 << 27) /* 0.494334608 */, + /* 6831 */ 0x07e93099 | (18 << 27) /* 0.494431113 */, + + /* 6832 */ 0x07e995cc | (18 << 27) /* 0.494527623 */, + /* 6833 */ 0x07e9fb00 | (18 << 27) /* 0.494624137 */, + /* 6834 */ 0x07ea6035 | (18 << 27) /* 0.494720656 */, + /* 6835 */ 0x07eac56b | (18 << 27) /* 0.494817180 */, + /* 6836 */ 0x07eb2aa3 | (18 << 27) /* 0.494913709 */, + /* 6837 */ 0x07eb8fdc | (18 << 27) /* 0.495010242 */, + /* 6838 */ 0x07ebf516 | (18 << 27) /* 0.495106780 */, + /* 6839 */ 0x07ec5a51 | (18 << 27) /* 0.495203322 */, + /* 6840 */ 0x07ecbf8e | (18 << 27) /* 0.495299870 */, + /* 6841 */ 0x07ed24cc | (18 << 27) /* 0.495396422 */, + /* 6842 */ 0x07ed8a0b | (18 << 27) /* 0.495492978 */, + /* 6843 */ 0x07edef4c | (18 << 27) /* 0.495589540 */, + /* 6844 */ 0x07ee548e | (18 << 27) /* 0.495686106 */, + /* 6845 */ 0x07eeb9d1 | (18 << 27) /* 0.495782677 */, + /* 6846 */ 0x07ef1f15 | (18 << 27) /* 0.495879252 */, + /* 6847 */ 0x07ef845b | (18 << 27) /* 0.495975833 */, + + /* 6848 */ 0x07efe9a1 | (18 << 27) /* 0.496072418 */, + /* 6849 */ 0x07f04ee9 | (18 << 27) /* 0.496169007 */, + /* 6850 */ 0x07f0b433 | (18 << 27) /* 0.496265602 */, + /* 6851 */ 0x07f1197d | (18 << 27) /* 0.496362201 */, + /* 6852 */ 0x07f17ec9 | (18 << 27) /* 0.496458804 */, + /* 6853 */ 0x07f1e416 | (18 << 27) /* 0.496555413 */, + /* 6854 */ 0x07f24965 | (18 << 27) /* 0.496652026 */, + /* 6855 */ 0x07f2aeb5 | (18 << 27) /* 0.496748644 */, + /* 6856 */ 0x07f31405 | (18 << 27) /* 0.496845266 */, + /* 6857 */ 0x07f37958 | (18 << 27) /* 0.496941894 */, + /* 6858 */ 0x07f3deab | (18 << 27) /* 0.497038526 */, + /* 6859 */ 0x07f44400 | (18 << 27) /* 0.497135162 */, + /* 6860 */ 0x07f4a956 | (18 << 27) /* 0.497231804 */, + /* 6861 */ 0x07f50ead | (18 << 27) /* 0.497328450 */, + /* 6862 */ 0x07f57405 | (18 << 27) /* 0.497425100 */, + /* 6863 */ 0x07f5d95f | (18 << 27) /* 0.497521756 */, + + /* 6864 */ 0x07f63eba | (18 << 27) /* 0.497618416 */, + /* 6865 */ 0x07f6a416 | (18 << 27) /* 0.497715081 */, + /* 6866 */ 0x07f70974 | (18 << 27) /* 0.497811750 */, + /* 6867 */ 0x07f76ed3 | (18 << 27) /* 0.497908425 */, + /* 6868 */ 0x07f7d433 | (18 << 27) /* 0.498005103 */, + /* 6869 */ 0x07f83994 | (18 << 27) /* 0.498101787 */, + /* 6870 */ 0x07f89ef7 | (18 << 27) /* 0.498198475 */, + /* 6871 */ 0x07f9045a | (18 << 27) /* 0.498295168 */, + /* 6872 */ 0x07f969c0 | (18 << 27) /* 0.498391866 */, + /* 6873 */ 0x07f9cf26 | (18 << 27) /* 0.498488568 */, + /* 6874 */ 0x07fa348e | (18 << 27) /* 0.498585275 */, + /* 6875 */ 0x07fa99f6 | (18 << 27) /* 0.498681987 */, + /* 6876 */ 0x07faff60 | (18 << 27) /* 0.498778704 */, + /* 6877 */ 0x07fb64cc | (18 << 27) /* 0.498875425 */, + /* 6878 */ 0x07fbca38 | (18 << 27) /* 0.498972150 */, + /* 6879 */ 0x07fc2fa6 | (18 << 27) /* 0.499068881 */, + + /* 6880 */ 0x07fc9516 | (18 << 27) /* 0.499165616 */, + /* 6881 */ 0x07fcfa86 | (18 << 27) /* 0.499262356 */, + /* 6882 */ 0x07fd5ff8 | (18 << 27) /* 0.499359101 */, + /* 6883 */ 0x07fdc56b | (18 << 27) /* 0.499455850 */, + /* 6884 */ 0x07fe2adf | (18 << 27) /* 0.499552604 */, + /* 6885 */ 0x07fe9054 | (18 << 27) /* 0.499649362 */, + /* 6886 */ 0x07fef5cb | (18 << 27) /* 0.499746126 */, + /* 6887 */ 0x07ff5b43 | (18 << 27) /* 0.499842894 */, + /* 6888 */ 0x07ffc0bc | (18 << 27) /* 0.499939666 */, + /* 6889 */ 0x0400131b | (19 << 27) /* 0.250018222 */, + /* 6890 */ 0x040045d9 | (19 << 27) /* 0.250066613 */, + /* 6891 */ 0x04007897 | (19 << 27) /* 0.250115006 */, + /* 6892 */ 0x0400ab57 | (19 << 27) /* 0.250163402 */, + /* 6893 */ 0x0400de16 | (19 << 27) /* 0.250211800 */, + /* 6894 */ 0x040110d7 | (19 << 27) /* 0.250260200 */, + /* 6895 */ 0x04014398 | (19 << 27) /* 0.250308603 */, + + /* 6896 */ 0x04017659 | (19 << 27) /* 0.250357008 */, + /* 6897 */ 0x0401a91c | (19 << 27) /* 0.250405415 */, + /* 6898 */ 0x0401dbdf | (19 << 27) /* 0.250453825 */, + /* 6899 */ 0x04020ea2 | (19 << 27) /* 0.250502237 */, + /* 6900 */ 0x04024166 | (19 << 27) /* 0.250550652 */, + /* 6901 */ 0x0402742b | (19 << 27) /* 0.250599068 */, + /* 6902 */ 0x0402a6f0 | (19 << 27) /* 0.250647488 */, + /* 6903 */ 0x0402d9b6 | (19 << 27) /* 0.250695909 */, + /* 6904 */ 0x04030c7d | (19 << 27) /* 0.250744333 */, + /* 6905 */ 0x04033f44 | (19 << 27) /* 0.250792759 */, + /* 6906 */ 0x0403720c | (19 << 27) /* 0.250841187 */, + /* 6907 */ 0x0403a4d5 | (19 << 27) /* 0.250889618 */, + /* 6908 */ 0x0403d79e | (19 << 27) /* 0.250938051 */, + /* 6909 */ 0x04040a68 | (19 << 27) /* 0.250986487 */, + /* 6910 */ 0x04043d32 | (19 << 27) /* 0.251034924 */, + /* 6911 */ 0x04046ffd | (19 << 27) /* 0.251083365 */, + + /* 6912 */ 0x0404a2c9 | (19 << 27) /* 0.251131807 */, + /* 6913 */ 0x0404d595 | (19 << 27) /* 0.251180252 */, + /* 6914 */ 0x04050862 | (19 << 27) /* 0.251228699 */, + /* 6915 */ 0x04053b30 | (19 << 27) /* 0.251277148 */, + /* 6916 */ 0x04056dfe | (19 << 27) /* 0.251325600 */, + /* 6917 */ 0x0405a0cd | (19 << 27) /* 0.251374054 */, + /* 6918 */ 0x0405d39c | (19 << 27) /* 0.251422511 */, + /* 6919 */ 0x0406066c | (19 << 27) /* 0.251470970 */, + /* 6920 */ 0x0406393d | (19 << 27) /* 0.251519431 */, + /* 6921 */ 0x04066c0e | (19 << 27) /* 0.251567894 */, + /* 6922 */ 0x04069ee0 | (19 << 27) /* 0.251616360 */, + /* 6923 */ 0x0406d1b3 | (19 << 27) /* 0.251664828 */, + /* 6924 */ 0x04070486 | (19 << 27) /* 0.251713299 */, + /* 6925 */ 0x0407375a | (19 << 27) /* 0.251761772 */, + /* 6926 */ 0x04076a2e | (19 << 27) /* 0.251810247 */, + /* 6927 */ 0x04079d03 | (19 << 27) /* 0.251858724 */, + + /* 6928 */ 0x0407cfd9 | (19 << 27) /* 0.251907204 */, + /* 6929 */ 0x040802af | (19 << 27) /* 0.251955686 */, + /* 6930 */ 0x04083586 | (19 << 27) /* 0.252004171 */, + /* 6931 */ 0x0408685e | (19 << 27) /* 0.252052658 */, + /* 6932 */ 0x04089b36 | (19 << 27) /* 0.252101147 */, + /* 6933 */ 0x0408ce0f | (19 << 27) /* 0.252149638 */, + /* 6934 */ 0x040900e8 | (19 << 27) /* 0.252198132 */, + /* 6935 */ 0x040933c2 | (19 << 27) /* 0.252246628 */, + /* 6936 */ 0x0409669d | (19 << 27) /* 0.252295127 */, + /* 6937 */ 0x04099978 | (19 << 27) /* 0.252343627 */, + /* 6938 */ 0x0409cc54 | (19 << 27) /* 0.252392131 */, + /* 6939 */ 0x0409ff31 | (19 << 27) /* 0.252440636 */, + /* 6940 */ 0x040a320e | (19 << 27) /* 0.252489144 */, + /* 6941 */ 0x040a64ec | (19 << 27) /* 0.252537654 */, + /* 6942 */ 0x040a97cb | (19 << 27) /* 0.252586166 */, + /* 6943 */ 0x040acaaa | (19 << 27) /* 0.252634681 */, + + /* 6944 */ 0x040afd89 | (19 << 27) /* 0.252683198 */, + /* 6945 */ 0x040b306a | (19 << 27) /* 0.252731718 */, + /* 6946 */ 0x040b634b | (19 << 27) /* 0.252780240 */, + /* 6947 */ 0x040b962c | (19 << 27) /* 0.252828764 */, + /* 6948 */ 0x040bc90e | (19 << 27) /* 0.252877290 */, + /* 6949 */ 0x040bfbf1 | (19 << 27) /* 0.252925819 */, + /* 6950 */ 0x040c2ed5 | (19 << 27) /* 0.252974350 */, + /* 6951 */ 0x040c61b9 | (19 << 27) /* 0.253022883 */, + /* 6952 */ 0x040c949e | (19 << 27) /* 0.253071419 */, + /* 6953 */ 0x040cc783 | (19 << 27) /* 0.253119957 */, + /* 6954 */ 0x040cfa69 | (19 << 27) /* 0.253168498 */, + /* 6955 */ 0x040d2d4f | (19 << 27) /* 0.253217040 */, + /* 6956 */ 0x040d6037 | (19 << 27) /* 0.253265585 */, + /* 6957 */ 0x040d931e | (19 << 27) /* 0.253314133 */, + /* 6958 */ 0x040dc607 | (19 << 27) /* 0.253362682 */, + /* 6959 */ 0x040df8f0 | (19 << 27) /* 0.253411234 */, + + /* 6960 */ 0x040e2bda | (19 << 27) /* 0.253459789 */, + /* 6961 */ 0x040e5ec4 | (19 << 27) /* 0.253508345 */, + /* 6962 */ 0x040e91af | (19 << 27) /* 0.253556904 */, + /* 6963 */ 0x040ec49b | (19 << 27) /* 0.253605466 */, + /* 6964 */ 0x040ef787 | (19 << 27) /* 0.253654029 */, + /* 6965 */ 0x040f2a74 | (19 << 27) /* 0.253702595 */, + /* 6966 */ 0x040f5d61 | (19 << 27) /* 0.253751164 */, + /* 6967 */ 0x040f904f | (19 << 27) /* 0.253799734 */, + /* 6968 */ 0x040fc33e | (19 << 27) /* 0.253848307 */, + /* 6969 */ 0x040ff62d | (19 << 27) /* 0.253896883 */, + /* 6970 */ 0x0410291d | (19 << 27) /* 0.253945460 */, + /* 6971 */ 0x04105c0e | (19 << 27) /* 0.253994040 */, + /* 6972 */ 0x04108eff | (19 << 27) /* 0.254042622 */, + /* 6973 */ 0x0410c1f1 | (19 << 27) /* 0.254091207 */, + /* 6974 */ 0x0410f4e3 | (19 << 27) /* 0.254139794 */, + /* 6975 */ 0x041127d6 | (19 << 27) /* 0.254188383 */, + + /* 6976 */ 0x04115aca | (19 << 27) /* 0.254236974 */, + /* 6977 */ 0x04118dbe | (19 << 27) /* 0.254285568 */, + /* 6978 */ 0x0411c0b3 | (19 << 27) /* 0.254334165 */, + /* 6979 */ 0x0411f3a9 | (19 << 27) /* 0.254382763 */, + /* 6980 */ 0x0412269f | (19 << 27) /* 0.254431364 */, + /* 6981 */ 0x04125996 | (19 << 27) /* 0.254479967 */, + /* 6982 */ 0x04128c8d | (19 << 27) /* 0.254528572 */, + /* 6983 */ 0x0412bf85 | (19 << 27) /* 0.254577180 */, + /* 6984 */ 0x0412f27e | (19 << 27) /* 0.254625790 */, + /* 6985 */ 0x04132577 | (19 << 27) /* 0.254674403 */, + /* 6986 */ 0x04135871 | (19 << 27) /* 0.254723017 */, + /* 6987 */ 0x04138b6c | (19 << 27) /* 0.254771635 */, + /* 6988 */ 0x0413be67 | (19 << 27) /* 0.254820254 */, + /* 6989 */ 0x0413f163 | (19 << 27) /* 0.254868876 */, + /* 6990 */ 0x0414245f | (19 << 27) /* 0.254917500 */, + /* 6991 */ 0x0414575c | (19 << 27) /* 0.254966126 */, + + /* 6992 */ 0x04148a5a | (19 << 27) /* 0.255014755 */, + /* 6993 */ 0x0414bd58 | (19 << 27) /* 0.255063386 */, + /* 6994 */ 0x0414f057 | (19 << 27) /* 0.255112019 */, + /* 6995 */ 0x04152356 | (19 << 27) /* 0.255160655 */, + /* 6996 */ 0x04155657 | (19 << 27) /* 0.255209292 */, + /* 6997 */ 0x04158957 | (19 << 27) /* 0.255257933 */, + /* 6998 */ 0x0415bc59 | (19 << 27) /* 0.255306575 */, + /* 6999 */ 0x0415ef5b | (19 << 27) /* 0.255355220 */, + /* 7000 */ 0x0416225d | (19 << 27) /* 0.255403867 */, + /* 7001 */ 0x04165561 | (19 << 27) /* 0.255452517 */, + /* 7002 */ 0x04168864 | (19 << 27) /* 0.255501169 */, + /* 7003 */ 0x0416bb69 | (19 << 27) /* 0.255549823 */, + /* 7004 */ 0x0416ee6e | (19 << 27) /* 0.255598479 */, + /* 7005 */ 0x04172174 | (19 << 27) /* 0.255647138 */, + /* 7006 */ 0x0417547a | (19 << 27) /* 0.255695799 */, + /* 7007 */ 0x04178781 | (19 << 27) /* 0.255744463 */, + + /* 7008 */ 0x0417ba89 | (19 << 27) /* 0.255793128 */, + /* 7009 */ 0x0417ed91 | (19 << 27) /* 0.255841796 */, + /* 7010 */ 0x0418209a | (19 << 27) /* 0.255890467 */, + /* 7011 */ 0x041853a3 | (19 << 27) /* 0.255939139 */, + /* 7012 */ 0x041886ad | (19 << 27) /* 0.255987814 */, + /* 7013 */ 0x0418b9b8 | (19 << 27) /* 0.256036492 */, + /* 7014 */ 0x0418ecc3 | (19 << 27) /* 0.256085171 */, + /* 7015 */ 0x04191fcf | (19 << 27) /* 0.256133853 */, + /* 7016 */ 0x041952dc | (19 << 27) /* 0.256182537 */, + /* 7017 */ 0x041985e9 | (19 << 27) /* 0.256231224 */, + /* 7018 */ 0x0419b8f7 | (19 << 27) /* 0.256279913 */, + /* 7019 */ 0x0419ec05 | (19 << 27) /* 0.256328604 */, + /* 7020 */ 0x041a1f15 | (19 << 27) /* 0.256377297 */, + /* 7021 */ 0x041a5224 | (19 << 27) /* 0.256425993 */, + /* 7022 */ 0x041a8534 | (19 << 27) /* 0.256474691 */, + /* 7023 */ 0x041ab845 | (19 << 27) /* 0.256523392 */, + + /* 7024 */ 0x041aeb57 | (19 << 27) /* 0.256572095 */, + /* 7025 */ 0x041b1e69 | (19 << 27) /* 0.256620800 */, + /* 7026 */ 0x041b517c | (19 << 27) /* 0.256669507 */, + /* 7027 */ 0x041b848f | (19 << 27) /* 0.256718217 */, + /* 7028 */ 0x041bb7a3 | (19 << 27) /* 0.256766929 */, + /* 7029 */ 0x041beab8 | (19 << 27) /* 0.256815643 */, + /* 7030 */ 0x041c1dcd | (19 << 27) /* 0.256864359 */, + /* 7031 */ 0x041c50e3 | (19 << 27) /* 0.256913078 */, + /* 7032 */ 0x041c83fa | (19 << 27) /* 0.256961800 */, + /* 7033 */ 0x041cb711 | (19 << 27) /* 0.257010523 */, + /* 7034 */ 0x041cea28 | (19 << 27) /* 0.257059249 */, + /* 7035 */ 0x041d1d41 | (19 << 27) /* 0.257107977 */, + /* 7036 */ 0x041d505a | (19 << 27) /* 0.257156708 */, + /* 7037 */ 0x041d8373 | (19 << 27) /* 0.257205440 */, + /* 7038 */ 0x041db68e | (19 << 27) /* 0.257254175 */, + /* 7039 */ 0x041de9a8 | (19 << 27) /* 0.257302913 */, + + /* 7040 */ 0x041e1cc4 | (19 << 27) /* 0.257351652 */, + /* 7041 */ 0x041e4fe0 | (19 << 27) /* 0.257400394 */, + /* 7042 */ 0x041e82fd | (19 << 27) /* 0.257449139 */, + /* 7043 */ 0x041eb61a | (19 << 27) /* 0.257497885 */, + /* 7044 */ 0x041ee938 | (19 << 27) /* 0.257546634 */, + /* 7045 */ 0x041f1c57 | (19 << 27) /* 0.257595386 */, + /* 7046 */ 0x041f4f76 | (19 << 27) /* 0.257644139 */, + /* 7047 */ 0x041f8296 | (19 << 27) /* 0.257692895 */, + /* 7048 */ 0x041fb5b6 | (19 << 27) /* 0.257741653 */, + /* 7049 */ 0x041fe8d7 | (19 << 27) /* 0.257790414 */, + /* 7050 */ 0x04201bf9 | (19 << 27) /* 0.257839176 */, + /* 7051 */ 0x04204f1b | (19 << 27) /* 0.257887941 */, + /* 7052 */ 0x0420823e | (19 << 27) /* 0.257936709 */, + /* 7053 */ 0x0420b561 | (19 << 27) /* 0.257985478 */, + /* 7054 */ 0x0420e885 | (19 << 27) /* 0.258034250 */, + /* 7055 */ 0x04211baa | (19 << 27) /* 0.258083025 */, + + /* 7056 */ 0x04214ed0 | (19 << 27) /* 0.258131801 */, + /* 7057 */ 0x042181f6 | (19 << 27) /* 0.258180580 */, + /* 7058 */ 0x0421b51c | (19 << 27) /* 0.258229361 */, + /* 7059 */ 0x0421e843 | (19 << 27) /* 0.258278145 */, + /* 7060 */ 0x04221b6b | (19 << 27) /* 0.258326931 */, + /* 7061 */ 0x04224e94 | (19 << 27) /* 0.258375719 */, + /* 7062 */ 0x042281bd | (19 << 27) /* 0.258424509 */, + /* 7063 */ 0x0422b4e6 | (19 << 27) /* 0.258473302 */, + /* 7064 */ 0x0422e811 | (19 << 27) /* 0.258522097 */, + /* 7065 */ 0x04231b3c | (19 << 27) /* 0.258570894 */, + /* 7066 */ 0x04234e67 | (19 << 27) /* 0.258619694 */, + /* 7067 */ 0x04238193 | (19 << 27) /* 0.258668496 */, + /* 7068 */ 0x0423b4c0 | (19 << 27) /* 0.258717300 */, + /* 7069 */ 0x0423e7ee | (19 << 27) /* 0.258766106 */, + /* 7070 */ 0x04241b1c | (19 << 27) /* 0.258814915 */, + /* 7071 */ 0x04244e4a | (19 << 27) /* 0.258863726 */, + + /* 7072 */ 0x04248179 | (19 << 27) /* 0.258912540 */, + /* 7073 */ 0x0424b4a9 | (19 << 27) /* 0.258961356 */, + /* 7074 */ 0x0424e7da | (19 << 27) /* 0.259010174 */, + /* 7075 */ 0x04251b0b | (19 << 27) /* 0.259058994 */, + /* 7076 */ 0x04254e3d | (19 << 27) /* 0.259107817 */, + /* 7077 */ 0x0425816f | (19 << 27) /* 0.259156642 */, + /* 7078 */ 0x0425b4a2 | (19 << 27) /* 0.259205469 */, + /* 7079 */ 0x0425e7d6 | (19 << 27) /* 0.259254298 */, + /* 7080 */ 0x04261b0a | (19 << 27) /* 0.259303130 */, + /* 7081 */ 0x04264e3f | (19 << 27) /* 0.259351964 */, + /* 7082 */ 0x04268174 | (19 << 27) /* 0.259400801 */, + /* 7083 */ 0x0426b4aa | (19 << 27) /* 0.259449639 */, + /* 7084 */ 0x0426e7e1 | (19 << 27) /* 0.259498480 */, + /* 7085 */ 0x04271b18 | (19 << 27) /* 0.259547324 */, + /* 7086 */ 0x04274e50 | (19 << 27) /* 0.259596169 */, + /* 7087 */ 0x04278188 | (19 << 27) /* 0.259645017 */, + + /* 7088 */ 0x0427b4c2 | (19 << 27) /* 0.259693868 */, + /* 7089 */ 0x0427e7fb | (19 << 27) /* 0.259742720 */, + /* 7090 */ 0x04281b36 | (19 << 27) /* 0.259791575 */, + /* 7091 */ 0x04284e71 | (19 << 27) /* 0.259840432 */, + /* 7092 */ 0x042881ac | (19 << 27) /* 0.259889291 */, + /* 7093 */ 0x0428b4e8 | (19 << 27) /* 0.259938153 */, + /* 7094 */ 0x0428e825 | (19 << 27) /* 0.259987017 */, + /* 7095 */ 0x04291b63 | (19 << 27) /* 0.260035883 */, + /* 7096 */ 0x04294ea1 | (19 << 27) /* 0.260084752 */, + /* 7097 */ 0x042981df | (19 << 27) /* 0.260133623 */, + /* 7098 */ 0x0429b51f | (19 << 27) /* 0.260182496 */, + /* 7099 */ 0x0429e85f | (19 << 27) /* 0.260231372 */, + /* 7100 */ 0x042a1b9f | (19 << 27) /* 0.260280249 */, + /* 7101 */ 0x042a4ee0 | (19 << 27) /* 0.260329129 */, + /* 7102 */ 0x042a8222 | (19 << 27) /* 0.260378012 */, + /* 7103 */ 0x042ab564 | (19 << 27) /* 0.260426896 */, + + /* 7104 */ 0x042ae8a7 | (19 << 27) /* 0.260475783 */, + /* 7105 */ 0x042b1beb | (19 << 27) /* 0.260524673 */, + /* 7106 */ 0x042b4f2f | (19 << 27) /* 0.260573564 */, + /* 7107 */ 0x042b8274 | (19 << 27) /* 0.260622458 */, + /* 7108 */ 0x042bb5ba | (19 << 27) /* 0.260671354 */, + /* 7109 */ 0x042be900 | (19 << 27) /* 0.260720252 */, + /* 7110 */ 0x042c1c46 | (19 << 27) /* 0.260769153 */, + /* 7111 */ 0x042c4f8e | (19 << 27) /* 0.260818056 */, + /* 7112 */ 0x042c82d6 | (19 << 27) /* 0.260866961 */, + /* 7113 */ 0x042cb61e | (19 << 27) /* 0.260915869 */, + /* 7114 */ 0x042ce967 | (19 << 27) /* 0.260964779 */, + /* 7115 */ 0x042d1cb1 | (19 << 27) /* 0.261013691 */, + /* 7116 */ 0x042d4ffb | (19 << 27) /* 0.261062606 */, + /* 7117 */ 0x042d8346 | (19 << 27) /* 0.261111522 */, + /* 7118 */ 0x042db692 | (19 << 27) /* 0.261160441 */, + /* 7119 */ 0x042de9de | (19 << 27) /* 0.261209363 */, + + /* 7120 */ 0x042e1d2b | (19 << 27) /* 0.261258286 */, + /* 7121 */ 0x042e5078 | (19 << 27) /* 0.261307212 */, + /* 7122 */ 0x042e83c6 | (19 << 27) /* 0.261356140 */, + /* 7123 */ 0x042eb715 | (19 << 27) /* 0.261405071 */, + /* 7124 */ 0x042eea64 | (19 << 27) /* 0.261454004 */, + /* 7125 */ 0x042f1db4 | (19 << 27) /* 0.261502939 */, + /* 7126 */ 0x042f5105 | (19 << 27) /* 0.261551876 */, + /* 7127 */ 0x042f8456 | (19 << 27) /* 0.261600816 */, + /* 7128 */ 0x042fb7a8 | (19 << 27) /* 0.261649758 */, + /* 7129 */ 0x042feafa | (19 << 27) /* 0.261698702 */, + /* 7130 */ 0x04301e4d | (19 << 27) /* 0.261747649 */, + /* 7131 */ 0x043051a1 | (19 << 27) /* 0.261796597 */, + /* 7132 */ 0x043084f5 | (19 << 27) /* 0.261845548 */, + /* 7133 */ 0x0430b84a | (19 << 27) /* 0.261894502 */, + /* 7134 */ 0x0430eb9f | (19 << 27) /* 0.261943458 */, + /* 7135 */ 0x04311ef5 | (19 << 27) /* 0.261992416 */, + + /* 7136 */ 0x0431524c | (19 << 27) /* 0.262041376 */, + /* 7137 */ 0x043185a3 | (19 << 27) /* 0.262090338 */, + /* 7138 */ 0x0431b8fb | (19 << 27) /* 0.262139303 */, + /* 7139 */ 0x0431ec54 | (19 << 27) /* 0.262188270 */, + /* 7140 */ 0x04321fad | (19 << 27) /* 0.262237240 */, + /* 7141 */ 0x04325306 | (19 << 27) /* 0.262286211 */, + /* 7142 */ 0x04328661 | (19 << 27) /* 0.262335185 */, + /* 7143 */ 0x0432b9bc | (19 << 27) /* 0.262384162 */, + /* 7144 */ 0x0432ed17 | (19 << 27) /* 0.262433140 */, + /* 7145 */ 0x04332074 | (19 << 27) /* 0.262482121 */, + /* 7146 */ 0x043353d0 | (19 << 27) /* 0.262531104 */, + /* 7147 */ 0x0433872e | (19 << 27) /* 0.262580089 */, + /* 7148 */ 0x0433ba8c | (19 << 27) /* 0.262629077 */, + /* 7149 */ 0x0433edea | (19 << 27) /* 0.262678067 */, + /* 7150 */ 0x0434214a | (19 << 27) /* 0.262727059 */, + /* 7151 */ 0x043454aa | (19 << 27) /* 0.262776054 */, + + /* 7152 */ 0x0434880a | (19 << 27) /* 0.262825051 */, + /* 7153 */ 0x0434bb6b | (19 << 27) /* 0.262874050 */, + /* 7154 */ 0x0434eecd | (19 << 27) /* 0.262923051 */, + /* 7155 */ 0x0435222f | (19 << 27) /* 0.262972055 */, + /* 7156 */ 0x04355592 | (19 << 27) /* 0.263021061 */, + /* 7157 */ 0x043588f6 | (19 << 27) /* 0.263070069 */, + /* 7158 */ 0x0435bc5a | (19 << 27) /* 0.263119079 */, + /* 7159 */ 0x0435efbf | (19 << 27) /* 0.263168092 */, + /* 7160 */ 0x04362324 | (19 << 27) /* 0.263217107 */, + /* 7161 */ 0x0436568a | (19 << 27) /* 0.263266125 */, + /* 7162 */ 0x043689f1 | (19 << 27) /* 0.263315144 */, + /* 7163 */ 0x0436bd58 | (19 << 27) /* 0.263364166 */, + /* 7164 */ 0x0436f0c0 | (19 << 27) /* 0.263413191 */, + /* 7165 */ 0x04372428 | (19 << 27) /* 0.263462217 */, + /* 7166 */ 0x04375791 | (19 << 27) /* 0.263511246 */, + /* 7167 */ 0x04378afb | (19 << 27) /* 0.263560277 */, + + /* 7168 */ 0x0437be65 | (19 << 27) /* 0.263609310 */, + /* 7169 */ 0x0437f1d0 | (19 << 27) /* 0.263658346 */, + /* 7170 */ 0x0438253c | (19 << 27) /* 0.263707384 */, + /* 7171 */ 0x043858a8 | (19 << 27) /* 0.263756424 */, + /* 7172 */ 0x04388c14 | (19 << 27) /* 0.263805466 */, + /* 7173 */ 0x0438bf82 | (19 << 27) /* 0.263854511 */, + /* 7174 */ 0x0438f2f0 | (19 << 27) /* 0.263903558 */, + /* 7175 */ 0x0439265e | (19 << 27) /* 0.263952607 */, + /* 7176 */ 0x043959cd | (19 << 27) /* 0.264001659 */, + /* 7177 */ 0x04398d3d | (19 << 27) /* 0.264050713 */, + /* 7178 */ 0x0439c0ae | (19 << 27) /* 0.264099769 */, + /* 7179 */ 0x0439f41f | (19 << 27) /* 0.264148827 */, + /* 7180 */ 0x043a2790 | (19 << 27) /* 0.264197888 */, + /* 7181 */ 0x043a5b02 | (19 << 27) /* 0.264246951 */, + /* 7182 */ 0x043a8e75 | (19 << 27) /* 0.264296016 */, + /* 7183 */ 0x043ac1e9 | (19 << 27) /* 0.264345084 */, + + /* 7184 */ 0x043af55d | (19 << 27) /* 0.264394153 */, + /* 7185 */ 0x043b28d2 | (19 << 27) /* 0.264443225 */, + /* 7186 */ 0x043b5c47 | (19 << 27) /* 0.264492300 */, + /* 7187 */ 0x043b8fbd | (19 << 27) /* 0.264541376 */, + /* 7188 */ 0x043bc333 | (19 << 27) /* 0.264590455 */, + /* 7189 */ 0x043bf6aa | (19 << 27) /* 0.264639536 */, + /* 7190 */ 0x043c2a22 | (19 << 27) /* 0.264688620 */, + /* 7191 */ 0x043c5d9a | (19 << 27) /* 0.264737706 */, + /* 7192 */ 0x043c9113 | (19 << 27) /* 0.264786794 */, + /* 7193 */ 0x043cc48d | (19 << 27) /* 0.264835884 */, + /* 7194 */ 0x043cf807 | (19 << 27) /* 0.264884976 */, + /* 7195 */ 0x043d2b82 | (19 << 27) /* 0.264934071 */, + /* 7196 */ 0x043d5efd | (19 << 27) /* 0.264983168 */, + /* 7197 */ 0x043d9279 | (19 << 27) /* 0.265032268 */, + /* 7198 */ 0x043dc5f6 | (19 << 27) /* 0.265081369 */, + /* 7199 */ 0x043df973 | (19 << 27) /* 0.265130473 */, + + /* 7200 */ 0x043e2cf1 | (19 << 27) /* 0.265179580 */, + /* 7201 */ 0x043e6070 | (19 << 27) /* 0.265228688 */, + /* 7202 */ 0x043e93ef | (19 << 27) /* 0.265277799 */, + /* 7203 */ 0x043ec76e | (19 << 27) /* 0.265326912 */, + /* 7204 */ 0x043efaef | (19 << 27) /* 0.265376027 */, + /* 7205 */ 0x043f2e6f | (19 << 27) /* 0.265425145 */, + /* 7206 */ 0x043f61f1 | (19 << 27) /* 0.265474264 */, + /* 7207 */ 0x043f9573 | (19 << 27) /* 0.265523387 */, + /* 7208 */ 0x043fc8f6 | (19 << 27) /* 0.265572511 */, + /* 7209 */ 0x043ffc79 | (19 << 27) /* 0.265621638 */, + /* 7210 */ 0x04402ffd | (19 << 27) /* 0.265670766 */, + /* 7211 */ 0x04406382 | (19 << 27) /* 0.265719898 */, + /* 7212 */ 0x04409707 | (19 << 27) /* 0.265769031 */, + /* 7213 */ 0x0440ca8d | (19 << 27) /* 0.265818167 */, + /* 7214 */ 0x0440fe13 | (19 << 27) /* 0.265867305 */, + /* 7215 */ 0x0441319a | (19 << 27) /* 0.265916445 */, + + /* 7216 */ 0x04416522 | (19 << 27) /* 0.265965588 */, + /* 7217 */ 0x044198aa | (19 << 27) /* 0.266014732 */, + /* 7218 */ 0x0441cc33 | (19 << 27) /* 0.266063880 */, + /* 7219 */ 0x0441ffbc | (19 << 27) /* 0.266113029 */, + /* 7220 */ 0x04423346 | (19 << 27) /* 0.266162181 */, + /* 7221 */ 0x044266d1 | (19 << 27) /* 0.266211334 */, + /* 7222 */ 0x04429a5c | (19 << 27) /* 0.266260491 */, + /* 7223 */ 0x0442cde8 | (19 << 27) /* 0.266309649 */, + /* 7224 */ 0x04430174 | (19 << 27) /* 0.266358810 */, + /* 7225 */ 0x04433501 | (19 << 27) /* 0.266407973 */, + /* 7226 */ 0x0443688f | (19 << 27) /* 0.266457138 */, + /* 7227 */ 0x04439c1d | (19 << 27) /* 0.266506305 */, + /* 7228 */ 0x0443cfac | (19 << 27) /* 0.266555475 */, + /* 7229 */ 0x0444033c | (19 << 27) /* 0.266604647 */, + /* 7230 */ 0x044436cc | (19 << 27) /* 0.266653822 */, + /* 7231 */ 0x04446a5d | (19 << 27) /* 0.266702998 */, + + /* 7232 */ 0x04449dee | (19 << 27) /* 0.266752177 */, + /* 7233 */ 0x0444d180 | (19 << 27) /* 0.266801358 */, + /* 7234 */ 0x04450513 | (19 << 27) /* 0.266850541 */, + /* 7235 */ 0x044538a6 | (19 << 27) /* 0.266899727 */, + /* 7236 */ 0x04456c39 | (19 << 27) /* 0.266948915 */, + /* 7237 */ 0x04459fce | (19 << 27) /* 0.266998105 */, + /* 7238 */ 0x0445d363 | (19 << 27) /* 0.267047298 */, + /* 7239 */ 0x044606f8 | (19 << 27) /* 0.267096492 */, + /* 7240 */ 0x04463a8f | (19 << 27) /* 0.267145689 */, + /* 7241 */ 0x04466e25 | (19 << 27) /* 0.267194888 */, + /* 7242 */ 0x0446a1bd | (19 << 27) /* 0.267244090 */, + /* 7243 */ 0x0446d555 | (19 << 27) /* 0.267293294 */, + /* 7244 */ 0x044708ee | (19 << 27) /* 0.267342500 */, + /* 7245 */ 0x04473c87 | (19 << 27) /* 0.267391708 */, + /* 7246 */ 0x04477021 | (19 << 27) /* 0.267440919 */, + /* 7247 */ 0x0447a3bb | (19 << 27) /* 0.267490131 */, + + /* 7248 */ 0x0447d756 | (19 << 27) /* 0.267539347 */, + /* 7249 */ 0x04480af2 | (19 << 27) /* 0.267588564 */, + /* 7250 */ 0x04483e8e | (19 << 27) /* 0.267637783 */, + /* 7251 */ 0x0448722b | (19 << 27) /* 0.267687005 */, + /* 7252 */ 0x0448a5c9 | (19 << 27) /* 0.267736229 */, + /* 7253 */ 0x0448d967 | (19 << 27) /* 0.267785456 */, + /* 7254 */ 0x04490d05 | (19 << 27) /* 0.267834685 */, + /* 7255 */ 0x044940a5 | (19 << 27) /* 0.267883915 */, + /* 7256 */ 0x04497445 | (19 << 27) /* 0.267933149 */, + /* 7257 */ 0x0449a7e5 | (19 << 27) /* 0.267982384 */, + /* 7258 */ 0x0449db86 | (19 << 27) /* 0.268031622 */, + /* 7259 */ 0x044a0f28 | (19 << 27) /* 0.268080862 */, + /* 7260 */ 0x044a42ca | (19 << 27) /* 0.268130104 */, + /* 7261 */ 0x044a766d | (19 << 27) /* 0.268179349 */, + /* 7262 */ 0x044aaa11 | (19 << 27) /* 0.268228595 */, + /* 7263 */ 0x044addb5 | (19 << 27) /* 0.268277844 */, + + /* 7264 */ 0x044b115a | (19 << 27) /* 0.268327096 */, + /* 7265 */ 0x044b44ff | (19 << 27) /* 0.268376349 */, + /* 7266 */ 0x044b78a5 | (19 << 27) /* 0.268425605 */, + /* 7267 */ 0x044bac4c | (19 << 27) /* 0.268474863 */, + /* 7268 */ 0x044bdff3 | (19 << 27) /* 0.268524123 */, + /* 7269 */ 0x044c139b | (19 << 27) /* 0.268573386 */, + /* 7270 */ 0x044c4743 | (19 << 27) /* 0.268622651 */, + /* 7271 */ 0x044c7aec | (19 << 27) /* 0.268671918 */, + /* 7272 */ 0x044cae96 | (19 << 27) /* 0.268721187 */, + /* 7273 */ 0x044ce240 | (19 << 27) /* 0.268770459 */, + /* 7274 */ 0x044d15eb | (19 << 27) /* 0.268819733 */, + /* 7275 */ 0x044d4997 | (19 << 27) /* 0.268869009 */, + /* 7276 */ 0x044d7d43 | (19 << 27) /* 0.268918287 */, + /* 7277 */ 0x044db0ef | (19 << 27) /* 0.268967568 */, + /* 7278 */ 0x044de49d | (19 << 27) /* 0.269016851 */, + /* 7279 */ 0x044e184b | (19 << 27) /* 0.269066136 */, + + /* 7280 */ 0x044e4bf9 | (19 << 27) /* 0.269115423 */, + /* 7281 */ 0x044e7fa8 | (19 << 27) /* 0.269164713 */, + /* 7282 */ 0x044eb358 | (19 << 27) /* 0.269214005 */, + /* 7283 */ 0x044ee708 | (19 << 27) /* 0.269263299 */, + /* 7284 */ 0x044f1ab9 | (19 << 27) /* 0.269312595 */, + /* 7285 */ 0x044f4e6b | (19 << 27) /* 0.269361894 */, + /* 7286 */ 0x044f821d | (19 << 27) /* 0.269411195 */, + /* 7287 */ 0x044fb5cf | (19 << 27) /* 0.269460498 */, + /* 7288 */ 0x044fe983 | (19 << 27) /* 0.269509804 */, + /* 7289 */ 0x04501d37 | (19 << 27) /* 0.269559111 */, + /* 7290 */ 0x045050eb | (19 << 27) /* 0.269608421 */, + /* 7291 */ 0x045084a0 | (19 << 27) /* 0.269657734 */, + /* 7292 */ 0x0450b856 | (19 << 27) /* 0.269707048 */, + /* 7293 */ 0x0450ec0d | (19 << 27) /* 0.269756365 */, + /* 7294 */ 0x04511fc4 | (19 << 27) /* 0.269805684 */, + /* 7295 */ 0x0451537b | (19 << 27) /* 0.269855005 */, + + /* 7296 */ 0x04518733 | (19 << 27) /* 0.269904329 */, + /* 7297 */ 0x0451baec | (19 << 27) /* 0.269953654 */, + /* 7298 */ 0x0451eea5 | (19 << 27) /* 0.270002982 */, + /* 7299 */ 0x0452225f | (19 << 27) /* 0.270052313 */, + /* 7300 */ 0x0452561a | (19 << 27) /* 0.270101645 */, + /* 7301 */ 0x045289d5 | (19 << 27) /* 0.270150980 */, + /* 7302 */ 0x0452bd91 | (19 << 27) /* 0.270200317 */, + /* 7303 */ 0x0452f14d | (19 << 27) /* 0.270249656 */, + /* 7304 */ 0x0453250a | (19 << 27) /* 0.270298998 */, + /* 7305 */ 0x045358c8 | (19 << 27) /* 0.270348341 */, + /* 7306 */ 0x04538c86 | (19 << 27) /* 0.270397687 */, + /* 7307 */ 0x0453c045 | (19 << 27) /* 0.270447036 */, + /* 7308 */ 0x0453f405 | (19 << 27) /* 0.270496386 */, + /* 7309 */ 0x045427c5 | (19 << 27) /* 0.270545739 */, + /* 7310 */ 0x04545b85 | (19 << 27) /* 0.270595094 */, + /* 7311 */ 0x04548f46 | (19 << 27) /* 0.270644451 */, + + /* 7312 */ 0x0454c308 | (19 << 27) /* 0.270693811 */, + /* 7313 */ 0x0454f6cb | (19 << 27) /* 0.270743173 */, + /* 7314 */ 0x04552a8e | (19 << 27) /* 0.270792537 */, + /* 7315 */ 0x04555e51 | (19 << 27) /* 0.270841903 */, + /* 7316 */ 0x04559216 | (19 << 27) /* 0.270891271 */, + /* 7317 */ 0x0455c5db | (19 << 27) /* 0.270940642 */, + /* 7318 */ 0x0455f9a0 | (19 << 27) /* 0.270990015 */, + /* 7319 */ 0x04562d66 | (19 << 27) /* 0.271039390 */, + /* 7320 */ 0x0456612d | (19 << 27) /* 0.271088768 */, + /* 7321 */ 0x045694f4 | (19 << 27) /* 0.271138148 */, + /* 7322 */ 0x0456c8bc | (19 << 27) /* 0.271187530 */, + /* 7323 */ 0x0456fc84 | (19 << 27) /* 0.271236914 */, + /* 7324 */ 0x0457304e | (19 << 27) /* 0.271286301 */, + /* 7325 */ 0x04576417 | (19 << 27) /* 0.271335689 */, + /* 7326 */ 0x045797e2 | (19 << 27) /* 0.271385080 */, + /* 7327 */ 0x0457cbac | (19 << 27) /* 0.271434474 */, + + /* 7328 */ 0x0457ff78 | (19 << 27) /* 0.271483869 */, + /* 7329 */ 0x04583344 | (19 << 27) /* 0.271533267 */, + /* 7330 */ 0x04586711 | (19 << 27) /* 0.271582667 */, + /* 7331 */ 0x04589ade | (19 << 27) /* 0.271632069 */, + /* 7332 */ 0x0458ceac | (19 << 27) /* 0.271681474 */, + /* 7333 */ 0x0459027b | (19 << 27) /* 0.271730880 */, + /* 7334 */ 0x0459364a | (19 << 27) /* 0.271780289 */, + /* 7335 */ 0x04596a19 | (19 << 27) /* 0.271829701 */, + /* 7336 */ 0x04599dea | (19 << 27) /* 0.271879114 */, + /* 7337 */ 0x0459d1bb | (19 << 27) /* 0.271928530 */, + /* 7338 */ 0x045a058c | (19 << 27) /* 0.271977948 */, + /* 7339 */ 0x045a395e | (19 << 27) /* 0.272027368 */, + /* 7340 */ 0x045a6d31 | (19 << 27) /* 0.272076790 */, + /* 7341 */ 0x045aa104 | (19 << 27) /* 0.272126215 */, + /* 7342 */ 0x045ad4d8 | (19 << 27) /* 0.272175642 */, + /* 7343 */ 0x045b08ad | (19 << 27) /* 0.272225071 */, + + /* 7344 */ 0x045b3c82 | (19 << 27) /* 0.272274503 */, + /* 7345 */ 0x045b7058 | (19 << 27) /* 0.272323936 */, + /* 7346 */ 0x045ba42e | (19 << 27) /* 0.272373372 */, + /* 7347 */ 0x045bd805 | (19 << 27) /* 0.272422810 */, + /* 7348 */ 0x045c0bdd | (19 << 27) /* 0.272472251 */, + /* 7349 */ 0x045c3fb5 | (19 << 27) /* 0.272521693 */, + /* 7350 */ 0x045c738e | (19 << 27) /* 0.272571138 */, + /* 7351 */ 0x045ca767 | (19 << 27) /* 0.272620585 */, + /* 7352 */ 0x045cdb41 | (19 << 27) /* 0.272670035 */, + /* 7353 */ 0x045d0f1b | (19 << 27) /* 0.272719486 */, + /* 7354 */ 0x045d42f7 | (19 << 27) /* 0.272768940 */, + /* 7355 */ 0x045d76d2 | (19 << 27) /* 0.272818396 */, + /* 7356 */ 0x045daaaf | (19 << 27) /* 0.272867855 */, + /* 7357 */ 0x045dde8c | (19 << 27) /* 0.272917315 */, + /* 7358 */ 0x045e1269 | (19 << 27) /* 0.272966778 */, + /* 7359 */ 0x045e4647 | (19 << 27) /* 0.273016243 */, + + /* 7360 */ 0x045e7a26 | (19 << 27) /* 0.273065710 */, + /* 7361 */ 0x045eae06 | (19 << 27) /* 0.273115180 */, + /* 7362 */ 0x045ee1e6 | (19 << 27) /* 0.273164652 */, + /* 7363 */ 0x045f15c6 | (19 << 27) /* 0.273214126 */, + /* 7364 */ 0x045f49a7 | (19 << 27) /* 0.273263602 */, + /* 7365 */ 0x045f7d89 | (19 << 27) /* 0.273313081 */, + /* 7366 */ 0x045fb16c | (19 << 27) /* 0.273362561 */, + /* 7367 */ 0x045fe54f | (19 << 27) /* 0.273412044 */, + /* 7368 */ 0x04601932 | (19 << 27) /* 0.273461530 */, + /* 7369 */ 0x04604d16 | (19 << 27) /* 0.273511017 */, + /* 7370 */ 0x046080fb | (19 << 27) /* 0.273560507 */, + /* 7371 */ 0x0460b4e1 | (19 << 27) /* 0.273609999 */, + /* 7372 */ 0x0460e8c7 | (19 << 27) /* 0.273659493 */, + /* 7373 */ 0x04611cad | (19 << 27) /* 0.273708989 */, + /* 7374 */ 0x04615094 | (19 << 27) /* 0.273758488 */, + /* 7375 */ 0x0461847c | (19 << 27) /* 0.273807989 */, + + /* 7376 */ 0x0461b864 | (19 << 27) /* 0.273857492 */, + /* 7377 */ 0x0461ec4d | (19 << 27) /* 0.273906997 */, + /* 7378 */ 0x04622037 | (19 << 27) /* 0.273956505 */, + /* 7379 */ 0x04625421 | (19 << 27) /* 0.274006015 */, + /* 7380 */ 0x0462880c | (19 << 27) /* 0.274055527 */, + /* 7381 */ 0x0462bbf7 | (19 << 27) /* 0.274105041 */, + /* 7382 */ 0x0462efe3 | (19 << 27) /* 0.274154558 */, + /* 7383 */ 0x046323d0 | (19 << 27) /* 0.274204076 */, + /* 7384 */ 0x046357bd | (19 << 27) /* 0.274253597 */, + /* 7385 */ 0x04638bab | (19 << 27) /* 0.274303121 */, + /* 7386 */ 0x0463bf99 | (19 << 27) /* 0.274352646 */, + /* 7387 */ 0x0463f388 | (19 << 27) /* 0.274402174 */, + /* 7388 */ 0x04642778 | (19 << 27) /* 0.274451704 */, + /* 7389 */ 0x04645b68 | (19 << 27) /* 0.274501236 */, + /* 7390 */ 0x04648f59 | (19 << 27) /* 0.274550771 */, + /* 7391 */ 0x0464c34a | (19 << 27) /* 0.274600307 */, + + /* 7392 */ 0x0464f73c | (19 << 27) /* 0.274649846 */, + /* 7393 */ 0x04652b2f | (19 << 27) /* 0.274699387 */, + /* 7394 */ 0x04655f22 | (19 << 27) /* 0.274748931 */, + /* 7395 */ 0x04659316 | (19 << 27) /* 0.274798476 */, + /* 7396 */ 0x0465c70a | (19 << 27) /* 0.274848024 */, + /* 7397 */ 0x0465faff | (19 << 27) /* 0.274897574 */, + /* 7398 */ 0x04662ef5 | (19 << 27) /* 0.274947126 */, + /* 7399 */ 0x046662eb | (19 << 27) /* 0.274996681 */, + /* 7400 */ 0x046696e2 | (19 << 27) /* 0.275046238 */, + /* 7401 */ 0x0466cad9 | (19 << 27) /* 0.275095797 */, + /* 7402 */ 0x0466fed1 | (19 << 27) /* 0.275145358 */, + /* 7403 */ 0x046732ca | (19 << 27) /* 0.275194921 */, + /* 7404 */ 0x046766c3 | (19 << 27) /* 0.275244487 */, + /* 7405 */ 0x04679abd | (19 << 27) /* 0.275294055 */, + /* 7406 */ 0x0467ceb7 | (19 << 27) /* 0.275343625 */, + /* 7407 */ 0x046802b2 | (19 << 27) /* 0.275393198 */, + + /* 7408 */ 0x046836ae | (19 << 27) /* 0.275442772 */, + /* 7409 */ 0x04686aaa | (19 << 27) /* 0.275492349 */, + /* 7410 */ 0x04689ea7 | (19 << 27) /* 0.275541928 */, + /* 7411 */ 0x0468d2a4 | (19 << 27) /* 0.275591509 */, + /* 7412 */ 0x046906a2 | (19 << 27) /* 0.275641093 */, + /* 7413 */ 0x04693aa1 | (19 << 27) /* 0.275690679 */, + /* 7414 */ 0x04696ea0 | (19 << 27) /* 0.275740267 */, + /* 7415 */ 0x0469a2a0 | (19 << 27) /* 0.275789857 */, + /* 7416 */ 0x0469d6a0 | (19 << 27) /* 0.275839449 */, + /* 7417 */ 0x046a0aa1 | (19 << 27) /* 0.275889044 */, + /* 7418 */ 0x046a3ea3 | (19 << 27) /* 0.275938641 */, + /* 7419 */ 0x046a72a5 | (19 << 27) /* 0.275988240 */, + /* 7420 */ 0x046aa6a8 | (19 << 27) /* 0.276037842 */, + /* 7421 */ 0x046adaab | (19 << 27) /* 0.276087445 */, + /* 7422 */ 0x046b0eaf | (19 << 27) /* 0.276137051 */, + /* 7423 */ 0x046b42b3 | (19 << 27) /* 0.276186659 */, + + /* 7424 */ 0x046b76b9 | (19 << 27) /* 0.276236269 */, + /* 7425 */ 0x046baabe | (19 << 27) /* 0.276285882 */, + /* 7426 */ 0x046bdec5 | (19 << 27) /* 0.276335497 */, + /* 7427 */ 0x046c12cc | (19 << 27) /* 0.276385113 */, + /* 7428 */ 0x046c46d3 | (19 << 27) /* 0.276434733 */, + /* 7429 */ 0x046c7adb | (19 << 27) /* 0.276484354 */, + /* 7430 */ 0x046caee4 | (19 << 27) /* 0.276533978 */, + /* 7431 */ 0x046ce2ee | (19 << 27) /* 0.276583604 */, + /* 7432 */ 0x046d16f7 | (19 << 27) /* 0.276633232 */, + /* 7433 */ 0x046d4b02 | (19 << 27) /* 0.276682862 */, + /* 7434 */ 0x046d7f0d | (19 << 27) /* 0.276732495 */, + /* 7435 */ 0x046db319 | (19 << 27) /* 0.276782129 */, + /* 7436 */ 0x046de725 | (19 << 27) /* 0.276831766 */, + /* 7437 */ 0x046e1b32 | (19 << 27) /* 0.276881406 */, + /* 7438 */ 0x046e4f40 | (19 << 27) /* 0.276931047 */, + /* 7439 */ 0x046e834e | (19 << 27) /* 0.276980691 */, + + /* 7440 */ 0x046eb75c | (19 << 27) /* 0.277030337 */, + /* 7441 */ 0x046eeb6c | (19 << 27) /* 0.277079985 */, + /* 7442 */ 0x046f1f7c | (19 << 27) /* 0.277129635 */, + /* 7443 */ 0x046f538c | (19 << 27) /* 0.277179288 */, + /* 7444 */ 0x046f879d | (19 << 27) /* 0.277228942 */, + /* 7445 */ 0x046fbbaf | (19 << 27) /* 0.277278600 */, + /* 7446 */ 0x046fefc1 | (19 << 27) /* 0.277328259 */, + /* 7447 */ 0x047023d4 | (19 << 27) /* 0.277377920 */, + /* 7448 */ 0x047057e8 | (19 << 27) /* 0.277427584 */, + /* 7449 */ 0x04708bfc | (19 << 27) /* 0.277477250 */, + /* 7450 */ 0x0470c011 | (19 << 27) /* 0.277526918 */, + /* 7451 */ 0x0470f426 | (19 << 27) /* 0.277576588 */, + /* 7452 */ 0x0471283c | (19 << 27) /* 0.277626261 */, + /* 7453 */ 0x04715c52 | (19 << 27) /* 0.277675936 */, + /* 7454 */ 0x04719069 | (19 << 27) /* 0.277725613 */, + /* 7455 */ 0x0471c481 | (19 << 27) /* 0.277775292 */, + + /* 7456 */ 0x0471f899 | (19 << 27) /* 0.277824973 */, + /* 7457 */ 0x04722cb2 | (19 << 27) /* 0.277874657 */, + /* 7458 */ 0x047260cc | (19 << 27) /* 0.277924343 */, + /* 7459 */ 0x047294e6 | (19 << 27) /* 0.277974031 */, + /* 7460 */ 0x0472c900 | (19 << 27) /* 0.278023722 */, + /* 7461 */ 0x0472fd1b | (19 << 27) /* 0.278073414 */, + /* 7462 */ 0x04733137 | (19 << 27) /* 0.278123109 */, + /* 7463 */ 0x04736554 | (19 << 27) /* 0.278172806 */, + /* 7464 */ 0x04739971 | (19 << 27) /* 0.278222505 */, + /* 7465 */ 0x0473cd8e | (19 << 27) /* 0.278272207 */, + /* 7466 */ 0x047401ad | (19 << 27) /* 0.278321910 */, + /* 7467 */ 0x047435cb | (19 << 27) /* 0.278371616 */, + /* 7468 */ 0x047469eb | (19 << 27) /* 0.278421324 */, + /* 7469 */ 0x04749e0b | (19 << 27) /* 0.278471035 */, + /* 7470 */ 0x0474d22c | (19 << 27) /* 0.278520747 */, + /* 7471 */ 0x0475064d | (19 << 27) /* 0.278570462 */, + + /* 7472 */ 0x04753a6f | (19 << 27) /* 0.278620179 */, + /* 7473 */ 0x04756e91 | (19 << 27) /* 0.278669898 */, + /* 7474 */ 0x0475a2b4 | (19 << 27) /* 0.278719619 */, + /* 7475 */ 0x0475d6d7 | (19 << 27) /* 0.278769343 */, + /* 7476 */ 0x04760afc | (19 << 27) /* 0.278819069 */, + /* 7477 */ 0x04763f20 | (19 << 27) /* 0.278868797 */, + /* 7478 */ 0x04767346 | (19 << 27) /* 0.278918527 */, + /* 7479 */ 0x0476a76c | (19 << 27) /* 0.278968260 */, + /* 7480 */ 0x0476db92 | (19 << 27) /* 0.279017995 */, + /* 7481 */ 0x04770fba | (19 << 27) /* 0.279067731 */, + /* 7482 */ 0x047743e1 | (19 << 27) /* 0.279117471 */, + /* 7483 */ 0x0477780a | (19 << 27) /* 0.279167212 */, + /* 7484 */ 0x0477ac33 | (19 << 27) /* 0.279216956 */, + /* 7485 */ 0x0477e05c | (19 << 27) /* 0.279266701 */, + /* 7486 */ 0x04781486 | (19 << 27) /* 0.279316449 */, + /* 7487 */ 0x047848b1 | (19 << 27) /* 0.279366200 */, + + /* 7488 */ 0x04787cdc | (19 << 27) /* 0.279415952 */, + /* 7489 */ 0x0478b108 | (19 << 27) /* 0.279465707 */, + /* 7490 */ 0x0478e535 | (19 << 27) /* 0.279515464 */, + /* 7491 */ 0x04791962 | (19 << 27) /* 0.279565223 */, + /* 7492 */ 0x04794d8f | (19 << 27) /* 0.279614984 */, + /* 7493 */ 0x047981be | (19 << 27) /* 0.279664748 */, + /* 7494 */ 0x0479b5ed | (19 << 27) /* 0.279714513 */, + /* 7495 */ 0x0479ea1c | (19 << 27) /* 0.279764281 */, + /* 7496 */ 0x047a1e4c | (19 << 27) /* 0.279814051 */, + /* 7497 */ 0x047a527d | (19 << 27) /* 0.279863824 */, + /* 7498 */ 0x047a86ae | (19 << 27) /* 0.279913598 */, + /* 7499 */ 0x047abae0 | (19 << 27) /* 0.279963375 */, + /* 7500 */ 0x047aef12 | (19 << 27) /* 0.280013154 */, + /* 7501 */ 0x047b2346 | (19 << 27) /* 0.280062935 */, + /* 7502 */ 0x047b5779 | (19 << 27) /* 0.280112719 */, + /* 7503 */ 0x047b8bad | (19 << 27) /* 0.280162504 */, + + /* 7504 */ 0x047bbfe2 | (19 << 27) /* 0.280212292 */, + /* 7505 */ 0x047bf418 | (19 << 27) /* 0.280262082 */, + /* 7506 */ 0x047c284e | (19 << 27) /* 0.280311875 */, + /* 7507 */ 0x047c5c84 | (19 << 27) /* 0.280361669 */, + /* 7508 */ 0x047c90bb | (19 << 27) /* 0.280411466 */, + /* 7509 */ 0x047cc4f3 | (19 << 27) /* 0.280461265 */, + /* 7510 */ 0x047cf92c | (19 << 27) /* 0.280511066 */, + /* 7511 */ 0x047d2d65 | (19 << 27) /* 0.280560869 */, + /* 7512 */ 0x047d619e | (19 << 27) /* 0.280610675 */, + /* 7513 */ 0x047d95d8 | (19 << 27) /* 0.280660483 */, + /* 7514 */ 0x047dca13 | (19 << 27) /* 0.280710292 */, + /* 7515 */ 0x047dfe4e | (19 << 27) /* 0.280760105 */, + /* 7516 */ 0x047e328a | (19 << 27) /* 0.280809919 */, + /* 7517 */ 0x047e66c7 | (19 << 27) /* 0.280859736 */, + /* 7518 */ 0x047e9b04 | (19 << 27) /* 0.280909554 */, + /* 7519 */ 0x047ecf42 | (19 << 27) /* 0.280959375 */, + + /* 7520 */ 0x047f0380 | (19 << 27) /* 0.281009199 */, + /* 7521 */ 0x047f37bf | (19 << 27) /* 0.281059024 */, + /* 7522 */ 0x047f6bff | (19 << 27) /* 0.281108852 */, + /* 7523 */ 0x047fa03f | (19 << 27) /* 0.281158682 */, + /* 7524 */ 0x047fd47f | (19 << 27) /* 0.281208514 */, + /* 7525 */ 0x048008c1 | (19 << 27) /* 0.281258348 */, + /* 7526 */ 0x04803d02 | (19 << 27) /* 0.281308184 */, + /* 7527 */ 0x04807145 | (19 << 27) /* 0.281358023 */, + /* 7528 */ 0x0480a588 | (19 << 27) /* 0.281407864 */, + /* 7529 */ 0x0480d9cc | (19 << 27) /* 0.281457707 */, + /* 7530 */ 0x04810e10 | (19 << 27) /* 0.281507552 */, + /* 7531 */ 0x04814255 | (19 << 27) /* 0.281557400 */, + /* 7532 */ 0x0481769a | (19 << 27) /* 0.281607250 */, + /* 7533 */ 0x0481aae0 | (19 << 27) /* 0.281657101 */, + /* 7534 */ 0x0481df27 | (19 << 27) /* 0.281706956 */, + /* 7535 */ 0x0482136e | (19 << 27) /* 0.281756812 */, + + /* 7536 */ 0x048247b6 | (19 << 27) /* 0.281806670 */, + /* 7537 */ 0x04827bfe | (19 << 27) /* 0.281856531 */, + /* 7538 */ 0x0482b047 | (19 << 27) /* 0.281906394 */, + /* 7539 */ 0x0482e491 | (19 << 27) /* 0.281956259 */, + /* 7540 */ 0x048318db | (19 << 27) /* 0.282006127 */, + /* 7541 */ 0x04834d26 | (19 << 27) /* 0.282055996 */, + /* 7542 */ 0x04838171 | (19 << 27) /* 0.282105868 */, + /* 7543 */ 0x0483b5bd | (19 << 27) /* 0.282155742 */, + /* 7544 */ 0x0483ea0a | (19 << 27) /* 0.282205618 */, + /* 7545 */ 0x04841e57 | (19 << 27) /* 0.282255496 */, + /* 7546 */ 0x048452a4 | (19 << 27) /* 0.282305377 */, + /* 7547 */ 0x048486f3 | (19 << 27) /* 0.282355260 */, + /* 7548 */ 0x0484bb42 | (19 << 27) /* 0.282405145 */, + /* 7549 */ 0x0484ef91 | (19 << 27) /* 0.282455032 */, + /* 7550 */ 0x048523e1 | (19 << 27) /* 0.282504921 */, + /* 7551 */ 0x04855832 | (19 << 27) /* 0.282554813 */, + + /* 7552 */ 0x04858c83 | (19 << 27) /* 0.282604707 */, + /* 7553 */ 0x0485c0d5 | (19 << 27) /* 0.282654603 */, + /* 7554 */ 0x0485f527 | (19 << 27) /* 0.282704501 */, + /* 7555 */ 0x0486297a | (19 << 27) /* 0.282754401 */, + /* 7556 */ 0x04865dce | (19 << 27) /* 0.282804304 */, + /* 7557 */ 0x04869222 | (19 << 27) /* 0.282854209 */, + /* 7558 */ 0x0486c677 | (19 << 27) /* 0.282904116 */, + /* 7559 */ 0x0486facc | (19 << 27) /* 0.282954025 */, + /* 7560 */ 0x04872f22 | (19 << 27) /* 0.283003936 */, + /* 7561 */ 0x04876379 | (19 << 27) /* 0.283053850 */, + /* 7562 */ 0x048797d0 | (19 << 27) /* 0.283103766 */, + /* 7563 */ 0x0487cc28 | (19 << 27) /* 0.283153684 */, + /* 7564 */ 0x04880080 | (19 << 27) /* 0.283203604 */, + /* 7565 */ 0x048834d9 | (19 << 27) /* 0.283253527 */, + /* 7566 */ 0x04886933 | (19 << 27) /* 0.283303451 */, + /* 7567 */ 0x04889d8d | (19 << 27) /* 0.283353378 */, + + /* 7568 */ 0x0488d1e8 | (19 << 27) /* 0.283403307 */, + /* 7569 */ 0x04890643 | (19 << 27) /* 0.283453238 */, + /* 7570 */ 0x04893a9f | (19 << 27) /* 0.283503172 */, + /* 7571 */ 0x04896efb | (19 << 27) /* 0.283553107 */, + /* 7572 */ 0x0489a358 | (19 << 27) /* 0.283603045 */, + /* 7573 */ 0x0489d7b6 | (19 << 27) /* 0.283652985 */, + /* 7574 */ 0x048a0c14 | (19 << 27) /* 0.283702927 */, + /* 7575 */ 0x048a4073 | (19 << 27) /* 0.283752872 */, + /* 7576 */ 0x048a74d3 | (19 << 27) /* 0.283802818 */, + /* 7577 */ 0x048aa933 | (19 << 27) /* 0.283852767 */, + /* 7578 */ 0x048add93 | (19 << 27) /* 0.283902718 */, + /* 7579 */ 0x048b11f5 | (19 << 27) /* 0.283952671 */, + /* 7580 */ 0x048b4656 | (19 << 27) /* 0.284002627 */, + /* 7581 */ 0x048b7ab9 | (19 << 27) /* 0.284052584 */, + /* 7582 */ 0x048baf1c | (19 << 27) /* 0.284102544 */, + /* 7583 */ 0x048be37f | (19 << 27) /* 0.284152506 */, + + /* 7584 */ 0x048c17e3 | (19 << 27) /* 0.284202470 */, + /* 7585 */ 0x048c4c48 | (19 << 27) /* 0.284252436 */, + /* 7586 */ 0x048c80ad | (19 << 27) /* 0.284302405 */, + /* 7587 */ 0x048cb513 | (19 << 27) /* 0.284352376 */, + /* 7588 */ 0x048ce97a | (19 << 27) /* 0.284402349 */, + /* 7589 */ 0x048d1de1 | (19 << 27) /* 0.284452324 */, + /* 7590 */ 0x048d5249 | (19 << 27) /* 0.284502301 */, + /* 7591 */ 0x048d86b1 | (19 << 27) /* 0.284552281 */, + /* 7592 */ 0x048dbb1a | (19 << 27) /* 0.284602263 */, + /* 7593 */ 0x048def83 | (19 << 27) /* 0.284652246 */, + /* 7594 */ 0x048e23ed | (19 << 27) /* 0.284702233 */, + /* 7595 */ 0x048e5858 | (19 << 27) /* 0.284752221 */, + /* 7596 */ 0x048e8cc3 | (19 << 27) /* 0.284802211 */, + /* 7597 */ 0x048ec12f | (19 << 27) /* 0.284852204 */, + /* 7598 */ 0x048ef59b | (19 << 27) /* 0.284902199 */, + /* 7599 */ 0x048f2a08 | (19 << 27) /* 0.284952196 */, + + /* 7600 */ 0x048f5e76 | (19 << 27) /* 0.285002195 */, + /* 7601 */ 0x048f92e4 | (19 << 27) /* 0.285052197 */, + /* 7602 */ 0x048fc753 | (19 << 27) /* 0.285102201 */, + /* 7603 */ 0x048ffbc2 | (19 << 27) /* 0.285152206 */, + /* 7604 */ 0x04903032 | (19 << 27) /* 0.285202214 */, + /* 7605 */ 0x049064a3 | (19 << 27) /* 0.285252225 */, + /* 7606 */ 0x04909914 | (19 << 27) /* 0.285302237 */, + /* 7607 */ 0x0490cd86 | (19 << 27) /* 0.285352252 */, + /* 7608 */ 0x049101f8 | (19 << 27) /* 0.285402269 */, + /* 7609 */ 0x0491366b | (19 << 27) /* 0.285452288 */, + /* 7610 */ 0x04916ade | (19 << 27) /* 0.285502309 */, + /* 7611 */ 0x04919f52 | (19 << 27) /* 0.285552332 */, + /* 7612 */ 0x0491d3c7 | (19 << 27) /* 0.285602358 */, + /* 7613 */ 0x0492083c | (19 << 27) /* 0.285652386 */, + /* 7614 */ 0x04923cb2 | (19 << 27) /* 0.285702416 */, + /* 7615 */ 0x04927128 | (19 << 27) /* 0.285752448 */, + + /* 7616 */ 0x0492a59f | (19 << 27) /* 0.285802482 */, + /* 7617 */ 0x0492da17 | (19 << 27) /* 0.285852519 */, + /* 7618 */ 0x04930e8f | (19 << 27) /* 0.285902557 */, + /* 7619 */ 0x04934308 | (19 << 27) /* 0.285952598 */, + /* 7620 */ 0x04937781 | (19 << 27) /* 0.286002641 */, + /* 7621 */ 0x0493abfb | (19 << 27) /* 0.286052687 */, + /* 7622 */ 0x0493e076 | (19 << 27) /* 0.286102734 */, + /* 7623 */ 0x049414f1 | (19 << 27) /* 0.286152784 */, + /* 7624 */ 0x0494496c | (19 << 27) /* 0.286202836 */, + /* 7625 */ 0x04947de9 | (19 << 27) /* 0.286252890 */, + /* 7626 */ 0x0494b266 | (19 << 27) /* 0.286302946 */, + /* 7627 */ 0x0494e6e3 | (19 << 27) /* 0.286353005 */, + /* 7628 */ 0x04951b61 | (19 << 27) /* 0.286403065 */, + /* 7629 */ 0x04954fe0 | (19 << 27) /* 0.286453128 */, + /* 7630 */ 0x0495845f | (19 << 27) /* 0.286503193 */, + /* 7631 */ 0x0495b8df | (19 << 27) /* 0.286553260 */, + + /* 7632 */ 0x0495ed5f | (19 << 27) /* 0.286603329 */, + /* 7633 */ 0x049621e0 | (19 << 27) /* 0.286653401 */, + /* 7634 */ 0x04965662 | (19 << 27) /* 0.286703475 */, + /* 7635 */ 0x04968ae4 | (19 << 27) /* 0.286753551 */, + /* 7636 */ 0x0496bf67 | (19 << 27) /* 0.286803629 */, + /* 7637 */ 0x0496f3ea | (19 << 27) /* 0.286853709 */, + /* 7638 */ 0x0497286e | (19 << 27) /* 0.286903792 */, + /* 7639 */ 0x04975cf2 | (19 << 27) /* 0.286953876 */, + /* 7640 */ 0x04979177 | (19 << 27) /* 0.287003963 */, + /* 7641 */ 0x0497c5fd | (19 << 27) /* 0.287054052 */, + /* 7642 */ 0x0497fa83 | (19 << 27) /* 0.287104143 */, + /* 7643 */ 0x04982f0a | (19 << 27) /* 0.287154237 */, + /* 7644 */ 0x04986392 | (19 << 27) /* 0.287204332 */, + /* 7645 */ 0x0498981a | (19 << 27) /* 0.287254430 */, + /* 7646 */ 0x0498cca2 | (19 << 27) /* 0.287304530 */, + /* 7647 */ 0x0499012c | (19 << 27) /* 0.287354632 */, + + /* 7648 */ 0x049935b5 | (19 << 27) /* 0.287404737 */, + /* 7649 */ 0x04996a40 | (19 << 27) /* 0.287454843 */, + /* 7650 */ 0x04999ecb | (19 << 27) /* 0.287504952 */, + /* 7651 */ 0x0499d356 | (19 << 27) /* 0.287555063 */, + /* 7652 */ 0x049a07e2 | (19 << 27) /* 0.287605176 */, + /* 7653 */ 0x049a3c6f | (19 << 27) /* 0.287655291 */, + /* 7654 */ 0x049a70fc | (19 << 27) /* 0.287705409 */, + /* 7655 */ 0x049aa58a | (19 << 27) /* 0.287755528 */, + /* 7656 */ 0x049ada19 | (19 << 27) /* 0.287805650 */, + /* 7657 */ 0x049b0ea8 | (19 << 27) /* 0.287855774 */, + /* 7658 */ 0x049b4337 | (19 << 27) /* 0.287905900 */, + /* 7659 */ 0x049b77c8 | (19 << 27) /* 0.287956028 */, + /* 7660 */ 0x049bac58 | (19 << 27) /* 0.288006159 */, + /* 7661 */ 0x049be0ea | (19 << 27) /* 0.288056292 */, + /* 7662 */ 0x049c157c | (19 << 27) /* 0.288106427 */, + /* 7663 */ 0x049c4a0e | (19 << 27) /* 0.288156564 */, + + /* 7664 */ 0x049c7ea1 | (19 << 27) /* 0.288206703 */, + /* 7665 */ 0x049cb335 | (19 << 27) /* 0.288256844 */, + /* 7666 */ 0x049ce7ca | (19 << 27) /* 0.288306988 */, + /* 7667 */ 0x049d1c5e | (19 << 27) /* 0.288357134 */, + /* 7668 */ 0x049d50f4 | (19 << 27) /* 0.288407282 */, + /* 7669 */ 0x049d858a | (19 << 27) /* 0.288457432 */, + /* 7670 */ 0x049dba21 | (19 << 27) /* 0.288507584 */, + /* 7671 */ 0x049deeb8 | (19 << 27) /* 0.288557739 */, + /* 7672 */ 0x049e2350 | (19 << 27) /* 0.288607895 */, + /* 7673 */ 0x049e57e8 | (19 << 27) /* 0.288658054 */, + /* 7674 */ 0x049e8c81 | (19 << 27) /* 0.288708215 */, + /* 7675 */ 0x049ec11b | (19 << 27) /* 0.288758379 */, + /* 7676 */ 0x049ef5b5 | (19 << 27) /* 0.288808544 */, + /* 7677 */ 0x049f2a50 | (19 << 27) /* 0.288858712 */, + /* 7678 */ 0x049f5eeb | (19 << 27) /* 0.288908881 */, + /* 7679 */ 0x049f9387 | (19 << 27) /* 0.288959053 */, + + /* 7680 */ 0x049fc824 | (19 << 27) /* 0.289009227 */, + /* 7681 */ 0x049ffcc1 | (19 << 27) /* 0.289059404 */, + /* 7682 */ 0x04a0315e | (19 << 27) /* 0.289109582 */, + /* 7683 */ 0x04a065fd | (19 << 27) /* 0.289159763 */, + /* 7684 */ 0x04a09a9b | (19 << 27) /* 0.289209946 */, + /* 7685 */ 0x04a0cf3b | (19 << 27) /* 0.289260131 */, + /* 7686 */ 0x04a103db | (19 << 27) /* 0.289310318 */, + /* 7687 */ 0x04a1387b | (19 << 27) /* 0.289360507 */, + /* 7688 */ 0x04a16d1d | (19 << 27) /* 0.289410699 */, + /* 7689 */ 0x04a1a1be | (19 << 27) /* 0.289460893 */, + /* 7690 */ 0x04a1d661 | (19 << 27) /* 0.289511088 */, + /* 7691 */ 0x04a20b04 | (19 << 27) /* 0.289561287 */, + /* 7692 */ 0x04a23fa7 | (19 << 27) /* 0.289611487 */, + /* 7693 */ 0x04a2744b | (19 << 27) /* 0.289661689 */, + /* 7694 */ 0x04a2a8f0 | (19 << 27) /* 0.289711894 */, + /* 7695 */ 0x04a2dd95 | (19 << 27) /* 0.289762101 */, + + /* 7696 */ 0x04a3123b | (19 << 27) /* 0.289812309 */, + /* 7697 */ 0x04a346e2 | (19 << 27) /* 0.289862521 */, + /* 7698 */ 0x04a37b89 | (19 << 27) /* 0.289912734 */, + /* 7699 */ 0x04a3b030 | (19 << 27) /* 0.289962949 */, + /* 7700 */ 0x04a3e4d8 | (19 << 27) /* 0.290013167 */, + /* 7701 */ 0x04a41981 | (19 << 27) /* 0.290063387 */, + /* 7702 */ 0x04a44e2b | (19 << 27) /* 0.290113609 */, + /* 7703 */ 0x04a482d5 | (19 << 27) /* 0.290163833 */, + /* 7704 */ 0x04a4b77f | (19 << 27) /* 0.290214059 */, + /* 7705 */ 0x04a4ec2a | (19 << 27) /* 0.290264288 */, + /* 7706 */ 0x04a520d6 | (19 << 27) /* 0.290314519 */, + /* 7707 */ 0x04a55582 | (19 << 27) /* 0.290364751 */, + /* 7708 */ 0x04a58a2f | (19 << 27) /* 0.290414986 */, + /* 7709 */ 0x04a5bedd | (19 << 27) /* 0.290465224 */, + /* 7710 */ 0x04a5f38b | (19 << 27) /* 0.290515463 */, + /* 7711 */ 0x04a62839 | (19 << 27) /* 0.290565705 */, + + /* 7712 */ 0x04a65ce8 | (19 << 27) /* 0.290615948 */, + /* 7713 */ 0x04a69198 | (19 << 27) /* 0.290666194 */, + /* 7714 */ 0x04a6c648 | (19 << 27) /* 0.290716442 */, + /* 7715 */ 0x04a6faf9 | (19 << 27) /* 0.290766692 */, + /* 7716 */ 0x04a72fab | (19 << 27) /* 0.290816945 */, + /* 7717 */ 0x04a7645d | (19 << 27) /* 0.290867199 */, + /* 7718 */ 0x04a79910 | (19 << 27) /* 0.290917456 */, + /* 7719 */ 0x04a7cdc3 | (19 << 27) /* 0.290967715 */, + /* 7720 */ 0x04a80277 | (19 << 27) /* 0.291017976 */, + /* 7721 */ 0x04a8372b | (19 << 27) /* 0.291068239 */, + /* 7722 */ 0x04a86be0 | (19 << 27) /* 0.291118505 */, + /* 7723 */ 0x04a8a096 | (19 << 27) /* 0.291168772 */, + /* 7724 */ 0x04a8d54c | (19 << 27) /* 0.291219042 */, + /* 7725 */ 0x04a90a03 | (19 << 27) /* 0.291269314 */, + /* 7726 */ 0x04a93eba | (19 << 27) /* 0.291319588 */, + /* 7727 */ 0x04a97372 | (19 << 27) /* 0.291369865 */, + + /* 7728 */ 0x04a9a82b | (19 << 27) /* 0.291420143 */, + /* 7729 */ 0x04a9dce4 | (19 << 27) /* 0.291470424 */, + /* 7730 */ 0x04aa119d | (19 << 27) /* 0.291520706 */, + /* 7731 */ 0x04aa4658 | (19 << 27) /* 0.291570991 */, + /* 7732 */ 0x04aa7b13 | (19 << 27) /* 0.291621278 */, + /* 7733 */ 0x04aaafce | (19 << 27) /* 0.291671568 */, + /* 7734 */ 0x04aae48a | (19 << 27) /* 0.291721859 */, + /* 7735 */ 0x04ab1947 | (19 << 27) /* 0.291772153 */, + /* 7736 */ 0x04ab4e04 | (19 << 27) /* 0.291822449 */, + /* 7737 */ 0x04ab82c2 | (19 << 27) /* 0.291872747 */, + /* 7738 */ 0x04abb780 | (19 << 27) /* 0.291923047 */, + /* 7739 */ 0x04abec3f | (19 << 27) /* 0.291973349 */, + /* 7740 */ 0x04ac20fe | (19 << 27) /* 0.292023653 */, + /* 7741 */ 0x04ac55be | (19 << 27) /* 0.292073960 */, + /* 7742 */ 0x04ac8a7f | (19 << 27) /* 0.292124269 */, + /* 7743 */ 0x04acbf40 | (19 << 27) /* 0.292174580 */, + + /* 7744 */ 0x04acf402 | (19 << 27) /* 0.292224893 */, + /* 7745 */ 0x04ad28c5 | (19 << 27) /* 0.292275208 */, + /* 7746 */ 0x04ad5d88 | (19 << 27) /* 0.292325526 */, + /* 7747 */ 0x04ad924b | (19 << 27) /* 0.292375845 */, + /* 7748 */ 0x04adc70f | (19 << 27) /* 0.292426167 */, + /* 7749 */ 0x04adfbd4 | (19 << 27) /* 0.292476491 */, + /* 7750 */ 0x04ae3099 | (19 << 27) /* 0.292526817 */, + /* 7751 */ 0x04ae655f | (19 << 27) /* 0.292577145 */, + /* 7752 */ 0x04ae9a26 | (19 << 27) /* 0.292627476 */, + /* 7753 */ 0x04aeceed | (19 << 27) /* 0.292677808 */, + /* 7754 */ 0x04af03b4 | (19 << 27) /* 0.292728143 */, + /* 7755 */ 0x04af387d | (19 << 27) /* 0.292778480 */, + /* 7756 */ 0x04af6d45 | (19 << 27) /* 0.292828819 */, + /* 7757 */ 0x04afa20f | (19 << 27) /* 0.292879160 */, + /* 7758 */ 0x04afd6d9 | (19 << 27) /* 0.292929504 */, + /* 7759 */ 0x04b00ba3 | (19 << 27) /* 0.292979849 */, + + /* 7760 */ 0x04b0406e | (19 << 27) /* 0.293030197 */, + /* 7761 */ 0x04b0753a | (19 << 27) /* 0.293080547 */, + /* 7762 */ 0x04b0aa06 | (19 << 27) /* 0.293130899 */, + /* 7763 */ 0x04b0ded3 | (19 << 27) /* 0.293181253 */, + /* 7764 */ 0x04b113a1 | (19 << 27) /* 0.293231610 */, + /* 7765 */ 0x04b1486f | (19 << 27) /* 0.293281968 */, + /* 7766 */ 0x04b17d3d | (19 << 27) /* 0.293332329 */, + /* 7767 */ 0x04b1b20c | (19 << 27) /* 0.293382692 */, + /* 7768 */ 0x04b1e6dc | (19 << 27) /* 0.293433057 */, + /* 7769 */ 0x04b21bad | (19 << 27) /* 0.293483424 */, + /* 7770 */ 0x04b2507d | (19 << 27) /* 0.293533794 */, + /* 7771 */ 0x04b2854f | (19 << 27) /* 0.293584165 */, + /* 7772 */ 0x04b2ba21 | (19 << 27) /* 0.293634539 */, + /* 7773 */ 0x04b2eef4 | (19 << 27) /* 0.293684915 */, + /* 7774 */ 0x04b323c7 | (19 << 27) /* 0.293735293 */, + /* 7775 */ 0x04b3589b | (19 << 27) /* 0.293785673 */, + + /* 7776 */ 0x04b38d6f | (19 << 27) /* 0.293836055 */, + /* 7777 */ 0x04b3c244 | (19 << 27) /* 0.293886440 */, + /* 7778 */ 0x04b3f71a | (19 << 27) /* 0.293936826 */, + /* 7779 */ 0x04b42bf0 | (19 << 27) /* 0.293987215 */, + /* 7780 */ 0x04b460c7 | (19 << 27) /* 0.294037606 */, + /* 7781 */ 0x04b4959e | (19 << 27) /* 0.294087999 */, + /* 7782 */ 0x04b4ca76 | (19 << 27) /* 0.294138395 */, + /* 7783 */ 0x04b4ff4e | (19 << 27) /* 0.294188792 */, + /* 7784 */ 0x04b53427 | (19 << 27) /* 0.294239192 */, + /* 7785 */ 0x04b56901 | (19 << 27) /* 0.294289593 */, + /* 7786 */ 0x04b59ddb | (19 << 27) /* 0.294339997 */, + /* 7787 */ 0x04b5d2b6 | (19 << 27) /* 0.294390403 */, + /* 7788 */ 0x04b60791 | (19 << 27) /* 0.294440812 */, + /* 7789 */ 0x04b63c6d | (19 << 27) /* 0.294491222 */, + /* 7790 */ 0x04b6714a | (19 << 27) /* 0.294541635 */, + /* 7791 */ 0x04b6a627 | (19 << 27) /* 0.294592049 */, + + /* 7792 */ 0x04b6db05 | (19 << 27) /* 0.294642466 */, + /* 7793 */ 0x04b70fe3 | (19 << 27) /* 0.294692885 */, + /* 7794 */ 0x04b744c2 | (19 << 27) /* 0.294743306 */, + /* 7795 */ 0x04b779a1 | (19 << 27) /* 0.294793730 */, + /* 7796 */ 0x04b7ae81 | (19 << 27) /* 0.294844155 */, + /* 7797 */ 0x04b7e362 | (19 << 27) /* 0.294894583 */, + /* 7798 */ 0x04b81843 | (19 << 27) /* 0.294945013 */, + /* 7799 */ 0x04b84d24 | (19 << 27) /* 0.294995445 */, + /* 7800 */ 0x04b88207 | (19 << 27) /* 0.295045879 */, + /* 7801 */ 0x04b8b6ea | (19 << 27) /* 0.295096315 */, + /* 7802 */ 0x04b8ebcd | (19 << 27) /* 0.295146753 */, + /* 7803 */ 0x04b920b1 | (19 << 27) /* 0.295197194 */, + /* 7804 */ 0x04b95596 | (19 << 27) /* 0.295247637 */, + /* 7805 */ 0x04b98a7b | (19 << 27) /* 0.295298082 */, + /* 7806 */ 0x04b9bf61 | (19 << 27) /* 0.295348529 */, + /* 7807 */ 0x04b9f447 | (19 << 27) /* 0.295398978 */, + + /* 7808 */ 0x04ba292e | (19 << 27) /* 0.295449429 */, + /* 7809 */ 0x04ba5e16 | (19 << 27) /* 0.295499883 */, + /* 7810 */ 0x04ba92fe | (19 << 27) /* 0.295550338 */, + /* 7811 */ 0x04bac7e6 | (19 << 27) /* 0.295600796 */, + /* 7812 */ 0x04bafcd0 | (19 << 27) /* 0.295651256 */, + /* 7813 */ 0x04bb31b9 | (19 << 27) /* 0.295701718 */, + /* 7814 */ 0x04bb66a4 | (19 << 27) /* 0.295752183 */, + /* 7815 */ 0x04bb9b8f | (19 << 27) /* 0.295802649 */, + /* 7816 */ 0x04bbd07a | (19 << 27) /* 0.295853118 */, + /* 7817 */ 0x04bc0566 | (19 << 27) /* 0.295903588 */, + /* 7818 */ 0x04bc3a53 | (19 << 27) /* 0.295954061 */, + /* 7819 */ 0x04bc6f40 | (19 << 27) /* 0.296004536 */, + /* 7820 */ 0x04bca42e | (19 << 27) /* 0.296055013 */, + /* 7821 */ 0x04bcd91d | (19 << 27) /* 0.296105493 */, + /* 7822 */ 0x04bd0e0c | (19 << 27) /* 0.296155974 */, + /* 7823 */ 0x04bd42fb | (19 << 27) /* 0.296206458 */, + + /* 7824 */ 0x04bd77ec | (19 << 27) /* 0.296256944 */, + /* 7825 */ 0x04bdacdc | (19 << 27) /* 0.296307432 */, + /* 7826 */ 0x04bde1ce | (19 << 27) /* 0.296357922 */, + /* 7827 */ 0x04be16c0 | (19 << 27) /* 0.296408414 */, + /* 7828 */ 0x04be4bb2 | (19 << 27) /* 0.296458908 */, + /* 7829 */ 0x04be80a5 | (19 << 27) /* 0.296509405 */, + /* 7830 */ 0x04beb599 | (19 << 27) /* 0.296559904 */, + /* 7831 */ 0x04beea8d | (19 << 27) /* 0.296610404 */, + /* 7832 */ 0x04bf1f82 | (19 << 27) /* 0.296660907 */, + /* 7833 */ 0x04bf5477 | (19 << 27) /* 0.296711413 */, + /* 7834 */ 0x04bf896d | (19 << 27) /* 0.296761920 */, + /* 7835 */ 0x04bfbe64 | (19 << 27) /* 0.296812429 */, + /* 7836 */ 0x04bff35b | (19 << 27) /* 0.296862941 */, + /* 7837 */ 0x04c02852 | (19 << 27) /* 0.296913455 */, + /* 7838 */ 0x04c05d4b | (19 << 27) /* 0.296963971 */, + /* 7839 */ 0x04c09243 | (19 << 27) /* 0.297014489 */, + + /* 7840 */ 0x04c0c73d | (19 << 27) /* 0.297065009 */, + /* 7841 */ 0x04c0fc37 | (19 << 27) /* 0.297115531 */, + /* 7842 */ 0x04c13131 | (19 << 27) /* 0.297166056 */, + /* 7843 */ 0x04c1662d | (19 << 27) /* 0.297216582 */, + /* 7844 */ 0x04c19b28 | (19 << 27) /* 0.297267111 */, + /* 7845 */ 0x04c1d025 | (19 << 27) /* 0.297317642 */, + /* 7846 */ 0x04c20521 | (19 << 27) /* 0.297368175 */, + /* 7847 */ 0x04c23a1f | (19 << 27) /* 0.297418710 */, + /* 7848 */ 0x04c26f1d | (19 << 27) /* 0.297469248 */, + /* 7849 */ 0x04c2a41b | (19 << 27) /* 0.297519787 */, + /* 7850 */ 0x04c2d91b | (19 << 27) /* 0.297570329 */, + /* 7851 */ 0x04c30e1a | (19 << 27) /* 0.297620873 */, + /* 7852 */ 0x04c3431b | (19 << 27) /* 0.297671418 */, + /* 7853 */ 0x04c3781c | (19 << 27) /* 0.297721967 */, + /* 7854 */ 0x04c3ad1d | (19 << 27) /* 0.297772517 */, + /* 7855 */ 0x04c3e21f | (19 << 27) /* 0.297823069 */, + + /* 7856 */ 0x04c41722 | (19 << 27) /* 0.297873624 */, + /* 7857 */ 0x04c44c25 | (19 << 27) /* 0.297924180 */, + /* 7858 */ 0x04c48129 | (19 << 27) /* 0.297974739 */, + /* 7859 */ 0x04c4b62d | (19 << 27) /* 0.298025300 */, + /* 7860 */ 0x04c4eb32 | (19 << 27) /* 0.298075863 */, + /* 7861 */ 0x04c52038 | (19 << 27) /* 0.298126429 */, + /* 7862 */ 0x04c5553e | (19 << 27) /* 0.298176996 */, + /* 7863 */ 0x04c58a44 | (19 << 27) /* 0.298227565 */, + /* 7864 */ 0x04c5bf4c | (19 << 27) /* 0.298278137 */, + /* 7865 */ 0x04c5f453 | (19 << 27) /* 0.298328711 */, + /* 7866 */ 0x04c6295c | (19 << 27) /* 0.298379287 */, + /* 7867 */ 0x04c65e65 | (19 << 27) /* 0.298429865 */, + /* 7868 */ 0x04c6936e | (19 << 27) /* 0.298480445 */, + /* 7869 */ 0x04c6c878 | (19 << 27) /* 0.298531028 */, + /* 7870 */ 0x04c6fd83 | (19 << 27) /* 0.298581612 */, + /* 7871 */ 0x04c7328e | (19 << 27) /* 0.298632199 */, + + /* 7872 */ 0x04c7679a | (19 << 27) /* 0.298682788 */, + /* 7873 */ 0x04c79ca7 | (19 << 27) /* 0.298733379 */, + /* 7874 */ 0x04c7d1b4 | (19 << 27) /* 0.298783972 */, + /* 7875 */ 0x04c806c1 | (19 << 27) /* 0.298834567 */, + /* 7876 */ 0x04c83bcf | (19 << 27) /* 0.298885165 */, + /* 7877 */ 0x04c870de | (19 << 27) /* 0.298935764 */, + /* 7878 */ 0x04c8a5ed | (19 << 27) /* 0.298986366 */, + /* 7879 */ 0x04c8dafd | (19 << 27) /* 0.299036970 */, + /* 7880 */ 0x04c9100d | (19 << 27) /* 0.299087576 */, + /* 7881 */ 0x04c9451e | (19 << 27) /* 0.299138184 */, + /* 7882 */ 0x04c97a30 | (19 << 27) /* 0.299188794 */, + /* 7883 */ 0x04c9af42 | (19 << 27) /* 0.299239406 */, + /* 7884 */ 0x04c9e455 | (19 << 27) /* 0.299290021 */, + /* 7885 */ 0x04ca1968 | (19 << 27) /* 0.299340638 */, + /* 7886 */ 0x04ca4e7c | (19 << 27) /* 0.299391256 */, + /* 7887 */ 0x04ca8391 | (19 << 27) /* 0.299441877 */, + + /* 7888 */ 0x04cab8a6 | (19 << 27) /* 0.299492500 */, + /* 7889 */ 0x04caedbb | (19 << 27) /* 0.299543126 */, + /* 7890 */ 0x04cb22d1 | (19 << 27) /* 0.299593753 */, + /* 7891 */ 0x04cb57e8 | (19 << 27) /* 0.299644382 */, + /* 7892 */ 0x04cb8d00 | (19 << 27) /* 0.299695014 */, + /* 7893 */ 0x04cbc217 | (19 << 27) /* 0.299745648 */, + /* 7894 */ 0x04cbf730 | (19 << 27) /* 0.299796284 */, + /* 7895 */ 0x04cc2c49 | (19 << 27) /* 0.299846922 */, + /* 7896 */ 0x04cc6163 | (19 << 27) /* 0.299897562 */, + /* 7897 */ 0x04cc967d | (19 << 27) /* 0.299948204 */, + /* 7898 */ 0x04cccb98 | (19 << 27) /* 0.299998849 */, + /* 7899 */ 0x04cd00b3 | (19 << 27) /* 0.300049495 */, + /* 7900 */ 0x04cd35cf | (19 << 27) /* 0.300100144 */, + /* 7901 */ 0x04cd6aeb | (19 << 27) /* 0.300150795 */, + /* 7902 */ 0x04cda008 | (19 << 27) /* 0.300201448 */, + /* 7903 */ 0x04cdd526 | (19 << 27) /* 0.300252103 */, + + /* 7904 */ 0x04ce0a44 | (19 << 27) /* 0.300302761 */, + /* 7905 */ 0x04ce3f63 | (19 << 27) /* 0.300353420 */, + /* 7906 */ 0x04ce7482 | (19 << 27) /* 0.300404082 */, + /* 7907 */ 0x04cea9a2 | (19 << 27) /* 0.300454745 */, + /* 7908 */ 0x04cedec3 | (19 << 27) /* 0.300505411 */, + /* 7909 */ 0x04cf13e4 | (19 << 27) /* 0.300556079 */, + /* 7910 */ 0x04cf4906 | (19 << 27) /* 0.300606749 */, + /* 7911 */ 0x04cf7e28 | (19 << 27) /* 0.300657421 */, + /* 7912 */ 0x04cfb34b | (19 << 27) /* 0.300708096 */, + /* 7913 */ 0x04cfe86e | (19 << 27) /* 0.300758772 */, + /* 7914 */ 0x04d01d92 | (19 << 27) /* 0.300809451 */, + /* 7915 */ 0x04d052b6 | (19 << 27) /* 0.300860132 */, + /* 7916 */ 0x04d087db | (19 << 27) /* 0.300910815 */, + /* 7917 */ 0x04d0bd01 | (19 << 27) /* 0.300961500 */, + /* 7918 */ 0x04d0f227 | (19 << 27) /* 0.301012187 */, + /* 7919 */ 0x04d1274e | (19 << 27) /* 0.301062876 */, + + /* 7920 */ 0x04d15c76 | (19 << 27) /* 0.301113568 */, + /* 7921 */ 0x04d1919e | (19 << 27) /* 0.301164261 */, + /* 7922 */ 0x04d1c6c6 | (19 << 27) /* 0.301214957 */, + /* 7923 */ 0x04d1fbef | (19 << 27) /* 0.301265655 */, + /* 7924 */ 0x04d23119 | (19 << 27) /* 0.301316355 */, + /* 7925 */ 0x04d26643 | (19 << 27) /* 0.301367057 */, + /* 7926 */ 0x04d29b6e | (19 << 27) /* 0.301417761 */, + /* 7927 */ 0x04d2d099 | (19 << 27) /* 0.301468468 */, + /* 7928 */ 0x04d305c5 | (19 << 27) /* 0.301519176 */, + /* 7929 */ 0x04d33af2 | (19 << 27) /* 0.301569887 */, + /* 7930 */ 0x04d3701f | (19 << 27) /* 0.301620599 */, + /* 7931 */ 0x04d3a54d | (19 << 27) /* 0.301671314 */, + /* 7932 */ 0x04d3da7b | (19 << 27) /* 0.301722031 */, + /* 7933 */ 0x04d40faa | (19 << 27) /* 0.301772751 */, + /* 7934 */ 0x04d444d9 | (19 << 27) /* 0.301823472 */, + /* 7935 */ 0x04d47a09 | (19 << 27) /* 0.301874195 */, + + /* 7936 */ 0x04d4af3a | (19 << 27) /* 0.301924921 */, + /* 7937 */ 0x04d4e46b | (19 << 27) /* 0.301975649 */, + /* 7938 */ 0x04d5199c | (19 << 27) /* 0.302026378 */, + /* 7939 */ 0x04d54ecf | (19 << 27) /* 0.302077110 */, + /* 7940 */ 0x04d58401 | (19 << 27) /* 0.302127845 */, + /* 7941 */ 0x04d5b935 | (19 << 27) /* 0.302178581 */, + /* 7942 */ 0x04d5ee69 | (19 << 27) /* 0.302229319 */, + /* 7943 */ 0x04d6239d | (19 << 27) /* 0.302280060 */, + /* 7944 */ 0x04d658d2 | (19 << 27) /* 0.302330802 */, + /* 7945 */ 0x04d68e08 | (19 << 27) /* 0.302381547 */, + /* 7946 */ 0x04d6c33e | (19 << 27) /* 0.302432294 */, + /* 7947 */ 0x04d6f875 | (19 << 27) /* 0.302483043 */, + /* 7948 */ 0x04d72dad | (19 << 27) /* 0.302533794 */, + /* 7949 */ 0x04d762e5 | (19 << 27) /* 0.302584547 */, + /* 7950 */ 0x04d7981d | (19 << 27) /* 0.302635303 */, + /* 7951 */ 0x04d7cd56 | (19 << 27) /* 0.302686060 */, + + /* 7952 */ 0x04d80290 | (19 << 27) /* 0.302736820 */, + /* 7953 */ 0x04d837ca | (19 << 27) /* 0.302787581 */, + /* 7954 */ 0x04d86d05 | (19 << 27) /* 0.302838345 */, + /* 7955 */ 0x04d8a240 | (19 << 27) /* 0.302889111 */, + /* 7956 */ 0x04d8d77c | (19 << 27) /* 0.302939879 */, + /* 7957 */ 0x04d90cb9 | (19 << 27) /* 0.302990650 */, + /* 7958 */ 0x04d941f6 | (19 << 27) /* 0.303041422 */, + /* 7959 */ 0x04d97734 | (19 << 27) /* 0.303092197 */, + /* 7960 */ 0x04d9ac72 | (19 << 27) /* 0.303142973 */, + /* 7961 */ 0x04d9e1b1 | (19 << 27) /* 0.303193752 */, + /* 7962 */ 0x04da16f0 | (19 << 27) /* 0.303244533 */, + /* 7963 */ 0x04da4c30 | (19 << 27) /* 0.303295316 */, + /* 7964 */ 0x04da8171 | (19 << 27) /* 0.303346101 */, + /* 7965 */ 0x04dab6b2 | (19 << 27) /* 0.303396889 */, + /* 7966 */ 0x04daebf4 | (19 << 27) /* 0.303447678 */, + /* 7967 */ 0x04db2136 | (19 << 27) /* 0.303498469 */, + + /* 7968 */ 0x04db5679 | (19 << 27) /* 0.303549263 */, + /* 7969 */ 0x04db8bbc | (19 << 27) /* 0.303600059 */, + /* 7970 */ 0x04dbc100 | (19 << 27) /* 0.303650857 */, + /* 7971 */ 0x04dbf644 | (19 << 27) /* 0.303701657 */, + /* 7972 */ 0x04dc2b8a | (19 << 27) /* 0.303752459 */, + /* 7973 */ 0x04dc60cf | (19 << 27) /* 0.303803263 */, + /* 7974 */ 0x04dc9616 | (19 << 27) /* 0.303854070 */, + /* 7975 */ 0x04dccb5c | (19 << 27) /* 0.303904878 */, + /* 7976 */ 0x04dd00a4 | (19 << 27) /* 0.303955689 */, + /* 7977 */ 0x04dd35ec | (19 << 27) /* 0.304006502 */, + /* 7978 */ 0x04dd6b34 | (19 << 27) /* 0.304057317 */, + /* 7979 */ 0x04dda07d | (19 << 27) /* 0.304108134 */, + /* 7980 */ 0x04ddd5c7 | (19 << 27) /* 0.304158953 */, + /* 7981 */ 0x04de0b11 | (19 << 27) /* 0.304209774 */, + /* 7982 */ 0x04de405c | (19 << 27) /* 0.304260597 */, + /* 7983 */ 0x04de75a7 | (19 << 27) /* 0.304311423 */, + + /* 7984 */ 0x04deaaf3 | (19 << 27) /* 0.304362251 */, + /* 7985 */ 0x04dee040 | (19 << 27) /* 0.304413080 */, + /* 7986 */ 0x04df158d | (19 << 27) /* 0.304463912 */, + /* 7987 */ 0x04df4adb | (19 << 27) /* 0.304514746 */, + /* 7988 */ 0x04df8029 | (19 << 27) /* 0.304565582 */, + /* 7989 */ 0x04dfb578 | (19 << 27) /* 0.304616421 */, + /* 7990 */ 0x04dfeac7 | (19 << 27) /* 0.304667261 */, + /* 7991 */ 0x04e02017 | (19 << 27) /* 0.304718103 */, + /* 7992 */ 0x04e05567 | (19 << 27) /* 0.304768948 */, + /* 7993 */ 0x04e08ab8 | (19 << 27) /* 0.304819795 */, + /* 7994 */ 0x04e0c00a | (19 << 27) /* 0.304870644 */, + /* 7995 */ 0x04e0f55c | (19 << 27) /* 0.304921495 */, + /* 7996 */ 0x04e12aaf | (19 << 27) /* 0.304972348 */, + /* 7997 */ 0x04e16002 | (19 << 27) /* 0.305023203 */, + /* 7998 */ 0x04e19556 | (19 << 27) /* 0.305074060 */, + /* 7999 */ 0x04e1caab | (19 << 27) /* 0.305124920 */, + + /* 8000 */ 0x04e20000 | (19 << 27) /* 0.305175781 */, + /* 8001 */ 0x04e23555 | (19 << 27) /* 0.305226645 */, + /* 8002 */ 0x04e26aac | (19 << 27) /* 0.305277511 */, + /* 8003 */ 0x04e2a002 | (19 << 27) /* 0.305328379 */, + /* 8004 */ 0x04e2d55a | (19 << 27) /* 0.305379249 */, + /* 8005 */ 0x04e30ab2 | (19 << 27) /* 0.305430121 */, + /* 8006 */ 0x04e3400a | (19 << 27) /* 0.305480995 */, + /* 8007 */ 0x04e37563 | (19 << 27) /* 0.305531872 */, + /* 8008 */ 0x04e3aabd | (19 << 27) /* 0.305582750 */, + /* 8009 */ 0x04e3e017 | (19 << 27) /* 0.305633631 */, + /* 8010 */ 0x04e41572 | (19 << 27) /* 0.305684513 */, + /* 8011 */ 0x04e44acd | (19 << 27) /* 0.305735398 */, + /* 8012 */ 0x04e48029 | (19 << 27) /* 0.305786285 */, + /* 8013 */ 0x04e4b585 | (19 << 27) /* 0.305837174 */, + /* 8014 */ 0x04e4eae2 | (19 << 27) /* 0.305888066 */, + /* 8015 */ 0x04e52040 | (19 << 27) /* 0.305938959 */, + + /* 8016 */ 0x04e5559e | (19 << 27) /* 0.305989854 */, + /* 8017 */ 0x04e58afd | (19 << 27) /* 0.306040752 */, + /* 8018 */ 0x04e5c05c | (19 << 27) /* 0.306091652 */, + /* 8019 */ 0x04e5f5bc | (19 << 27) /* 0.306142554 */, + /* 8020 */ 0x04e62b1c | (19 << 27) /* 0.306193457 */, + /* 8021 */ 0x04e6607d | (19 << 27) /* 0.306244364 */, + /* 8022 */ 0x04e695df | (19 << 27) /* 0.306295272 */, + /* 8023 */ 0x04e6cb41 | (19 << 27) /* 0.306346182 */, + /* 8024 */ 0x04e700a3 | (19 << 27) /* 0.306397094 */, + /* 8025 */ 0x04e73607 | (19 << 27) /* 0.306448009 */, + /* 8026 */ 0x04e76b6b | (19 << 27) /* 0.306498925 */, + /* 8027 */ 0x04e7a0cf | (19 << 27) /* 0.306549844 */, + /* 8028 */ 0x04e7d634 | (19 << 27) /* 0.306600765 */, + /* 8029 */ 0x04e80b99 | (19 << 27) /* 0.306651688 */, + /* 8030 */ 0x04e84100 | (19 << 27) /* 0.306702613 */, + /* 8031 */ 0x04e87666 | (19 << 27) /* 0.306753540 */, + + /* 8032 */ 0x04e8abcd | (19 << 27) /* 0.306804470 */, + /* 8033 */ 0x04e8e135 | (19 << 27) /* 0.306855401 */, + /* 8034 */ 0x04e9169e | (19 << 27) /* 0.306906334 */, + /* 8035 */ 0x04e94c07 | (19 << 27) /* 0.306957270 */, + /* 8036 */ 0x04e98170 | (19 << 27) /* 0.307008208 */, + /* 8037 */ 0x04e9b6da | (19 << 27) /* 0.307059148 */, + /* 8038 */ 0x04e9ec45 | (19 << 27) /* 0.307110090 */, + /* 8039 */ 0x04ea21b0 | (19 << 27) /* 0.307161034 */, + /* 8040 */ 0x04ea571c | (19 << 27) /* 0.307211980 */, + /* 8041 */ 0x04ea8c88 | (19 << 27) /* 0.307262928 */, + /* 8042 */ 0x04eac1f5 | (19 << 27) /* 0.307313879 */, + /* 8043 */ 0x04eaf762 | (19 << 27) /* 0.307364831 */, + /* 8044 */ 0x04eb2cd0 | (19 << 27) /* 0.307415786 */, + /* 8045 */ 0x04eb623f | (19 << 27) /* 0.307466743 */, + /* 8046 */ 0x04eb97ae | (19 << 27) /* 0.307517702 */, + /* 8047 */ 0x04ebcd1e | (19 << 27) /* 0.307568663 */, + + /* 8048 */ 0x04ec028e | (19 << 27) /* 0.307619626 */, + /* 8049 */ 0x04ec37ff | (19 << 27) /* 0.307670591 */, + /* 8050 */ 0x04ec6d71 | (19 << 27) /* 0.307721558 */, + /* 8051 */ 0x04eca2e3 | (19 << 27) /* 0.307772528 */, + /* 8052 */ 0x04ecd855 | (19 << 27) /* 0.307823499 */, + /* 8053 */ 0x04ed0dc8 | (19 << 27) /* 0.307874473 */, + /* 8054 */ 0x04ed433c | (19 << 27) /* 0.307925449 */, + /* 8055 */ 0x04ed78b0 | (19 << 27) /* 0.307976426 */, + /* 8056 */ 0x04edae25 | (19 << 27) /* 0.308027406 */, + /* 8057 */ 0x04ede39a | (19 << 27) /* 0.308078389 */, + /* 8058 */ 0x04ee1910 | (19 << 27) /* 0.308129373 */, + /* 8059 */ 0x04ee4e87 | (19 << 27) /* 0.308180359 */, + /* 8060 */ 0x04ee83fe | (19 << 27) /* 0.308231347 */, + /* 8061 */ 0x04eeb976 | (19 << 27) /* 0.308282338 */, + /* 8062 */ 0x04eeeeee | (19 << 27) /* 0.308333331 */, + /* 8063 */ 0x04ef2467 | (19 << 27) /* 0.308384325 */, + + /* 8064 */ 0x04ef59e0 | (19 << 27) /* 0.308435322 */, + /* 8065 */ 0x04ef8f5a | (19 << 27) /* 0.308486321 */, + /* 8066 */ 0x04efc4d5 | (19 << 27) /* 0.308537322 */, + /* 8067 */ 0x04effa50 | (19 << 27) /* 0.308588325 */, + /* 8068 */ 0x04f02fcb | (19 << 27) /* 0.308639331 */, + /* 8069 */ 0x04f06547 | (19 << 27) /* 0.308690338 */, + /* 8070 */ 0x04f09ac4 | (19 << 27) /* 0.308741348 */, + /* 8071 */ 0x04f0d041 | (19 << 27) /* 0.308792359 */, + /* 8072 */ 0x04f105bf | (19 << 27) /* 0.308843373 */, + /* 8073 */ 0x04f13b3e | (19 << 27) /* 0.308894389 */, + /* 8074 */ 0x04f170bd | (19 << 27) /* 0.308945407 */, + /* 8075 */ 0x04f1a63c | (19 << 27) /* 0.308996427 */, + /* 8076 */ 0x04f1dbbd | (19 << 27) /* 0.309047449 */, + /* 8077 */ 0x04f2113d | (19 << 27) /* 0.309098473 */, + /* 8078 */ 0x04f246bf | (19 << 27) /* 0.309149499 */, + /* 8079 */ 0x04f27c40 | (19 << 27) /* 0.309200528 */, + + /* 8080 */ 0x04f2b1c3 | (19 << 27) /* 0.309251558 */, + /* 8081 */ 0x04f2e746 | (19 << 27) /* 0.309302591 */, + /* 8082 */ 0x04f31cc9 | (19 << 27) /* 0.309353626 */, + /* 8083 */ 0x04f3524d | (19 << 27) /* 0.309404663 */, + /* 8084 */ 0x04f387d2 | (19 << 27) /* 0.309455702 */, + /* 8085 */ 0x04f3bd57 | (19 << 27) /* 0.309506743 */, + /* 8086 */ 0x04f3f2dd | (19 << 27) /* 0.309557786 */, + /* 8087 */ 0x04f42864 | (19 << 27) /* 0.309608831 */, + /* 8088 */ 0x04f45dea | (19 << 27) /* 0.309659879 */, + /* 8089 */ 0x04f49372 | (19 << 27) /* 0.309710928 */, + /* 8090 */ 0x04f4c8fa | (19 << 27) /* 0.309761980 */, + /* 8091 */ 0x04f4fe83 | (19 << 27) /* 0.309813033 */, + /* 8092 */ 0x04f5340c | (19 << 27) /* 0.309864089 */, + /* 8093 */ 0x04f56996 | (19 << 27) /* 0.309915147 */, + /* 8094 */ 0x04f59f20 | (19 << 27) /* 0.309966207 */, + /* 8095 */ 0x04f5d4ab | (19 << 27) /* 0.310017269 */, + + /* 8096 */ 0x04f60a36 | (19 << 27) /* 0.310068333 */, + /* 8097 */ 0x04f63fc2 | (19 << 27) /* 0.310119400 */, + /* 8098 */ 0x04f6754f | (19 << 27) /* 0.310170468 */, + /* 8099 */ 0x04f6aadc | (19 << 27) /* 0.310221539 */, + /* 8100 */ 0x04f6e06a | (19 << 27) /* 0.310272611 */, + /* 8101 */ 0x04f715f8 | (19 << 27) /* 0.310323686 */, + /* 8102 */ 0x04f74b87 | (19 << 27) /* 0.310374763 */, + /* 8103 */ 0x04f78116 | (19 << 27) /* 0.310425842 */, + /* 8104 */ 0x04f7b6a6 | (19 << 27) /* 0.310476923 */, + /* 8105 */ 0x04f7ec37 | (19 << 27) /* 0.310528006 */, + /* 8106 */ 0x04f821c8 | (19 << 27) /* 0.310579091 */, + /* 8107 */ 0x04f85759 | (19 << 27) /* 0.310630179 */, + /* 8108 */ 0x04f88cec | (19 << 27) /* 0.310681268 */, + /* 8109 */ 0x04f8c27e | (19 << 27) /* 0.310732360 */, + /* 8110 */ 0x04f8f812 | (19 << 27) /* 0.310783453 */, + /* 8111 */ 0x04f92da6 | (19 << 27) /* 0.310834549 */, + + /* 8112 */ 0x04f9633a | (19 << 27) /* 0.310885647 */, + /* 8113 */ 0x04f998cf | (19 << 27) /* 0.310936747 */, + /* 8114 */ 0x04f9ce65 | (19 << 27) /* 0.310987849 */, + /* 8115 */ 0x04fa03fb | (19 << 27) /* 0.311038953 */, + /* 8116 */ 0x04fa3992 | (19 << 27) /* 0.311090059 */, + /* 8117 */ 0x04fa6f29 | (19 << 27) /* 0.311141168 */, + /* 8118 */ 0x04faa4c1 | (19 << 27) /* 0.311192278 */, + /* 8119 */ 0x04fada59 | (19 << 27) /* 0.311243390 */, + /* 8120 */ 0x04fb0ff2 | (19 << 27) /* 0.311294505 */, + /* 8121 */ 0x04fb458c | (19 << 27) /* 0.311345622 */, + /* 8122 */ 0x04fb7b26 | (19 << 27) /* 0.311396741 */, + /* 8123 */ 0x04fbb0c1 | (19 << 27) /* 0.311447862 */, + /* 8124 */ 0x04fbe65c | (19 << 27) /* 0.311498985 */, + /* 8125 */ 0x04fc1bf8 | (19 << 27) /* 0.311550110 */, + /* 8126 */ 0x04fc5194 | (19 << 27) /* 0.311601237 */, + /* 8127 */ 0x04fc8731 | (19 << 27) /* 0.311652366 */, + + /* 8128 */ 0x04fcbcce | (19 << 27) /* 0.311703498 */, + /* 8129 */ 0x04fcf26c | (19 << 27) /* 0.311754631 */, + /* 8130 */ 0x04fd280b | (19 << 27) /* 0.311805767 */, + /* 8131 */ 0x04fd5daa | (19 << 27) /* 0.311856905 */, + /* 8132 */ 0x04fd934a | (19 << 27) /* 0.311908044 */, + /* 8133 */ 0x04fdc8ea | (19 << 27) /* 0.311959186 */, + /* 8134 */ 0x04fdfe8b | (19 << 27) /* 0.312010330 */, + /* 8135 */ 0x04fe342c | (19 << 27) /* 0.312061476 */, + /* 8136 */ 0x04fe69ce | (19 << 27) /* 0.312112625 */, + /* 8137 */ 0x04fe9f71 | (19 << 27) /* 0.312163775 */, + /* 8138 */ 0x04fed514 | (19 << 27) /* 0.312214927 */, + /* 8139 */ 0x04ff0ab8 | (19 << 27) /* 0.312266082 */, + /* 8140 */ 0x04ff405c | (19 << 27) /* 0.312317238 */, + /* 8141 */ 0x04ff7601 | (19 << 27) /* 0.312368397 */, + /* 8142 */ 0x04ffaba6 | (19 << 27) /* 0.312419558 */, + /* 8143 */ 0x04ffe14c | (19 << 27) /* 0.312470720 */, + + /* 8144 */ 0x050016f3 | (19 << 27) /* 0.312521885 */, + /* 8145 */ 0x05004c9a | (19 << 27) /* 0.312573052 */, + /* 8146 */ 0x05008241 | (19 << 27) /* 0.312624222 */, + /* 8147 */ 0x0500b7e9 | (19 << 27) /* 0.312675393 */, + /* 8148 */ 0x0500ed92 | (19 << 27) /* 0.312726566 */, + /* 8149 */ 0x0501233b | (19 << 27) /* 0.312777742 */, + /* 8150 */ 0x050158e5 | (19 << 27) /* 0.312828919 */, + /* 8151 */ 0x05018e90 | (19 << 27) /* 0.312880099 */, + /* 8152 */ 0x0501c43b | (19 << 27) /* 0.312931280 */, + /* 8153 */ 0x0501f9e6 | (19 << 27) /* 0.312982464 */, + /* 8154 */ 0x05022f92 | (19 << 27) /* 0.313033650 */, + /* 8155 */ 0x0502653f | (19 << 27) /* 0.313084838 */, + /* 8156 */ 0x05029aec | (19 << 27) /* 0.313136028 */, + /* 8157 */ 0x0502d09a | (19 << 27) /* 0.313187220 */, + /* 8158 */ 0x05030648 | (19 << 27) /* 0.313238414 */, + /* 8159 */ 0x05033bf7 | (19 << 27) /* 0.313289611 */, + + /* 8160 */ 0x050371a7 | (19 << 27) /* 0.313340809 */, + /* 8161 */ 0x0503a757 | (19 << 27) /* 0.313392010 */, + /* 8162 */ 0x0503dd07 | (19 << 27) /* 0.313443212 */, + /* 8163 */ 0x050412b9 | (19 << 27) /* 0.313494417 */, + /* 8164 */ 0x0504486a | (19 << 27) /* 0.313545624 */, + /* 8165 */ 0x05047e1d | (19 << 27) /* 0.313596833 */, + /* 8166 */ 0x0504b3cf | (19 << 27) /* 0.313648044 */, + /* 8167 */ 0x0504e983 | (19 << 27) /* 0.313699257 */, + /* 8168 */ 0x05051f37 | (19 << 27) /* 0.313750472 */, + /* 8169 */ 0x050554eb | (19 << 27) /* 0.313801689 */, + /* 8170 */ 0x05058aa0 | (19 << 27) /* 0.313852909 */, + /* 8171 */ 0x0505c056 | (19 << 27) /* 0.313904130 */, + /* 8172 */ 0x0505f60c | (19 << 27) /* 0.313955354 */, + /* 8173 */ 0x05062bc3 | (19 << 27) /* 0.314006579 */, + /* 8174 */ 0x0506617a | (19 << 27) /* 0.314057807 */, + /* 8175 */ 0x05069732 | (19 << 27) /* 0.314109037 */, + + /* 8176 */ 0x0506cceb | (19 << 27) /* 0.314160269 */, + /* 8177 */ 0x050702a4 | (19 << 27) /* 0.314211502 */, + /* 8178 */ 0x0507385d | (19 << 27) /* 0.314262739 */, + /* 8179 */ 0x05076e17 | (19 << 27) /* 0.314313977 */, + /* 8180 */ 0x0507a3d2 | (19 << 27) /* 0.314365217 */, + /* 8181 */ 0x0507d98d | (19 << 27) /* 0.314416459 */, + /* 8182 */ 0x05080f49 | (19 << 27) /* 0.314467704 */, + /* 8183 */ 0x05084506 | (19 << 27) /* 0.314518950 */, + /* 8184 */ 0x05087ac2 | (19 << 27) /* 0.314570199 */, + /* 8185 */ 0x0508b080 | (19 << 27) /* 0.314621449 */, + /* 8186 */ 0x0508e63e | (19 << 27) /* 0.314672702 */, + /* 8187 */ 0x05091bfd | (19 << 27) /* 0.314723957 */, + /* 8188 */ 0x050951bc | (19 << 27) /* 0.314775214 */, + /* 8189 */ 0x0509877c | (19 << 27) /* 0.314826473 */, + /* 8190 */ 0x0509bd3c | (19 << 27) /* 0.314877734 */, + /* 8191 */ 0x0509f2fd | (19 << 27) /* 0.314928997 */, + + /* 8192 */ 0x050a28be | (19 << 27) /* 0.314980262 */, + /* 8193 */ 0x050a5e80 | (19 << 27) /* 0.315031530 */, + /* 8194 */ 0x050a9443 | (19 << 27) /* 0.315082799 */, + /* 8195 */ 0x050aca06 | (19 << 27) /* 0.315134071 */, + /* 8196 */ 0x050affc9 | (19 << 27) /* 0.315185344 */, + /* 8197 */ 0x050b358e | (19 << 27) /* 0.315236620 */, + /* 8198 */ 0x050b6b52 | (19 << 27) /* 0.315287898 */, + /* 8199 */ 0x050ba118 | (19 << 27) /* 0.315339178 */, + /* 8200 */ 0x050bd6de | (19 << 27) /* 0.315390460 */, + /* 8201 */ 0x050c0ca4 | (19 << 27) /* 0.315441744 */, + /* 8202 */ 0x050c426b | (19 << 27) /* 0.315493030 */, + /* 8203 */ 0x050c7833 | (19 << 27) /* 0.315544318 */, + /* 8204 */ 0x050cadfb | (19 << 27) /* 0.315595608 */, + /* 8205 */ 0x050ce3c4 | (19 << 27) /* 0.315646901 */, + /* 8206 */ 0x050d198d | (19 << 27) /* 0.315698195 */, diff --git a/lib/rbcodec/codecs/libmad/sf_table.dat b/lib/rbcodec/codecs/libmad/sf_table.dat new file mode 100644 index 0000000000..de084d97da --- /dev/null +++ b/lib/rbcodec/codecs/libmad/sf_table.dat @@ -0,0 +1,106 @@ +/* + * libmad - MPEG audio decoder library + * Copyright (C) 2000-2004 Underbit Technologies, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * $Id$ + */ + +/* + * These are the scalefactor values for Layer I and Layer II. + * The values are from Table B.1 of ISO/IEC 11172-3. + * + * There is some error introduced by the 32-bit fixed-point representation; + * the amount of error is shown. For 16-bit PCM output, this shouldn't be + * too much of a problem. + * + * Strictly speaking, Table B.1 has only 63 entries (0-62), thus a strict + * interpretation of ISO/IEC 11172-3 would suggest that a scalefactor index of + * 63 is invalid. However, for better compatibility with current practices, we + * add a 64th entry. + */ + + MAD_F(0x20000000), /* 2.000000000000 => 2.000000000000, e 0.000000000000 */ + MAD_F(0x1965fea5), /* 1.587401051968 => 1.587401051074, e 0.000000000894 */ + MAD_F(0x1428a2fa), /* 1.259921049895 => 1.259921051562, e -0.000000001667 */ + MAD_F(0x10000000), /* 1.000000000000 => 1.000000000000, e 0.000000000000 */ + MAD_F(0x0cb2ff53), /* 0.793700525984 => 0.793700527400, e -0.000000001416 */ + MAD_F(0x0a14517d), /* 0.629960524947 => 0.629960525781, e -0.000000000833 */ + MAD_F(0x08000000), /* 0.500000000000 => 0.500000000000, e 0.000000000000 */ + MAD_F(0x06597fa9), /* 0.396850262992 => 0.396850261837, e 0.000000001155 */ + + MAD_F(0x050a28be), /* 0.314980262474 => 0.314980261028, e 0.000000001446 */ + MAD_F(0x04000000), /* 0.250000000000 => 0.250000000000, e 0.000000000000 */ + MAD_F(0x032cbfd5), /* 0.198425131496 => 0.198425132781, e -0.000000001285 */ + MAD_F(0x0285145f), /* 0.157490131237 => 0.157490130514, e 0.000000000723 */ + MAD_F(0x02000000), /* 0.125000000000 => 0.125000000000, e 0.000000000000 */ + MAD_F(0x01965fea), /* 0.099212565748 => 0.099212564528, e 0.000000001220 */ + MAD_F(0x01428a30), /* 0.078745065618 => 0.078745067120, e -0.000000001501 */ + MAD_F(0x01000000), /* 0.062500000000 => 0.062500000000, e 0.000000000000 */ + + MAD_F(0x00cb2ff5), /* 0.049606282874 => 0.049606282264, e 0.000000000610 */ + MAD_F(0x00a14518), /* 0.039372532809 => 0.039372533560, e -0.000000000751 */ + MAD_F(0x00800000), /* 0.031250000000 => 0.031250000000, e 0.000000000000 */ + MAD_F(0x006597fb), /* 0.024803141437 => 0.024803142995, e -0.000000001558 */ + MAD_F(0x0050a28c), /* 0.019686266405 => 0.019686266780, e -0.000000000375 */ + MAD_F(0x00400000), /* 0.015625000000 => 0.015625000000, e 0.000000000000 */ + MAD_F(0x0032cbfd), /* 0.012401570719 => 0.012401569635, e 0.000000001084 */ + MAD_F(0x00285146), /* 0.009843133202 => 0.009843133390, e -0.000000000188 */ + + MAD_F(0x00200000), /* 0.007812500000 => 0.007812500000, e 0.000000000000 */ + MAD_F(0x001965ff), /* 0.006200785359 => 0.006200786680, e -0.000000001321 */ + MAD_F(0x001428a3), /* 0.004921566601 => 0.004921566695, e -0.000000000094 */ + MAD_F(0x00100000), /* 0.003906250000 => 0.003906250000, e 0.000000000000 */ + MAD_F(0x000cb2ff), /* 0.003100392680 => 0.003100391477, e 0.000000001202 */ + MAD_F(0x000a1451), /* 0.002460783301 => 0.002460781485, e 0.000000001816 */ + MAD_F(0x00080000), /* 0.001953125000 => 0.001953125000, e 0.000000000000 */ + MAD_F(0x00065980), /* 0.001550196340 => 0.001550197601, e -0.000000001262 */ + + MAD_F(0x00050a29), /* 0.001230391650 => 0.001230392605, e -0.000000000955 */ + MAD_F(0x00040000), /* 0.000976562500 => 0.000976562500, e 0.000000000000 */ + MAD_F(0x00032cc0), /* 0.000775098170 => 0.000775098801, e -0.000000000631 */ + MAD_F(0x00028514), /* 0.000615195825 => 0.000615194440, e 0.000000001385 */ + MAD_F(0x00020000), /* 0.000488281250 => 0.000488281250, e 0.000000000000 */ + MAD_F(0x00019660), /* 0.000387549085 => 0.000387549400, e -0.000000000315 */ + MAD_F(0x0001428a), /* 0.000307597913 => 0.000307597220, e 0.000000000693 */ + MAD_F(0x00010000), /* 0.000244140625 => 0.000244140625, e 0.000000000000 */ + + MAD_F(0x0000cb30), /* 0.000193774542 => 0.000193774700, e -0.000000000158 */ + MAD_F(0x0000a145), /* 0.000153798956 => 0.000153798610, e 0.000000000346 */ + MAD_F(0x00008000), /* 0.000122070313 => 0.000122070313, e 0.000000000000 */ + MAD_F(0x00006598), /* 0.000096887271 => 0.000096887350, e -0.000000000079 */ + MAD_F(0x000050a3), /* 0.000076899478 => 0.000076901168, e -0.000000001689 */ + MAD_F(0x00004000), /* 0.000061035156 => 0.000061035156, e 0.000000000000 */ + MAD_F(0x000032cc), /* 0.000048443636 => 0.000048443675, e -0.000000000039 */ + MAD_F(0x00002851), /* 0.000038449739 => 0.000038448721, e 0.000000001018 */ + + MAD_F(0x00002000), /* 0.000030517578 => 0.000030517578, e 0.000000000000 */ + MAD_F(0x00001966), /* 0.000024221818 => 0.000024221838, e -0.000000000020 */ + MAD_F(0x00001429), /* 0.000019224870 => 0.000019226223, e -0.000000001354 */ + MAD_F(0x00001000), /* 0.000015258789 => 0.000015258789, e -0.000000000000 */ + MAD_F(0x00000cb3), /* 0.000012110909 => 0.000012110919, e -0.000000000010 */ + MAD_F(0x00000a14), /* 0.000009612435 => 0.000009611249, e 0.000000001186 */ + MAD_F(0x00000800), /* 0.000007629395 => 0.000007629395, e -0.000000000000 */ + MAD_F(0x00000659), /* 0.000006055454 => 0.000006053597, e 0.000000001858 */ + + MAD_F(0x0000050a), /* 0.000004806217 => 0.000004805624, e 0.000000000593 */ + MAD_F(0x00000400), /* 0.000003814697 => 0.000003814697, e 0.000000000000 */ + MAD_F(0x0000032d), /* 0.000003027727 => 0.000003028661, e -0.000000000934 */ + MAD_F(0x00000285), /* 0.000002403109 => 0.000002402812, e 0.000000000296 */ + MAD_F(0x00000200), /* 0.000001907349 => 0.000001907349, e -0.000000000000 */ + MAD_F(0x00000196), /* 0.000001513864 => 0.000001512468, e 0.000000001396 */ + MAD_F(0x00000143), /* 0.000001201554 => 0.000001203269, e -0.000000001714 */ + MAD_F(0x00000000) /* this compatibility entry is not part of Table B.1 */ diff --git a/lib/rbcodec/codecs/libmad/stream.c b/lib/rbcodec/codecs/libmad/stream.c new file mode 100644 index 0000000000..6c8bbcf850 --- /dev/null +++ b/lib/rbcodec/codecs/libmad/stream.c @@ -0,0 +1,165 @@ +/* + * libmad - MPEG audio decoder library + * Copyright (C) 2000-2004 Underbit Technologies, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * $Id$ + */ + +# ifdef HAVE_CONFIG_H +# include "config.h" +# endif + +# include "global.h" + +# include "bit.h" +# include "stream.h" + +/* + * NAME: stream->init() + * DESCRIPTION: initialize stream struct + */ +void mad_stream_init(struct mad_stream *stream) +{ + stream->buffer = 0; + stream->bufend = 0; + /* rockbox: not used + stream->skiplen = 0; */ + + stream->sync = 0; + stream->freerate = 0; + + stream->this_frame = 0; + stream->next_frame = 0; + mad_bit_init(&stream->ptr, 0); + + mad_bit_init(&stream->anc_ptr, 0); + stream->anc_bitlen = 0; + +/* rockbox: comment this to avoid allocation in following code. main_data is + * linked to an array in ../mpa.c before calling this. + stream->main_data = 0; +*/ + stream->md_len = 0; + + stream->options = 0; + stream->error = MAD_ERROR_NONE; +} + +/* + * NAME: stream->finish() + * DESCRIPTION: deallocate any dynamic memory associated with stream + */ +/* rockbox: not used +void mad_stream_finish(struct mad_stream *stream) +{ + if (stream->main_data) { + free(stream->main_data); + stream->main_data = 0; + } + + mad_bit_finish(&stream->anc_ptr); + mad_bit_finish(&stream->ptr); +} */ + +/* + * NAME: stream->buffer() + * DESCRIPTION: set stream buffer pointers + */ +void mad_stream_buffer(struct mad_stream *stream, + unsigned char const *buffer, unsigned long length) +{ + stream->buffer = buffer; + stream->bufend = buffer + length; + + stream->this_frame = buffer; + stream->next_frame = buffer; + + stream->sync = 1; + + mad_bit_init(&stream->ptr, buffer); +} + +/* + * NAME: stream->skip() + * DESCRIPTION: arrange to skip bytes before the next frame + */ +/* rockbox: not used +void mad_stream_skip(struct mad_stream *stream, unsigned long length) +{ + stream->skiplen += length; +} */ + +/* + * NAME: stream->sync() + * DESCRIPTION: locate the next stream sync word + */ +int mad_stream_sync(struct mad_stream *stream) +{ + register unsigned char const *ptr, *end; + + ptr = mad_bit_nextbyte(&stream->ptr); + end = stream->bufend; + + while (ptr < end - 1 && + !(ptr[0] == 0xff && (ptr[1] & 0xe0) == 0xe0)) + ++ptr; + + if (end - ptr < MAD_BUFFER_GUARD) + return -1; + + mad_bit_init(&stream->ptr, ptr); + + return 0; +} + +/* + * NAME: stream->errorstr() + * DESCRIPTION: return a string description of the current error condition + */ +char const *mad_stream_errorstr(struct mad_stream const *stream) +{ + switch (stream->error) { + case MAD_ERROR_NONE: return "no error"; + + case MAD_ERROR_BUFLEN: return "input buffer too small (or EOF)"; + case MAD_ERROR_BUFPTR: return "invalid (null) buffer pointer"; + + case MAD_ERROR_NOMEM: return "not enough memory"; + + case MAD_ERROR_LOSTSYNC: return "lost synchronization"; + case MAD_ERROR_BADLAYER: return "reserved header layer value"; + case MAD_ERROR_BADBITRATE: return "forbidden bitrate value"; + case MAD_ERROR_BADSAMPLERATE: return "reserved sample frequency value"; + case MAD_ERROR_BADEMPHASIS: return "reserved emphasis value"; + + case MAD_ERROR_BADCRC: return "CRC check failed"; + case MAD_ERROR_BADBITALLOC: return "forbidden bit allocation value"; + case MAD_ERROR_BADSCALEFACTOR: return "bad scalefactor index"; + case MAD_ERROR_BADMODE: return "bad bitrate/mode combination"; + case MAD_ERROR_BADFRAMELEN: return "bad frame length"; + case MAD_ERROR_BADBIGVALUES: return "bad big_values count"; + case MAD_ERROR_BADBLOCKTYPE: return "reserved block_type"; + case MAD_ERROR_BADSCFSI: return "bad scalefactor selection info"; + case MAD_ERROR_BADDATAPTR: return "bad main_data_begin pointer"; + case MAD_ERROR_BADPART3LEN: return "bad audio data length"; + case MAD_ERROR_BADHUFFTABLE: return "bad Huffman table select"; + case MAD_ERROR_BADHUFFDATA: return "Huffman data overrun"; + case MAD_ERROR_BADSTEREO: return "incompatible block_type for JS"; + } + + return 0; +} diff --git a/lib/rbcodec/codecs/libmad/stream.h b/lib/rbcodec/codecs/libmad/stream.h new file mode 100644 index 0000000000..0aafb98787 --- /dev/null +++ b/lib/rbcodec/codecs/libmad/stream.h @@ -0,0 +1,113 @@ +/* + * libmad - MPEG audio decoder library + * Copyright (C) 2000-2004 Underbit Technologies, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * $Id$ + */ + +# ifndef LIBMAD_STREAM_H +# define LIBMAD_STREAM_H + +# include "bit.h" + +# define MAD_BUFFER_GUARD 8 +# define MAD_BUFFER_MDLEN (511 + 2048 + MAD_BUFFER_GUARD) + +enum mad_error { + MAD_ERROR_NONE = 0x0000, /* no error */ + + MAD_ERROR_BUFLEN = 0x0001, /* input buffer too small (or EOF) */ + MAD_ERROR_BUFPTR = 0x0002, /* invalid (null) buffer pointer */ + + MAD_ERROR_NOMEM = 0x0031, /* not enough memory */ + + MAD_ERROR_LOSTSYNC = 0x0101, /* lost synchronization */ + MAD_ERROR_BADLAYER = 0x0102, /* reserved header layer value */ + MAD_ERROR_BADBITRATE = 0x0103, /* forbidden bitrate value */ + MAD_ERROR_BADSAMPLERATE = 0x0104, /* reserved sample frequency value */ + MAD_ERROR_BADEMPHASIS = 0x0105, /* reserved emphasis value */ + + MAD_ERROR_BADCRC = 0x0201, /* CRC check failed */ + MAD_ERROR_BADBITALLOC = 0x0211, /* forbidden bit allocation value */ + MAD_ERROR_BADSCALEFACTOR = 0x0221, /* bad scalefactor index */ + MAD_ERROR_BADMODE = 0x0222, /* bad bitrate/mode combination */ + MAD_ERROR_BADFRAMELEN = 0x0231, /* bad frame length */ + MAD_ERROR_BADBIGVALUES = 0x0232, /* bad big_values count */ + MAD_ERROR_BADBLOCKTYPE = 0x0233, /* reserved block_type */ + MAD_ERROR_BADSCFSI = 0x0234, /* bad scalefactor selection info */ + MAD_ERROR_BADDATAPTR = 0x0235, /* bad main_data_begin pointer */ + MAD_ERROR_BADPART3LEN = 0x0236, /* bad audio data length */ + MAD_ERROR_BADHUFFTABLE = 0x0237, /* bad Huffman table select */ + MAD_ERROR_BADHUFFDATA = 0x0238, /* Huffman data overrun */ + MAD_ERROR_BADSTEREO = 0x0239 /* incompatible block_type for JS */ +}; + +# define MAD_RECOVERABLE(error) ((error) & 0xff00) + +struct mad_stream { + unsigned char const *buffer; /* input bitstream buffer */ + unsigned char const *bufend; /* end of buffer */ + /* rockbox: not used + unsigned long skiplen; */ /* bytes to skip before next frame */ + + int sync; /* stream sync found */ + unsigned long freerate; /* free bitrate (fixed) */ + + unsigned char const *this_frame; /* start of current frame */ + unsigned char const *next_frame; /* start of next frame */ + struct mad_bitptr ptr; /* current processing bit pointer */ + + struct mad_bitptr anc_ptr; /* ancillary bits pointer */ + unsigned int anc_bitlen; /* number of ancillary bits */ + + unsigned char (*main_data)[MAD_BUFFER_MDLEN] MEM_ALIGN_ATTR; + /* Layer III main_data() */ + unsigned int md_len; /* bytes in main_data */ + + int options; /* decoding options (see below) */ + enum mad_error error; /* error code (see above) */ +}; + +enum { + MAD_OPTION_IGNORECRC = 0x0001, /* ignore CRC errors */ +# if 0 /* rockbox: unused */ + MAD_OPTION_HALFSAMPLERATE = 0x0002 /* generate PCM at 1/2 sample rate */ +# endif +# if 0 /* not yet implemented */ + MAD_OPTION_LEFTCHANNEL = 0x0010, /* decode left channel only */ + MAD_OPTION_RIGHTCHANNEL = 0x0020, /* decode right channel only */ + MAD_OPTION_SINGLECHANNEL = 0x0030 /* combine channels */ +# endif +}; + +void mad_stream_init(struct mad_stream *); +/* rockbox: not used +void mad_stream_finish(struct mad_stream *); */ + +# define mad_stream_options(stream, opts) \ + ((void) ((stream)->options = (opts))) + +void mad_stream_buffer(struct mad_stream *, + unsigned char const *, unsigned long); +/* rockbox: not used +void mad_stream_skip(struct mad_stream *, unsigned long); */ + +int mad_stream_sync(struct mad_stream *); + +char const *mad_stream_errorstr(struct mad_stream const *); + +# endif diff --git a/lib/rbcodec/codecs/libmad/synth.c b/lib/rbcodec/codecs/libmad/synth.c new file mode 100644 index 0000000000..ebcf3d5015 --- /dev/null +++ b/lib/rbcodec/codecs/libmad/synth.c @@ -0,0 +1,1232 @@ +/* + * libmad - MPEG audio decoder library + * Copyright (C) 2000-2004 Underbit Technologies, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * $Id$ + */ + +# ifdef HAVE_CONFIG_H +# include "config.h" +# endif + +# include "global.h" + +# include "fixed.h" +# include "frame.h" +# include "synth.h" + +/* + * NAME: synth->init() + * DESCRIPTION: initialize synth struct + */ +void mad_synth_init(struct mad_synth *synth) +{ + mad_synth_mute(synth); + + synth->phase = 0; + + synth->pcm.samplerate = 0; + synth->pcm.channels = 0; + synth->pcm.length = 0; + #if defined(CPU_COLDFIRE) + /* init the emac unit here, since this function should always be called + before using libmad */ + coldfire_set_macsr(EMAC_FRACTIONAL | EMAC_SATURATE | EMAC_ROUND); + #endif +} + +/* + * NAME: synth->mute() + * DESCRIPTION: zero all polyphase filterbank values, resetting synthesis + */ +void mad_synth_mute(struct mad_synth *synth) +{ + memset(synth->filter, 0, sizeof(synth->filter)); +} + +#if 0 /* dct32 asm implementation is slower on current arm systems */ +/* #ifdef FPM_ARM */ + +void dct32(mad_fixed_t const in[32], unsigned int slot, + mad_fixed_t lo[16][8], mad_fixed_t hi[16][8]); + +#else + +/* + * An optional optimization called here the Subband Synthesis Optimization + * (SSO) improves the performance of subband synthesis at the expense of + * accuracy. + * + * The idea is to simplify 32x32->64-bit multiplication to 32x32->32 such + * that extra scaling and rounding are not necessary. This often allows the + * compiler to use faster 32-bit multiply-accumulate instructions instead of + * explicit 64-bit multiply, shift, and add instructions. + * + * SSO works like this: a full 32x32->64-bit multiply of two mad_fixed_t + * values requires the result to be right-shifted 28 bits to be properly + * scaled to the same fixed-point format. Right shifts can be applied at any + * time to either operand or to the result, so the optimization involves + * careful placement of these shifts to minimize the loss of accuracy. + * + * First, a 14-bit shift is applied with rounding at compile-time to the D[] + * table of coefficients for the subband synthesis window. This only loses 2 + * bits of accuracy because the lower 12 bits are always zero. A second + * 12-bit shift occurs after the DCT calculation. This loses 12 bits of + * accuracy. Finally, a third 2-bit shift occurs just before the sample is + * saved in the PCM buffer. 14 + 12 + 2 == 28 bits. + */ + +/* FPM_DEFAULT without OPT_SSO will actually not work. */ +# if defined(FPM_DEFAULT) && !defined(OPT_SSO) +# define OPT_SSO +# endif + +/* second SSO shift, with rounding */ +# if defined(OPT_SSO) +# define SHIFT(x) (((x) + (1L << 11)) >> 12) +# else +# define SHIFT(x) (x) +# endif + +/* possible DCT speed optimization */ +# if defined(FPM_COLDFIRE_EMAC) +/* This is a Coldfire version of the OPT_SPEED optimisation below, but in the + case of Coldfire it does not loose additional precision. */ +# define MUL(x, y) \ + ({ \ + mad_fixed64hi_t hi; \ + asm volatile("mac.l %[a], %[b], %%acc0\n\t" \ + "movclr.l %%acc0, %[hi]" \ + : [hi] "=r" (hi) \ + : [a] "r" ((x)), [b] "r" ((y))); \ + hi; \ + }) +# elif defined(FPM_ARM) +/* This is an ARM version of the OPT_SPEED optimisation below. This + implementation will loose 1 bit of accuracy. */ +# define MUL(x, y) \ + ({ \ + mad_fixed64lo_t lo; \ + mad_fixed64hi_t hi; \ + asm volatile ( \ + "smull %[lo], %[hi], %[a], %[b]\n\t" /* hi = result */ \ + "mov %[hi], %[hi], lsl #1" /* hi <<= 1 */ \ + : [lo]"=&r"(lo), [hi]"=&r"(hi) \ + : [a]"r"(x), [b]"r"(y)); \ + hi; \ + }) +# elif defined(OPT_SPEED) && defined(MAD_F_MLX) +# define MUL(x, y) \ + ({ mad_fixed64hi_t hi; \ + mad_fixed64lo_t lo; \ + MAD_F_MLX(hi, lo, (x), (y)); \ + hi << (32 - MAD_F_SCALEBITS - 3); \ + }) +# else +# define MUL(x, y) mad_f_mul((x), (y>>3)) +# endif + +/* + * NAME: dct32() + * DESCRIPTION: perform fast in[32]->out[32] DCT + */ +static +void dct32(mad_fixed_t const in[32], unsigned int slot, + mad_fixed_t lo[16][8], mad_fixed_t hi[16][8]) +{ + mad_fixed_t t0, t1, t2, t3, t4, t5, t6, t7; + mad_fixed_t t8, t9, t10, t11, t12, t13, t14, t15; + mad_fixed_t t16, t17, t18, t19, t20, t21, t22, t23; + mad_fixed_t t24, t25, t26, t27, t28, t29, t30, t31; + mad_fixed_t t32, t33, t34, t35, t36, t37, t38, t39; + mad_fixed_t t40, t41, t42, t43, t44, t45, t46, t47; + mad_fixed_t t48, t49, t50, t51, t52, t53, t54, t55; + mad_fixed_t t56, t57, t58, t59, t60, t61, t62, t63; + mad_fixed_t t64, t65, t66, t67, t68, t69, t70, t71; + mad_fixed_t t72, t73, t74, t75, t76, t77, t78, t79; + mad_fixed_t t80, t81, t82, t83, t84, t85, t86, t87; + mad_fixed_t t88, t89, t90, t91, t92, t93, t94, t95; + mad_fixed_t t96, t97, t98, t99, t100, t101, t102, t103; + mad_fixed_t t104, t105, t106, t107, t108, t109, t110, t111; + mad_fixed_t t112, t113, t114, t115, t116, t117, t118, t119; + mad_fixed_t t120, t121, t122, t123, t124, t125, t126, t127; + mad_fixed_t t128, t129, t130, t131, t132, t133, t134, t135; + mad_fixed_t t136, t137, t138, t139, t140, t141, t142, t143; + mad_fixed_t t144, t145, t146, t147, t148, t149, t150, t151; + mad_fixed_t t152, t153, t154, t155, t156, t157, t158, t159; + mad_fixed_t t160, t161, t162, t163, t164, t165, t166, t167; + mad_fixed_t t168, t169, t170, t171, t172, t173, t174, t175; + mad_fixed_t t176; + + /* costab[i] = cos(PI / (2 * 32) * i) */ +#define costab1 MAD_F(0x7fd8878e) /* 0.998795456 */ +#define costab2 MAD_F(0x7f62368f) /* 0.995184727 */ +#define costab3 MAD_F(0x7e9d55fc) /* 0.989176510 */ +#define costab4 MAD_F(0x7d8a5f40) /* 0.980785280 */ +#define costab5 MAD_F(0x7c29fbee) /* 0.970031253 */ +#define costab6 MAD_F(0x7a7d055b) /* 0.956940336 */ +#define costab7 MAD_F(0x78848414) /* 0.941544065 */ +#define costab8 MAD_F(0x7641af3d) /* 0.923879533 */ +#define costab9 MAD_F(0x73b5ebd1) /* 0.903989293 */ +#define costab10 MAD_F(0x70e2cbc6) /* 0.881921264 */ +#define costab11 MAD_F(0x6dca0d14) /* 0.857728610 */ +#define costab12 MAD_F(0x6a5d98a4) /* 0.831469612 */ +#define costab13 MAD_F(0x66cf8120) /* 0.803207531 */ +#define costab14 MAD_F(0x62f201ac) /* 0.773010453 */ +#define costab15 MAD_F(0x5ed77c8a) /* 0.740951125 */ +#define costab16 MAD_F(0x5a82799a) /* 0.707106781 */ +#define costab17 MAD_F(0x55f5a4d2) /* 0.671558955 */ +#define costab18 MAD_F(0x5133cc94) /* 0.634393284 */ +#define costab19 MAD_F(0x4c3fdff4) /* 0.595699304 */ +#define costab20 MAD_F(0x471cece7) /* 0.555570233 */ +#define costab21 MAD_F(0x41ce1e65) /* 0.514102744 */ +#define costab22 MAD_F(0x3c56ba70) /* 0.471396737 */ +#define costab23 MAD_F(0x36ba2014) /* 0.427555093 */ +#define costab24 MAD_F(0x30fbc54d) /* 0.382683432 */ +#define costab25 MAD_F(0x2b1f34eb) /* 0.336889853 */ +#define costab26 MAD_F(0x25280c5e) /* 0.290284677 */ +#define costab27 MAD_F(0x1f19f97b) /* 0.242980180 */ +#define costab28 MAD_F(0x18f8b83c) /* 0.195090322 */ +#define costab29 MAD_F(0x12c8106f) /* 0.146730474 */ +#define costab30 MAD_F(0x0c8bd35e) /* 0.098017140 */ +#define costab31 MAD_F(0x0647d97c) /* 0.049067674 */ + + t0 = in[0] + in[31]; t16 = MUL(in[0] - in[31], costab1); + t1 = in[15] + in[16]; t17 = MUL(in[15] - in[16], costab31); + + t41 = t16 + t17; + t59 = MUL(t16 - t17, costab2); + t33 = t0 + t1; + t50 = MUL(t0 - t1, costab2); + + t2 = in[7] + in[24]; t18 = MUL(in[7] - in[24], costab15); + t3 = in[8] + in[23]; t19 = MUL(in[8] - in[23], costab17); + + t42 = t18 + t19; + t60 = MUL(t18 - t19, costab30); + t34 = t2 + t3; + t51 = MUL(t2 - t3, costab30); + + t4 = in[3] + in[28]; t20 = MUL(in[3] - in[28], costab7); + t5 = in[12] + in[19]; t21 = MUL(in[12] - in[19], costab25); + + t43 = t20 + t21; + t61 = MUL(t20 - t21, costab14); + t35 = t4 + t5; + t52 = MUL(t4 - t5, costab14); + + t6 = in[4] + in[27]; t22 = MUL(in[4] - in[27], costab9); + t7 = in[11] + in[20]; t23 = MUL(in[11] - in[20], costab23); + + t44 = t22 + t23; + t62 = MUL(t22 - t23, costab18); + t36 = t6 + t7; + t53 = MUL(t6 - t7, costab18); + + t8 = in[1] + in[30]; t24 = MUL(in[1] - in[30], costab3); + t9 = in[14] + in[17]; t25 = MUL(in[14] - in[17], costab29); + + t45 = t24 + t25; + t63 = MUL(t24 - t25, costab6); + t37 = t8 + t9; + t54 = MUL(t8 - t9, costab6); + + t10 = in[6] + in[25]; t26 = MUL(in[6] - in[25], costab13); + t11 = in[9] + in[22]; t27 = MUL(in[9] - in[22], costab19); + + t46 = t26 + t27; + t64 = MUL(t26 - t27, costab26); + t38 = t10 + t11; + t55 = MUL(t10 - t11, costab26); + + t12 = in[2] + in[29]; t28 = MUL(in[2] - in[29], costab5); + t13 = in[13] + in[18]; t29 = MUL(in[13] - in[18], costab27); + + t47 = t28 + t29; + t65 = MUL(t28 - t29, costab10); + t39 = t12 + t13; + t56 = MUL(t12 - t13, costab10); + + t14 = in[5] + in[26]; t30 = MUL(in[5] - in[26], costab11); + t15 = in[10] + in[21]; t31 = MUL(in[10] - in[21], costab21); + + t48 = t30 + t31; + t66 = MUL(t30 - t31, costab22); + t40 = t14 + t15; + t57 = MUL(t14 - t15, costab22); + + t69 = t33 + t34; t89 = MUL(t33 - t34, costab4); + t70 = t35 + t36; t90 = MUL(t35 - t36, costab28); + t71 = t37 + t38; t91 = MUL(t37 - t38, costab12); + t72 = t39 + t40; t92 = MUL(t39 - t40, costab20); + t73 = t41 + t42; t94 = MUL(t41 - t42, costab4); + t74 = t43 + t44; t95 = MUL(t43 - t44, costab28); + t75 = t45 + t46; t96 = MUL(t45 - t46, costab12); + t76 = t47 + t48; t97 = MUL(t47 - t48, costab20); + + t78 = t50 + t51; t100 = MUL(t50 - t51, costab4); + t79 = t52 + t53; t101 = MUL(t52 - t53, costab28); + t80 = t54 + t55; t102 = MUL(t54 - t55, costab12); + t81 = t56 + t57; t103 = MUL(t56 - t57, costab20); + + t83 = t59 + t60; t106 = MUL(t59 - t60, costab4); + t84 = t61 + t62; t107 = MUL(t61 - t62, costab28); + t85 = t63 + t64; t108 = MUL(t63 - t64, costab12); + t86 = t65 + t66; t109 = MUL(t65 - t66, costab20); + + t113 = t69 + t70; + t114 = t71 + t72; + + /* 0 */ hi[15][slot] = SHIFT(t113 + t114); + /* 16 */ lo[ 0][slot] = SHIFT(MUL(t113 - t114, costab16)); + + t115 = t73 + t74; + t116 = t75 + t76; + + t32 = t115 + t116; + + /* 1 */ hi[14][slot] = SHIFT(t32); + + t118 = t78 + t79; + t119 = t80 + t81; + + t58 = t118 + t119; + + /* 2 */ hi[13][slot] = SHIFT(t58); + + t121 = t83 + t84; + t122 = t85 + t86; + + t67 = t121 + t122; + + t49 = (t67 * 2) - t32; + + /* 3 */ hi[12][slot] = SHIFT(t49); + + t125 = t89 + t90; + t126 = t91 + t92; + + t93 = t125 + t126; + + /* 4 */ hi[11][slot] = SHIFT(t93); + + t128 = t94 + t95; + t129 = t96 + t97; + + t98 = t128 + t129; + + t68 = (t98 * 2) - t49; + + /* 5 */ hi[10][slot] = SHIFT(t68); + + t132 = t100 + t101; + t133 = t102 + t103; + + t104 = t132 + t133; + + t82 = (t104 * 2) - t58; + + /* 6 */ hi[ 9][slot] = SHIFT(t82); + + t136 = t106 + t107; + t137 = t108 + t109; + + t110 = t136 + t137; + + t87 = (t110 * 2) - t67; + + t77 = (t87 * 2) - t68; + + /* 7 */ hi[ 8][slot] = SHIFT(t77); + + t141 = MUL(t69 - t70, costab8); + t142 = MUL(t71 - t72, costab24); + t143 = t141 + t142; + + /* 8 */ hi[ 7][slot] = SHIFT(t143); + /* 24 */ lo[ 8][slot] = + SHIFT((MUL(t141 - t142, costab16) * 2) - t143); + + t144 = MUL(t73 - t74, costab8); + t145 = MUL(t75 - t76, costab24); + t146 = t144 + t145; + + t88 = (t146 * 2) - t77; + + /* 9 */ hi[ 6][slot] = SHIFT(t88); + + t148 = MUL(t78 - t79, costab8); + t149 = MUL(t80 - t81, costab24); + t150 = t148 + t149; + + t105 = (t150 * 2) - t82; + + /* 10 */ hi[ 5][slot] = SHIFT(t105); + + t152 = MUL(t83 - t84, costab8); + t153 = MUL(t85 - t86, costab24); + t154 = t152 + t153; + + t111 = (t154 * 2) - t87; + + t99 = (t111 * 2) - t88; + + /* 11 */ hi[ 4][slot] = SHIFT(t99); + + t157 = MUL(t89 - t90, costab8); + t158 = MUL(t91 - t92, costab24); + t159 = t157 + t158; + + t127 = (t159 * 2) - t93; + + /* 12 */ hi[ 3][slot] = SHIFT(t127); + + t160 = (MUL(t125 - t126, costab16) * 2) - t127; + + /* 20 */ lo[ 4][slot] = SHIFT(t160); + /* 28 */ lo[12][slot] = + SHIFT((((MUL(t157 - t158, costab16) * 2) - t159) * 2) - t160); + + t161 = MUL(t94 - t95, costab8); + t162 = MUL(t96 - t97, costab24); + t163 = t161 + t162; + + t130 = (t163 * 2) - t98; + + t112 = (t130 * 2) - t99; + + /* 13 */ hi[ 2][slot] = SHIFT(t112); + + t164 = (MUL(t128 - t129, costab16) * 2) - t130; + + t166 = MUL(t100 - t101, costab8); + t167 = MUL(t102 - t103, costab24); + t168 = t166 + t167; + + t134 = (t168 * 2) - t104; + + t120 = (t134 * 2) - t105; + + /* 14 */ hi[ 1][slot] = SHIFT(t120); + + t135 = (MUL(t118 - t119, costab16) * 2) - t120; + + /* 18 */ lo[ 2][slot] = SHIFT(t135); + + t169 = (MUL(t132 - t133, costab16) * 2) - t134; + + t151 = (t169 * 2) - t135; + + /* 22 */ lo[ 6][slot] = SHIFT(t151); + + t170 = (((MUL(t148 - t149, costab16) * 2) - t150) * 2) - t151; + + /* 26 */ lo[10][slot] = SHIFT(t170); + /* 30 */ lo[14][slot] = + SHIFT((((((MUL(t166 - t167, costab16) * 2) - + t168) * 2) - t169) * 2) - t170); + + t171 = MUL(t106 - t107, costab8); + t172 = MUL(t108 - t109, costab24); + t173 = t171 + t172; + + t138 = (t173 * 2) - t110; + + t123 = (t138 * 2) - t111; + + t139 = (MUL(t121 - t122, costab16) * 2) - t123; + + t117 = (t123 * 2) - t112; + + /* 15 */ hi[ 0][slot] = SHIFT(t117); + + t124 = (MUL(t115 - t116, costab16) * 2) - t117; + + /* 17 */ lo[ 1][slot] = SHIFT(t124); + + t131 = (t139 * 2) - t124; + + /* 19 */ lo[ 3][slot] = SHIFT(t131); + + t140 = (t164 * 2) - t131; + + /* 21 */ lo[ 5][slot] = SHIFT(t140); + + t174 = (MUL(t136 - t137, costab16) * 2) - t138; + + t155 = (t174 * 2) - t139; + + t147 = (t155 * 2) - t140; + + /* 23 */ lo[ 7][slot] = SHIFT(t147); + + t156 = (((MUL(t144 - t145, costab16) * 2) - t146) * 2) - t147; + + /* 25 */ lo[ 9][slot] = SHIFT(t156); + + t175 = (((MUL(t152 - t153, costab16) * 2) - t154) * 2) - t155; + + t165 = (t175 * 2) - t156; + + /* 27 */ lo[11][slot] = SHIFT(t165); + + t176 = (((((MUL(t161 - t162, costab16) * 2) - + t163) * 2) - t164) * 2) - t165; + + /* 29 */ lo[13][slot] = SHIFT(t176); + /* 31 */ lo[15][slot] = + SHIFT((((((((MUL(t171 - t172, costab16) * 2) - + t173) * 2) - t174) * 2) - t175) * 2) - t176); + + /* + * Totals: + * 80 multiplies + * 80 additions + * 119 subtractions + * 49 shifts (not counting SSO) + */ +} + +# undef MUL +# undef SHIFT + +#endif + +/* third SSO shift and/or D[] optimization preshift */ + +# if defined(OPT_SSO) +# if MAD_F_FRACBITS != 28 +# error "MAD_F_FRACBITS must be 28 to use OPT_SSO" +# endif +# define ML0(hi, lo, x, y) ((lo) = (x) * (y)) +# define MLA(hi, lo, x, y) ((lo) += (x) * (y)) +# define MLN(hi, lo) ((lo) = -(lo)) +# define MLZ(hi, lo) ((void) (hi), (mad_fixed_t) (lo)) +# define SHIFT(x) ((x) >> 2) +# define PRESHIFT(x) ((MAD_F(x) + (1L << 13)) >> 14) +# else +# define ML0(hi, lo, x, y) MAD_F_ML0((hi), (lo), (x), (y)) +# define MLA(hi, lo, x, y) MAD_F_MLA((hi), (lo), (x), (y)) +# define MLN(hi, lo) MAD_F_MLN((hi), (lo)) +# define MLZ(hi, lo) MAD_F_MLZ((hi), (lo)) +# define SHIFT(x) (x) +# if defined(MAD_F_SCALEBITS) +# undef MAD_F_SCALEBITS +# define MAD_F_SCALEBITS (MAD_F_FRACBITS - 12) +# define PRESHIFT(x) (MAD_F(x) >> 12) +# else +# define PRESHIFT(x) MAD_F(x) +# endif +# endif + +static +mad_fixed_t const D[17][32] ICONST_ATTR MEM_ALIGN_ATTR = { +# include "D.dat" +}; + +/* + * NAME: synth->full() + * DESCRIPTION: perform full frequency PCM synthesis + */ +/* optimised version of synth_full */ +# ifdef FPM_COLDFIRE_EMAC + +#define SYNTH_EMAC1(res, f1, pD) \ + asm volatile( \ + "movem.l (%0), %%d0-%%d7 \n\t" \ + "move.l (%1), %%a5 \n\t" \ + "mac.l %%d0, %%a5, 56(%1), %%a5, %%acc0\n\t" \ + "mac.l %%d1, %%a5, 48(%1), %%a5, %%acc0\n\t" \ + "mac.l %%d2, %%a5, 40(%1), %%a5, %%acc0\n\t" \ + "mac.l %%d3, %%a5, 32(%1), %%a5, %%acc0\n\t" \ + "mac.l %%d4, %%a5, 24(%1), %%a5, %%acc0\n\t" \ + "mac.l %%d5, %%a5, 16(%1), %%a5, %%acc0\n\t" \ + "mac.l %%d6, %%a5, 8(%1), %%a5, %%acc0\n\t" \ + "mac.l %%d7, %%a5, %%acc0\n\t" \ + : \ + : "a" (*f1), "a" (*pD) \ + : "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", "a5"); \ + asm volatile ( \ + "movclr.l %%acc0, %0 \n\t" \ + : "=d" (res)); + +#define SYNTH_EMAC2(res, f1, f2, pD) \ + asm volatile( \ + "movem.l (%0), %%d0-%%d7 \n\t" \ + "move.l 4(%1), %%a5 \n\t" \ + "msac.l %%d0, %%a5, 60(%1), %%a5, %%acc0\n\t" \ + "msac.l %%d1, %%a5, 52(%1), %%a5, %%acc0\n\t" \ + "msac.l %%d2, %%a5, 44(%1), %%a5, %%acc0\n\t" \ + "msac.l %%d3, %%a5, 36(%1), %%a5, %%acc0\n\t" \ + "msac.l %%d4, %%a5, 28(%1), %%a5, %%acc0\n\t" \ + "msac.l %%d5, %%a5, 20(%1), %%a5, %%acc0\n\t" \ + "msac.l %%d6, %%a5, 12(%1), %%a5, %%acc0\n\t" \ + "msac.l %%d7, %%a5, (%1), %%a5, %%acc0\n\t" \ + "movem.l (%2), %%d0-%%d7 \n\t" \ + "mac.l %%d0, %%a5, 56(%1), %%a5, %%acc0\n\t" \ + "mac.l %%d1, %%a5, 48(%1), %%a5, %%acc0\n\t" \ + "mac.l %%d2, %%a5, 40(%1), %%a5, %%acc0\n\t" \ + "mac.l %%d3, %%a5, 32(%1), %%a5, %%acc0\n\t" \ + "mac.l %%d4, %%a5, 24(%1), %%a5, %%acc0\n\t" \ + "mac.l %%d5, %%a5, 16(%1), %%a5, %%acc0\n\t" \ + "mac.l %%d6, %%a5, 8(%1), %%a5, %%acc0\n\t" \ + "mac.l %%d7, %%a5, %%acc0\n\t" \ + : \ + : "a" (*f1), "a" (*pD), "a" (*f2) \ + : "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", "a5", "memory"); \ + asm volatile ( \ + "movclr.l %%acc0, %0 \n\t" \ + : "=d" (res)); + +#define SYNTH_EMAC_ODD_SBSAMPLE(f1, f2, pD1, pD2, res1, res2) \ + asm volatile ( \ + "movem.l (%0), %%d0-%%d7 \n\t" \ + "move.l 4(%2), %%a5 \n\t" \ + "msac.l %%d0, %%a5, 60(%2), %%a5, %%acc0\n\t" \ + "msac.l %%d1, %%a5, 52(%2), %%a5, %%acc0\n\t" \ + "msac.l %%d2, %%a5, 44(%2), %%a5, %%acc0\n\t" \ + "msac.l %%d3, %%a5, 36(%2), %%a5, %%acc0\n\t" \ + "msac.l %%d4, %%a5, 28(%2), %%a5, %%acc0\n\t" \ + "msac.l %%d5, %%a5, 20(%2), %%a5, %%acc0\n\t" \ + "msac.l %%d6, %%a5, 12(%2), %%a5, %%acc0\n\t" \ + "msac.l %%d7, %%a5, 112(%3), %%a5, %%acc0\n\t" \ + "mac.l %%d7, %%a5, 104(%3), %%a5, %%acc1\n\t" \ + "mac.l %%d6, %%a5, 96(%3), %%a5, %%acc1\n\t" \ + "mac.l %%d5, %%a5, 88(%3), %%a5, %%acc1\n\t" \ + "mac.l %%d4, %%a5, 80(%3), %%a5, %%acc1\n\t" \ + "mac.l %%d3, %%a5, 72(%3), %%a5, %%acc1\n\t" \ + "mac.l %%d2, %%a5, 64(%3), %%a5, %%acc1\n\t" \ + "mac.l %%d1, %%a5, 120(%3), %%a5, %%acc1\n\t" \ + "mac.l %%d0, %%a5, 8(%2), %%a5, %%acc1\n\t" \ + "movem.l (%1), %%d0-%%d7 \n\t" \ + "mac.l %%d7, %%a5, 16(%2), %%a5, %%acc0\n\t" \ + "mac.l %%d6, %%a5, 24(%2), %%a5, %%acc0\n\t" \ + "mac.l %%d5, %%a5, 32(%2), %%a5, %%acc0\n\t" \ + "mac.l %%d4, %%a5, 40(%2), %%a5, %%acc0\n\t" \ + "mac.l %%d3, %%a5, 48(%2), %%a5, %%acc0\n\t" \ + "mac.l %%d2, %%a5, 56(%2), %%a5, %%acc0\n\t" \ + "mac.l %%d1, %%a5, (%2), %%a5, %%acc0\n\t" \ + "mac.l %%d0, %%a5, 60(%3), %%a5, %%acc0\n\t" \ + "mac.l %%d0, %%a5, 68(%3), %%a5, %%acc1\n\t" \ + "mac.l %%d1, %%a5, 76(%3), %%a5, %%acc1\n\t" \ + "mac.l %%d2, %%a5, 84(%3), %%a5, %%acc1\n\t" \ + "mac.l %%d3, %%a5, 92(%3), %%a5, %%acc1\n\t" \ + "mac.l %%d4, %%a5, 100(%3), %%a5, %%acc1\n\t" \ + "mac.l %%d5, %%a5, 108(%3), %%a5, %%acc1\n\t" \ + "mac.l %%d6, %%a5, 116(%3), %%a5, %%acc1\n\t" \ + "mac.l %%d7, %%a5, %%acc1\n\t" \ + : \ + : "a" (*f1), "a" (*f2), "a" (*pD1), "a" (*pD2) \ + : "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", "a5", "memory"); \ + asm volatile( \ + "movclr.l %%acc0, %0\n\t" \ + "movclr.l %%acc1, %1\n\t" \ + : "=d" (res1), "=d" (res2) ); + +#define SYNTH_EMAC_EVEN_SBSAMPLE(f1, f2, pD1, pD2, res1, res2) \ + asm volatile ( \ + "movem.l (%0), %%d0-%%d7 \n\t" \ + "move.l (%2), %%a5 \n\t" \ + "msac.l %%d0, %%a5, 56(%2), %%a5, %%acc0\n\t" \ + "msac.l %%d1, %%a5, 48(%2), %%a5, %%acc0\n\t" \ + "msac.l %%d2, %%a5, 40(%2), %%a5, %%acc0\n\t" \ + "msac.l %%d3, %%a5, 32(%2), %%a5, %%acc0\n\t" \ + "msac.l %%d4, %%a5, 24(%2), %%a5, %%acc0\n\t" \ + "msac.l %%d5, %%a5, 16(%2), %%a5, %%acc0\n\t" \ + "msac.l %%d6, %%a5, 8(%2), %%a5, %%acc0\n\t" \ + "msac.l %%d7, %%a5, 116(%3), %%a5, %%acc0\n\t" \ + "mac.l %%d7, %%a5, 108(%3), %%a5, %%acc1\n\t" \ + "mac.l %%d6, %%a5, 100(%3), %%a5, %%acc1\n\t" \ + "mac.l %%d5, %%a5, 92(%3), %%a5, %%acc1\n\t" \ + "mac.l %%d4, %%a5, 84(%3), %%a5, %%acc1\n\t" \ + "mac.l %%d3, %%a5, 76(%3), %%a5, %%acc1\n\t" \ + "mac.l %%d2, %%a5, 68(%3), %%a5, %%acc1\n\t" \ + "mac.l %%d1, %%a5, 60(%3), %%a5, %%acc1\n\t" \ + "mac.l %%d0, %%a5, 12(%2), %%a5, %%acc1\n\t" \ + "movem.l (%1), %%d0-%%d7 \n\t" \ + "mac.l %%d7, %%a5, 20(%2), %%a5, %%acc0\n\t" \ + "mac.l %%d6, %%a5, 28(%2), %%a5, %%acc0\n\t" \ + "mac.l %%d5, %%a5, 36(%2), %%a5, %%acc0\n\t" \ + "mac.l %%d4, %%a5, 44(%2), %%a5, %%acc0\n\t" \ + "mac.l %%d3, %%a5, 52(%2), %%a5, %%acc0\n\t" \ + "mac.l %%d2, %%a5, 60(%2), %%a5, %%acc0\n\t" \ + "mac.l %%d1, %%a5, 4(%2), %%a5, %%acc0\n\t" \ + "mac.l %%d0, %%a5, 120(%3), %%a5, %%acc0\n\t" \ + "mac.l %%d0, %%a5, 64(%3), %%a5, %%acc1\n\t" \ + "mac.l %%d1, %%a5, 72(%3), %%a5, %%acc1\n\t" \ + "mac.l %%d2, %%a5, 80(%3), %%a5, %%acc1\n\t" \ + "mac.l %%d3, %%a5, 88(%3), %%a5, %%acc1\n\t" \ + "mac.l %%d4, %%a5, 96(%3), %%a5, %%acc1\n\t" \ + "mac.l %%d5, %%a5, 104(%3), %%a5, %%acc1\n\t" \ + "mac.l %%d6, %%a5, 112(%3), %%a5, %%acc1\n\t" \ + "mac.l %%d7, %%a5, %%acc1\n\t" \ + : \ + : "a" (*f1), "a" (*f2), "a" (*pD1), "a" (*pD2) \ + : "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", "a5", "memory"); \ + asm volatile( \ + "movclr.l %%acc0, %0\n\t" \ + "movclr.l %%acc1, %1\n\t" \ + : "=d" (res1), "=d" (res2) ); + +static +void synth_full(struct mad_synth *synth, struct mad_frame const *frame, + unsigned int nch, unsigned int ns) +{ + int sb; + unsigned int phase, ch, s, p; + mad_fixed_t *pcm, (*filter)[2][2][16][8]; + mad_fixed_t (*sbsample)[36][32]; + mad_fixed_t (*fe)[8], (*fx)[8], (*fo)[8]; + mad_fixed_t const (*D0ptr)[32]; + mad_fixed_t const (*D1ptr)[32]; + mad_fixed64hi_t hi0, hi1; + + for (ch = 0; ch < nch; ++ch) { + sbsample = &(*frame->sbsample_prev)[ch]; + filter = &synth->filter[ch]; + phase = synth->phase; + pcm = synth->pcm.samples[ch]; + + for (s = 0; s < ns; ++s) { + dct32((*sbsample)[s], phase >> 1, + (*filter)[0][phase & 1], (*filter)[1][phase & 1]); + + p = (phase - 1) & 0xf; + + /* calculate 32 samples */ + fe = &(*filter)[0][ phase & 1][0]; + fx = &(*filter)[0][~phase & 1][0]; + fo = &(*filter)[1][~phase & 1][0]; + + D0ptr = (void*)&D[0][ p]; + D1ptr = (void*)&D[0][-p]; + + if(s & 1) + { + SYNTH_EMAC2(hi0, fx, fe, D0ptr); + pcm[0] = hi0 << 3; /* shift result to libmad's fixed point format */ + pcm += 16; + + for (sb = 15; sb; sb--, fo++) { + ++fe; + ++D0ptr; + ++D1ptr; + + /* D[32 - sb][i] == -D[sb][31 - i] */ + SYNTH_EMAC_ODD_SBSAMPLE(fo, fe, D0ptr, D1ptr, hi0, hi1); + pcm[-sb] = hi0 << 3; + pcm[ sb] = hi1 << 3; + } + + ++D0ptr; + SYNTH_EMAC1(hi0, fo, D0ptr+1); + pcm[0] = -(hi0 << 3); + } + else + { + SYNTH_EMAC2(hi0, fe, fx, D0ptr); + pcm[0] = -(hi0 << 3); /* shift result to libmad's fixed point format */ + pcm += 16; + + for (sb = 15; sb; sb--, fo++) { + ++fe; + ++D0ptr; + ++D1ptr; + + /* D[32 - sb][i] == -D[sb][31 - i] */ + SYNTH_EMAC_EVEN_SBSAMPLE(fo, fe, D0ptr, D1ptr, hi0, hi1); + pcm[-sb] = hi0 << 3; + pcm[ sb] = hi1 << 3; + } + + ++D0ptr; + SYNTH_EMAC1(hi0, fo, D0ptr); + pcm[0] = -(hi0 << 3); + } + pcm += 16; + phase = (phase + 1) % 16; + } + } +} + +#elif defined(FPM_ARM) + +#define PROD_O(hi, lo, f, ptr) \ + ({ \ + mad_fixed_t *__p = (f); \ + asm("ldmia %2!, {r0, r1, r2, r3}\n\t" \ + "ldr r4, [%3, #0]\n\t" \ + "ldr r12, [%3, #56]\n\t" \ + "smull %0, %1, r0, r4\n\t" \ + "ldr r4, [%3, #48]\n\t" \ + "smlal %0, %1, r1, r12\n\t" \ + "ldr r12, [%3, #40]\n\t" \ + "smlal %0, %1, r2, r4\n\t" \ + "smlal %0, %1, r3, r12\n\t" \ + "ldmia %2, {r0, r1, r2, r3}\n\t" \ + "ldr r4, [%3, #32]\n\t" \ + "ldr r12, [%3, #24]\n\t" \ + "smlal %0, %1, r0, r4\n\t" \ + "ldr r4, [%3, #16]\n\t" \ + "smlal %0, %1, r1, r12\n\t" \ + "ldr r12, [%3, #8]\n\t" \ + "smlal %0, %1, r2, r4\n\t" \ + "smlal %0, %1, r3, r12\n\t" \ + : "=&r" (lo), "=&r" (hi), "+r" (__p) \ + : "r" (ptr) \ + : "r0", "r1", "r2", "r3", "r4", "r12"); \ + }) + +#define PROD_A(hi, lo, f, ptr) \ + ({ \ + mad_fixed_t *__p = (f); \ + asm("ldmia %2!, {r0, r1, r2, r3}\n\t" \ + "ldr r4, [%3, #0]\n\t" \ + "ldr r12, [%3, #56]\n\t" \ + "smlal %0, %1, r0, r4\n\t" \ + "ldr r4, [%3, #48]\n\t" \ + "smlal %0, %1, r1, r12\n\t" \ + "ldr r12, [%3, #40]\n\t" \ + "smlal %0, %1, r2, r4\n\t" \ + "smlal %0, %1, r3, r12\n\t" \ + "ldmia %2, {r0, r1, r2, r3}\n\t" \ + "ldr r4, [%3, #32]\n\t" \ + "ldr r12, [%3, #24]\n\t" \ + "smlal %0, %1, r0, r4\n\t" \ + "ldr r4, [%3, #16]\n\t" \ + "smlal %0, %1, r1, r12\n\t" \ + "ldr r12, [%3, #8]\n\t" \ + "smlal %0, %1, r2, r4\n\t" \ + "smlal %0, %1, r3, r12\n\t" \ + : "+r" (lo), "+r" (hi), "+r" (__p) \ + : "r" (ptr) \ + : "r0", "r1", "r2", "r3", "r4", "r12"); \ + }) + +void synth_full_odd_sbsample (mad_fixed_t *pcm, + mad_fixed_t (*fo)[8], + mad_fixed_t (*fe)[8], + mad_fixed_t const (*D0ptr)[32], + mad_fixed_t const (*D1ptr)[32]); +void synth_full_even_sbsample(mad_fixed_t *pcm, + mad_fixed_t (*fo)[8], + mad_fixed_t (*fe)[8], + mad_fixed_t const (*D0ptr)[32], + mad_fixed_t const (*D1ptr)[32]); + +static +void synth_full(struct mad_synth *synth, struct mad_frame const *frame, + unsigned int nch, unsigned int ns) ICODE_ATTR_MPA_SYNTH; +static +void synth_full(struct mad_synth *synth, struct mad_frame const *frame, + unsigned int nch, unsigned int ns) +{ + int p; + unsigned int phase, ch, s; + mad_fixed_t *pcm, (*filter)[2][2][16][8]; + mad_fixed_t (*sbsample)[36][32]; + mad_fixed_t (*fe)[8], (*fx)[8], (*fo)[8]; + mad_fixed_t const (*D0ptr)[32], *ptr; + mad_fixed_t const (*D1ptr)[32]; + mad_fixed64hi_t hi; + mad_fixed64lo_t lo; + + for (ch = 0; ch < nch; ++ch) { + sbsample = &(*frame->sbsample_prev)[ch]; + filter = &synth->filter[ch]; + phase = synth->phase; + pcm = synth->pcm.samples[ch]; + + for (s = 0; s < ns; ++s) { + dct32((*sbsample)[s], phase >> 1, + (*filter)[0][phase & 1], (*filter)[1][phase & 1]); + + p = (phase - 1) & 0xf; + + /* calculate 32 samples */ + fe = &(*filter)[0][ phase & 1][0]; + fx = &(*filter)[0][~phase & 1][0]; + fo = &(*filter)[1][~phase & 1][0]; + + D0ptr = (void*)&D[0][ p]; + D1ptr = (void*)&D[0][-p]; + + if(s & 1) + { + ptr = *D0ptr; + PROD_O(hi, lo, *fx, ptr+1); + MLN(hi, lo); + PROD_A(hi, lo, *fe, ptr); + pcm[0] = SHIFT(MLZ(hi, lo)); + pcm += 16; + + synth_full_odd_sbsample(pcm, fo, fe, D0ptr, D1ptr); + D0ptr += 15; + D1ptr += 15; + fo += 15; + fe += 15; + + ptr = *(D0ptr + 1); + PROD_O(hi, lo, *fo, ptr+1); + pcm[0] = SHIFT(-MLZ(hi, lo)); + } + else + { + ptr = *D0ptr; + PROD_O(hi, lo, *fx, ptr); + MLN(hi, lo); + PROD_A(hi, lo, *fe, ptr+1); + pcm[0] = SHIFT(MLZ(hi, lo)); + pcm += 16; + + synth_full_even_sbsample(pcm, fo, fe, D0ptr, D1ptr); + D0ptr += 15; + D1ptr += 15; + fo += 15; + fe += 15; + + ptr = *(D0ptr + 1); + PROD_O(hi, lo, *fo, ptr); + pcm[0] = SHIFT(-MLZ(hi, lo)); + } + + pcm += 16; + phase = (phase + 1) % 16; + } + } +} + +# else /* not FPM_COLDFIRE_EMAC and not FPM_ARM */ + +#define PROD_O(hi, lo, f, ptr, offset) \ + ML0(hi, lo, (*f)[0], ptr[ 0+offset]); \ + MLA(hi, lo, (*f)[1], ptr[14+offset]); \ + MLA(hi, lo, (*f)[2], ptr[12+offset]); \ + MLA(hi, lo, (*f)[3], ptr[10+offset]); \ + MLA(hi, lo, (*f)[4], ptr[ 8+offset]); \ + MLA(hi, lo, (*f)[5], ptr[ 6+offset]); \ + MLA(hi, lo, (*f)[6], ptr[ 4+offset]); \ + MLA(hi, lo, (*f)[7], ptr[ 2+offset]); + +#define PROD_A(hi, lo, f, ptr, offset) \ + MLA(hi, lo, (*f)[0], ptr[ 0+offset]); \ + MLA(hi, lo, (*f)[1], ptr[14+offset]); \ + MLA(hi, lo, (*f)[2], ptr[12+offset]); \ + MLA(hi, lo, (*f)[3], ptr[10+offset]); \ + MLA(hi, lo, (*f)[4], ptr[ 8+offset]); \ + MLA(hi, lo, (*f)[5], ptr[ 6+offset]); \ + MLA(hi, lo, (*f)[6], ptr[ 4+offset]); \ + MLA(hi, lo, (*f)[7], ptr[ 2+offset]); + +#define PROD_SB(hi, lo, ptr, offset, first_idx, last_idx) \ + ML0(hi, lo, (*fe)[0], ptr[first_idx]); \ + MLA(hi, lo, (*fe)[1], ptr[16+offset]); \ + MLA(hi, lo, (*fe)[2], ptr[18+offset]); \ + MLA(hi, lo, (*fe)[3], ptr[20+offset]); \ + MLA(hi, lo, (*fe)[4], ptr[22+offset]); \ + MLA(hi, lo, (*fe)[5], ptr[24+offset]); \ + MLA(hi, lo, (*fe)[6], ptr[26+offset]); \ + MLA(hi, lo, (*fe)[7], ptr[28+offset]); \ + MLA(hi, lo, (*fo)[7], ptr[29-offset]); \ + MLA(hi, lo, (*fo)[6], ptr[27-offset]); \ + MLA(hi, lo, (*fo)[5], ptr[25-offset]); \ + MLA(hi, lo, (*fo)[4], ptr[23-offset]); \ + MLA(hi, lo, (*fo)[3], ptr[21-offset]); \ + MLA(hi, lo, (*fo)[2], ptr[19-offset]); \ + MLA(hi, lo, (*fo)[1], ptr[17-offset]); \ + MLA(hi, lo, (*fo)[0], ptr[last_idx ]); + +static +void synth_full(struct mad_synth *synth, struct mad_frame const *frame, + unsigned int nch, unsigned int ns) +{ + int p, sb; + unsigned int phase, ch, s; + mad_fixed_t *pcm, (*filter)[2][2][16][8]; + mad_fixed_t (*sbsample)[36][32]; + mad_fixed_t (*fe)[8], (*fx)[8], (*fo)[8]; + mad_fixed_t const (*D0ptr)[32], *ptr; + mad_fixed_t const (*D1ptr)[32]; + mad_fixed64hi_t hi; + mad_fixed64lo_t lo; + + for (ch = 0; ch < nch; ++ch) { + sbsample = &(*frame->sbsample_prev)[ch]; + filter = &synth->filter[ch]; + phase = synth->phase; + pcm = synth->pcm.samples[ch]; + + for (s = 0; s < ns; ++s) { + dct32((*sbsample)[s], phase >> 1, + (*filter)[0][phase & 1], (*filter)[1][phase & 1]); + + p = (phase - 1) & 0xf; + + /* calculate 32 samples */ + fe = &(*filter)[0][ phase & 1][0]; + fx = &(*filter)[0][~phase & 1][0]; + fo = &(*filter)[1][~phase & 1][0]; + + D0ptr = (void*)&D[0][ p]; + D1ptr = (void*)&D[0][-p]; + + if(s & 1) + { + ptr = *D0ptr; + PROD_O(hi, lo, fx, ptr, 1) + MLN(hi, lo); + PROD_A(hi, lo, fe, ptr, 0) + pcm[0] = SHIFT(MLZ(hi, lo)); + pcm += 16; + + for (sb = 15; sb; sb--, fo++) + { + ++fe; + ++D0ptr; + ++D1ptr; + + /* D[32 - sb][i] == -D[sb][31 - i] */ + ptr = *D0ptr; + PROD_O(hi, lo, fo, ptr, 1) + MLN(hi, lo); + PROD_A(hi, lo, fe, ptr, 0) + pcm[-sb] = SHIFT(MLZ(hi, lo)); + + ptr = *D1ptr; + PROD_SB(hi, lo, ptr, 1, 15, 30) + pcm[sb] = SHIFT(MLZ(hi, lo)); + } + + ptr = *(D0ptr + 1); + PROD_O(hi, lo, fo, ptr, 1) + pcm[0] = SHIFT(-MLZ(hi, lo)); + } + else + { + ptr = *D0ptr; + PROD_O(hi, lo, fx, ptr, 0) + MLN(hi, lo); + PROD_A(hi, lo, fe, ptr, 1) + pcm[0] = SHIFT(MLZ(hi, lo)); + pcm += 16; + + for (sb = 15; sb; sb--, fo++) + { + ++fe; + ++D0ptr; + ++D1ptr; + + /* D[32 - sb][i] == -D[sb][31 - i] */ + ptr = *D0ptr; + PROD_O(hi, lo, fo, ptr, 0) + MLN(hi, lo); + PROD_A(hi, lo, fe, ptr, 1) + pcm[-sb] = SHIFT(MLZ(hi, lo)); + + ptr = *D1ptr; + PROD_SB(hi, lo, ptr, 0, 30, 15) + pcm[sb] = SHIFT(MLZ(hi, lo)); + } + + ptr = *(D0ptr + 1); + PROD_O(hi, lo, fo, ptr, 0) + pcm[0] = SHIFT(-MLZ(hi, lo)); + } + + pcm += 16; + phase = (phase + 1) % 16; + } + } +} +# endif /* FPM_COLDFIRE_EMAC, FPM_ARM */ + +#if 0 /* rockbox: unused */ +/* + * NAME: synth->half() + * DESCRIPTION: perform half frequency PCM synthesis + */ +static +void synth_half(struct mad_synth *synth, struct mad_frame const *frame, + unsigned int nch, unsigned int ns) +{ + unsigned int phase, ch, s, sb, pe, po; + mad_fixed_t *pcm1, *pcm2, (*filter)[2][2][16][8]; + mad_fixed_t (*sbsample)[36][32]; + register mad_fixed_t (*fe)[8], (*fx)[8], (*fo)[8]; + register mad_fixed_t const (*Dptr)[32], *ptr; + register mad_fixed64hi_t hi; + register mad_fixed64lo_t lo; + + for (ch = 0; ch < nch; ++ch) { + sbsample = &(*frame->sbsample_prev)[ch]; + filter = &synth->filter[ch]; + phase = synth->phase; + pcm1 = synth->pcm.samples[ch]; + + for (s = 0; s < ns; ++s) { + dct32((*sbsample)[s], phase >> 1, + (*filter)[0][phase & 1], (*filter)[1][phase & 1]); + + pe = phase & ~1; + po = ((phase - 1) & 0xf) | 1; + + /* calculate 16 samples */ + + fe = &(*filter)[0][ phase & 1][0]; + fx = &(*filter)[0][~phase & 1][0]; + fo = &(*filter)[1][~phase & 1][0]; + + Dptr = &D[0]; + + ptr = *Dptr + po; + ML0(hi, lo, (*fx)[0], ptr[ 0]); + MLA(hi, lo, (*fx)[1], ptr[14]); + MLA(hi, lo, (*fx)[2], ptr[12]); + MLA(hi, lo, (*fx)[3], ptr[10]); + MLA(hi, lo, (*fx)[4], ptr[ 8]); + MLA(hi, lo, (*fx)[5], ptr[ 6]); + MLA(hi, lo, (*fx)[6], ptr[ 4]); + MLA(hi, lo, (*fx)[7], ptr[ 2]); + MLN(hi, lo); + + ptr = *Dptr + pe; + MLA(hi, lo, (*fe)[0], ptr[ 0]); + MLA(hi, lo, (*fe)[1], ptr[14]); + MLA(hi, lo, (*fe)[2], ptr[12]); + MLA(hi, lo, (*fe)[3], ptr[10]); + MLA(hi, lo, (*fe)[4], ptr[ 8]); + MLA(hi, lo, (*fe)[5], ptr[ 6]); + MLA(hi, lo, (*fe)[6], ptr[ 4]); + MLA(hi, lo, (*fe)[7], ptr[ 2]); + + *pcm1++ = SHIFT(MLZ(hi, lo)); + + pcm2 = pcm1 + 14; + + for (sb = 1; sb < 16; ++sb) { + ++fe; + ++Dptr; + + /* D[32 - sb][i] == -D[sb][31 - i] */ + + if (!(sb & 1)) { + ptr = *Dptr + po; + ML0(hi, lo, (*fo)[0], ptr[ 0]); + MLA(hi, lo, (*fo)[1], ptr[14]); + MLA(hi, lo, (*fo)[2], ptr[12]); + MLA(hi, lo, (*fo)[3], ptr[10]); + MLA(hi, lo, (*fo)[4], ptr[ 8]); + MLA(hi, lo, (*fo)[5], ptr[ 6]); + MLA(hi, lo, (*fo)[6], ptr[ 4]); + MLA(hi, lo, (*fo)[7], ptr[ 2]); + MLN(hi, lo); + + ptr = *Dptr + pe; + MLA(hi, lo, (*fe)[7], ptr[ 2]); + MLA(hi, lo, (*fe)[6], ptr[ 4]); + MLA(hi, lo, (*fe)[5], ptr[ 6]); + MLA(hi, lo, (*fe)[4], ptr[ 8]); + MLA(hi, lo, (*fe)[3], ptr[10]); + MLA(hi, lo, (*fe)[2], ptr[12]); + MLA(hi, lo, (*fe)[1], ptr[14]); + MLA(hi, lo, (*fe)[0], ptr[ 0]); + + *pcm1++ = SHIFT(MLZ(hi, lo)); + + ptr = *Dptr - po; + ML0(hi, lo, (*fo)[7], ptr[31 - 2]); + MLA(hi, lo, (*fo)[6], ptr[31 - 4]); + MLA(hi, lo, (*fo)[5], ptr[31 - 6]); + MLA(hi, lo, (*fo)[4], ptr[31 - 8]); + MLA(hi, lo, (*fo)[3], ptr[31 - 10]); + MLA(hi, lo, (*fo)[2], ptr[31 - 12]); + MLA(hi, lo, (*fo)[1], ptr[31 - 14]); + MLA(hi, lo, (*fo)[0], ptr[31 - 16]); + + ptr = *Dptr - pe; + MLA(hi, lo, (*fe)[0], ptr[31 - 16]); + MLA(hi, lo, (*fe)[1], ptr[31 - 14]); + MLA(hi, lo, (*fe)[2], ptr[31 - 12]); + MLA(hi, lo, (*fe)[3], ptr[31 - 10]); + MLA(hi, lo, (*fe)[4], ptr[31 - 8]); + MLA(hi, lo, (*fe)[5], ptr[31 - 6]); + MLA(hi, lo, (*fe)[6], ptr[31 - 4]); + MLA(hi, lo, (*fe)[7], ptr[31 - 2]); + + *pcm2-- = SHIFT(MLZ(hi, lo)); + } + + ++fo; + } + + ++Dptr; + + ptr = *Dptr + po; + ML0(hi, lo, (*fo)[0], ptr[ 0]); + MLA(hi, lo, (*fo)[1], ptr[14]); + MLA(hi, lo, (*fo)[2], ptr[12]); + MLA(hi, lo, (*fo)[3], ptr[10]); + MLA(hi, lo, (*fo)[4], ptr[ 8]); + MLA(hi, lo, (*fo)[5], ptr[ 6]); + MLA(hi, lo, (*fo)[6], ptr[ 4]); + MLA(hi, lo, (*fo)[7], ptr[ 2]); + + *pcm1 = SHIFT(-MLZ(hi, lo)); + pcm1 += 8; + + phase = (phase + 1) % 16; + } + } +} +#endif /* unused */ + +/* + * NAME: synth->frame() + * DESCRIPTION: perform PCM synthesis of frame subband samples + */ +void mad_synth_frame(struct mad_synth *synth, struct mad_frame const *frame) +{ + unsigned int nch, ns; +#if 0 /* rockbox: unused */ + void (*synth_frame)(struct mad_synth *, struct mad_frame const *, + unsigned int, unsigned int); +#endif + + nch = MAD_NCHANNELS(&frame->header); + ns = MAD_NSBSAMPLES(&frame->header); + + synth->pcm.samplerate = frame->header.samplerate; + synth->pcm.channels = nch; + synth->pcm.length = 32 * ns; + +#if 0 /* rockbox: unused */ + synth_frame = synth_full; + + if (frame->options & MAD_OPTION_HALFSAMPLERATE) { + synth->pcm.samplerate /= 2; + synth->pcm.length /= 2; + + synth_frame = synth_half; + } + + synth_frame(synth, frame, nch, ns); +#else + synth_full(synth, frame, nch, ns); +#endif + + synth->phase = (synth->phase + ns) % 16; +} diff --git a/lib/rbcodec/codecs/libmad/synth.h b/lib/rbcodec/codecs/libmad/synth.h new file mode 100644 index 0000000000..93dd3946d4 --- /dev/null +++ b/lib/rbcodec/codecs/libmad/synth.h @@ -0,0 +1,52 @@ +/* + * libmad - MPEG audio decoder library + * Copyright (C) 2000-2004 Underbit Technologies, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * $Id$ + */ + +# ifndef LIBMAD_SYNTH_H +# define LIBMAD_SYNTH_H + +# include "fixed.h" +# include "frame.h" + +struct mad_pcm { + unsigned int samplerate; /* sampling frequency (Hz) */ + unsigned short channels; /* number of channels */ + unsigned short length; /* number of samples per channel */ + mad_fixed_t samples[2][1152] MEM_ALIGN_ATTR; /* PCM output samples [ch][sample] */ +}; + +struct mad_synth { + mad_fixed_t filter[2][2][2][16][8] MEM_ALIGN_ATTR; /* polyphase filterbank outputs */ + /* [ch][eo][peo][s][v] */ + + unsigned int phase; /* current processing phase */ + + struct mad_pcm pcm; /* PCM output */ +}; + +void mad_synth_init(struct mad_synth *); + +# define mad_synth_finish(synth) /* nothing */ + +void mad_synth_mute(struct mad_synth *); + +void mad_synth_frame(struct mad_synth *, struct mad_frame const *); + +# endif diff --git a/lib/rbcodec/codecs/libmad/synth_full_arm.S b/lib/rbcodec/codecs/libmad/synth_full_arm.S new file mode 100644 index 0000000000..0a4f9b93c2 --- /dev/null +++ b/lib/rbcodec/codecs/libmad/synth_full_arm.S @@ -0,0 +1,340 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2007 by Tomasz Malesinski + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include "config.h" +#include "mad_iram.h" + + .section ICODE_SECTION_MPA_ARM,"ax",%progbits + + .global synth_full_odd_sbsample + .global synth_full_even_sbsample + + /* + ;; r0 = pcm (pushed on the stack to free a register) + ;; r1 = fo + ;; r2 = fe + ;; r3 = D0ptr + ;; r4 = D1ptr + + ;; r5 = loop counter + ;; r6,r7 accumulator1 + ;; r8,r9 accumulator2 + */ + +synth_full_odd_sbsample: + stmdb sp!, {r0, r4-r11, lr} + ldr r4, [sp, #40] + mov r5, #15 + add r2, r2, #32 +.l: + /* ;; PROD_O and odd half of SB_SAMPLE*/ + add r3, r3, #128 + add r4, r4, #128 + ldr r7, [r3, #4] + ldmia r1!, {r0, r10, r11, lr} + ldr r9, [r4, #120] + smull r6, r7, r0, r7 + ldr r12, [r3, #60] + smull r8, r9, r0, r9 + ldr r0, [r3, #52] + smlal r6, r7, r10, r12 + ldr r12, [r3, #44] + smlal r6, r7, r11, r0 + ldr r0, [r4, #64] + smlal r6, r7, lr, r12 + ldr r12, [r4, #72] + smlal r8, r9, r10, r0 + ldr r0, [r4, #80] + smlal r8, r9, r11, r12 + smlal r8, r9, lr, r0 + ldr r0, [r3, #36] + + ldmia r1!, {r10, r11, r12, lr} + smlal r6, r7, r10, r0 + + ldr r0, [r4, #88] /*;;1 cycle stall on arm9, but we free up r10*/ + smlal r8, r9, r10, r0 + + ldr r0, [r3, #28] + ldr r10, [r3, #20] + smlal r6, r7, r11, r0 + ldr r0, [r3, #12] + smlal r6, r7, r12, r10 + ldr r10, [r4, #96] + smlal r6, r7, lr, r0 + ldr r0, [r4, #104] + smlal r8, r9, r11, r10 + ldr r10, [r4, #112] + smlal r8, r9, r12, r0 + smlal r8, r9, lr, r10 + + rsbs r6, r6, #0 + rsc r7, r7, #0 + + /* ;; PROD_A and even half of SB_SAMPLE*/ + ldr r0, [r3, #0] + ldmia r2!, {r10, r11, r12, lr} + smlal r6, r7, r10, r0 + + ldr r0, [r4, #60] /*;;1 cycle stall on arm9, but we free up r10*/ + smlal r8, r9, r10, r0 + ldr r10, [r3, #56] + ldr r0, [r3, #48] + smlal r6, r7, r11, r10 + ldr r10, [r3, #40] + smlal r6, r7, r12, r0 + ldr r0, [r4, #68] + smlal r6, r7, lr, r10 + ldr r10, [r4, #76] + smlal r8, r9, r11, r0 + ldr r0, [r4, #84] + smlal r8, r9, r12, r10 + smlal r8, r9, lr, r0 + + ldr r0, [r3, #32] + ldmia r2!, {r10, r11, r12, lr} + smlal r6, r7, r10, r0 + + ldr r0, [r4, #92] /*;;1 cycle stall on arm9, but we free up r10*/ + smlal r8, r9, r10, r0 + + ldr r0, [r3, #24] + ldr r10, [r3, #16] + smlal r6, r7, r11, r0 + ldr r0, [r3, #8] + smlal r6, r7, r12, r10 + ldr r10, [r4, #100] + smlal r6, r7, lr, r0 + ldr r0, [r4, #108] + smlal r8, r9, r11, r10 + ldr r10, [r4, #116] + smlal r8, r9, r12, r0 + smlal r8, r9, lr, r10 + + ldr r0, [sp] + + movs r6, r6, lsr #16 + adc r6, r6, r7, lsl #16 + str r6, [r0, -r5, lsl #2] + + movs r8, r8, lsr #16 + adc r8, r8, r9, lsl #16 + str r8, [r0, r5, lsl #2] + + subs r5, r5, #1 + bne .l + + ldmpc regs="r0,r4-r11" + +synth_full_even_sbsample: + stmdb sp!, {r0, r4-r11, lr} + ldr r4, [sp, #40] + mov r5, #15 + add r2, r2, #32 +.l2: + /* ;; PROD_O and odd half of SB_SAMPLE*/ + add r3, r3, #128 + add r4, r4, #128 + ldr r7, [r3, #0] + ldmia r1!, {r0, r10, r11, lr} + ldr r9, [r4, #60] + smull r6, r7, r0, r7 + ldr r12, [r3, #56] + smull r8, r9, r0, r9 + ldr r0, [r3, #48] + smlal r6, r7, r10, r12 + ldr r12, [r3, #40] + smlal r6, r7, r11, r0 + ldr r0, [r4, #68] + smlal r6, r7, lr, r12 + + ldr r12, [r4, #76] + smlal r8, r9, r10, r0 + ldr r0, [r4, #84] + smlal r8, r9, r11, r12 + smlal r8, r9, lr, r0 + + ldr r0, [r3, #32] + ldmia r1!, {r10, r11, r12, lr} + + smlal r6, r7, r10, r0 + ldr r0, [r4, #92] + smlal r8, r9, r10, r0 + ldr r0, [r3, #24] + ldr r10, [r3, #16] + smlal r6, r7, r11, r0 + ldr r0, [r3, #8] + smlal r6, r7, r12, r10 + ldr r10, [r4, #100] + smlal r6, r7, lr, r0 + ldr r0, [r4, #108] + smlal r8, r9, r11, r10 + ldr r10, [r4, #116] + smlal r8, r9, r12, r0 + smlal r8, r9, lr, r10 + + rsbs r6, r6, #0 + rsc r7, r7, #0 + + ldr r0, [r3, #4] + ldmia r2!, {r10, r11, r12, lr} + smlal r6, r7, r10, r0 + ldr r0, [r4, #120] /*;;1 cycle stall on arm9, but we free up r10*/ + smlal r8, r9, r10, r0 + ldr r0, [r3, #60] + ldr r10, [r3, #52] + smlal r6, r7, r11, r0 + ldr r0, [r3, #44] + smlal r6, r7, r12, r10 + ldr r10, [r4, #64] + smlal r6, r7, lr, r0 + + ldr r0, [r4, #72] + smlal r8, r9, r11, r10 + ldr r10, [r4, #80] + smlal r8, r9, r12, r0 + + smlal r8, r9, lr, r10 + + ldr r0, [r3, #36] + ldmia r2!, {r10, r11, r12, lr} + smlal r6, r7, r10, r0 + ldr r0, [r4, #88] /*;;1 cycle stall on arm9, but we free up r10*/ + smlal r8, r9, r10, r0 + + ldr r0, [r3, #28] + ldr r10, [r3, #20] + smlal r6, r7, r11, r0 + ldr r0, [r3, #12] + smlal r6, r7, r12, r10 + ldr r10, [r4, #96] + smlal r6, r7, lr, r0 + ldr r0, [r4, #104] + smlal r8, r9, r11, r10 + ldr r10, [r4, #112] + smlal r8, r9, r12, r0 + smlal r8, r9, lr, r10 + + ldr r0, [sp] + + movs r6, r6, lsr #16 + adc r6, r6, r7, lsl #16 + str r6, [r0, -r5, lsl #2] + + movs r8, r8, lsr #16 + adc r8, r8, r9, lsl #16 + str r8, [r0, r5, lsl #2] + + subs r5, r5, #1 + bne .l2 + + ldmpc regs="r0,r4-r11" + + .global III_aliasreduce + +III_aliasreduce: + stmdb sp!, {r4-r11, lr} + add r1, r0, r1, lsl #2 + add r0, r0, #72 +.arl1: + mov r2, #8 + mov r3, r0 @ a + mov r4, r0 @ b + ldr r5, =csa @ cs/ca +.arl2: + ldmdb r3, {r6, r12} + ldmia r4, {r7, lr} + + ldmia r5!, {r8, r9} + smull r10, r11, r7, r8 + smlal r10, r11, r12, r9 + movs r10, r10, lsr #28 + adc r10, r10, r11, lsl #4 + + rsb r7, r7, #0 + smull r11, r8, r12, r8 + smlal r11, r8, r7, r9 + movs r11, r11, lsr #28 + adc r11, r11, r8, lsl #4 + + ldmia r5!, {r8, r9} + smull r12, r7, lr, r8 + smlal r12, r7, r6, r9 + movs r12, r12, lsr #28 + adc r12, r12, r7, lsl #4 + stmia r4!, {r10, r12} + + rsb lr, lr, #0 + smull r7, r10, r6, r8 + smlal r7, r10, lr, r9 + movs r7, r7, lsr #28 + adc r7, r7, r10, lsl #4 + stmdb r3!, {r7, r11} + + subs r2, r2, #2 + bne .arl2 + add r0, r0, #72 + cmp r0, r1 + blo .arl1 + ldmpc regs=r4-r11 + +csa: + .word +0x0db84a81 + .word -0x083b5fe7 + .word +0x0e1b9d7f + .word -0x078c36d2 + .word +0x0f31adcf + .word -0x05039814 + .word +0x0fbba815 + .word -0x02e91dd1 + .word +0x0feda417 + .word -0x0183603a + .word +0x0ffc8fc8 + .word -0x00a7cb87 + .word +0x0fff964c + .word -0x003a2847 + .word +0x0ffff8d3 + .word -0x000f27b4 + + .global III_overlap +III_overlap: + stmdb sp!, {r4-r7, lr} + add r2, r2, r3, lsl #2 + mov r3, #6 +.ol: + ldmia r0!, {r4, r5, r6} + ldmia r1!, {r7, r12, lr} + add r4, r4, r7 + add r5, r5, r12 + add r6, r6, lr + str r4, [r2], #128 + str r5, [r2], #128 + str r6, [r2], #128 + subs r3, r3, #1 + bne .ol + sub r1, r1, #72 + ldmia r0!, {r4, r5, r6, r7, r12, lr} + stmia r1!, {r4, r5, r6, r7, r12, lr} + ldmia r0!, {r4, r5, r6, r7, r12, lr} + stmia r1!, {r4, r5, r6, r7, r12, lr} + ldmia r0!, {r4, r5, r6, r7, r12, lr} + stmia r1!, {r4, r5, r6, r7, r12, lr} + ldmpc regs=r4-r7 diff --git a/lib/rbcodec/codecs/libmusepack/AUTHORS b/lib/rbcodec/codecs/libmusepack/AUTHORS new file mode 100644 index 0000000000..1bcac63765 --- /dev/null +++ b/lib/rbcodec/codecs/libmusepack/AUTHORS @@ -0,0 +1,10 @@ +libmpcdec is the result of the work of many people: + +* Andree Buschmann and Frank Klemm + Original implementation and core development. + +* Peter Pawlowski and Benoit Amiaux + Portability and further optimizations. + +* Miles Egan + Port to pure C, documentation, and api refinements. diff --git a/lib/rbcodec/codecs/libmusepack/COPYING b/lib/rbcodec/codecs/libmusepack/COPYING new file mode 100644 index 0000000000..10190c014a --- /dev/null +++ b/lib/rbcodec/codecs/libmusepack/COPYING @@ -0,0 +1,31 @@ +Copyright (c) 2005, The Musepack Development Team +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + + * Neither the name of the The Musepack Development Team nor the + names of its contributors may be used to endorse or promote + products derived from this software without specific prior + written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/lib/rbcodec/codecs/libmusepack/ChangeLog b/lib/rbcodec/codecs/libmusepack/ChangeLog new file mode 100644 index 0000000000..6c998480bd --- /dev/null +++ b/lib/rbcodec/codecs/libmusepack/ChangeLog @@ -0,0 +1,40 @@ +1.3.0 + * first sv8 release + * major changes in the API (decoder and demuxer are split) + +1.2.3 + * Reduced memory usage and code size. Patch by Peter Pawlowski + +1.2.2 + * Fixed compilation under OpenBSD + * Unix EOF again + +1.2.1 + * Warnings cleanup, patch by Tomas Salfischberger, Thom Johansen and + Daniel Stenberg (Rockbox) + * Mplayer interface, patch by Reimar Doffinger + * Unix EOF everywhere + +1.2 + * 1.1.1 broke the API (BOOL type changed to mpc_bool_t). Version bumped to 1.2 to reflect the major change. Sorry to those who were caught by this error + * Fixed relative/absolute includes (#include "stuff.h" in /include/mpcdec, #include in src/) + * Added msvc project files + * Changed mpc_reader_t structure, any specific data of the reader's + implementations should be hidden behind the (void*) data pointer. (example + in default implementation mpc_reader_file) + * Renamed to libmpcdec (to make room for libmpcenc) + +1.1.1 + * fix for fixed-point mode bug + +1.1 + * add compliance & cleanup patches from Michael Roitzsch of xine project + * switch to BSD license + * port to pure C + * add doxygen documentation + * revise API somewhat + +1.0.3 + * autotools build process + * sample binary added + * floating-point mode by default diff --git a/lib/rbcodec/codecs/libmusepack/SOURCES b/lib/rbcodec/codecs/libmusepack/SOURCES new file mode 100644 index 0000000000..60d762afd2 --- /dev/null +++ b/lib/rbcodec/codecs/libmusepack/SOURCES @@ -0,0 +1,14 @@ +crc32.c +huffman.c +mpc_bits_reader.c +mpc_decoder.c +mpc_demux.c +requant.c +streaminfo.c +synth_filter.c +#if defined(CPU_ARM) +synth_filter_arm.S +#endif +#if defined(CPU_COLDFIRE) +synth_filter_coldfire.S +#endif diff --git a/lib/rbcodec/codecs/libmusepack/crc32.c b/lib/rbcodec/codecs/libmusepack/crc32.c new file mode 100644 index 0000000000..7613f1c2c8 --- /dev/null +++ b/lib/rbcodec/codecs/libmusepack/crc32.c @@ -0,0 +1,57 @@ +/* +* C Implementation: crc32 +* +* code from http://www.w3.org/TR/PNG/#D-CRCAppendix +* +*/ +#include "internal.h" + +/* Table of CRCs of all 8-bit messages. */ +static unsigned long crc_table[256]; + +/* Flag: has the table been computed? Initially false. */ +static int crc_table_computed = 0; + +/* Make the table for a fast CRC. */ +static void make_crc_table(void) +{ + unsigned long c; + int n, k; + + for (n = 0; n < 256; n++) { + c = (unsigned long) n; + for (k = 0; k < 8; k++) { + if (c & 1) + c = 0xedb88320L ^ (c >> 1); + else + c = c >> 1; + } + crc_table[n] = c; + } + crc_table_computed = 1; +} + + +/* Update a running CRC with the bytes buf[0..len-1]--the CRC + should be initialized to all 1's, and the transmitted value + is the 1's complement of the final running CRC (see the + crc() routine below). */ + +static unsigned long update_crc(unsigned long crc, unsigned char *buf, int len) +{ + unsigned long c = crc; + int n; + + if (!crc_table_computed) + make_crc_table(); + for (n = 0; n < len; n++) { + c = crc_table[(c ^ buf[n]) & 0xff] ^ (c >> 8); + } + return c; +} + +/* Return the CRC of the bytes buf[0..len-1]. */ +unsigned long mpc_crc32(unsigned char *buf, int len) +{ + return update_crc(0xffffffffL, buf, len) ^ 0xffffffffL; +} diff --git a/lib/rbcodec/codecs/libmusepack/decoder.h b/lib/rbcodec/codecs/libmusepack/decoder.h new file mode 100644 index 0000000000..1acacae8d9 --- /dev/null +++ b/lib/rbcodec/codecs/libmusepack/decoder.h @@ -0,0 +1,101 @@ +/* + Copyright (c) 2005-2009, The Musepack Development Team + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + + * Neither the name of the The Musepack Development Team nor the + names of its contributors may be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +/// \file decoder.h +#ifndef _MPCDEC_DECODER_H_ +#define _MPCDEC_DECODER_H_ +#ifdef WIN32 +#pragma once +#endif + +#include "reader.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define SEEKING_TABLE_SIZE 256u +// set it to SLOW_SEEKING_WINDOW to not use fast seeking +#define FAST_SEEKING_WINDOW 32 +// set it to FAST_SEEKING_WINDOW to only use fast seeking +#define SLOW_SEEKING_WINDOW 0x80000000 + +enum { + MPC_V_MEM = 2304, + MPC_DECODER_MEMSIZE = 16384, // overall buffer size +}; + +struct mpc_decoder_t { + /// @name internal state variables + //@{ + mpc_uint32_t stream_version; ///< Streamversion of stream + mpc_int32_t max_band; ///< Maximum band-index used in stream (0...31) + mpc_uint32_t ms; ///< Mid/side stereo (0: off, 1: on) + mpc_uint32_t channels; ///< Number of channels in stream + + mpc_uint64_t samples; ///< Number of samples in stream + + mpc_uint64_t decoded_samples; ///< Number of samples decoded from file begining + mpc_uint32_t samples_to_skip; ///< Number samples to skip (used for seeking) + mpc_int32_t last_max_band; ///< number of bands used in the last frame + + // randomizer state variables + mpc_uint32_t __r1; + mpc_uint32_t __r2; + + mpc_int32_t SCF_Index_L [32] [3]; + mpc_int32_t SCF_Index_R [32] [3]; // holds scalefactor-indices + mpc_quantizer Q [32]; // holds quantized samples + mpc_int32_t Res_L [32]; + mpc_int32_t Res_R [32]; // holds the chosen quantizer for each subband + mpc_bool_t DSCF_Flag_L [32]; + mpc_bool_t DSCF_Flag_R [32]; // differential SCF used? + mpc_int32_t SCFI_L [32]; + mpc_int32_t SCFI_R [32]; // describes order of transmitted SCF + mpc_bool_t MS_Flag[32]; // MS used? +#ifdef MPC_FIXED_POINT + mpc_uint8_t SCF_shift[256]; +#endif + + MPC_SAMPLE_FORMAT *V_L; + MPC_SAMPLE_FORMAT *V_R; + MPC_SAMPLE_FORMAT *Y_L; + MPC_SAMPLE_FORMAT *Y_R; + mpc_uint32_t SCF[256]; ///< holds adapted scalefactors (for clipping prevention) + //@} +}; + +#ifdef __cplusplus +} +#endif +#endif diff --git a/lib/rbcodec/codecs/libmusepack/huffman.c b/lib/rbcodec/codecs/libmusepack/huffman.c new file mode 100644 index 0000000000..c304775623 --- /dev/null +++ b/lib/rbcodec/codecs/libmusepack/huffman.c @@ -0,0 +1,530 @@ +/* + Copyright (c) 2005-2009, The Musepack Development Team + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + + * Neither the name of the The Musepack Development Team nor the + names of its contributors may be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +/// \file huffman.c +/// Implementations of sv7/sv8 huffman decoding functions. +#include "mpcdec.h" +#include "huffman.h" + + +// sv7 huffman tables +static const mpc_huffman mpc_table_HuffHdr [10] ICONST_ATTR = { + {0x8000, 1, 0}, {0x6000, 3, 1}, {0x5e00, 7,-4}, {0x5d80, 9, 3}, {0x5d00, 9, 4}, + {0x5c00, 8,-5}, {0x5800, 6, 2}, {0x5000, 5,-3}, {0x4000, 4,-2}, {0x0000, 2,-1} +}; + +const mpc_huffman mpc_table_HuffSCFI [4] ICONST_ATTR = { + {0x8000, 1, 1}, {0x6000, 3, 2}, {0x4000, 3, 0}, {0x0000, 2, 3} +}; + +static const mpc_huffman mpc_table_HuffDSCF [16] ICONST_ATTR = { + {0xf800, 5, 5}, {0xf000, 5,-4}, {0xe000, 4, 3}, {0xd000, 4,-3}, + {0xc000, 4, 8}, {0xa000, 3, 1}, {0x9000, 4, 0}, {0x8800, 5,-5}, + {0x8400, 6, 7}, {0x8000, 6,-7}, {0x6000, 3,-1}, {0x4000, 3, 2}, + {0x3000, 4, 4}, {0x2800, 5, 6}, {0x2000, 5,-6}, {0x0000, 3,-2} +}; + +static const mpc_huffman mpc_table_HuffQ1 [2] [27] ICONST_ATTR = { + { + {0xe000, 3, 13}, {0xdc00, 6, 26}, {0xd800, 6, 0}, + {0xd400, 6, 20}, {0xd000, 6, 6}, {0xc000, 4, 14}, + {0xb000, 4, 12}, {0xa000, 4, 4}, {0x9000, 4, 22}, + {0x8c00, 6, 8}, {0x8800, 6, 18}, {0x8400, 6, 24}, + {0x8000, 6, 2}, {0x7000, 4, 16}, {0x6000, 4, 10}, + {0x5800, 5, 17}, {0x5000, 5, 9}, {0x4800, 5, 1}, + {0x4000, 5, 25}, {0x3800, 5, 5}, {0x3000, 5, 21}, + {0x2800, 5, 3}, {0x2000, 5, 11}, {0x1800, 5, 15}, + {0x1000, 5, 23}, {0x0800, 5, 19}, {0x0000, 5, 7} + }, { + {0x8000, 1, 13}, {0x7e00, 7, 15}, {0x7c00, 7, 1}, + {0x7a00, 7, 11}, {0x7800, 7, 7}, {0x7600, 7, 17}, + {0x7400, 7, 25}, {0x7200, 7, 19}, {0x7180, 9, 8}, + {0x7100, 9, 18}, {0x7080, 9, 2}, {0x7000, 9, 24}, + {0x6e00, 7, 3}, {0x6c00, 7, 23}, {0x6a00, 7, 21}, + {0x6800, 7, 5}, {0x6700, 8, 0}, {0x6600, 8, 26}, + {0x6500, 8, 6}, {0x6400, 8, 20}, {0x6000, 6, 9}, + {0x5000, 4, 14}, {0x4000, 4, 12}, {0x3000, 4, 4}, + {0x2000, 4, 22}, {0x1000, 4, 16}, {0x0000, 4, 10} + } +}; + +static const mpc_huffman mpc_table_HuffQ2 [2] [25] ICONST_ATTR = { + { + {0xf000, 4, 13}, {0xe000, 4, 17}, {0xd000, 4, 7}, {0xc000, 4, 11}, {0xbc00, 6, 1}, + {0xb800, 6, 23}, {0xb600, 7, 4}, {0xb400, 7, 20}, {0xb200, 7, 0}, {0xb000, 7, 24}, + {0xa800, 5, 22}, {0xa000, 5, 10}, {0x8000, 3, 12}, {0x7800, 5, 2}, {0x7000, 5, 14}, + {0x6000, 4, 6}, {0x5000, 4, 18}, {0x4000, 4, 8}, {0x3000, 4, 16}, {0x2800, 5, 9}, + {0x2000, 5, 5}, {0x1800, 5, 15}, {0x1000, 5, 21}, {0x0800, 5, 19}, {0x0000, 5, 3} + }, { + {0xf800, 5, 18}, {0xf000, 5, 6}, {0xe800, 5, 8}, {0xe700, 8, 3}, {0xe6c0,10, 24}, + {0xe680,10, 4}, {0xe640,10, 0}, {0xe600,10, 20}, {0xe400, 7, 23}, {0xe200, 7, 1}, + {0xe000, 7, 19}, {0xd800, 5, 16}, {0xd600, 7, 15}, {0xd400, 7, 21}, {0xd200, 7, 9}, + {0xd000, 7, 5}, {0xcc00, 6, 2}, {0xc800, 6, 10}, {0xc400, 6, 14}, {0xc000, 6, 22}, + {0x8000, 2, 12}, {0x6000, 3, 13}, {0x4000, 3, 17}, {0x2000, 3, 11}, {0x0000, 3, 7} + } +}; + +static const mpc_huffman mpc_table_HuffQ3 [2] [7] ICONST_ATTR = { + { + {0xe000, 3, 1}, {0xd000, 4, 3}, {0xc000, 4,-3}, {0xa000, 3, 2}, + {0x8000, 3,-2}, {0x4000, 2, 0}, {0x0000, 2,-1} + }, { + {0xc000, 2, 0}, {0x8000, 2,-1}, {0x4000, 2, 1}, {0x3000, 4,-2}, + {0x2800, 5, 3}, {0x2000, 5,-3}, {0x0000, 3, 2} + } +}; + +static const mpc_huffman mpc_table_HuffQ4 [2] [9] ICONST_ATTR = { + { + {0xe000, 3, 0}, {0xc000, 3,-1}, {0xa000, 3, 1}, + {0x8000, 3,-2}, {0x6000, 3, 2}, {0x5000, 4,-4}, + {0x4000, 4, 4}, {0x2000, 3, 3}, {0x0000, 3,-3} + }, { + {0xe000, 3, 1}, {0xd000, 4, 2}, {0xc000, 4,-3}, + {0x8000, 2, 0}, {0x6000, 3,-2}, {0x5000, 4, 3}, + {0x4800, 5,-4}, {0x4000, 5, 4}, {0x0000, 2,-1} + } +}; + +static const mpc_huffman mpc_table_HuffQ5 [2] [15] ICONST_ATTR = { + { + {0xf000, 4, 2}, {0xe800, 5, 5}, {0xe400, 6,-7}, {0xe000, 6, 7}, {0xd000, 4,-3}, + {0xc000, 4, 3}, {0xb800, 5,-6}, {0xb000, 5, 6}, {0xa000, 4,-4}, {0x9000, 4, 4}, + {0x8000, 4,-5}, {0x6000, 3, 0}, {0x4000, 3,-1}, {0x2000, 3, 1}, {0x0000, 3,-2} + }, { + {0xf000, 4, 3}, {0xe800, 5, 4}, {0xe600, 7, 6}, {0xe500, 8,-7}, {0xe400, 8, 7}, + {0xe000, 6,-6}, {0xc000, 3, 0}, {0xa000, 3,-1}, {0x8000, 3, 1}, {0x6000, 3,-2}, + {0x4000, 3, 2}, {0x3800, 5,-5}, {0x3000, 5, 5}, {0x2000, 4,-4}, {0x0000, 3,-3} + } +}; + +static const mpc_huffman mpc_table_HuffQ6 [2] [31] ICONST_ATTR = { + { + {0xf800, 5, 3}, {0xf000, 5, -4}, {0xec00, 6,-11}, {0xe800, 6, 12}, {0xe000, 5, 4}, + {0xd800, 5, 6}, {0xd000, 5, -5}, {0xc800, 5, 5}, {0xc000, 5, 7}, {0xb800, 5, -7}, + {0xb400, 6,-12}, {0xb000, 6,-13}, {0xa800, 5, -6}, {0xa000, 5, 8}, {0x9800, 5, -8}, + {0x9000, 5, 9}, {0x8800, 5, -9}, {0x8400, 6, 13}, {0x8200, 7,-15}, {0x8000, 7, 15}, + {0x7000, 4, 0}, {0x6800, 5,-10}, {0x6000, 5, 10}, {0x5000, 4, -1}, {0x4000, 4, 2}, + {0x3000, 4, 1}, {0x2000, 4, -2}, {0x1c00, 6, 14}, {0x1800, 6,-14}, {0x1000, 5, 11}, + {0x0000, 4, -3} + }, { + {0xf800, 5, -6}, {0xf000, 5, 6}, {0xe000, 4, 1}, {0xd000, 4, -1}, {0xce00, 7, 10}, + {0xcc00, 7,-10}, {0xcb00, 8,-11}, {0xca80, 9,-12}, {0xca60,11, 13}, {0xca58,13, 15}, + {0xca50,13,-14}, {0xca48,13, 14}, {0xca40,13,-15}, {0xca00,10,-13}, {0xc900, 8, 11}, + {0xc800, 8, 12}, {0xc400, 6, -9}, {0xc000, 6, 9}, {0xb000, 4, -2}, {0xa000, 4, 2}, + {0x9000, 4, 3}, {0x8000, 4, -3}, {0x7800, 5, -7}, {0x7000, 5, 7}, {0x6000, 4, -4}, + {0x5000, 4, 4}, {0x4800, 5, -8}, {0x4000, 5, 8}, {0x3000, 4, 5}, {0x2000, 4, -5}, + {0x0000, 3, 0} + } +}; + +static const mpc_huffman mpc_table_HuffQ7 [2] [63] ICONST_ATTR = { + { + {0xfc00, 6, 7}, {0xf800, 6, 8}, {0xf400, 6, 9}, {0xf000, 6, -8}, {0xec00, 6, 11}, + {0xea00, 7, 21}, {0xe900, 8,-28}, {0xe800, 8, 28}, {0xe400, 6, -9}, {0xe200, 7,-22}, + {0xe000, 7,-21}, {0xdc00, 6,-10}, {0xd800, 6,-11}, {0xd400, 6, 10}, {0xd000, 6, 12}, + {0xcc00, 6,-13}, {0xca00, 7, 22}, {0xc800, 7, 23}, {0xc400, 6,-12}, {0xc000, 6, 13}, + {0xbc00, 6, 14}, {0xb800, 6,-14}, {0xb600, 7,-23}, {0xb500, 8,-29}, {0xb400, 8, 29}, + {0xb000, 6,-15}, {0xac00, 6, 15}, {0xa800, 6, 16}, {0xa400, 6,-16}, {0xa200, 7,-24}, + {0xa000, 7, 24}, {0x9c00, 6, 17}, {0x9a00, 7,-25}, {0x9900, 8,-30}, {0x9800, 8, 30}, + {0x9400, 6,-17}, {0x9000, 6, 18}, {0x8c00, 6,-18}, {0x8a00, 7, 25}, {0x8800, 7, 26}, + {0x8400, 6, 19}, {0x8200, 7,-26}, {0x8000, 7,-27}, {0x7800, 5, 2}, {0x7400, 6,-19}, + {0x7000, 6, 20}, {0x6800, 5, -1}, {0x6700, 8,-31}, {0x6600, 8, 31}, {0x6400, 7, 27}, + {0x6000, 6,-20}, {0x5800, 5, 1}, {0x5000, 5, -5}, {0x4800, 5, -3}, {0x4000, 5, 3}, + {0x3800, 5, 0}, {0x3000, 5, -2}, {0x2800, 5, -4}, {0x2000, 5, 4}, {0x1800, 5, 5}, + {0x1000, 5, -6}, {0x0800, 5, 6}, {0x0000, 5, -7} + }, { + {0xf800, 5, -1}, {0xf000, 5, 2}, {0xe800, 5, -2}, {0xe000, 5, 3}, {0xdf00, 8,-20}, + {0xdec0,10, 24}, {0xdebc,14, 28}, {0xdeb8,14,-28}, {0xdeb4,14,-30}, {0xdeb0,14, 30}, + {0xdea0,12,-27}, {0xde9c,14, 29}, {0xde98,14,-29}, {0xde94,14, 31}, {0xde90,14,-31}, + {0xde80,12, 27}, {0xde00, 9,-22}, {0xdc00, 7,-17}, {0xd800, 6,-11}, {0xd000, 5, -3}, + {0xc800, 5, 4}, {0xc000, 5, -4}, {0xbe00, 7, 17}, {0xbd00, 8, 20}, {0xbc80, 9, 22}, + {0xbc40,10,-25}, {0xbc00,10,-26}, {0xb800, 6, 12}, {0xb000, 5, 5}, {0xa800, 5, -5}, + {0xa000, 5, 6}, {0x9800, 5, -6}, {0x9400, 6,-12}, {0x9200, 7,-18}, {0x9000, 7, 18}, + {0x8c00, 6, 13}, {0x8800, 6,-13}, {0x8000, 5, -7}, {0x7c00, 6, 14}, {0x7b00, 8, 21}, + {0x7a00, 8,-21}, {0x7800, 7,-19}, {0x7000, 5, 7}, {0x6800, 5, 8}, {0x6400, 6,-14}, + {0x6000, 6,-15}, {0x5800, 5, -8}, {0x5400, 6, 15}, {0x5200, 7, 19}, {0x51c0,10, 25}, + {0x5180,10, 26}, {0x5100, 9,-23}, {0x5080, 9, 23}, {0x5000, 9,-24}, {0x4800, 5,-9}, + {0x4000, 5, 9}, {0x3c00, 6, 16}, {0x3800, 6,-16}, {0x3000, 5, 10}, {0x2000, 4, 0}, + {0x1800, 5,-10}, {0x1000, 5, 11}, {0x0000, 4, 1} + } +}; + +// sv8 huffman tables +static const mpc_huffman mpc_huff_SCFI_1 [3] ICONST_ATTR = { + {0x8000, 1, 1}, {0x4000, 2, 2}, {0x0, 3, 3} +}; // 3 +static const mpc_int8_t mpc_sym_SCFI_1 [4] ICONST_ATTR = { + 2, 3, 1, 0 +}; +static const mpc_huffman mpc_huff_SCFI_2 [5] ICONST_ATTR = { + {0x8000, 2, 3}, {0x4000, 3, 5}, {0x1800, 5, 11}, {0x400, 6, 14}, {0x0, 7, 15} +}; // 5 +static const mpc_int8_t mpc_sym_SCFI_2 [16] ICONST_ATTR = { + 15, 10, 14, 11, 13, 9, 7, 6, 5, 12, 8, 3, 2, 0, 4, 1 +}; + +static const mpc_huffman mpc_huff_DSCF_1 [12] ICONST_ATTR = { + {0xa000, 3, 7}, {0x4000, 4, 12}, {0x2800, 5, 16}, {0x1800, 6, 21}, + {0x0e00, 7, 27}, {0x0700, 8, 34}, {0x0380, 9, 41}, {0x0140, 10, 48}, + {0x0080, 11, 53}, {0x0030, 12, 57}, {0x0018, 13, 60}, {0x0000, 14, 63} +}; // 12 +static const mpc_int8_t mpc_sym_DSCF_1 [64] ICONST_ATTR = { + 35, 34, 33, 36, 32, 30, 29, 27, 26, 37, 28, 25, 39, 38, 24, 23, + 40, 22, 21, 20, 19, 43, 42, 41, 18, 17, 16, 15, 46, 45, 44, 14, + 13, 12, 11, 49, 48, 47, 31, 10, 9, 8, 7, 6, 52, 51, 50, 5, + 4, 3, 54, 53, 2, 1, 0, 57, 56, 55, 63, 62, 61, 60, 59, 58 +}; +static const mpc_huffman mpc_huff_DSCF_2 [13] ICONST_ATTR = { + {0x6000, 3, 7}, {0x3000, 4, 10}, {0x1800, 5, 13}, {0x1000, 6, 16}, + {0x0a00, 7, 20}, {0x0600, 8, 25}, {0x0380, 9, 31}, {0x01c0, 10, 38}, + {0x00e0, 11, 45}, {0x0050, 12, 52}, {0x0020, 13, 57}, {0x000c, 14, 61}, + {0x0000, 15, 64} +}; // 13 +static const mpc_int8_t mpc_sym_DSCF_2 [65] ICONST_ATTR = { + 33, 32, 31, 30, 29, 34, 28, 27, 36, 35, 26, 37, 25, 38, 24, 23, + 40, 39, 22, 21, 42, 41, 20, 19, 18, 45, 44, 43, 17, 16, 15, 14, + 48, 47, 46, 13, 12, 11, 10, 64, 52, 51, 50, 49, 9, 8, 7, 6, + 55, 54, 53, 5, 4, 3, 58, 57, 56, 2, 1, 63, 62, 61, 60, 59, + 0 +}; + +static const mpc_huffman mpc_huff_Bands [12] ICONST_ATTR = { + {0x8000, 1, 1}, {0x4000, 2, 2}, {0x2000, 3, 3}, {0x1000, 5, 6}, + {0x0800, 6, 8}, {0x0600, 7, 10}, {0x0300, 8, 13}, {0x0200, 9, 16}, + {0x0140, 10, 20}, {0x00c0, 11, 25}, {0x0010, 12, 31}, {0x0000, 13, 32} +}; // 12 +static const mpc_int8_t mpc_sym_Bands [33] ICONST_ATTR = { + 0, 32, 1, 31, 2, 30, 3, 4, 29, 6, 5, 28, 7, 27, 26, 8, + 25, 24, 23, 9, 22, 21, 20, 18, 17, 16, 15, 14, 12, 11, 10, 19, + 13 +}; + +static const mpc_huffman mpc_huff_Res_1 [16] ICONST_ATTR = { + {0x8000, 1, 1}, {0x4000, 2, 2}, {0x2000, 3, 3}, {0x1000, 4, 4}, + {0x0800, 5, 5}, {0x0400, 6, 6}, {0x0200, 7, 7}, {0x0100, 8, 8}, + {0x0080, 9, 9}, {0x0040, 10, 10}, {0x0020, 11, 11}, {0x0010, 12, 12}, + {0x0008, 13, 13}, {0x0004, 14, 14}, {0x0002, 15, 15}, {0x0000, 16, 16} +}; // 16 +static const mpc_int8_t mpc_sym_Res_1 [17] ICONST_ATTR = { + 0, 1, 16, 2, 3, 4, 5, 15, 6, 7, 8, 9, 10, 11, 12, 14, 13 +}; +static const mpc_huffman mpc_huff_Res_2 [12] ICONST_ATTR = { + {0x4000, 2, 3}, {0x2000, 3, 4}, {0x1000, 4, 5}, {0x0800, 5, 6}, + {0x0400, 6, 7}, {0x0200, 7, 8}, {0x0100, 8, 9}, {0x0080, 9, 10}, + {0x0040, 10, 11}, {0x0020, 11, 12}, {0x0010, 12, 13}, {0x0000, 14, 16} +}; // 12 +static const mpc_int8_t mpc_sym_Res_2 [17] ICONST_ATTR = { + 16, 1, 0, 2, 15, 3, 14, 4, 5, 13, 6, 12, 7, 11, 10, 9, 8 +}; + +static const mpc_huffman mpc_huff_Q1 [10] ICONST_ATTR = { + {0x6000, 3, 7}, {0x1000, 4, 10}, {0x0800, 5, 11}, {0x0400, 6, 12}, + {0x0200, 7, 13}, {0x0100, 8, 14}, {0x0080, 9, 15}, {0x0040, 10, 16}, + {0x0020, 11, 17}, {0x0000, 12, 18} +}; // 10 +static const mpc_int8_t mpc_sym_Q1 [19] ICONST_ATTR = { + 7, 6, 5, 4, 3, 10, 9, 8, 2, 1, 11, 0, 12, 13, 14, 15, 16, 18, 17 +}; + +static const mpc_huffman mpc_huff_Q2_1 [10] ICONST_ATTR = { + {0xe000, 3, 7}, {0x8000, 4, 14}, {0x3c00, 6, 38}, {0x2a00, 7, 53}, + {0x1200, 8, 74}, {0x0600, 9, 92}, {0x03c0, 10,104}, {0x0060, 11,119}, + {0x0020, 12,122}, {0x0000, 13,124} +}; // 10 +static const mpc_int8_t mpc_sym_Q2_1 [125] ICONST_ATTR = { + 62, 87, 67, 63, 61, 57, 37, 93, 92, 88, 86, 83, 82, 81, 68, 66, 58, 56, 42, 41, 38, 36, 32, 31,112, + 91, 72, 64, 60, 52, 43, 33, 12,117,113,111,107, 97, 89, 85, 77, 73, 71, 69, 65, 59, 55, 53, 51, 47, + 39, 35, 27, 17, 13, 11, 7,118,116,108,106, 98, 96, 94, 90, 84, 80, 78, 76, 48, 46, 44, 40, 34, 30, + 28, 26, 18, 16, 8, 6,122,110,102, 74, 70, 54, 50, 22, 2,123,121,119,115,114,109,105,103,101, 99, + 95, 79, 75, 49, 45, 29, 25, 23, 21, 19, 15, 14, 10, 9, 5, 3, 1,124,104, 20, 0,120,100, 24, 4 +}; +static const mpc_huffman mpc_huff_Q2_2 [9] ICONST_ATTR = { + {0xf000, 4, 15}, {0x7000, 5, 30}, {0x4800, 6, 44}, + {0x3c00, 7, 62}, {0x0c00, 8, 92}, {0x0780, 9,104}, + {0x00c0, 10,119}, {0x0040, 11,122}, {0x0000, 12,124} +}; // 9 +static const mpc_int8_t mpc_sym_Q2_2 [125] ICONST_ATTR = { + 62, 92, 87, 86, 82, 68, 67, 66, 63, 61, 58, 57, 56, 42, 38, 37, 32, 93, 91, 88, 83, 81, 43, 41, 36, + 33, 31,112, 72, 64, 60, 52, 12,118,117,116,113,111,108,107,106, 98, 97, 96, 94, 90, 89, 85, 84, 80, + 78, 77, 76, 73, 71, 69, 65, 59, 55, 53, 51, 48, 47, 46, 44, 40, 39, 35, 34, 30, 28, 27, 26, 18, 17, + 16, 13, 11, 8, 7, 6,122,110, 74, 70, 54, 50, 22, 14, 2,123,121,119,115,114,109,105,103,102,101, + 99, 95, 79, 75, 49, 45, 29, 25, 23, 21, 19, 15, 10, 9, 5, 3, 1,124,104, 20, 0,120,100, 24, 4 +}; + +static const mpc_huffman mpc_huff_Q3 [7] ICONST_ATTR = { + {0xe000, 3, 7}, {0x8000, 4, 14}, {0x5000, 5, 22}, {0x2400, 6, 32}, + {0x0a00, 7, 41}, {0x0200, 8, 46}, {0x0000, 9, 48} +}; // 7 +static const mpc_int8_t mpc_sym_Q3 [49] ICONST_ATTR = { + 0, 17, 16, 1, 15,-16, -1, + 32, 31, 2, 14,-15,-32, 34, + 33, 47, 46, 18, 30,-14, -2, + -31,-17,-18, 49, 48, 63, 19, + 29, 3, 13,-13, -3,-30,-47, + -48,-33, 50, 62, 35, 45,-29, + -19,-46,-34, 51, 61,-45,-35 +}; + +static const mpc_huffman mpc_huff_Q4 [8] ICONST_ATTR = { + {0xf000, 4, 15}, {0x9000, 5, 30}, {0x3400, 6, 48}, {0x1800, 7, 61}, + {0x0500, 8, 73}, {0x0100, 9, 78}, {0x0000, 10, 80}, {0x0000, 0, 90} +}; // 8 +static const mpc_int8_t mpc_sym_Q4 [91] ICONST_ATTR = { + 0, 32, 17, 16, 31, 2, 1, 15, 14,-15,-16, -1,-32, 49, 48, + 34, 33, 47, 46, 19, 18, 30, 29, 3, 13,-13,-14, -2, -3,-30, + -31,-17,-18,-47,-48,-33, 64, 50, 63, 62, 35, 45, 4, 12,-29, + -19,-46,-34,-64,-49, 66, 65, 79, 78, 51, 61, 36, 44, 20, 28, + -12, -4,-28,-20,-45,-35,-62,-63,-50, 67, 77, 52, 60,-44,-36, + -61,-51, 68, 76,-60,-52, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0 +}; + +static const mpc_huffman mpc_huff_Q5_1 [6] ICONST_ATTR = { + {0xc000, 2, 3}, {0x4000, 3, 6}, {0x2000, 4, 8}, + {0x1000, 5, 10}, {0x0800, 6, 12}, {0x0000, 7, 14} +}; // 6 +static const mpc_int8_t mpc_sym_Q5_1 [15] ICONST_ATTR = { + 0, 2, 1, -1, -2, 3, -3, 4, -4, 5, -5, 7, 6, -6, -7 +}; +static const mpc_huffman mpc_huff_Q5_2 [4] ICONST_ATTR = { + {0x6000, 3, 7}, {0x2000, 4, 10}, {0x1000, 5, 12}, {0x0, 6, 14} +}; // 4 +static const mpc_int8_t mpc_sym_Q5_2 [15] ICONST_ATTR = { + 2, 1, 0, -1, -2, 4, 3, -3, -4, 5, -5, 7, 6, -6, -7 +}; + +static const mpc_huffman mpc_huff_Q6_1 [8] ICONST_ATTR = { + {0xc000, 2, 3}, {0x8000, 3, 6}, {0x4000, 4, 10}, {0x2800, 5, 14}, + {0x0c00, 6, 19}, {0x0800, 7, 22}, {0x0400, 8, 26}, {0x0000, 9, 30} +}; // 8 +static const mpc_int8_t mpc_sym_Q6_1 [31] ICONST_ATTR = { + 0, 1, -1, 3, 2, -2, -3, 4, -4, -5, 8, 7, 6, 5, -6, + -7, -8, 9, -9, 11, 10,-10,-11, 15, 14, 13, 12,-12,-13,-14, + -15 +}; +static const mpc_huffman mpc_huff_Q6_2 [5] ICONST_ATTR = { + {0x5000, 4, 15}, {0x2000, 5, 20}, {0x1000, 6, 24}, {0x400, 7, 28}, {0x0, 8, 30} +}; // 5 +static const mpc_int8_t mpc_sym_Q6_2 [31] ICONST_ATTR = { + 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, 8, 7, 6, -6, + -7, -8, 10, 9, -9,-10, 13, 12, 11,-11,-12,-13, 15, 14,-14, + -15 +}; + +static const mpc_huffman mpc_huff_Q7_1 [9] ICONST_ATTR_MPC_LARGE_IRAM = { + {0xc000, 2, 3}, {0x8000, 3, 6}, {0x6000, 4, 10}, + {0x4000, 5, 16}, {0x2800, 6, 24}, {0x1400, 7, 34}, + {0x0a00, 8, 44}, {0x0400, 9, 54}, {0x0000, 10, 62} +}; // 9 +static const mpc_int8_t mpc_sym_Q7_1 [63] ICONST_ATTR_MPC_LARGE_IRAM = { + 0, 1, -1, 2, -2, 4, 3, -3, -4, 7, 6, 5, -5, -6, -7, + 13, 11, 10, 9, 8, -8, -9,-10,-11,-12, 17, 16, 15, 14, 12, + -13,-14,-15,-16,-17, 28, 27, 21, 20, 19, 18,-18,-19,-20,-21, + -27,-28, 31, 30, 29, 26, 25, 24, 23, 22,-22,-23,-24,-25,-26, + -29,-30,-31 +}; +static const mpc_huffman mpc_huff_Q7_2 [5] ICONST_ATTR_MPC_LARGE_IRAM = { + {0x6000, 5, 31}, {0x2400, 6, 43}, {0x1000, 7, 52}, {0x200, 8, 60}, {0x0, 9, 62} +}; // 5 +static const mpc_int8_t mpc_sym_Q7_2 [63] ICONST_ATTR_MPC_LARGE_IRAM = { + 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, + -5, -6, -7, -8, -9, 17, 16, 15, 14, 13, 12, 11,-10,-11,-12, + -13,-14,-15,-16,-17, 22, 21, 20, 19, 18,-18,-19,-20,-21,-22, + 29, 28, 27, 26, 25, 24, 23,-23,-24,-25,-26,-27,-28,-29, 31, + 30,-30,-31 +}; + +static const mpc_huffman mpc_huff_Q8_1 [11] ICONST_ATTR_MPC_LARGE_IRAM = { + {0xc000, 2, 3}, {0x8000, 3, 6}, {0x7000, 4, 10}, {0x5800, 5, 17}, + {0x3800, 6, 28}, {0x2800, 7, 42}, {0x1900, 8, 62}, {0x0d00, 9, 87}, + {0x0280, 10,113}, {0x0060, 11,123}, {0x0000, 12,126} +}; // 11 +static const mpc_int8_t mpc_sym_Q8_1 [127] ICONST_ATTR_MPC_LARGE_IRAM = { + 0, 1, -1, -2, 3, 2, -3, 7, 6, 5, 4, -4, -5, -6, -7, 11, 10, 9, 8, -8, + -9,-10,-11, 19, 18, 17, 16, 15, 14, 13, 12,-12,-13,-14,-15,-16,-17,-19, 56, 55, + 31, 28, 27, 26, 25, 24, 23, 22, 21, 20,-18,-20,-21,-22,-23,-24,-25,-26,-27,-33, + -54,-56, 63, 62, 61, 60, 59, 58, 57, 54, 53, 43, 40, 39, 38, 37, 36, 35, 34, 33, + 32, 30, 29,-28,-29,-30,-31,-32,-34,-35,-36,-37,-38,-39,-40,-41,-43,-53,-55,-57, + -58,-59,-60,-61, 49, 47, 46, 45, 44, 42, 41,-42,-44,-45,-46,-47,-48,-49,-50,-62, + -63, 52, 51, 50, 48,-51,-52 +}; +static const mpc_huffman mpc_huff_Q8_2 [4] ICONST_ATTR_MPC_LARGE_IRAM = { + {0x9800, 6, 63}, {0x2a00, 7, 101}, {0x400, 8, 122}, {0x0, 9, 126} +}; // 4 +static const mpc_int8_t mpc_sym_Q8_2 [127] ICONST_ATTR_MPC_LARGE_IRAM = { + 13, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, + -8, -9,-10,-11,-12,-13, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, + 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 12,-14,-15,-16,-17,-18,-19,-20, + -21,-22,-23,-24,-25,-26,-27,-28,-29,-30,-31,-32,-33,-34,-35,-36,-37,-38,-39,-40, + -41, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, + 40,-42,-43,-44,-45,-46,-47,-48,-49,-50,-51,-52,-53,-54,-55,-56,-57,-58,-59, 63, + 62, 61, 60,-60,-61,-62,-63 +}; + +static const mpc_huffman mpc_huff_Q9up [6] ICONST_ATTR_MPC_LARGE_IRAM = { + {0xf800, 6, 63}, {0xac00, 7,125}, {0x2600, 8, -45}, + {0x0280, 9, -7}, {0x0040, 10, -2}, {0x0000, 11, -1} +}; // 6 +static const mpc_int8_t mpc_sym_Q9up [256] ICONST_ATTR_MPC_LARGE_IRAM = { + -128, 127,-108,-110,-111,-112,-113,-114,-115,-116,-117,-118,-119,-120,-121,-122, + -123,-124,-125,-126,-127, 126, 125, 124, 123, 122, 121, 120, 119, 118, 117, 116, + 115, 114, 113, 112, 111, 110, 109, 108, -44, -45, -46, -47, -48, -49, -50, -51, + -52, -53, -54, -55, -56, -57, -58, -59, -60, -61, -62, -63, -64, -65, -66, -67, + -68, -69, -70, -71, -72, -73, -74, -75, -76, -77, -78, -79, -80, -81, -82, -83, + -84, -85, -86, -87, -88, -89, -90, -91, -92, -93, -94, -95, -96, -97, -98, -99, + -100,-101,-102,-103,-104,-105,-106,-107,-109, 107, 106, 105, 104, 103, 102, 101, + 100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, + 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, + 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, + 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 40, 20, 19, -7, -8, + -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -20, -21, -22, -23, -24, + -25, -26, -27, -28, -29, -30, -31, -32, -33, -34, -35, -36, -37, -38, -39, -40, + -41, -42, -43, 41, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, + 27, 26, 25, 24, 23, 22, 21, 18, 17, 16, 15, 14, 13, 12, 11, 10, + 9, 8, 7, 6, 5, -3, -4, -5, -6, 4, 3, 2, 1, 0, -1, -2 +}; + +/* sv7 lookup tables */ +mpc_lut_data mpc_HuffHdr IBSS_ATTR_MPC_LARGE_IRAM; +mpc_lut_data mpc_HuffDSCF IBSS_ATTR_MPC_LARGE_IRAM; +mpc_lut_data mpc_HuffQ [7] [2] IBSS_ATTR_MPC_LARGE_IRAM; + +/* sv8 lookup tables */ +mpc_can_data mpc_can_SCFI[2] IBSS_ATTR_MPC_LARGE_IRAM; +mpc_can_data mpc_can_DSCF[2] IBSS_ATTR_MPC_LARGE_IRAM; +mpc_can_data mpc_can_Bands IBSS_ATTR_MPC_LARGE_IRAM; +mpc_can_data mpc_can_Res[2] IBSS_ATTR_MPC_LARGE_IRAM; +mpc_can_data mpc_can_Q1 IBSS_ATTR_MPC_LARGE_IRAM; +mpc_can_data mpc_can_Q9up IBSS_ATTR_MPC_LARGE_IRAM; +mpc_can_data mpc_can_Q [6][2] IBSS_ATTR_MPC_LARGE_IRAM; + +static void huff_fill_lut(const mpc_huffman *table, mpc_huff_lut *lut, const int bits) +{ + int i, idx = 0; + const int shift = 16 - bits; + for (i = (1 << bits) - 1; i >= 0 ; i--) { + if ((table[idx].Code >> shift) < i) { + lut[i].Length = table[idx].Length; + lut[i].Value = table[idx].Value; + } else { + if (table[idx].Length <= bits) { + lut[i].Length = table[idx].Length; + lut[i].Value = table[idx].Value; + } else { + lut[i].Length = 0; + lut[i].Value = idx; + } + if (i != 0) + do { + idx++; + } while ((table[idx].Code >> shift) == i); + } + } +} + +static void can_fill_lut(mpc_can_data * data, const int bits) +{ + int i, idx = 0; + const int shift = 16 - bits; + const mpc_huffman * table = data->table; + const mpc_int8_t * sym = data->sym; + mpc_huff_lut * lut = data->lut; + for (i = (1 << bits) - 1; i >= 0 ; i--) { + if ((table[idx].Code >> shift) < i) { + if (table[idx].Length <= bits) { + lut[i].Length = table[idx].Length; + lut[i].Value = sym[(table[idx].Value - (i >> (bits - table[idx].Length))) & 0xFF]; + } else { + lut[i].Length = 0; + lut[i].Value = idx; + } + } else { + if (table[idx].Length <= bits) { + lut[i].Length = table[idx].Length; + lut[i].Value = sym[(table[idx].Value - (i >> (bits - table[idx].Length))) & 0xFF]; + } else { + lut[i].Length = 0; + lut[i].Value = idx; + } + if (i != 0) + do { + idx++; + } while ((table[idx].Code >> shift) == i); + } + } +} + +void huff_init_lut(const int bits) +{ + /* sv7: create vlc lookup tables */ + mpc_HuffDSCF.table = mpc_table_HuffDSCF ; huff_fill_lut(mpc_HuffDSCF.table , mpc_HuffDSCF.lut , bits); + mpc_HuffHdr.table = mpc_table_HuffHdr ; huff_fill_lut(mpc_HuffHdr.table , mpc_HuffHdr.lut , bits); + mpc_HuffQ[0][0].table = mpc_table_HuffQ1[0]; huff_fill_lut(mpc_HuffQ[0][0].table, mpc_HuffQ[0][0].lut, bits); + mpc_HuffQ[0][1].table = mpc_table_HuffQ1[1]; huff_fill_lut(mpc_HuffQ[0][1].table, mpc_HuffQ[0][1].lut, bits); + mpc_HuffQ[1][0].table = mpc_table_HuffQ2[0]; huff_fill_lut(mpc_HuffQ[1][0].table, mpc_HuffQ[1][0].lut, bits); + mpc_HuffQ[1][1].table = mpc_table_HuffQ2[1]; huff_fill_lut(mpc_HuffQ[1][1].table, mpc_HuffQ[1][1].lut, bits); + mpc_HuffQ[2][0].table = mpc_table_HuffQ3[0]; huff_fill_lut(mpc_HuffQ[2][0].table, mpc_HuffQ[2][0].lut, bits); + mpc_HuffQ[2][1].table = mpc_table_HuffQ3[1]; huff_fill_lut(mpc_HuffQ[2][1].table, mpc_HuffQ[2][1].lut, bits); + mpc_HuffQ[3][0].table = mpc_table_HuffQ4[0]; huff_fill_lut(mpc_HuffQ[3][0].table, mpc_HuffQ[3][0].lut, bits); + mpc_HuffQ[3][1].table = mpc_table_HuffQ4[1]; huff_fill_lut(mpc_HuffQ[3][1].table, mpc_HuffQ[3][1].lut, bits); + mpc_HuffQ[4][0].table = mpc_table_HuffQ5[0]; huff_fill_lut(mpc_HuffQ[4][0].table, mpc_HuffQ[4][0].lut, bits); + mpc_HuffQ[4][1].table = mpc_table_HuffQ5[1]; huff_fill_lut(mpc_HuffQ[4][1].table, mpc_HuffQ[4][1].lut, bits); + mpc_HuffQ[5][0].table = mpc_table_HuffQ6[0]; huff_fill_lut(mpc_HuffQ[5][0].table, mpc_HuffQ[5][0].lut, bits); + mpc_HuffQ[5][1].table = mpc_table_HuffQ6[1]; huff_fill_lut(mpc_HuffQ[5][1].table, mpc_HuffQ[5][1].lut, bits); + mpc_HuffQ[6][0].table = mpc_table_HuffQ7[0]; huff_fill_lut(mpc_HuffQ[6][0].table, mpc_HuffQ[6][0].lut, bits); + mpc_HuffQ[6][1].table = mpc_table_HuffQ7[1]; huff_fill_lut(mpc_HuffQ[6][1].table, mpc_HuffQ[6][1].lut, bits); + + /* sv8: create vlc lookup tables */ + mpc_can_Bands.table = mpc_huff_Bands ; mpc_can_Bands.sym = mpc_sym_Bands; + mpc_can_SCFI[0].table = mpc_huff_SCFI_1; mpc_can_SCFI[0].sym = mpc_sym_SCFI_1; can_fill_lut(&mpc_can_SCFI[0], bits); + mpc_can_SCFI[1].table = mpc_huff_SCFI_2; mpc_can_SCFI[1].sym = mpc_sym_SCFI_2; can_fill_lut(&mpc_can_SCFI[1], bits); + mpc_can_DSCF[0].table = mpc_huff_DSCF_1; mpc_can_DSCF[0].sym = mpc_sym_DSCF_1; can_fill_lut(&mpc_can_DSCF[0], bits); + mpc_can_DSCF[1].table = mpc_huff_DSCF_2; mpc_can_DSCF[1].sym = mpc_sym_DSCF_2; can_fill_lut(&mpc_can_DSCF[1], bits); + mpc_can_Res[0].table = mpc_huff_Res_1 ; mpc_can_Res[0].sym = mpc_sym_Res_1 ; can_fill_lut(&mpc_can_Res[0] , bits); + mpc_can_Res[1].table = mpc_huff_Res_2 ; mpc_can_Res[1].sym = mpc_sym_Res_2 ; can_fill_lut(&mpc_can_Res[1] , bits); + mpc_can_Q1.table = mpc_huff_Q1 ; mpc_can_Q1.sym = mpc_sym_Q1 ; can_fill_lut(&mpc_can_Q1 , bits); + mpc_can_Q9up.table = mpc_huff_Q9up ; mpc_can_Q9up.sym = mpc_sym_Q9up ; can_fill_lut(&mpc_can_Q9up , bits); + mpc_can_Q[0][0].table = mpc_huff_Q2_1 ; mpc_can_Q[0][0].sym = mpc_sym_Q2_1 ; can_fill_lut(&mpc_can_Q[0][0], bits); + mpc_can_Q[0][1].table = mpc_huff_Q2_2 ; mpc_can_Q[0][1].sym = mpc_sym_Q2_2 ; can_fill_lut(&mpc_can_Q[0][1], bits); + mpc_can_Q[1][0].table = mpc_huff_Q3 ; mpc_can_Q[1][0].sym = mpc_sym_Q3 ; can_fill_lut(&mpc_can_Q[1][0], bits); + mpc_can_Q[1][1].table = mpc_huff_Q4 ; mpc_can_Q[1][1].sym = mpc_sym_Q4 ; can_fill_lut(&mpc_can_Q[1][1], bits); + mpc_can_Q[2][0].table = mpc_huff_Q5_1 ; mpc_can_Q[2][0].sym = mpc_sym_Q5_1 ; can_fill_lut(&mpc_can_Q[2][0], bits); + mpc_can_Q[2][1].table = mpc_huff_Q5_2 ; mpc_can_Q[2][1].sym = mpc_sym_Q5_2 ; can_fill_lut(&mpc_can_Q[2][1], bits); + mpc_can_Q[3][0].table = mpc_huff_Q6_1 ; mpc_can_Q[3][0].sym = mpc_sym_Q6_1 ; can_fill_lut(&mpc_can_Q[3][0], bits); + mpc_can_Q[3][1].table = mpc_huff_Q6_2 ; mpc_can_Q[3][1].sym = mpc_sym_Q6_2 ; can_fill_lut(&mpc_can_Q[3][1], bits); + mpc_can_Q[4][0].table = mpc_huff_Q7_1 ; mpc_can_Q[4][0].sym = mpc_sym_Q7_1 ; can_fill_lut(&mpc_can_Q[4][0], bits); + mpc_can_Q[4][1].table = mpc_huff_Q7_2 ; mpc_can_Q[4][1].sym = mpc_sym_Q7_2 ; can_fill_lut(&mpc_can_Q[4][1], bits); + mpc_can_Q[5][0].table = mpc_huff_Q8_1 ; mpc_can_Q[5][0].sym = mpc_sym_Q8_1 ; can_fill_lut(&mpc_can_Q[5][0], bits); + mpc_can_Q[5][1].table = mpc_huff_Q8_2 ; mpc_can_Q[5][1].sym = mpc_sym_Q8_2 ; can_fill_lut(&mpc_can_Q[5][1], bits); +} diff --git a/lib/rbcodec/codecs/libmusepack/huffman.h b/lib/rbcodec/codecs/libmusepack/huffman.h new file mode 100644 index 0000000000..1244149184 --- /dev/null +++ b/lib/rbcodec/codecs/libmusepack/huffman.h @@ -0,0 +1,83 @@ +/* + Copyright (c) 2005-2009, The Musepack Development Team + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + + * Neither the name of the The Musepack Development Team nor the + names of its contributors may be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +/// \file huffman.h +/// Data structures and functions for huffman coding. + +#ifndef _MPCDEC_HUFFMAN_H_ +#define _MPCDEC_HUFFMAN_H_ +#ifdef WIN32 +#pragma once +#endif + +#include "mpc_types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +// LUT size parameter, LUT size is 1 << LUT_DEPTH +#define LUT_DEPTH 6 + +/// Huffman table entry. +typedef struct mpc_huffman_t { + mpc_uint16_t Code; + mpc_uint8_t Length; + mpc_int8_t Value; +} mpc_huffman; + +/// Huffman LUT entry. +typedef struct mpc_huff_lut_t { + mpc_uint8_t Length; + mpc_int8_t Value; +} mpc_huff_lut; + +/// Type used for huffman LUT decoding +typedef struct mpc_lut_data_t { + mpc_huffman const *table; + mpc_huff_lut lut[1 << LUT_DEPTH]; +} mpc_lut_data; + +/// Type used for canonical huffman decoding +typedef struct mpc_can_data_t { + mpc_huffman const *table; + mpc_int8_t const *sym; + mpc_huff_lut lut[1 << LUT_DEPTH]; +} mpc_can_data; + +void huff_init_lut(const int bits); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/lib/rbcodec/codecs/libmusepack/internal.h b/lib/rbcodec/codecs/libmusepack/internal.h new file mode 100644 index 0000000000..897e6a7b17 --- /dev/null +++ b/lib/rbcodec/codecs/libmusepack/internal.h @@ -0,0 +1,123 @@ +/* + Copyright (c) 2005-2009, The Musepack Development Team + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + + * Neither the name of the The Musepack Development Team nor the + names of its contributors may be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +/// \file internal.h +/// Definitions and structures used only internally by the libmpcdec. +#ifndef _MPCDEC_INTERNAL_H_ +#define _MPCDEC_INTERNAL_H_ +#ifdef WIN32 +#pragma once +#endif +#ifdef __cplusplus +extern "C" { +#endif + +#include "mpcdec.h" + +/* rockbox: not used, rockbox's swap32 is used now. +/// Big/little endian 32 bit byte swapping routine. +static mpc_inline +mpc_uint32_t mpc_swap32(mpc_uint32_t val) { + return (((val & 0xFF000000) >> 24) | ((val & 0x00FF0000) >> 8) + | ((val & 0x0000FF00) << 8) | ((val & 0x000000FF) << 24)); +} +*/ +typedef struct mpc_block_t { + char key[2]; // block key + mpc_uint64_t size; // block size minus the block header size +} mpc_block; + +#define MAX_FRAME_SIZE 4352 +#define DEMUX_BUFFER_SIZE (32768 - MAX_FRAME_SIZE) // need some space as sand box + +struct mpc_demux_t { + mpc_reader * r; + mpc_decoder * d; + mpc_streaminfo si; + + // buffer + mpc_uint8_t *buffer; + mpc_size_t bytes_total; + mpc_bits_reader bits_reader; + mpc_int32_t block_bits; /// bits remaining in current audio block + mpc_uint_t block_frames; /// frames remaining in current audio block + + // seeking + mpc_seek_t * seek_table; + mpc_uint_t seek_pwr; /// distance between 2 frames in seek_table = 2^seek_pwr + mpc_uint32_t seek_table_size; /// used size in seek_table + + // chapters +/* rockbox: not used + mpc_seek_t chap_pos; /// supposed position of the first chapter block + mpc_int_t chap_nb; /// number of chapters (-1 if unknown, 0 if no chapter) + mpc_chap_info * chap; /// chapters position and tag +*/ +}; + +/** + * checks if a block key is valid + * @param key the two caracters key to check + * @return MPC_STATUS_FAIL if the key is invalid, MPC_STATUS_OK else + */ +static mpc_inline mpc_status mpc_check_key(char * key) +{ + if (key[0] < 65 || key[0] > 90 || key[1] < 65 || key[1] > 90) + return MPC_STATUS_FAIL; + return MPC_STATUS_OK; +} + +/// helper functions used by multiple files +mpc_uint32_t mpc_random_int(mpc_decoder *d); // in synth_filter.c +void mpc_decoder_init_quant(mpc_decoder *d, MPC_SAMPLE_FORMAT factor); // in requant.c +void mpc_decoder_synthese_filter_float(mpc_decoder *d, MPC_SAMPLE_FORMAT* OutData, mpc_int_t channels); +unsigned long mpc_crc32(unsigned char *buf, int len); + +// streaminfo.c +mpc_status streaminfo_read_header_sv8(mpc_streaminfo* si, + const mpc_bits_reader * r_in, + mpc_size_t block_size); +mpc_status streaminfo_read_header_sv7(mpc_streaminfo* si, mpc_bits_reader * r_in); +void streaminfo_encoder_info(mpc_streaminfo* si, const mpc_bits_reader * r_in); +void streaminfo_gain(mpc_streaminfo* si, const mpc_bits_reader * r_in); + +// mpc_decoder.c +void mpc_decoder_reset_scf(mpc_decoder * d, int value); + +#define MPC_IS_FAILURE(X) ((int)(X) < (int)MPC_STATUS_OK) +#define MPC_AUTO_FAIL(X) { mpc_status s = (X); if (MPC_IS_FAILURE(s)) return s; } + +#ifdef __cplusplus +} +#endif +#endif diff --git a/lib/rbcodec/codecs/libmusepack/libmusepack.make b/lib/rbcodec/codecs/libmusepack/libmusepack.make new file mode 100644 index 0000000000..53b07869bf --- /dev/null +++ b/lib/rbcodec/codecs/libmusepack/libmusepack.make @@ -0,0 +1,18 @@ +# __________ __ ___. +# Open \______ \ ____ ____ | | _\_ |__ _______ ___ +# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / +# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < +# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ +# \/ \/ \/ \/ \/ +# $Id$ +# + +# libmusepack +MUSEPACKLIB := $(CODECDIR)/libmusepack.a +MUSEPACKLIB_SRC := $(call preprocess, $(RBCODECLIB_DIR)/codecs/libmusepack/SOURCES) +MUSEPACKLIB_OBJ := $(call c2obj, $(MUSEPACKLIB_SRC)) +OTHER_SRC += $(MUSEPACKLIB_SRC) + +$(MUSEPACKLIB): $(MUSEPACKLIB_OBJ) + $(SILENT)$(shell rm -f $@) + $(call PRINTS,AR $(@F))$(AR) rcs $@ $^ >/dev/null diff --git a/lib/rbcodec/codecs/libmusepack/minimax.h b/lib/rbcodec/codecs/libmusepack/minimax.h new file mode 100644 index 0000000000..1192626567 --- /dev/null +++ b/lib/rbcodec/codecs/libmusepack/minimax.h @@ -0,0 +1,57 @@ +/* + * Musepack audio compression + * Copyright (C) 1999-2004 Buschmann/Klemm/Piecha/Wolf + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#pragma once + +# define clip(x,min,max) ( (x) < (min) ? (min) : (x) > (max) ? (max) : (x) ) + +#ifdef __cplusplus + +# define maxi(A,B) ( (A) >? (B) ) +# define mini(A,B) ( (A) ? (B) ) +# define mind(A,B) ( (A) ? (B) ) +# define minf(A,B) ( (A) (B) ? (A) : (B) ) +# define mini(A,B) ( (A) < (B) ? (A) : (B) ) +# define maxd(A,B) ( (A) > (B) ? (A) : (B) ) +# define mind(A,B) ( (A) < (B) ? (A) : (B) ) +# define maxf(A,B) ( (A) > (B) ? (A) : (B) ) +# define minf(A,B) ( (A) < (B) ? (A) : (B) ) + +#endif + +#ifdef __GNUC__ + +# define absi(A) abs (A) +# define absf(A) fabsf (A) +# define absd(A) fabs (A) + +#else + +# define absi(A) ( (A) >= 0 ? (A) : -(A) ) +# define absf(A) ( (A) >= 0.f ? (A) : -(A) ) +# define absd(A) ( (A) >= 0. ? (A) : -(A) ) + +#endif + diff --git a/lib/rbcodec/codecs/libmusepack/mpc_bits_reader.c b/lib/rbcodec/codecs/libmusepack/mpc_bits_reader.c new file mode 100644 index 0000000000..c917ad510a --- /dev/null +++ b/lib/rbcodec/codecs/libmusepack/mpc_bits_reader.c @@ -0,0 +1,181 @@ +/* + Copyright (c) 2007-2009, The Musepack Development Team + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + + * Neither the name of the The Musepack Development Team nor the + names of its contributors may be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include "mpcdec.h" +#include "internal.h" +#include "huffman.h" +#include "mpc_bits_reader.h" + +const mpc_uint32_t Cnk[MAX_ENUM / 2][MAX_ENUM] ICONST_ATTR_MPC_BITSREADER = +{ + {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31}, + {0, 0, 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120, 136, 153, 171, 190, 210, 231, 253, 276, 300, 325, 351, 378, 406, 435, 465}, + {0, 0, 0, 1, 4, 10, 20, 35, 56, 84, 120, 165, 220, 286, 364, 455, 560, 680, 816, 969, 1140, 1330, 1540, 1771, 2024, 2300, 2600, 2925, 3276, 3654, 4060, 4495}, + {0, 0, 0, 0, 1, 5, 15, 35, 70, 126, 210, 330, 495, 715, 1001, 1365, 1820, 2380, 3060, 3876, 4845, 5985, 7315, 8855, 10626, 12650, 14950, 17550, 20475, 23751, 27405, 31465}, + {0, 0, 0, 0, 0, 1, 6, 21, 56, 126, 252, 462, 792, 1287, 2002, 3003, 4368, 6188, 8568, 11628, 15504, 20349, 26334, 33649, 42504, 53130, 65780, 80730, 98280, 118755, 142506, 169911}, + {0, 0, 0, 0, 0, 0, 1, 7, 28, 84, 210, 462, 924, 1716, 3003, 5005, 8008, 12376, 18564, 27132, 38760, 54264, 74613, 100947, 134596, 177100, 230230, 296010, 376740, 475020, 593775, 736281}, + {0, 0, 0, 0, 0, 0, 0, 1, 8, 36, 120, 330, 792, 1716, 3432, 6435, 11440, 19448, 31824, 50388, 77520, 116280, 170544, 245157, 346104, 480700, 657800, 888030, 1184040, 1560780, 2035800, 2629575}, + {0, 0, 0, 0, 0, 0, 0, 0, 1, 9, 45, 165, 495, 1287, 3003, 6435, 12870, 24310, 43758, 75582, 125970, 203490, 319770, 490314, 735471, 1081575, 1562275, 2220075, 3108105, 4292145, 5852925, 7888725}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 10, 55, 220, 715, 2002, 5005, 11440, 24310, 48620, 92378, 167960, 293930, 497420, 817190, 1307504, 2042975, 3124550, 4686825, 6906900, 10015005, 14307150, 20160075}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 11, 66, 286, 1001, 3003, 8008, 19448, 43758, 92378, 184756, 352716, 646646, 1144066, 1961256, 3268760, 5311735, 8436285, 13123110, 20030010, 30045015, 44352165}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 12, 78, 364, 1365, 4368, 12376, 31824, 75582, 167960, 352716, 705432, 1352078, 2496144, 4457400, 7726160, 13037895, 21474180, 34597290, 54627300, 84672315}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 13, 91, 455, 1820, 6188, 18564, 50388, 125970, 293930, 646646, 1352078, 2704156, 5200300, 9657700, 17383860, 30421755, 51895935, 86493225, 141120525}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 14, 105, 560, 2380, 8568, 27132, 77520, 203490, 497420, 1144066, 2496144, 5200300, 10400600, 20058300, 37442160, 67863915, 119759850, 206253075}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 15, 120, 680, 3060, 11628, 38760, 116280, 319770, 817190, 1961256, 4457400, 9657700, 20058300, 40116600, 77558760, 145422675, 265182525}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 16, 136, 816, 3876, 15504, 54264, 170544, 490314, 1307504, 3268760, 7726160, 17383860, 37442160, 77558760, 155117520, 300540195}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 17, 153, 969, 4845, 20349, 74613, 245157, 735471, 2042975, 5311735, 13037895, 30421755, 67863915, 145422675, 300540195} +}; + +const mpc_uint8_t Cnk_len[MAX_ENUM / 2][MAX_ENUM] ICONST_ATTR_MPC_BITSREADER = +{ + {0, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5}, + {0, 0, 2, 3, 4, 4, 5, 5, 6, 6, 6, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9}, + {0, 0, 0, 2, 4, 5, 6, 6, 7, 7, 8, 8, 9, 9, 9, 10, 10, 10, 10, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 13, 13}, + {0, 0, 0, 0, 3, 4, 6, 7, 7, 8, 9, 9, 10, 10, 11, 11, 12, 12, 12, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 15, 16}, + {0, 0, 0, 0, 0, 3, 5, 6, 7, 8, 9, 10, 11, 11, 12, 13, 13, 14, 14, 14, 15, 15, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18}, + {0, 0, 0, 0, 0, 0, 3, 5, 7, 8, 9, 10, 11, 12, 13, 13, 14, 15, 15, 16, 16, 17, 17, 18, 18, 18, 19, 19, 19, 20, 20, 20}, + {0, 0, 0, 0, 0, 0, 0, 3, 6, 7, 9, 10, 11, 12, 13, 14, 15, 15, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 21, 22, 22}, + {0, 0, 0, 0, 0, 0, 0, 0, 4, 6, 8, 9, 11, 12, 13, 14, 15, 16, 17, 17, 18, 19, 19, 20, 21, 21, 22, 22, 23, 23, 23, 24}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 6, 8, 10, 11, 13, 14, 15, 16, 17, 18, 19, 19, 20, 21, 21, 22, 23, 23, 24, 24, 25, 25}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 7, 9, 10, 12, 13, 15, 16, 17, 18, 19, 20, 21, 21, 22, 23, 24, 24, 25, 25, 26, 26}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 7, 9, 11, 13, 14, 15, 17, 18, 19, 20, 21, 22, 23, 23, 24, 25, 26, 26, 27, 27}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 7, 9, 11, 13, 15, 16, 17, 19, 20, 21, 22, 23, 24, 25, 25, 26, 27, 28, 28}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 7, 10, 12, 14, 15, 17, 18, 19, 21, 22, 23, 24, 25, 26, 27, 27, 28, 29}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 7, 10, 12, 14, 16, 17, 19, 20, 21, 23, 24, 25, 26, 27, 28, 28, 29}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 8, 10, 12, 14, 16, 18, 19, 21, 22, 23, 25, 26, 27, 28, 29, 30}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 8, 10, 13, 15, 17, 18, 20, 21, 23, 24, 25, 27, 28, 29, 30} + +}; + +const mpc_uint32_t Cnk_lost[MAX_ENUM / 2][MAX_ENUM] ICONST_ATTR_MPC_BITSREADER = +{ + {0, 0, 1, 0, 3, 2, 1, 0, 7, 6, 5, 4, 3, 2, 1, 0, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0}, + {0, 0, 1, 2, 6, 1, 11, 4, 28, 19, 9, 62, 50, 37, 23, 8, 120, 103, 85, 66, 46, 25, 3, 236, 212, 187, 161, 134, 106, 77, 47, 16}, + {0, 0, 0, 0, 6, 12, 29, 8, 44, 8, 91, 36, 226, 148, 57, 464, 344, 208, 55, 908, 718, 508, 277, 24, 1796, 1496, 1171, 820, 442, 36, 3697, 3232}, + {0, 0, 0, 0, 3, 1, 29, 58, 2, 46, 182, 17, 309, 23, 683, 228, 1716, 1036, 220, 3347, 2207, 877, 7529, 5758, 3734, 1434, 15218, 12293, 9017, 5363, 1303, 29576}, + {0, 0, 0, 0, 0, 2, 11, 8, 2, 4, 50, 232, 761, 46, 1093, 3824, 2004, 7816, 4756, 880, 12419, 6434, 31887, 23032, 12406, 65292, 50342, 32792, 12317, 119638, 92233, 60768}, + {0, 0, 0, 0, 0, 0, 1, 4, 44, 46, 50, 100, 332, 1093, 3187, 184, 4008, 14204, 5636, 26776, 11272, 56459, 30125, 127548, 85044, 31914, 228278, 147548, 49268, 454801, 312295, 142384}, + {0, 0, 0, 0, 0, 0, 0, 0, 28, 8, 182, 232, 332, 664, 1757, 4944, 13320, 944, 15148, 53552, 14792, 91600, 16987, 178184, 43588, 390776, 160546, 913112, 536372, 61352, 1564729, 828448}, + {0, 0, 0, 0, 0, 0, 0, 0, 7, 19, 91, 17, 761, 1093, 1757, 3514, 8458, 21778, 55490, 5102, 58654, 204518, 33974, 313105, 1015577, 534877, 1974229, 1086199, 4096463, 2535683, 499883, 6258916}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 9, 36, 309, 46, 3187, 4944, 8458, 16916, 38694, 94184, 230358, 26868, 231386, 789648, 54177, 1069754, 3701783, 1481708, 6762211, 2470066, 13394357, 5505632}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 62, 226, 23, 1093, 184, 13320, 21778, 38694, 77388, 171572, 401930, 953086, 135896, 925544, 3076873, 8340931, 3654106, 13524422, 3509417, 22756699, 2596624}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 50, 148, 683, 3824, 4008, 944, 55490, 94184, 171572, 343144, 745074, 1698160, 3931208, 662448, 3739321, 12080252, 32511574, 12481564, 49545413, 5193248}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 37, 57, 228, 2004, 14204, 15148, 5102, 230358, 401930, 745074, 1490148, 3188308, 7119516, 16170572, 3132677, 15212929, 47724503, 127314931, 42642616}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 23, 464, 1716, 7816, 5636, 53552, 58654, 26868, 953086, 1698160, 3188308, 6376616, 13496132, 29666704, 66353813, 14457878, 62182381, 189497312}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 8, 344, 1036, 4756, 26776, 14792, 204518, 231386, 135896, 3931208, 7119516, 13496132, 26992264, 56658968, 123012781, 3252931, 65435312}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 120, 208, 220, 880, 11272, 91600, 33974, 789648, 925544, 662448, 16170572, 29666704, 56658968, 113317936, 236330717, 508019104}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15, 103, 55, 3347, 12419, 56459, 16987, 313105, 54177, 3076873, 3739321, 3132677, 66353813, 123012781, 236330717} +}; + +static const mpc_uint8_t log2[32] ICONST_ATTR_MPC_BITSREADER = +{ 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6}; + +static const mpc_uint8_t log2_lost[32] ICONST_ATTR_MPC_BITSREADER = +{ 0, 1, 0, 3, 2, 1, 0, 7, 6, 5, 4, 3, 2, 1, 0, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 31}; + +mpc_int32_t mpc_bits_golomb_dec(mpc_bits_reader * r, const mpc_uint_t k) +{ + unsigned int l = 0; + unsigned int code = r->buff[0] & ((1 << r->count) - 1); + + while( code == 0 ) { + l += r->count; + r->buff++; + code = r->buff[0]; + r->count = 8; + } + + while( ((1 << (r->count - 1)) & code) == 0 ) { + l++; + r->count--; + } + r->count--; + + while( r->count < k ) { + r->buff++; + r->count += 8; + code = (code << 8) | r->buff[0]; + } + + r->count -= k; + + return (l << k) | ((code >> r->count) & ((1 << k) - 1)); +} + +mpc_uint32_t mpc_bits_log_dec(mpc_bits_reader * r, mpc_uint_t max) +{ + mpc_uint32_t value = 0; + if (max == 0) + return 0; + if (log2[max - 1] > 1) + value = mpc_bits_read(r, log2[max - 1] - 1); + if (value >= log2_lost[max - 1]) + value = ((value << 1) | mpc_bits_read(r, 1)) - log2_lost[max - 1]; + return value; +} + +unsigned int mpc_bits_get_size(mpc_bits_reader * r, mpc_uint64_t * p_size) +{ + unsigned char tmp; + mpc_uint64_t size = 0; + unsigned int ret = 0; + + do { + tmp = mpc_bits_read(r, 8); + size = (size << 7) | (tmp & 0x7F); + ret++; + } while((tmp & 0x80)); + + *p_size = size; + return ret; +} + +int mpc_bits_get_block(mpc_bits_reader * r, mpc_block * p_block) +{ + int size = 2; + + p_block->size = 0; + p_block->key[0] = mpc_bits_read(r, 8); + p_block->key[1] = mpc_bits_read(r, 8); + + size += mpc_bits_get_size(r, &(p_block->size)); + + if (p_block->size >= (mpc_uint64_t)size) // check if the block size doesn't conflict with the header size + p_block->size -= (mpc_uint64_t)size; + + return size; +} + + + diff --git a/lib/rbcodec/codecs/libmusepack/mpc_bits_reader.h b/lib/rbcodec/codecs/libmusepack/mpc_bits_reader.h new file mode 100644 index 0000000000..1233720c74 --- /dev/null +++ b/lib/rbcodec/codecs/libmusepack/mpc_bits_reader.h @@ -0,0 +1,175 @@ +/* + Copyright (c) 2007-2009, The Musepack Development Team + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + + * Neither the name of the The Musepack Development Team nor the + names of its contributors may be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#define MAX_ENUM 32 + +MPC_API int mpc_bits_get_block(mpc_bits_reader * r, mpc_block * p_block); +mpc_int32_t mpc_bits_golomb_dec(mpc_bits_reader * r, const mpc_uint_t k); +MPC_API unsigned int mpc_bits_get_size(mpc_bits_reader * r, mpc_uint64_t * p_size); +mpc_uint32_t mpc_bits_log_dec(mpc_bits_reader * r, mpc_uint_t max); + +extern const mpc_uint32_t Cnk [MAX_ENUM / 2][MAX_ENUM]; +extern const mpc_uint8_t Cnk_len [MAX_ENUM / 2][MAX_ENUM]; +extern const mpc_uint32_t Cnk_lost[MAX_ENUM / 2][MAX_ENUM]; + +// can read up to 31 bits +static mpc_inline mpc_uint32_t mpc_bits_read(mpc_bits_reader * r, const unsigned int nb_bits) +{ + mpc_uint32_t ret; + + r->buff -= (int)(r->count - nb_bits) >> 3; + r->count = (r->count - nb_bits) & 0x07; + + ret = (r->buff[0] | (r->buff[-1] << 8)) >> r->count; + if (nb_bits > (16 - r->count)) { + ret |= (mpc_uint32_t)((r->buff[-2] << 16) | (r->buff[-3] << 24)) >> r->count; + if (nb_bits > 24 && r->count != 0) + ret |= r->buff[-4] << (32 - r->count); + } + + return ret & ((1 << nb_bits) - 1); +} + +#if defined(CPU_COLDFIRE) +/* rockbox: This is specific code to optimize demux performance on Coldfire + * CPUs. Coldfire CPUs are very sensible to RAM accesses. As the bitstream + * buffer does not fit into IRAM the read accesses to the uint8 buffer are very + * expensive in terms of CPU cycles. + * The following code uses two variables in IRAM. The variable last_code keeps + * the 4-byte value of buf[0]<<16 | buf[1]<<8 | buf[2]. As long as buf[0] will + * read from the same address the following code will avoid re-reading of the + * buffers. If buf[0] did advance to the next uint8-entry since the last call + * the following will only need to load 1 uint8-entry instead of 3. + */ +static mpc_inline mpc_uint16_t get_code_from_buffer(mpc_bits_reader *r) +{ + /* Buffer advanced by 1 entry since last call */ + if (r->buff == r->buffered_addr + 1) { + r->buffered_code = (r->buffered_code<<8) | r->buff[2]; + r->buffered_addr = r->buff; + } + /* Buffer must be fully re-read */ + else if (r->buff != r->buffered_addr) { + r->buffered_code = (r->buff[0] << 16) | (r->buff[1] << 8) | r->buff[2]; + r->buffered_addr = r->buff; + } + + return (mpc_uint16_t)((r->buffered_code >> r->count) & 0xFFFF); +} +#else +/* Use the decoder's default implementation. This is faster on non-Coldfire targets */ +#define get_code_from_buffer(r) (mpc_uint16_t)((((r->buff[0] << 16) | (r->buff[1] << 8) | r->buff[2]) >> r->count) & 0xFFFF); +#endif + +// basic huffman decoding routine +// works with maximum lengths up to 16 +static mpc_inline mpc_int32_t mpc_bits_huff_dec(mpc_bits_reader * r, const mpc_huffman *Table) +{ + const mpc_uint16_t code = get_code_from_buffer(r); + + while (code < Table->Code) Table++; + + r->buff -= (int)(r->count - Table->Length) >> 3; + r->count = (r->count - Table->Length) & 0x07; + + return Table->Value; +} + +static mpc_inline mpc_int32_t mpc_bits_can_dec(mpc_bits_reader * r, const mpc_can_data *can) +{ + const mpc_uint16_t code = get_code_from_buffer(r); + const mpc_huff_lut tmp = can->lut[code >> (16 - LUT_DEPTH)]; + const mpc_huffman * Table; + + if (tmp.Length != 0) { + r->buff -= (int)(r->count - tmp.Length) >> 3; + r->count = (r->count - tmp.Length) & 0x07; + return tmp.Value; + } + + Table = can->table + (unsigned char)tmp.Value; + while (code < Table->Code) Table++; + + r->buff -= (int)(r->count - Table->Length) >> 3; + r->count = (r->count - Table->Length) & 0x07; + + return can->sym[(Table->Value - (code >> (16 - Table->Length))) & 0xFF] ; +} + +// LUT-based huffman decoding routine +// works with maximum lengths up to 16 +static mpc_inline mpc_int32_t mpc_bits_huff_lut(mpc_bits_reader * r, const mpc_lut_data *lut) +{ + const mpc_uint16_t code = get_code_from_buffer(r); + const mpc_huff_lut tmp = lut->lut[code >> (16 - LUT_DEPTH)]; + const mpc_huffman * Table; + + if (tmp.Length != 0) { + r->buff -= (int)(r->count - tmp.Length) >> 3; + r->count = (r->count - tmp.Length) & 0x07; + return tmp.Value; + } + + Table = lut->table + (unsigned char)tmp.Value; + while (code < Table->Code) Table++; + + r->buff -= (int)(r->count - Table->Length) >> 3; + r->count = (r->count - Table->Length) & 0x07; + + return Table->Value; +} + +static mpc_inline mpc_uint32_t mpc_bits_enum_dec(mpc_bits_reader * r, mpc_uint_t k, mpc_uint_t n) +{ + mpc_uint32_t bits = 0; + mpc_uint32_t code; + const mpc_uint32_t * C = Cnk[k-1]; + + code = mpc_bits_read(r, Cnk_len[k-1][n-1] - 1); + + if (code >= Cnk_lost[k-1][n-1]) + code = ((code << 1) | mpc_bits_read(r, 1)) - Cnk_lost[k-1][n-1]; + + do { + n--; + if (code >= C[n]) { + bits |= 1 << n; + code -= C[n]; + C -= MAX_ENUM; + k--; + } + } while(k > 0); + + return bits; +} diff --git a/lib/rbcodec/codecs/libmusepack/mpc_decoder.c b/lib/rbcodec/codecs/libmusepack/mpc_decoder.c new file mode 100644 index 0000000000..3bfc4cc7fc --- /dev/null +++ b/lib/rbcodec/codecs/libmusepack/mpc_decoder.c @@ -0,0 +1,767 @@ +/* + Copyright (c) 2005-2009, The Musepack Development Team + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + + * Neither the name of the The Musepack Development Team nor the + names of its contributors may be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +/// \file mpc_decoder.c +/// Core decoding routines and logic. + +#include +#include +#include "mpcdec.h" +#include "minimax.h" +#include "decoder.h" +#include "huffman.h" +#include "internal.h" +#include "mpcdec_math.h" +#include "requant.h" +#include "mpc_bits_reader.h" + +//SV7 tables +extern const mpc_lut_data mpc_HuffQ [7] [2]; +extern const mpc_lut_data mpc_HuffHdr; +extern const mpc_huffman mpc_table_HuffSCFI [ 4]; +extern const mpc_lut_data mpc_HuffDSCF; + +//SV8 tables +extern const mpc_can_data mpc_can_Bands; +extern const mpc_can_data mpc_can_SCFI[2]; +extern const mpc_can_data mpc_can_DSCF[2]; +extern const mpc_can_data mpc_can_Res [2]; +extern const mpc_can_data mpc_can_Q [8][2]; +extern const mpc_can_data mpc_can_Q1; +extern const mpc_can_data mpc_can_Q9up; + +//Decoder globals (g_Y_L and g_Y_R do not fit into iram for all targets) +static mpc_decoder g_mpc_decoder IBSS_ATTR; +static MPC_SAMPLE_FORMAT g_V_L[MPC_V_MEM + 960 ] IBSS_ATTR MEM_ALIGN_ATTR; +static MPC_SAMPLE_FORMAT g_Y_L[MPC_FRAME_LENGTH] IBSS_ATTR_MPC_LARGE_IRAM MEM_ALIGN_ATTR; +static MPC_SAMPLE_FORMAT g_V_R[MPC_V_MEM + 960 ] IBSS_ATTR MEM_ALIGN_ATTR; +static MPC_SAMPLE_FORMAT g_Y_R[MPC_FRAME_LENGTH] IBSS_ATTR_MPC_LARGE_IRAM MEM_ALIGN_ATTR; + +//SV7 globals (decoding results for bundled quantizers (3- and 5-step)) +static const mpc_int32_t g_sv7_idx30[] ICONST_ATTR = +{-1, 0, 1,-1, 0, 1,-1, 0, 1,-1, 0, 1,-1, 0, 1,-1, 0, 1,-1, 0, 1,-1, 0, 1,-1, 0, 1}; +static const mpc_int32_t g_sv7_idx31[] ICONST_ATTR = +{-1,-1,-1, 0, 0, 0, 1, 1, 1,-1,-1,-1, 0, 0, 0, 1, 1, 1,-1,-1,-1, 0, 0, 0, 1, 1, 1}; +static const mpc_int32_t g_sv7_idx32[] ICONST_ATTR = +{-1,-1,-1,-1,-1,-1,-1,-1,-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1}; +static const mpc_int32_t g_sv7_idx50[] ICONST_ATTR = +{-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2}; +static const mpc_int32_t g_sv7_idx51[] ICONST_ATTR = +{-2,-2,-2,-2,-2,-1,-1,-1,-1,-1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2}; + +//SV8 globals (decoding results for bundled quantizers (3- and 5-step)) +static const mpc_int8_t g_sv8_idx50[125] ICONST_ATTR = +{-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2, + -2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2, + -2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2, + -2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2, + -2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2}; +static const mpc_int8_t g_sv8_idx51[125] ICONST_ATTR = +{-2,-2,-2,-2,-2,-1,-1,-1,-1,-1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, + -2,-2,-2,-2,-2,-1,-1,-1,-1,-1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, + -2,-2,-2,-2,-2,-1,-1,-1,-1,-1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, + -2,-2,-2,-2,-2,-1,-1,-1,-1,-1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, + -2,-2,-2,-2,-2,-1,-1,-1,-1,-1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2}; +static const mpc_int8_t g_sv8_idx52[125] ICONST_ATTR = +{-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2, + -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2}; +static const mpc_int8_t g_sv8_HuffQ2_var[125] ICONST_ATTR = +{ 6, 5, 4, 5, 6, 5, 4, 3, 4, 5, 4, 3, 2, 3, 4, 5, 4, 3, 4, 5, 6, 5, 4, 5, 6, + 5, 4, 3, 4, 5, 4, 3, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 3, 4, 5, 4, 3, 4, 5, + 4, 3, 2, 3, 4, 3, 2, 1, 2, 3, 2, 1, 0, 1, 2, 3, 2, 1, 2, 3, 4, 3, 2, 3, 4, + 5, 4, 3, 4, 5, 4, 3, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 3, 4, 5, 4, 3, 4, 5, + 6, 5, 4, 5, 6, 5, 4, 3, 4, 5, 4, 3, 2, 3, 4, 5, 4, 3, 4, 5, 6, 5, 4, 5, 6}; + +//------------------------------------------------------------------------------ +// types +//------------------------------------------------------------------------------ +enum +{ + MEMSIZE = MPC_DECODER_MEMSIZE, // overall buffer size + MEMSIZE2 = (MEMSIZE/2), // size of one buffer + MEMMASK = (MEMSIZE-1) +}; + +//------------------------------------------------------------------------------ +// forward declarations +//------------------------------------------------------------------------------ +static void mpc_decoder_requantisierung (mpc_decoder *d) + ICODE_ATTR_MPC_LARGE_IRAM; +static void mpc_decoder_read_bitstream_sv7(mpc_decoder * d, + mpc_bits_reader * r) + ICODE_ATTR_MPC_LARGE_IRAM; +static void mpc_decoder_read_bitstream_sv8(mpc_decoder * d, + mpc_bits_reader * r, + mpc_bool_t is_key_frame) + ICODE_ATTR_MPC_SV8_BS_DEC; + +//------------------------------------------------------------------------------ +// macros +//------------------------------------------------------------------------------ +#define REQUANT_M1_S1_SAMPLES(IDX) \ + *(YL+=IDX) = (templ = MPC_MULTIPLY_FLOAT_INT(facL,*L++))+(tempr = MPC_MULTIPLY_FLOAT_INT(facR,*R++)); \ + *(YR+=IDX) = templ - tempr; + +#define REQUANT_M1_S1(SUBFRAME) \ + facL = MPC_MULTIPLY_SCF( Cc[d->Res_L[Band]] , d->SCF_Index_L[Band][SUBFRAME] & 0xFF); \ + facR = MPC_MULTIPLY_SCF( Cc[d->Res_R[Band]] , d->SCF_Index_R[Band][SUBFRAME] & 0xFF); \ + for (n = 0; n < 12; n+=4, YL += 32, YR += 32) { \ + REQUANT_M1_S1_SAMPLES( 0); \ + REQUANT_M1_S1_SAMPLES(32); \ + REQUANT_M1_S1_SAMPLES(32); \ + REQUANT_M1_S1_SAMPLES(32); \ + } + +#define REQUANT_M1_S0_SAMPLES(IDX) \ + *(YR+=IDX) = *(YL+=IDX) = MPC_MULTIPLY_FLOAT_INT(facL,*L++); + +#define REQUANT_M1_S0(SUBFRAME) \ + facL = MPC_MULTIPLY_SCF( Cc[d->Res_L[Band]] , d->SCF_Index_L[Band][SUBFRAME] & 0xFF); \ + for (n = 0; n < 12; n+=4, YL += 32, YR += 32) { \ + REQUANT_M1_S0_SAMPLES( 0); \ + REQUANT_M1_S0_SAMPLES(32); \ + REQUANT_M1_S0_SAMPLES(32); \ + REQUANT_M1_S0_SAMPLES(32); \ + } + +#define REQUANT_M0_S1_SAMPLES(IDX) \ + *(YR+=IDX) = -(*(YL+=IDX) = MPC_MULTIPLY_FLOAT_INT(facR,*R++)); + +#define REQUANT_M0_S1(SUBFRAME) \ + facR = MPC_MULTIPLY_SCF( Cc[d->Res_R[Band]] , d->SCF_Index_R[Band][SUBFRAME] & 0xFF); \ + for (n = 0; n < 12; n+=4, YL += 32, YR += 32) { \ + REQUANT_M0_S1_SAMPLES( 0); \ + REQUANT_M0_S1_SAMPLES(32); \ + REQUANT_M0_S1_SAMPLES(32); \ + REQUANT_M0_S1_SAMPLES(32); \ + } + +#define REQUANT_L1_R1_SAMPLES(IDX) \ + *(YL+=IDX) = MPC_MULTIPLY_FLOAT_INT(facL,*L++); \ + *(YR+=IDX) = MPC_MULTIPLY_FLOAT_INT(facR,*R++); + +#define REQUANT_L1_R1(SUBFRAME) \ + facL = MPC_MULTIPLY_SCF( Cc[d->Res_L[Band]] , d->SCF_Index_L[Band][SUBFRAME] & 0xFF); \ + facR = MPC_MULTIPLY_SCF( Cc[d->Res_R[Band]] , d->SCF_Index_R[Band][SUBFRAME] & 0xFF); \ + for (n = 0; n < 12; n+=4, YL += 32, YR += 32) { \ + REQUANT_L1_R1_SAMPLES( 0); \ + REQUANT_L1_R1_SAMPLES(32); \ + REQUANT_L1_R1_SAMPLES(32); \ + REQUANT_L1_R1_SAMPLES(32); \ + } + +#define REQUANT_L1_R0_SAMPLES(IDX) \ + *(YL+=IDX) = MPC_MULTIPLY_FLOAT_INT(facL,*L++); \ + *(YR+=IDX) = 0; + +#define REQUANT_L1_R0(SUBFRAME) \ + facL = MPC_MULTIPLY_SCF( Cc[d->Res_L[Band]] , d->SCF_Index_L[Band][SUBFRAME] & 0xFF); \ + for (n = 0; n < 12; n+=4, YL += 32, YR += 32) { \ + REQUANT_L1_R0_SAMPLES( 0); \ + REQUANT_L1_R0_SAMPLES(32); \ + REQUANT_L1_R0_SAMPLES(32); \ + REQUANT_L1_R0_SAMPLES(32); \ + } + +#define REQUANT_L0_R1_SAMPLES(IDX) \ + *(YL+=IDX) = 0; \ + *(YR+=IDX) = MPC_MULTIPLY_FLOAT_INT(facR,*R++); + +#define REQUANT_L0_R1(SUBFRAME) \ + facR = MPC_MULTIPLY_SCF( Cc[d->Res_R[Band]] , d->SCF_Index_R[Band][SUBFRAME] & 0xFF); \ + for (n = 0; n < 12; n+=4, YL += 32, YR += 32) { \ + REQUANT_L0_R1_SAMPLES( 0); \ + REQUANT_L0_R1_SAMPLES(32); \ + REQUANT_L0_R1_SAMPLES(32); \ + REQUANT_L0_R1_SAMPLES(32); \ + } + +#define REQUANT_SILENCE_SAMPLES(IDX) \ + *(YR+=IDX) = *(YL+=IDX) = 0; + +#define REQUANT_SILENCE \ + for (n = 0; n < 36; n+=4, YL += 32, YR += 32) { \ + REQUANT_SILENCE_SAMPLES( 0); \ + REQUANT_SILENCE_SAMPLES(32); \ + REQUANT_SILENCE_SAMPLES(32); \ + REQUANT_SILENCE_SAMPLES(32); \ + } + +/** + * set the scf indexes for seeking use + * needed only for sv7 seeking + * @param d + */ +void mpc_decoder_reset_scf(mpc_decoder * d, int value) +{ + memset(d->SCF_Index_L, value, sizeof d->SCF_Index_L ); + memset(d->SCF_Index_R, value, sizeof d->SCF_Index_R ); +} + +static void mpc_decoder_setup(mpc_decoder *d) +{ +#if defined(CPU_COLDFIRE) + coldfire_set_macsr(EMAC_FRACTIONAL | EMAC_SATURATE); +#endif + + memset(d, 0, sizeof *d); + + d->__r1 = 1; + d->__r2 = 1; + d->V_L = g_V_L; + d->V_R = g_V_R; + d->Y_L = g_Y_L; + d->Y_R = g_Y_R; + + memset(d->V_L, 0, sizeof(g_V_L)); + memset(d->V_R, 0, sizeof(g_V_R)); + memset(d->Y_L, 0, sizeof(g_Y_L)); + memset(d->Y_R, 0, sizeof(g_Y_R)); + + mpc_decoder_init_quant(d, MAKE_MPC_SAMPLE(1.0)); +} + +static void mpc_decoder_set_streaminfo(mpc_decoder *d, mpc_streaminfo *si) +{ + d->stream_version = si->stream_version; + d->ms = si->ms; + d->max_band = si->max_band; + d->channels = si->channels; + d->samples_to_skip = MPC_DECODER_SYNTH_DELAY + si->beg_silence; + + if (si->stream_version == 7 && si->is_true_gapless) + d->samples = ((si->samples + MPC_FRAME_LENGTH - 1) / MPC_FRAME_LENGTH) * MPC_FRAME_LENGTH; + else + d->samples = si->samples; +} + +mpc_decoder * mpc_decoder_init(mpc_streaminfo *si) +{ + mpc_decoder* p_tmp = &g_mpc_decoder; + + if (p_tmp != 0) { + mpc_decoder_setup(p_tmp); + mpc_decoder_set_streaminfo(p_tmp, si); + huff_init_lut(LUT_DEPTH); + } + + return p_tmp; +} + +/* rockbox: not used +void mpc_decoder_exit(mpc_decoder *d) +{ + (void)d; +} +*/ + +void mpc_decoder_decode_frame(mpc_decoder * d, + mpc_bits_reader * r, + mpc_frame_info * i) +{ + mpc_bits_reader r_sav = *r; + mpc_int64_t samples_left; + + samples_left = d->samples - d->decoded_samples + MPC_DECODER_SYNTH_DELAY; + + if (samples_left <= 0 && d->samples != 0) { + i->samples = 0; + i->bits = -1; + return; + } + + if (d->stream_version == 8) { + mpc_decoder_read_bitstream_sv8(d, r, i->is_key_frame); + } else { + mpc_decoder_read_bitstream_sv7(d, r); + } + + if (d->samples_to_skip < MPC_FRAME_LENGTH + MPC_DECODER_SYNTH_DELAY) { + mpc_decoder_requantisierung(d); + mpc_decoder_synthese_filter_float(d, i->buffer, d->channels); + } + + d->decoded_samples += MPC_FRAME_LENGTH; + + // reconstruct exact filelength + if (d->decoded_samples - d->samples < MPC_FRAME_LENGTH && d->stream_version == 7) { + int last_frame_samples = mpc_bits_read(r, 11); + if (d->decoded_samples == d->samples) { + if (last_frame_samples == 0) last_frame_samples = MPC_FRAME_LENGTH; + d->samples += last_frame_samples - MPC_FRAME_LENGTH; + samples_left += last_frame_samples - MPC_FRAME_LENGTH; + } + } + + i->samples = samples_left > MPC_FRAME_LENGTH ? MPC_FRAME_LENGTH : samples_left < 0 ? 0 : (mpc_uint32_t) samples_left; + i->bits = (mpc_uint32_t) (((r->buff - r_sav.buff) << 3) + r_sav.count - r->count); + + if (d->samples_to_skip) { + if (i->samples <= d->samples_to_skip) { + d->samples_to_skip -= i->samples; + i->samples = 0; + } else { + i->samples -= d->samples_to_skip; + + /* move valid samples to beginning for channel 0. noninterleaved! */ + memmove(i->buffer, + i->buffer + d->samples_to_skip, + i->samples * sizeof(MPC_SAMPLE_FORMAT)); + /* move valid samples to beginning for channel 1. noninterleaved! */ + memmove(i->buffer + MPC_FRAME_LENGTH, + i->buffer + MPC_FRAME_LENGTH + d->samples_to_skip, + i->samples * sizeof(MPC_SAMPLE_FORMAT)); + + d->samples_to_skip = 0; + } + } +} + +static void +mpc_decoder_requantisierung(mpc_decoder *d) +{ + mpc_int32_t Band; + mpc_int32_t n; + MPC_SAMPLE_FORMAT facL; + MPC_SAMPLE_FORMAT facR; + MPC_SAMPLE_FORMAT templ; + MPC_SAMPLE_FORMAT tempr; + MPC_SAMPLE_FORMAT* YL; + MPC_SAMPLE_FORMAT* YR; + mpc_int16_t* L; + mpc_int16_t* R; + const mpc_int32_t Last_Band = d->max_band; + +#ifdef MPC_FIXED_POINT +#if MPC_FIXED_POINT_FRACTPART == 14 +#define MPC_MULTIPLY_SCF(CcVal, SCF_idx) \ + MPC_MULTIPLY_EX(CcVal, d->SCF[SCF_idx], d->SCF_shift[SCF_idx]) +#else + +#error FIXME, Cc table is in 18.14 format + +#endif +#else +#define MPC_MULTIPLY_SCF(CcVal, SCF_idx) \ + MPC_MULTIPLY(CcVal, d->SCF[SCF_idx]) +#endif + // requantization and scaling of subband-samples + for ( Band = 0; Band <= Last_Band; Band++ ) { // setting pointers + YL = d->Y_L + Band; + YR = d->Y_R + Band; + L = d->Q[Band].L; + R = d->Q[Band].R; + /************************** MS-coded **************************/ + if ( d->MS_Flag [Band] ) { + if ( d->Res_L [Band] ) { + if ( d->Res_R [Band] ) { // M!=0, S!=0 + REQUANT_M1_S1(0); + REQUANT_M1_S1(1); + REQUANT_M1_S1(2); + } else { // M!=0, S==0 + REQUANT_M1_S0(0); + REQUANT_M1_S0(1); + REQUANT_M1_S0(2); + } + } else { + if ( d->Res_R[Band] ) // M==0, S!=0 + { + REQUANT_M0_S1(0); + REQUANT_M0_S1(1); + REQUANT_M0_S1(2); + } else { // M==0, S==0 + REQUANT_SILENCE; + } + } + } + /************************** LR-coded **************************/ + else { + if ( d->Res_L [Band] ) { + if ( d->Res_R [Band] ) { // L!=0, R!=0 + REQUANT_L1_R1(0); + REQUANT_L1_R1(1); + REQUANT_L1_R1(2); + } else { // L!=0, R==0 + REQUANT_L1_R0(0); + REQUANT_L1_R0(1); + REQUANT_L1_R0(2); + } + } + else { + if ( d->Res_R [Band] ) { // L==0, R!=0 + REQUANT_L0_R1(0); + REQUANT_L0_R1(1); + REQUANT_L0_R1(2); + } else { // L==0, R==0 + REQUANT_SILENCE; + } + } + } + } +} + +static void mpc_decoder_read_bitstream_sv7(mpc_decoder * d, mpc_bits_reader * r) +{ + mpc_int32_t n, idx, Max_used_Band = 0; + + /***************************** Header *****************************/ + + // first subband + d->Res_L[0] = mpc_bits_read(r, 4); + d->Res_R[0] = mpc_bits_read(r, 4); + if (!(d->Res_L[0] == 0 && d->Res_R[0] == 0)) { + if (d->ms) + d->MS_Flag[0] = mpc_bits_read(r, 1); + Max_used_Band = 1; + } + + // consecutive subbands + for ( n = 1; n <= d->max_band; n++ ) { + idx = mpc_bits_huff_lut(r, & mpc_HuffHdr); + d->Res_L[n] = (idx!=4) ? d->Res_L[n - 1] + idx : (int) mpc_bits_read(r, 4); + + idx = mpc_bits_huff_lut(r, & mpc_HuffHdr); + d->Res_R[n] = (idx!=4) ? d->Res_R[n - 1] + idx : (int) mpc_bits_read(r, 4); + + if (!(d->Res_L[n] == 0 && d->Res_R[n] == 0)) { + if (d->ms) + d->MS_Flag[n] = mpc_bits_read(r, 1); + Max_used_Band = n + 1; + } + } + + /****************************** SCFI ******************************/ + for ( n = 0; n < Max_used_Band; n++ ) { + if (d->Res_L[n]) + d->SCFI_L[n] = mpc_bits_huff_dec(r, mpc_table_HuffSCFI); + if (d->Res_R[n]) + d->SCFI_R[n] = mpc_bits_huff_dec(r, mpc_table_HuffSCFI); + } + + /**************************** SCF/DSCF ****************************/ + for ( n = 0; n < Max_used_Band; n++ ) { + mpc_int32_t * SCF = d->SCF_Index_L[n]; + mpc_uint32_t Res = d->Res_L[n], SCFI = d->SCFI_L[n]; + do { + if (Res) { + switch (SCFI) { + case 1: + idx = mpc_bits_huff_lut(r, & mpc_HuffDSCF); + SCF[0] = (idx!=8) ? SCF[2] + idx : (int) mpc_bits_read(r, 6); + idx = mpc_bits_huff_lut(r, & mpc_HuffDSCF); + SCF[1] = (idx!=8) ? SCF[0] + idx : (int) mpc_bits_read(r, 6); + SCF[2] = SCF[1]; + break; + case 3: + idx = mpc_bits_huff_lut(r, & mpc_HuffDSCF); + SCF[0] = (idx!=8) ? SCF[2] + idx : (int) mpc_bits_read(r, 6); + SCF[1] = SCF[0]; + SCF[2] = SCF[1]; + break; + case 2: + idx = mpc_bits_huff_lut(r, & mpc_HuffDSCF); + SCF[0] = (idx!=8) ? SCF[2] + idx : (int) mpc_bits_read(r, 6); + SCF[1] = SCF[0]; + idx = mpc_bits_huff_lut(r, & mpc_HuffDSCF); + SCF[2] = (idx!=8) ? SCF[1] + idx : (int) mpc_bits_read(r, 6); + break; + case 0: + idx = mpc_bits_huff_lut(r, & mpc_HuffDSCF); + SCF[0] = (idx!=8) ? SCF[2] + idx : (int) mpc_bits_read(r, 6); + idx = mpc_bits_huff_lut(r, & mpc_HuffDSCF); + SCF[1] = (idx!=8) ? SCF[0] + idx : (int) mpc_bits_read(r, 6); + idx = mpc_bits_huff_lut(r, & mpc_HuffDSCF); + SCF[2] = (idx!=8) ? SCF[1] + idx : (int) mpc_bits_read(r, 6); + break; + default: + return; + } + if (SCF[0] > 1024) + SCF[0] = 0x8080; + if (SCF[1] > 1024) + SCF[1] = 0x8080; + if (SCF[2] > 1024) + SCF[2] = 0x8080; + } + Res = d->Res_R[n]; + SCFI = d->SCFI_R[n]; + } while ( SCF == d->SCF_Index_L[n] && (SCF = d->SCF_Index_R[n])); + } + +// if (d->seeking == TRUE) +// return; + + /***************************** Samples ****************************/ + for ( n = 0; n < Max_used_Band; n++ ) { + mpc_int16_t *q = d->Q[n].L, Res = d->Res_L[n]; + do { + mpc_uint32_t nbit; + mpc_int32_t k, dc; + const mpc_lut_data *Table; + switch (Res) { + case -2: case -3: case -4: case -5: case -6: case -7: case -8: case -9: + case -10: case -11: case -12: case -13: case -14: case -15: case -16: case -17: case 0: + break; + case -1: + for (k=0; k<36; k++ ) { + mpc_uint32_t tmp = mpc_random_int(d); + q[k] = ((tmp >> 24) & 0xFF) + ((tmp >> 16) & 0xFF) + ((tmp >> 8) & 0xFF) + ((tmp >> 0) & 0xFF) - 510; + } + break; + case 1: + Table = & mpc_HuffQ[0][mpc_bits_read(r, 1)]; + for ( k = 0; k < 36; k += 3) { + idx = mpc_bits_huff_lut(r, Table); + q[k] = g_sv7_idx30[idx]; + q[k + 1] = g_sv7_idx31[idx]; + q[k + 2] = g_sv7_idx32[idx]; + } + break; + case 2: + Table = & mpc_HuffQ[1][mpc_bits_read(r, 1)]; + for ( k = 0; k < 36; k += 2) { + idx = mpc_bits_huff_lut(r, Table); + q[k] = g_sv7_idx50[idx]; + q[k + 1] = g_sv7_idx51[idx]; + } + break; + case 3: + case 4: + case 5: + case 6: + case 7: + Table = & mpc_HuffQ[Res - 1][mpc_bits_read(r, 1)]; + for ( k = 0; k < 36; k++ ) + q[k] = mpc_bits_huff_lut(r, Table); + break; + case 8: case 9: case 10: case 11: case 12: case 13: case 14: case 15: case 16: case 17: + nbit = Res_bit[Res]; + dc = Dc[Res]; + for ( k = 0; k < 36; k++ ) + q[k] = (mpc_int32_t)mpc_bits_read(r, nbit) - dc; + break; + default: + return; + } + + Res = d->Res_R[n]; + } while (q == d->Q[n].L && (q = d->Q[n].R)); + } +} + +static void mpc_decoder_read_bitstream_sv8(mpc_decoder * d, mpc_bits_reader * r, mpc_bool_t is_key_frame) +{ + mpc_int32_t n, Max_used_Band; + const mpc_can_data * Table, * Tables[2]; + + /***************************** Header *****************************/ + + if (is_key_frame == MPC_TRUE) { + Max_used_Band = mpc_bits_log_dec(r, d->max_band + 1); + } else { + Max_used_Band = d->last_max_band + mpc_bits_can_dec(r, & mpc_can_Bands); + if (Max_used_Band > 32) Max_used_Band -= 33; + } + d->last_max_band = Max_used_Band; + + if (Max_used_Band) { + d->Res_L[Max_used_Band-1] = mpc_bits_can_dec(r, & mpc_can_Res[0]); + d->Res_R[Max_used_Band-1] = mpc_bits_can_dec(r, & mpc_can_Res[0]); + if (d->Res_L[Max_used_Band-1] > 15) d->Res_L[Max_used_Band-1] -= 17; + if (d->Res_R[Max_used_Band-1] > 15) d->Res_R[Max_used_Band-1] -= 17; + for ( n = Max_used_Band - 2; n >= 0; n--) { + d->Res_L[n] = mpc_bits_can_dec(r, & mpc_can_Res[d->Res_L[n + 1] > 2]) + d->Res_L[n + 1]; + if (d->Res_L[n] > 15) d->Res_L[n] -= 17; + d->Res_R[n] = mpc_bits_can_dec(r, & mpc_can_Res[d->Res_R[n + 1] > 2]) + d->Res_R[n + 1]; + if (d->Res_R[n] > 15) d->Res_R[n] -= 17; + } + + if (d->ms) { + mpc_uint_t cnt = 0, tot = 0; + mpc_uint32_t tmp = 0; + for( n = 0; n < Max_used_Band; n++) + if ( d->Res_L[n] != 0 || d->Res_R[n] != 0 ) + tot++; + cnt = mpc_bits_log_dec(r, tot); + if (cnt != 0 && cnt != tot) + tmp = mpc_bits_enum_dec(r, mini(cnt, tot-cnt), tot); + if (cnt * 2 > tot) tmp = ~tmp; + for( n = Max_used_Band - 1; n >= 0; n--) + if ( d->Res_L[n] != 0 || d->Res_R[n] != 0 ) { + d->MS_Flag[n] = tmp & 1; + tmp >>= 1; + } + } + } + + for( n = Max_used_Band; n <= d->max_band; n++) + d->Res_L[n] = d->Res_R[n] = 0; + + /****************************** SCFI ******************************/ + if (is_key_frame == MPC_TRUE){ + for( n = 0; n < 32; n++) + d->DSCF_Flag_L[n] = d->DSCF_Flag_R[n] = 1; // new block -> force key frame + } + + Tables[0] = & mpc_can_SCFI[0]; + Tables[1] = & mpc_can_SCFI[1]; + for ( n = 0; n < Max_used_Band; n++ ) { + int tmp = 0, cnt = -1; + if (d->Res_L[n]) cnt++; + if (d->Res_R[n]) cnt++; + if (cnt >= 0) { + tmp = mpc_bits_can_dec(r, Tables[cnt]); + if (d->Res_L[n]) d->SCFI_L[n] = tmp >> (2 * cnt); + if (d->Res_R[n]) d->SCFI_R[n] = tmp & 3; + } + } + + /**************************** SCF/DSCF ****************************/ + + for ( n = 0; n < Max_used_Band; n++ ) { + mpc_int32_t * SCF = d->SCF_Index_L[n]; + mpc_uint32_t Res = d->Res_L[n], SCFI = d->SCFI_L[n]; + mpc_bool_t * DSCF_Flag = &d->DSCF_Flag_L[n]; + + do { + if ( Res ) { + int m; + if (*DSCF_Flag == 1) { + SCF[0] = (mpc_int32_t)mpc_bits_read(r, 7) - 6; + *DSCF_Flag = 0; + } else { + mpc_uint_t tmp = mpc_bits_can_dec(r, & mpc_can_DSCF[1]); + if (tmp == 64) + tmp += mpc_bits_read(r, 6); + SCF[0] = ((SCF[2] - 25 + tmp) & 127) - 6; + } + for( m = 0; m < 2; m++){ + if (((SCFI << m) & 2) == 0) { + mpc_uint_t tmp = mpc_bits_can_dec(r, & mpc_can_DSCF[0]); + if (tmp == 31) + tmp = 64 + mpc_bits_read(r, 6); + SCF[m + 1] = ((SCF[m] - 25 + tmp) & 127) - 6; + } else + SCF[m + 1] = SCF[m]; + } + } + Res = d->Res_R[n]; + SCFI = d->SCFI_R[n]; + DSCF_Flag = &d->DSCF_Flag_R[n]; + } while ( SCF == d->SCF_Index_L[n] && (SCF = d->SCF_Index_R[n])); + } + + /***************************** Samples ****************************/ + for ( n = 0; n < Max_used_Band; n++ ) { + mpc_int16_t *q = d->Q[n].L, Res = d->Res_L[n]; + static const mpc_uint32_t thres[] = {0, 0, 3, 0, 0, 1, 3, 4, 8}; + do { + mpc_uint32_t nbit; + mpc_uint32_t k = 0, idx = 1, dc; + if (Res != 0) { + if (Res == 2) { + Tables[0] = & mpc_can_Q [0][0]; + Tables[1] = & mpc_can_Q [0][1]; + idx = 2 * thres[Res]; + for ( ; k < 36; k += 3) { + int tmp = mpc_bits_can_dec(r, Tables[idx > thres[Res]]); + q[k] = g_sv8_idx50[tmp]; + q[k + 1] = g_sv8_idx51[tmp]; + q[k + 2] = g_sv8_idx52[tmp]; + idx = (idx >> 1) + g_sv8_HuffQ2_var[tmp]; + } + } else if (Res == 1) { + Table = & mpc_can_Q1; + for( ; k < 36; ){ + mpc_uint32_t kmax = k + 18; + mpc_uint_t cnt = mpc_bits_can_dec(r, Table); + idx = 0; + if (cnt > 0 && cnt < 18) + idx = mpc_bits_enum_dec(r, cnt <= 9 ? cnt : 18 - cnt, 18); + if (cnt > 9) idx = ~idx; + for ( ; k < kmax; k++) { + q[k] = 0; + if ( idx & (1 << 17) ) + q[k] = (mpc_bits_read(r, 1) << 1) - 1; + idx <<= 1; + } + } + } else if (Res == -1) { + for ( ; k<36; k++ ) { + mpc_uint32_t tmp = mpc_random_int(d); + q[k] = ((tmp >> 24) & 0xFF) + ((tmp >> 16) & 0xFF) + ((tmp >> 8) & 0xFF) + ((tmp >> 0) & 0xFF) - 510; + } + } else if (Res <= 4) { + Table = & mpc_can_Q[1][Res - 3]; + for ( ; k < 36; k += 2 ) { + union { + mpc_int8_t sym; + struct { mpc_int8_t s1:4, s2:4; }; + } tmp; + tmp.sym = mpc_bits_can_dec(r, Table); + q[k] = tmp.s1; + q[k + 1] = tmp.s2; + } + } else if (Res <= 8) { + Tables[0] = & mpc_can_Q [Res - 3][0]; + Tables[1] = & mpc_can_Q [Res - 3][1]; + idx = 2 * thres[Res]; + for ( ; k < 36; k++ ) { + q[k] = mpc_bits_can_dec(r, Tables[idx > thres[Res]]); + idx = (idx >> 1) + absi(q[k]); + } + } else if (Res == 9) { + dc = Dc[Res]; + for ( ; k < 36; k++ ) { + q[k] = (unsigned char) mpc_bits_can_dec(r, & mpc_can_Q9up); + q[k] -= dc; + } + } else { + nbit = (Res - 9); + dc = Dc[Res]; + for ( ; k < 36; k++ ) { + q[k] = (unsigned char) mpc_bits_can_dec(r, & mpc_can_Q9up); + q[k] = (q[k] << nbit) | mpc_bits_read(r, nbit); + q[k] -= dc; + } + } + } + + Res = d->Res_R[n]; + } while (q == d->Q[n].L && (q = d->Q[n].R)); + } +} + diff --git a/lib/rbcodec/codecs/libmusepack/mpc_demux.c b/lib/rbcodec/codecs/libmusepack/mpc_demux.c new file mode 100644 index 0000000000..9523163c0e --- /dev/null +++ b/lib/rbcodec/codecs/libmusepack/mpc_demux.c @@ -0,0 +1,730 @@ +/* + Copyright (c) 2005-2009, The Musepack Development Team + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + + * Neither the name of the The Musepack Development Team nor the + names of its contributors may be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include +#include +#include "streaminfo.h" +#include "mpcdec.h" +#include "internal.h" +#include "decoder.h" +#include "huffman.h" +#include "mpc_bits_reader.h" + +#include + +/// maximum number of seek points in the table. The distance between points will +/// be adapted so this value is never exceeded. +#define MAX_SEEK_TABLE_SIZE 8192 + +// defines +#define MAX_BUFFER_SIZE (DEMUX_BUFFER_SIZE + MAX_FRAME_SIZE) + +// globals +static mpc_uint8_t g_buffer[MAX_BUFFER_SIZE] IBSS_ATTR_MPC_BITBUFFER; +static mpc_seek_t g_seek_table[MAX_SEEK_TABLE_SIZE]; +static mpc_demux g_mpc_demux IBSS_ATTR; + +enum { + MPC_BUFFER_SWAP = 1, + MPC_BUFFER_FULL = 2, +}; + +static void mpc_demux_clear_buff(mpc_demux * d) +{ + d->bytes_total = 0; + d->bits_reader.buff = d->buffer; + d->bits_reader.count = 8; + d->bits_reader.buffered_addr = 0; + d->bits_reader.buffered_code = 0; + d->block_bits = 0; + d->block_frames = 0; + memset(d->buffer, 0, sizeof(g_buffer)); +} + +static mpc_uint32_t +mpc_demux_fill(mpc_demux * d, mpc_uint32_t min_bytes, int flags) +{ + mpc_uint32_t unread_bytes = d->bytes_total + d->buffer - d->bits_reader.buff + - ((8 - d->bits_reader.count) >> 3); + mpc_int32_t offset = 0; + + if (min_bytes == 0 || min_bytes > MAX_BUFFER_SIZE || + (unread_bytes < min_bytes && flags & MPC_BUFFER_FULL)) + min_bytes = MAX_BUFFER_SIZE; + + if (unread_bytes < min_bytes) { + mpc_uint32_t bytes2read = min_bytes - unread_bytes; + mpc_uint32_t bytes_free = MAX_BUFFER_SIZE - d->bytes_total; + + if (flags & MPC_BUFFER_SWAP) { + bytes2read &= -1 << 2; + offset = (unread_bytes + 3) & ( -1 << 2); + offset -= unread_bytes; + } + + if (bytes2read > bytes_free) { + if (d->bits_reader.count == 0) { + d->bits_reader.count = 8; + d->bits_reader.buff++; + } + memmove(d->buffer + offset, d->bits_reader.buff, unread_bytes); + d->bits_reader.buff = d->buffer + offset; + d->bytes_total = unread_bytes + offset; + /* reset Coldfire optimized read when rebuffering */ + d->bits_reader.buffered_addr = 0; + d->bits_reader.buffered_code = 0; + } + bytes2read = d->r->read(d->r, d->buffer + d->bytes_total, bytes2read); + if (flags & MPC_BUFFER_SWAP){ + unsigned int i, * tmp = (unsigned int *) (d->buffer + d->bytes_total); + for(i = 0 ;i < (bytes2read >> 2); i++) + tmp[i] = swap32(tmp[i]); + } + d->bytes_total += bytes2read; + return bytes2read; + } + + return (mpc_uint32_t) -1; +} + +/** + * seek to a bit position in the stream + * @param d demuxer context + * @param fpos position in the stream in bits from the beginning of mpc datas + * @param min_bytes number of bytes to load after seeking + */ +static mpc_status +mpc_demux_seek(mpc_demux * d, mpc_seek_t fpos, mpc_uint32_t min_bytes) { + // d->bits_reader.buff - d->buffer = current byte position within buffer + // d->bytes_total = buffer is filled with bytes_total bytes + // fpos = desired file position in bit (not byte) + // buf_fpos = desired byte position within buffer + mpc_seek_t next_pos = fpos>>3; + mpc_int_t buf_fpos = next_pos - d->r->tell(d->r) + d->bytes_total; + + // is desired byte position within lower and upper boundaries of buffer? + if (buf_fpos >= 0 && buf_fpos + min_bytes <= d->bytes_total) { + // desired bytes are available in current buffer + d->bits_reader.buff += buf_fpos - (d->bits_reader.buff - d->buffer); + d->bits_reader.count = 8 - (fpos & 7); + } else { + // buffer needs to be refilled + if (d->si.stream_version == 7) + next_pos = ((next_pos - d->si.header_position) & (-1 << 2)) + d->si.header_position; + buf_fpos = fpos - (next_pos << 3); + if (!d->r->seek(d->r, (mpc_int32_t) next_pos)) + return MPC_STATUS_FAIL; + mpc_demux_clear_buff(d); + if (d->si.stream_version == 7) + mpc_demux_fill(d, MAX_BUFFER_SIZE, MPC_BUFFER_FULL | MPC_BUFFER_SWAP); + else + mpc_demux_fill(d, MAX_BUFFER_SIZE, MPC_BUFFER_FULL); + d->bits_reader.buff += buf_fpos >> 3; + d->bits_reader.count = 8 - (buf_fpos & 7); + } + + return MPC_STATUS_OK; +} + +/** + * return the current position in the stream (in bits) from the beginning + * of the file + * @param d demuxer context + * @return current stream position in bits + */ +static mpc_seek_t mpc_demux_pos(mpc_demux * d) +{ + return (((mpc_seek_t)(d->r->tell(d->r)) - d->bytes_total + + d->bits_reader.buff - d->buffer) << 3) + 8 - d->bits_reader.count; +} + +/** + * Searches for a ID3v2-tag and reads the length (in bytes) of it. + * + * @param d demuxer context + * @return size of tag, in bytes + * @return MPC_STATUS_FAIL on errors of any kind + */ +static mpc_int32_t mpc_demux_skip_id3v2(mpc_demux * d) +{ + mpc_uint8_t tmp [4]; + mpc_bool_t footerPresent; // ID3v2.4-flag + mpc_int32_t size; + + // we must be at the beginning of the stream + mpc_demux_fill(d, 3, 0); + + // check id3-tag + if ( 0 != memcmp( d->bits_reader.buff, "ID3", 3 ) ) + return 0; + + mpc_demux_fill(d, 10, 0); + + mpc_bits_read(&d->bits_reader, 24); // read ID3 + mpc_bits_read(&d->bits_reader, 16); // read tag version + + tmp[0] = mpc_bits_read(&d->bits_reader, 8); // read flags + footerPresent = tmp[0] & 0x10; + if ( tmp[0] & 0x0F ) + return MPC_STATUS_FAIL; // not (yet???) allowed + + tmp[0] = mpc_bits_read(&d->bits_reader, 8); // read size + tmp[1] = mpc_bits_read(&d->bits_reader, 8); // read size + tmp[2] = mpc_bits_read(&d->bits_reader, 8); // read size + tmp[3] = mpc_bits_read(&d->bits_reader, 8); // read size + + if ( (tmp[0] | tmp[1] | tmp[2] | tmp[3]) & 0x80 ) + return MPC_STATUS_FAIL; // not allowed + + // read headerSize (syncsave: 4 * $0xxxxxxx = 28 significant bits) + size = tmp[0] << 21; + size |= tmp[1] << 14; + size |= tmp[2] << 7; + size |= tmp[3]; + + size += 10; //header + + if ( footerPresent ) size += 10; + + // This is called before file headers get read, streamversion etc isn't yet known, demuxing isn't properly initialized and we can't call mpc_demux_seek() from here. + mpc_demux_clear_buff(d); + if (!d->r->seek(d->r, size)) + return MPC_STATUS_FAIL; + + return size; +} + +static mpc_status mpc_demux_seek_init(mpc_demux * d) +{ + size_t seek_table_size; + if (d->seek_table != 0) + return MPC_STATUS_OK; + + d->seek_pwr = 6; + if (d->si.block_pwr > d->seek_pwr) + d->seek_pwr = d->si.block_pwr; + seek_table_size = (2 + d->si.samples / (MPC_FRAME_LENGTH << d->seek_pwr)); + while (seek_table_size > MAX_SEEK_TABLE_SIZE) { + d->seek_pwr++; + seek_table_size = (2 + d->si.samples / (MPC_FRAME_LENGTH << d->seek_pwr)); + } + d->seek_table = g_seek_table; + if (d->seek_table == 0) + return MPC_STATUS_FAIL; + d->seek_table[0] = (mpc_seek_t)mpc_demux_pos(d); + d->seek_table_size = 1; + + return MPC_STATUS_OK; +} + +/* rockbox: do not use +static mpc_status mpc_demux_ST(mpc_demux * d) +{ + mpc_uint64_t tmp; + mpc_seek_t * table, last[2]; + mpc_bits_reader r = d->bits_reader; + mpc_uint_t i, diff_pwr = 0, mask; + mpc_uint32_t file_table_size; + + if (d->seek_table != 0) + return MPC_STATUS_OK; + + mpc_bits_get_size(&r, &tmp); + file_table_size = (mpc_seek_t) tmp; + d->seek_pwr = d->si.block_pwr + mpc_bits_read(&r, 4); + + tmp = 2 + d->si.samples / (MPC_FRAME_LENGTH << d->seek_pwr); + while (tmp > MAX_SEEK_TABLE_SIZE) { + d->seek_pwr++; + diff_pwr++; + tmp = 2 + d->si.samples / (MPC_FRAME_LENGTH << d->seek_pwr); + } + if ((file_table_size >> diff_pwr) > tmp) + file_table_size = tmp << diff_pwr; + d->seek_table = g_seek_table; + d->seek_table_size = (file_table_size + ((1 << diff_pwr) - 1)) >> diff_pwr; + + table = d->seek_table; + mpc_bits_get_size(&r, &tmp); + table[0] = last[0] = (mpc_seek_t) (tmp + d->si.header_position) * 8; + + if (d->seek_table_size == 1) + return MPC_STATUS_OK; + + mpc_bits_get_size(&r, &tmp); + last[1] = (mpc_seek_t) (tmp + d->si.header_position) * 8; + if (diff_pwr == 0) table[1] = last[1]; + + mask = (1 << diff_pwr) - 1; + for (i = 2; i < file_table_size; i++) { + int code = mpc_bits_golomb_dec(&r, 12); + if (code & 1) + code = -(code & (-1 << 1)); + code <<= 2; + last[i & 1] = code + 2 * last[(i-1) & 1] - last[i & 1]; + if ((i & mask) == 0) + table[i >> diff_pwr] = last[i & 1]; + } + return MPC_STATUS_OK; +} + +static mpc_status mpc_demux_SP(mpc_demux * d, int size, int block_size) +{ + mpc_seek_t cur; + mpc_uint64_t ptr; + mpc_block b; + int st_head_size; + + cur = mpc_demux_pos(d); + mpc_bits_get_size(&d->bits_reader, &ptr); + MPC_AUTO_FAIL( mpc_demux_seek(d, (ptr - size) * 8 + cur, 11) ); + st_head_size = mpc_bits_get_block(&d->bits_reader, &b); + if (memcmp(b.key, "ST", 2) == 0) { + d->chap_pos = (ptr - size + b.size + st_head_size) * 8 + cur; + d->chap_nb = -1; + if (mpc_demux_fill(d, (mpc_uint32_t) b.size, 0) < b.size) + return MPC_STATUS_FAIL; + MPC_AUTO_FAIL( mpc_demux_ST(d) ); + } + return mpc_demux_seek(d, cur, 11 + block_size); +} +*/ +/* rockbox: not used +static void mpc_demux_chap_empty(mpc_demux * d) { + free(d->chap); d->chap = 0; + d->chap_nb = 0; // -1 for undefined, 0 for no chapters + d->chap_pos = 0; +} +*/ +/* rockbox: not used +static mpc_status mpc_demux_chap_find_inner(mpc_demux * d) +{ + mpc_block b; + int tag_size = 0, chap_size = 0, size, i = 0; + + d->chap_nb = 0; + + if (d->si.stream_version < 8) + return MPC_STATUS_OK; + + if (d->chap_pos == 0) { + mpc_uint64_t cur_pos = (d->si.header_position + 4) * 8; + MPC_AUTO_FAIL( mpc_demux_seek(d, cur_pos, 11) ); // seek to the beginning of the stream + size = mpc_bits_get_block(&d->bits_reader, &b); + while (memcmp(b.key, "SE", 2) != 0) { + mpc_uint64_t new_pos = cur_pos + (size + b.size) * 8; + MPC_AUTO_FAIL(mpc_check_key(b.key)); + + if (memcmp(b.key, "CT", 2) == 0) { + if (d->chap_pos == 0) d->chap_pos = cur_pos; + } else { + d->chap_pos = 0; + } + if (new_pos <= cur_pos) + return MPC_STATUS_FAIL; + cur_pos = new_pos; + + MPC_AUTO_FAIL( mpc_demux_seek(d, cur_pos, 11) ); + size = mpc_bits_get_block(&d->bits_reader, &b); + } + if (d->chap_pos == 0) + d->chap_pos = cur_pos; + } + + mpc_demux_seek(d, d->chap_pos, 20); + size = mpc_bits_get_block(&d->bits_reader, &b); + while (memcmp(b.key, "CT", 2) == 0) { + mpc_uint64_t chap_sample; + d->chap_nb++; + chap_size += size; + size = mpc_bits_get_size(&d->bits_reader, &chap_sample) + 4; + chap_size += size; + tag_size += b.size - size; + MPC_AUTO_FAIL( mpc_demux_seek(d, d->chap_pos + (chap_size + tag_size) * 8, 20) ); + size = mpc_bits_get_block(&d->bits_reader, &b); + } + + if (d->chap_nb > 0) { + char * ptag; + d->chap = malloc(sizeof(mpc_chap_info) * d->chap_nb + tag_size); + if (d->chap == 0) + return MPC_STATUS_FAIL; + + ptag = (char*)(d->chap + d->chap_nb); + + MPC_AUTO_FAIL( mpc_demux_seek(d, d->chap_pos, 11) ); + size = mpc_bits_get_block(&d->bits_reader, &b); + while (memcmp(b.key, "CT", 2) == 0) { + mpc_uint_t tmp_size; + char * tmp_ptag = ptag; + if (mpc_demux_fill(d, 11 + (mpc_uint32_t) b.size, 0) < b.size) + return MPC_STATUS_FAIL; + size = mpc_bits_get_size(&d->bits_reader, &d->chap[i].sample) + 4; + d->chap[i].gain = (mpc_uint16_t) mpc_bits_read(&d->bits_reader, 16); + d->chap[i].peak = (mpc_uint16_t) mpc_bits_read(&d->bits_reader, 16); + + tmp_size = b.size - size; + do { + mpc_uint_t rd_size = tmp_size; + mpc_uint8_t * tmp_buff = d->bits_reader.buff + ((8 - d->bits_reader.count) >> 3); + mpc_uint32_t avail_bytes = d->bytes_total + d->buffer - tmp_buff; + rd_size = mini(rd_size, avail_bytes); + memcpy(tmp_ptag, tmp_buff, rd_size); + tmp_size -= rd_size; + tmp_ptag += rd_size; + d->bits_reader.buff += rd_size; + mpc_demux_fill(d, tmp_size, 0); + } while (tmp_size > 0); + + d->chap[i].tag_size = b.size - size; + d->chap[i].tag = ptag; + ptag += b.size - size; + i++; + size = mpc_bits_get_block(&d->bits_reader, &b); + } + } + + d->bits_reader.buff -= size; + return MPC_STATUS_OK; +} +*/ +/* rockbox: not used +static mpc_status mpc_demux_chap_find(mpc_demux * d) { + mpc_status s = mpc_demux_chap_find_inner(d); + if (MPC_IS_FAILURE(s)) + mpc_demux_chap_empty(d); + return s; +} +*/ +/** + * Gets the number of chapters in the stream + * @param d pointer to a musepack demuxer + * @return the number of chapters found in the stream + */ +/* rockbox: not used +mpc_int_t mpc_demux_chap_nb(mpc_demux * d) +{ + if (d->chap_nb == -1) + mpc_demux_chap_find(d); + return d->chap_nb; +} +*/ +/** + * Gets datas associated to a given chapter + * The chapter tag is an APEv2 tag without the preamble + * @param d pointer to a musepack demuxer + * @param chap_nb chapter number you want datas (from 0 to mpc_demux_chap_nb(d) - 1) + * @return the chapter information structure + */ +/* rockbox: not used +mpc_chap_info const * mpc_demux_chap(mpc_demux * d, int chap_nb) +{ + if (d->chap_nb == -1) + mpc_demux_chap_find(d); + if (chap_nb >= d->chap_nb || chap_nb < 0) + return 0; + return &d->chap[chap_nb]; +} +*/ + +static mpc_status mpc_demux_header(mpc_demux * d) +{ + char magic[4]; + + d->si.pns = 0xFF; +/* rockbox: not used + d->si.profile_name = "n.a."; +*/ + // get header position + d->si.header_position = mpc_demux_skip_id3v2(d); + if(d->si.header_position < 0) + return MPC_STATUS_FAIL; + + d->si.tag_offset = d->si.total_file_length = d->r->get_size(d->r); + + mpc_demux_fill(d, 4, 0); + magic[0] = mpc_bits_read(&d->bits_reader, 8); + magic[1] = mpc_bits_read(&d->bits_reader, 8); + magic[2] = mpc_bits_read(&d->bits_reader, 8); + magic[3] = mpc_bits_read(&d->bits_reader, 8); + + if (memcmp(magic, "MP+", 3) == 0) { + d->si.stream_version = magic[3] & 15; + d->si.pns = magic[3] >> 4; + if (d->si.stream_version != 7) + return MPC_STATUS_FAIL; + if (mpc_demux_fill(d, 6 * 4, MPC_BUFFER_SWAP) < 6 * 4) // header block size + endian convertion + return MPC_STATUS_FAIL; + MPC_AUTO_FAIL( streaminfo_read_header_sv7(&d->si, &d->bits_reader) ); + } else if (memcmp(magic, "MPCK", 4) == 0) { + mpc_block b; + int size; + mpc_demux_fill(d, 11, 0); // max header block size + size = mpc_bits_get_block(&d->bits_reader, &b); + while( memcmp(b.key, "AP", 2) != 0 ){ // scan all blocks until audio + if (mpc_check_key(b.key) != MPC_STATUS_OK) + return MPC_STATUS_FAIL; + if (b.size > (mpc_uint64_t) MAX_BUFFER_SIZE - 11) + return MPC_STATUS_FAIL; + + if (mpc_demux_fill(d, 11 + (mpc_uint32_t) b.size, 0) <= b.size) + return MPC_STATUS_FAIL; + + if (memcmp(b.key, "SH", 2) == 0) { + MPC_AUTO_FAIL( streaminfo_read_header_sv8(&d->si, &d->bits_reader, (mpc_uint32_t) b.size) ); + } else if (memcmp(b.key, "RG", 2) == 0) { + streaminfo_gain(&d->si, &d->bits_reader); + } else if (memcmp(b.key, "EI", 2) == 0) { + streaminfo_encoder_info(&d->si, &d->bits_reader); +/* rockbox: do not use + } else if (memcmp(b.key, "SO", 2) == 0) { + MPC_AUTO_FAIL( mpc_demux_SP(d, size, (mpc_uint32_t) b.size) ); + } else if (memcmp(b.key, "ST", 2) == 0) { + MPC_AUTO_FAIL( mpc_demux_ST(d) ); +*/ + } + d->bits_reader.buff += b.size; + size = mpc_bits_get_block(&d->bits_reader, &b); + } + d->bits_reader.buff -= size; + if (d->si.stream_version == 0) // si not initialized !!! + return MPC_STATUS_FAIL; + } else { + return MPC_STATUS_FAIL; + } + + return MPC_STATUS_OK; +} + +mpc_demux * mpc_demux_init(mpc_reader * p_reader) +{ + mpc_demux* p_tmp = &g_mpc_demux; + + if (p_tmp != 0) { + memset(p_tmp, 0, sizeof(mpc_demux)); + p_tmp->buffer = g_buffer; + p_tmp->r = p_reader; +/* rockbox: not used + p_tmp->chap_nb = -1; +*/ + mpc_demux_clear_buff(p_tmp); + if (mpc_demux_header(p_tmp) == MPC_STATUS_OK && + mpc_demux_seek_init(p_tmp) == MPC_STATUS_OK) { + p_tmp->d = mpc_decoder_init(&p_tmp->si); + } else { + if (p_tmp->seek_table) + memset(p_tmp->seek_table, 0, sizeof(g_seek_table)); + p_tmp = 0; + } + } + + return p_tmp; +} + +/* rockbox: not used +void mpc_demux_exit(mpc_demux * d) +{ + mpc_decoder_exit(d->d); + memset(d->seek_table, 0, sizeof(g_seek_table)); +} +*/ + +void mpc_demux_get_info(mpc_demux * d, mpc_streaminfo * i) +{ + memcpy(i, &d->si, sizeof d->si); +} + +static mpc_status mpc_demux_decode_inner(mpc_demux * d, mpc_frame_info * i) +{ + mpc_bits_reader r; + if (d->si.stream_version >= 8) { + i->is_key_frame = MPC_FALSE; + + if (d->block_frames == 0) { + mpc_block b = {{0,0},0}; + d->bits_reader.count &= -8; + if (d->d->decoded_samples == (d->seek_table_size << d->seek_pwr) * MPC_FRAME_LENGTH) { + d->seek_table[d->seek_table_size] = (mpc_seek_t) mpc_demux_pos(d); + d->seek_table_size ++; + } + mpc_demux_fill(d, 11, MPC_BUFFER_FULL); // max header block size + mpc_bits_get_block(&d->bits_reader, &b); + while( memcmp(b.key, "AP", 2) != 0 ) { // scan all blocks until audio + MPC_AUTO_FAIL( mpc_check_key(b.key) ); + + if (memcmp(b.key, "SE", 2) == 0) { // end block + i->bits = -1; + return MPC_STATUS_OK; + } + + if (mpc_demux_fill(d, 11 + (mpc_uint32_t) b.size, MPC_BUFFER_FULL) < b.size) + return MPC_STATUS_FAIL; + + d->bits_reader.buff += b.size; + mpc_bits_get_block(&d->bits_reader, &b); + } + d->block_bits = (mpc_uint32_t) b.size * 8; + d->block_frames = 1 << d->si.block_pwr; + i->is_key_frame = MPC_TRUE; + } + mpc_demux_fill(d, MAX_FRAME_SIZE, MPC_BUFFER_FULL); + r = d->bits_reader; + mpc_decoder_decode_frame(d->d, &d->bits_reader, i); + d->block_bits -= ((d->bits_reader.buff - r.buff) << 3) + r.count - d->bits_reader.count; + d->block_frames--; + if (d->block_bits < 0 || (d->block_frames == 0 && d->block_bits > 7)) + return MPC_STATUS_FAIL; + } else { + if (d->d->decoded_samples == (d->seek_table_size << d->seek_pwr) * MPC_FRAME_LENGTH) { + d->seek_table[d->seek_table_size] = (mpc_seek_t) mpc_demux_pos(d); + d->seek_table_size ++; + } + mpc_demux_fill(d, MAX_FRAME_SIZE, MPC_BUFFER_FULL | MPC_BUFFER_SWAP); + d->block_bits = (mpc_int_t) mpc_bits_read(&d->bits_reader, 20); // read frame size + if (MPC_FRAME_LENGTH > d->d->samples - d->d->decoded_samples - 1) d->block_bits += 11; // we will read last frame size + r = d->bits_reader; + mpc_decoder_decode_frame(d->d, &d->bits_reader, i); + if (i->bits != -1 && d->block_bits != (mpc_int32_t)(((d->bits_reader.buff - r.buff) << 3) + r.count - d->bits_reader.count)) + return MPC_STATUS_FAIL; + } + if (i->bits != -1 && d->buffer + d->bytes_total < d->bits_reader.buff + ((8 - d->bits_reader.count) >> 3)) + return MPC_STATUS_FAIL; + + return MPC_STATUS_OK; +} + +mpc_status mpc_demux_decode(mpc_demux * d, mpc_frame_info * i) { + mpc_status s = mpc_demux_decode_inner(d, i); + if (MPC_IS_FAILURE(s)) + i->bits = -1; // we pretend it's end of file + return s; +} + +/* rockbox: not used +mpc_status mpc_demux_seek_second(mpc_demux * d, double seconds) +{ + return mpc_demux_seek_sample(d, (mpc_int64_t)(seconds * (double)d->si.sample_freq + 0.5)); +} +*/ + +mpc_status mpc_demux_seek_sample(mpc_demux * d, mpc_uint64_t destsample) +{ + mpc_uint32_t fwd, samples_to_skip, i; + mpc_uint32_t block_samples = MPC_FRAME_LENGTH << d->si.block_pwr; + mpc_seek_t fpos; + + destsample += d->si.beg_silence; + if (destsample > d->si.samples) destsample = d->si.samples; + fwd = (mpc_uint32_t) (destsample / block_samples); + samples_to_skip = MPC_DECODER_SYNTH_DELAY + + (mpc_uint32_t) (destsample % block_samples); + if (d->si.stream_version == 7) { + if (fwd > 32) { + fwd -= 32; + samples_to_skip += MPC_FRAME_LENGTH * 32; + } else { + samples_to_skip += MPC_FRAME_LENGTH * fwd; + fwd = 0; + } + } + + i = fwd >> (d->seek_pwr - d->si.block_pwr); + if (i >= d->seek_table_size) + i = d->seek_table_size - 1; + fpos = d->seek_table[i]; + i <<= d->seek_pwr - d->si.block_pwr; + d->d->decoded_samples = i * block_samples; + + if (d->si.stream_version >= 8) { + mpc_block b; + int size; + mpc_demux_seek(d, fpos, 11); + size = mpc_bits_get_block(&d->bits_reader, &b); + while(i < fwd) { + if (memcmp(b.key, "AP", 2) == 0) { + if (d->d->decoded_samples == (d->seek_table_size << d->seek_pwr) * MPC_FRAME_LENGTH) { + d->seek_table[d->seek_table_size] = (mpc_seek_t) mpc_demux_pos(d) - 8 * size; + d->seek_table_size ++; + } + d->d->decoded_samples += block_samples; + i++; + } + fpos += ((mpc_uint32_t)b.size + size) * 8; + mpc_demux_seek(d, fpos, 11); + size = mpc_bits_get_block(&d->bits_reader, &b); + } + d->bits_reader.buff -= size; + } else { + mpc_decoder_reset_scf(d->d, fwd != 0); + mpc_demux_seek(d, fpos, 4); + for( ; i < fwd; i++){ + if (d->d->decoded_samples == (d->seek_table_size << d->seek_pwr) * MPC_FRAME_LENGTH) { + d->seek_table[d->seek_table_size] = (mpc_seek_t) mpc_demux_pos(d); + d->seek_table_size ++; + } + d->d->decoded_samples += block_samples; + fpos += mpc_bits_read(&d->bits_reader, 20) + 20; + mpc_demux_seek(d, fpos, 4); + } + } + d->d->samples_to_skip = samples_to_skip; + return MPC_STATUS_OK; +} + +/* rockbox: not used +void mpc_set_replay_level(mpc_demux * d, float level, mpc_bool_t use_gain, + mpc_bool_t use_title, mpc_bool_t clip_prevention) +{ + float peak = (float) ( use_title ? d->si.peak_title : d->si.peak_album ); + float gain = (float) ( use_title ? d->si.gain_title : d->si.gain_album ); + + if(!use_gain && !clip_prevention) + return; + + if(!peak) + peak = 1.; + else + peak = (float) ( (1 << 15) / pow(10, peak / (20 * 256)) ); + + if(!gain) + gain = 1.; + else + gain = (float) pow(10, (level - gain / 256) / 20); + + if(clip_prevention && (peak < gain || !use_gain)) + gain = peak; + + mpc_decoder_scale_output(d->d, gain); +} +*/ diff --git a/lib/rbcodec/codecs/libmusepack/mpc_types.h b/lib/rbcodec/codecs/libmusepack/mpc_types.h new file mode 100644 index 0000000000..0e7aa9d2c3 --- /dev/null +++ b/lib/rbcodec/codecs/libmusepack/mpc_types.h @@ -0,0 +1,145 @@ +/* + Copyright (c) 2005-2009, The Musepack Development Team + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + + * Neither the name of the The Musepack Development Team nor the + names of its contributors may be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +#ifndef _MPC_TYPES_H_ +#define _MPC_TYPES_H_ +#ifdef WIN32 +#pragma once +#endif + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _MSC_VER +typedef __int8 mpc_int8_t; +typedef unsigned __int8 mpc_uint8_t; +typedef __int16 mpc_int16_t; +typedef unsigned __int16 mpc_uint16_t; +typedef __int32 mpc_int32_t; +typedef unsigned __int32 mpc_uint32_t; +typedef __int64 mpc_int64_t; +typedef unsigned __int64 mpc_uint64_t; +#define mpc_inline __inline +#else +typedef signed char mpc_int8_t; +typedef unsigned char mpc_uint8_t; +typedef short mpc_int16_t; +typedef unsigned short mpc_uint16_t; +typedef int mpc_int32_t; +typedef unsigned int mpc_uint32_t; +typedef long long mpc_int64_t; +typedef unsigned long long mpc_uint64_t; +#define mpc_inline inline +#endif + +typedef int mpc_int_t; +typedef unsigned int mpc_uint_t; +typedef size_t mpc_size_t; +typedef mpc_uint8_t mpc_bool_t; + +// #define LONG_SEEK_TABLE +#ifdef LONG_SEEK_TABLE // define as needed (mpc_uint32_t supports files up to 512 MB) +typedef mpc_uint64_t mpc_seek_t; +#else +typedef mpc_uint32_t mpc_seek_t; +#endif + +# define mpc_int64_min -9223372036854775808ll +# define mpc_int64_max 9223372036854775807ll + +typedef struct mpc_quantizer { + mpc_int16_t L [36]; + mpc_int16_t R [36]; +} mpc_quantizer; + +/// Libmpcdec error codes +typedef enum mpc_status { + // Success. + MPC_STATUS_OK = 0, + // Generic failure (I/O error or invalid file). + MPC_STATUS_FAIL = -1 +} mpc_status; + +#define MPC_FIXED_POINT +#define MPC_FIXED_POINT_SHIFT 16 + +#ifdef MPC_FIXED_POINT +# define MPC_FIXED_POINT_FRACTPART 14 +# define MPC_FIXED_POINT_SCALE_SHIFT (MPC_FIXED_POINT_SHIFT + MPC_FIXED_POINT_FRACTPART) +# define MPC_FIXED_POINT_SCALE (1 << (MPC_FIXED_POINT_SCALE_SHIFT - 1)) +typedef mpc_int32_t MPC_SAMPLE_FORMAT; +#else +typedef float MPC_SAMPLE_FORMAT; +#endif + +enum { + MPC_FALSE = 0, + MPC_TRUE = !MPC_FALSE +}; + +//// 'Cdecl' forces the use of standard C/C++ calling convention /////// +#if defined _WIN32 +# define mpc_cdecl __cdecl +#elif defined __ZTC__ +# define mpc_cdecl _cdecl +#elif defined __TURBOC__ +# define mpc_cdecl cdecl +#else +# define mpc_cdecl +#endif + +/* DLL building support on win32 hosts */ +#ifndef MPC_API +# ifdef DLL_EXPORT /* defined by libtool (if required) */ +# define MPC_API __declspec(dllexport) +# endif +# ifdef MPC_DLL_IMPORT /* define if linking with this dll */ +# define MPC_API __declspec(dllimport) +# endif +# ifndef MPC_API /* static linking or !_WIN32 */ +# if defined(__GNUC__) && (__GNUC__ >= 4) +# define MPC_API __attribute__ ((visibility("default"))) +# else +# define MPC_API +# endif +# endif +#endif + +#ifdef __cplusplus +} +#endif +#endif diff --git a/lib/rbcodec/codecs/libmusepack/mpcdec.h b/lib/rbcodec/codecs/libmusepack/mpcdec.h new file mode 100644 index 0000000000..85536e726a --- /dev/null +++ b/lib/rbcodec/codecs/libmusepack/mpcdec.h @@ -0,0 +1,212 @@ +/* + Copyright (c) 2005-2009, The Musepack Development Team + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + + * Neither the name of the The Musepack Development Team nor the + names of its contributors may be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +/// \file mpcdec.h +/// Top level include file for libmpcdec. +#ifndef _MPCDEC_H_ +#define _MPCDEC_H_ +#ifdef WIN32 +#pragma once +#endif + +#include "reader.h" +#include "streaminfo.h" +#include "config.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#if (CONFIG_CPU == MCF5250) +/* Enough IRAM but performance suffers with ICODE_ATTR. */ +#define IBSS_ATTR_MPC_LARGE_IRAM IBSS_ATTR +#define ICODE_ATTR_MPC_LARGE_IRAM +#define ICONST_ATTR_MPC_LARGE_IRAM ICONST_ATTR +/* Does not fit into IRAM. */ +#define IBSS_ATTR_MPC_BITBUFFER +#define ICODE_ATTR_MPC_SV8_BS_DEC +/* Keep the data arrays of bitsreadr.c in IRAM. */ +#define ICONST_ATTR_MPC_BITSREADER ICONST_ATTR + +#elif (CONFIG_CPU == PP5022) || (CONFIG_CPU == PP5024) +/* Enough IRAM to move additional data and code to it. */ +#define IBSS_ATTR_MPC_LARGE_IRAM IBSS_ATTR +#define ICODE_ATTR_MPC_LARGE_IRAM ICODE_ATTR +#define ICONST_ATTR_MPC_LARGE_IRAM ICONST_ATTR +/* Does not fit into IRAM. */ +#define IBSS_ATTR_MPC_BITBUFFER +#define ICODE_ATTR_MPC_SV8_BS_DEC +/* Not putting the data arrays of bitsreader.c to IRAM allows to move the + * sv7/sv8 bitstream demuxing into IRAM. This config is faster. */ +#define ICONST_ATTR_MPC_BITSREADER + +#elif defined(CPU_S5L870X) +/* Enough IRAM to move additional data and code to it. */ +#define IBSS_ATTR_MPC_LARGE_IRAM IBSS_ATTR +#define ICODE_ATTR_MPC_LARGE_IRAM ICODE_ATTR +#define ICONST_ATTR_MPC_LARGE_IRAM ICONST_ATTR +/* Faster when moved to IRAM. */ +#define IBSS_ATTR_MPC_BITBUFFER IBSS_ATTR +#define ICODE_ATTR_MPC_SV8_BS_DEC ICODE_ATTR +/* Not faster when moved to IRAM. */ +#define ICONST_ATTR_MPC_BITSREADER + +#else +/* Not enough IRAM available. */ +#define IBSS_ATTR_MPC_LARGE_IRAM +#define ICODE_ATTR_MPC_LARGE_IRAM +#define ICONST_ATTR_MPC_LARGE_IRAM +#define IBSS_ATTR_MPC_BITBUFFER +#define ICODE_ATTR_MPC_SV8_BS_DEC +#define ICONST_ATTR_MPC_BITSREADER +#endif + +enum { + MPC_FRAME_LENGTH = (36 * 32), ///< Samples per mpc frame + MPC_DECODER_BUFFER_LENGTH = (MPC_FRAME_LENGTH * 2), ///< Required buffer size for decoder (2 channels) + MPC_DECODER_SYNTH_DELAY = 481 +}; + +typedef struct mpc_decoder_t mpc_decoder; +typedef struct mpc_demux_t mpc_demux; + +typedef struct mpc_bits_reader_t { + unsigned char * buff; /// pointer on current byte + unsigned int count; /// unread bits in current byte + mpc_uint8_t *buffered_addr; /// used for rockbox Coldfire optimization only + mpc_uint32_t buffered_code; /// used for rockbox Coldfire optimization only +} mpc_bits_reader; + +typedef struct mpc_frame_info_t { + mpc_uint32_t samples; /// number of samples in the frame (counting once for multiple channels) + mpc_int32_t bits; /// number of bits consumed by this frame (-1) if end of stream + MPC_SAMPLE_FORMAT * buffer; /// frame samples buffer (size = samples * channels * sizeof(MPC_SAMPLE_FORMAT)) + mpc_bool_t is_key_frame; /// 1 if this frame is a key frame (first in block) 0 else. Set by the demuxer. +} mpc_frame_info; + +/* rockbox: not used +typedef struct mpc_chap_info_t { + mpc_uint64_t sample; /// sample where the chapter starts + mpc_uint16_t gain; /// replaygain chapter value + mpc_uint16_t peak; /// peak chapter loudness level + mpc_uint_t tag_size; /// size of the tag element (0 if no tag is present for this chapter) + char * tag; /// pointer to an APEv2 tag without the preamble +} mpc_chap_info; +*/ + +/// Initializes mpc decoder with the supplied stream info parameters. +/// \param si streaminfo structure indicating format of source stream +/// \return pointer on the initialized decoder structure if successful, 0 if not +MPC_API mpc_decoder * mpc_decoder_init(mpc_streaminfo *si); + +/* rockbox: not used +/// Releases input mpc decoder +MPC_API void mpc_decoder_exit(mpc_decoder *p_dec); +*/ + +/** + * Sets decoder sample scaling factor. All decoded samples will be multiplied + * by this factor. Useful for applying replay gain. + * @param scale_factor multiplicative scaling factor + */ +/* rockbox: changed to static +MPC_API void mpc_decoder_scale_output(mpc_decoder *p_dec, double scale_factor); +*/ + +MPC_API void mpc_decoder_decode_frame(mpc_decoder * d, mpc_bits_reader * r, mpc_frame_info * i); + +// This is the gain reference used in old replaygain +#define MPC_OLD_GAIN_REF 64.82 + +/** + * init demuxer + * @param p_reader initialized mpc_reader pointer + * @return an initialized mpc_demux pointer + */ +MPC_API mpc_demux * mpc_demux_init(mpc_reader * p_reader); +/* rockbox: not used +/// free demuxer +MPC_API void mpc_demux_exit(mpc_demux * d); +*/ +/** + * Calls mpc_decoder_scale_output to set the scaling factor according to the + * replay gain stream information and the supplied ouput level + * @param d pointer to a musepack demuxer + * @param level the desired ouput level (in db). Must be MPC_OLD_GAIN_REF (64.82 db) if you want to get the old replaygain behavior + * @param use_gain set it to MPC_TRUE if you want to set the scaling factor according to the stream gain + * @param use_title MPC_TRUE : uses the title gain, MPC_FALSE : uses the album gain + * @param clip_prevention MPC_TRUE : uses cliping prevention + */ +/* rockbox: not used +MPC_API void mpc_set_replay_level(mpc_demux * d, float level, mpc_bool_t use_gain, + mpc_bool_t use_title, mpc_bool_t clip_prevention); +*/ +/// decode frame +MPC_API mpc_status mpc_demux_decode(mpc_demux * d, mpc_frame_info * i); +/// get streaminfo +MPC_API void mpc_demux_get_info(mpc_demux * d, mpc_streaminfo * i); +/// seeks to a given sample +MPC_API mpc_status mpc_demux_seek_sample(mpc_demux * d, mpc_uint64_t destsample); +/* rockbox: not used +/// seeks to a given second +MPC_API mpc_status mpc_demux_seek_second(mpc_demux * d, double seconds); +*/ + +/* rockbox: keep static +/// \return the current position in the stream (in bits) from the beginning of the file +MPC_API mpc_seek_t mpc_demux_pos(mpc_demux * d); +*/ + +/// chapters : only for sv8 streams +/** + * Gets the number of chapters in the stream + * @param d pointer to a musepack demuxer + * @return the number of chapters found in the stream + */ +/* rockbox: not used +MPC_API mpc_int_t mpc_demux_chap_nb(mpc_demux * d); +*/ +/** + * Gets datas associated to a given chapter + * The chapter tag is an APEv2 tag without the preamble + * @param d pointer to a musepack demuxer + * @param chap_nb chapter number you want datas (from 0 to mpc_demux_chap_nb(d) - 1) + * @return the chapter information structure + */ +/* rockbox: not used +MPC_API mpc_chap_info const * mpc_demux_chap(mpc_demux * d, int chap_nb); +*/ +#ifdef __cplusplus +} +#endif +#endif diff --git a/lib/rbcodec/codecs/libmusepack/mpcdec_math.h b/lib/rbcodec/codecs/libmusepack/mpcdec_math.h new file mode 100644 index 0000000000..955681f4e5 --- /dev/null +++ b/lib/rbcodec/codecs/libmusepack/mpcdec_math.h @@ -0,0 +1,231 @@ +/* + Copyright (c) 2005, The Musepack Development Team + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + + * Neither the name of the The Musepack Development Team nor the + names of its contributors may be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +/// \file math.h +/// Libmpcdec internal math routines. + +#ifndef _mpcdec_math_h_ +#define _mpcdec_math_h_ + +#include "mpc_types.h" + +#define MPC_FIXED_POINT_SHIFT 16 + +#ifdef MPC_FIXED_POINT + + #ifdef _WIN32_WCE + #include + #define MPC_HAVE_MULHIGH + #endif + + typedef mpc_int64_t MPC_SAMPLE_FORMAT_MULTIPLY; + + #define MAKE_MPC_SAMPLE(X) (MPC_SAMPLE_FORMAT)((double)(X) * (double)(((mpc_int64_t)1)<>Y) + +#if defined(CPU_COLDFIRE) + + #define MPC_MULTIPLY(X,Y) mpc_multiply((X), (Y)) + #define MPC_MULTIPLY_EX(X,Y,Z) mpc_multiply_ex((X), (Y), (Z)) + + static inline MPC_SAMPLE_FORMAT mpc_multiply(MPC_SAMPLE_FORMAT x, + MPC_SAMPLE_FORMAT y) + { + MPC_SAMPLE_FORMAT t1, t2; + asm volatile ( + "mac.l %[x],%[y],%%acc0\n" /* multiply */ + "mulu.l %[y],%[x] \n" /* get lower half, avoid emac stall */ + "movclr.l %%acc0,%[t1] \n" /* get higher half */ + "moveq.l #17,%[t2] \n" + "asl.l %[t2],%[t1] \n" /* hi <<= 17, plus one free */ + "moveq.l #14,%[t2] \n" + "lsr.l %[t2],%[x] \n" /* (unsigned)lo >>= 14 */ + "or.l %[x],%[t1] \n" /* combine result */ + : /* outputs */ + [t1]"=&d"(t1), + [t2]"=&d"(t2), + [x] "+d" (x) + : /* inputs */ + [y] "d" (y) + ); + return t1; + } + + static inline MPC_SAMPLE_FORMAT mpc_multiply_ex(MPC_SAMPLE_FORMAT x, + MPC_SAMPLE_FORMAT y, + unsigned shift) + { + MPC_SAMPLE_FORMAT t1, t2; + asm volatile ( + "mac.l %[x],%[y],%%acc0\n" /* multiply */ + "mulu.l %[y],%[x] \n" /* get lower half, avoid emac stall */ + "movclr.l %%acc0,%[t1] \n" /* get higher half */ + "moveq.l #31,%[t2] \n" + "sub.l %[sh],%[t2] \n" /* t2 = 31 - shift */ + "ble.s 1f \n" + "asl.l %[t2],%[t1] \n" /* hi <<= 31 - shift */ + "lsr.l %[sh],%[x] \n" /* (unsigned)lo >>= shift */ + "or.l %[x],%[t1] \n" /* combine result */ + "bra.s 2f \n" + "1: \n" + "neg.l %[t2] \n" /* t2 = shift - 31 */ + "asr.l %[t2],%[t1] \n" /* hi >>= t2 */ + "2: \n" + : /* outputs */ + [t1]"=&d"(t1), + [t2]"=&d"(t2), + [x] "+d" (x) + : /* inputs */ + [y] "d" (y), + [sh]"d" (shift) + ); + return t1; + } + #elif defined(CPU_ARM) + /* Calculate: result = (X*Y)>>14 */ + #define MPC_MULTIPLY(X,Y) \ + ({ \ + MPC_SAMPLE_FORMAT lo; \ + MPC_SAMPLE_FORMAT hi; \ + asm volatile ( \ + "smull %[lo], %[hi], %[x], %[y] \n\t" /* multiply */ \ + "mov %[lo], %[lo], lsr #14 \n\t" /* lo >>= 14 */ \ + "orr %[lo], %[lo], %[hi], lsl #18" /* lo |= (hi << 18) */ \ + : [lo]"=&r"(lo), [hi]"=&r"(hi) \ + : [x]"r"(X), [y]"r"(Y)); \ + lo; \ + }) + + /* Calculate: result = (X*Y)>>Z */ + #define MPC_MULTIPLY_EX(X,Y,Z) \ + ({ \ + MPC_SAMPLE_FORMAT lo; \ + MPC_SAMPLE_FORMAT hi; \ + asm volatile ( \ + "smull %[lo], %[hi], %[x], %[y] \n\t" /* multiply */ \ + "mov %[lo], %[lo], lsr %[shr] \n\t" /* lo >>= Z */ \ + "orr %[lo], %[lo], %[hi], lsl %[shl]" /* lo |= (hi << (32-Z)) */ \ + : [lo]"=&r"(lo), [hi]"=&r"(hi) \ + : [x]"r"(X), [y]"r"(Y), [shr]"r"(Z), [shl]"r"(32-Z)); \ + lo; \ + }) + #else /* libmusepack standard */ + + #define MPC_MULTIPLY_NOTRUNCATE(X,Y) \ + (((MPC_SAMPLE_FORMAT_MULTIPLY)(X) * (MPC_SAMPLE_FORMAT_MULTIPLY)(Y)) >> MPC_FIXED_POINT_FRACTPART) + + #define MPC_MULTIPLY_EX_NOTRUNCATE(X,Y,Z) \ + (((MPC_SAMPLE_FORMAT_MULTIPLY)(X) * (MPC_SAMPLE_FORMAT_MULTIPLY)(Y)) >> (Z)) + + #ifdef _DEBUG + static inline MPC_SAMPLE_FORMAT MPC_MULTIPLY(MPC_SAMPLE_FORMAT item1,MPC_SAMPLE_FORMAT item2) + { + MPC_SAMPLE_FORMAT_MULTIPLY temp = MPC_MULTIPLY_NOTRUNCATE(item1,item2); + assert(temp == (MPC_SAMPLE_FORMAT_MULTIPLY)(MPC_SAMPLE_FORMAT)temp); + return (MPC_SAMPLE_FORMAT)temp; + } + + static inline MPC_SAMPLE_FORMAT MPC_MULTIPLY_EX(MPC_SAMPLE_FORMAT item1,MPC_SAMPLE_FORMAT item2,unsigned shift) + { + MPC_SAMPLE_FORMAT_MULTIPLY temp = MPC_MULTIPLY_EX_NOTRUNCATE(item1,item2,shift); + assert(temp == (MPC_SAMPLE_FORMAT_MULTIPLY)(MPC_SAMPLE_FORMAT)temp); + return (MPC_SAMPLE_FORMAT)temp; + } + #else + #define MPC_MULTIPLY(X,Y) ((MPC_SAMPLE_FORMAT)MPC_MULTIPLY_NOTRUNCATE(X,Y)) + #define MPC_MULTIPLY_EX(X,Y,Z) ((MPC_SAMPLE_FORMAT)MPC_MULTIPLY_EX_NOTRUNCATE(X,Y,Z)) + #endif + + #endif + + #ifdef MPC_HAVE_MULHIGH + #define MPC_MULTIPLY_FRACT(X,Y) _MulHigh(X,Y) + #else + #if defined(CPU_COLDFIRE) + /* loses one bit of accuracy. The rest of the macros won't be as easy as this... */ + #define MPC_MULTIPLY_FRACT(X,Y) \ + ({ \ + MPC_SAMPLE_FORMAT t; \ + asm volatile ( \ + "mac.l %[A], %[B], %%acc0\n\t" \ + "movclr.l %%acc0, %[t] \n\t" \ + "asr.l #1, %[t] \n\t" \ + : [t] "=d" (t) \ + : [A] "r" ((X)), [B] "r" ((Y))); \ + t; \ + }) + #elif defined(CPU_ARM) + /* Calculate: result = (X*Y)>>32, without need for >>32 */ + #define MPC_MULTIPLY_FRACT(X,Y) \ + ({ \ + MPC_SAMPLE_FORMAT lo; \ + MPC_SAMPLE_FORMAT hi; \ + asm volatile ( \ + "smull %[lo], %[hi], %[x], %[y]" /* hi = result */ \ + : [lo]"=&r"(lo), [hi]"=&r"(hi) \ + : [x]"r"(X), [y]"r"(Y)); \ + hi; \ + }) + #else + #define MPC_MULTIPLY_FRACT(X,Y) MPC_MULTIPLY_EX(X,Y,32) + #endif + #endif + + #define MPC_MAKE_FRACT_CONST(X) (MPC_SAMPLE_FORMAT)((X) * (double)(((mpc_int64_t)1)<<32) ) + + #define MPC_MULTIPLY_FLOAT_INT(X,Y) ((X)*(Y)) + +#else + //in floating-point mode, decoded samples are in -1...1 range + + typedef float MPC_SAMPLE_FORMAT; + + #define MAKE_MPC_SAMPLE(X) ((MPC_SAMPLE_FORMAT)(X)) + #define MAKE_MPC_SAMPLE_EX(X,Y) ((MPC_SAMPLE_FORMAT)(X)) + + #define MPC_MULTIPLY_FRACT(X,Y) ((X)*(Y)) + #define MPC_MAKE_FRACT_CONST(X) (X) + + #define MPC_MULTIPLY_FLOAT_INT(X,Y) ((X)*(Y)) + #define MPC_MULTIPLY(X,Y) ((X)*(Y)) + #define MPC_MULTIPLY_EX(X,Y,Z) ((X)*(Y)) + + #define MPC_SHR_RND(X, Y) (X) + +#endif + +#endif // _mpcdec_math_h_ + diff --git a/lib/rbcodec/codecs/libmusepack/reader.h b/lib/rbcodec/codecs/libmusepack/reader.h new file mode 100644 index 0000000000..c46844cd59 --- /dev/null +++ b/lib/rbcodec/codecs/libmusepack/reader.h @@ -0,0 +1,100 @@ +/* + Copyright (c) 2005-2009, The Musepack Development Team + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + + * Neither the name of the The Musepack Development Team nor the + names of its contributors may be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +/// \file reader.h +#ifndef _MPCDEC_READER_H_ +#define _MPCDEC_READER_H_ +#ifdef WIN32 +#pragma once +#endif + +#include "mpc_types.h" +#include + +#ifdef __cplusplus +extern "C" { +#endif + + +/// \brief Stream reader interface structure. +/// +/// This is the structure you must supply to the musepack decoding library +/// to feed it with raw data. Implement the five member functions to provide +/// a functional reader. +typedef struct mpc_reader_t mpc_reader; +struct mpc_reader_t { + /// Reads size bytes of data into buffer at ptr. + mpc_int32_t (*read)(mpc_reader *p_reader, void *ptr, mpc_int32_t size); + + /// Seeks to byte position offset. + mpc_bool_t (*seek)(mpc_reader *p_reader, mpc_int32_t offset); + + /// Returns the current byte offset in the stream. + mpc_int32_t (*tell)(mpc_reader *p_reader); + + /// Returns the total length of the source stream, in bytes. + mpc_int32_t (*get_size)(mpc_reader *p_reader); + + /* rockbox: not used + /// True if the stream is a seekable stream. + mpc_bool_t (*canseek)(mpc_reader *p_reader); + + /// Field that can be used to identify a particular instance of + /// reader or carry along data associated with that reader. + void *data; + */ +}; +/* rockbox: not used +/// Initializes reader with default stdio file reader implementation. Use +/// this if you're just reading from a plain file. +/// +/// \param r p_reader handle to initialize +/// \param filename input filename to attach to the reader +MPC_API mpc_status mpc_reader_init_stdio(mpc_reader *p_reader, const char *filename); + +/// Initializes reader with default stdio file reader implementation. Use +/// this if you prefer to open the file yourself. +/// +/// \param r p_reader handle to initialize +/// \param p_file input file handle (already open) +MPC_API mpc_status mpc_reader_init_stdio_stream(mpc_reader * p_reader, FILE * p_file); + +/// Release reader with default stdio file reader implementation. +/// +/// \param r reader handle to release +MPC_API void mpc_reader_exit_stdio(mpc_reader *p_reader); +*/ +#ifdef __cplusplus +} +#endif +#endif diff --git a/lib/rbcodec/codecs/libmusepack/requant.c b/lib/rbcodec/codecs/libmusepack/requant.c new file mode 100644 index 0000000000..fc27dfd199 --- /dev/null +++ b/lib/rbcodec/codecs/libmusepack/requant.c @@ -0,0 +1,184 @@ +/* + Copyright (c) 2005-2009, The Musepack Development Team + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + + * Neither the name of the The Musepack Development Team nor the + names of its contributors may be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +/// \file requant.c +/// Requantization function implementations. +/// \todo document me +#include "mpcdec.h" +#include "requant.h" +#include "mpcdec_math.h" +#include "decoder.h" +#include "internal.h" +#include + +/* C O N S T A N T S */ +// Bits per sample for chosen quantizer +const mpc_uint8_t Res_bit [18] ICONST_ATTR = { + 0, 0, 0, 0, 0, 0, 0, 0, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 +}; + +// Requantization coefficients +// 65536/step bzw. 65536/(2*D+1) + +#define _(X) MAKE_MPC_SAMPLE_EX(X,14) + +const MPC_SAMPLE_FORMAT __Cc [1 + 18] ICONST_ATTR = { + _(111.285962475327f), // 32768/2/255*sqrt(3) + _(65536.000000000000f), _(21845.333333333332f), _(13107.200000000001f), _(9362.285714285713f), + _(7281.777777777777f), _(4369.066666666666f), _(2114.064516129032f), _(1040.253968253968f), + _(516.031496062992f), _(257.003921568627f), _(128.250489236790f), _(64.062561094819f), + _(32.015632633121f), _(16.003907203907f), _(8.000976681723f), _(4.000244155527f), + _(2.000061037018f), _(1.000015259021f) +}; + +#undef _ + +// Requantization offset +// 2*D+1 = steps of quantizer +const mpc_int16_t __Dc [1 + 18] ICONST_ATTR = { + 2, + 0, 1, 2, 3, 4, 7, 15, 31, 63, + 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767 +}; + +// Table'ized SCF calculated from mpc_decoder_scale_output(d, 1.0) +static const mpc_uint32_t SCF[] = { + 1289035711, 1073741824, 1788812356, 1490046106, 1241179595, 1033878604, 861200887, 717363687, + 597550081, 497747664, 414614180, 345365595, 287682863, 239634262, 199610707, 166271859, + 138501244, 115368858, 96100028, 80049465, 66679657, 55542865, 46266132, 38538793, + 32102070, 26740403, 22274239, 18554010, 15455132, 12873826, 10723648, 8932591, + 7440676, 6197939, 5162763, 4300482, 3582218, 2983918, 2485546, 2070412, + 1724613, 1436569, 1196634, 996773, 830293, 691618, 576104, 479883, + 399734, 332970, 277358, 231034, 192446, 160304, 133530, 111228, + 92651, 77176, 64286, 53549, 44605, 37155, 30949, 25780, + 21474, 17888, 14900, 12411, 10338, 8612, 7173, 5975, + 4977, 4146, 3453, 2876, 2396, 1996, 1662, 1385, + 1153, 961, 800, 666, 555, 462, 385, 321, + 267, 222, 185, 154, 128, 107, 89, 74, + 61, 51, 43, 35, 29, 24, 20, 17, + 14, 11, 9, 8, 6, 5, 4, 3, + 3, 2, 2, 1, 1, 1, 1, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 2147483648, 2147483648, 2147483648, 2147483648, 2147483648, 2147483648, 2147483648, + 2147483648, 2147483648, 2147483648, 2147483648, 1930697728, 1608233877, 1339627724, 1115883992, + 1859019579, 1548527365, 1289893354, 1074456223, 1790002518, 1491037488, 1242005398, 2069132964, + 1723547752, 1435681952, 1195895306, 1992315335, 1659560152, 1382381519, 1151497076, 1918349601, + 1597948125, 1331059892, 1108747153, 1847129882, 1538623477, 1281643607, 2135168687, 1778554232, + 1481501287, 1234061927, 2055899448, 1712524489, 1426499787, 1188246741, 1979573121, 1648946134, + 1373540247, 1144132468, 1906080447, 1587728158, 1322546856, 1101655960, 1835316227, 1528782931, + 1273446622, 2121512828, 1767179166, 1472026076, 1226169259, 2042750570, 1701571728, 1417376349, + 1180647093, 1966912401, 1638400000, 1364755521, 1136814961, 1893889764, 1577573554, 1314088268, + 1094610119, 1823578129, 1519005322, 1265302063, 2107944308, 1755876851, 1462611466, 1218327071, + 2029685788, 1690689017, 1408311261, 1173096050, 1954332656, 1627921315, 1356026979, 1129544254, + 1881777048, 1567483896, 1305683778, 1087609341, 1811915104, 1509290248, 1257209594, 2094462567, + 1744646821, 1453257069, 1210535039, 2016704564, 1679875908, 1399304151, 1165593302, 1941833367, + 1617509648, 1347354262, 1122320049, 1869741801, 1557458768, 1297333040, 1080653338, 1800326672, + 1499637308, 1249168882, 2081067051, 1733488616, 1443962500, 1202792843, 2003806364, 1669131957, + 1390354647, 1158138538, 1929414019, 1607164572, 1338737013, 1115142047, 1857783528, 1547497758 +}; + +// Table'ized SCF_shift calculated from mpc_decoder_scale_output(d, 1.0) +static const mpc_uint8_t SCF_shift[] = { + 30, 30, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, + 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, + 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, + 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, + 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, + 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, + 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, + 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, + 31, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, + 5, 5, 5, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, + 9, 9, 10, 10, 10, 10, 11, 11, 11, 12, 12, 12, 12, 13, 13, 13, + 13, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 17, 17, 17, 17, + 18, 18, 18, 18, 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 22, + 22, 22, 22, 23, 23, 23, 23, 24, 24, 24, 24, 25, 25, 25, 25, 26, + 26, 26, 27, 27, 27, 27, 28, 28, 28, 28, 29, 29, 29, 29, 30, 30 +}; + +/* F U N C T I O N S */ +/* not used anymore, tables from above are used +#ifdef MPC_FIXED_POINT +static mpc_uint32_t find_shift(double fval) +{ + mpc_int64_t val = (mpc_int64_t) fval; + mpc_uint32_t ptr = 0; + if(val<0) + val = -val; + while(val) + { + val >>= 1; + ptr++; + } + return ptr > 31 ? 0 : 31 - ptr; +} +#endif + +#define SET_SCF(N,X) d->SCF[N] = MAKE_MPC_SAMPLE_EX(X,d->SCF_shift[N] = (mpc_uint8_t) find_shift(X)); + +static void +mpc_decoder_scale_output(mpc_decoder *d, double factor) +{ + mpc_int32_t n; double f1, f2; + +#ifndef MPC_FIXED_POINT + factor *= 1.0 / (double) (1<<(MPC_FIXED_POINT_SHIFT-1)); +#else + factor *= 1.0 / (double) (1<<(16-MPC_FIXED_POINT_SHIFT)); +#endif + f1 = f2 = factor; + + // handles +1.58...-98.41 dB, where's scf[n] / scf[n-1] = 1.20050805774840750476 + + SET_SCF(1,factor); + + f1 *= 0.83298066476582673961; + f2 *= 1/0.83298066476582673961; + + for ( n = 1; n <= 128; n++ ) { + SET_SCF((mpc_uint8_t)(1+n),f1); + SET_SCF((mpc_uint8_t)(1-n),f2); + f1 *= 0.83298066476582673961; + f2 *= 1/0.83298066476582673961; + } +} +*/ +void +mpc_decoder_init_quant(mpc_decoder *d, MPC_SAMPLE_FORMAT factor) +{ + //mpc_decoder_scale_output(d, (double)factor / MPC_FIXED_POINT_SHIFT) + (void)factor; + memcpy(d->SCF, SCF, sizeof(d->SCF)); + memcpy(d->SCF_shift, SCF_shift, sizeof(d->SCF_shift)); +} diff --git a/lib/rbcodec/codecs/libmusepack/requant.h b/lib/rbcodec/codecs/libmusepack/requant.h new file mode 100644 index 0000000000..908fda30eb --- /dev/null +++ b/lib/rbcodec/codecs/libmusepack/requant.h @@ -0,0 +1,61 @@ +/* + Copyright (c) 2005-2009, The Musepack Development Team + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + + * Neither the name of the The Musepack Development Team nor the + names of its contributors may be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +/// \file requant.h +/// Requantization function definitions. +#ifndef _MPCDEC_REQUANT_H_ +#define _MPCDEC_REQUANT_H_ +#ifdef WIN32 +#pragma once +#endif + +#include "mpc_types.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +/* C O N S T A N T S */ +extern const mpc_uint8_t Res_bit [18]; ///< Bits per sample for chosen quantizer +extern const MPC_SAMPLE_FORMAT __Cc [1 + 18]; ///< Requantization coefficients +extern const mpc_int16_t __Dc [1 + 18]; ///< Requantization offset + +#define Cc (__Cc + 1) +#define Dc (__Dc + 1) + + +#ifdef __cplusplus +} +#endif +#endif diff --git a/lib/rbcodec/codecs/libmusepack/streaminfo.c b/lib/rbcodec/codecs/libmusepack/streaminfo.c new file mode 100644 index 0000000000..6b4d3df0c1 --- /dev/null +++ b/lib/rbcodec/codecs/libmusepack/streaminfo.c @@ -0,0 +1,255 @@ +/* + Copyright (c) 2005-2009, The Musepack Development Team + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + + * Neither the name of the The Musepack Development Team nor the + names of its contributors may be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +/// \file streaminfo.c +/// Implementation of streaminfo reading functions. + +#include +#include "mpcdec.h" +#include "streaminfo.h" +#include +#include "internal.h" +#include "huffman.h" +#include "mpc_bits_reader.h" + +/* rockbox: not used +static const char na[] = "n.a."; +static char const * const versionNames[] = { + na, "'Unstable/Experimental'", na, na, na, "'quality 0'", "'quality 1'", + "'Telephone'", "'Thumb'", "'Radio'", "'Standard'", "'Extreme'", "'Insane'", + "'BrainDead'", "'quality 9'", "'quality 10'" +}; +*/ +static const mpc_int32_t samplefreqs[8] = { 44100, 48000, 37800, 32000 }; +/* rockbox: not used +static const char * +mpc_get_version_string(float profile) // profile is 0...15, where 7...13 is used +{ + return profile >= sizeof versionNames / sizeof *versionNames ? na : versionNames[(int)profile]; +} +*/ +/* rockbox: not used +static void +mpc_get_encoder_string(mpc_streaminfo* si) +{ + int ver = si->encoder_version; + if (si->stream_version >= 8) + ver = (si->encoder_version >> 24) * 100 + ((si->encoder_version >> 16) & 0xFF); + if (ver <= 116) { + if (ver == 0) { + sprintf(si->encoder, "Buschmann 1.7.0...9, Klemm 0.90...1.05"); + } else { + switch (ver % 10) { + case 0: + sprintf(si->encoder, "Release %u.%u", ver / 100, + ver / 10 % 10); + break; + case 2: case 4: case 6: case 8: + sprintf(si->encoder, "Beta %u.%02u", ver / 100, + ver % 100); + break; + default: + sprintf(si->encoder, "--Alpha-- %u.%02u", + ver / 100, ver % 100); + break; + } + } + } else { + int major = si->encoder_version >> 24; + int minor = (si->encoder_version >> 16) & 0xFF; + int build = (si->encoder_version >> 8) & 0xFF; + char * tmp = "--Stable--"; + + if (minor & 1) + tmp = "--Unstable--"; + + sprintf(si->encoder, "%s %u.%u.%u", tmp, major, minor, build); + } +} +*/ + +static mpc_status check_streaminfo(mpc_streaminfo * si) +{ + if (si->max_band == 0 || si->max_band >= 32 + || si->channels > 2 || si->channels == 0 || si->sample_freq == 0) + return MPC_STATUS_FAIL; + return MPC_STATUS_OK; +} + +/// Reads streaminfo from SV7 header. +mpc_status +streaminfo_read_header_sv7(mpc_streaminfo* si, mpc_bits_reader * r) +{ + mpc_uint32_t frames, last_frame_samples; + + si->bitrate = 0; + frames = (mpc_bits_read(r, 16) << 16) | mpc_bits_read(r, 16); + mpc_bits_read(r, 1); // intensity stereo : should be 0 + si->ms = mpc_bits_read(r, 1); + si->max_band = mpc_bits_read(r, 6); + si->profile = mpc_bits_read(r, 4); +/* rockbox: not used + si->profile_name = mpc_get_version_string(si->profile); +*/ + mpc_bits_read(r, 2); // Link ? + si->sample_freq = samplefreqs[mpc_bits_read(r, 2)]; + mpc_bits_read(r, 16); // Estimatedpeak_title + si->gain_title = (mpc_uint16_t) mpc_bits_read(r, 16); + si->peak_title = (mpc_uint16_t) mpc_bits_read(r, 16); + si->gain_album = (mpc_uint16_t) mpc_bits_read(r, 16); + si->peak_album = (mpc_uint16_t) mpc_bits_read(r, 16); + si->is_true_gapless = mpc_bits_read(r, 1); // true gapless: used? + last_frame_samples = mpc_bits_read(r, 11); // true gapless: valid samples for last frame + si->fast_seek = mpc_bits_read(r, 1); // fast seeking + mpc_bits_read(r, 19); // unused + si->encoder_version = mpc_bits_read(r, 8); + si->channels = 2; + si->block_pwr = 0; + +/* rockbox: not used + // convert gain info + if (si->gain_title != 0) { + int tmp = (int)((MPC_OLD_GAIN_REF - (mpc_int16_t)si->gain_title / 100.) * 256. + .5); + if (tmp >= (1 << 16) || tmp < 0) tmp = 0; + si->gain_title = (mpc_int16_t) tmp; + } + + if (si->gain_album != 0) { + int tmp = (int)((MPC_OLD_GAIN_REF - (mpc_int16_t)si->gain_album / 100.) * 256. + .5); + if (tmp >= (1 << 16) || tmp < 0) tmp = 0; + si->gain_album = (mpc_int16_t) tmp; + } + + if (si->peak_title != 0) + si->peak_title = (mpc_uint16_t) (log10(si->peak_title) * 20 * 256 + .5); + + if (si->peak_album != 0) + si->peak_album = (mpc_uint16_t) (log10(si->peak_album) * 20 * 256 + .5); + + mpc_get_encoder_string(si); +*/ + + if (last_frame_samples == 0) last_frame_samples = MPC_FRAME_LENGTH; + else if (last_frame_samples > MPC_FRAME_LENGTH) return MPC_STATUS_FAIL; + si->samples = (mpc_int64_t) frames * MPC_FRAME_LENGTH; + if (si->is_true_gapless) + si->samples -= (MPC_FRAME_LENGTH - last_frame_samples); + else + si->samples -= MPC_DECODER_SYNTH_DELAY; + + si->average_bitrate = 8LL * (si->tag_offset - si->header_position) + * si->sample_freq / si->samples; + + return check_streaminfo(si); +} + +/// Reads replay gain datas +void streaminfo_gain(mpc_streaminfo* si, const mpc_bits_reader * r_in) +{ + mpc_bits_reader r = *r_in; + + int version = mpc_bits_read(&r, 8); // gain version + if (version != 1) // we only know ver 1 + return; + si->gain_title = (mpc_uint16_t) mpc_bits_read(&r, 16); + si->peak_title = (mpc_uint16_t) mpc_bits_read(&r, 16); + si->gain_album = (mpc_uint16_t) mpc_bits_read(&r, 16); + si->peak_album = (mpc_uint16_t) mpc_bits_read(&r, 16); +} + +/// Reads streaminfo from SV8 header. +mpc_status +streaminfo_read_header_sv8(mpc_streaminfo* si, const mpc_bits_reader * r_in, + mpc_size_t block_size) +{ + mpc_uint32_t CRC; + mpc_bits_reader r = *r_in; + + CRC = (mpc_bits_read(&r, 16) << 16) | mpc_bits_read(&r, 16); + if (CRC != mpc_crc32(r.buff + 1 - (r.count >> 3), (int)block_size - 4)) + return MPC_STATUS_FAIL; + + si->stream_version = mpc_bits_read(&r, 8); + if (si->stream_version != 8) + return MPC_STATUS_FAIL; + + mpc_bits_get_size(&r, &si->samples); + mpc_bits_get_size(&r, &si->beg_silence); + + si->is_true_gapless = 1; + si->sample_freq = samplefreqs[mpc_bits_read(&r, 3)]; + si->max_band = mpc_bits_read(&r, 5) + 1; + si->channels = mpc_bits_read(&r, 4) + 1; + si->ms = mpc_bits_read(&r, 1); + si->block_pwr = mpc_bits_read(&r, 3) * 2; + + si->bitrate = 0; + + if ((si->samples - si->beg_silence) != 0) + si->average_bitrate = 8LL * (si->tag_offset - si->header_position) + * si->sample_freq / (si->samples - si->beg_silence); + + return check_streaminfo(si); +} + +/// Reads encoder informations +void streaminfo_encoder_info(mpc_streaminfo* si, const mpc_bits_reader * r_in) +{ + mpc_bits_reader r = *r_in; + + si->profile = mpc_bits_read(&r, 7); // to be divided by 8 +/* rockbox: not used + si->profile_name = mpc_get_version_string(si->profile); +*/ + si->pns = mpc_bits_read(&r, 1); + si->encoder_version = mpc_bits_read(&r, 8) << 24; // major + si->encoder_version |= mpc_bits_read(&r, 8) << 16; // minor + si->encoder_version |= mpc_bits_read(&r, 8) << 8; // build + +/* rockbox: not used + mpc_get_encoder_string(si); +*/ +} + +/* rockbox: not used +double +mpc_streaminfo_get_length(mpc_streaminfo * si) +{ + return (double) (si->samples - si->beg_silence) / si->sample_freq; +} + +mpc_int64_t mpc_streaminfo_get_length_samples(mpc_streaminfo *si) +{ + return si->samples - si->beg_silence; +} +*/ diff --git a/lib/rbcodec/codecs/libmusepack/streaminfo.h b/lib/rbcodec/codecs/libmusepack/streaminfo.h new file mode 100644 index 0000000000..52e97936a0 --- /dev/null +++ b/lib/rbcodec/codecs/libmusepack/streaminfo.h @@ -0,0 +1,114 @@ +/* + Copyright (c) 2005-2009, The Musepack Development Team + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + + * Neither the name of the The Musepack Development Team nor the + names of its contributors may be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +/// \file streaminfo.h +#ifndef _MPCDEC_STREAMINFO_H_ +#define _MPCDEC_STREAMINFO_H_ +#ifdef WIN32 +#pragma once +#endif + +#include "mpc_types.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +typedef mpc_int32_t mpc_streaminfo_off_t; + +/// \brief mpc stream properties structure +/// +/// Structure containing all the properties of an mpc stream. Populated +/// by the streaminfo_read function. +typedef struct mpc_streaminfo { + /// @name Core mpc stream properties + //@{ + mpc_uint32_t sample_freq; ///< Sample frequency of stream + mpc_uint32_t channels; ///< Number of channels in stream + mpc_uint32_t stream_version; ///< Streamversion of stream + mpc_uint32_t bitrate; ///< Bitrate of stream file (in bps) + mpc_uint32_t average_bitrate; ///< Average bitrate of stream (in bits/sec) + mpc_uint32_t max_band; ///< Maximum band-index used in stream (0...31) + mpc_uint32_t ms; ///< Mid/side stereo (0: off, 1: on) + mpc_uint32_t fast_seek; ///< True if stream supports fast-seeking (sv7) + mpc_uint32_t block_pwr; ///< Number of frames in a block = 2^block_pwr (sv8) + //@} + + /// @name Replaygain properties + //@{ + mpc_uint16_t gain_title; ///< Replaygain title value + mpc_uint16_t gain_album; ///< Replaygain album value + mpc_uint16_t peak_album; ///< Peak album loudness level + mpc_uint16_t peak_title; ///< Peak title loudness level + //@} + + /// @name True gapless properties + //@{ + mpc_uint32_t is_true_gapless; ///< True gapless? (0: no, 1: yes) + mpc_uint64_t samples; ///< Number of samples in the stream + mpc_uint64_t beg_silence; ///< Number of samples that must not be played at the beginning of the stream + //@} + + /// @name Encoder informations + //@{ + mpc_uint32_t encoder_version; ///< Version of encoder used +/* rockbox: not used + char encoder[256]; ///< Encoder name +*/ + mpc_bool_t pns; ///< pns used + mpc_uint32_t profile; ///< Quality profile of stream +/* rockbox: not used + const char* profile_name; ///< Name of profile used by stream +*/ + //@} + + + mpc_streaminfo_off_t header_position; ///< Byte offset of position of header in stream + mpc_streaminfo_off_t tag_offset; ///< Offset to file tags + mpc_streaminfo_off_t total_file_length; ///< Total length of underlying file +} mpc_streaminfo; + +/* rockbox: not used +/// Gets length of stream si, in seconds. +/// \return length of stream in seconds +MPC_API double mpc_streaminfo_get_length(mpc_streaminfo *si); + +/// Returns length of stream si, in samples. +/// \return length of stream in samples +MPC_API mpc_int64_t mpc_streaminfo_get_length_samples(mpc_streaminfo *si); +*/ +#ifdef __cplusplus +} +#endif +#endif diff --git a/lib/rbcodec/codecs/libmusepack/synth_filter.c b/lib/rbcodec/codecs/libmusepack/synth_filter.c new file mode 100644 index 0000000000..3ad2b236a0 --- /dev/null +++ b/lib/rbcodec/codecs/libmusepack/synth_filter.c @@ -0,0 +1,610 @@ +/* + Copyright (c) 2005, The Musepack Development Team + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + + * Neither the name of the The Musepack Development Team nor the + names of its contributors may be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +/// \file synth_filter.c +/// Synthesis functions. +/// \todo document me +#include +#include +#include "mpcdec.h" +#include "decoder.h" +#include "mpcdec_math.h" +#include "internal.h" + +/* C O N S T A N T S */ +#undef _ + +#if defined(MPC_FIXED_POINT) + #if defined(CPU_ARM) + #if ARM_ARCH >= 6 + // on ARMv6 we use 32*32=64>>32 multiplies (smmul/smmla) so we need to scale up the D coefficients + // the ARM11 multiplier doesn't have early termination so the magnitude of the multiplicands does not + // matter for speed. + #define D(value) (value << (14)) + #else + // do not up-scale D-values to achieve higher speed in smull/mlal + // operations. saves ~14/8 = 1.75 cycles per multiplication + #define D(value) (value) + #endif + // in this configuration a post-shift by >>16 is needed after synthesis + #else + // saturate to +/- 2^31 (= value << (31-17)), D-values are +/- 2^17 + #define D(value) (value << (14)) + #endif +#else + // IMPORTANT: internal scaling is somehow strange for floating point, therefore we scale the coefficients Di_opt + // by the correct amount to have proper scaled output + #define D(value) MAKE_MPC_SAMPLE((double)value*(double)(0x1000)) +#endif + +// Di_opt coefficients are +/- 2^17 (pre-shifted by <<16) +static const MPC_SAMPLE_FORMAT Di_opt [512] ICONST_ATTR MEM_ALIGN_ATTR = { +/* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 */ +/* 0 */ D( 0), -D( 29), D(213), -D( 459), D(2037), -D(5153), D( 6574), -D(37489), D(75038), D(37489), D(6574), D(5153), D(2037), D(459), D(213), D(29), +/* 1 */ -D( 1), -D( 31), D(218), -D( 519), D(2000), -D(5517), D( 5959), -D(39336), D(74992), D(35640), D(7134), D(4788), D(2063), D(401), D(208), D(26), +/* 2 */ -D( 1), -D( 35), D(222), -D( 581), D(1952), -D(5879), D( 5288), -D(41176), D(74856), D(33791), D(7640), D(4425), D(2080), D(347), D(202), D(24), +/* 3 */ -D( 1), -D( 38), D(225), -D( 645), D(1893), -D(6237), D( 4561), -D(43006), D(74630), D(31947), D(8092), D(4063), D(2087), D(294), D(196), D(21), +/* 4 */ -D( 1), -D( 41), D(227), -D( 711), D(1822), -D(6589), D( 3776), -D(44821), D(74313), D(30112), D(8492), D(3705), D(2085), D(244), D(190), D(19), +/* 5 */ -D( 1), -D( 45), D(228), -D( 779), D(1739), -D(6935), D( 2935), -D(46617), D(73908), D(28289), D(8840), D(3351), D(2075), D(197), D(183), D(17), +/* 6 */ -D( 1), -D( 49), D(228), -D( 848), D(1644), -D(7271), D( 2037), -D(48390), D(73415), D(26482), D(9139), D(3004), D(2057), D(153), D(176), D(16), +/* 7 */ -D( 2), -D( 53), D(227), -D( 919), D(1535), -D(7597), D( 1082), -D(50137), D(72835), D(24694), D(9389), D(2663), D(2032), D(111), D(169), D(14), +/* 8 */ -D( 2), -D( 58), D(224), -D( 991), D(1414), -D(7910), D( 70), -D(51853), D(72169), D(22929), D(9592), D(2330), D(2001), D( 72), D(161), D(13), +/* 9 */ -D( 2), -D( 63), D(221), -D(1064), D(1280), -D(8209), -D( 998), -D(53534), D(71420), D(21189), D(9750), D(2006), D(1962), D( 36), D(154), D(11), +/* 10 */ -D( 2), -D( 68), D(215), -D(1137), D(1131), -D(8491), -D( 2122), -D(55178), D(70590), D(19478), D(9863), D(1692), D(1919), D( 2), D(147), D(10), +/* 11 */ -D( 3), -D( 73), D(208), -D(1210), D( 970), -D(8755), -D( 3300), -D(56778), D(69679), D(17799), D(9935), D(1388), D(1870), -D( 29), D(139), D( 9), +/* 12 */ -D( 3), -D( 79), D(200), -D(1283), D( 794), -D(8998), -D( 4533), -D(58333), D(68692), D(16155), D(9966), D(1095), D(1817), -D( 57), D(132), D( 8), +/* 13 */ -D( 4), -D( 85), D(189), -D(1356), D( 605), -D(9219), -D( 5818), -D(59838), D(67629), D(14548), D(9959), D( 814), D(1759), -D( 83), D(125), D( 7), +/* 14 */ -D( 4), -D( 91), D(177), -D(1428), D( 402), -D(9416), -D( 7154), -D(61289), D(66494), D(12980), D(9916), D( 545), D(1698), -D(106), D(117), D( 7), +/* 15 */ -D( 5), -D( 97), D(163), -D(1498), D( 185), -D(9585), -D( 8540), -D(62684), D(65290), D(11455), D(9838), D( 288), D(1634), -D(127), D(111), D( 6), +/* 16 */ -D( 5), -D(104), D(146), -D(1567), -D( 45), -D(9727), -D( 9975), -D(64019), D(64019), D( 9975), D(9727), D( 45), D(1567), -D(146), D(104), D( 5), +/* 17 */ -D( 6), -D(111), D(127), -D(1634), -D( 288), -D(9838), -D(11455), -D(65290), D(62684), D( 8540), D(9585), -D( 185), D(1498), -D(163), D( 97), D( 5), +/* 18 */ -D( 7), -D(117), D(106), -D(1698), -D( 545), -D(9916), -D(12980), -D(66494), D(61289), D( 7154), D(9416), -D( 402), D(1428), -D(177), D( 91), D( 4), +/* 19 */ -D( 7), -D(125), D( 83), -D(1759), -D( 814), -D(9959), -D(14548), -D(67629), D(59838), D( 5818), D(9219), -D( 605), D(1356), -D(189), D( 85), D( 4), +/* 20 */ -D( 8), -D(132), D( 57), -D(1817), -D(1095), -D(9966), -D(16155), -D(68692), D(58333), D( 4533), D(8998), -D( 794), D(1283), -D(200), D( 79), D( 3), +/* 21 */ -D( 9), -D(139), D( 29), -D(1870), -D(1388), -D(9935), -D(17799), -D(69679), D(56778), D( 3300), D(8755), -D( 970), D(1210), -D(208), D( 73), D( 3), +/* 22 */ -D(10), -D(147), -D( 2), -D(1919), -D(1692), -D(9863), -D(19478), -D(70590), D(55178), D( 2122), D(8491), -D(1131), D(1137), -D(215), D( 68), D( 2), +/* 23 */ -D(11), -D(154), -D( 36), -D(1962), -D(2006), -D(9750), -D(21189), -D(71420), D(53534), D( 998), D(8209), -D(1280), D(1064), -D(221), D( 63), D( 2), +/* 24 */ -D(13), -D(161), -D( 72), -D(2001), -D(2330), -D(9592), -D(22929), -D(72169), D(51853), -D( 70), D(7910), -D(1414), D( 991), -D(224), D( 58), D( 2), +/* 25 */ -D(14), -D(169), -D(111), -D(2032), -D(2663), -D(9389), -D(24694), -D(72835), D(50137), -D( 1082), D(7597), -D(1535), D( 919), -D(227), D( 53), D( 2), +/* 26 */ -D(16), -D(176), -D(153), -D(2057), -D(3004), -D(9139), -D(26482), -D(73415), D(48390), -D( 2037), D(7271), -D(1644), D( 848), -D(228), D( 49), D( 1), +/* 27 */ -D(17), -D(183), -D(197), -D(2075), -D(3351), -D(8840), -D(28289), -D(73908), D(46617), -D( 2935), D(6935), -D(1739), D( 779), -D(228), D( 45), D( 1), +/* 28 */ -D(19), -D(190), -D(244), -D(2085), -D(3705), -D(8492), -D(30112), -D(74313), D(44821), -D( 3776), D(6589), -D(1822), D( 711), -D(227), D( 41), D( 1), +/* 29 */ -D(21), -D(196), -D(294), -D(2087), -D(4063), -D(8092), -D(31947), -D(74630), D(43006), -D( 4561), D(6237), -D(1893), D( 645), -D(225), D( 38), D( 1), +/* 30 */ -D(24), -D(202), -D(347), -D(2080), -D(4425), -D(7640), -D(33791), -D(74856), D(41176), -D( 5288), D(5879), -D(1952), D( 581), -D(222), D( 35), D( 1), +/* 31 */ -D(26), -D(208), -D(401), -D(2063), -D(4788), -D(7134), -D(35640), -D(74992), D(39336), -D( 5959), D(5517), -D(2000), D( 519), -D(218), D( 31), D( 1) +}; + +#undef D + +// DCT32-coefficients were expanded (<<) by DCT32_COEFFICIENT_EXPAND +#define DCT32_COEFFICIENT_EXPAND 31 + +#if defined(MPC_FIXED_POINT) + // define 64=32x32-multiplication for DCT-coefficients with samples. Via usage of MPC_FRACT highly optimized assembler might be used + // MULTIPLY_FRACT will perform >>32 after multiplication, as coef were expanded by DCT32_COEFFICIENT_EXPAND we'll correct this on the result. + // Will loose 4 bit accuracy on result in fract part without effect on final audio result + #define MPC_DCT32_MUL(sample, coef) (MPC_MULTIPLY_FRACT(sample,coef) << (32-DCT32_COEFFICIENT_EXPAND)) + #define MPC_DCT32_SHIFT(sample) (sample) +#else + // for floating point use the standard multiplication macro + #define MPC_DCT32_MUL(sample, coef) (MPC_MULTIPLY(sample, coef) ) + #define MPC_DCT32_SHIFT(sample) (sample) +#endif + +/****************************************************************************** + * mpc_dct32(const int *in, int *out) + * + * mpc_dct32 is a dct32 with in[32]->dct[32] that contains the mirroring from + * dct[32] to the expected out[64]. The symmetry is + * out[16] = 0, + * out[ 0..15] = dct[ 0..15], + * out[32..17] = -dct[ 0..15], + * out[33..48] = -dct[16..31], + * out[63..48] = -dct[16..31]. + * The cos-tab has the format s0.31. + *****************************************************************************/ +void +mpc_dct32(const MPC_SAMPLE_FORMAT *in, MPC_SAMPLE_FORMAT *v) +ICODE_ATTR_MPC_LARGE_IRAM; + +void +mpc_dct32(const MPC_SAMPLE_FORMAT *in, MPC_SAMPLE_FORMAT *v) +{ + MPC_SAMPLE_FORMAT t0, t1, t2, t3, t4, t5, t6, t7; + MPC_SAMPLE_FORMAT t8, t9, t10, t11, t12, t13, t14, t15; + MPC_SAMPLE_FORMAT t16, t17, t18, t19, t20, t21, t22, t23; + MPC_SAMPLE_FORMAT t24, t25, t26, t27, t28, t29, t30, t31; + MPC_SAMPLE_FORMAT t32, t33, t34, t35, t36, t37, t38, t39; + MPC_SAMPLE_FORMAT t40, t41, t42, t43, t44, t45, t46, t47; + MPC_SAMPLE_FORMAT t48, t49, t50, t51, t52, t53, t54, t55; + MPC_SAMPLE_FORMAT t56, t57, t58, t59, t60, t61, t62, t63; + MPC_SAMPLE_FORMAT t64, t65, t66, t67, t68, t69, t70, t71; + MPC_SAMPLE_FORMAT t72, t73, t74, t75, t76, t77, t78, t79; + MPC_SAMPLE_FORMAT t80, t81, t82, t83, t84, t85, t86, t87; + MPC_SAMPLE_FORMAT t88, t89, t90, t91, t92, t93, t94, t95; + MPC_SAMPLE_FORMAT t96, t97, t98, t99, t100, t101, t102, t103; + MPC_SAMPLE_FORMAT t104, t105, t106, t107, t108, t109, t110, t111; + MPC_SAMPLE_FORMAT t112, t113, t114, t115, t116, t117, t118, t119; + MPC_SAMPLE_FORMAT t120, t121, t122, t123, t124, t125, t126, t127; + MPC_SAMPLE_FORMAT t128, t129, t130, t131, t132, t133, t134, t135; + MPC_SAMPLE_FORMAT t136, t137, t138, t139, t140, t141, t142, t143; + MPC_SAMPLE_FORMAT t144, t145, t146, t147, t148, t149, t150, t151; + MPC_SAMPLE_FORMAT t152, t153, t154, t155, t156, t157, t158, t159; + MPC_SAMPLE_FORMAT t160, t161, t162, t163, t164, t165, t166, t167; + MPC_SAMPLE_FORMAT t168, t169, t170, t171, t172, t173, t174, t175; + MPC_SAMPLE_FORMAT t176; + + /* costab[i] = cos(PI / (2 * 32) * i) */ +#define costab01 (0x7fd8878e) /* 0.998795456 */ +#define costab02 (0x7f62368f) /* 0.995184727 */ +#define costab03 (0x7e9d55fc) /* 0.989176510 */ +#define costab04 (0x7d8a5f40) /* 0.980785280 */ +#define costab05 (0x7c29fbee) /* 0.970031253 */ +#define costab06 (0x7a7d055b) /* 0.956940336 */ +#define costab07 (0x78848414) /* 0.941544065 */ +#define costab08 (0x7641af3d) /* 0.923879533 */ +#define costab09 (0x73b5ebd1) /* 0.903989293 */ +#define costab10 (0x70e2cbc6) /* 0.881921264 */ +#define costab11 (0x6dca0d14) /* 0.857728610 */ +#define costab12 (0x6a6d98a4) /* 0.831469612 */ +#define costab13 (0x66cf8120) /* 0.803207531 */ +#define costab14 (0x62f201ac) /* 0.773010453 */ +#define costab15 (0x5ed77c8a) /* 0.740951125 */ +#define costab16 (0x5a82799a) /* 0.707106781 */ +#define costab17 (0x55f5a4d2) /* 0.671558955 */ +#define costab18 (0x5133cc94) /* 0.634393284 */ +#define costab19 (0x4c3fdff4) /* 0.595699304 */ +#define costab20 (0x471cece7) /* 0.555570233 */ +#define costab21 (0x41ce1e65) /* 0.514102744 */ +#define costab22 (0x3c56ba70) /* 0.471396737 */ +#define costab23 (0x36ba2014) /* 0.427555093 */ +#define costab24 (0x30fbc54d) /* 0.382683432 */ +#define costab25 (0x2b1f34eb) /* 0.336889853 */ +#define costab26 (0x25280c5e) /* 0.290284677 */ +#define costab27 (0x1f19f97b) /* 0.242980180 */ +#define costab28 (0x18f8b83c) /* 0.195090322 */ +#define costab29 (0x12c8106f) /* 0.146730474 */ +#define costab30 (0x0c8bd35e) /* 0.098017140 */ +#define costab31 (0x0647d97c) /* 0.049067674 */ + + t0 = in[ 0] + in[31]; t16 = MPC_DCT32_MUL(in[ 0] - in[31], costab01); + t1 = in[15] + in[16]; t17 = MPC_DCT32_MUL(in[15] - in[16], costab31); + + t41 = t16 + t17; + t59 = MPC_DCT32_MUL(t16 - t17, costab02); + t33 = t0 + t1; + t50 = MPC_DCT32_MUL(t0 - t1, costab02); + + t2 = in[ 7] + in[24]; t18 = MPC_DCT32_MUL(in[ 7] - in[24], costab15); + t3 = in[ 8] + in[23]; t19 = MPC_DCT32_MUL(in[ 8] - in[23], costab17); + + t42 = t18 + t19; + t60 = MPC_DCT32_MUL(t18 - t19, costab30); + t34 = t2 + t3; + t51 = MPC_DCT32_MUL(t2 - t3, costab30); + + t4 = in[ 3] + in[28]; t20 = MPC_DCT32_MUL(in[ 3] - in[28], costab07); + t5 = in[12] + in[19]; t21 = MPC_DCT32_MUL(in[12] - in[19], costab25); + + t43 = t20 + t21; + t61 = MPC_DCT32_MUL(t20 - t21, costab14); + t35 = t4 + t5; + t52 = MPC_DCT32_MUL(t4 - t5, costab14); + + t6 = in[ 4] + in[27]; t22 = MPC_DCT32_MUL(in[ 4] - in[27], costab09); + t7 = in[11] + in[20]; t23 = MPC_DCT32_MUL(in[11] - in[20], costab23); + + t44 = t22 + t23; + t62 = MPC_DCT32_MUL(t22 - t23, costab18); + t36 = t6 + t7; + t53 = MPC_DCT32_MUL(t6 - t7, costab18); + + t8 = in[ 1] + in[30]; t24 = MPC_DCT32_MUL(in[ 1] - in[30], costab03); + t9 = in[14] + in[17]; t25 = MPC_DCT32_MUL(in[14] - in[17], costab29); + + t45 = t24 + t25; + t63 = MPC_DCT32_MUL(t24 - t25, costab06); + t37 = t8 + t9; + t54 = MPC_DCT32_MUL(t8 - t9, costab06); + + t10 = in[ 6] + in[25]; t26 = MPC_DCT32_MUL(in[ 6] - in[25], costab13); + t11 = in[ 9] + in[22]; t27 = MPC_DCT32_MUL(in[ 9] - in[22], costab19); + + t46 = t26 + t27; + t64 = MPC_DCT32_MUL(t26 - t27, costab26); + t38 = t10 + t11; + t55 = MPC_DCT32_MUL(t10 - t11, costab26); + + t12 = in[ 2] + in[29]; t28 = MPC_DCT32_MUL(in[ 2] - in[29], costab05); + t13 = in[13] + in[18]; t29 = MPC_DCT32_MUL(in[13] - in[18], costab27); + + t47 = t28 + t29; + t65 = MPC_DCT32_MUL(t28 - t29, costab10); + t39 = t12 + t13; + t56 = MPC_DCT32_MUL(t12 - t13, costab10); + + t14 = in[ 5] + in[26]; t30 = MPC_DCT32_MUL(in[ 5] - in[26], costab11); + t15 = in[10] + in[21]; t31 = MPC_DCT32_MUL(in[10] - in[21], costab21); + + t48 = t30 + t31; + t66 = MPC_DCT32_MUL(t30 - t31, costab22); + t40 = t14 + t15; + t57 = MPC_DCT32_MUL(t14 - t15, costab22); + + t69 = t33 + t34; t89 = MPC_DCT32_MUL(t33 - t34, costab04); + t70 = t35 + t36; t90 = MPC_DCT32_MUL(t35 - t36, costab28); + t71 = t37 + t38; t91 = MPC_DCT32_MUL(t37 - t38, costab12); + t72 = t39 + t40; t92 = MPC_DCT32_MUL(t39 - t40, costab20); + t73 = t41 + t42; t94 = MPC_DCT32_MUL(t41 - t42, costab04); + t74 = t43 + t44; t95 = MPC_DCT32_MUL(t43 - t44, costab28); + t75 = t45 + t46; t96 = MPC_DCT32_MUL(t45 - t46, costab12); + t76 = t47 + t48; t97 = MPC_DCT32_MUL(t47 - t48, costab20); + + t78 = t50 + t51; t100 = MPC_DCT32_MUL(t50 - t51, costab04); + t79 = t52 + t53; t101 = MPC_DCT32_MUL(t52 - t53, costab28); + t80 = t54 + t55; t102 = MPC_DCT32_MUL(t54 - t55, costab12); + t81 = t56 + t57; t103 = MPC_DCT32_MUL(t56 - t57, costab20); + + t83 = t59 + t60; t106 = MPC_DCT32_MUL(t59 - t60, costab04); + t84 = t61 + t62; t107 = MPC_DCT32_MUL(t61 - t62, costab28); + t85 = t63 + t64; t108 = MPC_DCT32_MUL(t63 - t64, costab12); + t86 = t65 + t66; t109 = MPC_DCT32_MUL(t65 - t66, costab20); + + t113 = t69 + t70; + t114 = t71 + t72; + + /* 0 */ v[48] = -MPC_DCT32_SHIFT(t113 + t114); + /* 16 */ v[32] = -(v[ 0] = MPC_DCT32_SHIFT(MPC_DCT32_MUL(t113 - t114, costab16))); + + t115 = t73 + t74; + t116 = t75 + t76; + + t32 = t115 + t116; + + /* 1 */ v[49] = v[47] = -MPC_DCT32_SHIFT(t32); + + t118 = t78 + t79; + t119 = t80 + t81; + + t58 = t118 + t119; + + /* 2 */ v[50] = v[46] = -MPC_DCT32_SHIFT(t58); + + t121 = t83 + t84; + t122 = t85 + t86; + + t67 = t121 + t122; + + t49 = (t67 * 2) - t32; + + /* 3 */ v[51] = v[45] = -MPC_DCT32_SHIFT(t49); + + t125 = t89 + t90; + t126 = t91 + t92; + + t93 = t125 + t126; + + /* 4 */ v[52] = v[44] = -MPC_DCT32_SHIFT(t93); + + t128 = t94 + t95; + t129 = t96 + t97; + + t98 = t128 + t129; + + t68 = (t98 * 2) - t49; + + /* 5 */ v[53] = v[43] = -MPC_DCT32_SHIFT(t68); + + t132 = t100 + t101; + t133 = t102 + t103; + + t104 = t132 + t133; + + t82 = (t104 * 2) - t58; + + /* 6 */ v[54] = v[42] = -MPC_DCT32_SHIFT(t82); + + t136 = t106 + t107; + t137 = t108 + t109; + + t110 = t136 + t137; + + t87 = (t110 * 2) - t67; + + t77 = (t87 * 2) - t68; + + /* 7 */ v[55] = v[41] = -MPC_DCT32_SHIFT(t77); + + t141 = MPC_DCT32_MUL(t69 - t70, costab08); + t142 = MPC_DCT32_MUL(t71 - t72, costab24); + t143 = t141 + t142; + + /* 8 */ v[56] = v[40] = -MPC_DCT32_SHIFT(t143); + /* 24 */ v[24] = -(v[ 8] = MPC_DCT32_SHIFT((MPC_DCT32_MUL(t141 - t142, costab16) * 2) - t143)); + + t144 = MPC_DCT32_MUL(t73 - t74, costab08); + t145 = MPC_DCT32_MUL(t75 - t76, costab24); + t146 = t144 + t145; + + t88 = (t146 * 2) - t77; + + /* 9 */ v[57] = v[39] = -MPC_DCT32_SHIFT(t88); + + t148 = MPC_DCT32_MUL(t78 - t79, costab08); + t149 = MPC_DCT32_MUL(t80 - t81, costab24); + t150 = t148 + t149; + + t105 = (t150 * 2) - t82; + + /* 10 */ v[58] = v[38] = -MPC_DCT32_SHIFT(t105); + + t152 = MPC_DCT32_MUL(t83 - t84, costab08); + t153 = MPC_DCT32_MUL(t85 - t86, costab24); + t154 = t152 + t153; + + t111 = (t154 * 2) - t87; + + t99 = (t111 * 2) - t88; + + /* 11 */ v[59] = v[37] = -MPC_DCT32_SHIFT(t99); + + t157 = MPC_DCT32_MUL(t89 - t90, costab08); + t158 = MPC_DCT32_MUL(t91 - t92, costab24); + t159 = t157 + t158; + + t127 = (t159 * 2) - t93; + + /* 12 */ v[60] = v[36] = -MPC_DCT32_SHIFT(t127); + + t160 = (MPC_DCT32_MUL(t125 - t126, costab16) * 2) - t127; + + /* 20 */ v[28] = -(v[ 4] = MPC_DCT32_SHIFT(t160)); + /* 28 */ v[20] = -(v[12] = MPC_DCT32_SHIFT((((MPC_DCT32_MUL(t157 - t158, costab16) * 2) - t159) * 2) - t160)); + + t161 = MPC_DCT32_MUL(t94 - t95, costab08); + t162 = MPC_DCT32_MUL(t96 - t97, costab24); + t163 = t161 + t162; + + t130 = (t163 * 2) - t98; + + t112 = (t130 * 2) - t99; + + /* 13 */ v[61] = v[35] = -MPC_DCT32_SHIFT(t112); + + t164 = (MPC_DCT32_MUL(t128 - t129, costab16) * 2) - t130; + + t166 = MPC_DCT32_MUL(t100 - t101, costab08); + t167 = MPC_DCT32_MUL(t102 - t103, costab24); + t168 = t166 + t167; + + t134 = (t168 * 2) - t104; + + t120 = (t134 * 2) - t105; + + /* 14 */ v[62] = v[34] = -MPC_DCT32_SHIFT(t120); + + t135 = (MPC_DCT32_MUL(t118 - t119, costab16) * 2) - t120; + + /* 18 */ v[30] = -(v[ 2] = MPC_DCT32_SHIFT(t135)); + + t169 = (MPC_DCT32_MUL(t132 - t133, costab16) * 2) - t134; + + t151 = (t169 * 2) - t135; + + /* 22 */ v[26] = -(v[ 6] = MPC_DCT32_SHIFT(t151)); + + t170 = (((MPC_DCT32_MUL(t148 - t149, costab16) * 2) - t150) * 2) - t151; + + /* 26 */ v[22] = -(v[10] = MPC_DCT32_SHIFT(t170)); + /* 30 */ v[18] = -(v[14] = MPC_DCT32_SHIFT((((((MPC_DCT32_MUL(t166 - t167, costab16) * 2) - t168) * 2) - t169) * 2) - t170)); + + t171 = MPC_DCT32_MUL(t106 - t107, costab08); + t172 = MPC_DCT32_MUL(t108 - t109, costab24); + t173 = t171 + t172; + + t138 = (t173 * 2) - t110; + + t123 = (t138 * 2) - t111; + + t139 = (MPC_DCT32_MUL(t121 - t122, costab16) * 2) - t123; + + t117 = (t123 * 2) - t112; + + /* 15 */ v[63] = v[33] =-MPC_DCT32_SHIFT(t117); + + t124 = (MPC_DCT32_MUL(t115 - t116, costab16) * 2) - t117; + + /* 17 */ v[31] = -(v[ 1] = MPC_DCT32_SHIFT(t124)); + + t131 = (t139 * 2) - t124; + + /* 19 */ v[29] = -(v[ 3] = MPC_DCT32_SHIFT(t131)); + + t140 = (t164 * 2) - t131; + + /* 21 */ v[27] = -(v[ 5] = MPC_DCT32_SHIFT(t140)); + + t174 = (MPC_DCT32_MUL(t136 - t137, costab16) * 2) - t138; + + t155 = (t174 * 2) - t139; + + t147 = (t155 * 2) - t140; + + /* 23 */ v[25] = -(v[ 7] = MPC_DCT32_SHIFT(t147)); + + t156 = (((MPC_DCT32_MUL(t144 - t145, costab16) * 2) - t146) * 2) - t147; + + /* 25 */ v[23] = -(v[ 9] = MPC_DCT32_SHIFT(t156)); + + t175 = (((MPC_DCT32_MUL(t152 - t153, costab16) * 2) - t154) * 2) - t155; + + t165 = (t175 * 2) - t156; + + /* 27 */ v[21] = -(v[11] = MPC_DCT32_SHIFT(t165)); + + t176 = (((((MPC_DCT32_MUL(t161 - t162, costab16) * 2) - t163) * 2) - t164) * 2) - t165; + + /* 29 */ v[19] = -(v[13] = MPC_DCT32_SHIFT(t176)); + /* 31 */ v[17] = -(v[15] = MPC_DCT32_SHIFT((((((((MPC_DCT32_MUL(t171 - t172, costab16) * 2) - t173) * 2) - t174) * 2) - t175) * 2) - t176)); +} + +#if defined(CPU_ARM) || defined(CPU_COLDFIRE) +extern void +mpc_decoder_windowing_D(MPC_SAMPLE_FORMAT * Data, + const MPC_SAMPLE_FORMAT * V, + const MPC_SAMPLE_FORMAT * D); +#else +static void +mpc_decoder_windowing_D(MPC_SAMPLE_FORMAT * Data, + const MPC_SAMPLE_FORMAT * V, + const MPC_SAMPLE_FORMAT * D) +{ + mpc_int32_t k; + + // 64=64x64-multiply (FIXED_POINT) or float=float*float (!FIXED_POINT) in C + for ( k = 0; k < 32; k++, D += 16, V++ ) + { + *Data = MPC_MULTIPLY_EX(V[ 0],D[ 0],30) + MPC_MULTIPLY_EX(V[ 96],D[ 1],30) + + MPC_MULTIPLY_EX(V[128],D[ 2],30) + MPC_MULTIPLY_EX(V[224],D[ 3],30) + + MPC_MULTIPLY_EX(V[256],D[ 4],30) + MPC_MULTIPLY_EX(V[352],D[ 5],30) + + MPC_MULTIPLY_EX(V[384],D[ 6],30) + MPC_MULTIPLY_EX(V[480],D[ 7],30) + + MPC_MULTIPLY_EX(V[512],D[ 8],30) + MPC_MULTIPLY_EX(V[608],D[ 9],30) + + MPC_MULTIPLY_EX(V[640],D[10],30) + MPC_MULTIPLY_EX(V[736],D[11],30) + + MPC_MULTIPLY_EX(V[768],D[12],30) + MPC_MULTIPLY_EX(V[864],D[13],30) + + MPC_MULTIPLY_EX(V[896],D[14],30) + MPC_MULTIPLY_EX(V[992],D[15],30); + Data += 1; + // total: 16 muls, 15 adds, 16 shifts + } +} +#endif /* CPU_ARM || CPU_COLDFIRE */ + +static void +mpc_full_synthesis_filter(MPC_SAMPLE_FORMAT *OutData, MPC_SAMPLE_FORMAT *V, + const MPC_SAMPLE_FORMAT *Y) ICODE_ATTR_MPC_LARGE_IRAM; +static void +mpc_full_synthesis_filter(MPC_SAMPLE_FORMAT *OutData, MPC_SAMPLE_FORMAT *V, + const MPC_SAMPLE_FORMAT *Y) +{ + mpc_uint32_t n; + + if (NULL != OutData) + { + for ( n = 0; n < 36; n++, Y += 32, OutData += 32 ) + { + V -= 64; + mpc_dct32(Y, V); + mpc_decoder_windowing_D( OutData, V, Di_opt ); + } + } +} + +void +mpc_decoder_synthese_filter_float(mpc_decoder *d, MPC_SAMPLE_FORMAT *OutData, + int num_channels) +{ + (void)num_channels; + + /********* left channel ********/ + memmove(d->V_L + MPC_V_MEM, d->V_L, 960 * sizeof(MPC_SAMPLE_FORMAT) ); + mpc_full_synthesis_filter(OutData, + (MPC_SAMPLE_FORMAT *)(d->V_L + MPC_V_MEM), + (MPC_SAMPLE_FORMAT *)(d->Y_L)); + + /******** right channel ********/ + memmove(d->V_R + MPC_V_MEM, d->V_R, 960 * sizeof(MPC_SAMPLE_FORMAT) ); + mpc_full_synthesis_filter((OutData == NULL ? NULL : OutData + MPC_FRAME_LENGTH), + (MPC_SAMPLE_FORMAT *)(d->V_R + MPC_V_MEM), + (MPC_SAMPLE_FORMAT *)(d->Y_R)); +} + +/*******************************************/ +/* */ +/* dithered synthesis */ +/* */ +/*******************************************/ + +static const unsigned char Parity [256] = { // parity + 0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1, + 1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0, + 1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0, + 0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1, + 1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0, + 0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1, + 0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1, + 1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0 +}; + +/* + * This is a simple random number generator with good quality for audio purposes. + * It consists of two polycounters with opposite rotation direction and different + * periods. The periods are coprime, so the total period is the product of both. + * + * ------------------------------------------------------------------------------------------------- + * +-> |31:30:29:28:27:26:25:24:23:22:21:20:19:18:17:16:15:14:13:12:11:10: 9: 8: 7: 6: 5: 4: 3: 2: 1: 0| + * | ------------------------------------------------------------------------------------------------- + * | | | | | | | + * | +--+--+--+-XOR-+--------+ + * | | + * +--------------------------------------------------------------------------------------+ + * + * ------------------------------------------------------------------------------------------------- + * |31:30:29:28:27:26:25:24:23:22:21:20:19:18:17:16:15:14:13:12:11:10: 9: 8: 7: 6: 5: 4: 3: 2: 1: 0| <-+ + * ------------------------------------------------------------------------------------------------- | + * | | | | | + * +--+----XOR----+--+ | + * | | + * +----------------------------------------------------------------------------------------+ + * + * + * The first has an period of 3*5*17*257*65537, the second of 7*47*73*178481, + * which gives a period of 18.410.713.077.675.721.215. The result is the + * XORed values of both generators. + */ +mpc_uint32_t +mpc_random_int(mpc_decoder *d) +{ +#if 1 + mpc_uint32_t t1, t2, t3, t4; + + t3 = t1 = d->__r1; t4 = t2 = d->__r2; // Parity calculation is done via table lookup, this is also available + t1 &= 0xF5; t2 >>= 25; // on CPUs without parity, can be implemented in C and avoid unpredictable + t1 = Parity [t1]; t2 &= 0x63; // jumps and slow rotate through the carry flag operations. + t1 <<= 31; t2 = Parity [t2]; + + return (d->__r1 = (t3 >> 1) | t1 ) ^ (d->__r2 = (t4 + t4) | t2 ); +#else + return (d->__r1 = (d->__r1 >> 1) | ((mpc_uint32_t)Parity [d->__r1 & 0xF5] << 31) ) ^ + (d->__r2 = (d->__r2 << 1) | (mpc_uint32_t)Parity [(d->__r2 >> 25) & 0x63] ); +#endif +} diff --git a/lib/rbcodec/codecs/libmusepack/synth_filter_arm.S b/lib/rbcodec/codecs/libmusepack/synth_filter_arm.S new file mode 100644 index 0000000000..9bd4e04626 --- /dev/null +++ b/lib/rbcodec/codecs/libmusepack/synth_filter_arm.S @@ -0,0 +1,693 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2008 by Andree Buschmann + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include "config.h" + +#if defined(CPU_S5L870X) + /* Moving this asm routine to iram is (little) faster on S5L870x. */ + .section .icode, "ax", %progbits +#else + .section .text, "ax", %progbits +#endif + +/**************************************************************************** + * void mpc_decoder_windowing_D(...) + * + * 2nd step within synthesis filter. Does the dewindowing. + * 64=32x32 multiplies + * Uses un-shifted D[]-values. D[] will always be the second operand of + * smull/smlal to achieve higher speed as D[] has lower amplitude than V[]. + ****************************************************************************/ + .align 2 + .global mpc_decoder_windowing_D + .type mpc_decoder_windowing_D, %function +#if 0 +mpc_decoder_windowing_D: + /* r0 = Data[] */ + /* r1 = V[] */ + /* r2 = D[] */ + /* lr = counter */ + /************************************************************************ + * Reference implementation. + ***********************************************************************/ + stmfd sp!, {r4-r8, lr} + + mov lr, #32 +.loop32: + ldmia r2!, { r3-r6 } /* load D[00..03] */ + ldr r7, [r1] /* 0 */ + smull r8, r12, r7, r3 + ldr r7, [r1, #96*4] /* 1 */ + smlal r8, r12, r7, r4 + ldr r7, [r1, #128*4] /* 2 */ + smlal r8, r12, r7, r5 + ldr r7, [r1, #224*4] /* 3 */ + smlal r8, r12, r7, r6 + ldmia r2!, { r3-r6 } /* load D[04..07] */ + ldr r7, [r1, #256*4] /* 4 */ + smlal r8, r12, r7, r3 + ldr r7, [r1, #352*4] /* 5 */ + smlal r8, r12, r7, r4 + ldr r7, [r1, #384*4] /* 6 */ + smlal r8, r12, r7, r5 + ldr r7, [r1, #480*4] /* 7 */ + smlal r8, r12, r7, r6 + ldmia r2!, { r3-r6 } /* load D[08..11] */ + ldr r7, [r1, #512*4] /* 8 */ + smlal r8, r12, r7, r3 + ldr r7, [r1, #608*4] /* 9 */ + smlal r8, r12, r7, r4 + ldr r7, [r1, #640*4] /* 10 */ + smlal r8, r12, r7, r5 + ldr r7, [r1, #736*4] /* 11 */ + smlal r8, r12, r7, r6 + ldmia r2!, { r3-r6 } /* load D[12..15] */ + ldr r7, [r1, #768*4] /* 12 */ + smlal r8, r12, r7, r3 + ldr r7, [r1, #864*4] /* 13 */ + smlal r8, r12, r7, r4 + ldr r7, [r1, #896*4] /* 14 */ + smlal r8, r12, r7, r5 + ldr r7, [r1, #992*4] /* 15 */ + smlal r8, r12, r7, r6 + mov r8, r8, lsr #16 + orr r8, r8, r12, lsl #16 /* (lo>>16) || (hi<<16) */ + str r8, [r0], #4 /* store Data */ + add r1, r1, #4 /* V++ */ + + subs lr, lr, #1 + bgt .loop32 + + ldmpc regs=r4-r8 +#elif defined(CPU_ARM7TDMI) /* arm7 only */ +mpc_decoder_windowing_D: + /* r0 = Data[] */ + /* r1 = V[] */ + /* r2 = D[] */ + /* lr = counter */ + /************************************************************************ + * Further speed up through making use of symmetries within D[]-window. + * The row V[00] can be extracted as it has symmetries within this single + * row. 8 smull/mlal and 8 ldr's can be saved at the cost of 2 add's. + * The rows V[01..15] are symmetric to V[31..17]. 15 x 16 ldr's can be + * saved at the cost of 15 x 4 + 1 add's. + * The row V[16] can be extracted as it has symmetries within this single + * row. 8 smull/mlal and 8 ldr's can be saved. + * Used for arm7 only. For arm9 and above see implementation below. + ***********************************************************************/ + stmfd sp!, {r4-r11, lr} + + /****************************************** + * row 0 with internal symmetry + *****************************************/ + add r2, r2, #4 /* D+=1, r2 = D[01] as D[00] = 0 */ + ldmia r2!, { r3-r6 } /* load D[01..04] */ + ldr r7 , [r1, #96*4] /* 1 */ + ldr r10, [r1, #992*4] /* 15 */ + rsb r10, r10, r7 /* V[01] - V[15] */ + smull r8, r9, r10, r3 + ldr r7 , [r1, #128*4] /* 2 */ + ldr r10, [r1, #896*4] /* 14 */ + add r10, r10, r7 /* V[02] + V[14] */ + smlal r8, r9, r10, r4 + ldr r7 , [r1, #224*4] /* 3 */ + ldr r10, [r1, #864*4] /* 13 */ + rsb r10, r10, r7 /* V[03] - V[13] */ + smlal r8, r9, r10, r5 + ldr r7 , [r1, #256*4] /* 4 */ + ldr r10, [r1, #768*4] /* 12 */ + add r10, r10, r7 /* V[04] + V[12] */ + smlal r8, r9, r10, r6 + ldmia r2!, { r3-r6 } /* load D[05..08] */ + ldr r7 , [r1, #352*4] /* 5 */ + ldr r10, [r1, #736*4] /* 11 */ + rsb r10, r10, r7 /* V[05] - V[11] */ + smlal r8, r9, r10, r3 + ldr r7 , [r1, #384*4] /* 6 */ + ldr r10, [r1, #640*4] /* 10 */ + add r10, r10, r7 /* V[06] + V[10] */ + smlal r8, r9, r10, r4 + ldr r7 , [r1, #480*4] /* 7 */ + ldr r10, [r1, #608*4] /* 9 */ + rsb r10, r10, r7 /* V[07] - V[09] */ + smlal r8, r9, r10, r5 + ldr r10, [r1, #512*4] /* 8 */ + smlal r8, r9, r10, r6 + mov r8, r8, lsr #16 + orr r8, r8, r9, lsl #16 /* (lo>>16) || (hi<<16) */ + str r8, [r0], #4 /* store Data */ + add r1, r1, #4 /* V+=1, r1 = V[01] */ + add r2, r2, #7*4 /* D+=7, r2 = D[16] */ + + /****************************************** + * rows 01..15 are symmetric to rows 31..17 + * r8 = lo, r9 = hi of 01..15 + * r1 = V[01..15] + * r10 = lo, r11 = hi of 31..17 + * r12 = V[31..16] + *****************************************/ + mov lr, #15*8 + add r12, r1, #30*4 /* r12 = V[31] */ +.loop15: + ldmia r2!, { r3-r6 } /* load D[00..03] */ + ldr r7, [r12, #768*4] /* 12 */ + smull r10, r11, r7, r6 + ldr r7, [r12, #864*4] /* 13 */ + smlal r10, r11, r7, r5 + ldr r7, [r12, #896*4] /* 14 */ + smlal r10, r11, r7, r4 + ldr r7, [r12, #992*4] /* 15 */ + smlal r10, r11, r7, r3 + ldr r7, [r1] /* 0 */ + smull r8, r9, r7, r3 + ldr r7, [r1, #96*4] /* 1 */ + smlal r8, r9, r7, r4 + ldr r7, [r1, #128*4] /* 2 */ + smlal r8, r9, r7, r5 + ldr r7, [r1, #224*4] /* 3 */ + smlal r8, r9, r7, r6 + ldmia r2!, { r3-r6 } /* load D[04..07] */ + ldr r7, [r1, #256*4] /* 4 */ + smlal r8, r9, r7, r3 + ldr r7, [r1, #352*4] /* 5 */ + smlal r8, r9, r7, r4 + ldr r7, [r1, #384*4] /* 6 */ + smlal r8, r9, r7, r5 + ldr r7, [r1, #480*4] /* 7 */ + smlal r8, r9, r7, r6 + ldr r7, [r12, #512*4] /* 8 */ + smlal r10, r11, r7, r6 + ldr r7, [r12, #608*4] /* 9 */ + smlal r10, r11, r7, r5 + ldr r7, [r12, #640*4] /* 10 */ + smlal r10, r11, r7, r4 + ldr r7, [r12, #736*4] /* 11 */ + smlal r10, r11, r7, r3 + ldmia r2!, { r3-r6 } /* load D[08..11] */ + ldr r7, [r12, #256*4] /* 4 */ + smlal r10, r11, r7, r6 + ldr r7, [r12, #352*4] /* 5 */ + smlal r10, r11, r7, r5 + ldr r7, [r12, #384*4] /* 6 */ + smlal r10, r11, r7, r4 + ldr r7, [r12, #480*4] /* 7 */ + smlal r10, r11, r7, r3 + ldr r7, [r1, #512*4] /* 8 */ + smlal r8, r9, r7, r3 + ldr r7, [r1, #608*4] /* 9 */ + smlal r8, r9, r7, r4 + ldr r7, [r1, #640*4] /* 10 */ + smlal r8, r9, r7, r5 + ldr r7, [r1, #736*4] /* 11 */ + smlal r8, r9, r7, r6 + ldmia r2!, { r3-r6 } /* load D[12..15] */ + ldr r7, [r1, #768*4] /* 12 */ + smlal r8, r9, r7, r3 + ldr r7, [r1, #864*4] /* 13 */ + smlal r8, r9, r7, r4 + ldr r7, [r1, #896*4] /* 14 */ + smlal r8, r9, r7, r5 + ldr r7, [r1, #992*4] /* 15 */ + smlal r8, r9, r7, r6 + ldr r7, [r12] /* 0 */ + smlal r10, r11, r7, r6 + ldr r7, [r12, #96*4] /* 1 */ + smlal r10, r11, r7, r5 + ldr r7, [r12, #128*4] /* 2 */ + smlal r10, r11, r7, r4 + ldr r7, [r12, #224*4] /* 3 */ + smlal r10, r11, r7, r3 + /* store Data[01..15] */ + mov r8, r8, lsr #16 + orr r8, r8, r9, lsl #16 /* (lo>>16) || (hi<<16) */ + /* store Data[31..17] */ + mov r10, r10, lsr #16 + orr r10, r10, r11, lsl #16 /* (lo>>16) || (hi<<16) */ + rsb r10, r10, #0 /* r10 = -r10 */ + str r10, [r0, lr] /* store Data */ + str r8, [r0], #4 /* store Data */ + /* correct adresses for next loop */ + sub r12, r12, #4 /* r12 = V-- */ + add r1, r1, #4 /* r1 = V++ */ + /* next loop */ + subs lr, lr, #8 + bgt .loop15 + + /****************************************** + * V[16] with internal symmetry + *****************************************/ + ldmia r2!, { r3-r6 } /* load D[00..03] */ + ldr r7 , [r1] /* 0 */ + ldr r10, [r1, #992*4] /* 15 */ + rsb r10, r10, r7 /* V[00] - V[15] */ + smull r8, r9, r10, r3 + ldr r7 , [r1, #96*4] /* 1 */ + ldr r10, [r1, #896*4] /* 14 */ + rsb r10, r10, r7 /* V[01] - V[14] */ + smlal r8, r9, r10, r4 + ldr r7 , [r1, #128*4] /* 2 */ + ldr r10, [r1, #864*4] /* 13 */ + rsb r10, r10, r7 /* V[02] - V[13] */ + smlal r8, r9, r10, r5 + ldr r7 , [r1, #224*4] /* 3 */ + ldr r10, [r1, #768*4] /* 12 */ + rsb r10, r10, r7 /* V[03] - V[12] */ + smlal r8, r9, r10, r6 + ldmia r2!, { r3-r6 } /* load D[04..07] */ + ldr r7 , [r1, #256*4] /* 4 */ + ldr r10, [r1, #736*4] /* 11 */ + rsb r10, r10, r7 /* V[04] - V[11] */ + smlal r8, r9, r10, r3 + ldr r7 , [r1, #352*4] /* 5 */ + ldr r10, [r1, #640*4] /* 10 */ + rsb r10, r10, r7 /* V[05] - V[10] */ + smlal r8, r9, r10, r4 + ldr r7 , [r1, #384*4] /* 6 */ + ldr r10, [r1, #608*4] /* 9 */ + rsb r10, r10, r7 /* V[06] - V[09] */ + smlal r8, r9, r10, r5 + ldr r7 , [r1, #480*4] /* 7 */ + ldr r10, [r1, #512*4] /* 8 */ + rsb r10, r10, r7 /* V[07] - V[08] */ + smlal r8, r9, r10, r6 + mov r8, r8, lsr #16 + orr r8, r8, r9, lsl #16 /* (lo>>16) || (hi<<16) */ + str r8, [r0], #4 /* store Data */ + + ldmpc regs=r4-r11 +#elif ARM_ARCH < 6 /* arm9 and above */ + mpc_decoder_windowing_D: + /* r0 = Data[] */ + /* r1 = V[] */ + /* r2 = D[] */ + /* lr = counter */ + /************************************************************************ + * Further speed up through making use of symmetries within D[]-window. + * The row V[00] can be extracted as it has symmetries within this single + * row. 8 smull/mlal and 8 ldr's can be saved at the cost of 2 add's. + * The rows V[01..15] are symmetric to V[31..17]. 15 x 16 ldr's can be + * saved at the cost of 15 x 4 + 1 add's. + * The row V[16] can be extracted as it has symmetries within this single + * row. 8 smull/mlal and 8 ldr's can be saved. + * On arm9 (still armv4 architecture) reducing stalls after ldr/ldm speeds + * up decoding even though several ldm-calls are replaced with ldr to free + * 2 registers. + ***********************************************************************/ + stmfd sp!, {r4-r11, lr} + + /****************************************** + * row 0 with internal symmetry + *****************************************/ + add r2, r2, #4 /* D+=1, r2 = D[01] as D[00] = 0 */ + ldmia r2!, { r3-r6 } /* load D[01..04] */ + ldr r7 , [r1, #96*4] /* 1 */ + ldr r10, [r1, #992*4] /* 15 */ + ldr r11, [r1, #128*4] /* 2 */ + ldr r12, [r1, #896*4] /* 14 */ + rsb r10, r10, r7 /* V[01] - V[15] */ + smull r8, r9, r10, r3 + ldr r7 , [r1, #224*4] /* 3 */ + ldr r10, [r1, #864*4] /* 13 */ + add r12, r12, r11 /* V[02] + V[14] */ + smlal r8, r9, r12, r4 + ldr r11, [r1, #256*4] /* 4 */ + ldr r12, [r1, #768*4] /* 12 */ + rsb r10, r10, r7 /* V[03] - V[13] */ + smlal r8, r9, r10, r5 + ldr r7 , [r1, #352*4] /* 5 */ + ldr r10, [r1, #736*4] /* 11 */ + add r12, r12, r11 /* V[04] + V[12] */ + smlal r8, r9, r12, r6 + ldmia r2!, { r3-r6 } /* load D[05..08] */ + ldr r11, [r1, #384*4] /* 6 */ + ldr r12, [r1, #640*4] /* 10 */ + rsb r10, r10, r7 /* V[05] - V[11] */ + smlal r8, r9, r10, r3 + ldr r7 , [r1, #480*4] /* 7 */ + ldr r10, [r1, #608*4] /* 9 */ + add r12, r12, r11 /* V[06] + V[10] */ + smlal r8, r9, r12, r4 + ldr r11, [r1, #512*4] /* 8 */ + rsb r10, r10, r7 /* V[07] - V[09] */ + smlal r8, r9, r10, r5 + smlal r8, r9, r11, r6 + mov r8, r8, lsr #16 + orr r8, r8, r9, lsl #16 /* (lo>>16) || (hi<<16) */ + str r8, [r0], #4 /* store Data */ + add r1, r1, #4 /* V+=1, r1 = V[01] */ + add r2, r2, #7*4 /* D+=7, r2 = D[16] */ + + /****************************************** + * rows 01..15 are symmetric to rows 31..17 + * r8 = lo, r9 = hi of 01..15 + * r1 = V[01..15] + * r10 = lo, r11 = hi of 31..17 + * r12 = V[31..16] + *****************************************/ + mov lr, #15*8 + add r12, r1, #30*4 /* r12 = V[31] */ +.loop15: + ldmia r2!, { r3-r4 } /* load D[00..01] */ + ldr r7, [r12, #896*4] /* 14 */ + ldr r5, [r12, #992*4] /* 15 */ + smull r10, r11, r7, r4 + ldr r7, [r1] /* 0 */ + smlal r10, r11, r5, r3 + ldr r5, [r1, #96*4] /* 1 */ + smull r8, r9, r7, r3 + ldr r7, [r12, #768*4] /* 12 */ + smlal r8, r9, r5, r4 + ldmia r2!, { r3-r4 } /* load D[02..03] */ + ldr r5, [r12, #864*4] /* 13 */ + smlal r10, r11, r7, r4 + ldr r7, [r1, #128*4] /* 2 */ + smlal r10, r11, r5, r3 + ldr r5, [r1, #224*4] /* 3 */ + smlal r8, r9, r7, r3 + ldr r7, [r1, #256*4] /* 4 */ + smlal r8, r9, r5, r4 + ldmia r2!, { r3-r4 } /* load D[04..04] */ + ldr r5, [r1, #352*4] /* 5 */ + smlal r8, r9, r7, r3 + ldr r7, [r12, #640*4] /* 10 */ + smlal r8, r9, r5, r4 + ldr r5, [r12, #736*4] /* 11 */ + smlal r10, r11, r7, r4 + ldr r7, [r1, #384*4] /* 6 */ + smlal r10, r11, r5, r3 + ldmia r2!, { r3-r4 } /* load D[06..07] */ + ldr r5, [r1, #480*4] /* 7 */ + smlal r8, r9, r7, r3 + ldr r7, [r12, #512*4] /* 8 */ + smlal r8, r9, r5, r4 + ldr r5, [r12, #608*4] /* 9 */ + smlal r10, r11, r7, r4 + ldr r7, [r12, #384*4] /* 6 */ + smlal r10, r11, r5, r3 + ldmia r2!, { r3-r4 } /* load D[08..09] */ + ldr r5, [r12, #480*4] /* 7 */ + smlal r10, r11, r7, r4 + ldr r7, [r1, #512*4] /* 8 */ + smlal r10, r11, r5, r3 + ldr r5, [r1, #608*4] /* 9 */ + smlal r8, r9, r7, r3 + ldr r7, [r1, #640*4] /* 10 */ + smlal r8, r9, r5, r4 + ldmia r2!, { r3-r4 } /* load D[10..11] */ + ldr r5, [r1, #736*4] /* 11 */ + smlal r8, r9, r7, r3 + ldr r7, [r12, #256*4] /* 4 */ + smlal r8, r9, r5, r4 + ldr r5, [r12, #352*4] /* 5 */ + smlal r10, r11, r7, r4 + ldr r7, [r1, #768*4] /* 12 */ + smlal r10, r11, r5, r3 + ldmia r2!, { r3-r4 } /* load D[12..13] */ + ldr r5, [r1, #864*4] /* 13 */ + smlal r8, r9, r7, r3 + ldr r7, [r12, #128*4] /* 2 */ + smlal r8, r9, r5, r4 + ldr r5, [r12, #224*4] /* 3 */ + smlal r10, r11, r7, r4 + ldr r7, [r12] /* 0 */ + smlal r10, r11, r5, r3 + ldmia r2!, { r3-r4 } /* load D[14..15] */ + ldr r5, [r12, #96*4] /* 1 */ + smlal r10, r11, r7, r4 + ldr r7, [r1, #896*4] /* 14 */ + smlal r10, r11, r5, r3 + ldr r5, [r1, #992*4] /* 15 */ + smlal r8, r9, r7, r3 + smlal r8, r9, r5, r4 + /* store Data[01..15] */ + mov r8, r8, lsr #16 + orr r8, r8, r9, lsl #16 /* (lo>>16) || (hi<<16) */ + /* store Data[31..17] */ + mov r10, r10, lsr #16 + orr r10, r10, r11, lsl #16 /* (lo>>16) || (hi<<16) */ + rsb r10, r10, #0 /* r10 = -r10 */ + str r10, [r0, lr] /* store Data */ + str r8, [r0], #4 /* store Data */ + /* correct adresses for next loop */ + sub r12, r12, #4 /* r12 = V-- */ + add r1, r1, #4 /* r1 = V++ */ + /* next loop */ + subs lr, lr, #8 + bgt .loop15 + + /****************************************** + * V[16] with internal symmetry + *****************************************/ + ldmia r2!, { r3-r6 } /* load D[00..03] */ + ldr r7 , [r1] /* 0 */ + ldr r10, [r1, #992*4] /* 15 */ + ldr r11, [r1, #96*4] /* 1 */ + ldr r12, [r1, #896*4] /* 14 */ + rsb r10, r10, r7 /* V[00] - V[15] */ + smull r8, r9, r10, r3 + ldr r7 , [r1, #128*4] /* 2 */ + ldr r10, [r1, #864*4] /* 13 */ + rsb r12, r12, r11 /* V[01] - V[14] */ + smlal r8, r9, r12, r4 + ldr r11, [r1, #224*4] /* 3 */ + ldr r12, [r1, #768*4] /* 12 */ + rsb r10, r10, r7 /* V[02] - V[13] */ + smlal r8, r9, r10, r5 + ldr r7 , [r1, #256*4] /* 4 */ + ldr r10, [r1, #736*4] /* 11 */ + rsb r12, r12, r11 /* V[03] - V[12] */ + smlal r8, r9, r12, r6 + ldmia r2!, { r3-r6 } /* load D[04..07] */ + ldr r11, [r1, #352*4] /* 5 */ + ldr r12, [r1, #640*4] /* 10 */ + rsb r10, r10, r7 /* V[04] - V[11] */ + smlal r8, r9, r10, r3 + ldr r7 , [r1, #384*4] /* 6 */ + ldr r10, [r1, #608*4] /* 9 */ + rsb r12, r12, r11 /* V[05] - V[10] */ + smlal r8, r9, r12, r4 + ldr r11, [r1, #480*4] /* 7 */ + ldr r12, [r1, #512*4] /* 8 */ + rsb r10, r10, r7 /* V[06] - V[09] */ + smlal r8, r9, r10, r5 + rsb r12, r12, r11 /* V[07] - V[08] */ + smlal r8, r9, r12, r6 + mov r8, r8, lsr #16 + orr r8, r8, r9, lsl #16 /* (lo>>16) || (hi<<16) */ + str r8, [r0], #4 /* store Data */ + + ldmpc regs=r4-r11 +#else + mpc_decoder_windowing_D: + /* r0 = Data[] */ + /* r1 = V[] */ + /* r2 = D[] */ + /* lr = counter */ + /************************************************************************ + * Further speed up through making use of symmetries within D[]-window. + * The row V[00] can be extracted as it has symmetries within this single + * row. 8 smull/mlal and 8 ldr's can be saved at the cost of 2 add's. + * The rows V[01..15] are symmetric to V[31..17]. 15 x 16 ldr's can be + * saved at the cost of 15 x 4 + 1 add's. + * The row V[16] can be extracted as it has symmetries within this single + * row. 8 smull/mlal and 8 ldr's can be saved. + * On armv6 use smmulr/smlalr which are faster than smull/smlal and only + * accumulate the top 32 bits of the result so that frees up 2 + * registers so we can ldm larger blocks. + ***********************************************************************/ + stmfd sp!, {r4-r11, lr} + + /****************************************** + * row 0 with internal symmetry + *****************************************/ + add r2, r2, #4 /* D+=1, r2 = D[01] as D[00] = 0 */ + ldmia r2!, { r3-r6 } /* load D[01..04] */ + ldr r7 , [r1, #96*4] /* 1 */ + ldr r10, [r1, #992*4] /* 15 */ + ldr r11, [r1, #128*4] /* 2 */ + rsb r10, r10, r7 /* V[01] - V[15] */ + ldr r12, [r1, #896*4] /* 14 */ + smmulr r9, r10, r3 + ldr r7 , [r1, #224*4] /* 3 */ + add r12, r12, r11 /* V[02] + V[14] */ + ldr r10, [r1, #864*4] /* 13 */ + smmlar r9, r12, r4, r9 + ldr r11, [r1, #256*4] /* 4 */ + rsb r10, r10, r7 /* V[03] - V[13] */ + ldr r12, [r1, #768*4] /* 12 */ + smmlar r9, r10, r5, r9 + ldr r7 , [r1, #352*4] /* 5 */ + add r12, r12, r11 /* V[04] + V[12] */ + ldr r10, [r1, #736*4] /* 11 */ + smmlar r9, r12, r6, r9 + ldmia r2!, { r3-r6 } /* load D[05..08] */ + ldr r11, [r1, #384*4] /* 6 */ + rsb r10, r10, r7 /* V[05] - V[11] */ + ldr r12, [r1, #640*4] /* 10 */ + smmlar r9, r10, r3, r9 + ldr r7 , [r1, #480*4] /* 7 */ + add r12, r12, r11 /* V[06] + V[10] */ + ldr r10, [r1, #608*4] /* 9 */ + smmlar r9, r12, r4, r9 + rsb r10, r10, r7 /* V[07] - V[09] */ + ldr r11, [r1, #512*4] /* 8 */ + smmlar r9, r10, r5, r9 + add r1, r1, #4 /* V+=1, r1 = V[01] */ + smmlar r9, r11, r6, r9 + add r2, r2, #7*4 /* D+=7, r2 = D[16] */ + mov r9, r9, lsl #2 + str r9, [r0], #4 /* store Data */ + + /****************************************** + * rows 01..15 are symmetric to rows 31..17 + * r9 = acc of 01..15 + * r1 = V[01..15] + * r11 = acc of 31..17 + * r12 = V[31..16] + *****************************************/ + mov lr, #15*8 + add r12, r1, #30*4 /* r12 = V[31] */ +.loop15: + ldmia r2!, { r3-r6 } /* load D[00..03] */ + ldr r7, [r12, #896*4] /* 14 */ + ldr r8, [r12, #992*4] /* 15 */ + smmulr r11, r7, r4 + ldr r7, [r1] /* 0 */ + smmlar r11, r8, r3, r11 + ldr r8, [r1, #96*4] /* 1 */ + smmulr r9, r7, r3 + ldr r7, [r12, #768*4] /* 12 */ + smmlar r9, r8, r4, r9 + ldr r8, [r12, #864*4] /* 13 */ + smmlar r11, r7, r6, r11 + ldr r7, [r1, #128*4] /* 2 */ + smmlar r11, r8, r5, r11 + ldr r8, [r1, #224*4] /* 3 */ + smmlar r9, r7, r5, r9 + ldr r7, [r1, #256*4] /* 4 */ + smmlar r9, r8, r6, r9 + ldmia r2!, { r3-r6 } /* load D[04..07] */ + ldr r8, [r1, #352*4] /* 5 */ + smmlar r9, r7, r3, r9 + ldr r7, [r12, #640*4] /* 10 */ + smmlar r9, r8, r4, r9 + ldr r8, [r12, #736*4] /* 11 */ + smmlar r11, r7, r4, r11 + ldr r7, [r1, #384*4] /* 6 */ + smmlar r11, r8, r3, r11 + ldr r8, [r1, #480*4] /* 7 */ + smmlar r9, r7, r5, r9 + ldr r7, [r12, #512*4] /* 8 */ + smmlar r9, r8, r6, r9 + ldr r8, [r12, #608*4] /* 9 */ + smmlar r11, r7, r6, r11 + ldr r7, [r12, #384*4] /* 6 */ + smmlar r11, r8, r5, r11 + ldmia r2!, { r3-r6 } /* load D[08..11] */ + ldr r8, [r12, #480*4] /* 7 */ + smmlar r11, r7, r4, r11 + ldr r7, [r1, #512*4] /* 8 */ + smmlar r11, r8, r3, r11 + ldr r8, [r1, #608*4] /* 9 */ + smmlar r9, r7, r3, r9 + ldr r7, [r1, #640*4] /* 10 */ + smmlar r9, r8, r4, r9 + ldr r8, [r1, #736*4] /* 11 */ + smmlar r9, r7, r5, r9 + ldr r7, [r12, #256*4] /* 4 */ + smmlar r9, r8, r6, r9 + ldr r8, [r12, #352*4] /* 5 */ + smmlar r11, r7, r6, r11 + ldr r7, [r1, #768*4] /* 12 */ + smmlar r11, r8, r5, r11 + ldmia r2!, { r3-r6 } /* load D[12..15] */ + ldr r8, [r1, #864*4] /* 13 */ + smmlar r9, r7, r3, r9 + ldr r7, [r12, #128*4] /* 2 */ + smmlar r9, r8, r4, r9 + ldr r8, [r12, #224*4] /* 3 */ + smmlar r11, r7, r4, r11 + ldr r7, [r12] /* 0 */ + smmlar r11, r8, r3, r11 + ldr r8, [r12, #96*4] /* 1 */ + smmlar r11, r7, r6, r11 + ldr r7, [r1, #896*4] /* 14 */ + smmlar r11, r8, r5, r11 + ldr r8, [r1, #992*4] /* 15 */ + smmlar r9, r7, r5, r9 + sub r12, r12, #4 /* r12 = V-- correct adresses for next loop */ + smmlar r9, r8, r6, r9 + add r1, r1, #4 /* r1 = V++ correct adresses for next loop */ + rsb r11, r11, #0 /* r11 = -r11 */ + /* store Data[01..15] */ + mov r9, r9, lsl #2 + /* store Data[31..17] */ + mov r11, r11, lsl #2 + str r11, [r0, lr] /* store Data */ + str r9, [r0], #4 /* store Data */ + /* next loop */ + subs lr, lr, #8 + bgt .loop15 + + /****************************************** + * V[16] with internal symmetry + *****************************************/ + ldmia r2!, { r3-r6 } /* load D[00..03] */ + ldr r7 , [r1] /* 0 */ + ldr r10, [r1, #992*4] /* 15 */ + ldr r11, [r1, #96*4] /* 1 */ + rsb r10, r10, r7 /* V[00] - V[15] */ + ldr r12, [r1, #896*4] /* 14 */ + smmulr r9, r10, r3 + ldr r7 , [r1, #128*4] /* 2 */ + rsb r12, r12, r11 /* V[01] - V[14] */ + ldr r10, [r1, #864*4] /* 13 */ + smmlar r9, r12, r4, r9 + ldr r11, [r1, #224*4] /* 3 */ + rsb r10, r10, r7 /* V[02] - V[13] */ + ldr r12, [r1, #768*4] /* 12 */ + smmlar r9, r10, r5, r9 + ldr r7 , [r1, #256*4] /* 4 */ + rsb r12, r12, r11 /* V[03] - V[12] */ + ldr r10, [r1, #736*4] /* 11 */ + smmlar r9, r12, r6, r9 + ldmia r2!, { r3-r6 } /* load D[04..07] */ + ldr r11, [r1, #352*4] /* 5 */ + rsb r10, r10, r7 /* V[04] - V[11] */ + ldr r12, [r1, #640*4] /* 10 */ + smmlar r9, r10, r3, r9 + ldr r7 , [r1, #384*4] /* 6 */ + rsb r12, r12, r11 /* V[05] - V[10] */ + ldr r10, [r1, #608*4] /* 9 */ + smmlar r9, r12, r4, r9 + ldr r11, [r1, #480*4] /* 7 */ + rsb r10, r10, r7 /* V[06] - V[09] */ + ldr r12, [r1, #512*4] /* 8 */ + smmlar r9, r10, r5, r9 + rsb r12, r12, r11 /* V[07] - V[08] */ + smmlar r9, r12, r6, r9 + mov r9, r9, lsl #2 + str r9, [r0], #4 /* store Data */ + + ldmpc regs=r4-r11 +#endif +.mpc_dewindowing_end: + .size mpc_decoder_windowing_D,.mpc_dewindowing_end-mpc_decoder_windowing_D diff --git a/lib/rbcodec/codecs/libmusepack/synth_filter_coldfire.S b/lib/rbcodec/codecs/libmusepack/synth_filter_coldfire.S new file mode 100644 index 0000000000..758ab3d496 --- /dev/null +++ b/lib/rbcodec/codecs/libmusepack/synth_filter_coldfire.S @@ -0,0 +1,78 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2005 by Thom Johansen + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include "config.h" +/* + * static void + * mpc_decoder_windowing_D(MPC_SAMPLE_FORMAT * Data, + * const MPC_SAMPLE_FORMAT * V, + * const MPC_SAMPLE_FORMAT * D) + */ + +#if defined(USE_IRAM) + .section .icode +#else + .text +#endif + .align 2 + .global mpc_decoder_windowing_D + .type mpc_decoder_windowing_D, @function + +mpc_decoder_windowing_D: + lea.l (-9*4, %sp), %sp + movem.l %d2-%d7/%a2-%a4, (%sp) | save some registers + movem.l (9*4+4, %sp), %a0-%a2 | a0 = Data, a1 = V, a2 = D + moveq.l #32, %d0 | loop counter + + move.l (%a1), %a4 + 0: | loop + movem.l (%a2), %d1-%d7/%a3 + + mac.l %d1, %a4, ( 96*4, %a1), %a4, %acc0 + mac.l %d2, %a4, (128*4, %a1), %a4, %acc0 + mac.l %d3, %a4, (224*4, %a1), %a4, %acc0 + mac.l %d4, %a4, (256*4, %a1), %a4, %acc0 + mac.l %d5, %a4, (352*4, %a1), %a4, %acc0 + mac.l %d6, %a4, (384*4, %a1), %a4, %acc0 + mac.l %d7, %a4, (480*4, %a1), %a4, %acc0 + mac.l %a3, %a4, (512*4, %a1), %a4, %acc0 + movem.l (8*4, %a2), %d1-%d7/%a3 + mac.l %d1, %a4, (608*4, %a1), %a4, %acc0 + mac.l %d2, %a4, (640*4, %a1), %a4, %acc0 + mac.l %d3, %a4, (736*4, %a1), %a4, %acc0 + mac.l %d4, %a4, (768*4, %a1), %a4, %acc0 + mac.l %d5, %a4, (864*4, %a1), %a4, %acc0 + mac.l %d6, %a4, (896*4, %a1), %a4, %acc0 + mac.l %d7, %a4, (992*4, %a1), %a4, %acc0 + mac.l %a3, %a4, ( 4, %a1), %a4, %acc0 + + lea.l (16*4, %a2), %a2 + addq.l #4, %a1 + movclr.l %acc0, %d1 + lsl.l #1, %d1 + move.l %d1, (%a0)+ + subq.l #1, %d0 + bne 0b + + movem.l (%sp), %d2-%d7/%a2-%a4 | restore stacked regs + lea.l (9*4, %sp), %sp + rts + diff --git a/lib/rbcodec/codecs/libpcm/SOURCES b/lib/rbcodec/codecs/libpcm/SOURCES new file mode 100644 index 0000000000..356c9cdbb7 --- /dev/null +++ b/lib/rbcodec/codecs/libpcm/SOURCES @@ -0,0 +1,11 @@ +linear_pcm.c +itut_g711.c +dvi_adpcm.c +ieee_float.c +adpcm_seek.c +dialogic_oki_adpcm.c +ms_adpcm.c +yamaha_adpcm.c +ima_adpcm_common.c +qt_ima_adpcm.c +swf_adpcm.c diff --git a/lib/rbcodec/codecs/libpcm/adpcm_seek.c b/lib/rbcodec/codecs/libpcm/adpcm_seek.c new file mode 100644 index 0000000000..ce49d5fcd3 --- /dev/null +++ b/lib/rbcodec/codecs/libpcm/adpcm_seek.c @@ -0,0 +1,101 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2010 Yoshihisa Uchida + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ +#include "adpcm_seek.h" +#include "codeclib.h" + +/* + * The helper functions in order to seek for the adpcm codec + * which does not include the header each the data block. + */ + +#define MAX_STORE_COUNT 1000 + +static struct adpcm_data seek_table[MAX_STORE_COUNT]; +static int seek_count; +static int cur_count; +static int max_ratio; +static int cur_ratio; + +void init_seek_table(uint32_t max_count) +{ + int i = 0; + + for ( ; i < MAX_STORE_COUNT; i++) + { + seek_table[i].is_valid = false; + } + seek_count = max_count / MAX_STORE_COUNT + 1; + max_ratio = max_count / seek_count + 1; + cur_count = 0; + cur_ratio = -1; +} + +void add_adpcm_data(struct adpcm_data *data) +{ + if (--cur_count <= 0) + { + cur_count = seek_count; + if (++cur_ratio >= max_ratio) + cur_ratio = max_ratio - 1; + + if (!seek_table[cur_ratio].is_valid) + { + seek_table[cur_ratio].pcmdata[0] = data->pcmdata[0]; + seek_table[cur_ratio].pcmdata[1] = data->pcmdata[1]; + seek_table[cur_ratio].step[0] = data->step[0]; + seek_table[cur_ratio].step[1] = data->step[1]; + seek_table[cur_ratio].is_valid = true; + } + } +} + +uint32_t seek(uint32_t count, struct adpcm_data *seek_data, + uint8_t *(*read_buffer)(size_t *realsize), + int (*decode)(const uint8_t *inbuf, size_t inbufsize)) +{ + int new_ratio = count / seek_count; + + if (new_ratio >= max_ratio) + new_ratio = max_ratio - 1; + + if (!seek_table[new_ratio].is_valid) + { + uint8_t *buffer; + size_t n; + + do + { + buffer = read_buffer(&n); + if (n == 0) + break; + decode(buffer, n); + } while (cur_ratio < new_ratio); + } + + seek_data->pcmdata[0] = seek_table[new_ratio].pcmdata[0]; + seek_data->pcmdata[1] = seek_table[new_ratio].pcmdata[1]; + seek_data->step[0] = seek_table[new_ratio].step[0]; + seek_data->step[1] = seek_table[new_ratio].step[1]; + + cur_ratio = new_ratio; + cur_count = seek_count; + return cur_ratio * seek_count; +} diff --git a/lib/rbcodec/codecs/libpcm/adpcm_seek.h b/lib/rbcodec/codecs/libpcm/adpcm_seek.h new file mode 100644 index 0000000000..2dd3f000b1 --- /dev/null +++ b/lib/rbcodec/codecs/libpcm/adpcm_seek.h @@ -0,0 +1,39 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2010 Yoshihisa Uchida + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ +#ifndef CODEC_LIBPCM_ADPCM_SEEK_H +#define CODEC_LIBPCM_ADPCM_SEEK_H + +#include +#include +#include + +struct adpcm_data { + int16_t pcmdata[2]; + uint16_t step[2]; + bool is_valid; +}; + +void init_seek_table(uint32_t max_count); +void add_adpcm_data(struct adpcm_data *data); +uint32_t seek(uint32_t seek_time, struct adpcm_data *seek_data, + uint8_t *(*read_buffer)(size_t *realsize), + int (*decode)(const uint8_t *inbuf, size_t inbufsize)); +#endif diff --git a/lib/rbcodec/codecs/libpcm/dialogic_oki_adpcm.c b/lib/rbcodec/codecs/libpcm/dialogic_oki_adpcm.c new file mode 100644 index 0000000000..60090aaa89 --- /dev/null +++ b/lib/rbcodec/codecs/libpcm/dialogic_oki_adpcm.c @@ -0,0 +1,183 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2010 Yoshihisa Uchida + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ +#include "codeclib.h" +#include "adpcm_seek.h" +#include "support_formats.h" + +/* + * Dialogic OKI ADPCM + * + * References + * [1] Dialogic Corporation, Dialogic ADPCM Algorithm, 1988 + * [2] MultimediaWiki, Dialogic IMA ADPCM, URL:http://wiki.multimedia.cx/index.php?title=Dialogic_IMA_ADPCM + * [3] sox source code, src/adpcms.c + * [4] Tetsuya Isaki, NetBSD:/sys/dev/audio.c, http://www.tri-tree.gr.jp/~isaki/NetBSD/src/sys/dev/ic/msm6258.c.html + */ + +static const uint16_t step_table[] ICONST_ATTR = { + 16, 17, 19, 21, 23, 25, 28, 31, 34, 37, 41, 45, 50, 55, + 60, 66, 73, 80, 88, 97, 107, 118, 130, 143, 157, 173, 190, 209, + 230, 253, 279, 307, 337, 371, 408, 449, 494, 544, 598, 658, 724, 796, + 876, 963, 1060, 1166, 1282, 1411, 1552, +}; + +static const int index_table[] ICONST_ATTR = { + -1, -1, -1, -1, 2, 4, 6, 8 +}; + +static struct adpcm_data cur_data; +static int blocksperchunk; + +static struct pcm_format *fmt; + +static bool set_format(struct pcm_format *format) +{ + uint32_t max_chunk_count; + + fmt = format; + + if (fmt->bitspersample != 4) + { + DEBUGF("CODEC_ERROR: dialogic oki adpcm must be 4 bitspersample: %d\n", + fmt->bitspersample); + return false; + } + + if (fmt->channels != 1) + { + DEBUGF("CODEC_ERROR: dialogic oki adpcm must be monaural\n"); + return false; + } + + /* blockalign = 2 samples */ + fmt->blockalign = 1; + fmt->samplesperblock = 2; + + /* chunksize = about 1/32[sec] data */ + blocksperchunk = ci->id3->frequency >> 6; + fmt->chunksize = blocksperchunk * fmt->blockalign; + + max_chunk_count = (uint64_t)ci->id3->length * ci->id3->frequency + / (2000LL * fmt->chunksize); + + /* initialize seek table */ + init_seek_table(max_chunk_count); + /* add first data */ + add_adpcm_data(&cur_data); + + return true; +} + +static int16_t create_pcmdata(uint8_t nibble) +{ + int16_t delta; + int16_t index = cur_data.step[0]; + int16_t step = step_table[index]; + + delta = (step >> 3); + if (nibble & 4) delta += step; + if (nibble & 2) delta += (step >> 1); + if (nibble & 1) delta += (step >> 2); + + if (nibble & 0x08) + cur_data.pcmdata[0] -= delta; + else + cur_data.pcmdata[0] += delta; + + CLIP(cur_data.pcmdata[0], -2048, 2047); + + index += index_table[nibble & 0x07]; + CLIP(index, 0, 48); + cur_data.step[0] = index; + + return cur_data.pcmdata[0]; +} + +static int decode(const uint8_t *inbuf, size_t inbufsize, + int32_t *outbuf, int *outbufcount) +{ + size_t nsamples = 0; + + while (inbufsize) + { + *outbuf++ = create_pcmdata(*inbuf >> 4) << (PCM_OUTPUT_DEPTH - 12); + *outbuf++ = create_pcmdata(*inbuf ) << (PCM_OUTPUT_DEPTH - 12); + nsamples += 2; + + inbuf++; + inbufsize--; + } + + *outbufcount = nsamples; + add_adpcm_data(&cur_data); + + return CODEC_OK; +} + +static int decode_for_seek(const uint8_t *inbuf, size_t inbufsize) +{ + while (inbufsize) + { + create_pcmdata(*inbuf >> 4); + create_pcmdata(*inbuf ); + + inbuf++; + inbufsize--; + } + + add_adpcm_data(&cur_data); + + return CODEC_OK; +} + +static struct pcm_pos *get_seek_pos(uint32_t seek_val, int seek_mode, + uint8_t *(*read_buffer)(size_t *realsize)) +{ + static struct pcm_pos newpos; + uint32_t seek_count = (seek_mode == PCM_SEEK_TIME)? + ((uint64_t)seek_val * ci->id3->frequency / 1000LL) + / (blocksperchunk * fmt->samplesperblock) : + seek_val / (unsigned long)fmt->chunksize; + uint32_t new_count = seek(seek_count, &cur_data, read_buffer, &decode_for_seek); + + newpos.pos = new_count * fmt->chunksize; + newpos.samples = new_count * blocksperchunk * fmt->samplesperblock; + return &newpos; +} + +static const struct pcm_codec codec = { + set_format, + get_seek_pos, + decode, + }; + +const struct pcm_codec *get_dialogic_oki_adpcm_codec(void) +{ + /* + * initialize first pcm data, step index + * because the dialogic oki adpcm is always monaural, + * pcmdata[1], step[1] do not use. + */ + cur_data.pcmdata[0] = 0; + cur_data.step[0] = 0; + + return &codec; +} diff --git a/lib/rbcodec/codecs/libpcm/dvi_adpcm.c b/lib/rbcodec/codecs/libpcm/dvi_adpcm.c new file mode 100644 index 0000000000..2e702ca394 --- /dev/null +++ b/lib/rbcodec/codecs/libpcm/dvi_adpcm.c @@ -0,0 +1,308 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2005 Dave Chapman + * Copyright (C) 2009 Yoshihisa Uchida + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ +#include "codeclib.h" +#include "ima_adpcm_common.h" +#include "support_formats.h" + +/* + * Intel DVI ADPCM (IMA ADPCM) + * + * References + * [1] The IMA Digital Audio Focus and Technical Working Groups, + * Recommended Practices for Enhancing Digital Audio Compatibility + * in Multimedia Systems Revision 3.00, 1992 + * [2] Microsoft Corporation, New Multimedia Data Types and Data Techniques, + * Revision:3.0, 1994 + * [3] ffmpeg source code, libavcodec/adpcm.c + */ + +static struct pcm_format *fmt; + +static bool set_format(struct pcm_format *format) +{ + fmt = format; + + if (fmt->bitspersample < 2 || fmt->bitspersample > 5) + { + DEBUGF("CODEC_ERROR: dvi adpcm must be 2, 3, 4 or 5 bitspersample: %d\n", + fmt->bitspersample); + return false; + } + + fmt->chunksize = fmt->blockalign; + + init_ima_adpcm_decoder(fmt->bitspersample, NULL); + return true; +} + +static struct pcm_pos *get_seek_pos(uint32_t seek_val, int seek_mode, + uint8_t *(*read_buffer)(size_t *realsize)) +{ + static struct pcm_pos newpos; + uint32_t newblock = (seek_mode == PCM_SEEK_TIME) ? + ((uint64_t)seek_val * ci->id3->frequency / 1000LL) + / fmt->samplesperblock : + seek_val / fmt->blockalign; + + (void)read_buffer; + newpos.pos = newblock * fmt->blockalign; + newpos.samples = newblock * fmt->samplesperblock; + return &newpos; +} + +static inline void decode_2bit(const uint8_t **inbuf, size_t inbufsize, + int32_t **outbuf, int *outbufcount) +{ + int ch; + int i; + int32_t *pcmbuf; + int samples; + + samples = inbufsize / (4 * fmt->channels) - 1; + *outbufcount += (samples << 4); + while (samples-- > 0) + { + for (ch = 0; ch < fmt->channels; ch++) + { + pcmbuf = *outbuf + ch; + for (i = 0; i < 4; i++) + { + *pcmbuf = create_pcmdata(ch, **inbuf ) << IMA_ADPCM_INC_DEPTH; + pcmbuf += fmt->channels; + *pcmbuf = create_pcmdata(ch, **inbuf >> 2) << IMA_ADPCM_INC_DEPTH; + pcmbuf += fmt->channels; + *pcmbuf = create_pcmdata(ch, **inbuf >> 4) << IMA_ADPCM_INC_DEPTH; + pcmbuf += fmt->channels; + *pcmbuf = create_pcmdata(ch, **inbuf >> 6) << IMA_ADPCM_INC_DEPTH; + pcmbuf += fmt->channels; + (*inbuf)++; + } + } + *outbuf += 16 * fmt->channels; + } +} + +static inline void decode_3bit(const uint8_t **inbuf, size_t inbufsize, + int32_t **outbuf, int *outbufcount) +{ + const uint8_t *adpcmbuf; + uint32_t adpcms; + int ch; + int i; + int32_t *pcmbuf; + int samples; + + samples = (inbufsize - 4 * fmt->channels) / (12 * fmt->channels); + *outbufcount += (samples << 5); + while (samples--) + { + for (ch = 0; ch < fmt->channels; ch++) + { + adpcmbuf = *inbuf + ch * 4; + pcmbuf = *outbuf + ch; + adpcms = *adpcmbuf++; + adpcms |= (*adpcmbuf++) << 8; + adpcms |= (*adpcmbuf++) << 16; + for (i = 0; i < 8; i++) + { + *pcmbuf = create_pcmdata(ch, adpcms >> (3 * i)) << IMA_ADPCM_INC_DEPTH; + pcmbuf += fmt->channels; + } + adpcms = *adpcmbuf++; + adpcmbuf += (fmt->channels - 1) * 4; + adpcms |= (*adpcmbuf++) << 8; + adpcms |= (*adpcmbuf++) << 16; + for (i = 0; i < 8; i++) + { + *pcmbuf = create_pcmdata(ch, adpcms >> (3 * i)) << IMA_ADPCM_INC_DEPTH; + pcmbuf += fmt->channels; + } + adpcms = *adpcmbuf++; + adpcms |= (*adpcmbuf++) << 8; + adpcmbuf += (fmt->channels - 1) * 4; + adpcms |= (*adpcmbuf++) << 16; + for (i = 0; i < 8; i++) + { + *pcmbuf = create_pcmdata(ch, adpcms >> (3 * i)) << IMA_ADPCM_INC_DEPTH; + pcmbuf += fmt->channels; + } + adpcms = *adpcmbuf++; + adpcms |= (*adpcmbuf++) << 8; + adpcms |= (*adpcmbuf++) << 16; + for (i = 0; i < 8; i++) + { + *pcmbuf = create_pcmdata(ch, adpcms >> (3 * i)) << IMA_ADPCM_INC_DEPTH; + pcmbuf += fmt->channels; + } + } + *outbuf += 32 * fmt->channels; + *inbuf += 12 * fmt->channels; + } +} + +static inline void decode_4bit(const uint8_t **inbuf, size_t inbufsize, + int32_t **outbuf, int *outbufcount) +{ + int ch; + int i; + int32_t *pcmbuf; + int samples; + + samples = inbufsize / (4 * fmt->channels) - 1; + *outbufcount += (samples << 3); + while (samples-- > 0) + { + for (ch = 0; ch < fmt->channels; ch++) + { + pcmbuf = *outbuf + ch; + for (i = 0; i < 4; i++) + { + *pcmbuf = create_pcmdata_size4(ch, **inbuf ) << IMA_ADPCM_INC_DEPTH; + pcmbuf += fmt->channels; + *pcmbuf = create_pcmdata_size4(ch, **inbuf >> 4) << IMA_ADPCM_INC_DEPTH; + pcmbuf += fmt->channels; + (*inbuf)++; + } + } + *outbuf += 8 * fmt->channels; + } +} + +static inline void decode_5bit(const uint8_t **inbuf, size_t inbufsize, + int32_t **outbuf, int *outbufcount) +{ + const uint8_t *adpcmbuf; + uint64_t adpcms; + int ch; + int i; + int32_t *pcmbuf; + int samples; + + samples = (inbufsize - 4 * fmt->channels) / (20 * fmt->channels); + *outbufcount += (samples << 5); + while (samples--) + { + for (ch = 0; ch < fmt->channels; ch++) + { + adpcmbuf = *inbuf + ch * 4; + pcmbuf = *outbuf + ch; + adpcms = *adpcmbuf++; + adpcms |= (*adpcmbuf++) << 8; + adpcms |= (*adpcmbuf++) << 16; + adpcms |= (uint64_t)(*adpcmbuf++) << 24; + adpcmbuf += (fmt->channels - 1) * 4; + adpcms |= (uint64_t)(*adpcmbuf++) << 32; + for (i = 0; i < 8; i++) + { + *pcmbuf = create_pcmdata(ch, adpcms >> (5 * i)) << IMA_ADPCM_INC_DEPTH; + pcmbuf += fmt->channels; + } + adpcms = *adpcmbuf++; + adpcms |= (*adpcmbuf++) << 8; + adpcms |= (*adpcmbuf++) << 16; + adpcmbuf += (fmt->channels - 1) * 4; + adpcms |= (uint64_t)(*adpcmbuf++) << 24; + adpcms |= (uint64_t)(*adpcmbuf++) << 32; + for (i = 0; i < 8; i++) + { + *pcmbuf = create_pcmdata(ch, adpcms >> (5 * i)) << IMA_ADPCM_INC_DEPTH; + pcmbuf += fmt->channels; + } + adpcms = *adpcmbuf++; + adpcms |= (*adpcmbuf++) << 8; + adpcmbuf += (fmt->channels - 1) * 4; + adpcms |= (*adpcmbuf++) << 16; + adpcms |= (uint64_t)(*adpcmbuf++) << 24; + adpcms |= (uint64_t)(*adpcmbuf++) << 32; + for (i = 0; i < 8; i++) + { + *pcmbuf = create_pcmdata(ch, adpcms >> (5 * i)) << IMA_ADPCM_INC_DEPTH; + pcmbuf += fmt->channels; + } + adpcms = *adpcmbuf++; + adpcmbuf += (fmt->channels - 1) * 4; + adpcms |= (*adpcmbuf++) << 8; + adpcms |= (*adpcmbuf++) << 16; + adpcms |= (uint64_t)(*adpcmbuf++) << 24; + adpcms |= (uint64_t)(*adpcmbuf++) << 32; + for (i = 0; i < 8; i++) + { + *pcmbuf = create_pcmdata(ch, adpcms >> (5 * i)) << IMA_ADPCM_INC_DEPTH; + pcmbuf += fmt->channels; + } + } + *outbuf += 32 * fmt->channels; + *inbuf += 20 * fmt->channels; + } +} + +static int decode(const uint8_t *inbuf, size_t inbufsize, + int32_t *outbuf, int *outbufcount) +{ + int ch; + int32_t init_pcmdata[2]; + int8_t init_index[2]; + + *outbufcount = 0; + for (ch = 0; ch < fmt->channels; ch++) + { + init_pcmdata[ch] = inbuf[0] | (inbuf[1] << 8); + if (init_pcmdata[ch] > 32767) + init_pcmdata[ch] -= 65536; + + init_index[ch] = inbuf[2]; + if (init_index[ch] > 88 || init_index[ch] < 0) + { + DEBUGF("CODEC_ERROR: dvi adpcm illegal step index=%d > 88\n", + init_index[ch]); + return CODEC_ERROR; + } + inbuf += 4; + + *outbuf++ = init_pcmdata[ch] << IMA_ADPCM_INC_DEPTH; + } + + *outbufcount += 1; + set_decode_parameters(fmt->channels, init_pcmdata, init_index); + + if (fmt->bitspersample == 4) + decode_4bit(&inbuf, inbufsize, &outbuf, outbufcount); + else if (fmt->bitspersample == 3) + decode_3bit(&inbuf, inbufsize, &outbuf, outbufcount); + else if (fmt->bitspersample == 5) + decode_5bit(&inbuf, inbufsize, &outbuf, outbufcount); + else /* fmt->bitspersample == 2 */ + decode_2bit(&inbuf, inbufsize, &outbuf, outbufcount); + + return CODEC_OK; +} + +static const struct pcm_codec codec = { + set_format, + get_seek_pos, + decode, + }; + +const struct pcm_codec *get_dvi_adpcm_codec(void) +{ + return &codec; +} diff --git a/lib/rbcodec/codecs/libpcm/ieee_float.c b/lib/rbcodec/codecs/libpcm/ieee_float.c new file mode 100644 index 0000000000..639390bcd5 --- /dev/null +++ b/lib/rbcodec/codecs/libpcm/ieee_float.c @@ -0,0 +1,165 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2009 Yoshihisa Uchida + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ +#include "codeclib.h" +#include "pcm_common.h" +#include "support_formats.h" + +/* + * IEEE float + */ + +static struct pcm_format *fmt; + +static bool set_format(struct pcm_format *format) +{ + fmt = format; + + if (fmt->channels == 0) + { + DEBUGF("CODEC_ERROR: channels is 0\n"); + return false; + } + + if (fmt->bitspersample != 32 && fmt->bitspersample != 64) + { + DEBUGF("CODEC_ERROR: ieee float must be 32 or 64 bitspersample: %d\n", + fmt->bitspersample); + return false; + } + + fmt->bytespersample = fmt->bitspersample >> 3; + + if (fmt->blockalign == 0) + fmt->blockalign = fmt->bytespersample * fmt->channels; + + fmt->samplesperblock = fmt->blockalign / (fmt->bytespersample * fmt->channels); + + /* chunksize = about 1/50[sec] data */ + fmt->chunksize = (ci->id3->frequency / (50 * fmt->samplesperblock)) + * fmt->blockalign; + + return true; +} + +static struct pcm_pos *get_seek_pos(uint32_t seek_val, int seek_mode, + uint8_t *(*read_buffer)(size_t *realsize)) +{ + static struct pcm_pos newpos; + uint32_t newblock = (seek_mode == PCM_SEEK_TIME) ? + ((uint64_t)seek_val * ci->id3->frequency / 1000LL) + / fmt->samplesperblock : + seek_val / fmt->blockalign; + + (void)read_buffer; + newpos.pos = newblock * fmt->blockalign; + newpos.samples = newblock * fmt->samplesperblock; + return &newpos; +} + +static int decode(const uint8_t *inbuf, size_t inbufsize, + int32_t *outbuf, int *outbufsize) +{ + uint32_t i; + int32_t pcm; + int16_t exp; + int sgn; + + if (fmt->bitspersample == 32) + { + for (i = 0; i < inbufsize; i += 4) + { + if (fmt->is_little_endian) + { + pcm = (inbuf[0]<<5)|(inbuf[1]<<13)|((inbuf[2]|0x80)<<21); + exp = ((inbuf[2]>>7)|((inbuf[3]&0x7f)<<1)) - 127; + sgn = inbuf[3] & 0x80; + } + else + { + pcm = (inbuf[3]<<5)|(inbuf[2]<<13)|((inbuf[1]|0x80)<<21); + exp = ((inbuf[1]>>7)|((inbuf[0]&0x7f)<<1)) - 127; + sgn = inbuf[0] & 0x80; + } + if (exp > -29 && exp < 0) + { + pcm >>= -exp; + if (sgn) + pcm = -pcm; + } + else if (exp < -28) + pcm = 0; + else + pcm = (sgn)?-(1<<28):(1<<28)-1; + + outbuf[i/4] = pcm; + inbuf += 4; + } + *outbufsize = inbufsize >> 2; + } + else + { + for (i = 0; i < inbufsize; i += 8) + { + if (fmt->is_little_endian) + { + pcm = inbuf[3]|(inbuf[4]<<8)|(inbuf[5]<<16)|(((inbuf[6]&0x0f)|0x10)<<24); + exp = (((inbuf[6]&0xf0)>>4)|((inbuf[7]&0x7f)<<4)) - 1023; + sgn = inbuf[7] & 0x80; + } + else + { + pcm = inbuf[4]|(inbuf[3]<<8)|(inbuf[2]<<16)|(((inbuf[1]&0x0f)|0x10)<<24); + exp = (((inbuf[1]&0xf0)>>4)|((inbuf[0]&0x7f)<<4)) - 1023; + sgn = inbuf[0] & 0x80; + } + if (exp > -29 && exp < 0) + { + pcm >>= -exp; + if (sgn) + pcm = -pcm; + } + else if (exp < -28) + pcm = 0; + else + pcm = (sgn)?-(1<<28):(1<<28)-1; + + outbuf[i/8] = pcm; + inbuf += 8; + } + *outbufsize = inbufsize >> 3; + } + + if (fmt->channels == 2) + *outbufsize >>= 1; + + return CODEC_OK; +} + +static const struct pcm_codec codec = { + set_format, + get_seek_pos, + decode, + }; + +const struct pcm_codec *get_ieee_float_codec(void) +{ + return &codec; +} diff --git a/lib/rbcodec/codecs/libpcm/ima_adpcm_common.c b/lib/rbcodec/codecs/libpcm/ima_adpcm_common.c new file mode 100644 index 0000000000..724cce31b0 --- /dev/null +++ b/lib/rbcodec/codecs/libpcm/ima_adpcm_common.c @@ -0,0 +1,171 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2010 Yoshihisa Uchida + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ +#include "codeclib.h" +#include "pcm_common.h" +#include "ima_adpcm_common.h" + +/* + * Functions for IMA ADPCM and IMA ADPCM series format + * + * References + * [1] The IMA Digital Audio Focus and Technical Working Groups, + * Recommended Practices for Enhancing Digital Audio Compatibility + * in Multimedia Systems Revision 3.00, 1992 + * [2] Microsoft Corporation, New Multimedia Data Types and Data Techniques, + * Revision:3.0, 1994 + * [3] ffmpeg source code, libavcodec/adpcm.c + */ + +/* step table */ +static const uint16_t step_table[89] ICONST_ATTR = { + 7, 8, 9, 10, 11, 12, 13, 14, + 16, 17, 19, 21, 23, 25, 28, 31, + 34, 37, 41, 45, 50, 55, 60, 66, + 73, 80, 88, 97, 107, 118, 130, 143, + 157, 173, 190, 209, 230, 253, 279, 307, + 337, 371, 408, 449, 494, 544, 598, 658, + 724, 796, 876, 963, 1060, 1166, 1282, 1411, + 1552, 1707, 1878, 2066, 2272, 2499, 2749, 3024, + 3327, 3660, 4026, 4428, 4871, 5358, 5894, 6484, + 7132, 7845, 8630, 9493, 10442, 11487, 12635, 13899, + 15289, 16818, 18500, 20350, 22385, 24623, 27086, 29794, + 32767 +}; + +/* step index tables */ +static const int index_tables[4][16] ICONST_ATTR = { + /* adpcm data size is 2 */ + { -1, 2 }, + /* adpcm data size is 3 */ + { -1, -1, 1, 2 }, + /* adpcm data size is 4 */ + { -1, -1, -1, -1, 2, 4, 6, 8 }, + /* adpcm data size is 5 */ + { -1, -1, -1, -1, -1, -1, -1, -1, 1, 2, 4, 6, 8, 10, 13, 16 }, +}; + +static int32_t pcmdata[2]; +static int8_t indices[2]; + +static int adpcm_data_size; +static uint8_t step_mask; +static uint8_t step_sign_mask; +static int8_t step_shift; +static const int *use_index_table; + +/* + * Before first decoding, this function must be executed. + * + * params + * bit: adpcm data size (2 <= bit <= 5). + * index_table: step index table + * if index_table is null, then step index table + * is used index_tables[bit-2]. + */ +void init_ima_adpcm_decoder(int bit, const int *index_table) +{ + adpcm_data_size = bit; + step_sign_mask = 1 << (adpcm_data_size - 1); + step_mask = step_sign_mask - 1; + step_shift = adpcm_data_size - 2; + if (index_table) + use_index_table = index_table; + else + use_index_table = index_tables[adpcm_data_size - 2]; +} + +/* + * When starting decoding for each block, this function must be executed. + * + * params + * channels: channel count + * init_pcmdata: array of init pcmdata + * init_index: array of init step indexes + */ +void set_decode_parameters(int channels, int32_t *init_pcmdata, int8_t *init_index) +{ + int ch; + + for (ch = 0; ch < channels; ch++) + { + pcmdata[ch] = init_pcmdata[ch]; + indices[ch] = init_index[ch]; + } +} + +/* + * convert ADPCM to PCM for any adpcm data size. + * + * If adpcm_data_size is 4, then you use create_pcmdata_size4() + * in place of this functon. + */ +int16_t create_pcmdata(int ch, uint8_t nibble) +{ + int check_bit = 1 << step_shift; + int32_t delta = 0; + int16_t step = step_table[indices[ch]]; + + do { + if (nibble & check_bit) + delta += step; + step >>= 1; + check_bit >>= 1; + } while (check_bit); + delta += step; + + if (nibble & step_sign_mask) + pcmdata[ch] -= delta; + else + pcmdata[ch] += delta; + + indices[ch] += use_index_table[nibble & step_mask]; + CLIP(indices[ch], 0, 88); + + CLIP(pcmdata[ch], -32768, 32767); + + return (int16_t)pcmdata[ch]; +} + +/* + * convert ADPCM to PCM when adpcm data size is 4. + */ +int16_t create_pcmdata_size4(int ch, uint8_t nibble) +{ + int32_t delta; + int16_t step = step_table[indices[ch]]; + + delta = (step >> 3); + if (nibble & 4) delta += step; + if (nibble & 2) delta += (step >> 1); + if (nibble & 1) delta += (step >> 2); + + if (nibble & 0x08) + pcmdata[ch] -= delta; + else + pcmdata[ch] += delta; + + indices[ch] += use_index_table[nibble & 0x07]; + CLIP(indices[ch], 0, 88); + + CLIP(pcmdata[ch], -32768, 32767); + + return (int16_t)pcmdata[ch]; +} diff --git a/lib/rbcodec/codecs/libpcm/ima_adpcm_common.h b/lib/rbcodec/codecs/libpcm/ima_adpcm_common.h new file mode 100644 index 0000000000..46fd6083ec --- /dev/null +++ b/lib/rbcodec/codecs/libpcm/ima_adpcm_common.h @@ -0,0 +1,33 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2010 Yoshihisa Uchida + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ +#ifndef CODEC_LIBPCM_IMA_ADPCM_COMMON_H +#define CODEC_LIBPCM_IMA_ADPCM_COMMON_H + +#include +#include + +#define IMA_ADPCM_INC_DEPTH (PCM_OUTPUT_DEPTH - 16) + +void init_ima_adpcm_decoder(int bit, const int *index_table); +void set_decode_parameters(int channels, int32_t *init_pcmdata, int8_t *init_index); +int16_t create_pcmdata(int ch, uint8_t nibble); +int16_t create_pcmdata_size4(int ch, uint8_t nibble); +#endif diff --git a/lib/rbcodec/codecs/libpcm/itut_g711.c b/lib/rbcodec/codecs/libpcm/itut_g711.c new file mode 100644 index 0000000000..88ff5f59e6 --- /dev/null +++ b/lib/rbcodec/codecs/libpcm/itut_g711.c @@ -0,0 +1,204 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2005 Dave Chapman + * Copyright (C) 2009 Yoshihisa Uchida + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ +#include "codeclib.h" +#include "support_formats.h" + +/* + * ITU-T G.711 A-law mu-law + */ + +static const int16_t alaw2linear16[256] ICONST_ATTR = { + -5504, -5248, -6016, -5760, -4480, -4224, -4992, + -4736, -7552, -7296, -8064, -7808, -6528, -6272, + -7040, -6784, -2752, -2624, -3008, -2880, -2240, + -2112, -2496, -2368, -3776, -3648, -4032, -3904, + -3264, -3136, -3520, -3392, -22016, -20992, -24064, + -23040, -17920, -16896, -19968, -18944, -30208, -29184, + -32256, -31232, -26112, -25088, -28160, -27136, -11008, + -10496, -12032, -11520, -8960, -8448, -9984, -9472, + -15104, -14592, -16128, -15616, -13056, -12544, -14080, + -13568, -344, -328, -376, -360, -280, -264, + -312, -296, -472, -456, -504, -488, -408, + -392, -440, -424, -88, -72, -120, -104, + -24, -8, -56, -40, -216, -200, -248, + -232, -152, -136, -184, -168, -1376, -1312, + -1504, -1440, -1120, -1056, -1248, -1184, -1888, + -1824, -2016, -1952, -1632, -1568, -1760, -1696, + -688, -656, -752, -720, -560, -528, -624, + -592, -944, -912, -1008, -976, -816, -784, + -880, -848, 5504, 5248, 6016, 5760, 4480, + 4224, 4992, 4736, 7552, 7296, 8064, 7808, + 6528, 6272, 7040, 6784, 2752, 2624, 3008, + 2880, 2240, 2112, 2496, 2368, 3776, 3648, + 4032, 3904, 3264, 3136, 3520, 3392, 22016, + 20992, 24064, 23040, 17920, 16896, 19968, 18944, + 30208, 29184, 32256, 31232, 26112, 25088, 28160, + 27136, 11008, 10496, 12032, 11520, 8960, 8448, + 9984, 9472, 15104, 14592, 16128, 15616, 13056, + 12544, 14080, 13568, 344, 328, 376, 360, + 280, 264, 312, 296, 472, 456, 504, + 488, 408, 392, 440, 424, 88, 72, + 120, 104, 24, 8, 56, 40, 216, + 200, 248, 232, 152, 136, 184, 168, + 1376, 1312, 1504, 1440, 1120, 1056, 1248, + 1184, 1888, 1824, 2016, 1952, 1632, 1568, + 1760, 1696, 688, 656, 752, 720, 560, + 528, 624, 592, 944, 912, 1008, 976, + 816, 784, 880, 848 +}; + +static const int16_t ulaw2linear16[256] ICONST_ATTR = { + -32124, -31100, -30076, -29052, -28028, -27004, -25980, + -24956, -23932, -22908, -21884, -20860, -19836, -18812, + -17788, -16764, -15996, -15484, -14972, -14460, -13948, + -13436, -12924, -12412, -11900, -11388, -10876, -10364, + -9852, -9340, -8828, -8316, -7932, -7676, -7420, + -7164, -6908, -6652, -6396, -6140, -5884, -5628, + -5372, -5116, -4860, -4604, -4348, -4092, -3900, + -3772, -3644, -3516, -3388, -3260, -3132, -3004, + -2876, -2748, -2620, -2492, -2364, -2236, -2108, + -1980, -1884, -1820, -1756, -1692, -1628, -1564, + -1500, -1436, -1372, -1308, -1244, -1180, -1116, + -1052, -988, -924, -876, -844, -812, -780, + -748, -716, -684, -652, -620, -588, -556, + -524, -492, -460, -428, -396, -372, -356, + -340, -324, -308, -292, -276, -260, -244, + -228, -212, -196, -180, -164, -148, -132, + -120, -112, -104, -96, -88, -80, -72, + -64, -56, -48, -40, -32, -24, -16, + -8, 0, 32124, 31100, 30076, 29052, 28028, + 27004, 25980, 24956, 23932, 22908, 21884, 20860, + 19836, 18812, 17788, 16764, 15996, 15484, 14972, + 14460, 13948, 13436, 12924, 12412, 11900, 11388, + 10876, 10364, 9852, 9340, 8828, 8316, 7932, + 7676, 7420, 7164, 6908, 6652, 6396, 6140, + 5884, 5628, 5372, 5116, 4860, 4604, 4348, + 4092, 3900, 3772, 3644, 3516, 3388, 3260, + 3132, 3004, 2876, 2748, 2620, 2492, 2364, + 2236, 2108, 1980, 1884, 1820, 1756, 1692, + 1628, 1564, 1500, 1436, 1372, 1308, 1244, + 1180, 1116, 1052, 988, 924, 876, 844, + 812, 780, 748, 716, 684, 652, 620, + 588, 556, 524, 492, 460, 428, 396, + 372, 356, 340, 324, 308, 292, 276, + 260, 244, 228, 212, 196, 180, 164, + 148, 132, 120, 112, 104, 96, 88, + 80, 72, 64, 56, 48, 40, 32, + 24, 16, 8, 0 +}; + +static struct pcm_format *fmt; + +static bool set_format(struct pcm_format *format) +{ + fmt = format; + + if (fmt->channels == 0) + { + DEBUGF("CODEC_ERROR: channels is 0\n"); + return false; + } + + if (fmt->bitspersample != 8) + { + DEBUGF("CODEC_ERROR: alaw and mulaw must have 8 bitspersample: %d\n", + fmt->bitspersample); + return false; + } + + fmt->bytespersample = 1; + + if (fmt->blockalign == 0) + fmt->blockalign = fmt->channels; + + fmt->samplesperblock = fmt->blockalign / fmt->channels; + + /* chunksize = about 1/50[sec] data */ + fmt->chunksize = (ci->id3->frequency / (50 * fmt->samplesperblock)) + * fmt->blockalign; + + return true; +} + +static struct pcm_pos *get_seek_pos(uint32_t seek_val, int seek_mode, + uint8_t *(*read_buffer)(size_t *realsize)) +{ + static struct pcm_pos newpos; + uint32_t newblock = (seek_mode == PCM_SEEK_TIME) ? + ((uint64_t)seek_val * ci->id3->frequency / 1000LL) + / fmt->samplesperblock : + seek_val / fmt->blockalign; + + (void)read_buffer; + newpos.pos = newblock * fmt->blockalign; + newpos.samples = newblock * fmt->samplesperblock; + return &newpos; +} + +static int decode_alaw(const uint8_t *inbuf, size_t inbufsize, + int32_t *outbuf, int *outbufsize) +{ + uint32_t i; + + for (i = 0; i < inbufsize; i++) + outbuf[i] = alaw2linear16[inbuf[i]] << (PCM_OUTPUT_DEPTH - 16); + + *outbufsize = (fmt->channels == 2) ? (inbufsize >> 1) : inbufsize; + + return CODEC_OK; +} + +static int decode_mulaw(const uint8_t *inbuf, size_t inbufsize, + int32_t *outbuf, int *outbufsize) +{ + uint32_t i; + + for (i = 0; i < inbufsize; i++) + outbuf[i] = ulaw2linear16[inbuf[i]] << (PCM_OUTPUT_DEPTH - 16); + + *outbufsize = (fmt->channels == 2) ? (inbufsize >> 1) : inbufsize; + + return CODEC_OK; +} + +static const struct pcm_codec alaw_codec = { + set_format, + get_seek_pos, + decode_alaw, + }; + +static const struct pcm_codec mulaw_codec = { + set_format, + get_seek_pos, + decode_mulaw, + }; + +const struct pcm_codec *get_itut_g711_alaw_codec(void) +{ + return &alaw_codec; +} + +const struct pcm_codec *get_itut_g711_mulaw_codec(void) +{ + return &mulaw_codec; +} + diff --git a/lib/rbcodec/codecs/libpcm/libpcm.make b/lib/rbcodec/codecs/libpcm/libpcm.make new file mode 100644 index 0000000000..15c23bedf2 --- /dev/null +++ b/lib/rbcodec/codecs/libpcm/libpcm.make @@ -0,0 +1,18 @@ +# __________ __ ___. +# Open \______ \ ____ ____ | | _\_ |__ _______ ___ +# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / +# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < +# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ +# \/ \/ \/ \/ \/ +# $Id$ +# + +# libpcm +PCMSLIB := $(CODECDIR)/libpcm.a +PCMSLIB_SRC := $(call preprocess, $(RBCODECLIB_DIR)/codecs/libpcm/SOURCES) +PCMSLIB_OBJ := $(call c2obj, $(PCMSLIB_SRC)) +OTHER_SRC += $(PCMSLIB_SRC) + +$(PCMSLIB): $(PCMSLIB_OBJ) + $(SILENT)$(shell rm -f $@) + $(call PRINTS,AR $(@F))$(AR) rcs $@ $^ >/dev/null diff --git a/lib/rbcodec/codecs/libpcm/linear_pcm.c b/lib/rbcodec/codecs/libpcm/linear_pcm.c new file mode 100644 index 0000000000..5c3c140b8c --- /dev/null +++ b/lib/rbcodec/codecs/libpcm/linear_pcm.c @@ -0,0 +1,294 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2005 Dave Chapman + * Copyright (C) 2009 Yoshihisa Uchida + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ +#include "codeclib.h" +#include "support_formats.h" + +/* + * Linear PCM + */ + +#define INC_DEPTH_8 (PCM_OUTPUT_DEPTH - 8) +#define INC_DEPTH_16 (PCM_OUTPUT_DEPTH - 16) +#define INC_DEPTH_24 (PCM_OUTPUT_DEPTH - 24) +#define DEC_DEPTH_32 (32 - PCM_OUTPUT_DEPTH) + + +static struct pcm_format *fmt; + +static bool set_format(struct pcm_format *format) +{ + fmt = format; + + if (fmt->channels == 0) + { + DEBUGF("CODEC_ERROR: channels is 0\n"); + return false; + } + + if (fmt->bitspersample == 0) + { + DEBUGF("CODEC_ERROR: bitspersample is 0\n"); + return false; + } + + if (fmt->bitspersample > 32) + { + DEBUGF("CODEC_ERROR: pcm with more than 32 bitspersample " + "is unsupported\n"); + return false; + } + + fmt->bytespersample = fmt->bitspersample >> 3; + + if (fmt->blockalign == 0) + fmt->blockalign = fmt->bytespersample * fmt->channels; + + fmt->samplesperblock = fmt->blockalign / (fmt->bytespersample * fmt->channels); + + /* chunksize = about 1/50[sec] data */ + fmt->chunksize = (ci->id3->frequency / (50 * fmt->samplesperblock)) + * fmt->blockalign; + + return true; +} + +static struct pcm_pos *get_seek_pos(uint32_t seek_val, int seek_mode, + uint8_t *(*read_buffer)(size_t *realsize)) +{ + static struct pcm_pos newpos; + uint32_t newblock = (seek_mode == PCM_SEEK_TIME) ? + ((uint64_t)seek_val * ci->id3->frequency / 1000LL) + / fmt->samplesperblock : + seek_val / fmt->blockalign; + + (void)read_buffer; + newpos.pos = newblock * fmt->blockalign; + newpos.samples = newblock * fmt->samplesperblock; + return &newpos; +} + +/* 8bit decode functions */ +static inline void decode_s8(const uint8_t *inbuf, size_t inbufsize, int32_t *outbuf) +{ + size_t i = 0; + + for ( ; i < inbufsize; i++) + outbuf[i] = SE(inbuf[i]) << INC_DEPTH_8; +} + +static inline void decode_u8(const uint8_t *inbuf, size_t inbufsize, int32_t *outbuf) +{ + size_t i = 0; + + for ( ; i < inbufsize; i++) + outbuf[i] = SFT(inbuf[i]) << INC_DEPTH_8; +} + +/* 16bit decode functions */ +static inline void decode_s16le(const uint8_t *inbuf, size_t inbufsize, int32_t *outbuf) +{ + size_t i = 0; + + for ( ; i < inbufsize; i += 2) + outbuf[i/2] = (inbuf[i] << INC_DEPTH_16)|(SE(inbuf[i+1]) << INC_DEPTH_8); +} + +static inline void decode_u16le(const uint8_t *inbuf, size_t inbufsize, int32_t *outbuf) +{ + size_t i = 0; + + for ( ; i < inbufsize; i += 2) + outbuf[i/2] = (inbuf[i] << INC_DEPTH_16)|(SFT(inbuf[i+1]) << INC_DEPTH_8); +} + +static inline void decode_s16be(const uint8_t *inbuf, size_t inbufsize, int32_t *outbuf) +{ + size_t i = 0; + + for ( ; i < inbufsize; i += 2) + outbuf[i/2] = (inbuf[i+1] << INC_DEPTH_16)|(SE(inbuf[i]) << INC_DEPTH_8); +} + +static inline void decode_u16be(const uint8_t *inbuf, size_t inbufsize, int32_t *outbuf) +{ + size_t i = 0; + + for ( ; i < inbufsize; i += 2) + outbuf[i/2] = (inbuf[i+1] << INC_DEPTH_16)|(SFT(inbuf[i]) << INC_DEPTH_8); +} + +/* 24bit decode functions */ +static inline void decode_s24le(const uint8_t *inbuf, size_t inbufsize, int32_t *outbuf) +{ + size_t i = 0; + + for ( ; i < inbufsize; i += 3) + outbuf[i/3] = (inbuf[i] << INC_DEPTH_24)|(inbuf[i+1] << INC_DEPTH_16)| + (SE(inbuf[i+2]) << INC_DEPTH_8); +} + +static inline void decode_u24le(const uint8_t *inbuf, size_t inbufsize, int32_t *outbuf) +{ + size_t i = 0; + + for ( ; i < inbufsize; i += 3) + outbuf[i/3] = (inbuf[i] << INC_DEPTH_24)|(inbuf[i+1] << INC_DEPTH_16)| + (SFT(inbuf[i+2]) << INC_DEPTH_8); +} + +static inline void decode_s24be(const uint8_t *inbuf, size_t inbufsize, int32_t *outbuf) +{ + size_t i = 0; + + for ( ; i < inbufsize; i += 3) + outbuf[i/3] = (inbuf[i+2] << INC_DEPTH_24)|(inbuf[i+1] << INC_DEPTH_16)| + (SE(inbuf[i]) << INC_DEPTH_8); +} + +static inline void decode_u24be(const uint8_t *inbuf, size_t inbufsize, int32_t *outbuf) +{ + size_t i = 0; + + for ( ; i < inbufsize; i += 3) + outbuf[i/3] = (inbuf[i+2] << INC_DEPTH_24)|(inbuf[i+1] << INC_DEPTH_16)| + (SFT(inbuf[i]) << INC_DEPTH_8); +} + +/* 32bit decode functions */ +static inline void decode_s32le(const uint8_t *inbuf, size_t inbufsize, int32_t *outbuf) +{ + size_t i = 0; + + for ( ; i < inbufsize; i += 4) + outbuf[i/4] = (inbuf[i] >> DEC_DEPTH_32)|(inbuf[i+1] << INC_DEPTH_24)| + (inbuf[i+2] << INC_DEPTH_16)|(SE(inbuf[i+3]) << INC_DEPTH_8); +} + +static inline void decode_u32le(const uint8_t *inbuf, size_t inbufsize, int32_t *outbuf) +{ + size_t i = 0; + + for ( ; i < inbufsize; i += 4) + outbuf[i/4] = (inbuf[i] >> DEC_DEPTH_32)|(inbuf[i+1] << INC_DEPTH_24)| + (inbuf[i+2] << INC_DEPTH_16)|(SFT(inbuf[i+3]) << INC_DEPTH_8); +} + +static inline void decode_s32be(const uint8_t *inbuf, size_t inbufsize, int32_t *outbuf) +{ + size_t i = 0; + + for ( ; i < inbufsize; i += 4) + outbuf[i/4] = (inbuf[i+3] >> DEC_DEPTH_32)|(inbuf[i+2] << INC_DEPTH_24)| + (inbuf[i+1] << INC_DEPTH_16)|(SE(inbuf[i]) << INC_DEPTH_8); +} + +static inline void decode_u32be(const uint8_t *inbuf, size_t inbufsize, int32_t *outbuf) +{ + size_t i = 0; + + for ( ; i < inbufsize; i += 4) + outbuf[i/4] = (inbuf[i+3] >> DEC_DEPTH_32)|(inbuf[i+2] << INC_DEPTH_24)| + (inbuf[i+1] << INC_DEPTH_16)|(SFT(inbuf[i]) << INC_DEPTH_8); +} + +static int decode(const uint8_t *inbuf, size_t inbufsize, int32_t *outbuf, int *outbufcount) +{ + if (fmt->bitspersample > 24) + { + if (fmt->is_little_endian) + { + if (fmt->is_signed) + decode_s32le(inbuf, inbufsize, outbuf); + else + decode_u32le(inbuf, inbufsize, outbuf); + } + else + { + if (fmt->is_signed) + decode_s32be(inbuf, inbufsize, outbuf); + else + decode_u32be(inbuf, inbufsize, outbuf); + } + *outbufcount = inbufsize >> 2; + } + else if (fmt->bitspersample > 16) + { + if (fmt->is_little_endian) + { + if (fmt->is_signed) + decode_s24le(inbuf, inbufsize, outbuf); + else + decode_u24le(inbuf, inbufsize, outbuf); + } + else + { + if (fmt->is_signed) + decode_s24be(inbuf, inbufsize, outbuf); + else + decode_u24be(inbuf, inbufsize, outbuf); + } + *outbufcount = inbufsize / 3; + } + else if (fmt->bitspersample > 8) + { + if (fmt->is_little_endian) + { + if (fmt->is_signed) + decode_s16le(inbuf, inbufsize, outbuf); + else + decode_u16le(inbuf, inbufsize, outbuf); + } + else + { + if (fmt->is_signed) + decode_s16be(inbuf, inbufsize, outbuf); + else + decode_u16be(inbuf, inbufsize, outbuf); + } + *outbufcount = inbufsize >> 1; + } + else + { + if (fmt->is_signed) + decode_s8(inbuf, inbufsize, outbuf); + else + decode_u8(inbuf, inbufsize, outbuf); + + *outbufcount = inbufsize; + } + + if (fmt->channels == 2) + *outbufcount >>= 1; + + return CODEC_OK; +} + +static const struct pcm_codec codec = { + set_format, + get_seek_pos, + decode, + }; + +const struct pcm_codec *get_linear_pcm_codec(void) +{ + return &codec; +} diff --git a/lib/rbcodec/codecs/libpcm/ms_adpcm.c b/lib/rbcodec/codecs/libpcm/ms_adpcm.c new file mode 100644 index 0000000000..a385d6c99f --- /dev/null +++ b/lib/rbcodec/codecs/libpcm/ms_adpcm.c @@ -0,0 +1,168 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2010 Yoshihisa Uchida + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ +#include "codeclib.h" +#include "support_formats.h" + +/* + * Microsoft ADPCM + * + * References + * [1] Microsoft, New Multimedia Data Types and Data Techniques Revision 3.0, 1994 + * [2] MulitimediaWiki, Microsoft ADPCM, 2006 + * (http://wiki.multimedia.cx/index.php?title=Microsoft_ADPCM) + * [3] ffmpeg source code, libavcodec/adpcm.c + */ + +#define ADPCM_NUM_COEFF 7 + +static int16_t dec_coeff[2][2]; +static uint16_t delta[2]; +static int16_t sample[2][2]; + +static struct pcm_format *fmt; + +static const int16_t adaptation_table[] ICONST_ATTR = { + 230, 230, 230, 230, 307, 409, 512, 614, + 768, 614, 512, 409, 307, 230, 230, 230 +}; + +static bool set_format(struct pcm_format *format) +{ + fmt = format; + + if (fmt->bitspersample != 4) + { + DEBUGF("CODEC_ERROR: microsoft adpcm must be 4 bitspersample: %d\n", + fmt->bitspersample); + return false; + } + + fmt->chunksize = fmt->blockalign; + + return true; +} + +static struct pcm_pos *get_seek_pos(uint32_t seek_val, int seek_mode, + uint8_t *(*read_buffer)(size_t *realsize)) +{ + static struct pcm_pos newpos; + uint32_t newblock = (seek_mode == PCM_SEEK_TIME) ? + ((uint64_t)seek_val * ci->id3->frequency / 1000LL) + / fmt->samplesperblock : + seek_val / fmt->blockalign; + + (void)read_buffer; + newpos.pos = newblock * fmt->blockalign; + newpos.samples = newblock * fmt->samplesperblock; + return &newpos; +} + +static int16_t create_pcmdata(int ch, uint8_t nibble) +{ + int32_t pcmdata; + + pcmdata = (sample[ch][0] * dec_coeff[ch][0] + + sample[ch][1] * dec_coeff[ch][1]) / 256; + pcmdata += (delta[ch] * (nibble - ((nibble & 0x8) << 1))); + + CLIP(pcmdata, -32768, 32767); + + sample[ch][1] = sample[ch][0]; + sample[ch][0] = pcmdata; + + delta[ch] = (adaptation_table[nibble] * delta[ch]) >> 8; + if (delta[ch] < 16) + delta[ch] = 16; + + return (int16_t)pcmdata; +} + +static int decode(const uint8_t *inbuf, size_t inbufsize, + int32_t *outbuf, int *outbufcount) +{ + int ch; + size_t nsamples = 0; + int size = fmt->samplesperblock; + + /* read block header */ + for (ch = 0; ch < fmt->channels; ch++) + { + if (*inbuf >= ADPCM_NUM_COEFF) + { + DEBUGF("CODEC_ERROR: microsoft adpcm illegal initial coeff=%d > 7\n", + *inbuf); + return CODEC_ERROR; + } + dec_coeff[ch][0] = fmt->coeffs[*inbuf][0]; + dec_coeff[ch][1] = fmt->coeffs[*inbuf][1]; + inbuf++; + } + + for (ch = 0; ch < fmt->channels; ch++) + { + delta[ch] = inbuf[0] | (SE(inbuf[1]) << 8); + inbuf += 2; + } + + for (ch = 0; ch < fmt->channels; ch++) + { + sample[ch][0] = inbuf[0] | (SE(inbuf[1]) << 8); + inbuf += 2; + } + + for (ch = 0; ch < fmt->channels; ch++) + { + sample[ch][1] = inbuf[0] | (SE(inbuf[1]) << 8); + inbuf += 2; + } + + inbufsize -= 7 * fmt->channels; + ch = fmt->channels - 1; + + while (size-- > 0) + { + *outbuf++ = create_pcmdata(0, *inbuf >> 4 ) << (PCM_OUTPUT_DEPTH - 16); + *outbuf++ = create_pcmdata(ch, *inbuf & 0xf) << (PCM_OUTPUT_DEPTH - 16); + nsamples += 2; + + inbuf++; + inbufsize--; + if (inbufsize <= 0) + break; + } + + if (fmt->channels == 2) + nsamples >>= 1; + *outbufcount = nsamples; + + return CODEC_OK; +} + +static const struct pcm_codec codec = { + set_format, + get_seek_pos, + decode, + }; + +const struct pcm_codec *get_ms_adpcm_codec(void) +{ + return &codec; +} diff --git a/lib/rbcodec/codecs/libpcm/pcm_common.h b/lib/rbcodec/codecs/libpcm/pcm_common.h new file mode 100644 index 0000000000..90e29c98ee --- /dev/null +++ b/lib/rbcodec/codecs/libpcm/pcm_common.h @@ -0,0 +1,190 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2009 Yoshihisa Uchida + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ +#ifndef CODEC_LIBPCM_PCM_COMMON_H +#define CODEC_LIBPCM_PCM_COMMON_H + +#include +#include +#include + +/* decoded pcm sample depth (sample 28bit + sign 1bit) */ +#define PCM_OUTPUT_DEPTH 29 + +/* Macro that sign extends an unsigned byte */ +#define SE(x) ((int32_t)((int8_t)(x))) + +/* Macro that shift to -0x80. (0 .. 127 to -128 .. -1, 128 .. 255 to 0 .. 127) */ +#define SFT(x) ((int32_t)x-0x80) + +/* Macro that clipping data */ +#define CLIP(data, min, max) \ +if ((data) > (max)) data = max; \ +else if ((data) < (min)) data = min; + +/* nums of msadpcm coeffs + * In many case, nNumCoef is 7. + * Depending upon the encoder, as for this value there is a possibility + * of increasing more. + * If you found the file where this value exceeds 7, please report. + */ +#define MSADPCM_NUM_COEFF 7 + +struct pcm_format { + /* + * RIFF: wFormatTag (in 'fmt ' chunk) + * AIFF: compressionType (in 'COMM' chunk) + */ + uint32_t formattag; + + /* + * RIFF: wChannels (in 'fmt ' chunk) + * AIFF: numChannels (in 'COMM' chunk) + */ + uint16_t channels; + + /* + * RIFF: dwSamplesPerSec (in 'fmt ' chunk) + * AIFF: sampleRate (in 'COMM' chunk) + */ + uint32_t samplespersec; + + /* RIFF: dwAvgBytesPerSec (in 'fmt ' chunk) */ + uint32_t avgbytespersec; + + /* + * RIFF: wBlockAlign (in 'fmt ' chunk) + * AIFF: blockSize (in 'SSND' chunk) + */ + uint16_t blockalign; + + /* + * RIFF: wBitsPerSample (in 'fmt ' chunk) + * AIFF: sampleSize (in 'COMM' chunk) + */ + uint16_t bitspersample; + + /* RIFF: wSize (in 'fmt ' chunk) */ + uint16_t size; + + /* RIFF: dSamplesPerBlock (in 'fmt ' chunk) */ + uint16_t samplesperblock; + + /* RIFF: wTotalSamples (in 'fact' chunk) */ + uint16_t totalsamples; + + /* the following values are not RIFF/AIFF chunk values */ + + /* bytes per sample */ + int bytespersample; + + /* chunk size */ + long chunksize; + + /* data size */ + uint32_t numbytes; + + /* + * data endian + * true: little endian, false: big endian + */ + bool is_little_endian; + + /* + * data signess + * true: signed, false: unsigned + */ + bool is_signed; + + /* the following values are format speciffic parameters */ + + /* microsoft adpcm: aCoeff */ + int16_t coeffs[MSADPCM_NUM_COEFF][2]; +}; + +struct pcm_pos { + uint32_t pos; + uint32_t samples; +}; + +#define PCM_SEEK_TIME 0 +#define PCM_SEEK_POS 1 + +struct pcm_codec { + /* + * sets the format speciffic RIFF/AIFF header information and checks the pcm_format. + * + * [In/Out] format + * the structure which supplies RIFF/AIFF header information. + * + * return + * true: RIFF/AIFF header check OK + * false: RIFF/AIFF header check NG + */ + bool (*set_format)(struct pcm_format *format); + + /* + * get seek position + * + * [In] seek_val + * seek time [ms] or seek position + * + * [In] seek_mode + * if seek_mode sets PCM_SEEK_TIME, then seek_val means the seek time. + * if seek_mode sets PCM_SEEK_POS, then seek_val means the seek position. + * + * [In] read_buffer + * the function which reads the data from the file (chunksize bytes read). + * + * return + * position after the seeking. + */ + struct pcm_pos *(*get_seek_pos)(uint32_t seek_val, int seek_mode, + uint8_t *(*read_buffer)(size_t *realsize)); + + /* + * decode wave data. + * + * [In] inbuf + * the start pointer of wave data buffer. + * + * [In] inbufsize + * wave data buffer size (bytes). + * + * [Out] outbuf + * the start pointer of the buffer which supplies decoded pcm data. + * + * [Out] outbufcount + * decoded pcm data count. + * + * return + * CODEC_OK: decode succeed. + * CODEC_ERROR: decode failure. + */ + int (*decode)(const uint8_t *inbuf, size_t inbufsize, + int32_t *outbuf, int *outbufcount); +}; + +struct pcm_entry { + uint32_t format_tag; + const struct pcm_codec *(*get_codec)(void); +}; + +#endif diff --git a/lib/rbcodec/codecs/libpcm/qt_ima_adpcm.c b/lib/rbcodec/codecs/libpcm/qt_ima_adpcm.c new file mode 100644 index 0000000000..d7b3360eb3 --- /dev/null +++ b/lib/rbcodec/codecs/libpcm/qt_ima_adpcm.c @@ -0,0 +1,138 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2010 Yoshihisa Uchida + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ +#include "codeclib.h" +#include "ima_adpcm_common.h" +#include "support_formats.h" + +/* + * Apple QuickTime IMA ADPCM + * + * References + * [1] Multimedia Wiki, Apple QuickTime IMA ADPCM + * URL:http://wiki.multimedia.cx/index.php?title=Apple_QuickTime_IMA_ADPCM + * [2] Apple Inc., Technical Note TN1081 Understanding the Differences Between + * Apple and Windows IMA-ADPCM Compressed Sound Files, 1996 + * [3] ffmpeg source code, libavcodec/adpcm.c + */ + +static struct pcm_format *fmt; + +static bool set_format(struct pcm_format *format) +{ + fmt = format; + + if (fmt->bitspersample != 4) + { + DEBUGF("CODEC_ERROR: quicktime ima adpcm must be 4 bitspersample: %d\n", + fmt->bitspersample); + return false; + } + + fmt->blockalign = 34 * fmt->channels; + fmt->samplesperblock = 64; + + /* chunksize = about 1/50[s] data */ + fmt->chunksize = (ci->id3->frequency / (50 * fmt->samplesperblock)) + * fmt->blockalign; + + init_ima_adpcm_decoder(4, NULL); + return true; +} + +static struct pcm_pos *get_seek_pos(uint32_t seek_val, int seek_mode, + uint8_t *(*read_buffer)(size_t *realsize)) +{ + static struct pcm_pos newpos; + uint32_t newblock = (seek_mode == PCM_SEEK_TIME) ? + ((uint64_t)seek_val * ci->id3->frequency / 1000LL) + / fmt->samplesperblock : + seek_val / fmt->blockalign; + + (void)read_buffer; + newpos.pos = newblock * fmt->blockalign; + newpos.samples = newblock * fmt->samplesperblock; + return &newpos; +} + +static int decode(const uint8_t *inbuf, size_t inbufsize, + int32_t *outbuf, int *outbufcount) +{ + int ch; + size_t nsamples = 0; + int block_size; + int32_t *pcmbuf; + int32_t init_pcmdata; + int8_t init_index; + + while (inbufsize > 0) + { + for (ch = 0; ch < fmt->channels; ch++) + { + /* read block header */ + init_pcmdata = (inbuf[0] << 8)|(inbuf[1] & 0x80); + if (init_pcmdata > 32767) + init_pcmdata -= 65536; + + init_index = inbuf[1] & 0x7f; + if (init_index > 88) + { + DEBUGF("CODEC_ERROR: quicktime ima adpcm illegal step index=%d > 88\n", + init_index); + return CODEC_ERROR; + } + + inbuf += 2; + inbufsize -= 2; + + set_decode_parameters(1, &init_pcmdata, &init_index); + + /* read block data */ + pcmbuf = outbuf + ch; + for (block_size = 32; block_size > 0 && inbufsize > 0; block_size--, inbufsize--) + { + *pcmbuf = create_pcmdata_size4(ch, *inbuf ) << IMA_ADPCM_INC_DEPTH; + pcmbuf += fmt->channels; + *pcmbuf = create_pcmdata_size4(ch, *inbuf >> 4) << IMA_ADPCM_INC_DEPTH; + pcmbuf += fmt->channels; + nsamples += 2; + inbuf++; + } + } + outbuf += 64 * fmt->channels; + } + + if (fmt->channels == 2) + nsamples >>= 1; + *outbufcount = nsamples; + + return CODEC_OK; +} + +static const struct pcm_codec codec = { + set_format, + get_seek_pos, + decode, + }; + +const struct pcm_codec *get_qt_ima_adpcm_codec(void) +{ + return &codec; +} diff --git a/lib/rbcodec/codecs/libpcm/support_formats.h b/lib/rbcodec/codecs/libpcm/support_formats.h new file mode 100644 index 0000000000..b1e089e464 --- /dev/null +++ b/lib/rbcodec/codecs/libpcm/support_formats.h @@ -0,0 +1,55 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2009 Yoshihisa Uchida + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ +#ifndef CODEC_LIBPCM_SUPPORT_FORMATS_H +#define CODEC_LIBPCM_SUPPORT_FORMATS_H + +#include "pcm_common.h" + +/* Linear PCM */ +const struct pcm_codec *get_linear_pcm_codec(void); + +/* ITU-T G.711 A-law */ +const struct pcm_codec *get_itut_g711_alaw_codec(void); + +/* ITU-T G.711 mu-law */ +const struct pcm_codec *get_itut_g711_mulaw_codec(void); + +/* Intel DVI ADPCM (IMA ADPCM) */ +const struct pcm_codec *get_dvi_adpcm_codec(void); + +/* IEEE float */ +const struct pcm_codec *get_ieee_float_codec(void); + +/* Microsoft ADPCM */ +const struct pcm_codec *get_ms_adpcm_codec(void); + +/* Dialogic OKI ADPCM */ +const struct pcm_codec *get_dialogic_oki_adpcm_codec(void); + +/* YAMAHA ADPCM */ +const struct pcm_codec *get_yamaha_adpcm_codec(void); + +/* Apple QuickTime IMA ADPCM */ +const struct pcm_codec *get_qt_ima_adpcm_codec(void); + +/* Adobe SWF ADPCM */ +const struct pcm_codec *get_swf_adpcm_codec(void); +#endif diff --git a/lib/rbcodec/codecs/libpcm/swf_adpcm.c b/lib/rbcodec/codecs/libpcm/swf_adpcm.c new file mode 100644 index 0000000000..c440fd1303 --- /dev/null +++ b/lib/rbcodec/codecs/libpcm/swf_adpcm.c @@ -0,0 +1,236 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2010 Yoshihisa Uchida + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ +#include "codeclib.h" +#include "ima_adpcm_common.h" +#include "support_formats.h" + +/* + * Adobe SWF ADPCM + * + * References + * [1] Adobe, SWF File Format Specification Version 10, 2008 + * [2] Jack Jansen, adpcm.c in adpcm.zip + * [3] ffmpeg source code, libavcodec/adpcm.c + */ + +/* step index table when bitspersample is 3. + * (when bitspersample is 2, 4, 5, step index table uses the table + * which is defined ima_adpcm_common.c.) + */ +static const int index_table[4] ICONST_ATTR = { + -1, -1, 2, 4, +}; + +static int validity_bits = 8; +static bool first_block = true; +static int blockbits = 0; +static int lastbytebits = 0; +static bool after_seek = false; + +static struct pcm_format *fmt; + +#define GET_SAMPLE_COUNT(s) ((((s) << 3) / fmt->channels - 22) / fmt->bitspersample + 1) + +static bool set_format(struct pcm_format *format) +{ + fmt = format; + + if (fmt->bitspersample < 2 || fmt->bitspersample > 5) + { + DEBUGF("CODEC_ERROR: swf adpcm must be 2, 3, 4 or 5 bitspersample: %d\n", + fmt->bitspersample); + return false; + } + + if (fmt->samplesperblock == 0) + fmt->samplesperblock = (((fmt->blockalign << 3) - 2) / fmt->channels - 22) + / fmt->bitspersample + 1; + + blockbits = ((fmt->samplesperblock - 1) * fmt->bitspersample + 22) * fmt->channels; + + /* + * chunksize = about 93 [ms] data (frequency:44.1kHz, 4096 [sample/block]) + * chunksize changes depending upon the position of block. + */ + fmt->chunksize = (blockbits + 9) >> 3; + + /* initialize for ima adpcm common functions */ + if (fmt->bitspersample == 3) + init_ima_adpcm_decoder(fmt->bitspersample, index_table); + else + init_ima_adpcm_decoder(fmt->bitspersample, NULL); + + return true; +} + +static struct pcm_pos *get_seek_pos(uint32_t seek_val, int seek_mode, + uint8_t *(*read_buffer)(size_t *realsize)) +{ + static struct pcm_pos newpos; + uint32_t chunkbits = blockbits; + uint32_t seekblocks = (seek_mode == PCM_SEEK_TIME)? + ((uint64_t)seek_val * ci->id3->frequency) + / (1000LL * fmt->samplesperblock) : + ((seek_val << 3) - 2) / blockbits; + uint32_t seekbits = seekblocks * blockbits + 2; + + (void)read_buffer; + + newpos.pos = seekbits >> 3; + newpos.samples = seekblocks * fmt->samplesperblock; + + if (newpos.pos == 0) + { + first_block = true; + lastbytebits = 0; + } + else + { + first_block = false; + lastbytebits = seekbits & 0x07; + if (lastbytebits != 0) + chunkbits -= (8 - lastbytebits); + } + + /* calculates next read bytes */ + fmt->chunksize = (chunkbits >> 3) + (((chunkbits & 0x07) > 0)?1:0) + + ((lastbytebits > 0)?1:0); + + after_seek = true; + return &newpos; +} + +static uint8_t get_data(const uint8_t **buf, int bit) +{ + uint8_t res = 0; + uint8_t mask = (1 << bit) - 1; + + if (validity_bits >= bit) + { + validity_bits -= bit; + return (**buf >> validity_bits) & mask; + } + + if (validity_bits > 0) + res = **buf << (bit - validity_bits); + + validity_bits += 8 - bit; + res = (res | (*(++(*buf)) >> validity_bits)) & mask; + return res; +} + +static int decode(const uint8_t *inbuf, size_t inbufsize, + int32_t *outbuf, int *outbufcount) +{ + int ch; + int adpcm_code_size; + int count = ((size_t)fmt->chunksize == inbufsize) ? fmt->samplesperblock : + GET_SAMPLE_COUNT(inbufsize); + int32_t init_pcmdata[2]; + int8_t init_index[2]; + static uint8_t lastbyte = 0; + + validity_bits = 8; + *outbufcount = count; + + /* read block header */ + ch = fmt->channels - 1; + if (first_block) + { + adpcm_code_size = get_data(&inbuf, 2) + 2; + if (fmt->bitspersample != adpcm_code_size) + { + DEBUGF("CODEC_ERROR: swf adpcm different adpcm code size=%d != %d\n", + adpcm_code_size, fmt->bitspersample); + return CODEC_ERROR; + } + init_pcmdata[0] = (get_data(&inbuf, 8) << 8) | get_data(&inbuf, 8); + + lastbytebits = 0; + first_block = false; + } + else + { + if (after_seek && lastbytebits > 0) + { + lastbyte = *inbuf++; + after_seek = false; + } + if (lastbytebits > 0) + init_pcmdata[0] = ((lastbyte << (8 + lastbytebits)) | + (get_data(&inbuf, 8) << lastbytebits) | + get_data(&inbuf, lastbytebits)) & 65535; + else + init_pcmdata[0] = (get_data(&inbuf, 8) << 8) | get_data(&inbuf, 8); + } + after_seek = false; + + init_index[0] = get_data(&inbuf, 6); + if (init_pcmdata[0] > 32767) + init_pcmdata[0] -= 65536; + + if (ch > 0) + { + init_pcmdata[1] = (get_data(&inbuf, 8) << 8) | get_data(&inbuf, 8); + init_index[1] = get_data(&inbuf, 6); + if (init_pcmdata[1] > 32767) + init_pcmdata[1] -= 65536; + } + + *outbuf++ = init_pcmdata[0] << IMA_ADPCM_INC_DEPTH; + if (ch > 0) + *outbuf++ = init_pcmdata[1] << IMA_ADPCM_INC_DEPTH; + + set_decode_parameters(fmt->channels, init_pcmdata, init_index); + + /* read block data */ + while (--count > 0) + { + *outbuf++ = create_pcmdata(0, get_data(&inbuf, fmt->bitspersample)) + << IMA_ADPCM_INC_DEPTH; + if (ch > 0) + *outbuf++ = create_pcmdata(ch, get_data(&inbuf, fmt->bitspersample)) + << IMA_ADPCM_INC_DEPTH; + } + + lastbyte = *inbuf; + lastbytebits = (8 - validity_bits) & 0x07; + + /* calculates next read bytes */ + fmt->chunksize = (blockbits - validity_bits + 7) >> 3; + + return CODEC_OK; +} + +static const struct pcm_codec codec = { + set_format, + get_seek_pos, + decode, + }; + +const struct pcm_codec *get_swf_adpcm_codec(void) +{ + first_block = true; + lastbytebits = 0; + after_seek = false; + + return &codec; +} diff --git a/lib/rbcodec/codecs/libpcm/yamaha_adpcm.c b/lib/rbcodec/codecs/libpcm/yamaha_adpcm.c new file mode 100644 index 0000000000..c67fe7524a --- /dev/null +++ b/lib/rbcodec/codecs/libpcm/yamaha_adpcm.c @@ -0,0 +1,250 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2010 Yoshihisa Uchida + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ +#include "codeclib.h" +#include "adpcm_seek.h" +#include "support_formats.h" + +/* + * YAMAHA ADPCM + * + * References + * [1] YAMAHA, YAMAHA ADPCM ACM Driver Version 1.0.0.0, 2005 + * [2] BlendWorks, YM2608 ADPCM, + * http://web.archive.org/web/20050208190547/www.memb.jp/~dearna/ma/ym2608/adpcm.html + * [3] Naoyuki Sawa, ADPCM no shikumi #1, + * http://www.piece-me.org/piece-lab/adpcm/adpcm1.html + * [4] ffmpeg source code, libavcodec/adpcm.c + */ + +/* ADPCM data block layout + * + * when the block header exists. (for example, encoding by YAMAHA ADPCM ACM Driver) + * blockAlign = (frequency / 60 + 4) * channels. + * + * block + * (channels = 1) + * int16_t first value (Little endian) + * uint16_t first predictor (Little endian) + * uint8_t ADPCM data (1st data: 0-3 bit, 2nd data: 4-7 bit) + * .... + * + * (channels = 2) + * int16_t Left channel first value (Little endian) + * uint16_t Left channel first predictor (Little endian) + * int16_t Right channel first value (Little endian) + * uint16_t Right channel first predictor (Little endian) + * uint8_t ADPCM data (Left channel: 0-3 bit, Right channel: 4-7 bit) + * .... + * + * when the block header does not exist. (for example, encoding by ffmpeg) + * blockAlign = 8000 + * + * block + * (channels = 1) + * uint8_t ADPCM data (1st data: 0-3 bit, 2nd data: 4-7 bit) + * .... + * + * (channels = 2) + * uint8_t ADPCM data (Left channel: 0-3 bit, Right channel: 4-7 bit) + * .... + */ + +static const int32_t amplification_table[] ICONST_ATTR = { + 230, 230, 230, 230, 307, 409, 512, 614, 230, 230, 230, 230, 307, 409, 512, 614 +}; + +static bool has_block_header = false; + +static struct adpcm_data cur_data; +static int blocksperchunk; + +static struct pcm_format *fmt; + +static bool set_format(struct pcm_format *format) +{ + fmt = format; + + if (fmt->channels == 0) + { + DEBUGF("CODEC_ERROR: channels is 0\n"); + return false; + } + + if (fmt->bitspersample != 4) + { + DEBUGF("CODEC_ERROR: yamaha adpcm must be 4 bitspersample: %d\n", + fmt->bitspersample); + return false; + } + + /* check exists block header */ + if (fmt->blockalign == ((ci->id3->frequency / 60) + 4) * fmt->channels) + { + has_block_header = true; + + /* chunksize = about 1/30 [sec] data */ + fmt->chunksize = fmt->blockalign; + blocksperchunk = 1; + } + else + { + uint32_t max_chunk_count; + + has_block_header = false; + + /* blockalign = 2 * channels samples */ + fmt->blockalign = fmt->channels; + fmt->samplesperblock = 2; + + /* chunksize = about 1/32[sec] data */ + blocksperchunk = ci->id3->frequency >> 6; + fmt->chunksize = blocksperchunk * fmt->blockalign; + + max_chunk_count = (uint64_t)ci->id3->length * ci->id3->frequency + / (2000LL * fmt->chunksize / fmt->channels); + + /* initialize seek table */ + init_seek_table(max_chunk_count); + /* add first data */ + add_adpcm_data(&cur_data); + } + + return true; +} + +static int16_t create_pcmdata(int ch, uint8_t nibble) +{ + int32_t tmp_pcmdata = cur_data.pcmdata[ch]; + int32_t step = cur_data.step[ch]; + int32_t delta = step >> 3; + + if (nibble & 4) delta += step; + if (nibble & 2) delta += (step >> 1); + if (nibble & 1) delta += (step >> 2); + + if (nibble & 0x08) + tmp_pcmdata -= delta; + else + tmp_pcmdata += delta; + + CLIP(tmp_pcmdata, -32768, 32767); + cur_data.pcmdata[ch] = tmp_pcmdata; + + step = (step * amplification_table[nibble & 0x07]) >> 8; + CLIP(step, 127, 24576); + cur_data.step[ch] = step; + + return cur_data.pcmdata[ch]; +} + +static int decode(const uint8_t *inbuf, size_t inbufsize, + int32_t *outbuf, int *outbufcount) +{ + int ch; + size_t nsamples = 0; + + /* read block header */ + if (has_block_header) + { + for (ch = 0; ch < fmt->channels; ch++) + { + cur_data.pcmdata[ch] = inbuf[0] | (SE(inbuf[1]) << 8); + cur_data.step[ch] = inbuf[2] | (inbuf[3] << 8); + + inbuf += 4; + inbufsize -= 4; + } + } + + /* read block data */ + ch = fmt->channels - 1; + while (inbufsize) + { + *outbuf++ = create_pcmdata(0, *inbuf ) << (PCM_OUTPUT_DEPTH - 16); + *outbuf++ = create_pcmdata(ch, *inbuf >> 4) << (PCM_OUTPUT_DEPTH - 16); + nsamples += 2; + + inbuf++; + inbufsize--; + } + + if (fmt->channels == 2) + nsamples >>= 1; + *outbufcount = nsamples; + + if (!has_block_header) + add_adpcm_data(&cur_data); + + return CODEC_OK; +} + +static int decode_for_seek(const uint8_t *inbuf, size_t inbufsize) +{ + int ch = fmt->channels - 1; + + while (inbufsize) + { + create_pcmdata(0, *inbuf ); + create_pcmdata(ch, *inbuf >> 4); + + inbuf++; + inbufsize--; + } + + add_adpcm_data(&cur_data); + + return CODEC_OK; +} + +static struct pcm_pos *get_seek_pos(uint32_t seek_val, int seek_mode, + uint8_t *(*read_buffer)(size_t *realsize)) +{ + static struct pcm_pos newpos; + uint32_t new_count = (seek_mode == PCM_SEEK_TIME)? + ((uint64_t)seek_val * ci->id3->frequency / 1000LL) + / (blocksperchunk * fmt->samplesperblock) : + seek_val / (unsigned long)fmt->chunksize; + + if (!has_block_header) + { + new_count = seek(new_count, &cur_data, read_buffer, &decode_for_seek); + } + newpos.pos = new_count * fmt->chunksize; + newpos.samples = new_count * blocksperchunk * fmt->samplesperblock; + return &newpos; +} + +static struct pcm_codec codec = { + set_format, + get_seek_pos, + decode, + }; + +const struct pcm_codec *get_yamaha_adpcm_codec(void) +{ + /* initialize first step, pcm data */ + cur_data.pcmdata[0] = 0; + cur_data.pcmdata[1] = 0; + cur_data.step[0] = 127; + cur_data.step[1] = 127; + + return &codec; +} diff --git a/lib/rbcodec/codecs/librm/SOURCES b/lib/rbcodec/codecs/librm/SOURCES new file mode 100644 index 0000000000..e0ff169fae --- /dev/null +++ b/lib/rbcodec/codecs/librm/SOURCES @@ -0,0 +1 @@ +rm.c diff --git a/lib/rbcodec/codecs/librm/bytestream.h b/lib/rbcodec/codecs/librm/bytestream.h new file mode 100644 index 0000000000..c2a968a4bd --- /dev/null +++ b/lib/rbcodec/codecs/librm/bytestream.h @@ -0,0 +1,37 @@ +#ifndef RM_BYTESTREAM_H +#define RM_BYTESTREAM_H + +#include + +static inline void advance_buffer(uint8_t **buf, int val) +{ + *buf += val; +} + +static inline uint8_t rm_get_uint8(uint8_t *buf) +{ + return (uint8_t)buf[0]; +} + +static inline uint16_t rm_get_uint16be(uint8_t *buf) +{ + return (uint16_t)((buf[0] << 8)|buf[1]); +} + +static inline uint32_t rm_get_uint32be(uint8_t *buf) +{ + return (uint32_t)((buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3]); +} + +static inline uint16_t rm_get_uint16le(uint8_t *buf) +{ + return (uint16_t)((buf[1] << 8)|buf[0]); +} + +static inline uint32_t rm_get_uint32le(uint8_t *buf) +{ + return (uint32_t)((buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0]); +} + +#endif /* RM_BYTESTREAM_H */ + diff --git a/lib/rbcodec/codecs/librm/librm.make b/lib/rbcodec/codecs/librm/librm.make new file mode 100644 index 0000000000..3c736abec9 --- /dev/null +++ b/lib/rbcodec/codecs/librm/librm.make @@ -0,0 +1,18 @@ +# __________ __ ___. +# Open \______ \ ____ ____ | | _\_ |__ _______ ___ +# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / +# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < +# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ +# \/ \/ \/ \/ \/ +# $Id: librm.make 20151 2009-03-01 09:04:15Z amiconn $ +# + +# librm +RMLIB := $(CODECDIR)/librm.a +RMLIB_SRC := $(call preprocess, $(RBCODECLIB_DIR)/codecs/librm/SOURCES) +RMLIB_OBJ := $(call c2obj, $(RMLIB_SRC)) +OTHER_SRC += $(RMLIB_SRC) + +$(RMLIB): $(RMLIB_OBJ) + $(SILENT)$(shell rm -f $@) + $(call PRINTS,AR $(@F))$(AR) rcs $@ $^ >/dev/null diff --git a/lib/rbcodec/codecs/librm/rm.c b/lib/rbcodec/codecs/librm/rm.c new file mode 100644 index 0000000000..eabbe5d92a --- /dev/null +++ b/lib/rbcodec/codecs/librm/rm.c @@ -0,0 +1,592 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2008 Dave Chapman + * Copyright (C) 2009 Mohamed Tarek + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ +#include +#include + +#include "rm.h" +#ifdef ROCKBOX +#include "codeclib.h" +#endif + +#define SWAP(a, b) do{uint8_t SWAP_tmp= b; b= a; a= SWAP_tmp;}while(0) + +#ifdef TEST +#include +#include +#include "inttypes.h" +#include + +int filesize(int fd) +{ + struct stat buf; + + if (fstat(fd,&buf) == -1) { + return -1; + } else { + return (int)buf.st_size; + } +} + +static int read_uint8(int fd, uint8_t* buf) +{ + unsigned char tmp[1]; + int res; + + res=read(fd, tmp, 1); + *buf = tmp[0]; + return res; +} + +static int read_uint16be(int fd, uint16_t* buf) +{ + unsigned char tmp[2]; + int res; + + res=read(fd, tmp, 2); + *buf = (tmp[0] << 8) | tmp[1]; + return res; +} + +static int read_uint32be(int fd, uint32_t* buf) +{ + unsigned char tmp[4]; + int res; + + res=read(fd, tmp, 4); + *buf = (tmp[0] << 24) | (tmp[1] << 16) | (tmp[2] << 8) | tmp[3]; + return res; +} + + +static void print_cook_extradata(RMContext *rmctx) { + + DEBUGF(" cook_version = 0x%08x\n", rm_get_uint32be(rmctx->codec_extradata)); + DEBUGF(" samples_per_frame_per_channel = %d\n", rm_get_uint16be(&rmctx->codec_extradata[4])); + DEBUGF(" number_of_subbands_in_freq_domain = %d\n", rm_get_uint16be(&rmctx->codec_extradata[6])); + if(rmctx->extradata_size == 16) { + DEBUGF(" joint_stereo_subband_start = %d\n",rm_get_uint16be(&rmctx->codec_extradata[12])); + DEBUGF(" joint_stereo_vlc_bits = %d\n", rm_get_uint16be(&rmctx->codec_extradata[14])); + } +} + + +struct real_object_t +{ + uint32_t fourcc; + uint32_t size; + uint16_t version; +}; + +#define FOURCC(a,b,c,d) (((a)<<24) | ((b) << 16) | ((c) << 8) | (d)) + +static int real_read_object_header(int fd, struct real_object_t* obj) +{ + int n; + + if ((n = read_uint32be(fd, &obj->fourcc)) <= 0) return n; + if ((n = read_uint32be(fd, &obj->size)) <= 0) return n; + if ((n = read_uint16be(fd, &obj->version)) <= 0) return n; + + return 1; +} + +static char* fourcc2str(uint32_t f) +{ + static char res[5]; + + res[0] = (f & 0xff000000) >> 24; + res[1] = (f & 0xff0000) >> 16; + res[2] = (f & 0xff00) >> 8; + res[3] = (f & 0xff); + res[4] = 0; + + return res; +} + +static int read_str(int fd, char* buf) +{ + uint8_t len; + int res; + + res = read(fd, &len, 1); + res = read(fd, buf, len); + buf[len]=0; + + return len+1; +} + +static int real_read_audio_stream_info(int fd, RMContext *rmctx) +{ + int skipped = 0; + uint32_t version; + struct real_object_t obj; + memset(&obj,0,sizeof(obj)); + uint32_t header_size; + uint16_t flavor; + uint32_t coded_framesize; + uint32_t unknown1; + uint32_t unknown2; + uint32_t unknown3; + uint16_t unknown4; + uint16_t unknown5; + uint16_t unknown6; + uint16_t unknown7; + uint32_t unknown8; + uint8_t interleaver_id_length; + uint32_t interleaver_id; + uint8_t fourcc_length; + uint32_t fourcc = 0; + uint8_t unknown9; + uint16_t unknown10; + uint8_t unknown11; + + read_uint32be(fd, &version); + skipped += 4; + + DEBUGF(" version=0x%04x\n",((version >> 16) & 0xff)); + if (((version >> 16) & 0xff) == 3) { + /* Very old version */ + } else { + real_read_object_header(fd, &obj); + skipped += 10; + read_uint32be(fd, &header_size); + skipped += 4; + /* obj.size will be filled with an unknown value, replaced with header_size */ + DEBUGF(" Object: %s, size: %d bytes, version: 0x%04x\n",fourcc2str(obj.fourcc),header_size,obj.version); + + read_uint16be(fd, &flavor); + read_uint32be(fd, &coded_framesize); + read_uint32be(fd, &unknown1); + read_uint32be(fd, &unknown2); + read_uint32be(fd, &unknown3); + read_uint16be(fd, &rmctx->sub_packet_h); + read_uint16be(fd, &rmctx->block_align); + read_uint16be(fd, &rmctx->sub_packet_size); + read_uint16be(fd, &unknown4); + skipped += 26; + if (((version >> 16) & 0xff) == 5) + { + read_uint16be(fd, &unknown5); + read_uint16be(fd, &unknown6); + read_uint16be(fd, &unknown7); + skipped += 6; + } + read_uint16be(fd, &rmctx->sample_rate); + read_uint32be(fd, &unknown8); + read_uint16be(fd, &rmctx->nb_channels); + skipped += 8; + if (((version >> 16) & 0xff) == 4) + { + read_uint8(fd, &interleaver_id_length); + read_uint32be(fd, &interleaver_id); + read_uint8(fd, &fourcc_length); + read_uint32be(fd, &fourcc); + skipped += 10; + } + if (((version >> 16) & 0xff) == 5) + { + read_uint32be(fd, &interleaver_id); + read_uint32be(fd, &fourcc); + skipped += 8; + } + read_uint8(fd,&unknown9); + read_uint16be(fd,&unknown10); + skipped += 3; + if (((version >> 16) & 0xff) == 5) + { + read_uint8(fd, &unknown11); + skipped += 1; + } + + switch(fourcc) { + case FOURCC('c','o','o','k'): + rmctx->codec_type = CODEC_COOK; + read_uint32be(fd, &rmctx->extradata_size); + skipped += 4; + read(fd, rmctx->codec_extradata, rmctx->extradata_size); + skipped += rmctx->extradata_size; + break; + + case FOURCC('a','t','r','c'): + rmctx->codec_type = CODEC_ATRAC; + read_uint32be(fd, &rmctx->extradata_size); + skipped += 4; + read(fd, rmctx->codec_extradata, rmctx->extradata_size); + skipped += rmctx->extradata_size; + break; + + case FOURCC('r','a','a','c'): + case FOURCC('r','a','c','p'): + rmctx->codec_type = CODEC_AAC; + read_uint32be(fd, &rmctx->extradata_size); + skipped += 4; + read(fd, rmctx->codec_extradata, rmctx->extradata_size); + skipped += rmctx->extradata_size; + break; + + case FOURCC('d','n','e','t'): + rmctx->codec_type = CODEC_AC3; + break; + + default: /* Not a supported codec */ + return -1; + } + + + DEBUGF(" flavor = %d\n",flavor); + DEBUGF(" coded_frame_size = %d\n",coded_framesize); + DEBUGF(" sub_packet_h = %d\n",rmctx->sub_packet_h); + DEBUGF(" frame_size = %d\n",rmctx->block_align); + DEBUGF(" sub_packet_size = %d\n",rmctx->sub_packet_size); + DEBUGF(" sample_rate= %d\n",rmctx->sample_rate); + DEBUGF(" channels= %d\n",rmctx->nb_channels); + DEBUGF(" fourcc = %s\n",fourcc2str(fourcc)); + DEBUGF(" codec_extra_data_length = %d\n",rmctx->extradata_size); + if(rmctx->codec_type == CODEC_COOK) { + DEBUGF(" cook_extradata :\n"); + print_cook_extradata(rmctx); + } + + } + + return skipped; +} + +int real_parse_header(int fd, RMContext *rmctx) +{ + struct real_object_t obj; + memset(&obj,0,sizeof(obj)); + int res; + int skipped; + off_t curpos; + + uint32_t unknown1; + uint32_t unknown2; + + uint32_t max_bitrate; + uint32_t avg_bitrate = 0; + uint32_t max_packet_size; + uint32_t avg_packet_size; + uint32_t packet_count; + uint32_t duration; + uint32_t preroll; + uint32_t index_offset; + uint16_t num_streams; + uint16_t flags = 0; + + uint16_t stream_id; + uint32_t start_time; + char desc[256]; + char mimetype[256]; + uint32_t codec_data_size; + uint32_t v; + + char title[256]; + char author[256]; + char copyright[256]; + char comment[256]; + + uint32_t next_data_off; + uint8_t header_end; + + curpos = lseek(fd, 0, SEEK_SET); + res = real_read_object_header(fd, &obj); + + if (obj.fourcc == FOURCC('.','r','a',0xfd)) + { + /* Very old .ra format - not yet supported */ + return -1; + } + else if (obj.fourcc != FOURCC('.','R','M','F')) + { + return -1; + } + + read_uint32be(fd, &unknown1); + read_uint32be(fd, &unknown2); + + DEBUGF("Object: %s, size: %d bytes, version: 0x%04x, pos: %d\n",fourcc2str(obj.fourcc),(int)obj.size,obj.version,(int)curpos); + DEBUGF(" unknown1=%d (0x%08x)\n",unknown1,unknown1); + DEBUGF(" unknown2=%d (0x%08x)\n",unknown2,unknown2); + + res = real_read_object_header(fd, &obj); + header_end = 0; + while(res) + { + DEBUGF("Object: %s, size: %d bytes, version: 0x%04x, pos: %d\n",fourcc2str(obj.fourcc),(int)obj.size,obj.version,(int)curpos); + skipped = 10; + if(obj.fourcc == FOURCC('I','N','D','X')) + break; + switch (obj.fourcc) + { + case FOURCC('P','R','O','P'): /* File properties */ + read_uint32be(fd, &max_bitrate); + read_uint32be(fd, &rmctx->bit_rate); /*avg bitrate*/ + read_uint32be(fd, &max_packet_size); + read_uint32be(fd, &avg_packet_size); + read_uint32be(fd, &packet_count); + read_uint32be(fd, &rmctx->duration); + read_uint32be(fd, &preroll); + read_uint32be(fd, &index_offset); + read_uint32be(fd, &rmctx->data_offset); + read_uint16be(fd, &num_streams); + read_uint16be(fd, &rmctx->flags); + skipped += 40; + + DEBUGF(" max_bitrate = %d\n",max_bitrate); + DEBUGF(" avg_bitrate = %d\n",avg_bitrate); + DEBUGF(" max_packet_size = %d\n",max_packet_size); + DEBUGF(" avg_packet_size = %d\n",avg_packet_size); + DEBUGF(" packet_count = %d\n",packet_count); + DEBUGF(" duration = %d\n",rmctx->duration); + DEBUGF(" preroll = %d\n",preroll); + DEBUGF(" index_offset = %d\n",index_offset); + DEBUGF(" data_offset = %d\n",rmctx->data_offset); + DEBUGF(" num_streams = %d\n",num_streams); + DEBUGF(" flags=0x%04x\n",flags); + break; + + case FOURCC('C','O','N','T'): + /* Four strings - Title, Author, Copyright, Comment */ + skipped += read_str(fd,title); + skipped += read_str(fd,author); + skipped += read_str(fd,copyright); + skipped += read_str(fd,comment); + + DEBUGF(" title=\"%s\"\n",title); + DEBUGF(" author=\"%s\"\n",author); + DEBUGF(" copyright=\"%s\"\n",copyright); + DEBUGF(" comment=\"%s\"\n",comment); + break; + + case FOURCC('M','D','P','R'): /* Media properties */ + read_uint16be(fd,&stream_id); + skipped += 2; + read_uint32be(fd,&max_bitrate); + skipped += 4; + read_uint32be(fd,&avg_bitrate); + skipped += 4; + read_uint32be(fd,&max_packet_size); + skipped += 4; + read_uint32be(fd,&avg_packet_size); + skipped += 4; + read_uint32be(fd,&start_time); + skipped += 4; + read_uint32be(fd,&preroll); + skipped += 4; + read_uint32be(fd,&duration); + skipped += 4; + skipped += read_str(fd,desc); + skipped += read_str(fd,mimetype); + read_uint32be(fd,&codec_data_size); + skipped += 4; + //From ffmpeg: codec_pos = url_ftell(pb); + read_uint32be(fd,&v); + skipped += 4; + + DEBUGF(" stream_id = 0x%04x\n",stream_id); + DEBUGF(" max_bitrate = %d\n",max_bitrate); + DEBUGF(" avg_bitrate = %d\n",avg_bitrate); + DEBUGF(" max_packet_size = %d\n",max_packet_size); + DEBUGF(" avg_packet_size = %d\n",avg_packet_size); + DEBUGF(" start_time = %d\n",start_time); + DEBUGF(" preroll = %d\n",preroll); + DEBUGF(" duration = %d\n",duration); + DEBUGF(" desc=\"%s\"\n",desc); + DEBUGF(" mimetype=\"%s\"\n",mimetype); + DEBUGF(" codec_data_size = %d\n",codec_data_size); + DEBUGF(" v=\"%s\"\n", fourcc2str(v)); + + if (v == FOURCC('.','r','a',0xfd)) + { + skipped += real_read_audio_stream_info(fd, rmctx); + } + + break; + + case FOURCC('D','A','T','A'): + + read_uint32be(fd,&rmctx->nb_packets); + skipped += 4; + read_uint32be(fd,&next_data_off); + skipped += 4; + if (!rmctx->nb_packets && (rmctx->flags & 4)) + rmctx->nb_packets = 3600 * 25; + + /*** + * nb_packets correction : + * in some samples, number of packets may not exactly form + * an integer number of scrambling units. This is corrected + * by constructing a partially filled unit out of the few + * remaining samples at the end of decoding. + ***/ + if(rmctx->nb_packets % rmctx->sub_packet_h) + rmctx->nb_packets += rmctx->sub_packet_h - (rmctx->nb_packets % rmctx->sub_packet_h); + + DEBUGF(" data_nb_packets = %d\n",rmctx->nb_packets); + DEBUGF(" next DATA offset = %d\n",next_data_off); + header_end = 1; + break; + } + if(header_end) break; + curpos = lseek(fd, obj.size - skipped, SEEK_CUR); + res = real_read_object_header(fd, &obj); + } + + + return 0; +} + +void rm_get_packet_fd(int fd,RMContext *rmctx, RMPacket *pkt) +{ + uint8_t unknown,packet_group; + uint16_t x; + uint16_t sps = rmctx->sub_packet_size; + uint16_t h = rmctx->sub_packet_h; + uint16_t y = rmctx->sub_packet_cnt; + uint16_t w = rmctx->audio_framesize; + int res; + do + { + y = rmctx->sub_packet_cnt; + read_uint16be(fd,&pkt->version); + read_uint16be(fd,&pkt->length); + read_uint16be(fd,&pkt->stream_number); + read_uint32be(fd,&pkt->timestamp); + DEBUGF(" version = %d\n" + " length = %d\n" + " stream = %d\n" + " timestmp= %d\n",pkt->version,pkt->length,pkt->stream_number,pkt->timestamp); + + if(pkt->version == 0) + { + read_uint8(fd,&packet_group); + read_uint8(fd,&pkt->flags); + } + if(pkt->version == 1) + read_uint8(fd,&unknown); + + if (pkt->flags & 2) /* keyframe */ + y = rmctx->sub_packet_cnt = 0; + if (!y) /* if keyframe update playback elapsed time */ + rmctx->audiotimestamp = pkt->timestamp; + + for(x = 0 ; x < w/sps; x++) + { + res = read(fd,pkt->data+(sps*(h*x+((h+1)/2)*(y&1)+(y>>1))), sps); + } + rmctx->audio_pkt_cnt++; + }while(++(rmctx->sub_packet_cnt) < h); + +} +#endif /*TEST*/ + +int rm_get_packet(uint8_t **src,RMContext *rmctx, RMPacket *pkt) +{ + int consumed = 0; + /* rockbox: comment 'set but unused' variables + uint8_t unknown; + */ + uint16_t x, place; + uint16_t sps = rmctx->sub_packet_size; + uint16_t h = rmctx->sub_packet_h; + uint16_t y = rmctx->sub_packet_cnt; + uint16_t w = rmctx->audio_framesize; + do + { + y = rmctx->sub_packet_cnt; + pkt->version = rm_get_uint16be(*src); + + /* Simple error checking */ + if(pkt->version != 0 && pkt->version != 1) + { + DEBUGF("parsing packets failed\n"); + return -1; + } + + pkt->length = rm_get_uint16be(*src+2); + pkt->stream_number = rm_get_uint16be(*src+4); + pkt->timestamp = rm_get_uint32be(*src+6); + /*DEBUGF(" version = %d\n" + " length = %d\n" + " stream = %d\n" + " timestamp= %d\n\n",pkt->version,pkt->length,pkt->stream_number,pkt->timestamp);*/ + /* unknown =*/ rm_get_uint8(*src+10); + pkt->flags = rm_get_uint8(*src+11); + + if(pkt->version == 1) + /* unknown = */ rm_get_uint8(*src+10); + + if (pkt->flags & 2) /* keyframe */ + y = rmctx->sub_packet_cnt = 0; + if (!y) + rmctx->audiotimestamp = pkt->timestamp; + + /* Skip packet header */ + advance_buffer(src, PACKET_HEADER_SIZE); + consumed += PACKET_HEADER_SIZE; + if (rmctx->codec_type == CODEC_COOK || rmctx->codec_type == CODEC_ATRAC) { + for(x = 0 ; x < w/sps; x++) + { + place = sps*(h*x+((h+1)/2)*(y&1)+(y>>1)); + pkt->frames[place/sps] = *src; + advance_buffer(src,sps); + consumed += sps; + } + } + else if (rmctx->codec_type == CODEC_AAC) { + rmctx->sub_packet_cnt = (rm_get_uint16be(*src) & 0xf0) >> 4; + advance_buffer(src, 2); + consumed += 2; + if (rmctx->sub_packet_cnt) { + for(x = 0; x < rmctx->sub_packet_cnt; x++) { + rmctx->sub_packet_lengths[x] = rm_get_uint16be(*src); + advance_buffer(src, 2); + consumed += 2; + } + rmctx->audio_pkt_cnt = --rmctx->sub_packet_cnt; + } + } + + else if (rmctx->codec_type == CODEC_AC3) { + /* The byte order of the data is reversed from standard AC3 */ + for(x = 0; x < pkt->length - PACKET_HEADER_SIZE; x+=2) { + SWAP((*src)[0], (*src)[1]); + *src += 2; + } + *src -= x; + } + rmctx->audio_pkt_cnt++; + }while(++(rmctx->sub_packet_cnt) < h); + +return consumed; +} + +#ifdef DEBUG +void dump_rm_context(RMContext *rmctx) +{ + DEBUGF("block_align = %d\n", rmctx->block_align); + DEBUGF("nb_channels = %d\n", rmctx->nb_channels); + DEBUGF("sample_rate = %d\n", rmctx->sample_rate); + DEBUGF("bit_rate = %d\n", rmctx->bit_rate ); +} +#endif diff --git a/lib/rbcodec/codecs/librm/rm.h b/lib/rbcodec/codecs/librm/rm.h new file mode 100644 index 0000000000..c4a4e3a77e --- /dev/null +++ b/lib/rbcodec/codecs/librm/rm.h @@ -0,0 +1,102 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2009 Mohamed Tarek + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ +#ifndef _RM_H +#define _RM_H + +#include +#include +#include "bytestream.h" + +#define MAX_EXTRADATA_SIZE 16 +#define DATA_HEADER_SIZE 18 +#define PACKET_HEADER_SIZE 12 + +enum codecs { + CODEC_COOK, + CODEC_AAC, + CODEC_AC3, + CODEC_ATRAC +}; + +typedef struct rm_packet +{ + uint8_t *frames[100]; /* Pointers to ordered audio frames in buffer */ + uint16_t version; + uint16_t length; + uint32_t timestamp; + uint16_t stream_number; + uint8_t flags; + +#ifdef TEST + uint8_t data[30000]; /* Reordered data. No malloc, hence the size */ +#endif +}RMPacket; + +typedef struct rm_context +{ + /* Demux Context */ + int old_format; + int current_stream; + int remaining_len; + int audio_stream_num; /*< Stream number for audio packets*/ + int audio_pkt_cnt; /* Output packet counter*/ + + /* Stream Variables */ + uint32_t data_offset; + uint32_t duration; + uint32_t audiotimestamp; /* Audio packet timestamp*/ + uint16_t sub_packet_cnt; /* Subpacket counter, used while reading */ + uint16_t sub_packet_size, sub_packet_h, coded_framesize; /* Descrambling parameters from container */ + uint16_t audio_framesize; /* Audio frame size from container */ + uint16_t sub_packet_lengths[16]; /* Length of each subpacket */ + + /* Codec Context */ + enum codecs codec_type; + uint16_t block_align; + uint32_t nb_packets; + int frame_number; + uint16_t sample_rate; + uint16_t nb_channels; + uint32_t bit_rate; + uint16_t flags; + + /*codec extradata*/ + uint32_t extradata_size; + uint8_t codec_extradata[MAX_EXTRADATA_SIZE]; + +} RMContext; + +int real_parse_header(int fd, RMContext *rmctx); + +/* Get a (sub_packet_h*frames_per_packet) number of audio frames from a memory buffer */ +int rm_get_packet(uint8_t **src,RMContext *rmctx, RMPacket *pkt); + +#ifdef TEST + +int filesize(int fd); +void advance_buffer(uint8_t **buf, int val); + +/* Get a (sub_packet_h*frames_per_packet) number of audio frames from a file descriptor */ +void rm_get_packet_fd(int fd,RMContext *rmctx, RMPacket *pkt); + +#endif /* TEST */ + +#endif /* _RM_H */ diff --git a/lib/rbcodec/codecs/libspc/SOURCES b/lib/rbcodec/codecs/libspc/SOURCES new file mode 100644 index 0000000000..901232a6eb --- /dev/null +++ b/lib/rbcodec/codecs/libspc/SOURCES @@ -0,0 +1,4 @@ +spc_cpu.c +spc_dsp.c +spc_emu.c +spc_profiler.c diff --git a/lib/rbcodec/codecs/libspc/libspc.make b/lib/rbcodec/codecs/libspc/libspc.make new file mode 100644 index 0000000000..a005f7914a --- /dev/null +++ b/lib/rbcodec/codecs/libspc/libspc.make @@ -0,0 +1,18 @@ +# __________ __ ___. +# Open \______ \ ____ ____ | | _\_ |__ _______ ___ +# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / +# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < +# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ +# \/ \/ \/ \/ \/ +# $Id$ +# + +# libspc +SPCLIB := $(CODECDIR)/libspc.a +SPCLIB_SRC := $(call preprocess, $(RBCODECLIB_DIR)/codecs/libspc/SOURCES) +SPCLIB_OBJ := $(call c2obj, $(SPCLIB_SRC)) +OTHER_SRC += $(SPCLIB_SRC) + +$(SPCLIB): $(SPCLIB_OBJ) + $(SILENT)$(shell rm -f $@) + $(call PRINTS,AR $(@F))$(AR) rcs $@ $^ >/dev/null diff --git a/lib/rbcodec/codecs/libspc/spc_codec.h b/lib/rbcodec/codecs/libspc/spc_codec.h new file mode 100644 index 0000000000..7f6b6e2e9f --- /dev/null +++ b/lib/rbcodec/codecs/libspc/spc_codec.h @@ -0,0 +1,491 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2007-2008 Michael Sevakis (jhMikeS) + * Copyright (C) 2006-2007 Adam Gashlin (hcs) + * Copyright (C) 2004-2007 Shay Green (blargg) + * Copyright (C) 2002 Brad Martin + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +/* lovingly ripped off from Game_Music_Emu 0.5.2. http://www.slack.net/~ant/ */ +/* DSP Based on Brad Martin's OpenSPC DSP emulator */ +/* tag reading from sexyspc by John Brawn (John_Brawn@yahoo.com) and others */ + +#ifndef _SPC_CODEC_H_ +#define _SPC_CODEC_H_ + +/* rather than comment out asserts, just define NDEBUG */ +#ifndef NDEBUG +#define NDEBUG +#endif +#include + +/** Basic configuration options **/ + +#ifndef ARM_ARCH +#define ARM_ARCH 0 +#endif + +#define SPC_DUAL_CORE 1 + +#if !defined(SPC_DUAL_CORE) || NUM_CORES == 1 +#undef SPC_DUAL_CORE +#define SPC_DUAL_CORE 0 +#endif + +/* Only some targets are fast enough for gaussian and realtime BRR decode */ +#if CONFIG_CPU == S3C2440 || CONFIG_CPU == IMX31L || \ + CONFIG_CPU == AS3525 || CONFIG_CPU == AS3525v2 || \ + defined(CPU_S5L870X) || \ + (CONFIG_PLATFORM & PLATFORM_HOSTED) || MEMORYSIZE <= 2 + /* Don't cache BRR waves */ + #define SPC_BRRCACHE 0 + + /* Allow gaussian interpolation */ + #define SPC_NOINTERP 0 + + /* Allow echo processing */ + #define SPC_NOECHO 0 +#elif defined(CPU_COLDFIRE) + /* Cache BRR waves */ + #define SPC_BRRCACHE 1 + + /* Disable gaussian interpolation */ + #define SPC_NOINTERP 1 + + /* Allow echo processing */ + #define SPC_NOECHO 0 +#elif defined (CPU_PP) && SPC_DUAL_CORE + /* Cache BRR waves */ + #define SPC_BRRCACHE 1 + + /* Disable gaussian interpolation */ + #define SPC_NOINTERP 1 + + /* Allow echo processing */ + #define SPC_NOECHO 0 +#else + /* Cache BRR waves */ + #define SPC_BRRCACHE 1 + + /* Disable gaussian interpolation */ + #define SPC_NOINTERP 1 + + /* Disable echo processing */ + #define SPC_NOECHO 1 +#endif + +#if (CONFIG_CPU == MCF5250) +#define IBSS_ATTR_SPC IBSS_ATTR +#define ICODE_ATTR_SPC ICODE_ATTR +#define ICONST_ATTR_SPC ICONST_ATTR +/* Not enough IRAM available to move further data to it. */ +#define IBSS_ATTR_SPC_LARGE_IRAM + +#elif (CONFIG_CPU == PP5020) +/* spc is slower on PP5020 when moving data to IRAM. */ +#define IBSS_ATTR_SPC +#define ICODE_ATTR_SPC +#define ICONST_ATTR_SPC +/* Not enough IRAM available to move further data to it. */ +#define IBSS_ATTR_SPC_LARGE_IRAM + +#elif (CONFIG_CPU == PP5022) || (CONFIG_CPU == PP5024) +#define IBSS_ATTR_SPC IBSS_ATTR +#define ICODE_ATTR_SPC ICODE_ATTR +#define ICONST_ATTR_SPC ICONST_ATTR +/* Not enough IRAM available to move further data to it. */ +#define IBSS_ATTR_SPC_LARGE_IRAM + +#elif defined(CPU_S5L870X) +#define IBSS_ATTR_SPC IBSS_ATTR +#define ICODE_ATTR_SPC ICODE_ATTR +#define ICONST_ATTR_SPC ICONST_ATTR +/* Very large IRAM. Move even more data to it. */ +#define IBSS_ATTR_SPC_LARGE_IRAM IBSS_ATTR + +#else +#define IBSS_ATTR_SPC IBSS_ATTR +#define ICODE_ATTR_SPC ICODE_ATTR +#define ICONST_ATTR_SPC ICONST_ATTR +/* Not enough IRAM available to move further data to it. */ +#define IBSS_ATTR_SPC_LARGE_IRAM +#endif + +#if SPC_DUAL_CORE + #undef SHAREDBSS_ATTR + #define SHAREDBSS_ATTR __attribute__ ((section(".ibss"))) + #undef SHAREDDATA_ATTR + #define SHAREDDATA_ATTR __attribute__((section(".idata"))) +#endif + +/* Samples per channel per iteration */ +#if defined(CPU_PP) && NUM_CORES == 1 +#define WAV_CHUNK_SIZE 2048 +#else +#define WAV_CHUNK_SIZE 1024 +#endif + +/**************** Little-endian handling ****************/ + +static inline unsigned get_le16( void const* p ) +{ + return ((unsigned char const*) p) [1] * 0x100u + + ((unsigned char const*) p) [0]; +} + +static inline int get_le16s( void const* p ) +{ + return ((signed char const*) p) [1] * 0x100 + + ((unsigned char const*) p) [0]; +} + +static inline void set_le16( void* p, unsigned n ) +{ + ((unsigned char*) p) [1] = (unsigned char) (n >> 8); + ((unsigned char*) p) [0] = (unsigned char) n; +} + +#define GET_LE16( addr ) get_le16( addr ) +#define GET_LE16A( addr ) get_le16( addr ) +#define SET_LE16( addr, data ) set_le16( addr, data ) +#define INT16A( addr ) (*(uint16_t*) (addr)) +#define INT16SA( addr ) (*(int16_t*) (addr)) + +#ifdef ROCKBOX_LITTLE_ENDIAN + #define GET_LE16SA( addr ) (*( int16_t*) (addr)) + #define SET_LE16A( addr, data ) (void) (*(uint16_t*) (addr) = (data)) +#else + #define GET_LE16SA( addr ) get_le16s( addr ) + #define SET_LE16A( addr, data ) set_le16 ( addr, data ) +#endif + +struct Spc_Emu; +#define THIS struct Spc_Emu* const this + +/* The CPU portion (shock!) */ + +struct cpu_regs_t +{ + long pc; /* more than 16 bits to allow overflow detection */ + uint8_t a; + uint8_t x; + uint8_t y; + uint8_t status; + uint8_t sp; +}; + +struct src_dir +{ + uint16_t start; + uint16_t loop; +}; + +struct cpu_ram_t +{ + union { + uint8_t padding1 [0x100]; + uint16_t align; + } padding1 [1]; + union { + uint8_t ram [0x10000]; + struct src_dir sd [0x10000/sizeof(struct src_dir)]; + }; + uint8_t padding2 [0x100]; +}; + +#undef RAM +#define RAM ram.ram +extern struct cpu_ram_t ram; + +long CPU_run( THIS, long start_time ) ICODE_ATTR_SPC; +void CPU_Init( THIS ); + +/* The DSP portion (awe!) */ +enum { VOICE_COUNT = 8 }; +enum { REGISTER_COUNT = 128 }; + +struct raw_voice_t +{ + int8_t volume [2]; + uint8_t rate [2]; + uint8_t waveform; + uint8_t adsr [2]; /* envelope rates for attack, decay, and sustain */ + uint8_t gain; /* envelope gain (if not using ADSR) */ + int8_t envx; /* current envelope level */ + int8_t outx; /* current sample */ + int8_t unused [6]; +}; + +struct globals_t +{ + int8_t unused1 [12]; + int8_t volume_0; /* 0C Main Volume Left (-.7) */ + int8_t echo_feedback; /* 0D Echo Feedback (-.7) */ + int8_t unused2 [14]; + int8_t volume_1; /* 1C Main Volume Right (-.7) */ + int8_t unused3 [15]; + int8_t echo_volume_0; /* 2C Echo Volume Left (-.7) */ + uint8_t pitch_mods; /* 2D Pitch Modulation on/off for each voice */ + int8_t unused4 [14]; + int8_t echo_volume_1; /* 3C Echo Volume Right (-.7) */ + uint8_t noise_enables; /* 3D Noise output on/off for each voice */ + int8_t unused5 [14]; + uint8_t key_ons; /* 4C Key On for each voice */ + uint8_t echo_ons; /* 4D Echo on/off for each voice */ + int8_t unused6 [14]; + uint8_t key_offs; /* 5C key off for each voice + (instantiates release mode) */ + uint8_t wave_page; /* 5D source directory (wave table offsets) */ + int8_t unused7 [14]; + uint8_t flags; /* 6C flags and noise freq */ + uint8_t echo_page; /* 6D */ + int8_t unused8 [14]; + uint8_t wave_ended; /* 7C */ + uint8_t echo_delay; /* 7D ms >> 4 */ + char unused9 [2]; +}; + +enum state_t +{ /* -1, 0, +1 allows more efficient if statements */ + state_decay = -1, + state_sustain = 0, + state_attack = +1, + state_release = 2 +}; + +struct cache_entry_t +{ + int16_t const* samples; + unsigned end; /* past-the-end position */ + unsigned loop; /* number of samples in loop */ + unsigned start_addr; +}; + +enum { BRR_BLOCK_SIZE = 16 }; +enum { BRR_CACHE_SIZE = 0x20000 + 32} ; + +struct voice_t +{ +#if SPC_BRRCACHE + int16_t const* samples; + long wave_end; + int wave_loop; +#else + int16_t samples [3 + BRR_BLOCK_SIZE + 1]; + int block_header; /* header byte from current block */ +#endif + uint8_t const* addr; + short volume [2]; + long position;/* position in samples buffer, with 12-bit fraction */ + short envx; + short env_mode; + short env_timer; + short key_on_delay; +}; + +#if SPC_BRRCACHE +/* a little extra for samples that go past end */ +extern int16_t BRRcache [BRR_CACHE_SIZE]; +#endif + +enum { FIR_BUF_HALF = 8 }; + +#if defined(CPU_COLDFIRE) +/* global because of the large aligment requirement for hardware masking - + * L-R interleaved 16-bit samples for easy loading and mac.w use. + */ +enum +{ + FIR_BUF_CNT = FIR_BUF_HALF, + FIR_BUF_SIZE = FIR_BUF_CNT * sizeof ( int32_t ), + FIR_BUF_ALIGN = FIR_BUF_SIZE * 2, + FIR_BUF_MASK = ~((FIR_BUF_ALIGN / 2) | (sizeof ( int32_t ) - 1)) +}; +#elif defined (CPU_ARM) +#if ARM_ARCH >= 6 +enum +{ + FIR_BUF_CNT = FIR_BUF_HALF * 2, + FIR_BUF_SIZE = FIR_BUF_CNT * sizeof ( int32_t ), + FIR_BUF_ALIGN = FIR_BUF_SIZE, + FIR_BUF_MASK = ~((FIR_BUF_ALIGN / 2) | (sizeof ( int32_t ) - 1)) +}; +#else +enum +{ + FIR_BUF_CNT = FIR_BUF_HALF * 2 * 2, + FIR_BUF_SIZE = FIR_BUF_CNT * sizeof ( int32_t ), + FIR_BUF_ALIGN = FIR_BUF_SIZE, + FIR_BUF_MASK = ~((FIR_BUF_ALIGN / 2) | (sizeof ( int32_t ) * 2 - 1)) +}; +#endif /* ARM_ARCH */ +#endif /* CPU_* */ + +struct Spc_Dsp +{ + union + { + struct raw_voice_t voice [VOICE_COUNT]; + uint8_t reg [REGISTER_COUNT]; + struct globals_t g; + int16_t align; + } r; + + unsigned echo_pos; + int keys_down; + int noise_count; + uint16_t noise; /* also read as int16_t */ + +#if defined(CPU_COLDFIRE) + /* FIR history is interleaved. Hardware handles wrapping by mask. + * |LR|LR|LR|LR|LR|LR|LR|LR| */ + int32_t *fir_ptr; + /* wrapped address just behind current position - + allows mac.w to increment and mask fir_ptr */ + int32_t *last_fir_ptr; + /* copy of echo FIR constants as int16_t for use with mac.w */ + int16_t fir_coeff [VOICE_COUNT]; +#elif defined (CPU_ARM) + /* fir_buf [i + 8] == fir_buf [i], to avoid wrap checking in FIR code */ + int32_t *fir_ptr; +#if ARM_ARCH >= 6 + /* FIR history is interleaved with guard to eliminate wrap checking + * when convolving. + * |LR|LR|LR|LR|LR|LR|LR|LR|--|--|--|--|--|--|--|--| */ + /* copy of echo FIR constants as int16_t, loaded as int32 for + * halfword, packed multiples */ + int16_t fir_coeff [VOICE_COUNT]; +#else + /* FIR history is interleaved with guard to eliminate wrap checking + * when convolving. + * |LL|RR|LL|RR|LL|RR|LL|RR|LL|RR|LL|RR|LL|RR|LL|RR|... + * |--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--| */ + /* copy of echo FIR constants as int32_t, for faster access */ + int32_t fir_coeff [VOICE_COUNT]; +#endif /* ARM_ARCH */ +#else /* Unoptimized CPU */ + /* fir_buf [i + 8] == fir_buf [i], to avoid wrap checking in FIR code */ + int fir_pos; /* (0 to 7) */ + int fir_buf [FIR_BUF_HALF * 2] [2]; + /* copy of echo FIR constants as int, for faster access */ + int fir_coeff [VOICE_COUNT]; +#endif + + struct voice_t voice_state [VOICE_COUNT]; + +#if SPC_BRRCACHE + uint8_t oldsize; + struct cache_entry_t wave_entry [256]; + struct cache_entry_t wave_entry_old [256]; +#endif +}; + +void DSP_run_( struct Spc_Dsp* this, long count, int32_t* out_buf ) ICODE_ATTR_SPC; +void DSP_reset( struct Spc_Dsp* this ); + +static inline void DSP_run( struct Spc_Dsp* this, long count, int32_t* out ) +{ + /* Should we just fill the buffer with silence? Flags won't be cleared */ + /* during this run so it seems it should keep resetting every sample. */ + if ( this->r.g.flags & 0x80 ) + DSP_reset( this ); + + DSP_run_( this, count, out ); +} + +/**************** SPC emulator ****************/ +/* 1.024 MHz clock / 32000 samples per second */ +enum { CLOCKS_PER_SAMPLE = 32 }; + +enum { EXTRA_CLOCKS = CLOCKS_PER_SAMPLE / 2 }; + +/* using this disables timer (since this will always be in the future) */ +enum { TIMER_DISABLED_TIME = 127 }; + +enum { ROM_SIZE = 64 }; +enum { ROM_ADDR = 0xFFC0 }; + +enum { TIMER_COUNT = 3 }; + +struct Timer +{ + long next_tick; + int period; + int count; + int shift; + int enabled; + int counter; +}; + +struct Spc_Emu +{ + uint8_t cycle_table [0x100]; + struct cpu_regs_t r; + + int32_t* sample_buf; + long next_dsp; + int rom_enabled; + int extra_cycles; + + struct Timer timer [TIMER_COUNT]; + + /* large objects at end */ + struct Spc_Dsp dsp; + uint8_t extra_ram [ROM_SIZE]; + uint8_t boot_rom [ROM_SIZE]; +}; + +enum { SPC_FILE_SIZE = 0x10180 }; + +struct spc_file_t +{ + char signature [27]; + char unused [10]; + uint8_t pc [2]; + uint8_t a; + uint8_t x; + uint8_t y; + uint8_t status; + uint8_t sp; + char unused2 [212]; + uint8_t ram [0x10000]; + uint8_t dsp [128]; + uint8_t ipl_rom [128]; +}; + +void SPC_Init( THIS ); + +int SPC_load_spc( THIS, const void* data, long size ); + +/**************** DSP interaction ****************/ +void DSP_write( struct Spc_Dsp* this, int i, int data ) ICODE_ATTR_SPC; + +static inline int DSP_read( struct Spc_Dsp* this, int i ) +{ + assert( (unsigned) i < REGISTER_COUNT ); + return this->r.reg [i]; +} + +int SPC_read( THIS, unsigned addr, long const time ) ICODE_ATTR_SPC; +void SPC_write( THIS, unsigned addr, int data, long const time ) ICODE_ATTR_SPC; + +/**************** Sample generation ****************/ +int SPC_play( THIS, long count, int32_t* out ) ICODE_ATTR_SPC; + +#endif /* _SPC_CODEC_H_ */ diff --git a/lib/rbcodec/codecs/libspc/spc_cpu.c b/lib/rbcodec/codecs/libspc/spc_cpu.c new file mode 100644 index 0000000000..23dcc257de --- /dev/null +++ b/lib/rbcodec/codecs/libspc/spc_cpu.c @@ -0,0 +1,1049 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2006-2007 Adam Gashlin (hcs) + * Copyright (C) 2004-2007 Shay Green (blargg) + * Copyright (C) 2002 Brad Martin + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +/* The CPU portion (shock!) */ +#include "codeclib.h" +#include "spc_codec.h" +#include "spc_profiler.h" + +#undef check +#define check assert + +#define READ( addr ) (SPC_read( this, addr, spc_time_ )) +#define WRITE( addr, value ) (SPC_write( this, addr, value, spc_time_ )) + +#define READ_DP( addr ) READ( (addr) + dp ) +#define WRITE_DP( addr, value ) WRITE( (addr) + dp, value ) + +#define READ_PROG16( addr ) GET_LE16( RAM + (addr) ) + +#define READ_PC( pc ) (*(pc)) +#define READ_PC16( pc ) GET_LE16( pc ) + +#define SET_PC( n ) (pc = RAM + (n)) +#define GET_PC() (pc - RAM) + +static unsigned char const cycle_table [0x100] = { + 2,8,4,5,3,4,3,6,2,6,5,4,5,4,6,8, /* 0 */ + 2,8,4,5,4,5,5,6,5,5,6,5,2,2,4,6, /* 1 */ + 2,8,4,5,3,4,3,6,2,6,5,4,5,4,5,4, /* 2 */ + 2,8,4,5,4,5,5,6,5,5,6,5,2,2,3,8, /* 3 */ + 2,8,4,5,3,4,3,6,2,6,4,4,5,4,6,6, /* 4 */ + 2,8,4,5,4,5,5,6,5,5,4,5,2,2,4,3, /* 5 */ + 2,8,4,5,3,4,3,6,2,6,4,4,5,4,5,5, /* 6 */ + 2,8,4,5,4,5,5,6,5,5,5,5,2,2,3,6, /* 7 */ + 2,8,4,5,3,4,3,6,2,6,5,4,5,2,4,5, /* 8 */ + 2,8,4,5,4,5,5,6,5,5,5,5,2,2,12,5,/* 9 */ + 3,8,4,5,3,4,3,6,2,6,4,4,5,2,4,4, /* A */ + 2,8,4,5,4,5,5,6,5,5,5,5,2,2,3,4, /* B */ + 3,8,4,5,4,5,4,7,2,5,6,4,5,2,4,9, /* C */ + 2,8,4,5,5,6,6,7,4,5,4,5,2,2,6,3, /* D */ + 2,8,4,5,3,4,3,6,2,4,5,3,4,3,4,3, /* E */ + 2,8,4,5,4,5,5,6,3,4,5,4,2,2,4,3 /* F */ +}; + +#define MEM_BIT() CPU_mem_bit( this, pc, spc_time_ ) + +static unsigned CPU_mem_bit( THIS, uint8_t const* pc, long const spc_time_ ) + ICODE_ATTR_SPC; + +static unsigned CPU_mem_bit( THIS, uint8_t const* pc, long const spc_time_ ) +{ + unsigned addr = READ_PC16( pc ); + unsigned t = READ( addr & 0x1FFF ) >> (addr >> 13); + return (t << 8) & 0x100; +} + +/* status flags */ +enum { st_n = 0x80 }; +enum { st_v = 0x40 }; +enum { st_p = 0x20 }; +enum { st_b = 0x10 }; +enum { st_h = 0x08 }; +enum { st_i = 0x04 }; +enum { st_z = 0x02 }; +enum { st_c = 0x01 }; + +#define IS_NEG (nz & 0x880) + +#define CALC_STATUS( out )\ +{\ + out = status & ~(st_n | st_z | st_c);\ + out |= (c >> 8) & st_c;\ + out |= (dp >> 3) & st_p;\ + if ( IS_NEG ) out |= st_n;\ + if ( !(nz & 0xFF) ) out |= st_z;\ +} + +#define SET_STATUS( in )\ +{\ + status = in & ~(st_n | st_z | st_c | st_p);\ + c = in << 8;\ + nz = ((in << 4) & 0x800) | (~in & st_z);\ + dp = (in << 3) & 0x100;\ +} + + +/* stack */ +#define PUSH( v ) (*--sp = (uint8_t) (v)) +#define PUSH16( v ) (sp -= 2, SET_LE16( sp, v )) +#define POP() (*sp++) +#define SET_SP( v ) (sp = RAM + 0x101 + (v)) +#define GET_SP() (sp - 0x101 - RAM) + +long CPU_run( THIS, long start_time ) +{ +#if 0 + ENTER_TIMER(cpu); +#endif + + register long spc_time_ = start_time; + +#ifdef CPU_ARM + uint8_t* const ram_ = ram.ram; + #undef RAM + #define RAM ram_ +#endif + + int a = this->r.a; + int x = this->r.x; + int y = this->r.y; + + uint8_t const* pc; + SET_PC( this->r.pc ); + + uint8_t* sp; + SET_SP( this->r.sp ); + + int status; + int c; + int nz; + unsigned dp; + { + int temp = this->r.status; + SET_STATUS( temp ); + } + + goto loop; + + /* main loop */ +cbranch_taken_loop: + pc += *(int8_t const*) pc; + spc_time_ += 2; +inc_pc_loop: + pc++; +loop: + check( (unsigned) GET_PC() < 0x10000 ); + check( (unsigned) GET_SP() < 0x100 ); + check( (unsigned) a < 0x100 ); + check( (unsigned) x < 0x100 ); + check( (unsigned) y < 0x100 ); + + unsigned opcode = *pc; + int cycles = this->cycle_table [opcode]; + unsigned data = *++pc; + if ( (spc_time_ += cycles) > 0 ) + goto out_of_time; + switch ( opcode ) + { + +/* Common instructions */ + +#define BRANCH( cond )\ +{\ + pc++;\ + int offset = (int8_t) data;\ + if ( cond ) {\ + pc += offset;\ + spc_time_ += 2;\ + }\ + goto loop;\ +} + + case 0xF0: /* BEQ (most common) */ + BRANCH( !(uint8_t) nz ) + + case 0xD0: /* BNE */ + BRANCH( (uint8_t) nz ) + + case 0x3F: /* CALL */ + PUSH16( GET_PC() + 2 ); + SET_PC( READ_PC16( pc ) ); + goto loop; + + case 0x6F: /* RET */ + SET_PC( POP() ); + pc += POP() * 0x100; + goto loop; + +#define CASE( n ) case n: + +/* Define common address modes based on opcode for immediate mode. Execution + ends with data set to the address of the operand. */ +#define ADDR_MODES( op )\ + CASE( op - 0x02 ) /* (X) */\ + data = x + dp;\ + pc--;\ + goto end_##op;\ + CASE( op + 0x0F ) /* (dp)+Y */\ + data = READ_PROG16( data + dp ) + y;\ + goto end_##op;\ + CASE( op - 0x01 ) /* (dp+X) */\ + data = READ_PROG16( ((uint8_t) (data + x)) + dp );\ + goto end_##op;\ + CASE( op + 0x0E ) /* abs+Y */\ + data += y;\ + goto abs_##op;\ + CASE( op + 0x0D ) /* abs+X */\ + data += x;\ + CASE( op - 0x03 ) /* abs */\ + abs_##op:\ + data += 0x100 * READ_PC( ++pc );\ + goto end_##op;\ + CASE( op + 0x0C ) /* dp+X */\ + data = (uint8_t) (data + x);\ + CASE( op - 0x04 ) /* dp */\ + data += dp;\ + end_##op: + +/* 1. 8-bit Data Transmission Commands. Group I */ + + ADDR_MODES( 0xE8 ) /* MOV A,addr */ + /*case 0xE4:*/ /* MOV a,dp (most common) */ + mov_a_addr: + a = nz = READ( data ); + goto inc_pc_loop; + case 0xBF: /* MOV A,(X)+ */ + data = x + dp; + x = (uint8_t) (x + 1); + pc--; + goto mov_a_addr; + + case 0xE8: /* MOV A,imm */ + a = data; + nz = data; + goto inc_pc_loop; + + case 0xF9: /* MOV X,dp+Y */ + data = (uint8_t) (data + y); + case 0xF8: /* MOV X,dp */ + data += dp; + goto mov_x_addr; + case 0xE9: /* MOV X,abs */ + data = READ_PC16( pc ); + pc++; + mov_x_addr: + data = READ( data ); + case 0xCD: /* MOV X,imm */ + x = data; + nz = data; + goto inc_pc_loop; + + case 0xFB: /* MOV Y,dp+X */ + data = (uint8_t) (data + x); + case 0xEB: /* MOV Y,dp */ + data += dp; + goto mov_y_addr; + case 0xEC: /* MOV Y,abs */ + data = READ_PC16( pc ); + pc++; + mov_y_addr: + data = READ( data ); + case 0x8D: /* MOV Y,imm */ + y = data; + nz = data; + goto inc_pc_loop; + +/* 2. 8-BIT DATA TRANSMISSION COMMANDS, GROUP 2 */ + + ADDR_MODES( 0xC8 ) /* MOV addr,A */ + WRITE( data, a ); + goto inc_pc_loop; + + { + int temp; + case 0xCC: /* MOV abs,Y */ + temp = y; + goto mov_abs_temp; + case 0xC9: /* MOV abs,X */ + temp = x; + mov_abs_temp: + WRITE( READ_PC16( pc ), temp ); + pc += 2; + goto loop; + } + + case 0xD9: /* MOV dp+Y,X */ + data = (uint8_t) (data + y); + case 0xD8: /* MOV dp,X */ + WRITE( data + dp, x ); + goto inc_pc_loop; + + case 0xDB: /* MOV dp+X,Y */ + data = (uint8_t) (data + x); + case 0xCB: /* MOV dp,Y */ + WRITE( data + dp, y ); + goto inc_pc_loop; + + case 0xFA: /* MOV dp,dp */ + data = READ( data + dp ); + case 0x8F: /* MOV dp,#imm */ + WRITE_DP( READ_PC( ++pc ), data ); + goto inc_pc_loop; + +/* 3. 8-BIT DATA TRANSMISSIN COMMANDS, GROUP 3. */ + + case 0x7D: /* MOV A,X */ + a = x; + nz = x; + goto loop; + + case 0xDD: /* MOV A,Y */ + a = y; + nz = y; + goto loop; + + case 0x5D: /* MOV X,A */ + x = a; + nz = a; + goto loop; + + case 0xFD: /* MOV Y,A */ + y = a; + nz = a; + goto loop; + + case 0x9D: /* MOV X,SP */ + x = nz = GET_SP(); + goto loop; + + case 0xBD: /* MOV SP,X */ + SET_SP( x ); + goto loop; + + /*case 0xC6:*/ /* MOV (X),A (handled by MOV addr,A in group 2) */ + + case 0xAF: /* MOV (X)+,A */ + WRITE_DP( x, a ); + x++; + goto loop; + +/* 5. 8-BIT LOGIC OPERATION COMMANDS */ + +#define LOGICAL_OP( op, func )\ + ADDR_MODES( op ) /* addr */\ + data = READ( data );\ + case op: /* imm */\ + nz = a func##= data;\ + goto inc_pc_loop;\ + { unsigned addr;\ + case op + 0x11: /* X,Y */\ + data = READ_DP( y );\ + addr = x + dp;\ + pc--;\ + goto addr_##op;\ + case op + 0x01: /* dp,dp */\ + data = READ_DP( data );\ + case op + 0x10: /*dp,imm*/\ + addr = READ_PC( ++pc ) + dp;\ + addr_##op:\ + nz = data func READ( addr );\ + WRITE( addr, nz );\ + goto inc_pc_loop;\ + } + + LOGICAL_OP( 0x28, & ); /* AND */ + + LOGICAL_OP( 0x08, | ); /* OR */ + + LOGICAL_OP( 0x48, ^ ); /* EOR */ + +/* 4. 8-BIT ARITHMETIC OPERATION COMMANDS */ + + ADDR_MODES( 0x68 ) /* CMP addr */ + data = READ( data ); + case 0x68: /* CMP imm */ + nz = a - data; + c = ~nz; + nz &= 0xFF; + goto inc_pc_loop; + + case 0x79: /* CMP (X),(Y) */ + data = READ_DP( x ); + nz = data - READ_DP( y ); + c = ~nz; + nz &= 0xFF; + goto loop; + + case 0x69: /* CMP (dp),(dp) */ + data = READ_DP( data ); + case 0x78: /* CMP dp,imm */ + nz = READ_DP( READ_PC( ++pc ) ) - data; + c = ~nz; + nz &= 0xFF; + goto inc_pc_loop; + + case 0x3E: /* CMP X,dp */ + data += dp; + goto cmp_x_addr; + case 0x1E: /* CMP X,abs */ + data = READ_PC16( pc ); + pc++; + cmp_x_addr: + data = READ( data ); + case 0xC8: /* CMP X,imm */ + nz = x - data; + c = ~nz; + nz &= 0xFF; + goto inc_pc_loop; + + case 0x7E: /* CMP Y,dp */ + data += dp; + goto cmp_y_addr; + case 0x5E: /* CMP Y,abs */ + data = READ_PC16( pc ); + pc++; + cmp_y_addr: + data = READ( data ); + case 0xAD: /* CMP Y,imm */ + nz = y - data; + c = ~nz; + nz &= 0xFF; + goto inc_pc_loop; + + { + int addr; + case 0xB9: /* SBC (x),(y) */ + case 0x99: /* ADC (x),(y) */ + pc--; /* compensate for inc later */ + data = READ_DP( x ); + addr = y + dp; + goto adc_addr; + case 0xA9: /* SBC dp,dp */ + case 0x89: /* ADC dp,dp */ + data = READ_DP( data ); + case 0xB8: /* SBC dp,imm */ + case 0x98: /* ADC dp,imm */ + addr = READ_PC( ++pc ) + dp; + adc_addr: + nz = READ( addr ); + goto adc_data; + +/* catch ADC and SBC together, then decode later based on operand */ +#undef CASE +#define CASE( n ) case n: case (n) + 0x20: + ADDR_MODES( 0x88 ) /* ADC/SBC addr */ + data = READ( data ); + case 0xA8: /* SBC imm */ + case 0x88: /* ADC imm */ + addr = -1; /* A */ + nz = a; + adc_data: { + if ( opcode & 0x20 ) + data ^= 0xFF; /* SBC */ + int carry = (c >> 8) & 1; + int ov = (nz ^ 0x80) + carry + (int8_t) data; /* sign-extend */ + int hc = (nz & 15) + carry; + c = nz += data + carry; + hc = (nz & 15) - hc; + status = (status & ~(st_v | st_h)) | ((ov >> 2) & st_v) | + ((hc >> 1) & st_h); + if ( addr < 0 ) { + a = (uint8_t) nz; + goto inc_pc_loop; + } + WRITE( addr, (uint8_t) nz ); + goto inc_pc_loop; + } + + } + +/* 6. ADDITION & SUBTRACTION COMMANDS */ + +#define INC_DEC_REG( reg, n )\ + nz = reg + n;\ + reg = (uint8_t) nz;\ + goto loop; + + case 0xBC: INC_DEC_REG( a, 1 ) /* INC A */ + case 0x3D: INC_DEC_REG( x, 1 ) /* INC X */ + case 0xFC: INC_DEC_REG( y, 1 ) /* INC Y */ + + case 0x9C: INC_DEC_REG( a, -1 ) /* DEC A */ + case 0x1D: INC_DEC_REG( x, -1 ) /* DEC X */ + case 0xDC: INC_DEC_REG( y, -1 ) /* DEC Y */ + + case 0x9B: /* DEC dp+X */ + case 0xBB: /* INC dp+X */ + data = (uint8_t) (data + x); + case 0x8B: /* DEC dp */ + case 0xAB: /* INC dp */ + data += dp; + goto inc_abs; + case 0x8C: /* DEC abs */ + case 0xAC: /* INC abs */ + data = READ_PC16( pc ); + pc++; + inc_abs: + nz = ((opcode >> 4) & 2) - 1; + nz += READ( data ); + WRITE( data, (uint8_t) nz ); + goto inc_pc_loop; + +/* 7. SHIFT, ROTATION COMMANDS */ + + case 0x5C: /* LSR A */ + c = 0; + case 0x7C:{/* ROR A */ + nz = ((c >> 1) & 0x80) | (a >> 1); + c = a << 8; + a = nz; + goto loop; + } + + case 0x1C: /* ASL A */ + c = 0; + case 0x3C:{/* ROL A */ + int temp = (c >> 8) & 1; + c = a << 1; + nz = c | temp; + a = (uint8_t) nz; + goto loop; + } + + case 0x0B: /* ASL dp */ + c = 0; + data += dp; + goto rol_mem; + case 0x1B: /* ASL dp+X */ + c = 0; + case 0x3B: /* ROL dp+X */ + data = (uint8_t) (data + x); + case 0x2B: /* ROL dp */ + data += dp; + goto rol_mem; + case 0x0C: /* ASL abs */ + c = 0; + case 0x2C: /* ROL abs */ + data = READ_PC16( pc ); + pc++; + rol_mem: + nz = (c >> 8) & 1; + nz |= (c = READ( data ) << 1); + WRITE( data, (uint8_t) nz ); + goto inc_pc_loop; + + case 0x4B: /* LSR dp */ + c = 0; + data += dp; + goto ror_mem; + case 0x5B: /* LSR dp+X */ + c = 0; + case 0x7B: /* ROR dp+X */ + data = (uint8_t) (data + x); + case 0x6B: /* ROR dp */ + data += dp; + goto ror_mem; + case 0x4C: /* LSR abs */ + c = 0; + case 0x6C: /* ROR abs */ + data = READ_PC16( pc ); + pc++; + ror_mem: { + int temp = READ( data ); + nz = ((c >> 1) & 0x80) | (temp >> 1); + c = temp << 8; + WRITE( data, nz ); + goto inc_pc_loop; + } + + case 0x9F: /* XCN */ + nz = a = (a >> 4) | (uint8_t) (a << 4); + goto loop; + +/* 8. 16-BIT TRANSMISION COMMANDS */ + + case 0xBA: /* MOVW YA,dp */ + a = READ_DP( data ); + nz = (a & 0x7F) | (a >> 1); + y = READ_DP( (uint8_t) (data + 1) ); + nz |= y; + goto inc_pc_loop; + + case 0xDA: /* MOVW dp,YA */ + WRITE_DP( data, a ); + WRITE_DP( (uint8_t) (data + 1), y ); + goto inc_pc_loop; + +/* 9. 16-BIT OPERATION COMMANDS */ + + case 0x3A: /* INCW dp */ + case 0x1A:{/* DECW dp */ + data += dp; + + /* low byte */ + int temp = READ( data ); + temp += ((opcode >> 4) & 2) - 1; /* +1 for INCW, -1 for DECW */ + nz = ((temp >> 1) | temp) & 0x7F; + WRITE( data, (uint8_t) temp ); + + /* high byte */ + data = ((uint8_t) (data + 1)) + dp; + temp >>= 8; + temp = (uint8_t) (temp + READ( data )); + nz |= temp; + WRITE( data, temp ); + + goto inc_pc_loop; + } + + case 0x9A: /* SUBW YA,dp */ + case 0x7A: /* ADDW YA,dp */ + { + /* read 16-bit addend */ + int temp = READ_DP( data ); + int sign = READ_DP( (uint8_t) (data + 1) ); + temp += 0x100 * sign; + status &= ~(st_v | st_h); + + /* to do: fix half-carry for SUBW (it's probably wrong) */ + + /* for SUBW, negate and truncate to 16 bits */ + if ( opcode & 0x80 ) { + temp = (temp ^ 0xFFFF) + 1; + sign = temp >> 8; + } + + /* add low byte (A) */ + temp += a; + a = (uint8_t) temp; + nz = (temp | (temp >> 1)) & 0x7F; + + /* add high byte (Y) */ + temp >>= 8; + c = y + temp; + nz = (nz | c) & 0xFF; + + /* half-carry (temporary avoids CodeWarrior optimizer bug) */ + unsigned hc = (c & 15) - (y & 15); + status |= (hc >> 4) & st_h; + + /* overflow if sign of YA changed when previous sign + and addend sign were same */ + status |= (((c ^ y) & ~(y ^ sign)) >> 1) & st_v; + + y = (uint8_t) c; + + goto inc_pc_loop; + } + + case 0x5A: { /* CMPW YA,dp */ + int temp = a - READ_DP( data ); + nz = ((temp >> 1) | temp) & 0x7F; + temp = y + (temp >> 8); + temp -= READ_DP( (uint8_t) (data + 1) ); + nz |= temp; + c = ~temp; + nz &= 0xFF; + goto inc_pc_loop; + } + +/* 10. MULTIPLICATION & DIVISON COMMANDS */ + + case 0xCF: { /* MUL YA */ + unsigned temp = y * a; + a = (uint8_t) temp; + nz = ((temp >> 1) | temp) & 0x7F; + y = temp >> 8; + nz |= y; + goto loop; + } + + case 0x9E: /* DIV YA,X */ + { + /* behavior based on SPC CPU tests */ + + status &= ~(st_h | st_v); + + if ( (y & 15) >= (x & 15) ) + status |= st_h; + + if ( y >= x ) + status |= st_v; + + unsigned ya = y * 0x100 + a; + if ( y < x * 2 ) + { + a = ya / x; + y = ya - a * x; + } + else + { + a = 255 - (ya - x * 0x200) / (256 - x); + y = x + (ya - x * 0x200) % (256 - x); + } + + nz = (uint8_t) a; + a = (uint8_t) a; + + goto loop; + } + +/* 11. DECIMAL COMPENSATION COMMANDS */ + + /* seem unused */ + /* case 0xDF: */ /* DAA */ + /* case 0xBE: */ /* DAS */ + +/* 12. BRANCHING COMMANDS */ + + case 0x2F: /* BRA rel */ + pc += (int8_t) data; + goto inc_pc_loop; + + case 0x30: /* BMI */ + BRANCH( IS_NEG ) + + case 0x10: /* BPL */ + BRANCH( !IS_NEG ) + + case 0xB0: /* BCS */ + BRANCH( c & 0x100 ) + + case 0x90: /* BCC */ + BRANCH( !(c & 0x100) ) + + case 0x70: /* BVS */ + BRANCH( status & st_v ) + + case 0x50: /* BVC */ + BRANCH( !(status & st_v) ) + + case 0x03: /* BBS dp.bit,rel */ + case 0x23: + case 0x43: + case 0x63: + case 0x83: + case 0xA3: + case 0xC3: + case 0xE3: + pc++; + if ( (READ_DP( data ) >> (opcode >> 5)) & 1 ) + goto cbranch_taken_loop; + goto inc_pc_loop; + + case 0x13: /* BBC dp.bit,rel */ + case 0x33: + case 0x53: + case 0x73: + case 0x93: + case 0xB3: + case 0xD3: + case 0xF3: + pc++; + if ( !((READ_DP( data ) >> (opcode >> 5)) & 1) ) + goto cbranch_taken_loop; + goto inc_pc_loop; + + case 0xDE: /* CBNE dp+X,rel */ + data = (uint8_t) (data + x); + /* fall through */ + case 0x2E: /* CBNE dp,rel */ + pc++; + if ( READ_DP( data ) != a ) + goto cbranch_taken_loop; + goto inc_pc_loop; + + case 0xFE: /* DBNZ Y,rel */ + y = (uint8_t) (y - 1); + BRANCH( y ) + + case 0x6E: { /* DBNZ dp,rel */ + pc++; + unsigned temp = READ_DP( data ) - 1; + WRITE_DP( (uint8_t) data, (uint8_t) temp ); + if ( temp ) + goto cbranch_taken_loop; + goto inc_pc_loop; + } + + case 0x1F: /* JMP (abs+X) */ + SET_PC( READ_PC16( pc ) + x ); + /* fall through */ + case 0x5F: /* JMP abs */ + SET_PC( READ_PC16( pc ) ); + goto loop; + +/* 13. SUB-ROUTINE CALL RETURN COMMANDS */ + + case 0x0F:{/* BRK */ + check( 0 ); /* untested */ + PUSH16( GET_PC() + 1 ); + SET_PC( READ_PROG16( 0xFFDE ) ); /* vector address verified */ + int temp; + CALC_STATUS( temp ); + PUSH( temp ); + status = (status | st_b) & ~st_i; + goto loop; + } + + case 0x4F: /* PCALL offset */ + PUSH16( GET_PC() + 1 ); + SET_PC( 0xFF00 + data ); + goto loop; + + case 0x01: /* TCALL n */ + case 0x11: + case 0x21: + case 0x31: + case 0x41: + case 0x51: + case 0x61: + case 0x71: + case 0x81: + case 0x91: + case 0xA1: + case 0xB1: + case 0xC1: + case 0xD1: + case 0xE1: + case 0xF1: + PUSH16( GET_PC() ); + SET_PC( READ_PROG16( 0xFFDE - (opcode >> 3) ) ); + goto loop; + +/* 14. STACK OPERATION COMMANDS */ + + { + int temp; + case 0x7F: /* RET1 */ + temp = POP(); + SET_PC( POP() ); + pc += POP() << 8; + goto set_status; + case 0x8E: /* POP PSW */ + temp = POP(); + set_status: + SET_STATUS( temp ); + goto loop; + } + + case 0x0D: { /* PUSH PSW */ + int temp; + CALC_STATUS( temp ); + PUSH( temp ); + goto loop; + } + + case 0x2D: /* PUSH A */ + PUSH( a ); + goto loop; + + case 0x4D: /* PUSH X */ + PUSH( x ); + goto loop; + + case 0x6D: /* PUSH Y */ + PUSH( y ); + goto loop; + + case 0xAE: /* POP A */ + a = POP(); + goto loop; + + case 0xCE: /* POP X */ + x = POP(); + goto loop; + + case 0xEE: /* POP Y */ + y = POP(); + goto loop; + +/* 15. BIT OPERATION COMMANDS */ + + case 0x02: /* SET1 */ + case 0x22: + case 0x42: + case 0x62: + case 0x82: + case 0xA2: + case 0xC2: + case 0xE2: + case 0x12: /* CLR1 */ + case 0x32: + case 0x52: + case 0x72: + case 0x92: + case 0xB2: + case 0xD2: + case 0xF2: { + data += dp; + int bit = 1 << (opcode >> 5); + int mask = ~bit; + if ( opcode & 0x10 ) + bit = 0; + WRITE( data, (READ( data ) & mask) | bit ); + goto inc_pc_loop; + } + + case 0x0E: /* TSET1 abs */ + case 0x4E:{/* TCLR1 abs */ + data = READ_PC16( pc ); + pc += 2; + unsigned temp = READ( data ); + nz = temp & a; + temp &= ~a; + if ( !(opcode & 0x40) ) + temp |= a; + WRITE( data, temp ); + goto loop; + } + + case 0x4A: /* AND1 C,mem.bit */ + c &= MEM_BIT(); + pc += 2; + goto loop; + + case 0x6A: /* AND1 C,/mem.bit */ + check( 0 ); /* untested */ + c &= ~MEM_BIT(); + pc += 2; + goto loop; + + case 0x0A: /* OR1 C,mem.bit */ + check( 0 ); /* untested */ + c |= MEM_BIT(); + pc += 2; + goto loop; + + case 0x2A: /* OR1 C,/mem.bit */ + check( 0 ); /* untested */ + c |= ~MEM_BIT(); + pc += 2; + goto loop; + + case 0x8A: /* EOR1 C,mem.bit */ + c ^= MEM_BIT(); + pc += 2; + goto loop; + + case 0xEA: { /* NOT1 mem.bit */ + data = READ_PC16( pc ); + pc += 2; + unsigned temp = READ( data & 0x1FFF ); + temp ^= 1 << (data >> 13); + WRITE( data & 0x1FFF, temp ); + goto loop; + } + + case 0xCA: { /* MOV1 mem.bit,C */ + data = READ_PC16( pc ); + pc += 2; + unsigned temp = READ( data & 0x1FFF ); + unsigned bit = data >> 13; + temp = (temp & ~(1 << bit)) | (((c >> 8) & 1) << bit); + WRITE( data & 0x1FFF, temp ); + goto loop; + } + + case 0xAA: /* MOV1 C,mem.bit */ + c = MEM_BIT(); + pc += 2; + goto loop; + +/* 16. PROGRAM STATUS FLAG OPERATION COMMANDS */ + + case 0x60: /* CLRC */ + c = 0; + goto loop; + + case 0x80: /* SETC */ + c = ~0; + goto loop; + + case 0xED: /* NOTC */ + c ^= 0x100; + goto loop; + + case 0xE0: /* CLRV */ + status &= ~(st_v | st_h); + goto loop; + + case 0x20: /* CLRP */ + dp = 0; + goto loop; + + case 0x40: /* SETP */ + dp = 0x100; + goto loop; + + case 0xA0: /* EI */ + check( 0 ); /* untested */ + status |= st_i; + goto loop; + + case 0xC0: /* DI */ + check( 0 ); /* untested */ + status &= ~st_i; + goto loop; + +/* 17. OTHER COMMANDS */ + + case 0x00: /* NOP */ + goto loop; + + /*case 0xEF:*/ /* SLEEP */ + /*case 0xFF:*/ /* STOP */ + case 0xFF: + c |= 1; /* force switch table to have 256 entries, + hopefully helping optimizer */ + } /* switch */ + + /* unhandled instructions fall out of switch so emulator can catch them */ + +out_of_time: + /* undo partial execution of opcode */ + spc_time_ -= this->cycle_table [*--pc]; + { + int temp; + CALC_STATUS( temp ); + this->r.status = (uint8_t) temp; + } + + this->r.pc = GET_PC(); + this->r.sp = (uint8_t) GET_SP(); + this->r.a = (uint8_t) a; + this->r.x = (uint8_t) x; + this->r.y = (uint8_t) y; + +#if 0 + EXIT_TIMER(cpu); +#endif + return spc_time_; +} + +void CPU_Init( THIS ) +{ + ci->memcpy( this->cycle_table, cycle_table, sizeof cycle_table ); +} + diff --git a/lib/rbcodec/codecs/libspc/spc_dsp.c b/lib/rbcodec/codecs/libspc/spc_dsp.c new file mode 100644 index 0000000000..6350c4c331 --- /dev/null +++ b/lib/rbcodec/codecs/libspc/spc_dsp.c @@ -0,0 +1,1594 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2007-2008 Michael Sevakis (jhMikeS) + * Copyright (C) 2006-2007 Adam Gashlin (hcs) + * Copyright (C) 2004-2007 Shay Green (blargg) + * Copyright (C) 2002 Brad Martin + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +/* The DSP portion (awe!) */ +#include "codeclib.h" +#include "spc_codec.h" +#include "spc_profiler.h" + +#if defined(CPU_COLDFIRE) || defined (CPU_ARM) +int32_t fir_buf[FIR_BUF_CNT] IBSS_ATTR_SPC + __attribute__((aligned(FIR_BUF_ALIGN*1))); +#endif +#if SPC_BRRCACHE +/* a little extra for samples that go past end */ +int16_t BRRcache [BRR_CACHE_SIZE] CACHEALIGN_ATTR; +#endif + +void DSP_write( struct Spc_Dsp* this, int i, int data ) +{ + assert( (unsigned) i < REGISTER_COUNT ); + + this->r.reg [i] = data; + int high = i >> 4; + int low = i & 0x0F; + if ( low < 2 ) /* voice volumes */ + { + int left = *(int8_t const*) &this->r.reg [i & ~1]; + int right = *(int8_t const*) &this->r.reg [i | 1]; + struct voice_t* v = this->voice_state + high; + v->volume [0] = left; + v->volume [1] = right; + } + else if ( low == 0x0F ) /* fir coefficients */ + { + this->fir_coeff [7 - high] = (int8_t) data; /* sign-extend */ + } +} + +#define CLAMP16( n ) clip_sample_16( n ) + +#if SPC_BRRCACHE +static void decode_brr( struct Spc_Dsp* this, unsigned start_addr, + struct voice_t* voice, + struct raw_voice_t const* const raw_voice ) ICODE_ATTR_SPC; +static void decode_brr( struct Spc_Dsp* this, unsigned start_addr, + struct voice_t* voice, + struct raw_voice_t const* const raw_voice ) +{ + /* setup same variables as where decode_brr() is called from */ + #undef RAM + #define RAM ram.ram + + struct src_dir const* const sd = + &ram.sd[this->r.g.wave_page * 0x100/sizeof(struct src_dir)]; + struct cache_entry_t* const wave_entry = + &this->wave_entry [raw_voice->waveform]; + + /* the following block can be put in place of the call to + decode_brr() below + */ + { + DEBUGF( "decode at %08x (wave #%d)\n", + start_addr, raw_voice->waveform ); + + /* see if in cache */ + int i; + for ( i = 0; i < this->oldsize; i++ ) + { + struct cache_entry_t* e = &this->wave_entry_old [i]; + if ( e->start_addr == start_addr ) + { + DEBUGF( "found in wave_entry_old (oldsize=%d)\n", + this->oldsize ); + *wave_entry = *e; + goto wave_in_cache; + } + } + + wave_entry->start_addr = start_addr; + + uint8_t const* const loop_ptr = + RAM + letoh16(sd[raw_voice->waveform].loop); + short* loop_start = 0; + + short* out = BRRcache + start_addr * 2; + wave_entry->samples = out; + *out++ = 0; + int smp1 = 0; + int smp2 = 0; + + uint8_t const* addr = RAM + start_addr; + int block_header; + do + { + if ( addr == loop_ptr ) + { + loop_start = out; + DEBUGF( "loop at %08lx (wave #%d)\n", + (unsigned long)(addr - RAM), raw_voice->waveform ); + } + + /* header */ + block_header = *addr; + addr += 9; + voice->addr = addr; + int const filter = (block_header & 0x0C) - 0x08; + + /* scaling + (invalid scaling gives -4096 for neg nybble, 0 for pos) */ + static unsigned char const right_shifts [16] = { + 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 29, 29, 29, + }; + static unsigned char const left_shifts [16] = { + 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 11, 11, 11 + }; + int const scale = block_header >> 4; + int const right_shift = right_shifts [scale]; + int const left_shift = left_shifts [scale]; + + /* output position */ + out += BRR_BLOCK_SIZE; + int offset = -BRR_BLOCK_SIZE << 2; + + do /* decode and filter 16 samples */ + { + /* Get nybble, sign-extend, then scale + get byte, select which nybble, sign-extend, then shift based + on scaling. also handles invalid scaling values. */ + int delta = (int) (int8_t) (addr [offset >> 3] << (offset & 4)) + >> right_shift << left_shift; + + out [offset >> 2] = smp2; + + if ( filter == 0 ) /* mode 0x08 (30-90% of the time) */ + { + delta -= smp2 >> 1; + delta += smp2 >> 5; + smp2 = smp1; + delta += smp1; + delta += (-smp1 - (smp1 >> 1)) >> 5; + } + else + { + if ( filter == -4 ) /* mode 0x04 */ + { + delta += smp1 >> 1; + delta += (-smp1) >> 5; + } + else if ( filter > -4 ) /* mode 0x0C */ + { + delta -= smp2 >> 1; + delta += (smp2 + (smp2 >> 1)) >> 4; + delta += smp1; + delta += (-smp1 * 13) >> 7; + } + smp2 = smp1; + } + + delta = CLAMP16( delta ); + smp1 = (int16_t) (delta * 2); /* sign-extend */ + } + while ( (offset += 4) != 0 ); + + /* if next block has end flag set, this block ends early */ + /* (verified) */ + if ( (block_header & 3) != 3 && (*addr & 3) == 1 ) + { + /* skip last 9 samples */ + out -= 9; + goto early_end; + } + } + while ( !(block_header & 1) && addr < RAM + 0x10000 ); + + out [0] = smp2; + out [1] = smp1; + + early_end: + wave_entry->end = (out - 1 - wave_entry->samples) << 12; + + wave_entry->loop = 0; + if ( (block_header & 2) ) + { + if ( loop_start ) + { + int loop = out - loop_start; + wave_entry->loop = loop; + wave_entry->end += 0x3000; + out [2] = loop_start [2]; + out [3] = loop_start [3]; + out [4] = loop_start [4]; + } + else + { + DEBUGF( "loop point outside initial wave\n" ); + } + } + + DEBUGF( "end at %08lx (wave #%d)\n", + (unsigned long)(addr - RAM), raw_voice->waveform ); + + /* add to cache */ + this->wave_entry_old [this->oldsize++] = *wave_entry; +wave_in_cache:; + } +} +#endif + +static void key_on(struct Spc_Dsp* const this, struct voice_t* const voice, + struct src_dir const* const sd, + struct raw_voice_t const* const raw_voice, + const int key_on_delay, const int vbit) ICODE_ATTR_SPC; +static void key_on(struct Spc_Dsp* const this, struct voice_t* const voice, + struct src_dir const* const sd, + struct raw_voice_t const* const raw_voice, + const int key_on_delay, const int vbit) { + #undef RAM + #define RAM ram.ram + int const env_rate_init = 0x7800; + voice->key_on_delay = key_on_delay; + if ( key_on_delay == 0 ) + { + this->keys_down |= vbit; + voice->envx = 0; + voice->env_mode = state_attack; + voice->env_timer = env_rate_init; /* TODO: inaccurate? */ + unsigned start_addr = letoh16(sd[raw_voice->waveform].start); + #if !SPC_BRRCACHE + { + voice->addr = RAM + start_addr; + /* BRR filter uses previous samples */ + voice->samples [BRR_BLOCK_SIZE + 1] = 0; + voice->samples [BRR_BLOCK_SIZE + 2] = 0; + /* decode three samples immediately */ + voice->position = (BRR_BLOCK_SIZE + 3) * 0x1000 - 1; + voice->block_header = 0; /* "previous" BRR header */ + } + #else + { + voice->position = 3 * 0x1000 - 1; + struct cache_entry_t* const wave_entry = + &this->wave_entry [raw_voice->waveform]; + + /* predecode BRR if not already */ + if ( wave_entry->start_addr != start_addr ) + { + /* the following line can be replaced by the indicated block + in decode_brr() */ + decode_brr( this, start_addr, voice, raw_voice ); + } + + voice->samples = wave_entry->samples; + voice->wave_end = wave_entry->end; + voice->wave_loop = wave_entry->loop; + } + #endif + } +} + +void DSP_run_( struct Spc_Dsp* this, long count, int32_t* out_buf ) +{ + #undef RAM +#if defined(CPU_ARM) && !SPC_BRRCACHE + uint8_t* const ram_ = ram.ram; + #define RAM ram_ +#else + #define RAM ram.ram +#endif +#if 0 + EXIT_TIMER(cpu); + ENTER_TIMER(dsp); +#endif + + /* Here we check for keys on/off. Docs say that successive writes + to KON/KOF must be separated by at least 2 Ts periods or risk + being neglected. Therefore DSP only looks at these during an + update, and not at the time of the write. Only need to do this + once however, since the regs haven't changed over the whole + period we need to catch up with. */ + + { + int key_ons = this->r.g.key_ons; + int key_offs = this->r.g.key_offs; + /* keying on a voice resets that bit in ENDX */ + this->r.g.wave_ended &= ~key_ons; + /* key_off bits prevent key_on from being acknowledged */ + this->r.g.key_ons = key_ons & key_offs; + + /* process key events outside loop, since they won't re-occur */ + struct voice_t* voice = this->voice_state + 8; + int vbit = 0x80; + do + { + --voice; + if ( key_offs & vbit ) + { + voice->env_mode = state_release; + voice->key_on_delay = 0; + } + else if ( key_ons & vbit ) + { + voice->key_on_delay = 8; + } + } + while ( (vbit >>= 1) != 0 ); + } + + struct src_dir const* const sd = + &ram.sd[this->r.g.wave_page * 0x100/sizeof(struct src_dir)]; + + #ifdef ROCKBOX_BIG_ENDIAN + /* Convert endiannesses before entering loops - these + get used alot */ + const uint32_t rates[VOICE_COUNT] = + { + GET_LE16A( this->r.voice[0].rate ) & 0x3FFF, + GET_LE16A( this->r.voice[1].rate ) & 0x3FFF, + GET_LE16A( this->r.voice[2].rate ) & 0x3FFF, + GET_LE16A( this->r.voice[3].rate ) & 0x3FFF, + GET_LE16A( this->r.voice[4].rate ) & 0x3FFF, + GET_LE16A( this->r.voice[5].rate ) & 0x3FFF, + GET_LE16A( this->r.voice[6].rate ) & 0x3FFF, + GET_LE16A( this->r.voice[7].rate ) & 0x3FFF, + }; + #define VOICE_RATE(x) *(x) + #define IF_RBE(...) __VA_ARGS__ + #ifdef CPU_COLDFIRE + /* Initialize mask register with the buffer address mask */ + asm volatile ("move.l %[m], %%mask" : : [m]"i"(FIR_BUF_MASK)); + const int echo_wrap = (this->r.g.echo_delay & 15) * 0x800; + const int echo_start = this->r.g.echo_page * 0x100; + #endif /* CPU_COLDFIRE */ + #else + #define VOICE_RATE(x) (GET_LE16(raw_voice->rate) & 0x3FFF) + #define IF_RBE(...) + #endif /* ROCKBOX_BIG_ENDIAN */ + +#if !SPC_NOINTERP + int const slow_gaussian = (this->r.g.pitch_mods >> 1) | + this->r.g.noise_enables; +#endif + /* (g.flags & 0x40) ? 30 : 14 */ + int const global_muting = ((this->r.g.flags & 0x40) >> 2) + 14 - 8; + int const global_vol_0 = this->r.g.volume_0; + int const global_vol_1 = this->r.g.volume_1; + + /* each rate divides exactly into 0x7800 without remainder */ + int const env_rate_init = 0x7800; + static unsigned short const env_rates [0x20] ICONST_ATTR_SPC = + { + 0x0000, 0x000F, 0x0014, 0x0018, 0x001E, 0x0028, 0x0030, 0x003C, + 0x0050, 0x0060, 0x0078, 0x00A0, 0x00C0, 0x00F0, 0x0140, 0x0180, + 0x01E0, 0x0280, 0x0300, 0x03C0, 0x0500, 0x0600, 0x0780, 0x0A00, + 0x0C00, 0x0F00, 0x1400, 0x1800, 0x1E00, 0x2800, 0x3C00, 0x7800 + }; + + do /* one pair of output samples per iteration */ + { + /* Noise */ + if ( this->r.g.noise_enables ) + { + if ( (this->noise_count -= + env_rates [this->r.g.flags & 0x1F]) <= 0 ) + { + this->noise_count = env_rate_init; + int feedback = (this->noise << 13) ^ (this->noise << 14); + this->noise = (feedback & 0x8000) ^ (this->noise >> 1 & ~1); + } + } + +#if !SPC_NOECHO + int echo_0 = 0; + int echo_1 = 0; +#endif + long prev_outx = 0; /* TODO: correct value for first channel? */ + int chans_0 = 0; + int chans_1 = 0; + /* TODO: put raw_voice pointer in voice_t? */ + struct raw_voice_t * raw_voice = this->r.voice; + struct voice_t* voice = this->voice_state; + int vbit = 1; + IF_RBE( const uint32_t* vr = rates; ) + for ( ; vbit < 0x100; vbit <<= 1, ++voice, ++raw_voice IF_RBE( , ++vr ) ) + { + /* pregen involves checking keyon, etc */ +#if 0 + ENTER_TIMER(dsp_pregen); +#endif + + /* Key on events are delayed */ + int key_on_delay = voice->key_on_delay; + + if ( UNLIKELY ( --key_on_delay >= 0 ) ) /* <1% of the time */ + { + key_on(this,voice,sd,raw_voice,key_on_delay,vbit); + } + + if ( !(this->keys_down & vbit) ) /* Silent channel */ + { + silent_chan: + raw_voice->envx = 0; + raw_voice->outx = 0; + prev_outx = 0; + continue; + } + + /* Envelope */ + { + int const ENV_RANGE = 0x800; + int env_mode = voice->env_mode; + int adsr0 = raw_voice->adsr [0]; + int env_timer; + if ( LIKELY ( env_mode != state_release ) ) /* 99% of the time */ + { + env_timer = voice->env_timer; + if ( LIKELY ( adsr0 & 0x80 ) ) /* 79% of the time */ + { + int adsr1 = raw_voice->adsr [1]; + if ( LIKELY ( env_mode == state_sustain ) ) /* 74% of the time */ + { + if ( (env_timer -= env_rates [adsr1 & 0x1F]) > 0 ) + goto write_env_timer; + + int envx = voice->envx; + envx--; /* envx *= 255 / 256 */ + envx -= envx >> 8; + voice->envx = envx; + /* TODO: should this be 8? */ + raw_voice->envx = envx >> 4; + goto init_env_timer; + } + else if ( env_mode < 0 ) /* 25% state_decay */ + { + int envx = voice->envx; + if ( (env_timer -= + env_rates [(adsr0 >> 3 & 0x0E) + 0x10]) <= 0 ) + { + envx--; /* envx *= 255 / 256 */ + envx -= envx >> 8; + voice->envx = envx; + /* TODO: should this be 8? */ + raw_voice->envx = envx >> 4; + env_timer = env_rate_init; + } + + int sustain_level = adsr1 >> 5; + if ( envx <= (sustain_level + 1) * 0x100 ) + voice->env_mode = state_sustain; + + goto write_env_timer; + } + else /* state_attack */ + { + int t = adsr0 & 0x0F; + if ( (env_timer -= env_rates [t * 2 + 1]) > 0 ) + goto write_env_timer; + + int envx = voice->envx; + + int const step = ENV_RANGE / 64; + envx += step; + if ( t == 15 ) + envx += ENV_RANGE / 2 - step; + + if ( envx >= ENV_RANGE ) + { + envx = ENV_RANGE - 1; + voice->env_mode = state_decay; + } + voice->envx = envx; + /* TODO: should this be 8? */ + raw_voice->envx = envx >> 4; + goto init_env_timer; + } + } + else /* gain mode */ + { + int t = raw_voice->gain; + if ( t < 0x80 ) + { + raw_voice->envx = t; + voice->envx = t << 4; + goto env_end; + } + else + { + if ( (env_timer -= env_rates [t & 0x1F]) > 0 ) + goto write_env_timer; + + int envx = voice->envx; + int mode = t >> 5; + if ( mode <= 5 ) /* decay */ + { + int step = ENV_RANGE / 64; + if ( mode == 5 ) /* exponential */ + { + envx--; /* envx *= 255 / 256 */ + step = envx >> 8; + } + if ( (envx -= step) < 0 ) + { + envx = 0; + if ( voice->env_mode == state_attack ) + voice->env_mode = state_decay; + } + } + else /* attack */ + { + int const step = ENV_RANGE / 64; + envx += step; + if ( mode == 7 && + envx >= ENV_RANGE * 3 / 4 + step ) + envx += ENV_RANGE / 256 - step; + + if ( envx >= ENV_RANGE ) + envx = ENV_RANGE - 1; + } + voice->envx = envx; + /* TODO: should this be 8? */ + raw_voice->envx = envx >> 4; + goto init_env_timer; + } + } + } + else /* state_release */ + { + int envx = voice->envx; + if ( (envx -= ENV_RANGE / 256) > 0 ) + { + voice->envx = envx; + raw_voice->envx = envx >> 8; + goto env_end; + } + else + { + /* bit was set, so this clears it */ + this->keys_down ^= vbit; + voice->envx = 0; + goto silent_chan; + } + } + init_env_timer: + env_timer = env_rate_init; + write_env_timer: + voice->env_timer = env_timer; + env_end:; + } +#if 0 + EXIT_TIMER(dsp_pregen); + + ENTER_TIMER(dsp_gen); +#endif + #if !SPC_BRRCACHE + /* Decode BRR block */ + if ( voice->position >= BRR_BLOCK_SIZE * 0x1000 ) + { + voice->position -= BRR_BLOCK_SIZE * 0x1000; + + uint8_t const* addr = voice->addr; + if ( addr >= RAM + 0x10000 ) + addr -= 0x10000; + + /* action based on previous block's header */ + if ( voice->block_header & 1 ) + { + addr = RAM + letoh16(sd[raw_voice->waveform].loop); + this->r.g.wave_ended |= vbit; + if ( !(voice->block_header & 2) ) /* 1% of the time */ + { + /* first block was end block; + don't play anything (verified) */ + /* bit was set, so this clears it */ + this->keys_down ^= vbit; + + /* since voice->envx is 0, + samples and position don't matter */ + raw_voice->envx = 0; + voice->envx = 0; + goto skip_decode; + } + } + + /* header */ + int const block_header = *addr; + addr += 9; + voice->addr = addr; + voice->block_header = block_header; + + /* previous samples */ + int smp2 = voice->samples [BRR_BLOCK_SIZE + 1]; + int smp1 = voice->samples [BRR_BLOCK_SIZE + 2]; + voice->samples [0] = voice->samples [BRR_BLOCK_SIZE]; + + /* output position */ + short* out = voice->samples + (1 + BRR_BLOCK_SIZE); + int offset = -BRR_BLOCK_SIZE << 2; + + /* if next block has end flag set, + this block ends early (verified) */ + if ( (block_header & 3) != 3 && (*addr & 3) == 1 ) + { + /* arrange for last 9 samples to be skipped */ + int const skip = 9; + out += (skip & 1); + voice->samples [skip] = voice->samples [BRR_BLOCK_SIZE]; + voice->position += skip * 0x1000; + offset = (-BRR_BLOCK_SIZE + (skip & ~1)) << 2; + addr -= skip / 2; + /* force sample to end on next decode */ + voice->block_header = 1; + } + + int const filter = block_header & 0x0c; + int const scale = block_header >> 4; + + if ( filter == 0x08 ) /* filter 2 (30-90% of the time) */ + { + /* y[n] = x[n] + 61/32 * y[n-1] - 15/16 * y[n-2] */ + do /* decode and filter 16 samples */ + { + /* Get nybble, sign-extend, then scale + get byte, select which nybble, sign-extend, then shift + based on scaling. */ + int delta = (int8_t)(addr [offset >> 3] << (offset & 4)) >> 4; + delta = (delta << scale) >> 1; + + if (scale > 0xc) + delta = (delta >> 17) << 11; + + out [offset >> 2] = smp2; + + delta -= smp2 >> 1; + delta += smp2 >> 5; + delta += smp1; + delta += (-smp1 - (smp1 >> 1)) >> 5; + + delta = CLAMP16( delta ); + smp2 = smp1; + smp1 = (int16_t) (delta * 2); /* sign-extend */ + } + while ( (offset += 4) != 0 ); + } + else if ( filter == 0x04 ) /* filter 1 */ + { + /* y[n] = x[n] + 15/16 * y[n-1] */ + do /* decode and filter 16 samples */ + { + /* Get nybble, sign-extend, then scale + get byte, select which nybble, sign-extend, then shift + based on scaling. */ + int delta = (int8_t)(addr [offset >> 3] << (offset & 4)) >> 4; + delta = (delta << scale) >> 1; + + if (scale > 0xc) + delta = (delta >> 17) << 11; + + out [offset >> 2] = smp2; + + delta += smp1 >> 1; + delta += (-smp1) >> 5; + + delta = CLAMP16( delta ); + smp2 = smp1; + smp1 = (int16_t) (delta * 2); /* sign-extend */ + } + while ( (offset += 4) != 0 ); + } + else if ( filter == 0x0c ) /* filter 3 */ + { + /* y[n] = x[n] + 115/64 * y[n-1] - 13/16 * y[n-2] */ + do /* decode and filter 16 samples */ + { + /* Get nybble, sign-extend, then scale + get byte, select which nybble, sign-extend, then shift + based on scaling. */ + int delta = (int8_t)(addr [offset >> 3] << (offset & 4)) >> 4; + delta = (delta << scale) >> 1; + + if (scale > 0xc) + delta = (delta >> 17) << 11; + + out [offset >> 2] = smp2; + + delta -= smp2 >> 1; + delta += (smp2 + (smp2 >> 1)) >> 4; + delta += smp1; + delta += (-smp1 * 13) >> 7; + + delta = CLAMP16( delta ); + smp2 = smp1; + smp1 = (int16_t) (delta * 2); /* sign-extend */ + } + while ( (offset += 4) != 0 ); + } + else /* filter 0 */ + { + /* y[n] = x[n] */ + do /* decode and filter 16 samples */ + { + /* Get nybble, sign-extend, then scale + get byte, select which nybble, sign-extend, then shift + based on scaling. */ + int delta = (int8_t)(addr [offset >> 3] << (offset & 4)) >> 4; + delta = (delta << scale) >> 1; + + if (scale > 0xc) + delta = (delta >> 17) << 11; + + out [offset >> 2] = smp2; + + smp2 = smp1; + smp1 = delta * 2; + } + while ( (offset += 4) != 0 ); + } + + out [0] = smp2; + out [1] = smp1; + + skip_decode:; + } + #endif /* !SPC_BRRCACHE */ + /* Get rate (with possible modulation) */ + int rate = VOICE_RATE(vr); + if ( this->r.g.pitch_mods & vbit ) + rate = (rate * (prev_outx + 32768)) >> 15; + + #if !SPC_NOINTERP + /* Interleved gauss table (to improve cache coherency). */ + /* gauss [i * 2 + j] = normal_gauss [(1 - j) * 256 + i] */ + static short const gauss [512] ICONST_ATTR_SPC MEM_ALIGN_ATTR = + { +370,1305, 366,1305, 362,1304, 358,1304, 354,1304, 351,1304, 347,1304, 343,1303, +339,1303, 336,1303, 332,1302, 328,1302, 325,1301, 321,1300, 318,1300, 314,1299, +311,1298, 307,1297, 304,1297, 300,1296, 297,1295, 293,1294, 290,1293, 286,1292, +283,1291, 280,1290, 276,1288, 273,1287, 270,1286, 267,1284, 263,1283, 260,1282, +257,1280, 254,1279, 251,1277, 248,1275, 245,1274, 242,1272, 239,1270, 236,1269, +233,1267, 230,1265, 227,1263, 224,1261, 221,1259, 218,1257, 215,1255, 212,1253, +210,1251, 207,1248, 204,1246, 201,1244, 199,1241, 196,1239, 193,1237, 191,1234, +188,1232, 186,1229, 183,1227, 180,1224, 178,1221, 175,1219, 173,1216, 171,1213, +168,1210, 166,1207, 163,1205, 161,1202, 159,1199, 156,1196, 154,1193, 152,1190, +150,1186, 147,1183, 145,1180, 143,1177, 141,1174, 139,1170, 137,1167, 134,1164, +132,1160, 130,1157, 128,1153, 126,1150, 124,1146, 122,1143, 120,1139, 118,1136, +117,1132, 115,1128, 113,1125, 111,1121, 109,1117, 107,1113, 106,1109, 104,1106, +102,1102, 100,1098, 99,1094, 97,1090, 95,1086, 94,1082, 92,1078, 90,1074, + 89,1070, 87,1066, 86,1061, 84,1057, 83,1053, 81,1049, 80,1045, 78,1040, + 77,1036, 76,1032, 74,1027, 73,1023, 71,1019, 70,1014, 69,1010, 67,1005, + 66,1001, 65, 997, 64, 992, 62, 988, 61, 983, 60, 978, 59, 974, 58, 969, + 56, 965, 55, 960, 54, 955, 53, 951, 52, 946, 51, 941, 50, 937, 49, 932, + 48, 927, 47, 923, 46, 918, 45, 913, 44, 908, 43, 904, 42, 899, 41, 894, + 40, 889, 39, 884, 38, 880, 37, 875, 36, 870, 36, 865, 35, 860, 34, 855, + 33, 851, 32, 846, 32, 841, 31, 836, 30, 831, 29, 826, 29, 821, 28, 816, + 27, 811, 27, 806, 26, 802, 25, 797, 24, 792, 24, 787, 23, 782, 23, 777, + 22, 772, 21, 767, 21, 762, 20, 757, 20, 752, 19, 747, 19, 742, 18, 737, + 17, 732, 17, 728, 16, 723, 16, 718, 15, 713, 15, 708, 15, 703, 14, 698, + 14, 693, 13, 688, 13, 683, 12, 678, 12, 674, 11, 669, 11, 664, 11, 659, + 10, 654, 10, 649, 10, 644, 9, 640, 9, 635, 9, 630, 8, 625, 8, 620, + 8, 615, 7, 611, 7, 606, 7, 601, 6, 596, 6, 592, 6, 587, 6, 582, + 5, 577, 5, 573, 5, 568, 5, 563, 4, 559, 4, 554, 4, 550, 4, 545, + 4, 540, 3, 536, 3, 531, 3, 527, 3, 522, 3, 517, 2, 513, 2, 508, + 2, 504, 2, 499, 2, 495, 2, 491, 2, 486, 1, 482, 1, 477, 1, 473, + 1, 469, 1, 464, 1, 460, 1, 456, 1, 451, 1, 447, 1, 443, 1, 439, + 0, 434, 0, 430, 0, 426, 0, 422, 0, 418, 0, 414, 0, 410, 0, 405, + 0, 401, 0, 397, 0, 393, 0, 389, 0, 385, 0, 381, 0, 378, 0, 374, + }; + /* Gaussian interpolation using most recent 4 samples */ + long position = voice->position; + voice->position += rate; + short const* interp = voice->samples + (position >> 12); + int offset = position >> 4 & 0xFF; + + /* Only left half of gaussian kernel is in table, so we must mirror + for right half */ + short const* fwd = gauss + offset * 2; + short const* rev = gauss + 510 - offset * 2; + + /* Use faster gaussian interpolation when exact result isn't needed + by pitch modulator of next channel */ + int amp_0, amp_1; /* Also serve as temps _0, and _1 */ + if ( LIKELY ( !(slow_gaussian & vbit) ) ) /* 99% of the time */ + { + /* Main optimization is lack of clamping. Not a problem since + output never goes more than +/- 16 outside 16-bit range and + things are clamped later anyway. Other optimization is to + preserve fractional accuracy, eliminating several masks. */ + #if defined (CPU_ARM) + int output; + int _2, _3; /* All-purpose temps */ + /* Multiple ASM blocks keep regs free and reduce result + * latency issues. */ + #if ARM_ARCH >= 6 + /* Interpolate */ + asm volatile ( + "ldr %[_0], [%[interp]] \r\n" /* _0=i0i1 */ + "ldr %[_2], [%[fwd]] \r\n" /* _2=f0f1 */ + "ldr %[_1], [%[interp], #4] \r\n" /* _1=i2i3 */ + "ldr %[_3], [%[rev]] \r\n" /* _3=r0r1 */ + "smuad %[out], %[_0], %[_2] \r\n" /* out=f0*i0 + f1*i1 */ + "smladx %[out], %[_1], %[_3], %[out] \r\n" /* out+=r1*i2 + r0*i3 */ + : [out]"=r"(output), + [_0]"=&r"(amp_0), [_1]"=&r"(amp_1), + [_2]"=&r"(_2), [_3]"=r"(_3) + : [fwd]"r"(fwd), [rev]"r"(rev), + [interp]"r"(interp)); + /* Apply voice envelope */ + asm volatile ( + "mov %[_2], %[out], asr #(11-5) \r\n" /* To do >> 16 later */ + "mul %[out], %[_2], %[envx] \r\n" /* and avoid exp. shift */ + : [out]"+r"(output), [_2]"=&r"(_2) + : [envx]"r"((int)voice->envx)); + /* Apply left and right volume */ + asm volatile ( + "smulwb %[amp_0], %[out], %[vvol_0] \r\n" /* (32x16->48)[47:16]->[31:0] */ + "smulwb %[amp_1], %[out], %[vvol_1] \r\n" + : [out]"+r"(output), + [amp_0]"=&r"(amp_0), [amp_1]"=r"(amp_1) + : [vvol_0]"r"(voice->volume[0]), + [vvol_1]"r"(voice->volume[1])); + + raw_voice->outx = output >> (8+5); /* 'output' still 5 bits too big */ + #else /* ARM_ARCH < 6 */ + /* Perform gaussian interpolation on four samples */ + asm volatile ( + "ldrsh %[_0], [%[interp]] \r\n" + "ldrsh %[_2], [%[fwd]] \r\n" + "ldrsh %[_1], [%[interp], #2] \r\n" + "ldrsh %[_3], [%[fwd], #2] \r\n" + "mul %[out], %[_0], %[_2] \r\n" /* out= fwd[0]*interp[0] */ + "ldrsh %[_0], [%[interp], #4] \r\n" + "ldrsh %[_2], [%[rev], #2] \r\n" + "mla %[out], %[_1], %[_3], %[out] \r\n" /* out+=fwd[1]*interp[1] */ + "ldrsh %[_1], [%[interp], #6] \r\n" + "ldrsh %[_3], [%[rev]] \r\n" + "mla %[out], %[_0], %[_2], %[out] \r\n" /* out+=rev[1]*interp[2] */ + "mla %[out], %[_1], %[_3], %[out] \r\n" /* out+=rev[0]*interp[3] */ + : [out]"=&r"(output), + [_0]"=&r"(amp_0), [_1]"=&r"(amp_1), + [_2]"=&r"(_2), [_3]"=&r"(_3) + : [fwd]"r"(fwd), [rev]"r"(rev), + [interp]"r"(interp)); + /* Apply voice envelope */ + asm volatile ( + "mov %[_2], %[out], asr #11 \r\n" + "mul %[out], %[_2], %[envx] \r\n" + : [out]"+r"(output), [_2]"=&r"(_2) + : [envx]"r"((int)voice->envx)); + /* Reduce and apply left and right volume */ + asm volatile ( + "mov %[out], %[out], asr #11 \r\n" + "mul %[amp_0], %[out], %[vvol_0] \r\n" + "mul %[amp_1], %[out], %[vvol_1] \r\n" + : [out]"+r"(output), + [amp_0]"=&r"(amp_0), [amp_1]"=r"(amp_1) + : [vvol_0]"r"((int)voice->volume[0]), + [vvol_1]"r"((int)voice->volume[1])); + + raw_voice->outx = output >> 8; + #endif /* ARM_ARCH */ + #else /* Unoptimized CPU */ + int output = (((fwd [0] * interp [0] + + fwd [1] * interp [1] + + rev [1] * interp [2] + + rev [0] * interp [3] ) >> 11) * voice->envx) >> 11; + + /* duplicated here to give compiler more to run in parallel */ + amp_0 = voice->volume [0] * output; + amp_1 = voice->volume [1] * output; + + raw_voice->outx = output >> 8; + #endif /* CPU_* */ + } + else /* slow gaussian */ + { + #if defined(CPU_ARM) + #if ARM_ARCH >= 6 + int output = *(int16_t*) &this->noise; + + if ( !(this->r.g.noise_enables & vbit) ) + { + /* Interpolate */ + int _2, _3; + asm volatile ( + /* NOTE: often-unaligned accesses */ + "ldr %[_0], [%[interp]] \r\n" /* _0=i0i1 */ + "ldr %[_2], [%[fwd]] \r\n" /* _2=f0f1 */ + "ldr %[_1], [%[interp], #4] \r\n" /* _1=i2i3 */ + "ldr %[_3], [%[rev]] \r\n" /* _3=f2f3 */ + "smulbb %[out], %[_0], %[_2] \r\n" /* out=f0*i0 */ + "smultt %[_0], %[_0], %[_2] \r\n" /* _0=f1*i1 */ + "smulbt %[_2], %[_1], %[_3] \r\n" /* _2=r1*i2 */ + "smultb %[_3], %[_1], %[_3] \r\n" /* _3=r0*i3 */ + : [out]"=r"(output), + [_0]"=&r"(amp_0), [_1]"=&r"(amp_1), + [_2]"=&r"(_2), [_3]"=r"(_3) + : [fwd]"r"(fwd), [rev]"r"(rev), + [interp]"r"(interp)); + asm volatile ( + "mov %[out], %[out], asr#12 \r\n" + "add %[_0], %[out], %[_0], asr #12 \r\n" + "add %[_2], %[_0], %[_2], asr #12 \r\n" + "pkhbt %[_0], %[_2], %[_3], asl #4 \r\n" /* _3[31:16], _2[15:0] */ + "sadd16 %[_0], %[_0], %[_0] \r\n" /* _3[31:16]*2, _2[15:0]*2 */ + "qsubaddx %[out], %[_0], %[_0] \r\n" /* out[15:0]= + * sat16(_3[31:16]+_2[15:0]) */ + : [out]"+r"(output), + [_0]"+r"(amp_0), [_2]"+r"(_2), [_3]"+r"(_3)); + } + /* Apply voice envelope */ + asm volatile ( + "smulbb %[out], %[out], %[envx] \r\n" + : [out]"+r"(output) + : [envx]"r"(voice->envx)); + /* Reduce and apply left and right volume */ + asm volatile ( + "mov %[out], %[out], asr #11 \r\n" + "bic %[out], %[out], #0x1 \r\n" + "mul %[amp_0], %[out], %[vvol_0] \r\n" + "mul %[amp_1], %[out], %[vvol_1] \r\n" + : [out]"+r"(output), + [amp_0]"=&r"(amp_0), [amp_1]"=r"(amp_1) + : [vvol_0]"r"((int)voice->volume[0]), + [vvol_1]"r"((int)voice->volume[1])); + + prev_outx = output; + raw_voice->outx = output >> 8; + #else /* ARM_ARCH < 6 */ + int output = *(int16_t*) &this->noise; + + if ( !(this->r.g.noise_enables & vbit) ) + { + /* Interpolate */ + int _2, _3; + asm volatile ( + "ldrsh %[_0], [%[interp]] \r\n" + "ldrsh %[_2], [%[fwd]] \r\n" + "ldrsh %[_1], [%[interp], #2] \r\n" + "ldrsh %[_3], [%[fwd], #2] \r\n" + "mul %[out], %[_2], %[_0] \r\n" /* fwd[0]*interp[0] */ + "ldrsh %[_2], [%[rev], #2] \r\n" + "mul %[_0], %[_3], %[_1] \r\n" /* fwd[1]*interp[1] */ + "ldrsh %[_1], [%[interp], #4] \r\n" + "mov %[out], %[out], asr #12 \r\n" + "ldrsh %[_3], [%[rev]] \r\n" + "mul %[_2], %[_1], %[_2] \r\n" /* rev[1]*interp[2] */ + "ldrsh %[_1], [%[interp], #6] \r\n" + "add %[_0], %[out], %[_0], asr #12 \r\n" + "mul %[_3], %[_1], %[_3] \r\n" /* rev[0]*interp[3] */ + "add %[_2], %[_0], %[_2], asr #12 \r\n" + "mov %[_2], %[_2], lsl #17 \r\n" + "mov %[_3], %[_3], asr #12 \r\n" + "mov %[_3], %[_3], asl #1 \r\n" + "add %[out], %[_3], %[_2], asr #16 \r\n" + : [out]"=&r"(output), + [_0]"=&r"(amp_0), [_1]"=&r"(amp_1), + [_2]"=&r"(_2), [_3]"=&r"(_3) + : [fwd]"r"(fwd), [rev]"r"(rev), + [interp]"r"(interp)); + + output = CLAMP16(output); + } + /* Apply voice envelope */ + asm volatile ( + "mul %[_0], %[out], %[envx] \r\n" + : [_0]"=r"(amp_0) + : [out]"r"(output), [envx]"r"((int)voice->envx)); + /* Reduce and apply left and right volume */ + asm volatile ( + "mov %[out], %[amp_0], asr #11 \r\n" /* amp_0 = _0 */ + "bic %[out], %[out], #0x1 \r\n" + "mul %[amp_0], %[out], %[vvol_0] \r\n" + "mul %[amp_1], %[out], %[vvol_1] \r\n" + : [out]"+r"(output), + [amp_0]"+r"(amp_0), [amp_1]"=r"(amp_1) + : [vvol_0]"r"((int)voice->volume[0]), + [vvol_1]"r"((int)voice->volume[1])); + + prev_outx = output; + raw_voice->outx = output >> 8; + #endif /* ARM_ARCH >= 6 */ + #else /* Unoptimized CPU */ + int output = *(int16_t*) &this->noise; + + if ( !(this->r.g.noise_enables & vbit) ) + { + output = (fwd [0] * interp [0]) & ~0xFFF; + output = (output + fwd [1] * interp [1]) & ~0xFFF; + output = (output + rev [1] * interp [2]) >> 12; + output = (int16_t) (output * 2); + output += ((rev [0] * interp [3]) >> 12) * 2; + output = CLAMP16( output ); + } + output = (output * voice->envx) >> 11 & ~1; + + /* duplicated here to give compiler more to run in parallel */ + amp_0 = voice->volume [0] * output; + amp_1 = voice->volume [1] * output; + + prev_outx = output; + raw_voice->outx = output >> 8; + #endif /* CPU_* */ + } + #else /* SPCNOINTERP */ + /* two-point linear interpolation */ + #ifdef CPU_COLDFIRE + int amp_0 = (int16_t)this->noise; + int amp_1; + + if ( (this->r.g.noise_enables & vbit) == 0 ) + { + uint32_t f = voice->position; + int32_t y0; + + /** + * Formula (fastest found so far of MANY): + * output = y0 + f*y1 - f*y0 + */ + asm volatile ( + /* separate fractional and whole parts */ + "move.l %[f], %[y1] \r\n" + "and.l #0xfff, %[f] \r\n" + "lsr.l %[sh], %[y1] \r\n" + /* load samples y0 (upper) & y1 (lower) */ + "move.l 2(%[s], %[y1].l*2), %[y1] \r\n" + /* %acc0 = f*y1 */ + "mac.w %[f]l, %[y1]l, %%acc0 \r\n" + /* %acc0 -= f*y0 */ + "msac.w %[f]l, %[y1]u, %%acc0 \r\n" + /* separate out y0 and sign extend */ + "swap %[y1] \r\n" + "movea.w %[y1], %[y0] \r\n" + /* fetch result, scale down and add y0 */ + "movclr.l %%acc0, %[y1] \r\n" + /* output = y0 + (result >> 12) */ + "asr.l %[sh], %[y1] \r\n" + "add.l %[y0], %[y1] \r\n" + : [f]"+d"(f), [y0]"=&a"(y0), [y1]"=&d"(amp_0) + : [s]"a"(voice->samples), [sh]"d"(12)); + } + + /* apply voice envelope to output */ + asm volatile ( + "mac.w %[out]l, %[envx]l, %%acc0 \r\n" + : + : [out]"r"(amp_0), [envx]"r"(voice->envx)); + + /* advance voice position */ + voice->position += rate; + + /* fetch output, scale and apply left and right + voice volume */ + asm volatile ( + "movclr.l %%acc0, %[out] \r\n" + "asr.l %[sh], %[out] \r\n" + "mac.l %[vvol_0], %[out], %%acc0 \r\n" + "mac.l %[vvol_1], %[out], %%acc1 \r\n" + : [out]"=&d"(amp_0) + : [vvol_0]"r"((int)voice->volume[0]), + [vvol_1]"r"((int)voice->volume[1]), + [sh]"d"(11)); + + /* save this output into previous, scale and save in + output register */ + prev_outx = amp_0; + raw_voice->outx = amp_0 >> 8; + + /* fetch final voice output */ + asm volatile ( + "movclr.l %%acc0, %[amp_0] \r\n" + "movclr.l %%acc1, %[amp_1] \r\n" + : [amp_0]"=r"(amp_0), [amp_1]"=r"(amp_1)); + #elif defined (CPU_ARM) + int amp_0, amp_1; + + if ( (this->r.g.noise_enables & vbit) != 0 ) + { + amp_0 = *(int16_t *)&this->noise; + } + else + { + uint32_t f = voice->position; + amp_0 = (uint32_t)voice->samples; + + asm volatile( + "mov %[y1], %[f], lsr #12 \r\n" + "eor %[f], %[f], %[y1], lsl #12 \r\n" + "add %[y1], %[y0], %[y1], lsl #1 \r\n" + "ldrsh %[y0], [%[y1], #2] \r\n" + "ldrsh %[y1], [%[y1], #4] \r\n" + "sub %[y1], %[y1], %[y0] \r\n" + "mul %[f], %[y1], %[f] \r\n" + "add %[y0], %[y0], %[f], asr #12 \r\n" + : [f]"+r"(f), [y0]"+r"(amp_0), [y1]"=&r"(amp_1)); + } + + voice->position += rate; + + asm volatile( + "mul %[amp_1], %[amp_0], %[envx] \r\n" + "mov %[amp_0], %[amp_1], asr #11 \r\n" + "mov %[amp_1], %[amp_0], asr #8 \r\n" + : [amp_0]"+r"(amp_0), [amp_1]"=r"(amp_1) + : [envx]"r"(voice->envx)); + + prev_outx = amp_0; + raw_voice->outx = (int8_t)amp_1; + + asm volatile( + "mul %[amp_1], %[amp_0], %[vol_1] \r\n" + "mul %[amp_0], %[vol_0], %[amp_0] \r\n" + : [amp_0]"+r"(amp_0), [amp_1]"=&r"(amp_1) + : [vol_0]"r"((int)voice->volume[0]), + [vol_1]"r"((int)voice->volume[1])); + #else /* Unoptimized CPU */ + int output; + + if ( (this->r.g.noise_enables & vbit) == 0 ) + { + int const fraction = voice->position & 0xfff; + short const* const pos = (voice->samples + (voice->position >> 12)) + 1; + output = pos[0] + ((fraction * (pos[1] - pos[0])) >> 12); + } else { + output = *(int16_t *)&this->noise; + } + + voice->position += rate; + + output = (output * voice->envx) >> 11; + + /* duplicated here to give compiler more to run in parallel */ + int amp_0 = voice->volume [0] * output; + int amp_1 = voice->volume [1] * output; + + prev_outx = output; + raw_voice->outx = (int8_t) (output >> 8); + #endif /* CPU_* */ + #endif /* SPCNOINTERP */ + + #if SPC_BRRCACHE + if ( voice->position >= voice->wave_end ) + { + long loop_len = voice->wave_loop << 12; + voice->position -= loop_len; + this->r.g.wave_ended |= vbit; + if ( !loop_len ) + { + this->keys_down ^= vbit; + raw_voice->envx = 0; + voice->envx = 0; + } + } + #endif +#if 0 + EXIT_TIMER(dsp_gen); + + ENTER_TIMER(dsp_mix); +#endif + chans_0 += amp_0; + chans_1 += amp_1; + #if !SPC_NOECHO + if ( this->r.g.echo_ons & vbit ) + { + echo_0 += amp_0; + echo_1 += amp_1; + } + #endif +#if 0 + EXIT_TIMER(dsp_mix); +#endif + } + /* end of voice loop */ + + #if !SPC_NOECHO + #ifdef CPU_COLDFIRE + /* Read feedback from echo buffer */ + int echo_pos = this->echo_pos; + uint8_t* const echo_ptr = RAM + ((echo_start + echo_pos) & 0xFFFF); + echo_pos += 4; + if ( echo_pos >= echo_wrap ) + echo_pos = 0; + this->echo_pos = echo_pos; + int fb = swap_odd_even32(*(int32_t *)echo_ptr); + int out_0, out_1; + + /* Keep last 8 samples */ + *this->last_fir_ptr = fb; + this->last_fir_ptr = this->fir_ptr; + + /* Apply echo FIR filter to output samples read from echo buffer - + circular buffer is hardware incremented and masked; FIR + coefficients and buffer history are loaded in parallel with + multiply accumulate operations. Shift left by one here and once + again when calculating feedback to have sample values justified + to bit 31 in the output to ease endian swap, interleaving and + clamping before placing result in the program's echo buffer. */ + int _0, _1, _2; + asm volatile ( + "move.l (%[fir_c]) , %[_2] \r\n" + "mac.w %[fb]u, %[_2]u, <<, (%[fir_p])+&, %[_0], %%acc0 \r\n" + "mac.w %[fb]l, %[_2]u, <<, (%[fir_p])& , %[_1], %%acc1 \r\n" + "mac.w %[_0]u, %[_2]l, << , %%acc0 \r\n" + "mac.w %[_0]l, %[_2]l, <<, 4(%[fir_c]) , %[_2], %%acc1 \r\n" + "mac.w %[_1]u, %[_2]u, <<, 4(%[fir_p])& , %[_0], %%acc0 \r\n" + "mac.w %[_1]l, %[_2]u, <<, 8(%[fir_p])& , %[_1], %%acc1 \r\n" + "mac.w %[_0]u, %[_2]l, << , %%acc0 \r\n" + "mac.w %[_0]l, %[_2]l, <<, 8(%[fir_c]) , %[_2], %%acc1 \r\n" + "mac.w %[_1]u, %[_2]u, <<, 12(%[fir_p])& , %[_0], %%acc0 \r\n" + "mac.w %[_1]l, %[_2]u, <<, 16(%[fir_p])& , %[_1], %%acc1 \r\n" + "mac.w %[_0]u, %[_2]l, << , %%acc0 \r\n" + "mac.w %[_0]l, %[_2]l, <<, 12(%[fir_c]) , %[_2], %%acc1 \r\n" + "mac.w %[_1]u, %[_2]u, <<, 20(%[fir_p])& , %[_0], %%acc0 \r\n" + "mac.w %[_1]l, %[_2]u, << , %%acc1 \r\n" + "mac.w %[_0]u, %[_2]l, << , %%acc0 \r\n" + "mac.w %[_0]l, %[_2]l, << , %%acc1 \r\n" + : [_0]"=&r"(_0), [_1]"=&r"(_1), [_2]"=&r"(_2), + [fir_p]"+a"(this->fir_ptr) + : [fir_c]"a"(this->fir_coeff), [fb]"r"(fb) + ); + + /* Generate output */ + asm volatile ( + /* fetch filter results _after_ gcc loads asm + block parameters to eliminate emac stalls */ + "movclr.l %%acc0, %[out_0] \r\n" + "movclr.l %%acc1, %[out_1] \r\n" + /* apply global volume */ + "mac.l %[chans_0], %[gv_0] , %%acc2 \r\n" + "mac.l %[chans_1], %[gv_1] , %%acc3 \r\n" + /* apply echo volume and add to final output */ + "mac.l %[ev_0], %[out_0], >>, %%acc2 \r\n" + "mac.l %[ev_1], %[out_1], >>, %%acc3 \r\n" + : [out_0]"=&r"(out_0), [out_1]"=&r"(out_1) + : [chans_0]"r"(chans_0), [gv_0]"r"(global_vol_0), + [ev_0]"r"((int)this->r.g.echo_volume_0), + [chans_1]"r"(chans_1), [gv_1]"r"(global_vol_1), + [ev_1]"r"((int)this->r.g.echo_volume_1) + ); + + /* Feedback into echo buffer */ + if ( !(this->r.g.flags & 0x20) ) + { + int sh = 1 << 9; + + asm volatile ( + /* scale echo voices; saturate if overflow */ + "mac.l %[sh], %[e1] , %%acc1 \r\n" + "mac.l %[sh], %[e0] , %%acc0 \r\n" + /* add scaled output from FIR filter */ + "mac.l %[out_1], %[ef], <<, %%acc1 \r\n" + "mac.l %[out_0], %[ef], <<, %%acc0 \r\n" + /* swap and fetch feedback results - simply + swap_odd_even32 mixed in between macs and + movclrs to mitigate stall issues */ + "move.l #0x00ff00ff, %[sh] \r\n" + "movclr.l %%acc1, %[e1] \r\n" + "swap %[e1] \r\n" + "movclr.l %%acc0, %[e0] \r\n" + "move.w %[e1], %[e0] \r\n" + "and.l %[e0], %[sh] \r\n" + "eor.l %[sh], %[e0] \r\n" + "lsl.l #8, %[sh] \r\n" + "lsr.l #8, %[e0] \r\n" + "or.l %[sh], %[e0] \r\n" + /* save final feedback into echo buffer */ + "move.l %[e0], (%[echo_ptr]) \r\n" + : [e0]"+d"(echo_0), [e1]"+d"(echo_1), [sh]"+d"(sh) + : [out_0]"r"(out_0), [out_1]"r"(out_1), + [ef]"r"((int)this->r.g.echo_feedback), + [echo_ptr]"a"((int32_t *)echo_ptr) + ); + } + + /* Output final samples */ + asm volatile ( + /* fetch output saved in %acc2 and %acc3 */ + "movclr.l %%acc2, %[out_0] \r\n" + "movclr.l %%acc3, %[out_1] \r\n" + /* scale right by global_muting shift */ + "asr.l %[gm], %[out_0] \r\n" + "asr.l %[gm], %[out_1] \r\n" + : [out_0]"=&d"(out_0), [out_1]"=&d"(out_1) + : [gm]"d"(global_muting) + ); + + out_buf [ 0] = out_0; + out_buf [WAV_CHUNK_SIZE] = out_1; + out_buf ++; + #elif defined (CPU_ARM) + /* Read feedback from echo buffer */ + int echo_pos = this->echo_pos; + uint8_t* const echo_ptr = RAM + + ((this->r.g.echo_page * 0x100 + echo_pos) & 0xFFFF); + echo_pos += 4; + if ( echo_pos >= (this->r.g.echo_delay & 15) * 0x800 ) + echo_pos = 0; + this->echo_pos = echo_pos; + + #if ARM_ARCH >= 6 + int32_t *fir_ptr, *fir_coeff; + int fb_0, fb_1; + + /* Apply FIR */ + + /* Keep last 8 samples */ + asm volatile ( + "ldr %[fb_0], [%[echo_p]] \r\n" + "add %[fir_p], %[t_fir_p], #4 \r\n" + "bic %[t_fir_p], %[fir_p], %[mask] \r\n" + "str %[fb_0], [%[fir_p], #-4] \r\n" + /* duplicate at +8 eliminates wrap checking below */ + "str %[fb_0], [%[fir_p], #28] \r\n" + : [fir_p]"=&r"(fir_ptr), [t_fir_p]"+r"(this->fir_ptr), + [fb_0]"=&r"(fb_0) + : [echo_p]"r"(echo_ptr), [mask]"i"(~FIR_BUF_MASK)); + + fir_coeff = (int32_t *)this->fir_coeff; + + /* Fugly, but the best version found. */ + int _0; + asm volatile ( /* L0R0 = acc0 */ + "ldmia %[fir_p]!, { r2-r5 } \r\n" /* L1R1-L4R4 = r2-r5 */ + "ldmia %[fir_c]!, { r0-r1 } \r\n" /* C0C1-C2C3 = r0-r1 */ + "pkhbt %[_0], %[acc0], r2, asl #16 \r\n" /* L0R0,L1R1->L0L1,R0R1 */ + "pkhtb r2, r2, %[acc0], asr #16 \r\n" + "smuad %[acc0], %[_0], r0 \r\n" /* acc0=L0*C0+L1*C1 */ + "smuad %[acc1], r2, r0 \r\n" /* acc1=R0*C0+R1*C1 */ + "pkhbt %[_0], r3, r4, asl #16 \r\n" /* L2R2,L3R3->L2L3,R2R3 */ + "pkhtb r4, r4, r3, asr #16 \r\n" + "smlad %[acc0], %[_0], r1, %[acc0] \r\n" /* acc0+=L2*C2+L3*C3 */ + "smlad %[acc1], r4, r1, %[acc1] \r\n" /* acc1+=R2*C2+R3*C3 */ + "ldmia %[fir_p], { r2-r4 } \r\n" /* L5R5-L7R7 = r2-r4 */ + "ldmia %[fir_c], { r0-r1 } \r\n" /* C4C5-C6C7 = r0-r1 */ + "pkhbt %[_0], r5, r2, asl #16 \r\n" /* L4R4,L5R5->L4L5,R4R5 */ + "pkhtb r2, r2, r5, asr #16 \r\n" + "smlad %[acc0], %[_0], r0, %[acc0] \r\n" /* acc0+=L4*C4+L5*C5 */ + "smlad %[acc1], r2, r0, %[acc1] \r\n" /* acc1+=R4*C4+R5*C5 */ + "pkhbt %[_0], r3, r4, asl #16 \r\n" /* L6R6,L7R7->L6L7,R6R7 */ + "pkhtb r4, r4, r3, asr #16 \r\n" + "smlad %[acc0], %[_0], r1, %[acc0] \r\n" /* acc0+=L6*C6+L7*C7 */ + "smlad %[acc1], r4, r1, %[acc1] \r\n" /* acc1+=R6*C6+R7*C7 */ + : [acc0]"+r"(fb_0), [acc1]"=&r"(fb_1), [_0]"=&r"(_0), + [fir_p]"+r"(fir_ptr), [fir_c]"+r"(fir_coeff) + : + : "r0", "r1", "r2", "r3", "r4", "r5"); + + /* Generate output */ + int amp_0, amp_1; + + asm volatile ( + "mul %[amp_0], %[gvol_0], %[chans_0] \r\n" + "mul %[amp_1], %[gvol_1], %[chans_1] \r\n" + : [amp_0]"=&r"(amp_0), [amp_1]"=r"(amp_1) + : [gvol_0]"r"(global_vol_0), [gvol_1]"r"(global_vol_1), + [chans_0]"r"(chans_0), [chans_1]"r"(chans_1)); + asm volatile ( + "mla %[amp_0], %[fb_0], %[ev_0], %[amp_0] \r\n" + "mla %[amp_1], %[fb_1], %[ev_1], %[amp_1] \r\n" + : [amp_0]"+r"(amp_0), [amp_1]"+r"(amp_1) + : [fb_0]"r"(fb_0), [fb_1]"r"(fb_1), + [ev_0]"r"((int)this->r.g.echo_volume_0), + [ev_1]"r"((int)this->r.g.echo_volume_1)); + + out_buf [ 0] = amp_0 >> global_muting; + out_buf [WAV_CHUNK_SIZE] = amp_1 >> global_muting; + out_buf ++; + + if ( !(this->r.g.flags & 0x20) ) + { + /* Feedback into echo buffer */ + int e0, e1; + + asm volatile ( + "mov %[e0], %[echo_0], asl #7 \r\n" + "mov %[e1], %[echo_1], asl #7 \r\n" + "mla %[e0], %[fb_0], %[efb], %[e0] \r\n" + "mla %[e1], %[fb_1], %[efb], %[e1] \r\n" + : [e0]"=&r"(e0), [e1]"=&r"(e1) + : [echo_0]"r"(echo_0), [echo_1]"r"(echo_1), + [fb_0]"r"(fb_0), [fb_1]"r"(fb_1), + [efb]"r"((int)this->r.g.echo_feedback)); + asm volatile ( + "ssat %[e0], #16, %[e0], asr #14 \r\n" + "ssat %[e1], #16, %[e1], asr #14 \r\n" + "pkhbt %[e0], %[e0], %[e1], lsl #16 \r\n" + "str %[e0], [%[echo_p]] \r\n" + : [e0]"+r"(e0), [e1]"+r"(e1) + : [echo_p]"r"(echo_ptr)); + } + #else /* ARM_ARCH < 6 */ + int fb_0 = GET_LE16SA( echo_ptr ); + int fb_1 = GET_LE16SA( echo_ptr + 2 ); + int32_t *fir_ptr, *fir_coeff; + + /* Keep last 8 samples */ + + /* Apply FIR */ + asm volatile ( + "add %[fir_p], %[t_fir_p], #8 \r\n" + "bic %[t_fir_p], %[fir_p], %[mask] \r\n" + "str %[fb_0], [%[fir_p], #-8] \r\n" + "str %[fb_1], [%[fir_p], #-4] \r\n" + /* duplicate at +8 eliminates wrap checking below */ + "str %[fb_0], [%[fir_p], #56] \r\n" + "str %[fb_1], [%[fir_p], #60] \r\n" + : [fir_p]"=&r"(fir_ptr), [t_fir_p]"+r"(this->fir_ptr) + : [fb_0]"r"(fb_0), [fb_1]"r"(fb_1), [mask]"i"(~FIR_BUF_MASK)); + + fir_coeff = this->fir_coeff; + + asm volatile ( + "ldmia %[fir_c]!, { r0-r1 } \r\n" + "ldmia %[fir_p]!, { r4-r5 } \r\n" + "mul %[fb_0], r0, %[fb_0] \r\n" + "mul %[fb_1], r0, %[fb_1] \r\n" + "mla %[fb_0], r4, r1, %[fb_0] \r\n" + "mla %[fb_1], r5, r1, %[fb_1] \r\n" + "ldmia %[fir_c]!, { r0-r1 } \r\n" + "ldmia %[fir_p]!, { r2-r5 } \r\n" + "mla %[fb_0], r2, r0, %[fb_0] \r\n" + "mla %[fb_1], r3, r0, %[fb_1] \r\n" + "mla %[fb_0], r4, r1, %[fb_0] \r\n" + "mla %[fb_1], r5, r1, %[fb_1] \r\n" + "ldmia %[fir_c]!, { r0-r1 } \r\n" + "ldmia %[fir_p]!, { r2-r5 } \r\n" + "mla %[fb_0], r2, r0, %[fb_0] \r\n" + "mla %[fb_1], r3, r0, %[fb_1] \r\n" + "mla %[fb_0], r4, r1, %[fb_0] \r\n" + "mla %[fb_1], r5, r1, %[fb_1] \r\n" + "ldmia %[fir_c]!, { r0-r1 } \r\n" + "ldmia %[fir_p]!, { r2-r5 } \r\n" + "mla %[fb_0], r2, r0, %[fb_0] \r\n" + "mla %[fb_1], r3, r0, %[fb_1] \r\n" + "mla %[fb_0], r4, r1, %[fb_0] \r\n" + "mla %[fb_1], r5, r1, %[fb_1] \r\n" + : [fb_0]"+r"(fb_0), [fb_1]"+r"(fb_1), + [fir_p]"+r"(fir_ptr), [fir_c]"+r"(fir_coeff) + : + : "r0", "r1", "r2", "r3", "r4", "r5"); + + /* Generate output */ + int amp_0 = (chans_0 * global_vol_0 + fb_0 * this->r.g.echo_volume_0) + >> global_muting; + int amp_1 = (chans_1 * global_vol_1 + fb_1 * this->r.g.echo_volume_1) + >> global_muting; + + out_buf [ 0] = amp_0; + out_buf [WAV_CHUNK_SIZE] = amp_1; + out_buf ++; + + if ( !(this->r.g.flags & 0x20) ) + { + /* Feedback into echo buffer */ + int e0 = (echo_0 >> 7) + ((fb_0 * this->r.g.echo_feedback) >> 14); + int e1 = (echo_1 >> 7) + ((fb_1 * this->r.g.echo_feedback) >> 14); + e0 = CLAMP16( e0 ); + SET_LE16A( echo_ptr , e0 ); + e1 = CLAMP16( e1 ); + SET_LE16A( echo_ptr + 2, e1 ); + } + #endif /* ARM_ARCH */ + #else /* Unoptimized CPU */ + /* Read feedback from echo buffer */ + int echo_pos = this->echo_pos; + uint8_t* const echo_ptr = RAM + + ((this->r.g.echo_page * 0x100 + echo_pos) & 0xFFFF); + echo_pos += 4; + if ( echo_pos >= (this->r.g.echo_delay & 15) * 0x800 ) + echo_pos = 0; + this->echo_pos = echo_pos; + int fb_0 = GET_LE16SA( echo_ptr ); + int fb_1 = GET_LE16SA( echo_ptr + 2 ); + + /* Keep last 8 samples */ + int (* const fir_ptr) [2] = this->fir_buf + this->fir_pos; + this->fir_pos = (this->fir_pos + 1) & (FIR_BUF_HALF - 1); + fir_ptr [ 0] [0] = fb_0; + fir_ptr [ 0] [1] = fb_1; + /* duplicate at +8 eliminates wrap checking below */ + fir_ptr [FIR_BUF_HALF] [0] = fb_0; + fir_ptr [FIR_BUF_HALF] [1] = fb_1; + + /* Apply FIR */ + fb_0 *= this->fir_coeff [0]; + fb_1 *= this->fir_coeff [0]; + + #define DO_PT( i )\ + fb_0 += fir_ptr [i] [0] * this->fir_coeff [i];\ + fb_1 += fir_ptr [i] [1] * this->fir_coeff [i]; + + DO_PT( 1 ) + DO_PT( 2 ) + DO_PT( 3 ) + DO_PT( 4 ) + DO_PT( 5 ) + DO_PT( 6 ) + DO_PT( 7 ) + + /* Generate output */ + int amp_0 = (chans_0 * global_vol_0 + fb_0 * this->r.g.echo_volume_0) + >> global_muting; + int amp_1 = (chans_1 * global_vol_1 + fb_1 * this->r.g.echo_volume_1) + >> global_muting; + out_buf [ 0] = amp_0; + out_buf [WAV_CHUNK_SIZE] = amp_1; + out_buf ++; + + if ( !(this->r.g.flags & 0x20) ) + { + /* Feedback into echo buffer */ + int e0 = (echo_0 >> 7) + ((fb_0 * this->r.g.echo_feedback) >> 14); + int e1 = (echo_1 >> 7) + ((fb_1 * this->r.g.echo_feedback) >> 14); + e0 = CLAMP16( e0 ); + SET_LE16A( echo_ptr , e0 ); + e1 = CLAMP16( e1 ); + SET_LE16A( echo_ptr + 2, e1 ); + } + #endif /* CPU_* */ + #else /* SPCNOECHO == 1*/ + /* Generate output */ + int amp_0 = (chans_0 * global_vol_0) >> global_muting; + int amp_1 = (chans_1 * global_vol_1) >> global_muting; + out_buf [ 0] = amp_0; + out_buf [WAV_CHUNK_SIZE] = amp_1; + out_buf ++; + #endif /* SPCNOECHO */ + } + while ( --count ); +#if 0 + EXIT_TIMER(dsp); + ENTER_TIMER(cpu); +#endif +} + +void DSP_reset( struct Spc_Dsp* this ) +{ + this->keys_down = 0; + this->echo_pos = 0; + this->noise_count = 0; + this->noise = 2; + + this->r.g.flags = 0xE0; /* reset, mute, echo off */ + this->r.g.key_ons = 0; + + ci->memset( this->voice_state, 0, sizeof this->voice_state ); + + int i; + for ( i = VOICE_COUNT; --i >= 0; ) + { + struct voice_t* v = this->voice_state + i; + v->env_mode = state_release; + v->addr = ram.ram; + } + + #if SPC_BRRCACHE + this->oldsize = 0; + for ( i = 0; i < 256; i++ ) + this->wave_entry [i].start_addr = -1; + #endif + +#if defined(CPU_COLDFIRE) + this->fir_ptr = fir_buf; + this->last_fir_ptr = &fir_buf [7]; + ci->memset( fir_buf, 0, sizeof fir_buf ); +#elif defined (CPU_ARM) + this->fir_ptr = fir_buf; + ci->memset( fir_buf, 0, sizeof fir_buf ); +#else + this->fir_pos = 0; + ci->memset( this->fir_buf, 0, sizeof this->fir_buf ); +#endif + + assert( offsetof (struct globals_t,unused9 [2]) == REGISTER_COUNT ); + assert( sizeof (this->r.voice) == REGISTER_COUNT ); +} diff --git a/lib/rbcodec/codecs/libspc/spc_emu.c b/lib/rbcodec/codecs/libspc/spc_emu.c new file mode 100644 index 0000000000..5ea5b0cdeb --- /dev/null +++ b/lib/rbcodec/codecs/libspc/spc_emu.c @@ -0,0 +1,397 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2006-2007 Adam Gashlin (hcs) + * Copyright (C) 2004-2007 Shay Green (blargg) + * Copyright (C) 2002 Brad Martin + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ +#include "codeclib.h" +#include "spc_codec.h" +#include "spc_profiler.h" + +/* lovingly ripped off from Game_Music_Emu 0.5.2. http://www.slack.net/~ant/ */ +/* DSP Based on Brad Martin's OpenSPC DSP emulator */ +/* tag reading from sexyspc by John Brawn (John_Brawn@yahoo.com) and others */ + +struct cpu_ram_t ram IBSS_ATTR_SPC_LARGE_IRAM CACHEALIGN_ATTR; + +/**************** Timers ****************/ + +static void Timer_run_( struct Timer* t, long time ) ICODE_ATTR_SPC; +static void Timer_run_( struct Timer* t, long time ) +{ + /* when disabled, next_tick should always be in the future */ + assert( t->enabled ); + + int elapsed = ((time - t->next_tick) >> t->shift) + 1; + t->next_tick += elapsed << t->shift; + + elapsed += t->count; + if ( elapsed >= t->period ) /* avoid unnecessary division */ + { + int n = elapsed / t->period; + elapsed -= n * t->period; + t->counter = (t->counter + n) & 15; + } + t->count = elapsed; +} + +static inline void Timer_run( struct Timer* t, long time ) +{ + if ( time >= t->next_tick ) + Timer_run_( t, time ); +} + +/**************** SPC emulator ****************/ +/* 1.024 MHz clock / 32000 samples per second */ + +static void SPC_enable_rom( THIS, int enable ) +{ + if ( this->rom_enabled != enable ) + { + this->rom_enabled = enable; + ci->memcpy( RAM + ROM_ADDR, (enable ? this->boot_rom : this->extra_ram), ROM_SIZE ); + /* TODO: ROM can still get overwritten when DSP writes to echo buffer */ + } +} + +void SPC_Init( THIS ) +{ + this->timer [0].shift = 4 + 3; /* 8 kHz */ + this->timer [1].shift = 4 + 3; /* 8 kHz */ + this->timer [2].shift = 4; /* 8 kHz */ + + /* Put STOP instruction around memory to catch PC underflow/overflow. */ + ci->memset( ram.padding1, 0xFF, sizeof ram.padding1 ); + ci->memset( ram.padding2, 0xFF, sizeof ram.padding2 ); + + /* A few tracks read from the last four bytes of IPL ROM */ + this->boot_rom [sizeof this->boot_rom - 2] = 0xC0; + this->boot_rom [sizeof this->boot_rom - 1] = 0xFF; + ci->memset( this->boot_rom, 0, sizeof this->boot_rom - 2 ); + + /* Have DSP in a defined state in case EMU is run and hasn't loaded + * a program yet */ + DSP_reset(&this->dsp); +} + +static void SPC_load_state( THIS, struct cpu_regs_t const* cpu_state, + const void* new_ram, const void* dsp_state ) +{ + ci->memcpy(&(this->r),cpu_state,sizeof this->r); + + /* ram */ + ci->memcpy( RAM, new_ram, sizeof RAM ); + ci->memcpy( this->extra_ram, RAM + ROM_ADDR, sizeof this->extra_ram ); + + /* boot rom (have to force enable_rom() to update it) */ + this->rom_enabled = !(RAM [0xF1] & 0x80); + SPC_enable_rom( this, !this->rom_enabled ); + + /* dsp */ + /* some SPCs rely on DSP immediately generating one sample */ + this->extra_cycles = 32; + DSP_reset( &this->dsp ); + int i; + for ( i = 0; i < REGISTER_COUNT; i++ ) + DSP_write( &this->dsp, i, ((uint8_t const*) dsp_state) [i] ); + + /* timers */ + for ( i = 0; i < TIMER_COUNT; i++ ) + { + struct Timer* t = &this->timer [i]; + + t->next_tick = -EXTRA_CLOCKS; + t->enabled = (RAM [0xF1] >> i) & 1; + if ( !t->enabled ) + t->next_tick = TIMER_DISABLED_TIME; + t->count = 0; + t->counter = RAM [0xFD + i] & 15; + + int p = RAM [0xFA + i]; + if ( !p ) + p = 0x100; + t->period = p; + } + + /* Handle registers which already give 0 when read by + setting RAM and not changing it. + Put STOP instruction in registers which can be read, + to catch attempted execution. */ + RAM [0xF0] = 0; + RAM [0xF1] = 0; + RAM [0xF3] = 0xFF; + RAM [0xFA] = 0; + RAM [0xFB] = 0; + RAM [0xFC] = 0; + RAM [0xFD] = 0xFF; + RAM [0xFE] = 0xFF; + RAM [0xFF] = 0xFF; +} + +static void clear_echo( THIS ) +{ + if ( !(DSP_read( &this->dsp, 0x6C ) & 0x20) ) + { + unsigned addr = 0x100 * DSP_read( &this->dsp, 0x6D ); + size_t size = 0x800 * DSP_read( &this->dsp, 0x7D ); + size_t max_size = sizeof RAM - addr; + if ( size > max_size ) + size = sizeof RAM - addr; + ci->memset( RAM + addr, 0xFF, size ); + } +} + +int SPC_load_spc( THIS, const void* data, long size ) +{ + struct spc_file_t const* spc = (struct spc_file_t const*) data; + struct cpu_regs_t regs; + + if ( size < SPC_FILE_SIZE ) + return -1; + + if ( ci->memcmp( spc->signature, "SNES-SPC700 Sound File Data", 27 ) != 0 ) + return -1; + + regs.pc = spc->pc [1] * 0x100 + spc->pc [0]; + regs.a = spc->a; + regs.x = spc->x; + regs.y = spc->y; + regs.status = spc->status; + regs.sp = spc->sp; + + if ( (unsigned long) size >= sizeof *spc ) + ci->memcpy( this->boot_rom, spc->ipl_rom, sizeof this->boot_rom ); + + SPC_load_state( this, ®s, spc->ram, spc->dsp ); + + clear_echo(this); + + return 0; +} + +/**************** DSP interaction ****************/ +static void SPC_run_dsp_( THIS, long time ) ICODE_ATTR_SPC; +static void SPC_run_dsp_( THIS, long time ) +{ + /* divide by CLOCKS_PER_SAMPLE */ + int count = ((time - this->next_dsp) >> 5) + 1; + int32_t* buf = this->sample_buf; + this->sample_buf = buf + count; + this->next_dsp += count * CLOCKS_PER_SAMPLE; + DSP_run( &this->dsp, count, buf ); +} + +static inline void SPC_run_dsp( THIS, long time ) +{ + if ( time >= this->next_dsp ) + SPC_run_dsp_( this, time ); +} + +int SPC_read( THIS, unsigned addr, long const time ) +{ + int result = RAM [addr]; + + if ( ((unsigned) (addr - 0xF0)) < 0x10 ) + { + assert( 0xF0 <= addr && addr <= 0xFF ); + + /* counters */ + int i = addr - 0xFD; + if ( i >= 0 ) + { + struct Timer* t = &this->timer [i]; + Timer_run( t, time ); + result = t->counter; + t->counter = 0; + } + /* dsp */ + else if ( addr == 0xF3 ) + { + SPC_run_dsp( this, time ); + result = DSP_read( &this->dsp, RAM [0xF2] & 0x7F ); + } + } + return result; +} + +void SPC_write( THIS, unsigned addr, int data, long const time ) +{ + /* first page is very common */ + if ( addr < 0xF0 ) + { + RAM [addr] = (uint8_t) data; + } + else switch ( addr ) + { + /* RAM */ + default: + if ( addr < ROM_ADDR ) + { + RAM [addr] = (uint8_t) data; + } + else + { + this->extra_ram [addr - ROM_ADDR] = (uint8_t) data; + if ( !this->rom_enabled ) + RAM [addr] = (uint8_t) data; + } + break; + + /* DSP */ + /*case 0xF2:*/ /* mapped to RAM */ + case 0xF3: { + SPC_run_dsp( this, time ); + int reg = RAM [0xF2]; + if ( reg < REGISTER_COUNT ) { + DSP_write( &this->dsp, reg, data ); + } + else { + /*dprintf( "DSP write to $%02X\n", (int) reg ); */ + } + break; + } + + case 0xF0: /* Test register */ + /*dprintf( "Wrote $%02X to $F0\n", (int) data ); */ + break; + + /* Config */ + case 0xF1: + { + int i; + /* timers */ + for ( i = 0; i < TIMER_COUNT; i++ ) + { + struct Timer * t = this->timer+i; + if ( !(data & (1 << i)) ) + { + t->enabled = 0; + t->next_tick = TIMER_DISABLED_TIME; + } + else if ( !t->enabled ) + { + /* just enabled */ + t->enabled = 1; + t->counter = 0; + t->count = 0; + t->next_tick = time; + } + } + + /* port clears */ + if ( data & 0x10 ) + { + RAM [0xF4] = 0; + RAM [0xF5] = 0; + } + if ( data & 0x20 ) + { + RAM [0xF6] = 0; + RAM [0xF7] = 0; + } + + SPC_enable_rom( this, (data & 0x80) != 0 ); + break; + } + + /* Ports */ + case 0xF4: + case 0xF5: + case 0xF6: + case 0xF7: + /* to do: handle output ports */ + break; + + /* verified on SNES that these are read/write (RAM) */ + /*case 0xF8: */ + /*case 0xF9: */ + + /* Timers */ + case 0xFA: + case 0xFB: + case 0xFC: { + int i = addr - 0xFA; + struct Timer* t = &this->timer [i]; + if ( (t->period & 0xFF) != data ) + { + Timer_run( t, time ); + this->timer[i].period = data ? data : 0x100; + } + break; + } + + /* Counters (cleared on write) */ + case 0xFD: + case 0xFE: + case 0xFF: + /*dprintf( "Wrote to counter $%02X\n", (int) addr ); */ + this->timer [addr - 0xFD].counter = 0; + break; + } +} + +/**************** Sample generation ****************/ +int SPC_play( THIS, long count, int32_t* out ) +{ + int i; + assert( count % 2 == 0 ); /* output is always in pairs of samples */ + + long start_time = -(count >> 1) * CLOCKS_PER_SAMPLE - EXTRA_CLOCKS; + + /* DSP output is made on-the-fly when DSP registers are read or written */ + this->sample_buf = out; + this->next_dsp = start_time + CLOCKS_PER_SAMPLE; + + /* Localize timer next_tick times and run them to the present to prevent + a running but ignored timer's next_tick from getting too far behind + and overflowing. */ + for ( i = 0; i < TIMER_COUNT; i++ ) + { + struct Timer* t = &this->timer [i]; + if ( t->enabled ) + { + t->next_tick += start_time + EXTRA_CLOCKS; + Timer_run( t, start_time ); + } + } + + /* Run from start_time to 0, pre-advancing by extra cycles from last run */ + this->extra_cycles = CPU_run( this, start_time + this->extra_cycles ) + + EXTRA_CLOCKS; + if ( this->extra_cycles < 0 ) + { + /*dprintf( "Unhandled instruction $%02X, pc = $%04X\n", + (int) CPU_read( r.pc ), (unsigned) r.pc ); */ + + return -1; + } + + /* Catch DSP up to present */ +#if 0 + ENTER_TIMER(cpu); +#endif + SPC_run_dsp( this, -EXTRA_CLOCKS ); +#if 0 + EXIT_TIMER(cpu); +#endif + assert( this->next_dsp == CLOCKS_PER_SAMPLE - EXTRA_CLOCKS ); + assert( this->sample_buf - out == count ); + + return 0; +} diff --git a/lib/rbcodec/codecs/libspc/spc_profiler.c b/lib/rbcodec/codecs/libspc/spc_profiler.c new file mode 100644 index 0000000000..0ced8b5bd3 --- /dev/null +++ b/lib/rbcodec/codecs/libspc/spc_profiler.c @@ -0,0 +1,66 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2006-2007 Adam Gashlin (hcs) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +/* lovingly ripped off from Game_Music_Emu 0.5.2. http://www.slack.net/~ant/ */ +/* DSP Based on Brad Martin's OpenSPC DSP emulator */ +/* tag reading from sexyspc by John Brawn (John_Brawn@yahoo.com) and others */ + +#if defined(SPC_PROFILE) && defined(USEC_TIMER) + +#include "codeclib.h" +#include "spc_codec.h" +#define SPC_DEFINE_PROFILER_TIMERS +#include "spc_profiler.h" + +void reset_profile_timers(void) +{ + RESET_TIMER(total); + RESET_TIMER(render); +#if 0 + RESET_TIMER(cpu); + RESET_TIMER(dsp); + RESET_TIMER(dsp_pregen); + RESET_TIMER(dsp_gen); + RESET_TIMER(dsp_mix); +#endif +} + +void print_timers(char * path) +{ + int logfd = ci->open("/spclog.txt",O_WRONLY|O_CREAT|O_APPEND, 0666); + ci->fdprintf(logfd,"%s:\t",path); + ci->fdprintf(logfd,"%10ld total\t",READ_TIMER(total)); + PRINT_TIMER_PCT(render,total,"render"); +#if 0 + PRINT_TIMER_PCT(cpu,total,"CPU"); + PRINT_TIMER_PCT(dsp,total,"DSP"); + ci->fdprintf(logfd,"("); + PRINT_TIMER_PCT(dsp_pregen,dsp,"pregen"); + PRINT_TIMER_PCT(dsp_gen,dsp,"gen"); + PRINT_TIMER_PCT(dsp_mix,dsp,"mix"); +#endif + ci->fdprintf(logfd,"\n"); + + ci->close(logfd); + logfd=-1; +} + +#endif /* #if defined(SPC_PROFILE) && defined(USEC_TIMER) */ diff --git a/lib/rbcodec/codecs/libspc/spc_profiler.h b/lib/rbcodec/codecs/libspc/spc_profiler.h new file mode 100644 index 0000000000..405ee43ef9 --- /dev/null +++ b/lib/rbcodec/codecs/libspc/spc_profiler.h @@ -0,0 +1,72 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2006-2007 Adam Gashlin (hcs) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +/* a fun simple elapsed time profiler */ +#ifndef _SPC_PROFILER_H_ +#define _SPC_PROFILER_H_ + +#if defined(SPC_PROFILE) && defined(USEC_TIMER) + +#ifdef SPC_DEFINE_PROFILER_TIMERS +#define CREATE_TIMER(name) uint32_t spc_timer_##name##_start,\ + spc_timer_##name##_total +#else +#define CREATE_TIMER(name) extern uint32_t spc_timer_##name##_start,\ + spc_timer_##name##_total +#endif + +#define ENTER_TIMER(name) spc_timer_##name##_start=USEC_TIMER +#define EXIT_TIMER(name) spc_timer_##name##_total+=\ + (USEC_TIMER-spc_timer_##name##_start) +#define READ_TIMER(name) (spc_timer_##name##_total) +#define RESET_TIMER(name) spc_timer_##name##_total=0 + +#define PRINT_TIMER_PCT(bname,tname,nstr) ci->fdprintf( \ + logfd,"%10ld ",READ_TIMER(bname));\ + ci->fdprintf(logfd,"(%3d%%) " nstr "\t",\ + ((uint64_t)READ_TIMER(bname))*100/READ_TIMER(tname)) + +CREATE_TIMER(total); +CREATE_TIMER(render); +#if 0 +CREATE_TIMER(cpu); +CREATE_TIMER(dsp); +CREATE_TIMER(dsp_pregen); +CREATE_TIMER(dsp_gen); +CREATE_TIMER(dsp_mix); +#endif + +void reset_profile_timers(void); +void print_timers(char * path); + +#else + +#define CREATE_TIMER(name) +#define ENTER_TIMER(name) +#define EXIT_TIMER(name) +#define READ_TIMER(name) +#define RESET_TIMER(name) +#define print_timers(path) +#define reset_profile_timers() + +#endif + +#endif /* _SPC_PROFILER_H_ */ diff --git a/lib/rbcodec/codecs/libspeex/COPYING b/lib/rbcodec/codecs/libspeex/COPYING new file mode 100644 index 0000000000..3b6b579cf3 --- /dev/null +++ b/lib/rbcodec/codecs/libspeex/COPYING @@ -0,0 +1,34 @@ +Copyright 2002-2006 + Xiph.org Foundation + Jean-Marc Valin + David Rowe + EpicGames + Analog Devices + Commonwealth Scientific and Industrial Research Organisation (CSIRO) + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +- Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + +- Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the following disclaimer in the +documentation and/or other materials provided with the distribution. + +- Neither the name of the Xiph.org Foundation nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/lib/rbcodec/codecs/libspeex/README.rockbox b/lib/rbcodec/codecs/libspeex/README.rockbox new file mode 100644 index 0000000000..84fff59b60 --- /dev/null +++ b/lib/rbcodec/codecs/libspeex/README.rockbox @@ -0,0 +1,30 @@ +Library: libspeex-1.2beta3 (SVN version 14054) +Imported: 2007-03-12 by Dan Everton + + +This directory contains a local version of libspeex for decoding Ogg/Speex +audio streams. + + +LICENSING INFORMATION + +Speex is available under the terms of the Xiph.Org variant of the BSD +license, which is both an open source and free software license. The +license is described in the COPYING file in this directory. + + +IMPORT DETAILS + +The .[ch] files from speex/libspeex/ and speex/include/ were imported +into Rockbox. This includes the test files. Some hackery was done to +the include files so that they #include properly when built in Rockbox. + +A simple config-speex.h file was added to enable libspeex's fixed-point +integer-only mode and to specify the endianness of the target CPU. Also, +ARM specific optimisations were enabled. + +Since some parts of Speex still rely on functions, a simple +include was created to get these parts to compile. Stub functions can be +found in rockbox.c in this directory. + + diff --git a/lib/rbcodec/codecs/libspeex/SOURCES b/lib/rbcodec/codecs/libspeex/SOURCES new file mode 100644 index 0000000000..575bcb5bae --- /dev/null +++ b/lib/rbcodec/codecs/libspeex/SOURCES @@ -0,0 +1,45 @@ +bits.c +cb_search.c +exc_10_16_table.c +exc_10_32_table.c +exc_20_32_table.c +exc_5_256_table.c +exc_5_64_table.c +exc_8_128_table.c +filters.c +gain_table.c +gain_table_lbr.c +hexc_10_32_table.c +hexc_table.c +high_lsp_tables.c +lsp.c +lsp_tables_nb.c +ltp.c +modes.c +modes_wb.c +nb_celp.c +quant_lsp.c +sb_celp.c +speex.c +speex_callbacks.c +#ifndef ROCKBOX_VOICE_CODEC +#ifndef ROCKBOX_VOICE_ENCODER +oggframing.c +#endif +stereo.c +speex_header.c +#endif +#ifdef ROCKBOX_VOICE_ENCODER +lpc.c +vbr.c +vq.c +window.c +resample.c +#else +#ifdef CPU_COLDFIRE +filters_cf.S +ltp_cf.S +#elif defined(CPU_ARM) +filters_arm4.S +#endif +#endif diff --git a/lib/rbcodec/codecs/libspeex/_kiss_fft_guts.h b/lib/rbcodec/codecs/libspeex/_kiss_fft_guts.h new file mode 100644 index 0000000000..12c055040f --- /dev/null +++ b/lib/rbcodec/codecs/libspeex/_kiss_fft_guts.h @@ -0,0 +1,166 @@ +/* +Copyright (c) 2003-2004, Mark Borgerding + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + * Neither the author nor the names of any contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifdef MIN +#undef MIN +#endif +#define MIN(a,b) ((a)<(b) ? (a):(b)) +#ifdef MAX +#undef MAX +#endif +#define MAX(a,b) ((a)>(b) ? (a):(b)) + +/* kiss_fft.h + defines kiss_fft_scalar as either short or a float type + and defines + typedef struct { kiss_fft_scalar r; kiss_fft_scalar i; }kiss_fft_cpx; */ +#include "kiss_fft.h" +#include "math_approx.h" + +#define MAXFACTORS 32 +/* e.g. an fft of length 128 has 4 factors + as far as kissfft is concerned + 4*4*4*2 + */ + +struct kiss_fft_state{ + int nfft; + int inverse; + int factors[2*MAXFACTORS]; + kiss_fft_cpx twiddles[1]; +}; + +/* + Explanation of macros dealing with complex math: + + C_MUL(m,a,b) : m = a*b + C_FIXDIV( c , div ) : if a fixed point impl., c /= div. noop otherwise + C_SUB( res, a,b) : res = a - b + C_SUBFROM( res , a) : res -= a + C_ADDTO( res , a) : res += a + * */ +#ifdef FIXED_POINT +#include "arch.h" +# define FRACBITS 15 +# define SAMPPROD spx_int32_t +#define SAMP_MAX 32767 + +#define SAMP_MIN -SAMP_MAX + +#if defined(CHECK_OVERFLOW) +# define CHECK_OVERFLOW_OP(a,op,b) \ + if ( (SAMPPROD)(a) op (SAMPPROD)(b) > SAMP_MAX || (SAMPPROD)(a) op (SAMPPROD)(b) < SAMP_MIN ) { \ + fprintf(stderr,"WARNING:overflow @ " __FILE__ "(%d): (%d " #op" %d) = %ld\n",__LINE__,(a),(b),(SAMPPROD)(a) op (SAMPPROD)(b) ); } +#endif + + +# define smul(a,b) ( (SAMPPROD)(a)*(b) ) +# define sround( x ) (kiss_fft_scalar)( ( (x) + (1<<(FRACBITS-1)) ) >> FRACBITS ) + +# define S_MUL(a,b) sround( smul(a,b) ) + +# define C_MUL(m,a,b) \ + do{ (m).r = sround( smul((a).r,(b).r) - smul((a).i,(b).i) ); \ + (m).i = sround( smul((a).r,(b).i) + smul((a).i,(b).r) ); }while(0) + +# define C_MUL4(m,a,b) \ + do{ (m).r = PSHR32( smul((a).r,(b).r) - smul((a).i,(b).i),17 ); \ + (m).i = PSHR32( smul((a).r,(b).i) + smul((a).i,(b).r),17 ); }while(0) + +# define DIVSCALAR(x,k) \ + (x) = sround( smul( x, SAMP_MAX/k ) ) + +# define C_FIXDIV(c,div) \ + do { DIVSCALAR( (c).r , div); \ + DIVSCALAR( (c).i , div); }while (0) + +# define C_MULBYSCALAR( c, s ) \ + do{ (c).r = sround( smul( (c).r , s ) ) ;\ + (c).i = sround( smul( (c).i , s ) ) ; }while(0) + +#else /* not FIXED_POINT*/ + +# define S_MUL(a,b) ( (a)*(b) ) +#define C_MUL(m,a,b) \ + do{ (m).r = (a).r*(b).r - (a).i*(b).i;\ + (m).i = (a).r*(b).i + (a).i*(b).r; }while(0) + +#define C_MUL4(m,a,b) C_MUL(m,a,b) + +# define C_FIXDIV(c,div) /* NOOP */ +# define C_MULBYSCALAR( c, s ) \ + do{ (c).r *= (s);\ + (c).i *= (s); }while(0) +#endif + +#ifndef CHECK_OVERFLOW_OP +# define CHECK_OVERFLOW_OP(a,op,b) /* noop */ +#endif + +#define C_ADD( res, a,b)\ + do { \ + CHECK_OVERFLOW_OP((a).r,+,(b).r)\ + CHECK_OVERFLOW_OP((a).i,+,(b).i)\ + (res).r=(a).r+(b).r; (res).i=(a).i+(b).i; \ + }while(0) +#define C_SUB( res, a,b)\ + do { \ + CHECK_OVERFLOW_OP((a).r,-,(b).r)\ + CHECK_OVERFLOW_OP((a).i,-,(b).i)\ + (res).r=(a).r-(b).r; (res).i=(a).i-(b).i; \ + }while(0) +#define C_ADDTO( res , a)\ + do { \ + CHECK_OVERFLOW_OP((res).r,+,(a).r)\ + CHECK_OVERFLOW_OP((res).i,+,(a).i)\ + (res).r += (a).r; (res).i += (a).i;\ + }while(0) + +#define C_SUBFROM( res , a)\ + do {\ + CHECK_OVERFLOW_OP((res).r,-,(a).r)\ + CHECK_OVERFLOW_OP((res).i,-,(a).i)\ + (res).r -= (a).r; (res).i -= (a).i; \ + }while(0) + + +#ifdef FIXED_POINT +# define KISS_FFT_COS(phase) floor(MIN(32767,MAX(-32767,.5+32768 * cos (phase)))) +# define KISS_FFT_SIN(phase) floor(MIN(32767,MAX(-32767,.5+32768 * sin (phase)))) +# define HALF_OF(x) ((x)>>1) +#elif defined(USE_SIMD) +# define KISS_FFT_COS(phase) _mm_set1_ps( cos(phase) ) +# define KISS_FFT_SIN(phase) _mm_set1_ps( sin(phase) ) +# define HALF_OF(x) ((x)*_mm_set1_ps(.5)) +#else +# define KISS_FFT_COS(phase) (kiss_fft_scalar) cos(phase) +# define KISS_FFT_SIN(phase) (kiss_fft_scalar) sin(phase) +# define HALF_OF(x) ((x)*.5) +#endif + +#define kf_cexp(x,phase) \ + do{ \ + (x)->r = KISS_FFT_COS(phase);\ + (x)->i = KISS_FFT_SIN(phase);\ + }while(0) +#define kf_cexp2(x,phase) \ + do{ \ + (x)->r = spx_cos_norm((phase));\ + (x)->i = spx_cos_norm((phase)-32768);\ +}while(0) + + +/* a debugging function */ +#define pcpx(c)\ + fprintf(stderr,"%g + %gi\n",(double)((c)->r),(double)((c)->i) ) diff --git a/lib/rbcodec/codecs/libspeex/arch.h b/lib/rbcodec/codecs/libspeex/arch.h new file mode 100644 index 0000000000..35b5363837 --- /dev/null +++ b/lib/rbcodec/codecs/libspeex/arch.h @@ -0,0 +1,242 @@ +/* Copyright (C) 2003 Jean-Marc Valin */ +/** + @file arch.h + @brief Various architecture definitions Speex +*/ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + - Neither the name of the Xiph.org Foundation nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef ARCH_H +#define ARCH_H + +#include "config-speex.h" + +#ifndef SPEEX_VERSION +#define SPEEX_MAJOR_VERSION 1 /**< Major Speex version. */ +#define SPEEX_MINOR_VERSION 1 /**< Minor Speex version. */ +#define SPEEX_MICRO_VERSION 15 /**< Micro Speex version. */ +#define SPEEX_EXTRA_VERSION "" /**< Extra Speex version. */ +#define SPEEX_VERSION "speex-1.2beta4" /**< Speex version string. */ +#endif + +/* A couple test to catch stupid option combinations */ +#ifdef FIXED_POINT + +#ifdef FLOATING_POINT +#error You cannot compile as floating point and fixed point at the same time +#endif +#ifdef _USE_SSE +#error SSE is only for floating-point +#endif +#if ((defined (ARM4_ASM)||defined (ARM4_ASM)) && defined(BFIN_ASM)) || (defined (ARM4_ASM)&&defined(ARM5E_ASM)) +#error Make up your mind. What CPU do you have? +#endif +#ifdef VORBIS_PSYCHO +#error Vorbis-psy model currently not implemented in fixed-point +#endif + +#else + +#ifndef FLOATING_POINT +#error You now need to define either FIXED_POINT or FLOATING_POINT +#endif +#if defined (ARM4_ASM) || defined(ARM5E_ASM) || defined(BFIN_ASM) +#error I suppose you can have a [ARM4/ARM5E/Blackfin] that has float instructions? +#endif +#ifdef FIXED_POINT_DEBUG +#error "Don't you think enabling fixed-point is a good thing to do if you want to debug that?" +#endif + + +#endif + +#ifndef OUTSIDE_SPEEX +#include "speex/speex_types.h" +#endif + +#undef ABS +#define ABS(x) ((x) < 0 ? (-(x)) : (x)) /**< Absolute integer value. */ +#define ABS16(x) ((x) < 0 ? (-(x)) : (x)) /**< Absolute 16-bit value. */ +#define MIN16(a,b) ((a) < (b) ? (a) : (b)) /**< Maximum 16-bit value. */ +#define MAX16(a,b) ((a) > (b) ? (a) : (b)) /**< Maximum 16-bit value. */ +#define ABS32(x) ((x) < 0 ? (-(x)) : (x)) /**< Absolute 32-bit value. */ +#define MIN32(a,b) ((a) < (b) ? (a) : (b)) /**< Maximum 32-bit value. */ +#define MAX32(a,b) ((a) > (b) ? (a) : (b)) /**< Maximum 32-bit value. */ + +#ifdef FIXED_POINT + +typedef spx_int16_t spx_word16_t; +typedef spx_int32_t spx_word32_t; +typedef spx_word32_t spx_mem_t; +typedef spx_word16_t spx_coef_t; +typedef spx_word16_t spx_lsp_t; +typedef spx_word32_t spx_sig_t; + +#define Q15ONE 32767 + +#define LPC_SCALING 8192 +#define SIG_SCALING 16384 +#define LSP_SCALING 8192. +#define GAMMA_SCALING 32768. +#define GAIN_SCALING 64 +#define GAIN_SCALING_1 0.015625 + +#define LPC_SHIFT 13 +#define LSP_SHIFT 13 +#define SIG_SHIFT 14 +#define GAIN_SHIFT 6 + +#define VERY_SMALL 0 +#define VERY_LARGE32 ((spx_word32_t)2147483647) +#define VERY_LARGE16 ((spx_word16_t)32767) +#define Q15_ONE ((spx_word16_t)32767) + + +#ifdef FIXED_DEBUG +#include "fixed_debug.h" +#else + +#include "fixed_generic.h" + +#ifdef ARM5E_ASM +#include "fixed_arm5e.h" +#elif defined (ARM4_ASM) +#include "fixed_arm4.h" +#elif defined (BFIN_ASM) +#include "fixed_bfin.h" +#endif + +#endif + + +#else + +typedef float spx_mem_t; +typedef float spx_coef_t; +typedef float spx_lsp_t; +typedef float spx_sig_t; +typedef float spx_word16_t; +typedef float spx_word32_t; + +#define Q15ONE 1.0f +#define LPC_SCALING 1.f +#define SIG_SCALING 1.f +#define LSP_SCALING 1.f +#define GAMMA_SCALING 1.f +#define GAIN_SCALING 1.f +#define GAIN_SCALING_1 1.f + + +#define VERY_SMALL 1e-15f +#define VERY_LARGE32 1e15f +#define VERY_LARGE16 1e15f +#define Q15_ONE ((spx_word16_t)1.f) + +#define QCONST16(x,bits) (x) +#define QCONST32(x,bits) (x) + +#define NEG16(x) (-(x)) +#define NEG32(x) (-(x)) +#define EXTRACT16(x) (x) +#define EXTEND32(x) (x) +#define SHR16(a,shift) (a) +#define SHL16(a,shift) (a) +#define SHR32(a,shift) (a) +#define SHL32(a,shift) (a) +#define PSHR16(a,shift) (a) +#define PSHR32(a,shift) (a) +#define VSHR32(a,shift) (a) +#define SATURATE16(x,a) (x) +#define SATURATE32(x,a) (x) + +#define PSHR(a,shift) (a) +#define SHR(a,shift) (a) +#define SHL(a,shift) (a) +#define SATURATE(x,a) (x) + +#define ADD16(a,b) ((a)+(b)) +#define SUB16(a,b) ((a)-(b)) +#define ADD32(a,b) ((a)+(b)) +#define SUB32(a,b) ((a)-(b)) +#define MULT16_16_16(a,b) ((a)*(b)) +#define MULT16_16(a,b) ((spx_word32_t)(a)*(spx_word32_t)(b)) +#define MAC16_16(c,a,b) ((c)+(spx_word32_t)(a)*(spx_word32_t)(b)) + +#define MULT16_32_Q11(a,b) ((a)*(b)) +#define MULT16_32_Q13(a,b) ((a)*(b)) +#define MULT16_32_Q14(a,b) ((a)*(b)) +#define MULT16_32_Q15(a,b) ((a)*(b)) +#define MULT16_32_P15(a,b) ((a)*(b)) + +#define MAC16_32_Q11(c,a,b) ((c)+(a)*(b)) +#define MAC16_32_Q15(c,a,b) ((c)+(a)*(b)) + +#define MAC16_16_Q11(c,a,b) ((c)+(a)*(b)) +#define MAC16_16_Q13(c,a,b) ((c)+(a)*(b)) +#define MAC16_16_P13(c,a,b) ((c)+(a)*(b)) +#define MULT16_16_Q11_32(a,b) ((a)*(b)) +#define MULT16_16_Q13(a,b) ((a)*(b)) +#define MULT16_16_Q14(a,b) ((a)*(b)) +#define MULT16_16_Q15(a,b) ((a)*(b)) +#define MULT16_16_P15(a,b) ((a)*(b)) +#define MULT16_16_P13(a,b) ((a)*(b)) +#define MULT16_16_P14(a,b) ((a)*(b)) + +#define DIV32_16(a,b) (((spx_word32_t)(a))/(spx_word16_t)(b)) +#define PDIV32_16(a,b) (((spx_word32_t)(a))/(spx_word16_t)(b)) +#define DIV32(a,b) (((spx_word32_t)(a))/(spx_word32_t)(b)) +#define PDIV32(a,b) (((spx_word32_t)(a))/(spx_word32_t)(b)) + + +#endif + + +#if defined (CONFIG_TI_C54X) || defined (CONFIG_TI_C55X) + +/* 2 on TI C5x DSP */ +#define BYTES_PER_CHAR 2 +#define BITS_PER_CHAR 16 +#define LOG2_BITS_PER_CHAR 4 + +#else + +#define BYTES_PER_CHAR 1 +#define BITS_PER_CHAR 8 +#define LOG2_BITS_PER_CHAR 3 + +#endif + + + +#ifdef FIXED_DEBUG +long long spx_mips=0; +#endif + + +#endif diff --git a/lib/rbcodec/codecs/libspeex/bits.c b/lib/rbcodec/codecs/libspeex/bits.c new file mode 100644 index 0000000000..c7a5c14ede --- /dev/null +++ b/lib/rbcodec/codecs/libspeex/bits.c @@ -0,0 +1,399 @@ +/* Copyright (C) 2002 Jean-Marc Valin + File: speex_bits.c + + Handles bit packing/unpacking + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + - Neither the name of the Xiph.org Foundation nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + +#ifdef HAVE_CONFIG_H +#include "config-speex.h" +#endif + +#include "speex/speex_bits.h" +#include "arch.h" +#include "os_support.h" + +/* Maximum size of the bit-stream (for fixed-size allocation) */ +#ifndef MAX_CHARS_PER_FRAME +#define MAX_CHARS_PER_FRAME (2000/BYTES_PER_CHAR) +#endif + +#ifdef ROCKBOX_VOICE_ENCODER +void speex_bits_init(SpeexBits *bits) +{ + bits->chars = (char*)speex_alloc(MAX_CHARS_PER_FRAME); + if (!bits->chars) + return; + + bits->buf_size = MAX_CHARS_PER_FRAME; + + bits->owner=1; + + speex_bits_reset(bits); +} +#endif + +#if 0 +/* Rockbox: unused */ +void speex_bits_init_buffer(SpeexBits *bits, void *buff, int buf_size) +{ + bits->chars = (char*)buff; + bits->buf_size = buf_size; + + bits->owner=0; + + speex_bits_reset(bits); +} +#endif + +void speex_bits_set_bit_buffer(SpeexBits *bits, void *buff, int buf_size) +{ + bits->chars = (char*)buff; + bits->buf_size = buf_size; + + bits->owner=0; + + bits->nbBits=buf_size<charPtr=0; + bits->bitPtr=0; + bits->overflow=0; + +} + +#ifndef ROCKBOX_VOICE_CODEC +void speex_bits_destroy(SpeexBits *bits) +{ + if (bits->owner) + speex_free(bits->chars); + /* Will do something once the allocation is dynamic */ +} +#endif + +#ifdef ROCKBOX_VOICE_ENCODER +void speex_bits_reset(SpeexBits *bits) +{ + /* We only need to clear the first byte now */ + bits->chars[0]=0; + bits->nbBits=0; + bits->charPtr=0; + bits->bitPtr=0; + bits->overflow=0; +} +#endif + +#if 0 +/* Rockbox: unused */ +void speex_bits_rewind(SpeexBits *bits) +{ + bits->charPtr=0; + bits->bitPtr=0; + bits->overflow=0; +} +#endif + +#if !defined(SPEEX_VOICE_ENCODER) && !defined(ROCKBOX_VOICE_CODEC) +void speex_bits_read_from(SpeexBits *bits, char *chars, int len) +{ + int i; + int nchars = len / BYTES_PER_CHAR; + if (nchars > bits->buf_size) + { + speex_notify("Packet is larger than allocated buffer"); + if (bits->owner) + { + char *tmp = (char*)speex_realloc(bits->chars, nchars); + if (tmp) + { + bits->buf_size=nchars; + bits->chars=tmp; + } else { + nchars=bits->buf_size; + speex_warning("Could not resize input buffer: truncating input"); + } + } else { + speex_warning("Do not own input buffer: truncating oversize input"); + nchars=bits->buf_size; + } + } +#if (BYTES_PER_CHAR==2) +/* Swap bytes to proper endian order (could be done externally) */ +#define HTOLS(A) ((((A) >> 8)&0xff)|(((A) & 0xff)<<8)) +#else +#define HTOLS(A) (A) +#endif + for (i=0;ichars[i]=HTOLS(chars[i]); + + bits->nbBits=nchars<charPtr=0; + bits->bitPtr=0; + bits->overflow=0; +} + +static void speex_bits_flush(SpeexBits *bits) +{ + int nchars = ((bits->nbBits+BITS_PER_CHAR-1)>>LOG2_BITS_PER_CHAR); + if (bits->charPtr>0) + SPEEX_MOVE(bits->chars, &bits->chars[bits->charPtr], nchars-bits->charPtr); + bits->nbBits -= bits->charPtr<charPtr=0; +} + +void speex_bits_read_whole_bytes(SpeexBits *bits, char *chars, int nbytes) +{ + int i,pos; + int nchars = nbytes/BYTES_PER_CHAR; + + if (((bits->nbBits+BITS_PER_CHAR-1)>>LOG2_BITS_PER_CHAR)+nchars > bits->buf_size) + { + /* Packet is larger than allocated buffer */ + if (bits->owner) + { + char *tmp = (char*)speex_realloc(bits->chars, (bits->nbBits>>LOG2_BITS_PER_CHAR)+nchars+1); + if (tmp) + { + bits->buf_size=(bits->nbBits>>LOG2_BITS_PER_CHAR)+nchars+1; + bits->chars=tmp; + } else { + nchars=bits->buf_size-(bits->nbBits>>LOG2_BITS_PER_CHAR)-1; + speex_warning("Could not resize input buffer: truncating oversize input"); + } + } else { + speex_warning("Do not own input buffer: truncating oversize input"); + nchars=bits->buf_size; + } + } + + speex_bits_flush(bits); + pos=bits->nbBits>>LOG2_BITS_PER_CHAR; + for (i=0;ichars[pos+i]=HTOLS(chars[i]); + bits->nbBits+=nchars<bitPtr; + charPtr=bits->charPtr; + nbBits=bits->nbBits; + speex_bits_insert_terminator(bits); + bits->bitPtr=bitPtr; + bits->charPtr=charPtr; + bits->nbBits=nbBits; + + if (max_nchars > ((bits->nbBits+BITS_PER_CHAR-1)>>LOG2_BITS_PER_CHAR)) + max_nchars = ((bits->nbBits+BITS_PER_CHAR-1)>>LOG2_BITS_PER_CHAR); + + for (i=0;ichars[i]); + return max_nchars*BYTES_PER_CHAR; +} + +int speex_bits_write_whole_bytes(SpeexBits *bits, char *chars, int max_nbytes) +{ + int max_nchars = max_nbytes/BYTES_PER_CHAR; + int i; + if (max_nchars > ((bits->nbBits)>>LOG2_BITS_PER_CHAR)) + max_nchars = ((bits->nbBits)>>LOG2_BITS_PER_CHAR); + for (i=0;ichars[i]); + + if (bits->bitPtr>0) + bits->chars[0]=bits->chars[max_nchars]; + else + bits->chars[0]=0; + bits->charPtr=0; + bits->nbBits &= (BITS_PER_CHAR-1); + return max_nchars*BYTES_PER_CHAR; +} + +void speex_bits_pack(SpeexBits *bits, int data, int nbBits) +{ + unsigned int d=data; + + if (bits->charPtr+((nbBits+bits->bitPtr)>>LOG2_BITS_PER_CHAR) >= bits->buf_size) + { + speex_notify("Buffer too small to pack bits"); + if (bits->owner) + { + int new_nchars = ((bits->buf_size+5)*3)>>1; + char *tmp = (char*)speex_realloc(bits->chars, new_nchars); + if (tmp) + { + bits->buf_size=new_nchars; + bits->chars=tmp; + } else { + speex_warning("Could not resize input buffer: not packing"); + return; + } + } else { + speex_warning("Do not own input buffer: not packing"); + return; + } + } + + while(nbBits) + { + int bit; + bit = (d>>(nbBits-1))&1; + bits->chars[bits->charPtr] |= bit<<(BITS_PER_CHAR-1-bits->bitPtr); + bits->bitPtr++; + + if (bits->bitPtr==BITS_PER_CHAR) + { + bits->bitPtr=0; + bits->charPtr++; + bits->chars[bits->charPtr] = 0; + } + bits->nbBits++; + nbBits--; + } +} +#endif /* SPEEX_DISABLE_ENCODER */ + +#if 0 +/* Rockbox: unused */ +int speex_bits_unpack_signed(SpeexBits *bits, int nbBits) +{ + unsigned int d=speex_bits_unpack_unsigned(bits,nbBits); + /* If number is negative */ + if (d>>(nbBits-1)) + { + d |= (-1)<charPtr<bitPtr+nbBits>bits->nbBits) + bits->overflow=1; + if (bits->overflow) + return 0; + while(nbBits) + { + d<<=1; + d |= (bits->chars[bits->charPtr]>>(BITS_PER_CHAR-1 - bits->bitPtr))&1; + bits->bitPtr++; + if (bits->bitPtr==BITS_PER_CHAR) + { + bits->bitPtr=0; + bits->charPtr++; + } + nbBits--; + } + return d; +} + +#if 0 +/* Rockbox: unused */ +unsigned int speex_bits_peek_unsigned(SpeexBits *bits, int nbBits) +{ + unsigned int d=0; + int bitPtr, charPtr; + char *chars; + + if ((bits->charPtr<bitPtr+nbBits>bits->nbBits) + bits->overflow=1; + if (bits->overflow) + return 0; + + bitPtr=bits->bitPtr; + charPtr=bits->charPtr; + chars = bits->chars; + while(nbBits) + { + d<<=1; + d |= (chars[charPtr]>>(BITS_PER_CHAR-1 - bitPtr))&1; + bitPtr++; + if (bitPtr==BITS_PER_CHAR) + { + bitPtr=0; + charPtr++; + } + nbBits--; + } + return d; +} +#endif + +int speex_bits_peek(SpeexBits *bits) +{ + if ((bits->charPtr<bitPtr+1>bits->nbBits) + bits->overflow=1; + if (bits->overflow) + return 0; + return (bits->chars[bits->charPtr]>>(BITS_PER_CHAR-1 - bits->bitPtr))&1; +} + +void speex_bits_advance(SpeexBits *bits, int n) +{ + if (((bits->charPtr<bitPtr+n>bits->nbBits) || bits->overflow){ + bits->overflow=1; + return; + } + bits->charPtr += (bits->bitPtr+n) >> LOG2_BITS_PER_CHAR; /* divide by BITS_PER_CHAR */ + bits->bitPtr = (bits->bitPtr+n) & (BITS_PER_CHAR-1); /* modulo by BITS_PER_CHAR */ +} + +int speex_bits_remaining(SpeexBits *bits) +{ + if (bits->overflow) + return -1; + else + return bits->nbBits-((bits->charPtr<bitPtr); +} + +#if 0 +/* Rockbox: unused */ +int speex_bits_nbytes(SpeexBits *bits) +{ + return ((bits->nbBits+BITS_PER_CHAR-1)>>LOG2_BITS_PER_CHAR); +} +#endif + +#ifndef SPEEX_DISABLE_ENCODER +void speex_bits_insert_terminator(SpeexBits *bits) +{ + if (bits->bitPtr) + speex_bits_pack(bits, 0, 1); + while (bits->bitPtr) + speex_bits_pack(bits, 1, 1); +} +#endif /* SPEEX_DISABLE_ENCODER */ diff --git a/lib/rbcodec/codecs/libspeex/cb_search.c b/lib/rbcodec/codecs/libspeex/cb_search.c new file mode 100644 index 0000000000..35fe3a2f67 --- /dev/null +++ b/lib/rbcodec/codecs/libspeex/cb_search.c @@ -0,0 +1,621 @@ +/* Copyright (C) 2002-2006 Jean-Marc Valin + File: cb_search.c + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + - Neither the name of the Xiph.org Foundation nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifdef HAVE_CONFIG_H +#include "config-speex.h" +#endif + +#include "cb_search.h" +#include "filters.h" +#include "stack_alloc.h" +#include "vq.h" +#include "arch.h" +#include "math_approx.h" +#include "os_support.h" + +#ifdef _USE_SSE +#include "cb_search_sse.h" +#elif defined(ARM4_ASM) || defined(ARM5E_ASM) +#include "cb_search_arm4.h" +#elif defined(BFIN_ASM) +#include "cb_search_bfin.h" +#endif + +#ifndef SPEEX_DISABLE_ENCODER +#ifndef OVERRIDE_COMPUTE_WEIGHTED_CODEBOOK +static void compute_weighted_codebook(const signed char *shape_cb, const spx_word16_t *r, spx_word16_t *resp, spx_word16_t *resp2, spx_word32_t *E, int shape_cb_size, int subvect_size, char *stack) +{ + int i, j, k; + VARDECL(spx_word16_t *shape); + ALLOC(shape, subvect_size, spx_word16_t); + for (i=0;isubvect_size; + nb_subvect = params->nb_subvect; + shape_cb_size = 1<shape_bits; + shape_cb = params->shape_cb; + have_sign = params->have_sign; + ALLOC(resp, shape_cb_size*subvect_size, spx_word16_t); +#ifdef _USE_SSE + ALLOC(resp2, (shape_cb_size*subvect_size)>>2, __m128); + ALLOC(E, shape_cb_size>>2, __m128); +#else + resp2 = resp; + ALLOC(E, shape_cb_size, spx_word32_t); +#endif + ALLOC(t, nsf, spx_word16_t); + ALLOC(e, nsf, spx_sig_t); + + /* FIXME: Do we still need to copy the target? */ + SPEEX_COPY(t, target, nsf); + + compute_weighted_codebook(shape_cb, r, resp, resp2, E, shape_cb_size, subvect_size, stack); + + for (i=0;ishape_bits+have_sign); + + { + int rind; + spx_word16_t *res; + spx_word16_t sign=1; + rind = best_index; + if (rind>=shape_cb_size) + { + sign=-1; + rind-=shape_cb_size; + } + res = resp+rind*subvect_size; + if (sign>0) + for (m=0;m=shape_cb_size) + { + sign=-1; + rind-=shape_cb_size; + } + + q=subvect_size-m; +#ifdef FIXED_POINT + g=sign*shape_cb[rind*subvect_size+m]; +#else + g=sign*0.03125*shape_cb[rind*subvect_size+m]; +#endif + target_update(t+subvect_size*(i+1), g, r+q, nsf-subvect_size*(i+1)); + } + } + + /* Update excitation */ + /* FIXME: We could update the excitation directly above */ + for (j=0;j10) + N=10; + /* Complexity isn't as important for the codebooks as it is for the pitch */ + N=(2*N)/3; + if (N<1) + N=1; + if (N==1) + { + split_cb_search_shape_sign_N1(target,ak,awk1,awk2,par,p,nsf,exc,r,bits,stack,update_target); + return; + } + ALLOC(ot2, N, spx_word16_t*); + ALLOC(nt2, N, spx_word16_t*); + ALLOC(oind, N, int*); + ALLOC(nind, N, int*); + + params = (const split_cb_params *) par; + subvect_size = params->subvect_size; + nb_subvect = params->nb_subvect; + shape_cb_size = 1<shape_bits; + shape_cb = params->shape_cb; + have_sign = params->have_sign; + ALLOC(resp, shape_cb_size*subvect_size, spx_word16_t); +#ifdef _USE_SSE + ALLOC(resp2, (shape_cb_size*subvect_size)>>2, __m128); + ALLOC(E, shape_cb_size>>2, __m128); +#else + resp2 = resp; + ALLOC(E, shape_cb_size, spx_word32_t); +#endif + ALLOC(t, nsf, spx_word16_t); + ALLOC(e, nsf, spx_sig_t); + ALLOC(ind, nb_subvect, int); + + ALLOC(tmp, 2*N*nsf, spx_word16_t); + for (i=0;im;n--) + { + ndist[n] = ndist[n-1]; + best_nind[n] = best_nind[n-1]; + best_ntarget[n] = best_ntarget[n-1]; + } + /* n is equal to m here, so they're interchangeable */ + ndist[m] = err; + best_nind[n] = best_index[k]; + best_ntarget[n] = j; + break; + } + } + } + } + if (i==0) + break; + } + for (j=0;j=shape_cb_size) + { + sign=-1; + rind-=shape_cb_size; + } + + q=subvect_size-m; +#ifdef FIXED_POINT + g=sign*shape_cb[rind*subvect_size+m]; +#else + g=sign*0.03125*shape_cb[rind*subvect_size+m]; +#endif + target_update(nt[j]+subvect_size*(i+1), g, r+q, nsf-subvect_size*(i+1)); + } + + for (q=0;qshape_bits+have_sign); + } + + /* Put everything back together */ + for (i=0;i=shape_cb_size) + { + sign=-1; + rind-=shape_cb_size; + } +#ifdef FIXED_POINT + if (sign==1) + { + for (j=0;jsubvect_size; + nb_subvect = params->nb_subvect; + shape_cb = params->shape_cb; + have_sign = params->have_sign; + + ALLOC(ind, nb_subvect, int); + ALLOC(signs, nb_subvect, int); + + /* Decode codewords and gains */ + for (i=0;ishape_bits); + } + /* Compute decoded excitation */ + for (i=0;i>>= 13;\n\t" + "A1 += R0.L*R0.L (IS);\n\t" + "W[P3++] = R0;\n\t" + "P0 += 1;\n\t" + "P2 += 2;\n\t" + "LOOP_END outter%=;\n\t" + "P4 = %4;\n\t" + "R1 = A1;\n\t" + "[P4] = R1;\n\t" + : + : "m" (subvect_size), "m" (shape_cb), "m" (r), "m" (resp), "m" (E) + : "A0", "P0", "P1", "P2", "P3", "P4", "R0", "R1", "R2", "I0", "I1", "L0", + "L1", "A0", "A1", "memory" +#if !(__GNUC__ == 3) + , "LC0", "LC1" /* gcc 3.4 doesn't know about LC registers */ +#endif + ); + shape_cb += subvect_size; + resp += subvect_size; + E++; + } +} + +#define OVERRIDE_TARGET_UPDATE +static inline void target_update(spx_word16_t *t, spx_word16_t g, spx_word16_t *r, int len) +{ + if (!len) + return; + __asm__ __volatile__ + ( + "I0 = %0;\n\t" + "I1 = %1;\n\t" + "L0 = 0;\n\t" + "L1 = 0;\n\t" + "R2 = 4096;\n\t" + "LOOP tupdate%= LC0 = %3;\n\t" + "LOOP_BEGIN tupdate%=;\n\t" + "R0.L = W[I0] || R1.L = W[I1++];\n\t" + "R1 = (A1 = R1.L*%2.L) (IS);\n\t" + "R1 = R1 + R2;\n\t" + "R1 >>>= 13;\n\t" + "R0.L = R0.L - R1.L;\n\t" + "W[I0++] = R0.L;\n\t" + "LOOP_END tupdate%=;\n\t" + : + : "a" (t), "a" (r), "d" (g), "a" (len) + : "R0", "R1", "R2", "A1", "I0", "I1", "L0", "L1" + ); +} diff --git a/lib/rbcodec/codecs/libspeex/cb_search_sse.h b/lib/rbcodec/codecs/libspeex/cb_search_sse.h new file mode 100644 index 0000000000..8b039686fb --- /dev/null +++ b/lib/rbcodec/codecs/libspeex/cb_search_sse.h @@ -0,0 +1,84 @@ +/* Copyright (C) 2004 Jean-Marc Valin */ +/** + @file cb_search_sse.h + @brief Fixed codebook functions (SSE version) +*/ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + - Neither the name of the Xiph.org Foundation nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include + +static inline void _spx_mm_getr_ps (__m128 U, float *__Z, float *__Y, float *__X, float *__W) +{ + union { + float __a[4]; + __m128 __v; + } __u; + + __u.__v = U; + + *__Z = __u.__a[0]; + *__Y = __u.__a[1]; + *__X = __u.__a[2]; + *__W = __u.__a[3]; + +} + +#define OVERRIDE_COMPUTE_WEIGHTED_CODEBOOK +static void compute_weighted_codebook(const signed char *shape_cb, const spx_sig_t *_r, float *resp, __m128 *resp2, __m128 *E, int shape_cb_size, int subvect_size, char *stack) +{ + int i, j, k; + __m128 resj, EE; + VARDECL(__m128 *r); + VARDECL(__m128 *shape); + ALLOC(r, subvect_size, __m128); + ALLOC(shape, subvect_size, __m128); + for(j=0;j>2] = EE; + } +} diff --git a/lib/rbcodec/codecs/libspeex/config-speex.h b/lib/rbcodec/codecs/libspeex/config-speex.h new file mode 100644 index 0000000000..7e0672c150 --- /dev/null +++ b/lib/rbcodec/codecs/libspeex/config-speex.h @@ -0,0 +1,186 @@ +#ifndef ROCKBOX_VOICE_ENCODER +#include "codeclib.h" +#include "autoconf.h" +#else +#define ICODE_ATTR +#define IDATA_ATTR +#define IBSS_ATTR +#define ICONST_ATTR +#endif +/* config.h. Generated from config.h.in by configure. */ +/* config.h.in. Generated from configure.ac by autoheader. */ + +#ifndef ROCKBOX_VOICE_ENCODER + +#define DISABLE_FLOAT_API +#define DISABLE_VBR + +/* Make use of ARM4E assembly optimizations */ +#if defined(CPU_ARM) +#define ARM4_ASM +#endif + +/* Make use of Coldfire assembly optimizations */ +#if defined(CPU_COLDFIRE) +#define COLDFIRE_ASM +#endif + +/* Make use of Blackfin assembly optimizations */ +/* #undef BFIN_ASM */ +#endif /* ROCKBOX_VOICE_ENCODER */ + +/* Disable wideband codec */ +/* #undef DISABLE_WIDEBAND */ + +/* Enable valgrind extra checks */ +/* #undef ENABLE_VALGRIND */ + +/* Debug fixed-point implementation */ +/* #undef FIXED_DEBUG */ + +#ifndef ROCKBOX_VOICE_ENCODER +/* Compile target codec as fixed point */ +#define FIXED_POINT +#else +/* Compile voice clip encoder as floating point */ +#define FLOATING_POINT +#endif + +#ifndef ROCKBOX_VOICE_CODEC +#define EXC_ICONST_ATTR ICONST_ATTR +#define GAIN_ICONST_ATTR ICONST_ATTR +#define HEXC_ICONST_ATTR ICONST_ATTR +#define LSP_ICONST_ATTR ICONST_ATTR +#else +#define EXC_ICONST_ATTR +#define GAIN_ICONST_ATTR +#define HEXC_ICONST_ATTR +#define LSP_ICONST_ATTR +#endif + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_DLFCN_H */ + +/* Define to 1 if you have the `getopt_long' function. */ +#define HAVE_GETOPT_LONG 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_INTTYPES_H 1 + +/* Define to 1 if you have the `m' library (-lm). */ +/* #undef HAVE_LIBM */ + +/* Define to 1 if you have the `winmm' library (-lwinmm). */ +/* #undef HAVE_LIBWINMM */ + +/* Define to 1 if you have the header file. */ +/* #define HAVE_MEMORY_H 1 */ + +/* Define to 1 if you have the header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_AUDIOIO_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SOUNDCARD_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UNISTD_H 1 + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "" + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "" + +/* Reduce precision to 16 bits (EXPERIMENTAL) */ +/* #undef PRECISION16 */ + +/* The size of `int', as computed by sizeof. */ +#define SIZEOF_INT 4 + +/* The size of `long', as computed by sizeof. */ +#define SIZEOF_LONG 4 + +/* The size of `short', as computed by sizeof. */ +#define SIZEOF_SHORT 2 + +/* Version extra */ +#define SPEEX_EXTRA_VERSION "-git" + +/* Version major */ +#define SPEEX_MAJOR_VERSION 1 + +/* Version micro */ +#define SPEEX_MICRO_VERSION 15 + +/* Version minor */ +#define SPEEX_MINOR_VERSION 1 + +/* Complete version string */ +#define SPEEX_VERSION "1.2beta3" + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Enable support for TI C55X DSP */ +/* #undef TI_C55X */ + +/* Make use of alloca */ +/* #undef USE_ALLOCA */ + +/* Use C99 variable-size arrays */ +#define VAR_ARRAYS + +/* Enable Vorbis-style psychoacoustics (EXPERIMENTAL) */ +/* #undef VORBIS_PSYCHO */ + +/* Define to 1 if your processor stores words with the most significant byte + first (like Motorola and SPARC, unlike Intel and VAX). */ +#ifdef ROCKBOX_BIG_ENDIAN +#define WORDS_BIGENDIAN 1 +#endif + +/* Enable SSE support */ +/* #undef _USE_SSE */ + +/* Define to empty if `const' does not conform to ANSI C. */ +/* #undef const */ + +/* Define to `__inline__' or `__inline' if that's what the C compiler + calls it, or to nothing if 'inline' is not supported under any name. */ +#ifndef __cplusplus +/* #undef inline */ +#endif + +/* Define to equivalent of C99 restrict keyword, or to nothing if this is not + supported. Do not define if restrict is supported directly. */ +#define restrict __restrict + +#define RELEASE 1 + diff --git a/lib/rbcodec/codecs/libspeex/exc_10_16_table.c b/lib/rbcodec/codecs/libspeex/exc_10_16_table.c new file mode 100644 index 0000000000..755c5a0b7f --- /dev/null +++ b/lib/rbcodec/codecs/libspeex/exc_10_16_table.c @@ -0,0 +1,51 @@ +/* Copyright (C) 2002 Jean-Marc Valin + File: exc_10_16_table.c + Codebook for excitation in narrowband CELP mode (3200 bps) + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + - Neither the name of the Xiph.org Foundation nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include "config-speex.h" + +const signed char exc_10_16_table[160] EXC_ICONST_ATTR = { +22,39,14,44,11,35,-2,23,-4,6, +46,-28,13,-27,-23,12,4,20,-5,9, +37,-18,-23,23,0,9,-6,-20,4,-1, +-17,-5,-4,17,0,1,9,-2,1,2, +2,-12,8,-25,39,15,9,16,-55,-11, +9,11,5,10,-2,-60,8,13,-6,11, +-16,27,-47,-12,11,1,16,-7,9,-3, +-29,9,-14,25,-19,34,36,12,40,-10, +-3,-24,-14,-37,-21,-35,-2,-36,3,-6, +67,28,6,-17,-3,-12,-16,-15,-17,-7, +-59,-36,-13,1,7,1,2,10,2,11, +13,10,8,-2,7,3,5,4,2,2, +-3,-8,4,-5,6,7,-42,15,35,-2, +-46,38,28,-20,-9,1,7,-3,0,-2, +0,0,0,0,0,0,0,0,0,0, +-15,-28,52,32,5,-5,-17,-20,-10,-1}; diff --git a/lib/rbcodec/codecs/libspeex/exc_10_32_table.c b/lib/rbcodec/codecs/libspeex/exc_10_32_table.c new file mode 100644 index 0000000000..1c94b5511c --- /dev/null +++ b/lib/rbcodec/codecs/libspeex/exc_10_32_table.c @@ -0,0 +1,67 @@ +/* Copyright (C) 2002 Jean-Marc Valin + File: exc_10_32_table.c + Codebook for excitation in narrowband CELP mode (4000 bps) + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + - Neither the name of the Xiph.org Foundation nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include "config-speex.h" + +const signed char exc_10_32_table[320] EXC_ICONST_ATTR = { +7,17,17,27,25,22,12,4,-3,0, +28,-36,39,-24,-15,3,-9,15,-5,10, +31,-28,11,31,-21,9,-11,-11,-2,-7, +-25,14,-22,31,4,-14,19,-12,14,-5, +4,-7,4,-5,9,0,-2,42,-47,-16, +1,8,0,9,23,-57,0,28,-11,6, +-31,55,-45,3,-5,4,2,-2,4,-7, +-3,6,-2,7,-3,12,5,8,54,-10, +8,-7,-8,-24,-25,-27,-14,-5,8,5, +44,23,5,-9,-11,-11,-13,-9,-12,-8, +-29,-8,-22,6,-15,3,-12,-1,-5,-3, +34,-1,29,-16,17,-4,12,2,1,4, +-2,-4,2,-1,11,-3,-52,28,30,-9, +-32,25,44,-20,-24,4,6,-1,0,0, +0,0,0,0,0,0,0,0,0,0, +-25,-10,22,29,13,-13,-22,-13,-4,0, +-4,-16,10,15,-36,-24,28,25,-1,-3, +66,-33,-11,-15,6,0,3,4,-2,5, +24,-20,-47,29,19,-2,-4,-1,0,-1, +-2,3,1,8,-11,5,5,-57,28,28, +0,-16,4,-4,12,-6,-1,2,-20,61, +-9,24,-22,-42,29,6,17,8,4,2, +-65,15,8,10,5,6,5,3,2,-2, +-3,5,-9,4,-5,23,13,23,-3,-63, +3,-5,-4,-6,0,-3,23,-36,-46,9, +5,5,8,4,9,-5,1,-3,10,1, +-6,10,-11,24,-47,31,22,-12,14,-10, +6,11,-7,-7,7,-31,51,-12,-6,7, +6,-17,9,-11,-20,52,-19,3,-6,-6, +-8,-5,23,-41,37,1,-21,10,-14,8, +7,5,-15,-15,23,39,-26,-33,7,2, +-32,-30,-21,-8,4,12,17,15,14,11}; diff --git a/lib/rbcodec/codecs/libspeex/exc_20_32_table.c b/lib/rbcodec/codecs/libspeex/exc_20_32_table.c new file mode 100644 index 0000000000..40dbb34e9e --- /dev/null +++ b/lib/rbcodec/codecs/libspeex/exc_20_32_table.c @@ -0,0 +1,67 @@ +/* Copyright (C) 2002 Jean-Marc Valin + File: exc_20_32_table.c + Codebook for excitation in narrowband CELP mode (2000 bps) + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + - Neither the name of the Xiph.org Foundation nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include "config-speex.h" + +const signed char exc_20_32_table[640] EXC_ICONST_ATTR = { +12,32,25,46,36,33,9,14,-3,6,1,-8,0,-10,-5,-7,-7,-7,-5,-5, +31,-27,24,-32,-4,10,-11,21,-3,19,23,-9,22,24,-10,-1,-10,-13,-7,-11, +42,-33,31,19,-8,0,-10,-16,1,-21,-17,10,-8,14,8,4,11,-2,5,-2, +-33,11,-16,33,11,-4,9,-4,11,2,6,-5,8,-5,11,-4,-6,26,-36,-16, +0,4,-2,-8,12,6,-1,34,-46,-22,9,9,21,9,5,-66,-5,26,2,10, +13,2,19,9,12,-81,3,13,13,0,-14,22,-35,6,-7,-4,6,-6,10,-6, +-31,38,-33,0,-10,-11,5,-12,12,-17,5,0,-6,13,-9,10,8,25,33,2, +-12,8,-6,10,-2,21,7,17,43,5,11,-7,-9,-20,-36,-20,-23,-4,-4,-3, +27,-9,-9,-49,-39,-38,-11,-9,6,5,23,25,5,3,3,4,1,2,-3,-1, +87,39,17,-21,-9,-19,-9,-15,-13,-14,-17,-11,-10,-11,-8,-6,-1,-3,-3,-1, +-54,-34,-27,-8,-11,-4,-5,0,0,4,8,6,9,7,9,7,6,5,5,5, +48,10,19,-10,12,-1,9,-3,2,5,-3,2,-2,-2,0,-2,-26,6,9,-7, +-16,-9,2,7,7,-5,-43,11,22,-11,-9,34,37,-15,-13,-6,1,-1,1,1, +-64,56,52,-11,-27,5,4,3,1,2,1,3,-1,-4,-4,-10,-7,-4,-4,2, +-1,-7,-7,-12,-10,-15,-9,-5,-5,-11,-16,-13,6,16,4,-13,-16,-10,-4,2, +-47,-13,25,47,19,-14,-20,-8,-17,0,-3,-13,1,6,-17,-14,15,1,10,6, +-24,0,-10,19,-69,-8,14,49,17,-5,33,-29,3,-4,0,2,-8,5,-6,2, +120,-56,-12,-47,23,-9,6,-5,1,2,-5,1,-10,4,-1,-1,4,-1,0,-3, +30,-52,-67,30,22,11,-1,-4,3,0,7,2,0,1,-10,-4,-8,-13,5,1, +1,-1,5,13,-9,-3,-10,-62,22,48,-4,-6,2,3,5,1,1,4,1,13, +3,-20,10,-9,13,-2,-4,9,-20,44,-1,20,-32,-67,19,0,28,11,8,2, +-11,15,-19,-53,31,2,34,10,6,-4,-58,8,10,13,14,1,12,2,0,0, +-128,37,-8,44,-9,26,-3,18,2,6,11,-1,9,1,5,3,0,1,1,2, +12,3,-2,-3,7,25,9,18,-6,-37,3,-8,-16,3,-10,-7,17,-34,-44,11, +17,-15,-3,-16,-1,-13,11,-46,-65,-2,8,13,2,4,4,5,15,5,9,6, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +-9,19,-12,12,-28,38,29,-1,12,2,5,23,-10,3,4,-15,21,-4,3,3, +6,17,-9,-4,-8,-20,26,5,-10,6,1,-19,18,-15,-12,47,-6,-2,-7,-9, +-1,-17,-2,-2,-14,30,-14,2,-7,-4,-1,-12,11,-25,16,-3,-12,11,-7,7, +-17,1,19,-28,31,-7,-10,7,-10,3,12,5,-16,6,24,41,-29,-54,0,1, +7,-1,5,-6,13,10,-4,-8,8,-9,-27,-53,-38,-1,10,19,17,16,12,12, +0,3,-7,-4,13,12,-31,-14,6,-5,3,5,17,43,50,25,10,1,-6,-2}; diff --git a/lib/rbcodec/codecs/libspeex/exc_5_256_table.c b/lib/rbcodec/codecs/libspeex/exc_5_256_table.c new file mode 100644 index 0000000000..1a32057956 --- /dev/null +++ b/lib/rbcodec/codecs/libspeex/exc_5_256_table.c @@ -0,0 +1,291 @@ +/* Copyright (C) 2002 Jean-Marc Valin + File: exc_5_256_table.c + Codebook for excitation in narrowband CELP mode (12800 bps) + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + - Neither the name of the Xiph.org Foundation nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include "config-speex.h" + +const signed char exc_5_256_table[1280] EXC_ICONST_ATTR = { +-8,-37,5,-43,5, +73,61,39,12,-3, +-61,-32,2,42,30, +-3,17,-27,9,34, +20,-1,-5,2,23, +-7,-46,26,53,-47, +20,-2,-33,-89,-51, +-64,27,11,15,-34, +-5,-56,25,-9,-1, +-29,1,40,67,-23, +-16,16,33,19,7, +14,85,22,-10,-10, +-12,-7,-1,52,89, +29,11,-20,-37,-46, +-15,17,-24,-28,24, +2,1,0,23,-101, +23,14,-1,-23,-18, +9,5,-13,38,1, +-28,-28,4,27,51, +-26,34,-40,35,47, +54,38,-54,-26,-6, +42,-25,13,-30,-36, +18,41,-4,-33,23, +-32,-7,-4,51,-3, +17,-52,56,-47,36, +-2,-21,36,10,8, +-33,31,19,9,-5, +-40,10,-9,-21,19, +18,-78,-18,-5,0, +-26,-36,-47,-51,-44, +18,40,27,-2,29, +49,-26,2,32,-54, +30,-73,54,3,-5, +36,22,53,10,-1, +-84,-53,-29,-5,3, +-44,53,-51,4,22, +71,-35,-1,33,-5, +-27,-7,36,17,-23, +-39,16,-9,-55,-15, +-20,39,-35,6,-39, +-14,18,48,-64,-17, +-15,9,39,81,37, +-68,37,47,-21,-6, +-104,13,6,9,-2, +35,8,-23,18,42, +45,21,33,-5,-49, +9,-6,-43,-56,39, +2,-16,-25,87,1, +-3,-9,17,-25,-11, +-9,-1,10,2,-14, +-14,4,-1,-10,28, +-23,40,-32,26,-9, +26,4,-27,-23,3, +42,-60,1,49,-3, +27,10,-52,-40,-2, +18,45,-23,17,-44, +3,-3,17,-46,52, +-40,-47,25,75,31, +-49,53,30,-30,-32, +-36,38,-6,-15,-16, +54,-27,-48,3,38, +-29,-32,-22,-14,-4, +-23,-13,32,-39,9, +8,-45,-13,34,-16, +49,40,32,31,28, +23,23,32,47,59, +-68,8,62,44,25, +-14,-24,-65,-16,36, +67,-25,-38,-21,4, +-33,-2,42,5,-63, +40,11,26,-42,-23, +-61,79,-31,23,-20, +10,-32,53,-25,-36, +10,-26,-5,3,0, +-71,5,-10,-37,1, +-24,21,-54,-17,1, +-29,-25,-15,-27,32, +68,45,-16,-37,-18, +-5,1,0,-77,71, +-6,3,-20,71,-67, +29,-35,10,-30,19, +4,16,17,5,0, +-14,19,2,28,26, +59,3,2,24,39, +55,-50,-45,-18,-17, +33,-35,14,-1,1, +8,87,-35,-29,0, +-27,13,-7,23,-13, +37,-40,50,-35,14, +19,-7,-14,49,54, +-5,22,-2,-29,-8, +-27,38,13,27,48, +12,-41,-21,-15,28, +7,-16,-24,-19,-20, +11,-20,9,2,13, +23,-20,11,27,-27, +71,-69,8,2,-6, +22,12,16,16,9, +-16,-8,-17,1,25, +1,40,-37,-33,66, +94,53,4,-22,-25, +-41,-42,25,35,-16, +-15,57,31,-29,-32, +21,16,-60,45,15, +-1,7,57,-26,-47, +-29,11,8,15,19, +-105,-8,54,27,10, +-17,6,-12,-1,-10, +4,0,23,-10,31, +13,11,10,12,-64, +23,-3,-8,-19,16, +52,24,-40,16,10, +40,5,9,0,-13, +-7,-21,-8,-6,-7, +-21,59,16,-53,18, +-60,11,-47,14,-18, +25,-13,-24,4,-39, +16,-28,54,26,-67, +30,27,-20,-52,20, +-12,55,12,18,-16, +39,-14,-6,-26,56, +-88,-55,12,25,26, +-37,6,75,0,-34, +-81,54,-30,1,-7, +49,-23,-14,21,10, +-62,-58,-57,-47,-34, +15,-4,34,-78,31, +25,-11,7,50,-10, +42,-63,14,-36,-4, +57,55,57,53,42, +-42,-1,15,40,37, +15,25,-11,6,1, +31,-2,-6,-1,-7, +-64,34,28,30,-1, +3,21,0,-88,-12, +-56,25,-28,40,8, +-28,-14,9,12,2, +-6,-17,22,49,-6, +-26,14,28,-20,4, +-12,50,35,40,13, +-38,-58,-29,17,30, +22,60,26,-54,-39, +-12,58,-28,-63,10, +-21,-8,-12,26,-62, +6,-10,-11,-22,-6, +-7,4,1,18,2, +-70,11,14,4,13, +19,-24,-34,24,67, +17,51,-21,13,23, +54,-30,48,1,-13, +80,26,-16,-2,13, +-4,6,-30,29,-24, +73,-58,30,-27,20, +-2,-21,41,45,30, +-27,-3,-5,-18,-20, +-49,-3,-35,10,42, +-19,-67,-53,-11,9, +13,-15,-33,-51,-30, +15,7,25,-30,4, +28,-22,-34,54,-29, +39,-46,20,16,34, +-4,47,75,1,-44, +-55,-24,7,-1,9, +-42,50,-8,-36,41, +68,0,-4,-10,-23, +-15,-50,64,36,-9, +-27,12,25,-38,-47, +-37,32,-49,51,-36, +2,-4,69,-26,19, +7,45,67,46,13, +-63,46,15,-47,4, +-41,13,-6,5,-21, +37,26,-55,-7,33, +-1,-28,10,-17,-64, +-14,0,-36,-17,93, +-3,-9,-66,44,-21, +3,-12,38,-6,-13, +-12,19,13,43,-43, +-10,-12,6,-5,9, +-49,32,-5,2,4, +5,15,-16,10,-21, +8,-62,-8,64,8, +79,-1,-66,-49,-18, +5,40,-5,-30,-45, +1,-6,21,-32,93, +-18,-30,-21,32,21, +-18,22,8,5,-41, +-54,80,22,-10,-7, +-8,-23,-64,66,56, +-14,-30,-41,-46,-14, +-29,-37,27,-14,42, +-2,-9,-29,34,14, +33,-14,22,4,10, +26,26,28,32,23, +-72,-32,3,0,-14, +35,-42,-78,-32,6, +29,-18,-45,-5,7, +-33,-45,-3,-22,-34, +8,-8,4,-51,-25, +-9,59,-78,21,-5, +-25,-48,66,-15,-17, +-24,-49,-13,25,-23, +-64,-6,40,-24,-19, +-11,57,-33,-8,1, +10,-52,-54,28,39, +49,34,-11,-61,-41, +-43,10,15,-15,51, +30,15,-51,32,-34, +-2,-34,14,18,16, +1,1,-3,-3,1, +1,-18,6,16,48, +12,-5,-42,7,36, +48,7,-20,-10,7, +12,2,54,39,-38, +37,54,4,-11,-8, +-46,-10,5,-10,-34, +46,-12,29,-37,39, +36,-11,24,56,17, +14,20,25,0,-25, +-28,55,-7,-5,27, +3,9,-26,-8,6, +-24,-10,-30,-31,-34, +18,4,22,21,40, +-1,-29,-37,-8,-21, +92,-29,11,-3,11, +73,23,22,7,4, +-44,-9,-11,21,-13, +11,9,-78,-1,47, +114,-12,-37,-19,-5, +-11,-22,19,12,-30, +7,38,45,-21,-8, +-9,55,-45,56,-21, +7,17,46,-57,-87, +-6,27,31,31,7, +-56,-12,46,21,-5, +-12,36,3,3,-21, +43,19,12,-7,9, +-14,0,-9,-33,-91, +7,26,3,-11,64, +83,-31,-46,25,2, +9,5,2,2,-1, +20,-17,10,-5,-27, +-8,20,8,-19,16, +-21,-13,-31,5,5, +42,24,9,34,-20, +28,-61,22,11,-39, +64,-20,-1,-30,-9, +-20,24,-25,-24,-29, +22,-60,6,-5,41, +-9,-87,14,34,15, +-57,52,69,15,-3, +-102,58,16,3,6, +60,-75,-32,26,7, +-57,-27,-32,-24,-21, +-29,-16,62,-46,31, +30,-27,-15,7,15}; diff --git a/lib/rbcodec/codecs/libspeex/exc_5_64_table.c b/lib/rbcodec/codecs/libspeex/exc_5_64_table.c new file mode 100644 index 0000000000..7d29f60373 --- /dev/null +++ b/lib/rbcodec/codecs/libspeex/exc_5_64_table.c @@ -0,0 +1,99 @@ +/* Copyright (C) 2002 Jean-Marc Valin + File: exc_5_64_table.c + Codebook for excitation in narrowband CELP mode (9600 bps) + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + - Neither the name of the Xiph.org Foundation nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include "config-speex.h" + +const signed char exc_5_64_table[320] EXC_ICONST_ATTR = { +1,5,-15,49,-66, +-48,-4,50,-44,7, +37,16,-18,25,-26, +-26,-15,19,19,-27, +-47,28,57,5,-17, +-32,-41,68,21,-2, +64,56,8,-16,-13, +-26,-9,-16,11,6, +-39,25,-19,22,-31, +20,-45,55,-43,10, +-16,47,-40,40,-20, +-51,3,-17,-14,-15, +-24,53,-20,-46,46, +27,-68,32,3,-18, +-5,9,-31,16,-9, +-10,-1,-23,48,95, +47,25,-41,-32,-3, +15,-25,-55,36,41, +-27,20,5,13,14, +-22,5,2,-23,18, +46,-15,17,-18,-34, +-5,-8,27,-55,73, +16,2,-1,-17,40, +-78,33,0,2,19, +4,53,-16,-15,-16, +-28,-3,-13,49,8, +-7,-29,27,-13,32, +20,32,-61,16,14, +41,44,40,24,20, +7,4,48,-60,-77, +17,-6,-48,65,-15, +32,-30,-71,-10,-3, +-6,10,-2,-7,-29, +-56,67,-30,7,-5, +86,-6,-10,0,5, +-31,60,34,-38,-3, +24,10,-2,30,23, +24,-41,12,70,-43, +15,-17,6,13,16, +-13,8,30,-15,-8, +5,23,-34,-98,-4, +-13,13,-48,-31,70, +12,31,25,24,-24, +26,-7,33,-16,8, +5,-11,-14,-8,-65, +13,10,-2,-9,0, +-3,-68,5,35,7, +0,-31,-1,-17,-9, +-9,16,-37,-18,-1, +69,-48,-28,22,-21, +-11,5,49,55,23, +-86,-36,16,2,13, +63,-51,30,-11,13, +24,-18,-6,14,-19, +1,41,9,-5,27, +-36,-44,-34,-37,-21, +-26,31,-39,15,43, +5,-8,29,20,-8, +-20,-52,-28,-1,13, +26,-34,-10,-9,27, +-8,8,27,-66,4, +12,-22,49,10,-77, +32,-18,3,-38,12, +-3,-1,2,2,0}; diff --git a/lib/rbcodec/codecs/libspeex/exc_8_128_table.c b/lib/rbcodec/codecs/libspeex/exc_8_128_table.c new file mode 100644 index 0000000000..02a58e052c --- /dev/null +++ b/lib/rbcodec/codecs/libspeex/exc_8_128_table.c @@ -0,0 +1,163 @@ +/* Copyright (C) 2002 Jean-Marc Valin + File: exc_8_128_table.c + Codebook for excitation in narrowband CELP mode (7000 bps) + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + - Neither the name of the Xiph.org Foundation nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include "config-speex.h" + +const signed char exc_8_128_table[1024] EXC_ICONST_ATTR = { +-14,9,13,-32,2,-10,31,-10, +-8,-8,6,-4,-1,10,-64,23, +6,20,13,6,8,-22,16,34, +7,42,-49,-28,5,26,4,-15, +41,34,41,32,33,24,23,14, +8,40,34,4,-24,-41,-19,-15, +13,-13,33,-54,24,27,-44,33, +27,-15,-15,24,-19,14,-36,14, +-9,24,-12,-4,37,-5,16,-34, +5,10,33,-15,-54,-16,12,25, +12,1,2,0,3,-1,-4,-4, +11,2,-56,54,27,-20,13,-6, +-46,-41,-33,-11,-5,7,12,14, +-14,-5,8,20,6,3,4,-8, +-5,-42,11,8,-14,25,-2,2, +13,11,-22,39,-9,9,5,-45, +-9,7,-9,12,-7,34,-17,-102, +7,2,-42,18,35,-9,-34,11, +-5,-2,3,22,46,-52,-25,-9, +-94,8,11,-5,-5,-5,4,-7, +-35,-7,54,5,-32,3,24,-9, +-22,8,65,37,-1,-12,-23,-6, +-9,-28,55,-33,14,-3,2,18, +-60,41,-17,8,-16,17,-11,0, +-11,29,-28,37,9,-53,33,-14, +-9,7,-25,-7,-11,26,-32,-8, +24,-21,22,-19,19,-10,29,-14, +0,0,0,0,0,0,0,0, +-5,-52,10,41,6,-30,-4,16, +32,22,-27,-22,32,-3,-28,-3, +3,-35,6,17,23,21,8,2, +4,-45,-17,14,23,-4,-31,-11, +-3,14,1,19,-11,2,61,-8, +9,-12,7,-10,12,-3,-24,99, +-48,23,50,-37,-5,-23,0,8, +-14,35,-64,-5,46,-25,13,-1, +-49,-19,-15,9,34,50,25,11, +-6,-9,-16,-20,-32,-33,-32,-27, +10,-8,12,-15,56,-14,-32,33, +3,-9,1,65,-9,-9,-10,-2, +-6,-23,9,17,3,-28,13,-32, +4,-2,-10,4,-16,76,12,-52, +6,13,33,-6,4,-14,-9,-3, +1,-15,-16,28,1,-15,11,16, +9,4,-21,-37,-40,-6,22,12, +-15,-23,-14,-17,-16,-9,-10,-9, +13,-39,41,5,-9,16,-38,25, +46,-47,4,49,-14,17,-2,6, +18,5,-6,-33,-22,44,50,-2, +1,3,-6,7,7,-3,-21,38, +-18,34,-14,-41,60,-13,6,16, +-24,35,19,-13,-36,24,3,-17, +-14,-10,36,44,-44,-29,-3,3, +-54,-8,12,55,26,4,-2,-5, +2,-11,22,-23,2,22,1,-25, +-39,66,-49,21,-8,-2,10,-14, +-60,25,6,10,27,-25,16,5, +-2,-9,26,-13,-20,58,-2,7, +52,-9,2,5,-4,-15,23,-1, +-38,23,8,27,-6,0,-27,-7, +39,-10,-14,26,11,-45,-12,9, +-5,34,4,-35,10,43,-22,-11, +56,-7,20,1,10,1,-26,9, +94,11,-27,-14,-13,1,-11,0, +14,-5,-6,-10,-4,-15,-8,-41, +21,-5,1,-28,-8,22,-9,33, +-23,-4,-4,-12,39,4,-7,3, +-60,80,8,-17,2,-6,12,-5, +1,9,15,27,31,30,27,23, +61,47,26,10,-5,-8,-12,-13, +5,-18,25,-15,-4,-15,-11,12, +-2,-2,-16,-2,-6,24,12,11, +-4,9,1,-9,14,-45,57,12, +20,-35,26,11,-64,32,-10,-10, +42,-4,-9,-16,32,24,7,10, +52,-11,-57,29,0,8,0,-6, +17,-17,-56,-40,7,20,18,12, +-6,16,5,7,-1,9,1,10, +29,12,16,13,-2,23,7,9, +-3,-4,-5,18,-64,13,55,-25, +9,-9,24,14,-25,15,-11,-40, +-30,37,1,-19,22,-5,-31,13, +-2,0,7,-4,16,-67,12,66, +-36,24,-8,18,-15,-23,19,0, +-45,-7,4,3,-13,13,35,5, +13,33,10,27,23,0,-7,-11, +43,-74,36,-12,2,5,-8,6, +-33,11,-16,-14,-5,-7,-3,17, +-34,27,-16,11,-9,15,33,-31, +8,-16,7,-6,-7,63,-55,-17, +11,-1,20,-46,34,-30,6,9, +19,28,-9,5,-24,-8,-23,-2, +31,-19,-16,-5,-15,-18,0,26, +18,37,-5,-15,-2,17,5,-27, +21,-33,44,12,-27,-9,17,11, +25,-21,-31,-7,13,33,-8,-25, +-7,7,-10,4,-6,-9,48,-82, +-23,-8,6,11,-23,3,-3,49, +-29,25,31,4,14,16,9,-4, +-18,10,-26,3,5,-44,-9,9, +-47,-55,15,9,28,1,4,-3, +46,6,-6,-38,-29,-31,-15,-6, +3,0,14,-6,8,-54,-50,33, +-5,1,-14,33,-48,26,-4,-5, +-3,-5,-3,-5,-28,-22,77,55, +-1,2,10,10,-9,-14,-66,-49, +11,-36,-6,-20,10,-10,16,12, +4,-1,-16,45,-44,-50,31,-2, +25,42,23,-32,-22,0,11,20, +-40,-35,-40,-36,-32,-26,-21,-13, +52,-22,6,-24,-20,17,-5,-8, +36,-25,-11,21,-26,6,34,-8, +7,20,-3,5,-25,-8,18,-5, +-9,-4,1,-9,20,20,39,48, +-24,9,5,-65,22,29,4,3, +-43,-11,32,-6,9,19,-27,-10, +-47,-14,24,10,-7,-36,-7,-1, +-4,-5,-5,16,53,25,-26,-29, +-4,-12,45,-58,-34,33,-5,2, +-1,27,-48,31,-15,22,-5,4, +7,7,-25,-3,11,-22,16,-12, +8,-3,7,-11,45,14,-73,-19, +56,-46,24,-20,28,-12,-2,-1, +-36,-3,-33,19,-6,7,2,-15, +5,-31,-45,8,35,13,20,0, +-9,48,-13,-43,-3,-13,2,-5, +72,-68,-27,2,1,-2,-7,5, +36,33,-40,-12,-4,-5,23,19}; diff --git a/lib/rbcodec/codecs/libspeex/fftwrap.c b/lib/rbcodec/codecs/libspeex/fftwrap.c new file mode 100644 index 0000000000..2312f755d6 --- /dev/null +++ b/lib/rbcodec/codecs/libspeex/fftwrap.c @@ -0,0 +1,288 @@ +/* Copyright (C) 2005-2006 Jean-Marc Valin + File: fftwrap.c + + Wrapper for various FFTs + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + - Neither the name of the Xiph.org Foundation nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + +#ifdef HAVE_CONFIG_H +#include "config-speex.h" +#endif + +/*#define USE_SMALLFT*/ +#define USE_KISS_FFT + + +#include "arch.h" +#include "os_support.h" + +#define MAX_FFT_SIZE 2048 + +#ifdef FIXED_POINT +static int maximize_range(spx_word16_t *in, spx_word16_t *out, spx_word16_t bound, int len) +{ + int i, shift; + spx_word16_t max_val = 0; + for (i=0;imax_val) + max_val = in[i]; + if (-in[i]>max_val) + max_val = -in[i]; + } + shift=0; + while (max_val <= (bound>>1) && max_val != 0) + { + max_val <<= 1; + shift++; + } + for (i=0;i + +void *spx_fft_init(int size) +{ + struct drft_lookup *table; + table = speex_alloc(sizeof(struct drft_lookup)); + spx_drft_init((struct drft_lookup *)table, size); + return (void*)table; +} + +void spx_fft_destroy(void *table) +{ + spx_drft_clear(table); + speex_free(table); +} + +void spx_fft(void *table, float *in, float *out) +{ + if (in==out) + { + int i; + float scale = 1./((struct drft_lookup *)table)->n; + speex_warning("FFT should not be done in-place"); + for (i=0;i<((struct drft_lookup *)table)->n;i++) + out[i] = scale*in[i]; + } else { + int i; + float scale = 1./((struct drft_lookup *)table)->n; + for (i=0;i<((struct drft_lookup *)table)->n;i++) + out[i] = scale*in[i]; + } + spx_drft_forward((struct drft_lookup *)table, out); +} + +void spx_ifft(void *table, float *in, float *out) +{ + if (in==out) + { + speex_warning("FFT should not be done in-place"); + } else { + int i; + for (i=0;i<((struct drft_lookup *)table)->n;i++) + out[i] = in[i]; + } + spx_drft_backward((struct drft_lookup *)table, out); +} + +#elif defined(USE_KISS_FFT) + +#include "kiss_fftr.h" +#include "kiss_fft.h" + +struct kiss_config { + kiss_fftr_cfg forward; + kiss_fftr_cfg backward; + int N; +}; + +void *spx_fft_init(int size) +{ + struct kiss_config *table; + table = (struct kiss_config*)speex_alloc(sizeof(struct kiss_config)); + table->forward = kiss_fftr_alloc(size,0,NULL,NULL); + table->backward = kiss_fftr_alloc(size,1,NULL,NULL); + table->N = size; + return table; +} + +void spx_fft_destroy(void *table) +{ + struct kiss_config *t = (struct kiss_config *)table; + kiss_fftr_free(t->forward); + kiss_fftr_free(t->backward); + speex_free(table); +} + +#ifdef FIXED_POINT + +void spx_fft(void *table, spx_word16_t *in, spx_word16_t *out) +{ + int shift; + struct kiss_config *t = (struct kiss_config *)table; + shift = maximize_range(in, in, 32000, t->N); + kiss_fftr2(t->forward, in, out); + renorm_range(in, in, shift, t->N); + renorm_range(out, out, shift, t->N); +} + +#else + +void spx_fft(void *table, spx_word16_t *in, spx_word16_t *out) +{ + int i; + float scale; + struct kiss_config *t = (struct kiss_config *)table; + scale = 1./t->N; + kiss_fftr2(t->forward, in, out); + for (i=0;iN;i++) + out[i] *= scale; +} +#endif + +void spx_ifft(void *table, spx_word16_t *in, spx_word16_t *out) +{ + struct kiss_config *t = (struct kiss_config *)table; + kiss_fftri2(t->backward, in, out); +} + + +#else + +#error No other FFT implemented + +#endif + + +#ifdef FIXED_POINT +/*#include "smallft.h"*/ + + +void spx_fft_float(void *table, float *in, float *out) +{ + int i; +#ifdef USE_SMALLFT + int N = ((struct drft_lookup *)table)->n; +#elif defined(USE_KISS_FFT) + int N = ((struct kiss_config *)table)->N; +#else +#endif +#ifdef VAR_ARRAYS + spx_word16_t _in[N]; + spx_word16_t _out[N]; +#else + spx_word16_t _in[MAX_FFT_SIZE]; + spx_word16_t _out[MAX_FFT_SIZE]; +#endif + for (i=0;iN); + scale = 1./((struct kiss_config *)table)->N; + for (i=0;i<((struct kiss_config *)table)->N;i++) + out[i] = scale*in[i]; + spx_drft_forward(&t, out); + spx_drft_clear(&t); + } +#endif +} + +void spx_ifft_float(void *table, float *in, float *out) +{ + int i; +#ifdef USE_SMALLFT + int N = ((struct drft_lookup *)table)->n; +#elif defined(USE_KISS_FFT) + int N = ((struct kiss_config *)table)->N; +#else +#endif +#ifdef VAR_ARRAYS + spx_word16_t _in[N]; + spx_word16_t _out[N]; +#else + spx_word16_t _in[MAX_FFT_SIZE]; + spx_word16_t _out[MAX_FFT_SIZE]; +#endif + for (i=0;iN); + for (i=0;i<((struct kiss_config *)table)->N;i++) + out[i] = in[i]; + spx_drft_backward(&t, out); + spx_drft_clear(&t); + } +#endif +} + +#else + +void spx_fft_float(void *table, float *in, float *out) +{ + spx_fft(table, in, out); +} +void spx_ifft_float(void *table, float *in, float *out) +{ + spx_ifft(table, in, out); +} + +#endif diff --git a/lib/rbcodec/codecs/libspeex/fftwrap.h b/lib/rbcodec/codecs/libspeex/fftwrap.h new file mode 100644 index 0000000000..dfaf489441 --- /dev/null +++ b/lib/rbcodec/codecs/libspeex/fftwrap.h @@ -0,0 +1,58 @@ +/* Copyright (C) 2005 Jean-Marc Valin + File: fftwrap.h + + Wrapper for various FFTs + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + - Neither the name of the Xiph.org Foundation nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + +#ifndef FFTWRAP_H +#define FFTWRAP_H + +#include "arch.h" + +/** Compute tables for an FFT */ +void *spx_fft_init(int size); + +/** Destroy tables for an FFT */ +void spx_fft_destroy(void *table); + +/** Forward (real to half-complex) transform */ +void spx_fft(void *table, spx_word16_t *in, spx_word16_t *out); + +/** Backward (half-complex to real) transform */ +void spx_ifft(void *table, spx_word16_t *in, spx_word16_t *out); + +/** Forward (real to half-complex) transform of float data */ +void spx_fft_float(void *table, float *in, float *out); + +/** Backward (half-complex to real) transform of float data */ +void spx_ifft_float(void *table, float *in, float *out); + +#endif diff --git a/lib/rbcodec/codecs/libspeex/filterbank.c b/lib/rbcodec/codecs/libspeex/filterbank.c new file mode 100644 index 0000000000..d2a8f1af90 --- /dev/null +++ b/lib/rbcodec/codecs/libspeex/filterbank.c @@ -0,0 +1,227 @@ +/* Copyright (C) 2006 Jean-Marc Valin */ +/** + @file filterbank.c + @brief Converting between psd and filterbank + */ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + 3. The name of the author may not be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifdef HAVE_CONFIG_H +#include "config-speex.h" +#endif + +#include "filterbank.h" +#include "arch.h" +#include +#include "math_approx.h" +#include "os_support.h" + +#ifdef FIXED_POINT + +#define toBARK(n) (MULT16_16(26829,spx_atan(SHR32(MULT16_16(97,n),2))) + MULT16_16(4588,spx_atan(MULT16_32_Q15(20,MULT16_16(n,n)))) + MULT16_16(3355,n)) + +#else +#define toBARK(n) (13.1f*atan(.00074f*(n))+2.24f*atan((n)*(n)*1.85e-8f)+1e-4f*(n)) +#endif + +#define toMEL(n) (2595.f*log10(1.f+(n)/700.f)) + +FilterBank *filterbank_new(int banks, spx_word32_t sampling, int len, int type) +{ + FilterBank *bank; + spx_word32_t df; + spx_word32_t max_mel, mel_interval; + int i; + int id1; + int id2; + df = DIV32(SHL32(sampling,15),MULT16_16(2,len)); + max_mel = toBARK(EXTRACT16(sampling/2)); + mel_interval = PDIV32(max_mel,banks-1); + + bank = (FilterBank*)speex_alloc(sizeof(FilterBank)); + bank->nb_banks = banks; + bank->len = len; + bank->bank_left = (int*)speex_alloc(len*sizeof(int)); + bank->bank_right = (int*)speex_alloc(len*sizeof(int)); + bank->filter_left = (spx_word16_t*)speex_alloc(len*sizeof(spx_word16_t)); + bank->filter_right = (spx_word16_t*)speex_alloc(len*sizeof(spx_word16_t)); + /* Think I can safely disable normalisation that for fixed-point (and probably float as well) */ +#ifndef FIXED_POINT + bank->scaling = (float*)speex_alloc(banks*sizeof(float)); +#endif + for (i=0;i max_mel) + break; +#ifdef FIXED_POINT + id1 = DIV32(mel,mel_interval); +#else + id1 = (int)(floor(mel/mel_interval)); +#endif + if (id1>banks-2) + { + id1 = banks-2; + val = Q15_ONE; + } else { + val = DIV32_16(mel - id1*mel_interval,EXTRACT16(PSHR32(mel_interval,15))); + } + id2 = id1+1; + bank->bank_left[i] = id1; + bank->filter_left[i] = SUB16(Q15_ONE,val); + bank->bank_right[i] = id2; + bank->filter_right[i] = val; + } + + /* Think I can safely disable normalisation for fixed-point (and probably float as well) */ +#ifndef FIXED_POINT + for (i=0;inb_banks;i++) + bank->scaling[i] = 0; + for (i=0;ilen;i++) + { + int id = bank->bank_left[i]; + bank->scaling[id] += bank->filter_left[i]; + id = bank->bank_right[i]; + bank->scaling[id] += bank->filter_right[i]; + } + for (i=0;inb_banks;i++) + bank->scaling[i] = Q15_ONE/(bank->scaling[i]); +#endif + return bank; +} + +void filterbank_destroy(FilterBank *bank) +{ + speex_free(bank->bank_left); + speex_free(bank->bank_right); + speex_free(bank->filter_left); + speex_free(bank->filter_right); +#ifndef FIXED_POINT + speex_free(bank->scaling); +#endif + speex_free(bank); +} + +void filterbank_compute_bank32(FilterBank *bank, spx_word32_t *ps, spx_word32_t *mel) +{ + int i; + for (i=0;inb_banks;i++) + mel[i] = 0; + + for (i=0;ilen;i++) + { + int id; + id = bank->bank_left[i]; + mel[id] += MULT16_32_P15(bank->filter_left[i],ps[i]); + id = bank->bank_right[i]; + mel[id] += MULT16_32_P15(bank->filter_right[i],ps[i]); + } + /* Think I can safely disable normalisation that for fixed-point (and probably float as well) */ +#ifndef FIXED_POINT + /*for (i=0;inb_banks;i++) + mel[i] = MULT16_32_P15(Q15(bank->scaling[i]),mel[i]); + */ +#endif +} + +void filterbank_compute_psd16(FilterBank *bank, spx_word16_t *mel, spx_word16_t *ps) +{ + int i; + for (i=0;ilen;i++) + { + spx_word32_t tmp; + int id1, id2; + id1 = bank->bank_left[i]; + id2 = bank->bank_right[i]; + tmp = MULT16_16(mel[id1],bank->filter_left[i]); + tmp += MULT16_16(mel[id2],bank->filter_right[i]); + ps[i] = EXTRACT16(PSHR32(tmp,15)); + } +} + + +#ifndef FIXED_POINT +void filterbank_compute_bank(FilterBank *bank, float *ps, float *mel) +{ + int i; + for (i=0;inb_banks;i++) + mel[i] = 0; + + for (i=0;ilen;i++) + { + int id = bank->bank_left[i]; + mel[id] += bank->filter_left[i]*ps[i]; + id = bank->bank_right[i]; + mel[id] += bank->filter_right[i]*ps[i]; + } + for (i=0;inb_banks;i++) + mel[i] *= bank->scaling[i]; +} + +void filterbank_compute_psd(FilterBank *bank, float *mel, float *ps) +{ + int i; + for (i=0;ilen;i++) + { + int id = bank->bank_left[i]; + ps[i] = mel[id]*bank->filter_left[i]; + id = bank->bank_right[i]; + ps[i] += mel[id]*bank->filter_right[i]; + } +} + +void filterbank_psy_smooth(FilterBank *bank, float *ps, float *mask) +{ + /* Low freq slope: 14 dB/Bark*/ + /* High freq slope: 9 dB/Bark*/ + /* Noise vs tone: 5 dB difference */ + /* FIXME: Temporary kludge */ + float bark[100]; + int i; + /* Assumes 1/3 Bark resolution */ + float decay_low = 0.34145f; + float decay_high = 0.50119f; + filterbank_compute_bank(bank, ps, bark); + for (i=1;inb_banks;i++) + { + /*float decay_high = 13-1.6*log10(bark[i-1]); + decay_high = pow(10,(-decay_high/30.f));*/ + bark[i] = bark[i] + decay_high*bark[i-1]; + } + for (i=bank->nb_banks-2;i>=0;i--) + { + bark[i] = bark[i] + decay_low*bark[i+1]; + } + filterbank_compute_psd(bank, bark, mask); +} + +#endif diff --git a/lib/rbcodec/codecs/libspeex/filterbank.h b/lib/rbcodec/codecs/libspeex/filterbank.h new file mode 100644 index 0000000000..3e889a22f7 --- /dev/null +++ b/lib/rbcodec/codecs/libspeex/filterbank.h @@ -0,0 +1,66 @@ +/* Copyright (C) 2006 Jean-Marc Valin */ +/** + @file filterbank.h + @brief Converting between psd and filterbank + */ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + 3. The name of the author may not be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef FILTERBANK_H +#define FILTERBANK_H + +#include "arch.h" + +typedef struct { + int *bank_left; + int *bank_right; + spx_word16_t *filter_left; + spx_word16_t *filter_right; +#ifndef FIXED_POINT + float *scaling; +#endif + int nb_banks; + int len; +} FilterBank; + + +FilterBank *filterbank_new(int banks, spx_word32_t sampling, int len, int type); + +void filterbank_destroy(FilterBank *bank); + +void filterbank_compute_bank32(FilterBank *bank, spx_word32_t *ps, spx_word32_t *mel); + +void filterbank_compute_psd16(FilterBank *bank, spx_word16_t *mel, spx_word16_t *psd); + +#ifndef FIXED_POINT +void filterbank_compute_bank(FilterBank *bank, float *psd, float *mel); +void filterbank_compute_psd(FilterBank *bank, float *mel, float *psd); +#endif + + +#endif diff --git a/lib/rbcodec/codecs/libspeex/filters.c b/lib/rbcodec/codecs/libspeex/filters.c new file mode 100644 index 0000000000..09f93c2a59 --- /dev/null +++ b/lib/rbcodec/codecs/libspeex/filters.c @@ -0,0 +1,845 @@ +/* Copyright (C) 2002-2006 Jean-Marc Valin + File: filters.c + Various analysis/synthesis filters + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + - Neither the name of the Xiph.org Foundation nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifdef HAVE_CONFIG_H +#include "config-speex.h" +#endif + +#include "filters.h" +#include "stack_alloc.h" +#include "arch.h" +#include "math_approx.h" +#include "ltp.h" +#include + +#ifdef _USE_SSE +#include "filters_sse.h" +#elif defined (ARM4_ASM) || defined(ARM5E_ASM) +#include "filters_arm4.h" +#define OVERRIDE_IIR_MEM16 +#define OVERRIDE_QMF_SYNTH +#define OVERRIDE_SIGNAL_MUL +#elif defined (COLDFIRE_ASM) +#define OVERRIDE_IIR_MEM16 +#define OVERRIDE_QMF_SYNTH +#define OVERRIDE_SIGNAL_MUL +#elif defined (BFIN_ASM) +#include "filters_bfin.h" +#endif + + + +void bw_lpc(spx_word16_t gamma, const spx_coef_t *lpc_in, spx_coef_t *lpc_out, int order) +{ + int i; + spx_word16_t tmp=gamma; + for (i=0;i=min_val && vec[i] <= max_val)) + { + if (vec[i] < min_val) + vec[i] = min_val; + else if (vec[i] > max_val) + vec[i] = max_val; + else /* Has to be NaN */ + vec[i] = 0; + } + } +} + +void highpass(const spx_word16_t *x, spx_word16_t *y, int len, int filtID, spx_mem_t *mem) +{ + int i; +#ifdef FIXED_POINT + static const spx_word16_t Pcoef[5][3] ICONST_ATTR = {{16384, -31313, 14991}, {16384, -31569, 15249}, {16384, -31677, 15328}, {16384, -32313, 15947}, {16384, -22446, 6537}}; + static const spx_word16_t Zcoef[5][3] ICONST_ATTR = {{15672, -31344, 15672}, {15802, -31601, 15802}, {15847, -31694, 15847}, {16162, -32322, 16162}, {14418, -28836, 14418}}; +#else + const spx_word16_t Pcoef[5][3] = {{1.00000f, -1.91120f, 0.91498f}, {1.00000f, -1.92683f, 0.93071f}, {1.00000f, -1.93338f, 0.93553f}, {1.00000f, -1.97226f, 0.97332f}, {1.00000f, -1.37000f, 0.39900f}}; + const spx_word16_t Zcoef[5][3] = {{0.95654f, -1.91309f, 0.95654f}, {0.96446f, -1.92879f, 0.96446f}, {0.96723f, -1.93445f, 0.96723f}, {0.98645f, -1.97277f, 0.98645f}, {0.88000f, -1.76000f, 0.88000f}}; +#endif + const spx_word16_t *den, *num; + if (filtID>4) + filtID=4; + + den = Pcoef[filtID]; num = Zcoef[filtID]; + /*return;*/ + for (i=0;i SHL32(EXTEND32(SIG_SCALING), 8)) + { + spx_word16_t scale_1; + scale = PSHR32(scale, SIG_SHIFT); + scale_1 = EXTRACT16(PDIV32_16(SHL32(EXTEND32(SIG_SCALING),7),scale)); + for (i=0;i SHR32(EXTEND32(SIG_SCALING), 2)) { + spx_word16_t scale_1; + scale = PSHR32(scale, SIG_SHIFT-5); + scale_1 = DIV32_16(SHL32(EXTEND32(SIG_SCALING),3),scale); + for (i=0;i max_val) + max_val = tmp; + } + + sig_shift=0; + while (max_val>16383) + { + sig_shift++; + max_val >>= 1; + } + + for (i=0;i max_val) + max_val = tmp; + } + if (max_val>16383) + { + spx_word32_t sum=0; + for (i=0;i= max_val) + max_val = tmp; + } + + sig_shift=0; + while (max_val>max_scale) + { + sig_shift++; + max_val >>= 1; + } + + for (i=0;i>1; + for (i=0;i>1; + N2 = N>>1; + ALLOC(xx1, M2+N2, spx_word16_t); + ALLOC(xx2, M2+N2, spx_word16_t); + + for (i = 0; i < N2; i++) + xx1[i] = x1[N2-1-i]; + for (i = 0; i < M2; i++) + xx1[N2+i] = mem1[2*i+1]; + for (i = 0; i < N2; i++) + xx2[i] = x2[N2-1-i]; + for (i = 0; i < M2; i++) + xx2[N2+i] = mem2[2*i+1]; + + for (i = 0; i < N2; i += 2) { + spx_sig_t y0, y1, y2, y3; + spx_word16_t x10, x20; + + y0 = y1 = y2 = y3 = 0; + x10 = xx1[N2-2-i]; + x20 = xx2[N2-2-i]; + + for (j = 0; j < M2; j += 2) { + spx_word16_t x11, x21; + spx_word16_t a0, a1; + + a0 = a[2*j]; + a1 = a[2*j+1]; + x11 = xx1[N2-1+j-i]; + x21 = xx2[N2-1+j-i]; + +#ifdef FIXED_POINT + /* We multiply twice by the same coef to avoid overflows */ + y0 = MAC16_16(MAC16_16(y0, a0, x11), NEG16(a0), x21); + y1 = MAC16_16(MAC16_16(y1, a1, x11), a1, x21); + y2 = MAC16_16(MAC16_16(y2, a0, x10), NEG16(a0), x20); + y3 = MAC16_16(MAC16_16(y3, a1, x10), a1, x20); +#else + y0 = ADD32(y0,MULT16_16(a0, x11-x21)); + y1 = ADD32(y1,MULT16_16(a1, x11+x21)); + y2 = ADD32(y2,MULT16_16(a0, x10-x20)); + y3 = ADD32(y3,MULT16_16(a1, x10+x20)); +#endif + a0 = a[2*j+2]; + a1 = a[2*j+3]; + x10 = xx1[N2+j-i]; + x20 = xx2[N2+j-i]; + +#ifdef FIXED_POINT + /* We multiply twice by the same coef to avoid overflows */ + y0 = MAC16_16(MAC16_16(y0, a0, x10), NEG16(a0), x20); + y1 = MAC16_16(MAC16_16(y1, a1, x10), a1, x20); + y2 = MAC16_16(MAC16_16(y2, a0, x11), NEG16(a0), x21); + y3 = MAC16_16(MAC16_16(y3, a1, x11), a1, x21); +#else + y0 = ADD32(y0,MULT16_16(a0, x10-x20)); + y1 = ADD32(y1,MULT16_16(a1, x10+x20)); + y2 = ADD32(y2,MULT16_16(a0, x11-x21)); + y3 = ADD32(y3,MULT16_16(a1, x11+x21)); +#endif + } +#ifdef FIXED_POINT + y[2*i] = EXTRACT16(SATURATE32(PSHR32(y0,15),32767)); + y[2*i+1] = EXTRACT16(SATURATE32(PSHR32(y1,15),32767)); + y[2*i+2] = EXTRACT16(SATURATE32(PSHR32(y2,15),32767)); + y[2*i+3] = EXTRACT16(SATURATE32(PSHR32(y3,15),32767)); +#else + /* Normalize up explicitly if we're in float */ + y[2*i] = 2.f*y0; + y[2*i+1] = 2.f*y1; + y[2*i+2] = 2.f*y2; + y[2*i+3] = 2.f*y3; +#endif + } + + for (i = 0; i < M2; i++) + mem1[2*i+1] = xx1[i]; + for (i = 0; i < M2; i++) + mem2[2*i+1] = xx2[i]; +} +#endif + +#ifdef FIXED_POINT +#if 0 +const spx_word16_t shift_filt[3][7] = {{-33, 1043, -4551, 19959, 19959, -4551, 1043}, + {-98, 1133, -4425, 29179, 8895, -2328, 444}, + {444, -2328, 8895, 29179, -4425, 1133, -98}}; +#else +const spx_word16_t shift_filt[3][7] = {{-390, 1540, -4993, 20123, 20123, -4993, 1540}, + {-1064, 2817, -6694, 31589, 6837, -990, -209}, + {-209, -990, 6837, 31589, -6694, 2817, -1064}}; +#endif +#else +#if 0 +const float shift_filt[3][7] = {{-9.9369e-04, 3.1831e-02, -1.3889e-01, 6.0910e-01, 6.0910e-01, -1.3889e-01, 3.1831e-02}, + {-0.0029937, 0.0345613, -0.1350474, 0.8904793, 0.2714479, -0.0710304, 0.0135403}, + {0.0135403, -0.0710304, 0.2714479, 0.8904793, -0.1350474, 0.0345613, -0.0029937}}; +#else +const float shift_filt[3][7] = {{-0.011915f, 0.046995f, -0.152373f, 0.614108f, 0.614108f, -0.152373f, 0.046995f}, + {-0.0324855f, 0.0859768f, -0.2042986f, 0.9640297f, 0.2086420f, -0.0302054f, -0.0063646f}, + {-0.0063646f, -0.0302054f, 0.2086420f, 0.9640297f, -0.2042986f, 0.0859768f, -0.0324855f}}; +#endif +#endif + +static int interp_pitch( +spx_word16_t *exc, /*decoded excitation*/ +spx_word16_t *interp, /*decoded excitation*/ +int pitch, /*pitch period*/ +int len +) +{ + int i,j,k; + spx_word32_t corr[4][7]; + spx_word32_t maxcorr; + int maxi, maxj; + for (i=0;i<7;i++) + { + corr[0][i] = inner_prod(exc, exc-pitch-3+i, len); + } + for (i=0;i<3;i++) + { + for (j=0;j<7;j++) + { + int i1, i2; + spx_word32_t tmp=0; + i1 = 3-j; + if (i1<0) + i1 = 0; + i2 = 10-j; + if (i2>7) + i2 = 7; + for (k=i1;k maxcorr) + { + maxcorr = corr[i][j]; + maxi=i; + maxj=j; + } + } + } + for (i=0;i0) + { + for (k=0;k<7;k++) + { + tmp += MULT16_16(exc[i-(pitch-maxj+3)+k-3],shift_filt[maxi-1][k]); + } + } else { + tmp = SHL32(exc[i-(pitch-maxj+3)],15); + } + interp[i] = PSHR32(tmp,15); + } + return pitch-maxj+3; +} + +void multicomb( +spx_word16_t *exc, /*decoded excitation*/ +spx_word16_t *new_exc, /*enhanced excitation*/ +spx_coef_t *ak, /*LPC filter coefs*/ +int p, /*LPC order*/ +int nsf, /*sub-frame size*/ +int pitch, /*pitch period*/ +int max_pitch, +spx_word16_t comb_gain, /*gain of comb filter*/ +char *stack +) +{ + (void)ak; + (void)p; + (void)stack; + int i; + VARDECL(spx_word16_t *iexc); + spx_word16_t old_ener, new_ener; + int corr_pitch; + + spx_word16_t iexc0_mag, iexc1_mag, exc_mag; + spx_word32_t corr0, corr1; + spx_word16_t gain0, gain1; + spx_word16_t pgain1, pgain2; + spx_word16_t c1, c2; + spx_word16_t g1, g2; + spx_word16_t ngain; + spx_word16_t gg1, gg2; +#ifdef FIXED_POINT + int scaledown=0; +#endif +#if 0 /* Set to 1 to enable full pitch search */ + int nol_pitch[6]; + spx_word16_t nol_pitch_coef[6]; + spx_word16_t ol_pitch_coef; + open_loop_nbest_pitch(exc, 20, 120, nsf, + nol_pitch, nol_pitch_coef, 6, stack); + corr_pitch=nol_pitch[0]; + ol_pitch_coef = nol_pitch_coef[0]; + /*Try to remove pitch multiples*/ + for (i=1;i<6;i++) + { +#ifdef FIXED_POINT + if ((nol_pitch_coef[i]>MULT16_16_Q15(nol_pitch_coef[0],19661)) && +#else + if ((nol_pitch_coef[i]>.6*nol_pitch_coef[0]) && +#endif + (ABS(2*nol_pitch[i]-corr_pitch)<=2 || ABS(3*nol_pitch[i]-corr_pitch)<=3 || + ABS(4*nol_pitch[i]-corr_pitch)<=4 || ABS(5*nol_pitch[i]-corr_pitch)<=5)) + { + corr_pitch = nol_pitch[i]; + } + } +#else + corr_pitch = pitch; +#endif + + ALLOC(iexc, 2*nsf, spx_word16_t); + + interp_pitch(exc, iexc, corr_pitch, 80); + if (corr_pitch>max_pitch) + interp_pitch(exc, iexc+nsf, 2*corr_pitch, 80); + else + interp_pitch(exc, iexc+nsf, -corr_pitch, 80); + +#ifdef FIXED_POINT + for (i=0;i16383) + { + scaledown = 1; + break; + } + } + if (scaledown) + { + for (i=0;i MULT16_16(iexc0_mag,exc_mag)) + pgain1 = QCONST16(1., 14); + else + pgain1 = PDIV32_16(SHL32(PDIV32(corr0, exc_mag),14),iexc0_mag); + if (corr1 > MULT16_16(iexc1_mag,exc_mag)) + pgain2 = QCONST16(1., 14); + else + pgain2 = PDIV32_16(SHL32(PDIV32(corr1, exc_mag),14),iexc1_mag); + gg1 = PDIV32_16(SHL32(EXTEND32(exc_mag),8), iexc0_mag); + gg2 = PDIV32_16(SHL32(EXTEND32(exc_mag),8), iexc1_mag); + if (comb_gain>0) + { +#ifdef FIXED_POINT + c1 = (MULT16_16_Q15(QCONST16(.4,15),comb_gain)+QCONST16(.07,15)); + c2 = QCONST16(.5,15)+MULT16_16_Q14(QCONST16(1.72,14),(c1-QCONST16(.07,15))); +#else + c1 = .4*comb_gain+.07; + c2 = .5+1.72*(c1-.07); +#endif + } else + { + c1=c2=0; + } +#ifdef FIXED_POINT + g1 = 32767 - MULT16_16_Q13(MULT16_16_Q15(c2, pgain1),pgain1); + g2 = 32767 - MULT16_16_Q13(MULT16_16_Q15(c2, pgain2),pgain2); +#else + g1 = 1-c2*pgain1*pgain1; + g2 = 1-c2*pgain2*pgain2; +#endif + if (g1max_pitch) + { + gain0 = MULT16_16_Q15(QCONST16(.7,15),MULT16_16_Q14(g1,gg1)); + gain1 = MULT16_16_Q15(QCONST16(.3,15),MULT16_16_Q14(g2,gg2)); + } else { + gain0 = MULT16_16_Q15(QCONST16(.6,15),MULT16_16_Q14(g1,gg1)); + gain1 = MULT16_16_Q15(QCONST16(.6,15),MULT16_16_Q14(g2,gg2)); + } + for (i=0;i new_ener) + old_ener = new_ener; + ngain = PDIV32_16(SHL32(EXTEND32(old_ener),14),new_ener); + + for (i=0;i> 13 + x[i] + mov r5, #0x7f00 + orr r5, r5, #0xff @ r5 = 32767 + cmp r14, r5 + movgt r14, r5 @ Clip positive + cmn r14, r5 + rsblt r14, r5, #0 @ Clip negative + strh r14, [r2], #2 @ Write result to y[i] + + ldrsh r4, [r1] + mul r5, r4, r14 + sub r5, r6, r5 @ mem[0] = mem[1] - den[0]*y[i] + ldrsh r4, [r1, #2] + mul r6, r4, r14 + sub r6, r7, r6 @ mem[1] = mem[2] - den[1]*y[i] + ldrsh r4, [r1, #4] + mul r7, r4, r14 + sub r7, r8, r7 @ mem[2] = mem[3] - den[2]*y[i] + ldrsh r4, [r1, #6] + mul r8, r4, r14 + sub r8, r9, r8 @ mem[3] = mem[4] - den[3]*y[i] + ldrsh r4, [r1, #8] + mul r9, r4, r14 + sub r9, r10, r9 @ mem[4] = mem[5] - den[4]*y[i] + ldrsh r4, [r1, #10] + mul r10, r4, r14 + sub r10, r11, r10 @ mem[5] = mem[6] - den[5]*y[i] + ldrsh r4, [r1, #12] + mul r11, r4, r14 + sub r11, r12, r11 @ mem[6] = mem[7] - den[6]*y[i] + ldrsh r4, [r1, #14] + mul r12, r4, r14 + rsb r12, r12, #0 @ mem[7] = -den[7]*y[i] + subs r3, r3, #1 + bne 0b + ldr r4, [sp, #40] @ r4 = mem + stmia r4, { r5-r12 } @ Save back mem[] + ldmpc regs=r4-r11 @ Exit + +.order_10: + ldmia r4, { r5-r9 } @ r5-r9 = mem[0..4] + add r5, r5, #4096 @ Rounding constant + ldrsh r14, [r0], #2 + add r14, r14, r5, asr #13 @ (mem[0] + 4096) >> 13 + x[i] + mov r5, #0x7f00 + orr r5, r5, #0xff @ r5 = 32767 + cmp r14, r5 + movgt r14, r5 @ Clip positive + cmn r14, r5 + rsblt r14, r5, #0 @ Clip negative + strh r14, [r2], #2 @ Write result to y[i] + + ldmia r1!, { r10-r12 } @ r10-r12 = den[0..5] + mov r5, r10, lsl #16 + mov r5, r5, asr #16 + mul r5, r14, r5 + sub r5, r6, r5 @ mem[0] = mem[1] - den[0]*y[i] + mov r10, r10, asr #16 + mul r6, r14, r10 + sub r6, r7, r6 @ mem[1] = mem[2] - den[1]*y[i] + mov r10, r11, lsl #16 + mov r10, r10, asr #16 + mul r7, r14, r10 + sub r7, r8, r7 @ mem[2] = mem[3] - den[2]*y[i] + mov r10, r11, asr #16 + mul r8, r14, r10 + sub r8, r9, r8 @ mem[3] = mem[4] - den[3]*y[i] + stmia r4!, { r5-r8 } @ Write back mem[0..3], r4 = &mem[4] + mov r10, r12, lsl #16 + mov r10, r10, asr #16 + mul r5, r14, r10 + + ldmib r4, { r6-r10 } @ r6-r10 = mem[5..9] + sub r5, r6, r5 @ mem[4] = mem[5] - den[4]*y[i] + mov r12, r12, asr #16 + mul r6, r14, r12 + sub r6, r7, r6 @ mem[5] = mem[6] - den[5]*y[i] + ldmia r1!, { r11-r12 } @ r11-r12 = den[6..9] + mov r7, r11, lsl #16 + mov r7, r7, asr #16 + mul r7, r14, r7 + sub r7, r8, r7 @ mem[6] = mem[7] - den[6]*y[i] + mov r11, r11, asr #16 + mul r8, r14, r11 + sub r8, r9, r8 @ mem[7] = mem[8] - den[7]*y[i] + mov r11, r12, lsl #16 + mov r11, r11, asr #16 + mul r9, r14, r11 + sub r9, r10, r9 @ mem[8] = mem[9] - den[8]*y[i] + mov r12, r12, asr #16 + mul r10, r14, r12 + rsb r10, r10, #0 @ mem[9] = -den[9]*y[i] + stmia r4!, { r5-r10 } @ Write back mem[4..9] + sub r4, r4, #10*4 + sub r1, r1, #10*2 + subs r3, r3, #1 + bne .order_10 + ldmpc regs=r4-r11 @ Exit + + +/* void qmf_synth(const spx_word16_t *x1, const spx_word16_t *x2, const spx_word16_t *a, spx_word16_t *y, int N, int M, spx_word32_t *mem1, spx_word32_t *mem2, char *stack) */ + .global qmf_synth +qmf_synth: + stmdb sp!, { r4-r11, lr } + add r7, sp, #36 @ r0 = x1, r1 = x2, r2 = a, r3 = y + ldmia r7, { r4-r7 } @ r4 = N, r5 = M, r6 = mem1, r7 = mem2 + + add r8, r4, r5 + sub r9, sp, r8 @ r9 = sp - (N + M >> 1) = xx2 + sub r8, r9, r8 @ r8 = r9 - (N + M >> 1) = xx1 + str sp, [r8, #-4] @ Stack old sp + sub sp, r8, #4 @ Update sp + + add r0, r0, r4 @ x1 += N >> 1 + add r1, r1, r4 @ x2 += N >> 1 + mov r14, r4 @ Loop counter is N +0: + @ Backwards copy x1 and x2 arrays to xx1 and xx2, assume N2 is power of two + @ N should always be a multiple of four, so this should be OK + ldmdb r0!, { r10-r11 } + mov r12, r10, ror #16 + mov r11, r11, ror #16 + stmia r8!, { r11-r12 } + ldmdb r1!, { r10-r11 } + mov r12, r10, ror #16 + mov r11, r11, ror #16 + stmia r9!, { r11-r12 } + subs r14, r14, #8 + bne 0b + + @ Copy alternate members of mem1 and mem2 to last part of xx1 and xx2 + mov r14, r5 @ Loop counter is M + add r6, r6, #2 + add r7, r7, #2 + stmdb sp!, { r6-r7 } @ Stack &mem1[1], &mem2[1] +0: + ldrh r10, [r6], #4 + ldrh r11, [r6], #4 + ldrh r12, [r7], #4 + orr r10, r10, r11, lsl #16 + ldrh r11, [r7], #4 + orr r11, r12, r11, lsl #16 + str r10, [r8], #4 + str r11, [r9], #4 + subs r14, r14, #4 + bne 0b + + sub r0, r8, r5 @ r0 = &xx1[N2] + sub r1, r9, r5 @ r1 = &xx2[N2] + str r4, [sp, #-4]! @ Stack N + mov r4, r5 + str r4, [sp, #-4]! @ Stack M + @ Main loop, register usage: + @ r0 = xx1, r1 = xx2, r2 = a, r3 = y, r4 = M, r5 = x10, r6 = x11, r7 = x20 + @ r8 = x21, r9 = [a1, a0], r10 = acc0, r11 = acc1, r12 = acc2, r14 = acc3 +0: @ Outerloop + mov r10, #16384 @ Init acccumulators to rounding const + mov r11, #16384 + mov r12, #16384 + mov r14, #16384 + + ldrsh r5, [r0, #-4]! @ r5 = x10, r0 = &xx1[N2 - 2] + ldrsh r7, [r1, #-4]! @ r7 = x20, r1 = &xx2[N2 - 2] +1: @ Innerloop + ldrsh r9, [r2], #2 @ r9 = a0 + ldrsh r6, [r0, #2]! @ r6 = x11 + ldrsh r8, [r1, #2]! @ r8 = x21 + sub r5, r5, r7 @ r5 = x10 - x20 + add r7, r5, r7, asl #1 @ r7 = x10 + x20 + mla r12, r9, r5, r12 @ acc2 += a0*(x10 - x20) + sub r5, r6, r8 @ r5 = x11 - x21 + mla r10, r9, r5, r10 @ acc0 += a0*(x11 - x21) + ldrsh r9, [r2], #2 @ r9 = a1 + add r5, r6, r8 @ r5 = x11 + x21 + mla r14, r9, r7, r14 @ acc3 += a1*(x10 + x20) + mla r11, r9, r5, r11 @ acc1 += a1*(x11 + x21) + + ldrsh r9, [r2], #2 @ r9 = a1 + ldrsh r5, [r0, #2]! @ r5 = x10 + ldrsh r7, [r1, #2]! @ r7 = x20 + sub r6, r6, r8 @ r6 = x11 - x21 + add r8, r6, r8, asl #1 @ r8 = x11 + x21 + mla r12, r9, r6, r12 @ acc2 += a0*(x11 - x21) + sub r6, r5, r7 @ r6 = x10 - x20 + mla r10, r9, r6, r10 @ acc0 += a0*(x10 - x20) + ldrsh r9, [r2], #2 @ r9 = a1 + add r6, r5, r7 @ r5 = x10 + x20 + mla r14, r9, r8, r14 @ acc3 += a1*(x11 + x21) + mla r11, r9, r6, r11 @ acc1 += a1*(x10 + x10) + subs r4, r4, #4 + bne 1b + + ldr r4, [sp] @ r4 = M + sub r2, r2, r4, lsl #1 @ r2 = &a[0] + sub r0, r0, r4 @ r0 = &xx1[N2 - 2 - i] + sub r1, r1, r4 @ r1 = &xx2[N2 - 2 - i] + + mov r10, r10, asr #15 @ Shift outputs down + mov r11, r11, asr #15 + mov r12, r12, asr #15 + mov r14, r14, asr #15 + + @ Clip output to -32768..32767 range, which works fine despite not being + @ Speex' usual clipping range. + mvn r9, #0x8000 + mov r5, r10, asr #15 + teq r5, r5, asr #31 + eorne r10, r9, r5, asr #31 + mov r5, r11, asr #15 + teq r5, r5, asr #31 + eorne r11, r9, r5, asr #31 + mov r5, r12, asr #15 + teq r5, r5, asr #31 + eorne r12, r9, r5, asr #31 + mov r5, r14, asr #15 + teq r5, r5, asr #31 + eorne r14, r9, r5, asr #31 + + strh r10, [r3], #2 @ Write outputs + strh r11, [r3], #2 + strh r12, [r3], #2 + strh r14, [r3], #2 + ldr r10, [sp, #4] @ Load N + subs r10, r10, #4 @ Are we done? + strne r10, [sp, #4] @ no -> + bne 0b @ do outer loop + + @ Copy start of xx1 and xx2 back to alternate mem1 and mem2 entries + @ r0 and r1 are &xx1[0] and &xx2[0] at this point + add sp, sp, #8 + ldmia sp, { r5-r6, sp } @ Fetch &mem1[1], &mem2[1], restore sp +0: + ldr r7, [r0], #4 + ldr r8, [r1], #4 + strh r7, [r5], #4 + strh r8, [r6], #4 + mov r7, r7, lsr #16 + mov r8, r8, lsr #16 + strh r7, [r5], #4 + strh r8, [r6], #4 + subs r4, r4, #4 + bne 0b + ldmpc regs=r4-r11 @ Exit + + +/* void signal_mul(const spx_sig_t *x, spx_sig_t *y, spx_word32_t scale, int len) */ + .global signal_mul +signal_mul: + stmdb sp!, { r4-r8, lr } +0: + ldmia r0!, { r5-r8 } @ Load four input samples + smull r5, r12, r2, r5 + mov r12, r12, lsl #18 @ Recombine upper and lower parts + orr r5, r12, r5, lsr #14 + smull r6, r12, r2, r6 + mov r12, r12, lsl #18 + orr r6, r12, r6, lsr #14 + smull r7, r12, r2, r7 + mov r12, r12, lsl #18 + orr r7, r12, r7, lsr #14 + smull r8, r12, r2, r8 + mov r12, r12, lsl #18 + orr r8, r12, r8, lsr #14 + stmia r1!, { r5-r8 } @ Store four output samples + subs r3, r3, #4 @ Are we done? + bne 0b + + ldmpc regs=r4-r8 @ Exit + diff --git a/lib/rbcodec/codecs/libspeex/filters_arm4.h b/lib/rbcodec/codecs/libspeex/filters_arm4.h new file mode 100644 index 0000000000..18c2a7d448 --- /dev/null +++ b/lib/rbcodec/codecs/libspeex/filters_arm4.h @@ -0,0 +1,96 @@ +/* Copyright (C) 2004 Jean-Marc Valin */ +/** + @file filters_arm4.h + @brief Various analysis/synthesis filters (ARM4 version) +*/ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + - Neither the name of the Xiph.org Foundation nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#define OVERRIDE_NORMALIZE16 +int normalize16(const spx_sig_t *x, spx_word16_t *y, spx_sig_t max_scale, int len) +{ + spx_sig_t max_val=1; + int sig_shift; + int dead1, dead2, dead3, dead4, dead5, dead6; + + __asm__ __volatile__ ( + "\tmov %1, #1 \n" + "\tmov %3, #0 \n" + + ".normalize16loop1%=: \n" + + "\tldr %4, [%0], #4 \n" + "\tcmp %4, %1 \n" + "\tmovgt %1, %4 \n" + "\tcmp %4, %3 \n" + "\tmovlt %3, %4 \n" + + "\tsubs %2, %2, #1 \n" + "\tbne .normalize16loop1%=\n" + + "\trsb %3, %3, #0 \n" + "\tcmp %1, %3 \n" + "\tmovlt %1, %3 \n" + : "=r" (dead1), "=r" (max_val), "=r" (dead3), "=r" (dead4), + "=r" (dead5), "=r" (dead6) + : "0" (x), "2" (len) + : "cc", "memory"); + + sig_shift=0; + while (max_val>max_scale) + { + sig_shift++; + max_val >>= 1; + } + + __asm__ __volatile__ ( + ".normalize16loop%=: \n" + + "\tldr %4, [%0], #4 \n" + "\tldr %5, [%0], #4 \n" + "\tmov %4, %4, asr %3 \n" + "\tstrh %4, [%1], #2 \n" + "\tldr %4, [%0], #4 \n" + "\tmov %5, %5, asr %3 \n" + "\tstrh %5, [%1], #2 \n" + "\tldr %5, [%0], #4 \n" + "\tmov %4, %4, asr %3 \n" + "\tstrh %4, [%1], #2 \n" + "\tsubs %2, %2, #1 \n" + "\tmov %5, %5, asr %3 \n" + "\tstrh %5, [%1], #2 \n" + + "\tbge .normalize16loop%=\n" + : "=r" (dead1), "=r" (dead2), "=r" (dead3), "=r" (dead4), + "=r" (dead5), "=r" (dead6) + : "0" (x), "1" (y), "2" (len>>2), "3" (sig_shift) + : "cc", "memory"); + return sig_shift; +} + diff --git a/lib/rbcodec/codecs/libspeex/filters_bfin.h b/lib/rbcodec/codecs/libspeex/filters_bfin.h new file mode 100644 index 0000000000..1e433ee167 --- /dev/null +++ b/lib/rbcodec/codecs/libspeex/filters_bfin.h @@ -0,0 +1,515 @@ +/* Copyright (C) 2005 Analog Devices */ +/** + @file filters_bfin.h + @brief Various analysis/synthesis filters (Blackfin version) +*/ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + - Neither the name of the Xiph.org Foundation nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#define OVERRIDE_NORMALIZE16 +int normalize16(const spx_sig_t *x, spx_word16_t *y, spx_sig_t max_scale, int len) +{ + spx_sig_t max_val=1; + int sig_shift; + __asm__ + ( + "%0 = 0;\n\t" + "I0 = %1;\n\t" + "L0 = 0;\n\t" + "R1 = [I0++];\n\t" + "LOOP norm_max%= LC0 = %2;\n\t" + "LOOP_BEGIN norm_max%=;\n\t" + "R2 = ABS R1 || R1 = [I0++];\n\t" + "%0 = MAX(%0, R2);\n\t" + "LOOP_END norm_max%=;\n\t" + : "=&d" (max_val) + : "a" (x), "a" (len) + : "R1", "R2" + ); + + sig_shift=0; + while (max_val>max_scale) + { + sig_shift++; + max_val >>= 1; + } + + __asm__ __volatile__ + ( + "I0 = %0;\n\t" + "L0 = 0;\n\t" + "P1 = %1;\n\t" + "R0 = [I0++];\n\t" + "LOOP norm_shift%= LC0 = %3;\n\t" + "LOOP_BEGIN norm_shift%=;\n\t" + "R1 = ASHIFT R0 by %2.L || R0 = [I0++];\n\t" + "W[P1++] = R1;\n\t" + "LOOP_END norm_shift%=;\n\t" + "R1 = ASHIFT R0 by %2.L;\n\t" + "W[P1++] = R1;\n\t" + : : "a" (x), "a" (y), "d" (-sig_shift), "a" (len-1) + : "I0", "L0", "P1", "R0", "R1", "memory" + ); + return sig_shift; +} + + + +#define OVERRIDE_FILTER_MEM16 +void filter_mem16(const spx_word16_t *_x, const spx_coef_t *num, const spx_coef_t *den, spx_word16_t *_y, int N, int ord, spx_mem_t *mem, char *stack) +{ + VARDECL(spx_word32_t *xy2); + VARDECL(spx_word32_t *numden_a); + spx_word32_t *xy; + spx_word16_t *numden; + int i; + + ALLOC(xy2, (N+1), spx_word32_t); + ALLOC(numden_a, (2*ord+2), spx_word32_t); + xy = xy2+1; + numden = (spx_word16_t*) numden_a; + + for (i=0;i>> 13;\n\t" + "W[%0] = R3.L;\n\t" + "R0 <<= 1;\n\t" + "R1 = R1 + R0;\n\t" + "R1 >>>= 13;\n\t" + "W[%1] = R1.L;\n\t" + "LOOP_END samples%=;\n\t" + : "=a" (ytmp2), "=a" (y) + : "a" (awk2), "a" (ak), "d" (ord), "m" (N), "0" (ytmp2), "1" (y) + : "A0", "A1", "R0", "R1", "R2", "R3", "I0", "I1", "I2", "I3", "L0", "L1", "L2", "L3", "A0", "A1" + ); +} + + + +#if 0 /* Equivalent C function for filter_mem2 and compute_impulse_response */ +#define min(a,b) ((a)<(b) ? (a):(b)) + +void compute_impulse_response(const spx_coef_t *ak, const spx_coef_t *awk1, const spx_coef_t *awk2, spx_word16_t *y, int N, int ord, char *stack) +{ + int i,j; + VARDECL(spx_word16_t *ytmp); + ALLOC(ytmp, N, spx_word16_t); + + y[0] = LPC_SCALING; + for (i=0;i> 13 with rounding + move.w (%a3)+, %d0 + ext.l %d0 + add.l %d1, %d0 | Add with x[i] + move.l #32767, %d1 + move.l #65534, %a6 + add.l %d1, %d0 | Bias result to [-1..65534] + cmp.l %a6, %d0 | Now do clip to [0..65534] range + jls 2f + jpl 1f + clr.l %d0 | Clip low + .word 0x51fa | trapf.w, shadow next insn +1: + move.l %a6, %d0 | Clip high +2: + sub.l %d1, %d0 | Bias clipped result back to [-32767..32767] + move.w %d0, (%a5)+ | Write result to y[i] + neg.l %d0 | msac.w is bugged in gas, do this for now + move.l (%a4)+, %a6 | Fetch den[0] and den[1] + mac.w %a6u, %d0l, %acc0 + mac.w %a6l, %d0l, (%a4)+, %a6, %acc1 + mac.w %a6u, %d0l, %acc2 + mac.w %a6l, %d0l, (%a4)+, %a6, %acc3 + movclr.l %acc0, %d1 + add.l %d2, %d1 | mem[0] = mem[1] - den[0]*y[i] + movclr.l %acc1, %d2 + add.l %d3, %d2 | mem[1] = mem[2] - den[1]*y[i] + movclr.l %acc2, %d3 + add.l %d4, %d3 | mem[2] = mem[3] - den[2]*y[i] + movclr.l %acc3, %d4 + add.l %d5, %d4 | mem[3] = mem[4] - den[3]*y[i] + mac.w %a6u, %d0l, %acc0 + mac.w %a6l, %d0l, (%a4)+, %a6, %acc1 + mac.w %a6u, %d0l, %acc2 + mac.w %a6l, %d0l, %acc3 + lea.l (-16, %a4), %a4 | wrap den pointer back to den[0] + movclr.l %acc0, %d5 + add.l %d6, %d5 | mem[4] = mem[5] - den[4]*y[i] + movclr.l %acc1, %d6 + add.l %d7, %d6 | mem[5] = mem[6] - den[5]*y[i] + movclr.l %acc2, %d7 + add.l %a0, %d7 | mem[6] = mem[7] - den[6]*y[i] + movclr.l %acc3, %a0 | mem[7] = -den[7]*y[i] + subq.l #1, (44+16, %sp) | Have we done all samples? + jne 0b + move.l (44+24, %sp), %a6 | Fetch mem pointer + movem.l %d1-%d7/%a0, (%a6) | Save back mem[] + jra .exit + + | d0 = y[i], d1-d7, a0-a2 = mem[0] .. mem[9] + | a3 = x, a4 = den, a5 = y, a6 = temp +.order_10: + movem.l (%a6), %d1-%d7/%a0-%a2 | Fetch mem[] array +0: + moveq.l #13, %d0 + add.l #4096, %d1 + asr.l %d0, %d1 | mem[0] >> 13 with rounding + move.w (%a3)+, %d0 + ext.l %d0 + add.l %d1, %d0 | Add with x[i] + move.l #32767, %d1 + move.l #65534, %a6 + add.l %d1, %d0 | Bias result to [-1..65534] + cmp.l %a6, %d0 | Now do clip to [0..65534] range + jls 2f + jpl 1f + clr.l %d0 | Clip low + .word 0x51fa | trapf.w, shadow next insn +1: + move.l %a6, %d0 | Clip high +2: + sub.l %d1, %d0 | Bias clipped result back to [-32767..32767] + move.w %d0, (%a5)+ | Write result to y[i] + neg.l %d0 | msac.w is bugged in gas, do this for now + move.l (%a4)+, %a6 | Fetch den[0] and den[1] + mac.w %a6u, %d0l, %acc0 + mac.w %a6l, %d0l, (%a4)+, %a6, %acc1 + mac.w %a6u, %d0l, %acc2 + mac.w %a6l, %d0l, (%a4)+, %a6, %acc3 + movclr.l %acc0, %d1 + add.l %d2, %d1 | mem[0] = mem[1] - den[0]*y[i] + movclr.l %acc1, %d2 + add.l %d3, %d2 | mem[1] = mem[2] - den[1]*y[i] + movclr.l %acc2, %d3 + add.l %d4, %d3 | mem[2] = mem[3] - den[2]*y[i] + movclr.l %acc3, %d4 + add.l %d5, %d4 | mem[3] = mem[4] - den[3]*y[i] + mac.w %a6u, %d0l, %acc0 + mac.w %a6l, %d0l, (%a4)+, %a6, %acc1 + mac.w %a6u, %d0l, %acc2 + mac.w %a6l, %d0l, (%a4)+, %a6, %acc3 + lea.l (-20, %a4), %a4 | wrap den pointer back to den[0] + movclr.l %acc0, %d5 + add.l %d6, %d5 | mem[4] = mem[5] - den[4]*y[i] + movclr.l %acc1, %d6 + add.l %d7, %d6 | mem[5] = mem[6] - den[5]*y[i] + movclr.l %acc2, %d7 + add.l %a0, %d7 | mem[6] = mem[7] - den[6]*y[i] + movclr.l %acc3, %a0 + add.l %a1, %a0 | mem[7] = mem[8] - den[7]*y[i] + mac.w %a6u, %d0l, %acc0 + mac.w %a6l, %d0l, %acc1 + movclr.l %acc0, %a1 + add.l %a2, %a1 | mem[8] = mem[9] - den[8]*y[i] + movclr.l %acc1, %a2 | mem[9] = -den[9]*y[i] + + subq.l #1, (44+16, %sp) | Have we done all samples? + jne 0b + move.l (44+24, %sp), %a6 | Fetch mem pointer + movem.l %d1-%d7/%a0-%a2, (%a6) | Save back mem[] + +.exit: + movem.l (%sp), %d2-%d7/%a2-%a6 + lea.l (44, %sp), %sp + rts + + +/* void qmf_synth(const spx_word16_t *x1, const spx_word16_t *x2, const spx_word16_t *a, spx_word16_t *y, int N, int M, spx_word32_t *mem1, spx_word32_t *mem2, char *stack) */ + .global qmf_synth +qmf_synth: + lea.l (-44, %sp), %sp + movem.l %d2-%d7/%a2-%a6, (%sp) + movem.l (44+4, %sp), %a0-%a3 | a0 = x1, a1 = x2, a2 = a, a3 = y + movem.l (44+20, %sp), %d0-%d1/%a4-%a5 | d0 = N, d1 = M, a4 = mem1,a5 = mem2 + move.l #0x80, %macsr | Enable saturation + + | Comments make more sense when compared to the reference C version + move.l %a2, %d6 | Backup a + lsr.l #1, %d0 | N2 = N >> 1 + lsr.l #1, %d1 | M2 = M >> 1 + move.l %d1, %d7 | Backup M2 + clr.l %d2 + sub.l %d0, %d2 + sub.l %d1, %d2 | d2 = -(N2 + M2) + lea.l (%sp, %d2.l*2), %a2 | Alloc two buffers of N2 + M2 shorts + lea.l (%a2, %d2.l*2), %a6 | a2 = xx1, a6 = xx2 + move.l %sp, %d3 + move.l %a6, %sp | Update sp + move.l %d3, -(%sp) | Stack old %sp + + | Backwards copy x1 and x2 arrays to xx1 and xx2, assume N2 is power of two + | TODO: these copying loops probably have more potential for optimization + lea.l (%a0, %d0.l*2), %a0 | x1 += N2 + lea.l (%a1, %d0.l*2), %a1 | x2 += N2 + move.l %d0, %d2 | Loop counter is N2 +0: + move.l -(%a0), %d3 + swap.w %d3 + move.l %d3, (%a2)+ + move.l -(%a1), %d3 + swap.w %d3 + move.l %d3, (%a6)+ + subq.l #2, %d2 + jne 0b + + | Copy alternate members of mem1 and mem2 to last part of xx1 and xx2 + move.l %d1, %d2 | Loop counter is M2 + addq.l #2, %a4 | a4 = &mem1[1] + addq.l #2, %a5 | a5 = &mem2[1] + move.l %a4, %d3 | Backup mem1 and mem2 + move.l %a5, %d4 +0: + move.w (%a4), (%a2)+ + move.w (%a5), (%a6)+ + addq.l #4, %a4 + addq.l #4, %a5 + subq.l #1, %d2 + jne 0b + move.l %d3, %a4 | a4 = &mem1[1] + move.l %d4, %a5 | a5 = &mem2[1] + + clr.l %d2 + sub.l %d1, %d2 | d2 = -M2 + lea.l (-4, %a2, %d2.l*2), %a0 | a0 = &xx1[N2 - 2] + lea.l (-4, %a6, %d2.l*2), %a1 | a1 = &xx2[N2 - 2] + move.l %d6, %a2 | a2 = a + + | Main loop, register usage: + | d0 = N2 counter, d1 = M2 counter, d7 = M2 backup + | d2 = x10, d3 = x11, d4 = x20, d5 = x21, d6 = [a0, a1] + | a0 = xx1, a1 = xx2, a2 = a, a3 = y, a4 = mem1, a5 = mem2 +0: | Outerloop + move.l #32768, %d2 | Rounding constant + move.l %d2, %acc0 + move.l %d2, %acc1 + move.l %d2, %acc2 + move.l %d2, %acc3 + move.w (%a0)+, %d2 | d2 = x10 + move.w (%a1)+, %d4 | d4 = x20 + move.l (%a2)+, %d6 | d6 = [a0, a1] +1: | Innerloop + move.w (%a0)+, %d3 | d3 = x11 + move.w (%a1)+, %d5 | d5 = x21 + mac.w %d6u, %d3l, <<, %acc0 | acc0 += a0*x11 + msac.w %d6u, %d5l, <<, %acc0 | acc0 -= a0*x21 + mac.w %d6l, %d3l, <<, %acc1 | acc1 += a1*x11 + mac.w %d6l, %d5l, <<, %acc1 | acc1 += a1*x21 + mac.w %d6u, %d2l, <<, %acc2 | acc2 += a0*x10 + msac.w %d6u, %d4l, <<, %acc2 | acc2 -= a0*x20 + mac.w %d6l, %d2l, <<, %acc3 | acc3 += a1*x10 + mac.w %d6l, %d4l, <<, (%a2)+, %d6, %acc3 | acc3 += a1*x20 + + move.w (%a0)+, %d2 | d2 = x10 + move.w (%a1)+, %d4 | d4 = x20 + mac.w %d6u, %d2l, <<, %acc0 | acc0 += a0*x10 + msac.w %d6u, %d4l, <<, %acc0 | acc0 -= a0*x20 + mac.w %d6l, %d2l, <<, %acc1 | acc1 += a1*x10 + mac.w %d6l, %d4l, <<, %acc1 | acc1 += a1*x20 + mac.w %d6u, %d3l, <<, %acc2 | acc2 += a0*x11 + msac.w %d6u, %d5l, <<, %acc2 | acc2 -= a0*x21 + mac.w %d6l, %d3l, <<, %acc3 | acc3 += a1*x11 + mac.w %d6l, %d5l, <<, (%a2)+, %d6, %acc3 | acc3 += a1*x21 + subq.l #2, %d1 + jne 1b + + sub.l %d7, %d1 | d1 = -M2 + lea.l (-4, %a2, %d1.l*4), %a2 | a2 = &a[0] + lea.l (-6, %a0, %d1.l*2), %a0 | a0 = &xx1[N2 - 2 - i] + lea.l (-6, %a1, %d1.l*2), %a1 | a1 = &xx2[N2 - 2 - i] + neg.l %d1 | d1 = M2 + movclr.l %acc0, %d2 + movclr.l %acc1, %d3 + movclr.l %acc2, %d4 + movclr.l %acc3, %d5 + swap.w %d2 | Shift 16 right + swap.w %d3 + swap.w %d4 + swap.w %d5 + | Thanks to the extra shift in the mac chain, we get clipping for free. + | The clipping will be [-32768..32767], not Speex standard [-32767..32767], + | but since qmf_synth() is called so late in the signal chain, it should + | work fine. + move.w %d2, (%a3)+ | Write results to y[] + move.w %d3, (%a3)+ + move.w %d4, (%a3)+ + move.w %d5, (%a3)+ + subq.l #2, %d0 + jne 0b + + | Copy start of xx1 and xx2 back to alternate mem1 and mem2 entries + addq.l #4, %a0 | a0 = &xx1[0] + addq.l #4, %a1 | a1 = &xx2[0] +0: + move.w (%a0)+, (%a4) + move.w (%a1)+, (%a5) + addq.l #4, %a4 + addq.l #4, %a5 + subq.l #1, %d1 + jne 0b + + move.l #0, %macsr + move.l (%sp), %sp + movem.l (%sp), %d2-%d7/%a2-%a6 + lea.l (44, %sp), %sp + rts + + +/* void signal_mul(const spx_sig_t *x, spx_sig_t *y, spx_word32_t scale, int len) */ + .global signal_mul +signal_mul: + lea.l (-20, %sp), %sp + movem.l %d2-%d6, (%sp) + movem.l (20+4, %sp), %a0-%a1 | a0 = x, a1 = y + movem.l (20+12, %sp), %d0-%d1 | d0 = scale, d1 = len + moveq.l #0x20, %d6 + move.l %d6, %macsr | Set MAC unit to fractional mode + asl.l #3, %d0 | Pre-scale 'scale' + moveq.l #9, %d6 +0: + movem.l (%a0), %d2-%d5 | Fetch input + asl.l %d6, %d2 | Shift each value 9 to the left + asl.l %d6, %d3 + asl.l %d6, %d4 + asl.l %d6, %d5 + mac.l %d2, %d0, %acc0 | Do multiplies + mac.l %d3, %d0, %acc1 + mac.l %d4, %d0, %acc2 + mac.l %d5, %d0, %acc3 + lea.l (16, %a0), %a0 + movclr.l %acc0, %d2 + movclr.l %acc1, %d3 + movclr.l %acc2, %d4 + movclr.l %acc3, %d5 + asl.l #5, %d2 | Adjust to proper format + asl.l #5, %d3 + asl.l #5, %d4 + asl.l #5, %d5 + movem.l %d2-%d5, (%a1) | Save output + lea.l (16, %a1), %a1 + subq.l #4, %d1 + jne 0b + + clr.l %d0 + move.l %d0, %macsr | Set MAC unit back to integer mode + movem.l (%sp), %d2-%d6 + lea.l (20, %sp), %sp + rts + diff --git a/lib/rbcodec/codecs/libspeex/filters_sse.h b/lib/rbcodec/codecs/libspeex/filters_sse.h new file mode 100644 index 0000000000..4bb333daf3 --- /dev/null +++ b/lib/rbcodec/codecs/libspeex/filters_sse.h @@ -0,0 +1,336 @@ +/* Copyright (C) 2002 Jean-Marc Valin */ +/** + @file filters_sse.h + @brief Various analysis/synthesis filters (SSE version) +*/ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + - Neither the name of the Xiph.org Foundation nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include + +void filter_mem16_10(const float *x, const float *_num, const float *_den, float *y, int N, int ord, float *_mem) +{ + __m128 num[3], den[3], mem[3]; + + int i; + + /* Copy numerator, denominator and memory to aligned xmm */ + for (i=0;i<2;i++) + { + mem[i] = _mm_loadu_ps(_mem+4*i); + num[i] = _mm_loadu_ps(_num+4*i); + den[i] = _mm_loadu_ps(_den+4*i); + } + mem[2] = _mm_setr_ps(_mem[8], _mem[9], 0, 0); + num[2] = _mm_setr_ps(_num[8], _num[9], 0, 0); + den[2] = _mm_setr_ps(_den[8], _den[9], 0, 0); + + for (i=0;i>1; + __asm__ ( + "P0 = 15;\n\t" + "R0 = %1;\n\t" + "R1 = %2;\n\t" + //"R0 = R0 + R1;\n\t" + "R0 <<= 1;\n\t" + "DIVS (R0, R1);\n\t" + "LOOP divide%= LC0 = P0;\n\t" + "LOOP_BEGIN divide%=;\n\t" + "DIVQ (R0, R1);\n\t" + "LOOP_END divide%=;\n\t" + "R0 = R0.L;\n\t" + "%0 = R0;\n\t" + : "=m" (res) + : "m" (a), "m" (bb) + : "P0", "R0", "R1", "cc"); + return res; +} + +#undef DIV32_16 +static inline spx_word16_t DIV32_16(spx_word32_t a, spx_word16_t b) +{ + spx_word32_t res, bb; + bb = b; + /* Make the roundinf consistent with the C version + (do we need to do that?)*/ + if (a<0) + a += (b-1); + __asm__ ( + "P0 = 15;\n\t" + "R0 = %1;\n\t" + "R1 = %2;\n\t" + "R0 <<= 1;\n\t" + "DIVS (R0, R1);\n\t" + "LOOP divide%= LC0 = P0;\n\t" + "LOOP_BEGIN divide%=;\n\t" + "DIVQ (R0, R1);\n\t" + "LOOP_END divide%=;\n\t" + "R0 = R0.L;\n\t" + "%0 = R0;\n\t" + : "=m" (res) + : "m" (a), "m" (bb) + : "P0", "R0", "R1", "cc"); + return res; +} + +#undef MAX16 +static inline spx_word16_t MAX16(spx_word16_t a, spx_word16_t b) +{ + spx_word32_t res; + __asm__ ( + "%1 = %1.L (X);\n\t" + "%2 = %2.L (X);\n\t" + "%0 = MAX(%1,%2);" + : "=d" (res) + : "%d" (a), "d" (b) + ); + return res; +} + +#undef MULT16_32_Q15 +static inline spx_word32_t MULT16_32_Q15(spx_word16_t a, spx_word32_t b) +{ + spx_word32_t res; + __asm__ + ( + "A1 = %2.L*%1.L (M);\n\t" + "A1 = A1 >>> 15;\n\t" + "%0 = (A1 += %2.L*%1.H) ;\n\t" + : "=&W" (res), "=&d" (b) + : "d" (a), "1" (b) + : "A1" + ); + return res; +} + +#undef MAC16_32_Q15 +static inline spx_word32_t MAC16_32_Q15(spx_word32_t c, spx_word16_t a, spx_word32_t b) +{ + spx_word32_t res; + __asm__ + ( + "A1 = %2.L*%1.L (M);\n\t" + "A1 = A1 >>> 15;\n\t" + "%0 = (A1 += %2.L*%1.H);\n\t" + "%0 = %0 + %4;\n\t" + : "=&W" (res), "=&d" (b) + : "d" (a), "1" (b), "d" (c) + : "A1" + ); + return res; +} + +#undef MULT16_32_Q14 +static inline spx_word32_t MULT16_32_Q14(spx_word16_t a, spx_word32_t b) +{ + spx_word32_t res; + __asm__ + ( + "%2 <<= 1;\n\t" + "A1 = %1.L*%2.L (M);\n\t" + "A1 = A1 >>> 15;\n\t" + "%0 = (A1 += %1.L*%2.H);\n\t" + : "=W" (res), "=d" (a), "=d" (b) + : "1" (a), "2" (b) + : "A1" + ); + return res; +} + +#undef MAC16_32_Q14 +static inline spx_word32_t MAC16_32_Q14(spx_word32_t c, spx_word16_t a, spx_word32_t b) +{ + spx_word32_t res; + __asm__ + ( + "%1 <<= 1;\n\t" + "A1 = %2.L*%1.L (M);\n\t" + "A1 = A1 >>> 15;\n\t" + "%0 = (A1 += %2.L*%1.H);\n\t" + "%0 = %0 + %4;\n\t" + : "=&W" (res), "=&d" (b) + : "d" (a), "1" (b), "d" (c) + : "A1" + ); + return res; +} + +#endif diff --git a/lib/rbcodec/codecs/libspeex/fixed_debug.h b/lib/rbcodec/codecs/libspeex/fixed_debug.h new file mode 100644 index 0000000000..d5c449f4d9 --- /dev/null +++ b/lib/rbcodec/codecs/libspeex/fixed_debug.h @@ -0,0 +1,487 @@ +/* Copyright (C) 2003 Jean-Marc Valin */ +/** + @file fixed_debug.h + @brief Fixed-point operations with debugging +*/ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + - Neither the name of the Xiph.org Foundation nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef FIXED_DEBUG_H +#define FIXED_DEBUG_H + +#include + +extern long long spx_mips; +#define MIPS_INC spx_mips++, + +#define QCONST16(x,bits) ((spx_word16_t)(.5+(x)*(((spx_word32_t)1)<<(bits)))) +#define QCONST32(x,bits) ((spx_word32_t)(.5+(x)*(((spx_word32_t)1)<<(bits)))) + + +#define VERIFY_SHORT(x) ((x)<=32767&&(x)>=-32768) +#define VERIFY_INT(x) ((x)<=2147483647LL&&(x)>=-2147483648LL) + +static inline short NEG16(int x) +{ + int res; + if (!VERIFY_SHORT(x)) + { + fprintf (stderr, "NEG16: input is not short: %d\n", (int)x); + } + res = -x; + if (!VERIFY_SHORT(res)) + fprintf (stderr, "NEG16: output is not short: %d\n", (int)res); + spx_mips++; + return res; +} +static inline int NEG32(long long x) +{ + long long res; + if (!VERIFY_INT(x)) + { + fprintf (stderr, "NEG16: input is not int: %d\n", (int)x); + } + res = -x; + if (!VERIFY_INT(res)) + fprintf (stderr, "NEG16: output is not int: %d\n", (int)res); + spx_mips++; + return res; +} + +#define EXTRACT16(x) _EXTRACT16(x, __FILE__, __LINE__) +static inline short _EXTRACT16(int x, char *file, int line) +{ + int res; + if (!VERIFY_SHORT(x)) + { + fprintf (stderr, "EXTRACT16: input is not short: %d in %s: line %d\n", x, file, line); + } + res = x; + spx_mips++; + return res; +} + +#define EXTEND32(x) _EXTEND32(x, __FILE__, __LINE__) +static inline int _EXTEND32(int x, char *file, int line) +{ + int res; + if (!VERIFY_SHORT(x)) + { + fprintf (stderr, "EXTEND32: input is not short: %d in %s: line %d\n", x, file, line); + } + res = x; + spx_mips++; + return res; +} + +#define SHR16(a, shift) _SHR16(a, shift, __FILE__, __LINE__) +static inline short _SHR16(int a, int shift, char *file, int line) +{ + int res; + if (!VERIFY_SHORT(a) || !VERIFY_SHORT(shift)) + { + fprintf (stderr, "SHR16: inputs are not short: %d >> %d in %s: line %d\n", a, shift, file, line); + } + res = a>>shift; + if (!VERIFY_SHORT(res)) + fprintf (stderr, "SHR16: output is not short: %d in %s: line %d\n", res, file, line); + spx_mips++; + return res; +} +#define SHL16(a, shift) _SHL16(a, shift, __FILE__, __LINE__) +static inline short _SHL16(int a, int shift, char *file, int line) +{ + int res; + if (!VERIFY_SHORT(a) || !VERIFY_SHORT(shift)) + { + fprintf (stderr, "SHL16: inputs are not short: %d %d in %s: line %d\n", a, shift, file, line); + } + res = a<>shift; + if (!VERIFY_INT(res)) + { + fprintf (stderr, "SHR32: output is not int: %d\n", (int)res); + } + spx_mips++; + return res; +} +static inline int SHL32(long long a, int shift) +{ + long long res; + if (!VERIFY_INT(a) || !VERIFY_SHORT(shift)) + { + fprintf (stderr, "SHL32: inputs are not int: %d %d\n", (int)a, shift); + } + res = a<>1))),shift)) +#define PSHR32(a,shift) (SHR32(ADD32((a),((1<<((shift))>>1))),shift)) +#define VSHR32(a, shift) (((shift)>0) ? SHR32(a, shift) : SHL32(a, -(shift))) + +#define SATURATE16(x,a) (((x)>(a) ? (a) : (x)<-(a) ? -(a) : (x))) +#define SATURATE32(x,a) (((x)>(a) ? (a) : (x)<-(a) ? -(a) : (x))) + +//#define SHR(a,shift) ((a) >> (shift)) +//#define SHL(a,shift) ((a) << (shift)) + +#define ADD16(a, b) _ADD16(a, b, __FILE__, __LINE__) +static inline short _ADD16(int a, int b, char *file, int line) +{ + int res; + if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b)) + { + fprintf (stderr, "ADD16: inputs are not short: %d %d in %s: line %d\n", a, b, file, line); + } + res = a+b; + if (!VERIFY_SHORT(res)) + { + fprintf (stderr, "ADD16: output is not short: %d+%d=%d in %s: line %d\n", a,b,res, file, line); + } + spx_mips++; + return res; +} + +#define SUB16(a, b) _SUB16(a, b, __FILE__, __LINE__) +static inline short _SUB16(int a, int b, char *file, int line) +{ + int res; + if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b)) + { + fprintf (stderr, "SUB16: inputs are not short: %d %d in %s: line %d\n", a, b, file, line); + } + res = a-b; + if (!VERIFY_SHORT(res)) + fprintf (stderr, "SUB16: output is not short: %d in %s: line %d\n", res, file, line); + spx_mips++; + return res; +} + +#define ADD32(a, b) _ADD32(a, b, __FILE__, __LINE__) +static inline int _ADD32(long long a, long long b, char *file, int line) +{ + long long res; + if (!VERIFY_INT(a) || !VERIFY_INT(b)) + { + fprintf (stderr, "ADD32: inputs are not int: %d %d in %s: line %d\n", (int)a, (int)b, file, line); + } + res = a+b; + if (!VERIFY_INT(res)) + { + fprintf (stderr, "ADD32: output is not int: %d in %s: line %d\n", (int)res, file, line); + } + spx_mips++; + return res; +} + +static inline int SUB32(long long a, long long b) +{ + long long res; + if (!VERIFY_INT(a) || !VERIFY_INT(b)) + { + fprintf (stderr, "SUB32: inputs are not int: %d %d\n", (int)a, (int)b); + } + res = a-b; + if (!VERIFY_INT(res)) + fprintf (stderr, "SUB32: output is not int: %d\n", (int)res); + spx_mips++; + return res; +} + +#define ADD64(a,b) (MIPS_INC(a)+(b)) + +/* result fits in 16 bits */ +static inline short MULT16_16_16(int a, int b) +{ + int res; + if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b)) + { + fprintf (stderr, "MULT16_16_16: inputs are not short: %d %d\n", a, b); + } + res = a*b; + if (!VERIFY_SHORT(res)) + fprintf (stderr, "MULT16_16_16: output is not short: %d\n", res); + spx_mips++; + return res; +} + +#define MULT16_16(a, b) _MULT16_16(a, b, __FILE__, __LINE__) +static inline int _MULT16_16(int a, int b, char *file, int line) +{ + long long res; + if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b)) + { + fprintf (stderr, "MULT16_16: inputs are not short: %d %d in %s: line %d\n", a, b, file, line); + } + res = ((long long)a)*b; + if (!VERIFY_INT(res)) + fprintf (stderr, "MULT16_16: output is not int: %d in %s: line %d\n", (int)res, file, line); + spx_mips++; + return res; +} + +#define MAC16_16(c,a,b) (spx_mips--,ADD32((c),MULT16_16((a),(b)))) +#define MAC16_16_Q11(c,a,b) (EXTRACT16(ADD16((c),EXTRACT16(SHR32(MULT16_16((a),(b)),11))))) +#define MAC16_16_Q13(c,a,b) (EXTRACT16(ADD16((c),EXTRACT16(SHR32(MULT16_16((a),(b)),13))))) +#define MAC16_16_P13(c,a,b) (EXTRACT16(ADD32((c),SHR32(ADD32(4096,MULT16_16((a),(b))),13)))) + + +#define MULT16_32_QX(a, b, Q) _MULT16_32_QX(a, b, Q, __FILE__, __LINE__) +static inline int _MULT16_32_QX(int a, long long b, int Q, char *file, int line) +{ + long long res; + if (!VERIFY_SHORT(a) || !VERIFY_INT(b)) + { + fprintf (stderr, "MULT16_32_Q%d: inputs are not short+int: %d %d in %s: line %d\n", Q, (int)a, (int)b, file, line); + } + if (ABS32(b)>=(1<<(15+Q))) + fprintf (stderr, "MULT16_32_Q%d: second operand too large: %d %d in %s: line %d\n", Q, (int)a, (int)b, file, line); + res = (((long long)a)*(long long)b) >> Q; + if (!VERIFY_INT(res)) + fprintf (stderr, "MULT16_32_Q%d: output is not int: %d*%d=%d in %s: line %d\n", Q, (int)a, (int)b,(int)res, file, line); + spx_mips+=5; + return res; +} + +static inline int MULT16_32_PX(int a, long long b, int Q) +{ + long long res; + if (!VERIFY_SHORT(a) || !VERIFY_INT(b)) + { + fprintf (stderr, "MULT16_32_P%d: inputs are not short+int: %d %d\n", Q, (int)a, (int)b); + } + if (ABS32(b)>=(1<<(15+Q))) + fprintf (stderr, "MULT16_32_Q%d: second operand too large: %d %d\n", Q, (int)a, (int)b); + res = ((((long long)a)*(long long)b) + ((1<>1))>> Q; + if (!VERIFY_INT(res)) + fprintf (stderr, "MULT16_32_P%d: output is not int: %d*%d=%d\n", Q, (int)a, (int)b,(int)res); + spx_mips+=5; + return res; +} + + +#define MULT16_32_Q11(a,b) MULT16_32_QX(a,b,11) +#define MAC16_32_Q11(c,a,b) ADD32((c),MULT16_32_Q11((a),(b))) +#define MULT16_32_Q12(a,b) MULT16_32_QX(a,b,12) +#define MULT16_32_Q13(a,b) MULT16_32_QX(a,b,13) +#define MULT16_32_Q14(a,b) MULT16_32_QX(a,b,14) +#define MULT16_32_Q15(a,b) MULT16_32_QX(a,b,15) +#define MULT16_32_P15(a,b) MULT16_32_PX(a,b,15) +#define MAC16_32_Q15(c,a,b) ADD32((c),MULT16_32_Q15((a),(b))) + +static inline int SATURATE(int a, int b) +{ + if (a>b) + a=b; + if (a<-b) + a = -b; + return a; +} + +static inline int MULT16_16_Q11_32(int a, int b) +{ + long long res; + if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b)) + { + fprintf (stderr, "MULT16_16_Q11: inputs are not short: %d %d\n", a, b); + } + res = ((long long)a)*b; + res >>= 11; + if (!VERIFY_INT(res)) + fprintf (stderr, "MULT16_16_Q11: output is not short: %d*%d=%d\n", (int)a, (int)b, (int)res); + spx_mips+=3; + return res; +} +static inline short MULT16_16_Q13(int a, int b) +{ + long long res; + if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b)) + { + fprintf (stderr, "MULT16_16_Q13: inputs are not short: %d %d\n", a, b); + } + res = ((long long)a)*b; + res >>= 13; + if (!VERIFY_SHORT(res)) + fprintf (stderr, "MULT16_16_Q13: output is not short: %d*%d=%d\n", a, b, (int)res); + spx_mips+=3; + return res; +} +static inline short MULT16_16_Q14(int a, int b) +{ + long long res; + if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b)) + { + fprintf (stderr, "MULT16_16_Q14: inputs are not short: %d %d\n", a, b); + } + res = ((long long)a)*b; + res >>= 14; + if (!VERIFY_SHORT(res)) + fprintf (stderr, "MULT16_16_Q14: output is not short: %d\n", (int)res); + spx_mips+=3; + return res; +} +static inline short MULT16_16_Q15(int a, int b) +{ + long long res; + if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b)) + { + fprintf (stderr, "MULT16_16_Q15: inputs are not short: %d %d\n", a, b); + } + res = ((long long)a)*b; + res >>= 15; + if (!VERIFY_SHORT(res)) + { + fprintf (stderr, "MULT16_16_Q15: output is not short: %d\n", (int)res); + } + spx_mips+=3; + return res; +} + +static inline short MULT16_16_P13(int a, int b) +{ + long long res; + if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b)) + { + fprintf (stderr, "MULT16_16_P13: inputs are not short: %d %d\n", a, b); + } + res = ((long long)a)*b; + res += 4096; + if (!VERIFY_INT(res)) + fprintf (stderr, "MULT16_16_P13: overflow: %d*%d=%d\n", a, b, (int)res); + res >>= 13; + if (!VERIFY_SHORT(res)) + fprintf (stderr, "MULT16_16_P13: output is not short: %d*%d=%d\n", a, b, (int)res); + spx_mips+=4; + return res; +} +static inline short MULT16_16_P14(int a, int b) +{ + long long res; + if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b)) + { + fprintf (stderr, "MULT16_16_P14: inputs are not short: %d %d\n", a, b); + } + res = ((long long)a)*b; + res += 8192; + if (!VERIFY_INT(res)) + fprintf (stderr, "MULT16_16_P14: overflow: %d*%d=%d\n", a, b, (int)res); + res >>= 14; + if (!VERIFY_SHORT(res)) + fprintf (stderr, "MULT16_16_P14: output is not short: %d*%d=%d\n", a, b, (int)res); + spx_mips+=4; + return res; +} +static inline short MULT16_16_P15(int a, int b) +{ + long long res; + if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b)) + { + fprintf (stderr, "MULT16_16_P15: inputs are not short: %d %d\n", a, b); + } + res = ((long long)a)*b; + res += 16384; + if (!VERIFY_INT(res)) + fprintf (stderr, "MULT16_16_P15: overflow: %d*%d=%d\n", a, b, (int)res); + res >>= 15; + if (!VERIFY_SHORT(res)) + fprintf (stderr, "MULT16_16_P15: output is not short: %d*%d=%d\n", a, b, (int)res); + spx_mips+=4; + return res; +} + +#define DIV32_16(a, b) _DIV32_16(a, b, __FILE__, __LINE__) + +static inline int _DIV32_16(long long a, long long b, char *file, int line) +{ + long long res; + if (b==0) + { + fprintf(stderr, "DIV32_16: divide by zero: %d/%d in %s: line %d\n", (int)a, (int)b, file, line); + return 0; + } + if (!VERIFY_INT(a) || !VERIFY_SHORT(b)) + { + fprintf (stderr, "DIV32_16: inputs are not int/short: %d %d in %s: line %d\n", (int)a, (int)b, file, line); + } + res = a/b; + if (!VERIFY_SHORT(res)) + { + fprintf (stderr, "DIV32_16: output is not short: %d / %d = %d in %s: line %d\n", (int)a,(int)b,(int)res, file, line); + if (res>32767) + res = 32767; + if (res<-32768) + res = -32768; + } + spx_mips+=20; + return res; +} + +#define DIV32(a, b) _DIV32(a, b, __FILE__, __LINE__) +static inline int _DIV32(long long a, long long b, char *file, int line) +{ + long long res; + if (b==0) + { + fprintf(stderr, "DIV32: divide by zero: %d/%d in %s: line %d\n", (int)a, (int)b, file, line); + return 0; + } + + if (!VERIFY_INT(a) || !VERIFY_INT(b)) + { + fprintf (stderr, "DIV32: inputs are not int/short: %d %d in %s: line %d\n", (int)a, (int)b, file, line); + } + res = a/b; + if (!VERIFY_INT(res)) + fprintf (stderr, "DIV32: output is not int: %d in %s: line %d\n", (int)res, file, line); + spx_mips+=36; + return res; +} +#define PDIV32(a,b) DIV32(ADD32((a),(b)>>1),b) +#define PDIV32_16(a,b) DIV32_16(ADD32((a),(b)>>1),b) + +#endif diff --git a/lib/rbcodec/codecs/libspeex/fixed_generic.h b/lib/rbcodec/codecs/libspeex/fixed_generic.h new file mode 100644 index 0000000000..2948177c0b --- /dev/null +++ b/lib/rbcodec/codecs/libspeex/fixed_generic.h @@ -0,0 +1,106 @@ +/* Copyright (C) 2003 Jean-Marc Valin */ +/** + @file fixed_generic.h + @brief Generic fixed-point operations +*/ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + - Neither the name of the Xiph.org Foundation nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef FIXED_GENERIC_H +#define FIXED_GENERIC_H + +#define QCONST16(x,bits) ((spx_word16_t)(.5+(x)*(((spx_word32_t)1)<<(bits)))) +#define QCONST32(x,bits) ((spx_word32_t)(.5+(x)*(((spx_word32_t)1)<<(bits)))) + +#define NEG16(x) (-(x)) +#define NEG32(x) (-(x)) +#define EXTRACT16(x) ((spx_word16_t)(x)) +#define EXTEND32(x) ((spx_word32_t)(x)) +#define SHR16(a,shift) ((a) >> (shift)) +#define SHL16(a,shift) ((a) << (shift)) +#define SHR32(a,shift) ((a) >> (shift)) +#define SHL32(a,shift) ((a) << (shift)) +#define PSHR16(a,shift) (SHR16((a)+((1<<((shift))>>1)),shift)) +#define PSHR32(a,shift) (SHR32((a)+((1<<((shift))>>1)),shift)) +#define VSHR32(a, shift) (((shift)>0) ? SHR32(a, shift) : SHL32(a, -(shift))) +#define SATURATE16(x,a) (((x)>(a) ? (a) : (x)<-(a) ? -(a) : (x))) +#define SATURATE32(x,a) (((x)>(a) ? (a) : (x)<-(a) ? -(a) : (x))) + +#define SHR(a,shift) ((a) >> (shift)) +#define SHL(a,shift) ((spx_word32_t)(a) << (shift)) +#define PSHR(a,shift) (SHR((a)+((1<<((shift))>>1)),shift)) +#define SATURATE(x,a) (((x)>(a) ? (a) : (x)<-(a) ? -(a) : (x))) + + +#define ADD16(a,b) ((spx_word16_t)((spx_word16_t)(a)+(spx_word16_t)(b))) +#define SUB16(a,b) ((spx_word16_t)(a)-(spx_word16_t)(b)) +#define ADD32(a,b) ((spx_word32_t)(a)+(spx_word32_t)(b)) +#define SUB32(a,b) ((spx_word32_t)(a)-(spx_word32_t)(b)) + + +/* result fits in 16 bits */ +#define MULT16_16_16(a,b) ((((spx_word16_t)(a))*((spx_word16_t)(b)))) + +/* (spx_word32_t)(spx_word16_t) gives TI compiler a hint that it's 16x16->32 multiply */ +#define MULT16_16(a,b) (((spx_word32_t)(spx_word16_t)(a))*((spx_word32_t)(spx_word16_t)(b))) + +#define MAC16_16(c,a,b) (ADD32((c),MULT16_16((a),(b)))) +#define MULT16_32_Q12(a,b) ADD32(MULT16_16((a),SHR((b),12)), SHR(MULT16_16((a),((b)&0x00000fff)),12)) +#define MULT16_32_Q13(a,b) ADD32(MULT16_16((a),SHR((b),13)), SHR(MULT16_16((a),((b)&0x00001fff)),13)) +#define MULT16_32_Q14(a,b) ADD32(MULT16_16((a),SHR((b),14)), SHR(MULT16_16((a),((b)&0x00003fff)),14)) + +#define MULT16_32_Q11(a,b) ADD32(MULT16_16((a),SHR((b),11)), SHR(MULT16_16((a),((b)&0x000007ff)),11)) +#define MAC16_32_Q11(c,a,b) ADD32(c,ADD32(MULT16_16((a),SHR((b),11)), SHR(MULT16_16((a),((b)&0x000007ff)),11))) + +#define MULT16_32_P15(a,b) ADD32(MULT16_16((a),SHR((b),15)), PSHR(MULT16_16((a),((b)&0x00007fff)),15)) +#define MULT16_32_Q15(a,b) ADD32(MULT16_16((a),SHR((b),15)), SHR(MULT16_16((a),((b)&0x00007fff)),15)) +#define MAC16_32_Q15(c,a,b) ADD32(c,ADD32(MULT16_16((a),SHR((b),15)), SHR(MULT16_16((a),((b)&0x00007fff)),15))) + + +#define MAC16_16_Q11(c,a,b) (ADD32((c),SHR(MULT16_16((a),(b)),11))) +#define MAC16_16_Q13(c,a,b) (ADD32((c),SHR(MULT16_16((a),(b)),13))) +#define MAC16_16_P13(c,a,b) (ADD32((c),SHR(ADD32(4096,MULT16_16((a),(b))),13))) + +#define MULT16_16_Q11_32(a,b) (SHR(MULT16_16((a),(b)),11)) +#define MULT16_16_Q13(a,b) (SHR(MULT16_16((a),(b)),13)) +#define MULT16_16_Q14(a,b) (SHR(MULT16_16((a),(b)),14)) +#define MULT16_16_Q15(a,b) (SHR(MULT16_16((a),(b)),15)) + +#define MULT16_16_P13(a,b) (SHR(ADD32(4096,MULT16_16((a),(b))),13)) +#define MULT16_16_P14(a,b) (SHR(ADD32(8192,MULT16_16((a),(b))),14)) +#define MULT16_16_P15(a,b) (SHR(ADD32(16384,MULT16_16((a),(b))),15)) + +#define MUL_16_32_R15(a,bh,bl) ADD32(MULT16_16((a),(bh)), SHR(MULT16_16((a),(bl)),15)) + +#define DIV32_16(a,b) ((spx_word16_t)(((spx_word32_t)(a))/((spx_word16_t)(b)))) +#define PDIV32_16(a,b) ((spx_word16_t)(((spx_word32_t)(a)+((spx_word16_t)(b)>>1))/((spx_word16_t)(b)))) +#define DIV32(a,b) (((spx_word32_t)(a))/((spx_word32_t)(b))) +#define PDIV32(a,b) (((spx_word32_t)(a)+((spx_word16_t)(b)>>1))/((spx_word32_t)(b))) + +#endif diff --git a/lib/rbcodec/codecs/libspeex/gain_table.c b/lib/rbcodec/codecs/libspeex/gain_table.c new file mode 100644 index 0000000000..bf236e80fc --- /dev/null +++ b/lib/rbcodec/codecs/libspeex/gain_table.c @@ -0,0 +1,162 @@ +/* Copyright (C) 2002 Jean-Marc Valin + File: gain_table.c + Codebook for 3-tap pitch prediction gain (128 entries) + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + 3. The name of the author may not be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#include "config-speex.h" + +const signed char gain_cdbk_nb[512] GAIN_ICONST_ATTR = { +-32, -32, -32, 0, +-28, -67, -5, 33, +-42, -6, -32, 18, +-57, -10, -54, 35, +-16, 27, -41, 42, +19, -19, -40, 36, +-45, 24, -21, 40, +-8, -14, -18, 28, +1, 14, -58, 53, +-18, -88, -39, 39, +-38, 21, -18, 37, +-19, 20, -43, 38, +10, 17, -48, 54, +-52, -58, -13, 33, +-44, -1, -11, 32, +-12, -11, -34, 22, +14, 0, -46, 46, +-37, -35, -34, 5, +-25, 44, -30, 43, +6, -4, -63, 49, +-31, 43, -41, 43, +-23, 30, -43, 41, +-43, 26, -14, 44, +-33, 1, -13, 27, +-13, 18, -37, 37, +-46, -73, -45, 34, +-36, 24, -25, 34, +-36, -11, -20, 19, +-25, 12, -18, 33, +-36, -69, -59, 34, +-45, 6, 8, 46, +-22, -14, -24, 18, +-1, 13, -44, 44, +-39, -48, -26, 15, +-32, 31, -37, 34, +-33, 15, -46, 31, +-24, 30, -36, 37, +-41, 31, -23, 41, +-50, 22, -4, 50, +-22, 2, -21, 28, +-17, 30, -34, 40, +-7, -60, -28, 29, +-38, 42, -28, 42, +-44, -11, 21, 43, +-16, 8, -44, 34, +-39, -55, -43, 21, +-11, -35, 26, 41, +-9, 0, -34, 29, +-8, 121, -81, 113, +7, -16, -22, 33, +-37, 33, -31, 36, +-27, -7, -36, 17, +-34, 70, -57, 65, +-37, -11, -48, 21, +-40, 17, -1, 44, +-33, 6, -6, 33, +-9, 0, -20, 34, +-21, 69, -33, 57, +-29, 33, -31, 35, +-55, 12, -1, 49, +-33, 27, -22, 35, +-50, -33, -47, 17, +-50, 54, 51, 94, +-1, -5, -44, 35, +-4, 22, -40, 45, +-39, -66, -25, 24, +-33, 1, -26, 20, +-24, -23, -25, 12, +-11, 21, -45, 44, +-25, -45, -19, 17, +-43, 105, -16, 82, +5, -21, 1, 41, +-16, 11, -33, 30, +-13, -99, -4, 57, +-37, 33, -15, 44, +-25, 37, -63, 54, +-36, 24, -31, 31, +-53, -56, -38, 26, +-41, -4, 4, 37, +-33, 13, -30, 24, +49, 52, -94, 114, +-5, -30, -15, 23, +1, 38, -40, 56, +-23, 12, -36, 29, +-17, 40, -47, 51, +-37, -41, -39, 11, +-49, 34, 0, 58, +-18, -7, -4, 34, +-16, 17, -27, 35, +30, 5, -62, 65, +4, 48, -68, 76, +-43, 11, -11, 38, +-18, 19, -15, 41, +-23, -62, -39, 23, +-42, 10, -2, 41, +-21, -13, -13, 25, +-9, 13, -47, 42, +-23, -62, -24, 24, +-44, 60, -21, 58, +-18, -3, -52, 32, +-22, 22, -36, 34, +-75, 57, 16, 90, +-19, 3, 10, 45, +-29, 23, -38, 32, +-5, -62, -51, 38, +-51, 40, -18, 53, +-42, 13, -24, 32, +-34, 14, -20, 30, +-56, -75, -26, 37, +-26, 32, 15, 59, +-26, 17, -29, 29, +-7, 28, -52, 53, +-12, -30, 5, 30, +-5, -48, -5, 35, +2, 2, -43, 40, +21, 16, 16, 75, +-25, -45, -32, 10, +-43, 18, -10, 42, +9, 0, -1, 52, +-1, 7, -30, 36, +19, -48, -4, 48, +-28, 25, -29, 32, +-22, 0, -31, 22, +-32, 17, -10, 36, +-64, -41, -62, 36, +-52, 15, 16, 58, +-30, -22, -32, 6, +-7, 9, -38, 36}; diff --git a/lib/rbcodec/codecs/libspeex/gain_table_lbr.c b/lib/rbcodec/codecs/libspeex/gain_table_lbr.c new file mode 100644 index 0000000000..b74df318a3 --- /dev/null +++ b/lib/rbcodec/codecs/libspeex/gain_table_lbr.c @@ -0,0 +1,66 @@ +/* Copyright (C) 2002 Jean-Marc Valin + File: gain_table_lbr.c + Codebook for 3-tap pitch prediction gain (32 entries) + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + 3. The name of the author may not be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#include "config-speex.h" + +const signed char gain_cdbk_lbr[128] GAIN_ICONST_ATTR = { +-32, -32, -32, 0, +-31, -58, -16, 22, +-41, -24, -43, 14, +-56, -22, -55, 29, +-13, 33, -41, 47, +-4, -39, -9, 29, +-41, 15, -12, 38, +-8, -15, -12, 31, +1, 2, -44, 40, +-22, -66, -42, 27, +-38, 28, -23, 38, +-21, 14, -37, 31, +0, 21, -50, 52, +-53, -71, -27, 33, +-37, -1, -19, 25, +-19, -5, -28, 22, +6, 65, -44, 74, +-33, -48, -33, 9, +-40, 57, -14, 58, +-17, 4, -45, 32, +-31, 38, -33, 36, +-23, 28, -40, 39, +-43, 29, -12, 46, +-34, 13, -23, 28, +-16, 15, -27, 34, +-14, -82, -15, 43, +-31, 25, -32, 29, +-21, 5, -5, 38, +-47, -63, -51, 33, +-46, 12, 3, 47, +-28, -17, -29, 11, +-10, 14, -40, 38}; diff --git a/lib/rbcodec/codecs/libspeex/hexc_10_32_table.c b/lib/rbcodec/codecs/libspeex/hexc_10_32_table.c new file mode 100644 index 0000000000..9a924e7ff0 --- /dev/null +++ b/lib/rbcodec/codecs/libspeex/hexc_10_32_table.c @@ -0,0 +1,68 @@ +/* Copyright (C) 2002 Jean-Marc Valin + File: hexc_10_32_table.c + Codebook for high-band excitation in SB-CELP mode (4000 bps) + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + - Neither the name of the Xiph.org Foundation nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include "config-speex.h" + +const signed char hexc_10_32_table[320] HEXC_ICONST_ATTR = { +-3, -2, -1, 0, -4, 5, 35, -40, -9, 13, +-44, 5, -27, -1, -7, 6, -11, 7, -8, 7, +19, -14, 15, -4, 9, -10, 10, -8, 10, -9, +-1, 1, 0, 0, 2, 5, -18, 22, -53, 50, +1, -23, 50, -36, 15, 3, -13, 14, -10, 6, +1, 5, -3, 4, -2, 5, -32, 25, 5, -2, +-1, -4, 1, 11, -29, 26, -6, -15, 30, -18, +0, 15, -17, 40, -41, 3, 9, -2, -2, 3, +-3, -1, -5, 2, 21, -6, -16, -21, 23, 2, +60, 15, 16, -16, -9, 14, 9, -1, 7, -9, +0, 1, 1, 0, -1, -6, 17, -28, 54, -45, +-1, 1, -1, -6, -6, 2, 11, 26, -29, -2, +46, -21, 34, 12, -23, 32, -23, 16, -10, 3, +66, 19, -20, 24, 7, 11, -3, 0, -3, -1, +-50, -46, 2, -18, -3, 4, -1, -2, 3, -3, +-19, 41, -36, 9, 11, -24, 21, -16, 9, -3, +-25, -3, 10, 18, -9, -2, -5, -1, -5, 6, +-4, -3, 2, -26, 21, -19, 35, -15, 7, -13, +17, -19, 39, -43, 48, -31, 16, -9, 7, -2, +-5, 3, -4, 9, -19, 27, -55, 63, -35, 10, +26, -44, -2, 9, 4, 1, -6, 8, -9, 5, +-8, -1, -3, -16, 45, -42, 5, 15, -16, 10, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +-16, 24, -55, 47, -38, 27, -19, 7, -3, 1, +16, 27, 20, -19, 18, 5, -7, 1, -5, 2, +-6, 8, -22, 0, -3, -3, 8, -1, 7, -8, +1, -3, 5, 0, 17, -48, 58, -52, 29, -7, +-2, 3, -10, 6, -26, 58, -31, 1, -6, 3, +93, -29, 39, 3, 17, 5, 6, -1, -1, -1, +27, 13, 10, 19, -7, -34, 12, 10, -4, 9, +-76, 9, 8, -28, -2, -11, 2, -1, 3, 1, +-83, 38, -39, 4, -16, -6, -2, -5, 5, -2, +}; diff --git a/lib/rbcodec/codecs/libspeex/hexc_table.c b/lib/rbcodec/codecs/libspeex/hexc_table.c new file mode 100644 index 0000000000..d892abd18c --- /dev/null +++ b/lib/rbcodec/codecs/libspeex/hexc_table.c @@ -0,0 +1,164 @@ +/* Copyright (C) 2002 Jean-Marc Valin + File: hexc_table.c + Codebook for high-band excitation in SB-CELP mode (8000 bps with sign) + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + - Neither the name of the Xiph.org Foundation nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include "config-speex.h" + +const signed char hexc_table[1024] HEXC_ICONST_ATTR = { +-24, 21, -20, 5, -5, -7, 14, -10, +2, -27, 16, -20, 0, -32, 26, 19, +8, -11, -41, 31, 28, -27, -32, 34, +42, 34, -17, 22, -10, 13, -29, 18, +-12, -26, -24, 11, 22, 5, -5, -5, +54, -68, -43, 57, -25, 24, 4, 4, +26, -8, -12, -17, 54, 30, -45, 1, +10, -15, 18, -41, 11, 68, -67, 37, +-16, -24, -16, 38, -22, 6, -29, 30, +66, -27, 5, 7, -16, 13, 2, -12, +-7, -3, -20, 36, 4, -28, 9, 3, +32, 48, 26, 39, 3, 0, 7, -21, +-13, 5, -82, -7, 73, -20, 34, -9, +-5, 1, -1, 10, -5, -10, -1, 9, +1, -9, 10, 0, -14, 11, -1, -2, +-1, 11, 20, 96, -81, -22, -12, -9, +-58, 9, 24, -30, 26, -35, 27, -12, +13, -18, 56, -59, 15, -7, 23, -15, +-1, 6, -25, 14, -22, -20, 47, -11, +16, 2, 38, -23, -19, -30, -9, 40, +-11, 5, 4, -6, 8, 26, -21, -11, +127, 4, 1, 6, -9, 2, -7, -2, +-3, 7, -5, 10, -19, 7, -106, 91, +-3, 9, -4, 21, -8, 26, -80, 8, +1, -2, -10, -17, -17, -27, 32, 71, +6, -29, 11, -23, 54, -38, 29, -22, +39, 87, -31, -12, -20, 3, -2, -2, +2, 20, 0, -1, -35, 27, 9, -6, +-12, 3, -12, -6, 13, 1, 14, -22, +-59, -15, -17, -25, 13, -7, 7, 3, +0, 1, -7, 6, -3, 61, -37, -23, +-23, -29, 38, -31, 27, 1, -8, 2, +-27, 23, -26, 36, -34, 5, 24, -24, +-6, 7, 3, -59, 78, -62, 44, -16, +1, 6, 0, 17, 8, 45, 0, -110, +6, 14, -2, 32, -77, -56, 62, -3, +3, -13, 4, -16, 102, -15, -36, -1, +9, -113, 6, 23, 0, 9, 9, 5, +-8, -1, -14, 5, -12, 121, -53, -27, +-8, -9, 22, -13, 3, 2, -3, 1, +-2, -71, 95, 38, -19, 15, -16, -5, +71, 10, 2, -32, -13, -5, 15, -1, +-2, -14, -85, 30, 29, 6, 3, 2, +0, 0, 0, 0, 0, 0, 0, 0, +2, -65, -56, -9, 18, 18, 23, -14, +-2, 0, 12, -29, 26, -12, 1, 2, +-12, -64, 90, -6, 4, 1, 5, -5, +-110, -3, -31, 22, -29, 9, 0, 8, +-40, -5, 21, -5, -5, 13, 10, -18, +40, 1, 35, -20, 30, -28, 11, -6, +19, 7, 14, 18, -64, 9, -6, 16, +51, 68, 8, 16, 12, -8, 0, -9, +20, -22, 25, 7, -4, -13, 41, -35, +93, -18, -54, 11, -1, 1, -9, 4, +-66, 66, -31, 20, -22, 25, -23, 11, +10, 9, 19, 15, 11, -5, -31, -10, +-23, -28, -6, -6, -3, -4, 5, 3, +-28, 22, -11, -42, 25, -25, -16, 41, +34, 47, -6, 2, 42, -19, -22, 5, +-39, 32, 6, -35, 22, 17, -30, 8, +-26, -11, -11, 3, -12, 33, 33, -37, +21, -1, 6, -4, 3, 0, -5, 5, +12, -12, 57, 27, -61, -3, 20, -17, +2, 0, 4, 0, -2, -33, -58, 81, +-23, 39, -10, -5, 2, 6, -7, 5, +4, -3, -2, -13, -23, -72, 107, 15, +-5, 0, -7, -3, -6, 5, -4, 15, +47, 12, -31, 25, -16, 8, 22, -25, +-62, -56, -18, 14, 28, 12, 2, -11, +74, -66, 41, -20, -7, 16, -20, 16, +-8, 0, -16, 4, -19, 92, 12, -59, +-14, -39, 49, -25, -16, 23, -27, 19, +-3, -33, 19, 85, -29, 6, -7, -10, +16, -7, -12, 1, -6, 2, 4, -2, +64, 10, -25, 41, -2, -31, 15, 0, +110, 50, 69, 35, 28, 19, -10, 2, +-43, -49, -56, -15, -16, 10, 3, 12, +-1, -8, 1, 26, -12, -1, 7, -11, +-27, 41, 25, 1, -11, -18, 22, -7, +-1, -47, -8, 23, -3, -17, -7, 18, +-125, 59, -5, 3, 18, 1, 2, 3, +27, -35, 65, -53, 50, -46, 37, -21, +-28, 7, 14, -37, -5, -5, 12, 5, +-8, 78, -19, 21, -6, -16, 8, -7, +5, 2, 7, 2, 10, -6, 12, -60, +44, 11, -36, -32, 31, 0, 2, -2, +2, 1, -3, 7, -10, 17, -21, 10, +6, -2, 19, -2, 59, -38, -86, 38, +8, -41, -30, -45, -33, 7, 15, 28, +29, -7, 24, -40, 7, 7, 5, -2, +9, 24, -23, -18, 6, -29, 30, 2, +28, 49, -11, -46, 10, 43, -13, -9, +-1, -3, -7, -7, -17, -6, 97, -33, +-21, 3, 5, 1, 12, -43, -8, 28, +7, -43, -7, 17, -20, 19, -1, 2, +-13, 9, 54, 34, 9, -28, -11, -9, +-17, 110, -59, 44, -26, 0, 3, -12, +-47, 73, -34, -43, 38, -33, 16, -5, +-46, -4, -6, -2, -25, 19, -29, 28, +-13, 5, 14, 27, -40, -43, 4, 32, +-13, -2, -35, -4, 112, -42, 9, -12, +37, -28, 17, 14, -19, 35, -39, 23, +3, -14, -1, -57, -5, 94, -9, 3, +-39, 5, 30, -10, -32, 42, -13, -14, +-97, -63, 30, -9, 1, -7, 12, 5, +20, 17, -9, -36, -30, 25, 47, -9, +-15, 12, -22, 98, -8, -50, 15, -27, +21, -16, -11, 2, 12, -10, 10, -3, +33, 36, -96, 0, -17, 31, -9, 9, +3, -20, 13, -11, 8, -4, 10, -10, +9, 1, 112, -70, -27, 5, -21, 2, +-57, -3, -29, 10, 19, -21, 21, -10, +-66, -3, 91, -35, 30, -12, 0, -7, +59, -28, 26, 2, 14, -18, 1, 1, +11, 17, 20, -54, -59, 27, 4, 29, +32, 5, 19, 12, -4, 1, 7, -10, +5, -2, 10, 0, 23, -5, 28, -104, +46, 11, 16, 3, 29, 1, -8, -14, +1, 7, -50, 88, -62, 26, 8, -17, +-14, 50, 0, 32, -12, -3, -27, 18, +-8, -5, 8, 3, -20, -11, 37, -12, +9, 33, 46, -101, -1, -4, 1, 6, +-1, 28, -42, -15, 16, 5, -1, -2, +-55, 85, 38, -9, -4, 11, -2, -9, +-6, 3, -20, -10, -77, 89, 24, -3, +-104, -57, -26, -31, -20, -6, -9, 14, +20, -23, 46, -15, -31, 28, 1, -15, +-2, 6, -2, 31, 45, -76, 23, -25, +}; diff --git a/lib/rbcodec/codecs/libspeex/high_lsp_tables.c b/lib/rbcodec/codecs/libspeex/high_lsp_tables.c new file mode 100644 index 0000000000..56dc0f9faa --- /dev/null +++ b/lib/rbcodec/codecs/libspeex/high_lsp_tables.c @@ -0,0 +1,165 @@ +/* Copyright (C) 2002 Jean-Marc Valin + File: high_lsp_tables.c + Codebooks for high-band LSPs in SB-CELP mode + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + 3. The name of the author may not be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#include "config-speex.h" + +const signed char high_lsp_cdbk[512] LSP_ICONST_ATTR ={ +39,12,-14,-20,-29,-61,-67,-76, +-32,-71,-67,68,77,46,34,5, +-13,-48,-46,-72,-81,-84,-60,-58, +-40,-28,82,93,68,45,29,3, +-19,-47,-28,-43,-35,-30,-8,-13, +-39,-91,-91,-123,-96,10,10,-6, +-18,-55,-60,-91,-56,-36,-27,-16, +-48,-75,40,28,-10,-28,35,9, +37,19,1,-20,-31,-41,-18,-25, +-35,-68,-80,45,27,-1,47,13, +0,-29,-35,-57,-50,-79,-73,-38, +-19,5,35,14,-10,-23,16,-8, +5,-24,-40,-62,-23,-27,-22,-16, +-18,-46,-72,-77,43,21,33,1, +-80,-70,-70,-64,-56,-52,-39,-33, +-31,-38,-19,-19,-15,32,33,-2, +7,-15,-15,-24,-23,-33,-41,-56, +-24,-57,5,89,64,41,27,5, +-9,-47,-60,-97,-97,-124,-20,-9, +-44,-73,31,29,-4,64,48,7, +-35,-57,0,-3,-26,-47,-3,-6, +-40,-76,-79,-48,12,81,55,10, +9,-24,-43,-73,-57,-69,16,5, +-28,-53,18,29,20,0,-4,-11, +6,-13,23,7,-17,-35,-37,-37, +-30,-68,-63,6,24,-9,-14,3, +21,-13,-27,-57,-49,-80,-24,-41, +-5,-16,-5,1,45,25,12,-7, +3,-15,-6,-16,-15,-8,6,-13, +-42,-81,-80,-87,14,1,-10,-3, +-43,-69,-46,-24,-28,-29,36,6, +-43,-56,-12,12,54,79,43,9, +54,22,2,8,-12,-43,-46,-52, +-38,-69,-89,-5,75,38,33,5, +-13,-53,-62,-87,-89,-113,-99,-55, +-34,-37,62,55,33,16,21,-2, +-17,-46,-29,-38,-38,-48,-39,-42, +-36,-75,-72,-88,-48,-30,21,2, +-15,-57,-64,-98,-84,-76,25,1, +-46,-80,-12,18,-7,3,34,6, +38,31,23,4,-1,20,14,-15, +-43,-78,-91,-24,14,-3,54,16, +0,-27,-28,-44,-56,-83,-92,-89, +-3,34,56,41,36,22,20,-8, +-7,-35,-42,-62,-49,3,12,-10, +-50,-87,-96,-66,92,70,38,9, +-70,-71,-62,-42,-39,-43,-11,-7, +-50,-79,-58,-50,-31,32,31,-6, +-4,-25,7,-17,-38,-70,-58,-27, +-43,-83,-28,59,36,20,31,2, +-27,-71,-80,-109,-98,-75,-33,-32, +-31,-2,33,15,-6,43,33,-5, +0,-22,-10,-27,-34,-49,-11,-20, +-41,-91,-100,-121,-39,57,41,10, +-19,-50,-38,-59,-60,-70,-18,-20, +-8,-31,-8,-15,1,-14,-26,-25, +33,21,32,17,1,-19,-19,-26, +-58,-81,-35,-22,45,30,11,-11, +3,-26,-48,-87,-67,-83,-58,3, +-1,-26,-20,44,10,25,39,5, +-9,-35,-27,-38,7,10,4,-9, +-42,-85,-102,-127,52,44,28,10, +-47,-61,-40,-39,-17,-1,-10,-33, +-42,-74,-48,21,-4,70,52,10}; + + +const signed char high_lsp_cdbk2[512] LSP_ICONST_ATTR ={ +-36,-62,6,-9,-10,-14,-56,23, +1,-26,23,-48,-17,12,8,-7, +23,29,-36,-28,-6,-29,-17,-5, +40,23,10,10,-46,-13,36,6, +4,-30,-29,62,32,-32,-1,22, +-14,1,-4,-22,-45,2,54,4, +-30,-57,-59,-12,27,-3,-31,8, +-9,5,10,-14,32,66,19,9, +2,-25,-37,23,-15,18,-38,-31, +5,-9,-21,15,0,22,62,30, +15,-12,-14,-46,77,21,33,3, +34,29,-19,50,2,11,9,-38, +-12,-37,62,1,-15,54,32,6, +2,-24,20,35,-21,2,19,24, +-13,55,4,9,39,-19,30,-1, +-21,73,54,33,8,18,3,15, +6,-19,-47,6,-3,-48,-50,1, +26,20,8,-23,-50,65,-14,-55, +-17,-31,-37,-28,53,-1,-17,-53, +1,57,11,-8,-25,-30,-37,64, +5,-52,-45,15,23,31,15,14, +-25,24,33,-2,-44,-56,-18,6, +-21,-43,4,-12,17,-37,20,-10, +34,15,2,15,55,21,-11,-31, +-6,46,25,16,-9,-25,-8,-62, +28,17,20,-32,-29,26,30,25, +-19,2,-16,-17,26,-51,2,50, +42,19,-66,23,29,-2,3,19, +-19,-37,32,15,6,30,-34,13, +11,-5,40,31,10,-42,4,-9, +26,-9,-70,17,-2,-23,20,-22, +-55,51,-24,-31,22,-22,15,-13, +3,-10,-28,-16,56,4,-63,11, +-18,-15,-18,-38,-35,16,-7,34, +-1,-21,-49,-47,9,-37,7,8, +69,55,20,6,-33,-45,-10,-9, +6,-9,12,71,15,-3,-42,-7, +-24,32,-35,-2,-42,-17,-5,0, +-2,-33,-54,13,-12,-34,47,23, +19,55,7,-8,74,31,14,16, +-23,-26,19,12,-18,-49,-28,-31, +-20,2,-14,-20,-47,78,40,13, +-23,-11,21,-6,18,1,47,5, +38,35,32,46,22,8,13,16, +-14,18,51,19,40,39,11,-26, +-1,-17,47,2,-53,-15,31,-22, +38,21,-15,-16,5,-33,53,15, +-38,86,11,-3,-24,49,13,-4, +-11,-18,28,20,-12,-27,-26,35, +-25,-35,-3,-20,-61,30,10,-55, +-12,-22,-52,-54,-14,19,-32,-12, +45,15,-8,-48,-9,11,-32,8, +-16,-34,-13,51,18,38,-2,-32, +-17,22,-2,-18,-28,-70,59,27, +-28,-19,-10,-20,-9,-9,-8,-21, +21,-8,35,-2,45,-3,-9,12, +0,30,7,-39,43,27,-38,-91, +30,26,19,-55,-4,63,14,-17, +13,9,13,2,7,4,6,61, +72,-1,-17,29,-1,-22,-17,8, +-28,-37,63,44,41,3,2,14, +9,-6,75,-8,-7,-12,-15,-12, +13,9,-4,30,-22,-65,15,0, +-45,4,-4,1,5,22,11,23}; diff --git a/lib/rbcodec/codecs/libspeex/jitter.c b/lib/rbcodec/codecs/libspeex/jitter.c new file mode 100644 index 0000000000..d9f6c67b86 --- /dev/null +++ b/lib/rbcodec/codecs/libspeex/jitter.c @@ -0,0 +1,839 @@ +/* Copyright (C) 2002 Jean-Marc Valin + File: speex_jitter.h + + Adaptive jitter buffer for Speex + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + - Neither the name of the Xiph.org Foundation nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + +/* +TODO: +- Add short-term estimate +- Defensive programming + + warn when last returned < last desired (begative buffering) + + warn if update_delay not called between get() and tick() or is called twice in a row +- Linked list structure for holding the packets instead of the current fixed-size array + + return memory to a pool + + allow pre-allocation of the pool + + optional max number of elements +- Statistics + + drift + + loss + + late + + jitter + + buffering delay +*/ +#ifdef HAVE_CONFIG_H +#include "config-speex.h" +#endif + + +#include "arch.h" +#include "speex/speex.h" +#include "speex/speex_bits.h" +#include "speex/speex_jitter.h" +#include "os_support.h" + +#ifndef NULL +#define NULL 0 +#endif + +#define SPEEX_JITTER_MAX_BUFFER_SIZE 200 /**< Maximum number of packets in jitter buffer */ + +#define TSUB(a,b) ((spx_int32_t)((a)-(b))) + +#define GT32(a,b) (((spx_int32_t)((a)-(b)))>0) +#define GE32(a,b) (((spx_int32_t)((a)-(b)))>=0) +#define LT32(a,b) (((spx_int32_t)((a)-(b)))<0) +#define LE32(a,b) (((spx_int32_t)((a)-(b)))<=0) + +#define ROUND_DOWN(x, step) ((x)<0 ? ((x)-(step)+1)/(step)*(step) : (x)/(step)*(step)) + +#define MAX_TIMINGS 20 +#define MAX_BUFFERS 3 +#define TOP_DELAY 20 + +/** Buffer that keeps the time of arrival of the latest packets */ +struct TimingBuffer { + int filled; /**< Number of entries occupied in "timing" and "counts"*/ + int curr_count; /**< Number of packet timings we got (including those we discarded) */ + spx_int16_t timing[MAX_TIMINGS]; /**< Sorted list of all timings ("latest" packets first) */ + spx_int16_t counts[MAX_TIMINGS]; /**< Order the packets were put in (will be used for short-term estimate) */ +}; + +static void tb_init(struct TimingBuffer *tb) +{ + tb->filled = 0; + tb->curr_count = 0; +} + +/* Add the timing of a new packet to the TimingBuffer */ +static void tb_add(struct TimingBuffer *tb, spx_int16_t timing) +{ + int pos; + /* Discard packet that won't make it into the list because they're too early */ + if (tb->filled >= MAX_TIMINGS && timing >= tb->timing[tb->filled-1]) + { + tb->curr_count++; + return; + } + + /* Find where the timing info goes in the sorted list */ + pos = 0; + /* FIXME: Do bisection instead of linear search */ + while (posfilled && timing >= tb->timing[pos]) + { + pos++; + } + + speex_assert(pos <= tb->filled && pos < MAX_TIMINGS); + + /* Shift everything so we can perform the insertion */ + if (pos < tb->filled) + { + int move_size = tb->filled-pos; + if (tb->filled == MAX_TIMINGS) + move_size -= 1; + SPEEX_COPY(&tb->timing[pos+1], &tb->timing[pos], move_size); + SPEEX_COPY(&tb->counts[pos+1], &tb->counts[pos], move_size); + } + /* Insert */ + tb->timing[pos] = timing; + tb->counts[pos] = tb->curr_count; + + tb->curr_count++; + if (tb->filledfilled++; +} + + + +/** Jitter buffer structure */ +struct JitterBuffer_ { + spx_uint32_t pointer_timestamp; /**< Timestamp of what we will *get* next */ + spx_uint32_t last_returned_timestamp; /**< Useful for getting the next packet with the same timestamp (for fragmented media) */ + spx_uint32_t next_stop; /**< Estimated time the next get() will be called */ + + spx_int32_t buffered; /**< Amount of data we think is still buffered by the application (timestamp units)*/ + + JitterBufferPacket packets[SPEEX_JITTER_MAX_BUFFER_SIZE]; /**< Packets stored in the buffer */ + spx_uint32_t arrival[SPEEX_JITTER_MAX_BUFFER_SIZE]; /**< Packet arrival time (0 means it was late, even though it's a valid timestamp) */ + + void (*destroy) (void *); /**< Callback for destroying a packet */ + + spx_int32_t delay_step; /**< Size of the steps when adjusting buffering (timestamp units) */ + spx_int32_t concealment_size; /**< Size of the packet loss concealment "units" */ + int reset_state; /**< True if state was just reset */ + int buffer_margin; /**< How many frames we want to keep in the buffer (lower bound) */ + int late_cutoff; /**< How late must a packet be for it not to be considered at all */ + int interp_requested; /**< An interpolation is requested by speex_jitter_update_delay() */ + int auto_adjust; /**< Whether to automatically adjust the delay at any time */ + + struct TimingBuffer _tb[MAX_BUFFERS]; /**< Don't use those directly */ + struct TimingBuffer *timeBuffers[MAX_BUFFERS]; /**< Storing arrival time of latest frames so we can compute some stats */ + int window_size; /**< Total window over which the late frames are counted */ + int subwindow_size; /**< Sub-window size for faster computation */ + int max_late_rate; /**< Absolute maximum amount of late packets tolerable (in percent) */ + int latency_tradeoff; /**< Latency equivalent of losing one percent of packets */ + int auto_tradeoff; /**< Latency equivalent of losing one percent of packets (automatic default) */ + + int lost_count; /**< Number of consecutive lost packets */ +}; + +/** Based on available data, this computes the optimal delay for the jitter buffer. + The optimised function is in timestamp units and is: + cost = delay + late_factor*[number of frames that would be late if we used that delay] + @param tb Array of buffers + @param late_factor Equivalent cost of a late frame (in timestamp units) + */ +static spx_int16_t compute_opt_delay(JitterBuffer *jitter) +{ + int i; + spx_int16_t opt=0; + spx_int32_t best_cost=0x7fffffff; + int late = 0; + int pos[MAX_BUFFERS]; + int tot_count; + float late_factor; + int penalty_taken = 0; + int best = 0; + int worst = 0; + spx_int32_t deltaT; + struct TimingBuffer *tb; + + tb = jitter->_tb; + + /* Number of packet timings we have received (including those we didn't keep) */ + tot_count = 0; + for (i=0;ilatency_tradeoff != 0) + late_factor = jitter->latency_tradeoff * 100.0f / tot_count; + else + late_factor = jitter->auto_tradeoff * jitter->window_size/tot_count; + + /*fprintf(stderr, "late_factor = %f\n", late_factor);*/ + for (i=0;idelay_step); + pos[next]++; + + /* Actual cost function that tells us how bad using this delay would be */ + cost = -latest + late_factor*late; + /*fprintf(stderr, "cost %d = %d + %f * %d\n", cost, -latest, late_factor, late);*/ + if (cost < best_cost) + { + best_cost = cost; + opt = latest; + } + } else { + break; + } + + /* For the next timing we will consider, there will be one more late packet to count */ + late++; + /* Two-frame penalty if we're going to increase the amount of late frames (hysteresis) */ + if (latest >= 0 && !penalty_taken) + { + penalty_taken = 1; + late+=2; + } + } + + deltaT = best-worst; + /* This is a default "automatic latency tradeoff" when none is provided */ + jitter->auto_tradeoff = 1 + deltaT/TOP_DELAY; + /*fprintf(stderr, "auto_tradeoff = %d (%d %d %d)\n", jitter->auto_tradeoff, best, worst, i);*/ + + /* FIXME: Compute a short-term estimate too and combine with the long-term one */ + + /* Prevents reducing the buffer size when we haven't really had much data */ + if (tot_count < TOP_DELAY && opt > 0) + return 0; + return opt; +} + + +/** Initialise jitter buffer */ +JitterBuffer *jitter_buffer_init(int step_size) +{ + JitterBuffer *jitter = (JitterBuffer*)speex_alloc(sizeof(JitterBuffer)); + if (jitter) + { + int i; + spx_int32_t tmp; + for (i=0;ipackets[i].data=NULL; + jitter->delay_step = step_size; + jitter->concealment_size = step_size; + /*FIXME: Should this be 0 or 1?*/ + jitter->buffer_margin = 0; + jitter->late_cutoff = 50; + jitter->destroy = NULL; + jitter->latency_tradeoff = 0; + jitter->auto_adjust = 1; + tmp = 4; + jitter_buffer_ctl(jitter, JITTER_BUFFER_SET_MAX_LATE_RATE, &tmp); + jitter_buffer_reset(jitter); + } + return jitter; +} + +/** Reset jitter buffer */ +void jitter_buffer_reset(JitterBuffer *jitter) +{ + int i; + for (i=0;ipackets[i].data) + { + if (jitter->destroy) + jitter->destroy(jitter->packets[i].data); + else + speex_free(jitter->packets[i].data); + jitter->packets[i].data = NULL; + } + } + /* Timestamp is actually undefined at this point */ + jitter->pointer_timestamp = 0; + jitter->next_stop = 0; + jitter->reset_state = 1; + jitter->lost_count = 0; + jitter->buffered = 0; + jitter->auto_tradeoff = 32000; + + for (i=0;i_tb[i]); + jitter->timeBuffers[i] = &jitter->_tb[i]; + } + /*fprintf (stderr, "reset\n");*/ +} + +/** Destroy jitter buffer */ +void jitter_buffer_destroy(JitterBuffer *jitter) +{ + jitter_buffer_reset(jitter); + speex_free(jitter); +} + +/** Take the following timing into consideration for future calculations */ +static void update_timings(JitterBuffer *jitter, spx_int32_t timing) +{ + if (timing < -32767) + timing = -32767; + if (timing > 32767) + timing = 32767; + /* If the current sub-window is full, perform a rotation and discard oldest sub-widow */ + if (jitter->timeBuffers[0]->curr_count >= jitter->subwindow_size) + { + int i; + /*fprintf(stderr, "Rotate buffer\n");*/ + struct TimingBuffer *tmp = jitter->timeBuffers[MAX_BUFFERS-1]; + for (i=MAX_BUFFERS-1;i>=1;i--) + jitter->timeBuffers[i] = jitter->timeBuffers[i-1]; + jitter->timeBuffers[0] = tmp; + tb_init(jitter->timeBuffers[0]); + } + tb_add(jitter->timeBuffers[0], timing); +} + +/** Compensate all timings when we do an adjustment of the buffering */ +static void shift_timings(JitterBuffer *jitter, spx_int16_t amount) +{ + int i, j; + for (i=0;itimeBuffers[i]->filled;j++) + jitter->timeBuffers[i]->timing[j] += amount; + } +} + + +/** Put one packet into the jitter buffer */ +void jitter_buffer_put(JitterBuffer *jitter, const JitterBufferPacket *packet) +{ + int i,j; + int late; + /*fprintf (stderr, "put packet %d %d\n", timestamp, span);*/ + + /* Cleanup buffer (remove old packets that weren't played) */ + if (!jitter->reset_state) + { + for (i=0;ipackets[i].data && LE32(jitter->packets[i].timestamp + jitter->packets[i].span, jitter->pointer_timestamp)) + { + /*fprintf (stderr, "cleaned (not played)\n");*/ + if (jitter->destroy) + jitter->destroy(jitter->packets[i].data); + else + speex_free(jitter->packets[i].data); + jitter->packets[i].data = NULL; + } + } + } + + /*fprintf(stderr, "arrival: %d %d %d\n", packet->timestamp, jitter->next_stop, jitter->pointer_timestamp);*/ + /* Check if packet is late (could still be useful though) */ + if (!jitter->reset_state && LT32(packet->timestamp, jitter->next_stop)) + { + update_timings(jitter, ((spx_int32_t)packet->timestamp) - ((spx_int32_t)jitter->next_stop) - jitter->buffer_margin); + late = 1; + } else { + late = 0; + } + + /* Only insert the packet if it's not hopelessly late (i.e. totally useless) */ + if (jitter->reset_state || GE32(packet->timestamp+packet->span+jitter->delay_step, jitter->pointer_timestamp)) + { + + /*Find an empty slot in the buffer*/ + for (i=0;ipackets[i].data==NULL) + break; + } + + /*No place left in the buffer, need to make room for it by discarding the oldest packet */ + if (i==SPEEX_JITTER_MAX_BUFFER_SIZE) + { + int earliest=jitter->packets[0].timestamp; + i=0; + for (j=1;jpackets[i].data || LT32(jitter->packets[j].timestamp,earliest)) + { + earliest = jitter->packets[j].timestamp; + i=j; + } + } + if (jitter->destroy) + jitter->destroy(jitter->packets[i].data); + else + speex_free(jitter->packets[i].data); + jitter->packets[i].data=NULL; + if (jitter->lost_count>20) + { + jitter_buffer_reset(jitter); + } + /*fprintf (stderr, "Buffer is full, discarding earliest frame %d (currently at %d)\n", timestamp, jitter->pointer_timestamp);*/ + } + + /* Copy packet in buffer */ + if (jitter->destroy) + { + jitter->packets[i].data = packet->data; + } else { + jitter->packets[i].data=(char*)speex_alloc(packet->len); + for (j=0;jlen;j++) + jitter->packets[i].data[j]=packet->data[j]; + } + jitter->packets[i].timestamp=packet->timestamp; + jitter->packets[i].span=packet->span; + jitter->packets[i].len=packet->len; + jitter->packets[i].sequence=packet->sequence; + jitter->packets[i].user_data=packet->user_data; + if (jitter->reset_state || late) + jitter->arrival[i] = 0; + else + jitter->arrival[i] = jitter->next_stop; + } + + +} + +/** Get one packet from the jitter buffer */ +int jitter_buffer_get(JitterBuffer *jitter, JitterBufferPacket *packet, spx_int32_t desired_span, spx_int32_t *start_offset) +{ + int i; + unsigned int j; + int incomplete = 0; + spx_int16_t opt; + + if (start_offset != NULL) + *start_offset = 0; + + /* Syncing on the first call */ + if (jitter->reset_state) + { + int found = 0; + /* Find the oldest packet */ + spx_uint32_t oldest=0; + for (i=0;ipackets[i].data && (!found || LT32(jitter->packets[i].timestamp,oldest))) + { + oldest = jitter->packets[i].timestamp; + found = 1; + } + } + if (found) + { + jitter->reset_state=0; + jitter->pointer_timestamp = oldest; + jitter->next_stop = oldest; + } else { + packet->timestamp = 0; + packet->span = jitter->interp_requested; + return JITTER_BUFFER_MISSING; + } + } + + + jitter->last_returned_timestamp = jitter->pointer_timestamp; + + if (jitter->interp_requested != 0) + { + packet->timestamp = jitter->pointer_timestamp; + packet->span = jitter->interp_requested; + + /* Increment the pointer because it got decremented in the delay update */ + jitter->pointer_timestamp += jitter->interp_requested; + packet->len = 0; + /*fprintf (stderr, "Deferred interpolate\n");*/ + + jitter->interp_requested = 0; + + jitter->buffered = packet->span - desired_span; + + return JITTER_BUFFER_INSERTION; + } + + /* Searching for the packet that fits best */ + + /* Search the buffer for a packet with the right timestamp and spanning the whole current chunk */ + for (i=0;ipackets[i].data && jitter->packets[i].timestamp==jitter->pointer_timestamp && GE32(jitter->packets[i].timestamp+jitter->packets[i].span,jitter->pointer_timestamp+desired_span)) + break; + } + + /* If no match, try for an "older" packet that still spans (fully) the current chunk */ + if (i==SPEEX_JITTER_MAX_BUFFER_SIZE) + { + for (i=0;ipackets[i].data && LE32(jitter->packets[i].timestamp, jitter->pointer_timestamp) && GE32(jitter->packets[i].timestamp+jitter->packets[i].span,jitter->pointer_timestamp+desired_span)) + break; + } + } + + /* If still no match, try for an "older" packet that spans part of the current chunk */ + if (i==SPEEX_JITTER_MAX_BUFFER_SIZE) + { + for (i=0;ipackets[i].data && LE32(jitter->packets[i].timestamp, jitter->pointer_timestamp) && GT32(jitter->packets[i].timestamp+jitter->packets[i].span,jitter->pointer_timestamp)) + break; + } + } + + /* If still no match, try for earliest packet possible */ + if (i==SPEEX_JITTER_MAX_BUFFER_SIZE) + { + int found = 0; + spx_uint32_t best_time=0; + int best_span=0; + int besti=0; + for (i=0;ipackets[i].data && LT32(jitter->packets[i].timestamp,jitter->pointer_timestamp+desired_span) && GE32(jitter->packets[i].timestamp,jitter->pointer_timestamp)) + { + if (!found || LT32(jitter->packets[i].timestamp,best_time) || (jitter->packets[i].timestamp==best_time && GT32(jitter->packets[i].span,best_span))) + { + best_time = jitter->packets[i].timestamp; + best_span = jitter->packets[i].span; + besti = i; + found = 1; + } + } + } + if (found) + { + i=besti; + incomplete = 1; + /*fprintf (stderr, "incomplete: %d %d %d %d\n", jitter->packets[i].timestamp, jitter->pointer_timestamp, chunk_size, jitter->packets[i].span);*/ + } + } + + /* If we find something */ + if (i!=SPEEX_JITTER_MAX_BUFFER_SIZE) + { + spx_int32_t offset; + + /* We (obviously) haven't lost this packet */ + jitter->lost_count = 0; + + /* In this case, 0 isn't as a valid timestamp */ + if (jitter->arrival[i] != 0) + { + update_timings(jitter, ((spx_int32_t)jitter->packets[i].timestamp) - ((spx_int32_t)jitter->arrival[i]) - jitter->buffer_margin); + } + + + if (jitter->packets[i].len > packet->len) + { + speex_warning_int("jitter_buffer_get(): packet too large to fit. Size is", jitter->packets[i].len); + } else { + packet->len = jitter->packets[i].len; + } + /* Copy packet */ + if (jitter->destroy) + { + packet->data = jitter->packets[i].data; + } else { + for (j=0;jlen;j++) + packet->data[j] = jitter->packets[i].data[j]; + /* Remove packet */ + speex_free(jitter->packets[i].data); + } + jitter->packets[i].data = NULL; + /* Set timestamp and span (if requested) */ + offset = (spx_int32_t)jitter->packets[i].timestamp-(spx_int32_t)jitter->pointer_timestamp; + if (start_offset != NULL) + *start_offset = offset; + else if (offset != 0) + speex_warning_int("jitter_buffer_get() discarding non-zero start_offset", offset); + + packet->timestamp = jitter->packets[i].timestamp; + jitter->last_returned_timestamp = packet->timestamp; + + packet->span = jitter->packets[i].span; + packet->sequence = jitter->packets[i].sequence; + packet->user_data = jitter->packets[i].user_data; + /* Point to the end of the current packet */ + jitter->pointer_timestamp = jitter->packets[i].timestamp+jitter->packets[i].span; + + jitter->buffered = packet->span - desired_span; + + if (start_offset != NULL) + jitter->buffered += *start_offset; + + return JITTER_BUFFER_OK; + } + + + /* If we haven't found anything worth returning */ + + /*fprintf (stderr, "not found\n");*/ + jitter->lost_count++; + /*fprintf (stderr, "m");*/ + /*fprintf (stderr, "lost_count = %d\n", jitter->lost_count);*/ + + opt = compute_opt_delay(jitter); + + /* Should we force an increase in the buffer or just do normal interpolation? */ + if (opt < 0) + { + /* Need to increase buffering */ + + /* Shift histogram to compensate */ + shift_timings(jitter, -opt); + + packet->timestamp = jitter->pointer_timestamp; + packet->span = -opt; + /* Don't move the pointer_timestamp forward */ + packet->len = 0; + + jitter->buffered = packet->span - desired_span; + return JITTER_BUFFER_INSERTION; + /*jitter->pointer_timestamp -= jitter->delay_step;*/ + /*fprintf (stderr, "Forced to interpolate\n");*/ + } else { + /* Normal packet loss */ + packet->timestamp = jitter->pointer_timestamp; + + desired_span = ROUND_DOWN(desired_span, jitter->concealment_size); + packet->span = desired_span; + jitter->pointer_timestamp += desired_span; + packet->len = 0; + + jitter->buffered = packet->span - desired_span; + return JITTER_BUFFER_MISSING; + /*fprintf (stderr, "Normal loss\n");*/ + } + + +} + +int jitter_buffer_get_another(JitterBuffer *jitter, JitterBufferPacket *packet) +{ + int i, j; + for (i=0;ipackets[i].data && jitter->packets[i].timestamp==jitter->last_returned_timestamp) + break; + } + if (i!=SPEEX_JITTER_MAX_BUFFER_SIZE) + { + /* Copy packet */ + packet->len = jitter->packets[i].len; + if (jitter->destroy) + { + packet->data = jitter->packets[i].data; + } else { + for (j=0;jlen;j++) + packet->data[j] = jitter->packets[i].data[j]; + /* Remove packet */ + speex_free(jitter->packets[i].data); + } + jitter->packets[i].data = NULL; + packet->timestamp = jitter->packets[i].timestamp; + packet->span = jitter->packets[i].span; + packet->sequence = jitter->packets[i].sequence; + packet->user_data = jitter->packets[i].user_data; + return JITTER_BUFFER_OK; + } else { + packet->data = NULL; + packet->len = 0; + packet->span = 0; + return JITTER_BUFFER_MISSING; + } +} + +/* Let the jitter buffer know it's the right time to adjust the buffering delay to the network conditions */ +static int _jitter_buffer_update_delay(JitterBuffer *jitter, JitterBufferPacket *packet, spx_int32_t *start_offset) +{ + spx_int16_t opt = compute_opt_delay(jitter); + /*fprintf(stderr, "opt adjustment is %d ", opt);*/ + + if (opt < 0) + { + shift_timings(jitter, -opt); + + jitter->pointer_timestamp += opt; + jitter->interp_requested = -opt; + /*fprintf (stderr, "Decision to interpolate %d samples\n", -opt);*/ + } else if (opt > 0) + { + shift_timings(jitter, -opt); + jitter->pointer_timestamp += opt; + /*fprintf (stderr, "Decision to drop %d samples\n", opt);*/ + } + + return opt; +} + +/* Let the jitter buffer know it's the right time to adjust the buffering delay to the network conditions */ +int jitter_buffer_update_delay(JitterBuffer *jitter, JitterBufferPacket *packet, spx_int32_t *start_offset) +{ + /* If the programmer calls jitter_buffer_update_delay() directly, + automatically disable auto-adjustment */ + jitter->auto_adjust = 0; + + return _jitter_buffer_update_delay(jitter, packet, start_offset); +} + +/** Get pointer timestamp of jitter buffer */ +int jitter_buffer_get_pointer_timestamp(JitterBuffer *jitter) +{ + return jitter->pointer_timestamp; +} + +void jitter_buffer_tick(JitterBuffer *jitter) +{ + /* Automatically-adjust the buffering delay if requested */ + if (jitter->auto_adjust) + _jitter_buffer_update_delay(jitter, NULL, NULL); + + if (jitter->buffered >= 0) + { + jitter->next_stop = jitter->pointer_timestamp - jitter->buffered; + } else { + jitter->next_stop = jitter->pointer_timestamp; + speex_warning_int("jitter buffer sees negative buffering, your code might be broken. Value is ", jitter->buffered); + } + jitter->buffered = 0; +} + +void jitter_buffer_remaining_span(JitterBuffer *jitter, spx_uint32_t rem) +{ + /* Automatically-adjust the buffering delay if requested */ + if (jitter->auto_adjust) + _jitter_buffer_update_delay(jitter, NULL, NULL); + + if (jitter->buffered < 0) + speex_warning_int("jitter buffer sees negative buffering, your code might be broken. Value is ", jitter->buffered); + jitter->next_stop = jitter->pointer_timestamp - rem; +} + + +/* Used like the ioctl function to control the jitter buffer parameters */ +int jitter_buffer_ctl(JitterBuffer *jitter, int request, void *ptr) +{ + int count, i; + switch(request) + { + case JITTER_BUFFER_SET_MARGIN: + jitter->buffer_margin = *(spx_int32_t*)ptr; + break; + case JITTER_BUFFER_GET_MARGIN: + *(spx_int32_t*)ptr = jitter->buffer_margin; + break; + case JITTER_BUFFER_GET_AVALIABLE_COUNT: + count = 0; + for (i=0;ipackets[i].data && LE32(jitter->pointer_timestamp, jitter->packets[i].timestamp)) + { + count++; + } + } + *(spx_int32_t*)ptr = count; + break; + case JITTER_BUFFER_SET_DESTROY_CALLBACK: + jitter->destroy = (void (*) (void *))ptr; + break; + case JITTER_BUFFER_GET_DESTROY_CALLBACK: + *(void (**) (void *))ptr = jitter->destroy; + break; + case JITTER_BUFFER_SET_DELAY_STEP: + jitter->delay_step = *(spx_int32_t*)ptr; + break; + case JITTER_BUFFER_GET_DELAY_STEP: + *(spx_int32_t*)ptr = jitter->delay_step; + break; + case JITTER_BUFFER_SET_CONCEALMENT_SIZE: + jitter->concealment_size = *(spx_int32_t*)ptr; + break; + case JITTER_BUFFER_GET_CONCEALMENT_SIZE: + *(spx_int32_t*)ptr = jitter->concealment_size; + break; + case JITTER_BUFFER_SET_MAX_LATE_RATE: + jitter->max_late_rate = *(spx_int32_t*)ptr; + jitter->window_size = 100*TOP_DELAY/jitter->max_late_rate; + jitter->subwindow_size = jitter->window_size/MAX_BUFFERS; + break; + case JITTER_BUFFER_GET_MAX_LATE_RATE: + *(spx_int32_t*)ptr = jitter->max_late_rate; + break; + case JITTER_BUFFER_SET_LATE_COST: + jitter->latency_tradeoff = *(spx_int32_t*)ptr; + break; + case JITTER_BUFFER_GET_LATE_COST: + *(spx_int32_t*)ptr = jitter->latency_tradeoff; + break; + default: + speex_warning_int("Unknown jitter_buffer_ctl request: ", request); + return -1; + } + return 0; +} + diff --git a/lib/rbcodec/codecs/libspeex/kiss_fft.c b/lib/rbcodec/codecs/libspeex/kiss_fft.c new file mode 100644 index 0000000000..5b699a362f --- /dev/null +++ b/lib/rbcodec/codecs/libspeex/kiss_fft.c @@ -0,0 +1,523 @@ +/* +Copyright (c) 2003-2004, Mark Borgerding +Copyright (c) 2005-2007, Jean-Marc Valin + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + * Neither the author nor the names of any contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#ifdef HAVE_CONFIG_H +#include "config-speex.h" +#endif + +#include "_kiss_fft_guts.h" +#include "arch.h" +#include "os_support.h" + +/* The guts header contains all the multiplication and addition macros that are defined for + fixed or floating point complex numbers. It also delares the kf_ internal functions. + */ + +static void kf_bfly2( + kiss_fft_cpx * Fout, + const size_t fstride, + const kiss_fft_cfg st, + int m, + int N, + int mm + ) +{ + kiss_fft_cpx * Fout2; + kiss_fft_cpx * tw1; + kiss_fft_cpx t; + if (!st->inverse) { + int i,j; + kiss_fft_cpx * Fout_beg = Fout; + for (i=0;itwiddles; + for(j=0;jr , tw1->r),MULT16_16(Fout2->i , tw1->i)), 1); + ti = SHR32(ADD32(MULT16_16(Fout2->i , tw1->r),MULT16_16(Fout2->r , tw1->i)), 1); + tw1 += fstride; + Fout2->r = PSHR32(SUB32(SHL32(EXTEND32(Fout->r), 14), tr), 15); + Fout2->i = PSHR32(SUB32(SHL32(EXTEND32(Fout->i), 14), ti), 15); + Fout->r = PSHR32(ADD32(SHL32(EXTEND32(Fout->r), 14), tr), 15); + Fout->i = PSHR32(ADD32(SHL32(EXTEND32(Fout->i), 14), ti), 15); + ++Fout2; + ++Fout; + } + } + } else { + int i,j; + kiss_fft_cpx * Fout_beg = Fout; + for (i=0;itwiddles; + for(j=0;jinverse) + { + kiss_fft_cpx * Fout_beg = Fout; + for (i=0;itwiddles; + for (j=0;jtwiddles; + for (j=0;jr = PSHR16(Fout->r, 2); + Fout->i = PSHR16(Fout->i, 2); + C_SUB( scratch[5] , *Fout, scratch[1] ); + C_ADDTO(*Fout, scratch[1]); + C_ADD( scratch[3] , scratch[0] , scratch[2] ); + C_SUB( scratch[4] , scratch[0] , scratch[2] ); + Fout[m2].r = PSHR16(Fout[m2].r, 2); + Fout[m2].i = PSHR16(Fout[m2].i, 2); + C_SUB( Fout[m2], *Fout, scratch[3] ); + tw1 += fstride; + tw2 += fstride*2; + tw3 += fstride*3; + C_ADDTO( *Fout , scratch[3] ); + + Fout[m].r = scratch[5].r + scratch[4].i; + Fout[m].i = scratch[5].i - scratch[4].r; + Fout[m3].r = scratch[5].r - scratch[4].i; + Fout[m3].i = scratch[5].i + scratch[4].r; + ++Fout; + } + } + } +} + +static void kf_bfly3( + kiss_fft_cpx * Fout, + const size_t fstride, + const kiss_fft_cfg st, + size_t m + ) +{ + size_t k=m; + const size_t m2 = 2*m; + kiss_fft_cpx *tw1,*tw2; + kiss_fft_cpx scratch[5]; + kiss_fft_cpx epi3; + epi3 = st->twiddles[fstride*m]; + + tw1=tw2=st->twiddles; + + do{ + if (!st->inverse) { + C_FIXDIV(*Fout,3); C_FIXDIV(Fout[m],3); C_FIXDIV(Fout[m2],3); + } + + C_MUL(scratch[1],Fout[m] , *tw1); + C_MUL(scratch[2],Fout[m2] , *tw2); + + C_ADD(scratch[3],scratch[1],scratch[2]); + C_SUB(scratch[0],scratch[1],scratch[2]); + tw1 += fstride; + tw2 += fstride*2; + + Fout[m].r = Fout->r - HALF_OF(scratch[3].r); + Fout[m].i = Fout->i - HALF_OF(scratch[3].i); + + C_MULBYSCALAR( scratch[0] , epi3.i ); + + C_ADDTO(*Fout,scratch[3]); + + Fout[m2].r = Fout[m].r + scratch[0].i; + Fout[m2].i = Fout[m].i - scratch[0].r; + + Fout[m].r -= scratch[0].i; + Fout[m].i += scratch[0].r; + + ++Fout; + }while(--k); +} + +static void kf_bfly5( + kiss_fft_cpx * Fout, + const size_t fstride, + const kiss_fft_cfg st, + int m + ) +{ + kiss_fft_cpx *Fout0,*Fout1,*Fout2,*Fout3,*Fout4; + int u; + kiss_fft_cpx scratch[13]; + kiss_fft_cpx * twiddles = st->twiddles; + kiss_fft_cpx *tw; + kiss_fft_cpx ya,yb; + ya = twiddles[fstride*m]; + yb = twiddles[fstride*2*m]; + + Fout0=Fout; + Fout1=Fout0+m; + Fout2=Fout0+2*m; + Fout3=Fout0+3*m; + Fout4=Fout0+4*m; + + tw=st->twiddles; + for ( u=0; uinverse) { + C_FIXDIV( *Fout0,5); C_FIXDIV( *Fout1,5); C_FIXDIV( *Fout2,5); C_FIXDIV( *Fout3,5); C_FIXDIV( *Fout4,5); + } + scratch[0] = *Fout0; + + C_MUL(scratch[1] ,*Fout1, tw[u*fstride]); + C_MUL(scratch[2] ,*Fout2, tw[2*u*fstride]); + C_MUL(scratch[3] ,*Fout3, tw[3*u*fstride]); + C_MUL(scratch[4] ,*Fout4, tw[4*u*fstride]); + + C_ADD( scratch[7],scratch[1],scratch[4]); + C_SUB( scratch[10],scratch[1],scratch[4]); + C_ADD( scratch[8],scratch[2],scratch[3]); + C_SUB( scratch[9],scratch[2],scratch[3]); + + Fout0->r += scratch[7].r + scratch[8].r; + Fout0->i += scratch[7].i + scratch[8].i; + + scratch[5].r = scratch[0].r + S_MUL(scratch[7].r,ya.r) + S_MUL(scratch[8].r,yb.r); + scratch[5].i = scratch[0].i + S_MUL(scratch[7].i,ya.r) + S_MUL(scratch[8].i,yb.r); + + scratch[6].r = S_MUL(scratch[10].i,ya.i) + S_MUL(scratch[9].i,yb.i); + scratch[6].i = -S_MUL(scratch[10].r,ya.i) - S_MUL(scratch[9].r,yb.i); + + C_SUB(*Fout1,scratch[5],scratch[6]); + C_ADD(*Fout4,scratch[5],scratch[6]); + + scratch[11].r = scratch[0].r + S_MUL(scratch[7].r,yb.r) + S_MUL(scratch[8].r,ya.r); + scratch[11].i = scratch[0].i + S_MUL(scratch[7].i,yb.r) + S_MUL(scratch[8].i,ya.r); + scratch[12].r = - S_MUL(scratch[10].i,yb.i) + S_MUL(scratch[9].i,ya.i); + scratch[12].i = S_MUL(scratch[10].r,yb.i) - S_MUL(scratch[9].r,ya.i); + + C_ADD(*Fout2,scratch[11],scratch[12]); + C_SUB(*Fout3,scratch[11],scratch[12]); + + ++Fout0;++Fout1;++Fout2;++Fout3;++Fout4; + } +} + +/* perform the butterfly for one stage of a mixed radix FFT */ +static void kf_bfly_generic( + kiss_fft_cpx * Fout, + const size_t fstride, + const kiss_fft_cfg st, + int m, + int p + ) +{ + int u,k,q1,q; + kiss_fft_cpx * twiddles = st->twiddles; + kiss_fft_cpx t; + kiss_fft_cpx scratchbuf[17]; + int Norig = st->nfft; + + /*CHECKBUF(scratchbuf,nscratchbuf,p);*/ + if (p>17) + speex_fatal("KissFFT: max radix supported is 17"); + + for ( u=0; uinverse) { + C_FIXDIV(scratchbuf[q1],p); + } + k += m; + } + + k=u; + for ( q1=0 ; q1

=Norig) twidx-=Norig; + C_MUL(t,scratchbuf[q] , twiddles[twidx] ); + C_ADDTO( Fout[ k ] ,t); + } + k += m; + } + } +} + +static +void kf_shuffle( + kiss_fft_cpx * Fout, + const kiss_fft_cpx * f, + const size_t fstride, + int in_stride, + int * factors, + const kiss_fft_cfg st + ) +{ + const int p=*factors++; /* the radix */ + const int m=*factors++; /* stage's fft length/p */ + + /*printf ("fft %d %d %d %d %d %d\n", p*m, m, p, s2, fstride*in_stride, N);*/ + if (m==1) + { + int j; + for (j=0;j32000 || (spx_int32_t)p*(spx_int32_t)p > n) + p = n; /* no more factors, skip to end */ + } + n /= p; + *facbuf++ = p; + *facbuf++ = n; + } while (n > 1); +} +/* + * + * User-callable function to allocate all necessary storage space for the fft. + * + * The return value is a contiguous block of memory, allocated with malloc. As such, + * It can be freed with free(), rather than a kiss_fft-specific function. + * */ +kiss_fft_cfg kiss_fft_alloc(int nfft,int inverse_fft,void * mem,size_t * lenmem ) +{ + kiss_fft_cfg st=NULL; + size_t memneeded = sizeof(struct kiss_fft_state) + + sizeof(kiss_fft_cpx)*(nfft-1); /* twiddle factors*/ + + if ( lenmem==NULL ) { + st = ( kiss_fft_cfg)KISS_FFT_MALLOC( memneeded ); + }else{ + if (mem != NULL && *lenmem >= memneeded) + st = (kiss_fft_cfg)mem; + *lenmem = memneeded; + } + if (st) { + int i; + st->nfft=nfft; + st->inverse = inverse_fft; +#ifdef FIXED_POINT + for (i=0;iinverse) + phase = -phase; + kf_cexp2(st->twiddles+i, DIV32(SHL32(phase,17),nfft)); + } +#else + for (i=0;iinverse) + phase *= -1; + kf_cexp(st->twiddles+i, phase ); + } +#endif + kf_factor(nfft,st->factors); + } + return st; +} + + + + +void kiss_fft_stride(kiss_fft_cfg st,const kiss_fft_cpx *fin,kiss_fft_cpx *fout,int in_stride) +{ + if (fin == fout) + { + speex_fatal("In-place FFT not supported"); + /*CHECKBUF(tmpbuf,ntmpbuf,st->nfft); + kf_work(tmpbuf,fin,1,in_stride, st->factors,st); + SPEEX_MOVE(fout,tmpbuf,st->nfft);*/ + } else { + kf_shuffle( fout, fin, 1,in_stride, st->factors,st); + kf_work( fout, fin, 1,in_stride, st->factors,st, 1, in_stride, 1); + } +} + +void kiss_fft(kiss_fft_cfg cfg,const kiss_fft_cpx *fin,kiss_fft_cpx *fout) +{ + kiss_fft_stride(cfg,fin,fout,1); +} + diff --git a/lib/rbcodec/codecs/libspeex/kiss_fft.h b/lib/rbcodec/codecs/libspeex/kiss_fft.h new file mode 100644 index 0000000000..43319b1ba8 --- /dev/null +++ b/lib/rbcodec/codecs/libspeex/kiss_fft.h @@ -0,0 +1,108 @@ +#ifndef KISS_FFT_H +#define KISS_FFT_H + +#include +#include +#include "arch.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* + ATTENTION! + If you would like a : + -- a utility that will handle the caching of fft objects + -- real-only (no imaginary time component ) FFT + -- a multi-dimensional FFT + -- a command-line utility to perform ffts + -- a command-line utility to perform fast-convolution filtering + + Then see kfc.h kiss_fftr.h kiss_fftnd.h fftutil.c kiss_fastfir.c + in the tools/ directory. +*/ + +#ifdef USE_SIMD +# include +# define kiss_fft_scalar __m128 +#define KISS_FFT_MALLOC(nbytes) memalign(16,nbytes) +#else +#define KISS_FFT_MALLOC speex_alloc +#endif + + +#ifdef FIXED_POINT +#include "arch.h" +# define kiss_fft_scalar spx_int16_t +#else +# ifndef kiss_fft_scalar +/* default is float */ +# define kiss_fft_scalar float +# endif +#endif + +typedef struct { + kiss_fft_scalar r; + kiss_fft_scalar i; +}kiss_fft_cpx; + +typedef struct kiss_fft_state* kiss_fft_cfg; + +/* + * kiss_fft_alloc + * + * Initialize a FFT (or IFFT) algorithm's cfg/state buffer. + * + * typical usage: kiss_fft_cfg mycfg=kiss_fft_alloc(1024,0,NULL,NULL); + * + * The return value from fft_alloc is a cfg buffer used internally + * by the fft routine or NULL. + * + * If lenmem is NULL, then kiss_fft_alloc will allocate a cfg buffer using malloc. + * The returned value should be free()d when done to avoid memory leaks. + * + * The state can be placed in a user supplied buffer 'mem': + * If lenmem is not NULL and mem is not NULL and *lenmem is large enough, + * then the function places the cfg in mem and the size used in *lenmem + * and returns mem. + * + * If lenmem is not NULL and ( mem is NULL or *lenmem is not large enough), + * then the function returns NULL and places the minimum cfg + * buffer size in *lenmem. + * */ + +kiss_fft_cfg kiss_fft_alloc(int nfft,int inverse_fft,void * mem,size_t * lenmem); + +/* + * kiss_fft(cfg,in_out_buf) + * + * Perform an FFT on a complex input buffer. + * for a forward FFT, + * fin should be f[0] , f[1] , ... ,f[nfft-1] + * fout will be F[0] , F[1] , ... ,F[nfft-1] + * Note that each element is complex and can be accessed like + f[k].r and f[k].i + * */ +void kiss_fft(kiss_fft_cfg cfg,const kiss_fft_cpx *fin,kiss_fft_cpx *fout); + +/* + A more generic version of the above function. It reads its input from every Nth sample. + * */ +void kiss_fft_stride(kiss_fft_cfg cfg,const kiss_fft_cpx *fin,kiss_fft_cpx *fout,int fin_stride); + +/* If kiss_fft_alloc allocated a buffer, it is one contiguous + buffer and can be simply free()d when no longer needed*/ +#define kiss_fft_free speex_free + +/* + Cleans up some memory that gets managed internally. Not necessary to call, but it might clean up + your compiler output to call this before you exit. +*/ +void kiss_fft_cleanup(void); + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/lib/rbcodec/codecs/libspeex/kiss_fftr.c b/lib/rbcodec/codecs/libspeex/kiss_fftr.c new file mode 100644 index 0000000000..1c694b195d --- /dev/null +++ b/lib/rbcodec/codecs/libspeex/kiss_fftr.c @@ -0,0 +1,297 @@ +/* +Copyright (c) 2003-2004, Mark Borgerding + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + * Neither the author nor the names of any contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifdef HAVE_CONFIG_H +#include "config-speex.h" +#endif + +#include "os_support.h" +#include "kiss_fftr.h" +#include "_kiss_fft_guts.h" + +struct kiss_fftr_state{ + kiss_fft_cfg substate; + kiss_fft_cpx * tmpbuf; + kiss_fft_cpx * super_twiddles; +#ifdef USE_SIMD + long pad; +#endif +}; + +kiss_fftr_cfg kiss_fftr_alloc(int nfft,int inverse_fft,void * mem,size_t * lenmem) +{ + int i; + kiss_fftr_cfg st = NULL; + size_t subsize, memneeded; + + if (nfft & 1) { + speex_warning("Real FFT optimization must be even.\n"); + return NULL; + } + nfft >>= 1; + + kiss_fft_alloc (nfft, inverse_fft, NULL, &subsize); + memneeded = sizeof(struct kiss_fftr_state) + subsize + sizeof(kiss_fft_cpx) * ( nfft * 2); + + if (lenmem == NULL) { + st = (kiss_fftr_cfg) KISS_FFT_MALLOC (memneeded); + } else { + if (*lenmem >= memneeded) + st = (kiss_fftr_cfg) mem; + *lenmem = memneeded; + } + if (!st) + return NULL; + + st->substate = (kiss_fft_cfg) (st + 1); /*just beyond kiss_fftr_state struct */ + st->tmpbuf = (kiss_fft_cpx *) (((char *) st->substate) + subsize); + st->super_twiddles = st->tmpbuf + nfft; + kiss_fft_alloc(nfft, inverse_fft, st->substate, &subsize); + +#ifdef FIXED_POINT + for (i=0;i>1); + if (!inverse_fft) + phase = -phase; + kf_cexp2(st->super_twiddles+i, DIV32(SHL32(phase,16),nfft)); + } +#else + for (i=0;isuper_twiddles+i, phase ); + } +#endif + return st; +} + +void kiss_fftr(kiss_fftr_cfg st,const kiss_fft_scalar *timedata,kiss_fft_cpx *freqdata) +{ + /* input buffer timedata is stored row-wise */ + int k,ncfft; + kiss_fft_cpx fpnk,fpk,f1k,f2k,tw,tdc; + + if ( st->substate->inverse) { + speex_fatal("kiss fft usage error: improper alloc\n"); + } + + ncfft = st->substate->nfft; + + /*perform the parallel fft of two real signals packed in real,imag*/ + kiss_fft( st->substate , (const kiss_fft_cpx*)timedata, st->tmpbuf ); + /* The real part of the DC element of the frequency spectrum in st->tmpbuf + * contains the sum of the even-numbered elements of the input time sequence + * The imag part is the sum of the odd-numbered elements + * + * The sum of tdc.r and tdc.i is the sum of the input time sequence. + * yielding DC of input time sequence + * The difference of tdc.r - tdc.i is the sum of the input (dot product) [1,-1,1,-1... + * yielding Nyquist bin of input time sequence + */ + + tdc.r = st->tmpbuf[0].r; + tdc.i = st->tmpbuf[0].i; + C_FIXDIV(tdc,2); + CHECK_OVERFLOW_OP(tdc.r ,+, tdc.i); + CHECK_OVERFLOW_OP(tdc.r ,-, tdc.i); + freqdata[0].r = tdc.r + tdc.i; + freqdata[ncfft].r = tdc.r - tdc.i; +#ifdef USE_SIMD + freqdata[ncfft].i = freqdata[0].i = _mm_set1_ps(0); +#else + freqdata[ncfft].i = freqdata[0].i = 0; +#endif + + for ( k=1;k <= ncfft/2 ; ++k ) { + fpk = st->tmpbuf[k]; + fpnk.r = st->tmpbuf[ncfft-k].r; + fpnk.i = - st->tmpbuf[ncfft-k].i; + C_FIXDIV(fpk,2); + C_FIXDIV(fpnk,2); + + C_ADD( f1k, fpk , fpnk ); + C_SUB( f2k, fpk , fpnk ); + C_MUL( tw , f2k , st->super_twiddles[k]); + + freqdata[k].r = HALF_OF(f1k.r + tw.r); + freqdata[k].i = HALF_OF(f1k.i + tw.i); + freqdata[ncfft-k].r = HALF_OF(f1k.r - tw.r); + freqdata[ncfft-k].i = HALF_OF(tw.i - f1k.i); + } +} + +void kiss_fftri(kiss_fftr_cfg st,const kiss_fft_cpx *freqdata, kiss_fft_scalar *timedata) +{ + /* input buffer timedata is stored row-wise */ + int k, ncfft; + + if (st->substate->inverse == 0) { + speex_fatal("kiss fft usage error: improper alloc\n"); + } + + ncfft = st->substate->nfft; + + st->tmpbuf[0].r = freqdata[0].r + freqdata[ncfft].r; + st->tmpbuf[0].i = freqdata[0].r - freqdata[ncfft].r; + /*C_FIXDIV(st->tmpbuf[0],2);*/ + + for (k = 1; k <= ncfft / 2; ++k) { + kiss_fft_cpx fk, fnkc, fek, fok, tmp; + fk = freqdata[k]; + fnkc.r = freqdata[ncfft - k].r; + fnkc.i = -freqdata[ncfft - k].i; + /*C_FIXDIV( fk , 2 ); + C_FIXDIV( fnkc , 2 );*/ + + C_ADD (fek, fk, fnkc); + C_SUB (tmp, fk, fnkc); + C_MUL (fok, tmp, st->super_twiddles[k]); + C_ADD (st->tmpbuf[k], fek, fok); + C_SUB (st->tmpbuf[ncfft - k], fek, fok); +#ifdef USE_SIMD + st->tmpbuf[ncfft - k].i *= _mm_set1_ps(-1.0); +#else + st->tmpbuf[ncfft - k].i *= -1; +#endif + } + kiss_fft (st->substate, st->tmpbuf, (kiss_fft_cpx *) timedata); +} + +void kiss_fftr2(kiss_fftr_cfg st,const kiss_fft_scalar *timedata,kiss_fft_scalar *freqdata) +{ + /* input buffer timedata is stored row-wise */ + int k,ncfft; + kiss_fft_cpx f2k,tdc; + spx_word32_t f1kr, f1ki, twr, twi; + + if ( st->substate->inverse) { + speex_fatal("kiss fft usage error: improper alloc\n"); + } + + ncfft = st->substate->nfft; + + /*perform the parallel fft of two real signals packed in real,imag*/ + kiss_fft( st->substate , (const kiss_fft_cpx*)timedata, st->tmpbuf ); + /* The real part of the DC element of the frequency spectrum in st->tmpbuf + * contains the sum of the even-numbered elements of the input time sequence + * The imag part is the sum of the odd-numbered elements + * + * The sum of tdc.r and tdc.i is the sum of the input time sequence. + * yielding DC of input time sequence + * The difference of tdc.r - tdc.i is the sum of the input (dot product) [1,-1,1,-1... + * yielding Nyquist bin of input time sequence + */ + + tdc.r = st->tmpbuf[0].r; + tdc.i = st->tmpbuf[0].i; + C_FIXDIV(tdc,2); + CHECK_OVERFLOW_OP(tdc.r ,+, tdc.i); + CHECK_OVERFLOW_OP(tdc.r ,-, tdc.i); + freqdata[0] = tdc.r + tdc.i; + freqdata[2*ncfft-1] = tdc.r - tdc.i; + + for ( k=1;k <= ncfft/2 ; ++k ) + { + /*fpk = st->tmpbuf[k]; + fpnk.r = st->tmpbuf[ncfft-k].r; + fpnk.i = - st->tmpbuf[ncfft-k].i; + C_FIXDIV(fpk,2); + C_FIXDIV(fpnk,2); + + C_ADD( f1k, fpk , fpnk ); + C_SUB( f2k, fpk , fpnk ); + + C_MUL( tw , f2k , st->super_twiddles[k]); + + freqdata[2*k-1] = HALF_OF(f1k.r + tw.r); + freqdata[2*k] = HALF_OF(f1k.i + tw.i); + freqdata[2*(ncfft-k)-1] = HALF_OF(f1k.r - tw.r); + freqdata[2*(ncfft-k)] = HALF_OF(tw.i - f1k.i); + */ + + /*f1k.r = PSHR32(ADD32(EXTEND32(st->tmpbuf[k].r), EXTEND32(st->tmpbuf[ncfft-k].r)),1); + f1k.i = PSHR32(SUB32(EXTEND32(st->tmpbuf[k].i), EXTEND32(st->tmpbuf[ncfft-k].i)),1); + f2k.r = PSHR32(SUB32(EXTEND32(st->tmpbuf[k].r), EXTEND32(st->tmpbuf[ncfft-k].r)),1); + f2k.i = SHR32(ADD32(EXTEND32(st->tmpbuf[k].i), EXTEND32(st->tmpbuf[ncfft-k].i)),1); + + C_MUL( tw , f2k , st->super_twiddles[k]); + + freqdata[2*k-1] = HALF_OF(f1k.r + tw.r); + freqdata[2*k] = HALF_OF(f1k.i + tw.i); + freqdata[2*(ncfft-k)-1] = HALF_OF(f1k.r - tw.r); + freqdata[2*(ncfft-k)] = HALF_OF(tw.i - f1k.i); + */ + f2k.r = SHR32(SUB32(EXTEND32(st->tmpbuf[k].r), EXTEND32(st->tmpbuf[ncfft-k].r)),1); + f2k.i = PSHR32(ADD32(EXTEND32(st->tmpbuf[k].i), EXTEND32(st->tmpbuf[ncfft-k].i)),1); + + f1kr = SHL32(ADD32(EXTEND32(st->tmpbuf[k].r), EXTEND32(st->tmpbuf[ncfft-k].r)),13); + f1ki = SHL32(SUB32(EXTEND32(st->tmpbuf[k].i), EXTEND32(st->tmpbuf[ncfft-k].i)),13); + + twr = SHR32(SUB32(MULT16_16(f2k.r,st->super_twiddles[k].r),MULT16_16(f2k.i,st->super_twiddles[k].i)), 1); + twi = SHR32(ADD32(MULT16_16(f2k.i,st->super_twiddles[k].r),MULT16_16(f2k.r,st->super_twiddles[k].i)), 1); + +#ifdef FIXED_POINT + freqdata[2*k-1] = PSHR32(f1kr + twr, 15); + freqdata[2*k] = PSHR32(f1ki + twi, 15); + freqdata[2*(ncfft-k)-1] = PSHR32(f1kr - twr, 15); + freqdata[2*(ncfft-k)] = PSHR32(twi - f1ki, 15); +#else + freqdata[2*k-1] = .5f*(f1kr + twr); + freqdata[2*k] = .5f*(f1ki + twi); + freqdata[2*(ncfft-k)-1] = .5f*(f1kr - twr); + freqdata[2*(ncfft-k)] = .5f*(twi - f1ki); + +#endif + } +} + +void kiss_fftri2(kiss_fftr_cfg st,const kiss_fft_scalar *freqdata,kiss_fft_scalar *timedata) +{ + /* input buffer timedata is stored row-wise */ + int k, ncfft; + + if (st->substate->inverse == 0) { + speex_fatal ("kiss fft usage error: improper alloc\n"); + } + + ncfft = st->substate->nfft; + + st->tmpbuf[0].r = freqdata[0] + freqdata[2*ncfft-1]; + st->tmpbuf[0].i = freqdata[0] - freqdata[2*ncfft-1]; + /*C_FIXDIV(st->tmpbuf[0],2);*/ + + for (k = 1; k <= ncfft / 2; ++k) { + kiss_fft_cpx fk, fnkc, fek, fok, tmp; + fk.r = freqdata[2*k-1]; + fk.i = freqdata[2*k]; + fnkc.r = freqdata[2*(ncfft - k)-1]; + fnkc.i = -freqdata[2*(ncfft - k)]; + /*C_FIXDIV( fk , 2 ); + C_FIXDIV( fnkc , 2 );*/ + + C_ADD (fek, fk, fnkc); + C_SUB (tmp, fk, fnkc); + C_MUL (fok, tmp, st->super_twiddles[k]); + C_ADD (st->tmpbuf[k], fek, fok); + C_SUB (st->tmpbuf[ncfft - k], fek, fok); +#ifdef USE_SIMD + st->tmpbuf[ncfft - k].i *= _mm_set1_ps(-1.0); +#else + st->tmpbuf[ncfft - k].i *= -1; +#endif + } + kiss_fft (st->substate, st->tmpbuf, (kiss_fft_cpx *) timedata); +} diff --git a/lib/rbcodec/codecs/libspeex/kiss_fftr.h b/lib/rbcodec/codecs/libspeex/kiss_fftr.h new file mode 100644 index 0000000000..7bfb423340 --- /dev/null +++ b/lib/rbcodec/codecs/libspeex/kiss_fftr.h @@ -0,0 +1,51 @@ +#ifndef KISS_FTR_H +#define KISS_FTR_H + +#include "kiss_fft.h" +#ifdef __cplusplus +extern "C" { +#endif + + +/* + + Real optimized version can save about 45% cpu time vs. complex fft of a real seq. + + + + */ + +typedef struct kiss_fftr_state *kiss_fftr_cfg; + + +kiss_fftr_cfg kiss_fftr_alloc(int nfft,int inverse_fft,void * mem, size_t * lenmem); +/* + nfft must be even + + If you don't care to allocate space, use mem = lenmem = NULL +*/ + + +void kiss_fftr(kiss_fftr_cfg cfg,const kiss_fft_scalar *timedata,kiss_fft_cpx *freqdata); +/* + input timedata has nfft scalar points + output freqdata has nfft/2+1 complex points +*/ + +void kiss_fftr2(kiss_fftr_cfg st,const kiss_fft_scalar *timedata,kiss_fft_scalar *freqdata); + +void kiss_fftri(kiss_fftr_cfg cfg,const kiss_fft_cpx *freqdata,kiss_fft_scalar *timedata); + +void kiss_fftri2(kiss_fftr_cfg st,const kiss_fft_scalar *freqdata, kiss_fft_scalar *timedata); + +/* + input freqdata has nfft/2+1 complex points + output timedata has nfft scalar points +*/ + +#define kiss_fftr_free speex_free + +#ifdef __cplusplus +} +#endif +#endif diff --git a/lib/rbcodec/codecs/libspeex/libspeex.make b/lib/rbcodec/codecs/libspeex/libspeex.make new file mode 100644 index 0000000000..6138dff4a9 --- /dev/null +++ b/lib/rbcodec/codecs/libspeex/libspeex.make @@ -0,0 +1,66 @@ +# __________ __ ___. +# Open \______ \ ____ ____ | | _\_ |__ _______ ___ +# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / +# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < +# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ +# \/ \/ \/ \/ \/ +# $Id$ +# + +# we need to build two different speex libraries +# (one for codec, one for core voice) +# so a little trickery is necessary + +# disable strict aliasing optimizations for now, it gives warnings due to +# some horrid typecasting +_SPEEXFLAGS = $(filter-out -fstrict-aliasing, $(CODECFLAGS)) \ + -fno-strict-aliasing -DHAVE_CONFIG_H -DSPEEX_DISABLE_ENCODER \ + -I$(RBCODECLIB_DIR)/codecs/libspeex + +# build voice codec with core -O switch +VOICESPEEXFLAGS = $(filter-out -ffunction-sections, $(filter-out -DCODEC,$(_SPEEXFLAGS))) -DROCKBOX_VOICE_CODEC + +# libspeex is faster on ARM-targets with -O1 instead of -O2 +SPEEXFLAGS = $(filter-out -O%,$(_SPEEXFLAGS)) + +ifeq ($(ARCH),arch_arm) + SPEEXFLAGS += -O1 +else + SPEEXFLAGS += -O2 +endif + +# libspeex +SPEEXLIB := $(CODECDIR)/libspeex.a +SPEEXLIB_SRC := $(call preprocess, $(RBCODECLIB_DIR)/codecs/libspeex/SOURCES) +SPEEXLIB_OBJ := $(call c2obj, $(SPEEXLIB_SRC)) +OTHER_SRC += $(SPEEXLIB_SRC) + +$(SPEEXLIB): $(SPEEXLIB_OBJ) + $(SILENT)$(shell rm -f $@) + $(call PRINTS,AR $(@F))$(AR) rcs $@ $^ >/dev/null + +# libspeex-voice +VOICESPEEXLIB := $(CODECDIR)/libspeex-voice.a +VOICESPEEXLIB_SRC := $(call preprocess, $(RBCODECLIB_DIR)/codecs/libspeex/SOURCES) +VOICESPEEXLIB_OBJ := $(addsuffix .o,$(basename $(subst $(RBCODECLIB_DIR)/codecs/libspeex,$(RBCODEC_BLD)/codecs/libspeex-voice,$(VOICESPEEXLIB_SRC)))) + +$(VOICESPEEXLIB): $(VOICESPEEXLIB_OBJ) + $(call PRINTS,AR $(@F))$(AR) rcs $@ $^ >/dev/null + +# pattern rules + +$(CODECDIR)/libspeex-voice/%.o : $(RBCODECLIB_DIR)/codecs/libspeex/%.c + $(SILENT)mkdir -p $(dir $@) + $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) $(VOICESPEEXFLAGS) -c $< -o $@ + +$(CODECDIR)/libspeex-voice/%.o : $(RBCODECLIB_DIR)/codecs/libspeex/%.S + $(SILENT)mkdir -p $(dir $@) + $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) $(VOICESPEEXFLAGS) $(ASMFLAGS) -c $< -o $@ + +$(CODECDIR)/libspeex/%.o: $(RBCODECLIB_DIR)/codecs/libspeex/%.c + $(SILENT)mkdir -p $(dir $@) + $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) $(SPEEXFLAGS) -c $< -o $@ + +$(CODECDIR)/libspeex/%.o: $(RBCODECLIB_DIR)/codecs/libspeex/%.S + $(SILENT)mkdir -p $(dir $@) + $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) $(SPEEXFLAGS) $(ASMFLAGS) -c $< -o $@ diff --git a/lib/rbcodec/codecs/libspeex/lpc.c b/lib/rbcodec/codecs/libspeex/lpc.c new file mode 100644 index 0000000000..9845633a6c --- /dev/null +++ b/lib/rbcodec/codecs/libspeex/lpc.c @@ -0,0 +1,201 @@ +/* + Copyright 1992, 1993, 1994 by Jutta Degener and Carsten Bormann, + Technische Universitaet Berlin + + Any use of this software is permitted provided that this notice is not + removed and that neither the authors nor the Technische Universitaet Berlin + are deemed to have made any representations as to the suitability of this + software for any purpose nor are held responsible for any defects of + this software. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE. + + As a matter of courtesy, the authors request to be informed about uses + this software has found, about bugs in this software, and about any + improvements that may be of general interest. + + Berlin, 28.11.1994 + Jutta Degener + Carsten Bormann + + + Code modified by Jean-Marc Valin + + Speex License: + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + - Neither the name of the Xiph.org Foundation nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifdef HAVE_CONFIG_H +#include "config-speex.h" +#endif + +#include "lpc.h" + +#ifdef BFIN_ASM +#include "lpc_bfin.h" +#endif + +/* LPC analysis + * + * The next two functions calculate linear prediction coefficients + * and/or the related reflection coefficients from the first P_MAX+1 + * values of the autocorrelation function. + */ + +/* Invented by N. Levinson in 1947, modified by J. Durbin in 1959. + */ + +/* returns minimum mean square error */ +spx_word32_t _spx_lpc( +spx_coef_t *lpc, /* out: [0...p-1] LPC coefficients */ +const spx_word16_t *ac, /* in: [0...p] autocorrelation values */ +int p +) +{ + int i, j; + spx_word16_t r; + spx_word16_t error = ac[0]; + + if (ac[0] == 0) + { + for (i = 0; i < p; i++) + lpc[i] = 0; + return 0; + } + + for (i = 0; i < p; i++) { + + /* Sum up this iteration's reflection coefficient */ + spx_word32_t rr = NEG32(SHL32(EXTEND32(ac[i + 1]),13)); + for (j = 0; j < i; j++) + rr = SUB32(rr,MULT16_16(lpc[j],ac[i - j])); +#ifdef FIXED_POINT + r = DIV32_16(rr+PSHR32(error,1),ADD16(error,8)); +#else + r = rr/(error+.003*ac[0]); +#endif + /* Update LPC coefficients and total error */ + lpc[i] = r; + for (j = 0; j < i>>1; j++) + { + spx_word16_t tmp = lpc[j]; + lpc[j] = MAC16_16_P13(lpc[j],r,lpc[i-1-j]); + lpc[i-1-j] = MAC16_16_P13(lpc[i-1-j],r,tmp); + } + if (i & 1) + lpc[j] = MAC16_16_P13(lpc[j],lpc[j],r); + + error = SUB16(error,MULT16_16_Q13(r,MULT16_16_Q13(error,r))); + } + return error; +} + + +#ifdef FIXED_POINT + +/* Compute the autocorrelation + * ,--, + * ac(i) = > x(n) * x(n-i) for all n + * `--' + * for lags between 0 and lag-1, and x == 0 outside 0...n-1 + */ + +#ifndef OVERRIDE_SPEEX_AUTOCORR +void _spx_autocorr( +const spx_word16_t *x, /* in: [0...n-1] samples x */ +spx_word16_t *ac, /* out: [0...lag-1] ac values */ +int lag, +int n +) +{ + spx_word32_t d; + int i, j; + spx_word32_t ac0=1; + int shift, ac_shift; + + for (j=0;j x(n) * x(n-i) for all n + * `--' + * for lags between 0 and lag-1, and x == 0 outside 0...n-1 + */ +void _spx_autocorr( +const spx_word16_t *x, /* in: [0...n-1] samples x */ +float *ac, /* out: [0...lag-1] ac values */ +int lag, +int n +) +{ + float d; + int i; + while (lag--) + { + for (i = lag, d = 0; i < n; i++) + d += x[i] * x[i-lag]; + ac[lag] = d; + } + ac[0] += 10; +} + +#endif + + diff --git a/lib/rbcodec/codecs/libspeex/lpc.h b/lib/rbcodec/codecs/libspeex/lpc.h new file mode 100644 index 0000000000..952ecdd933 --- /dev/null +++ b/lib/rbcodec/codecs/libspeex/lpc.h @@ -0,0 +1,53 @@ +/* Copyright (C) 2002 Jean-Marc Valin */ +/** + @file lpc.h + @brief Functions for LPC (Linear Prediction Coefficients) analysis +*/ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + - Neither the name of the Xiph.org Foundation nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef LPC_H +#define LPC_H + +#include "arch.h" + +void _spx_autocorr( + const spx_word16_t * x, /* in: [0...n-1] samples x */ + spx_word16_t *ac, /* out: [0...lag-1] ac values */ + int lag, int n); + +spx_word32_t /* returns minimum mean square error */ +_spx_lpc( + spx_coef_t * lpc, /* [0...p-1] LPC coefficients */ + const spx_word16_t * ac, /* in: [0...p] autocorrelation values */ + int p + ); + + +#endif diff --git a/lib/rbcodec/codecs/libspeex/lpc_bfin.h b/lib/rbcodec/codecs/libspeex/lpc_bfin.h new file mode 100644 index 0000000000..7310ffba52 --- /dev/null +++ b/lib/rbcodec/codecs/libspeex/lpc_bfin.h @@ -0,0 +1,131 @@ +/* Copyright (C) 2005 Analog Devices */ +/** + @file lpc_bfin.h + @author Jean-Marc Valin + @brief Functions for LPC (Linear Prediction Coefficients) analysis (Blackfin version) +*/ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + - Neither the name of the Xiph.org Foundation nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#define OVERRIDE_SPEEX_AUTOCORR +void _spx_autocorr( +const spx_word16_t *x, /* in: [0...n-1] samples x */ +spx_word16_t *ac, /* out: [0...lag-1] ac values */ +int lag, +int n + ) +{ + spx_word32_t d; + const spx_word16_t *xs; + int i, j; + spx_word32_t ac0=1; + spx_word32_t ac32[11], *ac32top; + int shift, ac_shift; + ac32top = ac32+lag-1; + int lag_1, N_lag; + int nshift; + lag_1 = lag-1; + N_lag = n-lag_1; + for (j=0;j> 1;\n\t" + "LOOP_BEGIN pitch%=;\n\t" + "I1 = P0;\n\t" + "A1 = A0 = 0;\n\t" + "R1 = [I1++];\n\t" + "LOOP inner_prod%= LC1 = P3 >> 1;\n\t" + "LOOP_BEGIN inner_prod%=;\n\t" + "A1 += R0.L*R1.H, A0 += R0.L*R1.L (IS) || R1.L = W[I1++];\n\t" + "A1 += R0.H*R1.L, A0 += R0.H*R1.H (IS) || R1.H = W[I1++] || R0 = [I0++];\n\t" + "LOOP_END inner_prod%=;\n\t" + "A0 = ASHIFT A0 by R4.L;\n\t" + "A1 = ASHIFT A1 by R4.L;\n\t" + + "R2 = A0, R3 = A1;\n\t" + "[P1--] = R2;\n\t" + "[P1--] = R3;\n\t" + "P0 += 4;\n\t" + "LOOP_END pitch%=;\n\t" + : : "m" (xs), "m" (x), "m" (ac32top), "m" (N_lag), "m" (lag_1), "m" (nshift) + : "A0", "A1", "P0", "P1", "P2", "P3", "P4", "R0", "R1", "R2", "R3", "R4", "I0", "I1", "L0", "L1", "B0", "B1", "memory" + ); + d=0; + for (j=0;j +#include "lsp.h" +#include "stack_alloc.h" +#include "math_approx.h" + +#ifndef M_PI +#define M_PI 3.14159265358979323846 /* pi */ +#endif + +#ifndef NULL +#define NULL 0 +#endif + +#ifdef FIXED_POINT + +#define FREQ_SCALE 16384 + +/*#define ANGLE2X(a) (32768*cos(((a)/8192.)))*/ +#define ANGLE2X(a) (SHL16(spx_cos(a),2)) + +/*#define X2ANGLE(x) (acos(.00006103515625*(x))*LSP_SCALING)*/ +#define X2ANGLE(x) (spx_acos(x)) + +#ifdef BFIN_ASM +#include "lsp_bfin.h" +#endif + +#else + +/*#define C1 0.99940307 +#define C2 -0.49558072 +#define C3 0.03679168*/ + +#define FREQ_SCALE 1. +#define ANGLE2X(a) (spx_cos(a)) +#define X2ANGLE(x) (acos(x)) + +#endif + + +/*---------------------------------------------------------------------------*\ + + FUNCTION....: cheb_poly_eva() + + AUTHOR......: David Rowe + DATE CREATED: 24/2/93 + + This function evaluates a series of Chebyshev polynomials + +\*---------------------------------------------------------------------------*/ + +#ifndef SPEEX_DISABLE_ENCODER + +#ifdef FIXED_POINT + +#ifndef OVERRIDE_CHEB_POLY_EVA +static inline spx_word32_t cheb_poly_eva( + spx_word16_t *coef, /* P or Q coefs in Q13 format */ + spx_word16_t x, /* cos of freq (-1.0 to 1.0) in Q14 format */ + int m, /* LPC order/2 */ + char *stack +) +{ + int i; + spx_word16_t b0, b1; + spx_word32_t sum; + + /*Prevents overflows*/ + if (x>16383) + x = 16383; + if (x<-16383) + x = -16383; + + /* Initialise values */ + b1=16384; + b0=x; + + /* Evaluate Chebyshev series formulation usin g iterative approach */ + sum = ADD32(EXTEND32(coef[m]), EXTEND32(MULT16_16_P14(coef[m-1],x))); + for(i=2;i<=m;i++) + { + spx_word16_t tmp=b0; + b0 = SUB16(MULT16_16_Q13(x,b0), b1); + b1 = tmp; + sum = ADD32(sum, EXTEND32(MULT16_16_P14(coef[m-i],b0))); + } + + return sum; +} +#endif + +#else + +static float cheb_poly_eva(spx_word32_t *coef, spx_word16_t x, int m, char *stack) +{ + int k; + float b0, b1, tmp; + + /* Initial conditions */ + b0=0; /* b_(m+1) */ + b1=0; /* b_(m+2) */ + + x*=2; + + /* Calculate the b_(k) */ + for(k=m;k>0;k--) + { + tmp=b0; /* tmp holds the previous value of b0 */ + b0=x*b0-b1+coef[m-k]; /* b0 holds its new value based on b0 and b1 */ + b1=tmp; /* b1 holds the previous value of b0 */ + } + + return(-b1+.5*x*b0+coef[m]); +} +#endif + +/*---------------------------------------------------------------------------*\ + + FUNCTION....: lpc_to_lsp() + + AUTHOR......: David Rowe + DATE CREATED: 24/2/93 + + This function converts LPC coefficients to LSP + coefficients. + +\*---------------------------------------------------------------------------*/ + +#ifdef FIXED_POINT +#define SIGN_CHANGE(a,b) (((a)&0x70000000)^((b)&0x70000000)||(b==0)) +#else +#define SIGN_CHANGE(a,b) (((a)*(b))<0.0) +#endif + + +int lpc_to_lsp (spx_coef_t *a,int lpcrdr,spx_lsp_t *freq,int nb,spx_word16_t delta, char *stack) +/* float *a lpc coefficients */ +/* int lpcrdr order of LPC coefficients (10) */ +/* float *freq LSP frequencies in the x domain */ +/* int nb number of sub-intervals (4) */ +/* float delta grid spacing interval (0.02) */ + + +{ + spx_word16_t temp_xr,xl,xr,xm=0; + spx_word32_t psuml,psumr,psumm,temp_psumr/*,temp_qsumr*/; + int i,j,m,flag,k; + VARDECL(spx_word32_t *Q); /* ptrs for memory allocation */ + VARDECL(spx_word32_t *P); + VARDECL(spx_word16_t *Q16); /* ptrs for memory allocation */ + VARDECL(spx_word16_t *P16); + spx_word32_t *px; /* ptrs of respective P'(z) & Q'(z) */ + spx_word32_t *qx; + spx_word32_t *p; + spx_word32_t *q; + spx_word16_t *pt; /* ptr used for cheb_poly_eval() + whether P' or Q' */ + int roots=0; /* DR 8/2/94: number of roots found */ + flag = 1; /* program is searching for a root when, + 1 else has found one */ + m = lpcrdr/2; /* order of P'(z) & Q'(z) polynomials */ + + /* Allocate memory space for polynomials */ + ALLOC(Q, (m+1), spx_word32_t); + ALLOC(P, (m+1), spx_word32_t); + + /* determine P'(z)'s and Q'(z)'s coefficients where + P'(z) = P(z)/(1 + z^(-1)) and Q'(z) = Q(z)/(1-z^(-1)) */ + + px = P; /* initialise ptrs */ + qx = Q; + p = px; + q = qx; + +#ifdef FIXED_POINT + *px++ = LPC_SCALING; + *qx++ = LPC_SCALING; + for(i=0;i=32768) + speex_warning_int("px", *px); + if (fabs(*qx)>=32768) + speex_warning_int("qx", *qx);*/ + *px = PSHR32(*px,2); + *qx = PSHR32(*qx,2); + px++; + qx++; + } + /* The reason for this lies in the way cheb_poly_eva() is implemented for fixed-point */ + P[m] = PSHR32(P[m],3); + Q[m] = PSHR32(Q[m],3); +#else + *px++ = LPC_SCALING; + *qx++ = LPC_SCALING; + for(i=0;i= -FREQ_SCALE)){ + spx_word16_t dd; + /* Modified by JMV to provide smaller steps around x=+-1 */ +#ifdef FIXED_POINT + dd = MULT16_16_Q15(delta,SUB16(FREQ_SCALE, MULT16_16_Q14(MULT16_16_Q14(xl,xl),14000))); + if (psuml<512 && psuml>-512) + dd = PSHR16(dd,1); +#else + dd=delta*(1-.9*xl*xl); + if (fabs(psuml)<.2) + dd *= .5; +#endif + xr = SUB16(xl, dd); /* interval spacing */ + psumr = cheb_poly_eva(pt,xr,m,stack);/* poly(xl-delta_x) */ + temp_psumr = psumr; + temp_xr = xr; + + /* if no sign change increment xr and re-evaluate poly(xr). Repeat til + sign change. + if a sign change has occurred the interval is bisected and then + checked again for a sign change which determines in which + interval the zero lies in. + If there is no sign change between poly(xm) and poly(xl) set interval + between xm and xr else set interval between xl and xr and repeat till + root is located within the specified limits */ + + if(SIGN_CHANGE(psumr,psuml)) + { + roots++; + + psumm=psuml; + for(k=0;k<=nb;k++){ +#ifdef FIXED_POINT + xm = ADD16(PSHR16(xl,1),PSHR16(xr,1)); /* bisect the interval */ +#else + xm = .5*(xl+xr); /* bisect the interval */ +#endif + psumm=cheb_poly_eva(pt,xm,m,stack); + /*if(psumm*psuml>0.)*/ + if(!SIGN_CHANGE(psumm,psuml)) + { + psuml=psumm; + xl=xm; + } else { + psumr=psumm; + xr=xm; + } + } + + /* once zero is found, reset initial interval to xr */ + freq[j] = X2ANGLE(xm); + xl = xm; + flag = 0; /* reset flag for next search */ + } + else{ + psuml=temp_psumr; + xl=temp_xr; + } + } + } + return(roots); +} + +#endif /* SPEEX_DISABLE_ENCODER */ + +/*---------------------------------------------------------------------------*\ + + FUNCTION....: lsp_to_lpc() + + AUTHOR......: David Rowe + DATE CREATED: 24/2/93 + + Converts LSP coefficients to LPC coefficients. + +\*---------------------------------------------------------------------------*/ + +#ifdef FIXED_POINT + +void lsp_to_lpc(spx_lsp_t *freq,spx_coef_t *ak,int lpcrdr, char *stack) +/* float *freq array of LSP frequencies in the x domain */ +/* float *ak array of LPC coefficients */ +/* int lpcrdr order of LPC coefficients */ +{ + (void)stack; + int i,j; + spx_word32_t xout1,xout2,xin; + spx_word32_t mult, a; + VARDECL(spx_word16_t *freqn); + VARDECL(spx_word32_t **xp); + VARDECL(spx_word32_t *xpmem); + VARDECL(spx_word32_t **xq); + VARDECL(spx_word32_t *xqmem); + int m = lpcrdr>>1; + + /* + + Reconstruct P(z) and Q(z) by cascading second order polynomials + in form 1 - 2cos(w)z(-1) + z(-2), where w is the LSP frequency. + In the time domain this is: + + y(n) = x(n) - 2cos(w)x(n-1) + x(n-2) + + This is what the ALLOCS below are trying to do: + + int xp[m+1][lpcrdr+1+2]; // P matrix in QIMP + int xq[m+1][lpcrdr+1+2]; // Q matrix in QIMP + + These matrices store the output of each stage on each row. The + final (m-th) row has the output of the final (m-th) cascaded + 2nd order filter. The first row is the impulse input to the + system (not written as it is known). + + The version below takes advantage of the fact that a lot of the + outputs are zero or known, for example if we put an inpulse + into the first section the "clock" it 10 times only the first 3 + outputs samples are non-zero (it's an FIR filter). + */ + + ALLOC(xp, (m+1), spx_word32_t*); + ALLOC(xpmem, (m+1)*(lpcrdr+1+2), spx_word32_t); + + ALLOC(xq, (m+1), spx_word32_t*); + ALLOC(xqmem, (m+1)*(lpcrdr+1+2), spx_word32_t); + + for(i=0; i<=m; i++) { + xp[i] = xpmem + i*(lpcrdr+1+2); + xq[i] = xqmem + i*(lpcrdr+1+2); + } + + /* work out 2cos terms in Q14 */ + + ALLOC(freqn, lpcrdr, spx_word16_t); + for (i=0;i 32767) a = 32767; + ak[j-1] = (short)a; + + } + +} + +#else + +void lsp_to_lpc(spx_lsp_t *freq,spx_coef_t *ak,int lpcrdr, char *stack) +/* float *freq array of LSP frequencies in the x domain */ +/* float *ak array of LPC coefficients */ +/* int lpcrdr order of LPC coefficients */ + + +{ + int i,j; + float xout1,xout2,xin1,xin2; + VARDECL(float *Wp); + float *pw,*n1,*n2,*n3,*n4=NULL; + VARDECL(float *x_freq); + int m = lpcrdr>>1; + + ALLOC(Wp, 4*m+2, float); + pw = Wp; + + /* initialise contents of array */ + + for(i=0;i<=4*m+1;i++){ /* set contents of buffer to 0 */ + *pw++ = 0.0; + } + + /* Set pointers up */ + + pw = Wp; + xin1 = 1.0; + xin2 = 1.0; + + ALLOC(x_freq, lpcrdr, float); + for (i=0;i0) + ak[j-1] = (xout1 + xout2)*0.5f; + *(n4+1) = xin1; + *(n4+2) = xin2; + + xin1 = 0.0; + xin2 = 0.0; + } + +} +#endif + + +#ifdef FIXED_POINT + +/*Makes sure the LSPs are stable*/ +void lsp_enforce_margin(spx_lsp_t *lsp, int len, spx_word16_t margin) +{ + int i; + spx_word16_t m = margin; + spx_word16_t m2 = 25736-margin; + + if (lsp[0]m2) + lsp[len-1]=m2; + for (i=1;ilsp[i+1]-m) + lsp[i]= SHR16(lsp[i],1) + SHR16(lsp[i+1]-m,1); + } +} + + +void lsp_interpolate(spx_lsp_t *old_lsp, spx_lsp_t *new_lsp, spx_lsp_t *interp_lsp, int len, int subframe, int nb_subframes) +{ + int i; + spx_word16_t tmp = DIV32_16(SHL32(EXTEND32(1 + subframe),14),nb_subframes); + spx_word16_t tmp2 = 16384-tmp; + for (i=0;iLSP_SCALING*(M_PI-margin)) + lsp[len-1]=LSP_SCALING*(M_PI-margin); + for (i=1;ilsp[i+1]-LSP_SCALING*margin) + lsp[i]= .5f* (lsp[i] + lsp[i+1]-LSP_SCALING*margin); + } +} + + +void lsp_interpolate(spx_lsp_t *old_lsp, spx_lsp_t *new_lsp, spx_lsp_t *interp_lsp, int len, int subframe, int nb_subframes) +{ + int i; + float tmp = (1.0f + subframe)/nb_subframes; + for (i=0;i>>= 14;\n\t" + "R3 = R3 + R5;\n\t" + + "R0 = R2;\n\t" /* R0: b0 */ + "R1 = 16384;\n\t" /* R1: b1 */ + "LOOP cpe%= LC0 = %3;\n\t" + "LOOP_BEGIN cpe%=;\n\t" + "P1 = R0;\n\t" + "R0 = R2.L * R0.L (IS) || R5 = W[P0--] (X);\n\t" + "R0 >>>= 13;\n\t" + "R0 = R0 - R1;\n\t" + "R1 = P1;\n\t" + "R5 = R5.L * R0.L (IS);\n\t" + "R5 = R5 + R4;\n\t" + "R5 >>>= 14;\n\t" + "R3 = R3 + R5;\n\t" + "LOOP_END cpe%=;\n\t" + "%0 = R3;\n\t" + : "=&d" (sum) + : "a" (x), "a" (&coef[m]), "a" (m-1) + : "R0", "R1", "R3", "R2", "R4", "R5", "P0", "P1" + ); + return sum; +} +#endif + + + diff --git a/lib/rbcodec/codecs/libspeex/lsp_tables_nb.c b/lib/rbcodec/codecs/libspeex/lsp_tables_nb.c new file mode 100644 index 0000000000..6bdd2e4d0f --- /dev/null +++ b/lib/rbcodec/codecs/libspeex/lsp_tables_nb.c @@ -0,0 +1,362 @@ +/* Copyright (C) 2002 Jean-Marc Valin + File: lsp_tables_nb.c + Codebooks for LSPs in narrowband CELP mode + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + 3. The name of the author may not be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#include "config-speex.h" + +const signed char cdbk_nb[640] LSP_ICONST_ATTR = { +30,19,38,34,40,32,46,43,58,43, +5,-18,-25,-40,-33,-55,-52,20,34,28, +-20,-63,-97,-92,61,53,47,49,53,75, +-14,-53,-77,-79,0,-3,-5,19,22,26, +-9,-53,-55,66,90,72,85,68,74,52, +-4,-41,-58,-31,-18,-31,27,32,30,18, +24,3,8,5,-12,-3,26,28,74,63, +-2,-39,-67,-77,-106,-74,59,59,73,65, +44,40,71,72,82,83,98,88,89,60, +-6,-31,-47,-48,-13,-39,-9,7,2,79, +-1,-39,-60,-17,87,81,65,50,45,19, +-21,-67,-91,-87,-41,-50,7,18,39,74, +10,-31,-28,39,24,13,23,5,56,45, +29,10,-5,-13,-11,-35,-18,-8,-10,-8, +-25,-71,-77,-21,2,16,50,63,87,87, +5,-32,-40,-51,-68,0,12,6,54,34, +5,-12,32,52,68,64,69,59,65,45, +14,-16,-31,-40,-65,-67,41,49,47,37, +-11,-52,-75,-84,-4,57,48,42,42,33, +-11,-51,-68,-6,13,0,8,-8,26,32, +-23,-53,0,36,56,76,97,105,111,97, +-1,-28,-39,-40,-43,-54,-44,-40,-18,35, +16,-20,-19,-28,-42,29,47,38,74,45, +3,-29,-48,-62,-80,-104,-33,56,59,59, +10,17,46,72,84,101,117,123,123,106, +-7,-33,-49,-51,-70,-67,-27,-31,70,67, +-16,-62,-85,-20,82,71,86,80,85,74, +-19,-58,-75,-45,-29,-33,-18,-25,45,57, +-12,-42,-5,12,28,36,52,64,81,82, +13,-9,-27,-28,22,3,2,22,26,6, +-6,-44,-51,2,15,10,48,43,49,34, +-19,-62,-84,-89,-102,-24,8,17,61,68, +39,24,23,19,16,-5,12,15,27,15, +-8,-44,-49,-60,-18,-32,-28,52,54,62, +-8,-48,-77,-70,66,101,83,63,61,37, +-12,-50,-75,-64,33,17,13,25,15,77, +1,-42,-29,72,64,46,49,31,61,44, +-8,-47,-54,-46,-30,19,20,-1,-16,0, +16,-12,-18,-9,-26,-27,-10,-22,53,45, +-10,-47,-75,-82,-105,-109,8,25,49,77, +50,65,114,117,124,118,115,96,90,61, +-9,-45,-63,-60,-75,-57,8,11,20,29, +0,-35,-49,-43,40,47,35,40,55,38, +-24,-76,-103,-112,-27,3,23,34,52,75, +8,-29,-43,12,63,38,35,29,24,8, +25,11,1,-15,-18,-43,-7,37,40,21, +-20,-56,-19,-19,-4,-2,11,29,51,63, +-2,-44,-62,-75,-89,30,57,51,74,51, +50,46,68,64,65,52,63,55,65,43, +18,-9,-26,-35,-55,-69,3,6,8,17, +-15,-61,-86,-97,1,86,93,74,78,67, +-1,-38,-66,-48,48,39,29,25,17,-1, +13,13,29,39,50,51,69,82,97,98, +-2,-36,-46,-27,-16,-30,-13,-4,-7,-4, +25,-5,-11,-6,-25,-21,33,12,31,29, +-8,-38,-52,-63,-68,-89,-33,-1,10,74, +-2,-15,59,91,105,105,101,87,84,62, +-7,-33,-50,-35,-54,-47,25,17,82,81, +-13,-56,-83,21,58,31,42,25,72,65, +-24,-66,-91,-56,9,-2,21,10,69,75, +2,-24,11,22,25,28,38,34,48,33, +7,-29,-26,17,15,-1,14,0,-2,0, +-6,-41,-67,6,-2,-9,19,2,85,74, +-22,-67,-84,-71,-50,3,11,-9,2,62}; + +const signed char cdbk_nb_low1[320] LSP_ICONST_ATTR = { +-34,-52,-15,45,2, +23,21,52,24,-33, +-9,-1,9,-44,-41, +-13,-17,44,22,-17, +-6,-4,-1,22,38, +26,16,2,50,27, +-35,-34,-9,-41,6, +0,-16,-34,51,8, +-14,-31,-49,15,-33, +45,49,33,-11,-37, +-62,-54,45,11,-5, +-72,11,-1,-12,-11, +24,27,-11,-43,46, +43,33,-12,-9,-1, +1,-4,-23,-57,-71, +11,8,16,17,-8, +-20,-31,-41,53,48, +-16,3,65,-24,-8, +-23,-32,-37,-32,-49, +-10,-17,6,38,5, +-9,-17,-46,8,52, +3,6,45,40,39, +-7,-6,-34,-74,31, +8,1,-16,43,68, +-11,-19,-31,4,6, +0,-6,-17,-16,-38, +-16,-30,2,9,-39, +-16,-1,43,-10,48, +3,3,-16,-31,-3, +62,68,43,13,3, +-10,8,20,-56,12, +12,-2,-18,22,-15, +-40,-36,1,7,41, +0,1,46,-6,-62, +-4,-12,-2,-11,-83, +-13,-2,91,33,-10, +0,4,-11,-16,79, +32,37,14,9,51, +-21,-28,-56,-34,0, +21,9,-26,11,28, +-42,-54,-23,-2,-15, +31,30,8,-39,-66, +-39,-36,31,-28,-40, +-46,35,40,22,24, +33,48,23,-34,14, +40,32,17,27,-3, +25,26,-13,-61,-17, +11,4,31,60,-6, +-26,-41,-64,13,16, +-26,54,31,-11,-23, +-9,-11,-34,-71,-21, +-34,-35,55,50,29, +-22,-27,-50,-38,57, +33,42,57,48,26, +11,0,-49,-31,26, +-4,-14,5,78,37, +17,0,-49,-12,-23, +26,14,2,2,-43, +-17,-12,10,-8,-4, +8,18,12,-6,20, +-12,-6,-13,-25,34, +15,40,49,7,8, +13,20,20,-19,-22, +-2,-8,2,51,-51}; + +const signed char cdbk_nb_low2[320] LSP_ICONST_ATTR = { +-6,53,-21,-24,4, +26,17,-4,-37,25, +17,-36,-13,31,3, +-6,27,15,-10,31, +28,26,-10,-10,-40, +16,-7,15,13,41, +-9,0,-4,50,-6, +-7,14,38,22,0, +-48,2,1,-13,-19, +32,-3,-60,11,-17, +-1,-24,-34,-1,35, +-5,-27,28,44,13, +25,15,42,-11,15, +51,35,-36,20,8, +-4,-12,-29,19,-47, +49,-15,-4,16,-29, +-39,14,-30,4,25, +-9,-5,-51,-14,-3, +-40,-32,38,5,-9, +-8,-4,-1,-22,71, +-3,14,26,-18,-22, +24,-41,-25,-24,6, +23,19,-10,39,-26, +-27,65,45,2,-7, +-26,-8,22,-12,16, +15,16,-35,-5,33, +-21,-8,0,23,33, +34,6,21,36,6, +-7,-22,8,-37,-14, +31,38,11,-4,-3, +-39,-32,-8,32,-23, +-6,-12,16,20,-28, +-4,23,13,-52,-1, +22,6,-33,-40,-6, +4,-62,13,5,-26, +35,39,11,2,57, +-11,9,-20,-28,-33, +52,-5,-6,-2,22, +-14,-16,-48,35,1, +-58,20,13,33,-1, +-74,56,-18,-22,-31, +12,6,-14,4,-2, +-9,-47,10,-3,29, +-17,-5,61,14,47, +-12,2,72,-39,-17, +92,64,-53,-51,-15, +-30,-38,-41,-29,-28, +27,9,36,9,-35, +-42,81,-21,20,25, +-16,-5,-17,-35,21, +15,-28,48,2,-2, +9,-19,29,-40,30, +-18,-18,18,-16,-57, +15,-20,-12,-15,-37, +-15,33,-39,21,-22, +-13,35,11,13,-38, +-63,29,23,-27,32, +18,3,-26,42,33, +-64,-66,-17,16,56, +2,36,3,31,21, +-41,-39,8,-57,14, +37,-2,19,-36,-19, +-23,-29,-16,1,-3, +-8,-10,31,64,-65}; + +const signed char cdbk_nb_high1[320] LSP_ICONST_ATTR = { +-26,-8,29,21,4, +19,-39,33,-7,-36, +56,54,48,40,29, +-4,-24,-42,-66,-43, +-60,19,-2,37,41, +-10,-37,-60,-64,18, +-22,77,73,40,25, +4,19,-19,-66,-2, +11,5,21,14,26, +-25,-86,-4,18,1, +26,-37,10,37,-1, +24,-12,-59,-11,20, +-6,34,-16,-16,42, +19,-28,-51,53,32, +4,10,62,21,-12, +-34,27,4,-48,-48, +-50,-49,31,-7,-21, +-42,-25,-4,-43,-22, +59,2,27,12,-9, +-6,-16,-8,-32,-58, +-16,-29,-5,41,23, +-30,-33,-46,-13,-10, +-38,52,52,1,-17, +-9,10,26,-25,-6, +33,-20,53,55,25, +-32,-5,-42,23,21, +66,5,-28,20,9, +75,29,-7,-42,-39, +15,3,-23,21,6, +11,1,-29,14,63, +10,54,26,-24,-51, +-49,7,-23,-51,15, +-66,1,60,25,10, +0,-30,-4,-15,17, +19,59,40,4,-5, +33,6,-22,-58,-70, +-5,23,-6,60,44, +-29,-16,-47,-29,52, +-19,50,28,16,35, +31,36,0,-21,6, +21,27,22,42,7, +-66,-40,-8,7,19, +46,0,-4,60,36, +45,-7,-29,-6,-32, +-39,2,6,-9,33, +20,-51,-34,18,-6, +19,6,11,5,-19, +-29,-2,42,-11,-45, +-21,-55,57,37,2, +-14,-67,-16,-27,-38, +69,48,19,2,-17, +20,-20,-16,-34,-17, +-25,-61,10,73,45, +16,-40,-64,-17,-29, +-22,56,17,-39,8, +-11,8,-25,-18,-13, +-19,8,54,57,36, +-17,-26,-4,6,-21, +40,42,-4,20,31, +53,10,-34,-53,31, +-17,35,0,15,-6, +-20,-63,-73,22,25, +29,17,8,-29,-39, +-69,18,15,-15,-5}; + +const signed char cdbk_nb_high2[320] LSP_ICONST_ATTR = { +11,47,16,-9,-46, +-32,26,-64,34,-5, +38,-7,47,20,2, +-73,-99,-3,-45,20, +70,-52,15,-6,-7, +-82,31,21,47,51, +39,-3,9,0,-41, +-7,-15,-54,2,0, +27,-31,9,-45,-22, +-38,-24,-24,8,-33, +23,5,50,-36,-17, +-18,-51,-2,13,19, +43,12,-15,-12,61, +38,38,7,13,0, +6,-1,3,62,9, +27,22,-33,38,-35, +-9,30,-43,-9,-32, +-1,4,-4,1,-5, +-11,-8,38,31,11, +-10,-42,-21,-37,1, +43,15,-13,-35,-19, +-18,15,23,-26,59, +1,-21,53,8,-41, +-50,-14,-28,4,21, +25,-28,-40,5,-40, +-41,4,51,-33,-8, +-8,1,17,-60,12, +25,-41,17,34,43, +19,45,7,-37,24, +-15,56,-2,35,-10, +48,4,-47,-2,5, +-5,-54,5,-3,-33, +-10,30,-2,-44,-24, +-38,9,-9,42,4, +6,-56,44,-16,9, +-40,-26,18,-20,10, +28,-41,-21,-4,13, +-18,32,-30,-3,37, +15,22,28,50,-40, +3,-29,-64,7,51, +-19,-11,17,-27,-40, +-64,24,-12,-7,-27, +3,37,48,-1,2, +-9,-38,-34,46,1, +27,-6,19,-13,26, +10,34,20,25,40, +50,-6,-7,30,9, +-24,0,-23,71,-61, +22,58,-34,-4,2, +-49,-33,25,30,-8, +-6,-16,77,2,38, +-8,-35,-6,-30,56, +78,31,33,-20,13, +-39,20,22,4,21, +-8,4,-6,10,-83, +-41,9,-25,-43,15, +-7,-12,-34,-39,-37, +-33,19,30,16,-33, +42,-25,25,-68,44, +-15,-11,-4,23,50, +14,4,-39,-43,20, +-30,60,9,-20,7, +16,19,-33,37,29, +16,-35,7,38,-27}; diff --git a/lib/rbcodec/codecs/libspeex/ltp.c b/lib/rbcodec/codecs/libspeex/ltp.c new file mode 100644 index 0000000000..9f10bc09d8 --- /dev/null +++ b/lib/rbcodec/codecs/libspeex/ltp.c @@ -0,0 +1,856 @@ +/* Copyright (C) 2002-2006 Jean-Marc Valin + File: ltp.c + Long-Term Prediction functions + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + - Neither the name of the Xiph.org Foundation nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifdef HAVE_CONFIG_H +#include "config-speex.h" +#endif + +#include +#include "ltp.h" +#include "stack_alloc.h" +#include "filters.h" +#include "speex/speex_bits.h" +#include "math_approx.h" +#include "os_support.h" + +#ifndef NULL +#define NULL 0 +#endif + + +#ifdef _USE_SSE +#include "ltp_sse.h" +#elif defined (ARM4_ASM) || defined(ARM5E_ASM) +#include "ltp_arm4.h" +#elif defined (COLDFIRE_ASM) +#define OVERRIDE_INNER_PROD +#elif defined (BFIN_ASM) +#include "ltp_bfin.h" +#endif + +#ifndef OVERRIDE_INNER_PROD +spx_word32_t inner_prod(const spx_word16_t *x, const spx_word16_t *y, int len) +{ + spx_word32_t sum=0; + len >>= 2; + while(len--) + { + spx_word32_t part=0; + part = MAC16_16(part,*x++,*y++); + part = MAC16_16(part,*x++,*y++); + part = MAC16_16(part,*x++,*y++); + part = MAC16_16(part,*x++,*y++); + /* HINT: If you had a 40-bit accumulator, you could shift only at the end */ + sum = ADD32(sum,SHR32(part,6)); + } + return sum; +} +#endif + +#ifndef SPEEX_DISABLE_ENCODER +#ifndef OVERRIDE_PITCH_XCORR +#if 0 /* HINT: Enable this for machines with enough registers (i.e. not x86) */ +void pitch_xcorr(const spx_word16_t *_x, const spx_word16_t *_y, spx_word32_t *corr, int len, int nb_pitch, char *stack) +{ + int i,j; + for (i=0;i16383) + { + scaledown=1; + break; + } + } + /* If the weighted input is close to saturation, then we scale it down */ + if (scaledown) + { + for (i=-end;iMULT16_16(best_score[N-1],ADD16(1,ener16[i-start]))) + { + /* We can safely put it last and then check */ + best_score[N-1]=tmp; + best_ener[N-1]=ener16[i-start]+1; + pitch[N-1]=i; + /* Check if it comes in front of others */ + for (j=0;jMULT16_16(best_score[j],ADD16(1,ener16[i-start]))) + { + for (k=N-1;k>j;k--) + { + best_score[k]=best_score[k-1]; + best_ener[k]=best_ener[k-1]; + pitch[k]=pitch[k-1]; + } + best_score[j]=tmp; + best_ener[j]=ener16[i-start]+1; + pitch[j]=i; + break; + } + } + } + } + + /* Compute open-loop gain if necessary */ + if (gain) + { + for (j=0;jbest_sum && gain_sum<=max_gain) { + best_sum=sum; + best_cdbk=i; + } + } + + return best_cdbk; +} +#endif + +/** Finds the best quantized 3-tap pitch predictor by analysis by synthesis */ +static spx_word32_t pitch_gain_search_3tap( +const spx_word16_t target[], /* Target vector */ +const spx_coef_t ak[], /* LPCs for this subframe */ +const spx_coef_t awk1[], /* Weighted LPCs #1 for this subframe */ +const spx_coef_t awk2[], /* Weighted LPCs #2 for this subframe */ +spx_sig_t exc[], /* Excitation */ +const signed char *gain_cdbk, +int gain_cdbk_size, +int pitch, /* Pitch value */ +int p, /* Number of LPC coeffs */ +int nsf, /* Number of samples in subframe */ +SpeexBits *bits, +char *stack, +const spx_word16_t *exc2, +const spx_word16_t *r, +spx_word16_t *new_target, +int *cdbk_index, +int plc_tuning, +spx_word32_t cumul_gain, +int scaledown +) +{ + int i,j; + VARDECL(spx_word16_t *tmp1); + VARDECL(spx_word16_t *e); + spx_word16_t *x[3]; + spx_word32_t corr[3]; + spx_word32_t A[3][3]; + spx_word16_t gain[3]; + spx_word32_t err; + spx_word16_t max_gain=128; + int best_cdbk=0; + + ALLOC(tmp1, 3*nsf, spx_word16_t); + ALLOC(e, nsf, spx_word16_t); + + if (cumul_gain > 262144) + max_gain = 31; + + x[0]=tmp1; + x[1]=tmp1+nsf; + x[2]=tmp1+2*nsf; + + for (j=0;j=0;i--) + { + spx_word16_t e0=exc2[-pitch-1+i]; +#ifdef FIXED_POINT + /* Scale excitation down if needed (avoiding overflow) */ + if (scaledown) + e0 = SHR16(e0,1); +#endif + x[i][0]=MULT16_16_Q14(r[0], e0); + for (j=0;j30) + plc_tuning=30; +#ifdef FIXED_POINT + C[0] = SHL32(C[0],1); + C[1] = SHL32(C[1],1); + C[2] = SHL32(C[2],1); + C[3] = SHL32(C[3],1); + C[4] = SHL32(C[4],1); + C[5] = SHL32(C[5],1); + C[6] = MAC16_32_Q15(C[6],MULT16_16_16(plc_tuning,655),C[6]); + C[7] = MAC16_32_Q15(C[7],MULT16_16_16(plc_tuning,655),C[7]); + C[8] = MAC16_32_Q15(C[8],MULT16_16_16(plc_tuning,655),C[8]); + normalize16(C, C16, 32767, 9); +#else + C[6]*=.5*(1+.02*plc_tuning); + C[7]*=.5*(1+.02*plc_tuning); + C[8]*=.5*(1+.02*plc_tuning); +#endif + + best_cdbk = pitch_gain_search_3tap_vq(gain_cdbk, gain_cdbk_size, C16, max_gain); + +#ifdef FIXED_POINT + gain[0] = ADD16(32,(spx_word16_t)gain_cdbk[best_cdbk*4]); + gain[1] = ADD16(32,(spx_word16_t)gain_cdbk[best_cdbk*4+1]); + gain[2] = ADD16(32,(spx_word16_t)gain_cdbk[best_cdbk*4+2]); + /*printf ("%d %d %d %d\n",gain[0],gain[1],gain[2], best_cdbk);*/ +#else + gain[0] = 0.015625*gain_cdbk[best_cdbk*4] + .5; + gain[1] = 0.015625*gain_cdbk[best_cdbk*4+1]+ .5; + gain[2] = 0.015625*gain_cdbk[best_cdbk*4+2]+ .5; +#endif + *cdbk_index=best_cdbk; + } + + SPEEX_MEMSET(exc, 0, nsf); + for (i=0;i<3;i++) + { + int j; + int tmp1, tmp3; + int pp=pitch+1-i; + tmp1=nsf; + if (tmp1>pp) + tmp1=pp; + for (j=0;jpp+pitch) + tmp3=pp+pitch; + for (j=tmp1;jgain_bits; + gain_cdbk = params->gain_cdbk + 4*gain_cdbk_size*cdbk_offset; + + N=complexity; + if (N>10) + N=10; + if (N<1) + N=1; + + ALLOC(nbest, N, int); + params = (const ltp_params*) par; + + if (endpitch_bits); + speex_bits_pack(bits, 0, params->gain_bits); + SPEEX_MEMSET(exc, 0, nsf); + return start; + } + +#ifdef FIXED_POINT + /* Check if we need to scale everything down in the pitch search to avoid overflows */ + for (i=0;i16383) + { + scaledown=1; + break; + } + } + for (i=-end;i16383) + { + scaledown=1; + break; + } + } +#endif + if (N>end-start+1) + N=end-start+1; + if (end != start) + open_loop_nbest_pitch(sw, start, end, nsf, nbest, NULL, N, stack); + else + nbest[0] = start; + + ALLOC(best_exc, nsf, spx_sig_t); + ALLOC(new_target, nsf, spx_word16_t); + ALLOC(best_target, nsf, spx_word16_t); + + for (i=0;ipitch_bits); + speex_bits_pack(bits, best_gain_index, params->gain_bits); +#ifdef FIXED_POINT + *cumul_gain = MULT16_32_Q13(SHL16(params->gain_cdbk[4*best_gain_index+3],8), MAX32(1024,*cumul_gain)); +#else + *cumul_gain = 0.03125*MAX32(1024,*cumul_gain)*params->gain_cdbk[4*best_gain_index+3]; +#endif + /*printf ("%f\n", cumul_gain);*/ + /*printf ("encode pitch: %d %d\n", best_pitch, best_gain_index);*/ + SPEEX_COPY(exc, best_exc, nsf); + SPEEX_COPY(target, best_target, nsf); +#ifdef FIXED_POINT + /* Scale target back up if needed */ + if (scaledown) + { + for (i=0;igain_bits; + gain_cdbk = params->gain_cdbk + 4*gain_cdbk_size*cdbk_offset; + + pitch = speex_bits_unpack_unsigned(bits, params->pitch_bits); + pitch += start; + gain_index = speex_bits_unpack_unsigned(bits, params->gain_bits); + /*printf ("decode pitch: %d %d\n", pitch, gain_index);*/ +#ifdef FIXED_POINT + gain[0] = ADD16(32,(spx_word16_t)gain_cdbk[gain_index*4]); + gain[1] = ADD16(32,(spx_word16_t)gain_cdbk[gain_index*4+1]); + gain[2] = ADD16(32,(spx_word16_t)gain_cdbk[gain_index*4+2]); +#else + gain[0] = 0.015625*gain_cdbk[gain_index*4]+.5; + gain[1] = 0.015625*gain_cdbk[gain_index*4+1]+.5; + gain[2] = 0.015625*gain_cdbk[gain_index*4+2]+.5; +#endif + + if (count_lost && pitch > subframe_offset) + { + spx_word16_t gain_sum; + if (1) { +#ifdef FIXED_POINT + spx_word16_t tmp = count_lost < 4 ? last_pitch_gain : SHR16(last_pitch_gain,1); + if (tmp>62) + tmp=62; +#else + spx_word16_t tmp = count_lost < 4 ? last_pitch_gain : 0.5 * last_pitch_gain; + if (tmp>.95) + tmp=.95; +#endif + gain_sum = gain_3tap_to_1tap(gain); + + if (gain_sum > tmp) + { + spx_word16_t fact = DIV32_16(SHL32(EXTEND32(tmp),14),gain_sum); + for (i=0;i<3;i++) + gain[i]=MULT16_16_Q14(fact,gain[i]); + } + + } + + } + + *pitch_val = pitch; + gain_val[0]=gain[0]; + gain_val[1]=gain[1]; + gain_val[2]=gain[2]; + gain[0] = SHL16(gain[0],7); + gain[1] = SHL16(gain[1],7); + gain[2] = SHL16(gain[2],7); + SPEEX_MEMSET(exc_out, 0, nsf); + for (i=0;i<3;i++) + { + int j; + int tmp1, tmp3; + int pp=pitch+1-i; + tmp1=nsf; + if (tmp1>pp) + tmp1=pp; + for (j=0;jpp+pitch) + tmp3=pp+pitch; + for (j=tmp1;j63) + pitch_coef=63; +#else + if (pitch_coef>.99) + pitch_coef=.99; +#endif + for (i=0;i63) + pitch_coef=63; +#else + if (pitch_coef>.99) + pitch_coef=.99; +#endif + for (i=0;i0 ? g[0] : -SHR16(g[0],1)) + (g[2]>0 ? g[2] : -SHR16(g[2],1))) +#else +#define gain_3tap_to_1tap(g) (ABS(g[1]) + (g[0]>0 ? g[0] : -.5*g[0]) + (g[2]>0 ? g[2] : -.5*g[2])) +#endif + +spx_word32_t inner_prod(const spx_word16_t *x, const spx_word16_t *y, int len); +void pitch_xcorr(const spx_word16_t *_x, const spx_word16_t *_y, spx_word32_t *corr, int len, int nb_pitch, char *stack); + +void open_loop_nbest_pitch(spx_word16_t *sw, int start, int end, int len, int *pitch, spx_word16_t *gain, int N, char *stack); + + +/** Finds the best quantized 3-tap pitch predictor by analysis by synthesis */ +int pitch_search_3tap( +spx_word16_t target[], /* Target vector */ +spx_word16_t *sw, +spx_coef_t ak[], /* LPCs for this subframe */ +spx_coef_t awk1[], /* Weighted LPCs #1 for this subframe */ +spx_coef_t awk2[], /* Weighted LPCs #2 for this subframe */ +spx_sig_t exc[], /* Overlapping codebook */ +const void *par, +int start, /* Smallest pitch value allowed */ +int end, /* Largest pitch value allowed */ +spx_word16_t pitch_coef, /* Voicing (pitch) coefficient */ +int p, /* Number of LPC coeffs */ +int nsf, /* Number of samples in subframe */ +SpeexBits *bits, +char *stack, +spx_word16_t *exc2, +spx_word16_t *r, +int complexity, +int cdbk_offset, +int plc_tuning, +spx_word32_t *cumul_gain +); + +/*Unquantize adaptive codebook and update pitch contribution*/ +void pitch_unquant_3tap( +spx_word16_t exc[], /* Input excitation */ +spx_word32_t exc_out[], /* Output excitation */ +int start, /* Smallest pitch value allowed */ +int end, /* Largest pitch value allowed */ +spx_word16_t pitch_coef, /* Voicing (pitch) coefficient */ +const void *par, +int nsf, /* Number of samples in subframe */ +int *pitch_val, +spx_word16_t *gain_val, +SpeexBits *bits, +char *stack, +int lost, +int subframe_offset, +spx_word16_t last_pitch_gain, +int cdbk_offset +); + +/** Forced pitch delay and gain */ +int forced_pitch_quant( +spx_word16_t target[], /* Target vector */ +spx_word16_t *sw, +spx_coef_t ak[], /* LPCs for this subframe */ +spx_coef_t awk1[], /* Weighted LPCs #1 for this subframe */ +spx_coef_t awk2[], /* Weighted LPCs #2 for this subframe */ +spx_sig_t exc[], /* Excitation */ +const void *par, +int start, /* Smallest pitch value allowed */ +int end, /* Largest pitch value allowed */ +spx_word16_t pitch_coef, /* Voicing (pitch) coefficient */ +int p, /* Number of LPC coeffs */ +int nsf, /* Number of samples in subframe */ +SpeexBits *bits, +char *stack, +spx_word16_t *exc2, +spx_word16_t *r, +int complexity, +int cdbk_offset, +int plc_tuning, +spx_word32_t *cumul_gain +); + +/** Unquantize forced pitch delay and gain */ +void forced_pitch_unquant( +spx_word16_t exc[], /* Input excitation */ +spx_word32_t exc_out[], /* Output excitation */ +int start, /* Smallest pitch value allowed */ +int end, /* Largest pitch value allowed */ +spx_word16_t pitch_coef, /* Voicing (pitch) coefficient */ +const void *par, +int nsf, /* Number of samples in subframe */ +int *pitch_val, +spx_word16_t *gain_val, +SpeexBits *bits, +char *stack, +int lost, +int subframe_offset, +spx_word16_t last_pitch_gain, +int cdbk_offset +); diff --git a/lib/rbcodec/codecs/libspeex/ltp_arm4.h b/lib/rbcodec/codecs/libspeex/ltp_arm4.h new file mode 100644 index 0000000000..46ecfa40ec --- /dev/null +++ b/lib/rbcodec/codecs/libspeex/ltp_arm4.h @@ -0,0 +1,188 @@ +/* Copyright (C) 2004 Jean-Marc Valin */ +/** + @file ltp_arm4.h + @brief Long-Term Prediction functions (ARM4 version) +*/ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + - Neither the name of the Xiph.org Foundation nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#define OVERRIDE_INNER_PROD +spx_word32_t inner_prod(const spx_word16_t *x, const spx_word16_t *y, int len) +{ + spx_word32_t sum1=0,sum2=0; + spx_word16_t *deadx, *deady; + int deadlen, dead1, dead2, dead3, dead4, dead5, dead6; + __asm__ __volatile__ ( + "\tldrsh %5, [%0], #2 \n" + "\tldrsh %6, [%1], #2 \n" + ".inner_prod_loop%=:\n" + "\tsub %7, %7, %7\n" + "\tsub %10, %10, %10\n" + + "\tldrsh %8, [%0], #2 \n" + "\tldrsh %9, [%1], #2 \n" + "\tmla %7, %5, %6, %7\n" + "\tldrsh %5, [%0], #2 \n" + "\tldrsh %6, [%1], #2 \n" + "\tmla %10, %8, %9, %10\n" + "\tldrsh %8, [%0], #2 \n" + "\tldrsh %9, [%1], #2 \n" + "\tmla %7, %5, %6, %7\n" + "\tldrsh %5, [%0], #2 \n" + "\tldrsh %6, [%1], #2 \n" + "\tmla %10, %8, %9, %10\n" + + "\tldrsh %8, [%0], #2 \n" + "\tldrsh %9, [%1], #2 \n" + "\tmla %7, %5, %6, %7\n" + "\tldrsh %5, [%0], #2 \n" + "\tldrsh %6, [%1], #2 \n" + "\tmla %10, %8, %9, %10\n" + "\tldrsh %8, [%0], #2 \n" + "\tldrsh %9, [%1], #2 \n" + "\tmla %7, %5, %6, %7\n" + "\tldrsh %5, [%0], #2 \n" + "\tldrsh %6, [%1], #2 \n" + "\tmla %10, %8, %9, %10\n" + + "\tsubs %4, %4, #1\n" + "\tadd %2, %2, %7, asr #5\n" + "\tadd %3, %3, %10, asr #5\n" + "\tbne .inner_prod_loop%=\n" + : "=r" (deadx), "=r" (deady), "+r" (sum1), "+r" (sum2), + "=r" (deadlen), "=r" (dead1), "=r" (dead2), "=r" (dead3), + "=r" (dead4), "=r" (dead5), "=r" (dead6) + : "0" (x), "1" (y), "4" (len>>3) + : "cc", "memory" + ); + return (sum1+sum2)>>1; +} + +#define OVERRIDE_PITCH_XCORR +void pitch_xcorr(const spx_word16_t *_x, const spx_word16_t *_y, spx_word32_t *corr, int len, int nb_pitch, char *stack) +{ + (void)stack; + int i,j; + for (i=0;i>> 6;\n\t" + "R0 = A0;\n\t" + "%0 = R0;\n\t" + : "=m" (sum) + : "m" (x), "m" (y), "d" (len-1) + : "P0", "P1", "P2", "R0", "R1", "A0", "I0", "I1", "L0", "L1", "R3" + ); + return sum; +} + +#define OVERRIDE_PITCH_XCORR +void pitch_xcorr(const spx_word16_t *_x, const spx_word16_t *_y, spx_word32_t *corr, int len, int nb_pitch, char *stack) +{ + corr += nb_pitch - 1; + __asm__ __volatile__ ( + "P2 = %0;\n\t" + "I0 = P2;\n\t" /* x in I0 */ + "B0 = P2;\n\t" /* x in B0 */ + "R0 = %3;\n\t" /* len in R0 */ + "P3 = %3;\n\t" + "P3 += -2;\n\t" /* len in R0 */ + "P4 = %4;\n\t" /* nb_pitch in R0 */ + "R1 = R0 << 1;\n\t" /* number of bytes in x */ + "L0 = R1;\n\t" + "P0 = %1;\n\t" + + "P1 = %2;\n\t" + "B1 = P1;\n\t" + "L1 = 0;\n\t" /*Disable looping on I1*/ + + "r0 = [I0++];\n\t" + "LOOP pitch%= LC0 = P4 >> 1;\n\t" + "LOOP_BEGIN pitch%=;\n\t" + "I1 = P0;\n\t" + "A1 = A0 = 0;\n\t" + "R1 = [I1++];\n\t" + "LOOP inner_prod%= LC1 = P3 >> 1;\n\t" + "LOOP_BEGIN inner_prod%=;\n\t" + "A1 += R0.L*R1.H, A0 += R0.L*R1.L (IS) || R1.L = W[I1++];\n\t" + "A1 += R0.H*R1.L, A0 += R0.H*R1.H (IS) || R1.H = W[I1++] || R0 = [I0++];\n\t" + "LOOP_END inner_prod%=;\n\t" + "A1 += R0.L*R1.H, A0 += R0.L*R1.L (IS) || R1.L = W[I1++];\n\t" + "A1 += R0.H*R1.L, A0 += R0.H*R1.H (IS) || R0 = [I0++];\n\t" + "A0 = A0 >>> 6;\n\t" + "A1 = A1 >>> 6;\n\t" + "R2 = A0, R3 = A1;\n\t" + "[P1--] = r2;\n\t" + "[P1--] = r3;\n\t" + "P0 += 4;\n\t" + "LOOP_END pitch%=;\n\t" + "L0 = 0;\n\t" + : : "m" (_x), "m" (_y), "m" (corr), "m" (len), "m" (nb_pitch) + : "A0", "A1", "P0", "P1", "P2", "P3", "P4", "R0", "R1", "R2", "R3", "I0", "I1", "L0", "L1", "B0", "B1", "memory" + ); +} + +#define OVERRIDE_COMPUTE_PITCH_ERROR +static inline spx_word32_t compute_pitch_error(spx_word16_t *C, spx_word16_t *g, spx_word16_t pitch_control) +{ + spx_word32_t sum; + __asm__ __volatile__ + ( + "A0 = 0;\n\t" + + "R0 = W[%1++];\n\t" + "R1.L = %2.L*%5.L (IS);\n\t" + "A0 += R1.L*R0.L (IS) || R0 = W[%1++];\n\t" + + "R1.L = %3.L*%5.L (IS);\n\t" + "A0 += R1.L*R0.L (IS) || R0 = W[%1++];\n\t" + + "R1.L = %4.L*%5.L (IS);\n\t" + "A0 += R1.L*R0.L (IS) || R0 = W[%1++];\n\t" + + "R1.L = %2.L*%3.L (IS);\n\t" + "A0 -= R1.L*R0.L (IS) || R0 = W[%1++];\n\t" + + "R1.L = %4.L*%3.L (IS);\n\t" + "A0 -= R1.L*R0.L (IS) || R0 = W[%1++];\n\t" + + "R1.L = %4.L*%2.L (IS);\n\t" + "A0 -= R1.L*R0.L (IS) || R0 = W[%1++];\n\t" + + "R1.L = %2.L*%2.L (IS);\n\t" + "A0 -= R1.L*R0.L (IS) || R0 = W[%1++];\n\t" + + "R1.L = %3.L*%3.L (IS);\n\t" + "A0 -= R1.L*R0.L (IS) || R0 = W[%1++];\n\t" + + "R1.L = %4.L*%4.L (IS);\n\t" + "A0 -= R1.L*R0.L (IS);\n\t" + + "%0 = A0;\n\t" + : "=&D" (sum), "=a" (C) + : "d" (g[0]), "d" (g[1]), "d" (g[2]), "d" (pitch_control), "1" (C) + : "R0", "R1", "R2", "A0" + ); + return sum; +} + +#define OVERRIDE_OPEN_LOOP_NBEST_PITCH +#ifdef OVERRIDE_OPEN_LOOP_NBEST_PITCH +void open_loop_nbest_pitch(spx_word16_t *sw, int start, int end, int len, int *pitch, spx_word16_t *gain, int N, char *stack) +{ + int i,j,k; + VARDECL(spx_word32_t *best_score); + VARDECL(spx_word32_t *best_ener); + spx_word32_t e0; + VARDECL(spx_word32_t *corr); + VARDECL(spx_word32_t *energy); + + ALLOC(best_score, N, spx_word32_t); + ALLOC(best_ener, N, spx_word32_t); + ALLOC(corr, end-start+1, spx_word32_t); + ALLOC(energy, end-start+2, spx_word32_t); + + for (i=0;i>>= 6;\n\t" +" R1 = R1 + R2;\n\t" +" R0 >>>= 6;\n\t" +" R1 = R1 - R0;\n\t" +" R2 = MAX(R1,R3);\n\t" +"eu2: [P0++] = R2;\n\t" + : : "d" (energy), "d" (&sw[-start-1]), "d" (&sw[-start+len-1]), + "a" (end-start) + : "P0", "I1", "I2", "R0", "R1", "R2", "R3" +#if (__GNUC__ == 4) + , "LC1" +#endif + ); + + pitch_xcorr(sw, sw-end, corr, len, end-start+1, stack); + + /* FIXME: Fixed-point and floating-point code should be merged */ + { + VARDECL(spx_word16_t *corr16); + VARDECL(spx_word16_t *ener16); + ALLOC(corr16, end-start+1, spx_word16_t); + ALLOC(ener16, end-start+1, spx_word16_t); + /* Normalize to 180 so we can square it and it still fits in 16 bits */ + normalize16(corr, corr16, 180, end-start+1); + normalize16(energy, ener16, 180, end-start+1); + + if (N == 1) { + /* optimised asm to handle N==1 case */ + __asm__ __volatile__ + ( +" I0 = %1;\n\t" /* I0: corr16[] */ +" L0 = 0;\n\t" +" I1 = %2;\n\t" /* I1: energy */ +" L1 = 0;\n\t" +" R2 = -1;\n\t" /* R2: best score */ +" R3 = 0;\n\t" /* R3: best energy */ +" P0 = %4;\n\t" /* P0: best pitch */ +" P1 = %4;\n\t" /* P1: counter */ +" LSETUP (sl1, sl2) LC1 = %3;\n\t" +"sl1: R0.L = W [I0++] || R1.L = W [I1++];\n\t" +" R0 = R0.L * R0.L (IS);\n\t" +" R1 += 1;\n\t" +" R4 = R0.L * R3.L;\n\t" +" R5 = R2.L * R1.L;\n\t" +" cc = R5 < R4;\n\t" +" if cc R2 = R0;\n\t" +" if cc R3 = R1;\n\t" +" if cc P0 = P1;\n\t" +"sl2: P1 += 1;\n\t" +" %0 = P0;\n\t" + : "=&d" (pitch[0]) + : "a" (corr16), "a" (ener16), "a" (end+1-start), "d" (start) + : "P0", "P1", "I0", "I1", "R0", "R1", "R2", "R3", "R4", "R5" +#if (__GNUC__ == 4) + , "LC1" +#endif + ); + + } + else { + for (i=start;i<=end;i++) + { + spx_word16_t tmp = MULT16_16_16(corr16[i-start],corr16[i-start]); + /* Instead of dividing the tmp by the energy, we multiply on the other side */ + if (MULT16_16(tmp,best_ener[N-1])>MULT16_16(best_score[N-1],ADD16(1,ener16[i-start]))) + { + /* We can safely put it last and then check */ + best_score[N-1]=tmp; + best_ener[N-1]=ener16[i-start]+1; + pitch[N-1]=i; + /* Check if it comes in front of others */ + for (j=0;jMULT16_16(best_score[j],ADD16(1,ener16[i-start]))) + { + for (k=N-1;k>j;k--) + { + best_score[k]=best_score[k-1]; + best_ener[k]=best_ener[k-1]; + pitch[k]=pitch[k-1]; + } + best_score[j]=tmp; + best_ener[j]=ener16[i-start]+1; + pitch[j]=i; + break; + } + } + } + } + } + } + + /* Compute open-loop gain */ + if (gain) + { + for (j=0;jbest_sum && gain_sum<=max_gain) ------ (1) + + if (sum>best_sum && !(gain_sum>max_gain)) ------ (2) + + if (max_gain<=gain_sum) { ------ (3) + sum = -VERY_LARGE32; + } + if (best_sum<=sum) + + The blackin cc instructions are all of the form: + + cc = x < y (or cc = x <= y) +*/ +" R1 = B0\n\t" +" R2 = %5\n\t" +" R3 = %6\n\t" +" cc = R2 <= R1;\n\t" +" if cc R0 = R3;\n\t" +" cc = %0 <= R0;\n\t" +" if cc %0 = R0;\n\t" +" if cc %1 = P1;\n\t" + +"pgs2: P1 += 1;\n\t" + + : "=&d" (best_sum), "=&d" (best_cdbk) + : "a" (gain_cdbk), "a" (C16), "a" (gain_cdbk_size), "a" (max_gain), + "b" (-VERY_LARGE32) + : "R0", "R1", "R2", "R3", "R4", "P0", + "P1", "I1", "L1", "A0", "B0" +#if (__GNUC__ == 4) + , "LC1" +#endif + ); + + return best_cdbk; +} +#endif + diff --git a/lib/rbcodec/codecs/libspeex/ltp_cf.S b/lib/rbcodec/codecs/libspeex/ltp_cf.S new file mode 100644 index 0000000000..a1baed6d41 --- /dev/null +++ b/lib/rbcodec/codecs/libspeex/ltp_cf.S @@ -0,0 +1,85 @@ +/* Copyright (C) 2007 Thom Johansen */ +/** + @file ltp_cf.S + @brief Long-Term Prediction functions (Coldfire version) +*/ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + - Neither the name of the Xiph.org Foundation nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + .text +/* spx_word32_t inner_prod(const spx_word16_t *x, const spx_word16_t *y, int len) */ + .global inner_prod +inner_prod: + lea.l (-28, %sp), %sp + movem.l %d2-%d7/%a2, (%sp) + movem.l (28+4, %sp), %a0-%a1 | a0 = x, a1 = y + move.l (28+12, %sp), %d0 | d0 = len + + | We assume we're never called with a 'len' of zero + btst #2, %d0 | Check if we need to do one round of four + jeq 0f | samples before we do runs of eight + movem.l (%a0), %d1-%d2 | Fetch four samples from x + movem.l (%a1), %d3-%d4 | Fetch four samples from y + mac.w %d1u, %d3u, %acc0 + mac.w %d1l, %d3l, %acc0 + mac.w %d2u, %d4u, %acc0 + mac.w %d2l, %d4l, %acc0 + addq.l #8, %a0 + addq.l #8, %a1 + subq.l #4, %d0 + jeq .save + +0: + movem.l (%a0), %d1-%d4 | Fetch eight samples from x + movem.l (%a1), %d5-%d7/%a2 | Fetch eight samples from y + mac.w %d1u, %d5u, %acc0 + mac.w %d1l, %d5l, %acc0 + mac.w %d2u, %d6u, %acc0 + mac.w %d2l, %d6l, %acc0 + mac.w %d3u, %d7u, %acc0 + mac.w %d3l, %d7l, %acc0 + mac.w %d4u, %a2u, %acc0 + mac.w %d4l, %a2l, %acc0 + lea.l (16, %a0), %a0 + lea.l (16, %a1), %a1 + subq.l #8, %d0 + jne 0b + +.save: + move.l %accext01, %d1 | Fetch top 8 bits of answer + movclr.l %acc0, %d0 | Fetch lower 32 bits + lsr.l #6, %d0 + moveq.l #26, %d2 + asl.l %d2, %d1 + or.l %d1, %d0 | Combine (top << 26) | (lower >> 6) + + movem.l (%sp), %d2-%d7/%a2 + lea.l (28, %sp), %sp + rts + diff --git a/lib/rbcodec/codecs/libspeex/ltp_sse.h b/lib/rbcodec/codecs/libspeex/ltp_sse.h new file mode 100644 index 0000000000..bed6eaac9a --- /dev/null +++ b/lib/rbcodec/codecs/libspeex/ltp_sse.h @@ -0,0 +1,92 @@ +/* Copyright (C) 2002 Jean-Marc Valin */ +/** + @file ltp_sse.h + @brief Long-Term Prediction functions (SSE version) +*/ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + - Neither the name of the Xiph.org Foundation nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include + +#define OVERRIDE_INNER_PROD +float inner_prod(const float *a, const float *b, int len) +{ + int i; + float ret; + __m128 sum = _mm_setzero_ps(); + for (i=0;i<(len>>2);i+=2) + { + sum = _mm_add_ps(sum, _mm_mul_ps(_mm_loadu_ps(a+0), _mm_loadu_ps(b+0))); + sum = _mm_add_ps(sum, _mm_mul_ps(_mm_loadu_ps(a+4), _mm_loadu_ps(b+4))); + a += 8; + b += 8; + } + sum = _mm_add_ps(sum, _mm_movehl_ps(sum, sum)); + sum = _mm_add_ss(sum, _mm_shuffle_ps(sum, sum, 0x55)); + _mm_store_ss(&ret, sum); + return ret; +} + +#define OVERRIDE_PITCH_XCORR +void pitch_xcorr(const float *_x, const float *_y, float *corr, int len, int nb_pitch, char *stack) +{ + int i, offset; + VARDECL(__m128 *x); + VARDECL(__m128 *y); + int N, L; + N = len>>2; + L = nb_pitch>>2; + ALLOC(x, N, __m128); + ALLOC(y, N+L, __m128); + for (i=0;i=(spx_int32_t)65536) + { + x >>= 16; + r += 16; + } + if (x>=256) + { + x >>= 8; + r += 8; + } + if (x>=16) + { + x >>= 4; + r += 4; + } + if (x>=4) + { + x >>= 2; + r += 2; + } + if (x>=2) + { + r += 1; + } + return r; +} + +static inline spx_int16_t spx_ilog4(spx_uint32_t x) +{ + int r=0; + if (x>=(spx_int32_t)65536) + { + x >>= 16; + r += 8; + } + if (x>=256) + { + x >>= 8; + r += 4; + } + if (x>=16) + { + x >>= 4; + r += 2; + } + if (x>=4) + { + r += 1; + } + return r; +} + +#ifdef FIXED_POINT + +/** Generate a pseudo-random number */ +static inline spx_word16_t speex_rand(spx_word16_t std, spx_int32_t *seed) +{ + spx_word32_t res; + *seed = 1664525 * *seed + 1013904223; + res = MULT16_16(EXTRACT16(SHR32(*seed,16)),std); + return EXTRACT16(PSHR32(SUB32(res, SHR32(res, 3)),14)); +} + +/* sqrt(x) ~= 0.22178 + 1.29227*x - 0.77070*x^2 + 0.25723*x^3 (for .25 < x < 1) */ +/*#define C0 3634 +#define C1 21173 +#define C2 -12627 +#define C3 4215*/ + +/* sqrt(x) ~= 0.22178 + 1.29227*x - 0.77070*x^2 + 0.25659*x^3 (for .25 < x < 1) */ +#define C0 3634 +#define C1 21173 +#define C2 -12627 +#define C3 4204 + +static inline spx_word16_t spx_sqrt(spx_word32_t x) +{ + int k; + spx_word32_t rt; + k = spx_ilog4(x)-6; + x = VSHR32(x, (k<<1)); + rt = ADD16(C0, MULT16_16_Q14(x, ADD16(C1, MULT16_16_Q14(x, ADD16(C2, MULT16_16_Q14(x, (C3))))))); + rt = VSHR32(rt,7-k); + return rt; +} + +/* log(x) ~= -2.18151 + 4.20592*x - 2.88938*x^2 + 0.86535*x^3 (for .5 < x < 1) */ + + +#define A1 16469 +#define A2 2242 +#define A3 1486 + +static inline spx_word16_t spx_acos(spx_word16_t x) +{ + int s=0; + spx_word16_t ret; + spx_word16_t sq; + if (x<0) + { + s=1; + x = NEG16(x); + } + x = SUB16(16384,x); + + x = x >> 1; + sq = MULT16_16_Q13(x, ADD16(A1, MULT16_16_Q13(x, ADD16(A2, MULT16_16_Q13(x, (A3)))))); + ret = spx_sqrt(SHL32(EXTEND32(sq),13)); + + /*ret = spx_sqrt(67108864*(-1.6129e-04 + 2.0104e+00*f + 2.7373e-01*f*f + 1.8136e-01*f*f*f));*/ + if (s) + ret = SUB16(25736,ret); + return ret; +} + + +#define K1 8192 +#define K2 -4096 +#define K3 340 +#define K4 -10 + +static inline spx_word16_t spx_cos(spx_word16_t x) +{ + spx_word16_t x2; + + if (x<12868) + { + x2 = MULT16_16_P13(x,x); + return ADD32(K1, MULT16_16_P13(x2, ADD32(K2, MULT16_16_P13(x2, ADD32(K3, MULT16_16_P13(K4, x2)))))); + } else { + x = SUB16(25736,x); + x2 = MULT16_16_P13(x,x); + return SUB32(-K1, MULT16_16_P13(x2, ADD32(K2, MULT16_16_P13(x2, ADD32(K3, MULT16_16_P13(K4, x2)))))); + } +} + +#define L1 32767 +#define L2 -7651 +#define L3 8277 +#define L4 -626 + +static inline spx_word16_t _spx_cos_pi_2(spx_word16_t x) +{ + spx_word16_t x2; + + x2 = MULT16_16_P15(x,x); + return ADD16(1,MIN16(32766,ADD32(SUB16(L1,x2), MULT16_16_P15(x2, ADD32(L2, MULT16_16_P15(x2, ADD32(L3, MULT16_16_P15(L4, x2)))))))); +} + +static inline spx_word16_t spx_cos_norm(spx_word32_t x) +{ + x = x&0x0001ffff; + if (x>SHL32(EXTEND32(1), 16)) + x = SUB32(SHL32(EXTEND32(1), 17),x); + if (x&0x00007fff) + { + if (x14) + return 0x7fffffff; + else if (integer < -15) + return 0; + frac = SHL16(x-SHL16(integer,11),3); + frac = ADD16(D0, MULT16_16_Q14(frac, ADD16(D1, MULT16_16_Q14(frac, ADD16(D2 , MULT16_16_Q14(D3,frac)))))); + return VSHR32(EXTEND32(frac), -integer-2); +} + +/* Input in Q11 format, output in Q16 */ +static inline spx_word32_t spx_exp(spx_word16_t x) +{ + if (x>21290) + return 0x7fffffff; + else if (x<-21290) + return 0; + else + return spx_exp2(MULT16_16_P14(23637,x)); +} +#define M1 32767 +#define M2 -21 +#define M3 -11943 +#define M4 4936 + +static inline spx_word16_t spx_atan01(spx_word16_t x) +{ + return MULT16_16_P15(x, ADD32(M1, MULT16_16_P15(x, ADD32(M2, MULT16_16_P15(x, ADD32(M3, MULT16_16_P15(M4, x))))))); +} + +#undef M1 +#undef M2 +#undef M3 +#undef M4 + +/* Input in Q15, output in Q14 */ +static inline spx_word16_t spx_atan(spx_word32_t x) +{ + if (x <= 32767) + { + return SHR16(spx_atan01(x),1); + } else { + int e = spx_ilog2(x); + if (e>=29) + return 25736; + x = DIV32_16(SHL32(EXTEND32(32767),29-e), EXTRACT16(SHR32(x, e-14))); + return SUB16(25736, SHR16(spx_atan01(x),1)); + } +} +#else + +#ifndef M_PI +#define M_PI 3.14159265358979323846 /* pi */ +#endif + +#define C1 0.9999932946f +#define C2 -0.4999124376f +#define C3 0.0414877472f +#define C4 -0.0012712095f + + +#define SPX_PI_2 1.5707963268 +static inline spx_word16_t spx_cos(spx_word16_t x) +{ + if (x>16) + +#else + +static const spx_float_t MIN_LEAK = .005f; + +/* Constants for the two-path filter */ +static const spx_float_t VAR1_SMOOTH = .36f; +static const spx_float_t VAR2_SMOOTH = .7225f; +static const spx_float_t VAR1_UPDATE = .5f; +static const spx_float_t VAR2_UPDATE = .25f; +static const spx_float_t VAR_BACKTRACK = 4.f; +#define TOP16(x) (x) +#endif + + +#define PLAYBACK_DELAY 2 + +void speex_echo_get_residual(SpeexEchoState *st, spx_word32_t *Yout, int len); + + +/** Speex echo cancellation state. */ +struct SpeexEchoState_ { + int frame_size; /**< Number of samples processed each time */ + int window_size; + int M; + int cancel_count; + int adapted; + int saturated; + int screwed_up; + spx_int32_t sampling_rate; + spx_word16_t spec_average; + spx_word16_t beta0; + spx_word16_t beta_max; + spx_word32_t sum_adapt; + spx_word16_t leak_estimate; + + spx_word16_t *e; /* scratch */ + spx_word16_t *x; /* Far-end input buffer (2N) */ + spx_word16_t *X; /* Far-end buffer (M+1 frames) in frequency domain */ + spx_word16_t *input; /* scratch */ + spx_word16_t *y; /* scratch */ + spx_word16_t *last_y; + spx_word16_t *Y; /* scratch */ + spx_word16_t *E; + spx_word32_t *PHI; /* scratch */ + spx_word32_t *W; /* (Background) filter weights */ +#ifdef TWO_PATH + spx_word16_t *foreground; /* Foreground filter weights */ + spx_word32_t Davg1; /* 1st recursive average of the residual power difference */ + spx_word32_t Davg2; /* 2nd recursive average of the residual power difference */ + spx_float_t Dvar1; /* Estimated variance of 1st estimator */ + spx_float_t Dvar2; /* Estimated variance of 2nd estimator */ +#endif + spx_word32_t *power; /* Power of the far-end signal */ + spx_float_t *power_1;/* Inverse power of far-end */ + spx_word16_t *wtmp; /* scratch */ +#ifdef FIXED_POINT + spx_word16_t *wtmp2; /* scratch */ +#endif + spx_word32_t *Rf; /* scratch */ + spx_word32_t *Yf; /* scratch */ + spx_word32_t *Xf; /* scratch */ + spx_word32_t *Eh; + spx_word32_t *Yh; + spx_float_t Pey; + spx_float_t Pyy; + spx_word16_t *window; + spx_word16_t *prop; + void *fft_table; + spx_word16_t memX, memD, memE; + spx_word16_t preemph; + spx_word16_t notch_radius; + spx_mem_t notch_mem[2]; + + /* NOTE: If you only use speex_echo_cancel() and want to save some memory, remove this */ + spx_int16_t *play_buf; + int play_buf_pos; + int play_buf_started; +}; + +static inline void filter_dc_notch16(const spx_int16_t *in, spx_word16_t radius, spx_word16_t *out, int len, spx_mem_t *mem) +{ + int i; + spx_word16_t den2; +#ifdef FIXED_POINT + den2 = MULT16_16_Q15(radius,radius) + MULT16_16_Q15(QCONST16(.7,15),MULT16_16_Q15(32767-radius,32767-radius)); +#else + den2 = radius*radius + .7*(1-radius)*(1-radius); +#endif + /*printf ("%d %d %d %d %d %d\n", num[0], num[1], num[2], den[0], den[1], den[2]);*/ + for (i=0;i>= 1; + while(len--) + { + spx_word32_t part=0; + part = MAC16_16(part,*x++,*y++); + part = MAC16_16(part,*x++,*y++); + /* HINT: If you had a 40-bit accumulator, you could shift only at the end */ + sum = ADD32(sum,SHR32(part,6)); + } + return sum; +} + +/** Compute power spectrum of a half-complex (packed) vector */ +static inline void power_spectrum(const spx_word16_t *X, spx_word32_t *ps, int N) +{ + int i, j; + ps[0]=MULT16_16(X[0],X[0]); + for (i=1,j=1;i max_sum) + max_sum = prop[i]; + } + for (i=0;i +static FILE *rFile=NULL, *pFile=NULL, *oFile=NULL; + +static void dump_audio(const spx_int16_t *rec, const spx_int16_t *play, const spx_int16_t *out, int len) +{ + if (!(rFile && pFile && oFile)) + { + speex_fatal("Dump files not open"); + } + fwrite(rec, sizeof(spx_int16_t), len, rFile); + fwrite(play, sizeof(spx_int16_t), len, pFile); + fwrite(out, sizeof(spx_int16_t), len, oFile); +} +#endif + +/** Creates a new echo canceller state */ +SpeexEchoState *speex_echo_state_init(int frame_size, int filter_length) +{ + int i,N,M; + SpeexEchoState *st = (SpeexEchoState *)speex_alloc(sizeof(SpeexEchoState)); + +#ifdef DUMP_ECHO_CANCEL_DATA + if (rFile || pFile || oFile) + speex_fatal("Opening dump files twice"); + rFile = fopen("aec_rec.sw", "wb"); + pFile = fopen("aec_play.sw", "wb"); + oFile = fopen("aec_out.sw", "wb"); +#endif + + st->frame_size = frame_size; + st->window_size = 2*frame_size; + N = st->window_size; + M = st->M = (filter_length+st->frame_size-1)/frame_size; + st->cancel_count=0; + st->sum_adapt = 0; + st->saturated = 0; + st->screwed_up = 0; + /* This is the default sampling rate */ + st->sampling_rate = 8000; + st->spec_average = DIV32_16(SHL32(EXTEND32(st->frame_size), 15), st->sampling_rate); +#ifdef FIXED_POINT + st->beta0 = DIV32_16(SHL32(EXTEND32(st->frame_size), 16), st->sampling_rate); + st->beta_max = DIV32_16(SHL32(EXTEND32(st->frame_size), 14), st->sampling_rate); +#else + st->beta0 = (2.0f*st->frame_size)/st->sampling_rate; + st->beta_max = (.5f*st->frame_size)/st->sampling_rate; +#endif + st->leak_estimate = 0; + + st->fft_table = spx_fft_init(N); + + st->e = (spx_word16_t*)speex_alloc(N*sizeof(spx_word16_t)); + st->x = (spx_word16_t*)speex_alloc(N*sizeof(spx_word16_t)); + st->input = (spx_word16_t*)speex_alloc(st->frame_size*sizeof(spx_word16_t)); + st->y = (spx_word16_t*)speex_alloc(N*sizeof(spx_word16_t)); + st->last_y = (spx_word16_t*)speex_alloc(N*sizeof(spx_word16_t)); + st->Yf = (spx_word32_t*)speex_alloc((st->frame_size+1)*sizeof(spx_word32_t)); + st->Rf = (spx_word32_t*)speex_alloc((st->frame_size+1)*sizeof(spx_word32_t)); + st->Xf = (spx_word32_t*)speex_alloc((st->frame_size+1)*sizeof(spx_word32_t)); + st->Yh = (spx_word32_t*)speex_alloc((st->frame_size+1)*sizeof(spx_word32_t)); + st->Eh = (spx_word32_t*)speex_alloc((st->frame_size+1)*sizeof(spx_word32_t)); + + st->X = (spx_word16_t*)speex_alloc((M+1)*N*sizeof(spx_word16_t)); + st->Y = (spx_word16_t*)speex_alloc(N*sizeof(spx_word16_t)); + st->E = (spx_word16_t*)speex_alloc(N*sizeof(spx_word16_t)); + st->W = (spx_word32_t*)speex_alloc(M*N*sizeof(spx_word32_t)); +#ifdef TWO_PATH + st->foreground = (spx_word16_t*)speex_alloc(M*N*sizeof(spx_word16_t)); +#endif + st->PHI = (spx_word32_t*)speex_alloc(N*sizeof(spx_word32_t)); + st->power = (spx_word32_t*)speex_alloc((frame_size+1)*sizeof(spx_word32_t)); + st->power_1 = (spx_float_t*)speex_alloc((frame_size+1)*sizeof(spx_float_t)); + st->window = (spx_word16_t*)speex_alloc(N*sizeof(spx_word16_t)); + st->prop = (spx_word16_t*)speex_alloc(M*sizeof(spx_word16_t)); + st->wtmp = (spx_word16_t*)speex_alloc(N*sizeof(spx_word16_t)); +#ifdef FIXED_POINT + st->wtmp2 = (spx_word16_t*)speex_alloc(N*sizeof(spx_word16_t)); + for (i=0;i>1;i++) + { + st->window[i] = (16383-SHL16(spx_cos(DIV32_16(MULT16_16(25736,i<<1),N)),1)); + st->window[N-i-1] = st->window[i]; + } +#else + for (i=0;iwindow[i] = .5-.5*cos(2*M_PI*i/N); +#endif + for (i=0;i<=st->frame_size;i++) + st->power_1[i] = FLOAT_ONE; + for (i=0;iW[i] = 0; + { + spx_word32_t sum = 0; + /* Ratio of ~10 between adaptation rate of first and last block */ + spx_word16_t decay = SHR32(spx_exp(NEG16(DIV32_16(QCONST16(2.4,11),M))),1); + st->prop[0] = QCONST16(.7, 15); + sum = EXTEND32(st->prop[0]); + for (i=1;iprop[i] = MULT16_16_Q15(st->prop[i-1], decay); + sum = ADD32(sum, EXTEND32(st->prop[i])); + } + for (i=M-1;i>=0;i--) + { + st->prop[i] = DIV32(MULT16_16(QCONST16(.8,15), st->prop[i]),sum); + } + } + + st->memX=st->memD=st->memE=0; + st->preemph = QCONST16(.9,15); + if (st->sampling_rate<12000) + st->notch_radius = QCONST16(.9, 15); + else if (st->sampling_rate<24000) + st->notch_radius = QCONST16(.982, 15); + else + st->notch_radius = QCONST16(.992, 15); + + st->notch_mem[0] = st->notch_mem[1] = 0; + st->adapted = 0; + st->Pey = st->Pyy = FLOAT_ONE; + +#ifdef TWO_PATH + st->Davg1 = st->Davg2 = 0; + st->Dvar1 = st->Dvar2 = FLOAT_ZERO; +#endif + + st->play_buf = (spx_int16_t*)speex_alloc((PLAYBACK_DELAY+1)*st->frame_size*sizeof(spx_int16_t)); + st->play_buf_pos = PLAYBACK_DELAY*st->frame_size; + st->play_buf_started = 0; + + return st; +} + +/** Resets echo canceller state */ +void speex_echo_state_reset(SpeexEchoState *st) +{ + int i, M, N; + st->cancel_count=0; + st->screwed_up = 0; + N = st->window_size; + M = st->M; + for (i=0;iW[i] = 0; +#ifdef TWO_PATH + for (i=0;iforeground[i] = 0; +#endif + for (i=0;iX[i] = 0; + for (i=0;i<=st->frame_size;i++) + { + st->power[i] = 0; + st->power_1[i] = FLOAT_ONE; + st->Eh[i] = 0; + st->Yh[i] = 0; + } + for (i=0;iframe_size;i++) + { + st->last_y[i] = 0; + } + for (i=0;iE[i] = 0; + st->x[i] = 0; + } + st->notch_mem[0] = st->notch_mem[1] = 0; + st->memX=st->memD=st->memE=0; + + st->saturated = 0; + st->adapted = 0; + st->sum_adapt = 0; + st->Pey = st->Pyy = FLOAT_ONE; +#ifdef TWO_PATH + st->Davg1 = st->Davg2 = 0; + st->Dvar1 = st->Dvar2 = FLOAT_ZERO; +#endif + for (i=0;i<3*st->frame_size;i++) + st->play_buf[i] = 0; + st->play_buf_pos = PLAYBACK_DELAY*st->frame_size; + st->play_buf_started = 0; + +} + +/** Destroys an echo canceller state */ +void speex_echo_state_destroy(SpeexEchoState *st) +{ + spx_fft_destroy(st->fft_table); + + speex_free(st->e); + speex_free(st->x); + speex_free(st->input); + speex_free(st->y); + speex_free(st->last_y); + speex_free(st->Yf); + speex_free(st->Rf); + speex_free(st->Xf); + speex_free(st->Yh); + speex_free(st->Eh); + + speex_free(st->X); + speex_free(st->Y); + speex_free(st->E); + speex_free(st->W); +#ifdef TWO_PATH + speex_free(st->foreground); +#endif + speex_free(st->PHI); + speex_free(st->power); + speex_free(st->power_1); + speex_free(st->window); + speex_free(st->prop); + speex_free(st->wtmp); +#ifdef FIXED_POINT + speex_free(st->wtmp2); +#endif + speex_free(st->play_buf); + speex_free(st); + +#ifdef DUMP_ECHO_CANCEL_DATA + fclose(rFile); + fclose(pFile); + fclose(oFile); + rFile = pFile = oFile = NULL; +#endif +} + +void speex_echo_capture(SpeexEchoState *st, const spx_int16_t *rec, spx_int16_t *out) +{ + int i; + /*speex_warning_int("capture with fill level ", st->play_buf_pos/st->frame_size);*/ + st->play_buf_started = 1; + if (st->play_buf_pos>=st->frame_size) + { + speex_echo_cancellation(st, rec, st->play_buf, out); + st->play_buf_pos -= st->frame_size; + for (i=0;iplay_buf_pos;i++) + st->play_buf[i] = st->play_buf[i+st->frame_size]; + } else { + speex_warning("No playback frame available (your application is buggy and/or got xruns)"); + if (st->play_buf_pos!=0) + { + speex_warning("internal playback buffer corruption?"); + st->play_buf_pos = 0; + } + for (i=0;iframe_size;i++) + out[i] = rec[i]; + } +} + +void speex_echo_playback(SpeexEchoState *st, const spx_int16_t *play) +{ + /*speex_warning_int("playback with fill level ", st->play_buf_pos/st->frame_size);*/ + if (!st->play_buf_started) + { + speex_warning("discarded first playback frame"); + return; + } + if (st->play_buf_pos<=PLAYBACK_DELAY*st->frame_size) + { + int i; + for (i=0;iframe_size;i++) + st->play_buf[st->play_buf_pos+i] = play[i]; + st->play_buf_pos += st->frame_size; + if (st->play_buf_pos <= (PLAYBACK_DELAY-1)*st->frame_size) + { + speex_warning("Auto-filling the buffer (your application is buggy and/or got xruns)"); + for (i=0;iframe_size;i++) + st->play_buf[st->play_buf_pos+i] = play[i]; + st->play_buf_pos += st->frame_size; + } + } else { + speex_warning("Had to discard a playback frame (your application is buggy and/or got xruns)"); + } +} + +/** Performs echo cancellation on a frame (deprecated, last arg now ignored) */ +void speex_echo_cancel(SpeexEchoState *st, const spx_int16_t *in, const spx_int16_t *far_end, spx_int16_t *out, spx_int32_t *Yout) +{ + speex_echo_cancellation(st, in, far_end, out); +} + +/** Performs echo cancellation on a frame */ +void speex_echo_cancellation(SpeexEchoState *st, const spx_int16_t *in, const spx_int16_t *far_end, spx_int16_t *out) +{ + int i,j; + int N,M; + spx_word32_t Syy,See,Sxx,Sdd, Sff; +#ifdef TWO_PATH + spx_word32_t Dbf; + int update_foreground; +#endif + spx_word32_t Sey; + spx_word16_t ss, ss_1; + spx_float_t Pey = FLOAT_ONE, Pyy=FLOAT_ONE; + spx_float_t alpha, alpha_1; + spx_word16_t RER; + spx_word32_t tmp32; + + N = st->window_size; + M = st->M; + st->cancel_count++; +#ifdef FIXED_POINT + ss=DIV32_16(11469,M); + ss_1 = SUB16(32767,ss); +#else + ss=.35/M; + ss_1 = 1-ss; +#endif + + /* Apply a notch filter to make sure DC doesn't end up causing problems */ + filter_dc_notch16(in, st->notch_radius, st->input, st->frame_size, st->notch_mem); + /* Copy input data to buffer and apply pre-emphasis */ + for (i=0;iframe_size;i++) + { + spx_word32_t tmp32; + tmp32 = SUB32(EXTEND32(far_end[i]), EXTEND32(MULT16_16_P15(st->preemph, st->memX))); +#ifdef FIXED_POINT + /* If saturation occurs here, we need to freeze adaptation for M+1 frames (not just one) */ + if (tmp32 > 32767) + { + tmp32 = 32767; + st->saturated = M+1; + } + if (tmp32 < -32767) + { + tmp32 = -32767; + st->saturated = M+1; + } +#endif + st->x[i+st->frame_size] = EXTRACT16(tmp32); + st->memX = far_end[i]; + + tmp32 = SUB32(EXTEND32(st->input[i]), EXTEND32(MULT16_16_P15(st->preemph, st->memD))); +#ifdef FIXED_POINT + if (tmp32 > 32767) + { + tmp32 = 32767; + if (st->saturated == 0) + st->saturated = 1; + } + if (tmp32 < -32767) + { + tmp32 = -32767; + if (st->saturated == 0) + st->saturated = 1; + } +#endif + st->memD = st->input[i]; + st->input[i] = tmp32; + } + + /* Shift memory: this could be optimized eventually*/ + for (j=M-1;j>=0;j--) + { + for (i=0;iX[(j+1)*N+i] = st->X[j*N+i]; + } + + /* Convert x (far end) to frequency domain */ + spx_fft(st->fft_table, st->x, &st->X[0]); + for (i=0;ilast_y[i] = st->x[i]; + Sxx = mdf_inner_prod(st->x+st->frame_size, st->x+st->frame_size, st->frame_size); + for (i=0;iframe_size;i++) + st->x[i] = st->x[i+st->frame_size]; + /* From here on, the top part of x is used as scratch space */ + +#ifdef TWO_PATH + /* Compute foreground filter */ + spectral_mul_accum16(st->X, st->foreground, st->Y, N, M); + spx_ifft(st->fft_table, st->Y, st->e); + for (i=0;iframe_size;i++) + st->e[i] = SUB16(st->input[i], st->e[i+st->frame_size]); + Sff = mdf_inner_prod(st->e, st->e, st->frame_size); +#endif + + /* Adjust proportional adaption rate */ + mdf_adjust_prop (st->W, N, M, st->prop); + /* Compute weight gradient */ + if (st->saturated == 0) + { + for (j=M-1;j>=0;j--) + { + weighted_spectral_mul_conj(st->power_1, FLOAT_SHL(PSEUDOFLOAT(st->prop[j]),-15), &st->X[(j+1)*N], st->E, st->PHI, N); + for (i=0;iW[j*N+i] = ADD32(st->W[j*N+i], st->PHI[i]); + + } + } else { + st->saturated--; + } + + /* Update weight to prevent circular convolution (MDF / AUMDF) */ + for (j=0;jcancel_count%(M-1) == j-1) + { +#ifdef FIXED_POINT + for (i=0;iwtmp2[i] = EXTRACT16(PSHR32(st->W[j*N+i],NORMALIZE_SCALEDOWN+16)); + spx_ifft(st->fft_table, st->wtmp2, st->wtmp); + for (i=0;iframe_size;i++) + { + st->wtmp[i]=0; + } + for (i=st->frame_size;iwtmp[i]=SHL16(st->wtmp[i],NORMALIZE_SCALEUP); + } + spx_fft(st->fft_table, st->wtmp, st->wtmp2); + /* The "-1" in the shift is a sort of kludge that trades less efficient update speed for decrease noise */ + for (i=0;iW[j*N+i] -= SHL32(EXTEND32(st->wtmp2[i]),16+NORMALIZE_SCALEDOWN-NORMALIZE_SCALEUP-1); +#else + spx_ifft(st->fft_table, &st->W[j*N], st->wtmp); + for (i=st->frame_size;iwtmp[i]=0; + } + spx_fft(st->fft_table, st->wtmp, &st->W[j*N]); +#endif + } + } + + /* Compute filter response Y */ + spectral_mul_accum(st->X, st->W, st->Y, N, M); + spx_ifft(st->fft_table, st->Y, st->y); + +#ifdef TWO_PATH + /* Difference in response, this is used to estimate the variance of our residual power estimate */ + for (i=0;iframe_size;i++) + st->e[i] = SUB16(st->e[i+st->frame_size], st->y[i+st->frame_size]); + Dbf = 10+mdf_inner_prod(st->e, st->e, st->frame_size); +#endif + + for (i=0;iframe_size;i++) + st->e[i] = SUB16(st->input[i], st->y[i+st->frame_size]); + See = mdf_inner_prod(st->e, st->e, st->frame_size); +#ifndef TWO_PATH + Sff = See; +#endif + +#ifdef TWO_PATH + /* Logic for updating the foreground filter */ + + /* For two time windows, compute the mean of the energy difference, as well as the variance */ + st->Davg1 = ADD32(MULT16_32_Q15(QCONST16(.6f,15),st->Davg1), MULT16_32_Q15(QCONST16(.4f,15),SUB32(Sff,See))); + st->Davg2 = ADD32(MULT16_32_Q15(QCONST16(.85f,15),st->Davg2), MULT16_32_Q15(QCONST16(.15f,15),SUB32(Sff,See))); + st->Dvar1 = FLOAT_ADD(FLOAT_MULT(VAR1_SMOOTH, st->Dvar1), FLOAT_MUL32U(MULT16_32_Q15(QCONST16(.4f,15),Sff), MULT16_32_Q15(QCONST16(.4f,15),Dbf))); + st->Dvar2 = FLOAT_ADD(FLOAT_MULT(VAR2_SMOOTH, st->Dvar2), FLOAT_MUL32U(MULT16_32_Q15(QCONST16(.15f,15),Sff), MULT16_32_Q15(QCONST16(.15f,15),Dbf))); + + /* Equivalent float code: + st->Davg1 = .6*st->Davg1 + .4*(Sff-See); + st->Davg2 = .85*st->Davg2 + .15*(Sff-See); + st->Dvar1 = .36*st->Dvar1 + .16*Sff*Dbf; + st->Dvar2 = .7225*st->Dvar2 + .0225*Sff*Dbf; + */ + + update_foreground = 0; + /* Check if we have a statistically significant reduction in the residual echo */ + /* Note that this is *not* Gaussian, so we need to be careful about the longer tail */ + if (FLOAT_GT(FLOAT_MUL32U(SUB32(Sff,See),ABS32(SUB32(Sff,See))), FLOAT_MUL32U(Sff,Dbf))) + update_foreground = 1; + else if (FLOAT_GT(FLOAT_MUL32U(st->Davg1, ABS32(st->Davg1)), FLOAT_MULT(VAR1_UPDATE,(st->Dvar1)))) + update_foreground = 1; + else if (FLOAT_GT(FLOAT_MUL32U(st->Davg2, ABS32(st->Davg2)), FLOAT_MULT(VAR2_UPDATE,(st->Dvar2)))) + update_foreground = 1; + + /* Do we update? */ + if (update_foreground) + { + st->Davg1 = st->Davg2 = 0; + st->Dvar1 = st->Dvar2 = FLOAT_ZERO; + /* Copy background filter to foreground filter */ + for (i=0;iforeground[i] = EXTRACT16(PSHR32(st->W[i],16)); + /* Apply a smooth transition so as to not introduce blocking artifacts */ + for (i=0;iframe_size;i++) + st->e[i+st->frame_size] = MULT16_16_Q15(st->window[i+st->frame_size],st->e[i+st->frame_size]) + MULT16_16_Q15(st->window[i],st->y[i+st->frame_size]); + } else { + int reset_background=0; + /* Otherwise, check if the background filter is significantly worse */ + if (FLOAT_GT(FLOAT_MUL32U(NEG32(SUB32(Sff,See)),ABS32(SUB32(Sff,See))), FLOAT_MULT(VAR_BACKTRACK,FLOAT_MUL32U(Sff,Dbf)))) + reset_background = 1; + if (FLOAT_GT(FLOAT_MUL32U(NEG32(st->Davg1), ABS32(st->Davg1)), FLOAT_MULT(VAR_BACKTRACK,st->Dvar1))) + reset_background = 1; + if (FLOAT_GT(FLOAT_MUL32U(NEG32(st->Davg2), ABS32(st->Davg2)), FLOAT_MULT(VAR_BACKTRACK,st->Dvar2))) + reset_background = 1; + if (reset_background) + { + /* Copy foreground filter to background filter */ + for (i=0;iW[i] = SHL32(EXTEND32(st->foreground[i]),16); + /* We also need to copy the output so as to get correct adaptation */ + for (i=0;iframe_size;i++) + st->y[i+st->frame_size] = st->e[i+st->frame_size]; + for (i=0;iframe_size;i++) + st->e[i] = SUB16(st->input[i], st->y[i+st->frame_size]); + See = Sff; + st->Davg1 = st->Davg2 = 0; + st->Dvar1 = st->Dvar2 = FLOAT_ZERO; + } + } +#endif + + /* Compute error signal (for the output with de-emphasis) */ + for (i=0;iframe_size;i++) + { + spx_word32_t tmp_out; +#ifdef TWO_PATH + tmp_out = SUB32(EXTEND32(st->input[i]), EXTEND32(st->e[i+st->frame_size])); +#else + tmp_out = SUB32(EXTEND32(st->input[i]), EXTEND32(st->y[i+st->frame_size])); +#endif + /* Saturation */ + if (tmp_out>32767) + tmp_out = 32767; + else if (tmp_out<-32768) + tmp_out = -32768; + tmp_out = ADD32(tmp_out, EXTEND32(MULT16_16_P15(st->preemph, st->memE))); + /* This is an arbitrary test for saturation in the microphone signal */ + if (in[i] <= -32000 || in[i] >= 32000) + { + tmp_out = 0; + if (st->saturated == 0) + st->saturated = 1; + } + out[i] = (spx_int16_t)tmp_out; + st->memE = tmp_out; + } + +#ifdef DUMP_ECHO_CANCEL_DATA + dump_audio(in, far_end, out, st->frame_size); +#endif + + /* Compute error signal (filter update version) */ + for (i=0;iframe_size;i++) + { + st->e[i+st->frame_size] = st->e[i]; + st->e[i] = 0; + } + + /* Compute a bunch of correlations */ + Sey = mdf_inner_prod(st->e+st->frame_size, st->y+st->frame_size, st->frame_size); + Syy = mdf_inner_prod(st->y+st->frame_size, st->y+st->frame_size, st->frame_size); + Sdd = mdf_inner_prod(st->input, st->input, st->frame_size); + + /*printf ("%f %f %f %f\n", Sff, See, Syy, Sdd, st->update_cond);*/ + + /* Do some sanity check */ + if (!(Syy>=0 && Sxx>=0 && See >= 0) +#ifndef FIXED_POINT + || !(Sff < N*1e9 && Syy < N*1e9 && Sxx < N*1e9) +#endif + ) + { + /* Things have gone really bad */ + st->screwed_up += 50; + for (i=0;iframe_size;i++) + out[i] = 0; + } else if (SHR32(Sff, 2) > ADD32(Sdd, SHR32(MULT16_16(N, 10000),6))) + { + /* AEC seems to add lots of echo instead of removing it, let's see if it will improve */ + st->screwed_up++; + } else { + /* Everything's fine */ + st->screwed_up=0; + } + if (st->screwed_up>=50) + { + speex_warning("The echo canceller started acting funny and got slapped (reset). It swears it will behave now."); + speex_echo_state_reset(st); + return; + } + + /* Add a small noise floor to make sure not to have problems when dividing */ + See = MAX32(See, SHR32(MULT16_16(N, 100),6)); + + /* Convert error to frequency domain */ + spx_fft(st->fft_table, st->e, st->E); + for (i=0;iframe_size;i++) + st->y[i] = 0; + spx_fft(st->fft_table, st->y, st->Y); + + /* Compute power spectrum of far end (X), error (E) and filter response (Y) */ + power_spectrum(st->E, st->Rf, N); + power_spectrum(st->Y, st->Yf, N); + power_spectrum(st->X, st->Xf, N); + + /* Smooth far end energy estimate over time */ + for (j=0;j<=st->frame_size;j++) + st->power[j] = MULT16_32_Q15(ss_1,st->power[j]) + 1 + MULT16_32_Q15(ss,st->Xf[j]); + + /* Enable this to compute the power based only on the tail (would need to compute more + efficiently to make this really useful */ + if (0) + { + float scale2 = .5f/M; + for (j=0;j<=st->frame_size;j++) + st->power[j] = 100; + for (i=0;iX[i*N], st->Xf, N); + for (j=0;j<=st->frame_size;j++) + st->power[j] += scale2*st->Xf[j]; + } + } + + /* Compute filtered spectra and (cross-)correlations */ + for (j=st->frame_size;j>=0;j--) + { + spx_float_t Eh, Yh; + Eh = PSEUDOFLOAT(st->Rf[j] - st->Eh[j]); + Yh = PSEUDOFLOAT(st->Yf[j] - st->Yh[j]); + Pey = FLOAT_ADD(Pey,FLOAT_MULT(Eh,Yh)); + Pyy = FLOAT_ADD(Pyy,FLOAT_MULT(Yh,Yh)); +#ifdef FIXED_POINT + st->Eh[j] = MAC16_32_Q15(MULT16_32_Q15(SUB16(32767,st->spec_average),st->Eh[j]), st->spec_average, st->Rf[j]); + st->Yh[j] = MAC16_32_Q15(MULT16_32_Q15(SUB16(32767,st->spec_average),st->Yh[j]), st->spec_average, st->Yf[j]); +#else + st->Eh[j] = (1-st->spec_average)*st->Eh[j] + st->spec_average*st->Rf[j]; + st->Yh[j] = (1-st->spec_average)*st->Yh[j] + st->spec_average*st->Yf[j]; +#endif + } + + Pyy = FLOAT_SQRT(Pyy); + Pey = FLOAT_DIVU(Pey,Pyy); + + /* Compute correlation updatete rate */ + tmp32 = MULT16_32_Q15(st->beta0,Syy); + if (tmp32 > MULT16_32_Q15(st->beta_max,See)) + tmp32 = MULT16_32_Q15(st->beta_max,See); + alpha = FLOAT_DIV32(tmp32, See); + alpha_1 = FLOAT_SUB(FLOAT_ONE, alpha); + /* Update correlations (recursive average) */ + st->Pey = FLOAT_ADD(FLOAT_MULT(alpha_1,st->Pey) , FLOAT_MULT(alpha,Pey)); + st->Pyy = FLOAT_ADD(FLOAT_MULT(alpha_1,st->Pyy) , FLOAT_MULT(alpha,Pyy)); + if (FLOAT_LT(st->Pyy, FLOAT_ONE)) + st->Pyy = FLOAT_ONE; + /* We don't really hope to get better than 33 dB (MIN_LEAK-3dB) attenuation anyway */ + if (FLOAT_LT(st->Pey, FLOAT_MULT(MIN_LEAK,st->Pyy))) + st->Pey = FLOAT_MULT(MIN_LEAK,st->Pyy); + if (FLOAT_GT(st->Pey, st->Pyy)) + st->Pey = st->Pyy; + /* leak_estimate is the linear regression result */ + st->leak_estimate = FLOAT_EXTRACT16(FLOAT_SHL(FLOAT_DIVU(st->Pey, st->Pyy),14)); + /* This looks like a stupid bug, but it's right (because we convert from Q14 to Q15) */ + if (st->leak_estimate > 16383) + st->leak_estimate = 32767; + else + st->leak_estimate = SHL16(st->leak_estimate,1); + /*printf ("%f\n", st->leak_estimate);*/ + + /* Compute Residual to Error Ratio */ +#ifdef FIXED_POINT + tmp32 = MULT16_32_Q15(st->leak_estimate,Syy); + tmp32 = ADD32(SHR32(Sxx,13), ADD32(tmp32, SHL32(tmp32,1))); + /* Check for y in e (lower bound on RER) */ + { + spx_float_t bound = PSEUDOFLOAT(Sey); + bound = FLOAT_DIVU(FLOAT_MULT(bound, bound), PSEUDOFLOAT(ADD32(1,Syy))); + if (FLOAT_GT(bound, PSEUDOFLOAT(See))) + tmp32 = See; + else if (tmp32 < FLOAT_EXTRACT32(bound)) + tmp32 = FLOAT_EXTRACT32(bound); + } + if (tmp32 > SHR32(See,1)) + tmp32 = SHR32(See,1); + RER = FLOAT_EXTRACT16(FLOAT_SHL(FLOAT_DIV32(tmp32,See),15)); +#else + RER = (.0001*Sxx + 3.*MULT16_32_Q15(st->leak_estimate,Syy)) / See; + /* Check for y in e (lower bound on RER) */ + if (RER < Sey*Sey/(1+See*Syy)) + RER = Sey*Sey/(1+See*Syy); + if (RER > .5) + RER = .5; +#endif + + /* We consider that the filter has had minimal adaptation if the following is true*/ + if (!st->adapted && st->sum_adapt > SHL32(EXTEND32(M),15) && MULT16_32_Q15(st->leak_estimate,Syy) > MULT16_32_Q15(QCONST16(.03f,15),Syy)) + { + st->adapted = 1; + } + + if (st->adapted) + { + /* Normal learning rate calculation once we're past the minimal adaptation phase */ + for (i=0;i<=st->frame_size;i++) + { + spx_word32_t r, e; + /* Compute frequency-domain adaptation mask */ + r = MULT16_32_Q15(st->leak_estimate,SHL32(st->Yf[i],3)); + e = SHL32(st->Rf[i],3)+1; +#ifdef FIXED_POINT + if (r>SHR32(e,1)) + r = SHR32(e,1); +#else + if (r>.5*e) + r = .5*e; +#endif + r = MULT16_32_Q15(QCONST16(.7,15),r) + MULT16_32_Q15(QCONST16(.3,15),(spx_word32_t)(MULT16_32_Q15(RER,e))); + /*st->power_1[i] = adapt_rate*r/(e*(1+st->power[i]));*/ + st->power_1[i] = FLOAT_SHL(FLOAT_DIV32_FLOAT(r,FLOAT_MUL32U(e,st->power[i]+10)),WEIGHT_SHIFT+16); + } + } else { + /* Temporary adaption rate if filter is not yet adapted enough */ + spx_word16_t adapt_rate=0; + + if (Sxx > SHR32(MULT16_16(N, 1000),6)) + { + tmp32 = MULT16_32_Q15(QCONST16(.25f, 15), Sxx); +#ifdef FIXED_POINT + if (tmp32 > SHR32(See,2)) + tmp32 = SHR32(See,2); +#else + if (tmp32 > .25*See) + tmp32 = .25*See; +#endif + adapt_rate = FLOAT_EXTRACT16(FLOAT_SHL(FLOAT_DIV32(tmp32, See),15)); + } + for (i=0;i<=st->frame_size;i++) + st->power_1[i] = FLOAT_SHL(FLOAT_DIV32(EXTEND32(adapt_rate),ADD32(st->power[i],10)),WEIGHT_SHIFT+1); + + + /* How much have we adapted so far? */ + st->sum_adapt = ADD32(st->sum_adapt,adapt_rate); + } + + /* Save residual echo so it can be used by the nonlinear processor */ + if (st->adapted) + { + /* If the filter is adapted, take the filtered echo */ + for (i=0;iframe_size;i++) + st->last_y[i] = st->last_y[st->frame_size+i]; + for (i=0;iframe_size;i++) + st->last_y[st->frame_size+i] = in[i]-out[i]; + } else { + /* If filter isn't adapted yet, all we can do is take the far end signal directly */ + /* moved earlier: for (i=0;ilast_y[i] = st->x[i];*/ + } + +} + +/* Compute spectrum of estimated echo for use in an echo post-filter */ +void speex_echo_get_residual(SpeexEchoState *st, spx_word32_t *residual_echo, int len) +{ + int i; + spx_word16_t leak2; + int N; + + N = st->window_size; + + /* Apply hanning window (should pre-compute it)*/ + for (i=0;iy[i] = MULT16_16_Q15(st->window[i],st->last_y[i]); + + /* Compute power spectrum of the echo */ + spx_fft(st->fft_table, st->y, st->Y); + power_spectrum(st->Y, residual_echo, N); + +#ifdef FIXED_POINT + if (st->leak_estimate > 16383) + leak2 = 32767; + else + leak2 = SHL16(st->leak_estimate, 1); +#else + if (st->leak_estimate>.5) + leak2 = 1; + else + leak2 = 2*st->leak_estimate; +#endif + /* Estimate residual echo */ + for (i=0;i<=st->frame_size;i++) + residual_echo[i] = (spx_int32_t)MULT16_32_Q15(leak2,residual_echo[i]); + +} + +int speex_echo_ctl(SpeexEchoState *st, int request, void *ptr) +{ + switch(request) + { + + case SPEEX_ECHO_GET_FRAME_SIZE: + (*(int*)ptr) = st->frame_size; + break; + case SPEEX_ECHO_SET_SAMPLING_RATE: + st->sampling_rate = (*(int*)ptr); + st->spec_average = DIV32_16(SHL32(EXTEND32(st->frame_size), 15), st->sampling_rate); +#ifdef FIXED_POINT + st->beta0 = DIV32_16(SHL32(EXTEND32(st->frame_size), 16), st->sampling_rate); + st->beta_max = DIV32_16(SHL32(EXTEND32(st->frame_size), 14), st->sampling_rate); +#else + st->beta0 = (2.0f*st->frame_size)/st->sampling_rate; + st->beta_max = (.5f*st->frame_size)/st->sampling_rate; +#endif + if (st->sampling_rate<12000) + st->notch_radius = QCONST16(.9, 15); + else if (st->sampling_rate<24000) + st->notch_radius = QCONST16(.982, 15); + else + st->notch_radius = QCONST16(.992, 15); + break; + case SPEEX_ECHO_GET_SAMPLING_RATE: + (*(int*)ptr) = st->sampling_rate; + break; + default: + speex_warning_int("Unknown speex_echo_ctl request: ", request); + return -1; + } + return 0; +} diff --git a/lib/rbcodec/codecs/libspeex/misc_bfin.h b/lib/rbcodec/codecs/libspeex/misc_bfin.h new file mode 100644 index 0000000000..77b082c057 --- /dev/null +++ b/lib/rbcodec/codecs/libspeex/misc_bfin.h @@ -0,0 +1,54 @@ +/* Copyright (C) 2005 Analog Devices */ +/** + @file misc_bfin.h + @author Jean-Marc Valin + @brief Various compatibility routines for Speex (Blackfin version) +*/ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + - Neither the name of the Xiph.org Foundation nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#define OVERRIDE_SPEEX_MOVE +void *speex_move (void *dest, void *src, int n) +{ + __asm__ __volatile__ + ( + "L0 = 0;\n\t" + "I0 = %0;\n\t" + "R0 = [I0++];\n\t" + "LOOP move%= LC0 = %2;\n\t" + "LOOP_BEGIN move%=;\n\t" + "[%1++] = R0 || R0 = [I0++];\n\t" + "LOOP_END move%=;\n\t" + "[%1++] = R0;\n\t" + : "=a" (src), "=a" (dest) + : "a" ((n>>2)-1), "0" (src), "1" (dest) + : "R0", "I0", "L0", "memory" + ); + return dest; +} diff --git a/lib/rbcodec/codecs/libspeex/modes.c b/lib/rbcodec/codecs/libspeex/modes.c new file mode 100644 index 0000000000..d1046f1cfb --- /dev/null +++ b/lib/rbcodec/codecs/libspeex/modes.c @@ -0,0 +1,484 @@ +/* Copyright (C) 2002-2006 Jean-Marc Valin + File: modes.c + + Describes the different modes of the codec + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + - Neither the name of the Xiph.org Foundation nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + +#ifdef HAVE_CONFIG_H +#include "config-speex.h" +#endif + +#include "modes.h" +#include "ltp.h" +#include "quant_lsp.h" +#include "cb_search.h" +#include "sb_celp.h" +#include "nb_celp.h" +#include "vbr.h" +#include "arch.h" +#include + +#ifndef NULL +#define NULL 0 +#endif + + +/* Extern declarations for all codebooks we use here */ +extern const signed char gain_cdbk_nb[]; +extern const signed char gain_cdbk_lbr[]; +extern const signed char exc_5_256_table[]; +extern const signed char exc_5_64_table[]; +extern const signed char exc_8_128_table[]; +extern const signed char exc_10_32_table[]; +extern const signed char exc_10_16_table[]; +extern const signed char exc_20_32_table[]; + + +/* Parameters for Long-Term Prediction (LTP)*/ +static const ltp_params ltp_params_nb = { + gain_cdbk_nb, + 7, + 7 +}; + +/* Parameters for Long-Term Prediction (LTP)*/ +static const ltp_params ltp_params_vlbr = { + gain_cdbk_lbr, + 5, + 0 +}; + +/* Parameters for Long-Term Prediction (LTP)*/ +static const ltp_params ltp_params_lbr = { + gain_cdbk_lbr, + 5, + 7 +}; + +/* Parameters for Long-Term Prediction (LTP)*/ +static const ltp_params ltp_params_med = { + gain_cdbk_lbr, + 5, + 7 +}; + +/* Split-VQ innovation parameters for very low bit-rate narrowband */ +static const split_cb_params split_cb_nb_vlbr = { + 10, /*subvect_size*/ + 4, /*nb_subvect*/ + exc_10_16_table, /*shape_cb*/ + 4, /*shape_bits*/ + 0, +}; + +/* Split-VQ innovation parameters for very low bit-rate narrowband */ +static const split_cb_params split_cb_nb_ulbr = { + 20, /*subvect_size*/ + 2, /*nb_subvect*/ + exc_20_32_table, /*shape_cb*/ + 5, /*shape_bits*/ + 0, +}; + +/* Split-VQ innovation parameters for low bit-rate narrowband */ +static const split_cb_params split_cb_nb_lbr = { + 10, /*subvect_size*/ + 4, /*nb_subvect*/ + exc_10_32_table, /*shape_cb*/ + 5, /*shape_bits*/ + 0, +}; + + +/* Split-VQ innovation parameters narrowband */ +static const split_cb_params split_cb_nb = { + 5, /*subvect_size*/ + 8, /*nb_subvect*/ + exc_5_64_table, /*shape_cb*/ + 6, /*shape_bits*/ + 0, +}; + +/* Split-VQ innovation parameters narrowband */ +static const split_cb_params split_cb_nb_med = { + 8, /*subvect_size*/ + 5, /*nb_subvect*/ + exc_8_128_table, /*shape_cb*/ + 7, /*shape_bits*/ + 0, +}; + +/* Split-VQ innovation for low-band wideband */ +static const split_cb_params split_cb_sb = { + 5, /*subvect_size*/ + 8, /*nb_subvect*/ + exc_5_256_table, /*shape_cb*/ + 8, /*shape_bits*/ + 0, +}; + + + +/* 2150 bps "vocoder-like" mode for comfort noise */ +static const SpeexSubmode nb_submode1 = { + 0, + 1, + 0, + 0, +#ifndef SPEEX_DISABLE_ENCODER + /* LSP quantization */ + lsp_quant_lbr, + lsp_unquant_lbr, + /* No pitch quantization */ + forced_pitch_quant, + forced_pitch_unquant, + NULL, + /* No innovation quantization (noise only) */ + noise_codebook_quant, + noise_codebook_unquant, +#else + /* LSP quantization */ + NULL, + lsp_unquant_lbr, + /* No pitch quantization */ + NULL, + forced_pitch_unquant, + NULL, + /* No innovation quantization (noise only) */ + NULL, + noise_codebook_unquant, +#endif + NULL, + -1, + 43 +}; + +/* 3.95 kbps very low bit-rate mode */ +static const SpeexSubmode nb_submode8 = { + 0, + 1, + 0, + 0, +#ifndef SPEEX_DISABLE_ENCODER + /*LSP quantization*/ + lsp_quant_lbr, + lsp_unquant_lbr, + /*No pitch quantization*/ + forced_pitch_quant, + forced_pitch_unquant, + NULL, + /*Innovation quantization*/ + split_cb_search_shape_sign, + split_cb_shape_sign_unquant, + &split_cb_nb_ulbr, +#else + /*LSP quantization*/ + NULL, + lsp_unquant_lbr, + /*No pitch quantization*/ + NULL, + forced_pitch_unquant, + NULL, + /*Innovation quantization*/ + NULL, + split_cb_shape_sign_unquant, + &split_cb_nb_ulbr, +#endif + QCONST16(.5,15), + 79 +}; + +/* 5.95 kbps very low bit-rate mode */ +static const SpeexSubmode nb_submode2 = { + 0, + 0, + 0, + 0, +#ifndef SPEEX_DISABLE_ENCODER + /*LSP quantization*/ + lsp_quant_lbr, + lsp_unquant_lbr, + /*No pitch quantization*/ + pitch_search_3tap, + pitch_unquant_3tap, + <p_params_vlbr, + /*Innovation quantization*/ + split_cb_search_shape_sign, + split_cb_shape_sign_unquant, + &split_cb_nb_vlbr, +#else + /*LSP quantization*/ + NULL, + lsp_unquant_lbr, + /*No pitch quantization*/ + NULL, + pitch_unquant_3tap, + <p_params_vlbr, + /*Innovation quantization*/ + NULL, + split_cb_shape_sign_unquant, + &split_cb_nb_vlbr, +#endif + QCONST16(.6,15), + 119 +}; + +/* 8 kbps low bit-rate mode */ +static const SpeexSubmode nb_submode3 = { + -1, + 0, + 1, + 0, +#ifndef SPEEX_DISABLE_ENCODER + /*LSP quantization*/ + lsp_quant_lbr, + lsp_unquant_lbr, + /*Pitch quantization*/ + pitch_search_3tap, + pitch_unquant_3tap, + <p_params_lbr, + /*Innovation quantization*/ + split_cb_search_shape_sign, + split_cb_shape_sign_unquant, + &split_cb_nb_lbr, +#else + /*LSP quantization*/ + NULL, + lsp_unquant_lbr, + /*Pitch quantization*/ + NULL, + pitch_unquant_3tap, + <p_params_lbr, + /*Innovation quantization*/ + NULL, + split_cb_shape_sign_unquant, + &split_cb_nb_lbr, +#endif + QCONST16(.55,15), + 160 +}; + +/* 11 kbps medium bit-rate mode */ +static const SpeexSubmode nb_submode4 = { + -1, + 0, + 1, + 0, +#ifndef SPEEX_DISABLE_ENCODER + /*LSP quantization*/ + lsp_quant_lbr, + lsp_unquant_lbr, + /*Pitch quantization*/ + pitch_search_3tap, + pitch_unquant_3tap, + <p_params_med, + /*Innovation quantization*/ + split_cb_search_shape_sign, + split_cb_shape_sign_unquant, + &split_cb_nb_med, +#else + /*LSP quantization*/ + NULL, + lsp_unquant_lbr, + /*Pitch quantization*/ + NULL, + pitch_unquant_3tap, + <p_params_med, + /*Innovation quantization*/ + NULL, + split_cb_shape_sign_unquant, + &split_cb_nb_med, +#endif + QCONST16(.45,15), + 220 +}; + +/* 15 kbps high bit-rate mode */ +static const SpeexSubmode nb_submode5 = { + -1, + 0, + 3, + 0, +#ifndef SPEEX_DISABLE_ENCODER + /*LSP quantization*/ + lsp_quant_nb, + lsp_unquant_nb, + /*Pitch quantization*/ + pitch_search_3tap, + pitch_unquant_3tap, + <p_params_nb, + /*Innovation quantization*/ + split_cb_search_shape_sign, + split_cb_shape_sign_unquant, + &split_cb_nb, +#else + /*LSP quantization*/ + NULL, + lsp_unquant_nb, + /*Pitch quantization*/ + NULL, + pitch_unquant_3tap, + <p_params_nb, + /*Innovation quantization*/ + NULL, + split_cb_shape_sign_unquant, + &split_cb_nb, +#endif + QCONST16(.3,15), + 300 +}; + +/* 18.2 high bit-rate mode */ +static const SpeexSubmode nb_submode6 = { + -1, + 0, + 3, + 0, +#ifndef SPEEX_DISABLE_ENCODER + /*LSP quantization*/ + lsp_quant_nb, + lsp_unquant_nb, + /*Pitch quantization*/ + pitch_search_3tap, + pitch_unquant_3tap, + <p_params_nb, + /*Innovation quantization*/ + split_cb_search_shape_sign, + split_cb_shape_sign_unquant, + &split_cb_sb, +#else + /*LSP quantization*/ + NULL, + lsp_unquant_nb, + /*Pitch quantization*/ + NULL, + pitch_unquant_3tap, + <p_params_nb, + /*Innovation quantization*/ + NULL, + split_cb_shape_sign_unquant, + &split_cb_sb, +#endif + QCONST16(.2,15), + 364 +}; + +/* 24.6 kbps high bit-rate mode */ +static const SpeexSubmode nb_submode7 = { + -1, + 0, + 3, + 1, +#ifndef SPEEX_DISABLE_ENCODER + /*LSP quantization*/ + lsp_quant_nb, + lsp_unquant_nb, + /*Pitch quantization*/ + pitch_search_3tap, + pitch_unquant_3tap, + <p_params_nb, + /*Innovation quantization*/ + split_cb_search_shape_sign, + split_cb_shape_sign_unquant, + &split_cb_nb, +#else + /*LSP quantization*/ + NULL, + lsp_unquant_nb, + /*Pitch quantization*/ + NULL, + pitch_unquant_3tap, + <p_params_nb, + /*Innovation quantization*/ + NULL, + split_cb_shape_sign_unquant, + &split_cb_nb, +#endif + QCONST16(.1,15), + 492 +}; + + +/* Default mode for narrowband */ +static const SpeexNBMode nb_mode = { + 160, /*frameSize*/ + 40, /*subframeSize*/ + 10, /*lpcSize*/ + 17, /*pitchStart*/ + 144, /*pitchEnd*/ +#ifdef FIXED_POINT + 29491, 19661, /* gamma1, gamma2 */ +#else + 0.9, 0.6, /* gamma1, gamma2 */ +#endif + QCONST16(.0002,15), /*lpc_floor*/ + {NULL, &nb_submode1, &nb_submode2, &nb_submode3, &nb_submode4, &nb_submode5, &nb_submode6, &nb_submode7, + &nb_submode8, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, + 5, + {1, 8, 2, 3, 3, 4, 4, 5, 5, 6, 7} +}; + + +/* Default mode for narrowband */ +const SpeexMode speex_nb_mode = { + &nb_mode, + nb_mode_query, + "narrowband", + 0, + 4, +#ifndef SPEEX_DISABLE_ENCODER + &nb_encoder_init, + &nb_encoder_destroy, + &nb_encode, + &nb_decoder_init, + &nb_decoder_destroy, + &nb_decode, + &nb_encoder_ctl, + &nb_decoder_ctl, +#else +/* NULL, + NULL, + NULL, */ + &nb_decoder_init, + &nb_decoder_destroy, + &nb_decode, +/* NULL, */ + &nb_decoder_ctl, +#endif +}; + + + +int speex_mode_query(const SpeexMode *mode, int request, void *ptr) +{ + return mode->query(mode->mode, request, ptr); +} + diff --git a/lib/rbcodec/codecs/libspeex/modes.h b/lib/rbcodec/codecs/libspeex/modes.h new file mode 100644 index 0000000000..0fa1c3460e --- /dev/null +++ b/lib/rbcodec/codecs/libspeex/modes.h @@ -0,0 +1,161 @@ +/* Copyright (C) 2002-2006 Jean-Marc Valin */ +/** + @file modes.h + @brief Describes the different modes of the codec +*/ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + - Neither the name of the Xiph.org Foundation nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + +#ifndef MODES_H +#define MODES_H + +#include "speex/speex.h" +#include "speex/speex_bits.h" +#include "arch.h" + +#define NB_SUBMODES 16 +#define NB_SUBMODE_BITS 4 + +#define SB_SUBMODES 8 +#define SB_SUBMODE_BITS 3 + +/* Used internally, NOT TO BE USED in applications */ +/** Used internally*/ +#define SPEEX_GET_PI_GAIN 100 +/** Used internally*/ +#define SPEEX_GET_EXC 101 +/** Used internally*/ +#define SPEEX_GET_INNOV 102 +/** Used internally*/ +#define SPEEX_GET_DTX_STATUS 103 +/** Used internally*/ +#define SPEEX_SET_INNOVATION_SAVE 104 +/** Used internally*/ +#define SPEEX_SET_WIDEBAND 105 + +/** Used internally*/ +#define SPEEX_GET_STACK 106 + + +/** Quantizes LSPs */ +typedef void (*lsp_quant_func)(spx_lsp_t *, spx_lsp_t *, int, SpeexBits *); + +/** Decodes quantized LSPs */ +typedef void (*lsp_unquant_func)(spx_lsp_t *, int, SpeexBits *); + + +/** Long-term predictor quantization */ +typedef int (*ltp_quant_func)(spx_word16_t *, spx_word16_t *, spx_coef_t *, spx_coef_t *, + spx_coef_t *, spx_sig_t *, const void *, int, int, spx_word16_t, + int, int, SpeexBits*, char *, spx_word16_t *, spx_word16_t *, int, int, int, spx_word32_t *); + +/** Long-term un-quantize */ +typedef void (*ltp_unquant_func)(spx_word16_t *, spx_word32_t *, int, int, spx_word16_t, const void *, int, int *, + spx_word16_t *, SpeexBits*, char*, int, int, spx_word16_t, int); + + +/** Innovation quantization function */ +typedef void (*innovation_quant_func)(spx_word16_t *, spx_coef_t *, spx_coef_t *, spx_coef_t *, const void *, int, int, + spx_sig_t *, spx_word16_t *, SpeexBits *, char *, int, int); + +/** Innovation unquantization function */ +typedef void (*innovation_unquant_func)(spx_sig_t *, const void *, int, SpeexBits*, char *, spx_int32_t *); + +/** Description of a Speex sub-mode (wither narrowband or wideband */ +typedef struct SpeexSubmode { + int lbr_pitch; /**< Set to -1 for "normal" modes, otherwise encode pitch using a global pitch and allowing a +- lbr_pitch variation (for low not-rates)*/ + int forced_pitch_gain; /**< Use the same (forced) pitch gain for all sub-frames */ + int have_subframe_gain; /**< Number of bits to use as sub-frame innovation gain */ + int double_codebook; /**< Apply innovation quantization twice for higher quality (and higher bit-rate)*/ + /*LSP functions*/ + lsp_quant_func lsp_quant; /**< LSP quantization function */ + lsp_unquant_func lsp_unquant; /**< LSP unquantization function */ + + /*Long-term predictor functions*/ + ltp_quant_func ltp_quant; /**< Long-term predictor (pitch) quantizer */ + ltp_unquant_func ltp_unquant; /**< Long-term predictor (pitch) un-quantizer */ + const void *ltp_params; /**< Pitch parameters (options) */ + + /*Quantization of innovation*/ + innovation_quant_func innovation_quant; /**< Innovation quantization */ + innovation_unquant_func innovation_unquant; /**< Innovation un-quantization */ + const void *innovation_params; /**< Innovation quantization parameters*/ + + spx_word16_t comb_gain; /**< Gain of enhancer comb filter */ + + int bits_per_frame; /**< Number of bits per frame after encoding*/ +} SpeexSubmode; + +/** Struct defining the encoding/decoding mode*/ +typedef struct SpeexNBMode { + int frameSize; /**< Size of frames used for encoding */ + int subframeSize; /**< Size of sub-frames used for encoding */ + int lpcSize; /**< Order of LPC filter */ + int pitchStart; /**< Smallest pitch value allowed */ + int pitchEnd; /**< Largest pitch value allowed */ + + spx_word16_t gamma1; /**< Perceptual filter parameter #1 */ + spx_word16_t gamma2; /**< Perceptual filter parameter #2 */ + spx_word16_t lpc_floor; /**< Noise floor for LPC analysis */ + + const SpeexSubmode *submodes[NB_SUBMODES]; /**< Sub-mode data for the mode */ + int defaultSubmode; /**< Default sub-mode to use when encoding */ + int quality_map[11]; /**< Mode corresponding to each quality setting */ +} SpeexNBMode; + + +/** Struct defining the encoding/decoding mode for SB-CELP (wideband) */ +typedef struct SpeexSBMode { + const SpeexMode *nb_mode; /**< Embedded narrowband mode */ + int frameSize; /**< Size of frames used for encoding */ + int subframeSize; /**< Size of sub-frames used for encoding */ + int lpcSize; /**< Order of LPC filter */ + spx_word16_t gamma1; /**< Perceptual filter parameter #1 */ + spx_word16_t gamma2; /**< Perceptual filter parameter #1 */ + spx_word16_t lpc_floor; /**< Noise floor for LPC analysis */ + spx_word16_t folding_gain; + + const SpeexSubmode *submodes[SB_SUBMODES]; /**< Sub-mode data for the mode */ + int defaultSubmode; /**< Default sub-mode to use when encoding */ + int low_quality_map[11]; /**< Mode corresponding to each quality setting */ + int quality_map[11]; /**< Mode corresponding to each quality setting */ +#ifndef DISABLE_VBR + const float (*vbr_thresh)[11]; +#endif + int nb_modes; +} SpeexSBMode; + +int speex_encode_native(void *state, spx_word16_t *in, SpeexBits *bits); +int speex_decode_native(void *state, SpeexBits *bits, spx_word16_t *out); + +int nb_mode_query(const void *mode, int request, void *ptr); +int wb_mode_query(const void *mode, int request, void *ptr); + +#endif diff --git a/lib/rbcodec/codecs/libspeex/modes_wb.c b/lib/rbcodec/codecs/libspeex/modes_wb.c new file mode 100644 index 0000000000..93922afa2f --- /dev/null +++ b/lib/rbcodec/codecs/libspeex/modes_wb.c @@ -0,0 +1,374 @@ +/* Copyright (C) 2002-2007 Jean-Marc Valin + File: modes.c + + Describes the wideband modes of the codec + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + - Neither the name of the Xiph.org Foundation nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + +#ifdef HAVE_CONFIG_H +#include "config-speex.h" +#endif + +#include "modes.h" +#include "ltp.h" +#include "quant_lsp.h" +#include "cb_search.h" +#include "sb_celp.h" +#include "nb_celp.h" +#include "vbr.h" +#include "arch.h" +#include +#include "os_support.h" + + +#ifndef NULL +#define NULL 0 +#endif + +#ifndef ROCKBOX_VOICE_CODEC +const SpeexMode * const speex_mode_list[SPEEX_NB_MODES] = {&speex_nb_mode, &speex_wb_mode, &speex_uwb_mode}; +#else +const SpeexMode * const speex_mode_list[SPEEX_NB_MODES] = {&speex_nb_mode, &speex_wb_mode, NULL}; +#endif + +extern const signed char hexc_table[]; +extern const signed char hexc_10_32_table[]; + +#ifndef DISABLE_WIDEBAND + +/* Split-VQ innovation for high-band wideband */ +static const split_cb_params split_cb_high = { + 8, /*subvect_size*/ + 5, /*nb_subvect*/ + hexc_table, /*shape_cb*/ + 7, /*shape_bits*/ + 1, +}; + + +/* Split-VQ innovation for high-band wideband */ +static const split_cb_params split_cb_high_lbr = { + 10, /*subvect_size*/ + 4, /*nb_subvect*/ + hexc_10_32_table, /*shape_cb*/ + 5, /*shape_bits*/ + 0, +}; + +#endif + + +static const SpeexSubmode wb_submode1 = { + 0, + 0, + 1, + 0, + /*LSP quantization*/ +#ifndef SPEEX_DISABLE_ENCODER + lsp_quant_high, + lsp_unquant_high, +#else + NULL, + lsp_unquant_high, +#endif + /*Pitch quantization*/ + NULL, + NULL, + NULL, + /*No innovation quantization*/ + NULL, + NULL, + NULL, + -1, + 36 +}; + + +static const SpeexSubmode wb_submode2 = { + 0, + 0, + 1, + 0, +#ifndef SPEEX_DISABLE_ENCODER + /*LSP quantization*/ + lsp_quant_high, + lsp_unquant_high, + /*Pitch quantization*/ + NULL, + NULL, + NULL, + /*Innovation quantization*/ + split_cb_search_shape_sign, + split_cb_shape_sign_unquant, +#else + /*LSP quantization*/ + NULL, + lsp_unquant_high, + /*Pitch quantization*/ + NULL, + NULL, + NULL, + /*Innovation quantization*/ + NULL, + split_cb_shape_sign_unquant, +#endif +#ifdef DISABLE_WIDEBAND + NULL, +#else + &split_cb_high_lbr, +#endif + -1, + 112 +}; + + +static const SpeexSubmode wb_submode3 = { + 0, + 0, + 1, + 0, +#ifndef SPEEX_DISABLE_ENCODER + /*LSP quantization*/ + lsp_quant_high, + lsp_unquant_high, + /*Pitch quantization*/ + NULL, + NULL, + NULL, + /*Innovation quantization*/ + split_cb_search_shape_sign, + split_cb_shape_sign_unquant, +#else + /*LSP quantization*/ + NULL, + lsp_unquant_high, + /*Pitch quantization*/ + NULL, + NULL, + NULL, + /*Innovation quantization*/ + NULL, + split_cb_shape_sign_unquant, +#endif +#ifdef DISABLE_WIDEBAND + NULL, +#else + &split_cb_high, +#endif + -1, + 192 +}; + +static const SpeexSubmode wb_submode4 = { + 0, + 0, + 1, + 1, +#ifndef SPEEX_DISABLE_ENCODER + /*LSP quantization*/ + lsp_quant_high, + lsp_unquant_high, + /*Pitch quantization*/ + NULL, + NULL, + NULL, + /*Innovation quantization*/ + split_cb_search_shape_sign, + split_cb_shape_sign_unquant, +#else + /*LSP quantization*/ + NULL, + lsp_unquant_high, + /*Pitch quantization*/ + NULL, + NULL, + NULL, + /*Innovation quantization*/ + NULL, + split_cb_shape_sign_unquant, +#endif +#ifdef DISABLE_WIDEBAND + NULL, +#else + &split_cb_high, +#endif + -1, + 352 +}; + + +/* Split-band wideband CELP mode*/ +static const SpeexSBMode sb_wb_mode = { + &speex_nb_mode, + 160, /*frameSize*/ + 40, /*subframeSize*/ + 8, /*lpcSize*/ +#ifdef FIXED_POINT + 29491, 19661, /* gamma1, gamma2 */ +#else + 0.9, 0.6, /* gamma1, gamma2 */ +#endif + QCONST16(.0002,15), /*lpc_floor*/ + QCONST16(0.9f,15), + {NULL, &wb_submode1, &wb_submode2, &wb_submode3, &wb_submode4, NULL, NULL, NULL}, + 3, + {1, 8, 2, 3, 4, 5, 5, 6, 6, 7, 7}, + {1, 1, 1, 1, 1, 1, 2, 2, 3, 3, 4}, +#ifndef DISABLE_VBR + vbr_hb_thresh, +#endif + 5 +}; + + +const SpeexMode speex_wb_mode = { + &sb_wb_mode, + wb_mode_query, + "wideband (sub-band CELP)", + 1, + 4, +#ifndef SPEEX_DISABLE_ENCODER + &sb_encoder_init, + &sb_encoder_destroy, + &sb_encode, + &sb_decoder_init, + &sb_decoder_destroy, + &sb_decode, + &sb_encoder_ctl, + &sb_decoder_ctl, +#else +/* NULL, + NULL, + NULL, */ + &sb_decoder_init, + &sb_decoder_destroy, + &sb_decode, +/* NULL, */ + &sb_decoder_ctl, +#endif +}; + + + +/* "Ultra-wideband" mode stuff */ + + + +#ifndef ROCKBOX_VOICE_CODEC +/* Split-band "ultra-wideband" (32 kbps) CELP mode*/ +static const SpeexSBMode sb_uwb_mode = { + &speex_wb_mode, + 320, /*frameSize*/ + 80, /*subframeSize*/ + 8, /*lpcSize*/ +#ifdef FIXED_POINT + 29491, 19661, /* gamma1, gamma2 */ +#else + 0.9, 0.6, /* gamma1, gamma2 */ +#endif + QCONST16(.0002,15), /*lpc_floor*/ + QCONST16(0.7f,15), + {NULL, &wb_submode1, NULL, NULL, NULL, NULL, NULL, NULL}, + 1, + {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, + {0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, +#ifndef DISABLE_VBR + vbr_uhb_thresh, +#endif + 2 +}; +#endif + +int wb_mode_query(const void *mode, int request, void *ptr) +{ + const SpeexSBMode *m = (const SpeexSBMode*)mode; + + switch (request) + { + case SPEEX_MODE_FRAME_SIZE: + *((int*)ptr)=2*m->frameSize; + break; + case SPEEX_SUBMODE_BITS_PER_FRAME: + if (*((int*)ptr)==0) + *((int*)ptr) = SB_SUBMODE_BITS+1; + else if (m->submodes[*((int*)ptr)]==NULL) + *((int*)ptr) = -1; + else + *((int*)ptr) = m->submodes[*((int*)ptr)]->bits_per_frame; + break; + default: + speex_warning_int("Unknown wb_mode_query request: ", request); + return -1; + } + return 0; +} + + +#ifndef ROCKBOX_VOICE_CODEC +const SpeexMode speex_uwb_mode = { + &sb_uwb_mode, + wb_mode_query, + "ultra-wideband (sub-band CELP)", + 2, + 4, +#ifndef SPEEX_DISABLE_ENCODER + &sb_encoder_init, + &sb_encoder_destroy, + &sb_encode, + &sb_decoder_init, + &sb_decoder_destroy, + &sb_decode, + &sb_encoder_ctl, + &sb_decoder_ctl, +#else +/* NULL, + NULL, + NULL, */ + &sb_decoder_init, + &sb_decoder_destroy, + &sb_decode, +/* NULL, */ + &sb_decoder_ctl, +#endif +}; +#endif + +/* We have defined speex_lib_get_mode() as a macro in speex.h */ +#undef speex_lib_get_mode + +const SpeexMode * speex_lib_get_mode (int mode) +{ + if (mode < 0 || mode >= SPEEX_NB_MODES) return NULL; + + return speex_mode_list[mode]; +} + + + diff --git a/lib/rbcodec/codecs/libspeex/nb_celp.c b/lib/rbcodec/codecs/libspeex/nb_celp.c new file mode 100644 index 0000000000..364f987472 --- /dev/null +++ b/lib/rbcodec/codecs/libspeex/nb_celp.c @@ -0,0 +1,1917 @@ +/* Copyright (C) 2002-2006 Jean-Marc Valin + File: nb_celp.c + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + - Neither the name of the Xiph.org Foundation nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifdef HAVE_CONFIG_H +#include "config-speex.h" +#endif + +#include +#include "nb_celp.h" +#include "lpc.h" +#include "lsp.h" +#include "ltp.h" +#include "quant_lsp.h" +#include "cb_search.h" +#include "filters.h" +#include "stack_alloc.h" +#include "vq.h" +#include "speex/speex_bits.h" +#include "vbr.h" +#include "arch.h" +#include "math_approx.h" +#include "os_support.h" +#include "speex/speex_callbacks.h" + +#ifdef VORBIS_PSYCHO +#include "vorbis_psy.h" +#endif + +#ifndef M_PI +#define M_PI 3.14159265358979323846 /* pi */ +#endif + +#ifndef NULL +#define NULL 0 +#endif + +#define SUBMODE(x) st->submodes[st->submodeID]->x + +/* Default size for the encoder and decoder stack (can be changed at compile time). + This does not apply when using variable-size arrays or alloca. */ +#ifndef NB_ENC_STACK +#define NB_ENC_STACK (8000*sizeof(spx_sig_t)) +#endif + +#ifndef NB_DEC_STACK +#define NB_DEC_STACK (4000*sizeof(spx_sig_t)) +#endif + + +#ifdef FIXED_POINT +const spx_word32_t ol_gain_table[32] ICONST_ATTR = {18900, 25150, 33468, 44536, 59265, 78865, 104946, 139653, 185838, 247297, 329081, 437913, 582736, 775454, 1031906, 1373169, 1827293, 2431601, 3235761, 4305867, 5729870, 7624808, 10146425, 13501971, 17967238, 23909222, 31816294, 42338330, 56340132, 74972501, 99766822, 132760927}; +const spx_word16_t exc_gain_quant_scal3_bound[7] ICONST_ATTR = {1841, 3883, 6051, 8062, 10444, 13580, 18560}; +const spx_word16_t exc_gain_quant_scal3[8] ICONST_ATTR = {1002, 2680, 5086, 7016, 9108, 11781, 15380, 21740}; +const spx_word16_t exc_gain_quant_scal1_bound[1] ICONST_ATTR = {14385}; +const spx_word16_t exc_gain_quant_scal1[2] ICONST_ATTR = {11546, 17224}; + +#define LSP_MARGIN 16 +#define LSP_DELTA1 6553 +#define LSP_DELTA2 1638 + +#else + +const float exc_gain_quant_scal3_bound[7]={0.112338f, 0.236980f, 0.369316f, 0.492054f, 0.637471f, 0.828874f, 1.132784f}; +const float exc_gain_quant_scal3[8]={0.061130f, 0.163546f, 0.310413f, 0.428220f, 0.555887f, 0.719055f, 0.938694f, 1.326874f}; +const float exc_gain_quant_scal1_bound[1]={0.87798f}; +const float exc_gain_quant_scal1[2]={0.70469f, 1.05127f}; + +#define LSP_MARGIN .002f +#define LSP_DELTA1 .2f +#define LSP_DELTA2 .05f + +#endif + +#ifdef VORBIS_PSYCHO +#define EXTRA_BUFFER 100 +#else +#define EXTRA_BUFFER 0 +#endif + + +#define sqr(x) ((x)*(x)) + +extern const spx_word16_t lag_window[]; +extern const spx_word16_t lpc_window[]; + +#ifndef SPEEX_DISABLE_ENCODER +void *nb_encoder_init(const SpeexMode *m) +{ + EncState *st; + const SpeexNBMode *mode; + int i; + + mode=(const SpeexNBMode *)m->mode; + st = (EncState*)speex_alloc(sizeof(EncState)); + if (!st) + return NULL; +#if defined(VAR_ARRAYS) || defined (USE_ALLOCA) + st->stack = NULL; +#else + st->stack = (char*)speex_alloc_scratch(NB_ENC_STACK); +#endif + + st->mode=m; + + st->frameSize = mode->frameSize; + st->nbSubframes=mode->frameSize/mode->subframeSize; + st->subframeSize=mode->subframeSize; + st->windowSize = st->frameSize+st->subframeSize; + st->lpcSize = mode->lpcSize; + st->gamma1=mode->gamma1; + st->gamma2=mode->gamma2; + st->min_pitch=mode->pitchStart; + st->max_pitch=mode->pitchEnd; + st->lpc_floor = mode->lpc_floor; + + st->submodes=mode->submodes; + st->submodeID=st->submodeSelect=mode->defaultSubmode; + st->bounded_pitch = 1; + + st->encode_submode = 1; + +#ifdef VORBIS_PSYCHO + st->psy = vorbis_psy_init(8000, 256); + st->curve = (float*)speex_alloc(128*sizeof(float)); + st->old_curve = (float*)speex_alloc(128*sizeof(float)); + st->psy_window = (float*)speex_alloc(256*sizeof(float)); +#endif + + st->cumul_gain = 1024; + + /* Allocating input buffer */ + st->winBuf = (spx_word16_t*)speex_alloc((st->windowSize-st->frameSize)*sizeof(spx_word16_t)); + /* Allocating excitation buffer */ + st->excBuf = (spx_word16_t*)speex_alloc((mode->frameSize+mode->pitchEnd+2)*sizeof(spx_word16_t)); + st->exc = st->excBuf + mode->pitchEnd + 2; + st->swBuf = (spx_word16_t*)speex_alloc((mode->frameSize+mode->pitchEnd+2)*sizeof(spx_word16_t)); + st->sw = st->swBuf + mode->pitchEnd + 2; + + st->window= lpc_window; + + /* Create the window for autocorrelation (lag-windowing) */ + st->lagWindow = lag_window; + + st->old_lsp = (spx_lsp_t*)speex_alloc((st->lpcSize)*sizeof(spx_lsp_t)); + st->old_qlsp = (spx_lsp_t*)speex_alloc((st->lpcSize)*sizeof(spx_lsp_t)); + st->first = 1; + for (i=0;ilpcSize;i++) + st->old_lsp[i]= DIV32(MULT16_16(QCONST16(3.1415927f, LSP_SHIFT), i+1), st->lpcSize+1); + + st->mem_sp = (spx_mem_t*)speex_alloc((st->lpcSize)*sizeof(spx_mem_t)); + st->mem_sw = (spx_mem_t*)speex_alloc((st->lpcSize)*sizeof(spx_mem_t)); + st->mem_sw_whole = (spx_mem_t*)speex_alloc((st->lpcSize)*sizeof(spx_mem_t)); + st->mem_exc = (spx_mem_t*)speex_alloc((st->lpcSize)*sizeof(spx_mem_t)); + st->mem_exc2 = (spx_mem_t*)speex_alloc((st->lpcSize)*sizeof(spx_mem_t)); + + st->pi_gain = (spx_word32_t*)speex_alloc((st->nbSubframes)*sizeof(spx_word32_t)); + st->innov_rms_save = NULL; + + st->pitch = (int*)speex_alloc((st->nbSubframes)*sizeof(int)); + +#ifndef DISABLE_VBR + st->vbr = (VBRState*)speex_alloc(sizeof(VBRState)); + vbr_init(st->vbr); + st->vbr_quality = 8; + st->vbr_enabled = 0; + st->vbr_max = 0; + st->vad_enabled = 0; + st->dtx_enabled = 0; + st->dtx_count=0; + st->abr_enabled = 0; + st->abr_drift = 0; + st->abr_drift2 = 0; +#endif /* #ifndef DISABLE_VBR */ + + st->plc_tuning = 2; + st->complexity=2; + st->sampling_rate=8000; + st->isWideband = 0; + st->highpass_enabled = 1; + +#ifdef ENABLE_VALGRIND + VALGRIND_MAKE_READABLE(st, NB_ENC_STACK); +#endif + return st; +} + +void nb_encoder_destroy(void *state) +{ + EncState *st=(EncState *)state; + /* Free all allocated memory */ +#if !(defined(VAR_ARRAYS) || defined (USE_ALLOCA)) + speex_free_scratch(st->stack); +#endif + + speex_free (st->winBuf); + speex_free (st->excBuf); + speex_free (st->old_qlsp); + speex_free (st->swBuf); + + speex_free (st->old_lsp); + speex_free (st->mem_sp); + speex_free (st->mem_sw); + speex_free (st->mem_sw_whole); + speex_free (st->mem_exc); + speex_free (st->mem_exc2); + speex_free (st->pi_gain); + speex_free (st->pitch); + +#ifndef DISABLE_VBR + vbr_destroy(st->vbr); + speex_free (st->vbr); +#endif /* #ifndef DISABLE_VBR */ + +#ifdef VORBIS_PSYCHO + vorbis_psy_destroy(st->psy); + speex_free (st->curve); + speex_free (st->old_curve); + speex_free (st->psy_window); +#endif + + /*Free state memory... should be last*/ + speex_free(st); +} + +int nb_encode(void *state, void *vin, SpeexBits *bits) +{ + EncState *st; + int i, sub, roots; + int ol_pitch; + spx_word16_t ol_pitch_coef; + spx_word32_t ol_gain; + VARDECL(spx_word16_t *ringing); + VARDECL(spx_word16_t *target); + VARDECL(spx_sig_t *innov); + VARDECL(spx_word32_t *exc32); + VARDECL(spx_mem_t *mem); + VARDECL(spx_coef_t *bw_lpc1); + VARDECL(spx_coef_t *bw_lpc2); + VARDECL(spx_coef_t *lpc); + VARDECL(spx_lsp_t *lsp); + VARDECL(spx_lsp_t *qlsp); + VARDECL(spx_lsp_t *interp_lsp); + VARDECL(spx_lsp_t *interp_qlsp); + VARDECL(spx_coef_t *interp_lpc); + VARDECL(spx_coef_t *interp_qlpc); + char *stack; + VARDECL(spx_word16_t *syn_resp); + VARDECL(spx_word16_t *real_exc); + + spx_word32_t ener=0; + spx_word16_t fine_gain; + spx_word16_t *in = (spx_word16_t*)vin; + + st=(EncState *)state; + stack=st->stack; + + ALLOC(lpc, st->lpcSize, spx_coef_t); + ALLOC(bw_lpc1, st->lpcSize, spx_coef_t); + ALLOC(bw_lpc2, st->lpcSize, spx_coef_t); + ALLOC(lsp, st->lpcSize, spx_lsp_t); + ALLOC(qlsp, st->lpcSize, spx_lsp_t); + ALLOC(interp_lsp, st->lpcSize, spx_lsp_t); + ALLOC(interp_qlsp, st->lpcSize, spx_lsp_t); + ALLOC(interp_lpc, st->lpcSize, spx_coef_t); + ALLOC(interp_qlpc, st->lpcSize, spx_coef_t); + + /* Move signals 1 frame towards the past */ + SPEEX_MOVE(st->excBuf, st->excBuf+st->frameSize, st->max_pitch+2); + SPEEX_MOVE(st->swBuf, st->swBuf+st->frameSize, st->max_pitch+2); + + if (st->highpass_enabled) + highpass(in, in, st->frameSize, (st->isWideband?HIGHPASS_WIDEBAND:HIGHPASS_NARROWBAND)|HIGHPASS_INPUT, st->mem_hp); + + { + VARDECL(spx_word16_t *w_sig); + VARDECL(spx_word16_t *autocorr); + ALLOC(w_sig, st->windowSize, spx_word16_t); + ALLOC(autocorr, st->lpcSize+1, spx_word16_t); + /* Window for analysis */ + for (i=0;iwindowSize-st->frameSize;i++) + w_sig[i] = EXTRACT16(SHR32(MULT16_16(st->winBuf[i],st->window[i]),SIG_SHIFT)); + for (;iwindowSize;i++) + w_sig[i] = EXTRACT16(SHR32(MULT16_16(in[i-st->windowSize+st->frameSize],st->window[i]),SIG_SHIFT)); + /* Compute auto-correlation */ + _spx_autocorr(w_sig, autocorr, st->lpcSize+1, st->windowSize); + autocorr[0] = ADD16(autocorr[0],MULT16_16_Q15(autocorr[0],st->lpc_floor)); /* Noise floor in auto-correlation domain */ + + /* Lag windowing: equivalent to filtering in the power-spectrum domain */ + for (i=0;ilpcSize+1;i++) + autocorr[i] = MULT16_16_Q14(autocorr[i],st->lagWindow[i]); + + /* Levinson-Durbin */ + _spx_lpc(lpc, autocorr, st->lpcSize); + /* LPC to LSPs (x-domain) transform */ + roots=lpc_to_lsp (lpc, st->lpcSize, lsp, 10, LSP_DELTA1, stack); + /* Check if we found all the roots */ + if (roots!=st->lpcSize) + { + /*If we can't find all LSP's, do some damage control and use previous filter*/ + for (i=0;ilpcSize;i++) + { + lsp[i]=st->old_lsp[i]; + } + } + } + + + + + /* Whole frame analysis (open-loop estimation of pitch and excitation gain) */ + { + int diff = st->windowSize-st->frameSize; + if (st->first) + for (i=0;ilpcSize;i++) + interp_lsp[i] = lsp[i]; + else + lsp_interpolate(st->old_lsp, lsp, interp_lsp, st->lpcSize, st->nbSubframes, st->nbSubframes<<1); + + lsp_enforce_margin(interp_lsp, st->lpcSize, LSP_MARGIN); + + /* Compute interpolated LPCs (unquantized) for whole frame*/ + lsp_to_lpc(interp_lsp, interp_lpc, st->lpcSize,stack); + + + /*Open-loop pitch*/ + if (!st->submodes[st->submodeID] || (st->complexity>2 && SUBMODE(have_subframe_gain)<3) || SUBMODE(forced_pitch_gain) || SUBMODE(lbr_pitch) != -1 +#ifndef DISABLE_VBR + || st->vbr_enabled || st->vad_enabled +#endif + ) + { + int nol_pitch[6]; + spx_word16_t nol_pitch_coef[6]; + + bw_lpc(st->gamma1, interp_lpc, bw_lpc1, st->lpcSize); + bw_lpc(st->gamma2, interp_lpc, bw_lpc2, st->lpcSize); + + SPEEX_COPY(st->sw, st->winBuf, diff); + SPEEX_COPY(st->sw+diff, in, st->frameSize-diff); + filter_mem16(st->sw, bw_lpc1, bw_lpc2, st->sw, st->frameSize, st->lpcSize, st->mem_sw_whole, stack); + + open_loop_nbest_pitch(st->sw, st->min_pitch, st->max_pitch, st->frameSize, + nol_pitch, nol_pitch_coef, 6, stack); + ol_pitch=nol_pitch[0]; + ol_pitch_coef = nol_pitch_coef[0]; + /*Try to remove pitch multiples*/ + for (i=1;i<6;i++) + { +#ifdef FIXED_POINT + if ((nol_pitch_coef[i]>MULT16_16_Q15(nol_pitch_coef[0],27853)) && +#else + if ((nol_pitch_coef[i]>.85*nol_pitch_coef[0]) && +#endif + (ABS(2*nol_pitch[i]-ol_pitch)<=2 || ABS(3*nol_pitch[i]-ol_pitch)<=3 || + ABS(4*nol_pitch[i]-ol_pitch)<=4 || ABS(5*nol_pitch[i]-ol_pitch)<=5)) + { + /*ol_pitch_coef=nol_pitch_coef[i];*/ + ol_pitch = nol_pitch[i]; + } + } + /*if (ol_pitch>50) + ol_pitch/=2;*/ + /*ol_pitch_coef = sqrt(ol_pitch_coef);*/ + + } else { + ol_pitch=0; + ol_pitch_coef=0; + } + + /*Compute "real" excitation*/ + SPEEX_COPY(st->exc, st->winBuf, diff); + SPEEX_COPY(st->exc+diff, in, st->frameSize-diff); + fir_mem16(st->exc, interp_lpc, st->exc, st->frameSize, st->lpcSize, st->mem_exc, stack); + + /* Compute open-loop excitation gain */ + { + spx_word16_t g = compute_rms16(st->exc, st->frameSize); + if (st->submodeID!=1 && ol_pitch>0) + ol_gain = MULT16_16(g, MULT16_16_Q14(QCONST16(1.1,14), + spx_sqrt(QCONST32(1.,28)-MULT16_32_Q15(QCONST16(.8,15),SHL32(MULT16_16(ol_pitch_coef,ol_pitch_coef),16))))); + else + ol_gain = SHL32(EXTEND32(g),SIG_SHIFT); + } + } + +#ifdef VORBIS_PSYCHO + SPEEX_MOVE(st->psy_window, st->psy_window+st->frameSize, 256-st->frameSize); + SPEEX_COPY(&st->psy_window[256-st->frameSize], in, st->frameSize); + compute_curve(st->psy, st->psy_window, st->curve); + /*print_vec(st->curve, 128, "curve");*/ + if (st->first) + SPEEX_COPY(st->old_curve, st->curve, 128); +#endif + + /*VBR stuff*/ +#ifndef DISABLE_VBR + if (st->vbr && (st->vbr_enabled||st->vad_enabled)) + { + float lsp_dist=0; + for (i=0;ilpcSize;i++) + lsp_dist += (st->old_lsp[i] - lsp[i])*(st->old_lsp[i] - lsp[i]); + lsp_dist /= LSP_SCALING*LSP_SCALING; + + if (st->abr_enabled) + { + float qual_change=0; + if (st->abr_drift2 * st->abr_drift > 0) + { + /* Only adapt if long-term and short-term drift are the same sign */ + qual_change = -.00001*st->abr_drift/(1+st->abr_count); + if (qual_change>.05) + qual_change=.05; + if (qual_change<-.05) + qual_change=-.05; + } + st->vbr_quality += qual_change; + if (st->vbr_quality>10) + st->vbr_quality=10; + if (st->vbr_quality<0) + st->vbr_quality=0; + } + + st->relative_quality = vbr_analysis(st->vbr, in, st->frameSize, ol_pitch, GAIN_SCALING_1*ol_pitch_coef); + /*if (delta_qual<0)*/ + /* delta_qual*=.1*(3+st->vbr_quality);*/ + if (st->vbr_enabled) + { + spx_int32_t mode; + int choice=0; + float min_diff=100; + mode = 8; + while (mode) + { + int v1; + float thresh; + v1=(int)floor(st->vbr_quality); + if (v1==10) + thresh = vbr_nb_thresh[mode][v1]; + else + thresh = (st->vbr_quality-v1)*vbr_nb_thresh[mode][v1+1] + (1+v1-st->vbr_quality)*vbr_nb_thresh[mode][v1]; + if (st->relative_quality > thresh && + st->relative_quality-threshrelative_quality-thresh; + } + mode--; + } + mode=choice; + if (mode==0) + { + if (st->dtx_count==0 || lsp_dist>.05 || !st->dtx_enabled || st->dtx_count>20) + { + mode=1; + st->dtx_count=1; + } else { + mode=0; + st->dtx_count++; + } + } else { + st->dtx_count=0; + } + + speex_encoder_ctl(state, SPEEX_SET_MODE, &mode); + if (st->vbr_max>0) + { + spx_int32_t rate; + speex_encoder_ctl(state, SPEEX_GET_BITRATE, &rate); + if (rate > st->vbr_max) + { + rate = st->vbr_max; + speex_encoder_ctl(state, SPEEX_SET_BITRATE, &rate); + } + } + + if (st->abr_enabled) + { + spx_int32_t bitrate; + speex_encoder_ctl(state, SPEEX_GET_BITRATE, &bitrate); + st->abr_drift+=(bitrate-st->abr_enabled); + st->abr_drift2 = .95*st->abr_drift2 + .05*(bitrate-st->abr_enabled); + st->abr_count += 1.0; + } + + } else { + /*VAD only case*/ + int mode; + if (st->relative_quality<2) + { + if (st->dtx_count==0 || lsp_dist>.05 || !st->dtx_enabled || st->dtx_count>20) + { + st->dtx_count=1; + mode=1; + } else { + mode=0; + st->dtx_count++; + } + } else { + st->dtx_count = 0; + mode=st->submodeSelect; + } + /*speex_encoder_ctl(state, SPEEX_SET_MODE, &mode);*/ + st->submodeID=mode; + } + } else { + st->relative_quality = -1; + } +#endif /* #ifndef DISABLE_VBR */ + + if (st->encode_submode) + { + /* First, transmit a zero for narrowband */ + speex_bits_pack(bits, 0, 1); + + /* Transmit the sub-mode we use for this frame */ + speex_bits_pack(bits, st->submodeID, NB_SUBMODE_BITS); + + } + + /* If null mode (no transmission), just set a couple things to zero*/ + if (st->submodes[st->submodeID] == NULL) + { + for (i=0;iframeSize;i++) + st->exc[i]=st->sw[i]=VERY_SMALL; + + for (i=0;ilpcSize;i++) + st->mem_sw[i]=0; + st->first=1; + st->bounded_pitch = 1; + + SPEEX_COPY(st->winBuf, in+2*st->frameSize-st->windowSize, st->windowSize-st->frameSize); + + /* Clear memory (no need to really compute it) */ + for (i=0;ilpcSize;i++) + st->mem_sp[i] = 0; + return 0; + + } + + /* LSP Quantization */ + if (st->first) + { + for (i=0;ilpcSize;i++) + st->old_lsp[i] = lsp[i]; + } + + + /*Quantize LSPs*/ +#if 1 /*0 for unquantized*/ + SUBMODE(lsp_quant)(lsp, qlsp, st->lpcSize, bits); +#else + for (i=0;ilpcSize;i++) + qlsp[i]=lsp[i]; +#endif + + /*If we use low bit-rate pitch mode, transmit open-loop pitch*/ + if (SUBMODE(lbr_pitch)!=-1) + { + speex_bits_pack(bits, ol_pitch-st->min_pitch, 7); + } + + if (SUBMODE(forced_pitch_gain)) + { + int quant; + /* This just damps the pitch a bit, because it tends to be too aggressive when forced */ + ol_pitch_coef = MULT16_16_Q15(QCONST16(.9,15), ol_pitch_coef); +#ifdef FIXED_POINT + quant = PSHR16(MULT16_16_16(15, ol_pitch_coef),GAIN_SHIFT); +#else + quant = (int)floor(.5+15*ol_pitch_coef*GAIN_SCALING_1); +#endif + if (quant>15) + quant=15; + if (quant<0) + quant=0; + speex_bits_pack(bits, quant, 4); + ol_pitch_coef=MULT16_16_P15(QCONST16(0.066667,15),SHL16(quant,GAIN_SHIFT)); + } + + + /*Quantize and transmit open-loop excitation gain*/ +#ifdef FIXED_POINT + { + int qe = scal_quant32(ol_gain, ol_gain_table, 32); + /*ol_gain = exp(qe/3.5)*SIG_SCALING;*/ + ol_gain = MULT16_32_Q15(28406,ol_gain_table[qe]); + speex_bits_pack(bits, qe, 5); + } +#else + { + int qe = (int)(floor(.5+3.5*log(ol_gain*1.0/SIG_SCALING))); + if (qe<0) + qe=0; + if (qe>31) + qe=31; + ol_gain = exp(qe/3.5)*SIG_SCALING; + speex_bits_pack(bits, qe, 5); + } +#endif + + + + /* Special case for first frame */ + if (st->first) + { + for (i=0;ilpcSize;i++) + st->old_qlsp[i] = qlsp[i]; + } + + /* Target signal */ + ALLOC(target, st->subframeSize, spx_word16_t); + ALLOC(innov, st->subframeSize, spx_sig_t); + ALLOC(exc32, st->subframeSize, spx_word32_t); + ALLOC(ringing, st->subframeSize, spx_word16_t); + ALLOC(syn_resp, st->subframeSize, spx_word16_t); + ALLOC(real_exc, st->subframeSize, spx_word16_t); + ALLOC(mem, st->lpcSize, spx_mem_t); + + /* Loop on sub-frames */ + for (sub=0;subnbSubframes;sub++) + { + int offset; + spx_word16_t *sw; + spx_word16_t *exc; + int pitch; + int response_bound = st->subframeSize; + + /* Offset relative to start of frame */ + offset = st->subframeSize*sub; + /* Excitation */ + exc=st->exc+offset; + /* Weighted signal */ + sw=st->sw+offset; + + /* LSP interpolation (quantized and unquantized) */ + lsp_interpolate(st->old_lsp, lsp, interp_lsp, st->lpcSize, sub, st->nbSubframes); + lsp_interpolate(st->old_qlsp, qlsp, interp_qlsp, st->lpcSize, sub, st->nbSubframes); + + /* Make sure the filters are stable */ + lsp_enforce_margin(interp_lsp, st->lpcSize, LSP_MARGIN); + lsp_enforce_margin(interp_qlsp, st->lpcSize, LSP_MARGIN); + + /* Compute interpolated LPCs (quantized and unquantized) */ + lsp_to_lpc(interp_lsp, interp_lpc, st->lpcSize,stack); + + lsp_to_lpc(interp_qlsp, interp_qlpc, st->lpcSize, stack); + + /* Compute analysis filter gain at w=pi (for use in SB-CELP) */ + { + spx_word32_t pi_g=LPC_SCALING; + for (i=0;ilpcSize;i+=2) + { + /*pi_g += -st->interp_qlpc[i] + st->interp_qlpc[i+1];*/ + pi_g = ADD32(pi_g, SUB32(EXTEND32(interp_qlpc[i+1]),EXTEND32(interp_qlpc[i]))); + } + st->pi_gain[sub] = pi_g; + } + +#ifdef VORBIS_PSYCHO + { + float curr_curve[128]; + float fact = ((float)sub+1.0f)/st->nbSubframes; + for (i=0;i<128;i++) + curr_curve[i] = (1.0f-fact)*st->old_curve[i] + fact*st->curve[i]; + curve_to_lpc(st->psy, curr_curve, bw_lpc1, bw_lpc2, 10); + } +#else + /* Compute bandwidth-expanded (unquantized) LPCs for perceptual weighting */ + bw_lpc(st->gamma1, interp_lpc, bw_lpc1, st->lpcSize); + if (st->gamma2>=0) + bw_lpc(st->gamma2, interp_lpc, bw_lpc2, st->lpcSize); + else + { + for (i=0;ilpcSize;i++) + bw_lpc2[i]=0; + } + /*print_vec(st->bw_lpc1, 10, "bw_lpc");*/ +#endif + + /*FIXME: This will break if we change the window size */ + speex_assert(st->windowSize-st->frameSize == st->subframeSize); + if (sub==0) + { + for (i=0;isubframeSize;i++) + real_exc[i] = sw[i] = st->winBuf[i]; + } else { + for (i=0;isubframeSize;i++) + real_exc[i] = sw[i] = in[i+((sub-1)*st->subframeSize)]; + } + fir_mem16(real_exc, interp_qlpc, real_exc, st->subframeSize, st->lpcSize, st->mem_exc2, stack); + + if (st->complexity==0) + response_bound >>= 1; + compute_impulse_response(interp_qlpc, bw_lpc1, bw_lpc2, syn_resp, response_bound, st->lpcSize, stack); + for (i=response_bound;isubframeSize;i++) + syn_resp[i]=VERY_SMALL; + + /* Compute zero response of A(z/g1) / ( A(z/g2) * A(z) ) */ + for (i=0;ilpcSize;i++) + mem[i]=SHL32(st->mem_sp[i],1); + for (i=0;isubframeSize;i++) + ringing[i] = VERY_SMALL; +#ifdef SHORTCUTS2 + iir_mem16(ringing, interp_qlpc, ringing, response_bound, st->lpcSize, mem, stack); + for (i=0;ilpcSize;i++) + mem[i]=SHL32(st->mem_sw[i],1); + filter_mem16(ringing, st->bw_lpc1, st->bw_lpc2, ringing, response_bound, st->lpcSize, mem, stack); + SPEEX_MEMSET(&ringing[response_bound], 0, st->subframeSize-response_bound); +#else + iir_mem16(ringing, interp_qlpc, ringing, st->subframeSize, st->lpcSize, mem, stack); + for (i=0;ilpcSize;i++) + mem[i]=SHL32(st->mem_sw[i],1); + filter_mem16(ringing, bw_lpc1, bw_lpc2, ringing, st->subframeSize, st->lpcSize, mem, stack); +#endif + + /* Compute weighted signal */ + for (i=0;ilpcSize;i++) + mem[i]=st->mem_sw[i]; + filter_mem16(sw, bw_lpc1, bw_lpc2, sw, st->subframeSize, st->lpcSize, mem, stack); + + if (st->complexity==0) + for (i=0;ilpcSize;i++) + st->mem_sw[i]=mem[i]; + + /* Compute target signal (saturation prevents overflows on clipped input speech) */ + for (i=0;isubframeSize;i++) + target[i]=EXTRACT16(SATURATE(SUB32(sw[i],PSHR32(ringing[i],1)),32767)); + + /* Reset excitation */ + SPEEX_MEMSET(exc, 0, st->subframeSize); + + /* If we have a long-term predictor (otherwise, something's wrong) */ + speex_assert (SUBMODE(ltp_quant)); + { + int pit_min, pit_max; + /* Long-term prediction */ + if (SUBMODE(lbr_pitch) != -1) + { + /* Low bit-rate pitch handling */ + int margin; + margin = SUBMODE(lbr_pitch); + if (margin) + { + if (ol_pitch < st->min_pitch+margin-1) + ol_pitch=st->min_pitch+margin-1; + if (ol_pitch > st->max_pitch-margin) + ol_pitch=st->max_pitch-margin; + pit_min = ol_pitch-margin+1; + pit_max = ol_pitch+margin; + } else { + pit_min=pit_max=ol_pitch; + } + } else { + pit_min = st->min_pitch; + pit_max = st->max_pitch; + } + + /* Force pitch to use only the current frame if needed */ + if (st->bounded_pitch && pit_max>offset) + pit_max=offset; + + /* Perform pitch search */ + pitch = SUBMODE(ltp_quant)(target, sw, interp_qlpc, bw_lpc1, bw_lpc2, + exc32, SUBMODE(ltp_params), pit_min, pit_max, ol_pitch_coef, + st->lpcSize, st->subframeSize, bits, stack, + exc, syn_resp, st->complexity, 0, st->plc_tuning, &st->cumul_gain); + + st->pitch[sub]=pitch; + } + /* Quantization of innovation */ + SPEEX_MEMSET(innov, 0, st->subframeSize); + + /* FIXME: Make sure this is save from overflows (so far so good) */ + for (i=0;isubframeSize;i++) + real_exc[i] = EXTRACT16(SUB32(EXTEND32(real_exc[i]), PSHR32(exc32[i],SIG_SHIFT-1))); + + ener = SHL32(EXTEND32(compute_rms16(real_exc, st->subframeSize)),SIG_SHIFT); + + /*FIXME: Should use DIV32_16 and make sure result fits in 16 bits */ +#ifdef FIXED_POINT + { + spx_word32_t f = PDIV32(ener,PSHR32(ol_gain,SIG_SHIFT)); + if (f<=32767) + fine_gain = f; + else + fine_gain = 32767; + } +#else + fine_gain = PDIV32_16(ener,PSHR32(ol_gain,SIG_SHIFT)); +#endif + /* Calculate gain correction for the sub-frame (if any) */ + if (SUBMODE(have_subframe_gain)) + { + int qe; + if (SUBMODE(have_subframe_gain)==3) + { + qe = scal_quant(fine_gain, exc_gain_quant_scal3_bound, 8); + speex_bits_pack(bits, qe, 3); + ener=MULT16_32_Q14(exc_gain_quant_scal3[qe],ol_gain); + } else { + qe = scal_quant(fine_gain, exc_gain_quant_scal1_bound, 2); + speex_bits_pack(bits, qe, 1); + ener=MULT16_32_Q14(exc_gain_quant_scal1[qe],ol_gain); + } + } else { + ener=ol_gain; + } + + /*printf ("%f %f\n", ener, ol_gain);*/ + + /* Normalize innovation */ + signal_div(target, target, ener, st->subframeSize); + + /* Quantize innovation */ + speex_assert (SUBMODE(innovation_quant)); + { + /* Codebook search */ + SUBMODE(innovation_quant)(target, interp_qlpc, bw_lpc1, bw_lpc2, + SUBMODE(innovation_params), st->lpcSize, st->subframeSize, + innov, syn_resp, bits, stack, st->complexity, SUBMODE(double_codebook)); + + /* De-normalize innovation and update excitation */ + signal_mul(innov, innov, ener, st->subframeSize); + + for (i=0;isubframeSize;i++) + exc[i] = EXTRACT16(SATURATE32(PSHR32(ADD32(SHL32(exc32[i],1),innov[i]),SIG_SHIFT),32767)); + + /* In some (rare) modes, we do a second search (more bits) to reduce noise even more */ + if (SUBMODE(double_codebook)) { + char *tmp_stack=stack; + VARDECL(spx_sig_t *innov2); + ALLOC(innov2, st->subframeSize, spx_sig_t); + SPEEX_MEMSET(innov2, 0, st->subframeSize); + for (i=0;isubframeSize;i++) + target[i]=MULT16_16_P13(QCONST16(2.2f,13), target[i]); + SUBMODE(innovation_quant)(target, interp_qlpc, bw_lpc1, bw_lpc2, + SUBMODE(innovation_params), st->lpcSize, st->subframeSize, + innov2, syn_resp, bits, stack, st->complexity, 0); + signal_mul(innov2, innov2, MULT16_32_Q15(QCONST16(0.454545f,15),ener), st->subframeSize); + for (i=0;isubframeSize;i++) + innov[i] = ADD32(innov[i],innov2[i]); + stack = tmp_stack; + } + for (i=0;isubframeSize;i++) + exc[i] = EXTRACT16(SATURATE32(PSHR32(ADD32(SHL32(exc32[i],1),innov[i]),SIG_SHIFT),32767)); + if (st->innov_rms_save) + { + st->innov_rms_save[sub] = compute_rms(innov, st->subframeSize); + } + } + + /* Final signal synthesis from excitation */ + iir_mem16(exc, interp_qlpc, sw, st->subframeSize, st->lpcSize, st->mem_sp, stack); + + /* Compute weighted signal again, from synthesized speech (not sure it's the right thing) */ + if (st->complexity!=0) + filter_mem16(sw, bw_lpc1, bw_lpc2, sw, st->subframeSize, st->lpcSize, st->mem_sw, stack); + + } + + /* Store the LSPs for interpolation in the next frame */ + if (st->submodeID>=1) + { + for (i=0;ilpcSize;i++) + st->old_lsp[i] = lsp[i]; + for (i=0;ilpcSize;i++) + st->old_qlsp[i] = qlsp[i]; + } + +#ifdef VORBIS_PSYCHO + if (st->submodeID>=1) + SPEEX_COPY(st->old_curve, st->curve, 128); +#endif + + if (st->submodeID==1) + { +#ifndef DISABLE_VBR + if (st->dtx_count) + speex_bits_pack(bits, 15, 4); + else +#endif + speex_bits_pack(bits, 0, 4); + } + + /* The next frame will not be the first (Duh!) */ + st->first = 0; + SPEEX_COPY(st->winBuf, in+2*st->frameSize-st->windowSize, st->windowSize-st->frameSize); + + if (SUBMODE(innovation_quant) == noise_codebook_quant || st->submodeID==0) + st->bounded_pitch = 1; + else + st->bounded_pitch = 0; + + return 1; +} +#endif /* SPEEX_DISABLE_ENCODER */ + +static DecState global_decstate IBSS_ATTR; + +void *nb_decoder_init(const SpeexMode *m) +{ + DecState *st = &global_decstate; + const SpeexNBMode *mode; + int i; + + mode=(const SpeexNBMode*)m->mode; +/* + st = (DecState *)speex_alloc(sizeof(DecState)); + if (!st) + return NULL; +*/ + memset(st, 0, sizeof(*st)); +#if defined(VAR_ARRAYS) || defined (USE_ALLOCA) + st->stack = NULL; +#else + st->stack = (char*)speex_alloc_scratch(NB_DEC_STACK); +#endif + + st->mode=m; + + + st->encode_submode = 1; + + st->first=1; + /* Codec parameters, should eventually have several "modes"*/ + st->frameSize = mode->frameSize; + st->nbSubframes=mode->frameSize/mode->subframeSize; + st->subframeSize=mode->subframeSize; + st->lpcSize = mode->lpcSize; + st->min_pitch=mode->pitchStart; + st->max_pitch=mode->pitchEnd; + + st->submodes=mode->submodes; + st->submodeID=mode->defaultSubmode; + + st->lpc_enh_enabled=1; + + /* st->excBuf = (spx_word16_t*)speex_alloc((st->frameSize + 2*st->max_pitch + st->subframeSize + 12)*sizeof(spx_word16_t)); */ + st->exc = st->excBuf + 2*st->max_pitch + st->subframeSize + 6; + SPEEX_MEMSET(st->excBuf, 0, st->frameSize + st->max_pitch); + + /* st->interp_qlpc = (spx_coef_t*)speex_alloc(st->lpcSize*sizeof(spx_coef_t)); */ + /* st->old_qlsp = (spx_lsp_t*)speex_alloc(st->lpcSize*sizeof(spx_lsp_t)); */ + /* st->mem_sp = (spx_mem_t*)speex_alloc(st->lpcSize*sizeof(spx_mem_t)); */ + /* st->pi_gain = (spx_word32_t*)speex_alloc((st->nbSubframes)*sizeof(spx_word32_t)); */ + st->last_pitch = 40; + st->count_lost=0; + st->pitch_gain_buf[0] = st->pitch_gain_buf[1] = st->pitch_gain_buf[2] = 0; + st->pitch_gain_buf_idx = 0; + st->seed = 1000; + + st->sampling_rate=8000; + st->last_ol_gain = 0; + + st->user_callback.func = &speex_default_user_handler; + st->user_callback.data = NULL; + for (i=0;i<16;i++) + st->speex_callbacks[i].func = NULL; + + st->voc_m1=st->voc_m2=st->voc_mean=0; + st->voc_offset=0; + st->dtx_enabled=0; + st->isWideband = 0; + st->highpass_enabled = 1; + +#ifdef CPU_COLDFIRE + coldfire_set_macsr(0); // Integer mode +#endif +#ifdef ENABLE_VALGRIND + VALGRIND_MAKE_READABLE(st, NB_DEC_STACK); +#endif + return st; +} + +void nb_decoder_destroy(void *state) +{ +#if !(defined(VAR_ARRAYS) || defined (USE_ALLOCA)) + DecState *st; + st=(DecState*)state; + speex_free_scratch(st->stack); +#else + (void)state; +#endif +/* + speex_free (st->excBuf); + speex_free (st->interp_qlpc); + speex_free (st->old_qlsp); + speex_free (st->mem_sp); + speex_free (st->pi_gain); + + speex_free(state); +*/ +} + +#define median3(a, b, c) ((a) < (b) ? ((b) < (c) ? (b) : ((a) < (c) ? (c) : (a))) : ((c) < (b) ? (b) : ((c) < (a) ? (c) : (a)))) + +#ifdef FIXED_POINT +const spx_word16_t attenuation[10] = {32767, 31483, 27923, 22861, 17278, 12055, 7764, 4616, 2533, 1283}; +#else +const spx_word16_t attenuation[10] = {1., 0.961, 0.852, 0.698, 0.527, 0.368, 0.237, 0.141, 0.077, 0.039}; + +#endif + +#ifndef ROCKBOX_VOICE_CODEC +static void nb_decode_lost(DecState *st, spx_word16_t *out, char *stack) +{ + int i; + int pitch_val; + spx_word16_t pitch_gain; + spx_word16_t fact; + spx_word16_t gain_med; + spx_word16_t innov_gain; + spx_word16_t noise_gain; + + if (st->count_lost<10) + fact = attenuation[st->count_lost]; + else + fact = 0; + + gain_med = median3(st->pitch_gain_buf[0], st->pitch_gain_buf[1], st->pitch_gain_buf[2]); + if (gain_med < st->last_pitch_gain) + st->last_pitch_gain = gain_med; + +#ifdef FIXED_POINT + pitch_gain = st->last_pitch_gain; + if (pitch_gain>54) + pitch_gain = 54; + pitch_gain = SHL16(pitch_gain, 9); +#else + pitch_gain = GAIN_SCALING_1*st->last_pitch_gain; + if (pitch_gain>.85) + pitch_gain=.85; +#endif + pitch_gain = MULT16_16_Q15(fact,pitch_gain) + VERY_SMALL; + /* FIXME: This was rms of innovation (not exc) */ + innov_gain = compute_rms16(st->exc, st->frameSize); + noise_gain = MULT16_16_Q15(innov_gain, MULT16_16_Q15(fact, SUB16(Q15ONE,MULT16_16_Q15(pitch_gain,pitch_gain)))); + /* Shift all buffers by one frame */ + SPEEX_MOVE(st->excBuf, st->excBuf+st->frameSize, 2*st->max_pitch + st->subframeSize + 12); + + + pitch_val = st->last_pitch + SHR32((spx_int32_t)speex_rand(1+st->count_lost, &st->seed),SIG_SHIFT); + if (pitch_val > st->max_pitch) + pitch_val = st->max_pitch; + if (pitch_val < st->min_pitch) + pitch_val = st->min_pitch; + for (i=0;iframeSize;i++) + { + st->exc[i]= MULT16_16_Q15(pitch_gain, (st->exc[i-pitch_val]+VERY_SMALL)) + + speex_rand(noise_gain, &st->seed); + } + + bw_lpc(QCONST16(.98,15), st->interp_qlpc, st->interp_qlpc, st->lpcSize); + iir_mem16(&st->exc[-st->subframeSize], st->interp_qlpc, out, st->frameSize, + st->lpcSize, st->mem_sp, stack); + highpass(out, out, st->frameSize, HIGHPASS_NARROWBAND|HIGHPASS_OUTPUT, st->mem_hp); + + st->first = 0; + st->count_lost++; + st->pitch_gain_buf[st->pitch_gain_buf_idx++] = PSHR16(pitch_gain,9); + if (st->pitch_gain_buf_idx > 2) /* rollover */ + st->pitch_gain_buf_idx = 0; +} +#endif + +/* Just so we don't need to carry the complete wideband mode information */ +static const unsigned short wb_skip_table[8] = {0, 36, 112, 192, 352, 0, 0, 0}; + +int nb_decode(void *state, SpeexBits *bits, void *vout) +{ + DecState *st; + int i, sub; + int pitch; + spx_word16_t pitch_gain[3]; + spx_word32_t ol_gain=0; + int ol_pitch=0; + spx_word16_t ol_pitch_coef=0; + int best_pitch=40; + spx_word16_t best_pitch_gain=0; + int wideband; + int m; + char *stack; + VARDECL(spx_sig_t *innov); + VARDECL(spx_word32_t *exc32); + VARDECL(spx_coef_t *ak); + VARDECL(spx_lsp_t *qlsp); + spx_word16_t pitch_average=0; + + spx_word16_t *out = (spx_word16_t*)vout; + VARDECL(spx_lsp_t *interp_qlsp); + + st=(DecState*)state; + stack=st->stack; + + /* Check if we're in DTX mode*/ + if (!bits && st->dtx_enabled) + { + st->submodeID=0; + } else + { + /* If bits is NULL, consider the packet to be lost (what could we do anyway) */ +#ifndef ROCKBOX_VOICE_CODEC + if (!bits) + { + nb_decode_lost(st, out, stack); + return 0; + } +#endif + + if (st->encode_submode) + { + + /* Search for next narrowband block (handle requests, skip wideband blocks) */ + do { + if (speex_bits_remaining(bits)<5) + return -1; + wideband = speex_bits_unpack_unsigned(bits, 1); + if (wideband) /* Skip wideband block (for compatibility) */ + { + int submode; + int advance; + advance = submode = speex_bits_unpack_unsigned(bits, SB_SUBMODE_BITS); + /*speex_mode_query(&speex_wb_mode, SPEEX_SUBMODE_BITS_PER_FRAME, &advance);*/ + advance = wb_skip_table[submode]; + if (advance < 0) + { + speex_notify("Invalid mode encountered. The stream is corrupted."); + return -2; + } + advance -= (SB_SUBMODE_BITS+1); + speex_bits_advance(bits, advance); + + if (speex_bits_remaining(bits)<5) + return -1; + wideband = speex_bits_unpack_unsigned(bits, 1); + if (wideband) + { + advance = submode = speex_bits_unpack_unsigned(bits, SB_SUBMODE_BITS); + /*speex_mode_query(&speex_wb_mode, SPEEX_SUBMODE_BITS_PER_FRAME, &advance);*/ + advance = wb_skip_table[submode]; + if (advance < 0) + { + speex_notify("Invalid mode encountered. The stream is corrupted."); + return -2; + } + advance -= (SB_SUBMODE_BITS+1); + speex_bits_advance(bits, advance); + wideband = speex_bits_unpack_unsigned(bits, 1); + if (wideband) + { + speex_notify("More than two wideband layers found. The stream is corrupted."); + return -2; + } + + } + } + if (speex_bits_remaining(bits)<4) + return -1; + /* FIXME: Check for overflow */ + m = speex_bits_unpack_unsigned(bits, 4); + if (m==15) /* We found a terminator */ + { + return -1; + } else if (m==14) /* Speex in-band request */ + { + int ret = speex_inband_handler(bits, st->speex_callbacks, state); + if (ret) + return ret; + } else if (m==13) /* User in-band request */ + { + int ret = st->user_callback.func(bits, state, st->user_callback.data); + if (ret) + return ret; + } else if (m>8) /* Invalid mode */ + { + speex_notify("Invalid mode encountered. The stream is corrupted."); + return -2; + } + + } while (m>8); + + /* Get the sub-mode that was used */ + st->submodeID = m; + } + + } + + /* Shift all buffers by one frame */ + SPEEX_MOVE(st->excBuf, st->excBuf+st->frameSize, 2*st->max_pitch + st->subframeSize + 12); + + /* If null mode (no transmission), just set a couple things to zero*/ + if (st->submodes[st->submodeID] == NULL) + { + VARDECL(spx_coef_t *lpc); + ALLOC(lpc, st->lpcSize, spx_coef_t); + bw_lpc(QCONST16(0.93f,15), st->interp_qlpc, lpc, st->lpcSize); + { + spx_word16_t innov_gain=0; + /* FIXME: This was innov, not exc */ + innov_gain = compute_rms16(st->exc, st->frameSize); + for (i=0;iframeSize;i++) + st->exc[i]=speex_rand(innov_gain, &st->seed); + } + + + st->first=1; + + /* Final signal synthesis from excitation */ + iir_mem16(st->exc, lpc, out, st->frameSize, st->lpcSize, st->mem_sp, stack); + + st->count_lost=0; + return 0; + } + + ALLOC(qlsp, st->lpcSize, spx_lsp_t); + + /* Unquantize LSPs */ + SUBMODE(lsp_unquant)(qlsp, st->lpcSize, bits); + + /*Damp memory if a frame was lost and the LSP changed too much*/ + if (st->count_lost) + { + spx_word16_t fact; + spx_word32_t lsp_dist=0; + for (i=0;ilpcSize;i++) + lsp_dist = ADD32(lsp_dist, EXTEND32(ABS(st->old_qlsp[i] - qlsp[i]))); +#ifdef FIXED_POINT + fact = SHR16(19661,SHR32(lsp_dist,LSP_SHIFT+2)); +#else + fact = .6*exp(-.2*lsp_dist); +#endif + for (i=0;ilpcSize;i++) + st->mem_sp[i] = MULT16_32_Q15(fact,st->mem_sp[i]); + } + + + /* Handle first frame and lost-packet case */ + if (st->first || st->count_lost) + { + for (i=0;ilpcSize;i++) + st->old_qlsp[i] = qlsp[i]; + } + + /* Get open-loop pitch estimation for low bit-rate pitch coding */ + if (SUBMODE(lbr_pitch)!=-1) + { + ol_pitch = st->min_pitch+speex_bits_unpack_unsigned(bits, 7); + } + + if (SUBMODE(forced_pitch_gain)) + { + int quant; + quant = speex_bits_unpack_unsigned(bits, 4); + ol_pitch_coef=MULT16_16_P15(QCONST16(0.066667,15),SHL16(quant,GAIN_SHIFT)); + } + + /* Get global excitation gain */ + { + int qe; + qe = speex_bits_unpack_unsigned(bits, 5); +#ifdef FIXED_POINT + /* FIXME: Perhaps we could slightly lower the gain here when the output is going to saturate? */ + ol_gain = MULT16_32_Q15(28406,ol_gain_table[qe]); +#else + ol_gain = SIG_SCALING*exp(qe/3.5); +#endif + } + + ALLOC(ak, st->lpcSize, spx_coef_t); + ALLOC(innov, st->subframeSize, spx_sig_t); + ALLOC(exc32, st->subframeSize, spx_word32_t); + + if (st->submodeID==1) + { + int extra; + extra = speex_bits_unpack_unsigned(bits, 4); + + if (extra==15) + st->dtx_enabled=1; + else + st->dtx_enabled=0; + } + if (st->submodeID>1) + st->dtx_enabled=0; + + /*Loop on subframes */ + for (sub=0;subnbSubframes;sub++) + { + int offset; + spx_word16_t *exc; + spx_word16_t *innov_save = NULL; + spx_word16_t tmp; + + /* Offset relative to start of frame */ + offset = st->subframeSize*sub; + /* Excitation */ + exc=st->exc+offset; + + if (st->innov_save) + innov_save = st->innov_save+offset; + + + /* Reset excitation */ + SPEEX_MEMSET(exc, 0, st->subframeSize); + + /*Adaptive codebook contribution*/ + speex_assert (SUBMODE(ltp_unquant)); + { + int pit_min, pit_max; + /* Handle pitch constraints if any */ + if (SUBMODE(lbr_pitch) != -1) + { + int margin; + margin = SUBMODE(lbr_pitch); + if (margin) + { +/* GT - need optimization? + if (ol_pitch < st->min_pitch+margin-1) + ol_pitch=st->min_pitch+margin-1; + if (ol_pitch > st->max_pitch-margin) + ol_pitch=st->max_pitch-margin; + pit_min = ol_pitch-margin+1; + pit_max = ol_pitch+margin; +*/ + pit_min = ol_pitch-margin+1; + if (pit_min < st->min_pitch) + pit_min = st->min_pitch; + pit_max = ol_pitch+margin; + if (pit_max > st->max_pitch) + pit_max = st->max_pitch; + } else { + pit_min = pit_max = ol_pitch; + } + } else { + pit_min = st->min_pitch; + pit_max = st->max_pitch; + } + + + + SUBMODE(ltp_unquant)(exc, exc32, pit_min, pit_max, ol_pitch_coef, SUBMODE(ltp_params), + st->subframeSize, &pitch, &pitch_gain[0], bits, stack, + st->count_lost, offset, st->last_pitch_gain, 0); + + /* Ensuring that things aren't blowing up as would happen if e.g. an encoder is + crafting packets to make us produce NaNs and slow down the decoder (vague DoS threat). + We can probably be even more aggressive and limit to 15000 or so. */ + sanitize_values32(exc32, NEG32(QCONST32(32000,SIG_SHIFT-1)), QCONST32(32000,SIG_SHIFT-1), st->subframeSize); + + tmp = gain_3tap_to_1tap(pitch_gain); + + pitch_average += tmp; + if ((tmp>best_pitch_gain&&ABS(2*best_pitch-pitch)>=3&&ABS(3*best_pitch-pitch)>=4&&ABS(4*best_pitch-pitch)>=5) + || (tmp>MULT16_16_Q15(QCONST16(.6,15),best_pitch_gain)&&(ABS(best_pitch-2*pitch)<3||ABS(best_pitch-3*pitch)<4||ABS(best_pitch-4*pitch)<5)) + || (MULT16_16_Q15(QCONST16(.67,15),tmp)>best_pitch_gain&&(ABS(2*best_pitch-pitch)<3||ABS(3*best_pitch-pitch)<4||ABS(4*best_pitch-pitch)<5)) ) + { + best_pitch = pitch; + if (tmp > best_pitch_gain) + best_pitch_gain = tmp; + } + } + + /* Unquantize the innovation */ + { + int q_energy; + spx_word32_t ener; + + SPEEX_MEMSET(innov, 0, st->subframeSize); + + /* Decode sub-frame gain correction */ + if (SUBMODE(have_subframe_gain)==3) + { + q_energy = speex_bits_unpack_unsigned(bits, 3); + ener = MULT16_32_Q14(exc_gain_quant_scal3[q_energy],ol_gain); + } else if (SUBMODE(have_subframe_gain)==1) + { + q_energy = speex_bits_unpack_unsigned(bits, 1); + ener = MULT16_32_Q14(exc_gain_quant_scal1[q_energy],ol_gain); + } else { + ener = ol_gain; + } + + speex_assert (SUBMODE(innovation_unquant)); + { + /*Fixed codebook contribution*/ + SUBMODE(innovation_unquant)(innov, SUBMODE(innovation_params), st->subframeSize, bits, stack, &st->seed); + /* De-normalize innovation and update excitation */ + + signal_mul(innov, innov, ener, st->subframeSize); + + /* Decode second codebook (only for some modes) */ + if (SUBMODE(double_codebook)) + { + char *tmp_stack=stack; + VARDECL(spx_sig_t *innov2); + ALLOC(innov2, st->subframeSize, spx_sig_t); + SPEEX_MEMSET(innov2, 0, st->subframeSize); + SUBMODE(innovation_unquant)(innov2, SUBMODE(innovation_params), st->subframeSize, bits, stack, &st->seed); + signal_mul(innov2, innov2, MULT16_32_Q15(QCONST16(0.454545f,15),ener), st->subframeSize); + for (i=0;isubframeSize;i++) + innov[i] = ADD32(innov[i], innov2[i]); + stack = tmp_stack; + } + for (i=0;isubframeSize;i++) + exc[i]=EXTRACT16(SATURATE32(PSHR32(ADD32(SHL32(exc32[i],1),innov[i]),SIG_SHIFT),32767)); + /*print_vec(exc, 40, "innov");*/ + if (innov_save) + { + for (i=0;isubframeSize;i++) + innov_save[i] = EXTRACT16(PSHR32(innov[i], SIG_SHIFT)); + } + } + + /*Vocoder mode*/ + if (st->submodeID==1) + { + spx_word16_t g=ol_pitch_coef; + g=MULT16_16_P14(QCONST16(1.5f,14),(g-QCONST16(.2f,6))); + if (g<0) + g=0; + if (g>GAIN_SCALING) + g=GAIN_SCALING; + + SPEEX_MEMSET(exc, 0, st->subframeSize); + while (st->voc_offsetsubframeSize) + { + /* exc[st->voc_offset]= g*sqrt(2*ol_pitch)*ol_gain; + Not quite sure why we need the factor of two in the sqrt */ + if (st->voc_offset>=0) + exc[st->voc_offset]=MULT16_16(spx_sqrt(MULT16_16_16(2,ol_pitch)),EXTRACT16(PSHR32(MULT16_16(g,PSHR32(ol_gain,SIG_SHIFT)),6))); + st->voc_offset+=ol_pitch; + } + st->voc_offset -= st->subframeSize; + + for (i=0;isubframeSize;i++) + { + spx_word16_t exci=exc[i]; + exc[i]= ADD16(ADD16(MULT16_16_Q15(QCONST16(.7f,15),exc[i]) , MULT16_16_Q15(QCONST16(.3f,15),st->voc_m1)), + SUB16(MULT16_16_Q15(Q15_ONE-MULT16_16_16(QCONST16(.85f,9),g),EXTRACT16(PSHR32(innov[i],SIG_SHIFT))), + MULT16_16_Q15(MULT16_16_16(QCONST16(.15f,9),g),EXTRACT16(PSHR32(st->voc_m2,SIG_SHIFT))) + )); + st->voc_m1 = exci; + st->voc_m2=innov[i]; + st->voc_mean = EXTRACT16(PSHR32(ADD32(MULT16_16(QCONST16(.8f,15),st->voc_mean), MULT16_16(QCONST16(.2f,15),exc[i])), 15)); + exc[i]-=st->voc_mean; + } + } + + } + } + + ALLOC(interp_qlsp, st->lpcSize, spx_lsp_t); + + if (st->lpc_enh_enabled && SUBMODE(comb_gain)>0 && !st->count_lost) + { + multicomb(st->exc-st->subframeSize, out, st->interp_qlpc, st->lpcSize, 2*st->subframeSize, best_pitch, 40, SUBMODE(comb_gain), stack); + multicomb(st->exc+st->subframeSize, out+2*st->subframeSize, st->interp_qlpc, st->lpcSize, 2*st->subframeSize, best_pitch, 40, SUBMODE(comb_gain), stack); + } else { + SPEEX_COPY(out, &st->exc[-st->subframeSize], st->frameSize); + } + + /* If the last packet was lost, re-scale the excitation to obtain the same energy as encoded in ol_gain */ + if (st->count_lost) + { + spx_word16_t exc_ener; + spx_word32_t gain32; + spx_word16_t gain; + exc_ener = compute_rms16 (st->exc, st->frameSize); + gain32 = PDIV32(ol_gain, ADD16(exc_ener,1)); +#ifdef FIXED_POINT + if (gain32 > 32767) + gain32 = 32767; + gain = EXTRACT16(gain32); +#else + if (gain32 > 2) + gain32=2; + gain = gain32; +#endif + for (i=0;iframeSize;i++) + { + st->exc[i] = MULT16_16_Q14(gain, st->exc[i]); + out[i]=st->exc[i-st->subframeSize]; + } + } + + /*Loop on subframes */ + for (sub=0;subnbSubframes;sub++) + { + int offset; + spx_word16_t *sp; + + /* Offset relative to start of frame */ + offset = st->subframeSize*sub; + /* Original signal */ + sp=out+offset; + + /* LSP interpolation (quantized and unquantized) */ + lsp_interpolate(st->old_qlsp, qlsp, interp_qlsp, st->lpcSize, sub, st->nbSubframes); + + /* Make sure the LSP's are stable */ + lsp_enforce_margin(interp_qlsp, st->lpcSize, LSP_MARGIN); + + /* Compute interpolated LPCs (unquantized) */ + lsp_to_lpc(interp_qlsp, ak, st->lpcSize, stack); + + /* Compute analysis filter at w=pi */ + { + spx_word32_t pi_g=LPC_SCALING; + for (i=0;ilpcSize;i+=2) + { + /*pi_g += -st->interp_qlpc[i] + st->interp_qlpc[i+1];*/ + pi_g = ADD32(pi_g, SUB32(EXTEND32(ak[i+1]),EXTEND32(ak[i]))); + } + st->pi_gain[sub] = pi_g; + } + + iir_mem16(sp, st->interp_qlpc, sp, st->subframeSize, st->lpcSize, + st->mem_sp, stack); + + for (i=0;ilpcSize;i++) + st->interp_qlpc[i] = ak[i]; + + } + + if (st->highpass_enabled) + highpass(out, out, st->frameSize, (st->isWideband?HIGHPASS_WIDEBAND:HIGHPASS_NARROWBAND)|HIGHPASS_OUTPUT, st->mem_hp); + /*for (i=0;iframeSize;i++) + printf ("%d\n", (int)st->frame[i]);*/ + + /* Tracking output level */ + st->level = 1+PSHR32(ol_gain,SIG_SHIFT); + st->max_level = MAX16(MULT16_16_Q15(QCONST16(.99f,15), st->max_level), st->level); + st->min_level = MIN16(ADD16(1,MULT16_16_Q14(QCONST16(1.01f,14), st->min_level)), st->level); + if (st->max_level < st->min_level+1) + st->max_level = st->min_level+1; + /*printf ("%f %f %f %d\n", og, st->min_level, st->max_level, update);*/ + + /* Store the LSPs for interpolation in the next frame */ + for (i=0;ilpcSize;i++) + st->old_qlsp[i] = qlsp[i]; + + /* The next frame will not be the first (Duh!) */ + st->first = 0; + st->count_lost=0; + st->last_pitch = best_pitch; +#ifdef FIXED_POINT + st->last_pitch_gain = PSHR16(pitch_average,2); +#else + st->last_pitch_gain = .25*pitch_average; +#endif + st->pitch_gain_buf[st->pitch_gain_buf_idx++] = st->last_pitch_gain; + if (st->pitch_gain_buf_idx > 2) /* rollover */ + st->pitch_gain_buf_idx = 0; + + st->last_ol_gain = ol_gain; + + return 0; +} + +#ifndef SPEEX_DISABLE_ENCODER +int nb_encoder_ctl(void *state, int request, void *ptr) +{ + EncState *st; + st=(EncState*)state; + switch(request) + { + case SPEEX_GET_FRAME_SIZE: + (*(spx_int32_t*)ptr) = st->frameSize; + break; + case SPEEX_SET_LOW_MODE: + case SPEEX_SET_MODE: + st->submodeSelect = st->submodeID = (*(spx_int32_t*)ptr); + break; + case SPEEX_GET_LOW_MODE: + case SPEEX_GET_MODE: + (*(spx_int32_t*)ptr) = st->submodeID; + break; +#ifndef DISABLE_VBR + case SPEEX_SET_VBR: + st->vbr_enabled = (*(spx_int32_t*)ptr); + break; + case SPEEX_GET_VBR: + (*(spx_int32_t*)ptr) = st->vbr_enabled; + break; + case SPEEX_SET_VAD: + st->vad_enabled = (*(spx_int32_t*)ptr); + break; + case SPEEX_GET_VAD: + (*(spx_int32_t*)ptr) = st->vad_enabled; + break; + case SPEEX_SET_DTX: + st->dtx_enabled = (*(spx_int32_t*)ptr); + break; + case SPEEX_GET_DTX: + (*(spx_int32_t*)ptr) = st->dtx_enabled; + break; + case SPEEX_SET_ABR: + st->abr_enabled = (*(spx_int32_t*)ptr); + st->vbr_enabled = st->abr_enabled!=0; + if (st->vbr_enabled) + { + spx_int32_t i=10; + spx_int32_t rate, target; + float vbr_qual; + target = (*(spx_int32_t*)ptr); + while (i>=0) + { + speex_encoder_ctl(st, SPEEX_SET_QUALITY, &i); + speex_encoder_ctl(st, SPEEX_GET_BITRATE, &rate); + if (rate <= target) + break; + i--; + } + vbr_qual=i; + if (vbr_qual<0) + vbr_qual=0; + speex_encoder_ctl(st, SPEEX_SET_VBR_QUALITY, &vbr_qual); + st->abr_count=0; + st->abr_drift=0; + st->abr_drift2=0; + } + + break; + case SPEEX_GET_ABR: + (*(spx_int32_t*)ptr) = st->abr_enabled; + break; +#endif /* #ifndef DISABLE_VBR */ +#if !defined(DISABLE_VBR) && !defined(DISABLE_FLOAT_API) + case SPEEX_SET_VBR_QUALITY: + st->vbr_quality = (*(float*)ptr); + break; + case SPEEX_GET_VBR_QUALITY: + (*(float*)ptr) = st->vbr_quality; + break; +#endif /* !defined(DISABLE_VBR) && !defined(DISABLE_FLOAT_API) */ + case SPEEX_SET_QUALITY: + { + int quality = (*(spx_int32_t*)ptr); + if (quality < 0) + quality = 0; + if (quality > 10) + quality = 10; + st->submodeSelect = st->submodeID = ((const SpeexNBMode*)(st->mode->mode))->quality_map[quality]; + } + break; + case SPEEX_SET_COMPLEXITY: + st->complexity = (*(spx_int32_t*)ptr); + if (st->complexity<0) + st->complexity=0; + break; + case SPEEX_GET_COMPLEXITY: + (*(spx_int32_t*)ptr) = st->complexity; + break; + case SPEEX_SET_BITRATE: + { + spx_int32_t i=10; + spx_int32_t rate, target; + target = (*(spx_int32_t*)ptr); + while (i>=0) + { + speex_encoder_ctl(st, SPEEX_SET_QUALITY, &i); + speex_encoder_ctl(st, SPEEX_GET_BITRATE, &rate); + if (rate <= target) + break; + i--; + } + } + break; + case SPEEX_GET_BITRATE: + if (st->submodes[st->submodeID]) + (*(spx_int32_t*)ptr) = st->sampling_rate*SUBMODE(bits_per_frame)/st->frameSize; + else + (*(spx_int32_t*)ptr) = st->sampling_rate*(NB_SUBMODE_BITS+1)/st->frameSize; + break; + case SPEEX_SET_SAMPLING_RATE: + st->sampling_rate = (*(spx_int32_t*)ptr); + break; + case SPEEX_GET_SAMPLING_RATE: + (*(spx_int32_t*)ptr)=st->sampling_rate; + break; + case SPEEX_RESET_STATE: + { + int i; + st->bounded_pitch = 1; + st->first = 1; + for (i=0;ilpcSize;i++) + st->old_lsp[i]= DIV32(MULT16_16(QCONST16(3.1415927f, LSP_SHIFT), i+1), st->lpcSize+1); + for (i=0;ilpcSize;i++) + st->mem_sw[i]=st->mem_sw_whole[i]=st->mem_sp[i]=st->mem_exc[i]=0; + for (i=0;iframeSize+st->max_pitch+1;i++) + st->excBuf[i]=st->swBuf[i]=0; + for (i=0;iwindowSize-st->frameSize;i++) + st->winBuf[i]=0; + } + break; + case SPEEX_SET_SUBMODE_ENCODING: + st->encode_submode = (*(spx_int32_t*)ptr); + break; + case SPEEX_GET_SUBMODE_ENCODING: + (*(spx_int32_t*)ptr) = st->encode_submode; + break; + case SPEEX_GET_LOOKAHEAD: + (*(spx_int32_t*)ptr)=(st->windowSize-st->frameSize); + break; + case SPEEX_SET_PLC_TUNING: + st->plc_tuning = (*(spx_int32_t*)ptr); + if (st->plc_tuning>100) + st->plc_tuning=100; + break; + case SPEEX_GET_PLC_TUNING: + (*(spx_int32_t*)ptr)=(st->plc_tuning); + break; +#ifndef DISABLE_VBR + case SPEEX_SET_VBR_MAX_BITRATE: + st->vbr_max = (*(spx_int32_t*)ptr); + break; + case SPEEX_GET_VBR_MAX_BITRATE: + (*(spx_int32_t*)ptr) = st->vbr_max; + break; +#endif /* #ifndef DISABLE_VBR */ + case SPEEX_SET_HIGHPASS: + st->highpass_enabled = (*(spx_int32_t*)ptr); + break; + case SPEEX_GET_HIGHPASS: + (*(spx_int32_t*)ptr) = st->highpass_enabled; + break; + + /* This is all internal stuff past this point */ + case SPEEX_GET_PI_GAIN: + { + int i; + spx_word32_t *g = (spx_word32_t*)ptr; + for (i=0;inbSubframes;i++) + g[i]=st->pi_gain[i]; + } + break; + case SPEEX_GET_EXC: + { + int i; + for (i=0;inbSubframes;i++) + ((spx_word16_t*)ptr)[i] = compute_rms16(st->exc+i*st->subframeSize, st->subframeSize); + } + break; +#ifndef DISABLE_VBR + case SPEEX_GET_RELATIVE_QUALITY: + (*(float*)ptr)=st->relative_quality; + break; +#endif /* #ifndef DISABLE_VBR */ + case SPEEX_SET_INNOVATION_SAVE: + st->innov_rms_save = (spx_word16_t*)ptr; + break; + case SPEEX_SET_WIDEBAND: + st->isWideband = *((spx_int32_t*)ptr); + break; + case SPEEX_GET_STACK: + *((char**)ptr) = st->stack; + break; + default: + speex_warning_int("Unknown nb_ctl request: ", request); + return -1; + } + return 0; +} +#endif /* SPEEX_DISABLE_ENCODER */ + +int nb_decoder_ctl(void *state, int request, void *ptr) +{ + DecState *st; + st=(DecState*)state; + switch(request) + { + case SPEEX_SET_LOW_MODE: + case SPEEX_SET_MODE: + st->submodeID = (*(spx_int32_t*)ptr); + break; + case SPEEX_GET_LOW_MODE: + case SPEEX_GET_MODE: + (*(spx_int32_t*)ptr) = st->submodeID; + break; + case SPEEX_SET_ENH: + st->lpc_enh_enabled = *((spx_int32_t*)ptr); + break; + case SPEEX_GET_ENH: + *((spx_int32_t*)ptr) = st->lpc_enh_enabled; + break; + case SPEEX_GET_FRAME_SIZE: + (*(spx_int32_t*)ptr) = st->frameSize; + break; + case SPEEX_GET_BITRATE: + if (st->submodes[st->submodeID]) + (*(spx_int32_t*)ptr) = st->sampling_rate*SUBMODE(bits_per_frame)/st->frameSize; + else + (*(spx_int32_t*)ptr) = st->sampling_rate*(NB_SUBMODE_BITS+1)/st->frameSize; + break; + case SPEEX_SET_SAMPLING_RATE: + st->sampling_rate = (*(spx_int32_t*)ptr); + break; + case SPEEX_GET_SAMPLING_RATE: + (*(spx_int32_t*)ptr)=st->sampling_rate; + break; + case SPEEX_SET_HANDLER: + { + SpeexCallback *c = (SpeexCallback*)ptr; + st->speex_callbacks[c->callback_id].func=c->func; + st->speex_callbacks[c->callback_id].data=c->data; + st->speex_callbacks[c->callback_id].callback_id=c->callback_id; + } + break; + case SPEEX_SET_USER_HANDLER: + { + SpeexCallback *c = (SpeexCallback*)ptr; + st->user_callback.func=c->func; + st->user_callback.data=c->data; + st->user_callback.callback_id=c->callback_id; + } + break; + case SPEEX_RESET_STATE: + { + int i; + for (i=0;ilpcSize;i++) + st->mem_sp[i]=0; + for (i=0;iframeSize + st->max_pitch + 1;i++) + st->excBuf[i]=0; + } + break; + case SPEEX_SET_SUBMODE_ENCODING: + st->encode_submode = (*(spx_int32_t*)ptr); + break; + case SPEEX_GET_SUBMODE_ENCODING: + (*(spx_int32_t*)ptr) = st->encode_submode; + break; + case SPEEX_GET_LOOKAHEAD: + (*(spx_int32_t*)ptr)=st->subframeSize; + break; + case SPEEX_SET_HIGHPASS: + st->highpass_enabled = (*(spx_int32_t*)ptr); + break; + case SPEEX_GET_HIGHPASS: + (*(spx_int32_t*)ptr) = st->highpass_enabled; + break; + /* FIXME: Convert to fixed-point and re-enable even when float API is disabled */ +#ifndef DISABLE_FLOAT_API + case SPEEX_GET_ACTIVITY: + { + float ret; + ret = log(st->level/st->min_level)/log(st->max_level/st->min_level); + if (ret>1) + ret = 1; + /* Done in a strange way to catch NaNs as well */ + if (!(ret > 0)) + ret = 0; + /*printf ("%f %f %f %f\n", st->level, st->min_level, st->max_level, ret);*/ + (*(spx_int32_t*)ptr) = (int)(100*ret); + } + break; +#endif + case SPEEX_GET_PI_GAIN: + { + int i; + spx_word32_t *g = (spx_word32_t*)ptr; + for (i=0;inbSubframes;i++) + g[i]=st->pi_gain[i]; + } + break; + case SPEEX_GET_EXC: + { + int i; + for (i=0;inbSubframes;i++) + ((spx_word16_t*)ptr)[i] = compute_rms16(st->exc+i*st->subframeSize, st->subframeSize); + } + break; + case SPEEX_GET_DTX_STATUS: + *((spx_int32_t*)ptr) = st->dtx_enabled; + break; + case SPEEX_SET_INNOVATION_SAVE: + st->innov_save = (spx_word16_t*)ptr; + break; + case SPEEX_SET_WIDEBAND: + st->isWideband = *((spx_int32_t*)ptr); + break; + case SPEEX_GET_STACK: + *((char**)ptr) = st->stack; + break; + default: + speex_warning_int("Unknown nb_ctl request: ", request); + return -1; + } + return 0; +} diff --git a/lib/rbcodec/codecs/libspeex/nb_celp.h b/lib/rbcodec/codecs/libspeex/nb_celp.h new file mode 100644 index 0000000000..30edbefaeb --- /dev/null +++ b/lib/rbcodec/codecs/libspeex/nb_celp.h @@ -0,0 +1,205 @@ +/* Copyright (C) 2002-2006 Jean-Marc Valin */ +/** + @file nb_celp.h + @brief Narrowband CELP encoder/decoder +*/ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + - Neither the name of the Xiph.org Foundation nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + +#ifndef NB_CELP_H +#define NB_CELP_H + +#include "modes.h" +#include "speex/speex_bits.h" +#include "speex/speex_callbacks.h" +#include "vbr.h" +#include "filters.h" + +#ifdef VORBIS_PSYCHO +#include "vorbis_psy.h" +#endif + +/**Structure representing the full state of the narrowband encoder*/ +typedef struct EncState { + const SpeexMode *mode; /**< Mode corresponding to the state */ + int first; /**< Is this the first frame? */ + int frameSize; /**< Size of frames */ + int subframeSize; /**< Size of sub-frames */ + int nbSubframes; /**< Number of sub-frames */ + int windowSize; /**< Analysis (LPC) window length */ + int lpcSize; /**< LPC order */ + int min_pitch; /**< Minimum pitch value allowed */ + int max_pitch; /**< Maximum pitch value allowed */ + + spx_word32_t cumul_gain; /**< Product of previously used pitch gains (Q10) */ + int bounded_pitch; /**< Next frame should not rely on previous frames for pitch */ + int ol_pitch; /**< Open-loop pitch */ + int ol_voiced; /**< Open-loop voiced/non-voiced decision */ + int *pitch; + +#ifdef VORBIS_PSYCHO + VorbisPsy *psy; + float *psy_window; + float *curve; + float *old_curve; +#endif + + spx_word16_t gamma1; /**< Perceptual filter: A(z/gamma1) */ + spx_word16_t gamma2; /**< Perceptual filter: A(z/gamma2) */ + spx_word16_t lpc_floor; /**< Noise floor multiplier for A[0] in LPC analysis*/ + char *stack; /**< Pseudo-stack allocation for temporary memory */ + spx_word16_t *winBuf; /**< Input buffer (original signal) */ + spx_word16_t *excBuf; /**< Excitation buffer */ + spx_word16_t *exc; /**< Start of excitation frame */ + spx_word16_t *swBuf; /**< Weighted signal buffer */ + spx_word16_t *sw; /**< Start of weighted signal frame */ + const spx_word16_t *window; /**< Temporary (Hanning) window */ + const spx_word16_t *lagWindow; /**< Window applied to auto-correlation */ + spx_lsp_t *old_lsp; /**< LSPs for previous frame */ + spx_lsp_t *old_qlsp; /**< Quantized LSPs for previous frame */ + spx_mem_t *mem_sp; /**< Filter memory for signal synthesis */ + spx_mem_t *mem_sw; /**< Filter memory for perceptually-weighted signal */ + spx_mem_t *mem_sw_whole; /**< Filter memory for perceptually-weighted signal (whole frame)*/ + spx_mem_t *mem_exc; /**< Filter memory for excitation (whole frame) */ + spx_mem_t *mem_exc2; /**< Filter memory for excitation (whole frame) */ + spx_mem_t mem_hp[2]; /**< High-pass filter memory */ + spx_word32_t *pi_gain; /**< Gain of LPC filter at theta=pi (fe/2) */ + spx_word16_t *innov_rms_save; /**< If non-NULL, innovation RMS is copied here */ + +#ifndef DISABLE_VBR + VBRState *vbr; /**< State of the VBR data */ + float vbr_quality; /**< Quality setting for VBR encoding */ + float relative_quality; /**< Relative quality that will be needed by VBR */ + spx_int32_t vbr_enabled; /**< 1 for enabling VBR, 0 otherwise */ + spx_int32_t vbr_max; /**< Max bit-rate allowed in VBR mode */ + int vad_enabled; /**< 1 for enabling VAD, 0 otherwise */ + int dtx_enabled; /**< 1 for enabling DTX, 0 otherwise */ + int dtx_count; /**< Number of consecutive DTX frames */ + spx_int32_t abr_enabled; /**< ABR setting (in bps), 0 if off */ + float abr_drift; + float abr_drift2; + float abr_count; +#endif /* #ifndef DISABLE_VBR */ + + int complexity; /**< Complexity setting (0-10 from least complex to most complex) */ + spx_int32_t sampling_rate; + int plc_tuning; + int encode_submode; + const SpeexSubmode * const *submodes; /**< Sub-mode data */ + int submodeID; /**< Activated sub-mode */ + int submodeSelect; /**< Mode chosen by the user (may differ from submodeID if VAD is on) */ + int isWideband; /**< Is this used as part of the embedded wideband codec */ + int highpass_enabled; /**< Is the input filter enabled */ +} EncState; + +/**Structure representing the full state of the narrowband decoder*/ +typedef struct DecState { + const SpeexMode *mode; /**< Mode corresponding to the state */ + int first; /**< Is this the first frame? */ + int count_lost; /**< Was the last frame lost? */ + int frameSize; /**< Size of frames */ + int subframeSize; /**< Size of sub-frames */ + int nbSubframes; /**< Number of sub-frames */ + int lpcSize; /**< LPC order */ + int min_pitch; /**< Minimum pitch value allowed */ + int max_pitch; /**< Maximum pitch value allowed */ + spx_int32_t sampling_rate; + + spx_word16_t last_ol_gain; /**< Open-loop gain for previous frame */ + + char *stack; /**< Pseudo-stack allocation for temporary memory */ + /* Size calculated from maximum values of frameSize, max_pitch and + * subframeSize, being respectively 160, 144 and 40 */ + spx_word16_t excBuf[500]; /**< Excitation buffer */ + spx_word16_t *exc; /**< Start of excitation frame */ + spx_lsp_t old_qlsp[10]; /**< Quantized LSPs for previous frame */ + spx_coef_t interp_qlpc[10]; /**< Interpolated quantized LPCs */ + spx_mem_t mem_sp[10]; /**< Filter memory for synthesis signal */ + spx_mem_t mem_hp[2]; /**< High-pass filter memory */ + spx_word32_t pi_gain[4]; /**< Gain of LPC filter at theta=pi (fe/2) */ + spx_word16_t *innov_save; /** If non-NULL, innovation is copied here */ + + spx_word16_t level; + spx_word16_t max_level; + spx_word16_t min_level; + + /* This is used in packet loss concealment */ + int last_pitch; /**< Pitch of last correctly decoded frame */ + spx_word16_t last_pitch_gain; /**< Pitch gain of last correctly decoded frame */ + spx_word16_t pitch_gain_buf[3]; /**< Pitch gain of last decoded frames */ + int pitch_gain_buf_idx; /**< Tail of the buffer */ + spx_int32_t seed; /** Seed used for random number generation */ + + int encode_submode; + const SpeexSubmode * const *submodes; /**< Sub-mode data */ + int submodeID; /**< Activated sub-mode */ + int lpc_enh_enabled; /**< 1 when LPC enhancer is on, 0 otherwise */ + SpeexCallback speex_callbacks[SPEEX_MAX_CALLBACKS]; + + SpeexCallback user_callback; + + /*Vocoder data*/ + spx_word16_t voc_m1; + spx_word32_t voc_m2; + spx_word16_t voc_mean; + int voc_offset; + + int dtx_enabled; + int isWideband; /**< Is this used as part of the embedded wideband codec */ + int highpass_enabled; /**< Is the input filter enabled */ +} DecState; + +/** Initializes encoder state*/ +void *nb_encoder_init(const SpeexMode *m); + +/** De-allocates encoder state resources*/ +void nb_encoder_destroy(void *state); + +/** Encodes one frame*/ +int nb_encode(void *state, void *in, SpeexBits *bits); + + +/** Initializes decoder state*/ +void *nb_decoder_init(const SpeexMode *m); + +/** De-allocates decoder state resources*/ +void nb_decoder_destroy(void *state); + +/** Decodes one frame*/ +int nb_decode(void *state, SpeexBits *bits, void *out); + +/** ioctl-like function for controlling a narrowband encoder */ +int nb_encoder_ctl(void *state, int request, void *ptr); + +/** ioctl-like function for controlling a narrowband decoder */ +int nb_decoder_ctl(void *state, int request, void *ptr); + + +#endif diff --git a/lib/rbcodec/codecs/libspeex/oggframing.c b/lib/rbcodec/codecs/libspeex/oggframing.c new file mode 100644 index 0000000000..42d29502a8 --- /dev/null +++ b/lib/rbcodec/codecs/libspeex/oggframing.c @@ -0,0 +1,909 @@ +/******************************************************************** + * * + * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * + * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * + * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * + * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * + * * + * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2002 * + * by the Xiph.Org Foundation http://www.xiph.org/ * + * * + ******************************************************************** + + function: code raw [Vorbis] packets into framed OggSquish stream and + decode Ogg streams back into raw packets + last mod: $Id$ + + note: The CRC code is directly derived from public domain code by + Ross Williams (ross@guest.adelaide.edu.au). See docs/framing.html + for details. + + ********************************************************************/ + +//#include "config-tremor.h" +#include +#include "speex/ogg.h" +#include "arch.h" + +/* A complete description of Ogg framing exists in docs/framing.html */ + +int spx_ogg_page_version(spx_ogg_page *og){ + return((int)(og->header[4])); +} + +int spx_ogg_page_continued(spx_ogg_page *og){ + return((int)(og->header[5]&0x01)); +} + +int spx_ogg_page_bos(spx_ogg_page *og){ + return((int)(og->header[5]&0x02)); +} + +int spx_ogg_page_eos(spx_ogg_page *og){ + return((int)(og->header[5]&0x04)); +} + +spx_ogg_int64_t spx_ogg_page_granulepos(spx_ogg_page *og){ + unsigned char *page=og->header; + spx_ogg_int64_t granulepos=page[13]&(0xff); + granulepos= (granulepos<<8)|(page[12]&0xff); + granulepos= (granulepos<<8)|(page[11]&0xff); + granulepos= (granulepos<<8)|(page[10]&0xff); + granulepos= (granulepos<<8)|(page[9]&0xff); + granulepos= (granulepos<<8)|(page[8]&0xff); + granulepos= (granulepos<<8)|(page[7]&0xff); + granulepos= (granulepos<<8)|(page[6]&0xff); + return(granulepos); +} + +int spx_ogg_page_serialno(spx_ogg_page *og){ + return(og->header[14] | + (og->header[15]<<8) | + (og->header[16]<<16) | + (og->header[17]<<24)); +} + +long spx_ogg_page_pageno(spx_ogg_page *og){ + return(og->header[18] | + (og->header[19]<<8) | + (og->header[20]<<16) | + (og->header[21]<<24)); +} + + + +/* returns the number of packets that are completed on this page (if + the leading packet is begun on a previous page, but ends on this + page, it's counted */ + +/* NOTE: +If a page consists of a packet begun on a previous page, and a new +packet begun (but not completed) on this page, the return will be: + spx_ogg_page_packets(page) ==1, + spx_ogg_page_continued(page) !=0 + +If a page happens to be a single packet that was begun on a +previous page, and spans to the next page (in the case of a three or +more page packet), the return will be: + spx_ogg_page_packets(page) ==0, + spx_ogg_page_continued(page) !=0 +*/ + +int spx_ogg_page_packets(spx_ogg_page *og){ + int i,n=og->header[26],count=0; + for(i=0;iheader[27+i]<255)count++; + return(count); +} + + +#if 0 +/* helper to initialize lookup for direct-table CRC (illustrative; we + use the static init below) */ + +static spx_ogg_uint32_t _spx_ogg_crc_entry(unsigned long index){ + int i; + unsigned long r; + + r = index << 24; + for (i=0; i<8; i++) + if (r & 0x80000000UL) + r = (r << 1) ^ 0x04c11db7; /* The same as the ethernet generator + polynomial, although we use an + unreflected alg and an init/final + of 0, not 0xffffffff */ + else + r<<=1; + return (r & 0xffffffffUL); +} +#endif + +static const spx_ogg_uint32_t crc_lookup[256]={ + 0x00000000,0x04c11db7,0x09823b6e,0x0d4326d9, + 0x130476dc,0x17c56b6b,0x1a864db2,0x1e475005, + 0x2608edb8,0x22c9f00f,0x2f8ad6d6,0x2b4bcb61, + 0x350c9b64,0x31cd86d3,0x3c8ea00a,0x384fbdbd, + 0x4c11db70,0x48d0c6c7,0x4593e01e,0x4152fda9, + 0x5f15adac,0x5bd4b01b,0x569796c2,0x52568b75, + 0x6a1936c8,0x6ed82b7f,0x639b0da6,0x675a1011, + 0x791d4014,0x7ddc5da3,0x709f7b7a,0x745e66cd, + 0x9823b6e0,0x9ce2ab57,0x91a18d8e,0x95609039, + 0x8b27c03c,0x8fe6dd8b,0x82a5fb52,0x8664e6e5, + 0xbe2b5b58,0xbaea46ef,0xb7a96036,0xb3687d81, + 0xad2f2d84,0xa9ee3033,0xa4ad16ea,0xa06c0b5d, + 0xd4326d90,0xd0f37027,0xddb056fe,0xd9714b49, + 0xc7361b4c,0xc3f706fb,0xceb42022,0xca753d95, + 0xf23a8028,0xf6fb9d9f,0xfbb8bb46,0xff79a6f1, + 0xe13ef6f4,0xe5ffeb43,0xe8bccd9a,0xec7dd02d, + 0x34867077,0x30476dc0,0x3d044b19,0x39c556ae, + 0x278206ab,0x23431b1c,0x2e003dc5,0x2ac12072, + 0x128e9dcf,0x164f8078,0x1b0ca6a1,0x1fcdbb16, + 0x018aeb13,0x054bf6a4,0x0808d07d,0x0cc9cdca, + 0x7897ab07,0x7c56b6b0,0x71159069,0x75d48dde, + 0x6b93dddb,0x6f52c06c,0x6211e6b5,0x66d0fb02, + 0x5e9f46bf,0x5a5e5b08,0x571d7dd1,0x53dc6066, + 0x4d9b3063,0x495a2dd4,0x44190b0d,0x40d816ba, + 0xaca5c697,0xa864db20,0xa527fdf9,0xa1e6e04e, + 0xbfa1b04b,0xbb60adfc,0xb6238b25,0xb2e29692, + 0x8aad2b2f,0x8e6c3698,0x832f1041,0x87ee0df6, + 0x99a95df3,0x9d684044,0x902b669d,0x94ea7b2a, + 0xe0b41de7,0xe4750050,0xe9362689,0xedf73b3e, + 0xf3b06b3b,0xf771768c,0xfa325055,0xfef34de2, + 0xc6bcf05f,0xc27dede8,0xcf3ecb31,0xcbffd686, + 0xd5b88683,0xd1799b34,0xdc3abded,0xd8fba05a, + 0x690ce0ee,0x6dcdfd59,0x608edb80,0x644fc637, + 0x7a089632,0x7ec98b85,0x738aad5c,0x774bb0eb, + 0x4f040d56,0x4bc510e1,0x46863638,0x42472b8f, + 0x5c007b8a,0x58c1663d,0x558240e4,0x51435d53, + 0x251d3b9e,0x21dc2629,0x2c9f00f0,0x285e1d47, + 0x36194d42,0x32d850f5,0x3f9b762c,0x3b5a6b9b, + 0x0315d626,0x07d4cb91,0x0a97ed48,0x0e56f0ff, + 0x1011a0fa,0x14d0bd4d,0x19939b94,0x1d528623, + 0xf12f560e,0xf5ee4bb9,0xf8ad6d60,0xfc6c70d7, + 0xe22b20d2,0xe6ea3d65,0xeba91bbc,0xef68060b, + 0xd727bbb6,0xd3e6a601,0xdea580d8,0xda649d6f, + 0xc423cd6a,0xc0e2d0dd,0xcda1f604,0xc960ebb3, + 0xbd3e8d7e,0xb9ff90c9,0xb4bcb610,0xb07daba7, + 0xae3afba2,0xaafbe615,0xa7b8c0cc,0xa379dd7b, + 0x9b3660c6,0x9ff77d71,0x92b45ba8,0x9675461f, + 0x8832161a,0x8cf30bad,0x81b02d74,0x857130c3, + 0x5d8a9099,0x594b8d2e,0x5408abf7,0x50c9b640, + 0x4e8ee645,0x4a4ffbf2,0x470cdd2b,0x43cdc09c, + 0x7b827d21,0x7f436096,0x7200464f,0x76c15bf8, + 0x68860bfd,0x6c47164a,0x61043093,0x65c52d24, + 0x119b4be9,0x155a565e,0x18197087,0x1cd86d30, + 0x029f3d35,0x065e2082,0x0b1d065b,0x0fdc1bec, + 0x3793a651,0x3352bbe6,0x3e119d3f,0x3ad08088, + 0x2497d08d,0x2056cd3a,0x2d15ebe3,0x29d4f654, + 0xc5a92679,0xc1683bce,0xcc2b1d17,0xc8ea00a0, + 0xd6ad50a5,0xd26c4d12,0xdf2f6bcb,0xdbee767c, + 0xe3a1cbc1,0xe760d676,0xea23f0af,0xeee2ed18, + 0xf0a5bd1d,0xf464a0aa,0xf9278673,0xfde69bc4, + 0x89b8fd09,0x8d79e0be,0x803ac667,0x84fbdbd0, + 0x9abc8bd5,0x9e7d9662,0x933eb0bb,0x97ffad0c, + 0xafb010b1,0xab710d06,0xa6322bdf,0xa2f33668, + 0xbcb4666d,0xb8757bda,0xb5365d03,0xb1f740b4}; + +/* init the encode/decode logical stream state */ + +int spx_ogg_stream_init(spx_ogg_stream_state *os,int serialno){ + if(os){ + memset(os,0,sizeof(*os)); + os->body_storage=16*1024; + os->body_data=_spx_ogg_malloc(os->body_storage*sizeof(*os->body_data)); + + os->lacing_storage=1024; + os->lacing_vals=_spx_ogg_malloc(os->lacing_storage*sizeof(*os->lacing_vals)); + os->granule_vals=_spx_ogg_malloc(os->lacing_storage*sizeof(*os->granule_vals)); + + os->serialno=serialno; + + return(0); + } + return(-1); +} + +/* _clear does not free os, only the non-flat storage within */ +int spx_ogg_stream_clear(spx_ogg_stream_state *os){ + if(os){ + if(os->body_data)_spx_ogg_free(os->body_data); + if(os->lacing_vals)_spx_ogg_free(os->lacing_vals); + if(os->granule_vals)_spx_ogg_free(os->granule_vals); + + memset(os,0,sizeof(*os)); + } + return(0); +} + +int spx_ogg_stream_destroy(spx_ogg_stream_state *os){ + if(os){ + spx_ogg_stream_clear(os); + _spx_ogg_free(os); + } + return(0); +} + +/* Helpers for spx_ogg_stream_encode; this keeps the structure and + what's happening fairly clear */ + +static void _os_body_expand(spx_ogg_stream_state *os,int needed){ + if(os->body_storage<=os->body_fill+needed){ + os->body_storage+=(needed+1024); + os->body_data=_spx_ogg_realloc(os->body_data,os->body_storage*sizeof(*os->body_data)); + } +} + +static void _os_lacing_expand(spx_ogg_stream_state *os,int needed){ + if(os->lacing_storage<=os->lacing_fill+needed){ + os->lacing_storage+=(needed+32); + os->lacing_vals=_spx_ogg_realloc(os->lacing_vals,os->lacing_storage*sizeof(*os->lacing_vals)); + os->granule_vals=_spx_ogg_realloc(os->granule_vals,os->lacing_storage*sizeof(*os->granule_vals)); + } +} + +/* checksum the page */ +/* Direct table CRC; note that this will be faster in the future if we + perform the checksum silmultaneously with other copies */ + +void spx_ogg_page_checksum_set(spx_ogg_page *og){ + if(og){ + spx_ogg_uint32_t crc_reg=0; + int i; + + /* safety; needed for API behavior, but not framing code */ + og->header[22]=0; + og->header[23]=0; + og->header[24]=0; + og->header[25]=0; + + for(i=0;iheader_len;i++) + crc_reg=(crc_reg<<8)^crc_lookup[((crc_reg >> 24)&0xff)^og->header[i]]; + for(i=0;ibody_len;i++) + crc_reg=(crc_reg<<8)^crc_lookup[((crc_reg >> 24)&0xff)^og->body[i]]; + + og->header[22]=(unsigned char)(crc_reg&0xff); + og->header[23]=(unsigned char)((crc_reg>>8)&0xff); + og->header[24]=(unsigned char)((crc_reg>>16)&0xff); + og->header[25]=(unsigned char)((crc_reg>>24)&0xff); + } +} + +/* submit data to the internal buffer of the framing engine */ +int spx_ogg_stream_packetin(spx_ogg_stream_state *os,spx_ogg_packet *op){ + int lacing_vals=op->bytes/255+1,i; + + if(os->body_returned){ + /* advance packet data according to the body_returned pointer. We + had to keep it around to return a pointer into the buffer last + call */ + + os->body_fill-=os->body_returned; + if(os->body_fill) + memmove(os->body_data,os->body_data+os->body_returned, + os->body_fill); + os->body_returned=0; + } + + /* make sure we have the buffer storage */ + _os_body_expand(os,op->bytes); + _os_lacing_expand(os,lacing_vals); + + /* Copy in the submitted packet. Yes, the copy is a waste; this is + the liability of overly clean abstraction for the time being. It + will actually be fairly easy to eliminate the extra copy in the + future */ + + memcpy(os->body_data+os->body_fill,op->packet,op->bytes); + os->body_fill+=op->bytes; + + /* Store lacing vals for this packet */ + for(i=0;ilacing_vals[os->lacing_fill+i]=255; + os->granule_vals[os->lacing_fill+i]=os->granulepos; + } + os->lacing_vals[os->lacing_fill+i]=(op->bytes)%255; + os->granulepos=os->granule_vals[os->lacing_fill+i]=op->granulepos; + + /* flag the first segment as the beginning of the packet */ + os->lacing_vals[os->lacing_fill]|= 0x100; + + os->lacing_fill+=lacing_vals; + + /* for the sake of completeness */ + os->packetno++; + + if(op->e_o_s)os->e_o_s=1; + + return(0); +} + +/* This will flush remaining packets into a page (returning nonzero), + even if there is not enough data to trigger a flush normally + (undersized page). If there are no packets or partial packets to + flush, spx_ogg_stream_flush returns 0. Note that spx_ogg_stream_flush will + try to flush a normal sized page like spx_ogg_stream_pageout; a call to + spx_ogg_stream_flush does not guarantee that all packets have flushed. + Only a return value of 0 from spx_ogg_stream_flush indicates all packet + data is flushed into pages. + + since spx_ogg_stream_flush will flush the last page in a stream even if + it's undersized, you almost certainly want to use spx_ogg_stream_pageout + (and *not* spx_ogg_stream_flush) unless you specifically need to flush + an page regardless of size in the middle of a stream. */ + +int spx_ogg_stream_flush(spx_ogg_stream_state *os,spx_ogg_page *og){ + int i; + int vals=0; + int maxvals=(os->lacing_fill>255?255:os->lacing_fill); + int bytes=0; + long acc=0; + spx_ogg_int64_t granule_pos=-1; + + if(maxvals==0)return(0); + + /* construct a page */ + /* decide how many segments to include */ + + /* If this is the initial header case, the first page must only include + the initial header packet */ + if(os->b_o_s==0){ /* 'initial header page' case */ + granule_pos=0; + for(vals=0;valslacing_vals[vals]&0x0ff)<255){ + vals++; + break; + } + } + }else{ + for(vals=0;vals4096)break; + acc+=os->lacing_vals[vals]&0x0ff; + if((os->lacing_vals[vals]&0xff)<255) + granule_pos=os->granule_vals[vals]; + } + } + + /* construct the header in temp storage */ + memcpy(os->header,"OggS",4); + + /* stream structure version */ + os->header[4]=0x00; + + /* continued packet flag? */ + os->header[5]=0x00; + if((os->lacing_vals[0]&0x100)==0)os->header[5]|=0x01; + /* first page flag? */ + if(os->b_o_s==0)os->header[5]|=0x02; + /* last page flag? */ + if(os->e_o_s && os->lacing_fill==vals)os->header[5]|=0x04; + os->b_o_s=1; + + /* 64 bits of PCM position */ + for(i=6;i<14;i++){ + os->header[i]=(unsigned char)(granule_pos&0xff); + granule_pos>>=8; + } + + /* 32 bits of stream serial number */ + { + long serialno=os->serialno; + for(i=14;i<18;i++){ + os->header[i]=(unsigned char)(serialno&0xff); + serialno>>=8; + } + } + + /* 32 bits of page counter (we have both counter and page header + because this val can roll over) */ + if(os->pageno==-1)os->pageno=0; /* because someone called + stream_reset; this would be a + strange thing to do in an + encode stream, but it has + plausible uses */ + { + long pageno=os->pageno++; + for(i=18;i<22;i++){ + os->header[i]=(unsigned char)(pageno&0xff); + pageno>>=8; + } + } + + /* zero for computation; filled in later */ + os->header[22]=0; + os->header[23]=0; + os->header[24]=0; + os->header[25]=0; + + /* segment table */ + os->header[26]=(unsigned char)(vals&0xff); + for(i=0;iheader[i+27]=(unsigned char)(os->lacing_vals[i]&0xff); + + /* set pointers in the spx_ogg_page struct */ + og->header=os->header; + og->header_len=os->header_fill=vals+27; + og->body=os->body_data+os->body_returned; + og->body_len=bytes; + + /* advance the lacing data and set the body_returned pointer */ + + os->lacing_fill-=vals; + memmove(os->lacing_vals,os->lacing_vals+vals,os->lacing_fill*sizeof(*os->lacing_vals)); + memmove(os->granule_vals,os->granule_vals+vals,os->lacing_fill*sizeof(*os->granule_vals)); + os->body_returned+=bytes; + + /* calculate the checksum */ + + spx_ogg_page_checksum_set(og); + + /* done */ + return(1); +} + + +/* This constructs pages from buffered packet segments. The pointers +returned are to static buffers; do not free. The returned buffers are +good only until the next call (using the same spx_ogg_stream_state) */ + +int spx_ogg_stream_pageout(spx_ogg_stream_state *os, spx_ogg_page *og){ + + if((os->e_o_s&&os->lacing_fill) || /* 'were done, now flush' case */ + os->body_fill-os->body_returned > 4096 ||/* 'page nominal size' case */ + os->lacing_fill>=255 || /* 'segment table full' case */ + (os->lacing_fill&&!os->b_o_s)){ /* 'initial header page' case */ + + return(spx_ogg_stream_flush(os,og)); + } + + /* not enough data to construct a page and not end of stream */ + return(0); +} + +int spx_ogg_stream_eos(spx_ogg_stream_state *os){ + return os->e_o_s; +} + +/* DECODING PRIMITIVES: packet streaming layer **********************/ + +/* This has two layers to place more of the multi-serialno and paging + control in the application's hands. First, we expose a data buffer + using spx_ogg_sync_buffer(). The app either copies into the + buffer, or passes it directly to read(), etc. We then call + spx_ogg_sync_wrote() to tell how many bytes we just added. + + Pages are returned (pointers into the buffer in spx_ogg_sync_state) + by spx_ogg_sync_pageout(). The page is then submitted to + spx_ogg_stream_pagein() along with the appropriate + spx_ogg_stream_state* (ie, matching serialno). We then get raw + packets out calling spx_ogg_stream_packetout() with a + spx_ogg_stream_state. */ + +/* initialize the struct to a known state */ +int spx_ogg_sync_init(spx_ogg_sync_state *oy){ + if(oy){ + memset(oy,0,sizeof(*oy)); + } + return(0); +} + +/* clear non-flat storage within */ +int spx_ogg_sync_clear(spx_ogg_sync_state *oy){ + if(oy){ + if(oy->data)_spx_ogg_free(oy->data); + spx_ogg_sync_init(oy); + } + return(0); +} + +int spx_ogg_sync_destroy(spx_ogg_sync_state *oy){ + if(oy){ + spx_ogg_sync_clear(oy); + _spx_ogg_free(oy); + } + return(0); +} +void spx_ogg_alloc_buffer(spx_ogg_sync_state *oy, long size){ + long newsize=size+oy->fill+size; /* an extra page to be nice */ + if(oy->data){ + oy->data=_spx_ogg_realloc(oy->data,newsize); + }else + oy->data=_spx_ogg_malloc(newsize); + oy->storage=newsize; + return; +} + +char *spx_ogg_sync_buffer(spx_ogg_sync_state *oy, long size){ + + /* first, clear out any space that has been previously returned */ + if(oy->returned){ + oy->fill-=oy->returned; + if(oy->fill>0) + memmove(oy->data,oy->data+oy->returned,oy->fill); + oy->returned=0; + } + + if(size>oy->storage-oy->fill){ + /* We need to extend the internal buffer */ + long newsize=size+oy->fill+4096; /* an extra page to be nice */ + if(oy->data){ + oy->data=_spx_ogg_realloc(oy->data,newsize); + }else + oy->data=_spx_ogg_malloc(newsize); + oy->storage=newsize; + } + + /* expose a segment at least as large as requested at the fill mark */ + return((char *)oy->data+oy->fill); +} + +int spx_ogg_sync_wrote(spx_ogg_sync_state *oy, long bytes){ + if(oy->fill+bytes>oy->storage)return(-1); + oy->fill+=bytes; + return(0); +} + +/* sync the stream. This is meant to be useful for finding page + boundaries. + + return values for this: + -n) skipped n bytes + 0) page not ready; more data (no bytes skipped) + n) page synced at current location; page length n bytes + +*/ + +long spx_ogg_sync_pageseek(spx_ogg_sync_state *oy,spx_ogg_page *og){ + unsigned char *page=oy->data+oy->returned; + unsigned char *next; + long bytes=oy->fill-oy->returned; + + if(oy->headerbytes==0){ + int headerbytes,i; + if(bytes<27)return(0); /* not enough for a header */ + + /* verify capture pattern */ + if(memcmp(page,"OggS",4))goto sync_fail; + + headerbytes=page[26]+27; + if(bytesbodybytes+=page[27+i]; + oy->headerbytes=headerbytes; + } + + if(oy->bodybytes+oy->headerbytes>bytes)return(0); + + /* The whole test page is buffered. Verify the checksum */ + { + /* Grab the checksum bytes, set the header field to zero */ + char chksum[4]; + spx_ogg_page log; + + memcpy(chksum,page+22,4); + memset(page+22,0,4); + + /* set up a temp page struct and recompute the checksum */ + log.header=page; + log.header_len=oy->headerbytes; + log.body=page+oy->headerbytes; + log.body_len=oy->bodybytes; + spx_ogg_page_checksum_set(&log); + + /* Compare */ + if(memcmp(chksum,page+22,4)){ + /* D'oh. Mismatch! Corrupt page (or miscapture and not a page + at all) */ + /* replace the computed checksum with the one actually read in */ + memcpy(page+22,chksum,4); + + /* Bad checksum. Lose sync */ + goto sync_fail; + } + } + + /* yes, have a whole page all ready to go */ + { + unsigned char *page=oy->data+oy->returned; + long bytes; + + if(og){ + og->header=page; + og->header_len=oy->headerbytes; + og->body=page+oy->headerbytes; + og->body_len=oy->bodybytes; + } + + oy->unsynced=0; + oy->returned+=(bytes=oy->headerbytes+oy->bodybytes); + oy->headerbytes=0; + oy->bodybytes=0; + return(bytes); + } + + sync_fail: + + oy->headerbytes=0; + oy->bodybytes=0; + + /* search for possible capture */ + next=memchr(page+1,'O',bytes-1); + if(!next) + next=oy->data+oy->fill; + + oy->returned=next-oy->data; + return(-(next-page)); +} + +/* sync the stream and get a page. Keep trying until we find a page. + Supress 'sync errors' after reporting the first. + + return values: + -1) recapture (hole in data) + 0) need more data + 1) page returned + + Returns pointers into buffered data; invalidated by next call to + _stream, _clear, _init, or _buffer */ + +int spx_ogg_sync_pageout(spx_ogg_sync_state *oy, spx_ogg_page *og){ + + /* all we need to do is verify a page at the head of the stream + buffer. If it doesn't verify, we look for the next potential + frame */ + + for(;;){ + long ret=spx_ogg_sync_pageseek(oy,og); + if(ret>0){ + /* have a page */ + return(1); + } + if(ret==0){ + /* need more data */ + return(0); + } + + /* head did not start a synced page... skipped some bytes */ + if(!oy->unsynced){ + oy->unsynced=1; + return(-1); + } + + /* loop. keep looking */ + + } +} + +/* add the incoming page to the stream state; we decompose the page + into packet segments here as well. */ + +int spx_ogg_stream_pagein(spx_ogg_stream_state *os, spx_ogg_page *og){ + unsigned char *header=og->header; + unsigned char *body=og->body; + long bodysize=og->body_len; + int segptr=0; + + int version=spx_ogg_page_version(og); + int continued=spx_ogg_page_continued(og); + int bos=spx_ogg_page_bos(og); + int eos=spx_ogg_page_eos(og); + spx_ogg_int64_t granulepos=spx_ogg_page_granulepos(og); + int serialno=spx_ogg_page_serialno(og); + long pageno=spx_ogg_page_pageno(og); + int segments=header[26]; + + /* clean up 'returned data' */ + { + long lr=os->lacing_returned; + long br=os->body_returned; + + /* body data */ + if(br){ + os->body_fill-=br; + if(os->body_fill) + memmove(os->body_data,os->body_data+br,os->body_fill); + os->body_returned=0; + } + + if(lr){ + /* segment table */ + if(os->lacing_fill-lr){ + memmove(os->lacing_vals,os->lacing_vals+lr, + (os->lacing_fill-lr)*sizeof(*os->lacing_vals)); + memmove(os->granule_vals,os->granule_vals+lr, + (os->lacing_fill-lr)*sizeof(*os->granule_vals)); + } + os->lacing_fill-=lr; + os->lacing_packet-=lr; + os->lacing_returned=0; + } + } + + /* check the serial number */ + if(serialno!=os->serialno)return(-1); + if(version>0)return(-1); + + _os_lacing_expand(os,segments+1); + + /* are we in sequence? */ + if(pageno!=os->pageno){ + int i; + + /* unroll previous partial packet (if any) */ + for(i=os->lacing_packet;ilacing_fill;i++) + os->body_fill-=os->lacing_vals[i]&0xff; + os->lacing_fill=os->lacing_packet; + + /* make a note of dropped data in segment table */ + if(os->pageno!=-1){ + os->lacing_vals[os->lacing_fill++]=0x400; + os->lacing_packet++; + } + } + + /* are we a 'continued packet' page? If so, we may need to skip + some segments */ + if(continued){ + if(os->lacing_fill<1 || + os->lacing_vals[os->lacing_fill-1]==0x400){ + bos=0; + for(;segptrbody_data+os->body_fill,body,bodysize); + os->body_fill+=bodysize; + } + + { + int saved=-1; + while(segptrlacing_vals[os->lacing_fill]=val; + os->granule_vals[os->lacing_fill]=-1; + + if(bos){ + os->lacing_vals[os->lacing_fill]|=0x100; + bos=0; + } + + if(val<255)saved=os->lacing_fill; + + os->lacing_fill++; + segptr++; + + if(val<255)os->lacing_packet=os->lacing_fill; + } + + /* set the granulepos on the last granuleval of the last full packet */ + if(saved!=-1){ + os->granule_vals[saved]=granulepos; + } + + } + + if(eos){ + os->e_o_s=1; + if(os->lacing_fill>0) + os->lacing_vals[os->lacing_fill-1]|=0x200; + } + + os->pageno=pageno+1; + + return(0); +} + +/* clear things to an initial state. Good to call, eg, before seeking */ +int spx_ogg_sync_reset(spx_ogg_sync_state *oy){ + oy->fill=0; + oy->returned=0; + oy->unsynced=0; + oy->headerbytes=0; + oy->bodybytes=0; + return(0); +} + +int spx_ogg_stream_reset(spx_ogg_stream_state *os){ + os->body_fill=0; + os->body_returned=0; + + os->lacing_fill=0; + os->lacing_packet=0; + os->lacing_returned=0; + + os->header_fill=0; + + os->e_o_s=0; + os->b_o_s=0; + os->pageno=-1; + os->packetno=0; + os->granulepos=0; + + return(0); +} + +int spx_ogg_stream_reset_serialno(spx_ogg_stream_state *os,int serialno){ + spx_ogg_stream_reset(os); + os->serialno=serialno; + return(0); +} + +static int _packetout(spx_ogg_stream_state *os,spx_ogg_packet *op,int adv){ + + /* The last part of decode. We have the stream broken into packet + segments. Now we need to group them into packets (or return the + out of sync markers) */ + + int ptr=os->lacing_returned; + + if(os->lacing_packet<=ptr)return(0); + + if(os->lacing_vals[ptr]&0x400){ + /* we need to tell the codec there's a gap; it might need to + handle previous packet dependencies. */ + os->lacing_returned++; + os->packetno++; + return(-1); + } + + if(!op && !adv)return(1); /* just using peek as an inexpensive way + to ask if there's a whole packet + waiting */ + + /* Gather the whole packet. We'll have no holes or a partial packet */ + { + int size=os->lacing_vals[ptr]&0xff; + int bytes=size; + int eos=os->lacing_vals[ptr]&0x200; /* last packet of the stream? */ + int bos=os->lacing_vals[ptr]&0x100; /* first packet of the stream? */ + + while(size==255){ + int val=os->lacing_vals[++ptr]; + size=val&0xff; + if(val&0x200)eos=0x200; + bytes+=size; + } + + if(op){ + op->e_o_s=eos; + op->b_o_s=bos; + op->packet=os->body_data+os->body_returned; + op->packetno=os->packetno; + op->granulepos=os->granule_vals[ptr]; + op->bytes=bytes; + } + + if(adv){ + os->body_returned+=bytes; + os->lacing_returned=ptr+1; + os->packetno++; + } + } + return(1); +} + +int spx_ogg_stream_packetout(spx_ogg_stream_state *os,spx_ogg_packet *op){ + return _packetout(os,op,1); +} + +int spx_ogg_stream_packetpeek(spx_ogg_stream_state *os,spx_ogg_packet *op){ + return _packetout(os,op,0); +} + +void spx_ogg_packet_clear(spx_ogg_packet *op) { + _spx_ogg_free(op->packet); + memset(op, 0, sizeof(*op)); +} + diff --git a/lib/rbcodec/codecs/libspeex/os_support.h b/lib/rbcodec/codecs/libspeex/os_support.h new file mode 100644 index 0000000000..71d24753c1 --- /dev/null +++ b/lib/rbcodec/codecs/libspeex/os_support.h @@ -0,0 +1,165 @@ +/* Copyright (C) 2007 Jean-Marc Valin + + File: os_support.h + This is the (tiny) OS abstraction layer. Aside from math.h, this is the + only place where system headers are allowed. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + 3. The name of the author may not be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef OS_SUPPORT_H +#define OS_SUPPORT_H + +#include "config-speex.h" +#include "rockbox.h" + +#include +#include +#include + +/** Speex wrapper for calloc. To do your own dynamic allocation, all you need to do is replace this function, speex_realloc and speex_free + NOTE: speex_alloc needs to CLEAR THE MEMORY */ +#ifndef OVERRIDE_SPEEX_ALLOC +static inline void *speex_alloc (int size) +{ + /* WARNING: this is not equivalent to malloc(). If you want to use malloc() + or your own allocator, YOU NEED TO CLEAR THE MEMORY ALLOCATED. Otherwise + you will experience strange bugs */ + return calloc(size,1); +} +#endif + +/** Same as speex_alloc, except that the area is only needed inside a Speex call (might cause problem with wideband though) */ +#ifndef OVERRIDE_SPEEX_ALLOC_SCRATCH +static inline void *speex_alloc_scratch (int size) +{ + /* Scratch space doesn't need to be cleared */ + return calloc(size,1); +} +#endif + +/** Speex wrapper for realloc. To do your own dynamic allocation, all you need to do is replace this function, speex_alloc and speex_free */ +#ifndef OVERRIDE_SPEEX_REALLOC +static inline void *speex_realloc (void *ptr, int size) +{ + return realloc(ptr, size); +} +#endif + +/** Speex wrapper for calloc. To do your own dynamic allocation, all you need to do is replace this function, speex_realloc and speex_alloc */ +#ifndef OVERRIDE_SPEEX_FREE +static inline void speex_free (void *ptr) +{ + free(ptr); +} +#endif + +/** Same as speex_free, except that the area is only needed inside a Speex call (might cause problem with wideband though) */ +#ifndef OVERRIDE_SPEEX_FREE_SCRATCH +static inline void speex_free_scratch (void *ptr) +{ + free(ptr); +} +#endif + +/** Copy n bytes of memory from src to dst. The 0* term provides compile-time type checking */ +#ifndef OVERRIDE_SPEEX_COPY +#define SPEEX_COPY(dst, src, n) (memcpy((dst), (src), (n)*sizeof(*(dst)) + 0*((dst)-(src)) )) +#endif + +/** Copy n bytes of memory from src to dst, allowing overlapping regions. The 0* term + provides compile-time type checking */ +#ifndef OVERRIDE_SPEEX_MOVE +#define SPEEX_MOVE(dst, src, n) (memmove((dst), (src), (n)*sizeof(*(dst)) + 0*((dst)-(src)) )) +#endif + +/** Set n bytes of memory to value of c, starting at address s */ +#ifndef OVERRIDE_SPEEX_MEMSET +#define SPEEX_MEMSET(dst, c, n) (memset((dst), (c), (n)*sizeof(*(dst)))) +#endif + + +#ifndef OVERRIDE_SPEEX_FATAL +static inline void _speex_fatal(const char *str, const char *file, int line) +{ + fprintf (stderr, "Fatal (internal) error in %s, line %d: %s\n", file, line, str); + exit(1); +} +#endif + +#ifndef OVERRIDE_SPEEX_WARNING +static inline void speex_warning(const char *str) +{ +#ifndef DISABLE_WARNINGS + fprintf (stderr, "warning: %s\n", str); +#endif +} +#endif + +#ifndef OVERRIDE_SPEEX_WARNING_INT +static inline void speex_warning_int(const char *str, int val) +{ +#ifndef DISABLE_WARNINGS + fprintf (stderr, "warning: %s %d\n", str, val); +#endif +} +#endif + +#ifndef OVERRIDE_SPEEX_NOTIFY +static inline void speex_notify(const char *str) +{ +#ifndef DISABLE_NOTIFICATIONS + fprintf (stderr, "notification: %s\n", str); +#endif +} +#endif + +#ifndef OVERRIDE_SPEEX_PUTC +/** Speex wrapper for putc */ +static inline void _speex_putc(int ch, void *file) +{ + FILE *f = (FILE *)file; + fprintf(f, "%c", ch); +} +#endif + +#define speex_fatal(str) _speex_fatal(str, __FILE__, __LINE__); +#define speex_assert(cond) {if (!(cond)) {speex_fatal("assertion failed: " #cond);}} + +#ifndef RELEASE +static inline void print_vec(float *vec, int len, char *name) +{ + int i; + printf ("%s ", name); + for (i=0;i +#include "speex/speex_preprocess.h" +#include "speex/speex_echo.h" +#include "arch.h" +#include "fftwrap.h" +#include "filterbank.h" +#include "math_approx.h" +#include "os_support.h" + +#ifndef M_PI +#define M_PI 3.14159263 +#endif + +#define LOUDNESS_EXP 5.f +#define AMP_SCALE .001f +#define AMP_SCALE_1 1000.f + +#define NB_BANDS 24 + +#define SPEECH_PROB_START_DEFAULT QCONST16(0.35f,15) +#define SPEECH_PROB_CONTINUE_DEFAULT QCONST16(0.20f,15) +#define NOISE_SUPPRESS_DEFAULT -15 +#define ECHO_SUPPRESS_DEFAULT -40 +#define ECHO_SUPPRESS_ACTIVE_DEFAULT -15 + +#ifndef NULL +#define NULL 0 +#endif + +#define SQR(x) ((x)*(x)) +#define SQR16(x) (MULT16_16((x),(x))) +#define SQR16_Q15(x) (MULT16_16_Q15((x),(x))) + +#ifdef FIXED_POINT +static inline spx_word16_t DIV32_16_Q8(spx_word32_t a, spx_word32_t b) +{ + if (SHR32(a,7) >= b) + { + return 32767; + } else { + if (b>=QCONST32(1,23)) + { + a = SHR32(a,8); + b = SHR32(b,8); + } + if (b>=QCONST32(1,19)) + { + a = SHR32(a,4); + b = SHR32(b,4); + } + if (b>=QCONST32(1,15)) + { + a = SHR32(a,4); + b = SHR32(b,4); + } + a = SHL32(a,8); + return PDIV32_16(a,b); + } + +} +static inline spx_word16_t DIV32_16_Q15(spx_word32_t a, spx_word32_t b) +{ + if (SHR32(a,15) >= b) + { + return 32767; + } else { + if (b>=QCONST32(1,23)) + { + a = SHR32(a,8); + b = SHR32(b,8); + } + if (b>=QCONST32(1,19)) + { + a = SHR32(a,4); + b = SHR32(b,4); + } + if (b>=QCONST32(1,15)) + { + a = SHR32(a,4); + b = SHR32(b,4); + } + a = SHL32(a,15)-a; + return DIV32_16(a,b); + } +} +#define SNR_SCALING 256.f +#define SNR_SCALING_1 0.0039062f +#define SNR_SHIFT 8 + +#define FRAC_SCALING 32767.f +#define FRAC_SCALING_1 3.0518e-05 +#define FRAC_SHIFT 1 + +#define EXPIN_SCALING 2048.f +#define EXPIN_SCALING_1 0.00048828f +#define EXPIN_SHIFT 11 +#define EXPOUT_SCALING_1 1.5259e-05 + +#define NOISE_SHIFT 7 + +#else + +#define DIV32_16_Q8(a,b) ((a)/(b)) +#define DIV32_16_Q15(a,b) ((a)/(b)) +#define SNR_SCALING 1.f +#define SNR_SCALING_1 1.f +#define SNR_SHIFT 0 +#define FRAC_SCALING 1.f +#define FRAC_SCALING_1 1.f +#define FRAC_SHIFT 0 +#define NOISE_SHIFT 0 + +#define EXPIN_SCALING 1.f +#define EXPIN_SCALING_1 1.f +#define EXPOUT_SCALING_1 1.f + +#endif + +/** Speex pre-processor state. */ +struct SpeexPreprocessState_ { + /* Basic info */ + int frame_size; /**< Number of samples processed each time */ + int ps_size; /**< Number of points in the power spectrum */ + int sampling_rate; /**< Sampling rate of the input/output */ + int nbands; + FilterBank *bank; + + /* Parameters */ + int denoise_enabled; + int vad_enabled; + int dereverb_enabled; + spx_word16_t reverb_decay; + spx_word16_t reverb_level; + spx_word16_t speech_prob_start; + spx_word16_t speech_prob_continue; + int noise_suppress; + int echo_suppress; + int echo_suppress_active; + SpeexEchoState *echo_state; + + /* DSP-related arrays */ + spx_word16_t *frame; /**< Processing frame (2*ps_size) */ + spx_word16_t *ft; /**< Processing frame in freq domain (2*ps_size) */ + spx_word32_t *ps; /**< Current power spectrum */ + spx_word16_t *gain2; /**< Adjusted gains */ + spx_word16_t *gain_floor; /**< Minimum gain allowed */ + spx_word16_t *window; /**< Analysis/Synthesis window */ + spx_word32_t *noise; /**< Noise estimate */ + spx_word32_t *reverb_estimate; /**< Estimate of reverb energy */ + spx_word32_t *old_ps; /**< Power spectrum for last frame */ + spx_word16_t *gain; /**< Ephraim Malah gain */ + spx_word16_t *prior; /**< A-priori SNR */ + spx_word16_t *post; /**< A-posteriori SNR */ + + spx_word32_t *S; /**< Smoothed power spectrum */ + spx_word32_t *Smin; /**< See Cohen paper */ + spx_word32_t *Stmp; /**< See Cohen paper */ + int *update_prob; /**< Probability of speech presence for noise update */ + + spx_word16_t *zeta; /**< Smoothed a priori SNR */ + spx_word32_t *echo_noise; + spx_word32_t *residual_echo; + + /* Misc */ + spx_word16_t *inbuf; /**< Input buffer (overlapped analysis) */ + spx_word16_t *outbuf; /**< Output buffer (for overlap and add) */ + + /* AGC stuff, only for floating point for now */ +#ifndef FIXED_POINT + int agc_enabled; + float agc_level; + float loudness_accum; + float *loudness_weight; /**< Perceptual loudness curve */ + float loudness; /**< Loudness estimate */ + float agc_gain; /**< Current AGC gain */ + int nb_loudness_adapt; /**< Number of frames used for loudness adaptation so far */ + float max_gain; /**< Maximum gain allowed */ + float max_increase_step; /**< Maximum increase in gain from one frame to another */ + float max_decrease_step; /**< Maximum decrease in gain from one frame to another */ + float prev_loudness; /**< Loudness of previous frame */ + float init_max; /**< Current gain limit during initialisation */ +#endif + int nb_adapt; /**< Number of frames used for adaptation so far */ + int was_speech; + int min_count; /**< Number of frames processed so far */ + void *fft_lookup; /**< Lookup table for the FFT */ +#ifdef FIXED_POINT + int frame_shift; +#endif +}; + + +static void conj_window(spx_word16_t *w, int len) +{ + int i; + for (i=0;i19) + return ADD32(EXTEND32(Q15_ONE),EXTEND32(DIV32_16(QCONST32(.1296,23), SHR32(xx,EXPIN_SHIFT-SNR_SHIFT)))); + frac = SHL32(xx-SHL32(ind,10),5); + return SHL32(DIV32_16(PSHR32(MULT16_16(Q15_ONE-frac,table[ind]) + MULT16_16(frac,table[ind+1]),7),(spx_sqrt(SHL32(xx,15)+6711))),7); +} + +static inline spx_word16_t qcurve(spx_word16_t x) +{ + x = MAX16(x, 1); + return DIV32_16(SHL32(EXTEND32(32767),9),ADD16(512,MULT16_16_Q15(QCONST16(.60f,15),DIV32_16(32767,x)))); +} + +/* Compute the gain floor based on different floors for the background noise and residual echo */ +static void compute_gain_floor(int noise_suppress, int effective_echo_suppress, spx_word32_t *noise, spx_word32_t *echo, spx_word16_t *gain_floor, int len) +{ + int i; + + if (noise_suppress > effective_echo_suppress) + { + spx_word16_t noise_gain, gain_ratio; + noise_gain = EXTRACT16(MIN32(Q15_ONE,SHR32(spx_exp(MULT16_16(QCONST16(0.11513,11),noise_suppress)),1))); + gain_ratio = EXTRACT16(MIN32(Q15_ONE,SHR32(spx_exp(MULT16_16(QCONST16(.2302585f,11),effective_echo_suppress-noise_suppress)),1))); + + /* gain_floor = sqrt [ (noise*noise_floor + echo*echo_floor) / (noise+echo) ] */ + for (i=0;i19) + return FRAC_SCALING*(1+.1296/x); + frac = 2*x-integer; + return FRAC_SCALING*((1-frac)*table[ind] + frac*table[ind+1])/sqrt(x+.0001f); +} + +static inline spx_word16_t qcurve(spx_word16_t x) +{ + return 1.f/(1.f+.15f/(SNR_SCALING_1*x)); +} + +static void compute_gain_floor(int noise_suppress, int effective_echo_suppress, spx_word32_t *noise, spx_word32_t *echo, spx_word16_t *gain_floor, int len) +{ + int i; + float echo_floor; + float noise_floor; + + noise_floor = exp(.2302585f*noise_suppress); + echo_floor = exp(.2302585f*effective_echo_suppress); + + /* Compute the gain floor based on different floors for the background noise and residual echo */ + for (i=0;iframe_size = frame_size; + + /* Round ps_size down to the nearest power of two */ +#if 0 + i=1; + st->ps_size = st->frame_size; + while(1) + { + if (st->ps_size & ~i) + { + st->ps_size &= ~i; + i<<=1; + } else { + break; + } + } + + + if (st->ps_size < 3*st->frame_size/4) + st->ps_size = st->ps_size * 3 / 2; +#else + st->ps_size = st->frame_size; +#endif + + N = st->ps_size; + N3 = 2*N - st->frame_size; + N4 = st->frame_size - N3; + + st->sampling_rate = sampling_rate; + st->denoise_enabled = 1; + st->vad_enabled = 0; + st->dereverb_enabled = 0; + st->reverb_decay = 0; + st->reverb_level = 0; + st->noise_suppress = NOISE_SUPPRESS_DEFAULT; + st->echo_suppress = ECHO_SUPPRESS_DEFAULT; + st->echo_suppress_active = ECHO_SUPPRESS_ACTIVE_DEFAULT; + + st->speech_prob_start = SPEECH_PROB_START_DEFAULT; + st->speech_prob_continue = SPEECH_PROB_CONTINUE_DEFAULT; + + st->echo_state = NULL; + + st->nbands = NB_BANDS; + M = st->nbands; + st->bank = filterbank_new(M, sampling_rate, N, 1); + + st->frame = (spx_word16_t*)speex_alloc(2*N*sizeof(spx_word16_t)); + st->window = (spx_word16_t*)speex_alloc(2*N*sizeof(spx_word16_t)); + st->ft = (spx_word16_t*)speex_alloc(2*N*sizeof(spx_word16_t)); + + st->ps = (spx_word32_t*)speex_alloc((N+M)*sizeof(spx_word32_t)); + st->noise = (spx_word32_t*)speex_alloc((N+M)*sizeof(spx_word32_t)); + st->echo_noise = (spx_word32_t*)speex_alloc((N+M)*sizeof(spx_word32_t)); + st->residual_echo = (spx_word32_t*)speex_alloc((N+M)*sizeof(spx_word32_t)); + st->reverb_estimate = (spx_word32_t*)speex_alloc((N+M)*sizeof(spx_word32_t)); + st->old_ps = (spx_word32_t*)speex_alloc((N+M)*sizeof(spx_word32_t)); + st->prior = (spx_word16_t*)speex_alloc((N+M)*sizeof(spx_word16_t)); + st->post = (spx_word16_t*)speex_alloc((N+M)*sizeof(spx_word16_t)); + st->gain = (spx_word16_t*)speex_alloc((N+M)*sizeof(spx_word16_t)); + st->gain2 = (spx_word16_t*)speex_alloc((N+M)*sizeof(spx_word16_t)); + st->gain_floor = (spx_word16_t*)speex_alloc((N+M)*sizeof(spx_word16_t)); + st->zeta = (spx_word16_t*)speex_alloc((N+M)*sizeof(spx_word16_t)); + + st->S = (spx_word32_t*)speex_alloc(N*sizeof(spx_word32_t)); + st->Smin = (spx_word32_t*)speex_alloc(N*sizeof(spx_word32_t)); + st->Stmp = (spx_word32_t*)speex_alloc(N*sizeof(spx_word32_t)); + st->update_prob = (int*)speex_alloc(N*sizeof(int)); + + st->inbuf = (spx_word16_t*)speex_alloc(N3*sizeof(spx_word16_t)); + st->outbuf = (spx_word16_t*)speex_alloc(N3*sizeof(spx_word16_t)); + + conj_window(st->window, 2*N3); + for (i=2*N3;i<2*st->ps_size;i++) + st->window[i]=Q15_ONE; + + if (N4>0) + { + for (i=N3-1;i>=0;i--) + { + st->window[i+N3+N4]=st->window[i+N3]; + st->window[i+N3]=1; + } + } + for (i=0;inoise[i]=QCONST32(1.f,NOISE_SHIFT); + st->reverb_estimate[i]=0; + st->old_ps[i]=1; + st->gain[i]=Q15_ONE; + st->post[i]=SHL16(1, SNR_SHIFT); + st->prior[i]=SHL16(1, SNR_SHIFT); + } + + for (i=0;iupdate_prob[i] = 1; + for (i=0;iinbuf[i]=0; + st->outbuf[i]=0; + } +#ifndef FIXED_POINT + st->agc_enabled = 0; + st->agc_level = 8000; + st->loudness_weight = (float*)speex_alloc(N*sizeof(float)); + for (i=0;iloudness_weight[i] = .5f*(1.f/(1.f+ff/8000.f))+1.f*exp(-.5f*(ff-3800.f)*(ff-3800.f)/9e5f);*/ + st->loudness_weight[i] = .35f-.35f*ff/16000.f+.73f*exp(-.5f*(ff-3800)*(ff-3800)/9e5f); + if (st->loudness_weight[i]<.01f) + st->loudness_weight[i]=.01f; + st->loudness_weight[i] *= st->loudness_weight[i]; + } + /*st->loudness = pow(AMP_SCALE*st->agc_level,LOUDNESS_EXP);*/ + st->loudness = 1e-15; + st->agc_gain = 1; + st->nb_loudness_adapt = 0; + st->max_gain = 30; + st->max_increase_step = exp(0.11513f * 12.*st->frame_size / st->sampling_rate); + st->max_decrease_step = exp(-0.11513f * 40.*st->frame_size / st->sampling_rate); + st->prev_loudness = 1; + st->init_max = 1; +#endif + st->was_speech = 0; + + st->fft_lookup = spx_fft_init(2*N); + + st->nb_adapt=0; + st->min_count=0; + return st; +} + +void speex_preprocess_state_destroy(SpeexPreprocessState *st) +{ + speex_free(st->frame); + speex_free(st->ft); + speex_free(st->ps); + speex_free(st->gain2); + speex_free(st->gain_floor); + speex_free(st->window); + speex_free(st->noise); + speex_free(st->reverb_estimate); + speex_free(st->old_ps); + speex_free(st->gain); + speex_free(st->prior); + speex_free(st->post); +#ifndef FIXED_POINT + speex_free(st->loudness_weight); +#endif + speex_free(st->echo_noise); + speex_free(st->residual_echo); + + speex_free(st->S); + speex_free(st->Smin); + speex_free(st->Stmp); + speex_free(st->update_prob); + speex_free(st->zeta); + + speex_free(st->inbuf); + speex_free(st->outbuf); + + spx_fft_destroy(st->fft_lookup); + filterbank_destroy(st->bank); + speex_free(st); +} + +/* FIXME: The AGC doesn't work yet with fixed-point*/ +#ifndef FIXED_POINT +static void speex_compute_agc(SpeexPreprocessState *st, spx_word16_t Pframe, spx_word16_t *ft) +{ + int i; + int N = st->ps_size; + float target_gain; + float loudness=1.f; + float rate; + + for (i=2;ips[i]* st->loudness_weight[i]; + } + loudness=sqrt(loudness); + /*if (loudness < 2*pow(st->loudness, 1.0/LOUDNESS_EXP) && + loudness*2 > pow(st->loudness, 1.0/LOUDNESS_EXP))*/ + if (Pframe>.3f) + { + st->nb_loudness_adapt++; + /*rate=2.0f*Pframe*Pframe/(1+st->nb_loudness_adapt);*/ + rate = .03*Pframe*Pframe; + st->loudness = (1-rate)*st->loudness + (rate)*pow(AMP_SCALE*loudness, LOUDNESS_EXP); + st->loudness_accum = (1-rate)*st->loudness_accum + rate; + if (st->init_max < st->max_gain && st->nb_adapt > 20) + st->init_max *= 1.f + .1f*Pframe*Pframe; + } + /*printf ("%f %f %f %f\n", Pframe, loudness, pow(st->loudness, 1.0f/LOUDNESS_EXP), st->loudness2);*/ + + target_gain = AMP_SCALE*st->agc_level*pow(st->loudness/(1e-4+st->loudness_accum), -1.0f/LOUDNESS_EXP); + + if ((Pframe>.5 && st->nb_adapt > 20) || target_gain < st->agc_gain) + { + if (target_gain > st->max_increase_step*st->agc_gain) + target_gain = st->max_increase_step*st->agc_gain; + if (target_gain < st->max_decrease_step*st->agc_gain && loudness < 10*st->prev_loudness) + target_gain = st->max_decrease_step*st->agc_gain; + if (target_gain > st->max_gain) + target_gain = st->max_gain; + if (target_gain > st->init_max) + target_gain = st->init_max; + + st->agc_gain = target_gain; + } + /*fprintf (stderr, "%f %f %f\n", loudness, (float)AMP_SCALE_1*pow(st->loudness, 1.0f/LOUDNESS_EXP), st->agc_gain);*/ + + for (i=0;i<2*N;i++) + ft[i] *= st->agc_gain; + st->prev_loudness = loudness; +} +#endif + +static void preprocess_analysis(SpeexPreprocessState *st, spx_int16_t *x) +{ + int i; + int N = st->ps_size; + int N3 = 2*N - st->frame_size; + int N4 = st->frame_size - N3; + spx_word32_t *ps=st->ps; + + /* 'Build' input frame */ + for (i=0;iframe[i]=st->inbuf[i]; + for (i=0;iframe_size;i++) + st->frame[N3+i]=x[i]; + + /* Update inbuf */ + for (i=0;iinbuf[i]=x[N4+i]; + + /* Windowing */ + for (i=0;i<2*N;i++) + st->frame[i] = MULT16_16_Q15(st->frame[i], st->window[i]); + +#ifdef FIXED_POINT + { + spx_word16_t max_val=0; + for (i=0;i<2*N;i++) + max_val = MAX16(max_val, ABS16(st->frame[i])); + st->frame_shift = 14-spx_ilog2(EXTEND32(max_val)); + for (i=0;i<2*N;i++) + st->frame[i] = SHL16(st->frame[i], st->frame_shift); + } +#endif + + /* Perform FFT */ + spx_fft(st->fft_lookup, st->frame, st->ft); + + /* Power spectrum */ + ps[0]=MULT16_16(st->ft[0],st->ft[0]); + for (i=1;ift[2*i-1],st->ft[2*i-1]) + MULT16_16(st->ft[2*i],st->ft[2*i]); + for (i=0;ips[i] = PSHR32(st->ps[i], 2*st->frame_shift); + + filterbank_compute_bank32(st->bank, ps, ps+N); +} + +static void update_noise_prob(SpeexPreprocessState *st) +{ + int i; + int min_range; + int N = st->ps_size; + + for (i=1;iS[i] = MULT16_32_Q15(QCONST16(.8f,15),st->S[i]) + MULT16_32_Q15(QCONST16(.05f,15),st->ps[i-1]) + + MULT16_32_Q15(QCONST16(.1f,15),st->ps[i]) + MULT16_32_Q15(QCONST16(.05f,15),st->ps[i+1]); + st->S[0] = MULT16_32_Q15(QCONST16(.8f,15),st->S[0]) + MULT16_32_Q15(QCONST16(.2f,15),st->ps[0]); + st->S[N-1] = MULT16_32_Q15(QCONST16(.8f,15),st->S[N-1]) + MULT16_32_Q15(QCONST16(.2f,15),st->ps[N-1]); + + if (st->nb_adapt==1) + { + for (i=0;iSmin[i] = st->Stmp[i] = 0; + } + + if (st->nb_adapt < 100) + min_range = 15; + else if (st->nb_adapt < 1000) + min_range = 50; + else if (st->nb_adapt < 10000) + min_range = 150; + else + min_range = 300; + if (st->min_count > min_range) + { + st->min_count = 0; + for (i=0;iSmin[i] = MIN32(st->Stmp[i], st->S[i]); + st->Stmp[i] = st->S[i]; + } + } else { + for (i=0;iSmin[i] = MIN32(st->Smin[i], st->S[i]); + st->Stmp[i] = MIN32(st->Stmp[i], st->S[i]); + } + } + for (i=0;iS[i]) > ADD32(st->Smin[i],EXTEND32(20))) + st->update_prob[i] = 1; + else + st->update_prob[i] = 0; + /*fprintf (stderr, "%f ", st->S[i]/st->Smin[i]);*/ + /*fprintf (stderr, "%f ", st->update_prob[i]);*/ + } + +} + +#define NOISE_OVERCOMPENS 1. + +void speex_echo_get_residual(SpeexEchoState *st, spx_word32_t *Yout, int len); + +int speex_preprocess(SpeexPreprocessState *st, spx_int16_t *x, spx_int32_t *echo) +{ + return speex_preprocess_run(st, x); +} + +int speex_preprocess_run(SpeexPreprocessState *st, spx_int16_t *x) +{ + int i; + int M; + int N = st->ps_size; + int N3 = 2*N - st->frame_size; + int N4 = st->frame_size - N3; + spx_word32_t *ps=st->ps; + spx_word32_t Zframe; + spx_word16_t Pframe; + spx_word16_t beta, beta_1; + spx_word16_t effective_echo_suppress; + + st->nb_adapt++; + if (st->nb_adapt>20000) + st->nb_adapt = 20000; + st->min_count++; + + beta = MAX16(QCONST16(.03,15),DIV32_16(Q15_ONE,st->nb_adapt)); + beta_1 = Q15_ONE-beta; + M = st->nbands; + /* Deal with residual echo if provided */ + if (st->echo_state) + { + speex_echo_get_residual(st->echo_state, st->residual_echo, N); +#ifndef FIXED_POINT + /* If there are NaNs or ridiculous values, it'll show up in the DC and we just reset everything to zero */ + if (!(st->residual_echo[0] >=0 && st->residual_echo[0]residual_echo[i] = 0; + } +#endif + for (i=0;iecho_noise[i] = MAX32(MULT16_32_Q15(QCONST16(.6f,15),st->echo_noise[i]), st->residual_echo[i]); + filterbank_compute_bank32(st->bank, st->echo_noise, st->echo_noise+N); + } else { + for (i=0;iecho_noise[i] = 0; + } + preprocess_analysis(st, x); + + update_noise_prob(st); + + /* Noise estimation always updated for the 10 first frames */ + /*if (st->nb_adapt<10) + { + for (i=1;iupdate_prob[i] = 0; + } + */ + + /* Update the noise estimate for the frequencies where it can be */ + for (i=0;iupdate_prob[i] || st->ps[i] < PSHR32(st->noise[i], NOISE_SHIFT)) + st->noise[i] = MAX32(EXTEND32(0),MULT16_32_Q15(beta_1,st->noise[i]) + MULT16_32_Q15(beta,SHL32(st->ps[i],NOISE_SHIFT))); + } + filterbank_compute_bank32(st->bank, st->noise, st->noise+N); + + /* Special case for first frame */ + if (st->nb_adapt==1) + for (i=0;iold_ps[i] = ps[i]; + + /* Compute a posteriori SNR */ + for (i=0;inoise[i],NOISE_SHIFT)) , st->echo_noise[i]) , st->reverb_estimate[i]); + + /* A posteriori SNR = ps/noise - 1*/ + st->post[i] = SUB16(DIV32_16_Q8(ps[i],tot_noise), QCONST16(1.f,SNR_SHIFT)); + st->post[i]=MIN16(st->post[i], QCONST16(100.f,SNR_SHIFT)); + + /* Computing update gamma = .1 + .9*(old/(old+noise))^2 */ + gamma = QCONST16(.1f,15)+MULT16_16_Q15(QCONST16(.89f,15),SQR16_Q15(DIV32_16_Q15(st->old_ps[i],ADD32(st->old_ps[i],tot_noise)))); + + /* A priori SNR update = gamma*max(0,post) + (1-gamma)*old/noise */ + st->prior[i] = EXTRACT16(PSHR32(ADD32(MULT16_16(gamma,MAX16(0,st->post[i])), MULT16_16(Q15_ONE-gamma,DIV32_16_Q8(st->old_ps[i],tot_noise))), 15)); + st->prior[i]=MIN16(st->prior[i], QCONST16(100.f,SNR_SHIFT)); + } + + /*print_vec(st->post, N+M, "");*/ + + /* Recursive average of the a priori SNR. A bit smoothed for the psd components */ + st->zeta[0] = PSHR32(ADD32(MULT16_16(QCONST16(.7f,15),st->zeta[0]), MULT16_16(QCONST16(.3f,15),st->prior[0])),15); + for (i=1;izeta[i] = PSHR32(ADD32(ADD32(ADD32(MULT16_16(QCONST16(.7f,15),st->zeta[i]), MULT16_16(QCONST16(.15f,15),st->prior[i])), + MULT16_16(QCONST16(.075f,15),st->prior[i-1])), MULT16_16(QCONST16(.075f,15),st->prior[i+1])),15); + for (i=N-1;izeta[i] = PSHR32(ADD32(MULT16_16(QCONST16(.7f,15),st->zeta[i]), MULT16_16(QCONST16(.3f,15),st->prior[i])),15); + + /* Speech probability of presence for the entire frame is based on the average filterbank a priori SNR */ + Zframe = 0; + for (i=N;izeta[i])); + Pframe = QCONST16(.1f,15)+MULT16_16_Q15(QCONST16(.899f,15),qcurve(DIV32_16(Zframe,st->nbands))); + + effective_echo_suppress = EXTRACT16(PSHR32(ADD32(MULT16_16(SUB16(Q15_ONE,Pframe), st->echo_suppress), MULT16_16(Pframe, st->echo_suppress_active)),15)); + + compute_gain_floor(st->noise_suppress, effective_echo_suppress, st->noise+N, st->echo_noise+N, st->gain_floor+N, M); + + /* Compute Ephraim & Malah gain speech probability of presence for each critical band (Bark scale) + Technically this is actually wrong because the EM gaim assumes a slightly different probability + distribution */ + for (i=N;iprior[i]), 15), ADD16(st->prior[i], SHL32(1,SNR_SHIFT))); + theta = MULT16_32_P15(prior_ratio, QCONST32(1.f,EXPIN_SHIFT)+SHL32(EXTEND32(st->post[i]),EXPIN_SHIFT-SNR_SHIFT)); + + MM = hypergeom_gain(theta); + /* Gain with bound */ + st->gain[i] = EXTRACT16(MIN32(Q15_ONE, MULT16_32_Q15(prior_ratio, MM))); + /* Save old Bark power spectrum */ + st->old_ps[i] = MULT16_32_P15(QCONST16(.2f,15),st->old_ps[i]) + MULT16_32_P15(MULT16_16_P15(QCONST16(.8f,15),SQR16_Q15(st->gain[i])),ps[i]); + + P1 = QCONST16(.199f,15)+MULT16_16_Q15(QCONST16(.8f,15),qcurve (st->zeta[i])); + q = Q15_ONE-MULT16_16_Q15(Pframe,P1); +#ifdef FIXED_POINT + theta = MIN32(theta, EXTEND32(32767)); +/*Q8*/tmp = MULT16_16_Q15((SHL32(1,SNR_SHIFT)+st->prior[i]),EXTRACT16(MIN32(Q15ONE,SHR32(spx_exp(-EXTRACT16(theta)),1)))); + tmp = MIN16(QCONST16(3.,SNR_SHIFT), tmp); /* Prevent overflows in the next line*/ +/*Q8*/tmp = EXTRACT16(PSHR32(MULT16_16(PDIV32_16(SHL32(EXTEND32(q),8),(Q15_ONE-q)),tmp),8)); + st->gain2[i]=DIV32_16(SHL32(EXTEND32(32767),SNR_SHIFT), ADD16(256,tmp)); +#else + st->gain2[i]=1/(1.f + (q/(1.f-q))*(1+st->prior[i])*exp(-theta)); +#endif + } + /* Convert the EM gains and speech prob to linear frequency */ + filterbank_compute_psd16(st->bank,st->gain2+N, st->gain2); + filterbank_compute_psd16(st->bank,st->gain+N, st->gain); + + /* Use 1 for linear gain resolution (best) or 0 for Bark gain resolution (faster) */ + if (1) + { + filterbank_compute_psd16(st->bank,st->gain_floor+N, st->gain_floor); + + /* Compute gain according to the Ephraim-Malah algorithm -- linear frequency */ + for (i=0;iprior[i]), 15), ADD16(st->prior[i], SHL32(1,SNR_SHIFT))); + theta = MULT16_32_P15(prior_ratio, QCONST32(1.f,EXPIN_SHIFT)+SHL32(EXTEND32(st->post[i]),EXPIN_SHIFT-SNR_SHIFT)); + + /* Optimal estimator for loudness domain */ + MM = hypergeom_gain(theta); + /* EM gain with bound */ + g = EXTRACT16(MIN32(Q15_ONE, MULT16_32_Q15(prior_ratio, MM))); + /* Interpolated speech probability of presence */ + p = st->gain2[i]; + + /* Constrain the gain to be close to the Bark scale gain */ + if (MULT16_16_Q15(QCONST16(.333f,15),g) > st->gain[i]) + g = MULT16_16(3,st->gain[i]); + st->gain[i] = g; + + /* Save old power spectrum */ + st->old_ps[i] = MULT16_32_P15(QCONST16(.2f,15),st->old_ps[i]) + MULT16_32_P15(MULT16_16_P15(QCONST16(.8f,15),SQR16_Q15(st->gain[i])),ps[i]); + + /* Apply gain floor */ + if (st->gain[i] < st->gain_floor[i]) + st->gain[i] = st->gain_floor[i]; + + /* Exponential decay model for reverberation (unused) */ + /*st->reverb_estimate[i] = st->reverb_decay*st->reverb_estimate[i] + st->reverb_decay*st->reverb_level*st->gain[i]*st->gain[i]*st->ps[i];*/ + + /* Take into account speech probability of presence (loudness domain MMSE estimator) */ + /* gain2 = [p*sqrt(gain)+(1-p)*sqrt(gain _floor) ]^2 */ + tmp = MULT16_16_P15(p,spx_sqrt(SHL32(EXTEND32(st->gain[i]),15))) + MULT16_16_P15(SUB16(Q15_ONE,p),spx_sqrt(SHL32(EXTEND32(st->gain_floor[i]),15))); + st->gain2[i]=SQR16_Q15(tmp); + + /* Use this if you want a log-domain MMSE estimator instead */ + /*st->gain2[i] = pow(st->gain[i], p) * pow(st->gain_floor[i],1.f-p);*/ + } + } else { + for (i=N;igain2[i]; + st->gain[i] = MAX16(st->gain[i], st->gain_floor[i]); + tmp = MULT16_16_P15(p,spx_sqrt(SHL32(EXTEND32(st->gain[i]),15))) + MULT16_16_P15(SUB16(Q15_ONE,p),spx_sqrt(SHL32(EXTEND32(st->gain_floor[i]),15))); + st->gain2[i]=SQR16_Q15(tmp); + } + filterbank_compute_psd16(st->bank,st->gain2+N, st->gain2); + } + + /* If noise suppression is off, don't apply the gain (but then why call this in the first place!) */ + if (!st->denoise_enabled) + { + for (i=0;igain2[i]=Q15_ONE; + } + + /* Apply computed gain */ + for (i=1;ift[2*i-1] = MULT16_16_P15(st->gain2[i],st->ft[2*i-1]); + st->ft[2*i] = MULT16_16_P15(st->gain2[i],st->ft[2*i]); + } + st->ft[0] = MULT16_16_P15(st->gain2[0],st->ft[0]); + st->ft[2*N-1] = MULT16_16_P15(st->gain2[N-1],st->ft[2*N-1]); + + /*FIXME: This *will* not work for fixed-point */ +#ifndef FIXED_POINT + if (st->agc_enabled) + speex_compute_agc(st, Pframe, st->ft); +#endif + + /* Inverse FFT with 1/N scaling */ + spx_ifft(st->fft_lookup, st->ft, st->frame); + /* Scale back to original (lower) amplitude */ + for (i=0;i<2*N;i++) + st->frame[i] = PSHR16(st->frame[i], st->frame_shift); + + /*FIXME: This *will* not work for fixed-point */ +#ifndef FIXED_POINT + if (st->agc_enabled) + { + float max_sample=0; + for (i=0;i<2*N;i++) + if (fabs(st->frame[i])>max_sample) + max_sample = fabs(st->frame[i]); + if (max_sample>28000.f) + { + float damp = 28000.f/max_sample; + for (i=0;i<2*N;i++) + st->frame[i] *= damp; + } + } +#endif + + /* Synthesis window (for WOLA) */ + for (i=0;i<2*N;i++) + st->frame[i] = MULT16_16_Q15(st->frame[i], st->window[i]); + + /* Perform overlap and add */ + for (i=0;ioutbuf[i] + st->frame[i]; + for (i=0;iframe[N3+i]; + + /* Update outbuf */ + for (i=0;ioutbuf[i] = st->frame[st->frame_size+i]; + + /* FIXME: This VAD is a kludge */ + if (st->vad_enabled) + { + if (Pframe > st->speech_prob_start || (st->was_speech && Pframe > st->speech_prob_continue)) + { + st->was_speech=1; + return 1; + } else + { + st->was_speech=0; + return 0; + } + } else { + return 1; + } +} + +void speex_preprocess_estimate_update(SpeexPreprocessState *st, spx_int16_t *x) +{ + int i; + int N = st->ps_size; + int N3 = 2*N - st->frame_size; + int M; + spx_word32_t *ps=st->ps; + + M = st->nbands; + st->min_count++; + + preprocess_analysis(st, x); + + update_noise_prob(st); + + for (i=1;iupdate_prob[i] || st->ps[i] < PSHR32(st->noise[i],NOISE_SHIFT)) + { + st->noise[i] = MULT16_32_Q15(QCONST16(.95f,15),st->noise[i]) + MULT16_32_Q15(QCONST16(.05f,15),SHL32(st->ps[i],NOISE_SHIFT)); + } + } + + for (i=0;ioutbuf[i] = MULT16_16_Q15(x[st->frame_size-N3+i],st->window[st->frame_size+i]); + + /* Save old power spectrum */ + for (i=0;iold_ps[i] = ps[i]; + + for (i=0;ireverb_estimate[i] = MULT16_32_Q15(st->reverb_decay, st->reverb_estimate[i]); +} + + +int speex_preprocess_ctl(SpeexPreprocessState *state, int request, void *ptr) +{ + int i; + SpeexPreprocessState *st; + st=(SpeexPreprocessState*)state; + switch(request) + { + case SPEEX_PREPROCESS_SET_DENOISE: + st->denoise_enabled = (*(spx_int32_t*)ptr); + break; + case SPEEX_PREPROCESS_GET_DENOISE: + (*(spx_int32_t*)ptr) = st->denoise_enabled; + break; +#ifndef FIXED_POINT + case SPEEX_PREPROCESS_SET_AGC: + st->agc_enabled = (*(spx_int32_t*)ptr); + break; + case SPEEX_PREPROCESS_GET_AGC: + (*(spx_int32_t*)ptr) = st->agc_enabled; + break; +#ifndef DISABLE_FLOAT_API + case SPEEX_PREPROCESS_SET_AGC_LEVEL: + st->agc_level = (*(float*)ptr); + if (st->agc_level<1) + st->agc_level=1; + if (st->agc_level>32768) + st->agc_level=32768; + break; + case SPEEX_PREPROCESS_GET_AGC_LEVEL: + (*(float*)ptr) = st->agc_level; + break; +#endif /* #ifndef DISABLE_FLOAT_API */ + case SPEEX_PREPROCESS_SET_AGC_INCREMENT: + st->max_increase_step = exp(0.11513f * (*(spx_int32_t*)ptr)*st->frame_size / st->sampling_rate); + break; + case SPEEX_PREPROCESS_GET_AGC_INCREMENT: + (*(spx_int32_t*)ptr) = floor(.5+8.6858*log(st->max_increase_step)*st->sampling_rate/st->frame_size); + break; + case SPEEX_PREPROCESS_SET_AGC_DECREMENT: + st->max_decrease_step = exp(0.11513f * (*(spx_int32_t*)ptr)*st->frame_size / st->sampling_rate); + break; + case SPEEX_PREPROCESS_GET_AGC_DECREMENT: + (*(spx_int32_t*)ptr) = floor(.5+8.6858*log(st->max_decrease_step)*st->sampling_rate/st->frame_size); + break; + case SPEEX_PREPROCESS_SET_AGC_MAX_GAIN: + st->max_gain = exp(0.11513f * (*(spx_int32_t*)ptr)); + break; + case SPEEX_PREPROCESS_GET_AGC_MAX_GAIN: + (*(spx_int32_t*)ptr) = floor(.5+8.6858*log(st->max_gain)); + break; +#endif + case SPEEX_PREPROCESS_SET_VAD: + speex_warning("The VAD has been replaced by a hack pending a complete rewrite"); + st->vad_enabled = (*(spx_int32_t*)ptr); + break; + case SPEEX_PREPROCESS_GET_VAD: + (*(spx_int32_t*)ptr) = st->vad_enabled; + break; + + case SPEEX_PREPROCESS_SET_DEREVERB: + st->dereverb_enabled = (*(spx_int32_t*)ptr); + for (i=0;ips_size;i++) + st->reverb_estimate[i]=0; + break; + case SPEEX_PREPROCESS_GET_DEREVERB: + (*(spx_int32_t*)ptr) = st->dereverb_enabled; + break; + + case SPEEX_PREPROCESS_SET_DEREVERB_LEVEL: + /* FIXME: Re-enable when de-reverberation is actually enabled again */ + /*st->reverb_level = (*(float*)ptr);*/ + break; + case SPEEX_PREPROCESS_GET_DEREVERB_LEVEL: + /* FIXME: Re-enable when de-reverberation is actually enabled again */ + /*(*(float*)ptr) = st->reverb_level;*/ + break; + + case SPEEX_PREPROCESS_SET_DEREVERB_DECAY: + /* FIXME: Re-enable when de-reverberation is actually enabled again */ + /*st->reverb_decay = (*(float*)ptr);*/ + break; + case SPEEX_PREPROCESS_GET_DEREVERB_DECAY: + /* FIXME: Re-enable when de-reverberation is actually enabled again */ + /*(*(float*)ptr) = st->reverb_decay;*/ + break; + + case SPEEX_PREPROCESS_SET_PROB_START: + *(spx_int32_t*)ptr = MIN32(100,MAX32(0, *(spx_int32_t*)ptr)); + st->speech_prob_start = DIV32_16(MULT16_16(Q15ONE,*(spx_int32_t*)ptr), 100); + break; + case SPEEX_PREPROCESS_GET_PROB_START: + (*(spx_int32_t*)ptr) = MULT16_16_Q15(st->speech_prob_start, 100); + break; + + case SPEEX_PREPROCESS_SET_PROB_CONTINUE: + *(spx_int32_t*)ptr = MIN32(100,MAX32(0, *(spx_int32_t*)ptr)); + st->speech_prob_continue = DIV32_16(MULT16_16(Q15ONE,*(spx_int32_t*)ptr), 100); + break; + case SPEEX_PREPROCESS_GET_PROB_CONTINUE: + (*(spx_int32_t*)ptr) = MULT16_16_Q15(st->speech_prob_continue, 100); + break; + + case SPEEX_PREPROCESS_SET_NOISE_SUPPRESS: + st->noise_suppress = -ABS(*(spx_int32_t*)ptr); + break; + case SPEEX_PREPROCESS_GET_NOISE_SUPPRESS: + (*(spx_int32_t*)ptr) = st->noise_suppress; + break; + case SPEEX_PREPROCESS_SET_ECHO_SUPPRESS: + st->echo_suppress = -ABS(*(spx_int32_t*)ptr); + break; + case SPEEX_PREPROCESS_GET_ECHO_SUPPRESS: + (*(spx_int32_t*)ptr) = st->echo_suppress; + break; + case SPEEX_PREPROCESS_SET_ECHO_SUPPRESS_ACTIVE: + st->echo_suppress_active = -ABS(*(spx_int32_t*)ptr); + break; + case SPEEX_PREPROCESS_GET_ECHO_SUPPRESS_ACTIVE: + (*(spx_int32_t*)ptr) = st->echo_suppress_active; + break; + case SPEEX_PREPROCESS_SET_ECHO_STATE: + st->echo_state = (SpeexEchoState*)ptr; + break; + case SPEEX_PREPROCESS_GET_ECHO_STATE: + ptr = (void*)st->echo_state; + break; +#ifndef FIXED_POINT + case SPEEX_PREPROCESS_GET_AGC_LOUDNESS: + (*(spx_int32_t*)ptr) = pow(st->loudness, 1.0/LOUDNESS_EXP); + break; +#endif + + default: + speex_warning_int("Unknown speex_preprocess_ctl request: ", request); + return -1; + } + return 0; +} diff --git a/lib/rbcodec/codecs/libspeex/pseudofloat.h b/lib/rbcodec/codecs/libspeex/pseudofloat.h new file mode 100644 index 0000000000..448dd61ffe --- /dev/null +++ b/lib/rbcodec/codecs/libspeex/pseudofloat.h @@ -0,0 +1,382 @@ +/* Copyright (C) 2005 Jean-Marc Valin */ +/** + @file pseudofloat.h + @brief Pseudo-floating point + * This header file provides a lightweight floating point type for + * use on fixed-point platforms when a large dynamic range is + * required. The new type is not compatible with the 32-bit IEEE format, + * it is not even remotely as accurate as 32-bit floats, and is not + * even guaranteed to produce even remotely correct results for code + * other than Speex. It makes all kinds of shortcuts that are acceptable + * for Speex, but may not be acceptable for your application. You're + * quite welcome to reuse this code and improve it, but don't assume + * it works out of the box. Most likely, it doesn't. + */ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + - Neither the name of the Xiph.org Foundation nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef PSEUDOFLOAT_H +#define PSEUDOFLOAT_H + +#include "arch.h" +#include "os_support.h" +#include "math_approx.h" +#include + +#ifdef FIXED_POINT + +typedef struct { + spx_int16_t m; + spx_int16_t e; +} spx_float_t; + +static const spx_float_t FLOAT_ZERO = {0,0}; +static const spx_float_t FLOAT_ONE = {16384,-14}; +static const spx_float_t FLOAT_HALF = {16384,-15}; + +#ifdef MIN +#undef MIN +#endif +#define MIN(a,b) ((a)<(b)?(a):(b)) +static inline spx_float_t PSEUDOFLOAT(spx_int32_t x) +{ + int e=0; + int sign=0; + if (x<0) + { + sign = 1; + x = -x; + } + if (x==0) + { + spx_float_t r = {0,0}; + return r; + } + e = spx_ilog2(ABS32(x))-14; + x = VSHR32(x, e); + if (sign) + { + spx_float_t r; + r.m = -x; + r.e = e; + return r; + } + else + { + spx_float_t r; + r.m = x; + r.e = e; + return r; + } +} + + +static inline spx_float_t FLOAT_ADD(spx_float_t a, spx_float_t b) +{ + spx_float_t r; + if (a.m==0) + return b; + else if (b.m==0) + return a; + if ((a).e > (b).e) + { + r.m = ((a).m>>1) + ((b).m>>MIN(15,(a).e-(b).e+1)); + r.e = (a).e+1; + } + else + { + r.m = ((b).m>>1) + ((a).m>>MIN(15,(b).e-(a).e+1)); + r.e = (b).e+1; + } + if (r.m>0) + { + if (r.m<16384) + { + r.m<<=1; + r.e-=1; + } + } else { + if (r.m>-16384) + { + r.m<<=1; + r.e-=1; + } + } + /*printf ("%f + %f = %f\n", REALFLOAT(a), REALFLOAT(b), REALFLOAT(r));*/ + return r; +} + +static inline spx_float_t FLOAT_SUB(spx_float_t a, spx_float_t b) +{ + spx_float_t r; + if (a.m==0) + return b; + else if (b.m==0) + return a; + if ((a).e > (b).e) + { + r.m = ((a).m>>1) - ((b).m>>MIN(15,(a).e-(b).e+1)); + r.e = (a).e+1; + } + else + { + r.m = ((a).m>>MIN(15,(b).e-(a).e+1)) - ((b).m>>1); + r.e = (b).e+1; + } + if (r.m>0) + { + if (r.m<16384) + { + r.m<<=1; + r.e-=1; + } + } else { + if (r.m>-16384) + { + r.m<<=1; + r.e-=1; + } + } + /*printf ("%f + %f = %f\n", REALFLOAT(a), REALFLOAT(b), REALFLOAT(r));*/ + return r; +} + +static inline int FLOAT_LT(spx_float_t a, spx_float_t b) +{ + if (a.m==0) + return b.m>0; + else if (b.m==0) + return a.m<0; + if ((a).e > (b).e) + return ((a).m>>1) < ((b).m>>MIN(15,(a).e-(b).e+1)); + else + return ((b).m>>1) > ((a).m>>MIN(15,(b).e-(a).e+1)); + +} + +static inline int FLOAT_GT(spx_float_t a, spx_float_t b) +{ + return FLOAT_LT(b,a); +} + +static inline spx_float_t FLOAT_MULT(spx_float_t a, spx_float_t b) +{ + spx_float_t r; + r.m = (spx_int16_t)((spx_int32_t)(a).m*(b).m>>15); + r.e = (a).e+(b).e+15; + if (r.m>0) + { + if (r.m<16384) + { + r.m<<=1; + r.e-=1; + } + } else { + if (r.m>-16384) + { + r.m<<=1; + r.e-=1; + } + } + /*printf ("%f * %f = %f\n", REALFLOAT(a), REALFLOAT(b), REALFLOAT(r));*/ + return r; +} + +static inline spx_float_t FLOAT_AMULT(spx_float_t a, spx_float_t b) +{ + spx_float_t r; + r.m = (spx_int16_t)((spx_int32_t)(a).m*(b).m>>15); + r.e = (a).e+(b).e+15; + return r; +} + + +static inline spx_float_t FLOAT_SHL(spx_float_t a, int b) +{ + spx_float_t r; + r.m = a.m; + r.e = a.e+b; + return r; +} + +static inline spx_int16_t FLOAT_EXTRACT16(spx_float_t a) +{ + if (a.e<0) + return EXTRACT16((EXTEND32(a.m)+(EXTEND32(1)<<(-a.e-1)))>>-a.e); + else + return a.m<>-a.e; + else + return EXTEND32(a.m)<=SHL32(EXTEND32(b.m-1),15)) + { + a >>= 1; + e++; + } + r.m = DIV32_16(a,b.m); + r.e = e-b.e; + return r; +} + + +/* Do NOT attempt to divide by a negative number */ +static inline spx_float_t FLOAT_DIV32(spx_word32_t a, spx_word32_t b) +{ + int e0=0,e=0; + spx_float_t r; + if (a==0) + { + return FLOAT_ZERO; + } + if (b>32767) + { + e0 = spx_ilog2(b)-14; + b = VSHR32(b, e0); + e0 = -e0; + } + e = spx_ilog2(ABS32(a))-spx_ilog2(b-1)-15; + a = VSHR32(a, e); + if (ABS32(a)>=SHL32(EXTEND32(b-1),15)) + { + a >>= 1; + e++; + } + e += e0; + r.m = DIV32_16(a,b); + r.e = e; + return r; +} + +/* Do NOT attempt to divide by a negative number */ +static inline spx_float_t FLOAT_DIVU(spx_float_t a, spx_float_t b) +{ + int e=0; + spx_int32_t num; + spx_float_t r; + if (b.m<=0) + { + speex_warning_int("Attempted to divide by", b.m); + return FLOAT_ONE; + } + num = a.m; + a.m = ABS16(a.m); + while (a.m >= b.m) + { + e++; + a.m >>= 1; + } + num = num << (15-e); + r.m = DIV32_16(num,b.m); + r.e = a.e-b.e-15+e; + return r; +} + +static inline spx_float_t FLOAT_SQRT(spx_float_t a) +{ + spx_float_t r; + spx_int32_t m; + m = SHL32(EXTEND32(a.m), 14); + r.e = a.e - 14; + if (r.e & 1) + { + r.e -= 1; + m <<= 1; + } + r.e >>= 1; + r.m = spx_sqrt(m); + return r; +} + +#else + +#define spx_float_t float +#define FLOAT_ZERO 0.f +#define FLOAT_ONE 1.f +#define FLOAT_HALF 0.5f +#define PSEUDOFLOAT(x) (x) +#define FLOAT_MULT(a,b) ((a)*(b)) +#define FLOAT_AMULT(a,b) ((a)*(b)) +#define FLOAT_MUL32(a,b) ((a)*(b)) +#define FLOAT_DIV32(a,b) ((a)/(b)) +#define FLOAT_EXTRACT16(a) (a) +#define FLOAT_EXTRACT32(a) (a) +#define FLOAT_ADD(a,b) ((a)+(b)) +#define FLOAT_SUB(a,b) ((a)-(b)) +#define REALFLOAT(x) (x) +#define FLOAT_DIV32_FLOAT(a,b) ((a)/(b)) +#define FLOAT_MUL32U(a,b) ((a)*(b)) +#define FLOAT_SHL(a,b) (a) +#define FLOAT_LT(a,b) ((a)<(b)) +#define FLOAT_GT(a,b) ((a)>(b)) +#define FLOAT_DIVU(a,b) ((a)/(b)) +#define FLOAT_SQRT(a) (spx_sqrt(a)) + +#endif + +#endif diff --git a/lib/rbcodec/codecs/libspeex/quant_lsp.c b/lib/rbcodec/codecs/libspeex/quant_lsp.c new file mode 100644 index 0000000000..9b9104c842 --- /dev/null +++ b/lib/rbcodec/codecs/libspeex/quant_lsp.c @@ -0,0 +1,391 @@ +/* Copyright (C) 2002 Jean-Marc Valin + File: quant_lsp.c + LSP vector quantization + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + - Neither the name of the Xiph.org Foundation nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifdef HAVE_CONFIG_H +#include "config-speex.h" +#endif + +#include "quant_lsp.h" +#include "os_support.h" +#include +#ifndef M_PI +#define M_PI 3.14159265358979323846 +#endif + +#include "arch.h" + +#ifdef BFIN_ASM +#include "quant_lsp_bfin.h" +#endif + +#ifdef FIXED_POINT + +#define LSP_LINEAR(i) (SHL16(i+1,11)) +#define LSP_LINEAR_HIGH(i) (ADD16(MULT16_16_16(i,2560),6144)) +#define LSP_DIV_256(x) (SHL16((spx_word16_t)x, 5)) +#define LSP_DIV_512(x) (SHL16((spx_word16_t)x, 4)) +#define LSP_DIV_1024(x) (SHL16((spx_word16_t)x, 3)) +#define LSP_PI 25736 + +#else + +#define LSP_LINEAR(i) (.25*(i)+.25) +#define LSP_LINEAR_HIGH(i) (.3125*(i)+.75) +#define LSP_SCALE 256. +#define LSP_DIV_256(x) (0.0039062*(x)) +#define LSP_DIV_512(x) (0.0019531*(x)) +#define LSP_DIV_1024(x) (0.00097656*(x)) +#define LSP_PI M_PI + +#endif + +#ifndef SPEEX_DISABLE_ENCODER +static void compute_quant_weights(spx_lsp_t *qlsp, spx_word16_t *quant_weight, int order) +{ + int i; + spx_word16_t tmp1, tmp2; + for (i=0;i tmp2 ? tmp1 : tmp2; + }*/ + + for (i=0;i>> 16;\n\t" +" R1 = (A1 += R2.L*R0.H) (IS);\n\t" +"lwq4: R3 = R3 + R1;\n\t" + +" cc =R3<%0;\n\t" +" if cc %0=R3;\n\t" +" if cc %1=R5;\n\t" +"lwq2: R5 += 1;\n\t" +" L0 = 0;\n\t" +" L1 = 0;\n\t" + : "=&d" (best_dist), "=&d" (best_id) + : "a" (x), "a" (weight), "b" (cdbk), "a" (nbVec), "a" (nbDim) + : "I0", "I1", "P2", "R0", "R1", "R2", "R3", "R5", "A1", + "L0", "L1", "B0", "B1" + ); + + for (j=0;j +static void *speex_alloc (int size) {return calloc(size,1);} +static void *speex_realloc (void *ptr, int size) {return realloc(ptr, size);} +static void speex_free (void *ptr) {free(ptr);} +#include "speex_resampler.h" +#include "arch.h" +#else /* OUTSIDE_SPEEX */ + +#include "speex/speex_resampler.h" +#include "arch.h" +#include "os_support.h" +#endif /* OUTSIDE_SPEEX */ + +#include + +#ifndef M_PI +#define M_PI 3.14159263 +#endif + +#ifdef FIXED_POINT +#define WORD2INT(x) ((x) < -32767 ? -32768 : ((x) > 32766 ? 32767 : (x))) +#else +#define WORD2INT(x) ((x) < -32767.5f ? -32768 : ((x) > 32766.5f ? 32767 : floor(.5+(x)))) +#endif + +/*#define float double*/ +#define FILTER_SIZE 64 +#define OVERSAMPLE 8 + +#define IMAX(a,b) ((a) > (b) ? (a) : (b)) +#define IMIN(a,b) ((a) < (b) ? (a) : (b)) + +#ifndef NULL +#define NULL 0 +#endif + +typedef int (*resampler_basic_func)(SpeexResamplerState *, spx_uint32_t , const spx_word16_t *, spx_uint32_t *, spx_word16_t *, spx_uint32_t *); + +struct SpeexResamplerState_ { + spx_uint32_t in_rate; + spx_uint32_t out_rate; + spx_uint32_t num_rate; + spx_uint32_t den_rate; + + int quality; + spx_uint32_t nb_channels; + spx_uint32_t filt_len; + spx_uint32_t mem_alloc_size; + int int_advance; + int frac_advance; + float cutoff; + spx_uint32_t oversample; + int initialised; + int started; + + /* These are per-channel */ + spx_int32_t *last_sample; + spx_uint32_t *samp_frac_num; + spx_uint32_t *magic_samples; + + spx_word16_t *mem; + spx_word16_t *sinc_table; + spx_uint32_t sinc_table_length; + resampler_basic_func resampler_ptr; + + int in_stride; + int out_stride; +} ; + +static double kaiser12_table[68] = { + 0.99859849, 1.00000000, 0.99859849, 0.99440475, 0.98745105, 0.97779076, + 0.96549770, 0.95066529, 0.93340547, 0.91384741, 0.89213598, 0.86843014, + 0.84290116, 0.81573067, 0.78710866, 0.75723148, 0.72629970, 0.69451601, + 0.66208321, 0.62920216, 0.59606986, 0.56287762, 0.52980938, 0.49704014, + 0.46473455, 0.43304576, 0.40211431, 0.37206735, 0.34301800, 0.31506490, + 0.28829195, 0.26276832, 0.23854851, 0.21567274, 0.19416736, 0.17404546, + 0.15530766, 0.13794294, 0.12192957, 0.10723616, 0.09382272, 0.08164178, + 0.07063950, 0.06075685, 0.05193064, 0.04409466, 0.03718069, 0.03111947, + 0.02584161, 0.02127838, 0.01736250, 0.01402878, 0.01121463, 0.00886058, + 0.00691064, 0.00531256, 0.00401805, 0.00298291, 0.00216702, 0.00153438, + 0.00105297, 0.00069463, 0.00043489, 0.00025272, 0.00013031, 0.0000527734, + 0.00001000, 0.00000000}; +/* +static double kaiser12_table[36] = { + 0.99440475, 1.00000000, 0.99440475, 0.97779076, 0.95066529, 0.91384741, + 0.86843014, 0.81573067, 0.75723148, 0.69451601, 0.62920216, 0.56287762, + 0.49704014, 0.43304576, 0.37206735, 0.31506490, 0.26276832, 0.21567274, + 0.17404546, 0.13794294, 0.10723616, 0.08164178, 0.06075685, 0.04409466, + 0.03111947, 0.02127838, 0.01402878, 0.00886058, 0.00531256, 0.00298291, + 0.00153438, 0.00069463, 0.00025272, 0.0000527734, 0.00000500, 0.00000000}; +*/ +static double kaiser10_table[36] = { + 0.99537781, 1.00000000, 0.99537781, 0.98162644, 0.95908712, 0.92831446, + 0.89005583, 0.84522401, 0.79486424, 0.74011713, 0.68217934, 0.62226347, + 0.56155915, 0.50119680, 0.44221549, 0.38553619, 0.33194107, 0.28205962, + 0.23636152, 0.19515633, 0.15859932, 0.12670280, 0.09935205, 0.07632451, + 0.05731132, 0.04193980, 0.02979584, 0.02044510, 0.01345224, 0.00839739, + 0.00488951, 0.00257636, 0.00115101, 0.00035515, 0.00000000, 0.00000000}; + +static double kaiser8_table[36] = { + 0.99635258, 1.00000000, 0.99635258, 0.98548012, 0.96759014, 0.94302200, + 0.91223751, 0.87580811, 0.83439927, 0.78875245, 0.73966538, 0.68797126, + 0.63451750, 0.58014482, 0.52566725, 0.47185369, 0.41941150, 0.36897272, + 0.32108304, 0.27619388, 0.23465776, 0.19672670, 0.16255380, 0.13219758, + 0.10562887, 0.08273982, 0.06335451, 0.04724088, 0.03412321, 0.02369490, + 0.01563093, 0.00959968, 0.00527363, 0.00233883, 0.00050000, 0.00000000}; + +static double kaiser6_table[36] = { + 0.99733006, 1.00000000, 0.99733006, 0.98935595, 0.97618418, 0.95799003, + 0.93501423, 0.90755855, 0.87598009, 0.84068475, 0.80211977, 0.76076565, + 0.71712752, 0.67172623, 0.62508937, 0.57774224, 0.53019925, 0.48295561, + 0.43647969, 0.39120616, 0.34752997, 0.30580127, 0.26632152, 0.22934058, + 0.19505503, 0.16360756, 0.13508755, 0.10953262, 0.08693120, 0.06722600, + 0.05031820, 0.03607231, 0.02432151, 0.01487334, 0.00752000, 0.00000000}; + +struct FuncDef { + double *table; + int oversample; +}; + +static struct FuncDef _KAISER12 = {kaiser12_table, 64}; +#define KAISER12 (&_KAISER12) +/*static struct FuncDef _KAISER12 = {kaiser12_table, 32}; +#define KAISER12 (&_KAISER12)*/ +static struct FuncDef _KAISER10 = {kaiser10_table, 32}; +#define KAISER10 (&_KAISER10) +static struct FuncDef _KAISER8 = {kaiser8_table, 32}; +#define KAISER8 (&_KAISER8) +static struct FuncDef _KAISER6 = {kaiser6_table, 32}; +#define KAISER6 (&_KAISER6) + +struct QualityMapping { + int base_length; + int oversample; + float downsample_bandwidth; + float upsample_bandwidth; + struct FuncDef *window_func; +}; + + +/* This table maps conversion quality to internal parameters. There are two + reasons that explain why the up-sampling bandwidth is larger than the + down-sampling bandwidth: + 1) When up-sampling, we can assume that the spectrum is already attenuated + close to the Nyquist rate (from an A/D or a previous resampling filter) + 2) Any aliasing that occurs very close to the Nyquist rate will be masked + by the sinusoids/noise just below the Nyquist rate (guaranteed only for + up-sampling). +*/ +static const struct QualityMapping quality_map[11] = { + { 8, 4, 0.830f, 0.860f, KAISER6 }, /* Q0 */ + { 16, 4, 0.850f, 0.880f, KAISER6 }, /* Q1 */ + { 32, 4, 0.882f, 0.910f, KAISER6 }, /* Q2 */ /* 82.3% cutoff ( ~60 dB stop) 6 */ + { 48, 8, 0.895f, 0.917f, KAISER8 }, /* Q3 */ /* 84.9% cutoff ( ~80 dB stop) 8 */ + { 64, 8, 0.921f, 0.940f, KAISER8 }, /* Q4 */ /* 88.7% cutoff ( ~80 dB stop) 8 */ + { 80, 16, 0.922f, 0.940f, KAISER10}, /* Q5 */ /* 89.1% cutoff (~100 dB stop) 10 */ + { 96, 16, 0.940f, 0.945f, KAISER10}, /* Q6 */ /* 91.5% cutoff (~100 dB stop) 10 */ + {128, 16, 0.950f, 0.950f, KAISER10}, /* Q7 */ /* 93.1% cutoff (~100 dB stop) 10 */ + {160, 16, 0.960f, 0.960f, KAISER10}, /* Q8 */ /* 94.5% cutoff (~100 dB stop) 10 */ + {192, 32, 0.968f, 0.968f, KAISER12}, /* Q9 */ /* 95.5% cutoff (~100 dB stop) 10 */ + {256, 32, 0.975f, 0.975f, KAISER12}, /* Q10 */ /* 96.6% cutoff (~100 dB stop) 10 */ +}; +/*8,24,40,56,80,104,128,160,200,256,320*/ +static double compute_func(float x, struct FuncDef *func) +{ + float y, frac; + double interp[4]; + int ind; + y = x*func->oversample; + ind = (int)floor(y); + frac = (y-ind); + /* CSE with handle the repeated powers */ + interp[3] = -0.1666666667*frac + 0.1666666667*(frac*frac*frac); + interp[2] = frac + 0.5*(frac*frac) - 0.5*(frac*frac*frac); + /*interp[2] = 1.f - 0.5f*frac - frac*frac + 0.5f*frac*frac*frac;*/ + interp[0] = -0.3333333333*frac + 0.5*(frac*frac) - 0.1666666667*(frac*frac*frac); + /* Just to make sure we don't have rounding problems */ + interp[1] = 1.f-interp[3]-interp[2]-interp[0]; + + /*sum = frac*accum[1] + (1-frac)*accum[2];*/ + return interp[0]*func->table[ind] + interp[1]*func->table[ind+1] + interp[2]*func->table[ind+2] + interp[3]*func->table[ind+3]; +} + +#if 0 +#include +int main(int argc, char **argv) +{ + int i; + for (i=0;i<256;i++) + { + printf ("%f\n", compute_func(i/256., KAISER12)); + } + return 0; +} +#endif + +#ifdef FIXED_POINT +/* The slow way of computing a sinc for the table. Should improve that some day */ +static spx_word16_t sinc(float cutoff, float x, int N, struct FuncDef *window_func) +{ + /*fprintf (stderr, "%f ", x);*/ + float xx = x * cutoff; + if (fabs(x)<1e-6f) + return WORD2INT(32768.*cutoff); + else if (fabs(x) > .5f*N) + return 0; + /*FIXME: Can it really be any slower than this? */ + return WORD2INT(32768.*cutoff*sin(M_PI*xx)/(M_PI*xx) * compute_func(fabs(2.*x/N), window_func)); +} +#else +/* The slow way of computing a sinc for the table. Should improve that some day */ +static spx_word16_t sinc(float cutoff, float x, int N, struct FuncDef *window_func) +{ + /*fprintf (stderr, "%f ", x);*/ + float xx = x * cutoff; + if (fabs(x)<1e-6) + return cutoff; + else if (fabs(x) > .5*N) + return 0; + /*FIXME: Can it really be any slower than this? */ + return cutoff*sin(M_PI*xx)/(M_PI*xx) * compute_func(fabs(2.*x/N), window_func); +} +#endif + +#ifdef FIXED_POINT +static void cubic_coef(spx_word16_t x, spx_word16_t interp[4]) +{ + /* Compute interpolation coefficients. I'm not sure whether this corresponds to cubic interpolation + but I know it's MMSE-optimal on a sinc */ + spx_word16_t x2, x3; + x2 = MULT16_16_P15(x, x); + x3 = MULT16_16_P15(x, x2); + interp[0] = PSHR32(MULT16_16(QCONST16(-0.16667f, 15),x) + MULT16_16(QCONST16(0.16667f, 15),x3),15); + interp[1] = EXTRACT16(EXTEND32(x) + SHR32(SUB32(EXTEND32(x2),EXTEND32(x3)),1)); + interp[3] = PSHR32(MULT16_16(QCONST16(-0.33333f, 15),x) + MULT16_16(QCONST16(.5f,15),x2) - MULT16_16(QCONST16(0.16667f, 15),x3),15); + /* Just to make sure we don't have rounding problems */ + interp[2] = Q15_ONE-interp[0]-interp[1]-interp[3]; + if (interp[2]<32767) + interp[2]+=1; +} +#else +static void cubic_coef(spx_word16_t frac, spx_word16_t interp[4]) +{ + /* Compute interpolation coefficients. I'm not sure whether this corresponds to cubic interpolation + but I know it's MMSE-optimal on a sinc */ + interp[0] = -0.16667f*frac + 0.16667f*frac*frac*frac; + interp[1] = frac + 0.5f*frac*frac - 0.5f*frac*frac*frac; + /*interp[2] = 1.f - 0.5f*frac - frac*frac + 0.5f*frac*frac*frac;*/ + interp[3] = -0.33333f*frac + 0.5f*frac*frac - 0.16667f*frac*frac*frac; + /* Just to make sure we don't have rounding problems */ + interp[2] = 1.-interp[0]-interp[1]-interp[3]; +} +#endif + +static int resampler_basic_direct_single(SpeexResamplerState *st, spx_uint32_t channel_index, const spx_word16_t *in, spx_uint32_t *in_len, spx_word16_t *out, spx_uint32_t *out_len) +{ + int N = st->filt_len; + int out_sample = 0; + spx_word16_t *mem; + int last_sample = st->last_sample[channel_index]; + spx_uint32_t samp_frac_num = st->samp_frac_num[channel_index]; + mem = st->mem + channel_index * st->mem_alloc_size; + while (!(last_sample >= (spx_int32_t)*in_len || out_sample >= (spx_int32_t)*out_len)) + { + int j; + spx_word32_t sum=0; + + /* We already have all the filter coefficients pre-computed in the table */ + const spx_word16_t *ptr; + /* Do the memory part */ + for (j=0;last_sample-N+1+j < 0;j++) + { + sum += MULT16_16(mem[last_sample+j],st->sinc_table[samp_frac_num*st->filt_len+j]); + } + + /* Do the new part */ + if (in != NULL) + { + ptr = in+st->in_stride*(last_sample-N+1+j); + for (;jsinc_table[samp_frac_num*st->filt_len+j]); + ptr += st->in_stride; + } + } + + *out = PSHR32(sum,15); + out += st->out_stride; + out_sample++; + last_sample += st->int_advance; + samp_frac_num += st->frac_advance; + if (samp_frac_num >= st->den_rate) + { + samp_frac_num -= st->den_rate; + last_sample++; + } + } + st->last_sample[channel_index] = last_sample; + st->samp_frac_num[channel_index] = samp_frac_num; + return out_sample; +} + +#ifdef FIXED_POINT +#else +/* This is the same as the previous function, except with a double-precision accumulator */ +static int resampler_basic_direct_double(SpeexResamplerState *st, spx_uint32_t channel_index, const spx_word16_t *in, spx_uint32_t *in_len, spx_word16_t *out, spx_uint32_t *out_len) +{ + int N = st->filt_len; + int out_sample = 0; + spx_word16_t *mem; + int last_sample = st->last_sample[channel_index]; + spx_uint32_t samp_frac_num = st->samp_frac_num[channel_index]; + mem = st->mem + channel_index * st->mem_alloc_size; + while (!(last_sample >= (spx_int32_t)*in_len || out_sample >= (spx_int32_t)*out_len)) + { + int j; + double sum=0; + + /* We already have all the filter coefficients pre-computed in the table */ + const spx_word16_t *ptr; + /* Do the memory part */ + for (j=0;last_sample-N+1+j < 0;j++) + { + sum += MULT16_16(mem[last_sample+j],(double)st->sinc_table[samp_frac_num*st->filt_len+j]); + } + + /* Do the new part */ + if (in != NULL) + { + ptr = in+st->in_stride*(last_sample-N+1+j); + for (;jsinc_table[samp_frac_num*st->filt_len+j]); + ptr += st->in_stride; + } + } + + *out = sum; + out += st->out_stride; + out_sample++; + last_sample += st->int_advance; + samp_frac_num += st->frac_advance; + if (samp_frac_num >= st->den_rate) + { + samp_frac_num -= st->den_rate; + last_sample++; + } + } + st->last_sample[channel_index] = last_sample; + st->samp_frac_num[channel_index] = samp_frac_num; + return out_sample; +} +#endif + +static int resampler_basic_interpolate_single(SpeexResamplerState *st, spx_uint32_t channel_index, const spx_word16_t *in, spx_uint32_t *in_len, spx_word16_t *out, spx_uint32_t *out_len) +{ + int N = st->filt_len; + int out_sample = 0; + spx_word16_t *mem; + int last_sample = st->last_sample[channel_index]; + spx_uint32_t samp_frac_num = st->samp_frac_num[channel_index]; + mem = st->mem + channel_index * st->mem_alloc_size; + while (!(last_sample >= (spx_int32_t)*in_len || out_sample >= (spx_int32_t)*out_len)) + { + int j; + spx_word32_t sum=0; + + /* We need to interpolate the sinc filter */ + spx_word32_t accum[4] = {0.f,0.f, 0.f, 0.f}; + spx_word16_t interp[4]; + const spx_word16_t *ptr; + int offset; + spx_word16_t frac; + offset = samp_frac_num*st->oversample/st->den_rate; +#ifdef FIXED_POINT + frac = PDIV32(SHL32((samp_frac_num*st->oversample) % st->den_rate,15),st->den_rate); +#else + frac = ((float)((samp_frac_num*st->oversample) % st->den_rate))/st->den_rate; +#endif + /* This code is written like this to make it easy to optimise with SIMD. + For most DSPs, it would be best to split the loops in two because most DSPs + have only two accumulators */ + for (j=0;last_sample-N+1+j < 0;j++) + { + spx_word16_t curr_mem = mem[last_sample+j]; + accum[0] += MULT16_16(curr_mem,st->sinc_table[4+(j+1)*st->oversample-offset-2]); + accum[1] += MULT16_16(curr_mem,st->sinc_table[4+(j+1)*st->oversample-offset-1]); + accum[2] += MULT16_16(curr_mem,st->sinc_table[4+(j+1)*st->oversample-offset]); + accum[3] += MULT16_16(curr_mem,st->sinc_table[4+(j+1)*st->oversample-offset+1]); + } + + if (in != NULL) + { + ptr = in+st->in_stride*(last_sample-N+1+j); + /* Do the new part */ + for (;jin_stride; + accum[0] += MULT16_16(curr_in,st->sinc_table[4+(j+1)*st->oversample-offset-2]); + accum[1] += MULT16_16(curr_in,st->sinc_table[4+(j+1)*st->oversample-offset-1]); + accum[2] += MULT16_16(curr_in,st->sinc_table[4+(j+1)*st->oversample-offset]); + accum[3] += MULT16_16(curr_in,st->sinc_table[4+(j+1)*st->oversample-offset+1]); + } + } + cubic_coef(frac, interp); + sum = MULT16_32_Q15(interp[0],accum[0]) + MULT16_32_Q15(interp[1],accum[1]) + MULT16_32_Q15(interp[2],accum[2]) + MULT16_32_Q15(interp[3],accum[3]); + + *out = PSHR32(sum,15); + out += st->out_stride; + out_sample++; + last_sample += st->int_advance; + samp_frac_num += st->frac_advance; + if (samp_frac_num >= st->den_rate) + { + samp_frac_num -= st->den_rate; + last_sample++; + } + } + st->last_sample[channel_index] = last_sample; + st->samp_frac_num[channel_index] = samp_frac_num; + return out_sample; +} + +#ifdef FIXED_POINT +#else +/* This is the same as the previous function, except with a double-precision accumulator */ +static int resampler_basic_interpolate_double(SpeexResamplerState *st, spx_uint32_t channel_index, const spx_word16_t *in, spx_uint32_t *in_len, spx_word16_t *out, spx_uint32_t *out_len) +{ + int N = st->filt_len; + int out_sample = 0; + spx_word16_t *mem; + int last_sample = st->last_sample[channel_index]; + spx_uint32_t samp_frac_num = st->samp_frac_num[channel_index]; + mem = st->mem + channel_index * st->mem_alloc_size; + while (!(last_sample >= (spx_int32_t)*in_len || out_sample >= (spx_int32_t)*out_len)) + { + int j; + spx_word32_t sum=0; + + /* We need to interpolate the sinc filter */ + double accum[4] = {0.f,0.f, 0.f, 0.f}; + float interp[4]; + const spx_word16_t *ptr; + float alpha = ((float)samp_frac_num)/st->den_rate; + int offset = samp_frac_num*st->oversample/st->den_rate; + float frac = alpha*st->oversample - offset; + /* This code is written like this to make it easy to optimise with SIMD. + For most DSPs, it would be best to split the loops in two because most DSPs + have only two accumulators */ + for (j=0;last_sample-N+1+j < 0;j++) + { + double curr_mem = mem[last_sample+j]; + accum[0] += MULT16_16(curr_mem,st->sinc_table[4+(j+1)*st->oversample-offset-2]); + accum[1] += MULT16_16(curr_mem,st->sinc_table[4+(j+1)*st->oversample-offset-1]); + accum[2] += MULT16_16(curr_mem,st->sinc_table[4+(j+1)*st->oversample-offset]); + accum[3] += MULT16_16(curr_mem,st->sinc_table[4+(j+1)*st->oversample-offset+1]); + } + if (in != NULL) + { + ptr = in+st->in_stride*(last_sample-N+1+j); + /* Do the new part */ + for (;jin_stride; + accum[0] += MULT16_16(curr_in,st->sinc_table[4+(j+1)*st->oversample-offset-2]); + accum[1] += MULT16_16(curr_in,st->sinc_table[4+(j+1)*st->oversample-offset-1]); + accum[2] += MULT16_16(curr_in,st->sinc_table[4+(j+1)*st->oversample-offset]); + accum[3] += MULT16_16(curr_in,st->sinc_table[4+(j+1)*st->oversample-offset+1]); + } + } + cubic_coef(frac, interp); + sum = interp[0]*accum[0] + interp[1]*accum[1] + interp[2]*accum[2] + interp[3]*accum[3]; + + *out = PSHR32(sum,15); + out += st->out_stride; + out_sample++; + last_sample += st->int_advance; + samp_frac_num += st->frac_advance; + if (samp_frac_num >= st->den_rate) + { + samp_frac_num -= st->den_rate; + last_sample++; + } + } + st->last_sample[channel_index] = last_sample; + st->samp_frac_num[channel_index] = samp_frac_num; + return out_sample; +} +#endif + +static void update_filter(SpeexResamplerState *st) +{ + spx_uint32_t old_length; + + old_length = st->filt_len; + st->oversample = quality_map[st->quality].oversample; + st->filt_len = quality_map[st->quality].base_length; + + if (st->num_rate > st->den_rate) + { + /* down-sampling */ + st->cutoff = quality_map[st->quality].downsample_bandwidth * st->den_rate / st->num_rate; + /* FIXME: divide the numerator and denominator by a certain amount if they're too large */ + st->filt_len = st->filt_len*st->num_rate / st->den_rate; + /* Round down to make sure we have a multiple of 4 */ + st->filt_len &= (~0x3); + if (2*st->den_rate < st->num_rate) + st->oversample >>= 1; + if (4*st->den_rate < st->num_rate) + st->oversample >>= 1; + if (8*st->den_rate < st->num_rate) + st->oversample >>= 1; + if (16*st->den_rate < st->num_rate) + st->oversample >>= 1; + if (st->oversample < 1) + st->oversample = 1; + } else { + /* up-sampling */ + st->cutoff = quality_map[st->quality].upsample_bandwidth; + } + + /* Choose the resampling type that requires the least amount of memory */ + if (st->den_rate <= st->oversample) + { + spx_uint32_t i; + if (!st->sinc_table) + st->sinc_table = (spx_word16_t *)speex_alloc(st->filt_len*st->den_rate*sizeof(spx_word16_t)); + else if (st->sinc_table_length < st->filt_len*st->den_rate) + { + st->sinc_table = (spx_word16_t *)speex_realloc(st->sinc_table,st->filt_len*st->den_rate*sizeof(spx_word16_t)); + st->sinc_table_length = st->filt_len*st->den_rate; + } + for (i=0;iden_rate;i++) + { + spx_int32_t j; + for (j=0;jfilt_len;j++) + { + st->sinc_table[i*st->filt_len+j] = sinc(st->cutoff,((j-(spx_int32_t)st->filt_len/2+1)-((float)i)/st->den_rate), st->filt_len, quality_map[st->quality].window_func); + } + } +#ifdef FIXED_POINT + st->resampler_ptr = resampler_basic_direct_single; +#else + if (st->quality>8) + st->resampler_ptr = resampler_basic_direct_double; + else + st->resampler_ptr = resampler_basic_direct_single; +#endif + /*fprintf (stderr, "resampler uses direct sinc table and normalised cutoff %f\n", cutoff);*/ + } else { + spx_int32_t i; + if (!st->sinc_table) + st->sinc_table = (spx_word16_t *)speex_alloc((st->filt_len*st->oversample+8)*sizeof(spx_word16_t)); + else if (st->sinc_table_length < st->filt_len*st->oversample+8) + { + st->sinc_table = (spx_word16_t *)speex_realloc(st->sinc_table,(st->filt_len*st->oversample+8)*sizeof(spx_word16_t)); + st->sinc_table_length = st->filt_len*st->oversample+8; + } + for (i=-4;i<(spx_int32_t)(st->oversample*st->filt_len+4);i++) + st->sinc_table[i+4] = sinc(st->cutoff,(i/(float)st->oversample - st->filt_len/2), st->filt_len, quality_map[st->quality].window_func); +#ifdef FIXED_POINT + st->resampler_ptr = resampler_basic_interpolate_single; +#else + if (st->quality>8) + st->resampler_ptr = resampler_basic_interpolate_double; + else + st->resampler_ptr = resampler_basic_interpolate_single; +#endif + /*fprintf (stderr, "resampler uses interpolated sinc table and normalised cutoff %f\n", cutoff);*/ + } + st->int_advance = st->num_rate/st->den_rate; + st->frac_advance = st->num_rate%st->den_rate; + + + /* Here's the place where we update the filter memory to take into account + the change in filter length. It's probably the messiest part of the code + due to handling of lots of corner cases. */ + if (!st->mem) + { + spx_uint32_t i; + st->mem = (spx_word16_t*)speex_alloc(st->nb_channels*(st->filt_len-1) * sizeof(spx_word16_t)); + for (i=0;inb_channels*(st->filt_len-1);i++) + st->mem[i] = 0; + st->mem_alloc_size = st->filt_len-1; + /*speex_warning("init filter");*/ + } else if (!st->started) + { + spx_uint32_t i; + st->mem = (spx_word16_t*)speex_realloc(st->mem, st->nb_channels*(st->filt_len-1) * sizeof(spx_word16_t)); + for (i=0;inb_channels*(st->filt_len-1);i++) + st->mem[i] = 0; + st->mem_alloc_size = st->filt_len-1; + /*speex_warning("reinit filter");*/ + } else if (st->filt_len > old_length) + { + spx_int32_t i; + /* Increase the filter length */ + /*speex_warning("increase filter size");*/ + int old_alloc_size = st->mem_alloc_size; + if (st->filt_len-1 > st->mem_alloc_size) + { + st->mem = (spx_word16_t*)speex_realloc(st->mem, st->nb_channels*(st->filt_len-1) * sizeof(spx_word16_t)); + st->mem_alloc_size = st->filt_len-1; + } + for (i=st->nb_channels-1;i>=0;i--) + { + spx_int32_t j; + spx_uint32_t olen = old_length; + /*if (st->magic_samples[i])*/ + { + /* Try and remove the magic samples as if nothing had happened */ + + /* FIXME: This is wrong but for now we need it to avoid going over the array bounds */ + olen = old_length + 2*st->magic_samples[i]; + for (j=old_length-2+st->magic_samples[i];j>=0;j--) + st->mem[i*st->mem_alloc_size+j+st->magic_samples[i]] = st->mem[i*old_alloc_size+j]; + for (j=0;jmagic_samples[i];j++) + st->mem[i*st->mem_alloc_size+j] = 0; + st->magic_samples[i] = 0; + } + if (st->filt_len > olen) + { + /* If the new filter length is still bigger than the "augmented" length */ + /* Copy data going backward */ + for (j=0;jmem[i*st->mem_alloc_size+(st->filt_len-2-j)] = st->mem[i*st->mem_alloc_size+(olen-2-j)]; + /* Then put zeros for lack of anything better */ + for (;jfilt_len-1;j++) + st->mem[i*st->mem_alloc_size+(st->filt_len-2-j)] = 0; + /* Adjust last_sample */ + st->last_sample[i] += (st->filt_len - olen)/2; + } else { + /* Put back some of the magic! */ + st->magic_samples[i] = (olen - st->filt_len)/2; + for (j=0;jfilt_len-1+st->magic_samples[i];j++) + st->mem[i*st->mem_alloc_size+j] = st->mem[i*st->mem_alloc_size+j+st->magic_samples[i]]; + } + } + } else if (st->filt_len < old_length) + { + spx_uint32_t i; + /* Reduce filter length, this a bit tricky. We need to store some of the memory as "magic" + samples so they can be used directly as input the next time(s) */ + for (i=0;inb_channels;i++) + { + spx_uint32_t j; + spx_uint32_t old_magic = st->magic_samples[i]; + st->magic_samples[i] = (old_length - st->filt_len)/2; + /* We must copy some of the memory that's no longer used */ + /* Copy data going backward */ + for (j=0;jfilt_len-1+st->magic_samples[i]+old_magic;j++) + st->mem[i*st->mem_alloc_size+j] = st->mem[i*st->mem_alloc_size+j+st->magic_samples[i]]; + st->magic_samples[i] += old_magic; + } + } + +} + +SpeexResamplerState *speex_resampler_init(spx_uint32_t nb_channels, spx_uint32_t in_rate, spx_uint32_t out_rate, int quality, int *err) +{ + return speex_resampler_init_frac(nb_channels, in_rate, out_rate, in_rate, out_rate, quality, err); +} + +SpeexResamplerState *speex_resampler_init_frac(spx_uint32_t nb_channels, spx_uint32_t ratio_num, spx_uint32_t ratio_den, spx_uint32_t in_rate, spx_uint32_t out_rate, int quality, int *err) +{ + spx_uint32_t i; + SpeexResamplerState *st; + if (quality > 10 || quality < 0) + { + if (err) + *err = RESAMPLER_ERR_INVALID_ARG; + return NULL; + } + st = (SpeexResamplerState *)speex_alloc(sizeof(SpeexResamplerState)); + st->initialised = 0; + st->started = 0; + st->in_rate = 0; + st->out_rate = 0; + st->num_rate = 0; + st->den_rate = 0; + st->quality = -1; + st->sinc_table_length = 0; + st->mem_alloc_size = 0; + st->filt_len = 0; + st->mem = 0; + st->resampler_ptr = 0; + + st->cutoff = 1.f; + st->nb_channels = nb_channels; + st->in_stride = 1; + st->out_stride = 1; + + /* Per channel data */ + st->last_sample = (spx_int32_t*)speex_alloc(nb_channels*sizeof(int)); + st->magic_samples = (spx_uint32_t*)speex_alloc(nb_channels*sizeof(int)); + st->samp_frac_num = (spx_uint32_t*)speex_alloc(nb_channels*sizeof(int)); + for (i=0;ilast_sample[i] = 0; + st->magic_samples[i] = 0; + st->samp_frac_num[i] = 0; + } + + speex_resampler_set_quality(st, quality); + speex_resampler_set_rate_frac(st, ratio_num, ratio_den, in_rate, out_rate); + + + update_filter(st); + + st->initialised = 1; + if (err) + *err = RESAMPLER_ERR_SUCCESS; + + return st; +} + +void speex_resampler_destroy(SpeexResamplerState *st) +{ + speex_free(st->mem); + speex_free(st->sinc_table); + speex_free(st->last_sample); + speex_free(st->magic_samples); + speex_free(st->samp_frac_num); + speex_free(st); +} + + + +static int speex_resampler_process_native(SpeexResamplerState *st, spx_uint32_t channel_index, const spx_word16_t *in, spx_uint32_t *in_len, spx_word16_t *out, spx_uint32_t *out_len) +{ + int j=0; + int N = st->filt_len; + int out_sample = 0; + spx_word16_t *mem; + spx_uint32_t tmp_out_len = 0; + mem = st->mem + channel_index * st->mem_alloc_size; + st->started = 1; + + /* Handle the case where we have samples left from a reduction in filter length */ + if (st->magic_samples[channel_index]) + { + int istride_save; + spx_uint32_t tmp_in_len; + spx_uint32_t tmp_magic; + + istride_save = st->in_stride; + tmp_in_len = st->magic_samples[channel_index]; + tmp_out_len = *out_len; + /* magic_samples needs to be set to zero to avoid infinite recursion */ + tmp_magic = st->magic_samples[channel_index]; + st->magic_samples[channel_index] = 0; + st->in_stride = 1; + speex_resampler_process_native(st, channel_index, mem+N-1, &tmp_in_len, out, &tmp_out_len); + st->in_stride = istride_save; + /*speex_warning_int("extra samples:", tmp_out_len);*/ + /* If we couldn't process all "magic" input samples, save the rest for next time */ + if (tmp_in_len < tmp_magic) + { + spx_uint32_t i; + st->magic_samples[channel_index] = tmp_magic-tmp_in_len; + for (i=0;imagic_samples[channel_index];i++) + mem[N-1+i]=mem[N-1+i+tmp_in_len]; + } + out += tmp_out_len*st->out_stride; + *out_len -= tmp_out_len; + } + + /* Call the right resampler through the function ptr */ + out_sample = st->resampler_ptr(st, channel_index, in, in_len, out, out_len); + + if (st->last_sample[channel_index] < (spx_int32_t)*in_len) + *in_len = st->last_sample[channel_index]; + *out_len = out_sample+tmp_out_len; + st->last_sample[channel_index] -= *in_len; + + for (j=0;jin_stride*(j+*in_len-N+1)]; + + return RESAMPLER_ERR_SUCCESS; +} + +#define FIXED_STACK_ALLOC 1024 + +#ifdef FIXED_POINT +int speex_resampler_process_float(SpeexResamplerState *st, spx_uint32_t channel_index, const float *in, spx_uint32_t *in_len, float *out, spx_uint32_t *out_len) +{ + spx_uint32_t i; + int istride_save, ostride_save; +#ifdef VAR_ARRAYS + spx_word16_t x[*in_len]; + spx_word16_t y[*out_len]; + /*VARDECL(spx_word16_t *x); + VARDECL(spx_word16_t *y); + ALLOC(x, *in_len, spx_word16_t); + ALLOC(y, *out_len, spx_word16_t);*/ + istride_save = st->in_stride; + ostride_save = st->out_stride; + for (i=0;i<*in_len;i++) + x[i] = WORD2INT(in[i*st->in_stride]); + st->in_stride = st->out_stride = 1; + speex_resampler_process_native(st, channel_index, x, in_len, y, out_len); + st->in_stride = istride_save; + st->out_stride = ostride_save; + for (i=0;i<*out_len;i++) + out[i*st->out_stride] = y[i]; +#else + spx_word16_t x[FIXED_STACK_ALLOC]; + spx_word16_t y[FIXED_STACK_ALLOC]; + spx_uint32_t ilen=*in_len, olen=*out_len; + istride_save = st->in_stride; + ostride_save = st->out_stride; + while (ilen && olen) + { + spx_uint32_t ichunk, ochunk; + ichunk = ilen; + ochunk = olen; + if (ichunk>FIXED_STACK_ALLOC) + ichunk=FIXED_STACK_ALLOC; + if (ochunk>FIXED_STACK_ALLOC) + ochunk=FIXED_STACK_ALLOC; + for (i=0;iin_stride]); + st->in_stride = st->out_stride = 1; + speex_resampler_process_native(st, channel_index, x, &ichunk, y, &ochunk); + st->in_stride = istride_save; + st->out_stride = ostride_save; + for (i=0;iout_stride] = y[i]; + out += ochunk; + in += ichunk; + ilen -= ichunk; + olen -= ochunk; + } + *in_len -= ilen; + *out_len -= olen; +#endif + return RESAMPLER_ERR_SUCCESS; +} +int speex_resampler_process_int(SpeexResamplerState *st, spx_uint32_t channel_index, const spx_int16_t *in, spx_uint32_t *in_len, spx_int16_t *out, spx_uint32_t *out_len) +{ + return speex_resampler_process_native(st, channel_index, in, in_len, out, out_len); +} +#else +int speex_resampler_process_float(SpeexResamplerState *st, spx_uint32_t channel_index, const float *in, spx_uint32_t *in_len, float *out, spx_uint32_t *out_len) +{ + return speex_resampler_process_native(st, channel_index, in, in_len, out, out_len); +} +int speex_resampler_process_int(SpeexResamplerState *st, spx_uint32_t channel_index, const spx_int16_t *in, spx_uint32_t *in_len, spx_int16_t *out, spx_uint32_t *out_len) +{ + spx_uint32_t i; + int istride_save, ostride_save; +#ifdef VAR_ARRAYS + spx_word16_t x[*in_len]; + spx_word16_t y[*out_len]; + /*VARDECL(spx_word16_t *x); + VARDECL(spx_word16_t *y); + ALLOC(x, *in_len, spx_word16_t); + ALLOC(y, *out_len, spx_word16_t);*/ + istride_save = st->in_stride; + ostride_save = st->out_stride; + for (i=0;i<*in_len;i++) + x[i] = in[i*st->in_stride]; + st->in_stride = st->out_stride = 1; + speex_resampler_process_native(st, channel_index, x, in_len, y, out_len); + st->in_stride = istride_save; + st->out_stride = ostride_save; + for (i=0;i<*out_len;i++) + out[i*st->out_stride] = WORD2INT(y[i]); +#else + spx_word16_t x[FIXED_STACK_ALLOC]; + spx_word16_t y[FIXED_STACK_ALLOC]; + spx_uint32_t ilen=*in_len, olen=*out_len; + istride_save = st->in_stride; + ostride_save = st->out_stride; + while (ilen && olen) + { + spx_uint32_t ichunk, ochunk; + ichunk = ilen; + ochunk = olen; + if (ichunk>FIXED_STACK_ALLOC) + ichunk=FIXED_STACK_ALLOC; + if (ochunk>FIXED_STACK_ALLOC) + ochunk=FIXED_STACK_ALLOC; + for (i=0;iin_stride]; + st->in_stride = st->out_stride = 1; + speex_resampler_process_native(st, channel_index, x, &ichunk, y, &ochunk); + st->in_stride = istride_save; + st->out_stride = ostride_save; + for (i=0;iout_stride] = WORD2INT(y[i]); + out += ochunk; + in += ichunk; + ilen -= ichunk; + olen -= ochunk; + } + *in_len -= ilen; + *out_len -= olen; +#endif + return RESAMPLER_ERR_SUCCESS; +} +#endif + +int speex_resampler_process_interleaved_float(SpeexResamplerState *st, const float *in, spx_uint32_t *in_len, float *out, spx_uint32_t *out_len) +{ + spx_uint32_t i; + int istride_save, ostride_save; + spx_uint32_t bak_len = *out_len; + istride_save = st->in_stride; + ostride_save = st->out_stride; + st->in_stride = st->out_stride = st->nb_channels; + for (i=0;inb_channels;i++) + { + *out_len = bak_len; + if (in != NULL) + speex_resampler_process_float(st, i, in+i, in_len, out+i, out_len); + else + speex_resampler_process_float(st, i, NULL, in_len, out+i, out_len); + } + st->in_stride = istride_save; + st->out_stride = ostride_save; + return RESAMPLER_ERR_SUCCESS; +} + + +int speex_resampler_process_interleaved_int(SpeexResamplerState *st, const spx_int16_t *in, spx_uint32_t *in_len, spx_int16_t *out, spx_uint32_t *out_len) +{ + spx_uint32_t i; + int istride_save, ostride_save; + spx_uint32_t bak_len = *out_len; + istride_save = st->in_stride; + ostride_save = st->out_stride; + st->in_stride = st->out_stride = st->nb_channels; + for (i=0;inb_channels;i++) + { + *out_len = bak_len; + if (in != NULL) + speex_resampler_process_int(st, i, in+i, in_len, out+i, out_len); + else + speex_resampler_process_int(st, i, NULL, in_len, out+i, out_len); + } + st->in_stride = istride_save; + st->out_stride = ostride_save; + return RESAMPLER_ERR_SUCCESS; +} + +int speex_resampler_set_rate(SpeexResamplerState *st, spx_uint32_t in_rate, spx_uint32_t out_rate) +{ + return speex_resampler_set_rate_frac(st, in_rate, out_rate, in_rate, out_rate); +} + +void speex_resampler_get_rate(SpeexResamplerState *st, spx_uint32_t *in_rate, spx_uint32_t *out_rate) +{ + *in_rate = st->in_rate; + *out_rate = st->out_rate; +} + +int speex_resampler_set_rate_frac(SpeexResamplerState *st, spx_uint32_t ratio_num, spx_uint32_t ratio_den, spx_uint32_t in_rate, spx_uint32_t out_rate) +{ + spx_uint32_t fact; + spx_uint32_t old_den; + spx_uint32_t i; + if (st->in_rate == in_rate && st->out_rate == out_rate && st->num_rate == ratio_num && st->den_rate == ratio_den) + return RESAMPLER_ERR_SUCCESS; + + old_den = st->den_rate; + st->in_rate = in_rate; + st->out_rate = out_rate; + st->num_rate = ratio_num; + st->den_rate = ratio_den; + /* FIXME: This is terribly inefficient, but who cares (at least for now)? */ + for (fact=2;fact<=IMIN(st->num_rate, st->den_rate);fact++) + { + while ((st->num_rate % fact == 0) && (st->den_rate % fact == 0)) + { + st->num_rate /= fact; + st->den_rate /= fact; + } + } + + if (old_den > 0) + { + for (i=0;inb_channels;i++) + { + st->samp_frac_num[i]=st->samp_frac_num[i]*st->den_rate/old_den; + /* Safety net */ + if (st->samp_frac_num[i] >= st->den_rate) + st->samp_frac_num[i] = st->den_rate-1; + } + } + + if (st->initialised) + update_filter(st); + return RESAMPLER_ERR_SUCCESS; +} + +void speex_resampler_get_ratio(SpeexResamplerState *st, spx_uint32_t *ratio_num, spx_uint32_t *ratio_den) +{ + *ratio_num = st->num_rate; + *ratio_den = st->den_rate; +} + +int speex_resampler_set_quality(SpeexResamplerState *st, int quality) +{ + if (quality > 10 || quality < 0) + return RESAMPLER_ERR_INVALID_ARG; + if (st->quality == quality) + return RESAMPLER_ERR_SUCCESS; + st->quality = quality; + if (st->initialised) + update_filter(st); + return RESAMPLER_ERR_SUCCESS; +} + +void speex_resampler_get_quality(SpeexResamplerState *st, int *quality) +{ + *quality = st->quality; +} + +void speex_resampler_set_input_stride(SpeexResamplerState *st, spx_uint32_t stride) +{ + st->in_stride = stride; +} + +void speex_resampler_get_input_stride(SpeexResamplerState *st, spx_uint32_t *stride) +{ + *stride = st->in_stride; +} + +void speex_resampler_set_output_stride(SpeexResamplerState *st, spx_uint32_t stride) +{ + st->out_stride = stride; +} + +void speex_resampler_get_output_stride(SpeexResamplerState *st, spx_uint32_t *stride) +{ + *stride = st->out_stride; +} + +int speex_resampler_skip_zeros(SpeexResamplerState *st) +{ + spx_uint32_t i; + for (i=0;inb_channels;i++) + st->last_sample[i] = st->filt_len/2; + return RESAMPLER_ERR_SUCCESS; +} + +int speex_resampler_reset_mem(SpeexResamplerState *st) +{ + spx_uint32_t i; + for (i=0;inb_channels*(st->filt_len-1);i++) + st->mem[i] = 0; + return RESAMPLER_ERR_SUCCESS; +} + +const char *speex_resampler_strerror(int err) +{ + switch (err) + { + case RESAMPLER_ERR_SUCCESS: + return "Success."; + case RESAMPLER_ERR_ALLOC_FAILED: + return "Memory allocation failed."; + case RESAMPLER_ERR_BAD_STATE: + return "Bad resampler state."; + case RESAMPLER_ERR_INVALID_ARG: + return "Invalid argument."; + case RESAMPLER_ERR_PTR_OVERLAP: + return "Input and output buffers overlap."; + default: + return "Unknown error. Bad error code or strange version mismatch."; + } +} diff --git a/lib/rbcodec/codecs/libspeex/rockbox.h b/lib/rbcodec/codecs/libspeex/rockbox.h new file mode 100644 index 0000000000..459c8b532f --- /dev/null +++ b/lib/rbcodec/codecs/libspeex/rockbox.h @@ -0,0 +1,119 @@ +/************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * + * Copyright (C) 2007 Dan Everton + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ***************************************************************************/ + +#ifndef SPEEX_ROCKBOX_H +#define SPEEX_ROCKBOX_H + +/* We don't want all this stuff if we're building encoder */ +#ifndef ROCKBOX_VOICE_ENCODER + +#include "codeclib.h" +#include "debug.h" + +#if !defined(ROCKBOX_VOICE_CODEC) + +#if defined(DEBUG) || defined(SIMULATOR) +#undef DEBUGF +#define DEBUGF ci->debugf +#endif + + +#ifdef ROCKBOX_HAS_LOGF +#undef LOGF +#define LOGF ci->logf +#endif + +#endif /* ROCKBOX_VOICE_CODEC */ + +#define OVERRIDE_SPEEX_ALLOC 1 +static inline void *speex_alloc (int size) +{ + return codec_calloc(size, 1); +} + +#define OVERRIDE_SPEEX_ALLOC_SCRATCH 1 +static inline void *speex_alloc_scratch (int size) +{ + return codec_calloc(size,1); +} + +#define OVERRIDE_SPEEX_REALLOC 1 +static inline void *speex_realloc (void *ptr, int size) +{ + return codec_realloc(ptr, size); +} + +#define OVERRIDE_SPEEX_FREE 1 +static inline void speex_free (void *ptr) +{ + codec_free(ptr); +} + +#define OVERRIDE_SPEEX_FREE_SCRATCH 1 +static inline void speex_free_scratch (void *ptr) +{ + codec_free(ptr); +} + +#define OVERRIDE_SPEEX_FATAL 1 +static inline void _speex_fatal(const char *str, const char *file, int line) +{ + (void)str; + (void)file; + (void)line; + DEBUGF("Fatal error: %s\n", str); + //exit(1); +} + +#define OVERRIDE_SPEEX_WARNING 1 +static inline void speex_warning(const char *str) +{ + (void)str; + DEBUGF("warning: %s\n", str); +} + +#define OVERRIDE_SPEEX_WARNING_INT 1 +static inline void speex_warning_int(const char *str, int val) +{ + (void)str; + (void)val; + DEBUGF("warning: %s %d\n", str, val); +} + +#define OVERRIDE_SPEEX_NOTIFY 1 +static inline void speex_notify(const char *str) +{ + (void)str; + DEBUGF("notice: %s\n", str); +} + +#define OVERRIDE_SPEEX_PUTC 1 +static inline void _speex_putc(int ch, void *file) +{ + (void)ch; + (void)file; + //FILE *f = (FILE *)file; + //printf("%c", ch); +} + +#endif /* ROCKBOX_VOICE_ENCODER */ + +#endif + diff --git a/lib/rbcodec/codecs/libspeex/sb_celp.c b/lib/rbcodec/codecs/libspeex/sb_celp.c new file mode 100644 index 0000000000..b28744812f --- /dev/null +++ b/lib/rbcodec/codecs/libspeex/sb_celp.c @@ -0,0 +1,1510 @@ +/* Copyright (C) 2002-2006 Jean-Marc Valin + File: sb_celp.c + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + - Neither the name of the Xiph.org Foundation nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifdef HAVE_CONFIG_H +#include "config-speex.h" +#endif + +#include +#include "sb_celp.h" +#include "filters.h" +#include "lpc.h" +#include "lsp.h" +#include "stack_alloc.h" +#include "cb_search.h" +#include "quant_lsp.h" +#include "vq.h" +#include "ltp.h" +#include "arch.h" +#include "math_approx.h" +#include "os_support.h" + +#ifndef NULL +#define NULL 0 +#endif + +/* Default size for the encoder and decoder stack (can be changed at compile time). + This does not apply when using variable-size arrays or alloca. */ +#ifndef SB_ENC_STACK +#define SB_ENC_STACK (10000*sizeof(spx_sig_t)) +#endif + +#ifndef SB_DEC_STACK +#define SB_DEC_STACK (6000*sizeof(spx_sig_t)) +#endif + + +#ifdef DISABLE_WIDEBAND +void *sb_encoder_init(const SpeexMode *m) +{ + speex_fatal("Wideband and Ultra-wideband are disabled"); + return NULL; +} +void sb_encoder_destroy(void *state) +{ + speex_fatal("Wideband and Ultra-wideband are disabled"); +} +int sb_encode(void *state, void *vin, SpeexBits *bits) +{ + speex_fatal("Wideband and Ultra-wideband are disabled"); + return -2; +} +void *sb_decoder_init(const SpeexMode *m) +{ + speex_fatal("Wideband and Ultra-wideband are disabled"); + return NULL; +} +void sb_decoder_destroy(void *state) +{ + speex_fatal("Wideband and Ultra-wideband are disabled"); +} +int sb_decode(void *state, SpeexBits *bits, void *vout) +{ + speex_fatal("Wideband and Ultra-wideband are disabled"); + return -2; +} +int sb_encoder_ctl(void *state, int request, void *ptr) +{ + speex_fatal("Wideband and Ultra-wideband are disabled"); + return -2; +} +int sb_decoder_ctl(void *state, int request, void *ptr) +{ + speex_fatal("Wideband and Ultra-wideband are disabled"); + return -2; +} +#else + + +#ifndef M_PI +#define M_PI 3.14159265358979323846 /* pi */ +#endif + +#define sqr(x) ((x)*(x)) + +#define SUBMODE(x) st->submodes[st->submodeID]->x + +#ifdef FIXED_POINT +static const spx_word16_t gc_quant_bound[16] ICONST_ATTR = {125, 164, 215, 282, 370, 484, 635, 832, 1090, 1428, 1871, 2452, 3213, 4210, 5516, 7228}; +static const spx_word16_t fold_quant_bound[32] ICONST_ATTR = { + 39, 44, 50, 57, 64, 73, 83, 94, + 106, 120, 136, 154, 175, 198, 225, 255, + 288, 327, 370, 420, 476, 539, 611, 692, + 784, 889, 1007, 1141, 1293, 1465, 1660, 1881}; +#define LSP_MARGIN 410 +#define LSP_DELTA1 6553 +#define LSP_DELTA2 1638 + +#else + +static const spx_word16_t gc_quant_bound[16] = { + 0.97979, 1.28384, 1.68223, 2.20426, 2.88829, 3.78458, 4.95900, 6.49787, + 8.51428, 11.15642, 14.61846, 19.15484, 25.09895, 32.88761, 43.09325, 56.46588}; +static const spx_word16_t fold_quant_bound[32] = { + 0.30498, 0.34559, 0.39161, 0.44375, 0.50283, 0.56979, 0.64565, 0.73162, + 0.82903, 0.93942, 1.06450, 1.20624, 1.36685, 1.54884, 1.75506, 1.98875, + 2.25355, 2.55360, 2.89361, 3.27889, 3.71547, 4.21018, 4.77076, 5.40598, + 6.12577, 6.94141, 7.86565, 8.91295, 10.09969, 11.44445, 12.96826, 14.69497}; + +#define LSP_MARGIN .05 +#define LSP_DELTA1 .2 +#define LSP_DELTA2 .05 + +#endif + +#define QMF_ORDER 64 + +#ifdef FIXED_POINT +static const spx_word16_t h0[64] ICONST_ATTR = {2, -7, -7, 18, 15, -39, -25, 75, 35, -130, -41, 212, 38, -327, -17, 483, -32, -689, 124, 956, -283, -1307, 543, 1780, -973, -2467, 1733, 3633, -3339, -6409, 9059, 30153, 30153, 9059, -6409, -3339, 3633, 1733, -2467, -973, 1780, 543, -1307, -283, 956, 124, -689, -32, 483, -17, -327, 38, 212, -41, -130, 35, 75, -25, -39, 15, 18, -7, -7, 2}; + +#else +static const float h0[64] = { + 3.596189e-05f, -0.0001123515f, + -0.0001104587f, 0.0002790277f, + 0.0002298438f, -0.0005953563f, + -0.0003823631f, 0.00113826f, + 0.0005308539f, -0.001986177f, + -0.0006243724f, 0.003235877f, + 0.0005743159f, -0.004989147f, + -0.0002584767f, 0.007367171f, + -0.0004857935f, -0.01050689f, + 0.001894714f, 0.01459396f, + -0.004313674f, -0.01994365f, + 0.00828756f, 0.02716055f, + -0.01485397f, -0.03764973f, + 0.026447f, 0.05543245f, + -0.05095487f, -0.09779096f, + 0.1382363f, 0.4600981f, + 0.4600981f, 0.1382363f, + -0.09779096f, -0.05095487f, + 0.05543245f, 0.026447f, + -0.03764973f, -0.01485397f, + 0.02716055f, 0.00828756f, + -0.01994365f, -0.004313674f, + 0.01459396f, 0.001894714f, + -0.01050689f, -0.0004857935f, + 0.007367171f, -0.0002584767f, + -0.004989147f, 0.0005743159f, + 0.003235877f, -0.0006243724f, + -0.001986177f, 0.0005308539f, + 0.00113826f, -0.0003823631f, + -0.0005953563f, 0.0002298438f, + 0.0002790277f, -0.0001104587f, + -0.0001123515f, 3.596189e-05f +}; + +#endif + +extern const spx_word16_t lag_window[]; +extern const spx_word16_t lpc_window[]; + +#ifndef SPEEX_DISABLE_ENCODER +void *sb_encoder_init(const SpeexMode *m) +{ + int i; + spx_int32_t tmp; + SBEncState *st; + const SpeexSBMode *mode; + + st = (SBEncState*)speex_alloc(sizeof(SBEncState)); + if (!st) + return NULL; + st->mode = m; + mode = (const SpeexSBMode*)m->mode; + + + st->st_low = speex_encoder_init(mode->nb_mode); +#if defined(VAR_ARRAYS) || defined (USE_ALLOCA) + st->stack = NULL; +#else + /*st->stack = (char*)speex_alloc_scratch(SB_ENC_STACK);*/ + speex_encoder_ctl(st->st_low, SPEEX_GET_STACK, &st->stack); +#endif + + st->full_frame_size = 2*mode->frameSize; + st->frame_size = mode->frameSize; + st->subframeSize = mode->subframeSize; + st->nbSubframes = mode->frameSize/mode->subframeSize; + st->windowSize = st->frame_size+st->subframeSize; + st->lpcSize=mode->lpcSize; + + st->encode_submode = 1; + st->submodes=mode->submodes; + st->submodeSelect = st->submodeID=mode->defaultSubmode; + + tmp=9; + speex_encoder_ctl(st->st_low, SPEEX_SET_QUALITY, &tmp); + tmp=1; + speex_encoder_ctl(st->st_low, SPEEX_SET_WIDEBAND, &tmp); + + st->lpc_floor = mode->lpc_floor; + st->gamma1=mode->gamma1; + st->gamma2=mode->gamma2; + st->first=1; + + st->high=(spx_word16_t*)speex_alloc((st->windowSize-st->frame_size)*sizeof(spx_word16_t)); + + st->h0_mem=(spx_word16_t*)speex_alloc((QMF_ORDER)*sizeof(spx_word16_t)); + st->h1_mem=(spx_word16_t*)speex_alloc((QMF_ORDER)*sizeof(spx_word16_t)); + + st->window= lpc_window; + + st->lagWindow = lag_window; + + st->old_lsp = (spx_lsp_t*)speex_alloc(st->lpcSize*sizeof(spx_lsp_t)); + st->old_qlsp = (spx_lsp_t*)speex_alloc(st->lpcSize*sizeof(spx_lsp_t)); + st->interp_qlpc = (spx_coef_t*)speex_alloc(st->lpcSize*sizeof(spx_coef_t)); + st->pi_gain = (spx_word32_t*)speex_alloc((st->nbSubframes)*sizeof(spx_word32_t)); + st->exc_rms = (spx_word16_t*)speex_alloc((st->nbSubframes)*sizeof(spx_word16_t)); + st->innov_rms_save = NULL; + + st->mem_sp = (spx_mem_t*)speex_alloc((st->lpcSize)*sizeof(spx_mem_t)); + st->mem_sp2 = (spx_mem_t*)speex_alloc((st->lpcSize)*sizeof(spx_mem_t)); + st->mem_sw = (spx_mem_t*)speex_alloc((st->lpcSize)*sizeof(spx_mem_t)); + + for (i=0;ilpcSize;i++) + st->old_lsp[i]= DIV32(MULT16_16(QCONST16(3.1415927f, LSP_SHIFT), i+1), st->lpcSize+1); + +#ifndef DISABLE_VBR + st->vbr_quality = 8; + st->vbr_enabled = 0; + st->vbr_max = 0; + st->vbr_max_high = 20000; /* We just need a big value here */ + st->vad_enabled = 0; + st->abr_enabled = 0; + st->relative_quality=0; +#endif /* #ifndef DISABLE_VBR */ + + st->complexity=2; + speex_encoder_ctl(st->st_low, SPEEX_GET_SAMPLING_RATE, &st->sampling_rate); + st->sampling_rate*=2; +#ifdef ENABLE_VALGRIND + VALGRIND_MAKE_READABLE(st, (st->stack-(char*)st)); +#endif + return st; +} + +void sb_encoder_destroy(void *state) +{ + SBEncState *st=(SBEncState*)state; + + speex_encoder_destroy(st->st_low); +#if !(defined(VAR_ARRAYS) || defined (USE_ALLOCA)) + /*speex_free_scratch(st->stack);*/ +#endif + + speex_free(st->high); + + speex_free(st->h0_mem); + speex_free(st->h1_mem); + + speex_free(st->old_lsp); + speex_free(st->old_qlsp); + speex_free(st->interp_qlpc); + speex_free(st->pi_gain); + speex_free(st->exc_rms); + + speex_free(st->mem_sp); + speex_free(st->mem_sp2); + speex_free(st->mem_sw); + + + speex_free(st); +} + + +int sb_encode(void *state, void *vin, SpeexBits *bits) +{ + SBEncState *st; + int i, roots, sub; + char *stack; + VARDECL(spx_mem_t *mem); + VARDECL(spx_sig_t *innov); + VARDECL(spx_word16_t *target); + VARDECL(spx_word16_t *syn_resp); + VARDECL(spx_word32_t *low_pi_gain); + spx_word16_t *low; + spx_word16_t *high; + VARDECL(spx_word16_t *low_exc_rms); + VARDECL(spx_word16_t *low_innov_rms); + const SpeexSBMode *mode; + spx_int32_t dtx; + spx_word16_t *in = (spx_word16_t*)vin; + spx_word16_t e_low=0, e_high=0; + VARDECL(spx_coef_t *lpc); + VARDECL(spx_coef_t *interp_lpc); + VARDECL(spx_coef_t *bw_lpc1); + VARDECL(spx_coef_t *bw_lpc2); + VARDECL(spx_lsp_t *lsp); + VARDECL(spx_lsp_t *qlsp); + VARDECL(spx_lsp_t *interp_lsp); + VARDECL(spx_lsp_t *interp_qlsp); + + st = (SBEncState*)state; + stack=st->stack; + mode = (const SpeexSBMode*)(st->mode->mode); + low = in; + high = in+st->frame_size; + + /* High-band buffering / sync with low band */ + /* Compute the two sub-bands by filtering with QMF h0*/ + qmf_decomp(in, h0, low, high, st->full_frame_size, QMF_ORDER, st->h0_mem, stack); + +#ifndef DISABLE_VBR + if (st->vbr_enabled || st->vad_enabled) + { + /* Need to compute things here before the signal is trashed by the encoder */ + /*FIXME: Are the two signals (low, high) in sync? */ + e_low = compute_rms16(low, st->frame_size); + e_high = compute_rms16(high, st->frame_size); + } +#endif /* #ifndef DISABLE_VBR */ + + ALLOC(low_innov_rms, st->nbSubframes, spx_word16_t); + speex_encoder_ctl(st->st_low, SPEEX_SET_INNOVATION_SAVE, low_innov_rms); + /* Encode the narrowband part*/ + speex_encode_native(st->st_low, low, bits); + + high = high - (st->windowSize-st->frame_size); + SPEEX_COPY(high, st->high, st->windowSize-st->frame_size); + SPEEX_COPY(st->high, &high[st->frame_size], st->windowSize-st->frame_size); + + + ALLOC(low_pi_gain, st->nbSubframes, spx_word32_t); + ALLOC(low_exc_rms, st->nbSubframes, spx_word16_t); + speex_encoder_ctl(st->st_low, SPEEX_GET_PI_GAIN, low_pi_gain); + speex_encoder_ctl(st->st_low, SPEEX_GET_EXC, low_exc_rms); + + speex_encoder_ctl(st->st_low, SPEEX_GET_LOW_MODE, &dtx); + + if (dtx==0) + dtx=1; + else + dtx=0; + + ALLOC(lpc, st->lpcSize, spx_coef_t); + ALLOC(interp_lpc, st->lpcSize, spx_coef_t); + ALLOC(bw_lpc1, st->lpcSize, spx_coef_t); + ALLOC(bw_lpc2, st->lpcSize, spx_coef_t); + + ALLOC(lsp, st->lpcSize, spx_lsp_t); + ALLOC(qlsp, st->lpcSize, spx_lsp_t); + ALLOC(interp_lsp, st->lpcSize, spx_lsp_t); + ALLOC(interp_qlsp, st->lpcSize, spx_lsp_t); + + { + VARDECL(spx_word16_t *autocorr); + VARDECL(spx_word16_t *w_sig); + ALLOC(autocorr, st->lpcSize+1, spx_word16_t); + ALLOC(w_sig, st->windowSize, spx_word16_t); + /* Window for analysis */ + /* FIXME: This is a kludge */ + if (st->subframeSize==80) + { + for (i=0;iwindowSize;i++) + w_sig[i] = EXTRACT16(SHR32(MULT16_16(high[i],st->window[i>>1]),SIG_SHIFT)); + } else { + for (i=0;iwindowSize;i++) + w_sig[i] = EXTRACT16(SHR32(MULT16_16(high[i],st->window[i]),SIG_SHIFT)); + } + /* Compute auto-correlation */ + _spx_autocorr(w_sig, autocorr, st->lpcSize+1, st->windowSize); + autocorr[0] = ADD16(autocorr[0],MULT16_16_Q15(autocorr[0],st->lpc_floor)); /* Noise floor in auto-correlation domain */ + + /* Lag windowing: equivalent to filtering in the power-spectrum domain */ + for (i=0;ilpcSize+1;i++) + autocorr[i] = MULT16_16_Q14(autocorr[i],st->lagWindow[i]); + + /* Levinson-Durbin */ + _spx_lpc(lpc, autocorr, st->lpcSize); + } + + /* LPC to LSPs (x-domain) transform */ + roots=lpc_to_lsp (lpc, st->lpcSize, lsp, 10, LSP_DELTA1, stack); + if (roots!=st->lpcSize) + { + roots = lpc_to_lsp (lpc, st->lpcSize, lsp, 10, LSP_DELTA2, stack); + if (roots!=st->lpcSize) { + /*If we can't find all LSP's, do some damage control and use a flat filter*/ + for (i=0;ilpcSize;i++) + { + lsp[i]=st->old_lsp[i]; + } + } + } + +#ifndef DISABLE_VBR + /* VBR code */ + if ((st->vbr_enabled || st->vad_enabled) && !dtx) + { + float ratio; + if (st->abr_enabled) + { + float qual_change=0; + if (st->abr_drift2 * st->abr_drift > 0) + { + /* Only adapt if long-term and short-term drift are the same sign */ + qual_change = -.00001*st->abr_drift/(1+st->abr_count); + if (qual_change>.1) + qual_change=.1; + if (qual_change<-.1) + qual_change=-.1; + } + st->vbr_quality += qual_change; + if (st->vbr_quality>10) + st->vbr_quality=10; + if (st->vbr_quality<0) + st->vbr_quality=0; + } + + + ratio = 2*log((1.f+e_high)/(1.f+e_low)); + + speex_encoder_ctl(st->st_low, SPEEX_GET_RELATIVE_QUALITY, &st->relative_quality); + if (ratio<-4) + ratio=-4; + if (ratio>2) + ratio=2; + /*if (ratio>-2)*/ + if (st->vbr_enabled) + { + spx_int32_t modeid; + modeid = mode->nb_modes-1; + st->relative_quality+=1.0*(ratio+2); + if (st->relative_quality<-1) + st->relative_quality=-1; + while (modeid) + { + int v1; + float thresh; + v1=(int)floor(st->vbr_quality); + if (v1==10) + thresh = mode->vbr_thresh[modeid][v1]; + else + thresh = (st->vbr_quality-v1) * mode->vbr_thresh[modeid][v1+1] + + (1+v1-st->vbr_quality) * mode->vbr_thresh[modeid][v1]; + if (st->relative_quality >= thresh && st->sampling_rate*st->submodes[modeid]->bits_per_frame/st->full_frame_size <= st->vbr_max_high) + break; + modeid--; + } + speex_encoder_ctl(state, SPEEX_SET_HIGH_MODE, &modeid); + if (st->abr_enabled) + { + spx_int32_t bitrate; + speex_encoder_ctl(state, SPEEX_GET_BITRATE, &bitrate); + st->abr_drift+=(bitrate-st->abr_enabled); + st->abr_drift2 = .95*st->abr_drift2 + .05*(bitrate-st->abr_enabled); + st->abr_count += 1.0; + } + + } else { + /* VAD only */ + int modeid; + if (st->relative_quality<2.0) + modeid=1; + else + modeid=st->submodeSelect; + /*speex_encoder_ctl(state, SPEEX_SET_MODE, &mode);*/ + st->submodeID=modeid; + + } + /*fprintf (stderr, "%f %f\n", ratio, low_qual);*/ + } +#endif /* #ifndef DISABLE_VBR */ + + if (st->encode_submode) + { + speex_bits_pack(bits, 1, 1); + if (dtx) + speex_bits_pack(bits, 0, SB_SUBMODE_BITS); + else + speex_bits_pack(bits, st->submodeID, SB_SUBMODE_BITS); + } + + /* If null mode (no transmission), just set a couple things to zero*/ + if (dtx || st->submodes[st->submodeID] == NULL) + { + for (i=0;iframe_size;i++) + high[i]=VERY_SMALL; + + for (i=0;ilpcSize;i++) + st->mem_sw[i]=0; + st->first=1; + + /* Final signal synthesis from excitation */ + iir_mem16(high, st->interp_qlpc, high, st->frame_size, st->lpcSize, st->mem_sp, stack); + + if (dtx) + return 0; + else + return 1; + } + + + /* LSP quantization */ + SUBMODE(lsp_quant)(lsp, qlsp, st->lpcSize, bits); + + if (st->first) + { + for (i=0;ilpcSize;i++) + st->old_lsp[i] = lsp[i]; + for (i=0;ilpcSize;i++) + st->old_qlsp[i] = qlsp[i]; + } + + ALLOC(mem, st->lpcSize, spx_mem_t); + ALLOC(syn_resp, st->subframeSize, spx_word16_t); + ALLOC(innov, st->subframeSize, spx_sig_t); + ALLOC(target, st->subframeSize, spx_word16_t); + + for (sub=0;subnbSubframes;sub++) + { + VARDECL(spx_word16_t *exc); + VARDECL(spx_word16_t *res); + VARDECL(spx_word16_t *sw); + spx_word16_t *sp; + spx_word16_t filter_ratio; /*Q7*/ + int offset; + spx_word32_t rl, rh; /*Q13*/ + spx_word16_t eh=0; + + offset = st->subframeSize*sub; + sp=high+offset; + ALLOC(exc, st->subframeSize, spx_word16_t); + ALLOC(res, st->subframeSize, spx_word16_t); + ALLOC(sw, st->subframeSize, spx_word16_t); + + /* LSP interpolation (quantized and unquantized) */ + lsp_interpolate(st->old_lsp, lsp, interp_lsp, st->lpcSize, sub, st->nbSubframes); + lsp_interpolate(st->old_qlsp, qlsp, interp_qlsp, st->lpcSize, sub, st->nbSubframes); + + lsp_enforce_margin(interp_lsp, st->lpcSize, LSP_MARGIN); + lsp_enforce_margin(interp_qlsp, st->lpcSize, LSP_MARGIN); + + lsp_to_lpc(interp_lsp, interp_lpc, st->lpcSize,stack); + lsp_to_lpc(interp_qlsp, st->interp_qlpc, st->lpcSize, stack); + + bw_lpc(st->gamma1, interp_lpc, bw_lpc1, st->lpcSize); + bw_lpc(st->gamma2, interp_lpc, bw_lpc2, st->lpcSize); + + /* Compute mid-band (4000 Hz for wideband) response of low-band and high-band + filters */ + st->pi_gain[sub]=LPC_SCALING; + rh = LPC_SCALING; + for (i=0;ilpcSize;i+=2) + { + rh += st->interp_qlpc[i+1] - st->interp_qlpc[i]; + st->pi_gain[sub] += st->interp_qlpc[i] + st->interp_qlpc[i+1]; + } + + rl = low_pi_gain[sub]; +#ifdef FIXED_POINT + filter_ratio=EXTRACT16(SATURATE(PDIV32(SHL32(ADD32(rl,82),7),ADD32(82,rh)),32767)); +#else + filter_ratio=(rl+.01)/(rh+.01); +#endif + + /* Compute "real excitation" */ + fir_mem16(sp, st->interp_qlpc, exc, st->subframeSize, st->lpcSize, st->mem_sp2, stack); + /* Compute energy of low-band and high-band excitation */ + + eh = compute_rms16(exc, st->subframeSize); + + if (!SUBMODE(innovation_quant)) {/* 1 for spectral folding excitation, 0 for stochastic */ + spx_word32_t g; /*Q7*/ + spx_word16_t el; /*Q0*/ + el = low_innov_rms[sub]; + + /* Gain to use if we want to use the low-band excitation for high-band */ + g=PDIV32(MULT16_16(filter_ratio,eh),EXTEND32(ADD16(1,el))); + +#if 0 + { + char *tmp_stack=stack; + float *tmp_sig; + float g2; + ALLOC(tmp_sig, st->subframeSize, spx_sig_t); + for (i=0;ilpcSize;i++) + mem[i]=st->mem_sp[i]; + iir_mem2(st->low_innov+offset, st->interp_qlpc, tmp_sig, st->subframeSize, st->lpcSize, mem); + g2 = compute_rms(sp, st->subframeSize)/(.01+compute_rms(tmp_sig, st->subframeSize)); + /*fprintf (stderr, "gains: %f %f\n", g, g2);*/ + g = g2; + stack = tmp_stack; + } +#endif + + /*print_vec(&g, 1, "gain factor");*/ + /* Gain quantization */ + { + int quant = scal_quant(g, fold_quant_bound, 32); + /*speex_warning_int("tata", quant);*/ + if (quant<0) + quant=0; + if (quant>31) + quant=31; + speex_bits_pack(bits, quant, 5); + } + if (st->innov_rms_save) + { + st->innov_rms_save[sub] = eh; + } + st->exc_rms[sub] = eh; + } else { + spx_word16_t gc; /*Q7*/ + spx_word32_t scale; /*Q14*/ + spx_word16_t el; /*Q0*/ + el = low_exc_rms[sub]; /*Q0*/ + + gc = PDIV32_16(MULT16_16(filter_ratio,1+eh),1+el); + + /* This is a kludge that cleans up a historical bug */ + if (st->subframeSize==80) + gc = MULT16_16_P15(QCONST16(0.70711f,15),gc); + /*printf ("%f %f %f %f\n", el, eh, filter_ratio, gc);*/ + { + int qgc = scal_quant(gc, gc_quant_bound, 16); + speex_bits_pack(bits, qgc, 4); + gc = MULT16_16_Q15(QCONST16(0.87360,15),gc_quant_bound[qgc]); + } + if (st->subframeSize==80) + gc = MULT16_16_P14(QCONST16(1.4142f,14), gc); + + scale = SHL32(MULT16_16(PDIV32_16(SHL32(EXTEND32(gc),SIG_SHIFT-6),filter_ratio),(1+el)),6); + + compute_impulse_response(st->interp_qlpc, bw_lpc1, bw_lpc2, syn_resp, st->subframeSize, st->lpcSize, stack); + + + /* Reset excitation */ + for (i=0;isubframeSize;i++) + res[i]=VERY_SMALL; + + /* Compute zero response (ringing) of A(z/g1) / ( A(z/g2) * Aq(z) ) */ + for (i=0;ilpcSize;i++) + mem[i]=st->mem_sp[i]; + iir_mem16(res, st->interp_qlpc, res, st->subframeSize, st->lpcSize, mem, stack); + + for (i=0;ilpcSize;i++) + mem[i]=st->mem_sw[i]; + filter_mem16(res, bw_lpc1, bw_lpc2, res, st->subframeSize, st->lpcSize, mem, stack); + + /* Compute weighted signal */ + for (i=0;ilpcSize;i++) + mem[i]=st->mem_sw[i]; + filter_mem16(sp, bw_lpc1, bw_lpc2, sw, st->subframeSize, st->lpcSize, mem, stack); + + /* Compute target signal */ + for (i=0;isubframeSize;i++) + target[i]=SUB16(sw[i],res[i]); + + signal_div(target, target, scale, st->subframeSize); + + /* Reset excitation */ + SPEEX_MEMSET(innov, 0, st->subframeSize); + + /*print_vec(target, st->subframeSize, "\ntarget");*/ + SUBMODE(innovation_quant)(target, st->interp_qlpc, bw_lpc1, bw_lpc2, + SUBMODE(innovation_params), st->lpcSize, st->subframeSize, + innov, syn_resp, bits, stack, st->complexity, SUBMODE(double_codebook)); + /*print_vec(target, st->subframeSize, "after");*/ + + signal_mul(innov, innov, scale, st->subframeSize); + + if (SUBMODE(double_codebook)) { + char *tmp_stack=stack; + VARDECL(spx_sig_t *innov2); + ALLOC(innov2, st->subframeSize, spx_sig_t); + SPEEX_MEMSET(innov2, 0, st->subframeSize); + for (i=0;isubframeSize;i++) + target[i]=MULT16_16_P13(QCONST16(2.5f,13), target[i]); + + SUBMODE(innovation_quant)(target, st->interp_qlpc, bw_lpc1, bw_lpc2, + SUBMODE(innovation_params), st->lpcSize, st->subframeSize, + innov2, syn_resp, bits, stack, st->complexity, 0); + signal_mul(innov2, innov2, MULT16_32_P15(QCONST16(0.4f,15),scale), st->subframeSize); + + for (i=0;isubframeSize;i++) + innov[i] = ADD32(innov[i],innov2[i]); + stack = tmp_stack; + } + for (i=0;isubframeSize;i++) + exc[i] = PSHR32(innov[i],SIG_SHIFT); + + if (st->innov_rms_save) + { + st->innov_rms_save[sub] = MULT16_16_Q15(QCONST16(.70711f, 15), compute_rms(innov, st->subframeSize)); + } + st->exc_rms[sub] = compute_rms16(exc, st->subframeSize); + + + } + + + /*Keep the previous memory*/ + for (i=0;ilpcSize;i++) + mem[i]=st->mem_sp[i]; + /* Final signal synthesis from excitation */ + iir_mem16(exc, st->interp_qlpc, sp, st->subframeSize, st->lpcSize, st->mem_sp, stack); + + /* Compute weighted signal again, from synthesized speech (not sure it's the right thing) */ + filter_mem16(sp, bw_lpc1, bw_lpc2, sw, st->subframeSize, st->lpcSize, st->mem_sw, stack); + } + + for (i=0;ilpcSize;i++) + st->old_lsp[i] = lsp[i]; + for (i=0;ilpcSize;i++) + st->old_qlsp[i] = qlsp[i]; + + st->first=0; + + return 1; +} +#endif /* SPEEX_DISABLE_ENCODER */ + + + +static SBDecState global_decstate_wb IBSS_ATTR; +/* Do not include this for voice codec, files will never be UWB */ +#ifndef ROCKBOX_VOICE_CODEC +static SBDecState global_decstate_uwb IBSS_ATTR; +#endif + +void *sb_decoder_init(const SpeexMode *m) +{ + spx_int32_t tmp; + SBDecState *st; + const SpeexSBMode *mode; +/* + st = (SBDecState*)speex_alloc(sizeof(SBDecState)); + if (!st) + return NULL; +*/ +#ifndef ROCKBOX_VOICE_CODEC + if (m->modeID == SPEEX_MODEID_UWB) + st = &global_decstate_uwb; + else +#endif + st = &global_decstate_wb; + memset(st, 0, sizeof(*st)); + st->mode = m; + mode=(const SpeexSBMode*)m->mode; + st->encode_submode = 1; + + st->st_low = speex_decoder_init(mode->nb_mode); +#if defined(VAR_ARRAYS) || defined (USE_ALLOCA) + st->stack = NULL; +#else + /*st->stack = (char*)speex_alloc_scratch(SB_DEC_STACK);*/ + speex_decoder_ctl(st->st_low, SPEEX_GET_STACK, &st->stack); +#endif + + st->full_frame_size = 2*mode->frameSize; + st->frame_size = mode->frameSize; + st->subframeSize = mode->subframeSize; + st->nbSubframes = mode->frameSize/mode->subframeSize; + st->lpcSize=mode->lpcSize; + speex_decoder_ctl(st->st_low, SPEEX_GET_SAMPLING_RATE, &st->sampling_rate); + st->sampling_rate*=2; + tmp=1; + speex_decoder_ctl(st->st_low, SPEEX_SET_WIDEBAND, &tmp); + + st->submodes=mode->submodes; + st->submodeID=mode->defaultSubmode; + + st->first=1; + + /* st->g0_mem = (spx_word32_t*)speex_alloc((QMF_ORDER)*sizeof(spx_word32_t)); */ + /* st->g1_mem = (spx_word32_t*)speex_alloc((QMF_ORDER)*sizeof(spx_word32_t)); */ + + /* st->excBuf = (spx_word16_t*)speex_alloc((st->subframeSize)*sizeof(spx_word16_t)); */ + + /* st->old_qlsp = (spx_lsp_t*)speex_alloc((st->lpcSize)*sizeof(spx_lsp_t)); */ + /* st->interp_qlpc = (spx_coef_t*)speex_alloc(st->lpcSize*sizeof(spx_coef_t)); */ + + /* st->pi_gain = (spx_word32_t*)speex_alloc((st->nbSubframes)*sizeof(spx_word32_t)); */ + /*st->exc_rms = (spx_word16_t*)speex_alloc((st->nbSubframes)*sizeof(spx_word16_t)); */ + /* st->mem_sp = (spx_mem_t*)speex_alloc((2*st->lpcSize)*sizeof(spx_mem_t)); */ + + st->innov_save = NULL; + + + st->lpc_enh_enabled=0; + st->seed = 1000; + +#ifdef ENABLE_VALGRIND + VALGRIND_MAKE_READABLE(st, (st->stack-(char*)st)); +#endif + return st; +} + +void sb_decoder_destroy(void *state) +{ + SBDecState *st; + st = (SBDecState*)state; + speex_decoder_destroy(st->st_low); +#if !(defined(VAR_ARRAYS) || defined (USE_ALLOCA)) + /*speex_free_scratch(st->stack);*/ +#endif +/* + speex_free(st->g0_mem); + speex_free(st->g1_mem); + speex_free(st->excBuf); + speex_free(st->old_qlsp); + speex_free(st->interp_qlpc); + speex_free(st->pi_gain); + speex_free(st->exc_rms); + speex_free(st->mem_sp); + + speex_free(state); +*/ +} + +#ifndef ROCKBOX_VOICE_CODEC +static void sb_decode_lost(SBDecState *st, spx_word16_t *out, int dtx, char *stack) +{ + int i; + int saved_modeid=0; + + if (dtx) + { + saved_modeid=st->submodeID; + st->submodeID=1; + } else { + bw_lpc(QCONST16(0.99f,15), st->interp_qlpc, st->interp_qlpc, st->lpcSize); + } + + st->first=1; + + + /* Final signal synthesis from excitation */ + if (!dtx) + { + st->last_ener = MULT16_16_Q15(QCONST16(.9f,15),st->last_ener); + } + for (i=0;iframe_size;i++) + out[i+st->frame_size] = speex_rand(st->last_ener, &st->seed); + + iir_mem16(out+st->frame_size, st->interp_qlpc, out+st->frame_size, st->frame_size, st->lpcSize, + st->mem_sp, stack); + + + /* Reconstruct the original */ + qmf_synth(out, out+st->frame_size, h0, out, st->full_frame_size, QMF_ORDER, st->g0_mem, st->g1_mem, stack); + if (dtx) + { + st->submodeID=saved_modeid; + } + + return; +} +#endif + +int sb_decode(void *state, SpeexBits *bits, void *vout) +{ + int i, sub; + SBDecState *st; + int wideband; + int ret; + char *stack; + VARDECL(spx_word32_t *low_pi_gain); + VARDECL(spx_word16_t *low_exc_rms); + VARDECL(spx_coef_t *ak); + VARDECL(spx_lsp_t *qlsp); + VARDECL(spx_lsp_t *interp_qlsp); + spx_int32_t dtx; + const SpeexSBMode *mode; + spx_word16_t *out = (spx_word16_t*)vout; + spx_word16_t *low_innov_alias; + spx_word32_t exc_ener_sum = 0; + + st = (SBDecState*)state; + stack=st->stack; + mode = (const SpeexSBMode*)(st->mode->mode); + + low_innov_alias = out+st->frame_size; + speex_decoder_ctl(st->st_low, SPEEX_SET_INNOVATION_SAVE, low_innov_alias); + /* Decode the low-band */ + ret = speex_decode_native(st->st_low, bits, out); + + speex_decoder_ctl(st->st_low, SPEEX_GET_DTX_STATUS, &dtx); + + /* If error decoding the narrowband part, propagate error */ + if (ret!=0) + { + return ret; + } + +#ifndef ROCKBOX_VOICE_CODEC + if (!bits) + { + sb_decode_lost(st, out, dtx, stack); + return 0; + } +#endif + + if (st->encode_submode) + { + + /*Check "wideband bit"*/ + if (speex_bits_remaining(bits)>0) + wideband = speex_bits_peek(bits); + else + wideband = 0; + if (wideband) + { + /*Regular wideband frame, read the submode*/ + wideband = speex_bits_unpack_unsigned(bits, 1); + st->submodeID = speex_bits_unpack_unsigned(bits, SB_SUBMODE_BITS); + } else + { + /*Was a narrowband frame, set "null submode"*/ + st->submodeID = 0; + } + if (st->submodeID != 0 && st->submodes[st->submodeID] == NULL) + { + speex_notify("Invalid mode encountered. The stream is corrupted."); + return -2; + } + } + + /* If null mode (no transmission), just set a couple things to zero*/ + if (st->submodes[st->submodeID] == NULL) + { +#ifndef ROCKBOX_VOICE_CODEC + if (dtx) + { + sb_decode_lost(st, out, 1, stack); + return 0; + } +#endif + + for (i=0;iframe_size;i++) + out[st->frame_size+i]=VERY_SMALL; + + st->first=1; + + /* Final signal synthesis from excitation */ + iir_mem16(out+st->frame_size, st->interp_qlpc, out+st->frame_size, st->frame_size, st->lpcSize, st->mem_sp, stack); + + qmf_synth(out, out+st->frame_size, h0, out, st->full_frame_size, QMF_ORDER, st->g0_mem, st->g1_mem, stack); + + return 0; + + } + + ALLOC(low_pi_gain, st->nbSubframes, spx_word32_t); + ALLOC(low_exc_rms, st->nbSubframes, spx_word16_t); + speex_decoder_ctl(st->st_low, SPEEX_GET_PI_GAIN, low_pi_gain); + speex_decoder_ctl(st->st_low, SPEEX_GET_EXC, low_exc_rms); + + ALLOC(qlsp, st->lpcSize, spx_lsp_t); + ALLOC(interp_qlsp, st->lpcSize, spx_lsp_t); + SUBMODE(lsp_unquant)(qlsp, st->lpcSize, bits); + + if (st->first) + { + for (i=0;ilpcSize;i++) + st->old_qlsp[i] = qlsp[i]; + } + + ALLOC(ak, st->lpcSize, spx_coef_t); + + for (sub=0;subnbSubframes;sub++) + { + VARDECL(spx_word32_t *exc); + spx_word16_t *innov_save=NULL; + spx_word16_t *sp; + spx_word16_t filter_ratio; + spx_word16_t el=0; + int offset; + spx_word32_t rl=0,rh=0; + + offset = st->subframeSize*sub; + sp=out+st->frame_size+offset; + ALLOC(exc, st->subframeSize, spx_word32_t); + /* Pointer for saving innovation */ + if (st->innov_save) + { + innov_save = st->innov_save+2*offset; + SPEEX_MEMSET(innov_save, 0, 2*st->subframeSize); + } + + /* LSP interpolation */ + lsp_interpolate(st->old_qlsp, qlsp, interp_qlsp, st->lpcSize, sub, st->nbSubframes); + + lsp_enforce_margin(interp_qlsp, st->lpcSize, LSP_MARGIN); + + /* LSP to LPC */ + lsp_to_lpc(interp_qlsp, ak, st->lpcSize, stack); + + /* Calculate reponse ratio between the low and high filter in the middle + of the band (4000 Hz) */ + + st->pi_gain[sub]=LPC_SCALING; + rh = LPC_SCALING; + for (i=0;ilpcSize;i+=2) + { + rh += ak[i+1] - ak[i]; + st->pi_gain[sub] += ak[i] + ak[i+1]; + } + + rl = low_pi_gain[sub]; +#ifdef FIXED_POINT + filter_ratio=EXTRACT16(SATURATE(PDIV32(SHL32(ADD32(rl,82),7),ADD32(82,rh)),32767)); +#else + filter_ratio=(rl+.01)/(rh+.01); +#endif + + SPEEX_MEMSET(exc, 0, st->subframeSize); + if (!SUBMODE(innovation_unquant)) + { + spx_word32_t g; + int quant; + + quant = speex_bits_unpack_unsigned(bits, 5); + g= spx_exp(MULT16_16(QCONST16(.125f,11),(quant-10))); + + g = PDIV32(g, filter_ratio); + + for (i=0;isubframeSize;i+=2) + { + exc[i]=SHL32(MULT16_32_P15(MULT16_16_Q15(mode->folding_gain,low_innov_alias[offset+i]),SHL32(g,6)),SIG_SHIFT); + exc[i+1]=NEG32(SHL32(MULT16_32_P15(MULT16_16_Q15(mode->folding_gain,low_innov_alias[offset+i+1]),SHL32(g,6)),SIG_SHIFT)); + } + + } else { + spx_word16_t gc; + spx_word32_t scale; + int qgc = speex_bits_unpack_unsigned(bits, 4); + + el = low_exc_rms[sub]; + gc = MULT16_16_Q15(QCONST16(0.87360,15),gc_quant_bound[qgc]); + + if (st->subframeSize==80) + gc = MULT16_16_P14(QCONST16(1.4142f,14),gc); + + scale = SHL32(PDIV32(SHL32(MULT16_16(gc, el),3), filter_ratio),SIG_SHIFT-3); + SUBMODE(innovation_unquant)(exc, SUBMODE(innovation_params), st->subframeSize, + bits, stack, &st->seed); + + signal_mul(exc,exc,scale,st->subframeSize); + + if (SUBMODE(double_codebook)) { + char *tmp_stack=stack; + VARDECL(spx_sig_t *innov2); + ALLOC(innov2, st->subframeSize, spx_sig_t); + SPEEX_MEMSET(innov2, 0, st->subframeSize); + SUBMODE(innovation_unquant)(innov2, SUBMODE(innovation_params), st->subframeSize, + bits, stack, &st->seed); + signal_mul(innov2, innov2, MULT16_32_P15(QCONST16(0.4f,15),scale), st->subframeSize); + for (i=0;isubframeSize;i++) + exc[i] = ADD32(exc[i],innov2[i]); + stack = tmp_stack; + } + + } + + if (st->innov_save) + { + for (i=0;isubframeSize;i++) + innov_save[2*i]=EXTRACT16(PSHR32(exc[i],SIG_SHIFT)); + } + + iir_mem16(st->excBuf, st->interp_qlpc, sp, st->subframeSize, st->lpcSize, + st->mem_sp, stack); + for (i=0;isubframeSize;i++) + st->excBuf[i]=EXTRACT16(PSHR32(exc[i],SIG_SHIFT)); + for (i=0;ilpcSize;i++) + st->interp_qlpc[i] = ak[i]; + st->exc_rms[sub] = compute_rms16(st->excBuf, st->subframeSize); + exc_ener_sum = ADD32(exc_ener_sum, DIV32(MULT16_16(st->exc_rms[sub],st->exc_rms[sub]), st->nbSubframes)); + } + st->last_ener = spx_sqrt(exc_ener_sum); + + qmf_synth(out, out+st->frame_size, h0, out, st->full_frame_size, QMF_ORDER, st->g0_mem, st->g1_mem, stack); + for (i=0;ilpcSize;i++) + st->old_qlsp[i] = qlsp[i]; + + st->first=0; + + return 0; +} + +#ifndef SPEEX_DISABLE_ENCODER +int sb_encoder_ctl(void *state, int request, void *ptr) +{ + SBEncState *st; + st=(SBEncState*)state; + switch(request) + { + case SPEEX_GET_FRAME_SIZE: + (*(spx_int32_t*)ptr) = st->full_frame_size; + break; + case SPEEX_SET_HIGH_MODE: + st->submodeSelect = st->submodeID = (*(spx_int32_t*)ptr); + break; + case SPEEX_SET_LOW_MODE: + speex_encoder_ctl(st->st_low, SPEEX_SET_LOW_MODE, ptr); + break; + case SPEEX_SET_DTX: + speex_encoder_ctl(st->st_low, SPEEX_SET_DTX, ptr); + break; + case SPEEX_GET_DTX: + speex_encoder_ctl(st->st_low, SPEEX_GET_DTX, ptr); + break; + case SPEEX_GET_LOW_MODE: + speex_encoder_ctl(st->st_low, SPEEX_GET_LOW_MODE, ptr); + break; + case SPEEX_SET_MODE: + speex_encoder_ctl(st, SPEEX_SET_QUALITY, ptr); + break; +#ifndef DISABLE_VBR + case SPEEX_SET_VBR: + st->vbr_enabled = (*(spx_int32_t*)ptr); + speex_encoder_ctl(st->st_low, SPEEX_SET_VBR, ptr); + break; + case SPEEX_GET_VBR: + (*(spx_int32_t*)ptr) = st->vbr_enabled; + break; + case SPEEX_SET_VAD: + st->vad_enabled = (*(spx_int32_t*)ptr); + speex_encoder_ctl(st->st_low, SPEEX_SET_VAD, ptr); + break; + case SPEEX_GET_VAD: + (*(spx_int32_t*)ptr) = st->vad_enabled; + break; +#endif /* #ifndef DISABLE_VBR */ +#if !defined(DISABLE_VBR) && !defined(DISABLE_FLOAT_API) + case SPEEX_SET_VBR_QUALITY: + { + spx_int32_t q; + float qual = (*(float*)ptr)+.6; + st->vbr_quality = (*(float*)ptr); + if (qual>10) + qual=10; + q=(int)floor(.5+*(float*)ptr); + if (q>10) + q=10; + speex_encoder_ctl(st->st_low, SPEEX_SET_VBR_QUALITY, &qual); + speex_encoder_ctl(state, SPEEX_SET_QUALITY, &q); + break; + } + case SPEEX_GET_VBR_QUALITY: + (*(float*)ptr) = st->vbr_quality; + break; +#endif /* #if !defined(DISABLE_VBR) && !defined(DISABLE_FLOAT_API) */ +#ifndef DISABLE_VBR + case SPEEX_SET_ABR: + st->abr_enabled = (*(spx_int32_t*)ptr); + st->vbr_enabled = st->abr_enabled!=0; + speex_encoder_ctl(st->st_low, SPEEX_SET_VBR, &st->vbr_enabled); + if (st->vbr_enabled) + { + spx_int32_t i=10, rate, target; + float vbr_qual; + target = (*(spx_int32_t*)ptr); + while (i>=0) + { + speex_encoder_ctl(st, SPEEX_SET_QUALITY, &i); + speex_encoder_ctl(st, SPEEX_GET_BITRATE, &rate); + if (rate <= target) + break; + i--; + } + vbr_qual=i; + if (vbr_qual<0) + vbr_qual=0; + speex_encoder_ctl(st, SPEEX_SET_VBR_QUALITY, &vbr_qual); + st->abr_count=0; + st->abr_drift=0; + st->abr_drift2=0; + } + + break; + case SPEEX_GET_ABR: + (*(spx_int32_t*)ptr) = st->abr_enabled; + break; +#endif /* #ifndef DISABLE_VBR */ + + case SPEEX_SET_QUALITY: + { + spx_int32_t nb_qual; + int quality = (*(spx_int32_t*)ptr); + if (quality < 0) + quality = 0; + if (quality > 10) + quality = 10; + st->submodeSelect = st->submodeID = ((const SpeexSBMode*)(st->mode->mode))->quality_map[quality]; + nb_qual = ((const SpeexSBMode*)(st->mode->mode))->low_quality_map[quality]; + speex_encoder_ctl(st->st_low, SPEEX_SET_MODE, &nb_qual); + } + break; + case SPEEX_SET_COMPLEXITY: + speex_encoder_ctl(st->st_low, SPEEX_SET_COMPLEXITY, ptr); + st->complexity = (*(spx_int32_t*)ptr); + if (st->complexity<1) + st->complexity=1; + break; + case SPEEX_GET_COMPLEXITY: + (*(spx_int32_t*)ptr) = st->complexity; + break; + case SPEEX_SET_BITRATE: + { + spx_int32_t i=10; + spx_int32_t rate, target; + target = (*(spx_int32_t*)ptr); + while (i>=0) + { + speex_encoder_ctl(st, SPEEX_SET_QUALITY, &i); + speex_encoder_ctl(st, SPEEX_GET_BITRATE, &rate); + if (rate <= target) + break; + i--; + } + } + break; + case SPEEX_GET_BITRATE: + speex_encoder_ctl(st->st_low, request, ptr); + /*fprintf (stderr, "before: %d\n", (*(int*)ptr));*/ + if (st->submodes[st->submodeID]) + (*(spx_int32_t*)ptr) += st->sampling_rate*SUBMODE(bits_per_frame)/st->full_frame_size; + else + (*(spx_int32_t*)ptr) += st->sampling_rate*(SB_SUBMODE_BITS+1)/st->full_frame_size; + /*fprintf (stderr, "after: %d\n", (*(int*)ptr));*/ + break; + case SPEEX_SET_SAMPLING_RATE: + { + spx_int32_t tmp=(*(spx_int32_t*)ptr); + st->sampling_rate = tmp; + tmp>>=1; + speex_encoder_ctl(st->st_low, SPEEX_SET_SAMPLING_RATE, &tmp); + } + break; + case SPEEX_GET_SAMPLING_RATE: + (*(spx_int32_t*)ptr)=st->sampling_rate; + break; + case SPEEX_RESET_STATE: + { + int i; + st->first = 1; + for (i=0;ilpcSize;i++) + st->old_lsp[i]= DIV32(MULT16_16(QCONST16(3.1415927f, LSP_SHIFT), i+1), st->lpcSize+1); + for (i=0;ilpcSize;i++) + st->mem_sw[i]=st->mem_sp[i]=st->mem_sp2[i]=0; + for (i=0;ih0_mem[i]=st->h1_mem[i]=0; + } + break; + case SPEEX_SET_SUBMODE_ENCODING: + st->encode_submode = (*(spx_int32_t*)ptr); + speex_encoder_ctl(st->st_low, SPEEX_SET_SUBMODE_ENCODING, ptr); + break; + case SPEEX_GET_SUBMODE_ENCODING: + (*(spx_int32_t*)ptr) = st->encode_submode; + break; + case SPEEX_GET_LOOKAHEAD: + speex_encoder_ctl(st->st_low, SPEEX_GET_LOOKAHEAD, ptr); + (*(spx_int32_t*)ptr) = 2*(*(spx_int32_t*)ptr) + QMF_ORDER - 1; + break; + case SPEEX_SET_PLC_TUNING: + speex_encoder_ctl(st->st_low, SPEEX_SET_PLC_TUNING, ptr); + break; + case SPEEX_GET_PLC_TUNING: + speex_encoder_ctl(st->st_low, SPEEX_GET_PLC_TUNING, ptr); + break; +#ifndef DISABLE_VBR + case SPEEX_SET_VBR_MAX_BITRATE: + { + st->vbr_max = (*(spx_int32_t*)ptr); + if (SPEEX_SET_VBR_MAX_BITRATE<1) + { + speex_encoder_ctl(st->st_low, SPEEX_SET_VBR_MAX_BITRATE, &st->vbr_max); + st->vbr_max_high = 17600; + } else { + spx_int32_t low_rate; + if (st->vbr_max >= 42200) + { + st->vbr_max_high = 17600; + } else if (st->vbr_max >= 27800) + { + st->vbr_max_high = 9600; + } else if (st->vbr_max > 20600) + { + st->vbr_max_high = 5600; + } else { + st->vbr_max_high = 1800; + } + if (st->subframeSize==80) + st->vbr_max_high = 1800; + low_rate = st->vbr_max - st->vbr_max_high; + speex_encoder_ctl(st->st_low, SPEEX_SET_VBR_MAX_BITRATE, &low_rate); + } + } + break; + case SPEEX_GET_VBR_MAX_BITRATE: + (*(spx_int32_t*)ptr) = st->vbr_max; + break; +#endif /* #ifndef DISABLE_VBR */ + case SPEEX_SET_HIGHPASS: + speex_encoder_ctl(st->st_low, SPEEX_SET_HIGHPASS, ptr); + break; + case SPEEX_GET_HIGHPASS: + speex_encoder_ctl(st->st_low, SPEEX_GET_HIGHPASS, ptr); + break; + + + /* This is all internal stuff past this point */ + case SPEEX_GET_PI_GAIN: + { + int i; + spx_word32_t *g = (spx_word32_t*)ptr; + for (i=0;inbSubframes;i++) + g[i]=st->pi_gain[i]; + } + break; + case SPEEX_GET_EXC: + { + int i; + for (i=0;inbSubframes;i++) + ((spx_word16_t*)ptr)[i] = st->exc_rms[i]; + } + break; +#ifndef DISABLE_VBR + case SPEEX_GET_RELATIVE_QUALITY: + (*(float*)ptr)=st->relative_quality; + break; +#endif /* #ifndef DISABLE_VBR */ + case SPEEX_SET_INNOVATION_SAVE: + st->innov_rms_save = (spx_word16_t*)ptr; + break; + case SPEEX_SET_WIDEBAND: + speex_encoder_ctl(st->st_low, SPEEX_SET_WIDEBAND, ptr); + break; + case SPEEX_GET_STACK: + *((char**)ptr) = st->stack; + break; + default: + speex_warning_int("Unknown nb_ctl request: ", request); + return -1; + } + return 0; +} +#endif /* SPEEX_DISABLE_ENCODER */ + +int sb_decoder_ctl(void *state, int request, void *ptr) +{ + SBDecState *st; + st=(SBDecState*)state; + switch(request) + { + case SPEEX_SET_HIGH_MODE: + st->submodeID = (*(spx_int32_t*)ptr); + break; + case SPEEX_SET_LOW_MODE: + speex_decoder_ctl(st->st_low, SPEEX_SET_LOW_MODE, ptr); + break; + case SPEEX_GET_LOW_MODE: + speex_decoder_ctl(st->st_low, SPEEX_GET_LOW_MODE, ptr); + break; + case SPEEX_GET_FRAME_SIZE: + (*(spx_int32_t*)ptr) = st->full_frame_size; + break; + case SPEEX_SET_ENH: + speex_decoder_ctl(st->st_low, request, ptr); + st->lpc_enh_enabled = *((spx_int32_t*)ptr); + break; + case SPEEX_GET_ENH: + *((spx_int32_t*)ptr) = st->lpc_enh_enabled; + break; + case SPEEX_SET_MODE: + case SPEEX_SET_QUALITY: + { + spx_int32_t nb_qual; + int quality = (*(spx_int32_t*)ptr); + if (quality < 0) + quality = 0; + if (quality > 10) + quality = 10; + st->submodeID = ((const SpeexSBMode*)(st->mode->mode))->quality_map[quality]; + nb_qual = ((const SpeexSBMode*)(st->mode->mode))->low_quality_map[quality]; + speex_decoder_ctl(st->st_low, SPEEX_SET_MODE, &nb_qual); + } + break; + case SPEEX_GET_BITRATE: + speex_decoder_ctl(st->st_low, request, ptr); + if (st->submodes[st->submodeID]) + (*(spx_int32_t*)ptr) += st->sampling_rate*SUBMODE(bits_per_frame)/st->full_frame_size; + else + (*(spx_int32_t*)ptr) += st->sampling_rate*(SB_SUBMODE_BITS+1)/st->full_frame_size; + break; + case SPEEX_SET_SAMPLING_RATE: + { + spx_int32_t tmp=(*(spx_int32_t*)ptr); + st->sampling_rate = tmp; + tmp>>=1; + speex_decoder_ctl(st->st_low, SPEEX_SET_SAMPLING_RATE, &tmp); + } + break; + case SPEEX_GET_SAMPLING_RATE: + (*(spx_int32_t*)ptr)=st->sampling_rate; + break; + case SPEEX_SET_HANDLER: + speex_decoder_ctl(st->st_low, SPEEX_SET_HANDLER, ptr); + break; + case SPEEX_SET_USER_HANDLER: + speex_decoder_ctl(st->st_low, SPEEX_SET_USER_HANDLER, ptr); + break; + case SPEEX_RESET_STATE: + { + int i; + for (i=0;i<2*st->lpcSize;i++) + st->mem_sp[i]=0; + for (i=0;ig0_mem[i]=st->g1_mem[i]=0; + st->last_ener=0; + } + break; + case SPEEX_SET_SUBMODE_ENCODING: + st->encode_submode = (*(spx_int32_t*)ptr); + speex_decoder_ctl(st->st_low, SPEEX_SET_SUBMODE_ENCODING, ptr); + break; + case SPEEX_GET_SUBMODE_ENCODING: + (*(spx_int32_t*)ptr) = st->encode_submode; + break; + case SPEEX_GET_LOOKAHEAD: + speex_decoder_ctl(st->st_low, SPEEX_GET_LOOKAHEAD, ptr); + (*(spx_int32_t*)ptr) = 2*(*(spx_int32_t*)ptr); + break; + case SPEEX_SET_HIGHPASS: + speex_decoder_ctl(st->st_low, SPEEX_SET_HIGHPASS, ptr); + break; + case SPEEX_GET_HIGHPASS: + speex_decoder_ctl(st->st_low, SPEEX_GET_HIGHPASS, ptr); + break; + case SPEEX_GET_ACTIVITY: + speex_decoder_ctl(st->st_low, SPEEX_GET_ACTIVITY, ptr); + break; + case SPEEX_GET_PI_GAIN: + { + int i; + spx_word32_t *g = (spx_word32_t*)ptr; + for (i=0;inbSubframes;i++) + g[i]=st->pi_gain[i]; + } + break; + case SPEEX_GET_EXC: + { + int i; + for (i=0;inbSubframes;i++) + ((spx_word16_t*)ptr)[i] = st->exc_rms[i]; + } + break; + case SPEEX_GET_DTX_STATUS: + speex_decoder_ctl(st->st_low, SPEEX_GET_DTX_STATUS, ptr); + break; + case SPEEX_SET_INNOVATION_SAVE: + st->innov_save = (spx_word16_t*)ptr; + break; + case SPEEX_SET_WIDEBAND: + speex_decoder_ctl(st->st_low, SPEEX_SET_WIDEBAND, ptr); + break; + case SPEEX_GET_STACK: + *((char**)ptr) = st->stack; + break; + default: + speex_warning_int("Unknown nb_ctl request: ", request); + return -1; + } + return 0; +} + +#endif + diff --git a/lib/rbcodec/codecs/libspeex/sb_celp.h b/lib/rbcodec/codecs/libspeex/sb_celp.h new file mode 100644 index 0000000000..5a65d1ff8d --- /dev/null +++ b/lib/rbcodec/codecs/libspeex/sb_celp.h @@ -0,0 +1,160 @@ +/* Copyright (C) 2002-2006 Jean-Marc Valin */ +/** + @file sb_celp.h + @brief Sub-band CELP mode used for wideband encoding +*/ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + - Neither the name of the Xiph.org Foundation nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + +#ifndef SB_CELP_H +#define SB_CELP_H + +#include "modes.h" +#include "speex/speex_bits.h" +#include "nb_celp.h" + +/**Structure representing the full state of the sub-band encoder*/ +typedef struct SBEncState { + const SpeexMode *mode; /**< Pointer to the mode (containing for vtable info) */ + void *st_low; /**< State of the low-band (narrowband) encoder */ + int full_frame_size; /**< Length of full-band frames*/ + int frame_size; /**< Length of high-band frames*/ + int subframeSize; /**< Length of high-band sub-frames*/ + int nbSubframes; /**< Number of high-band sub-frames*/ + int windowSize; /**< Length of high-band LPC window*/ + int lpcSize; /**< Order of high-band LPC analysis */ + int first; /**< First frame? */ + spx_word16_t lpc_floor; /**< Controls LPC analysis noise floor */ + spx_word16_t gamma1; /**< Perceptual weighting coef 1 */ + spx_word16_t gamma2; /**< Perceptual weighting coef 2 */ + + char *stack; /**< Temporary allocation stack */ + spx_word16_t *high; /**< High-band signal (buffer) */ + spx_word16_t *h0_mem, *h1_mem; + + const spx_word16_t *window; /**< LPC analysis window */ + const spx_word16_t *lagWindow; /**< Auto-correlation window */ + spx_lsp_t *old_lsp; /**< LSPs of previous frame */ + spx_lsp_t *old_qlsp; /**< Quantized LSPs of previous frame */ + spx_coef_t *interp_qlpc; /**< Interpolated quantized LPCs for current sub-frame */ + + spx_mem_t *mem_sp; /**< Synthesis signal memory */ + spx_mem_t *mem_sp2; + spx_mem_t *mem_sw; /**< Perceptual signal memory */ + spx_word32_t *pi_gain; + spx_word16_t *exc_rms; + spx_word16_t *innov_rms_save; /**< If non-NULL, innovation is copied here */ + +#ifndef DISABLE_VBR + float vbr_quality; /**< Quality setting for VBR encoding */ + int vbr_enabled; /**< 1 for enabling VBR, 0 otherwise */ + spx_int32_t vbr_max; /**< Max bit-rate allowed in VBR mode (total) */ + spx_int32_t vbr_max_high; /**< Max bit-rate allowed in VBR mode for the high-band */ + spx_int32_t abr_enabled; /**< ABR setting (in bps), 0 if off */ + float abr_drift; + float abr_drift2; + float abr_count; + int vad_enabled; /**< 1 for enabling VAD, 0 otherwise */ + float relative_quality; +#endif /* #ifndef DISABLE_VBR */ + + int encode_submode; + const SpeexSubmode * const *submodes; + int submodeID; + int submodeSelect; + int complexity; + spx_int32_t sampling_rate; + +} SBEncState; + + +/**Structure representing the full state of the sub-band decoder*/ +typedef struct SBDecState { + const SpeexMode *mode; /**< Pointer to the mode (containing for vtable info) */ + void *st_low; /**< State of the low-band (narrowband) encoder */ + int full_frame_size; + int frame_size; + int subframeSize; + int nbSubframes; + int lpcSize; + int first; + spx_int32_t sampling_rate; + int lpc_enh_enabled; + + char *stack; + spx_word16_t g0_mem[64], g1_mem[64]; + +/* Voice codec files will be WB mode, which has sub frame size of 40 */ +#ifndef ROCKBOX_VOICE_CODEC + spx_word16_t excBuf[80]; +#else + spx_word16_t excBuf[40]; +#endif + spx_lsp_t old_qlsp[8]; + spx_coef_t interp_qlpc[8]; + + spx_mem_t mem_sp[16]; + spx_word32_t pi_gain[4]; + spx_word16_t exc_rms[4]; + spx_word16_t *innov_save; /** If non-NULL, innovation is copied here */ + + spx_word16_t last_ener; + spx_int32_t seed; + + int encode_submode; + const SpeexSubmode * const *submodes; + int submodeID; +} SBDecState; + + +/**Initializes encoder state*/ +void *sb_encoder_init(const SpeexMode *m); + +/**De-allocates encoder state resources*/ +void sb_encoder_destroy(void *state); + +/**Encodes one frame*/ +int sb_encode(void *state, void *in, SpeexBits *bits); + + +/**Initializes decoder state*/ +void *sb_decoder_init(const SpeexMode *m); + +/**De-allocates decoder state resources*/ +void sb_decoder_destroy(void *state); + +/**Decodes one frame*/ +int sb_decode(void *state, SpeexBits *bits, void *out); + +int sb_encoder_ctl(void *state, int request, void *ptr); + +int sb_decoder_ctl(void *state, int request, void *ptr); + +#endif diff --git a/lib/rbcodec/codecs/libspeex/smallft.c b/lib/rbcodec/codecs/libspeex/smallft.c new file mode 100644 index 0000000000..6e3a927b5f --- /dev/null +++ b/lib/rbcodec/codecs/libspeex/smallft.c @@ -0,0 +1,1261 @@ +/******************************************************************** + * * + * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * + * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * + * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * + * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * + * * + * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2001 * + * by the XIPHOPHORUS Company http://www.xiph.org/ * + * * + ******************************************************************** + + function: *unnormalized* fft transform + last mod: $Id$ + + ********************************************************************/ + +/* FFT implementation from OggSquish, minus cosine transforms, + * minus all but radix 2/4 case. In Vorbis we only need this + * cut-down version. + * + * To do more than just power-of-two sized vectors, see the full + * version I wrote for NetLib. + * + * Note that the packing is a little strange; rather than the FFT r/i + * packing following R_0, I_n, R_1, I_1, R_2, I_2 ... R_n-1, I_n-1, + * it follows R_0, R_1, I_1, R_2, I_2 ... R_n-1, I_n-1, I_n like the + * FORTRAN version + */ + +#ifdef HAVE_CONFIG_H +#include "config-speex.h" +#endif + +#include +#include "smallft.h" +#include "arch.h" +#include "os_support.h" + +static void drfti1(int n, float *wa, int *ifac){ + static int ntryh[4] = { 4,2,3,5 }; + static float tpi = 6.28318530717958648f; + float arg,argh,argld,fi; + int ntry=0,i,j=-1; + int k1, l1, l2, ib; + int ld, ii, ip, is, nq, nr; + int ido, ipm, nfm1; + int nl=n; + int nf=0; + + L101: + j++; + if (j < 4) + ntry=ntryh[j]; + else + ntry+=2; + + L104: + nq=nl/ntry; + nr=nl-ntry*nq; + if (nr!=0) goto L101; + + nf++; + ifac[nf+1]=ntry; + nl=nq; + if(ntry!=2)goto L107; + if(nf==1)goto L107; + + for (i=1;i>1; + ipp2=ip; + idp2=ido; + nbd=(ido-1)>>1; + t0=l1*ido; + t10=ip*ido; + + if(ido==1)goto L119; + for(ik=0;ikl1){ + for(j=1;j>1; + ipp2=ip; + ipph=(ip+1)>>1; + if(idol1)goto L139; + + is= -ido-1; + t1=0; + for(j=1;jn==1)return; + drftf1(l->n,data,l->trigcache,l->trigcache+l->n,l->splitcache); +} + +void spx_drft_backward(struct drft_lookup *l,float *data){ + if (l->n==1)return; + drftb1(l->n,data,l->trigcache,l->trigcache+l->n,l->splitcache); +} + +void spx_drft_init(struct drft_lookup *l,int n) +{ + l->n=n; + l->trigcache=(float*)speex_alloc(3*n*sizeof(*l->trigcache)); + l->splitcache=(int*)speex_alloc(32*sizeof(*l->splitcache)); + fdrffti(n, l->trigcache, l->splitcache); +} + +void spx_drft_clear(struct drft_lookup *l) +{ + if(l) + { + if(l->trigcache) + speex_free(l->trigcache); + if(l->splitcache) + speex_free(l->splitcache); + } +} diff --git a/lib/rbcodec/codecs/libspeex/smallft.h b/lib/rbcodec/codecs/libspeex/smallft.h new file mode 100644 index 0000000000..4ef9e58c7d --- /dev/null +++ b/lib/rbcodec/codecs/libspeex/smallft.h @@ -0,0 +1,46 @@ +/******************************************************************** + * * + * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * + * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * + * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * + * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * + * * + * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2001 * + * by the XIPHOPHORUS Company http://www.xiph.org/ * + * * + ******************************************************************** + + function: fft transform + last mod: $Id$ + + ********************************************************************/ +/** + @file smallft.h + @brief Discrete Rotational Fourier Transform (DRFT) +*/ + +#ifndef _V_SMFT_H_ +#define _V_SMFT_H_ + + +#ifdef __cplusplus +extern "C" { +#endif + +/** Discrete Rotational Fourier Transform lookup */ +struct drft_lookup{ + int n; + float *trigcache; + int *splitcache; +}; + +extern void spx_drft_forward(struct drft_lookup *l,float *data); +extern void spx_drft_backward(struct drft_lookup *l,float *data); +extern void spx_drft_init(struct drft_lookup *l,int n); +extern void spx_drft_clear(struct drft_lookup *l); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/lib/rbcodec/codecs/libspeex/speex.c b/lib/rbcodec/codecs/libspeex/speex.c new file mode 100644 index 0000000000..0dcfb3f7f6 --- /dev/null +++ b/lib/rbcodec/codecs/libspeex/speex.c @@ -0,0 +1,252 @@ +/* Copyright (C) 2002 Jean-Marc Valin + File: speex.c + + Basic Speex functions + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + - Neither the name of the Xiph.org Foundation nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + +#ifdef HAVE_CONFIG_H +#include "config-speex.h" +#endif + +#include "modes.h" +#include +#include "os_support.h" + +#ifndef NULL +#define NULL 0 +#endif + +#define MAX_IN_SAMPLES 640 + +#ifndef SPEEX_DISABLE_ENCODER +void *speex_encoder_init(const SpeexMode *mode) +{ + return mode->enc_init(mode); +} +#endif + +void *speex_decoder_init(const SpeexMode *mode) +{ + return mode->dec_init(mode); +} + +#ifndef SPEEX_DISABLE_ENCODER +void speex_encoder_destroy(void *state) +{ + (*((SpeexMode**)state))->enc_destroy(state); +} +#endif + +void speex_decoder_destroy(void *state) +{ + (*((SpeexMode**)state))->dec_destroy(state); +} + +#ifndef SPEEX_DISABLE_ENCODER +int speex_encode_native(void *state, spx_word16_t *in, SpeexBits *bits) +{ + return (*((SpeexMode**)state))->enc(state, in, bits); +} +#endif + +int speex_decode_native(void *state, SpeexBits *bits, spx_word16_t *out) +{ + return (*((SpeexMode**)state))->dec(state, bits, out); +} + + + +#ifdef FIXED_POINT + +#ifndef SPEEX_DISABLE_ENCODER +#ifndef DISABLE_FLOAT_API +int speex_encode(void *state, float *in, SpeexBits *bits) +{ + int i; + spx_int32_t N; + spx_int16_t short_in[MAX_IN_SAMPLES]; + speex_encoder_ctl(state, SPEEX_GET_FRAME_SIZE, &N); + for (i=0;i32767.f) + short_in[i] = 32767; + else if (in[i]<-32768.f) + short_in[i] = -32768; + else + short_in[i] = (spx_int16_t)floor(.5+in[i]); + } + return (*((SpeexMode**)state))->enc(state, short_in, bits); +} +#endif /* #ifndef DISABLE_FLOAT_API */ + +int speex_encode_int(void *state, spx_int16_t *in, SpeexBits *bits) +{ + SpeexMode *mode; + mode = *(SpeexMode**)state; + return (mode)->enc(state, in, bits); +} +#endif /* SPEEX_DISABLE_ENCODER */ + +#ifndef DISABLE_FLOAT_API +int speex_decode(void *state, SpeexBits *bits, float *out) +{ + int i, ret; + spx_int32_t N; + spx_int16_t short_out[MAX_IN_SAMPLES]; + speex_decoder_ctl(state, SPEEX_GET_FRAME_SIZE, &N); + ret = (*((SpeexMode**)state))->dec(state, bits, short_out); + for (i=0;idec(state, bits, out); +} + +#else + +int speex_encode(void *state, float *in, SpeexBits *bits) +{ + return (*((SpeexMode**)state))->enc(state, in, bits); +} + +int speex_encode_int(void *state, spx_int16_t *in, SpeexBits *bits) +{ + int i; + spx_int32_t N; + float float_in[MAX_IN_SAMPLES]; + speex_encoder_ctl(state, SPEEX_GET_FRAME_SIZE, &N); + for (i=0;ienc(state, float_in, bits); +} + +int speex_decode(void *state, SpeexBits *bits, float *out) +{ + return (*((SpeexMode**)state))->dec(state, bits, out); +} + +int speex_decode_int(void *state, SpeexBits *bits, spx_int16_t *out) +{ + int i; + spx_int32_t N; + float float_out[MAX_IN_SAMPLES]; + int ret; + speex_decoder_ctl(state, SPEEX_GET_FRAME_SIZE, &N); + ret = (*((SpeexMode**)state))->dec(state, bits, float_out); + for (i=0;i32767.f) + out[i] = 32767; + else if (float_out[i]<-32768.f) + out[i] = -32768; + else + out[i] = (spx_int16_t)floor(.5+float_out[i]); + } + return ret; +} +#endif + +#ifndef SPEEX_DISABLE_ENCODER +int speex_encoder_ctl(void *state, int request, void *ptr) +{ + return (*((SpeexMode**)state))->enc_ctl(state, request, ptr); +} +#endif + +int speex_decoder_ctl(void *state, int request, void *ptr) +{ + return (*((SpeexMode**)state))->dec_ctl(state, request, ptr); +} + +int nb_mode_query(const void *mode, int request, void *ptr) +{ + const SpeexNBMode *m = (const SpeexNBMode*)mode; + + switch (request) + { + case SPEEX_MODE_FRAME_SIZE: + *((int*)ptr)=m->frameSize; + break; + case SPEEX_SUBMODE_BITS_PER_FRAME: + if (*((int*)ptr)==0) + *((int*)ptr) = NB_SUBMODE_BITS+1; + else if (m->submodes[*((int*)ptr)]==NULL) + *((int*)ptr) = -1; + else + *((int*)ptr) = m->submodes[*((int*)ptr)]->bits_per_frame; + break; + default: + speex_warning_int("Unknown nb_mode_query request: ", request); + return -1; + } + return 0; +} + + + +int speex_lib_ctl(int request, void *ptr) +{ + switch (request) + { + case SPEEX_LIB_GET_MAJOR_VERSION: + *((int*)ptr) = SPEEX_MAJOR_VERSION; + break; + case SPEEX_LIB_GET_MINOR_VERSION: + *((int*)ptr) = SPEEX_MINOR_VERSION; + break; + case SPEEX_LIB_GET_MICRO_VERSION: + *((int*)ptr) = SPEEX_MICRO_VERSION; + break; + case SPEEX_LIB_GET_EXTRA_VERSION: + *((const char**)ptr) = SPEEX_EXTRA_VERSION; + break; + case SPEEX_LIB_GET_VERSION_STRING: + *((const char**)ptr) = SPEEX_VERSION; + break; + /*case SPEEX_LIB_SET_ALLOC_FUNC: + break; + case SPEEX_LIB_GET_ALLOC_FUNC: + break; + case SPEEX_LIB_SET_FREE_FUNC: + break; + case SPEEX_LIB_GET_FREE_FUNC: + break;*/ + default: + speex_warning_int("Unknown wb_mode_query request: ", request); + return -1; + } + return 0; +} diff --git a/lib/rbcodec/codecs/libspeex/speex/ogg.h b/lib/rbcodec/codecs/libspeex/speex/ogg.h new file mode 100644 index 0000000000..8898b99582 --- /dev/null +++ b/lib/rbcodec/codecs/libspeex/speex/ogg.h @@ -0,0 +1,216 @@ +/******************************************************************** + * * + * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * + * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * + * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * + * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * + * * + * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2002 * + * by the Xiph.Org Foundation http://www.xiph.org/ * + * * + ******************************************************************** + + function: toplevel libogg include + last mod: $Id$ + + ********************************************************************/ +#ifndef _OGG_H +#define _OGG_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "codeclib.h" + +typedef short spx_ogg_int16_t; +typedef unsigned short spx_ogg_uint16_t; +typedef int spx_ogg_int32_t; +typedef unsigned int spx_ogg_uint32_t; +typedef long long spx_ogg_int64_t; + + +#define _spx_ogg_malloc codec_malloc +#define _spx_ogg_calloc codec_calloc +#define _spx_ogg_realloc codec_realloc +#define _spx_ogg_free codec_free + + +typedef struct { + long endbyte; + int endbit; + + unsigned char *buffer; + unsigned char *ptr; + long storage; +} oggpack_buffer; + +/* spx_ogg_page is used to encapsulate the data in one Ogg bitstream page *****/ + +typedef struct { + unsigned char *header; + long header_len; + unsigned char *body; + long body_len; +} spx_ogg_page; + +/* spx_ogg_stream_state contains the current encode/decode state of a logical + Ogg bitstream **********************************************************/ + +typedef struct { + unsigned char *body_data; /* bytes from packet bodies */ + long body_storage; /* storage elements allocated */ + long body_fill; /* elements stored; fill mark */ + long body_returned; /* elements of fill returned */ + + + int *lacing_vals; /* The values that will go to the segment table */ + spx_ogg_int64_t *granule_vals; /* granulepos values for headers. Not compact + this way, but it is simple coupled to the + lacing fifo */ + long lacing_storage; + long lacing_fill; + long lacing_packet; + long lacing_returned; + + unsigned char header[282]; /* working space for header encode */ + int header_fill; + + int e_o_s; /* set when we have buffered the last packet in the + logical bitstream */ + int b_o_s; /* set after we've written the initial page + of a logical bitstream */ + long serialno; + long pageno; + spx_ogg_int64_t packetno; /* sequence number for decode; the framing + knows where there's a hole in the data, + but we need coupling so that the codec + (which is in a seperate abstraction + layer) also knows about the gap */ + spx_ogg_int64_t granulepos; + +} spx_ogg_stream_state; + +/* spx_ogg_packet is used to encapsulate the data and metadata belonging + to a single raw Ogg/Vorbis packet *************************************/ + +typedef struct { + unsigned char *packet; + long bytes; + long b_o_s; + long e_o_s; + + spx_ogg_int64_t granulepos; + + spx_ogg_int64_t packetno; /* sequence number for decode; the framing + knows where there's a hole in the data, + but we need coupling so that the codec + (which is in a seperate abstraction + layer) also knows about the gap */ +} spx_ogg_packet; + +typedef struct { + unsigned char *data; + int storage; + int fill; + int returned; + + int unsynced; + int headerbytes; + int bodybytes; +} spx_ogg_sync_state; + +/* Ogg BITSTREAM PRIMITIVES: bitstream ************************/ + +extern void oggpack_writeinit(oggpack_buffer *b); +extern void oggpack_writetrunc(oggpack_buffer *b,long bits); +extern void oggpack_writealign(oggpack_buffer *b); +extern void oggpack_writecopy(oggpack_buffer *b,void *source,long bits); +extern void oggpack_reset(oggpack_buffer *b); +extern void oggpack_writeclear(oggpack_buffer *b); +extern void oggpack_readinit(oggpack_buffer *b,unsigned char *buf,int bytes); +extern void oggpack_write(oggpack_buffer *b,unsigned long value,int bits); +extern long oggpack_look(oggpack_buffer *b,int bits); +extern long oggpack_look1(oggpack_buffer *b); +extern void oggpack_adv(oggpack_buffer *b,int bits); +extern void oggpack_adv1(oggpack_buffer *b); +extern long oggpack_read(oggpack_buffer *b,int bits); +extern long oggpack_read1(oggpack_buffer *b); +extern long oggpack_bytes(oggpack_buffer *b); +extern long oggpack_bits(oggpack_buffer *b); +extern unsigned char *oggpack_get_buffer(oggpack_buffer *b); + +extern void oggpackB_writeinit(oggpack_buffer *b); +extern void oggpackB_writetrunc(oggpack_buffer *b,long bits); +extern void oggpackB_writealign(oggpack_buffer *b); +extern void oggpackB_writecopy(oggpack_buffer *b,void *source,long bits); +extern void oggpackB_reset(oggpack_buffer *b); +extern void oggpackB_writeclear(oggpack_buffer *b); +extern void oggpackB_readinit(oggpack_buffer *b,unsigned char *buf,int bytes); +extern void oggpackB_write(oggpack_buffer *b,unsigned long value,int bits); +extern long oggpackB_look(oggpack_buffer *b,int bits); +extern long oggpackB_look1(oggpack_buffer *b); +extern void oggpackB_adv(oggpack_buffer *b,int bits); +extern void oggpackB_adv1(oggpack_buffer *b); +extern long oggpackB_read(oggpack_buffer *b,int bits); +extern long oggpackB_read1(oggpack_buffer *b); +extern long oggpackB_bytes(oggpack_buffer *b); +extern long oggpackB_bits(oggpack_buffer *b); +extern unsigned char *oggpackB_get_buffer(oggpack_buffer *b); + +/* Ogg BITSTREAM PRIMITIVES: encoding **************************/ + +extern int spx_ogg_stream_packetin(spx_ogg_stream_state *os, spx_ogg_packet *op); +extern int spx_ogg_stream_pageout(spx_ogg_stream_state *os, spx_ogg_page *og); +extern int spx_ogg_stream_flush(spx_ogg_stream_state *os, spx_ogg_page *og); + +/* Ogg BITSTREAM PRIMITIVES: decoding **************************/ + +extern int spx_ogg_sync_init(spx_ogg_sync_state *oy); +extern int spx_ogg_sync_clear(spx_ogg_sync_state *oy); +extern int spx_ogg_sync_reset(spx_ogg_sync_state *oy); +extern int spx_ogg_sync_destroy(spx_ogg_sync_state *oy); + +extern void spx_ogg_alloc_buffer(spx_ogg_sync_state *oy, long size); +extern char *spx_ogg_sync_buffer(spx_ogg_sync_state *oy, long size); +extern int spx_ogg_sync_wrote(spx_ogg_sync_state *oy, long bytes); +extern long spx_ogg_sync_pageseek(spx_ogg_sync_state *oy,spx_ogg_page *og); +extern int spx_ogg_sync_pageout(spx_ogg_sync_state *oy, spx_ogg_page *og); +extern int spx_ogg_stream_pagein(spx_ogg_stream_state *os, spx_ogg_page *og); +extern int spx_ogg_stream_packetout(spx_ogg_stream_state *os,spx_ogg_packet *op); +extern int spx_ogg_stream_packetpeek(spx_ogg_stream_state *os,spx_ogg_packet *op); + +/* Ogg BITSTREAM PRIMITIVES: general ***************************/ + +extern int spx_ogg_stream_init(spx_ogg_stream_state *os,int serialno); +extern int spx_ogg_stream_clear(spx_ogg_stream_state *os); +extern int spx_ogg_stream_reset(spx_ogg_stream_state *os); +extern int spx_ogg_stream_reset_serialno(spx_ogg_stream_state *os,int serialno); +extern int spx_ogg_stream_destroy(spx_ogg_stream_state *os); +extern int spx_ogg_stream_eos(spx_ogg_stream_state *os); + +extern void spx_ogg_page_checksum_set(spx_ogg_page *og); + +extern int spx_ogg_page_version(spx_ogg_page *og); +extern int spx_ogg_page_continued(spx_ogg_page *og); +extern int spx_ogg_page_bos(spx_ogg_page *og); +extern int spx_ogg_page_eos(spx_ogg_page *og); +extern spx_ogg_int64_t spx_ogg_page_granulepos(spx_ogg_page *og); +extern int spx_ogg_page_serialno(spx_ogg_page *og); +extern long spx_ogg_page_pageno(spx_ogg_page *og); +extern int spx_ogg_page_packets(spx_ogg_page *og); + +extern void spx_ogg_packet_clear(spx_ogg_packet *op); + + +#ifdef __cplusplus +} +#endif + +#endif /* _OGG_H */ + + + + + + diff --git a/lib/rbcodec/codecs/libspeex/speex/speex.h b/lib/rbcodec/codecs/libspeex/speex/speex.h new file mode 100644 index 0000000000..086d492670 --- /dev/null +++ b/lib/rbcodec/codecs/libspeex/speex/speex.h @@ -0,0 +1,428 @@ +/* Copyright (C) 2002-2006 Jean-Marc Valin*/ +/** + @file speex.h + @brief Describes the different modes of the codec +*/ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + - Neither the name of the Xiph.org Foundation nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + +#ifndef SPEEX_H +#define SPEEX_H +/** @defgroup Codec Speex encoder and decoder + * This is the Speex codec itself. + * @{ + */ + +#include "speex_bits.h" +#include "speex_types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Values allowed for *ctl() requests */ + +/** Set enhancement on/off (decoder only) */ +#define SPEEX_SET_ENH 0 +/** Get enhancement state (decoder only) */ +#define SPEEX_GET_ENH 1 + +/*Would be SPEEX_SET_FRAME_SIZE, but it's (currently) invalid*/ +/** Obtain frame size used by encoder/decoder */ +#define SPEEX_GET_FRAME_SIZE 3 + +/** Set quality value */ +#define SPEEX_SET_QUALITY 4 +/** Get current quality setting */ +/* #define SPEEX_GET_QUALITY 5 -- Doesn't make much sense, does it? */ + +/** Set sub-mode to use */ +#define SPEEX_SET_MODE 6 +/** Get current sub-mode in use */ +#define SPEEX_GET_MODE 7 + +/** Set low-band sub-mode to use (wideband only)*/ +#define SPEEX_SET_LOW_MODE 8 +/** Get current low-band mode in use (wideband only)*/ +#define SPEEX_GET_LOW_MODE 9 + +/** Set high-band sub-mode to use (wideband only)*/ +#define SPEEX_SET_HIGH_MODE 10 +/** Get current high-band mode in use (wideband only)*/ +#define SPEEX_GET_HIGH_MODE 11 + +/** Set VBR on (1) or off (0) */ +#define SPEEX_SET_VBR 12 +/** Get VBR status (1 for on, 0 for off) */ +#define SPEEX_GET_VBR 13 + +/** Set quality value for VBR encoding (0-10) */ +#define SPEEX_SET_VBR_QUALITY 14 +/** Get current quality value for VBR encoding (0-10) */ +#define SPEEX_GET_VBR_QUALITY 15 + +/** Set complexity of the encoder (0-10) */ +#define SPEEX_SET_COMPLEXITY 16 +/** Get current complexity of the encoder (0-10) */ +#define SPEEX_GET_COMPLEXITY 17 + +/** Set bit-rate used by the encoder (or lower) */ +#define SPEEX_SET_BITRATE 18 +/** Get current bit-rate used by the encoder or decoder */ +#define SPEEX_GET_BITRATE 19 + +/** Define a handler function for in-band Speex request*/ +#define SPEEX_SET_HANDLER 20 + +/** Define a handler function for in-band user-defined request*/ +#define SPEEX_SET_USER_HANDLER 22 + +/** Set sampling rate used in bit-rate computation */ +#define SPEEX_SET_SAMPLING_RATE 24 +/** Get sampling rate used in bit-rate computation */ +#define SPEEX_GET_SAMPLING_RATE 25 + +/** Reset the encoder/decoder memories to zero*/ +#define SPEEX_RESET_STATE 26 + +/** Get VBR info (mostly used internally) */ +#define SPEEX_GET_RELATIVE_QUALITY 29 + +/** Set VAD status (1 for on, 0 for off) */ +#define SPEEX_SET_VAD 30 + +/** Get VAD status (1 for on, 0 for off) */ +#define SPEEX_GET_VAD 31 + +/** Set Average Bit-Rate (ABR) to n bits per seconds */ +#define SPEEX_SET_ABR 32 +/** Get Average Bit-Rate (ABR) setting (in bps) */ +#define SPEEX_GET_ABR 33 + +/** Set DTX status (1 for on, 0 for off) */ +#define SPEEX_SET_DTX 34 +/** Get DTX status (1 for on, 0 for off) */ +#define SPEEX_GET_DTX 35 + +/** Set submode encoding in each frame (1 for yes, 0 for no, setting to no breaks the standard) */ +#define SPEEX_SET_SUBMODE_ENCODING 36 +/** Get submode encoding in each frame */ +#define SPEEX_GET_SUBMODE_ENCODING 37 + +/*#define SPEEX_SET_LOOKAHEAD 38*/ +/** Returns the lookahead used by Speex */ +#define SPEEX_GET_LOOKAHEAD 39 + +/** Sets tuning for packet-loss concealment (expected loss rate) */ +#define SPEEX_SET_PLC_TUNING 40 +/** Gets tuning for PLC */ +#define SPEEX_GET_PLC_TUNING 41 + +/** Sets the max bit-rate allowed in VBR mode */ +#define SPEEX_SET_VBR_MAX_BITRATE 42 +/** Gets the max bit-rate allowed in VBR mode */ +#define SPEEX_GET_VBR_MAX_BITRATE 43 + +/** Turn on/off input/output high-pass filtering */ +#define SPEEX_SET_HIGHPASS 44 +/** Get status of input/output high-pass filtering */ +#define SPEEX_GET_HIGHPASS 45 + +/** Get "activity level" of the last decoded frame, i.e. + how much damage we cause if we remove the frame */ +#define SPEEX_GET_ACTIVITY 47 + + +/* Preserving compatibility:*/ +/** Equivalent to SPEEX_SET_ENH */ +#define SPEEX_SET_PF 0 +/** Equivalent to SPEEX_GET_ENH */ +#define SPEEX_GET_PF 1 + + + + +/* Values allowed for mode queries */ +/** Query the frame size of a mode */ +#define SPEEX_MODE_FRAME_SIZE 0 + +/** Query the size of an encoded frame for a particular sub-mode */ +#define SPEEX_SUBMODE_BITS_PER_FRAME 1 + + + +/** Get major Speex version */ +#define SPEEX_LIB_GET_MAJOR_VERSION 1 +/** Get minor Speex version */ +#define SPEEX_LIB_GET_MINOR_VERSION 3 +/** Get micro Speex version */ +#define SPEEX_LIB_GET_MICRO_VERSION 5 +/** Get extra Speex version */ +#define SPEEX_LIB_GET_EXTRA_VERSION 7 +/** Get Speex version string */ +#define SPEEX_LIB_GET_VERSION_STRING 9 + +/*#define SPEEX_LIB_SET_ALLOC_FUNC 10 +#define SPEEX_LIB_GET_ALLOC_FUNC 11 +#define SPEEX_LIB_SET_FREE_FUNC 12 +#define SPEEX_LIB_GET_FREE_FUNC 13 + +#define SPEEX_LIB_SET_WARNING_FUNC 14 +#define SPEEX_LIB_GET_WARNING_FUNC 15 +#define SPEEX_LIB_SET_ERROR_FUNC 16 +#define SPEEX_LIB_GET_ERROR_FUNC 17 +*/ + +/** Number of defined modes in Speex */ +#define SPEEX_NB_MODES 3 + +/** modeID for the defined narrowband mode */ +#define SPEEX_MODEID_NB 0 + +/** modeID for the defined wideband mode */ +#define SPEEX_MODEID_WB 1 + +/** modeID for the defined ultra-wideband mode */ +#define SPEEX_MODEID_UWB 2 + +struct SpeexMode; + + +/* Prototypes for mode function pointers */ + +/** Encoder state initialization function */ +typedef void *(*encoder_init_func)(const struct SpeexMode *mode); + +/** Encoder state destruction function */ +typedef void (*encoder_destroy_func)(void *st); + +/** Main encoding function */ +typedef int (*encode_func)(void *state, void *in, SpeexBits *bits); + +/** Function for controlling the encoder options */ +typedef int (*encoder_ctl_func)(void *state, int request, void *ptr); + +/** Decoder state initialization function */ +typedef void *(*decoder_init_func)(const struct SpeexMode *mode); + +/** Decoder state destruction function */ +typedef void (*decoder_destroy_func)(void *st); + +/** Main decoding function */ +typedef int (*decode_func)(void *state, SpeexBits *bits, void *out); + +/** Function for controlling the decoder options */ +typedef int (*decoder_ctl_func)(void *state, int request, void *ptr); + + +/** Query function for a mode */ +typedef int (*mode_query_func)(const void *mode, int request, void *ptr); + +/** Struct defining a Speex mode */ +typedef struct SpeexMode { + /** Pointer to the low-level mode data */ + const void *mode; + + /** Pointer to the mode query function */ + mode_query_func query; + + /** The name of the mode (you should not rely on this to identify the mode)*/ + const char *modeName; + + /**ID of the mode*/ + int modeID; + + /**Version number of the bitstream (incremented every time we break + bitstream compatibility*/ + int bitstream_version; + +#ifndef SPEEX_DISABLE_ENCODER + /** Pointer to encoder initialization function */ + encoder_init_func enc_init; + + /** Pointer to encoder destruction function */ + encoder_destroy_func enc_destroy; + + /** Pointer to frame encoding function */ + encode_func enc; +#endif + + /** Pointer to decoder initialization function */ + decoder_init_func dec_init; + + /** Pointer to decoder destruction function */ + decoder_destroy_func dec_destroy; + + /** Pointer to frame decoding function */ + decode_func dec; + +#ifndef SPEEX_DISABLE_ENCODER + /** ioctl-like requests for encoder */ + encoder_ctl_func enc_ctl; +#endif + + /** ioctl-like requests for decoder */ + decoder_ctl_func dec_ctl; + +} SpeexMode; + +/** + * Returns a handle to a newly created Speex encoder state structure. For now, + * the "mode" argument can be &nb_mode or &wb_mode . In the future, more modes + * may be added. Note that for now if you have more than one channels to + * encode, you need one state per channel. + * + * @param mode The mode to use (either speex_nb_mode or speex_wb.mode) + * @return A newly created encoder state or NULL if state allocation fails + */ +void *speex_encoder_init(const SpeexMode *mode); + +/** Frees all resources associated to an existing Speex encoder state. + * @param state Encoder state to be destroyed */ +void speex_encoder_destroy(void *state); + +/** Uses an existing encoder state to encode one frame of speech pointed to by + "in". The encoded bit-stream is saved in "bits". + @param state Encoder state + @param in Frame that will be encoded with a +-2^15 range. This data MAY be + overwritten by the encoder and should be considered uninitialised + after the call. + @param bits Bit-stream where the data will be written + @return 0 if frame needs not be transmitted (DTX only), 1 otherwise + */ +int speex_encode(void *state, float *in, SpeexBits *bits); + +/** Uses an existing encoder state to encode one frame of speech pointed to by + "in". The encoded bit-stream is saved in "bits". + @param state Encoder state + @param in Frame that will be encoded with a +-2^15 range + @param bits Bit-stream where the data will be written + @return 0 if frame needs not be transmitted (DTX only), 1 otherwise + */ +int speex_encode_int(void *state, spx_int16_t *in, SpeexBits *bits); + +/** Used like the ioctl function to control the encoder parameters + * + * @param state Encoder state + * @param request ioctl-type request (one of the SPEEX_* macros) + * @param ptr Data exchanged to-from function + * @return 0 if no error, -1 if request in unknown, -2 for invalid parameter + */ +int speex_encoder_ctl(void *state, int request, void *ptr); + + +/** Returns a handle to a newly created decoder state structure. For now, + * the mode argument can be &nb_mode or &wb_mode . In the future, more modes + * may be added. Note that for now if you have more than one channels to + * decode, you need one state per channel. + * + * @param mode Speex mode (one of speex_nb_mode or speex_wb_mode) + * @return A newly created decoder state or NULL if state allocation fails + */ +void *speex_decoder_init(const SpeexMode *mode); + +/** Frees all resources associated to an existing decoder state. + * + * @param state State to be destroyed + */ +void speex_decoder_destroy(void *state); + +/** Uses an existing decoder state to decode one frame of speech from + * bit-stream bits. The output speech is saved written to out. + * + * @param state Decoder state + * @param bits Bit-stream from which to decode the frame (NULL if the packet was lost) + * @param out Where to write the decoded frame + * @return return status (0 for no error, -1 for end of stream, -2 corrupt stream) + */ +int speex_decode(void *state, SpeexBits *bits, float *out); + +/** Uses an existing decoder state to decode one frame of speech from + * bit-stream bits. The output speech is saved written to out. + * + * @param state Decoder state + * @param bits Bit-stream from which to decode the frame (NULL if the packet was lost) + * @param out Where to write the decoded frame + * @return return status (0 for no error, -1 for end of stream, -2 corrupt stream) + */ +int speex_decode_int(void *state, SpeexBits *bits, spx_int16_t *out); + +/** Used like the ioctl function to control the encoder parameters + * + * @param state Decoder state + * @param request ioctl-type request (one of the SPEEX_* macros) + * @param ptr Data exchanged to-from function + * @return 0 if no error, -1 if request in unknown, -2 for invalid parameter + */ +int speex_decoder_ctl(void *state, int request, void *ptr); + + +/** Query function for mode information + * + * @param mode Speex mode + * @param request ioctl-type request (one of the SPEEX_* macros) + * @param ptr Data exchanged to-from function + * @return 0 if no error, -1 if request in unknown, -2 for invalid parameter + */ +int speex_mode_query(const SpeexMode *mode, int request, void *ptr); + +/** Functions for controlling the behavior of libspeex + * @param request ioctl-type request (one of the SPEEX_LIB_* macros) + * @param ptr Data exchanged to-from function + * @return 0 if no error, -1 if request in unknown, -2 for invalid parameter + */ +int speex_lib_ctl(int request, void *ptr); + +/** Default narrowband mode */ +extern const SpeexMode speex_nb_mode; + +/** Default wideband mode */ +extern const SpeexMode speex_wb_mode; + +/** Default "ultra-wideband" mode */ +extern const SpeexMode speex_uwb_mode; + +/** List of all modes available */ +extern const SpeexMode * const speex_mode_list[SPEEX_NB_MODES]; + +/** Obtain one of the modes available */ +const SpeexMode * speex_lib_get_mode (int mode); + +#ifndef WIN32 +/* We actually override the function in the narrowband case so that we can avoid linking in the wideband stuff */ +#define speex_lib_get_mode(mode) ((mode)==SPEEX_MODEID_NB ? &speex_nb_mode : speex_lib_get_mode (mode)) +#endif + +#ifdef __cplusplus +} +#endif + +/** @}*/ +#endif diff --git a/lib/rbcodec/codecs/libspeex/speex/speex_bits.h b/lib/rbcodec/codecs/libspeex/speex/speex_bits.h new file mode 100644 index 0000000000..fee2893380 --- /dev/null +++ b/lib/rbcodec/codecs/libspeex/speex/speex_bits.h @@ -0,0 +1,184 @@ +/* Copyright (C) 2002 Jean-Marc Valin */ +/** + @file speex_bits.h + @brief Handles bit packing/unpacking +*/ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + - Neither the name of the Xiph.org Foundation nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + +#ifndef BITS_H +#define BITS_H +/** @defgroup SpeexBits SpeexBits: Bit-stream manipulations + * This is the structure that holds the bit-stream when encoding or decoding + * with Speex. It allows some manipulations as well. + * @{ + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/** Bit-packing data structure representing (part of) a bit-stream. */ +typedef struct SpeexBits { + char *chars; /**< "raw" data */ + int nbBits; /**< Total number of bits stored in the stream*/ + int charPtr; /**< Position of the byte "cursor" */ + int bitPtr; /**< Position of the bit "cursor" within the current char */ + int owner; /**< Does the struct "own" the "raw" buffer (member "chars") */ + int overflow;/**< Set to one if we try to read past the valid data */ + int buf_size;/**< Allocated size for buffer */ + int reserved1; /**< Reserved for future use */ + void *reserved2; /**< Reserved for future use */ +} SpeexBits; + +/** Initializes and allocates resources for a SpeexBits struct */ +void speex_bits_init(SpeexBits *bits); + +/** Initializes SpeexBits struct using a pre-allocated buffer*/ +/* Rockbox: unused +void speex_bits_init_buffer(SpeexBits *bits, void *buff, int buf_size); +*/ + +/** Sets the bits in a SpeexBits struct to use data from an existing buffer (for decoding without copying data) */ +void speex_bits_set_bit_buffer(SpeexBits *bits, void *buff, int buf_size); + +/** Frees all resources associated to a SpeexBits struct. Right now this does nothing since no resources are allocated, but this could change in the future.*/ +void speex_bits_destroy(SpeexBits *bits); + +/** Resets bits to initial value (just after initialization, erasing content)*/ +void speex_bits_reset(SpeexBits *bits); + +/** Rewind the bit-stream to the beginning (ready for read) without erasing the content */ +/* Rockbox: unused +void speex_bits_rewind(SpeexBits *bits); +*/ + +/** Initializes the bit-stream from the data in an area of memory */ +void speex_bits_read_from(SpeexBits *bits, char *bytes, int len); + +/** Append bytes to the bit-stream + * + * @param bits Bit-stream to operate on + * @param bytes pointer to the bytes what will be appended + * @param len Number of bytes of append + */ +void speex_bits_read_whole_bytes(SpeexBits *bits, char *bytes, int len); + +/** Write the content of a bit-stream to an area of memory + * + * @param bits Bit-stream to operate on + * @param bytes Memory location where to write the bits + * @param max_len Maximum number of bytes to write (i.e. size of the "bytes" buffer) + * @return Number of bytes written to the "bytes" buffer +*/ +int speex_bits_write(SpeexBits *bits, char *bytes, int max_len); + +/** Like speex_bits_write, but writes only the complete bytes in the stream. Also removes the written bytes from the stream */ +int speex_bits_write_whole_bytes(SpeexBits *bits, char *bytes, int max_len); + +/** Append bits to the bit-stream + * @param bits Bit-stream to operate on + * @param data Value to append as integer + * @param nbBits number of bits to consider in "data" + */ +void speex_bits_pack(SpeexBits *bits, int data, int nbBits); + +/** Interpret the next bits in the bit-stream as a signed integer + * + * @param bits Bit-stream to operate on + * @param nbBits Number of bits to interpret + * @return A signed integer represented by the bits read + */ +/* Rockbox: unused +int speex_bits_unpack_signed(SpeexBits *bits, int nbBits); +*/ + +/** Interpret the next bits in the bit-stream as an unsigned integer + * + * @param bits Bit-stream to operate on + * @param nbBits Number of bits to interpret + * @return An unsigned integer represented by the bits read + */ +unsigned int speex_bits_unpack_unsigned(SpeexBits *bits, int nbBits); + +/** Returns the number of bytes in the bit-stream, including the last one even if it is not "full" + * + * @param bits Bit-stream to operate on + * @return Number of bytes in the stream + */ +/* Rockbox: unused +int speex_bits_nbytes(SpeexBits *bits); +*/ + +/** Same as speex_bits_unpack_unsigned, but without modifying the cursor position + * + * @param bits Bit-stream to operate on + * @param nbBits Number of bits to look for + * @return Value of the bits peeked, interpreted as unsigned + */ +/* Rockbox: unused +unsigned int speex_bits_peek_unsigned(SpeexBits *bits, int nbBits); +*/ + +/** Get the value of the next bit in the stream, without modifying the + * "cursor" position + * + * @param bits Bit-stream to operate on + * @return Value of the bit peeked (one bit only) + */ +int speex_bits_peek(SpeexBits *bits); + +/** Advances the position of the "bit cursor" in the stream + * + * @param bits Bit-stream to operate on + * @param n Number of bits to advance + */ +void speex_bits_advance(SpeexBits *bits, int n); + +/** Returns the number of bits remaining to be read in a stream + * + * @param bits Bit-stream to operate on + * @return Number of bits that can still be read from the stream + */ +int speex_bits_remaining(SpeexBits *bits); + +/** Insert a terminator so that the data can be sent as a packet while auto-detecting + * the number of frames in each packet + * + * @param bits Bit-stream to operate on + */ +void speex_bits_insert_terminator(SpeexBits *bits); + +#ifdef __cplusplus +} +#endif + +/* @} */ +#endif diff --git a/lib/rbcodec/codecs/libspeex/speex/speex_callbacks.h b/lib/rbcodec/codecs/libspeex/speex/speex_callbacks.h new file mode 100644 index 0000000000..6f450b3a3a --- /dev/null +++ b/lib/rbcodec/codecs/libspeex/speex/speex_callbacks.h @@ -0,0 +1,134 @@ +/* Copyright (C) 2002 Jean-Marc Valin*/ +/** + @file speex_callbacks.h + @brief Describes callback handling and in-band signalling +*/ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + - Neither the name of the Xiph.org Foundation nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + +#ifndef SPEEX_CALLBACKS_H +#define SPEEX_CALLBACKS_H +/** @defgroup SpeexCallbacks Various definitions for Speex callbacks supported by the decoder. + * @{ + */ + +#include "speex.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** Total number of callbacks */ +#define SPEEX_MAX_CALLBACKS 16 + +/* Describes all the in-band requests */ + +/*These are 1-bit requests*/ +/** Request for perceptual enhancement (1 for on, 0 for off) */ +#define SPEEX_INBAND_ENH_REQUEST 0 +/** Reserved */ +#define SPEEX_INBAND_RESERVED1 1 + +/*These are 4-bit requests*/ +/** Request for a mode change */ +#define SPEEX_INBAND_MODE_REQUEST 2 +/** Request for a low mode change */ +#define SPEEX_INBAND_LOW_MODE_REQUEST 3 +/** Request for a high mode change */ +#define SPEEX_INBAND_HIGH_MODE_REQUEST 4 +/** Request for VBR (1 on, 0 off) */ +#define SPEEX_INBAND_VBR_QUALITY_REQUEST 5 +/** Request to be sent acknowledge */ +#define SPEEX_INBAND_ACKNOWLEDGE_REQUEST 6 +/** Request for VBR (1 for on, 0 for off) */ +#define SPEEX_INBAND_VBR_REQUEST 7 + +/*These are 8-bit requests*/ +/** Send a character in-band */ +#define SPEEX_INBAND_CHAR 8 +/** Intensity stereo information */ +#define SPEEX_INBAND_STEREO 9 + +/*These are 16-bit requests*/ +/** Transmit max bit-rate allowed */ +#define SPEEX_INBAND_MAX_BITRATE 10 + +/*These are 32-bit requests*/ +/** Acknowledge packet reception */ +#define SPEEX_INBAND_ACKNOWLEDGE 12 + +/** Callback function type */ +typedef int (*speex_callback_func)(SpeexBits *bits, void *state, void *data); + +/** Callback information */ +typedef struct SpeexCallback { + int callback_id; /**< ID associated to the callback */ + speex_callback_func func; /**< Callback handler function */ + void *data; /**< Data that will be sent to the handler */ + void *reserved1; /**< Reserved for future use */ + int reserved2; /**< Reserved for future use */ +} SpeexCallback; + +/** Handle in-band request */ +int speex_inband_handler(SpeexBits *bits, SpeexCallback *callback_list, void *state); + +/** Standard handler for mode request (change mode, no questions asked) */ +int speex_std_mode_request_handler(SpeexBits *bits, void *state, void *data); + +/** Standard handler for high mode request (change high mode, no questions asked) */ +int speex_std_high_mode_request_handler(SpeexBits *bits, void *state, void *data); + +/** Standard handler for in-band characters (write to stderr) */ +int speex_std_char_handler(SpeexBits *bits, void *state, void *data); + +/** Default handler for user-defined requests: in this case, just ignore */ +int speex_default_user_handler(SpeexBits *bits, void *state, void *data); + + + +/** Standard handler for low mode request (change low mode, no questions asked) */ +int speex_std_low_mode_request_handler(SpeexBits *bits, void *state, void *data); + +/** Standard handler for VBR request (Set VBR, no questions asked) */ +int speex_std_vbr_request_handler(SpeexBits *bits, void *state, void *data); + +/** Standard handler for enhancer request (Turn enhancer on/off, no questions asked) */ +int speex_std_enh_request_handler(SpeexBits *bits, void *state, void *data); + +/** Standard handler for VBR quality request (Set VBR quality, no questions asked) */ +int speex_std_vbr_quality_request_handler(SpeexBits *bits, void *state, void *data); + + +#ifdef __cplusplus +} +#endif + +/** @} */ +#endif diff --git a/lib/rbcodec/codecs/libspeex/speex/speex_config_types.h b/lib/rbcodec/codecs/libspeex/speex/speex_config_types.h new file mode 100644 index 0000000000..ef328d48c1 --- /dev/null +++ b/lib/rbcodec/codecs/libspeex/speex/speex_config_types.h @@ -0,0 +1,13 @@ +#ifndef __SPEEX_TYPES_H__ +#define __SPEEX_TYPES_H__ + +#include "inttypes.h" +#define spx_int16_t int16_t +#define spx_uint16_t uint16_t +#define spx_int32_t int32_t +#define spx_uint32_t uint32_t +#define spx_int64_t int64_t +#define spx_uint64_t uint64_t + +#endif + diff --git a/lib/rbcodec/codecs/libspeex/speex/speex_echo.h b/lib/rbcodec/codecs/libspeex/speex/speex_echo.h new file mode 100644 index 0000000000..6fcb0c00d7 --- /dev/null +++ b/lib/rbcodec/codecs/libspeex/speex/speex_echo.h @@ -0,0 +1,123 @@ +/* Copyright (C) Jean-Marc Valin */ +/** + @file speex_echo.h + @brief Echo cancellation +*/ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + 3. The name of the author may not be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef SPEEX_ECHO_H +#define SPEEX_ECHO_H +/** @defgroup SpeexEchoState SpeexEchoState: Acoustic echo canceller + * This is the acoustic echo canceller module. + * @{ + */ +#include "speex_types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** Obtain frame size used by the AEC */ +#define SPEEX_ECHO_GET_FRAME_SIZE 3 + +/** Set sampling rate */ +#define SPEEX_ECHO_SET_SAMPLING_RATE 24 +/** Get sampling rate */ +#define SPEEX_ECHO_GET_SAMPLING_RATE 25 + +/** Internal echo canceller state. Should never be accessed directly. */ +struct SpeexEchoState_; + +/** @class SpeexEchoState + * This holds the state of the echo canceller. You need one per channel. +*/ + +/** Internal echo canceller state. Should never be accessed directly. */ +typedef struct SpeexEchoState_ SpeexEchoState; + +/** Creates a new echo canceller state + * @param frame_size Number of samples to process at one time (should correspond to 10-20 ms) + * @param filter_length Number of samples of echo to cancel (should generally correspond to 100-500 ms) + * @return Newly-created echo canceller state + */ +SpeexEchoState *speex_echo_state_init(int frame_size, int filter_length); + +/** Destroys an echo canceller state + * @param st Echo canceller state +*/ +void speex_echo_state_destroy(SpeexEchoState *st); + +/** Performs echo cancellation a frame, based on the audio sent to the speaker (no delay is added + * to playback in this form) + * + * @param st Echo canceller state + * @param rec Signal from the microphone (near end + far end echo) + * @param play Signal played to the speaker (received from far end) + * @param out Returns near-end signal with echo removed + */ +void speex_echo_cancellation(SpeexEchoState *st, const spx_int16_t *rec, const spx_int16_t *play, spx_int16_t *out); + +/** Performs echo cancellation a frame (deprecated) */ +void speex_echo_cancel(SpeexEchoState *st, const spx_int16_t *rec, const spx_int16_t *play, spx_int16_t *out, spx_int32_t *Yout); + +/** Perform echo cancellation using internal playback buffer, which is delayed by two frames + * to account for the delay introduced by most soundcards (but it could be off!) + * @param st Echo canceller state + * @param rec Signal from the microphone (near end + far end echo) + * @param out Returns near-end signal with echo removed +*/ +void speex_echo_capture(SpeexEchoState *st, const spx_int16_t *rec, spx_int16_t *out); + +/** Let the echo canceller know that a frame was just queued to the soundcard + * @param st Echo canceller state + * @param play Signal played to the speaker (received from far end) +*/ +void speex_echo_playback(SpeexEchoState *st, const spx_int16_t *play); + +/** Reset the echo canceller to its original state + * @param st Echo canceller state + */ +void speex_echo_state_reset(SpeexEchoState *st); + +/** Used like the ioctl function to control the echo canceller parameters + * + * @param st Echo canceller state + * @param request ioctl-type request (one of the SPEEX_ECHO_* macros) + * @param ptr Data exchanged to-from function + * @return 0 if no error, -1 if request in unknown + */ +int speex_echo_ctl(SpeexEchoState *st, int request, void *ptr); + +#ifdef __cplusplus +} +#endif + + +/** @}*/ +#endif diff --git a/lib/rbcodec/codecs/libspeex/speex/speex_header.h b/lib/rbcodec/codecs/libspeex/speex/speex_header.h new file mode 100644 index 0000000000..2b60003fe9 --- /dev/null +++ b/lib/rbcodec/codecs/libspeex/speex/speex_header.h @@ -0,0 +1,91 @@ +/* Copyright (C) 2002 Jean-Marc Valin */ +/** + @file speex_header.h + @brief Describes the Speex header +*/ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + - Neither the name of the Xiph.org Foundation nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + + +#ifndef SPEEX_HEADER_H +#define SPEEX_HEADER_H +/** @defgroup SpeexHeader SpeexHeader: Makes it easy to write/parse an Ogg/Speex header + * This is the Speex header for the Ogg encapsulation. You don't need that if you just use RTP. + * @{ + */ + +#include "speex_types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +struct SpeexMode; + +/** Length of the Speex header identifier */ +#define SPEEX_HEADER_STRING_LENGTH 8 + +/** Maximum number of characters for encoding the Speex version number in the header */ +#define SPEEX_HEADER_VERSION_LENGTH 20 + +/** Speex header info for file-based formats */ +typedef struct SpeexHeader { + char speex_string[SPEEX_HEADER_STRING_LENGTH]; /**< Identifies a Speex bit-stream, always set to "Speex " */ + char speex_version[SPEEX_HEADER_VERSION_LENGTH]; /**< Speex version */ + spx_int32_t speex_version_id; /**< Version for Speex (for checking compatibility) */ + spx_int32_t header_size; /**< Total size of the header ( sizeof(SpeexHeader) ) */ + spx_int32_t rate; /**< Sampling rate used */ + spx_int32_t mode; /**< Mode used (0 for narrowband, 1 for wideband) */ + spx_int32_t mode_bitstream_version; /**< Version ID of the bit-stream */ + spx_int32_t nb_channels; /**< Number of channels encoded */ + spx_int32_t bitrate; /**< Bit-rate used */ + spx_int32_t frame_size; /**< Size of frames */ + spx_int32_t vbr; /**< 1 for a VBR encoding, 0 otherwise */ + spx_int32_t frames_per_packet; /**< Number of frames stored per Ogg packet */ + spx_int32_t extra_headers; /**< Number of additional headers after the comments */ + spx_int32_t reserved1; /**< Reserved for future use, must be zero */ + spx_int32_t reserved2; /**< Reserved for future use, must be zero */ +} SpeexHeader; + +/** Initializes a SpeexHeader using basic information */ +void speex_init_header(SpeexHeader *header, int rate, int nb_channels, const struct SpeexMode *m); + +/** Creates the header packet from the header itself (mostly involves endianness conversion) */ +char *speex_header_to_packet(SpeexHeader *header, int *size); + +/** Creates a SpeexHeader from a packet */ +SpeexHeader *speex_packet_to_header(char *packet, int size); + +#ifdef __cplusplus +} +#endif + +/** @} */ +#endif diff --git a/lib/rbcodec/codecs/libspeex/speex/speex_jitter.h b/lib/rbcodec/codecs/libspeex/speex/speex_jitter.h new file mode 100644 index 0000000000..03bac15636 --- /dev/null +++ b/lib/rbcodec/codecs/libspeex/speex/speex_jitter.h @@ -0,0 +1,197 @@ +/* Copyright (C) 2002 Jean-Marc Valin */ +/** + @file speex_jitter.h + @brief Adaptive jitter buffer for Speex +*/ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + - Neither the name of the Xiph.org Foundation nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + +#ifndef SPEEX_JITTER_H +#define SPEEX_JITTER_H +/** @defgroup JitterBuffer JitterBuffer: Adaptive jitter buffer + * This is the jitter buffer that reorders UDP/RTP packets and adjusts the buffer size + * to maintain good quality and low latency. + * @{ + */ + +#include "speex_types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** Generic adaptive jitter buffer state */ +struct JitterBuffer_; + +/** Generic adaptive jitter buffer state */ +typedef struct JitterBuffer_ JitterBuffer; + +/** Definition of an incoming packet */ +typedef struct _JitterBufferPacket JitterBufferPacket; + +/** Definition of an incoming packet */ +struct _JitterBufferPacket { + char *data; /**< Data bytes contained in the packet */ + spx_uint32_t len; /**< Length of the packet in bytes */ + spx_uint32_t timestamp; /**< Timestamp for the packet */ + spx_uint32_t span; /**< Time covered by the packet (same units as timestamp) */ + spx_uint16_t sequence; /**< RTP Sequence number if available (0 otherwise) */ + spx_uint32_t user_data; /**< Put whatever data you like here (it's ignored by the jitter buffer) */ +}; + +/** Packet has been retrieved */ +#define JITTER_BUFFER_OK 0 +/** Packet is lost or is late */ +#define JITTER_BUFFER_MISSING 1 +/** A "fake" packet is meant to be inserted here to increase buffering */ +#define JITTER_BUFFER_INSERTION 2 +/** There was an error in the jitter buffer */ +#define JITTER_BUFFER_INTERNAL_ERROR -1 +/** Invalid argument */ +#define JITTER_BUFFER_BAD_ARGUMENT -2 + + +/** Set minimum amount of extra buffering required (margin) */ +#define JITTER_BUFFER_SET_MARGIN 0 +/** Get minimum amount of extra buffering required (margin) */ +#define JITTER_BUFFER_GET_MARGIN 1 +/* JITTER_BUFFER_SET_AVAILABLE_COUNT wouldn't make sense */ + +/** Get the amount of available packets currently buffered */ +#define JITTER_BUFFER_GET_AVAILABLE_COUNT 3 +/** Included because of an early misspelling (will remove in next release) */ +#define JITTER_BUFFER_GET_AVALIABLE_COUNT 3 + +/** Assign a function to destroy unused packet. When setting that, the jitter + buffer no longer copies packet data. */ +#define JITTER_BUFFER_SET_DESTROY_CALLBACK 4 +/** */ +#define JITTER_BUFFER_GET_DESTROY_CALLBACK 5 + +/** Tell the jitter buffer to only adjust the delay in multiples of the step parameter provided */ +#define JITTER_BUFFER_SET_DELAY_STEP 6 +/** */ +#define JITTER_BUFFER_GET_DELAY_STEP 7 + +/** Tell the jitter buffer to only do concealment in multiples of the size parameter provided */ +#define JITTER_BUFFER_SET_CONCEALMENT_SIZE 8 +#define JITTER_BUFFER_GET_CONCEALMENT_SIZE 9 + +/** Absolute max amount of loss that can be tolerated regardless of the delay. Typical loss + should be half of that or less. */ +#define JITTER_BUFFER_SET_MAX_LATE_RATE 10 +#define JITTER_BUFFER_GET_MAX_LATE_RATE 11 + +/** Equivalent cost of one percent late packet in timestamp units */ +#define JITTER_BUFFER_SET_LATE_COST 12 +#define JITTER_BUFFER_GET_LATE_COST 13 + + +/** Initialises jitter buffer + * + * @param step_size Starting value for the size of concleanment packets and delay + adjustment steps. Can be changed at any time using JITTER_BUFFER_SET_DELAY_STEP + and JITTER_BUFFER_GET_CONCEALMENT_SIZE. + * @return Newly created jitter buffer state + */ +JitterBuffer *jitter_buffer_init(int step_size); + +/** Restores jitter buffer to its original state + * + * @param jitter Jitter buffer state + */ +void jitter_buffer_reset(JitterBuffer *jitter); + +/** Destroys jitter buffer + * + * @param jitter Jitter buffer state + */ +void jitter_buffer_destroy(JitterBuffer *jitter); + +/** Put one packet into the jitter buffer + * + * @param jitter Jitter buffer state + * @param packet Incoming packet +*/ +void jitter_buffer_put(JitterBuffer *jitter, const JitterBufferPacket *packet); + +/** Get one packet from the jitter buffer + * + * @param jitter Jitter buffer state + * @param packet Returned packet + * @param desired_span Number of samples (or units) we wish to get from the buffer (no guarantee) + * @param current_timestamp Timestamp for the returned packet +*/ +int jitter_buffer_get(JitterBuffer *jitter, JitterBufferPacket *packet, spx_int32_t desired_span, spx_int32_t *start_offset); + +/** Used right after jitter_buffer_get() to obtain another packet that would have the same timestamp. + * This is mainly useful for media where a single "frame" can be split into several packets. + * + * @param jitter Jitter buffer state + * @param packet Returned packet + */ +int jitter_buffer_get_another(JitterBuffer *jitter, JitterBufferPacket *packet); + +/** Get pointer timestamp of jitter buffer + * + * @param jitter Jitter buffer state +*/ +int jitter_buffer_get_pointer_timestamp(JitterBuffer *jitter); + +/** Advance by one tick + * + * @param jitter Jitter buffer state +*/ +void jitter_buffer_tick(JitterBuffer *jitter); + +/** Telling the jitter buffer about the remaining data in the application buffer + * @param jitter Jitter buffer state + * @param rem Amount of data buffered by the application (timestamp units) + */ +void jitter_buffer_remaining_span(JitterBuffer *jitter, spx_uint32_t rem); + +/** Used like the ioctl function to control the jitter buffer parameters + * + * @param jitter Jitter buffer state + * @param request ioctl-type request (one of the JITTER_BUFFER_* macros) + * @param ptr Data exchanged to-from function + * @return 0 if no error, -1 if request in unknown +*/ +int jitter_buffer_ctl(JitterBuffer *jitter, int request, void *ptr); + +int jitter_buffer_update_delay(JitterBuffer *jitter, JitterBufferPacket *packet, spx_int32_t *start_offset); + +/* @} */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/lib/rbcodec/codecs/libspeex/speex/speex_preprocess.h b/lib/rbcodec/codecs/libspeex/speex/speex_preprocess.h new file mode 100644 index 0000000000..273efaff79 --- /dev/null +++ b/lib/rbcodec/codecs/libspeex/speex/speex_preprocess.h @@ -0,0 +1,190 @@ +/* Copyright (C) 2003 Epic Games + Written by Jean-Marc Valin */ +/** + * @file speex_preprocess.h + * @brief Speex preprocessor. The preprocess can do noise suppression, + * residual echo suppression (after using the echo canceller), automatic + * gain control (AGC) and voice activity detection (VAD). +*/ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + 3. The name of the author may not be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef SPEEX_PREPROCESS_H +#define SPEEX_PREPROCESS_H +/** @defgroup SpeexPreprocessState SpeexPreprocessState: The Speex preprocessor + * This is the Speex preprocessor. The preprocess can do noise suppression, + * residual echo suppression (after using the echo canceller), automatic + * gain control (AGC) and voice activity detection (VAD). + * @{ + */ + +#include "speex_types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** State of the preprocessor (one per channel). Should never be accessed directly. */ +struct SpeexPreprocessState_; + +/** State of the preprocessor (one per channel). Should never be accessed directly. */ +typedef struct SpeexPreprocessState_ SpeexPreprocessState; + + +/** Creates a new preprocessing state. You MUST create one state per channel processed. + * @param frame_size Number of samples to process at one time (should correspond to 10-20 ms). Must be + * the same value as that used for the echo canceller for residual echo cancellation to work. + * @param sampling_rate Sampling rate used for the input. + * @return Newly created preprocessor state +*/ +SpeexPreprocessState *speex_preprocess_state_init(int frame_size, int sampling_rate); + +/** Destroys a preprocessor state + * @param st Preprocessor state to destroy +*/ +void speex_preprocess_state_destroy(SpeexPreprocessState *st); + +/** Preprocess a frame + * @param st Preprocessor state + * @param x Audio sample vector (in and out). Must be same size as specified in speex_preprocess_state_init(). + * @return Bool value for voice activity (1 for speech, 0 for noise/silence), ONLY if VAD turned on. +*/ +int speex_preprocess_run(SpeexPreprocessState *st, spx_int16_t *x); + +/** Preprocess a frame (deprecated, use speex_preprocess_run() instead)*/ +int speex_preprocess(SpeexPreprocessState *st, spx_int16_t *x, spx_int32_t *echo); + +/** Update preprocessor state, but do not compute the output + * @param st Preprocessor state + * @param x Audio sample vector (in only). Must be same size as specified in speex_preprocess_state_init(). +*/ +void speex_preprocess_estimate_update(SpeexPreprocessState *st, spx_int16_t *x); + +/** Used like the ioctl function to control the preprocessor parameters + * @param st Preprocessor state + * @param request ioctl-type request (one of the SPEEX_PREPROCESS_* macros) + * @param ptr Data exchanged to-from function + * @return 0 if no error, -1 if request in unknown +*/ +int speex_preprocess_ctl(SpeexPreprocessState *st, int request, void *ptr); + + + +/** Set preprocessor denoiser state */ +#define SPEEX_PREPROCESS_SET_DENOISE 0 +/** Get preprocessor denoiser state */ +#define SPEEX_PREPROCESS_GET_DENOISE 1 + +/** Set preprocessor Automatic Gain Control state */ +#define SPEEX_PREPROCESS_SET_AGC 2 +/** Get preprocessor Automatic Gain Control state */ +#define SPEEX_PREPROCESS_GET_AGC 3 + +/** Set preprocessor Voice Activity Detection state */ +#define SPEEX_PREPROCESS_SET_VAD 4 +/** Get preprocessor Voice Activity Detection state */ +#define SPEEX_PREPROCESS_GET_VAD 5 + +/** Set preprocessor Automatic Gain Control level */ +#define SPEEX_PREPROCESS_SET_AGC_LEVEL 6 +/** Get preprocessor Automatic Gain Control level */ +#define SPEEX_PREPROCESS_GET_AGC_LEVEL 7 + +/** Set preprocessor dereverb state */ +#define SPEEX_PREPROCESS_SET_DEREVERB 8 +/** Get preprocessor dereverb state */ +#define SPEEX_PREPROCESS_GET_DEREVERB 9 + +/** Set preprocessor dereverb level */ +#define SPEEX_PREPROCESS_SET_DEREVERB_LEVEL 10 +/** Get preprocessor dereverb level */ +#define SPEEX_PREPROCESS_GET_DEREVERB_LEVEL 11 + +/** Set preprocessor dereverb decay */ +#define SPEEX_PREPROCESS_SET_DEREVERB_DECAY 12 +/** Get preprocessor dereverb decay */ +#define SPEEX_PREPROCESS_GET_DEREVERB_DECAY 13 + +/** Set probability required for the VAD to go from silence to voice */ +#define SPEEX_PREPROCESS_SET_PROB_START 14 +/** Get probability required for the VAD to go from silence to voice */ +#define SPEEX_PREPROCESS_GET_PROB_START 15 + +/** Set probability required for the VAD to stay in the voice state (integer percent) */ +#define SPEEX_PREPROCESS_SET_PROB_CONTINUE 16 +/** Get probability required for the VAD to stay in the voice state (integer percent) */ +#define SPEEX_PREPROCESS_GET_PROB_CONTINUE 17 + +/** Set maximum attenuation of the noise in dB (negative number) */ +#define SPEEX_PREPROCESS_SET_NOISE_SUPPRESS 18 +/** Get maximum attenuation of the noise in dB (negative number) */ +#define SPEEX_PREPROCESS_GET_NOISE_SUPPRESS 19 + +/** Set maximum attenuation of the residual echo in dB (negative number) */ +#define SPEEX_PREPROCESS_SET_ECHO_SUPPRESS 20 +/** Get maximum attenuation of the residual echo in dB (negative number) */ +#define SPEEX_PREPROCESS_GET_ECHO_SUPPRESS 21 + +/** Set maximum attenuation of the residual echo in dB when near end is active (negative number) */ +#define SPEEX_PREPROCESS_SET_ECHO_SUPPRESS_ACTIVE 22 +/** Get maximum attenuation of the residual echo in dB when near end is active (negative number) */ +#define SPEEX_PREPROCESS_GET_ECHO_SUPPRESS_ACTIVE 23 + +/** Set the corresponding echo canceller state so that residual echo suppression can be performed (NULL for no residual echo suppression) */ +#define SPEEX_PREPROCESS_SET_ECHO_STATE 24 +/** Get the corresponding echo canceller state */ +#define SPEEX_PREPROCESS_GET_ECHO_STATE 25 + +/** Set maximal gain increase in dB/second (int32) */ +#define SPEEX_PREPROCESS_SET_AGC_INCREMENT 26 + +/** Get maximal gain increase in dB/second (int32) */ +#define SPEEX_PREPROCESS_GET_AGC_INCREMENT 27 + +/** Set maximal gain decrease in dB/second (int32) */ +#define SPEEX_PREPROCESS_SET_AGC_DECREMENT 28 + +/** Get maximal gain decrease in dB/second (int32) */ +#define SPEEX_PREPROCESS_GET_AGC_DECREMENT 29 + +/** Set maximal gain in dB (int32) */ +#define SPEEX_PREPROCESS_SET_AGC_MAX_GAIN 30 + +/** Get maximal gain in dB (int32) */ +#define SPEEX_PREPROCESS_GET_AGC_MAX_GAIN 31 + +/* Can't set loudness */ +/** Get loudness */ +#define SPEEX_PREPROCESS_GET_AGC_LOUDNESS 33 + +#ifdef __cplusplus +} +#endif + +/** @}*/ +#endif diff --git a/lib/rbcodec/codecs/libspeex/speex/speex_resampler.h b/lib/rbcodec/codecs/libspeex/speex/speex_resampler.h new file mode 100644 index 0000000000..c44fbcd0d1 --- /dev/null +++ b/lib/rbcodec/codecs/libspeex/speex/speex_resampler.h @@ -0,0 +1,328 @@ +/* Copyright (C) 2007 Jean-Marc Valin + + File: speex_resampler.h + Resampling code + + The design goals of this code are: + - Very fast algorithm + - Low memory requirement + - Good *perceptual* quality (and not best SNR) + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + 3. The name of the author may not be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + + +#ifndef SPEEX_RESAMPLER_H +#define SPEEX_RESAMPLER_H + +#ifdef OUTSIDE_SPEEX + +/********* WARNING: MENTAL SANITY ENDS HERE *************/ + +/* If the resampler is defined outside of Speex, we change the symbol names so that + there won't be any clash if linking with Speex later on. */ + +/* #define RANDOM_PREFIX your software name here */ +#ifndef RANDOM_PREFIX +#error "Please define RANDOM_PREFIX (above) to something specific to your project to prevent symbol name clashes" +#endif + +#define CAT_PREFIX2(a,b) a ## b +#define CAT_PREFIX(a,b) CAT_PREFIX2(a, b) + +#define speex_resampler_init CAT_PREFIX(RANDOM_PREFIX,_resampler_init) +#define speex_resampler_init_frac CAT_PREFIX(RANDOM_PREFIX,_resampler_init_frac) +#define speex_resampler_destroy CAT_PREFIX(RANDOM_PREFIX,_resampler_destroy) +#define speex_resampler_process_float CAT_PREFIX(RANDOM_PREFIX,_resampler_process_float) +#define speex_resampler_process_int CAT_PREFIX(RANDOM_PREFIX,_resampler_process_int) +#define speex_resampler_process_interleaved_float CAT_PREFIX(RANDOM_PREFIX,_resampler_process_interleaved_float) +#define speex_resampler_process_interleaved_int CAT_PREFIX(RANDOM_PREFIX,_resampler_process_interleaved_int) +#define speex_resampler_set_rate CAT_PREFIX(RANDOM_PREFIX,_resampler_set_rate) +#define speex_resampler_get_rate CAT_PREFIX(RANDOM_PREFIX,_resampler_get_rate) +#define speex_resampler_set_rate_frac CAT_PREFIX(RANDOM_PREFIX,_resampler_set_rate_frac) +#define speex_resampler_get_ratio CAT_PREFIX(RANDOM_PREFIX,_resampler_get_ratio) +#define speex_resampler_set_quality CAT_PREFIX(RANDOM_PREFIX,_resampler_set_quality) +#define speex_resampler_get_quality CAT_PREFIX(RANDOM_PREFIX,_resampler_get_quality) +#define speex_resampler_set_input_stride CAT_PREFIX(RANDOM_PREFIX,_resampler_set_input_stride) +#define speex_resampler_get_input_stride CAT_PREFIX(RANDOM_PREFIX,_resampler_get_input_stride) +#define speex_resampler_set_output_stride CAT_PREFIX(RANDOM_PREFIX,_resampler_set_output_stride) +#define speex_resampler_get_output_stride CAT_PREFIX(RANDOM_PREFIX,_resampler_get_output_stride) +#define speex_resampler_skip_zeros CAT_PREFIX(RANDOM_PREFIX,_resampler_skip_zeros) +#define speex_resampler_reset_mem CAT_PREFIX(RANDOM_PREFIX,_resampler_reset_mem) +#define speex_resampler_strerror CAT_PREFIX(RANDOM_PREFIX,_resampler_strerror) + +#define spx_int16_t short +#define spx_int32_t int +#define spx_uint16_t unsigned short +#define spx_uint32_t unsigned int + +#else /* OUTSIDE_SPEEX */ + +#include "speex/speex_types.h" + +#endif /* OUTSIDE_SPEEX */ + +#ifdef __cplusplus +extern "C" { +#endif + +#define SPEEX_RESAMPLER_QUALITY_MAX 10 +#define SPEEX_RESAMPLER_QUALITY_MIN 0 +#define SPEEX_RESAMPLER_QUALITY_DEFAULT 4 +#define SPEEX_RESAMPLER_QUALITY_VOIP 3 +#define SPEEX_RESAMPLER_QUALITY_DESKTOP 5 + +enum { + RESAMPLER_ERR_SUCCESS = 0, + RESAMPLER_ERR_ALLOC_FAILED = 1, + RESAMPLER_ERR_BAD_STATE = 2, + RESAMPLER_ERR_INVALID_ARG = 3, + RESAMPLER_ERR_PTR_OVERLAP = 4, + + RESAMPLER_ERR_MAX_ERROR +}; + +struct SpeexResamplerState_; +typedef struct SpeexResamplerState_ SpeexResamplerState; + +/** Create a new resampler with integer input and output rates. + * @param nb_channels Number of channels to be processed + * @param in_rate Input sampling rate (integer number of Hz). + * @param out_rate Output sampling rate (integer number of Hz). + * @param quality Resampling quality between 0 and 10, where 0 has poor quality + * and 10 has very high quality. + * @return Newly created resampler state + * @retval NULL Error: not enough memory + */ +SpeexResamplerState *speex_resampler_init(spx_uint32_t nb_channels, + spx_uint32_t in_rate, + spx_uint32_t out_rate, + int quality, + int *err); + +/** Create a new resampler with fractional input/output rates. The sampling + * rate ratio is an arbitrary rational number with both the numerator and + * denominator being 32-bit integers. + * @param nb_channels Number of channels to be processed + * @param ratio_num Numerator of the sampling rate ratio + * @param ratio_den Denominator of the sampling rate ratio + * @param in_rate Input sampling rate rounded to the nearest integer (in Hz). + * @param out_rate Output sampling rate rounded to the nearest integer (in Hz). + * @param quality Resampling quality between 0 and 10, where 0 has poor quality + * and 10 has very high quality. + * @return Newly created resampler state + * @retval NULL Error: not enough memory + */ +SpeexResamplerState *speex_resampler_init_frac(spx_uint32_t nb_channels, + spx_uint32_t ratio_num, + spx_uint32_t ratio_den, + spx_uint32_t in_rate, + spx_uint32_t out_rate, + int quality, + int *err); + +/** Destroy a resampler state. + * @param st Resampler state + */ +void speex_resampler_destroy(SpeexResamplerState *st); + +/** Resample a float array. The input and output buffers must *not* overlap. + * @param st Resampler state + * @param channel_index Index of the channel to process for the multi-channel + * base (0 otherwise) + * @param in Input buffer + * @param in_len Number of input samples in the input buffer. Returns the + * number of samples processed + * @param out Output buffer + * @param out_len Size of the output buffer. Returns the number of samples written + */ +int speex_resampler_process_float(SpeexResamplerState *st, + spx_uint32_t channel_index, + const float *in, + spx_uint32_t *in_len, + float *out, + spx_uint32_t *out_len); + +/** Resample an int array. The input and output buffers must *not* overlap. + * @param st Resampler state + * @param channel_index Index of the channel to process for the multi-channel + * base (0 otherwise) + * @param in Input buffer + * @param in_len Number of input samples in the input buffer. Returns the number + * of samples processed + * @param out Output buffer + * @param out_len Size of the output buffer. Returns the number of samples written + */ +int speex_resampler_process_int(SpeexResamplerState *st, + spx_uint32_t channel_index, + const spx_int16_t *in, + spx_uint32_t *in_len, + spx_int16_t *out, + spx_uint32_t *out_len); + +/** Resample an interleaved float array. The input and output buffers must *not* overlap. + * @param st Resampler state + * @param in Input buffer + * @param in_len Number of input samples in the input buffer. Returns the number + * of samples processed. This is all per-channel. + * @param out Output buffer + * @param out_len Size of the output buffer. Returns the number of samples written. + * This is all per-channel. + */ +int speex_resampler_process_interleaved_float(SpeexResamplerState *st, + const float *in, + spx_uint32_t *in_len, + float *out, + spx_uint32_t *out_len); + +/** Resample an interleaved int array. The input and output buffers must *not* overlap. + * @param st Resampler state + * @param in Input buffer + * @param in_len Number of input samples in the input buffer. Returns the number + * of samples processed. This is all per-channel. + * @param out Output buffer + * @param out_len Size of the output buffer. Returns the number of samples written. + * This is all per-channel. + */ +int speex_resampler_process_interleaved_int(SpeexResamplerState *st, + const spx_int16_t *in, + spx_uint32_t *in_len, + spx_int16_t *out, + spx_uint32_t *out_len); + +/** Set (change) the input/output sampling rates (integer value). + * @param st Resampler state + * @param in_rate Input sampling rate (integer number of Hz). + * @param out_rate Output sampling rate (integer number of Hz). + */ +int speex_resampler_set_rate(SpeexResamplerState *st, + spx_uint32_t in_rate, + spx_uint32_t out_rate); + +/** Get the current input/output sampling rates (integer value). + * @param st Resampler state + * @param in_rate Input sampling rate (integer number of Hz) copied. + * @param out_rate Output sampling rate (integer number of Hz) copied. + */ +void speex_resampler_get_rate(SpeexResamplerState *st, + spx_uint32_t *in_rate, + spx_uint32_t *out_rate); + +/** Set (change) the input/output sampling rates and resampling ratio + * (fractional values in Hz supported). + * @param st Resampler state + * @param ratio_num Numerator of the sampling rate ratio + * @param ratio_den Denominator of the sampling rate ratio + * @param in_rate Input sampling rate rounded to the nearest integer (in Hz). + * @param out_rate Output sampling rate rounded to the nearest integer (in Hz). + */ +int speex_resampler_set_rate_frac(SpeexResamplerState *st, + spx_uint32_t ratio_num, + spx_uint32_t ratio_den, + spx_uint32_t in_rate, + spx_uint32_t out_rate); + +/** Get the current resampling ratio. This will be reduced to the least + * common denominator. + * @param st Resampler state + * @param ratio_num Numerator of the sampling rate ratio copied + * @param ratio_den Denominator of the sampling rate ratio copied + */ +void speex_resampler_get_ratio(SpeexResamplerState *st, + spx_uint32_t *ratio_num, + spx_uint32_t *ratio_den); + +/** Set (change) the conversion quality. + * @param st Resampler state + * @param quality Resampling quality between 0 and 10, where 0 has poor + * quality and 10 has very high quality. + */ +int speex_resampler_set_quality(SpeexResamplerState *st, + int quality); + +/** Get the conversion quality. + * @param st Resampler state + * @param quality Resampling quality between 0 and 10, where 0 has poor + * quality and 10 has very high quality. + */ +void speex_resampler_get_quality(SpeexResamplerState *st, + int *quality); + +/** Set (change) the input stride. + * @param st Resampler state + * @param stride Input stride + */ +void speex_resampler_set_input_stride(SpeexResamplerState *st, + spx_uint32_t stride); + +/** Get the input stride. + * @param st Resampler state + * @param stride Input stride copied + */ +void speex_resampler_get_input_stride(SpeexResamplerState *st, + spx_uint32_t *stride); + +/** Set (change) the output stride. + * @param st Resampler state + * @param stride Output stride + */ +void speex_resampler_set_output_stride(SpeexResamplerState *st, + spx_uint32_t stride); + +/** Get the output stride. + * @param st Resampler state copied + * @param stride Output stride + */ +void speex_resampler_get_output_stride(SpeexResamplerState *st, + spx_uint32_t *stride); + +/** Make sure that the first samples to go out of the resamplers don't have + * leading zeros. This is only useful before starting to use a newly created + * resampler. It is recommended to use that when resampling an audio file, as + * it will generate a file with the same length. For real-time processing, + * it is probably easier not to use this call (so that the output duration + * is the same for the first frame). + * @param st Resampler state + */ +int speex_resampler_skip_zeros(SpeexResamplerState *st); + +/** Reset a resampler so a new (unrelated) stream can be processed. + * @param st Resampler state + */ +int speex_resampler_reset_mem(SpeexResamplerState *st); + +/** Returns the English meaning for an error code + * @param err Error code + * @return English string + */ +const char *speex_resampler_strerror(int err); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/lib/rbcodec/codecs/libspeex/speex/speex_stereo.h b/lib/rbcodec/codecs/libspeex/speex/speex_stereo.h new file mode 100644 index 0000000000..67e2a8d4e0 --- /dev/null +++ b/lib/rbcodec/codecs/libspeex/speex/speex_stereo.h @@ -0,0 +1,91 @@ +/* Copyright (C) 2002 Jean-Marc Valin*/ +/** + @file speex_stereo.h + @brief Describes the handling for intensity stereo +*/ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + - Neither the name of the Xiph.org Foundation nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef STEREO_H +#define STEREO_H +/** @defgroup SpeexStereoState SpeexStereoState: Handling Speex stereo files + * This describes the Speex intensity stereo encoding/decoding + * @{ + */ + +#include "speex_types.h" +#include "speex_bits.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** If you access any of these fields directly, I'll personally come and bite you */ +typedef struct SpeexStereoState { + float balance; /**< Left/right balance info */ + float e_ratio; /**< Ratio of energies: E(left+right)/[E(left)+E(right)] */ + float smooth_left; /**< Smoothed left channel gain */ + float smooth_right; /**< Smoothed right channel gain */ + float reserved1; /**< Reserved for future use */ + float reserved2; /**< Reserved for future use */ +} SpeexStereoState; + +/** Deprecated. Use speex_stereo_state_init() instead. */ +#define SPEEX_STEREO_STATE_INIT {1,.5,1,1,0,0} + +/** Initialise/create a stereo stereo state */ +SpeexStereoState *speex_stereo_state_init(void); + +/** Reset/re-initialise an already allocated stereo state */ +void speex_stereo_state_reset(SpeexStereoState *stereo); + +/** Destroy a stereo stereo state */ +void speex_stereo_state_destroy(SpeexStereoState *stereo); + +/** Transforms a stereo frame into a mono frame and stores intensity stereo info in 'bits' */ +void speex_encode_stereo(float *data, int frame_size, SpeexBits *bits); + +/** Transforms a stereo frame into a mono frame and stores intensity stereo info in 'bits' */ +void speex_encode_stereo_int(spx_int16_t *data, int frame_size, SpeexBits *bits); + +/** Transforms a mono frame into a stereo frame using intensity stereo info */ +void speex_decode_stereo(float *data, int frame_size, SpeexStereoState *stereo); + +/** Transforms a mono frame into a stereo frame using intensity stereo info */ +void speex_decode_stereo_int(spx_int16_t *data, int frame_size, SpeexStereoState *stereo); + +/** Callback handler for intensity stereo info */ +int speex_std_stereo_request_handler(SpeexBits *bits, void *state, void *data); + +#ifdef __cplusplus +} +#endif + +/** @} */ +#endif diff --git a/lib/rbcodec/codecs/libspeex/speex/speex_types.h b/lib/rbcodec/codecs/libspeex/speex/speex_types.h new file mode 100644 index 0000000000..a2ff1d6b53 --- /dev/null +++ b/lib/rbcodec/codecs/libspeex/speex/speex_types.h @@ -0,0 +1,126 @@ +/* speex_types.h taken from libogg */ +/******************************************************************** + * * + * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * + * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * + * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * + * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * + * * + * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2002 * + * by the Xiph.Org Foundation http://www.xiph.org/ * + * * + ******************************************************************** + + function: #ifdef jail to whip a few platforms into the UNIX ideal. + last mod: $Id$ + + ********************************************************************/ +/** + @file speex_types.h + @brief Speex types +*/ +#ifndef _SPEEX_TYPES_H +#define _SPEEX_TYPES_H + +#if defined(_WIN32) + +# if defined(__CYGWIN__) +# include <_G_config.h> + typedef _G_int32_t spx_int32_t; + typedef _G_uint32_t spx_uint32_t; + typedef _G_int16_t spx_int16_t; + typedef _G_uint16_t spx_uint16_t; +# elif defined(__MINGW32__) + typedef short spx_int16_t; + typedef unsigned short spx_uint16_t; + typedef int spx_int32_t; + typedef unsigned int spx_uint32_t; +# elif defined(__MWERKS__) + typedef int spx_int32_t; + typedef unsigned int spx_uint32_t; + typedef short spx_int16_t; + typedef unsigned short spx_uint16_t; +# else + /* MSVC/Borland */ + typedef __int32 spx_int32_t; + typedef unsigned __int32 spx_uint32_t; + typedef __int16 spx_int16_t; + typedef unsigned __int16 spx_uint16_t; +# endif + +#elif defined(__MACOS__) + +# include + typedef SInt16 spx_int16_t; + typedef UInt16 spx_uint16_t; + typedef SInt32 spx_int32_t; + typedef UInt32 spx_uint32_t; + +#elif defined(__MACOSX__) /* MacOS X Framework build */ + +# include + typedef int16_t spx_int16_t; + typedef u_int16_t spx_uint16_t; + typedef int32_t spx_int32_t; + typedef u_int32_t spx_uint32_t; + +#elif defined(__BEOS__) + + /* Be */ +# include + typedef int16_t spx_int16_t; + typedef u_int16_t spx_uint16_t; + typedef int32_t spx_int32_t; + typedef u_int32_t spx_uint32_t; + +#elif defined (__EMX__) + + /* OS/2 GCC */ + typedef short spx_int16_t; + typedef unsigned short spx_uint16_t; + typedef int spx_int32_t; + typedef unsigned int spx_uint32_t; + +#elif defined (DJGPP) + + /* DJGPP */ + typedef short spx_int16_t; + typedef int spx_int32_t; + typedef unsigned int spx_uint32_t; + +#elif defined(R5900) + + /* PS2 EE */ + typedef int spx_int32_t; + typedef unsigned spx_uint32_t; + typedef short spx_int16_t; + +#elif defined(__SYMBIAN32__) + + /* Symbian GCC */ + typedef signed short spx_int16_t; + typedef unsigned short spx_uint16_t; + typedef signed int spx_int32_t; + typedef unsigned int spx_uint32_t; + +#elif defined(CONFIG_TI_C54X) || defined (CONFIG_TI_C55X) + + typedef short spx_int16_t; + typedef unsigned short spx_uint16_t; + typedef long spx_int32_t; + typedef unsigned long spx_uint32_t; + +#elif defined(CONFIG_TI_C6X) + + typedef short spx_int16_t; + typedef unsigned short spx_uint16_t; + typedef int spx_int32_t; + typedef unsigned int spx_uint32_t; + +#else + +# include "speex_config_types.h" + +#endif + +#endif /* _SPEEX_TYPES_H */ diff --git a/lib/rbcodec/codecs/libspeex/speex_callbacks.c b/lib/rbcodec/codecs/libspeex/speex_callbacks.c new file mode 100644 index 0000000000..f1de038488 --- /dev/null +++ b/lib/rbcodec/codecs/libspeex/speex_callbacks.c @@ -0,0 +1,160 @@ +/* Copyright (C) 2002 Jean-Marc Valin + File speex_callbacks.c + Callback handling and in-band signalling + + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + - Neither the name of the Xiph.org Foundation nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + +#ifdef HAVE_CONFIG_H +#include "config-speex.h" +#endif + +#include "speex/speex_callbacks.h" +#include "arch.h" +#include "os_support.h" + +int speex_inband_handler(SpeexBits *bits, SpeexCallback *callback_list, void *state) +{ + int id; + SpeexCallback *callback; + /*speex_bits_advance(bits, 5);*/ + id=speex_bits_unpack_unsigned(bits, 4); + callback = callback_list+id; + + if (callback->func) + { + return callback->func(bits, state, callback->data); + } else + /*If callback is not registered, skip the right number of bits*/ + { + int adv; + if (id<2) + adv = 1; + else if (id<8) + adv = 4; + else if (id<10) + adv = 8; + else if (id<12) + adv = 16; + else if (id<14) + adv = 32; + else + adv = 64; + speex_bits_advance(bits, adv); + } + return 0; +} + +#if 0 +/* Rockbox: unused */ +int speex_std_mode_request_handler(SpeexBits *bits, void *state, void *data) +{ + (void)state; + spx_int32_t m; + m = speex_bits_unpack_unsigned(bits, 4); + speex_encoder_ctl(data, SPEEX_SET_MODE, &m); + return 0; +} + +int speex_std_low_mode_request_handler(SpeexBits *bits, void *state, void *data) +{ + (void)state; + spx_int32_t m; + m = speex_bits_unpack_unsigned(bits, 4); + speex_encoder_ctl(data, SPEEX_SET_LOW_MODE, &m); + return 0; +} + +int speex_std_high_mode_request_handler(SpeexBits *bits, void *state, void *data) +{ + (void)state; + spx_int32_t m; + m = speex_bits_unpack_unsigned(bits, 4); + speex_encoder_ctl(data, SPEEX_SET_HIGH_MODE, &m); + return 0; +} +#endif + +#ifndef DISABLE_VBR +int speex_std_vbr_request_handler(SpeexBits *bits, void *state, void *data) +{ + (void)state; + spx_int32_t vbr; + vbr = speex_bits_unpack_unsigned(bits, 1); + speex_encoder_ctl(data, SPEEX_SET_VBR, &vbr); + return 0; +} +#endif /* #ifndef DISABLE_VBR */ + +#if 0 +/* Rockbox: unused */ +int speex_std_enh_request_handler(SpeexBits *bits, void *state, void *data) +{ + (void)state; + spx_int32_t enh; + enh = speex_bits_unpack_unsigned(bits, 1); + speex_decoder_ctl(data, SPEEX_SET_ENH, &enh); + return 0; +} +#endif + +#ifndef DISABLE_VBR +int speex_std_vbr_quality_request_handler(SpeexBits *bits, void *state, void *data) +{ + (void)state; + float qual; + qual = speex_bits_unpack_unsigned(bits, 4); + speex_encoder_ctl(data, SPEEX_SET_VBR_QUALITY, &qual); + return 0; +} +#endif /* #ifndef DISABLE_VBR */ + +#if 0 +/* Rockbox: unused */ +int speex_std_char_handler(SpeexBits *bits, void *state, void *data) +{ + (void)state; + unsigned char ch; + ch = speex_bits_unpack_unsigned(bits, 8); + _speex_putc(ch, data); + /*printf("speex_std_char_handler ch=%x\n", ch);*/ + return 0; +} +#endif + +/* Default handler for user callbacks: skip it */ +int speex_default_user_handler(SpeexBits *bits, void *state, void *data) +{ + (void)state; + (void)data; + int req_size = speex_bits_unpack_unsigned(bits, 4); + speex_bits_advance(bits, 5+8*req_size); + return 0; +} diff --git a/lib/rbcodec/codecs/libspeex/speex_header.c b/lib/rbcodec/codecs/libspeex/speex_header.c new file mode 100644 index 0000000000..b0e98b7c9c --- /dev/null +++ b/lib/rbcodec/codecs/libspeex/speex_header.c @@ -0,0 +1,188 @@ +/* Copyright (C) 2002 Jean-Marc Valin + File: speex_header.c + Describes the Speex header + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + - Neither the name of the Xiph.org Foundation nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + +#ifdef HAVE_CONFIG_H +#include "config-speex.h" +#endif + +#include "arch.h" +#include "speex/speex_header.h" +#include "speex/speex.h" +#include "os_support.h" + +#ifndef NULL +#define NULL 0 +#endif + +/** Convert little endian */ +static inline spx_int32_t le_int(spx_int32_t i) +{ +#ifdef ROCKBOX + return letoh32(i); +#elif !defined(__LITTLE_ENDIAN__) && ( defined(WORDS_BIGENDIAN) || defined(__BIG_ENDIAN__) ) + spx_uint32_t ui, ret; + ui = i; + ret = ui>>24; + ret |= (ui>>8)&0x0000ff00; + ret |= (ui<<8)&0x00ff0000; + ret |= (ui<<24); + return ret; +#else + return i; +#endif +} + +#define ENDIAN_SWITCH(x) {x=le_int(x);} + + +/* +typedef struct SpeexHeader { + char speex_string[8]; + char speex_version[SPEEX_HEADER_VERSION_LENGTH]; + int speex_version_id; + int header_size; + int rate; + int mode; + int mode_bitstream_version; + int nb_channels; + int bitrate; + int frame_size; + int vbr; + int frames_per_packet; + int extra_headers; + int reserved1; + int reserved2; +} SpeexHeader; +*/ + +#ifndef SPEEX_DISABLE_ENCODER +void speex_init_header(SpeexHeader *header, int rate, int nb_channels, const SpeexMode *m) +{ + int i; + const char *h="Speex "; + /* + strncpy(header->speex_string, "Speex ", 8); + strncpy(header->speex_version, SPEEX_VERSION, SPEEX_HEADER_VERSION_LENGTH-1); + header->speex_version[SPEEX_HEADER_VERSION_LENGTH-1]=0; + */ + for (i=0;i<8;i++) + header->speex_string[i]=h[i]; + for (i=0;ispeex_version[i]=SPEEX_VERSION[i]; + for (;ispeex_version[i]=0; + + header->speex_version_id = 1; + header->header_size = sizeof(SpeexHeader); + + header->rate = rate; + header->mode = m->modeID; + header->mode_bitstream_version = m->bitstream_version; + if (m->modeID<0) + speex_warning("This mode is meant to be used alone"); + header->nb_channels = nb_channels; + header->bitrate = -1; + speex_mode_query(m, SPEEX_MODE_FRAME_SIZE, &header->frame_size); + header->vbr = 0; + + header->frames_per_packet = 0; + header->extra_headers = 0; + header->reserved1 = 0; + header->reserved2 = 0; +} + +char *speex_header_to_packet(SpeexHeader *header, int *size) +{ + SpeexHeader *le_header; + le_header = (SpeexHeader*)speex_alloc(sizeof(SpeexHeader)); + + SPEEX_COPY(le_header, header, 1); + + /*Make sure everything is now little-endian*/ + ENDIAN_SWITCH(le_header->speex_version_id); + ENDIAN_SWITCH(le_header->header_size); + ENDIAN_SWITCH(le_header->rate); + ENDIAN_SWITCH(le_header->mode); + ENDIAN_SWITCH(le_header->mode_bitstream_version); + ENDIAN_SWITCH(le_header->nb_channels); + ENDIAN_SWITCH(le_header->bitrate); + ENDIAN_SWITCH(le_header->frame_size); + ENDIAN_SWITCH(le_header->vbr); + ENDIAN_SWITCH(le_header->frames_per_packet); + ENDIAN_SWITCH(le_header->extra_headers); + + *size = sizeof(SpeexHeader); + return (char *)le_header; +} +#endif /* SPEEX_DISABLE_ENCODER */ + +static SpeexHeader global_le_header; /* Avoid malloc */ +SpeexHeader *speex_packet_to_header(char *packet, int size) +{ + int i; + SpeexHeader *le_header = &global_le_header; + const char *h = "Speex "; + for (i=0;i<8;i++) + if (packet[i]!=h[i]) + { + speex_notify("This doesn't look like a Speex file"); + return NULL; + } + + /*FIXME: Do we allow larger headers?*/ + if (size < (int)sizeof(SpeexHeader)) + { + speex_notify("Speex header too small"); + return NULL; + } + + /* le_header = (SpeexHeader*)speex_alloc(sizeof(SpeexHeader)); */ + + SPEEX_COPY(le_header, (SpeexHeader*)packet, 1); + + /*Make sure everything is converted correctly from little-endian*/ + ENDIAN_SWITCH(le_header->speex_version_id); + ENDIAN_SWITCH(le_header->header_size); + ENDIAN_SWITCH(le_header->rate); + ENDIAN_SWITCH(le_header->mode); + ENDIAN_SWITCH(le_header->mode_bitstream_version); + ENDIAN_SWITCH(le_header->nb_channels); + ENDIAN_SWITCH(le_header->bitrate); + ENDIAN_SWITCH(le_header->frame_size); + ENDIAN_SWITCH(le_header->vbr); + ENDIAN_SWITCH(le_header->frames_per_packet); + ENDIAN_SWITCH(le_header->extra_headers); + + return le_header; + +} diff --git a/lib/rbcodec/codecs/libspeex/stack_alloc.h b/lib/rbcodec/codecs/libspeex/stack_alloc.h new file mode 100644 index 0000000000..f06f2f6f7f --- /dev/null +++ b/lib/rbcodec/codecs/libspeex/stack_alloc.h @@ -0,0 +1,130 @@ +/* Copyright (C) 2002 Jean-Marc Valin */ +/** + @file stack_alloc.h + @brief Temporary memory allocation on stack +*/ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + - Neither the name of the Xiph.org Foundation nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef STACK_ALLOC_H +#define STACK_ALLOC_H + +#include "config-speex.h" + +#ifdef USE_ALLOCA +# ifdef WIN32 +# include +# else +# ifdef HAVE_ALLOCA_H +# include +# else +# include +# endif +# endif +#endif + +/** + * @def ALIGN(stack, size) + * + * Aligns the stack to a 'size' boundary + * + * @param stack Stack + * @param size New size boundary + */ + +/** + * @def PUSH(stack, size, type) + * + * Allocates 'size' elements of type 'type' on the stack + * + * @param stack Stack + * @param size Number of elements + * @param type Type of element + */ + +/** + * @def PUSHS(stack, type) + * + * Allocates a struct stack + * + * @param stack Stack + * @param type Struct type + */ + +/** + * @def VARDECL(var) + * + * Declare variable on stack + * + * @param var Variable to declare + */ + +/** + * @def ALLOC(var, size, type) + * + * Allocate 'size' elements of 'type' on stack + * + * @param var Name of variable to allocate + * @param size Number of elements + * @param type Type of element + */ + +#ifdef ENABLE_VALGRIND + +#include + +#define ALIGN(stack, size) ((stack) += ((size) - (long)(stack)) & ((size) - 1)) + +#define PUSH(stack, size, type) (VALGRIND_MAKE_NOACCESS(stack, 1000),ALIGN((stack),sizeof(type)),VALGRIND_MAKE_WRITABLE(stack, ((size)*sizeof(type))),(stack)+=((size)*sizeof(type)),(type*)((stack)-((size)*sizeof(type)))) + +#define PUSHS(stack, type) (VALGRIND_MAKE_NOACCESS(stack, 1000),ALIGN((stack),sizeof(long)),VALGRIND_MAKE_WRITABLE(stack, (sizeof(type))),(stack)+=(sizeof(type)),(type*)((stack)-(sizeof(type)))) + +#else + +#define ALIGN(stack, size) ((stack) += ((size) - (long)(stack)) & ((size) - 1)) + +#define PUSH(stack, size, type) (ALIGN((stack),sizeof(type)),(stack)+=((size)*sizeof(type)),(type*)((stack)-((size)*sizeof(type)))) + +#define PUSHS(stack, type) (ALIGN((stack),sizeof(long)),(stack)+=(sizeof(type)),(type*)((stack)-(sizeof(type)))) + +#endif + +#if defined(VAR_ARRAYS) +#define VARDECL(var) +#define ALLOC(var, size, type) type var[size] +#elif defined(USE_ALLOCA) +#define VARDECL(var) var +#define ALLOC(var, size, type) var = alloca(sizeof(type)*(size)) +#else +#define VARDECL(var) var +#define ALLOC(var, size, type) var = PUSH(stack, size, type) +#endif + + +#endif diff --git a/lib/rbcodec/codecs/libspeex/stereo.c b/lib/rbcodec/codecs/libspeex/stereo.c new file mode 100644 index 0000000000..652d2a6e90 --- /dev/null +++ b/lib/rbcodec/codecs/libspeex/stereo.c @@ -0,0 +1,302 @@ +/* Copyright (C) 2002 Jean-Marc Valin + File: stereo.c + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + - Neither the name of the Xiph.org Foundation nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifdef HAVE_CONFIG_H +#include "config-speex.h" +#endif + +#include "speex/speex_stereo.h" +#include "speex/speex_callbacks.h" +#include "math_approx.h" +#include "vq.h" +#include +#include "os_support.h" + +typedef struct RealSpeexStereoState { + spx_word32_t balance; /**< Left/right balance info */ + spx_word32_t e_ratio; /**< Ratio of energies: E(left+right)/[E(left)+E(right)] */ + spx_word32_t smooth_left; /**< Smoothed left channel gain */ + spx_word32_t smooth_right; /**< Smoothed right channel gain */ + spx_uint32_t reserved1; /**< Reserved for future use */ + spx_int32_t reserved2; /**< Reserved for future use */ +} RealSpeexStereoState; + + +/*float e_ratio_quant[4] = {1, 1.26, 1.587, 2};*/ +#ifndef FIXED_POINT +static const float e_ratio_quant[4] = {.25f, .315f, .397f, .5f}; +static const float e_ratio_quant_bounds[3] = {0.2825f, 0.356f, 0.4485f}; +#else +static const spx_word16_t e_ratio_quant[4] = {8192, 10332, 13009, 16384}; +static const spx_word16_t e_ratio_quant_bounds[3] = {9257, 11665, 14696}; +static const spx_word16_t balance_bounds[31] = {18, 23, 30, 38, 49, 63, 81, 104, + 134, 172, 221, 284, 364, 468, 600, 771, + 990, 1271, 1632, 2096, 2691, 3455, 4436, 5696, + 7314, 9392, 12059, 15484, 19882, 25529, 32766}; +#endif + +/* This is an ugly compatibility hack that properly resets the stereo state + In case it it compiled in fixed-point, but initialised with the deprecated + floating point static initialiser */ +#ifdef FIXED_POINT +#define COMPATIBILITY_HACK(s) do {if ((s)->reserved1 != 0xdeadbeef) speex_stereo_state_reset((SpeexStereoState*)s); } while (0); +#else +#define COMPATIBILITY_HACK(s) +#endif + +static SpeexStereoState global_stereo_state; +SpeexStereoState *speex_stereo_state_init() +{ + /* SpeexStereoState *stereo = speex_alloc(sizeof(SpeexStereoState)); */ + SpeexStereoState *stereo = &global_stereo_state; + speex_stereo_state_reset(stereo); + return stereo; +} + +void speex_stereo_state_reset(SpeexStereoState *_stereo) +{ + RealSpeexStereoState *stereo = (RealSpeexStereoState*)_stereo; +#ifdef FIXED_POINT + stereo->balance = 65536; + stereo->e_ratio = 16384; + stereo->smooth_left = 16384; + stereo->smooth_right = 16384; + stereo->reserved1 = 0xdeadbeef; + stereo->reserved2 = 0; +#else + stereo->balance = 1.0f; + stereo->e_ratio = .5f; + stereo->smooth_left = 1.f; + stereo->smooth_right = 1.f; + stereo->reserved1 = 0; + stereo->reserved2 = 0; +#endif +} + +void speex_stereo_state_destroy(SpeexStereoState *stereo) +{ + (void)stereo; + /* speex_free(stereo); */ +} + +#ifndef SPEEX_DISABLE_ENCODER +#ifndef DISABLE_FLOAT_API +void speex_encode_stereo(float *data, int frame_size, SpeexBits *bits) +{ + int i, tmp; + float e_left=0, e_right=0, e_tot=0; + float balance, e_ratio; + for (i=0;i0) + speex_bits_pack(bits, 0, 1); + else + speex_bits_pack(bits, 1, 1); + balance=floor(.5+fabs(balance)); + if (balance>30) + balance=31; + + speex_bits_pack(bits, (int)balance, 5); + + /* FIXME: this is a hack */ + tmp=scal_quant(e_ratio*Q15_ONE, e_ratio_quant_bounds, 4); + speex_bits_pack(bits, tmp, 2); +} +#endif /* #ifndef DISABLE_FLOAT_API */ + +void speex_encode_stereo_int(spx_int16_t *data, int frame_size, SpeexBits *bits) +{ + int i, tmp; + spx_word32_t e_left=0, e_right=0, e_tot=0; + spx_word32_t balance, e_ratio; + spx_word32_t largest, smallest; + int balance_id; +#ifdef FIXED_POINT + int shift; +#endif + + /* In band marker */ + speex_bits_pack(bits, 14, 5); + /* Stereo marker */ + speex_bits_pack(bits, SPEEX_INBAND_STEREO, 4); + + for (i=0;i e_right) + { + speex_bits_pack(bits, 0, 1); + largest = e_left; + smallest = e_right; + } else { + speex_bits_pack(bits, 1, 1); + largest = e_right; + smallest = e_left; + } + + /* Balance quantization */ +#ifdef FIXED_POINT + shift = spx_ilog2(largest)-15; + largest = VSHR32(largest, shift-4); + smallest = VSHR32(smallest, shift); + balance = DIV32(largest, ADD32(smallest, 1)); + if (balance > 32767) + balance = 32767; + balance_id = scal_quant(EXTRACT16(balance), balance_bounds, 32); +#else + balance=(largest+1.)/(smallest+1.); + balance=4*log(balance); + balance_id=floor(.5+fabs(balance)); + if (balance_id>30) + balance_id=31; +#endif + + speex_bits_pack(bits, balance_id, 5); + + /* "coherence" quantisation */ +#ifdef FIXED_POINT + shift = spx_ilog2(e_tot); + e_tot = VSHR32(e_tot, shift-25); + e_left = VSHR32(e_left, shift-10); + e_right = VSHR32(e_right, shift-10); + e_ratio = DIV32(e_tot, e_left+e_right+1); +#else + e_ratio = e_tot/(1.+e_left+e_right); +#endif + + tmp=scal_quant(EXTRACT16(e_ratio), e_ratio_quant_bounds, 4); + /*fprintf (stderr, "%d %d %d %d\n", largest, smallest, balance_id, e_ratio);*/ + speex_bits_pack(bits, tmp, 2); +} +#endif /* SPEEX_DISABLE_ENCODER */ + +#ifndef DISABLE_FLOAT_API +void speex_decode_stereo(float *data, int frame_size, SpeexStereoState *_stereo) +{ + int i; + spx_word32_t balance; + spx_word16_t e_left, e_right, e_ratio; + RealSpeexStereoState *stereo = (RealSpeexStereoState*)_stereo; + + COMPATIBILITY_HACK(stereo); + + balance=stereo->balance; + e_ratio=stereo->e_ratio; + + /* These two are Q14, with max value just below 2. */ + e_right = DIV32(QCONST32(1., 22), spx_sqrt(MULT16_32_Q15(e_ratio, ADD32(QCONST32(1., 16), balance)))); + e_left = SHR32(MULT16_16(spx_sqrt(balance), e_right), 8); + + for (i=frame_size-1;i>=0;i--) + { + spx_word16_t tmp=data[i]; + stereo->smooth_left = EXTRACT16(PSHR32(MAC16_16(MULT16_16(stereo->smooth_left, QCONST16(0.98, 15)), e_left, QCONST16(0.02, 15)), 15)); + stereo->smooth_right = EXTRACT16(PSHR32(MAC16_16(MULT16_16(stereo->smooth_right, QCONST16(0.98, 15)), e_right, QCONST16(0.02, 15)), 15)); + data[2*i] = (float)MULT16_16_P14(stereo->smooth_left, tmp); + data[2*i+1] = (float)MULT16_16_P14(stereo->smooth_right, tmp); + } +} +#endif /* #ifndef DISABLE_FLOAT_API */ + +void speex_decode_stereo_int(spx_int16_t *data, int frame_size, SpeexStereoState *_stereo) +{ + int i; + spx_word32_t balance; + spx_word16_t e_left, e_right, e_ratio; + RealSpeexStereoState *stereo = (RealSpeexStereoState*)_stereo; + + /* COMPATIBILITY_HACK(stereo); */ + + balance=stereo->balance; + e_ratio=stereo->e_ratio; + + /* These two are Q14, with max value just below 2. */ + e_right = DIV32(QCONST32(1., 22), spx_sqrt(MULT16_32_Q15(e_ratio, ADD32(QCONST32(1., 16), balance)))); + e_left = SHR32(MULT16_16(spx_sqrt(balance), e_right), 8); + + for (i=frame_size-1;i>=0;i--) + { + spx_int16_t tmp=data[i]; + stereo->smooth_left = EXTRACT16(PSHR32(MAC16_16(MULT16_16(stereo->smooth_left, QCONST16(0.98, 15)), e_left, QCONST16(0.02, 15)), 15)); + stereo->smooth_right = EXTRACT16(PSHR32(MAC16_16(MULT16_16(stereo->smooth_right, QCONST16(0.98, 15)), e_right, QCONST16(0.02, 15)), 15)); + data[2*i] = (spx_int16_t)MULT16_16_P14(stereo->smooth_left, tmp); + data[2*i+1] = (spx_int16_t)MULT16_16_P14(stereo->smooth_right, tmp); + } +} + +int speex_std_stereo_request_handler(SpeexBits *bits, void *state, void *data) +{ + (void)state; + RealSpeexStereoState *stereo; + spx_word16_t sign=1, dexp; + int tmp; + + stereo = (RealSpeexStereoState*)data; + + /* COMPATIBILITY_HACK(stereo); */ + + if (speex_bits_unpack_unsigned(bits, 1)) + sign=-1; + dexp = speex_bits_unpack_unsigned(bits, 5); +#ifndef FIXED_POINT + stereo->balance = exp(sign*.25*dexp); +#else + stereo->balance = spx_exp(MULT16_16(sign, SHL16(dexp, 9))); +#endif + tmp = speex_bits_unpack_unsigned(bits, 2); + stereo->e_ratio = e_ratio_quant[tmp]; + + return 0; +} diff --git a/lib/rbcodec/codecs/libspeex/vbr.c b/lib/rbcodec/codecs/libspeex/vbr.c new file mode 100644 index 0000000000..32b33bc10e --- /dev/null +++ b/lib/rbcodec/codecs/libspeex/vbr.c @@ -0,0 +1,275 @@ +/* Copyright (C) 2002 Jean-Marc Valin + File: vbr.c + + VBR-related routines + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + - Neither the name of the Xiph.org Foundation nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + +#ifdef HAVE_CONFIG_H +#include "config-speex.h" +#endif + +#include "vbr.h" +#include + + +#define sqr(x) ((x)*(x)) + +#define MIN_ENERGY 6000 +#define NOISE_POW .3 + +#ifndef DISABLE_VBR + +const float vbr_nb_thresh[9][11]={ + {-1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f}, /* CNG */ + { 4.0f, 2.5f, 2.0f, 1.2f, 0.5f, 0.0f, -0.5f, -0.7f, -0.8f, -0.9f, -1.0f}, /* 2 kbps */ + {10.0f, 6.5f, 5.2f, 4.5f, 3.9f, 3.5f, 3.0f, 2.5f, 2.3f, 1.8f, 1.0f}, /* 6 kbps */ + {11.0f, 8.8f, 7.5f, 6.5f, 5.0f, 3.9f, 3.9f, 3.9f, 3.5f, 3.0f, 1.0f}, /* 8 kbps */ + {11.0f, 11.0f, 9.9f, 8.5f, 7.0f, 6.0f, 4.5f, 4.0f, 4.0f, 4.0f, 2.0f}, /* 11 kbps */ + {11.0f, 11.0f, 11.0f, 11.0f, 9.5f, 8.5f, 8.0f, 7.0f, 6.0f, 5.0f, 3.0f}, /* 15 kbps */ + {11.0f, 11.0f, 11.0f, 11.0f, 11.0f, 11.0f, 9.5f, 8.5f, 7.0f, 6.0f, 5.0f}, /* 18 kbps */ + {11.0f, 11.0f, 11.0f, 11.0f, 11.0f, 11.0f, 11.0f, 11.0f, 9.8f, 9.5f, 7.5f}, /* 24 kbps */ + { 7.0f, 4.5f, 3.7f, 3.0f, 2.5f, 2.0f, 1.8f, 1.5f, 1.0f, 0.0f, 0.0f} /* 4 kbps */ +}; + + +const float vbr_hb_thresh[5][11]={ + {-1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f}, /* silence */ + {-1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f}, /* 2 kbps */ + {11.0f, 11.0f, 9.5f, 8.5f, 7.5f, 6.0f, 5.0f, 3.9f, 3.0f, 2.0f, 1.0f}, /* 6 kbps */ + {11.0f, 11.0f, 11.0f, 11.0f, 11.0f, 9.5f, 8.7f, 7.8f, 7.0f, 6.5f, 4.0f}, /* 10 kbps */ + {11.0f, 11.0f, 11.0f, 11.0f, 11.0f, 11.0f, 11.0f, 11.0f, 9.8f, 7.5f, 5.5f} /* 18 kbps */ +}; + +const float vbr_uhb_thresh[2][11]={ + {-1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f}, /* silence */ + { 3.9f, 2.5f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, -1.0f} /* 2 kbps */ +}; + +void vbr_init(VBRState *vbr) +{ + int i; + + vbr->average_energy=0; + vbr->last_energy=1; + vbr->accum_sum=0; + vbr->energy_alpha=.1; + vbr->soft_pitch=0; + vbr->last_pitch_coef=0; + vbr->last_quality=0; + + vbr->noise_accum = .05*pow(MIN_ENERGY, NOISE_POW); + vbr->noise_accum_count=.05; + vbr->noise_level=vbr->noise_accum/vbr->noise_accum_count; + vbr->consec_noise=0; + + + for (i=0;ilast_log_energy[i] = log(MIN_ENERGY); +} + + +/* + This function should analyse the signal and decide how critical the + coding error will be perceptually. The following factors should be + taken into account: + + -Attacks (positive energy derivative) should be coded with more bits + + -Stationary voiced segments should receive more bits + + -Segments with (very) low absolute energy should receive less bits (maybe + only shaped noise?) + + -DTX for near-zero energy? + + -Stationary fricative segments should have less bits + + -Temporal masking: when energy slope is decreasing, decrease the bit-rate + + -Decrease bit-rate for males (low pitch)? + + -(wideband only) less bits in the high-band when signal is very + non-stationary (harder to notice high-frequency noise)??? + +*/ + +float vbr_analysis(VBRState *vbr, spx_word16_t *sig, int len, int pitch, float pitch_coef) +{ + int i; + float ener=0, ener1=0, ener2=0; + float qual=7; + int va; + float log_energy; + float non_st=0; + float voicing; + float pow_ener; + + for (i=0;i>1;i++) + ener1 += ((float)sig[i])*sig[i]; + + for (i=len>>1;ilast_log_energy[i]); + non_st = non_st/(30*VBR_MEMORY_SIZE); + if (non_st>1) + non_st=1; + + voicing = 3*(pitch_coef-.4)*fabs(pitch_coef-.4); + vbr->average_energy = (1-vbr->energy_alpha)*vbr->average_energy + vbr->energy_alpha*ener; + vbr->noise_level=vbr->noise_accum/vbr->noise_accum_count; + pow_ener = pow(ener,NOISE_POW); + if (vbr->noise_accum_count<.06 && ener>MIN_ENERGY) + vbr->noise_accum = .05*pow_ener; + + if ((voicing<.3 && non_st < .2 && pow_ener < 1.2*vbr->noise_level) + || (voicing<.3 && non_st < .05 && pow_ener < 1.5*vbr->noise_level) + || (voicing<.4 && non_st < .05 && pow_ener < 1.2*vbr->noise_level) + || (voicing<0 && non_st < .05)) + { + float tmp; + va = 0; + vbr->consec_noise++; + if (pow_ener > 3*vbr->noise_level) + tmp = 3*vbr->noise_level; + else + tmp = pow_ener; + if (vbr->consec_noise>=4) + { + vbr->noise_accum = .95*vbr->noise_accum + .05*tmp; + vbr->noise_accum_count = .95*vbr->noise_accum_count + .05; + } + } else { + va = 1; + vbr->consec_noise=0; + } + + if (pow_ener < vbr->noise_level && ener>MIN_ENERGY) + { + vbr->noise_accum = .95*vbr->noise_accum + .05*pow_ener; + vbr->noise_accum_count = .95*vbr->noise_accum_count + .05; + } + + /* Checking for very low absolute energy */ + if (ener < 30000) + { + qual -= .7; + if (ener < 10000) + qual-=.7; + if (ener < 3000) + qual-=.7; + } else { + float short_diff, long_diff; + short_diff = log((ener+1)/(1+vbr->last_energy)); + long_diff = log((ener+1)/(1+vbr->average_energy)); + /*fprintf (stderr, "%f %f\n", short_diff, long_diff);*/ + + if (long_diff<-5) + long_diff=-5; + if (long_diff>2) + long_diff=2; + + if (long_diff>0) + qual += .6*long_diff; + if (long_diff<0) + qual += .5*long_diff; + if (short_diff>0) + { + if (short_diff>5) + short_diff=5; + qual += .5*short_diff; + } + /* Checking for energy increases */ + if (ener2 > 1.6*ener1) + qual += .5; + } + vbr->last_energy = ener; + vbr->soft_pitch = .6*vbr->soft_pitch + .4*pitch_coef; + qual += 2.2*((pitch_coef-.4) + (vbr->soft_pitch-.4)); + + if (qual < vbr->last_quality) + qual = .5*qual + .5*vbr->last_quality; + if (qual<4) + qual=4; + if (qual>10) + qual=10; + + /* + if (vbr->consec_noise>=2) + qual-=1.3; + if (vbr->consec_noise>=5) + qual-=1.3; + if (vbr->consec_noise>=12) + qual-=1.3; + */ + if (vbr->consec_noise>=3) + qual=4; + + if (vbr->consec_noise) + qual -= 1.0 * (log(3.0 + vbr->consec_noise)-log(3)); + if (qual<0) + qual=0; + + if (ener<60000) + { + if (vbr->consec_noise>2) + qual-=0.5*(log(3.0 + vbr->consec_noise)-log(3)); + if (ener<10000&&vbr->consec_noise>2) + qual-=0.5*(log(3.0 + vbr->consec_noise)-log(3)); + if (qual<0) + qual=0; + qual += .3*log(.0001+ener/60000.0); + } + if (qual<-1) + qual=-1; + + /*printf ("%f %f %f %f %d\n", qual, voicing, non_st, pow_ener/(.01+vbr->noise_level), va);*/ + + vbr->last_pitch_coef = pitch_coef; + vbr->last_quality = qual; + + for (i=VBR_MEMORY_SIZE-1;i>0;i--) + vbr->last_log_energy[i] = vbr->last_log_energy[i-1]; + vbr->last_log_energy[0] = log_energy; + + /*printf ("VBR: %f %f %f %d %f\n", (float)(log_energy-log(vbr->average_energy+MIN_ENERGY)), non_st, voicing, va, vbr->noise_level);*/ + + return qual; +} + +void vbr_destroy(VBRState *vbr) +{ +} + +#endif /* #ifndef DISABLE_VBR */ diff --git a/lib/rbcodec/codecs/libspeex/vbr.h b/lib/rbcodec/codecs/libspeex/vbr.h new file mode 100644 index 0000000000..ff1e3e46f2 --- /dev/null +++ b/lib/rbcodec/codecs/libspeex/vbr.h @@ -0,0 +1,70 @@ +/* Copyright (C) 2002 Jean-Marc Valin */ +/** + @file vbr.h + @brief Variable Bit-Rate (VBR) related routines +*/ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + - Neither the name of the Xiph.org Foundation nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + + +#ifndef VBR_H +#define VBR_H + +#include "arch.h" + +#define VBR_MEMORY_SIZE 5 + +extern const float vbr_nb_thresh[9][11]; +extern const float vbr_hb_thresh[5][11]; +extern const float vbr_uhb_thresh[2][11]; + +/** VBR state. */ +typedef struct VBRState { + float energy_alpha; + float average_energy; + float last_energy; + float last_log_energy[VBR_MEMORY_SIZE]; + float accum_sum; + float last_pitch_coef; + float soft_pitch; + float last_quality; + float noise_level; + float noise_accum; + float noise_accum_count; + int consec_noise; +} VBRState; + +void vbr_init(VBRState *vbr); + +float vbr_analysis(VBRState *vbr, spx_word16_t *sig, int len, int pitch, float pitch_coef); + +void vbr_destroy(VBRState *vbr); + +#endif diff --git a/lib/rbcodec/codecs/libspeex/vorbis_psy.c b/lib/rbcodec/codecs/libspeex/vorbis_psy.c new file mode 100644 index 0000000000..2032bf63e2 --- /dev/null +++ b/lib/rbcodec/codecs/libspeex/vorbis_psy.c @@ -0,0 +1,508 @@ +/* Copyright (C) 2005 Jean-Marc Valin, CSIRO, Christopher Montgomery + File: vorbis_psy.c + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + - Neither the name of the Xiph.org Foundation nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifdef HAVE_CONFIG_H +#include "config-speex.h" +#endif + +#ifdef VORBIS_PSYCHO + +#include "arch.h" +#include "smallft.h" +#include "lpc.h" +#include "vorbis_psy.h" + +#include +#include +#include + +/* psychoacoustic setup ********************************************/ + +static VorbisPsyInfo example_tuning = { + + .5,.5, + 3,3,25, + + /*63 125 250 500 1k 2k 4k 8k 16k*/ + // vorbis mode 4 style + //{-32,-32,-32,-32,-28,-24,-22,-20,-20, -20, -20, -8, -6, -6, -6, -6, -6}, + { -4, -6, -6, -6, -6, -6, -6, -6, -8, -8,-10,-10, -8, -6, -4, -4, -2}, + + { + 0, 1, 2, 3, 4, 5, 5, 5, /* 7dB */ + 6, 6, 6, 5, 4, 4, 4, 4, /* 15dB */ + 4, 4, 5, 5, 5, 6, 6, 6, /* 23dB */ + 7, 7, 7, 8, 8, 8, 9, 10, /* 31dB */ + 11,12,13,14,15,16,17, 18, /* 39dB */ + } + +}; + + + +/* there was no great place to put this.... */ +#include +static void _analysis_output(char *base,int i,float *v,int n,int bark,int dB){ + int j; + FILE *of; + char buffer[80]; + + sprintf(buffer,"%s_%d.m",base,i); + of=fopen(buffer,"w"); + + if(!of)perror("failed to open data dump file"); + + for(j=0;j> 16; + if( lo>=0 ) break; + hi = b[i] & 0xffff; + + tN = N[hi] + N[-lo]; + tX = X[hi] - X[-lo]; + tXX = XX[hi] + XX[-lo]; + tY = Y[hi] + Y[-lo]; + tXY = XY[hi] - XY[-lo]; + + A = tY * tXX - tX * tXY; + B = tN * tXY - tX * tY; + D = tN * tXX - tX * tX; + R = (A + x * B) / D; + if (R < 0.f) + R = 0.f; + + noise[i] = R - offset; + } + + for ( ;; i++, x += 1.f) { + + lo = b[i] >> 16; + hi = b[i] & 0xffff; + if(hi>=n)break; + + tN = N[hi] - N[lo]; + tX = X[hi] - X[lo]; + tXX = XX[hi] - XX[lo]; + tY = Y[hi] - Y[lo]; + tXY = XY[hi] - XY[lo]; + + A = tY * tXX - tX * tXY; + B = tN * tXY - tX * tY; + D = tN * tXX - tX * tX; + R = (A + x * B) / D; + if (R < 0.f) R = 0.f; + + noise[i] = R - offset; + } + for ( ; i < n; i++, x += 1.f) { + + R = (A + x * B) / D; + if (R < 0.f) R = 0.f; + + noise[i] = R - offset; + } + + if (fixed <= 0) return; + + for (i = 0, x = 0.f;; i++, x += 1.f) { + hi = i + fixed / 2; + lo = hi - fixed; + if(lo>=0)break; + + tN = N[hi] + N[-lo]; + tX = X[hi] - X[-lo]; + tXX = XX[hi] + XX[-lo]; + tY = Y[hi] + Y[-lo]; + tXY = XY[hi] - XY[-lo]; + + + A = tY * tXX - tX * tXY; + B = tN * tXY - tX * tY; + D = tN * tXX - tX * tX; + R = (A + x * B) / D; + + if (R - offset < noise[i]) noise[i] = R - offset; + } + for ( ;; i++, x += 1.f) { + + hi = i + fixed / 2; + lo = hi - fixed; + if(hi>=n)break; + + tN = N[hi] - N[lo]; + tX = X[hi] - X[lo]; + tXX = XX[hi] - XX[lo]; + tY = Y[hi] - Y[lo]; + tXY = XY[hi] - XY[lo]; + + A = tY * tXX - tX * tXY; + B = tN * tXY - tX * tY; + D = tN * tXX - tX * tX; + R = (A + x * B) / D; + + if (R - offset < noise[i]) noise[i] = R - offset; + } + for ( ; i < n; i++, x += 1.f) { + R = (A + x * B) / D; + if (R - offset < noise[i]) noise[i] = R - offset; + } +} + +static void _vp_noisemask(VorbisPsy *p, + float *logfreq, + float *logmask){ + + int i,n=p->n/2; + float *work=alloca(n*sizeof(*work)); + + bark_noise_hybridmp(n,p->bark,logfreq,logmask, + 140.,-1); + + for(i=0;ibark,work,logmask,0., + p->vi->noisewindowfixed); + + for(i=0;i=NOISE_COMPAND_LEVELS)dB=NOISE_COMPAND_LEVELS-1; + if(dB<0)dB=0; + logmask[i]= work[i]+p->vi->noisecompand[dB]+p->noiseoffset[i]; + } + +} + +VorbisPsy *vorbis_psy_init(int rate, int n) +{ + long i,j,lo=-99,hi=1; + VorbisPsy *p = speex_alloc(sizeof(VorbisPsy)); + memset(p,0,sizeof(*p)); + + p->n = n; + spx_drft_init(&p->lookup, n); + p->bark = speex_alloc(n*sizeof(*p->bark)); + p->rate=rate; + p->vi = &example_tuning; + + /* BH4 window */ + p->window = speex_alloc(sizeof(*p->window)*n); + float a0 = .35875f; + float a1 = .48829f; + float a2 = .14128f; + float a3 = .01168f; + for(i=0;iwindow[i] = //a0 - a1*cos(2.*M_PI/n*(i+.5)) + a2*cos(4.*M_PI/n*(i+.5)) - a3*cos(6.*M_PI/n*(i+.5)); + sin((i+.5)/n * M_PI)*sin((i+.5)/n * M_PI); + /* bark scale lookups */ + for(i=0;ivi->noisewindowlominvi->noisewindowlo);lo++); + + for(;hi<=n && (hivi->noisewindowhimin || + toBARK(rate/(2*n)*hi)<(bark+p->vi->noisewindowhi));hi++); + + p->bark[i]=((lo-1)<<16)+(hi-1); + + } + + /* set up rolling noise median */ + p->noiseoffset=speex_alloc(n*sizeof(*p->noiseoffset)); + + for(i=0;i=P_BANDS-1)halfoc=P_BANDS-1; + inthalfoc=(int)halfoc; + del=halfoc-inthalfoc; + + p->noiseoffset[i]= + p->vi->noiseoff[inthalfoc]*(1.-del) + + p->vi->noiseoff[inthalfoc+1]*del; + + } +#if 0 + _analysis_output_always("noiseoff0",ls,p->noiseoffset,n,1,0,0); +#endif + + return p; +} + +void vorbis_psy_destroy(VorbisPsy *p) +{ + if(p){ + spx_drft_clear(&p->lookup); + if(p->bark) + speex_free(p->bark); + if(p->noiseoffset) + speex_free(p->noiseoffset); + if(p->window) + speex_free(p->window); + memset(p,0,sizeof(*p)); + speex_free(p); + } +} + +void compute_curve(VorbisPsy *psy, float *audio, float *curve) +{ + int i; + float work[psy->n]; + + float scale=4.f/psy->n; + float scale_dB; + + scale_dB=todB(scale); + + /* window the PCM data; use a BH4 window, not vorbis */ + for(i=0;in;i++) + work[i]=audio[i] * psy->window[i]; + + { + static int seq=0; + + //_analysis_output("win",seq,work,psy->n,0,0); + + seq++; + } + + /* FFT yields more accurate tonal estimation (not phase sensitive) */ + spx_drft_forward(&psy->lookup,work); + + /* magnitudes */ + work[0]=scale_dB+todB(work[0]); + for(i=1;in-1;i+=2){ + float temp = work[i]*work[i] + work[i+1]*work[i+1]; + work[(i+1)>>1] = scale_dB+.5f * todB(temp); + } + + /* derive a noise curve */ + _vp_noisemask(psy,work,curve); +#define SIDEL 12 + for (i=0;in>>1)-i-1]=curve[(psy->n>>1)-SIDEH]; + } + for(i=0;i<((psy->n)>>1);i++) + curve[i] = fromdB(1.2*curve[i]+.2*i); + //curve[i] = fromdB(0.8*curve[i]+.35*i); + //curve[i] = fromdB(0.9*curve[i])*pow(1.0*i+45,1.3); +} + +/* Transform a masking curve (power spectrum) into a pole-zero filter */ +void curve_to_lpc(VorbisPsy *psy, float *curve, float *awk1, float *awk2, int ord) +{ + int i; + float ac[psy->n]; + float tmp; + int len = psy->n >> 1; + for (i=0;i<2*len;i++) + ac[i] = 0; + for (i=1;ilookup, ac); + _spx_lpc(awk1, ac, ord); + tmp = 1.; + for (i=0;ilookup, ac); + /* Compute (power) response of awk1 (all zero) */ + ac[0] *= ac[0]; + for (i=1;ilookup, ac); + _spx_lpc(awk2, ac, ord); + tmp = 1; + for (i=0;i +#include + +#define ORDER 10 +#define CURVE_SIZE 24 + +int main() +{ + int i; + float curve[CURVE_SIZE]; + float awk1[ORDER], awk2[ORDER]; + for (i=0;i1e-13?log((x)*(x))*4.34294480f:-30) +#define fromdB(x) (exp((x)*.11512925f)) + +/* The bark scale equations are approximations, since the original + table was somewhat hand rolled. The below are chosen to have the + best possible fit to the rolled tables, thus their somewhat odd + appearance (these are more accurate and over a longer range than + the oft-quoted bark equations found in the texts I have). The + approximations are valid from 0 - 30kHz (nyquist) or so. + + all f in Hz, z in Bark */ + +#define toBARK(n) (13.1f*atan(.00074f*(n))+2.24f*atan((n)*(n)*1.85e-8f)+1e-4f*(n)) +#define fromBARK(z) (102.f*(z)-2.f*pow(z,2.f)+.4f*pow(z,3.f)+pow(1.46f,z)-1.f) + +/* Frequency to octave. We arbitrarily declare 63.5 Hz to be octave + 0.0 */ + +#define toOC(n) (log(n)*1.442695f-5.965784f) +#define fromOC(o) (exp(((o)+5.965784f)*.693147f)) + + +typedef struct { + + float noisewindowlo; + float noisewindowhi; + int noisewindowlomin; + int noisewindowhimin; + int noisewindowfixed; + float noiseoff[P_BANDS]; + float noisecompand[NOISE_COMPAND_LEVELS]; + +} VorbisPsyInfo; + + + +typedef struct { + int n; + int rate; + struct drft_lookup lookup; + VorbisPsyInfo *vi; + + float *window; + float *noiseoffset; + long *bark; + +} VorbisPsy; + + +VorbisPsy *vorbis_psy_init(int rate, int size); +void vorbis_psy_destroy(VorbisPsy *psy); +void compute_curve(VorbisPsy *psy, float *audio, float *curve); +void curve_to_lpc(VorbisPsy *psy, float *curve, float *awk1, float *awk2, int ord); + +#endif +#endif diff --git a/lib/rbcodec/codecs/libspeex/vq.c b/lib/rbcodec/codecs/libspeex/vq.c new file mode 100644 index 0000000000..fff470a588 --- /dev/null +++ b/lib/rbcodec/codecs/libspeex/vq.c @@ -0,0 +1,147 @@ +/* Copyright (C) 2002 Jean-Marc Valin + File: vq.c + Vector quantization + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + - Neither the name of the Xiph.org Foundation nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifdef HAVE_CONFIG_H +#include "config-speex.h" +#endif + +#include "vq.h" +#include "stack_alloc.h" +#include "arch.h" + +#ifdef _USE_SSE +#include +#include "vq_sse.h" +#elif defined(SHORTCUTS) && (defined(ARM4_ASM) || defined(ARM5E_ASM)) +#include "vq_arm4.h" +#elif defined(BFIN_ASM) +#include "vq_bfin.h" +#endif + + +int scal_quant(spx_word16_t in, const spx_word16_t *boundary, int entries) +{ + int i=0; + while (iboundary[0]) + { + boundary++; + i++; + } + return i; +} + +int scal_quant32(spx_word32_t in, const spx_word32_t *boundary, int entries) +{ + int i=0; + while (iboundary[0]) + { + boundary++; + i++; + } + return i; +} + + +#ifndef OVERRIDE_VQ_NBEST +/*Finds the indices of the n-best entries in a codebook*/ +void vq_nbest(spx_word16_t *in, const spx_word16_t *codebook, int len, int entries, spx_word32_t *E, int N, int *nbest, spx_word32_t *best_dist, char *stack) +{ + int i,j,k,used; + used = 0; + for (i=0;i= 1) && (k > used || dist < best_dist[k-1]); k--) + { + best_dist[k]=best_dist[k-1]; + nbest[k] = nbest[k-1]; + } + best_dist[k]=dist; + nbest[k]=i; + used++; + } + } +} +#endif + + + + +#ifndef OVERRIDE_VQ_NBEST_SIGN +/*Finds the indices of the n-best entries in a codebook with sign*/ +void vq_nbest_sign(spx_word16_t *in, const spx_word16_t *codebook, int len, int entries, spx_word32_t *E, int N, int *nbest, spx_word32_t *best_dist, char *stack) +{ + int i,j,k, sign, used; + used=0; + for (i=0;i0) + { + sign=0; + dist=-dist; + } else + { + sign=1; + } +#ifdef FIXED_POINT + dist = ADD32(dist,SHR32(E[i],1)); +#else + dist = ADD32(dist,.5f*E[i]); +#endif + if (i= 1) && (k > used || dist < best_dist[k-1]); k--) + { + best_dist[k]=best_dist[k-1]; + nbest[k] = nbest[k-1]; + } + best_dist[k]=dist; + nbest[k]=i; + used++; + if (sign) + nbest[k]+=entries; + } + } +} +#endif diff --git a/lib/rbcodec/codecs/libspeex/vq.h b/lib/rbcodec/codecs/libspeex/vq.h new file mode 100644 index 0000000000..5a4ced249c --- /dev/null +++ b/lib/rbcodec/codecs/libspeex/vq.h @@ -0,0 +1,54 @@ +/* Copyright (C) 2002 Jean-Marc Valin */ +/** + @file vq.h + @brief Vector quantization +*/ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + - Neither the name of the Xiph.org Foundation nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef VQ_H +#define VQ_H + +#include "arch.h" + +int scal_quant(spx_word16_t in, const spx_word16_t *boundary, int entries); +int scal_quant32(spx_word32_t in, const spx_word32_t *boundary, int entries); + +#ifdef _USE_SSE +#include +void vq_nbest(spx_word16_t *in, const __m128 *codebook, int len, int entries, __m128 *E, int N, int *nbest, spx_word32_t *best_dist, char *stack); + +void vq_nbest_sign(spx_word16_t *in, const __m128 *codebook, int len, int entries, __m128 *E, int N, int *nbest, spx_word32_t *best_dist, char *stack); +#else +void vq_nbest(spx_word16_t *in, const spx_word16_t *codebook, int len, int entries, spx_word32_t *E, int N, int *nbest, spx_word32_t *best_dist, char *stack); + +void vq_nbest_sign(spx_word16_t *in, const spx_word16_t *codebook, int len, int entries, spx_word32_t *E, int N, int *nbest, spx_word32_t *best_dist, char *stack); +#endif + +#endif diff --git a/lib/rbcodec/codecs/libspeex/vq_arm4.h b/lib/rbcodec/codecs/libspeex/vq_arm4.h new file mode 100644 index 0000000000..d2697e5784 --- /dev/null +++ b/lib/rbcodec/codecs/libspeex/vq_arm4.h @@ -0,0 +1,115 @@ +/* Copyright (C) 2004 Jean-Marc Valin */ +/** + @file vq_arm4.h + @brief ARM4-optimized vq routine +*/ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + - Neither the name of the Xiph.org Foundation nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#define OVERRIDE_VQ_NBEST +void vq_nbest(spx_word16_t *in, const spx_word16_t *codebook, int len, int entries, spx_word32_t *E, int N, int *nbest, spx_word32_t *best_dist, char *stack) +{ + int i,j; + for (i=0;i>= 1;\n\t" + "A0 = %0;\n\t" + "R0.L = W[%1++%7] || R1.L = W[I0++];\n\t" + "LOOP vq_loop%= LC1 = %5;\n\t" + "LOOP_BEGIN vq_loop%=;\n\t" + "%0 = (A0 -= R0.L*R1.L) (IS) || R0.L = W[%1++%7] || R1.L = W[I0++];\n\t" + "LOOP_END vq_loop%=;\n\t" + "%0 = (A0 -= R0.L*R1.L) (IS);\n\t" + "cc = %0 < %2;\n\t" + "if cc %2 = %0;\n\t" + "if cc %3 = R2;\n\t" + "R2 += 1;\n\t" + "LOOP_END entries_loop%=;\n\t" + : "=&D" (dist), "=&a" (codebook), "=&d" (best_dist[0]), "=&d" (nbest[0]), "=&a" (E) + : "a" (len-1), "a" (in), "a" (2), "d" (entries), "d" (len<<1), "1" (codebook), "4" (E), "2" (best_dist[0]), "3" (nbest[0]) + : "R0", "R1", "R2", "I0", "L0", "B0", "A0", "cc", "memory" + ); + } + } else { + int i,k,used; + used = 0; + for (i=0;i>= 1;\n\t" + "A0 = %0;\n\t" + "I0 = %3;\n\t" + "L0 = 0;\n\t" + "R0.L = W[%1++%4] || R1.L = W[I0++];\n\t" + "LOOP vq_loop%= LC0 = %2;\n\t" + "LOOP_BEGIN vq_loop%=;\n\t" + "%0 = (A0 -= R0.L*R1.L) (IS) || R0.L = W[%1++%4] || R1.L = W[I0++];\n\t" + "LOOP_END vq_loop%=;\n\t" + "%0 = (A0 -= R0.L*R1.L) (IS);\n\t" + : "=D" (dist), "=a" (codebook) + : "a" (len-1), "a" (in), "a" (2), "1" (codebook), "0" (E[i]) + : "R0", "R1", "I0", "L0", "A0" + ); + if (i= 1) && (k > used || dist < best_dist[k-1]); k--) + { + best_dist[k]=best_dist[k-1]; + nbest[k] = nbest[k-1]; + } + best_dist[k]=dist; + nbest[k]=i; + used++; + } + } + } +} diff --git a/lib/rbcodec/codecs/libspeex/vq_sse.h b/lib/rbcodec/codecs/libspeex/vq_sse.h new file mode 100644 index 0000000000..00a42ce354 --- /dev/null +++ b/lib/rbcodec/codecs/libspeex/vq_sse.h @@ -0,0 +1,120 @@ +/* Copyright (C) 2004 Jean-Marc Valin */ +/** + @file vq_sse.h + @brief SSE-optimized vq routine +*/ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + - Neither the name of the Xiph.org Foundation nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#define OVERRIDE_VQ_NBEST +void vq_nbest(spx_word16_t *_in, const __m128 *codebook, int len, int entries, __m128 *E, int N, int *nbest, spx_word32_t *best_dist, char *stack) +{ + int i,j,k,used; + VARDECL(float *dist); + VARDECL(__m128 *in); + __m128 half; + used = 0; + ALLOC(dist, entries, float); + half = _mm_set_ps1(.5f); + ALLOC(in, len, __m128); + for (i=0;i>2;i++) + { + __m128 d = _mm_mul_ps(E[i], half); + for (j=0;j= 1) && (k > used || dist[i] < best_dist[k-1]); k--) + { + best_dist[k]=best_dist[k-1]; + nbest[k] = nbest[k-1]; + } + best_dist[k]=dist[i]; + nbest[k]=i; + used++; + } + } +} + + + + +#define OVERRIDE_VQ_NBEST_SIGN +void vq_nbest_sign(spx_word16_t *_in, const __m128 *codebook, int len, int entries, __m128 *E, int N, int *nbest, spx_word32_t *best_dist, char *stack) +{ + int i,j,k,used; + VARDECL(float *dist); + VARDECL(__m128 *in); + __m128 half; + used = 0; + ALLOC(dist, entries, float); + half = _mm_set_ps1(.5f); + ALLOC(in, len, __m128); + for (i=0;i>2;i++) + { + __m128 d = _mm_setzero_ps(); + for (j=0;j0) + { + sign=0; + dist[i]=-dist[i]; + } else + { + sign=1; + } + dist[i] += .5f*((float*)E)[i]; + if (i= 1) && (k > used || dist[i] < best_dist[k-1]); k--) + { + best_dist[k]=best_dist[k-1]; + nbest[k] = nbest[k-1]; + } + best_dist[k]=dist[i]; + nbest[k]=i; + used++; + if (sign) + nbest[k]+=entries; + } + } +} diff --git a/lib/rbcodec/codecs/libspeex/window.c b/lib/rbcodec/codecs/libspeex/window.c new file mode 100644 index 0000000000..84ed4916cf --- /dev/null +++ b/lib/rbcodec/codecs/libspeex/window.c @@ -0,0 +1,102 @@ +/* Copyright (C) 2006 Jean-Marc Valin + File: window.c + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + - Neither the name of the Xiph.org Foundation nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifdef HAVE_CONFIG_H +#include "config-speex.h" +#endif + +#include "arch.h" + +#ifdef FIXED_POINT +const spx_word16_t lag_window[11] ICONST_ATTR = { + 16384, 16337, 16199, 15970, 15656, 15260, 14790, 14254, 13659, 13015, 12330 +}; + +const spx_word16_t lpc_window[200] ICONST_ATTR = { +1310, 1313, 1321, 1333, 1352, 1375, 1403, 1436, +1475, 1518, 1567, 1621, 1679, 1743, 1811, 1884, +1962, 2044, 2132, 2224, 2320, 2421, 2526, 2636, +2750, 2868, 2990, 3116, 3246, 3380, 3518, 3659, +3804, 3952, 4104, 4259, 4417, 4578, 4742, 4909, +5079, 5251, 5425, 5602, 5781, 5963, 6146, 6331, +6518, 6706, 6896, 7087, 7280, 7473, 7668, 7863, +8059, 8256, 8452, 8650, 8847, 9044, 9241, 9438, +9635, 9831, 10026, 10220, 10414, 10606, 10797, 10987, +11176, 11363, 11548, 11731, 11912, 12091, 12268, 12443, +12615, 12785, 12952, 13116, 13277, 13435, 13590, 13742, +13890, 14035, 14176, 14314, 14448, 14578, 14704, 14826, +14944, 15058, 15168, 15273, 15374, 15470, 15562, 15649, +15732, 15810, 15883, 15951, 16015, 16073, 16127, 16175, +16219, 16257, 16291, 16319, 16342, 16360, 16373, 16381, +16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384, +16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384, +16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384, +16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384, +16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384, +16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384, +16384, 16384, 16384, 16361, 16294, 16183, 16028, 15830, +15588, 15304, 14979, 14613, 14207, 13763, 13282, 12766, +12215, 11631, 11016, 10373, 9702, 9007, 8289, 7551, +6797, 6028, 5251, 4470, 3695, 2943, 2248, 1696 +}; +#else +const spx_word16_t lag_window[11] = { + 1.00000, 0.99716, 0.98869, 0.97474, 0.95554, 0.93140, 0.90273, 0.86998, 0.83367, 0.79434, 0.75258 +}; + +const spx_word16_t lpc_window[200] = { + 0.080000f, 0.080158f, 0.080630f, 0.081418f, 0.082520f, 0.083935f, 0.085663f, 0.087703f, + 0.090052f, 0.092710f, 0.095674f, 0.098943f, 0.102514f, 0.106385f, 0.110553f, 0.115015f, + 0.119769f, 0.124811f, 0.130137f, 0.135744f, 0.141628f, 0.147786f, 0.154212f, 0.160902f, + 0.167852f, 0.175057f, 0.182513f, 0.190213f, 0.198153f, 0.206328f, 0.214731f, 0.223357f, + 0.232200f, 0.241254f, 0.250513f, 0.259970f, 0.269619f, 0.279453f, 0.289466f, 0.299651f, + 0.310000f, 0.320507f, 0.331164f, 0.341965f, 0.352901f, 0.363966f, 0.375151f, 0.386449f, + 0.397852f, 0.409353f, 0.420943f, 0.432615f, 0.444361f, 0.456172f, 0.468040f, 0.479958f, + 0.491917f, 0.503909f, 0.515925f, 0.527959f, 0.540000f, 0.552041f, 0.564075f, 0.576091f, + 0.588083f, 0.600042f, 0.611960f, 0.623828f, 0.635639f, 0.647385f, 0.659057f, 0.670647f, + 0.682148f, 0.693551f, 0.704849f, 0.716034f, 0.727099f, 0.738035f, 0.748836f, 0.759493f, + 0.770000f, 0.780349f, 0.790534f, 0.800547f, 0.810381f, 0.820030f, 0.829487f, 0.838746f, + 0.847800f, 0.856643f, 0.865269f, 0.873672f, 0.881847f, 0.889787f, 0.897487f, 0.904943f, + 0.912148f, 0.919098f, 0.925788f, 0.932214f, 0.938372f, 0.944256f, 0.949863f, 0.955189f, + 0.960231f, 0.964985f, 0.969447f, 0.973615f, 0.977486f, 0.981057f, 0.984326f, 0.987290f, + 0.989948f, 0.992297f, 0.994337f, 0.996065f, 0.997480f, 0.998582f, 0.999370f, 0.999842f, + 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, + 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, + 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, + 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, + 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, + 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, + 1.000000f, 1.000000f, 1.000000f, 0.998640f, 0.994566f, 0.987787f, 0.978324f, 0.966203f, + 0.951458f, 0.934131f, 0.914270f, 0.891931f, 0.867179f, 0.840084f, 0.810723f, 0.779182f, + 0.745551f, 0.709930f, 0.672424f, 0.633148f, 0.592223f, 0.549781f, 0.505964f, 0.460932f, + 0.414863f, 0.367968f, 0.320511f, 0.272858f, 0.225569f, 0.179655f, 0.137254f, 0.103524f +}; +#endif diff --git a/lib/rbcodec/codecs/libtremor/CHANGELOG b/lib/rbcodec/codecs/libtremor/CHANGELOG new file mode 100644 index 0000000000..53f23351e2 --- /dev/null +++ b/lib/rbcodec/codecs/libtremor/CHANGELOG @@ -0,0 +1,19 @@ +*** 20020517: 1.0.2 *** + + Playback bugfix to floor1; mode mistakenly used for sizing instead + of blockflag + +*** 20020515: 1.0.1 *** + + Added complete API documentation to source tarball. No code + changes. + +*** 20020412: 1.0.1 *** + + Fixed a clipping bug that affected ARM processors; negative + overflows were being properly clipped, but then clobbered to + positive by the positive overflow chec (asm_arm.h:CLIP_TO_15) + +*** 20020403: 1.0.0 *** + + Initial version \ No newline at end of file diff --git a/lib/rbcodec/codecs/libtremor/COPYING b/lib/rbcodec/codecs/libtremor/COPYING new file mode 100644 index 0000000000..6111c6c5a6 --- /dev/null +++ b/lib/rbcodec/codecs/libtremor/COPYING @@ -0,0 +1,28 @@ +Copyright (c) 2002, Xiph.org Foundation + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +- Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + +- Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the following disclaimer in the +documentation and/or other materials provided with the distribution. + +- Neither the name of the Xiph.org Foundation nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION +OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/lib/rbcodec/codecs/libtremor/README b/lib/rbcodec/codecs/libtremor/README new file mode 100644 index 0000000000..1321175322 --- /dev/null +++ b/lib/rbcodec/codecs/libtremor/README @@ -0,0 +1,46 @@ +This README covers the Ogg Vorbis 'Tremor' integer playback codec +source as of date 2002 09 02, version 1.0.0. + + ****** + +The C source in this package will build on any ANSI C compiler and +function completely and properly on any platform. The included build +system assumes GNU build system and make tools (m4, automake, +autoconf, libtool and gmake). GCC is not required, although GCC is +the most tested compiler. To build using GNU tools, type in the +source directory: + +./autogen.sh +make + +Currently, the source implements playback in pure C on all platforms +except ARM, where a [currently] small amount of assembly (see +asm_arm.h) is used to implement 64 bit math operations and fast LSP +computation. If building on ARM without the benefit of GNU build +system tools, be sure that '_ARM_ASSEM_' is #defined by the build +system if this assembly is desired, else the resulting library will +use whatever 64 bit math builtins the compiler implements. + +No math library is required by this source. No floating point +operations are used at any point in either setup or decode. This +decoder library will properly decode any past, current or future +Vorbis I file or stream. + + ******** + +The build system produces a static and [when supported by the OS] +dynamic library named 'libvorbisidec'. This library exposes an API +nearly identical to the BSD reference library's 'libvorbisfile', +including all the features familiar to users of vorbisfile. This API +is similar enough that the proper header file to include is named +'ivorbisfile.h' [included in the source build directory]. Lower level +libvorbis-style headers and structures are in 'ivorbiscodec.h' +[included in the source build directory]. A simple example program, +ivorbisfile_example.c, can be built with 'make example'. + + ******** + +Detailed Tremor API Documentation begins at doc/index.html + +Monty +xiph.org diff --git a/lib/rbcodec/codecs/libtremor/README.rockbox b/lib/rbcodec/codecs/libtremor/README.rockbox new file mode 100644 index 0000000000..a4e141f6b3 --- /dev/null +++ b/lib/rbcodec/codecs/libtremor/README.rockbox @@ -0,0 +1,17 @@ +Library: Tremor-1.1.2 (Released 2002-05-17) +Imported: 2005-02-16 by Marcoen Hirschberg + +This directory contains a local version of Tremor for use by Rockbox +for software decoding of Ogg Vorbis files. + +LICENSING INFORMATION + +Tremor is distributed under Xiph.Org's BSD-like license - see the file COPYING +in this directory for details. + +IMPORT DETAILS + +The base version first imported into Rockbox was the SVN version of +Tremor-1.0.2 which was checked out on 2005-02-16. + +The autoconf/automake files were removed, as well as the doc and debian directories. diff --git a/lib/rbcodec/codecs/libtremor/SOURCES b/lib/rbcodec/codecs/libtremor/SOURCES new file mode 100644 index 0000000000..c622699599 --- /dev/null +++ b/lib/rbcodec/codecs/libtremor/SOURCES @@ -0,0 +1,16 @@ +bitwise.c +block.c +codebook.c +floor0.c +floor1.c +framing.c +info.c +mapping0.c +registry.c +res012.c +sharedbook.c +synthesis.c +vorbisfile.c +window.c +ctype.c +oggmalloc.c diff --git a/lib/rbcodec/codecs/libtremor/asm_arm.h b/lib/rbcodec/codecs/libtremor/asm_arm.h new file mode 100644 index 0000000000..42834a2581 --- /dev/null +++ b/lib/rbcodec/codecs/libtremor/asm_arm.h @@ -0,0 +1,190 @@ +/******************************************************************** + * * + * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * + * * + * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * + * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * + * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * + * * + * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * + * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * + * * + ******************************************************************** + + function: arm7 and later wide math functions + + ********************************************************************/ + +#ifdef _ARM_ASSEM_ +#if ARM_ARCH < 6 +#define INCL_OPTIMIZED_VECTOR_FMUL_WINDOW +static inline void ff_vector_fmul_window_c(ogg_int32_t *dst, const ogg_int32_t *src0, + const ogg_int32_t *src1, const ogg_int32_t *win, int len) +{ + /* len is always a power of 2 and always >= 16 so this is unrolled 2 times*/ + ogg_int32_t *dst0 = dst, *dst1 = dst + 2*len; + const ogg_int32_t *win0 = win, *win1 = win + 2*len; + src1 += len; + asm volatile ("cmp %[len], #0\n\t" + "b 1f\n\t" + "0:\n\t" + "ldr r0, [%[src0]], #4\n\t" + "ldr r1, [%[src1], #-4]!\n\t" + "ldr r2, [%[win0]], #4\n\t" + "ldr r3, [%[win1], #-4]!\n\t" + "smull r4, r5, r0, r2\n\t" + "smlal r4, r5, r1, r3\n\t" + "rsb r2, r2, #0\n\t" + "lsl r5, r5, #1\n\t" + "str r5, [%[dst1], #-4]!\n\t" + "smull r4, r5, r0, r3\n\t" + "smlal r4, r5, r1, r2\n\t" + "ldr r0, [%[src0]], #4\n\t" + "ldr r1, [%[src1], #-4]!\n\t" + "lsl r5, r5, #1\n\t" + "str r5, [%[dst0]], #4\n\t" + + "ldr r2, [%[win0]], #4\n\t" + "ldr r3, [%[win1], #-4]!\n\t" + "smull r4, r5, r0, r2\n\t" + "smlal r4, r5, r1, r3\n\t" + "rsb r2, r2, #0\n\t" + "lsl r5, r5, #1\n\t" + "str r5, [%[dst1], #-4]!\n\t" + "smull r4, r5, r0, r3\n\t" + "smlal r4, r5, r1, r2\n\t" + "subs %[len], %[len], #2\n\t" + "lsl r5, r5, #1\n\t" + "str r5, [%[dst0]], #4\n\t" + "1:\n\t" + "bgt 0b\n\t" + : [dst0] "+r" (dst0), [dst1] "+r" (dst1), + [src0] "+r" (src0), [src1] "+r" (src1), + [win0] "+r" (win0), [win1] "+r" (win1), + [len] "+r" (len) + :: "r0", "r1", "r2", "r3", "r4", "r5", "cc", "memory"); +} +#endif +#ifndef _V_LSP_MATH_ASM +#define _V_LSP_MATH_ASM + +static inline void lsp_loop_asm(ogg_uint32_t *qip,ogg_uint32_t *pip, + ogg_int32_t *qexpp, + ogg_int32_t *ilsp,ogg_int32_t wi, + ogg_int32_t m){ + + ogg_uint32_t qi=*qip,pi=*pip; + ogg_int32_t qexp=*qexpp; + + asm("mov r0,%3;" + "movs r1,%5,asr#1;" + "add r0,r0,r1,lsl#3;" + "beq 2f;\n" + "1:" + + "ldmdb r0!,{r1,r3};" + "subs r1,r1,%4;" //ilsp[j]-wi + "rsbmi r1,r1,#0;" //labs(ilsp[j]-wi) + "umull %0,r2,r1,%0;" //qi*=labs(ilsp[j]-wi) + + "subs r1,r3,%4;" //ilsp[j+1]-wi + "rsbmi r1,r1,#0;" //labs(ilsp[j+1]-wi) + "umull %1,r3,r1,%1;" //pi*=labs(ilsp[j+1]-wi) + + "cmn r2,r3;" // shift down 16? + "beq 0f;" + "add %2,%2,#16;" + "mov %0,%0,lsr #16;" + "orr %0,%0,r2,lsl #16;" + "mov %1,%1,lsr #16;" + "orr %1,%1,r3,lsl #16;" + "0:" + "cmp r0,%3;\n" + "bhi 1b;\n" + + "2:" + // odd filter assymetry + "ands r0,%5,#1;\n" + "beq 3f;\n" + "add r0,%3,%5,lsl#2;\n" + + "ldr r1,[r0,#-4];\n" + "mov r0,#0x4000;\n" + + "subs r1,r1,%4;\n" //ilsp[j]-wi + "rsbmi r1,r1,#0;\n" //labs(ilsp[j]-wi) + "umull %0,r2,r1,%0;\n" //qi*=labs(ilsp[j]-wi) + "umull %1,r3,r0,%1;\n" //pi*=labs(ilsp[j+1]-wi) + + "cmn r2,r3;\n" // shift down 16? + "beq 3f;\n" + "add %2,%2,#16;\n" + "mov %0,%0,lsr #16;\n" + "orr %0,%0,r2,lsl #16;\n" + "mov %1,%1,lsr #16;\n" + "orr %1,%1,r3,lsl #16;\n" + + //qi=(pi>>shift)*labs(ilsp[j]-wi); + //pi=(qi>>shift)*labs(ilsp[j+1]-wi); + //qexp+=shift; + + //} + + /* normalize to max 16 sig figs */ + "3:" + "mov r2,#0;" + "orr r1,%0,%1;" + "tst r1,#0xff000000;" + "addne r2,r2,#8;" + "movne r1,r1,lsr #8;" + "tst r1,#0x00f00000;" + "addne r2,r2,#4;" + "movne r1,r1,lsr #4;" + "tst r1,#0x000c0000;" + "addne r2,r2,#2;" + "movne r1,r1,lsr #2;" + "tst r1,#0x00020000;" + "addne r2,r2,#1;" + "movne r1,r1,lsr #1;" + "tst r1,#0x00010000;" + "addne r2,r2,#1;" + "mov %0,%0,lsr r2;" + "mov %1,%1,lsr r2;" + "add %2,%2,r2;" + + : "+r"(qi),"+r"(pi),"+r"(qexp) + : "r"(ilsp),"r"(wi),"r"(m) + : "r0","r1","r2","r3","cc"); + + *qip=qi; + *pip=pi; + *qexpp=qexp; +} + +static inline void lsp_norm_asm(ogg_uint32_t *qip,ogg_int32_t *qexpp){ + + ogg_uint32_t qi=*qip; + ogg_int32_t qexp=*qexpp; + + asm("tst %0,#0x0000ff00;" + "moveq %0,%0,lsl #8;" + "subeq %1,%1,#8;" + "tst %0,#0x0000f000;" + "moveq %0,%0,lsl #4;" + "subeq %1,%1,#4;" + "tst %0,#0x0000c000;" + "moveq %0,%0,lsl #2;" + "subeq %1,%1,#2;" + "tst %0,#0x00008000;" + "moveq %0,%0,lsl #1;" + "subeq %1,%1,#1;" + : "+r"(qi),"+r"(qexp) + : + : "cc"); + *qip=qi; + *qexpp=qexp; +} + +#endif +#endif + diff --git a/lib/rbcodec/codecs/libtremor/asm_mcf5249.h b/lib/rbcodec/codecs/libtremor/asm_mcf5249.h new file mode 100644 index 0000000000..38aa117d84 --- /dev/null +++ b/lib/rbcodec/codecs/libtremor/asm_mcf5249.h @@ -0,0 +1,85 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * + * Copyright (C) 2005 by Pedro Vasconcelos + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ +/* asm routines for wide math on the MCF5249 */ + +#include "os_types.h" + +#if defined(CPU_COLDFIRE) + +#ifndef _V_WIDE_MATH +#define _V_WIDE_MATH + +#define INCL_OPTIMIZED_VECTOR_FMUL_WINDOW +static inline void ff_vector_fmul_window_c(ogg_int32_t *dst, const ogg_int32_t *src0, + const ogg_int32_t *src1, const ogg_int32_t *win, int len) +{ + /* len is always a power of 2 and always >= 16 so this is unrolled 4 times*/ + ogg_int32_t *dst0 = dst, *dst1 = dst + 2*len; + const ogg_int32_t *win0 = win, *win1 = win + 2*len; + src1 += len; + asm volatile ("move.l (%[src0])+, %%d0\n\t" + "move.l -(%[win1]), %%d3\n\t" + "tst.l %[len]\n\t" + "bra.s 1f\n\t" + "0:\n\t" + "mac.l %%d0, %%d3, (%[win0])+, %%d2, %%acc0\n\t" + "mac.l %%d0, %%d2, -(%[src1]), %%d1, %%acc1\n\t" + "msac.l %%d1, %%d2, (%[src0])+, %%d0, %%acc0\n\t" + "mac.l %%d1, %%d3, -(%[win1]), %%d3, %%acc1\n\t" + "mac.l %%d0, %%d3, (%[win0])+, %%d2, %%acc2\n\t" + "mac.l %%d0, %%d2, -(%[src1]), %%d1, %%acc3\n\t" + "msac.l %%d1, %%d2, (%[src0])+, %%d0, %%acc2\n\t" + "mac.l %%d1, %%d3, -(%[win1]), %%d3, %%acc3\n\t" + "movclr.l %%acc0, %%d1\n\t" + "movclr.l %%acc2, %%d2\n\t" + "subq.l #8, %[dst1]\n\t" + "movclr.l %%acc1, %%d5\n\t" + "movclr.l %%acc3, %%d4\n\t" + "movem.l %%d4-%%d5, (%[dst1])\n\t" + "mac.l %%d0, %%d3, (%[win0])+, %%d5, %%acc0\n\t" + "mac.l %%d0, %%d5, -(%[src1]), %%d4, %%acc1\n\t" + "msac.l %%d4, %%d5, (%[src0])+, %%d0, %%acc0\n\t" + "mac.l %%d4, %%d3, -(%[win1]), %%d3, %%acc1\n\t" + "mac.l %%d0, %%d3, (%[win0])+, %%d5, %%acc2\n\t" + "mac.l %%d0, %%d5, -(%[src1]), %%d4, %%acc3\n\t" + "msac.l %%d4, %%d5, (%[src0])+, %%d0, %%acc2\n\t" /* will read one past end of src0 */ + "mac.l %%d4, %%d3, -(%[win1]), %%d3, %%acc3\n\t" /* will read one into win0 */ + "movclr.l %%acc0, %%d4\n\t" + "movclr.l %%acc2, %%d5\n\t" + "movem.l %%d1-%%d2/%%d4-%%d5, (%[dst0])\n\t" + "lea (16, %[dst0]), %[dst0]\n\t" + "subq.l #8, %[dst1]\n\t" + "movclr.l %%acc1, %%d2\n\t" + "movclr.l %%acc3, %%d1\n\t" + "movem.l %%d1-%%d2, (%[dst1])\n\t" + "subq.l #4, %[len]\n\t" + "1:\n\t" + "bgt.s 0b\n\t" + : [dst0] "+a" (dst0), [dst1] "+a" (dst1), + [src0] "+a" (src0), [src1] "+a" (src1), + [win0] "+a" (win0), [win1] "+a" (win1), + [len] "+d" (len) + :: "d0", "d1", "d2", "d3", "d4", "d5", "cc", "memory" ); +} + +#define MB() + +#endif +#endif diff --git a/lib/rbcodec/codecs/libtremor/backends.h b/lib/rbcodec/codecs/libtremor/backends.h new file mode 100644 index 0000000000..e27f1f2b80 --- /dev/null +++ b/lib/rbcodec/codecs/libtremor/backends.h @@ -0,0 +1,133 @@ +/******************************************************************** + * * + * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * + * * + * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * + * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * + * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * + * * + * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * + * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * + * * + ******************************************************************** + + function: backend and mapping structures + + ********************************************************************/ + +/* this is exposed up here because we need it for static modes. + Lookups for each backend aren't exposed because there's no reason + to do so */ + +#ifndef _vorbis_backend_h_ +#define _vorbis_backend_h_ + +#include "codec_internal.h" + +/* this would all be simpler/shorter with templates, but.... */ +/* Transform backend generic *************************************/ + +/* only mdct right now. Flesh it out more if we ever transcend mdct + in the transform domain */ + +/* Floor backend generic *****************************************/ +typedef struct{ + vorbis_info_floor *(*unpack)(vorbis_info *,oggpack_buffer *); + vorbis_look_floor *(*look) (vorbis_dsp_state *,vorbis_info_mode *, + vorbis_info_floor *); + void (*free_info) (vorbis_info_floor *); + void (*free_look) (vorbis_look_floor *); + void *(*inverse1) (struct vorbis_block *,vorbis_look_floor *); + int (*inverse2) (struct vorbis_block *,vorbis_look_floor *, + void *buffer,ogg_int32_t *); +} vorbis_func_floor; + +typedef struct{ + int order; + long rate; + long barkmap; + + int ampbits; + int ampdB; + + int numbooks; /* <= 16 */ + int books[16]; + +} vorbis_info_floor0; + +#define VIF_POSIT 63 +#define VIF_CLASS 16 +#define VIF_PARTS 31 +typedef struct{ + int partitions; /* 0 to 31 */ + int partitionclass[VIF_PARTS]; /* 0 to 15 */ + + int class_dim[VIF_CLASS]; /* 1 to 8 */ + int class_subs[VIF_CLASS]; /* 0,1,2,3 (bits: 1< +#include +#include +#include "ogg.h" + +#define BUFFER_INCREMENT 256 + +const unsigned long mask[] ICONST_ATTR = +{0x00000000,0x00000001,0x00000003,0x00000007,0x0000000f, + 0x0000001f,0x0000003f,0x0000007f,0x000000ff,0x000001ff, + 0x000003ff,0x000007ff,0x00000fff,0x00001fff,0x00003fff, + 0x00007fff,0x0000ffff,0x0001ffff,0x0003ffff,0x0007ffff, + 0x000fffff,0x001fffff,0x003fffff,0x007fffff,0x00ffffff, + 0x01ffffff,0x03ffffff,0x07ffffff,0x0fffffff,0x1fffffff, + 0x3fffffff,0x7fffffff,0xffffffff }; + +#if 0 +static const unsigned int mask8B[]= +{0x00,0x80,0xc0,0xe0,0xf0,0xf8,0xfc,0xfe,0xff}; + +void oggpack_writeinit(oggpack_buffer *b){ + memset(b,0,sizeof(*b)); + b->ptr=b->buffer=_ogg_malloc(BUFFER_INCREMENT); + b->buffer[0]='\0'; + b->storage=BUFFER_INCREMENT; +} + +void oggpackB_writeinit(oggpack_buffer *b){ + oggpack_writeinit(b); +} + +int oggpack_writecheck(oggpack_buffer *b){ + if(!b->ptr || !b->storage)return -1; + return 0; +} + +int oggpackB_writecheck(oggpack_buffer *b){ + return oggpack_writecheck(b); +} + +void oggpack_writetrunc(oggpack_buffer *b,long bits){ + long bytes=bits>>3; + if(b->ptr){ + bits-=bytes*8; + b->ptr=b->buffer+bytes; + b->endbit=bits; + b->endbyte=bytes; + *b->ptr&=mask[bits]; + } +} + +void oggpackB_writetrunc(oggpack_buffer *b,long bits){ + long bytes=bits>>3; + if(b->ptr){ + bits-=bytes*8; + b->ptr=b->buffer+bytes; + b->endbit=bits; + b->endbyte=bytes; + *b->ptr&=mask8B[bits]; + } +} + +/* Takes only up to 32 bits. */ +void oggpack_write(oggpack_buffer *b,unsigned long value,int bits){ + if(bits<0 || bits>32) goto err; + if(b->endbyte>=b->storage-4){ + void *ret; + if(!b->ptr)return; + if(b->storage>LONG_MAX-BUFFER_INCREMENT) goto err; + ret=_ogg_realloc(b->buffer,b->storage+BUFFER_INCREMENT); + if(!ret) goto err; + b->buffer=ret; + b->storage+=BUFFER_INCREMENT; + b->ptr=b->buffer+b->endbyte; + } + + value&=mask[bits]; + bits+=b->endbit; + + b->ptr[0]|=value<endbit; + + if(bits>=8){ + b->ptr[1]=(unsigned char)(value>>(8-b->endbit)); + if(bits>=16){ + b->ptr[2]=(unsigned char)(value>>(16-b->endbit)); + if(bits>=24){ + b->ptr[3]=(unsigned char)(value>>(24-b->endbit)); + if(bits>=32){ + if(b->endbit) + b->ptr[4]=(unsigned char)(value>>(32-b->endbit)); + else + b->ptr[4]=0; + } + } + } + } + + b->endbyte+=bits/8; + b->ptr+=bits/8; + b->endbit=bits&7; + return; + err: + oggpack_writeclear(b); +} + +/* Takes only up to 32 bits. */ +void oggpackB_write(oggpack_buffer *b,unsigned long value,int bits){ + if(bits<0 || bits>32) goto err; + if(b->endbyte>=b->storage-4){ + void *ret; + if(!b->ptr)return; + if(b->storage>LONG_MAX-BUFFER_INCREMENT) goto err; + ret=_ogg_realloc(b->buffer,b->storage+BUFFER_INCREMENT); + if(!ret) goto err; + b->buffer=ret; + b->storage+=BUFFER_INCREMENT; + b->ptr=b->buffer+b->endbyte; + } + + value=(value&mask[bits])<<(32-bits); + bits+=b->endbit; + + b->ptr[0]|=value>>(24+b->endbit); + + if(bits>=8){ + b->ptr[1]=(unsigned char)(value>>(16+b->endbit)); + if(bits>=16){ + b->ptr[2]=(unsigned char)(value>>(8+b->endbit)); + if(bits>=24){ + b->ptr[3]=(unsigned char)(value>>(b->endbit)); + if(bits>=32){ + if(b->endbit) + b->ptr[4]=(unsigned char)(value<<(8-b->endbit)); + else + b->ptr[4]=0; + } + } + } + } + + b->endbyte+=bits/8; + b->ptr+=bits/8; + b->endbit=bits&7; + return; + err: + oggpack_writeclear(b); +} + +void oggpack_writealign(oggpack_buffer *b){ + int bits=8-b->endbit; + if(bits<8) + oggpack_write(b,0,bits); +} + +void oggpackB_writealign(oggpack_buffer *b){ + int bits=8-b->endbit; + if(bits<8) + oggpackB_write(b,0,bits); +} + +static void oggpack_writecopy_helper(oggpack_buffer *b, + void *source, + long bits, + void (*w)(oggpack_buffer *, + unsigned long, + int), + int msb){ + unsigned char *ptr=(unsigned char *)source; + + long bytes=bits/8; + bits-=bytes*8; + + if(b->endbit){ + int i; + /* unaligned copy. Do it the hard way. */ + for(i=0;iendbyte+bytes+1>=b->storage){ + void *ret; + if(!b->ptr) goto err; + if(b->endbyte+bytes+BUFFER_INCREMENT>b->storage) goto err; + b->storage=b->endbyte+bytes+BUFFER_INCREMENT; + ret=_ogg_realloc(b->buffer,b->storage); + if(!ret) goto err; + b->buffer=ret; + b->ptr=b->buffer+b->endbyte; + } + + memmove(b->ptr,source,bytes); + b->ptr+=bytes; + b->endbyte+=bytes; + *b->ptr=0; + + } + if(bits){ + if(msb) + w(b,(unsigned long)(ptr[bytes]>>(8-bits)),bits); + else + w(b,(unsigned long)(ptr[bytes]),bits); + } + return; + err: + oggpack_writeclear(b); +} + +void oggpack_writecopy(oggpack_buffer *b,void *source,long bits){ + oggpack_writecopy_helper(b,source,bits,oggpack_write,0); +} + +void oggpackB_writecopy(oggpack_buffer *b,void *source,long bits){ + oggpack_writecopy_helper(b,source,bits,oggpackB_write,1); +} + +void oggpack_reset(oggpack_buffer *b){ + if(!b->ptr)return; + b->ptr=b->buffer; + b->buffer[0]=0; + b->endbit=b->endbyte=0; +} + +void oggpackB_reset(oggpack_buffer *b){ + oggpack_reset(b); +} + +void oggpack_writeclear(oggpack_buffer *b){ + if(b->buffer)_ogg_free(b->buffer); + memset(b,0,sizeof(*b)); +} + +void oggpackB_writeclear(oggpack_buffer *b){ + oggpack_writeclear(b); +} +#endif +void oggpack_readinit(oggpack_buffer *b,unsigned char *buf,int bytes){ + memset(b,0,sizeof(*b)); + b->buffer=b->ptr=buf; + b->storage=bytes; +} +#if 0 +void oggpackB_readinit(oggpack_buffer *b,unsigned char *buf,int bytes){ + oggpack_readinit(b,buf,bytes); +} +#endif +/* Read in bits without advancing the bitptr; bits <= 32 */ +/* moved to ogg.h for inlining */ +#if 0 +long oggpack_look(oggpack_buffer *b,int bits){ + unsigned long ret; + unsigned long m; + + if(bits<0 || bits>32) return -1; + m=mask[bits]; + bits+=b->endbit; + + if(b->endbyte >= b->storage-4){ + /* not the main path */ + if(b->endbyte > b->storage-((bits+7)>>3)) return -1; + /* special case to avoid reading b->ptr[0], which might be past the end of + the buffer; also skips some useless accounting */ + else if(!bits)return(0L); + } + + ret=b->ptr[0]>>b->endbit; + if(bits>8){ + ret|=b->ptr[1]<<(8-b->endbit); + if(bits>16){ + ret|=b->ptr[2]<<(16-b->endbit); + if(bits>24){ + ret|=b->ptr[3]<<(24-b->endbit); + if(bits>32 && b->endbit) + ret|=b->ptr[4]<<(32-b->endbit); + } + } + } + return(m&ret); +} +#endif + +#if 0 +/* Read in bits without advancing the bitptr; bits <= 32 */ +long oggpackB_look(oggpack_buffer *b,int bits){ + unsigned long ret; + int m=32-bits; + + if(m<0 || m>32) return -1; + bits+=b->endbit; + + if(b->endbyte >= b->storage-4){ + /* not the main path */ + if(b->endbyte > b->storage-((bits+7)>>3)) return -1; + /* special case to avoid reading b->ptr[0], which might be past the end of + the buffer; also skips some useless accounting */ + else if(!bits)return(0L); + } + + ret=b->ptr[0]<<(24+b->endbit); + if(bits>8){ + ret|=b->ptr[1]<<(16+b->endbit); + if(bits>16){ + ret|=b->ptr[2]<<(8+b->endbit); + if(bits>24){ + ret|=b->ptr[3]<<(b->endbit); + if(bits>32 && b->endbit) + ret|=b->ptr[4]>>(8-b->endbit); + } + } + } + return ((ret&0xffffffff)>>(m>>1))>>((m+1)>>1); +} + +long oggpack_look1(oggpack_buffer *b){ + if(b->endbyte>=b->storage)return(-1); + return((b->ptr[0]>>b->endbit)&1); +} + +long oggpackB_look1(oggpack_buffer *b){ + if(b->endbyte>=b->storage)return(-1); + return((b->ptr[0]>>(7-b->endbit))&1); +} +#endif +/* moved to ogg.h for inlining +void oggpack_adv(oggpack_buffer *b,int bits){ + bits+=b->endbit; + + if(b->endbyte > b->storage-((bits+7)>>3)) goto overflow; + + b->ptr+=bits/8; + b->endbyte+=bits/8; + b->endbit=bits&7; + return; + + overflow: + b->ptr=NULL; + b->endbyte=b->storage; + b->endbit=1; +} +*/ +#if 0 +void oggpackB_adv(oggpack_buffer *b,int bits){ + oggpack_adv(b,bits); +} + +void oggpack_adv1(oggpack_buffer *b){ + if(++(b->endbit)>7){ + b->endbit=0; + b->ptr++; + b->endbyte++; + } +} + +void oggpackB_adv1(oggpack_buffer *b){ + oggpack_adv1(b); +} +#endif +/* bits <= 32 */ +long oggpack_read(oggpack_buffer *b,int bits) ICODE_ATTR_TREMOR_NOT_MDCT; +long oggpack_read(oggpack_buffer *b,int bits){ + long ret; + unsigned long m; + + if(bits<0 || bits>32) goto err; + m=mask[bits]; + bits+=b->endbit; + + if(b->endbyte >= b->storage-4){ + /* not the main path */ + if(b->endbyte > b->storage-((bits+7)>>3)) goto overflow; + /* special case to avoid reading b->ptr[0], which might be past the end of + the buffer; also skips some useless accounting */ + else if(!bits)return(0L); + } + + ret=b->ptr[0]>>b->endbit; + if(bits>8){ + ret|=b->ptr[1]<<(8-b->endbit); + if(bits>16){ + ret|=b->ptr[2]<<(16-b->endbit); + if(bits>24){ + ret|=b->ptr[3]<<(24-b->endbit); + if(bits>32 && b->endbit){ + ret|=b->ptr[4]<<(32-b->endbit); + } + } + } + } + ret&=m; + b->ptr+=bits/8; + b->endbyte+=bits/8; + b->endbit=bits&7; + return ret; + + overflow: + err: + b->ptr=NULL; + b->endbyte=b->storage; + b->endbit=1; + return -1L; +} +#if 0 +/* bits <= 32 */ +long oggpackB_read(oggpack_buffer *b,int bits){ + long ret; + long m=32-bits; + + if(m<0 || m>32) goto err; + bits+=b->endbit; + + if(b->endbyte+4>=b->storage){ + /* not the main path */ + if(b->endbyte > b->storage-((bits+7)>>3)) goto overflow; + /* special case to avoid reading b->ptr[0], which might be past the end of + the buffer; also skips some useless accounting */ + else if(!bits)return(0L); + } + + ret=b->ptr[0]<<(24+b->endbit); + if(bits>8){ + ret|=b->ptr[1]<<(16+b->endbit); + if(bits>16){ + ret|=b->ptr[2]<<(8+b->endbit); + if(bits>24){ + ret|=b->ptr[3]<<(b->endbit); + if(bits>32 && b->endbit) + ret|=b->ptr[4]>>(8-b->endbit); + } + } + } + ret=((ret&0xffffffffUL)>>(m>>1))>>((m+1)>>1); + + b->ptr+=bits/8; + b->endbyte+=bits/8; + b->endbit=bits&7; + return ret; + + overflow: + err: + b->ptr=NULL; + b->endbyte=b->storage; + b->endbit=1; + return -1L; +} + +long oggpack_read1(oggpack_buffer *b){ + long ret; + + if(b->endbyte >= b->storage) goto overflow; + ret=(b->ptr[0]>>b->endbit)&1; + + b->endbit++; + if(b->endbit>7){ + b->endbit=0; + b->ptr++; + b->endbyte++; + } + return ret; + + overflow: + b->ptr=NULL; + b->endbyte=b->storage; + b->endbit=1; + return -1L; +} + +long oggpackB_read1(oggpack_buffer *b){ + long ret; + + if(b->endbyte >= b->storage) goto overflow; + ret=(b->ptr[0]>>(7-b->endbit))&1; + + b->endbit++; + if(b->endbit>7){ + b->endbit=0; + b->ptr++; + b->endbyte++; + } + return ret; + + overflow: + b->ptr=NULL; + b->endbyte=b->storage; + b->endbit=1; + return -1L; +} +#endif +/* moved to ogg.h for inlining +long oggpack_bytes(oggpack_buffer *b){ + return(b->endbyte+(b->endbit+7)/8); +} +*/ +#if 0 +long oggpack_bits(oggpack_buffer *b){ + return(b->endbyte*8+b->endbit); +} + +long oggpackB_bytes(oggpack_buffer *b){ + return oggpack_bytes(b); +} + +long oggpackB_bits(oggpack_buffer *b){ + return oggpack_bits(b); +} + +unsigned char *oggpack_get_buffer(oggpack_buffer *b){ + return(b->buffer); +} + +unsigned char *oggpackB_get_buffer(oggpack_buffer *b){ + return oggpack_get_buffer(b); +} +#endif +/* Self test of the bitwise routines; everything else is based on + them, so they damned well better be solid. */ + +#ifdef _V_SELFTEST +#include + +static int ilog(unsigned int v){ + int ret=0; + while(v){ + ret++; + v>>=1; + } + return(ret); +} + +oggpack_buffer o; +oggpack_buffer r; + +void report(char *in){ + fprintf(stderr,"%s",in); + exit(1); +} + +void cliptest(unsigned long *b,int vals,int bits,int *comp,int compsize){ + long bytes,i; + unsigned char *buffer; + + oggpack_reset(&o); + for(i=0;i +#include +#include "ogg.h" +#include "ivorbiscodec.h" +#include "codec_internal.h" + +#include "window.h" +#include "registry.h" +#include "misc.h" +#include "ffmpeg_stuff.h" +//#include + +static int ilog(unsigned int v){ + int ret=0; + if(v)--v; + while(v){ + ret++; + v>>=1; + } + return(ret); +} + +static ogg_int32_t* _pcmbp[CHANNELS] IBSS_ATTR; +static ogg_int32_t* _pcmret[CHANNELS] IBSS_ATTR; +/* save original pointers returned by malloc so we can free it easily */ +static ogg_int32_t* malloc_pointers[3] = {NULL}; + +/* pcm accumulator examples (not exhaustive): + + <-------------- lW ----------------> + <--------------- W ----------------> +: .....|..... _______________ | +: .''' | '''_--- | |\ | +:.....''' |_____--- '''......| | \_______| +:.................|__________________|_______|__|______| + |<------ Sl ------>| > Sr < |endW + |beginSl |endSl | |endSr + |beginW |endlW |beginSr + + + |< lW >| + <--------------- W ----------------> + | | .. ______________ | + | | ' `/ | ---_ | + |___.'___/`. | ---_____| + |_______|__|_______|_________________| + | >|Sl|< |<------ Sr ----->|endW + | | |endSl |beginSr |endSr + |beginW | |endlW + mult[0] |beginSl mult[n] + + <-------------- lW -----------------> + |<--W-->| +: .............. ___ | | +: .''' |`/ \ | | +:.....''' |/`....\|...| +:.........................|___|___|___| + |Sl |Sr |endW + | | |endSr + | |beginSr + | |endSl + |beginSl + |beginW +*/ + +/* block abstraction setup *********************************************/ + +#ifndef WORD_ALIGN +#define WORD_ALIGN 8 +#endif + +int vorbis_block_init(vorbis_dsp_state *v, vorbis_block *vb){ + memset(vb,0,sizeof(*vb)); + vb->vd=v; + vb->localalloc=0; + vb->localstore=NULL; + + return(0); +} + +void *_vorbis_block_alloc(vorbis_block *vb,long bytes){ + bytes=(bytes+(WORD_ALIGN-1)) & ~(WORD_ALIGN-1); + if(bytes+vb->localtop>vb->localalloc){ + /* can't just _ogg_realloc... there are outstanding pointers */ + if(vb->localstore){ + struct alloc_chain *link=(struct alloc_chain *)_ogg_malloc(sizeof(*link)); + vb->totaluse+=vb->localtop; + link->next=vb->reap; + link->ptr=vb->localstore; + vb->reap=link; + } + /* highly conservative */ + vb->localalloc=bytes; + vb->localstore=_ogg_malloc(vb->localalloc); + vb->localtop=0; + } + { + void *ret=(void *)(((char *)vb->localstore)+vb->localtop); + vb->localtop+=bytes; + return ret; + } +} + +/* reap the chain, pull the ripcord */ +void _vorbis_block_ripcord(vorbis_block *vb){ + /* reap the chain */ + struct alloc_chain *reap=vb->reap; + while(reap){ + struct alloc_chain *next=reap->next; + _ogg_free(reap->ptr); + memset(reap,0,sizeof(*reap)); + _ogg_free(reap); + reap=next; + } + /* consolidate storage */ + if(vb->totaluse){ + vb->localstore=_ogg_realloc(vb->localstore,vb->totaluse+vb->localalloc); + vb->localalloc+=vb->totaluse; + vb->totaluse=0; + } + + /* pull the ripcord */ + vb->localtop=0; + vb->reap=NULL; +} + +int vorbis_block_clear(vorbis_block *vb){ + _vorbis_block_ripcord(vb); + if(vb->localstore)_ogg_free(vb->localstore); + + memset(vb,0,sizeof(*vb)); + return(0); +} + +static int _vds_init(vorbis_dsp_state *v,vorbis_info *vi){ + int i; + long b_size[2]; + + codec_setup_info *ci=(codec_setup_info *)vi->codec_setup; + private_state *b=NULL; + + if(ci==NULL) return 1; + + memset(v,0,sizeof(*v)); + b=(private_state *)(v->backend_state=_ogg_calloc(1,sizeof(*b))); + + v->vi=vi; + b->modebits=ilog(ci->modes); + +#ifdef TREMOR_USE_IRAM + /* allocate IRAM buffer for the PCM data generated by synthesis */ + iram_malloc_init(); + + v->floors = iram_malloc(vi->channels*ci->blocksizes[1]/2*sizeof(ogg_int32_t)); + v->residues[0] = iram_malloc(vi->channels*ci->blocksizes[1]/2*sizeof(ogg_int32_t)); + /* if we can get away with it, put a double buffer into IRAM too, so that + overlap-add runs iram-to-iram and we avoid needing to memcpy */ + v->residues[1] = iram_malloc(vi->channels*ci->blocksizes[1]/2*sizeof(ogg_int32_t)); + if (v->residues[1] == NULL) + v->saved = iram_malloc(vi->channels*ci->blocksizes[1]/4*sizeof(ogg_int32_t)); + +#endif + + if (v->residues[0] == NULL) { + malloc_pointers[0] = _ogg_malloc(vi->channels*ci->blocksizes[1]/2*sizeof(ogg_int32_t)); + v->residues[0] = malloc_pointers[0]; + } + + if (v->residues[1] == NULL && v->saved == NULL) { + malloc_pointers[1] = _ogg_malloc(vi->channels*ci->blocksizes[1]/2*sizeof(ogg_int32_t)); + v->residues[1] = malloc_pointers[1]; + } + + if (v->floors == NULL) { + malloc_pointers[2] = _ogg_malloc(vi->channels*ci->blocksizes[1]/2*sizeof(ogg_int32_t)); + v->floors = malloc_pointers[2]; + } + + /* needed for the first overlap/add */ + if (v->saved) { + memset(v->saved, 0, vi->channels*ci->blocksizes[1]/4*sizeof(ogg_int32_t)); + for (i = 0; i < vi->channels; i++) + v->saved_ptr[i] = v->saved + i*ci->blocksizes[1]/4; + } else { + memset(v->residues[1], 0, vi->channels*ci->blocksizes[1]/2*sizeof(ogg_int32_t)); + for (i = 0; i < vi->channels; i++) + v->saved_ptr[i] = v->residues[1] + i*ci->blocksizes[1]/2; + } + + /* Vorbis I uses only window type 0 */ + b_size[0]=ci->blocksizes[0]/2; + b_size[1]=ci->blocksizes[1]/2; + b->window[0]=_vorbis_window(0,b_size[0]); + b->window[1]=_vorbis_window(0,b_size[1]); + +#ifdef TREMOR_USE_IRAM + /* allocate IRAM buffer for window tables too, if sufficient iram available */ + /* give preference to the larger window over the smaller window + (on the assumption that both windows are equally likely used) */ + LOOKUP_TNC *iramposw; + for(i=1; i>=0; i--){ + iramposw=iram_malloc(b_size[i]*sizeof(LOOKUP_TNC)); + if(iramposw!=NULL) { + memcpy(iramposw, b->window[i], b_size[i]*sizeof(LOOKUP_TNC)); + b->window[i]=iramposw; + } + } +#endif + + /* finish the codebooks */ + if(!ci->fullbooks){ + ci->fullbooks=(codebook *)_ogg_calloc(ci->books,sizeof(*ci->fullbooks)); + for(i=0;ibooks;i++){ + if(ci->book_param[i]==NULL) + goto abort_books; + if(vorbis_book_init_decode(ci->fullbooks+i,ci->book_param[i])) + goto abort_books; + /* decode codebooks are now standalone after init */ + vorbis_staticbook_destroy(ci->book_param[i]); + ci->book_param[i]=NULL; + } + } + + v->pcm_storage=ci->blocksizes[1]; + v->pcmret=_pcmret; + v->pcmb=_pcmbp; + + _pcmbp[0]=NULL; + _pcmbp[1]=NULL; + + /* all 1 (large block) or 0 (small block) */ + /* explicitly set for the sake of clarity */ + v->lW=0; /* previous window size */ + v->W=0; /* current window size */ + + /* initialize all the mapping/backend lookups */ + b->mode=(vorbis_look_mapping **)_ogg_calloc(ci->modes,sizeof(*b->mode)); + for(i=0;imodes;i++){ + int mapnum=ci->mode_param[i]->mapping; + int maptype=ci->map_type[mapnum]; + b->mode[i]=_mapping_P[maptype]->look(v,ci->mode_param[i], + ci->map_param[mapnum]); + } + + return(0); +abort_books: + for(i=0;ibooks;i++){ + if(ci->book_param[i]!=NULL){ + vorbis_staticbook_destroy(ci->book_param[i]); + ci->book_param[i]=NULL; + } + } + vorbis_dsp_clear(v); + return -1; +} + +int vorbis_synthesis_restart(vorbis_dsp_state *v){ + vorbis_info *vi=v->vi; + codec_setup_info *ci; + + if(!v->backend_state)return -1; + if(!vi)return -1; + ci=vi->codec_setup; + if(!ci)return -1; + + v->pcm_current=0; + + v->pcm_returned=-1; + v->granulepos=-1; + v->sequence=-1; + ((private_state *)(v->backend_state))->sample_count=-1; + + return(0); +} + +int vorbis_synthesis_init(vorbis_dsp_state *v,vorbis_info *vi){ + if(_vds_init(v,vi))return 1; + vorbis_synthesis_restart(v); + + return 0; +} + +void vorbis_dsp_clear(vorbis_dsp_state *v){ + int i; + if(v){ + vorbis_info *vi=v->vi; + codec_setup_info *ci=(codec_setup_info *)(vi?vi->codec_setup:NULL); + private_state *b=(private_state *)v->backend_state; + + if(vi != NULL) + { + /* pcm buffer came from oggmalloc rather than iram */ + for(i=0;i<3;i++) + if(malloc_pointers[i]) { + _ogg_free(malloc_pointers[i]); + malloc_pointers[i] = NULL; + } + } + + /* free mode lookups; these are actually vorbis_look_mapping structs */ + if(ci){ + for(i=0;imodes;i++){ + int mapnum=ci->mode_param[i]->mapping; + int maptype=ci->map_type[mapnum]; + if(b && b->mode)_mapping_P[maptype]->free_look(b->mode[i]); + } + } + + if(b){ + if(b->mode)_ogg_free(b->mode); + _ogg_free(b); + } + + memset(v,0,sizeof(*v)); + } +} + +/* Unlike in analysis, the window is only partially applied for each + block. The time domain envelope is not yet handled at the point of + calling (as it relies on the previous block). */ + +int vorbis_synthesis_blockin(vorbis_dsp_state *v,vorbis_block *vb) + ICODE_ATTR; +int vorbis_synthesis_blockin(vorbis_dsp_state *v,vorbis_block *vb){ + vorbis_info *vi=v->vi; + codec_setup_info *ci=(codec_setup_info *)vi->codec_setup; + private_state *b=v->backend_state; + + if(v->pcm_current>v->pcm_returned && v->pcm_returned!=-1)return(OV_EINVAL); + + v->lW=v->W; + v->W=vb->W; + v->nW=-1; + + if((v->sequence==-1)|| + (v->sequence+1 != vb->sequence)){ + v->granulepos=-1; /* out of sequence; lose count */ + b->sample_count=-1; + } + + v->sequence=vb->sequence; + int n=ci->blocksizes[v->W]/2; + int ln=ci->blocksizes[v->lW]/2; + + if(LIKELY(vb->pcmend != 0)){ /* no pcm to process if vorbis_synthesis_trackonly + was called on block */ + window_overlap_add(ci->blocksizes[v->W], ci->blocksizes[v->lW], + ci->blocksizes[0], ci->blocksizes[1], vi->channels, + b->window[v->W & v->lW], v); + /* deal with initial packet state; we do this using the explicit + pcm_returned==-1 flag otherwise we're sensitive to first block + being short or long */ + + if(v->pcm_returned==-1){ + v->pcm_returned=0; + v->pcm_current=0; + }else{ + v->pcm_returned=0; + v->pcm_current=(n+ln)/2; + } + } + + /* track the frame number... This is for convenience, but also + making sure our last packet doesn't end with added padding. If + the last packet is partial, the number of samples we'll have to + return will be past the vb->granulepos. + + This is not foolproof! It will be confused if we begin + decoding at the last page after a seek or hole. In that case, + we don't have a starting point to judge where the last frame + is. For this reason, vorbisfile will always try to make sure + it reads the last two marked pages in proper sequence */ + + if(b->sample_count==-1){ + b->sample_count=0; + }else{ + b->sample_count+=(n+ln)/2; + } + + if(v->granulepos==-1){ + if(vb->granulepos!=-1){ /* only set if we have a position to set to */ + + v->granulepos=vb->granulepos; + + /* is this a short page? */ + if(b->sample_count>v->granulepos){ + /* corner case; if this is both the first and last audio page, + then spec says the end is cut, not beginning */ + if(vb->eofflag){ + /* trim the end */ + /* no preceeding granulepos; assume we started at zero (we'd + have to in a short single-page stream) */ + /* granulepos could be -1 due to a seek, but that would result + in a long coun`t, not short count */ + + v->pcm_current-=(b->sample_count-v->granulepos); + }else{ + /* trim the beginning */ + v->pcm_returned+=(b->sample_count-v->granulepos); + if(v->pcm_returned>v->pcm_current) + v->pcm_returned=v->pcm_current; + } + + } + + } + }else{ + v->granulepos+=(n+ln)/2; + if(vb->granulepos!=-1 && v->granulepos!=vb->granulepos){ + + if(v->granulepos>vb->granulepos){ + long extra=v->granulepos-vb->granulepos; + + if(extra) + if(vb->eofflag){ + /* partial last frame. Strip the extra samples off */ + v->pcm_current-=extra; + } /* else {Shouldn't happen *unless* the bitstream is out of + spec. Either way, believe the bitstream } */ + } /* else {Shouldn't happen *unless* the bitstream is out of + spec. Either way, believe the bitstream } */ + v->granulepos=vb->granulepos; + } + } + + /* Update, cleanup */ + + if(vb->eofflag)v->eofflag=1; + return(0); +} + +/* pcm==NULL indicates we just want the pending samples, no more */ +int vorbis_synthesis_pcmout(vorbis_dsp_state *v,ogg_int32_t ***pcm) ICODE_ATTR; +int vorbis_synthesis_pcmout(vorbis_dsp_state *v,ogg_int32_t ***pcm){ + vorbis_info *vi=v->vi; + if(v->pcm_returned>-1 && v->pcm_returnedpcm_current){ + if(pcm){ + int i; + for(i=0;ichannels;i++) + v->pcmret[i]=v->pcmb[i]+v->pcm_returned; + *pcm=v->pcmret; + } + return(v->pcm_current-v->pcm_returned); + } + return 0; +} + +int vorbis_synthesis_read(vorbis_dsp_state *v,int bytes){ + if(bytes && v->pcm_returned+bytes>v->pcm_current)return(OV_EINVAL); + v->pcm_returned+=bytes; + return(0); +} + diff --git a/lib/rbcodec/codecs/libtremor/codebook.c b/lib/rbcodec/codecs/libtremor/codebook.c new file mode 100644 index 0000000000..7087f0a323 --- /dev/null +++ b/lib/rbcodec/codecs/libtremor/codebook.c @@ -0,0 +1,587 @@ +/******************************************************************** + * * + * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * + * * + * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * + * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * + * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * + * * + * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * + * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * + * * + ******************************************************************** + + function: basic codebook pack/unpack/code/decode operations + + ********************************************************************/ + +#include "config-tremor.h" +#include +#include +#include "ogg.h" +#include "ivorbiscodec.h" +#include "codebook.h" +#include "misc.h" +#include "os.h" + +/* unpacks a codebook from the packet buffer into the codebook struct, + readies the codebook auxiliary structures for decode *************/ +static_codebook *vorbis_staticbook_unpack(oggpack_buffer *opb){ + long i,j; + static_codebook *s=_ogg_calloc(1,sizeof(*s)); + + /* make sure alignment is correct */ + if(oggpack_read(opb,24)!=0x564342)goto _eofout; + + /* first the basic parameters */ + s->dim=oggpack_read(opb,16); + s->entries=oggpack_read(opb,24); + if(s->entries==-1)goto _eofout; + + if(_ilog(s->dim)+_ilog(s->entries)>24)goto _eofout; + + /* codeword ordering.... length ordered or unordered? */ + switch((int)oggpack_read(opb,1)){ + case 0:{ + long unused; + /* allocated but unused entries? */ + unused=oggpack_read(opb,1); + if((s->entries*(unused?1:5)+7)>>3>opb->storage-oggpack_bytes(opb)) + goto _eofout; + /* unordered */ + s->lengthlist=(long *)_ogg_malloc(sizeof(*s->lengthlist)*s->entries); + + /* allocated but unused entries? */ + if(unused){ + /* yes, unused entries */ + + for(i=0;ientries;i++){ + if(oggpack_read(opb,1)){ + long num=oggpack_read(opb,5); + if(num==-1)goto _eofout; + s->lengthlist[i]=num+1; + }else + s->lengthlist[i]=0; + } + }else{ + /* all entries used; no tagging */ + for(i=0;ientries;i++){ + long num=oggpack_read(opb,5); + if(num==-1)goto _eofout; + s->lengthlist[i]=num+1; + } + } + + break; + } + case 1: + /* ordered */ + { + long length=oggpack_read(opb,5)+1; + if(length==0)goto _eofout; + s->lengthlist=(long *)_ogg_malloc(sizeof(*s->lengthlist)*s->entries); + + for(i=0;ientries;){ + long num=oggpack_read(opb,_ilog(s->entries-i)); + if(num==-1)goto _eofout; + if(length>32 || num>s->entries-i || + (num>0 && (num-1)>>(length>>1)>>((length+1)>>1))>0){ + goto _errout; + } + for(j=0;jlengthlist[i]=length; + length++; + } + } + break; + default: + /* EOF */ + goto _eofout; + } + + /* Do we have a mapping to unpack? */ + switch((s->maptype=oggpack_read(opb,4))){ + case 0: + /* no mapping */ + break; + case 1: case 2: + /* implicitly populated value mapping */ + /* explicitly populated value mapping */ + + s->q_min=oggpack_read(opb,32); + s->q_delta=oggpack_read(opb,32); + s->q_quant=oggpack_read(opb,4)+1; + s->q_sequencep=oggpack_read(opb,1); + if(s->q_sequencep==-1)goto _eofout; + + { + int quantvals=0; + switch(s->maptype){ + case 1: + quantvals=(s->dim==0?0:_book_maptype1_quantvals(s)); + break; + case 2: + quantvals=s->entries*s->dim; + break; + } + + /* quantized values */ + if((quantvals*s->q_quant+7)>>3>opb->storage-oggpack_bytes(opb)) + goto _eofout; + s->quantlist=(long *)_ogg_malloc(sizeof(*s->quantlist)*quantvals); + for(i=0;iquantlist[i]=oggpack_read(opb,s->q_quant); + + if(quantvals&&s->quantlist[quantvals-1]==-1)goto _eofout; + } + break; + default: + goto _errout; + } + + /* all set */ + return(s); + + _errout: + _eofout: + vorbis_staticbook_destroy(s); + return(NULL); +} + +/* the 'eliminate the decode tree' optimization actually requires the + codewords to be MSb first, not LSb. This is an annoying inelegancy + (and one of the first places where carefully thought out design + turned out to be wrong; Vorbis II and future Ogg codecs should go + to an MSb bitpacker), but not actually the huge hit it appears to + be. The first-stage decode table catches most words so that + bitreverse is not in the main execution path. */ + +static inline ogg_uint32_t bitreverse(register ogg_uint32_t x) +{ + unsigned tmp, ret; +#ifdef _ARM_ASSEM_ +#if ARM_ARCH >= 6 + unsigned mask = 0x0f0f0f0f; +#else + unsigned mask = 0x00ff00ff; +#endif + asm ( +#if ARM_ARCH >= 6 + "rev %[r], %[x] \n" /* swap halfwords and bytes */ + "and %[t], %[m], %[r] \n" /* Sequence is one instruction */ + "eor %[r], %[t], %[r] \n" /* longer than on <= ARMv5, but */ + "mov %[t], %[t], lsl #4 \n" /* interlock free */ + "orr %[r], %[t], %[r], lsr #4\n" /* nibbles swapped */ + "eor %[m], %[m], %[m], lsl #2\n" /* mask = 0x33333333 */ + "and %[t], %[m], %[r] \n" + "eor %[r], %[t], %[r] \n" + "mov %[t], %[t], lsl #2 \n" + "orr %[r], %[t], %[r], lsr #2\n" /* dibits swapped */ + "eor %[m], %[m], %[m], lsl #1\n" /* mask = 0x55555555 */ + "and %[t], %[m], %[r] \n" + "eor %[r], %[t], %[r] \n" + "mov %[t], %[t], lsl #1 \n" + "orr %[r], %[t], %[r], lsr #1\n" /* bits swapped */ +#else /* ARM_ARCH <= 5 */ + "mov %[r], %[x], ror #16 \n" /* swap halfwords */ + "and %[t], %[m], %[r], lsr #8\n" + "eor %[r], %[r], %[t], lsl #8\n" + "orr %[r], %[t], %[r], lsl #8\n" /* bytes swapped */ + "eor %[m], %[m], %[m], lsl #4\n" /* mask = 0x0f0f0f0f */ + "and %[t], %[m], %[r], lsr #4\n" + "eor %[r], %[r], %[t], lsl #4\n" + "orr %[r], %[t], %[r], lsl #4\n" /* nibbles swapped */ + "eor %[m], %[m], %[m], lsl #2\n" /* mask = 0x33333333 */ + "and %[t], %[m], %[r], lsr #2\n" + "eor %[r], %[r], %[t], lsl #2\n" + "orr %[r], %[t], %[r], lsl #2\n" /* dibits swapped */ + "eor %[m], %[m], %[m], lsl #1\n" /* mask = 0x55555555 */ + "and %[t], %[m], %[r], lsr #1\n" + "eor %[r], %[r], %[t], lsl #1\n" + "orr %[r], %[t], %[r], lsl #1\n" /* bits swapped */ +#endif /* ARM_ARCH */ + : /* outputs */ + [m]"+r"(mask), + [r]"=r"(ret), + [t]"=r"(tmp) + : /* inputs */ + [x]"r"(x) + ); +#else /* !_ARM_ASSEM_ */ + + ret = (x>>16) | (x<<16); + tmp = ret & 0x00ff00ff; + ret ^= tmp; + ret = (ret >> 8) | (tmp << 8); /* bytes swapped */ + tmp = ret & 0x0f0f0f0f; + ret ^= tmp; + ret = (ret >> 4) | (tmp << 4); /* 4-bit units swapped */ + tmp = ret & 0x33333333; + ret ^= tmp; + ret = (ret >> 2) | (tmp << 2); /* 2-bit units swapped */ + tmp = ret & 0x55555555; + ret ^= tmp; + ret = (ret >> 1) | (tmp << 1); /* done */ +#endif /* !_ARM_ASSEM_ */ + return ret; +} + +static inline long bisect_codelist(long lo, long hi, ogg_uint32_t cache, + const ogg_uint32_t *codelist) +{ + ogg_uint32_t testword=bitreverse(cache); + long p; + while(LIKELY(p = (hi-lo) >> 1) > 0){ + if(codelist[lo+p] > testword) + hi -= p; + else + lo += p; + } + return lo; +} + +STIN long decode_packed_entry_number(codebook *book, + oggpack_buffer *b){ + int read=book->dec_maxlength; + long lo,hi; + long lok = oggpack_look(b,book->dec_firsttablen); + + if (LIKELY(lok >= 0)) { + ogg_int32_t entry = book->dec_firsttable[lok]; + if(UNLIKELY(entry < 0)){ + lo=(entry>>15)&0x7fff; + hi=book->used_entries-(entry&0x7fff); + }else{ + oggpack_adv(b, book->dec_codelengths[entry-1]); + return(entry-1); + } + }else{ + lo=0; + hi=book->used_entries; + } + + lok = oggpack_look(b, read); + + while(lok<0 && read>1) + lok = oggpack_look(b, --read); + + if(lok<0){ + oggpack_adv(b,1); /* force eop */ + return -1; + } + + /* bisect search for the codeword in the ordered list */ + { + lo = bisect_codelist(lo, hi, lok, book->codelist); + + if(book->dec_codelengths[lo]<=read){ + oggpack_adv(b, book->dec_codelengths[lo]); + return(lo); + } + } + + oggpack_adv(b, read+1); + return(-1); +} + +static long decode_packed_block(codebook *book, oggpack_buffer *b, + long *buf, int n){ + long *bufptr = buf; + long *bufend = buf + n; + + while (bufptrendbyte < b->storage - 8) { + ogg_uint32_t *ptr; + unsigned long bit, bitend; + unsigned long adr; + ogg_uint32_t cache = 0; + int cachesize = 0; + const unsigned int cachemask = (1<dec_firsttablen)-1; + const int book_dec_maxlength = book->dec_maxlength; + const ogg_uint32_t *book_dec_firsttable = book->dec_firsttable; + const long book_used_entries = book->used_entries; + const ogg_uint32_t *book_codelist = book->codelist; + const char *book_dec_codelengths = book->dec_codelengths; + + adr = (unsigned long)b->ptr; + bit = (adr&3)*8+b->endbit; + ptr = (ogg_uint32_t*)(adr&~3); + bitend = ((adr&3)+(b->storage-b->endbyte))*8; + while (bufptr=bitend) + break; + bit-=cachesize; + cache = letoh32(ptr[bit>>5]); + if (bit&31) { + cache >>= (bit&31); + cache |= letoh32(ptr[(bit>>5)+1]) << (32-(bit&31)); + } + cachesize=32; + bit+=32; + } + + ogg_int32_t entry = book_dec_firsttable[cache&cachemask]; + if(UNLIKELY(entry < 0)){ + const long lo = (entry>>15)&0x7fff, hi = book_used_entries-(entry&0x7fff); + entry = bisect_codelist(lo, hi, cache, book_codelist); + }else + entry--; + + *bufptr++ = entry; + int l = book_dec_codelengths[entry]; + cachesize -= l; + cache >>= l; + } + + adr=(unsigned long)b->ptr; + bit-=(adr&3)*8+cachesize; + b->endbyte+=bit/8; + b->ptr+=bit/8; + b->endbit=bit&7; + } else { + long r = decode_packed_entry_number(book, b); + if (r == -1) return bufptr-buf; + *bufptr++ = r; + } + } + return n; +} + +/* Decode side is specced and easier, because we don't need to find + matches using different criteria; we simply read and map. There are + two things we need to do 'depending': + + We may need to support interleave. We don't really, but it's + convenient to do it here rather than rebuild the vector later. + + Cascades may be additive or multiplicitive; this is not inherent in + the codebook, but set in the code using the codebook. Like + interleaving, it's easiest to do it here. + addmul==0 -> declarative (set the value) + addmul==1 -> additive + addmul==2 -> multiplicitive */ + +/* returns the [original, not compacted] entry number or -1 on eof *********/ +long vorbis_book_decode(codebook *book, oggpack_buffer *b){ + if(book->used_entries>0){ + long packed_entry=decode_packed_entry_number(book,b); + if(packed_entry>=0) + return(book->dec_index[packed_entry]); + } + + /* if there's no dec_index, the codebook unpacking isn't collapsed */ + return(-1); +} + +/* returns 0 on OK or -1 on eof *************************************/ +/* decode vector / dim granularity gaurding is done in the upper layer */ +long vorbis_book_decodevs_add(codebook *book,ogg_int32_t *a, + oggpack_buffer *b,int n,int point){ + if(book->used_entries>0){ + int step=n/book->dim; + long *entry = (long *)alloca(sizeof(*entry)*step); + ogg_int32_t **t = (ogg_int32_t **)alloca(sizeof(*t)*step); + int i,j,o; + int shift=point-book->binarypoint; + + if(shift>=0){ + for (i = 0; i < step; i++) { + entry[i]=decode_packed_entry_number(book,b); + if(entry[i]==-1)return(-1); + t[i] = book->valuelist+entry[i]*book->dim; + } + for(i=0,o=0;idim;i++,o+=step) + for (j=0;j>shift; + }else{ + for (i = 0; i < step; i++) { + entry[i]=decode_packed_entry_number(book,b); + if(entry[i]==-1)return(-1); + t[i] = book->valuelist+entry[i]*book->dim; + } + for(i=0,o=0;idim;i++,o+=step) + for (j=0;jused_entries>0){ + int i,j,entry; + ogg_int32_t *t; + int shift=point-book->binarypoint; + + if(shift>=0){ + for(i=0;ivaluelist+entry*book->dim; + for (j=0;jdim;) + a[i++]+=t[j++]>>shift; + } + }else{ + shift = -shift; + for(i=0;ivaluelist+entry*book->dim; + for (j=0;jdim;) + a[i++]+=t[j++]< internally rather than in the upper layer (called only by + floor0) */ +long vorbis_book_decodev_set(codebook *book,ogg_int32_t *a, + oggpack_buffer *b,int n,int point){ + if(book->used_entries>0){ + int i,j,entry; + ogg_int32_t *t; + int shift=point-book->binarypoint; + + if(shift>=0){ + + for(i=0;ivaluelist+entry*book->dim; + for (j=0;idim;){ + a[i++]=t[j++]>>shift; + } + } + }else{ + shift = -shift; + for(i=0;ivaluelist+entry*book->dim; + for (j=0;idim;){ + a[i++]=t[j++]<binarypoint; + long entries[32]; + ogg_int32_t *p0 = &(a[0][offset]); + ogg_int32_t *p1 = &(a[1][offset]); + const unsigned long dim = book->dim; + const ogg_int32_t * const vlist = book->valuelist; + + if(shift>=0){ + while(n>0){ + chunk=32; + if (16*dim>n) + chunk=(n*2-1)/dim + 1; + read = decode_packed_block(book,b,entries,chunk); + for(k=0;k>shift; + *p1++ += *t++>>shift; + }while(t0){ + chunk=32; + if (16*dim>n) + chunk=(n*2-1)/dim + 1; + read = decode_packed_block(book,b,entries,chunk); + for(k=0;kused_entries>0)){ + long i,j,k,chunk,read; + int chptr=0; + int shift=point-book->binarypoint; + long entries[32]; + + if (!(book->dim&1) && ch==2) + return vorbis_book_decodevv_add_2ch_even(book,a,offset,b,n,point); + + if(shift>=0){ + + for(i=offset;idim>(offset+n-i)*ch) + chunk=((offset+n-i)*ch+book->dim-1)/book->dim; + read = decode_packed_block(book,b,entries,chunk); + for(k=0;kvaluelist+entries[k]*book->dim; + for (j=0;jdim;j++){ + a[chptr++][i]+=t[j]>>shift; + if(chptr==ch){ + chptr=0; + i++; + } + } + } + if (readdim>(offset+n-i)*ch) + chunk=((offset+n-i)*ch+book->dim-1)/book->dim; + read = decode_packed_block(book,b,entries,chunk); + for(k=0;kvaluelist+entries[k]*book->dim; + for (j=0;jdim;j++){ + a[chptr++][i]+=t[j]<value mapping to be done. + + If encode-side mapping must be done (and thus the entry needs to be + hunted), the auxiliary encode pointer will point to a decision + tree. This is true of both VQ and huffman, but is mostly useful + with VQ. + +*/ + +typedef struct static_codebook{ + long dim; /* codebook dimensions (elements per vector) */ + long entries; /* codebook entries */ + long *lengthlist; /* codeword lengths in bits */ + + /* mapping ***************************************************************/ + int maptype; /* 0=none + 1=implicitly populated values from map column + 2=listed arbitrary values */ + + /* The below does a linear, single monotonic sequence mapping. */ + long q_min; /* packed 32 bit float; quant value 0 maps to minval */ + long q_delta; /* packed 32 bit float; val 1 - val 0 == delta */ + int q_quant; /* bits: 0 < quant <= 16 */ + int q_sequencep; /* bitflag */ + + long *quantlist; /* map == 1: (int)(entries^(1/dim)) element column map + map == 2: list of dim*entries quantized entry vals + */ +} static_codebook; + +typedef struct codebook{ + long dim; /* codebook dimensions (elements per vector) */ + long entries; /* codebook entries */ + long used_entries; /* populated codebook entries */ + + /* the below are ordered by bitreversed codeword and only used + entries are populated */ + int binarypoint; + ogg_int32_t *valuelist; /* list of dim*entries actual entry values */ + ogg_uint32_t *codelist; /* list of bitstream codewords for each entry */ + + int *dec_index; + char *dec_codelengths; + ogg_uint32_t *dec_firsttable; + int dec_firsttablen; + int dec_maxlength; + + long q_min; /* packed 32 bit float; quant value 0 maps to minval */ + long q_delta; /* packed 32 bit float; val 1 - val 0 == delta */ + +} codebook; + +extern void vorbis_staticbook_destroy(static_codebook *b); +extern int vorbis_book_init_decode(codebook *dest,const static_codebook *source); + +extern void vorbis_book_clear(codebook *b); +extern long _book_maptype1_quantvals(const static_codebook *b); + +extern static_codebook *vorbis_staticbook_unpack(oggpack_buffer *b); + +extern long vorbis_book_decode(codebook *book, oggpack_buffer *b); +extern long vorbis_book_decodevs_add(codebook *book, ogg_int32_t *a, + oggpack_buffer *b,int n,int point); +extern long vorbis_book_decodev_set(codebook *book, ogg_int32_t *a, + oggpack_buffer *b,int n,int point); +extern long vorbis_book_decodev_add(codebook *book, ogg_int32_t *a, + oggpack_buffer *b,int n,int point); +extern long vorbis_book_decodevv_add(codebook *book, ogg_int32_t **a, + long off,int ch, + oggpack_buffer *b,int n,int point); + +extern int _ilog(unsigned int v); + + +#endif diff --git a/lib/rbcodec/codecs/libtremor/codec_internal.h b/lib/rbcodec/codecs/libtremor/codec_internal.h new file mode 100644 index 0000000000..3cbd7cde89 --- /dev/null +++ b/lib/rbcodec/codecs/libtremor/codec_internal.h @@ -0,0 +1,93 @@ +/******************************************************************** + * * + * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * + * * + * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * + * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * + * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * + * * + * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * + * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * + * * + ******************************************************************** + + function: libvorbis codec headers + + ********************************************************************/ + +#ifndef _V_CODECI_H_ +#define _V_CODECI_H_ + +#include "codebook.h" + +typedef void vorbis_look_mapping; +typedef void vorbis_look_floor; +typedef void vorbis_look_residue; +typedef void vorbis_look_transform; + +/* mode ************************************************************/ +typedef struct { + int blockflag; + int windowtype; + int transformtype; + int mapping; +} vorbis_info_mode; + +typedef void vorbis_info_floor; +typedef void vorbis_info_residue; +typedef void vorbis_info_mapping; + +typedef struct private_state { + /* local lookup storage */ + const void *window[2]; + + /* backend lookups are tied to the mode, not the backend or naked mapping */ + int modebits; + vorbis_look_mapping **mode; + + ogg_int64_t sample_count; + +} private_state; + +/* codec_setup_info contains all the setup information specific to the + specific compression/decompression mode in progress (eg, + psychoacoustic settings, channel setup, options, codebook + etc). +*********************************************************************/ + +typedef struct codec_setup_info { + + /* Vorbis supports only short and long blocks, but allows the + encoder to choose the sizes */ + + int blocksizes_nbits[2]; + long blocksizes[2]; /* = 1<= 0) { + err += ady - adx; + y += sy; + buf[x] = MULT31_SHIFT15(buf[x],lookup[y]); + x++; + } + buf[x] = MULT31_SHIFT15(buf[x],lookup[y]); + } + if (x <= 0) { + if (err + ady >= 0) + y += sy; + buf[x] = MULT31_SHIFT15(buf[x],lookup[y]); + } +} + +static inline void render_line(int x0, int y0, int x1, int y1, + const ogg_int32_t *lookup, ogg_int32_t *buf) +{ + int dy = y1 - y0; + int adx = x1 - x0; + int ady = abs(dy); + int sy = dy < 0 ? -1 : 1; + buf[x0] = MULT31_SHIFT15(buf[x0],lookup[y0]); + if (ady*2 <= adx) { // optimized common case + render_line_unrolled(x0, y0, x1, sy, ady, adx, lookup, buf); + } else { + int base = dy / adx; + int x = x0; + int y = y0; + int err = -adx; + ady -= abs(base) * adx; + while (++x < x1) { + y += base; + err += ady; + if (err >= 0) { + err -= adx; + y += sy; + } + buf[x] = MULT31_SHIFT15(buf[x],lookup[y]); + } + } +} + +#ifndef INCL_OPTIMIZED_VECTOR_FMUL_WINDOW +#define INCL_OPTIMIZED_VECTOR_FMUL_WINDOW +static inline void ff_vector_fmul_window_c(ogg_int32_t *dst, const ogg_int32_t *src0, + const ogg_int32_t *src1, const ogg_int32_t *win, int len){ + int i,j; + dst += len; + win += len; + src0+= len; + for(i=-len, j=len-1; i<0; i++, j--) { + ogg_int32_t s0 = src0[i]; + ogg_int32_t s1 = src1[j]; + ogg_int32_t wi = win[i]; + ogg_int32_t wj = win[j]; + XNPROD31(s0, s1, wj, wi, &dst[i], &dst[j]); + /* + dst[i] = MULT31(s0,wj) - MULT31(s1,wi); + dst[j] = MULT31(s0,wi) + MULT31(s1,wj); + */ + } +} +#endif + +static inline void copy_normalize(ogg_int32_t *dst, ogg_int32_t *src, int len) +{ + memcpy(dst, src, len * sizeof(ogg_int32_t)); +} + +static inline void window_overlap_add(unsigned int blocksize, unsigned int lastblock, + unsigned int bs0, unsigned int bs1, int ch, + const ogg_int32_t *win, vorbis_dsp_state *v) +{ + unsigned retlen = (blocksize + lastblock) / 4; + int j; + for (j = 0; j < ch; j++) { + ogg_int32_t *residue = v->residues[v->ri] + j * blocksize / 2; + ogg_int32_t *saved = v->saved_ptr[j]; + ogg_int32_t *ret = v->floors + j * retlen; + ogg_int32_t *buf = residue; + + if (v->W == v->lW) { + ff_vector_fmul_window_c(ret, saved, buf, win, blocksize / 4); + } else if (v->W > v->lW) { + ff_vector_fmul_window_c(ret, saved, buf, win, bs0 / 4); + copy_normalize(ret+bs0/2, buf+bs0/4, (bs1-bs0)/4); + } else { + copy_normalize(ret, saved, (bs1 - bs0) / 4); + ff_vector_fmul_window_c(ret + (bs1 - bs0) / 4, saved + (bs1 - bs0) / 4, buf, win, bs0 / 4); + } + if (v->residues[1] == NULL) { + memcpy(saved, buf + blocksize / 4, blocksize / 4 * sizeof(ogg_int32_t)); + v->saved_ptr[j] = v->saved + j * bs1 / 4; + } else { + v->saved_ptr[j] = buf + blocksize / 4; + } + + v->pcmb[j] = ret; + } + + if (v->residues[1] != NULL) { + v->ri ^= 1; + } +} diff --git a/lib/rbcodec/codecs/libtremor/floor0.c b/lib/rbcodec/codecs/libtremor/floor0.c new file mode 100644 index 0000000000..cd0a9f89f6 --- /dev/null +++ b/lib/rbcodec/codecs/libtremor/floor0.c @@ -0,0 +1,444 @@ +/******************************************************************** + * * + * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * + * * + * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * + * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * + * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * + * * + * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * + * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * + * * + ******************************************************************** + + function: floor backend 0 implementation + + ********************************************************************/ + +#include "config-tremor.h" +#include +#include +#include "ogg.h" +#include "ivorbiscodec.h" +#include "codec_internal.h" +#include "registry.h" +#include "codebook.h" +#include "misc.h" +#include "os.h" + +#define LSP_FRACBITS 14 + +typedef struct { + long n; + int ln; + int m; + int *linearmap; + + vorbis_info_floor0 *vi; + ogg_int32_t *lsp_look; + +} vorbis_look_floor0; + +/*************** LSP decode ********************/ + +#include "lsp_lookup.h" + +/* interpolated 1./sqrt(p) where .5 <= a < 1. (.100000... to .111111...) in + 16.16 format + returns in m.8 format */ + +static const long ADJUST_SQRT2[2] ={8192,5792}; +static inline ogg_int32_t vorbis_invsqlook_i(long a,long e){ + long i=(a&0x7fff)>>(INVSQ_LOOKUP_I_SHIFT-1); + long d=a&INVSQ_LOOKUP_I_MASK; /* 0.10 */ + long val=INVSQ_LOOKUP_I[i]- /* 1.16 */ + ((INVSQ_LOOKUP_IDel[i]*d)>>INVSQ_LOOKUP_I_SHIFT); /* result 1.16 */ + val*=ADJUST_SQRT2[e&1]; + e=(e>>1)+21; + return(val>>e); +} + +/* interpolated lookup based fromdB function, domain -140dB to 0dB only */ +/* a is in n.12 format */ +static inline ogg_int32_t vorbis_fromdBlook_i(long a){ + int i=(-a)>>(12-FROMdB2_SHIFT); + if(i<0) return 0x7fffffff; + if(i>=(FROMdB_LOOKUP_SZ<>FROMdB_SHIFT] * FROMdB2_LOOKUP[i&FROMdB2_MASK]; +} + +/* interpolated lookup based cos function, domain 0 to PI only */ +/* a is in 0.16 format, where 0==0, 2^^16-1==PI, return 0.14 */ +static inline ogg_int32_t vorbis_coslook_i(long a){ + int i=a>>COS_LOOKUP_I_SHIFT; + int d=a&COS_LOOKUP_I_MASK; + return COS_LOOKUP_I[i]- ((d*(COS_LOOKUP_I[i]-COS_LOOKUP_I[i+1]))>> + COS_LOOKUP_I_SHIFT); +} + +/* interpolated lookup based cos function */ +/* a is in 0.16 format, where 0==0, 2^^16==PI, return .LSP_FRACBITS */ +static inline ogg_int32_t vorbis_coslook2_i(long a){ + a=a&0x1ffff; + + if(a>0x10000)a=0x20000-a; + { + int i=a>>COS_LOOKUP_I_SHIFT; + int d=a&COS_LOOKUP_I_MASK; + a=((COS_LOOKUP_I[i]<> + (COS_LOOKUP_I_SHIFT-LSP_FRACBITS+14); + } + + return(a); +} + +static const int barklook[28] ={ + 0,100,200,301, 405,516,635,766, + 912,1077,1263,1476, 1720,2003,2333,2721, + 3184,3742,4428,5285, 6376,7791,9662,12181, + 15624,20397,27087,36554 +}; + +/* used in init only; interpolate the long way */ +static inline ogg_int32_t toBARK(int n){ + int i; + for(i=0;i<27;i++) + if(n>=barklook[i] && n>10)*0x517d)>>14; +#endif + + /* safeguard against a malicious stream */ + if(val<0 || (val>>COS_LOOKUP_I_SHIFT)>=COS_LOOKUP_I_SZ){ + memset(curve,0,sizeof(*curve)*n); + return; + } + + ilsp[i]=vorbis_coslook_i(val); + } + + i=0; + while(i>16); + qi=((qi*qi)>>16); + + if(m&1){ + qexp= qexp*2-28*((m+1)>>1)+m; + pi*=(1<<14)-((wi*wi)>>14); + qi+=pi>>14; + }else{ + qexp= qexp*2-13*m; + + pi*=(1<<14)-wi; + qi*=(1<<14)+wi; + + qi=(qi+pi)>>14; + } + + if(qi&0xffff0000){ /* checks for 1.xxxxxxxxxxxxxxxx */ + qi>>=1; qexp++; + }else + lsp_norm_asm(&qi,&qexp); + +#else + + j=1; + if(m>1){ + qi*=labs(ilsp[0]-wi); + pi*=labs(ilsp[1]-wi); + + for(j+=2;j>25])) + if(!(shift=MLOOP_2[(pi|qi)>>19])) + shift=MLOOP_3[(pi|qi)>>16]; + qi=(qi>>shift)*labs(ilsp[j-1]-wi); + pi=(pi>>shift)*labs(ilsp[j]-wi); + qexp+=shift; + } + } + if(!(shift=MLOOP_1[(pi|qi)>>25])) + if(!(shift=MLOOP_2[(pi|qi)>>19])) + shift=MLOOP_3[(pi|qi)>>16]; + + /* pi,qi normalized collectively, both tracked using qexp */ + + if(m&1){ + /* odd order filter; slightly assymetric */ + /* the last coefficient */ + qi=(qi>>shift)*labs(ilsp[j-1]-wi); + pi=(pi>>shift)<<14; + qexp+=shift; + + if(!(shift=MLOOP_1[(pi|qi)>>25])) + if(!(shift=MLOOP_2[(pi|qi)>>19])) + shift=MLOOP_3[(pi|qi)>>16]; + + pi>>=shift; + qi>>=shift; + qexp+=shift-14*((m+1)>>1); + + pi=((pi*pi)>>16); + qi=((qi*qi)>>16); + qexp=qexp*2+m; + + pi*=(1<<14)-((wi*wi)>>14); + qi+=pi>>14; + + }else{ + /* even order filter; still symmetric */ + + /* p*=p(1-w), q*=q(1+w), let normalization drift because it isn't + worth tracking step by step */ + + pi>>=shift; + qi>>=shift; + qexp+=shift-7*m; + + pi=((pi*pi)>>16); + qi=((qi*qi)>>16); + qexp=qexp*2+m; + + pi*=(1<<14)-wi; + qi*=(1<<14)+wi; + qi=(qi+pi)>>14; + + } + + + /* we've let the normalization drift because it wasn't important; + however, for the lookup, things must be normalized again. We + need at most one right shift or a number of left shifts */ + + if(qi&0xffff0000){ /* checks for 1.xxxxxxxxxxxxxxxx */ + qi>>=1; qexp++; + }else + while(qi && !(qi&0x8000)){ /* checks for 0.0xxxxxxxxxxxxxxx or less*/ + qi<<=1; qexp--; + } + +#endif + + amp=vorbis_fromdBlook_i(ampi* /* n.4 */ + vorbis_invsqlook_i(qi,qexp)- + /* m.8, m+n<=8 */ + ampoffseti); /* 8.12[0] */ + +#ifdef _LOW_ACCURACY_ + amp>>=9; +#endif + curve[i]= MULT31_SHIFT15(curve[i],amp); + while(map[++i]==k) curve[i]= MULT31_SHIFT15(curve[i],amp); + } +} + +/*************** vorbis decode glue ************/ + +static void floor0_free_info(vorbis_info_floor *i){ + vorbis_info_floor0 *info=(vorbis_info_floor0 *)i; + if(info){ + memset(info,0,sizeof(*info)); + _ogg_free(info); + } +} + +static void floor0_free_look(vorbis_look_floor *i){ + vorbis_look_floor0 *look=(vorbis_look_floor0 *)i; + if(look){ + + if(look->linearmap)_ogg_free(look->linearmap); + if(look->lsp_look)_ogg_free(look->lsp_look); + memset(look,0,sizeof(*look)); + _ogg_free(look); + } +} + +static vorbis_info_floor *floor0_unpack (vorbis_info *vi,oggpack_buffer *opb){ + codec_setup_info *ci=(codec_setup_info *)vi->codec_setup; + int j; + + vorbis_info_floor0 *info=(vorbis_info_floor0 *)_ogg_malloc(sizeof(*info)); + info->order=oggpack_read(opb,8); + info->rate=oggpack_read(opb,16); + info->barkmap=oggpack_read(opb,16); + info->ampbits=oggpack_read(opb,6); + info->ampdB=oggpack_read(opb,8); + info->numbooks=oggpack_read(opb,4)+1; + + if(info->order<1)goto err_out; + if(info->rate<1)goto err_out; + if(info->barkmap<1)goto err_out; + if(info->numbooks<1)goto err_out; + + for(j=0;jnumbooks;j++){ + info->books[j]=oggpack_read(opb,8); + if(info->books[j]<0 || info->books[j]>=ci->books)goto err_out; + if(ci->book_param[info->books[j]]->maptype==0)goto err_out; + if(ci->book_param[info->books[j]]->dim<1)goto err_out; + } + return(info); + + err_out: + floor0_free_info(info); + return(NULL); +} + +/* initialize Bark scale and normalization lookups. We could do this + with static tables, but Vorbis allows a number of possible + combinations, so it's best to do it computationally. + + The below is authoritative in terms of defining scale mapping. + Note that the scale depends on the sampling rate as well as the + linear block and mapping sizes */ + +static vorbis_look_floor *floor0_look (vorbis_dsp_state *vd,vorbis_info_mode *mi, + vorbis_info_floor *i){ + int j; + // ogg_int32_t scale; + vorbis_info *vi=vd->vi; + codec_setup_info *ci=(codec_setup_info *)vi->codec_setup; + vorbis_info_floor0 *info=(vorbis_info_floor0 *)i; + vorbis_look_floor0 *look=(vorbis_look_floor0 *)_ogg_calloc(1,sizeof(*look)); + look->m=info->order; + look->n=ci->blocksizes[mi->blockflag]/2; + look->ln=info->barkmap; + look->vi=info; + + /* the mapping from a linear scale to a smaller bark scale is + straightforward. We do *not* make sure that the linear mapping + does not skip bark-scale bins; the decoder simply skips them and + the encoder may do what it wishes in filling them. They're + necessary in some mapping combinations to keep the scale spacing + accurate */ + look->linearmap=(int *)_ogg_malloc((look->n+1)*sizeof(*look->linearmap)); + for(j=0;jn;j++){ + + int val=(look->ln* + ((toBARK(info->rate/2*j/look->n)<<11)/toBARK(info->rate/2)))>>11; + + if(val>=look->ln)val=look->ln-1; /* guard against the approximation */ + look->linearmap[j]=val; + } + look->linearmap[j]=-1; + + look->lsp_look=(ogg_int32_t *)_ogg_malloc(look->ln*sizeof(*look->lsp_look)); + for(j=0;jln;j++) + look->lsp_look[j]=vorbis_coslook2_i(0x10000*j/look->ln); + + return look; +} + +static void *floor0_inverse1(vorbis_block *vb,vorbis_look_floor *i){ + vorbis_look_floor0 *look=(vorbis_look_floor0 *)i; + vorbis_info_floor0 *info=look->vi; + int j,k; + + int ampraw=oggpack_read(&vb->opb,info->ampbits); + if(ampraw>0){ /* also handles the -1 out of data case */ + long maxval=(1<ampbits)-1; + int amp=((ampraw*info->ampdB)<<4)/maxval; + int booknum=oggpack_read(&vb->opb,_ilog(info->numbooks)); + + if(booknum!=-1 && booknumnumbooks){ /* be paranoid */ + codec_setup_info *ci=(codec_setup_info *)vb->vd->vi->codec_setup; + codebook *b=ci->fullbooks+info->books[booknum]; + ogg_int32_t last=0; + ogg_int32_t *lsp=(ogg_int32_t *)_vorbis_block_alloc(vb,sizeof(*lsp)*(look->m+1)); + + if(vorbis_book_decodev_set(b,lsp,&vb->opb,look->m,-24)==-1)goto eop; + for(j=0;jm;){ + for(k=0;jm && kdim;k++,j++)lsp[j]+=last; + last=lsp[j-1]; + } + + lsp[look->m]=amp; + return(lsp); + } + } + eop: + return(NULL); +} + +static int floor0_inverse2(vorbis_block *vb,vorbis_look_floor *i, + void *memo,ogg_int32_t *out){ + vorbis_look_floor0 *look=(vorbis_look_floor0 *)i; + vorbis_info_floor0 *info=look->vi; + (void)vb; + + if(memo){ + ogg_int32_t *lsp=(ogg_int32_t *)memo; + ogg_int32_t amp=lsp[look->m]; + + /* take the coefficients back to a spectral envelope curve */ + vorbis_lsp_to_curve(out,look->linearmap,look->n,look->ln, + lsp,look->m,amp,info->ampdB,look->lsp_look); + return(1); + } + memset(out,0,sizeof(*out)*look->n); + return(0); +} + +/* export hooks */ +const vorbis_func_floor floor0_exportbundle ICONST_ATTR ={ + &floor0_unpack,&floor0_look,&floor0_free_info, + &floor0_free_look,&floor0_inverse1,&floor0_inverse2 +}; + + diff --git a/lib/rbcodec/codecs/libtremor/floor1.c b/lib/rbcodec/codecs/libtremor/floor1.c new file mode 100644 index 0000000000..d2268db121 --- /dev/null +++ b/lib/rbcodec/codecs/libtremor/floor1.c @@ -0,0 +1,426 @@ +/******************************************************************** + * * + * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * + * * + * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * + * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * + * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * + * * + * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * + * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * + * * + ******************************************************************** + + function: floor backend 1 implementation + + ********************************************************************/ + +#include "config-tremor.h" +#include +#include +#include "ogg.h" +#include "ivorbiscodec.h" +#include "codec_internal.h" +#include "registry.h" +#include "codebook.h" +#include "misc.h" +#include "ffmpeg_stuff.h" + +#define floor1_rangedB 140 /* floor 1 fixed at -140dB to 0dB range */ + +typedef struct { + int forward_index[VIF_POSIT+2]; + + int hineighbor[VIF_POSIT]; + int loneighbor[VIF_POSIT]; + int posts; + + int n; + int quant_q; + vorbis_info_floor1 *vi; + +} vorbis_look_floor1; + +/***********************************************/ + +static void floor1_free_info(vorbis_info_floor *i){ + vorbis_info_floor1 *info=(vorbis_info_floor1 *)i; + if(info){ + //memset(info,0,sizeof(*info)); + _ogg_free(info); + } +} + +static void floor1_free_look(vorbis_look_floor *i){ + vorbis_look_floor1 *look=(vorbis_look_floor1 *)i; + if(look){ + //memset(look,0,sizeof(*look)); + _ogg_free(look); + } +} + +static inline int ilog(register unsigned int v){ + register int ret=0; + while(v){ + ret++; + v>>=1; + } + return(ret); +} + +static int icomp(const void *a,const void *b){ + return(**(int **)a-**(int **)b); +} + +static vorbis_info_floor *floor1_unpack (vorbis_info *vi,oggpack_buffer *opb){ + codec_setup_info *ci=(codec_setup_info *)vi->codec_setup; + int j,k,count=0,maxclass=-1,rangebits; + + vorbis_info_floor1 *info=(vorbis_info_floor1 *)_ogg_calloc(1,sizeof(*info)); + /* read partitions */ + info->partitions=oggpack_read(opb,5); /* only 0 to 31 legal */ + for(j=0;jpartitions;j++){ + info->partitionclass[j]=oggpack_read(opb,4); /* only 0 to 15 legal */ + if(info->partitionclass[j]<0)goto err_out; + if(maxclasspartitionclass[j])maxclass=info->partitionclass[j]; + } + + /* read partition classes */ + for(j=0;jclass_dim[j]=oggpack_read(opb,3)+1; /* 1 to 8 */ + info->class_subs[j]=oggpack_read(opb,2); /* 0,1,2,3 bits */ + if(info->class_subs[j]<0) + goto err_out; + if(info->class_subs[j])info->class_book[j]=oggpack_read(opb,8); + if(info->class_book[j]<0 || info->class_book[j]>=ci->books) + goto err_out; + for(k=0;k<(1<class_subs[j]);k++){ + info->class_subbook[j][k]=oggpack_read(opb,8)-1; + if(info->class_subbook[j][k]<-1 || info->class_subbook[j][k]>=ci->books) + goto err_out; + } + } + + /* read the post list */ + info->mult=oggpack_read(opb,2)+1; /* only 1,2,3,4 legal now */ + rangebits=oggpack_read(opb,4); + if(rangebits<0)goto err_out; + + for(j=0,k=0;jpartitions;j++){ + count+=info->class_dim[info->partitionclass[j]]; + for(;kpostlist[k+2]=oggpack_read(opb,rangebits); + if(t<0 || t>=(1<postlist[0]=0; + info->postlist[1]=1<postlist+j; + qsort(sortpointer,count+2,sizeof(*sortpointer),icomp); + + for(j=1;jvi=info; + look->n=info->postlist[1]; + + /* we drop each position value in-between already decoded values, + and use linear interpolation to predict each new value past the + edges. The positions are read in the order of the position + list... we precompute the bounding positions in the lookup. Of + course, the neighbors can change (if a position is declined), but + this is an initial mapping */ + + for(i=0;ipartitions;i++)n+=info->class_dim[info->partitionclass[i]]; + n+=2; + look->posts=n; + + /* also store a sorted position index */ + for(i=0;ipostlist+i; + qsort(sortpointer,n,sizeof(*sortpointer),icomp); + + /* points from sort order back to range number */ + for(i=0;iforward_index[i]=sortpointer[i]-info->postlist; + + /* quantize values to multiplier spec */ + switch(info->mult){ + case 1: /* 1024 -> 256 */ + look->quant_q=256; + break; + case 2: /* 1024 -> 128 */ + look->quant_q=128; + break; + case 3: /* 1024 -> 86 */ + look->quant_q=86; + break; + case 4: /* 1024 -> 64 */ + look->quant_q=64; + break; + } + + /* discover our neighbors for decode where we don't use fit flags + (that would push the neighbors outward) */ + for(i=0;in; + int currentx=info->postlist[i+2]; + for(j=0;jpostlist[j]; + if(x>lx && xcurrentx){ + hi=j; + hx=x; + } + } + look->loneighbor[i]=lo; + look->hineighbor[i]=hi; + } + + return(look); +} + +static int render_point(int x0,int x1,int y0,int y1,int x){ + y0&=0x7fff; /* mask off flag */ + y1&=0x7fff; + return y0+((y1-y0)*(x-x0))/(x1-x0); +} + +#ifdef _LOW_ACCURACY_ +# define XdB(n) ((((n)>>8)+1)>>1) +#else +# define XdB(n) (n) +#endif + +/* keep the floor lookup table in fast IRAM */ +static const ogg_int32_t FLOOR_fromdB_LOOKUP[256] ICONST_ATTR = { + XdB(0x000000e5), XdB(0x000000f4), XdB(0x00000103), XdB(0x00000114), + XdB(0x00000126), XdB(0x00000139), XdB(0x0000014e), XdB(0x00000163), + XdB(0x0000017a), XdB(0x00000193), XdB(0x000001ad), XdB(0x000001c9), + XdB(0x000001e7), XdB(0x00000206), XdB(0x00000228), XdB(0x0000024c), + XdB(0x00000272), XdB(0x0000029b), XdB(0x000002c6), XdB(0x000002f4), + XdB(0x00000326), XdB(0x0000035a), XdB(0x00000392), XdB(0x000003cd), + XdB(0x0000040c), XdB(0x00000450), XdB(0x00000497), XdB(0x000004e4), + XdB(0x00000535), XdB(0x0000058c), XdB(0x000005e8), XdB(0x0000064a), + XdB(0x000006b3), XdB(0x00000722), XdB(0x00000799), XdB(0x00000818), + XdB(0x0000089e), XdB(0x0000092e), XdB(0x000009c6), XdB(0x00000a69), + XdB(0x00000b16), XdB(0x00000bcf), XdB(0x00000c93), XdB(0x00000d64), + XdB(0x00000e43), XdB(0x00000f30), XdB(0x0000102d), XdB(0x0000113a), + XdB(0x00001258), XdB(0x0000138a), XdB(0x000014cf), XdB(0x00001629), + XdB(0x0000179a), XdB(0x00001922), XdB(0x00001ac4), XdB(0x00001c82), + XdB(0x00001e5c), XdB(0x00002055), XdB(0x0000226f), XdB(0x000024ac), + XdB(0x0000270e), XdB(0x00002997), XdB(0x00002c4b), XdB(0x00002f2c), + XdB(0x0000323d), XdB(0x00003581), XdB(0x000038fb), XdB(0x00003caf), + XdB(0x000040a0), XdB(0x000044d3), XdB(0x0000494c), XdB(0x00004e10), + XdB(0x00005323), XdB(0x0000588a), XdB(0x00005e4b), XdB(0x0000646b), + XdB(0x00006af2), XdB(0x000071e5), XdB(0x0000794c), XdB(0x0000812e), + XdB(0x00008993), XdB(0x00009283), XdB(0x00009c09), XdB(0x0000a62d), + XdB(0x0000b0f9), XdB(0x0000bc79), XdB(0x0000c8b9), XdB(0x0000d5c4), + XdB(0x0000e3a9), XdB(0x0000f274), XdB(0x00010235), XdB(0x000112fd), + XdB(0x000124dc), XdB(0x000137e4), XdB(0x00014c29), XdB(0x000161bf), + XdB(0x000178bc), XdB(0x00019137), XdB(0x0001ab4a), XdB(0x0001c70e), + XdB(0x0001e4a1), XdB(0x0002041f), XdB(0x000225aa), XdB(0x00024962), + XdB(0x00026f6d), XdB(0x000297f0), XdB(0x0002c316), XdB(0x0002f109), + XdB(0x000321f9), XdB(0x00035616), XdB(0x00038d97), XdB(0x0003c8b4), + XdB(0x000407a7), XdB(0x00044ab2), XdB(0x00049218), XdB(0x0004de23), + XdB(0x00052f1e), XdB(0x0005855c), XdB(0x0005e135), XdB(0x00064306), + XdB(0x0006ab33), XdB(0x00071a24), XdB(0x0007904b), XdB(0x00080e20), + XdB(0x00089422), XdB(0x000922da), XdB(0x0009bad8), XdB(0x000a5cb6), + XdB(0x000b091a), XdB(0x000bc0b1), XdB(0x000c8436), XdB(0x000d5471), + XdB(0x000e3233), XdB(0x000f1e5f), XdB(0x001019e4), XdB(0x001125c1), + XdB(0x00124306), XdB(0x001372d5), XdB(0x0014b663), XdB(0x00160ef7), + XdB(0x00177df0), XdB(0x001904c1), XdB(0x001aa4f9), XdB(0x001c603d), + XdB(0x001e384f), XdB(0x00202f0f), XdB(0x0022467a), XdB(0x002480b1), + XdB(0x0026dff7), XdB(0x002966b3), XdB(0x002c1776), XdB(0x002ef4fc), + XdB(0x0032022d), XdB(0x00354222), XdB(0x0038b828), XdB(0x003c67c2), + XdB(0x004054ae), XdB(0x004482e8), XdB(0x0048f6af), XdB(0x004db488), + XdB(0x0052c142), XdB(0x005821ff), XdB(0x005ddc33), XdB(0x0063f5b0), + XdB(0x006a74a7), XdB(0x00715faf), XdB(0x0078bdce), XdB(0x0080967f), + XdB(0x0088f1ba), XdB(0x0091d7f9), XdB(0x009b5247), XdB(0x00a56a41), + XdB(0x00b02a27), XdB(0x00bb9ce2), XdB(0x00c7ce12), XdB(0x00d4ca17), + XdB(0x00e29e20), XdB(0x00f15835), XdB(0x0101074b), XdB(0x0111bb4e), + XdB(0x01238531), XdB(0x01367704), XdB(0x014aa402), XdB(0x016020a7), + XdB(0x017702c3), XdB(0x018f6190), XdB(0x01a955cb), XdB(0x01c4f9cf), + XdB(0x01e269a8), XdB(0x0201c33b), XdB(0x0223265a), XdB(0x0246b4ea), + XdB(0x026c9302), XdB(0x0294e716), XdB(0x02bfda13), XdB(0x02ed9793), + XdB(0x031e4e09), XdB(0x03522ee4), XdB(0x03896ed0), XdB(0x03c445e2), + XdB(0x0402efd6), XdB(0x0445ac4b), XdB(0x048cbefc), XdB(0x04d87013), + XdB(0x05290c67), XdB(0x057ee5ca), XdB(0x05da5364), XdB(0x063bb204), + XdB(0x06a36485), XdB(0x0711d42b), XdB(0x0787710e), XdB(0x0804b299), + XdB(0x088a17ef), XdB(0x0918287e), XdB(0x09af747c), XdB(0x0a50957e), + XdB(0x0afc2f19), XdB(0x0bb2ef7f), XdB(0x0c759034), XdB(0x0d44d6ca), + XdB(0x0e2195bc), XdB(0x0f0cad0d), XdB(0x10070b62), XdB(0x1111aeea), + XdB(0x122da66c), XdB(0x135c120f), XdB(0x149e24d9), XdB(0x15f525b1), + XdB(0x176270e3), XdB(0x18e7794b), XdB(0x1a85c9ae), XdB(0x1c3f06d1), + XdB(0x1e14f07d), XdB(0x200963d7), XdB(0x221e5ccd), XdB(0x2455f870), + XdB(0x26b2770b), XdB(0x29363e2b), XdB(0x2be3db5c), XdB(0x2ebe06b6), + XdB(0x31c7a55b), XdB(0x3503ccd4), XdB(0x3875c5aa), XdB(0x3c210f44), + XdB(0x4009632b), XdB(0x4432b8cf), XdB(0x48a149bc), XdB(0x4d59959e), + XdB(0x52606733), XdB(0x57bad899), XdB(0x5d6e593a), XdB(0x6380b298), + XdB(0x69f80e9a), XdB(0x70dafda8), XdB(0x78307d76), XdB(0x7fffffff), +}; + +static void *floor1_inverse1(vorbis_block *vb,vorbis_look_floor *in) + ICODE_ATTR_TREMOR_NOT_MDCT; +static void *floor1_inverse1(vorbis_block *vb,vorbis_look_floor *in){ + vorbis_look_floor1 *look=(vorbis_look_floor1 *)in; + vorbis_info_floor1 *info=look->vi; + codec_setup_info *ci=(codec_setup_info *)vb->vd->vi->codec_setup; + int i,j,k; + codebook *books=ci->fullbooks; + + /* unpack wrapped/predicted values from stream */ + if(oggpack_read(&vb->opb,1)==1){ + int *fit_value=(int *)_vorbis_block_alloc(vb,(look->posts)*sizeof(*fit_value)); + int ilg = ilog(look->quant_q-1); + fit_value[0]=oggpack_read(&vb->opb,ilg); + fit_value[1]=oggpack_read(&vb->opb,ilg); + + /* partition by partition */ + /* partition by partition */ + for(i=0,j=2;ipartitions;i++){ + int classv=info->partitionclass[i]; + int cdim=info->class_dim[classv]; + int csubbits=info->class_subs[classv]; + int csub=1<class_book[classv],&vb->opb); + + if(cval==-1)goto eop; + } + + for(k=0;kclass_subbook[classv][cval&(csub-1)]; + cval>>=csubbits; + if(book>=0){ + if((fit_value[j+k]=vorbis_book_decode(books+book,&vb->opb))==-1) + goto eop; + }else{ + fit_value[j+k]=0; + } + } + j+=cdim; + } + + /* unwrap positive values and reconsitute via linear interpolation */ + for(i=2;iposts;i++){ + int predicted=render_point(info->postlist[look->loneighbor[i-2]], + info->postlist[look->hineighbor[i-2]], + fit_value[look->loneighbor[i-2]], + fit_value[look->hineighbor[i-2]], + info->postlist[i]); + int hiroom=look->quant_q-predicted; + int loroom=predicted; + int room=(hiroom=room){ + if(hiroom>loroom){ + val = val-loroom; + }else{ + val = -1-(val-hiroom); + } + }else{ + if(val&1){ + val= -((val+1)>>1); + }else{ + val>>=1; + } + } + + fit_value[i]=(val+predicted)&0x7fff;; + fit_value[look->loneighbor[i-2]]&=0x7fff; + fit_value[look->hineighbor[i-2]]&=0x7fff; + + }else{ + fit_value[i]=predicted|0x8000; + } + } + + return(fit_value); + } + eop: + return(NULL); +} + +static int floor1_inverse2(vorbis_block *vb,vorbis_look_floor *in,void *memo, + ogg_int32_t *out) ICODE_ATTR_TREMOR_NOT_MDCT; +static int floor1_inverse2(vorbis_block *vb,vorbis_look_floor *in,void *memo, + ogg_int32_t *out){ + vorbis_look_floor1 *look=(vorbis_look_floor1 *)in; + vorbis_info_floor1 *info=look->vi; + + codec_setup_info *ci=(codec_setup_info *)vb->vd->vi->codec_setup; + int n=ci->blocksizes[vb->W]/2; + int j; + + if(memo){ + /* render the lines */ + int *fit_value=(int *)memo; + int hx=0; + int lx=0; + int ly=fit_value[0]*info->mult; + /* guard lookup against out-of-range values */ + ly=(ly<0?0:ly>255?255:ly); + + for(j=1;jposts;j++){ + int current=look->forward_index[j]; + int hy=fit_value[current]&0x7fff; + if(hy==fit_value[current]){ + + hx=info->postlist[current]; + hy*=info->mult; + /* guard lookup against out-of-range values */ + hy=(hy<0?0:hy>255?255:hy); + + render_line(lx, ly, hx, hy, FLOOR_fromdB_LOOKUP, out); + + lx=hx; + ly=hy; + } + } + for(j=hx;j +#include +#include "ogg.h" + +/* A complete description of Ogg framing exists in docs/framing.html */ + +static int ogg_page_version(const ogg_page *og){ + return((int)(og->header[4])); +} + +int ogg_page_continued(const ogg_page *og){ + return((int)(og->header[5]&0x01)); +} + +int ogg_page_bos(const ogg_page *og){ + return((int)(og->header[5]&0x02)); +} + +int ogg_page_eos(const ogg_page *og){ + return((int)(og->header[5]&0x04)); +} + +ogg_int64_t ogg_page_granulepos(const ogg_page *og){ + unsigned char *page=og->header; + ogg_int64_t granulepos=page[13]&(0xff); + granulepos= (granulepos<<8)|(page[12]&0xff); + granulepos= (granulepos<<8)|(page[11]&0xff); + granulepos= (granulepos<<8)|(page[10]&0xff); + granulepos= (granulepos<<8)|(page[9]&0xff); + granulepos= (granulepos<<8)|(page[8]&0xff); + granulepos= (granulepos<<8)|(page[7]&0xff); + granulepos= (granulepos<<8)|(page[6]&0xff); + return(granulepos); +} + +ogg_uint32_t ogg_page_serialno(const ogg_page *og){ + return(og->header[14] | + (og->header[15]<<8) | + (og->header[16]<<16) | + (og->header[17]<<24)); +} + +static long ogg_page_pageno(const ogg_page *og){ + return(og->header[18] | + (og->header[19]<<8) | + (og->header[20]<<16) | + (og->header[21]<<24)); +} + + + +/* returns the number of packets that are completed on this page (if + the leading packet is begun on a previous page, but ends on this + page, it's counted */ + +/* NOTE: +If a page consists of a packet begun on a previous page, and a new +packet begun (but not completed) on this page, the return will be: + ogg_page_packets(page) ==1, + ogg_page_continued(page) !=0 + +If a page happens to be a single packet that was begun on a +previous page, and spans to the next page (in the case of a three or +more page packet), the return will be: + ogg_page_packets(page) ==0, + ogg_page_continued(page) !=0 +*/ +/* +int ogg_page_packets(const ogg_page *og){ + int i,n=og->header[26],count=0; + for(i=0;iheader[27+i]<255)count++; + return(count); +} +*/ + +#if 0 +/* helper to initialize lookup for direct-table CRC (illustrative; we + use the static init below) */ + +static ogg_uint32_t _ogg_crc_entry(unsigned long index){ + int i; + unsigned long r; + + r = index << 24; + for (i=0; i<8; i++) + if (r & 0x80000000UL) + r = (r << 1) ^ 0x04c11db7; /* The same as the ethernet generator + polynomial, although we use an + unreflected alg and an init/final + of 0, not 0xffffffff */ + else + r<<=1; + return (r & 0xffffffffUL); +} +#endif + +static const ogg_uint32_t crc_lookup[256] ICONST_ATTR = { + 0x00000000,0x04c11db7,0x09823b6e,0x0d4326d9, + 0x130476dc,0x17c56b6b,0x1a864db2,0x1e475005, + 0x2608edb8,0x22c9f00f,0x2f8ad6d6,0x2b4bcb61, + 0x350c9b64,0x31cd86d3,0x3c8ea00a,0x384fbdbd, + 0x4c11db70,0x48d0c6c7,0x4593e01e,0x4152fda9, + 0x5f15adac,0x5bd4b01b,0x569796c2,0x52568b75, + 0x6a1936c8,0x6ed82b7f,0x639b0da6,0x675a1011, + 0x791d4014,0x7ddc5da3,0x709f7b7a,0x745e66cd, + 0x9823b6e0,0x9ce2ab57,0x91a18d8e,0x95609039, + 0x8b27c03c,0x8fe6dd8b,0x82a5fb52,0x8664e6e5, + 0xbe2b5b58,0xbaea46ef,0xb7a96036,0xb3687d81, + 0xad2f2d84,0xa9ee3033,0xa4ad16ea,0xa06c0b5d, + 0xd4326d90,0xd0f37027,0xddb056fe,0xd9714b49, + 0xc7361b4c,0xc3f706fb,0xceb42022,0xca753d95, + 0xf23a8028,0xf6fb9d9f,0xfbb8bb46,0xff79a6f1, + 0xe13ef6f4,0xe5ffeb43,0xe8bccd9a,0xec7dd02d, + 0x34867077,0x30476dc0,0x3d044b19,0x39c556ae, + 0x278206ab,0x23431b1c,0x2e003dc5,0x2ac12072, + 0x128e9dcf,0x164f8078,0x1b0ca6a1,0x1fcdbb16, + 0x018aeb13,0x054bf6a4,0x0808d07d,0x0cc9cdca, + 0x7897ab07,0x7c56b6b0,0x71159069,0x75d48dde, + 0x6b93dddb,0x6f52c06c,0x6211e6b5,0x66d0fb02, + 0x5e9f46bf,0x5a5e5b08,0x571d7dd1,0x53dc6066, + 0x4d9b3063,0x495a2dd4,0x44190b0d,0x40d816ba, + 0xaca5c697,0xa864db20,0xa527fdf9,0xa1e6e04e, + 0xbfa1b04b,0xbb60adfc,0xb6238b25,0xb2e29692, + 0x8aad2b2f,0x8e6c3698,0x832f1041,0x87ee0df6, + 0x99a95df3,0x9d684044,0x902b669d,0x94ea7b2a, + 0xe0b41de7,0xe4750050,0xe9362689,0xedf73b3e, + 0xf3b06b3b,0xf771768c,0xfa325055,0xfef34de2, + 0xc6bcf05f,0xc27dede8,0xcf3ecb31,0xcbffd686, + 0xd5b88683,0xd1799b34,0xdc3abded,0xd8fba05a, + 0x690ce0ee,0x6dcdfd59,0x608edb80,0x644fc637, + 0x7a089632,0x7ec98b85,0x738aad5c,0x774bb0eb, + 0x4f040d56,0x4bc510e1,0x46863638,0x42472b8f, + 0x5c007b8a,0x58c1663d,0x558240e4,0x51435d53, + 0x251d3b9e,0x21dc2629,0x2c9f00f0,0x285e1d47, + 0x36194d42,0x32d850f5,0x3f9b762c,0x3b5a6b9b, + 0x0315d626,0x07d4cb91,0x0a97ed48,0x0e56f0ff, + 0x1011a0fa,0x14d0bd4d,0x19939b94,0x1d528623, + 0xf12f560e,0xf5ee4bb9,0xf8ad6d60,0xfc6c70d7, + 0xe22b20d2,0xe6ea3d65,0xeba91bbc,0xef68060b, + 0xd727bbb6,0xd3e6a601,0xdea580d8,0xda649d6f, + 0xc423cd6a,0xc0e2d0dd,0xcda1f604,0xc960ebb3, + 0xbd3e8d7e,0xb9ff90c9,0xb4bcb610,0xb07daba7, + 0xae3afba2,0xaafbe615,0xa7b8c0cc,0xa379dd7b, + 0x9b3660c6,0x9ff77d71,0x92b45ba8,0x9675461f, + 0x8832161a,0x8cf30bad,0x81b02d74,0x857130c3, + 0x5d8a9099,0x594b8d2e,0x5408abf7,0x50c9b640, + 0x4e8ee645,0x4a4ffbf2,0x470cdd2b,0x43cdc09c, + 0x7b827d21,0x7f436096,0x7200464f,0x76c15bf8, + 0x68860bfd,0x6c47164a,0x61043093,0x65c52d24, + 0x119b4be9,0x155a565e,0x18197087,0x1cd86d30, + 0x029f3d35,0x065e2082,0x0b1d065b,0x0fdc1bec, + 0x3793a651,0x3352bbe6,0x3e119d3f,0x3ad08088, + 0x2497d08d,0x2056cd3a,0x2d15ebe3,0x29d4f654, + 0xc5a92679,0xc1683bce,0xcc2b1d17,0xc8ea00a0, + 0xd6ad50a5,0xd26c4d12,0xdf2f6bcb,0xdbee767c, + 0xe3a1cbc1,0xe760d676,0xea23f0af,0xeee2ed18, + 0xf0a5bd1d,0xf464a0aa,0xf9278673,0xfde69bc4, + 0x89b8fd09,0x8d79e0be,0x803ac667,0x84fbdbd0, + 0x9abc8bd5,0x9e7d9662,0x933eb0bb,0x97ffad0c, + 0xafb010b1,0xab710d06,0xa6322bdf,0xa2f33668, + 0xbcb4666d,0xb8757bda,0xb5365d03,0xb1f740b4}; + +/* init the encode/decode logical stream state */ + +int ogg_stream_init(ogg_stream_state *os,int serialno){ + if(os){ + memset(os,0,sizeof(*os)); + os->body_storage=16*1024; + os->lacing_storage=1024; + + os->body_data=_ogg_malloc(os->body_storage*sizeof(*os->body_data)); + os->lacing_vals=_ogg_malloc(os->lacing_storage*sizeof(*os->lacing_vals)); + os->granule_vals=_ogg_malloc(os->lacing_storage*sizeof(*os->granule_vals)); + + if(!os->body_data || !os->lacing_vals || !os->granule_vals){ + ogg_stream_clear(os); + return -1; + } + + os->serialno=serialno; + + return(0); + } + return(-1); +} + +/* async/delayed error detection for the ogg_stream_state */ +static int ogg_stream_check(ogg_stream_state *os){ + if(!os || !os->body_data) return -1; + return 0; +} + +/* _clear does not free os, only the non-flat storage within */ +int ogg_stream_clear(ogg_stream_state *os){ + if(os){ + if(os->body_data)_ogg_free(os->body_data); + if(os->lacing_vals)_ogg_free(os->lacing_vals); + if(os->granule_vals)_ogg_free(os->granule_vals); + + memset(os,0,sizeof(*os)); + } + return(0); +} +/* +int ogg_stream_destroy(ogg_stream_state *os){ + if(os){ + ogg_stream_clear(os); + _ogg_free(os); + } + return(0); +} +*/ +/* Helpers for ogg_stream_encode; this keeps the structure and + what's happening fairly clear */ + +int _os_body_expand(ogg_stream_state *os,int needed){ + if(os->body_storage<=os->body_fill+needed){ + void *ret; + ret=_ogg_realloc(os->body_data,(os->body_storage+needed+1024)* + sizeof(*os->body_data)); + if(!ret){ + ogg_stream_clear(os); + return -1; + } + os->body_storage+=(needed+1024); + os->body_data=ret; + } + return 0; +} + +static int _os_lacing_expand(ogg_stream_state *os,int needed){ + if(os->lacing_storage<=os->lacing_fill+needed){ + void *ret; + ret=_ogg_realloc(os->lacing_vals,(os->lacing_storage+needed+32)* + sizeof(*os->lacing_vals)); + if(!ret){ + ogg_stream_clear(os); + return -1; + } + os->lacing_vals=ret; + ret=_ogg_realloc(os->granule_vals,(os->lacing_storage+needed+32)* + sizeof(*os->granule_vals)); + if(!ret){ + ogg_stream_clear(os); + return -1; + } + os->granule_vals=ret; + os->lacing_storage+=(needed+32); + } + return 0; +} + +/* checksum the page */ +/* Direct table CRC; note that this will be faster in the future if we + perform the checksum simultaneously with other copies */ + +static void ogg_page_checksum_set(ogg_page *og){ + if(og){ + ogg_uint32_t crc_reg=0; + int i; + + /* safety; needed for API behavior, but not framing code */ + og->header[22]=0; + og->header[23]=0; + og->header[24]=0; + og->header[25]=0; + + for(i=0;iheader_len;i++) + crc_reg=(crc_reg<<8)^crc_lookup[((crc_reg >> 24)&0xff)^og->header[i]]; + for(i=0;ibody_len;i++) + crc_reg=(crc_reg<<8)^crc_lookup[((crc_reg >> 24)&0xff)^og->body[i]]; + + og->header[22]=(unsigned char)(crc_reg&0xff); + og->header[23]=(unsigned char)((crc_reg>>8)&0xff); + og->header[24]=(unsigned char)((crc_reg>>16)&0xff); + og->header[25]=(unsigned char)((crc_reg>>24)&0xff); + } +} + +#if 0 +/* submit data to the internal buffer of the framing engine */ +int ogg_stream_iovecin(ogg_stream_state *os, ogg_iovec_t *iov, int count, + long e_o_s, ogg_int64_t granulepos){ + + int bytes = 0, lacing_vals, i; + + if(ogg_stream_check(os)) return -1; + if(!iov) return 0; + + for (i = 0; i < count; ++i) bytes += (int)iov[i].iov_len; + lacing_vals=bytes/255+1; + + if(os->body_returned){ + /* advance packet data according to the body_returned pointer. We + had to keep it around to return a pointer into the buffer last + call */ + + os->body_fill-=os->body_returned; + if(os->body_fill) + memmove(os->body_data,os->body_data+os->body_returned, + os->body_fill); + os->body_returned=0; + } + + /* make sure we have the buffer storage */ + if(_os_body_expand(os,bytes) || _os_lacing_expand(os,lacing_vals)) + return -1; + + /* Copy in the submitted packet. Yes, the copy is a waste; this is + the liability of overly clean abstraction for the time being. It + will actually be fairly easy to eliminate the extra copy in the + future */ + + for (i = 0; i < count; ++i) { + memcpy(os->body_data+os->body_fill, iov[i].iov_base, iov[i].iov_len); + os->body_fill += (int)iov[i].iov_len; + } + + /* Store lacing vals for this packet */ + for(i=0;ilacing_vals[os->lacing_fill+i]=255; + os->granule_vals[os->lacing_fill+i]=os->granulepos; + } + os->lacing_vals[os->lacing_fill+i]=bytes%255; + os->granulepos=os->granule_vals[os->lacing_fill+i]=granulepos; + + /* flag the first segment as the beginning of the packet */ + os->lacing_vals[os->lacing_fill]|= 0x100; + + os->lacing_fill+=lacing_vals; + + /* for the sake of completeness */ + os->packetno++; + + if(e_o_s)os->e_o_s=1; + + return(0); +} + +int ogg_stream_packetin(ogg_stream_state *os,ogg_packet *op){ + ogg_iovec_t iov; + iov.iov_base = op->packet; + iov.iov_len = op->bytes; + return ogg_stream_iovecin(os, &iov, 1, op->e_o_s, op->granulepos); +} + + +/* Conditionally flush a page; force==0 will only flush nominal-size + pages, force==1 forces us to flush a page regardless of page size + so long as there's any data available at all. */ +static int ogg_stream_flush_i(ogg_stream_state *os,ogg_page *og, int force, int nfill){ + int i; + int vals=0; + int maxvals=(os->lacing_fill>255?255:os->lacing_fill); + int bytes=0; + long acc=0; + ogg_int64_t granule_pos=-1; + + if(ogg_stream_check(os)) return(0); + if(maxvals==0) return(0); + + /* construct a page */ + /* decide how many segments to include */ + + /* If this is the initial header case, the first page must only include + the initial header packet */ + if(os->b_o_s==0){ /* 'initial header page' case */ + granule_pos=0; + for(vals=0;valslacing_vals[vals]&0x0ff)<255){ + vals++; + break; + } + } + }else{ + + /* The extra packets_done, packet_just_done logic here attempts to do two things: + 1) Don't unneccessarily span pages. + 2) Unless necessary, don't flush pages if there are less than four packets on + them; this expands page size to reduce unneccessary overhead if incoming packets + are large. + These are not necessary behaviors, just 'always better than naive flushing' + without requiring an application to explicitly request a specific optimized + behavior. We'll want an explicit behavior setup pathway eventually as well. */ + + int packets_done=0; + int packet_just_done=0; + for(vals=0;valsnfill && packet_just_done>=4){ + force=1; + break; + } + acc+=os->lacing_vals[vals]&0x0ff; + if((os->lacing_vals[vals]&0xff)<255){ + granule_pos=os->granule_vals[vals]; + packet_just_done=++packets_done; + }else + packet_just_done=0; + } + if(vals==255)force=1; + } + + if(!force) return(0); + + /* construct the header in temp storage */ + memcpy(os->header,"OggS",4); + + /* stream structure version */ + os->header[4]=0x00; + + /* continued packet flag? */ + os->header[5]=0x00; + if((os->lacing_vals[0]&0x100)==0)os->header[5]|=0x01; + /* first page flag? */ + if(os->b_o_s==0)os->header[5]|=0x02; + /* last page flag? */ + if(os->e_o_s && os->lacing_fill==vals)os->header[5]|=0x04; + os->b_o_s=1; + + /* 64 bits of PCM position */ + for(i=6;i<14;i++){ + os->header[i]=(unsigned char)(granule_pos&0xff); + granule_pos>>=8; + } + + /* 32 bits of stream serial number */ + { + long serialno=os->serialno; + for(i=14;i<18;i++){ + os->header[i]=(unsigned char)(serialno&0xff); + serialno>>=8; + } + } + + /* 32 bits of page counter (we have both counter and page header + because this val can roll over) */ + if(os->pageno==-1)os->pageno=0; /* because someone called + stream_reset; this would be a + strange thing to do in an + encode stream, but it has + plausible uses */ + { + long pageno=os->pageno++; + for(i=18;i<22;i++){ + os->header[i]=(unsigned char)(pageno&0xff); + pageno>>=8; + } + } + + /* zero for computation; filled in later */ + os->header[22]=0; + os->header[23]=0; + os->header[24]=0; + os->header[25]=0; + + /* segment table */ + os->header[26]=(unsigned char)(vals&0xff); + for(i=0;iheader[i+27]=(unsigned char)(os->lacing_vals[i]&0xff); + + /* set pointers in the ogg_page struct */ + og->header=os->header; + og->header_len=os->header_fill=vals+27; + og->body=os->body_data+os->body_returned; + og->body_len=bytes; + + /* advance the lacing data and set the body_returned pointer */ + + os->lacing_fill-=vals; + memmove(os->lacing_vals,os->lacing_vals+vals,os->lacing_fill*sizeof(*os->lacing_vals)); + memmove(os->granule_vals,os->granule_vals+vals,os->lacing_fill*sizeof(*os->granule_vals)); + os->body_returned+=bytes; + + /* calculate the checksum */ + + ogg_page_checksum_set(og); + + /* done */ + return(1); +} + +/* This will flush remaining packets into a page (returning nonzero), + even if there is not enough data to trigger a flush normally + (undersized page). If there are no packets or partial packets to + flush, ogg_stream_flush returns 0. Note that ogg_stream_flush will + try to flush a normal sized page like ogg_stream_pageout; a call to + ogg_stream_flush does not guarantee that all packets have flushed. + Only a return value of 0 from ogg_stream_flush indicates all packet + data is flushed into pages. + + since ogg_stream_flush will flush the last page in a stream even if + it's undersized, you almost certainly want to use ogg_stream_pageout + (and *not* ogg_stream_flush) unless you specifically need to flush + an page regardless of size in the middle of a stream. */ + +int ogg_stream_flush(ogg_stream_state *os,ogg_page *og){ + return ogg_stream_flush_i(os,og,1,4096); +} + +/* This constructs pages from buffered packet segments. The pointers +returned are to static buffers; do not free. The returned buffers are +good only until the next call (using the same ogg_stream_state) */ + +int ogg_stream_pageout(ogg_stream_state *os, ogg_page *og){ + int force=0; + if(ogg_stream_check(os)) return 0; + + if((os->e_o_s&&os->lacing_fill) || /* 'were done, now flush' case */ + (os->lacing_fill&&!os->b_o_s)) /* 'initial header page' case */ + force=1; + + return(ogg_stream_flush_i(os,og,force,4096)); +} + +/* Like the above, but an argument is provided to adjust the nominal +page size for applications which are smart enough to provide their +own delay based flushing */ + +int ogg_stream_pageout_fill(ogg_stream_state *os, ogg_page *og, int nfill){ + int force=0; + if(ogg_stream_check(os)) return 0; + + if((os->e_o_s&&os->lacing_fill) || /* 'were done, now flush' case */ + (os->lacing_fill&&!os->b_o_s)) /* 'initial header page' case */ + force=1; + + return(ogg_stream_flush_i(os,og,force,nfill)); +} + +int ogg_stream_eos(ogg_stream_state *os){ + if(ogg_stream_check(os)) return 1; + return os->e_o_s; +} +#endif +/* DECODING PRIMITIVES: packet streaming layer **********************/ + +/* This has two layers to place more of the multi-serialno and paging + control in the application's hands. First, we expose a data buffer + using ogg_sync_buffer(). The app either copies into the + buffer, or passes it directly to read(), etc. We then call + ogg_sync_wrote() to tell how many bytes we just added. + + Pages are returned (pointers into the buffer in ogg_sync_state) + by ogg_sync_pageout(). The page is then submitted to + ogg_stream_pagein() along with the appropriate + ogg_stream_state* (ie, matching serialno). We then get raw + packets out calling ogg_stream_packetout() with a + ogg_stream_state. */ + +/* initialize the struct to a known state */ +int ogg_sync_init(ogg_sync_state *oy){ + if(oy){ + oy->storage = -1; /* used as a readiness flag */ + memset(oy,0,sizeof(*oy)); + } + return(0); +} + +/* clear non-flat storage within */ +int ogg_sync_clear(ogg_sync_state *oy){ + if(oy){ + if(oy->data)_ogg_free(oy->data); + memset(oy,0,sizeof(*oy)); + } + return(0); +} + +/* +int ogg_sync_destroy(ogg_sync_state *oy){ + if(oy){ + ogg_sync_clear(oy); + _ogg_free(oy); + } + return(0); +} +*/ +static int ogg_sync_check(ogg_sync_state *oy){ + if(oy->storage<0) return -1; + return 0; +} + +char *ogg_sync_buffer(ogg_sync_state *oy, long size){ + if(ogg_sync_check(oy)) return NULL; + + /* first, clear out any space that has been previously returned */ + if(oy->returned){ + oy->fill-=oy->returned; + if(oy->fill>0) + memmove(oy->data,oy->data+oy->returned,oy->fill); + oy->returned=0; + } + + if(size>oy->storage-oy->fill){ + /* We need to extend the internal buffer */ + long newsize=size+oy->fill+4096; /* an extra page to be nice */ + void *ret; + + if(oy->data) + ret=_ogg_realloc(oy->data,newsize); + else + ret=_ogg_malloc(newsize); + if(!ret){ + ogg_sync_clear(oy); + return NULL; + } + oy->data=ret; + oy->storage=newsize; + } + + /* expose a segment at least as large as requested at the fill mark */ + return((char *)oy->data+oy->fill); +} + +int ogg_sync_wrote(ogg_sync_state *oy, long bytes){ + if(ogg_sync_check(oy))return -1; + if(oy->fill+bytes>oy->storage)return -1; + oy->fill+=bytes; + return(0); +} + +/* sync the stream. This is meant to be useful for finding page + boundaries. + + return values for this: + -n) skipped n bytes + 0) page not ready; more data (no bytes skipped) + n) page synced at current location; page length n bytes + +*/ + +long ogg_sync_pageseek(ogg_sync_state *oy,ogg_page *og){ + unsigned char *page=oy->data+oy->returned; + unsigned char *next; + long bytes=oy->fill-oy->returned; + + if(ogg_sync_check(oy))return 0; + + if(oy->headerbytes==0){ + int headerbytes,i; + if(bytes<27)return(0); /* not enough for a header */ + + /* verify capture pattern */ + if(memcmp(page,"OggS",4))goto sync_fail; + + headerbytes=page[26]+27; + if(bytesbodybytes+=page[27+i]; + oy->headerbytes=headerbytes; + } + + if(oy->bodybytes+oy->headerbytes>bytes)return(0); + + /* The whole test page is buffered. Verify the checksum */ + { + /* Grab the checksum bytes, set the header field to zero */ + char chksum[4]; + ogg_page log; + + memcpy(chksum,page+22,4); + memset(page+22,0,4); + + /* set up a temp page struct and recompute the checksum */ + log.header=page; + log.header_len=oy->headerbytes; + log.body=page+oy->headerbytes; + log.body_len=oy->bodybytes; + ogg_page_checksum_set(&log); + + /* Compare */ + if(memcmp(chksum,page+22,4)){ + /* D'oh. Mismatch! Corrupt page (or miscapture and not a page + at all) */ + /* replace the computed checksum with the one actually read in */ + memcpy(page+22,chksum,4); + + /* Bad checksum. Lose sync */ + goto sync_fail; + } + } + + /* yes, have a whole page all ready to go */ + { + unsigned char *page=oy->data+oy->returned; + long bytes; + + if(og){ + og->header=page; + og->header_len=oy->headerbytes; + og->body=page+oy->headerbytes; + og->body_len=oy->bodybytes; + } + + oy->unsynced=0; + oy->returned+=(bytes=oy->headerbytes+oy->bodybytes); + oy->headerbytes=0; + oy->bodybytes=0; + return(bytes); + } + + sync_fail: + + oy->headerbytes=0; + oy->bodybytes=0; + + /* search for possible capture */ + next=memchr(page+1,'O',bytes-1); + if(!next) + next=oy->data+oy->fill; + + oy->returned=(int)(next-oy->data); + return((long)-(next-page)); +} + +/* sync the stream and get a page. Keep trying until we find a page. + Suppress 'sync errors' after reporting the first. + + return values: + -1) recapture (hole in data) + 0) need more data + 1) page returned + + Returns pointers into buffered data; invalidated by next call to + _stream, _clear, _init, or _buffer */ + +#if 0 +int ogg_sync_pageout(ogg_sync_state *oy, ogg_page *og){ + + if(ogg_sync_check(oy))return 0; + + /* all we need to do is verify a page at the head of the stream + buffer. If it doesn't verify, we look for the next potential + frame */ + + for(;;){ + long ret=ogg_sync_pageseek(oy,og); + if(ret>0){ + /* have a page */ + return(1); + } + if(ret==0){ + /* need more data */ + return(0); + } + + /* head did not start a synced page... skipped some bytes */ + if(!oy->unsynced){ + oy->unsynced=1; + return(-1); + } + + /* loop. keep looking */ + + } +} +#endif +/* add the incoming page to the stream state; we decompose the page + into packet segments here as well. */ + +int ogg_stream_pagein(ogg_stream_state *os, ogg_page *og, bool copy_body){ + unsigned char *header=og->header; + unsigned char *body=og->body; + long bodysize=og->body_len; + int segptr=0; + + int version=ogg_page_version(og); + int continued=ogg_page_continued(og); + int bos=ogg_page_bos(og); + int eos=ogg_page_eos(og); + ogg_int64_t granulepos=ogg_page_granulepos(og); + ogg_uint32_t serialno=ogg_page_serialno(og); + long pageno=ogg_page_pageno(og); + int segments=header[26]; + + if(ogg_stream_check(os)) return -1; + + /* clean up 'returned data' */ + { + long lr=os->lacing_returned; + long br=os->body_returned; + + /* body data */ + if(br){ + os->body_fill-=br; + if(os->body_fill) + memmove(os->body_data,os->body_data+br,os->body_fill); + os->body_returned=0; + } + + if(lr){ + /* segment table */ + if(os->lacing_fill-lr){ + memmove(os->lacing_vals,os->lacing_vals+lr, + (os->lacing_fill-lr)*sizeof(*os->lacing_vals)); + memmove(os->granule_vals,os->granule_vals+lr, + (os->lacing_fill-lr)*sizeof(*os->granule_vals)); + } + os->lacing_fill-=lr; + os->lacing_packet-=lr; + os->lacing_returned=0; + } + } + + /* check the serial number */ + if(serialno!=os->serialno)return(-1); + if(version>0)return(-1); + + if(_os_lacing_expand(os,segments+1)) return -1; + + /* are we in sequence? */ + if(pageno!=os->pageno){ + int i; + + /* unroll previous partial packet (if any) */ + for(i=os->lacing_packet;ilacing_fill;i++) + os->body_fill-=os->lacing_vals[i]&0xff; + os->lacing_fill=os->lacing_packet; + + /* make a note of dropped data in segment table */ + if(os->pageno!=-1){ + os->lacing_vals[os->lacing_fill++]=0x400; + os->lacing_packet++; + } + } + + /* are we a 'continued packet' page? If so, we may need to skip + some segments */ + if(continued){ + if(os->lacing_fill<1 || + os->lacing_vals[os->lacing_fill-1]==0x400){ + bos=0; + for(;segptrbody_data+os->body_fill,body,bodysize); + } + os->body_fill+=bodysize; + } + + { + int saved=-1; + while(segptrlacing_vals[os->lacing_fill]=val; + os->granule_vals[os->lacing_fill]=-1; + + if(bos){ + os->lacing_vals[os->lacing_fill]|=0x100; + bos=0; + } + + if(val<255)saved=os->lacing_fill; + + os->lacing_fill++; + segptr++; + + if(val<255)os->lacing_packet=os->lacing_fill; + } + + /* set the granulepos on the last granuleval of the last full packet */ + if(saved!=-1){ + os->granule_vals[saved]=granulepos; + } + + } + + if(eos){ + os->e_o_s=1; + if(os->lacing_fill>0) + os->lacing_vals[os->lacing_fill-1]|=0x200; + } + + os->pageno=pageno+1; + + return(0); +} + +/* clear things to an initial state. Good to call, eg, before seeking */ +int ogg_sync_reset(ogg_sync_state *oy){ + if(ogg_sync_check(oy))return -1; + + oy->fill=0; + oy->returned=0; + oy->unsynced=0; + oy->headerbytes=0; + oy->bodybytes=0; + return(0); +} + +int ogg_stream_reset(ogg_stream_state *os){ + if(ogg_stream_check(os)) return -1; + + os->body_fill=0; + os->body_returned=0; + + os->lacing_fill=0; + os->lacing_packet=0; + os->lacing_returned=0; + +/* os->header_fill=0; */ + + os->e_o_s=0; + os->b_o_s=0; + os->pageno=-1; + os->packetno=0; + os->granulepos=0; + + return(0); +} + +int ogg_stream_reset_serialno(ogg_stream_state *os,int serialno){ + if(ogg_stream_check(os)) return -1; + ogg_stream_reset(os); + os->serialno=serialno; + return(0); +} + +static int _packetout(ogg_stream_state *os,ogg_packet *op,int adv) + ICODE_ATTR_TREMOR_NOT_MDCT; +static int _packetout(ogg_stream_state *os,ogg_packet *op,int adv){ + + /* The last part of decode. We have the stream broken into packet + segments. Now we need to group them into packets (or return the + out of sync markers) */ + + int ptr=os->lacing_returned; + + if(os->lacing_packet<=ptr)return(0); + + if(os->lacing_vals[ptr]&0x400){ + /* we need to tell the codec there's a gap; it might need to + handle previous packet dependencies. */ + os->lacing_returned++; + os->packetno++; + return(-1); + } + + if(!op && !adv)return(1); /* just using peek as an inexpensive way + to ask if there's a whole packet + waiting */ + + /* Gather the whole packet. We'll have no holes or a partial packet */ + { + int size=os->lacing_vals[ptr]&0xff; + long bytes=size; + int eos=os->lacing_vals[ptr]&0x200; /* last packet of the stream? */ + int bos=os->lacing_vals[ptr]&0x100; /* first packet of the stream? */ + + while(size==255){ + int val=os->lacing_vals[++ptr]; + size=val&0xff; + if(val&0x200)eos=0x200; + bytes+=size; + } + + if(op){ + op->e_o_s=eos; + op->b_o_s=bos; + op->packet=os->body_data+os->body_returned; + op->packetno=os->packetno; + op->granulepos=os->granule_vals[ptr]; + op->bytes=bytes; + } + + if(adv){ + os->body_returned+=bytes; + os->lacing_returned=ptr+1; + os->packetno++; + } + } + return(1); +} + +int ogg_stream_packetout(ogg_stream_state *os,ogg_packet *op) + ICODE_ATTR_TREMOR_NOT_MDCT; +int ogg_stream_packetout(ogg_stream_state *os,ogg_packet *op){ + if(ogg_stream_check(os)) return 0; + return _packetout(os,op,1); +} + +int ogg_stream_packetpeek(ogg_stream_state *os,ogg_packet *op) + ICODE_ATTR_TREMOR_NOT_MDCT; +int ogg_stream_packetpeek(ogg_stream_state *os,ogg_packet *op){ + if(ogg_stream_check(os)) return 0; + return _packetout(os,op,0); +} + +/* +void ogg_packet_clear(ogg_packet *op) { + _ogg_free(op->packet); + memset(op, 0, sizeof(*op)); +} +*/ +#ifdef _V_SELFTEST +#include + +ogg_stream_state os_en, os_de; +ogg_sync_state oy; + +void checkpacket(ogg_packet *op,long len, int no, long pos){ + long j; + static int sequence=0; + static int lastno=0; + + if(op->bytes!=len){ + fprintf(stderr,"incorrect packet length (%ld != %ld)!\n",op->bytes,len); + exit(1); + } + if(op->granulepos!=pos){ + fprintf(stderr,"incorrect packet granpos (%ld != %ld)!\n",(long)op->granulepos,pos); + exit(1); + } + + /* packet number just follows sequence/gap; adjust the input number + for that */ + if(no==0){ + sequence=0; + }else{ + sequence++; + if(no>lastno+1) + sequence++; + } + lastno=no; + if(op->packetno!=sequence){ + fprintf(stderr,"incorrect packet sequence %ld != %d\n", + (long)(op->packetno),sequence); + exit(1); + } + + /* Test data */ + for(j=0;jbytes;j++) + if(op->packet[j]!=((j+no)&0xff)){ + fprintf(stderr,"body data mismatch (1) at pos %ld: %x!=%lx!\n\n", + j,op->packet[j],(j+no)&0xff); + exit(1); + } +} + +void check_page(unsigned char *data,const int *header,ogg_page *og){ + long j; + /* Test data */ + for(j=0;jbody_len;j++) + if(og->body[j]!=data[j]){ + fprintf(stderr,"body data mismatch (2) at pos %ld: %x!=%x!\n\n", + j,data[j],og->body[j]); + exit(1); + } + + /* Test header */ + for(j=0;jheader_len;j++){ + if(og->header[j]!=header[j]){ + fprintf(stderr,"header content mismatch at pos %ld:\n",j); + for(j=0;jheader[j]); + fprintf(stderr,"\n"); + exit(1); + } + } + if(og->header_len!=header[26]+27){ + fprintf(stderr,"header length incorrect! (%ld!=%d)\n", + og->header_len,header[26]+27); + exit(1); + } +} + +void print_header(ogg_page *og){ + int j; + fprintf(stderr,"\nHEADER:\n"); + fprintf(stderr," capture: %c %c %c %c version: %d flags: %x\n", + og->header[0],og->header[1],og->header[2],og->header[3], + (int)og->header[4],(int)og->header[5]); + + fprintf(stderr," granulepos: %d serialno: %d pageno: %ld\n", + (og->header[9]<<24)|(og->header[8]<<16)| + (og->header[7]<<8)|og->header[6], + (og->header[17]<<24)|(og->header[16]<<16)| + (og->header[15]<<8)|og->header[14], + ((long)(og->header[21])<<24)|(og->header[20]<<16)| + (og->header[19]<<8)|og->header[18]); + + fprintf(stderr," checksum: %02x:%02x:%02x:%02x\n segments: %d (", + (int)og->header[22],(int)og->header[23], + (int)og->header[24],(int)og->header[25], + (int)og->header[26]); + + for(j=27;jheader_len;j++) + fprintf(stderr,"%d ",(int)og->header[j]); + fprintf(stderr,")\n\n"); +} + +void copy_page(ogg_page *og){ + unsigned char *temp=_ogg_malloc(og->header_len); + memcpy(temp,og->header,og->header_len); + og->header=temp; + + temp=_ogg_malloc(og->body_len); + memcpy(temp,og->body,og->body_len); + og->body=temp; +} + +void free_page(ogg_page *og){ + _ogg_free (og->header); + _ogg_free (og->body); +} + +void error(void){ + fprintf(stderr,"error!\n"); + exit(1); +} + +/* 17 only */ +const int head1_0[] = {0x4f,0x67,0x67,0x53,0,0x06, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x01,0x02,0x03,0x04,0,0,0,0, + 0x15,0xed,0xec,0x91, + 1, + 17}; + +/* 17, 254, 255, 256, 500, 510, 600 byte, pad */ +const int head1_1[] = {0x4f,0x67,0x67,0x53,0,0x02, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x01,0x02,0x03,0x04,0,0,0,0, + 0x59,0x10,0x6c,0x2c, + 1, + 17}; +const int head2_1[] = {0x4f,0x67,0x67,0x53,0,0x04, + 0x07,0x18,0x00,0x00,0x00,0x00,0x00,0x00, + 0x01,0x02,0x03,0x04,1,0,0,0, + 0x89,0x33,0x85,0xce, + 13, + 254,255,0,255,1,255,245,255,255,0, + 255,255,90}; + +/* nil packets; beginning,middle,end */ +const int head1_2[] = {0x4f,0x67,0x67,0x53,0,0x02, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x01,0x02,0x03,0x04,0,0,0,0, + 0xff,0x7b,0x23,0x17, + 1, + 0}; +const int head2_2[] = {0x4f,0x67,0x67,0x53,0,0x04, + 0x07,0x28,0x00,0x00,0x00,0x00,0x00,0x00, + 0x01,0x02,0x03,0x04,1,0,0,0, + 0x5c,0x3f,0x66,0xcb, + 17, + 17,254,255,0,0,255,1,0,255,245,255,255,0, + 255,255,90,0}; + +/* large initial packet */ +const int head1_3[] = {0x4f,0x67,0x67,0x53,0,0x02, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x01,0x02,0x03,0x04,0,0,0,0, + 0x01,0x27,0x31,0xaa, + 18, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,10}; + +const int head2_3[] = {0x4f,0x67,0x67,0x53,0,0x04, + 0x07,0x08,0x00,0x00,0x00,0x00,0x00,0x00, + 0x01,0x02,0x03,0x04,1,0,0,0, + 0x7f,0x4e,0x8a,0xd2, + 4, + 255,4,255,0}; + + +/* continuing packet test */ +const int head1_4[] = {0x4f,0x67,0x67,0x53,0,0x02, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x01,0x02,0x03,0x04,0,0,0,0, + 0xff,0x7b,0x23,0x17, + 1, + 0}; + +const int head2_4[] = {0x4f,0x67,0x67,0x53,0,0x00, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0x01,0x02,0x03,0x04,1,0,0,0, + 0xf8,0x3c,0x19,0x79, + 255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255}; + +const int head3_4[] = {0x4f,0x67,0x67,0x53,0,0x05, + 0x07,0x0c,0x00,0x00,0x00,0x00,0x00,0x00, + 0x01,0x02,0x03,0x04,2,0,0,0, + 0x38,0xe6,0xb6,0x28, + 6, + 255,220,255,4,255,0}; + + +/* spill expansion test */ +const int head1_4b[] = {0x4f,0x67,0x67,0x53,0,0x02, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x01,0x02,0x03,0x04,0,0,0,0, + 0xff,0x7b,0x23,0x17, + 1, + 0}; + +const int head2_4b[] = {0x4f,0x67,0x67,0x53,0,0x00, + 0x07,0x10,0x00,0x00,0x00,0x00,0x00,0x00, + 0x01,0x02,0x03,0x04,1,0,0,0, + 0xce,0x8f,0x17,0x1a, + 23, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,10,255,4,255,0,0}; + + +const int head3_4b[] = {0x4f,0x67,0x67,0x53,0,0x04, + 0x07,0x14,0x00,0x00,0x00,0x00,0x00,0x00, + 0x01,0x02,0x03,0x04,2,0,0,0, + 0x9b,0xb2,0x50,0xa1, + 1, + 0}; + +/* page with the 255 segment limit */ +const int head1_5[] = {0x4f,0x67,0x67,0x53,0,0x02, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x01,0x02,0x03,0x04,0,0,0,0, + 0xff,0x7b,0x23,0x17, + 1, + 0}; + +const int head2_5[] = {0x4f,0x67,0x67,0x53,0,0x00, + 0x07,0xfc,0x03,0x00,0x00,0x00,0x00,0x00, + 0x01,0x02,0x03,0x04,1,0,0,0, + 0xed,0x2a,0x2e,0xa7, + 255, + 10,10,10,10,10,10,10,10, + 10,10,10,10,10,10,10,10, + 10,10,10,10,10,10,10,10, + 10,10,10,10,10,10,10,10, + 10,10,10,10,10,10,10,10, + 10,10,10,10,10,10,10,10, + 10,10,10,10,10,10,10,10, + 10,10,10,10,10,10,10,10, + 10,10,10,10,10,10,10,10, + 10,10,10,10,10,10,10,10, + 10,10,10,10,10,10,10,10, + 10,10,10,10,10,10,10,10, + 10,10,10,10,10,10,10,10, + 10,10,10,10,10,10,10,10, + 10,10,10,10,10,10,10,10, + 10,10,10,10,10,10,10,10, + 10,10,10,10,10,10,10,10, + 10,10,10,10,10,10,10,10, + 10,10,10,10,10,10,10,10, + 10,10,10,10,10,10,10,10, + 10,10,10,10,10,10,10,10, + 10,10,10,10,10,10,10,10, + 10,10,10,10,10,10,10,10, + 10,10,10,10,10,10,10,10, + 10,10,10,10,10,10,10,10, + 10,10,10,10,10,10,10,10, + 10,10,10,10,10,10,10,10, + 10,10,10,10,10,10,10,10, + 10,10,10,10,10,10,10,10, + 10,10,10,10,10,10,10,10, + 10,10,10,10,10,10,10,10, + 10,10,10,10,10,10,10}; + +const int head3_5[] = {0x4f,0x67,0x67,0x53,0,0x04, + 0x07,0x00,0x04,0x00,0x00,0x00,0x00,0x00, + 0x01,0x02,0x03,0x04,2,0,0,0, + 0x6c,0x3b,0x82,0x3d, + 1, + 50}; + + +/* packet that overspans over an entire page */ +const int head1_6[] = {0x4f,0x67,0x67,0x53,0,0x02, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x01,0x02,0x03,0x04,0,0,0,0, + 0xff,0x7b,0x23,0x17, + 1, + 0}; + +const int head2_6[] = {0x4f,0x67,0x67,0x53,0,0x00, + 0x07,0x04,0x00,0x00,0x00,0x00,0x00,0x00, + 0x01,0x02,0x03,0x04,1,0,0,0, + 0x68,0x22,0x7c,0x3d, + 255, + 100, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255}; + +const int head3_6[] = {0x4f,0x67,0x67,0x53,0,0x01, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0x01,0x02,0x03,0x04,2,0,0,0, + 0xf4,0x87,0xba,0xf3, + 255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255}; + +const int head4_6[] = {0x4f,0x67,0x67,0x53,0,0x05, + 0x07,0x10,0x00,0x00,0x00,0x00,0x00,0x00, + 0x01,0x02,0x03,0x04,3,0,0,0, + 0xf7,0x2f,0x6c,0x60, + 5, + 254,255,4,255,0}; + +/* packet that overspans over an entire page */ +const int head1_7[] = {0x4f,0x67,0x67,0x53,0,0x02, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x01,0x02,0x03,0x04,0,0,0,0, + 0xff,0x7b,0x23,0x17, + 1, + 0}; + +const int head2_7[] = {0x4f,0x67,0x67,0x53,0,0x00, + 0x07,0x04,0x00,0x00,0x00,0x00,0x00,0x00, + 0x01,0x02,0x03,0x04,1,0,0,0, + 0x68,0x22,0x7c,0x3d, + 255, + 100, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255, + 255,255,255,255,255,255}; + +const int head3_7[] = {0x4f,0x67,0x67,0x53,0,0x05, + 0x07,0x08,0x00,0x00,0x00,0x00,0x00,0x00, + 0x01,0x02,0x03,0x04,2,0,0,0, + 0xd4,0xe0,0x60,0xe5, + 1, + 0}; + +void test_pack(const int *pl, const int **headers, int byteskip, + int pageskip, int packetskip){ + unsigned char *data=_ogg_malloc(1024*1024); /* for scripted test cases only */ + long inptr=0; + long outptr=0; + long deptr=0; + long depacket=0; + long granule_pos=7,pageno=0; + int i,j,packets,pageout=pageskip; + int eosflag=0; + int bosflag=0; + + int byteskipcount=0; + + ogg_stream_reset(&os_en); + ogg_stream_reset(&os_de); + ogg_sync_reset(&oy); + + for(packets=0;packetsbyteskip){ + memcpy(next,og.header,byteskipcount-byteskip); + next+=byteskipcount-byteskip; + byteskipcount=byteskip; + } + + byteskipcount+=og.body_len; + if(byteskipcount>byteskip){ + memcpy(next,og.body,byteskipcount-byteskip); + next+=byteskipcount-byteskip; + byteskipcount=byteskip; + } + + ogg_sync_wrote(&oy,next-buf); + + while(1){ + int ret=ogg_sync_pageout(&oy,&og_de); + if(ret==0)break; + if(ret<0)continue; + /* got a page. Happy happy. Verify that it's good. */ + + fprintf(stderr,"(%d), ",pageout); + + check_page(data+deptr,headers[pageout],&og_de); + deptr+=og_de.body_len; + pageout++; + + /* submit it to deconstitution */ + ogg_stream_pagein(&os_de,&og_de); + + /* packets out? */ + while(ogg_stream_packetpeek(&os_de,&op_de2)>0){ + ogg_stream_packetpeek(&os_de,NULL); + ogg_stream_packetout(&os_de,&op_de); /* just catching them all */ + + /* verify peek and out match */ + if(memcmp(&op_de,&op_de2,sizeof(op_de))){ + fprintf(stderr,"packetout != packetpeek! pos=%ld\n", + depacket); + exit(1); + } + + /* verify the packet! */ + /* check data */ + if(memcmp(data+depacket,op_de.packet,op_de.bytes)){ + fprintf(stderr,"packet data mismatch in decode! pos=%ld\n", + depacket); + exit(1); + } + /* check bos flag */ + if(bosflag==0 && op_de.b_o_s==0){ + fprintf(stderr,"b_o_s flag not set on packet!\n"); + exit(1); + } + if(bosflag && op_de.b_o_s){ + fprintf(stderr,"b_o_s flag incorrectly set on packet!\n"); + exit(1); + } + bosflag=1; + depacket+=op_de.bytes; + + /* check eos flag */ + if(eosflag){ + fprintf(stderr,"Multiple decoded packets with eos flag!\n"); + exit(1); + } + + if(op_de.e_o_s)eosflag=1; + + /* check granulepos flag */ + if(op_de.granulepos!=-1){ + fprintf(stderr," granule:%ld ",(long)op_de.granulepos); + } + } + } + } + } + } + } + _ogg_free(data); + if(headers[pageno]!=NULL){ + fprintf(stderr,"did not write last page!\n"); + exit(1); + } + if(headers[pageout]!=NULL){ + fprintf(stderr,"did not decode last page!\n"); + exit(1); + } + if(inptr!=outptr){ + fprintf(stderr,"encoded page data incomplete!\n"); + exit(1); + } + if(inptr!=deptr){ + fprintf(stderr,"decoded page data incomplete!\n"); + exit(1); + } + if(inptr!=depacket){ + fprintf(stderr,"decoded packet data incomplete!\n"); + exit(1); + } + if(!eosflag){ + fprintf(stderr,"Never got a packet with EOS set!\n"); + exit(1); + } + fprintf(stderr,"ok.\n"); +} + +int main(void){ + + ogg_stream_init(&os_en,0x04030201); + ogg_stream_init(&os_de,0x04030201); + ogg_sync_init(&oy); + + /* Exercise each code path in the framing code. Also verify that + the checksums are working. */ + + { + /* 17 only */ + const int packets[]={17, -1}; + const int *headret[]={head1_0,NULL}; + + fprintf(stderr,"testing single page encoding... "); + test_pack(packets,headret,0,0,0); + } + + { + /* 17, 254, 255, 256, 500, 510, 600 byte, pad */ + const int packets[]={17, 254, 255, 256, 500, 510, 600, -1}; + const int *headret[]={head1_1,head2_1,NULL}; + + fprintf(stderr,"testing basic page encoding... "); + test_pack(packets,headret,0,0,0); + } + + { + /* nil packets; beginning,middle,end */ + const int packets[]={0,17, 254, 255, 0, 256, 0, 500, 510, 600, 0, -1}; + const int *headret[]={head1_2,head2_2,NULL}; + + fprintf(stderr,"testing basic nil packets... "); + test_pack(packets,headret,0,0,0); + } + + { + /* large initial packet */ + const int packets[]={4345,259,255,-1}; + const int *headret[]={head1_3,head2_3,NULL}; + + fprintf(stderr,"testing initial-packet lacing > 4k... "); + test_pack(packets,headret,0,0,0); + } + + { + /* continuing packet test; with page spill expansion, we have to + overflow the lacing table. */ + const int packets[]={0,65500,259,255,-1}; + const int *headret[]={head1_4,head2_4,head3_4,NULL}; + + fprintf(stderr,"testing single packet page span... "); + test_pack(packets,headret,0,0,0); + } + + { + /* spill expand packet test */ + const int packets[]={0,4345,259,255,0,0,-1}; + const int *headret[]={head1_4b,head2_4b,head3_4b,NULL}; + + fprintf(stderr,"testing page spill expansion... "); + test_pack(packets,headret,0,0,0); + } + + /* page with the 255 segment limit */ + { + + const int packets[]={0,10,10,10,10,10,10,10,10, + 10,10,10,10,10,10,10,10, + 10,10,10,10,10,10,10,10, + 10,10,10,10,10,10,10,10, + 10,10,10,10,10,10,10,10, + 10,10,10,10,10,10,10,10, + 10,10,10,10,10,10,10,10, + 10,10,10,10,10,10,10,10, + 10,10,10,10,10,10,10,10, + 10,10,10,10,10,10,10,10, + 10,10,10,10,10,10,10,10, + 10,10,10,10,10,10,10,10, + 10,10,10,10,10,10,10,10, + 10,10,10,10,10,10,10,10, + 10,10,10,10,10,10,10,10, + 10,10,10,10,10,10,10,10, + 10,10,10,10,10,10,10,10, + 10,10,10,10,10,10,10,10, + 10,10,10,10,10,10,10,10, + 10,10,10,10,10,10,10,10, + 10,10,10,10,10,10,10,10, + 10,10,10,10,10,10,10,10, + 10,10,10,10,10,10,10,10, + 10,10,10,10,10,10,10,10, + 10,10,10,10,10,10,10,10, + 10,10,10,10,10,10,10,10, + 10,10,10,10,10,10,10,10, + 10,10,10,10,10,10,10,10, + 10,10,10,10,10,10,10,10, + 10,10,10,10,10,10,10,10, + 10,10,10,10,10,10,10,10, + 10,10,10,10,10,10,10,50,-1}; + const int *headret[]={head1_5,head2_5,head3_5,NULL}; + + fprintf(stderr,"testing max packet segments... "); + test_pack(packets,headret,0,0,0); + } + + { + /* packet that overspans over an entire page */ + const int packets[]={0,100,130049,259,255,-1}; + const int *headret[]={head1_6,head2_6,head3_6,head4_6,NULL}; + + fprintf(stderr,"testing very large packets... "); + test_pack(packets,headret,0,0,0); + } + + { + /* test for the libogg 1.1.1 resync in large continuation bug + found by Josh Coalson) */ + const int packets[]={0,100,130049,259,255,-1}; + const int *headret[]={head1_6,head2_6,head3_6,head4_6,NULL}; + + fprintf(stderr,"testing continuation resync in very large packets... "); + test_pack(packets,headret,100,2,3); + } + + { + /* term only page. why not? */ + const int packets[]={0,100,64770,-1}; + const int *headret[]={head1_7,head2_7,head3_7,NULL}; + + fprintf(stderr,"testing zero data page (1 nil packet)... "); + test_pack(packets,headret,0,0,0); + } + + + + { + /* build a bunch of pages for testing */ + unsigned char *data=_ogg_malloc(1024*1024); + int pl[]={0, 1,1,98,4079, 1,1,2954,2057, 76,34,912,0,234,1000,1000, 1000,300,-1}; + int inptr=0,i,j; + ogg_page og[5]; + + ogg_stream_reset(&os_en); + + for(i=0;pl[i]!=-1;i++){ + ogg_packet op; + int len=pl[i]; + + op.packet=data+inptr; + op.bytes=len; + op.e_o_s=(pl[i+1]<0?1:0); + op.granulepos=(i+1)*1000; + + for(j=0;j0)error(); + + /* Test fractional page inputs: incomplete fixed header */ + memcpy(ogg_sync_buffer(&oy,og[1].header_len),og[1].header+3, + 20); + ogg_sync_wrote(&oy,20); + if(ogg_sync_pageout(&oy,&og_de)>0)error(); + + /* Test fractional page inputs: incomplete header */ + memcpy(ogg_sync_buffer(&oy,og[1].header_len),og[1].header+23, + 5); + ogg_sync_wrote(&oy,5); + if(ogg_sync_pageout(&oy,&og_de)>0)error(); + + /* Test fractional page inputs: incomplete body */ + + memcpy(ogg_sync_buffer(&oy,og[1].header_len),og[1].header+28, + og[1].header_len-28); + ogg_sync_wrote(&oy,og[1].header_len-28); + if(ogg_sync_pageout(&oy,&og_de)>0)error(); + + memcpy(ogg_sync_buffer(&oy,og[1].body_len),og[1].body,1000); + ogg_sync_wrote(&oy,1000); + if(ogg_sync_pageout(&oy,&og_de)>0)error(); + + memcpy(ogg_sync_buffer(&oy,og[1].body_len),og[1].body+1000, + og[1].body_len-1000); + ogg_sync_wrote(&oy,og[1].body_len-1000); + if(ogg_sync_pageout(&oy,&og_de)<=0)error(); + + fprintf(stderr,"ok.\n"); + } + + /* Test fractional page inputs: page + incomplete capture */ + { + ogg_page og_de; + fprintf(stderr,"Testing sync on 1+partial inputs... "); + ogg_sync_reset(&oy); + + memcpy(ogg_sync_buffer(&oy,og[1].header_len),og[1].header, + og[1].header_len); + ogg_sync_wrote(&oy,og[1].header_len); + + memcpy(ogg_sync_buffer(&oy,og[1].body_len),og[1].body, + og[1].body_len); + ogg_sync_wrote(&oy,og[1].body_len); + + memcpy(ogg_sync_buffer(&oy,og[1].header_len),og[1].header, + 20); + ogg_sync_wrote(&oy,20); + if(ogg_sync_pageout(&oy,&og_de)<=0)error(); + if(ogg_sync_pageout(&oy,&og_de)>0)error(); + + memcpy(ogg_sync_buffer(&oy,og[1].header_len),og[1].header+20, + og[1].header_len-20); + ogg_sync_wrote(&oy,og[1].header_len-20); + memcpy(ogg_sync_buffer(&oy,og[1].body_len),og[1].body, + og[1].body_len); + ogg_sync_wrote(&oy,og[1].body_len); + if(ogg_sync_pageout(&oy,&og_de)<=0)error(); + + fprintf(stderr,"ok.\n"); + } + + /* Test recapture: garbage + page */ + { + ogg_page og_de; + fprintf(stderr,"Testing search for capture... "); + ogg_sync_reset(&oy); + + /* 'garbage' */ + memcpy(ogg_sync_buffer(&oy,og[1].body_len),og[1].body, + og[1].body_len); + ogg_sync_wrote(&oy,og[1].body_len); + + memcpy(ogg_sync_buffer(&oy,og[1].header_len),og[1].header, + og[1].header_len); + ogg_sync_wrote(&oy,og[1].header_len); + + memcpy(ogg_sync_buffer(&oy,og[1].body_len),og[1].body, + og[1].body_len); + ogg_sync_wrote(&oy,og[1].body_len); + + memcpy(ogg_sync_buffer(&oy,og[2].header_len),og[2].header, + 20); + ogg_sync_wrote(&oy,20); + if(ogg_sync_pageout(&oy,&og_de)>0)error(); + if(ogg_sync_pageout(&oy,&og_de)<=0)error(); + if(ogg_sync_pageout(&oy,&og_de)>0)error(); + + memcpy(ogg_sync_buffer(&oy,og[2].header_len),og[2].header+20, + og[2].header_len-20); + ogg_sync_wrote(&oy,og[2].header_len-20); + memcpy(ogg_sync_buffer(&oy,og[2].body_len),og[2].body, + og[2].body_len); + ogg_sync_wrote(&oy,og[2].body_len); + if(ogg_sync_pageout(&oy,&og_de)<=0)error(); + + fprintf(stderr,"ok.\n"); + } + + /* Test recapture: page + garbage + page */ + { + ogg_page og_de; + fprintf(stderr,"Testing recapture... "); + ogg_sync_reset(&oy); + + memcpy(ogg_sync_buffer(&oy,og[1].header_len),og[1].header, + og[1].header_len); + ogg_sync_wrote(&oy,og[1].header_len); + + memcpy(ogg_sync_buffer(&oy,og[1].body_len),og[1].body, + og[1].body_len); + ogg_sync_wrote(&oy,og[1].body_len); + + memcpy(ogg_sync_buffer(&oy,og[2].header_len),og[2].header, + og[2].header_len); + ogg_sync_wrote(&oy,og[2].header_len); + + memcpy(ogg_sync_buffer(&oy,og[2].header_len),og[2].header, + og[2].header_len); + ogg_sync_wrote(&oy,og[2].header_len); + + if(ogg_sync_pageout(&oy,&og_de)<=0)error(); + + memcpy(ogg_sync_buffer(&oy,og[2].body_len),og[2].body, + og[2].body_len-5); + ogg_sync_wrote(&oy,og[2].body_len-5); + + memcpy(ogg_sync_buffer(&oy,og[3].header_len),og[3].header, + og[3].header_len); + ogg_sync_wrote(&oy,og[3].header_len); + + memcpy(ogg_sync_buffer(&oy,og[3].body_len),og[3].body, + og[3].body_len); + ogg_sync_wrote(&oy,og[3].body_len); + + if(ogg_sync_pageout(&oy,&og_de)>0)error(); + if(ogg_sync_pageout(&oy,&og_de)<=0)error(); + + fprintf(stderr,"ok.\n"); + } + + /* Free page data that was previously copied */ + { + for(i=0;i<5;i++){ + free_page(&og[i]); + } + } + } + + return(0); +} + +#endif + + + + diff --git a/lib/rbcodec/codecs/libtremor/info.c b/lib/rbcodec/codecs/libtremor/info.c new file mode 100644 index 0000000000..d922711e34 --- /dev/null +++ b/lib/rbcodec/codecs/libtremor/info.c @@ -0,0 +1,330 @@ +/******************************************************************** + * * + * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * + * * + * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * + * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * + * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * + * * + * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2003 * + * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * + * * + ******************************************************************** + + function: maintain the info structure, info <-> header packets + + ********************************************************************/ + +/* general handling of the header and the vorbis_info structure (and + substructures) */ + +#include "config-tremor.h" +#include +#include +#include "ogg.h" +#include "ivorbiscodec.h" +#include "codec_internal.h" +#include "codebook.h" +#include "registry.h" +#include "window.h" +#include "misc.h" +#include "os.h" + +/* helpers */ +static void _v_readstring(oggpack_buffer *o,char *buf,int bytes){ + while(bytes--){ + *buf++=oggpack_read(o,8); + } +} + +/* +void vorbis_comment_init(vorbis_comment *vc){ + memset(vc,0,sizeof(*vc)); +} + +void vorbis_comment_clear(vorbis_comment *vc){ + if(vc){ + long i; + if(vc->user_comments){ + for(i=0;icomments;i++) + if(vc->user_comments[i])_ogg_free(vc->user_comments[i]); + _ogg_free(vc->user_comments); + } + if(vc->comment_lengths)_ogg_free(vc->comment_lengths); + if(vc->vendor)_ogg_free(vc->vendor); + memset(vc,0,sizeof(*vc)); + } +} +*/ + +/* blocksize 0 is guaranteed to be short, 1 is guarantted to be long. + They may be equal, but short will never ge greater than long */ +int vorbis_info_blocksize(vorbis_info *vi,int zo){ + codec_setup_info *ci = (codec_setup_info *)vi->codec_setup; + return ci ? ci->blocksizes[zo] : -1; +} + +/* used by synthesis, which has a full, alloced vi */ +void vorbis_info_init(vorbis_info *vi){ + memset(vi,0,sizeof(*vi)); + vi->codec_setup=(codec_setup_info *)_ogg_calloc(1,sizeof(codec_setup_info)); +} + +void vorbis_info_clear(vorbis_info *vi){ + codec_setup_info *ci=(codec_setup_info *)vi->codec_setup; + int i; + + if(ci){ + + for(i=0;imodes;i++) + if(ci->mode_param[i])_ogg_free(ci->mode_param[i]); + + for(i=0;imaps;i++) /* unpack does the range checking */ + if(ci->map_param[i]) + _mapping_P[ci->map_type[i]]->free_info(ci->map_param[i]); + + for(i=0;ifloors;i++) /* unpack does the range checking */ + if(ci->floor_param[i]) + _floor_P[ci->floor_type[i]]->free_info(ci->floor_param[i]); + + for(i=0;iresidues;i++) /* unpack does the range checking */ + if(ci->residue_param[i]) + _residue_P[ci->residue_type[i]]->free_info(ci->residue_param[i]); + + for(i=0;ibooks;i++){ + if(ci->book_param[i]){ + /* knows if the book was not alloced */ + vorbis_staticbook_destroy(ci->book_param[i]); + } + if(ci->fullbooks) + vorbis_book_clear(ci->fullbooks+i); + } + if(ci->fullbooks) + _ogg_free(ci->fullbooks); + + _ogg_free(ci); + } + + memset(vi,0,sizeof(*vi)); +} + +/* Header packing/unpacking ********************************************/ + +static int _vorbis_unpack_info(vorbis_info *vi,oggpack_buffer *opb){ + codec_setup_info *ci=(codec_setup_info *)vi->codec_setup; + if(!ci)return(OV_EFAULT); + + vi->version=oggpack_read(opb,32); + if(vi->version!=0)return(OV_EVERSION); + + vi->channels=oggpack_read(opb,8); + vi->rate=oggpack_read(opb,32); + + vi->bitrate_upper=oggpack_read(opb,32); + vi->bitrate_nominal=oggpack_read(opb,32); + vi->bitrate_lower=oggpack_read(opb,32); + + ci->blocksizes_nbits[0]=oggpack_read(opb,4); + ci->blocksizes_nbits[1]=oggpack_read(opb,4); + ci->blocksizes[0]=1<<(ci->blocksizes_nbits[0]); + ci->blocksizes[1]=1<<(ci->blocksizes_nbits[1]); + + if(vi->rate<1)goto err_out; + if(vi->channels<1)goto err_out; + if(ci->blocksizes[0]<64)goto err_out; + if(ci->blocksizes[1]blocksizes[0])goto err_out; + if(ci->blocksizes[1]>8192)goto err_out; + + if(oggpack_read(opb,1)!=1)goto err_out; /* EOP check */ + + return(0); + err_out: + vorbis_info_clear(vi); + return(OV_EBADHEADER); +} + +#if 0 +static int _vorbis_unpack_comment(vorbis_comment *vc,oggpack_buffer *opb){ + int vendorlen; + vendorlen=oggpack_read(opb,32); + if(vendorlen<0)goto err_out; + if(vendorlen>opb->storage-oggpack_bytes(opb))goto err_out; + vc->vendor=(char *)_ogg_calloc(vendorlen+1,1); + if(vc->vendor==NULL)goto err_out; + _v_readstring(opb,vc->vendor,vendorlen); + vc->comments=0; + /* ROCKBOX: the meat of this function was deleted as we don't need it */ + return(0); + err_out: + vorbis_comment_clear(vc); + return(OV_EBADHEADER); +} +#endif + +/* all of the real encoding details are here. The modes, books, + everything */ +static int _vorbis_unpack_books(vorbis_info *vi,oggpack_buffer *opb){ + codec_setup_info *ci=(codec_setup_info *)vi->codec_setup; + int i; + if(!ci)return(OV_EFAULT); + + /* codebooks */ + ci->books=oggpack_read(opb,8)+1; + if(ci->books<=0)goto err_out; + for(i=0;ibooks;i++){ + ci->book_param[i]=vorbis_staticbook_unpack(opb); + if(!ci->book_param[i])goto err_out; + } + + /* time backend settings */ + ci->times=oggpack_read(opb,6)+1; + if(ci->times<=0)goto err_out; + for(i=0;itimes;i++){ + ci->time_type[i]=oggpack_read(opb,16); + if(ci->time_type[i]<0 || ci->time_type[i]>=VI_TIMEB)goto err_out; + /* ci->time_param[i]=_time_P[ci->time_type[i]]->unpack(vi,opb); + Vorbis I has no time backend */ + /*if(!ci->time_param[i])goto err_out;*/ + } + + /* floor backend settings */ + ci->floors=oggpack_read(opb,6)+1; + if(ci->floors<=0)goto err_out; + for(i=0;ifloors;i++){ + ci->floor_type[i]=oggpack_read(opb,16); + if(ci->floor_type[i]<0 || ci->floor_type[i]>=VI_FLOORB)goto err_out; + ci->floor_param[i]=_floor_P[ci->floor_type[i]]->unpack(vi,opb); + if(!ci->floor_param[i])goto err_out; + } + + /* residue backend settings */ + ci->residues=oggpack_read(opb,6)+1; + if(ci->residues<=0)goto err_out; + for(i=0;iresidues;i++){ + ci->residue_type[i]=oggpack_read(opb,16); + if(ci->residue_type[i]<0 || ci->residue_type[i]>=VI_RESB)goto err_out; + ci->residue_param[i]=_residue_P[ci->residue_type[i]]->unpack(vi,opb); + if(!ci->residue_param[i])goto err_out; + } + + /* map backend settings */ + ci->maps=oggpack_read(opb,6)+1; + if(ci->maps<=0)goto err_out; + for(i=0;imaps;i++){ + ci->map_type[i]=oggpack_read(opb,16); + if(ci->map_type[i]<0 || ci->map_type[i]>=VI_MAPB)goto err_out; + ci->map_param[i]=_mapping_P[ci->map_type[i]]->unpack(vi,opb); + if(!ci->map_param[i])goto err_out; + } + + /* mode settings */ + ci->modes=oggpack_read(opb,6)+1; + if(ci->modes<=0)goto err_out; + for(i=0;imodes;i++){ + ci->mode_param[i]=(vorbis_info_mode *)_ogg_calloc(1,sizeof(*ci->mode_param[i])); + ci->mode_param[i]->blockflag=oggpack_read(opb,1); + ci->mode_param[i]->windowtype=oggpack_read(opb,16); + ci->mode_param[i]->transformtype=oggpack_read(opb,16); + ci->mode_param[i]->mapping=oggpack_read(opb,8); + + if(ci->mode_param[i]->windowtype>=VI_WINDOWB)goto err_out; + if(ci->mode_param[i]->transformtype>=VI_WINDOWB)goto err_out; + if(ci->mode_param[i]->mapping>=ci->maps)goto err_out; + if(ci->mode_param[i]->mapping<0)goto err_out; + } + + if(oggpack_read(opb,1)!=1)goto err_out; /* top level EOP check */ + + return(0); + err_out: + vorbis_info_clear(vi); + return(OV_EBADHEADER); +} + +/* Is this packet a vorbis ID header? */ +int vorbis_synthesis_idheader(ogg_packet *op){ + oggpack_buffer opb; + char buffer[6]; + + if(op){ + oggpack_readinit(&opb,op->packet,op->bytes); + + if(!op->b_o_s) + return(0); /* Not the initial packet */ + + if(oggpack_read(&opb,8) != 1) + return 0; /* not an ID header */ + + memset(buffer,0,6); + _v_readstring(&opb,buffer,6); + if(memcmp(buffer,"vorbis",6)) + return 0; /* not vorbis */ + + return 1; + } + + return 0; +} + +/* The Vorbis header is in three packets; the initial small packet in + the first page that identifies basic parameters, a second packet + with bitstream comments and a third packet that holds the + codebook. */ + +int vorbis_synthesis_headerin(vorbis_info *vi,ogg_packet *op){ + oggpack_buffer opb; + + if(op){ + oggpack_readinit(&opb,op->packet,op->bytes); + + /* Which of the three types of header is this? */ + /* Also verify header-ness, vorbis */ + { + char buffer[6]; + int packtype=oggpack_read(&opb,8); + memset(buffer,0,6); + _v_readstring(&opb,buffer,6); + if(memcmp(buffer,"vorbis",6)){ + /* not a vorbis header */ + return(OV_ENOTVORBIS); + } + switch(packtype){ + case 0x01: /* least significant *bit* is read first */ + if(!op->b_o_s){ + /* Not the initial packet */ + return(OV_EBADHEADER); + } + if(vi->rate!=0){ + /* previously initialized info header */ + return(OV_EBADHEADER); + } + + return(_vorbis_unpack_info(vi,&opb)); + + case 0x03: /* least significant *bit* is read first */ + if(vi->rate==0){ + /* um... we didn't get the initial header */ + return(OV_EBADHEADER); + } + + /*return(_vorbis_unpack_comment(vc,&opb));*/ + return 0; + + case 0x05: /* least significant *bit* is read first */ + if(vi->rate==0 /*|| vc->vendor==NULL*/){ + /* um... we didn;t get the initial header or comments yet */ + return(OV_EBADHEADER); + } + + return(_vorbis_unpack_books(vi,&opb)); + + default: + /* Not a valid vorbis header type */ + return(OV_EBADHEADER); + break; + } + } + } + return(OV_EBADHEADER); +} + diff --git a/lib/rbcodec/codecs/libtremor/ivorbiscodec.h b/lib/rbcodec/codecs/libtremor/ivorbiscodec.h new file mode 100644 index 0000000000..4fb041603d --- /dev/null +++ b/lib/rbcodec/codecs/libtremor/ivorbiscodec.h @@ -0,0 +1,204 @@ +/******************************************************************** + * * + * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * + * * + * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * + * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * + * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * + * * + * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * + * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * + * * + ******************************************************************** + + function: libvorbis codec headers + + ********************************************************************/ + +#ifndef _vorbis_codec_h_ +#define _vorbis_codec_h_ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#include "ogg.h" +//#include + +typedef struct vorbis_info{ + int version; + int channels; + long rate; + + /* The below bitrate declarations are *hints*. + Combinations of the three values carry the following implications: + + all three set to the same value: + implies a fixed rate bitstream + only nominal set: + implies a VBR stream that averages the nominal bitrate. No hard + upper/lower limit + upper and or lower set: + implies a VBR bitstream that obeys the bitrate limits. nominal + may also be set to give a nominal rate. + none set: + the coder does not care to speculate. + */ + + long bitrate_upper; + long bitrate_nominal; + long bitrate_lower; + + void *codec_setup; +} vorbis_info; + +/* vorbis_dsp_state buffers the current vorbis audio + analysis/synthesis state. The DSP state belongs to a specific + logical bitstream ****************************************************/ +typedef struct vorbis_dsp_state{ + vorbis_info *vi; + + ogg_int32_t *residues[2]; + ogg_int32_t *floors; + ogg_int32_t *saved; + ogg_int32_t *saved_ptr[CHANNELS]; + + int ri; + + ogg_int32_t **pcmb; + ogg_int32_t **pcmret; + int pcm_storage; + int pcm_current; + int pcm_returned; + + int eofflag; + + long lW; + long W; + long nW; + + ogg_int64_t granulepos; + ogg_int64_t sequence; + + void *backend_state; +} vorbis_dsp_state; + +typedef struct vorbis_block{ + /* necessary stream state for linking to the framing abstraction */ + oggpack_buffer opb; + + long lW; + long W; + long nW; + int pcmend; + int mode; + + int eofflag; + ogg_int64_t granulepos; + ogg_int64_t sequence; + vorbis_dsp_state *vd; /* For read-only access of configuration */ + + /* local storage to avoid remallocing; it's up to the mapping to + structure it */ + void *localstore; + long localtop; + long localalloc; + long totaluse; + struct alloc_chain *reap; +} vorbis_block; + +/* vorbis_block is a single block of data to be processed as part of +the analysis/synthesis stream; it belongs to a specific logical +bitstream, but is independant from other vorbis_blocks belonging to +that logical bitstream. *************************************************/ + +struct alloc_chain{ + void *ptr; + struct alloc_chain *next; +}; + +/* vorbis_info contains all the setup information specific to the + specific compression/decompression mode in progress (eg, + psychoacoustic settings, channel setup, options, codebook + etc). vorbis_info and substructures are in backends.h. +*********************************************************************/ + +/* the comments are not part of vorbis_info so that vorbis_info can be + static storage */ +typedef struct vorbis_comment{ + /* unlimited user comment fields. libvorbis writes 'libvorbis' + whatever vendor is set to in encode */ + char **user_comments; + int *comment_lengths; + int comments; + char *vendor; + +} vorbis_comment; + + +/* libvorbis encodes in two abstraction layers; first we perform DSP + and produce a packet (see docs/analysis.txt). The packet is then + coded into a framed OggSquish bitstream by the second layer (see + docs/framing.txt). Decode is the reverse process; we sync/frame + the bitstream and extract individual packets, then decode the + packet back into PCM audio. + + The extra framing/packetizing is used in streaming formats, such as + files. Over the net (such as with UDP), the framing and + packetization aren't necessary as they're provided by the transport + and the streaming layer is not used */ + +/* Vorbis PRIMITIVES: general ***************************************/ + +extern void vorbis_info_init(vorbis_info *vi); +extern void vorbis_info_clear(vorbis_info *vi); +extern int vorbis_info_blocksize(vorbis_info *vi,int zo); +/* +extern void vorbis_comment_init(vorbis_comment *vc); +extern void vorbis_comment_add(vorbis_comment *vc, char *comment); +extern void vorbis_comment_add_tag(vorbis_comment *vc, + char *tag, char *contents); +extern void vorbis_comment_clear(vorbis_comment *vc); +*/ +extern int vorbis_block_init(vorbis_dsp_state *v, vorbis_block *vb); +extern int vorbis_block_clear(vorbis_block *vb); +extern void vorbis_dsp_clear(vorbis_dsp_state *v); + +/* Vorbis PRIMITIVES: synthesis layer *******************************/ +extern int vorbis_synthesis_idheader(ogg_packet *op); +extern int vorbis_synthesis_headerin(vorbis_info *vi,ogg_packet *op); + +extern int vorbis_synthesis_init(vorbis_dsp_state *v,vorbis_info *vi); +extern int vorbis_synthesis_restart(vorbis_dsp_state *v); +extern int vorbis_synthesis(vorbis_block *vb,ogg_packet *op); +extern int vorbis_synthesis_trackonly(vorbis_block *vb,ogg_packet *op); +extern int vorbis_synthesis_blockin(vorbis_dsp_state *v,vorbis_block *vb); +extern int vorbis_synthesis_pcmout(vorbis_dsp_state *v,ogg_int32_t ***pcm); +extern int vorbis_synthesis_read(vorbis_dsp_state *v,int samples); +extern long vorbis_packet_blocksize(vorbis_info *vi,ogg_packet *op); + +/* Vorbis ERRORS and return codes ***********************************/ + +#define OV_FALSE -1 +#define OV_EOF -2 +#define OV_HOLE -3 + +#define OV_EREAD -128 +#define OV_EFAULT -129 +#define OV_EIMPL -130 +#define OV_EINVAL -131 +#define OV_ENOTVORBIS -132 +#define OV_EBADHEADER -133 +#define OV_EVERSION -134 +#define OV_ENOTAUDIO -135 +#define OV_EBADPACKET -136 +#define OV_EBADLINK -137 +#define OV_ENOSEEK -138 + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif + diff --git a/lib/rbcodec/codecs/libtremor/ivorbisfile.h b/lib/rbcodec/codecs/libtremor/ivorbisfile.h new file mode 100644 index 0000000000..076783514e --- /dev/null +++ b/lib/rbcodec/codecs/libtremor/ivorbisfile.h @@ -0,0 +1,131 @@ +/******************************************************************** + * * + * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * + * * + * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * + * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * + * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * + * * + * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * + * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * + * * + ******************************************************************** + + function: stdio-based convenience library for opening/seeking/decoding + + ********************************************************************/ + +#ifndef _OV_FILE_H_ +#define _OV_FILE_H_ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#include +#include "ivorbiscodec.h" + + +#define CHUNKSIZE 1024 +/* The function prototypes for the callbacks are basically the same as for + * the stdio functions fread, fseek, fclose, ftell. + * The one difference is that the FILE * arguments have been replaced with + * a void * - this is to be used as a pointer to whatever internal data these + * functions might need. In the stdio case, it's just a FILE * cast to a void * + * + * If you use other functions, check the docs for these functions and return + * the right values. For seek_func(), you *MUST* return -1 if the stream is + * unseekable + */ +typedef struct { + size_t (*read_func) (void *ptr, size_t size, size_t nmemb, void *datasource); + int (*seek_func) (void *datasource, ogg_int64_t offset, int whence); + int (*close_func) (void *datasource); + long (*tell_func) (void *datasource); +} ov_callbacks; + +#define NOTOPEN 0 +#define PARTOPEN 1 +#define OPENED 2 +#define STREAMSET 3 +#define INITSET 4 + +typedef struct OggVorbis_File { + void *datasource; /* Pointer to a FILE *, etc. */ + int seekable; + ogg_int64_t offset; + ogg_int64_t end; + ogg_sync_state oy; + + /* If the FILE handle isn't seekable (eg, a pipe), only the current + stream appears */ + int links; + ogg_int64_t *offsets; + ogg_int64_t *dataoffsets; + ogg_uint32_t *serialnos; + ogg_int64_t *pcmlengths; + vorbis_info *vi; +/* vorbis_comment *vc; */ + + /* Decoding working state local storage */ + ogg_int64_t pcm_offset; + int ready_state; + ogg_uint32_t current_serialno; + int current_link; + + ogg_int64_t bittrack; + ogg_int64_t samptrack; + + ogg_stream_state os; /* take physical pages, weld into a logical + stream of packets */ + vorbis_dsp_state vd; /* central working state for the packet->PCM decoder */ + vorbis_block vb; /* local working space for packet->PCM decode */ + + ov_callbacks callbacks; + +} OggVorbis_File; + +extern int ov_clear(OggVorbis_File *vf); +extern int ov_open_callbacks(void *datasource, OggVorbis_File *vf, + const char *initial, long ibytes, ov_callbacks callbacks); + +extern int ov_test_callbacks(void *datasource, OggVorbis_File *vf, + const char *initial, long ibytes, ov_callbacks callbacks); +extern int ov_test_open(OggVorbis_File *vf); + +extern long ov_bitrate(OggVorbis_File *vf,int i); +extern long ov_bitrate_instant(OggVorbis_File *vf); +extern long ov_streams(OggVorbis_File *vf); +extern long ov_seekable(OggVorbis_File *vf); +extern long ov_serialnumber(OggVorbis_File *vf,int i); + +extern ogg_int64_t ov_raw_total(OggVorbis_File *vf,int i); +extern ogg_int64_t ov_pcm_total(OggVorbis_File *vf,int i); +extern ogg_int64_t ov_time_total(OggVorbis_File *vf,int i); + +extern int ov_raw_seek(OggVorbis_File *vf,ogg_int64_t pos); +extern int ov_pcm_seek(OggVorbis_File *vf,ogg_int64_t pos); +extern int ov_pcm_seek_page(OggVorbis_File *vf,ogg_int64_t pos); +extern int ov_time_seek(OggVorbis_File *vf,ogg_int64_t pos); +extern int ov_time_seek_page(OggVorbis_File *vf,ogg_int64_t pos); + +extern ogg_int64_t ov_raw_tell(OggVorbis_File *vf); +extern ogg_int64_t ov_pcm_tell(OggVorbis_File *vf); +extern ogg_int64_t ov_time_tell(OggVorbis_File *vf); + +extern vorbis_info *ov_info(OggVorbis_File *vf,int link); +extern vorbis_comment *ov_comment(OggVorbis_File *vf,int link); + +extern long ov_read(OggVorbis_File *vf,char *buffer,int length, + int *bitstream); +extern long ov_read_fixed(OggVorbis_File *vf,ogg_int32_t ***pcm_channels, + int length,int *bitstream); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif + + diff --git a/lib/rbcodec/codecs/libtremor/libtremor.make b/lib/rbcodec/codecs/libtremor/libtremor.make new file mode 100644 index 0000000000..4a581508b0 --- /dev/null +++ b/lib/rbcodec/codecs/libtremor/libtremor.make @@ -0,0 +1,18 @@ +# __________ __ ___. +# Open \______ \ ____ ____ | | _\_ |__ _______ ___ +# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / +# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < +# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ +# \/ \/ \/ \/ \/ +# $Id$ +# + +# libtremor +TREMORLIB := $(CODECDIR)/libtremor.a +TREMORLIB_SRC := $(call preprocess, $(RBCODECLIB_DIR)/codecs/libtremor/SOURCES) +TREMORLIB_OBJ := $(call c2obj, $(TREMORLIB_SRC)) +OTHER_SRC += $(TREMORLIB_SRC) + +$(TREMORLIB): $(TREMORLIB_OBJ) + $(SILENT)$(shell rm -f $@) + $(call PRINTS,AR $(@F))$(AR) rcs $@ $^ >/dev/null diff --git a/lib/rbcodec/codecs/libtremor/lsp_lookup.h b/lib/rbcodec/codecs/libtremor/lsp_lookup.h new file mode 100644 index 0000000000..d996677ca1 --- /dev/null +++ b/lib/rbcodec/codecs/libtremor/lsp_lookup.h @@ -0,0 +1,132 @@ +/******************************************************************** + * * + * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * + * * + * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * + * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * + * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * + * * + * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * + * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * + * * + ******************************************************************** + + function: lookup data + + ********************************************************************/ + +#ifndef _V_LOOKUP_DATA_H_ +#define _V_LOOKUP_DATA_H_ + +#include "os_types.h" + +#define FROMdB_LOOKUP_SZ 35 +#define FROMdB2_LOOKUP_SZ 32 +#define FROMdB_SHIFT 5 +#define FROMdB2_SHIFT 3 +#define FROMdB2_MASK 31 + +static const ogg_int32_t FROMdB_LOOKUP[FROMdB_LOOKUP_SZ] ={ + 0x003fffff, 0x0028619b, 0x00197a96, 0x0010137a, + 0x000a24b0, 0x00066666, 0x000409c3, 0x00028c42, + 0x00019b8c, 0x000103ab, 0x0000a3d7, 0x00006760, + 0x0000413a, 0x00002928, 0x000019f8, 0x00001062, + 0x00000a56, 0x00000686, 0x0000041e, 0x00000299, + 0x000001a3, 0x00000109, 0x000000a7, 0x00000069, + 0x00000042, 0x0000002a, 0x0000001a, 0x00000011, + 0x0000000b, 0x00000007, 0x00000004, 0x00000003, + 0x00000002, 0x00000001, 0x00000001}; + +static const ogg_int32_t FROMdB2_LOOKUP[FROMdB2_LOOKUP_SZ] ={ + 0x000001fc, 0x000001f5, 0x000001ee, 0x000001e7, + 0x000001e0, 0x000001d9, 0x000001d2, 0x000001cc, + 0x000001c5, 0x000001bf, 0x000001b8, 0x000001b2, + 0x000001ac, 0x000001a6, 0x000001a0, 0x0000019a, + 0x00000194, 0x0000018e, 0x00000188, 0x00000183, + 0x0000017d, 0x00000178, 0x00000172, 0x0000016d, + 0x00000168, 0x00000163, 0x0000015e, 0x00000159, + 0x00000154, 0x0000014f, 0x0000014a, 0x00000145, +}; + +#define INVSQ_LOOKUP_I_SHIFT 10 +#define INVSQ_LOOKUP_I_MASK 1023 +static const long INVSQ_LOOKUP_I[64+1] ={ + 92682, 91966, 91267, 90583, + 89915, 89261, 88621, 87995, + 87381, 86781, 86192, 85616, + 85051, 84497, 83953, 83420, + 82897, 82384, 81880, 81385, + 80899, 80422, 79953, 79492, + 79039, 78594, 78156, 77726, + 77302, 76885, 76475, 76072, + 75674, 75283, 74898, 74519, + 74146, 73778, 73415, 73058, + 72706, 72359, 72016, 71679, + 71347, 71019, 70695, 70376, + 70061, 69750, 69444, 69141, + 68842, 68548, 68256, 67969, + 67685, 67405, 67128, 66855, + 66585, 66318, 66054, 65794, + 65536, +}; + +static const long INVSQ_LOOKUP_IDel[64] ={ + 716, 699, 684, 668, + 654, 640, 626, 614, + 600, 589, 576, 565, + 554, 544, 533, 523, + 513, 504, 495, 486, + 477, 469, 461, 453, + 445, 438, 430, 424, + 417, 410, 403, 398, + 391, 385, 379, 373, + 368, 363, 357, 352, + 347, 343, 337, 332, + 328, 324, 319, 315, + 311, 306, 303, 299, + 294, 292, 287, 284, + 280, 277, 273, 270, + 267, 264, 260, 258, +}; + +#define COS_LOOKUP_I_SHIFT 9 +#define COS_LOOKUP_I_MASK 511 +#define COS_LOOKUP_I_SZ 128 +static const ogg_int32_t COS_LOOKUP_I[COS_LOOKUP_I_SZ+1] ={ + 16384, 16379, 16364, 16340, + 16305, 16261, 16207, 16143, + 16069, 15986, 15893, 15791, + 15679, 15557, 15426, 15286, + 15137, 14978, 14811, 14635, + 14449, 14256, 14053, 13842, + 13623, 13395, 13160, 12916, + 12665, 12406, 12140, 11866, + 11585, 11297, 11003, 10702, + 10394, 10080, 9760, 9434, + 9102, 8765, 8423, 8076, + 7723, 7366, 7005, 6639, + 6270, 5897, 5520, 5139, + 4756, 4370, 3981, 3590, + 3196, 2801, 2404, 2006, + 1606, 1205, 804, 402, + 0, -401, -803, -1204, + -1605, -2005, -2403, -2800, + -3195, -3589, -3980, -4369, + -4755, -5138, -5519, -5896, + -6269, -6638, -7004, -7365, + -7722, -8075, -8422, -8764, + -9101, -9433, -9759, -10079, + -10393, -10701, -11002, -11296, + -11584, -11865, -12139, -12405, + -12664, -12915, -13159, -13394, + -13622, -13841, -14052, -14255, + -14448, -14634, -14810, -14977, + -15136, -15285, -15425, -15556, + -15678, -15790, -15892, -15985, + -16068, -16142, -16206, -16260, + -16304, -16339, -16363, -16378, + -16383, +}; + +#endif + diff --git a/lib/rbcodec/codecs/libtremor/mapping0.c b/lib/rbcodec/codecs/libtremor/mapping0.c new file mode 100644 index 0000000000..084d5e076d --- /dev/null +++ b/lib/rbcodec/codecs/libtremor/mapping0.c @@ -0,0 +1,416 @@ +/******************************************************************** + * * + * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * + * * + * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * + * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * + * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * + * * + * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * + * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * + * * + ******************************************************************** + + function: channel mapping 0 implementation + + ********************************************************************/ + +#include "config-tremor.h" +#include +#include +#include +#include "ogg.h" +#include "ivorbiscodec.h" +#include "codeclib.h" +#include "codec_internal.h" +#include "codebook.h" +#include "window.h" +#include "registry.h" +#include "misc.h" +#include + +/* simplistic, wasteful way of doing this (unique lookup for each + mode/submapping); there should be a central repository for + identical lookups. That will require minor work, so I'm putting it + off as low priority. + + Why a lookup for each backend in a given mode? Because the + blocksize is set by the mode, and low backend lookups may require + parameters from other areas of the mode/mapping */ + +typedef struct { + vorbis_info_mode *mode; + vorbis_info_mapping0 *map; + + vorbis_look_floor **floor_look; + + vorbis_look_residue **residue_look; + + vorbis_func_floor **floor_func; + vorbis_func_residue **residue_func; + + int ch; + long lastframe; /* if a different mode is called, we need to + invalidate decay */ +} vorbis_look_mapping0; + +static void mapping0_free_info(vorbis_info_mapping *i){ + vorbis_info_mapping0 *info=(vorbis_info_mapping0 *)i; + if(info){ + memset(info,0,sizeof(*info)); + _ogg_free(info); + } +} + +static void mapping0_free_look(vorbis_look_mapping *look){ + int i; + vorbis_look_mapping0 *l=(vorbis_look_mapping0 *)look; + if(l){ + + for(i=0;imap->submaps;i++){ + l->floor_func[i]->free_look(l->floor_look[i]); + l->residue_func[i]->free_look(l->residue_look[i]); + } + + _ogg_free(l->floor_func); + _ogg_free(l->residue_func); + _ogg_free(l->floor_look); + _ogg_free(l->residue_look); + memset(l,0,sizeof(*l)); + _ogg_free(l); + } +} + +static vorbis_look_mapping *mapping0_look(vorbis_dsp_state *vd,vorbis_info_mode *vm, + vorbis_info_mapping *m){ + int i; + vorbis_info *vi=vd->vi; + codec_setup_info *ci=(codec_setup_info *)vi->codec_setup; + vorbis_look_mapping0 *look=(vorbis_look_mapping0 *)_ogg_calloc(1,sizeof(*look)); + vorbis_info_mapping0 *info=look->map=(vorbis_info_mapping0 *)m; + look->mode=vm; + + look->floor_look=(vorbis_look_floor **)_ogg_calloc(info->submaps,sizeof(*look->floor_look)); + + look->residue_look=(vorbis_look_residue **)_ogg_calloc(info->submaps,sizeof(*look->residue_look)); + + look->floor_func=(vorbis_func_floor **)_ogg_calloc(info->submaps,sizeof(*look->floor_func)); + look->residue_func=(vorbis_func_residue **)_ogg_calloc(info->submaps,sizeof(*look->residue_func)); + + for(i=0;isubmaps;i++){ + int floornum=info->floorsubmap[i]; + int resnum=info->residuesubmap[i]; + + look->floor_func[i]=_floor_P[ci->floor_type[floornum]]; + look->floor_look[i]=look->floor_func[i]-> + look(vd,vm,ci->floor_param[floornum]); + look->residue_func[i]=_residue_P[ci->residue_type[resnum]]; + look->residue_look[i]=look->residue_func[i]-> + look(vd,vm,ci->residue_param[resnum]); + + } + + look->ch=vi->channels; + + return(look); +} + +static int ilog(unsigned int v){ + int ret=0; + if(v)--v; + while(v){ + ret++; + v>>=1; + } + return(ret); +} + + +/* also responsible for range checking */ +static vorbis_info_mapping *mapping0_unpack(vorbis_info *vi,oggpack_buffer *opb){ + int i,b; + vorbis_info_mapping0 *info=(vorbis_info_mapping0 *)_ogg_calloc(1,sizeof(*info)); + codec_setup_info *ci=(codec_setup_info *)vi->codec_setup; + memset(info,0,sizeof(*info)); + + b=oggpack_read(opb,1); + if(b<0)goto err_out; + if(b){ + info->submaps=oggpack_read(opb,4)+1; + if(info->submaps<=0)goto err_out; + }else + info->submaps=1; + + b=oggpack_read(opb,1); + if(b<0)goto err_out; + if(b){ + info->coupling_steps=oggpack_read(opb,8)+1; + if(info->coupling_steps<=0)goto err_out; + for(i=0;icoupling_steps;i++){ + int testM=oggpack_read(opb,ilog(vi->channels)); + info->coupling_mag[i]=testM; + int testA=oggpack_read(opb,ilog(vi->channels)); + info->coupling_ang[i]=testA; + + if(testM<0 || + testA<0 || + testM==testA || + testM>=vi->channels || + testA>=vi->channels) goto err_out; + } + + } + + if(oggpack_read(opb,2)!=0)goto err_out; /* 2,3:reserved */ + + if(info->submaps>1){ + for(i=0;ichannels;i++){ + info->chmuxlist[i]=oggpack_read(opb,4); + if(info->chmuxlist[i]>=info->submaps || info->chmuxlist[i]<0)goto err_out; + } + } + for(i=0;isubmaps;i++){ + int temp=oggpack_read(opb,8); + if(temp>=ci->times)goto err_out; + info->floorsubmap[i]=oggpack_read(opb,8); + if(info->floorsubmap[i]>=ci->floors || info->floorsubmap[i]<0)goto err_out; + info->residuesubmap[i]=oggpack_read(opb,8); + if(info->residuesubmap[i]>=ci->residues || info->residuesubmap[i]<0) + goto err_out; + } + + return info; + + err_out: + mapping0_free_info(info); + return(NULL); +} + +#ifdef _ARM_ASSEM_ +#define MAGANG( _mag, _ang )\ +{\ + register int temp;\ + asm( "mov %[temp], %[ang]\n\t"\ + "cmp %[mag], #0\n\t"\ + "rsble %[temp], %[temp], #0\n\t"\ + "cmp %[ang], #0\n\t"\ + "subgt %[ang], %[mag], %[temp]\n\t"\ + "movle %[ang], %[mag]\n\t"\ + "addle %[mag], %[mag], %[temp]\n\t"\ + : [mag] "+r" ( ( _mag ) ), [ang] "+r" ( ( _ang ) ), [temp] "=&r" (temp)\ + :\ + : "cc" );\ +} + +static inline void channel_couple(ogg_int32_t *pcmM, ogg_int32_t *pcmA, int n) +{ + ogg_int32_t * const pcmMend = pcmM + n/2; + while(LIKELY(pcmM < pcmMend)) + { + register int M0 asm("r2"),M1 asm("r3"),M2 asm("r4"),M3 asm("r5"); + register int A0 asm("r6"),A1 asm("r7"),A2 asm("r8"),A3 asm("r9"); + asm volatile( "ldmia %[pcmM], {%[M0], %[M1], %[M2], %[M3]}\n\t" + "ldmia %[pcmA], {%[A0], %[A1], %[A2], %[A3]}\n\t" + : [M0] "=r" (M0), [M1] "=r" (M1), [M2] "=r" (M2), [M3] "=r" (M3), + [A0] "=r" (A0), [A1] "=r" (A1), [A2] "=r" (A2), [A3] "=r" (A3) + : [pcmM] "r" (pcmM), [pcmA] "r" (pcmA) + : "memory" ); + MAGANG( M0, A0 ); + MAGANG( M1, A1 ); + MAGANG( M2, A2 ); + MAGANG( M3, A3 ); + asm volatile( "stmia %[pcmM]!, {%[M0], %[M1], %[M2], %[M3]}\n\t" + "stmia %[pcmA]!, {%[A0], %[A1], %[A2], %[A3]}\n\t" + : [pcmM] "+r" (pcmM), [pcmA] "+r" (pcmA) + : [M0] "r" (M0), [M1] "r" (M1), [M2] "r" (M2), [M3] "r" (M3), + [A0] "r" (A0), [A1] "r" (A1), [A2] "r" (A2), [A3] "r" (A3) + : "memory" ); + } +} + +#elif defined CPU_COLDFIRE + +#define MAGANG( _mag, _ang, _off )\ +{\ + asm volatile( "tst.l %[mag]\n\t"\ + "bgt.s 1f\n\t"\ + "neg.l %[ang]\n\t" /* neg sets cc so we might as well jump */ \ + "ble.s 2f\n\t"\ + ".word 0x51fb\n\t" /* trapf.l, shadow next 2 insns */ \ + /* if we didn't jump, the next test will */ \ + /* false anyway */ \ + "1:\n\t"\ + "tst.l %[ang]\n\t"\ + "bgt.s 2f\n\t"\ + "add.l %[mag], %[ang]\n\t"\ + "move.l %[ang], (" #_off ", %[pcmM])\n\t"\ + ".word 0x51fa\n\t" /* trapf.w, shadow next insn */ \ + "2:\n\t"\ + "sub.l %[ang], %[mag]\n\t"\ + "move.l %[mag], (%[pcmA])+\n\t"\ + : [mag] "+r" ( ( _mag ) ), [ang] "+d" ( ( _ang ) ),\ + [pcmA] "+a" (pcmA)\ + : [pcmM] "a" (pcmM)\ + : "cc", "memory" );\ +} +static inline void channel_couple(ogg_int32_t *pcmM, ogg_int32_t *pcmA, unsigned int n) +{ + ogg_int32_t * const pcmMend = pcmM + n/2; + while(LIKELY(pcmM < pcmMend)) + { + register int M0 asm("a2"),M1 asm("a3"),M2 asm("a4"),M3 asm("a5"); + register int A0 asm("d2"),A1 asm("d3"),A2 asm("d4"),A3 asm("d5"); + asm volatile( "movem.l (%[pcmM]), %[M0]-%[M3]\n\t" + "movem.l (%[pcmA]), %[A0]-%[A3]\n\t" + : [M0] "=r" (M0), [M1] "=r" (M1), [M2] "=r" (M2), [M3] "=r" (M3), + [A0] "=r" (A0), [A1] "=r" (A1), [A2] "=r" (A2), [A3] "=r" (A3) + : [pcmM] "a" (pcmM), [pcmA] "a" (pcmA) ); + + /* use offsets instead of autoinc since the store to pcmM is conditional */ + MAGANG( M0, A0, 0 ); + MAGANG( M1, A1, 4 ); + MAGANG( M2, A2, 8 ); + MAGANG( M3, A3, 12 ); + + asm volatile( "lea.l (4*4, %[pcmM]), %[pcmM]\n\t" + : [pcmM] "+a" (pcmM)); + } +} +#else +static inline void channel_couple(ogg_int32_t *pcmM, ogg_int32_t *pcmA, int n) +{ + int j; + for(j=0;j0) + _ang = ang; + else + _ang = -ang; + + if(ang>0) + pcmA[j]=mag-_ang; + else{ + pcmA[j]=mag; + pcmM[j]=mag+_ang; + } + + } +} +#endif + +static int mapping0_inverse(vorbis_block *vb,vorbis_look_mapping *l){ + vorbis_dsp_state *vd=vb->vd; + vorbis_info *vi=vd->vi; + codec_setup_info *ci=(codec_setup_info *)vi->codec_setup; + vorbis_look_mapping0 *look=(vorbis_look_mapping0 *)l; + vorbis_info_mapping0 *info=look->map; + + int i,j; + long n=vb->pcmend=ci->blocksizes[vb->W]; + + /* bounded mapping arrays instead of using alloca(); + avoids memory leak; we can only deal with stereo anyway */ + ogg_int32_t *pcmbundle[CHANNELS]; + int zerobundle[CHANNELS]; + int nonzero[CHANNELS]; + void *floormemo[CHANNELS]; + + /* time domain information decode (note that applying the + information would have to happen later; we'll probably add a + function entry to the harness for that later */ + /* NOT IMPLEMENTED */ + + /* recover the spectral envelope; store it in the PCM vector for now */ + for(i=0;ichannels;i++){ + int submap=info->chmuxlist[i]; + floormemo[i]=look->floor_func[submap]-> + inverse1(vb,look->floor_look[submap]); + if(floormemo[i]) + nonzero[i]=1; + else + nonzero[i]=0; + memset(vd->floors + i * ci->blocksizes[vb->W]/2,0,sizeof(ogg_int32_t)*n/2); + } + + /* channel coupling can 'dirty' the nonzero listing */ + for(i=0;icoupling_steps;i++){ + if(nonzero[info->coupling_mag[i]] || + nonzero[info->coupling_ang[i]]){ + nonzero[info->coupling_mag[i]]=1; + nonzero[info->coupling_ang[i]]=1; + } + } + + /* recover the residue into our working vectors */ + for(i=0;isubmaps;i++){ + int ch_in_bundle=0; + for(j=0;jchannels;j++){ + if(info->chmuxlist[j]==i){ + if(nonzero[j]) + zerobundle[ch_in_bundle]=1; + else + zerobundle[ch_in_bundle]=0; + pcmbundle[ch_in_bundle++] = vd->floors + j * ci->blocksizes[vb->W]/2; + } + } + + look->residue_func[i]->inverse(vb,look->residue_look[i], + pcmbundle,zerobundle,ch_in_bundle); + } + + //for(j=0;jchannels;j++) + //_analysis_output("coupled",seq+j,vb->pcm[j],-8,n/2,0,0); + + + /* channel coupling */ + for(i=info->coupling_steps-1;i>=0;i--){ + ogg_int32_t *pcmM = vd->floors + info->coupling_mag[i] * ci->blocksizes[vb->W]/2; + ogg_int32_t *pcmA = vd->floors + info->coupling_ang[i] * ci->blocksizes[vb->W]/2; + channel_couple(pcmM,pcmA,n); + } + + //for(j=0;jchannels;j++) + //_analysis_output("residue",seq+j,vb->pcm[j],-8,n/2,0,0); + + //for(j=0;jchannels;j++) + //_analysis_output("mdct",seq+j,vb->pcm[j],-24,n/2,0,1); + + /* transform the PCM data; takes PCM vector, vb; modifies PCM vector */ + /* only MDCT right now.... */ + for(i=0;ichannels;i++){ + ogg_int32_t *pcm = vd->floors + i*ci->blocksizes[vb->W]/2; + int submap=info->chmuxlist[i]; + + if(nonzero[i]) { + /* compute and apply spectral envelope */ + look->floor_func[submap]-> + inverse2(vb,look->floor_look[submap],floormemo[i],pcm); + + ff_imdct_half(ci->blocksizes_nbits[vb->W], + (int32_t*)vd->residues[vd->ri] + i*ci->blocksizes[vb->W]/2, + (int32_t*)&vd->floors[i*ci->blocksizes[vb->W]/2]); + } + else + memset(vd->residues[vd->ri] + i*ci->blocksizes[vb->W]/2, 0, sizeof(ogg_int32_t)*n/2); + } + + //for(j=0;jchannels;j++) + //_analysis_output("imdct",seq+j,vb->pcm[j],-24,n,0,0); + + //for(j=0;jchannels;j++) + //_analysis_output("window",seq+j,vb->pcm[j],-24,n,0,0); + + //seq+=vi->channels; + /* all done! */ + return(0); +} + +/* export hooks */ +const vorbis_func_mapping mapping0_exportbundle ICONST_ATTR ={ + &mapping0_unpack, + &mapping0_look, + &mapping0_free_info, + &mapping0_free_look, + &mapping0_inverse +}; + diff --git a/lib/rbcodec/codecs/libtremor/misc.h b/lib/rbcodec/codecs/libtremor/misc.h new file mode 100644 index 0000000000..592a60ffd8 --- /dev/null +++ b/lib/rbcodec/codecs/libtremor/misc.h @@ -0,0 +1,276 @@ +/******************************************************************** + * * + * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * + * * + * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * + * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * + * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * + * * + * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * + * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * + * * + ******************************************************************** + + function: miscellaneous math and prototypes + + ********************************************************************/ + +#include "config-tremor.h" + +#ifndef _V_RANDOM_H_ +#define _V_RANDOM_H_ +#include "ivorbiscodec.h" +#include "os_types.h" + +#include "codeclib_misc.h" + +#include "asm_arm.h" +#include "asm_mcf5249.h" + +/* Some prototypes that were not defined elsewhere */ +void *_vorbis_block_alloc(vorbis_block *vb,long bytes); +void _vorbis_block_ripcord(vorbis_block *vb); +extern int _ilog(unsigned int v); + +#ifndef _V_WIDE_MATH +#define _V_WIDE_MATH + +#ifndef _LOW_ACCURACY_ +/* 64 bit multiply */ +/* #include */ +#if 0 +#if BYTE_ORDER==LITTLE_ENDIAN +union magic { + struct { + ogg_int32_t lo; + ogg_int32_t hi; + } halves; + ogg_int64_t whole; +}; +#elif BYTE_ORDER==BIG_ENDIAN +union magic { + struct { + ogg_int32_t hi; + ogg_int32_t lo; + } halves; + ogg_int64_t whole; +}; +#endif + +static inline ogg_int32_t MULT32(ogg_int32_t x, ogg_int32_t y) { + union magic magic; + magic.whole = (ogg_int64_t)x * y; + return magic.halves.hi; +} +static inline ogg_int32_t MULT31(ogg_int32_t x, ogg_int32_t y) { + return MULT32(x,y)<<1; +} + +static inline ogg_int32_t MULT31_SHIFT15(ogg_int32_t x, ogg_int32_t y) { + union magic magic; + magic.whole = (ogg_int64_t)x * y; + return ((ogg_uint32_t)(magic.halves.lo)>>15) | ((magic.halves.hi)<<17); +} +#endif +#else +/* 32 bit multiply, more portable but less accurate */ + +/* + * Note: Precision is biased towards the first argument therefore ordering + * is important. Shift values were chosen for the best sound quality after + * many listening tests. + */ + +/* + * For MULT32 and MULT31: The second argument is always a lookup table + * value already preshifted from 31 to 8 bits. We therefore take the + * opportunity to save on text space and use unsigned char for those + * tables in this case. + */ + +static inline ogg_int32_t MULT32(ogg_int32_t x, ogg_int32_t y) { + return (x >> 9) * y; /* y preshifted >>23 */ +} + +static inline ogg_int32_t MULT31(ogg_int32_t x, ogg_int32_t y) { + return (x >> 8) * y; /* y preshifted >>23 */ +} + +static inline ogg_int32_t MULT31_SHIFT15(ogg_int32_t x, ogg_int32_t y) { + return (x >> 6) * y; /* y preshifted >>9 */ +} +#endif + +/* + * This should be used as a memory barrier, forcing all cached values in + * registers to wr writen back to memory. Might or might not be beneficial + * depending on the architecture and compiler. + */ +#define MB() + +/* + * The XPROD functions are meant to optimize the cross products found all + * over the place in mdct.c by forcing memory operation ordering to avoid + * unnecessary register reloads as soon as memory is being written to. + * However this is only beneficial on CPUs with a sane number of general + * purpose registers which exclude the Intel x86. On Intel, better let the + * compiler actually reload registers directly from original memory by using + * macros. + */ + +/* replaced XPROD32 with a macro to avoid memory reference + _x, _y are the results (must be l-values) */ +/* +#define XPROD32(_a, _b, _t, _v, _x, _y) \ + { (_x)=MULT32(_a,_t)+MULT32(_b,_v); \ + (_y)=MULT32(_b,_t)-MULT32(_a,_v); } +*/ + +#ifdef __i386__ + +#define XPROD31(_a, _b, _t, _v, _x, _y) \ + { *(_x)=MULT31(_a,_t)+MULT31(_b,_v); \ + *(_y)=MULT31(_b,_t)-MULT31(_a,_v); } +#define XNPROD31(_a, _b, _t, _v, _x, _y) \ + { *(_x)=MULT31(_a,_t)-MULT31(_b,_v); \ + *(_y)=MULT31(_b,_t)+MULT31(_a,_v); } + +#else +/* +static inline void XPROD31(ogg_int32_t a, ogg_int32_t b, + ogg_int32_t t, ogg_int32_t v, + ogg_int32_t *x, ogg_int32_t *y) +{ + *x = MULT31(a, t) + MULT31(b, v); + *y = MULT31(b, t) - MULT31(a, v); +} + +static inline void XNPROD31(ogg_int32_t a, ogg_int32_t b, + ogg_int32_t t, ogg_int32_t v, + ogg_int32_t *x, ogg_int32_t *y) +{ + *x = MULT31(a, t) - MULT31(b, v); + *y = MULT31(b, t) + MULT31(a, v); +} +*/ +#endif + +#if 0 +#ifndef _V_VECT_OPS +#define _V_VECT_OPS + +/* generic misc.h has symmetrical versions of vect_add_right_left + and vect_add_left_right (since symmetrical versions of + vect_mult_fw and vect_mult_bw i.e. both use MULT31) */ +static inline +void vect_add_right_left(ogg_int32_t *x, const ogg_int32_t *y, int n) +{ + while (n>0) { + *x++ += *y++; + n--; + } +} + +static inline +void vect_add_left_right(ogg_int32_t *x, const ogg_int32_t *y, int n) +{ + vect_add_right_left(x,y,n); +} + +static inline +void ogg_vect_mult_fw(ogg_int32_t *data, LOOKUP_T *window, int n) +{ + while(n>0) { + *data = MULT31(*data, *window); + data++; + window++; + n--; + } +} + +static inline +void ogg_vect_mult_bw(ogg_int32_t *data, LOOKUP_T *window, int n) +{ + while(n>0) { + *data = MULT31(*data, *window); + data++; + window--; + n--; + } +} + +/* generic memcpy is probably optimal */ +static inline void vect_copy(ogg_int32_t *x, const ogg_int32_t *y, int n) +{ + memcpy(x,y,n*sizeof(ogg_int32_t)); +} +#endif + +static inline ogg_int32_t VFLOAT_MULT(ogg_int32_t a,ogg_int32_t ap, + ogg_int32_t b,ogg_int32_t bp, + ogg_int32_t *p){ + if(a && b){ +#ifndef _LOW_ACCURACY_ + *p=ap+bp+32; + return MULT32(a,b); +#else + *p=ap+bp+31; + return (a>>15)*(b>>16); +#endif + }else + return 0; +} +#endif +#endif +static inline ogg_int32_t VFLOAT_MULTI(ogg_int32_t a,ogg_int32_t ap, + ogg_int32_t i, + ogg_int32_t *p){ + + int ip=_ilog(abs(i))-31; + return VFLOAT_MULT(a,ap,i<<-ip,ip,p); +} +#if 0 +static inline ogg_int32_t VFLOAT_ADD(ogg_int32_t a,ogg_int32_t ap, + ogg_int32_t b,ogg_int32_t bp, + ogg_int32_t *p){ + + if(!a){ + *p=bp; + return b; + }else if(!b){ + *p=ap; + return a; + } + + /* yes, this can leak a bit. */ + if(ap>bp){ + int shift=ap-bp+1; + *p=ap+1; + a>>=1; + if(shift<32){ + b=(b+(1<<(shift-1)))>>shift; + }else{ + b=0; + } + }else{ + int shift=bp-ap+1; + *p=bp+1; + b>>=1; + if(shift<32){ + a=(a+(1<<(shift-1)))>>shift; + }else{ + a=0; + } + } + + a+=b; + if((a&0xc0000000)==0xc0000000 || + (a&0xc0000000)==0){ + a<<=1; + (*p)--; + } + return(a); +} +#endif +#endif + diff --git a/lib/rbcodec/codecs/libtremor/ogg.h b/lib/rbcodec/codecs/libtremor/ogg.h new file mode 100644 index 0000000000..d3af919b85 --- /dev/null +++ b/lib/rbcodec/codecs/libtremor/ogg.h @@ -0,0 +1,282 @@ +/******************************************************************** + * * + * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * + * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * + * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * + * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * + * * + * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * + * by the Xiph.Org Foundation http://www.xiph.org/ * + * * + ******************************************************************** + + function: toplevel libogg include + last mod: $Id$ + + ********************************************************************/ +#ifndef _OGG_H +#define _OGG_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include "os_types.h" + +extern const unsigned long mask[] ICONST_ATTR; + +typedef struct { + void *iov_base; + size_t iov_len; +} ogg_iovec_t; + +typedef struct { + long endbyte; + int endbit; + + unsigned char *buffer; + unsigned char *ptr; + long storage; +} oggpack_buffer; + +/* ogg_page is used to encapsulate the data in one Ogg bitstream page *****/ + +typedef struct { + unsigned char *header; + long header_len; + unsigned char *body; + long body_len; +} ogg_page; + +/* ogg_stream_state contains the current encode/decode state of a logical + Ogg bitstream **********************************************************/ + +typedef struct { + unsigned char *body_data; /* bytes from packet bodies */ + long body_storage; /* storage elements allocated */ + long body_fill; /* elements stored; fill mark */ + long body_returned; /* elements of fill returned */ + + + int *lacing_vals; /* The values that will go to the segment table */ + ogg_int64_t *granule_vals; /* granulepos values for headers. Not compact + this way, but it is simple coupled to the + lacing fifo */ + long lacing_storage; + long lacing_fill; + long lacing_packet; + long lacing_returned; + +#if 0 + unsigned char header[282]; /* working space for header encode */ + int header_fill; +#endif + int e_o_s; /* set when we have buffered the last packet in the + logical bitstream */ + int b_o_s; /* set after we've written the initial page + of a logical bitstream */ + ogg_uint32_t serialno; + long pageno; + ogg_int64_t packetno; /* sequence number for decode; the framing + knows where there's a hole in the data, + but we need coupling so that the codec + (which is in a separate abstraction + layer) also knows about the gap */ + ogg_int64_t granulepos; + +} ogg_stream_state; + +/* ogg_packet is used to encapsulate the data and metadata belonging + to a single raw Ogg/Vorbis packet *************************************/ + +typedef struct { + unsigned char *packet; + long bytes; + long b_o_s; + long e_o_s; + + ogg_int64_t granulepos; + + ogg_int64_t packetno; /* sequence number for decode; the framing + knows where there's a hole in the data, + but we need coupling so that the codec + (which is in a separate abstraction + layer) also knows about the gap */ +} ogg_packet; + +typedef struct { + unsigned char *data; + int storage; + int fill; + int returned; + + int unsynced; + int headerbytes; + int bodybytes; +} ogg_sync_state; + +/* Ogg BITSTREAM PRIMITIVES: bitstream ************************/ +/* +extern void oggpack_writeinit(oggpack_buffer *b); +extern int oggpack_writecheck(oggpack_buffer *b); +extern void oggpack_writetrunc(oggpack_buffer *b,long bits); +extern void oggpack_writealign(oggpack_buffer *b); +extern void oggpack_writecopy(oggpack_buffer *b,void *source,long bits); +extern void oggpack_reset(oggpack_buffer *b); +extern void oggpack_writeclear(oggpack_buffer *b); */ +extern void oggpack_readinit(oggpack_buffer *b,unsigned char *buf,int bytes); +/* +extern void oggpack_write(oggpack_buffer *b,unsigned long value,int bits); +extern long oggpack_look(oggpack_buffer *b,int bits); +*/ + +static inline long oggpack_look(oggpack_buffer *b,int bits){ + unsigned long ret; + unsigned long m; + + if(bits<0 || bits>32) return -1; + m=mask[bits]; + bits+=b->endbit; + + if(b->endbyte >= b->storage-4){ + /* not the main path */ + if(b->endbyte > b->storage-((bits+7)>>3)) return -1; + /* special case to avoid reading b->ptr[0], which might be past the end of + the buffer; also skips some useless accounting */ + else if(!bits)return(0L); + } + + ret=b->ptr[0]>>b->endbit; + if(bits>8){ + ret|=b->ptr[1]<<(8-b->endbit); + if(bits>16){ + ret|=b->ptr[2]<<(16-b->endbit); + if(bits>24){ + ret|=b->ptr[3]<<(24-b->endbit); + if(bits>32 && b->endbit) + ret|=b->ptr[4]<<(32-b->endbit); + } + } + } + return(m&ret); +} +/* +extern long oggpack_look1(oggpack_buffer *b); +extern void oggpack_adv(oggpack_buffer *b,int bits); +*/ + +static inline void oggpack_adv(oggpack_buffer *b, unsigned int bits){ + bits+=b->endbit; + + if(b->endbyte > b->storage-(int)((bits+7)>>3)) goto overflow; + + b->ptr+=bits/8; + b->endbyte+=bits/8; + b->endbit=bits&7; + return; + + overflow: + b->ptr=NULL; + b->endbyte=b->storage; + b->endbit=1; +} + +/* +extern void oggpack_adv1(oggpack_buffer *b); +*/ +extern long oggpack_read(oggpack_buffer *b,int bits); +/* +extern long oggpack_read1(oggpack_buffer *b); +extern long oggpack_bytes(oggpack_buffer *b); +*/ +static inline long oggpack_bytes(oggpack_buffer *b){ + return(b->endbyte+(b->endbit+7)/8); +} +#if 0 +extern long oggpack_bits(oggpack_buffer *b); +extern unsigned char *oggpack_get_buffer(oggpack_buffer *b); + +extern void oggpackB_writeinit(oggpack_buffer *b); +extern int oggpackB_writecheck(oggpack_buffer *b); +extern void oggpackB_writetrunc(oggpack_buffer *b,long bits); +extern void oggpackB_writealign(oggpack_buffer *b); +extern void oggpackB_writecopy(oggpack_buffer *b,void *source,long bits); +extern void oggpackB_reset(oggpack_buffer *b); +extern void oggpackB_writeclear(oggpack_buffer *b); +extern void oggpackB_readinit(oggpack_buffer *b,unsigned char *buf,int bytes); +extern void oggpackB_write(oggpack_buffer *b,unsigned long value,int bits); +extern long oggpackB_look(oggpack_buffer *b,int bits); +extern long oggpackB_look1(oggpack_buffer *b); +extern void oggpackB_adv(oggpack_buffer *b,int bits); +extern void oggpackB_adv1(oggpack_buffer *b); +extern long oggpackB_read(oggpack_buffer *b,int bits); +extern long oggpackB_read1(oggpack_buffer *b); +extern long oggpackB_bytes(oggpack_buffer *b); +extern long oggpackB_bits(oggpack_buffer *b); +extern unsigned char *oggpackB_get_buffer(oggpack_buffer *b); +# endif +/* Ogg BITSTREAM PRIMITIVES: encoding **************************/ +#if 0 +extern int ogg_stream_packetin(ogg_stream_state *os, ogg_packet *op); +extern int ogg_stream_iovecin(ogg_stream_state *os, ogg_iovec_t *iov, + int count, long e_o_s, ogg_int64_t granulepos); +extern int ogg_stream_pageout(ogg_stream_state *os, ogg_page *og); +extern int ogg_stream_pageout_fill(ogg_stream_state *os, ogg_page *og, int nfill); +extern int ogg_stream_flush(ogg_stream_state *os, ogg_page *og); +#endif +/* Ogg BITSTREAM PRIMITIVES: decoding **************************/ + +extern int _os_body_expand(ogg_stream_state *os,int needed); + +extern int ogg_sync_init(ogg_sync_state *oy); +extern int ogg_sync_clear(ogg_sync_state *oy); +extern int ogg_sync_reset(ogg_sync_state *oy); +/* +extern int ogg_sync_destroy(ogg_sync_state *oy); +extern int ogg_sync_check(ogg_sync_state *oy); +*/ + +extern char *ogg_sync_buffer(ogg_sync_state *oy, long size); +extern int ogg_sync_wrote(ogg_sync_state *oy, long bytes); +extern long ogg_sync_pageseek(ogg_sync_state *oy,ogg_page *og); +/* +extern int ogg_sync_pageout(ogg_sync_state *oy, ogg_page *og); +*/ +extern int ogg_stream_pagein(ogg_stream_state *os, ogg_page *og, bool copy_body); +extern int ogg_stream_packetout(ogg_stream_state *os,ogg_packet *op); +extern int ogg_stream_packetpeek(ogg_stream_state *os,ogg_packet *op); + +/* Ogg BITSTREAM PRIMITIVES: general ***************************/ + +extern int ogg_stream_init(ogg_stream_state *os,int serialno); +extern int ogg_stream_clear(ogg_stream_state *os); +extern int ogg_stream_reset(ogg_stream_state *os); +extern int ogg_stream_reset_serialno(ogg_stream_state *os,int serialno); +/* +extern int ogg_stream_destroy(ogg_stream_state *os); +extern int ogg_stream_check(ogg_stream_state *os); +*/ +extern int ogg_stream_eos(ogg_stream_state *os); + +/* +extern void ogg_page_checksum_set(ogg_page *og); +extern int ogg_page_version(const ogg_page *og); +*/ +extern int ogg_page_continued(const ogg_page *og); +extern int ogg_page_bos(const ogg_page *og); +extern int ogg_page_eos(const ogg_page *og); +extern ogg_int64_t ogg_page_granulepos(const ogg_page *og); +extern ogg_uint32_t ogg_page_serialno(const ogg_page *og); +/* +extern long ogg_page_pageno(const ogg_page *og); +extern int ogg_page_packets(const ogg_page *og); + +extern void ogg_packet_clear(ogg_packet *op); +*/ + +#ifdef __cplusplus +} +#endif + +#endif /* _OGG_H */ diff --git a/lib/rbcodec/codecs/libtremor/oggmalloc.c b/lib/rbcodec/codecs/libtremor/oggmalloc.c new file mode 100644 index 0000000000..783e0f7240 --- /dev/null +++ b/lib/rbcodec/codecs/libtremor/oggmalloc.c @@ -0,0 +1,86 @@ +#include "os_types.h" +#include + +#if defined(CPU_ARM) || defined(CPU_COLDFIRE) || defined(CPU_MIPS) +#include +extern jmp_buf rb_jump_buf; +#define LONGJMP(x) longjmp(rb_jump_buf, x) +#elif defined(SIMULATOR) +#define LONGJMP(x) do { DEBUGF("Vorbis: allocation failed!\n"); return NULL; } while (false) +#else +#define LONGJMP(x) return NULL +#endif + +void ogg_malloc_init(void) +{ + size_t bufsize; + void* buf = ci->codec_get_buffer(&bufsize); + init_memory_pool(bufsize, buf); +} + +void ogg_malloc_destroy() +{ + size_t bufsize; + void* buf = ci->codec_get_buffer(&bufsize); + destroy_memory_pool(buf); +} + +void *ogg_malloc(size_t size) +{ + void* x = tlsf_malloc(size); + + if (x == NULL) + LONGJMP(1); + + return x; +} + +void *ogg_calloc(size_t nmemb, size_t size) +{ + void *x = tlsf_calloc(nmemb, size); + + if (x == NULL) + LONGJMP(1); + + return x; +} + +void *ogg_realloc(void *ptr, size_t size) +{ + void *x = tlsf_realloc(ptr, size); + + if (x == NULL) + LONGJMP(1); + + return x; +} + +void ogg_free(void* ptr) +{ + tlsf_free(ptr); +} + +#ifdef TREMOR_USE_IRAM +/* Allocate IRAM buffer */ +static unsigned char iram_buff[IRAM_IBSS_SIZE] IBSS_ATTR MEM_ALIGN_ATTR; +static size_t iram_remain; + +void iram_malloc_init(void){ + iram_remain=IRAM_IBSS_SIZE; +} + +void *iram_malloc(size_t size){ + void* x; + + /* always ensure alignment to CACHEALIGN_SIZE byte */ + size = (size + (CACHEALIGN_SIZE-1)) & ~(CACHEALIGN_SIZE-1); + + if(size>iram_remain) + return NULL; + + x = &iram_buff[IRAM_IBSS_SIZE-iram_remain]; + iram_remain-=size; + + return x; +} +#endif diff --git a/lib/rbcodec/codecs/libtremor/os.h b/lib/rbcodec/codecs/libtremor/os.h new file mode 100644 index 0000000000..bafcaedb62 --- /dev/null +++ b/lib/rbcodec/codecs/libtremor/os.h @@ -0,0 +1,62 @@ +#ifndef _OS_H +#define _OS_H +/******************************************************************** + * * + * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * + * * + * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * + * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * + * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * + * * + * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * + * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * + * * + ******************************************************************** + + function: #ifdef jail to whip a few platforms into the UNIX ideal. + + ********************************************************************/ + +#include +#include "os_types.h" + +#ifndef _V_IFDEFJAIL_H_ +# define _V_IFDEFJAIL_H_ + +# ifdef __GNUC__ +# define STIN static inline +# elif defined(_WIN32) +# define STIN static __inline__ +# endif +#else +# define STIN static inline +#endif + +#ifndef M_PI +# define M_PI (3.1415926536f) +#endif + +#ifdef _WIN32 +# include +# define rint(x) (floor((x)+0.5f)) +# define NO_FLOAT_MATH_LIB +# define FAST_HYPOT(a, b) sqrt((a)*(a) + (b)*(b)) +#endif + +#ifdef HAVE_ALLOCA_H +# include +#endif + +#ifdef USE_MEMORY_H +# include +#endif + +#ifndef min +# define min(x,y) ((x)>(y)?(y):(x)) +#endif + +#ifndef max +# define max(x,y) ((x)<(y)?(y):(x)) +#endif + +#endif /* _OS_H */ diff --git a/lib/rbcodec/codecs/libtremor/os_types.h b/lib/rbcodec/codecs/libtremor/os_types.h new file mode 100644 index 0000000000..b5bd0b713a --- /dev/null +++ b/lib/rbcodec/codecs/libtremor/os_types.h @@ -0,0 +1,58 @@ +/******************************************************************** + * * + * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * + * * + * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * + * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * + * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * + * * + * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * + * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * + * * + ******************************************************************** + + function: #ifdef jail to whip a few platforms into the UNIX ideal. + + ********************************************************************/ +#include "config-tremor.h" + +#ifndef _OS_TYPES_H +#define _OS_TYPES_H + +#include +#include +#include + +#ifdef _LOW_ACCURACY_ +# define X(n) (((((n)>>22)+1)>>1) - ((((n)>>22)+1)>>9)) +# define LOOKUP_T const unsigned char +# define LOOKUP_TNC unsigned char +#else +# define X(n) (n) +# define LOOKUP_T const ogg_int32_t +# define LOOKUP_TNC ogg_int32_t +#endif + +/* make it easy on the folks that want to compile the libs with a + different malloc than stdlib */ + +#define _ogg_malloc ogg_malloc +#define _ogg_calloc ogg_calloc +#define _ogg_realloc ogg_realloc +#define _ogg_free ogg_free + +void ogg_malloc_init(void); +void ogg_malloc_destroy(void); +void *ogg_malloc(size_t size); +void *ogg_calloc(size_t nmemb, size_t size); +void *ogg_realloc(void *ptr, size_t size); +void ogg_free(void *ptr); +void iram_malloc_init(void); +void *iram_malloc(size_t size); + + typedef int16_t ogg_int16_t; + typedef int32_t ogg_int32_t; + typedef uint32_t ogg_uint32_t; + typedef int64_t ogg_int64_t; + +#endif /* _OS_TYPES_H */ diff --git a/lib/rbcodec/codecs/libtremor/registry.c b/lib/rbcodec/codecs/libtremor/registry.c new file mode 100644 index 0000000000..b1592628a1 --- /dev/null +++ b/lib/rbcodec/codecs/libtremor/registry.c @@ -0,0 +1,50 @@ +/******************************************************************** + * * + * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * + * * + * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * + * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * + * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * + * * + * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * + * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * + * * + ******************************************************************** + + function: registry for floor, res backends and channel mappings + + ********************************************************************/ + +#include "ivorbiscodec.h" +#include "codec_internal.h" +#include "registry.h" +#include "misc.h" + + +/* seems like major overkill now; the backend numbers will grow into + the infrastructure soon enough */ + +extern vorbis_func_floor floor0_exportbundle; +extern vorbis_func_floor floor1_exportbundle; +extern vorbis_func_residue residue0_exportbundle; +extern vorbis_func_residue residue1_exportbundle; +extern vorbis_func_residue residue2_exportbundle; +extern vorbis_func_mapping mapping0_exportbundle; + +vorbis_func_floor *_floor_P[] ICONST_ATTR = { + &floor0_exportbundle, + &floor1_exportbundle, +}; + +vorbis_func_residue *_residue_P[] ICONST_ATTR = { + &residue0_exportbundle, + &residue1_exportbundle, + &residue2_exportbundle, +}; + +vorbis_func_mapping *_mapping_P[] ICONST_ATTR = { + &mapping0_exportbundle, +}; + + + diff --git a/lib/rbcodec/codecs/libtremor/registry.h b/lib/rbcodec/codecs/libtremor/registry.h new file mode 100644 index 0000000000..2bc8068f69 --- /dev/null +++ b/lib/rbcodec/codecs/libtremor/registry.h @@ -0,0 +1,40 @@ +/******************************************************************** + * * + * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * + * * + * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * + * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * + * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * + * * + * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * + * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * + * * + ******************************************************************** + + function: registry for time, floor, res backends and channel mappings + + ********************************************************************/ + +#ifndef _V_REG_H_ +#define _V_REG_H_ + +#define VI_TRANSFORMB 1 +#define VI_WINDOWB 1 +#define VI_TIMEB 1 +#define VI_FLOORB 2 +#define VI_RESB 3 +#define VI_MAPB 1 + +#include "backends.h" + +#if defined(_WIN32) && defined(VORBISDLL_IMPORT) +# define EXTERN __declspec(dllimport) extern +#else +# define EXTERN extern +#endif + +EXTERN vorbis_func_floor *_floor_P[]; +EXTERN vorbis_func_residue *_residue_P[]; +EXTERN vorbis_func_mapping *_mapping_P[]; + +#endif diff --git a/lib/rbcodec/codecs/libtremor/res012.c b/lib/rbcodec/codecs/libtremor/res012.c new file mode 100644 index 0000000000..e4ff440a6d --- /dev/null +++ b/lib/rbcodec/codecs/libtremor/res012.c @@ -0,0 +1,374 @@ +/******************************************************************** + * * + * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * + * * + * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * + * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * + * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * + * * + * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * + * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * + * * + ******************************************************************** + + function: residue backend 0, 1 and 2 implementation + + ********************************************************************/ + +#include "config-tremor.h" +#include +#include +#include "ogg.h" +#include "ivorbiscodec.h" +#include "codec_internal.h" +#include "registry.h" +#include "codebook.h" +#include "misc.h" +#include "os.h" + +typedef struct { + vorbis_info_residue0 *info; + int map; + + int parts; + int stages; + codebook *fullbooks; + codebook *phrasebook; + codebook ***partbooks; + + int partvals; + int **decodemap; + +} vorbis_look_residue0; + +static void res0_free_info(vorbis_info_residue *i){ + vorbis_info_residue0 *info=(vorbis_info_residue0 *)i; + if(info){ + memset(info,0,sizeof(*info)); + _ogg_free(info); + } +} + +static void res0_free_look(vorbis_look_residue *i){ + int j; + if(i){ + + vorbis_look_residue0 *look=(vorbis_look_residue0 *)i; + + for(j=0;jparts;j++) + if(look->partbooks[j])_ogg_free(look->partbooks[j]); + _ogg_free(look->partbooks); + for(j=0;jpartvals;j++) + _ogg_free(look->decodemap[j]); + _ogg_free(look->decodemap); + + memset(look,0,sizeof(*look)); + _ogg_free(look); + } +} + +static int ilog(unsigned int v){ + int ret=0; + while(v){ + ret++; + v>>=1; + } + return(ret); +} + +static int icount(unsigned int v){ + int ret=0; + while(v){ + ret+=v&1; + v>>=1; + } + return(ret); +} + +/* vorbis_info is for range checking */ +static vorbis_info_residue *res0_unpack(vorbis_info *vi,oggpack_buffer *opb){ + int j,acc=0; + vorbis_info_residue0 *info=(vorbis_info_residue0 *)_ogg_calloc(1,sizeof(*info)); + codec_setup_info *ci=(codec_setup_info *)vi->codec_setup; + + info->begin=oggpack_read(opb,24); + info->end=oggpack_read(opb,24); + info->grouping=oggpack_read(opb,24)+1; + info->partitions=oggpack_read(opb,6)+1; + info->groupbook=oggpack_read(opb,8); + + /* check for premature EOP */ + if(info->groupbook<0)goto errout; + + for(j=0;jpartitions;j++){ + int cascade=oggpack_read(opb,3); + int cflag=oggpack_read(opb,1); + if(cflag<0) goto errout; + if(cflag){ + int c=oggpack_read(opb,5); + if(c<0) goto errout; + cascade|=(c<<3); + } + info->secondstages[j]=cascade; + + acc+=icount(cascade); + } + for(j=0;jbooklist[j]=book; + } + + if(info->groupbook>=ci->books)goto errout; + for(j=0;jbooklist[j]>=ci->books)goto errout; + if(ci->book_param[info->booklist[j]]->maptype==0)goto errout; + } + + /* verify the phrasebook is not specifying an impossible or + inconsistent partitioning scheme. */ + /* modify the phrasebook ranging check from r16327; an early beta + encoder had a bug where it used an oversized phrasebook by + accident. These files should continue to be playable, but don't + allow an exploit */ + { + int entries = ci->book_param[info->groupbook]->entries; + int dim = ci->book_param[info->groupbook]->dim; + int partvals = 1; + if (dim<1) goto errout; + while(dim>0){ + partvals *= info->partitions; + if(partvals > entries) goto errout; + dim--; + } + info->partvals = partvals; + } + + return(info); + errout: + res0_free_info(info); + return(NULL); +} + +static vorbis_look_residue *res0_look(vorbis_dsp_state *vd,vorbis_info_mode *vm, + vorbis_info_residue *vr){ + vorbis_info_residue0 *info=(vorbis_info_residue0 *)vr; + vorbis_look_residue0 *look=(vorbis_look_residue0 *)_ogg_calloc(1,sizeof(*look)); + codec_setup_info *ci=(codec_setup_info *)vd->vi->codec_setup; + + int j,k,acc=0; + int dim; + int maxstage=0; + look->info=info; + look->map=vm->mapping; + + look->parts=info->partitions; + look->fullbooks=ci->fullbooks; + look->phrasebook=ci->fullbooks+info->groupbook; + dim=look->phrasebook->dim; + + look->partbooks=(codebook ***)_ogg_calloc(look->parts,sizeof(*look->partbooks)); + + for(j=0;jparts;j++){ + int stages=ilog(info->secondstages[j]); + if(stages){ + if(stages>maxstage)maxstage=stages; + look->partbooks[j]=(codebook **)_ogg_calloc(stages,sizeof(*look->partbooks[j])); + for(k=0;ksecondstages[j]&(1<partbooks[j][k]=ci->fullbooks+info->booklist[acc++]; +#ifdef TRAIN_RES + look->training_data[k][j]=calloc(look->partbooks[j][k]->entries, + sizeof(***look->training_data)); +#endif + } + } + } + + look->partvals=look->parts; + for(j=1;jpartvals*=look->parts; + look->stages=maxstage; + look->decodemap=(int **)_ogg_malloc(look->partvals*sizeof(*look->decodemap)); + for(j=0;jpartvals;j++){ + long val=j; + long mult=look->partvals/look->parts; + look->decodemap[j]=(int *)_ogg_malloc(dim*sizeof(*look->decodemap[j])); + for(k=0;kparts; + look->decodemap[j][k]=deco; + } + } + + return(look); +} + +/* a truncated packet here just means 'stop working'; it's not an error */ +static int _01inverse(vorbis_block *vb,vorbis_look_residue *vl, + ogg_int32_t **in,int ch, + long (*decodepart)(codebook *, ogg_int32_t *, + oggpack_buffer *,int,int)){ + + long i,j,k,l,s; + vorbis_look_residue0 *look=(vorbis_look_residue0 *)vl; + vorbis_info_residue0 *info=look->info; + + /* move all this setup out later */ + int samples_per_partition=info->grouping; + int partitions_per_word=look->phrasebook->dim; + int max=vb->pcmend>>1; + int end=(info->endend:max); + int n=end-info->begin; + + if(n>0){ + int partvals=n/samples_per_partition; + int partwords=(partvals+partitions_per_word-1)/partitions_per_word; + int ***partword=(int ***)alloca(ch*sizeof(*partword)); + + for(j=0;jstages;s++){ + + /* each loop decodes on partition codeword containing + partitions_pre_word partitions */ + for(i=0,l=0;iphrasebook,&vb->opb); + if(temp==-1 || temp>=info->partvals)goto eopbreak; + partword[j][l]=look->decodemap[temp]; + if(partword[j][l]==NULL)goto errout; + } + } + + /* now we decode residual values for the partitions */ + for(k=0;kbegin+i*samples_per_partition; + if(info->secondstages[partword[j][l][k]]&(1<partbooks[partword[j][l][k]][s]; + if(stagebook){ + if(decodepart(stagebook,in[j]+offset,&vb->opb, + samples_per_partition,-8)==-1)goto eopbreak; + } + } + } + } + } + } + errout: + eopbreak: + return(0); +} + +static int res0_inverse(vorbis_block *vb,vorbis_look_residue *vl, + ogg_int32_t **in,int *nonzero,int ch){ + int i,used=0; + for(i=0;iinfo; + + /* move all this setup out later */ + int samples_per_partition=info->grouping; + int partitions_per_word=look->phrasebook->dim; + int max=(vb->pcmend*ch)>>1; + int end=(info->endend:max); + int n=end-info->begin; + + if(n>0){ + + int partvals=n/samples_per_partition; + int partwords=(partvals+partitions_per_word-1)/partitions_per_word; + int **partword=(int **)_vorbis_block_alloc(vb,partwords*sizeof(*partword)); + int beginoff=info->begin/ch; + + for(i=0;istages;s++){ + for(i=0,l=0;iphrasebook,&vb->opb); + if(temp==-1 || temp>=info->partvals)goto eopbreak; + partword[l]=look->decodemap[temp]; + if(partword[l]==NULL)goto errout; + } + + /* now we decode residual values for the partitions */ + for(k=0;ksecondstages[partword[l][k]]&(1<partbooks[partword[l][k]][s]; + if(stagebook){ + if(vorbis_book_decodevv_add(stagebook,in, + i*samples_per_partition+beginoff,ch, + &vb->opb, + samples_per_partition,-8)==-1) + goto eopbreak; + } + } + } + } + } + errout: + eopbreak: + return(0); +} + + +const vorbis_func_residue residue0_exportbundle ICONST_ATTR ={ + &res0_unpack, + &res0_look, + &res0_free_info, + &res0_free_look, + &res0_inverse +}; + +const vorbis_func_residue residue1_exportbundle ICONST_ATTR ={ + &res0_unpack, + &res0_look, + &res0_free_info, + &res0_free_look, + &res1_inverse +}; + +const vorbis_func_residue residue2_exportbundle ICONST_ATTR ={ + &res0_unpack, + &res0_look, + &res0_free_info, + &res0_free_look, + &res2_inverse +}; diff --git a/lib/rbcodec/codecs/libtremor/sharedbook.c b/lib/rbcodec/codecs/libtremor/sharedbook.c new file mode 100644 index 0000000000..8b046217c7 --- /dev/null +++ b/lib/rbcodec/codecs/libtremor/sharedbook.c @@ -0,0 +1,460 @@ +/******************************************************************** + * * + * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * + * * + * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * + * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * + * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * + * * + * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * + * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * + * * + ******************************************************************** + + function: basic shared codebook operations + + ********************************************************************/ + +#include "config-tremor.h" +#include +#include +#include "ogg.h" +#include "os.h" +#include "misc.h" +#include "ivorbiscodec.h" +#include "codebook.h" + +/**** pack/unpack helpers ******************************************/ +int _ilog(unsigned int v){ + int ret=0; + while(v){ + ret++; + v>>=1; + } + return(ret); +} + +/* 32 bit float (not IEEE; nonnormalized mantissa + + biased exponent) : neeeeeee eeemmmmm mmmmmmmm mmmmmmmm + Why not IEEE? It's just not that important here. */ + +#define VQ_FEXP 10 +#define VQ_FMAN 21 +#define VQ_FEXP_BIAS 768 /* bias toward values smaller than 1. */ + +static ogg_int32_t _float32_unpack(long val,int *point){ + long mant=val&0x1fffff; + int sign=val&0x80000000; + long exp =(val&0x7fe00000L)>>VQ_FMAN; + + exp-=(VQ_FMAN-1)+VQ_FEXP_BIAS; + + if(mant){ + while(!(mant&0x40000000)){ + mant<<=1; + exp-=1; + } + + if(sign)mant= -mant; + }else{ + sign=0; + exp=-9999; + } + + *point=exp; + return mant; +} + +/* given a list of word lengths, generate a list of codewords. Works + for length ordered or unordered, always assigns the lowest valued + codewords first. Extended to handle unused entries (length 0) */ +static ogg_uint32_t *_make_words(long *l,long n,long sparsecount){ + long i,j,count=0; + ogg_uint32_t marker[33]; + ogg_uint32_t *r=(ogg_uint32_t *)_ogg_malloc((sparsecount?sparsecount:n)*sizeof(*r)); + memset(marker,0,sizeof(marker)); + + for(i=0;i0){ + ogg_uint32_t entry=marker[length]; + + /* when we claim a node for an entry, we also claim the nodes + below it (pruning off the imagined tree that may have dangled + from it) as well as blocking the use of any nodes directly + above for leaves */ + + /* update ourself */ + if(length<32 && (entry>>length)){ + /* error condition; the lengths must specify an overpopulated tree */ + _ogg_free(r); + return(NULL); + } + r[count++]=entry; + + /* Look to see if the next shorter marker points to the node + above. if so, update it and repeat. */ + { + for(j=length;j>0;j--){ + + if(marker[j]&1){ + /* have to jump branches */ + if(j==1) + marker[1]++; + else + marker[j]=marker[j-1]<<1; + break; /* invariant says next upper marker would already + have been moved if it was on the same path */ + } + marker[j]++; + } + } + + /* prune the tree; the implicit invariant says all the longer + markers were dangling from our just-taken node. Dangle them + from our *new* node. */ + for(j=length+1;j<33;j++) + if((marker[j]>>1) == entry){ + entry=marker[j]; + marker[j]=marker[j-1]<<1; + }else + break; + }else + if(sparsecount==0)count++; + } + + /* sanity check the huffman tree; an underpopulated tree must be + rejected. The only exception is the one-node pseudo-nil tree, + which appears to be underpopulated because the tree doesn't + really exist; there's only one possible 'codeword' or zero bits, + but the above tree-gen code doesn't mark that. */ + if(sparsecount != 1){ + for(i=1;i<33;i++) + if(marker[i] & (0xffffffffUL>>(32-i))){ + _ogg_free(r); + return(NULL); + } + } + + /* bitreverse the words because our bitwise packer/unpacker is LSb + endian */ + for(i=0,count=0;i>j)&1; + } + + if(sparsecount){ + if(l[i]) + r[count++]=temp; + }else + r[count++]=temp; + } + + return(r); +} + +/* there might be a straightforward one-line way to do the below + that's portable and totally safe against roundoff, but I haven't + thought of it. Therefore, we opt on the side of caution */ +long _book_maptype1_quantvals(const static_codebook *b){ + /* get us a starting hint, we'll polish it below */ + int bits=_ilog(b->entries); + int vals=b->entries>>((bits-1)*(b->dim-1)/b->dim); + + while(1){ + long acc=1; + long acc1=1; + int i; + for(i=0;idim;i++){ + acc*=vals; + acc1*=vals+1; + } + if(acc<=b->entries && acc1>b->entries){ + return(vals); + }else{ + if(acc>b->entries){ + vals--; + }else{ + vals++; + } + } + } +} + +/* different than what _book_unquantize does for mainline: + we repack the book in a fixed point format that shares the same + binary point. Upon first use, we can shift point if needed */ + +/* we need to deal with two map types: in map type 1, the values are + generated algorithmically (each column of the vector counts through + the values in the quant vector). in map type 2, all the values came + in in an explicit list. Both value lists must be unpacked */ + +static ogg_int32_t *_book_unquantize(const static_codebook *b,int n, + int *sparsemap,int *maxpoint){ + long j,k,count=0; + if(b->maptype==1 || b->maptype==2){ + int quantvals; + int minpoint,delpoint; + ogg_int32_t mindel=_float32_unpack(b->q_min,&minpoint); + ogg_int32_t delta=_float32_unpack(b->q_delta,&delpoint); + ogg_int32_t *r=(ogg_int32_t *)_ogg_calloc(n*b->dim,sizeof(*r)); + int *rp=(int *)_ogg_calloc(n*b->dim,sizeof(*rp)); + + *maxpoint=minpoint; + + /* maptype 1 and 2 both use a quantized value vector, but + different sizes */ + switch(b->maptype){ + case 1: + /* most of the time, entries%dimensions == 0, but we need to be + well defined. We define that the possible vales at each + scalar is values == entries/dim. If entries%dim != 0, we'll + have 'too few' values (values*dimentries;j++){ + if((sparsemap && b->lengthlist[j]) || !sparsemap){ + ogg_int32_t last=0; + int lastpoint=0; + int indexdiv=1; + for(k=0;kdim;k++){ + int index= (j/indexdiv)%quantvals; + ogg_int32_t point=0; + int val=VFLOAT_MULTI(delta,delpoint, + abs(b->quantlist[index]),&point); + + val=VFLOAT_ADD(mindel,minpoint,val,point,&point); + val=VFLOAT_ADD(last,lastpoint,val,point,&point); + + if(b->q_sequencep){ + last=val; + lastpoint=point; + } + + if(sparsemap){ + r[sparsemap[count]*b->dim+k]=val; + rp[sparsemap[count]*b->dim+k]=point; + }else{ + r[count*b->dim+k]=val; + rp[count*b->dim+k]=point; + } + if(*maxpointentries;j++){ + if((sparsemap && b->lengthlist[j]) || !sparsemap){ + ogg_int32_t last=0; + int lastpoint=0; + + for(k=0;kdim;k++){ + ogg_int32_t point=0; + int val=VFLOAT_MULTI(delta,delpoint, + abs(b->quantlist[j*b->dim+k]),&point); + + val=VFLOAT_ADD(mindel,minpoint,val,point,&point); + val=VFLOAT_ADD(last,lastpoint,val,point,&point); + + if(b->q_sequencep){ + last=val; + lastpoint=point; + } + + if(sparsemap){ + r[sparsemap[count]*b->dim+k]=val; + rp[sparsemap[count]*b->dim+k]=point; + }else{ + r[count*b->dim+k]=val; + rp[count*b->dim+k]=point; + } + if(*maxpointdim;j++) + if(rp[j]<*maxpoint) + r[j]>>=*maxpoint-rp[j]; + + _ogg_free(rp); + return(r); + } + return(NULL); +} + +void vorbis_staticbook_destroy(static_codebook *b){ + if(b->quantlist)_ogg_free(b->quantlist); + if(b->lengthlist)_ogg_free(b->lengthlist); + memset(b,0,sizeof(*b)); + _ogg_free(b); +} + +void vorbis_book_clear(codebook *b){ + /* static book is not cleared; we're likely called on the lookup and + the static codebook belongs to the info struct */ + if(b->valuelist)_ogg_free(b->valuelist); + if(b->codelist)_ogg_free(b->codelist); + + if(b->dec_index)_ogg_free(b->dec_index); + if(b->dec_codelengths)_ogg_free(b->dec_codelengths); + if(b->dec_firsttable)_ogg_free(b->dec_firsttable); + + memset(b,0,sizeof(*b)); +} + +static ogg_uint32_t bitreverse(ogg_uint32_t x){ + x= ((x>>16)&0x0000ffffUL) | ((x<<16)&0xffff0000UL); + x= ((x>> 8)&0x00ff00ffUL) | ((x<< 8)&0xff00ff00UL); + x= ((x>> 4)&0x0f0f0f0fUL) | ((x<< 4)&0xf0f0f0f0UL); + x= ((x>> 2)&0x33333333UL) | ((x<< 2)&0xccccccccUL); + return((x>> 1)&0x55555555UL) | ((x<< 1)&0xaaaaaaaaUL); +} + +static int sort32a(const void *a,const void *b){ + return (**(ogg_uint32_t **)a>**(ogg_uint32_t **)b)- + (**(ogg_uint32_t **)a<**(ogg_uint32_t **)b); +} + +/* decode codebook arrangement is more heavily optimized than encode */ +int vorbis_book_init_decode(codebook *c,const static_codebook *s){ + int i,j,n=0,tabn; + int *sortindex; + memset(c,0,sizeof(*c)); + + /* count actually used entries */ + for(i=0;ientries;i++) + if(s->lengthlist[i]>0) + n++; + + c->entries=s->entries; + c->used_entries=n; + c->dim=s->dim; + + if(n>0){ + /* two different remappings go on here. + + First, we collapse the likely sparse codebook down only to + actually represented values/words. This collapsing needs to be + indexed as map-valueless books are used to encode original entry + positions as integers. + + Second, we reorder all vectors, including the entry index above, + by sorted bitreversed codeword to allow treeless decode. */ + + /* perform sort */ + ogg_uint32_t *codes=_make_words(s->lengthlist,s->entries,c->used_entries); + ogg_uint32_t **codep=(ogg_uint32_t **)_ogg_malloc(sizeof(*codep)*n); + + if(codes==NULL||codep==NULL){ + _ogg_free(codep); + _ogg_free(codes); + goto err_out; + } + + for(i=0;icodelist=(ogg_uint32_t *)_ogg_malloc(n*sizeof(*c->codelist)); + /* the index is a reverse index */ + for(i=0;icodelist[sortindex[i]]=codes[i]; + _ogg_free(codep); + _ogg_free(codes); + + + + c->valuelist=_book_unquantize(s,n,sortindex,&c->binarypoint); + c->dec_index=(int *)_ogg_malloc(n*sizeof(*c->dec_index)); + + for(n=0,i=0;ientries;i++) + if(s->lengthlist[i]>0) + c->dec_index[sortindex[n++]]=i; + + c->dec_codelengths=(char *)_ogg_malloc(n*sizeof(*c->dec_codelengths)); + for(n=0,i=0;ientries;i++) + if(s->lengthlist[i]>0) + c->dec_codelengths[sortindex[n++]]=s->lengthlist[i]; + + _ogg_free(sortindex); +/* Use a larger cache size when we have a large codec buffer, helps decoding + speed especially on targets with slow memory and high bitrate files */ +#if CODEC_SIZE < 0x100000 + c->dec_firsttablen=_ilog(c->used_entries)-4; /* this is magic */ +#else + c->dec_firsttablen=_ilog(c->used_entries)+1; /* this is magic */ +#endif + if(c->dec_firsttablen<5)c->dec_firsttablen=5; + if(c->dec_firsttablen>8)c->dec_firsttablen=8; + + tabn=1<dec_firsttablen; + c->dec_firsttable=(ogg_uint32_t *)_ogg_calloc(tabn,sizeof(*c->dec_firsttable)); + c->dec_maxlength=0; + + for(i=0;idec_maxlengthdec_codelengths[i]) + c->dec_maxlength=c->dec_codelengths[i]; + if(c->dec_codelengths[i]<=c->dec_firsttablen){ + ogg_uint32_t orig=bitreverse(c->codelist[i]); + for(j=0;j<(1<<(c->dec_firsttablen-c->dec_codelengths[i]));j++) + c->dec_firsttable[orig|(j<dec_codelengths[i])]=i+1; + } + } + + /* now fill in 'unused' entries in the firsttable with hi/lo search + hints for the non-direct-hits */ + { + ogg_uint32_t mask=0xfffffffeUL<<(31-c->dec_firsttablen); + long lo=0,hi=0; + + for(i=0;idec_firsttablen); + if(c->dec_firsttable[bitreverse(word)]==0){ + while((lo+1)codelist[lo+1]<=word)lo++; + while( hi=(c->codelist[hi]&mask))hi++; + + /* we only actually have 15 bits per hint to play with here. + In order to overflow gracefully (nothing breaks, efficiency + just drops), encode as the difference from the extremes. */ + { + unsigned long loval=lo; + unsigned long hival=n-hi; + + if(loval>0x7fff)loval=0x7fff; + if(hival>0x7fff)hival=0x7fff; + c->dec_firsttable[bitreverse(word)]= + 0x80000000UL | (loval<<15) | hival; + } + } + } + } + } + + return(0); + err_out: + vorbis_book_clear(c); + return(-1); +} + diff --git a/lib/rbcodec/codecs/libtremor/synthesis.c b/lib/rbcodec/codecs/libtremor/synthesis.c new file mode 100644 index 0000000000..d1ef99ae37 --- /dev/null +++ b/lib/rbcodec/codecs/libtremor/synthesis.c @@ -0,0 +1,129 @@ +/******************************************************************** + * * + * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * + * * + * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * + * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * + * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * + * * + * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2003 * + * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * + * * + ******************************************************************** + + function: single-block PCM synthesis + last mod: $Id$ + + ********************************************************************/ + +#include +#include "ogg.h" +#include "ivorbiscodec.h" +#include "codec_internal.h" +#include "registry.h" +#include "misc.h" +#include "os.h" + + +static inline int _vorbis_synthesis1(vorbis_block *vb,ogg_packet *op,int decodep){ + vorbis_dsp_state *vd= vb ? vb->vd : 0; + private_state *b= vd ? (private_state *)vd->backend_state: 0; + vorbis_info *vi= vd ? vd->vi : 0; + codec_setup_info *ci= vi ? (codec_setup_info *)vi->codec_setup : 0; + oggpack_buffer *opb=vb ? &vb->opb : 0; + int type,mode; + + if (!vd || !b || !vi || !ci || !opb) { + return OV_EBADPACKET; + } + + /* first things first. Make sure decode is ready */ + _vorbis_block_ripcord(vb); + oggpack_readinit(opb,op->packet,op->bytes); + + /* Check the packet type */ + if(oggpack_read(opb,1)!=0){ + /* Oops. This is not an audio data packet */ + return(OV_ENOTAUDIO); + } + + /* read our mode and pre/post windowsize */ + mode=oggpack_read(opb,b->modebits); + if(mode==-1)return(OV_EBADPACKET); + + vb->mode=mode; + if(!ci->mode_param[mode]){ + return(OV_EBADPACKET); + } + + vb->W=ci->mode_param[mode]->blockflag; + if(vb->W){ + vb->lW=oggpack_read(opb,1); + vb->nW=oggpack_read(opb,1); + if(vb->nW==-1) return(OV_EBADPACKET); + }else{ + vb->lW=0; + vb->nW=0; + } + + /* more setup */ + vb->granulepos=op->granulepos; + vb->sequence=op->packetno-3; /* first block is third packet */ + vb->eofflag=op->e_o_s; + + if(decodep && vi->channels<=CHANNELS) + { + /* set pcm end point */ + vb->pcmend=ci->blocksizes[vb->W]; + + /* unpack_header enforces range checking */ + type=ci->map_type[ci->mode_param[mode]->mapping]; + return(_mapping_P[type]->inverse(vb,b->mode[mode])); + }else{ + /* no pcm */ + vb->pcmend=0; + return(0); + } +} + +int vorbis_synthesis(vorbis_block *vb,ogg_packet *op) + ICODE_ATTR_TREMOR_NOT_MDCT; +int vorbis_synthesis(vorbis_block *vb,ogg_packet *op){ + return _vorbis_synthesis1(vb,op,1); +} + +/* used to track pcm position without actually performing decode. + Useful for sequential 'fast forward' */ +int vorbis_synthesis_trackonly(vorbis_block *vb,ogg_packet *op){ + return _vorbis_synthesis1(vb,op,0); +} + +long vorbis_packet_blocksize(vorbis_info *vi,ogg_packet *op){ + codec_setup_info *ci=(codec_setup_info *)vi->codec_setup; + oggpack_buffer opb; + int mode; + + oggpack_readinit(&opb,op->packet,op->bytes); + + /* Check the packet type */ + if(oggpack_read(&opb,1)!=0){ + /* Oops. This is not an audio data packet */ + return(OV_ENOTAUDIO); + } + + { + int modebits=0; + int v=ci->modes; + while(v>1){ + modebits++; + v>>=1; + } + + /* read our mode and pre/post windowsize */ + mode=oggpack_read(&opb,modebits); + } + if(mode==-1)return(OV_EBADPACKET); + return(ci->blocksizes[ci->mode_param[mode]->blockflag]); +} + + diff --git a/lib/rbcodec/codecs/libtremor/vorbisfile.c b/lib/rbcodec/codecs/libtremor/vorbisfile.c new file mode 100644 index 0000000000..271e5a09e3 --- /dev/null +++ b/lib/rbcodec/codecs/libtremor/vorbisfile.c @@ -0,0 +1,1671 @@ +/******************************************************************** + * * + * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * + * * + * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * + * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * + * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * + * * + * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2003 * + * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * + * * + ******************************************************************** + + function: stdio-based convenience library for opening/seeking/decoding + last mod: $Id$ + + ********************************************************************/ + +#include "config-tremor.h" +#include +#include +#include +#include +#include "system.h" + +#include "ivorbiscodec.h" +#include "ivorbisfile.h" + +#include "os.h" +#include "misc.h" + +/* A 'chained bitstream' is a Vorbis bitstream that contains more than + one logical bitstream arranged end to end (the only form of Ogg + multiplexing allowed in a Vorbis bitstream; grouping [parallel + multiplexing] is not allowed in Vorbis) */ + +/* A Vorbis file can be played beginning to end (streamed) without + worrying ahead of time about chaining (see decoder_example.c). If + we have the whole file, however, and want random access + (seeking/scrubbing) or desire to know the total length/time of a + file, we need to account for the possibility of chaining. */ + +/* We can handle things a number of ways; we can determine the entire + bitstream structure right off the bat, or find pieces on demand. + This example determines and caches structure for the entire + bitstream, but builds a virtual decoder on the fly when moving + between links in the chain. */ + +/* There are also different ways to implement seeking. Enough + information exists in an Ogg bitstream to seek to + sample-granularity positions in the output. Or, one can seek by + picking some portion of the stream roughly in the desired area if + we only want coarse navigation through the stream. */ + +/************************************************************************* + * Many, many internal helpers. The intention is not to be confusing; + * rampant duplication and monolithic function implementation would be + * harder to understand anyway. The high level functions are last. Begin + * grokking near the end of the file */ + + +/* read a little more data from the file/pipe into the ogg_sync framer */ +static long _get_data(OggVorbis_File *vf){ + if(!(vf->callbacks.read_func))return(-1); + if(vf->datasource){ + char *buffer=ogg_sync_buffer(&vf->oy,CHUNKSIZE); + long bytes=(vf->callbacks.read_func)(buffer,1,CHUNKSIZE,vf->datasource); + if(bytes>0)ogg_sync_wrote(&vf->oy,bytes); + return(bytes); + }else + return(0); +} + +/* save a tiny smidge of verbosity to make the code more readable */ +static int _seek_helper(OggVorbis_File *vf,ogg_int64_t offset){ + if(vf->datasource){ + if(!(vf->callbacks.seek_func)|| + (vf->callbacks.seek_func)(vf->datasource, offset, SEEK_SET) == -1) + return OV_EREAD; + vf->offset=offset; + ogg_sync_reset(&vf->oy); + }else{ + /* shouldn't happen unless someone writes a broken callback */ + return OV_EFAULT; + } + return 0; +} + +/* The read/seek functions track absolute position within the stream */ + +/* from the head of the stream, get the next page. boundary specifies + if the function is allowed to fetch more data from the stream (and + how much) or only use internally buffered data. + + boundary: -1) unbounded search + 0) read no additional data; use cached only + n) search for a new page beginning for n bytes + + return: <0) did not find a page (OV_FALSE, OV_EOF, OV_EREAD) + n) found a page at absolute offset n */ + +static ogg_int64_t _get_next_page(OggVorbis_File *vf,ogg_page *og, + ogg_int64_t boundary){ + if(boundary>0)boundary+=vf->offset; + while(1){ + long more; + + if(boundary>0 && vf->offset>=boundary)return(OV_FALSE); + more=ogg_sync_pageseek(&vf->oy,og); + + if(more<0){ + /* skipped n bytes */ + vf->offset-=more; + }else{ + if(more==0){ + /* send more paramedics */ + if(!boundary)return(OV_FALSE); + { + long ret=_get_data(vf); + if(ret==0)return(OV_EOF); + if(ret<0)return(OV_EREAD); + } + }else{ + /* got a page. Return the offset at the page beginning, + advance the internal offset past the page end */ + ogg_int64_t ret=vf->offset; + vf->offset+=more; + return(ret); + + } + } + } +} + +/* This is a nasty hack to work around the huge allocations we get from + huge comment packets, usually due to embedded album art */ +static int ogg_stream_discard_packet(OggVorbis_File *vf,ogg_page *og, + ogg_int64_t boundary){ + int ret; + while((ret = ogg_stream_packetout(&vf->os, NULL)) == 0) { + if(_get_next_page(vf, og, boundary)<0) + break; + ogg_stream_pagein(&vf->os,og,false); + } + if (ret < 0) + return -1; + /* We might be pretending to have filled in more of the buffer than there is + actual space, in this case the body storage must be expanded before we + start writing to it */ + if (vf->os.body_fill < og->body_len || vf->os.body_storage < vf->os.body_fill) + if(_os_body_expand(&vf->os, vf->os.body_fill - vf->os.body_storage + og->body_len)) + return -1; + memcpy(vf->os.body_data+vf->os.body_fill-og->body_len, og->body, og->body_len); + return 1; +} + +/* find the latest page beginning before the current stream cursor + position. Much dirtier than the above as Ogg doesn't have any + backward search linkage. no 'readp' as it will certainly have to + read. */ +/* returns offset or OV_EREAD, OV_FAULT */ +static ogg_int64_t _get_prev_page(OggVorbis_File *vf,ogg_page *og){ + ogg_int64_t begin=vf->offset; + ogg_int64_t end=begin; + ogg_int64_t ret; + ogg_int64_t offset=-1; + + while(offset==-1){ + begin-=CHUNKSIZE; + if(begin<0) + begin=0; + + ret=_seek_helper(vf,begin); + if(ret)return(ret); + + while(vf->offsetoffset); + if(ret==OV_EREAD)return(OV_EREAD); + if(ret<0){ + break; + }else{ + offset=ret; + } + } + } + + /* In a fully compliant, non-multiplexed stream, we'll still be + holding the last page. In multiplexed (or noncompliant streams), + we will probably have to re-read the last page we saw */ + if(og->header_len==0){ + ret=_seek_helper(vf,offset); + if(ret)return(ret); + + ret=_get_next_page(vf,og,CHUNKSIZE); + if(ret<0) + /* this shouldn't be possible */ + return(OV_EFAULT); + } + + return(offset); +} + +static void _add_serialno(ogg_page *og,ogg_uint32_t **serialno_list, int *n){ + long s = ogg_page_serialno(og); + (*n)++; + + if(*serialno_list){ + *serialno_list = _ogg_realloc(*serialno_list, sizeof(**serialno_list)*(*n)); + }else{ + *serialno_list = _ogg_malloc(sizeof(**serialno_list)); + } + + (*serialno_list)[(*n)-1] = s; +} + +/* returns nonzero if found */ +static int _lookup_serialno(ogg_uint32_t s, ogg_uint32_t *serialno_list, int n){ + if(serialno_list){ + while(n--){ + if(*serialno_list == (ogg_uint32_t) s) return 1; + serialno_list++; + } + } + return 0; +} + +static int _lookup_page_serialno(ogg_page *og, ogg_uint32_t *serialno_list, int n){ + ogg_uint32_t s = ogg_page_serialno(og); + return _lookup_serialno(s,serialno_list,n); +} + +/* performs the same search as _get_prev_page, but prefers pages of + the specified serial number. If a page of the specified serialno is + spotted during the seek-back-and-read-forward, it will return the + info of last page of the matching serial number instead of the very + last page. If no page of the specified serialno is seen, it will + return the info of last page and alter *serialno. */ +static ogg_int64_t _get_prev_page_serial(OggVorbis_File *vf, + ogg_uint32_t *serial_list, int serial_n, + int *serialno, ogg_int64_t *granpos){ + ogg_page og; + ogg_int64_t begin=vf->offset; + ogg_int64_t end=begin; + ogg_int64_t ret; + + ogg_int64_t prefoffset=-1; + ogg_int64_t offset=-1; + ogg_int64_t ret_serialno=-1; + ogg_int64_t ret_gran=-1; + + while(offset==-1){ + begin-=CHUNKSIZE; + if(begin<0) + begin=0; + + ret=_seek_helper(vf,begin); + if(ret)return(ret); + + while(vf->offsetoffset); + if(ret==OV_EREAD)return(OV_EREAD); + if(ret<0){ + break; + }else{ + ret_serialno=ogg_page_serialno(&og); + ret_gran=ogg_page_granulepos(&og); + offset=ret; + + if((ogg_uint32_t)ret_serialno == (ogg_uint32_t)*serialno){ + prefoffset=ret; + *granpos=ret_gran; + } + + if(!_lookup_serialno((ogg_uint32_t)ret_serialno,serial_list,serial_n)){ + /* we fell off the end of the link, which means we seeked + back too far and shouldn't have been looking in that link + to begin with. If we found the preferred serial number, + forget that we saw it. */ + prefoffset=-1; + } + } + } + } + + /* we're not interested in the page... just the serialno and granpos. */ + if(prefoffset>=0)return(prefoffset); + + *serialno = ret_serialno; + *granpos = ret_gran; + return(offset); + +} + +/* uses the local ogg_stream storage in vf; this is important for + non-streaming input sources */ +static int _fetch_headers(OggVorbis_File *vf,vorbis_info *vi, + ogg_uint32_t **serialno_list, int *serialno_n, + ogg_page *og_ptr){ + ogg_page og; + ogg_packet op; + int i,ret; + int allbos=0; + + if(!og_ptr){ + ogg_int64_t llret=_get_next_page(vf,&og,CHUNKSIZE); + if(llret==OV_EREAD)return(OV_EREAD); + if(llret<0)return(OV_ENOTVORBIS); + og_ptr=&og; + } + + vorbis_info_init(vi); +/* vorbis_comment_init(vc); */ + vf->ready_state=OPENED; + + /* extract the serialnos of all BOS pages + the first set of vorbis + headers we see in the link */ + + while(ogg_page_bos(og_ptr)){ + if(serialno_list){ + if(_lookup_page_serialno(og_ptr,*serialno_list,*serialno_n)){ + /* a dupe serialnumber in an initial header packet set == invalid stream */ + if(*serialno_list)_ogg_free(*serialno_list); + *serialno_list=0; + *serialno_n=0; + ret=OV_EBADHEADER; + goto bail_header; + } + + _add_serialno(og_ptr,serialno_list,serialno_n); + } + + if(vf->ready_stateos,ogg_page_serialno(og_ptr)); + ogg_stream_pagein(&vf->os,og_ptr,true); + + if(ogg_stream_packetout(&vf->os,&op) > 0 && + vorbis_synthesis_idheader(&op)){ + /* vorbis header; continue setup */ + vf->ready_state=STREAMSET; + if((ret=vorbis_synthesis_headerin(vi,&op))){ + ret=OV_EBADHEADER; + goto bail_header; + } + } + } + + /* get next page */ + { + ogg_int64_t llret=_get_next_page(vf,og_ptr,CHUNKSIZE); + if(llret==OV_EREAD){ + ret=OV_EREAD; + goto bail_header; + } + if(llret<0){ + ret=OV_ENOTVORBIS; + goto bail_header; + } + + /* if this page also belongs to our vorbis stream, submit it and break */ + if(vf->ready_state==STREAMSET && + vf->os.serialno == ogg_page_serialno(og_ptr)){ + ogg_stream_pagein(&vf->os,og_ptr,true); + break; + } + } + } + + if(vf->ready_state!=STREAMSET){ + ret = OV_ENOTVORBIS; + goto bail_header; + } + + while(1){ + + i=0; + /* discard comment packet */ + if(ogg_stream_discard_packet(vf,og_ptr,CHUNKSIZE) < 0){ + ret=OV_EBADHEADER; + goto bail_header; + } + i++; + + while(i<2){ /* get a page loop */ + + while(i<2){ /* get a packet loop */ + int result=ogg_stream_packetout(&vf->os,&op); + if(result==0)break; + if(result==-1){ + ret=OV_EBADHEADER; + goto bail_header; + } + + if((ret=vorbis_synthesis_headerin(vi,&op))) + goto bail_header; + + i++; + } + + while(i<2){ + if(_get_next_page(vf,og_ptr,CHUNKSIZE)<0){ + ret=OV_EBADHEADER; + goto bail_header; + } + + /* if this page belongs to the correct stream, go parse it */ + if(vf->os.serialno == ogg_page_serialno(og_ptr)){ + ogg_stream_pagein(&vf->os,og_ptr,true); + break; + } + + /* if we never see the final vorbis headers before the link + ends, abort */ + if(ogg_page_bos(og_ptr)){ + if(allbos){ + ret = OV_EBADHEADER; + goto bail_header; + }else + allbos=1; + } + + /* otherwise, keep looking */ + } + } + + return 0; + } + + bail_header: + vorbis_info_clear(vi); +/* vorbis_comment_clear(vc); */ + vf->ready_state=OPENED; + + return ret; +} + +/* Starting from current cursor position, get initial PCM offset of + next page. Consumes the page in the process without decoding + audio, however this is only called during stream parsing upon + seekable open. */ +static ogg_int64_t _initial_pcmoffset(OggVorbis_File *vf, vorbis_info *vi){ + ogg_page og; + ogg_int64_t accumulated=0; + long lastblock=-1; + int result; + ogg_uint32_t serialno = vf->os.serialno; + + while(1){ + ogg_packet op; + if(_get_next_page(vf,&og,-1)<0) + break; /* should not be possible unless the file is truncated/mangled */ + + if(ogg_page_bos(&og)) break; + if(ogg_page_serialno(&og)!= serialno) continue; + + /* count blocksizes of all frames in the page */ + ogg_stream_pagein(&vf->os,&og,true); + while((result=ogg_stream_packetout(&vf->os,&op))){ + if(result>0){ /* ignore holes */ + long thisblock=vorbis_packet_blocksize(vi,&op); + if(lastblock!=-1) + accumulated+=(lastblock+thisblock)>>2; + lastblock=thisblock; + } + } + + if(ogg_page_granulepos(&og)!=-1){ + /* pcm offset of last packet on the first audio page */ + accumulated= ogg_page_granulepos(&og)-accumulated; + break; + } + } + + /* less than zero? This is a stream with samples trimmed off + the beginning, a normal occurrence; set the offset to zero */ + if(accumulated<0)accumulated=0; + + return accumulated; +} + +/* finds each bitstream link one at a time using a bisection search + (has to begin by knowing the offset of the lb's initial page). + Recurses for each link so it can alloc the link storage after + finding them all, then unroll and fill the cache at the same time */ +static int _bisect_forward_serialno(OggVorbis_File *vf, + ogg_int64_t begin, + ogg_int64_t searched, + ogg_int64_t end, + ogg_int64_t endgran, + int endserial, + ogg_uint32_t *currentno_list, + int currentnos, + long m){ + ogg_int64_t pcmoffset; + ogg_int64_t dataoffset=searched; + ogg_int64_t endsearched=end; + ogg_int64_t next=end; + ogg_int64_t searchgran=-1; + ogg_page og; + ogg_int64_t ret,last; + int serialno = vf->os.serialno; + + /* invariants: + we have the headers and serialnos for the link beginning at 'begin' + we have the offset and granpos of the last page in the file (potentially + not a page we care about) + */ + + /* Is the last page in our list of current serialnumbers? */ + if(_lookup_serialno(endserial,currentno_list,currentnos)){ + + /* last page is in the starting serialno list, so we've bisected + down to (or just started with) a single link. Now we need to + find the last vorbis page belonging to the first vorbis stream + for this link. */ + + while(endserial != serialno){ + endserial = serialno; + vf->offset=_get_prev_page_serial(vf,currentno_list,currentnos,&endserial,&endgran); + } + + vf->links=m+1; + if(vf->offsets)_ogg_free(vf->offsets); + if(vf->serialnos)_ogg_free(vf->serialnos); + if(vf->dataoffsets)_ogg_free(vf->dataoffsets); + + vf->offsets=_ogg_malloc((vf->links+1)*sizeof(*vf->offsets)); + vf->vi=_ogg_realloc(vf->vi,vf->links*sizeof(*vf->vi)); +/* vf->vc=_ogg_realloc(vf->vc,vf->links*sizeof(*vf->vc));*/ + vf->serialnos=_ogg_malloc(vf->links*sizeof(*vf->serialnos)); + vf->dataoffsets=_ogg_malloc(vf->links*sizeof(*vf->dataoffsets)); + vf->pcmlengths=_ogg_malloc(vf->links*2*sizeof(*vf->pcmlengths)); + + vf->offsets[m+1]=end; + vf->offsets[m]=begin; + vf->pcmlengths[m*2+1]=endgran; + + }else{ + + ogg_uint32_t *next_serialno_list=NULL; + int next_serialnos=0; + vorbis_info vi; +/* vorbis_comment vc; */ + + /* the below guards against garbage seperating the last and + first pages of two links. */ + while(searchedoffset){ + ret=_seek_helper(vf,bisect); + if(ret)return(ret); + } + + last=_get_next_page(vf,&og,-1); + if(last==OV_EREAD)return(OV_EREAD); + if(last<0 || !_lookup_page_serialno(&og,currentno_list,currentnos)){ + endsearched=bisect; + if(last>=0)next=last; + }else{ + searched=vf->offset; + } + } + + /* Bisection point found */ + + /* for the time being, fetch end PCM offset the simple way */ + { + int testserial = serialno+1; + vf->offset = next; + while(testserial != serialno){ + testserial = serialno; + vf->offset=_get_prev_page_serial(vf,currentno_list,currentnos,&testserial,&searchgran); + } + } + + if(vf->offset!=next){ + ret=_seek_helper(vf,next); + if(ret)return(ret); + } + + ret=_fetch_headers(vf,&vi,&next_serialno_list,&next_serialnos,NULL); + if(ret)return(ret); + serialno = vf->os.serialno; + dataoffset = vf->offset; + + /* this will consume a page, however the next bistection always + starts with a raw seek */ + pcmoffset = _initial_pcmoffset(vf,&vi); + + ret=_bisect_forward_serialno(vf,next,vf->offset,end,endgran,endserial, + next_serialno_list,next_serialnos,m+1); + if(ret)return(ret); + + if(next_serialno_list)_ogg_free(next_serialno_list); + + vf->offsets[m+1]=next; + vf->serialnos[m+1]=serialno; + vf->dataoffsets[m+1]=dataoffset; + + vf->vi[m+1]=vi; +/* vf->vc[m+1]=vc; */ + + vf->pcmlengths[m*2+1]=searchgran; + vf->pcmlengths[m*2+2]=pcmoffset; + vf->pcmlengths[m*2+3]-=pcmoffset; + + } + return(0); +} + +static int _make_decode_ready(OggVorbis_File *vf){ + if(vf->ready_state>STREAMSET)return 0; + if(vf->ready_stateseekable){ + if(vorbis_synthesis_init(&vf->vd,vf->vi+vf->current_link)) + return OV_EBADLINK; + }else{ + if(vorbis_synthesis_init(&vf->vd,vf->vi)) + return OV_EBADLINK; + } + vorbis_block_init(&vf->vd,&vf->vb); + vf->ready_state=INITSET; + vf->bittrack=0; + vf->samptrack=0; + return 0; +} + +static int _open_seekable2(OggVorbis_File *vf){ + ogg_int64_t dataoffset=vf->dataoffsets[0],end,endgran=-1; + int endserial=vf->os.serialno; + int serialno=vf->os.serialno; + + /* we're partially open and have a first link header state in + storage in vf */ + + /* fetch initial PCM offset */ + ogg_int64_t pcmoffset = _initial_pcmoffset(vf,vf->vi); + + /* we can seek, so set out learning all about this file */ + if(vf->callbacks.seek_func && vf->callbacks.tell_func){ + (vf->callbacks.seek_func)(vf->datasource,0,SEEK_END); + vf->offset=vf->end=(vf->callbacks.tell_func)(vf->datasource); + }else{ + vf->offset=vf->end=-1; + } + + /* If seek_func is implemented, tell_func must also be implemented */ + if(vf->end==-1) return(OV_EINVAL); + + /* Get the offset of the last page of the physical bitstream, or, if + we're lucky the last vorbis page of this link as most OggVorbis + files will contain a single logical bitstream */ + end=_get_prev_page_serial(vf,vf->serialnos+2,vf->serialnos[1],&endserial,&endgran); + if(end<0)return(end); + + /* now determine bitstream structure recursively */ + if(_bisect_forward_serialno(vf,0,dataoffset,vf->offset,endgran,endserial, + vf->serialnos+2,vf->serialnos[1],0)<0)return(OV_EREAD); + + vf->offsets[0]=0; + vf->serialnos[0]=serialno; + vf->dataoffsets[0]=dataoffset; + vf->pcmlengths[0]=pcmoffset; + vf->pcmlengths[1]-=pcmoffset; + + return(ov_raw_seek(vf,dataoffset)); +} + +/* clear out the current logical bitstream decoder */ +static void _decode_clear(OggVorbis_File *vf){ + vorbis_dsp_clear(&vf->vd); + vorbis_block_clear(&vf->vb); + vf->ready_state=OPENED; +} + +/* fetch and process a packet. Handles the case where we're at a + bitstream boundary and dumps the decoding machine. If the decoding + machine is unloaded, it loads it. It also keeps pcm_offset up to + date (seek and read both use this. seek uses a special hack with + readp). + + return: <0) error, OV_HOLE (lost packet) or OV_EOF + 0) need more data (only if readp==0) + 1) got a packet +*/ + +static int _fetch_and_process_packet(OggVorbis_File *vf, + ogg_packet *op_in, + int readp, + int spanp){ + ogg_page og; + + /* handle one packet. Try to fetch it from current stream state */ + /* extract packets from page */ + while(1){ + + if(vf->ready_state==STREAMSET){ + int ret=_make_decode_ready(vf); + if(ret<0)return ret; + } + + /* process a packet if we can. If the machine isn't loaded, + neither is a page */ + if(vf->ready_state==INITSET){ + while(1) { + ogg_packet op; + ogg_packet *op_ptr=(op_in?op_in:&op); + int result=ogg_stream_packetout(&vf->os,op_ptr); + ogg_int64_t granulepos; + + op_in=NULL; + if(result==-1)return(OV_HOLE); /* hole in the data. */ + if(result>0){ + /* got a packet. process it */ + granulepos=op_ptr->granulepos; + if(!vorbis_synthesis(&vf->vb,op_ptr)){ /* lazy check for lazy + header handling. The + header packets aren't + audio, so if/when we + submit them, + vorbis_synthesis will + reject them */ + + /* suck in the synthesis data and track bitrate */ + { + int oldsamples=vorbis_synthesis_pcmout(&vf->vd,NULL); + /* for proper use of libvorbis within libvorbisfile, + oldsamples will always be zero. */ + if(oldsamples)return(OV_EFAULT); + + vorbis_synthesis_blockin(&vf->vd,&vf->vb); + vf->samptrack+=vorbis_synthesis_pcmout(&vf->vd,NULL)-oldsamples; + vf->bittrack+=op_ptr->bytes*8; + } + + /* update the pcm offset. */ + if(granulepos!=-1 && !op_ptr->e_o_s){ + int link=(vf->seekable?vf->current_link:0); + int i,samples; + + /* this packet has a pcm_offset on it (the last packet + completed on a page carries the offset) After processing + (above), we know the pcm position of the *last* sample + ready to be returned. Find the offset of the *first* + + As an aside, this trick is inaccurate if we begin + reading anew right at the last page; the end-of-stream + granulepos declares the last frame in the stream, and the + last packet of the last page may be a partial frame. + So, we need a previous granulepos from an in-sequence page + to have a reference point. Thus the !op_ptr->e_o_s clause + above */ + + if(vf->seekable && link>0) + granulepos-=vf->pcmlengths[link*2]; + if(granulepos<0)granulepos=0; /* actually, this + shouldn't be possible + here unless the stream + is very broken */ + + samples=vorbis_synthesis_pcmout(&vf->vd,NULL); + + granulepos-=samples; + for(i=0;ipcmlengths[i*2+1]; + vf->pcm_offset=granulepos; + } + return(1); + } + } + else + break; + } + } + + if(vf->ready_state>=OPENED){ + ogg_int64_t ret; + + while(1){ + /* the loop is not strictly necessary, but there's no sense in + doing the extra checks of the larger loop for the common + case in a multiplexed bistream where the page is simply + part of a different logical bitstream; keep reading until + we get one with the correct serialno */ + + if(!readp)return(0); + if((ret=_get_next_page(vf,&og,-1))<0){ + return(OV_EOF); /* eof. leave unitialized */ + } + + /* bitrate tracking; add the header's bytes here, the body bytes + are done by packet above */ + vf->bittrack+=og.header_len*8; + + if(vf->ready_state==INITSET){ + if(vf->current_serialno!=ogg_page_serialno(&og)){ + + /* two possibilities: + 1) our decoding just traversed a bitstream boundary + 2) another stream is multiplexed into this logical section */ + + if(ogg_page_bos(&og)){ + /* boundary case */ + if(!spanp) + return(OV_EOF); + + _decode_clear(vf); + + if(!vf->seekable){ + vorbis_info_clear(vf->vi); +/* vorbis_comment_clear(vf->vc); */ + } + break; + + }else + continue; /* possibility #2 */ + } + } + + break; + } + } + + /* Do we need to load a new machine before submitting the page? */ + /* This is different in the seekable and non-seekable cases. + + In the seekable case, we already have all the header + information loaded and cached; we just initialize the machine + with it and continue on our merry way. + + In the non-seekable (streaming) case, we'll only be at a + boundary if we just left the previous logical bitstream and + we're now nominally at the header of the next bitstream + */ + + if(vf->ready_state!=INITSET){ + int link; + + if(vf->ready_stateseekable){ + ogg_uint32_t serialno = ogg_page_serialno(&og); + + /* match the serialno to bitstream section. We use this rather than + offset positions to avoid problems near logical bitstream + boundaries */ + + for(link=0;linklinks;link++) + if(vf->serialnos[link]==serialno)break; + + if(link==vf->links) continue; /* not the desired Vorbis + bitstream section; keep + trying */ + + vf->current_serialno=serialno; + vf->current_link=link; + + ogg_stream_reset_serialno(&vf->os,vf->current_serialno); + vf->ready_state=STREAMSET; + + }else{ + /* we're streaming */ + /* fetch the three header packets, build the info struct */ + + int ret=_fetch_headers(vf,vf->vi,NULL,NULL,&og); + if(ret)return(ret); + vf->current_serialno=vf->os.serialno; + vf->current_link++; + link=0; + } + } + } + + /* the buffered page is the data we want, and we're ready for it; + add it to the stream state */ + ogg_stream_pagein(&vf->os,&og,true); + + } +} + +static int _ov_open1(void *f,OggVorbis_File *vf,const char *initial, + long ibytes, ov_callbacks callbacks){ + int offsettest=((f && callbacks.seek_func)?callbacks.seek_func(f,0,SEEK_CUR):-1); + ogg_uint32_t *serialno_list=NULL; + int serialno_list_size=0; + int ret; + + memset(vf,0,sizeof(*vf)); + vf->datasource=f; + vf->callbacks = callbacks; + + /* init the framing state */ + ogg_sync_init(&vf->oy); + + /* perhaps some data was previously read into a buffer for testing + against other stream types. Allow initialization from this + previously read data (especially as we may be reading from a + non-seekable stream) */ + if(initial){ + char *buffer=ogg_sync_buffer(&vf->oy,ibytes); + memcpy(buffer,initial,ibytes); + ogg_sync_wrote(&vf->oy,ibytes); + } + + /* can we seek? Stevens suggests the seek test was portable */ + if(offsettest!=-1)vf->seekable=1; + + /* No seeking yet; Set up a 'single' (current) logical bitstream + entry for partial open */ + vf->links=1; + vf->vi=_ogg_calloc(vf->links,sizeof(*vf->vi)); +/* vf->vc=_ogg_calloc(vf->links,sizeof(*vf->vc)); */ + ogg_stream_init(&vf->os,-1); /* fill in the serialno later */ + + /* Fetch all BOS pages, store the vorbis header and all seen serial + numbers, load subsequent vorbis setup headers */ + if((ret=_fetch_headers(vf,vf->vi,&serialno_list,&serialno_list_size,NULL))<0){ + vf->datasource=NULL; + ov_clear(vf); + }else{ + /* serial number list for first link needs to be held somewhere + for second stage of seekable stream open; this saves having to + seek/reread first link's serialnumber data then. */ + vf->serialnos=_ogg_calloc(serialno_list_size+2,sizeof(*vf->serialnos)); + vf->serialnos[0]=vf->current_serialno=vf->os.serialno; + vf->serialnos[1]=serialno_list_size; + memcpy(vf->serialnos+2,serialno_list,serialno_list_size*sizeof(*vf->serialnos)); + + vf->offsets=_ogg_calloc(1,sizeof(*vf->offsets)); + vf->dataoffsets=_ogg_calloc(1,sizeof(*vf->dataoffsets)); + vf->offsets[0]=0; + vf->dataoffsets[0]=vf->offset; + + vf->ready_state=PARTOPEN; + } + if(serialno_list)_ogg_free(serialno_list); + return(ret); +} + +static int _ov_open2(OggVorbis_File *vf){ + if(vf->ready_state != PARTOPEN) return OV_EINVAL; + vf->ready_state=OPENED; + if(vf->seekable){ + int ret=_open_seekable2(vf); + if(ret){ + vf->datasource=NULL; + ov_clear(vf); + } + return(ret); + }else + vf->ready_state=STREAMSET; + + return 0; +} + + +/* clear out the OggVorbis_File struct */ +int ov_clear(OggVorbis_File *vf){ + if(vf){ + vorbis_block_clear(&vf->vb); + vorbis_dsp_clear(&vf->vd); + ogg_stream_clear(&vf->os); + + if(vf->vi && vf->links){ + int i; + for(i=0;ilinks;i++){ + vorbis_info_clear(vf->vi+i); +/* vorbis_comment_clear(vf->vc+i); */ + } + _ogg_free(vf->vi); +/* _ogg_free(vf->vc); */ + } + if(vf->dataoffsets)_ogg_free(vf->dataoffsets); + if(vf->pcmlengths)_ogg_free(vf->pcmlengths); + if(vf->serialnos)_ogg_free(vf->serialnos); + if(vf->offsets)_ogg_free(vf->offsets); + ogg_sync_clear(&vf->oy); + if(vf->datasource && vf->callbacks.close_func) + (vf->callbacks.close_func)(vf->datasource); + memset(vf,0,sizeof(*vf)); + } +#ifdef DEBUG_LEAKS + _VDBG_dump(); +#endif + return(0); +} + +/* inspects the OggVorbis file and finds/documents all the logical + bitstreams contained in it. Tries to be tolerant of logical + bitstream sections that are truncated/woogie. + + return: -1) error + 0) OK +*/ + +int ov_open_callbacks(void *f,OggVorbis_File *vf, + const char *initial,long ibytes,ov_callbacks callbacks){ + #if defined(CPU_COLDFIRE) + /* this seems to be the closest we get to an init function, let's init emac + here. rounding is disabled because of MULT31_SHIFT15, which will be + inaccurate with rounding in its current incarnation */ + coldfire_set_macsr(EMAC_FRACTIONAL | EMAC_SATURATE); + #endif + int ret=_ov_open1(f,vf,initial,ibytes,callbacks); + if(ret)return ret; + return _ov_open2(vf); +} + +/* returns: total PCM length (samples) of content if i==-1 PCM length + (samples) of that logical bitstream for i==0 to n + OV_EINVAL if the stream is not seekable (we can't know the + length) or only partially open +*/ +ogg_int64_t ov_pcm_total(OggVorbis_File *vf,int i){ + if(vf->ready_stateseekable || i>=vf->links)return(OV_EINVAL); + if(i<0){ + ogg_int64_t acc=0; + int i; + for(i=0;ilinks;i++) + acc+=ov_pcm_total(vf,i); + return(acc); + }else{ + return(vf->pcmlengths[i*2+1]); + } +} + +/* returns: total milliseconds of content if i==-1 + milliseconds in that logical bitstream for i==0 to n + OV_EINVAL if the stream is not seekable (we can't know the + length) or only partially open +*/ +ogg_int64_t ov_time_total(OggVorbis_File *vf,int i){ + if(vf->ready_stateseekable || i>=vf->links)return(OV_EINVAL); + if(i<0){ + ogg_int64_t acc=0; + int i; + for(i=0;ilinks;i++) + acc+=ov_time_total(vf,i); + return(acc); + }else{ + return(((ogg_int64_t)vf->pcmlengths[i*2+1])*1000/vf->vi[i].rate); + } +} + +/* seek to an offset relative to the *compressed* data. This also + scans packets to update the PCM cursor. It will cross a logical + bitstream boundary, but only if it can't get any packets out of the + tail of the bitstream we seek to (so no surprises). + + returns zero on success, nonzero on failure */ + +int ov_raw_seek(OggVorbis_File *vf,ogg_int64_t pos){ + ogg_stream_state work_os; + int ret; + + if(vf->ready_stateseekable) + return(OV_ENOSEEK); /* don't dump machine if we can't seek */ + + if(pos<0 || pos>vf->end)return(OV_EINVAL); + + /* is the seek position outside our current link [if any]? */ + if(vf->ready_state>=STREAMSET){ + if(posoffsets[vf->current_link] || pos>=vf->offsets[vf->current_link+1]) + _decode_clear(vf); /* clear out stream state */ + } + + /* don't yet clear out decoding machine (if it's initialized), in + the case we're in the same link. Restart the decode lapping, and + let _fetch_and_process_packet deal with a potential bitstream + boundary */ + vf->pcm_offset=-1; + ogg_stream_reset_serialno(&vf->os, + vf->current_serialno); /* must set serialno */ + vorbis_synthesis_restart(&vf->vd); + + ret=_seek_helper(vf,pos); + if(ret)goto seek_error; + + /* we need to make sure the pcm_offset is set, but we don't want to + advance the raw cursor past good packets just to get to the first + with a granulepos. That's not equivalent behavior to beginning + decoding as immediately after the seek position as possible. + + So, a hack. We use two stream states; a local scratch state and + the shared vf->os stream state. We use the local state to + scan, and the shared state as a buffer for later decode. + + Unfortuantely, on the last page we still advance to last packet + because the granulepos on the last page is not necessarily on a + packet boundary, and we need to make sure the granpos is + correct. + */ + + { + ogg_page og; + ogg_packet op; + int lastblock=0; + int accblock=0; + int thisblock=0; + int lastflag=0; + int firstflag=0; + ogg_int64_t pagepos=-1; + + ogg_stream_init(&work_os,vf->current_serialno); /* get the memory ready */ + ogg_stream_reset(&work_os); /* eliminate the spurious OV_HOLE + return from not necessarily + starting from the beginning */ + + while(1){ + if(vf->ready_state>=STREAMSET){ + /* snarf/scan a packet if we can */ + int result=ogg_stream_packetout(&work_os,&op); + + if(result>0){ + + if(vf->vi[vf->current_link].codec_setup){ + thisblock=vorbis_packet_blocksize(vf->vi+vf->current_link,&op); + if(thisblock<0){ + ogg_stream_packetout(&vf->os,NULL); + thisblock=0; + }else{ + + /* We can't get a guaranteed correct pcm position out of the + last page in a stream because it might have a 'short' + granpos, which can only be detected in the presence of a + preceding page. However, if the last page is also the first + page, the granpos rules of a first page take precedence. Not + only that, but for first==last, the EOS page must be treated + as if its a normal first page for the stream to open/play. */ + if(lastflag && !firstflag) + ogg_stream_packetout(&vf->os,NULL); + else + if(lastblock)accblock+=(lastblock+thisblock)>>2; + } + + if(op.granulepos!=-1){ + int i,link=vf->current_link; + ogg_int64_t granulepos=op.granulepos-vf->pcmlengths[link*2]; + if(granulepos<0)granulepos=0; + + for(i=0;ipcmlengths[i*2+1]; + vf->pcm_offset=granulepos-accblock; + if(vf->pcm_offset<0)vf->pcm_offset=0; + break; + } + lastblock=thisblock; + continue; + }else + ogg_stream_packetout(&vf->os,NULL); + } + } + + if(!lastblock){ + pagepos=_get_next_page(vf,&og,-1); + if(pagepos<0){ + vf->pcm_offset=ov_pcm_total(vf,-1); + break; + } + }else{ + /* huh? Bogus stream with packets but no granulepos */ + vf->pcm_offset=-1; + break; + } + + /* has our decoding just traversed a bitstream boundary? */ + if(vf->ready_state>=STREAMSET){ + if(vf->current_serialno!=ogg_page_serialno(&og)){ + + /* two possibilities: + 1) our decoding just traversed a bitstream boundary + 2) another stream is multiplexed into this logical section? */ + + if(ogg_page_bos(&og)){ + /* we traversed */ + _decode_clear(vf); /* clear out stream state */ + ogg_stream_clear(&work_os); + } /* else, do nothing; next loop will scoop another page */ + } + } + + if(vf->ready_statelinks;link++) + if(vf->serialnos[link]==serialno)break; + + if(link==vf->links) continue; /* not the desired Vorbis + bitstream section; keep + trying */ + vf->current_link=link; + vf->current_serialno=serialno; + ogg_stream_reset_serialno(&vf->os,serialno); + ogg_stream_reset_serialno(&work_os,serialno); + vf->ready_state=STREAMSET; + firstflag=(pagepos<=vf->dataoffsets[link]); + } + + ogg_stream_pagein(&vf->os,&og,true); + ogg_stream_pagein(&work_os,&og,true); + lastflag=ogg_page_eos(&og); + + } + } + + ogg_stream_clear(&work_os); + vf->bittrack=0; + vf->samptrack=0; + return(0); + + seek_error: + /* dump the machine so we're in a known state */ + vf->pcm_offset=-1; + ogg_stream_clear(&work_os); + _decode_clear(vf); + return OV_EBADLINK; +} + +/* rescales the number x from the range of [0,from] to [0,to] + x is in the range [0,from] + from, to are in the range [1, 1<<62-1] */ +ogg_int64_t rescale64(ogg_int64_t x, ogg_int64_t from, ogg_int64_t to){ + ogg_int64_t frac=0; + ogg_int64_t ret=0; + int i; + if(x >= from) return to; + if(x <= 0) return 0; + + for(i=0;i<64;i++){ + if(x>=from){ + frac|=1; + x-=from; + } + x<<=1; + frac<<=1; + } + + for(i=0;i<64;i++){ + if(frac & 1){ + ret+=to; + } + frac>>=1; + ret>>=1; + } + + return ret; +} + +/* Page granularity seek (faster than sample granularity because we + don't do the last bit of decode to find a specific sample). + + Seek to the last [granule marked] page preceding the specified pos + location, such that decoding past the returned point will quickly + arrive at the requested position. */ +int ov_pcm_seek_page(OggVorbis_File *vf,ogg_int64_t pos){ + int link=-1; + ogg_int64_t result=0; + ogg_int64_t total=ov_pcm_total(vf,-1); + + if(vf->ready_stateseekable)return(OV_ENOSEEK); + + if(pos<0 || pos>total)return(OV_EINVAL); + + /* which bitstream section does this pcm offset occur in? */ + for(link=vf->links-1;link>=0;link--){ + total-=vf->pcmlengths[link*2+1]; + if(pos>=total)break; + } + + /* search within the logical bitstream for the page with the highest + pcm_pos preceding (or equal to) pos. There is a danger here; + missing pages or incorrect frame number information in the + bitstream could make our task impossible. Account for that (it + would be an error condition) */ + + /* new search algorithm by HB (Nicholas Vinen) */ + { + ogg_int64_t end=vf->offsets[link+1]; + ogg_int64_t begin=vf->offsets[link]; + ogg_int64_t begintime = vf->pcmlengths[link*2]; + ogg_int64_t endtime = vf->pcmlengths[link*2+1]+begintime; + ogg_int64_t target=pos-total+begintime; + ogg_int64_t best=begin; + + ogg_page og; + while(beginoffset){ + result=_seek_helper(vf,bisect); + if(result) goto seek_error; + } + + while(beginoffset); + if(result==OV_EREAD) goto seek_error; + if(result<0){ + if(bisect<=begin+1) + end=begin; /* found it */ + else{ + if(bisect==0) goto seek_error; + bisect-=CHUNKSIZE; + if(bisect<=begin)bisect=begin+1; + result=_seek_helper(vf,bisect); + if(result) goto seek_error; + } + }else{ + ogg_int64_t granulepos; + + if(ogg_page_serialno(&og)!=vf->serialnos[link]) + continue; + + granulepos=ogg_page_granulepos(&og); + if(granulepos==-1)continue; + + if(granuleposoffset; /* raw offset of next page */ + begintime=granulepos; + + if(target-begintime>44100)break; + bisect=begin; /* *not* begin + 1 */ + }else{ + if(bisect<=begin+1) + end=begin; /* found it */ + else{ + if(end==vf->offset){ /* we're pretty close - we'd be stuck in */ + end=result; + bisect-=CHUNKSIZE; /* an endless loop otherwise. */ + if(bisect<=begin)bisect=begin+1; + result=_seek_helper(vf,bisect); + if(result) goto seek_error; + }else{ + end=bisect; + endtime=granulepos; + break; + } + } + } + } + } + } + + /* found our page. seek to it, update pcm offset. Easier case than + raw_seek, don't keep packets preceding granulepos. */ + { + ogg_page og; + ogg_packet op; + + /* seek */ + result=_seek_helper(vf,best); + vf->pcm_offset=-1; + if(result) goto seek_error; + result=_get_next_page(vf,&og,-1); + if(result<0) goto seek_error; + + if(link!=vf->current_link){ + /* Different link; dump entire decode machine */ + _decode_clear(vf); + + vf->current_link=link; + vf->current_serialno=vf->serialnos[link]; + vf->ready_state=STREAMSET; + + }else{ + vorbis_synthesis_restart(&vf->vd); + } + + ogg_stream_reset_serialno(&vf->os,vf->current_serialno); + ogg_stream_pagein(&vf->os,&og,true); + + /* pull out all but last packet; the one with granulepos */ + while(1){ + result=ogg_stream_packetpeek(&vf->os,&op); + if(result==0){ + /* !!! the packet finishing this page originated on a + preceding page. Keep fetching previous pages until we + get one with a granulepos or without the 'continued' flag + set. Then just use raw_seek for simplicity. */ + + result=_seek_helper(vf,best); + if(result<0) goto seek_error; + + while(1){ + result=_get_prev_page(vf,&og); + if(result<0) goto seek_error; + if(ogg_page_serialno(&og)==vf->current_serialno && + (ogg_page_granulepos(&og)>-1 || + !ogg_page_continued(&og))){ + return ov_raw_seek(vf,result); + } + vf->offset=result; + } + } + if(result<0){ + result = OV_EBADPACKET; + goto seek_error; + } + if(op.granulepos!=-1){ + vf->pcm_offset=op.granulepos-vf->pcmlengths[vf->current_link*2]; + if(vf->pcm_offset<0)vf->pcm_offset=0; + vf->pcm_offset+=total; + break; + }else + result=ogg_stream_packetout(&vf->os,NULL); + } + } + } + + /* verify result */ + if(vf->pcm_offset>pos || pos>ov_pcm_total(vf,-1)){ + result=OV_EFAULT; + goto seek_error; + } + vf->bittrack=0; + vf->samptrack=0; + return(0); + + seek_error: + /* dump machine so we're in a known state */ + vf->pcm_offset=-1; + _decode_clear(vf); + return (int)result; +} + +/* seek to a sample offset relative to the decompressed pcm stream + returns zero on success, nonzero on failure */ + +int ov_pcm_seek(OggVorbis_File *vf,ogg_int64_t pos){ + int thisblock,lastblock=0; + int ret=ov_pcm_seek_page(vf,pos); + if(ret<0)return(ret); + if((ret=_make_decode_ready(vf)))return ret; + + /* discard leading packets we don't need for the lapping of the + position we want; don't decode them */ + + while(1){ + ogg_packet op; + ogg_page og; + + int ret=ogg_stream_packetpeek(&vf->os,&op); + if(ret>0){ + thisblock=vorbis_packet_blocksize(vf->vi+vf->current_link,&op); + if(thisblock<0){ + ogg_stream_packetout(&vf->os,NULL); + continue; /* non audio packet */ + } + if(lastblock)vf->pcm_offset+=(lastblock+thisblock)>>2; + + if(vf->pcm_offset+((thisblock+ + vorbis_info_blocksize(vf->vi,1))>>2)>=pos)break; + + /* remove the packet from packet queue and track its granulepos */ + ogg_stream_packetout(&vf->os,NULL); + vorbis_synthesis_trackonly(&vf->vb,&op); /* set up a vb with + only tracking, no + pcm_decode */ + vorbis_synthesis_blockin(&vf->vd,&vf->vb); + + /* end of logical stream case is hard, especially with exact + length positioning. */ + + if(op.granulepos>-1){ + int i; + /* always believe the stream markers */ + vf->pcm_offset=op.granulepos-vf->pcmlengths[vf->current_link*2]; + if(vf->pcm_offset<0)vf->pcm_offset=0; + for(i=0;icurrent_link;i++) + vf->pcm_offset+=vf->pcmlengths[i*2+1]; + } + + lastblock=thisblock; + + }else{ + if(ret<0 && ret!=OV_HOLE)break; + + /* suck in a new page */ + if(_get_next_page(vf,&og,-1)<0)break; + if(ogg_page_bos(&og))_decode_clear(vf); + + if(vf->ready_statelinks;link++) + if(vf->serialnos[link]==(ogg_uint32_t) serialno)break; + if(link==vf->links) continue; + vf->current_link=link; + + vf->ready_state=STREAMSET; + vf->current_serialno=ogg_page_serialno(&og); + ogg_stream_reset_serialno(&vf->os,serialno); + ret=_make_decode_ready(vf); + if(ret)return ret; + lastblock=0; + } + + ogg_stream_pagein(&vf->os,&og,true); + } + } + + vf->bittrack=0; + vf->samptrack=0; + /* discard samples until we reach the desired position. Crossing a + logical bitstream boundary with abandon is OK. */ + while(vf->pcm_offsetpcm_offset; + long samples=vorbis_synthesis_pcmout(&vf->vd,NULL); + + if(samples>target)samples=target; + vorbis_synthesis_read(&vf->vd,samples); + vf->pcm_offset+=samples; + + if(samplespcm_offset=ov_pcm_total(vf,-1); /* eof */ + } + return 0; +} + +/* seek to a playback time relative to the decompressed pcm stream + returns zero on success, nonzero on failure */ +int ov_time_seek(OggVorbis_File *vf,ogg_int64_t milliseconds){ + /* translate time to PCM position and call ov_pcm_seek */ + + int link=-1; + ogg_int64_t pcm_total=0; + ogg_int64_t time_total=0; + + if(vf->ready_stateseekable)return(OV_ENOSEEK); + if(milliseconds<0)return(OV_EINVAL); + + /* which bitstream section does this time offset occur in? */ + for(link=0;linklinks;link++){ + ogg_int64_t addsec = ov_time_total(vf,link); + if(millisecondspcmlengths[link*2+1]; + } + + if(link==vf->links)return(OV_EINVAL); + + /* enough information to convert time offset to pcm offset */ + { + ogg_int64_t target=pcm_total+(milliseconds-time_total)*vf->vi[link].rate/1000; + return(ov_pcm_seek(vf,target)); + } +} + +/* tell the current stream offset cursor. Note that seek followed by + tell will likely not give the set offset due to caching */ +ogg_int64_t ov_raw_tell(OggVorbis_File *vf){ + if(vf->ready_stateoffset); +} + +/* return time offset (milliseconds) of next PCM sample to be read */ +ogg_int64_t ov_time_tell(OggVorbis_File *vf){ + int link=0; + ogg_int64_t pcm_total=0; + ogg_int64_t time_total=0; + + if(vf->ready_stateseekable){ + pcm_total=ov_pcm_total(vf,-1); + time_total=ov_time_total(vf,-1); + + /* which bitstream section does this time offset occur in? */ + for(link=vf->links-1;link>=0;link--){ + pcm_total-=vf->pcmlengths[link*2+1]; + time_total-=ov_time_total(vf,link); + if(vf->pcm_offset>=pcm_total)break; + } + } + + return(time_total+(1000*vf->pcm_offset-pcm_total)/vf->vi[link].rate); +} + +/* link: -1) return the vorbis_info struct for the bitstream section + currently being decoded + 0-n) to request information for a specific bitstream section + + In the case of a non-seekable bitstream, any call returns the + current bitstream. NULL in the case that the machine is not + initialized */ + +vorbis_info *ov_info(OggVorbis_File *vf,int link){ + if(vf->seekable){ + if(link<0) + if(vf->ready_state>=STREAMSET) + return vf->vi+vf->current_link; + else + return vf->vi; + else + if(link>=vf->links) + return NULL; + else + return vf->vi+link; + }else{ + return vf->vi; + } +} + +/* input values: pcm_channels) a float vector per channel of output + length) the sample length being read by the app + + return values: <0) error/hole in data (OV_HOLE), partial open (OV_EINVAL) + 0) EOF + n) number of samples of PCM actually returned. The + below works on a packet-by-packet basis, so the + return length is not related to the 'length' passed + in, just guaranteed to fit. + + *section) set to the logical bitstream number */ + +long ov_read_fixed(OggVorbis_File *vf,ogg_int32_t ***pcm_channels,int length, + int *bitstream){ + if(vf->ready_stateready_state==INITSET){ + ogg_int32_t **pcm; + long samples=vorbis_synthesis_pcmout(&vf->vd,&pcm); + if(samples){ + if(pcm_channels)*pcm_channels=pcm; + if(samples>length)samples=length; + vorbis_synthesis_read(&vf->vd,samples); + vf->pcm_offset+=samples; + if(bitstream)*bitstream=vf->current_link; + return samples; + + } + } + + /* suck in another packet */ + { + int ret=_fetch_and_process_packet(vf,NULL,1,1); + if(ret==OV_EOF) + return(0); + if(ret<=0) + return(ret); + } + } +} + diff --git a/lib/rbcodec/codecs/libtremor/window.c b/lib/rbcodec/codecs/libtremor/window.c new file mode 100644 index 0000000000..3bc947f0e5 --- /dev/null +++ b/lib/rbcodec/codecs/libtremor/window.c @@ -0,0 +1,82 @@ +/******************************************************************** + * * + * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * + * * + * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * + * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * + * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * + * * + * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * + * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * + * * + ******************************************************************** + + function: window functions + + ********************************************************************/ + +#include "config-tremor.h" +#include +#include +#include "os.h" +#include "misc.h" +#include "window.h" +#include "window_lookup.h" + +const void *_vorbis_window(int type, int left){ + + switch(type){ + case 0: + + switch(left){ + case 32: + return vwin64; + case 64: + return vwin128; + case 128: + return vwin256; + case 256: + return vwin512; + case 512: + return vwin1024; + case 1024: + return vwin2048; + case 2048: + return vwin4096; + case 4096: + return vwin8192; + default: + return(0); + } + break; + default: + return(0); + } +} +#if 0 +void _vorbis_apply_window(ogg_int32_t *d,const void *window_p[2], + long *blocksizes, + int lW,int W,int nW){ + LOOKUP_T *window[2]={window_p[0],window_p[1]}; + long n=blocksizes[W]; + long ln=blocksizes[lW]; + long rn=blocksizes[nW]; + + long leftbegin=n/4-ln/4; + long leftend=leftbegin+ln/2; + + long rightbegin=n/2+n/4-rn/4; + long rightend=rightbegin+rn/2; + + /* Following memset is not required - we are careful to only overlap/add the + regions that geniunely overlap in the window region, and the portions + outside that region are not added (so don't need to be zerod). see block.c + memset((void *)&d[0], 0, sizeof(ogg_int32_t)*leftbegin); */ + + ogg_vect_mult_fw(&d[leftbegin], &window[lW][0], leftend-leftbegin); + ogg_vect_mult_bw(&d[rightbegin], &window[nW][rn/2-1], rightend-rightbegin); + + /* Again - memset not needed + memset((void *)&d[rightend], 0, sizeof(ogg_int32_t)*(n-rightend)); */ +} +#endif diff --git a/lib/rbcodec/codecs/libtremor/window.h b/lib/rbcodec/codecs/libtremor/window.h new file mode 100644 index 0000000000..166d0b8e9c --- /dev/null +++ b/lib/rbcodec/codecs/libtremor/window.h @@ -0,0 +1,27 @@ +/******************************************************************** + * * + * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * + * * + * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * + * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * + * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * + * * + * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * + * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * + * * + ******************************************************************** + + function: window functions + + ********************************************************************/ + +#ifndef _V_WINDOW_ +#define _V_WINDOW_ + +extern const void *_vorbis_window(int type,int left); +/*extern void _vorbis_apply_window(ogg_int32_t *d,const void *window[2], + long *blocksizes, + int lW,int W,int nW);*/ + + +#endif diff --git a/lib/rbcodec/codecs/libtremor/window_lookup.h b/lib/rbcodec/codecs/libtremor/window_lookup.h new file mode 100644 index 0000000000..5363b81042 --- /dev/null +++ b/lib/rbcodec/codecs/libtremor/window_lookup.h @@ -0,0 +1,2087 @@ +/******************************************************************** + * * + * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * + * * + * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * + * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * + * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * + * * + * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * + * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * + * * + ******************************************************************** + + function: window lookup tables + + ********************************************************************/ + + +#include "os_types.h" + +/* libvorbis currently only use the window sizes 256 and 2048, so only put + * them in fast IRAM. + */ +static LOOKUP_T vwin64[32] = { + X(0x001f0003), X(0x01168c98), X(0x030333c8), X(0x05dfe3a4), + X(0x09a49562), X(0x0e45df18), X(0x13b47ef2), X(0x19dcf676), + X(0x20a74d83), X(0x27f7137c), X(0x2fabb05a), X(0x37a1105a), + X(0x3fb0ab28), X(0x47b2dcd1), X(0x4f807bc6), X(0x56f48e70), + X(0x5dedfc79), X(0x64511653), X(0x6a08cfff), X(0x6f079328), + X(0x734796f4), X(0x76cab7f2), X(0x7999d6e8), X(0x7bc3cf9f), + X(0x7d5c20c1), X(0x7e7961df), X(0x7f33a567), X(0x7fa2e1d0), + X(0x7fdd78a5), X(0x7ff6ec6d), X(0x7ffed0e9), X(0x7ffffc3f), +}; + +static LOOKUP_T vwin128[64] = { + X(0x0007c04d), X(0x0045bb89), X(0x00c18b87), X(0x017ae294), + X(0x02714a4e), X(0x03a4217a), X(0x05129952), X(0x06bbb24f), + X(0x089e38a1), X(0x0ab8c073), X(0x0d09a228), X(0x0f8ef6bd), + X(0x12469488), X(0x152e0c7a), X(0x1842a81c), X(0x1b81686d), + X(0x1ee705d9), X(0x226ff15d), X(0x26185705), X(0x29dc21cc), + X(0x2db700fe), X(0x31a46f08), X(0x359fb9c1), X(0x39a40c0c), + X(0x3dac78b6), X(0x41b40674), X(0x45b5bcb0), X(0x49acb109), + X(0x4d94152b), X(0x516744bd), X(0x5521d320), X(0x58bf98a5), + X(0x5c3cbef4), X(0x5f95cc5d), X(0x62c7add7), X(0x65cfbf64), + X(0x68abd2ba), X(0x6b5a3405), X(0x6dd9acab), X(0x7029840d), + X(0x72497e38), X(0x7439d8ac), X(0x75fb4532), X(0x778ee30a), + X(0x78f6367e), X(0x7a331f1a), X(0x7b47cccd), X(0x7c36b416), + X(0x7d028192), X(0x7dae0d18), X(0x7e3c4caa), X(0x7eb04763), + X(0x7f0d08a7), X(0x7f5593b7), X(0x7f8cd7d5), X(0x7fb5a513), + X(0x7fd2a1fc), X(0x7fe64212), X(0x7ff2bd4c), X(0x7ffa0890), + X(0x7ffdcf39), X(0x7fff6dac), X(0x7fffed01), X(0x7fffffc4), +}; + +static LOOKUP_T vwin256[128] = { + X(0x0001f018), X(0x00117066), X(0x00306e9e), X(0x005ee5f1), + X(0x009ccf26), X(0x00ea208b), X(0x0146cdea), X(0x01b2c87f), + X(0x022dfedf), X(0x02b85ced), X(0x0351cbbd), X(0x03fa317f), + X(0x04b17167), X(0x05776b90), X(0x064bfcdc), X(0x072efedd), + X(0x082047b4), X(0x091fa9f1), X(0x0a2cf477), X(0x0b47f25d), + X(0x0c706ad2), X(0x0da620ff), X(0x0ee8d3ef), X(0x10383e75), + X(0x11941716), X(0x12fc0ff6), X(0x146fd6c8), X(0x15ef14c2), + X(0x17796e8e), X(0x190e844f), X(0x1aadf196), X(0x1c574d6e), + X(0x1e0a2a62), X(0x1fc61688), X(0x218a9b9c), X(0x23573f12), + X(0x252b823d), X(0x2706e269), X(0x28e8d913), X(0x2ad0dc0e), + X(0x2cbe5dc1), X(0x2eb0cd60), X(0x30a79733), X(0x32a224d5), + X(0x349fdd8b), X(0x36a02690), X(0x38a2636f), X(0x3aa5f65e), + X(0x3caa409e), X(0x3eaea2df), X(0x40b27da6), X(0x42b531b8), + X(0x44b62086), X(0x46b4ac99), X(0x48b03a05), X(0x4aa82ed5), + X(0x4c9bf37d), X(0x4e8af349), X(0x50749ccb), X(0x52586246), + X(0x5435ba1c), X(0x560c1f31), X(0x57db1152), X(0x59a21591), + X(0x5b60b6a3), X(0x5d168535), X(0x5ec31839), X(0x60660d36), + X(0x61ff0886), X(0x638db595), X(0x6511c717), X(0x668af734), + X(0x67f907b0), X(0x695bc207), X(0x6ab2f787), X(0x6bfe815a), + X(0x6d3e4090), X(0x6e721e16), X(0x6f9a0ab5), X(0x70b5fef8), + X(0x71c5fb16), X(0x72ca06cd), X(0x73c2313d), X(0x74ae90b2), + X(0x758f4275), X(0x76646a85), X(0x772e335c), X(0x77eccda0), + X(0x78a06fd7), X(0x79495613), X(0x79e7c19c), X(0x7a7bf894), + X(0x7b064596), X(0x7b86f757), X(0x7bfe6044), X(0x7c6cd615), + X(0x7cd2b16e), X(0x7d304d71), X(0x7d860756), X(0x7dd43e06), + X(0x7e1b51ad), X(0x7e5ba355), X(0x7e95947e), X(0x7ec986bb), + X(0x7ef7db4a), X(0x7f20f2b9), X(0x7f452c7f), X(0x7f64e6a7), + X(0x7f807d71), X(0x7f984aff), X(0x7faca700), X(0x7fbde662), + X(0x7fcc5b04), X(0x7fd85372), X(0x7fe21a99), X(0x7fe9f791), + X(0x7ff02d58), X(0x7ff4fa9e), X(0x7ff89990), X(0x7ffb3faa), + X(0x7ffd1d8b), X(0x7ffe5ecc), X(0x7fff29e0), X(0x7fff9ff3), + X(0x7fffdcd2), X(0x7ffff6d6), X(0x7ffffed0), X(0x7ffffffc), +}; + +static LOOKUP_T vwin512[256] = { + X(0x00007c06), X(0x00045c32), X(0x000c1c62), X(0x0017bc4c), + X(0x00273b7a), X(0x003a9955), X(0x0051d51c), X(0x006cede7), + X(0x008be2a9), X(0x00aeb22a), X(0x00d55b0d), X(0x00ffdbcc), + X(0x012e32b6), X(0x01605df5), X(0x01965b85), X(0x01d02939), + X(0x020dc4ba), X(0x024f2b83), X(0x02945ae6), X(0x02dd5004), + X(0x032a07d3), X(0x037a7f19), X(0x03ceb26e), X(0x04269e37), + X(0x04823eab), X(0x04e18fcc), X(0x05448d6d), X(0x05ab3329), + X(0x06157c68), X(0x0683645e), X(0x06f4e607), X(0x0769fc25), + X(0x07e2a146), X(0x085ecfbc), X(0x08de819f), X(0x0961b0cc), + X(0x09e856e3), X(0x0a726d46), X(0x0affed1d), X(0x0b90cf4c), + X(0x0c250c79), X(0x0cbc9d0b), X(0x0d577926), X(0x0df598aa), + X(0x0e96f337), X(0x0f3b8026), X(0x0fe3368f), X(0x108e0d42), + X(0x113bfaca), X(0x11ecf56b), X(0x12a0f324), X(0x1357e9ac), + X(0x1411ce70), X(0x14ce9698), X(0x158e3702), X(0x1650a444), + X(0x1715d2aa), X(0x17ddb638), X(0x18a842aa), X(0x19756b72), + X(0x1a4523b9), X(0x1b175e62), X(0x1bec0e04), X(0x1cc324f0), + X(0x1d9c9532), X(0x1e78508a), X(0x1f564876), X(0x20366e2e), + X(0x2118b2a2), X(0x21fd0681), X(0x22e35a37), X(0x23cb9dee), + X(0x24b5c18e), X(0x25a1b4c0), X(0x268f66f1), X(0x277ec74e), + X(0x286fc4cc), X(0x29624e23), X(0x2a5651d7), X(0x2b4bbe34), + X(0x2c428150), X(0x2d3a8913), X(0x2e33c332), X(0x2f2e1d35), + X(0x30298478), X(0x3125e62d), X(0x32232f61), X(0x33214cfc), + X(0x34202bc2), X(0x351fb85a), X(0x361fdf4f), X(0x37208d10), + X(0x3821adf7), X(0x39232e49), X(0x3a24fa3c), X(0x3b26fdf6), + X(0x3c292593), X(0x3d2b5d29), X(0x3e2d90c8), X(0x3f2fac7f), + X(0x40319c5f), X(0x41334c81), X(0x4234a905), X(0x43359e16), + X(0x443617f3), X(0x453602eb), X(0x46354b65), X(0x4733dde1), + X(0x4831a6ff), X(0x492e937f), X(0x4a2a9045), X(0x4b258a5f), + X(0x4c1f6f06), X(0x4d182ba2), X(0x4e0fadce), X(0x4f05e35b), + X(0x4ffaba53), X(0x50ee20fd), X(0x51e005e1), X(0x52d057ca), + X(0x53bf05ca), X(0x54abff3b), X(0x559733c7), X(0x56809365), + X(0x57680e62), X(0x584d955d), X(0x59311952), X(0x5a128b96), + X(0x5af1dddd), X(0x5bcf023a), X(0x5ca9eb27), X(0x5d828b81), + X(0x5e58d68d), X(0x5f2cbffc), X(0x5ffe3be9), X(0x60cd3edf), + X(0x6199bdda), X(0x6263ae45), X(0x632b0602), X(0x63efbb66), + X(0x64b1c53f), X(0x65711ad0), X(0x662db3d7), X(0x66e7888d), + X(0x679e91a5), X(0x6852c84e), X(0x69042635), X(0x69b2a582), + X(0x6a5e40dd), X(0x6b06f36c), X(0x6bacb8d2), X(0x6c4f8d30), + X(0x6cef6d26), X(0x6d8c55d4), X(0x6e2644d4), X(0x6ebd3840), + X(0x6f512ead), X(0x6fe2272e), X(0x7070214f), X(0x70fb1d17), + X(0x71831b06), X(0x72081c16), X(0x728a21b5), X(0x73092dc8), + X(0x738542a6), X(0x73fe631b), X(0x74749261), X(0x74e7d421), + X(0x75582c72), X(0x75c59fd5), X(0x76303333), X(0x7697ebdd), + X(0x76fccf85), X(0x775ee443), X(0x77be308a), X(0x781abb2e), + X(0x78748b59), X(0x78cba88e), X(0x79201aa7), X(0x7971e9cd), + X(0x79c11e79), X(0x7a0dc170), X(0x7a57dbc2), X(0x7a9f76c1), + X(0x7ae49c07), X(0x7b27556b), X(0x7b67ad02), X(0x7ba5ad1b), + X(0x7be1603a), X(0x7c1ad118), X(0x7c520a9e), X(0x7c8717e1), + X(0x7cba0421), X(0x7ceadac3), X(0x7d19a74f), X(0x7d46756e), + X(0x7d7150e5), X(0x7d9a4592), X(0x7dc15f69), X(0x7de6aa71), + X(0x7e0a32c0), X(0x7e2c0479), X(0x7e4c2bc7), X(0x7e6ab4db), + X(0x7e87abe9), X(0x7ea31d24), X(0x7ebd14be), X(0x7ed59edd), + X(0x7eecc7a3), X(0x7f029b21), X(0x7f17255a), X(0x7f2a723f), + X(0x7f3c8daa), X(0x7f4d835d), X(0x7f5d5f00), X(0x7f6c2c1b), + X(0x7f79f617), X(0x7f86c83a), X(0x7f92ada2), X(0x7f9db146), + X(0x7fa7ddf3), X(0x7fb13e46), X(0x7fb9dcb0), X(0x7fc1c36c), + X(0x7fc8fc83), X(0x7fcf91c7), X(0x7fd58cd2), X(0x7fdaf702), + X(0x7fdfd979), X(0x7fe43d1c), X(0x7fe82a8b), X(0x7febaa29), + X(0x7feec412), X(0x7ff1801c), X(0x7ff3e5d6), X(0x7ff5fc86), + X(0x7ff7cb29), X(0x7ff9586f), X(0x7ffaaaba), X(0x7ffbc81e), + X(0x7ffcb660), X(0x7ffd7af3), X(0x7ffe1afa), X(0x7ffe9b42), + X(0x7fff0047), X(0x7fff4e2f), X(0x7fff88c9), X(0x7fffb390), + X(0x7fffd1a6), X(0x7fffe5d7), X(0x7ffff296), X(0x7ffff9fd), + X(0x7ffffdcd), X(0x7fffff6d), X(0x7fffffed), X(0x7fffffff), +}; + +static LOOKUP_T vwin1024[512] = { + X(0x00001f02), X(0x0001170e), X(0x00030724), X(0x0005ef40), + X(0x0009cf59), X(0x000ea767), X(0x0014775e), X(0x001b3f2e), + X(0x0022fec8), X(0x002bb618), X(0x00356508), X(0x00400b81), + X(0x004ba968), X(0x00583ea0), X(0x0065cb0a), X(0x00744e84), + X(0x0083c8ea), X(0x00943a14), X(0x00a5a1da), X(0x00b80010), + X(0x00cb5488), X(0x00df9f10), X(0x00f4df76), X(0x010b1584), + X(0x01224101), X(0x013a61b2), X(0x01537759), X(0x016d81b6), + X(0x01888087), X(0x01a47385), X(0x01c15a69), X(0x01df34e6), + X(0x01fe02b1), X(0x021dc377), X(0x023e76e7), X(0x02601ca9), + X(0x0282b466), X(0x02a63dc1), X(0x02cab85d), X(0x02f023d6), + X(0x03167fcb), X(0x033dcbd3), X(0x03660783), X(0x038f3270), + X(0x03b94c29), X(0x03e4543a), X(0x04104a2e), X(0x043d2d8b), + X(0x046afdd5), X(0x0499ba8c), X(0x04c9632d), X(0x04f9f734), + X(0x052b7615), X(0x055ddf46), X(0x05913237), X(0x05c56e53), + X(0x05fa9306), X(0x06309fb6), X(0x066793c5), X(0x069f6e93), + X(0x06d82f7c), X(0x0711d5d9), X(0x074c60fe), X(0x0787d03d), + X(0x07c422e4), X(0x0801583e), X(0x083f6f91), X(0x087e681f), + X(0x08be4129), X(0x08fef9ea), X(0x0940919a), X(0x0983076d), + X(0x09c65a92), X(0x0a0a8a38), X(0x0a4f9585), X(0x0a957b9f), + X(0x0adc3ba7), X(0x0b23d4b9), X(0x0b6c45ee), X(0x0bb58e5a), + X(0x0bffad0f), X(0x0c4aa11a), X(0x0c966982), X(0x0ce3054d), + X(0x0d30737b), X(0x0d7eb308), X(0x0dcdc2eb), X(0x0e1da21a), + X(0x0e6e4f83), X(0x0ebfca11), X(0x0f1210ad), X(0x0f652238), + X(0x0fb8fd91), X(0x100da192), X(0x10630d11), X(0x10b93ee0), + X(0x111035cb), X(0x1167f09a), X(0x11c06e13), X(0x1219acf5), + X(0x1273abfb), X(0x12ce69db), X(0x1329e54a), X(0x13861cf3), + X(0x13e30f80), X(0x1440bb97), X(0x149f1fd8), X(0x14fe3ade), + X(0x155e0b40), X(0x15be8f92), X(0x161fc662), X(0x1681ae38), + X(0x16e4459b), X(0x17478b0b), X(0x17ab7d03), X(0x181019fb), + X(0x18756067), X(0x18db4eb3), X(0x1941e34a), X(0x19a91c92), + X(0x1a10f8ea), X(0x1a7976af), X(0x1ae29439), X(0x1b4c4fda), + X(0x1bb6a7e2), X(0x1c219a9a), X(0x1c8d2649), X(0x1cf9492e), + X(0x1d660188), X(0x1dd34d8e), X(0x1e412b74), X(0x1eaf996a), + X(0x1f1e959b), X(0x1f8e1e2f), X(0x1ffe3146), X(0x206ecd01), + X(0x20dfef78), X(0x215196c2), X(0x21c3c0f0), X(0x22366c10), + X(0x22a9962a), X(0x231d3d45), X(0x23915f60), X(0x2405fa7a), + X(0x247b0c8c), X(0x24f09389), X(0x25668d65), X(0x25dcf80c), + X(0x2653d167), X(0x26cb175e), X(0x2742c7d0), X(0x27bae09e), + X(0x28335fa2), X(0x28ac42b3), X(0x292587a5), X(0x299f2c48), + X(0x2a192e69), X(0x2a938bd1), X(0x2b0e4247), X(0x2b894f8d), + X(0x2c04b164), X(0x2c806588), X(0x2cfc69b2), X(0x2d78bb9a), + X(0x2df558f4), X(0x2e723f6f), X(0x2eef6cbb), X(0x2f6cde83), + X(0x2fea9270), X(0x30688627), X(0x30e6b74e), X(0x31652385), + X(0x31e3c86b), X(0x3262a39e), X(0x32e1b2b8), X(0x3360f352), + X(0x33e06303), X(0x345fff5e), X(0x34dfc5f8), X(0x355fb462), + X(0x35dfc82a), X(0x365ffee0), X(0x36e0560f), X(0x3760cb43), + X(0x37e15c05), X(0x386205df), X(0x38e2c657), X(0x39639af5), + X(0x39e4813e), X(0x3a6576b6), X(0x3ae678e3), X(0x3b678547), + X(0x3be89965), X(0x3c69b2c1), X(0x3ceacedc), X(0x3d6beb37), + X(0x3ded0557), X(0x3e6e1abb), X(0x3eef28e6), X(0x3f702d5a), + X(0x3ff1259a), X(0x40720f29), X(0x40f2e789), X(0x4173ac3f), + X(0x41f45ad0), X(0x4274f0c2), X(0x42f56b9a), X(0x4375c8e0), + X(0x43f6061d), X(0x447620db), X(0x44f616a5), X(0x4575e509), + X(0x45f58994), X(0x467501d6), X(0x46f44b62), X(0x477363cb), + X(0x47f248a6), X(0x4870f78e), X(0x48ef6e1a), X(0x496da9e8), + X(0x49eba897), X(0x4a6967c8), X(0x4ae6e521), X(0x4b641e47), + X(0x4be110e5), X(0x4c5dbaa7), X(0x4cda193f), X(0x4d562a5f), + X(0x4dd1ebbd), X(0x4e4d5b15), X(0x4ec87623), X(0x4f433aa9), + X(0x4fbda66c), X(0x5037b734), X(0x50b16acf), X(0x512abf0e), + X(0x51a3b1c5), X(0x521c40ce), X(0x52946a06), X(0x530c2b50), + X(0x53838292), X(0x53fa6db8), X(0x5470eab3), X(0x54e6f776), + X(0x555c91fc), X(0x55d1b844), X(0x56466851), X(0x56baa02f), + X(0x572e5deb), X(0x57a19f98), X(0x58146352), X(0x5886a737), + X(0x58f8696d), X(0x5969a81c), X(0x59da6177), X(0x5a4a93b4), + X(0x5aba3d0f), X(0x5b295bcb), X(0x5b97ee30), X(0x5c05f28d), + X(0x5c736738), X(0x5ce04a8d), X(0x5d4c9aed), X(0x5db856c1), + X(0x5e237c78), X(0x5e8e0a89), X(0x5ef7ff6f), X(0x5f6159b0), + X(0x5fca17d4), X(0x6032386e), X(0x6099ba15), X(0x61009b69), + X(0x6166db11), X(0x61cc77b9), X(0x62317017), X(0x6295c2e7), + X(0x62f96eec), X(0x635c72f1), X(0x63becdc8), X(0x64207e4b), + X(0x6481835a), X(0x64e1dbde), X(0x654186c8), X(0x65a0830e), + X(0x65fecfb1), X(0x665c6bb7), X(0x66b95630), X(0x67158e30), + X(0x677112d7), X(0x67cbe34b), X(0x6825feb9), X(0x687f6456), + X(0x68d81361), X(0x69300b1e), X(0x69874ada), X(0x69ddd1ea), + X(0x6a339fab), X(0x6a88b382), X(0x6add0cdb), X(0x6b30ab2a), + X(0x6b838dec), X(0x6bd5b4a6), X(0x6c271ee2), X(0x6c77cc36), + X(0x6cc7bc3d), X(0x6d16ee9b), X(0x6d6562fb), X(0x6db31911), + X(0x6e001099), X(0x6e4c4955), X(0x6e97c311), X(0x6ee27d9f), + X(0x6f2c78d9), X(0x6f75b4a2), X(0x6fbe30e4), X(0x7005ed91), + X(0x704ceaa1), X(0x70932816), X(0x70d8a5f8), X(0x711d6457), + X(0x7161634b), X(0x71a4a2f3), X(0x71e72375), X(0x7228e500), + X(0x7269e7c8), X(0x72aa2c0a), X(0x72e9b209), X(0x73287a12), + X(0x73668476), X(0x73a3d18f), X(0x73e061bc), X(0x741c3566), + X(0x74574cfa), X(0x7491a8ee), X(0x74cb49be), X(0x75042fec), + X(0x753c5c03), X(0x7573ce92), X(0x75aa882f), X(0x75e08979), + X(0x7615d313), X(0x764a65a7), X(0x767e41e5), X(0x76b16884), + X(0x76e3da40), X(0x771597dc), X(0x7746a221), X(0x7776f9dd), + X(0x77a69fe6), X(0x77d59514), X(0x7803da49), X(0x7831706a), + X(0x785e5861), X(0x788a9320), X(0x78b6219c), X(0x78e104cf), + X(0x790b3dbb), X(0x7934cd64), X(0x795db4d5), X(0x7985f51d), + X(0x79ad8f50), X(0x79d48486), X(0x79fad5de), X(0x7a208478), + X(0x7a45917b), X(0x7a69fe12), X(0x7a8dcb6c), X(0x7ab0fabb), + X(0x7ad38d36), X(0x7af5841a), X(0x7b16e0a3), X(0x7b37a416), + X(0x7b57cfb8), X(0x7b7764d4), X(0x7b9664b6), X(0x7bb4d0b0), + X(0x7bd2aa14), X(0x7beff23b), X(0x7c0caa7f), X(0x7c28d43c), + X(0x7c4470d2), X(0x7c5f81a5), X(0x7c7a081a), X(0x7c940598), + X(0x7cad7b8b), X(0x7cc66b5e), X(0x7cded680), X(0x7cf6be64), + X(0x7d0e247b), X(0x7d250a3c), X(0x7d3b711c), X(0x7d515a95), + X(0x7d66c822), X(0x7d7bbb3c), X(0x7d903563), X(0x7da43814), + X(0x7db7c4d0), X(0x7dcadd16), X(0x7ddd826a), X(0x7defb64d), + X(0x7e017a44), X(0x7e12cfd3), X(0x7e23b87f), X(0x7e3435cc), + X(0x7e444943), X(0x7e53f467), X(0x7e6338c0), X(0x7e7217d5), + X(0x7e80932b), X(0x7e8eac49), X(0x7e9c64b7), X(0x7ea9bdf8), + X(0x7eb6b994), X(0x7ec35910), X(0x7ecf9def), X(0x7edb89b6), + X(0x7ee71de9), X(0x7ef25c09), X(0x7efd4598), X(0x7f07dc16), + X(0x7f122103), X(0x7f1c15dc), X(0x7f25bc1f), X(0x7f2f1547), + X(0x7f3822cd), X(0x7f40e62b), X(0x7f4960d6), X(0x7f519443), + X(0x7f5981e7), X(0x7f612b31), X(0x7f689191), X(0x7f6fb674), + X(0x7f769b45), X(0x7f7d416c), X(0x7f83aa51), X(0x7f89d757), + X(0x7f8fc9df), X(0x7f958348), X(0x7f9b04ef), X(0x7fa0502e), + X(0x7fa56659), X(0x7faa48c7), X(0x7faef8c7), X(0x7fb377a7), + X(0x7fb7c6b3), X(0x7fbbe732), X(0x7fbfda67), X(0x7fc3a196), + X(0x7fc73dfa), X(0x7fcab0ce), X(0x7fcdfb4a), X(0x7fd11ea0), + X(0x7fd41c00), X(0x7fd6f496), X(0x7fd9a989), X(0x7fdc3bff), + X(0x7fdead17), X(0x7fe0fdee), X(0x7fe32f9d), X(0x7fe54337), + X(0x7fe739ce), X(0x7fe9146c), X(0x7fead41b), X(0x7fec79dd), + X(0x7fee06b2), X(0x7fef7b94), X(0x7ff0d97b), X(0x7ff22158), + X(0x7ff35417), X(0x7ff472a3), X(0x7ff57de0), X(0x7ff676ac), + X(0x7ff75de3), X(0x7ff8345a), X(0x7ff8fae4), X(0x7ff9b24b), + X(0x7ffa5b58), X(0x7ffaf6cd), X(0x7ffb8568), X(0x7ffc07e2), + X(0x7ffc7eed), X(0x7ffceb38), X(0x7ffd4d6d), X(0x7ffda631), + X(0x7ffdf621), X(0x7ffe3dd8), X(0x7ffe7dea), X(0x7ffeb6e7), + X(0x7ffee959), X(0x7fff15c4), X(0x7fff3ca9), X(0x7fff5e80), + X(0x7fff7bc0), X(0x7fff94d6), X(0x7fffaa2d), X(0x7fffbc29), + X(0x7fffcb29), X(0x7fffd786), X(0x7fffe195), X(0x7fffe9a3), + X(0x7fffeffa), X(0x7ffff4dd), X(0x7ffff889), X(0x7ffffb37), + X(0x7ffffd1a), X(0x7ffffe5d), X(0x7fffff29), X(0x7fffffa0), + X(0x7fffffdd), X(0x7ffffff7), X(0x7fffffff), X(0x7fffffff), +}; + +static LOOKUP_T vwin2048[1024] = { + X(0x000007c0), X(0x000045c4), X(0x0000c1ca), X(0x00017bd3), + X(0x000273de), X(0x0003a9eb), X(0x00051df9), X(0x0006d007), + X(0x0008c014), X(0x000aee1e), X(0x000d5a25), X(0x00100428), + X(0x0012ec23), X(0x00161216), X(0x001975fe), X(0x001d17da), + X(0x0020f7a8), X(0x00251564), X(0x0029710c), X(0x002e0a9e), + X(0x0032e217), X(0x0037f773), X(0x003d4ab0), X(0x0042dbca), + X(0x0048aabe), X(0x004eb788), X(0x00550224), X(0x005b8a8f), + X(0x006250c5), X(0x006954c1), X(0x0070967e), X(0x007815f9), + X(0x007fd32c), X(0x0087ce13), X(0x009006a9), X(0x00987ce9), + X(0x00a130cc), X(0x00aa224f), X(0x00b3516b), X(0x00bcbe1a), + X(0x00c66856), X(0x00d0501a), X(0x00da755f), X(0x00e4d81f), + X(0x00ef7853), X(0x00fa55f4), X(0x010570fc), X(0x0110c963), + X(0x011c5f22), X(0x01283232), X(0x0134428c), X(0x01409027), + X(0x014d1afb), X(0x0159e302), X(0x0166e831), X(0x01742a82), + X(0x0181a9ec), X(0x018f6665), X(0x019d5fe5), X(0x01ab9663), + X(0x01ba09d6), X(0x01c8ba34), X(0x01d7a775), X(0x01e6d18d), + X(0x01f63873), X(0x0205dc1e), X(0x0215bc82), X(0x0225d997), + X(0x02363350), X(0x0246c9a3), X(0x02579c86), X(0x0268abed), + X(0x0279f7cc), X(0x028b801a), X(0x029d44c9), X(0x02af45ce), + X(0x02c1831d), X(0x02d3fcaa), X(0x02e6b269), X(0x02f9a44c), + X(0x030cd248), X(0x03203c4f), X(0x0333e255), X(0x0347c44b), + X(0x035be225), X(0x03703bd5), X(0x0384d14d), X(0x0399a280), + X(0x03aeaf5e), X(0x03c3f7d9), X(0x03d97be4), X(0x03ef3b6e), + X(0x0405366a), X(0x041b6cc8), X(0x0431de78), X(0x04488b6c), + X(0x045f7393), X(0x047696dd), X(0x048df53b), X(0x04a58e9b), + X(0x04bd62ee), X(0x04d57223), X(0x04edbc28), X(0x050640ed), + X(0x051f0060), X(0x0537fa70), X(0x05512f0a), X(0x056a9e1e), + X(0x05844798), X(0x059e2b67), X(0x05b84978), X(0x05d2a1b8), + X(0x05ed3414), X(0x06080079), X(0x062306d3), X(0x063e470f), + X(0x0659c119), X(0x067574dd), X(0x06916247), X(0x06ad8941), + X(0x06c9e9b8), X(0x06e68397), X(0x070356c8), X(0x07206336), + X(0x073da8cb), X(0x075b2772), X(0x0778df15), X(0x0796cf9c), + X(0x07b4f8f3), X(0x07d35b01), X(0x07f1f5b1), X(0x0810c8eb), + X(0x082fd497), X(0x084f189e), X(0x086e94e9), X(0x088e495e), + X(0x08ae35e6), X(0x08ce5a68), X(0x08eeb6cc), X(0x090f4af8), + X(0x093016d3), X(0x09511a44), X(0x09725530), X(0x0993c77f), + X(0x09b57115), X(0x09d751d8), X(0x09f969ae), X(0x0a1bb87c), + X(0x0a3e3e26), X(0x0a60fa91), X(0x0a83eda2), X(0x0aa7173c), + X(0x0aca7743), X(0x0aee0d9b), X(0x0b11da28), X(0x0b35dccc), + X(0x0b5a156a), X(0x0b7e83e5), X(0x0ba3281f), X(0x0bc801fa), + X(0x0bed1159), X(0x0c12561c), X(0x0c37d025), X(0x0c5d7f55), + X(0x0c83638d), X(0x0ca97cae), X(0x0ccfca97), X(0x0cf64d2a), + X(0x0d1d0444), X(0x0d43efc7), X(0x0d6b0f92), X(0x0d926383), + X(0x0db9eb79), X(0x0de1a752), X(0x0e0996ee), X(0x0e31ba29), + X(0x0e5a10e2), X(0x0e829af6), X(0x0eab5841), X(0x0ed448a2), + X(0x0efd6bf4), X(0x0f26c214), X(0x0f504ade), X(0x0f7a062e), + X(0x0fa3f3df), X(0x0fce13cd), X(0x0ff865d2), X(0x1022e9ca), + X(0x104d9f8e), X(0x107886f9), X(0x10a39fe5), X(0x10ceea2c), + X(0x10fa65a6), X(0x1126122d), X(0x1151ef9a), X(0x117dfdc5), + X(0x11aa3c87), X(0x11d6abb6), X(0x12034b2c), X(0x12301ac0), + X(0x125d1a48), X(0x128a499b), X(0x12b7a891), X(0x12e536ff), + X(0x1312f4bb), X(0x1340e19c), X(0x136efd75), X(0x139d481e), + X(0x13cbc16a), X(0x13fa692f), X(0x14293f40), X(0x14584371), + X(0x14877597), X(0x14b6d585), X(0x14e6630d), X(0x15161e04), + X(0x1546063b), X(0x15761b85), X(0x15a65db3), X(0x15d6cc99), + X(0x16076806), X(0x16382fcd), X(0x166923bf), X(0x169a43ab), + X(0x16cb8f62), X(0x16fd06b5), X(0x172ea973), X(0x1760776b), + X(0x1792706e), X(0x17c49449), X(0x17f6e2cb), X(0x18295bc3), + X(0x185bfeff), X(0x188ecc4c), X(0x18c1c379), X(0x18f4e452), + X(0x19282ea4), X(0x195ba23c), X(0x198f3ee6), X(0x19c3046e), + X(0x19f6f2a1), X(0x1a2b094a), X(0x1a5f4833), X(0x1a93af28), + X(0x1ac83df3), X(0x1afcf460), X(0x1b31d237), X(0x1b66d744), + X(0x1b9c034e), X(0x1bd15621), X(0x1c06cf84), X(0x1c3c6f40), + X(0x1c72351e), X(0x1ca820e6), X(0x1cde3260), X(0x1d146953), + X(0x1d4ac587), X(0x1d8146c3), X(0x1db7eccd), X(0x1deeb76c), + X(0x1e25a667), X(0x1e5cb982), X(0x1e93f085), X(0x1ecb4b33), + X(0x1f02c953), X(0x1f3a6aaa), X(0x1f722efb), X(0x1faa160b), + X(0x1fe21f9e), X(0x201a4b79), X(0x2052995d), X(0x208b0910), + X(0x20c39a53), X(0x20fc4cea), X(0x21352097), X(0x216e151c), + X(0x21a72a3a), X(0x21e05fb5), X(0x2219b54d), X(0x22532ac3), + X(0x228cbfd8), X(0x22c6744d), X(0x230047e2), X(0x233a3a58), + X(0x23744b6d), X(0x23ae7ae3), X(0x23e8c878), X(0x242333ec), + X(0x245dbcfd), X(0x24986369), X(0x24d326f1), X(0x250e0750), + X(0x25490446), X(0x25841d90), X(0x25bf52ec), X(0x25faa417), + X(0x263610cd), X(0x267198cc), X(0x26ad3bcf), X(0x26e8f994), + X(0x2724d1d6), X(0x2760c451), X(0x279cd0c0), X(0x27d8f6e0), + X(0x2815366a), X(0x28518f1b), X(0x288e00ac), X(0x28ca8ad8), + X(0x29072d5a), X(0x2943e7eb), X(0x2980ba45), X(0x29bda422), + X(0x29faa53c), X(0x2a37bd4a), X(0x2a74ec07), X(0x2ab2312b), + X(0x2aef8c6f), X(0x2b2cfd8b), X(0x2b6a8437), X(0x2ba8202c), + X(0x2be5d120), X(0x2c2396cc), X(0x2c6170e7), X(0x2c9f5f29), + X(0x2cdd6147), X(0x2d1b76fa), X(0x2d599ff7), X(0x2d97dbf5), + X(0x2dd62aab), X(0x2e148bcf), X(0x2e52ff16), X(0x2e918436), + X(0x2ed01ae5), X(0x2f0ec2d9), X(0x2f4d7bc6), X(0x2f8c4562), + X(0x2fcb1f62), X(0x300a097a), X(0x3049035f), X(0x30880cc6), + X(0x30c72563), X(0x31064cea), X(0x3145830f), X(0x3184c786), + X(0x31c41a03), X(0x32037a39), X(0x3242e7dc), X(0x3282629f), + X(0x32c1ea36), X(0x33017e53), X(0x33411ea9), X(0x3380caec), + X(0x33c082ce), X(0x34004602), X(0x34401439), X(0x347fed27), + X(0x34bfd07e), X(0x34ffbdf0), X(0x353fb52e), X(0x357fb5ec), + X(0x35bfbfda), X(0x35ffd2aa), X(0x363fee0f), X(0x368011b9), + X(0x36c03d5a), X(0x370070a4), X(0x3740ab48), X(0x3780ecf7), + X(0x37c13562), X(0x3801843a), X(0x3841d931), X(0x388233f7), + X(0x38c2943d), X(0x3902f9b4), X(0x3943640d), X(0x3983d2f8), + X(0x39c44626), X(0x3a04bd48), X(0x3a45380e), X(0x3a85b62a), + X(0x3ac6374a), X(0x3b06bb20), X(0x3b47415c), X(0x3b87c9ae), + X(0x3bc853c7), X(0x3c08df57), X(0x3c496c0f), X(0x3c89f99f), + X(0x3cca87b6), X(0x3d0b1605), X(0x3d4ba43d), X(0x3d8c320e), + X(0x3dccbf27), X(0x3e0d4b3a), X(0x3e4dd5f6), X(0x3e8e5f0c), + X(0x3ecee62b), X(0x3f0f6b05), X(0x3f4fed49), X(0x3f906ca8), + X(0x3fd0e8d2), X(0x40116177), X(0x4051d648), X(0x409246f6), + X(0x40d2b330), X(0x41131aa7), X(0x41537d0c), X(0x4193da10), + X(0x41d43162), X(0x421482b4), X(0x4254cdb7), X(0x4295121b), + X(0x42d54f91), X(0x431585ca), X(0x4355b477), X(0x4395db49), + X(0x43d5f9f1), X(0x44161021), X(0x44561d8a), X(0x449621dd), + X(0x44d61ccc), X(0x45160e08), X(0x4555f544), X(0x4595d230), + X(0x45d5a47f), X(0x46156be3), X(0x4655280e), X(0x4694d8b2), + X(0x46d47d82), X(0x4714162f), X(0x4753a26d), X(0x479321ef), + X(0x47d29466), X(0x4811f987), X(0x48515104), X(0x48909a91), + X(0x48cfd5e1), X(0x490f02a7), X(0x494e2098), X(0x498d2f66), + X(0x49cc2ec7), X(0x4a0b1e6f), X(0x4a49fe11), X(0x4a88cd62), + X(0x4ac78c18), X(0x4b0639e6), X(0x4b44d683), X(0x4b8361a2), + X(0x4bc1dafa), X(0x4c004241), X(0x4c3e972c), X(0x4c7cd970), + X(0x4cbb08c5), X(0x4cf924e1), X(0x4d372d7a), X(0x4d752247), + X(0x4db30300), X(0x4df0cf5a), X(0x4e2e870f), X(0x4e6c29d6), + X(0x4ea9b766), X(0x4ee72f78), X(0x4f2491c4), X(0x4f61de02), + X(0x4f9f13ec), X(0x4fdc333b), X(0x50193ba8), X(0x50562ced), + X(0x509306c3), X(0x50cfc8e5), X(0x510c730d), X(0x514904f6), + X(0x51857e5a), X(0x51c1def5), X(0x51fe2682), X(0x523a54bc), + X(0x52766961), X(0x52b2642c), X(0x52ee44d9), X(0x532a0b26), + X(0x5365b6d0), X(0x53a14793), X(0x53dcbd2f), X(0x54181760), + X(0x545355e5), X(0x548e787d), X(0x54c97ee6), X(0x550468e1), + X(0x553f362c), X(0x5579e687), X(0x55b479b3), X(0x55eeef70), + X(0x5629477f), X(0x566381a1), X(0x569d9d97), X(0x56d79b24), + X(0x57117a0a), X(0x574b3a0a), X(0x5784dae9), X(0x57be5c69), + X(0x57f7be4d), X(0x5831005a), X(0x586a2254), X(0x58a32400), + X(0x58dc0522), X(0x5914c57f), X(0x594d64de), X(0x5985e305), + X(0x59be3fba), X(0x59f67ac3), X(0x5a2e93e9), X(0x5a668af2), + X(0x5a9e5fa6), X(0x5ad611ce), X(0x5b0da133), X(0x5b450d9d), + X(0x5b7c56d7), X(0x5bb37ca9), X(0x5bea7ede), X(0x5c215d41), + X(0x5c58179d), X(0x5c8eadbe), X(0x5cc51f6f), X(0x5cfb6c7c), + X(0x5d3194b2), X(0x5d6797de), X(0x5d9d75cf), X(0x5dd32e51), + X(0x5e08c132), X(0x5e3e2e43), X(0x5e737551), X(0x5ea8962d), + X(0x5edd90a7), X(0x5f12648e), X(0x5f4711b4), X(0x5f7b97ea), + X(0x5faff702), X(0x5fe42ece), X(0x60183f20), X(0x604c27cc), + X(0x607fe8a6), X(0x60b38180), X(0x60e6f22f), X(0x611a3a89), + X(0x614d5a62), X(0x61805190), X(0x61b31fe9), X(0x61e5c545), + X(0x62184179), X(0x624a945d), X(0x627cbdca), X(0x62aebd98), + X(0x62e0939f), X(0x63123fba), X(0x6343c1c1), X(0x6375198f), + X(0x63a646ff), X(0x63d749ec), X(0x64082232), X(0x6438cfad), + X(0x64695238), X(0x6499a9b3), X(0x64c9d5f9), X(0x64f9d6ea), + X(0x6529ac63), X(0x65595643), X(0x6588d46a), X(0x65b826b8), + X(0x65e74d0e), X(0x6616474b), X(0x66451552), X(0x6673b704), + X(0x66a22c44), X(0x66d074f4), X(0x66fe90f8), X(0x672c8033), + X(0x675a428a), X(0x6787d7e1), X(0x67b5401f), X(0x67e27b27), + X(0x680f88e1), X(0x683c6934), X(0x68691c05), X(0x6895a13e), + X(0x68c1f8c7), X(0x68ee2287), X(0x691a1e68), X(0x6945ec54), + X(0x69718c35), X(0x699cfdf5), X(0x69c8417f), X(0x69f356c0), + X(0x6a1e3da3), X(0x6a48f615), X(0x6a738002), X(0x6a9ddb5a), + X(0x6ac80808), X(0x6af205fd), X(0x6b1bd526), X(0x6b457575), + X(0x6b6ee6d8), X(0x6b982940), X(0x6bc13c9f), X(0x6bea20e5), + X(0x6c12d605), X(0x6c3b5bf1), X(0x6c63b29c), X(0x6c8bd9fb), + X(0x6cb3d200), X(0x6cdb9aa0), X(0x6d0333d0), X(0x6d2a9d86), + X(0x6d51d7b7), X(0x6d78e25a), X(0x6d9fbd67), X(0x6dc668d3), + X(0x6dece498), X(0x6e1330ad), X(0x6e394d0c), X(0x6e5f39ae), + X(0x6e84f68d), X(0x6eaa83a2), X(0x6ecfe0ea), X(0x6ef50e5e), + X(0x6f1a0bfc), X(0x6f3ed9bf), X(0x6f6377a4), X(0x6f87e5a8), + X(0x6fac23c9), X(0x6fd03206), X(0x6ff4105c), X(0x7017becc), + X(0x703b3d54), X(0x705e8bf5), X(0x7081aaaf), X(0x70a49984), + X(0x70c75874), X(0x70e9e783), X(0x710c46b2), X(0x712e7605), + X(0x7150757f), X(0x71724523), X(0x7193e4f6), X(0x71b554fd), + X(0x71d6953e), X(0x71f7a5bd), X(0x72188681), X(0x72393792), + X(0x7259b8f5), X(0x727a0ab2), X(0x729a2cd2), X(0x72ba1f5d), + X(0x72d9e25c), X(0x72f975d8), X(0x7318d9db), X(0x73380e6f), + X(0x735713a0), X(0x7375e978), X(0x73949003), X(0x73b3074c), + X(0x73d14f61), X(0x73ef684f), X(0x740d5222), X(0x742b0ce9), + X(0x744898b1), X(0x7465f589), X(0x74832381), X(0x74a022a8), + X(0x74bcf30e), X(0x74d994c3), X(0x74f607d8), X(0x75124c5f), + X(0x752e6268), X(0x754a4a05), X(0x7566034b), X(0x75818e4a), + X(0x759ceb16), X(0x75b819c4), X(0x75d31a66), X(0x75eded12), + X(0x760891dc), X(0x762308da), X(0x763d5221), X(0x76576dc8), + X(0x76715be4), X(0x768b1c8c), X(0x76a4afd9), X(0x76be15e0), + X(0x76d74ebb), X(0x76f05a82), X(0x7709394d), X(0x7721eb35), + X(0x773a7054), X(0x7752c8c4), X(0x776af49f), X(0x7782f400), + X(0x779ac701), X(0x77b26dbd), X(0x77c9e851), X(0x77e136d8), + X(0x77f8596f), X(0x780f5032), X(0x78261b3f), X(0x783cbab2), + X(0x78532eaa), X(0x78697745), X(0x787f94a0), X(0x789586db), + X(0x78ab4e15), X(0x78c0ea6d), X(0x78d65c03), X(0x78eba2f7), + X(0x7900bf68), X(0x7915b179), X(0x792a7949), X(0x793f16fb), + X(0x79538aaf), X(0x7967d488), X(0x797bf4a8), X(0x798feb31), + X(0x79a3b846), X(0x79b75c0a), X(0x79cad6a1), X(0x79de282e), + X(0x79f150d5), X(0x7a0450bb), X(0x7a172803), X(0x7a29d6d3), + X(0x7a3c5d50), X(0x7a4ebb9f), X(0x7a60f1e6), X(0x7a73004a), + X(0x7a84e6f2), X(0x7a96a604), X(0x7aa83da7), X(0x7ab9ae01), + X(0x7acaf73a), X(0x7adc1979), X(0x7aed14e6), X(0x7afde9a8), + X(0x7b0e97e8), X(0x7b1f1fcd), X(0x7b2f8182), X(0x7b3fbd2d), + X(0x7b4fd2f9), X(0x7b5fc30f), X(0x7b6f8d98), X(0x7b7f32bd), + X(0x7b8eb2a9), X(0x7b9e0d85), X(0x7bad437d), X(0x7bbc54b9), + X(0x7bcb4166), X(0x7bda09ae), X(0x7be8adbc), X(0x7bf72dbc), + X(0x7c0589d8), X(0x7c13c23d), X(0x7c21d716), X(0x7c2fc88f), + X(0x7c3d96d5), X(0x7c4b4214), X(0x7c58ca78), X(0x7c66302d), + X(0x7c737362), X(0x7c809443), X(0x7c8d92fc), X(0x7c9a6fbc), + X(0x7ca72aaf), X(0x7cb3c404), X(0x7cc03be8), X(0x7ccc9288), + X(0x7cd8c814), X(0x7ce4dcb9), X(0x7cf0d0a5), X(0x7cfca406), + X(0x7d08570c), X(0x7d13e9e5), X(0x7d1f5cbf), X(0x7d2aafca), + X(0x7d35e335), X(0x7d40f72e), X(0x7d4bebe4), X(0x7d56c188), + X(0x7d617848), X(0x7d6c1054), X(0x7d7689db), X(0x7d80e50e), + X(0x7d8b221b), X(0x7d954133), X(0x7d9f4286), X(0x7da92643), + X(0x7db2ec9b), X(0x7dbc95bd), X(0x7dc621da), X(0x7dcf9123), + X(0x7dd8e3c6), X(0x7de219f6), X(0x7deb33e2), X(0x7df431ba), + X(0x7dfd13af), X(0x7e05d9f2), X(0x7e0e84b4), X(0x7e171424), + X(0x7e1f8874), X(0x7e27e1d4), X(0x7e302074), X(0x7e384487), + X(0x7e404e3c), X(0x7e483dc4), X(0x7e501350), X(0x7e57cf11), + X(0x7e5f7138), X(0x7e66f9f4), X(0x7e6e6979), X(0x7e75bff5), + X(0x7e7cfd9a), X(0x7e842298), X(0x7e8b2f22), X(0x7e922366), + X(0x7e98ff97), X(0x7e9fc3e4), X(0x7ea6707f), X(0x7ead0598), + X(0x7eb38360), X(0x7eb9ea07), X(0x7ec039bf), X(0x7ec672b7), + X(0x7ecc9521), X(0x7ed2a12c), X(0x7ed8970a), X(0x7ede76ea), + X(0x7ee440fd), X(0x7ee9f573), X(0x7eef947d), X(0x7ef51e4b), + X(0x7efa930d), X(0x7efff2f2), X(0x7f053e2b), X(0x7f0a74e8), + X(0x7f0f9758), X(0x7f14a5ac), X(0x7f19a013), X(0x7f1e86bc), + X(0x7f2359d8), X(0x7f281995), X(0x7f2cc623), X(0x7f315fb1), + X(0x7f35e66e), X(0x7f3a5a8a), X(0x7f3ebc33), X(0x7f430b98), + X(0x7f4748e7), X(0x7f4b7450), X(0x7f4f8e01), X(0x7f539629), + X(0x7f578cf5), X(0x7f5b7293), X(0x7f5f4732), X(0x7f630b00), + X(0x7f66be2b), X(0x7f6a60df), X(0x7f6df34b), X(0x7f71759b), + X(0x7f74e7fe), X(0x7f784aa0), X(0x7f7b9daf), X(0x7f7ee156), + X(0x7f8215c3), X(0x7f853b22), X(0x7f88519f), X(0x7f8b5967), + X(0x7f8e52a6), X(0x7f913d87), X(0x7f941a36), X(0x7f96e8df), + X(0x7f99a9ad), X(0x7f9c5ccb), X(0x7f9f0265), X(0x7fa19aa5), + X(0x7fa425b5), X(0x7fa6a3c1), X(0x7fa914f3), X(0x7fab7974), + X(0x7fadd16f), X(0x7fb01d0d), X(0x7fb25c78), X(0x7fb48fd9), + X(0x7fb6b75a), X(0x7fb8d323), X(0x7fbae35d), X(0x7fbce831), + X(0x7fbee1c7), X(0x7fc0d047), X(0x7fc2b3d9), X(0x7fc48ca5), + X(0x7fc65ad3), X(0x7fc81e88), X(0x7fc9d7ee), X(0x7fcb872a), + X(0x7fcd2c63), X(0x7fcec7bf), X(0x7fd05966), X(0x7fd1e17c), + X(0x7fd36027), X(0x7fd4d58d), X(0x7fd641d3), X(0x7fd7a51e), + X(0x7fd8ff94), X(0x7fda5157), X(0x7fdb9a8e), X(0x7fdcdb5b), + X(0x7fde13e2), X(0x7fdf4448), X(0x7fe06caf), X(0x7fe18d3b), + X(0x7fe2a60e), X(0x7fe3b74b), X(0x7fe4c114), X(0x7fe5c38b), + X(0x7fe6bed2), X(0x7fe7b30a), X(0x7fe8a055), X(0x7fe986d4), + X(0x7fea66a7), X(0x7feb3ff0), X(0x7fec12cd), X(0x7fecdf5f), + X(0x7feda5c5), X(0x7fee6620), X(0x7fef208d), X(0x7fefd52c), + X(0x7ff0841c), X(0x7ff12d7a), X(0x7ff1d164), X(0x7ff26ff9), + X(0x7ff30955), X(0x7ff39d96), X(0x7ff42cd9), X(0x7ff4b739), + X(0x7ff53cd4), X(0x7ff5bdc5), X(0x7ff63a28), X(0x7ff6b217), + X(0x7ff725af), X(0x7ff7950a), X(0x7ff80043), X(0x7ff86773), + X(0x7ff8cab4), X(0x7ff92a21), X(0x7ff985d1), X(0x7ff9dddf), + X(0x7ffa3262), X(0x7ffa8374), X(0x7ffad12c), X(0x7ffb1ba1), + X(0x7ffb62ec), X(0x7ffba723), X(0x7ffbe85c), X(0x7ffc26b0), + X(0x7ffc6233), X(0x7ffc9afb), X(0x7ffcd11e), X(0x7ffd04b1), + X(0x7ffd35c9), X(0x7ffd647b), X(0x7ffd90da), X(0x7ffdbafa), + X(0x7ffde2f0), X(0x7ffe08ce), X(0x7ffe2ca7), X(0x7ffe4e8e), + X(0x7ffe6e95), X(0x7ffe8cce), X(0x7ffea94a), X(0x7ffec41b), + X(0x7ffedd52), X(0x7ffef4ff), X(0x7fff0b33), X(0x7fff1ffd), + X(0x7fff336e), X(0x7fff4593), X(0x7fff567d), X(0x7fff663a), + X(0x7fff74d8), X(0x7fff8265), X(0x7fff8eee), X(0x7fff9a81), + X(0x7fffa52b), X(0x7fffaef8), X(0x7fffb7f5), X(0x7fffc02d), + X(0x7fffc7ab), X(0x7fffce7c), X(0x7fffd4a9), X(0x7fffda3e), + X(0x7fffdf44), X(0x7fffe3c6), X(0x7fffe7cc), X(0x7fffeb60), + X(0x7fffee8a), X(0x7ffff153), X(0x7ffff3c4), X(0x7ffff5e3), + X(0x7ffff7b8), X(0x7ffff94b), X(0x7ffffaa1), X(0x7ffffbc1), + X(0x7ffffcb2), X(0x7ffffd78), X(0x7ffffe19), X(0x7ffffe9a), + X(0x7ffffeff), X(0x7fffff4e), X(0x7fffff89), X(0x7fffffb3), + X(0x7fffffd2), X(0x7fffffe6), X(0x7ffffff3), X(0x7ffffffa), + X(0x7ffffffe), X(0x7fffffff), X(0x7fffffff), X(0x7fffffff), +}; + +static LOOKUP_T vwin4096[2048] = { + X(0x000001f0), X(0x00001171), X(0x00003072), X(0x00005ef5), + X(0x00009cf8), X(0x0000ea7c), X(0x00014780), X(0x0001b405), + X(0x0002300b), X(0x0002bb91), X(0x00035698), X(0x0004011e), + X(0x0004bb25), X(0x000584ac), X(0x00065db3), X(0x0007463a), + X(0x00083e41), X(0x000945c7), X(0x000a5ccc), X(0x000b8350), + X(0x000cb954), X(0x000dfed7), X(0x000f53d8), X(0x0010b857), + X(0x00122c55), X(0x0013afd1), X(0x001542ca), X(0x0016e541), + X(0x00189735), X(0x001a58a7), X(0x001c2995), X(0x001e09ff), + X(0x001ff9e6), X(0x0021f948), X(0x00240826), X(0x00262680), + X(0x00285454), X(0x002a91a3), X(0x002cde6c), X(0x002f3aaf), + X(0x0031a66b), X(0x003421a0), X(0x0036ac4f), X(0x00394675), + X(0x003bf014), X(0x003ea92a), X(0x004171b7), X(0x004449bb), + X(0x00473135), X(0x004a2824), X(0x004d2e8a), X(0x00504463), + X(0x005369b2), X(0x00569e74), X(0x0059e2aa), X(0x005d3652), + X(0x0060996d), X(0x00640bf9), X(0x00678df7), X(0x006b1f66), + X(0x006ec045), X(0x00727093), X(0x00763051), X(0x0079ff7d), + X(0x007dde16), X(0x0081cc1d), X(0x0085c991), X(0x0089d671), + X(0x008df2bc), X(0x00921e71), X(0x00965991), X(0x009aa41a), + X(0x009efe0c), X(0x00a36766), X(0x00a7e028), X(0x00ac6850), + X(0x00b0ffde), X(0x00b5a6d1), X(0x00ba5d28), X(0x00bf22e4), + X(0x00c3f802), X(0x00c8dc83), X(0x00cdd065), X(0x00d2d3a8), + X(0x00d7e64a), X(0x00dd084c), X(0x00e239ac), X(0x00e77a69), + X(0x00ecca83), X(0x00f229f9), X(0x00f798ca), X(0x00fd16f5), + X(0x0102a479), X(0x01084155), X(0x010ded89), X(0x0113a913), + X(0x011973f3), X(0x011f4e27), X(0x012537af), X(0x012b308a), + X(0x013138b7), X(0x01375035), X(0x013d7702), X(0x0143ad1f), + X(0x0149f289), X(0x01504741), X(0x0156ab44), X(0x015d1e92), + X(0x0163a12a), X(0x016a330b), X(0x0170d433), X(0x017784a3), + X(0x017e4458), X(0x01851351), X(0x018bf18e), X(0x0192df0d), + X(0x0199dbcd), X(0x01a0e7cd), X(0x01a8030c), X(0x01af2d89), + X(0x01b66743), X(0x01bdb038), X(0x01c50867), X(0x01cc6fd0), + X(0x01d3e670), X(0x01db6c47), X(0x01e30153), X(0x01eaa593), + X(0x01f25907), X(0x01fa1bac), X(0x0201ed81), X(0x0209ce86), + X(0x0211beb8), X(0x0219be17), X(0x0221cca2), X(0x0229ea56), + X(0x02321733), X(0x023a5337), X(0x02429e60), X(0x024af8af), + X(0x02536220), X(0x025bdab3), X(0x02646267), X(0x026cf93a), + X(0x02759f2a), X(0x027e5436), X(0x0287185d), X(0x028feb9d), + X(0x0298cdf4), X(0x02a1bf62), X(0x02aabfe5), X(0x02b3cf7b), + X(0x02bcee23), X(0x02c61bdb), X(0x02cf58a2), X(0x02d8a475), + X(0x02e1ff55), X(0x02eb693e), X(0x02f4e230), X(0x02fe6a29), + X(0x03080127), X(0x0311a729), X(0x031b5c2d), X(0x03252031), + X(0x032ef334), X(0x0338d534), X(0x0342c630), X(0x034cc625), + X(0x0356d512), X(0x0360f2f6), X(0x036b1fce), X(0x03755b99), + X(0x037fa655), X(0x038a0001), X(0x0394689a), X(0x039ee020), + X(0x03a9668f), X(0x03b3fbe6), X(0x03bea024), X(0x03c95347), + X(0x03d4154d), X(0x03dee633), X(0x03e9c5f9), X(0x03f4b49b), + X(0x03ffb219), X(0x040abe71), X(0x0415d9a0), X(0x042103a5), + X(0x042c3c7d), X(0x04378428), X(0x0442daa2), X(0x044e3fea), + X(0x0459b3fd), X(0x046536db), X(0x0470c880), X(0x047c68eb), + X(0x0488181a), X(0x0493d60b), X(0x049fa2bc), X(0x04ab7e2a), + X(0x04b76854), X(0x04c36137), X(0x04cf68d1), X(0x04db7f21), + X(0x04e7a424), X(0x04f3d7d8), X(0x05001a3b), X(0x050c6b4a), + X(0x0518cb04), X(0x05253966), X(0x0531b66e), X(0x053e421a), + X(0x054adc68), X(0x05578555), X(0x05643cdf), X(0x05710304), + X(0x057dd7c1), X(0x058abb15), X(0x0597acfd), X(0x05a4ad76), + X(0x05b1bc7f), X(0x05beda14), X(0x05cc0635), X(0x05d940dd), + X(0x05e68a0b), X(0x05f3e1bd), X(0x060147f0), X(0x060ebca1), + X(0x061c3fcf), X(0x0629d176), X(0x06377194), X(0x06452027), + X(0x0652dd2c), X(0x0660a8a2), X(0x066e8284), X(0x067c6ad1), + X(0x068a6186), X(0x069866a1), X(0x06a67a1e), X(0x06b49bfc), + X(0x06c2cc38), X(0x06d10acf), X(0x06df57bf), X(0x06edb304), + X(0x06fc1c9d), X(0x070a9487), X(0x07191abe), X(0x0727af40), + X(0x0736520b), X(0x0745031c), X(0x0753c270), X(0x07629004), + X(0x07716bd6), X(0x078055e2), X(0x078f4e26), X(0x079e549f), + X(0x07ad694b), X(0x07bc8c26), X(0x07cbbd2e), X(0x07dafc5f), + X(0x07ea49b7), X(0x07f9a533), X(0x08090ed1), X(0x0818868c), + X(0x08280c62), X(0x0837a051), X(0x08474255), X(0x0856f26b), + X(0x0866b091), X(0x08767cc3), X(0x088656fe), X(0x08963f3f), + X(0x08a63584), X(0x08b639c8), X(0x08c64c0a), X(0x08d66c45), + X(0x08e69a77), X(0x08f6d69d), X(0x090720b3), X(0x091778b7), + X(0x0927dea5), X(0x0938527a), X(0x0948d433), X(0x095963cc), + X(0x096a0143), X(0x097aac94), X(0x098b65bb), X(0x099c2cb6), + X(0x09ad0182), X(0x09bde41a), X(0x09ced47d), X(0x09dfd2a5), + X(0x09f0de90), X(0x0a01f83b), X(0x0a131fa3), X(0x0a2454c3), + X(0x0a359798), X(0x0a46e820), X(0x0a584656), X(0x0a69b237), + X(0x0a7b2bc0), X(0x0a8cb2ec), X(0x0a9e47ba), X(0x0aafea24), + X(0x0ac19a29), X(0x0ad357c3), X(0x0ae522ef), X(0x0af6fbab), + X(0x0b08e1f1), X(0x0b1ad5c0), X(0x0b2cd712), X(0x0b3ee5e5), + X(0x0b510234), X(0x0b632bfd), X(0x0b75633b), X(0x0b87a7eb), + X(0x0b99fa08), X(0x0bac5990), X(0x0bbec67e), X(0x0bd140cf), + X(0x0be3c87e), X(0x0bf65d89), X(0x0c08ffeb), X(0x0c1bafa1), + X(0x0c2e6ca6), X(0x0c4136f6), X(0x0c540e8f), X(0x0c66f36c), + X(0x0c79e588), X(0x0c8ce4e1), X(0x0c9ff172), X(0x0cb30b37), + X(0x0cc6322c), X(0x0cd9664d), X(0x0ceca797), X(0x0cfff605), + X(0x0d135193), X(0x0d26ba3d), X(0x0d3a2fff), X(0x0d4db2d5), + X(0x0d6142ba), X(0x0d74dfac), X(0x0d8889a5), X(0x0d9c40a1), + X(0x0db0049d), X(0x0dc3d593), X(0x0dd7b380), X(0x0deb9e60), + X(0x0dff962f), X(0x0e139ae7), X(0x0e27ac85), X(0x0e3bcb05), + X(0x0e4ff662), X(0x0e642e98), X(0x0e7873a2), X(0x0e8cc57d), + X(0x0ea12423), X(0x0eb58f91), X(0x0eca07c2), X(0x0ede8cb1), + X(0x0ef31e5b), X(0x0f07bcba), X(0x0f1c67cb), X(0x0f311f88), + X(0x0f45e3ee), X(0x0f5ab4f7), X(0x0f6f92a0), X(0x0f847ce3), + X(0x0f9973bc), X(0x0fae7726), X(0x0fc3871e), X(0x0fd8a39d), + X(0x0fedcca1), X(0x10030223), X(0x1018441f), X(0x102d9291), + X(0x1042ed74), X(0x105854c3), X(0x106dc879), X(0x10834892), + X(0x1098d508), X(0x10ae6dd8), X(0x10c412fc), X(0x10d9c46f), + X(0x10ef822d), X(0x11054c30), X(0x111b2274), X(0x113104f5), + X(0x1146f3ac), X(0x115cee95), X(0x1172f5ab), X(0x118908e9), + X(0x119f284a), X(0x11b553ca), X(0x11cb8b62), X(0x11e1cf0f), + X(0x11f81ecb), X(0x120e7a90), X(0x1224e25a), X(0x123b5624), + X(0x1251d5e9), X(0x126861a3), X(0x127ef94e), X(0x12959ce3), + X(0x12ac4c5f), X(0x12c307bb), X(0x12d9cef2), X(0x12f0a200), + X(0x130780df), X(0x131e6b8a), X(0x133561fa), X(0x134c642c), + X(0x1363721a), X(0x137a8bbe), X(0x1391b113), X(0x13a8e214), + X(0x13c01eba), X(0x13d76702), X(0x13eebae5), X(0x14061a5e), + X(0x141d8567), X(0x1434fbfb), X(0x144c7e14), X(0x14640bae), + X(0x147ba4c1), X(0x14934949), X(0x14aaf941), X(0x14c2b4a2), + X(0x14da7b67), X(0x14f24d8a), X(0x150a2b06), X(0x152213d5), + X(0x153a07f1), X(0x15520755), X(0x156a11fb), X(0x158227dd), + X(0x159a48f5), X(0x15b2753d), X(0x15caacb1), X(0x15e2ef49), + X(0x15fb3d01), X(0x161395d2), X(0x162bf9b6), X(0x164468a8), + X(0x165ce2a1), X(0x1675679c), X(0x168df793), X(0x16a69280), + X(0x16bf385c), X(0x16d7e922), X(0x16f0a4cc), X(0x17096b54), + X(0x17223cb4), X(0x173b18e5), X(0x1753ffe2), X(0x176cf1a5), + X(0x1785ee27), X(0x179ef562), X(0x17b80750), X(0x17d123eb), + X(0x17ea4b2d), X(0x18037d10), X(0x181cb98d), X(0x1836009e), + X(0x184f523c), X(0x1868ae63), X(0x1882150a), X(0x189b862c), + X(0x18b501c4), X(0x18ce87c9), X(0x18e81836), X(0x1901b305), + X(0x191b582f), X(0x193507ad), X(0x194ec17a), X(0x1968858f), + X(0x198253e5), X(0x199c2c75), X(0x19b60f3a), X(0x19cffc2d), + X(0x19e9f347), X(0x1a03f482), X(0x1a1dffd7), X(0x1a381540), + X(0x1a5234b5), X(0x1a6c5e31), X(0x1a8691ac), X(0x1aa0cf21), + X(0x1abb1687), X(0x1ad567da), X(0x1aefc311), X(0x1b0a2826), + X(0x1b249712), X(0x1b3f0fd0), X(0x1b599257), X(0x1b741ea1), + X(0x1b8eb4a7), X(0x1ba95462), X(0x1bc3fdcd), X(0x1bdeb0de), + X(0x1bf96d91), X(0x1c1433dd), X(0x1c2f03bc), X(0x1c49dd27), + X(0x1c64c017), X(0x1c7fac85), X(0x1c9aa269), X(0x1cb5a1be), + X(0x1cd0aa7c), X(0x1cebbc9c), X(0x1d06d816), X(0x1d21fce4), + X(0x1d3d2aff), X(0x1d586260), X(0x1d73a2fe), X(0x1d8eecd4), + X(0x1daa3fda), X(0x1dc59c09), X(0x1de1015a), X(0x1dfc6fc5), + X(0x1e17e743), X(0x1e3367cd), X(0x1e4ef15b), X(0x1e6a83e7), + X(0x1e861f6a), X(0x1ea1c3da), X(0x1ebd7133), X(0x1ed9276b), + X(0x1ef4e67c), X(0x1f10ae5e), X(0x1f2c7f0a), X(0x1f485879), + X(0x1f643aa2), X(0x1f80257f), X(0x1f9c1908), X(0x1fb81536), + X(0x1fd41a00), X(0x1ff02761), X(0x200c3d4f), X(0x20285bc3), + X(0x204482b7), X(0x2060b221), X(0x207ce9fb), X(0x20992a3e), + X(0x20b572e0), X(0x20d1c3dc), X(0x20ee1d28), X(0x210a7ebe), + X(0x2126e895), X(0x21435aa6), X(0x215fd4ea), X(0x217c5757), + X(0x2198e1e8), X(0x21b57493), X(0x21d20f51), X(0x21eeb21b), + X(0x220b5ce7), X(0x22280fb0), X(0x2244ca6c), X(0x22618d13), + X(0x227e579f), X(0x229b2a06), X(0x22b80442), X(0x22d4e649), + X(0x22f1d015), X(0x230ec19d), X(0x232bbad9), X(0x2348bbc1), + X(0x2365c44c), X(0x2382d474), X(0x239fec30), X(0x23bd0b78), + X(0x23da3244), X(0x23f7608b), X(0x24149646), X(0x2431d36c), + X(0x244f17f5), X(0x246c63da), X(0x2489b711), X(0x24a71193), + X(0x24c47358), X(0x24e1dc57), X(0x24ff4c88), X(0x251cc3e2), + X(0x253a425e), X(0x2557c7f4), X(0x2575549a), X(0x2592e848), + X(0x25b082f7), X(0x25ce249e), X(0x25ebcd34), X(0x26097cb2), + X(0x2627330e), X(0x2644f040), X(0x2662b441), X(0x26807f07), + X(0x269e5089), X(0x26bc28c1), X(0x26da07a4), X(0x26f7ed2b), + X(0x2715d94d), X(0x2733cc02), X(0x2751c540), X(0x276fc500), + X(0x278dcb39), X(0x27abd7e2), X(0x27c9eaf3), X(0x27e80463), + X(0x28062429), X(0x28244a3e), X(0x28427697), X(0x2860a92d), + X(0x287ee1f7), X(0x289d20eb), X(0x28bb6603), X(0x28d9b134), + X(0x28f80275), X(0x291659c0), X(0x2934b709), X(0x29531a49), + X(0x29718378), X(0x298ff28b), X(0x29ae677b), X(0x29cce23e), + X(0x29eb62cb), X(0x2a09e91b), X(0x2a287523), X(0x2a4706dc), + X(0x2a659e3c), X(0x2a843b39), X(0x2aa2ddcd), X(0x2ac185ec), + X(0x2ae0338f), X(0x2afee6ad), X(0x2b1d9f3c), X(0x2b3c5d33), + X(0x2b5b208b), X(0x2b79e939), X(0x2b98b734), X(0x2bb78a74), + X(0x2bd662ef), X(0x2bf5409d), X(0x2c142374), X(0x2c330b6b), + X(0x2c51f87a), X(0x2c70ea97), X(0x2c8fe1b9), X(0x2caeddd6), + X(0x2ccddee7), X(0x2cece4e1), X(0x2d0befbb), X(0x2d2aff6d), + X(0x2d4a13ec), X(0x2d692d31), X(0x2d884b32), X(0x2da76de4), + X(0x2dc69540), X(0x2de5c13d), X(0x2e04f1d0), X(0x2e2426f0), + X(0x2e436095), X(0x2e629eb4), X(0x2e81e146), X(0x2ea1283f), + X(0x2ec07398), X(0x2edfc347), X(0x2eff1742), X(0x2f1e6f80), + X(0x2f3dcbf8), X(0x2f5d2ca0), X(0x2f7c916f), X(0x2f9bfa5c), + X(0x2fbb675d), X(0x2fdad869), X(0x2ffa4d76), X(0x3019c67b), + X(0x3039436f), X(0x3058c448), X(0x307848fc), X(0x3097d183), + X(0x30b75dd3), X(0x30d6ede2), X(0x30f681a6), X(0x31161917), + X(0x3135b42b), X(0x315552d8), X(0x3174f514), X(0x31949ad7), + X(0x31b44417), X(0x31d3f0ca), X(0x31f3a0e6), X(0x32135462), + X(0x32330b35), X(0x3252c555), X(0x327282b7), X(0x32924354), + X(0x32b20720), X(0x32d1ce13), X(0x32f19823), X(0x33116546), + X(0x33313573), X(0x3351089f), X(0x3370dec2), X(0x3390b7d1), + X(0x33b093c3), X(0x33d0728f), X(0x33f05429), X(0x3410388a), + X(0x34301fa7), X(0x34500977), X(0x346ff5ef), X(0x348fe506), + X(0x34afd6b3), X(0x34cfcaeb), X(0x34efc1a5), X(0x350fbad7), + X(0x352fb678), X(0x354fb47d), X(0x356fb4dd), X(0x358fb78e), + X(0x35afbc86), X(0x35cfc3bc), X(0x35efcd25), X(0x360fd8b8), + X(0x362fe66c), X(0x364ff636), X(0x3670080c), X(0x36901be5), + X(0x36b031b7), X(0x36d04978), X(0x36f0631e), X(0x37107ea0), + X(0x37309bf3), X(0x3750bb0e), X(0x3770dbe6), X(0x3790fe73), + X(0x37b122aa), X(0x37d14881), X(0x37f16fee), X(0x381198e8), + X(0x3831c365), X(0x3851ef5a), X(0x38721cbe), X(0x38924b87), + X(0x38b27bac), X(0x38d2ad21), X(0x38f2dfde), X(0x391313d8), + X(0x39334906), X(0x39537f5d), X(0x3973b6d4), X(0x3993ef60), + X(0x39b428f9), X(0x39d46393), X(0x39f49f25), X(0x3a14dba6), + X(0x3a35190a), X(0x3a555748), X(0x3a759657), X(0x3a95d62c), + X(0x3ab616be), X(0x3ad65801), X(0x3af699ed), X(0x3b16dc78), + X(0x3b371f97), X(0x3b576341), X(0x3b77a76c), X(0x3b97ec0d), + X(0x3bb8311b), X(0x3bd8768b), X(0x3bf8bc55), X(0x3c19026d), + X(0x3c3948ca), X(0x3c598f62), X(0x3c79d62b), X(0x3c9a1d1b), + X(0x3cba6428), X(0x3cdaab48), X(0x3cfaf271), X(0x3d1b3999), + X(0x3d3b80b6), X(0x3d5bc7be), X(0x3d7c0ea8), X(0x3d9c5569), + X(0x3dbc9bf7), X(0x3ddce248), X(0x3dfd2852), X(0x3e1d6e0c), + X(0x3e3db36c), X(0x3e5df866), X(0x3e7e3cf2), X(0x3e9e8106), + X(0x3ebec497), X(0x3edf079b), X(0x3eff4a09), X(0x3f1f8bd7), + X(0x3f3fccfa), X(0x3f600d69), X(0x3f804d1a), X(0x3fa08c02), + X(0x3fc0ca19), X(0x3fe10753), X(0x400143a7), X(0x40217f0a), + X(0x4041b974), X(0x4061f2da), X(0x40822b32), X(0x40a26272), + X(0x40c29891), X(0x40e2cd83), X(0x41030140), X(0x412333bd), + X(0x414364f1), X(0x416394d2), X(0x4183c355), X(0x41a3f070), + X(0x41c41c1b), X(0x41e4464a), X(0x42046ef4), X(0x42249610), + X(0x4244bb92), X(0x4264df72), X(0x428501a5), X(0x42a52222), + X(0x42c540de), X(0x42e55dd0), X(0x430578ed), X(0x4325922d), + X(0x4345a985), X(0x4365beeb), X(0x4385d255), X(0x43a5e3ba), + X(0x43c5f30f), X(0x43e6004b), X(0x44060b65), X(0x44261451), + X(0x44461b07), X(0x44661f7c), X(0x448621a7), X(0x44a6217d), + X(0x44c61ef6), X(0x44e61a07), X(0x450612a6), X(0x452608ca), + X(0x4545fc69), X(0x4565ed79), X(0x4585dbf1), X(0x45a5c7c6), + X(0x45c5b0ef), X(0x45e59761), X(0x46057b15), X(0x46255bfe), + X(0x46453a15), X(0x4665154f), X(0x4684eda2), X(0x46a4c305), + X(0x46c4956e), X(0x46e464d3), X(0x4704312b), X(0x4723fa6c), + X(0x4743c08d), X(0x47638382), X(0x47834344), X(0x47a2ffc9), + X(0x47c2b906), X(0x47e26ef2), X(0x48022183), X(0x4821d0b1), + X(0x48417c71), X(0x486124b9), X(0x4880c981), X(0x48a06abe), + X(0x48c00867), X(0x48dfa272), X(0x48ff38d6), X(0x491ecb8a), + X(0x493e5a84), X(0x495de5b9), X(0x497d6d22), X(0x499cf0b4), + X(0x49bc7066), X(0x49dbec2e), X(0x49fb6402), X(0x4a1ad7db), + X(0x4a3a47ad), X(0x4a59b370), X(0x4a791b1a), X(0x4a987ea1), + X(0x4ab7ddfd), X(0x4ad73924), X(0x4af6900c), X(0x4b15e2ad), + X(0x4b3530fc), X(0x4b547af1), X(0x4b73c082), X(0x4b9301a6), + X(0x4bb23e53), X(0x4bd17681), X(0x4bf0aa25), X(0x4c0fd937), + X(0x4c2f03ae), X(0x4c4e297f), X(0x4c6d4aa3), X(0x4c8c670f), + X(0x4cab7eba), X(0x4cca919c), X(0x4ce99fab), X(0x4d08a8de), + X(0x4d27ad2c), X(0x4d46ac8b), X(0x4d65a6f3), X(0x4d849c5a), + X(0x4da38cb7), X(0x4dc27802), X(0x4de15e31), X(0x4e003f3a), + X(0x4e1f1b16), X(0x4e3df1ba), X(0x4e5cc31e), X(0x4e7b8f3a), + X(0x4e9a5603), X(0x4eb91771), X(0x4ed7d37b), X(0x4ef68a18), + X(0x4f153b3f), X(0x4f33e6e7), X(0x4f528d08), X(0x4f712d97), + X(0x4f8fc88e), X(0x4fae5de1), X(0x4fcced8a), X(0x4feb777f), + X(0x5009fbb6), X(0x50287a28), X(0x5046f2cc), X(0x50656598), + X(0x5083d284), X(0x50a23988), X(0x50c09a9a), X(0x50def5b1), + X(0x50fd4ac7), X(0x511b99d0), X(0x5139e2c5), X(0x5158259e), + X(0x51766251), X(0x519498d6), X(0x51b2c925), X(0x51d0f334), + X(0x51ef16fb), X(0x520d3473), X(0x522b4b91), X(0x52495c4e), + X(0x526766a2), X(0x52856a83), X(0x52a367e9), X(0x52c15ecd), + X(0x52df4f24), X(0x52fd38e8), X(0x531b1c10), X(0x5338f892), + X(0x5356ce68), X(0x53749d89), X(0x539265eb), X(0x53b02788), + X(0x53cde257), X(0x53eb964f), X(0x54094369), X(0x5426e99c), + X(0x544488df), X(0x5462212c), X(0x547fb279), X(0x549d3cbe), + X(0x54babff4), X(0x54d83c12), X(0x54f5b110), X(0x55131ee7), + X(0x5530858d), X(0x554de4fc), X(0x556b3d2a), X(0x55888e11), + X(0x55a5d7a8), X(0x55c319e7), X(0x55e054c7), X(0x55fd883f), + X(0x561ab447), X(0x5637d8d8), X(0x5654f5ea), X(0x56720b75), + X(0x568f1971), X(0x56ac1fd7), X(0x56c91e9e), X(0x56e615c0), + X(0x57030534), X(0x571fecf2), X(0x573cccf3), X(0x5759a530), + X(0x577675a0), X(0x57933e3c), X(0x57affefd), X(0x57ccb7db), + X(0x57e968ce), X(0x580611cf), X(0x5822b2d6), X(0x583f4bdd), + X(0x585bdcdb), X(0x587865c9), X(0x5894e69f), X(0x58b15f57), + X(0x58cdcfe9), X(0x58ea384e), X(0x5906987d), X(0x5922f071), + X(0x593f4022), X(0x595b8788), X(0x5977c69c), X(0x5993fd57), + X(0x59b02bb2), X(0x59cc51a6), X(0x59e86f2c), X(0x5a04843c), + X(0x5a2090d0), X(0x5a3c94e0), X(0x5a589065), X(0x5a748359), + X(0x5a906db4), X(0x5aac4f70), X(0x5ac82884), X(0x5ae3f8ec), + X(0x5affc09f), X(0x5b1b7f97), X(0x5b3735cd), X(0x5b52e33a), + X(0x5b6e87d8), X(0x5b8a239f), X(0x5ba5b689), X(0x5bc1408f), + X(0x5bdcc1aa), X(0x5bf839d5), X(0x5c13a907), X(0x5c2f0f3b), + X(0x5c4a6c6a), X(0x5c65c08d), X(0x5c810b9e), X(0x5c9c4d97), + X(0x5cb78670), X(0x5cd2b623), X(0x5ceddcaa), X(0x5d08f9ff), + X(0x5d240e1b), X(0x5d3f18f8), X(0x5d5a1a8f), X(0x5d7512da), + X(0x5d9001d3), X(0x5daae773), X(0x5dc5c3b5), X(0x5de09692), + X(0x5dfb6004), X(0x5e162004), X(0x5e30d68d), X(0x5e4b8399), + X(0x5e662721), X(0x5e80c11f), X(0x5e9b518e), X(0x5eb5d867), + X(0x5ed055a4), X(0x5eeac940), X(0x5f053334), X(0x5f1f937b), + X(0x5f39ea0f), X(0x5f5436ea), X(0x5f6e7a06), X(0x5f88b35d), + X(0x5fa2e2e9), X(0x5fbd08a6), X(0x5fd7248d), X(0x5ff13698), + X(0x600b3ec2), X(0x60253d05), X(0x603f315b), X(0x60591bc0), + X(0x6072fc2d), X(0x608cd29e), X(0x60a69f0b), X(0x60c06171), + X(0x60da19ca), X(0x60f3c80f), X(0x610d6c3d), X(0x6127064d), + X(0x6140963a), X(0x615a1bff), X(0x61739797), X(0x618d08fc), + X(0x61a67029), X(0x61bfcd1a), X(0x61d91fc8), X(0x61f2682f), + X(0x620ba64a), X(0x6224da13), X(0x623e0386), X(0x6257229d), + X(0x62703754), X(0x628941a6), X(0x62a2418e), X(0x62bb3706), + X(0x62d4220a), X(0x62ed0296), X(0x6305d8a3), X(0x631ea42f), + X(0x63376533), X(0x63501bab), X(0x6368c793), X(0x638168e5), + X(0x6399ff9e), X(0x63b28bb8), X(0x63cb0d2f), X(0x63e383ff), + X(0x63fbf022), X(0x64145195), X(0x642ca853), X(0x6444f457), + X(0x645d359e), X(0x64756c22), X(0x648d97e0), X(0x64a5b8d3), + X(0x64bdcef6), X(0x64d5da47), X(0x64eddabf), X(0x6505d05c), + X(0x651dbb19), X(0x65359af2), X(0x654d6fe3), X(0x656539e7), + X(0x657cf8fb), X(0x6594ad1b), X(0x65ac5643), X(0x65c3f46e), + X(0x65db8799), X(0x65f30fc0), X(0x660a8ce0), X(0x6621fef3), + X(0x663965f7), X(0x6650c1e7), X(0x666812c1), X(0x667f5880), + X(0x66969320), X(0x66adc29e), X(0x66c4e6f7), X(0x66dc0026), + X(0x66f30e28), X(0x670a10fa), X(0x67210898), X(0x6737f4ff), + X(0x674ed62b), X(0x6765ac19), X(0x677c76c5), X(0x6793362c), + X(0x67a9ea4b), X(0x67c0931f), X(0x67d730a3), X(0x67edc2d6), + X(0x680449b3), X(0x681ac538), X(0x68313562), X(0x68479a2d), + X(0x685df396), X(0x6874419b), X(0x688a8438), X(0x68a0bb6a), + X(0x68b6e72e), X(0x68cd0782), X(0x68e31c63), X(0x68f925cd), + X(0x690f23be), X(0x69251633), X(0x693afd29), X(0x6950d89e), + X(0x6966a88f), X(0x697c6cf8), X(0x699225d9), X(0x69a7d32d), + X(0x69bd74f3), X(0x69d30b27), X(0x69e895c8), X(0x69fe14d2), + X(0x6a138844), X(0x6a28f01b), X(0x6a3e4c54), X(0x6a539ced), + X(0x6a68e1e4), X(0x6a7e1b37), X(0x6a9348e3), X(0x6aa86ae6), + X(0x6abd813d), X(0x6ad28be7), X(0x6ae78ae2), X(0x6afc7e2b), + X(0x6b1165c0), X(0x6b26419f), X(0x6b3b11c7), X(0x6b4fd634), + X(0x6b648ee6), X(0x6b793bda), X(0x6b8ddd0e), X(0x6ba27281), + X(0x6bb6fc31), X(0x6bcb7a1b), X(0x6bdfec3e), X(0x6bf45299), + X(0x6c08ad29), X(0x6c1cfbed), X(0x6c313ee4), X(0x6c45760a), + X(0x6c59a160), X(0x6c6dc0e4), X(0x6c81d493), X(0x6c95dc6d), + X(0x6ca9d86f), X(0x6cbdc899), X(0x6cd1acea), X(0x6ce5855f), + X(0x6cf951f7), X(0x6d0d12b1), X(0x6d20c78c), X(0x6d347087), + X(0x6d480da0), X(0x6d5b9ed6), X(0x6d6f2427), X(0x6d829d94), + X(0x6d960b1a), X(0x6da96cb9), X(0x6dbcc270), X(0x6dd00c3c), + X(0x6de34a1f), X(0x6df67c16), X(0x6e09a221), X(0x6e1cbc3f), + X(0x6e2fca6e), X(0x6e42ccaf), X(0x6e55c300), X(0x6e68ad60), + X(0x6e7b8bd0), X(0x6e8e5e4d), X(0x6ea124d8), X(0x6eb3df70), + X(0x6ec68e13), X(0x6ed930c3), X(0x6eebc77d), X(0x6efe5242), + X(0x6f10d111), X(0x6f2343e9), X(0x6f35aacb), X(0x6f4805b5), + X(0x6f5a54a8), X(0x6f6c97a2), X(0x6f7ecea4), X(0x6f90f9ae), + X(0x6fa318be), X(0x6fb52bd6), X(0x6fc732f4), X(0x6fd92e19), + X(0x6feb1d44), X(0x6ffd0076), X(0x700ed7ad), X(0x7020a2eb), + X(0x7032622f), X(0x7044157a), X(0x7055bcca), X(0x70675821), + X(0x7078e77e), X(0x708a6ae2), X(0x709be24c), X(0x70ad4dbd), + X(0x70bead36), X(0x70d000b5), X(0x70e1483d), X(0x70f283cc), + X(0x7103b363), X(0x7114d704), X(0x7125eead), X(0x7136fa60), + X(0x7147fa1c), X(0x7158ede4), X(0x7169d5b6), X(0x717ab193), + X(0x718b817d), X(0x719c4573), X(0x71acfd76), X(0x71bda988), + X(0x71ce49a8), X(0x71deddd7), X(0x71ef6617), X(0x71ffe267), + X(0x721052ca), X(0x7220b73e), X(0x72310fc6), X(0x72415c62), + X(0x72519d14), X(0x7261d1db), X(0x7271faba), X(0x728217b1), + X(0x729228c0), X(0x72a22dea), X(0x72b22730), X(0x72c21491), + X(0x72d1f611), X(0x72e1cbaf), X(0x72f1956c), X(0x7301534c), + X(0x7311054d), X(0x7320ab72), X(0x733045bc), X(0x733fd42d), + X(0x734f56c5), X(0x735ecd86), X(0x736e3872), X(0x737d9789), + X(0x738ceacf), X(0x739c3243), X(0x73ab6de7), X(0x73ba9dbe), + X(0x73c9c1c8), X(0x73d8da08), X(0x73e7e67f), X(0x73f6e72e), + X(0x7405dc17), X(0x7414c53c), X(0x7423a29f), X(0x74327442), + X(0x74413a26), X(0x744ff44d), X(0x745ea2b9), X(0x746d456c), + X(0x747bdc68), X(0x748a67ae), X(0x7498e741), X(0x74a75b23), + X(0x74b5c356), X(0x74c41fdb), X(0x74d270b6), X(0x74e0b5e7), + X(0x74eeef71), X(0x74fd1d57), X(0x750b3f9a), X(0x7519563c), + X(0x75276140), X(0x753560a8), X(0x75435477), X(0x75513cae), + X(0x755f1951), X(0x756cea60), X(0x757aafdf), X(0x758869d1), + X(0x75961837), X(0x75a3bb14), X(0x75b1526a), X(0x75bede3c), + X(0x75cc5e8d), X(0x75d9d35f), X(0x75e73cb5), X(0x75f49a91), + X(0x7601ecf6), X(0x760f33e6), X(0x761c6f65), X(0x76299f74), + X(0x7636c417), X(0x7643dd51), X(0x7650eb24), X(0x765ded93), + X(0x766ae4a0), X(0x7677d050), X(0x7684b0a4), X(0x7691859f), + X(0x769e4f45), X(0x76ab0d98), X(0x76b7c09c), X(0x76c46852), + X(0x76d104bf), X(0x76dd95e6), X(0x76ea1bc9), X(0x76f6966b), + X(0x770305d0), X(0x770f69fb), X(0x771bc2ef), X(0x772810af), + X(0x7734533e), X(0x77408aa0), X(0x774cb6d7), X(0x7758d7e8), + X(0x7764edd5), X(0x7770f8a2), X(0x777cf852), X(0x7788ece8), + X(0x7794d668), X(0x77a0b4d5), X(0x77ac8833), X(0x77b85085), + X(0x77c40dce), X(0x77cfc013), X(0x77db6756), X(0x77e7039b), + X(0x77f294e6), X(0x77fe1b3b), X(0x7809969c), X(0x7815070e), + X(0x78206c93), X(0x782bc731), X(0x783716ea), X(0x78425bc3), + X(0x784d95be), X(0x7858c4e1), X(0x7863e92d), X(0x786f02a8), + X(0x787a1156), X(0x78851539), X(0x78900e56), X(0x789afcb1), + X(0x78a5e04d), X(0x78b0b92f), X(0x78bb875b), X(0x78c64ad4), + X(0x78d1039e), X(0x78dbb1be), X(0x78e65537), X(0x78f0ee0e), + X(0x78fb7c46), X(0x7905ffe4), X(0x791078ec), X(0x791ae762), + X(0x79254b4a), X(0x792fa4a7), X(0x7939f380), X(0x794437d7), + X(0x794e71b0), X(0x7958a111), X(0x7962c5fd), X(0x796ce078), + X(0x7976f087), X(0x7980f62f), X(0x798af173), X(0x7994e258), + X(0x799ec8e2), X(0x79a8a515), X(0x79b276f7), X(0x79bc3e8b), + X(0x79c5fbd6), X(0x79cfaedc), X(0x79d957a2), X(0x79e2f62c), + X(0x79ec8a7f), X(0x79f6149f), X(0x79ff9492), X(0x7a090a5a), + X(0x7a1275fe), X(0x7a1bd781), X(0x7a252ee9), X(0x7a2e7c39), + X(0x7a37bf77), X(0x7a40f8a7), X(0x7a4a27ce), X(0x7a534cf0), + X(0x7a5c6813), X(0x7a65793b), X(0x7a6e806d), X(0x7a777dad), + X(0x7a807100), X(0x7a895a6b), X(0x7a9239f4), X(0x7a9b0f9e), + X(0x7aa3db6f), X(0x7aac9d6b), X(0x7ab55597), X(0x7abe03f9), + X(0x7ac6a895), X(0x7acf4370), X(0x7ad7d48f), X(0x7ae05bf6), + X(0x7ae8d9ac), X(0x7af14db5), X(0x7af9b815), X(0x7b0218d2), + X(0x7b0a6ff2), X(0x7b12bd78), X(0x7b1b016a), X(0x7b233bce), + X(0x7b2b6ca7), X(0x7b3393fc), X(0x7b3bb1d1), X(0x7b43c62c), + X(0x7b4bd111), X(0x7b53d286), X(0x7b5bca90), X(0x7b63b935), + X(0x7b6b9e78), X(0x7b737a61), X(0x7b7b4cf3), X(0x7b831634), + X(0x7b8ad629), X(0x7b928cd8), X(0x7b9a3a45), X(0x7ba1de77), + X(0x7ba97972), X(0x7bb10b3c), X(0x7bb893d9), X(0x7bc01350), + X(0x7bc789a6), X(0x7bcef6e0), X(0x7bd65b03), X(0x7bddb616), + X(0x7be5081c), X(0x7bec511c), X(0x7bf3911b), X(0x7bfac81f), + X(0x7c01f62c), X(0x7c091b49), X(0x7c10377b), X(0x7c174ac7), + X(0x7c1e5532), X(0x7c2556c4), X(0x7c2c4f80), X(0x7c333f6c), + X(0x7c3a268e), X(0x7c4104ec), X(0x7c47da8a), X(0x7c4ea76f), + X(0x7c556ba1), X(0x7c5c2724), X(0x7c62d9fe), X(0x7c698435), + X(0x7c7025cf), X(0x7c76bed0), X(0x7c7d4f40), X(0x7c83d723), + X(0x7c8a567f), X(0x7c90cd5a), X(0x7c973bb9), X(0x7c9da1a2), + X(0x7ca3ff1b), X(0x7caa542a), X(0x7cb0a0d3), X(0x7cb6e51e), + X(0x7cbd210f), X(0x7cc354ac), X(0x7cc97ffc), X(0x7ccfa304), + X(0x7cd5bdc9), X(0x7cdbd051), X(0x7ce1daa3), X(0x7ce7dcc3), + X(0x7cedd6b8), X(0x7cf3c888), X(0x7cf9b238), X(0x7cff93cf), + X(0x7d056d51), X(0x7d0b3ec5), X(0x7d110830), X(0x7d16c99a), + X(0x7d1c8306), X(0x7d22347c), X(0x7d27de00), X(0x7d2d7f9a), + X(0x7d33194f), X(0x7d38ab24), X(0x7d3e351f), X(0x7d43b748), + X(0x7d4931a2), X(0x7d4ea435), X(0x7d540f06), X(0x7d59721b), + X(0x7d5ecd7b), X(0x7d64212a), X(0x7d696d2f), X(0x7d6eb190), + X(0x7d73ee53), X(0x7d79237e), X(0x7d7e5117), X(0x7d837723), + X(0x7d8895a9), X(0x7d8dacae), X(0x7d92bc3a), X(0x7d97c451), + X(0x7d9cc4f9), X(0x7da1be39), X(0x7da6b017), X(0x7dab9a99), + X(0x7db07dc4), X(0x7db5599e), X(0x7dba2e2f), X(0x7dbefb7b), + X(0x7dc3c189), X(0x7dc8805e), X(0x7dcd3802), X(0x7dd1e879), + X(0x7dd691ca), X(0x7ddb33fb), X(0x7ddfcf12), X(0x7de46315), + X(0x7de8f00a), X(0x7ded75f8), X(0x7df1f4e3), X(0x7df66cd3), + X(0x7dfaddcd), X(0x7dff47d7), X(0x7e03aaf8), X(0x7e080735), + X(0x7e0c5c95), X(0x7e10ab1e), X(0x7e14f2d5), X(0x7e1933c1), + X(0x7e1d6de8), X(0x7e21a150), X(0x7e25cdff), X(0x7e29f3fc), + X(0x7e2e134c), X(0x7e322bf5), X(0x7e363dfd), X(0x7e3a496b), + X(0x7e3e4e45), X(0x7e424c90), X(0x7e464454), X(0x7e4a3595), + X(0x7e4e205a), X(0x7e5204aa), X(0x7e55e289), X(0x7e59b9ff), + X(0x7e5d8b12), X(0x7e6155c7), X(0x7e651a24), X(0x7e68d831), + X(0x7e6c8ff2), X(0x7e70416e), X(0x7e73ecac), X(0x7e7791b0), + X(0x7e7b3082), X(0x7e7ec927), X(0x7e825ba6), X(0x7e85e804), + X(0x7e896e48), X(0x7e8cee77), X(0x7e906899), X(0x7e93dcb2), + X(0x7e974aca), X(0x7e9ab2e5), X(0x7e9e150b), X(0x7ea17141), + X(0x7ea4c78e), X(0x7ea817f7), X(0x7eab6283), X(0x7eaea737), + X(0x7eb1e61a), X(0x7eb51f33), X(0x7eb85285), X(0x7ebb8019), + X(0x7ebea7f4), X(0x7ec1ca1d), X(0x7ec4e698), X(0x7ec7fd6d), + X(0x7ecb0ea1), X(0x7ece1a3a), X(0x7ed1203f), X(0x7ed420b6), + X(0x7ed71ba4), X(0x7eda110f), X(0x7edd00ff), X(0x7edfeb78), + X(0x7ee2d081), X(0x7ee5b01f), X(0x7ee88a5a), X(0x7eeb5f36), + X(0x7eee2eba), X(0x7ef0f8ed), X(0x7ef3bdd3), X(0x7ef67d73), + X(0x7ef937d3), X(0x7efbecf9), X(0x7efe9ceb), X(0x7f0147ae), + X(0x7f03ed4a), X(0x7f068dc4), X(0x7f092922), X(0x7f0bbf69), + X(0x7f0e50a1), X(0x7f10dcce), X(0x7f1363f7), X(0x7f15e622), + X(0x7f186355), X(0x7f1adb95), X(0x7f1d4ee9), X(0x7f1fbd57), + X(0x7f2226e4), X(0x7f248b96), X(0x7f26eb74), X(0x7f294683), + X(0x7f2b9cc9), X(0x7f2dee4d), X(0x7f303b13), X(0x7f328322), + X(0x7f34c680), X(0x7f370533), X(0x7f393f40), X(0x7f3b74ad), + X(0x7f3da581), X(0x7f3fd1c1), X(0x7f41f972), X(0x7f441c9c), + X(0x7f463b43), X(0x7f48556d), X(0x7f4a6b21), X(0x7f4c7c64), + X(0x7f4e893c), X(0x7f5091ae), X(0x7f5295c1), X(0x7f54957a), + X(0x7f5690e0), X(0x7f5887f7), X(0x7f5a7ac5), X(0x7f5c6951), + X(0x7f5e53a0), X(0x7f6039b8), X(0x7f621b9e), X(0x7f63f958), + X(0x7f65d2ed), X(0x7f67a861), X(0x7f6979ba), X(0x7f6b46ff), + X(0x7f6d1034), X(0x7f6ed560), X(0x7f709687), X(0x7f7253b1), + X(0x7f740ce1), X(0x7f75c21f), X(0x7f777370), X(0x7f7920d8), + X(0x7f7aca5f), X(0x7f7c7008), X(0x7f7e11db), X(0x7f7fafdd), + X(0x7f814a13), X(0x7f82e082), X(0x7f847331), X(0x7f860224), + X(0x7f878d62), X(0x7f8914f0), X(0x7f8a98d4), X(0x7f8c1912), + X(0x7f8d95b0), X(0x7f8f0eb5), X(0x7f908425), X(0x7f91f605), + X(0x7f93645c), X(0x7f94cf2f), X(0x7f963683), X(0x7f979a5d), + X(0x7f98fac4), X(0x7f9a57bb), X(0x7f9bb14a), X(0x7f9d0775), + X(0x7f9e5a41), X(0x7f9fa9b4), X(0x7fa0f5d3), X(0x7fa23ea4), + X(0x7fa3842b), X(0x7fa4c66f), X(0x7fa60575), X(0x7fa74141), + X(0x7fa879d9), X(0x7fa9af42), X(0x7faae182), X(0x7fac109e), + X(0x7fad3c9a), X(0x7fae657d), X(0x7faf8b4c), X(0x7fb0ae0b), + X(0x7fb1cdc0), X(0x7fb2ea70), X(0x7fb40420), X(0x7fb51ad5), + X(0x7fb62e95), X(0x7fb73f64), X(0x7fb84d48), X(0x7fb95846), + X(0x7fba6062), X(0x7fbb65a2), X(0x7fbc680c), X(0x7fbd67a3), + X(0x7fbe646d), X(0x7fbf5e70), X(0x7fc055af), X(0x7fc14a31), + X(0x7fc23bf9), X(0x7fc32b0d), X(0x7fc41773), X(0x7fc5012e), + X(0x7fc5e844), X(0x7fc6ccba), X(0x7fc7ae94), X(0x7fc88dd8), + X(0x7fc96a8a), X(0x7fca44af), X(0x7fcb1c4c), X(0x7fcbf167), + X(0x7fccc403), X(0x7fcd9425), X(0x7fce61d3), X(0x7fcf2d11), + X(0x7fcff5e3), X(0x7fd0bc4f), X(0x7fd1805a), X(0x7fd24207), + X(0x7fd3015c), X(0x7fd3be5d), X(0x7fd47910), X(0x7fd53178), + X(0x7fd5e79b), X(0x7fd69b7c), X(0x7fd74d21), X(0x7fd7fc8e), + X(0x7fd8a9c8), X(0x7fd954d4), X(0x7fd9fdb5), X(0x7fdaa471), + X(0x7fdb490b), X(0x7fdbeb89), X(0x7fdc8bef), X(0x7fdd2a42), + X(0x7fddc685), X(0x7fde60be), X(0x7fdef8f0), X(0x7fdf8f20), + X(0x7fe02353), X(0x7fe0b58d), X(0x7fe145d3), X(0x7fe1d428), + X(0x7fe26091), X(0x7fe2eb12), X(0x7fe373b0), X(0x7fe3fa6f), + X(0x7fe47f53), X(0x7fe50260), X(0x7fe5839b), X(0x7fe60308), + X(0x7fe680ab), X(0x7fe6fc88), X(0x7fe776a4), X(0x7fe7ef02), + X(0x7fe865a7), X(0x7fe8da97), X(0x7fe94dd6), X(0x7fe9bf68), + X(0x7fea2f51), X(0x7fea9d95), X(0x7feb0a39), X(0x7feb7540), + X(0x7febdeae), X(0x7fec4687), X(0x7fecaccf), X(0x7fed118b), + X(0x7fed74be), X(0x7fedd66c), X(0x7fee3698), X(0x7fee9548), + X(0x7feef27e), X(0x7fef4e3f), X(0x7fefa88e), X(0x7ff0016f), + X(0x7ff058e7), X(0x7ff0aef8), X(0x7ff103a6), X(0x7ff156f6), + X(0x7ff1a8eb), X(0x7ff1f988), X(0x7ff248d2), X(0x7ff296cc), + X(0x7ff2e37a), X(0x7ff32edf), X(0x7ff378ff), X(0x7ff3c1de), + X(0x7ff4097e), X(0x7ff44fe5), X(0x7ff49515), X(0x7ff4d911), + X(0x7ff51bde), X(0x7ff55d7f), X(0x7ff59df7), X(0x7ff5dd4a), + X(0x7ff61b7b), X(0x7ff6588d), X(0x7ff69485), X(0x7ff6cf65), + X(0x7ff70930), X(0x7ff741eb), X(0x7ff77998), X(0x7ff7b03b), + X(0x7ff7e5d7), X(0x7ff81a6f), X(0x7ff84e06), X(0x7ff880a1), + X(0x7ff8b241), X(0x7ff8e2ea), X(0x7ff912a0), X(0x7ff94165), + X(0x7ff96f3d), X(0x7ff99c2b), X(0x7ff9c831), X(0x7ff9f354), + X(0x7ffa1d95), X(0x7ffa46f9), X(0x7ffa6f81), X(0x7ffa9731), + X(0x7ffabe0d), X(0x7ffae416), X(0x7ffb0951), X(0x7ffb2dbf), + X(0x7ffb5164), X(0x7ffb7442), X(0x7ffb965d), X(0x7ffbb7b8), + X(0x7ffbd854), X(0x7ffbf836), X(0x7ffc175f), X(0x7ffc35d3), + X(0x7ffc5394), X(0x7ffc70a5), X(0x7ffc8d09), X(0x7ffca8c2), + X(0x7ffcc3d4), X(0x7ffcde3f), X(0x7ffcf809), X(0x7ffd1132), + X(0x7ffd29be), X(0x7ffd41ae), X(0x7ffd5907), X(0x7ffd6fc9), + X(0x7ffd85f9), X(0x7ffd9b97), X(0x7ffdb0a7), X(0x7ffdc52b), + X(0x7ffdd926), X(0x7ffdec99), X(0x7ffdff88), X(0x7ffe11f4), + X(0x7ffe23e0), X(0x7ffe354f), X(0x7ffe4642), X(0x7ffe56bc), + X(0x7ffe66bf), X(0x7ffe764e), X(0x7ffe856a), X(0x7ffe9416), + X(0x7ffea254), X(0x7ffeb026), X(0x7ffebd8e), X(0x7ffeca8f), + X(0x7ffed72a), X(0x7ffee362), X(0x7ffeef38), X(0x7ffefaaf), + X(0x7fff05c9), X(0x7fff1087), X(0x7fff1aec), X(0x7fff24f9), + X(0x7fff2eb1), X(0x7fff3816), X(0x7fff4128), X(0x7fff49eb), + X(0x7fff5260), X(0x7fff5a88), X(0x7fff6266), X(0x7fff69fc), + X(0x7fff714b), X(0x7fff7854), X(0x7fff7f1a), X(0x7fff859f), + X(0x7fff8be3), X(0x7fff91ea), X(0x7fff97b3), X(0x7fff9d41), + X(0x7fffa296), X(0x7fffa7b3), X(0x7fffac99), X(0x7fffb14b), + X(0x7fffb5c9), X(0x7fffba15), X(0x7fffbe31), X(0x7fffc21d), + X(0x7fffc5dc), X(0x7fffc96f), X(0x7fffccd8), X(0x7fffd016), + X(0x7fffd32d), X(0x7fffd61c), X(0x7fffd8e7), X(0x7fffdb8d), + X(0x7fffde0f), X(0x7fffe071), X(0x7fffe2b1), X(0x7fffe4d2), + X(0x7fffe6d5), X(0x7fffe8bb), X(0x7fffea85), X(0x7fffec34), + X(0x7fffedc9), X(0x7fffef45), X(0x7ffff0aa), X(0x7ffff1f7), + X(0x7ffff330), X(0x7ffff453), X(0x7ffff562), X(0x7ffff65f), + X(0x7ffff749), X(0x7ffff823), X(0x7ffff8ec), X(0x7ffff9a6), + X(0x7ffffa51), X(0x7ffffaee), X(0x7ffffb7e), X(0x7ffffc02), + X(0x7ffffc7a), X(0x7ffffce7), X(0x7ffffd4a), X(0x7ffffda3), + X(0x7ffffdf4), X(0x7ffffe3c), X(0x7ffffe7c), X(0x7ffffeb6), + X(0x7ffffee8), X(0x7fffff15), X(0x7fffff3c), X(0x7fffff5e), + X(0x7fffff7b), X(0x7fffff95), X(0x7fffffaa), X(0x7fffffbc), + X(0x7fffffcb), X(0x7fffffd7), X(0x7fffffe2), X(0x7fffffea), + X(0x7ffffff0), X(0x7ffffff5), X(0x7ffffff9), X(0x7ffffffb), + X(0x7ffffffd), X(0x7ffffffe), X(0x7fffffff), X(0x7fffffff), + X(0x7fffffff), X(0x7fffffff), X(0x7fffffff), X(0x7fffffff), +}; + +static LOOKUP_T vwin8192[4096] = { + X(0x0000007c), X(0x0000045c), X(0x00000c1d), X(0x000017bd), + X(0x0000273e), X(0x00003a9f), X(0x000051e0), X(0x00006d02), + X(0x00008c03), X(0x0000aee5), X(0x0000d5a7), X(0x00010049), + X(0x00012ecb), X(0x0001612d), X(0x00019770), X(0x0001d193), + X(0x00020f96), X(0x00025178), X(0x0002973c), X(0x0002e0df), + X(0x00032e62), X(0x00037fc5), X(0x0003d509), X(0x00042e2c), + X(0x00048b30), X(0x0004ec13), X(0x000550d7), X(0x0005b97a), + X(0x000625fe), X(0x00069661), X(0x00070aa4), X(0x000782c8), + X(0x0007fecb), X(0x00087eae), X(0x00090271), X(0x00098a14), + X(0x000a1597), X(0x000aa4f9), X(0x000b383b), X(0x000bcf5d), + X(0x000c6a5f), X(0x000d0941), X(0x000dac02), X(0x000e52a3), + X(0x000efd23), X(0x000fab84), X(0x00105dc3), X(0x001113e3), + X(0x0011cde2), X(0x00128bc0), X(0x00134d7e), X(0x0014131b), + X(0x0014dc98), X(0x0015a9f4), X(0x00167b30), X(0x0017504a), + X(0x00182945), X(0x0019061e), X(0x0019e6d7), X(0x001acb6f), + X(0x001bb3e6), X(0x001ca03c), X(0x001d9071), X(0x001e8485), + X(0x001f7c79), X(0x0020784b), X(0x002177fc), X(0x00227b8c), + X(0x002382fb), X(0x00248e49), X(0x00259d76), X(0x0026b081), + X(0x0027c76b), X(0x0028e234), X(0x002a00dc), X(0x002b2361), + X(0x002c49c6), X(0x002d7409), X(0x002ea22a), X(0x002fd42a), + X(0x00310a08), X(0x003243c5), X(0x00338160), X(0x0034c2d9), + X(0x00360830), X(0x00375165), X(0x00389e78), X(0x0039ef6a), + X(0x003b4439), X(0x003c9ce6), X(0x003df971), X(0x003f59da), + X(0x0040be20), X(0x00422645), X(0x00439247), X(0x00450226), + X(0x004675e3), X(0x0047ed7e), X(0x004968f5), X(0x004ae84b), + X(0x004c6b7d), X(0x004df28d), X(0x004f7d7a), X(0x00510c44), + X(0x00529eeb), X(0x00543570), X(0x0055cfd1), X(0x00576e0f), + X(0x00591029), X(0x005ab621), X(0x005c5ff5), X(0x005e0da6), + X(0x005fbf33), X(0x0061749d), X(0x00632de4), X(0x0064eb06), + X(0x0066ac05), X(0x006870e0), X(0x006a3998), X(0x006c062b), + X(0x006dd69b), X(0x006faae6), X(0x0071830d), X(0x00735f10), + X(0x00753eef), X(0x007722a9), X(0x00790a3f), X(0x007af5b1), + X(0x007ce4fe), X(0x007ed826), X(0x0080cf29), X(0x0082ca08), + X(0x0084c8c2), X(0x0086cb57), X(0x0088d1c7), X(0x008adc11), + X(0x008cea37), X(0x008efc37), X(0x00911212), X(0x00932bc7), + X(0x00954957), X(0x00976ac2), X(0x00999006), X(0x009bb925), + X(0x009de61e), X(0x00a016f1), X(0x00a24b9e), X(0x00a48425), + X(0x00a6c086), X(0x00a900c0), X(0x00ab44d4), X(0x00ad8cc2), + X(0x00afd889), X(0x00b22829), X(0x00b47ba2), X(0x00b6d2f5), + X(0x00b92e21), X(0x00bb8d26), X(0x00bdf004), X(0x00c056ba), + X(0x00c2c149), X(0x00c52fb1), X(0x00c7a1f1), X(0x00ca180a), + X(0x00cc91fb), X(0x00cf0fc5), X(0x00d19166), X(0x00d416df), + X(0x00d6a031), X(0x00d92d5a), X(0x00dbbe5b), X(0x00de5333), + X(0x00e0ebe3), X(0x00e3886b), X(0x00e628c9), X(0x00e8ccff), + X(0x00eb750c), X(0x00ee20f0), X(0x00f0d0ab), X(0x00f3843d), + X(0x00f63ba5), X(0x00f8f6e4), X(0x00fbb5fa), X(0x00fe78e5), + X(0x01013fa7), X(0x01040a3f), X(0x0106d8ae), X(0x0109aaf2), + X(0x010c810c), X(0x010f5afb), X(0x011238c0), X(0x01151a5b), + X(0x0117ffcb), X(0x011ae910), X(0x011dd62a), X(0x0120c719), + X(0x0123bbdd), X(0x0126b476), X(0x0129b0e4), X(0x012cb126), + X(0x012fb53c), X(0x0132bd27), X(0x0135c8e6), X(0x0138d879), + X(0x013bebdf), X(0x013f031a), X(0x01421e28), X(0x01453d0a), + X(0x01485fbf), X(0x014b8648), X(0x014eb0a4), X(0x0151ded2), + X(0x015510d4), X(0x015846a8), X(0x015b8050), X(0x015ebdc9), + X(0x0161ff15), X(0x01654434), X(0x01688d24), X(0x016bd9e6), + X(0x016f2a7b), X(0x01727ee1), X(0x0175d718), X(0x01793321), + X(0x017c92fc), X(0x017ff6a7), X(0x01835e24), X(0x0186c972), + X(0x018a3890), X(0x018dab7f), X(0x0191223f), X(0x01949ccf), + X(0x01981b2f), X(0x019b9d5f), X(0x019f235f), X(0x01a2ad2f), + X(0x01a63acf), X(0x01a9cc3e), X(0x01ad617c), X(0x01b0fa8a), + X(0x01b49767), X(0x01b83813), X(0x01bbdc8d), X(0x01bf84d6), + X(0x01c330ee), X(0x01c6e0d4), X(0x01ca9488), X(0x01ce4c0b), + X(0x01d2075b), X(0x01d5c679), X(0x01d98964), X(0x01dd501d), + X(0x01e11aa3), X(0x01e4e8f6), X(0x01e8bb17), X(0x01ec9104), + X(0x01f06abd), X(0x01f44844), X(0x01f82996), X(0x01fc0eb5), + X(0x01fff7a0), X(0x0203e456), X(0x0207d4d9), X(0x020bc926), + X(0x020fc140), X(0x0213bd24), X(0x0217bcd4), X(0x021bc04e), + X(0x021fc793), X(0x0223d2a3), X(0x0227e17d), X(0x022bf421), + X(0x02300a90), X(0x023424c8), X(0x023842ca), X(0x023c6495), + X(0x02408a2a), X(0x0244b389), X(0x0248e0b0), X(0x024d11a0), + X(0x02514659), X(0x02557eda), X(0x0259bb24), X(0x025dfb35), + X(0x02623f0f), X(0x026686b1), X(0x026ad21a), X(0x026f214b), + X(0x02737443), X(0x0277cb02), X(0x027c2588), X(0x028083d5), + X(0x0284e5e9), X(0x02894bc2), X(0x028db562), X(0x029222c8), + X(0x029693f4), X(0x029b08e6), X(0x029f819d), X(0x02a3fe19), + X(0x02a87e5b), X(0x02ad0261), X(0x02b18a2c), X(0x02b615bb), + X(0x02baa50f), X(0x02bf3827), X(0x02c3cf03), X(0x02c869a3), + X(0x02cd0807), X(0x02d1aa2d), X(0x02d65017), X(0x02daf9c4), + X(0x02dfa734), X(0x02e45866), X(0x02e90d5b), X(0x02edc612), + X(0x02f2828b), X(0x02f742c6), X(0x02fc06c3), X(0x0300ce80), + X(0x030599ff), X(0x030a6940), X(0x030f3c40), X(0x03141302), + X(0x0318ed84), X(0x031dcbc6), X(0x0322adc8), X(0x0327938a), + X(0x032c7d0c), X(0x03316a4c), X(0x03365b4d), X(0x033b500c), + X(0x03404889), X(0x034544c6), X(0x034a44c0), X(0x034f4879), + X(0x03544ff0), X(0x03595b24), X(0x035e6a16), X(0x03637cc5), + X(0x03689331), X(0x036dad5a), X(0x0372cb40), X(0x0377ece2), + X(0x037d1240), X(0x03823b5a), X(0x03876830), X(0x038c98c1), + X(0x0391cd0e), X(0x03970516), X(0x039c40d8), X(0x03a18055), + X(0x03a6c38d), X(0x03ac0a7f), X(0x03b1552b), X(0x03b6a390), + X(0x03bbf5af), X(0x03c14b88), X(0x03c6a519), X(0x03cc0263), + X(0x03d16366), X(0x03d6c821), X(0x03dc3094), X(0x03e19cc0), + X(0x03e70ca2), X(0x03ec803d), X(0x03f1f78e), X(0x03f77296), + X(0x03fcf155), X(0x040273cb), X(0x0407f9f7), X(0x040d83d9), + X(0x04131170), X(0x0418a2bd), X(0x041e37c0), X(0x0423d077), + X(0x04296ce4), X(0x042f0d04), X(0x0434b0da), X(0x043a5863), + X(0x044003a0), X(0x0445b290), X(0x044b6534), X(0x04511b8b), + X(0x0456d595), X(0x045c9352), X(0x046254c1), X(0x046819e1), + X(0x046de2b4), X(0x0473af39), X(0x04797f6e), X(0x047f5355), + X(0x04852aec), X(0x048b0635), X(0x0490e52d), X(0x0496c7d6), + X(0x049cae2e), X(0x04a29836), X(0x04a885ed), X(0x04ae7753), + X(0x04b46c68), X(0x04ba652b), X(0x04c0619d), X(0x04c661bc), + X(0x04cc658a), X(0x04d26d04), X(0x04d8782c), X(0x04de8701), + X(0x04e49983), X(0x04eaafb0), X(0x04f0c98a), X(0x04f6e710), + X(0x04fd0842), X(0x05032d1e), X(0x050955a6), X(0x050f81d8), + X(0x0515b1b5), X(0x051be53d), X(0x05221c6e), X(0x05285748), + X(0x052e95cd), X(0x0534d7fa), X(0x053b1dd0), X(0x0541674e), + X(0x0547b475), X(0x054e0544), X(0x055459bb), X(0x055ab1d9), + X(0x05610d9e), X(0x05676d0a), X(0x056dd01c), X(0x057436d5), + X(0x057aa134), X(0x05810f38), X(0x058780e2), X(0x058df631), + X(0x05946f25), X(0x059aebbe), X(0x05a16bfa), X(0x05a7efdb), + X(0x05ae775f), X(0x05b50287), X(0x05bb9152), X(0x05c223c0), + X(0x05c8b9d0), X(0x05cf5382), X(0x05d5f0d6), X(0x05dc91cc), + X(0x05e33663), X(0x05e9de9c), X(0x05f08a75), X(0x05f739ee), + X(0x05fded07), X(0x0604a3c0), X(0x060b5e19), X(0x06121c11), + X(0x0618dda8), X(0x061fa2dd), X(0x06266bb1), X(0x062d3822), + X(0x06340831), X(0x063adbde), X(0x0641b328), X(0x06488e0e), + X(0x064f6c91), X(0x06564eaf), X(0x065d346a), X(0x06641dc0), + X(0x066b0ab1), X(0x0671fb3d), X(0x0678ef64), X(0x067fe724), + X(0x0686e27f), X(0x068de173), X(0x0694e400), X(0x069bea27), + X(0x06a2f3e6), X(0x06aa013d), X(0x06b1122c), X(0x06b826b3), + X(0x06bf3ed1), X(0x06c65a86), X(0x06cd79d1), X(0x06d49cb3), + X(0x06dbc32b), X(0x06e2ed38), X(0x06ea1adb), X(0x06f14c13), + X(0x06f880df), X(0x06ffb940), X(0x0706f535), X(0x070e34bd), + X(0x071577d9), X(0x071cbe88), X(0x072408c9), X(0x072b569d), + X(0x0732a802), X(0x0739fcf9), X(0x07415582), X(0x0748b19b), + X(0x07501145), X(0x0757747f), X(0x075edb49), X(0x076645a3), + X(0x076db38c), X(0x07752503), X(0x077c9a09), X(0x0784129e), + X(0x078b8ec0), X(0x07930e70), X(0x079a91ac), X(0x07a21876), + X(0x07a9a2cc), X(0x07b130ad), X(0x07b8c21b), X(0x07c05714), + X(0x07c7ef98), X(0x07cf8ba6), X(0x07d72b3f), X(0x07dece62), + X(0x07e6750e), X(0x07ee1f43), X(0x07f5cd01), X(0x07fd7e48), + X(0x08053316), X(0x080ceb6d), X(0x0814a74a), X(0x081c66af), + X(0x0824299a), X(0x082bf00c), X(0x0833ba03), X(0x083b8780), + X(0x08435882), X(0x084b2d09), X(0x08530514), X(0x085ae0a3), + X(0x0862bfb6), X(0x086aa24c), X(0x08728865), X(0x087a7201), + X(0x08825f1e), X(0x088a4fbe), X(0x089243de), X(0x089a3b80), + X(0x08a236a2), X(0x08aa3545), X(0x08b23767), X(0x08ba3d09), + X(0x08c2462a), X(0x08ca52c9), X(0x08d262e7), X(0x08da7682), + X(0x08e28d9c), X(0x08eaa832), X(0x08f2c645), X(0x08fae7d4), + X(0x09030cdf), X(0x090b3566), X(0x09136168), X(0x091b90e5), + X(0x0923c3dc), X(0x092bfa4d), X(0x09343437), X(0x093c719b), + X(0x0944b277), X(0x094cf6cc), X(0x09553e99), X(0x095d89dd), + X(0x0965d899), X(0x096e2acb), X(0x09768073), X(0x097ed991), + X(0x09873625), X(0x098f962e), X(0x0997f9ac), X(0x09a0609e), + X(0x09a8cb04), X(0x09b138dd), X(0x09b9aa29), X(0x09c21ee8), + X(0x09ca9719), X(0x09d312bc), X(0x09db91d0), X(0x09e41456), + X(0x09ec9a4b), X(0x09f523b1), X(0x09fdb087), X(0x0a0640cc), + X(0x0a0ed47f), X(0x0a176ba2), X(0x0a200632), X(0x0a28a42f), + X(0x0a31459a), X(0x0a39ea72), X(0x0a4292b5), X(0x0a4b3e65), + X(0x0a53ed80), X(0x0a5ca006), X(0x0a6555f7), X(0x0a6e0f51), + X(0x0a76cc16), X(0x0a7f8c44), X(0x0a884fda), X(0x0a9116d9), + X(0x0a99e140), X(0x0aa2af0e), X(0x0aab8043), X(0x0ab454df), + X(0x0abd2ce1), X(0x0ac60849), X(0x0acee716), X(0x0ad7c948), + X(0x0ae0aedf), X(0x0ae997d9), X(0x0af28437), X(0x0afb73f7), + X(0x0b04671b), X(0x0b0d5da0), X(0x0b165788), X(0x0b1f54d0), + X(0x0b285579), X(0x0b315983), X(0x0b3a60ec), X(0x0b436bb5), + X(0x0b4c79dd), X(0x0b558b63), X(0x0b5ea048), X(0x0b67b88a), + X(0x0b70d429), X(0x0b79f324), X(0x0b83157c), X(0x0b8c3b30), + X(0x0b95643f), X(0x0b9e90a8), X(0x0ba7c06c), X(0x0bb0f38a), + X(0x0bba2a01), X(0x0bc363d1), X(0x0bcca0f9), X(0x0bd5e17a), + X(0x0bdf2552), X(0x0be86c81), X(0x0bf1b706), X(0x0bfb04e2), + X(0x0c045613), X(0x0c0daa99), X(0x0c170274), X(0x0c205da3), + X(0x0c29bc25), X(0x0c331dfb), X(0x0c3c8323), X(0x0c45eb9e), + X(0x0c4f576a), X(0x0c58c688), X(0x0c6238f6), X(0x0c6baeb5), + X(0x0c7527c3), X(0x0c7ea421), X(0x0c8823cd), X(0x0c91a6c8), + X(0x0c9b2d10), X(0x0ca4b6a6), X(0x0cae4389), X(0x0cb7d3b8), + X(0x0cc16732), X(0x0ccafdf8), X(0x0cd49809), X(0x0cde3564), + X(0x0ce7d609), X(0x0cf179f7), X(0x0cfb212e), X(0x0d04cbad), + X(0x0d0e7974), X(0x0d182a83), X(0x0d21ded8), X(0x0d2b9673), + X(0x0d355154), X(0x0d3f0f7b), X(0x0d48d0e6), X(0x0d529595), + X(0x0d5c5d88), X(0x0d6628be), X(0x0d6ff737), X(0x0d79c8f2), + X(0x0d839dee), X(0x0d8d762c), X(0x0d9751aa), X(0x0da13068), + X(0x0dab1266), X(0x0db4f7a3), X(0x0dbee01e), X(0x0dc8cbd8), + X(0x0dd2bace), X(0x0ddcad02), X(0x0de6a272), X(0x0df09b1e), + X(0x0dfa9705), X(0x0e049627), X(0x0e0e9883), X(0x0e189e19), + X(0x0e22a6e8), X(0x0e2cb2f0), X(0x0e36c230), X(0x0e40d4a8), + X(0x0e4aea56), X(0x0e55033b), X(0x0e5f1f56), X(0x0e693ea7), + X(0x0e73612c), X(0x0e7d86e5), X(0x0e87afd3), X(0x0e91dbf3), + X(0x0e9c0b47), X(0x0ea63dcc), X(0x0eb07383), X(0x0ebaac6b), + X(0x0ec4e883), X(0x0ecf27cc), X(0x0ed96a44), X(0x0ee3afea), + X(0x0eedf8bf), X(0x0ef844c2), X(0x0f0293f2), X(0x0f0ce64e), + X(0x0f173bd6), X(0x0f21948a), X(0x0f2bf069), X(0x0f364f72), + X(0x0f40b1a5), X(0x0f4b1701), X(0x0f557f86), X(0x0f5feb32), + X(0x0f6a5a07), X(0x0f74cc02), X(0x0f7f4124), X(0x0f89b96b), + X(0x0f9434d8), X(0x0f9eb369), X(0x0fa9351e), X(0x0fb3b9f7), + X(0x0fbe41f3), X(0x0fc8cd11), X(0x0fd35b51), X(0x0fddecb2), + X(0x0fe88134), X(0x0ff318d6), X(0x0ffdb397), X(0x10085177), + X(0x1012f275), X(0x101d9691), X(0x10283dca), X(0x1032e81f), + X(0x103d9591), X(0x1048461e), X(0x1052f9c5), X(0x105db087), + X(0x10686a62), X(0x10732756), X(0x107de763), X(0x1088aa87), + X(0x109370c2), X(0x109e3a14), X(0x10a9067c), X(0x10b3d5f9), + X(0x10bea88b), X(0x10c97e31), X(0x10d456eb), X(0x10df32b8), + X(0x10ea1197), X(0x10f4f387), X(0x10ffd889), X(0x110ac09b), + X(0x1115abbe), X(0x112099ef), X(0x112b8b2f), X(0x11367f7d), + X(0x114176d9), X(0x114c7141), X(0x11576eb6), X(0x11626f36), + X(0x116d72c1), X(0x11787957), X(0x118382f6), X(0x118e8f9e), + X(0x11999f4f), X(0x11a4b208), X(0x11afc7c7), X(0x11bae08e), + X(0x11c5fc5a), X(0x11d11b2c), X(0x11dc3d02), X(0x11e761dd), + X(0x11f289ba), X(0x11fdb49b), X(0x1208e27e), X(0x12141362), + X(0x121f4748), X(0x122a7e2d), X(0x1235b812), X(0x1240f4f6), + X(0x124c34d9), X(0x125777b9), X(0x1262bd96), X(0x126e0670), + X(0x12795245), X(0x1284a115), X(0x128ff2e0), X(0x129b47a5), + X(0x12a69f63), X(0x12b1fa19), X(0x12bd57c7), X(0x12c8b86c), + X(0x12d41c08), X(0x12df829a), X(0x12eaec21), X(0x12f6589d), + X(0x1301c80c), X(0x130d3a6f), X(0x1318afc4), X(0x1324280b), + X(0x132fa344), X(0x133b216d), X(0x1346a286), X(0x1352268e), + X(0x135dad85), X(0x1369376a), X(0x1374c43c), X(0x138053fb), + X(0x138be6a5), X(0x13977c3b), X(0x13a314bc), X(0x13aeb026), + X(0x13ba4e79), X(0x13c5efb5), X(0x13d193d9), X(0x13dd3ae4), + X(0x13e8e4d6), X(0x13f491ad), X(0x1400416a), X(0x140bf40b), + X(0x1417a98f), X(0x142361f7), X(0x142f1d41), X(0x143adb6d), + X(0x14469c7a), X(0x14526067), X(0x145e2734), X(0x1469f0df), + X(0x1475bd69), X(0x14818cd0), X(0x148d5f15), X(0x14993435), + X(0x14a50c31), X(0x14b0e708), X(0x14bcc4b8), X(0x14c8a542), + X(0x14d488a5), X(0x14e06edf), X(0x14ec57f1), X(0x14f843d9), + X(0x15043297), X(0x1510242b), X(0x151c1892), X(0x15280fcd), + X(0x153409dc), X(0x154006bc), X(0x154c066e), X(0x155808f1), + X(0x15640e44), X(0x15701666), X(0x157c2157), X(0x15882f16), + X(0x15943fa2), X(0x15a052fb), X(0x15ac691f), X(0x15b8820f), + X(0x15c49dc8), X(0x15d0bc4c), X(0x15dcdd98), X(0x15e901ad), + X(0x15f52888), X(0x1601522b), X(0x160d7e93), X(0x1619adc1), + X(0x1625dfb3), X(0x16321469), X(0x163e4be2), X(0x164a861d), + X(0x1656c31a), X(0x166302d8), X(0x166f4555), X(0x167b8a92), + X(0x1687d28e), X(0x16941d47), X(0x16a06abe), X(0x16acbaf0), + X(0x16b90ddf), X(0x16c56388), X(0x16d1bbeb), X(0x16de1708), + X(0x16ea74dd), X(0x16f6d56a), X(0x170338ae), X(0x170f9ea8), + X(0x171c0758), X(0x172872bd), X(0x1734e0d6), X(0x174151a2), + X(0x174dc520), X(0x175a3b51), X(0x1766b432), X(0x17732fc4), + X(0x177fae05), X(0x178c2ef4), X(0x1798b292), X(0x17a538dd), + X(0x17b1c1d4), X(0x17be4d77), X(0x17cadbc5), X(0x17d76cbc), + X(0x17e4005e), X(0x17f096a7), X(0x17fd2f98), X(0x1809cb31), + X(0x1816696f), X(0x18230a53), X(0x182faddc), X(0x183c5408), + X(0x1848fcd8), X(0x1855a849), X(0x1862565d), X(0x186f0711), + X(0x187bba64), X(0x18887057), X(0x189528e9), X(0x18a1e418), + X(0x18aea1e3), X(0x18bb624b), X(0x18c8254e), X(0x18d4eaeb), + X(0x18e1b321), X(0x18ee7df1), X(0x18fb4b58), X(0x19081b57), + X(0x1914edec), X(0x1921c317), X(0x192e9ad6), X(0x193b7529), + X(0x19485210), X(0x19553189), X(0x19621393), X(0x196ef82e), + X(0x197bdf59), X(0x1988c913), X(0x1995b55c), X(0x19a2a432), + X(0x19af9595), X(0x19bc8983), X(0x19c97ffd), X(0x19d67900), + X(0x19e3748e), X(0x19f072a3), X(0x19fd7341), X(0x1a0a7665), + X(0x1a177c10), X(0x1a248440), X(0x1a318ef4), X(0x1a3e9c2c), + X(0x1a4babe7), X(0x1a58be24), X(0x1a65d2e2), X(0x1a72ea20), + X(0x1a8003de), X(0x1a8d201a), X(0x1a9a3ed5), X(0x1aa7600c), + X(0x1ab483bf), X(0x1ac1a9ee), X(0x1aced297), X(0x1adbfdba), + X(0x1ae92b56), X(0x1af65b69), X(0x1b038df4), X(0x1b10c2f5), + X(0x1b1dfa6b), X(0x1b2b3456), X(0x1b3870b5), X(0x1b45af87), + X(0x1b52f0ca), X(0x1b60347f), X(0x1b6d7aa4), X(0x1b7ac339), + X(0x1b880e3c), X(0x1b955bad), X(0x1ba2ab8b), X(0x1baffdd5), + X(0x1bbd528a), X(0x1bcaa9a9), X(0x1bd80332), X(0x1be55f24), + X(0x1bf2bd7d), X(0x1c001e3d), X(0x1c0d8164), X(0x1c1ae6ef), + X(0x1c284edf), X(0x1c35b932), X(0x1c4325e7), X(0x1c5094fe), + X(0x1c5e0677), X(0x1c6b7a4f), X(0x1c78f086), X(0x1c86691b), + X(0x1c93e40d), X(0x1ca1615c), X(0x1caee107), X(0x1cbc630c), + X(0x1cc9e76b), X(0x1cd76e23), X(0x1ce4f733), X(0x1cf2829a), + X(0x1d001057), X(0x1d0da06a), X(0x1d1b32d1), X(0x1d28c78c), + X(0x1d365e9a), X(0x1d43f7f9), X(0x1d5193a9), X(0x1d5f31aa), + X(0x1d6cd1f9), X(0x1d7a7497), X(0x1d881982), X(0x1d95c0ba), + X(0x1da36a3d), X(0x1db1160a), X(0x1dbec422), X(0x1dcc7482), + X(0x1dda272b), X(0x1de7dc1a), X(0x1df59350), X(0x1e034ccb), + X(0x1e11088a), X(0x1e1ec68c), X(0x1e2c86d1), X(0x1e3a4958), + X(0x1e480e20), X(0x1e55d527), X(0x1e639e6d), X(0x1e7169f1), + X(0x1e7f37b2), X(0x1e8d07b0), X(0x1e9ad9e8), X(0x1ea8ae5b), + X(0x1eb68507), X(0x1ec45dec), X(0x1ed23908), X(0x1ee0165b), + X(0x1eedf5e4), X(0x1efbd7a1), X(0x1f09bb92), X(0x1f17a1b6), + X(0x1f258a0d), X(0x1f337494), X(0x1f41614b), X(0x1f4f5032), + X(0x1f5d4147), X(0x1f6b3489), X(0x1f7929f7), X(0x1f872192), + X(0x1f951b56), X(0x1fa31744), X(0x1fb1155b), X(0x1fbf159a), + X(0x1fcd17ff), X(0x1fdb1c8b), X(0x1fe9233b), X(0x1ff72c0f), + X(0x20053706), X(0x20134420), X(0x2021535a), X(0x202f64b4), + X(0x203d782e), X(0x204b8dc6), X(0x2059a57c), X(0x2067bf4e), + X(0x2075db3b), X(0x2083f943), X(0x20921964), X(0x20a03b9e), + X(0x20ae5fef), X(0x20bc8657), X(0x20caaed5), X(0x20d8d967), + X(0x20e7060e), X(0x20f534c7), X(0x21036592), X(0x2111986e), + X(0x211fcd59), X(0x212e0454), X(0x213c3d5d), X(0x214a7873), + X(0x2158b594), X(0x2166f4c1), X(0x217535f8), X(0x21837938), + X(0x2191be81), X(0x21a005d0), X(0x21ae4f26), X(0x21bc9a81), + X(0x21cae7e0), X(0x21d93743), X(0x21e788a8), X(0x21f5dc0e), + X(0x22043174), X(0x221288da), X(0x2220e23e), X(0x222f3da0), + X(0x223d9afe), X(0x224bfa58), X(0x225a5bac), X(0x2268bef9), + X(0x2277243f), X(0x22858b7d), X(0x2293f4b0), X(0x22a25fda), + X(0x22b0ccf8), X(0x22bf3c09), X(0x22cdad0d), X(0x22dc2002), + X(0x22ea94e8), X(0x22f90bbe), X(0x23078482), X(0x2315ff33), + X(0x23247bd1), X(0x2332fa5b), X(0x23417acf), X(0x234ffd2c), + X(0x235e8173), X(0x236d07a0), X(0x237b8fb4), X(0x238a19ae), + X(0x2398a58c), X(0x23a7334d), X(0x23b5c2f1), X(0x23c45477), + X(0x23d2e7dd), X(0x23e17d22), X(0x23f01446), X(0x23fead47), + X(0x240d4825), X(0x241be4dd), X(0x242a8371), X(0x243923dd), + X(0x2447c622), X(0x24566a3e), X(0x24651031), X(0x2473b7f8), + X(0x24826194), X(0x24910d03), X(0x249fba44), X(0x24ae6957), + X(0x24bd1a39), X(0x24cbccea), X(0x24da816a), X(0x24e937b7), + X(0x24f7efcf), X(0x2506a9b3), X(0x25156560), X(0x252422d6), + X(0x2532e215), X(0x2541a31a), X(0x255065e4), X(0x255f2a74), + X(0x256df0c7), X(0x257cb8dd), X(0x258b82b4), X(0x259a4e4c), + X(0x25a91ba4), X(0x25b7eaba), X(0x25c6bb8e), X(0x25d58e1e), + X(0x25e46269), X(0x25f3386e), X(0x2602102d), X(0x2610e9a4), + X(0x261fc4d3), X(0x262ea1b7), X(0x263d8050), X(0x264c609e), + X(0x265b429e), X(0x266a2650), X(0x26790bb3), X(0x2687f2c6), + X(0x2696db88), X(0x26a5c5f7), X(0x26b4b213), X(0x26c39fda), + X(0x26d28f4c), X(0x26e18067), X(0x26f0732b), X(0x26ff6796), + X(0x270e5da7), X(0x271d555d), X(0x272c4eb7), X(0x273b49b5), + X(0x274a4654), X(0x27594495), X(0x27684475), X(0x277745f4), + X(0x27864910), X(0x27954dc9), X(0x27a4541e), X(0x27b35c0d), + X(0x27c26596), X(0x27d170b7), X(0x27e07d6f), X(0x27ef8bbd), + X(0x27fe9ba0), X(0x280dad18), X(0x281cc022), X(0x282bd4be), + X(0x283aeaeb), X(0x284a02a7), X(0x28591bf2), X(0x286836cb), + X(0x28775330), X(0x28867120), X(0x2895909b), X(0x28a4b19e), + X(0x28b3d42a), X(0x28c2f83d), X(0x28d21dd5), X(0x28e144f3), + X(0x28f06d94), X(0x28ff97b8), X(0x290ec35d), X(0x291df082), + X(0x292d1f27), X(0x293c4f4a), X(0x294b80eb), X(0x295ab407), + X(0x2969e89e), X(0x29791eaf), X(0x29885639), X(0x29978f3b), + X(0x29a6c9b3), X(0x29b605a0), X(0x29c54302), X(0x29d481d7), + X(0x29e3c21e), X(0x29f303d6), X(0x2a0246fd), X(0x2a118b94), + X(0x2a20d198), X(0x2a301909), X(0x2a3f61e6), X(0x2a4eac2c), + X(0x2a5df7dc), X(0x2a6d44f4), X(0x2a7c9374), X(0x2a8be359), + X(0x2a9b34a2), X(0x2aaa8750), X(0x2ab9db60), X(0x2ac930d1), + X(0x2ad887a3), X(0x2ae7dfd3), X(0x2af73962), X(0x2b06944e), + X(0x2b15f096), X(0x2b254e38), X(0x2b34ad34), X(0x2b440d89), + X(0x2b536f34), X(0x2b62d236), X(0x2b72368d), X(0x2b819c38), + X(0x2b910336), X(0x2ba06b86), X(0x2bafd526), X(0x2bbf4015), + X(0x2bceac53), X(0x2bde19de), X(0x2bed88b5), X(0x2bfcf8d7), + X(0x2c0c6a43), X(0x2c1bdcf7), X(0x2c2b50f3), X(0x2c3ac635), + X(0x2c4a3cbd), X(0x2c59b488), X(0x2c692d97), X(0x2c78a7e7), + X(0x2c882378), X(0x2c97a049), X(0x2ca71e58), X(0x2cb69da4), + X(0x2cc61e2c), X(0x2cd59ff0), X(0x2ce522ed), X(0x2cf4a723), + X(0x2d042c90), X(0x2d13b334), X(0x2d233b0d), X(0x2d32c41a), + X(0x2d424e5a), X(0x2d51d9cc), X(0x2d61666e), X(0x2d70f440), + X(0x2d808340), X(0x2d90136e), X(0x2d9fa4c7), X(0x2daf374c), + X(0x2dbecafa), X(0x2dce5fd1), X(0x2dddf5cf), X(0x2ded8cf4), + X(0x2dfd253d), X(0x2e0cbeab), X(0x2e1c593b), X(0x2e2bf4ed), + X(0x2e3b91c0), X(0x2e4b2fb1), X(0x2e5acec1), X(0x2e6a6eee), + X(0x2e7a1037), X(0x2e89b29b), X(0x2e995618), X(0x2ea8faad), + X(0x2eb8a05a), X(0x2ec8471c), X(0x2ed7eef4), X(0x2ee797df), + X(0x2ef741dc), X(0x2f06eceb), X(0x2f16990a), X(0x2f264639), + X(0x2f35f475), X(0x2f45a3bd), X(0x2f555412), X(0x2f650570), + X(0x2f74b7d8), X(0x2f846b48), X(0x2f941fbe), X(0x2fa3d53a), + X(0x2fb38bbb), X(0x2fc3433f), X(0x2fd2fbc5), X(0x2fe2b54c), + X(0x2ff26fd3), X(0x30022b58), X(0x3011e7db), X(0x3021a55a), + X(0x303163d4), X(0x30412348), X(0x3050e3b5), X(0x3060a519), + X(0x30706773), X(0x30802ac3), X(0x308fef06), X(0x309fb43d), + X(0x30af7a65), X(0x30bf417d), X(0x30cf0985), X(0x30ded27a), + X(0x30ee9c5d), X(0x30fe672b), X(0x310e32e3), X(0x311dff85), + X(0x312dcd0f), X(0x313d9b80), X(0x314d6ad7), X(0x315d3b12), + X(0x316d0c30), X(0x317cde31), X(0x318cb113), X(0x319c84d4), + X(0x31ac5974), X(0x31bc2ef1), X(0x31cc054b), X(0x31dbdc7f), + X(0x31ebb48e), X(0x31fb8d74), X(0x320b6733), X(0x321b41c7), + X(0x322b1d31), X(0x323af96e), X(0x324ad67e), X(0x325ab45f), + X(0x326a9311), X(0x327a7291), X(0x328a52e0), X(0x329a33fb), + X(0x32aa15e1), X(0x32b9f892), X(0x32c9dc0c), X(0x32d9c04d), + X(0x32e9a555), X(0x32f98b22), X(0x330971b4), X(0x33195909), + X(0x3329411f), X(0x333929f6), X(0x3349138c), X(0x3358fde1), + X(0x3368e8f2), X(0x3378d4c0), X(0x3388c147), X(0x3398ae89), + X(0x33a89c82), X(0x33b88b32), X(0x33c87a98), X(0x33d86ab2), + X(0x33e85b80), X(0x33f84d00), X(0x34083f30), X(0x34183210), + X(0x3428259f), X(0x343819db), X(0x34480ec3), X(0x34580455), + X(0x3467fa92), X(0x3477f176), X(0x3487e902), X(0x3497e134), + X(0x34a7da0a), X(0x34b7d384), X(0x34c7cda0), X(0x34d7c85e), + X(0x34e7c3bb), X(0x34f7bfb7), X(0x3507bc50), X(0x3517b985), + X(0x3527b756), X(0x3537b5c0), X(0x3547b4c3), X(0x3557b45d), + X(0x3567b48d), X(0x3577b552), X(0x3587b6aa), X(0x3597b895), + X(0x35a7bb12), X(0x35b7be1e), X(0x35c7c1b9), X(0x35d7c5e1), + X(0x35e7ca96), X(0x35f7cfd6), X(0x3607d5a0), X(0x3617dbf3), + X(0x3627e2cd), X(0x3637ea2d), X(0x3647f212), X(0x3657fa7b), + X(0x36680366), X(0x36780cd2), X(0x368816bf), X(0x3698212b), + X(0x36a82c14), X(0x36b83779), X(0x36c8435a), X(0x36d84fb4), + X(0x36e85c88), X(0x36f869d2), X(0x37087793), X(0x371885c9), + X(0x37289473), X(0x3738a38f), X(0x3748b31d), X(0x3758c31a), + X(0x3768d387), X(0x3778e461), X(0x3788f5a7), X(0x37990759), + X(0x37a91975), X(0x37b92bf9), X(0x37c93ee4), X(0x37d95236), + X(0x37e965ed), X(0x37f97a08), X(0x38098e85), X(0x3819a363), + X(0x3829b8a2), X(0x3839ce3f), X(0x3849e43a), X(0x3859fa91), + X(0x386a1143), X(0x387a284f), X(0x388a3fb4), X(0x389a5770), + X(0x38aa6f83), X(0x38ba87ea), X(0x38caa0a5), X(0x38dab9b2), + X(0x38ead311), X(0x38faecbf), X(0x390b06bc), X(0x391b2107), + X(0x392b3b9e), X(0x393b5680), X(0x394b71ac), X(0x395b8d20), + X(0x396ba8dc), X(0x397bc4dd), X(0x398be124), X(0x399bfdae), + X(0x39ac1a7a), X(0x39bc3788), X(0x39cc54d5), X(0x39dc7261), + X(0x39ec902a), X(0x39fcae2f), X(0x3a0ccc70), X(0x3a1ceaea), + X(0x3a2d099c), X(0x3a3d2885), X(0x3a4d47a5), X(0x3a5d66f9), + X(0x3a6d8680), X(0x3a7da63a), X(0x3a8dc625), X(0x3a9de63f), + X(0x3aae0688), X(0x3abe26fe), X(0x3ace47a0), X(0x3ade686d), + X(0x3aee8963), X(0x3afeaa82), X(0x3b0ecbc7), X(0x3b1eed32), + X(0x3b2f0ec2), X(0x3b3f3075), X(0x3b4f524a), X(0x3b5f7440), + X(0x3b6f9656), X(0x3b7fb889), X(0x3b8fdada), X(0x3b9ffd46), + X(0x3bb01fce), X(0x3bc0426e), X(0x3bd06526), X(0x3be087f6), + X(0x3bf0aada), X(0x3c00cdd4), X(0x3c10f0e0), X(0x3c2113fe), + X(0x3c31372d), X(0x3c415a6b), X(0x3c517db7), X(0x3c61a110), + X(0x3c71c475), X(0x3c81e7e4), X(0x3c920b5c), X(0x3ca22edc), + X(0x3cb25262), X(0x3cc275ee), X(0x3cd2997e), X(0x3ce2bd11), + X(0x3cf2e0a6), X(0x3d03043b), X(0x3d1327cf), X(0x3d234b61), + X(0x3d336ef0), X(0x3d43927a), X(0x3d53b5ff), X(0x3d63d97c), + X(0x3d73fcf1), X(0x3d84205c), X(0x3d9443bd), X(0x3da46711), + X(0x3db48a58), X(0x3dc4ad91), X(0x3dd4d0ba), X(0x3de4f3d1), + X(0x3df516d7), X(0x3e0539c9), X(0x3e155ca6), X(0x3e257f6d), + X(0x3e35a21d), X(0x3e45c4b4), X(0x3e55e731), X(0x3e660994), + X(0x3e762bda), X(0x3e864e03), X(0x3e96700d), X(0x3ea691f7), + X(0x3eb6b3bf), X(0x3ec6d565), X(0x3ed6f6e8), X(0x3ee71845), + X(0x3ef7397c), X(0x3f075a8c), X(0x3f177b73), X(0x3f279c30), + X(0x3f37bcc2), X(0x3f47dd27), X(0x3f57fd5f), X(0x3f681d68), + X(0x3f783d40), X(0x3f885ce7), X(0x3f987c5c), X(0x3fa89b9c), + X(0x3fb8baa7), X(0x3fc8d97c), X(0x3fd8f819), X(0x3fe9167e), + X(0x3ff934a8), X(0x40095296), X(0x40197049), X(0x40298dbd), + X(0x4039aaf2), X(0x4049c7e7), X(0x4059e49a), X(0x406a010a), + X(0x407a1d36), X(0x408a391d), X(0x409a54bd), X(0x40aa7015), + X(0x40ba8b25), X(0x40caa5ea), X(0x40dac063), X(0x40eada90), + X(0x40faf46e), X(0x410b0dfe), X(0x411b273d), X(0x412b402a), + X(0x413b58c4), X(0x414b710a), X(0x415b88fa), X(0x416ba093), + X(0x417bb7d5), X(0x418bcebe), X(0x419be54c), X(0x41abfb7e), + X(0x41bc1153), X(0x41cc26ca), X(0x41dc3be2), X(0x41ec5099), + X(0x41fc64ef), X(0x420c78e1), X(0x421c8c6f), X(0x422c9f97), + X(0x423cb258), X(0x424cc4b2), X(0x425cd6a2), X(0x426ce827), + X(0x427cf941), X(0x428d09ee), X(0x429d1a2c), X(0x42ad29fb), + X(0x42bd3959), X(0x42cd4846), X(0x42dd56bf), X(0x42ed64c3), + X(0x42fd7252), X(0x430d7f6a), X(0x431d8c0a), X(0x432d9831), + X(0x433da3dd), X(0x434daf0d), X(0x435db9c0), X(0x436dc3f5), + X(0x437dcdab), X(0x438dd6df), X(0x439ddf92), X(0x43ade7c1), + X(0x43bdef6c), X(0x43cdf691), X(0x43ddfd2f), X(0x43ee0345), + X(0x43fe08d2), X(0x440e0dd4), X(0x441e124b), X(0x442e1634), + X(0x443e198f), X(0x444e1c5a), X(0x445e1e95), X(0x446e203e), + X(0x447e2153), X(0x448e21d5), X(0x449e21c0), X(0x44ae2115), + X(0x44be1fd1), X(0x44ce1df4), X(0x44de1b7d), X(0x44ee186a), + X(0x44fe14ba), X(0x450e106b), X(0x451e0b7e), X(0x452e05ef), + X(0x453dffbf), X(0x454df8eb), X(0x455df173), X(0x456de956), + X(0x457de092), X(0x458dd726), X(0x459dcd10), X(0x45adc251), + X(0x45bdb6e5), X(0x45cdaacd), X(0x45dd9e06), X(0x45ed9091), + X(0x45fd826a), X(0x460d7392), X(0x461d6407), X(0x462d53c8), + X(0x463d42d4), X(0x464d3129), X(0x465d1ec6), X(0x466d0baa), + X(0x467cf7d3), X(0x468ce342), X(0x469ccdf3), X(0x46acb7e7), + X(0x46bca11c), X(0x46cc8990), X(0x46dc7143), X(0x46ec5833), + X(0x46fc3e5f), X(0x470c23c6), X(0x471c0867), X(0x472bec40), + X(0x473bcf50), X(0x474bb196), X(0x475b9311), X(0x476b73c0), + X(0x477b53a1), X(0x478b32b4), X(0x479b10f6), X(0x47aaee67), + X(0x47bacb06), X(0x47caa6d1), X(0x47da81c7), X(0x47ea5be7), + X(0x47fa3530), X(0x480a0da1), X(0x4819e537), X(0x4829bbf3), + X(0x483991d3), X(0x484966d6), X(0x48593afb), X(0x48690e3f), + X(0x4878e0a3), X(0x4888b225), X(0x489882c4), X(0x48a8527e), + X(0x48b82153), X(0x48c7ef41), X(0x48d7bc47), X(0x48e78863), + X(0x48f75396), X(0x49071ddc), X(0x4916e736), X(0x4926afa2), + X(0x4936771f), X(0x49463dac), X(0x49560347), X(0x4965c7ef), + X(0x49758ba4), X(0x49854e63), X(0x4995102c), X(0x49a4d0fe), + X(0x49b490d7), X(0x49c44fb6), X(0x49d40d9a), X(0x49e3ca82), + X(0x49f3866c), X(0x4a034159), X(0x4a12fb45), X(0x4a22b430), + X(0x4a326c19), X(0x4a4222ff), X(0x4a51d8e1), X(0x4a618dbd), + X(0x4a714192), X(0x4a80f45f), X(0x4a90a623), X(0x4aa056dd), + X(0x4ab0068b), X(0x4abfb52c), X(0x4acf62c0), X(0x4adf0f44), + X(0x4aeebab9), X(0x4afe651c), X(0x4b0e0e6c), X(0x4b1db6a9), + X(0x4b2d5dd1), X(0x4b3d03e2), X(0x4b4ca8dd), X(0x4b5c4cbf), + X(0x4b6bef88), X(0x4b7b9136), X(0x4b8b31c8), X(0x4b9ad13d), + X(0x4baa6f93), X(0x4bba0ccb), X(0x4bc9a8e2), X(0x4bd943d7), + X(0x4be8dda9), X(0x4bf87658), X(0x4c080de1), X(0x4c17a444), + X(0x4c27397f), X(0x4c36cd92), X(0x4c46607b), X(0x4c55f239), + X(0x4c6582cb), X(0x4c75122f), X(0x4c84a065), X(0x4c942d6c), + X(0x4ca3b942), X(0x4cb343e6), X(0x4cc2cd57), X(0x4cd25594), + X(0x4ce1dc9c), X(0x4cf1626d), X(0x4d00e707), X(0x4d106a68), + X(0x4d1fec8f), X(0x4d2f6d7a), X(0x4d3eed2a), X(0x4d4e6b9d), + X(0x4d5de8d1), X(0x4d6d64c5), X(0x4d7cdf79), X(0x4d8c58eb), + X(0x4d9bd11a), X(0x4dab4804), X(0x4dbabdaa), X(0x4dca3209), + X(0x4dd9a520), X(0x4de916ef), X(0x4df88774), X(0x4e07f6ae), + X(0x4e17649c), X(0x4e26d13c), X(0x4e363c8f), X(0x4e45a692), + X(0x4e550f44), X(0x4e6476a4), X(0x4e73dcb2), X(0x4e83416c), + X(0x4e92a4d1), X(0x4ea206df), X(0x4eb16796), X(0x4ec0c6f5), + X(0x4ed024fa), X(0x4edf81a5), X(0x4eeedcf3), X(0x4efe36e5), + X(0x4f0d8f79), X(0x4f1ce6ad), X(0x4f2c3c82), X(0x4f3b90f4), + X(0x4f4ae405), X(0x4f5a35b1), X(0x4f6985fa), X(0x4f78d4dc), + X(0x4f882257), X(0x4f976e6a), X(0x4fa6b914), X(0x4fb60254), + X(0x4fc54a28), X(0x4fd49090), X(0x4fe3d58b), X(0x4ff31917), + X(0x50025b33), X(0x50119bde), X(0x5020db17), X(0x503018dd), + X(0x503f552f), X(0x504e900b), X(0x505dc971), X(0x506d0160), + X(0x507c37d7), X(0x508b6cd3), X(0x509aa055), X(0x50a9d25b), + X(0x50b902e4), X(0x50c831ef), X(0x50d75f7b), X(0x50e68b87), + X(0x50f5b612), X(0x5104df1a), X(0x5114069f), X(0x51232ca0), + X(0x5132511a), X(0x5141740f), X(0x5150957b), X(0x515fb55f), + X(0x516ed3b8), X(0x517df087), X(0x518d0bca), X(0x519c257f), + X(0x51ab3da7), X(0x51ba543f), X(0x51c96947), X(0x51d87cbd), + X(0x51e78ea1), X(0x51f69ef1), X(0x5205adad), X(0x5214bad3), + X(0x5223c662), X(0x5232d05a), X(0x5241d8b9), X(0x5250df7d), + X(0x525fe4a7), X(0x526ee835), X(0x527dea26), X(0x528cea78), + X(0x529be92c), X(0x52aae63f), X(0x52b9e1b0), X(0x52c8db80), + X(0x52d7d3ac), X(0x52e6ca33), X(0x52f5bf15), X(0x5304b251), + X(0x5313a3e5), X(0x532293d0), X(0x53318212), X(0x53406ea8), + X(0x534f5993), X(0x535e42d2), X(0x536d2a62), X(0x537c1043), + X(0x538af475), X(0x5399d6f6), X(0x53a8b7c4), X(0x53b796e0), + X(0x53c67447), X(0x53d54ffa), X(0x53e429f6), X(0x53f3023b), + X(0x5401d8c8), X(0x5410ad9c), X(0x541f80b5), X(0x542e5213), + X(0x543d21b5), X(0x544bef9a), X(0x545abbc0), X(0x54698627), + X(0x54784ece), X(0x548715b3), X(0x5495dad6), X(0x54a49e35), + X(0x54b35fd0), X(0x54c21fa6), X(0x54d0ddb5), X(0x54df99fd), + X(0x54ee547c), X(0x54fd0d32), X(0x550bc41d), X(0x551a793d), + X(0x55292c91), X(0x5537de16), X(0x55468dce), X(0x55553bb6), + X(0x5563e7cd), X(0x55729213), X(0x55813a87), X(0x558fe127), + X(0x559e85f2), X(0x55ad28e9), X(0x55bbca08), X(0x55ca6950), + X(0x55d906c0), X(0x55e7a257), X(0x55f63c13), X(0x5604d3f4), + X(0x561369f8), X(0x5621fe1f), X(0x56309067), X(0x563f20d1), + X(0x564daf5a), X(0x565c3c02), X(0x566ac6c7), X(0x56794faa), + X(0x5687d6a8), X(0x56965bc1), X(0x56a4def4), X(0x56b36040), + X(0x56c1dfa4), X(0x56d05d1f), X(0x56ded8af), X(0x56ed5255), + X(0x56fbca0f), X(0x570a3fdc), X(0x5718b3bc), X(0x572725ac), + X(0x573595ad), X(0x574403bd), X(0x57526fdb), X(0x5760da07), + X(0x576f423f), X(0x577da883), X(0x578c0cd1), X(0x579a6f29), + X(0x57a8cf8a), X(0x57b72df2), X(0x57c58a61), X(0x57d3e4d6), + X(0x57e23d50), X(0x57f093cd), X(0x57fee84e), X(0x580d3ad1), + X(0x581b8b54), X(0x5829d9d8), X(0x5838265c), X(0x584670dd), + X(0x5854b95c), X(0x5862ffd8), X(0x5871444f), X(0x587f86c1), + X(0x588dc72c), X(0x589c0591), X(0x58aa41ed), X(0x58b87c40), + X(0x58c6b489), X(0x58d4eac7), X(0x58e31ef9), X(0x58f1511f), + X(0x58ff8137), X(0x590daf40), X(0x591bdb3a), X(0x592a0524), + X(0x59382cfc), X(0x594652c2), X(0x59547675), X(0x59629815), + X(0x5970b79f), X(0x597ed513), X(0x598cf071), X(0x599b09b7), + X(0x59a920e5), X(0x59b735f9), X(0x59c548f4), X(0x59d359d2), + X(0x59e16895), X(0x59ef753b), X(0x59fd7fc4), X(0x5a0b882d), + X(0x5a198e77), X(0x5a2792a0), X(0x5a3594a9), X(0x5a43948e), + X(0x5a519251), X(0x5a5f8df0), X(0x5a6d876a), X(0x5a7b7ebe), + X(0x5a8973ec), X(0x5a9766f2), X(0x5aa557d0), X(0x5ab34685), + X(0x5ac1330f), X(0x5acf1d6f), X(0x5add05a3), X(0x5aeaebaa), + X(0x5af8cf84), X(0x5b06b12f), X(0x5b1490ab), X(0x5b226df7), + X(0x5b304912), X(0x5b3e21fc), X(0x5b4bf8b2), X(0x5b59cd35), + X(0x5b679f84), X(0x5b756f9e), X(0x5b833d82), X(0x5b91092e), + X(0x5b9ed2a3), X(0x5bac99e0), X(0x5bba5ee3), X(0x5bc821ac), + X(0x5bd5e23a), X(0x5be3a08c), X(0x5bf15ca1), X(0x5bff1679), + X(0x5c0cce12), X(0x5c1a836c), X(0x5c283686), X(0x5c35e760), + X(0x5c4395f7), X(0x5c51424c), X(0x5c5eec5e), X(0x5c6c942b), + X(0x5c7a39b4), X(0x5c87dcf7), X(0x5c957df3), X(0x5ca31ca8), + X(0x5cb0b915), X(0x5cbe5338), X(0x5ccbeb12), X(0x5cd980a1), + X(0x5ce713e5), X(0x5cf4a4dd), X(0x5d023387), X(0x5d0fbfe4), + X(0x5d1d49f2), X(0x5d2ad1b1), X(0x5d38571f), X(0x5d45da3c), + X(0x5d535b08), X(0x5d60d981), X(0x5d6e55a7), X(0x5d7bcf78), + X(0x5d8946f5), X(0x5d96bc1c), X(0x5da42eec), X(0x5db19f65), + X(0x5dbf0d86), X(0x5dcc794e), X(0x5dd9e2bd), X(0x5de749d1), + X(0x5df4ae8a), X(0x5e0210e7), X(0x5e0f70e7), X(0x5e1cce8a), + X(0x5e2a29ce), X(0x5e3782b4), X(0x5e44d93a), X(0x5e522d5f), + X(0x5e5f7f23), X(0x5e6cce85), X(0x5e7a1b85), X(0x5e876620), + X(0x5e94ae58), X(0x5ea1f42a), X(0x5eaf3797), X(0x5ebc789d), + X(0x5ec9b73c), X(0x5ed6f372), X(0x5ee42d41), X(0x5ef164a5), + X(0x5efe999f), X(0x5f0bcc2f), X(0x5f18fc52), X(0x5f262a09), + X(0x5f335553), X(0x5f407e2f), X(0x5f4da49d), X(0x5f5ac89b), + X(0x5f67ea29), X(0x5f750946), X(0x5f8225f2), X(0x5f8f402b), + X(0x5f9c57f2), X(0x5fa96d44), X(0x5fb68023), X(0x5fc3908c), + X(0x5fd09e7f), X(0x5fdda9fc), X(0x5feab302), X(0x5ff7b990), + X(0x6004bda5), X(0x6011bf40), X(0x601ebe62), X(0x602bbb09), + X(0x6038b534), X(0x6045ace4), X(0x6052a216), X(0x605f94cb), + X(0x606c8502), X(0x607972b9), X(0x60865df2), X(0x609346aa), + X(0x60a02ce1), X(0x60ad1096), X(0x60b9f1c9), X(0x60c6d079), + X(0x60d3aca5), X(0x60e0864d), X(0x60ed5d70), X(0x60fa320d), + X(0x61070424), X(0x6113d3b4), X(0x6120a0bc), X(0x612d6b3c), + X(0x613a3332), X(0x6146f89f), X(0x6153bb82), X(0x61607bd9), + X(0x616d39a5), X(0x6179f4e5), X(0x6186ad98), X(0x619363bd), + X(0x61a01753), X(0x61acc85b), X(0x61b976d3), X(0x61c622bc), + X(0x61d2cc13), X(0x61df72d8), X(0x61ec170c), X(0x61f8b8ad), + X(0x620557ba), X(0x6211f434), X(0x621e8e18), X(0x622b2568), + X(0x6237ba21), X(0x62444c44), X(0x6250dbd0), X(0x625d68c4), + X(0x6269f320), X(0x62767ae2), X(0x6283000b), X(0x628f829a), + X(0x629c028e), X(0x62a87fe6), X(0x62b4faa2), X(0x62c172c2), + X(0x62cde844), X(0x62da5b29), X(0x62e6cb6e), X(0x62f33915), + X(0x62ffa41c), X(0x630c0c83), X(0x63187248), X(0x6324d56d), + X(0x633135ef), X(0x633d93ce), X(0x6349ef0b), X(0x635647a3), + X(0x63629d97), X(0x636ef0e6), X(0x637b418f), X(0x63878f92), + X(0x6393daef), X(0x63a023a4), X(0x63ac69b1), X(0x63b8ad15), + X(0x63c4edd1), X(0x63d12be3), X(0x63dd674b), X(0x63e9a008), + X(0x63f5d61a), X(0x64020980), X(0x640e3a39), X(0x641a6846), + X(0x642693a5), X(0x6432bc56), X(0x643ee258), X(0x644b05ab), + X(0x6457264e), X(0x64634441), X(0x646f5f83), X(0x647b7814), + X(0x64878df3), X(0x6493a120), X(0x649fb199), X(0x64abbf5f), + X(0x64b7ca71), X(0x64c3d2ce), X(0x64cfd877), X(0x64dbdb69), + X(0x64e7dba6), X(0x64f3d92b), X(0x64ffd3fa), X(0x650bcc11), + X(0x6517c16f), X(0x6523b415), X(0x652fa402), X(0x653b9134), + X(0x65477bad), X(0x6553636a), X(0x655f486d), X(0x656b2ab3), + X(0x65770a3d), X(0x6582e70a), X(0x658ec11a), X(0x659a986d), + X(0x65a66d00), X(0x65b23ed5), X(0x65be0deb), X(0x65c9da41), + X(0x65d5a3d7), X(0x65e16aac), X(0x65ed2ebf), X(0x65f8f011), + X(0x6604aea1), X(0x66106a6e), X(0x661c2377), X(0x6627d9be), + X(0x66338d40), X(0x663f3dfd), X(0x664aebf5), X(0x66569728), + X(0x66623f95), X(0x666de53b), X(0x6679881b), X(0x66852833), + X(0x6690c583), X(0x669c600b), X(0x66a7f7ca), X(0x66b38cc0), + X(0x66bf1eec), X(0x66caae4f), X(0x66d63ae6), X(0x66e1c4b3), + X(0x66ed4bb4), X(0x66f8cfea), X(0x67045153), X(0x670fcfef), + X(0x671b4bbe), X(0x6726c4bf), X(0x67323af3), X(0x673dae58), + X(0x67491eee), X(0x67548cb5), X(0x675ff7ab), X(0x676b5fd2), + X(0x6776c528), X(0x678227ad), X(0x678d8761), X(0x6798e443), + X(0x67a43e52), X(0x67af958f), X(0x67bae9f9), X(0x67c63b8f), + X(0x67d18a52), X(0x67dcd640), X(0x67e81f59), X(0x67f3659d), + X(0x67fea90c), X(0x6809e9a5), X(0x68152768), X(0x68206254), + X(0x682b9a68), X(0x6836cfa6), X(0x6842020b), X(0x684d3199), + X(0x68585e4d), X(0x68638829), X(0x686eaf2b), X(0x6879d354), + X(0x6884f4a2), X(0x68901316), X(0x689b2eb0), X(0x68a6476d), + X(0x68b15d50), X(0x68bc7056), X(0x68c78080), X(0x68d28dcd), + X(0x68dd983e), X(0x68e89fd0), X(0x68f3a486), X(0x68fea65d), + X(0x6909a555), X(0x6914a16f), X(0x691f9aa9), X(0x692a9104), + X(0x69358480), X(0x6940751b), X(0x694b62d5), X(0x69564daf), + X(0x696135a7), X(0x696c1abe), X(0x6976fcf3), X(0x6981dc46), + X(0x698cb8b6), X(0x69979243), X(0x69a268ed), X(0x69ad3cb4), + X(0x69b80d97), X(0x69c2db96), X(0x69cda6b0), X(0x69d86ee5), + X(0x69e33436), X(0x69edf6a1), X(0x69f8b626), X(0x6a0372c5), + X(0x6a0e2c7e), X(0x6a18e350), X(0x6a23973c), X(0x6a2e4840), + X(0x6a38f65d), X(0x6a43a191), X(0x6a4e49de), X(0x6a58ef42), + X(0x6a6391be), X(0x6a6e3151), X(0x6a78cdfa), X(0x6a8367ba), + X(0x6a8dfe90), X(0x6a98927c), X(0x6aa3237d), X(0x6aadb194), + X(0x6ab83cc0), X(0x6ac2c500), X(0x6acd4a55), X(0x6ad7ccbf), + X(0x6ae24c3c), X(0x6aecc8cd), X(0x6af74271), X(0x6b01b929), + X(0x6b0c2cf4), X(0x6b169dd1), X(0x6b210bc1), X(0x6b2b76c2), + X(0x6b35ded6), X(0x6b4043fc), X(0x6b4aa632), X(0x6b55057a), + X(0x6b5f61d3), X(0x6b69bb3d), X(0x6b7411b7), X(0x6b7e6541), + X(0x6b88b5db), X(0x6b930385), X(0x6b9d4e3f), X(0x6ba79607), + X(0x6bb1dadf), X(0x6bbc1cc6), X(0x6bc65bbb), X(0x6bd097bf), + X(0x6bdad0d0), X(0x6be506f0), X(0x6bef3a1d), X(0x6bf96a58), + X(0x6c0397a0), X(0x6c0dc1f5), X(0x6c17e957), X(0x6c220dc6), + X(0x6c2c2f41), X(0x6c364dc9), X(0x6c40695c), X(0x6c4a81fc), + X(0x6c5497a7), X(0x6c5eaa5d), X(0x6c68ba1f), X(0x6c72c6eb), + X(0x6c7cd0c3), X(0x6c86d7a6), X(0x6c90db92), X(0x6c9adc8a), + X(0x6ca4da8b), X(0x6caed596), X(0x6cb8cdab), X(0x6cc2c2ca), + X(0x6cccb4f2), X(0x6cd6a424), X(0x6ce0905e), X(0x6cea79a1), + X(0x6cf45fee), X(0x6cfe4342), X(0x6d0823a0), X(0x6d120105), + X(0x6d1bdb73), X(0x6d25b2e8), X(0x6d2f8765), X(0x6d3958ea), + X(0x6d432777), X(0x6d4cf30a), X(0x6d56bba5), X(0x6d608147), + X(0x6d6a43f0), X(0x6d7403a0), X(0x6d7dc056), X(0x6d877a13), + X(0x6d9130d6), X(0x6d9ae4a0), X(0x6da4956f), X(0x6dae4345), + X(0x6db7ee20), X(0x6dc19601), X(0x6dcb3ae7), X(0x6dd4dcd3), + X(0x6dde7bc4), X(0x6de817bb), X(0x6df1b0b6), X(0x6dfb46b7), + X(0x6e04d9bc), X(0x6e0e69c7), X(0x6e17f6d5), X(0x6e2180e9), + X(0x6e2b0801), X(0x6e348c1d), X(0x6e3e0d3d), X(0x6e478b62), + X(0x6e51068a), X(0x6e5a7eb7), X(0x6e63f3e7), X(0x6e6d661b), + X(0x6e76d552), X(0x6e80418e), X(0x6e89aacc), X(0x6e93110f), + X(0x6e9c7454), X(0x6ea5d49d), X(0x6eaf31e9), X(0x6eb88c37), + X(0x6ec1e389), X(0x6ecb37de), X(0x6ed48936), X(0x6eddd790), + X(0x6ee722ee), X(0x6ef06b4d), X(0x6ef9b0b0), X(0x6f02f315), + X(0x6f0c327c), X(0x6f156ee6), X(0x6f1ea852), X(0x6f27dec1), + X(0x6f311232), X(0x6f3a42a5), X(0x6f43701a), X(0x6f4c9a91), + X(0x6f55c20a), X(0x6f5ee686), X(0x6f680803), X(0x6f712682), + X(0x6f7a4203), X(0x6f835a86), X(0x6f8c700b), X(0x6f958291), + X(0x6f9e921a), X(0x6fa79ea4), X(0x6fb0a830), X(0x6fb9aebd), + X(0x6fc2b24c), X(0x6fcbb2dd), X(0x6fd4b06f), X(0x6fddab03), + X(0x6fe6a299), X(0x6fef9730), X(0x6ff888c9), X(0x70017763), + X(0x700a62ff), X(0x70134b9c), X(0x701c313b), X(0x702513dc), + X(0x702df37e), X(0x7036d021), X(0x703fa9c6), X(0x7048806d), + X(0x70515415), X(0x705a24bf), X(0x7062f26b), X(0x706bbd17), + X(0x707484c6), X(0x707d4976), X(0x70860b28), X(0x708ec9dc), + X(0x70978591), X(0x70a03e48), X(0x70a8f400), X(0x70b1a6bb), + X(0x70ba5677), X(0x70c30335), X(0x70cbacf5), X(0x70d453b6), + X(0x70dcf77a), X(0x70e59840), X(0x70ee3607), X(0x70f6d0d1), + X(0x70ff689d), X(0x7107fd6b), X(0x71108f3b), X(0x71191e0d), + X(0x7121a9e2), X(0x712a32b9), X(0x7132b892), X(0x713b3b6e), + X(0x7143bb4c), X(0x714c382d), X(0x7154b211), X(0x715d28f7), + X(0x71659ce0), X(0x716e0dcc), X(0x71767bbb), X(0x717ee6ac), + X(0x71874ea1), X(0x718fb399), X(0x71981594), X(0x71a07493), + X(0x71a8d094), X(0x71b1299a), X(0x71b97fa2), X(0x71c1d2af), + X(0x71ca22bf), X(0x71d26fd2), X(0x71dab9ea), X(0x71e30106), + X(0x71eb4526), X(0x71f3864a), X(0x71fbc472), X(0x7203ff9e), + X(0x720c37cf), X(0x72146d05), X(0x721c9f3f), X(0x7224ce7e), + X(0x722cfac2), X(0x7235240b), X(0x723d4a59), X(0x72456dad), + X(0x724d8e05), X(0x7255ab63), X(0x725dc5c7), X(0x7265dd31), + X(0x726df1a0), X(0x72760315), X(0x727e1191), X(0x72861d12), + X(0x728e259a), X(0x72962b28), X(0x729e2dbd), X(0x72a62d59), + X(0x72ae29fc), X(0x72b623a5), X(0x72be1a56), X(0x72c60e0e), + X(0x72cdfece), X(0x72d5ec95), X(0x72ddd764), X(0x72e5bf3b), + X(0x72eda41a), X(0x72f58601), X(0x72fd64f1), X(0x730540e9), + X(0x730d19e9), X(0x7314eff3), X(0x731cc305), X(0x73249321), + X(0x732c6046), X(0x73342a75), X(0x733bf1ad), X(0x7343b5ef), + X(0x734b773b), X(0x73533591), X(0x735af0f2), X(0x7362a95d), + X(0x736a5ed3), X(0x73721153), X(0x7379c0df), X(0x73816d76), + X(0x73891719), X(0x7390bdc7), X(0x73986181), X(0x73a00247), + X(0x73a7a01a), X(0x73af3af8), X(0x73b6d2e4), X(0x73be67dc), + X(0x73c5f9e1), X(0x73cd88f3), X(0x73d51513), X(0x73dc9e40), + X(0x73e4247c), X(0x73eba7c5), X(0x73f3281c), X(0x73faa582), + X(0x74021ff7), X(0x7409977b), X(0x74110c0d), X(0x74187daf), + X(0x741fec61), X(0x74275822), X(0x742ec0f3), X(0x743626d5), + X(0x743d89c7), X(0x7444e9c9), X(0x744c46dd), X(0x7453a101), + X(0x745af837), X(0x74624c7f), X(0x74699dd8), X(0x7470ec44), + X(0x747837c2), X(0x747f8052), X(0x7486c5f5), X(0x748e08ac), + X(0x74954875), X(0x749c8552), X(0x74a3bf43), X(0x74aaf648), + X(0x74b22a62), X(0x74b95b90), X(0x74c089d2), X(0x74c7b52a), + X(0x74cedd97), X(0x74d6031a), X(0x74dd25b2), X(0x74e44561), + X(0x74eb6226), X(0x74f27c02), X(0x74f992f5), X(0x7500a6ff), + X(0x7507b820), X(0x750ec659), X(0x7515d1aa), X(0x751cda14), + X(0x7523df96), X(0x752ae231), X(0x7531e1e5), X(0x7538deb2), + X(0x753fd89a), X(0x7546cf9b), X(0x754dc3b7), X(0x7554b4ed), + X(0x755ba33e), X(0x75628eaa), X(0x75697732), X(0x75705cd5), + X(0x75773f95), X(0x757e1f71), X(0x7584fc6a), X(0x758bd67f), + X(0x7592adb2), X(0x75998203), X(0x75a05371), X(0x75a721fe), + X(0x75adeda9), X(0x75b4b673), X(0x75bb7c5c), X(0x75c23f65), + X(0x75c8ff8d), X(0x75cfbcd6), X(0x75d6773f), X(0x75dd2ec8), + X(0x75e3e373), X(0x75ea953f), X(0x75f1442d), X(0x75f7f03d), + X(0x75fe996f), X(0x76053fc5), X(0x760be33d), X(0x761283d8), + X(0x76192197), X(0x761fbc7b), X(0x76265482), X(0x762ce9af), + X(0x76337c01), X(0x763a0b78), X(0x76409814), X(0x764721d7), + X(0x764da8c1), X(0x76542cd1), X(0x765aae08), X(0x76612c67), + X(0x7667a7ee), X(0x766e209d), X(0x76749675), X(0x767b0975), + X(0x7681799f), X(0x7687e6f3), X(0x768e5170), X(0x7694b918), + X(0x769b1deb), X(0x76a17fe9), X(0x76a7df13), X(0x76ae3b68), + X(0x76b494ea), X(0x76baeb98), X(0x76c13f74), X(0x76c7907c), + X(0x76cddeb3), X(0x76d42a18), X(0x76da72ab), X(0x76e0b86d), + X(0x76e6fb5e), X(0x76ed3b7f), X(0x76f378d0), X(0x76f9b352), + X(0x76ffeb05), X(0x77061fe8), X(0x770c51fe), X(0x77128145), + X(0x7718adbf), X(0x771ed76c), X(0x7724fe4c), X(0x772b225f), + X(0x773143a7), X(0x77376223), X(0x773d7dd3), X(0x774396ba), + X(0x7749acd5), X(0x774fc027), X(0x7755d0af), X(0x775bde6f), + X(0x7761e965), X(0x7767f193), X(0x776df6fa), X(0x7773f998), + X(0x7779f970), X(0x777ff681), X(0x7785f0cd), X(0x778be852), + X(0x7791dd12), X(0x7797cf0d), X(0x779dbe43), X(0x77a3aab6), + X(0x77a99465), X(0x77af7b50), X(0x77b55f79), X(0x77bb40e0), + X(0x77c11f85), X(0x77c6fb68), X(0x77ccd48a), X(0x77d2aaec), + X(0x77d87e8d), X(0x77de4f6f), X(0x77e41d92), X(0x77e9e8f5), + X(0x77efb19b), X(0x77f57782), X(0x77fb3aad), X(0x7800fb1a), + X(0x7806b8ca), X(0x780c73bf), X(0x78122bf7), X(0x7817e175), + X(0x781d9438), X(0x78234440), X(0x7828f18f), X(0x782e9c25), + X(0x78344401), X(0x7839e925), X(0x783f8b92), X(0x78452b46), + X(0x784ac844), X(0x7850628b), X(0x7855fa1c), X(0x785b8ef8), + X(0x7861211e), X(0x7866b090), X(0x786c3d4d), X(0x7871c757), + X(0x78774ead), X(0x787cd351), X(0x78825543), X(0x7887d483), + X(0x788d5111), X(0x7892caef), X(0x7898421c), X(0x789db69a), + X(0x78a32868), X(0x78a89787), X(0x78ae03f8), X(0x78b36dbb), + X(0x78b8d4d1), X(0x78be393a), X(0x78c39af6), X(0x78c8fa06), + X(0x78ce566c), X(0x78d3b026), X(0x78d90736), X(0x78de5b9c), + X(0x78e3ad58), X(0x78e8fc6c), X(0x78ee48d7), X(0x78f3929b), + X(0x78f8d9b7), X(0x78fe1e2c), X(0x79035ffb), X(0x79089f24), + X(0x790ddba8), X(0x79131587), X(0x79184cc2), X(0x791d8159), + X(0x7922b34d), X(0x7927e29e), X(0x792d0f4d), X(0x7932395a), + X(0x793760c6), X(0x793c8591), X(0x7941a7bd), X(0x7946c749), + X(0x794be435), X(0x7950fe84), X(0x79561634), X(0x795b2b47), + X(0x79603dbc), X(0x79654d96), X(0x796a5ad4), X(0x796f6576), + X(0x79746d7e), X(0x797972eb), X(0x797e75bf), X(0x798375f9), + X(0x7988739b), X(0x798d6ea5), X(0x79926717), X(0x79975cf2), + X(0x799c5037), X(0x79a140e6), X(0x79a62f00), X(0x79ab1a85), + X(0x79b00376), X(0x79b4e9d3), X(0x79b9cd9d), X(0x79beaed4), + X(0x79c38d79), X(0x79c8698d), X(0x79cd4310), X(0x79d21a03), + X(0x79d6ee66), X(0x79dbc03a), X(0x79e08f7f), X(0x79e55c36), + X(0x79ea265f), X(0x79eeedfc), X(0x79f3b30c), X(0x79f87590), + X(0x79fd3589), X(0x7a01f2f7), X(0x7a06addc), X(0x7a0b6636), + X(0x7a101c08), X(0x7a14cf52), X(0x7a198013), X(0x7a1e2e4d), + X(0x7a22da01), X(0x7a27832f), X(0x7a2c29d7), X(0x7a30cdfa), + X(0x7a356f99), X(0x7a3a0eb4), X(0x7a3eab4c), X(0x7a434561), + X(0x7a47dcf5), X(0x7a4c7207), X(0x7a510498), X(0x7a5594a9), + X(0x7a5a223a), X(0x7a5ead4d), X(0x7a6335e0), X(0x7a67bbf6), + X(0x7a6c3f8f), X(0x7a70c0ab), X(0x7a753f4b), X(0x7a79bb6f), + X(0x7a7e3519), X(0x7a82ac48), X(0x7a8720fe), X(0x7a8b933b), + X(0x7a9002ff), X(0x7a94704b), X(0x7a98db20), X(0x7a9d437e), + X(0x7aa1a967), X(0x7aa60cd9), X(0x7aaa6dd7), X(0x7aaecc61), + X(0x7ab32877), X(0x7ab7821b), X(0x7abbd94b), X(0x7ac02e0a), + X(0x7ac48058), X(0x7ac8d035), X(0x7acd1da3), X(0x7ad168a1), + X(0x7ad5b130), X(0x7ad9f751), X(0x7ade3b05), X(0x7ae27c4c), + X(0x7ae6bb27), X(0x7aeaf796), X(0x7aef319a), X(0x7af36934), + X(0x7af79e64), X(0x7afbd12c), X(0x7b00018a), X(0x7b042f81), + X(0x7b085b10), X(0x7b0c8439), X(0x7b10aafc), X(0x7b14cf5a), + X(0x7b18f153), X(0x7b1d10e8), X(0x7b212e1a), X(0x7b2548e9), + X(0x7b296155), X(0x7b2d7761), X(0x7b318b0b), X(0x7b359c55), + X(0x7b39ab3f), X(0x7b3db7cb), X(0x7b41c1f8), X(0x7b45c9c8), + X(0x7b49cf3b), X(0x7b4dd251), X(0x7b51d30b), X(0x7b55d16b), + X(0x7b59cd70), X(0x7b5dc71b), X(0x7b61be6d), X(0x7b65b366), + X(0x7b69a608), X(0x7b6d9653), X(0x7b718447), X(0x7b756fe5), + X(0x7b79592e), X(0x7b7d4022), X(0x7b8124c3), X(0x7b850710), + X(0x7b88e70a), X(0x7b8cc4b3), X(0x7b90a00a), X(0x7b947911), + X(0x7b984fc8), X(0x7b9c242f), X(0x7b9ff648), X(0x7ba3c612), + X(0x7ba79390), X(0x7bab5ec1), X(0x7baf27a5), X(0x7bb2ee3f), + X(0x7bb6b28e), X(0x7bba7493), X(0x7bbe344e), X(0x7bc1f1c1), + X(0x7bc5acec), X(0x7bc965cf), X(0x7bcd1c6c), X(0x7bd0d0c3), + X(0x7bd482d4), X(0x7bd832a1), X(0x7bdbe02a), X(0x7bdf8b70), + X(0x7be33473), X(0x7be6db34), X(0x7bea7fb4), X(0x7bee21f4), + X(0x7bf1c1f3), X(0x7bf55fb3), X(0x7bf8fb35), X(0x7bfc9479), + X(0x7c002b7f), X(0x7c03c04a), X(0x7c0752d8), X(0x7c0ae32b), + X(0x7c0e7144), X(0x7c11fd23), X(0x7c1586c9), X(0x7c190e36), + X(0x7c1c936c), X(0x7c20166b), X(0x7c239733), X(0x7c2715c6), + X(0x7c2a9224), X(0x7c2e0c4e), X(0x7c318444), X(0x7c34fa07), + X(0x7c386d98), X(0x7c3bdef8), X(0x7c3f4e26), X(0x7c42bb25), + X(0x7c4625f4), X(0x7c498e95), X(0x7c4cf507), X(0x7c50594c), + X(0x7c53bb65), X(0x7c571b51), X(0x7c5a7913), X(0x7c5dd4aa), + X(0x7c612e17), X(0x7c64855b), X(0x7c67da76), X(0x7c6b2d6a), + X(0x7c6e7e37), X(0x7c71ccdd), X(0x7c75195e), X(0x7c7863ba), + X(0x7c7babf1), X(0x7c7ef206), X(0x7c8235f7), X(0x7c8577c6), + X(0x7c88b774), X(0x7c8bf502), X(0x7c8f306f), X(0x7c9269bd), + X(0x7c95a0ec), X(0x7c98d5fe), X(0x7c9c08f2), X(0x7c9f39cb), + X(0x7ca26887), X(0x7ca59528), X(0x7ca8bfb0), X(0x7cabe81d), + X(0x7caf0e72), X(0x7cb232af), X(0x7cb554d4), X(0x7cb874e2), + X(0x7cbb92db), X(0x7cbeaebe), X(0x7cc1c88d), X(0x7cc4e047), + X(0x7cc7f5ef), X(0x7ccb0984), X(0x7cce1b08), X(0x7cd12a7b), + X(0x7cd437dd), X(0x7cd74330), X(0x7cda4c74), X(0x7cdd53aa), + X(0x7ce058d3), X(0x7ce35bef), X(0x7ce65cff), X(0x7ce95c04), + X(0x7cec58ff), X(0x7cef53f0), X(0x7cf24cd7), X(0x7cf543b7), + X(0x7cf8388f), X(0x7cfb2b60), X(0x7cfe1c2b), X(0x7d010af1), + X(0x7d03f7b2), X(0x7d06e26f), X(0x7d09cb29), X(0x7d0cb1e0), + X(0x7d0f9696), X(0x7d12794b), X(0x7d1559ff), X(0x7d1838b4), + X(0x7d1b156a), X(0x7d1df022), X(0x7d20c8dd), X(0x7d239f9b), + X(0x7d26745e), X(0x7d294725), X(0x7d2c17f1), X(0x7d2ee6c4), + X(0x7d31b39f), X(0x7d347e81), X(0x7d37476b), X(0x7d3a0e5f), + X(0x7d3cd35d), X(0x7d3f9665), X(0x7d425779), X(0x7d451699), + X(0x7d47d3c6), X(0x7d4a8f01), X(0x7d4d484b), X(0x7d4fffa3), + X(0x7d52b50c), X(0x7d556885), X(0x7d581a0f), X(0x7d5ac9ac), + X(0x7d5d775c), X(0x7d60231f), X(0x7d62ccf6), X(0x7d6574e3), + X(0x7d681ae6), X(0x7d6abeff), X(0x7d6d612f), X(0x7d700178), + X(0x7d729fd9), X(0x7d753c54), X(0x7d77d6e9), X(0x7d7a6f9a), + X(0x7d7d0666), X(0x7d7f9b4f), X(0x7d822e55), X(0x7d84bf79), + X(0x7d874ebc), X(0x7d89dc1e), X(0x7d8c67a1), X(0x7d8ef144), + X(0x7d91790a), X(0x7d93fef2), X(0x7d9682fd), X(0x7d99052d), + X(0x7d9b8581), X(0x7d9e03fb), X(0x7da0809b), X(0x7da2fb62), + X(0x7da57451), X(0x7da7eb68), X(0x7daa60a8), X(0x7dacd413), + X(0x7daf45a9), X(0x7db1b56a), X(0x7db42357), X(0x7db68f71), + X(0x7db8f9b9), X(0x7dbb6230), X(0x7dbdc8d6), X(0x7dc02dac), + X(0x7dc290b3), X(0x7dc4f1eb), X(0x7dc75156), X(0x7dc9aef4), + X(0x7dcc0ac5), X(0x7dce64cc), X(0x7dd0bd07), X(0x7dd31379), + X(0x7dd56821), X(0x7dd7bb01), X(0x7dda0c1a), X(0x7ddc5b6b), + X(0x7ddea8f7), X(0x7de0f4bd), X(0x7de33ebe), X(0x7de586fc), + X(0x7de7cd76), X(0x7dea122e), X(0x7dec5525), X(0x7dee965a), + X(0x7df0d5d0), X(0x7df31386), X(0x7df54f7e), X(0x7df789b8), + X(0x7df9c235), X(0x7dfbf8f5), X(0x7dfe2dfa), X(0x7e006145), + X(0x7e0292d5), X(0x7e04c2ac), X(0x7e06f0cb), X(0x7e091d32), + X(0x7e0b47e1), X(0x7e0d70db), X(0x7e0f981f), X(0x7e11bdaf), + X(0x7e13e18a), X(0x7e1603b3), X(0x7e182429), X(0x7e1a42ed), + X(0x7e1c6001), X(0x7e1e7b64), X(0x7e209518), X(0x7e22ad1d), + X(0x7e24c375), X(0x7e26d81f), X(0x7e28eb1d), X(0x7e2afc70), + X(0x7e2d0c17), X(0x7e2f1a15), X(0x7e31266a), X(0x7e333115), + X(0x7e353a1a), X(0x7e374177), X(0x7e39472e), X(0x7e3b4b3f), + X(0x7e3d4dac), X(0x7e3f4e75), X(0x7e414d9a), X(0x7e434b1e), + X(0x7e4546ff), X(0x7e474140), X(0x7e4939e0), X(0x7e4b30e2), + X(0x7e4d2644), X(0x7e4f1a09), X(0x7e510c30), X(0x7e52fcbc), + X(0x7e54ebab), X(0x7e56d900), X(0x7e58c4bb), X(0x7e5aaedd), + X(0x7e5c9766), X(0x7e5e7e57), X(0x7e6063b2), X(0x7e624776), + X(0x7e6429a5), X(0x7e660a3f), X(0x7e67e945), X(0x7e69c6b8), + X(0x7e6ba299), X(0x7e6d7ce7), X(0x7e6f55a5), X(0x7e712cd3), + X(0x7e730272), X(0x7e74d682), X(0x7e76a904), X(0x7e7879f9), + X(0x7e7a4962), X(0x7e7c173f), X(0x7e7de392), X(0x7e7fae5a), + X(0x7e817799), X(0x7e833f50), X(0x7e85057f), X(0x7e86ca27), + X(0x7e888d49), X(0x7e8a4ee5), X(0x7e8c0efd), X(0x7e8dcd91), + X(0x7e8f8aa1), X(0x7e914630), X(0x7e93003c), X(0x7e94b8c8), + X(0x7e966fd4), X(0x7e982560), X(0x7e99d96e), X(0x7e9b8bfe), + X(0x7e9d3d10), X(0x7e9eeca7), X(0x7ea09ac2), X(0x7ea24762), + X(0x7ea3f288), X(0x7ea59c35), X(0x7ea7446a), X(0x7ea8eb27), + X(0x7eaa906c), X(0x7eac343c), X(0x7eadd696), X(0x7eaf777b), + X(0x7eb116ed), X(0x7eb2b4eb), X(0x7eb45177), X(0x7eb5ec91), + X(0x7eb7863b), X(0x7eb91e74), X(0x7ebab53e), X(0x7ebc4a99), + X(0x7ebdde87), X(0x7ebf7107), X(0x7ec1021b), X(0x7ec291c3), + X(0x7ec42001), X(0x7ec5acd5), X(0x7ec7383f), X(0x7ec8c241), + X(0x7eca4adb), X(0x7ecbd20d), X(0x7ecd57da), X(0x7ecedc41), + X(0x7ed05f44), X(0x7ed1e0e2), X(0x7ed3611d), X(0x7ed4dff6), + X(0x7ed65d6d), X(0x7ed7d983), X(0x7ed95438), X(0x7edacd8f), + X(0x7edc4586), X(0x7eddbc20), X(0x7edf315c), X(0x7ee0a53c), + X(0x7ee217c1), X(0x7ee388ea), X(0x7ee4f8b9), X(0x7ee6672f), + X(0x7ee7d44c), X(0x7ee94012), X(0x7eeaaa80), X(0x7eec1397), + X(0x7eed7b59), X(0x7eeee1c6), X(0x7ef046df), X(0x7ef1aaa5), + X(0x7ef30d18), X(0x7ef46e39), X(0x7ef5ce09), X(0x7ef72c88), + X(0x7ef889b8), X(0x7ef9e599), X(0x7efb402c), X(0x7efc9972), + X(0x7efdf16b), X(0x7eff4818), X(0x7f009d79), X(0x7f01f191), + X(0x7f03445f), X(0x7f0495e4), X(0x7f05e620), X(0x7f073516), + X(0x7f0882c5), X(0x7f09cf2d), X(0x7f0b1a51), X(0x7f0c6430), + X(0x7f0daccc), X(0x7f0ef425), X(0x7f103a3b), X(0x7f117f11), + X(0x7f12c2a5), X(0x7f1404fa), X(0x7f15460f), X(0x7f1685e6), + X(0x7f17c47f), X(0x7f1901db), X(0x7f1a3dfb), X(0x7f1b78e0), + X(0x7f1cb28a), X(0x7f1deafa), X(0x7f1f2231), X(0x7f20582f), + X(0x7f218cf5), X(0x7f22c085), X(0x7f23f2de), X(0x7f252401), + X(0x7f2653f0), X(0x7f2782ab), X(0x7f28b032), X(0x7f29dc87), + X(0x7f2b07aa), X(0x7f2c319c), X(0x7f2d5a5e), X(0x7f2e81f0), + X(0x7f2fa853), X(0x7f30cd88), X(0x7f31f18f), X(0x7f33146a), + X(0x7f343619), X(0x7f35569c), X(0x7f3675f6), X(0x7f379425), + X(0x7f38b12c), X(0x7f39cd0a), X(0x7f3ae7c0), X(0x7f3c0150), + X(0x7f3d19ba), X(0x7f3e30fe), X(0x7f3f471e), X(0x7f405c1a), + X(0x7f416ff3), X(0x7f4282a9), X(0x7f43943e), X(0x7f44a4b2), + X(0x7f45b405), X(0x7f46c239), X(0x7f47cf4e), X(0x7f48db45), + X(0x7f49e61f), X(0x7f4aefdc), X(0x7f4bf87e), X(0x7f4d0004), + X(0x7f4e0670), X(0x7f4f0bc2), X(0x7f500ffb), X(0x7f51131c), + X(0x7f521525), X(0x7f531618), X(0x7f5415f4), X(0x7f5514bb), + X(0x7f56126e), X(0x7f570f0c), X(0x7f580a98), X(0x7f590511), + X(0x7f59fe78), X(0x7f5af6ce), X(0x7f5bee14), X(0x7f5ce44a), + X(0x7f5dd972), X(0x7f5ecd8b), X(0x7f5fc097), X(0x7f60b296), + X(0x7f61a389), X(0x7f629370), X(0x7f63824e), X(0x7f647021), + X(0x7f655ceb), X(0x7f6648ad), X(0x7f673367), X(0x7f681d19), + X(0x7f6905c6), X(0x7f69ed6d), X(0x7f6ad40f), X(0x7f6bb9ad), + X(0x7f6c9e48), X(0x7f6d81e0), X(0x7f6e6475), X(0x7f6f460a), + X(0x7f70269d), X(0x7f710631), X(0x7f71e4c6), X(0x7f72c25c), + X(0x7f739ef4), X(0x7f747a8f), X(0x7f75552e), X(0x7f762ed1), + X(0x7f770779), X(0x7f77df27), X(0x7f78b5db), X(0x7f798b97), + X(0x7f7a605a), X(0x7f7b3425), X(0x7f7c06fa), X(0x7f7cd8d9), + X(0x7f7da9c2), X(0x7f7e79b7), X(0x7f7f48b8), X(0x7f8016c5), + X(0x7f80e3e0), X(0x7f81b009), X(0x7f827b40), X(0x7f834588), + X(0x7f840edf), X(0x7f84d747), X(0x7f859ec1), X(0x7f86654d), + X(0x7f872aec), X(0x7f87ef9e), X(0x7f88b365), X(0x7f897641), + X(0x7f8a3832), X(0x7f8af93a), X(0x7f8bb959), X(0x7f8c7890), + X(0x7f8d36df), X(0x7f8df448), X(0x7f8eb0ca), X(0x7f8f6c67), + X(0x7f90271e), X(0x7f90e0f2), X(0x7f9199e2), X(0x7f9251f0), + X(0x7f93091b), X(0x7f93bf65), X(0x7f9474ce), X(0x7f952958), + X(0x7f95dd01), X(0x7f968fcd), X(0x7f9741ba), X(0x7f97f2ca), + X(0x7f98a2fd), X(0x7f995254), X(0x7f9a00d0), X(0x7f9aae71), + X(0x7f9b5b38), X(0x7f9c0726), X(0x7f9cb23b), X(0x7f9d5c78), + X(0x7f9e05de), X(0x7f9eae6e), X(0x7f9f5627), X(0x7f9ffd0b), + X(0x7fa0a31b), X(0x7fa14856), X(0x7fa1ecbf), X(0x7fa29054), + X(0x7fa33318), X(0x7fa3d50b), X(0x7fa4762c), X(0x7fa5167e), + X(0x7fa5b601), X(0x7fa654b5), X(0x7fa6f29b), X(0x7fa78fb3), + X(0x7fa82bff), X(0x7fa8c77f), X(0x7fa96234), X(0x7fa9fc1e), + X(0x7faa953e), X(0x7fab2d94), X(0x7fabc522), X(0x7fac5be8), + X(0x7facf1e6), X(0x7fad871d), X(0x7fae1b8f), X(0x7faeaf3b), + X(0x7faf4222), X(0x7fafd445), X(0x7fb065a4), X(0x7fb0f641), + X(0x7fb1861b), X(0x7fb21534), X(0x7fb2a38c), X(0x7fb33124), + X(0x7fb3bdfb), X(0x7fb44a14), X(0x7fb4d56f), X(0x7fb5600c), + X(0x7fb5e9ec), X(0x7fb6730f), X(0x7fb6fb76), X(0x7fb78323), + X(0x7fb80a15), X(0x7fb8904d), X(0x7fb915cc), X(0x7fb99a92), + X(0x7fba1ea0), X(0x7fbaa1f7), X(0x7fbb2497), X(0x7fbba681), + X(0x7fbc27b5), X(0x7fbca835), X(0x7fbd2801), X(0x7fbda719), + X(0x7fbe257e), X(0x7fbea331), X(0x7fbf2032), X(0x7fbf9c82), + X(0x7fc01821), X(0x7fc09311), X(0x7fc10d52), X(0x7fc186e4), + X(0x7fc1ffc8), X(0x7fc277ff), X(0x7fc2ef89), X(0x7fc36667), + X(0x7fc3dc9a), X(0x7fc45221), X(0x7fc4c6ff), X(0x7fc53b33), + X(0x7fc5aebe), X(0x7fc621a0), X(0x7fc693db), X(0x7fc7056f), + X(0x7fc7765c), X(0x7fc7e6a3), X(0x7fc85645), X(0x7fc8c542), + X(0x7fc9339b), X(0x7fc9a150), X(0x7fca0e63), X(0x7fca7ad3), + X(0x7fcae6a2), X(0x7fcb51cf), X(0x7fcbbc5c), X(0x7fcc2649), + X(0x7fcc8f97), X(0x7fccf846), X(0x7fcd6058), X(0x7fcdc7cb), + X(0x7fce2ea2), X(0x7fce94dd), X(0x7fcefa7b), X(0x7fcf5f7f), + X(0x7fcfc3e8), X(0x7fd027b7), X(0x7fd08aed), X(0x7fd0ed8b), + X(0x7fd14f90), X(0x7fd1b0fd), X(0x7fd211d4), X(0x7fd27214), + X(0x7fd2d1bf), X(0x7fd330d4), X(0x7fd38f55), X(0x7fd3ed41), + X(0x7fd44a9a), X(0x7fd4a761), X(0x7fd50395), X(0x7fd55f37), + X(0x7fd5ba48), X(0x7fd614c9), X(0x7fd66eba), X(0x7fd6c81b), + X(0x7fd720ed), X(0x7fd77932), X(0x7fd7d0e8), X(0x7fd82812), + X(0x7fd87eae), X(0x7fd8d4bf), X(0x7fd92a45), X(0x7fd97f40), + X(0x7fd9d3b0), X(0x7fda2797), X(0x7fda7af5), X(0x7fdacdca), + X(0x7fdb2018), X(0x7fdb71dd), X(0x7fdbc31c), X(0x7fdc13d5), + X(0x7fdc6408), X(0x7fdcb3b6), X(0x7fdd02df), X(0x7fdd5184), + X(0x7fdd9fa5), X(0x7fdded44), X(0x7fde3a60), X(0x7fde86fb), + X(0x7fded314), X(0x7fdf1eac), X(0x7fdf69c4), X(0x7fdfb45d), + X(0x7fdffe76), X(0x7fe04811), X(0x7fe0912e), X(0x7fe0d9ce), + X(0x7fe121f0), X(0x7fe16996), X(0x7fe1b0c1), X(0x7fe1f770), + X(0x7fe23da4), X(0x7fe2835f), X(0x7fe2c89f), X(0x7fe30d67), + X(0x7fe351b5), X(0x7fe3958c), X(0x7fe3d8ec), X(0x7fe41bd4), + X(0x7fe45e46), X(0x7fe4a042), X(0x7fe4e1c8), X(0x7fe522da), + X(0x7fe56378), X(0x7fe5a3a1), X(0x7fe5e358), X(0x7fe6229b), + X(0x7fe6616d), X(0x7fe69fcc), X(0x7fe6ddbb), X(0x7fe71b39), + X(0x7fe75847), X(0x7fe794e5), X(0x7fe7d114), X(0x7fe80cd5), + X(0x7fe84827), X(0x7fe8830c), X(0x7fe8bd84), X(0x7fe8f78f), + X(0x7fe9312f), X(0x7fe96a62), X(0x7fe9a32b), X(0x7fe9db8a), + X(0x7fea137e), X(0x7fea4b09), X(0x7fea822b), X(0x7feab8e5), + X(0x7feaef37), X(0x7feb2521), X(0x7feb5aa4), X(0x7feb8fc1), + X(0x7febc478), X(0x7febf8ca), X(0x7fec2cb6), X(0x7fec603e), + X(0x7fec9363), X(0x7fecc623), X(0x7fecf881), X(0x7fed2a7c), + X(0x7fed5c16), X(0x7fed8d4e), X(0x7fedbe24), X(0x7fedee9b), + X(0x7fee1eb1), X(0x7fee4e68), X(0x7fee7dc0), X(0x7feeacb9), + X(0x7feedb54), X(0x7fef0991), X(0x7fef3771), X(0x7fef64f5), + X(0x7fef921d), X(0x7fefbee8), X(0x7fefeb59), X(0x7ff0176f), + X(0x7ff0432a), X(0x7ff06e8c), X(0x7ff09995), X(0x7ff0c444), + X(0x7ff0ee9c), X(0x7ff1189b), X(0x7ff14243), X(0x7ff16b94), + X(0x7ff1948e), X(0x7ff1bd32), X(0x7ff1e581), X(0x7ff20d7b), + X(0x7ff2351f), X(0x7ff25c70), X(0x7ff2836d), X(0x7ff2aa17), + X(0x7ff2d06d), X(0x7ff2f672), X(0x7ff31c24), X(0x7ff34185), + X(0x7ff36695), X(0x7ff38b55), X(0x7ff3afc4), X(0x7ff3d3e4), + X(0x7ff3f7b4), X(0x7ff41b35), X(0x7ff43e69), X(0x7ff4614e), + X(0x7ff483e6), X(0x7ff4a631), X(0x7ff4c82f), X(0x7ff4e9e1), + X(0x7ff50b47), X(0x7ff52c62), X(0x7ff54d33), X(0x7ff56db9), + X(0x7ff58df5), X(0x7ff5ade7), X(0x7ff5cd90), X(0x7ff5ecf1), + X(0x7ff60c09), X(0x7ff62ada), X(0x7ff64963), X(0x7ff667a5), + X(0x7ff685a1), X(0x7ff6a357), X(0x7ff6c0c7), X(0x7ff6ddf1), + X(0x7ff6fad7), X(0x7ff71778), X(0x7ff733d6), X(0x7ff74fef), + X(0x7ff76bc6), X(0x7ff78759), X(0x7ff7a2ab), X(0x7ff7bdba), + X(0x7ff7d888), X(0x7ff7f315), X(0x7ff80d61), X(0x7ff8276c), + X(0x7ff84138), X(0x7ff85ac4), X(0x7ff87412), X(0x7ff88d20), + X(0x7ff8a5f0), X(0x7ff8be82), X(0x7ff8d6d7), X(0x7ff8eeef), + X(0x7ff906c9), X(0x7ff91e68), X(0x7ff935cb), X(0x7ff94cf2), + X(0x7ff963dd), X(0x7ff97a8f), X(0x7ff99105), X(0x7ff9a742), + X(0x7ff9bd45), X(0x7ff9d30f), X(0x7ff9e8a0), X(0x7ff9fdf9), + X(0x7ffa131a), X(0x7ffa2803), X(0x7ffa3cb4), X(0x7ffa512f), + X(0x7ffa6573), X(0x7ffa7981), X(0x7ffa8d59), X(0x7ffaa0fc), + X(0x7ffab46a), X(0x7ffac7a3), X(0x7ffadaa8), X(0x7ffaed78), + X(0x7ffb0015), X(0x7ffb127f), X(0x7ffb24b6), X(0x7ffb36bb), + X(0x7ffb488d), X(0x7ffb5a2e), X(0x7ffb6b9d), X(0x7ffb7cdb), + X(0x7ffb8de9), X(0x7ffb9ec6), X(0x7ffbaf73), X(0x7ffbbff1), + X(0x7ffbd03f), X(0x7ffbe05e), X(0x7ffbf04f), X(0x7ffc0012), + X(0x7ffc0fa6), X(0x7ffc1f0d), X(0x7ffc2e47), X(0x7ffc3d54), + X(0x7ffc4c35), X(0x7ffc5ae9), X(0x7ffc6971), X(0x7ffc77ce), + X(0x7ffc8600), X(0x7ffc9407), X(0x7ffca1e4), X(0x7ffcaf96), + X(0x7ffcbd1f), X(0x7ffcca7e), X(0x7ffcd7b4), X(0x7ffce4c1), + X(0x7ffcf1a5), X(0x7ffcfe62), X(0x7ffd0af6), X(0x7ffd1763), + X(0x7ffd23a9), X(0x7ffd2fc8), X(0x7ffd3bc1), X(0x7ffd4793), + X(0x7ffd533f), X(0x7ffd5ec5), X(0x7ffd6a27), X(0x7ffd7563), + X(0x7ffd807a), X(0x7ffd8b6e), X(0x7ffd963d), X(0x7ffda0e8), + X(0x7ffdab70), X(0x7ffdb5d5), X(0x7ffdc017), X(0x7ffdca36), + X(0x7ffdd434), X(0x7ffdde0f), X(0x7ffde7c9), X(0x7ffdf161), + X(0x7ffdfad8), X(0x7ffe042f), X(0x7ffe0d65), X(0x7ffe167b), + X(0x7ffe1f71), X(0x7ffe2848), X(0x7ffe30ff), X(0x7ffe3997), + X(0x7ffe4211), X(0x7ffe4a6c), X(0x7ffe52a9), X(0x7ffe5ac8), + X(0x7ffe62c9), X(0x7ffe6aae), X(0x7ffe7275), X(0x7ffe7a1f), + X(0x7ffe81ad), X(0x7ffe891f), X(0x7ffe9075), X(0x7ffe97b0), + X(0x7ffe9ece), X(0x7ffea5d2), X(0x7ffeacbb), X(0x7ffeb38a), + X(0x7ffeba3e), X(0x7ffec0d8), X(0x7ffec758), X(0x7ffecdbf), + X(0x7ffed40d), X(0x7ffeda41), X(0x7ffee05d), X(0x7ffee660), + X(0x7ffeec4b), X(0x7ffef21f), X(0x7ffef7da), X(0x7ffefd7e), + X(0x7fff030b), X(0x7fff0881), X(0x7fff0de0), X(0x7fff1328), + X(0x7fff185b), X(0x7fff1d77), X(0x7fff227e), X(0x7fff276f), + X(0x7fff2c4b), X(0x7fff3112), X(0x7fff35c4), X(0x7fff3a62), + X(0x7fff3eeb), X(0x7fff4360), X(0x7fff47c2), X(0x7fff4c0f), + X(0x7fff504a), X(0x7fff5471), X(0x7fff5885), X(0x7fff5c87), + X(0x7fff6076), X(0x7fff6452), X(0x7fff681d), X(0x7fff6bd6), + X(0x7fff6f7d), X(0x7fff7313), X(0x7fff7698), X(0x7fff7a0c), + X(0x7fff7d6f), X(0x7fff80c2), X(0x7fff8404), X(0x7fff8736), + X(0x7fff8a58), X(0x7fff8d6b), X(0x7fff906e), X(0x7fff9362), + X(0x7fff9646), X(0x7fff991c), X(0x7fff9be3), X(0x7fff9e9c), + X(0x7fffa146), X(0x7fffa3e2), X(0x7fffa671), X(0x7fffa8f1), + X(0x7fffab65), X(0x7fffadca), X(0x7fffb023), X(0x7fffb26f), + X(0x7fffb4ae), X(0x7fffb6e0), X(0x7fffb906), X(0x7fffbb20), + X(0x7fffbd2e), X(0x7fffbf30), X(0x7fffc126), X(0x7fffc311), + X(0x7fffc4f1), X(0x7fffc6c5), X(0x7fffc88f), X(0x7fffca4d), + X(0x7fffcc01), X(0x7fffcdab), X(0x7fffcf4a), X(0x7fffd0e0), + X(0x7fffd26b), X(0x7fffd3ec), X(0x7fffd564), X(0x7fffd6d2), + X(0x7fffd838), X(0x7fffd993), X(0x7fffdae6), X(0x7fffdc31), + X(0x7fffdd72), X(0x7fffdeab), X(0x7fffdfdb), X(0x7fffe104), + X(0x7fffe224), X(0x7fffe33c), X(0x7fffe44d), X(0x7fffe556), + X(0x7fffe657), X(0x7fffe751), X(0x7fffe844), X(0x7fffe930), + X(0x7fffea15), X(0x7fffeaf3), X(0x7fffebca), X(0x7fffec9b), + X(0x7fffed66), X(0x7fffee2a), X(0x7fffeee8), X(0x7fffefa0), + X(0x7ffff053), X(0x7ffff0ff), X(0x7ffff1a6), X(0x7ffff247), + X(0x7ffff2e4), X(0x7ffff37a), X(0x7ffff40c), X(0x7ffff499), + X(0x7ffff520), X(0x7ffff5a3), X(0x7ffff621), X(0x7ffff69b), + X(0x7ffff710), X(0x7ffff781), X(0x7ffff7ee), X(0x7ffff857), + X(0x7ffff8bb), X(0x7ffff91c), X(0x7ffff979), X(0x7ffff9d2), + X(0x7ffffa27), X(0x7ffffa79), X(0x7ffffac8), X(0x7ffffb13), + X(0x7ffffb5b), X(0x7ffffba0), X(0x7ffffbe2), X(0x7ffffc21), + X(0x7ffffc5d), X(0x7ffffc96), X(0x7ffffccd), X(0x7ffffd01), + X(0x7ffffd32), X(0x7ffffd61), X(0x7ffffd8e), X(0x7ffffdb8), + X(0x7ffffde0), X(0x7ffffe07), X(0x7ffffe2b), X(0x7ffffe4d), + X(0x7ffffe6d), X(0x7ffffe8b), X(0x7ffffea8), X(0x7ffffec3), + X(0x7ffffedc), X(0x7ffffef4), X(0x7fffff0a), X(0x7fffff1f), + X(0x7fffff33), X(0x7fffff45), X(0x7fffff56), X(0x7fffff66), + X(0x7fffff75), X(0x7fffff82), X(0x7fffff8f), X(0x7fffff9a), + X(0x7fffffa5), X(0x7fffffaf), X(0x7fffffb8), X(0x7fffffc0), + X(0x7fffffc8), X(0x7fffffce), X(0x7fffffd5), X(0x7fffffda), + X(0x7fffffdf), X(0x7fffffe4), X(0x7fffffe8), X(0x7fffffeb), + X(0x7fffffef), X(0x7ffffff1), X(0x7ffffff4), X(0x7ffffff6), + X(0x7ffffff8), X(0x7ffffff9), X(0x7ffffffb), X(0x7ffffffc), + X(0x7ffffffd), X(0x7ffffffd), X(0x7ffffffe), X(0x7fffffff), + X(0x7fffffff), X(0x7fffffff), X(0x7fffffff), X(0x7fffffff), + X(0x7fffffff), X(0x7fffffff), X(0x7fffffff), X(0x7fffffff), + X(0x7fffffff), X(0x7fffffff), X(0x7fffffff), X(0x7fffffff), +}; + diff --git a/lib/rbcodec/codecs/libtta/README b/lib/rbcodec/codecs/libtta/README new file mode 100644 index 0000000000..8b1a1b23c0 --- /dev/null +++ b/lib/rbcodec/codecs/libtta/README @@ -0,0 +1,72 @@ +TTA Hardware Players Library +============================ + +Version 1.2, (c) 2004 Alexander Djourik. All rights reserved. + +* Introduction + +This library provides to decode a multichannel 8,16 and 24 +bits TTA audio files. TTA is a lossless audio format. Being +"lossless" means that no data/quality is lost in the compression +- when uncompressed, the data will be identical to the original. +The compression ratios of TTA depend on the type of music file +being compressed, but the compression size will generally range +between 30% - 70% of the original. + +TTA format supports both of ID3v1/v2 tags. Detailed format +description is available at http://www.true-audio.com. + +The decoder process has a minimal system requirements and does +not required to create a big additional memory pools. As the +TTA algorithms has a same system requirements both for decoding +and for encoding processes - the TTA recorder can be easily +realized also. + +* Changes + + 14/04/2004 1.0 Initial release + 16/04/2004 1.1 Code optimization + Code clean-up + 29/10/2004 1.2 ID3 tags support + Code clean-up + +* To Do + + - TTA recorder functions. + +* Developers + + Alexander Djourik + Pavel Zhilin + +* Copying + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. +3. Neither the name of the True Audio Software nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +* See also + +Please visit the TTA homepage at http://tta.sourceforge.net for the +latest in news and downloads. diff --git a/lib/rbcodec/codecs/libtta/README.rockbox b/lib/rbcodec/codecs/libtta/README.rockbox new file mode 100644 index 0000000000..549aa4e097 --- /dev/null +++ b/lib/rbcodec/codecs/libtta/README.rockbox @@ -0,0 +1,33 @@ +Library: True Audio +Imported by : Yoshihisa Uchida +Import date : 2010-03-05 +Baseed by : TTA library version 1.2 for hardware players (ttalib-hwplayer-1.2.tgz) + from http://true-audio.com/Free_Downloads + +This directory contains a decoder version of True Auido. + +LICENSING INFORMATION + +True Audio license is described in the README file or each source file in this directory. + +Limitation + + - Decoding is not real time on some targets. + - Max duration is 4095 seconds (about 1 hours 8 minutes). + +IMPORT DETAILS + +The .[ch] files from ttalib-hwplayer-1.2.tgz were imported into Rockbox. +But the following files do not include. + Makefile + tta.vcproj + samples/* + + +When source files import in Rockbox, I changed below. + +all files + - TAB => 4 spaces. + - // style comments changes to /* */ style. + +Moreover, I modify to optimize the decoding speed. diff --git a/lib/rbcodec/codecs/libtta/SOURCES b/lib/rbcodec/codecs/libtta/SOURCES new file mode 100644 index 0000000000..0a8f1171eb --- /dev/null +++ b/lib/rbcodec/codecs/libtta/SOURCES @@ -0,0 +1,7 @@ +ttadec.c +#ifdef CPU_ARM +filter_arm.S +#endif +#ifdef CPU_COLDFIRE +filter_coldfire.S +#endif diff --git a/lib/rbcodec/codecs/libtta/filter.h b/lib/rbcodec/codecs/libtta/filter.h new file mode 100644 index 0000000000..228757b9a0 --- /dev/null +++ b/lib/rbcodec/codecs/libtta/filter.h @@ -0,0 +1,136 @@ +/* + * filter.h + * + * Description: TTAv1 filter functions + * Developed by: Alexander Djourik + * Pavel Zhilin + * + * Copyright (c) 2004 True Audio Software. All rights reserved. + * + */ + +/* + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the True Audio Software nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef FILTER_H +#define FILTER_H + +///////// Filter Settings ////////// +static int flt_set[3] = {10, 9, 10}; + +#if defined(CPU_ARM) || defined(CPU_COLDFIRE) +int hybrid_filter(fltst *fs, int *in); /* implements in filter_arm.S */ + +#else + +static inline void +memshl (register int *pA) { + register int *pB = pA + 16; + + *pA++ = *pB++; + *pA++ = *pB++; + *pA++ = *pB++; + *pA++ = *pB++; + *pA++ = *pB++; + *pA++ = *pB++; + *pA++ = *pB++; + *pA = *pB; +} + +static inline void +hybrid_filter (fltst *fs, int *in) { + register int *pA = fs->dl + fs->index; + register int *pB = fs->qm; + register int *pM = fs->dx + fs->index; + register int sum = fs->round; + + if (!fs->error) { + sum += *pA++ * *pB++; + sum += *pA++ * *pB++; + sum += *pA++ * *pB++; + sum += *pA++ * *pB++; + sum += *pA++ * *pB++; + sum += *pA++ * *pB++; + sum += *pA++ * *pB++; + sum += *pA * *pB; + pM += 8; + } else if (fs->error < 0) { + sum += *pA++ * (*pB++ -= *pM++); + sum += *pA++ * (*pB++ -= *pM++); + sum += *pA++ * (*pB++ -= *pM++); + sum += *pA++ * (*pB++ -= *pM++); + sum += *pA++ * (*pB++ -= *pM++); + sum += *pA++ * (*pB++ -= *pM++); + sum += *pA++ * (*pB++ -= *pM++); + sum += *pA * (*pB -= *pM++); + } else { + sum += *pA++ * (*pB++ += *pM++); + sum += *pA++ * (*pB++ += *pM++); + sum += *pA++ * (*pB++ += *pM++); + sum += *pA++ * (*pB++ += *pM++); + sum += *pA++ * (*pB++ += *pM++); + sum += *pA++ * (*pB++ += *pM++); + sum += *pA++ * (*pB++ += *pM++); + sum += *pA * (*pB += *pM++); + } + + pB = pA++; + fs->error = *in; + *in += (sum >> fs->shift); + *pA = *in; + + *pM-- = ((*pB-- >> 30) | 1) << 2; + *pM-- = ((*pB-- >> 30) | 1) << 1; + *pM-- = ((*pB-- >> 30) | 1) << 1; + *pM = ((*pB >> 30) | 1); + + *(pA-1) = *(pA-0) - *(pA-1); + *(pA-2) = *(pA-1) - *(pA-2); + *(pA-3) = *(pA-2) - *(pA-3); + + /* + * Rockbox speciffic + * in order to make speed up, memshl() is executed at the rate once every 16 times. + */ + if (++fs->index == 16) + { + memshl (fs->dl); + memshl (fs->dx); + fs->index = 0; + } +} +#endif + +static inline void +filter_init (fltst *fs, int shift) { + ci->memset (fs, 0, sizeof(fltst)); + fs->shift = shift; + fs->round = 1 << (shift - 1); + fs->index = 0; +} + +#endif /* FILTER_H */ diff --git a/lib/rbcodec/codecs/libtta/filter_arm.S b/lib/rbcodec/codecs/libtta/filter_arm.S new file mode 100644 index 0000000000..f3959b83ca --- /dev/null +++ b/lib/rbcodec/codecs/libtta/filter_arm.S @@ -0,0 +1,198 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2010 Yoshihisa Uchida + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include "config.h" + +/* + * The following are assembler optimised version of + * void hybrid_filter(fltst *fs, int *in) + */ + +#ifdef USE_IRAM + .section .icode, "ax", %progbits +#else + .text +#endif + .align + .global hybrid_filter + .type hybrid_filter, %function + +hybrid_filter: + @ input: r0 = fs, r1 = in + stmdb sp!, {r4 - r12, lr} + + @ get fs members + @ r2 pA := fs->dl + fs->index + @ r3 pM := fs->dx + fs->index + @ r4 pB := fs->qm + @ r5 fs->index + @ r6 fs->error + @ lr sum := fs->round + + ldmia r0, {r5, r6, lr} @ r5 = fs->index + @ r6 = fs->error + @ lr = fs->round + add r2, r0, #148 @ r2 = fs->dl + add r3, r0, #52 @ r3 = fs->dx + add r4, r0, #20 @ r4 = fs->qm + add r2, r2, r5 @ r2 = (unsigned char*)fs->dl + fs->index + add r3, r3, r5 @ r3 = (unsigned char*)fs->dx + fs->index + + cmp r6, #0 + bmi .hf_negative + bne .hf_positive + + @ case fs->error == 0 + + add r3, r3, #32 + ldmia r4!, {r5, r6, r7, r8 } + ldmia r2!, {r9, r10, r11, r12} + mla lr, r5, r9, lr + mla lr, r6, r10, lr + mla lr, r7, r11, lr + mla lr, r8, r12, lr + ldmia r4!, {r5, r6, r7, r8 } + b .hf2 + +.hf_negative: + @ case fs->error < 0 + + ldmia r4, {r5, r6, r7, r8 } + ldmia r3!, {r9, r10, r11, r12} + sub r5, r5, r9 + sub r6, r6, r10 + sub r7, r7, r11 + sub r8, r8, r12 + stmia r4!, {r5, r6, r7, r8 } @ update fs->qm[0], ..., fs->qm[3] + ldmia r2!, {r9, r10, r11, r12} + mla lr, r5, r9, lr + mla lr, r6, r10, lr + mla lr, r7, r11, lr + mla lr, r8, r12, lr + ldmia r4, {r5, r6, r7, r8 } + ldmia r3!, {r9, r10, r11, r12} + sub r5, r5, r9 + sub r6, r6, r10 + sub r7, r7, r11 + sub r8, r8, r12 + stmia r4!, {r5, r6, r7, r8 } @ update fs->qm[4], ..., fs->qm[7] + b .hf2 + +.hf_positive: + @ case fs->error > 0 + + ldmia r4, {r5, r6, r7, r8 } + ldmia r3!, {r9, r10, r11, r12} + add r5, r5, r9 + add r6, r6, r10 + add r7, r7, r11 + add r8, r8, r12 + stmia r4!, {r5, r6, r7, r8 } @ update fs->qm[0], ..., fs->qm[3] + ldmia r2!, {r9, r10, r11, r12} + mla lr, r5, r9, lr + mla lr, r6, r10, lr + mla lr, r7, r11, lr + mla lr, r8, r12, lr + ldmia r4, {r5, r6, r7, r8 } + ldmia r3!, {r9, r10, r11, r12} + add r5, r5, r9 + add r6, r6, r10 + add r7, r7, r11 + add r8, r8, r12 + stmia r4!, {r5, r6, r7, r8 } @ update fs->qm[4], ..., fs->qm[7] + +.hf2: + ldmia r2!, {r9, r10, r11, r12} + mla lr, r5, r9, lr + mla lr, r6, r10, lr + mla lr, r7, r11, lr + mla lr, r8, r12, lr + + @ fs->error = *in; + @ *in += (sum >> fs->shift) + @ *pA = *in + + ldr r5, [r1] @ r5 = *in + ldr r6, [r0, #12] @ r6 = fs->shift + add lr, r5, lr, asr r6 + str lr, [r1] @ *in += (sum >> fs->shift) + + @ update fs->index + + ldr r1, [r0] @ r1 = fs->index + add r1, r1, #4 + ands r1, r1, #63 @ set Z flag (after this, CPSR must keep !!) + stmia r0, {r1, r5} @ fs->index = (fs->index + 4) & 63 + @ fs->error = (original) *in + + @ change *pM, *(pM-1), *(pM-2), *(pM-3) + @ r9 = *(pA-4), r5 = *(pM-3) + @ r10 = *(pA-3), r6 = *(pM-2) + @ r11 = *(pA-2), r7 = *(pM-1) + @ r12 = *(pA-1), r8 = *(pM-0) + @ lr = *(pA-0) + + mov r4, #1 + orr r5, r4, r9, asr #30 + orr r6, r4, r10, asr #30 + orr r7, r4, r11, asr #30 + orr r8, r4, r12, asr #30 + mov r6, r6, lsl #1 + mov r7, r7, lsl #1 + mov r8, r8, lsl #2 + + @ change *(pA-1), *(pA-2), *(pA-3) + sub r12, lr, r12 + sub r11, r12, r11 + sub r10, r11, r10 + + @ set to the memory: *pA, *(pA-1), *(pA-2), *(pA-3), *pM, *(pM-1), *(pM-2), *(pM-3) + stmneda r2, {r10, r11, r12, lr} + stmneda r3, {r5, r6, r7, r8} + ldmpc cond=ne regs=r4-r12 @ hybrid_filter end (when fs->index != 0) + +.hf_memshl: + @ memshl (fs->dl) + @ r9 = fs->dl[16 + 3] + @ r10 = fs->dl[16 + 4] + @ r11 = fs->dl[16 + 5] + @ r12 = fs->dl[16 + 6] + @ lr = fs->dl[16 + 7] + + add r2, r0, #212 @ r2 = fs->dl + 16 + ldmia r2, {r1, r3, r4} + sub r2, r2, #64 @ r2 = fs->dl + stmia r2, {r1, r3, r4, r9 - r12, lr} + + @ memshl (fs->dx) + @ r5 = fs->dx[16 + 4] + @ r6 = fs->dx[16 + 5] + @ r7 = fs->dx[16 + 6] + @ r8 = fs->dx[16 + 7] + + add r9, r0, #116 @ r9 = fs->dx + 16 + ldmia r9, {r1, r2, r3, r4} + sub r9, r9, #64 @ r9 = fs->dx + stmia r9, {r1 - r8} + ldmpc regs=r4-r12 @ hybrid_filter end (when fs->index == 0) + +hybrid_filter_end: + .size hybrid_filter, hybrid_filter_end - hybrid_filter diff --git a/lib/rbcodec/codecs/libtta/filter_coldfire.S b/lib/rbcodec/codecs/libtta/filter_coldfire.S new file mode 100644 index 0000000000..3950eb52e6 --- /dev/null +++ b/lib/rbcodec/codecs/libtta/filter_coldfire.S @@ -0,0 +1,164 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2010 Nils Wallménius + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include "config.h" + +/* + * The following is an assembler optimised version of + * void hybrid_filter(fltst *fs, int *in) + */ + +#if defined(USE_IRAM) + .section .icode +#else + .text +#endif + .align 2 + .global hybrid_filter + .type hybrid_filter, @function + +hybrid_filter: + lea.l (-8*4, %sp), %sp + movem.l %d2-%d7/%a2-%a3, (%sp) | save some registers + move.l (8*4+4, %sp), %a0 | a0 = fs + movem.l (%a0), %d4-%d5 | d4 = fs->index, d5 = fs->error + + lea.l (%a0, %d4.l*4), %a2 + lea.l (148, %a2), %a1 | a1 = fs->dl + fs->index (*pA) + lea.l (52, %a2), %a2 | a2 = fs->dx + fs->index (*pM) + + move.l (%a1)+, %a3 | load one value from *pA (needed in every case) + movem.l (20, %a0), %d0-%d3 | load 4 values from *pB + + tst.l %d5 + blt .hf_negative + bgt .hf_positive + + | fs->error == 0 + mac.l %d0, %a3, (%a1)+, %a3, %acc0 + mac.l %d1, %a3, (%a1)+, %a3, %acc0 + mac.l %d2, %a3, (%a1)+, %a3, %acc0 + mac.l %d3, %a3, (%a1)+, %d4, %acc0 + movem.l (4*4+20, %a0), %d0-%d3 | load 4 values from *pB + bra 0f + + .hf_negative: | fs->error < 0 + movem.l (%a2), %d4-%d7 | load 4 values from *pM + sub.l %d4, %d0 + sub.l %d5, %d1 + sub.l %d6, %d2 + sub.l %d7, %d3 + movem.l %d0-%d3, (20, %a0) + mac.l %d0, %a3, (%a1)+, %a3, %acc0 + mac.l %d1, %a3, (%a1)+, %a3, %acc0 + mac.l %d2, %a3, (%a1)+, %a3, %acc0 + mac.l %d3, %a3, (%a1)+, %d4, %acc0 + + movem.l (4*4+20, %a0), %d0-%d3 | load 4 values from *pB + movem.l (4*4, %a2), %d5-%d7/%a3 | load 4 values from *pM + sub.l %d5, %d0 + sub.l %d6, %d1 + sub.l %d7, %d2 + sub.l %a3, %d3 + movem.l %d0-%d3, (4*4+20, %a0) + bra 0f + + .hf_positive: | fs->error > 0 + movem.l (%a2), %d4-%d7 | load 4 values from *pM + add.l %d4, %d0 + add.l %d5, %d1 + add.l %d6, %d2 + add.l %d7, %d3 + movem.l %d0-%d3, (20, %a0) + mac.l %d0, %a3, (%a1)+, %a3, %acc0 + mac.l %d1, %a3, (%a1)+, %a3, %acc0 + mac.l %d2, %a3, (%a1)+, %a3, %acc0 + mac.l %d3, %a3, (%a1)+, %d4, %acc0 + + movem.l (4*4+20, %a0), %d0-%d3 | load 4 values from *pB + movem.l (4*4, %a2), %d5-%d7/%a3 | load 4 values from *pM + add.l %d5, %d0 + add.l %d6, %d1 + add.l %d7, %d2 + add.l %a3, %d3 + movem.l %d0-%d3, (4*4+20, %a0) + + 0: + + mac.l %d0, %d4, (%a1)+, %d5, %acc0 | common macro block + mac.l %d1, %d5, (%a1)+, %d6, %acc0 + mac.l %d2, %d6, (%a1), %d7, %acc0 + mac.l %d3, %d7, %acc0 + + move.l (8*4+8, %sp), %a3 | a3 = in + move.l (%a3), %d3 + move.l %d3, (4, %a0) | fs->error = *in + movclr.l %acc0, %d0 | d0 = sum + movem.l (8, %a0), %d1-%d2 + add.l %d1, %d0 | sum += fs->round + asr.l %d2, %d0 | sum >>= fs->shift + + add.l %d0, %d3 + move.l %d3, (%a3) | *in += (sum >> fs->shift) + + move.l %d3, ( 1*4, %a1) + sub.l %d7, %d3 + move.l %d3, ( 0*4, %a1) + sub.l %d6, %d3 + move.l %d3, (-1*4, %a1) + sub.l %d5, %d3 + move.l %d3, (-2*4, %a1) + + moveq #30,%d0 + asr.l %d0,%d7 + asr.l %d0,%d6 + asr.l %d0,%d5 + asr.l %d0,%d4 + + moveq #1,%d0 + or.l %d0,%d7 + or.l %d0,%d6 + or.l %d0,%d5 + or.l %d0,%d4 + + lsl.l #2,%d7 + lsl.l #1,%d6 + lsl.l #1,%d5 + movem.l %d4-%d7, (8*4-3*4,%a2) | store to *pM + + move.l (%a0), %d0 + addq.l #1, %d0 + cmp.l #16, %d0 | ++fs->index == 16 ? + bne 1f + + movem.l (16*4+148, %a0), %d0-%d7 + movem.l %d0-%d7, (148, %a0) + movem.l (16*4+52, %a0), %d0-%d7 + movem.l %d0-%d7, (52, %a0) + clr.l %d0 | fs->index = 0 + 1: + + move.l %d0, (%a0) + + movem.l (%sp), %d2-%d7/%a2-%a3 | restore stacked regs + lea.l (8*4, %sp), %sp + rts + diff --git a/lib/rbcodec/codecs/libtta/libtta.make b/lib/rbcodec/codecs/libtta/libtta.make new file mode 100644 index 0000000000..3fe3db1989 --- /dev/null +++ b/lib/rbcodec/codecs/libtta/libtta.make @@ -0,0 +1,18 @@ +# __________ __ ___. +# Open \______ \ ____ ____ | | _\_ |__ _______ ___ +# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / +# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < +# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ +# \/ \/ \/ \/ \/ +# $Id$ +# + +# libtta +TTALIB := $(CODECDIR)/libtta.a +TTALIB_SRC := $(call preprocess, $(RBCODECLIB_DIR)/codecs/libtta/SOURCES) +TTALIB_OBJ := $(call c2obj, $(TTALIB_SRC)) +OTHER_SRC += $(TTALIB_SRC) + +$(TTALIB): $(TTALIB_OBJ) + $(SILENT)$(shell rm -f $@) + $(call PRINTS,AR $(@F))$(AR) rcs $@ $^ >/dev/null diff --git a/lib/rbcodec/codecs/libtta/ttadec.c b/lib/rbcodec/codecs/libtta/ttadec.c new file mode 100644 index 0000000000..06ca431084 --- /dev/null +++ b/lib/rbcodec/codecs/libtta/ttadec.c @@ -0,0 +1,582 @@ +/* + * ttadec.c + * + * Description: TTAv1 decoder library for HW players + * Developed by: Alexander Djourik + * Pavel Zhilin + * + * Copyright (c) 2004 True Audio Software. All rights reserved. + * + */ + +/* + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the True Audio Software nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include "codeclib.h" + +#include "ttalib.h" +#include "ttadec.h" +#include "filter.h" + +/******************* static variables and structures *******************/ + +static unsigned char isobuffers[ISO_BUFFERS_SIZE + 4] IBSS_ATTR; +static unsigned char * const iso_buffers_end ICONST_ATTR = isobuffers + ISO_BUFFERS_SIZE; +static unsigned int pcm_buffer_size IBSS_ATTR; + +static decoder tta[MAX_NCH] IBSS_ATTR; /* decoder state */ +/* Rockbox speciffic: cache is defined in get_samples() (non static value) */ +/* static int cache[MAX_NCH]; // decoder cache */ + +static tta_info *ttainfo IBSS_ATTR; /* currently playing file info */ + +static unsigned int fframes IBSS_ATTR; /* number of frames in file */ +static unsigned int framelen IBSS_ATTR; /* the frame length in samples */ +static unsigned int lastlen IBSS_ATTR; /* the length of the last frame in samples */ +static unsigned int data_pos IBSS_ATTR; /* currently playing frame index */ +static unsigned int data_cur IBSS_ATTR; /* the playing position in frame */ + +static int maxvalue IBSS_ATTR; /* output data max value */ + +/* Rockbox speciffic: seek_table is static size */ +static unsigned int seek_table[MAX_SEEK_TABLE_SIZE]; /* the playing position table */ +static unsigned int st_state; /* seek table status */ + +static unsigned int frame_crc32 IBSS_ATTR; +static unsigned int bit_count IBSS_ATTR; +static unsigned int bit_cache IBSS_ATTR; +static unsigned char *bitpos IBSS_ATTR; + +/* Rockbox speciffic: deletes read_id3_tags(). */ +/* static int read_id3_tags (tta_info *info); */ + +/********************* rockbox helper functions *************************/ + +/* emulate stdio functions */ +static size_t tta_fread(void *ptr, size_t size, size_t nobj) +{ + size_t read_size; + unsigned char *buffer = ci->request_buffer(&read_size, size * nobj); + + if (read_size > 0) + { + ci->memcpy(ptr, buffer, read_size); + ci->advance_buffer(read_size); + } + return read_size; +} + +static int tta_fseek(long offset, int origin) +{ + switch (origin) + { + case SEEK_CUR: + ci->advance_buffer(offset); + break; + case SEEK_SET: + ci->seek_buffer(offset); + break; + case SEEK_END: + ci->seek_buffer(offset + ci->id3->filesize); + break; + default: + return -1; + } + return 0; +} + +/************************* crc32 functions *****************************/ + +#define UPDATE_CRC32(x, crc) crc = \ + (((crc>>8) & 0x00FFFFFF) ^ crc32_table[(crc^x) & 0xFF]) + +static unsigned int +crc32 (unsigned char *buffer, unsigned int len) { + unsigned int i; + unsigned int crc = 0xFFFFFFFF; + + for (i = 0; i < len; i++) UPDATE_CRC32(buffer[i], crc); + + return (crc ^ 0xFFFFFFFF); +} + +/************************* bit operations ******************************/ + +#define GET_BINARY(value, bits) \ + while (bit_count < bits) { \ + if (bitpos == iso_buffers_end) { \ + if (!tta_fread(isobuffers, 1, ISO_BUFFERS_SIZE)) { \ + ttainfo->STATE = READ_ERROR; \ + return -1; \ + } \ + bitpos = isobuffers; \ + } \ + UPDATE_CRC32(*bitpos, frame_crc32); \ + bit_cache |= *bitpos << bit_count; \ + bit_count += 8; \ + bitpos++; \ + } \ + value = bit_cache & bit_mask[bits]; \ + bit_cache >>= bits; \ + bit_count -= bits; \ + bit_cache &= bit_mask[bit_count]; + +#define GET_UNARY(value) \ + value = 0; \ + while (!(bit_cache ^ bit_mask[bit_count])) { \ + if (bitpos == iso_buffers_end) { \ + if (!tta_fread(isobuffers, 1, ISO_BUFFERS_SIZE)) { \ + ttainfo->STATE = READ_ERROR; \ + return -1; \ + } \ + bitpos = isobuffers; \ + } \ + value += bit_count; \ + bit_cache = *bitpos++; \ + UPDATE_CRC32(bit_cache, frame_crc32); \ + bit_count = 8; \ + } \ + while (bit_cache & 1) { \ + value++; \ + bit_cache >>= 1; \ + bit_count--; \ + } \ + bit_cache >>= 1; \ + bit_count--; + +/************************* rice operations ******************************/ + +static inline int update_rice(int value, adapt *rice, int depth, + const unsigned int *shift_table) +{ + if (depth > 0) + { + rice->sum1 += value - (rice->sum1 >> 4); + if (rice->k1 > 0 && rice->sum1 < shift_table[rice->k1]) + rice->k1--; + else if (rice->sum1 > shift_table[rice->k1 + 1]) + rice->k1++; + value += *(shift_table + rice->k0 - 4); + } + rice->sum0 += value - (rice->sum0 >> 4); + if (rice->k0 > 0 && rice->sum0 < shift_table[rice->k0]) + rice->k0--; + else if (rice->sum0 > shift_table[rice->k0 + 1]) + rice->k0++; + + return DEC(value); +} + +/************************* buffer functions ******************************/ + +static void init_buffer_read(void) { + frame_crc32 = 0xFFFFFFFFUL; + bit_count = bit_cache = 0; + bitpos = iso_buffers_end; +} + +static int done_buffer_read(void) { + unsigned int crc32, rbytes; + + frame_crc32 ^= 0xFFFFFFFFUL; + rbytes = iso_buffers_end - bitpos; + + if (rbytes < sizeof(int)) { + ci->memcpy(isobuffers, bitpos, 4); + if (!tta_fread(isobuffers + rbytes, 1, ISO_BUFFERS_SIZE - rbytes)) + return -1; + bitpos = isobuffers; + } + + ci->memcpy(&crc32, bitpos, 4); + crc32 = ENDSWAP_INT32(crc32); + bitpos += sizeof(int); + + if (crc32 != frame_crc32) return -1; + + bit_cache = bit_count = 0; + frame_crc32 = 0xFFFFFFFFUL; + + return 0; +} + +/************************* decoder functions ****************************/ + +/* rockbox: not used +const char *get_error_str (int error) { + switch (error) { + case NO_ERROR: return "No errors found"; + case OPEN_ERROR: return "Can't open file"; + case FORMAT_ERROR: return "Not supported file format"; + case FILE_ERROR: return "File is corrupted"; + case READ_ERROR: return "Can't read from file"; + case MEMORY_ERROR: return "Insufficient memory available"; + default: return "Unknown error code"; + } +} */ + +int set_tta_info (tta_info *info) +{ + unsigned int checksum; + unsigned int datasize; + unsigned int origsize; + tta_hdr ttahdr; + + /* clear the memory */ + ci->memset (info, 0, sizeof(tta_info)); + + /* skip id3v2 tags */ + tta_fseek(ci->id3->id3v2len, SEEK_SET); + + /* read TTA header */ + if (tta_fread (&ttahdr, 1, sizeof (ttahdr)) == 0) { + info->STATE = READ_ERROR; + return -1; + } + + /* check for TTA3 signature */ + if (ENDSWAP_INT32(ttahdr.TTAid) != TTA1_SIGN) { + DEBUGF("ID error: %x\n", ENDSWAP_INT32(ttahdr.TTAid)); + info->STATE = FORMAT_ERROR; + return -1; + } + + ttahdr.CRC32 = ENDSWAP_INT32(ttahdr.CRC32); + checksum = crc32((unsigned char *) &ttahdr, + sizeof(tta_hdr) - sizeof(int)); + if (checksum != ttahdr.CRC32) { + DEBUGF("CRC error: %x != %x\n", ttahdr.CRC32, checksum); + info->STATE = FILE_ERROR; + return -1; + } + + ttahdr.AudioFormat = ENDSWAP_INT16(ttahdr.AudioFormat); + ttahdr.NumChannels = ENDSWAP_INT16(ttahdr.NumChannels); + ttahdr.BitsPerSample = ENDSWAP_INT16(ttahdr.BitsPerSample); + ttahdr.SampleRate = ENDSWAP_INT32(ttahdr.SampleRate); + ttahdr.DataLength = ENDSWAP_INT32(ttahdr.DataLength); + + /* check for player supported formats */ + if (ttahdr.AudioFormat != WAVE_FORMAT_PCM || + ttahdr.NumChannels > MAX_NCH || + ttahdr.BitsPerSample > MAX_BPS ||( + ttahdr.SampleRate != 16000 && + ttahdr.SampleRate != 22050 && + ttahdr.SampleRate != 24000 && + ttahdr.SampleRate != 32000 && + ttahdr.SampleRate != 44100 && + ttahdr.SampleRate != 48000 && + ttahdr.SampleRate != 64000 && + ttahdr.SampleRate != 88200 && + ttahdr.SampleRate != 96000)) { + info->STATE = FORMAT_ERROR; + DEBUGF("illegal audio format: %d channels: %d samplerate: %d\n", + ttahdr.AudioFormat, ttahdr.NumChannels, ttahdr.SampleRate); + return -1; + } + + /* fill the File Info */ + info->NCH = ttahdr.NumChannels; + info->BPS = ttahdr.BitsPerSample; + info->BSIZE = (ttahdr.BitsPerSample + 7)/8; + info->FORMAT = ttahdr.AudioFormat; + info->SAMPLERATE = ttahdr.SampleRate; + info->DATALENGTH = ttahdr.DataLength; + info->FRAMELEN = (int) MULTIPLY_FRAME_TIME(ttahdr.SampleRate); + info->LENGTH = ttahdr.DataLength / ttahdr.SampleRate; + info->DATAPOS = ci->id3->id3v2len; + info->FILESIZE = ci->id3->filesize; + + datasize = info->FILESIZE - info->DATAPOS; + origsize = info->DATALENGTH * info->BSIZE * info->NCH; + + /* info->COMPRESS = (double) datasize / origsize; */ + info->BITRATE = (int) ((uint64_t) datasize * info->SAMPLERATE * info->NCH * info->BPS + / (origsize * 1000LL)); + + return 0; +} + +static void rice_init(adapt *rice, unsigned int k0, unsigned int k1) { + rice->k0 = k0; + rice->k1 = k1; + rice->sum0 = shift_16[k0]; + rice->sum1 = shift_16[k1]; +} + +static void decoder_init(decoder *tta, int nch, int byte_size) { + int shift = flt_set[byte_size - 1]; + int i; + + for (i = 0; i < nch; i++) { + filter_init(&tta[i].fst, shift); + rice_init(&tta[i].rice, 10, 10); + tta[i].last = 0; + } +} + +static void seek_table_init (unsigned int *seek_table, + unsigned int len, unsigned int data_offset) { + unsigned int *st, frame_len; + + for (st = seek_table; st < (seek_table + len); st++) { + frame_len = ENDSWAP_INT32(*st); + *st = data_offset; + data_offset += frame_len; + } +} + +int set_position (unsigned int pos, enum tta_seek_type type) +{ + unsigned int i; + unsigned int seek_pos; + + if (type == TTA_SEEK_TIME) + { + if (pos >= fframes) + pos = fframes -1; + } + else + { + pos -= ttainfo->DATAPOS; + for (i = 1; i < fframes; i++) + { + if (seek_table[i] > pos) + break; + } + pos = i - 1; + } + if (!st_state) { + ttainfo->STATE = FILE_ERROR; + return -1; + } + seek_pos = ttainfo->DATAPOS + seek_table[data_pos = pos]; + if (tta_fseek(seek_pos, SEEK_SET) < 0) { + ttainfo->STATE = READ_ERROR; + return -1; + } + + data_cur = 0; + framelen = 0; + + /* init bit reader */ + init_buffer_read(); + return data_pos * ttainfo->FRAMELEN; +} + +int player_init (tta_info *info) { + unsigned int checksum; + unsigned int data_offset; + unsigned int st_size; + +#ifdef CPU_COLDFIRE + coldfire_set_macsr(0); /* signed integer mode */ +#endif + + ttainfo = info; + + framelen = 0; + data_pos = 0; + data_cur = 0; + + lastlen = ttainfo->DATALENGTH % ttainfo->FRAMELEN; + fframes = ttainfo->DATALENGTH / ttainfo->FRAMELEN + (lastlen ? 1 : 0); + st_size = (fframes + 1) * sizeof(int); + + /* + * Rockbox speciffic + * playable tta file is to MAX_SEEK_TABLE_SIZE frames + * about 1:08:15 (frequency 44.1 kHz) + */ + if (fframes > MAX_SEEK_TABLE_SIZE) + { + LOGF("frame is too many: %d > %d", fframes, MAX_SEEK_TABLE_SIZE); + return -1; + } + + /* read seek table */ + if (!tta_fread(seek_table, st_size, 1)) { + ttainfo->STATE = READ_ERROR; + return -1; + } + + checksum = crc32((unsigned char *) seek_table, st_size - sizeof(int)); + st_state = (checksum == ENDSWAP_INT32(seek_table[fframes])); + data_offset = sizeof(tta_hdr) + st_size; + + /* init seek table */ + seek_table_init(seek_table, fframes, data_offset); + + /* init bit reader */ + init_buffer_read(); + + /* + * Rockbox speciffic + * because pcm data is int32_t, does not multiply ttainfo->BSIZE. + */ + pcm_buffer_size = PCM_BUFFER_LENGTH * ttainfo->NCH; + maxvalue = (1UL << ttainfo->BPS) - 1; + + return 0; +} + +/* + * Rockbox specffic + * because the seek table is static size buffer, player_stop() is nooperation function. + */ +void player_stop (void) { +/* + if (seek_table) { + free(seek_table); + seek_table = NULL; + } +*/ +} + +/* + * Rockbox speciffic + * with the optimization, the decoding logic is modify a little. + */ +int get_samples (int32_t *buffer) { + unsigned int k, depth, unary, binary; + int32_t *p = buffer; + decoder *dec = tta; + int value, res; + int cur_pos = pcm_buffer_size; + int pcm_shift_bits = TTA_OUTPUT_DEPTH - ttainfo->BPS; + int pr_bits = (ttainfo->BSIZE == 1)? 4 : 5; + int cache = 0; /* decoder cache */ + + fltst *fst; + adapt *rice; + + for (res = 0; --cur_pos >= 0;) { + fst = &dec->fst; + rice = &dec->rice; + + if (data_cur == framelen) { + if (data_pos == fframes) break; + if (framelen && done_buffer_read()) { + if (set_position(data_pos, TTA_SEEK_TIME) < 0) return -1; + if (res) break; + } + + if (data_pos == fframes - 1 && lastlen) + framelen = lastlen; + else framelen = ttainfo->FRAMELEN; + + decoder_init(tta, ttainfo->NCH, ttainfo->BSIZE); + data_pos++; data_cur = 0; + } + + /* decode Rice unsigned */ + GET_UNARY(unary); + + switch (unary) { + case 0: depth = 0; k = rice->k0; break; + default: + depth = 1; k = rice->k1; + unary--; + } + + if (k) { + GET_BINARY(binary, k); + value = (unary << k) + binary; + } else value = unary; + + value = update_rice(value, rice, depth, shift_16); + + /* Rockbox specific: the following logic move to update_rice() */ +#if 0 + if (depth > 0) + { + rice->sum1 += value - (rice->sum1 >> 4); + if (rice->k1 > 0 && rice->sum1 < shift_16[rice->k1]) + rice->k1--; + else if (rice->sum1 > shift_16[rice->k1 + 1]) + rice->k1++; + value += bit_shift[rice->k0]; + } + rice->sum0 += value - (rice->sum0 >> 4); + if (rice->k0 > 0 && rice->sum0 < shift_16[rice->k0]) + rice->k0--; + else if (rice->sum0 > shift_16[rice->k0 + 1]) + rice->k0++; + + value = DEC(value); +#endif + + /* decompress stage 1: adaptive hybrid filter */ + hybrid_filter(fst, &value); + + /* decompress stage 2: fixed order 1 prediction */ + value += PREDICTOR1(dec->last, pr_bits); + dec->last = value; + + /* check for errors */ + if (abs(value) > maxvalue) { + unsigned int tail = + pcm_buffer_size / (ttainfo->BSIZE * ttainfo->NCH) - res; + ci->memset(buffer, 0, pcm_buffer_size * sizeof(int32_t)); + data_cur += tail; res += tail; + break; + } + + /* Rockbox speciffic: Rockbox supports max 2channels */ + if (ttainfo->NCH == 1) + { + *p++ = value << pcm_shift_bits; + data_cur++; + res++; + } + else + { + if (dec == tta) + { + cache = value; + dec++; + } + else + { + value += cache / 2; + cache = value - cache; + dec = tta; + *p++ = cache << pcm_shift_bits; + *p++ = value << pcm_shift_bits; + data_cur++; + res++; + } + } + } + + return res; +} + +/* Rockbox speciffic: id3 tags functions delete. */ + +/* eof */ diff --git a/lib/rbcodec/codecs/libtta/ttadec.h b/lib/rbcodec/codecs/libtta/ttadec.h new file mode 100644 index 0000000000..c185e5c858 --- /dev/null +++ b/lib/rbcodec/codecs/libtta/ttadec.h @@ -0,0 +1,203 @@ +/* + * ttadec.h + * + * Description: TTAv1 decoder definitions and prototypes + * Developed by: Alexander Djourik + * Pavel Zhilin + * + * Copyright (c) 2004 True Audio Software. All rights reserved. + * + */ + +/* + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the True Audio Software nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef TTADEC_H_ +#define TTADEC_H_ + +#define __ATTRIBUTE_PACKED__ __attribute__((packed)) + +#define TTA1_SIGN 0x31415454 +#define MAX_ORDER 8 + +#ifndef WAVE_FORMAT_PCM +#define WAVE_FORMAT_PCM 1 +#endif + +typedef unsigned long long uint64; + +static const unsigned int crc32_table[256] ICONST_ATTR = { + 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, + 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, + 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, + 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, + 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, + 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, + 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, + 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5, + 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, + 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, + 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, + 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, + 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, + 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f, + 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, + 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, + 0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a, + 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433, + 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, + 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01, + 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, + 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, + 0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c, + 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, + 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, + 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, + 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, + 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, + 0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086, + 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, + 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, + 0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, + 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, + 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, + 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, + 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, + 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, + 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7, + 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, + 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, + 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, + 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, + 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, + 0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79, + 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, + 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, + 0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, + 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, + 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, + 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713, + 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, + 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, + 0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e, + 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, + 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, + 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, + 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, + 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, + 0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0, + 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, + 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, + 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf, + 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, + 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d +}; + +static const unsigned int bit_mask[] ICONST_ATTR = { + 0x00000000, 0x00000001, 0x00000003, 0x00000007, + 0x0000000f, 0x0000001f, 0x0000003f, 0x0000007f, + 0x000000ff, 0x000001ff, 0x000003ff, 0x000007ff, + 0x00000fff, 0x00001fff, 0x00003fff, 0x00007fff, + 0x0000ffff, 0x0001ffff, 0x0003ffff, 0x0007ffff, + 0x000fffff, 0x001fffff, 0x003fffff, 0x007fffff, + 0x00ffffff, 0x01ffffff, 0x03ffffff, 0x07ffffff, + 0x0fffffff, 0x1fffffff, 0x3fffffff, 0x7fffffff, + 0xffffffff +}; + +static const unsigned int bit_shift[] ICONST_ATTR = { + 0x00000001, 0x00000002, 0x00000004, 0x00000008, + 0x00000010, 0x00000020, 0x00000040, 0x00000080, + 0x00000100, 0x00000200, 0x00000400, 0x00000800, + 0x00001000, 0x00002000, 0x00004000, 0x00008000, + 0x00010000, 0x00020000, 0x00040000, 0x00080000, + 0x00100000, 0x00200000, 0x00400000, 0x00800000, + 0x01000000, 0x02000000, 0x04000000, 0x08000000, + 0x10000000, 0x20000000, 0x40000000, 0x80000000, + 0x80000000, 0x80000000, 0x80000000, 0x80000000, + 0x80000000, 0x80000000, 0x80000000, 0x80000000 +}; + +static const unsigned int * const shift_16 ICONST_ATTR = bit_shift + 4; + +typedef unsigned char byte; + +#ifndef ROCKBOX_LITTLE_ENDIAN +#define ENDSWAP_INT16(x) (((((x)>>8)&0xFF)|(((x)&0xFF)<<8))) +#define ENDSWAP_INT32(x) (((((x)>>24)&0xFF)|(((x)>>8)&0xFF00)|(((x)&0xFF00)<<8)|(((x)&0xFF)<<24))) +#define WRITE_BUFFER(x, bsize, out) { \ + if (bsize > 2) *out++ = (byte)(*x >> 16)); \ + if (bsize > 1) *out++ = (byte)(*x >> 8); \ + *out++ = (byte) *x; } +#else +#define ENDSWAP_INT16(x) (x) +#define ENDSWAP_INT32(x) (x) +#define WRITE_BUFFER(x, bsize, out) { \ + *out++ = (byte) *x; \ + if (bsize > 1) *out++ = (byte)(*x >> 8); \ + if (bsize > 2) *out++ = (byte)(*x >> 16); } +#endif + +#define PREDICTOR1(x, k) ((int)((((uint64)x << k) - x) >> k)) +#define DEC(x) (((x)&1)?(((x)+1)>>1):(-(x)>>1)) + +typedef struct { + unsigned int TTAid; + unsigned short AudioFormat; + unsigned short NumChannels; + unsigned short BitsPerSample; + unsigned int SampleRate; + unsigned int DataLength; + unsigned int CRC32; +} __ATTRIBUTE_PACKED__ tta_hdr; + +typedef struct { + unsigned int k0; + unsigned int k1; + unsigned int sum0; + unsigned int sum1; +} adapt; + +typedef struct { + int index; /* Rockbox speciffic */ + int error; + int round; + int shift; + int mutex; + int qm[MAX_ORDER]; + int dx[MAX_ORDER * 3]; /* original: dx[MAX_ORDER + 1] */ + int dl[MAX_ORDER * 3]; /* original: dx[MAX_ORDER + 1] */ +} fltst; + +typedef struct { + fltst fst; + adapt rice; + int last; +} decoder; + +/* Rockbox speciffic: about id3 tags definitions delete. */ +#endif /* TTADEC_H_ */ diff --git a/lib/rbcodec/codecs/libtta/ttalib.h b/lib/rbcodec/codecs/libtta/ttalib.h new file mode 100644 index 0000000000..45da71813a --- /dev/null +++ b/lib/rbcodec/codecs/libtta/ttalib.h @@ -0,0 +1,157 @@ +/* + * ttalib.h + * + * Description: TTAv1 player library prototypes + * Developed by: Alexander Djourik + * Pavel Zhilin + * + * Copyright (c) 2004 True Audio Software. All rights reserved. + * + */ + +/* + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the True Audio Software nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef TTALIB_H_ +#define TTALIB_H_ + +#define MAX_BPS 24 /* Max supported Bit resolution */ +#define MAX_NCH 2 /* Max supported number of channels (Rockbox changes: 8 -> 2) */ + +#ifndef MAXLINE +#define MAX_LINE 1024 +#endif + +/* decoded pcm sample depth (sample 28bit + sign 1bit) */ +#define TTA_OUTPUT_DEPTH 29 + +/* return codes */ +#define NO_ERROR 0 /* No errors found */ +#define OPEN_ERROR 1 /* Can't open file */ +#define FORMAT_ERROR 2 /* Unknown TTA format version */ +#define PLAYER_ERROR 3 /* Not supported file format */ +#define FILE_ERROR 4 /* File is corrupted */ +#define READ_ERROR 5 /* Can't read from file */ +#define MEMORY_ERROR 6 /* Insufficient memory available */ + +/* Rockbox speciffic: does not use FRAME_TIME */ +/* #define FRAME_TIME 1.04489795918367346939 */ +#define MULTIPLY_FRAME_TIME(x) (256 * (x) / 245) /* = FRAME_TIME * x */ +#define SEEK_STEP (int)MULTIPLY_FRAME_TIME(1000) /* (FRAME_TIME * 1000) */ + +#define ISO_BUFFER_LENGTH (1024*32) +#define ISO_NBUFFERS (8) +#define ISO_BUFFERS_SIZE (4096) /* (ISO_BUFFER_LENGTH*ISO_NBUFFERS) */ +#define PCM_BUFFER_LENGTH (4608) +#define MAX_SEEK_TABLE_SIZE (4096) + +typedef struct { + /* FILE *HANDLE; // file handle (Rockbox does not use) */ + unsigned int FILESIZE; /* compressed size */ + unsigned short NCH; /* number of channels */ + unsigned short BPS; /* bits per sample */ + unsigned short BSIZE; /* byte size */ + unsigned short FORMAT; /* audio format */ + unsigned int SAMPLERATE; /* samplerate (sps) */ + unsigned int DATALENGTH; /* data length in samples */ + unsigned int FRAMELEN; /* frame length */ + unsigned int LENGTH; /* playback time (sec) */ + unsigned int STATE; /* return code */ + unsigned int DATAPOS; /* size of ID3v2 header */ + unsigned int BITRATE; /* average bitrate (kbps) */ + /* double COMPRESS; // compression ratio (Rockbox does not use) */ + /* id3_info ID3; // ID3 information (Rockbox does not use) */ +} tta_info; + +enum tta_seek_type +{ + TTA_SEEK_TIME, + TTA_SEEK_POS, +}; + +/*********************** Library functions *************************/ +/* Rockbox speciffic: open_tta_file() does not use */ + +/* Rockbox speciffic: It is used in place of open_tta_file(). */ +int set_tta_info( // FUNCTION: set tta file info structure + tta_info *info); // file info structure +/* + * RETURN VALUE + * This function returns 0 if success. Otherwise, -1 is returned + * and the variable STATE of the currently using info structure + * is set to indicate the error. + * + */ + +/* Rockbox speciffic: close_tta_file() does not use */ + +/* Rockbox speciffic: set_position() change arguments and return value. */ +/* + * FUNCTION: sets playback position + * pos: seek position + * seek_time_ms / SEEK_STEP (when type is TTA_SEEK_TIME) + * file position (when type is TTA_SEEK_POS) + */ +int set_position ( + unsigned int pos, + enum tta_seek_type type); + +/* + * RETURN VALUE + * This function returns the seeked data position (>= 0) if success. Otherwise, -1 is returned + * and the variable STATE of the currently using info structure + * is set to indicate the error. + * + */ + +int player_init ( // FUNCTION: initializes TTA player + tta_info *info); // file info structure +/* + * RETURN VALUE + * This function returns 0 if success. Otherwise, -1 is returned + * and the variable STATE of the currently using info structure + * is set to indicate the error. + * + */ + +void player_stop (void); // FUNCTION: destroys memory pools + +/* Rockbox speciffic: unsigned char -> int32_t */ +int get_samples ( // FUNCTION: decode PCM_BUFFER_LENGTH samples + int32_t *buffer) ICODE_ATTR; // into the current PCM buffer position + +/* + * RETURN VALUE + * This function returns the number of samples successfully decoded. + * Otherwise, -1 is returned and the variable STATE of the currently + * using info structure is set to indicate the error. + * + */ + +const char *get_error_str (int error); // FUNCTION: get error description + +#endif /* TTALIB_H_ */ diff --git a/lib/rbcodec/codecs/libwavpack/LICENSE b/lib/rbcodec/codecs/libwavpack/LICENSE new file mode 100644 index 0000000000..3ee485817d --- /dev/null +++ b/lib/rbcodec/codecs/libwavpack/LICENSE @@ -0,0 +1,25 @@ + Copyright (c) 1998 - 2004 Conifer Software + All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of Conifer Software nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/lib/rbcodec/codecs/libwavpack/README b/lib/rbcodec/codecs/libwavpack/README new file mode 100644 index 0000000000..b373235e1c --- /dev/null +++ b/lib/rbcodec/codecs/libwavpack/README @@ -0,0 +1,52 @@ +//////////////////////////////////////////////////////////////////////////// +// **** WAVPACK **** // +// Hybrid Lossless Wavefile Compressor // +// Copyright (c) 1998 - 2004 Conifer Software. // +// All Rights Reserved. // +// Distributed under the BSD Software License (see license.txt) // +//////////////////////////////////////////////////////////////////////////// + +This package contains a tiny version of the WavPack 4.0 decoder that might +be used in a "resource limited" CPU environment or form the basis for a +hardware decoding implementation. It is packaged with a demo command-line +program that accepts a WavPack audio file on stdin and outputs a RIFF wav +file to stdout. The program is standard C, and a win32 executable is +included which was compiled under MS Visual C++ 6.0 using this command: + +cl /O1 /DWIN32 wvfilter.c wputils.c unpack.c float.c metadata.c words.c bits.c + +WavPack data is read with a stream reading callback. No direct seeking is +provided for, but it is possible to start decoding anywhere in a WavPack +stream. In this case, WavPack will be able to provide the sample-accurate +position when it synchs with the data and begins decoding. + +For demonstration purposes this uses a single static copy of the +WavpackContext structure, so obviously it cannot be used for more than one +file at a time. Also, this decoder will not handle "correction" files, plays +only the first two channels of multi-channel files, and is limited in +resolution in some large integer or floating point files (but always +provides at least 24 bits of resolution). It also will not accept WavPack +files from before version 4.0. + +To make this code viable on the greatest number of hardware platforms, the +following are true: + + speed is about 4x realtime on an AMD K6 300 MHz + ("high" mode 16/44 stereo; normal mode is about twice that fast) + + no floating-point math required; just 32b * 32b = 32b int multiply + + large data areas are static and less than 4K total + executable code and tables are less than 32K + no malloc / free usage + +To maintain compatibility on various platforms, the following conventions +are used: + + a "short" must be 16-bits + a "long" must be 32-bits + an "int" must be at least 16-bits, but may be larger + a "char" must default to signed + + +Questions or comments should be directed to david@wavpack.com diff --git a/lib/rbcodec/codecs/libwavpack/README.rockbox b/lib/rbcodec/codecs/libwavpack/README.rockbox new file mode 100644 index 0000000000..a74b0c511c --- /dev/null +++ b/lib/rbcodec/codecs/libwavpack/README.rockbox @@ -0,0 +1,15 @@ +Library: wavpack - Release 4.1 - September 14, 2004 +Imported: 2005-02-25 by Christian Gmeiner + + +This directory contains a "tiny" decoder version of wavpack for version 4.x. + +LICENSING INFORMATION + +wavpack is released under the BSD License as described +in the LICENSE file in this directory. + + +IMPORT DETAILS + +Excluded is wvfilter.c, because it is only a test programm. diff --git a/lib/rbcodec/codecs/libwavpack/SOURCES b/lib/rbcodec/codecs/libwavpack/SOURCES new file mode 100644 index 0000000000..b2518e59e0 --- /dev/null +++ b/lib/rbcodec/codecs/libwavpack/SOURCES @@ -0,0 +1,15 @@ +bits.c +float.c +metadata.c +unpack.c +pack.c +words.c +wputils.c +#if defined(CPU_COLDFIRE) +coldfire.S +#endif +#if defined(CPU_ARM) +arm.S +arml.S +#endif + diff --git a/lib/rbcodec/codecs/libwavpack/arm.S b/lib/rbcodec/codecs/libwavpack/arm.S new file mode 100644 index 0000000000..32de1df7de --- /dev/null +++ b/lib/rbcodec/codecs/libwavpack/arm.S @@ -0,0 +1,477 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2006 by David Bryant + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +/* This is an assembly optimized version of the following WavPack function: + * + * void decorr_stereo_pass_cont_arm (struct decorr_pass *dpp, + * long *buffer, long sample_count); + * + * It performs a single pass of stereo decorrelation on the provided buffer. + * Note that this version of the function requires that the 8 previous stereo + * samples are visible and correct. In other words, it ignores the "samples_*" + * fields in the decorr_pass structure and gets the history data directly + * from the buffer. It does, however, return the appropriate history samples + * to the decorr_pass structure before returning. + * + * This is written to work on a ARM7TDMI processor. This version only uses the + * 32-bit multiply-accumulate instruction and so will overflow with 24-bit + * WavPack files. + */ + +#include "config.h" + + .text + .align + .global decorr_stereo_pass_cont_arm + +/* + * on entry: + * + * r0 = struct decorr_pass *dpp + * r1 = long *buffer + * r2 = long sample_count + */ + +decorr_stereo_pass_cont_arm: + + stmfd sp!, {r4 - r8, r10, r11, lr} + mov r5, r0 @ r5 = dpp + mov r11, #512 @ r11 = 512 for rounding + ldrsh r6, [r0, #2] @ r6 = dpp->delta + ldrsh r4, [r0, #4] @ r4 = dpp->weight_A + ldrsh r0, [r0, #6] @ r0 = dpp->weight_B + cmp r2, #0 @ exit if no samples to process + beq common_exit + + add r7, r1, r2, asl #3 @ r7 = buffer ending position + ldrsh r2, [r5, #0] @ r2 = dpp->term + cmp r2, #0 + bmi minus_term + + ldr lr, [r1, #-16] @ load 2 sample history from buffer + ldr r10, [r1, #-12] @ for terms 2, 17, and 18 + ldr r8, [r1, #-8] + ldr r3, [r1, #-4] + cmp r2, #17 + beq term_17_loop + cmp r2, #18 + beq term_18_loop + cmp r2, #2 + beq term_2_loop + b term_default_loop @ else handle default (1-8, except 2) + +minus_term: + mov r10, #1024 @ r10 = -1024 for weight clipping + rsb r10, r10, #0 @ (only used for negative terms) + cmn r2, #1 + beq term_minus_1 + cmn r2, #2 + beq term_minus_2 + cmn r2, #3 + beq term_minus_3 + b common_exit + +/* + ****************************************************************************** + * Loop to handle term = 17 condition + * + * r0 = dpp->weight_B r8 = previous left sample + * r1 = bptr r9 = + * r2 = current sample r10 = second previous left sample + * r3 = previous right sample r11 = 512 (for rounding) + * r4 = dpp->weight_A ip = current decorrelation value + * r5 = dpp sp = + * r6 = dpp->delta lr = second previous right sample + * r7 = eptr pc = + ******************************************************************************* + */ + +term_17_loop: + rsbs ip, lr, r8, asl #1 @ decorr value = (2 * prev) - 2nd prev + mov lr, r8 @ previous becomes 2nd previous + ldr r2, [r1], #4 @ get sample & update pointer + mla r8, ip, r4, r11 @ mult decorr value by weight, round, + add r8, r2, r8, asr #10 @ shift, and add to new sample + strne r8, [r1, #-4] @ if change possible, store sample back + cmpne r2, #0 + beq .L325 + teq ip, r2 @ update weight based on signs + submi r4, r4, r6 + addpl r4, r4, r6 + +.L325: rsbs ip, r10, r3, asl #1 @ do same thing for right channel + mov r10, r3 + ldr r2, [r1], #4 + mla r3, ip, r0, r11 + add r3, r2, r3, asr #10 + strne r3, [r1, #-4] + cmpne r2, #0 + beq .L329 + teq ip, r2 + submi r0, r0, r6 + addpl r0, r0, r6 + +.L329: cmp r7, r1 @ loop back if more samples to do + bhi term_17_loop + b store_1718 @ common exit for terms 17 & 18 + +/* + ****************************************************************************** + * Loop to handle term = 18 condition + * + * r0 = dpp->weight_B r8 = previous left sample + * r1 = bptr r9 = + * r2 = current sample r10 = second previous left sample + * r3 = previous right sample r11 = 512 (for rounding) + * r4 = dpp->weight_A ip = decorrelation value + * r5 = dpp sp = + * r6 = dpp->delta lr = second previous right sample + * r7 = eptr pc = + ******************************************************************************* + */ + +term_18_loop: + sub ip, r8, lr @ decorr value = + mov lr, r8 @ ((3 * prev) - 2nd prev) >> 1 + adds ip, r8, ip, asr #1 + ldr r2, [r1], #4 @ get sample & update pointer + mla r8, ip, r4, r11 @ mult decorr value by weight, round, + add r8, r2, r8, asr #10 @ shift, and add to new sample + strne r8, [r1, #-4] @ if change possible, store sample back + cmpne r2, #0 + beq .L337 + teq ip, r2 @ update weight based on signs + submi r4, r4, r6 + addpl r4, r4, r6 + +.L337: sub ip, r3, r10 @ do same thing for right channel + mov r10, r3 + adds ip, r3, ip, asr #1 + ldr r2, [r1], #4 + mla r3, ip, r0, r11 + add r3, r2, r3, asr #10 + strne r3, [r1, #-4] + cmpne r2, #0 + beq .L341 + teq ip, r2 + submi r0, r0, r6 + addpl r0, r0, r6 + +.L341: cmp r7, r1 @ loop back if more samples to do + bhi term_18_loop + +/* common exit for terms 17 & 18 */ + +store_1718: + str r3, [r5, #40] @ store sample history into struct + str r8, [r5, #8] + str r10, [r5, #44] + str lr, [r5, #12] + b common_exit @ and return + +/* + ****************************************************************************** + * Loop to handle term = 2 condition + * (note that this case can be handled by the default term handler (1-8), but + * this special case is faster because it doesn't have to read memory twice) + * + * r0 = dpp->weight_B r8 = previous left sample + * r1 = bptr r9 = + * r2 = current sample r10 = second previous left sample + * r3 = previous right sample r11 = 512 (for rounding) + * r4 = dpp->weight_A ip = decorrelation value + * r5 = dpp sp = + * r6 = dpp->delta lr = second previous right sample + * r7 = eptr pc = + ******************************************************************************* + */ + +term_2_loop: + movs ip, lr @ get decorrelation value & test + mov lr, r8 @ previous becomes 2nd previous + ldr r2, [r1], #4 @ get sample & update pointer + mla r8, ip, r4, r11 @ mult decorr value by weight, round, + add r8, r2, r8, asr #10 @ shift, and add to new sample + strne r8, [r1, #-4] @ if change possible, store sample back + cmpne r2, #0 + beq .L225 + teq ip, r2 @ update weight based on signs + submi r4, r4, r6 + addpl r4, r4, r6 + +.L225: movs ip, r10 @ do same thing for right channel + mov r10, r3 + ldr r2, [r1], #4 + mla r3, ip, r0, r11 + add r3, r2, r3, asr #10 + strne r3, [r1, #-4] + cmpne r2, #0 + beq .L229 + teq ip, r2 + submi r0, r0, r6 + addpl r0, r0, r6 + +.L229: cmp r7, r1 @ loop back if more samples to do + bhi term_2_loop + b default_term_exit @ this exit updates all dpp->samples + +/* + ****************************************************************************** + * Loop to handle default term condition + * + * r0 = dpp->weight_B r8 = result accumulator + * r1 = bptr r9 = + * r2 = dpp->term r10 = + * r3 = decorrelation value r11 = 512 (for rounding) + * r4 = dpp->weight_A ip = current sample + * r5 = dpp sp = + * r6 = dpp->delta lr = + * r7 = eptr pc = + ******************************************************************************* + */ + +term_default_loop: + ldr ip, [r1] @ get original sample + ldr r3, [r1, -r2, asl #3] @ get decorrelation value based on term + mla r8, r3, r4, r11 @ mult decorr value by weight, round, + add r8, ip, r8, asr #10 @ shift and add to new sample + str r8, [r1], #4 @ store update sample + cmp r3, #0 + cmpne ip, #0 + beq .L350 + teq ip, r3 @ update weight based on signs + submi r4, r4, r6 + addpl r4, r4, r6 + +.L350: ldr ip, [r1] @ do the same thing for right channel + ldr r3, [r1, -r2, asl #3] + mla r8, r3, r0, r11 + add r8, ip, r8, asr #10 + str r8, [r1], #4 + cmp r3, #0 + cmpne ip, #0 + beq .L354 + teq ip, r3 + submi r0, r0, r6 + addpl r0, r0, r6 + +.L354: cmp r7, r1 @ loop back if more samples to do + bhi term_default_loop + +/* + * This exit is used by terms 1-8 to store the previous 8 samples into the decorr + * structure (even if they are not all used for the given term) + */ + +default_term_exit: + ldrsh r3, [r5, #0] + sub ip, r3, #1 + mov lr, #7 + +.L358: and r3, ip, #7 + add r3, r5, r3, asl #2 + ldr r2, [r1, #-4] + str r2, [r3, #40] + ldr r2, [r1, #-8]! + str r2, [r3, #8] + sub ip, ip, #1 + sub lr, lr, #1 + cmn lr, #1 + bne .L358 + b common_exit + +/* + ****************************************************************************** + * Loop to handle term = -1 condition + * + * r0 = dpp->weight_B r8 = + * r1 = bptr r9 = + * r2 = intermediate result r10 = -1024 (for clipping) + * r3 = previous right sample r11 = 512 (for rounding) + * r4 = dpp->weight_A ip = current sample + * r5 = dpp sp = + * r6 = dpp->delta lr = updated left sample + * r7 = eptr pc = + ******************************************************************************* + */ + +term_minus_1: + ldr r3, [r1, #-4] + +term_minus_1_loop: + ldr ip, [r1] @ for left channel the decorrelation value + mla r2, r3, r4, r11 @ is the previous right sample (in r3) + add lr, ip, r2, asr #10 + str lr, [r1], #8 + cmp r3, #0 + cmpne ip, #0 + beq .L361 + teq ip, r3 @ update weight based on signs + submi r4, r4, r6 + addpl r4, r4, r6 + cmp r4, #1024 + movgt r4, #1024 + cmp r4, r10 + movlt r4, r10 + +.L361: ldr r2, [r1, #-4] @ for right channel the decorrelation value + mla r3, lr, r0, r11 @ is the just updated right sample (in lr) + add r3, r2, r3, asr #10 + str r3, [r1, #-4] + cmp lr, #0 + cmpne r2, #0 + beq .L369 + teq r2, lr + submi r0, r0, r6 + addpl r0, r0, r6 + cmp r0, #1024 @ then clip weight to +/-1024 + movgt r0, #1024 + cmp r0, r10 + movlt r0, r10 + +.L369: cmp r7, r1 @ loop back if more samples to do + bhi term_minus_1_loop + + str r3, [r5, #8] @ else store right sample and exit + b common_exit + +/* + ****************************************************************************** + * Loop to handle term = -2 condition + * (note that the channels are processed in the reverse order here) + * + * r0 = dpp->weight_B r8 = + * r1 = bptr r9 = + * r2 = intermediate result r10 = -1024 (for clipping) + * r3 = previous left sample r11 = 512 (for rounding) + * r4 = dpp->weight_A ip = current sample + * r5 = dpp sp = + * r6 = dpp->delta lr = updated right sample + * r7 = eptr pc = + ******************************************************************************* + */ + +term_minus_2: + ldr r3, [r1, #-8] + +term_minus_2_loop: + ldr ip, [r1, #4] @ for right channel the decorrelation value + mla r2, r3, r0, r11 @ is the previous left sample (in r3) + add lr, ip, r2, asr #10 + str lr, [r1, #4] + cmp r3, #0 + cmpne ip, #0 + beq .L380 + teq ip, r3 @ update weight based on signs + submi r0, r0, r6 + addpl r0, r0, r6 + cmp r0, #1024 @ then clip weight to +/-1024 + movgt r0, #1024 + cmp r0, r10 + movlt r0, r10 + +.L380: ldr r2, [r1, #0] @ for left channel the decorrelation value + mla r3, lr, r4, r11 @ is the just updated left sample (in lr) + add r3, r2, r3, asr #10 + str r3, [r1], #8 + cmp lr, #0 + cmpne r2, #0 + beq .L388 + teq r2, lr + submi r4, r4, r6 + addpl r4, r4, r6 + cmp r4, #1024 + movgt r4, #1024 + cmp r4, r10 + movlt r4, r10 + +.L388: cmp r7, r1 @ loop back if more samples to do + bhi term_minus_2_loop + + str r3, [r5, #40] @ else store left channel and exit + b common_exit + +/* + ****************************************************************************** + * Loop to handle term = -3 condition + * + * r0 = dpp->weight_B r8 = previous left sample + * r1 = bptr r9 = + * r2 = current left sample r10 = -1024 (for clipping) + * r3 = previous right sample r11 = 512 (for rounding) + * r4 = dpp->weight_A ip = intermediate result + * r5 = dpp sp = + * r6 = dpp->delta lr = + * r7 = eptr pc = + ******************************************************************************* + */ + +term_minus_3: + ldr r3, [r1, #-4] @ load previous samples + ldr r8, [r1, #-8] + +term_minus_3_loop: + ldr ip, [r1] + mla r2, r3, r4, r11 + add r2, ip, r2, asr #10 + str r2, [r1], #4 + cmp r3, #0 + cmpne ip, #0 + beq .L399 + teq ip, r3 @ update weight based on signs + submi r4, r4, r6 + addpl r4, r4, r6 + cmp r4, #1024 @ then clip weight to +/-1024 + movgt r4, #1024 + cmp r4, r10 + movlt r4, r10 + +.L399: movs ip, r8 @ ip = previous left we use now + mov r8, r2 @ r8 = current left we use next time + ldr r2, [r1], #4 + mla r3, ip, r0, r11 + add r3, r2, r3, asr #10 + strne r3, [r1, #-4] + cmpne r2, #0 + beq .L407 + teq ip, r2 + submi r0, r0, r6 + addpl r0, r0, r6 + cmp r0, #1024 + movgt r0, #1024 + cmp r0, r10 + movlt r0, r10 + +.L407: cmp r7, r1 @ loop back if more samples to do + bhi term_minus_3_loop + + str r3, [r5, #8] @ else store previous samples & exit + str r8, [r5, #40] + +/* + * Before finally exiting we must store weights back for next time + */ + +common_exit: + strh r4, [r5, #4] + strh r0, [r5, #6] + ldmpc regs="r4-r8, r10-r11" + diff --git a/lib/rbcodec/codecs/libwavpack/arml.S b/lib/rbcodec/codecs/libwavpack/arml.S new file mode 100644 index 0000000000..60818aa1e6 --- /dev/null +++ b/lib/rbcodec/codecs/libwavpack/arml.S @@ -0,0 +1,506 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2006 by David Bryant + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +/* This is an assembly optimized version of the following WavPack function: + * + * void decorr_stereo_pass_cont_arml (struct decorr_pass *dpp, + * long *buffer, long sample_count); + * + * It performs a single pass of stereo decorrelation on the provided buffer. + * Note that this version of the function requires that the 8 previous stereo + * samples are visible and correct. In other words, it ignores the "samples_*" + * fields in the decorr_pass structure and gets the history data directly + * from the buffer. It does, however, return the appropriate history samples + * to the decorr_pass structure before returning. + * + * This is written to work on a ARM7TDMI processor. This version uses the + * 64-bit multiply-accumulate instruction and so can be used with all + * WavPack files. However, for optimum performance with 16-bit WavPack + * files, there is a faster version that only uses the 32-bit MLA + * instruction. + */ + +#include "config.h" + + .text + .align + .global decorr_stereo_pass_cont_arml + +/* + * on entry: + * + * r0 = struct decorr_pass *dpp + * r1 = long *buffer + * r2 = long sample_count + */ + +decorr_stereo_pass_cont_arml: + + stmfd sp!, {r4 - r8, r10, r11, lr} + mov r5, r0 @ r5 = dpp + mov r11, #512 @ r11 = 512 for rounding + ldrsh r6, [r0, #2] @ r6 = dpp->delta + ldrsh r4, [r0, #4] @ r4 = dpp->weight_A + ldrsh r0, [r0, #6] @ r0 = dpp->weight_B + cmp r2, #0 @ exit if no samples to process + beq common_exit + + mov r0, r0, asl #18 @ for 64-bit math we use weights << 18 + mov r4, r4, asl #18 + mov r6, r6, asl #18 + add r7, r1, r2, asl #3 @ r7 = buffer ending position + ldrsh r2, [r5, #0] @ r2 = dpp->term + cmp r2, #0 + blt minus_term + + ldr lr, [r1, #-16] @ load 2 sample history from buffer + ldr r10, [r1, #-12] @ for terms 2, 17, and 18 + ldr r8, [r1, #-8] + ldr r3, [r1, #-4] + + cmp r2, #18 + beq term_18_loop + mov lr, lr, asl #4 + mov r10, r10, asl #4 + cmp r2, #2 + beq term_2_loop + cmp r2, #17 + beq term_17_loop + b term_default_loop + +minus_term: + mov r10, #(1024 << 18) @ r10 = -1024 << 18 for weight clipping + rsb r10, r10, #0 @ (only used for negative terms) + cmn r2, #1 + beq term_minus_1 + cmn r2, #2 + beq term_minus_2 + cmn r2, #3 + beq term_minus_3 + b common_exit + +/* + ****************************************************************************** + * Loop to handle term = 17 condition + * + * r0 = dpp->weight_B r8 = previous left sample + * r1 = bptr r9 = + * r2 = current sample r10 = second previous left sample << 4 + * r3 = previous right sample r11 = lo accumulator (for rounding) + * r4 = dpp->weight_A ip = current decorrelation value + * r5 = dpp sp = + * r6 = dpp->delta lr = second previous right sample << 4 + * r7 = eptr pc = + ******************************************************************************* + */ + +term_17_loop: + rsbs ip, lr, r8, asl #5 @ decorr value = (2 * prev) - 2nd prev + mov lr, r8, asl #4 @ previous becomes 2nd previous + ldr r2, [r1], #4 @ get sample & update pointer + mov r11, #0x80000000 + mov r8, r2 + smlalne r11, r8, r4, ip + strne r8, [r1, #-4] @ if change possible, store sample back + cmpne r2, #0 + beq .L325 + teq ip, r2 @ update weight based on signs + submi r4, r4, r6 + addpl r4, r4, r6 + +.L325: rsbs ip, r10, r3, asl #5 @ do same thing for right channel + mov r10, r3, asl #4 + ldr r2, [r1], #4 + mov r11, #0x80000000 + mov r3, r2 + smlalne r11, r3, r0, ip + strne r3, [r1, #-4] + cmpne r2, #0 + beq .L329 + teq ip, r2 + submi r0, r0, r6 + addpl r0, r0, r6 + +.L329: cmp r7, r1 @ loop back if more samples to do + bhi term_17_loop + mov lr, lr, asr #4 + mov r10, r10, asr #4 + b store_1718 @ common exit for terms 17 & 18 + +/* + ****************************************************************************** + * Loop to handle term = 18 condition + * + * r0 = dpp->weight_B r8 = previous left sample + * r1 = bptr r9 = + * r2 = current sample r10 = second previous left sample + * r3 = previous right sample r11 = lo accumulator (for rounding) + * r4 = dpp->weight_A ip = decorrelation value + * r5 = dpp sp = + * r6 = dpp->delta lr = second previous right sample + * r7 = eptr pc = + ******************************************************************************* + */ + +term_18_loop: + rsb ip, lr, r8 @ decorr value = + mov lr, r8 @ ((3 * prev) - 2nd prev) >> 1 + add ip, lr, ip, asr #1 + movs ip, ip, asl #4 + ldr r2, [r1], #4 @ get sample & update pointer + mov r11, #0x80000000 + mov r8, r2 + smlalne r11, r8, r4, ip + strne r8, [r1, #-4] @ if change possible, store sample back + cmpne r2, #0 + beq .L337 + teq ip, r2 @ update weight based on signs + submi r4, r4, r6 + addpl r4, r4, r6 + +.L337: rsb ip, r10, r3 @ do same thing for right channel + mov r10, r3 + add ip, r10, ip, asr #1 + movs ip, ip, asl #4 + ldr r2, [r1], #4 + mov r11, #0x80000000 + mov r3, r2 + smlalne r11, r3, r0, ip + strne r3, [r1, #-4] + cmpne r2, #0 + beq .L341 + teq ip, r2 + submi r0, r0, r6 + addpl r0, r0, r6 + +.L341: cmp r7, r1 @ loop back if more samples to do + bhi term_18_loop + +/* common exit for terms 17 & 18 */ + +store_1718: + str r3, [r5, #40] @ store sample history into struct + str r8, [r5, #8] + str r10, [r5, #44] + str lr, [r5, #12] + b common_exit @ and return + +/* + ****************************************************************************** + * Loop to handle term = 2 condition + * (note that this case can be handled by the default term handler (1-8), but + * this special case is faster because it doesn't have to read memory twice) + * + * r0 = dpp->weight_B r8 = previous left sample + * r1 = bptr r9 = + * r2 = current sample r10 = second previous left sample << 4 + * r3 = previous right sample r11 = lo accumulator (for rounding) + * r4 = dpp->weight_A ip = decorrelation value + * r5 = dpp sp = + * r6 = dpp->delta lr = second previous right sample << 4 + * r7 = eptr pc = + ******************************************************************************* + */ + +term_2_loop: + movs ip, lr @ get decorrelation value & test + ldr r2, [r1], #4 @ get sample & update pointer + mov lr, r8, asl #4 @ previous becomes 2nd previous + mov r11, #0x80000000 + mov r8, r2 + smlalne r11, r8, r4, ip + strne r8, [r1, #-4] @ if change possible, store sample back + cmpne r2, #0 + beq .L225 + teq ip, r2 @ update weight based on signs + submi r4, r4, r6 + addpl r4, r4, r6 + +.L225: movs ip, r10 @ do same thing for right channel + ldr r2, [r1], #4 + mov r10, r3, asl #4 + mov r11, #0x80000000 + mov r3, r2 + smlalne r11, r3, r0, ip + strne r3, [r1, #-4] + cmpne r2, #0 + beq .L229 + teq ip, r2 + submi r0, r0, r6 + addpl r0, r0, r6 + +.L229: cmp r7, r1 @ loop back if more samples to do + bhi term_2_loop + + b default_term_exit @ this exit updates all dpp->samples + +/* + ****************************************************************************** + * Loop to handle default term condition + * + * r0 = dpp->weight_B r8 = result accumulator + * r1 = bptr r9 = + * r2 = dpp->term r10 = + * r3 = decorrelation value r11 = lo accumulator (for rounding) + * r4 = dpp->weight_A ip = current sample + * r5 = dpp sp = + * r6 = dpp->delta lr = + * r7 = eptr pc = + ******************************************************************************* + */ + +term_default_loop: + ldr r3, [r1, -r2, asl #3] @ get decorrelation value based on term + ldr ip, [r1], #4 @ get original sample and bump ptr + movs r3, r3, asl #4 + mov r11, #0x80000000 + mov r8, ip + smlalne r11, r8, r4, r3 + strne r8, [r1, #-4] @ if possibly changed, store updated sample + cmpne ip, #0 + beq .L350 + teq ip, r3 @ update weight based on signs + submi r4, r4, r6 + addpl r4, r4, r6 + +.L350: ldr r3, [r1, -r2, asl #3] @ do the same thing for right channel + ldr ip, [r1], #4 + movs r3, r3, asl #4 + mov r11, #0x80000000 + mov r8, ip + smlalne r11, r8, r0, r3 + strne r8, [r1, #-4] + cmpne ip, #0 + beq .L354 + teq ip, r3 + submi r0, r0, r6 + addpl r0, r0, r6 + +.L354: cmp r7, r1 @ loop back if more samples to do + bhi term_default_loop + +/* + * This exit is used by terms 1-8 to store the previous 8 samples into the decorr + * structure (even if they are not all used for the given term) + */ + +default_term_exit: + ldrsh r3, [r5, #0] + sub ip, r3, #1 + mov lr, #7 + +.L358: and r3, ip, #7 + add r3, r5, r3, asl #2 + ldr r2, [r1, #-4] + str r2, [r3, #40] + ldr r2, [r1, #-8]! + str r2, [r3, #8] + sub ip, ip, #1 + sub lr, lr, #1 + cmn lr, #1 + bne .L358 + b common_exit + +/* + ****************************************************************************** + * Loop to handle term = -1 condition + * + * r0 = dpp->weight_B r8 = + * r1 = bptr r9 = + * r2 = intermediate result r10 = -1024 (for clipping) + * r3 = previous right sample r11 = lo accumulator (for rounding) + * r4 = dpp->weight_A ip = current sample + * r5 = dpp sp = + * r6 = dpp->delta lr = updated left sample + * r7 = eptr pc = + ******************************************************************************* + */ + +term_minus_1: + ldr r3, [r1, #-4] + +term_minus_1_loop: + ldr ip, [r1], #8 @ for left channel the decorrelation value + movs r3, r3, asl #4 @ is the previous right sample (in r3) + mov r11, #0x80000000 + mov lr, ip + smlalne r11, lr, r4, r3 + strne lr, [r1, #-8] + cmpne ip, #0 + beq .L361 + teq ip, r3 @ update weight based on signs + submi r4, r4, r6 + addpl r4, r4, r6 + cmp r4, #(1024 << 18) + movgt r4, #(1024 << 18) + cmp r4, r10 + movlt r4, r10 + +.L361: ldr r2, [r1, #-4] @ for right channel the decorrelation value + movs lr, lr, asl #4 + mov r11, #0x80000000 + mov r3, r2 + smlalne r11, r3, r0, lr + strne r3, [r1, #-4] + cmpne r2, #0 + beq .L369 + teq r2, lr + submi r0, r0, r6 + addpl r0, r0, r6 + cmp r0, #(1024 << 18) @ then clip weight to +/-1024 + movgt r0, #(1024 << 18) + cmp r0, r10 + movlt r0, r10 + +.L369: cmp r7, r1 @ loop back if more samples to do + bhi term_minus_1_loop + + str r3, [r5, #8] @ else store right sample and exit + b common_exit + +/* + ****************************************************************************** + * Loop to handle term = -2 condition + * (note that the channels are processed in the reverse order here) + * + * r0 = dpp->weight_B r8 = + * r1 = bptr r9 = + * r2 = intermediate result r10 = -1024 (for clipping) + * r3 = previous left sample r11 = lo accumulator (for rounding) + * r4 = dpp->weight_A ip = current sample + * r5 = dpp sp = + * r6 = dpp->delta lr = updated right sample + * r7 = eptr pc = + ******************************************************************************* + */ + +term_minus_2: + ldr r3, [r1, #-8] + +term_minus_2_loop: + ldr ip, [r1, #4] @ for right channel the decorrelation value + movs r3, r3, asl #4 @ is the previous left sample (in r3) + mov r11, #0x80000000 + mov lr, ip + smlalne r11, lr, r0, r3 + strne lr, [r1, #4] + cmpne ip, #0 + beq .L380 + teq ip, r3 @ update weight based on signs + submi r0, r0, r6 + addpl r0, r0, r6 + cmp r0, #(1024 << 18) @ then clip weight to +/-1024 + movgt r0, #(1024 << 18) + cmp r0, r10 + movlt r0, r10 + +.L380: ldr r2, [r1], #8 @ for left channel the decorrelation value + movs lr, lr, asl #4 + mov r11, #0x80000000 + mov r3, r2 + smlalne r11, r3, r4, lr + strne r3, [r1, #-8] + cmpne r2, #0 + beq .L388 + teq r2, lr + submi r4, r4, r6 + addpl r4, r4, r6 + cmp r4, #(1024 << 18) + movgt r4, #(1024 << 18) + cmp r4, r10 + movlt r4, r10 + +.L388: cmp r7, r1 @ loop back if more samples to do + bhi term_minus_2_loop + + str r3, [r5, #40] @ else store left channel and exit + b common_exit + +/* + ****************************************************************************** + * Loop to handle term = -3 condition + * + * r0 = dpp->weight_B r8 = previous left sample + * r1 = bptr r9 = + * r2 = current left sample r10 = -1024 (for clipping) + * r3 = previous right sample r11 = lo accumulator (for rounding) + * r4 = dpp->weight_A ip = intermediate result + * r5 = dpp sp = + * r6 = dpp->delta lr = + * r7 = eptr pc = + ******************************************************************************* + */ + +term_minus_3: + ldr r3, [r1, #-4] @ load previous samples + ldr r8, [r1, #-8] + +term_minus_3_loop: + ldr ip, [r1], #4 + movs r3, r3, asl #4 + mov r11, #0x80000000 + mov r2, ip + smlalne r11, r2, r4, r3 + strne r2, [r1, #-4] + cmpne ip, #0 + beq .L399 + teq ip, r3 @ update weight based on signs + submi r4, r4, r6 + addpl r4, r4, r6 + cmp r4, #(1024 << 18) @ then clip weight to +/-1024 + movgt r4, #(1024 << 18) + cmp r4, r10 + movlt r4, r10 + +.L399: movs ip, r8, asl #4 @ ip = previous left we use now + mov r8, r2 @ r8 = current left we use next time + ldr r2, [r1], #4 + mov r11, #0x80000000 + mov r3, r2 + smlalne r11, r3, r0, ip + strne r3, [r1, #-4] + cmpne r2, #0 + beq .L407 + teq ip, r2 + submi r0, r0, r6 + addpl r0, r0, r6 + cmp r0, #(1024 << 18) + movgt r0, #(1024 << 18) + cmp r0, r10 + movlt r0, r10 + +.L407: cmp r7, r1 @ loop back if more samples to do + bhi term_minus_3_loop + + str r3, [r5, #8] @ else store previous samples & exit + str r8, [r5, #40] + +/* + * Before finally exiting we must store weights back for next time + */ + +common_exit: + mov r0, r0, asr #18 @ restore weights to real magnitude + mov r4, r4, asr #18 + strh r4, [r5, #4] + strh r0, [r5, #6] + ldmpc regs="r4-r8, r10-r11" + diff --git a/lib/rbcodec/codecs/libwavpack/bits.c b/lib/rbcodec/codecs/libwavpack/bits.c new file mode 100644 index 0000000000..0f0e79c292 --- /dev/null +++ b/lib/rbcodec/codecs/libwavpack/bits.c @@ -0,0 +1,170 @@ +//////////////////////////////////////////////////////////////////////////// +// **** WAVPACK **** // +// Hybrid Lossless Wavefile Compressor // +// Copyright (c) 1998 - 2004 Conifer Software. // +// All Rights Reserved. // +// Distributed under the BSD Software License (see license.txt) // +//////////////////////////////////////////////////////////////////////////// + +// bits.c + +// This module provides utilities to support the BitStream structure which is +// used to read and write all WavPack audio data streams. It also contains a +// wrapper for the stream I/O functions and a set of functions dealing with +// endian-ness, both for enhancing portability. Finally, a debug wrapper for +// the malloc() system is provided. + +#include "wavpack.h" +#include "system.h" + +#include + +////////////////////////// Bitstream functions //////////////////////////////// + +// Open the specified BitStream and associate with the specified buffer. + +static void bs_read (Bitstream *bs); + +void bs_open_read (Bitstream *bs, uchar *buffer_start, uchar *buffer_end, read_stream file, uint32_t file_bytes) +{ + CLEAR (*bs); + bs->buf = buffer_start; + bs->end = buffer_end; + + if (file) { + bs->ptr = bs->end - 1; + bs->file_bytes = file_bytes; + bs->file = file; + } + else + bs->ptr = bs->buf - 1; + + bs->wrap = bs_read; +} + +// This function is only called from the getbit() and getbits() macros when +// the BitStream has been exhausted and more data is required. Sinve these +// bistreams no longer access files, this function simple sets an error and +// resets the buffer. + +static void bs_read (Bitstream *bs) +{ + if (bs->file && bs->file_bytes) { + uint32_t bytes_read, bytes_to_read = bs->end - bs->buf; + + if (bytes_to_read > bs->file_bytes) + bytes_to_read = bs->file_bytes; + + bytes_read = bs->file (bs->buf, bytes_to_read); + + if (bytes_read) { + bs->end = bs->buf + bytes_read; + bs->file_bytes -= bytes_read; + } + else { + memset (bs->buf, -1, bs->end - bs->buf); + bs->error = 1; + } + } + else + bs->error = 1; + + if (bs->error) + memset (bs->buf, -1, bs->end - bs->buf); + + bs->ptr = bs->buf; +} + +// Open the specified BitStream using the specified buffer pointers. It is +// assumed that enough buffer space has been allocated for all data that will +// be written, otherwise an error will be generated. + +static void bs_write (Bitstream *bs); + +void bs_open_write (Bitstream *bs, uchar *buffer_start, uchar *buffer_end) +{ + bs->error = bs->sr = bs->bc = 0; + bs->ptr = bs->buf = buffer_start; + bs->end = buffer_end; + bs->wrap = bs_write; +} + +// This function is only called from the putbit() and putbits() macros when +// the buffer is full, which is now flagged as an error. + +static void bs_write (Bitstream *bs) +{ + bs->ptr = bs->buf; + bs->error = 1; +} + +// This function forces a flushing write of the specified BitStream, and +// returns the total number of bytes written into the buffer. + +uint32_t bs_close_write (Bitstream *bs) +{ + uint32_t bytes_written; + + if (bs->error) + return (uint32_t) -1; + + while (bs->bc || ((bs->ptr - bs->buf) & 1)) putbit_1 (bs); + bytes_written = bs->ptr - bs->buf; + CLEAR (*bs); + return bytes_written; +} + +/////////////////////// Endian Correction Routines //////////////////////////// + +void little_endian_to_native (void *data, char *format) +{ + uchar *cp = (uchar *) data; + + while (*format) { + switch (*format) { + case 'L': + *(long *)cp = letoh32(*(long *)cp); + cp += 4; + break; + + case 'S': + *(short *)cp = letoh16(*(short *)cp); + cp += 2; + break; + + default: + if (*format >= '0' && *format <= '9') + cp += *format - '0'; + + break; + } + + format++; + } +} + +void native_to_little_endian (void *data, char *format) +{ + uchar *cp = (uchar *) data; + + while (*format) { + switch (*format) { + case 'L': + *(long *)cp = htole32(*(long *)cp); + cp += 4; + break; + + case 'S': + *(short *)cp = htole16(*(short *)cp); + cp += 2; + break; + + default: + if (*format >= '0' && *format <= '9') + cp += *format - '0'; + break; + } + + format++; + } +} diff --git a/lib/rbcodec/codecs/libwavpack/coldfire.S b/lib/rbcodec/codecs/libwavpack/coldfire.S new file mode 100644 index 0000000000..884a0ac90f --- /dev/null +++ b/lib/rbcodec/codecs/libwavpack/coldfire.S @@ -0,0 +1,537 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2005 by David Bryant + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +/* This is an assembly optimized version of the following WavPack function: + * + * void decorr_stereo_pass_cont_mcf5249 (struct decorr_pass *dpp, + * long *buffer, long sample_count); + * + * It performs a single pass of stereo decorrelation on the provided buffer. + * Note that this version of the function requires that the 8 previous stereo + * samples are visible and correct. In other words, it ignores the "samples_*" + * fields in the decorr_pass structure and gets the history data directly + * from the buffer. It does, however, return the appropriate history samples + * to the decorr_pass structure before returning. + * + * This is written to work on a MCF5249 processor, or any processor based on + * the ColdFire V2 core with an EMAC unit. The EMAC is perfectly suited for + * the "apply_weight" function of WavPack decorrelation because it provides + * the requires 40-bit product. The fractional rounding mode of the EMAC is not + * configurable and uses "round to even" while WavPack uses "round to larger", + * so the rounding has to be done manually. + */ + + .text + .align 2 + .global decorr_stereo_pass_cont_mcf5249 + +decorr_stereo_pass_cont_mcf5249: + + lea (-44, %sp), %sp + movem.l %d2-%d7/%a2-%a6, (%sp) + move.l 44+4(%sp), %a2 | a2 = dpp-> + move.l 44+8(%sp), %a1 | a1 = bptr + move.w 2(%a2), %a3 | a3 = dpp->delta + move.w 4(%a2), %d3 | d3 = dpp->weight_A (sign extended) + ext.l %d3 + move.w 6(%a2), %d4 | d4 = dpp->weight_B (sign extended) + ext.l %d4 + move.l 44+12(%sp), %d0 | d0 = sample_count + jbeq return_only | if zero, nothing to do + + lsl.l #3, %d0 | d5 = bptr + (sample_count * 8) + move.l %d0, %d5 + add.l %a1, %d5 + + moveq.l #17, %d0 | left shift weights & delta 17 places + asl.l %d0, %d3 + asl.l %d0, %d4 + move.l %a3, %d1 + asl.l %d0, %d1 + move.l %d1, %a3 + + moveq.l #0x20, %d6 + move.l %d6, %macsr | set fractional mode for MAC + move.l #0x800000, %accext01 | acc1 = 0x00 0000 80 (for rounding) + + move.l #1024<<17, %d6 | d6 & d7 are weight clipping limits + move.l #-1024<<17, %d7 | (only used by negative terms) + + move.w (%a2), %d0 | d0 = term + ext.l %d0 + cmp.l #17, %d0 + jbeq term_17 | term = 17 + cmp.l #18, %d0 + jbeq term_18 | term = 18 + addq.l #1, %d0 + jbeq term_minus_1 | term = -1 + addq.l #1, %d0 + jbeq term_minus_2 | term = -2 + addq.l #1, %d0 + jbeq term_minus_3 | term = -3 + jbra term_default | default term = 1 - 8 + +|------------------------------------------------------------------------------ +| Loop to handle term = 17 condition +| +| a0 = d0 = (2 * bptr [-1]) - bptr [-2] +| a1 = bptr d1 = initial bptr [0] +| a2 = dpp-> d2 = updated bptr [0] +| a3 = dpp->delta << 17 d3 = dpp->weight_A << 17 +| a4 = d4 = dpp->weight_B << 17 +| a5 = d5 = eptr +| macsr = 0x20 acc1 = 0x00 0000 80 +|------------------------------------------------------------------------------ + +term_17: + move.l -8(%a1), %d0 | d0 = 2 * bptr [-1] - bptr [-2] + add.l %d0, %d0 + sub.l -16(%a1), %d0 + beq .L251 | if zero, skip calculation + move.l %acc1, %acc0 + asl.l #4, %d0 | acc0 = acc1 + (d0 << 4) * weight_A + mac.l %d0, %d3, %acc0 + move.l (%a1), %d1 + beq .L255 + eor.l %d1, %d0 | else compare signs + bge .L256 | if same, add delta to weight + sub.l %a3, %d3 | else subtract delta from weight + sub.l %a3, %d3 | subtract again instead of branch +.L256: add.l %a3, %d3 | add delta to weight + +.L255: move.l %acc0, %d2 | d2 = rounded product + add.l %d1, %d2 | update bptr [0] and store + move.l %d2, (%a1)+ + +.L253: move.l -8(%a1), %d0 | d0 = 2 * bptr [-1] - bptr [-2] + add.l %d0, %d0 + sub.l -16(%a1), %d0 + beq .L257 | if zero, skip calculations + move.l %acc1, %acc0 + asl.l #4, %d0 | acc0 = acc1 + (d0 << 4) * weight_B + mac.l %d0, %d4, %acc0 + move.l (%a1), %d1 + beq .L254 + eor.l %d1, %d0 | else compare signs + bge .L259 | if same, add delta to weight + sub.l %a3, %d4 | else subtract delta from weight + sub.l %a3, %d4 | subtract again instead of branch +.L259: add.l %a3, %d4 | add delta to weight + +.L254: move.l %acc0, %d2 | d2 = rounded product + add.l %d1, %d2 | update bptr [0] and store + move.l %d2, (%a1)+ + +.L252: cmp.l %a1, %d5 | loop if bptr < eptr + jbhi term_17 + bra term_17_18_finish | exit through common path + +.L251: addq.l #4, %a1 | update point and jump back into loop + bra .L253 + +.L257: addq.l #4, %a1 | update point and jump back into loop + bra .L252 + +|------------------------------------------------------------------------------ +| Loop to handle term = 18 condition +| +| a0 = d0 = ((3 * bptr [-1]) - bptr [-2]) >> 1 +| a1 = bptr d1 = initial bptr [0] +| a2 = dpp-> d2 = updated bptr [0] +| a3 = dpp->delta << 17 d3 = dpp->weight_A << 17 +| a4 = d4 = dpp->weight_B << 17 +| a5 = d5 = eptr +| macsr = 0x20 acc1 = 0x00 0000 80 +|------------------------------------------------------------------------------ + +term_18: + move.l -8(%a1), %a0 | d0 = (3 * bptr [-1] - bptr [-2]) >> 1 + lea (%a0,%a0.l*2), %a0 + move.l %a0, %d0 + sub.l -16(%a1), %d0 + asr.l #1, %d0 + beq .L260 + move.l %acc1, %acc0 + asl.l #4, %d0 | acc0 = acc1 + (d0 << 4) * weight_A + mac.l %d0, %d3, %acc0 + move.l (%a1), %d1 + beq .L266 + eor.l %d1, %d0 | else compare signs + bge .L267 | if same, add delta to weight + sub.l %a3, %d3 | else subtract delta from weight + sub.l %a3, %d3 | subtract again instead of branch +.L267: add.l %a3, %d3 | add delta to weight + +.L266: move.l %acc0, %d2 | d2 = rounded product + add.l %d1, %d2 | add applied weight to bptr [0], store + move.l %d2, (%a1)+ + +.L268: move.l -8(%a1), %a0 | d0 = (3 * bptr [-1] - bptr [-2]) >> 1 + lea (%a0,%a0.l*2), %a0 + move.l %a0, %d0 + sub.l -16(%a1), %d0 + asr.l #1, %d0 + beq .L261 + move.l %acc1, %acc0 + asl.l #4, %d0 | acc0 = acc1 + (d0 << 4) * weight_B + mac.l %d0, %d4, %acc0 + move.l (%a1), %d1 + beq .L265 + eor.l %d1, %d0 | else compare signs + bge .L270 | if same, add delta to weight + sub.l %a3, %d4 | else subtract delta from weight + sub.l %a3, %d4 | subtract again instead of branch +.L270: add.l %a3, %d4 | add delta to weight + +.L265: move.l %acc0, %d2 | d2 = rounded product + add.l %d1, %d2 | add applied weight to bptr [0], store + move.l %d2, (%a1)+ + +.L269: cmp.l %a1, %d5 | loop if bptr < eptr + jbhi term_18 + bra term_17_18_finish | exit through common path + +.L260: addq.l #4, %a1 | bump pointer and jump back into loop + bra .L268 + +.L261: addq.l #4, %a1 | bump pointer and jump back into loop + bra .L269 + +term_17_18_finish: + move.l -4(%a1), 40(%a2) | restore dpp->samples_A [0-1], B [0-1] + move.l -8(%a1), 8(%a2) + move.l -12(%a1), 44(%a2) + move.l -16(%a1), 12(%a2) + jbra finish_up + +|------------------------------------------------------------------------------ +| Loop to handle default terms (i.e. 1 - 8) +| +| a0 = tptr d0 = tptr [0] +| a1 = bptr d1 = initial bptr [0] +| a2 = dpp-> d2 = updated bptr [0] +| a3 = dpp->delta << 17 d3 = dpp->weight_A << 17 +| a4 = d4 = dpp->weight_B << 17 +| a5 = d5 = eptr +| macsr = 0x20 acc1 = 0x00 0000 80 +|------------------------------------------------------------------------------ + +term_default: + move.w (%a2), %d0 | a0 = a1 - (dpp->term * 8) + ext.l %d0 + lsl.l #3, %d0 + move.l %a1, %a0 + sub.l %d0, %a0 + +term_default_loop: + move.l (%a0)+, %d0 | d0 = tptr [0], skip ahead if zero + beq .L271 + move.l %acc1, %acc0 + asl.l #4, %d0 | acc0 = acc1 + (d0 << 4) * weight_A + mac.l %d0, %d3, %acc0 + move.l (%a1), %d1 + beq .L277 + eor.l %d1, %d0 | else compare signs + bge .L278 | if same, add delta to weight + sub.l %a3, %d3 | else subtract delta from weight + sub.l %a3, %d3 | subtract again instead of branch +.L278: add.l %a3, %d3 | add delta to weight + +.L277: move.l %acc0, %d2 | d2 = rounded product + add.l %d1, %d2 | add applied weight to bptr [0], store + move.l %d2, (%a1)+ + +.L275: move.l (%a0)+, %d0 | d0 = tptr [0], skip ahead if zero + beq .L272 + move.l %acc1, %acc0 + asl.l #4, %d0 | acc0 = acc1 + (d0 << 4) * weight_B + mac.l %d0, %d4, %acc0 + move.l (%a1), %d1 + beq .L276 + eor.l %d1, %d0 | else compare signs + bge .L281 | if same, add delta to weight + sub.l %a3, %d4 | else subtract delta from weight + sub.l %a3, %d4 | subtract again instead of branch +.L281: add.l %a3, %d4 | add delta to weight + +.L276: move.l %acc0, %d2 | d2 = rounded product + add.l %d1, %d2 | add applied weight to bptr [0], store + move.l %d2, (%a1)+ + +.L274: cmp.l %a1, %d5 | loop back if bptr < eptr + jbhi term_default_loop + move.w (%a2), %d0 | d0 = term - 1 + moveq.l #8, %d1 | d1 = loop counter + +.L323: subq.l #1, %d0 | back up & mask index + and.l #7, %d0 + move.l -(%a1), 40(%a2,%d0.l*4) | store dpp->samples_B [d0] + move.l -(%a1), 8(%a2,%d0.l*4) | store dpp->samples_A [d0] + subq.l #1, %d1 | loop on count + jbne .L323 + jbra finish_up + +.L271: addq.l #4, %a1 | bump pointer and jump back into loop + bra .L275 + +.L272: addq.l #4, %a1 | bump pointer and jump back into loop + bra .L274 + + +|------------------------------------------------------------------------------ +| Loop to handle term = -1 condition +| +| a0 = d0 = decorrelation sample +| a1 = bptr d1 = initial bptr [0] +| a2 = dpp-> d2 = updated bptr [0] +| a3 = dpp->delta << 17 d3 = dpp->weight_A << 17 +| a4 = d4 = dpp->weight_B << 17 +| a5 = d5 = eptr +| a6 = d6 = 1024 << 17 +| a7 = d7 = -1024 << 17 +| macsr = 0x20 acc1 = 0x00 0000 80 +|------------------------------------------------------------------------------ + +term_minus_1: + move.l -4(%a1), %d0 | d0 = bptr [-1] + beq .L402 + move.l %acc1, %acc0 + asl.l #4, %d0 | acc0 = acc1 + ((d0 << 4) * weight_A) + mac.l %d0, %d3, %acc0 + move.l (%a1), %d1 + beq .L405 + eor.l %d1, %d0 | else compare signs + bge .L404 | if same, add delta to weight + sub.l %a3, %d3 | else subtract delta from weight + cmp.l %d7, %d3 | check for negative clip limit + bge .L405 + move.l %d7, %d3 + bra .L405 + +.L404: add.l %a3, %d3 | add delta to weight + cmp.l %d6, %d3 | check for positive clip limit + ble .L405 + move.l %d6, %d3 + +.L405: move.l %acc0, %d0 | d2 = rounded product + add.l %d1, %d0 | add applied weight to bptr [0], store + move.l %d0, (%a1)+ + beq .L401 + +.L410: move.l %acc1, %acc0 + asl.l #4, %d0 | acc0 = acc1 + ((d0 << 4) * weight_B) + mac.l %d0, %d4, %acc0 + move.l (%a1), %d1 + beq .L403 + eor.l %d1, %d0 | else compare signs + bge .L407 | if same, add delta to weight + sub.l %a3, %d4 | else subtract delta from weight + cmp.l %d7, %d4 | check for negative clip limit + bge .L403 + move.l %d7, %d4 + bra .L403 + +.L407: add.l %a3, %d4 | add delta to weight + cmp.l %d6, %d4 | check for positive clip limit + ble .L403 + move.l %d6, %d4 + +.L403: move.l %acc0, %d2 | d2 = rounded product + add.l %d1, %d2 | add applied weight to bptr [1], store + move.l %d2, (%a1)+ + +.L411: cmp.l %a1, %d5 | loop back if bptr < eptr + jbhi term_minus_1 + move.l -4(%a1), 8(%a2) | dpp->samples_A [0] = bptr [-1] + jbra finish_up + +.L402: move.l (%a1)+, %d0 + bne .L410 + +.L401: addq.l #4, %a1 + bra .L411 + + +|------------------------------------------------------------------------------ +| Loop to handle term = -2 condition +| +| a0 = d0 = decorrelation sample +| a1 = bptr d1 = initial bptr [0] +| a2 = dpp-> d2 = updated bptr [0] +| a3 = dpp->delta << 17 d3 = dpp->weight_A << 17 +| a4 = d4 = dpp->weight_B << 17 +| a5 = d5 = eptr +| a6 = d6 = 1024 << 17 +| a7 = d7 = -1024 << 17 +| macsr = 0x20 acc1 = 0x00 0000 80 +|------------------------------------------------------------------------------ + +term_minus_2: + move.l -8(%a1), %d0 | d0 = bptr [-2] + beq .L511 + move.l %acc1, %acc0 + asl.l #4, %d0 | acc0 = acc1 + ((d0 << 4) * weight_B) + mac.l %d0, %d4, %acc0 + move.l 4(%a1), %d1 + beq .L505 + eor.l %d1, %d0 | else compare signs + bge .L504 | if same, add delta to weight + sub.l %a3, %d4 | else subtract delta from weight + cmp.l %d7, %d4 | ckeck for negative clip limit + bge .L505 + move.l %d7, %d4 + bra .L505 + +.L504: add.l %a3, %d4 | add delta to weight + cmp.l %d6, %d4 | check for positive clip limit + ble .L505 + move.l %d6, %d4 + +.L505: move.l %acc0, %d0 | d2 = rounded product + add.l %d1, %d0 | add applied weight to bptr [0], store + move.l %d0, 4(%a1) + beq .L512 + +.L510: move.l %acc1, %acc0 + asl.l #4, %d0 | acc0 = acc1 + ((d0 << 4) * weight_A) + mac.l %d0, %d3, %acc0 + move.l (%a1), %d1 + beq .L503 + eor.l %d1, %d0 | else compare signs + bge .L507 | if same, add delta to weight + sub.l %a3, %d3 | else subtract delta from weight + cmp.l %d7, %d3 | check for negative clip limit + bge .L503 + move.l %d7, %d3 + bra .L503 + +.L507: add.l %a3, %d3 | add delta to weight + cmp.l %d6, %d3 | check for negative clip limit + ble .L503 + move.l %d6, %d3 + +.L503: move.l %acc0, %d2 | d2 = rounded product + add.l %d1, %d2 | add applied weight to bptr [1], store + move.l %d2, (%a1) + +.L512: addq.l #8, %a1 + cmp.l %a1, %d5 | loop if bptr < eptr + jbhi term_minus_2 + move.l -8(%a1), 40(%a2) | dpp->samples_B [0] = bptr [-4] + jbra finish_up + +.L511: move.l 4(%a1), %d0 + beq .L512 + bra .L510 + + +|------------------------------------------------------------------------------ +| Loop to handle term = -3 condition +| +| a0 = d0 = decorrelation sample +| a1 = bptr d1 = initial bptr [0] +| a2 = dpp-> d2 = updated bptr [0] +| a3 = dpp->delta << 17 d3 = dpp->weight_A << 17 +| a4 = d4 = dpp->weight_B << 17 +| a5 = d5 = eptr +| a6 = d6 = 1024 << 17 +| a7 = d7 = -1024 << 17 +| macsr = 0x20 acc1 = 0x00 0000 80 +|------------------------------------------------------------------------------ + +term_minus_3: + move.l -4(%a1), %d0 | d0 = bptr [-1] + beq .L301 + move.l %acc1, %acc0 + asl.l #4, %d0 | acc0 = acc1 + ((d0 << 4) * weight_A) + mac.l %d0, %d3, %acc0 + move.l (%a1), %d1 + beq .L320 + eor.l %d1, %d0 | else compare signs + bge .L319 | if same, add delta to weight + sub.l %a3, %d3 | else subtract delta from weight + cmp.l %d7, %d3 | check for negative clip limit + bge .L320 + move.l %d7, %d3 + bra .L320 + +.L319: add.l %a3, %d3 | add delta to weight + cmp.l %d6, %d3 | check for positive clip limit + ble .L320 + move.l %d6, %d3 + +.L320: move.l %acc0, %d2 | d2 = rounded product + add.l %d1, %d2 | add applied weight to bptr [0], store + move.l %d2, (%a1)+ + +.L330: move.l -12(%a1), %d0 | d0 = bptr [-2] + beq .L302 + move.l %acc1, %acc0 + asl.l #4, %d0 | acc0 = acc1 + ((d0 << 4) * weight_B) + mac.l %d0, %d4, %acc0 + move.l (%a1), %d1 + beq .L318 + eor.l %d1, %d0 | else compare signs + bge .L322 | if same, add delta to weight + sub.l %a3, %d4 | else subtract delta from weight + cmp.l %d7, %d4 | check for negative clip limit + bge .L318 + move.l %d7, %d4 + bra .L318 + +.L322: add.l %a3, %d4 | add delta to weight + cmp.l %d6, %d4 | check for positive clip limit + ble .L318 + move.l %d6, %d4 + +.L318: move.l %acc0, %d2 | d2 = rounded product + add.l %d1, %d2 | add applied weight to bptr [1], store + move.l %d2, (%a1)+ + +.L331: cmp.l %a1, %d5 | bptr, eptr + jbhi term_minus_3 + move.l -4(%a1), 8(%a2) | dpp->samples_A [0] = bptr [-1] + move.l -8(%a1), 40(%a2) | dpp->samples_B [0] = bptr [-2] + jbra finish_up + +.L301: addq.l #4, %a1 + bra .L330 + +.L302: addq.l #4, %a1 + bra .L331 + +| finish and return + +finish_up: + moveq.l #17, %d0 + asr.l %d0, %d3 + asr.l %d0, %d4 + move.w %d3, 4(%a2) | weight_A, dpp->weight_A + move.w %d4, 6(%a2) | weight_B, dpp->weight_B + + clr.l %d0 | clear up EMAC + move.l %d0, %acc0 + move.l %d0, %acc1 + +return_only: + movem.l (%sp), %d2-%d7/%a2-%a6 + lea (44,%sp), %sp + rts diff --git a/lib/rbcodec/codecs/libwavpack/float.c b/lib/rbcodec/codecs/libwavpack/float.c new file mode 100644 index 0000000000..6e5c4e4f61 --- /dev/null +++ b/lib/rbcodec/codecs/libwavpack/float.c @@ -0,0 +1,47 @@ +//////////////////////////////////////////////////////////////////////////// +// **** WAVPACK **** // +// Hybrid Lossless Wavefile Compressor // +// Copyright (c) 1998 - 2004 Conifer Software. // +// All Rights Reserved. // +// Distributed under the BSD Software License (see license.txt) // +//////////////////////////////////////////////////////////////////////////// + +// float.c + +#include "wavpack.h" + +int read_float_info (WavpackStream *wps, WavpackMetadata *wpmd) +{ + int bytecnt = wpmd->byte_length; + char *byteptr = wpmd->data; + + if (bytecnt != 4) + return FALSE; + + wps->float_flags = *byteptr++; + wps->float_shift = *byteptr++; + wps->float_max_exp = *byteptr++; + wps->float_norm_exp = *byteptr; + return TRUE; +} + +/* This function converts WavPack floating point data into standard Rockbox + * 28-bit integers. It is assumed that clipping will be taken care of later. + */ + +void float_values (WavpackStream *wps, int32_t *values, int32_t num_values) +{ + int shift = wps->float_max_exp - wps->float_norm_exp + wps->float_shift + 5; + + if (shift > 32) + shift = 32; + else if (shift < -32) + shift = -32; + + if (shift > 0) + while (num_values--) + *values++ <<= shift; + else if (shift < 0) + while (num_values--) + *values++ >>= -shift; +} diff --git a/lib/rbcodec/codecs/libwavpack/libwavpack.make b/lib/rbcodec/codecs/libwavpack/libwavpack.make new file mode 100644 index 0000000000..27a2d214a1 --- /dev/null +++ b/lib/rbcodec/codecs/libwavpack/libwavpack.make @@ -0,0 +1,18 @@ +# __________ __ ___. +# Open \______ \ ____ ____ | | _\_ |__ _______ ___ +# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / +# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < +# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ +# \/ \/ \/ \/ \/ +# $Id$ +# + +# libwavpack +WAVPACKLIB := $(CODECDIR)/libwavpack.a +WAVPACKLIB_SRC := $(call preprocess, $(RBCODECLIB_DIR)/codecs/libwavpack/SOURCES) +WAVPACKLIB_OBJ := $(call c2obj, $(WAVPACKLIB_SRC)) +OTHER_SRC += $(WAVPACKLIB_SRC) + +$(WAVPACKLIB): $(WAVPACKLIB_OBJ) + $(SILENT)$(shell rm -f $@) + $(call PRINTS,AR $(@F))$(AR) rcs $@ $^ >/dev/null diff --git a/lib/rbcodec/codecs/libwavpack/make.bat b/lib/rbcodec/codecs/libwavpack/make.bat new file mode 100644 index 0000000000..0ca72d7e55 --- /dev/null +++ b/lib/rbcodec/codecs/libwavpack/make.bat @@ -0,0 +1 @@ +cl /O1 /DWIN32 wvfilter.c wputils.c unpack.c float.c metadata.c words.c bits.c diff --git a/lib/rbcodec/codecs/libwavpack/metadata.c b/lib/rbcodec/codecs/libwavpack/metadata.c new file mode 100644 index 0000000000..4dce10100f --- /dev/null +++ b/lib/rbcodec/codecs/libwavpack/metadata.c @@ -0,0 +1,171 @@ +//////////////////////////////////////////////////////////////////////////// +// **** WAVPACK **** // +// Hybrid Lossless Wavefile Compressor // +// Copyright (c) 1998 - 2003 Conifer Software. // +// All Rights Reserved. // +// Distributed under the BSD Software License (see license.txt) // +//////////////////////////////////////////////////////////////////////////// + +// metadata.c + +// This module handles the metadata structure introduced in WavPack 4.0 + +#include "wavpack.h" + +#include + +int read_metadata_buff (WavpackContext *wpc, WavpackMetadata *wpmd) +{ + uint32_t bytes_to_read; + uchar tchar; + + if (wpc->stream.block_bytes_left < 2 || !wpc->infile (&wpmd->id, 1) || !wpc->infile (&tchar, 1)) + return FALSE; + + wpmd->byte_length = tchar << 1; + wpc->stream.block_bytes_left -= 2; + + if (wpmd->id & ID_LARGE) { + wpmd->id &= ~ID_LARGE; + + if (wpc->stream.block_bytes_left < 2 || !wpc->infile (&tchar, 1)) + return FALSE; + + wpmd->byte_length += (int32_t) tchar << 9; + + if (!wpc->infile (&tchar, 1)) + return FALSE; + + wpmd->byte_length += (int32_t) tchar << 17; + wpc->stream.block_bytes_left -= 2; + } + + if ((wpc->stream.block_bytes_left -= wpmd->byte_length) < 0) + return FALSE; + + if (wpmd->id & ID_ODD_SIZE) { + wpmd->id &= ~ID_ODD_SIZE; + wpmd->byte_length--; + } + + if (!wpmd->byte_length || wpmd->id == ID_WV_BITSTREAM) { + wpmd->data = NULL; + return TRUE; + } + + bytes_to_read = wpmd->byte_length + (wpmd->byte_length & 1); + + if (bytes_to_read > sizeof (wpc->read_buffer)) { + wpmd->data = NULL; + + while (bytes_to_read > sizeof (wpc->read_buffer)) + if (wpc->infile (wpc->read_buffer, sizeof (wpc->read_buffer)) == sizeof (wpc->read_buffer)) + bytes_to_read -= sizeof (wpc->read_buffer); + else + return FALSE; + } + else + wpmd->data = wpc->read_buffer; + + if (bytes_to_read && wpc->infile (wpc->read_buffer, bytes_to_read) != (int32_t) bytes_to_read) { + wpmd->data = NULL; + return FALSE; + } + + return TRUE; +} + +int process_metadata (WavpackContext *wpc, WavpackMetadata *wpmd) +{ + WavpackStream *wps = &wpc->stream; + + switch (wpmd->id) { + case ID_DUMMY: + return TRUE; + + case ID_DECORR_TERMS: + return read_decorr_terms (wps, wpmd); + + case ID_DECORR_WEIGHTS: + return read_decorr_weights (wps, wpmd); + + case ID_DECORR_SAMPLES: + return read_decorr_samples (wps, wpmd); + + case ID_ENTROPY_VARS: + return read_entropy_vars (wps, wpmd); + + case ID_HYBRID_PROFILE: + return read_hybrid_profile (wps, wpmd); + + case ID_FLOAT_INFO: + return read_float_info (wps, wpmd); + + case ID_INT32_INFO: + return read_int32_info (wps, wpmd); + + case ID_CHANNEL_INFO: + return read_channel_info (wpc, wpmd); + + case ID_SAMPLE_RATE: + return read_sample_rate (wpc, wpmd); + + case ID_CONFIG_BLOCK: + return read_config_info (wpc, wpmd); + + case ID_WV_BITSTREAM: + return init_wv_bitstream (wpc, wpmd); + + case ID_SHAPING_WEIGHTS: + case ID_WVC_BITSTREAM: + case ID_WVX_BITSTREAM: + return TRUE; + + default: + return (wpmd->id & ID_OPTIONAL_DATA) ? TRUE : FALSE; + } +} + +int copy_metadata (WavpackMetadata *wpmd, uchar *buffer_start, uchar *buffer_end) +{ + uint32_t mdsize = wpmd->byte_length + (wpmd->byte_length & 1); + WavpackHeader *wphdr = (WavpackHeader *) buffer_start; + + if (wpmd->byte_length & 1) + ((char *) wpmd->data) [wpmd->byte_length] = 0; + + mdsize += (wpmd->byte_length > 510) ? 4 : 2; + buffer_start += wphdr->ckSize + 8; + + if (buffer_start + mdsize >= buffer_end) + return FALSE; + + buffer_start [0] = wpmd->id | (wpmd->byte_length & 1 ? ID_ODD_SIZE : 0); + buffer_start [1] = (wpmd->byte_length + 1) >> 1; + + if (wpmd->byte_length > 510) { + buffer_start [0] |= ID_LARGE; + buffer_start [2] = (wpmd->byte_length + 1) >> 9; + buffer_start [3] = (wpmd->byte_length + 1) >> 17; + } + + if (wpmd->data && wpmd->byte_length) { + if (wpmd->byte_length > 510) { + buffer_start [0] |= ID_LARGE; + buffer_start [2] = (wpmd->byte_length + 1) >> 9; + buffer_start [3] = (wpmd->byte_length + 1) >> 17; + memcpy (buffer_start + 4, wpmd->data, mdsize - 4); + } + else + memcpy (buffer_start + 2, wpmd->data, mdsize - 2); + } + + wphdr->ckSize += mdsize; + return TRUE; +} + +void free_metadata (WavpackMetadata *wpmd) +{ + wpmd->data = NULL; +} + diff --git a/lib/rbcodec/codecs/libwavpack/pack.c b/lib/rbcodec/codecs/libwavpack/pack.c new file mode 100644 index 0000000000..a46d05fe14 --- /dev/null +++ b/lib/rbcodec/codecs/libwavpack/pack.c @@ -0,0 +1,470 @@ +//////////////////////////////////////////////////////////////////////////// +// **** WAVPACK **** // +// Hybrid Lossless Wavefile Compressor // +// Copyright (c) 1998 - 2005 Conifer Software. // +// All Rights Reserved. // +// Distributed under the BSD Software License (see license.txt) // +//////////////////////////////////////////////////////////////////////////// + +// pack.c + +// This module actually handles the compression of the audio data, except for +// the entropy coding which is handled by the words? modules. For efficiency, +// the conversion is isolated to tight loops that handle an entire buffer. + +#include "wavpack.h" + +#include + +// This flag provides faster encoding speed at the expense of more code. The +// improvement applies to 16-bit stereo lossless only. + +//////////////////////////////// local tables /////////////////////////////// + +// These two tables specify the characteristics of the decorrelation filters. +// Each term represents one layer of the sequential filter, where positive +// values indicate the relative sample involved from the same channel (1=prev), +// 17 & 18 are special functions using the previous 2 samples, and negative +// values indicate cross channel decorrelation (in stereo only). + +static const signed char default_terms [] = { 18,18,2,3,-2,0 }; +static const signed char high_terms [] = { 18,18,2,3,-2,18,2,4,7,5,3,6,0 }; +static const signed char fast_terms [] = { 17,17,0 }; + +///////////////////////////// executable code //////////////////////////////// + +// This function initializes everything required to pack WavPack bitstreams +// and must be called BEFORE any other function in this module. + +void pack_init (WavpackContext *wpc) +{ + WavpackStream *wps = &wpc->stream; + uint32_t flags = wps->wphdr.flags; + struct decorr_pass *dpp; + const signed char *term_string; + int ti; + + wps->sample_index = 0; + CLEAR (wps->decorr_passes); + + if (wpc->config.flags & CONFIG_HIGH_FLAG) + term_string = high_terms; + else if (wpc->config.flags & CONFIG_FAST_FLAG) + term_string = fast_terms; + else + term_string = default_terms; + + for (dpp = wps->decorr_passes, ti = 0; term_string [ti]; ti++) + if (term_string [ti] >= 0 || (flags & CROSS_DECORR)) { + dpp->term = term_string [ti]; + dpp++->delta = 2; + } + else if (!(flags & MONO_FLAG)) { + dpp->term = -3; + dpp++->delta = 2; + } + + wps->num_terms = dpp - wps->decorr_passes; + init_words (wps); +} + +// Allocate room for and copy the decorrelation terms from the decorr_passes +// array into the specified metadata structure. Both the actual term id and +// the delta are packed into single characters. + +static void write_decorr_terms (WavpackStream *wps, WavpackMetadata *wpmd) +{ + int tcount = wps->num_terms; + struct decorr_pass *dpp; + char *byteptr; + + byteptr = wpmd->data = wpmd->temp_data; + wpmd->id = ID_DECORR_TERMS; + + for (dpp = wps->decorr_passes; tcount--; ++dpp) + *byteptr++ = ((dpp->term + 5) & 0x1f) | ((dpp->delta << 5) & 0xe0); + + wpmd->byte_length = byteptr - (char *) wpmd->data; +} + +// Allocate room for and copy the decorrelation term weights from the +// decorr_passes array into the specified metadata structure. The weights +// range +/-1024, but are rounded and truncated to fit in signed chars for +// metadata storage. Weights are separate for the two channels + +static void write_decorr_weights (WavpackStream *wps, WavpackMetadata *wpmd) +{ + int tcount = wps->num_terms; + struct decorr_pass *dpp; + signed char *byteptr; + + byteptr = wpmd->data = wpmd->temp_data; + wpmd->id = ID_DECORR_WEIGHTS; + + for (dpp = wps->decorr_passes; tcount--; ++dpp) { + dpp->weight_A = restore_weight (*byteptr++ = store_weight (dpp->weight_A)); + + if (!(wps->wphdr.flags & MONO_FLAG)) + dpp->weight_B = restore_weight (*byteptr++ = store_weight (dpp->weight_B)); + } + + wpmd->byte_length = byteptr - (signed char *) wpmd->data; +} + +// Allocate room for and copy the decorrelation samples from the decorr_passes +// array into the specified metadata structure. The samples are signed 32-bit +// values, but are converted to signed log2 values for storage in metadata. +// Values are stored for both channels and are specified from the first term +// with unspecified samples set to zero. The number of samples stored varies +// with the actual term value, so those must obviously be specified before +// these in the metadata list. Any number of terms can have their samples +// specified from no terms to all the terms, however I have found that +// sending more than the first term's samples is a waste. The "wcount" +// variable can be set to the number of terms to have their samples stored. + +static void write_decorr_samples (WavpackStream *wps, WavpackMetadata *wpmd) +{ + int tcount = wps->num_terms, wcount = 1, temp; + struct decorr_pass *dpp; + uchar *byteptr; + + byteptr = wpmd->data = wpmd->temp_data; + wpmd->id = ID_DECORR_SAMPLES; + + for (dpp = wps->decorr_passes; tcount--; ++dpp) + if (wcount) { + if (dpp->term > MAX_TERM) { + dpp->samples_A [0] = exp2s (temp = log2s (dpp->samples_A [0])); + *byteptr++ = temp; + *byteptr++ = temp >> 8; + dpp->samples_A [1] = exp2s (temp = log2s (dpp->samples_A [1])); + *byteptr++ = temp; + *byteptr++ = temp >> 8; + + if (!(wps->wphdr.flags & MONO_FLAG)) { + dpp->samples_B [0] = exp2s (temp = log2s (dpp->samples_B [0])); + *byteptr++ = temp; + *byteptr++ = temp >> 8; + dpp->samples_B [1] = exp2s (temp = log2s (dpp->samples_B [1])); + *byteptr++ = temp; + *byteptr++ = temp >> 8; + } + } + else if (dpp->term < 0) { + dpp->samples_A [0] = exp2s (temp = log2s (dpp->samples_A [0])); + *byteptr++ = temp; + *byteptr++ = temp >> 8; + dpp->samples_B [0] = exp2s (temp = log2s (dpp->samples_B [0])); + *byteptr++ = temp; + *byteptr++ = temp >> 8; + } + else { + int m = 0, cnt = dpp->term; + + while (cnt--) { + dpp->samples_A [m] = exp2s (temp = log2s (dpp->samples_A [m])); + *byteptr++ = temp; + *byteptr++ = temp >> 8; + + if (!(wps->wphdr.flags & MONO_FLAG)) { + dpp->samples_B [m] = exp2s (temp = log2s (dpp->samples_B [m])); + *byteptr++ = temp; + *byteptr++ = temp >> 8; + } + + m++; + } + } + + wcount--; + } + else { + CLEAR (dpp->samples_A); + CLEAR (dpp->samples_B); + } + + wpmd->byte_length = byteptr - (uchar *) wpmd->data; +} + +// Allocate room for and copy the configuration information into the specified +// metadata structure. Currently, we just store the upper 3 bytes of +// config.flags and only in the first block of audio data. Note that this is +// for informational purposes not required for playback or decoding (like +// whether high or fast mode was specified). + +static void write_config_info (WavpackContext *wpc, WavpackMetadata *wpmd) +{ + char *byteptr; + + byteptr = wpmd->data = wpmd->temp_data; + wpmd->id = ID_CONFIG_BLOCK; + *byteptr++ = (char) (wpc->config.flags >> 8); + *byteptr++ = (char) (wpc->config.flags >> 16); + *byteptr++ = (char) (wpc->config.flags >> 24); + wpmd->byte_length = byteptr - (char *) wpmd->data; +} + +// Pack an entire block of samples (either mono or stereo) into a completed +// WavPack block. It is assumed that there is sufficient space for the +// completed block at "wps->blockbuff" and that "wps->blockend" points to the +// end of the available space. A return value of FALSE indicates an error. +// Any unsent metadata is transmitted first, then required metadata for this +// block is sent, and finally the compressed integer data is sent. If a "wpx" +// stream is required for floating point data or large integer data, then this +// must be handled outside this function. To find out how much data was written +// the caller must look at the ckSize field of the written WavpackHeader, NOT +// the one in the WavpackStream. + +int pack_start_block (WavpackContext *wpc) +{ + WavpackStream *wps = &wpc->stream; + WavpackMetadata wpmd; + + memcpy (wps->blockbuff, &wps->wphdr, sizeof (WavpackHeader)); + + ((WavpackHeader *) wps->blockbuff)->ckSize = sizeof (WavpackHeader) - 8; + ((WavpackHeader *) wps->blockbuff)->block_index = wps->sample_index; + ((WavpackHeader *) wps->blockbuff)->block_samples = 0; + ((WavpackHeader *) wps->blockbuff)->crc = 0xffffffff; + + if (wpc->wrapper_bytes) { + wpmd.id = ID_RIFF_HEADER; + wpmd.byte_length = wpc->wrapper_bytes; + wpmd.data = wpc->wrapper_data; + copy_metadata (&wpmd, wps->blockbuff, wps->blockend); + free_metadata (&wpmd); + wpc->wrapper_data = NULL; + wpc->wrapper_bytes = 0; + } + + write_decorr_terms (wps, &wpmd); + copy_metadata (&wpmd, wps->blockbuff, wps->blockend); + free_metadata (&wpmd); + + write_decorr_weights (wps, &wpmd); + copy_metadata (&wpmd, wps->blockbuff, wps->blockend); + free_metadata (&wpmd); + + write_decorr_samples (wps, &wpmd); + copy_metadata (&wpmd, wps->blockbuff, wps->blockend); + free_metadata (&wpmd); + + write_entropy_vars (wps, &wpmd); + copy_metadata (&wpmd, wps->blockbuff, wps->blockend); + free_metadata (&wpmd); + + if ((wps->wphdr.flags & INITIAL_BLOCK) && !wps->sample_index) { + write_config_info (wpc, &wpmd); + copy_metadata (&wpmd, wps->blockbuff, wps->blockend); + free_metadata (&wpmd); + } + + bs_open_write (&wps->wvbits, wps->blockbuff + ((WavpackHeader *) wps->blockbuff)->ckSize + 12, wps->blockend); + + return TRUE; +} + +static void decorr_stereo_pass (struct decorr_pass *dpp, int32_t *bptr, int32_t *eptr, int m); +static void decorr_stereo_pass_18 (struct decorr_pass *dpp, int32_t *bptr, int32_t *eptr); +static void decorr_stereo_pass_17 (struct decorr_pass *dpp, int32_t *bptr, int32_t *eptr); +static void decorr_stereo_pass_m2 (struct decorr_pass *dpp, int32_t *bptr, int32_t *eptr); + +int pack_samples (WavpackContext *wpc, int32_t *buffer, uint32_t sample_count) +{ + WavpackStream *wps = &wpc->stream; + uint32_t flags = wps->wphdr.flags; + struct decorr_pass *dpp; + int32_t *bptr, *eptr; + int tcount, m; + uint32_t crc; + + if (!sample_count) + return TRUE; + + eptr = buffer + sample_count * ((flags & MONO_FLAG) ? 1 : 2); + m = ((WavpackHeader *) wps->blockbuff)->block_samples & (MAX_TERM - 1); + crc = ((WavpackHeader *) wps->blockbuff)->crc; + + /////////////////////// handle lossless mono mode ///////////////////////// + + if (!(flags & HYBRID_FLAG) && (flags & MONO_FLAG)) + for (bptr = buffer; bptr < eptr;) { + int32_t code; + + crc = crc * 3 + (code = *bptr); + + for (tcount = wps->num_terms, dpp = wps->decorr_passes; tcount--; dpp++) { + int32_t sam; + + if (dpp->term > MAX_TERM) { + if (dpp->term & 1) + sam = 2 * dpp->samples_A [0] - dpp->samples_A [1]; + else + sam = (3 * dpp->samples_A [0] - dpp->samples_A [1]) >> 1; + + dpp->samples_A [1] = dpp->samples_A [0]; + dpp->samples_A [0] = code; + } + else { + sam = dpp->samples_A [m]; + dpp->samples_A [(m + dpp->term) & (MAX_TERM - 1)] = code; + } + + code -= apply_weight_i (dpp->weight_A, sam); + update_weight (dpp->weight_A, 2, sam, code); + } + + m = (m + 1) & (MAX_TERM - 1); + *bptr++ = code; + } + + //////////////////// handle the lossless stereo mode ////////////////////// + + else if (!(flags & HYBRID_FLAG) && !(flags & MONO_FLAG)) { + if (flags & JOINT_STEREO) + for (bptr = buffer; bptr < eptr; bptr += 2) { + crc = crc * 9 + (bptr [0] * 3) + bptr [1]; + bptr [1] += ((bptr [0] -= bptr [1]) >> 1); + } + else + for (bptr = buffer; bptr < eptr; bptr += 2) + crc = crc * 9 + (bptr [0] * 3) + bptr [1]; + + for (tcount = wps->num_terms, dpp = wps->decorr_passes; tcount-- ; dpp++) { + if (dpp->term == 17) + decorr_stereo_pass_17 (dpp, buffer, eptr); + else if (dpp->term == 18) + decorr_stereo_pass_18 (dpp, buffer, eptr); + else if (dpp->term >= 1 && dpp->term <= 7) + decorr_stereo_pass (dpp, buffer, eptr, m); + else if (dpp->term == -2) + decorr_stereo_pass_m2 (dpp, buffer, eptr); + } + } + + send_words (buffer, sample_count, flags, &wps->w, &wps->wvbits); + ((WavpackHeader *) wps->blockbuff)->crc = crc; + ((WavpackHeader *) wps->blockbuff)->block_samples += sample_count; + wps->sample_index += sample_count; + + return TRUE; +} + +static void decorr_stereo_pass (struct decorr_pass *dpp, int32_t *bptr, int32_t *eptr, int m) +{ + int k = (m + dpp->term) & (MAX_TERM - 1); + int32_t sam; + + while (bptr < eptr) { + dpp->samples_A [k] = bptr [0]; + bptr [0] -= apply_weight_i (dpp->weight_A, (sam = dpp->samples_A [m])); + update_weight (dpp->weight_A, 2, sam, bptr [0]); + bptr++; + dpp->samples_B [k] = bptr [0]; + bptr [0] -= apply_weight_i (dpp->weight_B, (sam = dpp->samples_B [m])); + update_weight (dpp->weight_B, 2, sam, bptr [0]); + bptr++; + m = (m + 1) & (MAX_TERM - 1); + k = (k + 1) & (MAX_TERM - 1); + } +} + +static void decorr_stereo_pass_18 (struct decorr_pass *dpp, int32_t *bptr, int32_t *eptr) +{ + int32_t sam; + + while (bptr < eptr) { + sam = (3 * dpp->samples_A [0] - dpp->samples_A [1]) >> 1; + dpp->samples_A [1] = dpp->samples_A [0]; + dpp->samples_A [0] = bptr [0]; + bptr [0] -= apply_weight_i (dpp->weight_A, sam); + update_weight (dpp->weight_A, 2, sam, bptr [0]); + bptr++; + sam = (3 * dpp->samples_B [0] - dpp->samples_B [1]) >> 1; + dpp->samples_B [1] = dpp->samples_B [0]; + dpp->samples_B [0] = bptr [0]; + bptr [0] -= apply_weight_i (dpp->weight_B, sam); + update_weight (dpp->weight_B, 2, sam, bptr [0]); + bptr++; + } +} + +static void decorr_stereo_pass_m2 (struct decorr_pass *dpp, int32_t *bptr, int32_t *eptr) +{ + int32_t sam_A, sam_B; + + for (; bptr < eptr; bptr += 2) { + sam_A = bptr [1]; + sam_B = dpp->samples_B [0]; + dpp->samples_B [0] = bptr [0]; + bptr [0] -= apply_weight_i (dpp->weight_A, sam_A); + update_weight_clip (dpp->weight_A, 2, sam_A, bptr [0]); + bptr [1] -= apply_weight_i (dpp->weight_B, sam_B); + update_weight_clip (dpp->weight_B, 2, sam_B, bptr [1]); + } +} + +static void decorr_stereo_pass_17 (struct decorr_pass *dpp, int32_t *bptr, int32_t *eptr) +{ + int32_t sam; + + while (bptr < eptr) { + sam = 2 * dpp->samples_A [0] - dpp->samples_A [1]; + dpp->samples_A [1] = dpp->samples_A [0]; + dpp->samples_A [0] = bptr [0]; + bptr [0] -= apply_weight_i (dpp->weight_A, sam); + update_weight (dpp->weight_A, 2, sam, bptr [0]); + bptr++; + sam = 2 * dpp->samples_B [0] - dpp->samples_B [1]; + dpp->samples_B [1] = dpp->samples_B [0]; + dpp->samples_B [0] = bptr [0]; + bptr [0] -= apply_weight_i (dpp->weight_B, sam); + update_weight (dpp->weight_B, 2, sam, bptr [0]); + bptr++; + } +} + +int pack_finish_block (WavpackContext *wpc) +{ + WavpackStream *wps = &wpc->stream; + struct decorr_pass *dpp; + uint32_t data_count; + int tcount, m; + + m = ((WavpackHeader *) wps->blockbuff)->block_samples & (MAX_TERM - 1); + + if (m) + for (tcount = wps->num_terms, dpp = wps->decorr_passes; tcount--; dpp++) + if (dpp->term > 0 && dpp->term <= MAX_TERM) { + int32_t temp_A [MAX_TERM], temp_B [MAX_TERM]; + int k; + + memcpy (temp_A, dpp->samples_A, sizeof (dpp->samples_A)); + memcpy (temp_B, dpp->samples_B, sizeof (dpp->samples_B)); + + for (k = 0; k < MAX_TERM; k++) { + dpp->samples_A [k] = temp_A [m]; + dpp->samples_B [k] = temp_B [m]; + m = (m + 1) & (MAX_TERM - 1); + } + } + + flush_word (&wps->w, &wps->wvbits); + data_count = bs_close_write (&wps->wvbits); + + if (data_count) { + if (data_count != (uint32_t) -1) { + uchar *cptr = wps->blockbuff + ((WavpackHeader *) wps->blockbuff)->ckSize + 8; + + *cptr++ = ID_WV_BITSTREAM | ID_LARGE; + *cptr++ = data_count >> 1; + *cptr++ = data_count >> 9; + *cptr++ = data_count >> 17; + ((WavpackHeader *) wps->blockbuff)->ckSize += data_count + 4; + } + else + return FALSE; + } + + return TRUE; +} diff --git a/lib/rbcodec/codecs/libwavpack/unpack.c b/lib/rbcodec/codecs/libwavpack/unpack.c new file mode 100644 index 0000000000..69252f24ad --- /dev/null +++ b/lib/rbcodec/codecs/libwavpack/unpack.c @@ -0,0 +1,780 @@ +//////////////////////////////////////////////////////////////////////////// +// **** WAVPACK **** // +// Hybrid Lossless Wavefile Compressor // +// Copyright (c) 1998 - 2004 Conifer Software. // +// All Rights Reserved. // +// Distributed under the BSD Software License (see license.txt) // +//////////////////////////////////////////////////////////////////////////// + +// unpack.c + +// This module actually handles the decompression of the audio data, except +// for the entropy decoding which is handled by the words.c module. For +// maximum efficiency, the conversion is isolated to tight loops that handle +// an entire buffer. + +#include "wavpack.h" + +#include +#include + +static void strcpy_loc (char *dst, char *src) { while ((*dst++ = *src++) != 0); } + +#define LOSSY_MUTE + +///////////////////////////// executable code //////////////////////////////// + +// This function initializes everything required to unpack a WavPack block +// and must be called before unpack_samples() is called to obtain audio data. +// It is assumed that the WavpackHeader has been read into the wps->wphdr +// (in the current WavpackStream). This is where all the metadata blocks are +// scanned up to the one containing the audio bitstream. + +int unpack_init (WavpackContext *wpc) +{ + WavpackStream *wps = &wpc->stream; + WavpackMetadata wpmd; + + if (wps->wphdr.block_samples && wps->wphdr.block_index != (uint32_t) -1) + wps->sample_index = wps->wphdr.block_index; + + wps->mute_error = FALSE; + wps->crc = 0xffffffff; + CLEAR (wps->wvbits); + CLEAR (wps->decorr_passes); + CLEAR (wps->w); + + while (read_metadata_buff (wpc, &wpmd)) { + if (!process_metadata (wpc, &wpmd)) { + strcpy_loc (wpc->error_message, "invalid metadata!"); + return FALSE; + } + + if (wpmd.id == ID_WV_BITSTREAM) + break; + } + + if (wps->wphdr.block_samples && !bs_is_open (&wps->wvbits)) { + strcpy_loc (wpc->error_message, "invalid WavPack file!"); + return FALSE; + } + + if (wps->wphdr.block_samples) { + if ((wps->wphdr.flags & INT32_DATA) && wps->int32_sent_bits) + wpc->lossy_blocks = TRUE; + + if ((wps->wphdr.flags & FLOAT_DATA) && + wps->float_flags & (FLOAT_EXCEPTIONS | FLOAT_ZEROS_SENT | FLOAT_SHIFT_SENT | FLOAT_SHIFT_SAME)) + wpc->lossy_blocks = TRUE; + } + + return TRUE; +} + +// This function initialzes the main bitstream for audio samples, which must +// be in the "wv" file. + +int init_wv_bitstream (WavpackContext *wpc, WavpackMetadata *wpmd) +{ + WavpackStream *wps = &wpc->stream; + + if (wpmd->data) + bs_open_read (&wps->wvbits, wpmd->data, (unsigned char *) wpmd->data + wpmd->byte_length, NULL, 0); + else if (wpmd->byte_length) + bs_open_read (&wps->wvbits, wpc->read_buffer, wpc->read_buffer + sizeof (wpc->read_buffer), + wpc->infile, wpmd->byte_length + (wpmd->byte_length & 1)); + + return TRUE; +} + +// Read decorrelation terms from specified metadata block into the +// decorr_passes array. The terms range from -3 to 8, plus 17 & 18; +// other values are reserved and generate errors for now. The delta +// ranges from 0 to 7 with all values valid. Note that the terms are +// stored in the opposite order in the decorr_passes array compared +// to packing. + +int read_decorr_terms (WavpackStream *wps, WavpackMetadata *wpmd) +{ + int termcnt = wpmd->byte_length; + uchar *byteptr = wpmd->data; + struct decorr_pass *dpp; + + if (termcnt > MAX_NTERMS) + return FALSE; + + wps->num_terms = termcnt; + + for (dpp = wps->decorr_passes + termcnt - 1; termcnt--; dpp--) { + dpp->term = (int)(*byteptr & 0x1f) - 5; + dpp->delta = (*byteptr++ >> 5) & 0x7; + + if (!dpp->term || dpp->term < -3 || (dpp->term > MAX_TERM && dpp->term < 17) || dpp->term > 18) + return FALSE; + } + + return TRUE; +} + +// Read decorrelation weights from specified metadata block into the +// decorr_passes array. The weights range +/-1024, but are rounded and +// truncated to fit in signed chars for metadata storage. Weights are +// separate for the two channels and are specified from the "last" term +// (first during encode). Unspecified weights are set to zero. + +int read_decorr_weights (WavpackStream *wps, WavpackMetadata *wpmd) +{ + int termcnt = wpmd->byte_length, tcount; + signed char *byteptr = wpmd->data; + struct decorr_pass *dpp; + + if (!(wps->wphdr.flags & MONO_DATA)) + termcnt /= 2; + + if (termcnt > wps->num_terms) + return FALSE; + + for (tcount = wps->num_terms, dpp = wps->decorr_passes; tcount--; dpp++) + dpp->weight_A = dpp->weight_B = 0; + + while (--dpp >= wps->decorr_passes && termcnt--) { + dpp->weight_A = restore_weight (*byteptr++); + + if (!(wps->wphdr.flags & MONO_DATA)) + dpp->weight_B = restore_weight (*byteptr++); + } + + return TRUE; +} + +// Read decorrelation samples from specified metadata block into the +// decorr_passes array. The samples are signed 32-bit values, but are +// converted to signed log2 values for storage in metadata. Values are +// stored for both channels and are specified from the "last" term +// (first during encode) with unspecified samples set to zero. The +// number of samples stored varies with the actual term value, so +// those must obviously come first in the metadata. + +int read_decorr_samples (WavpackStream *wps, WavpackMetadata *wpmd) +{ + uchar *byteptr = wpmd->data; + uchar *endptr = byteptr + wpmd->byte_length; + struct decorr_pass *dpp; + int tcount; + + for (tcount = wps->num_terms, dpp = wps->decorr_passes; tcount--; dpp++) { + CLEAR (dpp->samples_A); + CLEAR (dpp->samples_B); + } + + if (wps->wphdr.version == 0x402 && (wps->wphdr.flags & HYBRID_FLAG)) { + byteptr += 2; + + if (!(wps->wphdr.flags & MONO_DATA)) + byteptr += 2; + } + + while (dpp-- > wps->decorr_passes && byteptr < endptr) + if (dpp->term > MAX_TERM) { + dpp->samples_A [0] = exp2s ((short)(byteptr [0] + (byteptr [1] << 8))); + dpp->samples_A [1] = exp2s ((short)(byteptr [2] + (byteptr [3] << 8))); + byteptr += 4; + + if (!(wps->wphdr.flags & MONO_DATA)) { + dpp->samples_B [0] = exp2s ((short)(byteptr [0] + (byteptr [1] << 8))); + dpp->samples_B [1] = exp2s ((short)(byteptr [2] + (byteptr [3] << 8))); + byteptr += 4; + } + } + else if (dpp->term < 0) { + dpp->samples_A [0] = exp2s ((short)(byteptr [0] + (byteptr [1] << 8))); + dpp->samples_B [0] = exp2s ((short)(byteptr [2] + (byteptr [3] << 8))); + byteptr += 4; + } + else { + int m = 0, cnt = dpp->term; + + while (cnt--) { + dpp->samples_A [m] = exp2s ((short)(byteptr [0] + (byteptr [1] << 8))); + byteptr += 2; + + if (!(wps->wphdr.flags & MONO_DATA)) { + dpp->samples_B [m] = exp2s ((short)(byteptr [0] + (byteptr [1] << 8))); + byteptr += 2; + } + + m++; + } + } + + return byteptr == endptr; +} + +// Read the int32 data from the specified metadata into the specified stream. +// This data is used for integer data that has more than 24 bits of magnitude +// or, in some cases, used to eliminate redundant bits from any audio stream. + +int read_int32_info (WavpackStream *wps, WavpackMetadata *wpmd) +{ + int bytecnt = wpmd->byte_length; + char *byteptr = wpmd->data; + + if (bytecnt != 4) + return FALSE; + + wps->int32_sent_bits = *byteptr++; + wps->int32_zeros = *byteptr++; + wps->int32_ones = *byteptr++; + wps->int32_dups = *byteptr; + return TRUE; +} + +// Read multichannel information from metadata. The first byte is the total +// number of channels and the following bytes represent the channel_mask +// as described for Microsoft WAVEFORMATEX. + +int read_channel_info (WavpackContext *wpc, WavpackMetadata *wpmd) +{ + int bytecnt = wpmd->byte_length, shift = 0; + char *byteptr = wpmd->data; + uint32_t mask = 0; + + if (!bytecnt || bytecnt > 5) + return FALSE; + + wpc->config.num_channels = *byteptr++; + + while (--bytecnt) { + mask |= (uint32_t) *byteptr++ << shift; + shift += 8; + } + + wpc->config.channel_mask = mask; + return TRUE; +} + +// Read configuration information from metadata. + +int read_config_info (WavpackContext *wpc, WavpackMetadata *wpmd) +{ + int bytecnt = wpmd->byte_length; + uchar *byteptr = wpmd->data; + + if (bytecnt >= 3) { + wpc->config.flags &= 0xff; + wpc->config.flags |= (int32_t) *byteptr++ << 8; + wpc->config.flags |= (int32_t) *byteptr++ << 16; + wpc->config.flags |= (int32_t) *byteptr << 24; + } + + return TRUE; +} + +// Read non-standard sampling rate from metadata. + +int read_sample_rate (WavpackContext *wpc, WavpackMetadata *wpmd) +{ + int bytecnt = wpmd->byte_length; + uchar *byteptr = wpmd->data; + + if (bytecnt == 3) { + wpc->config.sample_rate = (int32_t) *byteptr++; + wpc->config.sample_rate |= (int32_t) *byteptr++ << 8; + wpc->config.sample_rate |= (int32_t) *byteptr++ << 16; + } + + return TRUE; +} + +// This monster actually unpacks the WavPack bitstream(s) into the specified +// buffer as 32-bit integers or floats (depending on orignal data). Lossy +// samples will be clipped to their original limits (i.e. 8-bit samples are +// clipped to -128/+127) but are still returned in int32_ts. It is up to the +// caller to potentially reformat this for the final output including any +// multichannel distribution, block alignment or endian compensation. The +// function unpack_init() must have been called and the entire WavPack block +// must still be visible (although wps->blockbuff will not be accessed again). +// For maximum clarity, the function is broken up into segments that handle +// various modes. This makes for a few extra infrequent flag checks, but +// makes the code easier to follow because the nesting does not become so +// deep. For maximum efficiency, the conversion is isolated to tight loops +// that handle an entire buffer. The function returns the total number of +// samples unpacked, which can be less than the number requested if an error +// occurs or the end of the block is reached. + +#if defined(CPU_COLDFIRE) +extern void decorr_stereo_pass_cont_mcf5249 (struct decorr_pass *dpp, int32_t *buffer, int32_t sample_count); +#elif defined(CPU_ARM) +extern void decorr_stereo_pass_cont_arm (struct decorr_pass *dpp, int32_t *buffer, int32_t sample_count); +extern void decorr_stereo_pass_cont_arml (struct decorr_pass *dpp, int32_t *buffer, int32_t sample_count); +#else +static void decorr_stereo_pass_cont (struct decorr_pass *dpp, int32_t *buffer, int32_t sample_count); +#endif + +static void decorr_mono_pass (struct decorr_pass *dpp, int32_t *buffer, int32_t sample_count); +static void decorr_stereo_pass (struct decorr_pass *dpp, int32_t *buffer, int32_t sample_count); +static void fixup_samples (WavpackStream *wps, int32_t *buffer, uint32_t sample_count); + +int32_t unpack_samples (WavpackContext *wpc, int32_t *buffer, uint32_t sample_count) +{ + WavpackStream *wps = &wpc->stream; + uint32_t flags = wps->wphdr.flags, crc = wps->crc, i; + int32_t mute_limit = (1L << ((flags & MAG_MASK) >> MAG_LSB)) + 2; + struct decorr_pass *dpp; + int32_t *bptr, *eptr; + int tcount; + + if (wps->sample_index + sample_count > wps->wphdr.block_index + wps->wphdr.block_samples) + sample_count = wps->wphdr.block_index + wps->wphdr.block_samples - wps->sample_index; + + if (wps->mute_error) { + memset (buffer, 0, sample_count * (flags & MONO_FLAG ? 4 : 8)); + wps->sample_index += sample_count; + return sample_count; + } + + if (flags & HYBRID_FLAG) + mute_limit *= 2; + + ///////////////////// handle version 4 mono data ///////////////////////// + + if (flags & MONO_DATA) { + eptr = buffer + sample_count; + i = get_words (buffer, sample_count, flags, &wps->w, &wps->wvbits); + + for (tcount = wps->num_terms, dpp = wps->decorr_passes; tcount--; dpp++) + decorr_mono_pass (dpp, buffer, sample_count); + + for (bptr = buffer; bptr < eptr; ++bptr) { + if (labs (bptr [0]) > mute_limit) { + i = bptr - buffer; + break; + } + + crc = crc * 3 + bptr [0]; + } + } + + //////////////////// handle version 4 stereo data //////////////////////// + + else { + eptr = buffer + (sample_count * 2); + i = get_words (buffer, sample_count, flags, &wps->w, &wps->wvbits); + + if (sample_count < 16) + for (tcount = wps->num_terms, dpp = wps->decorr_passes; tcount--; dpp++) + decorr_stereo_pass (dpp, buffer, sample_count); + else + for (tcount = wps->num_terms, dpp = wps->decorr_passes; tcount--; dpp++) { + decorr_stereo_pass (dpp, buffer, 8); +#if defined(CPU_COLDFIRE) + decorr_stereo_pass_cont_mcf5249 (dpp, buffer + 16, sample_count - 8); +#elif defined(CPU_ARM) + if (((flags & MAG_MASK) >> MAG_LSB) > 15) + decorr_stereo_pass_cont_arml (dpp, buffer + 16, sample_count - 8); + else + decorr_stereo_pass_cont_arm (dpp, buffer + 16, sample_count - 8); +#else + decorr_stereo_pass_cont (dpp, buffer + 16, sample_count - 8); +#endif + } + + if (flags & JOINT_STEREO) + for (bptr = buffer; bptr < eptr; bptr += 2) { + bptr [0] += (bptr [1] -= (bptr [0] >> 1)); + + if (labs (bptr [0]) > mute_limit || labs (bptr [1]) > mute_limit) { + i = (bptr - buffer) / 2; + break; + } + + crc = (crc * 3 + bptr [0]) * 3 + bptr [1]; + } + else + for (bptr = buffer; bptr < eptr; bptr += 2) { + if (labs (bptr [0]) > mute_limit || labs (bptr [1]) > mute_limit) { + i = (bptr - buffer) / 2; + break; + } + + crc = (crc * 3 + bptr [0]) * 3 + bptr [1]; + } + } + + if (i != sample_count) { + memset (buffer, 0, sample_count * (flags & MONO_FLAG ? 4 : 8)); + wps->mute_error = TRUE; + i = sample_count; + } + + fixup_samples (wps, buffer, i); + + if (flags & FALSE_STEREO) { + int32_t *dptr = buffer + i * 2; + int32_t *sptr = buffer + i; + int32_t c = i; + + while (c--) { + *--dptr = *--sptr; + *--dptr = *sptr; + } + } + + wps->sample_index += i; + wps->crc = crc; + + return i; +} + +static void decorr_stereo_pass (struct decorr_pass *dpp, int32_t *buffer, int32_t sample_count) +{ + int32_t delta = dpp->delta, weight_A = dpp->weight_A, weight_B = dpp->weight_B; + int32_t *bptr, *eptr = buffer + (sample_count * 2), sam_A, sam_B; + int m, k; + + switch (dpp->term) { + + case 17: + for (bptr = buffer; bptr < eptr; bptr += 2) { + sam_A = 2 * dpp->samples_A [0] - dpp->samples_A [1]; + dpp->samples_A [1] = dpp->samples_A [0]; + dpp->samples_A [0] = apply_weight (weight_A, sam_A) + bptr [0]; + update_weight (weight_A, delta, sam_A, bptr [0]); + bptr [0] = dpp->samples_A [0]; + + sam_A = 2 * dpp->samples_B [0] - dpp->samples_B [1]; + dpp->samples_B [1] = dpp->samples_B [0]; + dpp->samples_B [0] = apply_weight (weight_B, sam_A) + bptr [1]; + update_weight (weight_B, delta, sam_A, bptr [1]); + bptr [1] = dpp->samples_B [0]; + } + + break; + + case 18: + for (bptr = buffer; bptr < eptr; bptr += 2) { + sam_A = (3 * dpp->samples_A [0] - dpp->samples_A [1]) >> 1; + dpp->samples_A [1] = dpp->samples_A [0]; + dpp->samples_A [0] = apply_weight (weight_A, sam_A) + bptr [0]; + update_weight (weight_A, delta, sam_A, bptr [0]); + bptr [0] = dpp->samples_A [0]; + + sam_A = (3 * dpp->samples_B [0] - dpp->samples_B [1]) >> 1; + dpp->samples_B [1] = dpp->samples_B [0]; + dpp->samples_B [0] = apply_weight (weight_B, sam_A) + bptr [1]; + update_weight (weight_B, delta, sam_A, bptr [1]); + bptr [1] = dpp->samples_B [0]; + } + + break; + + default: + for (m = 0, k = dpp->term & (MAX_TERM - 1), bptr = buffer; bptr < eptr; bptr += 2) { + sam_A = dpp->samples_A [m]; + dpp->samples_A [k] = apply_weight (weight_A, sam_A) + bptr [0]; + update_weight (weight_A, delta, sam_A, bptr [0]); + bptr [0] = dpp->samples_A [k]; + + sam_A = dpp->samples_B [m]; + dpp->samples_B [k] = apply_weight (weight_B, sam_A) + bptr [1]; + update_weight (weight_B, delta, sam_A, bptr [1]); + bptr [1] = dpp->samples_B [k]; + + m = (m + 1) & (MAX_TERM - 1); + k = (k + 1) & (MAX_TERM - 1); + } + + if (m) { + int32_t temp_samples [MAX_TERM]; + + memcpy (temp_samples, dpp->samples_A, sizeof (dpp->samples_A)); + + for (k = 0; k < MAX_TERM; k++, m++) + dpp->samples_A [k] = temp_samples [m & (MAX_TERM - 1)]; + + memcpy (temp_samples, dpp->samples_B, sizeof (dpp->samples_B)); + + for (k = 0; k < MAX_TERM; k++, m++) + dpp->samples_B [k] = temp_samples [m & (MAX_TERM - 1)]; + } + + break; + + case -1: + for (bptr = buffer; bptr < eptr; bptr += 2) { + sam_A = bptr [0] + apply_weight (weight_A, dpp->samples_A [0]); + update_weight_clip (weight_A, delta, dpp->samples_A [0], bptr [0]); + bptr [0] = sam_A; + dpp->samples_A [0] = bptr [1] + apply_weight (weight_B, sam_A); + update_weight_clip (weight_B, delta, sam_A, bptr [1]); + bptr [1] = dpp->samples_A [0]; + } + + break; + + case -2: + for (bptr = buffer; bptr < eptr; bptr += 2) { + sam_B = bptr [1] + apply_weight (weight_B, dpp->samples_B [0]); + update_weight_clip (weight_B, delta, dpp->samples_B [0], bptr [1]); + bptr [1] = sam_B; + dpp->samples_B [0] = bptr [0] + apply_weight (weight_A, sam_B); + update_weight_clip (weight_A, delta, sam_B, bptr [0]); + bptr [0] = dpp->samples_B [0]; + } + + break; + + case -3: + for (bptr = buffer; bptr < eptr; bptr += 2) { + sam_A = bptr [0] + apply_weight (weight_A, dpp->samples_A [0]); + update_weight_clip (weight_A, delta, dpp->samples_A [0], bptr [0]); + sam_B = bptr [1] + apply_weight (weight_B, dpp->samples_B [0]); + update_weight_clip (weight_B, delta, dpp->samples_B [0], bptr [1]); + bptr [0] = dpp->samples_B [0] = sam_A; + bptr [1] = dpp->samples_A [0] = sam_B; + } + + break; + } + + dpp->weight_A = weight_A; + dpp->weight_B = weight_B; +} + +#if (!defined(CPU_COLDFIRE) && !defined(CPU_ARM)) + +static void decorr_stereo_pass_cont (struct decorr_pass *dpp, int32_t *buffer, int32_t sample_count) +{ + int32_t delta = dpp->delta, weight_A = dpp->weight_A, weight_B = dpp->weight_B; + int32_t *bptr, *tptr, *eptr = buffer + (sample_count * 2), sam_A, sam_B; + int k, i; + + switch (dpp->term) { + + case 17: + for (bptr = buffer; bptr < eptr; bptr += 2) { + sam_A = 2 * bptr [-2] - bptr [-4]; + bptr [0] = apply_weight (weight_A, sam_A) + (sam_B = bptr [0]); + update_weight (weight_A, delta, sam_A, sam_B); + + sam_A = 2 * bptr [-1] - bptr [-3]; + bptr [1] = apply_weight (weight_B, sam_A) + (sam_B = bptr [1]); + update_weight (weight_B, delta, sam_A, sam_B); + } + + dpp->samples_B [0] = bptr [-1]; + dpp->samples_A [0] = bptr [-2]; + dpp->samples_B [1] = bptr [-3]; + dpp->samples_A [1] = bptr [-4]; + break; + + case 18: + for (bptr = buffer; bptr < eptr; bptr += 2) { + sam_A = (3 * bptr [-2] - bptr [-4]) >> 1; + bptr [0] = apply_weight (weight_A, sam_A) + (sam_B = bptr [0]); + update_weight (weight_A, delta, sam_A, sam_B); + + sam_A = (3 * bptr [-1] - bptr [-3]) >> 1; + bptr [1] = apply_weight (weight_B, sam_A) + (sam_B = bptr [1]); + update_weight (weight_B, delta, sam_A, sam_B); + } + + dpp->samples_B [0] = bptr [-1]; + dpp->samples_A [0] = bptr [-2]; + dpp->samples_B [1] = bptr [-3]; + dpp->samples_A [1] = bptr [-4]; + break; + + default: + for (bptr = buffer, tptr = buffer - (dpp->term * 2); bptr < eptr; bptr += 2, tptr += 2) { + bptr [0] = apply_weight (weight_A, tptr [0]) + (sam_A = bptr [0]); + update_weight (weight_A, delta, tptr [0], sam_A); + + bptr [1] = apply_weight (weight_B, tptr [1]) + (sam_A = bptr [1]); + update_weight (weight_B, delta, tptr [1], sam_A); + } + + for (k = dpp->term - 1, i = 8; i--; k--) { + dpp->samples_B [k & (MAX_TERM - 1)] = *--bptr; + dpp->samples_A [k & (MAX_TERM - 1)] = *--bptr; + } + + break; + + case -1: + for (bptr = buffer; bptr < eptr; bptr += 2) { + bptr [0] = apply_weight (weight_A, bptr [-1]) + (sam_A = bptr [0]); + update_weight_clip (weight_A, delta, bptr [-1], sam_A); + bptr [1] = apply_weight (weight_B, bptr [0]) + (sam_A = bptr [1]); + update_weight_clip (weight_B, delta, bptr [0], sam_A); + } + + dpp->samples_A [0] = bptr [-1]; + break; + + case -2: + for (bptr = buffer; bptr < eptr; bptr += 2) { + bptr [1] = apply_weight (weight_B, bptr [-2]) + (sam_A = bptr [1]); + update_weight_clip (weight_B, delta, bptr [-2], sam_A); + bptr [0] = apply_weight (weight_A, bptr [1]) + (sam_A = bptr [0]); + update_weight_clip (weight_A, delta, bptr [1], sam_A); + } + + dpp->samples_B [0] = bptr [-2]; + break; + + case -3: + for (bptr = buffer; bptr < eptr; bptr += 2) { + bptr [0] = apply_weight (weight_A, bptr [-1]) + (sam_A = bptr [0]); + update_weight_clip (weight_A, delta, bptr [-1], sam_A); + bptr [1] = apply_weight (weight_B, bptr [-2]) + (sam_A = bptr [1]); + update_weight_clip (weight_B, delta, bptr [-2], sam_A); + } + + dpp->samples_A [0] = bptr [-1]; + dpp->samples_B [0] = bptr [-2]; + break; + } + + dpp->weight_A = weight_A; + dpp->weight_B = weight_B; +} + +#endif + +static void decorr_mono_pass (struct decorr_pass *dpp, int32_t *buffer, int32_t sample_count) +{ + int32_t delta = dpp->delta, weight_A = dpp->weight_A; + int32_t *bptr, *eptr = buffer + sample_count, sam_A; + int m, k; + + switch (dpp->term) { + + case 17: + for (bptr = buffer; bptr < eptr; bptr++) { + sam_A = 2 * dpp->samples_A [0] - dpp->samples_A [1]; + dpp->samples_A [1] = dpp->samples_A [0]; + dpp->samples_A [0] = apply_weight (weight_A, sam_A) + bptr [0]; + update_weight (weight_A, delta, sam_A, bptr [0]); + bptr [0] = dpp->samples_A [0]; + } + + break; + + case 18: + for (bptr = buffer; bptr < eptr; bptr++) { + sam_A = (3 * dpp->samples_A [0] - dpp->samples_A [1]) >> 1; + dpp->samples_A [1] = dpp->samples_A [0]; + dpp->samples_A [0] = apply_weight (weight_A, sam_A) + bptr [0]; + update_weight (weight_A, delta, sam_A, bptr [0]); + bptr [0] = dpp->samples_A [0]; + } + + break; + + default: + for (m = 0, k = dpp->term & (MAX_TERM - 1), bptr = buffer; bptr < eptr; bptr++) { + sam_A = dpp->samples_A [m]; + dpp->samples_A [k] = apply_weight (weight_A, sam_A) + bptr [0]; + update_weight (weight_A, delta, sam_A, bptr [0]); + bptr [0] = dpp->samples_A [k]; + m = (m + 1) & (MAX_TERM - 1); + k = (k + 1) & (MAX_TERM - 1); + } + + if (m) { + int32_t temp_samples [MAX_TERM]; + + memcpy (temp_samples, dpp->samples_A, sizeof (dpp->samples_A)); + + for (k = 0; k < MAX_TERM; k++, m++) + dpp->samples_A [k] = temp_samples [m & (MAX_TERM - 1)]; + } + + break; + } + + dpp->weight_A = weight_A; +} + + +// This is a helper function for unpack_samples() that applies several final +// operations. First, if the data is 32-bit float data, then that conversion +// is done in the float.c module (whether lossy or lossless) and we return. +// Otherwise, if the extended integer data applies, then that operation is +// executed first. If the unpacked data is lossy (and not corrected) then +// it is clipped and shifted in a single operation. Otherwise, if it's +// lossless then the last step is to apply the final shift (if any). + +// This function has been modified for RockBox to return all integer samples +// as 28-bits, and clipping (for lossy mode) has been eliminated because this +// now happens in the dsp module. + +static void fixup_samples (WavpackStream *wps, int32_t *buffer, uint32_t sample_count) +{ + uint32_t flags = wps->wphdr.flags; + int shift = (flags & SHIFT_MASK) >> SHIFT_LSB; + + shift += 21 - (flags & BYTES_STORED) * 8; // this provides RockBox with 28-bit (+sign) + + if (flags & FLOAT_DATA) { + float_values (wps, buffer, (flags & MONO_DATA) ? sample_count : sample_count * 2); + return; + } + + if (flags & INT32_DATA) { + uint32_t count = (flags & MONO_DATA) ? sample_count : sample_count * 2; + int sent_bits = wps->int32_sent_bits, zeros = wps->int32_zeros; + int ones = wps->int32_ones, dups = wps->int32_dups; + int32_t *dptr = buffer; + + if (!(flags & HYBRID_FLAG) && !sent_bits && (zeros + ones + dups)) + while (count--) { + if (zeros) + *dptr <<= zeros; + else if (ones) + *dptr = ((*dptr + 1) << ones) - 1; + else if (dups) + *dptr = ((*dptr + (*dptr & 1)) << dups) - (*dptr & 1); + + dptr++; + } + else + shift += zeros + sent_bits + ones + dups; + } + + if (shift > 0) { + if (!(flags & MONO_DATA)) + sample_count *= 2; + + while (sample_count--) + *buffer++ <<= shift; + } + else if (shift < 0) { + shift = -shift; + + if (!(flags & MONO_DATA)) + sample_count *= 2; + + while (sample_count--) + *buffer++ >>= shift; + } +} + +// This function checks the crc value(s) for an unpacked block, returning the +// number of actual crc errors detected for the block. The block must be +// completely unpacked before this test is valid. For losslessly unpacked +// blocks of float or extended integer data the extended crc is also checked. +// Note that WavPack's crc is not a CCITT approved polynomial algorithm, but +// is a much simpler method that is virtually as robust for real world data. + +int check_crc_error (WavpackContext *wpc) +{ + WavpackStream *wps = &wpc->stream; + int result = 0; + + if (wps->crc != wps->wphdr.crc) + ++result; + + return result; +} diff --git a/lib/rbcodec/codecs/libwavpack/wavpack.h b/lib/rbcodec/codecs/libwavpack/wavpack.h new file mode 100644 index 0000000000..b15a176f33 --- /dev/null +++ b/lib/rbcodec/codecs/libwavpack/wavpack.h @@ -0,0 +1,447 @@ +//////////////////////////////////////////////////////////////////////////// +// **** WAVPACK **** // +// Hybrid Lossless Wavefile Compressor // +// Copyright (c) 1998 - 2004 Conifer Software. // +// All Rights Reserved. // +// Distributed under the BSD Software License (see license.txt) // +//////////////////////////////////////////////////////////////////////////// + +// wavpack.h +#ifdef CODEC +#include "codeclib.h" +#endif +#include + +// This header file contains all the definitions required by WavPack. + +typedef unsigned char uchar; +typedef unsigned short ushort; +#if 0 // unused and causing compiler errrors +typedef unsigned int uint; +#endif + +#include + +#define FALSE 0 +#define TRUE 1 + +////////////////////////////// WavPack Header ///////////////////////////////// + +// Note that this is the ONLY structure that is written to (or read from) +// WavPack 4.0 files, and is the preamble to every block in both the .wv +// and .wvc files. + +typedef struct { + char ckID [4]; + uint32_t ckSize; + short version; + uchar track_no, index_no; + uint32_t total_samples, block_index, block_samples, flags, crc; +} WavpackHeader; + +#define WavpackHeaderFormat "4LS2LLLLL" + +// or-values for "flags" + +#define BYTES_STORED 3 // 1-4 bytes/sample +#define MONO_FLAG 4 // not stereo +#define HYBRID_FLAG 8 // hybrid mode +#define JOINT_STEREO 0x10 // joint stereo +#define CROSS_DECORR 0x20 // no-delay cross decorrelation +#define HYBRID_SHAPE 0x40 // noise shape (hybrid mode only) +#define FLOAT_DATA 0x80 // ieee 32-bit floating point data + +#define INT32_DATA 0x100 // special extended int handling +#define HYBRID_BITRATE 0x200 // bitrate noise (hybrid mode only) +#define HYBRID_BALANCE 0x400 // balance noise (hybrid stereo mode only) + +#define INITIAL_BLOCK 0x800 // initial block of multichannel segment +#define FINAL_BLOCK 0x1000 // final block of multichannel segment + +#define SHIFT_LSB 13 +#define SHIFT_MASK (0x1fL << SHIFT_LSB) + +#define MAG_LSB 18 +#define MAG_MASK (0x1fL << MAG_LSB) + +#define SRATE_LSB 23 +#define SRATE_MASK (0xfL << SRATE_LSB) + +#define FALSE_STEREO 0x40000000 // block is stereo, but data is mono + +#define IGNORED_FLAGS 0x18000000 // reserved, but ignore if encountered +#define NEW_SHAPING 0x20000000 // use IIR filter for negative shaping +#define UNKNOWN_FLAGS 0x80000000 // also reserved, but refuse decode if + // encountered + +#define MONO_DATA (MONO_FLAG | FALSE_STEREO) + +#define MIN_STREAM_VERS 0x402 // lowest stream version we'll decode +#define MAX_STREAM_VERS 0x410 // highest stream version we'll decode +#define CUR_STREAM_VERS 0x403 // stream version we are writing now + +//////////////////////////// WavPack Metadata ///////////////////////////////// + +// This is an internal representation of metadata. + +typedef struct { + uchar temp_data [64]; + int32_t byte_length; + void *data; + uchar id; +} WavpackMetadata; + +#define ID_OPTIONAL_DATA 0x20 +#define ID_ODD_SIZE 0x40 +#define ID_LARGE 0x80 + +#define ID_DUMMY 0x0 +#define ID_ENCODER_INFO 0x1 +#define ID_DECORR_TERMS 0x2 +#define ID_DECORR_WEIGHTS 0x3 +#define ID_DECORR_SAMPLES 0x4 +#define ID_ENTROPY_VARS 0x5 +#define ID_HYBRID_PROFILE 0x6 +#define ID_SHAPING_WEIGHTS 0x7 +#define ID_FLOAT_INFO 0x8 +#define ID_INT32_INFO 0x9 +#define ID_WV_BITSTREAM 0xa +#define ID_WVC_BITSTREAM 0xb +#define ID_WVX_BITSTREAM 0xc +#define ID_CHANNEL_INFO 0xd + +#define ID_RIFF_HEADER (ID_OPTIONAL_DATA | 0x1) +#define ID_RIFF_TRAILER (ID_OPTIONAL_DATA | 0x2) +#define ID_REPLAY_GAIN (ID_OPTIONAL_DATA | 0x3) +#define ID_CUESHEET (ID_OPTIONAL_DATA | 0x4) +#define ID_CONFIG_BLOCK (ID_OPTIONAL_DATA | 0x5) +#define ID_MD5_CHECKSUM (ID_OPTIONAL_DATA | 0x6) +#define ID_SAMPLE_RATE (ID_OPTIONAL_DATA | 0x7) + +///////////////////////// WavPack Configuration /////////////////////////////// + +// This internal structure is used during encode to provide configuration to +// the encoding engine and during decoding to provide fle information back to +// the higher level functions. Not all fields are used in both modes. + +typedef struct { + int bits_per_sample, bytes_per_sample; + int flags, num_channels, float_norm_exp; + uint32_t sample_rate, channel_mask; +} WavpackConfig; + +#define CONFIG_BYTES_STORED 3 // 1-4 bytes/sample +#define CONFIG_MONO_FLAG 4 // not stereo +#define CONFIG_HYBRID_FLAG 8 // hybrid mode +#define CONFIG_JOINT_STEREO 0x10 // joint stereo +#define CONFIG_CROSS_DECORR 0x20 // no-delay cross decorrelation +#define CONFIG_HYBRID_SHAPE 0x40 // noise shape (hybrid mode only) +#define CONFIG_FLOAT_DATA 0x80 // ieee 32-bit floating point data + +#define CONFIG_ADOBE_MODE 0x100 // "adobe" mode for 32-bit floats +#define CONFIG_FAST_FLAG 0x200 // fast mode +#define CONFIG_VERY_FAST_FLAG 0x400 // double fast +#define CONFIG_HIGH_FLAG 0x800 // high quality mode +#define CONFIG_VERY_HIGH_FLAG 0x1000 // double high (not used yet) +#define CONFIG_BITRATE_KBPS 0x2000 // bitrate is kbps, not bits / sample +#define CONFIG_AUTO_SHAPING 0x4000 // automatic noise shaping +#define CONFIG_SHAPE_OVERRIDE 0x8000 // shaping mode specified +#define CONFIG_JOINT_OVERRIDE 0x10000 // joint-stereo mode specified +#define CONFIG_COPY_TIME 0x20000 // copy file-time from source +#define CONFIG_CREATE_EXE 0x40000 // create executable (not yet) +#define CONFIG_CREATE_WVC 0x80000 // create correction file +#define CONFIG_OPTIMIZE_WVC 0x100000 // maximize bybrid compression +#define CONFIG_QUALITY_MODE 0x200000 // psychoacoustic quality mode +#define CONFIG_RAW_FLAG 0x400000 // raw mode (not implemented yet) +#define CONFIG_CALC_NOISE 0x800000 // calc noise in hybrid mode +#define CONFIG_LOSSY_MODE 0x1000000 // obsolete (for information) +#define CONFIG_EXTRA_MODE 0x2000000 // extra processing mode +#define CONFIG_SKIP_WVX 0x4000000 // no wvx stream w/ floats & big ints +#define CONFIG_MD5_CHECKSUM 0x8000000 // compute & store MD5 signature +#define CONFIG_QUIET_MODE 0x10000000 // don't report progress % + +//////////////////////////////// WavPack Stream /////////////////////////////// + +// This internal structure contains everything required to handle a WavPack +// "stream", which is defined as a stereo or mono stream of audio samples. For +// multichannel audio several of these would be required. Each stream contains +// pointers to hold a complete allocated block of WavPack data, although it's +// possible to decode WavPack blocks without buffering an entire block. + +typedef int32_t (*read_stream)(void *, int32_t); + +typedef struct bs { + uchar *buf, *end, *ptr; + void (*wrap)(struct bs *bs); + uint32_t file_bytes, sr; + int error, bc; + read_stream file; +} Bitstream; + +#define MAX_NTERMS 16 +#define MAX_TERM 8 + +struct decorr_pass { + short term, delta, weight_A, weight_B; + int32_t samples_A [MAX_TERM], samples_B [MAX_TERM]; +}; + +struct entropy_data { + uint32_t median [3], slow_level, error_limit; +}; + +struct words_data { + uint32_t bitrate_delta [2], bitrate_acc [2]; + uint32_t pend_data, holding_one, zeros_acc; + int holding_zero, pend_count; + struct entropy_data c [2]; +}; + +typedef struct { + WavpackHeader wphdr; + Bitstream wvbits; + + struct words_data w; + + int num_terms, mute_error; + uint32_t sample_index, crc; + int32_t block_bytes_left; + + uchar int32_sent_bits, int32_zeros, int32_ones, int32_dups; + uchar float_flags, float_shift, float_max_exp, float_norm_exp; + uchar *blockbuff, *blockend; + + struct decorr_pass decorr_passes [MAX_NTERMS]; + +} WavpackStream; + +// flags for float_flags: + +#define FLOAT_SHIFT_ONES 1 // bits left-shifted into float = '1' +#define FLOAT_SHIFT_SAME 2 // bits left-shifted into float are the same +#define FLOAT_SHIFT_SENT 4 // bits shifted into float are sent literally +#define FLOAT_ZEROS_SENT 8 // "zeros" are not all real zeros +#define FLOAT_NEG_ZEROS 0x10 // contains negative zeros +#define FLOAT_EXCEPTIONS 0x20 // contains exceptions (inf, nan, etc.) + +/////////////////////////////// WavPack Context /////////////////////////////// + +// This internal structure holds everything required to encode or decode WavPack +// files. It is recommended that direct access to this structure be minimized +// and the provided utilities used instead. + +typedef struct { + WavpackStream stream; + WavpackConfig config; + + uchar *wrapper_data; + int wrapper_bytes; + + uchar read_buffer [1024]; + char error_message [80]; + + read_stream infile; + uint32_t total_samples, crc_errors, first_flags; + int open_flags, norm_offset, reduced_channels, lossy_blocks; + +} WavpackContext; + +//////////////////////// function prototypes and macros ////////////////////// + +#define CLEAR(destin) memset (&destin, 0, sizeof (destin)); + +// bits.c + +void bs_open_read (Bitstream *bs, uchar *buffer_start, uchar *buffer_end, read_stream file, uint32_t file_bytes); +void bs_open_write (Bitstream *bs, uchar *buffer_start, uchar *buffer_end); +uint32_t bs_close_write (Bitstream *bs); + +#define bs_is_open(bs) ((bs)->ptr != NULL) + +#define getbit(bs) ( \ + (((bs)->bc) ? \ + ((bs)->bc--, (bs)->sr & 1) : \ + (((++((bs)->ptr) != (bs)->end) ? (void) 0 : (bs)->wrap (bs)), (bs)->bc = 7, ((bs)->sr = *((bs)->ptr)) & 1) \ + ) ? \ + ((bs)->sr >>= 1, 1) : \ + ((bs)->sr >>= 1, 0) \ +) + +#define getbits(value, nbits, bs) { \ + while ((nbits) > (bs)->bc) { \ + if (++((bs)->ptr) == (bs)->end) (bs)->wrap (bs); \ + (bs)->sr |= (int32_t)*((bs)->ptr) << (bs)->bc; \ + (bs)->bc += 8; \ + } \ + *(value) = (bs)->sr; \ + if ((bs)->bc > 32) { \ + (bs)->bc -= (nbits); \ + (bs)->sr = *((bs)->ptr) >> (8 - (bs)->bc); \ + } \ + else { \ + (bs)->bc -= (nbits); \ + (bs)->sr >>= (nbits); \ + } \ +} + +#define putbit(bit, bs) { if (bit) (bs)->sr |= (1 << (bs)->bc); \ + if (++((bs)->bc) == 8) { \ + *((bs)->ptr) = (bs)->sr; \ + (bs)->sr = (bs)->bc = 0; \ + if (++((bs)->ptr) == (bs)->end) (bs)->wrap (bs); \ + }} + +#define putbit_0(bs) { \ + if (++((bs)->bc) == 8) { \ + *((bs)->ptr) = (bs)->sr; \ + (bs)->sr = (bs)->bc = 0; \ + if (++((bs)->ptr) == (bs)->end) (bs)->wrap (bs); \ + }} + +#define putbit_1(bs) { (bs)->sr |= (1 << (bs)->bc); \ + if (++((bs)->bc) == 8) { \ + *((bs)->ptr) = (bs)->sr; \ + (bs)->sr = (bs)->bc = 0; \ + if (++((bs)->ptr) == (bs)->end) (bs)->wrap (bs); \ + }} + +#define putbits(value, nbits, bs) { \ + (bs)->sr |= (int32_t)(value) << (bs)->bc; \ + if (((bs)->bc += (nbits)) >= 8) \ + do { \ + *((bs)->ptr) = (bs)->sr; \ + (bs)->sr >>= 8; \ + if (++((bs)->ptr) == (bs)->end) (bs)->wrap (bs); \ + } while (((bs)->bc -= 8) >= 8); \ +} + +void little_endian_to_native (void *data, char *format); +void native_to_little_endian (void *data, char *format); + +// These macros implement the weight application and update operations +// that are at the heart of the decorrelation loops. Note that when there +// are several alternative versions of the same macro (marked with PERFCOND) +// then the versions are functionally equivalent with respect to WavPack +// decoding and the user should choose the one that provides the best +// performance. This may be easier to check when NOT using the assembly +// language optimizations. + +#if 1 // PERFCOND +#define apply_weight_i(weight, sample) ((weight * sample + 512) >> 10) +#else +#define apply_weight_i(weight, sample) ((((weight * sample) >> 8) + 2) >> 2) +#endif + +#define apply_weight_f(weight, sample) (((((sample & 0xffff) * weight) >> 9) + \ + (((sample & ~0xffff) >> 9) * weight) + 1) >> 1) + +#if 1 // PERFCOND +#define apply_weight(weight, sample) (sample != (short) sample ? \ + apply_weight_f (weight, sample) : apply_weight_i (weight, sample)) +#else +#define apply_weight(weight, sample) ((int32_t)((weight * (int64_t) sample + 512) >> 10)) +#endif + +#if 0 // PERFCOND +#define update_weight(weight, delta, source, result) \ + if (source && result) { int32_t s = (int32_t) (source ^ result) >> 31; weight = (delta ^ s) + (weight - s); } +#elif 1 +#define update_weight(weight, delta, source, result) \ + if (source && result) weight += (((source ^ result) >> 30) | 1) * delta +#else +#define update_weight(weight, delta, source, result) \ + if (source && result) (source ^ result) < 0 ? (weight -= delta) : (weight += delta) +#endif + +#define update_weight_clip(weight, delta, source, result) \ + if (source && result && ((source ^ result) < 0 ? (weight -= delta) < -1024 : (weight += delta) > 1024)) \ + weight = weight < 0 ? -1024 : 1024 + +// unpack.c + +int unpack_init (WavpackContext *wpc); +int init_wv_bitstream (WavpackContext *wpc, WavpackMetadata *wpmd); +int read_decorr_terms (WavpackStream *wps, WavpackMetadata *wpmd); +int read_decorr_weights (WavpackStream *wps, WavpackMetadata *wpmd); +int read_decorr_samples (WavpackStream *wps, WavpackMetadata *wpmd); +int read_float_info (WavpackStream *wps, WavpackMetadata *wpmd); +int read_int32_info (WavpackStream *wps, WavpackMetadata *wpmd); +int read_channel_info (WavpackContext *wpc, WavpackMetadata *wpmd); +int read_config_info (WavpackContext *wpc, WavpackMetadata *wpmd); +int read_sample_rate (WavpackContext *wpc, WavpackMetadata *wpmd); +int32_t unpack_samples (WavpackContext *wpc, int32_t *buffer, uint32_t sample_count); +int check_crc_error (WavpackContext *wpc); + +// pack.c + +void pack_init (WavpackContext *wpc); +int pack_start_block (WavpackContext *wpc); +int pack_samples (WavpackContext *wpc, int32_t *buffer, uint32_t sample_count); +int pack_finish_block (WavpackContext *wpc); + +// metadata.c stuff + +int read_metadata_buff (WavpackContext *wpc, WavpackMetadata *wpmd); +int process_metadata (WavpackContext *wpc, WavpackMetadata *wpmd); +int copy_metadata (WavpackMetadata *wpmd, uchar *buffer_start, uchar *buffer_end); +void free_metadata (WavpackMetadata *wpmd); + +// words.c stuff + +void init_words (WavpackStream *wps); +int read_entropy_vars (WavpackStream *wps, WavpackMetadata *wpmd); +void write_entropy_vars (WavpackStream *wps, WavpackMetadata *wpmd); +int read_hybrid_profile (WavpackStream *wps, WavpackMetadata *wpmd); +int32_t get_words (int32_t *buffer, int nsamples, uint32_t flags, + struct words_data *w, Bitstream *bs); +void send_word_lossless (int32_t value, int chan, + struct words_data *w, Bitstream *bs); +void send_words (int32_t *buffer, int nsamples, uint32_t flags, + struct words_data *w, Bitstream *bs); +void flush_word (struct words_data *w, Bitstream *bs); +int log2s (int32_t value); +int32_t exp2s (int log); +signed char store_weight (int weight); +int restore_weight (signed char weight); + +#define WORD_EOF (1L << 31) + +// float.c + +int read_float_info (WavpackStream *wps, WavpackMetadata *wpmd); +void float_values (WavpackStream *wps, int32_t *values, int32_t num_values); +void float_normalize (int32_t *values, int32_t num_values, int delta_exp); + +// wputils.c + +WavpackContext *WavpackOpenFileInput (read_stream infile, char *error); + +int WavpackGetMode (WavpackContext *wpc); + +#define MODE_WVC 0x1 +#define MODE_LOSSLESS 0x2 +#define MODE_HYBRID 0x4 +#define MODE_FLOAT 0x8 +#define MODE_VALID_TAG 0x10 +#define MODE_HIGH 0x20 +#define MODE_FAST 0x40 + +uint32_t WavpackUnpackSamples (WavpackContext *wpc, int32_t *buffer, uint32_t samples); +uint32_t WavpackGetNumSamples (WavpackContext *wpc); +uint32_t WavpackGetSampleIndex (WavpackContext *wpc); +int WavpackGetNumErrors (WavpackContext *wpc); +int WavpackLossyBlocks (WavpackContext *wpc); +uint32_t WavpackGetSampleRate (WavpackContext *wpc); +int WavpackGetBitsPerSample (WavpackContext *wpc); +int WavpackGetBytesPerSample (WavpackContext *wpc); +int WavpackGetNumChannels (WavpackContext *wpc); +int WavpackGetReducedChannels (WavpackContext *wpc); +WavpackContext *WavpackOpenFileOutput (void); +int WavpackSetConfiguration (WavpackContext *wpc, WavpackConfig *config, uint32_t total_samples); +void WavpackAddWrapper (WavpackContext *wpc, void *data, uint32_t bcount); +int WavpackStartBlock (WavpackContext *wpc, uchar *begin, uchar *end); +int WavpackPackSamples (WavpackContext *wpc, int32_t *sample_buffer, uint32_t sample_count); +uint32_t WavpackFinishBlock (WavpackContext *wpc); +void WavpackUpdateNumSamples (WavpackContext *wpc, void *first_block); +void *WavpackGetWrapperLocation (void *first_block); + diff --git a/lib/rbcodec/codecs/libwavpack/words.c b/lib/rbcodec/codecs/libwavpack/words.c new file mode 100644 index 0000000000..3d9e753e4b --- /dev/null +++ b/lib/rbcodec/codecs/libwavpack/words.c @@ -0,0 +1,786 @@ +//////////////////////////////////////////////////////////////////////////// +// **** WAVPACK **** // +// Hybrid Lossless Wavefile Compressor // +// Copyright (c) 1998 - 2004 Conifer Software. // +// All Rights Reserved. // +//////////////////////////////////////////////////////////////////////////// + +// words.c + +// This module provides entropy word encoding and decoding functions using +// a variation on the Rice method. This was introduced in version 3.93 +// because it allows splitting the data into a "lossy" stream and a +// "correction" stream in a very efficient manner and is therefore ideal +// for the "hybrid" mode. For 4.0, the efficiency of this method was +// significantly improved by moving away from the normal Rice restriction of +// using powers of two for the modulus divisions and now the method can be +// used for both hybrid and pure lossless encoding. + +// Samples are divided by median probabilities at 5/7 (71.43%), 10/49 (20.41%), +// and 20/343 (5.83%). Each zone has 3.5 times fewer samples than the +// previous. Using standard Rice coding on this data would result in 1.4 +// bits per sample average (not counting sign bit). However, there is a +// very simple encoding that is over 99% efficient with this data and +// results in about 1.22 bits per sample. + +#include "wavpack.h" + +#include + +//////////////////////////////// local macros ///////////////////////////////// + +#define LIMIT_ONES 16 // maximum consecutive 1s sent for "div" data + +// these control the time constant "slow_level" which is used for hybrid mode +// that controls bitrate as a function of residual level (HYBRID_BITRATE). +#define SLS 8 +#define SLO ((1 << (SLS - 1))) + +// these control the time constant of the 3 median level breakpoints +#define DIV0 128 // 5/7 of samples +#define DIV1 64 // 10/49 of samples +#define DIV2 32 // 20/343 of samples + +// this macro retrieves the specified median breakpoint (without frac; min = 1) +#define GET_MED(med) (((c->median [med]) >> 4) + 1) + +// These macros update the specified median breakpoints. Note that the median +// is incremented when the sample is higher than the median, else decremented. +// They are designed so that the median will never drop below 1 and the value +// is essentially stationary if there are 2 increments for every 5 decrements. + +#define INC_MED0() (c->median [0] += ((c->median [0] + DIV0) / DIV0) * 5) +#define DEC_MED0() (c->median [0] -= ((c->median [0] + (DIV0-2)) / DIV0) * 2) +#define INC_MED1() (c->median [1] += ((c->median [1] + DIV1) / DIV1) * 5) +#define DEC_MED1() (c->median [1] -= ((c->median [1] + (DIV1-2)) / DIV1) * 2) +#define INC_MED2() (c->median [2] += ((c->median [2] + DIV2) / DIV2) * 5) +#define DEC_MED2() (c->median [2] -= ((c->median [2] + (DIV2-2)) / DIV2) * 2) + +#define count_bits(av) ( \ + (av) < (1 << 8) ? nbits_table [av] : \ + ( \ + (av) < (1L << 16) ? nbits_table [(av) >> 8] + 8 : \ + ((av) < (1L << 24) ? nbits_table [(av) >> 16] + 16 : nbits_table [(av) >> 24] + 24) \ + ) \ +) + +///////////////////////////// local table storage //////////////////////////// + +static const char nbits_table [] ICONST_ATTR = { + 0, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, // 0 - 15 + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, // 16 - 31 + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, // 32 - 47 + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, // 48 - 63 + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 64 - 79 + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 80 - 95 + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 96 - 111 + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 112 - 127 + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, // 128 - 143 + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, // 144 - 159 + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, // 160 - 175 + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, // 176 - 191 + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, // 192 - 207 + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, // 208 - 223 + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, // 224 - 239 + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 // 240 - 255 +}; + +static const uchar log2_table [] = { + 0x00, 0x01, 0x03, 0x04, 0x06, 0x07, 0x09, 0x0a, 0x0b, 0x0d, 0x0e, 0x10, 0x11, 0x12, 0x14, 0x15, + 0x16, 0x18, 0x19, 0x1a, 0x1c, 0x1d, 0x1e, 0x20, 0x21, 0x22, 0x24, 0x25, 0x26, 0x28, 0x29, 0x2a, + 0x2c, 0x2d, 0x2e, 0x2f, 0x31, 0x32, 0x33, 0x34, 0x36, 0x37, 0x38, 0x39, 0x3b, 0x3c, 0x3d, 0x3e, + 0x3f, 0x41, 0x42, 0x43, 0x44, 0x45, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4d, 0x4e, 0x4f, 0x50, 0x51, + 0x52, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5c, 0x5d, 0x5e, 0x5f, 0x60, 0x61, 0x62, 0x63, + 0x64, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x74, 0x75, + 0x76, 0x77, 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, + 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, + 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, + 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, 0xb0, 0xb1, 0xb2, 0xb2, + 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, 0xc0, 0xc0, + 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xcb, 0xcb, 0xcc, 0xcd, 0xce, + 0xcf, 0xd0, 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd8, 0xd9, 0xda, 0xdb, + 0xdc, 0xdc, 0xdd, 0xde, 0xdf, 0xe0, 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe4, 0xe5, 0xe6, 0xe7, 0xe7, + 0xe8, 0xe9, 0xea, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xee, 0xef, 0xf0, 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, + 0xf4, 0xf5, 0xf6, 0xf7, 0xf7, 0xf8, 0xf9, 0xf9, 0xfa, 0xfb, 0xfc, 0xfc, 0xfd, 0xfe, 0xff, 0xff +}; + +static const uchar exp2_table [] ICONST_ATTR = { + 0x00, 0x01, 0x01, 0x02, 0x03, 0x03, 0x04, 0x05, 0x06, 0x06, 0x07, 0x08, 0x08, 0x09, 0x0a, 0x0b, + 0x0b, 0x0c, 0x0d, 0x0e, 0x0e, 0x0f, 0x10, 0x10, 0x11, 0x12, 0x13, 0x13, 0x14, 0x15, 0x16, 0x16, + 0x17, 0x18, 0x19, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1d, 0x1e, 0x1f, 0x20, 0x20, 0x21, 0x22, 0x23, + 0x24, 0x24, 0x25, 0x26, 0x27, 0x28, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, + 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3a, 0x3b, 0x3c, 0x3d, + 0x3e, 0x3f, 0x40, 0x41, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x48, 0x49, 0x4a, 0x4b, + 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, + 0x5b, 0x5c, 0x5d, 0x5e, 0x5e, 0x5f, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, + 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, + 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x87, 0x88, 0x89, 0x8a, + 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, 0x90, 0x91, 0x92, 0x93, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b, + 0x9c, 0x9d, 0x9f, 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, + 0xaf, 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xbc, 0xbd, 0xbe, 0xbf, 0xc0, + 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc8, 0xc9, 0xca, 0xcb, 0xcd, 0xce, 0xcf, 0xd0, 0xd2, 0xd3, 0xd4, + 0xd6, 0xd7, 0xd8, 0xd9, 0xdb, 0xdc, 0xdd, 0xde, 0xe0, 0xe1, 0xe2, 0xe4, 0xe5, 0xe6, 0xe8, 0xe9, + 0xea, 0xec, 0xed, 0xee, 0xf0, 0xf1, 0xf2, 0xf4, 0xf5, 0xf6, 0xf8, 0xf9, 0xfa, 0xfc, 0xfd, 0xff +}; + +static const char ones_count_table [] ICONST_ATTR = { + 0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5, + 0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,6, + 0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5, + 0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,7, + 0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5, + 0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,6, + 0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5, + 0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,8 +}; + +///////////////////////////// executable code //////////////////////////////// + +void init_words (WavpackStream *wps) +{ + CLEAR (wps->w); +} + +static int mylog2 (uint32_t avalue); + +// Read the median log2 values from the specifed metadata structure, convert +// them back to 32-bit unsigned values and store them. If length is not +// exactly correct then we flag and return an error. + +int read_entropy_vars (WavpackStream *wps, WavpackMetadata *wpmd) +{ + uchar *byteptr = wpmd->data; + + if (wpmd->byte_length != ((wps->wphdr.flags & MONO_DATA) ? 6 : 12)) + return FALSE; + + wps->w.c [0].median [0] = exp2s (byteptr [0] + (byteptr [1] << 8)); + wps->w.c [0].median [1] = exp2s (byteptr [2] + (byteptr [3] << 8)); + wps->w.c [0].median [2] = exp2s (byteptr [4] + (byteptr [5] << 8)); + + if (!(wps->wphdr.flags & MONO_DATA)) { + wps->w.c [1].median [0] = exp2s (byteptr [6] + (byteptr [7] << 8)); + wps->w.c [1].median [1] = exp2s (byteptr [8] + (byteptr [9] << 8)); + wps->w.c [1].median [2] = exp2s (byteptr [10] + (byteptr [11] << 8)); + } + + return TRUE; +} + +// Allocates the correct space in the metadata structure and writes the +// current median values to it. Values are converted from 32-bit unsigned +// to our internal 16-bit mylog2 values, and read_entropy_vars () is called +// to read the values back because we must compensate for the loss through +// the log function. + +void write_entropy_vars (WavpackStream *wps, WavpackMetadata *wpmd) +{ + uchar *byteptr; + int temp; + + byteptr = wpmd->data = wpmd->temp_data; + wpmd->id = ID_ENTROPY_VARS; + + *byteptr++ = temp = mylog2 (wps->w.c [0].median [0]); + *byteptr++ = temp >> 8; + *byteptr++ = temp = mylog2 (wps->w.c [0].median [1]); + *byteptr++ = temp >> 8; + *byteptr++ = temp = mylog2 (wps->w.c [0].median [2]); + *byteptr++ = temp >> 8; + + if (!(wps->wphdr.flags & MONO_FLAG)) { + *byteptr++ = temp = mylog2 (wps->w.c [1].median [0]); + *byteptr++ = temp >> 8; + *byteptr++ = temp = mylog2 (wps->w.c [1].median [1]); + *byteptr++ = temp >> 8; + *byteptr++ = temp = mylog2 (wps->w.c [1].median [2]); + *byteptr++ = temp >> 8; + } + + wpmd->byte_length = byteptr - (uchar *) wpmd->data; + read_entropy_vars (wps, wpmd); +} + +// Read the hybrid related values from the specifed metadata structure, convert +// them back to their internal formats and store them. The extended profile +// stuff is not implemented yet, so return an error if we get more data than +// we know what to do with. + +int read_hybrid_profile (WavpackStream *wps, WavpackMetadata *wpmd) +{ + uchar *byteptr = wpmd->data; + uchar *endptr = byteptr + wpmd->byte_length; + + if (wps->wphdr.flags & HYBRID_BITRATE) { + wps->w.c [0].slow_level = exp2s (byteptr [0] + (byteptr [1] << 8)); + byteptr += 2; + + if (!(wps->wphdr.flags & MONO_DATA)) { + wps->w.c [1].slow_level = exp2s (byteptr [0] + (byteptr [1] << 8)); + byteptr += 2; + } + } + + wps->w.bitrate_acc [0] = (int32_t)(byteptr [0] + (byteptr [1] << 8)) << 16; + byteptr += 2; + + if (!(wps->wphdr.flags & MONO_DATA)) { + wps->w.bitrate_acc [1] = (int32_t)(byteptr [0] + (byteptr [1] << 8)) << 16; + byteptr += 2; + } + + if (byteptr < endptr) { + wps->w.bitrate_delta [0] = exp2s ((short)(byteptr [0] + (byteptr [1] << 8))); + byteptr += 2; + + if (!(wps->wphdr.flags & MONO_DATA)) { + wps->w.bitrate_delta [1] = exp2s ((short)(byteptr [0] + (byteptr [1] << 8))); + byteptr += 2; + } + + if (byteptr < endptr) + return FALSE; + } + else + wps->w.bitrate_delta [0] = wps->w.bitrate_delta [1] = 0; + + return TRUE; +} + +// This function is called during both encoding and decoding of hybrid data to +// update the "error_limit" variable which determines the maximum sample error +// allowed in the main bitstream. In the HYBRID_BITRATE mode (which is the only +// currently implemented) this is calculated from the slow_level values and the +// bitrate accumulators. Note that the bitrate accumulators can be changing. + +static void update_error_limit (struct words_data *w, uint32_t flags) +{ + int bitrate_0 = (w->bitrate_acc [0] += w->bitrate_delta [0]) >> 16; + + if (flags & MONO_DATA) { + if (flags & HYBRID_BITRATE) { + int slow_log_0 = (w->c [0].slow_level + SLO) >> SLS; + + if (slow_log_0 - bitrate_0 > -0x100) + w->c [0].error_limit = exp2s (slow_log_0 - bitrate_0 + 0x100); + else + w->c [0].error_limit = 0; + } + else + w->c [0].error_limit = exp2s (bitrate_0); + } + else { + int bitrate_1 = (w->bitrate_acc [1] += w->bitrate_delta [1]) >> 16; + + if (flags & HYBRID_BITRATE) { + int slow_log_0 = (w->c [0].slow_level + SLO) >> SLS; + int slow_log_1 = (w->c [1].slow_level + SLO) >> SLS; + + if (flags & HYBRID_BALANCE) { + int balance = (slow_log_1 - slow_log_0 + bitrate_1 + 1) >> 1; + + if (balance > bitrate_0) { + bitrate_1 = bitrate_0 * 2; + bitrate_0 = 0; + } + else if (-balance > bitrate_0) { + bitrate_0 = bitrate_0 * 2; + bitrate_1 = 0; + } + else { + bitrate_1 = bitrate_0 + balance; + bitrate_0 = bitrate_0 - balance; + } + } + + if (slow_log_0 - bitrate_0 > -0x100) + w->c [0].error_limit = exp2s (slow_log_0 - bitrate_0 + 0x100); + else + w->c [0].error_limit = 0; + + if (slow_log_1 - bitrate_1 > -0x100) + w->c [1].error_limit = exp2s (slow_log_1 - bitrate_1 + 0x100); + else + w->c [1].error_limit = 0; + } + else { + w->c [0].error_limit = exp2s (bitrate_0); + w->c [1].error_limit = exp2s (bitrate_1); + } + } +} + +static uint32_t read_code (Bitstream *bs, uint32_t maxcode); + +// Read the next word from the bitstream "wvbits" and return the value. This +// function can be used for hybrid or lossless streams, but since an +// optimized version is available for lossless this function would normally +// be used for hybrid only. If a hybrid lossless stream is being read then +// the "correction" offset is written at the specified pointer. A return value +// of WORD_EOF indicates that the end of the bitstream was reached (all 1s) or +// some other error occurred. + +int32_t get_words (int32_t *buffer, int nsamples, uint32_t flags, + struct words_data *w, Bitstream *bs) +{ + register struct entropy_data *c = w->c; + int csamples; + + if (!(flags & MONO_DATA)) + nsamples *= 2; + + for (csamples = 0; csamples < nsamples; ++csamples) { + uint32_t ones_count, low, mid, high; + + if (!(flags & MONO_DATA)) + c = w->c + (csamples & 1); + + if (!(w->c [0].median [0] & ~1) && !w->holding_zero && !w->holding_one && !(w->c [1].median [0] & ~1)) { + uint32_t mask; + int cbits; + + if (w->zeros_acc) { + if (--w->zeros_acc) { + c->slow_level -= (c->slow_level + SLO) >> SLS; + *buffer++ = 0; + continue; + } + } + else { + for (cbits = 0; cbits < 33 && getbit (bs); ++cbits); + + if (cbits == 33) + break; + + if (cbits < 2) + w->zeros_acc = cbits; + else { + for (mask = 1, w->zeros_acc = 0; --cbits; mask <<= 1) + if (getbit (bs)) + w->zeros_acc |= mask; + + w->zeros_acc |= mask; + } + + if (w->zeros_acc) { + c->slow_level -= (c->slow_level + SLO) >> SLS; + CLEAR (w->c [0].median); + CLEAR (w->c [1].median); + *buffer++ = 0; + continue; + } + } + } + + if (w->holding_zero) + ones_count = w->holding_zero = 0; + else { + int next8; + + if (bs->bc < 8) { + if (++(bs->ptr) == bs->end) + bs->wrap (bs); + + next8 = (bs->sr |= *(bs->ptr) << bs->bc) & 0xff; + bs->bc += 8; + } + else + next8 = bs->sr & 0xff; + + if (next8 == 0xff) { + bs->bc -= 8; + bs->sr >>= 8; + + for (ones_count = 8; ones_count < (LIMIT_ONES + 1) && getbit (bs); ++ones_count); + + if (ones_count == (LIMIT_ONES + 1)) + break; + + if (ones_count == LIMIT_ONES) { + uint32_t mask; + int cbits; + + for (cbits = 0; cbits < 33 && getbit (bs); ++cbits); + + if (cbits == 33) + break; + + if (cbits < 2) + ones_count = cbits; + else { + for (mask = 1, ones_count = 0; --cbits; mask <<= 1) + if (getbit (bs)) + ones_count |= mask; + + ones_count |= mask; + } + + ones_count += LIMIT_ONES; + } + } + else { + bs->bc -= (ones_count = ones_count_table [next8]) + 1; + bs->sr >>= ones_count + 1; + } + + if (w->holding_one) { + w->holding_one = ones_count & 1; + ones_count = (ones_count >> 1) + 1; + } + else { + w->holding_one = ones_count & 1; + ones_count >>= 1; + } + + w->holding_zero = ~w->holding_one & 1; + } + + if ((flags & HYBRID_FLAG) && ((flags & MONO_DATA) || !(csamples & 1))) + update_error_limit (w, flags); + + if (ones_count == 0) { + low = 0; + high = GET_MED (0) - 1; + DEC_MED0 (); + } + else { + low = GET_MED (0); + INC_MED0 (); + + if (ones_count == 1) { + high = low + GET_MED (1) - 1; + DEC_MED1 (); + } + else { + low += GET_MED (1); + INC_MED1 (); + + if (ones_count == 2) { + high = low + GET_MED (2) - 1; + DEC_MED2 (); + } + else { + low += (ones_count - 2) * GET_MED (2); + high = low + GET_MED (2) - 1; + INC_MED2 (); + } + } + } + + mid = (high + low + 1) >> 1; + + if (!c->error_limit) + mid = read_code (bs, high - low) + low; + else while (high - low > c->error_limit) { + if (getbit (bs)) + mid = (high + (low = mid) + 1) >> 1; + else + mid = ((high = mid - 1) + low + 1) >> 1; + } + + *buffer++ = getbit (bs) ? ~mid : mid; + + if (flags & HYBRID_BITRATE) + c->slow_level = c->slow_level - ((c->slow_level + SLO) >> SLS) + mylog2 (mid); + } + + return (flags & MONO_DATA) ? csamples : (csamples / 2); +} + +// Read a single unsigned value from the specified bitstream with a value +// from 0 to maxcode. If there are exactly a power of two number of possible +// codes then this will read a fixed number of bits; otherwise it reads the +// minimum number of bits and then determines whether another bit is needed +// to define the code. + +static uint32_t read_code (Bitstream *bs, uint32_t maxcode) +{ + int bitcount = count_bits (maxcode); + uint32_t extras = (1L << bitcount) - maxcode - 1, code; + + if (!bitcount) + return 0; + + getbits (&code, bitcount - 1, bs); + code &= (1L << (bitcount - 1)) - 1; + + if (code >= extras) { + code = (code << 1) - extras; + + if (getbit (bs)) + ++code; + } + + return code; +} + +void send_words (int32_t *buffer, int nsamples, uint32_t flags, + struct words_data *w, Bitstream *bs) +{ + register struct entropy_data *c = w->c; + + if (!(flags & MONO_FLAG)) + nsamples *= 2; + + while (nsamples--) { + int32_t value = *buffer++; + int sign = (value < 0) ? 1 : 0; + uint32_t ones_count, low, high; + + if (!(flags & MONO_FLAG)) + c = w->c + (~nsamples & 1); + + if (!(w->c [0].median [0] & ~1) && !w->holding_zero && !(w->c [1].median [0] & ~1)) { + if (w->zeros_acc) { + if (value) + flush_word (w, bs); + else { + w->zeros_acc++; + continue; + } + } + else if (value) { + putbit_0 (bs); + } + else { + CLEAR (w->c [0].median); + CLEAR (w->c [1].median); + w->zeros_acc = 1; + continue; + } + } + + if (sign) + value = ~value; + + if ((uint32_t) value < GET_MED (0)) { + ones_count = low = 0; + high = GET_MED (0) - 1; + DEC_MED0 (); + } + else { + low = GET_MED (0); + INC_MED0 (); + + if (value - low < GET_MED (1)) { + ones_count = 1; + high = low + GET_MED (1) - 1; + DEC_MED1 (); + } + else { + low += GET_MED (1); + INC_MED1 (); + + if (value - low < GET_MED (2)) { + ones_count = 2; + high = low + GET_MED (2) - 1; + DEC_MED2 (); + } + else { + ones_count = 2 + (value - low) / GET_MED (2); + low += (ones_count - 2) * GET_MED (2); + high = low + GET_MED (2) - 1; + INC_MED2 (); + } + } + } + + if (w->holding_zero) { + if (ones_count) + w->holding_one++; + + flush_word (w, bs); + + if (ones_count) { + w->holding_zero = 1; + ones_count--; + } + else + w->holding_zero = 0; + } + else + w->holding_zero = 1; + + w->holding_one = ones_count * 2; + + if (high != low) { + uint32_t maxcode = high - low, code = value - low; + int bitcount = count_bits (maxcode); + uint32_t extras = (1L << bitcount) - maxcode - 1; + + if (code < extras) { + w->pend_data |= code << w->pend_count; + w->pend_count += bitcount - 1; + } + else { + w->pend_data |= ((code + extras) >> 1) << w->pend_count; + w->pend_count += bitcount - 1; + w->pend_data |= ((code + extras) & 1) << w->pend_count++; + } + } + + w->pend_data |= ((int32_t) sign << w->pend_count++); + + if (!w->holding_zero) + flush_word (w, bs); + } +} + +// Used by send_word() and send_word_lossless() to actually send most the +// accumulated data onto the bitstream. This is also called directly from +// clients when all words have been sent. + +void flush_word (struct words_data *w, Bitstream *bs) +{ + int cbits; + + if (w->zeros_acc) { + cbits = count_bits (w->zeros_acc); + + while (cbits--) { + putbit_1 (bs); + } + + putbit_0 (bs); + + while (w->zeros_acc > 1) { + putbit (w->zeros_acc & 1, bs); + w->zeros_acc >>= 1; + } + + w->zeros_acc = 0; + } + + if (w->holding_one) { + if (w->holding_one >= LIMIT_ONES) { + putbits ((1L << LIMIT_ONES) - 1, LIMIT_ONES + 1, bs); + w->holding_one -= LIMIT_ONES; + cbits = count_bits (w->holding_one); + + while (cbits--) { + putbit_1 (bs); + } + + putbit_0 (bs); + + while (w->holding_one > 1) { + putbit (w->holding_one & 1, bs); + w->holding_one >>= 1; + } + + w->holding_zero = 0; + } + else + putbits ((1L << w->holding_one) - 1, w->holding_one, bs); + + w->holding_one = 0; + } + + if (w->holding_zero) { + putbit_0 (bs); + w->holding_zero = 0; + } + + if (w->pend_count) { + + while (w->pend_count > 24) { + putbit (w->pend_data & 1, bs); + w->pend_data >>= 1; + w->pend_count--; + } + + putbits (w->pend_data, w->pend_count, bs); + w->pend_data = w->pend_count = 0; + } +} + +// The concept of a base 2 logarithm is used in many parts of WavPack. It is +// a way of sufficiently accurately representing 32-bit signed and unsigned +// values storing only 16 bits (actually fewer). It is also used in the hybrid +// mode for quickly comparing the relative magnitude of large values (i.e. +// division) and providing smooth exponentials using only addition. + +// These are not strict logarithms in that they become linear around zero and +// can therefore represent both zero and negative values. They have 8 bits +// of precision and in "roundtrip" conversions the total error never exceeds 1 +// part in 225 except for the cases of +/-115 and +/-195 (which error by 1). + + +// This function returns the log2 for the specified 32-bit unsigned value. +// The maximum value allowed is about 0xff800000 and returns 8447. + +static int mylog2 (uint32_t avalue) +{ + int dbits; + + if ((avalue += avalue >> 9) < (1 << 8)) { + dbits = nbits_table [avalue]; + return (dbits << 8) + log2_table [(avalue << (9 - dbits)) & 0xff]; + } + else { + if (avalue < (1L << 16)) + dbits = nbits_table [avalue >> 8] + 8; + else if (avalue < (1L << 24)) + dbits = nbits_table [avalue >> 16] + 16; + else + dbits = nbits_table [avalue >> 24] + 24; + + return (dbits << 8) + log2_table [(avalue >> (dbits - 9)) & 0xff]; + } +} + +// This function returns the log2 for the specified 32-bit signed value. +// All input values are valid and the return values are in the range of +// +/- 8192. + +int log2s (int32_t value) +{ + return (value < 0) ? -mylog2 (-value) : mylog2 (value); +} + +// This function returns the original integer represented by the supplied +// logarithm (at least within the provided accuracy). The log is signed, +// but since a full 32-bit value is returned this can be used for unsigned +// conversions as well (i.e. the input range is -8192 to +8447). + +int32_t exp2s (int log) +{ + uint32_t value; + + if (log < 0) + return -exp2s (-log); + + value = exp2_table [log & 0xff] | 0x100; + + if ((log >>= 8) <= 9) + return value >> (9 - log); + else + return value << (log - 9); +} + +// These two functions convert internal weights (which are normally +/-1024) +// to and from an 8-bit signed character version for storage in metadata. The +// weights are clipped here in the case that they are outside that range. + +signed char store_weight (int weight) +{ + if (weight > 1024) + weight = 1024; + else if (weight < -1024) + weight = -1024; + + if (weight > 0) + weight -= (weight + 64) >> 7; + + return (weight + 4) >> 3; +} + +int restore_weight (signed char weight) +{ + int result; + + if ((result = (int) weight << 3) > 0) + result += (result + 64) >> 7; + + return result; +} diff --git a/lib/rbcodec/codecs/libwavpack/wputils.c b/lib/rbcodec/codecs/libwavpack/wputils.c new file mode 100644 index 0000000000..b0ccd3ba83 --- /dev/null +++ b/lib/rbcodec/codecs/libwavpack/wputils.c @@ -0,0 +1,555 @@ +//////////////////////////////////////////////////////////////////////////// +// **** WAVPACK **** // +// Hybrid Lossless Wavefile Compressor // +// Copyright (c) 1998 - 2004 Conifer Software. // +// All Rights Reserved. // +// Distributed under the BSD Software License (see license.txt) // +//////////////////////////////////////////////////////////////////////////// + +// wputils.c + +// This module provides a high-level interface for decoding WavPack 4.0 audio +// streams and files. WavPack data is read with a stream reading callback. No +// direct seeking is provided for, but it is possible to start decoding +// anywhere in a WavPack stream. In this case, WavPack will be able to provide +// the sample-accurate position when it synchs with the data and begins +// decoding. + +#include "wavpack.h" + +#include + +static void strcpy_loc (char *dst, char *src) { while ((*dst++ = *src++) != 0); } + +///////////////////////////// local table storage //////////////////////////// + +const uint32_t sample_rates [] = { 6000, 8000, 9600, 11025, 12000, 16000, 22050, + 24000, 32000, 44100, 48000, 64000, 88200, 96000, 192000 }; + +///////////////////////////// executable code //////////////////////////////// + +static uint32_t read_next_header (read_stream infile, WavpackHeader *wphdr); + +// This function reads data from the specified stream in search of a valid +// WavPack 4.0 audio block. If this fails in 1 megabyte (or an invalid or +// unsupported WavPack block is encountered) then an appropriate message is +// copied to "error" and NULL is returned, otherwise a pointer to a +// WavpackContext structure is returned (which is used to call all other +// functions in this module). This can be initiated at the beginning of a +// WavPack file, or anywhere inside a WavPack file. To determine the exact +// position within the file use WavpackGetSampleIndex(). For demonstration +// purposes this uses a single static copy of the WavpackContext structure, +// so obviously it cannot be used for more than one file at a time. Also, +// this function will not handle "correction" files, plays only the first +// two channels of multi-channel files, and is limited in resolution in some +// large integer or floating point files (but always provides at least 24 bits +// of resolution). + +static WavpackContext wpc IBSS_ATTR; + +WavpackContext *WavpackOpenFileInput (read_stream infile, char *error) +{ + WavpackStream *wps = &wpc.stream; + uint32_t bcount; + + CLEAR (wpc); + wpc.infile = infile; + wpc.total_samples = (uint32_t) -1; + wpc.norm_offset = 0; + wpc.open_flags = 0; + + // open the source file for reading and store the size + + while (!wps->wphdr.block_samples) { + + bcount = read_next_header (wpc.infile, &wps->wphdr); + + if (bcount == (uint32_t) -1) { + strcpy_loc (error, "invalid WavPack file!"); + return NULL; + } + + wps->block_bytes_left = wps->wphdr.ckSize - 24; + + if ((wps->wphdr.flags & UNKNOWN_FLAGS) || wps->wphdr.version < MIN_STREAM_VERS || + wps->wphdr.version > MAX_STREAM_VERS) { + strcpy_loc (error, "invalid WavPack file!"); + return NULL; + } + + if (wps->wphdr.block_samples && wps->wphdr.total_samples != (uint32_t) -1) + wpc.total_samples = wps->wphdr.total_samples; + + if (!unpack_init (&wpc)) { + strcpy_loc (error, wpc.error_message [0] ? wpc.error_message : + "invalid WavPack file!"); + + return NULL; + } + } + + wpc.config.flags &= ~0xff; + wpc.config.flags |= wps->wphdr.flags & 0xff; + wpc.config.bytes_per_sample = (wps->wphdr.flags & BYTES_STORED) + 1; + wpc.config.float_norm_exp = wps->float_norm_exp; + + wpc.config.bits_per_sample = (wpc.config.bytes_per_sample * 8) - + ((wps->wphdr.flags & SHIFT_MASK) >> SHIFT_LSB); + + if (!wpc.config.sample_rate) { + if (!wps || !wps->wphdr.block_samples || (wps->wphdr.flags & SRATE_MASK) == SRATE_MASK) + wpc.config.sample_rate = 44100; + else + wpc.config.sample_rate = sample_rates [(wps->wphdr.flags & SRATE_MASK) >> SRATE_LSB]; + } + + if (!wpc.config.num_channels) { + wpc.config.num_channels = (wps->wphdr.flags & MONO_FLAG) ? 1 : 2; + wpc.config.channel_mask = 0x5 - wpc.config.num_channels; + } + + if (!(wps->wphdr.flags & FINAL_BLOCK)) + wpc.reduced_channels = (wps->wphdr.flags & MONO_FLAG) ? 1 : 2; + + return &wpc; +} + +// This function obtains general information about an open file and returns +// a mask with the following bit values: + +// MODE_LOSSLESS: file is lossless (pure lossless only) +// MODE_HYBRID: file is hybrid mode (lossy part only) +// MODE_FLOAT: audio data is 32-bit ieee floating point +// MODE_HIGH: file was created in "high" mode (information only) +// MODE_FAST: file was created in "fast" mode (information only) + +int WavpackGetMode (WavpackContext *wpc) +{ + int mode = 0; + + if (wpc) { + if (wpc->config.flags & CONFIG_HYBRID_FLAG) + mode |= MODE_HYBRID; + else if (!(wpc->config.flags & CONFIG_LOSSY_MODE)) + mode |= MODE_LOSSLESS; + + if (wpc->lossy_blocks) + mode &= ~MODE_LOSSLESS; + + if (wpc->config.flags & CONFIG_FLOAT_DATA) + mode |= MODE_FLOAT; + + if (wpc->config.flags & CONFIG_HIGH_FLAG) + mode |= MODE_HIGH; + + if (wpc->config.flags & CONFIG_FAST_FLAG) + mode |= MODE_FAST; + } + + return mode; +} + +// Unpack the specified number of samples from the current file position. +// Note that "samples" here refers to "complete" samples, which would be +// 2 int32_t's for stereo files. The audio data is returned right-justified in +// 32-bit int32_t's in the endian mode native to the executing processor. So, +// if the original data was 16-bit, then the values returned would be +// +/-32k. Floating point data can also be returned if the source was +// floating point data (and this is normalized to +/-1.0). The actual number +// of samples unpacked is returned, which should be equal to the number +// requested unless the end of fle is encountered or an error occurs. + +uint32_t WavpackUnpackSamples (WavpackContext *wpc, int32_t *buffer, uint32_t samples) +{ + WavpackStream *wps = &wpc->stream; + uint32_t bcount, samples_unpacked = 0, samples_to_unpack; + int num_channels = wpc->config.num_channels; + + while (samples) { + if (!wps->wphdr.block_samples || !(wps->wphdr.flags & INITIAL_BLOCK) || + wps->sample_index >= wps->wphdr.block_index + wps->wphdr.block_samples) { + bcount = read_next_header (wpc->infile, &wps->wphdr); + + if (bcount == (uint32_t) -1) + break; + + wps->block_bytes_left = wps->wphdr.ckSize - 24; + + if (wps->wphdr.version < MIN_STREAM_VERS || wps->wphdr.version > MAX_STREAM_VERS) { + strcpy_loc (wpc->error_message, "invalid WavPack file!"); + break; + } + + if (!wps->wphdr.block_samples || wps->sample_index == wps->wphdr.block_index) + if (!unpack_init (wpc)) + break; + } + + if (!wps->wphdr.block_samples || !(wps->wphdr.flags & INITIAL_BLOCK) || + wps->sample_index >= wps->wphdr.block_index + wps->wphdr.block_samples) + continue; + + if (wps->sample_index < wps->wphdr.block_index) { + samples_to_unpack = wps->wphdr.block_index - wps->sample_index; + + if (samples_to_unpack > samples) + samples_to_unpack = samples; + + wps->sample_index += samples_to_unpack; + samples_unpacked += samples_to_unpack; + samples -= samples_to_unpack; + + if (wpc->reduced_channels) + samples_to_unpack *= wpc->reduced_channels; + else + samples_to_unpack *= num_channels; + + while (samples_to_unpack--) + *buffer++ = 0; + + continue; + } + + samples_to_unpack = wps->wphdr.block_index + wps->wphdr.block_samples - wps->sample_index; + + if (samples_to_unpack > samples) + samples_to_unpack = samples; + + unpack_samples (wpc, buffer, samples_to_unpack); + + if (wpc->reduced_channels) + buffer += samples_to_unpack * wpc->reduced_channels; + else + buffer += samples_to_unpack * num_channels; + + samples_unpacked += samples_to_unpack; + samples -= samples_to_unpack; + + if (wps->sample_index == wps->wphdr.block_index + wps->wphdr.block_samples) { + if (check_crc_error (wpc)) + wpc->crc_errors++; + } + + if (wps->sample_index == wpc->total_samples) + break; + } + + return samples_unpacked; +} + +// Get total number of samples contained in the WavPack file, or -1 if unknown + +uint32_t WavpackGetNumSamples (WavpackContext *wpc) +{ + return wpc ? wpc->total_samples : (uint32_t) -1; +} + +// Get the current sample index position, or -1 if unknown + +uint32_t WavpackGetSampleIndex (WavpackContext *wpc) +{ + if (wpc) + return wpc->stream.sample_index; + + return (uint32_t) -1; +} + +// Get the number of errors encountered so far + +int WavpackGetNumErrors (WavpackContext *wpc) +{ + return wpc ? wpc->crc_errors : 0; +} + +// return TRUE if any uncorrected lossy blocks were actually written or read + +int WavpackLossyBlocks (WavpackContext *wpc) +{ + return wpc ? wpc->lossy_blocks : 0; +} + +// Returns the sample rate of the specified WavPack file + +uint32_t WavpackGetSampleRate (WavpackContext *wpc) +{ + return wpc ? wpc->config.sample_rate : 44100; +} + +// Returns the number of channels of the specified WavPack file. Note that +// this is the actual number of channels contained in the file, but this +// version can only decode the first two. + +int WavpackGetNumChannels (WavpackContext *wpc) +{ + return wpc ? wpc->config.num_channels : 2; +} + +// Returns the actual number of valid bits per sample contained in the +// original file, which may or may not be a multiple of 8. Floating data +// always has 32 bits, integers may be from 1 to 32 bits each. When this +// value is not a multiple of 8, then the "extra" bits are located in the +// LSBs of the results. That is, values are right justified when unpacked +// into int32_t's, but are left justified in the number of bytes used by the +// original data. + +int WavpackGetBitsPerSample (WavpackContext *wpc) +{ + return wpc ? wpc->config.bits_per_sample : 16; +} + +// Returns the number of bytes used for each sample (1 to 4) in the original +// file. This is required information for the user of this module because the +// audio data is returned in the LOWER bytes of the int32_t buffer and must be +// left-shifted 8, 16, or 24 bits if normalized int32_t's are required. + +int WavpackGetBytesPerSample (WavpackContext *wpc) +{ + return wpc ? wpc->config.bytes_per_sample : 2; +} + +// This function will return the actual number of channels decoded from the +// file (which may or may not be less than the actual number of channels, but +// will always be 1 or 2). Normally, this will be the front left and right +// channels of a multi-channel file. + +int WavpackGetReducedChannels (WavpackContext *wpc) +{ + if (wpc) + return wpc->reduced_channels ? wpc->reduced_channels : wpc->config.num_channels; + else + return 2; +} + +// Read from current file position until a valid 32-byte WavPack 4.0 header is +// found and read into the specified pointer. The number of bytes skipped is +// returned. If no WavPack header is found within 1 meg, then a -1 is returned +// to indicate the error. No additional bytes are read past the header and it +// is returned in the processor's native endian mode. Seeking is not required. + +static uint32_t read_next_header (read_stream infile, WavpackHeader *wphdr) +{ + char buffer [sizeof (*wphdr)], *sp = buffer + sizeof (*wphdr), *ep = sp; + uint32_t bytes_skipped = 0; + int bleft; + + while (1) { + if (sp < ep) { + bleft = ep - sp; + memcpy (buffer, sp, bleft); + } + else + bleft = 0; + + if (infile (buffer + bleft, sizeof (*wphdr) - bleft) != (int32_t) sizeof (*wphdr) - bleft) + return -1; + + sp = buffer; + + if (*sp++ == 'w' && *sp == 'v' && *++sp == 'p' && *++sp == 'k' && + !(*++sp & 1) && sp [2] < 16 && !sp [3] && sp [5] == 4 && + sp [4] >= (MIN_STREAM_VERS & 0xff) && sp [4] <= (MAX_STREAM_VERS & 0xff)) { + memcpy (wphdr, buffer, sizeof (*wphdr)); + little_endian_to_native (wphdr, WavpackHeaderFormat); + return bytes_skipped; + } + + while (sp < ep && *sp != 'w') + sp++; + + if ((bytes_skipped += sp - buffer) > 1024 * 1024) + return -1; + } +} + +// Open context for writing WavPack files. The returned context pointer is used +// in all following calls to the library. A return value of NULL indicates +// that memory could not be allocated for the context. + +WavpackContext *WavpackOpenFileOutput (void) +{ + CLEAR (wpc); + return &wpc; +} + +// Set configuration for writing WavPack files. This must be done before +// sending any actual samples, however it is okay to send wrapper or other +// metadata before calling this. The "config" structure contains the following +// required information: + +// config->bytes_per_sample see WavpackGetBytesPerSample() for info +// config->bits_per_sample see WavpackGetBitsPerSample() for info +// config->num_channels self evident +// config->sample_rate self evident + +// In addition, the following fields and flags may be set: + +// config->flags: +// -------------- +// o CONFIG_HYBRID_FLAG select hybrid mode (must set bitrate) +// o CONFIG_JOINT_STEREO select joint stereo (must set override also) +// o CONFIG_JOINT_OVERRIDE override default joint stereo selection +// o CONFIG_HYBRID_SHAPE select hybrid noise shaping (set override & +// shaping_weight != 0.0) +// o CONFIG_SHAPE_OVERRIDE override default hybrid noise shaping +// (set CONFIG_HYBRID_SHAPE and shaping_weight) +// o CONFIG_FAST_FLAG "fast" compression mode +// o CONFIG_HIGH_FLAG "high" compression mode +// o CONFIG_BITRATE_KBPS hybrid bitrate is kbps, not bits / sample + +// config->bitrate hybrid bitrate in either bits/sample or kbps +// config->shaping_weight hybrid noise shaping coefficient override +// config->float_norm_exp select floating-point data (127 for +/-1.0) + +// If the number of samples to be written is known then it should be passed +// here. If the duration is not known then pass -1. In the case that the size +// is not known (or the writing is terminated early) then it is suggested that +// the application retrieve the first block written and let the library update +// the total samples indication. A function is provided to do this update and +// it should be done to the "correction" file also. If this cannot be done +// (because a pipe is being used, for instance) then a valid WavPack will still +// be created, but when applications want to access that file they will have +// to seek all the way to the end to determine the actual duration. Also, if +// a RIFF header has been included then it should be updated as well or the +// WavPack file will not be directly unpackable to a valid wav file (although +// it will still be usable by itself). A return of FALSE indicates an error. + +int WavpackSetConfiguration (WavpackContext *wpc, WavpackConfig *config, uint32_t total_samples) +{ + WavpackStream *wps = &wpc->stream; + uint32_t flags = (config->bytes_per_sample - 1), shift = 0; + int num_chans = config->num_channels; + int i; + + if ((wpc->config.flags & CONFIG_HYBRID_FLAG) || + wpc->config.float_norm_exp || + num_chans < 1 || num_chans > 2) + return FALSE; + + wpc->total_samples = total_samples; + wpc->config.sample_rate = config->sample_rate; + wpc->config.num_channels = config->num_channels; + wpc->config.bits_per_sample = config->bits_per_sample; + wpc->config.bytes_per_sample = config->bytes_per_sample; + wpc->config.flags = config->flags; + + shift = (config->bytes_per_sample * 8) - config->bits_per_sample; + + for (i = 0; i < 15; ++i) + if (wpc->config.sample_rate == sample_rates [i]) + break; + + flags |= i << SRATE_LSB; + flags |= shift << SHIFT_LSB; + flags |= CROSS_DECORR; + + if (!(config->flags & CONFIG_JOINT_OVERRIDE) || (config->flags & CONFIG_JOINT_STEREO)) + flags |= JOINT_STEREO; + + flags |= INITIAL_BLOCK | FINAL_BLOCK; + + if (num_chans == 1) { + flags &= ~(JOINT_STEREO | CROSS_DECORR | HYBRID_BALANCE); + flags |= MONO_FLAG; + } + + flags &= ~MAG_MASK; + flags += (1 << MAG_LSB) * ((flags & BYTES_STORED) * 8 + 7); + + memcpy (wps->wphdr.ckID, "wvpk", 4); + wps->wphdr.ckSize = sizeof (WavpackHeader) - 8; + wps->wphdr.total_samples = wpc->total_samples; + wps->wphdr.version = CUR_STREAM_VERS; + wps->wphdr.flags = flags; + + pack_init (wpc); + return TRUE; +} + +// Add wrapper (currently RIFF only) to WavPack blocks. This should be called +// before sending any audio samples. If the exact contents of the RIFF header +// are not known because, for example, the file duration is uncertain or +// trailing chunks are possible, simply write a "dummy" header of the correct +// length. When all data has been written it will be possible to read the +// first block written and update the header directly. An example of this can +// be found in the Audition filter. + +void WavpackAddWrapper (WavpackContext *wpc, void *data, uint32_t bcount) +{ + wpc->wrapper_data = data; + wpc->wrapper_bytes = bcount; +} + +// Start a WavPack block to be stored in the specified buffer. This must be +// called before calling WavpackPackSamples(). Note that writing CANNOT wrap +// in the buffer; the entire output block must fit in the buffer. + +int WavpackStartBlock (WavpackContext *wpc, uchar *begin, uchar *end) +{ + wpc->stream.blockbuff = begin; + wpc->stream.blockend = end; + return pack_start_block (wpc); +} + +// Pack the specified samples. Samples must be stored in int32_ts in the native +// endian format of the executing processor. The number of samples specified +// indicates composite samples (sometimes called "frames"). So, the actual +// number of data points would be this "sample_count" times the number of +// channels. The caller must decide how many samples to place in each +// WavPack block (1/2 second is common), but this function may be called as +// many times as desired to build the final block (and performs the actual +// compression during the call). A return of FALSE indicates an error. + +int WavpackPackSamples (WavpackContext *wpc, int32_t *sample_buffer, uint32_t sample_count) +{ + if (!sample_count || pack_samples (wpc, sample_buffer, sample_count)) + return TRUE; + + strcpy_loc (wpc->error_message, "output buffer overflowed!"); + return FALSE; +} + +// Finish the WavPack block being built, returning the total size of the +// block in bytes. Note that the possible conversion of the WavPack header to +// little-endian takes place here. + +uint32_t WavpackFinishBlock (WavpackContext *wpc) +{ + WavpackStream *wps = &wpc->stream; + uint32_t bcount; + + pack_finish_block (wpc); + bcount = ((WavpackHeader *) wps->blockbuff)->ckSize + 8; + native_to_little_endian ((WavpackHeader *) wps->blockbuff, WavpackHeaderFormat); + + return bcount; +} + +// Given the pointer to the first block written (to either a .wv or .wvc file), +// update the block with the actual number of samples written. This should +// be done if WavpackSetConfiguration() was called with an incorrect number +// of samples (or -1). It is the responsibility of the application to read and +// rewrite the block. An example of this can be found in the Audition filter. + +void WavpackUpdateNumSamples (WavpackContext *wpc, void *first_block) +{ + little_endian_to_native (wpc, WavpackHeaderFormat); + ((WavpackHeader *) first_block)->total_samples = WavpackGetSampleIndex (wpc); + native_to_little_endian (wpc, WavpackHeaderFormat); +} + +// Given the pointer to the first block written to a WavPack file, this +// function returns the location of the stored RIFF header that was originally +// written with WavpackAddWrapper(). This would normally be used to update +// the wav header to indicate that a different number of samples was actually +// written or if additional RIFF chunks are written at the end of the file. +// It is the responsibility of the application to read and rewrite the block. +// An example of this can be found in the Audition filter. + +void *WavpackGetWrapperLocation (void *first_block) +{ + if (((uchar *) first_block) [32] == ID_RIFF_HEADER) + return ((uchar *) first_block) + 34; + else + return NULL; +} + diff --git a/lib/rbcodec/codecs/libwma/SOURCES b/lib/rbcodec/codecs/libwma/SOURCES new file mode 100644 index 0000000000..14cf0c8922 --- /dev/null +++ b/lib/rbcodec/codecs/libwma/SOURCES @@ -0,0 +1,3 @@ +wmadeci.c +wmafixed.c +../lib/ffmpeg_bitstream.c diff --git a/lib/rbcodec/codecs/libwma/libwma.make b/lib/rbcodec/codecs/libwma/libwma.make new file mode 100644 index 0000000000..a916a4f90f --- /dev/null +++ b/lib/rbcodec/codecs/libwma/libwma.make @@ -0,0 +1,18 @@ +# __________ __ ___. +# Open \______ \ ____ ____ | | _\_ |__ _______ ___ +# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / +# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < +# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ +# \/ \/ \/ \/ \/ +# $Id$ +# + +# libwma +WMALIB := $(CODECDIR)/libwma.a +WMALIB_SRC := $(call preprocess, $(RBCODECLIB_DIR)/codecs/libwma/SOURCES) +WMALIB_OBJ := $(call c2obj, $(WMALIB_SRC)) +OTHER_SRC += $(WMALIB_SRC) + +$(WMALIB): $(WMALIB_OBJ) + $(SILENT)$(shell rm -f $@) + $(call PRINTS,AR $(@F))$(AR) rcs $@ $^ >/dev/null diff --git a/lib/rbcodec/codecs/libwma/types.h b/lib/rbcodec/codecs/libwma/types.h new file mode 100644 index 0000000000..8a5e2a992e --- /dev/null +++ b/lib/rbcodec/codecs/libwma/types.h @@ -0,0 +1,5 @@ +#include + +#define fixed32 int32_t +#define fixed64 int64_t + diff --git a/lib/rbcodec/codecs/libwma/wmadata.h b/lib/rbcodec/codecs/libwma/wmadata.h new file mode 100644 index 0000000000..07a55df19a --- /dev/null +++ b/lib/rbcodec/codecs/libwma/wmadata.h @@ -0,0 +1,2609 @@ +/* + * WMA compatible decoder + * copyright (c) 2002 The FFmpeg Project + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file wmadata.h + * Various WMA tables. + */ + +static const uint16_t wma_critical_freqs[25] = { + 100, 200, 300, 400, 510, 630, 770, 920, + 1080, 1270, 1480, 1720, 2000, 2320, 2700, 3150, + 3700, 4400, 5300, 6400, 7700, 9500, 12000, 15500, + 24500, +}; + +/* first value is number of bands */ +static const uint8_t exponent_band_22050[3][25] = { + { 10, 4, 8, 4, 8, 8, 12, 20, 24, 24, 16, }, + { 14, 4, 8, 8, 4, 12, 12, 16, 24, 16, 20, 24, 32, 40, 36, }, + { 23, 4, 4, 4, 8, 4, 4, 8, 8, 8, 8, 8, 12, 12, 16, 16, 24, 24, 32, 44, 48, 60, 84, 72, }, +}; + +static const uint8_t exponent_band_32000[3][25] = { + { 11, 4, 4, 8, 4, 4, 12, 16, 24, 20, 28, 4, }, + { 15, 4, 8, 4, 4, 8, 8, 16, 20, 12, 20, 20, 28, 40, 56, 8, }, + { 16, 8, 4, 8, 8, 12, 16, 20, 24, 40, 32, 32, 44, 56, 80, 112, 16, }, +}; + +static const uint8_t exponent_band_44100[3][25] = { + { 12, 4, 4, 4, 4, 4, 8, 8, 8, 12, 16, 20, 36, }, + { 15, 4, 8, 4, 8, 8, 4, 8, 8, 12, 12, 12, 24, 28, 40, 76, }, + { 17, 4, 8, 8, 4, 12, 12, 8, 8, 24, 16, 20, 24, 32, 40, 60, 80, 152, }, +}; + +static const uint16_t hgain_huffcodes[37] = { + 0x00003, 0x002e7, 0x00001, 0x005cd, 0x0005d, 0x005c9, 0x0005e, 0x00003, + 0x00016, 0x0000b, 0x00001, 0x00006, 0x00001, 0x00006, 0x00004, 0x00005, + 0x00004, 0x00007, 0x00003, 0x00007, 0x00004, 0x0000a, 0x0000a, 0x00002, + 0x00003, 0x00000, 0x00005, 0x00002, 0x0005f, 0x00004, 0x00003, 0x00002, + 0x005c8, 0x000b8, 0x005ca, 0x005cb, 0x005cc, +}; + +static const uint8_t hgain_huffbits[37] = { + 10, 12, 10, 13, 9, 13, 9, 8, + 7, 5, 5, 4, 4, 3, 3, 3, + 4, 3, 4, 4, 5, 5, 6, 8, + 7, 10, 8, 10, 9, 8, 9, 9, + 13, 10, 13, 13, 13, +}; + +static const fixed32 lsp_codebook[NB_LSP_COEFS][16] = { +{0x1fcc2,0x1fabd,0x1f8c7,0x1f66d,0x1f34c,0x1eef1,0x1e83e,0x1dca6,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0}, +{0x1f8fc,0x1f5f9,0x1f328,0x1f025,0x1ecd8,0x1e8fc,0x1e46f,0x1df1b,0x1d87c,0x1d047,0x1c6b5,0x1bb8f,0x1add8,0x19c0e,0x18220,0x154ca}, +{0x1e6ae,0x1dd65,0x1d58e,0x1cd3b,0x1c439,0x1ba69,0x1af5e,0x1a32c,0x195c4,0x18498,0x16fd2,0x156ea,0x13de4,0x11f63,0xf7ae,0xbd90}, +{0x1c4fa,0x1ada0,0x19976,0x1891d,0x17986,0x1697f,0x15858,0x145fd,0x1316b,0x11900,0xfcfa,0xdf55,0xbe63,0x9902,0x6e83,0x2e05}, +{0x16f2d,0x15205,0x135f3,0x11b14,0x10170,0xe743,0xcdec,0xb504,0x9ab2,0x7f86,0x6296,0x4565,0x24e2,0x90,0xffffd52f,0xffffa172}, +{0xffbc,0xd786,0xb521,0x943e,0x7876,0x5ea3,0x44ad,0x2bf0,0x1274,0xfffff829,0xfffe9981,0xffffbfab,0xffffa0bb,0xffff7d3f,0xffff59e3,0xffff3269}, +{0x43e1,0x102a,0xffffe94a,0xffffc9fa,0xffffb076,0xffff9a6b,0xffff871c,0xffff7555,0xffff62b4,0xffff4f81,0xffff3bf4,0xffff25f7,0xffff0c0f,0xfffeef53,0xfffecb7e,0xfffe9fb3}, +{0xffff75ea,0xffff4325,0xffff1da2,0xfffefd23,0xfffeddb9,0xfffebb51,0xfffe945f,0xfffe6131,0xfffee5fe,0xfffed5ba,0xfffec442,0xfffeb224,0xfffe9f95,0xfffe880e,0xfffe6c7a,0xfffe54c1}, +{0xffff9d2e,0xffff709e,0xffff5489,0xffff3d5e,0xffff295b,0xffff1761,0xffff06a2,0xfffef68a,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0}, +{0xfffe7045,0xfffe572f,0xfffe45ea,0xfffe38af,0xfffe2d8f,0xfffe2347,0xfffe18df,0xfffe0d42,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0} +}; + +static const uint32_t scale_huffcodes[121] = { + 0x3ffe8, 0x3ffe6, 0x3ffe7, 0x3ffe5, 0x7fff5, 0x7fff1, 0x7ffed, 0x7fff6, + 0x7ffee, 0x7ffef, 0x7fff0, 0x7fffc, 0x7fffd, 0x7ffff, 0x7fffe, 0x7fff7, + 0x7fff8, 0x7fffb, 0x7fff9, 0x3ffe4, 0x7fffa, 0x3ffe3, 0x1ffef, 0x1fff0, + 0x0fff5, 0x1ffee, 0x0fff2, 0x0fff3, 0x0fff4, 0x0fff1, 0x07ff6, 0x07ff7, + 0x03ff9, 0x03ff5, 0x03ff7, 0x03ff3, 0x03ff6, 0x03ff2, 0x01ff7, 0x01ff5, + 0x00ff9, 0x00ff7, 0x00ff6, 0x007f9, 0x00ff4, 0x007f8, 0x003f9, 0x003f7, + 0x003f5, 0x001f8, 0x001f7, 0x000fa, 0x000f8, 0x000f6, 0x00079, 0x0003a, + 0x00038, 0x0001a, 0x0000b, 0x00004, 0x00000, 0x0000a, 0x0000c, 0x0001b, + 0x00039, 0x0003b, 0x00078, 0x0007a, 0x000f7, 0x000f9, 0x001f6, 0x001f9, + 0x003f4, 0x003f6, 0x003f8, 0x007f5, 0x007f4, 0x007f6, 0x007f7, 0x00ff5, + 0x00ff8, 0x01ff4, 0x01ff6, 0x01ff8, 0x03ff8, 0x03ff4, 0x0fff0, 0x07ff4, + 0x0fff6, 0x07ff5, 0x3ffe2, 0x7ffd9, 0x7ffda, 0x7ffdb, 0x7ffdc, 0x7ffdd, + 0x7ffde, 0x7ffd8, 0x7ffd2, 0x7ffd3, 0x7ffd4, 0x7ffd5, 0x7ffd6, 0x7fff2, + 0x7ffdf, 0x7ffe7, 0x7ffe8, 0x7ffe9, 0x7ffea, 0x7ffeb, 0x7ffe6, 0x7ffe0, + 0x7ffe1, 0x7ffe2, 0x7ffe3, 0x7ffe4, 0x7ffe5, 0x7ffd7, 0x7ffec, 0x7fff4, + 0x7fff3, +}; + +static const uint8_t scale_huffbits[121] = { + 18, 18, 18, 18, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 18, 19, 18, 17, 17, + 16, 17, 16, 16, 16, 16, 15, 15, + 14, 14, 14, 14, 14, 14, 13, 13, + 12, 12, 12, 11, 12, 11, 10, 10, + 10, 9, 9, 8, 8, 8, 7, 6, + 6, 5, 4, 3, 1, 4, 4, 5, + 6, 6, 7, 7, 8, 8, 9, 9, + 10, 10, 10, 11, 11, 11, 11, 12, + 12, 13, 13, 13, 14, 14, 16, 15, + 16, 15, 18, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, +}; + +static const uint32_t coef0_huffcodes[666] = { + 0x00258, 0x0003d, 0x00000, 0x00005, 0x00008, 0x00008, 0x0000c, 0x0001b, + 0x0001f, 0x00015, 0x00024, 0x00032, 0x0003a, 0x00026, 0x0002c, 0x0002f, + 0x0004a, 0x0004d, 0x00061, 0x00070, 0x00073, 0x00048, 0x00052, 0x0005a, + 0x0005d, 0x0006e, 0x00099, 0x0009e, 0x000c1, 0x000ce, 0x000e4, 0x000f0, + 0x00093, 0x0009e, 0x000a2, 0x000a1, 0x000b8, 0x000d2, 0x000d3, 0x0012e, + 0x00130, 0x000de, 0x0012d, 0x0019b, 0x001e4, 0x00139, 0x0013a, 0x0013f, + 0x0014f, 0x0016d, 0x001a2, 0x0027c, 0x0027e, 0x00332, 0x0033c, 0x0033f, + 0x0038b, 0x00396, 0x003c5, 0x00270, 0x0027c, 0x0025a, 0x00395, 0x00248, + 0x004bd, 0x004fb, 0x00662, 0x00661, 0x0071b, 0x004e6, 0x004ff, 0x00666, + 0x0071c, 0x0071a, 0x0071f, 0x00794, 0x00536, 0x004e2, 0x0078e, 0x004ee, + 0x00518, 0x00535, 0x004fb, 0x0078d, 0x00530, 0x00680, 0x0068f, 0x005cb, + 0x00965, 0x006a6, 0x00967, 0x0097f, 0x00682, 0x006ae, 0x00cd0, 0x00e28, + 0x00f13, 0x00f1f, 0x009f5, 0x00cd3, 0x00f11, 0x00926, 0x00964, 0x00f32, + 0x00f12, 0x00f30, 0x00966, 0x00d0b, 0x00a68, 0x00b91, 0x009c7, 0x00b73, + 0x012fa, 0x0131d, 0x013f9, 0x01ca0, 0x0199c, 0x01c7a, 0x0198c, 0x01248, + 0x01c74, 0x01c64, 0x0139e, 0x012fd, 0x00a77, 0x012fc, 0x01c7b, 0x012ca, + 0x014cc, 0x014d2, 0x014e3, 0x014dc, 0x012dc, 0x03344, 0x02598, 0x0263c, + 0x0333b, 0x025e6, 0x01a1c, 0x01e3c, 0x014e2, 0x033d4, 0x01a11, 0x03349, + 0x03cce, 0x014e1, 0x01a34, 0x0273e, 0x02627, 0x0273f, 0x038ee, 0x03971, + 0x03c67, 0x03c61, 0x0333d, 0x038c2, 0x0263f, 0x038cd, 0x02638, 0x02e41, + 0x0351f, 0x03348, 0x03c66, 0x03562, 0x02989, 0x027d5, 0x0333c, 0x02e4f, + 0x0343b, 0x02ddf, 0x04bc8, 0x029c0, 0x02e57, 0x04c72, 0x025b7, 0x03547, + 0x03540, 0x029d3, 0x04c45, 0x025bb, 0x06600, 0x04c73, 0x04bce, 0x0357b, + 0x029a6, 0x029d2, 0x0263e, 0x0298a, 0x07183, 0x06602, 0x07958, 0x04b66, + 0x0537d, 0x05375, 0x04fe9, 0x04b67, 0x0799f, 0x04bc9, 0x051fe, 0x06a3b, + 0x05bb6, 0x04fa8, 0x0728f, 0x05376, 0x0492c, 0x0537e, 0x0795a, 0x06a3c, + 0x0e515, 0x07887, 0x0683a, 0x051f9, 0x051fd, 0x0cc6a, 0x06a8a, 0x0cc6d, + 0x05bb3, 0x0683b, 0x051fc, 0x05378, 0x0728e, 0x07886, 0x05bb7, 0x0f2a4, + 0x0795b, 0x0683c, 0x09fc1, 0x0683d, 0x0b752, 0x09678, 0x0a3e8, 0x06ac7, + 0x051f0, 0x0b759, 0x06af3, 0x04b6b, 0x0f2a0, 0x0f2ad, 0x096c3, 0x0e518, + 0x0b75c, 0x0d458, 0x0cc6b, 0x0537c, 0x067aa, 0x04fea, 0x0343a, 0x0cc71, + 0x0967f, 0x09fc4, 0x096c2, 0x0e516, 0x0f2a1, 0x0d45c, 0x0d45d, 0x0d45e, + 0x12fb9, 0x0967e, 0x1982f, 0x09883, 0x096c4, 0x0b753, 0x12fb8, 0x0f2a8, + 0x1ca21, 0x096c5, 0x0e51a, 0x1ca27, 0x12f3c, 0x0d471, 0x0f2aa, 0x0b75b, + 0x12fbb, 0x0f2a9, 0x0f2ac, 0x0d45a, 0x0b74f, 0x096c8, 0x16e91, 0x096ca, + 0x12fbf, 0x0d0a7, 0x13103, 0x0d516, 0x16e99, 0x12cbd, 0x0a3ea, 0x19829, + 0x0b755, 0x29ba7, 0x1ca28, 0x29ba5, 0x16e93, 0x1982c, 0x19828, 0x25994, + 0x0a3eb, 0x1ca29, 0x16e90, 0x1ca25, 0x1982d, 0x1ca26, 0x16e9b, 0x0b756, + 0x0967c, 0x25997, 0x0b75f, 0x198d3, 0x0b757, 0x19a2a, 0x0d45b, 0x0e517, + 0x1ca24, 0x1ca23, 0x1ca22, 0x0b758, 0x16e97, 0x0cd14, 0x13100, 0x00007, + 0x0003b, 0x0006b, 0x00097, 0x00138, 0x00125, 0x00173, 0x00258, 0x00335, + 0x0028e, 0x004c6, 0x00715, 0x00729, 0x004ef, 0x00519, 0x004ed, 0x00532, + 0x0068c, 0x00686, 0x00978, 0x00e5d, 0x00e31, 0x009f4, 0x00b92, 0x012f8, + 0x00d06, 0x00a67, 0x00d44, 0x00a76, 0x00d59, 0x012cd, 0x01c78, 0x01c75, + 0x0199f, 0x0198f, 0x01c67, 0x014c6, 0x01c79, 0x01c76, 0x00b94, 0x00d1b, + 0x01e32, 0x01e31, 0x01ab0, 0x01a05, 0x01aa1, 0x0333a, 0x025e5, 0x02626, + 0x03541, 0x03544, 0x03421, 0x03546, 0x02e55, 0x02e56, 0x0492d, 0x02dde, + 0x0299b, 0x02ddc, 0x0357a, 0x0249c, 0x0668b, 0x1c77f, 0x1ca20, 0x0d45f, + 0x09886, 0x16e9a, 0x0f2a7, 0x0b751, 0x0a3ee, 0x0cf59, 0x0cf57, 0x0b754, + 0x0d0a6, 0x16e98, 0x0b760, 0x06ac6, 0x0a3f0, 0x12fbe, 0x13104, 0x0f2a5, + 0x0a3ef, 0x0d472, 0x12cba, 0x1982e, 0x16e9c, 0x1c77e, 0x198d0, 0x13105, + 0x16e92, 0x0b75d, 0x0d459, 0x0001a, 0x000c0, 0x0016c, 0x003cd, 0x00350, + 0x0067b, 0x0051e, 0x006a9, 0x009f4, 0x00b72, 0x00d09, 0x01249, 0x01e3d, + 0x01ca1, 0x01a1f, 0x01721, 0x01a8a, 0x016e8, 0x03347, 0x01a35, 0x0249d, + 0x0299a, 0x02596, 0x02e4e, 0x0298b, 0x07182, 0x04c46, 0x025ba, 0x02e40, + 0x027d6, 0x04fe8, 0x06607, 0x05310, 0x09884, 0x072e1, 0x06a3d, 0x04b6a, + 0x04c7a, 0x06603, 0x04c7b, 0x03428, 0x06605, 0x09664, 0x09fc0, 0x071de, + 0x06601, 0x05bb2, 0x09885, 0x0a3e2, 0x1c61f, 0x12cbb, 0x0b750, 0x0cf58, + 0x0967d, 0x25995, 0x668ad, 0x0b75a, 0x09fc2, 0x0537f, 0x0b75e, 0x13fae, + 0x12fbc, 0x00031, 0x001c4, 0x004c5, 0x005b8, 0x00cf4, 0x0096f, 0x00d46, + 0x01e57, 0x01a04, 0x02625, 0x03346, 0x028f9, 0x04c47, 0x072e0, 0x04b69, + 0x03420, 0x07957, 0x06639, 0x0799e, 0x07959, 0x07881, 0x04b68, 0x09fc3, + 0x09fd6, 0x0cc70, 0x0a3f1, 0x12cbe, 0x0e30e, 0x0e51b, 0x06af2, 0x12cbc, + 0x1c77d, 0x0f2ab, 0x12fbd, 0x1aa2f, 0x0a3ec, 0x0d473, 0x05377, 0x0a3e9, + 0x1982b, 0x0e300, 0x12f3f, 0x0cf5f, 0x096c0, 0x38c3c, 0x16e94, 0x16e95, + 0x12f3d, 0x29ba4, 0x29ba6, 0x1c77c, 0x6a8ba, 0x3545c, 0x33457, 0x668ac, + 0x6a8bb, 0x16e9d, 0x0e519, 0x25996, 0x12f3e, 0x00036, 0x0033e, 0x006ad, + 0x00d03, 0x012c8, 0x0124a, 0x03c42, 0x03ccd, 0x06606, 0x07880, 0x06852, + 0x06a3a, 0x05bb4, 0x0f2a2, 0x09fc7, 0x12cb9, 0x0cc6c, 0x0a6e8, 0x096c1, + 0x0004a, 0x00355, 0x012f9, 0x014e8, 0x01abe, 0x025b6, 0x0492e, 0x09fc6, + 0x051ff, 0x0cc6f, 0x096cb, 0x0d071, 0x198d1, 0x12cb8, 0x38c3d, 0x13faf, + 0x096c9, 0x0009d, 0x00539, 0x012ce, 0x0341f, 0x029c1, 0x04b33, 0x0a3e3, + 0x0d070, 0x16e96, 0x0b763, 0x000a0, 0x009ce, 0x038cc, 0x0343d, 0x051fa, + 0x09888, 0x12fba, 0x000df, 0x00a75, 0x029a7, 0x09fc5, 0x0e301, 0x0967b, + 0x001e7, 0x012c9, 0x051fb, 0x09889, 0x0f2a6, 0x0016f, 0x01cb9, 0x0cf5a, + 0x12cbf, 0x09679, 0x00272, 0x01a15, 0x0967a, 0x003cb, 0x025f6, 0x0b762, + 0x0028d, 0x03c60, 0x0cf5e, 0x00352, 0x03ccc, 0x0072f, 0x07186, 0x004ec, + 0x05379, 0x0068e, 0x09887, 0x006a7, 0x06af1, 0x00e29, 0x0cf5b, 0x00f31, + 0x0d470, 0x009c6, 0x013fb, 0x13102, 0x019a5, 0x13101, 0x01983, 0x01c65, + 0x0124f, 0x014c7, 0x01726, 0x01abf, 0x03304, 0x02624, 0x03c41, 0x027d7, + 0x02ddd, 0x02e54, 0x0343c, 0x06604, 0x07181, 0x0663a, 0x04fa9, 0x0663b, + 0x05311, 0x0537a, 0x06839, 0x05bb5, 0x0492f, 0x06af0, 0x096c7, 0x0cc6e, + 0x0537b, 0x0cf5c, 0x0cf56, 0x198d2, 0x0cf5d, 0x0a3ed, 0x0f2a3, 0x1982a, + 0x0b761, 0x096c6, +}; + +static const uint8_t coef0_huffbits[666] = { + 11, 6, 2, 3, 4, 5, 5, 5, + 5, 6, 6, 6, 6, 7, 7, 7, + 7, 7, 7, 7, 7, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, + 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 11, 11, 11, 10, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 12, 12, 11, 12, + 12, 12, 12, 11, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 13, 13, 12, + 12, 12, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 14, + 13, 13, 13, 13, 13, 13, 13, 14, + 14, 14, 14, 14, 14, 14, 14, 14, + 14, 14, 14, 13, 14, 14, 14, 14, + 14, 14, 14, 14, 14, 14, 14, 14, + 14, 14, 14, 14, 14, 14, 14, 15, + 15, 14, 14, 15, 15, 15, 14, 15, + 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 14, 15, 15, 15, 15, 16, + 16, 16, 15, 16, 15, 15, 16, 16, + 16, 16, 15, 16, 16, 16, 15, 16, + 16, 15, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 15, 15, 16, 16, + 15, 16, 16, 16, 17, 17, 17, 16, + 16, 17, 16, 16, 16, 16, 17, 16, + 17, 17, 16, 16, 15, 15, 15, 16, + 17, 16, 17, 16, 16, 17, 17, 17, + 17, 17, 17, 16, 17, 17, 17, 16, + 17, 17, 16, 17, 17, 17, 16, 17, + 17, 16, 16, 17, 17, 17, 18, 17, + 17, 17, 17, 17, 18, 18, 17, 17, + 17, 19, 17, 19, 18, 17, 17, 18, + 17, 17, 18, 17, 17, 17, 18, 17, + 17, 18, 17, 17, 17, 17, 17, 16, + 17, 17, 17, 17, 18, 16, 17, 4, + 6, 8, 9, 9, 10, 10, 10, 10, + 11, 11, 11, 11, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 14, 13, 13, 13, 13, + 13, 13, 14, 14, 14, 14, 14, 14, + 15, 15, 15, 15, 15, 15, 16, 15, + 15, 15, 15, 15, 15, 17, 17, 17, + 16, 18, 16, 17, 17, 16, 16, 17, + 17, 18, 17, 16, 17, 17, 17, 16, + 17, 17, 18, 17, 18, 17, 17, 17, + 18, 17, 17, 5, 8, 10, 10, 11, + 11, 12, 12, 12, 13, 13, 14, 13, + 13, 14, 14, 14, 14, 14, 14, 15, + 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 16, 16, 15, 16, 16, + 15, 15, 15, 15, 15, 16, 16, 15, + 15, 16, 16, 17, 17, 18, 17, 16, + 17, 18, 19, 17, 16, 16, 17, 17, + 17, 6, 9, 11, 12, 12, 13, 13, + 13, 14, 14, 14, 15, 15, 15, 16, + 15, 15, 15, 15, 15, 15, 16, 16, + 16, 16, 17, 18, 16, 16, 16, 18, + 17, 16, 17, 18, 17, 17, 16, 17, + 17, 16, 17, 16, 17, 18, 18, 18, + 17, 19, 19, 17, 20, 19, 18, 19, + 20, 18, 16, 18, 17, 7, 10, 12, + 13, 13, 14, 14, 14, 15, 15, 16, + 16, 16, 16, 16, 18, 16, 17, 17, + 8, 11, 13, 14, 14, 15, 16, 16, + 16, 16, 17, 17, 17, 18, 18, 17, + 17, 8, 12, 14, 15, 15, 15, 17, + 17, 18, 17, 9, 12, 14, 15, 16, + 16, 17, 9, 13, 15, 16, 16, 17, + 9, 13, 16, 16, 16, 10, 13, 16, + 18, 17, 10, 14, 17, 10, 14, 17, + 11, 14, 16, 11, 14, 11, 15, 12, + 16, 12, 16, 12, 16, 12, 16, 12, + 17, 13, 13, 17, 13, 17, 13, 13, + 14, 14, 14, 14, 14, 14, 14, 15, + 15, 15, 15, 15, 15, 15, 16, 15, + 16, 16, 16, 16, 16, 16, 17, 16, + 16, 16, 16, 17, 16, 17, 16, 17, + 17, 17, +}; + +static const uint32_t coef1_huffcodes[555] = { + 0x00115, 0x00002, 0x00001, 0x00000, 0x0000d, 0x00007, 0x00013, 0x0001d, + 0x00008, 0x0000c, 0x00023, 0x0002b, 0x0003f, 0x00017, 0x0001b, 0x00043, + 0x00049, 0x00050, 0x00055, 0x00054, 0x00067, 0x00064, 0x0007b, 0x0002d, + 0x00028, 0x0002a, 0x00085, 0x00089, 0x0002b, 0x00035, 0x00090, 0x00091, + 0x00094, 0x00088, 0x000c1, 0x000c6, 0x000f2, 0x000e3, 0x000c5, 0x000e2, + 0x00036, 0x000f0, 0x000a7, 0x000cd, 0x000fb, 0x00059, 0x00116, 0x00103, + 0x00108, 0x0012b, 0x0012d, 0x00188, 0x0012e, 0x0014c, 0x001c3, 0x00187, + 0x001e7, 0x0006f, 0x00094, 0x00069, 0x001e6, 0x001ca, 0x00147, 0x00195, + 0x000a7, 0x00213, 0x00209, 0x00303, 0x00295, 0x00289, 0x0028c, 0x0028d, + 0x00312, 0x00330, 0x0029b, 0x00308, 0x00328, 0x0029a, 0x0025e, 0x003c5, + 0x00384, 0x0039f, 0x00397, 0x00296, 0x0032e, 0x00332, 0x003c6, 0x003e6, + 0x0012d, 0x000d1, 0x00402, 0x000dd, 0x00161, 0x0012b, 0x00127, 0x0045d, + 0x00601, 0x004ab, 0x0045f, 0x00410, 0x004bf, 0x00528, 0x0045c, 0x00424, + 0x00400, 0x00511, 0x00618, 0x0073d, 0x0063a, 0x00614, 0x0073c, 0x007c0, + 0x007cf, 0x00802, 0x00966, 0x00964, 0x00951, 0x008a0, 0x00346, 0x00803, + 0x00a52, 0x0024a, 0x007c1, 0x0063f, 0x00126, 0x00406, 0x00789, 0x008a2, + 0x00960, 0x00967, 0x00c05, 0x00c70, 0x00c79, 0x00a5d, 0x00c26, 0x00c4d, + 0x00372, 0x008a5, 0x00c08, 0x002c5, 0x00f11, 0x00cc4, 0x00f8e, 0x00e16, + 0x00496, 0x00e77, 0x00f9c, 0x00c25, 0x00f1e, 0x00c27, 0x00f1f, 0x00e17, + 0x00ccd, 0x00355, 0x00c09, 0x00c78, 0x00f90, 0x00521, 0x00357, 0x00356, + 0x0068e, 0x00f9d, 0x00c04, 0x00e58, 0x00a20, 0x00a2c, 0x00c4c, 0x0052f, + 0x00f8d, 0x01178, 0x01053, 0x01097, 0x0180f, 0x0180d, 0x012fb, 0x012aa, + 0x0202a, 0x00a40, 0x018ed, 0x01ceb, 0x01455, 0x018e3, 0x012a1, 0x00354, + 0x00353, 0x00f1c, 0x00c7b, 0x00c37, 0x0101d, 0x012cb, 0x01142, 0x0197d, + 0x01095, 0x01e3b, 0x0186b, 0x00588, 0x01c2a, 0x014b8, 0x01e3a, 0x018ec, + 0x01f46, 0x012fa, 0x00a53, 0x01ce8, 0x00a55, 0x01c29, 0x0117b, 0x01052, + 0x012a0, 0x00589, 0x00950, 0x01c2b, 0x00a50, 0x0208b, 0x0180e, 0x02027, + 0x02556, 0x01e20, 0x006e7, 0x01c28, 0x0197a, 0x00684, 0x020a2, 0x01f22, + 0x03018, 0x039cf, 0x03e25, 0x02557, 0x0294c, 0x028a6, 0x00d11, 0x028a9, + 0x02979, 0x00d46, 0x00a56, 0x039ce, 0x030cc, 0x0329a, 0x0149d, 0x0510f, + 0x0451c, 0x02028, 0x03299, 0x01ced, 0x014b9, 0x00f85, 0x00c7a, 0x01800, + 0x00341, 0x012ca, 0x039c8, 0x0329d, 0x00d0d, 0x03e20, 0x05144, 0x00d45, + 0x030d0, 0x0186d, 0x030d5, 0x00d0f, 0x00d40, 0x04114, 0x020a1, 0x0297f, + 0x03e24, 0x032f1, 0x04047, 0x030d4, 0x028a8, 0x00d0e, 0x0451d, 0x04044, + 0x0297e, 0x04042, 0x030d2, 0x030cf, 0x03e21, 0x03e26, 0x028a5, 0x0451a, + 0x00d48, 0x01a16, 0x00d44, 0x04518, 0x0149b, 0x039ca, 0x01498, 0x0403d, + 0x0451b, 0x0149c, 0x032f3, 0x030cb, 0x08073, 0x03e22, 0x0529a, 0x020aa, + 0x039cc, 0x0738a, 0x06530, 0x07389, 0x06193, 0x08071, 0x04043, 0x030ce, + 0x05147, 0x07388, 0x05145, 0x08072, 0x04521, 0x00d47, 0x0297c, 0x030cd, + 0x030ca, 0x0000b, 0x0000c, 0x00083, 0x000e4, 0x00048, 0x00102, 0x001cc, + 0x001f5, 0x00097, 0x0020b, 0x00124, 0x00453, 0x00627, 0x00639, 0x00605, + 0x00517, 0x001b8, 0x00663, 0x00667, 0x007c3, 0x00823, 0x00961, 0x00963, + 0x00e5a, 0x00e59, 0x00a2b, 0x00cbf, 0x00292, 0x00a2d, 0x007d0, 0x00953, + 0x00cc5, 0x00f84, 0x004ab, 0x014a7, 0x0068a, 0x0117a, 0x0052e, 0x01442, + 0x0052c, 0x00c77, 0x00f8f, 0x004aa, 0x01094, 0x01801, 0x012c4, 0x0297b, + 0x00952, 0x01f19, 0x006a5, 0x01149, 0x012c5, 0x01803, 0x022f2, 0x0329b, + 0x04520, 0x0149e, 0x00d13, 0x01f16, 0x01ce9, 0x0101c, 0x006e6, 0x039c9, + 0x06191, 0x07c8e, 0x06192, 0x0ca63, 0x039cd, 0x06190, 0x06884, 0x06885, + 0x07382, 0x00d49, 0x00d41, 0x0450c, 0x0149a, 0x030d1, 0x08077, 0x03e23, + 0x01a15, 0x0e701, 0x0e702, 0x08079, 0x0822a, 0x0a218, 0x07887, 0x0403f, + 0x0520b, 0x0529b, 0x0e700, 0x04519, 0x00007, 0x000e0, 0x000d0, 0x0039b, + 0x003e5, 0x00163, 0x0063e, 0x007c9, 0x00806, 0x00954, 0x01044, 0x01f44, + 0x0197c, 0x01f45, 0x00a51, 0x01f47, 0x00951, 0x0052d, 0x02291, 0x0092f, + 0x00a54, 0x00d12, 0x0297d, 0x00d0c, 0x01499, 0x0329e, 0x032f0, 0x02025, + 0x039c6, 0x00a57, 0x03e46, 0x00d42, 0x0738b, 0x05146, 0x04046, 0x08078, + 0x0510e, 0x07886, 0x02904, 0x04156, 0x04157, 0x06032, 0x030d3, 0x08bce, + 0x04040, 0x0403e, 0x0a414, 0x10457, 0x08075, 0x06887, 0x07c8f, 0x039c7, + 0x07387, 0x08070, 0x08bcf, 0x1482a, 0x10456, 0x1482b, 0x01a17, 0x06886, + 0x0450d, 0x00013, 0x0006b, 0x00615, 0x0080b, 0x0082b, 0x00952, 0x00e5b, + 0x018e2, 0x0186c, 0x01f18, 0x0329f, 0x00d43, 0x03e29, 0x05140, 0x05141, + 0x0ca62, 0x06033, 0x03c42, 0x03e28, 0x0450f, 0x0a21a, 0x07384, 0x0a219, + 0x0e703, 0x0a21b, 0x01a14, 0x07383, 0x045e6, 0x0007a, 0x0012c, 0x00ccc, + 0x0068f, 0x01802, 0x00a52, 0x00953, 0x04045, 0x01a20, 0x0451f, 0x000a4, + 0x00735, 0x01cec, 0x02029, 0x020a3, 0x0451e, 0x00069, 0x00c24, 0x02024, + 0x032f2, 0x05142, 0x00196, 0x00523, 0x000a6, 0x0197b, 0x0030b, 0x0092e, + 0x003e9, 0x03e27, 0x00160, 0x05143, 0x00652, 0x04041, 0x00734, 0x028a7, + 0x0080f, 0x01483, 0x0097c, 0x00340, 0x0068b, 0x00522, 0x01054, 0x01096, + 0x01f17, 0x0202b, 0x01cea, 0x020a0, 0x02978, 0x02026, 0x0297a, 0x039cb, + 0x03e2b, 0x0149f, 0x0329c, 0x07385, 0x08074, 0x0450e, 0x03e2a, 0x05149, + 0x08076, 0x07386, 0x05148, +}; + +static const uint8_t coef1_huffbits[555] = { + 9, 5, 2, 4, 4, 5, 5, 5, + 6, 6, 6, 6, 6, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 8, + 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, + 9, 8, 8, 8, 8, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, + 9, 10, 10, 10, 9, 9, 9, 9, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 11, 11, 11, 11, 11, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 13, 12, 12, 12, 12, 12, 12, 12, + 13, 12, 12, 12, 12, 12, 12, 12, + 12, 13, 12, 12, 12, 13, 13, 13, + 13, 12, 12, 12, 12, 12, 12, 13, + 12, 13, 13, 13, 13, 13, 13, 13, + 14, 14, 13, 13, 13, 13, 13, 13, + 13, 12, 12, 12, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 14, 13, 14, 13, 13, 13, + 13, 13, 14, 13, 14, 14, 13, 14, + 14, 13, 14, 13, 13, 14, 14, 13, + 14, 14, 14, 14, 14, 14, 14, 14, + 14, 15, 14, 14, 14, 14, 15, 15, + 15, 14, 14, 13, 13, 12, 12, 13, + 13, 13, 14, 14, 15, 14, 15, 15, + 14, 13, 14, 15, 15, 15, 14, 14, + 14, 14, 15, 14, 14, 15, 15, 15, + 14, 15, 14, 14, 14, 14, 14, 15, + 15, 16, 15, 15, 15, 14, 15, 15, + 15, 15, 14, 14, 16, 14, 15, 14, + 14, 15, 15, 15, 15, 16, 15, 14, + 15, 15, 15, 16, 15, 15, 14, 14, + 14, 4, 7, 8, 8, 9, 9, 9, + 9, 10, 10, 11, 11, 11, 11, 11, + 11, 12, 11, 11, 11, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 11, 12, + 12, 12, 13, 13, 13, 13, 13, 13, + 13, 12, 12, 13, 13, 13, 13, 14, + 14, 13, 14, 13, 13, 13, 14, 14, + 15, 15, 14, 13, 13, 13, 14, 14, + 15, 15, 15, 16, 14, 15, 17, 17, + 15, 15, 15, 15, 15, 14, 16, 14, + 16, 16, 16, 16, 16, 16, 15, 15, + 17, 15, 16, 15, 6, 8, 10, 10, + 10, 11, 11, 11, 12, 12, 13, 13, + 13, 13, 14, 13, 14, 13, 14, 14, + 14, 14, 14, 15, 15, 14, 14, 14, + 14, 14, 14, 15, 15, 15, 15, 16, + 15, 15, 16, 15, 15, 15, 14, 16, + 15, 15, 18, 17, 16, 17, 15, 14, + 15, 16, 16, 19, 17, 19, 16, 17, + 15, 7, 10, 11, 12, 12, 12, 12, + 13, 13, 13, 14, 15, 14, 15, 15, + 16, 15, 14, 14, 15, 16, 15, 16, + 16, 16, 16, 15, 15, 7, 11, 12, + 13, 13, 14, 14, 15, 15, 15, 8, + 11, 13, 14, 14, 15, 9, 12, 14, + 14, 15, 9, 13, 10, 13, 10, 14, + 10, 14, 11, 15, 11, 15, 11, 14, + 12, 15, 12, 13, 13, 13, 13, 13, + 13, 14, 13, 14, 14, 14, 14, 14, + 14, 15, 14, 15, 16, 15, 14, 15, + 16, 15, 15, +}; + +static const uint32_t coef2_huffcodes[1336] = { + 0x003e6, 0x000f6, 0x00000, 0x00002, 0x00006, 0x0000f, 0x0001b, 0x00028, + 0x00039, 0x0003f, 0x0006b, 0x00076, 0x000b7, 0x000e8, 0x000ef, 0x00169, + 0x001a7, 0x001d4, 0x001dc, 0x002c4, 0x00349, 0x00355, 0x00391, 0x003dc, + 0x00581, 0x005b2, 0x00698, 0x0070c, 0x00755, 0x0073a, 0x00774, 0x007cf, + 0x00b0a, 0x00b66, 0x00d2e, 0x00d5e, 0x00e1b, 0x00eac, 0x00e5a, 0x00f7e, + 0x00fa1, 0x0163e, 0x01a37, 0x01a52, 0x01c39, 0x01ab3, 0x01d5f, 0x01cb6, + 0x01f52, 0x01dd9, 0x02c04, 0x02c2e, 0x02c2d, 0x02c23, 0x03467, 0x034a3, + 0x0351b, 0x03501, 0x03a5d, 0x0351c, 0x03875, 0x03dea, 0x0397b, 0x039db, + 0x03df1, 0x039d8, 0x03bb4, 0x0580a, 0x0584d, 0x05842, 0x05b13, 0x058ea, + 0x0697d, 0x06a06, 0x068cc, 0x06ac7, 0x06a96, 0x072f4, 0x07543, 0x072b4, + 0x07d20, 0x0b003, 0x073b5, 0x07be6, 0x0d180, 0x07bd1, 0x07cb8, 0x07d06, + 0x07d25, 0x0d2f2, 0x0d19a, 0x0d334, 0x0e1dc, 0x0d529, 0x0d584, 0x0e1d2, + 0x0e5e3, 0x0eec4, 0x0e564, 0x0fa49, 0x16001, 0x0eedc, 0x0f7fa, 0x1a32c, + 0x16131, 0x16003, 0x0f9c8, 0x1ef80, 0x1d2a0, 0x1aa4b, 0x0f7ce, 0x1abfe, + 0x1aa50, 0x1a458, 0x1a816, 0x1cae4, 0x1d2fe, 0x1d52e, 0x1aa4c, 0x2c245, + 0x1d2a1, 0x1a35d, 0x1ca1b, 0x1d5d8, 0x1f531, 0x1ca1c, 0x1f389, 0x1f4af, + 0x3a5e7, 0x351fb, 0x2c24b, 0x34bce, 0x2c24d, 0x2c249, 0x2c24a, 0x72dfc, + 0x357ef, 0x35002, 0x3a5e6, 0x39431, 0x5843b, 0x34a77, 0x58431, 0x3a5f3, + 0x3a5dd, 0x3e5e5, 0x356bd, 0x3976e, 0x6a3d2, 0x3500d, 0x694c4, 0x580bd, + 0x3e5e8, 0x74b95, 0x34a6e, 0x3977c, 0x39432, 0x5b0d2, 0x6a3d8, 0x580b8, + 0x5b0cb, 0x5b0d7, 0x72dee, 0x72ded, 0x72dec, 0x74b9c, 0x3977f, 0x72dea, + 0x74b9e, 0x7be7d, 0x580bf, 0x5b0d5, 0x7cba8, 0x74b91, 0x3e5dd, 0xb6171, + 0xd46b3, 0xd46b9, 0x7cba1, 0x74b9f, 0x72de1, 0xe59f5, 0x3e5eb, 0x00004, + 0x00015, 0x00038, 0x00075, 0x000e8, 0x001d3, 0x00347, 0x0039c, 0x00690, + 0x0074a, 0x00b60, 0x00e93, 0x00f74, 0x0163d, 0x01a5a, 0x01d24, 0x01cbe, + 0x01f4b, 0x03468, 0x03562, 0x03947, 0x03e82, 0x05804, 0x05b12, 0x05803, + 0x0696d, 0x06a9e, 0x0697c, 0x06978, 0x06afb, 0x074b2, 0x072f5, 0x073c0, + 0x07541, 0x06944, 0x074b7, 0x070d3, 0x07ba9, 0x0b0b1, 0x0d1af, 0x0e1dd, + 0x0e5e2, 0x0e1a3, 0x0eec3, 0x1612f, 0x0e961, 0x0eeda, 0x0e78e, 0x0fa48, + 0x1612c, 0x0e511, 0x0e565, 0x0e953, 0x1aa4a, 0x0e59d, 0x1d52c, 0x1a811, + 0x1cae7, 0x1abfc, 0x1d52d, 0x1cacf, 0x1cf05, 0x2c254, 0x34a72, 0x1f4ac, + 0x3976b, 0x34a71, 0x2c6d9, 0x2d873, 0x34a6a, 0x357e7, 0x3464c, 0x3e5f5, + 0x58433, 0x1f53a, 0x3500a, 0x357ea, 0x34a73, 0x3942f, 0x357e5, 0x39775, + 0x694cd, 0x39772, 0x7cba5, 0x6a3ef, 0x35483, 0x74b98, 0x5b0c1, 0x39770, + 0x3a5d7, 0x39433, 0x39434, 0x694ce, 0x580be, 0x3e5ff, 0x6a3ec, 0xb616f, + 0xd46b1, 0x6a3d1, 0x72de5, 0x74b6e, 0x72de9, 0x3e700, 0xd46b6, 0x6a3e9, + 0x74b69, 0xe5675, 0xd46b8, 0x7cbaa, 0x3a5d1, 0x0000c, 0x0003c, 0x000eb, + 0x001f1, 0x003a4, 0x006a8, 0x007d5, 0x00d43, 0x00e77, 0x016c5, 0x01cb1, + 0x02c5d, 0x03a55, 0x03a56, 0x03e51, 0x03bb5, 0x05b0a, 0x06a9f, 0x074b8, + 0x07d28, 0x0d187, 0x0d40e, 0x0d52e, 0x0d425, 0x0eae3, 0x0e1d3, 0x1612e, + 0x0e59e, 0x0eec2, 0x0e578, 0x0e51a, 0x0e579, 0x0e515, 0x0e960, 0x0d183, + 0x0d220, 0x0d2cb, 0x0e512, 0x16c3e, 0x16002, 0x16c42, 0x1cae9, 0x3461a, + 0x1d2fa, 0x1a308, 0x1a849, 0x1cf07, 0x1f38f, 0x34b65, 0x2c253, 0x1ef9e, + 0x1cbc3, 0x1cbc1, 0x2c255, 0x1f384, 0x58435, 0x2c5cd, 0x3a5f7, 0x2c252, + 0x3959c, 0x2c6d8, 0x3a5d3, 0x6ad78, 0x6a3f2, 0x7cba9, 0xb6176, 0x72deb, + 0x39764, 0x3e5f6, 0x3a5d8, 0x74a8c, 0x6a3e6, 0x694d1, 0x6ad79, 0x1a4592, + 0xe59fb, 0x7cbb3, 0x5b0cd, 0x00017, 0x000b5, 0x002c3, 0x005b7, 0x00b1c, + 0x00e5c, 0x0163f, 0x01ab2, 0x01efa, 0x0348a, 0x0396e, 0x058da, 0x06963, + 0x06a30, 0x072cd, 0x073cf, 0x07ce7, 0x0d2ca, 0x0d2d8, 0x0e764, 0x0e794, + 0x16008, 0x16167, 0x1617e, 0x1aa49, 0x1a30b, 0x1a813, 0x2c6da, 0x1a580, + 0x1cbc2, 0x0f9ca, 0x1617f, 0x1d2fe, 0x0f7fc, 0x16c40, 0x0e513, 0x0eec5, + 0x0f7c3, 0x1d508, 0x1a81e, 0x1d2fd, 0x39430, 0x35486, 0x3e5fd, 0x2c24c, + 0x2c75a, 0x34a74, 0x3a5f4, 0x3464d, 0x694ca, 0x3a5f1, 0x1d509, 0x1d5c0, + 0x34648, 0x3464e, 0x6a3d5, 0x6a3e8, 0x6a3e7, 0x5b0c3, 0x2c248, 0x1f38a, + 0x3a5f2, 0x6a3e5, 0x00029, 0x00168, 0x0058c, 0x00b67, 0x00f9d, 0x01c3d, + 0x01cbf, 0x02c20, 0x0351d, 0x03df6, 0x06af9, 0x072b5, 0x0b1d7, 0x0b0b2, + 0x0d40a, 0x0d52b, 0x0e952, 0x0e797, 0x163c3, 0x1c3a0, 0x1f386, 0x1ca21, + 0x34655, 0x2c247, 0x1f53b, 0x2c250, 0x2c24f, 0x1f385, 0x1ef5d, 0x1cf15, + 0x1caea, 0x1ab0a, 0x1cf19, 0x1f53d, 0x1d5c2, 0x1d2fb, 0x1ef58, 0x34a78, + 0x357ec, 0x1f533, 0x3a5e1, 0x694d2, 0x58482, 0x3a5ee, 0x2c6dc, 0x357eb, + 0x5b0c4, 0x39778, 0x6a3e1, 0x7cbb4, 0x3a5e1, 0x74b68, 0x3a5ef, 0x3a5d2, + 0x39424, 0x72de2, 0xe59f6, 0xe59f7, 0x3e702, 0x3e5ec, 0x1f38b, 0x0003b, + 0x001f0, 0x00777, 0x00fa8, 0x01cb2, 0x02d84, 0x03a57, 0x03dd6, 0x06917, + 0x06a11, 0x07d07, 0x0eae2, 0x0e796, 0x0f9c9, 0x0f7fb, 0x16166, 0x16160, + 0x1ab1b, 0x1abfa, 0x2d87b, 0x1d2f7, 0x39768, 0x1f38c, 0x34653, 0x34651, + 0x6a3d9, 0x35001, 0x3abbd, 0x38742, 0x39426, 0x34a76, 0x3a5ec, 0x34a75, + 0x35000, 0x35488, 0x1cf10, 0x2c6db, 0x357ed, 0x357e8, 0x357e9, 0x3a5f0, + 0x694c2, 0xb6178, 0x72df5, 0x39425, 0x3942b, 0x74b6d, 0x74b6f, 0xb6177, + 0xb6179, 0x74b6a, 0xb6172, 0x58487, 0x3e5ee, 0x3e5ed, 0x72df2, 0x72df4, + 0x7cbae, 0x6a3ca, 0x70e86, 0x34bcf, 0x6a3c8, 0x00059, 0x00384, 0x00d5b, + 0x01c38, 0x03560, 0x0395b, 0x0584e, 0x06964, 0x073cd, 0x0b1e7, 0x0e798, + 0x0e78d, 0x0fa43, 0x1a848, 0x1a32f, 0x1aa4e, 0x3464a, 0x1f4ab, 0x1f38d, + 0x3a5eb, 0x3a5d4, 0x3548a, 0x6a3c7, 0x5b0d0, 0x6a3c5, 0x7cbb0, 0x694cb, + 0x3a5e5, 0x3e5e2, 0x3942c, 0x2d872, 0x1f4ae, 0x3a5d5, 0x694d3, 0x58481, + 0x35009, 0x39774, 0x58432, 0xb616c, 0x5b0db, 0x3548b, 0xb6174, 0x1d5d95, + 0xb004c, 0x7cbb2, 0x3a5e5, 0x74a8f, 0xe59f9, 0x72df6, 0xe59fd, 0x7cbad, + 0xd427d, 0x72cff, 0x3977a, 0x5b0d9, 0xb616d, 0xb616b, 0x1a4593, 0x7cbaf, + 0x5b0da, 0x00071, 0x003eb, 0x01603, 0x02c6c, 0x03961, 0x068c8, 0x06a31, + 0x072bd, 0x0d2c2, 0x0e51b, 0x0e5e6, 0x1abfb, 0x1d2ff, 0x1cae5, 0x1ef5c, + 0x1ef5e, 0x1cf13, 0x34a6d, 0x3976d, 0xb616a, 0x3e5f2, 0x6a3c4, 0xb6169, + 0x3e5dc, 0x580b9, 0x74b99, 0x75764, 0x58434, 0x3a5d9, 0x6945a, 0x69459, + 0x3548c, 0x3a5e9, 0x69457, 0x72df1, 0x6945e, 0x6a35e, 0x3e701, 0xb6168, + 0x5b0dd, 0x3a5de, 0x6a3c2, 0xd4278, 0x6a3cc, 0x72dfd, 0xb6165, 0x16009a, + 0x7cbb1, 0xd427c, 0xb6162, 0xe765e, 0x1cecbe, 0x7cbb6, 0x69454, 0xb6160, + 0xd427a, 0x1d5d96, 0xb1d6d, 0xe59f4, 0x72de8, 0x3a5db, 0x0007a, 0x006ae, + 0x01c3c, 0x03aba, 0x058e9, 0x072cc, 0x0d2dd, 0x0d22d, 0x0eec1, 0x0eedb, + 0x1d2a2, 0x1ef5b, 0x357e2, 0x3abbf, 0x1d2f9, 0x35004, 0x3a5dc, 0x351fc, + 0x3976c, 0x6a3c6, 0x6a3cb, 0x3e5ea, 0xe59f3, 0x6a3ce, 0x69452, 0xe59f0, + 0x74b90, 0xd4279, 0xd427b, 0x7cbb5, 0x5b0c5, 0x3a5e3, 0x3a5e2, 0x000d0, + 0x00775, 0x01efe, 0x03dd5, 0x0728c, 0x07cb9, 0x0e1a2, 0x0ea85, 0x0eed8, + 0x1a30a, 0x1aa4f, 0x3a5df, 0x35008, 0x3a5e0, 0x3e5f4, 0x3e5f7, 0xb1d6c, + 0x5843e, 0x34a70, 0x72df8, 0x74b6b, 0xd427f, 0x72df0, 0x5b0bf, 0x5b0c0, + 0xd46b0, 0x72def, 0xe59f8, 0x162e64, 0xb1d6f, 0x3a5e0, 0x39427, 0x69166, + 0x6a3e2, 0x6a3e3, 0x74a8d, 0xd427e, 0x1d5d97, 0xd46b4, 0x5b0d8, 0x6a3d3, + 0x000e0, 0x00b63, 0x034cc, 0x06a33, 0x073c9, 0x0e1a0, 0x0f7fd, 0x0f9cc, + 0x1617d, 0x1caeb, 0x1f4a9, 0x3abb3, 0x69450, 0x39420, 0x39777, 0x3e5e0, + 0x6a3d4, 0x6a3ed, 0xb6166, 0xe59f1, 0xb1d6e, 0xe5676, 0x6a3ea, 0xe5674, + 0xb6163, 0xd46b7, 0x7cba6, 0xd46ba, 0x1d5d94, 0xb6164, 0x6a3f1, 0x7cba2, + 0x69451, 0x72dfa, 0xd46bb, 0x72df7, 0x74b94, 0x1cecbf, 0xe59fa, 0x16009b, + 0x6a3e4, 0x000e6, 0x00e94, 0x03876, 0x070ef, 0x0d52a, 0x16015, 0x16014, + 0x1abf9, 0x1cf17, 0x34a79, 0x34650, 0x3e705, 0x6a3d0, 0x58430, 0x74b9d, + 0x7be7e, 0x5b0be, 0x39773, 0x6a3de, 0x000fb, 0x00f7b, 0x03dd7, 0x07bd0, + 0x0e59c, 0x0f9cd, 0x1cf18, 0x1d2ff, 0x34a7a, 0x39429, 0x3500c, 0x72de0, + 0x69456, 0x7be7c, 0xd46b5, 0xd46b2, 0x6a3dd, 0x001a2, 0x0163b, 0x06913, + 0x0b016, 0x0fa42, 0x1a32d, 0x1cf06, 0x34a7c, 0x34a7d, 0xb6161, 0x35481, + 0x3e5fa, 0x7cba0, 0x7be7f, 0x7cba3, 0x7cba7, 0x5b0d3, 0x72de6, 0x6a3dc, + 0x001a9, 0x01ab4, 0x06a34, 0x0d46a, 0x16130, 0x1ef5f, 0x1f532, 0x1f536, + 0x3942e, 0x58436, 0x6a3db, 0x6945b, 0x001c9, 0x01ca0, 0x0728b, 0x0eed9, + 0x1f539, 0x1ca1d, 0x39765, 0x39766, 0x58439, 0x6945d, 0x39767, 0x001d3, + 0x01f2c, 0x07bfc, 0x16161, 0x34652, 0x3a5ed, 0x3548d, 0x58438, 0x6a3da, + 0x002c1, 0x02c5e, 0x0d335, 0x1ab1a, 0x2d874, 0x35006, 0x35484, 0x5b0cc, + 0x74b9a, 0x72df3, 0x6a3d6, 0x002da, 0x034b3, 0x0d5ae, 0x1caee, 0x2d871, + 0x357e3, 0x74b97, 0x72df9, 0x580ba, 0x5b0d4, 0x0034d, 0x0354e, 0x0f750, + 0x1cbc0, 0x3a5e7, 0x3a5e4, 0x00385, 0x03a58, 0x16c41, 0x2c5cf, 0x3e5e1, + 0x74b6c, 0xe5677, 0x6a3df, 0x00390, 0x03e50, 0x163c2, 0x2d876, 0x35482, + 0x5b0d6, 0x5843a, 0x0039f, 0x0585e, 0x1a583, 0x3500f, 0x74b93, 0x39771, + 0x003e4, 0x06912, 0x16c43, 0x357e1, 0x0058a, 0x0696f, 0x1f538, 0x5b0c9, + 0x6a3cf, 0x005b6, 0x06af8, 0x1f534, 0x58483, 0x6a3e0, 0x00695, 0x07d02, + 0x1cae8, 0x58485, 0x006a2, 0x0754a, 0x357ee, 0x3977b, 0x00748, 0x074b2, + 0x34a7b, 0x00729, 0x0b1e0, 0x34649, 0x3e5e3, 0x0073d, 0x0d2c4, 0x3e5e6, + 0x007bb, 0x0b099, 0x39762, 0x5b0ce, 0x6945f, 0x007d1, 0x0d5ab, 0x39779, + 0x007d3, 0x0d52f, 0x39763, 0x6945c, 0x00b1a, 0x0d2c5, 0x35489, 0x00d23, + 0x0eaed, 0x3e5f8, 0x00d32, 0x16016, 0x3e5fb, 0x00d41, 0x0e768, 0x3a5ed, + 0x00e1f, 0x16017, 0x58027, 0x00ead, 0x0fa07, 0x69455, 0x00e54, 0x1612b, + 0x00e55, 0x1a581, 0x00f78, 0x1a32b, 0x580bc, 0x6a3ee, 0x00f79, 0x1abfd, + 0x00f95, 0x1ab18, 0x6a3f0, 0x01637, 0x1aa4d, 0x0162d, 0x1f53c, 0x6a3f3, + 0x01a31, 0x1a810, 0x39769, 0x01a50, 0x1caef, 0x01a36, 0x1a32e, 0x01a67, + 0x1f38e, 0x01a85, 0x1ef59, 0x01aa6, 0x1ef83, 0x01d51, 0x2c012, 0x01d53, + 0x2d879, 0x01d5e, 0x35005, 0x01cba, 0x1cf04, 0x69453, 0x01d2d, 0x351ff, + 0x01f2d, 0x2d86f, 0x01f29, 0x35007, 0x02c22, 0x351fa, 0x02c03, 0x3a5ec, + 0x02c5f, 0x3a5eb, 0x02c58, 0x34a6b, 0x03469, 0x356be, 0x02c59, 0x34a6c, + 0x0346a, 0x3a5ea, 0x034bd, 0x034bf, 0x356bf, 0x0386a, 0x03ab9, 0x5843f, + 0x0386b, 0x3a5f5, 0x03a4b, 0x39421, 0x03aa4, 0x3a5e9, 0x03a5a, 0x03960, + 0x3977e, 0x03de9, 0x03958, 0x03df7, 0x039e1, 0x3e5e4, 0x0395f, 0x69458, + 0x03e91, 0x03df2, 0x39428, 0x058f2, 0x03e80, 0x6a3c3, 0x03e93, 0x694c0, + 0x058b8, 0x5b0ca, 0x0584f, 0x694c1, 0x058f1, 0x068d6, 0x06a10, 0x06ac3, + 0x06a32, 0x070d2, 0x06911, 0x074b1, 0x07494, 0x06ad4, 0x06ad6, 0x072b8, + 0x06afa, 0x074b3, 0x07540, 0x073ce, 0x0b005, 0x074b3, 0x07495, 0x074b9, + 0x0d336, 0x07bff, 0x07763, 0x073c8, 0x07d29, 0x0b622, 0x0d221, 0x0d181, + 0x0b1d1, 0x074b8, 0x0b1d0, 0x0d19b, 0x0d2c3, 0x0b172, 0x0d2dc, 0x0b623, + 0x0d5aa, 0x0d426, 0x0d182, 0x0e795, 0x0e1d1, 0x0d337, 0x0e96c, 0x0e5e4, + 0x0e514, 0x0eaee, 0x16000, 0x0e767, 0x0e1a1, 0x0e78f, 0x16004, 0x0f7c2, + 0x0e799, 0x0e5e7, 0x0e566, 0x0e769, 0x0f751, 0x0eede, 0x0fa06, 0x16005, + 0x0fa9f, 0x1a5e6, 0x0e766, 0x1636f, 0x0eedd, 0x0eec0, 0x1a309, 0x1ceca, + 0x163cd, 0x0f9cb, 0x0eedf, 0x1a582, 0x1612d, 0x0e5e5, 0x1abf8, 0x1a30c, + 0x1ca1f, 0x163cc, 0x1a35c, 0x1ca1e, 0x1aa51, 0x163ac, 0x1a84e, 0x1a53f, + 0x1cf16, 0x1d2fc, 0x1a5b3, 0x1ab19, 0x1a81f, 0x1d5c3, 0x16c3f, 0x1d5c1, + 0x1d2fc, 0x1f4aa, 0x1a812, 0x1f535, 0x1cf12, 0x1a817, 0x1617c, 0x1ab0b, + 0x1d2f8, 0x1ef82, 0x2d87a, 0x1d52f, 0x1f530, 0x1aa48, 0x35487, 0x1d2fd, + 0x1f4ad, 0x1cf11, 0x3461b, 0x35485, 0x1ca20, 0x1caed, 0x1cae6, 0x1abff, + 0x3464f, 0x34a6f, 0x1ef81, 0x3464b, 0x39d96, 0x1f383, 0x1f537, 0x1cf14, + 0x2c5ce, 0x3500e, 0x2c251, 0x1caec, 0x1f387, 0x34654, 0x357e4, 0x2d878, + 0x3500b, 0x35480, 0x3a5e8, 0x3548e, 0x34b64, 0x1f4a8, 0x35003, 0x3e5df, + 0x2d870, 0x357e6, 0x3e5f0, 0x1ef5a, 0x3a5ea, 0x1f388, 0x3e703, 0x2c24e, + 0x3a5e2, 0x351fd, 0x2c6dd, 0x3e704, 0x351fe, 0x2d875, 0x5b0c7, 0x3976a, + 0x3a5e6, 0x39423, 0x58480, 0x2c246, 0x3a5e3, 0x2d877, 0x3e5f1, 0x3abbe, + 0x58489, 0x3e5f9, 0x357e0, 0x3abbc, 0x5b0c6, 0x69167, 0x69165, 0x3e5e9, + 0x39422, 0x3976f, 0x3977d, 0x3e5de, 0x6a3c9, 0x58b98, 0x3a5f6, 0x3a5d0, + 0x58486, 0x6a3c1, 0x3e5fc, 0x5b0dc, 0x3548f, 0x3942d, 0x694c9, 0x58484, + 0x3a5e8, 0x74b9b, 0x74b96, 0x694d0, 0x58488, 0x3a5e4, 0x3942a, 0x72ec2, + 0x39776, 0x5b0d1, 0x5b0cf, 0x3a5d6, 0xe59fc, 0x5b0c8, 0x3e5e7, 0x7cbb7, + 0x70e87, 0x7cbab, 0x5b0c2, 0x694c3, 0x74a8e, 0x3e5f3, 0x6a3cd, 0x72dfe, + 0x73b2e, 0x72ec0, 0x694c5, 0x58437, 0x694c8, 0x72dff, 0x39435, 0x5843d, + 0x6a3d7, 0x72ec1, 0xd22c8, 0x694cf, 0xb6173, 0x3e5fe, 0x580bb, 0xe59f2, + 0xb616e, 0xb6175, 0x3a5da, 0x5b0bd, 0x694cc, 0x5843c, 0x694c7, 0x74b92, + 0x72ec3, 0x694c6, 0xb6170, 0x7cbac, 0xb1733, 0x7cba4, 0xb6167, 0x72de7, + 0x72de4, 0x6a3c0, 0x3e5ef, 0x162e65, 0x72de3, 0x72dfb, 0x6a35f, 0x6a3eb, +}; + +static const uint8_t coef2_huffbits[1336] = { + 11, 9, 2, 3, 4, 4, 5, 6, + 6, 7, 7, 8, 8, 8, 9, 9, + 9, 9, 10, 10, 10, 10, 11, 11, + 11, 11, 11, 11, 11, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 14, + 14, 14, 14, 14, 14, 14, 14, 14, + 14, 14, 14, 14, 14, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 16, 15, 16, + 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, + 17, 17, 17, 17, 17, 17, 17, 17, + 17, 17, 17, 18, 17, 17, 17, 17, + 17, 17, 17, 18, 18, 17, 17, 18, + 17, 17, 18, 17, 18, 18, 18, 18, + 19, 18, 18, 18, 18, 18, 18, 20, + 18, 18, 18, 19, 19, 18, 19, 18, + 19, 19, 18, 19, 19, 18, 19, 19, + 19, 19, 18, 19, 19, 19, 19, 19, + 19, 19, 20, 20, 20, 19, 19, 20, + 19, 20, 19, 19, 20, 19, 19, 20, + 20, 20, 20, 19, 20, 21, 19, 3, + 5, 7, 8, 9, 9, 10, 11, 11, + 12, 12, 12, 13, 13, 13, 13, 14, + 14, 14, 14, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 16, 16, + 15, 15, 15, 15, 16, 16, 16, 16, + 17, 16, 17, 17, 16, 17, 17, 17, + 17, 17, 17, 16, 17, 17, 17, 17, + 18, 17, 17, 18, 18, 18, 18, 18, + 19, 18, 18, 18, 18, 18, 18, 19, + 19, 18, 18, 18, 18, 19, 18, 19, + 19, 19, 20, 19, 18, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 20, + 20, 19, 20, 19, 20, 19, 20, 19, + 19, 21, 20, 20, 19, 4, 7, 8, + 10, 11, 11, 12, 12, 13, 13, 14, + 14, 14, 14, 15, 15, 15, 15, 15, + 16, 16, 16, 16, 16, 16, 16, 17, + 17, 17, 17, 17, 17, 17, 16, 16, + 16, 16, 17, 17, 17, 17, 18, 18, + 18, 17, 17, 18, 18, 18, 18, 18, + 18, 18, 18, 18, 19, 18, 18, 18, + 19, 18, 19, 19, 19, 20, 20, 20, + 19, 19, 19, 19, 19, 19, 19, 21, + 21, 20, 19, 5, 8, 10, 11, 12, + 13, 13, 13, 14, 14, 15, 15, 15, + 15, 16, 16, 16, 16, 16, 17, 17, + 17, 17, 17, 17, 17, 17, 18, 17, + 18, 17, 17, 17, 17, 17, 17, 17, + 17, 17, 17, 17, 19, 18, 19, 18, + 18, 18, 18, 18, 19, 18, 17, 17, + 18, 18, 19, 19, 19, 19, 18, 18, + 18, 19, 6, 9, 11, 12, 13, 13, + 14, 14, 14, 15, 15, 16, 16, 16, + 16, 16, 16, 17, 17, 17, 18, 18, + 18, 18, 18, 18, 18, 18, 18, 18, + 18, 17, 18, 18, 17, 18, 18, 18, + 18, 18, 18, 19, 19, 18, 18, 18, + 19, 19, 19, 20, 19, 19, 18, 19, + 19, 20, 21, 21, 19, 19, 18, 6, + 10, 12, 13, 14, 14, 14, 15, 15, + 15, 16, 16, 17, 17, 17, 17, 17, + 17, 17, 18, 18, 19, 18, 18, 18, + 19, 18, 18, 18, 19, 18, 18, 18, + 18, 18, 18, 18, 18, 18, 18, 18, + 19, 20, 20, 19, 19, 19, 19, 20, + 20, 19, 20, 19, 19, 19, 20, 20, + 20, 19, 19, 18, 19, 7, 10, 12, + 13, 14, 15, 15, 15, 16, 16, 17, + 17, 17, 17, 17, 17, 18, 18, 18, + 18, 19, 18, 19, 19, 19, 20, 19, + 18, 19, 19, 18, 18, 19, 19, 19, + 18, 19, 19, 20, 19, 18, 20, 21, + 20, 20, 19, 19, 21, 20, 21, 20, + 20, 20, 19, 19, 20, 20, 21, 20, + 19, 7, 11, 13, 14, 15, 15, 15, + 16, 16, 17, 17, 17, 17, 18, 18, + 18, 18, 18, 19, 20, 19, 19, 20, + 19, 19, 19, 19, 19, 19, 19, 19, + 18, 18, 19, 20, 19, 19, 19, 20, + 19, 19, 19, 20, 19, 20, 20, 21, + 20, 20, 20, 21, 22, 20, 19, 20, + 20, 21, 20, 21, 20, 19, 8, 11, + 13, 14, 15, 16, 16, 16, 17, 17, + 17, 18, 18, 18, 18, 18, 19, 18, + 19, 19, 19, 19, 21, 19, 19, 21, + 19, 20, 20, 20, 19, 18, 18, 8, + 12, 14, 15, 16, 16, 16, 16, 17, + 17, 17, 19, 18, 18, 19, 19, 20, + 19, 18, 20, 19, 20, 20, 19, 19, + 20, 20, 21, 21, 20, 19, 19, 19, + 19, 19, 19, 20, 21, 20, 19, 19, + 8, 12, 14, 15, 16, 16, 17, 17, + 17, 18, 18, 18, 19, 19, 19, 19, + 19, 19, 20, 21, 20, 21, 19, 21, + 20, 20, 20, 20, 21, 20, 19, 20, + 19, 20, 20, 20, 19, 22, 21, 21, + 19, 9, 12, 14, 15, 16, 17, 17, + 17, 18, 18, 18, 19, 19, 19, 19, + 20, 19, 19, 19, 9, 13, 15, 16, + 17, 17, 18, 18, 18, 19, 18, 20, + 19, 20, 20, 20, 19, 9, 13, 15, + 16, 17, 17, 18, 18, 18, 20, 18, + 19, 20, 20, 20, 20, 19, 20, 19, + 9, 13, 15, 16, 17, 18, 18, 18, + 19, 19, 19, 19, 10, 14, 16, 17, + 18, 18, 19, 19, 19, 19, 19, 10, + 14, 16, 17, 18, 18, 18, 19, 19, + 10, 14, 16, 17, 18, 18, 18, 19, + 19, 20, 19, 10, 14, 16, 18, 18, + 18, 19, 20, 19, 19, 10, 14, 17, + 18, 18, 18, 10, 15, 17, 18, 19, + 19, 21, 19, 11, 15, 17, 18, 18, + 19, 19, 11, 15, 17, 18, 19, 19, + 11, 15, 17, 18, 11, 15, 18, 19, + 19, 11, 15, 18, 19, 19, 11, 16, + 18, 19, 11, 15, 18, 19, 11, 16, + 18, 12, 16, 18, 19, 12, 16, 19, + 12, 16, 19, 19, 19, 12, 16, 19, + 12, 16, 19, 19, 12, 16, 18, 12, + 16, 19, 12, 17, 19, 12, 17, 19, + 12, 17, 19, 12, 17, 19, 13, 17, + 13, 17, 13, 17, 19, 19, 13, 17, + 13, 17, 19, 13, 17, 13, 18, 19, + 13, 17, 19, 13, 18, 13, 17, 13, + 18, 13, 18, 13, 18, 13, 18, 13, + 18, 13, 18, 14, 18, 19, 14, 18, + 14, 18, 14, 18, 14, 18, 14, 19, + 14, 19, 14, 18, 14, 18, 14, 18, + 14, 19, 14, 14, 18, 14, 14, 19, + 14, 18, 14, 19, 14, 19, 14, 15, + 19, 15, 15, 15, 15, 19, 15, 19, + 15, 15, 19, 15, 15, 19, 15, 19, + 15, 19, 15, 19, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 16, + 15, 15, 15, 16, 16, 16, 15, 16, + 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 17, 16, 16, 16, 17, + 17, 16, 17, 17, 16, 17, 17, 17, + 17, 17, 17, 17, 17, 17, 17, 17, + 17, 17, 17, 17, 17, 17, 17, 18, + 17, 17, 17, 17, 17, 17, 17, 17, + 18, 17, 17, 18, 17, 17, 17, 17, + 18, 18, 17, 17, 17, 17, 17, 17, + 17, 18, 17, 18, 18, 17, 17, 17, + 18, 18, 18, 17, 18, 17, 18, 18, + 18, 18, 18, 18, 18, 18, 18, 17, + 18, 18, 18, 18, 19, 18, 18, 18, + 18, 18, 18, 18, 18, 18, 18, 18, + 18, 18, 18, 18, 18, 18, 18, 19, + 18, 18, 19, 18, 18, 18, 19, 18, + 19, 18, 18, 19, 18, 18, 19, 19, + 19, 19, 19, 18, 19, 18, 19, 18, + 19, 19, 18, 18, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 18, 19, + 19, 19, 19, 19, 18, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 20, + 19, 19, 19, 19, 21, 19, 19, 20, + 19, 20, 19, 19, 19, 19, 19, 20, + 20, 20, 19, 19, 19, 20, 19, 19, + 19, 20, 20, 19, 20, 19, 19, 21, + 20, 20, 19, 19, 19, 19, 19, 19, + 20, 19, 20, 20, 20, 20, 20, 20, + 20, 19, 19, 21, 20, 20, 19, 19, +}; + +static const uint32_t coef3_huffcodes[1072] = { + 0x001b2, 0x00069, 0x00000, 0x00004, 0x00006, 0x0000e, 0x00014, 0x00019, + 0x00016, 0x0002b, 0x00030, 0x0003d, 0x0003c, 0x0005a, 0x0005f, 0x0006d, + 0x0007e, 0x0005f, 0x0007f, 0x000b6, 0x000bc, 0x000d8, 0x000f2, 0x000fe, + 0x000bc, 0x000fc, 0x00161, 0x0016e, 0x00174, 0x00176, 0x001a2, 0x001e3, + 0x001f3, 0x00174, 0x0017a, 0x001ea, 0x002a8, 0x002c4, 0x002e6, 0x00314, + 0x00346, 0x00367, 0x003e9, 0x002e5, 0x002ee, 0x003d6, 0x00555, 0x00554, + 0x00557, 0x005c3, 0x005d6, 0x006e0, 0x0062f, 0x006e2, 0x00799, 0x00789, + 0x007fa, 0x005ce, 0x007fe, 0x005ec, 0x007cc, 0x007af, 0x00aa7, 0x00b19, + 0x00b94, 0x00b85, 0x00b9f, 0x00c48, 0x00c45, 0x00dd8, 0x00c4c, 0x00c4b, + 0x00d99, 0x00d1f, 0x00dc2, 0x00f95, 0x00fa2, 0x00bb5, 0x00b9f, 0x00f5d, + 0x00bbf, 0x00f47, 0x0154a, 0x00fd5, 0x00f45, 0x00f7f, 0x0160d, 0x01889, + 0x01757, 0x01722, 0x018b3, 0x0172d, 0x01a39, 0x01a18, 0x01bb3, 0x01b30, + 0x01e63, 0x0173c, 0x01b35, 0x01723, 0x01e80, 0x01fee, 0x01761, 0x01ffc, + 0x01f7f, 0x02c7c, 0x01fa1, 0x0177b, 0x01755, 0x0175a, 0x01fa6, 0x02eab, + 0x0310a, 0x02c69, 0x03669, 0x03127, 0x03103, 0x02e43, 0x03662, 0x03165, + 0x03124, 0x0313b, 0x03111, 0x03668, 0x0343b, 0x03c52, 0x03efc, 0x02e6c, + 0x03fda, 0x03ef8, 0x02e7b, 0x03ee2, 0x03cc5, 0x03d72, 0x058c0, 0x03df8, + 0x02ea9, 0x03e7e, 0x0556d, 0x05c82, 0x03d71, 0x03e7b, 0x03c42, 0x058d7, + 0x03f4e, 0x06200, 0x03d70, 0x05cb2, 0x05c96, 0x05cb0, 0x03f45, 0x05cb1, + 0x02e6d, 0x03110, 0x02f68, 0x05c90, 0x07ca6, 0x07c88, 0x06204, 0x062c8, + 0x078a6, 0x07986, 0x079d5, 0x0b1ad, 0x07989, 0x0b079, 0x05cdd, 0x0aad4, + 0x05de8, 0x07dcd, 0x07987, 0x05d67, 0x05d99, 0x0b91d, 0x07cf1, 0x05d9b, + 0x079d7, 0x0b07b, 0x05c85, 0x05d9a, 0x07dcc, 0x07ebf, 0x07dce, 0x07dfb, + 0x07ec0, 0x07d1a, 0x07a07, 0x05c84, 0x0c471, 0x07cf2, 0x0baef, 0x0b9d2, + 0x05deb, 0x07bd6, 0x0b845, 0x05d98, 0x0b91a, 0x0bae8, 0x0c4e0, 0x0dc31, + 0x0f93d, 0x0bbce, 0x0d1d2, 0x0f7a9, 0x0d9b9, 0x0bbcb, 0x0b900, 0x0aad7, + 0x0babd, 0x0c4e1, 0x0f46f, 0x0c588, 0x0c58b, 0x160e6, 0x0bbcf, 0x0bac3, + 0x0f945, 0x0f7a3, 0x0d1c1, 0x0fb8e, 0x0f7a4, 0x0fb8c, 0x0f40c, 0x0c473, + 0x0fd72, 0x0bbcd, 0x0fffa, 0x0f940, 0x0bbc9, 0x0f7a8, 0x1a1ed, 0x0bbc5, + 0x1f26f, 0x163fd, 0x160c7, 0x1a1f5, 0x0f947, 0x163fc, 0x154b3, 0x0fff6, + 0x163f6, 0x160e9, 0x1a1f0, 0x0bab9, 0x0baba, 0x17086, 0x0b903, 0x0fd75, + 0x0f308, 0x176f3, 0x163ff, 0x0fd7d, 0x1bb78, 0x163fb, 0x188db, 0x1a1f7, + 0x154b2, 0x172fd, 0x163f4, 0x1bb73, 0x172ff, 0x0babc, 0x0f97d, 0x1a1f3, + 0x1bb6d, 0x1ffd5, 0x1a1f4, 0x1f272, 0x17380, 0x17382, 0x1ffe7, 0x0bac8, + 0x0bbc4, 0x188d3, 0x160e0, 0x0fd7b, 0x1725f, 0x172f5, 0x1bb79, 0x1fad9, + 0x1f269, 0x188d0, 0x0bac4, 0x0bac5, 0x31185, 0x188d2, 0x188cc, 0x31187, + 0x3e7fe, 0x188d1, 0x1bb6c, 0x1f268, 0x1fad2, 0x1ffd9, 0x1a1ea, 0x1bb68, + 0x1facb, 0x3fdb2, 0x1e81a, 0x188ce, 0x172fb, 0x1a1ef, 0x1face, 0x1bb70, + 0x0bac1, 0x1bb6b, 0x172f8, 0x1bb66, 0x1ffdf, 0x1bb6a, 0x1ffd7, 0x1f266, + 0x176f8, 0x37653, 0x1fa7e, 0x31182, 0x1fac8, 0x2c7e3, 0x370ee, 0x176ec, + 0x176e9, 0x2e4bc, 0x160c5, 0x3765a, 0x3ce9c, 0x17373, 0x176e8, 0x188d4, + 0x176f1, 0x176ef, 0x37659, 0x1bb7c, 0x1ffde, 0x176f2, 0x3118b, 0x2c7d4, + 0x37651, 0x5ce9f, 0x37650, 0x31191, 0x3f4f6, 0x3f4f5, 0x7a06c, 0x1fac1, + 0x5c97b, 0x2c7e0, 0x79d3a, 0x3e7fd, 0x2c7df, 0x3f4f0, 0x7a06d, 0x376c1, + 0x79d3b, 0x00004, 0x00014, 0x00059, 0x000ab, 0x000b8, 0x00177, 0x001f5, + 0x001f2, 0x00315, 0x003fc, 0x005bd, 0x0062d, 0x006e8, 0x007dd, 0x00b04, + 0x007cd, 0x00b1e, 0x00d1e, 0x00f15, 0x00f3b, 0x00f41, 0x01548, 0x018b0, + 0x0173b, 0x01884, 0x01a1c, 0x01bb4, 0x01f25, 0x017b5, 0x0176d, 0x01ef8, + 0x02e73, 0x03107, 0x03125, 0x03105, 0x02e49, 0x03ce8, 0x03ef9, 0x03e5e, + 0x02e72, 0x03471, 0x03fd9, 0x0623f, 0x078a0, 0x06867, 0x05cb3, 0x06272, + 0x068ec, 0x06e9a, 0x079d4, 0x06e98, 0x0b1aa, 0x06e1a, 0x07985, 0x068ee, + 0x06e9b, 0x05c88, 0x0b1ac, 0x07dfa, 0x05d65, 0x07cf0, 0x07cbf, 0x0c475, + 0x160eb, 0x1bb7e, 0x0f7a6, 0x1fedd, 0x160e3, 0x0fffb, 0x0fb8d, 0x0fff9, + 0x0d1c0, 0x0c58c, 0x1a1e9, 0x0bab8, 0x0f5cf, 0x0fff5, 0x376c5, 0x1a1ec, + 0x160ed, 0x1fede, 0x1fac9, 0x1a1eb, 0x1f224, 0x176ee, 0x0fd79, 0x17080, + 0x17387, 0x1bb7a, 0x1ffe9, 0x176f7, 0x17385, 0x17781, 0x2c7d5, 0x17785, + 0x1ffe3, 0x163f5, 0x1fac2, 0x3e7f9, 0x3118d, 0x3fdb1, 0x1ffe2, 0x1f226, + 0x3118a, 0x2c7d9, 0x31190, 0x3118c, 0x3f4f3, 0x1bb7f, 0x1bb72, 0x31184, + 0xb92f4, 0x3e7fb, 0x6e1d9, 0x1faca, 0x62300, 0x3fdb8, 0x3d037, 0x3e7fc, + 0x62301, 0x3f4f2, 0x1f26a, 0x0000e, 0x00063, 0x000f8, 0x001ee, 0x00377, + 0x003f7, 0x006e3, 0x005cc, 0x00b05, 0x00dd2, 0x00fd4, 0x0172e, 0x0172a, + 0x01e23, 0x01f2d, 0x01763, 0x01769, 0x0176c, 0x02e75, 0x03104, 0x02ec1, + 0x03e58, 0x0583f, 0x03f62, 0x03f44, 0x058c5, 0x0623c, 0x05cf4, 0x07bd7, + 0x05d9d, 0x0aad2, 0x05d66, 0x0b1a9, 0x0b078, 0x07cfe, 0x0b918, 0x0c46f, + 0x0b919, 0x0b847, 0x06e1b, 0x0b84b, 0x0aad8, 0x0fd74, 0x172f4, 0x17081, + 0x0f97c, 0x1f273, 0x0f7a0, 0x0fd7c, 0x172f7, 0x0fd7a, 0x1bb77, 0x172fe, + 0x1f270, 0x0fd73, 0x1bb7b, 0x1a1bc, 0x1bb7d, 0x0bbc3, 0x172f6, 0x0baeb, + 0x0fb8f, 0x3f4f4, 0x3fdb4, 0x376c8, 0x3e7fa, 0x1ffd0, 0x62303, 0xb92f5, + 0x1f261, 0x31189, 0x3fdb5, 0x2c7db, 0x376c9, 0x1fad6, 0x1fad1, 0x00015, + 0x000f0, 0x002e0, 0x0058e, 0x005d7, 0x00c4d, 0x00fa1, 0x00bdb, 0x01756, + 0x01f70, 0x02c19, 0x0313c, 0x0370f, 0x03cc0, 0x02ea8, 0x058c6, 0x058c7, + 0x02eb7, 0x058d0, 0x07d18, 0x0aa58, 0x0b848, 0x05d9e, 0x05d6c, 0x0b84c, + 0x0c589, 0x0b901, 0x163f8, 0x0bac9, 0x0b9c5, 0x0f93c, 0x188d8, 0x0bbc7, + 0x160ec, 0x0fd6f, 0x188d9, 0x160ea, 0x0f7a7, 0x0f944, 0x0baab, 0x0dc3a, + 0x188cf, 0x176fb, 0x2c7d8, 0x2c7d7, 0x1bb75, 0x5ce9e, 0x62302, 0x370ed, + 0x176f4, 0x1ffd1, 0x370ef, 0x3f4f8, 0x376c7, 0x1ffe1, 0x376c6, 0x176ff, + 0x6e1d8, 0x176f6, 0x17087, 0x0f5cd, 0x00035, 0x001a0, 0x0058b, 0x00aac, + 0x00b9a, 0x0175f, 0x01e22, 0x01e8c, 0x01fb2, 0x0310b, 0x058d1, 0x0552e, + 0x05c27, 0x0686e, 0x07ca7, 0x0c474, 0x0dc33, 0x07bf2, 0x05de9, 0x07a35, + 0x0baaa, 0x0b9eb, 0x0fb95, 0x0b9b8, 0x17381, 0x1f262, 0x188cd, 0x17088, + 0x172fa, 0x0f7a2, 0x1fad3, 0x0bac0, 0x3765c, 0x1fedf, 0x1f225, 0x1fad4, + 0x2c7da, 0x5ce9d, 0x3e7f8, 0x1e203, 0x188d7, 0x00054, 0x002c0, 0x007a1, + 0x00f78, 0x01b36, 0x01fa3, 0x0313a, 0x03436, 0x0343a, 0x07d1d, 0x07bd8, + 0x05cdf, 0x0b846, 0x0b189, 0x0d9b8, 0x0fff8, 0x0d9be, 0x0c58a, 0x05dea, + 0x0d1d3, 0x160e4, 0x1f26b, 0x188da, 0x1e202, 0x2c7d2, 0x163fe, 0x31193, + 0x17782, 0x376c2, 0x2c7d1, 0x3fdb0, 0x3765d, 0x2c7d0, 0x1fad0, 0x1e201, + 0x188dd, 0x2c7e2, 0x37657, 0x37655, 0x376c4, 0x376c0, 0x176ea, 0x0006f, + 0x003cf, 0x00dd5, 0x01f23, 0x02c61, 0x02ed0, 0x05d54, 0x0552d, 0x07883, + 0x0b1a8, 0x0b91c, 0x0babf, 0x0b902, 0x0f7aa, 0x0f7a5, 0x1a1e8, 0x1ffd6, + 0x0babe, 0x1a1bf, 0x163f3, 0x1ffd8, 0x1fad7, 0x1f275, 0x1ffdc, 0x0007d, + 0x005bc, 0x01549, 0x02a99, 0x03def, 0x06273, 0x079d6, 0x07d1b, 0x0aad3, + 0x0d0fc, 0x2c7dd, 0x188d6, 0x0bac2, 0x2c7e1, 0x1bb76, 0x1a1bd, 0x31186, + 0x0fd78, 0x1a1be, 0x31183, 0x3fdb6, 0x3f4f1, 0x37652, 0x1fad5, 0x3f4f9, + 0x3e7ff, 0x5ce9c, 0x3765b, 0x31188, 0x17372, 0x000bd, 0x0078b, 0x01f21, + 0x03c43, 0x03ded, 0x0aad6, 0x07ec1, 0x0f942, 0x05c86, 0x17089, 0x0babb, + 0x1ffe8, 0x2c7de, 0x1f26e, 0x1fac4, 0x3f4f7, 0x37656, 0x1fa7d, 0x376c3, + 0x3fdb3, 0x3118f, 0x1fac6, 0x000f8, 0x007ed, 0x01efd, 0x03e7a, 0x05c91, + 0x0aad9, 0x0baec, 0x0dc32, 0x0f46e, 0x1e200, 0x176fa, 0x3765e, 0x3fdb7, + 0x2c7d6, 0x3fdb9, 0x37654, 0x37658, 0x3118e, 0x1ffdb, 0x000f6, 0x00c43, + 0x03106, 0x068ef, 0x0b84d, 0x0b188, 0x0bbcc, 0x1f264, 0x1bb69, 0x17386, + 0x1fac0, 0x00171, 0x00f39, 0x03e41, 0x068ed, 0x0d9bc, 0x0f7a1, 0x1bb67, + 0x1ffdd, 0x176f9, 0x001b9, 0x00f7d, 0x03f63, 0x0d0fd, 0x0b9ea, 0x188dc, + 0x1fac3, 0x1a1f2, 0x31192, 0x1ffe4, 0x001f6, 0x01754, 0x06865, 0x0f309, + 0x160e5, 0x176f5, 0x3765f, 0x1facc, 0x001e9, 0x01a1a, 0x06201, 0x0f105, + 0x176f0, 0x002df, 0x01756, 0x05d6d, 0x163fa, 0x176ed, 0x00342, 0x02e40, + 0x0d0ff, 0x17082, 0x003cd, 0x02a98, 0x0fffc, 0x2c7dc, 0x1fa7f, 0x003fe, + 0x03764, 0x0fffd, 0x176fc, 0x1fac5, 0x002f7, 0x02ed1, 0x0fb97, 0x0058a, + 0x02edc, 0x0bbc8, 0x005d4, 0x0623d, 0x160e8, 0x0062e, 0x05830, 0x163f9, + 0x006eb, 0x06205, 0x1f274, 0x007de, 0x062c9, 0x1f265, 0x005c9, 0x05cde, + 0x1ffd3, 0x005d4, 0x07988, 0x007ce, 0x0b849, 0x00b1b, 0x05c89, 0x1fac7, + 0x00b93, 0x05c83, 0x00b9e, 0x0f14f, 0x00c4a, 0x0b9c7, 0x00dd4, 0x0c470, + 0x1f271, 0x00f38, 0x0fb96, 0x176eb, 0x00fa0, 0x163f7, 0x00bb2, 0x0b91b, + 0x00bbe, 0x0f102, 0x00f44, 0x0f946, 0x1facd, 0x00f79, 0x0d9bd, 0x0154d, + 0x0bbc6, 0x00fd2, 0x160e7, 0x0172b, 0x188cb, 0x0175e, 0x0fd76, 0x0175c, + 0x1bb71, 0x0189f, 0x1a1ee, 0x01f24, 0x1a1f6, 0x01ba7, 0x0bbca, 0x01f7d, + 0x0ffff, 0x01f2e, 0x1bb65, 0x01bb5, 0x172f9, 0x01fef, 0x1f26c, 0x01f3e, + 0x0fd77, 0x01762, 0x1bb6e, 0x01ef9, 0x172fc, 0x01fa0, 0x02ab7, 0x02e4a, + 0x1f267, 0x01fb3, 0x1ffda, 0x02e42, 0x03101, 0x17780, 0x0313d, 0x03475, + 0x17784, 0x03126, 0x1facf, 0x03c51, 0x17783, 0x03e40, 0x1ffe5, 0x03663, + 0x1ffe0, 0x03e8f, 0x1f26d, 0x0343c, 0x03cc1, 0x176fd, 0x03e45, 0x02ec0, + 0x03f61, 0x03dee, 0x03fd8, 0x0583e, 0x02e45, 0x03e59, 0x03d02, 0x05ce8, + 0x05568, 0x176fe, 0x02f69, 0x1fad8, 0x058c1, 0x05c83, 0x1ffe6, 0x06271, + 0x06e1c, 0x062c7, 0x068e1, 0x0552f, 0x06864, 0x06866, 0x06e99, 0x05cbc, + 0x07ca5, 0x078a1, 0x05c82, 0x07dcf, 0x0623b, 0x0623e, 0x068e8, 0x07a36, + 0x05d9c, 0x0b077, 0x07cf3, 0x07a34, 0x07ca4, 0x07d19, 0x079d2, 0x07d1c, + 0x07bd9, 0x0b84a, 0x0fb94, 0x0aad5, 0x0dc30, 0x07bf3, 0x0baee, 0x0b07a, + 0x0c472, 0x0b91e, 0x0d9ba, 0x05d9f, 0x0d0fe, 0x0b9c6, 0x05c87, 0x0f14e, + 0x0baed, 0x0b92e, 0x0f103, 0x0b9c4, 0x0fb91, 0x0d9bb, 0x0b1ab, 0x0c58d, + 0x0fffe, 0x0f93b, 0x0f941, 0x0baea, 0x0b91f, 0x0f5cc, 0x0d9bf, 0x0f943, + 0x0f104, 0x1f260, 0x0fb92, 0x0f93f, 0x0f3a6, 0x0bac7, 0x0f7ab, 0x0bac6, + 0x17383, 0x0fd6d, 0x0bae9, 0x0fd6e, 0x1e74f, 0x188ca, 0x1f227, 0x0fb93, + 0x0fb90, 0x0fff7, 0x17085, 0x17083, 0x160e1, 0x17084, 0x0f93e, 0x160e2, + 0x160c6, 0x1a1f1, 0x1bb6f, 0x17384, 0x0fd70, 0x1f263, 0x188d5, 0x173a6, + 0x0f5ce, 0x163f2, 0x0fd71, 0x1ffd2, 0x160c4, 0x1ffd4, 0x2c7d3, 0x1bb74, +}; + +static const uint8_t coef3_huffbits[1072] = { + 9, 7, 2, 3, 4, 4, 5, 5, + 6, 6, 6, 6, 7, 7, 7, 7, + 7, 8, 8, 8, 8, 8, 8, 8, + 9, 9, 9, 9, 9, 9, 9, 9, + 9, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 12, 11, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 14, 13, 14, 14, 13, 14, 13, + 13, 14, 14, 14, 14, 14, 14, 14, + 14, 14, 14, 14, 14, 14, 14, 14, + 14, 14, 14, 14, 14, 14, 14, 15, + 14, 14, 15, 14, 14, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 14, 15, + 15, 15, 15, 15, 15, 15, 15, 15, + 15, 14, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 16, 15, 16, 16, 16, + 16, 15, 15, 16, 16, 16, 16, 16, + 15, 16, 16, 16, 15, 16, 15, 15, + 16, 15, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, + 16, 17, 16, 17, 16, 17, 17, 16, + 17, 16, 17, 16, 16, 17, 17, 17, + 16, 17, 16, 16, 17, 16, 17, 16, + 17, 17, 16, 16, 17, 17, 17, 17, + 17, 17, 17, 17, 16, 17, 17, 16, + 17, 17, 17, 17, 17, 17, 17, 17, + 16, 18, 17, 17, 17, 17, 17, 17, + 17, 17, 17, 17, 17, 17, 16, 17, + 17, 17, 17, 17, 17, 17, 17, 17, + 17, 17, 17, 17, 17, 17, 17, 18, + 17, 17, 17, 17, 18, 17, 17, 18, + 19, 17, 17, 17, 18, 17, 17, 17, + 18, 18, 18, 17, 17, 17, 18, 17, + 17, 17, 17, 17, 17, 17, 17, 17, + 18, 18, 18, 18, 18, 18, 18, 18, + 18, 18, 17, 18, 18, 18, 18, 17, + 18, 18, 18, 17, 17, 18, 18, 18, + 18, 19, 18, 18, 19, 19, 20, 18, + 19, 18, 19, 19, 18, 19, 20, 18, + 19, 4, 6, 7, 8, 9, 9, 9, + 10, 10, 10, 11, 11, 11, 11, 12, + 12, 12, 12, 12, 12, 13, 13, 13, + 13, 13, 13, 13, 13, 14, 14, 14, + 14, 14, 14, 14, 14, 14, 14, 14, + 14, 14, 14, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 16, 15, 15, 15, + 15, 16, 16, 15, 16, 16, 15, 16, + 17, 17, 17, 17, 17, 16, 16, 16, + 16, 16, 17, 17, 17, 16, 18, 17, + 17, 17, 18, 17, 17, 18, 17, 17, + 17, 17, 17, 18, 17, 18, 18, 18, + 17, 17, 18, 19, 18, 18, 17, 17, + 18, 18, 18, 18, 19, 17, 17, 18, + 20, 19, 19, 18, 19, 18, 19, 19, + 19, 19, 17, 5, 7, 9, 10, 10, + 11, 11, 12, 12, 12, 13, 13, 13, + 13, 13, 14, 14, 14, 14, 14, 15, + 14, 15, 15, 15, 15, 15, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 15, 16, 16, 17, 17, 17, + 16, 17, 17, 17, 17, 17, 17, 17, + 17, 17, 17, 17, 17, 17, 17, 16, + 16, 19, 18, 18, 19, 17, 19, 20, + 17, 18, 18, 18, 18, 18, 18, 6, + 8, 10, 11, 12, 12, 12, 13, 13, + 13, 14, 14, 14, 14, 15, 15, 15, + 15, 15, 15, 16, 16, 16, 16, 16, + 16, 17, 17, 17, 16, 16, 17, 17, + 17, 17, 17, 17, 17, 16, 16, 16, + 17, 18, 18, 18, 17, 19, 19, 18, + 18, 17, 18, 19, 18, 17, 18, 18, + 19, 18, 17, 17, 6, 9, 11, 12, + 13, 13, 13, 14, 14, 14, 15, 15, + 15, 15, 15, 16, 16, 16, 16, 16, + 16, 17, 16, 17, 17, 17, 17, 17, + 17, 17, 18, 17, 18, 17, 17, 18, + 18, 19, 19, 17, 17, 7, 10, 12, + 13, 13, 14, 14, 14, 14, 15, 16, + 16, 16, 16, 16, 16, 16, 16, 16, + 16, 17, 17, 17, 17, 18, 17, 18, + 18, 18, 18, 18, 18, 18, 18, 17, + 17, 18, 18, 18, 18, 18, 18, 7, + 10, 12, 13, 14, 15, 15, 15, 15, + 16, 16, 17, 17, 17, 17, 17, 17, + 17, 17, 17, 17, 18, 17, 17, 8, + 11, 13, 14, 15, 15, 15, 15, 16, + 16, 18, 17, 17, 18, 17, 17, 18, + 17, 17, 18, 18, 19, 18, 18, 19, + 19, 19, 18, 18, 18, 8, 11, 13, + 14, 15, 16, 16, 16, 16, 17, 17, + 17, 18, 17, 18, 19, 18, 18, 18, + 18, 18, 18, 8, 12, 14, 15, 15, + 16, 16, 16, 17, 17, 18, 18, 18, + 18, 18, 18, 18, 18, 17, 9, 12, + 14, 15, 16, 16, 17, 17, 17, 17, + 18, 9, 12, 14, 15, 16, 17, 17, + 17, 18, 9, 13, 15, 16, 17, 17, + 18, 17, 18, 17, 9, 13, 15, 16, + 17, 18, 18, 18, 10, 13, 15, 16, + 18, 10, 14, 16, 17, 18, 10, 14, + 16, 17, 10, 14, 16, 18, 18, 10, + 14, 16, 18, 18, 11, 15, 16, 11, + 15, 17, 11, 15, 17, 11, 15, 17, + 11, 15, 17, 11, 15, 17, 12, 16, + 17, 12, 15, 12, 16, 12, 16, 18, + 12, 16, 12, 16, 12, 16, 12, 16, + 17, 12, 16, 18, 12, 17, 13, 16, + 13, 16, 13, 16, 18, 13, 16, 13, + 17, 13, 17, 13, 17, 13, 17, 13, + 17, 13, 17, 13, 17, 13, 17, 13, + 16, 13, 17, 13, 17, 13, 17, 14, + 17, 14, 17, 14, 17, 14, 14, 14, + 17, 14, 17, 14, 14, 18, 14, 14, + 18, 14, 18, 14, 18, 14, 17, 14, + 17, 14, 17, 14, 14, 18, 14, 15, + 15, 15, 14, 15, 15, 14, 15, 15, + 15, 18, 15, 18, 15, 15, 17, 15, + 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 16, 15, 15, 15, 15, 16, + 16, 16, 16, 16, 15, 15, 15, 15, + 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 17, 16, 16, + 16, 17, 16, 16, 16, 17, 17, 17, + 17, 17, 16, 17, 17, 17, 17, 16, + 16, 16, 17, 17, 17, 17, 16, 17, + 17, 17, 17, 17, 17, 17, 17, 17, + 17, 17, 17, 17, 17, 17, 18, 17, +}; + +static const uint32_t coef4_huffcodes[476] = { + 0x00f01, 0x0001e, 0x00000, 0x00004, 0x00006, 0x0000d, 0x0000a, 0x00017, + 0x0001d, 0x00017, 0x0002c, 0x00031, 0x00039, 0x0003e, 0x00039, 0x0005a, + 0x00066, 0x00070, 0x0007b, 0x00070, 0x00077, 0x000af, 0x000c9, 0x000f2, + 0x000f4, 0x000b2, 0x000e3, 0x0015b, 0x0015d, 0x00181, 0x0019d, 0x001e3, + 0x001c5, 0x002b5, 0x002db, 0x00338, 0x003c3, 0x003cc, 0x003f0, 0x002cd, + 0x003fa, 0x003a1, 0x005b4, 0x00657, 0x007ab, 0x0074d, 0x0074c, 0x00ac1, + 0x00ac5, 0x0076b, 0x00ca8, 0x00f04, 0x00f00, 0x00fe3, 0x00f3c, 0x00f10, + 0x00f39, 0x00fe6, 0x00e26, 0x00e90, 0x016c5, 0x01827, 0x01954, 0x015c5, + 0x01958, 0x01f8a, 0x01c4a, 0x02b0f, 0x02b41, 0x02b0e, 0x033c6, 0x03050, + 0x01c4f, 0x02d88, 0x0305c, 0x03c18, 0x02b4f, 0x02cc2, 0x03a47, 0x05680, + 0x0569d, 0x06442, 0x06443, 0x06446, 0x0656e, 0x06444, 0x07120, 0x0748a, + 0x0c1ba, 0x07e22, 0x07aa6, 0x07f25, 0x07aa7, 0x07e20, 0x0c11b, 0x0c118, + 0x07aa5, 0x0ad0a, 0x0f389, 0x19ebb, 0x0caad, 0x0fe42, 0x0fe40, 0x16c34, + 0x2b4e5, 0x33d65, 0x16c30, 0x1e7ae, 0x1e25c, 0x18370, 0x1e703, 0x19eba, + 0x16c37, 0x0e234, 0x16c6e, 0x00004, 0x0002a, 0x00061, 0x00075, 0x000cb, + 0x000ff, 0x00190, 0x001eb, 0x001d1, 0x002b9, 0x00307, 0x00339, 0x0033f, + 0x003fb, 0x003b4, 0x0060c, 0x00679, 0x00645, 0x0067d, 0x0078a, 0x007e3, + 0x00749, 0x00ac4, 0x00ad2, 0x00ae3, 0x00c10, 0x00c16, 0x00ad1, 0x00cf4, + 0x00fe2, 0x01586, 0x00e9d, 0x019f1, 0x01664, 0x01e26, 0x01d38, 0x02b4d, + 0x033c5, 0x01fc2, 0x01fc3, 0x01d28, 0x03c1d, 0x0598e, 0x0f094, 0x07aa4, + 0x0ad38, 0x0ac0c, 0x0c11a, 0x079ea, 0x0c881, 0x0fe44, 0x0b635, 0x0ac0d, + 0x0b61e, 0x05987, 0x07121, 0x0f382, 0x0f387, 0x0e237, 0x0fe47, 0x0f383, + 0x0f091, 0x0f385, 0x0e233, 0x182ee, 0x19eb8, 0x1663e, 0x0f093, 0x00014, + 0x00058, 0x00159, 0x00167, 0x00300, 0x003d4, 0x005b5, 0x0079d, 0x0076a, + 0x00b67, 0x00b60, 0x00f05, 0x00cf0, 0x00f17, 0x00e95, 0x01822, 0x01913, + 0x016c2, 0x0182f, 0x01959, 0x01fcb, 0x01e27, 0x01c40, 0x033c7, 0x01e7b, + 0x01c49, 0x02d89, 0x01e23, 0x01660, 0x03f12, 0x02cc6, 0x033e1, 0x05b34, + 0x0609a, 0x06569, 0x07488, 0x07e21, 0x0cf5f, 0x0712c, 0x0389d, 0x067cf, + 0x07f28, 0x1663f, 0x33d67, 0x1663d, 0x1e25d, 0x3c1ab, 0x15c44, 0x16c36, + 0x0001f, 0x000ec, 0x00323, 0x005b2, 0x0079f, 0x00ac2, 0x00f16, 0x00e9e, + 0x01956, 0x01e0f, 0x019ea, 0x01666, 0x02b89, 0x02b02, 0x02d8c, 0x03c1b, + 0x03c19, 0x032b5, 0x03f9c, 0x02ccf, 0x03897, 0x05b35, 0x0ad02, 0x07f29, + 0x06441, 0x03884, 0x07888, 0x0784e, 0x06568, 0x0c1bb, 0x05986, 0x067cc, + 0x0fe49, 0x0fe48, 0x0c1bc, 0x0fe41, 0x18371, 0x1663c, 0x0e231, 0x0711e, + 0x0ad09, 0x0f092, 0x0002d, 0x001db, 0x00781, 0x00c1a, 0x00f55, 0x01580, + 0x01ea8, 0x02d9b, 0x032af, 0x03f16, 0x03c1c, 0x07834, 0x03c45, 0x0389c, + 0x067ce, 0x06445, 0x0c1b9, 0x07889, 0x07f3a, 0x0784f, 0x07f2b, 0x0ad0b, + 0x0f090, 0x0c11d, 0x0e94e, 0x0711f, 0x0e9f1, 0x0f38e, 0x079e9, 0x0ad03, + 0x0f09b, 0x0caae, 0x0fe46, 0x2b4e6, 0x0e9f0, 0x19eb6, 0x67ac1, 0x67ac0, + 0x33d66, 0x0f388, 0x00071, 0x003a0, 0x00ca9, 0x01829, 0x01d39, 0x02b43, + 0x02cc4, 0x06554, 0x0f09a, 0x0b61f, 0x067cd, 0x0711c, 0x0b636, 0x07f2a, + 0x0b634, 0x0c11f, 0x0cf5e, 0x0b61d, 0x0f06b, 0x0caab, 0x0c1be, 0x0e94c, + 0x0f099, 0x182ed, 0x0e94f, 0x0c119, 0x0e232, 0x2b4e4, 0x0f38a, 0x19eb4, + 0x1e25f, 0x0e94d, 0x000b7, 0x00785, 0x016cc, 0x03051, 0x033c4, 0x0656f, + 0x03891, 0x0711d, 0x0caaf, 0x0f097, 0x07489, 0x0f098, 0x0c880, 0x0caaa, + 0x0f386, 0x19eb7, 0x16c6f, 0x0f384, 0x182e8, 0x182e9, 0x0e230, 0x1e700, + 0x33d62, 0x33d63, 0x33d64, 0x16c33, 0x0e216, 0x000fd, 0x00c15, 0x01665, + 0x03c4a, 0x07f3b, 0x07896, 0x0c11c, 0x0e215, 0x16c32, 0x0f38b, 0x0f38d, + 0x182ea, 0x1e701, 0x712df, 0x15c46, 0x00194, 0x00fe0, 0x03f13, 0x0748b, + 0x0f096, 0x0cf80, 0x1e25e, 0xe25bd, 0x33d61, 0x16c31, 0x001f9, 0x01912, + 0x05710, 0x0f3d0, 0x0c1bf, 0x00301, 0x01e24, 0x0ad08, 0x003cd, 0x01c41, + 0x0c1bd, 0x00563, 0x03a52, 0x0f3d1, 0x00570, 0x02cce, 0x0e217, 0x0067b, + 0x0655d, 0x0074b, 0x06447, 0x00c12, 0x074fb, 0x00f08, 0x0b61c, 0x00e22, + 0x0fe43, 0x016c7, 0x01836, 0x019f2, 0x01c43, 0x01d3f, 0x01fcf, 0x02b4c, + 0x0304c, 0x032b6, 0x03a46, 0x05607, 0x03f17, 0x02cc5, 0x0609b, 0x0655c, + 0x07e23, 0x067c1, 0x07f26, 0x07f27, 0x0f095, 0x0e9f3, 0x0cf81, 0x0c11e, + 0x0caac, 0x0f38f, 0x0e9f2, 0x074fa, 0x0e236, 0x0fe45, 0x1c428, 0x0e235, + 0x182ef, 0x19eb5, 0x0f3d6, 0x182ec, 0x16c35, 0x0f38c, 0x2b4e7, 0x15c47, + 0xe25bc, 0x1e702, 0x1c4b6, 0x0e25a, 0x3c1aa, 0x15c45, 0x1c429, 0x19eb9, + 0x1e7af, 0x182eb, 0x1e0d4, 0x3896e, +}; + +static const uint8_t coef4_huffbits[476] = { + 12, 6, 2, 3, 4, 4, 5, 5, + 5, 6, 6, 6, 6, 6, 7, 7, + 7, 7, 7, 8, 8, 8, 8, 8, + 8, 9, 9, 9, 9, 9, 9, 9, + 10, 10, 10, 10, 10, 10, 10, 11, + 10, 11, 11, 11, 11, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 13, 13, 13, 13, 13, 13, + 13, 13, 14, 14, 14, 14, 14, 14, + 14, 14, 14, 14, 14, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 16, 16, + 16, 15, 15, 15, 15, 15, 16, 16, + 15, 16, 16, 17, 16, 16, 16, 17, + 18, 18, 17, 17, 17, 17, 17, 17, + 17, 17, 17, 4, 6, 7, 8, 8, + 8, 9, 9, 10, 10, 10, 10, 10, + 10, 11, 11, 11, 11, 11, 11, 11, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 13, 13, 13, 14, 13, 14, 14, + 14, 13, 13, 14, 14, 16, 16, 15, + 16, 16, 16, 15, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 17, 16, 16, + 16, 16, 17, 17, 17, 18, 16, 5, + 8, 9, 10, 10, 10, 11, 11, 12, + 12, 12, 12, 12, 12, 13, 13, 13, + 13, 13, 13, 13, 13, 14, 14, 13, + 14, 14, 13, 14, 14, 15, 14, 15, + 15, 15, 16, 15, 16, 16, 15, 15, + 15, 18, 18, 18, 17, 18, 17, 17, + 6, 9, 10, 11, 11, 12, 12, 13, + 13, 13, 13, 14, 14, 14, 14, 14, + 14, 14, 14, 15, 15, 15, 16, 15, + 15, 15, 15, 15, 15, 16, 16, 15, + 16, 16, 16, 16, 17, 18, 17, 16, + 16, 16, 7, 10, 11, 12, 12, 13, + 13, 14, 14, 14, 14, 15, 14, 15, + 15, 15, 16, 15, 15, 15, 15, 16, + 16, 16, 17, 16, 17, 16, 15, 16, + 16, 16, 16, 18, 17, 17, 19, 19, + 18, 16, 7, 11, 12, 13, 14, 14, + 15, 15, 16, 16, 15, 16, 16, 15, + 16, 16, 16, 16, 16, 16, 16, 17, + 16, 17, 17, 16, 17, 18, 16, 17, + 17, 17, 8, 11, 13, 14, 14, 15, + 15, 16, 16, 16, 16, 16, 16, 16, + 16, 17, 17, 16, 17, 17, 17, 17, + 18, 18, 18, 17, 17, 8, 12, 14, + 14, 15, 15, 16, 17, 17, 16, 16, + 17, 17, 20, 17, 9, 12, 14, 16, + 16, 16, 17, 21, 18, 17, 9, 13, + 15, 16, 16, 10, 13, 16, 10, 14, + 16, 11, 15, 16, 11, 15, 17, 11, + 15, 12, 15, 12, 16, 12, 16, 13, + 16, 13, 13, 13, 14, 14, 13, 14, + 14, 14, 15, 15, 14, 15, 15, 15, + 15, 15, 15, 15, 16, 17, 16, 16, + 16, 16, 17, 16, 17, 16, 18, 17, + 17, 17, 16, 17, 17, 16, 18, 17, + 21, 17, 18, 17, 18, 17, 18, 17, + 17, 17, 17, 19, +}; + +static const uint32_t coef5_huffcodes[435] = { + 0x00347, 0x0000b, 0x00001, 0x00001, 0x0000c, 0x00004, 0x00010, 0x00015, + 0x0001f, 0x0000b, 0x00023, 0x00026, 0x00029, 0x00035, 0x00037, 0x00001, + 0x00015, 0x0001a, 0x0001d, 0x0001c, 0x0001e, 0x0004e, 0x00049, 0x00051, + 0x00078, 0x00004, 0x00000, 0x00008, 0x0000d, 0x0007b, 0x00005, 0x00032, + 0x00095, 0x00091, 0x00096, 0x000a1, 0x000d9, 0x00003, 0x00019, 0x00061, + 0x00066, 0x00060, 0x00017, 0x0000e, 0x00063, 0x001a0, 0x001b7, 0x001e6, + 0x001e7, 0x001b6, 0x00018, 0x001e8, 0x00038, 0x00031, 0x00005, 0x0003d, + 0x00027, 0x001ea, 0x0001a, 0x000c5, 0x000f9, 0x000ff, 0x000db, 0x00250, + 0x000fc, 0x0025c, 0x00008, 0x00075, 0x003d7, 0x003d3, 0x001b0, 0x0007c, + 0x003ca, 0x00036, 0x00189, 0x004a6, 0x004a2, 0x004fb, 0x000c0, 0x0007f, + 0x0009a, 0x00311, 0x0006e, 0x0009b, 0x0068c, 0x006c0, 0x00484, 0x00012, + 0x000c3, 0x0094f, 0x00979, 0x009f9, 0x00d09, 0x00da6, 0x00da8, 0x00901, + 0x000c1, 0x00373, 0x00d08, 0x009fa, 0x00d8b, 0x00d85, 0x00d86, 0x000df, + 0x006e2, 0x000ce, 0x00f24, 0x009fe, 0x001f7, 0x007c1, 0x000cf, 0x009fc, + 0x009ff, 0x00d89, 0x00da9, 0x009fd, 0x001f8, 0x01a36, 0x0128c, 0x0129d, + 0x01a37, 0x00196, 0x003ea, 0x00f8b, 0x00d93, 0x01e45, 0x01e58, 0x01e4b, + 0x01e59, 0x013f1, 0x00309, 0x00265, 0x00308, 0x0243a, 0x027e1, 0x00f89, + 0x00324, 0x03cbc, 0x03c86, 0x03695, 0x0243c, 0x0243b, 0x0243e, 0x01e4a, + 0x003a5, 0x03468, 0x03428, 0x03c84, 0x027e0, 0x025e2, 0x01880, 0x00197, + 0x00325, 0x03cb7, 0x0791e, 0x007ec, 0x06c75, 0x004c8, 0x04bc7, 0x004c6, + 0x00983, 0x0481e, 0x01b53, 0x0251b, 0x01b58, 0x00984, 0x04fa8, 0x03cbb, + 0x00f8a, 0x00322, 0x0346a, 0x0243d, 0x00326, 0x03469, 0x0481f, 0x0481d, + 0x00746, 0x09032, 0x01b50, 0x01d13, 0x0d8e4, 0x0481b, 0x06c74, 0x0796b, + 0x07969, 0x00985, 0x0d8e3, 0x00986, 0x00fa2, 0x01301, 0x06c7c, 0x00987, + 0x03cb8, 0x0f4af, 0x00e88, 0x1b1c0, 0x00fce, 0x033eb, 0x03f6a, 0x03f69, + 0x00fcf, 0x0791f, 0x004c9, 0x04871, 0x00fcd, 0x00982, 0x00fcc, 0x00fa3, + 0x01d12, 0x0796c, 0x01b47, 0x00321, 0x0796a, 0x0d8e2, 0x04872, 0x04873, + 0x0000e, 0x00014, 0x0000a, 0x000a0, 0x00012, 0x0007d, 0x001a2, 0x0003b, + 0x0025f, 0x000dd, 0x0027c, 0x00343, 0x00368, 0x0036b, 0x0003e, 0x001fa, + 0x00485, 0x001b3, 0x0007f, 0x001b1, 0x0019e, 0x004ba, 0x007ad, 0x00339, + 0x00066, 0x007a4, 0x00793, 0x006c6, 0x0007e, 0x000f1, 0x00372, 0x009fb, + 0x00d83, 0x00d8a, 0x00947, 0x009f4, 0x001d0, 0x01b09, 0x01b4b, 0x007ec, + 0x003e1, 0x000ca, 0x003ec, 0x02539, 0x04fa9, 0x01b57, 0x03429, 0x03d2a, + 0x00d97, 0x003a7, 0x00dc0, 0x00d96, 0x00dc1, 0x007eb, 0x03cba, 0x00c43, + 0x00c41, 0x01b52, 0x007ef, 0x00323, 0x03cb9, 0x03c83, 0x007d0, 0x007ed, + 0x06c7f, 0x09033, 0x03f6c, 0x36383, 0x1e95d, 0x06c78, 0x00747, 0x01b51, + 0x00022, 0x00016, 0x00039, 0x00252, 0x00079, 0x00486, 0x00338, 0x00369, + 0x00d88, 0x00026, 0x00d87, 0x00f4b, 0x00d82, 0x00027, 0x001e1, 0x01a15, + 0x007c7, 0x012f0, 0x001e0, 0x006d0, 0x01a16, 0x01e44, 0x01e5f, 0x03690, + 0x00d90, 0x00c42, 0x00daf, 0x00d92, 0x00f80, 0x00cfb, 0x0342f, 0x0487f, + 0x01b46, 0x07968, 0x00d95, 0x00d91, 0x01b55, 0x03f68, 0x04bc6, 0x03cbd, + 0x00f81, 0x00320, 0x00069, 0x000fe, 0x006d5, 0x0033f, 0x000de, 0x007c6, + 0x01e40, 0x00d94, 0x00f88, 0x03c8e, 0x03694, 0x00dae, 0x00dad, 0x00267, + 0x003a6, 0x00327, 0x0487e, 0x007ee, 0x00749, 0x004c7, 0x03692, 0x01b56, + 0x00fd1, 0x07a56, 0x06c77, 0x09031, 0x00748, 0x06c7a, 0x0796d, 0x033ea, + 0x06c76, 0x00fd0, 0x36382, 0x1e417, 0x00745, 0x04faf, 0x0d8e1, 0x03f6b, + 0x1e95c, 0x04fad, 0x0009e, 0x004bd, 0x0067c, 0x01b08, 0x003eb, 0x01b45, + 0x03691, 0x0d8e5, 0x07904, 0x00981, 0x007ea, 0x019f4, 0x06c7d, 0x04fab, + 0x04fac, 0x06c7e, 0x01300, 0x06c7b, 0x0006f, 0x003f7, 0x03c85, 0x004c4, + 0x0001e, 0x006e1, 0x03693, 0x01b44, 0x00241, 0x01e46, 0x0019d, 0x00266, + 0x004bb, 0x02538, 0x007ac, 0x01b54, 0x00902, 0x04870, 0x00da7, 0x00900, + 0x00185, 0x06c79, 0x006e3, 0x003e9, 0x01e94, 0x003ed, 0x003f2, 0x0342e, + 0x0346b, 0x0251a, 0x004c5, 0x01881, 0x0481c, 0x01b59, 0x03c87, 0x04fae, + 0x007e9, 0x03f6d, 0x0f20a, 0x09030, 0x04faa, 0x0d8e6, 0x03f6f, 0x0481a, + 0x03f6e, 0x1e416, 0x0d8e7, +}; + +static const uint8_t coef5_huffbits[435] = { + 10, 4, 2, 4, 4, 5, 5, 5, + 5, 6, 6, 6, 6, 6, 6, 7, + 7, 7, 7, 7, 7, 7, 7, 7, + 7, 8, 8, 8, 8, 7, 8, 8, + 8, 8, 8, 8, 8, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 10, 9, 10, 10, 10, 10, + 10, 9, 10, 10, 10, 10, 10, 10, + 10, 10, 11, 11, 10, 10, 11, 11, + 10, 11, 11, 11, 11, 11, 12, 12, + 12, 12, 12, 12, 11, 11, 11, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 13, + 13, 13, 12, 12, 13, 13, 13, 12, + 12, 12, 12, 12, 13, 13, 13, 13, + 13, 14, 14, 14, 14, 13, 13, 13, + 13, 13, 14, 14, 14, 14, 14, 14, + 15, 14, 14, 14, 14, 14, 14, 13, + 14, 14, 14, 14, 14, 14, 15, 14, + 15, 14, 15, 15, 15, 15, 15, 15, + 16, 15, 15, 14, 15, 16, 15, 14, + 14, 15, 14, 14, 15, 14, 15, 15, + 15, 16, 15, 17, 16, 15, 15, 15, + 15, 16, 16, 16, 16, 17, 15, 16, + 14, 16, 16, 17, 16, 16, 16, 16, + 16, 15, 15, 15, 16, 16, 16, 16, + 17, 15, 15, 15, 15, 16, 15, 15, + 4, 7, 8, 8, 9, 9, 9, 10, + 10, 10, 10, 10, 10, 10, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 12, + 12, 11, 11, 11, 12, 12, 12, 12, + 12, 12, 12, 12, 13, 13, 13, 13, + 12, 13, 14, 14, 15, 15, 14, 14, + 14, 14, 14, 14, 14, 15, 14, 14, + 14, 15, 15, 15, 14, 14, 15, 15, + 15, 16, 16, 18, 17, 15, 15, 15, + 6, 9, 10, 10, 11, 11, 12, 12, + 12, 13, 12, 12, 12, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 14, + 14, 14, 14, 14, 14, 14, 14, 15, + 15, 15, 14, 14, 15, 16, 15, 14, + 14, 15, 7, 10, 11, 12, 13, 13, + 13, 14, 14, 14, 14, 14, 14, 14, + 14, 15, 15, 15, 15, 15, 14, 15, + 16, 15, 15, 16, 15, 15, 15, 16, + 15, 16, 18, 17, 15, 15, 16, 16, + 17, 15, 8, 11, 13, 13, 14, 15, + 14, 16, 15, 16, 15, 15, 15, 15, + 15, 15, 17, 15, 9, 12, 14, 15, + 10, 13, 14, 15, 10, 13, 11, 14, + 11, 14, 11, 15, 12, 15, 12, 12, + 13, 15, 13, 14, 13, 14, 14, 14, + 14, 14, 15, 15, 15, 15, 14, 15, + 15, 16, 16, 16, 15, 16, 16, 15, + 16, 17, 16, +}; + +static const uint16_t levels0[60] = { +317, 92, 62, 60, 19, 17, 10, 7, + 6, 5, 5, 3, 3, 3, 2, 2, + 2, 2, 2, 2, 2, 1, 2, 2, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, +}; + +static const uint16_t levels1[40] = { +311, 91, 61, 28, 10, 6, 5, 2, + 2, 2, 2, 2, 2, 2, 2, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, +}; + +static const uint16_t levels2[340] = { +181,110, 78, 63, 61, 62, 60, 61, + 33, 41, 41, 19, 17, 19, 12, 11, + 9, 11, 10, 6, 8, 7, 6, 4, + 5, 5, 4, 4, 3, 4, 3, 5, + 3, 4, 3, 3, 3, 3, 3, 3, + 2, 2, 4, 2, 3, 2, 3, 3, + 2, 2, 2, 2, 2, 2, 2, 2, + 3, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 1, 2, 1, 2, 2, + 2, 2, 1, 2, 1, 1, 1, 2, + 2, 1, 2, 1, 2, 2, 2, 2, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, +}; + +static const uint16_t levels3[180] = { +351,122, 76, 61, 41, 42, 24, 30, + 22, 19, 11, 9, 10, 8, 5, 5, + 4, 5, 5, 3, 3, 3, 3, 3, + 3, 3, 2, 2, 3, 2, 2, 2, + 3, 3, 2, 2, 2, 3, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 1, 1, + 2, 2, 1, 2, 1, 2, 2, 2, + 2, 2, 2, 1, 2, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 2, + 2, 1, 2, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, +}; + +static const uint16_t levels4[70] = { +113, 68, 49, 42, 40, 32, 27, 15, + 10, 5, 3, 3, 3, 3, 2, 2, + 2, 2, 2, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, +}; + +static const uint16_t levels5[40] = { +214, 72, 42, 40, 18, 4, 4, 2, + 2, 2, 2, 2, 1, 1, 2, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, +}; + +static const CoefVLCTable coef_vlcs[6] = { + { + sizeof(coef0_huffbits), coef0_huffcodes, coef0_huffbits, levels0, + }, + { + sizeof(coef1_huffbits), coef1_huffcodes, coef1_huffbits, levels1, + }, + { + sizeof(coef2_huffbits), coef2_huffcodes, coef2_huffbits, levels2, + }, + { + sizeof(coef3_huffbits), coef3_huffcodes, coef3_huffbits, levels3, + }, + { + sizeof(coef4_huffbits), coef4_huffcodes, coef4_huffbits, levels4, + }, + { + sizeof(coef5_huffbits), coef5_huffcodes, coef5_huffbits, levels5, + }, +}; + +/*table of the values of 10^(index*.05)*/ +const fixed64 pow_table[] ICONST_ATTR_WMA_XL_IRAM = + { 0x199a, 0x1cb9, 0x203a, 0x2429, 0x2893, 0x2d86, 0x3314, 0x3950, 0x404e, + 0x4827, 0x50f4, 0x5ad5, 0x65ea, 0x725a, 0x804e, 0x8ff6, 0xa186, 0xb53c, + 0xcb59, 0xe429, 0x10000LL,0x11f3dLL,0x14249LL,0x1699cLL,0x195bcLL, + 0x1c73dLL,0x1fec9LL,0x23d1dLL,0x2830bLL,0x2d182LL, 0x3298bLL,0x38c53LL, + 0x3fb28LL,0x47783LL,0x5030aLL,0x59f98LL,0x64f40LL,0x71457LL,0x7f17bLL, + 0x8e99aLL,0xa0000LL,0xb385eLL,0xc96d9LL,0xe2019LL,0xfd954LL,0x11c865LL, + 0x13f3dfLL,0x166320LL,0x191e6eLL,0x1c2f10LL,0x1f9f6eLL,0x237b39LL, + 0x27cf8bLL,0x2cab1aLL,0x321e65LL,0x383bf0LL,0x3f1882LL,0x46cb6aLL, + 0x4f6eceLL,0x592006LL,0x640000LL,0x7033acLL,0x7de47eLL,0x8d40f6LL, + 0x9e7d44LL,0xb1d3f4LL,0xc786b7LL,0xdfdf43LL,0xfb304bLL,0x119d69aLL, + 0x13c3a4eLL,0x162d03aLL,0x18e1b70LL,0x1beaf00LL,0x1f52feeLL, + 0x2325760LL,0x276f514LL,0x2c3f220LL,0x31a5408LL,0x37b403cLL,0x3e80000LL, + 0x46204b8LL,0x4eaece8LL,0x58489a0LL,0x630e4a8LL,0x6f24788LL,0x7cb4328LL, + 0x8beb8a0LL,0x9cfe2f0LL,0xb026200LL,0xc5a4710LL,0xddc2240LL,0xf8d1260LL, + 0x1172d600LL,0x1393df60LL,0x15f769c0LL,0x18a592c0LL,0x1ba77540LL, + 0x1f074840LL,0x22d08280LL,0x27100000LL,0x2bd42f40LL,0x312d4100LL, + 0x372d6000LL,0x3de8ee80LL,0x4576cb80LL,0x4df09f80LL,0x57733600LL, + 0x621edd80LL,0x6e17d480LL,0x7b86c700LL,0x8a995700LL,0x9b82b800LL, + 0xae7c5c00LL,0xc3c6b900LL,0xdbaa2200LL,0xf677bc00LL,0x1148a9400LL, + 0x13648d200LL,0x15c251800LL,0x186a00000LL,0x1b649d800LL,0x1ebc48a00LL, + 0x227c5c000LL,0x26b195000LL,0x2b6a3f000LL,0x30b663c00LL,0x36a801c00LL, + 0x3d534a400LL,0x44cee4800LL,0x4d343c800LL,0x569fd6000LL,0x6131b2800LL, + 0x6d0db9800LL,0x7a5c33800LL,0x894a55000LL,0x9a0ad6000LL,0xacd69d000LL, + 0xc1ed84000LL,0xd9972f000LL,0xf42400000LL,0x111ee28000LL,0x1335ad6000LL, + 0x158db98000LL,0x182efd4000LL,0x1b22676000LL,0x1e71fe6000LL, + 0x2229014000LL,0x26540e8000LL,0x2b014f0000LL,0x3040a5c000LL, + 0x3623e60000LL,0x3cbf0fc000LL,0x4428940000LL,0x4c79a08000LL, + 0x55ce758000LL,0x6046c58000LL,0x6c06220000LL,0x7934728000LL, + 0x87fe7d0000LL,0x9896800000LL,0xab34d90000LL,0xc018c60000LL, + 0xd7893f0000LL,0xf1d5e40000LL,0x10f580a0000LL,0x13073f00000LL, + 0x1559a0c0000LL,0x17f48900000LL,0x1ae0d160000LL,0x1e286780000LL, + 0x21d66fc0000LL,0x25f769c0000LL,0x2a995c80000LL,0x2fcc0440000LL, + 0x35a10940000LL,0x3c2c3b80000LL,0x4383d500000LL,0x4bc0c780000LL, + 0x54ff0e80000LL,0x5f5e1000000LL,0x6b010780000LL,0x780f7c00000LL, + 0x86b5c800000LL,0x9725ae00000LL,0xa9970600000LL,0xbe487500000LL, + 0xd5804700000LL,0xef8d5a00000LL,0x10cc82e00000LL,0x12d940c00000LL, + 0x152605c00000LL,0x17baa2200000LL,0x1a9fd9c00000LL,0x1ddf82a00000LL, + 0x2184a5c00000LL,0x259ba5400000LL,0x2a3265400000LL,0x2f587cc00000LL, + 0x351f69000000LL,0x3b9aca000000LL,0x42e0a4800000LL,0x4b09ad800000LL, + 0x54319d000000LL,0x5e778d000000LL,0x69fe64000000LL,0x76ed49800000LL, + 0x85702c000000LL,0x95b858000000LL,0xa7fd1c000000LL,0xbc7c87000000LL, + 0xd37c3a000000LL,0xed4a55000000LL,0x10a3e82000000LL,0x12abb1a000000LL, + 0x14f2e7a000000LL,0x1781474000000LL,0x1a5f7f4000000LL,0x1d974de000000LL, + 0x2133a18000000LL + }; + +/* 10^(index/16). We'll need to accomidate negative indicies too. + The algorithm sort of implies that there should be 128 values starting at -60, + however this has not been confirmed. More values may be needed. +*/ +const fixed32 pow_10_to_yover16[] ICONST_ATTR= +{ + /*60 negative indicies (-60 to -1)*/ + 0xc, 0xd, 0x10, 0x12, 0x15, 0x18, 0x1c, 0x20, 0x25, 0x2b, 0x31, 0x39, 0x42, + 0x4c, 0x57, 0x65, 0x75, 0x87, 0x9b, 0xb3, 0xcf, 0xef, 0x114, 0x13f, 0x171, + 0x1aa, 0x1eb, 0x238, 0x28f, 0x2f5, 0x36a, 0x3f1, 0x48d, 0x542, 0x612, 0x703, + 0x818, 0x959, 0xacc, 0xc77, 0xe65, 0x10a0, 0x1333, 0x162b, 0x199a, 0x1d90, + 0x2223, 0x276c, 0x2d86, 0x3492, 0x3cb5, 0x461b, 0x50f4, 0x5d7c, 0x6bf4, + 0x7caa, 0x8ff6, 0xa63e, 0xbff9, 0xddb0, + /*non-negative indicies (0-68)*/ + 0x10000, 0x127a0, 0x15562, 0x18a39, 0x1c73d, 0x20db4, 0x25f12, 0x2bd09, + 0x3298b, 0x3a6d9, 0x4378b, 0x4dea3, 0x59f98, 0x67e6b, 0x77fbb, 0x8a8de, + 0xa0000, 0xb8c3e, 0xd55d1, 0xf6636, 0x11c865, 0x148906, 0x17b6b7, 0x1b625b, + 0x1f9f6e, 0x248475, 0x2a2b6e, 0x30b25e, 0x383bf0, 0x40f02b, 0x4afd4b, + 0x5698b0, 0x640000, 0x737a6b, 0x855a26, 0x99fe1e, 0xb1d3f4, 0xcd5a3e, + 0xed232b, 0x111d78b, 0x13c3a4f, 0x16d2c94, 0x1a5b24e, 0x1e6f7b0, 0x2325761, + 0x28961b3, 0x2ede4eb, 0x361f6de, 0x3e80000, 0x482c830, 0x535857d, 0x603ed31, + 0x6f24787, 0x8058668, 0x9435fab, 0xab26b6d, 0xc5a4715, 0xe43bdc4, + 0x1078f70c, 0x1305acdd, 0x15f769cb, 0x195dd0fa, 0x1d4af12d, 0x21d3a4ab, + 0x27100000, 0x2d1bd1e1, 0x341736de, 0x3c2743e8, 0x4576cb4a +}; + +const fixed32 pow_a_table[] ICONST_ATTR_WMA_XL_IRAM = +{ + 0x1004,0x1008,0x100c,0x1010,0x1014,0x1018,0x101c,0x1021,0x1025,0x1029,0x102d, + 0x1031,0x1036,0x103a,0x103e,0x1043,0x1047,0x104b,0x1050,0x1054,0x1059,0x105d, + 0x1062,0x1066,0x106b,0x106f,0x1074,0x1078,0x107d,0x1082,0x1086,0x108b,0x1090, + 0x1095,0x1099,0x109e,0x10a3,0x10a8,0x10ad,0x10b2,0x10b7,0x10bc,0x10c1,0x10c6, + 0x10cb,0x10d0,0x10d5,0x10da,0x10df,0x10e5,0x10ea,0x10ef,0x10f5,0x10fa,0x10ff, + 0x1105,0x110a,0x1110,0x1115,0x111b,0x1120,0x1126,0x112c,0x1131,0x1137,0x113d, + 0x1143,0x1149,0x114f,0x1155,0x115a,0x1161,0x1167,0x116d,0x1173,0x1179,0x117f, + 0x1186,0x118c,0x1192,0x1199,0x119f,0x11a6,0x11ac,0x11b3,0x11b9,0x11c0,0x11c7, + 0x11ce,0x11d4,0x11db,0x11e2,0x11e9,0x11f0,0x11f8,0x11ff,0x1206,0x120d,0x1215, + 0x121c,0x1223,0x122b,0x1233,0x123a,0x1242,0x124a,0x1251,0x1259,0x1261,0x1269, + 0x1271,0x127a,0x1282,0x128a,0x1293,0x129b,0x12a4,0x12ac,0x12b5,0x12be,0x12c7, + 0x12d0,0x12d9,0x12e2,0x12eb,0x12f4,0x12fe,0x1307 +}; + + +/* 32.32 unsigned fixed format */ +/* This is a table of exponent values for an IEEE SP float. Theres never anything less then about index 115 + * making the size of this table fairly ridiculous. + */ + + +const fixed64 lsp_pow_e_table[] ICONST_ATTR_WMA_XL_IRAM = +{ + 0xb504f30000000000LL, 0x9837f00000000000LL, 0x8000000000000000LL, 0x6ba27e8000000000LL, 0x5a82798000000000LL, + 0x4c1bf80000000000LL, 0x4000000000000000LL, 0x35d13f4000000000LL, 0x2d413cc000000000LL, 0x260dfc0000000000LL, + 0x2000000000000000LL, 0x1ae89fa000000000LL, 0x16a09e6000000000LL, 0x1306fe0000000000LL, 0x1000000000000000LL, + 0xd744fd000000000LL, 0xb504f3000000000LL, 0x9837f0000000000LL, 0x800000000000000LL, 0x6ba27e800000000LL, + 0x5a8279800000000LL, 0x4c1bf8000000000LL, 0x400000000000000LL, 0x35d13f400000000LL, 0x2d413cc00000000LL, + 0x260dfc000000000LL, 0x200000000000000LL, 0x1ae89fa00000000LL, 0x16a09e600000000LL, 0x1306fe000000000LL, + 0x100000000000000LL, 0xd744fd00000000LL, 0xb504f300000000LL, 0x9837f000000000LL, 0x80000000000000LL, + 0x6ba27e80000000LL, 0x5a827980000000LL, 0x4c1bf800000000LL, 0x40000000000000LL, 0x35d13f40000000LL, + 0x2d413cc0000000LL, 0x260dfc00000000LL, 0x20000000000000LL, 0x1ae89fa0000000LL, 0x16a09e60000000LL, + 0x1306fe00000000LL, 0x10000000000000LL, 0xd744fd0000000LL, 0xb504f30000000LL, 0x9837f00000000LL, + 0x8000000000000LL, 0x6ba27e8000000LL, 0x5a82798000000LL, 0x4c1bf80000000LL, 0x4000000000000LL, + 0x35d13f4000000LL, 0x2d413cc000000LL, 0x260dfc0000000LL, 0x2000000000000LL, 0x1ae89fa000000LL, + 0x16a09e6000000LL, 0x1306fe0000000LL, 0x1000000000000LL, 0xd744fd000000LL, 0xb504f3000000LL, + 0x9837f0000000LL, 0x800000000000LL, 0x6ba27e800000LL, 0x5a8279800000LL, 0x4c1bf8000000LL, + 0x400000000000LL, 0x35d13f400000LL, 0x2d413cc00000LL, 0x260dfc000000LL, 0x200000000000LL, + 0x1ae89fa00000LL, 0x16a09e600000LL, 0x1306fe000000LL, 0x100000000000LL, 0xd744fd00000LL, + 0xb504f300000LL, 0x9837f000000LL, 0x80000000000LL, 0x6ba27e80000LL, 0x5a827980000LL, + 0x4c1bf800000LL, 0x40000000000LL, 0x35d13f40000LL, 0x2d413cc0000LL, 0x260dfc00000LL, + 0x20000000000LL, 0x1ae89fa0000LL, 0x16a09e60000LL, 0x1306fe00000LL, 0x10000000000LL, + 0xd744fd0000LL, 0xb504f30000LL, 0x9837f00000LL, 0x8000000000LL, 0x6ba27e8000LL, + 0x5a82798000LL, 0x4c1bf80000LL, 0x4000000000LL, 0x35d13f4000LL, 0x2d413cc000LL, + 0x260dfc0000LL, 0x2000000000LL, 0x1ae89fa000LL, 0x16a09e6000LL, 0x1306fe0000LL, + 0x1000000000LL, 0xd744fd000LL, 0xb504f3000LL, 0x9837f0000LL, 0x800000000LL, + 0x6ba27e800LL, 0x5a8279800LL, 0x4c1bf8000LL, 0x400000000LL, 0x35d13f400LL, + 0x2d413cc00LL, 0x260dfc000LL, 0x200000000LL, 0x1ae89fa00LL, 0x16a09e600LL, + 0x1306fe000LL, 0x100000000LL, 0xd744fd00LL, 0xb504f300LL, 0x9837f000LL, + 0x80000000LL, 0x6ba27e80LL, 0x5a827980LL, 0x4c1bf800LL, 0x40000000LL, + 0x35d13f40LL, 0x2d413cc0LL, 0x260dfc00LL, 0x20000000LL, 0x1ae89fa0LL, + 0x16a09e60LL, 0x1306fe00LL, 0x10000000LL, 0xd744fd0LL, 0xb504f30LL, + 0x9837f00LL, 0x8000000LL, 0x6ba27e8LL, 0x5a82798LL, 0x4c1bf80LL, + 0x4000000LL, 0x35d13f4LL, 0x2d413ccLL, 0x260dfc0LL, 0x2000000LL, + 0x1ae89faLL, 0x16a09e6LL, 0x1306fe0LL, 0x1000000LL, 0xd744fdLL, + 0xb504f3LL, 0x9837f0LL, 0x800000LL, 0x6ba27eLL, 0x5a8279LL, + 0x4c1bf8LL, 0x400000LL, 0x35d13fLL, 0x2d413cLL, 0x260dfcLL, + 0x200000LL, 0x1ae89fLL, 0x16a09eLL, 0x1306feLL, 0x100000LL, + 0xd744fLL, 0xb504fLL, 0x9837fLL, 0x80000LL, 0x6ba27LL, + 0x5a827LL, 0x4c1bfLL, 0x40000LL, 0x35d13LL, 0x2d413LL, + 0x260dfLL, 0x20000LL, 0x1ae89LL, 0x16a09LL, 0x1306fLL, + 0x10000LL, 0xd744LL, 0xb504LL, 0x9837LL, 0x8000LL, + 0x6ba2LL, 0x5a82LL, 0x4c1bLL, 0x4000LL, 0x35d1LL, + 0x2d41LL, 0x260dLL, 0x2000LL, 0x1ae8LL, 0x16a0LL, + 0x1306LL, 0x1000LL, 0xd74LL, 0xb50LL, 0x983LL, + 0x800LL, 0x6baLL, 0x5a8LL, 0x4c1LL, 0x400LL, + 0x35dLL, 0x2d4LL, 0x260LL, 0x200LL, 0x1aeLL, + 0x16aLL, 0x130LL, 0x100LL, 0xd7LL, 0xb5LL, + 0x98LL, 0x80LL, 0x6bLL, 0x5aLL, 0x4cLL, + 0x40LL, 0x35LL, 0x2dLL, 0x26LL, 0x20LL, + 0x1aLL, 0x16LL, 0x13LL, 0x10LL, 0xdLL, + 0xbLL, 0x9LL, 0x8LL, 0x6LL, 0x5LL, + 0x4LL, 0x4LL, 0x3LL, 0x2LL, 0x2LL, + 0x2LL, 0x1LL, 0x1LL, 0x1LL, 0x1LL, + 0x0LL +}; + +/* table of exp noise values multiplied by 16 in order to reduce rounding error */ +fixed32 noisetable_exp[] = +{ + 0x5, 0xfffffa2e, 0xc2c, 0xb47, 0xffffaebe, 0xfffffa63, 0xfffff7ff, 0x16bd, + 0xffffe704, 0xffffe34e, 0x71ee, 0x396e, 0xffff8bfd, 0x3b4, 0x562f, 0xffffc362, + 0x5327, 0xffffae19, 0x6cb4, 0x26b0, 0x87c4, 0x21dc, 0x8017, 0x1db0, + 0xffffe49e, 0xffffb162, 0xffffc808, 0xffffafea, 0xfffffe80, 0xfffffeb8, 0xffff8b6e, 0xffffc7a1, + 0x3f46, 0x5e8, 0x374f, 0xffff8fba, 0x87fd, 0x21e7, 0xffff9198, 0x78a0, + 0x7f7c, 0x864f, 0xffffca94, 0x42a7, 0xfffffcd6, 0xffffb916, 0x247a, 0x5679, + 0x8d9f, 0xffffb350, 0xffff9592, 0xffffcf73, 0x552d, 0xffffeb8c, 0x8622, 0xffff8091, + 0x238, 0x3ee8, 0x5c2f, 0x6e25, 0xffffe5cb, 0x86a1, 0xffffa8ca, 0xfe2, + 0x5dac, 0x2da2, 0x5ad1, 0xffffa94f, 0x729, 0xfffffdc0, 0xffff825c, 0x8bcd, + 0xffff7d05, 0xffff7d9e, 0xffffb5b6, 0x58a3, 0xffff8a3f, 0xffffd9c0, 0xffff8142, 0x596f, + 0x78aa, 0x2694, 0x78f5, 0xffff8a84, 0x43b3, 0x498a, 0xffffdfe5, 0xffffbba9, + 0xffff7228, 0xffff72c9, 0xfffff174, 0xffff9a76, 0x64d5, 0x221c, 0x88dd, 0xffffd319, + 0xfffffe14, 0xfffff99f, 0xffff8ba4, 0x6e34, 0x6cc, 0x3208, 0xfffffb14, 0x6670, + 0xffffd5ff, 0xffffa502, 0x641d, 0xffff75b6, 0xec2, 0xffffedf2, 0xffffb925, 0xffffe271, + 0xffffb727, 0xffff7450, 0xfffff421, 0x89e7, 0xfffff635, 0xffffa841, 0xffffda00, 0xffffc94e, + 0xef9, 0x28cc, 0xffffd477, 0xffff82b9, 0x2a7, 0xffff7540, 0x24c2, 0x4349, + 0xffffdf34, 0xdf7, 0x323d, 0xffffbce7, 0x29c5, 0x4700, 0x10b0, 0x1eb6, + 0x1172, 0x84be, 0xffffcee4, 0xffffe7bd, 0x1166, 0xffff7df0, 0xffffe115, 0x2383, + 0x23a0, 0x784a, 0x6f8e, 0xffff9043, 0x2b66, 0xffffc79e, 0xffff8966, 0xffffbfac, + 0x5fb1, 0xffffb183, 0x3602, 0x3d19, 0xffff7df4, 0x3ffe, 0xffffc919, 0x5ac7, + 0xffffa3e8, 0xfffff2ea, 0x47b9, 0xffffe344, 0x12f0, 0xffffc4e8, 0xfffff3fc, 0xffffcacd, + 0xffffd23b, 0x893a, 0x5e82, 0xffff8d36, 0x50e0, 0x49a6, 0x29dd, 0x16fa, + 0x451d, 0x8315, 0xffffe455, 0x749, 0x8624, 0x2fe5, 0x3ab5, 0xffffb4f1, + 0x72d, 0xffffccdf, 0x2b05, 0xffffa816, 0xffff9570, 0xffffd2e7, 0xffffa6ac, 0x2fc2, + 0xae4, 0x4c93, 0xfffffce1, 0xffffdb9f, 0x8102, 0x6bb1, 0xffffd5bf, 0xffff80e0, + 0xffffd70e, 0x568f, 0xc12, 0xffff9823, 0x700c, 0xffffa1aa, 0xffffa86c, 0xffffd303, + 0xffffbe7a, 0x38c9, 0xffff9f18, 0xffffcd7a, 0xffff8d75, 0x6955, 0xffffe70a, 0xffffbf49, + 0xffffc423, 0x31f, 0xffffe44a, 0x118a, 0xffffebfa, 0xffffedec, 0xffffee42, 0xffffd865, + 0xffff9b30, 0xffff8759, 0xffff827c, 0xffffbc26, 0xfffffb02, 0xffff8bee, 0xffffe6c2, 0x72f3, + 0xffffc2c9, 0xffff74ff, 0x2434, 0x1eb4, 0x11c9, 0x61c1, 0xffffa964, 0x89a3, + 0x6a43, 0x3d7f, 0xffffd09f, 0x14d8, 0x37bc, 0xfffffc31, 0xffffdb03, 0xfffff4e1, + 0x5547, 0xffffdc87, 0xffff929a, 0x73cc, 0x246f, 0x194e, 0xffffb4ce, 0x86b5, + 0x2f57, 0x7f05, 0x252b, 0xffff9b05, 0x5b7a, 0x164, 0x57cf, 0x7f86, + 0x5421, 0xffffa478, 0xffffbbda, 0x1b3c, 0xfffff4cb, 0xffffda7e, 0x5d8e, 0x1957, + 0xffffb3a7, 0x1979, 0xffff8ddd, 0xffffd7b9, 0xfffff028, 0xffff8c90, 0x476a, 0x6be6, + 0x419e, 0xfffffd2d, 0x8294, 0xffffc931, 0xffffe1ab, 0xffffdd4f, 0x46f0, 0x1930, + 0x4e5e, 0x8429, 0xffffde0a, 0xffff8e69, 0x2972, 0x387f, 0x3dd8, 0xffffbcc6, + 0x121b, 0x6d3d, 0x1fa4, 0xffffa3ea, 0xffffbbef, 0xffffcbd2, 0xffffbe04, 0xffffb424, + 0xffff7533, 0x70cd, 0x2370, 0x4822, 0xffff756e, 0xffffbe8c, 0x4131, 0x1ead, + 0x47de, 0xffffed53, 0xffff917e, 0x5f93, 0xffffe264, 0xffffde05, 0xffff9dc3, 0xffffc1d9, + 0xffff9b25, 0x3ade, 0xfffff9b7, 0xffffac80, 0x239e, 0xffffb980, 0xffffc9a4, 0x788c, + 0xffffbb6d, 0x3bb7, 0x6483, 0xffffeac0, 0x25ea, 0xffffbdfc, 0x333d, 0x8c0d, + 0x6d9a, 0xffffafe8, 0xffff8a74, 0x6067, 0xffff8642, 0x1a64, 0xfffff921, 0x3f3b, + 0xae4, 0x5112, 0x43a4, 0x1573, 0xffffc977, 0xffffa3b4, 0x21be, 0xffff96df, + 0xfffff035, 0x473b, 0xffff8d26, 0xb75, 0xffffecdc, 0x4455, 0x47d5, 0xffff7581, + 0xeca, 0xffffb3fe, 0xffff9f6a, 0xffffea15, 0xffffb9c3, 0x5516, 0xffffb654, 0x7f91, + 0x80b, 0xffff96b7, 0x2b60, 0x36b7, 0xffffc581, 0x285b, 0xffffa002, 0xffffc7e5, + 0x4965, 0xffff94d4, 0xffff764b, 0x1cd2, 0x5599, 0xffffd272, 0xffffcbfb, 0xffffae6d, + 0xffffd496, 0x3183, 0xffffe4f5, 0xffffa59f, 0x43df, 0x4569, 0xffffb185, 0x1d56, + 0xffff933a, 0xffff7a2c, 0x38d0, 0xffffb815, 0x5203, 0xfffffd89, 0xffff93ea, 0xffffa4dd, + 0x1f13, 0xffffad7d, 0xffffff4f, 0xffffe13c, 0xffffd60a, 0x8c88, 0x8276, 0xffffeaaf, + 0xffff8a66, 0xffff7888, 0xffff91e9, 0x8bdf, 0xdcf, 0xfffff282, 0xffffe91b, 0x1eb1, + 0x6fc, 0xffff81f6, 0x1617, 0xffffad02, 0xffffafaf, 0x60d5, 0x6f2b, 0x4e8b, + 0x2347, 0x3257, 0x29cf, 0x86c4, 0x75b3, 0x7745, 0xfffffcc7, 0x49cd, + 0x558f, 0xffff7c7a, 0x52e1, 0xffff7626, 0x7690, 0xffffb357, 0xffff7dbf, 0xffffa1ee, + 0xffffa874, 0xffff846f, 0xffffab72, 0x5cef, 0xffffb0cf, 0xffff8c24, 0xffff8e10, 0xffffe200, + 0x2a45, 0xfffff883, 0x5155, 0x37c9, 0xad6, 0x1ed9, 0x79e2, 0x1f4c, + 0x45f8, 0x48ec, 0xffffa331, 0x34a1, 0xffffc7b0, 0x2eb5, 0x5dc, 0x4cdd, + 0x4e5c, 0xffffa7c7, 0x3b08, 0x2776, 0x2e1a, 0x788d, 0x162b, 0x1fa7, + 0x466c, 0x5ca2, 0xfffff3ac, 0xffffa62f, 0xfffffd4c, 0x5f48, 0x779, 0x2a5e, + 0xffffe14e, 0x196, 0xffffaba1, 0x404c, 0xffffdc5b, 0x238f, 0x274, 0xffffa5c6, + 0xffff9e2b, 0x6201, 0xfffff195, 0xfffff3b0, 0x2285, 0xffffc7f0, 0xffffdff4, 0xffffc43d, + 0xffffac57, 0xffffb7a6, 0xffffe88c, 0xffffd3ac, 0xffffbb5c, 0x2cbd, 0x44d6, 0x5e30, + 0xffffeb53, 0x6d8b, 0xffff7f8b, 0xffff99a3, 0xffff7a4e, 0xffffbc82, 0x6a49, 0xfffff220, + 0xffffeaca, 0x4146, 0x8d72, 0xffffdcb7, 0xffffe2f3, 0xfffff736, 0x557f, 0x13fd, + 0x66a, 0x5d9, 0x29ee, 0xffffda1e, 0xd38, 0xffffe70f, 0xffffbbd7, 0xffffe1ee, + 0x4a0d, 0x502e, 0xffff8c37, 0xffffaccc, 0xffffdd0b, 0xffff7401, 0x3a89, 0x73b4, + 0x71b7, 0x5b43, 0xffff9baf, 0x4d76, 0x25f, 0x7f97, 0xffffcb71, 0x6b4c, + 0xffffe999, 0x3fd5, 0xffffd40b, 0x3f0d, 0xffffc17b, 0x3de9, 0x87f7, 0x6446, + 0x5be, 0xffffd88a, 0x7d05, 0xfffffe16, 0x467e, 0x1454, 0xffffca4e, 0xffffa047, + 0xffff92ac, 0xffffddc9, 0x72a9, 0xffffc902, 0x3605, 0xe47, 0x280c, 0x7662, + 0x609d, 0xffffae0a, 0x78e0, 0xffffa02a, 0x1c87, 0xfffff91b, 0xffff7792, 0xffff745e, + 0xffff8097, 0xffff8583, 0xffffe7e4, 0x61a5, 0x36a8, 0x7fe7, 0xffffaecc, 0xffff90f7, + 0x5ad9, 0x7e2f, 0xffffffca, 0x75c7, 0x7134, 0xffffd7fe, 0x3c22, 0x314c, + 0x7c97, 0x2068, 0xffff7926, 0x3e7c, 0x6926, 0x67f9, 0x3e28, 0x7c65, + 0x76b9, 0x25cf, 0x1039, 0xffffdf97, 0x8779, 0xffffe8fd, 0xffff9f74, 0x770a, + 0x8a50, 0xffffd241, 0xffffddee, 0x5aab, 0xffffc97f, 0x4572, 0x3276, 0xffffe7ec, + 0xffff8cc2, 0x6331, 0xfffffedf, 0x3b86, 0x3038, 0xffffd628, 0x2645, 0xffff737c, + 0x72fe, 0xffff8474, 0x23fb, 0x78f, 0x194c, 0x95a, 0xffff91d0, 0xffff8014, + 0x56e9, 0x2efe, 0xffffae5b, 0x614, 0xffffca3d, 0xffffd77e, 0x73e1, 0x35f7, + 0x71f3, 0xffff9279, 0xffffe6f3, 0x404b, 0x548d, 0x32a3, 0xc11, 0x637a, + 0xffff7605, 0x2ba8, 0xffff8f35, 0x8157, 0x423f, 0xffff9711, 0xffffb980, 0xffffb4b1, + 0x3494, 0xffffc9dd, 0x6c43, 0x563f, 0x52c, 0xffff9680, 0x8b7a, 0xffffcf49, + 0xffffa40b, 0x6daf, 0xffff840e, 0x29cd, 0xffffbf5c, 0x68b7, 0xffffedf3, 0xffffe329, + 0xfffff634, 0x8619, 0x33bc, 0x28b4, 0x5ed8, 0xffffcfbb, 0x883a, 0xfffffdf6, + 0xffffb980, 0x7bac, 0xfffffd6d, 0x418f, 0x4a25, 0xffffbed3, 0x4272, 0xffffef42, + 0x800f, 0x78e3, 0x82c8, 0x24e1, 0xffffcfa3, 0xffffb385, 0x86b, 0x645b, + 0x38aa, 0x6a22, 0xffffc21b, 0x60f0, 0x9b6, 0x912, 0x7621, 0xffff94cc, + 0xffffd5c9, 0xfffffdb5, 0xffffd93a, 0x2a11, 0xffff8b3d, 0xffffc0d2, 0xffffa00f, 0xffffe965, + 0xfffffa0f, 0xffffbfa9, 0x5e78, 0xffff925b, 0xffffeac8, 0xffffd5af, 0xffffba37, 0x395a, + 0xffffdc75, 0xfffffdf2, 0xffff7c7b, 0xffff89a3, 0x3766, 0xffffe8a9, 0x7118, 0x399e, + 0xffff7ff5, 0xffffac9a, 0xffff7d74, 0xffffa5d2, 0x4c27, 0x787f, 0x586, 0x7ce4, + 0xffffb38e, 0xffffb93d, 0x240d, 0x5a90, 0xffffb448, 0xffff8e29, 0xffffbc06, 0x3bf3, + 0xffffda90, 0xffffb78d, 0xffffc747, 0xffffa5c0, 0xffffe2dd, 0x7fbd, 0x8946, 0xffff8d50, + 0x2451, 0x18f9, 0xffffc1d4, 0xffffb689, 0xffffc37b, 0xffffbe2f, 0xffffbe9e, 0x8117, + 0x7050, 0xfffff504, 0x2b9, 0x464f, 0x298d, 0x2367, 0xffffe8c3, 0x79f1, + 0x4e38, 0x5cc8, 0x2928, 0xffffb486, 0x7cd6, 0xffffdbd9, 0xfffff110, 0xffffeff7, + 0x19b8, 0xffffeb99, 0xffff847c, 0xffff7612, 0xffffd542, 0x2966, 0xffff8ce2, 0x38fe, + 0xffffdeaa, 0x5238, 0x67c4, 0xffffa5e7, 0x4e6d, 0xffffd82e, 0x5973, 0x351b, + 0x74e8, 0xffffafcd, 0x66dd, 0x20e4, 0x609d, 0xffffade3, 0x509f, 0xffffa21f, + 0x2cce, 0x54c2, 0x1953, 0x85ce, 0x6bee, 0x3222, 0x6ff6, 0x3773, + 0x5a64, 0xffffe40f, 0xffffc6df, 0x3556, 0x80a9, 0xffff76c5, 0x495b, 0x1ae4, + 0xffffca33, 0x31f2, 0x833e, 0x89c3, 0x5f43, 0xffffbee7, 0x3ab2, 0x87af, + 0x4c74, 0xffff810b, 0xffffbed0, 0x6795, 0xffff785c, 0xffffbc0b, 0x520e, 0x4348, + 0xe03, 0x4541, 0x2557, 0xffff9110, 0x4044, 0x1947, 0x4dab, 0xcbe, + 0x3f72, 0x4507, 0xffffa362, 0xffffc20b, 0x6c1b, 0x27c7, 0xffff9bf2, 0x6506, + 0xffff89cc, 0x5c3e, 0x4509, 0x409a, 0xffff98db, 0x1674, 0xffff9324, 0x7328, + 0xffff99cf, 0xcd8, 0x730a, 0x14b9, 0x672d, 0xffffd620, 0x1dd8, 0x3bec, + 0xffff94b6, 0xffffb689, 0x7dfd, 0x3ffd, 0xffff9cb6, 0x3560, 0xffffbaf8, 0xffff8604, + 0x8795, 0xffff7aec, 0x66a5, 0x6a0b, 0x564b, 0xffff8d00, 0xffffed20, 0x11b8, + 0xffffdc27, 0x595d, 0xffffddf0, 0xfffffc70, 0xffffd5bf, 0x6714, 0xffffaf69, 0xdb2, + 0x3786, 0xffffbf9d, 0x7ca7, 0x5a53, 0xffff7c6a, 0xffff8465, 0xffffe4c6, 0xffffa238, + 0xffff7f9b, 0x6887, 0x3838, 0x7115, 0x5bce, 0xeae, 0x47c, 0xffffd54a, + 0xffffb9d5, 0x6183, 0x9c3, 0xbd5, 0xffffe217, 0x8237, 0x51d7, 0x52fe, + 0x6424, 0xffffb192, 0xffff7ebb, 0xffffd373, 0xffff9cf7, 0x390b, 0xffffa473, 0x8953, + 0xffff90c9, 0x594a, 0xc6e, 0x32ba, 0xffffae73, 0x86c7, 0xffffd7a0, 0xffffa82e, + 0x8d66, 0xffffabcf, 0xffff84d0, 0x3a84, 0xffffe8bd, 0x4948, 0x3f2a, 0xfffff4e5, + 0xffffb0bd, 0x4961, 0xffffd95b, 0xffffd96c, 0xffffce34, 0x57ff, 0xffffdf08, 0x2330, + 0xffffa8c7, 0x24cb, 0x740a, 0xffffdbcf, 0xffffad36, 0x306f, 0xffffa30b, 0xffffc488, + 0xffff8022, 0x464a, 0x6f00, 0xffffb419, 0xffff8450, 0x2ddb, 0x2731, 0x63fd, + 0x2946, 0x5c28, 0xffffb064, 0xffffb277, 0x1e0f, 0x6d71, 0xffff7ff3, 0xfffffb02, + 0xf2a, 0xffffd69c, 0x638, 0xffffe8ff, 0xffffbd7e, 0xffffb26f, 0xffffe153, 0xffff9879, + 0xffff849c, 0x1f73, 0xffff9b21, 0x2bb1, 0xffffa95b, 0xffffd582, 0xffffdbfa, 0xd2c, + 0xffffa86f, 0x2ab3, 0xffff9d78, 0x1074, 0xffffbcb5, 0x3990, 0xffffe869, 0xffffb422, + 0x2dc8, 0xffffca25, 0xffffcfe8, 0xaf1, 0xffff82c8, 0x36a, 0x2f4e, 0xfffffdcd, + 0x77fa, 0xffffad4f, 0xffffa54a, 0x50b9, 0x6eab, 0x5178, 0x8982, 0xffffe4dd, + 0xffff9a82, 0x45a2, 0x784e, 0xffffbd6e, 0x5019, 0xffffcc5c, 0x8009, 0x5d96, + 0xffffac8d, 0xffff8ec9, 0x4c, 0x4222, 0xfffffa7f, 0x3227, 0x67ea, 0xffffe679, + 0x3dc8, 0xffffb5b5, 0x1424, 0x3e4a, 0xfffff175, 0xffffaf4b, 0x4657, 0x1374, + 0xffff7233, 0x7190, 0x332, 0xaf0, 0x68c0, 0xffff85ad, 0xffffd0af, 0x2b1, + 0xffff8d54, 0x1f99, 0xffffe8d5, 0xffffc30b, 0x2877, 0xffff9d40, 0xffff8852, 0xffffb01a, + 0x4b32, 0x3279, 0xffff9099, 0x5f4f, 0xffffe08c, 0xffff9fe0, 0xffff9ecc, 0xfffff557, + 0xfffffc25, 0xffffa719, 0xffff920a, 0x62ac, 0xfffff11d, 0x152d, 0xfffff5d6, 0x5223, + 0xfffff438, 0xffff73f3, 0x34e1, 0x49a9, 0x6a73, 0x2ad3, 0x1f51, 0x824, + 0x1bc9, 0x5170, 0x552d, 0x52b5, 0xfffff12a, 0xffffec44, 0x7924, 0x5294, + 0xb63, 0x822f, 0xffff9afd, 0x7e29, 0x2d91, 0x42ad, 0xfffff589, 0xfffff6e9, + 0x2792, 0x4269, 0xffff9639, 0xffff726f, 0x4074, 0xffffa179, 0x8a6b, 0xffffb431, + 0x850f, 0xffff903f, 0x6b22, 0x738, 0x16a0, 0xffff917f, 0x8a5a, 0xb61, + 0xffffcce6, 0x6369, 0xffffb671, 0x66c0, 0x68e6, 0x41aa, 0x2fc3, 0x2382, + 0xffffabd5, 0x62c, 0x5041, 0xffff9903, 0x846b, 0x86f6, 0x8111, 0x15c, + 0x62ed, 0xfffff411, 0x517c, 0xffffbb6d, 0x8256, 0x141e, 0xfffffd31, 0x8777, + 0xffffabbe, 0x4eb5, 0xffffbae4, 0x75a2, 0x2bfc, 0xffff799f, 0x26bd, 0x2296, + 0x7b36, 0xffffddc6, 0x7517, 0x155a, 0x16b1, 0x25b4, 0xfffff8ce, 0x54e9, + 0xffffeb3c, 0x7e5e, 0xffffa981, 0xfffffdbb, 0x87f7, 0xfffff4fe, 0x5657, 0x2add, + 0x5113, 0x7bff, 0xffffbcec, 0x37fb, 0x59a3, 0xffffd989, 0xffff9ac8, 0xffff8e9e, + 0x5ea9, 0x1bbf, 0x8ca1, 0xffff7365, 0x4d65, 0x874c, 0x4119, 0x63ee, + 0xffff91ea, 0x8074, 0x8a3c, 0xffff74b0, 0xffffb940, 0x3c7a, 0x50f, 0xffffe11e, + 0x6c76, 0x5731, 0xf34, 0xffff8ace, 0xffffdb12, 0x4cb2, 0xffffa624, 0x8999, + 0xffff94e3, 0x469e, 0x4101, 0xffffe271, 0x850d, 0xffff95cf, 0xffff93fa, 0x3357, + 0x8fe, 0xffff9b75, 0xffffbd9b, 0x6a34, 0x1db7, 0xb19, 0xffffee5f, 0xffffc9c1, + 0x763, 0xffff9c09, 0x26a7, 0xffffb6c5, 0xf48, 0xe3e, 0x854f, 0xfffffa24, + 0xffffb689, 0x34bc, 0xffff7a74, 0xffff7240, 0x5849, 0xfffffa7f, 0xffffbd17, 0x17e4, + 0x8e6, 0xfffff805, 0xffffd6d6, 0xffffecd0, 0xffff8b9c, 0xffffed0b, 0x198e, 0x5422, + 0x8549, 0x8dc7, 0xffffb649, 0x1cb6, 0x5ba9, 0xffffc4f6, 0x7b31, 0xffff8611, + 0x62a9, 0xc49, 0xffff7b22, 0xffffd5f0, 0xffff9fce, 0x3f16, 0xffff72a8, 0xffff9a53, + 0xffffa401, 0xffff9f41, 0x53b8, 0xffffca3e, 0x86a2, 0xffffa27c, 0xffffb022, 0x7c4, + 0x3425, 0x344e, 0xffffcb0a, 0x6d47, 0x63b3, 0x677c, 0x4077, 0x72b, + 0x5a90, 0x4348, 0xffff8b9d, 0xffffbcef, 0xffff8e3f, 0x58fa, 0xffffe0a8, 0xffffaf0c, + 0x4698, 0x3da0, 0xffffd44c, 0xffffe85d, 0x455f, 0x5746, 0x5168, 0xfffff3ad, + 0xffffd7bb, 0x56b0, 0xffff7845, 0xffff8d1d, 0x8fa, 0xffffe8c1, 0xffffb00f, 0x6f65, + 0xffffb97c, 0x83b9, 0x4e67, 0x5e2a, 0x787f, 0x8d66, 0x397e, 0x7e75, + 0x4789, 0x7be7, 0x8a38, 0x7ce2, 0xffff9005, 0x3391, 0x873d, 0x5ade, + 0x71e5, 0xffffb84e, 0x4718, 0x438, 0x8700, 0xffffdf0d, 0xfffffed4, 0x88, + 0xfffff494, 0xffffab9a, 0x6c68, 0xffffece3, 0xffff9e05, 0x5590, 0xffffeda6, 0x491d, + 0x7376, 0x6e88, 0x75df, 0xffffd5a8, 0x88b7, 0xffffe707, 0x356d, 0xffff9881, + 0xffffef0f, 0xffffa40f, 0xffff8f5e, 0x3b0f, 0x3da, 0xfffff8d1, 0x6809, 0x83dd, + 0x876d, 0x3c44, 0xffffe878, 0x3faf, 0x78f, 0xffff7a85, 0xffffc78b, 0xffffd711, + 0xffff9d6b, 0x79c8, 0xd65, 0xffffe3e3, 0x478, 0x7129, 0xffff7dda, 0xffffab18, + 0xffffcd44, 0xffff7cfc, 0x723a, 0x5c3, 0x3737, 0x3451, 0x650a, 0xffffa327, + 0xfd9, 0xffff7bae, 0x1f5b, 0x2978, 0x8c99, 0x4cd4, 0xffffb3d6, 0x4036, + 0x2a0e, 0x35ea, 0x50b, 0xffff9518, 0xffff85c1, 0xffffcdc6, 0xffffdc56, 0xffff8d75, + 0xffff90f3, 0x11cb, 0xffffa7dd, 0xffff884c, 0xffffc35a, 0xffffc3cf, 0xffffad4a, 0xffffc75a, + 0xffffa170, 0x8adb, 0x7441, 0xffffe8d1, 0x42b4, 0xffffe1ad, 0xffffdd4a, 0xffff98bf, + 0x4cc2, 0xffff8b07, 0x334c, 0x5e4d, 0xffffb14a, 0xffff9c04, 0xffffb744, 0xffffa616, + 0x187d, 0x495a, 0xffffb1c3, 0x524d, 0xffffc04b, 0x6110, 0x6dff, 0x55b8, + 0x8de1, 0x3394, 0x886f, 0xc21, 0xffff995f, 0xd71, 0xffff90e8, 0xffff983a, + 0xffff92d8, 0xffffcce2, 0xffff90e7, 0xffff94ff, 0x4e0b, 0xffff9334, 0xffffeacb, 0xffff8f75, + 0x48aa, 0x7631, 0xfffffbf9, 0xffffd3e0, 0x6850, 0xffffa651, 0xffff8745, 0xffffe780, + 0xfffff596, 0xfffffed5, 0x3b41, 0x55cd, 0x5a08, 0xffffa0cf, 0xffff75a0, 0xe58, + 0xffffff64, 0x6763, 0xffff8c5f, 0x69b7, 0x453b, 0xffffba78, 0x7554, 0x4fba, + 0x6031, 0x1ed6, 0x30a2, 0x3c52, 0xfffffc1a, 0xffffecfe, 0xffffa280, 0xffff9d76, + 0xffffa66c, 0xffff8dc0, 0xffffaa2b, 0xffffbc38, 0x1cd9, 0xfffff3fa, 0x7078, 0xfffffecb, + 0x800e, 0xfffffa73, 0xffff9a9f, 0xffffb5c5, 0xffffda01, 0x68c8, 0x7787, 0xffffe959, + 0xffffc008, 0x357a, 0x37fb, 0xffff9b65, 0x4df5, 0x8ad5, 0x53aa, 0xffffcc5a, + 0xffff74a9, 0xffffed23, 0x4c8e, 0xffffbd47, 0xb95, 0x774c, 0x5109, 0xffffd8ef, + 0x4095, 0xffffad7a, 0x8a82, 0x2d80, 0xffff8d9a, 0xd43, 0x6bf9, 0x223, + 0x3eed, 0xffffc475, 0x3854, 0xffffa438, 0x1ac0, 0x990, 0x50f8, 0xfffffce9, + 0xffff72ab, 0x41f2, 0x845e, 0xffffef06, 0x7241, 0xffffcf1a, 0x7888, 0x5bf5, + 0xffffc6a5, 0xffffdbe1, 0x1573, 0x65ba, 0x1f5a, 0xffff9e88, 0xffffef80, 0x580c, + 0xffff8254, 0x5da1, 0xffff7a42, 0x220e, 0xffff7947, 0xffff7a6b, 0xffffaa90, 0x7b4, + 0xfffff0e5, 0xf4, 0xd7c, 0x3754, 0xffffa34c, 0x4314, 0x4e93, 0x5f33, + 0xffffd600, 0x150b, 0xffff867a, 0x5eee, 0x54fd, 0x630d, 0xfffff8e2, 0xffffdd08, + 0xffffdd29, 0xffff7350, 0xffffbc1a, 0x1429, 0xffffda45, 0x3e79, 0xffffca86, 0x1523, + 0x620c, 0xa9e, 0xfffffdb9, 0xffffb00f, 0xffff82bf, 0xfffffb63, 0xffff78de, 0x25ad, + 0x54ac, 0x3831, 0x66b6, 0x696e, 0x4e31, 0xffff81c0, 0xffff854a, 0xa8e, + 0x8ce6, 0x52dd, 0xffffa6c6, 0xffffe575, 0xffff9907, 0xffff9743, 0x2156, 0xffff8199, + 0x76ea, 0x7361, 0x8d23, 0xfffffa98, 0xfffffb0d, 0xffffa7b3, 0x12e3, 0x4239, + 0x4aeb, 0x7461, 0xe02, 0x987, 0x68b5, 0xfffffc95, 0x7ac, 0x7238, + 0xfffff148, 0xfffff26d, 0x58f4, 0x50b3, 0xffff869d, 0xffff8582, 0x5d94, 0x30fd, + 0x1e62, 0x83ab, 0xfffffa33, 0xffffb49d, 0x18e9, 0x4781, 0x6d8, 0x7bab, + 0x1aef, 0x2ca6, 0x81a9, 0x2f34, 0x248d, 0xffff9a23, 0xffffdd8a, 0xffffd9a2, + 0xfffffba7, 0x754, 0xffffdbe5, 0x28cc, 0xffff9659, 0x2219, 0x6bea, 0xffffe7ad, + 0xffff856e, 0xffffd3c1, 0x14ff, 0x350, 0x42f3, 0xffffd69d, 0xffffb4b5, 0xffffccd7, + 0x6500, 0x2fb6, 0xffff95b5, 0xffffe293, 0x5baa, 0xffffc45a, 0xffffda2f, 0xffff8de6, + 0xffff87ec, 0x5f0e, 0xffffca76, 0xffffac52, 0xfffff9a4, 0xffff9e0d, 0x771a, 0xd62, + 0x32f3, 0x8367, 0xffff982d, 0x240a, 0x20d, 0xfffff430, 0xffffba8d, 0xffffb810, + 0xffffcfd1, 0x8044, 0xffffcba1, 0xffff9772, 0xffffee63, 0xfffffd51, 0xfffff324, 0x101e, + 0xffffe7c7, 0xfffffb15, 0xffffc5eb, 0x8585, 0x427, 0xffffcdbf, 0xffffcc26, 0x21fb, + 0xffff7c96, 0xffff7705, 0xffffb428, 0xffffa3f8, 0x3906, 0x5787, 0xffffd8af, 0xffffd7d1, + 0xffff77d7, 0x5504, 0xffff73a1, 0x116e, 0x32d8, 0x16f2, 0x5c09, 0xfffff98c, + 0x7350, 0x6462, 0xffffada1, 0x3f1b, 0x6378, 0xffff81e0, 0x2dd3, 0xfffff52a, + 0x8142, 0x89e0, 0xffff9fc6, 0xffff7bf1, 0xffffd116, 0xffffebf0, 0xd84, 0x1669, + 0xffff9bca, 0x5050, 0x6f8a, 0x2c50, 0x8590, 0x32fd, 0x6abf, 0x6af0, + 0xffffa4de, 0x2042, 0xffff9f0b, 0x726, 0xffffcb98, 0x12a1, 0x497b, 0xffffa677, + 0xfffff6f1, 0x2433, 0xffffebc9, 0xffffd8cd, 0x2939, 0x2438, 0xffff79b3, 0xffff9226, + 0xffff9ca1, 0x4884, 0x6fe7, 0x2f89, 0x812a, 0xffffa72e, 0xffffb33c, 0xffff815e, + 0xffff8866, 0x3b83, 0xfffff5b5, 0x3fb2, 0x8221, 0xffffd486, 0x2665, 0xffffa540, + 0x5ce5, 0x893c, 0x4b34, 0x1b5d, 0xffff8b00, 0x8b56, 0xffffb3ab, 0xfffff0d7, + 0x353f, 0x63ce, 0xffff9b0b, 0xffff9689, 0xfffffe5a, 0x50c5, 0x3f3d, 0x1917, + 0x3045, 0xffffdb17, 0x2f69, 0x7ecc, 0xffff7f93, 0xffffa392, 0x9ed, 0xffff94dc, + 0x11e, 0xffffdcb5, 0xffff934b, 0xfffff44a, 0xffffd194, 0xffffe03b, 0x5841, 0xffffd49a, + 0x26f3, 0xfffffc5a, 0x8d0e, 0x6441, 0x2fc5, 0xffffed7a, 0xffffe739, 0xffffd2ff, + 0xffffb541, 0xffff8f9e, 0x807, 0xffff8e7d, 0xffff85b9, 0xffff8fc7, 0x778a, 0x8451, + 0xffffa75f, 0xffffe5b1, 0x2aeb, 0x7fe6, 0xffffc2b3, 0x8534, 0x268a, 0x6711, + 0xffff8cf8, 0xffffd800, 0xffff7913, 0x7c1b, 0x4e76, 0xffffde5d, 0x1545, 0xfffff355, + 0xffffc1bb, 0x398c, 0xffff798a, 0xffffdc27, 0x40ed, 0xfffff8fc, 0xfffff918, 0x7ef5, + 0x5182, 0x8369, 0x47af, 0xffffd6d5, 0xffff7e09, 0xffffa12e, 0x5363, 0xffffce2c, + 0xffffdc79, 0xfffff095, 0xffff7760, 0x4905, 0xffffd192, 0xffff9ca8, 0x39dc, 0xffffd67b, + 0x680, 0xffffb5a4, 0xffffd7d7, 0xffffb5a5, 0x7fcd, 0x7305, 0xffff8e3b, 0x179d, + 0xffffebf4, 0xffffad3c, 0xffff791f, 0xffffb513, 0x7d2e, 0x361f, 0x1a0f, 0xffffd336, + 0xffff7531, 0xffff73ec, 0x8acc, 0x85bf, 0xffff8a29, 0xd3c, 0x392, 0x4482, + 0x7272, 0xffff8403, 0x7d3e, 0xfffff055, 0x6ae2, 0xffffc5b3, 0x74ac, 0x30f6, + 0xfffff4bd, 0x19ba, 0xffffc488, 0xffffeec2, 0x877, 0xa9d, 0xfc1, 0x57a0, + 0x4879, 0x175a, 0xffffa0c0, 0x533, 0x8765, 0x2d23, 0x7ae9, 0x1d9e, + 0x16b2, 0x58c4, 0xffffe64f, 0xffff79ba, 0x68cd, 0x5c30, 0xffffb8e0, 0xffffc5d1, + 0xfffff04f, 0x5fec, 0x19ca, 0xffff8c02, 0x15ab, 0x8897, 0xffffebeb, 0x70d7, + 0x1662, 0x8c83, 0x8bc8, 0x21c8, 0xffffa728, 0x6513, 0xffff92f4, 0xffffadb2, + 0x7a29, 0xffffe450, 0x2136, 0xffffc6db, 0x26e, 0x8221, 0x3097, 0x5883, + 0xffffa134, 0x8284, 0xffffa6d9, 0x1c76, 0xffff8524, 0x164e, 0xffffa415, 0xffff841e, + 0x309d, 0xffffd4e1, 0xffff99a3, 0x4e11, 0xffff90a2, 0x51bf, 0xffffec39, 0xffff9073, + 0xe4e, 0xffff7a6a, 0x26b0, 0x64e4, 0x1a95, 0xffffeed3, 0x8049, 0x67b0, + 0x23e0, 0xffffb836, 0xf72, 0x2c0f, 0xffffacff, 0xffffa183, 0x87b8, 0xffff7e3a, + 0xffffef41, 0xffff796e, 0xfffffd33, 0x4c73, 0xffffd590, 0xffffdfac, 0xfffff5fb, 0xffff9594, + 0xffffba62, 0xffffa2d2, 0x496a, 0x1501, 0xffff9a7a, 0xffffc542, 0xffff8a89, 0xffffdda6, + 0xffff7f5e, 0xffffbf34, 0xffffe1e1, 0xffffb26c, 0xffffe9c3, 0x67cc, 0xffffb506, 0x6416, + 0x454, 0x3724, 0xffff9c3d, 0x2f27, 0x45cb, 0x670f, 0xffff7969, 0xffffdc9e, + 0xffff87e1, 0x1948, 0xfffffe4e, 0x1fdd, 0xffffe119, 0x5c64, 0xffffc383, 0x1062, + 0x6828, 0x6dd8, 0x2238, 0x12d5, 0xffffd611, 0xffff8739, 0x137a, 0x52c6, + 0x441c, 0xffffc74c, 0xffffee23, 0x583a, 0xffffd369, 0x3c68, 0xffff99a0, 0xffffb914, + 0xffffbe62, 0xffffcd86, 0x1438, 0xffffe64d, 0x53da, 0x2358, 0x89f6, 0x6e04, + 0x459f, 0xffffb2a5, 0xffffdaf4, 0xfffface2, 0x6673, 0xfffff8df, 0x594d, 0xffffeedd, + 0xffffa520, 0xffff8687, 0x70b0, 0x5dba, 0xffffe645, 0x3bbc, 0xffff8028, 0xffffea28, + 0xffffc7ba, 0x36ca, 0x7c40, 0x34ce, 0xffff7a62, 0x10bf, 0x5ee1, 0xffff98ab, + 0x10be, 0x3b49, 0x8c53, 0x8386, 0xffff7a09, 0xffff7a77, 0xffff7acd, 0x2cc4, + 0xffff93aa, 0x574, 0xffffc3ed, 0x2586, 0xffffeca4, 0x750e, 0xffffb075, 0x6308, + 0x67ac, 0xffffc8a3, 0x49c1, 0xfffff006, 0x89c9, 0x4f36, 0x3909, 0xffffd5d0, + 0xffffe4c1, 0xffff7a19, 0xffff8552, 0x7a2b, 0xffff9d63, 0x88e9, 0xfffffde4, 0x190a, + 0xffff826f, 0xffffecd9, 0x1983, 0xffffe551, 0xffff92e2, 0x2c5c, 0xffffd03c, 0x4adf, + 0x6865, 0xffff7e20, 0xffffea03, 0x841d, 0x4e37, 0x3d59, 0x3171, 0x673a, + 0x1afc, 0xffffa098, 0xffffde36, 0xfffffbbd, 0x47a5, 0x65be, 0x3738, 0x2beb, + 0x3e11, 0x6cff, 0x8da8, 0x22a6, 0xffffdf4a, 0x1151, 0xffffc349, 0x3485, + 0xffffee00, 0xffff864e, 0x865, 0x5989, 0x4145, 0xffff8999, 0xffff835e, 0xffffc2ad, + 0x2f00, 0xffffdc98, 0x7dfe, 0xffffc2fe, 0x1234, 0xfffff5da, 0xffffd55c, 0x119e, + 0xffff7dc3, 0xffffb27e, 0x7aae, 0xffff7b34, 0xffffde8e, 0x797, 0xffffab7e, 0xffffe6ce, + 0x7685, 0x600f, 0x7285, 0x6045, 0xffffe2f4, 0x69e7, 0xffffdfd8, 0x14a, + 0xffffda78, 0xffffabc0, 0x89c3, 0xffffbeac, 0xc37, 0x6df4, 0xffffe0d2, 0xffffc632, + 0xffffa62e, 0xffff8d46, 0xffff78fa, 0x3003, 0xfffff74e, 0x42a9, 0xffffe8d6, 0xffff7863, + 0x6a8e, 0xffff8696, 0x1844, 0xffffa06f, 0xd36, 0xffffd8d8, 0xffffe27c, 0x387e, + 0x30fb, 0xfffff762, 0x808a, 0x2d5b, 0x6717, 0xffffff14, 0x845b, 0xffff9586, + 0x68b, 0xffffe56f, 0xffff96b9, 0x6295, 0xffffb26c, 0x2a02, 0xfffffd8b, 0x6b98, + 0xffff8ca4, 0x501a, 0x5f44, 0xffffa9ac, 0xffffa063, 0xffff9030, 0xffff80d2, 0xffffcd8c, + 0x4c8c, 0xffffc0f8, 0x397, 0x819c, 0x767c, 0x7d99, 0xfffff123, 0x1b50, + 0x2c29, 0xffffd70f, 0xffffcca8, 0xffffa017, 0xfffff2b7, 0xffff74f0, 0xffffa9ed, 0x233b, + 0x1516, 0xffffbb9f, 0xffff97bc, 0x23c4, 0xfffff299, 0x7db1, 0xa52, 0xffff9161, + 0xffff8541, 0xffff75a7, 0xe20, 0x7dd3, 0xffffcc27, 0xffff9e5e, 0xffffe9ee, 0xb6e, + 0xffffe271, 0xffffe9e6, 0x6d72, 0xfffffd38, 0xffffa167, 0x6246, 0x83b, 0xffffa571, + 0xaeb, 0xffff8759, 0xffffa37f, 0xffffea7c, 0x6061, 0x8b6c, 0xffffb904, 0xffff88ea, + 0xffffa8f7, 0xffffd266, 0xffffa1bf, 0x343a, 0x6f9c, 0xffffd56b, 0x37ef, 0xffff8566, + 0x4eb7, 0xffffd9b3, 0xffffd22e, 0x8af7, 0x1d78, 0xfffff575, 0x391e, 0x4836, + 0xffffeaf1, 0xffff89a2, 0x6ac6, 0x611f, 0x8458, 0x2af6, 0x588f, 0x8e5, + 0x8bf6, 0xffffac56, 0x35d8, 0x6e0, 0x371b, 0xffff7743, 0xffffc693, 0x146c, + 0xffff80e3, 0xffffb207, 0xffffe58c, 0xffff8e50, 0xffffb07b, 0xfffff121, 0xffff9b54, 0x5dd4, + 0x700d, 0xffffe8a8, 0xffffdc38, 0xffffe745, 0x3734, 0x1db6, 0xffff8353, 0xffff7e3b, + 0x8eb, 0x6019, 0x2c5c, 0xffff8bd0, 0x8a7f, 0x7bc1, 0xfffff710, 0x4002, + 0x3650, 0xffffce4a, 0xffff7cce, 0xb70, 0x359a, 0x3013, 0x362, 0xffffa441, + 0x5b8e, 0xfffffe99, 0xffff7813, 0x7fdf, 0xffff8fc1, 0x5912, 0xffff8122, 0xfffff92a, + 0xffff8c22, 0x46a0, 0x5d05, 0xffffc4c0, 0xffffbc37, 0xffff9f62, 0x3103, 0xfffffb57, + 0xffffdf3b, 0xffffbde0, 0xffffe2fd, 0xffffcb24, 0x7291, 0xffffc112, 0x305d, 0x60f4, + 0xffffc8ae, 0xffff7574, 0xffffe0d9, 0xe58, 0xfffffeba, 0x66e, 0xffff8463, 0x8643, + 0xffffa427, 0x405e, 0xffffa5f5, 0xffffcb8f, 0xffffb04c, 0xffff79aa, 0x1a22, 0xffff896c, + 0xffff7d81, 0x7bda, 0x6989, 0x3996, 0x870e, 0x3a69, 0x3b4a, 0xffff9e08, + 0x2c97, 0x7ebd, 0xffffbf71, 0x1973, 0xffffdf6b, 0xffffbad9, 0x196a, 0x81e8, + 0x1c4, 0x61c5, 0x76e9, 0x25c5, 0x5131, 0xffff9e6e, 0xffff9637, 0xffff7d1a, + 0x5111, 0xffffff97, 0xffff8424, 0xffffbf3b, 0xffffb4f9, 0x2eaf, 0x7b44, 0x409e, + 0xffffe706, 0x1099, 0x328c, 0x401c, 0x2e7, 0x5b34, 0xffffd2f2, 0xffff9853, + 0xffff7804, 0xfffff344, 0xfffff283, 0x8ce9, 0xffff8fc2, 0xfffff155, 0xffffe2fe, 0xffff9d35, + 0x846f, 0xffffe3cf, 0x53f2, 0x67e4, 0xffffb405, 0xffff9c2a, 0x69a7, 0xfffff279, + 0xffffcd7b, 0xffffe05c, 0x5f40, 0x7110, 0x5c7d, 0xffffc8b4, 0xffffb97c, 0xfffffd3e, + 0x6b8f, 0xffffa8f4, 0xffffe8d7, 0xffffee7e, 0xa4e, 0xffff8a06, 0x4499, 0x65, + 0xffff9c0e, 0xffffdb63, 0xffff9123, 0x1fdb, 0x424a, 0xffffecca, 0xffffbde3, 0xb4, + 0xffffd7b7, 0xffffbb82, 0xffffa8bb, 0xffffcf0c, 0x1c1, 0xffff87e5, 0xfffff7cc, 0xffffc4dd, + 0xfffff3f1, 0x86c6, 0x3063, 0xffffbf8c, 0x2ddf, 0x7a9, 0x3d41, 0xfffff150, + 0xffff9224, 0xffffe905, 0xffffbd32, 0x76c2, 0x4021, 0xffff86cd, 0xffff895a, 0xffffd092, + 0x3b93, 0xffffbf5b, 0xffffe7f1, 0x44e, 0x7e09, 0x514f, 0xffffdae2, 0xffff8ae4, + 0xffffd626, 0x8cf6, 0xffffc1e5, 0xffff8d3e, 0xffffc16c, 0x5b5, 0xffff8d48, 0x264a, + 0x6750, 0x5f3f, 0x442e, 0xfffff88b, 0xffffe7d2, 0x73ce, 0xffffffac, 0x3302, + 0x5125, 0x590c, 0xffffe068, 0xffffb765, 0x473d, 0xffffd9cc, 0x9ae, 0x3ae0, + 0xffffdd98, 0x4346, 0xbe1, 0x506e, 0xffffe5dd, 0xffff8b4d, 0x6ac3, 0x89a1, + 0x229b, 0xffffa8bf, 0xffffb463, 0xffffb8aa, 0xffffb1bb, 0xffff8205, 0x76ba, 0x1117, + 0xffffae9e, 0xddf, 0xffffaf93, 0x1661, 0x490b, 0xffff798e, 0x4d5f, 0xffffbca8, + 0x13c4, 0x814a, 0x8340, 0xfffffe42, 0xffffc27f, 0xb42, 0xffffbeae, 0x39a3, + 0x5caa, 0xffffd38d, 0x2dba, 0xfffffe91, 0x5451, 0x768d, 0x827a, 0xffffbf93, + 0x5ff2, 0xffffeaa2, 0xffffb0fc, 0x677a, 0xffff758a, 0xffffbcc6, 0xffff9166, 0xffff9b70, + 0xffffa468, 0x36bf, 0xffffbf31, 0x2f3d, 0xffffd890, 0xfffff4af, 0x3b4b, 0xffffc047, + 0xffff98b3, 0xffffea02, 0xffff9ed7, 0x45b0, 0x8c73, 0xffffa371, 0xfffff4fa, 0xffffe309, + 0x3fce, 0x3020, 0x7e45, 0x40bb, 0x506c, 0x63a1, 0x52cd, 0xffff7a93, + 0x3108, 0xffffbf0a, 0xffffe87a, 0xffff782f, 0xffffcb8e, 0x3e37, 0x619a, 0xfffff75a, + 0xffffeb8a, 0x621f, 0xffff87fb, 0x594b, 0x70ee, 0x519c, 0xfffffa39, 0x540b, + 0xffff9ea8, 0x5321, 0xffff9ba2, 0xffff8804, 0x1049, 0x6249, 0xffffc186, 0x6915, + 0x45ba, 0xffffc569, 0x1275, 0x1141, 0xffff7d0c, 0xfffff6a0, 0xc88, 0xffffd0cf, + 0x5493, 0xffffca10, 0x8ba5, 0x5479, 0x56a5, 0xffff72c4, 0xffffc49a, 0x1f28, + 0x26e2, 0x1842, 0x5690, 0xffff8ee0, 0xffff7d53, 0x1896, 0xffffbaf2, 0x724a, + 0xffffc881, 0x2913, 0xffff8e93, 0x1318, 0x288c, 0xffff985d, 0x70ef, 0xffffaa46, + 0x114b, 0x5357, 0x36e9, 0xffff8651, 0xffffb4bb, 0xffffd3a5, 0xffffe071, 0xffffbc9d, + 0x6d70, 0xffff93f4, 0xffff939a, 0xffffbf01, 0xffff9dd5, 0x3632, 0x22dd, 0x290a, + 0xfffff94e, 0xfffffd3f, 0x240b, 0x1dd7, 0xfffff422, 0xffffedb5, 0xffffae3f, 0x3131, + 0xffffb91a, 0xff0, 0xffffa875, 0xffffc56b, 0x7819, 0x2174, 0xfffffc53, 0xfffff477, + 0x6134, 0x4655, 0x94, 0xffffd1ee, 0xffff7e80, 0xffff82ef, 0xffffff54, 0x7000, + 0x1e7c, 0xffffc0d0, 0x84a4, 0x5a2, 0xffff7ba9, 0xffffd915, 0xffff757e, 0x2b2b, + 0x2182, 0xffff9958, 0x3d0d, 0xffffe4af, 0x5c62, 0x7512, 0x4e8, 0xffffa6ed, + 0x2f28, 0xffff8ff9, 0x1a0f, 0xffffd103, 0xffff85f6, 0x69f7, 0xffffb04f, 0x41fe, + 0xffffbc7e, 0x427b, 0xffffa03e, 0xffffee6f, 0xffff9910, 0xffffa897, 0xffff7e20, 0xffffc977, + 0x266c, 0xffffd8e3, 0x3c0a, 0x22b0, 0xffff92ff, 0x1b5d, 0x24f4, 0x3bb7, + 0x425b, 0xffff90a5, 0xffffb687, 0x156d, 0x58ef, 0x1b16, 0xffffd3e1, 0x582, + 0xffffb1b1, 0x691d, 0xfffff853, 0x4c0a, 0x4887, 0xfffffa27, 0xffffbdae, 0xffff8d31, + 0xfffffdb2, 0xffffd009, 0x6287, 0xfffff1ff, 0xffffa748, 0xffffccdf, 0xffffa977, 0x16dd, + 0x281e, 0x8047, 0x66a, 0x2c5a, 0xffff86b5, 0x854a, 0x2a5a, 0x70dd, + 0xfffffeb6, 0x873f, 0xffffdd1a, 0xffffaa65, 0xffff8ca8, 0xffff83da, 0x67c9, 0x4745, + 0x1b41, 0xffffebf0, 0xffff740b, 0x30d7, 0x2afa, 0xffff761e, 0x5539, 0x23e9, + 0xffffabd8, 0xffff931a, 0x408b, 0xfffff2cb, 0x67dc, 0xffff7807, 0xffff964a, 0x5288, + 0xffffc66d, 0x2366, 0x148e, 0x38cb, 0x157f, 0xffff8346, 0xffffb678, 0xffffc4f2, + 0x1549, 0xffffcdb8, 0xffffc5b7, 0xffffd59b, 0xffffd217, 0x6f4e, 0xffffb9ba, 0x8263, + 0xfffff2df, 0xffffd860, 0xffffd9d7, 0xffff9597, 0xffffec05, 0xffff81f3, 0x8be0, 0xffffe4a7, + 0xffff85a4, 0x2fc4, 0x86e9, 0x701, 0x61d3, 0x69ff, 0xffff7563, 0xffff76ce, + 0xffffc010, 0x822f, 0xffff7b66, 0x5e31, 0xffffc663, 0xfffff119, 0x15f0, 0x85d0, + 0x28f1, 0x3fd6, 0xffffa127, 0xffff9166, 0xffffb044, 0x2e04, 0x322c, 0xffffb132, + 0xfffff73e, 0xffffb6b0, 0x3ea8, 0xffffac4d, 0x4a5b, 0xffffa5e8, 0xffff7697, 0x16e, + 0x49ca, 0x1272, 0x4a93, 0x44ce, 0x53e2, 0xfffff35b, 0xffff778a, 0xffffd189, + 0xffffb7e4, 0x90c, 0xffff8795, 0xffff96e2, 0x73ed, 0x3b2c, 0x5db2, 0xffff761f, + 0xffffdc8b, 0x4a06, 0xffffa033, 0xfc9, 0xffffe5e2, 0x7fed, 0xffffca3a, 0x218d, + 0xffffcb3d, 0x2af8, 0xffffb770, 0x8b27, 0xffffcd03, 0x8615, 0xffff7dd4, 0xffff7494, + 0x7f51, 0xffffdf3d, 0xffffbc52, 0xffffa686, 0xffffe0e6, 0xffffd409, 0xffffcd88, 0x5d0f, + 0x6c9c, 0x77ed, 0x69e2, 0x30b8, 0xffff894c, 0xffffe9c1, 0xffffa2b0, 0xffffff92, + 0xffffeecb, 0xffff7486, 0xfffff3a4, 0x4b1a, 0x15cf, 0xffffd171, 0xffffce83, 0xffffb1f3, + 0x2d8f, 0xffffa1a2, 0xffff90d0, 0x10a2, 0x4e89, 0xffff730e, 0xffffb689, 0x8bf3, + 0xffffc917, 0x3a3c, 0x28c6, 0x7a05, 0xffffc793, 0xffff944b, 0xffff8c4f, 0x13b6, + 0x6540, 0x3b3c, 0x1b68, 0xa31, 0xfffffce2, 0xffffa0f0, 0x4d63, 0xa6, + 0x290, 0xffff7f48, 0xffffb06c, 0x5986, 0xffffe2e9, 0xffffe281, 0x6fd1, 0xffff9467, + 0xffffa53c, 0xffffda9c, 0xfffffb90, 0x8a9b, 0x55f2, 0x646f, 0x517f, 0xa33, + 0x1a6, 0xffff8fda, 0xffff890b, 0xffff81f3, 0xffffaac7, 0xffffd83a, 0x7f, 0x2782, + 0x6083, 0xfffff711, 0xffffe8c7, 0x5553, 0x55b7, 0x4d1, 0x56e4, 0xffff8f89, + 0xffffbab6, 0xfffff28b, 0x232b, 0x5139, 0xbe4, 0x3b5e, 0xffffa73f, 0xffffdf16, + 0xcce, 0x5e29, 0xca2, 0xffffd78f, 0xffff861d, 0xffff8ef5, 0x63a9, 0x3d30, + 0xffffb006, 0xffffa007, 0x4596, 0x2801, 0x4936, 0x2816, 0x3f0a, 0xffff92c9, + 0x145, 0x4f85, 0x2c8, 0xc72, 0x36a8, 0xffff81cf, 0xffffeffc, 0xffffde3f, + 0xffffd5f2, 0x5692, 0x60d4, 0x4861, 0x339d, 0x6449, 0xffffdd43, 0xffff8c56, + 0xffffeb4d, 0xffff98b3, 0xfffff4cf, 0x455a, 0xffffb995, 0xffffce66, 0x1dce, 0x1f3e, + 0xffff92ea, 0xfffff303, 0x5783, 0x4aae, 0x29e6, 0xc20, 0x78b9, 0xffff878d, + 0x637, 0xffffb102, 0xffff7e5e, 0x6193, 0x5e68, 0xffffd7d8, 0x654c, 0xffffe71d, + 0xfffff721, 0x339e, 0xffff7e57, 0x5529, 0xfffffcf2, 0xffffe584, 0x26cf, 0xffffce2b, + 0xffffff6b, 0x6600, 0xffffe4e1, 0xffffb27a, 0xffff7760, 0xffff8f2d, 0xffffb0b8, 0xffffc68b, + 0x6907, 0x1110, 0xffffef9b, 0x27, 0xb8d, 0x2872, 0xffffc27e, 0x1bfd, + 0x123a, 0xffffdb77, 0xffffa828, 0x4f0a, 0x6fd6, 0xffff7358, 0xffffafee, 0xffffc050, + 0xffffc121, 0x2dc7, 0xffffe42c, 0x8dbf, 0x2698, 0x7efd, 0xffff98d6, 0xffff9eea, + 0xffffec08, 0x16a3, 0xd9f, 0x6ccb, 0xffff7e32, 0xffff7561, 0x6907, 0x651b, + 0xffff9d8d, 0xffff826f, 0x5a7e, 0x7a70, 0xffff9108, 0x54c, 0x84d0, 0x4a6e, + 0xffffc829, 0x5726, 0xffff9518, 0xffffeb06, 0xdcf, 0x143d, 0x385a, 0xffff8005, + 0xfffff2a7, 0xffffcd4e, 0xffff8b6d, 0xffffec7a, 0x536b, 0xffff8148, 0xffff7ff7, 0x3098, + 0x6fd7, 0x6a8c, 0xffff83fd, 0x52ca, 0x8cc1, 0x251c, 0x3fd6, 0xffffd96c, + 0x26de, 0x710, 0xffff9146, 0xffff9808, 0xffff790a, 0x46c7, 0xffff9cf3, 0x290d, + 0xffffe6b9, 0xffff9078, 0xffff75f7, 0x678a, 0xfffff708, 0x26f2, 0xfffff7aa, 0x583f, + 0x2e8f, 0xffffb64c, 0xffffc0bc, 0xffffa35b, 0x264a, 0xffffc82c, 0xcfc, 0x7d89, + 0x11e0, 0xffffce25, 0xffff9499, 0xffff7aa5, 0xe3c, 0xac7, 0x81c5, 0x7159, + 0x8c01, 0xb5c, 0xfffffc6c, 0xffffa6c9, 0x8249, 0x7524, 0xffff735e, 0xffffce06, + 0x10c7, 0x6334, 0xffff7b8d, 0xffffa314, 0xffffce5d, 0x4f8f, 0x3a7e, 0x277f, + 0x17b8, 0x8cd8, 0xffff9909, 0xffffc891, 0x5de9, 0xffffc012, 0x54d6, 0xffff8015, + 0xffff90d5, 0x15d, 0x703e, 0x3236, 0xffffdd2d, 0xffffca7a, 0x43c6, 0xb61, + 0x6fd2, 0x336c, 0xffff9509, 0xffffa109, 0x17f4, 0x18a4, 0x38d9, 0x6b5e, + 0xffffe932, 0x1fee, 0xffffd6a5, 0xffffeb7f, 0x5284, 0x1655, 0x15c9, 0x1fc6, + 0x6cd5, 0xffffa187, 0x60f5, 0x7248, 0xffff814d, 0xd14, 0x884e, 0xffff8616, + 0xffffab6c, 0x8c75, 0x1005, 0x57fc, 0xffff9c74, 0x84f, 0xffffb6a1, 0xffffd988, + 0xffff7530, 0x782, 0xffffa7be, 0xffff9cf5, 0x1497, 0xffffd560, 0xffffe680, 0xffffdf92, + 0x2ead, 0x8694, 0xffff9c30, 0x3b22, 0xa82, 0x1f5d, 0xffffba52, 0x5743, + 0xffffb4ee, 0xffffd01e, 0x119a, 0xffff7eff, 0x86da, 0x3771, 0xffffbc56, 0xffff89e1, + 0x483, 0xffffdbd8, 0xffffc090, 0x225, 0xac3, 0x4c86, 0x26f7, 0xfffff1fa, + 0xffff76a6, 0x2bb6, 0x6553, 0xffffb0ba, 0x1b0e, 0x4f6f, 0xffffc8f3, 0x787f, + 0x8416, 0x392, 0x18cd, 0xffff8c51, 0xffffb50d, 0xfffff2e8, 0x74bb, 0xffffc84a, + 0xffffca8d, 0xffff8508, 0xfffff79a, 0x5867, 0xffffbde9, 0xffffc76c, 0x5966, 0xffffa1a3, + 0x3ef6, 0xffffaf76, 0xffffb2a6, 0x62b4, 0xffffaf21, 0x1f61, 0xffff8de2, 0x6ae4, + 0x1711, 0x2848, 0xffffc6e4, 0xfffff285, 0xffffce37, 0xfffff33d, 0x10fa, 0x14a2, + 0x8c4b, 0x56d5, 0x6170, 0x2ce9, 0x10d8, 0x350e, 0x3e1e, 0xffffa4e0, + 0x5090, 0x8035, 0x43bb, 0xffffc129, 0x1cdb, 0x7cf4, 0x5897, 0xffffe38a, + 0xfffffda4, 0xffff8f8f, 0x1711, 0x73fe, 0x641b, 0x24f7, 0x53da, 0x3e9d, + 0xffffdd78, 0xffff857b, 0x34e7, 0x7881, 0xffffecc8, 0x80b8, 0xffffd388, 0xffffe600, + 0xffffea29, 0xffffecc9, 0xffff8b09, 0xfffffb67, 0xffffa4ea, 0x6e11, 0x631b, 0x332, + 0xffffcdfd, 0x1236, 0xaf1, 0x720, 0x2ab7, 0xffffa89c, 0xffffeab4, 0x65c1, + 0xffffff40, 0x203b, 0x2c2, 0x4c30, 0xffff94df, 0xffffe58b, 0x71fa, 0xffff8350, + 0xffff888f, 0x33d, 0xffffa878, 0x3d07, 0x199c, 0x644b, 0x5d3d, 0x2c5, + 0x783b, 0x855d, 0xfffffe0f, 0x29cf, 0x4bcf, 0x2631, 0xfffff8a4, 0xffffdd94, + 0x1d61, 0xfffffafc, 0xffff7e05, 0x24a0, 0xffff8a5a, 0x262a, 0x5c5b, 0x229f, + 0xffffe6a8, 0xffffcde6, 0xffffa684, 0x178, 0x37cf, 0x534, 0x190a, 0x86d9, + 0xffffd70b, 0xdf9, 0x8a0d, 0x7218, 0xfffff793, 0x420e, 0xffffa733, 0x811f, + 0xffffa1b0, 0x8cfc, 0xffffb39f, 0xffffb277, 0x8c8d, 0x188, 0x4b59, 0x660c, + 0xffffc5c1, 0xffffc2c9, 0xffffe996, 0x2fd7, 0x1650, 0x6209, 0xffffa6a9, 0x4c28, + 0x7291, 0x587e, 0x4ef5, 0xffffaa02, 0xffffb81c, 0xc34, 0xffff79d4, 0xbe0, + 0x6bc9, 0x49c7, 0xffffb6eb, 0x120a, 0x455f, 0xffffa242, 0x19e1, 0x5b62, + 0x5cec, 0xffff8be5, 0xfffff857, 0xffffc764, 0xa02, 0xffff8856, 0x702c, 0xffff7b18, + 0xffff85d1, 0xdb3, 0x6296, 0x3ef2, 0x55a0, 0xffffe47a, 0x3213, 0xffffdcb1, + 0x2a00, 0x2c6d, 0xfffff530, 0x77d2, 0xfffff051, 0xffff82cc, 0xffffe0f7, 0x603e, + 0xffffcdcf, 0x3ee8, 0xffff9788, 0x4ee3, 0xffff8a08, 0x44d7, 0xffffae63, 0xffffa7bc, + 0x151e, 0x5de1, 0xffffe129, 0x7ec1, 0xffff82e1, 0x7a8a, 0xffff7c0f, 0x866a, + 0x1c48, 0x63fd, 0xfffffdf7, 0x681d, 0xffffeb26, 0x6d6c, 0xfffff7b5, 0x63e, + 0xffffcbab, 0xffffedcd, 0xffffe5d6, 0x4967, 0x834b, 0x28eb, 0x6365, 0x7e4b, + 0xffffd7aa, 0xffff759e, 0x5cad, 0x22f6, 0xffffa019, 0xffff7a60, 0xffffb158, 0xffff9830, + 0xffff88fa, 0x5381, 0xffff9edf, 0xffffb70e, 0xffffb5e0, 0x28b9, 0xffffd778, 0x4aa9, + 0x1029, 0x4de8, 0x85a, 0xffffa5af, 0xffff9598, 0x694a, 0x442f, 0xffffc325, + 0x1646, 0x40b4, 0x51b0, 0x50c4, 0xfffff810, 0x6afc, 0x1611, 0x7c33, + 0x2c36, 0xffffadd9, 0xffffff75, 0xffffa472, 0x2a6f, 0x1ea3, 0x5389, 0x42ec, + 0xffff7734, 0x10df, 0x7e19, 0xffffbe25, 0x45dc, 0x52d1, 0xffff7b84, 0xfffff9d9, + 0x202c, 0x6f8c, 0xffff96b0, 0x4581, 0x13a9, 0x7c2c, 0x2c73, 0x456a, + 0xffff90d7, 0xffff918e, 0x4daf, 0xffff883f, 0x292d, 0xffffd140, 0x4599, 0x7022, + 0x6e51, 0x6fd8, 0xffffcc81, 0x55a, 0xffffb012, 0xffff8234, 0xffff8e12, 0xffff866e, + 0xffff82ab, 0x3a12, 0x77f1, 0xffff8e5c, 0xffffb9db, 0x8114, 0xffffb4d1, 0xffffaa27, + 0xffffef2b, 0x512b, 0xfffff599, 0x2614, 0xffffec61, 0x2e53, 0xffffe14a, 0x8762, + 0x15ea, 0xffffa04a, 0xa9c, 0x3db3, 0xffff9da7, 0x1ba7, 0x6f1, 0x7046, + 0x40d8, 0x2807, 0xfffff498, 0x4003, 0xb8b, 0x80d9, 0xffffc968, 0xffffb091, + 0x6a11, 0x575d, 0xffffbd30, 0x59b7, 0xffffec68, 0x3bc3, 0xffff9852, 0x8d97, + 0x3bdd, 0xffff7b05, 0x3a08, 0x796a, 0xffffde73, 0x23d7, 0xffff937c, 0xffff8364, + 0x2c86, 0xfffff529, 0xffffb941, 0x4f9f, 0x300a, 0xffffb69a, 0xffff8ae2, 0xffff76f4, + 0x6281, 0xffff7a7f, 0xffff8cae, 0x6a9b, 0xffffc3e3, 0x6b24, 0x1a7f, 0xffffbbaa, + 0xffff9898, 0xfffff100, 0xffff9a77, 0xfffffeb5, 0x8062, 0x26f6, 0x72a6, 0x82a8, + 0xffff8d48, 0xffffad0b, 0xffff78ed, 0x39d9, 0xffff8cbd, 0xffffe4fb, 0xffff73d3, 0xffff8749, + 0xffff7787, 0x186d, 0xffff8a66, 0xffffd430, 0x675d, 0x6208, 0x1e0a, 0xffffd207, + 0x7627, 0x272d, 0xffffe162, 0xffff7f78, 0xffff97cd, 0xffffe52f, 0xffff9648, 0xffffbde7, + 0x4a2, 0xffffab13, 0x408e, 0xffffaf5a, 0xfffffccf, 0xffffcaee, 0x3ce9, 0xffff9f86, + 0xffffbdf6, 0x6f7d, 0x1ac0, 0xffff7d8f, 0xffffb5f4, 0x15d5, 0xffffb317, 0xffff8d69, + 0xffffd179, 0xffff9256, 0xffffaed4, 0xfffffd69, 0xffffe67c, 0x8a5d, 0xffffb985, 0x7bd5, + 0x1eaa, 0xffff7ea6, 0x7a6, 0xffffcc73, 0x45fe, 0xffff9312, 0xffff8963, 0xffffcd75, + 0x3534, 0x29af, 0xffffa890, 0xffff81d1, 0x3c3a, 0xffffcbc4, 0x43ba, 0x320c, + 0x70c6, 0x2ec5, 0x189d, 0xffff768f, 0xfffffcf4, 0x3ea8, 0x8212, 0xffffabef, + 0xffffc162, 0x22d4, 0x5755, 0xffffc5a0, 0x87f4, 0xffffb7da, 0xffffa9f3, 0x6eb4, + 0x1abc, 0x5caf, 0x3043, 0x4be4, 0x557b, 0x18e5, 0x2499, 0x7f, + 0xffffcd2d, 0xffffd93e, 0x3af4, 0xffff8c49, 0xffffc5a9, 0xffffb1ba, 0xffff9c0c, 0x18ba, + 0x2cbe, 0xffff8efc, 0xffffa34b, 0x3b05, 0x49d, 0xffffe7b4, 0xffffd9de, 0xfffff909, + 0x5f8, 0x3651, 0xffff7d02, 0x5eda, 0xffffb6f3, 0xffffaa6d, 0x201e, 0xffffc0d0, + 0xd3c, 0x11dd, 0x8c01, 0xfffff81f, 0x84fb, 0xffffe312, 0x7cdc, 0x6d33, + 0xffff8b40, 0x79af, 0xfffff0d5, 0xffffe4ee, 0x73a8, 0x20e6, 0xffff927f, 0x8592, + 0xffffb092, 0x5012, 0x76b, 0xffffa971, 0x8ba1, 0xffffb512, 0x22f3, 0x8ae3, + 0x4217, 0x70e6, 0xffff8854, 0xffffa794, 0x69dd, 0xffffea58, 0x30f6, 0xffffa42d, + 0xffff9908, 0x5e1e, 0x2fd4, 0x329, 0x775a, 0xffff95b2, 0xffffa71e, 0xde7, + 0x2e22, 0x776e, 0x16d4, 0xffff8616, 0xffffb167, 0xffff85b5, 0x57da, 0x72eb, + 0xffffbaf7, 0xffffc299, 0x59ef, 0xfae, 0x1907, 0x4adb, 0x7242, 0x5bd3, + 0x189e, 0x5ad4, 0xffff8e3c, 0xffffedaa, 0xbe0, 0xffffffdc, 0xd45, 0x2ef8, + 0xffff7cd2, 0xffffaddd, 0x685a, 0x832e, 0xffffcf75, 0xffffd4dd, 0xbd6, 0x149f, + 0x3cdb, 0x7691, 0xffffc1e2, 0xffffa1c4, 0x7548, 0xffffa014, 0xffffe53b, 0xfffff6f1, + 0xffffeecb, 0xffffa681, 0xffffafc8, 0x6811, 0x875b, 0x1578, 0xffffdcbe, 0xffff8206, + 0x483f, 0xffff7c5c, 0xffffbf83, 0x2b71, 0x7789, 0xffff733b, 0xffffe5d4, 0x5b88, + 0x7751, 0xffffc109, 0x4a86, 0x7284, 0x67d8, 0x28d4, 0xffffa41e, 0xffff7baf, + 0x761d, 0xffffff5a, 0x3e9e, 0x4e25, 0x2a7a, 0xfffff846, 0xffff873f, 0x43a9, + 0xffffeeea, 0xffff840b, 0x716f, 0xffffacf0, 0x5da3, 0xffffb902, 0xffffaf05, 0x4b57, + 0x73da, 0xffff956d, 0x4cf1, 0x7716, 0x33dd, 0x464, 0xffffeb6c, 0x4007, + 0xfffff3b4, 0x1fe3, 0x721, 0xffffe758, 0xffffabb3, 0x19d8, 0xffffbc97, 0xffff751d, + 0x7cc7, 0xffffb5e3, 0xffff8625, 0x8590, 0xffff8fb2, 0x168b, 0x8a88, 0x5368, + 0x7a0a, 0xffffff50, 0xffff7c26, 0x2c26, 0x5a95, 0xffffd991, 0x19e2, 0xffff7a6d, + 0x3e4b, 0x2e49, 0x4b7a, 0xffffcaf0, 0xffffff91, 0x1fc2, 0x4ed5, 0xfffff2a5, + 0xffffcc85, 0x52ac, 0xffffcef3, 0x13ae, 0xffff7590, 0x4c03, 0x860a, 0x1715, + 0xfffff3b6, 0x3e42, 0xec, 0x5e30, 0x7f7b, 0xffff8325, 0xffffcc59, 0x3c5a, + 0x1730, 0xffff84b9, 0x543c, 0xffffc431, 0x210c, 0xffffff67, 0x3247, 0x78fa, + 0x6646, 0xffffb35a, 0xffffebe6, 0x74d8, 0xffff7d83, 0x696b, 0x2502, 0xffff898c, + 0xffffa4a3, 0xffffe1a7, 0xffffd2c6, 0xfffff1db, 0x8425, 0x4794, 0xfffff992, 0x5bec, + 0xffff999e, 0x4e2, 0xffffa80f, 0xffffee33, 0x6505, 0xfffffe03, 0xffffb529, 0x14ad, + 0xffff8511, 0xffffd437, 0xffffd6f4, 0xffffa716, 0x6fbe, 0xffffb2c5, 0x28fb, 0x9a7, + 0xffff72d3, 0xffffe490, 0x7ad4, 0x534e, 0x883e, 0x69a3, 0xffff9ebc, 0x36c1, + 0x3ac1, 0x8cc2, 0x4363, 0xffff980d, 0x42a1, 0xffff94ce, 0x7fa5, 0x59d0, + 0x2d35, 0xffffaddc, 0xffffc82e, 0x679d, 0xffffff04, 0xfffff390, 0x75c1, 0xfffff28e, + 0xffff8261, 0x7609, 0x6cc6, 0xffffeb00, 0xffffcdb1, 0xffff97c2, 0x2ec8, 0x7a4d, + 0x5a53, 0x4a2b, 0xfffff160, 0xffff7c7e, 0x8af1, 0xffffa8aa, 0x8a2, 0xffffd8c4, + 0x15e7, 0xffffa490, 0x35bb, 0x3846, 0x8b8f, 0xfffff39f, 0x115f, 0x26ed, + 0x3580, 0xffffdd48, 0xffff763b, 0xffffa8ec, 0xc2d, 0x7e4, 0x73c, 0xffffec28, + 0xffffb1ff, 0xffffd69c, 0xecc, 0xffff8a47, 0x1570, 0x5278, 0x7478, 0xffffa96c, + 0x87f7, 0x6c6d, 0xffff9c2a, 0x3e44, 0x4451, 0xffffe66f, 0x77a7, 0xffffa196, + 0xfffff4c8, 0x4d8, 0xffffda98, 0xffffb107, 0xffffe5f6, 0xffffd073, 0xfffffb60, 0xffffd970, + 0x7134, 0x1b66, 0xfffffed6, 0xfffffffb, 0x2f5d, 0xffffc33f, 0xffffb63a, 0x17aa, + 0xffffb6c7, 0xffffb5dd, 0x9a7, 0xffffb6ee, 0xffffce02, 0x4f50, 0xefc, 0xffffe4de, + 0xffff9e9b, 0xffffd397, 0xffffabfb, 0x771d, 0x7313, 0xffff8f5d, 0xbc, 0xffffa767, + 0xffff7a43, 0x1a04, 0x7e99, 0x5029, 0x2c61, 0xffffcf61, 0x6e6f, 0xffff8786, + 0x832e, 0xfffff079, 0x76f0, 0x6720, 0xb72, 0xffffc9bb, 0xffffb384, 0x8b40, + 0x4f6f, 0xffff9c0e, 0xffff7248, 0x8721, 0xffffb61c, 0x3264, 0x4af3, 0x26fa, + 0xffff78cb, 0x3f99, 0x519b, 0x3d38, 0xffff9e3c, 0x6363, 0xfffff082, 0x61, + 0x80e3, 0x882c, 0x1ad9, 0xfffff42c, 0xffffe5d7, 0xffff78aa, 0x7f81, 0x6333, + 0xe4b, 0x99, 0xfffff37c, 0xffffd8b0, 0x5f1f, 0xffffa399, 0x2fe4, 0x413f, + 0x2fb, 0x2d48, 0xffff9550, 0xffffd960, 0x8c72, 0xffff83f3, 0x3d50, 0x85ec, + 0xffffb965, 0x1cdd, 0xffff8626, 0xffffa6c0, 0xffffa058, 0xffffb314, 0x77c1, 0xffffa6dc, + 0x73d6, 0xffffbbbb, 0xfffffbf9, 0xffffcf13, 0xffffd10c, 0x8c3e, 0x5f5c, 0x4af5, + 0xffffd141, 0xffffd407, 0xffffc119, 0xffff86b0, 0xffffb16c, 0xfffff4f1, 0x404a, 0x6bab, + 0xffff9021, 0xffffd5f5, 0xffff87b0, 0xfffffb85, 0xffffbc33, 0x3ef, 0x16dd, 0xfffffc0a, + 0x346, 0xf7b, 0xffffb212, 0xffffe5b9, 0x1c45, 0x5a37, 0xffff8f95, 0xffffccda, + 0x11d2, 0xffff74a0, 0x52c1, 0xfffff70b, 0xffff90dd, 0x5ab1, 0x3ecb, 0x70d0, + 0x8ac4, 0xedb, 0x1091, 0xffff874d, 0xffffdce4, 0x4603, 0x157f, 0x4db, + 0xffffb596, 0x5604, 0xffff7a31, 0xffffe7e6, 0x3bc2, 0x1ec0, 0x861, 0xffffbb57, + 0xfffff94b, 0xffff9fb4, 0xffffea52, 0xfffff479, 0xffff9909, 0xffffa95f, 0xffffa074, 0x8889, + 0x198b, 0x56f4, 0x3423, 0x8241, 0xffffe3ff, 0xffff881a, 0x4e97, 0xffffcf1b, + 0xffffa603, 0x3957, 0xfffff6d5, 0xfffff0b2, 0x8464, 0x1f13, 0xffffe04e, 0x3ed2, + 0x1636, 0x19df, 0xffff9d9c, 0xffffb4af, 0xffff764e, 0x787f, 0x42a6, 0xffffda01, + 0x5a29, 0x8d78, 0x5fae, 0xffffe92e, 0xfffff130, 0x7c51, 0xffffbf50, 0xffffb867, + 0x2ddf, 0xffffb349, 0xffffd0e9, 0x6b0b, 0x6d50, 0xffffd468, 0xffffa3b0, 0xffff97d8, + 0x1960, 0xffffdbbb, 0xffffa4af, 0xffffbd37, 0x2ef3, 0x2437, 0xffffd17e, 0x13e5, + 0x54e0, 0xffffc59f, 0x22bb, 0xffff780f, 0x6239, 0xffff7d96, 0xffffda9d, 0x6e34, + 0xfffface6, 0x295a, 0x2719, 0xffffda03, 0xffffabc0, 0x23a3, 0x1cf2, 0xffffaa50, + 0xfffff1aa, 0x6565, 0x75b1, 0xffffc795, 0xffffb3d6, 0xffffac07, 0xffff8ab8, 0xffffe135, + 0x6be2, 0xffff9a21, 0x66be, 0x1ede, 0xffff9b45, 0xffffddb2, 0x19d9, 0xffff9a42, + 0x1470, 0xfffffd5c, 0x1e7e, 0x6407, 0x6ab4, 0x9cd, 0x1ce7, 0x7246, + 0xffffcc0e, 0x334a, 0x8d32, 0xffffdd26, 0xffff876d, 0x5f42, 0xffffce4d, 0x746f, + 0x23a2, 0xffffbddd, 0x1b98, 0xffffc9e3, 0xffff921c, 0xffffb30e, 0x3477, 0xffffa587, + 0x4067, 0x18a0, 0x361e, 0xffd, 0xffff880f, 0xffffef9a, 0xffffce51, 0x3ed, + 0x139b, 0x4957, 0xffffc1b0, 0x5718, 0x4e72, 0x898c, 0x1e76, 0xfffffc63, + 0x5a7e, 0x3388, 0xffff8b15, 0x8c3, 0x42ed, 0xffff9b9a, 0x1fff, 0xfffff544, + 0x66a4, 0xffff7c9f, 0xf3d, 0x8823, 0xffffab00, 0x8d96, 0xffff9a08, 0x16d3, + 0x55a3, 0xffffc3a3, 0x5f6e, 0xffffa6c2, 0xffff982e, 0xffffe233, 0x3b85, 0x4b3b, + 0xfffff53f, 0x31d2, 0x58f0, 0x8345, 0xffffb052, 0x8516, 0x1013, 0x3e91, + 0xffffdf3d, 0xffffb256, 0xffff8937, 0x7307, 0x6544, 0xffff9898, 0x26fc, 0x7aaa, + 0x5d8c, 0x45c4, 0x8168, 0xffffe0d2, 0xffffa15f, 0xffff8c32, 0x23e2, 0x2f6d, + 0x4e73, 0x5b19, 0xfffff7a0, 0x1530, 0x8a57, 0x5994, 0x7668, 0x8658, + 0x7810, 0x5ae5, 0xffffdd59, 0xffffe2e3, 0x6ade, 0xffff84ab, 0x2286, 0x3324, + 0x34d6, 0x6fa3, 0xffff9c8c, 0x1649, 0xffff9152, 0xffffde80, 0x140c, 0xffffe31f, + 0xffffab3a, 0x85b6, 0x870d, 0x21cd, 0x33ee, 0xffff8aa8, 0xffffcb20, 0x584, + 0xffffcdb5, 0x4b6c, 0x4b54, 0x559c, 0xffffc9b9, 0xffffc227, 0xffff93ec, 0xffffaf9c, + 0x2314, 0x4cd1, 0xffff9b8a, 0xffffa7f7, 0xffffe946, 0x6412, 0x8698, 0xfffff049, + 0xffffe24f, 0xffffbc02, 0xfffff5dc, 0x248b, 0xffffa1a1, 0xfffff591, 0x17f8, 0x7c7f, + 0x2a38, 0xffffc4b7, 0x50f4, 0x4567, 0xffffe9b3, 0x1139, 0xffffdc63, 0xffffaf43, + 0xffff921e, 0x38b5, 0x6f7c, 0x7e35, 0x4cb7, 0xffffdbdb, 0xfffffc86, 0x14e0, + 0xffffb500, 0xffff8fd7, 0xffffc44e, 0xffffe8ae, 0x615, 0x73de, 0x513c, 0xffff8c2d, + 0xffffa65e, 0x733b, 0xffffaa1a, 0xffff9823, 0x390f, 0x81e5, 0x6388, 0x2547, + 0x618c, 0xffffc2b5, 0xfe5, 0x61cf, 0xffff8162, 0xffff8c51, 0x8872, 0x5eae, + 0x5a61, 0xffffab35, 0xffff790b, 0xffff894f, 0xffff7e7f, 0x2ef3, 0xffffa954, 0xffff94a3, + 0xffffec89, 0xffffe3e7, 0x886c, 0xffff9f5c, 0x6429, 0x5828, 0xffffb33b, 0x38d4, + 0x3fb6, 0xffffe5df, 0x5e4, 0xffffa316, 0xffffdea1, 0xffffefe5, 0xbb0, 0xf7c, + 0xfffff415, 0x7f2, 0xfffff4ab, 0x8d31, 0xffffb9b1, 0xffffbbdd, 0xffffc868, 0xfffff245, + 0xffff91ae, 0x62db, 0xffffd076, 0xffffc4c5, 0x5575, 0x43af, 0xffffe6f3, 0x7cc1, + 0x6c8b, 0xffffb56c, 0xffffe101, 0xfffffe07, 0xffff8a88, 0xffff9931, 0xfffff933, 0xffffd4bd, + 0x355e, 0xffffd3df, 0x1e2d, 0x5b90, 0x6ce5, 0xffffff81, 0x5d0e, 0x514b, + 0xffffa086, 0x1caf, 0x300d, 0xffffc1e2, 0x357c, 0x2820, 0x4be, 0xffff9c0b, + 0x2e68, 0xffffb03b, 0x8ab1, 0x2aed, 0x3cc8, 0xffffa250, 0xffffca57, 0xffff8fe0, + 0xffffbc0e, 0xffffa87c, 0x3681, 0xffffff03, 0x6f96, 0xfffff6e8, 0x3818, 0xffff91eb, + 0x460a, 0xffffc57c, 0x23bf, 0xffffa010, 0x6ae0, 0x38fa, 0x6c95, 0xffffe509, + 0x2594, 0xffff892e, 0xffffd6fd, 0x4dbf, 0xffff7bca, 0x595b, 0x5265, 0xffff722c, + 0xffff9bbe, 0x6f1b, 0xffffa0d6, 0xffffb61d, 0xfffff32c, 0xac6, 0xffff8448, 0x37b3, + 0xffffb59c, 0x6132, 0xffff820a, 0xffffb87e, 0x7e80, 0xffffddb7, 0xffff84db, 0xffff868b, + 0x1498, 0x5ece, 0x4761, 0xffffbe71, 0xffff7b6f, 0x2492, 0x6b0e, 0xfffffcba, + 0xa45, 0xd5d, 0x361d, 0xf45, 0x82fe, 0xffffd7cf, 0xffffc64e, 0xffff8ad6, + 0xffffb43b, 0xfffff00e, 0xffff7b5b, 0xffff9858, 0x3756, 0xffffe97b, 0x6167, 0x52b9, + 0xfffffc14, 0x4bf6, 0x2c11, 0x5c7b, 0x75fc, 0xfffff1b7, 0x47f4, 0xffffc8ca, + 0x5fbc, 0xc3f, 0xffff9e06, 0xffffb109, 0xffff791e, 0x6661, 0x8942, 0xffff92b4, + 0xd4f, 0x15a8, 0x625d, 0x3878, 0xffff9a70, 0x636b, 0xffffad1a, 0xfffffc36, + 0x1abe, 0xfffff303, 0x4b0a, 0xffffe7cc, 0xffff904c, 0xffffe288, 0x5acd, 0xfffff71e, + 0x3252, 0xce1, 0x2db2, 0xffffc97a, 0xfffff8e7, 0xffffbb28, 0x7a7d, 0x6ed5, + 0xffffae7d, 0x8dbe, 0xffff744e, 0xffff8e03, 0x6cb, 0x86a7, 0xffffdc22, 0xffffd8fb, + 0xffffd18d, 0x4626, 0x8c87, 0xffffc3ae, 0xffffb882, 0x689a, 0x3791, 0xffffc0a0, + 0x7223, 0x3c, 0x8fe, 0xffff9ecf, 0xffffd89a, 0xffff7e2d, 0xffffa145, 0x56e7, + 0xfffffb34, 0x480c, 0xffffb7b6, 0x4d54, 0xffffc5f6, 0xffffde25, 0x4d3e, 0x7302, + 0xffffdb67, 0x4fb7, 0xfffffb02, 0x8765, 0xffffab7b, 0xda7, 0xffffb04f, 0xffffc9e5, + 0x15b6, 0x2718, 0xffffc98c, 0xffffe2eb, 0x8011, 0x8b74, 0x7aa7, 0xa1a, + 0x5d48, 0xffff9ffa, 0x1d7, 0xffffef63, 0xffff9746, 0x7c5b, 0xffff816e, 0x6c68, + 0x156f, 0x85b8, 0x16bc, 0xffffc689, 0xffff8006, 0xffffe2ec, 0xfffff102, 0xffffeb7d, + 0x8956, 0xfffff640, 0x4713, 0x7bad, 0x41bb, 0xffff9f79, 0x3691, 0xffff7b9d, + 0x7ca6, 0x5c98, 0x81e4, 0xffff9084, 0x7825, 0x543a, 0xffff8b4b, 0xffffd2f9, + 0xffff7f0a, 0xffff7655, 0x665e, 0xffffd3df, 0xffff8b05, 0x2da3, 0x2c10, 0x4dcf, + 0x23e0, 0x4e27, 0x5fb6, 0x82f3, 0xffffe5cb, 0x6d98, 0xffff9691, 0xa4a, + 0x3f51, 0x2573, 0x894c, 0xffff8107, 0x5091, 0xffffe034, 0x83db, 0x2029, + 0xffff8d63, 0x6ee6, 0xffff92d2, 0xfffffe7e, 0x5f72, 0x6704, 0xffffd1f6, 0x4d40, + 0xffffb1f6, 0x2766, 0x4b84, 0x7e47, 0x728a, 0x51f7, 0xffff9a48, 0x1149, + 0xffffc964, 0x456f, 0xffffa797, 0x6112, 0xffff7e4c, 0xffffea92, 0x8a8b, 0xffffc9bf, + 0xffffbc0c, 0x6591, 0xffffd69c, 0xffffe54f, 0xffff7adb, 0x581b, 0xffffad1f, 0xffff9607, + 0x3e51, 0xffffe644, 0x80a4, 0x272e, 0xffffd8d5, 0x4c15, 0x639a, 0x7345, + 0xffff7d10, 0x1f97, 0xffffe213, 0xffffcd19, 0xffffb907, 0x7196, 0x348c, 0xffffcd02, + 0xffffc4b0, 0xfffff3d3, 0x56d5, 0xffff7712, 0x2415, 0x19c9, 0xffffaa34, 0x5be0, + 0xffffbe3d, 0x3edb, 0xffff7ba6, 0xffff8704, 0xffff9b22, 0xffff7398, 0x1ad2, 0x2b12, + 0xfffffa9e, 0x82a0, 0x289f, 0x20c1, 0xffffa302, 0xffff8bac, 0x5528, 0x5b36, + 0xffff9f0e, 0x300, 0x76ab, 0xe31, 0x54dc, 0x14c2, 0xfffff3f7, 0xffff9727, + 0xffffb8a1, 0xfffffd6c, 0x668c, 0x12ce, 0x5e2b, 0x837f, 0x79d9, 0xffff9f2c, + 0xffffe8c0, 0x5569, 0xffffa931, 0xffff9828, 0x5447, 0xe70, 0xffffc612, 0xffffbdc8, + 0xffff8100, 0xffff948f, 0xffffd762, 0x165, 0x7caf, 0xffffe5ba, 0xffffd76a, 0x1b3f, + 0xffffbace, 0x75b9, 0x266, 0x3be3, 0xffffb139, 0xffffdf94, 0x2528, 0xffff85e5, + 0x63ec, 0xffffea79, 0x784, 0x12c5, 0xffffcf6d, 0xffff941e, 0xffffd6c0, 0xffffe17c, + 0xffffde73, 0x317d, 0xffff7430, 0x2eea, 0x2d4d, 0xffff7937, 0xfffffb7c, 0xffff802d, + 0xffff902a, 0xfffff7d6, 0xffffbdb7, 0xffffdf44, 0xffffd10a, 0xffffc6a9, 0x36fe, 0xffffc98c, + 0xffff732c, 0xffffe42e, 0xffffd1e4, 0x6c5e, 0xffffa8ab, 0x7624, 0xffffdd12, 0xffffaf68, + 0x4d98, 0x5f15, 0x865d, 0xffff8d23, 0x5266, 0x276c, 0x295e, 0x1d29, + 0x5e0b, 0x772f, 0x2942, 0x459e, 0xffffe4eb, 0xffff73dd, 0xffffd004, 0xffff886f, + 0xffffcaf9, 0x18e0, 0xc66, 0xffffd08d, 0xffff7a9f, 0xffffd290, 0x88d8, 0xffff7c4b, + 0xffff86dd, 0xe4c, 0x15ef, 0xffff99f5, 0xffffde0e, 0x44db, 0x6855, 0x29de, + 0x3458, 0xffffc7a8, 0xffffdc32, 0xffffb3ec, 0x6e1b, 0xffff8dfd, 0x86a6, 0x685d, + 0xffffee8d, 0xffff92e9, 0xffffc182, 0xfffff271, 0x39d5, 0xffff86a2, 0xffff7472, 0xffffecba, + 0xffffd44d, 0xffff7fef, 0xffffd860, 0xffffeb6d, 0x3822, 0xffff91b2, 0xffffe1ea, 0x657f, + 0xffff98be, 0x7c56, 0xffffe379, 0x1286, 0xfffff440, 0xffffefd4, 0xffffc00c, 0xffffef9d, + 0xffffbb0a, 0xffffe423, 0x717a, 0xffff8177, 0xffffc56c, 0xffff87c0, 0x389, 0xffffbd6f, + 0x6a85, 0x6072, 0xffff8991, 0x6768, 0xffffb310, 0x55a0, 0x3566, 0xffffa763, + 0x6ad8, 0xffffecf0, 0x6e47, 0x460f, 0xffff74c3, 0xffffa827, 0xffff8ed2, 0x63a8, + 0x6785, 0xffff9ab6, 0x8721, 0xffffb48d, 0xffff8e1d, 0x1b24, 0x4cad, 0x32a8, + 0xffffa063, 0x3cc6, 0x3f51, 0x27c7, 0x32e2, 0xffff9cf7, 0xffffeca9, 0x6a39, + 0x58fa, 0x305d, 0xffffb237, 0xffff8301, 0x2b29, 0x4d40, 0xbfb, 0xffffea6f, + 0x15a1, 0xffffcc4f, 0xffffc735, 0xffffdaca, 0x26e5, 0xffff9e2f, 0xffffc05a, 0xffff8cf2, + 0x7a37, 0x4531, 0xfffffa02, 0xffffb210, 0x8633, 0x4f0f, 0x754, 0xffffed54, + 0xffff8740, 0x59d2, 0xffff767e, 0xffff855a, 0x3d85, 0x71b9, 0x72cd, 0x4d3b, + 0x78a1, 0xffffa6c1, 0x6c3e, 0xffff9317, 0x2926, 0x119a, 0x44d2, 0xffffb033, + 0xffff935e, 0xffffc224, 0x4ba1, 0xffffdba2, 0xffffb9b7, 0x17e4, 0xffff8b75, 0x2f37, + 0xffff73b2, 0xffffcc5c, 0xffff88bc, 0x213a, 0x47b0, 0x13d5, 0x3ca1, 0x51a7, + 0x2e56, 0xffffc38a, 0x7f7a, 0xffffe80b, 0xffff8832, 0x7270, 0xffff8f10, 0xffff7ca1, + 0x6c56, 0x8390, 0xffffb0bf, 0xffff9200, 0x6bbb, 0x46c8, 0xfffff4db, 0x2ab3, + 0xffffa2c1, 0x7288, 0xfffff4a6, 0x5ec3, 0x7c3, 0xffff81af, 0x3cc2, 0x28f7, + 0x4a58, 0xfffff026, 0x7ff0, 0xfffffc62, 0xffff9148, 0xd8f, 0x185, 0x59f4, + 0x1caa, 0x39dd, 0x3787, 0x4a31, 0xffffed74, 0x4336, 0xffffa9ea, 0x4646, + 0xffffd6f7, 0x175a, 0xffffe833, 0xffff95e8, 0xffff79ef, 0x7509, 0x68b8, 0x5445, + 0xffffe6a9, 0x49e4, 0xee4, 0x5e83, 0xffff9812, 0xffff9b80, 0xffffcd5b, 0xffff905e, + 0x6959, 0x38cf, 0xffffbce0, 0x758b, 0x3d88, 0xffffc47d, 0xffff86ca, 0x1c6a, + 0x10f2, 0x2934, 0xffffeb47, 0xffffa621, 0xfffff453, 0x8822, 0xffffd84d, 0x88a8, + 0xffff7738, 0x2211, 0x278b, 0xffffb4fd, 0x4a25, 0x24a1, 0xffff9982, 0x4316, + 0x1f4, 0xffffec51, 0xffffaf4d, 0xfffff10f, 0x452d, 0xffffed98, 0xffff89e2, 0xffff9770, + 0xffff7393, 0x2e9a, 0xffffa805, 0x870c, 0xffffb79d, 0xffffdcb9, 0x190f, 0xffffaf36, + 0xffffae0b, 0x35a8, 0xffffcb81, 0x49b6, 0x5b81, 0xffffad9f, 0x4b00, 0x59f6, + 0xbcf, 0x2bf6, 0xffff83b9, 0x56a, 0x478b, 0xfffff9a6, 0xffffefb1, 0xd52, + 0xffff977e, 0xfffffde7, 0x2281, 0x486b, 0xffff7a45, 0x38, 0xffffa31e, 0x545b, + 0x5f67, 0x759e, 0x7227, 0x4710, 0xffffda15, 0xffffde83, 0xffffb16f, 0x445a, + 0xffffb2a9, 0xffffe77a, 0x8ff, 0x136f, 0xffffaa07, 0xffff739c, 0x16f8, 0xffffd05a, + 0x1bc1, 0xffffbd49, 0x6534, 0xffff8187, 0x30d6, 0xffff7c5a, 0x8038, 0xffffc927, + 0x81d3, 0x6e7, 0x7d71, 0x5eed, 0x2dbc, 0x7779, 0x49d9, 0xffffa59c, + 0xffff7c2e, 0xffff7a46, 0x1461, 0xffffcbc6, 0x47cd, 0x6df4, 0xffff9c8b, 0xffffba56, + 0xffffc1aa, 0xffffe2c4, 0xffffb8b3, 0x354f, 0xffffba6f, 0x7e32, 0x88d2, 0x1dda, + 0x65c3, 0xffff7a23, 0xffffa941, 0x772d, 0xffffa8e4, 0x6cac, 0x6006, 0xffff8cc0, + 0x2c22, 0xffff8f93, 0xffffd510, 0x4ac1, 0xffffcac2, 0xffffbfc5, 0xffff772e, 0xffffd90e, + 0xffffc04b, 0x1858, 0xffffdb53, 0x4730, 0xffff87ca, 0xfffff776, 0xb2b, 0x5f04, + 0xffff7deb, 0xffffafc4, 0x273c, 0xffffa9ad, 0x2f96, 0x1df3, 0xffff99ab, 0x3ccb, + 0x8cb2, 0x69c, 0xffffb855, 0xffffa904, 0x8a40, 0x1b30, 0xffffbfe7, 0x8a23, + 0x70f8, 0x57da, 0xffff75fe, 0x2214, 0x2be1, 0xffff990b, 0xffff9394, 0xffffe908, + 0xffffb2c4, 0xffffa067, 0xfffff7c6, 0xffff97cd, 0xffff7498, 0x3af8, 0x1241, 0x10e3, + 0xffffa621, 0xfffff296, 0x698e, 0xffffa28b, 0xffff9084, 0x12cf, 0xffffb1f9, 0x4359, + 0x336c, 0xffffcf1e, 0xffffa763, 0x80bf, 0x4019, 0x47d5, 0xffffec7a, 0xffff83f6, + 0xffffd75a, 0xffffb050, 0xffff9104, 0xfffffb14, 0xffffd821, 0xffff8b8d, 0xffffb3fd, 0xffffebb6, + 0x124e, 0xffffd263, 0xffff7eab, 0xb78, 0xffffb115, 0xffffa4e5, 0xffffe296, 0x1f8, + 0xffffdd28, 0x3378, 0xffff9498, 0x3617, 0xffffb7c3, 0xffffe507, 0xffffe6ae, 0x47b2, + 0x18a5, 0xffff77c3, 0xffffa734, 0xffffc105, 0xffff8925, 0x7add, 0xfffffab0, 0xffffe3ec, + 0x39d4, 0x74ba, 0x56ea, 0xffffebec, 0xffff8e36, 0x3b63, 0x931, 0xfffff745, + 0x81c5, 0x368d, 0xffffbca4, 0xffff80b1, 0xffffe01f, 0xfffff52c, 0xffffacf4, 0x486f, + 0xffffc5e0, 0xfffffaae, 0x10d4, 0x5ea8, 0x4832, 0x38b4, 0x6894, 0x6002, + 0xffffdf3b, 0xffffa4a1, 0xffffe890, 0xffffb7b1, 0x3fee, 0x3c88, 0x1b52, 0xffff8883, + 0x1f6c, 0xfffff5ac, 0xffffc0cb, 0xac9, 0xcd4, 0x14f7, 0xffffa823, 0x21e2, + 0xffff8831, 0x5526, 0xffffc6a1, 0x4551, 0xffffa492, 0xffff9837, 0xffffa222, 0xffffde9d, + 0x1efc, 0xffffec4e, 0xffffd75b, 0x3268, 0xffffc8d6, 0xffff7a3f, 0x4c9b, 0xffff86a0, + 0x45e3, 0xffffddfb, 0xffff806b, 0x7aef, 0xffffcfa4, 0x30ef, 0x7f2b, 0xffffa3bf, + 0x46d7, 0xfffff316, 0x3720, 0x6dd9, 0xffffdb02, 0xffffbc61, 0xffffdd72, 0x81b9, + 0x1bf4, 0xffffb670, 0xffffcd6c, 0x37d8, 0xffffbd23, 0x4df6, 0xfffff2eb, 0xfffff687, + 0x8b59, 0xffff909b, 0x34cd, 0xffffc786, 0x143b, 0x8570, 0xffffc38e, 0x965, + 0xffffd3a1, 0xffffac12, 0xffffbb63, 0xffffe93f, 0x12d2, 0xffffe053, 0x3b2b, 0x4bcd, + 0x52f2, 0xfffff538, 0xffffb301, 0xf71, 0xffffb774, 0xffffd5ba, 0xffffbe11, 0x1121, + 0xffffa83d, 0x1a5a, 0x1ce, 0x8a49, 0xffffccb0, 0x82d2, 0xffffb440, 0xffff8a82, + 0xffff91fe, 0xffff8bad, 0x3e1d, 0x5005, 0xffffb167, 0xffff8f02, 0x1a0b, 0xffffc6d1, + 0x6303, 0xffffb2fe, 0xffffae6b, 0x507c, 0xffff907f, 0xffffeecd, 0xffff801b, 0x7b03, + 0xffffe69a, 0xffff8454, 0xffff8110, 0x2195, 0x60df, 0xffffe944, 0xffff7ac8, 0x21d, + 0x798, 0xffffed4d, 0xffff78b9, 0x36fa, 0xffff7616, 0xffffbf0e, 0x32c0, 0xffffcc92, + 0x294d, 0x819b, 0x2413, 0xffffaa63, 0x7ae7, 0xffff72bb, 0x6505, 0xfffff0e8, + 0x7b0f, 0xffff7b00, 0xffff8a4b, 0xffff8f23, 0x2336, 0xffffe49d, 0xffff9a9c, 0x478d, + 0xffffc085, 0x6059, 0xffffd216, 0xffff9e9b, 0x5e49, 0xffff7f3e, 0x6038, 0x6ad9, + 0xffffc10b, 0xffffd364, 0xffff7ecc, 0x6fef, 0xffff7809, 0xffffc298, 0x835f, 0xffffb70d, + 0xffffbc76, 0xffffc2fa, 0x1779, 0x247d, 0xffffdbe8, 0xffffb8de, 0xffffb96f, 0xffff81ff, + 0xffffbea1, 0xffffa830, 0xffff7fcd, 0xfffff310, 0x51fe, 0x65dd, 0xffff9f9f, 0xffffc799, + 0xffff8390, 0xffffd9da, 0xffffbb03, 0xffffb886, 0x6e67, 0x5799, 0x677b, 0x45ad, + 0xffff934b, 0x70b5, 0x44d0, 0x2f7e, 0xffff7568, 0x15b2, 0xffffbb0d, 0x7bf6, + 0x2605, 0x2b90, 0x4916, 0xffff9cd0, 0xffffaef8, 0xffffe9ab, 0x7fbe, 0xffffac1a, + 0x846, 0xffffc2d1, 0xffffbfba, 0x7699, 0xffffbfb5, 0xffffdef6, 0xffffbfed, 0x2d29, + 0xffffee6e, 0xffffb0c7, 0x8879, 0x8584, 0x3415, 0xffffc2e9, 0xffffc15a, 0xffffa8c4, + 0x3d0c, 0x31ab, 0xffffc3e1, 0xffff8bd4, 0x2ce5, 0x409c, 0x4243, 0xfffff9ce, + 0xffffecff, 0x27c6, 0xffffcddf, 0x6137, 0xffff96f2, 0xffff8d64, 0xffff9537, 0x8566, + 0xffffdf03, 0x6ef9, 0x7ada, 0x1413, 0x46e4, 0xfd7, 0x2c50, 0x7295, + 0xffff8827, 0x8938, 0x3392, 0xffffe413, 0x6e09, 0xffff811b, 0xffffba76, 0xffffc622, + 0x4554, 0xffffba5e, 0x6476, 0xffffb6f3, 0x2589, 0xffffcb99, 0x121a, 0x7e6d, + 0xffffd01a, 0x5bb5, 0xfffff271, 0x5031, 0x528d, 0x63f7, 0x7e28, 0xffffec61, + 0x18e, 0x1915, 0xffffaa49, 0xfffffd82, 0x6e94, 0x80c3, 0xfffff9b9, 0xffff9231, + 0x2b46, 0xffffb3c1, 0x8ef, 0x220e, 0xffffa349, 0x3649, 0x8397, 0xffff981d, + 0x6ad9, 0xffffaee7, 0x1fa9, 0xffffab33, 0x1e07, 0x7698, 0x7732, 0xffffe853, + 0xffff7232, 0x4f9f, 0xffffcbbf, 0xffff7feb, 0x68ce, 0xffffbdf9, 0x17d4, 0x2ee8, + 0x12c4, 0x8112, 0xffffb67d, 0x4914, 0xffffd9a2, 0xffff9e22, 0x74c8, 0xffffd9d8, + 0x5ed2, 0xc27, 0x3957, 0x39ca, 0xffffae61, 0x4edd, 0x15d8, 0x50b9, + 0x5077, 0xffff9787, 0x421a, 0xffff7ec0, 0xffffb93c, 0xffff922c, 0x867f, 0x855c, + 0xffff91fc, 0xffff8bc5, 0xffff8a93, 0x3e3f, 0xffff7c92, 0x772f, 0xffffaedc, 0x474e, + 0xffffb582, 0x135b, 0xffffb468, 0xfffff11d, 0x6298, 0x43bd, 0xffff9698, 0x43e1, + 0xffffc5a7, 0xfffffed5, 0xffffd9be, 0x4176, 0x322d, 0x6eef, 0xffffbdda, 0xffffce75, + 0xffff990d, 0x1857, 0xffffe0bc, 0x639e, 0xffffb5de, 0xfffffa1b, 0x70c8, 0x3404, + 0xffffd256, 0xffffd016, 0x7b8b, 0x69ad, 0x843c, 0xffffe02d, 0xffff7409, 0x4bc2, + 0xffffa87d, 0xffff7408, 0xffffd4d3, 0x27a2, 0xffff74a7, 0xffffc225, 0xffffc7a1, 0xffffcaa1, + 0x3a52, 0x2fe3, 0x36c3, 0x4f3c, 0xffffb5b5, 0x1ec0, 0xffffac64, 0x5f2c, + 0x1f24, 0xffff9dbf, 0x482e, 0x384b, 0xffffb6ca, 0x1acf, 0x66d6, 0x2652, + 0xffffd61d, 0xffff88fc, 0xffff7bed, 0x1862, 0xffffcf25, 0xffffb8e2, 0xffff9823, 0x526f, + 0xffff8e92, 0x6309, 0x4888, 0xffffe6f9, 0x631, 0xffffd94a, 0x1cd3, 0xffffa01b, + 0x43d8, 0x2793, 0x6557, 0x794b, 0x1383, 0x269, 0x1240, 0xffffe15c, + 0x69c5, 0xffffe7b1, 0x8d62, 0x2ecc, 0x7ab3, 0xffff7c8a, 0xffff7d9c, 0x7270, + 0x5c06, 0x7667, 0x1006, 0x7c60, 0x53af, 0xffff8990, 0x4bf4, 0x7183, + 0x2675, 0x30f1, 0x2478, 0x6124, 0xffff8265, 0x116e, 0xffffab22, 0xffffda7e, + 0xffff8517, 0x89fc, 0xffff7a6e, 0xffffb9f7, 0xffffd29e, 0xffffa22b, 0x461, 0xffff8708, + 0x1bcb, 0x7e6d, 0xffffc54a, 0x5d4d, 0x88a1, 0xffffdf3b, 0x1d91, 0x12b6, + 0xffffeb16, 0xffffe8ea, 0x30f0, 0xffff7427, 0xffff7d09, 0xfffff64e, 0xffff8896, 0xffffa354, + 0xfffff72e, 0xffff81d9, 0xffff996c, 0xffff74a4, 0xffffc3cf, 0xfffff2d2, 0xffffbf2c, 0xffff741d, + 0xffffd89c, 0xffffc38a, 0xffffde7d, 0x5f1c, 0xffffb1bb, 0xffffa21f, 0xffffb38e, 0x8236, + 0xfffff3ed, 0xffffce5d, 0x585e, 0xffffbe23, 0xffff8372, 0xffffaf4d, 0x3fcf, 0x3927, + 0x5dda, 0xffffa074, 0xf76, 0x6969, 0x4196, 0x875e, 0xffffb681, 0x35bc, + 0xffffbf70, 0x15af, 0xfffff405, 0x8b2a, 0x6d4c, 0x218d, 0x89bc, 0xffff9efe, + 0xffffc56b, 0xffff942b, 0xffff8aa0, 0x4739, 0x6f8f, 0xffff8a85, 0x6c68, 0xffff958c, + 0xffff9507, 0xffff9771, 0x3fb7, 0xffff8354, 0x6186, 0xffff90d7, 0x1520, 0xffffe018, + 0x3b58, 0x411d, 0xffffdc5f, 0x1ecd, 0xc86, 0xffffa92a, 0xffffeaa6, 0x73a, + 0x3def, 0x58de, 0x4933, 0x675d, 0x5e3, 0x25e2, 0x3eb, 0x714d, + 0xa3a, 0xffff8420, 0xffffcb78, 0xffff887a, 0xffff7747, 0xffffff76, 0x280b, 0x2abd, + 0xffffbdcd, 0x7dc1, 0xffffac20, 0xffffc30a, 0xffff7238, 0x27f3, 0xffffce4b, 0x398d, + 0x4244, 0x3750, 0xffffc875, 0xffffc657, 0xffff9c8c, 0x3779, 0x55ce, 0x49d2, + 0xfffff9b4, 0xffffd3a7, 0xffffade9, 0x3b41, 0x681f, 0xffff8812, 0xffff7a5a, 0xffffc989, + 0x49e6, 0x3783, 0xffffb5f4, 0x70ba, 0xffffbf48, 0x8933, 0x3314, 0x2047, + 0x111e, 0xffffd1e0, 0xffffea38, 0xffff779e, 0xffffabe9, 0xffffe109, 0xffff9c1c, 0x3fdd, + 0x157b, 0x2726, 0x480, 0xffff7635, 0xffffb05d, 0xffff82de, 0xcec, 0xfffff7d9, + 0xffffb171, 0x45f9, 0x8a9f, 0x1d04, 0x1b06, 0x80b, 0x39a9, 0xfffff58c, + 0x274c, 0x1abd, 0xffff7ae0, 0xffffc2a1, 0xffffce98, 0xffff9427, 0xffffa278, 0xffff8c58, + 0x31d6, 0x6f95, 0xef0, 0xffffd311, 0xffff95a0, 0x7c0b, 0xffffaf59, 0x934, + 0x73b3, 0xffff98df, 0xffffa574, 0x6069, 0xffffead8, 0x671f, 0x5c9f, 0x4354, + 0x23dc, 0x1c3f, 0xffffbc97, 0x22d2, 0xffffdd4e, 0x1239, 0x3af3, 0xffffefad, + 0x6121, 0xffffd1e6, 0x66da, 0xffffcc0a, 0x63ea, 0xfffffc17, 0xffffc2d6, 0xffffa0f2, + 0xffffc2d3, 0xffffa772, 0x4b13, 0xffffcfba, 0xffffee11, 0x6561, 0x38cc, 0xffffabbe, + 0xffffe3f2, 0x4c6b, 0xfffff7ef, 0x6373, 0xffffeed8, 0x34cf, 0x59d9, 0x2699, + 0xffffd7fa, 0xfffffa92, 0xffffac49, 0x62d7, 0x6daa, 0x4ab3, 0xffffaf00, 0xffffce18, + 0xffff7e6c, 0x118, 0x72fe, 0xffff874a, 0x645, 0x2d6f, 0xffffa91f, 0x7443, + 0xffff82ca, 0x553f, 0xffffb391, 0xffff83c6, 0x581a, 0x4124, 0x4d68, 0x5981, + 0x40c2, 0xffff925c, 0x10e3, 0xffff957f, 0x7b13, 0xffff9008, 0x3563, 0xffffb7d3, + 0xffff8c80, 0x8508, 0x8a7e, 0xffffd76b, 0x5321, 0x39bb, 0xffffe271, 0xffffa6fa, + 0x758e, 0x3092, 0xffffd014, 0x2666, 0xffff745f, 0xffffb06f, 0xffff861c, 0xffffe4c9, + 0x306f, 0xffffc98f, 0xffff950b, 0x2139, 0x7698, 0xffff9796, 0x1df5, 0xfffff0f9, + 0x112c, 0x467a, 0x211b, 0x4469, 0x168f, 0x38b7, 0x2007, 0x2908, + 0x24, 0x280e, 0x5051, 0xffffb28f, 0x4c68, 0x836a, 0xffffea37, 0xffff9080, + 0xffff95e1, 0xffffe897, 0xffffcabd, 0xffff87dc, 0x88c2, 0x4507, 0xffff8a98, 0x405f, + 0x52c8, 0xffffc450, 0x204a, 0xffff8690, 0xffffec68, 0x28a5, 0xffffdb3c, 0xffffa42c, + 0x13e2, 0xffffb958, 0x595d, 0x4eae, 0xffff8001, 0xffff7f70, 0x4a8c, 0x748b, + 0xffffb9ea, 0xffff87ba, 0x4a61, 0xa72, 0xfffffc5b, 0xffff9428, 0xfffff71c, 0xffffa0d7, + 0xffffd5c7, 0xffffcd3f, 0xffff77eb, 0xfffff986, 0xffff92c6, 0x57a0, 0xffffe759, 0x815c, + 0xffff8cb3, 0xffffcdc4, 0x6a3f, 0x1a8, 0xffff7840, 0x60bd, 0xffffb606, 0xffff8946, + 0xffffebc2, 0xffffaae5, 0xffffce9d, 0xffffca7c, 0xffff761c, 0x3ffb, 0xffffc9e6, 0xffff94b5, + 0xffff7888, 0x63fc, 0xffff8da1, 0xffffd969, 0x21b0, 0x47be, 0x39e9, 0xffffee2b, + 0xffffbc45, 0x82a2, 0x243d, 0x75bc, 0xffff88cf, 0x8c54, 0xffffb154, 0xffffa214, + 0xffffb8bb, 0x8a04, 0xffff87de, 0x8cd6, 0xffffd8d3, 0xffffc81e, 0xffffdf1c, 0xffffb674, + 0x5782, 0xffffa361, 0xffffcd7b, 0xffffe9d7, 0xffff9bbf, 0xffffcae9, 0xffffeab3, 0xffffd75e, + 0xfffffab2, 0xd68, 0x8288, 0x5177, 0x5f43, 0xffffeebd, 0xffffc78f, 0xffff72d2, + 0x812, 0x752a, 0xffffc8ce, 0xfffff6d2, 0xdb9, 0x6b64, 0x3527, 0xfffff063, + 0x79be, 0x6579, 0xffffe19c, 0x226f, 0xffff9529, 0x1eb8, 0x8747, 0x41e2, + 0xffffde27, 0x46e7, 0x86bf, 0xffffa714, 0xffff93c7, 0xffffe02a, 0xffffc1e6, 0x36de, + 0xffffc76e, 0x43ed, 0x65a, 0x6cf4, 0x57f3, 0x4916, 0xffffecae, 0x7ca7, + 0x5c09, 0x48f0, 0xffffb23e, 0xffffaecc, 0xffffa88b, 0xffff7d10, 0x87c4, 0x669f, + 0x56c2, 0x43d, 0x8c6b, 0xfffff478, 0x87cb, 0xffffd0f4, 0xffffa7a1, 0x25e7, + 0x5a3d, 0x1df, 0xfffff384, 0x3438, 0x1ce8, 0x800, 0xffff8048, 0xffffad8a, + 0xffff9d72, 0xffff73f5, 0x818d, 0x420a, 0xffffae9d, 0xffffc332, 0xffffbe39, 0xffffce52, + 0x5b09, 0xffff8635, 0x1157, 0xffffb3d7, 0x33d1, 0xffff8149, 0xffffbe1d, 0xffffff1d, + 0xe7c, 0xa66, 0xffff8167, 0x191d, 0x1beb, 0xffff82ec, 0xffffa8a3, 0xffff78af, + 0x52ca, 0xffff7862, 0x7c41, 0x8b97, 0xffffbe29, 0xffffcaac, 0x7279, 0x893c, + 0x3b70, 0x7947, 0xffffed3c, 0xffffe6e8, 0x3dcb, 0x1d01, 0x88cf, 0xffffb5ae, + 0xffffa7ef, 0xffffece8, 0xfffffb0a, 0x1c20, 0x3691, 0x4f, 0x40aa, 0xffffebe0, + 0x5fa0, 0x38, 0x44dd, 0xffff8ab5, 0x2c13, 0xffffd8b8, 0xffff9f3d, 0x8815, + 0x8683, 0x6a60, 0x1a12, 0xffffa788, 0x5215, 0xffffcc46, 0xffff75bd, 0xffff8c9d, + 0x2871, 0xffff889e, 0xffff9608, 0x8d91, 0x8c85, 0xffffc2ee, 0x458b, 0x48e7, + 0x1d47, 0xffffe974, 0xffffa020, 0xffffe1fd, 0x6f80, 0x8264, 0x885, 0x4317, + 0xffffd135, 0x89c9, 0xffffb412, 0xffff7b42, 0x5b21, 0x5a98, 0xffffbc39, 0x16c0, + 0xffff7c6e, 0x286b, 0x1996, 0xffffd5e6, 0x5fb3, 0xffff950f, 0xe62, 0x215d, + 0x2328, 0xffff7dc1, 0xffffacb9, 0x1483, 0x3da9, 0x74e7, 0x410e, 0x8253, + 0x4216, 0x1ff1, 0x4d3a, 0x3771, 0x817a, 0xffff73f2, 0x624e, 0xffffff16, + 0x3dc5, 0x1384, 0x377c, 0xf2, 0x4bf2, 0xffff74f7, 0x3060, 0x728d, + 0x2aee, 0x7273, 0xffff8fbf, 0x1106, 0xffff89df, 0xffffc920, 0x3582, 0x25fd, + 0xffffce73, 0xffffe0f1, 0x6219, 0xffffadc3, 0xfe9, 0xffff837f, 0xffff9048, 0x781f, + 0xffffb93b, 0x189f, 0xfffffb71, 0x16d2, 0xf5e, 0xffffb0bf, 0x62f8, 0x51e2, + 0x2c58, 0x5d59, 0xffffc837, 0x161a, 0xffffa164, 0x39c, 0x10a3, 0xffff79f8, + 0xfffffd31, 0xffffb4e3, 0xffffc92d, 0x6f16, 0xffffab27, 0xfffff0ba, 0x1be7, 0xffffb0a9, + 0xffffe906, 0x3a70, 0xffffaf42, 0x8b55, 0xffffa625, 0xffffca7e, 0xffff7fdb, 0x4078, + 0x5d41, 0x7798, 0xfffff767, 0xffff964e, 0xffffd7df, 0xffffa537, 0x3b4a, 0x35d0, + 0x5ba2, 0xffffd3b1, 0xffffb2e2, 0xffffd0e7, 0x3602, 0x72f1, 0xffff8dcc, 0xffff7ade, + 0xffffb1ee, 0xffffafa9, 0xffffdad2, 0xffffea6a, 0x6667, 0xffff941e, 0xfffff259, 0xfffff365, + 0x15be, 0x1280, 0xfffffcab, 0x8bb6, 0xffffbf10, 0xffffb64d, 0x408f, 0xfffff18a, + 0xffff9956, 0xffffa946, 0x71e3, 0xffffe7e8, 0xffff7ddc, 0xfffff570, 0x1c0f, 0xffffc10d, + 0x6e81, 0x367d, 0x2846, 0x635e, 0xffff74fc, 0x4b36, 0xfffff47b, 0x8b6b, + 0x7d7, 0xffffeb07, 0xfffff577, 0xffffb507, 0x42a5, 0x733c, 0xffffe9a2, 0xffffe885, + 0xfffff77a, 0xd37, 0x5f47, 0xffffc515, 0xfffffd88, 0xffffeb05, 0xffffcb7f, 0xffffa183, + 0x63df, 0x896f, 0x7fd9, 0x5f5, 0xffffc008, 0x29ac, 0x360e, 0x259d, + 0x7d1, 0xfffff226, 0x3d55, 0xffffabfd, 0x54b4, 0x3085, 0x59a1, 0x8a1e, + 0xffff85f4, 0xffffef3e, 0x49e5, 0xffffe51a, 0xfffffe96, 0xffffdea7, 0x328a, 0xffffa638, + 0x4ced, 0xffffb2d8, 0xffffec06, 0x854b, 0x46a, 0xfffff0e7, 0x8922, 0x8266, + 0x280a, 0x68a6, 0x5210, 0x6a2, 0x4142, 0xffffca2d, 0xffff9e3b, 0x5dd5, + 0xffffe648, 0xffffaac4, 0x22d9, 0xfffff89e, 0x4059, 0xffffab1f, 0xffffd230, 0xffff8d23, + 0x6cf, 0x6067, 0xffffed0e, 0xffff74f8, 0x58ee, 0xffff964e, 0xffffe204, 0x5e81, + 0xffff9d1e, 0xffffa77a, 0xffffef8a, 0xffff8f01, 0xffff7694, 0x6c0b, 0x7293, 0x72b2, + 0xffffa48b, 0xffffeb04, 0x1953, 0x1d, 0xffff888f, 0xffff7b0a, 0xffffa134, 0x7fe3, + 0xffffacc2, 0x471, 0x999, 0x4397, 0xfffff6a0, 0x7af2, 0xffffaac9, 0xffffe255, + 0x1170, 0xffffaaec, 0x2b92, 0xffff96a5, 0xffffd8b4, 0x3e4a, 0x44b0, 0xffffefdf, + 0xffffc299, 0xffff7360, 0xffff7ec4, 0x4be8, 0x2e91, 0xffffc8dc, 0xffffb89a, 0xffff8894, + 0xffff9818, 0xffffb4a1, 0x669, 0x892, 0x8c52, 0xffffe05d, 0x6fc3, 0xffff861c, + 0x19f4, 0x876d, 0x2260, 0xffff873f, 0x363e, 0xfffff093, 0x1434, 0x840b, + 0x648b, 0xffff8ebb, 0x1a62, 0x604e, 0x5874, 0x4304, 0x6f7e, 0xffff8c56, + 0x603b, 0xffffbaa1, 0xffffe654, 0xffff7ea9, 0xffff9791, 0xffffc749, 0xffffa7d9, 0x11e6, + 0xffffa58d, 0x6995, 0x4a1c, 0x362e, 0xffff9be4, 0x8266, 0x304, 0xffffbe5c, + 0xffffb4e6, 0xffffa022, 0xffff821f, 0x1170, 0xffff8639, 0xffffcbf0, 0x2364, 0x6c9a, + 0xffff8726, 0xffff9417, 0xffffea48, 0xffffb072, 0x5f33, 0x4896, 0xffff7762, 0x65e9, + 0xfffffd0a, 0x57f, 0x3b2c, 0xffff751d, 0xffff8c1f, 0xffffef92, 0x7117, 0xffffed28, + 0x8b9f, 0x764b, 0xfffff95d, 0xffff8346, 0xffffada7, 0xffffcd90, 0xffffa794, 0x22f6, + 0x5821, 0x2a57, 0xffff7575, 0xffffc0a9, 0xffffc11c, 0xffff954c, 0x921, 0xffffb22e, + 0x6fa4, 0x5f18, 0xffffcc0d, 0xffffd4eb, 0xffff8fd0, 0xffffd740, 0xffffc4d2, 0x5b17, + 0x7391, 0xffffdc3a, 0xffff923d, 0x4572, 0xffffaf19, 0xffffc9fb, 0xd70, 0x4c5d, + 0xffffb57d, 0x7eda, 0x60ce, 0x3db6, 0x6478, 0xffff81ca, 0xffff8e3f, 0xffffae43, + 0x8aad, 0xffff76a0, 0x2d2d, 0xffffc6ed, 0x89c4, 0xfffff0bd, 0xfffff634, 0xffff86cc, + 0x8934, 0x5c28, 0xfffff07a, 0xffffc810, 0xffffc4d5, 0xffff931a, 0x6cc1, 0xffff820d, + 0x4ad9, 0xffffe2ec, 0x5400, 0xffffce27, 0xffffa35b, 0xfffffa9a, 0xffffc984, 0x29db, + 0x198b, 0xb84, 0xffff7987, 0x43fc, 0x475f, 0x432d, 0xffffe7cc, 0xffff9245, + 0xffffef67, 0x60c2, 0xffffa260, 0x3a6a, 0x6739, 0x6685, 0x1b66, 0xa0, + 0xffff76b4, 0x2f5f, 0x8857, 0xffffa00d, 0xffff8549, 0x203e, 0x841f, 0x28a6, + 0x4193, 0xffffa1d6, 0x798f, 0x5d16, 0x279b, 0x9b1, 0xffffd61c, 0xffff9bce, + 0x3ecd, 0xffffc062, 0xffffac02, 0xffffac45, 0x150e, 0x7e22, 0xffffc92e, 0xffffe529, + 0x60da, 0x3950, 0x3d86, 0x1575, 0x182f, 0x7ee7, 0xffff8da9, 0x1a01, + 0x2e85, 0x7cd5, 0xffff8cc0, 0xffff730f, 0xffff8fe1, 0xffffeb15, 0x3bb7, 0x2d60, + 0xfffffaa0, 0xffffbd0f, 0x33b2, 0xffffd0be, 0xffffc2df, 0xffff7f81, 0x6400, 0xffffd43b, + 0xffffc823, 0x418c, 0xd2f, 0xffffa895, 0x8c3c, 0xffffbaeb, 0x7f05, 0xffffa145, + 0x660d, 0xffffa464, 0xfffff7ba, 0x8a12, 0x5b5a, 0xffffc222, 0xffff999e, 0xffffe91a, + 0x1bd9, 0xffffb0f5, 0x8202, 0x7319, 0xffff877a, 0xffff97b7, 0xffffc451, 0xffffa669, + 0x34b1, 0xffffbcda, 0xffffb333, 0x76fa, 0x4fb3, 0x1bfa, 0x8822, 0xffffcd78, + 0xffff7440, 0xfffffb6c, 0xffffb200, 0x4f19, 0x33ed, 0xffffb977, 0x26b, 0xfffff89d, + 0xffffa1de, 0x61ec, 0x1d9c, 0xffff76c0, 0xffffb7c1, 0xfffff027, 0x700c, 0xffff841a, + 0xfffffd62, 0xffff8baf, 0x4562, 0x7eab, 0x2ac8, 0xffffca3d, 0x6a8c, 0xffffc5c5, + 0xffff76cf, 0x454e, 0x44b2, 0x2e49, 0x551c, 0x4b86, 0x734c, 0xffff9db0, + 0x1d8, 0xffff9219, 0xffffe716, 0xffff7e4f, 0xffffcad7, 0x208, 0xffffa001, 0xffffe587, + 0xffffeed7, 0xffffc27b, 0xffffc41d, 0x4531, 0x7ee, 0xffff755f, 0xa10, 0x1d02, + 0xffff75fe, 0xffff9543, 0x237f, 0xffffabf2, 0xd2, 0xae9, 0x2785, 0xffff85c8, + 0xffff9b84, 0xffffc2d6, 0xffffe149, 0x28ae, 0xffff75f9, 0xffff9667, 0x5647, 0x76e9, + 0xfffff7f3, 0xffffa9ae, 0xffffc163, 0xffff8412, 0xfaf, 0x1cde, 0xffff888f, 0xffff7e2f, + 0xffffd400, 0xffff8602, 0x37de, 0xffffb80c, 0xffffd2e9, 0x11ba, 0xffffb448, 0xffff9253, + 0x603a, 0x71c9, 0x4d23, 0x48c7, 0xffffc84d, 0xffffe1fb, 0x47db, 0x1877, + 0x45af, 0xfffff561, 0xffffd599, 0x7c57, 0xffff8cd4, 0xffffbc8b, 0x61db, 0x37a0, + 0x1544, 0xffffca6a, 0x8d85, 0x768f, 0xffff897a, 0xffff923c, 0xffffecde, 0xfffff499, + 0x100c, 0x5097, 0x8dd1, 0x1d2c, 0xffffd766, 0x31a3, 0xffff9f7e, 0x31e8, + 0x2744, 0x8dad, 0xffffd73e, 0x33ab, 0x3fed, 0xfffff38c, 0xffffe07f, 0x7827, + 0xfffffc55, 0x6531, 0x526b, 0x2399, 0x3c8c, 0x4633, 0xffffaafa, 0x11da, + 0xfffffca9, 0xffff7c90, 0x4499, 0x3445, 0x12c4, 0x2210, 0xffffe1e1, 0x431b, + 0x45da, 0xffff72cf, 0xffffdae7, 0x6ee7, 0xffffb843, 0x7930, 0xfffffc7c, 0xffffda3e, + 0xffff89d1, 0x8d06, 0xe73, 0xffff82c9, 0xffffeeb8, 0xffffc7dc, 0x3e13, 0xffff9f2f, + 0xffff7e2a, 0xffff7eaf, 0x6cb0, 0x5077, 0xc26, 0xffff9fcb, 0xffff7e45, 0x1bc3, + 0x6cd7, 0x800e, 0x333f, 0xffffef38, 0x3294, 0x38c5, 0xffff9860, 0x7fe2, + 0x1846, 0xffffc870, 0x8798, 0xffffa794, 0x3433, 0x70a5, 0xffffe031, 0xffffbd5a, + 0x626c, 0xfffff816, 0x7b1, 0x83fc, 0xffff9362, 0x306, 0x7587, 0xffffdb69, + 0xffff89e4, 0x1da2, 0x5532, 0xfffffd49, 0xffffba57, 0xffff8941, 0xc84, 0x6b89, + 0xffffecd4, 0x2578, 0x8a3e, 0xffffbd94, 0xffff8bc6, 0x7a73, 0x5cfc, 0xffffa543, + 0x4605, 0xffffbde5, 0x8cfe, 0x150b, 0xffffd23e, 0xffffa042, 0xffff7b69, 0xfffff168, + 0x1c44, 0xffff72f5, 0xfffff3c2, 0xfffff9ed, 0xffffeca1, 0x2d48, 0xffff9bce, 0x272b, + 0xffffc260, 0xffff929d, 0x3cb9, 0x5c11, 0x5d4, 0xffff8ad7, 0x6aa9, 0xfffffb80, + 0x572b, 0x2cbd, 0x5e8a, 0xffffb586, 0xfffff8e7, 0x6f5b, 0x28ce, 0x11a, + 0x71f5, 0xfffff744, 0x1be2, 0xffff95cd, 0x6cef, 0xffffc7f6, 0x1ac3, 0x8c96, + 0xffff760f, 0xffffa1ba, 0x370, 0x3277, 0xffff817a, 0xffffcee6, 0x195e, 0xffff7ccb, + 0xffffca7b, 0xffff9d90, 0x540e, 0x6725, 0xffff75a3, 0x48a5, 0xffffada6, 0xfffffdad, + 0x32e4, 0x1e1e, 0xffffe0eb, 0xffffed3c, 0xfd, 0xffff9fbf, 0x4878, 0x8dbc, + 0x3ef3, 0xfffffcd0, 0x80e5, 0x77b5, 0x8b4b, 0x7003, 0xffffb759, 0x8938, + 0x4a57, 0xca9, 0x6783, 0x27ee, 0x2c7a, 0xffff8bf7, 0xffffe754, 0x2a23, + 0x60ea, 0xffffc6bc, 0xffffb024, 0x34b2, 0xffffe44f, 0x2f16, 0x3df3, 0x883c, + 0x3eb1, 0xffff81dd, 0x5e00, 0x7ae1, 0x62bc, 0xffffcb8d, 0xffffd0eb, 0x457f, + 0x6bb3, 0x72a2, 0xffffb521, 0xffff7d69, 0xffffd032, 0x4d2, 0xffff9dcb, 0xfffffd7d, + 0x44d, 0x3c01, 0x34ed, 0xfffff07f, 0x74a6, 0x894, 0x524d, 0xdb3, + 0xcb3, 0xffff9661, 0xffff9d9a, 0xffffdae6, 0xffffd8df, 0xffffe241, 0x14a9, 0xffff79ad, + 0x1d71, 0x17e9, 0xffffcee6, 0x58cc, 0xffffa52b, 0x7b08, 0xec7, 0x5a66, + 0xffff7f3c, 0xffffc522, 0x210d, 0x109c, 0x162d, 0x4654, 0xfffffee4, 0x1b68, + 0x7e7b, 0xffffb804, 0xffff9c77, 0xffffa259, 0xfffffcdc, 0xffffb126, 0x6f3e, 0x597e, + 0xffff8c8b, 0xffffb09a, 0x4d39, 0x8bc3, 0x1208, 0x63f, 0x7e6a, 0x3bb1, + 0x8dd9, 0x4cac, 0xffff803c, 0xffff9d29, 0xffffa2d6, 0x1a9a, 0x16fe, 0xffffc6c9, + 0x6ff1, 0xffffb441, 0xffffbdc5, 0xfcd, 0xffffe445, 0xffffa0f3, 0xffffef93, 0xffffdd4e, + 0x3fe8, 0x40a2, 0xffffeac0, 0x6f7d, 0xffff83d1, 0x459e, 0x6eee, 0x7da, + 0xffff9f26, 0xffff9da6, 0xffffb81c, 0x25c8, 0x32a6, 0x2351, 0xffff7450, 0xffff90f0, + 0x16ee, 0xffffa868, 0xffffa2cb, 0xffff79fc, 0xfffffe99, 0x6a31, 0x1a59, 0xffffbca9, + 0xffff8d29, 0xffffc840, 0xffffd7e8, 0xffff9128, 0xfffff92c, 0xffffd49d, 0xffffa0a4, 0x7533, + 0x748, 0x4245, 0x34bc, 0x366c, 0xffffc838, 0x3265, 0x8226, 0x4aca, + 0xffffe761, 0x19e, 0x46bb, 0xffffdafa, 0xffffdd98, 0xffffc1b8, 0x7aa8, 0xffffc744, + 0xffff7766, 0xffffeb0c, 0x675b, 0x573, 0x5b52, 0xffffd638, 0x49a1, 0x5235, + 0xffffcd48, 0xffff8960, 0xffff8468, 0xffffc6b1, 0xfffff7c1, 0x6995, 0x5eb4, 0xffffc196, + 0xffff7779, 0x6104, 0xffff8f5b, 0x2928, 0x6cf0, 0x1b93, 0xffffbdd9, 0x1ca5, + 0x81b, 0x64c3, 0xfffff230, 0xffffc185, 0xffffd191, 0xffff858e, 0x6eb8, 0xffffd904, + 0x89ca, 0xffff8102, 0xffffc709, 0x39e2, 0x5bde, 0x1e9e, 0xffffb9c8, 0x81c2, + 0xffffb753, 0xffff9bba, 0xfe5, 0xffffaabf, 0xffff82e0, 0xffffcc44, 0x22e0, 0x1053, + 0x6b07, 0x2522, 0x6316, 0x5ddf, 0xfffff8fe, 0xffff896b, 0x8a7d, 0xffff9398, + 0xffffa42f, 0x4f57, 0x71a, 0xffffef95, 0xffffb170, 0x12e9, 0xffff8147, 0xffffdc5c, + 0xffff9d76, 0x2a39, 0x2a4a, 0x2d76, 0xffffa31c, 0xffffafcf, 0xffffb76e, 0x617c, + 0xa00, 0xffff878f, 0xffff737a, 0x6f54, 0x7516, 0xffffbc9a, 0x39c8, 0x5bbe, + 0x4d20, 0x32b6, 0xffff8d2f, 0xffffcee7, 0x46ef, 0x3bdb, 0xffffc557, 0xffffe1a6, + 0xffff7a54, 0x6572, 0xffff9a6d, 0x7b59, 0x3be8, 0xffffd635, 0x1acd, 0xffffe77a, + 0xffffa8c9, 0x531c, 0xffff8a3a, 0xfffff65d, 0xb96, 0x49b8, 0x735b, 0x791, + 0x682b, 0xfffff0f6, 0x179e, 0xfffff2ef, 0x3992, 0xffffc2d8, 0xffffb85c, 0xffff9e2d, + 0xffffdc7a, 0x1202, 0xffff761e, 0xffffae43, 0xffffddc9, 0xffff8377, 0xffffd6dc, 0x124, + 0x493d, 0x2f55, 0xfffff8c8, 0x5f25, 0xfffff800, 0xffff738a, 0x3465, 0x1089, + 0x4ea3, 0xffff83ec, 0x4f50, 0xffffaac4, 0x1c54, 0x58c5, 0xffffe6ab, 0xffff8a2e, + 0x74b2, 0x6032, 0xfffff56b, 0x836c, 0xffff8f09, 0x8316, 0xffffeb3e, 0x257c, + 0xffffd7c8, 0x671f, 0x4eab, 0x1220, 0xffff7c40, 0x3c05, 0xffffd400, 0x841, + 0xffff7c1a, 0x5119, 0x371c, 0xffffb126, 0xffffa46d, 0xffff8f00, 0xfffffed8, 0x6db7, + 0x1608, 0xffff7c99, 0x72a6, 0x7cad, 0xffff7831, 0x810d, 0x79d5, 0x1b55, + 0xffffd273, 0x5d84, 0x5983, 0xffffff4a, 0x5005, 0x69bf, 0xffffe75f, 0xffffd029, + 0xffffe1e8, 0xffff9e76, 0xff2, 0xfffff4d4, 0xffffe108, 0xffffb618, 0xffffed8b, 0xd27, + 0x94d, 0x52ff, 0x8634, 0xffffa360, 0xffffffe3, 0xffffb0d8, 0xffffaaee, 0xfffff959, + 0xffffbdaf, 0xffffc563, 0x2506, 0x4a98, 0xfffff9bb, 0x4ad2, 0x25f4, 0xffff9987, + 0x5bf9, 0x8d03, 0x58d7, 0xffff988b, 0xffffe7b6, 0x1aeb, 0xffffdd88, 0xffffd037, + 0xffff9db8, 0xffff77f7, 0x693, 0x8863, 0xffff9329, 0xffffb19f, 0x5447, 0x2606, + 0x77dd, 0xffffbd47, 0xfffffb00, 0x4c00, 0xffff9169, 0x7d2a, 0x8548, 0xffffe574, + 0x44b, 0xffffe68c, 0xffff9738, 0x4689, 0x27f6, 0x5a2c, 0x37a7, 0x529d, + 0xffff7c73, 0x76f2, 0x242f, 0x8134, 0x30a8, 0x3ab2, 0xfffffe83, 0x3bd5, + 0xffffc9ed, 0xffff7be3, 0x6356, 0xffffab4b, 0x6d2d, 0xffffb6dc, 0x1d24, 0x6908, + 0x6aa6, 0x4fe3, 0xffffe221, 0xffff8985, 0x3389, 0x6062, 0x8700, 0x4834, + 0x8cba, 0x842c, 0x15dd, 0x86ac, 0xffffa5c2, 0x375c, 0xffffc3e1, 0x2517, + 0x2a44, 0xffffa391, 0xffffec55, 0xffff7bec, 0xffffb1e1, 0x5156, 0x7b17, 0xd57, + 0x962, 0x4e52, 0x3b2e, 0xffffab67, 0xffffda44, 0x69e8, 0xffff78ec, 0xffffd084, + 0xffff8488, 0x773a, 0x6c60, 0xffffa9c9, 0x6d4a, 0xfffffe96, 0xffffe0e0, 0x1bef, + 0xffffde02, 0xaae, 0xffff9a10, 0x557, 0x4da9, 0x867c, 0x1741, 0x42f8, + 0xffffd09b, 0xffffd2d1, 0xffffe212, 0xfffff266, 0x45ed, 0xffffe717, 0x6837, 0x76c1, + 0xfffffef7, 0x5baf, 0xffffbee3, 0xffff830d, 0xffffb4fa, 0x372b, 0xffffb440, 0xffff8e7e, + 0xffffa00d, 0xffffbb90, 0xffff92d7, 0xffffa723, 0xffffe18b, 0xfffffbe0, 0xffffdf88, 0xffff76d1, + 0xffffd2af, 0x3a01, 0x8c46, 0xfffff48e, 0xffff8ada, 0xffffb3f4, 0x46ba, 0xffffa696, + 0x4a04, 0x8cf1, 0x362f, 0xffffc320, 0x73d2, 0xffffa00f, 0xfffff6ad, 0x7269, + 0x695e, 0x4812, 0x3b16, 0x6442, 0xffffa02b, 0xffffc2c0, 0xffffe410, 0xffffb923, + 0x6012, 0xffffdcd3, 0xffffbdfe, 0xffff97be, 0x6ad6, 0xffffe081, 0xffff97e9, 0xffff8adf, + 0xd9e, 0xffff7e8f, 0xffffc9c6, 0x6a7e, 0x53b9, 0xffff7fb5, 0x8314, 0xffff81f5, + 0x1d86, 0x3e5d, 0xfffffd9d, 0x201e, 0xffffde6d, 0x2055, 0x7317, 0x167c, + 0xffffcfa0, 0xffff9bbc, 0xffffa8e0, 0x2d83, 0x5a8d, 0xffffb0bd, 0x3926, 0x669f, + 0x4b9e, 0x6345, 0x2c7, 0xffff91c9, 0xffff745a, 0x5091, 0x56a3, 0x6e45, + 0x31ac, 0xffff9847, 0xffffbb04, 0x617c, 0x1374, 0x8dd7, 0xffffe142, 0xffffeb42, + 0x9d4, 0xffff8b2d, 0x84fc, 0x3b6, 0x604a, 0xffffd453, 0xffffd691, 0xffff7927, + 0xc47, 0x169d, 0x70bb, 0x10d4, 0x6b25, 0xffff8965, 0xffffc874, 0xffff7571, + 0x2165, 0xffffbb50, 0xffff7623, 0xffffab6f, 0xfffff47a, 0xffffb87b, 0x14d1, 0xffffff82, + 0xffffe1b8, 0xf6b, 0xffff74f4, 0xffffefb6, 0xffff88c0, 0x2eec, 0xffffade2, 0xffffdcd2, + 0xffffb1cc, 0x334f, 0xffffc569, 0xffff8414, 0x8070, 0x7bfa, 0x8992, 0xffffcc6d, + 0xffffa65a, 0x251f, 0x8bbf, 0x2463, 0xffff74d2, 0xfffff0cf, 0xffffde9a, 0x4f4a, + 0xffff8446, 0xffffa4e2, 0x808a, 0xfffffadd, 0x723e, 0xffffd82d, 0x1f14, 0x8c71, + 0xffffdc75, 0x6c3c, 0x4435, 0x472f, 0xffff7252, 0x22e5, 0x19c0, 0x88aa, + 0xffffd423, 0xffff8758, 0x2758, 0xffffd33d, 0xffffe1bb, 0x83b3, 0x8535, 0xaa5, + 0x7864, 0x6b59, 0x2ab7, 0x7e5b, 0x6df6, 0x6f3e, 0xffff908a, 0xffffb6d4, + 0x4eca, 0xffffa83f, 0xffffff3f, 0xffff7a6a, 0xffff74aa, 0x37e9, 0xffff8a5e, 0xfffff391, + 0xffffc4c1, 0x36fb, 0x21e2, 0x623d, 0xffff7306, 0xfffff202, 0x39cb, 0xffffcd47, + 0x13b6, 0x630e, 0xffffa3e6, 0xffffeb86, 0x5eb8, 0xffff73c0, 0xfffffa42, 0x49fb, + 0xffffed95, 0x718f, 0xffff7e6a, 0x1914, 0xffffa5e9, 0x8cf1, 0x2ae3, 0xfffff9e8, + 0xffffec23, 0x697d, 0x5ab9, 0x77f0, 0xfffff222, 0x5ff0, 0xffffa34d, 0x82bc, + 0x5950, 0x13c1, 0x5a9b, 0x570c, 0x4992, 0x405c, 0x3ecd, 0xfffff886, + 0x1362, 0x1704, 0xffff87b3, 0xffffe31c, 0x7e6c, 0x27e7, 0x355a, 0xffff84c4, + 0xffffe078, 0xffffc000, 0xffffd37a, 0x2690, 0x130d, 0xffffd22b, 0xffffa6c1, 0x12dd, + 0x36db, 0x5507, 0xffff8c14, 0xffffb616, 0x71ab, 0xffffd884, 0xffff7ed4, 0x1871, + 0x212a, 0xffff8acf, 0x353, 0x3bca, 0x7cfc, 0xffff7a5d, 0x5990, 0x4bb, + 0xffff7606, 0x6328, 0x386, 0xffffd02b, 0xffffe3b6, 0xfffff0bb, 0x4b6f, 0x8dc, + 0xfffff3ea, 0x169c, 0x3ed8, 0xffffa125, 0x3c69, 0xfffffedb, 0x6c9b, 0x17de, + 0xffffb5f8, 0xef6, 0xfffffbc6, 0xffff82b9, 0xffff7a4e, 0x6193, 0x6994, 0xffffe6b5, + 0xffffdb01, 0x5c14, 0x68a8, 0x26a4, 0xffffb021, 0x7bcc, 0xffff9f05, 0x814, + 0x162c, 0xffffb3e7, 0x2c53, 0xffffc8e1, 0x6920, 0xffff7254, 0x6d49, 0xffffb4c2, + 0xffffcaca, 0xffffe1cd, 0xffffd576, 0xffffbad8, 0xffffc4db, 0xffff7f6b, 0x758b, 0x1f19, + 0x4407, 0x3b61, 0xffffa2ea, 0xfffff403, 0x26b, 0x6789, 0x5ca7, 0x3b3, + 0x458b, 0xffffd823, 0xffff83b7, 0x2dc6, 0xffffbd8d, 0xffff7964, 0x77a3, 0x18bd, + 0x7ada, 0xffffc92e, 0x32e2, 0xffffe36a, 0xffff79db, 0x6ca2, 0xffffafdb, 0xffffba78, + 0x23cb, 0xffffc5ad, 0xffffe3f4, 0x89d5, 0x86ee, 0x13ca, 0xfffff25b, 0x3ebb, + 0x680d, 0x628a, 0xffffce21, 0x44c, 0xffff7532, 0xffff72a6, 0xffff88d5, 0x8599, + 0xffffe7cf, 0xffffbeed, 0xffffbcf5, 0x675c, 0x481d, 0x6ac3, 0xffffc0ae, 0x4ce4, + 0x46ef, 0x2b3f, 0x47fd, 0x35f4, 0xc48, 0x3038, 0x7b9b, 0x302d, + 0xffff85f4, 0x6652, 0xffff7f44, 0xffffec9b, 0xffffedd2, 0x2863, 0x2faa, 0x8cf1, + 0xffffc4e8, 0xcb3, 0xffff925c, 0xffffc9c0, 0xffffad2f, 0x5eb1, 0x5697, 0x66bd, + 0xffff8080, 0xffff98b1, 0x2955, 0xffffcdbd, 0xffffd6d8, 0xffff84a6, 0xffffe29c, 0xffff9edd, + 0x391f, 0x625c, 0xffff8094, 0xffffbad3, 0xffff8b97, 0x7d06, 0xffffadce, 0x1036, + 0xffffcbd0, 0x3027, 0xfffff405, 0x3104, 0xffffd411, 0x614d, 0x426b, 0x410, + 0x3524, 0xffffddf3, 0x3c3b, 0x7663, 0x4d40, 0x7c3e, 0xffffa330, 0xffffbd4a, + 0xffffce53, 0x989, 0xffffddc9, 0xffff92ed, 0x4449, 0xffffa2d2, 0xfffff261, 0x5c84, + 0xfffff447, 0xfffff6c6, 0x4520, 0xffffa40d, 0xffffd253, 0xffffbf75, 0xffffaeea, 0x8c96, + 0xffff7c66, 0xffffc745, 0x572b, 0x5167, 0xffffdc8a, 0x46cc, 0x5b66, 0xffffd61c, + 0x3fc6, 0x7a63, 0xffffc4d8, 0xffffe8b4, 0xffffdc6a, 0x6f63, 0xffffd716, 0xffffbb46, + 0x7426, 0xffff7dde, 0x26f1, 0xffffcd18, 0x1776, 0x4d89, 0x20c5, 0x6457, + 0x371c, 0xffff8c94, 0xffff72e4, 0x7cc, 0x835b, 0xffffb776, 0xffff93e1, 0xffff83cd, + 0x7241, 0xffffcfc4, 0xffffbda6, 0x63f0, 0xffffaa19, 0x7cf5, 0xffff8f8d, 0x1942, + 0xffff87ae, 0x4e6d, 0xffff78d5, 0x6e8c, 0x3539, 0xffffc063, 0x73c, 0x76dc, + 0xfffff8ff, 0xffffb5a1, 0x19bf, 0xffff7694, 0xf15, 0xfffff136, 0xffff82b9, 0xffffcc83, + 0xffff88a4, 0xffffc7e0, 0xffff7256, 0xffffe068, 0x25b4, 0xffffed48, 0xffff8d7d, 0x5f8c, + 0x1892, 0xffffd1e5, 0xffff7417, 0x7ecc, 0xfffffb74, 0x8c0c, 0x4758, 0xffffc7d7, + 0xffffe764, 0xfffffe29, 0xffff88fa, 0xffffe66d, 0xffffdeb4, 0x2f2d, 0x646b, 0xffffce8c, + 0x3769, 0x3912, 0xffffe6fb, 0xffffc166, 0xffffce02, 0x4dc7, 0x80b5, 0xffffc70d, + 0xffffc36a, 0x30ea, 0x7441, 0x5fe4, 0xffff7812, 0xffffe92e, 0xffffcc86, 0xffffe27b, + 0x49e2, 0x71c0, 0xffffab47, 0xffff9c51, 0x7377, 0xfffffc50, 0x7be0, 0x13e0, + 0xffffe5f2, 0x2db1, 0x2610, 0xffff8258, 0xffff978f, 0x282b, 0x395, 0x1031, + 0xffffb66c, 0xffff749b, 0xffffbf6f, 0xffffa7e1, 0x12f1, 0xffffcfa7, 0xfffff7fd, 0x6a21, + 0x8a4d, 0x4ff5, 0x71be, 0x8096, 0x5502, 0x4f40, 0x81c5, 0x5a75, + 0xffff8d39, 0x1bc0, 0xffff7827, 0xa59, 0xffff9929, 0x8db3, 0x5df1, 0xfffff7b2, + 0x420a, 0x6544, 0x6509, 0x7451, 0x1e7f, 0x4f76, 0x315a, 0x3620, + 0x5091, 0x4403, 0xffffd3e4, 0x5c0c, 0x80c2, 0x36c4, 0x5107, 0xffff943d, + 0x6452, 0xffffad40, 0xffff9b98, 0x58ab, 0x27b3, 0xffff8be9, 0xffffa656, 0xffffa5f8, + 0xffffbd22, 0xffff73fd, 0x2758, 0xffffa764, 0x62ed, 0xffff90c5, 0x1e51, 0xffff897b, + 0xffff82b3, 0x2d25, 0x76ad, 0xffff7f02, 0xfffffa89, 0x2d4f, 0x2ab, 0x5685, + 0x8ce1, 0xfffff7de, 0x5522, 0xffffbc64, 0xffff9e79, 0xffffef8b, 0xffff84f0, 0xffff933c, + 0x102e, 0x8bc, 0x5a44, 0xfffffe4f, 0xffffaed9, 0x7aee, 0xffffa2ae, 0x12e0, + 0x7c7b, 0x3a66, 0xffffb1f5, 0xffffa575, 0x3bf3, 0xffffe14f, 0xffffedca, 0xfffffb3d, + 0xffff8279, 0x296b, 0x8bc7, 0xc1b, 0xffffea63, 0x65cd, 0xffffa851, 0x878f, + 0xe37, 0x501a, 0x581c, 0x16c3, 0x6279, 0xffff9e12, 0xfffffc2c, 0x7d4c, + 0x4c95, 0xffffced3, 0xffff8b07, 0xffff87b0, 0xffffa928, 0x6ce2, 0xffff8bc1, 0xffff7fab, + 0x5249, 0xffffbf8f, 0x8074, 0x1ab9, 0xffffe2ed, 0xffffebbb, 0xfffffd25, 0x474f, + 0xffffe439, 0xffffe258, 0xffffb947, 0xfffffa1b, 0xffff90ea, 0x8134, 0x6eed, 0xffffc392, + 0xffff934a, 0xffffb921, 0xd9a, 0x6581, 0x37f2, 0xffffe672, 0xffffafd9, 0x30eb, + 0xffffa08e, 0xffffa39d, 0xffff9657, 0x26d0, 0xffffb97f, 0x5df, 0xffff9257, 0x3a34, + 0xfffffd43, 0xffffc367, 0x8bf0, 0x186, 0x1692, 0x5420, 0x7d2c, 0x83dd, + 0x4ad1, 0xfffffc05, 0x67a4, 0x7b06, 0xffffacd2, 0x7c2, 0x4f9a, 0x586a, + 0xffffdacd, 0xfffff2e4, 0xffffa666, 0xffffa2f2, 0xffffdd98, 0x50ec, 0xffffec94, 0xffffe01d, + 0xffffe6a5, 0x2b32, 0xffff9128, 0xffffba30, 0xffff82ba, 0xffffe9fc, 0xffffe738, 0x20fa, + 0x3c1b, 0xffffce2f, 0x533, 0x8bdf, 0x79be, 0xffff86e9, 0x82cf, 0xffffab3e, + 0x591d, 0xfffffeb2, 0xffff7424, 0x8932, 0xffffe0f9, 0xffff9d92, 0xffff7b20, 0x2495, + 0x879d, 0x85a3, 0x6f1f, 0x1cf2, 0x1220, 0x65c2, 0xffffc751, 0xffffa10f, + 0xffffa5df, 0xffffd1fd, 0xffffac41, 0xffff73d2, 0xffffc38e, 0xffffa17a, 0xffff9f58, 0x6600, + 0xffff95d8, 0x8400, 0x38dc, 0xffff9844, 0xffff9378, 0x5fdc, 0x3ed8, 0xb4b, + 0xffffb1fd, 0xffff72a1, 0x6313, 0x3acb, 0xffffd03c, 0xffffe6bb, 0x59f7, 0x5a17, + 0x20c2, 0xffffddc9, 0x60e0, 0xffffb1ff, 0x7867, 0xffffad34, 0x8cb0, 0xffff89ed, + 0xffff9cf1, 0x57ed, 0x186b, 0x85bb, 0x1ed9, 0xffffd073, 0x755, 0x39d, + 0xffffe507, 0x5144, 0x3bdd, 0xffff748f, 0x5a22, 0x2f8c, 0xffffe210, 0xffff8285, + 0x2ffa, 0x17c1, 0x11b5, 0xffffa5ff, 0x3950, 0x6b7f, 0xffffc962, 0xfffff345, + 0x80c6, 0xffffbb45, 0xffffac73, 0xffff941e, 0xffff9774, 0xffffe733, 0x35cb, 0xffffb0e4, + 0x8a90, 0x296d, 0xffffea99, 0xffffb292, 0x3778, 0xffffff27, 0x3422, 0x2bd4, + 0xffffb0ac, 0xffffda12, 0x3f00, 0x36ed, 0x38ec, 0xffff9a13, 0xffff9d40, 0x5ec5, + 0x5a1b, 0x5a7d, 0xffffccab, 0xfffffcd1, 0xffffa33b, 0xffff9848, 0x31d8, 0x2224, + 0x2eb0, 0xffffa658, 0xffff9e76, 0xffffd97a, 0x65a8, 0xffff8029, 0xf42, 0x2c21 +}; + diff --git a/lib/rbcodec/codecs/libwma/wmadec.h b/lib/rbcodec/codecs/libwma/wmadec.h new file mode 100644 index 0000000000..76429dede1 --- /dev/null +++ b/lib/rbcodec/codecs/libwma/wmadec.h @@ -0,0 +1,181 @@ +/* + * WMA compatible decoder + * Copyright (c) 2002 The FFmpeg Project. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef _WMADEC_H +#define _WMADEC_H + +#include +#include "ffmpeg_get_bits.h" +#include "types.h" + +//#define TRACE +/* size of blocks */ +#define BLOCK_MIN_BITS 7 +#define BLOCK_MAX_BITS 11 +#define BLOCK_MAX_SIZE (1 << BLOCK_MAX_BITS) + +#define BLOCK_NB_SIZES (BLOCK_MAX_BITS - BLOCK_MIN_BITS + 1) + +/* XXX: find exact max size */ +#define HIGH_BAND_MAX_SIZE 16 + +#define NB_LSP_COEFS 10 + +/* XXX: is it a suitable value ? */ +#define MAX_CODED_SUPERFRAME_SIZE 16384 + +#define M_PI 3.14159265358979323846 + +#define M_PI_F 0x3243f // in fixed 32 format +#define TWO_M_PI_F 0x6487f //in fixed 32 + +#define MAX_CHANNELS 2 + +#define NOISE_TAB_SIZE 8192 + +#define LSP_POW_BITS 7 + + +#if (CONFIG_CPU == PP5022) || (CONFIG_CPU == PP5024) || (CONFIG_CPU == MCF5250) +/* PP5022/24 and MCF5250 have 128KB of IRAM. 80KB are allocated for codecs */ +#define IBSS_ATTR_WMA_LARGE_IRAM IBSS_ATTR +#define IBSS_ATTR_WMA_XL_IRAM +#define ICONST_ATTR_WMA_XL_IRAM + +#elif defined(CPU_S5L870X) +/* S5L870x has even more IRAM. Use it. */ +#define IBSS_ATTR_WMA_LARGE_IRAM IBSS_ATTR +#define IBSS_ATTR_WMA_XL_IRAM IBSS_ATTR +#define ICONST_ATTR_WMA_XL_IRAM ICONST_ATTR + +#else +/* other PP's and MCF5249 have 96KB of IRAM */ +#define IBSS_ATTR_WMA_LARGE_IRAM +#define IBSS_ATTR_WMA_XL_IRAM +#define ICONST_ATTR_WMA_XL_IRAM + +#endif + + +#define VLCBITS 7 /*7 is the lowest without glitching*/ +#define VLCMAX ((22+VLCBITS-1)/VLCBITS) + +#define EXPVLCBITS 7 +#define EXPMAX ((19+EXPVLCBITS-1)/EXPVLCBITS) + +#define HGAINVLCBITS 9 +#define HGAINMAX ((13+HGAINVLCBITS-1)/HGAINVLCBITS) + + +typedef struct CoefVLCTable +{ + int n; /* total number of codes */ + const uint32_t *huffcodes; /* VLC bit values */ + const uint8_t *huffbits; /* VLC bit size */ + const uint16_t *levels; /* table to build run/level tables */ +} +CoefVLCTable; + +typedef struct WMADecodeContext +{ + GetBitContext gb; + + int nb_block_sizes; /* number of block sizes */ + + int sample_rate; + int nb_channels; + int bit_rate; + int version; /* 1 = 0x160 (WMAV1), 2 = 0x161 (WMAV2) */ + int block_align; + int use_bit_reservoir; + int use_variable_block_len; + int use_exp_vlc; /* exponent coding: 0 = lsp, 1 = vlc + delta */ + int use_noise_coding; /* true if perceptual noise is added */ + int byte_offset_bits; + VLC exp_vlc; + int exponent_sizes[BLOCK_NB_SIZES]; + uint16_t exponent_bands[BLOCK_NB_SIZES][25]; + int high_band_start[BLOCK_NB_SIZES]; /* index of first coef in high band */ + int coefs_start; /* first coded coef */ + int coefs_end[BLOCK_NB_SIZES]; /* max number of coded coefficients */ + int exponent_high_sizes[BLOCK_NB_SIZES]; + int exponent_high_bands[BLOCK_NB_SIZES][HIGH_BAND_MAX_SIZE]; + VLC hgain_vlc; + + /* coded values in high bands */ + int high_band_coded[MAX_CHANNELS][HIGH_BAND_MAX_SIZE]; + int high_band_values[MAX_CHANNELS][HIGH_BAND_MAX_SIZE]; + + /* there are two possible tables for spectral coefficients */ + VLC coef_vlc[2]; + uint16_t *run_table[2]; + uint16_t *level_table[2]; + /* frame info */ + int frame_len; /* frame length in samples */ + int frame_len_bits; /* frame_len = 1 << frame_len_bits */ + + /* block info */ + int reset_block_lengths; + int block_len_bits; /* log2 of current block length */ + int next_block_len_bits; /* log2 of next block length */ + int prev_block_len_bits; /* log2 of prev block length */ + int block_len; /* block length in samples */ + int block_num; /* block number in current frame */ + int block_pos; /* current position in frame */ + uint8_t ms_stereo; /* true if mid/side stereo mode */ + uint8_t channel_coded[MAX_CHANNELS]; /* true if channel is coded */ + int exponents_bsize[MAX_CHANNELS]; // log2 ratio frame/exp. length + fixed32 exponents[MAX_CHANNELS][BLOCK_MAX_SIZE] MEM_ALIGN_ATTR; + fixed32 max_exponent[MAX_CHANNELS]; + int16_t coefs1[MAX_CHANNELS][BLOCK_MAX_SIZE]; + fixed32 (*coefs)[MAX_CHANNELS][BLOCK_MAX_SIZE]; + fixed32 *windows[BLOCK_NB_SIZES]; + /* output buffer for one frame and the last for IMDCT windowing */ + fixed32 (*frame_out)[MAX_CHANNELS][BLOCK_MAX_SIZE*2]; + + /* last frame info */ + uint8_t last_superframe[MAX_CODED_SUPERFRAME_SIZE + 4] MEM_ALIGN_ATTR; /* padding added */ + int last_bitoffset; + int last_superframe_len; + fixed32 *noise_table; + int noise_index; + fixed32 noise_mult; /* XXX: suppress that and integrate it in the noise array */ + /* lsp_to_curve tables */ + fixed32 lsp_cos_table[BLOCK_MAX_SIZE] MEM_ALIGN_ATTR; + void *lsp_pow_m_table1; + void *lsp_pow_m_table2; + + /* State of current superframe decoding */ + int bit_offset; + int nb_frames; + int current_frame; + +#ifdef TRACE + + int frame_count; +#endif +} +WMADecodeContext; + +int wma_decode_init(WMADecodeContext* s, asf_waveformatex_t *wfx); +int wma_decode_superframe_init(WMADecodeContext* s, + const uint8_t *buf, int buf_size); +int wma_decode_superframe_frame(WMADecodeContext* s, + const uint8_t *buf, int buf_size); +#endif diff --git a/lib/rbcodec/codecs/libwma/wmadeci.c b/lib/rbcodec/codecs/libwma/wmadeci.c new file mode 100644 index 0000000000..d7a836dd97 --- /dev/null +++ b/lib/rbcodec/codecs/libwma/wmadeci.c @@ -0,0 +1,1445 @@ +/* + * WMA compatible decoder + * Copyright (c) 2002 The FFmpeg Project. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/** + * @file wmadec.c + * WMA compatible decoder. + */ + +#include +#include +#include +#include "wmadec.h" +#include "wmafixed.h" +#include "wmadata.h" + +static void wma_lsp_to_curve_init(WMADecodeContext *s, int frame_len); + +/*declarations of statically allocated variables used to remove malloc calls*/ + +static fixed32 coefsarray[MAX_CHANNELS][BLOCK_MAX_SIZE] IBSS_ATTR MEM_ALIGN_ATTR; +/*decode and window into IRAM on targets with at least 80KB of codec IRAM*/ +static fixed32 frame_out_buf[MAX_CHANNELS][BLOCK_MAX_SIZE * 2] IBSS_ATTR_WMA_LARGE_IRAM MEM_ALIGN_ATTR; + +/*MDCT reconstruction windows*/ +static fixed32 stat0[2048] IBSS_ATTR_WMA_XL_IRAM MEM_ALIGN_ATTR; +static fixed32 stat1[1024] IBSS_ATTR_WMA_XL_IRAM MEM_ALIGN_ATTR; +static fixed32 stat2[ 512] IBSS_ATTR_WMA_XL_IRAM MEM_ALIGN_ATTR; +static fixed32 stat3[ 256] IBSS_ATTR_WMA_XL_IRAM MEM_ALIGN_ATTR; +static fixed32 stat4[ 128] IBSS_ATTR_WMA_XL_IRAM MEM_ALIGN_ATTR; + +/*VLC lookup tables*/ +static uint16_t *runtabarray[2]; +static uint16_t *levtabarray[2]; + +static uint16_t runtab_big[1336] MEM_ALIGN_ATTR; +static uint16_t runtab_small[1072] MEM_ALIGN_ATTR; +static uint16_t levtab_big[1336] MEM_ALIGN_ATTR; +static uint16_t levtab_small[1072] MEM_ALIGN_ATTR; + +#define VLCBUF1SIZE 4598 +#define VLCBUF2SIZE 3574 +#define VLCBUF3SIZE 360 +#define VLCBUF4SIZE 540 + +/*putting these in IRAM actually makes PP slower*/ + +static VLC_TYPE vlcbuf1[VLCBUF1SIZE][2] IBSS_ATTR_WMA_XL_IRAM MEM_ALIGN_ATTR; +static VLC_TYPE vlcbuf2[VLCBUF2SIZE][2] MEM_ALIGN_ATTR; +/* This buffer gets reused for lsp tables */ +static VLC_TYPE vlcbuf3[VLCBUF3SIZE][2] MEM_ALIGN_ATTR; +static VLC_TYPE vlcbuf4[VLCBUF4SIZE][2] MEM_ALIGN_ATTR; + + + + +/** + * Apply MDCT window and add into output. + * + * We ensure that when the windows overlap their squared sum + * is always 1 (MDCT reconstruction rule). + * + * The Vorbis I spec has a great diagram explaining this process. + * See section 1.3.2.3 of http://xiph.org/vorbis/doc/Vorbis_I_spec.html + */ + static void wma_window(WMADecodeContext *s, fixed32 *in, fixed32 *out) + { + //float *in = s->output; + int block_len, bsize, n; + + /* left part */ + + /* previous block was larger, so we'll use the size of the current + * block to set the window size*/ + if (s->block_len_bits <= s->prev_block_len_bits) { + block_len = s->block_len; + bsize = s->frame_len_bits - s->block_len_bits; + + vector_fmul_add_add(out, in, s->windows[bsize], block_len); + + } else { + /*previous block was smaller or the same size, so use it's size to set the window length*/ + block_len = 1 << s->prev_block_len_bits; + /*find the middle of the two overlapped blocks, this will be the first overlapped sample*/ + n = (s->block_len - block_len) / 2; + bsize = s->frame_len_bits - s->prev_block_len_bits; + + vector_fmul_add_add(out+n, in+n, s->windows[bsize], block_len); + + memcpy(out+n+block_len, in+n+block_len, n*sizeof(fixed32)); + } + /* Advance to the end of the current block and prepare to window it for the next block. + * Since the window function needs to be reversed, we do it backwards starting with the + * last sample and moving towards the first + */ + out += s->block_len; + in += s->block_len; + + /* right part */ + if (s->block_len_bits <= s->next_block_len_bits) { + block_len = s->block_len; + bsize = s->frame_len_bits - s->block_len_bits; + + vector_fmul_reverse(out, in, s->windows[bsize], block_len); + + } else { + block_len = 1 << s->next_block_len_bits; + n = (s->block_len - block_len) / 2; + bsize = s->frame_len_bits - s->next_block_len_bits; + + memcpy(out, in, n*sizeof(fixed32)); + + vector_fmul_reverse(out+n, in+n, s->windows[bsize], block_len); + + memset(out+n+block_len, 0, n*sizeof(fixed32)); + } + } + + + + +/* XXX: use same run/length optimization as mpeg decoders */ +static void init_coef_vlc(VLC *vlc, + uint16_t **prun_table, uint16_t **plevel_table, + const CoefVLCTable *vlc_table, int tab) +{ + int n = vlc_table->n; + const uint8_t *table_bits = vlc_table->huffbits; + const uint32_t *table_codes = vlc_table->huffcodes; + const uint16_t *levels_table = vlc_table->levels; + uint16_t *run_table, *level_table; + const uint16_t *p; + int i, l, j, level; + + + init_vlc(vlc, VLCBITS, n, table_bits, 1, 1, table_codes, 4, 4, INIT_VLC_USE_NEW_STATIC); + + run_table = runtabarray[tab]; + level_table= levtabarray[tab]; + + p = levels_table; + i = 2; + level = 1; + while (i < n) + { + l = *p++; + for(j=0;jmono*/ + s->channel_coded[0]=0; + s->channel_coded[1]=0; + s->ms_stereo=0; + + s->sample_rate = wfx->rate; + s->nb_channels = wfx->channels; + s->bit_rate = wfx->bitrate; + s->block_align = wfx->blockalign; + + s->coefs = &coefsarray; + s->frame_out = &frame_out_buf; + + if (wfx->codec_id == ASF_CODEC_ID_WMAV1) { + s->version = 1; + } else if (wfx->codec_id == ASF_CODEC_ID_WMAV2 ) { + s->version = 2; + } else { + /*one of those other wma flavors that don't have GPLed decoders */ + return -1; + } + + /* extract flag infos */ + flags2 = 0; + extradata = wfx->data; + if (s->version == 1 && wfx->datalen >= 4) { + flags2 = extradata[2] | (extradata[3] << 8); + }else if (s->version == 2 && wfx->datalen >= 6){ + flags2 = extradata[4] | (extradata[5] << 8); + } + s->use_exp_vlc = flags2 & 0x0001; + s->use_bit_reservoir = flags2 & 0x0002; + s->use_variable_block_len = flags2 & 0x0004; + + /* compute MDCT block size */ + if (s->sample_rate <= 16000){ + s->frame_len_bits = 9; + }else if (s->sample_rate <= 22050 || + (s->sample_rate <= 32000 && s->version == 1)){ + s->frame_len_bits = 10; + }else{ + s->frame_len_bits = 11; + } + s->frame_len = 1 << s->frame_len_bits; + if (s-> use_variable_block_len) + { + int nb_max, nb; + nb = ((flags2 >> 3) & 3) + 1; + if ((s->bit_rate / s->nb_channels) >= 32000) + { + nb += 2; + } + nb_max = s->frame_len_bits - BLOCK_MIN_BITS; //max is 11-7 + if (nb > nb_max) + nb = nb_max; + s->nb_block_sizes = nb + 1; + } + else + { + s->nb_block_sizes = 1; + } + + /* init rate dependant parameters */ + s->use_noise_coding = 1; + high_freq = itofix64(s->sample_rate) >> 1; + + + /* if version 2, then the rates are normalized */ + sample_rate1 = s->sample_rate; + if (s->version == 2) + { + if (sample_rate1 >= 44100) + sample_rate1 = 44100; + else if (sample_rate1 >= 22050) + sample_rate1 = 22050; + else if (sample_rate1 >= 16000) + sample_rate1 = 16000; + else if (sample_rate1 >= 11025) + sample_rate1 = 11025; + else if (sample_rate1 >= 8000) + sample_rate1 = 8000; + } + + fixed64 tmp = itofix64(s->bit_rate); + fixed64 tmp2 = itofix64(s->nb_channels * s->sample_rate); + bps = fixdiv64(tmp, tmp2); + fixed64 tim = bps * s->frame_len; + fixed64 tmpi = fixdiv64(tim,itofix64(8)); + s->byte_offset_bits = av_log2(fixtoi64(tmpi+0x8000)) + 2; + + /* compute high frequency value and choose if noise coding should + be activated */ + bps1 = bps; + if (s->nb_channels == 2) + bps1 = fixmul32(bps,0x1999a); + if (sample_rate1 == 44100) + { + if (bps1 >= 0x9c29) + s->use_noise_coding = 0; + else + high_freq = fixmul32(high_freq,0x6666); + } + else if (sample_rate1 == 22050) + { + if (bps1 >= 0x128f6) + s->use_noise_coding = 0; + else if (bps1 >= 0xb852) + high_freq = fixmul32(high_freq,0xb333); + else + high_freq = fixmul32(high_freq,0x999a); + } + else if (sample_rate1 == 16000) + { + if (bps > 0x8000) + high_freq = fixmul32(high_freq,0x8000); + else + high_freq = fixmul32(high_freq,0x4ccd); + } + else if (sample_rate1 == 11025) + { + high_freq = fixmul32(high_freq,0xb333); + } + else if (sample_rate1 == 8000) + { + if (bps <= 0xa000) + { + high_freq = fixmul32(high_freq,0x8000); + } + else if (bps > 0xc000) + { + s->use_noise_coding = 0; + } + else + { + high_freq = fixmul32(high_freq,0xa666); + } + } + else + { + if (bps >= 0xcccd) + { + high_freq = fixmul32(high_freq,0xc000); + } + else if (bps >= 0x999a) + { + high_freq = fixmul32(high_freq,0x999a); + } + else + { + high_freq = fixmul32(high_freq,0x8000); + } + } + + /* compute the scale factor band sizes for each MDCT block size */ + { + int a, b, pos, lpos, k, block_len, i, j, n; + const uint8_t *table; + + if (s->version == 1) + { + s->coefs_start = 3; + } + else + { + s->coefs_start = 0; + } + for(k = 0; k < s->nb_block_sizes; ++k) + { + block_len = s->frame_len >> k; + + if (s->version == 1) + { + lpos = 0; + for(i=0;i<25;++i) + { + a = wma_critical_freqs[i]; + b = s->sample_rate; + pos = ((block_len * 2 * a) + (b >> 1)) / b; + if (pos > block_len) + pos = block_len; + s->exponent_bands[0][i] = pos - lpos; + if (pos >= block_len) + { + ++i; + break; + } + lpos = pos; + } + s->exponent_sizes[0] = i; + } + else + { + /* hardcoded tables */ + table = NULL; + a = s->frame_len_bits - BLOCK_MIN_BITS - k; + if (a < 3) + { + if (s->sample_rate >= 44100) + table = exponent_band_44100[a]; + else if (s->sample_rate >= 32000) + table = exponent_band_32000[a]; + else if (s->sample_rate >= 22050) + table = exponent_band_22050[a]; + } + if (table) + { + n = *table++; + for(i=0;iexponent_bands[k][i] = table[i]; + s->exponent_sizes[k] = n; + } + else + { + j = 0; + lpos = 0; + for(i=0;i<25;++i) + { + a = wma_critical_freqs[i]; + b = s->sample_rate; + pos = ((block_len * 2 * a) + (b << 1)) / (4 * b); + pos <<= 2; + if (pos > block_len) + pos = block_len; + if (pos > lpos) + s->exponent_bands[k][j++] = pos - lpos; + if (pos >= block_len) + break; + lpos = pos; + } + s->exponent_sizes[k] = j; + } + } + + /* max number of coefs */ + s->coefs_end[k] = (s->frame_len - ((s->frame_len * 9) / 100)) >> k; + /* high freq computation */ + + fixed32 tmp1 = high_freq*2; /* high_freq is a fixed32!*/ + fixed32 tmp2=itofix32(s->sample_rate>>1); + s->high_band_start[k] = fixtoi32( fixdiv32(tmp1, tmp2) * (block_len>>1) +0x8000); + + /* + s->high_band_start[k] = (int)((block_len * 2 * high_freq) / + s->sample_rate + 0.5);*/ + + n = s->exponent_sizes[k]; + j = 0; + pos = 0; + for(i=0;iexponent_bands[k][i]; + end = pos; + if (start < s->high_band_start[k]) + start = s->high_band_start[k]; + if (end > s->coefs_end[k]) + end = s->coefs_end[k]; + if (end > start) + s->exponent_high_bands[k][j++] = end - start; + } + s->exponent_high_sizes[k] = j; + } + } + + /* ffmpeg uses malloc to only allocate as many window sizes as needed. + * However, we're really only interested in the worst case memory usage. + * In the worst case you can have 5 window sizes, 128 doubling up 2048 + * Smaller windows are handled differently. + * Since we don't have malloc, just statically allocate this + */ + fixed32 *temp[5]; + temp[0] = stat0; + temp[1] = stat1; + temp[2] = stat2; + temp[3] = stat3; + temp[4] = stat4; + + /* init MDCT windows : simple sinus window */ + for(i = 0; i < s->nb_block_sizes; i++) + { + int n, j; + fixed32 alpha; + n = 1 << (s->frame_len_bits - i); + window = temp[i]; + + /* this calculates 0.5/(2*n) */ + alpha = (1<<15)>>(s->frame_len_bits - i+1); + for(j=0;jwindows[i] = window; + + } + + s->reset_block_lengths = 1; + + if (s->use_noise_coding) + { + /* init the noise generator */ + if (s->use_exp_vlc) + { + s->noise_mult = 0x51f; + s->noise_table = noisetable_exp; + } + else + { + s->noise_mult = 0xa3d; + /* LSP values are simply 2x the EXP values */ + for (i=0;inoise_table = noisetable_exp; + } +#if 0 +/* We use a lookup table computered in advance, so no need to do this*/ + { + unsigned int seed; + fixed32 norm; + seed = 1; + norm = 0; // PJJ: near as makes any diff to 0! + for (i=0;inoise_table[i] = itofix32((int)seed) * norm; + } + } +#endif + + s->hgain_vlc.table = vlcbuf4; + s->hgain_vlc.table_allocated = VLCBUF4SIZE; + init_vlc(&s->hgain_vlc, HGAINVLCBITS, sizeof(hgain_huffbits), + hgain_huffbits, 1, 1, + hgain_huffcodes, 2, 2, INIT_VLC_USE_NEW_STATIC); + } + + if (s->use_exp_vlc) + { + + s->exp_vlc.table = vlcbuf3; + s->exp_vlc.table_allocated = VLCBUF3SIZE; + + init_vlc(&s->exp_vlc, EXPVLCBITS, sizeof(scale_huffbits), + scale_huffbits, 1, 1, + scale_huffcodes, 4, 4, INIT_VLC_USE_NEW_STATIC); + } + else + { + wma_lsp_to_curve_init(s, s->frame_len); + } + + /* choose the VLC tables for the coefficients */ + coef_vlc_table = 2; + if (s->sample_rate >= 32000) + { + if (bps1 < 0xb852) + coef_vlc_table = 0; + else if (bps1 < 0x128f6) + coef_vlc_table = 1; + } + + /* since the coef2 table is the biggest and that has index 2 in coef_vlcs + it's safe to always assign like this */ + runtabarray[0] = runtab_big; runtabarray[1] = runtab_small; + levtabarray[0] = levtab_big; levtabarray[1] = levtab_small; + + s->coef_vlc[0].table = vlcbuf1; + s->coef_vlc[0].table_allocated = VLCBUF1SIZE; + s->coef_vlc[1].table = vlcbuf2; + s->coef_vlc[1].table_allocated = VLCBUF2SIZE; + + + init_coef_vlc(&s->coef_vlc[0], &s->run_table[0], &s->level_table[0], + &coef_vlcs[coef_vlc_table * 2], 0); + init_coef_vlc(&s->coef_vlc[1], &s->run_table[1], &s->level_table[1], + &coef_vlcs[coef_vlc_table * 2 + 1], 1); + + s->last_superframe_len = 0; + s->last_bitoffset = 0; + + return 0; +} + + +/* compute x^-0.25 with an exponent and mantissa table. We use linear + interpolation to reduce the mantissa table size at a small speed + expense (linear interpolation approximately doubles the number of + bits of precision). */ +static inline fixed32 pow_m1_4(WMADecodeContext *s, fixed32 x) +{ + union { + float f; + unsigned int v; + } u, t; + unsigned int e, m; + fixed32 a, b; + + u.f = fixtof64(x); + e = u.v >> 23; + m = (u.v >> (23 - LSP_POW_BITS)) & ((1 << LSP_POW_BITS) - 1); + /* build interpolation scale: 1 <= t < 2. */ + t.v = ((u.v << LSP_POW_BITS) & ((1 << 23) - 1)) | (127 << 23); + a = ((fixed32*)s->lsp_pow_m_table1)[m]; + b = ((fixed32*)s->lsp_pow_m_table2)[m]; + + /* lsp_pow_e_table contains 32.32 format */ + /* TODO: Since we're unlikely have value that cover the whole + * IEEE754 range, we probably don't need to have all possible exponents */ + + return (lsp_pow_e_table[e] * (a + fixmul32(b, ftofix32(t.f))) >>32); +} + +static void wma_lsp_to_curve_init(WMADecodeContext *s, int frame_len) +{ + fixed32 wdel, a, b, temp2; + int i; + + wdel = fixdiv32(itofix32(1), itofix32(frame_len)); + for (i=0; ilsp_cos_table[i] = temp2>>3; + + } + /* NOTE: these two tables are needed to avoid two operations in + pow_m1_4 */ + b = itofix32(1); + int ix = 0; + + s->lsp_pow_m_table1 = &vlcbuf3[0]; + s->lsp_pow_m_table2 = &vlcbuf3[1<=0;i--) + { + a = pow_a_table[ix++]<<4; + ((fixed32*)s->lsp_pow_m_table1)[i] = 2 * a - b; + ((fixed32*)s->lsp_pow_m_table2)[i] = b - a; + b = a; + } + +} + +/* NOTE: We use the same code as Vorbis here */ +/* XXX: optimize it further with SSE/3Dnow */ +static void wma_lsp_to_curve(WMADecodeContext *s, + fixed32 *out, + fixed32 *val_max_ptr, + int n, + fixed32 *lsp) +{ + int i, j; + fixed32 p, q, w, v, val_max, temp2; + + val_max = 0; + for(i=0;ilsp_cos_table[i]; + + for (j=1;j>9; /* p/q end up as 16.16 */ + v = pow_m1_4(s, v); + if (v > val_max) + val_max = v; + out[i] = v; + } + + *val_max_ptr = val_max; +} + +/* decode exponents coded with LSP coefficients (same idea as Vorbis) + * only used for low bitrate (< 16kbps) files + */ +static void decode_exp_lsp(WMADecodeContext *s, int ch) +{ + fixed32 lsp_coefs[NB_LSP_COEFS]; + int val, i; + + for (i = 0; i < NB_LSP_COEFS; ++i) + { + if (i == 0 || i >= 8) + val = get_bits(&s->gb, 3); + else + val = get_bits(&s->gb, 4); + lsp_coefs[i] = lsp_codebook[i][val]; + } + + wma_lsp_to_curve(s, + s->exponents[ch], + &s->max_exponent[ch], + s->block_len, + lsp_coefs); +} + +/* decode exponents coded with VLC codes - used for bitrate >= 32kbps*/ +static int decode_exp_vlc(WMADecodeContext *s, int ch) +{ + int last_exp, n, code; + const uint16_t *ptr, *band_ptr; + fixed32 v, max_scale; + fixed32 *q,*q_end; + + /*accommodate the 60 negative indices */ + const fixed32 *pow_10_to_yover16_ptr = &pow_10_to_yover16[61]; + + band_ptr = s->exponent_bands[s->frame_len_bits - s->block_len_bits]; + ptr = band_ptr; + q = s->exponents[ch]; + q_end = q + s->block_len; + max_scale = 0; + + + if (s->version == 1) //wmav1 only + { + last_exp = get_bits(&s->gb, 5) + 10; + + v = pow_10_to_yover16_ptr[last_exp]; + max_scale = v; + n = *ptr++; + switch (n & 3) do { + case 0: *q++ = v; + case 3: *q++ = v; + case 2: *q++ = v; + case 1: *q++ = v; + } while ((n -= 4) > 0); + } else { + last_exp = 36; + } + + while (q < q_end) + { + code = get_vlc2(&s->gb, s->exp_vlc.table, EXPVLCBITS, EXPMAX); + if (code < 0) + { + return -1; + } + /* NOTE: this offset is the same as MPEG4 AAC ! */ + last_exp += code - 60; + + v = pow_10_to_yover16_ptr[last_exp]; + if (v > max_scale) + { + max_scale = v; + } + n = *ptr++; + switch (n & 3) do { + case 0: *q++ = v; + case 3: *q++ = v; + case 2: *q++ = v; + case 1: *q++ = v; + } while ((n -= 4) > 0); + } + + s->max_exponent[ch] = max_scale; + return 0; +} + +/* return 0 if OK. return 1 if last block of frame. return -1 if + unrecorrable error. */ +static int wma_decode_block(WMADecodeContext *s) +{ + int n, v, a, ch, code, bsize; + int coef_nb_bits, total_gain; + int nb_coefs[MAX_CHANNELS]; + fixed32 mdct_norm; + + /*DEBUGF("***decode_block: %d (%d samples of %d in frame)\n", s->block_num, s->block_len, s->frame_len);*/ + + /* compute current block length */ + if (s->use_variable_block_len) + { + n = av_log2(s->nb_block_sizes - 1) + 1; + + if (s->reset_block_lengths) + { + s->reset_block_lengths = 0; + v = get_bits(&s->gb, n); + if (v >= s->nb_block_sizes) + { + return -2; + } + s->prev_block_len_bits = s->frame_len_bits - v; + v = get_bits(&s->gb, n); + if (v >= s->nb_block_sizes) + { + return -3; + } + s->block_len_bits = s->frame_len_bits - v; + } + else + { + /* update block lengths */ + s->prev_block_len_bits = s->block_len_bits; + s->block_len_bits = s->next_block_len_bits; + } + v = get_bits(&s->gb, n); + + if (v >= s->nb_block_sizes) + { + // rb->splash(HZ*4, "v was %d", v); //5, 7 + return -4; //this is it + } + else{ + //rb->splash(HZ, "passed v block (%d)!", v); + } + s->next_block_len_bits = s->frame_len_bits - v; + } + else + { + /* fixed block len */ + s->next_block_len_bits = s->frame_len_bits; + s->prev_block_len_bits = s->frame_len_bits; + s->block_len_bits = s->frame_len_bits; + } + /* now check if the block length is coherent with the frame length */ + s->block_len = 1 << s->block_len_bits; + + if ((s->block_pos + s->block_len) > s->frame_len) + { + return -5; //oddly 32k sample from tracker fails here + } + + if (s->nb_channels == 2) + { + s->ms_stereo = get_bits1(&s->gb); + } + v = 0; + for (ch = 0; ch < s->nb_channels; ++ch) + { + a = get_bits1(&s->gb); + s->channel_coded[ch] = a; + v |= a; + } + /* if no channel coded, no need to go further */ + /* XXX: fix potential framing problems */ + if (!v) + { + goto next; + } + + bsize = s->frame_len_bits - s->block_len_bits; + + /* read total gain and extract corresponding number of bits for + coef escape coding */ + total_gain = 1; + for(;;) + { + a = get_bits(&s->gb, 7); + total_gain += a; + if (a != 127) + { + break; + } + } + + if (total_gain < 15) + coef_nb_bits = 13; + else if (total_gain < 32) + coef_nb_bits = 12; + else if (total_gain < 40) + coef_nb_bits = 11; + else if (total_gain < 45) + coef_nb_bits = 10; + else + coef_nb_bits = 9; + + /* compute number of coefficients */ + n = s->coefs_end[bsize] - s->coefs_start; + + for(ch = 0; ch < s->nb_channels; ++ch) + { + nb_coefs[ch] = n; + } + /* complex coding */ + if (s->use_noise_coding) + { + + for(ch = 0; ch < s->nb_channels; ++ch) + { + if (s->channel_coded[ch]) + { + int i, n, a; + n = s->exponent_high_sizes[bsize]; + for(i=0;igb); + s->high_band_coded[ch][i] = a; + /* if noise coding, the coefficients are not transmitted */ + if (a) + nb_coefs[ch] -= s->exponent_high_bands[bsize][i]; + } + } + } + for(ch = 0; ch < s->nb_channels; ++ch) + { + if (s->channel_coded[ch]) + { + int i, n, val, code; + + n = s->exponent_high_sizes[bsize]; + val = (int)0x80000000; + for(i=0;ihigh_band_coded[ch][i]) + { + if (val == (int)0x80000000) + { + val = get_bits(&s->gb, 7) - 19; + } + else + { + //code = get_vlc(&s->gb, &s->hgain_vlc); + code = get_vlc2(&s->gb, s->hgain_vlc.table, HGAINVLCBITS, HGAINMAX); + if (code < 0) + { + return -6; + } + val += code - 18; + } + s->high_band_values[ch][i] = val; + } + } + } + } + } + + /* exponents can be reused in short blocks. */ + if ((s->block_len_bits == s->frame_len_bits) || get_bits1(&s->gb)) + { + for(ch = 0; ch < s->nb_channels; ++ch) + { + if (s->channel_coded[ch]) + { + if (s->use_exp_vlc) + { + if (decode_exp_vlc(s, ch) < 0) + { + return -7; + } + } + else + { + decode_exp_lsp(s, ch); + } + s->exponents_bsize[ch] = bsize; + } + } + } + + /* parse spectral coefficients : just RLE encoding */ + for(ch = 0; ch < s->nb_channels; ++ch) + { + if (s->channel_coded[ch]) + { + VLC *coef_vlc; + int level, run, sign, tindex; + int16_t *ptr, *eptr; + const int16_t *level_table, *run_table; + + /* special VLC tables are used for ms stereo because + there is potentially less energy there */ + tindex = (ch == 1 && s->ms_stereo); + coef_vlc = &s->coef_vlc[tindex]; + run_table = s->run_table[tindex]; + level_table = s->level_table[tindex]; + /* XXX: optimize */ + ptr = &s->coefs1[ch][0]; + eptr = ptr + nb_coefs[ch]; + memset(ptr, 0, s->block_len * sizeof(int16_t)); + + for(;;) + { + code = get_vlc2(&s->gb, coef_vlc->table, VLCBITS, VLCMAX); + + if (code < 0) + { + return -8; + } + if (code == 1) + { + /* EOB */ + break; + } + else if (code == 0) + { + /* escape */ + level = get_bits(&s->gb, coef_nb_bits); + /* NOTE: this is rather suboptimal. reading + block_len_bits would be better */ + run = get_bits(&s->gb, s->frame_len_bits); + } + else + { + /* normal code */ + run = run_table[code]; + level = level_table[code]; + } + sign = get_bits1(&s->gb); + if (!sign) + level = -level; + ptr += run; + if (ptr >= eptr) + { + break; + } + *ptr++ = level; + + + /* NOTE: EOB can be omitted */ + if (ptr >= eptr) + break; + } + } + if (s->version == 1 && s->nb_channels >= 2) + { + align_get_bits(&s->gb); + } + } + + { + int n4 = s->block_len >> 1; + + + mdct_norm = 0x10000>>(s->block_len_bits-1); + + if (s->version == 1) + { + mdct_norm *= fixtoi32(fixsqrt32(itofix32(n4))); + } + } + + + /* finally compute the MDCT coefficients */ + for(ch = 0; ch < s->nb_channels; ++ch) + { + if (s->channel_coded[ch]) + { + int16_t *coefs1; + fixed32 *exponents; + fixed32 *coefs, atemp; + fixed64 mult; + fixed64 mult1; + fixed32 noise, temp1, temp2, mult2; + int i, j, n, n1, last_high_band, esize; + fixed32 exp_power[HIGH_BAND_MAX_SIZE]; + + //total_gain, coefs1, mdctnorm are lossless + + coefs1 = s->coefs1[ch]; + exponents = s->exponents[ch]; + esize = s->exponents_bsize[ch]; + coefs = (*(s->coefs))[ch]; + n=0; + + /* + * The calculation of coefs has a shift right by 2 built in. This + * prepares samples for the Tremor IMDCT which uses a slightly + * different fixed format then the ffmpeg one. If the old ffmpeg + * imdct is used, each shift storing into coefs should be reduced + * by 1. + * See SVN logs for details. + */ + + + if (s->use_noise_coding) + { + /*This case is only used for low bitrates (typically less then 32kbps)*/ + + /*TODO: mult should be converted to 32 bit to speed up noise coding*/ + + mult = fixdiv64(pow_table[total_gain+20],Fixed32To64(s->max_exponent[ch])); + mult = mult* mdct_norm; + mult1 = mult; + + /* very low freqs : noise */ + for(i = 0;i < s->coefs_start; ++i) + { + *coefs++ = fixmul32( (fixmul32(s->noise_table[s->noise_index], + exponents[i<>esize])>>4),Fixed32From64(mult1)) >>2; + s->noise_index = (s->noise_index + 1) & (NOISE_TAB_SIZE - 1); + } + + n1 = s->exponent_high_sizes[bsize]; + + /* compute power of high bands */ + exponents = s->exponents[ch] +(s->high_band_start[bsize]<exponent_high_bands[s->frame_len_bits - + s->block_len_bits][j]; + if (s->high_band_coded[ch][j]) + { + fixed32 e2, v; + e2 = 0; + for(i = 0;i < n; ++i) + { + /*v is normalized later on so its fixed format is irrelevant*/ + v = exponents[i<>esize]>>4; + e2 += fixmul32(v, v)>>3; + } + exp_power[j] = e2/n; /*n is an int...*/ + last_high_band = j; + } + exponents += n<exponents[ch] + (s->coefs_start<high_band_start[bsize] - + s->coefs_start; + } + else + { + n = s->exponent_high_bands[s->frame_len_bits - + s->block_len_bits][j]; + } + if (j >= 0 && s->high_band_coded[ch][j]) + { + /* use noise with specified power */ + fixed32 tmp = fixdiv32(exp_power[j],exp_power[last_high_band]); + + /*mult1 is 48.16, pow_table is 48.16*/ + mult1 = fixmul32(fixsqrt32(tmp), + pow_table[s->high_band_values[ch][j]+20]) >> 16; + + /*this step has a fairly high degree of error for some reason*/ + mult1 = fixdiv64(mult1,fixmul32(s->max_exponent[ch],s->noise_mult)); + mult1 = mult1*mdct_norm>>PRECISION; + for(i = 0;i < n; ++i) + { + noise = s->noise_table[s->noise_index]; + s->noise_index = (s->noise_index + 1) & (NOISE_TAB_SIZE - 1); + *coefs++ = fixmul32((fixmul32(exponents[i<>esize],noise)>>4), + Fixed32From64(mult1)) >>2; + + } + exponents += n<noise_table[s->noise_index]; + s->noise_index = (s->noise_index + 1) & (NOISE_TAB_SIZE - 1); + + /*don't forget to renormalize the noise*/ + temp1 = (((int32_t)*coefs1++)<<16) + (noise>>4); + temp2 = fixmul32(exponents[i<>esize], mult>>18); + *coefs++ = fixmul32(temp1, temp2); + } + exponents += n<block_len - s->coefs_end[bsize]; + mult2 = fixmul32(mult>>16,exponents[((-1<>esize]) ; + for (i = 0; i < n; ++i) + { + /*renormalize the noise product and then reduce to 14.18 precison*/ + *coefs++ = fixmul32(s->noise_table[s->noise_index],mult2) >>6; + + s->noise_index = (s->noise_index + 1) & (NOISE_TAB_SIZE - 1); + } + } + else + { + /*Noise coding not used, simply convert from exp to fixed representation*/ + + fixed32 mult3 = (fixed32)(fixdiv64(pow_table[total_gain+20], + Fixed32To64(s->max_exponent[ch]))); + mult3 = fixmul32(mult3, mdct_norm); + + /*zero the first 3 coefficients for WMA V1, does nothing otherwise*/ + for(i=0; icoefs_start; i++) + *coefs++=0; + + n = nb_coefs[ch]; + + /* XXX: optimize more, unrolling this loop in asm + might be a good idea */ + + for(i = 0;i < n; ++i) + { + /*ffmpeg imdct needs 15.17, while tremor 14.18*/ + atemp = (coefs1[i] * mult3)>>2; + *coefs++=fixmul32(atemp,exponents[i<>esize]); + } + n = s->block_len - s->coefs_end[bsize]; + memset(coefs, 0, n*sizeof(fixed32)); + } + } + } + + + + if (s->ms_stereo && s->channel_coded[1]) + { + fixed32 a, b; + int i; + fixed32 (*coefs)[MAX_CHANNELS][BLOCK_MAX_SIZE] = (s->coefs); + + /* nominal case for ms stereo: we do it before mdct */ + /* no need to optimize this case because it should almost + never happen */ + if (!s->channel_coded[0]) + { + memset((*(s->coefs))[0], 0, sizeof(fixed32) * s->block_len); + s->channel_coded[0] = 1; + } + + for(i = 0; i < s->block_len; ++i) + { + a = (*coefs)[0][i]; + b = (*coefs)[1][i]; + (*coefs)[0][i] = a + b; + (*coefs)[1][i] = a - b; + } + } + + for(ch = 0; ch < s->nb_channels; ++ch) + { + /* BLOCK_MAX_SIZE is 2048 (samples) and MAX_CHANNELS is 2. */ + static uint32_t scratch_buf[BLOCK_MAX_SIZE * MAX_CHANNELS] IBSS_ATTR MEM_ALIGN_ATTR; + if (s->channel_coded[ch]) + { + int n4, index; + + n4 = s->block_len >>1; + + ff_imdct_calc((s->frame_len_bits - bsize + 1), + scratch_buf, + (*(s->coefs))[ch]); + + /* add in the frame */ + index = (s->frame_len / 2) + s->block_pos - n4; + wma_window(s, scratch_buf, &((*s->frame_out)[ch][index])); + + + + /* specific fast case for ms-stereo : add to second + channel if it is not coded */ + if (s->ms_stereo && !s->channel_coded[1]) + { + wma_window(s, scratch_buf, &((*s->frame_out)[1][index])); + } + } + } +next: + /* update block number */ + ++s->block_num; + s->block_pos += s->block_len; + if (s->block_pos >= s->frame_len) + { + return 1; + } + else + { + return 0; + } +} + +/* decode a frame of frame_len samples */ +static int wma_decode_frame(WMADecodeContext *s) +{ + int ret; + + /* read each block */ + s->block_num = 0; + s->block_pos = 0; + + + for(;;) + { + ret = wma_decode_block(s); + if (ret < 0) + { + + DEBUGF("wma_decode_block failed with code %d\n", ret); + return -1; + } + if (ret) + { + break; + } + } + + return 0; +} + +/* Initialise the superframe decoding */ + +int wma_decode_superframe_init(WMADecodeContext* s, + const uint8_t *buf, /*input*/ + int buf_size) +{ + if (buf_size==0) + { + s->last_superframe_len = 0; + return 0; + } + + s->current_frame = 0; + + init_get_bits(&s->gb, buf, buf_size*8); + + if (s->use_bit_reservoir) + { + /* read super frame header */ + skip_bits(&s->gb, 4); /* super frame index */ + s->nb_frames = get_bits(&s->gb, 4); + + if (s->last_superframe_len == 0) + s->nb_frames --; + else if (s->nb_frames == 0) + s->nb_frames++; + + s->bit_offset = get_bits(&s->gb, s->byte_offset_bits + 3); + } else { + s->nb_frames = 1; + } + + return 1; +} + + +/* Decode a single frame in the current superframe - return -1 if + there was a decoding error, or the number of samples decoded. +*/ + +int wma_decode_superframe_frame(WMADecodeContext* s, + const uint8_t *buf, /*input*/ + int buf_size) +{ + int pos, len, ch; + uint8_t *q; + int done = 0; + + for(ch = 0; ch < s->nb_channels; ch++) + memmove(&((*s->frame_out)[ch][0]), + &((*s->frame_out)[ch][s->frame_len]), + s->frame_len * sizeof(fixed32)); + + if ((s->use_bit_reservoir) && (s->current_frame == 0)) + { + if (s->last_superframe_len > 0) + { + /* add s->bit_offset bits to last frame */ + if ((s->last_superframe_len + ((s->bit_offset + 7) >> 3)) > + MAX_CODED_SUPERFRAME_SIZE) + { + DEBUGF("superframe size too large error\n"); + goto fail; + } + q = s->last_superframe + s->last_superframe_len; + len = s->bit_offset; + while (len > 7) + { + *q++ = (get_bits)(&s->gb, 8); + len -= 8; + } + if (len > 0) + { + *q++ = (get_bits)(&s->gb, len) << (8 - len); + } + + /* XXX: s->bit_offset bits into last frame */ + init_get_bits(&s->gb, s->last_superframe, MAX_CODED_SUPERFRAME_SIZE*8); + /* skip unused bits */ + if (s->last_bitoffset > 0) + skip_bits(&s->gb, s->last_bitoffset); + + /* this frame is stored in the last superframe and in the + current one */ + if (wma_decode_frame(s) < 0) + { + goto fail; + } + done = 1; + } + + /* read each frame starting from s->bit_offset */ + pos = s->bit_offset + 4 + 4 + s->byte_offset_bits + 3; + init_get_bits(&s->gb, buf + (pos >> 3), (MAX_CODED_SUPERFRAME_SIZE - (pos >> 3))*8); + len = pos & 7; + if (len > 0) + skip_bits(&s->gb, len); + + s->reset_block_lengths = 1; + } + + /* If we haven't decoded a frame yet, do it now */ + if (!done) + { + if (wma_decode_frame(s) < 0) + { + goto fail; + } + } + + s->current_frame++; + + if ((s->use_bit_reservoir) && (s->current_frame == s->nb_frames)) + { + /* we copy the end of the frame in the last frame buffer */ + pos = get_bits_count(&s->gb) + ((s->bit_offset + 4 + 4 + s->byte_offset_bits + 3) & ~7); + s->last_bitoffset = pos & 7; + pos >>= 3; + len = buf_size - pos; + if (len > MAX_CODED_SUPERFRAME_SIZE || len < 0) + { + DEBUGF("superframe size too large error after decoding\n"); + goto fail; + } + s->last_superframe_len = len; + memcpy(s->last_superframe, buf + pos, len); + } + + return s->frame_len; + +fail: + /* when error, we reset the bit reservoir */ + + s->last_superframe_len = 0; + return -1; +} + diff --git a/lib/rbcodec/codecs/libwma/wmafixed.c b/lib/rbcodec/codecs/libwma/wmafixed.c new file mode 100644 index 0000000000..bdf87a548b --- /dev/null +++ b/lib/rbcodec/codecs/libwma/wmafixed.c @@ -0,0 +1,223 @@ +/**************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * + * Copyright (C) 2007 Michael Giacomelli + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include "wmadec.h" +#include "wmafixed.h" +#include + +fixed64 IntTo64(int x){ + fixed64 res = 0; + unsigned char *p = (unsigned char *)&res; + +#ifdef ROCKBOX_BIG_ENDIAN + p[5] = x & 0xff; + p[4] = (x & 0xff00)>>8; + p[3] = (x & 0xff0000)>>16; + p[2] = (x & 0xff000000)>>24; +#else + p[2] = x & 0xff; + p[3] = (x & 0xff00)>>8; + p[4] = (x & 0xff0000)>>16; + p[5] = (x & 0xff000000)>>24; +#endif + return res; +} + +int IntFrom64(fixed64 x) +{ + int res = 0; + unsigned char *p = (unsigned char *)&x; + +#ifdef ROCKBOX_BIG_ENDIAN + res = p[5] | (p[4]<<8) | (p[3]<<16) | (p[2]<<24); +#else + res = p[2] | (p[3]<<8) | (p[4]<<16) | (p[5]<<24); +#endif + return res; +} + +fixed32 Fixed32From64(fixed64 x) +{ + return x & 0xFFFFFFFF; +} + +fixed64 Fixed32To64(fixed32 x) +{ + return (fixed64)x; +} + +/* + Not performance senstitive code here + +*/ + +fixed32 fixdiv32(fixed32 x, fixed32 y) +{ + fixed64 temp; + + if(x == 0) + return 0; + if(y == 0) + return 0x7fffffff; + temp = x; + temp <<= PRECISION; + return (fixed32)(temp / y); +} + +fixed64 fixdiv64(fixed64 x, fixed64 y) +{ + fixed64 temp; + + if(x == 0) + return 0; + if(y == 0) + return 0x07ffffffffffffffLL; + temp = x; + temp <<= PRECISION64; + return (fixed64)(temp / y); +} + + fixed32 fixsqrt32(fixed32 x) +{ + + unsigned long r = 0, s, v = (unsigned long)x; + +#define STEP(k) s = r + (1 << k * 2); r >>= 1; \ + if (s <= v) { v -= s; r |= (1 << k * 2); } + + STEP(15); + STEP(14); + STEP(13); + STEP(12); + STEP(11); + STEP(10); + STEP(9); + STEP(8); + STEP(7); + STEP(6); + STEP(5); + STEP(4); + STEP(3); + STEP(2); + STEP(1); + STEP(0); + + return (fixed32)(r << (PRECISION / 2)); +} + + + static const long cordic_circular_gain = 0xb2458939; /* 0.607252929 */ + + /* Table of values of atan(2^-i) in 0.32 format fractions of pi where pi = 0xffffffff / 2 */ + static const unsigned long atan_table[] = { + 0x1fffffff, /* +0.785398163 (or pi/4) */ + 0x12e4051d, /* +0.463647609 */ + 0x09fb385b, /* +0.244978663 */ + 0x051111d4, /* +0.124354995 */ + 0x028b0d43, /* +0.062418810 */ + 0x0145d7e1, /* +0.031239833 */ + 0x00a2f61e, /* +0.015623729 */ + 0x00517c55, /* +0.007812341 */ + 0x0028be53, /* +0.003906230 */ + 0x00145f2e, /* +0.001953123 */ + 0x000a2f98, /* +0.000976562 */ + 0x000517cc, /* +0.000488281 */ + 0x00028be6, /* +0.000244141 */ + 0x000145f3, /* +0.000122070 */ + 0x0000a2f9, /* +0.000061035 */ + 0x0000517c, /* +0.000030518 */ + 0x000028be, /* +0.000015259 */ + 0x0000145f, /* +0.000007629 */ + 0x00000a2f, /* +0.000003815 */ + 0x00000517, /* +0.000001907 */ + 0x0000028b, /* +0.000000954 */ + 0x00000145, /* +0.000000477 */ + 0x000000a2, /* +0.000000238 */ + 0x00000051, /* +0.000000119 */ + 0x00000028, /* +0.000000060 */ + 0x00000014, /* +0.000000030 */ + 0x0000000a, /* +0.000000015 */ + 0x00000005, /* +0.000000007 */ + 0x00000002, /* +0.000000004 */ + 0x00000001, /* +0.000000002 */ + 0x00000000, /* +0.000000001 */ + 0x00000000, /* +0.000000000 */ + }; + + /** + * Implements sin and cos using CORDIC rotation. + * + * @param phase has range from 0 to 0xffffffff, representing 0 and + * 2*pi respectively. + * @param cos return address for cos + * @return sin of phase, value is a signed value from LONG_MIN to LONG_MAX, + * representing -1 and 1 respectively. + * + * Gives at least 24 bits precision (last 2-8 bits or so are probably off) + */ + + long fsincos(unsigned long phase, fixed32 *cos) + { + int32_t x, x1, y, y1; + unsigned long z, z1; + int i; + + /* Setup initial vector */ + x = cordic_circular_gain; + y = 0; + z = phase; + + /* The phase has to be somewhere between 0..pi for this to work right */ + if (z < 0xffffffff / 4) { + /* z in first quadrant, z += pi/2 to correct */ + x = -x; + z += 0xffffffff / 4; + } else if (z < 3 * (0xffffffff / 4)) { + /* z in third quadrant, z -= pi/2 to correct */ + z -= 0xffffffff / 4; + } else { + /* z in fourth quadrant, z -= 3pi/2 to correct */ + x = -x; + z -= 3 * (0xffffffff / 4); + } + + /* Each iteration adds roughly 1-bit of extra precision */ + for (i = 0; i < 31; i++) { + x1 = x >> i; + y1 = y >> i; + z1 = atan_table[i]; + + /* Decided which direction to rotate vector. Pivot point is pi/2 */ + if (z >= 0xffffffff / 4) { + x -= y1; + y += x1; + z -= z1; + } else { + x += y1; + y -= x1; + z += z1; + } + } + + if (cos) + *cos = x; + + return y; + } diff --git a/lib/rbcodec/codecs/libwma/wmafixed.h b/lib/rbcodec/codecs/libwma/wmafixed.h new file mode 100644 index 0000000000..4225f165c9 --- /dev/null +++ b/lib/rbcodec/codecs/libwma/wmafixed.h @@ -0,0 +1,237 @@ +/**************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * + * Copyright (C) 2007 Michael Giacomelli + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +/* fixed precision code. We use a combination of Sign 15.16 and Sign.31 + precision here. + + The WMA decoder does not always follow this convention, and occasionally + renormalizes values to other formats in order to maximize precision. + However, only the two precisions above are provided in this file. + +*/ + +#include "types.h" + +#define PRECISION 16 +#define PRECISION64 16 + + +#define fixtof64(x) (float)((float)(x) / (float)(1 << PRECISION64)) //does not work on int64_t! +#define ftofix32(x) ((fixed32)((x) * (float)(1 << PRECISION) + ((x) < 0 ? -0.5 : 0.5))) +#define itofix64(x) (IntTo64(x)) +#define itofix32(x) ((x) << PRECISION) +#define fixtoi32(x) ((x) >> PRECISION) +#define fixtoi64(x) (IntFrom64(x)) + + +/*fixed functions*/ + +fixed64 IntTo64(int x); +int IntFrom64(fixed64 x); +fixed32 Fixed32From64(fixed64 x); +fixed64 Fixed32To64(fixed32 x); +fixed32 fixdiv32(fixed32 x, fixed32 y); +fixed64 fixdiv64(fixed64 x, fixed64 y); +fixed32 fixsqrt32(fixed32 x); +/* Inverse gain of circular cordic rotation in s0.31 format. */ +long fsincos(unsigned long phase, fixed32 *cos); + + +#ifdef CPU_ARM + +/*Sign-15.16 format */ +#define fixmul32(x, y) \ + ({ int32_t __hi; \ + uint32_t __lo; \ + int32_t __result; \ + asm ("smull %0, %1, %3, %4\n\t" \ + "movs %0, %0, lsr %5\n\t" \ + "adc %2, %0, %1, lsl %6" \ + : "=&r" (__lo), "=&r" (__hi), "=r" (__result) \ + : "%r" (x), "r" (y), \ + "M" (PRECISION), "M" (32 - PRECISION) \ + : "cc"); \ + __result; \ + }) + +#elif defined(CPU_COLDFIRE) + +static inline int32_t fixmul32(int32_t x, int32_t y) +{ +#if PRECISION != 16 +#warning Coldfire fixmul32() only works for PRECISION == 16 +#endif + int32_t t1; + asm ( + "mac.l %[x], %[y], %%acc0 \n" // multiply + "mulu.l %[y], %[x] \n" // get lower half, avoid emac stall + "movclr.l %%acc0, %[t1] \n" // get higher half + "lsr.l #1, %[t1] \n" + "move.w %[t1], %[x] \n" + "swap %[x] \n" + : [t1] "=&d" (t1), [x] "+d" (x) + : [y] "d" (y) + ); + return x; +} + +#else + +static inline fixed32 fixmul32(fixed32 x, fixed32 y) +{ + fixed64 temp; + temp = x; + temp *= y; + + temp >>= PRECISION; + + return (fixed32)temp; +} + +#endif + + +/* + * Helper functions for wma_window. + * + * + */ + +#ifdef CPU_ARM +static inline void vector_fmul_add_add(fixed32 *dst, const fixed32 *data, + const fixed32 *window, int n) +{ + /* Block sizes are always power of two */ + asm volatile ( + "0:" + "ldmia %[d]!, {r0, r1};" + "ldmia %[w]!, {r4, r5};" + /* consume the first data and window value so we can use those + * registers again */ + "smull r8, r9, r0, r4;" + "ldmia %[dst], {r0, r4};" + "add r0, r0, r9, lsl #1;" /* *dst=*dst+(r9<<1)*/ + "smull r8, r9, r1, r5;" + "add r1, r4, r9, lsl #1;" + "stmia %[dst]!, {r0, r1};" + "subs %[n], %[n], #2;" + "bne 0b;" + : [d] "+r" (data), [w] "+r" (window), [dst] "+r" (dst), [n] "+r" (n) + : : "r0", "r1", "r4", "r5", "r8", "r9", "memory", "cc"); +} + +static inline void vector_fmul_reverse(fixed32 *dst, const fixed32 *src0, const fixed32 *src1, + int len) +{ + /* Block sizes are always power of two */ + asm volatile ( + "add %[s1], %[s1], %[n], lsl #2;" + "0:" + "ldmia %[s0]!, {r0, r1};" + "ldmdb %[s1]!, {r4, r5};" + "smull r8, r9, r0, r5;" + "mov r0, r9, lsl #1;" + "smull r8, r9, r1, r4;" + "mov r1, r9, lsl #1;" + "stmia %[dst]!, {r0, r1};" + "subs %[n], %[n], #2;" + "bne 0b;" + : [s0] "+r" (src0), [s1] "+r" (src1), [dst] "+r" (dst), [n] "+r" (len) + : : "r0", "r1", "r4", "r5", "r8", "r9", "memory", "cc"); +} + +#elif defined(CPU_COLDFIRE) + +static inline void vector_fmul_add_add(fixed32 *dst, const fixed32 *data, + const fixed32 *window, int n) +{ + /* Block sizes are always power of two. Smallest block is always way bigger + * than four too.*/ + asm volatile ( + "0:" + "movem.l (%[d]), %%d0-%%d3;" + "movem.l (%[w]), %%d4-%%d5/%%a0-%%a1;" + "mac.l %%d0, %%d4, %%acc0;" + "mac.l %%d1, %%d5, %%acc1;" + "mac.l %%d2, %%a0, %%acc2;" + "mac.l %%d3, %%a1, %%acc3;" + "lea.l (16, %[d]), %[d];" + "lea.l (16, %[w]), %[w];" + "movclr.l %%acc0, %%d0;" + "movclr.l %%acc1, %%d1;" + "movclr.l %%acc2, %%d2;" + "movclr.l %%acc3, %%d3;" + "movem.l (%[dst]), %%d4-%%d5/%%a0-%%a1;" + "add.l %%d4, %%d0;" + "add.l %%d5, %%d1;" + "add.l %%a0, %%d2;" + "add.l %%a1, %%d3;" + "movem.l %%d0-%%d3, (%[dst]);" + "lea.l (16, %[dst]), %[dst];" + "subq.l #4, %[n];" + "jne 0b;" + : [d] "+a" (data), [w] "+a" (window), [dst] "+a" (dst), [n] "+d" (n) + : : "d0", "d1", "d2", "d3", "d4", "d5", "a0", "a1", "memory", "cc"); +} + +static inline void vector_fmul_reverse(fixed32 *dst, const fixed32 *src0, const fixed32 *src1, + int len) +{ + /* Block sizes are always power of two. Smallest block is always way bigger + * than four too.*/ + asm volatile ( + "lea.l (-16, %[s1], %[n]*4), %[s1];" + "0:" + "movem.l (%[s0]), %%d0-%%d3;" + "movem.l (%[s1]), %%d4-%%d5/%%a0-%%a1;" + "mac.l %%d0, %%a1, %%acc0;" + "mac.l %%d1, %%a0, %%acc1;" + "mac.l %%d2, %%d5, %%acc2;" + "mac.l %%d3, %%d4, %%acc3;" + "lea.l (16, %[s0]), %[s0];" + "lea.l (-16, %[s1]), %[s1];" + "movclr.l %%acc0, %%d0;" + "movclr.l %%acc1, %%d1;" + "movclr.l %%acc2, %%d2;" + "movclr.l %%acc3, %%d3;" + "movem.l %%d0-%%d3, (%[dst]);" + "lea.l (16, %[dst]), %[dst];" + "subq.l #4, %[n];" + "jne 0b;" + : [s0] "+a" (src0), [s1] "+a" (src1), [dst] "+a" (dst), [n] "+d" (len) + : : "d0", "d1", "d2", "d3", "d4", "d5", "a0", "a1", "memory", "cc"); +} + +#else + +static inline void vector_fmul_add_add(fixed32 *dst, const fixed32 *src0, const fixed32 *src1, int len){ + int i; + for(i=0; i ) \___| < | \_\ ( <_> > < < +# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ +# \/ \/ \/ \/ \/ +# $Id$ +# + +# libwmapro +WMAPROLIB := $(CODECDIR)/libwmapro.a +WMAPROLIB_SRC := $(call preprocess, $(RBCODECLIB_DIR)/codecs/libwmapro/SOURCES) +WMAPROLIB_OBJ := $(call c2obj, $(WMAPROLIB_SRC)) +OTHER_SRC += $(WMAPROLIB_SRC) + +$(WMAPROLIB): $(WMAPROLIB_OBJ) + $(SILENT)$(shell rm -f $@) + $(call PRINTS,AR $(@F))$(AR) rcs $@ $^ >/dev/null diff --git a/lib/rbcodec/codecs/libwmapro/mdct_tables.c b/lib/rbcodec/codecs/libwmapro/mdct_tables.c new file mode 100644 index 0000000000..bec3c37ee7 --- /dev/null +++ b/lib/rbcodec/codecs/libwmapro/mdct_tables.c @@ -0,0 +1,3391 @@ +#include "wmaprodec.h" +#include + +/* Tables for fixed-point trig tables for windowing and mdct */ + +/* Windowing trig tables in s.31 format */ +const int32_t sine_4096[] = { + 0xFFF9B782, 0xFFED2685, 0xFFE09587, 0xFFD4048A, 0xFFC7738D, 0xFFBAE291, + 0xFFAE5196, 0xFFA1C09B, 0xFF952FA1, 0xFF889EA8, 0xFF7C0DB1, 0xFF6F7CBB, + 0xFF62EBC5, 0xFF565AD3, 0xFF49C9E1, 0xFF3D38F0, 0xFF30A803, 0xFF241716, + 0xFF17862C, 0xFF0AF545, 0xFEFE645F, 0xFEF1D37C, 0xFEE5429B, 0xFED8B1BD, + 0xFECC20E4, 0xFEBF900C, 0xFEB2FF37, 0xFEA66E65, 0xFE99DD96, 0xFE8D4CCB, + 0xFE80BC06, 0xFE742B42, 0xFE679A82, 0xFE5B09C6, 0xFE4E790E, 0xFE41E85A, + 0xFE3557AD, 0xFE28C702, 0xFE1C365B, 0xFE0FA5B9, 0xFE03151C, 0xFDF68484, + 0xFDE9F3F3, 0xFDDD6363, 0xFDD0D2DC, 0xFDC4425A, 0xFDB7B1DB, 0xFDAB2164, + 0xFD9E90F0, 0xFD920085, 0xFD85701D, 0xFD78DFBE, 0xFD6C4F66, 0xFD5FBF10, + 0xFD532EC5, 0xFD469E7C, 0xFD3A0E3E, 0xFD2D7E07, 0xFD20EDD2, 0xFD145DA9, + 0xFD07CD83, 0xFCFB3D68, 0xFCEEAD51, 0xFCE21D46, 0xFCD58D42, 0xFCC8FD41, + 0xFCBC6D4D, 0xFCAFDD5D, 0xFCA34D79, 0xFC96BD9D, 0xFC8A2DC6, 0xFC7D9DFB, + 0xFC710E35, 0xFC647E7C, 0xFC57EEC8, 0xFC4B5F20, 0xFC3ECF82, 0xFC323FE9, + 0xFC25B05D, 0xFC1920D7, 0xFC0C915F, 0xFC0001F0, 0xFBF37287, 0xFBE6E329, + 0xFBDA53DC, 0xFBCDC491, 0xFBC13551, 0xFBB4A624, 0xFBA816F8, 0xFB9B87D8, + 0xFB8EF8C3, 0xFB8269C0, 0xFB75DAC1, 0xFB694BCC, 0xFB5CBCEB, 0xFB502E0E, + 0xFB439F3C, 0xFB371076, 0xFB2A81C3, 0xFB1DF315, 0xFB116472, 0xFB04D5E4, + 0xFAF8475A, 0xFAEBB8DC, 0xFADF2A73, 0xFAD29C0F, 0xFAC60DB7, 0xFAB97F6C, + 0xFAACF137, 0xFAA06306, 0xFA93D4E3, 0xFA8746D5, 0xFA7AB8CC, 0xFA6E2AD1, + 0xFA619CE4, 0xFA550F0D, 0xFA48813C, 0xFA3BF379, 0xFA2F65CC, 0xFA22D825, + 0xFA164A8D, 0xFA09BD04, 0xF9FD2F91, 0xF9F0A225, 0xF9E414C8, 0xF9D78782, + 0xF9CAFA43, 0xF9BE6D14, 0xF9B1DFFC, 0xF9A552EB, 0xF998C5EB, 0xF98C38FA, + 0xF97FAC21, 0xF9731F50, 0xF966928F, 0xF95A05E6, 0xF94D7946, 0xF940ECB6, + 0xF9346037, 0xF927D3D1, 0xF91B4774, 0xF90EBB28, 0xF9022EF4, 0xF8F5A2CA, + 0xF8E916B2, 0xF8DC8AAB, 0xF8CFFEBD, 0xF8C372DA, 0xF8B6E708, 0xF8AA5B50, + 0xF89DCFA2, 0xF8914407, 0xF884B885, 0xF8782D0F, 0xF86BA1AA, 0xF85F1659, + 0xF8528B22, 0xF845FFF6, 0xF83974DE, 0xF82CE9E0, 0xF8205EEE, 0xF813D40F, + 0xF8074944, 0xF7FABE95, 0xF7EE33F1, 0xF7E1A961, 0xF7D51EE5, 0xF7C8947E, + 0xF7BC0A3A, 0xF7AF7FFB, 0xF7A2F5D1, 0xF7966BBB, 0xF789E1BA, 0xF77D57CE, + 0xF770CDF7, 0xF7644445, 0xF757BA98, 0xF74B3100, 0xF73EA77E, 0xF7321E12, + 0xF72594BB, 0xF7190B7B, 0xF70C8260, 0xF6FFF94B, 0xF6F3704C, 0xF6E6E764, + 0xF6DA5E92, 0xF6CDD5D7, 0xF6C14D43, 0xF6B4C4B5, 0xF6A83C3E, 0xF69BB3DE, + 0xF68F2B96, 0xF682A365, 0xF6761B4B, 0xF6699358, 0xF65D0B6E, 0xF650839B, + 0xF643FBE0, 0xF637743D, 0xF62AECB2, 0xF61E6540, 0xF611DDF5, 0xF60556B4, + 0xF5F8CF8B, 0xF5EC487A, 0xF5DFC183, 0xF5D33AA4, 0xF5C6B3DF, 0xF5BA2D43, + 0xF5ADA6B0, 0xF5A12037, 0xF59499D7, 0xF5881391, 0xF57B8D65, 0xF56F0753, + 0xF562816B, 0xF555FB8D, 0xF54975C9, 0xF53CF020, 0xF5306A91, 0xF523E51D, + 0xF5175FC4, 0xF50ADA96, 0xF4FE5572, 0xF4F1D06A, 0xF4E54B7D, 0xF4D8C6AC, + 0xF4CC41F6, 0xF4BFBD5C, 0xF4B338ED, 0xF4A6B48B, 0xF49A3044, 0xF48DAC1A, + 0xF481280B, 0xF474A41A, 0xF4682054, 0xF45B9C9B, 0xF44F18FF, 0xF4429580, + 0xF436121E, 0xF4298ED9, 0xF41D0BB1, 0xF41088B6, 0xF40405C9, 0xF3F782F9, + 0xF3EB0047, 0xF3DE7DB3, 0xF3D1FB3D, 0xF3C578E5, 0xF3B8F6BB, 0xF3AC749F, + 0xF39FF2A2, 0xF39370C3, 0xF386EF03, 0xF37A6D62, 0xF36DEBE0, 0xF3616A8C, + 0xF354E948, 0xF3486823, 0xF33BE71E, 0xF32F6638, 0xF322E571, 0xF31664CA, + 0xF309E453, 0xF2FD63ED, 0xF2F0E3A6, 0xF2E4637F, 0xF2D7E379, 0xF2CB6393, + 0xF2BEE3CE, 0xF2B2643A, 0xF2A5E4B6, 0xF2996553, 0xF28CE612, 0xF28066F1, + 0xF273E7F2, 0xF2676924, 0xF25AEA68, 0xF24E6BCE, 0xF241ED55, 0xF2356EFE, + 0xF228F0C9, 0xF21C72B7, 0xF20FF4D6, 0xF2037708, 0xF1F6F95D, 0xF1EA7BD4, + 0xF1DDFE6E, 0xF1D1812B, 0xF1C5040B, 0xF1B8871D, 0xF1AC0A43, 0xF19F8D8D, + 0xF19310FA, 0xF186948A, 0xF17A183F, 0xF16D9C17, 0xF1612023, 0xF154A443, + 0xF1482887, 0xF13BACF0, 0xF12F317D, 0xF122B62F, 0xF1163B05, 0xF109C010, + 0xF0FD4530, 0xF0F0CA75, 0xF0E44FDF, 0xF0D7D56F, 0xF0CB5B24, 0xF0BEE0FE, + 0xF0B2670E, 0xF0A5ED34, 0xF0997380, 0xF08CF9F1, 0xF0808089, 0xF0740747, + 0xF0678E2C, 0xF05B1546, 0xF04E9C78, 0xF04223D0, 0xF035AB4F, 0xF02932F5, + 0xF01CBAC2, 0xF01042C6, 0xF003CAE2, 0xEFF75325, 0xEFEADB90, 0xEFDE6422, + 0xEFD1ECDC, 0xEFC575BE, 0xEFB8FEC8, 0xEFAC87FB, 0xEFA01155, 0xEF939AD8, + 0xEF8724A3, 0xEF7AAE77, 0xEF6E3874, 0xEF61C29A, 0xEF554CE9, 0xEF48D761, + 0xEF3C6202, 0xEF2FECCC, 0xEF2377C0, 0xEF1702DE, 0xEF0A8E25, 0xEEFE1996, + 0xEEF1A531, 0xEEE53116, 0xEED8BD06, 0xEECC491F, 0xEEBFD563, 0xEEB361D2, + 0xEEA6EE6C, 0xEE9A7B30, 0xEE8E081F, 0xEE819539, 0xEE75227E, 0xEE68AFEF, + 0xEE5C3D8B, 0xEE4FCB53, 0xEE435946, 0xEE36E784, 0xEE2A75CF, 0xEE1E0446, + 0xEE1192E9, 0xEE0521B8, 0xEDF8B0B4, 0xEDEC3FDC, 0xEDDFCF31, 0xEDD35EB2, + 0xEDC6EE60, 0xEDBA7E3C, 0xEDAE0E44, 0xEDA19E79, 0xED952EDC, 0xED88BF8C, + 0xED7C504A, 0xED6FE135, 0xED63724F, 0xED570396, 0xED4A950B, 0xED3E26AF, + 0xED31B880, 0xED254A80, 0xED18DCAF, 0xED0C6F0C, 0xED000198, 0xECF39453, + 0xECE7273D, 0xECDABA76, 0xECCE4DBE, 0xECC1E136, 0xECB574DD, 0xECA908B4, + 0xEC9C9CBA, 0xEC9030F0, 0xEC83C557, 0xEC7759ED, 0xEC6AEEB3, 0xEC5E83AA, + 0xEC5218D1, 0xEC45AE29, 0xEC3943D1, 0xEC2CD98B, 0xEC206F75, 0xEC140590, + 0xEC079BDD, 0xEBFB325A, 0xEBEEC909, 0xEBE25FEA, 0xEBD5F6FC, 0xEBC98E40, + 0xEBBD25B6, 0xEBB0BD5E, 0xEBA45538, 0xEB97ED44, 0xEB8B85A2, 0xEB7F1E13, + 0xEB72B6B7, 0xEB664F8D, 0xEB59E896, 0xEB4D81D2, 0xEB411B41, 0xEB34B4E4, + 0xEB284EB9, 0xEB1BE8C2, 0xEB0F82FF, 0xEB031D6F, 0xEAF6B813, 0xEAEA52EB, + 0xEADDEE17, 0xEAD18957, 0xEAC524CB, 0xEAB8C074, 0xEAAC5C51, 0xEA9FF863, + 0xEA9394AA, 0xEA873126, 0xEA7ACDD6, 0xEA6E6ABC, 0xEA6207D6, 0xEA55A527, + 0xEA4942AC, 0xEA3CE087, 0xEA307E78, 0xEA241C9E, 0xEA17BAFB, 0xEA0B598E, + 0xE9FEF857, 0xE9F29756, 0xE9E6368B, 0xE9D9D5F7, 0xE9CD759A, 0xE9C11574, + 0xE9B4B584, 0xE9A855CC, 0xE99BF64A, 0xE98F971F, 0xE983380D, 0xE976D931, + 0xE96A7A8D, 0xE95E1C21, 0xE951BDED, 0xE9455FF1, 0xE939022D, 0xE92CA4A1, + 0xE920474D, 0xE913EA32, 0xE9078D50, 0xE8FB30A6, 0xE8EED434, 0xE8E2781C, + 0xE8D61C1C, 0xE8C9C056, 0xE8BD64CA, 0xE8B10976, 0xE8A4AE5C, 0xE898537C, + 0xE88BF8D6, 0xE87F9E69, 0xE8734436, 0xE866EA3E, 0xE85A9080, 0xE84E36FC, + 0xE841DDD2, 0xE83584C3, 0xE8292BEF, 0xE81CD355, 0xE8107AF7, 0xE80422D3, + 0xE7F7CAEB, 0xE7EB733E, 0xE7DF1BCD, 0xE7D2C497, 0xE7C66D9C, 0xE7BA16DE, + 0xE7ADC05B, 0xE7A16A15, 0xE795142A, 0xE788BE5B, 0xE77C68C9, 0xE7701374, + 0xE763BE5B, 0xE757697F, 0xE74B14E0, 0xE73EC07E, 0xE7326C58, 0xE7261871, + 0xE719C4C6, 0xE70D7159, 0xE7011E29, 0xE6F4CB37, 0xE6E878A2, 0xE6DC262C, + 0xE6CFD3F4, 0xE6C381F9, 0xE6B7303E, 0xE6AADEC0, 0xE69E8D81, 0xE6923C81, + 0xE685EBBF, 0xE6799B3D, 0xE66D4AF9, 0xE660FAF4, 0xE654AB2F, 0xE6485BA9, + 0xE63C0C81, 0xE62FBD7A, 0xE6236EB3, 0xE617202B, 0xE60AD1E4, 0xE5FE83DC, + 0xE5F23615, 0xE5E5E88E, 0xE5D99B47, 0xE5CD4E41, 0xE5C1017B, 0xE5B4B4F6, + 0xE5A868B2, 0xE59C1CCF, 0xE58FD10D, 0xE583858C, 0xE5773A4D, 0xE56AEF4F, + 0xE55EA493, 0xE5525A19, 0xE5460FE0, 0xE539C5EA, 0xE52D7C35, 0xE52132C2, + 0xE514E992, 0xE508A0A5, 0xE4FC57F9, 0xE4F00FB0, 0xE4E3C78A, 0xE4D77FA8, + 0xE4CB3808, 0xE4BEF0AB, 0xE4B2A992, 0xE4A662BB, 0xE49A1C29, 0xE48DD5DA, + 0xE4818FCE, 0xE4754A07, 0xE4690483, 0xE45CBF44, 0xE4507A49, 0xE44435B1, + 0xE437F13F, 0xE42BAD11, 0xE41F6927, 0xE4132583, 0xE406E223, 0xE3FA9F09, + 0xE3EE5C33, 0xE3E219A3, 0xE3D5D758, 0xE3C99553, 0xE3BD5393, 0xE3B11219, + 0xE3A4D104, 0xE3989016, 0xE38C4F6E, 0xE3800F0C, 0xE373CEF1, 0xE3678F1C, + 0xE35B4F8D, 0xE34F1045, 0xE342D144, 0xE336928A, 0xE32A5417, 0xE31E15EB, + 0xE311D806, 0xE3059A69, 0xE2F95D32, 0xE2ED2024, 0xE2E0E35D, 0xE2D4A6DF, + 0xE2C86AA8, 0xE2BC2EB9, 0xE2AFF313, 0xE2A3B7B5, 0xE2977C9F, 0xE28B41D2, + 0xE27F074E, 0xE272CD13, 0xE2669320, 0xE25A5976, 0xE24E2035, 0xE241E71E, + 0xE235AE50, 0xE22975CC, 0xE21D3D91, 0xE21105A0, 0xE204CDF9, 0xE1F8969C, + 0xE1EC5F89, 0xE1E028C0, 0xE1D3F242, 0xE1C7BC0E, 0xE1BB8624, 0xE1AF50A5, + 0xE1A31B51, 0xE196E648, 0xE18AB18A, 0xE17E7D17, 0xE17248EF, 0xE1661513, + 0xE159E182, 0xE14DAE3D, 0xE1417B44, 0xE1354896, 0xE1291635, 0xE11CE41F, + 0xE110B256, 0xE10480F8, 0xE0F84FC8, 0xE0EC1EE4, 0xE0DFEE4D, 0xE0D3BE03, + 0xE0C78E05, 0xE0BB5E55, 0xE0AF2EF1, 0xE0A2FFDB, 0xE096D113, 0xE08AA298, + 0xE07E746A, 0xE072468A, 0xE06618F9, 0xE059EBD4, 0xE04DBEDE, 0xE0419236, + 0xE03565DD, 0xE02939D2, 0xE01D0E16, 0xE010E2A8, 0xE004B789, 0xDFF88CB9, + 0xDFEC6238, 0xDFE03807, 0xDFD40E24, 0xDFC7E491, 0xDFBBBB4D, 0xDFAF9259, + 0xDFA369B5, 0xDF974161, 0xDF8B195C, 0xDF7EF1A8, 0xDF72CA44, 0xDF66A36E, + 0xDF5A7CAB, 0xDF4E5638, 0xDF423015, 0xDF360A44, 0xDF29E4C4, 0xDF1DBF94, + 0xDF119AB6, 0xDF057629, 0xDEF951ED, 0xDEED2E03, 0xDEE10A6A, 0xDED4E723, + 0xDEC8C42E, 0xDEBCA18B, 0xDEB07F3A, 0xDEA45D3B, 0xDE983B8F, 0xDE8C1A35, + 0xDE7FF92D, 0xDE73D878, 0xDE67B816, 0xDE5B9807, 0xDE4F784B, 0xDE4358E2, + 0xDE3739CC, 0xDE2B1B09, 0xDE1EFC9A, 0xDE12DEBD, 0xDE06C0F5, 0xDDFAA381, + 0xDDEE8661, 0xDDE26995, 0xDDD64D1D, 0xDDCA30FA, 0xDDBE152B, 0xDDB1F9B1, + 0xDDA5DE8B, 0xDD99C3BA, 0xDD8DA93D, 0xDD818F16, 0xDD757544, 0xDD695BC7, + 0xDD5D42A0, 0xDD5129CE, 0xDD451151, 0xDD38F92B, 0xDD2CE15A, 0xDD20C9DF, + 0xDD14B2BA, 0xDD089BEB, 0xDCFC8572, 0xDCF06F50, 0xDCE45984, 0xDCD8440F, + 0xDCCC2F2E, 0xDCC01A67, 0xDCB405F7, 0xDCA7F1DD, 0xDC9BDE1B, 0xDC8FCAB0, + 0xDC83B79D, 0xDC77A4E1, 0xDC6B927D, 0xDC5F8070, 0xDC536EBC, 0xDC475D5F, + 0xDC3B4C5B, 0xDC2F3BAF, 0xDC232B5B, 0xDC171B60, 0xDC0B0BBE, 0xDBFEFC74, + 0xDBF2ED83, 0xDBE6DEEB, 0xDBDAD0AC, 0xDBCEC2C6, 0xDBC2B539, 0xDBB6A806, + 0xDBAA9B2D, 0xDB9E8EAD, 0xDB928287, 0xDB8676BA, 0xDB7A6B85, 0xDB6E606D, + 0xDB6255AF, 0xDB564B4C, 0xDB4A4143, 0xDB3E3794, 0xDB322E40, 0xDB262547, + 0xDB1A1CA9, 0xDB0E1466, 0xDB020C7E, 0xDAF604F1, 0xDAE9FDC0, 0xDADDF6EA, + 0xDAD1F070, 0xDAC5EA52, 0xDAB9E48F, 0xDAADDF29, 0xDAA1DA1E, 0xDA95D570, + 0xDA89D11E, 0xDA7DCD29, 0xDA71C990, 0xDA65C653, 0xDA59C374, 0xDA4DC0F1, + 0xDA41BECB, 0xDA35BD40, 0xDA29BBD5, 0xDA1DBAC7, 0xDA11BA17, 0xDA05B9C4, + 0xD9F9B9CF, 0xD9EDBA37, 0xD9E1BAFE, 0xD9D5BC23, 0xD9C9BDA6, 0xD9BDBF87, + 0xD9B1C1C6, 0xD9A5C464, 0xD999C761, 0xD98DCABC, 0xD981CE77, 0xD975D290, + 0xD969D708, 0xD95DDBE0, 0xD951E117, 0xD945E6AD, 0xD939ECA3, 0xD92DF2F9, + 0xD921F9AE, 0xD91600C3, 0xD90A0839, 0xD8FE100E, 0xD8F21881, 0xD8E62117, + 0xD8DA2A0D, 0xD8CE3364, 0xD8C23D1C, 0xD8B64735, 0xD8AA51AE, 0xD89E5C89, + 0xD89267C5, 0xD8867362, 0xD87A7F60, 0xD86E8BC0, 0xD8629882, 0xD856A5A5, + 0xD84AB32A, 0xD83EC112, 0xD832CF5B, 0xD826DE06, 0xD81AED14, 0xD80EFC84, + 0xD8030C57, 0xD7F71C8D, 0xD7EB2D25, 0xD7DF3E20, 0xD7D34F7E, 0xD7C76140, + 0xD7BB7364, 0xD7AF85EC, 0xD7A39914, 0xD797AC63, 0xD78BC016, 0xD77FD42C, + 0xD773E8A7, 0xD767FD85, 0xD75C12C8, 0xD750286F, 0xD7443E7A, 0xD73854EA, + 0xD72C6BBE, 0xD72082F7, 0xD7149A95, 0xD708B298, 0xD6FCCB00, 0xD6F0E3CE, + 0xD6E4FD00, 0xD6D91698, 0xD6CD3096, 0xD6C14AF9, 0xD6B565C2, 0xD6A980F0, + 0xD69D9C85, 0xD691B880, 0xD685D4E1, 0xD679F1A9, 0xD66E0ED7, 0xD6622CA8, + 0xD6564AA3, 0xD64A6905, 0xD63E87CE, 0xD632A6FE, 0xD626C695, 0xD61AE693, + 0xD60F06F9, 0xD60327C6, 0xD5F748FB, 0xD5EB6A98, 0xD5DF8C9C, 0xD5D3AF08, + 0xD5C7D1DD, 0xD5BBF519, 0xD5B018BE, 0xD5A43CCB, 0xD5986141, 0xD58C861F, + 0xD580AB66, 0xD574D116, 0xD568F72F, 0xD55D1DB1, 0xD551449C, 0xD5456BF1, + 0xD53993AF, 0xD52DBBD6, 0xD521E468, 0xD5160D9F, 0xD50A3704, 0xD4FE60D2, + 0xD4F28B0B, 0xD4E6B5AF, 0xD4DAE0BC, 0xD4CF0C34, 0xD4C33817, 0xD4B76464, + 0xD4AB911C, 0xD49FBE3F, 0xD493EBCD, 0xD48819C6, 0xD47C482A, 0xD47076FA, + 0xD464A635, 0xD458D5DC, 0xD44D05EE, 0xD441366D, 0xD4356757, 0xD42998AD, + 0xD41DCA70, 0xD411FC9E, 0xD4062F3A, 0xD3FA6241, 0xD3EE95B6, 0xD3E2C997, + 0xD3D6FE21, 0xD3CB32DB, 0xD3BF6803, 0xD3B39D98, 0xD3A7D39B, 0xD39C0A0B, + 0xD39040E8, 0xD3847833, 0xD378AFEC, 0xD36CE812, 0xD36120A7, 0xD35559A9, + 0xD349931A, 0xD33DCCFA, 0xD3320747, 0xD3264203, 0xD31A7D2E, 0xD30EB8C8, + 0xD302F4D0, 0xD2F73148, 0xD2EB6E2F, 0xD2DFAB85, 0xD2D3E94A, 0xD2C8277F, + 0xD2BC6623, 0xD2B0A537, 0xD2A4E4BB, 0xD29924EA, 0xD28D654E, 0xD281A622, + 0xD275E766, 0xD26A291A, 0xD25E6B3F, 0xD252ADD4, 0xD246F0DB, 0xD23B3452, + 0xD22F783A, 0xD223BC93, 0xD218015D, 0xD20C4698, 0xD2008C45, 0xD1F4D263, + 0xD1E918F3, 0xD1DD5FF5, 0xD1D1A768, 0xD1C5EF4E, 0xD1BA37A5, 0xD1AE806F, + 0xD1A2C9AB, 0xD1971359, 0xD18B5D7A, 0xD17FA80E, 0xD173F314, 0xD1683E8D, + 0xD15C8A79, 0xD150D714, 0xD14523E6, 0xD139712C, 0xD12DBEE5, 0xD1220D11, + 0xD1165BB1, 0xD10AAAC5, 0xD0FEFA4D, 0xD0F34A49, 0xD0E79AB9, 0xD0DBEB9D, + 0xD0D03CF5, 0xD0C48EC2, 0xD0B8E103, 0xD0AD33B9, 0xD0A186E4, 0xD095DA84, + 0xD08A2E98, 0xD07E8322, 0xD072D821, 0xD0672D95, 0xD05B837F, 0xD04FD9DE, + 0xD04430B3, 0xD03887FE, 0xD02CDFBF, 0xD02137F5, 0xD01590DD, 0xD009EA00, + 0xCFFE439A, 0xCFF29DA9, 0xCFE6F830, 0xCFDB532D, 0xCFCFAEA1, 0xCFC40A8B, + 0xCFB866ED, 0xCFACC3C6, 0xCFA12116, 0xCF957EDD, 0xCF89DD1C, 0xCF7E3BD3, + 0xCF729B01, 0xCF66FAA7, 0xCF5B5AC5, 0xCF4FBB5A, 0xCF441C68, 0xCF387DEF, + 0xCF2CDFED, 0xCF214264, 0xCF15A554, 0xCF0A08BC, 0xCEFE6C9E, 0xCEF2D0F8, + 0xCEE735CB, 0xCEDB9B17, 0xCED00118, 0xCEC46757, 0xCEB8CE0F, 0xCEAD3541, + 0xCEA19CED, 0xCE960512, 0xCE8A6DB1, 0xCE7ED6CB, 0xCE73405E, 0xCE67AA6C, + 0xCE5C14F4, 0xCE507FF7, 0xCE44EB74, 0xCE39576C, 0xCE2DC3DF, 0xCE2230CD, + 0xCE169E36, 0xCE0B0C1A, 0xCDFF7A79, 0xCDF3E953, 0xCDE858A9, 0xCDDCC87B, + 0xCDD138C8, 0xCDC5A992, 0xCDBA1AD7, 0xCDAE8C98, 0xCDA2FED5, 0xCD9771C9, + 0xCD8BE4FF, 0xCD8058B2, 0xCD74CCE1, 0xCD69418D, 0xCD5DB6B5, 0xCD522C5B, + 0xCD46A27D, 0xCD3B191D, 0xCD2F903A, 0xCD2407D4, 0xCD187FEC, 0xCD0CF882, + 0xCD017195, 0xCCF5EB26, 0xCCEA6535, 0xCCDEDFC2, 0xCCD35ACD, 0xCCC7D656, + 0xCCBC525E, 0xCCB0CEE4, 0xCCA54BE9, 0xCC99C96D, 0xCC8E476F, 0xCC82C5F1, + 0xCC7744F1, 0xCC6BC470, 0xCC6044AA, 0xCC54C528, 0xCC494626, 0xCC3DC7A3, + 0xCC3249A0, 0xCC26CC1D, 0xCC1B4F19, 0xCC0FD296, 0xCC045693, 0xCBF8DB10, + 0xCBED600E, 0xCBE1E58C, 0xCBD66B8B, 0xCBCAF20A, 0xCBBF790A, 0xCBB4008B, + 0xCBA8888D, 0xCB9D1111, 0xCB919A15, 0xCB86239B, 0xCB7AADA2, 0xCB6F382B, + 0xCB63C336, 0xCB584EC3, 0xCB4CDAD1, 0xCB416761, 0xCB35F474, 0xCB2A8209, + 0xCB1F105A, 0xCB139EF4, 0xCB082E10, 0xCAFCBDAF, 0xCAF14DD1, 0xCAE5DE76, + 0xCADA6F9D, 0xCACF0148, 0xCAC39376, 0xCAB82628, 0xCAACB95D, 0xCAA14D15, + 0xCA95E151, 0xCA8A7611, 0xCA7F0B55, 0xCA73A11D, 0xCA683769, 0xCA5CCE39, + 0xCA51658E, 0xCA45FD67, 0xCA3A95C4, 0xCA2F2EA7, 0xCA23C80E, 0xCA1861FA, + 0xCA0CFC6B, 0xCA019761, 0xC9F632DC, 0xC9EACF17, 0xC9DF6B9D, 0xC9D408A8, + 0xC9C8A63A, 0xC9BD4451, 0xC9B1E2EE, 0xC9A68211, 0xC99B21BA, 0xC98FC1E9, + 0xC984629E, 0xC97903DA, 0xC96DA59D, 0xC96247E6, 0xC956EAB6, 0xC94B8E0D, + 0xC94031EB, 0xC934D650, 0xC9297B3C, 0xC91E20AF, 0xC912C6AA, 0xC9076D2C, + 0xC8FC1436, 0xC8F0BBC8, 0xC8E563E2, 0xC8DA0C83, 0xC8CEB5AD, 0xC8C35F5F, + 0xC8B80999, 0xC8ACB495, 0xC8A15FE0, 0xC8960BB4, 0xC88AB810, 0xC87F64F5, + 0xC8741263, 0xC868C05B, 0xC85D6EDB, 0xC8521DE5, 0xC846CD78, 0xC83B7D94, + 0xC8302E3A, 0xC824DF6A, 0xC8199124, 0xC80E4367, 0xC802F635, 0xC7F7A98D, + 0xC7EC5D6F, 0xC7E111DB, 0xC7D5C6D2, 0xC7CA7C53, 0xC7BF325F, 0xC7B3E8F6, + 0xC7A8A018, 0xC79D57C5, 0xC7920FFD, 0xC786C8C0, 0xC77B8248, 0xC7703C22, + 0xC764F688, 0xC759B179, 0xC74E6CF6, 0xC74328FF, 0xC737E594, 0xC72CA2B5, + 0xC7216062, 0xC7161E9C, 0xC70ADD62, 0xC6FF9CB4, 0xC6F45C93, 0xC6E91CFF, + 0xC6DDDDF8, 0xC6D29F7E, 0xC6C76190, 0xC6BC2430, 0xC6B0E75E, 0xC6A5AB18, + 0xC69A6F61, 0xC68F3436, 0xC683F99A, 0xC678BF8B, 0xC66D860B, 0xC6624D18, + 0xC65714B4, 0xC64BDD17, 0xC640A5CF, 0xC6356F16, 0xC62A38EB, 0xC61F034F, + 0xC613CE42, 0xC60899C3, 0xC5FD65D4, 0xC5F23274, 0xC5E6FFA3, 0xC5DBCD62, + 0xC5D09BB0, 0xC5C56A8D, 0xC5BA39FA, 0xC5AF09F7, 0xC5A3DA84, 0xC598ABA1, + 0xC58D7D4E, 0xC5824F8B, 0xC5772258, 0xC56BF5B6, 0xC560C9A5, 0xC5559E24, + 0xC54A7334, 0xC53F48D5, 0xC5341F06, 0xC528F5C9, 0xC51DCD1D, 0xC512A53B, + 0xC5077DB2, 0xC4FC56BA, 0xC4F13053, 0xC4E60A7F, 0xC4DAE53C, 0xC4CFC08B, + 0xC4C49C6D, 0xC4B978E0, 0xC4AE55E6, 0xC4A3337E, 0xC49811A8, 0xC48CF065, + 0xC481CFB5, 0xC476AF98, 0xC46B900D, 0xC4607116, 0xC45552B1, 0xC44A34E0, + 0xC43F17A2, 0xC433FAF8, 0xC428DEE1, 0xC41DC35E, 0xC412A86E, 0xC4078E12, + 0xC3FC744B, 0xC3F15B17, 0xC3E642B0, 0xC3DB2AA5, 0xC3D0132F, 0xC3C4FC4C, + 0xC3B9E5FF, 0xC3AED046, 0xC3A3BB22, 0xC398A693, 0xC38D9299, 0xC3827F34, + 0xC3776C64, 0xC36C5A2A, 0xC3614885, 0xC3563776, 0xC34B26FC, 0xC3401719, + 0xC33507CB, 0xC329F913, 0xC31EEAF1, 0xC313DD66, 0xC308D070, 0xC2FDC412, + 0xC2F2B849, 0xC2E7AD18, 0xC2DCA27D, 0xC2D19879, 0xC2C68F0C, 0xC2BB8636, + 0xC2B07E2F, 0xC2A57687, 0xC29A6F77, 0xC28F68FF, 0xC284631E, 0xC2795DD4, + 0xC26E5923, 0xC2635509, 0xC2585187, 0xC24D4E9E, 0xC2424C4C, 0xC2374A94, + 0xC22C4973, 0xC22148EB, 0xC21648FC, 0xC20B49A5, 0xC2004AE8, 0xC1F54CC3, + 0xC1EA4F37, 0xC1DF5245, 0xC1D455EC, 0xC1C95A2C, 0xC1BE5F06, 0xC1B36479, + 0xC1A86A87, 0xC19D712E, 0xC192786E, 0xC1878049, 0xC17C88BE, 0xC17191CE, + 0xC1669B77, 0xC15BA5BC, 0xC150B09A, 0xC145BC14, 0xC13AC828, 0xC12FD4D7, + 0xC124E221, 0xC119F006, 0xC10EFE86, 0xC1040DA2, 0xC0F91D59, 0xC0EE2E1B, + 0xC0E33F09, 0xC0D85093, 0xC0CD62B8, 0xC0C2757A, 0xC0B788D8, 0xC0AC9CD1, + 0xC0A1B167, 0xC096C69A, 0xC08BDC69, 0xC080F2D4, 0xC07609DC, 0xC06B2181, + 0xC06039C3, 0xC05552A2, 0xC04A6C1D, 0xC03F8636, 0xC034A0ED, 0xC029BC40, + 0xC01ED832, 0xC013F4C1, 0xC00911ED, 0xBFFE2FB8, 0xBFF34E20, 0xBFE86D26, + 0xBFDD8CCB, 0xBFD2AD0E, 0xBFC7CDEF, 0xBFBCEF6E, 0xBFB2118C, 0xBFA73449, + 0xBF9C57A5, 0xBF917B9F, 0xBF86A039, 0xBF7BC571, 0xBF70EB49, 0xBF6611C0, + 0xBF5B38D6, 0xBF50608C, 0xBF4588E2, 0xBF3AB1D7, 0xBF2FDB6C, 0xBF2505A1, + 0xBF1A3076, 0xBF0F5BEB, 0xBF048800, 0xBEF9B4B6, 0xBEEEE20C, 0xBEE41003, + 0xBED93E9A, 0xBECE6DD2, 0xBEC39DAB, 0xBEB8CE25, 0xBEADFF40, 0xBEA330FC, + 0xBE9863C8, 0xBE8D96C6, 0xBE82CA67, 0xBE77FEA9, 0xBE6D338C, 0xBE626911, + 0xBE579F39, 0xBE4CD602, 0xBE420D6D, 0xBE37457B, 0xBE2C7E2B, 0xBE21B77D, + 0xBE16F172, 0xBE0C2C09, 0xBE016744, 0xBDF6A321, 0xBDEBDFA1, 0xBDE11CC4, + 0xBDD65A8A, 0xBDCB98F3, 0xBDC0D800, 0xBDB617B0, 0xBDAB5804, 0xBDA098FB, + 0xBD95DA97, 0xBD8B1CD6, 0xBD805FB9, 0xBD75A340, 0xBD6AE76B, 0xBD602C3B, + 0xBD5571AF, 0xBD4AB7C7, 0xBD3FFE84, 0xBD3545E6, 0xBD2A8DED, 0xBD1FD698, + 0xBD151FE9, 0xBD0A69DE, 0xBCFFB479, 0xBCF4FFB9, 0xBCEA4B9F, 0xBCDF982A, + 0xBCD4E55B, 0xBCCA3331, 0xBCBF81AE, 0xBCB4D0D0, 0xBCAA2098, 0xBC9F7107, + 0xBC94C21B, 0xBC8A13D6, 0xBC7F6638, 0xBC74B940, 0xBC6A0CEE, 0xBC5F6144, + 0xBC54B6AD, 0xBC4A0C50, 0xBC3F629B, 0xBC34B98C, 0xBC2A1125, 0xBC1F6965, + 0xBC14C24D, 0xBC0A1BDC, 0xBBFF7613, 0xBBF4D0F1, 0xBBEA2C78, 0xBBDF88A7, + 0xBBD4E57D, 0xBBCA42FC, 0xBBBFA123, 0xBBB4FFF3, 0xBBAA5F6B, 0xBB9FBF8C, + 0xBB952055, 0xBB8A81C8, 0xBB7FE3E3, 0xBB7546A7, 0xBB6AAA14, 0xBB600E2B, + 0xBB5572EB, 0xBB4AD854, 0xBB403E67, 0xBB35A523, 0xBB2B0C89, 0xBB207499, + 0xBB15DD53, 0xBB0B46B7, 0xBB00B0C5, 0xBAF61B7E, 0xBAEB86E0, 0xBAE0F2EE, + 0xBAD65FA5, 0xBACBCD08, 0xBAC13B15, 0xBAB6A9CD, 0xBAAC1930, 0xBAA1893E, + 0xBA96F9F7, 0xBA8C6B5B, 0xBA81DD6B, 0xBA775026, 0xBA6CC38D, 0xBA6237A0, + 0xBA57AC5E, 0xBA4D21C8, 0xBA4297DE, 0xBA380EA1, 0xBA2D860F, 0xBA22FE2A, + 0xBA1876F1, 0xBA0DF0CF, 0xBA036AEF, 0xB9F8E5BC, 0xB9EE6136, 0xB9E3DD5C, + 0xB9D95A30, 0xB9CED7B0, 0xB9C455DE, 0xB9B9D4B9, 0xB9AF5441, 0xB9A4D477, + 0xB99A555B, 0xB98FD6EC, 0xB985592B, 0xB97ADC18, 0xB9705FB3, 0xB965E3FC, + 0xB95B68F3, 0xB950EE99, 0xB94674EC, 0xB93BFBEF, 0xB93183A0, 0xB9270C00, + 0xB91C950E, 0xB9121ECC, 0xB907A938, 0xB8FD3454, 0xB8F2C01F, 0xB8E84C99, + 0xB8DDD9C2, 0xB8D3679B, 0xB8C8F624, 0xB8BE855C, 0xB8B41545, 0xB8A9A5DD, + 0xB89F3725, 0xB894C91D, 0xB88A5BC6, 0xB87FEF1E, 0xB8758328, 0xB86B17E1, + 0xB860AD4C, 0xB8564367, 0xB84BDA33, 0xB84171B0, 0xB83709DE, 0xB82CA2BD, + 0xB8223C4D, 0xB817D68E, 0xB80D7181, 0xB8030D26, 0xB7F8A97C, 0xB7EE4684, + 0xB7E3E43D, 0xB7D982A9, 0xB7CF2230, 0xB7C4C200, 0xB7BA6282, 0xB7B003B6, + 0xB7A5A59D, 0xB79B4836, 0xB790EB82, 0xB7868F80, 0xB77C3432, 0xB771D996, + 0xB7677FAD, 0xB75D2678, 0xB752CDF5, 0xB7487626, 0xB73E1F0B, 0xB733C8A3, + 0xB72972EE, 0xB71F1DEE, 0xB714C9A1, 0xB70A7608, 0xB7002323, 0xB6F5D0F2, + 0xB6EB7F75, 0xB6E12EAD, 0xB6D6DE99, 0xB6CC8F3A, 0xB6C2408F, 0xB6B7F299, + 0xB6ADA558, 0xB6A358CB, 0xB6990CF4, 0xB68EC1D2, 0xB6847765, 0xB67A2DAD, + 0xB66FE4AB, 0xB6659C5E, 0xB65B54C7, 0xB6510DE6, 0xB646C7BA, 0xB63C8245, + 0xB6323D85, 0xB627F97B, 0xB61DB628, 0xB613738B, 0xB60931A4, 0xB5FEF074, + 0xB5F4AFFA, 0xB5EA7038, 0xB5E0312C, 0xB5D5F2D6, 0xB5CBB538, 0xB5C17851, + 0xB5B73C21, 0xB5AD00A9, 0xB5A2C5E7, 0xB5988C46, 0xB58E52F4, 0xB5841A59, + 0xB579E276, 0xB56FAB4B, 0xB56574D9, 0xB55B3F1E, 0xB5510A1B, 0xB546D5D1, + 0xB53CA23F, 0xB5326F65, 0xB5283D45, 0xB51E0BDC, 0xB513DB2D, 0xB509AB36, + 0xB4FF7BF9, 0xB4F54D74, 0xB4EB1FA9, 0xB4E0F296, 0xB4D6C63E, 0xB4CC9A9E, + 0xB4C26FB8, 0xB4B8458C, 0xB4AE1C1A, 0xB4A3F361, 0xB499CB63, 0xB48FA41E, + 0xB4857D94, 0xB47B57C3, 0xB47132AE, 0xB4670E52, 0xB45CEAB1, 0xB452C7CB, + 0xB448A59F, 0xB43E842F, 0xB4346379, 0xB42A437E, 0xB420243E, 0xB41605BA, + 0xB40BE7F1, 0xB401CAE3, 0xB3F7AE91, 0xB3ED92FA, 0xB3E3781F, 0xB3D95E00, + 0xB3CF449D, 0xB3C52BF6, 0xB3BB140A, 0xB3B0FCDB, 0xB3A6E669, 0xB39CD0B2, + 0xB392BBB9, 0xB388A77B, 0xB37E93FB, 0xB3748137, 0xB36A6F97, 0xB3605E4D, + 0xB3564DC0, 0xB34C3DF0, 0xB3422EDD, 0xB3382088, 0xB32E12F1, 0xB3240616, + 0xB319F9FA, 0xB30FEE9B, 0xB305E3FA, 0xB2FBDA17, 0xB2F1D0F2, 0xB2E7C88B, + 0xB2DDC0E3, 0xB2D3B9F8, 0xB2C9B3CC, 0xB2BFAE5F, 0xB2B5A9B0, 0xB2ABA5C0, + 0xB2A1A28F, 0xB297A01D, 0xB28D9E69, 0xB2839D75, 0xB2799D40, 0xB26F9DCA, + 0xB2659F14, 0xB25BA11D, 0xB251A3E5, 0xB247A76E, 0xB23DABB6, 0xB233B0BE, + 0xB229B686, 0xB21FBD0E, 0xB215C456, 0xB20BCC5E, 0xB201D527, 0xB1F7DEB0, + 0xB1EDE8FA, 0xB1E3F404, 0xB1D9FFCF, 0xB1D00C5B, 0xB1C619A8, 0xB1BC27B6, + 0xB1B23685, 0xB1A84615, 0xB19E5666, 0xB1946779, 0xB18A794D, 0xB1808BE3, + 0xB1769F3B, 0xB16CB354, 0xB162C830, 0xB158DDCD, 0xB14EF491, 0xB1450BB3, + 0xB13B2396, 0xB1313C3C, 0xB12755A5, 0xB11D6FD0, 0xB1138ABE, 0xB109A66E, + 0xB0FFC2E1, 0xB0F5E018, 0xB0EBFE11, 0xB0E21CCD, 0xB0D83C4D, 0xB0CE5C90, + 0xB0C47D96, 0xB0BA9F60, 0xB0B0C1ED, 0xB0A6E53E, 0xB09D0953, 0xB0932E2C, + 0xB08953C8, 0xB07F7A29, 0xB075A14E, 0xB06BC937, 0xB061F1E5, 0xB0581B57, + 0xB04E458D, 0xB0447088, 0xB03A9C48, 0xB030C8CD, 0xB026F617, 0xB01D2425, + 0xB01352F9, 0xB0098292, 0xAFFFB2F1, 0xAFF5E414, 0xAFEC15FD, 0xAFE248AC, + 0xAFD87C21, 0xAFCEB05B, 0xAFC4E55B, 0xAFBB1B21, 0xAFB151AD, 0xAFA788FF, + 0xAF9DC118, 0xAF93F9F7, 0xAF8A339C, 0xAF806E08, 0xAF76A93A, 0xAF6CE533, + 0xAF6321F3, 0xAF595F7A, 0xAF4F9DC8, 0xAF45DCDD, 0xAF3C1CB9, 0xAF325DC0, + 0xAF289F2B, 0xAF1EE15D, 0xAF152457, 0xAF0B6818, 0xAF01ACA2, 0xAEF7F1F3, + 0xAEEE380C, 0xAEE47EED, 0xAEDAC696, 0xAED10F07, 0xAEC75841, 0xAEBDA243, + 0xAEB3ED0E, 0xAEAA38A1, 0xAEA084FD, 0xAE96D221, 0xAE8D200F, 0xAE836EC5, + 0xAE79BE45, 0xAE700E8E, 0xAE665FA0, 0xAE5CB17B, 0xAE530420, 0xAE49578E, + 0xAE3FABC6, 0xAE3600C7, 0xAE2C5693, 0xAE22AD28, 0xAE190487, 0xAE0F5CB1, + 0xAE05B5A4, 0xADFC0F62, 0xADF269EA, 0xADE8C53D, 0xADDF215A, 0xADD57E42, + 0xADCBDBF5, 0xADC23A72, 0xADB899BB, 0xADAEF9CE, 0xADA55AAC, 0xAD9BBC56, + 0xAD921ECB, 0xAD88820B, 0xAD7EE617, 0xAD754AEF, 0xAD6BB092, 0xAD621701, + 0xAD587E3B, 0xAD4EE642, 0xAD454F15, 0xAD3BB8B3, 0xAD32231E, 0xAD288E56, + 0xAD1EFABB, 0xAD15678B, 0xAD0BD528, 0xAD024392, 0xACF8B2C8, 0xACEF22CB, + 0xACE5939B, 0xACDC0538, 0xACD277A2, 0xACC8EADA, 0xACBF5EDF, 0xACB5D3B1, + 0xACAC4951, 0xACA2BFBE, 0xAC9936F9, 0xAC8FAF02, 0xAC8627D9, 0xAC7CA17D, + 0xAC731BF0, 0xAC699731, 0xAC601340, 0xAC56901D, 0xAC4D0DC9, 0xAC438C44, + 0xAC3A0B8D, 0xAC308BA5, 0xAC270C8B, 0xAC1D8E41, 0xAC1410C5, 0xAC0A9418, + 0xAC01183B, 0xABF79D2D, 0xABEE22EE, 0xABE4A97F, 0xABDB30DF, 0xABD1B90F, + 0xABC8420E, 0xABBECBDE, 0xABB5567D, 0xABABE1EC, 0xABA26E2B, 0xAB98FB3B, + 0xAB8F891A, 0xAB8617CA, 0xAB7CA74B, 0xAB73379C, 0xAB69C8BE, 0xAB605AB0, + 0xAB56ED73, 0xAB4D8107, 0xAB44156C, 0xAB3AAAA2, 0xAB3140A9, 0xAB27D782, + 0xAB1E6F2C, 0xAB150807, 0xAB0BA153, 0xAB023B72, 0xAAF8D662, 0xAAEF7224, + 0xAAE60EB8, 0xAADCAC1D, 0xAAD34A55, 0xAAC9E95F, 0xAAC0893C, 0xAAB729EA, + 0xAAADCB6B, 0xAAA46DBF, 0xAA9B10E5, 0xAA91B4DE, 0xAA8859A9, 0xAA7EFF48, + 0xAA75A5BA, 0xAA6C4CFE, 0xAA62F516, 0xAA599E01, 0xAA5047BF, 0xAA46F251, + 0xAA3D9DB6, 0xAA3449EF, 0xAA2AF6FC, 0xAA21A4DC, 0xAA185390, 0xAA0F0318, + 0xAA05B374, 0xA9FC64A5, 0xA9F316A9, 0xA9E9C982, 0xA9E07D30, 0xA9D731B2, + 0xA9CDE708, 0xA9C49D33, 0xA9BB5433, 0xA9B20C08, 0xA9A8C4B1, 0xA99F7E30, + 0xA9963884, 0xA98CF3AD, 0xA983AFAB, 0xA97A6C7F, 0xA9712A28, 0xA967E8A7, + 0xA95EA7FC, 0xA9556826, 0xA94C2926, 0xA942EAFC, 0xA939ADA8, 0xA930712A, + 0xA9273583, 0xA91DFAB1, 0xA914C114, 0xA90B87F0, 0xA9024FA2, 0xA8F9182A, + 0xA8EFE18A, 0xA8E6ABC0, 0xA8DD76CD, 0xA8D442B1, 0xA8CB0F6C, 0xA8C1DCFF, + 0xA8B8AB68, 0xA8AF7AA9, 0xA8A64AC2, 0xA89D1BB2, 0xA893ED79, 0xA88AC018, + 0xA881938F, 0xA87867DE, 0xA86F3D05, 0xA8661304, 0xA85CE9DB, 0xA853C18B, + 0xA84A9A13, 0xA8417373, 0xA8384DAB, 0xA82F28BC, 0xA82604A6, 0xA81CE169, + 0xA813BF04, 0xA80A9D79, 0xA8017CC6, 0xA7F85CED, 0xA7EF3DED, 0xA7E61FC6, + 0xA7DD0278, 0xA7D3E604, 0xA7CACA6A, 0xA7C1AFA9, 0xA7B895C2, 0xA7AF7CB4, + 0xA7A66481, 0xA79D4D28, 0xA79436A8, 0xA78B2103, 0xA7820C38, 0xA778F848, + 0xA76FE532, 0xA766D2F6, 0xA75DC195, 0xA754B10F, 0xA74BA163, 0xA7429293, + 0xA739849D, 0xA7307782, 0xA7276B9F, 0xA71E603B, 0xA71555B2, 0xA70C4C04, + 0xA7034332, 0xA6FA3B3C, 0xA6F13421, 0xA6E82DE2, 0xA6DF287E, 0xA6D623F7, + 0xA6CD204B, 0xA6C41D7C, 0xA6BB1B89, 0xA6B21A72, 0xA6A91A38, 0xA6A01AD9, + 0xA6971C58, 0xA68E1EB3, 0xA68521EB, 0xA67C25FF, 0xA6732AF1, 0xA66A30BF, + 0xA661376A, 0xA6583EF3, 0xA64F4759, 0xA646509C, 0xA63D5ABC, 0xA63465BA, + 0xA62B7196, 0xA6227E4F, 0xA6198BE6, 0xA6109A5A, 0xA607A9AD, 0xA5FEB9DE, + 0xA5F5CAEC, 0xA5ECDCD9, 0xA5E3EFA4, 0xA5DB034E, 0xA5D217D5, 0xA5C92D3C, + 0xA5C04381, 0xA5B75AA4, 0xA5AE72A7, 0xA5A58B88, 0xA59CA548, 0xA593BFE7, + 0xA58ADB66, 0xA581F7C3, 0xA5791500, 0xA570331C, 0xA5675218, 0xA55E71F3, + 0xA55592AE, 0xA54CB448, 0xA543D6C3, 0xA53AFA77, 0xA5321EB1, 0xA52943CB, + 0xA52069C6, 0xA51790A0, 0xA50EB85B, 0xA505E0F6, 0xA4FD0A72, 0xA4F434CE, + 0xA4EB600B, 0xA4E28C29, 0xA4D9B927, 0xA4D0E707, 0xA4C815C7, 0xA4BF4569, + 0xA4B675EB, 0xA4ADA74F, 0xA4A4D994, 0xA49C0CBB, 0xA49340C3, 0xA48A75AC, + 0xA481AB78, 0xA478E225, 0xA47019B4, 0xA4675225, 0xA45E8B77, 0xA455C5AC, + 0xA44D00C3, 0xA4443CBD, 0xA43B7999, 0xA432B757, 0xA429F5F7, 0xA421357B, + 0xA41875E1, 0xA40FB729, 0xA406F955, 0xA3FE3C63, 0xA3F58055, 0xA3ECC529, + 0xA3E40AE1, 0xA3DB517C, 0xA3D298FB, 0xA3C9E15D, 0xA3C12AA2, 0xA3B874CB, + 0xA3AFBFD8, 0xA3A70BC8, 0xA39E589C, 0xA395A655, 0xA38CF4F1, 0xA3844471, + 0xA37B94D6, 0xA372E61F, 0xA36A384C, 0xA3618B5E, 0xA358DFAC, 0xA3503487, + 0xA3478A47, 0xA33EE0EB, 0xA3363874, 0xA32D90E2, 0xA324EA35, 0xA31C446E, + 0xA3139F8B, 0xA30AFB8E, 0xA3025876, 0xA2F9B643, 0xA2F114F6, 0xA2E8748F, + 0xA2DFD50D, 0xA2D73671, 0xA2CE98BB, 0xA2C5FBEB, 0xA2BD6001, 0xA2B4C4FD, + 0xA2AC2AE0, 0xA2A391A8, 0xA29AF957, 0xA29261ED, 0xA289CB68, 0xA28135CB, + 0xA278A114, 0xA2700D44, 0xA2677A5B, 0xA25EE859, 0xA256573D, 0xA24DC709, + 0xA24537BC, 0xA23CA957, 0xA2341BD8, 0xA22B8F42, 0xA2230392, 0xA21A78CA, + 0xA211EEEA, 0xA20965F2, 0xA200DDE2, 0xA1F856B9, 0xA1EFD079, 0xA1E74B20, + 0xA1DEC6B0, 0xA1D64328, 0xA1CDC088, 0xA1C53ED1, 0xA1BCBE02, 0xA1B43E1C, + 0xA1ABBF1F, 0xA1A3410A, 0xA19AC3DE, 0xA192479B, 0xA189CC41, 0xA1815226, + 0xA178D89F, 0xA1706000, 0xA167E84B, 0xA15F717F, 0xA156FB9D, 0xA14E86A4, + 0xA1461295, 0xA13D9F6F, 0xA1352D34, 0xA12CBBE2, 0xA1244B7A, 0xA11BDBFD, + 0xA1136D69, 0xA10AFFC0, 0xA1029301, 0xA0FA272C, 0xA0F1BC42, 0xA0E95242, + 0xA0E0E92D, 0xA0D88103, 0xA0D019C3, 0xA0C7B36F, 0xA0BF4E05, 0xA0B6E986, + 0xA0AE85F3, 0xA0A6234A, 0xA09DC18D, 0xA09560BC, 0xA08D00D5, 0xA084A1DA, + 0xA07C43CB, 0xA073E6A8, 0xA06B8A70, 0xA0632F24, 0xA05AD4C4, 0xA0527B50, + 0xA04A22C8, 0xA041CB2C, 0xA039747C, 0xA0311EB9, 0xA028C9E2, 0xA02075F8, + 0xA01822FA, 0xA00FD0E9, 0xA0077FC4, 0x9FFF2F8D, 0x9FF6E042, 0x9FEE91E4, + 0x9FE64473, 0x9FDDF7F0, 0x9FD5AC59, 0x9FCD61B0, 0x9FC517F4, 0x9FBCCF26, + 0x9FB48799, 0x9FAC40A6, 0x9FA3FAA0, 0x9F9BB588, 0x9F93715E, 0x9F8B2E22, + 0x9F82EBD4, 0x9F7AAA74, 0x9F726A02, 0x9F6A2A7F, 0x9F61EBE9, 0x9F59AE42, + 0x9F51718A, 0x9F4935C0, 0x9F40FAE5, 0x9F38C0F8, 0x9F3087FA, 0x9F284FEC, + 0x9F2018CC, 0x9F17E29B, 0x9F0FAD59, 0x9F077906, 0x9EFF45A3, 0x9EF7132F, + 0x9EEEE1AA, 0x9EE6B115, 0x9EDE8170, 0x9ED652BA, 0x9ECE24F4, 0x9EC5F81E, + 0x9EBDCC37, 0x9EB5A141, 0x9EAD773B, 0x9EA54E24, 0x9E9D25FE, 0x9E94FEC9, + 0x9E8CD883, 0x9E84B32E, 0x9E7C8ECA, 0x9E746B56, 0x9E6C48D3, 0x9E642741, + 0x9E5C06A0, 0x9E53E6EF, 0x9E4BC82F, 0x9E43AA61, 0x9E3B8D84, 0x9E337198, + 0x9E2B569D, 0x9E233C94, 0x9E1B237C, 0x9E130B55, 0x9E0AF421, 0x9E02DDDE, + 0x9DFAC88C, 0x9DF2B47F, 0x9DEAA112, 0x9DE28E96, 0x9DDA7D0D, 0x9DD26C76, + 0x9DCA5CD1, 0x9DC24E1E, 0x9DBA405E, 0x9DB23390, 0x9DAA27B5, 0x9DA21CCC, + 0x9D9A12D6, 0x9D9209D3, 0x9D8A01C3, 0x9D81FAA6, 0x9D79F47B, 0x9D71EF44, + 0x9D69EB00, 0x9D61E7AF, 0x9D59E552, 0x9D51E3E8, 0x9D49E372, 0x9D41E3EF, + 0x9D39E55F, 0x9D31E7C4, 0x9D29EB1C, 0x9D21EF68, 0x9D19F4A8, 0x9D11FADC, + 0x9D0A0204, 0x9D020A21, 0x9CFA1331, 0x9CF21D36, 0x9CEA282F, 0x9CE2341D, + 0x9CDA4100, 0x9CD24ED7, 0x9CCA5DA2, 0x9CC26D63, 0x9CBA7E18, 0x9CB28FC2, + 0x9CAAA262, 0x9CA2B5F6, 0x9C9ACA80, 0x9C92DFFF, 0x9C8AF673, 0x9C830DDC, + 0x9C7B263C, 0x9C733F90, 0x9C6B59DA, 0x9C63751A, 0x9C5B9150, 0x9C53AE7C, + 0x9C4BCC9D, 0x9C43EC05, 0x9C3C0C13, 0x9C342D16, 0x9C2C4F10, 0x9C247201, + 0x9C1C95E7, 0x9C14BAC5, 0x9C0CE098, 0x9C050763, 0x9BFD2F24, 0x9BF557DB, + 0x9BED818A, 0x9BE5AC30, 0x9BDDD7CC, 0x9BD60460, 0x9BCE31EA, 0x9BC6606C, + 0x9BBE8FE6, 0x9BB6C056, 0x9BAEF1BE, 0x9BA7241E, 0x9B9F5775, 0x9B978BC4, + 0x9B8FC10B, 0x9B87F749, 0x9B802E80, 0x9B7866AE, 0x9B709FD4, 0x9B68D9F3, + 0x9B61150A, 0x9B595119, 0x9B518E20, 0x9B49CC20, 0x9B420B18, 0x9B3A4B09, + 0x9B328BF2, 0x9B2ACDD4, 0x9B2310AF, 0x9B1B5483, 0x9B139950, 0x9B0BDF16, + 0x9B0425D5, 0x9AFC6D8D, 0x9AF4B63E, 0x9AECFFE9, 0x9AE54A8D, 0x9ADD962A, + 0x9AD5E2C1, 0x9ACE3052, 0x9AC67EDC, 0x9ABECE61, 0x9AB71EDF, 0x9AAF7056, + 0x9AA7C2C8, 0x9AA01634, 0x9A986AE8, 0x9A90C049, 0x9A8916A3, 0x9A816DF8, + 0x9A79C647, 0x9A721F91, 0x9A6A79D5, 0x9A62D514, 0x9A5B314E, 0x9A538E83, + 0x9A4BECB2, 0x9A444BDC, 0x9A3CAC02, 0x9A350D22, 0x9A2D6F3E, 0x9A25D255, + 0x9A1E3667, 0x9A169B74, 0x9A0F017D, 0x9A076882, 0x99FFD082, 0x99F8397E, + 0x99F0A375, 0x99E90E69, 0x99E17A58, 0x99D9E743, 0x99D2552B, 0x99CAC40E, + 0x99C333EE, 0x99BBA4CA, 0x99B416A2, 0x99AC8976, 0x99A4FD48, 0x999D7215, + 0x9995E7DF, 0x998E5EA6, 0x9986D66A, 0x997F4F2B, 0x9977C8E8, 0x997043A3, + 0x9968BF5A, 0x99613C0F, 0x9959B9C1, 0x99523870, 0x994AB81D, 0x994338C7, + 0x993BBA6E, 0x99343D13, 0x992CC0B6, 0x99254556, 0x991DCAF4, 0x99165190, + 0x990ED92A, 0x990761C2, 0x98FFEB58, 0x98F87638, 0x98F101CB, 0x98E98E5B, + 0x98E21BEA, 0x98DAAA78, 0x98D33A04, 0x98CBCA8E, 0x98C45C17, 0x98BCEE9F, + 0x98B58226, 0x98AE16AB, 0x98A6AC30, 0x989F42B3, 0x9897DA36, 0x989072B7, + 0x98890C38, 0x9881A6B9, 0x987A4238, 0x9872DEB7, 0x986B7C36, 0x98641AB4, + 0x985CBA31, 0x98555AAF, 0x984DFC2C, 0x98469EA9, 0x983F4226, 0x9837E6A3, + 0x98308C20, 0x9829329D, 0x9821DA1B, 0x981A8299, 0x98132C17, 0x980BD695, + 0x98048214, 0x97FD2E94, 0x97F5DC14, 0x97EE8A95, 0x97E73A17, 0x97DFEA99, + 0x97D89C1D, 0x97D14EA1, 0x97CA0226, 0x97C2B6AD, 0x97BB6C35, 0x97B422BE, + 0x97ACDA49, 0x97A592D4, 0x979E4C62, 0x979706F1, 0x978FC281, 0x97887F13, + 0x97813CA7, 0x9779FB3D, 0x9772BAD5, 0x976B7B6F, 0x97643D54, 0x975CFFF2, + 0x9755C392, 0x974E8834, 0x97474DD9, 0x97401480, 0x9738DC29, 0x9731A4D5, + 0x972A6E84, 0x97233935, 0x971C04E9, 0x9714D1A0, 0x970D9F59, 0x97066E16, + 0x96FF3DD6, 0x96F80E98, 0x96F0E05E, 0x96E9B327, 0x96E286F4, 0x96DB5BC3, + 0x96D43196, 0x96CD086D, 0x96C5E047, 0x96BEB925, 0x96B79307, 0x96B06DEC, + 0x96A949D5, 0x96A226C3, 0x969B04B4, 0x9693E3A9, 0x968CC3A2, 0x9685A49F, + 0x967E86A1, 0x967769A7, 0x96704DB2, 0x966932C1, 0x966218D4, 0x965AFFEC, + 0x9653E809, 0x964CD12A, 0x9645BB51, 0x963EA67C, 0x963792AC, 0x96307FE1, + 0x96296E1B, 0x96225D5A, 0x961B4D9F, 0x96143EE9, 0x960D3138, 0x9606248C, + 0x95FF18E6, 0x95F80E46, 0x95F104AB, 0x95E9FC16, 0x95E2F487, 0x95DBEE45, + 0x95D4E8C1, 0x95CDE444, 0x95C6E0CC, 0x95BFDE5A, 0x95B8DCEF, 0x95B1DC8A, + 0x95AADD2B, 0x95A3DED2, 0x959CE180, 0x9595E535, 0x958EE9F0, 0x9587EFB1, + 0x9580F67A, 0x9579FE49, 0x9573071F, 0x956C10FC, 0x95651BE0, 0x955E27CB, + 0x955734BC, 0x955042B6, 0x954951B6, 0x954261BE, 0x953B72CD, 0x953484E3, + 0x952D9801, 0x9526AC27, 0x951FC154, 0x9518D789, 0x9511EEC6, 0x950B070A, + 0x95042057, 0x94FD3AAB, 0x94F65608, 0x94EF726C, 0x94E88FD9, 0x94E1AE4E, + 0x94DACDCB, 0x94D3EE51, 0x94CD0FDF, 0x94C63276, 0x94BF5615, 0x94B87ABD, + 0x94B1A06D, 0x94AAC727, 0x94A3EEE9, 0x949D17B4, 0x94964188, 0x948F6C65, + 0x9488984B, 0x9481C53A, 0x947AF333, 0x94742235, 0x946D5240, 0x9466839A, + 0x945FB5B8, 0x9458E8E0, 0x94521D11, 0x944B524C, 0x9444884B, 0x943DBF9A, + 0x9436F7F2, 0x94303155, 0x94296BC1, 0x9422A738, 0x941BE3B8, 0x94152143, + 0x940E5FD8, 0x94079F78, 0x9400E021, 0x93FA21D6, 0x93F36495, 0x93ECA85E, + 0x93E5ED32, 0x93DF3311, 0x93D879FB, 0x93D1C1EF, 0x93CB0AEF, 0x93C454F9, + 0x93BDA00F, 0x93B6EC2F, 0x93B0395B, 0x93A9881B, 0x93A2D75D, 0x939C27AB, + 0x93957904, 0x938ECB68, 0x93881ED9, 0x93817354, 0x937AC8DC, 0x93741F6F, + 0x936D770E, 0x9366CFB9, 0x93602970, 0x93598433, 0x9352E003, 0x934C3CDE, + 0x93459AC5, 0x933EF9B9, 0x933859B9, 0x9331BAC6, 0x932B1CDE, 0x93248004, + 0x931DE436, 0x93174975, 0x9310AFC0, 0x930A1718, 0x93037F7E, 0x92FCE8F0, + 0x92F6536F, 0x92EFBEFB, 0x92E92B94, 0x92E2993A, 0x92DC07EE, 0x92D577AE, + 0x92CEE87D, 0x92C85A58, 0x92C1CD41, 0x92BB4138, 0x92B4B63C, 0x92AE2C4E, + 0x92A7A36E, 0x92A11B9B, 0x929A94D7, 0x92940F20, 0x928D8A77, 0x928706DC, + 0x92808450, 0x927A02D1, 0x92738261, 0x926D02FF, 0x926684AC, 0x92600767, + 0x92598B30, 0x92531008, 0x924C95EF, 0x92461CE4, 0x923FA4E8, 0x92392DFB, + 0x9232B81C, 0x922C434D, 0x9225CF8D, 0x921F5CDB, 0x9218EB39, 0x92127AA6, + 0x920C0B22, 0x92059CAD, 0x91FF2F48, 0x91F8C2F3, 0x91F257AC, 0x91EBED76, + 0x91E5844E, 0x91DF1C37, 0x91D8B52F, 0x91D24F37, 0x91CBEA4F, 0x91C58677, + 0x91BF23AF, 0x91B8C1F7, 0x91B2614F, 0x91AC01B7, 0x91A5A32F, 0x919F45B8, + 0x9198E951, 0x91928DFA, 0x918C33B4, 0x9185DA7F, 0x917F825A, 0x91792B45, + 0x9172D542, 0x916C804F, 0x91662C6D, 0x915FD99C, 0x915987DC, 0x9153372C, + 0x914CE78E, 0x91469901, 0x91404B86, 0x9139FF1B, 0x9133B3C2, 0x912D697A, + 0x91272044, 0x9120D81F, 0x911A910C, 0x91144B0B, 0x910E061B, 0x9107C23C, + 0x91017F70, 0x90FB3DB6, 0x90F4FD0D, 0x90EEBD77, 0x90E87F71, 0x90E241FF, + 0x90DC059E, 0x90D5CA50, 0x90CF9014, 0x90C956EB, 0x90C31ED4, 0x90BCE7CF, + 0x90B6B1DD, 0x90B07CFE, 0x90AA4931, 0x90A41677, 0x909DE4D0, 0x9097B43B, + 0x909184BA, 0x908B564B, 0x908528EF, 0x907EFCA7, 0x9078D171, 0x9072A74F, + 0x906C7E40, 0x90665644, 0x90602F5C, 0x905A0987, 0x9053E4C5, 0x904DC118, + 0x90479E7D, 0x90417CF7, 0x903B5C84, 0x90353D25, 0x902F1ED9, 0x902901A2, + 0x9022E57E, 0x901CCA6F, 0x9016B074, 0x9010978C, 0x900A7FB9, 0x900468FA, + 0x8FFE5350, 0x8FF83EBA, 0x8FF22B38, 0x8FEC18CB, 0x8FE60772, 0x8FDFF72E, + 0x8FD9E7FF, 0x8FD3D9E4, 0x8FCDCCDE, 0x8FC7C0ED, 0x8FC1B611, 0x8FBBAC4A, + 0x8FB5A397, 0x8FAF9BFA, 0x8FA99572, 0x8FA38FFF, 0x8F9D8BA2, 0x8F978859, + 0x8F918626, 0x8F8B8509, 0x8F858501, 0x8F7F860E, 0x8F798831, 0x8F738B6A, + 0x8F6D8FB8, 0x8F67951D, 0x8F619B96, 0x8F5BA326, 0x8F55ABCC, 0x8F4FB588, + 0x8F49C05A, 0x8F43CC42, 0x8F3DD940, 0x8F37E754, 0x8F31F67F, 0x8F2C06C0, + 0x8F261817, 0x8F202A85, 0x8F1A3E09, 0x8F1452A4, 0x8F0E6855, 0x8F087F1E, + 0x8F0296FC, 0x8EFCAFF2, 0x8EF6C9FF, 0x8EF0E522, 0x8EEB015D, 0x8EE51EAE, + 0x8EDF3D16, 0x8ED95C96, 0x8ED37D2D, 0x8ECD9EDB, 0x8EC7C1A0, 0x8EC1E57D, + 0x8EBC0A71, 0x8EB6307D, 0x8EB057A0, 0x8EAA7FDB, 0x8EA4A92D, 0x8E9ED397, + 0x8E98FF19, 0x8E932BB3, 0x8E8D5964, 0x8E87882E, 0x8E81B80F, 0x8E7BE909, + 0x8E761B1A, 0x8E704E44, 0x8E6A8286, 0x8E64B7E0, 0x8E5EEE52, 0x8E5925DD, + 0x8E535EF6, 0x8E4D98B2, 0x8E47D386, 0x8E420F73, 0x8E3C4C78, 0x8E368A96, + 0x8E30C9CD, 0x8E2B0A1D, 0x8E254B86, 0x8E1F8E07, 0x8E19D1A2, 0x8E141655, + 0x8E0E5C22, 0x8E08A308, 0x8E02EB06, 0x8DFD341F, 0x8DF77E50, 0x8DF1C99B, + 0x8DEC15FF, 0x8DE6637D, 0x8DE0B215, 0x8DDB01C6, 0x8DD55290, 0x8DCFA474, + 0x8DC9F772, 0x8DC44B8A, 0x8DBEA0BC, 0x8DB8F708, 0x8DB34E6D, 0x8DADA6ED, + 0x8DA80086, 0x8DA25B3A, 0x8D9CB708, 0x8D9713F0, 0x8D9171F3, 0x8D8BD110, + 0x8D863147, 0x8D809299, 0x8D7AF505, 0x8D75588C, 0x8D6FBD2D, 0x8D6A22EA, + 0x8D6489C0, 0x8D5EF1B2, 0x8D595ABE, 0x8D53C4E6, 0x8D4E3028, 0x8D489C85, + 0x8D4309FE, 0x8D3D7891, 0x8D37E840, 0x8D32590A, 0x8D2CCAEF, 0x8D273DEF, + 0x8D21B20B, 0x8D1C2742, 0x8D169D95, 0x8D111503, 0x8D0B8D8D, 0x8D060733, + 0x8D0081F4, 0x8CFAFDD1, 0x8CF57ACA, 0x8CEFF8DE, 0x8CEA780F, 0x8CE4F85B, + 0x8CDF79C4, 0x8CD9FC48, 0x8CD47FE9, 0x8CCF04A6, 0x8CC98A7F, 0x8CC41174, + 0x8CBE9986, 0x8CB922B4, 0x8CB3ACFE, 0x8CAE3865, 0x8CA8C4E9, 0x8CA35289, + 0x8C9DE145, 0x8C98711F, 0x8C930215, 0x8C8D9428, 0x8C882758, 0x8C82BBA5, + 0x8C7D510E, 0x8C77E795, 0x8C727F39, 0x8C6D17FA, 0x8C67B1D8, 0x8C624CD3, + 0x8C5CE8EC, 0x8C578622, 0x8C522475, 0x8C4CC3E6, 0x8C476474, 0x8C42061F, + 0x8C3CA8E9, 0x8C374CD0, 0x8C31F1D4, 0x8C2C97F7, 0x8C273F37, 0x8C21E795, + 0x8C1C9111, 0x8C173BAA, 0x8C11E762, 0x8C0C9438, 0x8C07422C, 0x8C01F13E, + 0x8BFCA16F, 0x8BF752BD, 0x8BF20596, 0x8BECB921, 0x8BE76DCB, 0x8BE22393, + 0x8BDCDA79, 0x8BD7927E, 0x8BD24BA2, 0x8BCD05E4, 0x8BC7C145, 0x8BC27DC5, + 0x8BBD3B64, 0x8BB7FA21, 0x8BB2B9FE, 0x8BAD7AF9, 0x8BA83D14, 0x8BA3004D, + 0x8B9DC4A6, 0x8B988A1D, 0x8B9350B4, 0x8B8E186B, 0x8B88E140, 0x8B83AB35, + 0x8B7E7649, 0x8B79427D, 0x8B740FD0, 0x8B6EDE43, 0x8B69ADD6, 0x8B647E88, + 0x8B5F505A, 0x8B5A234C, 0x8B54F75D, 0x8B4FCC8E, 0x8B4AA2E0, 0x8B457A51, + 0x8B4052E2, 0x8B3B2C93, 0x8B360765, 0x8B30E357, 0x8B2BC068, 0x8B269E9A, + 0x8B217DED, 0x8B1C5E60, 0x8B173FF3, 0x8B1222A6, 0x8B0D067B, 0x8B07EB6F, + 0x8B02D185, 0x8AFDB8BB, 0x8AF8A111, 0x8AF38A89, 0x8AEE7521, 0x8AE960DA, + 0x8AE44DB4, 0x8ADF3BAF, 0x8ADA2ACB, 0x8AD51B08, 0x8AD00C66, 0x8ACAFEE6, + 0x8AC5F286, 0x8AC0E748, 0x8ABBDD2B, 0x8AB6D42F, 0x8AB1CC55, 0x8AACC59C, + 0x8AA7C005, 0x8AA2BB8F, 0x8A9DB83B, 0x8A98B609, 0x8A93B4F8, 0x8A8EB509, + 0x8A89B63B, 0x8A84B890, 0x8A7FBC06, 0x8A7AC09E, 0x8A75C659, 0x8A70CD35, + 0x8A6BD533, 0x8A66DE54, 0x8A61E896, 0x8A5CF3FB, 0x8A580082, 0x8A530E2C, + 0x8A4E1CF7, 0x8A492CE5, 0x8A443DF6, 0x8A3F5029, 0x8A3A637F, 0x8A3577F7, + 0x8A308D92, 0x8A2BA44F, 0x8A26BC30, 0x8A21D533, 0x8A1CEF59, 0x8A180AA2, + 0x8A13270D, 0x8A0E449C, 0x8A09634E, 0x8A048322, 0x89FFA41A, 0x89FAC635, + 0x89F5E974, 0x89F10DD5, 0x89EC335A, 0x89E75A02, 0x89E281CD, 0x89DDAABC, + 0x89D8D4CF, 0x89D40005, 0x89CF2C5E, 0x89CA5A3E, 0x89C588DF, 0x89C0B8A3, + 0x89BBE98B, 0x89B71B97, 0x89B24EC7, 0x89AD831B, 0x89A8B893, 0x89A3EF2F, + 0x899F26EF, 0x899A5FD2, 0x899599DA, 0x8990D507, 0x898C1157, 0x89874ECC, + 0x89828D65, 0x897DCD22, 0x89790E04, 0x8974500A, 0x896F9335, 0x896AD784, + 0x89661CF8, 0x89616391, 0x895CAB4E, 0x8957F430, 0x89533E37, 0x894E8962, + 0x8949D5B3, 0x89452328, 0x894071C2, 0x893BC182, 0x89371266, 0x8932646F, + 0x892DB79E, 0x89290BF2, 0x8924616B, 0x891FB809, 0x891B0FCC, 0x891668B5, + 0x8911C2C4, 0x890D1DF7, 0x89087A51, 0x8903D7D0, 0x88FF3674, 0x88FA963E, + 0x88F5F72E, 0x88F15943, 0x88ECBC7E, 0x88E820DF, 0x88E38666, 0x88DEED13, + 0x88DA54E6, 0x88D5BDDE, 0x88D127FD, 0x88CC9342, 0x88C7FFAD, 0x88C36D3E, + 0x88BEDBF5, 0x88BA4BD2, 0x88B5BCD6, 0x88B12F00, 0x88ACA251, 0x88A816C8, + 0x88A38C65, 0x889F0329, 0x889A7B14, 0x8895F425, 0x88916E5C, 0x888CE9BB, + 0x88886640, 0x8883E3EC, 0x887F62BF, 0x887AE2B8, 0x887663D9, 0x8871E620, + 0x886D698F, 0x8868EE24, 0x886473E1, 0x885FFAC5, 0x885B82CF, 0x88570C01, + 0x8852965B, 0x884E21DB, 0x8849AE83, 0x88453C53, 0x8840CB49, 0x883C5B68, + 0x8837ECAD, 0x88337F1B, 0x882F12AF, 0x882AA76C, 0x88263D50, 0x8821D45C, + 0x881D6C90, 0x881905EB, 0x8814A06E, 0x88103C1A, 0x880BD8ED, 0x880776E8, + 0x8803160B, 0x87FEB656, 0x87FA57CA, 0x87F5FA65, 0x87F19E29, 0x87ED4315, + 0x87E8E929, 0x87E49065, 0x87E038CA, 0x87DBE257, 0x87D78D0D, 0x87D33943, + 0x87CEE64A, 0x87CA9479, 0x87C643D0, 0x87C1F451, 0x87BDA5FA, 0x87B958CB, + 0x87B50CC6, 0x87B0C1E9, 0x87AC7836, 0x87A82FAB, 0x87A3E849, 0x879FA210, + 0x879B5D00, 0x87971919, 0x8792D65B, 0x878E94C6, 0x878A545B, 0x87861519, + 0x8781D700, 0x877D9A10, 0x87795E4A, 0x877523AD, 0x8770EA39, 0x876CB1EF, + 0x87687ACF, 0x876444D8, 0x8760100A, 0x875BDC66, 0x8757A9EC, 0x8753789C, + 0x874F4875, 0x874B1978, 0x8746EBA5, 0x8742BEFC, 0x873E937D, 0x873A6928, + 0x87363FFD, 0x873217FB, 0x872DF124, 0x8729CB77, 0x8725A6F4, 0x8721839B, + 0x871D616D, 0x87194069, 0x8715208F, 0x871101DF, 0x870CE45A, 0x8708C800, + 0x8704ACCF, 0x870092CA, 0x86FC79EE, 0x86F8623E, 0x86F44BB8, 0x86F0365D, + 0x86EC222C, 0x86E80F26, 0x86E3FD4B, 0x86DFEC9B, 0x86DBDD16, 0x86D7CEBB, + 0x86D3C18C, 0x86CFB587, 0x86CBAAAE, 0x86C7A0FF, 0x86C3987C, 0x86BF9124, + 0x86BB8AF7, 0x86B785F5, 0x86B3821F, 0x86AF7F73, 0x86AB7DF4, 0x86A77D9F, + 0x86A37E76, 0x869F8078, 0x869B83A6, 0x869787FF, 0x86938D84, 0x868F9435, + 0x868B9C11, 0x8687A519, 0x8683AF4C, 0x867FBAAC, 0x867BC737, 0x8677D4EE, + 0x8673E3D1, 0x866FF3DF, 0x866C051A, 0x86681781, 0x86642B13, 0x86603FD2, + 0x865C55BD, 0x86586CD4, 0x86548517, 0x86509E86, 0x864CB922, 0x8648D4EA, + 0x8644F1DE, 0x86410FFE, 0x863D2F4B, 0x86394FC5, 0x8635716B, 0x8631943D, + 0x862DB83C, 0x8629DD67, 0x862603BF, 0x86222B44, 0x861E53F6, 0x861A7DD4, + 0x8616A92D, 0x8612D565, 0x860F02C9, 0x860B315A, 0x86076119, 0x86039204, + 0x85FFC41C, 0x85FBF762, 0x85F82BD4, 0x85F46173, 0x85F09840, 0x85ECD03A, + 0x85E90961, 0x85E543B5, 0x85E17F36, 0x85DDBBE5, 0x85D9F9C2, 0x85D638CB, + 0x85D27902, 0x85CEBA67, 0x85CAFCF8, 0x85C740B8, 0x85C385A5, 0x85BFCBC0, + 0x85BC1308, 0x85B85B7E, 0x85B4A522, 0x85B0EFF3, 0x85AD3BF2, 0x85A98920, + 0x85A5D77A, 0x85A22703, 0x859E77BA, 0x859AC99F, 0x85971CB1, 0x859370F2, + 0x858FC661, 0x858C1CFE, 0x858874C9, 0x8584CDC2, 0x858127EA, 0x857D833F, + 0x8579DFC3, 0x85763D76, 0x85729C56, 0x856EFC66, 0x856B5DA3, 0x8567C00F, + 0x856423A9, 0x85608872, 0x855CEE6A, 0x85595590, 0x8555BDE5, 0x85522768, + 0x854E921A, 0x854AFDFB, 0x85476B0B, 0x8543D949, 0x854048B6, 0x853CB952, + 0x85392B1D, 0x85359E17, 0x85321240, 0x852E8798, 0x852AFE1F, 0x852775D5, + 0x8523EEBA, 0x852068CF, 0x851CE412, 0x85196085, 0x8515DE27, 0x85125CF8, + 0x850EDCF9, 0x850B5E29, 0x8507E088, 0x85046417, 0x8500E8D5, 0x84FD6EC3, + 0x84F9F5E0, 0x84F67E2C, 0x84F307A9, 0x84EF9255, 0x84EC1E30, 0x84E8AB3C, + 0x84E53976, 0x84E1C8E1, 0x84DE597C, 0x84DAEB46, 0x84D77E40, 0x84D4126A, + 0x84D0A7C4, 0x84CD3E4E, 0x84C9D608, 0x84C66EF2, 0x84C3090C, 0x84BFA456, + 0x84BC40D0, 0x84B8DE7A, 0x84B57D55, 0x84B21D60, 0x84AEBE9A, 0x84AB6106, + 0x84A804A1, 0x84A4A96D, 0x84A14F69, 0x849DF696, 0x849A9EF3, 0x84974880, + 0x8493F33E, 0x84909F2D, 0x848D4C90, 0x8489FADF, 0x8486AA60, 0x84835B11, + 0x84800CF2, 0x847CC005, 0x84797448, 0x847629BC, 0x8472E060, 0x846F9836, + 0x846C513C, 0x84690B74, 0x8465C6DC, 0x84628375, 0x845F4140, 0x845C003B, + 0x8458C067, 0x845581C5, 0x84524453, 0x844F0813, 0x844BCD04, 0x84489327, + 0x84455A7A, 0x844222FF, 0x843EECB5, 0x843BB79C, 0x843883B5, 0x84355100, + 0x84321F7B, 0x842EEF28, 0x842BC007, 0x84289217, 0x84256559, 0x842239CD, + 0x841F0F72, 0x841BE648, 0x8418BE51, 0x8415978B, 0x841271F7, 0x840F4D94, + 0x840C2A64, 0x84090865, 0x8405E798, 0x8402C7FD, 0x83FFA994, 0x83FC8C5D, + 0x83F97058, 0x83F65585, 0x83F33BE4, 0x83F02375, 0x83ED0C38, 0x83E9F62E, + 0x83E6E155, 0x83E3CDAF, 0x83E0BB3B, 0x83DDA9F9, 0x83DA99EA, 0x83D78B0D, + 0x83D47D62, 0x83D170E9, 0x83CE65A3, 0x83CB5B90, 0x83C852AF, 0x83C54B00, + 0x83C24484, 0x83BF3F3A, 0x83BC3B23, 0x83B9383F, 0x83B6368D, 0x83B3360E, + 0x83B036C2, 0x83AD38A8, 0x83AA3BC2, 0x83A7400E, 0x83A4458C, 0x83A14C3E, + 0x839E5422, 0x839B5D3A, 0x83986784, 0x83957301, 0x83927FB2, 0x838F8D95, + 0x838C9CAB, 0x8389ACF4, 0x8386BE71, 0x8383D121, 0x8380E503, 0x837DFA19, + 0x837B1062, 0x837827DF, 0x8375408E, 0x83725A71, 0x836F7588, 0x836C91D1, + 0x8369AF4E, 0x8366CDFF, 0x8363EDE3, 0x83610EFA, 0x835E3145, 0x835B54C3, + 0x83587975, 0x83559F5A, 0x8352C674, 0x834FEEC0, 0x834D1841, 0x834A42F5, + 0x83476EDC, 0x83449BF8, 0x8341CA47, 0x833EF9CA, 0x833C2ABA, 0x83395CA5, + 0x83368FC3, 0x8333C416, 0x8330F99C, 0x832E3056, 0x832B6844, 0x8328A167, + 0x8325DBBD, 0x83231747, 0x83205406, 0x831D91F8, 0x831AD11F, 0x8318117A, + 0x83155309, 0x831295CC, 0x830FD9C4, 0x830D1EF0, 0x830A6550, 0x8307ACE4, + 0x8304F5AD, 0x83023FAA, 0x82FF8ADC, 0x82FCD742, 0x82FA24DC, 0x82F773AB, + 0x82F4C3AF, 0x82F214E7, 0x82EF6753, 0x82ECBAF4, 0x82EA0FCA, 0x82E765D4, + 0x82E4BD13, 0x82E21587, 0x82DF6F30, 0x82DCCA0D, 0x82DA261F, 0x82D78365, + 0x82D4E1E1, 0x82D24191, 0x82CFA277, 0x82CD0491, 0x82CA67E0, 0x82C7CC64, + 0x82C5321D, 0x82C2990B, 0x82C0012E, 0x82BD6A86, 0x82BAD513, 0x82B840D5, + 0x82B5ADCD, 0x82B31BF9, 0x82B08B5B, 0x82ADFBF2, 0x82AB6DBE, 0x82A8E0BF, + 0x82A654F6, 0x82A3CA62, 0x82A14103, 0x829EB8D9, 0x829C31E5, 0x8299AC26, + 0x8297279D, 0x8294A449, 0x8292222B, 0x828FA142, 0x828D218E, 0x828AA311, + 0x828825C8, 0x8285A9B6, 0x82832ED8, 0x8280B531, 0x827E3CBF, 0x827BC583, + 0x82794F7C, 0x8276DAAC, 0x82746711, 0x8271F4AB, 0x826F837C, 0x826D1382, + 0x826AA4BF, 0x82683731, 0x8265CAD9, 0x82635FB6, 0x8260F5CA, 0x825E8D14, + 0x825C2594, 0x8259BF4A, 0x82575A35, 0x8254F657, 0x825293AF, 0x8250323D, + 0x824DD201, 0x824B72FC, 0x8249152C, 0x8246B893, 0x82445D30, 0x82420303, + 0x823FAA0C, 0x823D524C, 0x823AFBC2, 0x8238A66E, 0x82365251, 0x8233FF6A, + 0x8231ADB9, 0x822F5D3F, 0x822D0DFB, 0x822ABFEE, 0x82287317, 0x822627A5, + 0x8223DD3C, 0x82219408, 0x821F4C0B, 0x821D0545, 0x821ABFB6, 0x82187B5D, + 0x8216383B, 0x8213F64F, 0x8211B59A, 0x820F761C, 0x820D37D5, 0x820AFAC4, + 0x8208BEEA, 0x82068447, 0x82044ADB, 0x820212A5, 0x81FFDBA7, 0x81FDA5DF, + 0x81FB714F, 0x81F93DF5, 0x81F70BD2, 0x81F4DAE6, 0x81F2AB32, 0x81F07CB4, + 0x81EE4F6D, 0x81EC235D, 0x81E9F885, 0x81E7CEE3, 0x81E5A679, 0x81E37F46, + 0x81E1594A, 0x81DF3485, 0x81DD10F7, 0x81DAEEA1, 0x81D8CD82, 0x81D6AD9A, + 0x81D48EE9, 0x81D27170, 0x81D0552E, 0x81CE3A24, 0x81CC2050, 0x81CA07B5, + 0x81C7F050, 0x81C5DA23, 0x81C3C52E, 0x81C1B170, 0x81BF9EE9, 0x81BD8D9A, + 0x81BB7D83, 0x81B96EA3, 0x81B760FA, 0x81B5548A, 0x81B34950, 0x81B13F4F, + 0x81AF3685, 0x81AD2EF3, 0x81AB2898, 0x81A92376, 0x81A71F8A, 0x81A51CD7, + 0x81A31B5C, 0x81A11B18, 0x819F1C0C, 0x819D1E38, 0x819B219C, 0x81992637, + 0x81972C0B, 0x81953316, 0x81933B59, 0x819144D5, 0x818F4F88, 0x818D5B73, + 0x818B6896, 0x818976F2, 0x81878685, 0x81859750, 0x8183A954, 0x8181BC8F, + 0x817FD103, 0x817DE6AE, 0x817BFD92, 0x817A15AE, 0x81782F02, 0x8176498F, + 0x81746554, 0x81728250, 0x8170A086, 0x816EBFF3, 0x816CE099, 0x816B0277, + 0x8169258D, 0x816749DC, 0x81656F63, 0x81639622, 0x8161BE1A, 0x815FE74A, + 0x815E11B3, 0x815C3D54, 0x815A6A2E, 0x81589840, 0x8156C78B, 0x8154F80E, + 0x815329CA, 0x81515CBE, 0x814F90EB, 0x814DC650, 0x814BFCEE, 0x814A34C5, + 0x81486DD4, 0x8146A840, 0x8144E3C1, 0x8143207A, 0x81415E6C, 0x813F9D97, + 0x813DDDFA, 0x813C1F97, 0x813A626C, 0x8138A679, 0x8136EBC0, 0x81353240, + 0x813379F8, 0x8131C2E9, 0x81300D13, 0x812E5876, 0x812CA512, 0x812AF2E7, + 0x812941F5, 0x8127923B, 0x8125E3BB, 0x81243674, 0x81228A65, 0x8120DF90, + 0x811F35F4, 0x811D8D91, 0x811BE667, 0x811A4076, 0x81189BBE, 0x8116F83F, + 0x811555F9, 0x8113B4ED, 0x8112151A, 0x81107680, 0x810ED91F, 0x810D3CF7, + 0x810BA209, 0x810A0853, 0x81086FD7, 0x8106D895, 0x8105428B, 0x8103ADBB, + 0x81021A25, 0x810087C7, 0x80FEF6A3, 0x80FD66B9, 0x80FBD807, 0x80FA4A90, + 0x80F8BE51, 0x80F7334C, 0x80F5A981, 0x80F420EE, 0x80F29996, 0x80F11377, + 0x80EF8E91, 0x80EE0AE5, 0x80EC8872, 0x80EB0739, 0x80E9873A, 0x80E80874, + 0x80E68AE8, 0x80E50E95, 0x80E3937C, 0x80E2199D, 0x80E0A0F7, 0x80DF298B, + 0x80DDB358, 0x80DC3E5F, 0x80DACAA0, 0x80D9581B, 0x80D7E6D0, 0x80D676BE, + 0x80D507E6, 0x80D39A47, 0x80D22DE3, 0x80D0C2B8, 0x80CF58C7, 0x80CDF010, + 0x80CC8893, 0x80CB2250, 0x80C9BD46, 0x80C85977, 0x80C6F6E1, 0x80C59585, + 0x80C43563, 0x80C2D67B, 0x80C178CD, 0x80C01C59, 0x80BEC11F, 0x80BD671F, + 0x80BC0E59, 0x80BAB6CD, 0x80B9607B, 0x80B80B63, 0x80B6B785, 0x80B564E2, + 0x80B41378, 0x80B2C348, 0x80B17453, 0x80B02697, 0x80AEDA16, 0x80AD8ECF, + 0x80AC44C2, 0x80AAFBEF, 0x80A9B456, 0x80A86DF8, 0x80A728D4, 0x80A5E4EA, + 0x80A4A23A, 0x80A360C4, 0x80A22089, 0x80A0E1A1, 0x809FA3DA, 0x809E674E, + 0x809D2BFC, 0x809BF1E4, 0x809AB906, 0x80998163, 0x80984AFA, 0x809715CB, + 0x8095E1D7, 0x8094AF1D, 0x80937D9E, 0x80924D59, 0x80911E4E, 0x808FF07E, + 0x808EC3E8, 0x808D988D, 0x808C6E6C, 0x808B4586, 0x808A1DDA, 0x8088F769, + 0x8087D232, 0x8086AE36, 0x80858B74, 0x808469ED, 0x808349A0, 0x80822A8E, + 0x80810CB6, 0x807FF019, 0x807ED4B7, 0x807DBA8F, 0x807CA1A2, 0x807B89F0, + 0x807A7378, 0x80795E3B, 0x80784A38, 0x80773770, 0x807625E3, 0x80751590, + 0x80740679, 0x8072F89B, 0x8071EBF9, 0x8070E091, 0x806FD664, 0x806ECD72, + 0x806DC5BB, 0x806CBF3E, 0x806BB9FC, 0x806AB5F5, 0x8069B329, 0x8068B198, + 0x8067B141, 0x8066B225, 0x8065B444, 0x8064B79E, 0x8063BC33, 0x8062C202, + 0x8061C90D, 0x8060D152, 0x805FDAD3, 0x805EE58E, 0x805DF184, 0x805CFEB5, + 0x805C0D21, 0x805B1CC8, 0x805A2DA9, 0x80593FC6, 0x8058531E, 0x805767B1, + 0x80567D7F, 0x80559487, 0x8054ACCB, 0x8053C64A, 0x8052E104, 0x8051FCF8, + 0x80511A28, 0x80503893, 0x804F5839, 0x804E791A, 0x804D9B36, 0x804CBE8D, + 0x804BE31F, 0x804B08ED, 0x804A2FF5, 0x80495839, 0x804881B8, 0x8047AC71, + 0x8046D866, 0x80460596, 0x80453402, 0x804463A8, 0x8043948A, 0x8042C6A6, + 0x8041F9FE, 0x80412E92, 0x80406460, 0x803F9B69, 0x803ED3AE, 0x803E0D2E, + 0x803D47E9, 0x803C83E0, 0x803BC112, 0x803AFF7F, 0x803A3F27, 0x8039800A, + 0x8038C229, 0x80380583, 0x80374A18, 0x80368FE9, 0x8035D704, 0x80351F4B, + 0x803468CD, 0x8033B38B, 0x8032FF84, 0x80324CB9, 0x80319B28, 0x8030EAD4, + 0x80303BBA, 0x802F8DDC, 0x802EE139, 0x802E35D2, 0x802D8BA6, 0x802CE2B5, + 0x802C3B00, 0x802B9486, 0x802AEF48, 0x802A4B45, 0x8029A87D, 0x802906F1, + 0x802866A0, 0x8027C78B, 0x802729B1, 0x80268D13, 0x8025F1B0, 0x80255789, + 0x8024BE9D, 0x802426EC, 0x80239077, 0x8022FB3E, 0x80226740, 0x8021D47D, + 0x802142F6, 0x8020B2AB, 0x8020239B, 0x801F95C6, 0x801F092D, 0x801E7DD0, + 0x801DF3AE, 0x801D6AC7, 0x801CE31D, 0x801C5CAD, 0x801BD77A, 0x801B5381, + 0x801AD0C5, 0x801A4F44, 0x8019CEFE, 0x80194FF5, 0x8018D226, 0x80185594, + 0x8017DA3D, 0x80176021, 0x8016E741, 0x80166F9D, 0x8015F934, 0x80158407, + 0x80151016, 0x80149D60, 0x80142BE6, 0x8013BBA7, 0x80134CA4, 0x8012DEDD, + 0x80127252, 0x80120702, 0x80119CED, 0x80113415, 0x8010CC78, 0x80106616, + 0x801000F1, 0x800F9D07, 0x800F3A58, 0x800ED8E6, 0x800E78AF, 0x800E19B4, + 0x800DBBF4, 0x800D5F70, 0x800D0428, 0x800CAA1C, 0x800C514B, 0x800BF9B6, + 0x800BA35D, 0x800B4E3F, 0x800AFA5D, 0x800AA7B7, 0x800A564D, 0x800A061E, + 0x8009B72B, 0x80096974, 0x80091CF8, 0x8008D1B9, 0x800887B5, 0x80083EEC, + 0x8007F760, 0x8007B10F, 0x80076BFA, 0x80072821, 0x8006E584, 0x8006A422, + 0x800663FC, 0x80062512, 0x8005E763, 0x8005AAF1, 0x80056FBA, 0x800535BF, + 0x8004FCFF, 0x8004C57C, 0x80048F34, 0x80045A28, 0x80042658, 0x8003F3C4, + 0x8003C26F, 0x80039252, 0x80036371, 0x800335CC, 0x80030962, 0x8002DE35, + 0x8002B443, 0x80028B8D, 0x80026412, 0x80023DD4, 0x800218D1, 0x8001F50A, + 0x8001D27F, 0x8001B130, 0x8001911C, 0x80017245, 0x800154A9, 0x80013849, + 0x80011D25, 0x8001033D, 0x8000EA90, 0x8000D31F, 0x8000BCEA, 0x8000A7F1, + 0x80009434, 0x800081B3, 0x8000706D, 0x80006063, 0x80005195, 0x80004403, + 0x800037AD, 0x80002C92, 0x800022B4, 0x80001A11, 0x800012AA, 0x80000C7F, + 0x8000078F, 0x800003DC, 0x80000164, 0x80000028 +}; + +const int32_t sine_2048[] ICONST_ATTR_WMAPRO_WIN_VS_TMP = { + 0xFFF36F03, 0xFFDA4D09, 0xFFC12B0F, 0xFFA80918, 0xFF8EE725, 0xFF75C536, + 0xFF5CA34B, 0xFF438168, 0xFF2A5F8C, 0xFF113DB7, 0xFEF81BEE, 0xFEDEFA2D, + 0xFEC5D876, 0xFEACB6CE, 0xFE939531, 0xFE7A73A2, 0xFE615224, 0xFE4830B4, + 0xFE2F0F55, 0xFE15EE0A, 0xFDFCCCD0, 0xFDE3ABAA, 0xFDCA8A98, 0xFDB1699D, + 0xFD9848BC, 0xFD7F27EF, 0xFD66073A, 0xFD4CE69F, 0xFD33C61F, 0xFD1AA5BB, + 0xFD018577, 0xFCE8654C, 0xFCCF4541, 0xFCB62554, 0xFC9D0588, 0xFC83E5DE, + 0xFC6AC65A, 0xFC51A6F5, 0xFC3887B4, 0xFC1F6899, 0xFC0649A4, 0xFBED2AD7, + 0xFBD40C35, 0xFBBAEDB5, 0xFBA1CF67, 0xFB88B144, 0xFB6F9345, 0xFB56757B, + 0xFB3D57D7, 0xFB243A6A, 0xFB0B1D25, 0xFAF20019, 0xFAD8E33F, 0xFABFC690, + 0xFAA6AA1D, 0xFA8D8DD6, 0xFA7471CD, 0xFA5B55FB, 0xFA423A59, 0xFA291EF7, + 0xFA1003C7, 0xF9F6E8D9, 0xF9DDCE1F, 0xF9C4B3AA, 0xF9AB9972, 0xF9927F70, + 0xF97965B6, 0xF9604C34, 0xF94732FC, 0xF92E1A06, 0xF915014C, 0xF8FBE8DD, + 0xF8E2D0AC, 0xF8C9B8C9, 0xF8B0A126, 0xF89789D2, 0xF87E72C8, 0xF8655BFF, + 0xF84C458A, 0xF8332F59, 0xF81A197C, 0xF80103EE, 0xF7E7EEA7, 0xF7CED9AF, + 0xF7B5C518, 0xF79CB0C3, 0xF7839CC1, 0xF76A8923, 0xF75175C9, 0xF73862C5, + 0xF71F5018, 0xF7063DD2, 0xF6ED2BD5, 0xF6D41A32, 0xF6BB08F9, 0xF6A1F80B, + 0xF688E77A, 0xF66FD747, 0xF656C781, 0xF63DB80B, 0xF624A8F6, 0xF60B9A51, + 0xF5F28BFF, 0xF5D97E11, 0xF5C07096, 0xF5A76370, 0xF58E56B1, 0xF5754A59, + 0xF55C3E78, 0xF54332F1, 0xF52A27D4, 0xF5111D31, 0xF4F812EB, 0xF4DF0911, + 0xF4C5FFA6, 0xF4ACF6B9, 0xF493EE2B, 0xF47AE60F, 0xF461DE74, 0xF448D73C, + 0xF42FD078, 0xF416CA28, 0xF3FDC45D, 0xF3E4BEFA, 0xF3CBBA0D, 0xF3B2B5A9, + 0xF399B1AF, 0xF380AE2F, 0xF367AB3A, 0xF34EA8B2, 0xF335A6A7, 0xF31CA51A, + 0xF303A41C, 0xF2EAA38E, 0xF2D1A382, 0xF2B8A408, 0xF29FA500, 0xF286A67D, + 0xF26DA87F, 0xF254AB17, 0xF23BAE25, 0xF222B1BC, 0xF209B5EB, 0xF1F0BA94, + 0xF1D7BFC8, 0xF1BEC588, 0xF1A5CBE4, 0xF18CD2BE, 0xF173DA26, 0xF15AE22E, + 0xF141EAB7, 0xF128F3D1, 0xF10FFD8E, 0xF0F707CE, 0xF0DE12A2, 0xF0C51E0C, + 0xF0AC2A1C, 0xF09336B4, 0xF07A43E3, 0xF06151BC, 0xF048601F, 0xF02F6F1D, + 0xF0167EB8, 0xEFFD8EFF, 0xEFE49FD4, 0xEFCBB148, 0xEFB2C35C, 0xEF99D612, + 0xEF80E988, 0xEF67FD82, 0xEF4F121F, 0xEF362762, 0xEF1D3D4A, 0xEF0453D8, + 0xEEEB6B0F, 0xEED2830D, 0xEEB99B95, 0xEEA0B4C8, 0xEE87CEA7, 0xEE6EE931, + 0xEE560469, 0xEE3D2050, 0xEE243D05, 0xEE0B5A4B, 0xEDF27842, 0xEDD996EC, + 0xEDC0B648, 0xEDA7D659, 0xED8EF73E, 0xED7618BA, 0xED5D3AED, 0xED445DD7, + 0xED2B817B, 0xED12A5D8, 0xECF9CAF0, 0xECE0F0E3, 0xECC81774, 0xECAF3EC2, + 0xEC9666CF, 0xEC7D8F9C, 0xEC64B929, 0xEC4BE377, 0xEC330EA8, 0xEC1A3A7C, + 0xEC016715, 0xEBE89473, 0xEBCFC298, 0xEBB6F184, 0xEB9E2138, 0xEB8551D4, + 0xEB6C831B, 0xEB53B52E, 0xEB3AE80C, 0xEB221BB7, 0xEB095031, 0xEAF08579, + 0xEAD7BBB0, 0xEABEF299, 0xEAA62A54, 0xEA8D62E1, 0xEA749C42, 0xEA5BD678, + 0xEA431183, 0xEA2A4D84, 0xEA118A3E, 0xE9F8C7CF, 0xE9E0063B, 0xE9C74580, + 0xE9AE85A1, 0xE995C69E, 0xE97D0898, 0xE9644B50, 0xE94B8EE8, 0xE932D360, + 0xE91A18B9, 0xE9015EF3, 0xE8E8A631, 0xE8CFEE32, 0xE8B73719, 0xE89E80E5, + 0xE885CB98, 0xE86D1733, 0xE85463B6, 0xE83BB143, 0xE822FF9A, 0xE80A4EDE, + 0xE7F19F0D, 0xE7D8F02A, 0xE7C04236, 0xE7A79530, 0xE78EE93B, 0xE7763E17, + 0xE75D93E6, 0xE744EAA7, 0xE72C425D, 0xE7139B08, 0xE6FAF4A8, 0xE6E24F5F, + 0xE6C9AAEF, 0xE6B10777, 0xE69864F9, 0xE67FC376, 0xE66722EF, 0xE64E8364, + 0xE635E4F6, 0xE61D4767, 0xE604AAD8, 0xE5EC0F49, 0xE5D374BC, 0xE5BADB31, + 0xE5A242A9, 0xE589AB45, 0xE57114C6, 0xE5587F4E, 0xE53FEADD, 0xE5275773, + 0xE50EC513, 0xE4F633DC, 0xE4DDA391, 0xE4C51451, 0xE4AC861E, 0xE493F8F9, + 0xE47B6CE2, 0xE462E1DB, 0xE44A5804, 0xE431CF1F, 0xE419474D, 0xE400C08D, + 0xE3E83AE3, 0xE3CFB64D, 0xE3B732CE, 0xE39EB085, 0xE3862F34, 0xE36DAEFD, + 0xE3552FE0, 0xE33CB1DE, 0xE32434F8, 0xE30BB92F, 0xE2F33EA2, 0xE2DAC515, + 0xE2C24CA8, 0xE2A9D55B, 0xE2915F30, 0xE278EA27, 0xE2607642, 0xE24803A0, + 0xE22F9205, 0xE217218F, 0xE1FEB241, 0xE1E6441B, 0xE1CDD71E, 0xE1B56B4C, + 0xE19D00C3, 0xE1849747, 0xE16C2EF8, 0xE153C7D6, 0xE13B61E4, 0xE122FD21, + 0xE10A998E, 0xE0F2374C, 0xE0D9D61E, 0xE0C17623, 0xE0A9175D, 0xE090B9CC, + 0xE0785D71, 0xE060026C, 0xE047A880, 0xE02F4FCE, 0xE016F855, 0xDFFEA217, + 0xDFE64D16, 0xDFCDF951, 0xDFB5A6C9, 0xDF9D5581, 0xDF850578, 0xDF6CB6B0, + 0xDF546967, 0xDF3C1D23, 0xDF23D222, 0xDF0B8865, 0xDEF33FEE, 0xDEDAF8BD, + 0xDEC2B2D2, 0xDEAA6E30, 0xDE922AD7, 0xDE79E8C8, 0xDE61A804, 0xDE49688C, + 0xDE312A60, 0xDE18EDC0, 0xDE00B230, 0xDDE877F1, 0xDDD03F01, 0xDDB80763, + 0xDD9FD118, 0xDD879C1F, 0xDD6F687B, 0xDD57362C, 0xDD3F0533, 0xDD26D591, + 0xDD0EA747, 0xDCF67A56, 0xDCDE4EBF, 0xDCC624C0, 0xDCADFBDF, 0xDC95D45B, + 0xDC7DAE34, 0xDC65896C, 0xDC4D6603, 0xDC3543FA, 0xDC1D2353, 0xDC05040E, + 0xDBECE62C, 0xDBD4C9AE, 0xDBBCAE95, 0xDBA494E1, 0xDB8C7C95, 0xDB7465EE, + 0xDB5C5072, 0xDB443C60, 0xDB2C29B8, 0xDB14187C, 0xDAFC08AC, 0xDAE3FA4A, + 0xDACBED56, 0xDAB3E1D1, 0xDA9BD7BC, 0xDA83CF18, 0xDA6BC7E6, 0xDA53C227, + 0xDA3BBDDC, 0xDA23BB42, 0xDA0BB9E1, 0xD9F3B9F7, 0xD9DBBB85, 0xD9C3BE8A, + 0xD9ABC309, 0xD993C903, 0xD97BD077, 0xD963D968, 0xD94BE3D6, 0xD933EFC2, + 0xD91BFD2D, 0xD9040C17, 0xD8EC1CC0, 0xD8D42EAD, 0xD8BC421C, 0xD8A4570F, + 0xD88C6D87, 0xD8748584, 0xD85C9F07, 0xD844BA12, 0xD82CD6A4, 0xD814F4C0, + 0xD7FD1466, 0xD7E53596, 0xD7CD5853, 0xD7B57C9C, 0xD79DA2AF, 0xD785CA15, + 0xD76DF309, 0xD7561D8F, 0xD73E49A5, 0xD726774E, 0xD70EA68A, 0xD6F6D75A, + 0xD6DF09BF, 0xD6C73DBA, 0xD6AF734C, 0xD697AA76, 0xD67FE338, 0xD6681D94, + 0xD65059C7, 0xD6389759, 0xD620D687, 0xD6091753, 0xD5F159BC, 0xD5D99DC5, + 0xD5C1E36E, 0xD5AA2AB7, 0xD59273A3, 0xD57ABE31, 0xD5630A63, 0xD54B5839, + 0xD533A7B5, 0xD51BF914, 0xD5044BDE, 0xD4ECA050, 0xD4D4F66B, 0xD4BD4E30, + 0xD4A5A7A0, 0xD48E02BC, 0xD4765F85, 0xD45EBDFB, 0xD4471E20, 0xD42F7FF5, + 0xD417E37A, 0xD40048B0, 0xD3E8AF98, 0xD3D11870, 0xD3B982C0, 0xD3A1EEC5, + 0xD38A5C80, 0xD372CBF1, 0xD35B3D1A, 0xD343AFFC, 0xD32C2497, 0xD3149AED, + 0xD2FD12FE, 0xD2E58CCC, 0xD2CE0856, 0xD2B6859F, 0xD29F04A6, 0xD28785AA, + 0xD2700832, 0xD2588C7C, 0xD2411288, 0xD2299A58, 0xD21223EC, 0xD1FAAF46, + 0xD1E33C66, 0xD1CBCB4D, 0xD1B45BFC, 0xD19CEE74, 0xD18582B6, 0xD16E18C2, + 0xD156B0D6, 0xD13F4A7A, 0xD127E5EC, 0xD110832D, 0xD0F9223C, 0xD0E1C31C, + 0xD0CA65CD, 0xD0B30A50, 0xD09BB0A5, 0xD08458CF, 0xD06D02CD, 0xD055AEA0, + 0xD03E5C4A, 0xD0270BCB, 0xD00FBD60, 0xCFF87093, 0xCFE1259F, 0xCFC9DC87, + 0xCFB2954B, 0xCF9B4FEB, 0xCF840C68, 0xCF6CCAC5, 0xCF558B01, 0xCF3E4D1D, + 0xCF27111A, 0xCF0FD6F9, 0xCEF89EBC, 0xCEE16862, 0xCECA3428, 0xCEB30199, + 0xCE9BD0F0, 0xCE84A22F, 0xCE6D7556, 0xCE564A66, 0xCE3F2161, 0xCE27FA47, + 0xCE10D518, 0xCDF9B1D7, 0xCDE29083, 0xCDCB711D, 0xCDB453A8, 0xCD9D3822, + 0xCD861EC9, 0xCD6F0727, 0xCD57F178, 0xCD40DDBE, 0xCD29CBF8, 0xCD12BC27, + 0xCCFBAE4E, 0xCCE4A26C, 0xCCCD9882, 0xCCB69091, 0xCC9F8A9B, 0xCC8886A0, + 0xCC7184A1, 0xCC5A84D9, 0xCC4386D4, 0xCC2C8ACE, 0xCC1590C8, 0xCBFE98C2, + 0xCBE7A2BD, 0xCBD0AEBA, 0xCBB9BCBB, 0xCBA2CCBF, 0xCB8BDEC8, 0xCB74F2D7, + 0xCB5E08EC, 0xCB472109, 0xCB303B2E, 0xCB195797, 0xCB0275CF, 0xCAEB9613, + 0xCAD4B862, 0xCABDDCBF, 0xCAA70328, 0xCA902BA1, 0xCA795628, 0xCA6282C0, + 0xCA4BB16A, 0xCA34E225, 0xCA1E14F3, 0xCA0749D5, 0xC9F080CC, 0xC9D9BA12, + 0xC9C2F534, 0xC9AC326E, 0xC99571C0, 0xC97EB32C, 0xC967F6B1, 0xC9513C51, + 0xC93A840C, 0xC923CDE5, 0xC90D19DA, 0xC8F667EE, 0xC8DFB822, 0xC8C90A75, + 0xC8B25F23, 0xC89BB5B9, 0xC8850E72, 0xC86E694E, 0xC857C64F, 0xC8412575, + 0xC82A86C1, 0xC813EA34, 0xC7FD4FD0, 0xC7E6B794, 0xC7D02181, 0xC7B98D9A, + 0xC7A2FBDD, 0xC78C6C4D, 0xC775DF24, 0xC75F53EF, 0xC748CAE9, 0xC7324413, + 0xC71BBF6D, 0xC7053CF9, 0xC6EEBCB8, 0xC6D83EA9, 0xC6C1C2CF, 0xC6AB4929, + 0xC694D1BA, 0xC67E5C81, 0xC667E980, 0xC65178B7, 0xC63B0A60, 0xC6249E0B, + 0xC60E33F1, 0xC5F7CC12, 0xC5E16670, 0xC5CB030C, 0xC5B4A1E7, 0xC59E4300, + 0xC587E65A, 0xC5718BF5, 0xC55B33D2, 0xC544DDF2, 0xC52E8A55, 0xC5183936, + 0xC501EA23, 0xC4EB9D57, 0xC4D552D1, 0xC4BF0A94, 0xC4A8C49F, 0xC49280F4, + 0xC47C3F94, 0xC466007F, 0xC44FC3B6, 0xC439893A, 0xC423510D, 0xC40D1B2E, + 0xC3F6E79F, 0xC3E0B698, 0xC3CA87AB, 0xC3B45B10, 0xC39E30C8, 0xC38808D4, + 0xC371E335, 0xC35BBFEB, 0xC3459EF8, 0xC32F805C, 0xC3196419, 0xC3034A2E, + 0xC2ED329E, 0xC2D71D68, 0xC2C10A8E, 0xC2AAFA48, 0xC294EC28, 0xC27EE066, + 0xC268D703, 0xC252CFFF, 0xC23CCB5D, 0xC226C91C, 0xC210C93D, 0xC1FACBC2, + 0xC1E4D0AB, 0xC1CED7F9, 0xC1B8E1AD, 0xC1A2EDC7, 0xC18CFC49, 0xC1770D33, + 0xC1612086, 0xC14B3644, 0xC1354E6C, 0xC11F6900, 0xC1098601, 0xC0F3A5DE, + 0xC0DDC7BA, 0xC0C7EC06, 0xC0B212C1, 0xC09C3BED, 0xC086678B, 0xC070959B, + 0xC05AC61F, 0xC044F916, 0xC02F2E83, 0xC0196665, 0xC003A0BF, 0xBFEDDD8F, + 0xBFD81CD8, 0xBFC25E9B, 0xBFACA2D7, 0xBF96E98E, 0xBF8132C1, 0xBF6B7E71, + 0xBF55CC9D, 0xBF401D48, 0xBF2A7072, 0xBF14C61C, 0xBEFF1E47, 0xBEE978F3, + 0xBED3D622, 0xBEBE35D4, 0xBEA8980A, 0xBE92FD33, 0xBE7D6473, 0xBE67CE3B, + 0xBE523A89, 0xBE3CA960, 0xBE271AC0, 0xBE118EA9, 0xBDFC051E, 0xBDE67E1E, + 0xBDD0F9AA, 0xBDBB77C4, 0xBDA5F86B, 0xBD907BA2, 0xBD7B0168, 0xBD6589BE, + 0xBD5014A6, 0xBD3AA221, 0xBD25322E, 0xBD0FC4CF, 0xBCFA5A05, 0xBCE4F1D0, + 0xBCCF8C31, 0xBCBA292A, 0xBCA4C8BB, 0xBC8F6AE4, 0xBC7A0FA7, 0xBC64B704, + 0xBC4F616A, 0xBC3A0DFE, 0xBC24BD30, 0xBC0F6EFF, 0xBBFA236D, 0xBBE4DA7A, + 0xBBCF9428, 0xBBBA5076, 0xBBA50F66, 0xBB8FD0F9, 0xBB7A9530, 0xBB655C0A, + 0xBB50258A, 0xBB3AF1B0, 0xBB25C07C, 0xBB1091F0, 0xBAFB660C, 0xBAE63CD2, + 0xBAD11641, 0xBABBF25B, 0xBAA6D121, 0xBA91B294, 0xBA7C96B3, 0xBA677D81, + 0xBA5266FE, 0xBA3D532A, 0xBA284207, 0xBA133395, 0xB9FE2840, 0xB9E91F33, + 0xB9D418DA, 0xB9BF1536, 0xB9AA1447, 0xB995160E, 0xB9801A8C, 0xB96B21C2, + 0xB9562BB0, 0xB9413858, 0xB92C47BA, 0xB91759D7, 0xB9026EB0, 0xB8ED8646, + 0xB8D8A099, 0xB8C3BDAA, 0xB8AEDD7B, 0xB89A000B, 0xB885255C, 0xB8704D6F, + 0xB85B7843, 0xB846A5DB, 0xB831D637, 0xB81D0957, 0xB8083F3D, 0xB7F377E9, + 0xB7DEB35D, 0xB7C9F202, 0xB7B53306, 0xB7A076D3, 0xB78BBD6B, 0xB77706CD, + 0xB76252FC, 0xB74DA1F7, 0xB738F3C0, 0xB7244857, 0xB70F9FBE, 0xB6FAF9F4, + 0xB6E656FB, 0xB6D1B6D3, 0xB6BD197D, 0xB6A87EFB, 0xB693E74C, 0xB67F5273, + 0xB66AC06E, 0xB6563140, 0xB641A4E9, 0xB62D1B69, 0xB61894C3, 0xB60410F5, + 0xB5EF9002, 0xB5DB11EA, 0xB5C696AE, 0xB5B21E4E, 0xB59DA934, 0xB589368F, + 0xB574C6CA, 0xB56059E4, 0xB54BEFDF, 0xB53788BB, 0xB5232479, 0xB50EC31A, + 0xB4FA649F, 0xB4E60908, 0xB4D1B057, 0xB4BD5A8B, 0xB4A907A6, 0xB494B7A9, + 0xB4806A94, 0xB46C2068, 0xB457D927, 0xB44394D0, 0xB42F5364, 0xB41B14E5, + 0xB406D952, 0xB3F2A0AE, 0xB3DE6AF8, 0xB3CA3832, 0xB3B6085B, 0xB3A1DB76, + 0xB38DB182, 0xB3798A81, 0xB36566DA, 0xB35145C0, 0xB33D279B, 0xB3290C6C, + 0xB314F433, 0xB300DEF1, 0xB2ECCCA7, 0xB2D8BD56, 0xB2C4B0FE, 0xB2B0A7A0, + 0xB29CA13E, 0xB2889DD7, 0xB2749D6D, 0xB260A000, 0xB24CA592, 0xB238AE22, + 0xB224B9B2, 0xB210C842, 0xB1FCD9D3, 0xB1E8EE67, 0xB1D505FD, 0xB1C12097, + 0xB1AD3E35, 0xB1995ED7, 0xB1858280, 0xB171A92F, 0xB15DD2E6, 0xB14A000A, + 0xB1362FD1, 0xB12262A2, 0xB10E987D, 0xB0FAD164, 0xB0E70D57, 0xB0D34C56, + 0xB0BF8E62, 0xB0ABD37D, 0xB0981BA7, 0xB08466E0, 0xB070B52A, 0xB05D0685, + 0xB0495AF2, 0xB035B272, 0xB0220D05, 0xB00E6AAD, 0xAFFACB6A, 0xAFE72F3C, + 0xAFD39625, 0xAFC00025, 0xAFAC6D3E, 0xAF98DD6F, 0xAF8550B9, 0xAF71C71E, + 0xAF5E409E, 0xAF4ABD3A, 0xAF373CF2, 0xAF23C02B, 0xAF10461F, 0xAEFCCF31, + 0xAEE95B63, 0xAED5EAB5, 0xAEC27D29, 0xAEAF12BE, 0xAE9BAB76, 0xAE884751, + 0xAE74E650, 0xAE618874, 0xAE4E2DBE, 0xAE3AD62D, 0xAE2781C4, 0xAE143083, + 0xAE00E26A, 0xADED977A, 0xADDA4FB5, 0xADC70B1A, 0xADB3C9AB, 0xADA08B68, + 0xAD8D5052, 0xAD7A186A, 0xAD66E3B0, 0xAD53B225, 0xAD4083CB, 0xAD2D58A1, + 0xAD1A310A, 0xAD070C43, 0xACF3EAB0, 0xACE0CC50, 0xACCDB124, 0xACBA992E, + 0xACA7846E, 0xAC9472E4, 0xAC816491, 0xAC6E5977, 0xAC5B5195, 0xAC484CED, + 0xAC354B7F, 0xAC224D4C, 0xAC0F5255, 0xABFC5A9A, 0xABE9661D, 0xABD674DD, + 0xABC386DC, 0xABB09C1A, 0xAB9DB499, 0xAB8AD058, 0xAB77EF59, 0xAB65119D, + 0xAB523723, 0xAB3F5FED, 0xAB2C8BFB, 0xAB19BBAF, 0xAB06EE48, 0xAAF42429, + 0xAAE15D50, 0xAACE99C0, 0xAABBD979, 0xAAA91C7B, 0xAA9662C7, 0xAA83AC5E, + 0xAA70F941, 0xAA5E4971, 0xAA4B9CEE, 0xAA38F3B8, 0xAA264DD1, 0xAA13AB3A, + 0xAA010BF2, 0xA9EE6FFB, 0xA9DBD756, 0xA9C94203, 0xA9B6B003, 0xA9A42156, + 0xA99195FE, 0xA97F0DFB, 0xA96C894D, 0xA95A07F6, 0xA94789F6, 0xA9350F4E, + 0xA92297FF, 0xA9102467, 0xA8FDB3CB, 0xA8EB468A, 0xA8D8DCA4, 0xA8C6761A, + 0xA8B412EE, 0xA8A1B31F, 0xA88F56AE, 0xA87CFD9C, 0xA86AA7EA, 0xA8585598, + 0xA84606A8, 0xA833BB19, 0xA82172ED, 0xA80F2E24, 0xA7FCECBF, 0xA7EAAEBE, + 0xA7D87423, 0xA7C63CEE, 0xA7B40920, 0xA7A1D8B9, 0xA78FABBB, 0xA77D8225, + 0xA76B5BF9, 0xA7593937, 0xA74719E0, 0xA734FDF4, 0xA722E5D2, 0xA710D0C0, + 0xA6FEBF1B, 0xA6ECB0E6, 0xA6DAA61F, 0xA6C89EC8, 0xA6B69AE2, 0xA6A49A6D, + 0xA6929D6A, 0xA680A3D9, 0xA66EADBC, 0xA65CBB13, 0xA64ACBDF, 0xA638E020, + 0xA626F7D7, 0xA6151304, 0xA60331AA, 0xA5F153C7, 0xA5DF795D, 0xA5CDA26D, + 0xA5BBCEF7, 0xA5A9FEFC, 0xA598327C, 0xA5866979, 0xA574A3F2, 0xA562E1EA, + 0xA551235F, 0xA53F6854, 0xA52DB122, 0xA51BFD17, 0xA50A4C8D, 0xA4F89F84, + 0xA4E6F5FE, 0xA4D54FFB, 0xA4C3AD7C, 0xA4B20E81, 0xA4A0730B, 0xA48EDB1B, + 0xA47D46B2, 0xA46BB5D0, 0xA45A2876, 0xA4489EA4, 0xA437185B, 0xA425959D, + 0xA4141669, 0xA4029AC0, 0xA3F122A3, 0xA3DFAE12, 0xA3CE3D0F, 0xA3BCCF9A, + 0xA3AB65B3, 0xA399FF5C, 0xA3889C95, 0xA3773D5E, 0xA365E1B8, 0xA35489FD, + 0xA343357C, 0xA331E48F, 0xA3209735, 0xA30F4D70, 0xA2FE0740, 0xA2ECC4A6, + 0xA2DB85A3, 0xA2CA4A37, 0xA2B91263, 0xA2A7DE27, 0xA296AD85, 0xA285807D, + 0xA274570F, 0xA263313D, 0xA2520F06, 0xA240F06D, 0xA22FD570, 0xA21EBE11, + 0xA20DAA51, 0xA1FC9A30, 0xA1EB8DAF, 0xA1DA84CF, 0xA1C97F90, 0xA1B87DF2, + 0xA1A77FF7, 0xA196859F, 0xA1858F42, 0xA1749C32, 0xA163ACC8, 0xA152C103, + 0xA141D8E5, 0xA130F46E, 0xA120139E, 0xA10F3677, 0xA0FE5CF9, 0xA0ED8725, + 0xA0DCB4FB, 0xA0CBE67C, 0xA0BB1BA8, 0xA0AA5481, 0xA0999107, 0xA088D13A, + 0xA078151C, 0xA0675CAC, 0xA056A7EC, 0xA045F6DC, 0xA035497D, 0xA0249FD0, + 0xA013F9D4, 0xA003578B, 0x9FF2B8F5, 0x9FE21E14, 0x9FD186E7, 0x9FC0F36F, + 0x9FB06402, 0x9F9FD7F7, 0x9F8F4FA3, 0x9F7ECB06, 0x9F6E4A23, 0x9F5DCCF8, + 0x9F4D5387, 0x9F3CDDD1, 0x9F2C6BD5, 0x9F1BFD95, 0x9F0B9312, 0x9EFB2C4B, + 0x9EEAC942, 0x9EDA69F7, 0x9ECA0E6B, 0x9EB9B69E, 0x9EA96291, 0x9E991245, + 0x9E88C5BB, 0x9E787CF2, 0x9E6837EC, 0x9E57F6A9, 0x9E47B92A, 0x9E377F70, + 0x9E27497A, 0x9E17174A, 0x9E06E8E1, 0x9DF6BE91, 0x9DE697B6, 0x9DD674A3, + 0x9DC65559, 0x9DB639D8, 0x9DA62222, 0x9D960E36, 0x9D85FE16, 0x9D75F1C1, + 0x9D65E939, 0x9D55E47F, 0x9D45E392, 0x9D35E673, 0x9D25ED23, 0x9D15F7A4, + 0x9D0605F4, 0x9CF61815, 0x9CE62E08, 0x9CD647CC, 0x9CC66564, 0x9CB686CF, + 0x9CA6AC0D, 0x9C96D521, 0x9C870209, 0x9C7732C7, 0x9C67675C, 0x9C579FC7, + 0x9C47DC0A, 0x9C381C76, 0x9C28606A, 0x9C18A837, 0x9C08F3DF, 0x9BF94361, + 0x9BE996BE, 0x9BD9EDF7, 0x9BCA490D, 0x9BBAA7FF, 0x9BAB0ACF, 0x9B9B717E, + 0x9B8BDC0B, 0x9B7C4A78, 0x9B6CBCC5, 0x9B5D32F2, 0x9B4DAD01, 0x9B3E2AF1, + 0x9B2EACC4, 0x9B1F327A, 0x9B0FBC14, 0x9B004992, 0x9AF0DAF4, 0x9AE1703C, + 0x9AD2096B, 0x9AC2A67F, 0x9AB3477B, 0x9AA3EC5F, 0x9A949579, 0x9A85422E, + 0x9A75F2CD, 0x9A66A755, 0x9A575FC9, 0x9A481C28, 0x9A38DC72, 0x9A29A0AA, + 0x9A1A68CE, 0x9A0B34E0, 0x99FC04E0, 0x99ECD8D0, 0x99DDB0AE, 0x99CE8C7D, + 0x99BF6C3C, 0x99B04FED, 0x99A1378F, 0x99922323, 0x998312AB, 0x99740626, + 0x9964FD95, 0x9955F8F9, 0x9946F852, 0x9937FBA1, 0x992902E6, 0x991A0E23, + 0x990B1D57, 0x98FC30CF, 0x98ED47F3, 0x98DE6311, 0x98CF8229, 0x98C0A53B, + 0x98B1CC49, 0x98A2F752, 0x98942657, 0x98855959, 0x98769058, 0x9867CB55, + 0x98590A50, 0x984A4D4B, 0x983B9445, 0x982CDF3F, 0x981E2E3A, 0x980F8136, + 0x9800D834, 0x97F23334, 0x97E39238, 0x97D4F53F, 0x97C65C4A, 0x97B7C759, + 0x97A9366E, 0x979AA989, 0x978C20AA, 0x977D9BD2, 0x976F1B02, 0x97609E83, + 0x975225C3, 0x9743B10C, 0x9735405F, 0x9726D3BC, 0x97186B24, 0x970A0697, + 0x96FBA617, 0x96ED49A2, 0x96DEF13B, 0x96D09CE1, 0x96C24C96, 0x96B40059, + 0x96A5B82B, 0x9697740E, 0x96893400, 0x967AF804, 0x966CC019, 0x965E8C40, + 0x96505C79, 0x964230C5, 0x96340926, 0x9625E59A, 0x9617C623, 0x9609AAC1, + 0x95FB9375, 0x95ED8040, 0x95DF7169, 0x95D16662, 0x95C35F72, 0x95B55C9C, + 0x95A75DDE, 0x9599633A, 0x958B6CB0, 0x957D7A41, 0x956F8BEC, 0x9561A1B4, + 0x9553BB98, 0x9545D999, 0x9537FBB7, 0x952A21F3, 0x951C4C4E, 0x950E7AC7, + 0x9500AD60, 0x94F2E419, 0x94E51EF3, 0x94D75DED, 0x94C9A10A, 0x94BBE848, + 0x94AE33A9, 0x94A0832D, 0x9492D6D5, 0x94852EA2, 0x94778A93, 0x9469EAA9, + 0x945C4F2B, 0x944EB78D, 0x94412416, 0x943394C7, 0x942609A0, 0x941882A1, + 0x940AFFCB, 0x93FD811F, 0x93F0069D, 0x93E29045, 0x93D51E18, 0x93C7B017, + 0x93BA4642, 0x93ACE09A, 0x939F7F1E, 0x939221D1, 0x9384C8B1, 0x937773C0, + 0x936A22FF, 0x935CD66D, 0x934F8E0B, 0x934249DA, 0x933509DA, 0x9327CE0C, + 0x931A9671, 0x930D6308, 0x930033D2, 0x92F308D0, 0x92E5E202, 0x92D8BF69, + 0x92CBA106, 0x92BE86D8, 0x92B170E1, 0x92A45F20, 0x92975197, 0x928A4846, + 0x927D432D, 0x9270424C, 0x926345A5, 0x92564D38, 0x92495906, 0x923C6991, + 0x922F7DD5, 0x92229654, 0x9215B30F, 0x9208D407, 0x91FBF93D, 0x91EF22B0, + 0x91E25062, 0x91D58252, 0x91C8B882, 0x91BBF2F2, 0x91AF31A2, 0x91A27492, + 0x9195BBC4, 0x91890738, 0x917C56EE, 0x916FAAE7, 0x91630323, 0x91565FA2, + 0x9149C066, 0x913D256E, 0x91308EBC, 0x9123FC50, 0x91176E29, 0x910AE449, + 0x90FE5EB0, 0x90F1DD5F, 0x90E56056, 0x90D8E796, 0x90CC731E, 0x90C002F0, + 0x90B3970C, 0x90A72F73, 0x909ACC24, 0x908E6D21, 0x9082126A, 0x9075BBFF, + 0x906969E1, 0x905D1C10, 0x9050D28E, 0x90448D59, 0x90384C73, 0x902C0FDD, + 0x901FD796, 0x9013A39F, 0x900773F9, 0x8FFB48A4, 0x8FEF21A1, 0x8FE2FEF0, + 0x8FD6E091, 0x8FCAC685, 0x8FBEB0CD, 0x8FB29F69, 0x8FA69259, 0x8F9A899E, + 0x8F8E85B2, 0x8F8285A2, 0x8F7689E8, 0x8F6A9285, 0x8F5E9F78, 0x8F52B0C4, + 0x8F46C668, 0x8F3AE064, 0x8F2EFEB9, 0x8F232167, 0x8F174870, 0x8F0B73D3, + 0x8EFFA391, 0x8EF3D7AA, 0x8EE8101E, 0x8EDC4CEF, 0x8ED08E1D, 0x8EC4D3A8, + 0x8EB91D90, 0x8EAD6BD6, 0x8EA1BE7B, 0x8E96157E, 0x8E8A70E1, 0x8E7ED0A4, + 0x8E7334C7, 0x8E679D4B, 0x8E5C0A30, 0x8E507B76, 0x8E44F11F, 0x8E396B2A, + 0x8E2DE997, 0x8E226C69, 0x8E16F39E, 0x8E0B7F37, 0x8E000F35, 0x8DF4A398, + 0x8DE93C61, 0x8DDDD990, 0x8DD27B25, 0x8DC72121, 0x8DBBCB85, 0x8DB07A50, + 0x8DA52D83, 0x8D99E520, 0x8D8EA125, 0x8D836193, 0x8D78266C, 0x8D6CEFAF, + 0x8D61BD5D, 0x8D568F76, 0x8D4B65FB, 0x8D4040EB, 0x8D352049, 0x8D2A0413, + 0x8D1EECBC, 0x8D13D961, 0x8D08CA75, 0x8CFDBFF7, 0x8CF2B9E8, 0x8CE7B849, + 0x8CDCBB1A, 0x8CD1C25B, 0x8CC6CE0D, 0x8CBBDE31, 0x8CB0F2C6, 0x8CA60BCC, + 0x8C9B2946, 0x8C904B32, 0x8C857192, 0x8C7A9C65, 0x8C6FCBAD, 0x8C64FF69, + 0x8C5A379A, 0x8C4F7440, 0x8C44B55D, 0x8C39FAEF, 0x8C2F44F8, 0x8C249378, + 0x8C19E670, 0x8C0F3DE0, 0x8C0499C8, 0x8BF9FA28, 0x8BEF5F02, 0x8BE4C855, + 0x8BDA3622, 0x8BCFA86A, 0x8BC51F2C, 0x8BBA9A69, 0x8BB01A22, 0x8BA59E57, + 0x8B9B2708, 0x8B90B436, 0x8B8645E2, 0x8B7BDC0A, 0x8B7176B1, 0x8B6715D6, + 0x8B5CB97A, 0x8B52619D, 0x8B480E40, 0x8B3DBF62, 0x8B337505, 0x8B292F29, + 0x8B1EEDCE, 0x8B14B0F4, 0x8B0A789D, 0x8B0044C8, 0x8AF61575, 0x8AEBEAA6, + 0x8AE1C45A, 0x8AD7A2F9, 0x8ACD85B5, 0x8AC36CF6, 0x8AB958BC, 0x8AAF4908, + 0x8AA53DD9, 0x8A9B3731, 0x8A91350F, 0x8A873774, 0x8A7D3E61, 0x8A7349D5, + 0x8A6959D2, 0x8A5F6E57, 0x8A558765, 0x8A4BA4FC, 0x8A41C71E, 0x8A37EDC9, + 0x8A2E18FE, 0x8A2448BF, 0x8A1A7D0B, 0x8A10B5E2, 0x8A06F345, 0x89FD3535, + 0x89F37BB1, 0x89E9C6BB, 0x89E01652, 0x89D66A77, 0x89CCC32A, 0x89C3206B, + 0x89B9823C, 0x89AFE89C, 0x89A6538C, 0x899CC30B, 0x8993371B, 0x8989AFBC, + 0x89802CEF, 0x8976AEB2, 0x896D3508, 0x8963BFF0, 0x895A4F6A, 0x8950E378, + 0x89477C19, 0x893E194E, 0x8934BB16, 0x892B6174, 0x89220C66, 0x8918BBED, + 0x890F700A, 0x890628BC, 0x88FCE605, 0x88F3A7E5, 0x88EA6E5B, 0x88E13969, + 0x88D8090E, 0x88CEDD4C, 0x88C5B67F, 0x88BC93ED, 0x88B375F5, 0x88AA5C96, + 0x88A147D1, 0x889837A5, 0x888F2C15, 0x8886251F, 0x887D22C5, 0x88742505, + 0x886B2BE2, 0x8862375B, 0x88594771, 0x88505C24, 0x88477573, 0x883E9361, + 0x8835B5EC, 0x882CDD16, 0x882408DE, 0x881B3945, 0x88126E4C, 0x8809A7F2, + 0x8800E638, 0x87F8291F, 0x87EF70A6, 0x87E6BCCE, 0x87DE0D98, 0x87D56303, + 0x87CCBD10, 0x87C41BC0, 0x87BB7F12, 0x87B2E707, 0x87AA539F, 0x87A1C4DC, + 0x87993ABC, 0x8790B540, 0x87883469, 0x877FB837, 0x877740AB, 0x876ECDC4, + 0x87665F83, 0x875DF5E8, 0x875590F4, 0x874D30A7, 0x8744D501, 0x873C7E03, + 0x87342BAC, 0x872BDDFE, 0x872394F8, 0x871B509C, 0x871310E8, 0x870AD5DE, + 0x87029F7D, 0x86FA6DC7, 0x86F240BB, 0x86EA18AD, 0x86E1F4F7, 0x86D9D5EC, + 0x86D1BB8D, 0x86C9A5DA, 0x86C194D4, 0x86B9887A, 0x86B180CC, 0x86A97DCD, + 0x86A17F7A, 0x869985D6, 0x869190E0, 0x8689A098, 0x8681B4FF, 0x8679CE15, + 0x8671EBDB, 0x866A0E50, 0x86623575, 0x865A614B, 0x865291D1, 0x864AC708, + 0x864300F0, 0x863B3F8A, 0x863382D5, 0x862BCAD3, 0x86241783, 0x861C68E6, + 0x8614BEFC, 0x860D19C5, 0x86057942, 0x85FDDD73, 0x85F64657, 0x85EEB3F1, + 0x85E7263F, 0x85DF9D42, 0x85D818FA, 0x85D09968, 0x85C91E8C, 0x85C1A867, + 0x85BA36F7, 0x85B2CA3F, 0x85AB623E, 0x85A3FEF4, 0x859CA061, 0x85954687, + 0x858DF164, 0x8586A0FB, 0x857F554A, 0x85780E52, 0x8570CC13, 0x85698E8E, + 0x856255C3, 0x855B21B2, 0x8553F25C, 0x854CC7C0, 0x8545A228, 0x853E8103, + 0x85376499, 0x85304CEA, 0x852939F8, 0x85222BC3, 0x851B224A, 0x85141D8D, + 0x850D1D8E, 0x8506224D, 0x84FF2BC9, 0x84F83A03, 0x84F14CFC, 0x84EA64B3, + 0x84E38129, 0x84DCA25E, 0x84D5C852, 0x84CEF306, 0x84C8227A, 0x84C156AD, + 0x84BA8FA2, 0x84B3CD57, 0x84AD0FCC, 0x84A65703, 0x849FA2FC, 0x8498F3B6, + 0x84924932, 0x848BA370, 0x84850270, 0x847E6634, 0x8477CEBA, 0x84713C04, + 0x846AAE11, 0x846424E1, 0x845DA076, 0x845720CF, 0x8450A5EC, 0x844A2FCE, + 0x8443BE75, 0x843D51E2, 0x8436EA14, 0x8430870B, 0x842A28C9, 0x8423CF4C, + 0x841D7A97, 0x84172AA7, 0x8410DF7F, 0x840A991E, 0x84045785, 0x83FE1AB3, + 0x83F7E2A9, 0x83F1AF67, 0x83EB80ED, 0x83E5573D, 0x83DF3293, 0x83D91274, + 0x83D2F71E, 0x83CCE092, 0x83C6CED0, 0x83C0C1D8, 0x83BAB9AA, 0x83B4B646, + 0x83AEB7AD, 0x83A8BDE0, 0x83A2C8DD, 0x839CD8A6, 0x8396ED3A, 0x8391069B, + 0x838B24C7, 0x838547C0, 0x837F6F86, 0x83799C18, 0x8373CD77, 0x836E03A4, + 0x83683E9D, 0x83627E65, 0x835CC2FB, 0x83570C5E, 0x83515A90, 0x834BAD91, + 0x83460560, 0x834061FF, 0x833AC36C, 0x833529A9, 0x832F94B6, 0x832A0493, + 0x8324793F, 0x831EF2BC, 0x8319710A, 0x8313F428, 0x830E7C17, 0x830908D8, + 0x83039A69, 0x82FE30CD, 0x82F8CC02, 0x82F36C09, 0x82EE10E2, 0x82E8BA8D, + 0x82E3690C, 0x82DE1C5D, 0x82D8D481, 0x82D39178, 0x82CE5343, 0x82C919E1, + 0x82C3E553, 0x82BEB599, 0x82B98AB3, 0x82B464A2, 0x82AF4366, 0x82AA2732, + 0x82A50F9F, 0x829FFCE1, 0x829AEEF9, 0x8295E5E6, 0x8290E1A9, 0x828BE242, + 0x8286E7B1, 0x8281F1F7, 0x827D0113, 0x82781506, 0x82732DD0, 0x826E4B71, + 0x82696DEA, 0x82649539, 0x825FC161, 0x825AF260, 0x82562838, 0x825162E8, + 0x824CA270, 0x8247E6D1, 0x8243300A, 0x823E7E1D, 0x8239D109, 0x823528CE, + 0x8230856D, 0x822BE6E5, 0x82274D37, 0x8222B864, 0x821E286A, 0x82199D4B, + 0x82151707, 0x8210959D, 0x820C190F, 0x8207A15B, 0x82032E83, 0x81FEC086, + 0x81FA5764, 0x81F5F31F, 0x81F193B6, 0x81ED3928, 0x81E8E377, 0x81E492A3, + 0x81E046AB, 0x81DBFF8F, 0x81D7BD51, 0x81D37FF0, 0x81CF476C, 0x81CB13C6, + 0x81C6E4FD, 0x81C2BB13, 0x81BE9606, 0x81BA75D7, 0x81B65A86, 0x81B24414, + 0x81AE32AA, 0x81AA25F5, 0x81A61E1E, 0x81A21B27, 0x819E1D0F, 0x819A23D7, + 0x81962F7D, 0x81924004, 0x818E556A, 0x818A6FB1, 0x81868ED7, 0x8182B2DE, + 0x817EDBC5, 0x817B098D, 0x81773C35, 0x817373BE, 0x816FB028, 0x816BF174, + 0x816837A0, 0x816482AE, 0x8160D29E, 0x815D276F, 0x81598123, 0x8155DFB8, + 0x8152432F, 0x814EAB89, 0x814B18C5, 0x81478AE3, 0x814401E5, 0x81407DC9, + 0x813CFE90, 0x8139843A, 0x81360EC7, 0x81329E38, 0x812F328C, 0x812BCBC4, + 0x812869E0, 0x81250CDF, 0x8121B4C3, 0x811E618A, 0x811B1336, 0x8117C9C7, + 0x8114853B, 0x81114595, 0x810E0AD3, 0x810AD4F6, 0x8107A3FF, 0x810477EC, + 0x810150BF, 0x80FE2E77, 0x80FB1114, 0x80F7F898, 0x80F4E501, 0x80F1D650, + 0x80EECC84, 0x80EBC7BE, 0x80E8C7BF, 0x80E5CCA6, 0x80E2D674, 0x80DFE528, + 0x80DCF8C3, 0x80DA1145, 0x80D72EAE, 0x80D450FE, 0x80D17835, 0x80CEA453, + 0x80CBD558, 0x80C90B45, 0x80C6461A, 0x80C385D6, 0x80C0CA7A, 0x80BE1406, + 0x80BB627A, 0x80B8B5D6, 0x80B60E1A, 0x80B36B46, 0x80B0CD5B, 0x80AE3458, + 0x80ABA03E, 0x80A9110D, 0x80A686C4, 0x80A40165, 0x80A180EE, 0x809F0560, + 0x809C8EBC, 0x809A1D01, 0x8097B02F, 0x80954847, 0x8092E548, 0x80908733, + 0x808E2E08, 0x808BD9C6, 0x80898A6F, 0x80874001, 0x8084FA7D, 0x8082B9E4, + 0x80807E35, 0x807E4771, 0x807C1596, 0x8079E8A7, 0x8077C0A2, 0x80759D87, + 0x80737F58, 0x80716613, 0x806F51B9, 0x806D424B, 0x806B37C7, 0x8069322F, + 0x80673182, 0x806535C0, 0x80633EFD, 0x80614D12, 0x805F6013, 0x805D77FF, + 0x805B94D6, 0x8059B69A, 0x8057DD49, 0x805608E5, 0x8054396C, 0x80526EE0, + 0x8050A93F, 0x804EE88B, 0x804D2CC3, 0x804B75E7, 0x8049C3F8, 0x804816F6, + 0x80466EDF, 0x8044CBB6, 0x80432D79, 0x80419429, 0x803FFFC5, 0x803E704F, + 0x803CE5C5, 0x803B6028, 0x8039DF79, 0x803863B6, 0x8036ECE1, 0x80357AF8, + 0x80340DFE, 0x8032A5F0, 0x803142D0, 0x802FE49D, 0x802E8B57, 0x802D36FF, + 0x802BE795, 0x802A9D18, 0x80295789, 0x802816E8, 0x8026DB35, 0x8025A46F, + 0x80247297, 0x802345AD, 0x80221DB1, 0x8020FAA3, 0x801FDC83, 0x801EC351, + 0x801DAF0E, 0x801C9FB8, 0x801B9551, 0x801A8FD8, 0x80198F4D, 0x801893B1, + 0x80179D02, 0x8016AB43, 0x8015BE7B, 0x8014D698, 0x8013F3A4, 0x8013159E, + 0x80123C86, 0x8011685E, 0x80109924, 0x800FCED8, 0x800F097C, 0x800E490E, + 0x800D8D8E, 0x800CD6FE, 0x800C255D, 0x800B78AA, 0x800AD0E6, 0x800A2E11, + 0x8009902B, 0x8008F734, 0x8008632C, 0x8007D413, 0x800749E9, 0x8006C4AE, + 0x80064462, 0x8005C905, 0x80055297, 0x8004E118, 0x80047489, 0x80040CE8, + 0x8003AA37, 0x80034C75, 0x8002F3A2, 0x80029FBE, 0x800250CA, 0x800206C5, + 0x8001C1AF, 0x80018188, 0x80014650, 0x80011008, 0x8000DEAF, 0x8000B246, + 0x80008ACB, 0x80006840, 0x80004AA4, 0x800031F8, 0x80001E3B, 0x80000F6D, + 0x8000058E, 0x8000009F +}; + +const int32_t sine_1024[] = { + 0xFFE6DE06, 0xFFB49A13, 0xFF82562D, 0xFF501259, 0xFF1DCEA1, 0xFEEB8B0C, + 0xFEB947A0, 0xFE870468, 0xFE54C16A, 0xFE227EAD, 0xFDF03C3D, 0xFDBDFA1A, + 0xFD8BB850, 0xFD5976EC, 0xFD2735EC, 0xFCF4F55C, 0xFCC2B548, 0xFC9075B1, + 0xFC5E36A1, 0xFC2BF824, 0xFBF9BA3B, 0xFBC77CF0, 0xFB95404C, 0xFB630456, + 0xFB30C91F, 0xFAFE8E9D, 0xFACC54E1, 0xFA9A1BF3, 0xFA67E3D9, 0xFA35AC9C, + 0xFA03764C, 0xF9D140E1, 0xF99F0C69, 0xF96CD8ED, 0xF93AA675, 0xF9087508, + 0xF8D644B6, 0xF8A41577, 0xF871E75A, 0xF83FBA68, 0xF80D8EA7, 0xF7DB6421, + 0xF7A93AE4, 0xF77712E0, 0xF744EC3D, 0xF712C6F2, 0xF6E0A2F8, 0xF6AE8077, + 0xF67C5F55, 0xF64A3FBA, 0xF618218F, 0xF5E604FC, 0xF5B3E9F6, 0xF581D078, + 0xF54FB8A7, 0xF51DA26D, 0xF4EB8DF0, 0xF4B97B29, 0xF4876A0F, 0xF4555ACA, + 0xF4234D41, 0xF3F1419D, 0xF3BF37C4, 0xF38D2FE0, 0xF35B29E6, 0xF32925D0, + 0xF2F723C5, 0xF2C523AD, 0xF29325AE, 0xF26129C2, 0xF22F2FDF, 0xF1FD382E, + 0xF1CB4296, 0xF1994F3F, 0xF1675E10, 0xF1356F32, 0xF103829B, 0xF0D19845, + 0xF09FB055, 0xF06DCAB5, 0xF03BE78B, 0xF00A06CF, 0xEFD8287A, 0xEFA64CA3, + 0xEF747371, 0xEF429CAC, 0xEF10C87C, 0xEEDEF709, 0xEEAD2819, 0xEE7B5BD6, + 0xEE499247, 0xEE17CB92, 0xEDE60781, 0xEDB4463A, 0xED8287E5, 0xED50CC4B, + 0xED1F1392, 0xECED5DC2, 0xECBBAB03, 0xEC89FB1D, 0xEC584E38, 0xEC26A47A, + 0xEBF4FDAC, 0xEBC359F5, 0xEB91B97C, 0xEB601C0B, 0xEB2E81C8, 0xEAFCEABB, + 0xEACB570B, 0xEA99C680, 0xEA683942, 0xEA36AF79, 0xEA0528EB, 0xE9D3A5C2, + 0xE9A22604, 0xE970A9D8, 0xE93F3108, 0xE90DBBBA, 0xE8DC4A15, 0xE8AADBE2, + 0xE8797148, 0xE8480A50, 0xE816A71F, 0xE7E5477E, 0xE7B3EB95, 0xE782938B, + 0xE7513F28, 0xE71FEE94, 0xE6EEA1F4, 0xE6BD5914, 0xE68C1418, 0xE65AD30A, + 0xE629960F, 0xE5F85CF0, 0xE5C727D6, 0xE595F6E6, 0xE564C9E9, 0xE533A107, + 0xE5027C47, 0xE4D15BCF, 0xE4A03F6A, 0xE46F273D, 0xE43E136F, 0xE40D03CA, + 0xE3DBF875, 0xE3AAF177, 0xE379EEF6, 0xE348F0BC, 0xE317F6F0, 0xE2E701B8, + 0xE2B610DD, 0xE2852487, 0xE2543CDC, 0xE22359A5, 0xE1F27B09, 0xE1C1A110, + 0xE190CBDF, 0xE15FFB41, 0xE12F2F5C, 0xE0FE6857, 0xE0CDA5FA, 0xE09CE86D, + 0xE06C2FB8, 0xE03B7C00, 0xE00ACD0F, 0xDFDA230B, 0xDFA97DFD, 0xDF78DDEC, + 0xDF48431C, 0xDF17AD1B, 0xDEE71C2C, 0xDEB69058, 0xDE8609A7, 0xDE55881E, + 0xDE250BC7, 0xDDF494E6, 0xDDC42308, 0xDD93B671, 0xDD634F29, 0xDD32ED37, + 0xDD0290A4, 0xDCD23975, 0xDCA1E7F1, 0xDC719BA4, 0xDC4154D2, 0xDC111384, + 0xDBE0D7C0, 0xDBB0A18E, 0xDB807133, 0xDB50463C, 0xDB2020ED, 0xDAF0014D, + 0xDABFE765, 0xDA8FD33B, 0xDA5FC4D8, 0xDA2FBC7F, 0xD9FFB9BD, 0xD9CFBCD8, + 0xD99FC5D7, 0xD96FD4C0, 0xD93FE99C, 0xD9100472, 0xD8E02586, 0xD8B04C65, + 0xD8807955, 0xD850AC5C, 0xD820E581, 0xD7F124CD, 0xD7C16A46, 0xD791B630, + 0xD762081A, 0xD7326047, 0xD702BEC0, 0xD6D3238A, 0xD6A38EAE, 0xD6740033, + 0xD644785D, 0xD614F6B9, 0xD5E57B8D, 0xD5B606DE, 0xD58698B6, 0xD557311A, + 0xD527D012, 0xD4F875E2, 0xD4C92218, 0xD499D4F8, 0xD46A8E8A, 0xD43B4ED4, + 0xD40C15DE, 0xD3DCE3B0, 0xD3ADB88C, 0xD37E9401, 0xD34F7654, 0xD3205F8B, + 0xD2F14FAD, 0xD2C246C3, 0xD293450E, 0xD2644A1E, 0xD2355638, 0xD2066961, + 0xD1D783A0, 0xD1A8A4FF, 0xD179CD82, 0xD14AFD6E, 0xD11C3453, 0xD0ED7272, + 0xD0BEB7D4, 0xD090047F, 0xD061587C, 0xD032B3D0, 0xD00416BE, 0xCFD580D8, + 0xCFA6F25F, 0xCF786B5B, 0xCF49EBD2, 0xCF1B73CD, 0xCEED0352, 0xCEBE9AA4, + 0xCE903952, 0xCE61DFA1, 0xCE338D96, 0xCE05433A, 0xCDD70092, 0xCDA8C5A7, + 0xCD7A92BA, 0xCD4C675C, 0xCD1E43D1, 0xCCF0281E, 0xCCC2144A, 0xCC94085E, + 0xCC660460, 0xCC380891, 0xCC0A1485, 0xCBDC287B, 0xCBAE447C, 0xCB80688F, + 0xCB5294BA, 0xCB24C93F, 0xCAF705B0, 0xCAC94A4F, 0xCA9B9723, 0xCA6DEC32, + 0xCA404985, 0xCA12AF21, 0xC9E51D49, 0xC9B7938E, 0xC98A1233, 0xC95C993D, + 0xC92F28B5, 0xC901C0A0, 0xC8D46107, 0xC8A70A2A, 0xC879BB9B, 0xC84C759D, + 0xC81F3836, 0xC7F2036C, 0xC7C4D748, 0xC797B3D0, 0xC76A9944, 0xC73D8738, + 0xC7107DED, 0xC6E37D6A, 0xC6B685B5, 0xC68996D6, 0xC65CB0D4, 0xC62FD3EE, + 0xC602FFBA, 0xC5D63477, 0xC5A9722C, 0xC57CB8E0, 0xC550089A, 0xC5236161, + 0xC4F6C374, 0xC4CA2E6A, 0xC49DA281, 0xC4711FC0, 0xC444A62F, 0xC41835D3, + 0xC3EBCEB5, 0xC3BF7113, 0xC3931C83, 0xC366D145, 0xC33A8F5F, 0xC30E56D8, + 0xC2E227B7, 0xC2B6023C, 0xC289E5FB, 0xC25DD335, 0xC231C9F0, 0xC205CA33, + 0xC1D9D405, 0xC1ADE76D, 0xC1820471, 0xC1562B18, 0xC12A5B68, 0xC0FE956A, + 0xC0D2D992, 0xC0A72709, 0xC07B7E45, 0xC04FDF4C, 0xC0244A25, 0xBFF8BED8, + 0xBFCD3D6A, 0xBFA1C5E3, 0xBF765849, 0xBF4AF4A3, 0xBF1F9AF7, 0xBEF44B4D, + 0xBEC905AB, 0xBE9DCA85, 0xBE729906, 0xBE4771A3, 0xBE1C5463, 0xBDF1414C, + 0xBDC63865, 0xBD9B39B4, 0xBD704541, 0xBD455B11, 0xBD1A7B2C, 0xBCEFA597, + 0xBCC4DA5B, 0xBC9A197C, 0xBC6F6302, 0xBC44B760, 0xBC1A15C4, 0xBBEF7EA0, + 0xBBC4F1FB, 0xBB9A6FDB, 0xBB6FF848, 0xBB458B48, 0xBB1B28E1, 0xBAF0D11A, + 0xBAC683F9, 0xBA9C4185, 0xBA7209C4, 0xBA47DCBE, 0xBA1DBA78, 0xB9F3A363, + 0xB9C996B1, 0xB99F94D3, 0xB9759DD0, 0xB94BB1AD, 0xB921D071, 0xB8F7FA23, + 0xB8CE2ECA, 0xB8A46E6B, 0xB87AB90D, 0xB8510EB7, 0xB8276F6E, 0xB7FDDB3B, + 0xB7D45221, 0xB7AAD493, 0xB78161C3, 0xB757FA20, 0xB72E9DB2, 0xB7054C7F, + 0xB6DC068C, 0xB6B2CBE2, 0xB6899C85, 0xB660787C, 0xB6375FCE, 0xB60E5281, + 0xB5E5509B, 0xB5BC5A22, 0xB5936F86, 0xB56A8FFB, 0xB541BBF1, 0xB518F36D, + 0xB4F03677, 0xB4C78514, 0xB49EDF4B, 0xB4764521, 0xB44DB69E, 0xB42533C7, + 0xB3FCBCA2, 0xB3D45137, 0xB3ABF18B, 0xB3839DA3, 0xB35B55EF, 0xB33319A5, + 0xB30AE933, 0xB2E2C49F, 0xB2BAABF0, 0xB2929F2B, 0xB26A9E57, 0xB242A97A, + 0xB21AC09A, 0xB1F2E3BD, 0xB1CB12E9, 0xB1A34E25, 0xB17B9577, 0xB153E8E4, + 0xB12C48D8, 0xB104B48F, 0xB0DD2C75, 0xB0B5B08E, 0xB08E40E1, 0xB066DD75, + 0xB03F8650, 0xB0183B77, 0xAFF0FCF0, 0xAFC9CAC2, 0xAFA2A4F3, 0xAF7B8B88, + 0xAF547E88, 0xAF2D7E5C, 0xAF068A44, 0xAEDFA2A8, 0xAEB8C78F, 0xAE91F8FF, + 0xAE6B36FD, 0xAE448191, 0xAE1DD8BE, 0xADF73C8D, 0xADD0AD02, 0xADAA2A24, + 0xAD83B3F8, 0xAD5D4A85, 0xAD36EDCF, 0xAD109E40, 0xACEA5B19, 0xACC424C3, + 0xAC9DFB42, 0xAC77DE9D, 0xAC51CEDA, 0xAC2BCBFE, 0xAC05D610, 0xABDFED15, + 0xABBA1113, 0xAB944211, 0xAB6E8013, 0xAB48CB1F, 0xAB23233D, 0xAAFD88D0, + 0xAAD7FB1F, 0xAAB27A90, 0xAA8D0729, 0xAA67A0F0, 0xAA4247E9, 0xAA1CFC1B, + 0xA9F7BD8D, 0xA9D28C42, 0xA9AD6842, 0xA9885191, 0xA9634837, 0xA93E4C37, + 0xA9195DF7, 0xA8F47CBF, 0xA8CFA8F4, 0xA8AAE29A, 0xA88629B9, 0xA8617E55, + 0xA83CE074, 0xA818501C, 0xA7F3CD52, 0xA7CF581C, 0xA7AAF080, 0xA7869682, + 0xA7624A2A, 0xA73E0B7D, 0xA719DADB, 0xA6F5B793, 0xA6D1A206, 0xA6AD9A39, + 0xA689A033, 0xA665B3F9, 0xA641D590, 0xA61E04FF, 0xA5FA4249, 0xA5D68D76, + 0xA5B2E68A, 0xA58F4D8B, 0xA56BC27E, 0xA548456A, 0xA524D6AD, 0xA5017598, + 0xA4DE228C, 0xA4BADD8E, 0xA497A6A3, 0xA4747DD0, 0xA451631C, 0xA42E568B, + 0xA40B5823, 0xA3E867E9, 0xA3C585E3, 0xA3A2B216, 0xA37FEC87, 0xA35D353C, + 0xA33A8C93, 0xA317F1E0, 0xA2F56580, 0xA2D2E77A, 0xA2B077D2, 0xA28E168E, + 0xA26BC3B3, 0xA2497F46, 0xA227494D, 0xA20521CD, 0xA1E308CB, 0xA1C0FE4D, + 0xA19F0257, 0xA17D1545, 0xA15B3671, 0xA1396634, 0xA117A496, 0xA0F5F19A, + 0xA0D44D46, 0xA0B2B79F, 0xA09130AB, 0xA06FB86E, 0xA04E4EEE, 0xA02CF430, + 0xA00BA839, 0x9FEA6B0E, 0x9FC93CB4, 0x9FA81D85, 0x9F870CDE, 0x9F660B16, + 0x9F451835, 0x9F24343E, 0x9F035F37, 0x9EE29925, 0x9EC1E20C, 0x9EA139F3, + 0x9E80A0DE, 0x9E6016D2, 0x9E3F9BD4, 0x9E1F2FE9, 0x9DFED317, 0x9DDE85B3, + 0x9DBE471F, 0x9D9E17B3, 0x9D7DF772, 0x9D5DE662, 0x9D3DE489, 0x9D1DF1EA, + 0x9CFE0E8A, 0x9CDE3A70, 0x9CBE759F, 0x9C9EC01C, 0x9C7F19ED, 0x9C5F8316, + 0x9C3FFBED, 0x9C2083D5, 0x9C011B24, 0x9BE1C1DF, 0x9BC2780A, 0x9BA33DAB, + 0x9B8412C6, 0x9B64F75F, 0x9B45EB7D, 0x9B26EF23, 0x9B080256, 0x9AE9251C, + 0x9ACA5778, 0x9AAB9970, 0x9A8CEB57, 0x9A6E4C94, 0x9A4FBD7B, 0x9A313E10, + 0x9A12CE59, 0x99F46E5A, 0x99D61E17, 0x99B7DD96, 0x9999ACDB, 0x997B8BEA, + 0x995D7AC8, 0x993F797B, 0x99218806, 0x9903A66D, 0x98E5D503, 0x98C81333, + 0x98AA614E, 0x988CBF58, 0x986F2D56, 0x9851AB4D, 0x98343942, 0x9816D738, + 0x97F98534, 0x97DC433B, 0x97BF1151, 0x97A1EF7B, 0x9784DDBD, 0x9767DC66, + 0x974AEAE6, 0x972E098C, 0x9711385C, 0x96F4775B, 0x96D7C68C, 0x96BB25F6, + 0x969E959B, 0x96821580, 0x9665A5AA, 0x9649461D, 0x962CF6DD, 0x9610B7EF, + 0x95F48958, 0x95D86B62, 0x95BC5D84, 0x95A06009, 0x958472F5, 0x9568964D, + 0x954CCA15, 0x95310E51, 0x95156307, 0x94F9C839, 0x94DE3DEC, 0x94C2C424, + 0x94A75AE7, 0x948C0237, 0x9470BA19, 0x945582D7, 0x943A5BEA, 0x941F459B, + 0x94043FF0, 0x93E94AEB, 0x93CE6692, 0x93B392E8, 0x9398CFF2, 0x937E1DB3, + 0x93637C30, 0x9348EB6C, 0x932E6B6D, 0x9313FC36, 0x92F99DCA, 0x92DF502F, + 0x92C51368, 0x92AAE77A, 0x9290CC67, 0x9276C235, 0x925CC8E8, 0x9242E106, + 0x9229098D, 0x920F4304, 0x91F58D6F, 0x91DBE8D2, 0x91C25532, 0x91A8D292, + 0x918F60F6, 0x91760062, 0x915CB0DA, 0x91437262, 0x912A44FD, 0x911128B0, + 0x90F81D7F, 0x90DF236D, 0x90C63A7E, 0x90AD62B6, 0x90949C19, 0x907BE6AB, + 0x9063426F, 0x904AAF69, 0x90322D9E, 0x9019BD11, 0x90015DC5, 0x8FE90FBE, + 0x8FD0D301, 0x8FB8A790, 0x8FA08D71, 0x8F88851F, 0x8F708DAB, 0x8F58A793, + 0x8F40D2DB, 0x8F290F85, 0x8F115D96, 0x8EF9BD12, 0x8EE22DFB, 0x8ECAB057, + 0x8EB34427, 0x8E9BE971, 0x8E84A037, 0x8E6D687D, 0x8E564247, 0x8E3F2D98, + 0x8E282A74, 0x8E1138DE, 0x8DFA58DA, 0x8DE38A6C, 0x8DCCCD96, 0x8DB6225D, + 0x8D9F88C4, 0x8D8900CF, 0x8D728A80, 0x8D5C25DC, 0x8D45D2E6, 0x8D2F91A0, + 0x8D196281, 0x8D0344A8, 0x8CED388B, 0x8CD73E2D, 0x8CC15591, 0x8CAB7EBB, + 0x8C95B9AE, 0x8C80066D, 0x8C6A64FC, 0x8C54D55E, 0x8C3F5797, 0x8C29EBA9, + 0x8C149199, 0x8BFF4969, 0x8BEA131C, 0x8BD4EEB7, 0x8BBFDC3B, 0x8BAADBAD, + 0x8B95ED10, 0x8B811066, 0x8B6C45B4, 0x8B578CFC, 0x8B42E641, 0x8B2E5187, + 0x8B19CED1, 0x8B055E22, 0x8AF0FF7D, 0x8ADCB2E5, 0x8AC878C5, 0x8AB45051, + 0x8AA039F4, 0x8A8C35B1, 0x8A78438A, 0x8A646383, 0x8A50959F, 0x8A3CD9E2, + 0x8A29304D, 0x8A1598E5, 0x8A0213AC, 0x89EEA0A4, 0x89DB3FD2, 0x89C7F139, + 0x89B4B4DA, 0x89A18AB9, 0x898E72DA, 0x897B6D3E, 0x896879EA, 0x895598DF, + 0x8942CA21, 0x89300DB2, 0x891D6397, 0x890ACBD0, 0x88F84662, 0x88E5D34F, + 0x88D3729A, 0x88C124A3, 0x88AEE8B2, 0x889CBF28, 0x888AA807, 0x8878A352, + 0x8866B10B, 0x8854D137, 0x884303D6, 0x883148ED, 0x881FA07E, 0x880E0A8B, + 0x87FC8717, 0x87EB1626, 0x87D9B7B9, 0x87C86BD3, 0x87B73278, 0x87A60BA9, + 0x8794F769, 0x8783F5BC, 0x877306A3, 0x87622A21, 0x87516039, 0x8740A8ED, + 0x87300440, 0x871F7235, 0x870EF2CE, 0x86FE860D, 0x86EE2C49, 0x86DDE4DC, + 0x86CDB01E, 0x86BD8E11, 0x86AD7EB7, 0x869D8212, 0x868D9826, 0x867DC0F4, + 0x866DFC7F, 0x865E4ACA, 0x864EABD6, 0x863F1FA7, 0x862FA63E, 0x86203F9E, + 0x8610EBCA, 0x8601AAC4, 0x85F27C8E, 0x85E3612A, 0x85D4589B, 0x85C562E3, + 0x85B68004, 0x85A7B002, 0x8598F2DD, 0x858A4899, 0x857BB137, 0x856D2CBA, + 0x855EBB24, 0x85505C77, 0x854210FE, 0x8533D82A, 0x8525B246, 0x85179F54, + 0x85099F56, 0x84FBB24F, 0x84EDD840, 0x84E0112B, 0x84D25D14, 0x84C4BBFC, + 0x84B72DE4, 0x84A9B2D0, 0x849C4AC0, 0x848EF5B8, 0x8481B3BA, 0x847484C6, + 0x846768E0, 0x845A600A, 0x844D6A45, 0x84408793, 0x8433B7F7, 0x8426FB72, + 0x841A5206, 0x840DBBB6, 0x84013883, 0x83F4C86F, 0x83E86B7C, 0x83DC21EA, + 0x83CFEB3F, 0x83C3C7BB, 0x83B7B75F, 0x83ABBA2D, 0x839FD028, 0x8393F951, + 0x838835AA, 0x837C8535, 0x8370E7F4, 0x83655DE8, 0x8359E713, 0x834E8377, + 0x83433316, 0x8337F5F1, 0x832CCC0A, 0x8321B564, 0x8316B1FF, 0x830BC1DD, + 0x8300E501, 0x82F61B6B, 0x82EB651D, 0x82E0C21A, 0x82D63262, 0x82CBB5F7, + 0x82C14CDC, 0x82B6F710, 0x82ACB497, 0x82A285A5, 0x829869D5, 0x828E615B, + 0x82846C39, 0x827A8A72, 0x8270BC06, 0x826700F7, 0x825D5946, 0x8253C4F5, + 0x824A4405, 0x8240D679, 0x82377C50, 0x822E358E, 0x82250232, 0x821BE240, + 0x8212D5B7, 0x8209DC99, 0x8200F6E9, 0x81F824A6, 0x81EF65D3, 0x81E6BA71, + 0x81DE2281, 0x81D59E05, 0x81CD2CFE, 0x81C4CF6C, 0x81BC8552, 0x81B44EB1, + 0x81AC2BB3, 0x81A41C07, 0x819C1FD7, 0x81943725, 0x818C61F2, 0x8184A03E, + 0x817CF20D, 0x8175575D, 0x816DD032, 0x81665C8B, 0x815EFC6A, 0x8157AFD1, + 0x815076C0, 0x81495138, 0x81423F3A, 0x813B40C8, 0x813455E3, 0x812D7E8C, + 0x8126BAC3, 0x81200A8A, 0x81196DE2, 0x8112E4CC, 0x810C6F48, 0x81060D59, + 0x80FFBEFE, 0x80F98439, 0x80F35D0B, 0x80ED4994, 0x80E74996, 0x80E15D31, + 0x80DB8468, 0x80D5BF39, 0x80D00DA7, 0x80CA6FB2, 0x80C4E55B, 0x80BF6EA3, + 0x80BA0B8B, 0x80B4BC13, 0x80AF803D, 0x80AA5808, 0x80A54377, 0x80A0428A, + 0x809B5541, 0x80967B9E, 0x8091B5A0, 0x808D034A, 0x8088649A, 0x8083D994, + 0x807F6236, 0x807AFE81, 0x8076AE77, 0x80727218, 0x806E4965, 0x806A345E, + 0x80663303, 0x8062456A, 0x805E6B6B, 0x805AA51B, 0x8056F27A, 0x80535388, + 0x804FC848, 0x804C50B8, 0x8048ECD9, 0x80459CAD, 0x80426033, 0x803F376C, + 0x803C2259, 0x803920FA, 0x8036334F, 0x80335959, 0x80309318, 0x802DE08E, + 0x802B41B9, 0x8028B69B, 0x80263F34, 0x8023DB84, 0x80218B8C, 0x801F4F4D, + 0x801D26C5, 0x801B11F7, 0x801910E1, 0x80172385, 0x801549EC, 0x80138403, + 0x8011D1D4, 0x80103360, 0x800EA8A7, 0x800D31A8, 0x800BCE65, 0x800A7EDE, + 0x80094312, 0x80081B02, 0x800706AD, 0x80060616, 0x8005193A, 0x8004401B, + 0x80037AB8, 0x8002C912, 0x80022B29, 0x8001A0FD, 0x80012A8E, 0x8000C7DC, + 0x800078E8, 0x80003DB0, 0x80001636, 0x80000279 +}; + +const int32_t sine_512[] = { + 0xFFCDBC0C, 0xFF693440, 0xFF04ACD1, 0xFEA025FE, 0xFE3BA003, 0xFDD71B21, + 0xFD72978F, 0xFD0E1595, 0xFCA9956C, 0xFC45174E, 0xFBE09B85, 0xFB7C223F, + 0xFB17ABC2, 0xFAB33854, 0xFA4EC823, 0xF9EA5B74, 0xF985F28F, 0xF9218DA0, + 0xF8BD2CEF, 0xF858D0BF, 0xF7F47940, 0xF79026B8, 0xF72BD964, 0xF6C79182, + 0xF6634F60, 0xF5FF131C, 0xF59ADD04, 0xF536AD55, 0xF4D2844E, 0xF46E622B, + 0xF40A473C, 0xF3A6339D, 0xF342279C, 0xF2DE2378, 0xF27A276D, 0xF21633BA, + 0xF1B248AC, 0xF14E6661, 0xF0EA8D26, 0xF086BD38, 0xF022F6D7, 0xEFBF3A3E, + 0xEF5B87BC, 0xEEF7DF5E, 0xEE9441A2, 0xEE30AEA4, 0xEDCD2684, 0xED69A9BC, + 0xED06384C, 0xECA2D2B1, 0xEC3F78E7, 0xEBDC2B6D, 0xEB78EA5E, 0xEB15B5DA, + 0xEAB28E5C, 0xEA4F73E3, 0xE9EC66EA, 0xE989678F, 0xE92675F0, 0xE8C39289, + 0xE860BD57, 0xE7FDF6D8, 0xE79B3F08, 0xE7389663, 0xE6D5FD08, 0xE6737313, + 0xE610F900, 0xE5AE8ECC, 0xE54C34F4, 0xE4E9EB95, 0xE487B2CC, 0xE4258B13, + 0xE3C3746A, 0xE3616F4C, 0xE2FF7BB5, 0xE29D9A21, 0xE23BCAAE, 0xE1DA0D78, + 0xE17862F9, 0xE116CB31, 0xE0B54699, 0xE053D54F, 0xDFF2776F, 0xDF912D55, + 0xDF2FF77A, 0xDECED59F, 0xDE6DC83D, 0xDE0CCFCE, 0xDDABEC13, 0xDD4B1D85, + 0xDCEA645F, 0xDC89C11C, 0xDC29337A, 0xDBC8BBF4, 0xDB685B03, 0xDB081067, + 0xDAA7DC98, 0xDA47BFD3, 0xD9E7BA8F, 0xD987CC8E, 0xD927F647, 0xD8C83834, + 0xD8689215, 0xD8090462, 0xD7A98F92, 0xD74A3368, 0xD6EAF05A, 0xD68BC6A4, + 0xD62CB6BD, 0xD5CDC065, 0xD56EE416, 0xD5102244, 0xD4B17AB2, 0xD452EDD8, + 0xD3F47BEE, 0xD396256B, 0xD337EA13, 0xD2D9CA59, 0xD27BC6B6, 0xD21DDEEA, + 0xD1C0136B, 0xD1626475, 0xD104D27B, 0xD0A75D40, 0xD04A053A, 0xCFECCADE, + 0xCF8FADEE, 0xCF32AEDF, 0xCED5CE26, 0xCE790B85, 0xCE1C6772, 0xCDBFE225, + 0xCD637C11, 0xCD0734FC, 0xCCAB0D57, 0xCC4F0597, 0xCBF31D7F, 0xCB975583, + 0xCB3BADDB, 0xCAE026F9, 0xCA84C0A3, 0xCA297B4A, 0xC9CE5760, 0xC97354AB, + 0xC918739C, 0xC8BDB46B, 0xC863178A, 0xC8089CBD, 0xC7AE4476, 0xC7540F26, + 0xC6F9FC92, 0xC6A00D2B, 0xC6464161, 0xC5EC98FA, 0xC5931465, 0xC539B3DB, + 0xC4E077CB, 0xC4875FFB, 0xC42E6CDA, 0xC3D59ED7, 0xC37CF5B9, 0xC32471EF, + 0xC2CC13AF, 0xC273DB68, 0xC21BC8E0, 0xC1C3DC86, 0xC16C168F, 0xC1147733, + 0xC0BCFF15, 0xC065AD8E, 0xC00E8343, 0xBFB7806A, 0xBF60A537, 0xBF09F1E2, + 0xBEB3669E, 0xBE5D0411, 0xBE06C992, 0xBDB0B7C6, 0xBD5ACEE0, 0xBD050F17, + 0xBCAF789F, 0xBC5A0BAD, 0xBC04C8E2, 0xBBAFAF9A, 0xBB5AC075, 0xBB05FBA9, + 0xBAB16169, 0xBA5CF1E9, 0xBA08ADCA, 0xB9B49467, 0xB960A662, 0xB90CE3EC, + 0xB8B94D3B, 0xB865E281, 0xB812A3F2, 0xB7BF922B, 0xB76CAC8B, 0xB719F3B1, + 0xB6C767CE, 0xB6750916, 0xB622D7BB, 0xB5D0D3F0, 0xB57EFE51, 0xB52D563E, + 0xB4DBDC53, 0xB48A90C2, 0xB43973BC, 0xB3E88575, 0xB397C61E, 0xB347364F, + 0xB2F6D56D, 0xB2A6A410, 0xB256A269, 0xB206D0AB, 0xB1B72F05, 0xB167BDAA, + 0xB1187D2E, 0xB0C96CFA, 0xB07A8DA3, 0xB02BDF59, 0xAFDD624E, 0xAF8F16B1, + 0xAF40FCB2, 0xAEF314E6, 0xAEA55EB6, 0xAE57DAB4, 0xAE0A8911, 0xADBD69FD, + 0xAD707DA7, 0xAD23C43E, 0xACD73E54, 0xAC8AEB53, 0xAC3ECBCF, 0xABF2DFF4, + 0xABA727F2, 0xAB5BA3F7, 0xAB105493, 0xAAC53933, 0xAA7A5266, 0xAA2FA05B, + 0xA9E5233E, 0xA99ADB3F, 0xA950C88B, 0xA906EBAE, 0xA8BD4418, 0xA873D257, + 0xA82A9696, 0xA7E19104, 0xA798C1CD, 0xA750291E, 0xA707C780, 0xA6BF9C67, + 0xA677A85C, 0xA62FEB8C, 0xA5E86623, 0xA5A1184C, 0xA55A0235, 0xA5132462, + 0xA4CC7E4B, 0xA4861076, 0xA43FDB0E, 0xA3F9DE40, 0xA3B41A35, 0xA36E8F19, + 0xA3293D6F, 0xA2E424B1, 0xA29F4563, 0xA25A9FAE, 0xA21633BD, 0xA1D201BB, + 0xA18E09D1, 0xA14A4C7F, 0xA106C943, 0xA0C3809D, 0xA08072B5, 0xA03D9FB7, + 0x9FFB07CA, 0x9FB8AB6C, 0x9F768A1D, 0x9F34A45B, 0x9EF2FA4F, 0x9EB18C20, + 0x9E7059F7, 0x9E2F63FC, 0x9DEEAAAA, 0x9DAE2D84, 0x9D6DED04, 0x9D2DE951, + 0x9CEE2294, 0x9CAE98F3, 0x9C6F4C97, 0x9C303DF5, 0x9BF16C94, 0x9BB2D8EB, + 0x9B748322, 0x9B366B5E, 0x9AF891C6, 0x9ABAF680, 0x9A7D9A00, 0x9A407BD0, + 0x9A039C62, 0x99C6FBDE, 0x998A9A69, 0x994E7827, 0x9912953E, 0x98D6F21E, + 0x989B8E55, 0x98606A53, 0x9825863C, 0x97EAE236, 0x97B07E63, 0x97765AE9, + 0x973C7834, 0x9702D5D5, 0x96C9743A, 0x96905385, 0x965773DA, 0x961ED55C, + 0x95E6782E, 0x95AE5CBA, 0x95768293, 0x953EEA24, 0x95079390, 0x94D07EF7, + 0x9499AC7D, 0x94631C88, 0x942CCEAF, 0x93F6C359, 0x93C0FAA7, 0x938B74BB, + 0x935631B6, 0x932131B8, 0x92EC74E3, 0x92B7FB56, 0x9283C532, 0x924FD298, + 0x921C242A, 0x91E8B901, 0x91B591C2, 0x9182AE8B, 0x91500F7C, 0x911DB4B3, + 0x90EB9E52, 0x90B9CC75, 0x90883F3C, 0x9056F6C5, 0x9025F32F, 0x8FF53499, + 0x8FC4BB1F, 0x8F94875A, 0x8F649874, 0x8F34EF03, 0x8F058B26, 0x8ED66CFA, + 0x8EA7949D, 0x8E79022A, 0x8E4AB5BE, 0x8E1CAF77, 0x8DEEEF70, 0x8DC175C6, + 0x8D944295, 0x8D6755F9, 0x8D3AB00D, 0x8D0E515D, 0x8CE23924, 0x8CB667ED, + 0x8C8ADDD4, 0x8C5F9AF3, 0x8C349F65, 0x8C09EB45, 0x8BDF7EAC, 0x8BB559B6, + 0x8B8B7C7C, 0x8B61E718, 0x8B3899A4, 0x8B0F9438, 0x8AE6D6EF, 0x8ABE6249, + 0x8A96358F, 0x8A6E5142, 0x8A46B57C, 0x8A1F6253, 0x89F857E2, 0x89D1963E, + 0x89AB1D82, 0x8984EDC3, 0x895F071B, 0x8939699F, 0x89141569, 0x88EF0A8D, + 0x88CA4924, 0x88A5D1A0, 0x8881A35E, 0x885DBED3, 0x883A2413, 0x8816D335, + 0x87F3CC4E, 0x87D10F75, 0x87AE9CBF, 0x878C7440, 0x876A960F, 0x8749023F, + 0x8727B8E6, 0x8706BA18, 0x86E6063D, 0x86C59CC1, 0x86A57E0E, 0x8685AA35, + 0x8666214C, 0x8646E366, 0x8627F095, 0x860948ED, 0x85EAEC81, 0x85CCDB64, + 0x85AF15A7, 0x85919B5F, 0x85746C9B, 0x85578970, 0x853AF236, 0x851EA66F, + 0x8502A673, 0x84E6F256, 0x84CB8A28, 0x84B06DF9, 0x84959DDB, 0x847B19DE, + 0x8460E213, 0x8446F689, 0x842D5751, 0x8414047A, 0x83FAFE15, 0x83E24430, + 0x83C9D718, 0x83B1B660, 0x8399E257, 0x83825B09, 0x836B2087, 0x835432DE, + 0x833D921C, 0x83273E4F, 0x83113786, 0x82FB7DCD, 0x82E61132, 0x82D0F1C3, + 0x82BC1F8C, 0x82A79ACE, 0x8293632D, 0x827F78EA, 0x826BDC12, 0x82588CB1, + 0x82458AD3, 0x8232D682, 0x82206FCC, 0x820E56BB, 0x81FC8B5A, 0x81EB0DB4, + 0x81D9DDD5, 0x81C8FBC6, 0x81B86793, 0x81A8216E, 0x8198290E, 0x81887EA8, + 0x81792245, 0x816A13EE, 0x815B53AD, 0x814CE18A, 0x813EBD90, 0x8130E7C6, + 0x81236034, 0x811626E4, 0x81093BDE, 0x80FC9F29, 0x80F050CD, 0x80E450F0, + 0x80D89F5D, 0x80CD3C39, 0x80C2278B, 0x80B7615B, 0x80ACE9AE, 0x80A2C08C, + 0x8098E5FB, 0x808F5A00, 0x80861CA2, 0x807D2DE6, 0x80748DD2, 0x806C3C6C, + 0x806439CB, 0x805C85CD, 0x8055208B, 0x804E0A09, 0x8047424D, 0x8040C959, + 0x803A9F33, 0x8034C3DD, 0x802F375C, 0x8029F9B3, 0x80250AE5, 0x80206AF5, + 0x801C19E7, 0x801817BC, 0x80146480, 0x80110023, 0x800DEAB0, 0x800B242A, + 0x8008AC92, 0x800683EA, 0x8004AA33, 0x80031F6E, 0x8001E39C, 0x8000F6BE, + 0x800058D4, 0x800009DF +}; + +const int32_t sine_256[] ICONST_ATTR_WMAPRO_WIN_VS_TMP = { + 0xFF9B781E, 0xFED26950, 0xFE095D6B, 0xFD40565E, 0xFC775617, 0xFBAE5E8D, + 0xFAE571A2, 0xFA1C9157, 0xF953BF94, 0xF88AFE40, 0xF7C24F61, 0xF6F9B4C9, + 0xF6313075, 0xF568C463, 0xF4A07264, 0xF3D83C74, 0xF3102493, 0xF2482C8D, + 0xF1805660, 0xF0B8A409, 0xEFF11756, 0xEF29B241, 0xEE6276B8, 0xED9B66A5, + 0xECD48414, 0xEC0DD0B0, 0xEB474E83, 0xEA80FF77, 0xE9BAE575, 0xE8F50266, + 0xE82F5851, 0xE769E8E0, 0xE6A4B619, 0xE5DFC1E2, 0xE51B0E22, 0xE4569CBE, + 0xE3926FB9, 0xE2CE88BA, 0xE20AE9C3, 0xE14794B7, 0xE0848B77, 0xDFC1CFE5, + 0xDEFF6401, 0xDE3D494C, 0xDD7B8223, 0xDCBA1024, 0xDBF8F4F0, 0xDB3832DF, + 0xDA77CB50, 0xD9B7C09B, 0xD8F8141D, 0xD838C82A, 0xD779DE5D, 0xD6BB5850, + 0xD5FD3854, 0xD53F7FC3, 0xD48230EB, 0xD3C54D62, 0xD308D6BE, 0xD24CCF4A, + 0xD191385B, 0xD0D6143A, 0xD01B643D, 0xCF612AA7, 0xCEA76907, 0xCDEE20EF, + 0xCD35549C, 0xCC7D0561, 0xCBC5357A, 0xCB0DE672, 0xCA5719D3, 0xC9A0D1D4, + 0xC8EB0FC4, 0xC835D5D6, 0xC7812556, 0xC6CD0075, 0xC61968B6, 0xC5665F9C, + 0xC4B3E751, 0xC402011C, 0xC350AF27, 0xC29FF2EC, 0xC1EFCDEA, 0xC140420A, + 0xC091516E, 0xBFE2FCE5, 0xBF35468E, 0xBE883082, 0xBDDBBB92, 0xBD2FE9D5, + 0xBC84BCF2, 0xBBDA36FD, 0xBB3058C1, 0xBA87244E, 0xB9DE9BB0, 0xB936BFB2, + 0xB88F925B, 0xB7E9154A, 0xB7434A82, 0xB69E32C9, 0xB5F9D020, 0xB5562485, + 0xB4B330BC, 0xB410F6BE, 0xB36F7882, 0xB2CEB6CB, 0xB22EB38A, 0xB18F704B, + 0xB0F0EEFC, 0xB0533059, 0xAFB6364E, 0xAF1A02C1, 0xAE7E966C, 0xADE3F332, + 0xAD4A1A92, 0xACB10E67, 0xAC18CF69, 0xAB815F71, 0xAAEAC054, 0xAA54F2C6, + 0xA9BFF898, 0xA92BD33C, 0xA898847A, 0xA8060D04, 0xA7746EA1, 0xA6E3AB14, + 0xA653C30A, 0xA5C4B842, 0xA5368C78, 0xA4A94055, 0xA41CD591, 0xA3914D86, + 0xA306A9E5, 0xA27CEB53, 0xA1F4137C, 0xA16C2408, 0xA0E51D9A, 0xA05F01D6, + 0x9FD9D207, 0x9F558FC8, 0x9ED23BB9, 0x9E4FD771, 0x9DCE6485, 0x9D4DE38E, + 0x9CCE561E, 0x9C4FBD6E, 0x9BD21B06, 0x9B556F7D, 0x9AD9BC57, 0x9A5F0312, + 0x99E54441, 0x996C815F, 0x98F4BBE2, 0x987DF458, 0x98082C35, 0x97936499, + 0x971F9EEF, 0x96ACDBC0, 0x963B1C73, 0x95CA6267, 0x955AAE23, 0x94EC0102, + 0x947E5C15, 0x9411C0B1, 0x93A62F56, 0x933BA954, 0x92D22FB1, 0x9269C372, + 0x9202661A, 0x919C17A3, 0x9136D98D, 0x90D2ACD1, 0x906F9266, 0x900D8B42, + 0x8FAC9856, 0x8F4CBB0B, 0x8EEDF358, 0x8E9042A4, 0x8E33A9D4, 0x8DD829CE, + 0x8D7DC372, 0x8D2477A1, 0x8CCC47A6, 0x8C75337A, 0x8C1F3C65, 0x8BCA633B, + 0x8B76A8CE, 0x8B240DEB, 0x8AD293C7, 0x8A823A59, 0x8A3302D2, 0x89E4EDF5, + 0x8997FC81, 0x894C2F36, 0x890186CE, 0x88B8045E, 0x886FA7E0, 0x88287266, + 0x87E2649F, 0x879D7F37, 0x8759C2D9, 0x8717302D, 0x86D5C827, 0x86958AC5, + 0x865678F8, 0x8618935B, 0x85DBDA87, 0x85A04F13, 0x8565F192, 0x852CC2DA, + 0x84F4C2E8, 0x84BDF28F, 0x84885258, 0x8453E2C5, 0x8420A459, 0x83EE9791, + 0x83BDBD27, 0x838E1518, 0x835FA016, 0x83325E96, 0x83065106, 0x82DB77D4, + 0x82B1D369, 0x8289645F, 0x82622AB2, 0x823C26F8, 0x8217598E, 0x81F3C2CF, + 0x81D16313, 0x81B03AAE, 0x81904A1B, 0x81719157, 0x815410D7, 0x8137C8E4, + 0x811CB9C4, 0x8102E3B9, 0x80EA4722, 0x80D2E3FC, 0x80BCBAA3, 0x80A7CB4B, + 0x8094162A, 0x80819B6F, 0x80705B49, 0x806055F5, 0x80518B72, 0x8043FBFA, + 0x8037A7AE, 0x802C8EAD, 0x8022B111, 0x801A0EF5, 0x8012A874, 0x800C7D90, + 0x80078E60, 0x8003DAF2, 0x8001634E, 0x8000277B +}; + +const int32_t sine_128[] ICONST_ATTR = { + 0xFF36F079, 0xFDA4D929, 0xFC12D91C, 0xFA80FFCF, 0xF8EF5CBC, 0xF75DFF6C, + 0xF5CCF73F, 0xF43C53CB, 0xF2AC2474, 0xF11C7895, 0xEF8D5FC8, 0xEDFEE931, + 0xEC71244A, 0xEAE4208A, 0xE957ED00, 0xE7CC9912, 0xE642341D, 0xE4B8CD16, + 0xE3307348, 0xE1A935F1, 0xE02323EA, 0xDE9E4C5B, 0xDD1ABE41, 0xDB98888E, + 0xDA17BA63, 0xD898621B, 0xD71A8EBA, 0xD59E4EF9, 0xD423B181, 0xD2AAC4EB, + 0xD13397FA, 0xCFBE38AD, 0xCE4AB5A6, 0xCCD91D38, 0xCB697DA1, 0xC9FBE50E, + 0xC89061D1, 0xC727017A, 0xC5BFD232, 0xC45AE1D1, 0xC2F83E1B, 0xC197F4BB, + 0xC03A137E, 0xBEDEA73A, 0xBD85BE33, 0xBC2F6544, 0xBADBA934, 0xB98A97F6, + 0xB83C3DB0, 0xB6F0A81D, 0xB5A7E331, 0xB461FC6A, 0xB31EFFF0, 0xB1DEF9D2, + 0xB0A1F730, 0xAF68037B, 0xAE312B94, 0xACFD7B13, 0xABCCFD75, 0xAA9FBF37, + 0xA975CB39, 0xA84F2DB4, 0xA72BF147, 0xA60C21E8, 0xA4EFCA51, 0xA3D6F51F, + 0xA2C1ADDA, 0xA1AFFE80, 0xA0A1F24E, 0x9F979356, 0x9E90EB88, 0x9D8E05AD, + 0x9C8EEB1A, 0x9B93A649, 0x9A9C4048, 0x99A8C33F, 0x98B93843, 0x97CDA844, + 0x96E61CED, 0x96029E99, 0x9523369D, 0x9447ED4D, 0x9370CADA, 0x929DD7D5, + 0x91CF1CE2, 0x9104A0F4, 0x903E6C5C, 0x8F7C873A, 0x8EBEF810, 0x8E05C6AA, + 0x8D50FA2B, 0x8CA099FB, 0x8BF4AC06, 0x8B4D375E, 0x8AAA42E0, 0x8A0BD402, + 0x8971F14B, 0x88DCA0A9, 0x884BE838, 0x87BFCCD4, 0x87385443, 0x86B5840D, + 0x86376099, 0x85BDEF18, 0x85493481, 0x84D934C0, 0x846DF472, 0x840777B8, + 0x83A5C2C5, 0x8348D8DF, 0x82F0BDDB, 0x829D7552, 0x824F0211, 0x82056753, + 0x81C0A7F0, 0x8180C6B5, 0x8145C5C8, 0x810FA798, 0x80DE6E59, 0x80B21BB4, + 0x808AB17D, 0x8068313B, 0x804A9C52, 0x8031F3C2, 0x801E3892, 0x800F6B8C, + 0x80058D30, 0x80009DEA +}; + +const int32_t *sine_windows[6] = { + sine_128, sine_256, sine_512, sine_1024, sine_2048, sine_4096 +}; + + +/* mdct trig table. + the table should be in s.31 format, but in wma pro, all the tables are scaled + down to preserve energy in the signal, so this downscaling is equivalent to + having the tables in ~s15.16 instead. */ +/* rockbox: not used +const int32_t sincos_lookup_wmap[8064] = { + 0x0000011C, 0x00016A09, 0x000009FE, 0x000169E6, + 0x000012DF, 0x0001698B, 0x00001BBD, 0x000168F9, + 0x00002497, 0x0001682F, 0x00002D6B, 0x0001672D, + 0x00003638, 0x000165F4, 0x00003EFD, 0x00016484, + 0x000047B8, 0x000162DD, 0x00005068, 0x000160FF, + 0x0000590B, 0x00015EEA, 0x000061A1, 0x00015CA0, + 0x00006A28, 0x00015A20, 0x0000729E, 0x0001576A, + 0x00007B03, 0x0001547F, 0x00008354, 0x00015160, + 0x00008B92, 0x00014E0D, 0x000093BA, 0x00014A87, + 0x00009BCB, 0x000146CD, 0x0000A3C4, 0x000142E1, + 0x0000ABA4, 0x00013EC3, 0x0000B369, 0x00013A74, + 0x0000BB13, 0x000135F5, 0x0000C2A0, 0x00013146, + 0x0000CA0F, 0x00012C67, 0x0000D15F, 0x0001275B, + 0x0000D88E, 0x00012221, 0x0000DF9C, 0x00011CBA, + 0x0000E688, 0x00011727, 0x0000ED50, 0x00011169, + 0x0000F3F3, 0x00010B81, 0x0000FA71, 0x00010570, + 0x000100C8, 0x0000FF36, 0x000106F8, 0x0000F8D5, + 0x00010CFF, 0x0000F24E, 0x000112DC, 0x0000EBA1, + 0x00011890, 0x0000E4D0, 0x00011E18, 0x0000DDDC, + 0x00012373, 0x0000D6C5, 0x000128A2, 0x0000CF8E, + 0x00012DA3, 0x0000C836, 0x00013276, 0x0000C0C0, + 0x00013719, 0x0000B92B, 0x00013B8D, 0x0000B17B, + 0x00013FCF, 0x0000A9AE, 0x000143E1, 0x0000A1C8, + 0x000147C0, 0x000099C9, 0x00014B6D, 0x000091B2, + 0x00014EE7, 0x00008984, 0x0001522D, 0x00008142, + 0x0001553F, 0x000078EB, 0x0001581C, 0x00007082, + 0x00015AC5, 0x00006807, 0x00015D38, 0x00005F7D, + 0x00015F75, 0x000056E3, 0x0001617B, 0x00004E3D, + 0x0001634C, 0x0000458A, 0x000164E5, 0x00003CCC, + 0x00016648, 0x00003405, 0x00016773, 0x00002B36, + 0x00016867, 0x00002261, 0x00016923, 0x00001986, + 0x000169A7, 0x000010A7, 0x000169F4, 0x000007C6, + 0x00000064, 0x0000FFFF, 0x00000388, 0x0000FFF9, + 0x000006AC, 0x0000FFE9, 0x000009D0, 0x0000FFCF, + 0x00000CF4, 0x0000FFAC, 0x00001017, 0x0000FF7E, + 0x00001339, 0x0000FF46, 0x0000165A, 0x0000FF05, + 0x0000197B, 0x0000FEBA, 0x00001C9B, 0x0000FE65, + 0x00001FBA, 0x0000FE06, 0x000022D7, 0x0000FD9E, + 0x000025F3, 0x0000FD2B, 0x0000290E, 0x0000FCAF, + 0x00002C27, 0x0000FC29, 0x00002F3E, 0x0000FB9A, + 0x00003254, 0x0000FB01, 0x00003567, 0x0000FA5E, + 0x00003879, 0x0000F9B1, 0x00003B88, 0x0000F8FB, + 0x00003E95, 0x0000F83B, 0x000041A0, 0x0000F772, + 0x000044A8, 0x0000F69F, 0x000047AD, 0x0000F5C2, + 0x00004AB0, 0x0000F4DC, 0x00004DB0, 0x0000F3ED, + 0x000050AC, 0x0000F2F4, 0x000053A6, 0x0000F1F2, + 0x0000569D, 0x0000F0E7, 0x00005990, 0x0000EFD2, + 0x00005C7F, 0x0000EEB4, 0x00005F6B, 0x0000ED8D, + 0x00006254, 0x0000EC5C, 0x00006539, 0x0000EB23, + 0x00006819, 0x0000E9E0, 0x00006AF6, 0x0000E895, + 0x00006DCF, 0x0000E740, 0x000070A3, 0x0000E5E3, + 0x00007373, 0x0000E47D, 0x0000763F, 0x0000E30D, + 0x00007906, 0x0000E196, 0x00007BC8, 0x0000E015, + 0x00007E86, 0x0000DE8C, 0x0000813E, 0x0000DCFA, + 0x000083F2, 0x0000DB60, 0x000086A1, 0x0000D9BD, + 0x0000894A, 0x0000D812, 0x00008BEE, 0x0000D65F, + 0x00008E8D, 0x0000D4A3, 0x00009126, 0x0000D2DF, + 0x000093BA, 0x0000D113, 0x00009648, 0x0000CF3F, + 0x000098D0, 0x0000CD63, 0x00009B52, 0x0000CB7F, + 0x00009DCF, 0x0000C993, 0x0000A045, 0x0000C79F, + 0x0000A2B5, 0x0000C5A4, 0x0000A51F, 0x0000C3A1, + 0x0000A782, 0x0000C196, 0x0000A9DF, 0x0000BF84, + 0x0000AC35, 0x0000BD6B, 0x0000AE85, 0x0000BB4A, + 0x0000B0CE, 0x0000B922, 0x0000B310, 0x0000B6F3, + 0x0000B54B, 0x0000B4BD, 0x0000B780, 0x0000B280, + 0x0000B9AD, 0x0000B03C, 0x0000BBD3, 0x0000ADF2, + 0x0000BDF2, 0x0000ABA0, 0x0000C009, 0x0000A948, + 0x0000C21A, 0x0000A6EA, 0x0000C422, 0x0000A485, + 0x0000C623, 0x0000A219, 0x0000C81D, 0x00009FA8, + 0x0000CA0E, 0x00009D30, 0x0000CBF8, 0x00009AB2, + 0x0000CDDA, 0x0000982E, 0x0000CFB4, 0x000095A5, + 0x0000D187, 0x00009315, 0x0000D351, 0x00009080, + 0x0000D512, 0x00008DE6, 0x0000D6CC, 0x00008B46, + 0x0000D87E, 0x000088A0, 0x0000DA27, 0x000085F5, + 0x0000DBC7, 0x00008345, 0x0000DD5F, 0x00008090, + 0x0000DEEF, 0x00007DD7, 0x0000E076, 0x00007B18, + 0x0000E1F4, 0x00007854, 0x0000E36A, 0x0000758C, + 0x0000E4D7, 0x000072BF, 0x0000E63B, 0x00006FEE, + 0x0000E796, 0x00006D19, 0x0000E8E9, 0x00006A3F, + 0x0000EA32, 0x00006761, 0x0000EB72, 0x00006480, + 0x0000ECA9, 0x0000619A, 0x0000EDD7, 0x00005EB1, + 0x0000EEFC, 0x00005BC4, 0x0000F018, 0x000058D3, + 0x0000F12A, 0x000055DF, 0x0000F233, 0x000052E8, + 0x0000F333, 0x00004FED, 0x0000F42A, 0x00004CF0, + 0x0000F517, 0x000049EF, 0x0000F5FA, 0x000046EC, + 0x0000F6D4, 0x000043E6, 0x0000F7A5, 0x000040DD, + 0x0000F86C, 0x00003DD2, 0x0000F929, 0x00003AC4, + 0x0000F9DD, 0x000037B4, 0x0000FA87, 0x000034A2, + 0x0000FB28, 0x0000318E, 0x0000FBBF, 0x00002E78, + 0x0000FC4C, 0x00002B61, 0x0000FCCF, 0x00002847, + 0x0000FD49, 0x0000252C, 0x0000FDB9, 0x00002210, + 0x0000FE1F, 0x00001EF2, 0x0000FE7B, 0x00001BD3, + 0x0000FECE, 0x000018B3, 0x0000FF16, 0x00001592, + 0x0000FF55, 0x00001270, 0x0000FF8A, 0x00000F4E, + 0x0000FFB5, 0x00000C2B, 0x0000FFD7, 0x00000907, + 0x0000FFEE, 0x000005E3, 0x0000FFFC, 0x000002BF, + 0x00000023, 0x0000B504, 0x0000013F, 0x0000B503, + 0x0000025C, 0x0000B501, 0x00000378, 0x0000B4FC, + 0x00000494, 0x0000B4F6, 0x000005B1, 0x0000B4EE, + 0x000006CD, 0x0000B4E4, 0x000007E9, 0x0000B4D8, + 0x00000905, 0x0000B4CB, 0x00000A21, 0x0000B4BC, + 0x00000B3D, 0x0000B4AB, 0x00000C58, 0x0000B499, + 0x00000D74, 0x0000B484, 0x00000E8F, 0x0000B46E, + 0x00000FAB, 0x0000B457, 0x000010C6, 0x0000B43D, + 0x000011E1, 0x0000B422, 0x000012FC, 0x0000B405, + 0x00001417, 0x0000B3E6, 0x00001531, 0x0000B3C6, + 0x0000164B, 0x0000B3A4, 0x00001765, 0x0000B380, + 0x0000187F, 0x0000B35A, 0x00001999, 0x0000B333, + 0x00001AB2, 0x0000B30A, 0x00001BCB, 0x0000B2DF, + 0x00001CE4, 0x0000B2B2, 0x00001DFD, 0x0000B284, + 0x00001F15, 0x0000B254, 0x0000202D, 0x0000B222, + 0x00002145, 0x0000B1EF, 0x0000225C, 0x0000B1BA, + 0x00002373, 0x0000B183, 0x0000248A, 0x0000B14B, + 0x000025A0, 0x0000B110, 0x000026B6, 0x0000B0D4, + 0x000027CC, 0x0000B097, 0x000028E1, 0x0000B057, + 0x000029F6, 0x0000B016, 0x00002B0A, 0x0000AFD3, + 0x00002C1E, 0x0000AF8F, 0x00002D31, 0x0000AF49, + 0x00002E45, 0x0000AF01, 0x00002F57, 0x0000AEB8, + 0x00003069, 0x0000AE6C, 0x0000317B, 0x0000AE1F, + 0x0000328D, 0x0000ADD1, 0x0000339D, 0x0000AD81, + 0x000034AE, 0x0000AD2F, 0x000035BD, 0x0000ACDB, + 0x000036CD, 0x0000AC86, 0x000037DB, 0x0000AC2F, + 0x000038EA, 0x0000ABD6, 0x000039F7, 0x0000AB7C, + 0x00003B04, 0x0000AB20, 0x00003C11, 0x0000AAC3, + 0x00003D1D, 0x0000AA64, 0x00003E28, 0x0000AA03, + 0x00003F33, 0x0000A9A0, 0x0000403D, 0x0000A93C, + 0x00004147, 0x0000A8D6, 0x0000424F, 0x0000A86F, + 0x00004358, 0x0000A806, 0x0000445F, 0x0000A79C, + 0x00004566, 0x0000A72F, 0x0000466D, 0x0000A6C2, + 0x00004772, 0x0000A652, 0x00004877, 0x0000A5E1, + 0x0000497B, 0x0000A56E, 0x00004A7F, 0x0000A4FA, + 0x00004B82, 0x0000A484, 0x00004C84, 0x0000A40D, + 0x00004D85, 0x0000A394, 0x00004E86, 0x0000A319, + 0x00004F85, 0x0000A29D, 0x00005084, 0x0000A220, + 0x00005183, 0x0000A1A0, 0x00005280, 0x0000A120, + 0x0000537D, 0x0000A09D, 0x00005479, 0x0000A019, + 0x00005574, 0x00009F94, 0x0000566E, 0x00009F0D, + 0x00005767, 0x00009E84, 0x00005860, 0x00009DFA, + 0x00005958, 0x00009D6F, 0x00005A4F, 0x00009CE2, + 0x00005B45, 0x00009C53, 0x00005C3A, 0x00009BC3, + 0x00005D2E, 0x00009B31, 0x00005E21, 0x00009A9E, + 0x00005F14, 0x00009A09, 0x00006005, 0x00009973, + 0x000060F6, 0x000098DC, 0x000061E5, 0x00009843, + 0x000062D4, 0x000097A8, 0x000063C2, 0x0000970C, + 0x000064AF, 0x0000966F, 0x0000659B, 0x000095D0, + 0x00006685, 0x00009530, 0x0000676F, 0x0000948E, + 0x00006858, 0x000093EB, 0x00006940, 0x00009346, + 0x00006A27, 0x000092A0, 0x00006B0D, 0x000091F9, + 0x00006BF1, 0x00009150, 0x00006CD5, 0x000090A5, + 0x00006DB8, 0x00008FFA, 0x00006E99, 0x00008F4D, + 0x00006F7A, 0x00008E9E, 0x00007059, 0x00008DEF, + 0x00007138, 0x00008D3D, 0x00007215, 0x00008C8B, + 0x000072F1, 0x00008BD7, 0x000073CC, 0x00008B22, + 0x000074A6, 0x00008A6B, 0x0000757F, 0x000089B3, + 0x00007657, 0x000088FA, 0x0000772E, 0x00008840, + 0x00007803, 0x00008784, 0x000078D7, 0x000086C6, + 0x000079AB, 0x00008608, 0x00007A7C, 0x00008548, + 0x00007B4D, 0x00008487, 0x00007C1D, 0x000083C5, + 0x00007CEB, 0x00008301, 0x00007DB8, 0x0000823C, + 0x00007E84, 0x00008176, 0x00007F4F, 0x000080AF, + 0x00008019, 0x00007FE6, 0x000080E1, 0x00007F1D, + 0x000081A8, 0x00007E51, 0x0000826E, 0x00007D85, + 0x00008332, 0x00007CB8, 0x000083F6, 0x00007BE9, + 0x000084B8, 0x00007B19, 0x00008578, 0x00007A48, + 0x00008638, 0x00007976, 0x000086F6, 0x000078A2, + 0x000087B3, 0x000077CE, 0x0000886E, 0x000076F8, + 0x00008928, 0x00007621, 0x000089E1, 0x00007549, + 0x00008A99, 0x00007470, 0x00008B4F, 0x00007396, + 0x00008C04, 0x000072BA, 0x00008CB8, 0x000071DE, + 0x00008D6A, 0x00007100, 0x00008E1B, 0x00007022, + 0x00008ECA, 0x00006F42, 0x00008F78, 0x00006E61, + 0x00009025, 0x00006D7F, 0x000090D0, 0x00006C9C, + 0x0000917A, 0x00006BB8, 0x00009223, 0x00006AD3, + 0x000092CA, 0x000069ED, 0x0000936F, 0x00006906, + 0x00009414, 0x0000681E, 0x000094B6, 0x00006735, + 0x00009558, 0x0000664B, 0x000095F8, 0x00006560, + 0x00009696, 0x00006474, 0x00009733, 0x00006387, + 0x000097CF, 0x00006299, 0x00009869, 0x000061AA, + 0x00009902, 0x000060BA, 0x00009999, 0x00005FC9, + 0x00009A2F, 0x00005ED7, 0x00009AC3, 0x00005DE5, + 0x00009B56, 0x00005CF1, 0x00009BE7, 0x00005BFD, + 0x00009C77, 0x00005B07, 0x00009D05, 0x00005A11, + 0x00009D92, 0x0000591A, 0x00009E1D, 0x00005822, + 0x00009EA7, 0x00005729, 0x00009F2F, 0x00005630, + 0x00009FB5, 0x00005535, 0x0000A03A, 0x0000543A, + 0x0000A0BE, 0x0000533E, 0x0000A140, 0x00005241, + 0x0000A1C0, 0x00005143, 0x0000A23F, 0x00005045, + 0x0000A2BD, 0x00004F45, 0x0000A338, 0x00004E45, + 0x0000A3B2, 0x00004D45, 0x0000A42B, 0x00004C43, + 0x0000A4A2, 0x00004B41, 0x0000A517, 0x00004A3E, + 0x0000A58B, 0x0000493A, 0x0000A5FD, 0x00004836, + 0x0000A66E, 0x00004731, 0x0000A6DD, 0x0000462B, + 0x0000A74B, 0x00004525, 0x0000A7B6, 0x0000441D, + 0x0000A821, 0x00004316, 0x0000A889, 0x0000420D, + 0x0000A8F0, 0x00004104, 0x0000A955, 0x00003FFB, + 0x0000A9B9, 0x00003EF0, 0x0000AA1B, 0x00003DE5, + 0x0000AA7C, 0x00003CDA, 0x0000AADA, 0x00003BCE, + 0x0000AB37, 0x00003AC1, 0x0000AB93, 0x000039B4, + 0x0000ABED, 0x000038A6, 0x0000AC45, 0x00003798, + 0x0000AC9B, 0x00003689, 0x0000ACF0, 0x00003579, + 0x0000AD43, 0x0000346A, 0x0000AD95, 0x00003359, + 0x0000ADE5, 0x00003248, 0x0000AE33, 0x00003137, + 0x0000AE7F, 0x00003025, 0x0000AECA, 0x00002F13, + 0x0000AF13, 0x00002E00, 0x0000AF5B, 0x00002CED, + 0x0000AFA0, 0x00002BD9, 0x0000AFE4, 0x00002AC5, + 0x0000B027, 0x000029B0, 0x0000B067, 0x0000289B, + 0x0000B0A6, 0x00002786, 0x0000B0E3, 0x00002671, + 0x0000B11F, 0x0000255A, 0x0000B159, 0x00002444, + 0x0000B191, 0x0000232D, 0x0000B1C7, 0x00002216, + 0x0000B1FC, 0x000020FF, 0x0000B22F, 0x00001FE7, + 0x0000B260, 0x00001ECF, 0x0000B290, 0x00001DB7, + 0x0000B2BE, 0x00001C9E, 0x0000B2EA, 0x00001B85, + 0x0000B314, 0x00001A6C, 0x0000B33D, 0x00001953, + 0x0000B364, 0x00001839, 0x0000B389, 0x0000171F, + 0x0000B3AC, 0x00001605, 0x0000B3CE, 0x000014EB, + 0x0000B3EE, 0x000013D0, 0x0000B40C, 0x000012B5, + 0x0000B429, 0x0000119A, 0x0000B444, 0x0000107F, + 0x0000B45D, 0x00000F64, 0x0000B474, 0x00000E49, + 0x0000B489, 0x00000D2D, 0x0000B49D, 0x00000C11, + 0x0000B4AF, 0x00000AF6, 0x0000B4C0, 0x000009DA, + 0x0000B4CE, 0x000008BE, 0x0000B4DB, 0x000007A2, + 0x0000B4E6, 0x00000686, 0x0000B4F0, 0x00000569, + 0x0000B4F7, 0x0000044D, 0x0000B4FD, 0x00000331, + 0x0000B501, 0x00000215, 0x0000B504, 0x000000F8, + 0x0000000C, 0x00007FFF, 0x00000071, 0x00007FFF, + 0x000000D5, 0x00007FFF, 0x0000013A, 0x00007FFE, + 0x0000019E, 0x00007FFD, 0x00000203, 0x00007FFB, + 0x00000267, 0x00007FFA, 0x000002CC, 0x00007FF8, + 0x00000330, 0x00007FF5, 0x00000395, 0x00007FF3, + 0x000003F9, 0x00007FF0, 0x0000045E, 0x00007FEC, + 0x000004C2, 0x00007FE9, 0x00000527, 0x00007FE5, + 0x0000058B, 0x00007FE1, 0x000005EF, 0x00007FDC, + 0x00000654, 0x00007FD7, 0x000006B8, 0x00007FD2, + 0x0000071D, 0x00007FCD, 0x00000781, 0x00007FC7, + 0x000007E5, 0x00007FC1, 0x0000084A, 0x00007FBB, + 0x000008AE, 0x00007FB4, 0x00000912, 0x00007FAD, + 0x00000977, 0x00007FA6, 0x000009DB, 0x00007F9E, + 0x00000A3F, 0x00007F96, 0x00000AA3, 0x00007F8E, + 0x00000B07, 0x00007F86, 0x00000B6C, 0x00007F7D, + 0x00000BD0, 0x00007F74, 0x00000C34, 0x00007F6A, + 0x00000C98, 0x00007F60, 0x00000CFC, 0x00007F56, + 0x00000D60, 0x00007F4C, 0x00000DC4, 0x00007F41, + 0x00000E28, 0x00007F36, 0x00000E8C, 0x00007F2B, + 0x00000EF0, 0x00007F20, 0x00000F53, 0x00007F14, + 0x00000FB7, 0x00007F08, 0x0000101B, 0x00007EFB, + 0x0000107F, 0x00007EEE, 0x000010E2, 0x00007EE1, + 0x00001146, 0x00007ED4, 0x000011A9, 0x00007EC6, + 0x0000120D, 0x00007EB8, 0x00001271, 0x00007EAA, + 0x000012D4, 0x00007E9B, 0x00001337, 0x00007E8C, + 0x0000139B, 0x00007E7D, 0x000013FE, 0x00007E6D, + 0x00001461, 0x00007E5D, 0x000014C5, 0x00007E4D, + 0x00001528, 0x00007E3D, 0x0000158B, 0x00007E2C, + 0x000015EE, 0x00007E1B, 0x00001651, 0x00007E0A, + 0x000016B4, 0x00007DF8, 0x00001717, 0x00007DE6, + 0x0000177A, 0x00007DD4, 0x000017DD, 0x00007DC1, + 0x0000183F, 0x00007DAE, 0x000018A2, 0x00007D9B, + 0x00001905, 0x00007D87, 0x00001967, 0x00007D74, + 0x000019CA, 0x00007D60, 0x00001A2C, 0x00007D4B, + 0x00001A8E, 0x00007D36, 0x00001AF1, 0x00007D21, + 0x00001B53, 0x00007D0C, 0x00001BB5, 0x00007CF6, + 0x00001C17, 0x00007CE1, 0x00001C79, 0x00007CCA, + 0x00001CDB, 0x00007CB4, 0x00001D3D, 0x00007C9D, + 0x00001D9F, 0x00007C86, 0x00001E01, 0x00007C6E, + 0x00001E62, 0x00007C57, 0x00001EC4, 0x00007C3F, + 0x00001F26, 0x00007C26, 0x00001F87, 0x00007C0E, + 0x00001FE9, 0x00007BF5, 0x0000204A, 0x00007BDC, + 0x000020AB, 0x00007BC2, 0x0000210C, 0x00007BA8, + 0x0000216D, 0x00007B8E, 0x000021CE, 0x00007B74, + 0x0000222F, 0x00007B59, 0x00002290, 0x00007B3E, + 0x000022F1, 0x00007B23, 0x00002352, 0x00007B07, + 0x000023B2, 0x00007AEB, 0x00002413, 0x00007ACF, + 0x00002473, 0x00007AB3, 0x000024D3, 0x00007A96, + 0x00002534, 0x00007A79, 0x00002594, 0x00007A5C, + 0x000025F4, 0x00007A3E, 0x00002654, 0x00007A20, + 0x000026B4, 0x00007A02, 0x00002713, 0x000079E3, + 0x00002773, 0x000079C4, 0x000027D3, 0x000079A5, + 0x00002832, 0x00007986, 0x00002892, 0x00007966, + 0x000028F1, 0x00007946, 0x00002950, 0x00007926, + 0x000029AF, 0x00007905, 0x00002A0E, 0x000078E4, + 0x00002A6D, 0x000078C3, 0x00002ACC, 0x000078A2, + 0x00002B2B, 0x00007880, 0x00002B89, 0x0000785E, + 0x00002BE8, 0x0000783B, 0x00002C46, 0x00007819, + 0x00002CA4, 0x000077F6, 0x00002D02, 0x000077D3, + 0x00002D60, 0x000077AF, 0x00002DBE, 0x0000778B, + 0x00002E1C, 0x00007767, 0x00002E7A, 0x00007743, + 0x00002ED8, 0x0000771E, 0x00002F35, 0x000076F9, + 0x00002F92, 0x000076D4, 0x00002FF0, 0x000076AF, + 0x0000304D, 0x00007689, 0x000030AA, 0x00007663, + 0x00003107, 0x0000763C, 0x00003164, 0x00007616, + 0x000031C0, 0x000075EF, 0x0000321D, 0x000075C8, + 0x00003279, 0x000075A0, 0x000032D6, 0x00007578, + 0x00003332, 0x00007550, 0x0000338E, 0x00007528, + 0x000033EA, 0x000074FF, 0x00003446, 0x000074D6, + 0x000034A1, 0x000074AD, 0x000034FD, 0x00007484, + 0x00003558, 0x0000745A, 0x000035B4, 0x00007430, + 0x0000360F, 0x00007406, 0x0000366A, 0x000073DB, + 0x000036C5, 0x000073B0, 0x00003720, 0x00007385, + 0x0000377A, 0x00007359, 0x000037D5, 0x0000732E, + 0x0000382F, 0x00007302, 0x0000388A, 0x000072D5, + 0x000038E4, 0x000072A9, 0x0000393E, 0x0000727C, + 0x00003998, 0x0000724F, 0x000039F1, 0x00007222, + 0x00003A4B, 0x000071F4, 0x00003AA4, 0x000071C6, + 0x00003AFE, 0x00007198, 0x00003B57, 0x00007169, + 0x00003BB0, 0x0000713B, 0x00003C09, 0x0000710C, + 0x00003C61, 0x000070DC, 0x00003CBA, 0x000070AD, + 0x00003D12, 0x0000707D, 0x00003D6B, 0x0000704D, + 0x00003DC3, 0x0000701D, 0x00003E1B, 0x00006FEC, + 0x00003E73, 0x00006FBB, 0x00003ECA, 0x00006F8A, + 0x00003F22, 0x00006F58, 0x00003F79, 0x00006F27, + 0x00003FD0, 0x00006EF5, 0x00004027, 0x00006EC2, + 0x0000407E, 0x00006E90, 0x000040D5, 0x00006E5D, + 0x0000412C, 0x00006E2A, 0x00004182, 0x00006DF7, + 0x000041D8, 0x00006DC3, 0x0000422F, 0x00006D8F, + 0x00004284, 0x00006D5B, 0x000042DA, 0x00006D27, + 0x00004330, 0x00006CF2, 0x00004385, 0x00006CBD, + 0x000043DB, 0x00006C88, 0x00004430, 0x00006C53, + 0x00004485, 0x00006C1D, 0x000044DA, 0x00006BE7, + 0x0000452E, 0x00006BB1, 0x00004583, 0x00006B7A, + 0x000045D7, 0x00006B44, 0x0000462B, 0x00006B0D, + 0x0000467F, 0x00006AD5, 0x000046D3, 0x00006A9E, + 0x00004727, 0x00006A66, 0x0000477A, 0x00006A2E, + 0x000047CE, 0x000069F6, 0x00004821, 0x000069BD, + 0x00004874, 0x00006985, 0x000048C7, 0x0000694B, + 0x00004919, 0x00006912, 0x0000496C, 0x000068D9, + 0x000049BE, 0x0000689F, 0x00004A10, 0x00006865, + 0x00004A62, 0x0000682B, 0x00004AB4, 0x000067F0, + 0x00004B05, 0x000067B5, 0x00004B56, 0x0000677A, + 0x00004BA8, 0x0000673F, 0x00004BF9, 0x00006703, + 0x00004C49, 0x000066C8, 0x00004C9A, 0x0000668B, + 0x00004CEB, 0x0000664F, 0x00004D3B, 0x00006613, + 0x00004D8B, 0x000065D6, 0x00004DDB, 0x00006599, + 0x00004E2A, 0x0000655C, 0x00004E7A, 0x0000651E, + 0x00004EC9, 0x000064E0, 0x00004F18, 0x000064A2, + 0x00004F67, 0x00006464, 0x00004FB6, 0x00006426, + 0x00005005, 0x000063E7, 0x00005053, 0x000063A8, + 0x000050A1, 0x00006369, 0x000050EF, 0x00006329, + 0x0000513D, 0x000062EA, 0x0000518B, 0x000062AA, + 0x000051D8, 0x00006269, 0x00005225, 0x00006229, + 0x00005272, 0x000061E8, 0x000052BF, 0x000061A8, + 0x0000530C, 0x00006166, 0x00005358, 0x00006125, + 0x000053A4, 0x000060E4, 0x000053F0, 0x000060A2, + 0x0000543C, 0x00006060, 0x00005488, 0x0000601D, + 0x000054D3, 0x00005FDB, 0x0000551E, 0x00005F98, + 0x00005569, 0x00005F55, 0x000055B4, 0x00005F12, + 0x000055FE, 0x00005ECF, 0x00005649, 0x00005E8B, + 0x00005693, 0x00005E47, 0x000056DD, 0x00005E03, + 0x00005727, 0x00005DBF, 0x00005770, 0x00005D7A, + 0x000057B9, 0x00005D35, 0x00005803, 0x00005CF0, + 0x0000584B, 0x00005CAB, 0x00005894, 0x00005C66, + 0x000058DD, 0x00005C20, 0x00005925, 0x00005BDA, + 0x0000596D, 0x00005B94, 0x000059B5, 0x00005B4D, + 0x000059FC, 0x00005B07, 0x00005A44, 0x00005AC0, + 0x00005A8B, 0x00005A79, 0x00005AD2, 0x00005A32, + 0x00005B19, 0x000059EA, 0x00005B5F, 0x000059A3, + 0x00005BA5, 0x0000595B, 0x00005BEB, 0x00005913, + 0x00005C31, 0x000058CB, 0x00005C77, 0x00005882, + 0x00005CBC, 0x00005839, 0x00005D01, 0x000057F0, + 0x00005D46, 0x000057A7, 0x00005D8B, 0x0000575E, + 0x00005DD0, 0x00005714, 0x00005E14, 0x000056CA, + 0x00005E58, 0x00005680, 0x00005E9C, 0x00005636, + 0x00005EDF, 0x000055EC, 0x00005F23, 0x000055A1, + 0x00005F66, 0x00005556, 0x00005FA9, 0x0000550B, + 0x00005FEC, 0x000054C0, 0x0000602E, 0x00005475, + 0x00006070, 0x00005429, 0x000060B2, 0x000053DD, + 0x000060F4, 0x00005391, 0x00006135, 0x00005345, + 0x00006177, 0x000052F8, 0x000061B8, 0x000052AC, + 0x000061F9, 0x0000525F, 0x00006239, 0x00005212, + 0x0000627A, 0x000051C5, 0x000062BA, 0x00005177, + 0x000062F9, 0x0000512A, 0x00006339, 0x000050DC, + 0x00006378, 0x0000508E, 0x000063B8, 0x00005040, + 0x000063F7, 0x00004FF1, 0x00006435, 0x00004FA2, + 0x00006474, 0x00004F54, 0x000064B2, 0x00004F05, + 0x000064F0, 0x00004EB6, 0x0000652D, 0x00004E66, + 0x0000656B, 0x00004E17, 0x000065A8, 0x00004DC7, + 0x000065E5, 0x00004D77, 0x00006622, 0x00004D27, + 0x0000665E, 0x00004CD6, 0x0000669B, 0x00004C86, + 0x000066D6, 0x00004C35, 0x00006712, 0x00004BE4, + 0x0000674E, 0x00004B93, 0x00006789, 0x00004B42, + 0x000067C4, 0x00004AF1, 0x000067FF, 0x00004A9F, + 0x00006839, 0x00004A4D, 0x00006873, 0x000049FB, + 0x000068AD, 0x000049A9, 0x000068E7, 0x00004957, + 0x00006921, 0x00004905, 0x0000695A, 0x000048B2, + 0x00006993, 0x0000485F, 0x000069CB, 0x0000480C, + 0x00006A04, 0x000047B9, 0x00006A3C, 0x00004766, + 0x00006A74, 0x00004712, 0x00006AAC, 0x000046BE, + 0x00006AE3, 0x0000466A, 0x00006B1A, 0x00004616, + 0x00006B51, 0x000045C2, 0x00006B88, 0x0000456E, + 0x00006BBE, 0x00004519, 0x00006BF5, 0x000044C5, + 0x00006C2A, 0x00004470, 0x00006C60, 0x0000441B, + 0x00006C95, 0x000043C5, 0x00006CCA, 0x00004370, + 0x00006CFF, 0x0000431B, 0x00006D34, 0x000042C5, + 0x00006D68, 0x0000426F, 0x00006D9C, 0x00004219, + 0x00006DD0, 0x000041C3, 0x00006E04, 0x0000416D, + 0x00006E37, 0x00004116, 0x00006E6A, 0x000040BF, + 0x00006E9C, 0x00004069, 0x00006ECF, 0x00004012, + 0x00006F01, 0x00003FBB, 0x00006F33, 0x00003F63, + 0x00006F65, 0x00003F0C, 0x00006F96, 0x00003EB4, + 0x00006FC7, 0x00003E5D, 0x00006FF8, 0x00003E05, + 0x00007029, 0x00003DAD, 0x00007059, 0x00003D55, + 0x00007089, 0x00003CFC, 0x000070B9, 0x00003CA4, + 0x000070E8, 0x00003C4B, 0x00007117, 0x00003BF2, + 0x00007146, 0x00003B99, 0x00007175, 0x00003B40, + 0x000071A3, 0x00003AE7, 0x000071D2, 0x00003A8E, + 0x000071FF, 0x00003A34, 0x0000722D, 0x000039DB, + 0x0000725A, 0x00003981, 0x00007287, 0x00003927, + 0x000072B4, 0x000038CD, 0x000072E1, 0x00003873, + 0x0000730D, 0x00003819, 0x00007339, 0x000037BE, + 0x00007364, 0x00003764, 0x00007390, 0x00003709, + 0x000073BB, 0x000036AE, 0x000073E6, 0x00003653, + 0x00007410, 0x000035F8, 0x0000743A, 0x0000359D, + 0x00007464, 0x00003542, 0x0000748E, 0x000034E6, + 0x000074B7, 0x0000348B, 0x000074E1, 0x0000342F, + 0x00007509, 0x000033D3, 0x00007532, 0x00003377, + 0x0000755A, 0x0000331B, 0x00007582, 0x000032BF, + 0x000075AA, 0x00003262, 0x000075D1, 0x00003206, + 0x000075F9, 0x000031A9, 0x0000761F, 0x0000314C, + 0x00007646, 0x000030F0, 0x0000766C, 0x00003093, + 0x00007692, 0x00003036, 0x000076B8, 0x00002FD8, + 0x000076DD, 0x00002F7B, 0x00007703, 0x00002F1E, + 0x00007727, 0x00002EC0, 0x0000774C, 0x00002E63, + 0x00007770, 0x00002E05, 0x00007794, 0x00002DA7, + 0x000077B8, 0x00002D49, 0x000077DB, 0x00002CEB, + 0x000077FF, 0x00002C8D, 0x00007821, 0x00002C2E, + 0x00007844, 0x00002BD0, 0x00007866, 0x00002B71, + 0x00007888, 0x00002B13, 0x000078AA, 0x00002AB4, + 0x000078CB, 0x00002A55, 0x000078EC, 0x000029F6, + 0x0000790D, 0x00002997, 0x0000792E, 0x00002938, + 0x0000794E, 0x000028D9, 0x0000796E, 0x0000287A, + 0x0000798E, 0x0000281A, 0x000079AD, 0x000027BB, + 0x000079CC, 0x0000275B, 0x000079EB, 0x000026FB, + 0x00007A09, 0x0000269C, 0x00007A27, 0x0000263C, + 0x00007A45, 0x000025DC, 0x00007A63, 0x0000257C, + 0x00007A80, 0x0000251C, 0x00007A9D, 0x000024BB, + 0x00007ABA, 0x0000245B, 0x00007AD6, 0x000023FA, + 0x00007AF2, 0x0000239A, 0x00007B0E, 0x00002339, + 0x00007B2A, 0x000022D9, 0x00007B45, 0x00002278, + 0x00007B60, 0x00002217, 0x00007B7A, 0x000021B6, + 0x00007B95, 0x00002155, 0x00007BAF, 0x000020F4, + 0x00007BC9, 0x00002093, 0x00007BE2, 0x00002032, + 0x00007BFB, 0x00001FD0, 0x00007C14, 0x00001F6F, + 0x00007C2D, 0x00001F0D, 0x00007C45, 0x00001EAC, + 0x00007C5D, 0x00001E4A, 0x00007C74, 0x00001DE8, + 0x00007C8C, 0x00001D87, 0x00007CA3, 0x00001D25, + 0x00007CB9, 0x00001CC3, 0x00007CD0, 0x00001C61, + 0x00007CE6, 0x00001BFF, 0x00007CFC, 0x00001B9D, + 0x00007D11, 0x00001B3A, 0x00007D27, 0x00001AD8, + 0x00007D3C, 0x00001A76, 0x00007D50, 0x00001A13, + 0x00007D65, 0x000019B1, 0x00007D79, 0x0000194E, + 0x00007D8C, 0x000018EC, 0x00007DA0, 0x00001889, + 0x00007DB3, 0x00001827, 0x00007DC6, 0x000017C4, + 0x00007DD8, 0x00001761, 0x00007DEA, 0x000016FE, + 0x00007DFC, 0x0000169B, 0x00007E0E, 0x00001638, + 0x00007E1F, 0x000015D5, 0x00007E30, 0x00001572, + 0x00007E41, 0x0000150F, 0x00007E51, 0x000014AC, + 0x00007E61, 0x00001449, 0x00007E71, 0x000013E5, + 0x00007E81, 0x00001382, 0x00007E90, 0x0000131F, + 0x00007E9F, 0x000012BB, 0x00007EAD, 0x00001258, + 0x00007EBB, 0x000011F4, 0x00007EC9, 0x00001191, + 0x00007ED7, 0x0000112D, 0x00007EE4, 0x000010C9, + 0x00007EF1, 0x00001066, 0x00007EFE, 0x00001002, + 0x00007F0B, 0x00000F9E, 0x00007F17, 0x00000F3A, + 0x00007F23, 0x00000ED7, 0x00007F2E, 0x00000E73, + 0x00007F39, 0x00000E0F, 0x00007F44, 0x00000DAB, + 0x00007F4F, 0x00000D47, 0x00007F59, 0x00000CE3, + 0x00007F63, 0x00000C7F, 0x00007F6D, 0x00000C1B, + 0x00007F76, 0x00000BB7, 0x00007F7F, 0x00000B53, + 0x00007F88, 0x00000AEE, 0x00007F90, 0x00000A8A, + 0x00007F98, 0x00000A26, 0x00007FA0, 0x000009C2, + 0x00007FA8, 0x0000095E, 0x00007FAF, 0x000008F9, + 0x00007FB6, 0x00000895, 0x00007FBC, 0x00000831, + 0x00007FC3, 0x000007CC, 0x00007FC9, 0x00000768, + 0x00007FCE, 0x00000704, 0x00007FD4, 0x0000069F, + 0x00007FD9, 0x0000063B, 0x00007FDD, 0x000005D6, + 0x00007FE2, 0x00000572, 0x00007FE6, 0x0000050D, + 0x00007FEA, 0x000004A9, 0x00007FED, 0x00000445, + 0x00007FF0, 0x000003E0, 0x00007FF3, 0x0000037C, + 0x00007FF6, 0x00000317, 0x00007FF8, 0x000002B3, + 0x00007FFA, 0x0000024E, 0x00007FFC, 0x000001EA, + 0x00007FFD, 0x00000185, 0x00007FFE, 0x00000121, + 0x00007FFF, 0x000000BC, 0x00007FFF, 0x00000057, + 0x00000004, 0x00005A82, 0x00000027, 0x00005A82, + 0x0000004B, 0x00005A82, 0x0000006F, 0x00005A82, + 0x00000092, 0x00005A82, 0x000000B6, 0x00005A81, + 0x000000D9, 0x00005A81, 0x000000FD, 0x00005A81, + 0x00000120, 0x00005A80, 0x00000144, 0x00005A80, + 0x00000167, 0x00005A7F, 0x0000018B, 0x00005A7F, + 0x000001AE, 0x00005A7E, 0x000001D2, 0x00005A7D, + 0x000001F6, 0x00005A7D, 0x00000219, 0x00005A7C, + 0x0000023D, 0x00005A7B, 0x00000260, 0x00005A7A, + 0x00000284, 0x00005A79, 0x000002A7, 0x00005A78, + 0x000002CB, 0x00005A77, 0x000002EE, 0x00005A76, + 0x00000312, 0x00005A75, 0x00000335, 0x00005A73, + 0x00000359, 0x00005A72, 0x0000037C, 0x00005A71, + 0x000003A0, 0x00005A6F, 0x000003C3, 0x00005A6E, + 0x000003E7, 0x00005A6C, 0x0000040A, 0x00005A6B, + 0x0000042E, 0x00005A69, 0x00000451, 0x00005A68, + 0x00000475, 0x00005A66, 0x00000498, 0x00005A64, + 0x000004BC, 0x00005A62, 0x000004DF, 0x00005A60, + 0x00000503, 0x00005A5E, 0x00000526, 0x00005A5C, + 0x0000054A, 0x00005A5A, 0x0000056D, 0x00005A58, + 0x00000591, 0x00005A56, 0x000005B4, 0x00005A54, + 0x000005D8, 0x00005A52, 0x000005FB, 0x00005A4F, + 0x0000061F, 0x00005A4D, 0x00000642, 0x00005A4A, + 0x00000666, 0x00005A48, 0x00000689, 0x00005A45, + 0x000006AC, 0x00005A43, 0x000006D0, 0x00005A40, + 0x000006F3, 0x00005A3E, 0x00000717, 0x00005A3B, + 0x0000073A, 0x00005A38, 0x0000075E, 0x00005A35, + 0x00000781, 0x00005A32, 0x000007A4, 0x00005A2F, + 0x000007C8, 0x00005A2C, 0x000007EB, 0x00005A29, + 0x0000080F, 0x00005A26, 0x00000832, 0x00005A23, + 0x00000855, 0x00005A1F, 0x00000879, 0x00005A1C, + 0x0000089C, 0x00005A19, 0x000008C0, 0x00005A15, + 0x000008E3, 0x00005A12, 0x00000906, 0x00005A0E, + 0x0000092A, 0x00005A0B, 0x0000094D, 0x00005A07, + 0x00000970, 0x00005A04, 0x00000994, 0x00005A00, + 0x000009B7, 0x000059FC, 0x000009DA, 0x000059F8, + 0x000009FE, 0x000059F4, 0x00000A21, 0x000059F0, + 0x00000A44, 0x000059EC, 0x00000A68, 0x000059E8, + 0x00000A8B, 0x000059E4, 0x00000AAE, 0x000059E0, + 0x00000AD2, 0x000059DC, 0x00000AF5, 0x000059D8, + 0x00000B18, 0x000059D3, 0x00000B3B, 0x000059CF, + 0x00000B5F, 0x000059CA, 0x00000B82, 0x000059C6, + 0x00000BA5, 0x000059C1, 0x00000BC9, 0x000059BD, + 0x00000BEC, 0x000059B8, 0x00000C0F, 0x000059B3, + 0x00000C32, 0x000059AF, 0x00000C55, 0x000059AA, + 0x00000C79, 0x000059A5, 0x00000C9C, 0x000059A0, + 0x00000CBF, 0x0000599B, 0x00000CE2, 0x00005996, + 0x00000D05, 0x00005991, 0x00000D29, 0x0000598C, + 0x00000D4C, 0x00005987, 0x00000D6F, 0x00005981, + 0x00000D92, 0x0000597C, 0x00000DB5, 0x00005977, + 0x00000DD8, 0x00005971, 0x00000DFB, 0x0000596C, + 0x00000E1F, 0x00005966, 0x00000E42, 0x00005961, + 0x00000E65, 0x0000595B, 0x00000E88, 0x00005955, + 0x00000EAB, 0x00005950, 0x00000ECE, 0x0000594A, + 0x00000EF1, 0x00005944, 0x00000F14, 0x0000593E, + 0x00000F37, 0x00005938, 0x00000F5A, 0x00005932, + 0x00000F7D, 0x0000592C, 0x00000FA0, 0x00005926, + 0x00000FC3, 0x00005920, 0x00000FE6, 0x0000591A, + 0x00001009, 0x00005913, 0x0000102C, 0x0000590D, + 0x0000104F, 0x00005907, 0x00001072, 0x00005900, + 0x00001095, 0x000058FA, 0x000010B8, 0x000058F3, + 0x000010DB, 0x000058ED, 0x000010FE, 0x000058E6, + 0x00001121, 0x000058DF, 0x00001144, 0x000058D8, + 0x00001166, 0x000058D2, 0x00001189, 0x000058CB, + 0x000011AC, 0x000058C4, 0x000011CF, 0x000058BD, + 0x000011F2, 0x000058B6, 0x00001215, 0x000058AF, + 0x00001238, 0x000058A8, 0x0000125A, 0x000058A1, + 0x0000127D, 0x00005899, 0x000012A0, 0x00005892, + 0x000012C3, 0x0000588B, 0x000012E5, 0x00005883, + 0x00001308, 0x0000587C, 0x0000132B, 0x00005874, + 0x0000134E, 0x0000586D, 0x00001370, 0x00005865, + 0x00001393, 0x0000585D, 0x000013B6, 0x00005856, + 0x000013D9, 0x0000584E, 0x000013FB, 0x00005846, + 0x0000141E, 0x0000583E, 0x00001440, 0x00005836, + 0x00001463, 0x0000582E, 0x00001486, 0x00005826, + 0x000014A8, 0x0000581E, 0x000014CB, 0x00005816, + 0x000014EE, 0x0000580E, 0x00001510, 0x00005806, + 0x00001533, 0x000057FD, 0x00001555, 0x000057F5, + 0x00001578, 0x000057ED, 0x0000159A, 0x000057E4, + 0x000015BD, 0x000057DC, 0x000015DF, 0x000057D3, + 0x00001602, 0x000057CB, 0x00001624, 0x000057C2, + 0x00001647, 0x000057B9, 0x00001669, 0x000057B0, + 0x0000168C, 0x000057A8, 0x000016AE, 0x0000579F, + 0x000016D0, 0x00005796, 0x000016F3, 0x0000578D, + 0x00001715, 0x00005784, 0x00001738, 0x0000577B, + 0x0000175A, 0x00005771, 0x0000177C, 0x00005768, + 0x0000179F, 0x0000575F, 0x000017C1, 0x00005756, + 0x000017E3, 0x0000574C, 0x00001805, 0x00005743, + 0x00001828, 0x00005739, 0x0000184A, 0x00005730, + 0x0000186C, 0x00005726, 0x0000188E, 0x0000571D, + 0x000018B1, 0x00005713, 0x000018D3, 0x00005709, + 0x000018F5, 0x00005700, 0x00001917, 0x000056F6, + 0x00001939, 0x000056EC, 0x0000195B, 0x000056E2, + 0x0000197D, 0x000056D8, 0x000019A0, 0x000056CE, + 0x000019C2, 0x000056C4, 0x000019E4, 0x000056BA, + 0x00001A06, 0x000056B0, 0x00001A28, 0x000056A5, + 0x00001A4A, 0x0000569B, 0x00001A6C, 0x00005691, + 0x00001A8E, 0x00005686, 0x00001AB0, 0x0000567C, + 0x00001AD2, 0x00005671, 0x00001AF4, 0x00005667, + 0x00001B16, 0x0000565C, 0x00001B37, 0x00005651, + 0x00001B59, 0x00005647, 0x00001B7B, 0x0000563C, + 0x00001B9D, 0x00005631, 0x00001BBF, 0x00005626, + 0x00001BE1, 0x0000561B, 0x00001C03, 0x00005610, + 0x00001C24, 0x00005605, 0x00001C46, 0x000055FA, + 0x00001C68, 0x000055EF, 0x00001C8A, 0x000055E4, + 0x00001CAB, 0x000055D9, 0x00001CCD, 0x000055CD, + 0x00001CEF, 0x000055C2, 0x00001D10, 0x000055B7, + 0x00001D32, 0x000055AB, 0x00001D54, 0x000055A0, + 0x00001D75, 0x00005594, 0x00001D97, 0x00005589, + 0x00001DB8, 0x0000557D, 0x00001DDA, 0x00005571, + 0x00001DFC, 0x00005566, 0x00001E1D, 0x0000555A, + 0x00001E3F, 0x0000554E, 0x00001E60, 0x00005542, + 0x00001E82, 0x00005536, 0x00001EA3, 0x0000552A, + 0x00001EC4, 0x0000551E, 0x00001EE6, 0x00005512, + 0x00001F07, 0x00005506, 0x00001F29, 0x000054F9, + 0x00001F4A, 0x000054ED, 0x00001F6B, 0x000054E1, + 0x00001F8D, 0x000054D5, 0x00001FAE, 0x000054C8, + 0x00001FCF, 0x000054BC, 0x00001FF1, 0x000054AF, + 0x00002012, 0x000054A3, 0x00002033, 0x00005496, + 0x00002054, 0x00005489, 0x00002075, 0x0000547D, + 0x00002097, 0x00005470, 0x000020B8, 0x00005463, + 0x000020D9, 0x00005456, 0x000020FA, 0x00005449, + 0x0000211B, 0x0000543C, 0x0000213C, 0x0000542F, + 0x0000215D, 0x00005422, 0x0000217E, 0x00005415, + 0x0000219F, 0x00005408, 0x000021C0, 0x000053FB, + 0x000021E1, 0x000053ED, 0x00002202, 0x000053E0, + 0x00002223, 0x000053D3, 0x00002244, 0x000053C5, + 0x00002265, 0x000053B8, 0x00002286, 0x000053AA, + 0x000022A7, 0x0000539D, 0x000022C7, 0x0000538F, + 0x000022E8, 0x00005381, 0x00002309, 0x00005373, + 0x0000232A, 0x00005366, 0x0000234A, 0x00005358, + 0x0000236B, 0x0000534A, 0x0000238C, 0x0000533C, + 0x000023AD, 0x0000532E, 0x000023CD, 0x00005320, + 0x000023EE, 0x00005312, 0x0000240E, 0x00005304, + 0x0000242F, 0x000052F6, 0x00002450, 0x000052E7, + 0x00002470, 0x000052D9, 0x00002491, 0x000052CB, + 0x000024B1, 0x000052BC, 0x000024D2, 0x000052AE, + 0x000024F2, 0x0000529F, 0x00002513, 0x00005291, + 0x00002533, 0x00005282, 0x00002553, 0x00005274, + 0x00002574, 0x00005265, 0x00002594, 0x00005256, + 0x000025B4, 0x00005248, 0x000025D5, 0x00005239, + 0x000025F5, 0x0000522A, 0x00002615, 0x0000521B, + 0x00002635, 0x0000520C, 0x00002656, 0x000051FD, + 0x00002676, 0x000051EE, 0x00002696, 0x000051DF, + 0x000026B6, 0x000051CF, 0x000026D6, 0x000051C0, + 0x000026F6, 0x000051B1, 0x00002716, 0x000051A2, + 0x00002736, 0x00005192, 0x00002757, 0x00005183, + 0x00002777, 0x00005173, 0x00002796, 0x00005164, + 0x000027B6, 0x00005154, 0x000027D6, 0x00005145, + 0x000027F6, 0x00005135, 0x00002816, 0x00005125, + 0x00002836, 0x00005115, 0x00002856, 0x00005106, + 0x00002876, 0x000050F6, 0x00002895, 0x000050E6, + 0x000028B5, 0x000050D6, 0x000028D5, 0x000050C6, + 0x000028F5, 0x000050B6, 0x00002914, 0x000050A6, + 0x00002934, 0x00005096, 0x00002954, 0x00005085, + 0x00002973, 0x00005075, 0x00002993, 0x00005065, + 0x000029B2, 0x00005054, 0x000029D2, 0x00005044, + 0x000029F1, 0x00005034, 0x00002A11, 0x00005023, + 0x00002A30, 0x00005013, 0x00002A50, 0x00005002, + 0x00002A6F, 0x00004FF1, 0x00002A8F, 0x00004FE1, + 0x00002AAE, 0x00004FD0, 0x00002ACD, 0x00004FBF, + 0x00002AED, 0x00004FAE, 0x00002B0C, 0x00004F9D, + 0x00002B2B, 0x00004F8D, 0x00002B4A, 0x00004F7C, + 0x00002B69, 0x00004F6B, 0x00002B89, 0x00004F59, + 0x00002BA8, 0x00004F48, 0x00002BC7, 0x00004F37, + 0x00002BE6, 0x00004F26, 0x00002C05, 0x00004F15, + 0x00002C24, 0x00004F03, 0x00002C43, 0x00004EF2, + 0x00002C62, 0x00004EE1, 0x00002C81, 0x00004ECF, + 0x00002CA0, 0x00004EBE, 0x00002CBF, 0x00004EAC, + 0x00002CDE, 0x00004E9A, 0x00002CFD, 0x00004E89, + 0x00002D1C, 0x00004E77, 0x00002D3A, 0x00004E65, + 0x00002D59, 0x00004E54, 0x00002D78, 0x00004E42, + 0x00002D97, 0x00004E30, 0x00002DB5, 0x00004E1E, + 0x00002DD4, 0x00004E0C, 0x00002DF3, 0x00004DFA, + 0x00002E11, 0x00004DE8, 0x00002E30, 0x00004DD6, + 0x00002E4E, 0x00004DC4, 0x00002E6D, 0x00004DB1, + 0x00002E8B, 0x00004D9F, 0x00002EAA, 0x00004D8D, + 0x00002EC8, 0x00004D7B, 0x00002EE7, 0x00004D68, + 0x00002F05, 0x00004D56, 0x00002F23, 0x00004D43, + 0x00002F42, 0x00004D31, 0x00002F60, 0x00004D1E, + 0x00002F7E, 0x00004D0B, 0x00002F9D, 0x00004CF9, + 0x00002FBB, 0x00004CE6, 0x00002FD9, 0x00004CD3, + 0x00002FF7, 0x00004CC0, 0x00003015, 0x00004CAE, + 0x00003033, 0x00004C9B, 0x00003051, 0x00004C88, + 0x0000306F, 0x00004C75, 0x0000308D, 0x00004C62, + 0x000030AB, 0x00004C4F, 0x000030C9, 0x00004C3C, + 0x000030E7, 0x00004C28, 0x00003105, 0x00004C15, + 0x00003123, 0x00004C02, 0x00003141, 0x00004BEF, + 0x0000315F, 0x00004BDB, 0x0000317C, 0x00004BC8, + 0x0000319A, 0x00004BB4, 0x000031B8, 0x00004BA1, + 0x000031D6, 0x00004B8D, 0x000031F3, 0x00004B7A, + 0x00003211, 0x00004B66, 0x0000322E, 0x00004B52, + 0x0000324C, 0x00004B3F, 0x0000326A, 0x00004B2B, + 0x00003287, 0x00004B17, 0x000032A5, 0x00004B03, + 0x000032C2, 0x00004AEF, 0x000032DF, 0x00004ADB, + 0x000032FD, 0x00004AC7, 0x0000331A, 0x00004AB3, + 0x00003337, 0x00004A9F, 0x00003355, 0x00004A8B, + 0x00003372, 0x00004A77, 0x0000338F, 0x00004A63, + 0x000033AC, 0x00004A4E, 0x000033CA, 0x00004A3A, + 0x000033E7, 0x00004A26, 0x00003404, 0x00004A11, + 0x00003421, 0x000049FD, 0x0000343E, 0x000049E8, + 0x0000345B, 0x000049D4, 0x00003478, 0x000049BF, + 0x00003495, 0x000049AB, 0x000034B2, 0x00004996, + 0x000034CF, 0x00004981, 0x000034EB, 0x0000496C, + 0x00003508, 0x00004958, 0x00003525, 0x00004943, + 0x00003542, 0x0000492E, 0x0000355F, 0x00004919, + 0x0000357B, 0x00004904, 0x00003598, 0x000048EF, + 0x000035B5, 0x000048DA, 0x000035D1, 0x000048C5, + 0x000035EE, 0x000048B0, 0x0000360A, 0x0000489A, + 0x00003627, 0x00004885, 0x00003643, 0x00004870, + 0x00003660, 0x0000485A, 0x0000367C, 0x00004845, + 0x00003698, 0x00004830, 0x000036B5, 0x0000481A, + 0x000036D1, 0x00004805, 0x000036ED, 0x000047EF, + 0x0000370A, 0x000047DA, 0x00003726, 0x000047C4, + 0x00003742, 0x000047AE, 0x0000375E, 0x00004799, + 0x0000377A, 0x00004783, 0x00003796, 0x0000476D, + 0x000037B2, 0x00004757, 0x000037CE, 0x00004741, + 0x000037EA, 0x0000472B, 0x00003806, 0x00004715, + 0x00003822, 0x000046FF, 0x0000383E, 0x000046E9, + 0x0000385A, 0x000046D3, 0x00003875, 0x000046BD, + 0x00003891, 0x000046A7, 0x000038AD, 0x00004691, + 0x000038C9, 0x0000467A, 0x000038E4, 0x00004664, + 0x00003900, 0x0000464E, 0x0000391C, 0x00004637, + 0x00003937, 0x00004621, 0x00003953, 0x0000460A, + 0x0000396E, 0x000045F4, 0x0000398A, 0x000045DD, + 0x000039A5, 0x000045C7, 0x000039C0, 0x000045B0, + 0x000039DC, 0x00004599, 0x000039F7, 0x00004582, + 0x00003A12, 0x0000456C, 0x00003A2E, 0x00004555, + 0x00003A49, 0x0000453E, 0x00003A64, 0x00004527, + 0x00003A7F, 0x00004510, 0x00003A9A, 0x000044F9, + 0x00003AB5, 0x000044E2, 0x00003AD0, 0x000044CB, + 0x00003AEB, 0x000044B4, 0x00003B06, 0x0000449D, + 0x00003B21, 0x00004485, 0x00003B3C, 0x0000446E, + 0x00003B57, 0x00004457, 0x00003B72, 0x00004440, + 0x00003B8D, 0x00004428, 0x00003BA7, 0x00004411, + 0x00003BC2, 0x000043F9, 0x00003BDD, 0x000043E2, + 0x00003BF7, 0x000043CA, 0x00003C12, 0x000043B3, + 0x00003C2C, 0x0000439B, 0x00003C47, 0x00004384, + 0x00003C62, 0x0000436C, 0x00003C7C, 0x00004354, + 0x00003C96, 0x0000433C, 0x00003CB1, 0x00004325, + 0x00003CCB, 0x0000430D, 0x00003CE5, 0x000042F5, + 0x00003D00, 0x000042DD, 0x00003D1A, 0x000042C5, + 0x00003D34, 0x000042AD, 0x00003D4E, 0x00004295, + 0x00003D68, 0x0000427D, 0x00003D83, 0x00004265, + 0x00003D9D, 0x0000424C, 0x00003DB7, 0x00004234, + 0x00003DD1, 0x0000421C, 0x00003DEB, 0x00004204, + 0x00003E04, 0x000041EB, 0x00003E1E, 0x000041D3, + 0x00003E38, 0x000041BB, 0x00003E52, 0x000041A2, + 0x00003E6C, 0x0000418A, 0x00003E85, 0x00004171, + 0x00003E9F, 0x00004158, 0x00003EB9, 0x00004140, + 0x00003ED2, 0x00004127, 0x00003EEC, 0x0000410F, + 0x00003F05, 0x000040F6, 0x00003F1F, 0x000040DD, + 0x00003F38, 0x000040C4, 0x00003F52, 0x000040AB, + 0x00003F6B, 0x00004092, 0x00003F85, 0x0000407A, + 0x00003F9E, 0x00004061, 0x00003FB7, 0x00004048, + 0x00003FD0, 0x0000402F, 0x00003FE9, 0x00004015, + 0x00004003, 0x00003FFC, 0x0000401C, 0x00003FE3, + 0x00004035, 0x00003FCA, 0x0000404E, 0x00003FB1, + 0x00004067, 0x00003F98, 0x00004080, 0x00003F7E, + 0x00004099, 0x00003F65, 0x000040B2, 0x00003F4B, + 0x000040CA, 0x00003F32, 0x000040E3, 0x00003F19, + 0x000040FC, 0x00003EFF, 0x00004115, 0x00003EE6, + 0x0000412D, 0x00003ECC, 0x00004146, 0x00003EB2, + 0x0000415F, 0x00003E99, 0x00004177, 0x00003E7F, + 0x00004190, 0x00003E65, 0x000041A8, 0x00003E4B, + 0x000041C1, 0x00003E32, 0x000041D9, 0x00003E18, + 0x000041F1, 0x00003DFE, 0x0000420A, 0x00003DE4, + 0x00004222, 0x00003DCA, 0x0000423A, 0x00003DB0, + 0x00004252, 0x00003D96, 0x0000426B, 0x00003D7C, + 0x00004283, 0x00003D62, 0x0000429B, 0x00003D48, + 0x000042B3, 0x00003D2E, 0x000042CB, 0x00003D13, + 0x000042E3, 0x00003CF9, 0x000042FB, 0x00003CDF, + 0x00004313, 0x00003CC5, 0x0000432B, 0x00003CAA, + 0x00004342, 0x00003C90, 0x0000435A, 0x00003C75, + 0x00004372, 0x00003C5B, 0x00004389, 0x00003C40, + 0x000043A1, 0x00003C26, 0x000043B9, 0x00003C0B, + 0x000043D0, 0x00003BF1, 0x000043E8, 0x00003BD6, + 0x000043FF, 0x00003BBB, 0x00004417, 0x00003BA1, + 0x0000442E, 0x00003B86, 0x00004445, 0x00003B6B, + 0x0000445D, 0x00003B50, 0x00004474, 0x00003B35, + 0x0000448B, 0x00003B1A, 0x000044A2, 0x00003B00, + 0x000044BA, 0x00003AE5, 0x000044D1, 0x00003ACA, + 0x000044E8, 0x00003AAF, 0x000044FF, 0x00003A93, + 0x00004516, 0x00003A78, 0x0000452D, 0x00003A5D, + 0x00004544, 0x00003A42, 0x0000455B, 0x00003A27, + 0x00004571, 0x00003A0C, 0x00004588, 0x000039F0, + 0x0000459F, 0x000039D5, 0x000045B6, 0x000039BA, + 0x000045CC, 0x0000399E, 0x000045E3, 0x00003983, + 0x000045F9, 0x00003967, 0x00004610, 0x0000394C, + 0x00004626, 0x00003930, 0x0000463D, 0x00003915, + 0x00004653, 0x000038F9, 0x0000466A, 0x000038DD, + 0x00004680, 0x000038C2, 0x00004696, 0x000038A6, + 0x000046AC, 0x0000388A, 0x000046C3, 0x0000386F, + 0x000046D9, 0x00003853, 0x000046EF, 0x00003837, + 0x00004705, 0x0000381B, 0x0000471B, 0x000037FF, + 0x00004731, 0x000037E3, 0x00004747, 0x000037C7, + 0x0000475D, 0x000037AB, 0x00004772, 0x0000378F, + 0x00004788, 0x00003773, 0x0000479E, 0x00003757, + 0x000047B4, 0x0000373B, 0x000047C9, 0x0000371F, + 0x000047DF, 0x00003702, 0x000047F5, 0x000036E6, + 0x0000480A, 0x000036CA, 0x00004820, 0x000036AE, + 0x00004835, 0x00003691, 0x0000484A, 0x00003675, + 0x00004860, 0x00003659, 0x00004875, 0x0000363C, + 0x0000488A, 0x00003620, 0x000048A0, 0x00003603, + 0x000048B5, 0x000035E7, 0x000048CA, 0x000035CA, + 0x000048DF, 0x000035AD, 0x000048F4, 0x00003591, + 0x00004909, 0x00003574, 0x0000491E, 0x00003557, + 0x00004933, 0x0000353B, 0x00004948, 0x0000351E, + 0x0000495D, 0x00003501, 0x00004972, 0x000034E4, + 0x00004986, 0x000034C7, 0x0000499B, 0x000034AB, + 0x000049B0, 0x0000348E, 0x000049C4, 0x00003471, + 0x000049D9, 0x00003454, 0x000049ED, 0x00003437, + 0x00004A02, 0x0000341A, 0x00004A16, 0x000033FD, + 0x00004A2B, 0x000033DF, 0x00004A3F, 0x000033C2, + 0x00004A53, 0x000033A5, 0x00004A68, 0x00003388, + 0x00004A7C, 0x0000336B, 0x00004A90, 0x0000334D, + 0x00004AA4, 0x00003330, 0x00004AB8, 0x00003313, + 0x00004ACC, 0x000032F5, 0x00004AE0, 0x000032D8, + 0x00004AF4, 0x000032BB, 0x00004B08, 0x0000329D, + 0x00004B1C, 0x00003280, 0x00004B30, 0x00003262, + 0x00004B44, 0x00003245, 0x00004B57, 0x00003227, + 0x00004B6B, 0x00003209, 0x00004B7F, 0x000031EC, + 0x00004B92, 0x000031CE, 0x00004BA6, 0x000031B0, + 0x00004BB9, 0x00003193, 0x00004BCD, 0x00003175, + 0x00004BE0, 0x00003157, 0x00004BF3, 0x00003139, + 0x00004C07, 0x0000311C, 0x00004C1A, 0x000030FE, + 0x00004C2D, 0x000030E0, 0x00004C40, 0x000030C2, + 0x00004C53, 0x000030A4, 0x00004C67, 0x00003086, + 0x00004C7A, 0x00003068, 0x00004C8D, 0x0000304A, + 0x00004C9F, 0x0000302C, 0x00004CB2, 0x0000300E, + 0x00004CC5, 0x00002FF0, 0x00004CD8, 0x00002FD1, + 0x00004CEB, 0x00002FB3, 0x00004CFD, 0x00002F95, + 0x00004D10, 0x00002F77, 0x00004D23, 0x00002F58, + 0x00004D35, 0x00002F3A, 0x00004D48, 0x00002F1C, + 0x00004D5A, 0x00002EFD, 0x00004D6D, 0x00002EDF, + 0x00004D7F, 0x00002EC1, 0x00004D91, 0x00002EA2, + 0x00004DA4, 0x00002E84, 0x00004DB6, 0x00002E65, + 0x00004DC8, 0x00002E47, 0x00004DDA, 0x00002E28, + 0x00004DEC, 0x00002E0A, 0x00004DFF, 0x00002DEB, + 0x00004E11, 0x00002DCC, 0x00004E22, 0x00002DAE, + 0x00004E34, 0x00002D8F, 0x00004E46, 0x00002D70, + 0x00004E58, 0x00002D51, 0x00004E6A, 0x00002D33, + 0x00004E7C, 0x00002D14, 0x00004E8D, 0x00002CF5, + 0x00004E9F, 0x00002CD6, 0x00004EB0, 0x00002CB7, + 0x00004EC2, 0x00002C98, 0x00004ED4, 0x00002C79, + 0x00004EE5, 0x00002C5A, 0x00004EF6, 0x00002C3B, + 0x00004F08, 0x00002C1C, 0x00004F19, 0x00002BFD, + 0x00004F2A, 0x00002BDE, 0x00004F3B, 0x00002BBF, + 0x00004F4D, 0x00002BA0, 0x00004F5E, 0x00002B81, + 0x00004F6F, 0x00002B62, 0x00004F80, 0x00002B42, + 0x00004F91, 0x00002B23, 0x00004FA2, 0x00002B04, + 0x00004FB3, 0x00002AE5, 0x00004FC3, 0x00002AC5, + 0x00004FD4, 0x00002AA6, 0x00004FE5, 0x00002A87, + 0x00004FF6, 0x00002A67, 0x00005006, 0x00002A48, + 0x00005017, 0x00002A28, 0x00005027, 0x00002A09, + 0x00005038, 0x000029EA, 0x00005048, 0x000029CA, + 0x00005059, 0x000029AA, 0x00005069, 0x0000298B, + 0x00005079, 0x0000296B, 0x00005089, 0x0000294C, + 0x0000509A, 0x0000292C, 0x000050AA, 0x0000290C, + 0x000050BA, 0x000028ED, 0x000050CA, 0x000028CD, + 0x000050DA, 0x000028AD, 0x000050EA, 0x0000288D, + 0x000050FA, 0x0000286E, 0x0000510A, 0x0000284E, + 0x00005119, 0x0000282E, 0x00005129, 0x0000280E, + 0x00005139, 0x000027EE, 0x00005149, 0x000027CE, + 0x00005158, 0x000027AE, 0x00005168, 0x0000278E, + 0x00005177, 0x0000276F, 0x00005187, 0x0000274F, + 0x00005196, 0x0000272E, 0x000051A5, 0x0000270E, + 0x000051B5, 0x000026EE, 0x000051C4, 0x000026CE, + 0x000051D3, 0x000026AE, 0x000051E2, 0x0000268E, + 0x000051F2, 0x0000266E, 0x00005201, 0x0000264E, + 0x00005210, 0x0000262D, 0x0000521F, 0x0000260D, + 0x0000522E, 0x000025ED, 0x0000523C, 0x000025CD, + 0x0000524B, 0x000025AC, 0x0000525A, 0x0000258C, + 0x00005269, 0x0000256C, 0x00005277, 0x0000254B, + 0x00005286, 0x0000252B, 0x00005295, 0x0000250A, + 0x000052A3, 0x000024EA, 0x000052B2, 0x000024CA, + 0x000052C0, 0x000024A9, 0x000052CE, 0x00002489, + 0x000052DD, 0x00002468, 0x000052EB, 0x00002447, + 0x000052F9, 0x00002427, 0x00005307, 0x00002406, + 0x00005315, 0x000023E6, 0x00005324, 0x000023C5, + 0x00005332, 0x000023A4, 0x00005340, 0x00002384, + 0x0000534D, 0x00002363, 0x0000535B, 0x00002342, + 0x00005369, 0x00002322, 0x00005377, 0x00002301, + 0x00005385, 0x000022E0, 0x00005392, 0x000022BF, + 0x000053A0, 0x0000229E, 0x000053AD, 0x0000227E, + 0x000053BB, 0x0000225D, 0x000053C8, 0x0000223C, + 0x000053D6, 0x0000221B, 0x000053E3, 0x000021FA, + 0x000053F1, 0x000021D9, 0x000053FE, 0x000021B8, + 0x0000540B, 0x00002197, 0x00005418, 0x00002176, + 0x00005425, 0x00002155, 0x00005432, 0x00002134, + 0x0000543F, 0x00002113, 0x0000544C, 0x000020F2, + 0x00005459, 0x000020D1, 0x00005466, 0x000020AF, + 0x00005473, 0x0000208E, 0x00005480, 0x0000206D, + 0x0000548C, 0x0000204C, 0x00005499, 0x0000202B, + 0x000054A6, 0x00002009, 0x000054B2, 0x00001FE8, + 0x000054BF, 0x00001FC7, 0x000054CB, 0x00001FA6, + 0x000054D8, 0x00001F84, 0x000054E4, 0x00001F63, + 0x000054F0, 0x00001F42, 0x000054FD, 0x00001F20, + 0x00005509, 0x00001EFF, 0x00005515, 0x00001EDE, + 0x00005521, 0x00001EBC, 0x0000552D, 0x00001E9B, + 0x00005539, 0x00001E79, 0x00005545, 0x00001E58, + 0x00005551, 0x00001E36, 0x0000555D, 0x00001E15, + 0x00005568, 0x00001DF3, 0x00005574, 0x00001DD2, + 0x00005580, 0x00001DB0, 0x0000558C, 0x00001D8E, + 0x00005597, 0x00001D6D, 0x000055A3, 0x00001D4B, + 0x000055AE, 0x00001D2A, 0x000055BA, 0x00001D08, + 0x000055C5, 0x00001CE6, 0x000055D0, 0x00001CC5, + 0x000055DC, 0x00001CA3, 0x000055E7, 0x00001C81, + 0x000055F2, 0x00001C5F, 0x000055FD, 0x00001C3E, + 0x00005608, 0x00001C1C, 0x00005613, 0x00001BFA, + 0x0000561E, 0x00001BD8, 0x00005629, 0x00001BB6, + 0x00005634, 0x00001B95, 0x0000563F, 0x00001B73, + 0x00005649, 0x00001B51, 0x00005654, 0x00001B2F, + 0x0000565F, 0x00001B0D, 0x00005669, 0x00001AEB, + 0x00005674, 0x00001AC9, 0x0000567E, 0x00001AA7, + 0x00005689, 0x00001A85, 0x00005693, 0x00001A63, + 0x0000569E, 0x00001A41, 0x000056A8, 0x00001A1F, + 0x000056B2, 0x000019FD, 0x000056BC, 0x000019DB, + 0x000056C6, 0x000019B9, 0x000056D0, 0x00001997, + 0x000056DA, 0x00001975, 0x000056E4, 0x00001953, + 0x000056EE, 0x00001931, 0x000056F8, 0x0000190F, + 0x00005702, 0x000018EC, 0x0000570C, 0x000018CA, + 0x00005716, 0x000018A8, 0x0000571F, 0x00001886, + 0x00005729, 0x00001864, 0x00005732, 0x00001841, + 0x0000573C, 0x0000181F, 0x00005745, 0x000017FD, + 0x0000574F, 0x000017DB, 0x00005758, 0x000017B8, + 0x00005761, 0x00001796, 0x0000576B, 0x00001774, + 0x00005774, 0x00001751, 0x0000577D, 0x0000172F, + 0x00005786, 0x0000170D, 0x0000578F, 0x000016EA, + 0x00005798, 0x000016C8, 0x000057A1, 0x000016A5, + 0x000057AA, 0x00001683, 0x000057B3, 0x00001661, + 0x000057BB, 0x0000163E, 0x000057C4, 0x0000161C, + 0x000057CD, 0x000015F9, 0x000057D5, 0x000015D7, + 0x000057DE, 0x000015B4, 0x000057E6, 0x00001592, + 0x000057EF, 0x0000156F, 0x000057F7, 0x0000154D, + 0x000057FF, 0x0000152A, 0x00005808, 0x00001507, + 0x00005810, 0x000014E5, 0x00005818, 0x000014C2, + 0x00005820, 0x000014A0, 0x00005828, 0x0000147D, + 0x00005830, 0x0000145A, 0x00005838, 0x00001438, + 0x00005840, 0x00001415, 0x00005848, 0x000013F3, + 0x00005850, 0x000013D0, 0x00005858, 0x000013AD, + 0x0000585F, 0x0000138A, 0x00005867, 0x00001368, + 0x0000586F, 0x00001345, 0x00005876, 0x00001322, + 0x0000587E, 0x00001300, 0x00005885, 0x000012DD, + 0x0000588C, 0x000012BA, 0x00005894, 0x00001297, + 0x0000589B, 0x00001274, 0x000058A2, 0x00001252, + 0x000058A9, 0x0000122F, 0x000058B1, 0x0000120C, + 0x000058B8, 0x000011E9, 0x000058BF, 0x000011C6, + 0x000058C6, 0x000011A3, 0x000058CD, 0x00001181, + 0x000058D3, 0x0000115E, 0x000058DA, 0x0000113B, + 0x000058E1, 0x00001118, 0x000058E8, 0x000010F5, + 0x000058EE, 0x000010D2, 0x000058F5, 0x000010AF, + 0x000058FB, 0x0000108C, 0x00005902, 0x00001069, + 0x00005908, 0x00001046, 0x0000590F, 0x00001023, + 0x00005915, 0x00001000, 0x0000591B, 0x00000FDD, + 0x00005921, 0x00000FBA, 0x00005928, 0x00000F97, + 0x0000592E, 0x00000F74, 0x00005934, 0x00000F51, + 0x0000593A, 0x00000F2E, 0x00005940, 0x00000F0B, + 0x00005945, 0x00000EE8, 0x0000594B, 0x00000EC5, + 0x00005951, 0x00000EA2, 0x00005957, 0x00000E7F, + 0x0000595C, 0x00000E5C, 0x00005962, 0x00000E39, + 0x00005968, 0x00000E16, 0x0000596D, 0x00000DF3, + 0x00005973, 0x00000DCF, 0x00005978, 0x00000DAC, + 0x0000597D, 0x00000D89, 0x00005983, 0x00000D66, + 0x00005988, 0x00000D43, 0x0000598D, 0x00000D20, + 0x00005992, 0x00000CFD, 0x00005997, 0x00000CD9, + 0x0000599C, 0x00000CB6, 0x000059A1, 0x00000C93, + 0x000059A6, 0x00000C70, 0x000059AB, 0x00000C4D, + 0x000059B0, 0x00000C29, 0x000059B5, 0x00000C06, + 0x000059B9, 0x00000BE3, 0x000059BE, 0x00000BC0, + 0x000059C2, 0x00000B9C, 0x000059C7, 0x00000B79, + 0x000059CB, 0x00000B56, 0x000059D0, 0x00000B33, + 0x000059D4, 0x00000B0F, 0x000059D9, 0x00000AEC, + 0x000059DD, 0x00000AC9, 0x000059E1, 0x00000AA6, + 0x000059E5, 0x00000A82, 0x000059E9, 0x00000A5F, + 0x000059ED, 0x00000A3C, 0x000059F1, 0x00000A18, + 0x000059F5, 0x000009F5, 0x000059F9, 0x000009D2, + 0x000059FD, 0x000009AE, 0x00005A01, 0x0000098B, + 0x00005A04, 0x00000968, 0x00005A08, 0x00000944, + 0x00005A0C, 0x00000921, 0x00005A0F, 0x000008FE, + 0x00005A13, 0x000008DA, 0x00005A16, 0x000008B7, + 0x00005A1A, 0x00000893, 0x00005A1D, 0x00000870, + 0x00005A20, 0x0000084D, 0x00005A24, 0x00000829, + 0x00005A27, 0x00000806, 0x00005A2A, 0x000007E2, + 0x00005A2D, 0x000007BF, 0x00005A30, 0x0000079C, + 0x00005A33, 0x00000778, 0x00005A36, 0x00000755, + 0x00005A39, 0x00000731, 0x00005A3B, 0x0000070E, + 0x00005A3E, 0x000006EA, 0x00005A41, 0x000006C7, + 0x00005A44, 0x000006A4, 0x00005A46, 0x00000680, + 0x00005A49, 0x0000065D, 0x00005A4B, 0x00000639, + 0x00005A4E, 0x00000616, 0x00005A50, 0x000005F2, + 0x00005A52, 0x000005CF, 0x00005A54, 0x000005AB, + 0x00005A57, 0x00000588, 0x00005A59, 0x00000564, + 0x00005A5B, 0x00000541, 0x00005A5D, 0x0000051D, + 0x00005A5F, 0x000004FA, 0x00005A61, 0x000004D6, + 0x00005A63, 0x000004B3, 0x00005A65, 0x0000048F, + 0x00005A66, 0x0000046C, 0x00005A68, 0x00000448, + 0x00005A6A, 0x00000425, 0x00005A6B, 0x00000401, + 0x00005A6D, 0x000003DE, 0x00005A6E, 0x000003BA, + 0x00005A70, 0x00000397, 0x00005A71, 0x00000373, + 0x00005A72, 0x00000350, 0x00005A74, 0x0000032C, + 0x00005A75, 0x00000309, 0x00005A76, 0x000002E5, + 0x00005A77, 0x000002C2, 0x00005A78, 0x0000029E, + 0x00005A79, 0x0000027B, 0x00005A7A, 0x00000257, + 0x00005A7B, 0x00000234, 0x00005A7C, 0x00000210, + 0x00005A7D, 0x000001ED, 0x00005A7D, 0x000001C9, + 0x00005A7E, 0x000001A6, 0x00005A7F, 0x00000182, + 0x00005A7F, 0x0000015E, 0x00005A80, 0x0000013B, + 0x00005A80, 0x00000117, 0x00005A81, 0x000000F4, + 0x00005A81, 0x000000D0, 0x00005A81, 0x000000AD, + 0x00005A82, 0x00000089, 0x00005A82, 0x00000066, + 0x00005A82, 0x00000042, 0x00005A82, 0x0000001F, + 0x00000001, 0x00004000, 0x0000000E, 0x00003FFF, + 0x0000001A, 0x00003FFF, 0x00000027, 0x00003FFF, + 0x00000033, 0x00003FFF, 0x00000040, 0x00003FFF, + 0x0000004C, 0x00003FFF, 0x00000059, 0x00003FFF, + 0x00000066, 0x00003FFF, 0x00000072, 0x00003FFF, + 0x0000007F, 0x00003FFF, 0x0000008B, 0x00003FFF, + 0x00000098, 0x00003FFF, 0x000000A4, 0x00003FFF, + 0x000000B1, 0x00003FFF, 0x000000BE, 0x00003FFE, + 0x000000CA, 0x00003FFE, 0x000000D7, 0x00003FFE, + 0x000000E3, 0x00003FFE, 0x000000F0, 0x00003FFE, + 0x000000FC, 0x00003FFE, 0x00000109, 0x00003FFD, + 0x00000116, 0x00003FFD, 0x00000122, 0x00003FFD, + 0x0000012F, 0x00003FFD, 0x0000013B, 0x00003FFC, + 0x00000148, 0x00003FFC, 0x00000154, 0x00003FFC, + 0x00000161, 0x00003FFC, 0x0000016D, 0x00003FFB, + 0x0000017A, 0x00003FFB, 0x00000187, 0x00003FFB, + 0x00000193, 0x00003FFB, 0x000001A0, 0x00003FFA, + 0x000001AC, 0x00003FFA, 0x000001B9, 0x00003FFA, + 0x000001C5, 0x00003FF9, 0x000001D2, 0x00003FF9, + 0x000001DF, 0x00003FF8, 0x000001EB, 0x00003FF8, + 0x000001F8, 0x00003FF8, 0x00000204, 0x00003FF7, + 0x00000211, 0x00003FF7, 0x0000021D, 0x00003FF7, + 0x0000022A, 0x00003FF6, 0x00000236, 0x00003FF6, + 0x00000243, 0x00003FF5, 0x00000250, 0x00003FF5, + 0x0000025C, 0x00003FF4, 0x00000269, 0x00003FF4, + 0x00000275, 0x00003FF3, 0x00000282, 0x00003FF3, + 0x0000028E, 0x00003FF2, 0x0000029B, 0x00003FF2, + 0x000002A7, 0x00003FF1, 0x000002B4, 0x00003FF1, + 0x000002C1, 0x00003FF0, 0x000002CD, 0x00003FF0, + 0x000002DA, 0x00003FEF, 0x000002E6, 0x00003FEF, + 0x000002F3, 0x00003FEE, 0x000002FF, 0x00003FED, + 0x0000030C, 0x00003FED, 0x00000318, 0x00003FEC, + 0x00000325, 0x00003FEC, 0x00000332, 0x00003FEB, + 0x0000033E, 0x00003FEA, 0x0000034B, 0x00003FEA, + 0x00000357, 0x00003FE9, 0x00000364, 0x00003FE8, + 0x00000370, 0x00003FE8, 0x0000037D, 0x00003FE7, + 0x00000389, 0x00003FE6, 0x00000396, 0x00003FE6, + 0x000003A2, 0x00003FE5, 0x000003AF, 0x00003FE4, + 0x000003BC, 0x00003FE4, 0x000003C8, 0x00003FE3, + 0x000003D5, 0x00003FE2, 0x000003E1, 0x00003FE1, + 0x000003EE, 0x00003FE1, 0x000003FA, 0x00003FE0, + 0x00000407, 0x00003FDF, 0x00000413, 0x00003FDE, + 0x00000420, 0x00003FDD, 0x0000042C, 0x00003FDD, + 0x00000439, 0x00003FDC, 0x00000446, 0x00003FDB, + 0x00000452, 0x00003FDA, 0x0000045F, 0x00003FD9, + 0x0000046B, 0x00003FD8, 0x00000478, 0x00003FD7, + 0x00000484, 0x00003FD7, 0x00000491, 0x00003FD6, + 0x0000049D, 0x00003FD5, 0x000004AA, 0x00003FD4, + 0x000004B6, 0x00003FD3, 0x000004C3, 0x00003FD2, + 0x000004CF, 0x00003FD1, 0x000004DC, 0x00003FD0, + 0x000004E8, 0x00003FCF, 0x000004F5, 0x00003FCE, + 0x00000502, 0x00003FCD, 0x0000050E, 0x00003FCC, + 0x0000051B, 0x00003FCB, 0x00000527, 0x00003FCA, + 0x00000534, 0x00003FC9, 0x00000540, 0x00003FC8, + 0x0000054D, 0x00003FC7, 0x00000559, 0x00003FC6, + 0x00000566, 0x00003FC5, 0x00000572, 0x00003FC4, + 0x0000057F, 0x00003FC3, 0x0000058B, 0x00003FC2, + 0x00000598, 0x00003FC1, 0x000005A4, 0x00003FC0, + 0x000005B1, 0x00003FBF, 0x000005BD, 0x00003FBD, + 0x000005CA, 0x00003FBC, 0x000005D6, 0x00003FBB, + 0x000005E3, 0x00003FBA, 0x000005EF, 0x00003FB9, + 0x000005FC, 0x00003FB8, 0x00000608, 0x00003FB6, + 0x00000615, 0x00003FB5, 0x00000621, 0x00003FB4, + 0x0000062E, 0x00003FB3, 0x0000063A, 0x00003FB2, + 0x00000647, 0x00003FB0, 0x00000653, 0x00003FAF, + 0x00000660, 0x00003FAE, 0x0000066C, 0x00003FAD, + 0x00000679, 0x00003FAB, 0x00000685, 0x00003FAA, + 0x00000692, 0x00003FA9, 0x0000069E, 0x00003FA8, + 0x000006AB, 0x00003FA6, 0x000006B7, 0x00003FA5, + 0x000006C4, 0x00003FA4, 0x000006D0, 0x00003FA2, + 0x000006DD, 0x00003FA1, 0x000006E9, 0x00003FA0, + 0x000006F6, 0x00003F9E, 0x00000702, 0x00003F9D, + 0x0000070F, 0x00003F9B, 0x0000071B, 0x00003F9A, + 0x00000728, 0x00003F99, 0x00000734, 0x00003F97, + 0x00000741, 0x00003F96, 0x0000074D, 0x00003F94, + 0x0000075A, 0x00003F93, 0x00000766, 0x00003F92, + 0x00000773, 0x00003F90, 0x0000077F, 0x00003F8F, + 0x0000078C, 0x00003F8D, 0x00000798, 0x00003F8C, + 0x000007A5, 0x00003F8A, 0x000007B1, 0x00003F89, + 0x000007BE, 0x00003F87, 0x000007CA, 0x00003F86, + 0x000007D7, 0x00003F84, 0x000007E3, 0x00003F83, + 0x000007F0, 0x00003F81, 0x000007FC, 0x00003F7F, + 0x00000809, 0x00003F7E, 0x00000815, 0x00003F7C, + 0x00000821, 0x00003F7B, 0x0000082E, 0x00003F79, + 0x0000083A, 0x00003F77, 0x00000847, 0x00003F76, + 0x00000853, 0x00003F74, 0x00000860, 0x00003F73, + 0x0000086C, 0x00003F71, 0x00000879, 0x00003F6F, + 0x00000885, 0x00003F6E, 0x00000892, 0x00003F6C, + 0x0000089E, 0x00003F6A, 0x000008AA, 0x00003F69, + 0x000008B7, 0x00003F67, 0x000008C3, 0x00003F65, + 0x000008D0, 0x00003F63, 0x000008DC, 0x00003F62, + 0x000008E9, 0x00003F60, 0x000008F5, 0x00003F5E, + 0x00000902, 0x00003F5C, 0x0000090E, 0x00003F5B, + 0x0000091A, 0x00003F59, 0x00000927, 0x00003F57, + 0x00000933, 0x00003F55, 0x00000940, 0x00003F53, + 0x0000094C, 0x00003F52, 0x00000959, 0x00003F50, + 0x00000965, 0x00003F4E, 0x00000972, 0x00003F4C, + 0x0000097E, 0x00003F4A, 0x0000098A, 0x00003F48, + 0x00000997, 0x00003F46, 0x000009A3, 0x00003F45, + 0x000009B0, 0x00003F43, 0x000009BC, 0x00003F41, + 0x000009C8, 0x00003F3F, 0x000009D5, 0x00003F3D, + 0x000009E1, 0x00003F3B, 0x000009EE, 0x00003F39, + 0x000009FA, 0x00003F37, 0x00000A07, 0x00003F35, + 0x00000A13, 0x00003F33, 0x00000A1F, 0x00003F31, + 0x00000A2C, 0x00003F2F, 0x00000A38, 0x00003F2D, + 0x00000A45, 0x00003F2B, 0x00000A51, 0x00003F29, + 0x00000A5D, 0x00003F27, 0x00000A6A, 0x00003F25, + 0x00000A76, 0x00003F23, 0x00000A83, 0x00003F21, + 0x00000A8F, 0x00003F1F, 0x00000A9B, 0x00003F1D, + 0x00000AA8, 0x00003F1B, 0x00000AB4, 0x00003F19, + 0x00000AC1, 0x00003F17, 0x00000ACD, 0x00003F14, + 0x00000AD9, 0x00003F12, 0x00000AE6, 0x00003F10, + 0x00000AF2, 0x00003F0E, 0x00000AFE, 0x00003F0C, + 0x00000B0B, 0x00003F0A, 0x00000B17, 0x00003F08, + 0x00000B24, 0x00003F05, 0x00000B30, 0x00003F03, + 0x00000B3C, 0x00003F01, 0x00000B49, 0x00003EFF, + 0x00000B55, 0x00003EFD, 0x00000B61, 0x00003EFA, + 0x00000B6E, 0x00003EF8, 0x00000B7A, 0x00003EF6, + 0x00000B87, 0x00003EF4, 0x00000B93, 0x00003EF1, + 0x00000B9F, 0x00003EEF, 0x00000BAC, 0x00003EED, + 0x00000BB8, 0x00003EEA, 0x00000BC4, 0x00003EE8, + 0x00000BD1, 0x00003EE6, 0x00000BDD, 0x00003EE3, + 0x00000BE9, 0x00003EE1, 0x00000BF6, 0x00003EDF, + 0x00000C02, 0x00003EDC, 0x00000C0E, 0x00003EDA, + 0x00000C1B, 0x00003ED8, 0x00000C27, 0x00003ED5, + 0x00000C33, 0x00003ED3, 0x00000C40, 0x00003ED1, + 0x00000C4C, 0x00003ECE, 0x00000C58, 0x00003ECC, + 0x00000C65, 0x00003EC9, 0x00000C71, 0x00003EC7, + 0x00000C7D, 0x00003EC4, 0x00000C8A, 0x00003EC2, + 0x00000C96, 0x00003EBF, 0x00000CA2, 0x00003EBD, + 0x00000CAF, 0x00003EBA, 0x00000CBB, 0x00003EB8, + 0x00000CC7, 0x00003EB5, 0x00000CD4, 0x00003EB3, + 0x00000CE0, 0x00003EB0, 0x00000CEC, 0x00003EAE, + 0x00000CF9, 0x00003EAB, 0x00000D05, 0x00003EA9, + 0x00000D11, 0x00003EA6, 0x00000D1D, 0x00003EA4, + 0x00000D2A, 0x00003EA1, 0x00000D36, 0x00003E9F, + 0x00000D42, 0x00003E9C, 0x00000D4F, 0x00003E99, + 0x00000D5B, 0x00003E97, 0x00000D67, 0x00003E94, + 0x00000D74, 0x00003E91, 0x00000D80, 0x00003E8F, + 0x00000D8C, 0x00003E8C, 0x00000D98, 0x00003E89, + 0x00000DA5, 0x00003E87, 0x00000DB1, 0x00003E84, + 0x00000DBD, 0x00003E81, 0x00000DC9, 0x00003E7F, + 0x00000DD6, 0x00003E7C, 0x00000DE2, 0x00003E79, + 0x00000DEE, 0x00003E77, 0x00000DFB, 0x00003E74, + 0x00000E07, 0x00003E71, 0x00000E13, 0x00003E6E, + 0x00000E1F, 0x00003E6C, 0x00000E2C, 0x00003E69, + 0x00000E38, 0x00003E66, 0x00000E44, 0x00003E63, + 0x00000E50, 0x00003E60, 0x00000E5D, 0x00003E5E, + 0x00000E69, 0x00003E5B, 0x00000E75, 0x00003E58, + 0x00000E81, 0x00003E55, 0x00000E8E, 0x00003E52, + 0x00000E9A, 0x00003E4F, 0x00000EA6, 0x00003E4C, + 0x00000EB2, 0x00003E4A, 0x00000EBE, 0x00003E47, + 0x00000ECB, 0x00003E44, 0x00000ED7, 0x00003E41, + 0x00000EE3, 0x00003E3E, 0x00000EEF, 0x00003E3B, + 0x00000EFC, 0x00003E38, 0x00000F08, 0x00003E35, + 0x00000F14, 0x00003E32, 0x00000F20, 0x00003E2F, + 0x00000F2C, 0x00003E2C, 0x00000F39, 0x00003E29, + 0x00000F45, 0x00003E26, 0x00000F51, 0x00003E23, + 0x00000F5D, 0x00003E20, 0x00000F69, 0x00003E1D, + 0x00000F76, 0x00003E1A, 0x00000F82, 0x00003E17, + 0x00000F8E, 0x00003E14, 0x00000F9A, 0x00003E11, + 0x00000FA6, 0x00003E0E, 0x00000FB3, 0x00003E0B, + 0x00000FBF, 0x00003E08, 0x00000FCB, 0x00003E05, + 0x00000FD7, 0x00003E02, 0x00000FE3, 0x00003DFF, + 0x00000FEF, 0x00003DFB, 0x00000FFC, 0x00003DF8, + 0x00001008, 0x00003DF5, 0x00001014, 0x00003DF2, + 0x00001020, 0x00003DEF, 0x0000102C, 0x00003DEC, + 0x00001038, 0x00003DE8, 0x00001045, 0x00003DE5, + 0x00001051, 0x00003DE2, 0x0000105D, 0x00003DDF, + 0x00001069, 0x00003DDC, 0x00001075, 0x00003DD8, + 0x00001081, 0x00003DD5, 0x0000108D, 0x00003DD2, + 0x0000109A, 0x00003DCF, 0x000010A6, 0x00003DCB, + 0x000010B2, 0x00003DC8, 0x000010BE, 0x00003DC5, + 0x000010CA, 0x00003DC2, 0x000010D6, 0x00003DBE, + 0x000010E2, 0x00003DBB, 0x000010EE, 0x00003DB8, + 0x000010FB, 0x00003DB4, 0x00001107, 0x00003DB1, + 0x00001113, 0x00003DAE, 0x0000111F, 0x00003DAA, + 0x0000112B, 0x00003DA7, 0x00001137, 0x00003DA3, + 0x00001143, 0x00003DA0, 0x0000114F, 0x00003D9D, + 0x0000115B, 0x00003D99, 0x00001168, 0x00003D96, + 0x00001174, 0x00003D92, 0x00001180, 0x00003D8F, + 0x0000118C, 0x00003D8C, 0x00001198, 0x00003D88, + 0x000011A4, 0x00003D85, 0x000011B0, 0x00003D81, + 0x000011BC, 0x00003D7E, 0x000011C8, 0x00003D7A, + 0x000011D4, 0x00003D77, 0x000011E0, 0x00003D73, + 0x000011EC, 0x00003D70, 0x000011F8, 0x00003D6C, + 0x00001205, 0x00003D69, 0x00001211, 0x00003D65, + 0x0000121D, 0x00003D62, 0x00001229, 0x00003D5E, + 0x00001235, 0x00003D5A, 0x00001241, 0x00003D57, + 0x0000124D, 0x00003D53, 0x00001259, 0x00003D50, + 0x00001265, 0x00003D4C, 0x00001271, 0x00003D48, + 0x0000127D, 0x00003D45, 0x00001289, 0x00003D41, + 0x00001295, 0x00003D3E, 0x000012A1, 0x00003D3A, + 0x000012AD, 0x00003D36, 0x000012B9, 0x00003D33, + 0x000012C5, 0x00003D2F, 0x000012D1, 0x00003D2B, + 0x000012DD, 0x00003D27, 0x000012E9, 0x00003D24, + 0x000012F5, 0x00003D20, 0x00001301, 0x00003D1C, + 0x0000130D, 0x00003D19, 0x00001319, 0x00003D15, + 0x00001325, 0x00003D11, 0x00001331, 0x00003D0D, + 0x0000133D, 0x00003D0A, 0x00001349, 0x00003D06, + 0x00001355, 0x00003D02, 0x00001361, 0x00003CFE, + 0x0000136D, 0x00003CFA, 0x00001379, 0x00003CF7, + 0x00001385, 0x00003CF3, 0x00001391, 0x00003CEF, + 0x0000139D, 0x00003CEB, 0x000013A9, 0x00003CE7, + 0x000013B5, 0x00003CE3, 0x000013C1, 0x00003CDF, + 0x000013CD, 0x00003CDC, 0x000013D9, 0x00003CD8, + 0x000013E5, 0x00003CD4, 0x000013F1, 0x00003CD0, + 0x000013FC, 0x00003CCC, 0x00001408, 0x00003CC8, + 0x00001414, 0x00003CC4, 0x00001420, 0x00003CC0, + 0x0000142C, 0x00003CBC, 0x00001438, 0x00003CB8, + 0x00001444, 0x00003CB4, 0x00001450, 0x00003CB0, + 0x0000145C, 0x00003CAC, 0x00001468, 0x00003CA8, + 0x00001474, 0x00003CA4, 0x00001480, 0x00003CA0, + 0x0000148C, 0x00003C9C, 0x00001497, 0x00003C98, + 0x000014A3, 0x00003C94, 0x000014AF, 0x00003C90, + 0x000014BB, 0x00003C8C, 0x000014C7, 0x00003C88, + 0x000014D3, 0x00003C84, 0x000014DF, 0x00003C80, + 0x000014EB, 0x00003C7C, 0x000014F7, 0x00003C78, + 0x00001502, 0x00003C73, 0x0000150E, 0x00003C6F, + 0x0000151A, 0x00003C6B, 0x00001526, 0x00003C67, + 0x00001532, 0x00003C63, 0x0000153E, 0x00003C5F, + 0x0000154A, 0x00003C5A, 0x00001555, 0x00003C56, + 0x00001561, 0x00003C52, 0x0000156D, 0x00003C4E, + 0x00001579, 0x00003C4A, 0x00001585, 0x00003C45, + 0x00001591, 0x00003C41, 0x0000159C, 0x00003C3D, + 0x000015A8, 0x00003C39, 0x000015B4, 0x00003C34, + 0x000015C0, 0x00003C30, 0x000015CC, 0x00003C2C, + 0x000015D8, 0x00003C28, 0x000015E3, 0x00003C23, + 0x000015EF, 0x00003C1F, 0x000015FB, 0x00003C1B, + 0x00001607, 0x00003C16, 0x00001613, 0x00003C12, + 0x0000161E, 0x00003C0E, 0x0000162A, 0x00003C09, + 0x00001636, 0x00003C05, 0x00001642, 0x00003C01, + 0x0000164D, 0x00003BFC, 0x00001659, 0x00003BF8, + 0x00001665, 0x00003BF4, 0x00001671, 0x00003BEF, + 0x0000167D, 0x00003BEB, 0x00001688, 0x00003BE6, + 0x00001694, 0x00003BE2, 0x000016A0, 0x00003BDD, + 0x000016AC, 0x00003BD9, 0x000016B7, 0x00003BD5, + 0x000016C3, 0x00003BD0, 0x000016CF, 0x00003BCC, + 0x000016DB, 0x00003BC7, 0x000016E6, 0x00003BC3, + 0x000016F2, 0x00003BBE, 0x000016FE, 0x00003BBA, + 0x00001709, 0x00003BB5, 0x00001715, 0x00003BB1, + 0x00001721, 0x00003BAC, 0x0000172D, 0x00003BA7, + 0x00001738, 0x00003BA3, 0x00001744, 0x00003B9E, + 0x00001750, 0x00003B9A, 0x0000175B, 0x00003B95, + 0x00001767, 0x00003B91, 0x00001773, 0x00003B8C, + 0x0000177F, 0x00003B87, 0x0000178A, 0x00003B83, + 0x00001796, 0x00003B7E, 0x000017A2, 0x00003B7A, + 0x000017AD, 0x00003B75, 0x000017B9, 0x00003B70, + 0x000017C5, 0x00003B6C, 0x000017D0, 0x00003B67, + 0x000017DC, 0x00003B62, 0x000017E8, 0x00003B5E, + 0x000017F3, 0x00003B59, 0x000017FF, 0x00003B54, + 0x0000180B, 0x00003B4F, 0x00001816, 0x00003B4B, + 0x00001822, 0x00003B46, 0x0000182D, 0x00003B41, + 0x00001839, 0x00003B3C, 0x00001845, 0x00003B38, + 0x00001850, 0x00003B33, 0x0000185C, 0x00003B2E, + 0x00001868, 0x00003B29, 0x00001873, 0x00003B25, + 0x0000187F, 0x00003B20, 0x0000188A, 0x00003B1B, + 0x00001896, 0x00003B16, 0x000018A2, 0x00003B11, + 0x000018AD, 0x00003B0C, 0x000018B9, 0x00003B08, + 0x000018C4, 0x00003B03, 0x000018D0, 0x00003AFE, + 0x000018DC, 0x00003AF9, 0x000018E7, 0x00003AF4, + 0x000018F3, 0x00003AEF, 0x000018FE, 0x00003AEA, + 0x0000190A, 0x00003AE5, 0x00001915, 0x00003AE0, + 0x00001921, 0x00003ADC, 0x0000192D, 0x00003AD7, + 0x00001938, 0x00003AD2, 0x00001944, 0x00003ACD, + 0x0000194F, 0x00003AC8, 0x0000195B, 0x00003AC3, + 0x00001966, 0x00003ABE, 0x00001972, 0x00003AB9, + 0x0000197D, 0x00003AB4, 0x00001989, 0x00003AAF, + 0x00001994, 0x00003AAA, 0x000019A0, 0x00003AA5, + 0x000019AB, 0x00003AA0, 0x000019B7, 0x00003A9B, + 0x000019C2, 0x00003A96, 0x000019CE, 0x00003A91, + 0x000019D9, 0x00003A8B, 0x000019E5, 0x00003A86, + 0x000019F0, 0x00003A81, 0x000019FC, 0x00003A7C, + 0x00001A07, 0x00003A77, 0x00001A13, 0x00003A72, + 0x00001A1E, 0x00003A6D, 0x00001A2A, 0x00003A68, + 0x00001A35, 0x00003A63, 0x00001A41, 0x00003A5D, + 0x00001A4C, 0x00003A58, 0x00001A58, 0x00003A53, + 0x00001A63, 0x00003A4E, 0x00001A6F, 0x00003A49, + 0x00001A7A, 0x00003A44, 0x00001A85, 0x00003A3E, + 0x00001A91, 0x00003A39, 0x00001A9C, 0x00003A34, + 0x00001AA8, 0x00003A2F, 0x00001AB3, 0x00003A29, + 0x00001ABF, 0x00003A24, 0x00001ACA, 0x00003A1F, + 0x00001AD5, 0x00003A1A, 0x00001AE1, 0x00003A14, + 0x00001AEC, 0x00003A0F, 0x00001AF8, 0x00003A0A, + 0x00001B03, 0x00003A05, 0x00001B0E, 0x000039FF, + 0x00001B1A, 0x000039FA, 0x00001B25, 0x000039F5, + 0x00001B31, 0x000039EF, 0x00001B3C, 0x000039EA, + 0x00001B47, 0x000039E5, 0x00001B53, 0x000039DF, + 0x00001B5E, 0x000039DA, 0x00001B69, 0x000039D4, + 0x00001B75, 0x000039CF, 0x00001B80, 0x000039CA, + 0x00001B8B, 0x000039C4, 0x00001B97, 0x000039BF, + 0x00001BA2, 0x000039B9, 0x00001BAD, 0x000039B4, + 0x00001BB9, 0x000039AF, 0x00001BC4, 0x000039A9, + 0x00001BCF, 0x000039A4, 0x00001BDB, 0x0000399E, + 0x00001BE6, 0x00003999, 0x00001BF1, 0x00003993, + 0x00001BFD, 0x0000398E, 0x00001C08, 0x00003988, + 0x00001C13, 0x00003983, 0x00001C1E, 0x0000397D, + 0x00001C2A, 0x00003978, 0x00001C35, 0x00003972, + 0x00001C40, 0x0000396D, 0x00001C4C, 0x00003967, + 0x00001C57, 0x00003961, 0x00001C62, 0x0000395C, + 0x00001C6D, 0x00003956, 0x00001C79, 0x00003951, + 0x00001C84, 0x0000394B, 0x00001C8F, 0x00003946, + 0x00001C9A, 0x00003940, 0x00001CA6, 0x0000393A, + 0x00001CB1, 0x00003935, 0x00001CBC, 0x0000392F, + 0x00001CC7, 0x00003929, 0x00001CD3, 0x00003924, + 0x00001CDE, 0x0000391E, 0x00001CE9, 0x00003918, + 0x00001CF4, 0x00003913, 0x00001CFF, 0x0000390D, + 0x00001D0B, 0x00003907, 0x00001D16, 0x00003902, + 0x00001D21, 0x000038FC, 0x00001D2C, 0x000038F6, + 0x00001D37, 0x000038F0, 0x00001D43, 0x000038EB, + 0x00001D4E, 0x000038E5, 0x00001D59, 0x000038DF, + 0x00001D64, 0x000038D9, 0x00001D6F, 0x000038D4, + 0x00001D7A, 0x000038CE, 0x00001D86, 0x000038C8, + 0x00001D91, 0x000038C2, 0x00001D9C, 0x000038BC, + 0x00001DA7, 0x000038B7, 0x00001DB2, 0x000038B1, + 0x00001DBD, 0x000038AB, 0x00001DC8, 0x000038A5, + 0x00001DD3, 0x0000389F, 0x00001DDF, 0x00003899, + 0x00001DEA, 0x00003894, 0x00001DF5, 0x0000388E, + 0x00001E00, 0x00003888, 0x00001E0B, 0x00003882, + 0x00001E16, 0x0000387C, 0x00001E21, 0x00003876, + 0x00001E2C, 0x00003870, 0x00001E37, 0x0000386A, + 0x00001E42, 0x00003864, 0x00001E4D, 0x0000385E, + 0x00001E59, 0x00003858, 0x00001E64, 0x00003852, + 0x00001E6F, 0x0000384C, 0x00001E7A, 0x00003846, + 0x00001E85, 0x00003840, 0x00001E90, 0x0000383A, + 0x00001E9B, 0x00003834, 0x00001EA6, 0x0000382E, + 0x00001EB1, 0x00003828, 0x00001EBC, 0x00003822, + 0x00001EC7, 0x0000381C, 0x00001ED2, 0x00003816, + 0x00001EDD, 0x00003810, 0x00001EE8, 0x0000380A, + 0x00001EF3, 0x00003804, 0x00001EFE, 0x000037FE, + 0x00001F09, 0x000037F8, 0x00001F14, 0x000037F2, + 0x00001F1F, 0x000037EC, 0x00001F2A, 0x000037E6, + 0x00001F35, 0x000037E0, 0x00001F40, 0x000037D9, + 0x00001F4B, 0x000037D3, 0x00001F56, 0x000037CD, + 0x00001F61, 0x000037C7, 0x00001F6C, 0x000037C1, + 0x00001F77, 0x000037BB, 0x00001F82, 0x000037B4, + 0x00001F8D, 0x000037AE, 0x00001F97, 0x000037A8, + 0x00001FA2, 0x000037A2, 0x00001FAD, 0x0000379C, + 0x00001FB8, 0x00003795, 0x00001FC3, 0x0000378F, + 0x00001FCE, 0x00003789, 0x00001FD9, 0x00003783, + 0x00001FE4, 0x0000377C, 0x00001FEF, 0x00003776, + 0x00001FFA, 0x00003770, 0x00002004, 0x0000376A, + 0x0000200F, 0x00003763, 0x0000201A, 0x0000375D, + 0x00002025, 0x00003757, 0x00002030, 0x00003750, + 0x0000203B, 0x0000374A, 0x00002046, 0x00003744, + 0x00002051, 0x0000373D, 0x0000205B, 0x00003737, + 0x00002066, 0x00003731, 0x00002071, 0x0000372A, + 0x0000207C, 0x00003724, 0x00002087, 0x0000371E, + 0x00002092, 0x00003717, 0x0000209C, 0x00003711, + 0x000020A7, 0x0000370A, 0x000020B2, 0x00003704, + 0x000020BD, 0x000036FD, 0x000020C8, 0x000036F7, + 0x000020D2, 0x000036F1, 0x000020DD, 0x000036EA, + 0x000020E8, 0x000036E4, 0x000020F3, 0x000036DD, + 0x000020FD, 0x000036D7, 0x00002108, 0x000036D0, + 0x00002113, 0x000036CA, 0x0000211E, 0x000036C3, + 0x00002128, 0x000036BD, 0x00002133, 0x000036B6, + 0x0000213E, 0x000036B0, 0x00002149, 0x000036A9, + 0x00002153, 0x000036A3, 0x0000215E, 0x0000369C, + 0x00002169, 0x00003696, 0x00002174, 0x0000368F, + 0x0000217E, 0x00003688, 0x00002189, 0x00003682, + 0x00002194, 0x0000367B, 0x0000219E, 0x00003675, + 0x000021A9, 0x0000366E, 0x000021B4, 0x00003667, + 0x000021BE, 0x00003661, 0x000021C9, 0x0000365A, + 0x000021D4, 0x00003654, 0x000021DE, 0x0000364D, + 0x000021E9, 0x00003646, 0x000021F4, 0x00003640, + 0x000021FE, 0x00003639, 0x00002209, 0x00003632, + 0x00002214, 0x0000362C, 0x0000221E, 0x00003625, + 0x00002229, 0x0000361E, 0x00002234, 0x00003617, + 0x0000223E, 0x00003611, 0x00002249, 0x0000360A, + 0x00002253, 0x00003603, 0x0000225E, 0x000035FD, + 0x00002269, 0x000035F6, 0x00002273, 0x000035EF, + 0x0000227E, 0x000035E8, 0x00002288, 0x000035E1, + 0x00002293, 0x000035DB, 0x0000229E, 0x000035D4, + 0x000022A8, 0x000035CD, 0x000022B3, 0x000035C6, + 0x000022BD, 0x000035BF, 0x000022C8, 0x000035B9, + 0x000022D2, 0x000035B2, 0x000022DD, 0x000035AB, + 0x000022E7, 0x000035A4, 0x000022F2, 0x0000359D, + 0x000022FC, 0x00003596, 0x00002307, 0x00003590, + 0x00002312, 0x00003589, 0x0000231C, 0x00003582, + 0x00002327, 0x0000357B, 0x00002331, 0x00003574, + 0x0000233C, 0x0000356D, 0x00002346, 0x00003566, + 0x00002350, 0x0000355F, 0x0000235B, 0x00003558, + 0x00002365, 0x00003551, 0x00002370, 0x0000354A, + 0x0000237A, 0x00003543, 0x00002385, 0x0000353C, + 0x0000238F, 0x00003535, 0x0000239A, 0x0000352E, + 0x000023A4, 0x00003527, 0x000023AF, 0x00003520, + 0x000023B9, 0x00003519, 0x000023C3, 0x00003512, + 0x000023CE, 0x0000350B, 0x000023D8, 0x00003504, + 0x000023E3, 0x000034FD, 0x000023ED, 0x000034F6, + 0x000023F7, 0x000034EF, 0x00002402, 0x000034E8, + 0x0000240C, 0x000034E1, 0x00002417, 0x000034DA, + 0x00002421, 0x000034D3, 0x0000242B, 0x000034CC, + 0x00002436, 0x000034C5, 0x00002440, 0x000034BE, + 0x0000244A, 0x000034B6, 0x00002455, 0x000034AF, + 0x0000245F, 0x000034A8, 0x00002469, 0x000034A1, + 0x00002474, 0x0000349A, 0x0000247E, 0x00003493, + 0x00002488, 0x0000348C, 0x00002493, 0x00003484, + 0x0000249D, 0x0000347D, 0x000024A7, 0x00003476, + 0x000024B2, 0x0000346F, 0x000024BC, 0x00003468, + 0x000024C6, 0x00003460, 0x000024D1, 0x00003459, + 0x000024DB, 0x00003452, 0x000024E5, 0x0000344B, + 0x000024EF, 0x00003443, 0x000024FA, 0x0000343C, + 0x00002504, 0x00003435, 0x0000250E, 0x0000342E, + 0x00002518, 0x00003426, 0x00002523, 0x0000341F, + 0x0000252D, 0x00003418, 0x00002537, 0x00003410, + 0x00002541, 0x00003409, 0x0000254B, 0x00003402, + 0x00002556, 0x000033FA, 0x00002560, 0x000033F3, + 0x0000256A, 0x000033EC, 0x00002574, 0x000033E4, + 0x0000257E, 0x000033DD, 0x00002589, 0x000033D6, + 0x00002593, 0x000033CE, 0x0000259D, 0x000033C7, + 0x000025A7, 0x000033C0, 0x000025B1, 0x000033B8, + 0x000025BB, 0x000033B1, 0x000025C6, 0x000033A9, + 0x000025D0, 0x000033A2, 0x000025DA, 0x0000339B, + 0x000025E4, 0x00003393, 0x000025EE, 0x0000338C, + 0x000025F8, 0x00003384, 0x00002602, 0x0000337D, + 0x0000260D, 0x00003375, 0x00002617, 0x0000336E, + 0x00002621, 0x00003366, 0x0000262B, 0x0000335F, + 0x00002635, 0x00003357, 0x0000263F, 0x00003350, + 0x00002649, 0x00003348, 0x00002653, 0x00003341, + 0x0000265D, 0x00003339, 0x00002667, 0x00003332, + 0x00002671, 0x0000332A, 0x0000267B, 0x00003323, + 0x00002685, 0x0000331B, 0x0000268F, 0x00003313, + 0x00002699, 0x0000330C, 0x000026A3, 0x00003304, + 0x000026AD, 0x000032FD, 0x000026B7, 0x000032F5, + 0x000026C1, 0x000032EE, 0x000026CB, 0x000032E6, + 0x000026D5, 0x000032DE, 0x000026DF, 0x000032D7, + 0x000026E9, 0x000032CF, 0x000026F3, 0x000032C7, + 0x000026FD, 0x000032C0, 0x00002707, 0x000032B8, + 0x00002711, 0x000032B0, 0x0000271B, 0x000032A9, + 0x00002725, 0x000032A1, 0x0000272F, 0x00003299, + 0x00002739, 0x00003292, 0x00002743, 0x0000328A, + 0x0000274D, 0x00003282, 0x00002757, 0x0000327B, + 0x00002761, 0x00003273, 0x0000276B, 0x0000326B, + 0x00002774, 0x00003263, 0x0000277E, 0x0000325C, + 0x00002788, 0x00003254, 0x00002792, 0x0000324C, + 0x0000279C, 0x00003244, 0x000027A6, 0x0000323C, + 0x000027B0, 0x00003235, 0x000027BA, 0x0000322D, + 0x000027C3, 0x00003225, 0x000027CD, 0x0000321D, + 0x000027D7, 0x00003215, 0x000027E1, 0x0000320E, + 0x000027EB, 0x00003206, 0x000027F5, 0x000031FE, + 0x000027FE, 0x000031F6, 0x00002808, 0x000031EE, + 0x00002812, 0x000031E6, 0x0000281C, 0x000031DF, + 0x00002826, 0x000031D7, 0x0000282F, 0x000031CF, + 0x00002839, 0x000031C7, 0x00002843, 0x000031BF, + 0x0000284D, 0x000031B7, 0x00002856, 0x000031AF, + 0x00002860, 0x000031A7, 0x0000286A, 0x0000319F, + 0x00002874, 0x00003197, 0x0000287D, 0x0000318F, + 0x00002887, 0x00003187, 0x00002891, 0x0000317F, + 0x0000289B, 0x00003178, 0x000028A4, 0x00003170, + 0x000028AE, 0x00003168, 0x000028B8, 0x00003160, + 0x000028C1, 0x00003158, 0x000028CB, 0x00003150, + 0x000028D5, 0x00003148, 0x000028DE, 0x00003140, + 0x000028E8, 0x00003137, 0x000028F2, 0x0000312F, + 0x000028FB, 0x00003127, 0x00002905, 0x0000311F, + 0x0000290F, 0x00003117, 0x00002918, 0x0000310F, + 0x00002922, 0x00003107, 0x0000292C, 0x000030FF, + 0x00002935, 0x000030F7, 0x0000293F, 0x000030EF, + 0x00002948, 0x000030E7, 0x00002952, 0x000030DF, + 0x0000295C, 0x000030D7, 0x00002965, 0x000030CE, + 0x0000296F, 0x000030C6, 0x00002978, 0x000030BE, + 0x00002982, 0x000030B6, 0x0000298C, 0x000030AE, + 0x00002995, 0x000030A6, 0x0000299F, 0x0000309E, + 0x000029A8, 0x00003095, 0x000029B2, 0x0000308D, + 0x000029BB, 0x00003085, 0x000029C5, 0x0000307D, + 0x000029CE, 0x00003075, 0x000029D8, 0x0000306C, + 0x000029E1, 0x00003064, 0x000029EB, 0x0000305C, + 0x000029F4, 0x00003054, 0x000029FE, 0x0000304B, + 0x00002A07, 0x00003043, 0x00002A11, 0x0000303B, + 0x00002A1A, 0x00003033, 0x00002A24, 0x0000302A, + 0x00002A2D, 0x00003022, 0x00002A37, 0x0000301A, + 0x00002A40, 0x00003012, 0x00002A49, 0x00003009, + 0x00002A53, 0x00003001, 0x00002A5C, 0x00002FF9, + 0x00002A66, 0x00002FF0, 0x00002A6F, 0x00002FE8, + 0x00002A79, 0x00002FE0, 0x00002A82, 0x00002FD7, + 0x00002A8B, 0x00002FCF, 0x00002A95, 0x00002FC7, + 0x00002A9E, 0x00002FBE, 0x00002AA7, 0x00002FB6, + 0x00002AB1, 0x00002FAD, 0x00002ABA, 0x00002FA5, + 0x00002AC4, 0x00002F9D, 0x00002ACD, 0x00002F94, + 0x00002AD6, 0x00002F8C, 0x00002AE0, 0x00002F83, + 0x00002AE9, 0x00002F7B, 0x00002AF2, 0x00002F73, + 0x00002AFB, 0x00002F6A, 0x00002B05, 0x00002F62, + 0x00002B0E, 0x00002F59, 0x00002B17, 0x00002F51, + 0x00002B21, 0x00002F48, 0x00002B2A, 0x00002F40, + 0x00002B33, 0x00002F37, 0x00002B3C, 0x00002F2F, + 0x00002B46, 0x00002F26, 0x00002B4F, 0x00002F1E, + 0x00002B58, 0x00002F15, 0x00002B62, 0x00002F0D, + 0x00002B6B, 0x00002F04, 0x00002B74, 0x00002EFC, + 0x00002B7D, 0x00002EF3, 0x00002B86, 0x00002EEB, + 0x00002B90, 0x00002EE2, 0x00002B99, 0x00002EDA, + 0x00002BA2, 0x00002ED1, 0x00002BAB, 0x00002EC9, + 0x00002BB4, 0x00002EC0, 0x00002BBE, 0x00002EB7, + 0x00002BC7, 0x00002EAF, 0x00002BD0, 0x00002EA6, + 0x00002BD9, 0x00002E9E, 0x00002BE2, 0x00002E95, + 0x00002BEB, 0x00002E8C, 0x00002BF4, 0x00002E84, + 0x00002BFE, 0x00002E7B, 0x00002C07, 0x00002E72, + 0x00002C10, 0x00002E6A, 0x00002C19, 0x00002E61, + 0x00002C22, 0x00002E58, 0x00002C2B, 0x00002E50, + 0x00002C34, 0x00002E47, 0x00002C3D, 0x00002E3E, + 0x00002C46, 0x00002E36, 0x00002C4F, 0x00002E2D, + 0x00002C59, 0x00002E24, 0x00002C62, 0x00002E1C, + 0x00002C6B, 0x00002E13, 0x00002C74, 0x00002E0A, + 0x00002C7D, 0x00002E01, 0x00002C86, 0x00002DF9, + 0x00002C8F, 0x00002DF0, 0x00002C98, 0x00002DE7, + 0x00002CA1, 0x00002DDE, 0x00002CAA, 0x00002DD6, + 0x00002CB3, 0x00002DCD, 0x00002CBC, 0x00002DC4, + 0x00002CC5, 0x00002DBB, 0x00002CCE, 0x00002DB3, + 0x00002CD7, 0x00002DAA, 0x00002CE0, 0x00002DA1, + 0x00002CE9, 0x00002D98, 0x00002CF2, 0x00002D8F, + 0x00002CFB, 0x00002D87, 0x00002D03, 0x00002D7E, + 0x00002D0C, 0x00002D75, 0x00002D15, 0x00002D6C, + 0x00002D1E, 0x00002D63, 0x00002D27, 0x00002D5A, + 0x00002D30, 0x00002D51, 0x00002D39, 0x00002D49, + 0x00002D42, 0x00002D40, 0x00002D4B, 0x00002D37, + 0x00002D54, 0x00002D2E, 0x00002D5C, 0x00002D25, + 0x00002D65, 0x00002D1C, 0x00002D6E, 0x00002D13, + 0x00002D77, 0x00002D0A, 0x00002D80, 0x00002D01, + 0x00002D89, 0x00002CF8, 0x00002D92, 0x00002CEF, + 0x00002D9A, 0x00002CE6, 0x00002DA3, 0x00002CDD, + 0x00002DAC, 0x00002CD4, 0x00002DB5, 0x00002CCC, + 0x00002DBE, 0x00002CC3, 0x00002DC6, 0x00002CBA, + 0x00002DCF, 0x00002CB1, 0x00002DD8, 0x00002CA8, + 0x00002DE1, 0x00002C9F, 0x00002DE9, 0x00002C96, + 0x00002DF2, 0x00002C8D, 0x00002DFB, 0x00002C84, + 0x00002E04, 0x00002C7A, 0x00002E0C, 0x00002C71, + 0x00002E15, 0x00002C68, 0x00002E1E, 0x00002C5F, + 0x00002E27, 0x00002C56, 0x00002E2F, 0x00002C4D, + 0x00002E38, 0x00002C44, 0x00002E41, 0x00002C3B, + 0x00002E49, 0x00002C32, 0x00002E52, 0x00002C29, + 0x00002E5B, 0x00002C20, 0x00002E63, 0x00002C17, + 0x00002E6C, 0x00002C0E, 0x00002E75, 0x00002C04, + 0x00002E7D, 0x00002BFB, 0x00002E86, 0x00002BF2, + 0x00002E8F, 0x00002BE9, 0x00002E97, 0x00002BE0, + 0x00002EA0, 0x00002BD7, 0x00002EA8, 0x00002BCE, + 0x00002EB1, 0x00002BC4, 0x00002EBA, 0x00002BBB, + 0x00002EC2, 0x00002BB2, 0x00002ECB, 0x00002BA9, + 0x00002ED3, 0x00002BA0, 0x00002EDC, 0x00002B97, + 0x00002EE4, 0x00002B8D, 0x00002EED, 0x00002B84, + 0x00002EF5, 0x00002B7B, 0x00002EFE, 0x00002B72, + 0x00002F07, 0x00002B68, 0x00002F0F, 0x00002B5F, + 0x00002F18, 0x00002B56, 0x00002F20, 0x00002B4D, + 0x00002F29, 0x00002B43, 0x00002F31, 0x00002B3A, + 0x00002F3A, 0x00002B31, 0x00002F42, 0x00002B28, + 0x00002F4A, 0x00002B1E, 0x00002F53, 0x00002B15, + 0x00002F5B, 0x00002B0C, 0x00002F64, 0x00002B02, + 0x00002F6C, 0x00002AF9, 0x00002F75, 0x00002AF0, + 0x00002F7D, 0x00002AE7, 0x00002F86, 0x00002ADD, + 0x00002F8E, 0x00002AD4, 0x00002F96, 0x00002ACB, + 0x00002F9F, 0x00002AC1, 0x00002FA7, 0x00002AB8, + 0x00002FB0, 0x00002AAE, 0x00002FB8, 0x00002AA5, + 0x00002FC0, 0x00002A9C, 0x00002FC9, 0x00002A92, + 0x00002FD1, 0x00002A89, 0x00002FD9, 0x00002A80, + 0x00002FE2, 0x00002A76, 0x00002FEA, 0x00002A6D, + 0x00002FF2, 0x00002A63, 0x00002FFB, 0x00002A5A, + 0x00003003, 0x00002A51, 0x0000300B, 0x00002A47, + 0x00003014, 0x00002A3E, 0x0000301C, 0x00002A34, + 0x00003024, 0x00002A2B, 0x0000302C, 0x00002A21, + 0x00003035, 0x00002A18, 0x0000303D, 0x00002A0E, + 0x00003045, 0x00002A05, 0x0000304E, 0x000029FB, + 0x00003056, 0x000029F2, 0x0000305E, 0x000029E8, + 0x00003066, 0x000029DF, 0x0000306E, 0x000029D5, + 0x00003077, 0x000029CC, 0x0000307F, 0x000029C2, + 0x00003087, 0x000029B9, 0x0000308F, 0x000029AF, + 0x00003097, 0x000029A6, 0x000030A0, 0x0000299C, + 0x000030A8, 0x00002993, 0x000030B0, 0x00002989, + 0x000030B8, 0x00002980, 0x000030C0, 0x00002976, + 0x000030C8, 0x0000296C, 0x000030D0, 0x00002963, + 0x000030D9, 0x00002959, 0x000030E1, 0x00002950, + 0x000030E9, 0x00002946, 0x000030F1, 0x0000293C, + 0x000030F9, 0x00002933, 0x00003101, 0x00002929, + 0x00003109, 0x00002920, 0x00003111, 0x00002916, + 0x00003119, 0x0000290C, 0x00003121, 0x00002903, + 0x00003129, 0x000028F9, 0x00003131, 0x000028EF, + 0x00003139, 0x000028E6, 0x00003142, 0x000028DC, + 0x0000314A, 0x000028D2, 0x00003152, 0x000028C9, + 0x0000315A, 0x000028BF, 0x00003162, 0x000028B5, + 0x0000316A, 0x000028AC, 0x00003172, 0x000028A2, + 0x0000317A, 0x00002898, 0x00003181, 0x0000288E, + 0x00003189, 0x00002885, 0x00003191, 0x0000287B, + 0x00003199, 0x00002871, 0x000031A1, 0x00002868, + 0x000031A9, 0x0000285E, 0x000031B1, 0x00002854, + 0x000031B9, 0x0000284A, 0x000031C1, 0x00002841, + 0x000031C9, 0x00002837, 0x000031D1, 0x0000282D, + 0x000031D9, 0x00002823, 0x000031E0, 0x00002819, + 0x000031E8, 0x00002810, 0x000031F0, 0x00002806, + 0x000031F8, 0x000027FC, 0x00003200, 0x000027F2, + 0x00003208, 0x000027E8, 0x00003210, 0x000027DF, + 0x00003217, 0x000027D5, 0x0000321F, 0x000027CB, + 0x00003227, 0x000027C1, 0x0000322F, 0x000027B7, + 0x00003237, 0x000027AD, 0x0000323E, 0x000027A3, + 0x00003246, 0x0000279A, 0x0000324E, 0x00002790, + 0x00003256, 0x00002786, 0x0000325E, 0x0000277C, + 0x00003265, 0x00002772, 0x0000326D, 0x00002768, + 0x00003275, 0x0000275E, 0x0000327C, 0x00002754, + 0x00003284, 0x0000274A, 0x0000328C, 0x00002740, + 0x00003294, 0x00002737, 0x0000329B, 0x0000272D, + 0x000032A3, 0x00002723, 0x000032AB, 0x00002719, + 0x000032B2, 0x0000270F, 0x000032BA, 0x00002705, + 0x000032C2, 0x000026FB, 0x000032C9, 0x000026F1, + 0x000032D1, 0x000026E7, 0x000032D9, 0x000026DD, + 0x000032E0, 0x000026D3, 0x000032E8, 0x000026C9, + 0x000032EF, 0x000026BF, 0x000032F7, 0x000026B5, + 0x000032FF, 0x000026AB, 0x00003306, 0x000026A1, + 0x0000330E, 0x00002697, 0x00003315, 0x0000268D, + 0x0000331D, 0x00002683, 0x00003325, 0x00002679, + 0x0000332C, 0x0000266F, 0x00003334, 0x00002665, + 0x0000333B, 0x0000265B, 0x00003343, 0x00002651, + 0x0000334A, 0x00002647, 0x00003352, 0x0000263C, + 0x00003359, 0x00002632, 0x00003361, 0x00002628, + 0x00003368, 0x0000261E, 0x00003370, 0x00002614, + 0x00003377, 0x0000260A, 0x0000337F, 0x00002600, + 0x00003386, 0x000025F6, 0x0000338E, 0x000025EC, + 0x00003395, 0x000025E2, 0x0000339C, 0x000025D7, + 0x000033A4, 0x000025CD, 0x000033AB, 0x000025C3, + 0x000033B3, 0x000025B9, 0x000033BA, 0x000025AF, + 0x000033C1, 0x000025A5, 0x000033C9, 0x0000259A, + 0x000033D0, 0x00002590, 0x000033D8, 0x00002586, + 0x000033DF, 0x0000257C, 0x000033E6, 0x00002572, + 0x000033EE, 0x00002568, 0x000033F5, 0x0000255D, + 0x000033FC, 0x00002553, 0x00003404, 0x00002549, + 0x0000340B, 0x0000253F, 0x00003412, 0x00002535, + 0x0000341A, 0x0000252A, 0x00003421, 0x00002520, + 0x00003428, 0x00002516, 0x0000342F, 0x0000250C, + 0x00003437, 0x00002501, 0x0000343E, 0x000024F7, + 0x00003445, 0x000024ED, 0x0000344C, 0x000024E3, + 0x00003454, 0x000024D8, 0x0000345B, 0x000024CE, + 0x00003462, 0x000024C4, 0x00003469, 0x000024B9, + 0x00003471, 0x000024AF, 0x00003478, 0x000024A5, + 0x0000347F, 0x0000249B, 0x00003486, 0x00002490, + 0x0000348D, 0x00002486, 0x00003495, 0x0000247C, + 0x0000349C, 0x00002471, 0x000034A3, 0x00002467, + 0x000034AA, 0x0000245D, 0x000034B1, 0x00002452, + 0x000034B8, 0x00002448, 0x000034BF, 0x0000243E, + 0x000034C6, 0x00002433, 0x000034CE, 0x00002429, + 0x000034D5, 0x0000241E, 0x000034DC, 0x00002414, + 0x000034E3, 0x0000240A, 0x000034EA, 0x000023FF, + 0x000034F1, 0x000023F5, 0x000034F8, 0x000023EA, + 0x000034FF, 0x000023E0, 0x00003506, 0x000023D6, + 0x0000350D, 0x000023CB, 0x00003514, 0x000023C1, + 0x0000351B, 0x000023B6, 0x00003522, 0x000023AC, + 0x00003529, 0x000023A2, 0x00003530, 0x00002397, + 0x00003537, 0x0000238D, 0x0000353E, 0x00002382, + 0x00003545, 0x00002378, 0x0000354C, 0x0000236D, + 0x00003553, 0x00002363, 0x0000355A, 0x00002358, + 0x00003561, 0x0000234E, 0x00003568, 0x00002343, + 0x0000356F, 0x00002339, 0x00003576, 0x0000232E, + 0x0000357D, 0x00002324, 0x00003583, 0x00002319, + 0x0000358A, 0x0000230F, 0x00003591, 0x00002304, + 0x00003598, 0x000022FA, 0x0000359F, 0x000022EF, + 0x000035A6, 0x000022E5, 0x000035AD, 0x000022DA, + 0x000035B4, 0x000022D0, 0x000035BA, 0x000022C5, + 0x000035C1, 0x000022BB, 0x000035C8, 0x000022B0, + 0x000035CF, 0x000022A5, 0x000035D6, 0x0000229B, + 0x000035DC, 0x00002290, 0x000035E3, 0x00002286, + 0x000035EA, 0x0000227B, 0x000035F1, 0x00002271, + 0x000035F7, 0x00002266, 0x000035FE, 0x0000225B, + 0x00003605, 0x00002251, 0x0000360C, 0x00002246, + 0x00003612, 0x0000223C, 0x00003619, 0x00002231, + 0x00003620, 0x00002226, 0x00003627, 0x0000221C, + 0x0000362D, 0x00002211, 0x00003634, 0x00002206, + 0x0000363B, 0x000021FC, 0x00003641, 0x000021F1, + 0x00003648, 0x000021E6, 0x0000364F, 0x000021DC, + 0x00003655, 0x000021D1, 0x0000365C, 0x000021C6, + 0x00003662, 0x000021BC, 0x00003669, 0x000021B1, + 0x00003670, 0x000021A6, 0x00003676, 0x0000219C, + 0x0000367D, 0x00002191, 0x00003684, 0x00002186, + 0x0000368A, 0x0000217C, 0x00003691, 0x00002171, + 0x00003697, 0x00002166, 0x0000369E, 0x0000215B, + 0x000036A4, 0x00002151, 0x000036AB, 0x00002146, + 0x000036B1, 0x0000213B, 0x000036B8, 0x00002131, + 0x000036BE, 0x00002126, 0x000036C5, 0x0000211B, + 0x000036CB, 0x00002110, 0x000036D2, 0x00002106, + 0x000036D8, 0x000020FB, 0x000036DF, 0x000020F0, + 0x000036E5, 0x000020E5, 0x000036EC, 0x000020DA, + 0x000036F2, 0x000020D0, 0x000036F9, 0x000020C5, + 0x000036FF, 0x000020BA, 0x00003706, 0x000020AF, + 0x0000370C, 0x000020A4, 0x00003712, 0x0000209A, + 0x00003719, 0x0000208F, 0x0000371F, 0x00002084, + 0x00003726, 0x00002079, 0x0000372C, 0x0000206E, + 0x00003732, 0x00002064, 0x00003739, 0x00002059, + 0x0000373F, 0x0000204E, 0x00003745, 0x00002043, + 0x0000374C, 0x00002038, 0x00003752, 0x0000202D, + 0x00003758, 0x00002022, 0x0000375F, 0x00002018, + 0x00003765, 0x0000200D, 0x0000376B, 0x00002002, + 0x00003771, 0x00001FF7, 0x00003778, 0x00001FEC, + 0x0000377E, 0x00001FE1, 0x00003784, 0x00001FD6, + 0x0000378A, 0x00001FCB, 0x00003791, 0x00001FC0, + 0x00003797, 0x00001FB5, 0x0000379D, 0x00001FAB, + 0x000037A3, 0x00001FA0, 0x000037AA, 0x00001F95, + 0x000037B0, 0x00001F8A, 0x000037B6, 0x00001F7F, + 0x000037BC, 0x00001F74, 0x000037C2, 0x00001F69, + 0x000037C8, 0x00001F5E, 0x000037CF, 0x00001F53, + 0x000037D5, 0x00001F48, 0x000037DB, 0x00001F3D, + 0x000037E1, 0x00001F32, 0x000037E7, 0x00001F27, + 0x000037ED, 0x00001F1C, 0x000037F3, 0x00001F11, + 0x000037F9, 0x00001F06, 0x00003800, 0x00001EFB, + 0x00003806, 0x00001EF0, 0x0000380C, 0x00001EE5, + 0x00003812, 0x00001EDA, 0x00003818, 0x00001ECF, + 0x0000381E, 0x00001EC4, 0x00003824, 0x00001EB9, + 0x0000382A, 0x00001EAE, 0x00003830, 0x00001EA3, + 0x00003836, 0x00001E98, 0x0000383C, 0x00001E8D, + 0x00003842, 0x00001E82, 0x00003848, 0x00001E77, + 0x0000384E, 0x00001E6C, 0x00003854, 0x00001E61, + 0x0000385A, 0x00001E56, 0x00003860, 0x00001E4B, + 0x00003866, 0x00001E40, 0x0000386C, 0x00001E35, + 0x00003872, 0x00001E29, 0x00003878, 0x00001E1E, + 0x0000387D, 0x00001E13, 0x00003883, 0x00001E08, + 0x00003889, 0x00001DFD, 0x0000388F, 0x00001DF2, + 0x00003895, 0x00001DE7, 0x0000389B, 0x00001DDC, + 0x000038A1, 0x00001DD1, 0x000038A7, 0x00001DC6, + 0x000038AC, 0x00001DBA, 0x000038B2, 0x00001DAF, + 0x000038B8, 0x00001DA4, 0x000038BE, 0x00001D99, + 0x000038C4, 0x00001D8E, 0x000038CA, 0x00001D83, + 0x000038CF, 0x00001D78, 0x000038D5, 0x00001D6C, + 0x000038DB, 0x00001D61, 0x000038E1, 0x00001D56, + 0x000038E6, 0x00001D4B, 0x000038EC, 0x00001D40, + 0x000038F2, 0x00001D35, 0x000038F8, 0x00001D29, + 0x000038FD, 0x00001D1E, 0x00003903, 0x00001D13, + 0x00003909, 0x00001D08, 0x0000390E, 0x00001CFD, + 0x00003914, 0x00001CF1, 0x0000391A, 0x00001CE6, + 0x0000391F, 0x00001CDB, 0x00003925, 0x00001CD0, + 0x0000392B, 0x00001CC5, 0x00003930, 0x00001CB9, + 0x00003936, 0x00001CAE, 0x0000393C, 0x00001CA3, + 0x00003941, 0x00001C98, 0x00003947, 0x00001C8C, + 0x0000394D, 0x00001C81, 0x00003952, 0x00001C76, + 0x00003958, 0x00001C6B, 0x0000395D, 0x00001C5F, + 0x00003963, 0x00001C54, 0x00003968, 0x00001C49, + 0x0000396E, 0x00001C3E, 0x00003974, 0x00001C32, + 0x00003979, 0x00001C27, 0x0000397F, 0x00001C1C, + 0x00003984, 0x00001C10, 0x0000398A, 0x00001C05, + 0x0000398F, 0x00001BFA, 0x00003995, 0x00001BEE, + 0x0000399A, 0x00001BE3, 0x000039A0, 0x00001BD8, + 0x000039A5, 0x00001BCD, 0x000039AA, 0x00001BC1, + 0x000039B0, 0x00001BB6, 0x000039B5, 0x00001BAB, + 0x000039BB, 0x00001B9F, 0x000039C0, 0x00001B94, + 0x000039C6, 0x00001B89, 0x000039CB, 0x00001B7D, + 0x000039D0, 0x00001B72, 0x000039D6, 0x00001B67, + 0x000039DB, 0x00001B5B, 0x000039E0, 0x00001B50, + 0x000039E6, 0x00001B44, 0x000039EB, 0x00001B39, + 0x000039F1, 0x00001B2E, 0x000039F6, 0x00001B22, + 0x000039FB, 0x00001B17, 0x00003A01, 0x00001B0C, + 0x00003A06, 0x00001B00, 0x00003A0B, 0x00001AF5, + 0x00003A10, 0x00001AE9, 0x00003A16, 0x00001ADE, + 0x00003A1B, 0x00001AD3, 0x00003A20, 0x00001AC7, + 0x00003A25, 0x00001ABC, 0x00003A2B, 0x00001AB0, + 0x00003A30, 0x00001AA5, 0x00003A35, 0x00001A99, + 0x00003A3A, 0x00001A8E, 0x00003A40, 0x00001A83, + 0x00003A45, 0x00001A77, 0x00003A4A, 0x00001A6C, + 0x00003A4F, 0x00001A60, 0x00003A54, 0x00001A55, + 0x00003A5A, 0x00001A49, 0x00003A5F, 0x00001A3E, + 0x00003A64, 0x00001A32, 0x00003A69, 0x00001A27, + 0x00003A6E, 0x00001A1B, 0x00003A73, 0x00001A10, + 0x00003A78, 0x00001A05, 0x00003A7D, 0x000019F9, + 0x00003A83, 0x000019EE, 0x00003A88, 0x000019E2, + 0x00003A8D, 0x000019D7, 0x00003A92, 0x000019CB, + 0x00003A97, 0x000019C0, 0x00003A9C, 0x000019B4, + 0x00003AA1, 0x000019A9, 0x00003AA6, 0x0000199D, + 0x00003AAB, 0x00001992, 0x00003AB0, 0x00001986, + 0x00003AB5, 0x0000197A, 0x00003ABA, 0x0000196F, + 0x00003ABF, 0x00001963, 0x00003AC4, 0x00001958, + 0x00003AC9, 0x0000194C, 0x00003ACE, 0x00001941, + 0x00003AD3, 0x00001935, 0x00003AD8, 0x0000192A, + 0x00003ADD, 0x0000191E, 0x00003AE2, 0x00001913, + 0x00003AE7, 0x00001907, 0x00003AEC, 0x000018FB, + 0x00003AF0, 0x000018F0, 0x00003AF5, 0x000018E4, + 0x00003AFA, 0x000018D9, 0x00003AFF, 0x000018CD, + 0x00003B04, 0x000018C2, 0x00003B09, 0x000018B6, + 0x00003B0E, 0x000018AA, 0x00003B12, 0x0000189F, + 0x00003B17, 0x00001893, 0x00003B1C, 0x00001888, + 0x00003B21, 0x0000187C, 0x00003B26, 0x00001870, + 0x00003B2B, 0x00001865, 0x00003B2F, 0x00001859, + 0x00003B34, 0x0000184D, 0x00003B39, 0x00001842, + 0x00003B3E, 0x00001836, 0x00003B42, 0x0000182B, + 0x00003B47, 0x0000181F, 0x00003B4C, 0x00001813, + 0x00003B51, 0x00001808, 0x00003B55, 0x000017FC, + 0x00003B5A, 0x000017F0, 0x00003B5F, 0x000017E5, + 0x00003B63, 0x000017D9, 0x00003B68, 0x000017CD, + 0x00003B6D, 0x000017C2, 0x00003B71, 0x000017B6, + 0x00003B76, 0x000017AA, 0x00003B7B, 0x0000179F, + 0x00003B7F, 0x00001793, 0x00003B84, 0x00001787, + 0x00003B89, 0x0000177C, 0x00003B8D, 0x00001770, + 0x00003B92, 0x00001764, 0x00003B96, 0x00001759, + 0x00003B9B, 0x0000174D, 0x00003BA0, 0x00001741, + 0x00003BA4, 0x00001735, 0x00003BA9, 0x0000172A, + 0x00003BAD, 0x0000171E, 0x00003BB2, 0x00001712, + 0x00003BB6, 0x00001707, 0x00003BBB, 0x000016FB, + 0x00003BBF, 0x000016EF, 0x00003BC4, 0x000016E3, + 0x00003BC8, 0x000016D8, 0x00003BCD, 0x000016CC, + 0x00003BD1, 0x000016C0, 0x00003BD6, 0x000016B4, + 0x00003BDA, 0x000016A9, 0x00003BDF, 0x0000169D, + 0x00003BE3, 0x00001691, 0x00003BE7, 0x00001685, + 0x00003BEC, 0x0000167A, 0x00003BF0, 0x0000166E, + 0x00003BF5, 0x00001662, 0x00003BF9, 0x00001656, + 0x00003BFD, 0x0000164B, 0x00003C02, 0x0000163F, + 0x00003C06, 0x00001633, 0x00003C0B, 0x00001627, + 0x00003C0F, 0x0000161B, 0x00003C13, 0x00001610, + 0x00003C18, 0x00001604, 0x00003C1C, 0x000015F8, + 0x00003C20, 0x000015EC, 0x00003C24, 0x000015E0, + 0x00003C29, 0x000015D5, 0x00003C2D, 0x000015C9, + 0x00003C31, 0x000015BD, 0x00003C36, 0x000015B1, + 0x00003C3A, 0x000015A5, 0x00003C3E, 0x00001599, + 0x00003C42, 0x0000158E, 0x00003C47, 0x00001582, + 0x00003C4B, 0x00001576, 0x00003C4F, 0x0000156A, + 0x00003C53, 0x0000155E, 0x00003C57, 0x00001552, + 0x00003C5C, 0x00001547, 0x00003C60, 0x0000153B, + 0x00003C64, 0x0000152F, 0x00003C68, 0x00001523, + 0x00003C6C, 0x00001517, 0x00003C70, 0x0000150B, + 0x00003C74, 0x000014FF, 0x00003C79, 0x000014F4, + 0x00003C7D, 0x000014E8, 0x00003C81, 0x000014DC, + 0x00003C85, 0x000014D0, 0x00003C89, 0x000014C4, + 0x00003C8D, 0x000014B8, 0x00003C91, 0x000014AC, + 0x00003C95, 0x000014A0, 0x00003C99, 0x00001494, + 0x00003C9D, 0x00001489, 0x00003CA1, 0x0000147D, + 0x00003CA5, 0x00001471, 0x00003CA9, 0x00001465, + 0x00003CAD, 0x00001459, 0x00003CB1, 0x0000144D, + 0x00003CB5, 0x00001441, 0x00003CB9, 0x00001435, + 0x00003CBD, 0x00001429, 0x00003CC1, 0x0000141D, + 0x00003CC5, 0x00001411, 0x00003CC9, 0x00001405, + 0x00003CCD, 0x000013F9, 0x00003CD1, 0x000013EE, + 0x00003CD5, 0x000013E2, 0x00003CD9, 0x000013D6, + 0x00003CDD, 0x000013CA, 0x00003CE0, 0x000013BE, + 0x00003CE4, 0x000013B2, 0x00003CE8, 0x000013A6, + 0x00003CEC, 0x0000139A, 0x00003CF0, 0x0000138E, + 0x00003CF4, 0x00001382, 0x00003CF8, 0x00001376, + 0x00003CFB, 0x0000136A, 0x00003CFF, 0x0000135E, + 0x00003D03, 0x00001352, 0x00003D07, 0x00001346, + 0x00003D0B, 0x0000133A, 0x00003D0E, 0x0000132E, + 0x00003D12, 0x00001322, 0x00003D16, 0x00001316, + 0x00003D1A, 0x0000130A, 0x00003D1D, 0x000012FE, + 0x00003D21, 0x000012F2, 0x00003D25, 0x000012E6, + 0x00003D28, 0x000012DA, 0x00003D2C, 0x000012CE, + 0x00003D30, 0x000012C2, 0x00003D33, 0x000012B6, + 0x00003D37, 0x000012AA, 0x00003D3B, 0x0000129E, + 0x00003D3E, 0x00001292, 0x00003D42, 0x00001286, + 0x00003D46, 0x0000127A, 0x00003D49, 0x0000126E, + 0x00003D4D, 0x00001262, 0x00003D51, 0x00001256, + 0x00003D54, 0x0000124A, 0x00003D58, 0x0000123E, + 0x00003D5B, 0x00001232, 0x00003D5F, 0x00001226, + 0x00003D62, 0x0000121A, 0x00003D66, 0x0000120E, + 0x00003D6A, 0x00001202, 0x00003D6D, 0x000011F5, + 0x00003D71, 0x000011E9, 0x00003D74, 0x000011DD, + 0x00003D78, 0x000011D1, 0x00003D7B, 0x000011C5, + 0x00003D7F, 0x000011B9, 0x00003D82, 0x000011AD, + 0x00003D86, 0x000011A1, 0x00003D89, 0x00001195, + 0x00003D8C, 0x00001189, 0x00003D90, 0x0000117D, + 0x00003D93, 0x00001171, 0x00003D97, 0x00001165, + 0x00003D9A, 0x00001158, 0x00003D9E, 0x0000114C, + 0x00003DA1, 0x00001140, 0x00003DA4, 0x00001134, + 0x00003DA8, 0x00001128, 0x00003DAB, 0x0000111C, + 0x00003DAE, 0x00001110, 0x00003DB2, 0x00001104, + 0x00003DB5, 0x000010F8, 0x00003DB8, 0x000010EB, + 0x00003DBC, 0x000010DF, 0x00003DBF, 0x000010D3, + 0x00003DC2, 0x000010C7, 0x00003DC6, 0x000010BB, + 0x00003DC9, 0x000010AF, 0x00003DCC, 0x000010A3, + 0x00003DCF, 0x00001097, 0x00003DD3, 0x0000108A, + 0x00003DD6, 0x0000107E, 0x00003DD9, 0x00001072, + 0x00003DDC, 0x00001066, 0x00003DE0, 0x0000105A, + 0x00003DE3, 0x0000104E, 0x00003DE6, 0x00001042, + 0x00003DE9, 0x00001035, 0x00003DEC, 0x00001029, + 0x00003DF0, 0x0000101D, 0x00003DF3, 0x00001011, + 0x00003DF6, 0x00001005, 0x00003DF9, 0x00000FF9, + 0x00003DFC, 0x00000FEC, 0x00003DFF, 0x00000FE0, + 0x00003E02, 0x00000FD4, 0x00003E05, 0x00000FC8, + 0x00003E09, 0x00000FBC, 0x00003E0C, 0x00000FB0, + 0x00003E0F, 0x00000FA3, 0x00003E12, 0x00000F97, + 0x00003E15, 0x00000F8B, 0x00003E18, 0x00000F7F, + 0x00003E1B, 0x00000F73, 0x00003E1E, 0x00000F66, + 0x00003E21, 0x00000F5A, 0x00003E24, 0x00000F4E, + 0x00003E27, 0x00000F42, 0x00003E2A, 0x00000F36, + 0x00003E2D, 0x00000F29, 0x00003E30, 0x00000F1D, + 0x00003E33, 0x00000F11, 0x00003E36, 0x00000F05, + 0x00003E39, 0x00000EF9, 0x00003E3C, 0x00000EEC, + 0x00003E3F, 0x00000EE0, 0x00003E42, 0x00000ED4, + 0x00003E45, 0x00000EC8, 0x00003E47, 0x00000EBB, + 0x00003E4A, 0x00000EAF, 0x00003E4D, 0x00000EA3, + 0x00003E50, 0x00000E97, 0x00003E53, 0x00000E8A, + 0x00003E56, 0x00000E7E, 0x00003E59, 0x00000E72, + 0x00003E5B, 0x00000E66, 0x00003E5E, 0x00000E59, + 0x00003E61, 0x00000E4D, 0x00003E64, 0x00000E41, + 0x00003E67, 0x00000E35, 0x00003E69, 0x00000E28, + 0x00003E6C, 0x00000E1C, 0x00003E6F, 0x00000E10, + 0x00003E72, 0x00000E04, 0x00003E74, 0x00000DF7, + 0x00003E77, 0x00000DEB, 0x00003E7A, 0x00000DDF, + 0x00003E7D, 0x00000DD3, 0x00003E7F, 0x00000DC6, + 0x00003E82, 0x00000DBA, 0x00003E85, 0x00000DAE, + 0x00003E87, 0x00000DA2, 0x00003E8A, 0x00000D95, + 0x00003E8D, 0x00000D89, 0x00003E8F, 0x00000D7D, + 0x00003E92, 0x00000D70, 0x00003E95, 0x00000D64, + 0x00003E97, 0x00000D58, 0x00003E9A, 0x00000D4C, + 0x00003E9D, 0x00000D3F, 0x00003E9F, 0x00000D33, + 0x00003EA2, 0x00000D27, 0x00003EA4, 0x00000D1A, + 0x00003EA7, 0x00000D0E, 0x00003EA9, 0x00000D02, + 0x00003EAC, 0x00000CF5, 0x00003EAF, 0x00000CE9, + 0x00003EB1, 0x00000CDD, 0x00003EB4, 0x00000CD1, + 0x00003EB6, 0x00000CC4, 0x00003EB9, 0x00000CB8, + 0x00003EBB, 0x00000CAC, 0x00003EBE, 0x00000C9F, + 0x00003EC0, 0x00000C93, 0x00003EC3, 0x00000C87, + 0x00003EC5, 0x00000C7A, 0x00003EC7, 0x00000C6E, + 0x00003ECA, 0x00000C62, 0x00003ECC, 0x00000C55, + 0x00003ECF, 0x00000C49, 0x00003ED1, 0x00000C3D, + 0x00003ED4, 0x00000C30, 0x00003ED6, 0x00000C24, + 0x00003ED8, 0x00000C18, 0x00003EDB, 0x00000C0B, + 0x00003EDD, 0x00000BFF, 0x00003EDF, 0x00000BF3, + 0x00003EE2, 0x00000BE6, 0x00003EE4, 0x00000BDA, + 0x00003EE6, 0x00000BCE, 0x00003EE9, 0x00000BC1, + 0x00003EEB, 0x00000BB5, 0x00003EED, 0x00000BA9, + 0x00003EF0, 0x00000B9C, 0x00003EF2, 0x00000B90, + 0x00003EF4, 0x00000B83, 0x00003EF6, 0x00000B77, + 0x00003EF9, 0x00000B6B, 0x00003EFB, 0x00000B5E, + 0x00003EFD, 0x00000B52, 0x00003EFF, 0x00000B46, + 0x00003F02, 0x00000B39, 0x00003F04, 0x00000B2D, + 0x00003F06, 0x00000B21, 0x00003F08, 0x00000B14, + 0x00003F0A, 0x00000B08, 0x00003F0C, 0x00000AFB, + 0x00003F0F, 0x00000AEF, 0x00003F11, 0x00000AE3, + 0x00003F13, 0x00000AD6, 0x00003F15, 0x00000ACA, + 0x00003F17, 0x00000ABD, 0x00003F19, 0x00000AB1, + 0x00003F1B, 0x00000AA5, 0x00003F1D, 0x00000A98, + 0x00003F1F, 0x00000A8C, 0x00003F21, 0x00000A7F, + 0x00003F24, 0x00000A73, 0x00003F26, 0x00000A67, + 0x00003F28, 0x00000A5A, 0x00003F2A, 0x00000A4E, + 0x00003F2C, 0x00000A41, 0x00003F2E, 0x00000A35, + 0x00003F30, 0x00000A29, 0x00003F32, 0x00000A1C, + 0x00003F34, 0x00000A10, 0x00003F36, 0x00000A03, + 0x00003F38, 0x000009F7, 0x00003F3A, 0x000009EB, + 0x00003F3B, 0x000009DE, 0x00003F3D, 0x000009D2, + 0x00003F3F, 0x000009C5, 0x00003F41, 0x000009B9, + 0x00003F43, 0x000009AD, 0x00003F45, 0x000009A0, + 0x00003F47, 0x00000994, 0x00003F49, 0x00000987, + 0x00003F4B, 0x0000097B, 0x00003F4D, 0x0000096E, + 0x00003F4E, 0x00000962, 0x00003F50, 0x00000956, + 0x00003F52, 0x00000949, 0x00003F54, 0x0000093D, + 0x00003F56, 0x00000930, 0x00003F57, 0x00000924, + 0x00003F59, 0x00000917, 0x00003F5B, 0x0000090B, + 0x00003F5D, 0x000008FE, 0x00003F5F, 0x000008F2, + 0x00003F60, 0x000008E6, 0x00003F62, 0x000008D9, + 0x00003F64, 0x000008CD, 0x00003F66, 0x000008C0, + 0x00003F67, 0x000008B4, 0x00003F69, 0x000008A7, + 0x00003F6B, 0x0000089B, 0x00003F6C, 0x0000088E, + 0x00003F6E, 0x00000882, 0x00003F70, 0x00000876, + 0x00003F71, 0x00000869, 0x00003F73, 0x0000085D, + 0x00003F75, 0x00000850, 0x00003F76, 0x00000844, + 0x00003F78, 0x00000837, 0x00003F79, 0x0000082B, + 0x00003F7B, 0x0000081E, 0x00003F7D, 0x00000812, + 0x00003F7E, 0x00000805, 0x00003F80, 0x000007F9, + 0x00003F81, 0x000007EC, 0x00003F83, 0x000007E0, + 0x00003F84, 0x000007D4, 0x00003F86, 0x000007C7, + 0x00003F88, 0x000007BB, 0x00003F89, 0x000007AE, + 0x00003F8B, 0x000007A2, 0x00003F8C, 0x00000795, + 0x00003F8E, 0x00000789, 0x00003F8F, 0x0000077C, + 0x00003F90, 0x00000770, 0x00003F92, 0x00000763, + 0x00003F93, 0x00000757, 0x00003F95, 0x0000074A, + 0x00003F96, 0x0000073E, 0x00003F98, 0x00000731, + 0x00003F99, 0x00000725, 0x00003F9A, 0x00000718, + 0x00003F9C, 0x0000070C, 0x00003F9D, 0x000006FF, + 0x00003F9F, 0x000006F3, 0x00003FA0, 0x000006E6, + 0x00003FA1, 0x000006DA, 0x00003FA3, 0x000006CD, + 0x00003FA4, 0x000006C1, 0x00003FA5, 0x000006B4, + 0x00003FA7, 0x000006A8, 0x00003FA8, 0x0000069B, + 0x00003FA9, 0x0000068F, 0x00003FAA, 0x00000682, + 0x00003FAC, 0x00000676, 0x00003FAD, 0x00000669, + 0x00003FAE, 0x0000065D, 0x00003FB0, 0x00000650, + 0x00003FB1, 0x00000644, 0x00003FB2, 0x00000637, + 0x00003FB3, 0x0000062B, 0x00003FB4, 0x0000061E, + 0x00003FB6, 0x00000612, 0x00003FB7, 0x00000605, + 0x00003FB8, 0x000005F9, 0x00003FB9, 0x000005EC, + 0x00003FBA, 0x000005E0, 0x00003FBB, 0x000005D3, + 0x00003FBD, 0x000005C7, 0x00003FBE, 0x000005BA, + 0x00003FBF, 0x000005AE, 0x00003FC0, 0x000005A1, + 0x00003FC1, 0x00000595, 0x00003FC2, 0x00000588, + 0x00003FC3, 0x0000057C, 0x00003FC4, 0x0000056F, + 0x00003FC5, 0x00000563, 0x00003FC6, 0x00000556, + 0x00003FC7, 0x0000054A, 0x00003FC8, 0x0000053D, + 0x00003FCA, 0x00000531, 0x00003FCB, 0x00000524, + 0x00003FCC, 0x00000517, 0x00003FCD, 0x0000050B, + 0x00003FCE, 0x000004FE, 0x00003FCE, 0x000004F2, + 0x00003FCF, 0x000004E5, 0x00003FD0, 0x000004D9, + 0x00003FD1, 0x000004CC, 0x00003FD2, 0x000004C0, + 0x00003FD3, 0x000004B3, 0x00003FD4, 0x000004A7, + 0x00003FD5, 0x0000049A, 0x00003FD6, 0x0000048E, + 0x00003FD7, 0x00000481, 0x00003FD8, 0x00000475, + 0x00003FD9, 0x00000468, 0x00003FD9, 0x0000045B, + 0x00003FDA, 0x0000044F, 0x00003FDB, 0x00000442, + 0x00003FDC, 0x00000436, 0x00003FDD, 0x00000429, + 0x00003FDE, 0x0000041D, 0x00003FDE, 0x00000410, + 0x00003FDF, 0x00000404, 0x00003FE0, 0x000003F7, + 0x00003FE1, 0x000003EB, 0x00003FE2, 0x000003DE, + 0x00003FE2, 0x000003D2, 0x00003FE3, 0x000003C5, + 0x00003FE4, 0x000003B8, 0x00003FE4, 0x000003AC, + 0x00003FE5, 0x0000039F, 0x00003FE6, 0x00000393, + 0x00003FE7, 0x00000386, 0x00003FE7, 0x0000037A, + 0x00003FE8, 0x0000036D, 0x00003FE9, 0x00000361, + 0x00003FE9, 0x00000354, 0x00003FEA, 0x00000348, + 0x00003FEB, 0x0000033B, 0x00003FEB, 0x0000032E, + 0x00003FEC, 0x00000322, 0x00003FEC, 0x00000315, + 0x00003FED, 0x00000309, 0x00003FEE, 0x000002FC, + 0x00003FEE, 0x000002F0, 0x00003FEF, 0x000002E3, + 0x00003FEF, 0x000002D7, 0x00003FF0, 0x000002CA, + 0x00003FF0, 0x000002BD, 0x00003FF1, 0x000002B1, + 0x00003FF2, 0x000002A4, 0x00003FF2, 0x00000298, + 0x00003FF3, 0x0000028B, 0x00003FF3, 0x0000027F, + 0x00003FF4, 0x00000272, 0x00003FF4, 0x00000266, + 0x00003FF4, 0x00000259, 0x00003FF5, 0x0000024C, + 0x00003FF5, 0x00000240, 0x00003FF6, 0x00000233, + 0x00003FF6, 0x00000227, 0x00003FF7, 0x0000021A, + 0x00003FF7, 0x0000020E, 0x00003FF7, 0x00000201, + 0x00003FF8, 0x000001F5, 0x00003FF8, 0x000001E8, + 0x00003FF9, 0x000001DB, 0x00003FF9, 0x000001CF, + 0x00003FF9, 0x000001C2, 0x00003FFA, 0x000001B6, + 0x00003FFA, 0x000001A9, 0x00003FFA, 0x0000019D, + 0x00003FFB, 0x00000190, 0x00003FFB, 0x00000183, + 0x00003FFB, 0x00000177, 0x00003FFB, 0x0000016A, + 0x00003FFC, 0x0000015E, 0x00003FFC, 0x00000151, + 0x00003FFC, 0x00000145, 0x00003FFD, 0x00000138, + 0x00003FFD, 0x0000012C, 0x00003FFD, 0x0000011F, + 0x00003FFD, 0x00000112, 0x00003FFD, 0x00000106, + 0x00003FFE +}; +*/ diff --git a/lib/rbcodec/codecs/libwmapro/mdct_tables.h b/lib/rbcodec/codecs/libwmapro/mdct_tables.h new file mode 100644 index 0000000000..5e54868b01 --- /dev/null +++ b/lib/rbcodec/codecs/libwmapro/mdct_tables.h @@ -0,0 +1,10 @@ +#ifndef _MDCT_TABLES_H_ +#define _MDCT_TABLES_H_ +#include + +extern const int32_t *sine_windows[6]; +/* rockbox: not used +extern const int32_t sincos_lookup_wmap[8064]; +*/ +#endif /* _MDCT_TABLES_H_ */ + diff --git a/lib/rbcodec/codecs/libwmapro/quant.h b/lib/rbcodec/codecs/libwmapro/quant.h new file mode 100644 index 0000000000..3500615fde --- /dev/null +++ b/lib/rbcodec/codecs/libwmapro/quant.h @@ -0,0 +1,53 @@ +#ifndef _QUANT_H_ +#define _QUANT_H_ + +#include + +/* This table contains unscaled integer casts of the floating point inverse + * quantization factors used by wma pro. The formula for calculating the + * floating point value is : + * quant = pow(10.0, exp/20) + * 'exp' is an integer value which I have exmerimentally found to fall in the + * range (50,170). */ +const int32_t quant_tab[121] = { + 0x0000013C, 0x00000163, 0x0000018E, 0x000001BF, + 0x000001F5, 0x00000232, 0x00000277, 0x000002C4, + 0x0000031A, 0x0000037B, 0x000003E8, 0x00000462, + 0x000004EB, 0x00000585, 0x00000631, 0x000006F2, + 0x000007CB, 0x000008BF, 0x000009D0, 0x00000B02, + 0x00000C5A, 0x00000DDC, 0x00000F8D, 0x00001173, + 0x00001394, 0x000015F7, 0x000018A6, 0x00001BA7, + 0x00001F07, 0x000022D1, 0x00002710, 0x00002BD4, + 0x0000312D, 0x0000372D, 0x00003DE9, 0x00004577, + 0x00004DF1, 0x00005773, 0x0000621F, 0x00006E18, + 0x00007B87, 0x00008A99, 0x00009B83, 0x0000AE7C, + 0x0000C3C7, 0x0000DBAA, 0x0000F678, 0x0001148B, + 0x00013649, 0x00015C25, 0x000186A0, 0x0001B64A, + 0x0001EBC5, 0x000227C6, 0x00026B19, 0x0002B6A4, + 0x00030B66, 0x00036A80, 0x0003D535, 0x00044CEE, + 0x0004D344, 0x000569FD, 0x0006131B, 0x0006D0DC, + 0x0007A5C3, 0x000894A5, 0x0009A0AD, 0x000ACD6A, + 0x000C1ED8, 0x000D9973, 0x000F4240, 0x00111EE2, + 0x001335AD, 0x00158DBA, 0x00182EFD, 0x001B2267, + 0x001E71FE, 0x00222901, 0x0026540E, 0x002B014F, + 0x003040A6, 0x003623E6, 0x003CBF10, 0x00442894, + 0x004C79A0, 0x0055CE75, 0x006046C5, 0x006C0622, + 0x00793472, 0x0087FE7D, 0x00989680, 0x00AB34D9, + 0x00C018C6, 0x00D7893F, 0x00F1D5E4, 0x010F580A, + 0x013073EF, 0x01559A0B, 0x017F4890, 0x01AE0D15, + 0x01E28679, 0x021D66FB, 0x025F769D, 0x02A995C7, + 0x02FCC043, 0x035A1095, 0x03C2C3B6, 0x04383D52, + 0x04BC0C77, 0x054FF0E6, 0x05F5E100, 0x06B01075, + 0x0780F7BD, 0x086B5C7A, 0x09725AE7, 0x0A997065, + 0x0BE48757, 0x0D580472, 0x0EF8D5A3, 0x10CC82D5, + 0x12D940B6 +}; + +#define EXP_MIN 50 +#define EXP_MAX 170 + +/* return the correct value of quant based on exp */ +#define QUANT(exp) quant_tab[exp - EXP_MIN] + + +#endif /* _QUANT_H_ */ diff --git a/lib/rbcodec/codecs/libwmapro/wma.c b/lib/rbcodec/codecs/libwmapro/wma.c new file mode 100644 index 0000000000..83cec89a4c --- /dev/null +++ b/lib/rbcodec/codecs/libwmapro/wma.c @@ -0,0 +1,164 @@ +/* + * WMA compatible codec + * Copyright (c) 2002-2007 The FFmpeg Project + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "wma.h" +#include "codeclib.h" /* needed for av_log2() */ + +/** + *@brief Get the samples per frame for this stream. + *@param sample_rate output sample_rate + *@param version wma version + *@param decode_flags codec compression features + *@return log2 of the number of output samples per frame + */ +int ff_wma_get_frame_len_bits(int sample_rate, int version, + unsigned int decode_flags) +{ + + int frame_len_bits; + + if (sample_rate <= 16000) { + frame_len_bits = 9; + } else if (sample_rate <= 22050 || + (sample_rate <= 32000 && version == 1)) { + frame_len_bits = 10; + } else if (sample_rate <= 48000) { + frame_len_bits = 11; + } else if (sample_rate <= 96000) { + frame_len_bits = 12; + } else { + frame_len_bits = 13; + } + + if (version == 3) { + int tmp = decode_flags & 0x6; + if (tmp == 0x2) { + ++frame_len_bits; + } else if (tmp == 0x4) { + --frame_len_bits; + } else if (tmp == 0x6) { + frame_len_bits -= 2; + } + } + + return frame_len_bits; +} + +/** + * Decode an uncompressed coefficient. + * @param s codec context + * @return the decoded coefficient + */ +unsigned int ff_wma_get_large_val(GetBitContext* gb) +{ + /** consumes up to 34 bits */ + int n_bits = 8; + /** decode length */ + if (get_bits1(gb)) { + n_bits += 8; + if (get_bits1(gb)) { + n_bits += 8; + if (get_bits1(gb)) { + n_bits += 7; + } + } + } + return get_bits_long(gb, n_bits); +} + +/** + * Decode run level compressed coefficients. + * @param avctx codec context + * @param gb bitstream reader context + * @param vlc vlc table for get_vlc2 + * @param level_table level codes + * @param run_table run codes + * @param version 0 for wma1,2 1 for wmapro + * @param ptr output buffer + * @param offset offset in the output buffer + * @param num_coefs number of input coefficents + * @param block_len input buffer length (2^n) + * @param frame_len_bits number of bits for escaped run codes + * @param coef_nb_bits number of bits for escaped level codes + * @return 0 on success, -1 otherwise + */ +#define av_log(...) +int ff_wma_run_level_decode(GetBitContext* gb, + VLC *vlc, + const int32_t *level_table, const uint16_t *run_table, + int version, int32_t *ptr, int offset, + int num_coefs, int block_len, int frame_len_bits, + int coef_nb_bits) +{ + int32_t code, level, sign; + const unsigned int coef_mask = block_len - 1; + /* Rockbox: To be able to use rockbox' optimized mdct we need to pre-shift + * the values by >>(nbits-3). */ + const int nbits = av_log2(block_len)+1; + const int shift = WMAPRO_FRACT-(nbits-3); + for (; offset < num_coefs; offset++) { + code = get_vlc2(gb, vlc->table, VLCBITS, VLCMAX); + if (code > 1) { + /** normal code */ + offset += run_table[code]; + sign = !get_bits1(gb); + /* Rockbox: To be able to use rockbox' optimized mdct we need + * invert the sign. */ + ptr[offset & coef_mask] = sign ? level_table[code] : -level_table[code]; + ptr[offset & coef_mask] <<= shift; + } else if (code == 1) { + /** EOB */ + break; + } else { + /** escape */ + if (!version) { + level = get_bits(gb, coef_nb_bits); + /** NOTE: this is rather suboptimal. reading + block_len_bits would be better */ + offset += get_bits(gb, frame_len_bits); + } else { + level = ff_wma_get_large_val(gb); + /** escape decode */ + if (get_bits1(gb)) { + if (get_bits1(gb)) { + if (get_bits1(gb)) { + av_log(avctx,AV_LOG_ERROR, + "broken escape sequence\n"); + return -1; + } else + offset += get_bits(gb, frame_len_bits) + 4; + } else + offset += get_bits(gb, 2) + 1; + } + } + sign = !get_bits1(gb); + ptr[offset & coef_mask] = sign ? level : -level; + ptr[offset & coef_mask] <<= shift; + } + } + /** NOTE: EOB can be omitted */ + if (offset > num_coefs) { + av_log(avctx, AV_LOG_ERROR, "overflow in spectral RLE, ignoring\n"); + return -1; + } + + return 0; +} diff --git a/lib/rbcodec/codecs/libwmapro/wma.h b/lib/rbcodec/codecs/libwmapro/wma.h new file mode 100644 index 0000000000..6fa7b94724 --- /dev/null +++ b/lib/rbcodec/codecs/libwmapro/wma.h @@ -0,0 +1,75 @@ +/* + * WMA compatible codec + * Copyright (c) 2002-2007 The FFmpeg Project + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVCODEC_WMA_H +#define AVCODEC_WMA_H + +#include "ffmpeg_get_bits.h" +#include "ffmpeg_put_bits.h" + +#define WMAPRO_FRACT (17) +#define WMAPRO_DSP_SAMPLE_DEPTH (WMAPRO_FRACT + 8) + +/* size of blocks */ +#define BLOCK_MIN_BITS 7 +#define BLOCK_MAX_BITS 11 +#define BLOCK_MAX_SIZE (1 << BLOCK_MAX_BITS) + +#define BLOCK_NB_SIZES (BLOCK_MAX_BITS - BLOCK_MIN_BITS + 1) + +/* XXX: find exact max size */ +#define HIGH_BAND_MAX_SIZE 16 + +#define NB_LSP_COEFS 10 + +/* XXX: is it a suitable value ? */ +#define MAX_CODED_SUPERFRAME_SIZE 16384 + +#define MAX_CHANNELS 2 + +#define NOISE_TAB_SIZE 8192 + +#define LSP_POW_BITS 7 + +//FIXME should be in wmadec +#define VLCBITS 9 +#define VLCMAX ((22+VLCBITS-1)/VLCBITS) + +typedef struct CoefVLCTable { + int n; ///< total number of codes + int max_level; + const uint32_t *huffcodes; ///< VLC bit values + const uint8_t *huffbits; ///< VLC bit size + const uint16_t *levels; ///< table to build run/level tables +} CoefVLCTable; + + +int ff_wma_get_frame_len_bits(int sample_rate, int version, + unsigned int decode_flags); +unsigned int ff_wma_get_large_val(GetBitContext* gb); +int ff_wma_run_level_decode(GetBitContext* gb, + VLC *vlc, + const int32_t *level_table, const uint16_t *run_table, + int version, int32_t *ptr, int offset, + int num_coefs, int block_len, int frame_len_bits, + int coef_nb_bits); + +#endif /* AVCODEC_WMA_H */ diff --git a/lib/rbcodec/codecs/libwmapro/wmapro_math.h b/lib/rbcodec/codecs/libwmapro/wmapro_math.h new file mode 100644 index 0000000000..c78d6b627f --- /dev/null +++ b/lib/rbcodec/codecs/libwmapro/wmapro_math.h @@ -0,0 +1,250 @@ +#ifndef _WMAPRO_MATH_H_ +#define _WMAPRO_MATH_H_ + +#include + +/* rockbox: not used +#define fixtof16(x) (float)((float)(x) / (float)(1 << 16)) +#define fixtof31(x) (float)((float)(x) / (float)(1 << 31)) +#define ftofix16(x) ((int32_t)((x) * (float)(1 << 16) + ((x) < 0 ? -0.5:0.5))) +#define ftofix31(x) ((int32_t)((x) * (float)(1 << 31) + ((x) < 0 ? -0.5:0.5))) +*/ + +#if defined(CPU_ARM) + /* Calculates: result = (X*Y)>>Z */ + #define fixmulshift(X,Y,Z) \ + ({ \ + int32_t lo; \ + int32_t hi; \ + asm volatile ( \ + "smull %[lo], %[hi], %[x], %[y] \n\t" /* multiply */ \ + "mov %[lo], %[lo], lsr %[shr] \n\t" /* lo >>= Z */ \ + "orr %[lo], %[lo], %[hi], lsl %[shl]" /* lo |= (hi << (32-Z)) */ \ + : [lo]"=&r"(lo), [hi]"=&r"(hi) \ + : [x]"r"(X), [y]"r"(Y), [shr]"r"(Z), [shl]"r"(32-Z)); \ + lo; \ + }) + + /* Calculates: result = (X*Y)>>16 */ + #define fixmul16(X,Y) \ + ({ \ + int32_t lo; \ + int32_t hi; \ + asm volatile ( \ + "smull %[lo], %[hi], %[x], %[y] \n\t" /* multiply */ \ + "mov %[lo], %[lo], lsr #16 \n\t" /* lo >>= 16 */ \ + "orr %[lo], %[lo], %[hi], lsl #16" /* lo |= (hi << 16) */ \ + : [lo]"=&r"(lo), [hi]"=&r"(hi) \ + : [x]"r"(X), [y]"r"(Y)); \ + lo; \ + }) + + /* Calculates: result = (X*Y)>>24 */ + #define fixmul24(X,Y) \ + ({ \ + int32_t lo; \ + int32_t hi; \ + asm volatile ( \ + "smull %[lo], %[hi], %[x], %[y] \n\t" /* multiply */ \ + "mov %[lo], %[lo], lsr #24 \n\t" /* lo >>= 24 */ \ + "orr %[lo], %[lo], %[hi], lsl #8" /* lo |= (hi << 8) */ \ + : [lo]"=&r"(lo), [hi]"=&r"(hi) \ + : [x]"r"(X), [y]"r"(Y)); \ + lo; \ + }) + + /* Calculates: result = (X*Y)>>31, loose 1 bit precision */ + #define fixmul31(X,Y) \ + ({ \ + int32_t lo; \ + int32_t hi; \ + asm volatile ( \ + "smull %[lo], %[hi], %[x], %[y] \n\t" /* multiply */ \ + "mov %[hi], %[hi], lsl #1" /* hi <<= 1 */ \ + : [lo]"=&r"(lo), [hi]"=&r"(hi) \ + : [x]"r"(X), [y]"r"(Y)); \ + hi; \ + }) +#elif defined(CPU_COLDFIRE) + /* Calculates: result = (X*Y)>>Z */ + #define fixmulshift(X,Y,Z) \ + ({ \ + int32_t t1; \ + int32_t t2; \ + asm volatile ( \ + "mac.l %[x],%[y],%%acc0\n\t" /* multiply */ \ + "mulu.l %[y],%[x] \n\t" /* get lower half, avoid emac stall */ \ + "movclr.l %%acc0,%[t1] \n\t" /* get higher half */ \ + "moveq.l #31,%[t2] \n\t" \ + "sub.l %[sh],%[t2] \n\t" /* t2 = 31 - shift */ \ + "ble.s 1f \n\t" \ + "asl.l %[t2],%[t1] \n\t" /* hi <<= 31 - shift */ \ + "lsr.l %[sh],%[x] \n\t" /* (unsigned)lo >>= shift */ \ + "or.l %[x],%[t1] \n\t" /* combine result */ \ + "bra.s 2f \n\t" \ + "1: \n\t" \ + "neg.l %[t2] \n\t" /* t2 = shift - 31 */ \ + "asr.l %[t2],%[t1] \n\t" /* hi >>= t2 */ \ + "2: \n" \ + : [t1]"=&d"(t1), [t2]"=&d"(t2) \ + : [x] "d"((X)), [y] "d"((Y)), [sh]"d"((Z))); \ + t1; \ + }) + + /* Calculates: result = (X*Y)>>16 */ + #define fixmul16(X,Y) \ + ({ \ + int32_t t, x = (X); \ + asm volatile ( \ + "mac.l %[x],%[y],%%acc0\n\t" /* multiply */ \ + "mulu.l %[y],%[x] \n\t" /* get lower half, avoid emac stall */ \ + "movclr.l %%acc0,%[t] \n\t" /* get higher half */ \ + "lsr.l #1,%[t] \n\t" /* hi >>= 1 to compensate emac shift */ \ + "move.w %[t],%[x] \n\t" /* combine halfwords */\ + "swap %[x] \n\t" \ + : [t]"=&d"(t), [x] "+d" (x) \ + : [y] "d" ((Y))); \ + x; \ + }) + + /* Calculates: result = (X*Y)>>31 (may lose msb to overflow) */ + #define fixmul31(X,Y) \ + ({ \ + int32_t t; \ + asm volatile ( \ + "mac.l %[x], %[y], %%acc0\n\t" /* multiply */ \ + "movclr.l %%acc0, %[t]\n\t" /* get higher half as result */ \ + : [t] "=d" (t) \ + : [x] "r" ((X)), [y] "r" ((Y))); \ + t; \ + }) +#else + static inline int32_t fixmulshift(int32_t x, int32_t y, int shamt) + { + int64_t temp; + temp = x; + temp *= y; + + temp >>= shamt; + + return (int32_t)temp; + } + + static inline int32_t fixmul31(int32_t x, int32_t y) + { + int64_t temp; + temp = x; + temp *= y; + + temp >>= 31; + + return (int32_t)temp; + } + + static inline int32_t fixmul24(int32_t x, int32_t y) + { + int64_t temp; + temp = x; + temp *= y; + + temp >>= 24; + + return (int32_t)temp; + } + + static inline int32_t fixmul16(int32_t x, int32_t y) + { + int64_t temp; + temp = x; + temp *= y; + + temp >>= 16; + + return (int32_t)temp; + } +#endif /* CPU_COLDFIRE, CPU_ARM */ + +#if defined(CPU_COLDFIRE) + #define VECT_MUL_WIN_KERNEL(i, j, s0, s1, wi, wj) \ + asm volatile ( \ + "mac.l %[s0], %[wj], %%acc0 \n\t" \ + "msac.l %[s1], %[wi], %%acc0 \n\t" \ + "mac.l %[s0], %[wi], %%acc1 \n\t" \ + "mac.l %[s1], %[wj], %%acc1 \n\t" \ + "movclr.l %%acc0, %[s0] \n\t" \ + "move.l %[s0], (%[dst_i]) \n\t" \ + "movclr.l %%acc1, %[s0] \n\t" \ + "move.l %[s0], (%[dst_j]) \n\t" \ + : [s0] "+r" (s0) /* register is clobbered so specify it as an input */ \ + : [dst_i] "a" (&dst[i]), [dst_j] "a" (&dst[j]), \ + [s1] "r" (s1), [wi] "r" (wi), [wj] "r" (wj) \ + : "cc", "memory"); +#else + #define VECT_MUL_WIN_KERNEL(i, j, s0, s1, wi, wj) \ + dst[i] = fixmul31(wj, s0) - fixmul31(wi, s1); \ + dst[j] = fixmul31(wi, s0) + fixmul31(wj, s1); +#endif /* CPU_COLDFIRE */ + +static inline void vector_fixmul_window(int32_t *dst, const int32_t *src0, + const int32_t *src1, const int32_t *win, + int len) +{ + int i, j; + dst += len; + win += len; + src0+= len; + for(i=-len, j=len-1; i<0; i++, j--) { + int32_t s0 = src0[i]; /* s0 = src0[ 0 ... len-1] */ + int32_t s1 = src1[j]; /* s1 = src1[2*len-1 ... len] */ + int32_t wi = -win[i]; /* wi = -win[ 0 ... len-1] */ + int32_t wj = -win[j]; /* wj = -win[2*len-1 ... len] */ + VECT_MUL_WIN_KERNEL(i, j, s0, s1, wi, wj); + } +} + +#if defined(CPU_ARM) + #define VECT_MUL_SCALAR_KERNEL(dst, src, mul) \ + asm volatile ( \ + "ldmia %[src]!, {r1-r4} \n\t" \ + "smull r0, r5, r1, %[mul] \n\t" \ + "mov r0, r0, lsr #16 \n\t" \ + "orr r0, r0, r5, lsl #16\n\t" \ + "smull r1, r5, r2, %[mul] \n\t" \ + "mov r1, r1, lsr #16 \n\t" \ + "orr r1, r1, r5, lsl #16\n\t" \ + "smull r2, r5, r3, %[mul] \n\t" \ + "mov r2, r2, lsr #16 \n\t" \ + "orr r2, r2, r5, lsl #16\n\t" \ + "smull r3, r5, r4, %[mul] \n\t" \ + "mov r3, r3, lsr #16 \n\t" \ + "orr r3, r3, r5, lsl #16\n\t" \ + "stmia %[dst]!, {r0-r3} \n" \ + : [dst]"+r"(dst), [src]"+r"(src) \ + : [mul]"r"(mul) \ + : "r0", "r1", "r2", "r3", "r4", "r5", "memory"); +#else + #define VECT_MUL_SCALAR_KERNEL(dst, src, mul) \ + dst[i ] = fixmul16(src[i ], mul); \ + dst[i+1] = fixmul16(src[i+1], mul); \ + dst[i+2] = fixmul16(src[i+2], mul); \ + dst[i+3] = fixmul16(src[i+3], mul); +#endif /* CPU_ARM, CPU_COLDFIRE */ + +static inline void vector_fixmul_scalar(int32_t *dst, const int32_t *src, + int32_t mul, int len) +{ + /* len is _always_ a multiple of 4, because len is the difference of sfb's + * which themselves are always a multiple of 4. */ + int i; + for (i=0; i amax) return amax; + else return a; +} +#endif /* _WMAPRO_MATH_H_ */ diff --git a/lib/rbcodec/codecs/libwmapro/wmaprodata.h b/lib/rbcodec/codecs/libwmapro/wmaprodata.h new file mode 100644 index 0000000000..94762f7dbf --- /dev/null +++ b/lib/rbcodec/codecs/libwmapro/wmaprodata.h @@ -0,0 +1,615 @@ +/* + * WMA 9/3/PRO compatible decoder + * Copyright (c) 2007 Baptiste Coudurier, Benjamin Larsson, Ulion + * Copyright (c) 2008 - 2009 Sascha Sommer + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file libavcodec/wmaprodata.h + * @brief tables for wmapro decoding + */ + +#ifndef AVCODEC_WMAPRODATA_H +#define AVCODEC_WMAPRODATA_H + +#include +#include + +/* rockbox: not used +const int32_t fixed_sin64[33] = { + 0x00000000, 0xF9B82685, 0xF3742CA3, 0xED37EF92, 0xE70747C5, 0xE0E60686, + 0xDAD7F3A3, 0xD4E0CB16, 0xCF043AB4, 0xC945DFED, 0xC3A94591, 0xBE31E19C, + 0xB8E3131A, 0xB3C0200D, 0xAECC336D, 0xAA0A5B2F, 0xA57D8667, 0xA1288377, + 0x9D0DFE55, 0x99307EE1, 0x9592675D, 0x9235F2ED, 0x8F1D343B, 0x8C4A1430, + 0x89BE50C4, 0x877B7BED, 0x8582FAA6, 0x83D60413, 0x8275A0C1, 0x8162AA05, + 0x809DC972, 0x80277873, 0x80000001, +}; +*/ +/** + * @brief frequencies to divide the frequency spectrum into scale factor bands + */ +static const uint16_t critical_freq[] = { + 100, 200, 300, 400, 510, 630, 770, + 920, 1080, 1270, 1480, 1720, 2000, 2320, + 2700, 3150, 3700, 4400, 5300, 6400, 7700, + 9500, 12000, 15500, 20675, 28575, 41375, 63875, +}; + +/** + * @name Huffman tables for DPCM-coded scale factors + * @{ + */ +#define HUFF_SCALE_SIZE 121 +#define HUFF_SCALE_MAXBITS 19 +static const uint16_t scale_huffcodes[HUFF_SCALE_SIZE] = { + 0xE639, 0xE6C2, 0xE6C1, 0xE6C0, 0xE63F, 0xE63E, 0xE63D, 0xE63C, + 0xE63B, 0xE63A, 0xE638, 0xE637, 0xE636, 0xE635, 0xE634, 0xE632, + 0xE633, 0xE620, 0x737B, 0xE610, 0xE611, 0xE612, 0xE613, 0xE614, + 0xE615, 0xE616, 0xE617, 0xE618, 0xE619, 0xE61A, 0xE61B, 0xE61C, + 0xE61D, 0xE61E, 0xE61F, 0xE6C3, 0xE621, 0xE622, 0xE623, 0xE624, + 0xE625, 0xE626, 0xE627, 0xE628, 0xE629, 0xE62A, 0xE62B, 0xE62C, + 0xE62D, 0xE62E, 0xE62F, 0xE630, 0xE631, 0x1CDF, 0x0E60, 0x0399, + 0x00E7, 0x001D, 0x0000, 0x0001, 0x0001, 0x0001, 0x0002, 0x0006, + 0x0002, 0x0007, 0x0006, 0x000F, 0x0038, 0x0072, 0x039A, 0xE6C4, + 0xE6C5, 0xE6C6, 0xE6C7, 0xE6C8, 0xE6C9, 0xE6CA, 0xE6CB, 0xE6CC, + 0xE6CD, 0xE6CE, 0xE6CF, 0xE6D0, 0xE6D1, 0xE6D2, 0xE6D3, 0xE6D4, + 0xE6D5, 0xE6D6, 0xE6D7, 0xE6D8, 0xE6D9, 0xE6DA, 0xE6DB, 0xE6DC, + 0xE6DD, 0xE6DE, 0xE6DF, 0xE6E0, 0xE6E1, 0xE6E2, 0xE6E3, 0xE6E4, + 0xE6E5, 0xE6E6, 0xE6E7, 0xE6E8, 0xE6E9, 0xE6EA, 0xE6EB, 0xE6EC, + 0xE6ED, 0xE6EE, 0xE6EF, 0xE6F0, 0xE6F1, 0xE6F2, 0xE6F3, 0xE6F4, + 0xE6F5, +}; + +static const uint8_t scale_huffbits[HUFF_SCALE_SIZE] = { + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 18, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 16, 15, 13, + 11, 8, 5, 2, 1, 3, 5, 6, + 6, 7, 7, 7, 9, 10, 13, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, +}; +/** @} */ + + +/** + * @name Huffman, run and level tables for runlevel-coded scale factors + * @{ + */ +#define HUFF_SCALE_RL_SIZE 120 +#define HUFF_SCALE_RL_MAXBITS 21 +static const uint32_t scale_rl_huffcodes[HUFF_SCALE_RL_SIZE] = { + 0x00010C, 0x000001, 0x10FE2A, 0x000003, 0x000003, 0x000001, 0x000013, + 0x000020, 0x000029, 0x000014, 0x000016, 0x000045, 0x000049, 0x00002F, + 0x000042, 0x00008E, 0x00008F, 0x000129, 0x000009, 0x00000D, 0x0004AC, + 0x00002C, 0x000561, 0x0002E6, 0x00087C, 0x0002E2, 0x00095C, 0x000018, + 0x000001, 0x000016, 0x000044, 0x00002A, 0x000007, 0x000159, 0x000143, + 0x000128, 0x00015A, 0x00012D, 0x00002B, 0x0000A0, 0x000142, 0x00012A, + 0x0002EF, 0x0004AF, 0x00087D, 0x004AE9, 0x0043F9, 0x000067, 0x000199, + 0x002B05, 0x001583, 0x0021FE, 0x10FE2C, 0x000004, 0x00002E, 0x00010D, + 0x00000A, 0x000244, 0x000017, 0x000245, 0x000011, 0x00010E, 0x00012C, + 0x00002A, 0x00002F, 0x000121, 0x000046, 0x00087E, 0x0000BA, 0x000032, + 0x0087F0, 0x0056DC, 0x0002EC, 0x0043FA, 0x002B6F, 0x004AE8, 0x0002B7, + 0x10FE2B, 0x000001, 0x000051, 0x000010, 0x0002EE, 0x000B9C, 0x002576, + 0x000198, 0x0056DD, 0x0000CD, 0x000AC0, 0x000170, 0x004AEF, 0x00002D, + 0x0004AD, 0x0021FF, 0x0005CF, 0x002B04, 0x10FE29, 0x10FE28, 0x0002ED, + 0x002E74, 0x021FC4, 0x004AEE, 0x010FE3, 0x087F17, 0x000000, 0x000097, + 0x0002E3, 0x000ADA, 0x002575, 0x00173B, 0x0043FB, 0x002E75, 0x10FE2D, + 0x0015B6, 0x00056C, 0x000057, 0x000123, 0x000120, 0x00021E, 0x000172, + 0x0002B1, +}; + +static const uint8_t scale_rl_huffbits[HUFF_SCALE_RL_SIZE] = { + 9, 2, 21, 2, 4, 5, 5, + 6, 6, 7, 7, 7, 7, 6, + 7, 8, 8, 9, 10, 10, 11, + 12, 11, 12, 12, 12, 12, 11, + 4, 5, 7, 8, 9, 9, 9, + 9, 9, 9, 8, 8, 9, 9, + 12, 11, 12, 15, 15, 13, 15, + 14, 13, 14, 21, 5, 6, 9, + 10, 10, 11, 10, 11, 9, 9, + 6, 8, 9, 7, 12, 10, 12, + 16, 15, 12, 15, 14, 15, 10, + 21, 6, 7, 11, 12, 14, 14, + 15, 15, 14, 12, 11, 15, 12, + 11, 14, 13, 14, 21, 21, 12, + 16, 18, 15, 17, 20, 7, 8, + 12, 12, 14, 15, 15, 16, 21, + 13, 11, 7, 9, 9, 10, 11, + 10, +}; + + +static const uint8_t scale_rl_run[HUFF_SCALE_RL_SIZE] = { + 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 22, 23, 24, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, + 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 0, 1, 2, 3, + 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, + 23, 24, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, + 17, 18, 19, 20, 21, 22, 23, 24, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, + 0, 1, 0, 1, 0, 1, +}; + +static const uint8_t scale_rl_level[HUFF_SCALE_RL_SIZE] = { + 0, 0, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 7, 7, 8, 8, 9, 9, +}; +/** @} */ + + +/** + * @name Huffman, run and level codes for runlevel-coded coefficients + * @{ + */ +#define HUFF_COEF0_SIZE 272 +#define HUFF_COEF0_MAXBITS 21 +static const uint32_t coef0_huffcodes[HUFF_COEF0_SIZE] = { + 0x00004A, 0x00002B, 0x000000, 0x000003, 0x000006, 0x000009, 0x00000F, + 0x000010, 0x000016, 0x000011, 0x000016, 0x000028, 0x00002F, 0x000026, + 0x000029, 0x000045, 0x000055, 0x00005D, 0x000042, 0x00004E, 0x000051, + 0x00005E, 0x00008D, 0x0000A8, 0x0000AD, 0x000080, 0x000096, 0x00009F, + 0x0000AA, 0x0000BE, 0x00011C, 0x000153, 0x000158, 0x000170, 0x000104, + 0x00010D, 0x000105, 0x000103, 0x00012F, 0x000177, 0x000175, 0x000157, + 0x000174, 0x000225, 0x00023B, 0x00020D, 0x00021F, 0x000281, 0x00027B, + 0x000282, 0x0002AC, 0x0002FD, 0x00044F, 0x000478, 0x00044D, 0x0002EC, + 0x00044E, 0x000564, 0x000409, 0x00040B, 0x000501, 0x000545, 0x0004F3, + 0x000541, 0x00043B, 0x0004F1, 0x0004F4, 0x0008FD, 0x000A94, 0x000811, + 0x000B88, 0x000B91, 0x000B93, 0x0008EA, 0x000899, 0x000B8A, 0x000972, + 0x0009E5, 0x000A8F, 0x000A84, 0x000A8E, 0x000A00, 0x000830, 0x0008E8, + 0x000B95, 0x000871, 0x00083A, 0x000814, 0x000873, 0x000BFE, 0x001728, + 0x001595, 0x001712, 0x00102A, 0x001021, 0x001729, 0x00152E, 0x0013C3, + 0x001721, 0x001597, 0x00151B, 0x0010F2, 0x001403, 0x001703, 0x001503, + 0x001708, 0x0013C1, 0x00170E, 0x00170C, 0x0010E1, 0x0011EA, 0x001020, + 0x001500, 0x0017FA, 0x001704, 0x001705, 0x0017F0, 0x0017FB, 0x0021E6, + 0x002B2D, 0x0020C6, 0x002B29, 0x002E4A, 0x0023AC, 0x001519, 0x0023F3, + 0x002B2C, 0x0021C0, 0x0017FE, 0x0023D7, 0x0017F9, 0x0012E7, 0x0013C0, + 0x002261, 0x0023D3, 0x002057, 0x002056, 0x0021D2, 0x0020C7, 0x0023D2, + 0x0020EC, 0x0044C0, 0x002FE2, 0x00475B, 0x002A03, 0x002FE3, 0x0021E2, + 0x0021D0, 0x002A31, 0x002E13, 0x002E05, 0x0047E5, 0x00000E, 0x000024, + 0x000088, 0x0000B9, 0x00010C, 0x000224, 0x0002B3, 0x000283, 0x0002ED, + 0x00047B, 0x00041E, 0x00043D, 0x0004F5, 0x0005FD, 0x000A92, 0x000B96, + 0x000838, 0x000971, 0x000B83, 0x000B80, 0x000BF9, 0x0011D3, 0x0011E8, + 0x0011D7, 0x001527, 0x0011F8, 0x001073, 0x0010F0, 0x0010E4, 0x0017F8, + 0x001062, 0x001402, 0x0017E3, 0x00151A, 0x001077, 0x00152B, 0x00170D, + 0x0021D3, 0x002E41, 0x0013C2, 0x000029, 0x0000A9, 0x00025D, 0x000419, + 0x000544, 0x000B8B, 0x0009E4, 0x0011D2, 0x001526, 0x001724, 0x0012E6, + 0x00150B, 0x0017FF, 0x002E26, 0x002E4B, 0x002B28, 0x0021E3, 0x002A14, + 0x00475A, 0x002E12, 0x000057, 0x00023E, 0x000A90, 0x000BF0, 0x001072, + 0x001502, 0x0023D6, 0x0020ED, 0x002A30, 0x0044C7, 0x00008C, 0x00047F, + 0x00152A, 0x002262, 0x002E04, 0x0000A1, 0x0005F9, 0x000173, 0x000875, + 0x000171, 0x00152D, 0x0002E3, 0x0017E2, 0x0002AD, 0x0021C1, 0x000479, + 0x0021E7, 0x00041F, 0x005C4E, 0x000543, 0x005C4F, 0x000A91, 0x00898D, + 0x000B97, 0x008746, 0x000970, 0x008745, 0x000B85, 0x00A856, 0x00152F, + 0x010E8E, 0x0010E5, 0x00A857, 0x00170F, 0x021D11, 0x002A58, 0x010E8F, + 0x002E40, 0x021D13, 0x002A59, 0x043A25, 0x002A02, 0x043A21, 0x0044C1, + 0x087448, 0x0047E4, 0x043A20, 0x00542A, 0x087449, 0x00898C, +}; + +static const uint8_t coef0_huffbits[HUFF_COEF0_SIZE] = { + 8, 7, 2, 3, 3, 4, 4, + 5, 5, 6, 6, 6, 6, 7, + 7, 7, 7, 7, 8, 8, 8, + 8, 8, 8, 8, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 10, + 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, + 11, 11, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 13, + 12, 12, 12, 12, 12, 12, 13, + 13, 13, 13, 13, 13, 13, 12, + 12, 13, 13, 13, 13, 13, 13, + 13, 13, 14, 14, 13, 13, 14, + 13, 13, 14, 14, 14, 14, 14, + 14, 14, 14, 14, 14, 13, 14, + 14, 14, 14, 14, 14, 14, 15, + 14, 15, 14, 14, 14, 14, 14, + 14, 15, 14, 14, 14, 14, 14, + 14, 14, 15, 15, 15, 15, 14, + 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 4, 7, + 8, 9, 10, 10, 10, 11, 11, + 11, 12, 12, 12, 12, 12, 12, + 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 14, 14, 14, 14, + 14, 14, 14, 14, 14, 13, 14, + 15, 14, 14, 6, 9, 11, 12, + 12, 12, 13, 13, 13, 13, 14, + 14, 14, 14, 14, 14, 15, 15, + 15, 15, 7, 10, 12, 13, 14, + 14, 14, 15, 15, 15, 8, 11, + 13, 14, 15, 9, 12, 9, 13, + 10, 13, 10, 14, 11, 15, 11, + 15, 12, 15, 12, 15, 12, 16, + 12, 17, 13, 17, 13, 17, 13, + 18, 14, 17, 14, 19, 14, 18, + 14, 19, 14, 20, 15, 20, 15, + 21, 15, 20, 16, 21, 16, +}; + + +#define HUFF_COEF1_SIZE 244 +#define HUFF_COEF1_MAXBITS 22 +static const uint32_t coef1_huffcodes[HUFF_COEF1_SIZE] = { + 0x0001E2, 0x00007F, 0x000000, 0x000002, 0x000008, 0x00000E, 0x000019, + 0x00002F, 0x000037, 0x000060, 0x00006C, 0x000095, 0x0000C6, 0x0000F0, + 0x00012E, 0x000189, 0x0001A5, 0x0001F8, 0x000253, 0x00030A, 0x000344, + 0x00034D, 0x0003F2, 0x0004BD, 0x0005D7, 0x00062A, 0x00068B, 0x000693, + 0x000797, 0x00097D, 0x000BAB, 0x000C52, 0x000C5E, 0x000D21, 0x000D20, + 0x000F1A, 0x000FCE, 0x000FD1, 0x0012F1, 0x001759, 0x0018AC, 0x0018A7, + 0x0018BF, 0x001A2B, 0x001E52, 0x001E50, 0x001E31, 0x001FB8, 0x0025E6, + 0x0025E7, 0x002EB4, 0x002EB7, 0x003169, 0x00315B, 0x00317C, 0x00316C, + 0x0034CA, 0x00348D, 0x003F40, 0x003CA2, 0x003F76, 0x004BC3, 0x004BE5, + 0x003F73, 0x004BF8, 0x004BF9, 0x006131, 0x00628B, 0x006289, 0x0062DA, + 0x00628A, 0x0062D4, 0x006997, 0x0062B4, 0x006918, 0x00794D, 0x007E7B, + 0x007E87, 0x007EEA, 0x00794E, 0x00699D, 0x007967, 0x00699F, 0x0062DB, + 0x007E7A, 0x007EEB, 0x00BAC0, 0x0097C9, 0x00C537, 0x00C5AB, 0x00D233, + 0x00D338, 0x00BAC1, 0x00D23D, 0x012F91, 0x00D339, 0x00FDC8, 0x00D23C, + 0x00FDDC, 0x00FDC9, 0x00FDDD, 0x00D33C, 0x000003, 0x000016, 0x00003E, + 0x0000C3, 0x0001A1, 0x000347, 0x00062E, 0x000BAA, 0x000F2D, 0x001A2A, + 0x001E58, 0x00309B, 0x003CA3, 0x005D6A, 0x00629A, 0x006996, 0x00794F, + 0x007EE5, 0x00BAD7, 0x00C5AA, 0x00C5F4, 0x00FDDF, 0x00FDDE, 0x018A20, + 0x018A6D, 0x01A67B, 0x01A464, 0x025F21, 0x01F9E2, 0x01F9E3, 0x00000A, + 0x00003D, 0x000128, 0x0003C7, 0x000C24, 0x0018A3, 0x002EB1, 0x003CB2, + 0x00691F, 0x007E79, 0x000013, 0x0000BB, 0x00034E, 0x000D14, 0x0025FD, + 0x004BE7, 0x000024, 0x000188, 0x0007EF, 0x000035, 0x000308, 0x0012F2, + 0x00005C, 0x0003F6, 0x0025E0, 0x00006D, 0x000698, 0x000096, 0x000C25, + 0x0000C7, 0x000F1B, 0x0000F3, 0x0012FF, 0x000174, 0x001A66, 0x0001A0, + 0x003099, 0x0001E4, 0x00316B, 0x000252, 0x003F31, 0x00030B, 0x004BE6, + 0x000346, 0x0062FB, 0x00034F, 0x007966, 0x0003F5, 0x007E86, 0x0005D4, + 0x00C511, 0x00062C, 0x00C5F5, 0x000692, 0x00F299, 0x000795, 0x00F298, + 0x0007E9, 0x018A21, 0x00097E, 0x0175AD, 0x000C27, 0x01A67A, 0x000C57, + 0x02EB59, 0x000D22, 0x0314D9, 0x000F19, 0x03F3C2, 0x000FCD, 0x0348CB, + 0x0012F8, 0x04BE41, 0x0018A0, 0x03F3C1, 0x0018A1, 0x04BE40, 0x0018B7, + 0x0629B0, 0x001A64, 0x0D2329, 0x001E30, 0x03F3C3, 0x001F9F, 0x0BAD62, + 0x001F99, 0x0FCF00, 0x00309A, 0x0629B1, 0x002EB6, 0x175AC3, 0x00314C, + 0x069195, 0x003168, 0x0BAD63, 0x00348E, 0x175AC1, 0x003F30, 0x07E781, + 0x003F41, 0x0D2328, 0x003F42, 0x1F9E03, 0x004BC2, 0x175AC2, 0x003F74, + 0x175AC0, 0x005D61, 0x3F3C05, 0x006130, 0x3F3C04, 0x0062B5, +}; + +static const uint8_t coef1_huffbits[HUFF_COEF1_SIZE] = { + 9, 7, 2, 3, 4, 4, 5, + 6, 6, 7, 7, 8, 8, 8, + 9, 9, 9, 9, 10, 10, 10, + 10, 10, 11, 11, 11, 11, 11, + 11, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 14, + 14, 14, 14, 14, 14, 14, 14, + 14, 14, 14, 14, 14, 15, 15, + 14, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, + 15, 15, 16, 16, 16, 16, 16, + 16, 16, 16, 17, 16, 16, 16, + 16, 16, 16, 16, 3, 5, 6, + 8, 9, 10, 11, 12, 12, 13, + 13, 14, 14, 15, 15, 15, 15, + 15, 16, 16, 16, 16, 16, 17, + 17, 17, 17, 18, 17, 17, 4, + 6, 9, 10, 12, 13, 14, 14, + 15, 15, 5, 8, 10, 12, 14, + 15, 6, 9, 11, 6, 10, 13, + 7, 10, 14, 7, 11, 8, 12, + 8, 12, 8, 13, 9, 13, 9, + 14, 9, 14, 10, 14, 10, 15, + 10, 15, 10, 15, 10, 15, 11, + 16, 11, 16, 11, 16, 11, 16, + 11, 17, 12, 17, 12, 17, 12, + 18, 12, 18, 12, 18, 12, 18, + 13, 19, 13, 18, 13, 19, 13, + 19, 13, 20, 13, 18, 13, 20, + 13, 20, 14, 19, 14, 21, 14, + 19, 14, 20, 14, 21, 14, 19, + 14, 20, 14, 21, 15, 21, 14, + 21, 15, 22, 15, 22, 15, +}; + + +static const uint16_t coef0_run[HUFF_COEF0_SIZE] = { + 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, + 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, + 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, + 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, + 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, + 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, + 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, + 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, + 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, + 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, + 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 0, 1, + 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, + 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 0, 1, 2, 3, + 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, + 18, 19, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, + 2, 3, 4, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, +}; + +static const int32_t coef0_level[HUFF_COEF0_SIZE] = { + 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, + 5, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, + 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, + 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, + 25, 26, 26, 27, 27, 28, +}; + + +static const uint16_t coef1_run[HUFF_COEF1_SIZE] = { + 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, + 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, + 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, + 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, + 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 0, 1, 2, 3, 4, 5, + 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, + 2, 3, 4, 5, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, +}; + +static const int32_t coef1_level[HUFF_COEF1_SIZE] = { + 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, + 4, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 9, 9, 10, + 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, + 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, + 28, 29, 29, 30, 30, 31, 31, 32, 32, 33, 33, 34, 34, 35, 35, 36, 36, 37, + 37, 38, 38, 39, 39, 40, 40, 41, 41, 42, 42, 43, 43, 44, 44, 45, 45, 46, + 46, 47, 47, 48, 48, 49, 49, 50, 51, 52, +}; +/** @} */ + + +/** + * @name Huffman and vector lookup tables for vector-coded coefficients + * @{ + */ +#define HUFF_VEC4_SIZE 127 +#define HUFF_VEC4_MAXBITS 14 +static const uint16_t vec4_huffcodes[HUFF_VEC4_SIZE] = { + 0x0019, 0x0027, 0x00F2, 0x03BA, 0x0930, 0x1267, 0x0031, 0x0030, + 0x0097, 0x0221, 0x058B, 0x0124, 0x00EB, 0x01D4, 0x03D8, 0x0584, + 0x0364, 0x045F, 0x0F66, 0x0931, 0x24CD, 0x002F, 0x0039, 0x00E8, + 0x02C3, 0x078A, 0x0037, 0x0029, 0x0084, 0x01B1, 0x00ED, 0x0086, + 0x00F9, 0x03AB, 0x01EB, 0x08BC, 0x011E, 0x00F3, 0x0220, 0x058A, + 0x00EC, 0x008E, 0x012B, 0x01EA, 0x0119, 0x04B0, 0x04B1, 0x03B8, + 0x0691, 0x0365, 0x01ED, 0x049A, 0x0EA9, 0x0EA8, 0x08BD, 0x24CC, + 0x0026, 0x0035, 0x00DB, 0x02C4, 0x07B2, 0x0038, 0x002B, 0x007F, + 0x01B3, 0x00F4, 0x0091, 0x0116, 0x03BB, 0x0215, 0x0932, 0x002D, + 0x002A, 0x008A, 0x01DE, 0x0028, 0x0020, 0x005C, 0x0090, 0x0068, + 0x01EE, 0x00E9, 0x008D, 0x012A, 0x0087, 0x005D, 0x0118, 0x0349, + 0x01EF, 0x01E3, 0x08B9, 0x00F0, 0x00D3, 0x0214, 0x049B, 0x00DA, + 0x0089, 0x0125, 0x0217, 0x012D, 0x0690, 0x0094, 0x007D, 0x011F, + 0x007E, 0x0059, 0x0127, 0x01A5, 0x0111, 0x00F8, 0x045D, 0x03B9, + 0x0259, 0x0580, 0x02C1, 0x01DF, 0x0585, 0x0216, 0x0163, 0x01B0, + 0x03C4, 0x08B8, 0x078B, 0x0755, 0x0581, 0x0F67, 0x0000, +}; + +static const uint8_t vec4_huffbits[HUFF_VEC4_SIZE] = { + 5, 6, 8, 10, 12, 13, 6, 6, + 8, 10, 11, 9, 8, 9, 10, 11, + 10, 11, 12, 12, 14, 6, 6, 8, + 10, 11, 6, 6, 8, 9, 8, 8, + 8, 10, 9, 12, 9, 8, 10, 11, + 8, 8, 9, 9, 9, 11, 11, 10, + 11, 10, 9, 11, 12, 12, 12, 14, + 6, 6, 8, 10, 11, 6, 6, 7, + 9, 8, 8, 9, 10, 10, 12, 6, + 6, 8, 9, 6, 6, 7, 8, 7, + 9, 8, 8, 9, 8, 7, 9, 10, + 9, 9, 12, 8, 8, 10, 11, 8, + 8, 9, 10, 9, 11, 8, 7, 9, + 7, 7, 9, 9, 9, 8, 11, 10, + 10, 11, 10, 9, 11, 10, 9, 9, + 10, 12, 11, 11, 11, 12, 1, +}; + + +#define HUFF_VEC2_SIZE 137 +#define HUFF_VEC2_MAXBITS 12 +static const uint16_t vec2_huffcodes[HUFF_VEC2_SIZE] = { + 0x055, 0x01C, 0x01A, 0x02B, 0x028, 0x067, 0x08B, 0x039, + 0x170, 0x10D, 0x2A5, 0x047, 0x464, 0x697, 0x523, 0x8CB, + 0x01B, 0x00E, 0x000, 0x010, 0x012, 0x036, 0x048, 0x04C, + 0x0C2, 0x09B, 0x171, 0x03B, 0x224, 0x34A, 0x2D6, 0x019, + 0x00F, 0x002, 0x014, 0x017, 0x006, 0x05D, 0x054, 0x0C7, + 0x0B4, 0x192, 0x10E, 0x233, 0x043, 0x02C, 0x00F, 0x013, + 0x006, 0x02F, 0x02C, 0x068, 0x077, 0x0DF, 0x111, 0x1A4, + 0x16A, 0x2A4, 0x027, 0x011, 0x018, 0x02D, 0x00F, 0x04A, + 0x040, 0x097, 0x01F, 0x11B, 0x022, 0x16D, 0x066, 0x035, + 0x005, 0x02B, 0x049, 0x009, 0x075, 0x0CB, 0x0AA, 0x187, + 0x106, 0x08A, 0x047, 0x060, 0x06E, 0x01D, 0x074, 0x0C4, + 0x01E, 0x118, 0x1A7, 0x038, 0x042, 0x053, 0x076, 0x0A8, + 0x0CA, 0x082, 0x110, 0x18D, 0x12D, 0x0B9, 0x0C8, 0x0DE, + 0x01C, 0x0AB, 0x113, 0x18C, 0x10F, 0x09A, 0x0A5, 0x0B7, + 0x11A, 0x186, 0x1A6, 0x259, 0x153, 0x18A, 0x193, 0x020, + 0x10C, 0x046, 0x03A, 0x107, 0x149, 0x16C, 0x2D7, 0x225, + 0x258, 0x316, 0x696, 0x317, 0x042, 0x522, 0x290, 0x8CA, + 0x001, +}; + +static const uint8_t vec2_huffbits[HUFF_VEC2_SIZE] = { + 7, 6, 6, 6, 7, 7, 8, 9, + 9, 10, 10, 11, 11, 11, 12, 12, + 6, 4, 5, 5, 6, 6, 7, 8, + 8, 9, 9, 10, 10, 10, 11, 6, + 4, 5, 5, 6, 7, 7, 8, 8, + 9, 9, 10, 10, 11, 6, 5, 5, + 6, 6, 7, 7, 8, 8, 9, 9, + 10, 10, 7, 6, 6, 6, 7, 7, + 8, 8, 9, 9, 10, 10, 7, 6, + 7, 7, 7, 8, 8, 8, 9, 9, + 10, 8, 7, 7, 7, 8, 8, 8, + 9, 9, 9, 9, 8, 8, 8, 8, + 8, 9, 9, 9, 9, 8, 8, 8, + 9, 9, 9, 9, 10, 9, 9, 9, + 9, 9, 9, 10, 9, 9, 9, 10, + 10, 11, 10, 10, 10, 10, 11, 10, + 10, 10, 11, 10, 11, 12, 11, 12, + 3, +}; + + +#define HUFF_VEC1_SIZE 101 +#define HUFF_VEC1_MAXBITS 11 +static const uint16_t vec1_huffcodes[HUFF_VEC1_SIZE] = { + 0x01A, 0x003, 0x017, 0x010, 0x00C, 0x009, 0x005, 0x000, + 0x00D, 0x00A, 0x009, 0x00C, 0x00F, 0x002, 0x004, 0x007, + 0x00B, 0x00F, 0x01C, 0x006, 0x010, 0x015, 0x01C, 0x022, + 0x03B, 0x00E, 0x019, 0x023, 0x034, 0x036, 0x03A, 0x047, + 0x008, 0x00A, 0x01E, 0x031, 0x037, 0x050, 0x053, 0x06B, + 0x06F, 0x08C, 0x0E8, 0x0EA, 0x0EB, 0x016, 0x03E, 0x03F, + 0x06C, 0x089, 0x08A, 0x0A3, 0x0A4, 0x0D4, 0x0DD, 0x0EC, + 0x0EE, 0x11A, 0x1D2, 0x024, 0x025, 0x02E, 0x027, 0x0C2, + 0x0C0, 0x0DA, 0x0DB, 0x111, 0x144, 0x116, 0x14A, 0x145, + 0x1B8, 0x1AB, 0x1DA, 0x1DE, 0x1DB, 0x1DF, 0x236, 0x237, + 0x3A6, 0x3A7, 0x04D, 0x04C, 0x05E, 0x05F, 0x183, 0x182, + 0x186, 0x221, 0x187, 0x220, 0x22E, 0x22F, 0x296, 0x354, + 0x297, 0x355, 0x372, 0x373, 0x016, +}; + +static const uint8_t vec1_huffbits[HUFF_VEC1_SIZE] = { + 7, 6, 5, 5, 5, 5, 5, 5, + 4, 4, 4, 4, 4, 5, 5, 5, + 5, 5, 5, 6, 6, 6, 6, 6, + 6, 7, 7, 7, 7, 7, 7, 7, + 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 5, +}; + + +static const uint16_t symbol_to_vec4[HUFF_VEC4_SIZE] = { + 0, 1, 2, 3, 4, 5, 16, 17, 18, 19, + 20, 32, 33, 34, 35, 48, 49, 50, 64, 65, + 80, 256, 257, 258, 259, 260, 272, 273, 274, 275, + 288, 289, 290, 304, 305, 320, 512, 513, 514, 515, + 528, 529, 530, 544, 545, 560, 768, 769, 770, 784, + 785, 800, 1024, 1025, 1040, 1280, 4096, 4097, 4098, 4099, + 4100, 4112, 4113, 4114, 4115, 4128, 4129, 4130, 4144, 4145, + 4160, 4352, 4353, 4354, 4355, 4368, 4369, 4370, 4384, 4385, + 4400, 4608, 4609, 4610, 4624, 4625, 4640, 4864, 4865, 4880, + 5120, 8192, 8193, 8194, 8195, 8208, 8209, 8210, 8224, 8225, + 8240, 8448, 8449, 8450, 8464, 8465, 8480, 8704, 8705, 8720, + 8960, 12288, 12289, 12290, 12304, 12305, 12320, 12544, 12545, 12560, + 12800, 16384, 16385, 16400, 16640, 20480, 0, +}; + + +static const uint8_t symbol_to_vec2[HUFF_VEC2_SIZE] = { + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, + 30, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, + 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 64, 65, + 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 80, 81, 82, 83, 84, + 85, 86, 87, 88, 89, 90, 96, 97, 98, 99, 100, 101, 102, 103, 104, + 105, 112, 113, 114, 115, 116, 117, 118, 119, 120, 128, 129, 130, 131, 132, + 133, 134, 135, 144, 145, 146, 147, 148, 149, 150, 160, 161, 162, 163, 164, + 165, 176, 177, 178, 179, 180, 192, 193, 194, 195, 208, 209, 210, 224, 225, + 240, 0, +}; +/** @} */ + + +/** + * @brief decorrelation matrix for multichannel streams + **/ +/* rockbox: not used +static const float default_decorrelation_matrices[] = { + 1.000000, 0.707031, -0.707031, 0.707031, 0.707031, 0.578125, 0.707031, + 0.410156, 0.578125, -0.707031, 0.410156, 0.578125, 0.000000, -0.816406, + 0.500000, 0.652344, 0.500000, 0.269531, 0.500000, 0.269531, -0.500000, + -0.652344, 0.500000, -0.269531, -0.500000, 0.652344, 0.500000, -0.652344, + 0.500000, -0.269531, 0.445312, 0.601562, 0.511719, 0.371094, 0.195312, + 0.445312, 0.371094, -0.195312, -0.601562, -0.511719, 0.445312, 0.000000, + -0.632812, 0.000000, 0.632812, 0.445312, -0.371094, -0.195312, 0.601562, + -0.511719, 0.445312, -0.601562, 0.511719, -0.371094, 0.195312, 0.410156, + 0.558594, 0.500000, 0.410156, 0.289062, 0.148438, 0.410156, 0.410156, + 0.000000, -0.410156, -0.578125, -0.410156, 0.410156, 0.148438, -0.500000, + -0.410156, 0.289062, 0.558594, 0.410156, -0.148438, -0.500000, 0.410156, + 0.289062, -0.558594, 0.410156, -0.410156, 0.000000, 0.410156, -0.578125, + 0.410156, 0.410156, -0.558594, 0.500000, -0.410156, 0.289062, -0.148438, +}; +*/ +/** + * @brief default decorrelation matrix offsets + */ +/* rockbox: not used +static const float * const default_decorrelation[] = { + NULL, + &default_decorrelation_matrices[0], + &default_decorrelation_matrices[1], + &default_decorrelation_matrices[5], + &default_decorrelation_matrices[14], + &default_decorrelation_matrices[30], + &default_decorrelation_matrices[55] +}; +*/ +#endif /* AVCODEC_WMAPRODATA_H */ diff --git a/lib/rbcodec/codecs/libwmapro/wmaprodec.c b/lib/rbcodec/codecs/libwmapro/wmaprodec.c new file mode 100644 index 0000000000..9d42c6de0f --- /dev/null +++ b/lib/rbcodec/codecs/libwmapro/wmaprodec.c @@ -0,0 +1,1626 @@ +/* + * Wmapro compatible decoder + * Copyright (c) 2007 Baptiste Coudurier, Benjamin Larsson, Ulion + * Copyright (c) 2008 - 2009 Sascha Sommer, Benjamin Larsson + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file libavcodec/wmaprodec.c + * @brief wmapro decoder implementation + * Wmapro is an MDCT based codec comparable to wma standard or AAC. + * The decoding therefore consists of the following steps: + * - bitstream decoding + * - reconstruction of per-channel data + * - rescaling and inverse quantization + * - IMDCT + * - windowing and overlapp-add + * + * The compressed wmapro bitstream is split into individual packets. + * Every such packet contains one or more wma frames. + * The compressed frames may have a variable length and frames may + * cross packet boundaries. + * Common to all wmapro frames is the number of samples that are stored in + * a frame. + * The number of samples and a few other decode flags are stored + * as extradata that has to be passed to the decoder. + * + * The wmapro frames themselves are again split into a variable number of + * subframes. Every subframe contains the data for 2^N time domain samples + * where N varies between 7 and 12. + * + * Example wmapro bitstream (in samples): + * + * || packet 0 || packet 1 || packet 2 packets + * --------------------------------------------------- + * || frame 0 || frame 1 || frame 2 || frames + * --------------------------------------------------- + * || | | || | | | || || subframes of channel 0 + * --------------------------------------------------- + * || | | || | | | || || subframes of channel 1 + * --------------------------------------------------- + * + * The frame layouts for the individual channels of a wma frame does not need + * to be the same. + * + * However, if the offsets and lengths of several subframes of a frame are the + * same, the subframes of the channels can be grouped. + * Every group may then use special coding techniques like M/S stereo coding + * to improve the compression ratio. These channel transformations do not + * need to be applied to a whole subframe. Instead, they can also work on + * individual scale factor bands (see below). + * The coefficients that carry the audio signal in the frequency domain + * are transmitted as huffman-coded vectors with 4, 2 and 1 elements. + * In addition to that, the encoder can switch to a runlevel coding scheme + * by transmitting subframe_length / 128 zero coefficients. + * + * Before the audio signal can be converted to the time domain, the + * coefficients have to be rescaled and inverse quantized. + * A subframe is therefore split into several scale factor bands that get + * scaled individually. + * Scale factors are submitted for every frame but they might be shared + * between the subframes of a channel. Scale factors are initially DPCM-coded. + * Once scale factors are shared, the differences are transmitted as runlevel + * codes. + * Every subframe length and offset combination in the frame layout shares a + * common quantization factor that can be adjusted for every channel by a + * modifier. + * After the inverse quantization, the coefficients get processed by an IMDCT. + * The resulting values are then windowed with a sine window and the first half + * of the values are added to the second half of the output from the previous + * subframe in order to reconstruct the output samples. + */ + +#include "ffmpeg_get_bits.h" +#include "ffmpeg_put_bits.h" +#include "wmaprodata.h" +#include "wma.h" +#include "wmaprodec.h" +//#include "wmapro_mdct.h" +#include "mdct_tables.h" +#include "quant.h" +#include "wmapro_math.h" +#include "codecs.h" +#include "codeclib.h" +#include "../libasf/asf.h" + +/* Uncomment the following line to enable some debug output */ +//#define WMAPRO_DUMP_CTX_EN + +#undef DEBUGF +#ifdef WMAPRO_DUMP_CTX_EN +# define DEBUGF printf +#else +# define DEBUGF(...) +#endif + +/* Some defines to make it compile */ +#define AVERROR_INVALIDDATA -1 +#define AVERROR_PATCHWELCOME -2 +#define av_log_ask_for_sample(...) + +/* Taken from avcodec.h */ +#define FF_INPUT_BUFFER_PADDING_SIZE 8 + +/* Taken from libavutil/mem.h */ +#define DECLARE_ALIGNED(n,t,v) t __attribute__ ((aligned (n))) v + +/* Taken from libavutil/common.h */ +#define FFMIN(a,b) ((a) > (b) ? (b) : (a)) +#define FFMAX(a,b) ((a) > (b) ? (a) : (b)) + +/* Define some multiple used constants */ +#define SQRT2_FRACT16 0x00016A0A /* 0x00016A0A = (sqrt(2)*(1<<16)) */ +#define COS_PI4_FRACT16 0x0000B505 /* 0x0000B505 = (cos(pi/4)<<16) */ +#define ONE_FRACT16 0x00010000 /* 0x00010000 = (1<<16) */ + +/* Enable multichannel for large-memory targets only */ +#if (MEMORYSIZE > 2) +#define WMAPRO_MAX_CHANNELS 8 ///< max number of handled channels +#else +#define WMAPRO_MAX_CHANNELS 2 ///< max number of handled channels +#endif + +/* Current decoder limitations */ +#define MAX_SUBFRAMES 32 ///< max number of subframes per channel +#define MAX_BANDS 29 ///< max number of scale factor bands +#define MAX_FRAMESIZE 32768 ///< maximum compressed frame size + +#define WMAPRO_BLOCK_MAX_BITS 12 ///< log2 of max block size +#define WMAPRO_BLOCK_MAX_SIZE (1 << WMAPRO_BLOCK_MAX_BITS) ///< maximum block size +#define WMAPRO_BLOCK_SIZES (WMAPRO_BLOCK_MAX_BITS - BLOCK_MIN_BITS + 1) ///< possible block sizes +#define WMAPRO_OUT_BUF_SIZE (WMAPRO_BLOCK_MAX_SIZE + WMAPRO_BLOCK_MAX_SIZE / 2) + + +#define VLCBITS 9 +#define SCALEVLCBITS 8 +#define VEC4MAXDEPTH ((HUFF_VEC4_MAXBITS+VLCBITS-1)/VLCBITS) +#define VEC2MAXDEPTH ((HUFF_VEC2_MAXBITS+VLCBITS-1)/VLCBITS) +#define VEC1MAXDEPTH ((HUFF_VEC1_MAXBITS+VLCBITS-1)/VLCBITS) +#define SCALEMAXDEPTH ((HUFF_SCALE_MAXBITS+SCALEVLCBITS-1)/SCALEVLCBITS) +#define SCALERLMAXDEPTH ((HUFF_SCALE_RL_MAXBITS+VLCBITS-1)/VLCBITS) + +static VLC sf_vlc; ///< scale factor DPCM vlc +static VLC sf_rl_vlc; ///< scale factor run length vlc +static VLC vec4_vlc; ///< 4 coefficients per symbol +static VLC vec2_vlc; ///< 2 coefficients per symbol +static VLC vec1_vlc; ///< 1 coefficient per symbol +static VLC coef_vlc[2]; ///< coefficient run length vlc codes +//static float sin64[33]; ///< sinus table for decorrelation + +/* Global defined arrays to allow IRAM usage for some models. */ +static int32_t g_tmp[WMAPRO_BLOCK_MAX_SIZE] IBSS_ATTR_WMAPRO_LARGE_IRAM; +static int32_t g_out_ch0[WMAPRO_OUT_BUF_SIZE] IBSS_ATTR; +static int32_t g_out_ch1[WMAPRO_OUT_BUF_SIZE] IBSS_ATTR_WMAPRO_LARGE_IRAM; +#if (WMAPRO_MAX_CHANNELS > 2) + static int32_t g_out_multichannel[WMAPRO_MAX_CHANNELS-2][WMAPRO_OUT_BUF_SIZE]; +#endif + +/** + * @brief frame specific decoder context for a single channel + */ +typedef struct { + int16_t prev_block_len; ///< length of the previous block + uint8_t transmit_coefs; + uint8_t num_subframes; + uint16_t subframe_len[MAX_SUBFRAMES]; ///< subframe length in samples + uint16_t subframe_offset[MAX_SUBFRAMES]; ///< subframe positions in the current frame + uint8_t cur_subframe; ///< current subframe number + uint16_t decoded_samples; ///< number of already processed samples + uint8_t grouped; ///< channel is part of a group + int quant_step; ///< quantization step for the current subframe + int8_t reuse_sf; ///< share scale factors between subframes + int8_t scale_factor_step; ///< scaling step for the current subframe + int max_scale_factor; ///< maximum scale factor for the current subframe + int saved_scale_factors[2][MAX_BANDS]; ///< resampled and (previously) transmitted scale factor values + int8_t scale_factor_idx; ///< index for the transmitted scale factor values (used for resampling) + int* scale_factors; ///< pointer to the scale factor values used for decoding + uint8_t table_idx; ///< index in sf_offsets for the scale factor reference block + int32_t* coeffs; ///< pointer to the subframe decode buffer + int32_t* out; ///< output buffer +} WMAProChannelCtx; + +/** + * @brief channel group for channel transformations + */ +typedef struct { + uint8_t num_channels; ///< number of channels in the group + int8_t transform; ///< transform on / off + int8_t transform_band[MAX_BANDS]; ///< controls if the transform is enabled for a certain band + //float decorrelation_matrix[WMAPRO_MAX_CHANNELS*WMAPRO_MAX_CHANNELS]; + int32_t* channel_data[WMAPRO_MAX_CHANNELS]; ///< transformation coefficients + int32_t fixdecorrelation_matrix[WMAPRO_MAX_CHANNELS*WMAPRO_MAX_CHANNELS]; +} WMAProChannelGrp; + +/** + * @brief main decoder context + */ +typedef struct WMAProDecodeCtx { + /* generic decoder variables */ + uint8_t frame_data[MAX_FRAMESIZE + + FF_INPUT_BUFFER_PADDING_SIZE];///< compressed frame data + PutBitContext pb; ///< context for filling the frame_data buffer + int32_t* tmp; ///< IMDCT input buffer + + /* frame size dependent frame information (set during initialization) */ + uint32_t decode_flags; ///< used compression features + uint8_t len_prefix; ///< frame is prefixed with its length + uint8_t dynamic_range_compression; ///< frame contains DRC data + uint8_t bits_per_sample; ///< integer audio sample size for the unscaled IMDCT output (used to scale to [-1.0, 1.0]) + uint16_t samples_per_frame; ///< number of samples to output + uint16_t log2_frame_size; + int8_t num_channels; ///< number of channels in the stream (same as AVCodecContext.num_channels) + int8_t lfe_channel; ///< lfe channel index + uint8_t max_num_subframes; + uint8_t subframe_len_bits; ///< number of bits used for the subframe length + uint8_t max_subframe_len_bit; ///< flag indicating that the subframe is of maximum size when the first subframe length bit is 1 + uint16_t min_samples_per_subframe; + int8_t num_sfb[WMAPRO_BLOCK_SIZES]; ///< scale factor bands per block size + int16_t sfb_offsets[WMAPRO_BLOCK_SIZES][MAX_BANDS]; ///< scale factor band offsets (multiples of 4) + int8_t sf_offsets[WMAPRO_BLOCK_SIZES][WMAPRO_BLOCK_SIZES][MAX_BANDS]; ///< scale factor resample matrix + int16_t subwoofer_cutoffs[WMAPRO_BLOCK_SIZES]; ///< subwoofer cutoff values + + /* packet decode state */ + GetBitContext pgb; ///< bitstream reader context for the packet + uint8_t packet_offset; ///< frame offset in the packet + uint8_t packet_sequence_number; ///< current packet number + int num_saved_bits; ///< saved number of bits + int frame_offset; ///< frame offset in the bit reservoir + int subframe_offset; ///< subframe offset in the bit reservoir + uint8_t packet_loss; ///< set in case of bitstream error + uint8_t packet_done; ///< set when a packet is fully decoded + + /* frame decode state */ + uint32_t frame_num; ///< current frame number + GetBitContext gb; ///< bitstream reader context + int buf_bit_size; ///< buffer size in bits + int32_t samples; + int32_t* samples_end; ///< maximum samplebuffer pointer + uint8_t drc_gain; ///< gain for the DRC tool + int8_t skip_frame; ///< skip output step + int8_t parsed_all_subframes; ///< all subframes decoded? + + /* subframe/block decode state */ + int16_t subframe_len; ///< current subframe length + int8_t channels_for_cur_subframe; ///< number of channels that contain the subframe + int8_t channel_indexes_for_cur_subframe[WMAPRO_MAX_CHANNELS]; + int8_t num_bands; ///< number of scale factor bands + int16_t* cur_sfb_offsets; ///< sfb offsets for the current block + uint8_t table_idx; ///< index for the num_sfb, sfb_offsets, sf_offsets and subwoofer_cutoffs tables + int8_t esc_len; ///< length of escaped coefficients + + uint8_t num_chgroups; ///< number of channel groups + WMAProChannelGrp chgroup[WMAPRO_MAX_CHANNELS]; ///< channel group information + + WMAProChannelCtx channel[WMAPRO_MAX_CHANNELS]; ///< per channel data +} WMAProDecodeCtx; + +/* static decode context, to avoid malloc */ +static WMAProDecodeCtx globWMAProDecCtx; + +/** + *@brief helper function to print the most important members of the context + *@param s context + */ +#ifdef WMAPRO_DUMP_CTX_EN +static void dump_context(WMAProDecodeCtx *s) +{ +#define PRINT(a, b) printf(" %s = %d\n", a, b); +#define PRINT_HEX(a, b) printf(" %s = %x\n", a, b); + + PRINT("ed sample bit depth", s->bits_per_sample); + PRINT_HEX("ed decode flags", s->decode_flags); + PRINT("samples per frame", s->samples_per_frame); + PRINT("log2 frame size", s->log2_frame_size); + PRINT("max num subframes", s->max_num_subframes); + PRINT("len prefix", s->len_prefix); + PRINT("num channels", s->num_channels); +} +#endif + +/** + *@brief Initialize the decoder. + *@param avctx codec context + *@return 0 on success, -1 otherwise + */ +int decode_init(asf_waveformatex_t *wfx) +{ + memset(&globWMAProDecCtx, 0, sizeof(WMAProDecodeCtx)); + WMAProDecodeCtx *s = &globWMAProDecCtx; + uint8_t *edata_ptr = wfx->data; + unsigned int channel_mask; + int i; + int log2_max_num_subframes; + int num_possible_block_sizes; + + /* Use globally defined array. Allows IRAM usage for models with large IRAM. */ + s->tmp = g_tmp; + + /* Use globally defined arrays. Allows IRAM usage for up to 2 channels. */ + s->channel[0].out = g_out_ch0; + s->channel[1].out = g_out_ch1; +#if (WMAPRO_MAX_CHANNELS > 2) + for (i=2; ichannel[i].out = g_out_multichannel[i-2]; +#endif + +#if defined(CPU_COLDFIRE) + coldfire_set_macsr(EMAC_FRACTIONAL | EMAC_SATURATE); +#endif + + init_put_bits(&s->pb, s->frame_data, MAX_FRAMESIZE); + + if (wfx->datalen >= 18) { + s->decode_flags = AV_RL16(edata_ptr+14); + channel_mask = AV_RL32(edata_ptr+2); + s->bits_per_sample = AV_RL16(edata_ptr); + /** dump the extradata */ + for (i = 0; i < wfx->datalen; i++) + DEBUGF("[%x] ", wfx->data[i]); + DEBUGF("\n"); + + } else { + DEBUGF("Unknown extradata size\n"); + return AVERROR_INVALIDDATA; + } + + /** generic init */ + s->log2_frame_size = av_log2(wfx->blockalign) + 4; + + /** frame info */ + s->skip_frame = 1; /** skip first frame */ + s->packet_loss = 1; + s->len_prefix = (s->decode_flags & 0x40); + + if (!s->len_prefix) { + DEBUGF("no length prefix\n"); + return AVERROR_INVALIDDATA; + } + + /** get frame len */ + s->samples_per_frame = 1 << ff_wma_get_frame_len_bits(wfx->rate, + 3, s->decode_flags); + + /** init previous block len */ + for (i = 0; i < wfx->channels; i++) + s->channel[i].prev_block_len = s->samples_per_frame; + + /** subframe info */ + log2_max_num_subframes = ((s->decode_flags & 0x38) >> 3); + s->max_num_subframes = 1 << log2_max_num_subframes; + if (s->max_num_subframes == 16) + s->max_subframe_len_bit = 1; + s->subframe_len_bits = av_log2(log2_max_num_subframes) + 1; + + num_possible_block_sizes = log2_max_num_subframes + 1; + s->min_samples_per_subframe = s->samples_per_frame / s->max_num_subframes; + s->dynamic_range_compression = (s->decode_flags & 0x80); + + if (s->max_num_subframes > MAX_SUBFRAMES) { + DEBUGF("invalid number of subframes %i\n", + s->max_num_subframes); + return AVERROR_INVALIDDATA; + } + + s->num_channels = wfx->channels; + + /** extract lfe channel position */ + s->lfe_channel = -1; + + if (channel_mask & 8) { + unsigned int mask; + for (mask = 1; mask < 16; mask <<= 1) { + if (channel_mask & mask) + ++s->lfe_channel; + } + } + + if (s->num_channels < 0) { + DEBUGF("invalid number of channels %d\n", s->num_channels); + return AVERROR_INVALIDDATA; + } else if (s->num_channels > WMAPRO_MAX_CHANNELS) { + DEBUGF("unsupported number of channels\n"); + return AVERROR_PATCHWELCOME; + } + + INIT_VLC_STATIC(&sf_vlc, SCALEVLCBITS, HUFF_SCALE_SIZE, + scale_huffbits, 1, 1, + scale_huffcodes, 2, 2, 616, IBSS_ATTR_WMAPRO_VLC_TABLES); + + INIT_VLC_STATIC(&sf_rl_vlc, VLCBITS, HUFF_SCALE_RL_SIZE, + scale_rl_huffbits, 1, 1, + scale_rl_huffcodes, 4, 4, 1406, IBSS_ATTR_WMAPRO_VLC_TABLES); + + INIT_VLC_STATIC(&coef_vlc[0], VLCBITS, HUFF_COEF0_SIZE, + coef0_huffbits, 1, 1, + coef0_huffcodes, 4, 4, 2108, IBSS_ATTR_WMAPRO_VLC_TABLES); + + INIT_VLC_STATIC(&coef_vlc[1], VLCBITS, HUFF_COEF1_SIZE, + coef1_huffbits, 1, 1, + coef1_huffcodes, 4, 4, 3912, IBSS_ATTR_WMAPRO_VLC_TABLES); + + INIT_VLC_STATIC(&vec4_vlc, VLCBITS, HUFF_VEC4_SIZE, + vec4_huffbits, 1, 1, + vec4_huffcodes, 2, 2, 604, IBSS_ATTR_WMAPRO_VLC_TABLES); + + INIT_VLC_STATIC(&vec2_vlc, VLCBITS, HUFF_VEC2_SIZE, + vec2_huffbits, 1, 1, + vec2_huffcodes, 2, 2, 562, IBSS_ATTR_WMAPRO_VLC_TABLES); + + INIT_VLC_STATIC(&vec1_vlc, VLCBITS, HUFF_VEC1_SIZE, + vec1_huffbits, 1, 1, + vec1_huffcodes, 2, 2, 562, IBSS_ATTR_WMAPRO_VLC_TABLES); + + /** calculate number of scale factor bands and their offsets + for every possible block size */ + for (i = 0; i < num_possible_block_sizes; i++) { + int subframe_len = s->samples_per_frame >> i; + int x; + int band = 1; + + s->sfb_offsets[i][0] = 0; + + for (x = 0; x < MAX_BANDS-1 && s->sfb_offsets[i][band - 1] < subframe_len; x++) { + int offset = (subframe_len * 2 * critical_freq[x]) + / wfx->rate + 2; + offset &= ~3; + if (offset > s->sfb_offsets[i][band - 1]) + s->sfb_offsets[i][band++] = offset; + } + s->sfb_offsets[i][band - 1] = subframe_len; + s->num_sfb[i] = band - 1; + } + + + /** Scale factors can be shared between blocks of different size + as every block has a different scale factor band layout. + The matrix sf_offsets is needed to find the correct scale factor. + */ + + for (i = 0; i < num_possible_block_sizes; i++) { + int b; + for (b = 0; b < s->num_sfb[i]; b++) { + int x; + int offset = ((s->sfb_offsets[i][b] + + s->sfb_offsets[i][b + 1] - 1) << i) >> 1; + for (x = 0; x < num_possible_block_sizes; x++) { + int v = 0; + while (s->sfb_offsets[x][v + 1] << x < offset) + ++v; + s->sf_offsets[i][x][b] = v; + } + } + } + + /** calculate subwoofer cutoff values */ + for (i = 0; i < num_possible_block_sizes; i++) { + int block_size = s->samples_per_frame >> i; + int cutoff = (440*block_size + 3 * (wfx->rate >> 1) - 1) + / wfx->rate; + s->subwoofer_cutoffs[i] = av_clip(cutoff, 4, block_size); + } + +#if 0 + /** calculate sine values for the decorrelation matrix */ + for (i = 0; i < 33; i++) + sin64[i] = sin(i*M_PI / 64.0); +#endif + +#ifdef WMAPRO_DUMP_CTX_EN + dump_context(s); +#endif + return 0; +} + +/** + *@brief Decode the subframe length. + *@param s context + *@param offset sample offset in the frame + *@return decoded subframe length on success, < 0 in case of an error + */ +static int decode_subframe_length(WMAProDecodeCtx *s, int offset) +{ + int frame_len_shift = 0; + int subframe_len; + + /** no need to read from the bitstream when only one length is possible */ + if (offset == s->samples_per_frame - s->min_samples_per_subframe) + return s->min_samples_per_subframe; + + /** 1 bit indicates if the subframe is of maximum length */ + if (s->max_subframe_len_bit) { + if (get_bits1(&s->gb)) + frame_len_shift = 1 + get_bits(&s->gb, s->subframe_len_bits-1); + } else + frame_len_shift = get_bits(&s->gb, s->subframe_len_bits); + + subframe_len = s->samples_per_frame >> frame_len_shift; + + /** sanity check the length */ + if (subframe_len < s->min_samples_per_subframe || + subframe_len > s->samples_per_frame) { + DEBUGF("broken frame: subframe_len %i\n", + subframe_len); + return AVERROR_INVALIDDATA; + } + return subframe_len; +} + +/** + *@brief Decode how the data in the frame is split into subframes. + * Every WMA frame contains the encoded data for a fixed number of + * samples per channel. The data for every channel might be split + * into several subframes. This function will reconstruct the list of + * subframes for every channel. + * + * If the subframes are not evenly split, the algorithm estimates the + * channels with the lowest number of total samples. + * Afterwards, for each of these channels a bit is read from the + * bitstream that indicates if the channel contains a subframe with the + * next subframe size that is going to be read from the bitstream or not. + * If a channel contains such a subframe, the subframe size gets added to + * the channel's subframe list. + * The algorithm repeats these steps until the frame is properly divided + * between the individual channels. + * + *@param s context + *@return 0 on success, < 0 in case of an error + */ +static int decode_tilehdr(WMAProDecodeCtx *s) +{ + uint16_t num_samples[WMAPRO_MAX_CHANNELS]; /** sum of samples for all currently known subframes of a channel */ + uint8_t contains_subframe[WMAPRO_MAX_CHANNELS]; /** flag indicating if a channel contains the current subframe */ + int channels_for_cur_subframe = s->num_channels; /** number of channels that contain the current subframe */ + int fixed_channel_layout = 0; /** flag indicating that all channels use the same subframe offsets and sizes */ + int min_channel_len = 0; /** smallest sum of samples (channels with this length will be processed first) */ + int c; + + /* Should never consume more than 3073 bits (256 iterations for the + * while loop when always the minimum amount of 128 samples is substracted + * from missing samples in the 8 channel case). + * 1 + BLOCK_MAX_SIZE * MAX_CHANNELS / BLOCK_MIN_SIZE * (MAX_CHANNELS + 4) + */ + + /** reset tiling information */ + for (c = 0; c < s->num_channels; c++) + s->channel[c].num_subframes = 0; + + memset(num_samples, 0, sizeof(num_samples)); + + if (s->max_num_subframes == 1 || get_bits1(&s->gb)) + fixed_channel_layout = 1; + + /** loop until the frame data is split between the subframes */ + do { + int subframe_len; + + /** check which channels contain the subframe */ + for (c = 0; c < s->num_channels; c++) { + if (num_samples[c] == min_channel_len) { + if (fixed_channel_layout || channels_for_cur_subframe == 1 || + (min_channel_len == s->samples_per_frame - s->min_samples_per_subframe)) + contains_subframe[c] = 1; + else + contains_subframe[c] = get_bits1(&s->gb); + } else + contains_subframe[c] = 0; + } + + /** get subframe length, subframe_len == 0 is not allowed */ + if ((subframe_len = decode_subframe_length(s, min_channel_len)) <= 0) + return AVERROR_INVALIDDATA; + + /** add subframes to the individual channels and find new min_channel_len */ + min_channel_len += subframe_len; + for (c = 0; c < s->num_channels; c++) { + WMAProChannelCtx* chan = &s->channel[c]; + + if (contains_subframe[c]) { + if (chan->num_subframes >= MAX_SUBFRAMES) { + DEBUGF("broken frame: num subframes > 31\n"); + return AVERROR_INVALIDDATA; + } + chan->subframe_len[chan->num_subframes] = subframe_len; + num_samples[c] += subframe_len; + ++chan->num_subframes; + if (num_samples[c] > s->samples_per_frame) { + DEBUGF("broken frame: " + "channel len > samples_per_frame\n"); + return AVERROR_INVALIDDATA; + } + } else if (num_samples[c] <= min_channel_len) { + if (num_samples[c] < min_channel_len) { + channels_for_cur_subframe = 0; + min_channel_len = num_samples[c]; + } + ++channels_for_cur_subframe; + } + } + } while (min_channel_len < s->samples_per_frame); + + for (c = 0; c < s->num_channels; c++) { + int i; + int offset = 0; + for (i = 0; i < s->channel[c].num_subframes; i++) { + DEBUGF("frame[%i] channel[%i] subframe[%i]" + " len %i\n", s->frame_num, c, i, + s->channel[c].subframe_len[i]); + s->channel[c].subframe_offset[i] = offset; + offset += s->channel[c].subframe_len[i]; + } + } + + return 0; +} + +#if 0 +/** + *@brief Calculate a decorrelation matrix from the bitstream parameters. + *@param s codec context + *@param chgroup channel group for which the matrix needs to be calculated + */ +static void decode_decorrelation_matrix(WMAProDecodeCtx *s, + WMAProChannelGrp *chgroup) +{ + int i; + int offset = 0; + int8_t rotation_offset[WMAPRO_MAX_CHANNELS * WMAPRO_MAX_CHANNELS]; + memset(chgroup->decorrelation_matrix, 0, s->num_channels * + s->num_channels * sizeof(*chgroup->decorrelation_matrix)); + + for (i = 0; i < chgroup->num_channels * (chgroup->num_channels - 1) >> 1; i++) + rotation_offset[i] = get_bits(&s->gb, 6); + + for (i = 0; i < chgroup->num_channels; i++) { + chgroup->decorrelation_matrix[chgroup->num_channels * i + i] = + get_bits1(&s->gb) ? 1.0 : -1.0; + + if(chgroup->decorrelation_matrix[chgroup->num_channels * i + i] > 0) + chgroup->fixdecorrelation_matrix[chgroup->num_channels * i + i] = ONE_FRACT16; + else + chgroup->fixdecorrelation_matrix[chgroup->num_channels * i + i] = -ONE_FRACT16; + } + + for (i = 1; i < chgroup->num_channels; i++) { + int x; + for (x = 0; x < i; x++) { + int y; + for (y = 0; y < i + 1; y++) { + float v1 = chgroup->decorrelation_matrix[x * chgroup->num_channels + y]; + float v2 = chgroup->decorrelation_matrix[i * chgroup->num_channels + y]; + int32_t f1 = chgroup->fixdecorrelation_matrix[x * chgroup->num_channels + y]; + int32_t f2 = chgroup->fixdecorrelation_matrix[i * chgroup->num_channels + y]; + int n = rotation_offset[offset + x]; + float sinv; + float cosv; + int32_t fixsinv; + int32_t fixcosv; + + if (n < 32) { + sinv = sin64[n]; + cosv = sin64[32 - n]; + fixsinv = fixed_sin64[n]; + fixcosv = fixed_sin64[32-n]; + } else { + sinv = sin64[64 - n]; + cosv = -sin64[n - 32]; + fixsinv = fixed_sin64[64-n]; + fixcosv = -fixed_sin64[n-32]; + } + + chgroup->decorrelation_matrix[y + x * chgroup->num_channels] = + (v1 * sinv) - (v2 * cosv); + chgroup->decorrelation_matrix[y + i * chgroup->num_channels] = + (v1 * cosv) + (v2 * sinv); + chgroup->fixdecorrelation_matrix[y + x * chgroup->num_channels] = + fixmul31(f1, fixsinv) - fixmul31(f2, fixcosv); + chgroup->fixdecorrelation_matrix[y + i * chgroup->num_channels] = + fixmul31(f1, fixcosv) + fixmul31(f2, fixsinv); + + } + } + offset += i; + } +} +#endif + +/** + *@brief Decode channel transformation parameters + *@param s codec context + *@return 0 in case of success, < 0 in case of bitstream errors + */ +static int decode_channel_transform(WMAProDecodeCtx* s) +{ + int i; + /* should never consume more than 1921 bits for the 8 channel case + * 1 + MAX_CHANNELS * (MAX_CHANNELS + 2 + 3 * MAX_CHANNELS * MAX_CHANNELS + * + MAX_CHANNELS + MAX_BANDS + 1) + */ + + /** in the one channel case channel transforms are pointless */ + s->num_chgroups = 0; + if (s->num_channels > 1) { + int remaining_channels = s->channels_for_cur_subframe; + + if (get_bits1(&s->gb)) { + DEBUGF("unsupported channel transform bit\n"); + return AVERROR_INVALIDDATA; + } + + for (s->num_chgroups = 0; remaining_channels && + s->num_chgroups < s->channels_for_cur_subframe; s->num_chgroups++) { + WMAProChannelGrp* chgroup = &s->chgroup[s->num_chgroups]; + int32_t** channel_data = chgroup->channel_data; + chgroup->num_channels = 0; + chgroup->transform = 0; + + /** decode channel mask */ + if (remaining_channels > 2) { + for (i = 0; i < s->channels_for_cur_subframe; i++) { + int channel_idx = s->channel_indexes_for_cur_subframe[i]; + if (!s->channel[channel_idx].grouped + && get_bits1(&s->gb)) { + ++chgroup->num_channels; + s->channel[channel_idx].grouped = 1; + *channel_data++ = s->channel[channel_idx].coeffs; + } + } + } else { + chgroup->num_channels = remaining_channels; + for (i = 0; i < s->channels_for_cur_subframe; i++) { + int channel_idx = s->channel_indexes_for_cur_subframe[i]; + if (!s->channel[channel_idx].grouped) + *channel_data++ = s->channel[channel_idx].coeffs; + s->channel[channel_idx].grouped = 1; + } + } + + /** decode transform type */ + if (chgroup->num_channels == 2) { + if (get_bits1(&s->gb)) { + if (get_bits1(&s->gb)) { + DEBUGF("unsupported channel transform type\n"); + } + } else { + chgroup->transform = 1; + if (s->num_channels == 2) { + chgroup->fixdecorrelation_matrix[0] = ONE_FRACT16; + chgroup->fixdecorrelation_matrix[1] = -ONE_FRACT16; + chgroup->fixdecorrelation_matrix[2] = ONE_FRACT16; + chgroup->fixdecorrelation_matrix[3] = ONE_FRACT16; + } else { + /** cos(pi/4) */ + chgroup->fixdecorrelation_matrix[0] = COS_PI4_FRACT16; + chgroup->fixdecorrelation_matrix[1] = -COS_PI4_FRACT16; + chgroup->fixdecorrelation_matrix[2] = COS_PI4_FRACT16; + chgroup->fixdecorrelation_matrix[3] = COS_PI4_FRACT16; + } + } + } else if (chgroup->num_channels > 2) { + DEBUGF("in wmaprodec.c: Multichannel streams still not supported\n"); + return -1; +#if 0 + if (get_bits1(&s->gb)) { + chgroup->transform = 1; + if (get_bits1(&s->gb)) { + decode_decorrelation_matrix(s, chgroup); + } else { + /** FIXME: more than 6 coupled channels not supported */ + if (chgroup->num_channels > 6) { + av_log_ask_for_sample(s->avctx, + "coupled channels > 6\n"); + } else { + memcpy(chgroup->decorrelation_matrix, + default_decorrelation[chgroup->num_channels], + chgroup->num_channels * chgroup->num_channels * + sizeof(*chgroup->decorrelation_matrix)); + } + } + } +#endif + } + + /** decode transform on / off */ + if (chgroup->transform) { + if (!get_bits1(&s->gb)) { + int i; + /** transform can be enabled for individual bands */ + for (i = 0; i < s->num_bands; i++) { + chgroup->transform_band[i] = get_bits1(&s->gb); + } + } else { + memset(chgroup->transform_band, 1, s->num_bands); + } + } + remaining_channels -= chgroup->num_channels; + } + } + return 0; +} + +/** + *@brief Extract the coefficients from the bitstream. + *@param s codec context + *@param c current channel number + *@return 0 on success, < 0 in case of bitstream errors + */ +static int decode_coeffs(WMAProDecodeCtx *s, int c) +{ + int vlctable; + VLC* vlc; + WMAProChannelCtx* ci = &s->channel[c]; + int rl_mode = 0; + int cur_coeff = 0; + int num_zeros = 0; + const uint16_t* run; + const int32_t* level; + + DEBUGF("decode coefficients for channel %i\n", c); + + vlctable = get_bits1(&s->gb); + vlc = &coef_vlc[vlctable]; + + if (vlctable) { + run = coef1_run; + level = coef1_level; + } else { + run = coef0_run; + level = coef0_level; + } + + /** decode vector coefficients (consumes up to 167 bits per iteration for + 4 vector coded large values) */ + while (!rl_mode && cur_coeff + 3 < s->subframe_len) { + int32_t vals[4]; + int i; + unsigned int idx; + + idx = get_vlc2(&s->gb, vec4_vlc.table, VLCBITS, VEC4MAXDEPTH); + + if (idx == HUFF_VEC4_SIZE - 1) { + for (i = 0; i < 4; i += 2) { + idx = get_vlc2(&s->gb, vec2_vlc.table, VLCBITS, VEC2MAXDEPTH); + if (idx == HUFF_VEC2_SIZE - 1) { + int v0, v1; + v0 = get_vlc2(&s->gb, vec1_vlc.table, VLCBITS, VEC1MAXDEPTH); + if (v0 == HUFF_VEC1_SIZE - 1) + v0 += ff_wma_get_large_val(&s->gb); + v1 = get_vlc2(&s->gb, vec1_vlc.table, VLCBITS, VEC1MAXDEPTH); + if (v1 == HUFF_VEC1_SIZE - 1) + v1 += ff_wma_get_large_val(&s->gb); + + vals[i ] = v0; + vals[i+1] = v1; + } else { + vals[i ] = symbol_to_vec2[idx] >> 4; + vals[i+1] = symbol_to_vec2[idx] & 0xF; + } + } + } else { + vals[0] = (symbol_to_vec4[idx] >> 12); + vals[1] = (symbol_to_vec4[idx] >> 8) & 0xF; + vals[2] = (symbol_to_vec4[idx] >> 4) & 0xF; + vals[3] = (symbol_to_vec4[idx] ) & 0xF; + } + + /* Rockbox: To be able to use rockbox' optimized mdct we need to + * pre-shift the values by >>(nbits-3). */ + const int nbits = av_log2(s->subframe_len)+1; + const int shift = WMAPRO_FRACT-(nbits-3); + + /** decode sign */ + for (i = 0; i < 4; i++) { + if (vals[i]) { + int sign = get_bits1(&s->gb) - 1; + /* Rockbox: To be able to use rockbox' optimized mdct we need + * invert the sign. */ + ci->coeffs[cur_coeff] = (sign == -1)? vals[i]<coeffs[cur_coeff] = 0; + /** switch to run level mode when subframe_len / 128 zeros + were found in a row */ + rl_mode |= (++num_zeros > s->subframe_len >> 8); + } + ++cur_coeff; + } + } + + /** decode run level coded coefficients */ + if (rl_mode) { + memset(&ci->coeffs[cur_coeff], 0, + sizeof(*ci->coeffs) * (s->subframe_len - cur_coeff)); + + if (ff_wma_run_level_decode(&s->gb, vlc, + level, run, 1, ci->coeffs, + cur_coeff, s->subframe_len, + s->subframe_len, s->esc_len, 0)) + return AVERROR_INVALIDDATA; + + } + return 0; +} + +/** + *@brief Extract scale factors from the bitstream. + *@param s codec context + *@return 0 on success, < 0 in case of bitstream errors + */ +static int decode_scale_factors(WMAProDecodeCtx* s) +{ + int i; + + /** should never consume more than 5344 bits + * MAX_CHANNELS * (1 + MAX_BANDS * 23) + */ + + for (i = 0; i < s->channels_for_cur_subframe; i++) { + int c = s->channel_indexes_for_cur_subframe[i]; + int* sf; + int* sf_end; + s->channel[c].scale_factors = s->channel[c].saved_scale_factors[!s->channel[c].scale_factor_idx]; + sf_end = s->channel[c].scale_factors + s->num_bands; + + /** resample scale factors for the new block size + * as the scale factors might need to be resampled several times + * before some new values are transmitted, a backup of the last + * transmitted scale factors is kept in saved_scale_factors + */ + if (s->channel[c].reuse_sf) { + const int8_t* sf_offsets = s->sf_offsets[s->table_idx][s->channel[c].table_idx]; + int b; + for (b = 0; b < s->num_bands; b++) + s->channel[c].scale_factors[b] = + s->channel[c].saved_scale_factors[s->channel[c].scale_factor_idx][*sf_offsets++]; + } + + if (!s->channel[c].cur_subframe || get_bits1(&s->gb)) { + + if (!s->channel[c].reuse_sf) { + int val; + /** decode DPCM coded scale factors */ + s->channel[c].scale_factor_step = get_bits(&s->gb, 2) + 1; + val = 45 / s->channel[c].scale_factor_step; + for (sf = s->channel[c].scale_factors; sf < sf_end; sf++) { + val += get_vlc2(&s->gb, sf_vlc.table, SCALEVLCBITS, SCALEMAXDEPTH) - 60; + *sf = val; + } + } else { + int i; + /** run level decode differences to the resampled factors */ + for (i = 0; i < s->num_bands; i++) { + int idx; + int skip; + int val; + int sign; + + idx = get_vlc2(&s->gb, sf_rl_vlc.table, VLCBITS, SCALERLMAXDEPTH); + + if (!idx) { + uint32_t code = get_bits(&s->gb, 14); + val = code >> 6; + sign = (code & 1) - 1; + skip = (code & 0x3f) >> 1; + } else if (idx == 1) { + break; + } else { + skip = scale_rl_run[idx]; + val = scale_rl_level[idx]; + sign = get_bits1(&s->gb)-1; + } + + i += skip; + if (i >= s->num_bands) { + DEBUGF("invalid scale factor coding\n"); + return AVERROR_INVALIDDATA; + } + s->channel[c].scale_factors[i] += (val ^ sign) - sign; + } + } + + /** swap buffers */ + s->channel[c].scale_factor_idx = !s->channel[c].scale_factor_idx; + s->channel[c].table_idx = s->table_idx; + s->channel[c].reuse_sf = 1; + } + + /** calculate new scale factor maximum */ + s->channel[c].max_scale_factor = s->channel[c].scale_factors[0]; + for (sf = s->channel[c].scale_factors + 1; sf < sf_end; sf++) { + s->channel[c].max_scale_factor = + FFMAX(s->channel[c].max_scale_factor, *sf); + } + + } + return 0; +} + +/** + *@brief Reconstruct the individual channel data. + *@param s codec context + */ +static void inverse_channel_transform(WMAProDecodeCtx *s) +{ + int i; + + for (i = 0; i < s->num_chgroups; i++) { + if (s->chgroup[i].transform) { + const int num_channels = s->chgroup[i].num_channels; + int32_t data[WMAPRO_MAX_CHANNELS]; + int32_t** ch_data = s->chgroup[i].channel_data; + int32_t** ch_end = ch_data + num_channels; + const int8_t* tb = s->chgroup[i].transform_band; + int16_t* sfb; + + /** multichannel decorrelation */ + for (sfb = s->cur_sfb_offsets; + sfb < s->cur_sfb_offsets + s->num_bands; sfb++) { + int y; + if (*tb++ == 1) { + /** multiply values with the decorrelation_matrix */ + for (y = sfb[0]; y < FFMIN(sfb[1], s->subframe_len); y++) { + const int32_t* mat = s->chgroup[i].fixdecorrelation_matrix; + const int32_t* data_end = data + num_channels; + int32_t* data_ptr = data; + int32_t** ch; + + for (ch = ch_data; ch < ch_end; ch++) + *data_ptr++ = (*ch)[y]; + + for (ch = ch_data; ch < ch_end; ch++) { + int32_t sum = 0; + data_ptr = data; + + while (data_ptr < data_end) + sum += fixmul16(*mat++, *data_ptr++); + + (*ch)[y] = sum; + } + } + } else if (s->num_channels == 2) { + + /* Scale with sqrt(2) */ + int len = FFMIN(sfb[1], s->subframe_len) - sfb[0]; + vector_fixmul_scalar(ch_data[0] + sfb[0], + ch_data[0] + sfb[0], + SQRT2_FRACT16, len); + vector_fixmul_scalar(ch_data[1] + sfb[0], + ch_data[1] + sfb[0], + SQRT2_FRACT16, len); + + } + } + } + } +} + +/** + *@brief Apply sine window and reconstruct the output buffer. + *@param s codec context + */ +static void wmapro_window(WMAProDecodeCtx *s) +{ + int i; + + for (i = 0; i < s->channels_for_cur_subframe; i++) { + int c = s->channel_indexes_for_cur_subframe[i]; + const int32_t* window; + int winlen = s->channel[c].prev_block_len; + int32_t *xstart= s->channel[c].coeffs - (winlen >> 1); + + if (s->subframe_len < winlen) { + xstart += (winlen - s->subframe_len) >> 1; + winlen = s->subframe_len; + } + + window = sine_windows[av_log2(winlen) - BLOCK_MIN_BITS]; + + winlen >>= 1; + + vector_fixmul_window(xstart, xstart, xstart + winlen, + window, winlen); + + s->channel[c].prev_block_len = s->subframe_len; + + } +} + +/** + *@brief Decode a single subframe (block). + *@param s codec context + *@return 0 on success, < 0 when decoding failed + */ +static int decode_subframe(WMAProDecodeCtx *s) +{ + int offset = s->samples_per_frame; + int subframe_len = s->samples_per_frame; + int i; + int total_samples = s->samples_per_frame * s->num_channels; + int transmit_coeffs = 0; + int cur_subwoofer_cutoff; + + s->subframe_offset = get_bits_count(&s->gb); + + /** reset channel context and find the next block offset and size + == the next block of the channel with the smallest number of + decoded samples + */ + for (i = 0; i < s->num_channels; i++) { + s->channel[i].grouped = 0; + if (offset > s->channel[i].decoded_samples) { + offset = s->channel[i].decoded_samples; + subframe_len = + s->channel[i].subframe_len[s->channel[i].cur_subframe]; + } + } + + DEBUGF("processing subframe with offset %i len %i\n", offset, subframe_len); + + /** get a list of all channels that contain the estimated block */ + s->channels_for_cur_subframe = 0; + for (i = 0; i < s->num_channels; i++) { + const int cur_subframe = s->channel[i].cur_subframe; + /** substract already processed samples */ + total_samples -= s->channel[i].decoded_samples; + + /** and count if there are multiple subframes that match our profile */ + if (offset == s->channel[i].decoded_samples && + subframe_len == s->channel[i].subframe_len[cur_subframe]) { + total_samples -= s->channel[i].subframe_len[cur_subframe]; + s->channel[i].decoded_samples += + s->channel[i].subframe_len[cur_subframe]; + s->channel_indexes_for_cur_subframe[s->channels_for_cur_subframe] = i; + ++s->channels_for_cur_subframe; + } + } + + /** check if the frame will be complete after processing the + estimated block */ + if (!total_samples) + s->parsed_all_subframes = 1; + + + DEBUGF("subframe is part of %i channels\n", s->channels_for_cur_subframe); + + /** calculate number of scale factor bands and their offsets */ + s->table_idx = av_log2(s->samples_per_frame/subframe_len); + s->num_bands = s->num_sfb[s->table_idx]; + s->cur_sfb_offsets = s->sfb_offsets[s->table_idx]; + cur_subwoofer_cutoff = s->subwoofer_cutoffs[s->table_idx]; + + /** configure the decoder for the current subframe */ + for (i = 0; i < s->channels_for_cur_subframe; i++) { + int c = s->channel_indexes_for_cur_subframe[i]; + + s->channel[c].coeffs = &s->channel[c].out[(s->samples_per_frame >> 1) + + offset]; + } + + s->subframe_len = subframe_len; + s->esc_len = av_log2(s->subframe_len - 1) + 1; + + /** skip extended header if any */ + if (get_bits1(&s->gb)) { + int num_fill_bits; + if (!(num_fill_bits = get_bits(&s->gb, 2))) { + int len = get_bits(&s->gb, 4); + num_fill_bits = get_bits(&s->gb, len) + 1; + } + + if (num_fill_bits >= 0) { + if (get_bits_count(&s->gb) + num_fill_bits > s->num_saved_bits) { + DEBUGF("invalid number of fill bits\n"); + return AVERROR_INVALIDDATA; + } + + skip_bits_long(&s->gb, num_fill_bits); + } + } + + /** no idea for what the following bit is used */ + if (get_bits1(&s->gb)) { + DEBUGF("reserved bit set\n"); + return AVERROR_INVALIDDATA; + } + + if (decode_channel_transform(s) < 0) + return AVERROR_INVALIDDATA; + + for (i = 0; i < s->channels_for_cur_subframe; i++) { + int c = s->channel_indexes_for_cur_subframe[i]; + if ((s->channel[c].transmit_coefs = get_bits1(&s->gb))) + transmit_coeffs = 1; + } + + if (transmit_coeffs) { + int step; + int quant_step = 90 * s->bits_per_sample >> 4; + if ((get_bits1(&s->gb))) { + /** FIXME: might change run level mode decision */ + DEBUGF("unsupported quant step coding\n"); + return AVERROR_INVALIDDATA; + } + /** decode quantization step */ + step = get_sbits(&s->gb, 6); + quant_step += step; + if (step == -32 || step == 31) { + const int sign = (step == 31) - 1; + int quant = 0; + while (get_bits_count(&s->gb) + 5 < s->num_saved_bits && + (step = get_bits(&s->gb, 5)) == 31) { + quant += 31; + } + quant_step += ((quant + step) ^ sign) - sign; + } + if (quant_step < 0) { + DEBUGF("negative quant step\n"); + } + + /** decode quantization step modifiers for every channel */ + + if (s->channels_for_cur_subframe == 1) { + s->channel[s->channel_indexes_for_cur_subframe[0]].quant_step = quant_step; + } else { + int modifier_len = get_bits(&s->gb, 3); + for (i = 0; i < s->channels_for_cur_subframe; i++) { + int c = s->channel_indexes_for_cur_subframe[i]; + s->channel[c].quant_step = quant_step; + if (get_bits1(&s->gb)) { + if (modifier_len) { + s->channel[c].quant_step += get_bits(&s->gb, modifier_len) + 1; + } else + ++s->channel[c].quant_step; + } + } + } + + /** decode scale factors */ + if (decode_scale_factors(s) < 0) + return AVERROR_INVALIDDATA; + } + + DEBUGF("BITSTREAM: subframe header length was %i\n", + get_bits_count(&s->gb) - s->subframe_offset); + + /** parse coefficients */ + for (i = 0; i < s->channels_for_cur_subframe; i++) { + int c = s->channel_indexes_for_cur_subframe[i]; + if (s->channel[c].transmit_coefs && + get_bits_count(&s->gb) < s->num_saved_bits) { + decode_coeffs(s, c); + } else { + memset(s->channel[c].coeffs, 0, + sizeof(*s->channel[c].coeffs) * subframe_len); + } + } + + DEBUGF("BITSTREAM: subframe length was %i\n", + get_bits_count(&s->gb) - s->subframe_offset); + + if (transmit_coeffs) { + int nbits = av_log2(subframe_len)+1; + /** reconstruct the per channel data */ + inverse_channel_transform(s); + for (i = 0; i < s->channels_for_cur_subframe; i++) { + int c = s->channel_indexes_for_cur_subframe[i]; + const int* sf = s->channel[c].scale_factors; + int b; + + if (c == s->lfe_channel) + memset(&s->tmp[cur_subwoofer_cutoff], 0, sizeof(*s->tmp) * + (subframe_len - cur_subwoofer_cutoff)); + + /** inverse quantization and rescaling */ + for (b = 0; b < s->num_bands; b++) { + const int end = FFMIN(s->cur_sfb_offsets[b+1], s->subframe_len); + const int exp = s->channel[c].quant_step - + (s->channel[c].max_scale_factor - *sf++) * + s->channel[c].scale_factor_step; + + if(exp < EXP_MIN || exp > EXP_MAX) { + DEBUGF("in wmaprodec.c : unhandled value for exp (%d), please report sample.\n", exp); + return -1; + } + const int32_t quant = QUANT(exp); + int start = s->cur_sfb_offsets[b]; + + vector_fixmul_scalar(s->tmp+start, + s->channel[c].coeffs + start, + quant, end-start); + + + } + + /** apply imdct (ff_imdct_half == DCTIV with reverse) */ + ff_imdct_half(nbits,s->channel[c].coeffs, s->tmp); + + } + } + + /** window and overlapp-add */ + wmapro_window(s); + + /** handled one subframe */ + for (i = 0; i < s->channels_for_cur_subframe; i++) { + int c = s->channel_indexes_for_cur_subframe[i]; + if (s->channel[c].cur_subframe >= s->channel[c].num_subframes) { + DEBUGF("broken subframe\n"); + return AVERROR_INVALIDDATA; + } + ++s->channel[c].cur_subframe; + } + + return 0; +} + +/** + *@brief Decode one WMA frame. + *@param s codec context + *@return 0 if the trailer bit indicates that this is the last frame, + * 1 if there are additional frames + */ +static int decode_frame(WMAProDecodeCtx *s) +{ + GetBitContext* gb = &s->gb; + int more_frames = 0; + int len = 0; + int i; + + +#if 0 + /** check for potential output buffer overflow */ + /* Rockbox : No need to check that anymore since we work directly on the + buffers in the WMAProDecCtx */ + if (s->num_channels * s->samples_per_frame > s->samples_end - s->samples) { + /** return an error if no frame could be decoded at all */ + DEBUGF("not enough space for the output samples\n"); + s->packet_loss = 1; + return 0; + } +#endif + + /** get frame length */ + if (s->len_prefix) + len = get_bits(gb, s->log2_frame_size); + + DEBUGF("decoding frame with length %x\n", len); + + /** decode tile information */ + if (decode_tilehdr(s)) { + s->packet_loss = 1; + return 0; + } + + /** read postproc transform */ + if (s->num_channels > 1 && get_bits1(gb)) { + DEBUGF("Unsupported postproc transform found\n"); + s->packet_loss = 1; + return 0; + } + + /** read drc info */ + if (s->dynamic_range_compression) { + s->drc_gain = get_bits(gb, 8); + DEBUGF("drc_gain %i\n", s->drc_gain); + } + + /** no idea what these are for, might be the number of samples + that need to be skipped at the beginning or end of a stream */ + if (get_bits1(gb)) { + /** usually true for the first frame */ + if (get_bits1(gb)) { + get_bits(gb, av_log2(s->samples_per_frame * 2)); + DEBUGF("start skip\n"); + } + /** sometimes true for the last frame */ + if (get_bits1(gb)) { + get_bits(gb, av_log2(s->samples_per_frame * 2)); + DEBUGF("end skip\n"); + } + } + + DEBUGF("BITSTREAM: frame header length was %i\n", + get_bits_count(gb) - s->frame_offset); + + /** reset subframe states */ + s->parsed_all_subframes = 0; + for (i = 0; i < s->num_channels; i++) { + s->channel[i].decoded_samples = 0; + s->channel[i].cur_subframe = 0; + s->channel[i].reuse_sf = 0; + } + + /** decode all subframes */ + while (!s->parsed_all_subframes) { + if (decode_subframe(s) < 0) { + s->packet_loss = 1; + return 0; + } + } + + if (s->skip_frame) { + s->skip_frame = 0; + } else + s->samples += s->num_channels * s->samples_per_frame; + + if (len != (get_bits_count(gb) - s->frame_offset) + 2) { + /** FIXME: not sure if this is always an error */ + DEBUGF("frame[%i] would have to skip %i bits\n", + (int)s->frame_num, len - (get_bits_count(gb) - s->frame_offset) - 1); + s->packet_loss = 1; + return 0; + } + + /** skip the rest of the frame data */ + skip_bits_long(gb, len - (get_bits_count(gb) - s->frame_offset) - 1); + + /** decode trailer bit */ + more_frames = get_bits1(gb); + + ++s->frame_num; + return more_frames; +} + +/** + *@brief Calculate remaining input buffer length. + *@param s codec context + *@param gb bitstream reader context + *@return remaining size in bits + */ +static int remaining_bits(WMAProDecodeCtx *s, GetBitContext *gb) +{ + return s->buf_bit_size - get_bits_count(gb); +} + +/** + *@brief Fill the bit reservoir with a (partial) frame. + *@param s codec context + *@param gb bitstream reader context + *@param len length of the partial frame + *@param append decides wether to reset the buffer or not + */ +static void save_bits(WMAProDecodeCtx *s, GetBitContext* gb, int len, + int append) +{ + int buflen; + + /** when the frame data does not need to be concatenated, the input buffer + is resetted and additional bits from the previous frame are copyed + and skipped later so that a fast byte copy is possible */ + + if (!append) { + s->frame_offset = get_bits_count(gb) & 7; + s->num_saved_bits = s->frame_offset; + init_put_bits(&s->pb, s->frame_data, MAX_FRAMESIZE); + } + + buflen = (s->num_saved_bits + len + 8) >> 3; + + if (len <= 0 || buflen > MAX_FRAMESIZE) { + DEBUGF("input buffer too small\n"); + s->packet_loss = 1; + return; + } + + s->num_saved_bits += len; + if (!append) { + ff_copy_bits(&s->pb, gb->buffer + (get_bits_count(gb) >> 3), + s->num_saved_bits); + } else { + int align = 8 - (get_bits_count(gb) & 7); + align = FFMIN(align, len); + put_bits(&s->pb, align, get_bits(gb, align)); + len -= align; + ff_copy_bits(&s->pb, gb->buffer + (get_bits_count(gb) >> 3), len); + } + skip_bits_long(gb, len); + + { + PutBitContext tmp = s->pb; + flush_put_bits(&tmp); + } + + init_get_bits(&s->gb, s->frame_data, s->num_saved_bits); + skip_bits(&s->gb, s->frame_offset); +} + +/** + *@brief Decode a single WMA packet. + *@param avctx codec context + *@param data the output buffer + *@param data_size number of bytes that were written to the output buffer + *@param avpkt input packet + *@return number of bytes that were read from the input buffer + */ +int decode_packet(asf_waveformatex_t *wfx, int32_t *dec[2], int *data_size, + void* pktdata, int size) +{ + WMAProDecodeCtx *s = &globWMAProDecCtx; + GetBitContext* gb = &s->pgb; + const uint8_t* buf = pktdata; + int buf_size = size; + int num_bits_prev_frame; + int packet_sequence_number;\ + int i; + + /** reuse second half of the IMDCT output for the next frame */ + /* NOTE : Relies on the WMAProDecCtx being static */ + for(i = 0; i < s->num_channels; i++) + memcpy(&s->channel[i].out[0], + &s->channel[i].out[s->samples_per_frame], + s->samples_per_frame * sizeof(*s->channel[i].out) >> 1); + + + s->samples = 0; + *data_size = 0; + + if (s->packet_done || s->packet_loss) { + s->packet_done = 0; + s->buf_bit_size = buf_size << 3; + + /** sanity check for the buffer length */ + if (buf_size < wfx->blockalign) + return 0; + + buf_size = wfx->blockalign; + + /** parse packet header */ + init_get_bits(gb, buf, s->buf_bit_size); + packet_sequence_number = get_bits(gb, 4); + skip_bits(gb, 2); + + /** get number of bits that need to be added to the previous frame */ + num_bits_prev_frame = get_bits(gb, s->log2_frame_size); + DEBUGF("packet[%d]: nbpf %x\n", s->frame_num, + num_bits_prev_frame); + + /** check for packet loss */ + if (!s->packet_loss && + ((s->packet_sequence_number + 1) & 0xF) != packet_sequence_number) { + s->packet_loss = 1; + DEBUGF("Packet loss detected! seq %x vs %x\n", + s->packet_sequence_number, packet_sequence_number); + } + s->packet_sequence_number = packet_sequence_number; + + if (num_bits_prev_frame > 0) { + /** append the previous frame data to the remaining data from the + previous packet to create a full frame */ + save_bits(s, gb, num_bits_prev_frame, 1); + DEBUGF("accumulated %x bits of frame data\n", + s->num_saved_bits - s->frame_offset); + + /** decode the cross packet frame if it is valid */ + if (!s->packet_loss) + decode_frame(s); + } else if (s->num_saved_bits - s->frame_offset) { + DEBUGF("ignoring %x previously saved bits\n", + s->num_saved_bits - s->frame_offset); + } + + s->packet_loss = 0; + + } else { + int frame_size; + s->buf_bit_size = size << 3; + init_get_bits(gb, pktdata, s->buf_bit_size); + skip_bits(gb, s->packet_offset); + if (remaining_bits(s, gb) > s->log2_frame_size && + (frame_size = show_bits(gb, s->log2_frame_size)) && + frame_size <= remaining_bits(s, gb)) { + save_bits(s, gb, frame_size, 0); + s->packet_done = !decode_frame(s); + } else + s->packet_done = 1; + } + + if (s->packet_done && !s->packet_loss && + remaining_bits(s, gb) > 0) { + /** save the rest of the data so that it can be decoded + with the next packet */ + save_bits(s, gb, remaining_bits(s, gb), 0); + } + + dec[0] = s->channel[0].out; + dec[1] = s->channel[1].out; + + *data_size = s->samples; + s->packet_offset = get_bits_count(gb) & 7; + + s->frame_num++; + return (s->packet_loss) ? AVERROR_INVALIDDATA : get_bits_count(gb) >> 3; +} + +#if 0 +/** + *@brief wmapro decoder + */ +AVCodec wmapro_decoder = { + "wmapro", + AVMEDIA_TYPE_AUDIO, + CODEC_ID_WMAPRO, + sizeof(WMAProDecodeCtx), + decode_init, + NULL, + decode_end, + decode_packet, + .capabilities = CODEC_CAP_SUBFRAMES, + .flush= flush, + .long_name = NULL_IF_CONFIG_SMALL("Windows Media Audio 9 Professional"), +}; +#endif diff --git a/lib/rbcodec/codecs/libwmapro/wmaprodec.h b/lib/rbcodec/codecs/libwmapro/wmaprodec.h new file mode 100644 index 0000000000..d8398fc9f1 --- /dev/null +++ b/lib/rbcodec/codecs/libwmapro/wmaprodec.h @@ -0,0 +1,44 @@ +#include "codeclib.h" +#include "wma.h" +#include "../libasf/asf.h" + +#if (CONFIG_CPU == MCF5250) +/* Enough IRAM but performance suffers with ICODE_ATTR. */ +#define IBSS_ATTR_WMAPRO_LARGE_IRAM IBSS_ATTR +#define ICODE_ATTR_WMAPRO_LARGE_IRAM +#define ICONST_ATTR_WMAPRO_LARGE_IRAM ICONST_ATTR +#define IBSS_ATTR_WMAPRO_VLC_TABLES +#define ICONST_ATTR_WMAPRO_WIN_VS_TMP + +#elif (CONFIG_CPU == PP5022) || (CONFIG_CPU == PP5024) +/* Enough IRAM to move additional data and code to it. */ +#define IBSS_ATTR_WMAPRO_LARGE_IRAM IBSS_ATTR +#define ICODE_ATTR_WMAPRO_LARGE_IRAM ICODE_ATTR +#define ICONST_ATTR_WMAPRO_LARGE_IRAM ICONST_ATTR +#define IBSS_ATTR_WMAPRO_VLC_TABLES +#define ICONST_ATTR_WMAPRO_WIN_VS_TMP + +#elif defined(CPU_S5L870X) +/* Enough IRAM to move additional data and code to it. */ +#define IBSS_ATTR_WMAPRO_LARGE_IRAM IBSS_ATTR +#define ICODE_ATTR_WMAPRO_LARGE_IRAM ICODE_ATTR +#define ICONST_ATTR_WMAPRO_LARGE_IRAM ICONST_ATTR +#define IBSS_ATTR_WMAPRO_VLC_TABLES IBSS_ATTR +#define ICONST_ATTR_WMAPRO_WIN_VS_TMP ICONST_ATTR + +#else +/* Not enough IRAM available. */ +#define IBSS_ATTR_WMAPRO_LARGE_IRAM +#define ICODE_ATTR_WMAPRO_LARGE_IRAM +#define ICONST_ATTR_WMAPRO_LARGE_IRAM +#define IBSS_ATTR_WMAPRO_VLC_TABLES +/* Models with large IRAM put tmp to IRAM rather than window coefficients as + * this is the fastest option. On models with smaller IRAM the 2nd-best option + * is to move the window coefficients to IRAM. */ +#define ICONST_ATTR_WMAPRO_WIN_VS_TMP ICONST_ATTR + +#endif + +int decode_init(asf_waveformatex_t *wfx); +int decode_packet(asf_waveformatex_t *wfx, + int32_t *dec[2], int *data_size, void* pktdata, int size); diff --git a/lib/rbcodec/codecs/libwmavoice/Makefile b/lib/rbcodec/codecs/libwmavoice/Makefile new file mode 100644 index 0000000000..2bd7b94f9b --- /dev/null +++ b/lib/rbcodec/codecs/libwmavoice/Makefile @@ -0,0 +1,64 @@ +CC = gcc -o +INC = -I. +OUTPUT = wmavoice +STD = c99 +LIBS = -lm +CFLAGS = -Wall -ggdb -std=$(STD) $(INC) + +SOURCES = \ +acelp_filters.c\ +acelp_vectors.c\ +avfft.c\ +bitstream.c\ +celp_filters.c\ +celp_math.c\ +dct.c\ +fft.c\ +lsp.c\ +mdct.c\ +rdft.c\ +utils.c\ +wmavoice.c\ +libavutil/log.c\ +libavutil/lzo.c\ +libavutil/mem.c\ +libavutil/mathematics.c + +HEADERS = \ +acelp_vectors.h\ +celp_math.h\ +get_bits.h\ +wmavoice_data.h\ +avcodec.h\ +fft.h\ +acelp_filters.h\ +celp_filters.h\ +put_bits.h\ +lsp.h\ +internal.h\ +avfft.h\ +mathops.h\ +mdct_tablegen.h\ +dct32.c\ +libavutil/avutil.h\ +libavutil/attributes.h\ +libavutil/lzo.h\ +libavutil/mem.h\ +libavutil/log.h\ +libavutil/internal.h\ +libavutil/common.h\ +libavutil/intreadwrite.h\ +libavutil/bswap.h\ +libavutil/mathematics.h + +OBJECTS = $(SOURCES:.c=.o) + +all:$(OUTPUT) + +$(OUTPUT):$(SOURCES) $(HEADERS) + $(CC) $@ $(CFLAGS) $(SOURCES) $(LIBS) + @echo "Done." + +clean: + rm -f *.o $(OUTPUT) *~ + diff --git a/lib/rbcodec/codecs/libwmavoice/README.rockbox b/lib/rbcodec/codecs/libwmavoice/README.rockbox new file mode 100644 index 0000000000..8115619bf0 --- /dev/null +++ b/lib/rbcodec/codecs/libwmavoice/README.rockbox @@ -0,0 +1,26 @@ +Library: libwmavoice +Imported: 2010-08-07 by Mohamed Tarek + +This set of files form the files needed from ffmpeg's libavcodec and libavutil +to build a standalone wma voice decoder. + +LICENSING INFORMATION + +ffmpeg is licensed under the Lesser GNU General Public License and the file +wmavoice.c is copyright (c) 2009 Ronald S. Bultje. + +IMPORT DETAILS + +Based on ffmpeg svn r24734 dated 7 August 2010. + +As of 7 August 2010, libwmavoice contains just the files from ffmpeg with +minimum modifications to compile standalone. + +COMPILING + +the decoder can be compiled by issuing the "make" command from witin the +libwmavoice directory in any unix-line environment. + +To test the decoder in the rockbox simulator, cd to libwmavoice directory then +execute the following command to enable building wma voice: +patch -p 0 < wmavoice_mainbuild.patch diff --git a/lib/rbcodec/codecs/libwmavoice/SOURCES b/lib/rbcodec/codecs/libwmavoice/SOURCES new file mode 100644 index 0000000000..c98821c42a --- /dev/null +++ b/lib/rbcodec/codecs/libwmavoice/SOURCES @@ -0,0 +1,17 @@ +acelp_filters.c +acelp_vectors.c +avfft.c +bitstream.c +celp_filters.c +celp_math.c +dct.c +fft.c +lsp.c +mdct.c +rdft.c +utils.c +wmavoice.c +libavutil/log.c +libavutil/lzo.c +libavutil/mem.c +libavutil/mathematics.c diff --git a/lib/rbcodec/codecs/libwmavoice/acelp_filters.c b/lib/rbcodec/codecs/libwmavoice/acelp_filters.c new file mode 100644 index 0000000000..c48c0e72ce --- /dev/null +++ b/lib/rbcodec/codecs/libwmavoice/acelp_filters.c @@ -0,0 +1,145 @@ +/* + * various filters for ACELP-based codecs + * + * Copyright (c) 2008 Vladimir Voroshilov + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include + +#include "avcodec.h" +#include "acelp_filters.h" + +const int16_t ff_acelp_interp_filter[61] = { /* (0.15) */ + 29443, 28346, 25207, 20449, 14701, 8693, + 3143, -1352, -4402, -5865, -5850, -4673, + -2783, -672, 1211, 2536, 3130, 2991, + 2259, 1170, 0, -1001, -1652, -1868, + -1666, -1147, -464, 218, 756, 1060, + 1099, 904, 550, 135, -245, -514, + -634, -602, -451, -231, 0, 191, + 308, 340, 296, 198, 78, -36, + -120, -163, -165, -132, -79, -19, + 34, 73, 91, 89, 70, 38, + 0, +}; + +void ff_acelp_interpolate(int16_t* out, const int16_t* in, + const int16_t* filter_coeffs, int precision, + int frac_pos, int filter_length, int length) +{ + int n, i; + + //assert(frac_pos >= 0 && frac_pos < precision); + + for (n = 0; n < length; n++) { + int idx = 0; + int v = 0x4000; + + for (i = 0; i < filter_length;) { + + /* The reference G.729 and AMR fixed point code performs clipping after + each of the two following accumulations. + Since clipping affects only the synthetic OVERFLOW test without + causing an int type overflow, it was moved outside the loop. */ + + /* R(x):=ac_v[-k+x] + v += R(n-i)*ff_acelp_interp_filter(t+6i) + v += R(n+i+1)*ff_acelp_interp_filter(6-t+6i) */ + + v += in[n + i] * filter_coeffs[idx + frac_pos]; + idx += precision; + i++; + v += in[n - i] * filter_coeffs[idx - frac_pos]; + } + if (av_clip_int16(v >> 15) != (v >> 15)) + av_log(NULL, AV_LOG_WARNING, "overflow that would need cliping in ff_acelp_interpolate()\n"); + out[n] = v >> 15; + } +} + +void ff_acelp_interpolatef(float *out, const float *in, + const float *filter_coeffs, int precision, + int frac_pos, int filter_length, int length) +{ + int n, i; + + for (n = 0; n < length; n++) { + int idx = 0; + float v = 0; + + for (i = 0; i < filter_length;) { + v += in[n + i] * filter_coeffs[idx + frac_pos]; + idx += precision; + i++; + v += in[n - i] * filter_coeffs[idx - frac_pos]; + } + out[n] = v; + } +} + + +void ff_acelp_high_pass_filter(int16_t* out, int hpf_f[2], + const int16_t* in, int length) +{ + int i; + int tmp; + + for (i = 0; i < length; i++) { + tmp = (hpf_f[0]* 15836LL) >> 13; + tmp += (hpf_f[1]* -7667LL) >> 13; + tmp += 7699 * (in[i] - 2*in[i-1] + in[i-2]); + + /* With "+0x800" rounding, clipping is needed + for ALGTHM and SPEECH tests. */ + out[i] = av_clip_int16((tmp + 0x800) >> 12); + + hpf_f[1] = hpf_f[0]; + hpf_f[0] = tmp; + } +} + +void ff_acelp_apply_order_2_transfer_function(float *out, const float *in, + const float zero_coeffs[2], + const float pole_coeffs[2], + float gain, float mem[2], int n) +{ + int i; + float tmp; + + for (i = 0; i < n; i++) { + tmp = gain * in[i] - pole_coeffs[0] * mem[0] - pole_coeffs[1] * mem[1]; + out[i] = tmp + zero_coeffs[0] * mem[0] + zero_coeffs[1] * mem[1]; + + mem[1] = mem[0]; + mem[0] = tmp; + } +} + +void ff_tilt_compensation(float *mem, float tilt, float *samples, int size) +{ + float new_tilt_mem = samples[size - 1]; + int i; + + for (i = size - 1; i > 0; i--) + samples[i] -= tilt * samples[i - 1]; + + samples[0] -= tilt * *mem; + *mem = new_tilt_mem; +} + diff --git a/lib/rbcodec/codecs/libwmavoice/acelp_filters.h b/lib/rbcodec/codecs/libwmavoice/acelp_filters.h new file mode 100644 index 0000000000..0b1ccf4e71 --- /dev/null +++ b/lib/rbcodec/codecs/libwmavoice/acelp_filters.h @@ -0,0 +1,120 @@ +/* + * various filters for ACELP-based codecs + * + * Copyright (c) 2008 Vladimir Voroshilov + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVCODEC_ACELP_FILTERS_H +#define AVCODEC_ACELP_FILTERS_H + +#include + +/** + * low-pass Finite Impulse Response filter coefficients. + * + * Hamming windowed sinc filter with cutoff freq 3/40 of the sampling freq, + * the coefficients are scaled by 2^15. + * This array only contains the right half of the filter. + * This filter is likely identical to the one used in G.729, though this + * could not be determined from the original comments with certainity. + */ +extern const int16_t ff_acelp_interp_filter[61]; + +/** + * Generic FIR interpolation routine. + * @param[out] out buffer for interpolated data + * @param in input data + * @param filter_coeffs interpolation filter coefficients (0.15) + * @param precision sub sample factor, that is the precision of the position + * @param frac_pos fractional part of position [0..precision-1] + * @param filter_length filter length + * @param length length of output + * + * filter_coeffs contains coefficients of the right half of the symmetric + * interpolation filter. filter_coeffs[0] should the central (unpaired) coefficient. + * See ff_acelp_interp_filter for an example. + * + */ +void ff_acelp_interpolate(int16_t* out, const int16_t* in, + const int16_t* filter_coeffs, int precision, + int frac_pos, int filter_length, int length); + +/** + * Floating point version of ff_acelp_interpolate() + */ +void ff_acelp_interpolatef(float *out, const float *in, + const float *filter_coeffs, int precision, + int frac_pos, int filter_length, int length); + + +/** + * high-pass filtering and upscaling (4.2.5 of G.729). + * @param[out] out output buffer for filtered speech data + * @param[in,out] hpf_f past filtered data from previous (2 items long) + * frames (-0x20000000 <= (14.13) < 0x20000000) + * @param in speech data to process + * @param length input data size + * + * out[i] = 0.93980581 * in[i] - 1.8795834 * in[i-1] + 0.93980581 * in[i-2] + + * 1.9330735 * out[i-1] - 0.93589199 * out[i-2] + * + * The filter has a cut-off frequency of 1/80 of the sampling freq + * + * @note Two items before the top of the out buffer must contain two items from the + * tail of the previous subframe. + * + * @remark It is safe to pass the same array in in and out parameters. + * + * @remark AMR uses mostly the same filter (cut-off frequency 60Hz, same formula, + * but constants differs in 5th sign after comma). Fortunately in + * fixed-point all coefficients are the same as in G.729. Thus this + * routine can be used for the fixed-point AMR decoder, too. + */ +void ff_acelp_high_pass_filter(int16_t* out, int hpf_f[2], + const int16_t* in, int length); + +/** + * Apply an order 2 rational transfer function in-place. + * + * @param out output buffer for filtered speech samples + * @param in input buffer containing speech data (may be the same as out) + * @param zero_coeffs z^-1 and z^-2 coefficients of the numerator + * @param pole_coeffs z^-1 and z^-2 coefficients of the denominator + * @param gain scale factor for final output + * @param mem intermediate values used by filter (should be 0 initially) + * @param n number of samples + */ +void ff_acelp_apply_order_2_transfer_function(float *out, const float *in, + const float zero_coeffs[2], + const float pole_coeffs[2], + float gain, + float mem[2], int n); + +/** + * Apply tilt compensation filter, 1 - tilt * z-1. + * + * @param mem pointer to the filter's state (one single float) + * @param tilt tilt factor + * @param samples array where the filter is applied + * @param size the size of the samples array + */ +void ff_tilt_compensation(float *mem, float tilt, float *samples, int size); + + +#endif /* AVCODEC_ACELP_FILTERS_H */ diff --git a/lib/rbcodec/codecs/libwmavoice/acelp_vectors.c b/lib/rbcodec/codecs/libwmavoice/acelp_vectors.c new file mode 100644 index 0000000000..e41e5facb6 --- /dev/null +++ b/lib/rbcodec/codecs/libwmavoice/acelp_vectors.c @@ -0,0 +1,270 @@ +/* + * adaptive and fixed codebook vector operations for ACELP-based codecs + * + * Copyright (c) 2008 Vladimir Voroshilov + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include +#include "avcodec.h" +#include "acelp_vectors.h" +#include "celp_math.h" + +const uint8_t ff_fc_2pulses_9bits_track1[16] = +{ + 1, 3, + 6, 8, + 11, 13, + 16, 18, + 21, 23, + 26, 28, + 31, 33, + 36, 38 +}; +const uint8_t ff_fc_2pulses_9bits_track1_gray[16] = +{ + 1, 3, + 8, 6, + 18, 16, + 11, 13, + 38, 36, + 31, 33, + 21, 23, + 28, 26, +}; + +const uint8_t ff_fc_2pulses_9bits_track2_gray[32] = +{ + 0, 2, + 5, 4, + 12, 10, + 7, 9, + 25, 24, + 20, 22, + 14, 15, + 19, 17, + 36, 31, + 21, 26, + 1, 6, + 16, 11, + 27, 29, + 32, 30, + 39, 37, + 34, 35, +}; + +const uint8_t ff_fc_4pulses_8bits_tracks_13[16] = +{ + 0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, +}; + +const uint8_t ff_fc_4pulses_8bits_track_4[32] = +{ + 3, 4, + 8, 9, + 13, 14, + 18, 19, + 23, 24, + 28, 29, + 33, 34, + 38, 39, + 43, 44, + 48, 49, + 53, 54, + 58, 59, + 63, 64, + 68, 69, + 73, 74, + 78, 79, +}; + +#if 0 +static uint8_t gray_decode[32] = +{ + 0, 1, 3, 2, 7, 6, 4, 5, + 15, 14, 12, 13, 8, 9, 11, 10, + 31, 30, 28, 29, 24, 25, 27, 26, + 16, 17, 19, 18, 23, 22, 20, 21 +}; +#endif + +const float ff_pow_0_7[10] = { + 0.700000, 0.490000, 0.343000, 0.240100, 0.168070, + 0.117649, 0.082354, 0.057648, 0.040354, 0.028248 +}; + +const float ff_pow_0_75[10] = { + 0.750000, 0.562500, 0.421875, 0.316406, 0.237305, + 0.177979, 0.133484, 0.100113, 0.075085, 0.056314 +}; + +const float ff_pow_0_55[10] = { + 0.550000, 0.302500, 0.166375, 0.091506, 0.050328, + 0.027681, 0.015224, 0.008373, 0.004605, 0.002533 +}; + +const float ff_b60_sinc[61] = { + 0.898529 , 0.865051 , 0.769257 , 0.624054 , 0.448639 , 0.265289 , + 0.0959167 , -0.0412598 , -0.134338 , -0.178986 , -0.178528 , -0.142609 , +-0.0849304 , -0.0205078 , 0.0369568 , 0.0773926 , 0.0955200 , 0.0912781 , + 0.0689392 , 0.0357056 , 0. , -0.0305481 , -0.0504150 , -0.0570068 , +-0.0508423 , -0.0350037 , -0.0141602 , 0.00665283, 0.0230713 , 0.0323486 , + 0.0335388 , 0.0275879 , 0.0167847 , 0.00411987, -0.00747681, -0.0156860 , +-0.0193481 , -0.0183716 , -0.0137634 , -0.00704956, 0. , 0.00582886 , + 0.00939941, 0.0103760 , 0.00903320, 0.00604248, 0.00238037, -0.00109863 , +-0.00366211, -0.00497437, -0.00503540, -0.00402832, -0.00241089, -0.000579834, + 0.00103760, 0.00222778, 0.00277710, 0.00271606, 0.00213623, 0.00115967 , + 0. +}; + +void ff_acelp_fc_pulse_per_track( + int16_t* fc_v, + const uint8_t *tab1, + const uint8_t *tab2, + int pulse_indexes, + int pulse_signs, + int pulse_count, + int bits) +{ + int mask = (1 << bits) - 1; + int i; + + for(i=0; i>= bits; + pulse_signs >>= 1; + } + + fc_v[tab2[pulse_indexes]] += (pulse_signs & 1) ? 8191 : -8192; +} + +void ff_decode_10_pulses_35bits(const int16_t *fixed_index, + AMRFixed *fixed_sparse, + const uint8_t *gray_decode, + int half_pulse_count, int bits) +{ + int i; + int mask = (1 << bits) - 1; + + fixed_sparse->no_repeat_mask = 0; + fixed_sparse->n = 2 * half_pulse_count; + for (i = 0; i < half_pulse_count; i++) { + const int pos1 = gray_decode[fixed_index[2*i+1] & mask] + i; + const int pos2 = gray_decode[fixed_index[2*i ] & mask] + i; + const float sign = (fixed_index[2*i+1] & (1 << bits)) ? -1.0 : 1.0; + fixed_sparse->x[2*i+1] = pos1; + fixed_sparse->x[2*i ] = pos2; + fixed_sparse->y[2*i+1] = sign; + fixed_sparse->y[2*i ] = pos2 < pos1 ? -sign : sign; + } +} + +void ff_acelp_weighted_vector_sum( + int16_t* out, + const int16_t *in_a, + const int16_t *in_b, + int16_t weight_coeff_a, + int16_t weight_coeff_b, + int16_t rounder, + int shift, + int length) +{ + int i; + + // Clipping required here; breaks OVERFLOW test. + for(i=0; i> shift); +} + +void ff_weighted_vector_sumf(float *out, const float *in_a, const float *in_b, + float weight_coeff_a, float weight_coeff_b, int length) +{ + int i; + + for(i=0; in; i++) { + int x = in->x[i], repeats = !((in->no_repeat_mask >> i) & 1); + float y = in->y[i] * scale; + + do { + out[x] += y; + y *= in->pitch_fac; + x += in->pitch_lag; + } while (x < size && repeats); + } +} + +void ff_clear_fixed_vector(float *out, const AMRFixed *in, int size) +{ + int i; + + for (i=0; i < in->n; i++) { + int x = in->x[i], repeats = !((in->no_repeat_mask >> i) & 1); + + do { + out[x] = 0.0; + x += in->pitch_lag; + } while (x < size && repeats); + } +} diff --git a/lib/rbcodec/codecs/libwmavoice/acelp_vectors.h b/lib/rbcodec/codecs/libwmavoice/acelp_vectors.h new file mode 100644 index 0000000000..f3bc781446 --- /dev/null +++ b/lib/rbcodec/codecs/libwmavoice/acelp_vectors.h @@ -0,0 +1,264 @@ +/* + * adaptive and fixed codebook vector operations for ACELP-based codecs + * + * Copyright (c) 2008 Vladimir Voroshilov + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVCODEC_ACELP_VECTORS_H +#define AVCODEC_ACELP_VECTORS_H + +#include + +/** Sparse representation for the algebraic codebook (fixed) vector */ +typedef struct { + int n; + int x[10]; + float y[10]; + int no_repeat_mask; + int pitch_lag; + float pitch_fac; +} AMRFixed; + +/** + * Track|Pulse| Positions + * ------------------------------------------------------------------------- + * 1 | 0 | 0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75 + * ------------------------------------------------------------------------- + * 2 | 1 | 1, 6, 11, 16, 21, 26, 31, 36, 41, 46, 51, 56, 61, 66, 71, 76 + * ------------------------------------------------------------------------- + * 3 | 2 | 2, 7, 12, 17, 22, 27, 32, 37, 42, 47, 52, 57, 62, 67, 72, 77 + * ------------------------------------------------------------------------- + * + * Table contains only first the pulse indexes. + * + * Used in G.729 @@8k, G.729 @@4.4k, AMR @@7.95k, AMR @@7.40k + */ +extern const uint8_t ff_fc_4pulses_8bits_tracks_13[16]; + +/** + * Track|Pulse| Positions + * ------------------------------------------------------------------------- + * 4 | 3 | 3, 8, 13, 18, 23, 28, 33, 38, 43, 48, 53, 58, 63, 68, 73, 78 + * | | 4, 9, 14, 19, 24, 29, 34, 39, 44, 49, 54, 59, 64, 69, 74, 79 + * ------------------------------------------------------------------------- + * + * @remark Track in the table should be read top-to-bottom, left-to-right. + * + * Used in G.729 @@8k, G.729 @@4.4k, AMR @@7.95k, AMR @@7.40k + */ +extern const uint8_t ff_fc_4pulses_8bits_track_4[32]; + +/** + * Track|Pulse| Positions + * ----------------------------------------- + * 1 | 0 | 1, 6, 11, 16, 21, 26, 31, 36 + * | | 3, 8, 13, 18, 23, 28, 33, 38 + * ----------------------------------------- + * + * @remark Track in the table should be read top-to-bottom, left-to-right. + * + * @note (EE) Reference G.729D code also uses gray decoding for each + * pulse index before looking up the value in the table. + * + * Used in G.729 @@6.4k (with gray coding), AMR @@5.9k (without gray coding) + */ +extern const uint8_t ff_fc_2pulses_9bits_track1[16]; +extern const uint8_t ff_fc_2pulses_9bits_track1_gray[16]; + +/** + * Track|Pulse| Positions + * ----------------------------------------- + * 2 | 1 | 0, 7, 14, 20, 27, 34, 1, 21 + * | | 2, 9, 15, 22, 29, 35, 6, 26 + * | | 4,10, 17, 24, 30, 37, 11, 31 + * | | 5,12, 19, 25, 32, 39, 16, 36 + * ----------------------------------------- + * + * @remark Track in the table should be read top-to-bottom, left-to-right. + * + * @note (EE.1) This table (from the reference code) does not comply with + * the specification. + * The specification contains the following table: + * + * Track|Pulse| Positions + * ----------------------------------------- + * 2 | 1 | 0, 5, 10, 15, 20, 25, 30, 35 + * | | 1, 6, 11, 16, 21, 26, 31, 36 + * | | 2, 7, 12, 17, 22, 27, 32, 37 + * | | 4, 9, 14, 19, 24, 29, 34, 39 + * + * ----------------------------------------- + * + * @note (EE.2) Reference G.729D code also uses gray decoding for each + * pulse index before looking up the value in the table. + * + * Used in G.729 @@6.4k (with gray coding) + */ +extern const uint8_t ff_fc_2pulses_9bits_track2_gray[32]; + +/** + * b60 hamming windowed sinc function coefficients + */ +extern const float ff_b60_sinc[61]; + +/** + * Table of pow(0.7,n) + */ +extern const float ff_pow_0_7[10]; + +/** + * Table of pow(0.75,n) + */ +extern const float ff_pow_0_75[10]; + +/** + * Table of pow(0.55,n) + */ +extern const float ff_pow_0_55[10]; + +/** + * Decode fixed-codebook vector (3.8 and D.5.8 of G.729, 5.7.1 of AMR). + * @param[out] fc_v decoded fixed codebook vector (2.13) + * @param tab1 table used for first pulse_count pulses + * @param tab2 table used for last pulse + * @param pulse_indexes fixed codebook indexes + * @param pulse_signs signs of the excitation pulses (0 bit value + * means negative sign) + * @param bits number of bits per one pulse index + * @param pulse_count number of pulses decoded using first table + * @param bits length of one pulse index in bits + * + * Used in G.729 @@8k, G.729 @@4.4k, G.729 @@6.4k, AMR @@7.95k, AMR @@7.40k + */ +void ff_acelp_fc_pulse_per_track(int16_t* fc_v, + const uint8_t *tab1, + const uint8_t *tab2, + int pulse_indexes, + int pulse_signs, + int pulse_count, + int bits); + +/** + * Decode the algebraic codebook index to pulse positions and signs and + * construct the algebraic codebook vector for MODE_12k2. + * + * @note: The positions and signs are explicitly coded in MODE_12k2. + * + * @param fixed_index positions of the ten pulses + * @param fixed_sparse pointer to the algebraic codebook vector + * @param gray_decode gray decoding table + * @param half_pulse_count number of couples of pulses + * @param bits length of one pulse index in bits + */ +void ff_decode_10_pulses_35bits(const int16_t *fixed_index, + AMRFixed *fixed_sparse, + const uint8_t *gray_decode, + int half_pulse_count, int bits); + + +/** + * weighted sum of two vectors with rounding. + * @param[out] out result of addition + * @param in_a first vector + * @param in_b second vector + * @param weight_coeff_a first vector weight coefficient + * @param weight_coeff_a second vector weight coefficient + * @param rounder this value will be added to the sum of the two vectors + * @param shift result will be shifted to right by this value + * @param length vectors length + * + * @note It is safe to pass the same buffer for out and in_a or in_b. + * + * out[i] = (in_a[i]*weight_a + in_b[i]*weight_b + rounder) >> shift + */ +void ff_acelp_weighted_vector_sum(int16_t* out, + const int16_t *in_a, + const int16_t *in_b, + int16_t weight_coeff_a, + int16_t weight_coeff_b, + int16_t rounder, + int shift, + int length); + +/** + * float implementation of weighted sum of two vectors. + * @param[out] out result of addition + * @param in_a first vector + * @param in_b second vector + * @param weight_coeff_a first vector weight coefficient + * @param weight_coeff_a second vector weight coefficient + * @param length vectors length + * + * @note It is safe to pass the same buffer for out and in_a or in_b. + */ +void ff_weighted_vector_sumf(float *out, const float *in_a, const float *in_b, + float weight_coeff_a, float weight_coeff_b, + int length); + +/** + * Adaptive gain control (as used in AMR postfiltering) + * + * @param out output buffer for filtered speech data + * @param in the input speech buffer (may be the same as out) + * @param speech_energ input energy + * @param size the input buffer size + * @param alpha exponential filter factor + * @param gain_mem a pointer to the filter memory (single float of size) + */ +void ff_adaptive_gain_control(float *out, const float *in, float speech_energ, + int size, float alpha, float *gain_mem); + +/** + * Set the sum of squares of a signal by scaling + * + * @param out output samples + * @param in input samples + * @param sum_of_squares new sum of squares + * @param n number of samples + * + * @note If the input is zero (or its energy underflows), the output is zero. + * This is the behavior of AGC in the AMR reference decoder. The QCELP + * reference decoder seems to have undefined behavior. + * + * TIA/EIA/IS-733 2.4.8.3-2/3/4/5, 2.4.8.6 + * 3GPP TS 26.090 6.1 (6) + */ +void ff_scale_vector_to_given_sum_of_squares(float *out, const float *in, + float sum_of_squares, const int n); + +/** + * Add fixed vector to an array from a sparse representation + * + * @param out fixed vector with pitch sharpening + * @param in sparse fixed vector + * @param scale number to multiply the fixed vector by + * @param size the output vector size + */ +void ff_set_fixed_vector(float *out, const AMRFixed *in, float scale, int size); + +/** + * Clear array values set by set_fixed_vector + * + * @param out fixed vector to be cleared + * @param in sparse fixed vector + * @param size the output vector size + */ +void ff_clear_fixed_vector(float *out, const AMRFixed *in, int size); + +#endif /* AVCODEC_ACELP_VECTORS_H */ diff --git a/lib/rbcodec/codecs/libwmavoice/avcodec.h b/lib/rbcodec/codecs/libwmavoice/avcodec.h new file mode 100644 index 0000000000..db08ab3c5f --- /dev/null +++ b/lib/rbcodec/codecs/libwmavoice/avcodec.h @@ -0,0 +1,4044 @@ +/* + * copyright (c) 2001 Fabrice Bellard + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVCODEC_AVCODEC_H +#define AVCODEC_AVCODEC_H + +/** + * @file + * external API header + */ + +#include +#include "libavutil/avutil.h" + +#define LIBAVCODEC_VERSION_MAJOR 52 +#define LIBAVCODEC_VERSION_MINOR 84 +#define LIBAVCODEC_VERSION_MICRO 3 + +#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ + LIBAVCODEC_VERSION_MINOR, \ + LIBAVCODEC_VERSION_MICRO) +#define LIBAVCODEC_VERSION AV_VERSION(LIBAVCODEC_VERSION_MAJOR, \ + LIBAVCODEC_VERSION_MINOR, \ + LIBAVCODEC_VERSION_MICRO) +#define LIBAVCODEC_BUILD LIBAVCODEC_VERSION_INT + +#define LIBAVCODEC_IDENT "Lavc" AV_STRINGIFY(LIBAVCODEC_VERSION) + +#define AV_NOPTS_VALUE INT64_C(0x8000000000000000) +#define AV_TIME_BASE 1000000 +#define AV_TIME_BASE_Q (AVRational){1, AV_TIME_BASE} + +/** + * Identify the syntax and semantics of the bitstream. + * The principle is roughly: + * Two decoders with the same ID can decode the same streams. + * Two encoders with the same ID can encode compatible streams. + * There may be slight deviations from the principle due to implementation + * details. + * + * If you add a codec ID to this list, add it so that + * 1. no value of a existing codec ID changes (that would break ABI), + * 2. it is as close as possible to similar codecs. + */ +enum CodecID { + CODEC_ID_NONE, + + /* video codecs */ + CODEC_ID_MPEG1VIDEO, + CODEC_ID_MPEG2VIDEO, ///< preferred ID for MPEG-1/2 video decoding + CODEC_ID_MPEG2VIDEO_XVMC, + CODEC_ID_H261, + CODEC_ID_H263, + CODEC_ID_RV10, + CODEC_ID_RV20, + CODEC_ID_MJPEG, + CODEC_ID_MJPEGB, + CODEC_ID_LJPEG, + CODEC_ID_SP5X, + CODEC_ID_JPEGLS, + CODEC_ID_MPEG4, + CODEC_ID_RAWVIDEO, + CODEC_ID_MSMPEG4V1, + CODEC_ID_MSMPEG4V2, + CODEC_ID_MSMPEG4V3, + CODEC_ID_WMV1, + CODEC_ID_WMV2, + CODEC_ID_H263P, + CODEC_ID_H263I, + CODEC_ID_FLV1, + CODEC_ID_SVQ1, + CODEC_ID_SVQ3, + CODEC_ID_DVVIDEO, + CODEC_ID_HUFFYUV, + CODEC_ID_CYUV, + CODEC_ID_H264, + CODEC_ID_INDEO3, + CODEC_ID_VP3, + CODEC_ID_THEORA, + CODEC_ID_ASV1, + CODEC_ID_ASV2, + CODEC_ID_FFV1, + CODEC_ID_4XM, + CODEC_ID_VCR1, + CODEC_ID_CLJR, + CODEC_ID_MDEC, + CODEC_ID_ROQ, + CODEC_ID_INTERPLAY_VIDEO, + CODEC_ID_XAN_WC3, + CODEC_ID_XAN_WC4, + CODEC_ID_RPZA, + CODEC_ID_CINEPAK, + CODEC_ID_WS_VQA, + CODEC_ID_MSRLE, + CODEC_ID_MSVIDEO1, + CODEC_ID_IDCIN, + CODEC_ID_8BPS, + CODEC_ID_SMC, + CODEC_ID_FLIC, + CODEC_ID_TRUEMOTION1, + CODEC_ID_VMDVIDEO, + CODEC_ID_MSZH, + CODEC_ID_ZLIB, + CODEC_ID_QTRLE, + CODEC_ID_SNOW, + CODEC_ID_TSCC, + CODEC_ID_ULTI, + CODEC_ID_QDRAW, + CODEC_ID_VIXL, + CODEC_ID_QPEG, +#if LIBAVCODEC_VERSION_MAJOR < 53 + CODEC_ID_XVID, +#endif + CODEC_ID_PNG, + CODEC_ID_PPM, + CODEC_ID_PBM, + CODEC_ID_PGM, + CODEC_ID_PGMYUV, + CODEC_ID_PAM, + CODEC_ID_FFVHUFF, + CODEC_ID_RV30, + CODEC_ID_RV40, + CODEC_ID_VC1, + CODEC_ID_WMV3, + CODEC_ID_LOCO, + CODEC_ID_WNV1, + CODEC_ID_AASC, + CODEC_ID_INDEO2, + CODEC_ID_FRAPS, + CODEC_ID_TRUEMOTION2, + CODEC_ID_BMP, + CODEC_ID_CSCD, + CODEC_ID_MMVIDEO, + CODEC_ID_ZMBV, + CODEC_ID_AVS, + CODEC_ID_SMACKVIDEO, + CODEC_ID_NUV, + CODEC_ID_KMVC, + CODEC_ID_FLASHSV, + CODEC_ID_CAVS, + CODEC_ID_JPEG2000, + CODEC_ID_VMNC, + CODEC_ID_VP5, + CODEC_ID_VP6, + CODEC_ID_VP6F, + CODEC_ID_TARGA, + CODEC_ID_DSICINVIDEO, + CODEC_ID_TIERTEXSEQVIDEO, + CODEC_ID_TIFF, + CODEC_ID_GIF, + CODEC_ID_FFH264, + CODEC_ID_DXA, + CODEC_ID_DNXHD, + CODEC_ID_THP, + CODEC_ID_SGI, + CODEC_ID_C93, + CODEC_ID_BETHSOFTVID, + CODEC_ID_PTX, + CODEC_ID_TXD, + CODEC_ID_VP6A, + CODEC_ID_AMV, + CODEC_ID_VB, + CODEC_ID_PCX, + CODEC_ID_SUNRAST, + CODEC_ID_INDEO4, + CODEC_ID_INDEO5, + CODEC_ID_MIMIC, + CODEC_ID_RL2, + CODEC_ID_8SVX_EXP, + CODEC_ID_8SVX_FIB, + CODEC_ID_ESCAPE124, + CODEC_ID_DIRAC, + CODEC_ID_BFI, + CODEC_ID_CMV, + CODEC_ID_MOTIONPIXELS, + CODEC_ID_TGV, + CODEC_ID_TGQ, + CODEC_ID_TQI, + CODEC_ID_AURA, + CODEC_ID_AURA2, + CODEC_ID_V210X, + CODEC_ID_TMV, + CODEC_ID_V210, + CODEC_ID_DPX, + CODEC_ID_MAD, + CODEC_ID_FRWU, + CODEC_ID_FLASHSV2, + CODEC_ID_CDGRAPHICS, + CODEC_ID_R210, + CODEC_ID_ANM, + CODEC_ID_BINKVIDEO, + CODEC_ID_IFF_ILBM, + CODEC_ID_IFF_BYTERUN1, + CODEC_ID_KGV1, + CODEC_ID_YOP, + CODEC_ID_VP8, + CODEC_ID_PICTOR, + CODEC_ID_ANSI, + + /* various PCM "codecs" */ + CODEC_ID_PCM_S16LE= 0x10000, + CODEC_ID_PCM_S16BE, + CODEC_ID_PCM_U16LE, + CODEC_ID_PCM_U16BE, + CODEC_ID_PCM_S8, + CODEC_ID_PCM_U8, + CODEC_ID_PCM_MULAW, + CODEC_ID_PCM_ALAW, + CODEC_ID_PCM_S32LE, + CODEC_ID_PCM_S32BE, + CODEC_ID_PCM_U32LE, + CODEC_ID_PCM_U32BE, + CODEC_ID_PCM_S24LE, + CODEC_ID_PCM_S24BE, + CODEC_ID_PCM_U24LE, + CODEC_ID_PCM_U24BE, + CODEC_ID_PCM_S24DAUD, + CODEC_ID_PCM_ZORK, + CODEC_ID_PCM_S16LE_PLANAR, + CODEC_ID_PCM_DVD, + CODEC_ID_PCM_F32BE, + CODEC_ID_PCM_F32LE, + CODEC_ID_PCM_F64BE, + CODEC_ID_PCM_F64LE, + CODEC_ID_PCM_BLURAY, + + /* various ADPCM codecs */ + CODEC_ID_ADPCM_IMA_QT= 0x11000, + CODEC_ID_ADPCM_IMA_WAV, + CODEC_ID_ADPCM_IMA_DK3, + CODEC_ID_ADPCM_IMA_DK4, + CODEC_ID_ADPCM_IMA_WS, + CODEC_ID_ADPCM_IMA_SMJPEG, + CODEC_ID_ADPCM_MS, + CODEC_ID_ADPCM_4XM, + CODEC_ID_ADPCM_XA, + CODEC_ID_ADPCM_ADX, + CODEC_ID_ADPCM_EA, + CODEC_ID_ADPCM_G726, + CODEC_ID_ADPCM_CT, + CODEC_ID_ADPCM_SWF, + CODEC_ID_ADPCM_YAMAHA, + CODEC_ID_ADPCM_SBPRO_4, + CODEC_ID_ADPCM_SBPRO_3, + CODEC_ID_ADPCM_SBPRO_2, + CODEC_ID_ADPCM_THP, + CODEC_ID_ADPCM_IMA_AMV, + CODEC_ID_ADPCM_EA_R1, + CODEC_ID_ADPCM_EA_R3, + CODEC_ID_ADPCM_EA_R2, + CODEC_ID_ADPCM_IMA_EA_SEAD, + CODEC_ID_ADPCM_IMA_EA_EACS, + CODEC_ID_ADPCM_EA_XAS, + CODEC_ID_ADPCM_EA_MAXIS_XA, + CODEC_ID_ADPCM_IMA_ISS, + + /* AMR */ + CODEC_ID_AMR_NB= 0x12000, + CODEC_ID_AMR_WB, + + /* RealAudio codecs*/ + CODEC_ID_RA_144= 0x13000, + CODEC_ID_RA_288, + + /* various DPCM codecs */ + CODEC_ID_ROQ_DPCM= 0x14000, + CODEC_ID_INTERPLAY_DPCM, + CODEC_ID_XAN_DPCM, + CODEC_ID_SOL_DPCM, + + /* audio codecs */ + CODEC_ID_MP2= 0x15000, + CODEC_ID_MP3, ///< preferred ID for decoding MPEG audio layer 1, 2 or 3 + CODEC_ID_AAC, + CODEC_ID_AC3, + CODEC_ID_DTS, + CODEC_ID_VORBIS, + CODEC_ID_DVAUDIO, + CODEC_ID_WMAV1, + CODEC_ID_WMAV2, + CODEC_ID_MACE3, + CODEC_ID_MACE6, + CODEC_ID_VMDAUDIO, + CODEC_ID_SONIC, + CODEC_ID_SONIC_LS, + CODEC_ID_FLAC, + CODEC_ID_MP3ADU, + CODEC_ID_MP3ON4, + CODEC_ID_SHORTEN, + CODEC_ID_ALAC, + CODEC_ID_WESTWOOD_SND1, + CODEC_ID_GSM, ///< as in Berlin toast format + CODEC_ID_QDM2, + CODEC_ID_COOK, + CODEC_ID_TRUESPEECH, + CODEC_ID_TTA, + CODEC_ID_SMACKAUDIO, + CODEC_ID_QCELP, + CODEC_ID_WAVPACK, + CODEC_ID_DSICINAUDIO, + CODEC_ID_IMC, + CODEC_ID_MUSEPACK7, + CODEC_ID_MLP, + CODEC_ID_GSM_MS, /* as found in WAV */ + CODEC_ID_ATRAC3, + CODEC_ID_VOXWARE, + CODEC_ID_APE, + CODEC_ID_NELLYMOSER, + CODEC_ID_MUSEPACK8, + CODEC_ID_SPEEX, + CODEC_ID_WMAVOICE, + CODEC_ID_WMAPRO, + CODEC_ID_WMALOSSLESS, + CODEC_ID_ATRAC3P, + CODEC_ID_EAC3, + CODEC_ID_SIPR, + CODEC_ID_MP1, + CODEC_ID_TWINVQ, + CODEC_ID_TRUEHD, + CODEC_ID_MP4ALS, + CODEC_ID_ATRAC1, + CODEC_ID_BINKAUDIO_RDFT, + CODEC_ID_BINKAUDIO_DCT, + + /* subtitle codecs */ + CODEC_ID_DVD_SUBTITLE= 0x17000, + CODEC_ID_DVB_SUBTITLE, + CODEC_ID_TEXT, ///< raw UTF-8 text + CODEC_ID_XSUB, + CODEC_ID_SSA, + CODEC_ID_MOV_TEXT, + CODEC_ID_HDMV_PGS_SUBTITLE, + CODEC_ID_DVB_TELETEXT, + CODEC_ID_SRT, + + /* other specific kind of codecs (generally used for attachments) */ + CODEC_ID_TTF= 0x18000, + + CODEC_ID_PROBE= 0x19000, ///< codec_id is not known (like CODEC_ID_NONE) but lavf should attempt to identify it + + CODEC_ID_MPEG2TS= 0x20000, /**< _FAKE_ codec to indicate a raw MPEG-2 TS + * stream (only used by libavformat) */ +}; + +#if LIBAVCODEC_VERSION_MAJOR < 53 +#define CodecType AVMediaType + +#define CODEC_TYPE_UNKNOWN AVMEDIA_TYPE_UNKNOWN +#define CODEC_TYPE_VIDEO AVMEDIA_TYPE_VIDEO +#define CODEC_TYPE_AUDIO AVMEDIA_TYPE_AUDIO +#define CODEC_TYPE_DATA AVMEDIA_TYPE_DATA +#define CODEC_TYPE_SUBTITLE AVMEDIA_TYPE_SUBTITLE +#define CODEC_TYPE_ATTACHMENT AVMEDIA_TYPE_ATTACHMENT +#define CODEC_TYPE_NB AVMEDIA_TYPE_NB +#endif + +/** + * all in native-endian format + */ +enum SampleFormat { + SAMPLE_FMT_NONE = -1, + SAMPLE_FMT_U8, ///< unsigned 8 bits + SAMPLE_FMT_S16, ///< signed 16 bits + SAMPLE_FMT_S32, ///< signed 32 bits + SAMPLE_FMT_FLT, ///< float + SAMPLE_FMT_DBL, ///< double + SAMPLE_FMT_NB ///< Number of sample formats. DO NOT USE if dynamically linking to libavcodec +}; + +/* Audio channel masks */ +#define CH_FRONT_LEFT 0x00000001 +#define CH_FRONT_RIGHT 0x00000002 +#define CH_FRONT_CENTER 0x00000004 +#define CH_LOW_FREQUENCY 0x00000008 +#define CH_BACK_LEFT 0x00000010 +#define CH_BACK_RIGHT 0x00000020 +#define CH_FRONT_LEFT_OF_CENTER 0x00000040 +#define CH_FRONT_RIGHT_OF_CENTER 0x00000080 +#define CH_BACK_CENTER 0x00000100 +#define CH_SIDE_LEFT 0x00000200 +#define CH_SIDE_RIGHT 0x00000400 +#define CH_TOP_CENTER 0x00000800 +#define CH_TOP_FRONT_LEFT 0x00001000 +#define CH_TOP_FRONT_CENTER 0x00002000 +#define CH_TOP_FRONT_RIGHT 0x00004000 +#define CH_TOP_BACK_LEFT 0x00008000 +#define CH_TOP_BACK_CENTER 0x00010000 +#define CH_TOP_BACK_RIGHT 0x00020000 +#define CH_STEREO_LEFT 0x20000000 ///< Stereo downmix. +#define CH_STEREO_RIGHT 0x40000000 ///< See CH_STEREO_LEFT. + +/** Channel mask value used for AVCodecContext.request_channel_layout + to indicate that the user requests the channel order of the decoder output + to be the native codec channel order. */ +#define CH_LAYOUT_NATIVE 0x8000000000000000LL + +/* Audio channel convenience macros */ +#define CH_LAYOUT_MONO (CH_FRONT_CENTER) +#define CH_LAYOUT_STEREO (CH_FRONT_LEFT|CH_FRONT_RIGHT) +#define CH_LAYOUT_2_1 (CH_LAYOUT_STEREO|CH_BACK_CENTER) +#define CH_LAYOUT_SURROUND (CH_LAYOUT_STEREO|CH_FRONT_CENTER) +#define CH_LAYOUT_4POINT0 (CH_LAYOUT_SURROUND|CH_BACK_CENTER) +#define CH_LAYOUT_2_2 (CH_LAYOUT_STEREO|CH_SIDE_LEFT|CH_SIDE_RIGHT) +#define CH_LAYOUT_QUAD (CH_LAYOUT_STEREO|CH_BACK_LEFT|CH_BACK_RIGHT) +#define CH_LAYOUT_5POINT0 (CH_LAYOUT_SURROUND|CH_SIDE_LEFT|CH_SIDE_RIGHT) +#define CH_LAYOUT_5POINT1 (CH_LAYOUT_5POINT0|CH_LOW_FREQUENCY) +#define CH_LAYOUT_5POINT0_BACK (CH_LAYOUT_SURROUND|CH_BACK_LEFT|CH_BACK_RIGHT) +#define CH_LAYOUT_5POINT1_BACK (CH_LAYOUT_5POINT0_BACK|CH_LOW_FREQUENCY) +#define CH_LAYOUT_7POINT0 (CH_LAYOUT_5POINT0|CH_BACK_LEFT|CH_BACK_RIGHT) +#define CH_LAYOUT_7POINT1 (CH_LAYOUT_5POINT1|CH_BACK_LEFT|CH_BACK_RIGHT) +#define CH_LAYOUT_7POINT1_WIDE (CH_LAYOUT_5POINT1_BACK|\ + CH_FRONT_LEFT_OF_CENTER|CH_FRONT_RIGHT_OF_CENTER) +#define CH_LAYOUT_STEREO_DOWNMIX (CH_STEREO_LEFT|CH_STEREO_RIGHT) + +/* in bytes */ +#define AVCODEC_MAX_AUDIO_FRAME_SIZE 192000 // 1 second of 48khz 32bit audio + +/** + * Required number of additionally allocated bytes at the end of the input bitstream for decoding. + * This is mainly needed because some optimized bitstream readers read + * 32 or 64 bit at once and could read over the end.
+ * Note: If the first 23 bits of the additional bytes are not 0, then damaged + * MPEG bitstreams could cause overread and segfault. + */ +#define FF_INPUT_BUFFER_PADDING_SIZE 8 + +/** + * minimum encoding buffer size + * Used to avoid some checks during header writing. + */ +#define FF_MIN_BUFFER_SIZE 16384 + + +/** + * motion estimation type. + */ +enum Motion_Est_ID { + ME_ZERO = 1, ///< no search, that is use 0,0 vector whenever one is needed + ME_FULL, + ME_LOG, + ME_PHODS, + ME_EPZS, ///< enhanced predictive zonal search + ME_X1, ///< reserved for experiments + ME_HEX, ///< hexagon based search + ME_UMH, ///< uneven multi-hexagon search + ME_ITER, ///< iterative search + ME_TESA, ///< transformed exhaustive search algorithm +}; + +enum AVDiscard{ + /* We leave some space between them for extensions (drop some + * keyframes for intra-only or drop just some bidir frames). */ + AVDISCARD_NONE =-16, ///< discard nothing + AVDISCARD_DEFAULT= 0, ///< discard useless packets like 0 size packets in avi + AVDISCARD_NONREF = 8, ///< discard all non reference + AVDISCARD_BIDIR = 16, ///< discard all bidirectional frames + AVDISCARD_NONKEY = 32, ///< discard all frames except keyframes + AVDISCARD_ALL = 48, ///< discard all +}; + +enum AVColorPrimaries{ + AVCOL_PRI_BT709 =1, ///< also ITU-R BT1361 / IEC 61966-2-4 / SMPTE RP177 Annex B + AVCOL_PRI_UNSPECIFIED=2, + AVCOL_PRI_BT470M =4, + AVCOL_PRI_BT470BG =5, ///< also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM + AVCOL_PRI_SMPTE170M =6, ///< also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC + AVCOL_PRI_SMPTE240M =7, ///< functionally identical to above + AVCOL_PRI_FILM =8, + AVCOL_PRI_NB , ///< Not part of ABI +}; + +enum AVColorTransferCharacteristic{ + AVCOL_TRC_BT709 =1, ///< also ITU-R BT1361 + AVCOL_TRC_UNSPECIFIED=2, + AVCOL_TRC_GAMMA22 =4, ///< also ITU-R BT470M / ITU-R BT1700 625 PAL & SECAM + AVCOL_TRC_GAMMA28 =5, ///< also ITU-R BT470BG + AVCOL_TRC_NB , ///< Not part of ABI +}; + +enum AVColorSpace{ + AVCOL_SPC_RGB =0, + AVCOL_SPC_BT709 =1, ///< also ITU-R BT1361 / IEC 61966-2-4 xvYCC709 / SMPTE RP177 Annex B + AVCOL_SPC_UNSPECIFIED=2, + AVCOL_SPC_FCC =4, + AVCOL_SPC_BT470BG =5, ///< also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM / IEC 61966-2-4 xvYCC601 + AVCOL_SPC_SMPTE170M =6, ///< also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC / functionally identical to above + AVCOL_SPC_SMPTE240M =7, + AVCOL_SPC_NB , ///< Not part of ABI +}; + +enum AVColorRange{ + AVCOL_RANGE_UNSPECIFIED=0, + AVCOL_RANGE_MPEG =1, ///< the normal 219*2^(n-8) "MPEG" YUV ranges + AVCOL_RANGE_JPEG =2, ///< the normal 2^n-1 "JPEG" YUV ranges + AVCOL_RANGE_NB , ///< Not part of ABI +}; + +/** + * X X 3 4 X X are luma samples, + * 1 2 1-6 are possible chroma positions + * X X 5 6 X 0 is undefined/unknown position + */ +enum AVChromaLocation{ + AVCHROMA_LOC_UNSPECIFIED=0, + AVCHROMA_LOC_LEFT =1, ///< mpeg2/4, h264 default + AVCHROMA_LOC_CENTER =2, ///< mpeg1, jpeg, h263 + AVCHROMA_LOC_TOPLEFT =3, ///< DV + AVCHROMA_LOC_TOP =4, + AVCHROMA_LOC_BOTTOMLEFT =5, + AVCHROMA_LOC_BOTTOM =6, + AVCHROMA_LOC_NB , ///< Not part of ABI +}; + +/** + * LPC analysis type + */ +enum AVLPCType { + AV_LPC_TYPE_DEFAULT = -1, ///< use the codec default LPC type + AV_LPC_TYPE_NONE = 0, ///< do not use LPC prediction or use all zero coefficients + AV_LPC_TYPE_FIXED = 1, ///< fixed LPC coefficients + AV_LPC_TYPE_LEVINSON = 2, ///< Levinson-Durbin recursion + AV_LPC_TYPE_CHOLESKY = 3, ///< Cholesky factorization + AV_LPC_TYPE_NB , ///< Not part of ABI +}; + +typedef struct RcOverride{ + int start_frame; + int end_frame; + int qscale; // If this is 0 then quality_factor will be used instead. + float quality_factor; +} RcOverride; + +#define FF_MAX_B_FRAMES 16 + +/* encoding support + These flags can be passed in AVCodecContext.flags before initialization. + Note: Not everything is supported yet. +*/ + +#define CODEC_FLAG_QSCALE 0x0002 ///< Use fixed qscale. +#define CODEC_FLAG_4MV 0x0004 ///< 4 MV per MB allowed / advanced prediction for H.263. +#define CODEC_FLAG_QPEL 0x0010 ///< Use qpel MC. +#define CODEC_FLAG_GMC 0x0020 ///< Use GMC. +#define CODEC_FLAG_MV0 0x0040 ///< Always try a MB with MV=<0,0>. +#define CODEC_FLAG_PART 0x0080 ///< Use data partitioning. +/** + * The parent program guarantees that the input for B-frames containing + * streams is not written to for at least s->max_b_frames+1 frames, if + * this is not set the input will be copied. + */ +#define CODEC_FLAG_INPUT_PRESERVED 0x0100 +#define CODEC_FLAG_PASS1 0x0200 ///< Use internal 2pass ratecontrol in first pass mode. +#define CODEC_FLAG_PASS2 0x0400 ///< Use internal 2pass ratecontrol in second pass mode. +#define CODEC_FLAG_EXTERN_HUFF 0x1000 ///< Use external Huffman table (for MJPEG). +#define CODEC_FLAG_GRAY 0x2000 ///< Only decode/encode grayscale. +#define CODEC_FLAG_EMU_EDGE 0x4000 ///< Don't draw edges. +#define CODEC_FLAG_PSNR 0x8000 ///< error[?] variables will be set during encoding. +#define CODEC_FLAG_TRUNCATED 0x00010000 /** Input bitstream might be truncated at a random + location instead of only at frame boundaries. */ +#define CODEC_FLAG_NORMALIZE_AQP 0x00020000 ///< Normalize adaptive quantization. +#define CODEC_FLAG_INTERLACED_DCT 0x00040000 ///< Use interlaced DCT. +#define CODEC_FLAG_LOW_DELAY 0x00080000 ///< Force low delay. +#define CODEC_FLAG_ALT_SCAN 0x00100000 ///< Use alternate scan. +#define CODEC_FLAG_GLOBAL_HEADER 0x00400000 ///< Place global headers in extradata instead of every keyframe. +#define CODEC_FLAG_BITEXACT 0x00800000 ///< Use only bitexact stuff (except (I)DCT). +/* Fx : Flag for h263+ extra options */ +#define CODEC_FLAG_AC_PRED 0x01000000 ///< H.263 advanced intra coding / MPEG-4 AC prediction +#define CODEC_FLAG_H263P_UMV 0x02000000 ///< unlimited motion vector +#define CODEC_FLAG_CBP_RD 0x04000000 ///< Use rate distortion optimization for cbp. +#define CODEC_FLAG_QP_RD 0x08000000 ///< Use rate distortion optimization for qp selectioon. +#define CODEC_FLAG_H263P_AIV 0x00000008 ///< H.263 alternative inter VLC +#define CODEC_FLAG_OBMC 0x00000001 ///< OBMC +#define CODEC_FLAG_LOOP_FILTER 0x00000800 ///< loop filter +#define CODEC_FLAG_H263P_SLICE_STRUCT 0x10000000 +#define CODEC_FLAG_INTERLACED_ME 0x20000000 ///< interlaced motion estimation +#define CODEC_FLAG_SVCD_SCAN_OFFSET 0x40000000 ///< Will reserve space for SVCD scan offset user data. +#define CODEC_FLAG_CLOSED_GOP 0x80000000 +#define CODEC_FLAG2_FAST 0x00000001 ///< Allow non spec compliant speedup tricks. +#define CODEC_FLAG2_STRICT_GOP 0x00000002 ///< Strictly enforce GOP size. +#define CODEC_FLAG2_NO_OUTPUT 0x00000004 ///< Skip bitstream encoding. +#define CODEC_FLAG2_LOCAL_HEADER 0x00000008 ///< Place global headers at every keyframe instead of in extradata. +#define CODEC_FLAG2_BPYRAMID 0x00000010 ///< H.264 allow B-frames to be used as references. +#define CODEC_FLAG2_WPRED 0x00000020 ///< H.264 weighted biprediction for B-frames +#define CODEC_FLAG2_MIXED_REFS 0x00000040 ///< H.264 one reference per partition, as opposed to one reference per macroblock +#define CODEC_FLAG2_8X8DCT 0x00000080 ///< H.264 high profile 8x8 transform +#define CODEC_FLAG2_FASTPSKIP 0x00000100 ///< H.264 fast pskip +#define CODEC_FLAG2_AUD 0x00000200 ///< H.264 access unit delimiters +#define CODEC_FLAG2_BRDO 0x00000400 ///< B-frame rate-distortion optimization +#define CODEC_FLAG2_INTRA_VLC 0x00000800 ///< Use MPEG-2 intra VLC table. +#define CODEC_FLAG2_MEMC_ONLY 0x00001000 ///< Only do ME/MC (I frames -> ref, P frame -> ME+MC). +#define CODEC_FLAG2_DROP_FRAME_TIMECODE 0x00002000 ///< timecode is in drop frame format. +#define CODEC_FLAG2_SKIP_RD 0x00004000 ///< RD optimal MB level residual skipping +#define CODEC_FLAG2_CHUNKS 0x00008000 ///< Input bitstream might be truncated at a packet boundaries instead of only at frame boundaries. +#define CODEC_FLAG2_NON_LINEAR_QUANT 0x00010000 ///< Use MPEG-2 nonlinear quantizer. +#define CODEC_FLAG2_BIT_RESERVOIR 0x00020000 ///< Use a bit reservoir when encoding if possible +#define CODEC_FLAG2_MBTREE 0x00040000 ///< Use macroblock tree ratecontrol (x264 only) +#define CODEC_FLAG2_PSY 0x00080000 ///< Use psycho visual optimizations. +#define CODEC_FLAG2_SSIM 0x00100000 ///< Compute SSIM during encoding, error[] values are undefined. +#define CODEC_FLAG2_INTRA_REFRESH 0x00200000 ///< Use periodic insertion of intra blocks instead of keyframes. + +/* Unsupported options : + * Syntax Arithmetic coding (SAC) + * Reference Picture Selection + * Independent Segment Decoding */ +/* /Fx */ +/* codec capabilities */ + +#define CODEC_CAP_DRAW_HORIZ_BAND 0x0001 ///< Decoder can use draw_horiz_band callback. +/** + * Codec uses get_buffer() for allocating buffers and supports custom allocators. + * If not set, it might not use get_buffer() at all or use operations that + * assume the buffer was allocated by avcodec_default_get_buffer. + */ +#define CODEC_CAP_DR1 0x0002 +/* If 'parse_only' field is true, then avcodec_parse_frame() can be used. */ +#define CODEC_CAP_PARSE_ONLY 0x0004 +#define CODEC_CAP_TRUNCATED 0x0008 +/* Codec can export data for HW decoding (XvMC). */ +#define CODEC_CAP_HWACCEL 0x0010 +/** + * Codec has a nonzero delay and needs to be fed with NULL at the end to get the delayed data. + * If this is not set, the codec is guaranteed to never be fed with NULL data. + */ +#define CODEC_CAP_DELAY 0x0020 +/** + * Codec can be fed a final frame with a smaller size. + * This can be used to prevent truncation of the last audio samples. + */ +#define CODEC_CAP_SMALL_LAST_FRAME 0x0040 +/** + * Codec can export data for HW decoding (VDPAU). + */ +#define CODEC_CAP_HWACCEL_VDPAU 0x0080 +/** + * Codec can output multiple frames per AVPacket + * Normally demuxers return one frame at a time, demuxers which do not do + * are connected to a parser to split what they return into proper frames. + * This flag is reserved to the very rare category of codecs which have a + * bitstream that cannot be split into frames without timeconsuming + * operations like full decoding. Demuxers carring such bitstreams thus + * may return multiple frames in a packet. This has many disadvantages like + * prohibiting stream copy in many cases thus it should only be considered + * as a last resort. + */ +#define CODEC_CAP_SUBFRAMES 0x0100 +/** + * Codec is experimental and is thus avoided in favor of non experimental + * encoders + */ +#define CODEC_CAP_EXPERIMENTAL 0x0200 + +//The following defines may change, don't expect compatibility if you use them. +#define MB_TYPE_INTRA4x4 0x0001 +#define MB_TYPE_INTRA16x16 0x0002 //FIXME H.264-specific +#define MB_TYPE_INTRA_PCM 0x0004 //FIXME H.264-specific +#define MB_TYPE_16x16 0x0008 +#define MB_TYPE_16x8 0x0010 +#define MB_TYPE_8x16 0x0020 +#define MB_TYPE_8x8 0x0040 +#define MB_TYPE_INTERLACED 0x0080 +#define MB_TYPE_DIRECT2 0x0100 //FIXME +#define MB_TYPE_ACPRED 0x0200 +#define MB_TYPE_GMC 0x0400 +#define MB_TYPE_SKIP 0x0800 +#define MB_TYPE_P0L0 0x1000 +#define MB_TYPE_P1L0 0x2000 +#define MB_TYPE_P0L1 0x4000 +#define MB_TYPE_P1L1 0x8000 +#define MB_TYPE_L0 (MB_TYPE_P0L0 | MB_TYPE_P1L0) +#define MB_TYPE_L1 (MB_TYPE_P0L1 | MB_TYPE_P1L1) +#define MB_TYPE_L0L1 (MB_TYPE_L0 | MB_TYPE_L1) +#define MB_TYPE_QUANT 0x00010000 +#define MB_TYPE_CBP 0x00020000 +//Note bits 24-31 are reserved for codec specific use (h264 ref0, mpeg1 0mv, ...) + +/** + * Pan Scan area. + * This specifies the area which should be displayed. + * Note there may be multiple such areas for one frame. + */ +typedef struct AVPanScan{ + /** + * id + * - encoding: Set by user. + * - decoding: Set by libavcodec. + */ + int id; + + /** + * width and height in 1/16 pel + * - encoding: Set by user. + * - decoding: Set by libavcodec. + */ + int width; + int height; + + /** + * position of the top left corner in 1/16 pel for up to 3 fields/frames + * - encoding: Set by user. + * - decoding: Set by libavcodec. + */ + int16_t position[3][2]; +}AVPanScan; + +#define FF_COMMON_FRAME \ + /**\ + * pointer to the picture planes.\ + * This might be different from the first allocated byte\ + * - encoding: \ + * - decoding: \ + */\ + uint8_t *data[4];\ + int linesize[4];\ + /**\ + * pointer to the first allocated byte of the picture. Can be used in get_buffer/release_buffer.\ + * This isn't used by libavcodec unless the default get/release_buffer() is used.\ + * - encoding: \ + * - decoding: \ + */\ + uint8_t *base[4];\ + /**\ + * 1 -> keyframe, 0-> not\ + * - encoding: Set by libavcodec.\ + * - decoding: Set by libavcodec.\ + */\ + int key_frame;\ +\ + /**\ + * Picture type of the frame, see ?_TYPE below.\ + * - encoding: Set by libavcodec. for coded_picture (and set by user for input).\ + * - decoding: Set by libavcodec.\ + */\ + int pict_type;\ +\ + /**\ + * presentation timestamp in time_base units (time when frame should be shown to user)\ + * If AV_NOPTS_VALUE then frame_rate = 1/time_base will be assumed.\ + * - encoding: MUST be set by user.\ + * - decoding: Set by libavcodec.\ + */\ + int64_t pts;\ +\ + /**\ + * picture number in bitstream order\ + * - encoding: set by\ + * - decoding: Set by libavcodec.\ + */\ + int coded_picture_number;\ + /**\ + * picture number in display order\ + * - encoding: set by\ + * - decoding: Set by libavcodec.\ + */\ + int display_picture_number;\ +\ + /**\ + * quality (between 1 (good) and FF_LAMBDA_MAX (bad)) \ + * - encoding: Set by libavcodec. for coded_picture (and set by user for input).\ + * - decoding: Set by libavcodec.\ + */\ + int quality; \ +\ + /**\ + * buffer age (1->was last buffer and dint change, 2->..., ...).\ + * Set to INT_MAX if the buffer has not been used yet.\ + * - encoding: unused\ + * - decoding: MUST be set by get_buffer().\ + */\ + int age;\ +\ + /**\ + * is this picture used as reference\ + * The values for this are the same as the MpegEncContext.picture_structure\ + * variable, that is 1->top field, 2->bottom field, 3->frame/both fields.\ + * Set to 4 for delayed, non-reference frames.\ + * - encoding: unused\ + * - decoding: Set by libavcodec. (before get_buffer() call)).\ + */\ + int reference;\ +\ + /**\ + * QP table\ + * - encoding: unused\ + * - decoding: Set by libavcodec.\ + */\ + int8_t *qscale_table;\ + /**\ + * QP store stride\ + * - encoding: unused\ + * - decoding: Set by libavcodec.\ + */\ + int qstride;\ +\ + /**\ + * mbskip_table[mb]>=1 if MB didn't change\ + * stride= mb_width = (width+15)>>4\ + * - encoding: unused\ + * - decoding: Set by libavcodec.\ + */\ + uint8_t *mbskip_table;\ +\ + /**\ + * motion vector table\ + * @code\ + * example:\ + * int mv_sample_log2= 4 - motion_subsample_log2;\ + * int mb_width= (width+15)>>4;\ + * int mv_stride= (mb_width << mv_sample_log2) + 1;\ + * motion_val[direction][x + y*mv_stride][0->mv_x, 1->mv_y];\ + * @endcode\ + * - encoding: Set by user.\ + * - decoding: Set by libavcodec.\ + */\ + int16_t (*motion_val[2])[2];\ +\ + /**\ + * macroblock type table\ + * mb_type_base + mb_width + 2\ + * - encoding: Set by user.\ + * - decoding: Set by libavcodec.\ + */\ + uint32_t *mb_type;\ +\ + /**\ + * log2 of the size of the block which a single vector in motion_val represents: \ + * (4->16x16, 3->8x8, 2-> 4x4, 1-> 2x2)\ + * - encoding: unused\ + * - decoding: Set by libavcodec.\ + */\ + uint8_t motion_subsample_log2;\ +\ + /**\ + * for some private data of the user\ + * - encoding: unused\ + * - decoding: Set by user.\ + */\ + void *opaque;\ +\ + /**\ + * error\ + * - encoding: Set by libavcodec. if flags&CODEC_FLAG_PSNR.\ + * - decoding: unused\ + */\ + uint64_t error[4];\ +\ + /**\ + * type of the buffer (to keep track of who has to deallocate data[*])\ + * - encoding: Set by the one who allocates it.\ + * - decoding: Set by the one who allocates it.\ + * Note: User allocated (direct rendering) & internal buffers cannot coexist currently.\ + */\ + int type;\ + \ + /**\ + * When decoding, this signals how much the picture must be delayed.\ + * extra_delay = repeat_pict / (2*fps)\ + * - encoding: unused\ + * - decoding: Set by libavcodec.\ + */\ + int repeat_pict;\ + \ + /**\ + * \ + */\ + int qscale_type;\ + \ + /**\ + * The content of the picture is interlaced.\ + * - encoding: Set by user.\ + * - decoding: Set by libavcodec. (default 0)\ + */\ + int interlaced_frame;\ + \ + /**\ + * If the content is interlaced, is top field displayed first.\ + * - encoding: Set by user.\ + * - decoding: Set by libavcodec.\ + */\ + int top_field_first;\ + \ + /**\ + * Pan scan.\ + * - encoding: Set by user.\ + * - decoding: Set by libavcodec.\ + */\ + AVPanScan *pan_scan;\ + \ + /**\ + * Tell user application that palette has changed from previous frame.\ + * - encoding: ??? (no palette-enabled encoder yet)\ + * - decoding: Set by libavcodec. (default 0).\ + */\ + int palette_has_changed;\ + \ + /**\ + * codec suggestion on buffer type if != 0\ + * - encoding: unused\ + * - decoding: Set by libavcodec. (before get_buffer() call)).\ + */\ + int buffer_hints;\ +\ + /**\ + * DCT coefficients\ + * - encoding: unused\ + * - decoding: Set by libavcodec.\ + */\ + short *dct_coeff;\ +\ + /**\ + * motion reference frame index\ + * the order in which these are stored can depend on the codec.\ + * - encoding: Set by user.\ + * - decoding: Set by libavcodec.\ + */\ + int8_t *ref_index[2];\ +\ + /**\ + * reordered opaque 64bit number (generally a PTS) from AVCodecContext.reordered_opaque\ + * output in AVFrame.reordered_opaque\ + * - encoding: unused\ + * - decoding: Read by user.\ + */\ + int64_t reordered_opaque;\ +\ + /**\ + * hardware accelerator private data (FFmpeg allocated)\ + * - encoding: unused\ + * - decoding: Set by libavcodec\ + */\ + void *hwaccel_picture_private;\ + + +#define FF_QSCALE_TYPE_MPEG1 0 +#define FF_QSCALE_TYPE_MPEG2 1 +#define FF_QSCALE_TYPE_H264 2 +#define FF_QSCALE_TYPE_VP56 3 + +#define FF_BUFFER_TYPE_INTERNAL 1 +#define FF_BUFFER_TYPE_USER 2 ///< direct rendering buffers (image is (de)allocated by user) +#define FF_BUFFER_TYPE_SHARED 4 ///< Buffer from somewhere else; don't deallocate image (data/base), all other tables are not shared. +#define FF_BUFFER_TYPE_COPY 8 ///< Just a (modified) copy of some other buffer, don't deallocate anything. + + +#define FF_I_TYPE 1 ///< Intra +#define FF_P_TYPE 2 ///< Predicted +#define FF_B_TYPE 3 ///< Bi-dir predicted +#define FF_S_TYPE 4 ///< S(GMC)-VOP MPEG4 +#define FF_SI_TYPE 5 ///< Switching Intra +#define FF_SP_TYPE 6 ///< Switching Predicted +#define FF_BI_TYPE 7 + +#define FF_BUFFER_HINTS_VALID 0x01 // Buffer hints value is meaningful (if 0 ignore). +#define FF_BUFFER_HINTS_READABLE 0x02 // Codec will read from buffer. +#define FF_BUFFER_HINTS_PRESERVE 0x04 // User must not alter buffer content. +#define FF_BUFFER_HINTS_REUSABLE 0x08 // Codec will reuse the buffer (update). + +typedef struct AVPacket { + /** + * Presentation timestamp in AVStream->time_base units; the time at which + * the decompressed packet will be presented to the user. + * Can be AV_NOPTS_VALUE if it is not stored in the file. + * pts MUST be larger or equal to dts as presentation cannot happen before + * decompression, unless one wants to view hex dumps. Some formats misuse + * the terms dts and pts/cts to mean something different. Such timestamps + * must be converted to true pts/dts before they are stored in AVPacket. + */ + int64_t pts; + /** + * Decompression timestamp in AVStream->time_base units; the time at which + * the packet is decompressed. + * Can be AV_NOPTS_VALUE if it is not stored in the file. + */ + int64_t dts; + uint8_t *data; + int size; + int stream_index; + int flags; + /** + * Duration of this packet in AVStream->time_base units, 0 if unknown. + * Equals next_pts - this_pts in presentation order. + */ + int duration; + void (*destruct)(struct AVPacket *); + void *priv; + int64_t pos; ///< byte position in stream, -1 if unknown + + /** + * Time difference in AVStream->time_base units from the pts of this + * packet to the point at which the output from the decoder has converged + * independent from the availability of previous frames. That is, the + * frames are virtually identical no matter if decoding started from + * the very first frame or from this keyframe. + * Is AV_NOPTS_VALUE if unknown. + * This field is not the display duration of the current packet. + * This field has no meaning if the packet does not have AV_PKT_FLAG_KEY + * set. + * + * The purpose of this field is to allow seeking in streams that have no + * keyframes in the conventional sense. It corresponds to the + * recovery point SEI in H.264 and match_time_delta in NUT. It is also + * essential for some types of subtitle streams to ensure that all + * subtitles are correctly displayed after seeking. + */ + int64_t convergence_duration; +} AVPacket; +#define AV_PKT_FLAG_KEY 0x0001 +#if LIBAVCODEC_VERSION_MAJOR < 53 +#define PKT_FLAG_KEY AV_PKT_FLAG_KEY +#endif + +/** + * Audio Video Frame. + * New fields can be added to the end of FF_COMMON_FRAME with minor version + * bumps. + * Removal, reordering and changes to existing fields require a major + * version bump. No fields should be added into AVFrame before or after + * FF_COMMON_FRAME! + * sizeof(AVFrame) must not be used outside libav*. + */ +typedef struct AVFrame { + FF_COMMON_FRAME +} AVFrame; + +/** + * main external API structure. + * New fields can be added to the end with minor version bumps. + * Removal, reordering and changes to existing fields require a major + * version bump. + * sizeof(AVCodecContext) must not be used outside libav*. + */ +typedef struct AVCodecContext { + /** + * information on struct for av_log + * - set by avcodec_alloc_context + */ + const AVClass *av_class; + /** + * the average bitrate + * - encoding: Set by user; unused for constant quantizer encoding. + * - decoding: Set by libavcodec. 0 or some bitrate if this info is available in the stream. + */ + int bit_rate; + + /** + * number of bits the bitstream is allowed to diverge from the reference. + * the reference can be CBR (for CBR pass1) or VBR (for pass2) + * - encoding: Set by user; unused for constant quantizer encoding. + * - decoding: unused + */ + int bit_rate_tolerance; + + /** + * CODEC_FLAG_*. + * - encoding: Set by user. + * - decoding: Set by user. + */ + int flags; + + /** + * Some codecs need additional format info. It is stored here. + * If any muxer uses this then ALL demuxers/parsers AND encoders for the + * specific codec MUST set it correctly otherwise stream copy breaks. + * In general use of this field by muxers is not recommanded. + * - encoding: Set by libavcodec. + * - decoding: Set by libavcodec. (FIXME: Is this OK?) + */ + int sub_id; + + /** + * Motion estimation algorithm used for video coding. + * 1 (zero), 2 (full), 3 (log), 4 (phods), 5 (epzs), 6 (x1), 7 (hex), + * 8 (umh), 9 (iter), 10 (tesa) [7, 8, 10 are x264 specific, 9 is snow specific] + * - encoding: MUST be set by user. + * - decoding: unused + */ + int me_method; + + /** + * some codecs need / can use extradata like Huffman tables. + * mjpeg: Huffman tables + * rv10: additional flags + * mpeg4: global headers (they can be in the bitstream or here) + * The allocated memory should be FF_INPUT_BUFFER_PADDING_SIZE bytes larger + * than extradata_size to avoid prolems if it is read with the bitstream reader. + * The bytewise contents of extradata must not depend on the architecture or CPU endianness. + * - encoding: Set/allocated/freed by libavcodec. + * - decoding: Set/allocated/freed by user. + */ + uint8_t *extradata; + int extradata_size; + + /** + * This is the fundamental unit of time (in seconds) in terms + * of which frame timestamps are represented. For fixed-fps content, + * timebase should be 1/framerate and timestamp increments should be + * identically 1. + * - encoding: MUST be set by user. + * - decoding: Set by libavcodec. + */ + //AVRational time_base; + + /* video only */ + /** + * picture width / height. + * - encoding: MUST be set by user. + * - decoding: Set by libavcodec. + * Note: For compatibility it is possible to set this instead of + * coded_width/height before decoding. + */ + int width, height; + +#define FF_ASPECT_EXTENDED 15 + + /** + * the number of pictures in a group of pictures, or 0 for intra_only + * - encoding: Set by user. + * - decoding: unused + */ + int gop_size; + + /** + * Pixel format, see PIX_FMT_xxx. + * May be set by the demuxer if known from headers. + * May be overriden by the decoder if it knows better. + * - encoding: Set by user. + * - decoding: Set by user if known, overridden by libavcodec if known + */ + //enum PixelFormat pix_fmt; + + /** + * Frame rate emulation. If not zero, the lower layer (i.e. format handler) + * has to read frames at native frame rate. + * - encoding: Set by user. + * - decoding: unused + */ + int rate_emu; + + /** + * If non NULL, 'draw_horiz_band' is called by the libavcodec + * decoder to draw a horizontal band. It improves cache usage. Not + * all codecs can do that. You must check the codec capabilities + * beforehand. + * The function is also used by hardware acceleration APIs. + * It is called at least once during frame decoding to pass + * the data needed for hardware render. + * In that mode instead of pixel data, AVFrame points to + * a structure specific to the acceleration API. The application + * reads the structure and can change some fields to indicate progress + * or mark state. + * - encoding: unused + * - decoding: Set by user. + * @param height the height of the slice + * @param y the y position of the slice + * @param type 1->top field, 2->bottom field, 3->frame + * @param offset offset into the AVFrame.data from which the slice should be read + */ + void (*draw_horiz_band)(struct AVCodecContext *s, + const AVFrame *src, int offset[4], + int y, int type, int height); + + /* audio only */ + int sample_rate; ///< samples per second + int channels; ///< number of audio channels + + /** + * audio sample format + * - encoding: Set by user. + * - decoding: Set by libavcodec. + */ + enum SampleFormat sample_fmt; ///< sample format + + /* The following data should not be initialized. */ + /** + * Samples per packet, initialized when calling 'init'. + */ + int frame_size; + int frame_number; ///< audio or video frame number +#if LIBAVCODEC_VERSION_MAJOR < 53 + int real_pict_num; ///< Returns the real picture number of previous encoded frame. +#endif + + /** + * Number of frames the decoded output will be delayed relative to + * the encoded input. + * - encoding: Set by libavcodec. + * - decoding: unused + */ + int delay; + + /* - encoding parameters */ + float qcompress; ///< amount of qscale change between easy & hard scenes (0.0-1.0) + float qblur; ///< amount of qscale smoothing over time (0.0-1.0) + + /** + * minimum quantizer + * - encoding: Set by user. + * - decoding: unused + */ + int qmin; + + /** + * maximum quantizer + * - encoding: Set by user. + * - decoding: unused + */ + int qmax; + + /** + * maximum quantizer difference between frames + * - encoding: Set by user. + * - decoding: unused + */ + int max_qdiff; + + /** + * maximum number of B-frames between non-B-frames + * Note: The output will be delayed by max_b_frames+1 relative to the input. + * - encoding: Set by user. + * - decoding: unused + */ + int max_b_frames; + + /** + * qscale factor between IP and B-frames + * If > 0 then the last P-frame quantizer will be used (q= lastp_q*factor+offset). + * If < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset). + * - encoding: Set by user. + * - decoding: unused + */ + float b_quant_factor; + + /** obsolete FIXME remove */ + int rc_strategy; +#define FF_RC_STRATEGY_XVID 1 + + int b_frame_strategy; + + /** + * hurry up amount + * - encoding: unused + * - decoding: Set by user. 1-> Skip B-frames, 2-> Skip IDCT/dequant too, 5-> Skip everything except header + * @deprecated Deprecated in favor of skip_idct and skip_frame. + */ + int hurry_up; + + struct AVCodec *codec; + + void *priv_data; + + int rtp_payload_size; /* The size of the RTP payload: the coder will */ + /* do its best to deliver a chunk with size */ + /* below rtp_payload_size, the chunk will start */ + /* with a start code on some codecs like H.263. */ + /* This doesn't take account of any particular */ + /* headers inside the transmitted RTP payload. */ + + + /* The RTP callback: This function is called */ + /* every time the encoder has a packet to send. */ + /* It depends on the encoder if the data starts */ + /* with a Start Code (it should). H.263 does. */ + /* mb_nb contains the number of macroblocks */ + /* encoded in the RTP payload. */ + void (*rtp_callback)(struct AVCodecContext *avctx, void *data, int size, int mb_nb); + + /* statistics, used for 2-pass encoding */ + int mv_bits; + int header_bits; + int i_tex_bits; + int p_tex_bits; + int i_count; + int p_count; + int skip_count; + int misc_bits; + + /** + * number of bits used for the previously encoded frame + * - encoding: Set by libavcodec. + * - decoding: unused + */ + int frame_bits; + + /** + * Private data of the user, can be used to carry app specific stuff. + * - encoding: Set by user. + * - decoding: Set by user. + */ + void *opaque; + + char codec_name[32]; + enum AVMediaType codec_type; /* see AVMEDIA_TYPE_xxx */ + enum CodecID codec_id; /* see CODEC_ID_xxx */ + + /** + * fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A'). + * This is used to work around some encoder bugs. + * A demuxer should set this to what is stored in the field used to identify the codec. + * If there are multiple such fields in a container then the demuxer should choose the one + * which maximizes the information about the used codec. + * If the codec tag field in a container is larger then 32 bits then the demuxer should + * remap the longer ID to 32 bits with a table or other structure. Alternatively a new + * extra_codec_tag + size could be added but for this a clear advantage must be demonstrated + * first. + * - encoding: Set by user, if not then the default based on codec_id will be used. + * - decoding: Set by user, will be converted to uppercase by libavcodec during init. + */ + unsigned int codec_tag; + + /** + * Work around bugs in encoders which sometimes cannot be detected automatically. + * - encoding: Set by user + * - decoding: Set by user + */ + int workaround_bugs; +#define FF_BUG_AUTODETECT 1 ///< autodetection +#define FF_BUG_OLD_MSMPEG4 2 +#define FF_BUG_XVID_ILACE 4 +#define FF_BUG_UMP4 8 +#define FF_BUG_NO_PADDING 16 +#define FF_BUG_AMV 32 +#define FF_BUG_AC_VLC 0 ///< Will be removed, libavcodec can now handle these non-compliant files by default. +#define FF_BUG_QPEL_CHROMA 64 +#define FF_BUG_STD_QPEL 128 +#define FF_BUG_QPEL_CHROMA2 256 +#define FF_BUG_DIRECT_BLOCKSIZE 512 +#define FF_BUG_EDGE 1024 +#define FF_BUG_HPEL_CHROMA 2048 +#define FF_BUG_DC_CLIP 4096 +#define FF_BUG_MS 8192 ///< Work around various bugs in Microsoft's broken decoders. +#define FF_BUG_TRUNCATED 16384 +//#define FF_BUG_FAKE_SCALABILITY 16 //Autodetection should work 100%. + + /** + * luma single coefficient elimination threshold + * - encoding: Set by user. + * - decoding: unused + */ + int luma_elim_threshold; + + /** + * chroma single coeff elimination threshold + * - encoding: Set by user. + * - decoding: unused + */ + int chroma_elim_threshold; + + /** + * strictly follow the standard (MPEG4, ...). + * - encoding: Set by user. + * - decoding: Set by user. + * Setting this to STRICT or higher means the encoder and decoder will + * generally do stupid things, whereas setting it to unofficial or lower + * will mean the encoder might produce output that is not supported by all + * spec-compliant decoders. Decoders don't differentiate between normal, + * unofficial and experimental (that is, they always try to decode things + * when they can) unless they are explicitly asked to behave stupidly + * (=strictly conform to the specs) + */ + int strict_std_compliance; +#define FF_COMPLIANCE_VERY_STRICT 2 ///< Strictly conform to an older more strict version of the spec or reference software. +#define FF_COMPLIANCE_STRICT 1 ///< Strictly conform to all the things in the spec no matter what consequences. +#define FF_COMPLIANCE_NORMAL 0 +#if LIBAVCODEC_VERSION_MAJOR < 53 +#define FF_COMPLIANCE_INOFFICIAL -1 ///< Allow inofficial extensions (deprecated - use FF_COMPLIANCE_UNOFFICIAL instead). +#endif +#define FF_COMPLIANCE_UNOFFICIAL -1 ///< Allow unofficial extensions +#define FF_COMPLIANCE_EXPERIMENTAL -2 ///< Allow nonstandardized experimental things. + + /** + * qscale offset between IP and B-frames + * - encoding: Set by user. + * - decoding: unused + */ + float b_quant_offset; + + /** + * Error recognization; higher values will detect more errors but may + * misdetect some more or less valid parts as errors. + * - encoding: unused + * - decoding: Set by user. + */ + int error_recognition; +#define FF_ER_CAREFUL 1 +#define FF_ER_COMPLIANT 2 +#define FF_ER_AGGRESSIVE 3 +#define FF_ER_VERY_AGGRESSIVE 4 + + /** + * Called at the beginning of each frame to get a buffer for it. + * If pic.reference is set then the frame will be read later by libavcodec. + * avcodec_align_dimensions2() should be used to find the required width and + * height, as they normally need to be rounded up to the next multiple of 16. + * if CODEC_CAP_DR1 is not set then get_buffer() must call + * avcodec_default_get_buffer() instead of providing buffers allocated by + * some other means. + * - encoding: unused + * - decoding: Set by libavcodec, user can override. + */ + int (*get_buffer)(struct AVCodecContext *c, AVFrame *pic); + + /** + * Called to release buffers which were allocated with get_buffer. + * A released buffer can be reused in get_buffer(). + * pic.data[*] must be set to NULL. + * - encoding: unused + * - decoding: Set by libavcodec, user can override. + */ + void (*release_buffer)(struct AVCodecContext *c, AVFrame *pic); + + /** + * Size of the frame reordering buffer in the decoder. + * For MPEG-2 it is 1 IPB or 0 low delay IP. + * - encoding: Set by libavcodec. + * - decoding: Set by libavcodec. + */ + int has_b_frames; + + /** + * number of bytes per packet if constant and known or 0 + * Used by some WAV based audio codecs. + */ + int block_align; + + int parse_only; /* - decoding only: If true, only parsing is done + (function avcodec_parse_frame()). The frame + data is returned. Only MPEG codecs support this now. */ + + /** + * 0-> h263 quant 1-> mpeg quant + * - encoding: Set by user. + * - decoding: unused + */ + int mpeg_quant; + + /** + * pass1 encoding statistics output buffer + * - encoding: Set by libavcodec. + * - decoding: unused + */ + char *stats_out; + + /** + * pass2 encoding statistics input buffer + * Concatenated stuff from stats_out of pass1 should be placed here. + * - encoding: Allocated/set/freed by user. + * - decoding: unused + */ + char *stats_in; + + /** + * ratecontrol qmin qmax limiting method + * 0-> clipping, 1-> use a nice continous function to limit qscale wthin qmin/qmax. + * - encoding: Set by user. + * - decoding: unused + */ + float rc_qsquish; + + float rc_qmod_amp; + int rc_qmod_freq; + + /** + * ratecontrol override, see RcOverride + * - encoding: Allocated/set/freed by user. + * - decoding: unused + */ + RcOverride *rc_override; + int rc_override_count; + + /** + * rate control equation + * - encoding: Set by user + * - decoding: unused + */ + const char *rc_eq; + + /** + * maximum bitrate + * - encoding: Set by user. + * - decoding: unused + */ + int rc_max_rate; + + /** + * minimum bitrate + * - encoding: Set by user. + * - decoding: unused + */ + int rc_min_rate; + + /** + * decoder bitstream buffer size + * - encoding: Set by user. + * - decoding: unused + */ + int rc_buffer_size; + float rc_buffer_aggressivity; + + /** + * qscale factor between P and I-frames + * If > 0 then the last p frame quantizer will be used (q= lastp_q*factor+offset). + * If < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset). + * - encoding: Set by user. + * - decoding: unused + */ + float i_quant_factor; + + /** + * qscale offset between P and I-frames + * - encoding: Set by user. + * - decoding: unused + */ + float i_quant_offset; + + /** + * initial complexity for pass1 ratecontrol + * - encoding: Set by user. + * - decoding: unused + */ + float rc_initial_cplx; + + /** + * DCT algorithm, see FF_DCT_* below + * - encoding: Set by user. + * - decoding: unused + */ + int dct_algo; +#define FF_DCT_AUTO 0 +#define FF_DCT_FASTINT 1 +#define FF_DCT_INT 2 +#define FF_DCT_MMX 3 +#define FF_DCT_MLIB 4 +#define FF_DCT_ALTIVEC 5 +#define FF_DCT_FAAN 6 + + /** + * luminance masking (0-> disabled) + * - encoding: Set by user. + * - decoding: unused + */ + float lumi_masking; + + /** + * temporary complexity masking (0-> disabled) + * - encoding: Set by user. + * - decoding: unused + */ + float temporal_cplx_masking; + + /** + * spatial complexity masking (0-> disabled) + * - encoding: Set by user. + * - decoding: unused + */ + float spatial_cplx_masking; + + /** + * p block masking (0-> disabled) + * - encoding: Set by user. + * - decoding: unused + */ + float p_masking; + + /** + * darkness masking (0-> disabled) + * - encoding: Set by user. + * - decoding: unused + */ + float dark_masking; + + /** + * IDCT algorithm, see FF_IDCT_* below. + * - encoding: Set by user. + * - decoding: Set by user. + */ + int idct_algo; +#define FF_IDCT_AUTO 0 +#define FF_IDCT_INT 1 +#define FF_IDCT_SIMPLE 2 +#define FF_IDCT_SIMPLEMMX 3 +#define FF_IDCT_LIBMPEG2MMX 4 +#define FF_IDCT_PS2 5 +#define FF_IDCT_MLIB 6 +#define FF_IDCT_ARM 7 +#define FF_IDCT_ALTIVEC 8 +#define FF_IDCT_SH4 9 +#define FF_IDCT_SIMPLEARM 10 +#define FF_IDCT_H264 11 +#define FF_IDCT_VP3 12 +#define FF_IDCT_IPP 13 +#define FF_IDCT_XVIDMMX 14 +#define FF_IDCT_CAVS 15 +#define FF_IDCT_SIMPLEARMV5TE 16 +#define FF_IDCT_SIMPLEARMV6 17 +#define FF_IDCT_SIMPLEVIS 18 +#define FF_IDCT_WMV2 19 +#define FF_IDCT_FAAN 20 +#define FF_IDCT_EA 21 +#define FF_IDCT_SIMPLENEON 22 +#define FF_IDCT_SIMPLEALPHA 23 +#define FF_IDCT_BINK 24 + + /** + * slice count + * - encoding: Set by libavcodec. + * - decoding: Set by user (or 0). + */ + int slice_count; + /** + * slice offsets in the frame in bytes + * - encoding: Set/allocated by libavcodec. + * - decoding: Set/allocated by user (or NULL). + */ + int *slice_offset; + + /** + * error concealment flags + * - encoding: unused + * - decoding: Set by user. + */ + int error_concealment; +#define FF_EC_GUESS_MVS 1 +#define FF_EC_DEBLOCK 2 + + /** + * dsp_mask could be add used to disable unwanted CPU features + * CPU features (i.e. MMX, SSE. ...) + * + * With the FORCE flag you may instead enable given CPU features. + * (Dangerous: Usable in case of misdetection, improper usage however will + * result into program crash.) + */ + unsigned dsp_mask; +#define FF_MM_FORCE 0x80000000 /* Force usage of selected flags (OR) */ + /* lower 16 bits - CPU features */ +#define FF_MM_MMX 0x0001 ///< standard MMX +#define FF_MM_3DNOW 0x0004 ///< AMD 3DNOW +#if LIBAVCODEC_VERSION_MAJOR < 53 +#define FF_MM_MMXEXT 0x0002 ///< SSE integer functions or AMD MMX ext +#endif +#define FF_MM_MMX2 0x0002 ///< SSE integer functions or AMD MMX ext +#define FF_MM_SSE 0x0008 ///< SSE functions +#define FF_MM_SSE2 0x0010 ///< PIV SSE2 functions +#define FF_MM_SSE2SLOW 0x40000000 ///< SSE2 supported, but usually not faster + ///< than regular MMX/SSE (e.g. Core1) +#define FF_MM_3DNOWEXT 0x0020 ///< AMD 3DNowExt +#define FF_MM_SSE3 0x0040 ///< Prescott SSE3 functions +#define FF_MM_SSE3SLOW 0x20000000 ///< SSE3 supported, but usually not faster + ///< than regular MMX/SSE (e.g. Core1) +#define FF_MM_SSSE3 0x0080 ///< Conroe SSSE3 functions +#define FF_MM_SSE4 0x0100 ///< Penryn SSE4.1 functions +#define FF_MM_SSE42 0x0200 ///< Nehalem SSE4.2 functions +#define FF_MM_IWMMXT 0x0100 ///< XScale IWMMXT +#define FF_MM_ALTIVEC 0x0001 ///< standard AltiVec + + /** + * bits per sample/pixel from the demuxer (needed for huffyuv). + * - encoding: Set by libavcodec. + * - decoding: Set by user. + */ + int bits_per_coded_sample; + + /** + * prediction method (needed for huffyuv) + * - encoding: Set by user. + * - decoding: unused + */ + int prediction_method; +#define FF_PRED_LEFT 0 +#define FF_PRED_PLANE 1 +#define FF_PRED_MEDIAN 2 + + /** + * sample aspect ratio (0 if unknown) + * That is the width of a pixel divided by the height of the pixel. + * Numerator and denominator must be relatively prime and smaller than 256 for some video standards. + * - encoding: Set by user. + * - decoding: Set by libavcodec. + */ + //AVRational sample_aspect_ratio; + + /** + * the picture in the bitstream + * - encoding: Set by libavcodec. + * - decoding: Set by libavcodec. + */ + AVFrame *coded_frame; + + /** + * debug + * - encoding: Set by user. + * - decoding: Set by user. + */ + int debug; +#define FF_DEBUG_PICT_INFO 1 +#define FF_DEBUG_RC 2 +#define FF_DEBUG_BITSTREAM 4 +#define FF_DEBUG_MB_TYPE 8 +#define FF_DEBUG_QP 16 +#define FF_DEBUG_MV 32 +#define FF_DEBUG_DCT_COEFF 0x00000040 +#define FF_DEBUG_SKIP 0x00000080 +#define FF_DEBUG_STARTCODE 0x00000100 +#define FF_DEBUG_PTS 0x00000200 +#define FF_DEBUG_ER 0x00000400 +#define FF_DEBUG_MMCO 0x00000800 +#define FF_DEBUG_BUGS 0x00001000 +#define FF_DEBUG_VIS_QP 0x00002000 +#define FF_DEBUG_VIS_MB_TYPE 0x00004000 +#define FF_DEBUG_BUFFERS 0x00008000 + + /** + * debug + * - encoding: Set by user. + * - decoding: Set by user. + */ + int debug_mv; +#define FF_DEBUG_VIS_MV_P_FOR 0x00000001 //visualize forward predicted MVs of P frames +#define FF_DEBUG_VIS_MV_B_FOR 0x00000002 //visualize forward predicted MVs of B frames +#define FF_DEBUG_VIS_MV_B_BACK 0x00000004 //visualize backward predicted MVs of B frames + + /** + * error + * - encoding: Set by libavcodec if flags&CODEC_FLAG_PSNR. + * - decoding: unused + */ + uint64_t error[4]; + + /** + * minimum MB quantizer + * - encoding: unused + * - decoding: unused + */ + int mb_qmin; + + /** + * maximum MB quantizer + * - encoding: unused + * - decoding: unused + */ + int mb_qmax; + + /** + * motion estimation comparison function + * - encoding: Set by user. + * - decoding: unused + */ + int me_cmp; + /** + * subpixel motion estimation comparison function + * - encoding: Set by user. + * - decoding: unused + */ + int me_sub_cmp; + /** + * macroblock comparison function (not supported yet) + * - encoding: Set by user. + * - decoding: unused + */ + int mb_cmp; + /** + * interlaced DCT comparison function + * - encoding: Set by user. + * - decoding: unused + */ + int ildct_cmp; +#define FF_CMP_SAD 0 +#define FF_CMP_SSE 1 +#define FF_CMP_SATD 2 +#define FF_CMP_DCT 3 +#define FF_CMP_PSNR 4 +#define FF_CMP_BIT 5 +#define FF_CMP_RD 6 +#define FF_CMP_ZERO 7 +#define FF_CMP_VSAD 8 +#define FF_CMP_VSSE 9 +#define FF_CMP_NSSE 10 +#define FF_CMP_W53 11 +#define FF_CMP_W97 12 +#define FF_CMP_DCTMAX 13 +#define FF_CMP_DCT264 14 +#define FF_CMP_CHROMA 256 + + /** + * ME diamond size & shape + * - encoding: Set by user. + * - decoding: unused + */ + int dia_size; + + /** + * amount of previous MV predictors (2a+1 x 2a+1 square) + * - encoding: Set by user. + * - decoding: unused + */ + int last_predictor_count; + + /** + * prepass for motion estimation + * - encoding: Set by user. + * - decoding: unused + */ + int pre_me; + + /** + * motion estimation prepass comparison function + * - encoding: Set by user. + * - decoding: unused + */ + int me_pre_cmp; + + /** + * ME prepass diamond size & shape + * - encoding: Set by user. + * - decoding: unused + */ + int pre_dia_size; + + /** + * subpel ME quality + * - encoding: Set by user. + * - decoding: unused + */ + int me_subpel_quality; + + /** + * callback to negotiate the pixelFormat + * @param fmt is the list of formats which are supported by the codec, + * it is terminated by -1 as 0 is a valid format, the formats are ordered by quality. + * The first is always the native one. + * @return the chosen format + * - encoding: unused + * - decoding: Set by user, if not set the native format will be chosen. + */ + enum PixelFormat (*get_format)(struct AVCodecContext *s, const enum PixelFormat * fmt); + + /** + * DTG active format information (additional aspect ratio + * information only used in DVB MPEG-2 transport streams) + * 0 if not set. + * + * - encoding: unused + * - decoding: Set by decoder. + */ + int dtg_active_format; +#define FF_DTG_AFD_SAME 8 +#define FF_DTG_AFD_4_3 9 +#define FF_DTG_AFD_16_9 10 +#define FF_DTG_AFD_14_9 11 +#define FF_DTG_AFD_4_3_SP_14_9 13 +#define FF_DTG_AFD_16_9_SP_14_9 14 +#define FF_DTG_AFD_SP_4_3 15 + + /** + * maximum motion estimation search range in subpel units + * If 0 then no limit. + * + * - encoding: Set by user. + * - decoding: unused + */ + int me_range; + + /** + * intra quantizer bias + * - encoding: Set by user. + * - decoding: unused + */ + int intra_quant_bias; +#define FF_DEFAULT_QUANT_BIAS 999999 + + /** + * inter quantizer bias + * - encoding: Set by user. + * - decoding: unused + */ + int inter_quant_bias; + + /** + * color table ID + * - encoding: unused + * - decoding: Which clrtable should be used for 8bit RGB images. + * Tables have to be stored somewhere. FIXME + */ + int color_table_id; + + /** + * internal_buffer count + * Don't touch, used by libavcodec default_get_buffer(). + */ + int internal_buffer_count; + + /** + * internal_buffers + * Don't touch, used by libavcodec default_get_buffer(). + */ + void *internal_buffer; + +#define FF_LAMBDA_SHIFT 7 +#define FF_LAMBDA_SCALE (1< ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A'). + * This is used to work around some encoder bugs. + * - encoding: unused + * - decoding: Set by user, will be converted to uppercase by libavcodec during init. + */ + unsigned int stream_codec_tag; + + /** + * scene change detection threshold + * 0 is default, larger means fewer detected scene changes. + * - encoding: Set by user. + * - decoding: unused + */ + int scenechange_threshold; + + /** + * minimum Lagrange multipler + * - encoding: Set by user. + * - decoding: unused + */ + int lmin; + + /** + * maximum Lagrange multipler + * - encoding: Set by user. + * - decoding: unused + */ + int lmax; + + /** + * palette control structure + * - encoding: ??? (no palette-enabled encoder yet) + * - decoding: Set by user. + */ + struct AVPaletteControl *palctrl; + + /** + * noise reduction strength + * - encoding: Set by user. + * - decoding: unused + */ + int noise_reduction; + + /** + * Called at the beginning of a frame to get cr buffer for it. + * Buffer type (size, hints) must be the same. libavcodec won't check it. + * libavcodec will pass previous buffer in pic, function should return + * same buffer or new buffer with old frame "painted" into it. + * If pic.data[0] == NULL must behave like get_buffer(). + * if CODEC_CAP_DR1 is not set then reget_buffer() must call + * avcodec_default_reget_buffer() instead of providing buffers allocated by + * some other means. + * - encoding: unused + * - decoding: Set by libavcodec, user can override. + */ + int (*reget_buffer)(struct AVCodecContext *c, AVFrame *pic); + + /** + * Number of bits which should be loaded into the rc buffer before decoding starts. + * - encoding: Set by user. + * - decoding: unused + */ + int rc_initial_buffer_occupancy; + + /** + * + * - encoding: Set by user. + * - decoding: unused + */ + int inter_threshold; + + /** + * CODEC_FLAG2_* + * - encoding: Set by user. + * - decoding: Set by user. + */ + int flags2; + + /** + * Simulates errors in the bitstream to test error concealment. + * - encoding: Set by user. + * - decoding: unused + */ + int error_rate; + + /** + * MP3 antialias algorithm, see FF_AA_* below. + * - encoding: unused + * - decoding: Set by user. + */ + int antialias_algo; +#define FF_AA_AUTO 0 +#define FF_AA_FASTINT 1 //not implemented yet +#define FF_AA_INT 2 +#define FF_AA_FLOAT 3 + /** + * quantizer noise shaping + * - encoding: Set by user. + * - decoding: unused + */ + int quantizer_noise_shaping; + + /** + * thread count + * is used to decide how many independent tasks should be passed to execute() + * - encoding: Set by user. + * - decoding: Set by user. + */ + int thread_count; + + /** + * The codec may call this to execute several independent things. + * It will return only after finishing all tasks. + * The user may replace this with some multithreaded implementation, + * the default implementation will execute the parts serially. + * @param count the number of things to execute + * - encoding: Set by libavcodec, user can override. + * - decoding: Set by libavcodec, user can override. + */ + int (*execute)(struct AVCodecContext *c, int (*func)(struct AVCodecContext *c2, void *arg), void *arg2, int *ret, int count, int size); + + /** + * thread opaque + * Can be used by execute() to store some per AVCodecContext stuff. + * - encoding: set by execute() + * - decoding: set by execute() + */ + void *thread_opaque; + + /** + * Motion estimation threshold below which no motion estimation is + * performed, but instead the user specified motion vectors are used. + * + * - encoding: Set by user. + * - decoding: unused + */ + int me_threshold; + + /** + * Macroblock threshold below which the user specified macroblock types will be used. + * - encoding: Set by user. + * - decoding: unused + */ + int mb_threshold; + + /** + * precision of the intra DC coefficient - 8 + * - encoding: Set by user. + * - decoding: unused + */ + int intra_dc_precision; + + /** + * noise vs. sse weight for the nsse comparsion function + * - encoding: Set by user. + * - decoding: unused + */ + int nsse_weight; + + /** + * Number of macroblock rows at the top which are skipped. + * - encoding: unused + * - decoding: Set by user. + */ + int skip_top; + + /** + * Number of macroblock rows at the bottom which are skipped. + * - encoding: unused + * - decoding: Set by user. + */ + int skip_bottom; + + /** + * profile + * - encoding: Set by user. + * - decoding: Set by libavcodec. + */ + int profile; +#define FF_PROFILE_UNKNOWN -99 + +#define FF_PROFILE_AAC_MAIN 0 +#define FF_PROFILE_AAC_LOW 1 +#define FF_PROFILE_AAC_SSR 2 +#define FF_PROFILE_AAC_LTP 3 + +#define FF_PROFILE_H264_BASELINE 66 +#define FF_PROFILE_H264_MAIN 77 +#define FF_PROFILE_H264_EXTENDED 88 +#define FF_PROFILE_H264_HIGH 100 +#define FF_PROFILE_H264_HIGH_10 110 +#define FF_PROFILE_H264_HIGH_422 122 +#define FF_PROFILE_H264_HIGH_444 244 +#define FF_PROFILE_H264_CAVLC_444 44 + + /** + * level + * - encoding: Set by user. + * - decoding: Set by libavcodec. + */ + int level; +#define FF_LEVEL_UNKNOWN -99 + + /** + * low resolution decoding, 1-> 1/2 size, 2->1/4 size + * - encoding: unused + * - decoding: Set by user. + */ + int lowres; + + /** + * Bitstream width / height, may be different from width/height if lowres + * or other things are used. + * - encoding: unused + * - decoding: Set by user before init if known. Codec should override / dynamically change if needed. + */ + int coded_width, coded_height; + + /** + * frame skip threshold + * - encoding: Set by user. + * - decoding: unused + */ + int frame_skip_threshold; + + /** + * frame skip factor + * - encoding: Set by user. + * - decoding: unused + */ + int frame_skip_factor; + + /** + * frame skip exponent + * - encoding: Set by user. + * - decoding: unused + */ + int frame_skip_exp; + + /** + * frame skip comparison function + * - encoding: Set by user. + * - decoding: unused + */ + int frame_skip_cmp; + + /** + * Border processing masking, raises the quantizer for mbs on the borders + * of the picture. + * - encoding: Set by user. + * - decoding: unused + */ + float border_masking; + + /** + * minimum MB lagrange multipler + * - encoding: Set by user. + * - decoding: unused + */ + int mb_lmin; + + /** + * maximum MB lagrange multipler + * - encoding: Set by user. + * - decoding: unused + */ + int mb_lmax; + + /** + * + * - encoding: Set by user. + * - decoding: unused + */ + int me_penalty_compensation; + + /** + * + * - encoding: unused + * - decoding: Set by user. + */ + enum AVDiscard skip_loop_filter; + + /** + * + * - encoding: unused + * - decoding: Set by user. + */ + enum AVDiscard skip_idct; + + /** + * + * - encoding: unused + * - decoding: Set by user. + */ + enum AVDiscard skip_frame; + + /** + * + * - encoding: Set by user. + * - decoding: unused + */ + int bidir_refine; + + /** + * + * - encoding: Set by user. + * - decoding: unused + */ + int brd_scale; + + /** + * constant rate factor - quality-based VBR - values ~correspond to qps + * - encoding: Set by user. + * - decoding: unused + */ + float crf; + + /** + * constant quantization parameter rate control method + * - encoding: Set by user. + * - decoding: unused + */ + int cqp; + + /** + * minimum GOP size + * - encoding: Set by user. + * - decoding: unused + */ + int keyint_min; + + /** + * number of reference frames + * - encoding: Set by user. + * - decoding: Set by lavc. + */ + int refs; + + /** + * chroma qp offset from luma + * - encoding: Set by user. + * - decoding: unused + */ + int chromaoffset; + + /** + * Influences how often B-frames are used. + * - encoding: Set by user. + * - decoding: unused + */ + int bframebias; + + /** + * trellis RD quantization + * - encoding: Set by user. + * - decoding: unused + */ + int trellis; + + /** + * Reduce fluctuations in qp (before curve compression). + * - encoding: Set by user. + * - decoding: unused + */ + float complexityblur; + + /** + * in-loop deblocking filter alphac0 parameter + * alpha is in the range -6...6 + * - encoding: Set by user. + * - decoding: unused + */ + int deblockalpha; + + /** + * in-loop deblocking filter beta parameter + * beta is in the range -6...6 + * - encoding: Set by user. + * - decoding: unused + */ + int deblockbeta; + + /** + * macroblock subpartition sizes to consider - p8x8, p4x4, b8x8, i8x8, i4x4 + * - encoding: Set by user. + * - decoding: unused + */ + int partitions; +#define X264_PART_I4X4 0x001 /* Analyze i4x4 */ +#define X264_PART_I8X8 0x002 /* Analyze i8x8 (requires 8x8 transform) */ +#define X264_PART_P8X8 0x010 /* Analyze p16x8, p8x16 and p8x8 */ +#define X264_PART_P4X4 0x020 /* Analyze p8x4, p4x8, p4x4 */ +#define X264_PART_B8X8 0x100 /* Analyze b16x8, b8x16 and b8x8 */ + + /** + * direct MV prediction mode - 0 (none), 1 (spatial), 2 (temporal), 3 (auto) + * - encoding: Set by user. + * - decoding: unused + */ + int directpred; + + /** + * Audio cutoff bandwidth (0 means "automatic") + * - encoding: Set by user. + * - decoding: unused + */ + int cutoff; + + /** + * Multiplied by qscale for each frame and added to scene_change_score. + * - encoding: Set by user. + * - decoding: unused + */ + int scenechange_factor; + + /** + * + * Note: Value depends upon the compare function used for fullpel ME. + * - encoding: Set by user. + * - decoding: unused + */ + int mv0_threshold; + + /** + * Adjusts sensitivity of b_frame_strategy 1. + * - encoding: Set by user. + * - decoding: unused + */ + int b_sensitivity; + + /** + * - encoding: Set by user. + * - decoding: unused + */ + int compression_level; +#define FF_COMPRESSION_DEFAULT -1 + +#if LIBAVCODEC_VERSION_MAJOR < 53 + /** + * Sets whether to use LPC mode - used by FLAC encoder. + * - encoding: Set by user. + * - decoding: unused + * @deprecated Deprecated in favor of lpc_type and lpc_passes. + */ + int use_lpc; +#endif + + /** + * LPC coefficient precision - used by FLAC encoder + * - encoding: Set by user. + * - decoding: unused + */ + int lpc_coeff_precision; + + /** + * - encoding: Set by user. + * - decoding: unused + */ + int min_prediction_order; + + /** + * - encoding: Set by user. + * - decoding: unused + */ + int max_prediction_order; + + /** + * search method for selecting prediction order + * - encoding: Set by user. + * - decoding: unused + */ + int prediction_order_method; + + /** + * - encoding: Set by user. + * - decoding: unused + */ + int min_partition_order; + + /** + * - encoding: Set by user. + * - decoding: unused + */ + int max_partition_order; + + /** + * GOP timecode frame start number, in non drop frame format + * - encoding: Set by user. + * - decoding: unused + */ + int64_t timecode_frame_start; + +#if LIBAVCODEC_VERSION_MAJOR < 53 + /** + * Decoder should decode to this many channels if it can (0 for default) + * - encoding: unused + * - decoding: Set by user. + * @deprecated Deprecated in favor of request_channel_layout. + */ + int request_channels; +#endif + + /** + * Percentage of dynamic range compression to be applied by the decoder. + * The default value is 1.0, corresponding to full compression. + * - encoding: unused + * - decoding: Set by user. + */ + float drc_scale; + + /** + * opaque 64bit number (generally a PTS) that will be reordered and + * output in AVFrame.reordered_opaque + * - encoding: unused + * - decoding: Set by user. + */ + int64_t reordered_opaque; + + /** + * Bits per sample/pixel of internal libavcodec pixel/sample format. + * This field is applicable only when sample_fmt is SAMPLE_FMT_S32. + * - encoding: set by user. + * - decoding: set by libavcodec. + */ + int bits_per_raw_sample; + + /** + * Audio channel layout. + * - encoding: set by user. + * - decoding: set by libavcodec. + */ + int64_t channel_layout; + + /** + * Request decoder to use this channel layout if it can (0 for default) + * - encoding: unused + * - decoding: Set by user. + */ + int64_t request_channel_layout; + + /** + * Ratecontrol attempt to use, at maximum, of what can be used without an underflow. + * - encoding: Set by user. + * - decoding: unused. + */ + float rc_max_available_vbv_use; + + /** + * Ratecontrol attempt to use, at least, times the amount needed to prevent a vbv overflow. + * - encoding: Set by user. + * - decoding: unused. + */ + float rc_min_vbv_overflow_use; + + /** + * Hardware accelerator in use + * - encoding: unused. + * - decoding: Set by libavcodec + */ + struct AVHWAccel *hwaccel; + + /** + * For some codecs, the time base is closer to the field rate than the frame rate. + * Most notably, H.264 and MPEG-2 specify time_base as half of frame duration + * if no telecine is used ... + * + * Set to time_base ticks per frame. Default 1, e.g., H.264/MPEG-2 set it to 2. + */ + int ticks_per_frame; + + /** + * Hardware accelerator context. + * For some hardware accelerators, a global context needs to be + * provided by the user. In that case, this holds display-dependent + * data FFmpeg cannot instantiate itself. Please refer to the + * FFmpeg HW accelerator documentation to know how to fill this + * is. e.g. for VA API, this is a struct vaapi_context. + * - encoding: unused + * - decoding: Set by user + */ + void *hwaccel_context; + + /** + * Chromaticity coordinates of the source primaries. + * - encoding: Set by user + * - decoding: Set by libavcodec + */ + enum AVColorPrimaries color_primaries; + + /** + * Color Transfer Characteristic. + * - encoding: Set by user + * - decoding: Set by libavcodec + */ + enum AVColorTransferCharacteristic color_trc; + + /** + * YUV colorspace type. + * - encoding: Set by user + * - decoding: Set by libavcodec + */ + enum AVColorSpace colorspace; + + /** + * MPEG vs JPEG YUV range. + * - encoding: Set by user + * - decoding: Set by libavcodec + */ + enum AVColorRange color_range; + + /** + * This defines the location of chroma samples. + * - encoding: Set by user + * - decoding: Set by libavcodec + */ + enum AVChromaLocation chroma_sample_location; + + /** + * The codec may call this to execute several independent things. + * It will return only after finishing all tasks. + * The user may replace this with some multithreaded implementation, + * the default implementation will execute the parts serially. + * Also see avcodec_thread_init and e.g. the --enable-pthread configure option. + * @param c context passed also to func + * @param count the number of things to execute + * @param arg2 argument passed unchanged to func + * @param ret return values of executed functions, must have space for "count" values. May be NULL. + * @param func function that will be called count times, with jobnr from 0 to count-1. + * threadnr will be in the range 0 to c->thread_count-1 < MAX_THREADS and so that no + * two instances of func executing at the same time will have the same threadnr. + * @return always 0 currently, but code should handle a future improvement where when any call to func + * returns < 0 no further calls to func may be done and < 0 is returned. + * - encoding: Set by libavcodec, user can override. + * - decoding: Set by libavcodec, user can override. + */ + int (*execute2)(struct AVCodecContext *c, int (*func)(struct AVCodecContext *c2, void *arg, int jobnr, int threadnr), void *arg2, int *ret, int count); + + /** + * explicit P-frame weighted prediction analysis method + * 0: off + * 1: fast blind weighting (one reference duplicate with -1 offset) + * 2: smart weighting (full fade detection analysis) + * - encoding: Set by user. + * - decoding: unused + */ + int weighted_p_pred; + + /** + * AQ mode + * 0: Disabled + * 1: Variance AQ (complexity mask) + * 2: Auto-variance AQ (experimental) + * - encoding: Set by user + * - decoding: unused + */ + int aq_mode; + + /** + * AQ strength + * Reduces blocking and blurring in flat and textured areas. + * - encoding: Set by user + * - decoding: unused + */ + float aq_strength; + + /** + * PSY RD + * Strength of psychovisual optimization + * - encoding: Set by user + * - decoding: unused + */ + float psy_rd; + + /** + * PSY trellis + * Strength of psychovisual optimization + * - encoding: Set by user + * - decoding: unused + */ + float psy_trellis; + + /** + * RC lookahead + * Number of frames for frametype and ratecontrol lookahead + * - encoding: Set by user + * - decoding: unused + */ + int rc_lookahead; + + /** + * Constant rate factor maximum + * With CRF encoding mode and VBV restrictions enabled, prevents quality from being worse + * than crf_max, even if doing so would violate VBV restrictions. + * - encoding: Set by user. + * - decoding: unused + */ + float crf_max; + + int log_level_offset; + + /** + * Determines which LPC analysis algorithm to use. + * - encoding: Set by user + * - decoding: unused + */ + enum AVLPCType lpc_type; + + /** + * Number of passes to use for Cholesky factorization during LPC analysis + * - encoding: Set by user + * - decoding: unused + */ + int lpc_passes; +} AVCodecContext; + +/** + * AVCodec. + */ +typedef struct AVCodec { + /** + * Name of the codec implementation. + * The name is globally unique among encoders and among decoders (but an + * encoder and a decoder can share the same name). + * This is the primary way to find a codec from the user perspective. + */ + const char *name; + enum AVMediaType type; + enum CodecID id; + int priv_data_size; + int (*init)(AVCodecContext *); + int (*encode)(AVCodecContext *, uint8_t *buf, int buf_size, void *data); + int (*close)(AVCodecContext *); + int (*decode)(AVCodecContext *, void *outdata, int *outdata_size, AVPacket *avpkt); + /** + * Codec capabilities. + * see CODEC_CAP_* + */ + int capabilities; + struct AVCodec *next; + /** + * Flush buffers. + * Will be called when seeking + */ + void (*flush)(AVCodecContext *); + //const AVRational *supported_framerates; ///< array of supported framerates, or NULL if any, array is terminated by {0,0} + //const enum PixelFormat *pix_fmts; ///< array of supported pixel formats, or NULL if unknown, array is terminated by -1 + /** + * Descriptive name for the codec, meant to be more human readable than name. + * You should use the NULL_IF_CONFIG_SMALL() macro to define it. + */ + const char *long_name; + const int *supported_samplerates; ///< array of supported audio samplerates, or NULL if unknown, array is terminated by 0 + const enum SampleFormat *sample_fmts; ///< array of supported sample formats, or NULL if unknown, array is terminated by -1 + const int64_t *channel_layouts; ///< array of support channel layouts, or NULL if unknown. array is terminated by 0 + uint8_t max_lowres; ///< maximum value for lowres supported by the decoder +} AVCodec; + +/** + * AVHWAccel. + */ +typedef struct AVHWAccel { + /** + * Name of the hardware accelerated codec. + * The name is globally unique among encoders and among decoders (but an + * encoder and a decoder can share the same name). + */ + const char *name; + + /** + * Type of codec implemented by the hardware accelerator. + * + * See AVMEDIA_TYPE_xxx + */ + enum AVMediaType type; + + /** + * Codec implemented by the hardware accelerator. + * + * See CODEC_ID_xxx + */ + enum CodecID id; + + /** + * Supported pixel format. + * + * Only hardware accelerated formats are supported here. + */ + //enum PixelFormat pix_fmt; + + /** + * Hardware accelerated codec capabilities. + * see FF_HWACCEL_CODEC_CAP_* + */ + int capabilities; + + struct AVHWAccel *next; + + /** + * Called at the beginning of each frame or field picture. + * + * Meaningful frame information (codec specific) is guaranteed to + * be parsed at this point. This function is mandatory. + * + * Note that buf can be NULL along with buf_size set to 0. + * Otherwise, this means the whole frame is available at this point. + * + * @param avctx the codec context + * @param buf the frame data buffer base + * @param buf_size the size of the frame in bytes + * @return zero if successful, a negative value otherwise + */ + int (*start_frame)(AVCodecContext *avctx, const uint8_t *buf, uint32_t buf_size); + + /** + * Callback for each slice. + * + * Meaningful slice information (codec specific) is guaranteed to + * be parsed at this point. This function is mandatory. + * + * @param avctx the codec context + * @param buf the slice data buffer base + * @param buf_size the size of the slice in bytes + * @return zero if successful, a negative value otherwise + */ + int (*decode_slice)(AVCodecContext *avctx, const uint8_t *buf, uint32_t buf_size); + + /** + * Called at the end of each frame or field picture. + * + * The whole picture is parsed at this point and can now be sent + * to the hardware accelerator. This function is mandatory. + * + * @param avctx the codec context + * @return zero if successful, a negative value otherwise + */ + int (*end_frame)(AVCodecContext *avctx); + + /** + * Size of HW accelerator private data. + * + * Private data is allocated with av_mallocz() before + * AVCodecContext.get_buffer() and deallocated after + * AVCodecContext.release_buffer(). + */ + int priv_data_size; +} AVHWAccel; + +/** + * four components are given, that's all. + * the last component is alpha + */ +typedef struct AVPicture { + uint8_t *data[4]; + int linesize[4]; ///< number of bytes per line +} AVPicture; + +#if LIBAVCODEC_VERSION_MAJOR < 53 +/** + * AVPaletteControl + * This structure defines a method for communicating palette changes + * between and demuxer and a decoder. + * + * @deprecated Use AVPacket to send palette changes instead. + * This is totally broken. + */ +#define AVPALETTE_SIZE 1024 +#define AVPALETTE_COUNT 256 +typedef struct AVPaletteControl { + + /* Demuxer sets this to 1 to indicate the palette has changed; + * decoder resets to 0. */ + int palette_changed; + + /* 4-byte ARGB palette entries, stored in native byte order; note that + * the individual palette components should be on a 8-bit scale; if + * the palette data comes from an IBM VGA native format, the component + * data is probably 6 bits in size and needs to be scaled. */ + unsigned int palette[AVPALETTE_COUNT]; + +} AVPaletteControl attribute_deprecated; +#endif + +enum AVSubtitleType { + SUBTITLE_NONE, + + SUBTITLE_BITMAP, ///< A bitmap, pict will be set + + /** + * Plain text, the text field must be set by the decoder and is + * authoritative. ass and pict fields may contain approximations. + */ + SUBTITLE_TEXT, + + /** + * Formatted text, the ass field must be set by the decoder and is + * authoritative. pict and text fields may contain approximations. + */ + SUBTITLE_ASS, +}; + +typedef struct AVSubtitleRect { + int x; ///< top left corner of pict, undefined when pict is not set + int y; ///< top left corner of pict, undefined when pict is not set + int w; ///< width of pict, undefined when pict is not set + int h; ///< height of pict, undefined when pict is not set + int nb_colors; ///< number of colors in pict, undefined when pict is not set + + /** + * data+linesize for the bitmap of this subtitle. + * can be set for text/ass as well once they where rendered + */ + AVPicture pict; + enum AVSubtitleType type; + + char *text; ///< 0 terminated plain UTF-8 text + + /** + * 0 terminated ASS/SSA compatible event line. + * The pressentation of this is unaffected by the other values in this + * struct. + */ + char *ass; +} AVSubtitleRect; + +typedef struct AVSubtitle { + uint16_t format; /* 0 = graphics */ + uint32_t start_display_time; /* relative to packet pts, in ms */ + uint32_t end_display_time; /* relative to packet pts, in ms */ + unsigned num_rects; + AVSubtitleRect **rects; + int64_t pts; ///< Same as packet pts, in AV_TIME_BASE +} AVSubtitle; + +/* packet functions */ + +/** + * @deprecated use NULL instead + */ +attribute_deprecated void av_destruct_packet_nofree(AVPacket *pkt); + +/** + * Default packet destructor. + */ +void av_destruct_packet(AVPacket *pkt); + +/** + * Initialize optional fields of a packet with default values. + * + * @param pkt packet + */ +void av_init_packet(AVPacket *pkt); + +/** + * Allocate the payload of a packet and initialize its fields with + * default values. + * + * @param pkt packet + * @param size wanted payload size + * @return 0 if OK, AVERROR_xxx otherwise + */ +int av_new_packet(AVPacket *pkt, int size); + +/** + * Reduce packet size, correctly zeroing padding + * + * @param pkt packet + * @param size new size + */ +void av_shrink_packet(AVPacket *pkt, int size); + +/** + * @warning This is a hack - the packet memory allocation stuff is broken. The + * packet is allocated if it was not really allocated. + */ +int av_dup_packet(AVPacket *pkt); + +/** + * Free a packet. + * + * @param pkt packet to free + */ +void av_free_packet(AVPacket *pkt); + +/* resample.c */ + +struct ReSampleContext; +struct AVResampleContext; + +typedef struct ReSampleContext ReSampleContext; + +#if LIBAVCODEC_VERSION_MAJOR < 53 +/** + * @deprecated Use av_audio_resample_init() instead. + */ +attribute_deprecated ReSampleContext *audio_resample_init(int output_channels, int input_channels, + int output_rate, int input_rate); +#endif +/** + * Initialize audio resampling context + * + * @param output_channels number of output channels + * @param input_channels number of input channels + * @param output_rate output sample rate + * @param input_rate input sample rate + * @param sample_fmt_out requested output sample format + * @param sample_fmt_in input sample format + * @param filter_length length of each FIR filter in the filterbank relative to the cutoff freq + * @param log2_phase_count log2 of the number of entries in the polyphase filterbank + * @param linear If 1 then the used FIR filter will be linearly interpolated + between the 2 closest, if 0 the closest will be used + * @param cutoff cutoff frequency, 1.0 corresponds to half the output sampling rate + * @return allocated ReSampleContext, NULL if error occured + */ +ReSampleContext *av_audio_resample_init(int output_channels, int input_channels, + int output_rate, int input_rate, + enum SampleFormat sample_fmt_out, + enum SampleFormat sample_fmt_in, + int filter_length, int log2_phase_count, + int linear, double cutoff); + +int audio_resample(ReSampleContext *s, short *output, short *input, int nb_samples); +void audio_resample_close(ReSampleContext *s); + + +/** + * Initialize an audio resampler. + * Note, if either rate is not an integer then simply scale both rates up so they are. + * @param filter_length length of each FIR filter in the filterbank relative to the cutoff freq + * @param log2_phase_count log2 of the number of entries in the polyphase filterbank + * @param linear If 1 then the used FIR filter will be linearly interpolated + between the 2 closest, if 0 the closest will be used + * @param cutoff cutoff frequency, 1.0 corresponds to half the output sampling rate + */ +struct AVResampleContext *av_resample_init(int out_rate, int in_rate, int filter_length, int log2_phase_count, int linear, double cutoff); + +/** + * Resample an array of samples using a previously configured context. + * @param src an array of unconsumed samples + * @param consumed the number of samples of src which have been consumed are returned here + * @param src_size the number of unconsumed samples available + * @param dst_size the amount of space in samples available in dst + * @param update_ctx If this is 0 then the context will not be modified, that way several channels can be resampled with the same context. + * @return the number of samples written in dst or -1 if an error occurred + */ +int av_resample(struct AVResampleContext *c, short *dst, short *src, int *consumed, int src_size, int dst_size, int update_ctx); + + +/** + * Compensate samplerate/timestamp drift. The compensation is done by changing + * the resampler parameters, so no audible clicks or similar distortions occur + * @param compensation_distance distance in output samples over which the compensation should be performed + * @param sample_delta number of output samples which should be output less + * + * example: av_resample_compensate(c, 10, 500) + * here instead of 510 samples only 500 samples would be output + * + * note, due to rounding the actual compensation might be slightly different, + * especially if the compensation_distance is large and the in_rate used during init is small + */ +void av_resample_compensate(struct AVResampleContext *c, int sample_delta, int compensation_distance); +void av_resample_close(struct AVResampleContext *c); + +/** + * Allocate memory for a picture. Call avpicture_free to free it. + * + * @param picture the picture to be filled in + * @param pix_fmt the format of the picture + * @param width the width of the picture + * @param height the height of the picture + * @return zero if successful, a negative value if not + */ +int avpicture_alloc(AVPicture *picture, enum PixelFormat pix_fmt, int width, int height); + +/** + * Free a picture previously allocated by avpicture_alloc(). + * + * @param picture the AVPicture to be freed + */ +void avpicture_free(AVPicture *picture); + +/** + * Fill in the AVPicture fields. + * The fields of the given AVPicture are filled in by using the 'ptr' address + * which points to the image data buffer. Depending on the specified picture + * format, one or multiple image data pointers and line sizes will be set. + * If a planar format is specified, several pointers will be set pointing to + * the different picture planes and the line sizes of the different planes + * will be stored in the lines_sizes array. + * Call with ptr == NULL to get the required size for the ptr buffer. + * + * @param picture AVPicture whose fields are to be filled in + * @param ptr Buffer which will contain or contains the actual image data + * @param pix_fmt The format in which the picture data is stored. + * @param width the width of the image in pixels + * @param height the height of the image in pixels + * @return size of the image data in bytes + */ +int avpicture_fill(AVPicture *picture, uint8_t *ptr, + enum PixelFormat pix_fmt, int width, int height); +int avpicture_layout(const AVPicture* src, enum PixelFormat pix_fmt, int width, int height, + unsigned char *dest, int dest_size); + +/** + * Calculate the size in bytes that a picture of the given width and height + * would occupy if stored in the given picture format. + * Note that this returns the size of a compact representation as generated + * by avpicture_layout, which can be smaller than the size required for e.g. + * avpicture_fill. + * + * @param pix_fmt the given picture format + * @param width the width of the image + * @param height the height of the image + * @return Image data size in bytes or -1 on error (e.g. too large dimensions). + */ +int avpicture_get_size(enum PixelFormat pix_fmt, int width, int height); +void avcodec_get_chroma_sub_sample(enum PixelFormat pix_fmt, int *h_shift, int *v_shift); +const char *avcodec_get_pix_fmt_name(enum PixelFormat pix_fmt); +void avcodec_set_dimensions(AVCodecContext *s, int width, int height); + +#if LIBAVCODEC_VERSION_MAJOR < 53 +/** + * Return the pixel format corresponding to the name name. + * + * If there is no pixel format with name name, then look for a + * pixel format with the name corresponding to the native endian + * format of name. + * For example in a little-endian system, first look for "gray16", + * then for "gray16le". + * + * Finally if no pixel format has been found, return PIX_FMT_NONE. + * + * @deprecated Deprecated in favor of av_get_pix_fmt(). + */ +attribute_deprecated enum PixelFormat avcodec_get_pix_fmt(const char* name); +#endif + +/** + * Return a value representing the fourCC code associated to the + * pixel format pix_fmt, or 0 if no associated fourCC code can be + * found. + */ +unsigned int avcodec_pix_fmt_to_codec_tag(enum PixelFormat pix_fmt); + +/** + * Put a string representing the codec tag codec_tag in buf. + * + * @param buf_size size in bytes of buf + * @return the length of the string that would have been generated if + * enough space had been available, excluding the trailing null + */ +size_t av_get_codec_tag_string(char *buf, size_t buf_size, unsigned int codec_tag); + +#define FF_LOSS_RESOLUTION 0x0001 /**< loss due to resolution change */ +#define FF_LOSS_DEPTH 0x0002 /**< loss due to color depth change */ +#define FF_LOSS_COLORSPACE 0x0004 /**< loss due to color space conversion */ +#define FF_LOSS_ALPHA 0x0008 /**< loss of alpha bits */ +#define FF_LOSS_COLORQUANT 0x0010 /**< loss due to color quantization */ +#define FF_LOSS_CHROMA 0x0020 /**< loss of chroma (e.g. RGB to gray conversion) */ + +/** + * Compute what kind of losses will occur when converting from one specific + * pixel format to another. + * When converting from one pixel format to another, information loss may occur. + * For example, when converting from RGB24 to GRAY, the color information will + * be lost. Similarly, other losses occur when converting from some formats to + * other formats. These losses can involve loss of chroma, but also loss of + * resolution, loss of color depth, loss due to the color space conversion, loss + * of the alpha bits or loss due to color quantization. + * avcodec_get_fix_fmt_loss() informs you about the various types of losses + * which will occur when converting from one pixel format to another. + * + * @param[in] dst_pix_fmt destination pixel format + * @param[in] src_pix_fmt source pixel format + * @param[in] has_alpha Whether the source pixel format alpha channel is used. + * @return Combination of flags informing you what kind of losses will occur. + */ +int avcodec_get_pix_fmt_loss(enum PixelFormat dst_pix_fmt, enum PixelFormat src_pix_fmt, + int has_alpha); + +/** + * Find the best pixel format to convert to given a certain source pixel + * format. When converting from one pixel format to another, information loss + * may occur. For example, when converting from RGB24 to GRAY, the color + * information will be lost. Similarly, other losses occur when converting from + * some formats to other formats. avcodec_find_best_pix_fmt() searches which of + * the given pixel formats should be used to suffer the least amount of loss. + * The pixel formats from which it chooses one, are determined by the + * pix_fmt_mask parameter. + * + * @code + * src_pix_fmt = PIX_FMT_YUV420P; + * pix_fmt_mask = (1 << PIX_FMT_YUV422P) || (1 << PIX_FMT_RGB24); + * dst_pix_fmt = avcodec_find_best_pix_fmt(pix_fmt_mask, src_pix_fmt, alpha, &loss); + * @endcode + * + * @param[in] pix_fmt_mask bitmask determining which pixel format to choose from + * @param[in] src_pix_fmt source pixel format + * @param[in] has_alpha Whether the source pixel format alpha channel is used. + * @param[out] loss_ptr Combination of flags informing you what kind of losses will occur. + * @return The best pixel format to convert to or -1 if none was found. + */ +enum PixelFormat avcodec_find_best_pix_fmt(int64_t pix_fmt_mask, enum PixelFormat src_pix_fmt, + int has_alpha, int *loss_ptr); + + +/** + * Print in buf the string corresponding to the pixel format with + * number pix_fmt, or an header if pix_fmt is negative. + * + * @param[in] buf the buffer where to write the string + * @param[in] buf_size the size of buf + * @param[in] pix_fmt the number of the pixel format to print the corresponding info string, or + * a negative value to print the corresponding header. + * Meaningful values for obtaining a pixel format info vary from 0 to PIX_FMT_NB -1. + */ +void avcodec_pix_fmt_string (char *buf, int buf_size, enum PixelFormat pix_fmt); + +#define FF_ALPHA_TRANSP 0x0001 /* image has some totally transparent pixels */ +#define FF_ALPHA_SEMI_TRANSP 0x0002 /* image has some transparent pixels */ + +/** + * Tell if an image really has transparent alpha values. + * @return ored mask of FF_ALPHA_xxx constants + */ +int img_get_alpha_info(const AVPicture *src, + enum PixelFormat pix_fmt, int width, int height); + +/* deinterlace a picture */ +/* deinterlace - if not supported return -1 */ +int avpicture_deinterlace(AVPicture *dst, const AVPicture *src, + enum PixelFormat pix_fmt, int width, int height); + +/* external high level API */ + +/** + * If c is NULL, returns the first registered codec, + * if c is non-NULL, returns the next registered codec after c, + * or NULL if c is the last one. + */ +AVCodec *av_codec_next(AVCodec *c); + +/** + * Return the LIBAVCODEC_VERSION_INT constant. + */ +unsigned avcodec_version(void); + +/** + * Return the libavcodec build-time configuration. + */ +const char *avcodec_configuration(void); + +/** + * Return the libavcodec license. + */ +const char *avcodec_license(void); + +/** + * Initialize libavcodec. + * + * @warning This function must be called before any other libavcodec + * function. + */ +void avcodec_init(void); + +#if LIBAVCODEC_VERSION_MAJOR < 53 +/** + * @deprecated Deprecated in favor of avcodec_register(). + */ +attribute_deprecated void register_avcodec(AVCodec *codec); +#endif + +/** + * Register the codec codec and initialize libavcodec. + * + * @see avcodec_init() + */ +void avcodec_register(AVCodec *codec); + +/** + * Find a registered encoder with a matching codec ID. + * + * @param id CodecID of the requested encoder + * @return An encoder if one was found, NULL otherwise. + */ +AVCodec *avcodec_find_encoder(enum CodecID id); + +/** + * Find a registered encoder with the specified name. + * + * @param name name of the requested encoder + * @return An encoder if one was found, NULL otherwise. + */ +AVCodec *avcodec_find_encoder_by_name(const char *name); + +/** + * Find a registered decoder with a matching codec ID. + * + * @param id CodecID of the requested decoder + * @return A decoder if one was found, NULL otherwise. + */ +AVCodec *avcodec_find_decoder(enum CodecID id); + +/** + * Find a registered decoder with the specified name. + * + * @param name name of the requested decoder + * @return A decoder if one was found, NULL otherwise. + */ +AVCodec *avcodec_find_decoder_by_name(const char *name); +void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode); + +/** + * Set the fields of the given AVCodecContext to default values. + * + * @param s The AVCodecContext of which the fields should be set to default values. + */ +void avcodec_get_context_defaults(AVCodecContext *s); + +/** THIS FUNCTION IS NOT YET PART OF THE PUBLIC API! + * we WILL change its arguments and name a few times! */ +void avcodec_get_context_defaults2(AVCodecContext *s, enum AVMediaType); + +/** + * Allocate an AVCodecContext and set its fields to default values. The + * resulting struct can be deallocated by simply calling av_free(). + * + * @return An AVCodecContext filled with default values or NULL on failure. + * @see avcodec_get_context_defaults + */ +AVCodecContext *avcodec_alloc_context(void); + +/** THIS FUNCTION IS NOT YET PART OF THE PUBLIC API! + * we WILL change its arguments and name a few times! */ +AVCodecContext *avcodec_alloc_context2(enum AVMediaType); + +/** + * Copy the settings of the source AVCodecContext into the destination + * AVCodecContext. The resulting destination codec context will be + * unopened, i.e. you are required to call avcodec_open() before you + * can use this AVCodecContext to decode/encode video/audio data. + * + * @param dest target codec context, should be initialized with + * avcodec_alloc_context(), but otherwise uninitialized + * @param src source codec context + * @return AVERROR() on error (e.g. memory allocation error), 0 on success + */ +int avcodec_copy_context(AVCodecContext *dest, const AVCodecContext *src); + +/** + * Set the fields of the given AVFrame to default values. + * + * @param pic The AVFrame of which the fields should be set to default values. + */ +void avcodec_get_frame_defaults(AVFrame *pic); + +/** + * Allocate an AVFrame and set its fields to default values. The resulting + * struct can be deallocated by simply calling av_free(). + * + * @return An AVFrame filled with default values or NULL on failure. + * @see avcodec_get_frame_defaults + */ +AVFrame *avcodec_alloc_frame(void); + +int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic); +void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic); +int avcodec_default_reget_buffer(AVCodecContext *s, AVFrame *pic); + +/** + * Return the amount of padding in pixels which the get_buffer callback must + * provide around the edge of the image for codecs which do not have the + * CODEC_FLAG_EMU_EDGE flag. + * + * @return Required padding in pixels. + */ +unsigned avcodec_get_edge_width(void); +/** + * Modify width and height values so that they will result in a memory + * buffer that is acceptable for the codec if you do not use any horizontal + * padding. + * + * May only be used if a codec with CODEC_CAP_DR1 has been opened. + * If CODEC_FLAG_EMU_EDGE is not set, the dimensions must have been increased + * according to avcodec_get_edge_width() before. + */ +void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height); +/** + * Modify width and height values so that they will result in a memory + * buffer that is acceptable for the codec if you also ensure that all + * line sizes are a multiple of the respective linesize_align[i]. + * + * May only be used if a codec with CODEC_CAP_DR1 has been opened. + * If CODEC_FLAG_EMU_EDGE is not set, the dimensions must have been increased + * according to avcodec_get_edge_width() before. + */ +void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height, + int linesize_align[4]); + +#if LIBAVCODEC_VERSION_MAJOR < 53 +/** + * @deprecated Deprecated in favor of av_check_image_size(). + */ +attribute_deprecated +int avcodec_check_dimensions(void *av_log_ctx, unsigned int w, unsigned int h); +#endif + +enum PixelFormat avcodec_default_get_format(struct AVCodecContext *s, const enum PixelFormat * fmt); + +int avcodec_thread_init(AVCodecContext *s, int thread_count); +void avcodec_thread_free(AVCodecContext *s); +int avcodec_default_execute(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2),void *arg, int *ret, int count, int size); +int avcodec_default_execute2(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2, int, int),void *arg, int *ret, int count); +//FIXME func typedef + +/** + * Initialize the AVCodecContext to use the given AVCodec. Prior to using this + * function the context has to be allocated. + * + * The functions avcodec_find_decoder_by_name(), avcodec_find_encoder_by_name(), + * avcodec_find_decoder() and avcodec_find_encoder() provide an easy way for + * retrieving a codec. + * + * @warning This function is not thread safe! + * + * @code + * avcodec_register_all(); + * codec = avcodec_find_decoder(CODEC_ID_H264); + * if (!codec) + * exit(1); + * + * context = avcodec_alloc_context(); + * + * if (avcodec_open(context, codec) < 0) + * exit(1); + * @endcode + * + * @param avctx The context which will be set up to use the given codec. + * @param codec The codec to use within the context. + * @return zero on success, a negative value on error + * @see avcodec_alloc_context, avcodec_find_decoder, avcodec_find_encoder + */ +int avcodec_open(AVCodecContext *avctx, AVCodec *codec); + +#if LIBAVCODEC_VERSION_MAJOR < 53 +/** + * Decode an audio frame from buf into samples. + * Wrapper function which calls avcodec_decode_audio3. + * + * @deprecated Use avcodec_decode_audio3 instead. + * @param avctx the codec context + * @param[out] samples the output buffer + * @param[in,out] frame_size_ptr the output buffer size in bytes + * @param[in] buf the input buffer + * @param[in] buf_size the input buffer size in bytes + * @return On error a negative value is returned, otherwise the number of bytes + * used or zero if no frame could be decompressed. + */ +attribute_deprecated int avcodec_decode_audio2(AVCodecContext *avctx, int16_t *samples, + int *frame_size_ptr, + const uint8_t *buf, int buf_size); +#endif + +/** + * Decode the audio frame of size avpkt->size from avpkt->data into samples. + * Some decoders may support multiple frames in a single AVPacket, such + * decoders would then just decode the first frame. In this case, + * avcodec_decode_audio3 has to be called again with an AVPacket that contains + * the remaining data in order to decode the second frame etc. + * If no frame + * could be outputted, frame_size_ptr is zero. Otherwise, it is the + * decompressed frame size in bytes. + * + * @warning You must set frame_size_ptr to the allocated size of the + * output buffer before calling avcodec_decode_audio3(). + * + * @warning The input buffer must be FF_INPUT_BUFFER_PADDING_SIZE larger than + * the actual read bytes because some optimized bitstream readers read 32 or 64 + * bits at once and could read over the end. + * + * @warning The end of the input buffer avpkt->data should be set to 0 to ensure that + * no overreading happens for damaged MPEG streams. + * + * @note You might have to align the input buffer avpkt->data and output buffer + * samples. The alignment requirements depend on the CPU: On some CPUs it isn't + * necessary at all, on others it won't work at all if not aligned and on others + * it will work but it will have an impact on performance. + * + * In practice, avpkt->data should have 4 byte alignment at minimum and + * samples should be 16 byte aligned unless the CPU doesn't need it + * (AltiVec and SSE do). + * + * @param avctx the codec context + * @param[out] samples the output buffer, sample type in avctx->sample_fmt + * @param[in,out] frame_size_ptr the output buffer size in bytes + * @param[in] avpkt The input AVPacket containing the input buffer. + * You can create such packet with av_init_packet() and by then setting + * data and size, some decoders might in addition need other fields. + * All decoders are designed to use the least fields possible though. + * @return On error a negative value is returned, otherwise the number of bytes + * used or zero if no frame data was decompressed (used) from the input AVPacket. + */ +int avcodec_decode_audio3(AVCodecContext *avctx, int16_t *samples, + int *frame_size_ptr, + AVPacket *avpkt); + +#if LIBAVCODEC_VERSION_MAJOR < 53 +/** + * Decode a video frame from buf into picture. + * Wrapper function which calls avcodec_decode_video2. + * + * @deprecated Use avcodec_decode_video2 instead. + * @param avctx the codec context + * @param[out] picture The AVFrame in which the decoded video frame will be stored. + * @param[in] buf the input buffer + * @param[in] buf_size the size of the input buffer in bytes + * @param[in,out] got_picture_ptr Zero if no frame could be decompressed, otherwise, it is nonzero. + * @return On error a negative value is returned, otherwise the number of bytes + * used or zero if no frame could be decompressed. + */ +attribute_deprecated int avcodec_decode_video(AVCodecContext *avctx, AVFrame *picture, + int *got_picture_ptr, + const uint8_t *buf, int buf_size); +#endif + +/** + * Decode the video frame of size avpkt->size from avpkt->data into picture. + * Some decoders may support multiple frames in a single AVPacket, such + * decoders would then just decode the first frame. + * + * @warning The input buffer must be FF_INPUT_BUFFER_PADDING_SIZE larger than + * the actual read bytes because some optimized bitstream readers read 32 or 64 + * bits at once and could read over the end. + * + * @warning The end of the input buffer buf should be set to 0 to ensure that + * no overreading happens for damaged MPEG streams. + * + * @note You might have to align the input buffer avpkt->data. + * The alignment requirements depend on the CPU: on some CPUs it isn't + * necessary at all, on others it won't work at all if not aligned and on others + * it will work but it will have an impact on performance. + * + * In practice, avpkt->data should have 4 byte alignment at minimum. + * + * @note Some codecs have a delay between input and output, these need to be + * fed with avpkt->data=NULL, avpkt->size=0 at the end to return the remaining frames. + * + * @param avctx the codec context + * @param[out] picture The AVFrame in which the decoded video frame will be stored. + * Use avcodec_alloc_frame to get an AVFrame, the codec will + * allocate memory for the actual bitmap. + * with default get/release_buffer(), the decoder frees/reuses the bitmap as it sees fit. + * with overridden get/release_buffer() (needs CODEC_CAP_DR1) the user decides into what buffer the decoder + * decodes and the decoder tells the user once it does not need the data anymore, + * the user app can at this point free/reuse/keep the memory as it sees fit. + * + * @param[in] avpkt The input AVpacket containing the input buffer. + * You can create such packet with av_init_packet() and by then setting + * data and size, some decoders might in addition need other fields like + * flags&AV_PKT_FLAG_KEY. All decoders are designed to use the least + * fields possible. + * @param[in,out] got_picture_ptr Zero if no frame could be decompressed, otherwise, it is nonzero. + * @return On error a negative value is returned, otherwise the number of bytes + * used or zero if no frame could be decompressed. + */ +int avcodec_decode_video2(AVCodecContext *avctx, AVFrame *picture, + int *got_picture_ptr, + AVPacket *avpkt); + +#if LIBAVCODEC_VERSION_MAJOR < 53 +/* Decode a subtitle message. Return -1 if error, otherwise return the + * number of bytes used. If no subtitle could be decompressed, + * got_sub_ptr is zero. Otherwise, the subtitle is stored in *sub. */ +attribute_deprecated int avcodec_decode_subtitle(AVCodecContext *avctx, AVSubtitle *sub, + int *got_sub_ptr, + const uint8_t *buf, int buf_size); +#endif + +/** + * Decode a subtitle message. + * Return a negative value on error, otherwise return the number of bytes used. + * If no subtitle could be decompressed, got_sub_ptr is zero. + * Otherwise, the subtitle is stored in *sub. + * Note that CODEC_CAP_DR1 is not available for subtitle codecs. This is for + * simplicity, because the performance difference is expect to be negligible + * and reusing a get_buffer written for video codecs would probably perform badly + * due to a potentially very different allocation pattern. + * + * @param avctx the codec context + * @param[out] sub The AVSubtitle in which the decoded subtitle will be stored, must be + freed with avsubtitle_free if *got_sub_ptr is set. + * @param[in,out] got_sub_ptr Zero if no subtitle could be decompressed, otherwise, it is nonzero. + * @param[in] avpkt The input AVPacket containing the input buffer. + */ +int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub, + int *got_sub_ptr, + AVPacket *avpkt); + +/** + * Frees all allocated data in the given subtitle struct. + * + * @param sub AVSubtitle to free. + */ +void avsubtitle_free(AVSubtitle *sub); + +int avcodec_parse_frame(AVCodecContext *avctx, uint8_t **pdata, + int *data_size_ptr, + uint8_t *buf, int buf_size); + +/** + * Encode an audio frame from samples into buf. + * + * @note The output buffer should be at least FF_MIN_BUFFER_SIZE bytes large. + * However, for PCM audio the user will know how much space is needed + * because it depends on the value passed in buf_size as described + * below. In that case a lower value can be used. + * + * @param avctx the codec context + * @param[out] buf the output buffer + * @param[in] buf_size the output buffer size + * @param[in] samples the input buffer containing the samples + * The number of samples read from this buffer is frame_size*channels, + * both of which are defined in avctx. + * For PCM audio the number of samples read from samples is equal to + * buf_size * input_sample_size / output_sample_size. + * @return On error a negative value is returned, on success zero or the number + * of bytes used to encode the data read from the input buffer. + */ +int avcodec_encode_audio(AVCodecContext *avctx, uint8_t *buf, int buf_size, + const short *samples); + +/** + * Encode a video frame from pict into buf. + * The input picture should be + * stored using a specific format, namely avctx.pix_fmt. + * + * @param avctx the codec context + * @param[out] buf the output buffer for the bitstream of encoded frame + * @param[in] buf_size the size of the output buffer in bytes + * @param[in] pict the input picture to encode + * @return On error a negative value is returned, on success zero or the number + * of bytes used from the output buffer. + */ +int avcodec_encode_video(AVCodecContext *avctx, uint8_t *buf, int buf_size, + const AVFrame *pict); +int avcodec_encode_subtitle(AVCodecContext *avctx, uint8_t *buf, int buf_size, + const AVSubtitle *sub); + +int avcodec_close(AVCodecContext *avctx); + +/** + * Register all the codecs, parsers and bitstream filters which were enabled at + * configuration time. If you do not call this function you can select exactly + * which formats you want to support, by using the individual registration + * functions. + * + * @see avcodec_register + * @see av_register_codec_parser + * @see av_register_bitstream_filter + */ +void avcodec_register_all(void); + +/** + * Flush buffers, should be called when seeking or when switching to a different stream. + */ +void avcodec_flush_buffers(AVCodecContext *avctx); + +void avcodec_default_free_buffers(AVCodecContext *s); + +/* misc useful functions */ + +/** + * Return a single letter to describe the given picture type pict_type. + * + * @param[in] pict_type the picture type + * @return A single character representing the picture type. + */ +char av_get_pict_type_char(int pict_type); + +/** + * Return codec bits per sample. + * + * @param[in] codec_id the codec + * @return Number of bits per sample or zero if unknown for the given codec. + */ +int av_get_bits_per_sample(enum CodecID codec_id); + +/** + * Return sample format bits per sample. + * + * @param[in] sample_fmt the sample format + * @return Number of bits per sample or zero if unknown for the given sample format. + */ +int av_get_bits_per_sample_format(enum SampleFormat sample_fmt); + +/* frame parsing */ +typedef struct AVCodecParserContext { + void *priv_data; + struct AVCodecParser *parser; + int64_t frame_offset; /* offset of the current frame */ + int64_t cur_offset; /* current offset + (incremented by each av_parser_parse()) */ + int64_t next_frame_offset; /* offset of the next frame */ + /* video info */ + int pict_type; /* XXX: Put it back in AVCodecContext. */ + /** + * This field is used for proper frame duration computation in lavf. + * It signals, how much longer the frame duration of the current frame + * is compared to normal frame duration. + * + * frame_duration = (1 + repeat_pict) * time_base + * + * It is used by codecs like H.264 to display telecined material. + */ + int repeat_pict; /* XXX: Put it back in AVCodecContext. */ + int64_t pts; /* pts of the current frame */ + int64_t dts; /* dts of the current frame */ + + /* private data */ + int64_t last_pts; + int64_t last_dts; + int fetch_timestamp; + +#define AV_PARSER_PTS_NB 4 + int cur_frame_start_index; + int64_t cur_frame_offset[AV_PARSER_PTS_NB]; + int64_t cur_frame_pts[AV_PARSER_PTS_NB]; + int64_t cur_frame_dts[AV_PARSER_PTS_NB]; + + int flags; +#define PARSER_FLAG_COMPLETE_FRAMES 0x0001 +#define PARSER_FLAG_ONCE 0x0002 + + int64_t offset; ///< byte offset from starting packet start + int64_t cur_frame_end[AV_PARSER_PTS_NB]; + + /*! + * Set by parser to 1 for key frames and 0 for non-key frames. + * It is initialized to -1, so if the parser doesn't set this flag, + * old-style fallback using FF_I_TYPE picture type as key frames + * will be used. + */ + int key_frame; + + /** + * Time difference in stream time base units from the pts of this + * packet to the point at which the output from the decoder has converged + * independent from the availability of previous frames. That is, the + * frames are virtually identical no matter if decoding started from + * the very first frame or from this keyframe. + * Is AV_NOPTS_VALUE if unknown. + * This field is not the display duration of the current frame. + * This field has no meaning if the packet does not have AV_PKT_FLAG_KEY + * set. + * + * The purpose of this field is to allow seeking in streams that have no + * keyframes in the conventional sense. It corresponds to the + * recovery point SEI in H.264 and match_time_delta in NUT. It is also + * essential for some types of subtitle streams to ensure that all + * subtitles are correctly displayed after seeking. + */ + int64_t convergence_duration; + + // Timestamp generation support: + /** + * Synchronization point for start of timestamp generation. + * + * Set to >0 for sync point, 0 for no sync point and <0 for undefined + * (default). + * + * For example, this corresponds to presence of H.264 buffering period + * SEI message. + */ + int dts_sync_point; + + /** + * Offset of the current timestamp against last timestamp sync point in + * units of AVCodecContext.time_base. + * + * Set to INT_MIN when dts_sync_point unused. Otherwise, it must + * contain a valid timestamp offset. + * + * Note that the timestamp of sync point has usually a nonzero + * dts_ref_dts_delta, which refers to the previous sync point. Offset of + * the next frame after timestamp sync point will be usually 1. + * + * For example, this corresponds to H.264 cpb_removal_delay. + */ + int dts_ref_dts_delta; + + /** + * Presentation delay of current frame in units of AVCodecContext.time_base. + * + * Set to INT_MIN when dts_sync_point unused. Otherwise, it must + * contain valid non-negative timestamp delta (presentation time of a frame + * must not lie in the past). + * + * This delay represents the difference between decoding and presentation + * time of the frame. + * + * For example, this corresponds to H.264 dpb_output_delay. + */ + int pts_dts_delta; + + /** + * Position of the packet in file. + * + * Analogous to cur_frame_pts/dts + */ + int64_t cur_frame_pos[AV_PARSER_PTS_NB]; + + /** + * Byte position of currently parsed frame in stream. + */ + int64_t pos; + + /** + * Previous frame byte position. + */ + int64_t last_pos; +} AVCodecParserContext; + +typedef struct AVCodecParser { + int codec_ids[5]; /* several codec IDs are permitted */ + int priv_data_size; + int (*parser_init)(AVCodecParserContext *s); + int (*parser_parse)(AVCodecParserContext *s, + AVCodecContext *avctx, + const uint8_t **poutbuf, int *poutbuf_size, + const uint8_t *buf, int buf_size); + void (*parser_close)(AVCodecParserContext *s); + int (*split)(AVCodecContext *avctx, const uint8_t *buf, int buf_size); + struct AVCodecParser *next; +} AVCodecParser; + +AVCodecParser *av_parser_next(AVCodecParser *c); + +void av_register_codec_parser(AVCodecParser *parser); +AVCodecParserContext *av_parser_init(int codec_id); + +#if LIBAVCODEC_VERSION_MAJOR < 53 +attribute_deprecated +int av_parser_parse(AVCodecParserContext *s, + AVCodecContext *avctx, + uint8_t **poutbuf, int *poutbuf_size, + const uint8_t *buf, int buf_size, + int64_t pts, int64_t dts); +#endif + +/** + * Parse a packet. + * + * @param s parser context. + * @param avctx codec context. + * @param poutbuf set to pointer to parsed buffer or NULL if not yet finished. + * @param poutbuf_size set to size of parsed buffer or zero if not yet finished. + * @param buf input buffer. + * @param buf_size input length, to signal EOF, this should be 0 (so that the last frame can be output). + * @param pts input presentation timestamp. + * @param dts input decoding timestamp. + * @param pos input byte position in stream. + * @return the number of bytes of the input bitstream used. + * + * Example: + * @code + * while(in_len){ + * len = av_parser_parse2(myparser, AVCodecContext, &data, &size, + * in_data, in_len, + * pts, dts, pos); + * in_data += len; + * in_len -= len; + * + * if(size) + * decode_frame(data, size); + * } + * @endcode + */ +int av_parser_parse2(AVCodecParserContext *s, + AVCodecContext *avctx, + uint8_t **poutbuf, int *poutbuf_size, + const uint8_t *buf, int buf_size, + int64_t pts, int64_t dts, + int64_t pos); + +int av_parser_change(AVCodecParserContext *s, + AVCodecContext *avctx, + uint8_t **poutbuf, int *poutbuf_size, + const uint8_t *buf, int buf_size, int keyframe); +void av_parser_close(AVCodecParserContext *s); + + +typedef struct AVBitStreamFilterContext { + void *priv_data; + struct AVBitStreamFilter *filter; + AVCodecParserContext *parser; + struct AVBitStreamFilterContext *next; +} AVBitStreamFilterContext; + + +typedef struct AVBitStreamFilter { + const char *name; + int priv_data_size; + int (*filter)(AVBitStreamFilterContext *bsfc, + AVCodecContext *avctx, const char *args, + uint8_t **poutbuf, int *poutbuf_size, + const uint8_t *buf, int buf_size, int keyframe); + void (*close)(AVBitStreamFilterContext *bsfc); + struct AVBitStreamFilter *next; +} AVBitStreamFilter; + +void av_register_bitstream_filter(AVBitStreamFilter *bsf); +AVBitStreamFilterContext *av_bitstream_filter_init(const char *name); +int av_bitstream_filter_filter(AVBitStreamFilterContext *bsfc, + AVCodecContext *avctx, const char *args, + uint8_t **poutbuf, int *poutbuf_size, + const uint8_t *buf, int buf_size, int keyframe); +void av_bitstream_filter_close(AVBitStreamFilterContext *bsf); + +AVBitStreamFilter *av_bitstream_filter_next(AVBitStreamFilter *f); + +/* memory */ + +/** + * Reallocate the given block if it is not large enough, otherwise do nothing. + * + * @see av_realloc + */ +void *av_fast_realloc(void *ptr, unsigned int *size, unsigned int min_size); + +/** + * Allocate a buffer, reusing the given one if large enough. + * + * Contrary to av_fast_realloc the current buffer contents might not be + * preserved and on error the old buffer is freed, thus no special + * handling to avoid memleaks is necessary. + * + * @param ptr pointer to pointer to already allocated buffer, overwritten with pointer to new buffer + * @param size size of the buffer *ptr points to + * @param min_size minimum size of *ptr buffer after returning, *ptr will be NULL and + * *size 0 if an error occurred. + */ +void av_fast_malloc(void *ptr, unsigned int *size, unsigned int min_size); + +/** + * Copy image 'src' to 'dst'. + */ +void av_picture_copy(AVPicture *dst, const AVPicture *src, + enum PixelFormat pix_fmt, int width, int height); + +/** + * Crop image top and left side. + */ +int av_picture_crop(AVPicture *dst, const AVPicture *src, + enum PixelFormat pix_fmt, int top_band, int left_band); + +/** + * Pad image. + */ +int av_picture_pad(AVPicture *dst, const AVPicture *src, int height, int width, enum PixelFormat pix_fmt, + int padtop, int padbottom, int padleft, int padright, int *color); + +/** + * Encode extradata length to a buffer. Used by xiph codecs. + * + * @param s buffer to write to; must be at least (v/255+1) bytes long + * @param v size of extradata in bytes + * @return number of bytes written to the buffer. + */ +unsigned int av_xiphlacing(unsigned char *s, unsigned int v); + +#if LIBAVCODEC_VERSION_MAJOR < 53 +/** + * Parse str and put in width_ptr and height_ptr the detected values. + * + * @deprecated Deprecated in favor of av_parse_video_size(). + */ +attribute_deprecated int av_parse_video_frame_size(int *width_ptr, int *height_ptr, const char *str); + +/** + * Parse str and store the detected values in *frame_rate. + * + * @deprecated Deprecated in favor of av_parse_video_rate(). + */ +//attribute_deprecated int av_parse_video_frame_rate(AVRational *frame_rate, const char *str); +#endif + +/** + * Logs a generic warning message about a missing feature. This function is + * intended to be used internally by FFmpeg (libavcodec, libavformat, etc.) + * only, and would normally not be used by applications. + * @param[in] avc a pointer to an arbitrary struct of which the first field is + * a pointer to an AVClass struct + * @param[in] feature string containing the name of the missing feature + * @param[in] want_sample indicates if samples are wanted which exhibit this feature. + * If want_sample is non-zero, additional verbage will be added to the log + * message which tells the user how to report samples to the development + * mailing list. + */ +void av_log_missing_feature(void *avc, const char *feature, int want_sample); + +/** + * Log a generic warning message asking for a sample. This function is + * intended to be used internally by FFmpeg (libavcodec, libavformat, etc.) + * only, and would normally not be used by applications. + * @param[in] avc a pointer to an arbitrary struct of which the first field is + * a pointer to an AVClass struct + * @param[in] msg string containing an optional message, or NULL if no message + */ +void av_log_ask_for_sample(void *avc, const char *msg); + +/** + * Register the hardware accelerator hwaccel. + */ +void av_register_hwaccel(AVHWAccel *hwaccel); + +/** + * If hwaccel is NULL, returns the first registered hardware accelerator, + * if hwaccel is non-NULL, returns the next registered hardware accelerator + * after hwaccel, or NULL if hwaccel is the last one. + */ +AVHWAccel *av_hwaccel_next(AVHWAccel *hwaccel); + + +/** + * Lock operation used by lockmgr + */ +enum AVLockOp { + AV_LOCK_CREATE, ///< Create a mutex + AV_LOCK_OBTAIN, ///< Lock the mutex + AV_LOCK_RELEASE, ///< Unlock the mutex + AV_LOCK_DESTROY, ///< Free mutex resources +}; + +/** + * Register a user provided lock manager supporting the operations + * specified by AVLockOp. mutex points to a (void *) where the + * lockmgr should store/get a pointer to a user allocated mutex. It's + * NULL upon AV_LOCK_CREATE and != NULL for all other ops. + * + * @param cb User defined callback. Note: FFmpeg may invoke calls to this + * callback during the call to av_lockmgr_register(). + * Thus, the application must be prepared to handle that. + * If cb is set to NULL the lockmgr will be unregistered. + * Also note that during unregistration the previously registered + * lockmgr callback may also be invoked. + */ +int av_lockmgr_register(int (*cb)(void **mutex, enum AVLockOp op)); + +#endif /* AVCODEC_AVCODEC_H */ diff --git a/lib/rbcodec/codecs/libwmavoice/avfft.c b/lib/rbcodec/codecs/libwmavoice/avfft.c new file mode 100644 index 0000000000..7d5d08390f --- /dev/null +++ b/lib/rbcodec/codecs/libwmavoice/avfft.c @@ -0,0 +1,142 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "libavutil/mem.h" +#include "avfft.h" +#include "fft.h" + +/* FFT */ + +FFTContext *av_fft_init(int nbits, int inverse) +{ + FFTContext *s = av_malloc(sizeof(*s)); + + if (s && ff_fft_init(s, nbits, inverse)) + av_freep(&s); + + return s; +} + +void av_fft_permute(FFTContext *s, FFTComplex *z) +{ + s->fft_permute(s, z); +} + +void av_fft_calc(FFTContext *s, FFTComplex *z) +{ + s->fft_calc(s, z); +} + +void av_fft_end(FFTContext *s) +{ + if (s) { + ff_fft_end(s); + av_free(s); + } +} + +#if CONFIG_MDCT + +FFTContext *av_mdct_init(int nbits, int inverse, double scale) +{ + FFTContext *s = av_malloc(sizeof(*s)); + + if (s && ff_mdct_init(s, nbits, inverse, scale)) + av_freep(&s); + + return s; +} + +void av_imdct_calc(FFTContext *s, FFTSample *output, const FFTSample *input) +{ + s->imdct_calc(s, output, input); +} + +void av_imdct_half(FFTContext *s, FFTSample *output, const FFTSample *input) +{ + s->imdct_half(s, output, input); +} + +void av_mdct_calc(FFTContext *s, FFTSample *output, const FFTSample *input) +{ + s->mdct_calc(s, output, input); +} + +void av_mdct_end(FFTContext *s) +{ + if (s) { + ff_mdct_end(s); + av_free(s); + } +} + +#endif /* CONFIG_MDCT */ + +#if CONFIG_RDFT + +RDFTContext *av_rdft_init(int nbits, enum RDFTransformType trans) +{ + RDFTContext *s = av_malloc(sizeof(*s)); + + if (s && ff_rdft_init(s, nbits, trans)) + av_freep(&s); + + return s; +} + +void av_rdft_calc(RDFTContext *s, FFTSample *data) +{ + ff_rdft_calc(s, data); +} + +void av_rdft_end(RDFTContext *s) +{ + if (s) { + ff_rdft_end(s); + av_free(s); + } +} + +#endif /* CONFIG_RDFT */ + +#if CONFIG_DCT + +DCTContext *av_dct_init(int nbits, enum DCTTransformType inverse) +{ + DCTContext *s = av_malloc(sizeof(*s)); + + if (s && ff_dct_init(s, nbits, inverse)) + av_freep(&s); + + return s; +} + +void av_dct_calc(DCTContext *s, FFTSample *data) +{ + ff_dct_calc(s, data); +} + +void av_dct_end(DCTContext *s) +{ + if (s) { + ff_dct_end(s); + av_free(s); + } +} + +#endif /* CONFIG_DCT */ diff --git a/lib/rbcodec/codecs/libwmavoice/avfft.h b/lib/rbcodec/codecs/libwmavoice/avfft.h new file mode 100644 index 0000000000..be2d9c7e10 --- /dev/null +++ b/lib/rbcodec/codecs/libwmavoice/avfft.h @@ -0,0 +1,99 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVCODEC_AVFFT_H +#define AVCODEC_AVFFT_H + +typedef float FFTSample; + +typedef struct FFTComplex { + FFTSample re, im; +} FFTComplex; + +typedef struct FFTContext FFTContext; + +/** + * Set up a complex FFT. + * @param nbits log2 of the length of the input array + * @param inverse if 0 perform the forward transform, if 1 perform the inverse + */ +FFTContext *av_fft_init(int nbits, int inverse); + +/** + * Do the permutation needed BEFORE calling ff_fft_calc(). + */ +void av_fft_permute(FFTContext *s, FFTComplex *z); + +/** + * Do a complex FFT with the parameters defined in av_fft_init(). The + * input data must be permuted before. No 1.0/sqrt(n) normalization is done. + */ +void av_fft_calc(FFTContext *s, FFTComplex *z); + +void av_fft_end(FFTContext *s); + +FFTContext *av_mdct_init(int nbits, int inverse, double scale); +void av_imdct_calc(FFTContext *s, FFTSample *output, const FFTSample *input); +void av_imdct_half(FFTContext *s, FFTSample *output, const FFTSample *input); +void av_mdct_calc(FFTContext *s, FFTSample *output, const FFTSample *input); +void av_mdct_end(FFTContext *s); + +/* Real Discrete Fourier Transform */ + +enum RDFTransformType { + DFT_R2C, + IDFT_C2R, + IDFT_R2C, + DFT_C2R, +}; + +typedef struct RDFTContext RDFTContext; + +/** + * Set up a real FFT. + * @param nbits log2 of the length of the input array + * @param trans the type of transform + */ +RDFTContext *av_rdft_init(int nbits, enum RDFTransformType trans); +void av_rdft_calc(RDFTContext *s, FFTSample *data); +void av_rdft_end(RDFTContext *s); + +/* Discrete Cosine Transform */ + +typedef struct DCTContext DCTContext; + +enum DCTTransformType { + DCT_II = 0, + DCT_III, + DCT_I, + DST_I, +}; + +/** + * Set up DCT. + * @param nbits size of the input array: + * (1 << nbits) for DCT-II, DCT-III and DST-I + * (1 << nbits) + 1 for DCT-I + * + * @note the first element of the input of DST-I is ignored + */ +DCTContext *av_dct_init(int nbits, enum DCTTransformType type); +void av_dct_calc(DCTContext *s, FFTSample *data); +void av_dct_end (DCTContext *s); + +#endif /* AVCODEC_AVFFT_H */ diff --git a/lib/rbcodec/codecs/libwmavoice/bitstream.c b/lib/rbcodec/codecs/libwmavoice/bitstream.c new file mode 100644 index 0000000000..d408f66650 --- /dev/null +++ b/lib/rbcodec/codecs/libwmavoice/bitstream.c @@ -0,0 +1,341 @@ +/* + * Common bit i/o utils + * Copyright (c) 2000, 2001 Fabrice Bellard + * Copyright (c) 2002-2004 Michael Niedermayer + * Copyright (c) 2010 Loren Merritt + * + * alternative bitstream reader & writer by Michael Niedermayer + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * bitstream api. + */ + +#include "avcodec.h" +#include "get_bits.h" +#include "put_bits.h" + +const uint8_t ff_log2_run[32]={ + 0, 0, 0, 0, 1, 1, 1, 1, + 2, 2, 2, 2, 3, 3, 3, 3, + 4, 4, 5, 5, 6, 6, 7, 7, + 8, 9,10,11,12,13,14,15 +}; + +void align_put_bits(PutBitContext *s) +{ +#ifdef ALT_BITSTREAM_WRITER + put_bits(s,( - s->index) & 7,0); +#else + put_bits(s,s->bit_left & 7,0); +#endif +} + +void ff_put_string(PutBitContext *pb, const char *string, int terminate_string) +{ + while(*string){ + put_bits(pb, 8, *string); + string++; + } + if(terminate_string) + put_bits(pb, 8, 0); +} + +void ff_copy_bits(PutBitContext *pb, const uint8_t *src, int length) +{ + int words= length>>4; + int bits= length&15; + int i; + + if(length==0) return; + + if(/*CONFIG_SMALL ||*/ words < 16 || put_bits_count(pb)&7){ + for(i=0; i>(16-bits)); +} + +/* VLC decoding */ + +//#define DEBUG_VLC + +#define GET_DATA(v, table, i, wrap, size) \ +{\ + const uint8_t *ptr = (const uint8_t *)table + i * wrap;\ + switch(size) {\ + case 1:\ + v = *(const uint8_t *)ptr;\ + break;\ + case 2:\ + v = *(const uint16_t *)ptr;\ + break;\ + default:\ + v = *(const uint32_t *)ptr;\ + break;\ + }\ +} + + +static int alloc_table(VLC *vlc, int size, int use_static) +{ + int index; + index = vlc->table_size; + vlc->table_size += size; + if (vlc->table_size > vlc->table_allocated) { + if(use_static) + abort(); //cant do anything, init_vlc() is used with too little memory + vlc->table_allocated += (1 << vlc->bits); + vlc->table = av_realloc(vlc->table, + sizeof(VLC_TYPE) * 2 * vlc->table_allocated); + if (!vlc->table) + return -1; + } + return index; +} + +static av_always_inline uint32_t bitswap_32(uint32_t x) { + return av_reverse[x&0xFF]<<24 + | av_reverse[(x>>8)&0xFF]<<16 + | av_reverse[(x>>16)&0xFF]<<8 + | av_reverse[x>>24]; +} + +typedef struct { + uint8_t bits; + uint16_t symbol; + /** codeword, with the first bit-to-be-read in the msb + * (even if intended for a little-endian bitstream reader) */ + uint32_t code; +} VLCcode; + +static int compare_vlcspec(const void *a, const void *b) +{ + const VLCcode *sa=a, *sb=b; + return (sa->code >> 1) - (sb->code >> 1); +} + +/** + * Build VLC decoding tables suitable for use with get_vlc(). + * + * @param vlc the context to be initted + * + * @param table_nb_bits max length of vlc codes to store directly in this table + * (Longer codes are delegated to subtables.) + * + * @param nb_codes number of elements in codes[] + * + * @param codes descriptions of the vlc codes + * These must be ordered such that codes going into the same subtable are contiguous. + * Sorting by VLCcode.code is sufficient, though not necessary. + */ +static int build_table(VLC *vlc, int table_nb_bits, int nb_codes, + VLCcode *codes, int flags) +{ + int table_size, table_index, index, code_prefix, symbol, subtable_bits; + int i, j, k, n, nb, inc; + uint32_t code; + VLC_TYPE (*table)[2]; + + table_size = 1 << table_nb_bits; + table_index = alloc_table(vlc, table_size, flags & INIT_VLC_USE_NEW_STATIC); +#ifdef DEBUG_VLC + av_log(NULL,AV_LOG_DEBUG,"new table index=%d size=%d\n", + table_index, table_size); +#endif + if (table_index < 0) + return -1; + table = &vlc->table[table_index]; + + for (i = 0; i < table_size; i++) { + table[i][1] = 0; //bits + table[i][0] = -1; //codes + } + + /* first pass: map codes and compute auxillary table sizes */ + for (i = 0; i < nb_codes; i++) { + n = codes[i].bits; + code = codes[i].code; + symbol = codes[i].symbol; +#if defined(DEBUG_VLC) && 0 + av_log(NULL,AV_LOG_DEBUG,"i=%d n=%d code=0x%x\n", i, n, code); +#endif + if (n <= table_nb_bits) { + /* no need to add another table */ + j = code >> (32 - table_nb_bits); + nb = 1 << (table_nb_bits - n); + inc = 1; + if (flags & INIT_VLC_LE) { + j = bitswap_32(code); + inc = 1 << n; + } + for (k = 0; k < nb; k++) { +#ifdef DEBUG_VLC + av_log(NULL, AV_LOG_DEBUG, "%4x: code=%d n=%d\n", + j, i, n); +#endif + if (table[j][1] /*bits*/ != 0) { + av_log(NULL, AV_LOG_ERROR, "incorrect codes\n"); + return -1; + } + table[j][1] = n; //bits + table[j][0] = symbol; + j += inc; + } + } else { + /* fill auxiliary table recursively */ + n -= table_nb_bits; + code_prefix = code >> (32 - table_nb_bits); + subtable_bits = n; + codes[i].bits = n; + codes[i].code = code << table_nb_bits; + for (k = i+1; k < nb_codes; k++) { + n = codes[k].bits - table_nb_bits; + if (n <= 0) + break; + code = codes[k].code; + if (code >> (32 - table_nb_bits) != code_prefix) + break; + codes[k].bits = n; + codes[k].code = code << table_nb_bits; + subtable_bits = FFMAX(subtable_bits, n); + } + subtable_bits = FFMIN(subtable_bits, table_nb_bits); + j = (flags & INIT_VLC_LE) ? bitswap_32(code_prefix) >> (32 - table_nb_bits) : code_prefix; + table[j][1] = -subtable_bits; +#ifdef DEBUG_VLC + av_log(NULL,AV_LOG_DEBUG,"%4x: n=%d (subtable)\n", + j, codes[i].bits + table_nb_bits); +#endif + index = build_table(vlc, subtable_bits, k-i, codes+i, flags); + if (index < 0) + return -1; + /* note: realloc has been done, so reload tables */ + table = &vlc->table[table_index]; + table[j][0] = index; //code + i = k-1; + } + } + return table_index; +} + + +/* Build VLC decoding tables suitable for use with get_vlc(). + + 'nb_bits' set thee decoding table size (2^nb_bits) entries. The + bigger it is, the faster is the decoding. But it should not be too + big to save memory and L1 cache. '9' is a good compromise. + + 'nb_codes' : number of vlcs codes + + 'bits' : table which gives the size (in bits) of each vlc code. + + 'codes' : table which gives the bit pattern of of each vlc code. + + 'symbols' : table which gives the values to be returned from get_vlc(). + + 'xxx_wrap' : give the number of bytes between each entry of the + 'bits' or 'codes' tables. + + 'xxx_size' : gives the number of bytes of each entry of the 'bits' + or 'codes' tables. + + 'wrap' and 'size' allows to use any memory configuration and types + (byte/word/long) to store the 'bits', 'codes', and 'symbols' tables. + + 'use_static' should be set to 1 for tables, which should be freed + with av_free_static(), 0 if free_vlc() will be used. +*/ +int init_vlc_sparse(VLC *vlc, int nb_bits, int nb_codes, + const void *bits, int bits_wrap, int bits_size, + const void *codes, int codes_wrap, int codes_size, + const void *symbols, int symbols_wrap, int symbols_size, + int flags) +{ + VLCcode *buf; + int i, j, ret; + + vlc->bits = nb_bits; + if(flags & INIT_VLC_USE_NEW_STATIC){ + if(vlc->table_size && vlc->table_size == vlc->table_allocated){ + return 0; + }else if(vlc->table_size){ + abort(); // fatal error, we are called on a partially initialized table + } + }else { + vlc->table = NULL; + vlc->table_allocated = 0; + vlc->table_size = 0; + } + +#ifdef DEBUG_VLC + av_log(NULL,AV_LOG_DEBUG,"build table nb_codes=%d\n", nb_codes); +#endif + + buf = av_malloc((nb_codes+1)*sizeof(VLCcode)); + + assert(symbols_size <= 2 || !symbols); + j = 0; +#define COPY(condition)\ + for (i = 0; i < nb_codes; i++) {\ + GET_DATA(buf[j].bits, bits, i, bits_wrap, bits_size);\ + if (!(condition))\ + continue;\ + GET_DATA(buf[j].code, codes, i, codes_wrap, codes_size);\ + if (flags & INIT_VLC_LE)\ + buf[j].code = bitswap_32(buf[j].code);\ + else\ + buf[j].code <<= 32 - buf[j].bits;\ + if (symbols)\ + GET_DATA(buf[j].symbol, symbols, i, symbols_wrap, symbols_size)\ + else\ + buf[j].symbol = i;\ + j++;\ + } + COPY(buf[j].bits > nb_bits); + // qsort is the slowest part of init_vlc, and could probably be improved or avoided + qsort(buf, j, sizeof(VLCcode), compare_vlcspec); + COPY(buf[j].bits && buf[j].bits <= nb_bits); + nb_codes = j; + + ret = build_table(vlc, nb_bits, nb_codes, buf, flags); + + av_free(buf); + if (ret < 0) { + av_freep(&vlc->table); + return -1; + } + if((flags & INIT_VLC_USE_NEW_STATIC) && vlc->table_size != vlc->table_allocated) + av_log(NULL, AV_LOG_ERROR, "needed %d had %d\n", vlc->table_size, vlc->table_allocated); + return 0; +} + + +void free_vlc(VLC *vlc) +{ + av_freep(&vlc->table); +} + diff --git a/lib/rbcodec/codecs/libwmavoice/celp_filters.c b/lib/rbcodec/codecs/libwmavoice/celp_filters.c new file mode 100644 index 0000000000..26a62eed14 --- /dev/null +++ b/lib/rbcodec/codecs/libwmavoice/celp_filters.c @@ -0,0 +1,210 @@ +/* + * various filters for ACELP-based codecs + * + * Copyright (c) 2008 Vladimir Voroshilov + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include + +#include "avcodec.h" +#include "celp_filters.h" + +void ff_celp_convolve_circ(int16_t* fc_out, const int16_t* fc_in, + const int16_t* filter, int len) +{ + int i, k; + + memset(fc_out, 0, len * sizeof(int16_t)); + + /* Since there are few pulses over an entire subframe (i.e. almost + all fc_in[i] are zero) it is faster to loop over fc_in first. */ + for (i = 0; i < len; i++) { + if (fc_in[i]) { + for (k = 0; k < i; k++) + fc_out[k] += (fc_in[i] * filter[len + k - i]) >> 15; + + for (k = i; k < len; k++) + fc_out[k] += (fc_in[i] * filter[ k - i]) >> 15; + } + } +} + +void ff_celp_circ_addf(float *out, const float *in, + const float *lagged, int lag, float fac, int n) +{ + int k; + for (k = 0; k < lag; k++) + out[k] = in[k] + fac * lagged[n + k - lag]; + for (; k < n; k++) + out[k] = in[k] + fac * lagged[ k - lag]; +} + +int ff_celp_lp_synthesis_filter(int16_t *out, const int16_t *filter_coeffs, + const int16_t *in, int buffer_length, + int filter_length, int stop_on_overflow, + int rounder) +{ + int i,n; + + for (n = 0; n < buffer_length; n++) { + int sum = rounder; + for (i = 1; i <= filter_length; i++) + sum -= filter_coeffs[i-1] * out[n-i]; + + sum = (sum >> 12) + in[n]; + + if (sum + 0x8000 > 0xFFFFU) { + if (stop_on_overflow) + return 1; + sum = (sum >> 31) ^ 32767; + } + out[n] = sum; + } + + return 0; +} + +void ff_celp_lp_synthesis_filterf(float *out, const float *filter_coeffs, + const float* in, int buffer_length, + int filter_length) +{ + int i,n; + +#if 0 // Unoptimized code path for improved readability + for (n = 0; n < buffer_length; n++) { + out[n] = in[n]; + for (i = 1; i <= filter_length; i++) + out[n] -= filter_coeffs[i-1] * out[n-i]; + } +#else + float out0, out1, out2, out3; + float old_out0, old_out1, old_out2, old_out3; + float a,b,c; + + a = filter_coeffs[0]; + b = filter_coeffs[1]; + c = filter_coeffs[2]; + b -= filter_coeffs[0] * filter_coeffs[0]; + c -= filter_coeffs[1] * filter_coeffs[0]; + c -= filter_coeffs[0] * b; + + old_out0 = out[-4]; + old_out1 = out[-3]; + old_out2 = out[-2]; + old_out3 = out[-1]; + for (n = 0; n <= buffer_length - 4; n+=4) { + float tmp0,tmp1,tmp2,tmp3; + float val; + + out0 = in[0]; + out1 = in[1]; + out2 = in[2]; + out3 = in[3]; + + out0 -= filter_coeffs[2] * old_out1; + out1 -= filter_coeffs[2] * old_out2; + out2 -= filter_coeffs[2] * old_out3; + + out0 -= filter_coeffs[1] * old_out2; + out1 -= filter_coeffs[1] * old_out3; + + out0 -= filter_coeffs[0] * old_out3; + + val = filter_coeffs[3]; + + out0 -= val * old_out0; + out1 -= val * old_out1; + out2 -= val * old_out2; + out3 -= val * old_out3; + + old_out3 = out[-5]; + + for (i = 5; i <= filter_length; i += 2) { + val = filter_coeffs[i-1]; + + out0 -= val * old_out3; + out1 -= val * old_out0; + out2 -= val * old_out1; + out3 -= val * old_out2; + + old_out2 = out[-i-1]; + + val = filter_coeffs[i]; + + out0 -= val * old_out2; + out1 -= val * old_out3; + out2 -= val * old_out0; + out3 -= val * old_out1; + + FFSWAP(float, old_out0, old_out2); + old_out1 = old_out3; + old_out3 = out[-i-2]; + } + + tmp0 = out0; + tmp1 = out1; + tmp2 = out2; + tmp3 = out3; + + out3 -= a * tmp2; + out2 -= a * tmp1; + out1 -= a * tmp0; + + out3 -= b * tmp1; + out2 -= b * tmp0; + + out3 -= c * tmp0; + + + out[0] = out0; + out[1] = out1; + out[2] = out2; + out[3] = out3; + + old_out0 = out0; + old_out1 = out1; + old_out2 = out2; + old_out3 = out3; + + out += 4; + in += 4; + } + + out -= n; + in -= n; + for (; n < buffer_length; n++) { + out[n] = in[n]; + for (i = 1; i <= filter_length; i++) + out[n] -= filter_coeffs[i-1] * out[n-i]; + } +#endif +} + +void ff_celp_lp_zero_synthesis_filterf(float *out, const float *filter_coeffs, + const float *in, int buffer_length, + int filter_length) +{ + int i,n; + + for (n = 0; n < buffer_length; n++) { + out[n] = in[n]; + for (i = 1; i <= filter_length; i++) + out[n] += filter_coeffs[i-1] * in[n-i]; + } +} diff --git a/lib/rbcodec/codecs/libwmavoice/celp_filters.h b/lib/rbcodec/codecs/libwmavoice/celp_filters.h new file mode 100644 index 0000000000..145e3d3346 --- /dev/null +++ b/lib/rbcodec/codecs/libwmavoice/celp_filters.h @@ -0,0 +1,119 @@ +/* + * various filters for CELP-based codecs + * + * Copyright (c) 2008 Vladimir Voroshilov + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVCODEC_CELP_FILTERS_H +#define AVCODEC_CELP_FILTERS_H + +#include + +/** + * Circularly convolve fixed vector with a phase dispersion impulse + * response filter (D.6.2 of G.729 and 6.1.5 of AMR). + * @param fc_out vector with filter applied + * @param fc_in source vector + * @param filter phase filter coefficients + * + * fc_out[n] = sum(i,0,len-1){ fc_in[i] * filter[(len + n - i)%len] } + * + * \note fc_in and fc_out should not overlap! + */ +void ff_celp_convolve_circ(int16_t *fc_out, const int16_t *fc_in, + const int16_t *filter, int len); + +/** + * Add an array to a rotated array. + * + * out[k] = in[k] + fac * lagged[k-lag] with wrap-around + * + * @param out result vector + * @param in samples to be added unfiltered + * @param lagged samples to be rotated, multiplied and added + * @param lag lagged vector delay in the range [0, n] + * @param fac scalefactor for lagged samples + * @param n number of samples + */ +void ff_celp_circ_addf(float *out, const float *in, + const float *lagged, int lag, float fac, int n); + +/** + * LP synthesis filter. + * @param[out] out pointer to output buffer + * @param filter_coeffs filter coefficients (-0x8000 <= (3.12) < 0x8000) + * @param in input signal + * @param buffer_length amount of data to process + * @param filter_length filter length (10 for 10th order LP filter) + * @param stop_on_overflow 1 - return immediately if overflow occurs + * 0 - ignore overflows + * @param rounder the amount to add for rounding (usually 0x800 or 0xfff) + * + * @return 1 if overflow occurred, 0 - otherwise + * + * @note Output buffer must contain filter_length samples of past + * speech data before pointer. + * + * Routine applies 1/A(z) filter to given speech data. + */ +int ff_celp_lp_synthesis_filter(int16_t *out, const int16_t *filter_coeffs, + const int16_t *in, int buffer_length, + int filter_length, int stop_on_overflow, + int rounder); + +/** + * LP synthesis filter. + * @param[out] out pointer to output buffer + * - the array out[-filter_length, -1] must + * contain the previous result of this filter + * @param filter_coeffs filter coefficients. + * @param in input signal + * @param buffer_length amount of data to process + * @param filter_length filter length (10 for 10th order LP filter). Must be + * greater than 4 and even. + * + * @note Output buffer must contain filter_length samples of past + * speech data before pointer. + * + * Routine applies 1/A(z) filter to given speech data. + */ +void ff_celp_lp_synthesis_filterf(float *out, const float *filter_coeffs, + const float *in, int buffer_length, + int filter_length); + +/** + * LP zero synthesis filter. + * @param[out] out pointer to output buffer + * @param filter_coeffs filter coefficients. + * @param in input signal + * - the array in[-filter_length, -1] must + * contain the previous input of this filter + * @param buffer_length amount of data to process + * @param filter_length filter length (10 for 10th order LP filter) + * + * @note Output buffer must contain filter_length samples of past + * speech data before pointer. + * + * Routine applies A(z) filter to given speech data. + */ +void ff_celp_lp_zero_synthesis_filterf(float *out, const float *filter_coeffs, + const float *in, int buffer_length, + int filter_length); + +#endif /* AVCODEC_CELP_FILTERS_H */ diff --git a/lib/rbcodec/codecs/libwmavoice/celp_math.c b/lib/rbcodec/codecs/libwmavoice/celp_math.c new file mode 100644 index 0000000000..09111da819 --- /dev/null +++ b/lib/rbcodec/codecs/libwmavoice/celp_math.c @@ -0,0 +1,208 @@ +/* + * Various fixed-point math operations + * + * Copyright (c) 2008 Vladimir Voroshilov + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include +#include +#include + +#include "avcodec.h" +#include "celp_math.h" + +#ifdef G729_BITEXACT +/** + * Cosine table: base_cos[i] = (1<<15) * cos(i*PI/64) + */ +static const int16_t base_cos[64] = +{ + 32767, 32729, 32610, 32413, 32138, 31786, 31357, 30853, + 30274, 29622, 28899, 28106, 27246, 26320, 25330, 24279, + 23170, 22006, 20788, 19520, 18205, 16846, 15447, 14010, + 12540, 11039, 9512, 7962, 6393, 4808, 3212, 1608, + 0, -1608, -3212, -4808, -6393, -7962, -9512, -11039, + -12540, -14010, -15447, -16846, -18205, -19520, -20788, -22006, + -23170, -24279, -25330, -26320, -27246, -28106, -28899, -29622, + -30274, -30853, -31357, -31786, -32138, -32413, -32610, -32729 +}; + +/** + * Slope used to compute cos(x) + * + * cos(ind*64+offset) = base_cos[ind]+offset*slope_cos[ind] + * values multiplied by 1<<19 + */ +static const int16_t slope_cos[64] = +{ + -632, -1893, -3150, -4399, -5638, -6863, -8072, -9261, + -10428, -11570, -12684, -13767, -14817, -15832, -16808, -17744, + -18637, -19486, -20287, -21039, -21741, -22390, -22986, -23526, + -24009, -24435, -24801, -25108, -25354, -25540, -25664, -25726, + -25726, -25664, -25540, -25354, -25108, -24801, -24435, -24009, + -23526, -22986, -22390, -21741, -21039, -20287, -19486, -18637, + -17744, -16808, -15832, -14817, -13767, -12684, -11570, -10428, + -9261, -8072, -6863, -5638, -4399, -3150, -1893, -632 +}; + +/** + * Table used to compute exp2(x) + * + * tab_exp2[i] = (1<<14) * exp2(i/32) = 2^(i/32) i=0..32 + */ +static const uint16_t tab_exp2[33] = +{ + 16384, 16743, 17109, 17484, 17867, 18258, 18658, 19066, 19484, 19911, + 20347, 20792, 21247, 21713, 22188, 22674, 23170, 23678, 24196, 24726, + 25268, 25821, 26386, 26964, 27554, 28158, 28774, 29405, 30048, 30706, + 31379, 32066, 32767 +}; + +int16_t ff_cos(uint16_t arg) +{ + uint8_t offset= arg; + uint8_t ind = arg >> 8; + + assert(arg < 0x4000); + + return FFMAX(base_cos[ind] + ((slope_cos[ind] * offset) >> 12), -0x8000); +} + +int ff_exp2(uint16_t power) +{ + uint16_t frac_x0; + uint16_t frac_dx; + int result; + + assert(power <= 0x7fff); + + frac_x0 = power >> 10; + frac_dx = (power & 0x03ff) << 5; + + result = tab_exp2[frac_x0] << 15; + result += frac_dx * (tab_exp2[frac_x0+1] - tab_exp2[frac_x0]); + + return result >> 10; +} + +#else // G729_BITEXACT + +/** + * Cosine table: base_cos[i] = (1<<15) * cos(i*PI/64) + */ +static const int16_t tab_cos[65] = +{ + 32767, 32738, 32617, 32421, 32145, 31793, 31364, 30860, + 30280, 29629, 28905, 28113, 27252, 26326, 25336, 24285, + 23176, 22011, 20793, 19525, 18210, 16851, 15451, 14014, + 12543, 11043, 9515, 7965, 6395, 4810, 3214, 1609, + 1, -1607, -3211, -4808, -6393, -7962, -9513, -11040, + -12541, -14012, -15449, -16848, -18207, -19523, -20791, -22009, + -23174, -24283, -25334, -26324, -27250, -28111, -28904, -29627, + -30279, -30858, -31363, -31792, -32144, -32419, -32616, -32736, -32768, +}; + +static const uint16_t exp2a[]= +{ + 0, 1435, 2901, 4400, 5931, 7496, 9096, 10730, + 12400, 14106, 15850, 17632, 19454, 21315, 23216, 25160, + 27146, 29175, 31249, 33368, 35534, 37747, 40009, 42320, + 44682, 47095, 49562, 52082, 54657, 57289, 59979, 62727, +}; + +static const uint16_t exp2b[]= +{ + 3, 712, 1424, 2134, 2845, 3557, 4270, 4982, + 5696, 6409, 7124, 7839, 8554, 9270, 9986, 10704, + 11421, 12138, 12857, 13576, 14295, 15014, 15734, 16455, + 17176, 17898, 18620, 19343, 20066, 20790, 21514, 22238, +}; + +int16_t ff_cos(uint16_t arg) +{ + uint8_t offset= arg; + uint8_t ind = arg >> 8; + + assert(arg <= 0x3fff); + + return tab_cos[ind] + (offset * (tab_cos[ind+1] - tab_cos[ind]) >> 8); +} + +int ff_exp2(uint16_t power) +{ + unsigned int result= exp2a[power>>10] + 0x10000; + + assert(power <= 0x7fff); + + result= (result<<3) + ((result*exp2b[(power>>5)&31])>>17); + return result + ((result*(power&31)*89)>>22); +} + +#endif // else G729_BITEXACT + +/** + * Table used to compute log2(x) + * + * tab_log2[i] = (1<<15) * log2(1 + i/32), i=0..32 + */ +static const uint16_t tab_log2[33] = +{ +#ifdef G729_BITEXACT + 0, 1455, 2866, 4236, 5568, 6863, 8124, 9352, + 10549, 11716, 12855, 13967, 15054, 16117, 17156, 18172, + 19167, 20142, 21097, 22033, 22951, 23852, 24735, 25603, + 26455, 27291, 28113, 28922, 29716, 30497, 31266, 32023, 32767, +#else + 4, 1459, 2870, 4240, 5572, 6867, 8127, 9355, + 10552, 11719, 12858, 13971, 15057, 16120, 17158, 18175, + 19170, 20145, 21100, 22036, 22954, 23854, 24738, 25605, + 26457, 27294, 28116, 28924, 29719, 30500, 31269, 32025, 32769, +#endif +}; + +int ff_log2(uint32_t value) +{ + uint8_t power_int; + uint8_t frac_x0; + uint16_t frac_dx; + + // Stripping zeros from beginning + power_int = av_log2(value); + value <<= (31 - power_int); + + // b31 is always non-zero now + frac_x0 = (value & 0x7c000000) >> 26; // b26-b31 and [32..63] -> [0..31] + frac_dx = (value & 0x03fff800) >> 11; + + value = tab_log2[frac_x0]; + value += (frac_dx * (tab_log2[frac_x0+1] - tab_log2[frac_x0])) >> 15; + + return (power_int << 15) + value; +} + +float ff_dot_productf(const float* a, const float* b, int length) +{ + float sum = 0; + int i; + + for(i=0; i + +/** + * fixed-point implementation of cosine in [0; PI) domain. + * @param arg fixed-point cosine argument, 0 <= arg < 0x4000 + * + * @return value of (1<<15) * cos(arg * PI / (1<<14)), -0x8000 <= result <= 0x7fff + */ +int16_t ff_cos(uint16_t arg); + +/** + * fixed-point implementation of exp2(x) in [0; 1] domain. + * @param power argument to exp2, 0 <= power <= 0x7fff + * + * @return value of (1<<20) * exp2(power / (1<<15)) + * 0x8000c <= result <= 0xfffea + */ +int ff_exp2(uint16_t power); + +/** + * Calculate log2(x). + * @param value function argument, 0 < value <= 7fff ffff + * + * @return value of (1<<15) * log2(value) + */ +int ff_log2(uint32_t value); + +/** + * Shift value left or right depending on sign of offset parameter. + * @param value value to shift + * @param offset shift offset + * + * @return value << offset, if offset>=0; value >> -offset - otherwise + */ +static inline int bidir_sal(int value, int offset) +{ + if(offset < 0) return value >> -offset; + else return value << offset; +} + +/** + * returns the dot product. + * @param a input data array + * @param b input data array + * @param length number of elements + * + * @return dot product = sum of elementwise products + */ +float ff_dot_productf(const float* a, const float* b, int length); + +#endif /* AVCODEC_CELP_MATH_H */ diff --git a/lib/rbcodec/codecs/libwmavoice/dct.c b/lib/rbcodec/codecs/libwmavoice/dct.c new file mode 100644 index 0000000000..95aef5af6c --- /dev/null +++ b/lib/rbcodec/codecs/libwmavoice/dct.c @@ -0,0 +1,226 @@ +/* + * (I)DCT Transforms + * Copyright (c) 2009 Peter Ross + * Copyright (c) 2010 Alex Converse + * Copyright (c) 2010 Vitor Sessak + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * (Inverse) Discrete Cosine Transforms. These are also known as the + * type II and type III DCTs respectively. + */ + +#include +#include "libavutil/mathematics.h" +#include "fft.h" +//#include "x86/fft.h" + +#define DCT32_FLOAT +#include "dct32.c" + +/* sin((M_PI * x / (2*n)) */ +#define SIN(s,n,x) (s->costab[(n) - (x)]) + +/* cos((M_PI * x / (2*n)) */ +#define COS(s,n,x) (s->costab[x]) + +static void ff_dst_calc_I_c(DCTContext *ctx, FFTSample *data) +{ + int n = 1 << ctx->nbits; + int i; + + data[0] = 0; + for(i = 1; i < n/2; i++) { + float tmp1 = data[i ]; + float tmp2 = data[n - i]; + float s = SIN(ctx, n, 2*i); + + s *= tmp1 + tmp2; + tmp1 = (tmp1 - tmp2) * 0.5f; + data[i ] = s + tmp1; + data[n - i] = s - tmp1; + } + + data[n/2] *= 2; + ff_rdft_calc(&ctx->rdft, data); + + data[0] *= 0.5f; + + for(i = 1; i < n-2; i += 2) { + data[i + 1] += data[i - 1]; + data[i ] = -data[i + 2]; + } + + data[n-1] = 0; +} + +static void ff_dct_calc_I_c(DCTContext *ctx, FFTSample *data) +{ + int n = 1 << ctx->nbits; + int i; + float next = -0.5f * (data[0] - data[n]); + + for(i = 0; i < n/2; i++) { + float tmp1 = data[i ]; + float tmp2 = data[n - i]; + float s = SIN(ctx, n, 2*i); + float c = COS(ctx, n, 2*i); + + c *= tmp1 - tmp2; + s *= tmp1 - tmp2; + + next += c; + + tmp1 = (tmp1 + tmp2) * 0.5f; + data[i ] = tmp1 - s; + data[n - i] = tmp1 + s; + } + + ff_rdft_calc(&ctx->rdft, data); + data[n] = data[1]; + data[1] = next; + + for(i = 3; i <= n; i += 2) + data[i] = data[i - 2] - data[i]; +} + +static void ff_dct_calc_III_c(DCTContext *ctx, FFTSample *data) +{ + int n = 1 << ctx->nbits; + int i; + + float next = data[n - 1]; + float inv_n = 1.0f / n; + + for (i = n - 2; i >= 2; i -= 2) { + float val1 = data[i ]; + float val2 = data[i - 1] - data[i + 1]; + float c = COS(ctx, n, i); + float s = SIN(ctx, n, i); + + data[i ] = c * val1 + s * val2; + data[i + 1] = s * val1 - c * val2; + } + + data[1] = 2 * next; + + ff_rdft_calc(&ctx->rdft, data); + + for (i = 0; i < n / 2; i++) { + float tmp1 = data[i ] * inv_n; + float tmp2 = data[n - i - 1] * inv_n; + float csc = ctx->csc2[i] * (tmp1 - tmp2); + + tmp1 += tmp2; + data[i ] = tmp1 + csc; + data[n - i - 1] = tmp1 - csc; + } +} + +static void ff_dct_calc_II_c(DCTContext *ctx, FFTSample *data) +{ + int n = 1 << ctx->nbits; + int i; + float next; + + for (i=0; i < n/2; i++) { + float tmp1 = data[i ]; + float tmp2 = data[n - i - 1]; + float s = SIN(ctx, n, 2*i + 1); + + s *= tmp1 - tmp2; + tmp1 = (tmp1 + tmp2) * 0.5f; + + data[i ] = tmp1 + s; + data[n-i-1] = tmp1 - s; + } + + ff_rdft_calc(&ctx->rdft, data); + + next = data[1] * 0.5; + data[1] *= -1; + + for (i = n - 2; i >= 0; i -= 2) { + float inr = data[i ]; + float ini = data[i + 1]; + float c = COS(ctx, n, i); + float s = SIN(ctx, n, i); + + data[i ] = c * inr + s * ini; + + data[i+1] = next; + + next += s * inr - c * ini; + } +} + +static void dct32_func(DCTContext *ctx, FFTSample *data) +{ + ctx->dct32(data, data); +} + +void ff_dct_calc(DCTContext *s, FFTSample *data) +{ + s->dct_calc(s, data); +} + +av_cold int ff_dct_init(DCTContext *s, int nbits, enum DCTTransformType inverse) +{ + int n = 1 << nbits; + int i; + + s->nbits = nbits; + s->inverse = inverse; + + ff_init_ff_cos_tabs(nbits+2); + + s->costab = ff_cos_tabs[nbits+2]; + + s->csc2 = av_malloc(n/2 * sizeof(FFTSample)); + + if (ff_rdft_init(&s->rdft, nbits, inverse == DCT_III) < 0) { + av_free(s->csc2); + return -1; + } + + for (i = 0; i < n/2; i++) + s->csc2[i] = 0.5 / sin((M_PI / (2*n) * (2*i + 1))); + + switch(inverse) { + case DCT_I : s->dct_calc = ff_dct_calc_I_c; break; + case DCT_II : s->dct_calc = ff_dct_calc_II_c ; break; + case DCT_III: s->dct_calc = ff_dct_calc_III_c; break; + case DST_I : s->dct_calc = ff_dst_calc_I_c; break; + } + + if (inverse == DCT_II && nbits == 5) + s->dct_calc = dct32_func; + + s->dct32 = dct32; + //if (HAVE_MMX) ff_dct_init_mmx(s); + + return 0; +} + +av_cold void ff_dct_end(DCTContext *s) +{ + ff_rdft_end(&s->rdft); + av_free(s->csc2); +} diff --git a/lib/rbcodec/codecs/libwmavoice/dct32.c b/lib/rbcodec/codecs/libwmavoice/dct32.c new file mode 100644 index 0000000000..4e843ee832 --- /dev/null +++ b/lib/rbcodec/codecs/libwmavoice/dct32.c @@ -0,0 +1,267 @@ +/* + * Template for the Discrete Cosine Transform for 32 samples + * Copyright (c) 2001, 2002 Fabrice Bellard + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifdef DCT32_FLOAT +# define FIXHR(x) ((float)(x)) +# define MULH3(x, y, s) ((s)*(y)*(x)) +# define INTFLOAT float +#endif + + +/* tab[i][j] = 1.0 / (2.0 * cos(pi*(2*k+1) / 2^(6 - j))) */ + +/* cos(i*pi/64) */ + +#define COS0_0 FIXHR(0.50060299823519630134/2) +#define COS0_1 FIXHR(0.50547095989754365998/2) +#define COS0_2 FIXHR(0.51544730992262454697/2) +#define COS0_3 FIXHR(0.53104259108978417447/2) +#define COS0_4 FIXHR(0.55310389603444452782/2) +#define COS0_5 FIXHR(0.58293496820613387367/2) +#define COS0_6 FIXHR(0.62250412303566481615/2) +#define COS0_7 FIXHR(0.67480834145500574602/2) +#define COS0_8 FIXHR(0.74453627100229844977/2) +#define COS0_9 FIXHR(0.83934964541552703873/2) +#define COS0_10 FIXHR(0.97256823786196069369/2) +#define COS0_11 FIXHR(1.16943993343288495515/4) +#define COS0_12 FIXHR(1.48416461631416627724/4) +#define COS0_13 FIXHR(2.05778100995341155085/8) +#define COS0_14 FIXHR(3.40760841846871878570/8) +#define COS0_15 FIXHR(10.19000812354805681150/32) + +#define COS1_0 FIXHR(0.50241928618815570551/2) +#define COS1_1 FIXHR(0.52249861493968888062/2) +#define COS1_2 FIXHR(0.56694403481635770368/2) +#define COS1_3 FIXHR(0.64682178335999012954/2) +#define COS1_4 FIXHR(0.78815462345125022473/2) +#define COS1_5 FIXHR(1.06067768599034747134/4) +#define COS1_6 FIXHR(1.72244709823833392782/4) +#define COS1_7 FIXHR(5.10114861868916385802/16) + +#define COS2_0 FIXHR(0.50979557910415916894/2) +#define COS2_1 FIXHR(0.60134488693504528054/2) +#define COS2_2 FIXHR(0.89997622313641570463/2) +#define COS2_3 FIXHR(2.56291544774150617881/8) + +#define COS3_0 FIXHR(0.54119610014619698439/2) +#define COS3_1 FIXHR(1.30656296487637652785/4) + +#define COS4_0 FIXHR(0.70710678118654752439/2) + +/* butterfly operator */ +#define BF(a, b, c, s)\ +{\ + tmp0 = val##a + val##b;\ + tmp1 = val##a - val##b;\ + val##a = tmp0;\ + val##b = MULH3(tmp1, c, 1<<(s));\ +} + +#define BF0(a, b, c, s)\ +{\ + tmp0 = tab[a] + tab[b];\ + tmp1 = tab[a] - tab[b];\ + val##a = tmp0;\ + val##b = MULH3(tmp1, c, 1<<(s));\ +} + +#define BF1(a, b, c, d)\ +{\ + BF(a, b, COS4_0, 1);\ + BF(c, d,-COS4_0, 1);\ + val##c += val##d;\ +} + +#define BF2(a, b, c, d)\ +{\ + BF(a, b, COS4_0, 1);\ + BF(c, d,-COS4_0, 1);\ + val##c += val##d;\ + val##a += val##c;\ + val##c += val##b;\ + val##b += val##d;\ +} + +#define ADD(a, b) val##a += val##b + +/* DCT32 without 1/sqrt(2) coef zero scaling. */ +static void dct32(INTFLOAT *out, const INTFLOAT *tab) +{ + INTFLOAT tmp0, tmp1; + + INTFLOAT val0 , val1 , val2 , val3 , val4 , val5 , val6 , val7 , + val8 , val9 , val10, val11, val12, val13, val14, val15, + val16, val17, val18, val19, val20, val21, val22, val23, + val24, val25, val26, val27, val28, val29, val30, val31; + + /* pass 1 */ + BF0( 0, 31, COS0_0 , 1); + BF0(15, 16, COS0_15, 5); + /* pass 2 */ + BF( 0, 15, COS1_0 , 1); + BF(16, 31,-COS1_0 , 1); + /* pass 1 */ + BF0( 7, 24, COS0_7 , 1); + BF0( 8, 23, COS0_8 , 1); + /* pass 2 */ + BF( 7, 8, COS1_7 , 4); + BF(23, 24,-COS1_7 , 4); + /* pass 3 */ + BF( 0, 7, COS2_0 , 1); + BF( 8, 15,-COS2_0 , 1); + BF(16, 23, COS2_0 , 1); + BF(24, 31,-COS2_0 , 1); + /* pass 1 */ + BF0( 3, 28, COS0_3 , 1); + BF0(12, 19, COS0_12, 2); + /* pass 2 */ + BF( 3, 12, COS1_3 , 1); + BF(19, 28,-COS1_3 , 1); + /* pass 1 */ + BF0( 4, 27, COS0_4 , 1); + BF0(11, 20, COS0_11, 2); + /* pass 2 */ + BF( 4, 11, COS1_4 , 1); + BF(20, 27,-COS1_4 , 1); + /* pass 3 */ + BF( 3, 4, COS2_3 , 3); + BF(11, 12,-COS2_3 , 3); + BF(19, 20, COS2_3 , 3); + BF(27, 28,-COS2_3 , 3); + /* pass 4 */ + BF( 0, 3, COS3_0 , 1); + BF( 4, 7,-COS3_0 , 1); + BF( 8, 11, COS3_0 , 1); + BF(12, 15,-COS3_0 , 1); + BF(16, 19, COS3_0 , 1); + BF(20, 23,-COS3_0 , 1); + BF(24, 27, COS3_0 , 1); + BF(28, 31,-COS3_0 , 1); + + + + /* pass 1 */ + BF0( 1, 30, COS0_1 , 1); + BF0(14, 17, COS0_14, 3); + /* pass 2 */ + BF( 1, 14, COS1_1 , 1); + BF(17, 30,-COS1_1 , 1); + /* pass 1 */ + BF0( 6, 25, COS0_6 , 1); + BF0( 9, 22, COS0_9 , 1); + /* pass 2 */ + BF( 6, 9, COS1_6 , 2); + BF(22, 25,-COS1_6 , 2); + /* pass 3 */ + BF( 1, 6, COS2_1 , 1); + BF( 9, 14,-COS2_1 , 1); + BF(17, 22, COS2_1 , 1); + BF(25, 30,-COS2_1 , 1); + + /* pass 1 */ + BF0( 2, 29, COS0_2 , 1); + BF0(13, 18, COS0_13, 3); + /* pass 2 */ + BF( 2, 13, COS1_2 , 1); + BF(18, 29,-COS1_2 , 1); + /* pass 1 */ + BF0( 5, 26, COS0_5 , 1); + BF0(10, 21, COS0_10, 1); + /* pass 2 */ + BF( 5, 10, COS1_5 , 2); + BF(21, 26,-COS1_5 , 2); + /* pass 3 */ + BF( 2, 5, COS2_2 , 1); + BF(10, 13,-COS2_2 , 1); + BF(18, 21, COS2_2 , 1); + BF(26, 29,-COS2_2 , 1); + /* pass 4 */ + BF( 1, 2, COS3_1 , 2); + BF( 5, 6,-COS3_1 , 2); + BF( 9, 10, COS3_1 , 2); + BF(13, 14,-COS3_1 , 2); + BF(17, 18, COS3_1 , 2); + BF(21, 22,-COS3_1 , 2); + BF(25, 26, COS3_1 , 2); + BF(29, 30,-COS3_1 , 2); + + /* pass 5 */ + BF1( 0, 1, 2, 3); + BF2( 4, 5, 6, 7); + BF1( 8, 9, 10, 11); + BF2(12, 13, 14, 15); + BF1(16, 17, 18, 19); + BF2(20, 21, 22, 23); + BF1(24, 25, 26, 27); + BF2(28, 29, 30, 31); + + /* pass 6 */ + + ADD( 8, 12); + ADD(12, 10); + ADD(10, 14); + ADD(14, 9); + ADD( 9, 13); + ADD(13, 11); + ADD(11, 15); + + out[ 0] = val0; + out[16] = val1; + out[ 8] = val2; + out[24] = val3; + out[ 4] = val4; + out[20] = val5; + out[12] = val6; + out[28] = val7; + out[ 2] = val8; + out[18] = val9; + out[10] = val10; + out[26] = val11; + out[ 6] = val12; + out[22] = val13; + out[14] = val14; + out[30] = val15; + + ADD(24, 28); + ADD(28, 26); + ADD(26, 30); + ADD(30, 25); + ADD(25, 29); + ADD(29, 27); + ADD(27, 31); + + out[ 1] = val16 + val24; + out[17] = val17 + val25; + out[ 9] = val18 + val26; + out[25] = val19 + val27; + out[ 5] = val20 + val28; + out[21] = val21 + val29; + out[13] = val22 + val30; + out[29] = val23 + val31; + out[ 3] = val24 + val20; + out[19] = val25 + val21; + out[11] = val26 + val22; + out[27] = val27 + val23; + out[ 7] = val28 + val18; + out[23] = val29 + val19; + out[15] = val30 + val17; + out[31] = val31; +} diff --git a/lib/rbcodec/codecs/libwmavoice/fft.c b/lib/rbcodec/codecs/libwmavoice/fft.c new file mode 100644 index 0000000000..a030534a26 --- /dev/null +++ b/lib/rbcodec/codecs/libwmavoice/fft.c @@ -0,0 +1,298 @@ +/* + * FFT/IFFT transforms + * Copyright (c) 2008 Loren Merritt + * Copyright (c) 2002 Fabrice Bellard + * Partly based on libdjbfft by D. J. Bernstein + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * FFT/IFFT transforms. + */ + +#include +#include +#include "libavutil/mathematics.h" +#include "fft.h" + +/* cos(2*pi*x/n) for 0<=x<=n/4, followed by its reverse */ +#if !CONFIG_HARDCODED_TABLES +COSTABLE(16); +COSTABLE(32); +COSTABLE(64); +COSTABLE(128); +COSTABLE(256); +COSTABLE(512); +COSTABLE(1024); +COSTABLE(2048); +COSTABLE(4096); +COSTABLE(8192); +COSTABLE(16384); +COSTABLE(32768); +COSTABLE(65536); +#endif +COSTABLE_CONST FFTSample * const ff_cos_tabs[] = { + NULL, NULL, NULL, NULL, + ff_cos_16, ff_cos_32, ff_cos_64, ff_cos_128, ff_cos_256, ff_cos_512, ff_cos_1024, + ff_cos_2048, ff_cos_4096, ff_cos_8192, ff_cos_16384, ff_cos_32768, ff_cos_65536, +}; + +static int split_radix_permutation(int i, int n, int inverse) +{ + int m; + if(n <= 2) return i&1; + m = n >> 1; + if(!(i&m)) return split_radix_permutation(i, m, inverse)*2; + m >>= 1; + if(inverse == !(i&m)) return split_radix_permutation(i, m, inverse)*4 + 1; + else return split_radix_permutation(i, m, inverse)*4 - 1; +} + +av_cold void ff_init_ff_cos_tabs(int index) +{ +#if !CONFIG_HARDCODED_TABLES + int i; + int m = 1< 16) + goto fail; + s->nbits = nbits; + n = 1 << nbits; + + s->revtab = av_malloc(n * sizeof(uint16_t)); + if (!s->revtab) + goto fail; + s->tmp_buf = av_malloc(n * sizeof(FFTComplex)); + if (!s->tmp_buf) + goto fail; + s->inverse = inverse; + + s->fft_permute = ff_fft_permute_c; + s->fft_calc = ff_fft_calc_c; +#if CONFIG_MDCT + s->imdct_calc = ff_imdct_calc_c; + s->imdct_half = ff_imdct_half_c; + s->mdct_calc = ff_mdct_calc_c; +#endif + +#if 0 + if (ARCH_ARM) ff_fft_init_arm(s); + if (HAVE_ALTIVEC) ff_fft_init_altivec(s); + if (HAVE_MMX) ff_fft_init_mmx(s); +#endif + + for(j=4; j<=nbits; j++) { + ff_init_ff_cos_tabs(j); + } + for(i=0; irevtab[-split_radix_permutation(i, n, s->inverse) & (n-1)] = i; + + return 0; + fail: + av_freep(&s->revtab); + av_freep(&s->tmp_buf); + return -1; +} + +void ff_fft_permute_c(FFTContext *s, FFTComplex *z) +{ + int j, np; + const uint16_t *revtab = s->revtab; + np = 1 << s->nbits; + /* TODO: handle split-radix permute in a more optimal way, probably in-place */ + for(j=0;jtmp_buf[revtab[j]] = z[j]; + memcpy(z, s->tmp_buf, np * sizeof(FFTComplex)); +} + +av_cold void ff_fft_end(FFTContext *s) +{ + av_freep(&s->revtab); + av_freep(&s->tmp_buf); +} + +#define sqrthalf (float)M_SQRT1_2 + +#define BF(x,y,a,b) {\ + x = a - b;\ + y = a + b;\ +} + +#define BUTTERFLIES(a0,a1,a2,a3) {\ + BF(t3, t5, t5, t1);\ + BF(a2.re, a0.re, a0.re, t5);\ + BF(a3.im, a1.im, a1.im, t3);\ + BF(t4, t6, t2, t6);\ + BF(a3.re, a1.re, a1.re, t4);\ + BF(a2.im, a0.im, a0.im, t6);\ +} + +// force loading all the inputs before storing any. +// this is slightly slower for small data, but avoids store->load aliasing +// for addresses separated by large powers of 2. +#define BUTTERFLIES_BIG(a0,a1,a2,a3) {\ + FFTSample r0=a0.re, i0=a0.im, r1=a1.re, i1=a1.im;\ + BF(t3, t5, t5, t1);\ + BF(a2.re, a0.re, r0, t5);\ + BF(a3.im, a1.im, i1, t3);\ + BF(t4, t6, t2, t6);\ + BF(a3.re, a1.re, r1, t4);\ + BF(a2.im, a0.im, i0, t6);\ +} + +#define TRANSFORM(a0,a1,a2,a3,wre,wim) {\ + t1 = a2.re * wre + a2.im * wim;\ + t2 = a2.im * wre - a2.re * wim;\ + t5 = a3.re * wre - a3.im * wim;\ + t6 = a3.im * wre + a3.re * wim;\ + BUTTERFLIES(a0,a1,a2,a3)\ +} + +#define TRANSFORM_ZERO(a0,a1,a2,a3) {\ + t1 = a2.re;\ + t2 = a2.im;\ + t5 = a3.re;\ + t6 = a3.im;\ + BUTTERFLIES(a0,a1,a2,a3)\ +} + +/* z[0...8n-1], w[1...2n-1] */ +#define PASS(name)\ +static void name(FFTComplex *z, const FFTSample *wre, unsigned int n)\ +{\ + FFTSample t1, t2, t3, t4, t5, t6;\ + int o1 = 2*n;\ + int o2 = 4*n;\ + int o3 = 6*n;\ + const FFTSample *wim = wre+o1;\ + n--;\ +\ + TRANSFORM_ZERO(z[0],z[o1],z[o2],z[o3]);\ + TRANSFORM(z[1],z[o1+1],z[o2+1],z[o3+1],wre[1],wim[-1]);\ + do {\ + z += 2;\ + wre += 2;\ + wim -= 2;\ + TRANSFORM(z[0],z[o1],z[o2],z[o3],wre[0],wim[0]);\ + TRANSFORM(z[1],z[o1+1],z[o2+1],z[o3+1],wre[1],wim[-1]);\ + } while(--n);\ +} + +PASS(pass) +#undef BUTTERFLIES +#define BUTTERFLIES BUTTERFLIES_BIG +PASS(pass_big) + +#define DECL_FFT(n,n2,n4)\ +static void fft##n(FFTComplex *z)\ +{\ + fft##n2(z);\ + fft##n4(z+n4*2);\ + fft##n4(z+n4*3);\ + pass(z,ff_cos_##n,n4/2);\ +} + +static void fft4(FFTComplex *z) +{ + FFTSample t1, t2, t3, t4, t5, t6, t7, t8; + + BF(t3, t1, z[0].re, z[1].re); + BF(t8, t6, z[3].re, z[2].re); + BF(z[2].re, z[0].re, t1, t6); + BF(t4, t2, z[0].im, z[1].im); + BF(t7, t5, z[2].im, z[3].im); + BF(z[3].im, z[1].im, t4, t8); + BF(z[3].re, z[1].re, t3, t7); + BF(z[2].im, z[0].im, t2, t5); +} + +static void fft8(FFTComplex *z) +{ + FFTSample t1, t2, t3, t4, t5, t6, t7, t8; + + fft4(z); + + BF(t1, z[5].re, z[4].re, -z[5].re); + BF(t2, z[5].im, z[4].im, -z[5].im); + BF(t3, z[7].re, z[6].re, -z[7].re); + BF(t4, z[7].im, z[6].im, -z[7].im); + BF(t8, t1, t3, t1); + BF(t7, t2, t2, t4); + BF(z[4].re, z[0].re, z[0].re, t1); + BF(z[4].im, z[0].im, z[0].im, t2); + BF(z[6].re, z[2].re, z[2].re, t7); + BF(z[6].im, z[2].im, z[2].im, t8); + + TRANSFORM(z[1],z[3],z[5],z[7],sqrthalf,sqrthalf); +} + +#if !CONFIG_SMALL +static void fft16(FFTComplex *z) +{ + FFTSample t1, t2, t3, t4, t5, t6; + + fft8(z); + fft4(z+8); + fft4(z+12); + + TRANSFORM_ZERO(z[0],z[4],z[8],z[12]); + TRANSFORM(z[2],z[6],z[10],z[14],sqrthalf,sqrthalf); + TRANSFORM(z[1],z[5],z[9],z[13],ff_cos_16[1],ff_cos_16[3]); + TRANSFORM(z[3],z[7],z[11],z[15],ff_cos_16[3],ff_cos_16[1]); +} +#else +DECL_FFT(16,8,4) +#endif +DECL_FFT(32,16,8) +DECL_FFT(64,32,16) +DECL_FFT(128,64,32) +DECL_FFT(256,128,64) +DECL_FFT(512,256,128) +#if !CONFIG_SMALL +#define pass pass_big +#endif +DECL_FFT(1024,512,256) +DECL_FFT(2048,1024,512) +DECL_FFT(4096,2048,1024) +DECL_FFT(8192,4096,2048) +DECL_FFT(16384,8192,4096) +DECL_FFT(32768,16384,8192) +DECL_FFT(65536,32768,16384) + +static void (* const fft_dispatch[])(FFTComplex*) = { + fft4, fft8, fft16, fft32, fft64, fft128, fft256, fft512, fft1024, + fft2048, fft4096, fft8192, fft16384, fft32768, fft65536, +}; + +void ff_fft_calc_c(FFTContext *s, FFTComplex *z) +{ + fft_dispatch[s->nbits-2](z); +} + diff --git a/lib/rbcodec/codecs/libwmavoice/fft.h b/lib/rbcodec/codecs/libwmavoice/fft.h new file mode 100644 index 0000000000..2c54b56658 --- /dev/null +++ b/lib/rbcodec/codecs/libwmavoice/fft.h @@ -0,0 +1,244 @@ +/* + * Copyright (c) 2000, 2001, 2002 Fabrice Bellard + * Copyright (c) 2002-2004 Michael Niedermayer + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVCODEC_FFT_H +#define AVCODEC_FFT_H + +#include +//#include "config.h" +#include "libavutil/mem.h" +#include "avfft.h" + +/* FFT computation */ + +struct FFTContext { + int nbits; + int inverse; + uint16_t *revtab; + FFTComplex *tmp_buf; + int mdct_size; /* size of MDCT (i.e. number of input data * 2) */ + int mdct_bits; /* n = 2^nbits */ + /* pre/post rotation tables */ + FFTSample *tcos; + FFTSample *tsin; + void (*fft_permute)(struct FFTContext *s, FFTComplex *z); + void (*fft_calc)(struct FFTContext *s, FFTComplex *z); + void (*imdct_calc)(struct FFTContext *s, FFTSample *output, const FFTSample *input); + void (*imdct_half)(struct FFTContext *s, FFTSample *output, const FFTSample *input); + void (*mdct_calc)(struct FFTContext *s, FFTSample *output, const FFTSample *input); + int permutation; +#define FF_MDCT_PERM_NONE 0 +#define FF_MDCT_PERM_INTERLEAVE 1 +}; + +#if CONFIG_HARDCODED_TABLES +#define COSTABLE_CONST const +#define SINTABLE_CONST const +#define SINETABLE_CONST const +#else +#define COSTABLE_CONST +#define SINTABLE_CONST +#define SINETABLE_CONST +#endif + +#define COSTABLE(size) \ + COSTABLE_CONST DECLARE_ALIGNED(16, FFTSample, ff_cos_##size)[size/2] +#define SINTABLE(size) \ + SINTABLE_CONST DECLARE_ALIGNED(16, FFTSample, ff_sin_##size)[size/2] +#define SINETABLE(size) \ + SINETABLE_CONST DECLARE_ALIGNED(16, float, ff_sine_##size)[size] +extern COSTABLE(16); +extern COSTABLE(32); +extern COSTABLE(64); +extern COSTABLE(128); +extern COSTABLE(256); +extern COSTABLE(512); +extern COSTABLE(1024); +extern COSTABLE(2048); +extern COSTABLE(4096); +extern COSTABLE(8192); +extern COSTABLE(16384); +extern COSTABLE(32768); +extern COSTABLE(65536); +extern COSTABLE_CONST FFTSample* const ff_cos_tabs[17]; + +/** + * Initialize the cosine table in ff_cos_tabs[index] + * \param index index in ff_cos_tabs array of the table to initialize + */ +void ff_init_ff_cos_tabs(int index); + +extern SINTABLE(16); +extern SINTABLE(32); +extern SINTABLE(64); +extern SINTABLE(128); +extern SINTABLE(256); +extern SINTABLE(512); +extern SINTABLE(1024); +extern SINTABLE(2048); +extern SINTABLE(4096); +extern SINTABLE(8192); +extern SINTABLE(16384); +extern SINTABLE(32768); +extern SINTABLE(65536); + +/** + * Set up a complex FFT. + * @param nbits log2 of the length of the input array + * @param inverse if 0 perform the forward transform, if 1 perform the inverse + */ +int ff_fft_init(FFTContext *s, int nbits, int inverse); +void ff_fft_permute_c(FFTContext *s, FFTComplex *z); +void ff_fft_calc_c(FFTContext *s, FFTComplex *z); + +void ff_fft_init_altivec(FFTContext *s); +void ff_fft_init_mmx(FFTContext *s); +void ff_fft_init_arm(FFTContext *s); +void ff_dct_init_mmx(DCTContext *s); + +/** + * Do the permutation needed BEFORE calling ff_fft_calc(). + */ +static inline void ff_fft_permute(FFTContext *s, FFTComplex *z) +{ + s->fft_permute(s, z); +} +/** + * Do a complex FFT with the parameters defined in ff_fft_init(). The + * input data must be permuted before. No 1.0/sqrt(n) normalization is done. + */ +static inline void ff_fft_calc(FFTContext *s, FFTComplex *z) +{ + s->fft_calc(s, z); +} +void ff_fft_end(FFTContext *s); + +/* MDCT computation */ + +static inline void ff_imdct_calc(FFTContext *s, FFTSample *output, const FFTSample *input) +{ + s->imdct_calc(s, output, input); +} +static inline void ff_imdct_half(FFTContext *s, FFTSample *output, const FFTSample *input) +{ + s->imdct_half(s, output, input); +} + +static inline void ff_mdct_calc(FFTContext *s, FFTSample *output, + const FFTSample *input) +{ + s->mdct_calc(s, output, input); +} + +/** + * Maximum window size for ff_kbd_window_init. + */ +#define FF_KBD_WINDOW_MAX 1024 + +/** + * Generate a Kaiser-Bessel Derived Window. + * @param window pointer to half window + * @param alpha determines window shape + * @param n size of half window, max FF_KBD_WINDOW_MAX + */ +void ff_kbd_window_init(float *window, float alpha, int n); + +/** + * Generate a sine window. + * @param window pointer to half window + * @param n size of half window + */ +void ff_sine_window_init(float *window, int n); + +/** + * initialize the specified entry of ff_sine_windows + */ +void ff_init_ff_sine_windows(int index); +extern SINETABLE( 32); +extern SINETABLE( 64); +extern SINETABLE( 128); +extern SINETABLE( 256); +extern SINETABLE( 512); +extern SINETABLE(1024); +extern SINETABLE(2048); +extern SINETABLE(4096); +extern SINETABLE_CONST float * const ff_sine_windows[13]; + +int ff_mdct_init(FFTContext *s, int nbits, int inverse, double scale); +void ff_imdct_calc_c(FFTContext *s, FFTSample *output, const FFTSample *input); +void ff_imdct_half_c(FFTContext *s, FFTSample *output, const FFTSample *input); +void ff_mdct_calc_c(FFTContext *s, FFTSample *output, const FFTSample *input); +void ff_mdct_end(FFTContext *s); + +/* Real Discrete Fourier Transform */ + +struct RDFTContext { + int nbits; + int inverse; + int sign_convention; + + /* pre/post rotation tables */ + const FFTSample *tcos; + SINTABLE_CONST FFTSample *tsin; + FFTContext fft; + void (*rdft_calc)(struct RDFTContext *s, FFTSample *z); +}; + +/** + * Set up a real FFT. + * @param nbits log2 of the length of the input array + * @param trans the type of transform + */ +int ff_rdft_init(RDFTContext *s, int nbits, enum RDFTransformType trans); +void ff_rdft_end(RDFTContext *s); + +void ff_rdft_init_arm(RDFTContext *s); + +static av_always_inline void ff_rdft_calc(RDFTContext *s, FFTSample *data) +{ + s->rdft_calc(s, data); +} + +/* Discrete Cosine Transform */ + +struct DCTContext { + int nbits; + int inverse; + RDFTContext rdft; + const float *costab; + FFTSample *csc2; + void (*dct_calc)(struct DCTContext *s, FFTSample *data); + void (*dct32)(FFTSample *out, const FFTSample *in); +}; + +/** + * Set up DCT. + * @param nbits size of the input array: + * (1 << nbits) for DCT-II, DCT-III and DST-I + * (1 << nbits) + 1 for DCT-I + * + * @note the first element of the input of DST-I is ignored + */ +int ff_dct_init(DCTContext *s, int nbits, enum DCTTransformType type); +void ff_dct_calc(DCTContext *s, FFTSample *data); +void ff_dct_end (DCTContext *s); + +#endif /* AVCODEC_FFT_H */ diff --git a/lib/rbcodec/codecs/libwmavoice/get_bits.h b/lib/rbcodec/codecs/libwmavoice/get_bits.h new file mode 100644 index 0000000000..f4b3646e69 --- /dev/null +++ b/lib/rbcodec/codecs/libwmavoice/get_bits.h @@ -0,0 +1,691 @@ +/* + * copyright (c) 2004 Michael Niedermayer + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * bitstream reader API header. + */ + +#ifndef AVCODEC_GET_BITS_H +#define AVCODEC_GET_BITS_H + +#include +#include +#include +#include "libavutil/bswap.h" +#include "libavutil/common.h" +#include "libavutil/intreadwrite.h" +#include "libavutil/log.h" +#include "mathops.h" + +#if defined(ALT_BITSTREAM_READER_LE) && !defined(ALT_BITSTREAM_READER) +# define ALT_BITSTREAM_READER +#endif + +#if !defined(LIBMPEG2_BITSTREAM_READER) && !defined(A32_BITSTREAM_READER) && !defined(ALT_BITSTREAM_READER) +# if ARCH_ARM && !HAVE_FAST_UNALIGNED +# define A32_BITSTREAM_READER +# else +# define ALT_BITSTREAM_READER +//#define LIBMPEG2_BITSTREAM_READER +//#define A32_BITSTREAM_READER +# endif +#endif + +/* bit input */ +/* buffer, buffer_end and size_in_bits must be present and used by every reader */ +typedef struct GetBitContext { + const uint8_t *buffer, *buffer_end; +#ifdef ALT_BITSTREAM_READER + int index; +#elif defined LIBMPEG2_BITSTREAM_READER + uint8_t *buffer_ptr; + uint32_t cache; + int bit_count; +#elif defined A32_BITSTREAM_READER + uint32_t *buffer_ptr; + uint32_t cache0; + uint32_t cache1; + int bit_count; +#endif + int size_in_bits; +} GetBitContext; + +#define VLC_TYPE int16_t + +typedef struct VLC { + int bits; + VLC_TYPE (*table)[2]; ///< code, bits + int table_size, table_allocated; +} VLC; + +typedef struct RL_VLC_ELEM { + int16_t level; + int8_t len; + uint8_t run; +} RL_VLC_ELEM; + +/* Bitstream reader API docs: +name + arbitrary name which is used as prefix for the internal variables + +gb + getbitcontext + +OPEN_READER(name, gb) + loads gb into local variables + +CLOSE_READER(name, gb) + stores local vars in gb + +UPDATE_CACHE(name, gb) + refills the internal cache from the bitstream + after this call at least MIN_CACHE_BITS will be available, + +GET_CACHE(name, gb) + will output the contents of the internal cache, next bit is MSB of 32 or 64 bit (FIXME 64bit) + +SHOW_UBITS(name, gb, num) + will return the next num bits + +SHOW_SBITS(name, gb, num) + will return the next num bits and do sign extension + +SKIP_BITS(name, gb, num) + will skip over the next num bits + note, this is equivalent to SKIP_CACHE; SKIP_COUNTER + +SKIP_CACHE(name, gb, num) + will remove the next num bits from the cache (note SKIP_COUNTER MUST be called before UPDATE_CACHE / CLOSE_READER) + +SKIP_COUNTER(name, gb, num) + will increment the internal bit counter (see SKIP_CACHE & SKIP_BITS) + +LAST_SKIP_CACHE(name, gb, num) + will remove the next num bits from the cache if it is needed for UPDATE_CACHE otherwise it will do nothing + +LAST_SKIP_BITS(name, gb, num) + is equivalent to LAST_SKIP_CACHE; SKIP_COUNTER + +for examples see get_bits, show_bits, skip_bits, get_vlc +*/ + +#ifdef ALT_BITSTREAM_READER +# define MIN_CACHE_BITS 25 + +# define OPEN_READER(name, gb)\ + unsigned int name##_index= (gb)->index;\ + int name##_cache= 0;\ + +# define CLOSE_READER(name, gb)\ + (gb)->index= name##_index;\ + +# ifdef ALT_BITSTREAM_READER_LE +# define UPDATE_CACHE(name, gb)\ + name##_cache= AV_RL32( ((const uint8_t *)(gb)->buffer)+(name##_index>>3) ) >> (name##_index&0x07);\ + +# define SKIP_CACHE(name, gb, num)\ + name##_cache >>= (num); +# else +# define UPDATE_CACHE(name, gb)\ + name##_cache= AV_RB32( ((const uint8_t *)(gb)->buffer)+(name##_index>>3) ) << (name##_index&0x07);\ + +# define SKIP_CACHE(name, gb, num)\ + name##_cache <<= (num); +# endif + +// FIXME name? +# define SKIP_COUNTER(name, gb, num)\ + name##_index += (num);\ + +# define SKIP_BITS(name, gb, num)\ + {\ + SKIP_CACHE(name, gb, num)\ + SKIP_COUNTER(name, gb, num)\ + }\ + +# define LAST_SKIP_BITS(name, gb, num) SKIP_COUNTER(name, gb, num) +# define LAST_SKIP_CACHE(name, gb, num) ; + +# ifdef ALT_BITSTREAM_READER_LE +# define SHOW_UBITS(name, gb, num)\ + zero_extend(name##_cache, num) + +# define SHOW_SBITS(name, gb, num)\ + sign_extend(name##_cache, num) +# else +# define SHOW_UBITS(name, gb, num)\ + NEG_USR32(name##_cache, num) + +# define SHOW_SBITS(name, gb, num)\ + NEG_SSR32(name##_cache, num) +# endif + +# define GET_CACHE(name, gb)\ + ((uint32_t)name##_cache) + +static inline int get_bits_count(const GetBitContext *s){ + return s->index; +} + +static inline void skip_bits_long(GetBitContext *s, int n){ + s->index += n; +} + +#elif defined LIBMPEG2_BITSTREAM_READER +//libmpeg2 like reader + +# define MIN_CACHE_BITS 17 + +# define OPEN_READER(name, gb)\ + int name##_bit_count=(gb)->bit_count;\ + int name##_cache= (gb)->cache;\ + uint8_t * name##_buffer_ptr=(gb)->buffer_ptr;\ + +# define CLOSE_READER(name, gb)\ + (gb)->bit_count= name##_bit_count;\ + (gb)->cache= name##_cache;\ + (gb)->buffer_ptr= name##_buffer_ptr;\ + +# define UPDATE_CACHE(name, gb)\ + if(name##_bit_count >= 0){\ + name##_cache+= AV_RB16(name##_buffer_ptr) << name##_bit_count; \ + name##_buffer_ptr+=2;\ + name##_bit_count-= 16;\ + }\ + +# define SKIP_CACHE(name, gb, num)\ + name##_cache <<= (num);\ + +# define SKIP_COUNTER(name, gb, num)\ + name##_bit_count += (num);\ + +# define SKIP_BITS(name, gb, num)\ + {\ + SKIP_CACHE(name, gb, num)\ + SKIP_COUNTER(name, gb, num)\ + }\ + +# define LAST_SKIP_BITS(name, gb, num) SKIP_BITS(name, gb, num) +# define LAST_SKIP_CACHE(name, gb, num) SKIP_CACHE(name, gb, num) + +# define SHOW_UBITS(name, gb, num)\ + NEG_USR32(name##_cache, num) + +# define SHOW_SBITS(name, gb, num)\ + NEG_SSR32(name##_cache, num) + +# define GET_CACHE(name, gb)\ + ((uint32_t)name##_cache) + +static inline int get_bits_count(const GetBitContext *s){ + return (s->buffer_ptr - s->buffer)*8 - 16 + s->bit_count; +} + +static inline void skip_bits_long(GetBitContext *s, int n){ + OPEN_READER(re, s) + re_bit_count += n; + re_buffer_ptr += 2*(re_bit_count>>4); + re_bit_count &= 15; + re_cache = ((re_buffer_ptr[-2]<<8) + re_buffer_ptr[-1]) << (16+re_bit_count); + UPDATE_CACHE(re, s) + CLOSE_READER(re, s) +} + +#elif defined A32_BITSTREAM_READER + +# define MIN_CACHE_BITS 32 + +# define OPEN_READER(name, gb)\ + int name##_bit_count=(gb)->bit_count;\ + uint32_t name##_cache0= (gb)->cache0;\ + uint32_t name##_cache1= (gb)->cache1;\ + uint32_t * name##_buffer_ptr=(gb)->buffer_ptr;\ + +# define CLOSE_READER(name, gb)\ + (gb)->bit_count= name##_bit_count;\ + (gb)->cache0= name##_cache0;\ + (gb)->cache1= name##_cache1;\ + (gb)->buffer_ptr= name##_buffer_ptr;\ + +# define UPDATE_CACHE(name, gb)\ + if(name##_bit_count > 0){\ + const uint32_t next= av_be2ne32( *name##_buffer_ptr );\ + name##_cache0 |= NEG_USR32(next,name##_bit_count);\ + name##_cache1 |= next<buffer_ptr - s->buffer)*8 - 32 + s->bit_count; +} + +static inline void skip_bits_long(GetBitContext *s, int n){ + OPEN_READER(re, s) + re_bit_count += n; + re_buffer_ptr += re_bit_count>>5; + re_bit_count &= 31; + re_cache0 = av_be2ne32( re_buffer_ptr[-1] ) << re_bit_count; + re_cache1 = 0; + UPDATE_CACHE(re, s) + CLOSE_READER(re, s) +} + +#endif + +/** + * read mpeg1 dc style vlc (sign bit + mantisse with no MSB). + * if MSB not set it is negative + * @param n length in bits + * @author BERO + */ +static inline int get_xbits(GetBitContext *s, int n){ + register int sign; + register int32_t cache; + OPEN_READER(re, s) + UPDATE_CACHE(re, s) + cache = GET_CACHE(re,s); + sign=(~cache)>>31; + LAST_SKIP_BITS(re, s, n) + CLOSE_READER(re, s) + return (NEG_USR32(sign ^ cache, n) ^ sign) - sign; +} + +static inline int get_sbits(GetBitContext *s, int n){ + register int tmp; + OPEN_READER(re, s) + UPDATE_CACHE(re, s) + tmp= SHOW_SBITS(re, s, n); + LAST_SKIP_BITS(re, s, n) + CLOSE_READER(re, s) + return tmp; +} + +/** + * reads 1-17 bits. + * Note, the alt bitstream reader can read up to 25 bits, but the libmpeg2 reader can't + */ +static inline unsigned int get_bits(GetBitContext *s, int n){ + register int tmp; + OPEN_READER(re, s) + UPDATE_CACHE(re, s) + tmp= SHOW_UBITS(re, s, n); + LAST_SKIP_BITS(re, s, n) + CLOSE_READER(re, s) + return tmp; +} + +/** + * shows 1-17 bits. + * Note, the alt bitstream reader can read up to 25 bits, but the libmpeg2 reader can't + */ +static inline unsigned int show_bits(GetBitContext *s, int n){ + register int tmp; + OPEN_READER(re, s) + UPDATE_CACHE(re, s) + tmp= SHOW_UBITS(re, s, n); +// CLOSE_READER(re, s) + return tmp; +} + +static inline void skip_bits(GetBitContext *s, int n){ + //Note gcc seems to optimize this to s->index+=n for the ALT_READER :)) + OPEN_READER(re, s) + UPDATE_CACHE(re, s) + LAST_SKIP_BITS(re, s, n) + CLOSE_READER(re, s) +} + +static inline unsigned int get_bits1(GetBitContext *s){ +#ifdef ALT_BITSTREAM_READER + unsigned int index= s->index; + uint8_t result= s->buffer[ index>>3 ]; +#ifdef ALT_BITSTREAM_READER_LE + result>>= (index&0x07); + result&= 1; +#else + result<<= (index&0x07); + result>>= 8 - 1; +#endif + index++; + s->index= index; + + return result; +#else + return get_bits(s, 1); +#endif +} + +static inline unsigned int show_bits1(GetBitContext *s){ + return show_bits(s, 1); +} + +static inline void skip_bits1(GetBitContext *s){ + skip_bits(s, 1); +} + +/** + * reads 0-32 bits. + */ +static inline unsigned int get_bits_long(GetBitContext *s, int n){ + if(n<=MIN_CACHE_BITS) return get_bits(s, n); + else{ +#ifdef ALT_BITSTREAM_READER_LE + int ret= get_bits(s, 16); + return ret | (get_bits(s, n-16) << 16); +#else + int ret= get_bits(s, 16) << (n-16); + return ret | get_bits(s, n-16); +#endif + } +} + +/** + * reads 0-32 bits as a signed integer. + */ +static inline int get_sbits_long(GetBitContext *s, int n) { + return sign_extend(get_bits_long(s, n), n); +} + +/** + * shows 0-32 bits. + */ +static inline unsigned int show_bits_long(GetBitContext *s, int n){ + if(n<=MIN_CACHE_BITS) return show_bits(s, n); + else{ + GetBitContext gb= *s; + return get_bits_long(&gb, n); + } +} + +static inline int check_marker(GetBitContext *s, const char *msg) +{ + int bit= get_bits1(s); + if(!bit) + av_log(NULL, AV_LOG_INFO, "Marker bit missing %s\n", msg); + + return bit; +} + +/** + * init GetBitContext. + * @param buffer bitstream buffer, must be FF_INPUT_BUFFER_PADDING_SIZE bytes larger then the actual read bits + * because some optimized bitstream readers read 32 or 64 bit at once and could read over the end + * @param bit_size the size of the buffer in bits + * + * While GetBitContext stores the buffer size, for performance reasons you are + * responsible for checking for the buffer end yourself (take advantage of the padding)! + */ +static inline void init_get_bits(GetBitContext *s, + const uint8_t *buffer, int bit_size) +{ + int buffer_size= (bit_size+7)>>3; + if(buffer_size < 0 || bit_size < 0) { + buffer_size = bit_size = 0; + buffer = NULL; + } + + s->buffer= buffer; + s->size_in_bits= bit_size; + s->buffer_end= buffer + buffer_size; +#ifdef ALT_BITSTREAM_READER + s->index=0; +#elif defined LIBMPEG2_BITSTREAM_READER + s->buffer_ptr = (uint8_t*)((intptr_t)buffer&(~1)); + s->bit_count = 16 + 8*((intptr_t)buffer&1); + skip_bits_long(s, 0); +#elif defined A32_BITSTREAM_READER + s->buffer_ptr = (uint32_t*)((intptr_t)buffer&(~3)); + s->bit_count = 32 + 8*((intptr_t)buffer&3); + skip_bits_long(s, 0); +#endif +} + +static inline void align_get_bits(GetBitContext *s) +{ + int n= (-get_bits_count(s)) & 7; + if(n) skip_bits(s, n); +} + +#define init_vlc(vlc, nb_bits, nb_codes,\ + bits, bits_wrap, bits_size,\ + codes, codes_wrap, codes_size,\ + flags)\ + init_vlc_sparse(vlc, nb_bits, nb_codes,\ + bits, bits_wrap, bits_size,\ + codes, codes_wrap, codes_size,\ + NULL, 0, 0, flags) + +int init_vlc_sparse(VLC *vlc, int nb_bits, int nb_codes, + const void *bits, int bits_wrap, int bits_size, + const void *codes, int codes_wrap, int codes_size, + const void *symbols, int symbols_wrap, int symbols_size, + int flags); +#define INIT_VLC_LE 2 +#define INIT_VLC_USE_NEW_STATIC 4 +void free_vlc(VLC *vlc); + +#define INIT_VLC_STATIC(vlc, bits, a,b,c,d,e,f,g, static_size)\ +{\ + static VLC_TYPE table[static_size][2];\ + (vlc)->table= table;\ + (vlc)->table_allocated= static_size;\ + init_vlc(vlc, bits, a,b,c,d,e,f,g, INIT_VLC_USE_NEW_STATIC);\ +} + + +/** + * + * If the vlc code is invalid and max_depth=1, then no bits will be removed. + * If the vlc code is invalid and max_depth>1, then the number of bits removed + * is undefined. + */ +#define GET_VLC(code, name, gb, table, bits, max_depth)\ +{\ + int n, nb_bits;\ + unsigned int index;\ +\ + index= SHOW_UBITS(name, gb, bits);\ + code = table[index][0];\ + n = table[index][1];\ +\ + if(max_depth > 1 && n < 0){\ + LAST_SKIP_BITS(name, gb, bits)\ + UPDATE_CACHE(name, gb)\ +\ + nb_bits = -n;\ +\ + index= SHOW_UBITS(name, gb, nb_bits) + code;\ + code = table[index][0];\ + n = table[index][1];\ + if(max_depth > 2 && n < 0){\ + LAST_SKIP_BITS(name, gb, nb_bits)\ + UPDATE_CACHE(name, gb)\ +\ + nb_bits = -n;\ +\ + index= SHOW_UBITS(name, gb, nb_bits) + code;\ + code = table[index][0];\ + n = table[index][1];\ + }\ + }\ + SKIP_BITS(name, gb, n)\ +} + +#define GET_RL_VLC(level, run, name, gb, table, bits, max_depth, need_update)\ +{\ + int n, nb_bits;\ + unsigned int index;\ +\ + index= SHOW_UBITS(name, gb, bits);\ + level = table[index].level;\ + n = table[index].len;\ +\ + if(max_depth > 1 && n < 0){\ + SKIP_BITS(name, gb, bits)\ + if(need_update){\ + UPDATE_CACHE(name, gb)\ + }\ +\ + nb_bits = -n;\ +\ + index= SHOW_UBITS(name, gb, nb_bits) + level;\ + level = table[index].level;\ + n = table[index].len;\ + }\ + run= table[index].run;\ + SKIP_BITS(name, gb, n)\ +} + + +/** + * parses a vlc code, faster then get_vlc() + * @param bits is the number of bits which will be read at once, must be + * identical to nb_bits in init_vlc() + * @param max_depth is the number of times bits bits must be read to completely + * read the longest vlc code + * = (max_vlc_length + bits - 1) / bits + */ +static av_always_inline int get_vlc2(GetBitContext *s, VLC_TYPE (*table)[2], + int bits, int max_depth) +{ + int code; + + OPEN_READER(re, s) + UPDATE_CACHE(re, s) + + GET_VLC(code, re, s, table, bits, max_depth) + + CLOSE_READER(re, s) + return code; +} + +//#define TRACE + +#ifdef TRACE +static inline void print_bin(int bits, int n){ + int i; + + for(i=n-1; i>=0; i--){ + av_log(NULL, AV_LOG_DEBUG, "%d", (bits>>i)&1); + } + for(i=n; i<24; i++) + av_log(NULL, AV_LOG_DEBUG, " "); +} + +static inline int get_bits_trace(GetBitContext *s, int n, char *file, const char *func, int line){ + int r= get_bits(s, n); + + print_bin(r, n); + av_log(NULL, AV_LOG_DEBUG, "%5d %2d %3d bit @%5d in %s %s:%d\n", r, n, r, get_bits_count(s)-n, file, func, line); + return r; +} +static inline int get_vlc_trace(GetBitContext *s, VLC_TYPE (*table)[2], int bits, int max_depth, char *file, const char *func, int line){ + int show= show_bits(s, 24); + int pos= get_bits_count(s); + int r= get_vlc2(s, table, bits, max_depth); + int len= get_bits_count(s) - pos; + int bits2= show>>(24-len); + + print_bin(bits2, len); + + av_log(NULL, AV_LOG_DEBUG, "%5d %2d %3d vlc @%5d in %s %s:%d\n", bits2, len, r, pos, file, func, line); + return r; +} +static inline int get_xbits_trace(GetBitContext *s, int n, char *file, const char *func, int line){ + int show= show_bits(s, n); + int r= get_xbits(s, n); + + print_bin(show, n); + av_log(NULL, AV_LOG_DEBUG, "%5d %2d %3d xbt @%5d in %s %s:%d\n", show, n, r, get_bits_count(s)-n, file, func, line); + return r; +} + +#define get_bits(s, n) get_bits_trace(s, n, __FILE__, __PRETTY_FUNCTION__, __LINE__) +#define get_bits1(s) get_bits_trace(s, 1, __FILE__, __PRETTY_FUNCTION__, __LINE__) +#define get_xbits(s, n) get_xbits_trace(s, n, __FILE__, __PRETTY_FUNCTION__, __LINE__) +#define get_vlc(s, vlc) get_vlc_trace(s, (vlc)->table, (vlc)->bits, 3, __FILE__, __PRETTY_FUNCTION__, __LINE__) +#define get_vlc2(s, tab, bits, max) get_vlc_trace(s, tab, bits, max, __FILE__, __PRETTY_FUNCTION__, __LINE__) + +#define tprintf(p, ...) av_log(p, AV_LOG_DEBUG, __VA_ARGS__) + +#else //TRACE +#define tprintf(p, ...) {} +#endif + +static inline int decode012(GetBitContext *gb){ + int n; + n = get_bits1(gb); + if (n == 0) + return 0; + else + return get_bits1(gb) + 1; +} + +static inline int decode210(GetBitContext *gb){ + if (get_bits1(gb)) + return 0; + else + return 2 - get_bits1(gb); +} + +static inline int get_bits_left(GetBitContext *gb) +{ + return gb->size_in_bits - get_bits_count(gb); +} + +#endif /* AVCODEC_GET_BITS_H */ diff --git a/lib/rbcodec/codecs/libwmavoice/internal.h b/lib/rbcodec/codecs/libwmavoice/internal.h new file mode 100644 index 0000000000..24aca6b28b --- /dev/null +++ b/lib/rbcodec/codecs/libwmavoice/internal.h @@ -0,0 +1,53 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * common internal api header. + */ + +#ifndef AVCODEC_INTERNAL_H +#define AVCODEC_INTERNAL_H + +#include +#include "avcodec.h" + +/** + * Determine whether pix_fmt is a hardware accelerated format. + */ +int ff_is_hwaccel_pix_fmt(enum PixelFormat pix_fmt); + +/** + * Return the hardware accelerated codec for codec codec_id and + * pixel format pix_fmt. + * + * @param codec_id the codec to match + * @param pix_fmt the pixel format to match + * @return the hardware accelerated codec, or NULL if none was found. + */ +AVHWAccel *ff_find_hwaccel(enum CodecID codec_id, enum PixelFormat pix_fmt); + +/** + * Return the index into tab at which {a,b} match elements {[0],[1]} of tab. + * If there is no such matching pair then size is returned. + */ +int ff_match_2uint16(const uint16_t (*tab)[2], int size, int a, int b); + +unsigned int ff_toupper4(unsigned int x); + +#endif /* AVCODEC_INTERNAL_H */ diff --git a/lib/rbcodec/codecs/libwmavoice/libavutil/attributes.h b/lib/rbcodec/codecs/libwmavoice/libavutil/attributes.h new file mode 100644 index 0000000000..a95bb02e89 --- /dev/null +++ b/lib/rbcodec/codecs/libwmavoice/libavutil/attributes.h @@ -0,0 +1,121 @@ +/* + * copyright (c) 2006 Michael Niedermayer + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * Macro definitions for various function/variable attributes + */ + +#ifndef AVUTIL_ATTRIBUTES_H +#define AVUTIL_ATTRIBUTES_H + +#ifdef __GNUC__ +# define AV_GCC_VERSION_AT_LEAST(x,y) (__GNUC__ > x || __GNUC__ == x && __GNUC_MINOR__ >= y) +#else +# define AV_GCC_VERSION_AT_LEAST(x,y) 0 +#endif + +#ifndef av_always_inline +#if AV_GCC_VERSION_AT_LEAST(3,1) +# define av_always_inline __attribute__((always_inline)) inline +#else +# define av_always_inline inline +#endif +#endif + +#ifndef av_noinline +#if AV_GCC_VERSION_AT_LEAST(3,1) +# define av_noinline __attribute__((noinline)) +#else +# define av_noinline +#endif +#endif + +#ifndef av_pure +#if AV_GCC_VERSION_AT_LEAST(3,1) +# define av_pure __attribute__((pure)) +#else +# define av_pure +#endif +#endif + +#ifndef av_const +#if AV_GCC_VERSION_AT_LEAST(2,6) +# define av_const __attribute__((const)) +#else +# define av_const +#endif +#endif + +#ifndef av_cold +#if (!defined(__ICC) || __ICC > 1110) && AV_GCC_VERSION_AT_LEAST(4,3) +# define av_cold __attribute__((cold)) +#else +# define av_cold +#endif +#endif + +#ifndef av_flatten +#if (!defined(__ICC) || __ICC > 1110) && AV_GCC_VERSION_AT_LEAST(4,1) +# define av_flatten __attribute__((flatten)) +#else +# define av_flatten +#endif +#endif + +#ifndef attribute_deprecated +#if AV_GCC_VERSION_AT_LEAST(3,1) +# define attribute_deprecated __attribute__((deprecated)) +#else +# define attribute_deprecated +#endif +#endif + +#ifndef av_unused +#if defined(__GNUC__) +# define av_unused __attribute__((unused)) +#else +# define av_unused +#endif +#endif + +#ifndef av_alias +#if (!defined(__ICC) || __ICC > 1110) && AV_GCC_VERSION_AT_LEAST(3,3) +# define av_alias __attribute__((may_alias)) +#else +# define av_alias +#endif +#endif + +#ifndef av_uninit +#if defined(__GNUC__) && !defined(__ICC) +# define av_uninit(x) x=x +#else +# define av_uninit(x) x +#endif +#endif + +#ifdef __GNUC__ +# define av_builtin_constant_p __builtin_constant_p +#else +# define av_builtin_constant_p(x) 0 +#endif + +#endif /* AVUTIL_ATTRIBUTES_H */ diff --git a/lib/rbcodec/codecs/libwmavoice/libavutil/avutil.h b/lib/rbcodec/codecs/libwmavoice/libavutil/avutil.h new file mode 100644 index 0000000000..457829ac7f --- /dev/null +++ b/lib/rbcodec/codecs/libwmavoice/libavutil/avutil.h @@ -0,0 +1,89 @@ +/* + * copyright (c) 2006 Michael Niedermayer + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_AVUTIL_H +#define AVUTIL_AVUTIL_H + +/** + * @file + * external API header + */ + + +#define AV_STRINGIFY(s) AV_TOSTRING(s) +#define AV_TOSTRING(s) #s + +#define AV_GLUE(a, b) a ## b +#define AV_JOIN(a, b) AV_GLUE(a, b) + +#define AV_PRAGMA(s) _Pragma(#s) + +#define AV_VERSION_INT(a, b, c) (a<<16 | b<<8 | c) +#define AV_VERSION_DOT(a, b, c) a ##.## b ##.## c +#define AV_VERSION(a, b, c) AV_VERSION_DOT(a, b, c) + +#define LIBAVUTIL_VERSION_MAJOR 50 +#define LIBAVUTIL_VERSION_MINOR 23 +#define LIBAVUTIL_VERSION_MICRO 0 + +#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ + LIBAVUTIL_VERSION_MINOR, \ + LIBAVUTIL_VERSION_MICRO) +#define LIBAVUTIL_VERSION AV_VERSION(LIBAVUTIL_VERSION_MAJOR, \ + LIBAVUTIL_VERSION_MINOR, \ + LIBAVUTIL_VERSION_MICRO) +#define LIBAVUTIL_BUILD LIBAVUTIL_VERSION_INT + +#define LIBAVUTIL_IDENT "Lavu" AV_STRINGIFY(LIBAVUTIL_VERSION) + +/** + * Return the LIBAVUTIL_VERSION_INT constant. + */ +unsigned avutil_version(void); + +/** + * Return the libavutil build-time configuration. + */ +const char *avutil_configuration(void); + +/** + * Return the libavutil license. + */ +const char *avutil_license(void); + +enum AVMediaType { + AVMEDIA_TYPE_UNKNOWN = -1, + AVMEDIA_TYPE_VIDEO, + AVMEDIA_TYPE_AUDIO, + AVMEDIA_TYPE_DATA, + AVMEDIA_TYPE_SUBTITLE, + AVMEDIA_TYPE_ATTACHMENT, + AVMEDIA_TYPE_NB +}; + +#include "common.h" +//#include "error.h" +#include "mathematics.h" +//#include "rational.h" +//#include "intfloat_readwrite.h" +#include "log.h" +//#include "pixfmt.h" + +#endif /* AVUTIL_AVUTIL_H */ diff --git a/lib/rbcodec/codecs/libwmavoice/libavutil/bswap.h b/lib/rbcodec/codecs/libwmavoice/libavutil/bswap.h new file mode 100644 index 0000000000..303bcf3532 --- /dev/null +++ b/lib/rbcodec/codecs/libwmavoice/libavutil/bswap.h @@ -0,0 +1,124 @@ +/* + * copyright (c) 2006 Michael Niedermayer + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * byte swapping routines + */ + +#ifndef AVUTIL_BSWAP_H +#define AVUTIL_BSWAP_H + +#include +#include "libavutil/avconfig.h" +#include "attributes.h" + +#ifdef HAVE_AV_CONFIG_H + +#include "config.h" + +#if ARCH_ARM +# include "arm/bswap.h" +#elif ARCH_AVR32 +# include "avr32/bswap.h" +#elif ARCH_BFIN +# include "bfin/bswap.h" +#elif ARCH_SH4 +# include "sh4/bswap.h" +#elif ARCH_X86 +# include "x86/bswap.h" +#endif + +#endif /* HAVE_AV_CONFIG_H */ + +#define AV_BSWAP16C(x) (((x) << 8 & 0xff00) | ((x) >> 8 & 0x00ff)) +#define AV_BSWAP32C(x) (AV_BSWAP16C(x) << 16 | AV_BSWAP16C((x) >> 16)) +#define AV_BSWAP64C(x) (AV_BSWAP32C(x) << 32 | AV_BSWAP32C((x) >> 32)) + +#define AV_BSWAPC(s, x) AV_BSWAP##s##C(x) + +#ifndef av_bswap16 +static av_always_inline av_const uint16_t av_bswap16(uint16_t x) +{ + x= (x>>8) | (x<<8); + return x; +} +#endif + +#ifndef av_bswap32 +static av_always_inline av_const uint32_t av_bswap32(uint32_t x) +{ + x= ((x<<8)&0xFF00FF00) | ((x>>8)&0x00FF00FF); + x= (x>>16) | (x<<16); + return x; +} +#endif + +#ifndef av_bswap64 +static inline uint64_t av_const av_bswap64(uint64_t x) +{ +#if 0 + x= ((x<< 8)&0xFF00FF00FF00FF00ULL) | ((x>> 8)&0x00FF00FF00FF00FFULL); + x= ((x<<16)&0xFFFF0000FFFF0000ULL) | ((x>>16)&0x0000FFFF0000FFFFULL); + return (x>>32) | (x<<32); +#else + union { + uint64_t ll; + uint32_t l[2]; + } w, r; + w.ll = x; + r.l[0] = av_bswap32 (w.l[1]); + r.l[1] = av_bswap32 (w.l[0]); + return r.ll; +#endif +} +#endif + +// be2ne ... big-endian to native-endian +// le2ne ... little-endian to native-endian + +#if AV_HAVE_BIGENDIAN +#define av_be2ne16(x) (x) +#define av_be2ne32(x) (x) +#define av_be2ne64(x) (x) +#define av_le2ne16(x) av_bswap16(x) +#define av_le2ne32(x) av_bswap32(x) +#define av_le2ne64(x) av_bswap64(x) +#define AV_BE2NEC(s, x) (x) +#define AV_LE2NEC(s, x) AV_BSWAPC(s, x) +#else +#define av_be2ne16(x) av_bswap16(x) +#define av_be2ne32(x) av_bswap32(x) +#define av_be2ne64(x) av_bswap64(x) +#define av_le2ne16(x) (x) +#define av_le2ne32(x) (x) +#define av_le2ne64(x) (x) +#define AV_BE2NEC(s, x) AV_BSWAPC(s, x) +#define AV_LE2NEC(s, x) (x) +#endif + +#define AV_BE2NE16C(x) AV_BE2NEC(16, x) +#define AV_BE2NE32C(x) AV_BE2NEC(32, x) +#define AV_BE2NE64C(x) AV_BE2NEC(64, x) +#define AV_LE2NE16C(x) AV_LE2NEC(16, x) +#define AV_LE2NE32C(x) AV_LE2NEC(32, x) +#define AV_LE2NE64C(x) AV_LE2NEC(64, x) + +#endif /* AVUTIL_BSWAP_H */ diff --git a/lib/rbcodec/codecs/libwmavoice/libavutil/common.h b/lib/rbcodec/codecs/libwmavoice/libavutil/common.h new file mode 100644 index 0000000000..f9c03db559 --- /dev/null +++ b/lib/rbcodec/codecs/libwmavoice/libavutil/common.h @@ -0,0 +1,346 @@ +/* + * copyright (c) 2006 Michael Niedermayer + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * common internal and external API header + */ + +#ifndef AVUTIL_COMMON_H +#define AVUTIL_COMMON_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include "attributes.h" + +//rounded division & shift +#define RSHIFT(a,b) ((a) > 0 ? ((a) + ((1<<(b))>>1))>>(b) : ((a) + ((1<<(b))>>1)-1)>>(b)) +/* assume b>0 */ +#define ROUNDED_DIV(a,b) (((a)>0 ? (a) + ((b)>>1) : (a) - ((b)>>1))/(b)) +#define FFABS(a) ((a) >= 0 ? (a) : (-(a))) +#define FFSIGN(a) ((a) > 0 ? 1 : -1) + +#define FFMAX(a,b) ((a) > (b) ? (a) : (b)) +#define FFMAX3(a,b,c) FFMAX(FFMAX(a,b),c) +#define FFMIN(a,b) ((a) > (b) ? (b) : (a)) +#define FFMIN3(a,b,c) FFMIN(FFMIN(a,b),c) + +#define FFSWAP(type,a,b) do{type SWAP_tmp= b; b= a; a= SWAP_tmp;}while(0) +#define FF_ARRAY_ELEMS(a) (sizeof(a) / sizeof((a)[0])) +#define FFALIGN(x, a) (((x)+(a)-1)&~((a)-1)) + +/* misc math functions */ +extern const uint8_t ff_log2_tab[256]; + +extern const uint8_t av_reverse[256]; + +static inline av_const int av_log2_c(unsigned int v) +{ + int n = 0; + if (v & 0xffff0000) { + v >>= 16; + n += 16; + } + if (v & 0xff00) { + v >>= 8; + n += 8; + } + n += ff_log2_tab[v]; + + return n; +} + +static inline av_const int av_log2_16bit_c(unsigned int v) +{ + int n = 0; + if (v & 0xff00) { + v >>= 8; + n += 8; + } + n += ff_log2_tab[v]; + + return n; +} + +#ifdef HAVE_AV_CONFIG_H +# include "config.h" +# include "intmath.h" +#endif + +/* Pull in unguarded fallback defines at the end of this file. */ +#include "common.h" + +/** + * Clip a signed integer value into the amin-amax range. + * @param a value to clip + * @param amin minimum value of the clip range + * @param amax maximum value of the clip range + * @return clipped value + */ +static inline av_const int av_clip_c(int a, int amin, int amax) +{ + if (a < amin) return amin; + else if (a > amax) return amax; + else return a; +} + +/** + * Clip a signed integer value into the 0-255 range. + * @param a value to clip + * @return clipped value + */ +static inline av_const uint8_t av_clip_uint8_c(int a) +{ + if (a&(~0xFF)) return (-a)>>31; + else return a; +} + +/** + * Clip a signed integer value into the -128,127 range. + * @param a value to clip + * @return clipped value + */ +static inline av_const int8_t av_clip_int8_c(int a) +{ + if ((a+0x80) & ~0xFF) return (a>>31) ^ 0x7F; + else return a; +} + +/** + * Clip a signed integer value into the 0-65535 range. + * @param a value to clip + * @return clipped value + */ +static inline av_const uint16_t av_clip_uint16_c(int a) +{ + if (a&(~0xFFFF)) return (-a)>>31; + else return a; +} + +/** + * Clip a signed integer value into the -32768,32767 range. + * @param a value to clip + * @return clipped value + */ +static inline av_const int16_t av_clip_int16_c(int a) +{ + if ((a+0x8000) & ~0xFFFF) return (a>>31) ^ 0x7FFF; + else return a; +} + +/** + * Clip a signed 64-bit integer value into the -2147483648,2147483647 range. + * @param a value to clip + * @return clipped value + */ +static inline av_const int32_t av_clipl_int32_c(int64_t a) +{ + if ((a+0x80000000u) & ~UINT64_C(0xFFFFFFFF)) return (a>>63) ^ 0x7FFFFFFF; + else return a; +} + +/** + * Clip a float value into the amin-amax range. + * @param a value to clip + * @param amin minimum value of the clip range + * @param amax maximum value of the clip range + * @return clipped value + */ +static inline av_const float av_clipf_c(float a, float amin, float amax) +{ + if (a < amin) return amin; + else if (a > amax) return amax; + else return a; +} + +/** Compute ceil(log2(x)). + * @param x value used to compute ceil(log2(x)) + * @return computed ceiling of log2(x) + */ +static inline av_const int av_ceil_log2_c(int x) +{ + return av_log2((x - 1) << 1); +} + +#define MKTAG(a,b,c,d) ((a) | ((b) << 8) | ((c) << 16) | ((d) << 24)) +#define MKBETAG(a,b,c,d) ((d) | ((c) << 8) | ((b) << 16) | ((a) << 24)) + +/** + * Convert a UTF-8 character (up to 4 bytes) to its 32-bit UCS-4 encoded form. + * + * @param val Output value, must be an lvalue of type uint32_t. + * @param GET_BYTE Expression reading one byte from the input. + * Evaluated up to 7 times (4 for the currently + * assigned Unicode range). With a memory buffer + * input, this could be *ptr++. + * @param ERROR Expression to be evaluated on invalid input, + * typically a goto statement. + */ +#define GET_UTF8(val, GET_BYTE, ERROR)\ + val= GET_BYTE;\ + {\ + int ones= 7 - av_log2(val ^ 255);\ + if(ones==1)\ + ERROR\ + val&= 127>>ones;\ + while(--ones > 0){\ + int tmp= GET_BYTE - 128;\ + if(tmp>>6)\ + ERROR\ + val= (val<<6) + tmp;\ + }\ + } + +/** + * Convert a UTF-16 character (2 or 4 bytes) to its 32-bit UCS-4 encoded form. + * + * @param val Output value, must be an lvalue of type uint32_t. + * @param GET_16BIT Expression returning two bytes of UTF-16 data converted + * to native byte order. Evaluated one or two times. + * @param ERROR Expression to be evaluated on invalid input, + * typically a goto statement. + */ +#define GET_UTF16(val, GET_16BIT, ERROR)\ + val = GET_16BIT;\ + {\ + unsigned int hi = val - 0xD800;\ + if (hi < 0x800) {\ + val = GET_16BIT - 0xDC00;\ + if (val > 0x3FFU || hi > 0x3FFU)\ + ERROR\ + val += (hi<<10) + 0x10000;\ + }\ + }\ + +/*! + * \def PUT_UTF8(val, tmp, PUT_BYTE) + * Convert a 32-bit Unicode character to its UTF-8 encoded form (up to 4 bytes long). + * \param val is an input-only argument and should be of type uint32_t. It holds + * a UCS-4 encoded Unicode character that is to be converted to UTF-8. If + * val is given as a function it is executed only once. + * \param tmp is a temporary variable and should be of type uint8_t. It + * represents an intermediate value during conversion that is to be + * output by PUT_BYTE. + * \param PUT_BYTE writes the converted UTF-8 bytes to any proper destination. + * It could be a function or a statement, and uses tmp as the input byte. + * For example, PUT_BYTE could be "*output++ = tmp;" PUT_BYTE will be + * executed up to 4 times for values in the valid UTF-8 range and up to + * 7 times in the general case, depending on the length of the converted + * Unicode character. + */ +#define PUT_UTF8(val, tmp, PUT_BYTE)\ + {\ + int bytes, shift;\ + uint32_t in = val;\ + if (in < 0x80) {\ + tmp = in;\ + PUT_BYTE\ + } else {\ + bytes = (av_log2(in) + 4) / 5;\ + shift = (bytes - 1) * 6;\ + tmp = (256 - (256 >> bytes)) | (in >> shift);\ + PUT_BYTE\ + while (shift >= 6) {\ + shift -= 6;\ + tmp = 0x80 | ((in >> shift) & 0x3f);\ + PUT_BYTE\ + }\ + }\ + } + +/*! + * \def PUT_UTF16(val, tmp, PUT_16BIT) + * Convert a 32-bit Unicode character to its UTF-16 encoded form (2 or 4 bytes). + * \param val is an input-only argument and should be of type uint32_t. It holds + * a UCS-4 encoded Unicode character that is to be converted to UTF-16. If + * val is given as a function it is executed only once. + * \param tmp is a temporary variable and should be of type uint16_t. It + * represents an intermediate value during conversion that is to be + * output by PUT_16BIT. + * \param PUT_16BIT writes the converted UTF-16 data to any proper destination + * in desired endianness. It could be a function or a statement, and uses tmp + * as the input byte. For example, PUT_BYTE could be "*output++ = tmp;" + * PUT_BYTE will be executed 1 or 2 times depending on input character. + */ +#define PUT_UTF16(val, tmp, PUT_16BIT)\ + {\ + uint32_t in = val;\ + if (in < 0x10000) {\ + tmp = in;\ + PUT_16BIT\ + } else {\ + tmp = 0xD800 | ((in - 0x10000) >> 10);\ + PUT_16BIT\ + tmp = 0xDC00 | ((in - 0x10000) & 0x3FF);\ + PUT_16BIT\ + }\ + }\ + + + +#include "mem.h" + +#ifdef HAVE_AV_CONFIG_H +# include "internal.h" +#endif /* HAVE_AV_CONFIG_H */ + +#endif /* AVUTIL_COMMON_H */ + +/* + * The following definitions are outside the multiple inclusion guard + * to ensure they are immediately available in intmath.h. + */ + +#ifndef av_log2 +# define av_log2 av_log2_c +#endif +#ifndef av_log2_16bit +# define av_log2_16bit av_log2_16bit_c +#endif +#ifndef av_ceil_log2 +# define av_ceil_log2 av_ceil_log2_c +#endif +#ifndef av_clip +# define av_clip av_clip_c +#endif +#ifndef av_clip_uint8 +# define av_clip_uint8 av_clip_uint8_c +#endif +#ifndef av_clip_int8 +# define av_clip_int8 av_clip_int8_c +#endif +#ifndef av_clip_uint16 +# define av_clip_uint16 av_clip_uint16_c +#endif +#ifndef av_clip_int16 +# define av_clip_int16 av_clip_int16_c +#endif +#ifndef av_clipl_int32 +# define av_clipl_int32 av_clipl_int32_c +#endif +#ifndef av_clipf +# define av_clipf av_clipf_c +#endif diff --git a/lib/rbcodec/codecs/libwmavoice/libavutil/internal.h b/lib/rbcodec/codecs/libwmavoice/libavutil/internal.h new file mode 100644 index 0000000000..53d2b94c50 --- /dev/null +++ b/lib/rbcodec/codecs/libwmavoice/libavutil/internal.h @@ -0,0 +1,234 @@ +/* + * copyright (c) 2006 Michael Niedermayer + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * common internal API header + */ + +#ifndef AVUTIL_INTERNAL_H +#define AVUTIL_INTERNAL_H + +#if !defined(DEBUG) && !defined(NDEBUG) +# define NDEBUG +#endif + +#include +#include +#include +#include +#include "config.h" +#include "attributes.h" +#include "timer.h" + +#ifndef attribute_align_arg +#if ARCH_X86_32 && (!defined(__ICC) || __ICC > 1110) && AV_GCC_VERSION_AT_LEAST(4,2) +# define attribute_align_arg __attribute__((force_align_arg_pointer)) +#else +# define attribute_align_arg +#endif +#endif + + +/** + * Mark a variable as used and prevent the compiler from optimizing it away. + * This is useful for asm that accesses varibles in ways that the compiler does not + * understand + */ +#ifndef attribute_used +#if AV_GCC_VERSION_AT_LEAST(3,1) +# define attribute_used __attribute__((used)) +#else +# define attribute_used +#endif +#endif + +#ifndef INT16_MIN +#define INT16_MIN (-0x7fff - 1) +#endif + +#ifndef INT16_MAX +#define INT16_MAX 0x7fff +#endif + +#ifndef INT32_MIN +#define INT32_MIN (-0x7fffffff - 1) +#endif + +#ifndef INT32_MAX +#define INT32_MAX 0x7fffffff +#endif + +#ifndef UINT32_MAX +#define UINT32_MAX 0xffffffff +#endif + +#ifndef INT64_MIN +#define INT64_MIN (-0x7fffffffffffffffLL - 1) +#endif + +#ifndef INT64_MAX +#define INT64_MAX INT64_C(9223372036854775807) +#endif + +#ifndef UINT64_MAX +#define UINT64_MAX UINT64_C(0xFFFFFFFFFFFFFFFF) +#endif + +#ifndef INT_BIT +# define INT_BIT (CHAR_BIT * sizeof(int)) +#endif + +#ifndef offsetof +# define offsetof(T, F) ((unsigned int)((char *)&((T *)0)->F)) +#endif + +/* Use to export labels from asm. */ +#define LABEL_MANGLE(a) EXTERN_PREFIX #a + +// Use rip-relative addressing if compiling PIC code on x86-64. +#if ARCH_X86_64 && defined(PIC) +# define LOCAL_MANGLE(a) #a "(%%rip)" +#else +# define LOCAL_MANGLE(a) #a +#endif + +#define MANGLE(a) EXTERN_PREFIX LOCAL_MANGLE(a) + +/* debug stuff */ + +/* dprintf macros */ +#ifdef DEBUG +# define dprintf(pctx, ...) av_log(pctx, AV_LOG_DEBUG, __VA_ARGS__) +#else +# define dprintf(pctx, ...) +#endif + +#define av_abort() do { av_log(NULL, AV_LOG_ERROR, "Abort at %s:%d\n", __FILE__, __LINE__); abort(); } while (0) + +/* math */ + +#if ARCH_X86 +#define MASK_ABS(mask, level)\ + __asm__ volatile(\ + "cltd \n\t"\ + "xorl %1, %0 \n\t"\ + "subl %1, %0 \n\t"\ + : "+a" (level), "=&d" (mask)\ + ); +#else +#define MASK_ABS(mask, level)\ + mask = level >> 31;\ + level = (level ^ mask) - mask; +#endif + +/* avoid usage of dangerous/inappropriate system functions */ +#undef malloc +#define malloc please_use_av_malloc +#undef free +#define free please_use_av_free +#undef realloc +#define realloc please_use_av_realloc +#undef time +#define time time_is_forbidden_due_to_security_issues +#undef rand +#define rand rand_is_forbidden_due_to_state_trashing_use_av_lfg_get +#undef srand +#define srand srand_is_forbidden_due_to_state_trashing_use_av_lfg_init +#undef random +#define random random_is_forbidden_due_to_state_trashing_use_av_lfg_get +#undef sprintf +#define sprintf sprintf_is_forbidden_due_to_security_issues_use_snprintf +#undef strcat +#define strcat strcat_is_forbidden_due_to_security_issues_use_av_strlcat +#undef exit +#define exit exit_is_forbidden +#ifndef LIBAVFORMAT_BUILD +#undef printf +#define printf please_use_av_log_instead_of_printf +#undef fprintf +#define fprintf please_use_av_log_instead_of_fprintf +#undef puts +#define puts please_use_av_log_instead_of_puts +#undef perror +#define perror please_use_av_log_instead_of_perror +#endif + +#define FF_ALLOC_OR_GOTO(ctx, p, size, label)\ +{\ + p = av_malloc(size);\ + if (p == NULL && (size) != 0) {\ + av_log(ctx, AV_LOG_ERROR, "Cannot allocate memory.\n");\ + goto label;\ + }\ +} + +#define FF_ALLOCZ_OR_GOTO(ctx, p, size, label)\ +{\ + p = av_mallocz(size);\ + if (p == NULL && (size) != 0) {\ + av_log(ctx, AV_LOG_ERROR, "Cannot allocate memory.\n");\ + goto label;\ + }\ +} + +#include "libm.h" + +/** + * Return NULL if CONFIG_SMALL is true, otherwise the argument + * without modification. Used to disable the definition of strings + * (for example AVCodec long_names). + */ +#if CONFIG_SMALL +# define NULL_IF_CONFIG_SMALL(x) NULL +#else +# define NULL_IF_CONFIG_SMALL(x) x +#endif + + +/** + * Define a function with only the non-default version specified. + * + * On systems with ELF shared libraries, all symbols exported from + * FFmpeg libraries are tagged with the name and major version of the + * library to which they belong. If a function is moved from one + * library to another, a wrapper must be retained in the original + * location to preserve binary compatibility. + * + * Functions defined with this macro will never be used to resolve + * symbols by the build-time linker. + * + * @param type return type of function + * @param name name of function + * @param args argument list of function + * @param ver version tag to assign function + */ +#if HAVE_SYMVER_ASM_LABEL +# define FF_SYMVER(type, name, args, ver) \ + type ff_##name args __asm__ (EXTERN_PREFIX #name "@" ver); \ + type ff_##name args +#elif HAVE_SYMVER_GNU_ASM +# define FF_SYMVER(type, name, args, ver) \ + __asm__ (".symver ff_" #name "," EXTERN_PREFIX #name "@" ver); \ + type ff_##name args; \ + type ff_##name args +#endif + +#endif /* AVUTIL_INTERNAL_H */ diff --git a/lib/rbcodec/codecs/libwmavoice/libavutil/intreadwrite.h b/lib/rbcodec/codecs/libwmavoice/libavutil/intreadwrite.h new file mode 100644 index 0000000000..1849a64661 --- /dev/null +++ b/lib/rbcodec/codecs/libwmavoice/libavutil/intreadwrite.h @@ -0,0 +1,522 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_INTREADWRITE_H +#define AVUTIL_INTREADWRITE_H + +#include +#include "libavutil/avconfig.h" +#include "attributes.h" +#include "bswap.h" + +typedef union { + uint64_t u64; + uint32_t u32[2]; + uint16_t u16[4]; + uint8_t u8 [8]; + double f64; + float f32[2]; +} av_alias av_alias64; + +typedef union { + uint32_t u32; + uint16_t u16[2]; + uint8_t u8 [4]; + float f32; +} av_alias av_alias32; + +typedef union { + uint16_t u16; + uint8_t u8 [2]; +} av_alias av_alias16; + +/* + * Arch-specific headers can provide any combination of + * AV_[RW][BLN](16|24|32|64) and AV_(COPY|SWAP|ZERO)(64|128) macros. + * Preprocessor symbols must be defined, even if these are implemented + * as inline functions. + */ + +#ifdef HAVE_AV_CONFIG_H + +#include "config.h" + +#if ARCH_ARM +# include "arm/intreadwrite.h" +#elif ARCH_AVR32 +# include "avr32/intreadwrite.h" +#elif ARCH_MIPS +# include "mips/intreadwrite.h" +#elif ARCH_PPC +# include "ppc/intreadwrite.h" +#elif ARCH_TOMI +# include "tomi/intreadwrite.h" +#elif ARCH_X86 +# include "x86/intreadwrite.h" +#endif + +#endif /* HAVE_AV_CONFIG_H */ + +/* + * Map AV_RNXX <-> AV_R[BL]XX for all variants provided by per-arch headers. + */ + +#if AV_HAVE_BIGENDIAN + +# if defined(AV_RN16) && !defined(AV_RB16) +# define AV_RB16(p) AV_RN16(p) +# elif !defined(AV_RN16) && defined(AV_RB16) +# define AV_RN16(p) AV_RB16(p) +# endif + +# if defined(AV_WN16) && !defined(AV_WB16) +# define AV_WB16(p, v) AV_WN16(p, v) +# elif !defined(AV_WN16) && defined(AV_WB16) +# define AV_WN16(p, v) AV_WB16(p, v) +# endif + +# if defined(AV_RN24) && !defined(AV_RB24) +# define AV_RB24(p) AV_RN24(p) +# elif !defined(AV_RN24) && defined(AV_RB24) +# define AV_RN24(p) AV_RB24(p) +# endif + +# if defined(AV_WN24) && !defined(AV_WB24) +# define AV_WB24(p, v) AV_WN24(p, v) +# elif !defined(AV_WN24) && defined(AV_WB24) +# define AV_WN24(p, v) AV_WB24(p, v) +# endif + +# if defined(AV_RN32) && !defined(AV_RB32) +# define AV_RB32(p) AV_RN32(p) +# elif !defined(AV_RN32) && defined(AV_RB32) +# define AV_RN32(p) AV_RB32(p) +# endif + +# if defined(AV_WN32) && !defined(AV_WB32) +# define AV_WB32(p, v) AV_WN32(p, v) +# elif !defined(AV_WN32) && defined(AV_WB32) +# define AV_WN32(p, v) AV_WB32(p, v) +# endif + +# if defined(AV_RN64) && !defined(AV_RB64) +# define AV_RB64(p) AV_RN64(p) +# elif !defined(AV_RN64) && defined(AV_RB64) +# define AV_RN64(p) AV_RB64(p) +# endif + +# if defined(AV_WN64) && !defined(AV_WB64) +# define AV_WB64(p, v) AV_WN64(p, v) +# elif !defined(AV_WN64) && defined(AV_WB64) +# define AV_WN64(p, v) AV_WB64(p, v) +# endif + +#else /* AV_HAVE_BIGENDIAN */ + +# if defined(AV_RN16) && !defined(AV_RL16) +# define AV_RL16(p) AV_RN16(p) +# elif !defined(AV_RN16) && defined(AV_RL16) +# define AV_RN16(p) AV_RL16(p) +# endif + +# if defined(AV_WN16) && !defined(AV_WL16) +# define AV_WL16(p, v) AV_WN16(p, v) +# elif !defined(AV_WN16) && defined(AV_WL16) +# define AV_WN16(p, v) AV_WL16(p, v) +# endif + +# if defined(AV_RN24) && !defined(AV_RL24) +# define AV_RL24(p) AV_RN24(p) +# elif !defined(AV_RN24) && defined(AV_RL24) +# define AV_RN24(p) AV_RL24(p) +# endif + +# if defined(AV_WN24) && !defined(AV_WL24) +# define AV_WL24(p, v) AV_WN24(p, v) +# elif !defined(AV_WN24) && defined(AV_WL24) +# define AV_WN24(p, v) AV_WL24(p, v) +# endif + +# if defined(AV_RN32) && !defined(AV_RL32) +# define AV_RL32(p) AV_RN32(p) +# elif !defined(AV_RN32) && defined(AV_RL32) +# define AV_RN32(p) AV_RL32(p) +# endif + +# if defined(AV_WN32) && !defined(AV_WL32) +# define AV_WL32(p, v) AV_WN32(p, v) +# elif !defined(AV_WN32) && defined(AV_WL32) +# define AV_WN32(p, v) AV_WL32(p, v) +# endif + +# if defined(AV_RN64) && !defined(AV_RL64) +# define AV_RL64(p) AV_RN64(p) +# elif !defined(AV_RN64) && defined(AV_RL64) +# define AV_RN64(p) AV_RL64(p) +# endif + +# if defined(AV_WN64) && !defined(AV_WL64) +# define AV_WL64(p, v) AV_WN64(p, v) +# elif !defined(AV_WN64) && defined(AV_WL64) +# define AV_WN64(p, v) AV_WL64(p, v) +# endif + +#endif /* !AV_HAVE_BIGENDIAN */ + +/* + * Define AV_[RW]N helper macros to simplify definitions not provided + * by per-arch headers. + */ + +#if defined(__GNUC__) && !defined(__TI_COMPILER_VERSION__) + +union unaligned_64 { uint64_t l; } __attribute__((packed)) av_alias; +union unaligned_32 { uint32_t l; } __attribute__((packed)) av_alias; +union unaligned_16 { uint16_t l; } __attribute__((packed)) av_alias; + +# define AV_RN(s, p) (((const union unaligned_##s *) (p))->l) +# define AV_WN(s, p, v) ((((union unaligned_##s *) (p))->l) = (v)) + +#elif defined(__DECC) + +# define AV_RN(s, p) (*((const __unaligned uint##s##_t*)(p))) +# define AV_WN(s, p, v) (*((__unaligned uint##s##_t*)(p)) = (v)) + +#elif AV_HAVE_FAST_UNALIGNED + +# define AV_RN(s, p) (((const av_alias##s*)(p))->u##s) +# define AV_WN(s, p, v) (((av_alias##s*)(p))->u##s = (v)) + +#else + +#ifndef AV_RB16 +# define AV_RB16(x) \ + ((((const uint8_t*)(x))[0] << 8) | \ + ((const uint8_t*)(x))[1]) +#endif +#ifndef AV_WB16 +# define AV_WB16(p, d) do { \ + ((uint8_t*)(p))[1] = (d); \ + ((uint8_t*)(p))[0] = (d)>>8; \ + } while(0) +#endif + +#ifndef AV_RL16 +# define AV_RL16(x) \ + ((((const uint8_t*)(x))[1] << 8) | \ + ((const uint8_t*)(x))[0]) +#endif +#ifndef AV_WL16 +# define AV_WL16(p, d) do { \ + ((uint8_t*)(p))[0] = (d); \ + ((uint8_t*)(p))[1] = (d)>>8; \ + } while(0) +#endif + +#ifndef AV_RB32 +# define AV_RB32(x) \ + ((((const uint8_t*)(x))[0] << 24) | \ + (((const uint8_t*)(x))[1] << 16) | \ + (((const uint8_t*)(x))[2] << 8) | \ + ((const uint8_t*)(x))[3]) +#endif +#ifndef AV_WB32 +# define AV_WB32(p, d) do { \ + ((uint8_t*)(p))[3] = (d); \ + ((uint8_t*)(p))[2] = (d)>>8; \ + ((uint8_t*)(p))[1] = (d)>>16; \ + ((uint8_t*)(p))[0] = (d)>>24; \ + } while(0) +#endif + +#ifndef AV_RL32 +# define AV_RL32(x) \ + ((((const uint8_t*)(x))[3] << 24) | \ + (((const uint8_t*)(x))[2] << 16) | \ + (((const uint8_t*)(x))[1] << 8) | \ + ((const uint8_t*)(x))[0]) +#endif +#ifndef AV_WL32 +# define AV_WL32(p, d) do { \ + ((uint8_t*)(p))[0] = (d); \ + ((uint8_t*)(p))[1] = (d)>>8; \ + ((uint8_t*)(p))[2] = (d)>>16; \ + ((uint8_t*)(p))[3] = (d)>>24; \ + } while(0) +#endif + +#ifndef AV_RB64 +# define AV_RB64(x) \ + (((uint64_t)((const uint8_t*)(x))[0] << 56) | \ + ((uint64_t)((const uint8_t*)(x))[1] << 48) | \ + ((uint64_t)((const uint8_t*)(x))[2] << 40) | \ + ((uint64_t)((const uint8_t*)(x))[3] << 32) | \ + ((uint64_t)((const uint8_t*)(x))[4] << 24) | \ + ((uint64_t)((const uint8_t*)(x))[5] << 16) | \ + ((uint64_t)((const uint8_t*)(x))[6] << 8) | \ + (uint64_t)((const uint8_t*)(x))[7]) +#endif +#ifndef AV_WB64 +# define AV_WB64(p, d) do { \ + ((uint8_t*)(p))[7] = (d); \ + ((uint8_t*)(p))[6] = (d)>>8; \ + ((uint8_t*)(p))[5] = (d)>>16; \ + ((uint8_t*)(p))[4] = (d)>>24; \ + ((uint8_t*)(p))[3] = (d)>>32; \ + ((uint8_t*)(p))[2] = (d)>>40; \ + ((uint8_t*)(p))[1] = (d)>>48; \ + ((uint8_t*)(p))[0] = (d)>>56; \ + } while(0) +#endif + +#ifndef AV_RL64 +# define AV_RL64(x) \ + (((uint64_t)((const uint8_t*)(x))[7] << 56) | \ + ((uint64_t)((const uint8_t*)(x))[6] << 48) | \ + ((uint64_t)((const uint8_t*)(x))[5] << 40) | \ + ((uint64_t)((const uint8_t*)(x))[4] << 32) | \ + ((uint64_t)((const uint8_t*)(x))[3] << 24) | \ + ((uint64_t)((const uint8_t*)(x))[2] << 16) | \ + ((uint64_t)((const uint8_t*)(x))[1] << 8) | \ + (uint64_t)((const uint8_t*)(x))[0]) +#endif +#ifndef AV_WL64 +# define AV_WL64(p, d) do { \ + ((uint8_t*)(p))[0] = (d); \ + ((uint8_t*)(p))[1] = (d)>>8; \ + ((uint8_t*)(p))[2] = (d)>>16; \ + ((uint8_t*)(p))[3] = (d)>>24; \ + ((uint8_t*)(p))[4] = (d)>>32; \ + ((uint8_t*)(p))[5] = (d)>>40; \ + ((uint8_t*)(p))[6] = (d)>>48; \ + ((uint8_t*)(p))[7] = (d)>>56; \ + } while(0) +#endif + +#if AV_HAVE_BIGENDIAN +# define AV_RN(s, p) AV_RB##s(p) +# define AV_WN(s, p, v) AV_WB##s(p, v) +#else +# define AV_RN(s, p) AV_RL##s(p) +# define AV_WN(s, p, v) AV_WL##s(p, v) +#endif + +#endif /* HAVE_FAST_UNALIGNED */ + +#ifndef AV_RN16 +# define AV_RN16(p) AV_RN(16, p) +#endif + +#ifndef AV_RN32 +# define AV_RN32(p) AV_RN(32, p) +#endif + +#ifndef AV_RN64 +# define AV_RN64(p) AV_RN(64, p) +#endif + +#ifndef AV_WN16 +# define AV_WN16(p, v) AV_WN(16, p, v) +#endif + +#ifndef AV_WN32 +# define AV_WN32(p, v) AV_WN(32, p, v) +#endif + +#ifndef AV_WN64 +# define AV_WN64(p, v) AV_WN(64, p, v) +#endif + +#if AV_HAVE_BIGENDIAN +# define AV_RB(s, p) AV_RN##s(p) +# define AV_WB(s, p, v) AV_WN##s(p, v) +# define AV_RL(s, p) av_bswap##s(AV_RN##s(p)) +# define AV_WL(s, p, v) AV_WN##s(p, av_bswap##s(v)) +#else +# define AV_RB(s, p) av_bswap##s(AV_RN##s(p)) +# define AV_WB(s, p, v) AV_WN##s(p, av_bswap##s(v)) +# define AV_RL(s, p) AV_RN##s(p) +# define AV_WL(s, p, v) AV_WN##s(p, v) +#endif + +#define AV_RB8(x) (((const uint8_t*)(x))[0]) +#define AV_WB8(p, d) do { ((uint8_t*)(p))[0] = (d); } while(0) + +#define AV_RL8(x) AV_RB8(x) +#define AV_WL8(p, d) AV_WB8(p, d) + +#ifndef AV_RB16 +# define AV_RB16(p) AV_RB(16, p) +#endif +#ifndef AV_WB16 +# define AV_WB16(p, v) AV_WB(16, p, v) +#endif + +#ifndef AV_RL16 +# define AV_RL16(p) AV_RL(16, p) +#endif +#ifndef AV_WL16 +# define AV_WL16(p, v) AV_WL(16, p, v) +#endif + +#ifndef AV_RB32 +# define AV_RB32(p) AV_RB(32, p) +#endif +#ifndef AV_WB32 +# define AV_WB32(p, v) AV_WB(32, p, v) +#endif + +#ifndef AV_RL32 +# define AV_RL32(p) AV_RL(32, p) +#endif +#ifndef AV_WL32 +# define AV_WL32(p, v) AV_WL(32, p, v) +#endif + +#ifndef AV_RB64 +# define AV_RB64(p) AV_RB(64, p) +#endif +#ifndef AV_WB64 +# define AV_WB64(p, v) AV_WB(64, p, v) +#endif + +#ifndef AV_RL64 +# define AV_RL64(p) AV_RL(64, p) +#endif +#ifndef AV_WL64 +# define AV_WL64(p, v) AV_WL(64, p, v) +#endif + +#ifndef AV_RB24 +# define AV_RB24(x) \ + ((((const uint8_t*)(x))[0] << 16) | \ + (((const uint8_t*)(x))[1] << 8) | \ + ((const uint8_t*)(x))[2]) +#endif +#ifndef AV_WB24 +# define AV_WB24(p, d) do { \ + ((uint8_t*)(p))[2] = (d); \ + ((uint8_t*)(p))[1] = (d)>>8; \ + ((uint8_t*)(p))[0] = (d)>>16; \ + } while(0) +#endif + +#ifndef AV_RL24 +# define AV_RL24(x) \ + ((((const uint8_t*)(x))[2] << 16) | \ + (((const uint8_t*)(x))[1] << 8) | \ + ((const uint8_t*)(x))[0]) +#endif +#ifndef AV_WL24 +# define AV_WL24(p, d) do { \ + ((uint8_t*)(p))[0] = (d); \ + ((uint8_t*)(p))[1] = (d)>>8; \ + ((uint8_t*)(p))[2] = (d)>>16; \ + } while(0) +#endif + +/* + * The AV_[RW]NA macros access naturally aligned data + * in a type-safe way. + */ + +#define AV_RNA(s, p) (((const av_alias##s*)(p))->u##s) +#define AV_WNA(s, p, v) (((av_alias##s*)(p))->u##s = (v)) + +#ifndef AV_RN16A +# define AV_RN16A(p) AV_RNA(16, p) +#endif + +#ifndef AV_RN32A +# define AV_RN32A(p) AV_RNA(32, p) +#endif + +#ifndef AV_RN64A +# define AV_RN64A(p) AV_RNA(64, p) +#endif + +#ifndef AV_WN16A +# define AV_WN16A(p, v) AV_WNA(16, p, v) +#endif + +#ifndef AV_WN32A +# define AV_WN32A(p, v) AV_WNA(32, p, v) +#endif + +#ifndef AV_WN64A +# define AV_WN64A(p, v) AV_WNA(64, p, v) +#endif + +/* Parameters for AV_COPY*, AV_SWAP*, AV_ZERO* must be + * naturally aligned. They may be implemented using MMX, + * so emms_c() must be called before using any float code + * afterwards. + */ + +#define AV_COPY(n, d, s) \ + (((av_alias##n*)(d))->u##n = ((const av_alias##n*)(s))->u##n) + +#ifndef AV_COPY16 +# define AV_COPY16(d, s) AV_COPY(16, d, s) +#endif + +#ifndef AV_COPY32 +# define AV_COPY32(d, s) AV_COPY(32, d, s) +#endif + +#ifndef AV_COPY64 +# define AV_COPY64(d, s) AV_COPY(64, d, s) +#endif + +#ifndef AV_COPY128 +# define AV_COPY128(d, s) \ + do { \ + AV_COPY64(d, s); \ + AV_COPY64((char*)(d)+8, (char*)(s)+8); \ + } while(0) +#endif + +#define AV_SWAP(n, a, b) FFSWAP(av_alias##n, *(av_alias##n*)(a), *(av_alias##n*)(b)) + +#ifndef AV_SWAP64 +# define AV_SWAP64(a, b) AV_SWAP(64, a, b) +#endif + +#define AV_ZERO(n, d) (((av_alias##n*)(d))->u##n = 0) + +#ifndef AV_ZERO16 +# define AV_ZERO16(d) AV_ZERO(16, d) +#endif + +#ifndef AV_ZERO32 +# define AV_ZERO32(d) AV_ZERO(32, d) +#endif + +#ifndef AV_ZERO64 +# define AV_ZERO64(d) AV_ZERO(64, d) +#endif + +#ifndef AV_ZERO128 +# define AV_ZERO128(d) \ + do { \ + AV_ZERO64(d); \ + AV_ZERO64((char*)(d)+8); \ + } while(0) +#endif + +#endif /* AVUTIL_INTREADWRITE_H */ diff --git a/lib/rbcodec/codecs/libwmavoice/libavutil/log.c b/lib/rbcodec/codecs/libwmavoice/libavutil/log.c new file mode 100644 index 0000000000..2e225b3b50 --- /dev/null +++ b/lib/rbcodec/codecs/libwmavoice/libavutil/log.c @@ -0,0 +1,150 @@ +/* + * log functions + * Copyright (c) 2003 Michel Bardiaux + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * logging functions + */ + +#include +#include +#include "avutil.h" +#include "log.h" + +#if LIBAVUTIL_VERSION_MAJOR > 50 +static +#endif +int av_log_level = AV_LOG_INFO; + +#if defined(_WIN32) && !defined(__MINGW32CE__) +#include +static const uint8_t color[] = {12,12,12,14,7,7,7}; +static int16_t background, attr_orig; +static HANDLE con; +#define set_color(x) SetConsoleTextAttribute(con, background | color[x]) +#define reset_color() SetConsoleTextAttribute(con, attr_orig) +#else +static const uint8_t color[]={0x41,0x41,0x11,0x03,9,9,9}; +#define set_color(x) fprintf(stderr, "\033[%d;3%dm", color[x]>>4, color[x]&15) +#define reset_color() fprintf(stderr, "\033[0m") +#endif +static int use_color=-1; + +#undef fprintf +static void colored_fputs(int level, const char *str){ + if(use_color<0){ +#if defined(_WIN32) && !defined(__MINGW32CE__) + CONSOLE_SCREEN_BUFFER_INFO con_info; + con = GetStdHandle(STD_ERROR_HANDLE); + use_color = (con != INVALID_HANDLE_VALUE) && !getenv("NO_COLOR"); + if (use_color) { + GetConsoleScreenBufferInfo(con, &con_info); + attr_orig = con_info.wAttributes; + background = attr_orig & 0xF0; + } +#elif HAVE_ISATTY + use_color= getenv("TERM") && !getenv("NO_COLOR") && isatty(2); +#else + use_color= 0; +#endif + } + + if(use_color){ + set_color(level); + } + fputs(str, stderr); + if(use_color){ + reset_color(); + } +} + +const char* av_default_item_name(void* ptr){ + return (*(AVClass**)ptr)->class_name; +} + +void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl) +{ + static int print_prefix=1; + static int count; + static char line[1024], prev[1024]; + AVClass* avc= ptr ? *(AVClass**)ptr : NULL; + if(level>av_log_level) + return; + line[0]=0; +#undef fprintf + if(print_prefix && avc) { + if(avc->version >= (50<<16 | 15<<8 | 3) && avc->parent_log_context_offset){ + AVClass** parent= *(AVClass***)(((uint8_t*)ptr) + avc->parent_log_context_offset); + if(parent && *parent){ + snprintf(line, sizeof(line), "[%s @ %p] ", (*parent)->item_name(parent), parent); + } + } + snprintf(line + strlen(line), sizeof(line) - strlen(line), "[%s @ %p] ", avc->item_name(ptr), ptr); + } + + vsnprintf(line + strlen(line), sizeof(line) - strlen(line), fmt, vl); + + print_prefix= line[strlen(line)-1] == '\n'; + if(print_prefix && !strcmp(line, prev)){ + count++; + fprintf(stderr, " Last message repeated %d times\r", count); + return; + } + if(count>0){ + fprintf(stderr, " Last message repeated %d times\n", count); + count=0; + } + colored_fputs(av_clip(level>>3, 0, 6), line); + strcpy(prev, line); +} + +static void (*av_log_callback)(void*, int, const char*, va_list) = av_log_default_callback; + +void av_log(void* avcl, int level, const char *fmt, ...) +{ + AVClass* avc= avcl ? *(AVClass**)avcl : NULL; + va_list vl; + va_start(vl, fmt); + if(avc && avc->version >= (50<<16 | 15<<8 | 2) && avc->log_level_offset_offset && level>=AV_LOG_FATAL) + level += *(int*)(((uint8_t*)avcl) + avc->log_level_offset_offset); + av_vlog(avcl, level, fmt, vl); + va_end(vl); +} + +void av_vlog(void* avcl, int level, const char *fmt, va_list vl) +{ + av_log_callback(avcl, level, fmt, vl); +} + +int av_log_get_level(void) +{ + return av_log_level; +} + +void av_log_set_level(int level) +{ + av_log_level = level; +} + +void av_log_set_callback(void (*callback)(void*, int, const char*, va_list)) +{ + av_log_callback = callback; +} diff --git a/lib/rbcodec/codecs/libwmavoice/libavutil/log.h b/lib/rbcodec/codecs/libwmavoice/libavutil/log.h new file mode 100644 index 0000000000..831c26eae6 --- /dev/null +++ b/lib/rbcodec/codecs/libwmavoice/libavutil/log.h @@ -0,0 +1,138 @@ +/* + * copyright (c) 2006 Michael Niedermayer + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_LOG_H +#define AVUTIL_LOG_H + +#include +#include "avutil.h" + +/** + * Describe the class of an AVClass context structure. That is an + * arbitrary struct of which the first field is a pointer to an + * AVClass struct (e.g. AVCodecContext, AVFormatContext etc.). + */ +typedef struct { + /** + * The name of the class; usually it is the same name as the + * context structure type to which the AVClass is associated. + */ + const char* class_name; + + /** + * A pointer to a function which returns the name of a context + * instance ctx associated with the class. + */ + const char* (*item_name)(void* ctx); + + /** + * a pointer to the first option specified in the class if any or NULL + * + * @see av_set_default_options() + */ + const struct AVOption *option; + + /** + * LIBAVUTIL_VERSION with which this structure was created. + * This is used to allow fields to be added without requiring major + * version bumps everywhere. + */ + + int version; + + /** + * Offset in the structure where log_level_offset is stored. + * 0 means there is no such variable + */ + int log_level_offset_offset; + + /** + * Offset in the structure where a pointer to the parent context for loging is stored. + * for example a decoder that uses eval.c could pass its AVCodecContext to eval as such + * parent context. And a av_log() implementation could then display the parent context + * can be NULL of course + */ + int parent_log_context_offset; +} AVClass; + +/* av_log API */ + +#define AV_LOG_QUIET -8 + +/** + * Something went really wrong and we will crash now. + */ +#define AV_LOG_PANIC 0 + +/** + * Something went wrong and recovery is not possible. + * For example, no header was found for a format which depends + * on headers or an illegal combination of parameters is used. + */ +#define AV_LOG_FATAL 8 + +/** + * Something went wrong and cannot losslessly be recovered. + * However, not all future data is affected. + */ +#define AV_LOG_ERROR 16 + +/** + * Something somehow does not look correct. This may or may not + * lead to problems. An example would be the use of '-vstrict -2'. + */ +#define AV_LOG_WARNING 24 + +#define AV_LOG_INFO 32 +#define AV_LOG_VERBOSE 40 + +/** + * Stuff which is only useful for libav* developers. + */ +#define AV_LOG_DEBUG 48 + +/** + * Send the specified message to the log if the level is less than or equal + * to the current av_log_level. By default, all logging messages are sent to + * stderr. This behavior can be altered by setting a different av_vlog callback + * function. + * + * @param avcl A pointer to an arbitrary struct of which the first field is a + * pointer to an AVClass struct. + * @param level The importance level of the message, lower values signifying + * higher importance. + * @param fmt The format string (printf-compatible) that specifies how + * subsequent arguments are converted to output. + * @see av_vlog + */ +#ifdef __GNUC__ +void av_log(void *avcl, int level, const char *fmt, ...) __attribute__ ((__format__ (__printf__, 3, 4))); +#else +void av_log(void *avcl, int level, const char *fmt, ...); +#endif + +void av_vlog(void *avcl, int level, const char *fmt, va_list); +int av_log_get_level(void); +void av_log_set_level(int); +void av_log_set_callback(void (*)(void*, int, const char*, va_list)); +void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl); +const char* av_default_item_name(void* ctx); + +#endif /* AVUTIL_LOG_H */ diff --git a/lib/rbcodec/codecs/libwmavoice/libavutil/lzo.c b/lib/rbcodec/codecs/libwmavoice/libavutil/lzo.c new file mode 100644 index 0000000000..7f07cc2ee5 --- /dev/null +++ b/lib/rbcodec/codecs/libwmavoice/libavutil/lzo.c @@ -0,0 +1,280 @@ +/* + * LZO 1x decompression + * Copyright (c) 2006 Reimar Doeffinger + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "avutil.h" +#include "common.h" +//! Avoid e.g. MPlayers fast_memcpy, it slows things down here. +#undef memcpy +#include +#include "lzo.h" + +//! Define if we may write up to 12 bytes beyond the output buffer. +#define OUTBUF_PADDED 1 +//! Define if we may read up to 8 bytes beyond the input buffer. +#define INBUF_PADDED 1 +typedef struct LZOContext { + const uint8_t *in, *in_end; + uint8_t *out_start, *out, *out_end; + int error; +} LZOContext; + +/** + * \brief Reads one byte from the input buffer, avoiding an overrun. + * \return byte read + */ +static inline int get_byte(LZOContext *c) { + if (c->in < c->in_end) + return *c->in++; + c->error |= AV_LZO_INPUT_DEPLETED; + return 1; +} + +#ifdef INBUF_PADDED +#define GETB(c) (*(c).in++) +#else +#define GETB(c) get_byte(&(c)) +#endif + +/** + * \brief Decodes a length value in the coding used by lzo. + * \param x previous byte value + * \param mask bits used from x + * \return decoded length value + */ +static inline int get_len(LZOContext *c, int x, int mask) { + int cnt = x & mask; + if (!cnt) { + while (!(x = get_byte(c))) cnt += 255; + cnt += mask + x; + } + return cnt; +} + +//#define UNALIGNED_LOADSTORE +#define BUILTIN_MEMCPY +#ifdef UNALIGNED_LOADSTORE +#define COPY2(d, s) *(uint16_t *)(d) = *(uint16_t *)(s); +#define COPY4(d, s) *(uint32_t *)(d) = *(uint32_t *)(s); +#elif defined(BUILTIN_MEMCPY) +#define COPY2(d, s) memcpy(d, s, 2); +#define COPY4(d, s) memcpy(d, s, 4); +#else +#define COPY2(d, s) (d)[0] = (s)[0]; (d)[1] = (s)[1]; +#define COPY4(d, s) (d)[0] = (s)[0]; (d)[1] = (s)[1]; (d)[2] = (s)[2]; (d)[3] = (s)[3]; +#endif + +/** + * \brief Copies bytes from input to output buffer with checking. + * \param cnt number of bytes to copy, must be >= 0 + */ +static inline void copy(LZOContext *c, int cnt) { + register const uint8_t *src = c->in; + register uint8_t *dst = c->out; + if (cnt > c->in_end - src) { + cnt = FFMAX(c->in_end - src, 0); + c->error |= AV_LZO_INPUT_DEPLETED; + } + if (cnt > c->out_end - dst) { + cnt = FFMAX(c->out_end - dst, 0); + c->error |= AV_LZO_OUTPUT_FULL; + } +#if defined(INBUF_PADDED) && defined(OUTBUF_PADDED) + COPY4(dst, src); + src += 4; + dst += 4; + cnt -= 4; + if (cnt > 0) +#endif + memcpy(dst, src, cnt); + c->in = src + cnt; + c->out = dst + cnt; +} + +static inline void memcpy_backptr(uint8_t *dst, int back, int cnt); + +/** + * \brief Copies previously decoded bytes to current position. + * \param back how many bytes back we start + * \param cnt number of bytes to copy, must be >= 0 + * + * cnt > back is valid, this will copy the bytes we just copied, + * thus creating a repeating pattern with a period length of back. + */ +static inline void copy_backptr(LZOContext *c, int back, int cnt) { + register const uint8_t *src = &c->out[-back]; + register uint8_t *dst = c->out; + if (src < c->out_start || src > dst) { + c->error |= AV_LZO_INVALID_BACKPTR; + return; + } + if (cnt > c->out_end - dst) { + cnt = FFMAX(c->out_end - dst, 0); + c->error |= AV_LZO_OUTPUT_FULL; + } + memcpy_backptr(dst, back, cnt); + c->out = dst + cnt; +} + +static inline void memcpy_backptr(uint8_t *dst, int back, int cnt) { + const uint8_t *src = &dst[-back]; + if (back == 1) { + memset(dst, *src, cnt); + } else { +#ifdef OUTBUF_PADDED + COPY2(dst, src); + COPY2(dst + 2, src + 2); + src += 4; + dst += 4; + cnt -= 4; + if (cnt > 0) { + COPY2(dst, src); + COPY2(dst + 2, src + 2); + COPY2(dst + 4, src + 4); + COPY2(dst + 6, src + 6); + src += 8; + dst += 8; + cnt -= 8; + } +#endif + if (cnt > 0) { + int blocklen = back; + while (cnt > blocklen) { + memcpy(dst, src, blocklen); + dst += blocklen; + cnt -= blocklen; + blocklen <<= 1; + } + memcpy(dst, src, cnt); + } + } +} + +void av_memcpy_backptr(uint8_t *dst, int back, int cnt) { + memcpy_backptr(dst, back, cnt); +} + +int av_lzo1x_decode(void *out, int *outlen, const void *in, int *inlen) { + int state= 0; + int x; + LZOContext c; + c.in = in; + c.in_end = (const uint8_t *)in + *inlen; + c.out = c.out_start = out; + c.out_end = (uint8_t *)out + * outlen; + c.error = 0; + x = GETB(c); + if (x > 17) { + copy(&c, x - 17); + x = GETB(c); + if (x < 16) c.error |= AV_LZO_ERROR; + } + if (c.in > c.in_end) + c.error |= AV_LZO_INPUT_DEPLETED; + while (!c.error) { + int cnt, back; + if (x > 15) { + if (x > 63) { + cnt = (x >> 5) - 1; + back = (GETB(c) << 3) + ((x >> 2) & 7) + 1; + } else if (x > 31) { + cnt = get_len(&c, x, 31); + x = GETB(c); + back = (GETB(c) << 6) + (x >> 2) + 1; + } else { + cnt = get_len(&c, x, 7); + back = (1 << 14) + ((x & 8) << 11); + x = GETB(c); + back += (GETB(c) << 6) + (x >> 2); + if (back == (1 << 14)) { + if (cnt != 1) + c.error |= AV_LZO_ERROR; + break; + } + } + } else if(!state){ + cnt = get_len(&c, x, 15); + copy(&c, cnt + 3); + x = GETB(c); + if (x > 15) + continue; + cnt = 1; + back = (1 << 11) + (GETB(c) << 2) + (x >> 2) + 1; + } else { + cnt = 0; + back = (GETB(c) << 2) + (x >> 2) + 1; + } + copy_backptr(&c, back, cnt + 2); + state= + cnt = x & 3; + copy(&c, cnt); + x = GETB(c); + } + *inlen = c.in_end - c.in; + if (c.in > c.in_end) + *inlen = 0; + *outlen = c.out_end - c.out; + return c.error; +} + +#ifdef TEST +#include +#include +#include "log.h" +#define MAXSZ (10*1024*1024) + +/* Define one of these to 1 if you wish to benchmark liblzo + * instead of our native implementation. */ +#define BENCHMARK_LIBLZO_SAFE 0 +#define BENCHMARK_LIBLZO_UNSAFE 0 + +int main(int argc, char *argv[]) { + FILE *in = fopen(argv[1], "rb"); + uint8_t *orig = av_malloc(MAXSZ + 16); + uint8_t *comp = av_malloc(2*MAXSZ + 16); + uint8_t *decomp = av_malloc(MAXSZ + 16); + size_t s = fread(orig, 1, MAXSZ, in); + lzo_uint clen = 0; + long tmp[LZO1X_MEM_COMPRESS]; + int inlen, outlen; + int i; + av_log_set_level(AV_LOG_DEBUG); + lzo1x_999_compress(orig, s, comp, &clen, tmp); + for (i = 0; i < 300; i++) { +START_TIMER + inlen = clen; outlen = MAXSZ; +#if BENCHMARK_LIBLZO_SAFE + if (lzo1x_decompress_safe(comp, inlen, decomp, &outlen, NULL)) +#elif BENCHMARK_LIBLZO_UNSAFE + if (lzo1x_decompress(comp, inlen, decomp, &outlen, NULL)) +#else + if (av_lzo1x_decode(decomp, &outlen, comp, &inlen)) +#endif + av_log(NULL, AV_LOG_ERROR, "decompression error\n"); +STOP_TIMER("lzod") + } + if (memcmp(orig, decomp, s)) + av_log(NULL, AV_LOG_ERROR, "decompression incorrect\n"); + else + av_log(NULL, AV_LOG_ERROR, "decompression OK\n"); + fclose(in); + return 0; +} +#endif diff --git a/lib/rbcodec/codecs/libwmavoice/libavutil/lzo.h b/lib/rbcodec/codecs/libwmavoice/libavutil/lzo.h new file mode 100644 index 0000000000..6788054bff --- /dev/null +++ b/lib/rbcodec/codecs/libwmavoice/libavutil/lzo.h @@ -0,0 +1,66 @@ +/* + * LZO 1x decompression + * copyright (c) 2006 Reimar Doeffinger + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_LZO_H +#define AVUTIL_LZO_H + +#include + +/** \defgroup errflags Error flags returned by av_lzo1x_decode + * \{ */ +//! end of the input buffer reached before decoding finished +#define AV_LZO_INPUT_DEPLETED 1 +//! decoded data did not fit into output buffer +#define AV_LZO_OUTPUT_FULL 2 +//! a reference to previously decoded data was wrong +#define AV_LZO_INVALID_BACKPTR 4 +//! a non-specific error in the compressed bitstream +#define AV_LZO_ERROR 8 +/** \} */ + +#define AV_LZO_INPUT_PADDING 8 +#define AV_LZO_OUTPUT_PADDING 12 + +/** + * \brief Decodes LZO 1x compressed data. + * \param out output buffer + * \param outlen size of output buffer, number of bytes left are returned here + * \param in input buffer + * \param inlen size of input buffer, number of bytes left are returned here + * \return 0 on success, otherwise a combination of the error flags above + * + * Make sure all buffers are appropriately padded, in must provide + * AV_LZO_INPUT_PADDING, out must provide AV_LZO_OUTPUT_PADDING additional bytes. + */ +int av_lzo1x_decode(void *out, int *outlen, const void *in, int *inlen); + +/** + * \brief deliberately overlapping memcpy implementation + * \param dst destination buffer; must be padded with 12 additional bytes + * \param back how many bytes back we start (the initial size of the overlapping window) + * \param cnt number of bytes to copy, must be >= 0 + * + * cnt > back is valid, this will copy the bytes we just copied, + * thus creating a repeating pattern with a period length of back. + */ +void av_memcpy_backptr(uint8_t *dst, int back, int cnt); + +#endif /* AVUTIL_LZO_H */ diff --git a/lib/rbcodec/codecs/libwmavoice/libavutil/mathematics.c b/lib/rbcodec/codecs/libwmavoice/libavutil/mathematics.c new file mode 100644 index 0000000000..c4fbe3b7bc --- /dev/null +++ b/lib/rbcodec/codecs/libwmavoice/libavutil/mathematics.c @@ -0,0 +1,183 @@ +/* + * Copyright (c) 2005 Michael Niedermayer + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * miscellaneous math routines and tables + */ + +#include +#include +#include +#include "mathematics.h" + +const uint8_t ff_sqrt_tab[256]={ + 0, 16, 23, 28, 32, 36, 40, 43, 46, 48, 51, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 77, 79, 80, 82, 84, 85, 87, 88, 90, + 91, 92, 94, 95, 96, 98, 99,100,102,103,104,105,107,108,109,110,111,112,114,115,116,117,118,119,120,121,122,123,124,125,126,127, +128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,144,145,146,147,148,149,150,151,151,152,153,154,155,156,156, +157,158,159,160,160,161,162,163,164,164,165,166,167,168,168,169,170,171,171,172,173,174,174,175,176,176,177,178,179,179,180,181, +182,182,183,184,184,185,186,186,187,188,188,189,190,190,191,192,192,193,194,194,195,196,196,197,198,198,199,200,200,201,202,202, +203,204,204,205,205,206,207,207,208,208,209,210,210,211,212,212,213,213,214,215,215,216,216,217,218,218,219,219,220,220,221,222, +222,223,223,224,224,225,226,226,227,227,228,228,229,230,230,231,231,232,232,233,233,234,235,235,236,236,237,237,238,238,239,239, +240,240,241,242,242,243,243,244,244,245,245,246,246,247,247,248,248,249,249,250,250,251,251,252,252,253,253,254,254,255,255,255 +}; + +const uint8_t ff_log2_tab[256]={ + 0,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, + 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, + 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, + 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, + 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, + 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, + 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, + 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7 +}; + +const uint8_t av_reverse[256]={ +0x00,0x80,0x40,0xC0,0x20,0xA0,0x60,0xE0,0x10,0x90,0x50,0xD0,0x30,0xB0,0x70,0xF0, +0x08,0x88,0x48,0xC8,0x28,0xA8,0x68,0xE8,0x18,0x98,0x58,0xD8,0x38,0xB8,0x78,0xF8, +0x04,0x84,0x44,0xC4,0x24,0xA4,0x64,0xE4,0x14,0x94,0x54,0xD4,0x34,0xB4,0x74,0xF4, +0x0C,0x8C,0x4C,0xCC,0x2C,0xAC,0x6C,0xEC,0x1C,0x9C,0x5C,0xDC,0x3C,0xBC,0x7C,0xFC, +0x02,0x82,0x42,0xC2,0x22,0xA2,0x62,0xE2,0x12,0x92,0x52,0xD2,0x32,0xB2,0x72,0xF2, +0x0A,0x8A,0x4A,0xCA,0x2A,0xAA,0x6A,0xEA,0x1A,0x9A,0x5A,0xDA,0x3A,0xBA,0x7A,0xFA, +0x06,0x86,0x46,0xC6,0x26,0xA6,0x66,0xE6,0x16,0x96,0x56,0xD6,0x36,0xB6,0x76,0xF6, +0x0E,0x8E,0x4E,0xCE,0x2E,0xAE,0x6E,0xEE,0x1E,0x9E,0x5E,0xDE,0x3E,0xBE,0x7E,0xFE, +0x01,0x81,0x41,0xC1,0x21,0xA1,0x61,0xE1,0x11,0x91,0x51,0xD1,0x31,0xB1,0x71,0xF1, +0x09,0x89,0x49,0xC9,0x29,0xA9,0x69,0xE9,0x19,0x99,0x59,0xD9,0x39,0xB9,0x79,0xF9, +0x05,0x85,0x45,0xC5,0x25,0xA5,0x65,0xE5,0x15,0x95,0x55,0xD5,0x35,0xB5,0x75,0xF5, +0x0D,0x8D,0x4D,0xCD,0x2D,0xAD,0x6D,0xED,0x1D,0x9D,0x5D,0xDD,0x3D,0xBD,0x7D,0xFD, +0x03,0x83,0x43,0xC3,0x23,0xA3,0x63,0xE3,0x13,0x93,0x53,0xD3,0x33,0xB3,0x73,0xF3, +0x0B,0x8B,0x4B,0xCB,0x2B,0xAB,0x6B,0xEB,0x1B,0x9B,0x5B,0xDB,0x3B,0xBB,0x7B,0xFB, +0x07,0x87,0x47,0xC7,0x27,0xA7,0x67,0xE7,0x17,0x97,0x57,0xD7,0x37,0xB7,0x77,0xF7, +0x0F,0x8F,0x4F,0xCF,0x2F,0xAF,0x6F,0xEF,0x1F,0x9F,0x5F,0xDF,0x3F,0xBF,0x7F,0xFF, +}; + +int64_t av_gcd(int64_t a, int64_t b){ + if(b) return av_gcd(b, a%b); + else return a; +} + +int64_t av_rescale_rnd(int64_t a, int64_t b, int64_t c, enum AVRounding rnd){ + int64_t r=0; + assert(c > 0); + assert(b >=0); + assert((unsigned)rnd<=5 && rnd!=4); + + if(a<0 && a != INT64_MIN) return -av_rescale_rnd(-a, b, c, rnd ^ ((rnd>>1)&1)); + + if(rnd==AV_ROUND_NEAR_INF) r= c/2; + else if(rnd&1) r= c-1; + + if(b<=INT_MAX && c<=INT_MAX){ + if(a<=INT_MAX) + return (a * b + r)/c; + else + return a/c*b + (a%c*b + r)/c; + }else{ +#if 1 + uint64_t a0= a&0xFFFFFFFF; + uint64_t a1= a>>32; + uint64_t b0= b&0xFFFFFFFF; + uint64_t b1= b>>32; + uint64_t t1= a0*b1 + a1*b0; + uint64_t t1a= t1<<32; + int i; + + a0 = a0*b0 + t1a; + a1 = a1*b1 + (t1>>32) + (a0=0; i--){ +// int o= a1 & 0x8000000000000000ULL; + a1+= a1 + ((a0>>i)&1); + t1+=t1; + if(/*o || */c <= a1){ + a1 -= c; + t1++; + } + } + return t1; + } +#else + AVInteger ai; + ai= av_mul_i(av_int2i(a), av_int2i(b)); + ai= av_add_i(ai, av_int2i(r)); + + return av_i2int(av_div_i(ai, av_int2i(c))); + } +#endif +} + +int64_t av_rescale(int64_t a, int64_t b, int64_t c){ + return av_rescale_rnd(a, b, c, AV_ROUND_NEAR_INF); +} + +#if 0 +int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq){ + int64_t b= bq.num * (int64_t)cq.den; + int64_t c= cq.num * (int64_t)bq.den; + return av_rescale_rnd(a, b, c, AV_ROUND_NEAR_INF); +} + +int av_compare_ts(int64_t ts_a, AVRational tb_a, int64_t ts_b, AVRational tb_b){ + int64_t a= tb_a.num * (int64_t)tb_b.den; + int64_t b= tb_b.num * (int64_t)tb_a.den; + if (av_rescale_rnd(ts_a, a, b, AV_ROUND_DOWN) < ts_b) return -1; + if (av_rescale_rnd(ts_b, b, a, AV_ROUND_DOWN) < ts_a) return 1; + return 0; +} +#endif + +int64_t av_compare_mod(uint64_t a, uint64_t b, uint64_t mod){ + int64_t c= (a-b) & (mod-1); + if(c > (mod>>1)) + c-= mod; + return c; +} + +#ifdef TEST +#include "integer.h" +#undef printf +int main(void){ + int64_t a,b,c,d,e; + + for(a=7; a<(1LL<<62); a+=a/3+1){ + for(b=3; b<(1LL<<62); b+=b/4+1){ + for(c=9; c<(1LL<<62); c+=(c*2)/5+3){ + int64_t r= c/2; + AVInteger ai; + ai= av_mul_i(av_int2i(a), av_int2i(b)); + ai= av_add_i(ai, av_int2i(r)); + + d= av_i2int(av_div_i(ai, av_int2i(c))); + + e= av_rescale(a,b,c); + + if((double)a * (double)b / (double)c > (1LL<<63)) + continue; + + if(d!=e) printf("%"PRId64"*%"PRId64"/%"PRId64"= %"PRId64"=%"PRId64"\n", a, b, c, d, e); + } + } + } + return 0; +} +#endif diff --git a/lib/rbcodec/codecs/libwmavoice/libavutil/mathematics.h b/lib/rbcodec/codecs/libwmavoice/libavutil/mathematics.h new file mode 100644 index 0000000000..e07d4fe807 --- /dev/null +++ b/lib/rbcodec/codecs/libwmavoice/libavutil/mathematics.h @@ -0,0 +1,112 @@ +/* + * copyright (c) 2005 Michael Niedermayer + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_MATHEMATICS_H +#define AVUTIL_MATHEMATICS_H + +#include +#include +#include "attributes.h" +//#include "rational.h" + +#ifndef M_E +#define M_E 2.7182818284590452354 /* e */ +#endif +#ifndef M_LN2 +#define M_LN2 0.69314718055994530942 /* log_e 2 */ +#endif +#ifndef M_LN10 +#define M_LN10 2.30258509299404568402 /* log_e 10 */ +#endif +#ifndef M_LOG2_10 +#define M_LOG2_10 3.32192809488736234787 /* log_2 10 */ +#endif +#ifndef M_PHI +#define M_PHI 1.61803398874989484820 /* phi / golden ratio */ +#endif +#ifndef M_PI +#define M_PI 3.14159265358979323846 /* pi */ +#endif +#ifndef M_SQRT1_2 +#define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */ +#endif +#ifndef M_SQRT2 +#define M_SQRT2 1.41421356237309504880 /* sqrt(2) */ +#endif +#ifndef NAN +#define NAN (0.0/0.0) +#endif +#ifndef INFINITY +#define INFINITY (1.0/0.0) +#endif + +enum AVRounding { + AV_ROUND_ZERO = 0, ///< Round toward zero. + AV_ROUND_INF = 1, ///< Round away from zero. + AV_ROUND_DOWN = 2, ///< Round toward -infinity. + AV_ROUND_UP = 3, ///< Round toward +infinity. + AV_ROUND_NEAR_INF = 5, ///< Round to nearest and halfway cases away from zero. +}; + +/** + * Return the greatest common divisor of a and b. + * If both a and b are 0 or either or both are <0 then behavior is + * undefined. + */ +int64_t av_const av_gcd(int64_t a, int64_t b); + +/** + * Rescale a 64-bit integer with rounding to nearest. + * A simple a*b/c isn't possible as it can overflow. + */ +int64_t av_rescale(int64_t a, int64_t b, int64_t c) av_const; + +/** + * Rescale a 64-bit integer with specified rounding. + * A simple a*b/c isn't possible as it can overflow. + */ +int64_t av_rescale_rnd(int64_t a, int64_t b, int64_t c, enum AVRounding) av_const; + +/** + * Rescale a 64-bit integer by 2 rational numbers. + */ +//int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq) av_const; + +/** + * Compare 2 timestamps each in its own timebases. + * The result of the function is undefined if one of the timestamps + * is outside the int64_t range when represented in the others timebase. + * @return -1 if ts_a is before ts_b, 1 if ts_a is after ts_b or 0 if they represent the same position + */ +//int av_compare_ts(int64_t ts_a, AVRational tb_a, int64_t ts_b, AVRational tb_b); + +/** + * Compare 2 integers modulo mod. + * That is we compare integers a and b for which only the least + * significant log2(mod) bits are known. + * + * @param mod must be a power of 2 + * @return a negative value if a is smaller than b + * a positive value if a is greater than b + * 0 if a equals b + */ +int64_t av_compare_mod(uint64_t a, uint64_t b, uint64_t mod); + +#endif /* AVUTIL_MATHEMATICS_H */ diff --git a/lib/rbcodec/codecs/libwmavoice/libavutil/mem.c b/lib/rbcodec/codecs/libwmavoice/libavutil/mem.c new file mode 100644 index 0000000000..a9a3283775 --- /dev/null +++ b/lib/rbcodec/codecs/libwmavoice/libavutil/mem.c @@ -0,0 +1,176 @@ +/* + * default memory allocator for libavutil + * Copyright (c) 2002 Fabrice Bellard + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * default memory allocator for libavutil + */ + +//#include "config.h" + +#include +#include +#include +#if HAVE_MALLOC_H +#include +#endif + +#include "avutil.h" +#include "mem.h" + +/* here we can use OS-dependent allocation functions */ +#undef free +#undef malloc +#undef realloc + +#ifdef MALLOC_PREFIX + +#define malloc AV_JOIN(MALLOC_PREFIX, malloc) +#define memalign AV_JOIN(MALLOC_PREFIX, memalign) +#define posix_memalign AV_JOIN(MALLOC_PREFIX, posix_memalign) +#define realloc AV_JOIN(MALLOC_PREFIX, realloc) +#define free AV_JOIN(MALLOC_PREFIX, free) + +void *malloc(size_t size); +void *memalign(size_t align, size_t size); +int posix_memalign(void **ptr, size_t align, size_t size); +void *realloc(void *ptr, size_t size); +void free(void *ptr); + +#endif /* MALLOC_PREFIX */ + +/* You can redefine av_malloc and av_free in your project to use your + memory allocator. You do not need to suppress this file because the + linker will do it automatically. */ + +void *av_malloc(unsigned int size) +{ + void *ptr = NULL; +#if CONFIG_MEMALIGN_HACK + long diff; +#endif + + /* let's disallow possible ambiguous cases */ + if(size > (INT_MAX-16) ) + return NULL; + +#if CONFIG_MEMALIGN_HACK + ptr = malloc(size+16); + if(!ptr) + return ptr; + diff= ((-(long)ptr - 1)&15) + 1; + ptr = (char*)ptr + diff; + ((char*)ptr)[-1]= diff; +#elif HAVE_POSIX_MEMALIGN + if (posix_memalign(&ptr,16,size)) + ptr = NULL; +#elif HAVE_MEMALIGN + ptr = memalign(16,size); + /* Why 64? + Indeed, we should align it: + on 4 for 386 + on 16 for 486 + on 32 for 586, PPro - K6-III + on 64 for K7 (maybe for P3 too). + Because L1 and L2 caches are aligned on those values. + But I don't want to code such logic here! + */ + /* Why 16? + Because some CPUs need alignment, for example SSE2 on P4, & most RISC CPUs + it will just trigger an exception and the unaligned load will be done in the + exception handler or it will just segfault (SSE2 on P4). + Why not larger? Because I did not see a difference in benchmarks ... + */ + /* benchmarks with P3 + memalign(64)+1 3071,3051,3032 + memalign(64)+2 3051,3032,3041 + memalign(64)+4 2911,2896,2915 + memalign(64)+8 2545,2554,2550 + memalign(64)+16 2543,2572,2563 + memalign(64)+32 2546,2545,2571 + memalign(64)+64 2570,2533,2558 + + BTW, malloc seems to do 8-byte alignment by default here. + */ +#else + ptr = malloc(size); +#endif + return ptr; +} + +void *av_realloc(void *ptr, unsigned int size) +{ +#if CONFIG_MEMALIGN_HACK + int diff; +#endif + + /* let's disallow possible ambiguous cases */ + if(size > (INT_MAX-16) ) + return NULL; + +#if CONFIG_MEMALIGN_HACK + //FIXME this isn't aligned correctly, though it probably isn't needed + if(!ptr) return av_malloc(size); + diff= ((char*)ptr)[-1]; + return (char*)realloc((char*)ptr - diff, size + diff) + diff; +#else + return realloc(ptr, size); +#endif +} + +void av_free(void *ptr) +{ + /* XXX: this test should not be needed on most libcs */ + if (ptr) +#if CONFIG_MEMALIGN_HACK + free((char*)ptr - ((char*)ptr)[-1]); +#else + free(ptr); +#endif +} + +void av_freep(void *arg) +{ + void **ptr= (void**)arg; + av_free(*ptr); + *ptr = NULL; +} + +void *av_mallocz(unsigned int size) +{ + void *ptr = av_malloc(size); + if (ptr) + memset(ptr, 0, size); + return ptr; +} + +char *av_strdup(const char *s) +{ + char *ptr= NULL; + if(s){ + int len = strlen(s) + 1; + ptr = av_malloc(len); + if (ptr) + memcpy(ptr, s, len); + } + return ptr; +} + diff --git a/lib/rbcodec/codecs/libwmavoice/libavutil/mem.h b/lib/rbcodec/codecs/libwmavoice/libavutil/mem.h new file mode 100644 index 0000000000..c5ec2ab3c3 --- /dev/null +++ b/lib/rbcodec/codecs/libwmavoice/libavutil/mem.h @@ -0,0 +1,126 @@ +/* + * copyright (c) 2006 Michael Niedermayer + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * memory handling functions + */ + +#ifndef AVUTIL_MEM_H +#define AVUTIL_MEM_H + +#include "attributes.h" +#include "avutil.h" + +#if defined(__ICC) && _ICC < 1200 || defined(__SUNPRO_C) + #define DECLARE_ALIGNED(n,t,v) t __attribute__ ((aligned (n))) v + #define DECLARE_ASM_CONST(n,t,v) const t __attribute__ ((aligned (n))) v +#elif defined(__TI_COMPILER_VERSION__) + #define DECLARE_ALIGNED(n,t,v) \ + AV_PRAGMA(DATA_ALIGN(v,n)) \ + t __attribute__((aligned(n))) v + #define DECLARE_ASM_CONST(n,t,v) \ + AV_PRAGMA(DATA_ALIGN(v,n)) \ + static const t __attribute__((aligned(n))) v +#elif defined(__GNUC__) + #define DECLARE_ALIGNED(n,t,v) t __attribute__ ((aligned (n))) v + #define DECLARE_ASM_CONST(n,t,v) static const t attribute_used __attribute__ ((aligned (n))) v +#elif defined(_MSC_VER) + #define DECLARE_ALIGNED(n,t,v) __declspec(align(n)) t v + #define DECLARE_ASM_CONST(n,t,v) __declspec(align(n)) static const t v +#else + #define DECLARE_ALIGNED(n,t,v) t v + #define DECLARE_ASM_CONST(n,t,v) static const t v +#endif + +#if AV_GCC_VERSION_AT_LEAST(3,1) + #define av_malloc_attrib __attribute__((__malloc__)) +#else + #define av_malloc_attrib +#endif + +#if (!defined(__ICC) || __ICC > 1110) && AV_GCC_VERSION_AT_LEAST(4,3) + #define av_alloc_size(n) __attribute__((alloc_size(n))) +#else + #define av_alloc_size(n) +#endif + +/** + * Allocate a block of size bytes with alignment suitable for all + * memory accesses (including vectors if available on the CPU). + * @param size Size in bytes for the memory block to be allocated. + * @return Pointer to the allocated block, NULL if the block cannot + * be allocated. + * @see av_mallocz() + */ +void *av_malloc(unsigned int size) av_malloc_attrib av_alloc_size(1); + +/** + * Allocate or reallocate a block of memory. + * If ptr is NULL and size > 0, allocate a new block. If + * size is zero, free the memory block pointed to by ptr. + * @param size Size in bytes for the memory block to be allocated or + * reallocated. + * @param ptr Pointer to a memory block already allocated with + * av_malloc(z)() or av_realloc() or NULL. + * @return Pointer to a newly reallocated block or NULL if the block + * cannot be reallocated or the function is used to free the memory block. + * @see av_fast_realloc() + */ +void *av_realloc(void *ptr, unsigned int size) av_alloc_size(2); + +/** + * Free a memory block which has been allocated with av_malloc(z)() or + * av_realloc(). + * @param ptr Pointer to the memory block which should be freed. + * @note ptr = NULL is explicitly allowed. + * @note It is recommended that you use av_freep() instead. + * @see av_freep() + */ +void av_free(void *ptr); + +/** + * Allocate a block of size bytes with alignment suitable for all + * memory accesses (including vectors if available on the CPU) and + * zero all the bytes of the block. + * @param size Size in bytes for the memory block to be allocated. + * @return Pointer to the allocated block, NULL if it cannot be allocated. + * @see av_malloc() + */ +void *av_mallocz(unsigned int size) av_malloc_attrib av_alloc_size(1); + +/** + * Duplicate the string s. + * @param s string to be duplicated + * @return Pointer to a newly allocated string containing a + * copy of s or NULL if the string cannot be allocated. + */ +char *av_strdup(const char *s) av_malloc_attrib; + +/** + * Free a memory block which has been allocated with av_malloc(z)() or + * av_realloc() and set the pointer pointing to it to NULL. + * @param ptr Pointer to the pointer to the memory block which should + * be freed. + * @see av_free() + */ +void av_freep(void *ptr); + +#endif /* AVUTIL_MEM_H */ diff --git a/lib/rbcodec/codecs/libwmavoice/libwmavoice.make b/lib/rbcodec/codecs/libwmavoice/libwmavoice.make new file mode 100644 index 0000000000..609e5612f8 --- /dev/null +++ b/lib/rbcodec/codecs/libwmavoice/libwmavoice.make @@ -0,0 +1,37 @@ +# __________ __ ___. +# Open \______ \ ____ ____ | | _\_ |__ _______ ___ +# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / +# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < +# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ +# \/ \/ \/ \/ \/ +# $Id: libwmavoice.make 27586 2010-07-27 06:48:15Z nls $ +# + +# libwmavoice +WMAVOICELIB := $(CODECDIR)/libwmavoice.a +WMAVOICELIB_SRC := $(call preprocess, $(RBCODECLIB_DIR)/codecs/libwmavoice/SOURCES) +WMAVOICELIB_OBJ := $(call c2obj, $(WMAVOICELIB_SRC)) +OTHER_SRC += $(WMAVOICELIB_SRC) + +$(WMAVOICELIB): $(WMAVOICELIB_OBJ) + $(SILENT)$(shell rm -f $@) + $(call PRINTS,AR $(@F))$(AR) rcs $@ $^ >/dev/null + +WMAVOICEFLAGS = -I$(RBCODECLIB_DIR)/codecs/libwmavoice $(filter-out -O%,$(CODECFLAGS)) + +ifeq ($(ARCH),arch_m68k) + WMAVOICEFLAGS += -O2 +else + WMAVOICEFLAGS += -O1 +endif + +ifeq ($(APP_TYPE),sdl-sim) +# wmavoice needs libm in the simulator +$(CODECDIR)/wmavoice.codec: $(CODECDIR)/wmavoice.o + $(call PRINTS,LD $(@F))$(CC) $(CODECFLAGS) -o $(CODECDIR)/wmavoice.elf \ + $(filter %.o, $^) \ + $(filter %.a, $+) \ + -lgcc -lm $(CODECLDFLAGS) + $(SILENT)cp $(CODECDIR)/wmavoice.elf $@ +endif + diff --git a/lib/rbcodec/codecs/libwmavoice/lsp.c b/lib/rbcodec/codecs/libwmavoice/lsp.c new file mode 100644 index 0000000000..4dba9c1df9 --- /dev/null +++ b/lib/rbcodec/codecs/libwmavoice/lsp.c @@ -0,0 +1,174 @@ +/* + * LSP routines for ACELP-based codecs + * + * Copyright (c) 2007 Reynaldo H. Verdejo Pinochet (QCELP decoder) + * Copyright (c) 2008 Vladimir Voroshilov + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include + +#include "avcodec.h" +#define FRAC_BITS 14 +#include "mathops.h" +#include "lsp.h" +#include "celp_math.h" + +void ff_acelp_reorder_lsf(int16_t* lsfq, int lsfq_min_distance, int lsfq_min, int lsfq_max, int lp_order) +{ + int i, j; + + /* sort lsfq in ascending order. float bubble agorithm, + O(n) if data already sorted, O(n^2) - otherwise */ + for(i=0; i=0 && lsfq[j] > lsfq[j+1]; j--) + FFSWAP(int16_t, lsfq[j], lsfq[j+1]); + + for(i=0; i> 15); // divide by PI and (0,13) -> (0,14) +} + +/** + * \brief decodes polynomial coefficients from LSP + * \param f [out] decoded polynomial coefficients (-0x20000000 <= (3.22) <= 0x1fffffff) + * \param lsp LSP coefficients (-0x8000 <= (0.15) <= 0x7fff) + */ +static void lsp2poly(int* f, const int16_t* lsp, int lp_half_order) +{ + int i, j; + + f[0] = 0x400000; // 1.0 in (3.22) + f[1] = -lsp[0] << 8; // *2 and (0.15) -> (3.22) + + for(i=2; i<=lp_half_order; i++) + { + f[i] = f[i-2]; + for(j=i; j>1; j--) + f[j] -= MULL(f[j-1], lsp[2*i-2], FRAC_BITS) - f[j-2]; + + f[1] -= lsp[2*i-2] << 8; + } +} + +void ff_acelp_lsp2lpc(int16_t* lp, const int16_t* lsp, int lp_half_order) +{ + int i; + int f1[MAX_LP_HALF_ORDER+1]; // (3.22) + int f2[MAX_LP_HALF_ORDER+1]; // (3.22) + + lsp2poly(f1, lsp , lp_half_order); + lsp2poly(f2, lsp+1, lp_half_order); + + /* 3.2.6 of G.729, Equations 25 and 26*/ + lp[0] = 4096; + for(i=1; i> 11; // divide by 2 and (3.22) -> (3.12) + lp[(lp_half_order << 1) + 1 - i] = (ff1 - ff2) >> 11; // divide by 2 and (3.22) -> (3.12) + } +} + +void ff_acelp_lp_decode(int16_t* lp_1st, int16_t* lp_2nd, const int16_t* lsp_2nd, const int16_t* lsp_prev, int lp_order) +{ + int16_t lsp_1st[MAX_LP_ORDER]; // (0.15) + int i; + + /* LSP values for first subframe (3.2.5 of G.729, Equation 24)*/ + for(i=0; i> 1) + (lsp_prev[i] >> 1); +#else + lsp_1st[i] = (lsp_2nd[i] + lsp_prev[i]) >> 1; +#endif + + ff_acelp_lsp2lpc(lp_1st, lsp_1st, lp_order >> 1); + + /* LSP values for second subframe (3.2.5 of G.729)*/ + ff_acelp_lsp2lpc(lp_2nd, lsp_2nd, lp_order >> 1); +} + +void ff_lsp2polyf(const double *lsp, double *f, int lp_half_order) +{ + int i, j; + + f[0] = 1.0; + f[1] = -2 * lsp[0]; + lsp -= 2; + for(i=2; i<=lp_half_order; i++) + { + double val = -2 * lsp[2*i]; + f[i] = val * f[i-1] + 2*f[i-2]; + for(j=i-1; j>1; j--) + f[j] += f[j-1] * val + f[j-2]; + f[1] += val; + } +} + +void ff_acelp_lspd2lpc(const double *lsp, float *lpc, int lp_half_order) +{ + double pa[MAX_LP_HALF_ORDER+1], qa[MAX_LP_HALF_ORDER+1]; + float *lpc2 = lpc + (lp_half_order << 1) - 1; + + //assert(lp_half_order <= MAX_LP_HALF_ORDER); + + ff_lsp2polyf(lsp, pa, lp_half_order); + ff_lsp2polyf(lsp + 1, qa, lp_half_order); + + while (lp_half_order--) { + double paf = pa[lp_half_order+1] + pa[lp_half_order]; + double qaf = qa[lp_half_order+1] - qa[lp_half_order]; + + lpc [ lp_half_order] = 0.5*(paf+qaf); + lpc2[-lp_half_order] = 0.5*(paf-qaf); + } +} + +void ff_sort_nearly_sorted_floats(float *vals, int len) +{ + int i,j; + + for (i = 0; i < len - 1; i++) + for (j = i; j >= 0 && vals[j] > vals[j+1]; j--) + FFSWAP(float, vals[j], vals[j+1]); +} diff --git a/lib/rbcodec/codecs/libwmavoice/lsp.h b/lib/rbcodec/codecs/libwmavoice/lsp.h new file mode 100644 index 0000000000..5ee5c277bc --- /dev/null +++ b/lib/rbcodec/codecs/libwmavoice/lsp.h @@ -0,0 +1,120 @@ +/* + * LSP computing for ACELP-based codecs + * + * Copyright (c) 2008 Vladimir Voroshilov + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVCODEC_LSP_H +#define AVCODEC_LSP_H + +#include + +/** + (I.F) means fixed-point value with F fractional and I integer bits +*/ + +/** + * \brief ensure a minimum distance between LSFs + * \param[in,out] lsfq LSF to check and adjust + * \param lsfq_min_distance minimum distance between LSFs + * \param lsfq_min minimum allowed LSF value + * \param lsfq_max maximum allowed LSF value + * \param lp_order LP filter order + */ +void ff_acelp_reorder_lsf(int16_t* lsfq, int lsfq_min_distance, int lsfq_min, int lsfq_max, int lp_order); + +/** + * Adjust the quantized LSFs so they are increasing and not too close. + * + * This step is not mentioned in the AMR spec but is in the reference C decoder. + * Omitting this step creates audible distortion on the sinusoidal sweep + * test vectors in 3GPP TS 26.074. + * + * @param[in,out] lsf LSFs in Hertz + * @param min_spacing minimum distance between two consecutive lsf values + * @param size size of the lsf vector + */ +void ff_set_min_dist_lsf(float *lsf, double min_spacing, int size); + +/** + * \brief Convert LSF to LSP + * \param[out] lsp LSP coefficients (-0x8000 <= (0.15) < 0x8000) + * \param lsf normalized LSF coefficients (0 <= (2.13) < 0x2000 * PI) + * \param lp_order LP filter order + * + * \remark It is safe to pass the same array into the lsf and lsp parameters. + */ +void ff_acelp_lsf2lsp(int16_t *lsp, const int16_t *lsf, int lp_order); + +/** + * \brief LSP to LP conversion (3.2.6 of G.729) + * \param[out] lp decoded LP coefficients (-0x8000 <= (3.12) < 0x8000) + * \param lsp LSP coefficients (-0x8000 <= (0.15) < 0x8000) + * \param lp_half_order LP filter order, divided by 2 + */ +void ff_acelp_lsp2lpc(int16_t* lp, const int16_t* lsp, int lp_half_order); + +/** + * \brief Interpolate LSP for the first subframe and convert LSP -> LP for both subframes (3.2.5 and 3.2.6 of G.729) + * \param[out] lp_1st decoded LP coefficients for first subframe (-0x8000 <= (3.12) < 0x8000) + * \param[out] lp_2nd decoded LP coefficients for second subframe (-0x8000 <= (3.12) < 0x8000) + * \param lsp_2nd LSP coefficients of the second subframe (-0x8000 <= (0.15) < 0x8000) + * \param lsp_prev LSP coefficients from the second subframe of the previous frame (-0x8000 <= (0.15) < 0x8000) + * \param lp_order LP filter order + */ +void ff_acelp_lp_decode(int16_t* lp_1st, int16_t* lp_2nd, const int16_t* lsp_2nd, const int16_t* lsp_prev, int lp_order); + + +#define MAX_LP_HALF_ORDER 8 +#define MAX_LP_ORDER (2*MAX_LP_HALF_ORDER) + +/** + * Reconstruct LPC coefficients from the line spectral pair frequencies. + * + * @param lsp line spectral pairs in cosine domain + * @param lpc linear predictive coding coefficients + * @param lp_half_order half the number of the amount of LPCs to be + * reconstructed, need to be smaller or equal to MAX_LP_HALF_ORDER + * + * @note buffers should have a minimux size of 2*lp_half_order elements. + * + * TIA/EIA/IS-733 2.4.3.3.5 + */ +void ff_acelp_lspd2lpc(const double *lsp, float *lpc, int lp_half_order); + +/** + * Sort values in ascending order. + * + * @note O(n) if data already sorted, O(n^2) - otherwise + */ +void ff_sort_nearly_sorted_floats(float *vals, int len); + +/** + * Compute the Pa / (1 + z(-1)) or Qa / (1 - z(-1)) coefficients + * needed for LSP to LPC conversion. + * We only need to calculate the 6 first elements of the polynomial. + * + * @param lsp line spectral pairs in cosine domain + * @param[out] f polynomial input/output as a vector + * + * TIA/EIA/IS-733 2.4.3.3.5-1/2 + */ +void ff_lsp2polyf(const double *lsp, double *f, int lp_half_order); + +#endif /* AVCODEC_LSP_H */ diff --git a/lib/rbcodec/codecs/libwmavoice/mathops.h b/lib/rbcodec/codecs/libwmavoice/mathops.h new file mode 100644 index 0000000000..4d88ed14c9 --- /dev/null +++ b/lib/rbcodec/codecs/libwmavoice/mathops.h @@ -0,0 +1,182 @@ +/* + * simple math operations + * Copyright (c) 2001, 2002 Fabrice Bellard + * Copyright (c) 2006 Michael Niedermayer et al + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ +#ifndef AVCODEC_MATHOPS_H +#define AVCODEC_MATHOPS_H + +#include "libavutil/common.h" + +#if ARCH_ARM +# include "arm/mathops.h" +#elif ARCH_AVR32 +# include "avr32/mathops.h" +#elif ARCH_BFIN +# include "bfin/mathops.h" +#elif ARCH_MIPS +# include "mips/mathops.h" +#elif ARCH_PPC +# include "ppc/mathops.h" +#elif ARCH_X86 +# include "x86/mathops.h" +#endif + +/* generic implementation */ + +#ifndef MULL +# define MULL(a,b,s) (((int64_t)(a) * (int64_t)(b)) >> (s)) +#endif + +#ifndef MULH +//gcc 3.4 creates an incredibly bloated mess out of this +//# define MULH(a,b) (((int64_t)(a) * (int64_t)(b))>>32) + +static av_always_inline int MULH(int a, int b){ + return ((int64_t)(a) * (int64_t)(b))>>32; +} +#endif + +#ifndef UMULH +static av_always_inline unsigned UMULH(unsigned a, unsigned b){ + return ((uint64_t)(a) * (uint64_t)(b))>>32; +} +#endif + +#ifndef MUL64 +# define MUL64(a,b) ((int64_t)(a) * (int64_t)(b)) +#endif + +#ifndef MAC64 +# define MAC64(d, a, b) ((d) += MUL64(a, b)) +#endif + +#ifndef MLS64 +# define MLS64(d, a, b) ((d) -= MUL64(a, b)) +#endif + +/* signed 16x16 -> 32 multiply add accumulate */ +#ifndef MAC16 +# define MAC16(rt, ra, rb) rt += (ra) * (rb) +#endif + +/* signed 16x16 -> 32 multiply */ +#ifndef MUL16 +# define MUL16(ra, rb) ((ra) * (rb)) +#endif + +#ifndef MLS16 +# define MLS16(rt, ra, rb) ((rt) -= (ra) * (rb)) +#endif + +/* median of 3 */ +#ifndef mid_pred +#define mid_pred mid_pred +static inline av_const int mid_pred(int a, int b, int c) +{ +#if 0 + int t= (a-b)&((a-b)>>31); + a-=t; + b+=t; + b-= (b-c)&((b-c)>>31); + b+= (a-b)&((a-b)>>31); + + return b; +#else + if(a>b){ + if(c>b){ + if(c>a) b=a; + else b=c; + } + }else{ + if(b>c){ + if(c>a) b=c; + else b=a; + } + } + return b; +#endif +} +#endif + +#ifndef sign_extend +static inline av_const int sign_extend(int val, unsigned bits) +{ + return (val << ((8 * sizeof(int)) - bits)) >> ((8 * sizeof(int)) - bits); +} +#endif + +#ifndef zero_extend +static inline av_const unsigned zero_extend(unsigned val, unsigned bits) +{ + return (val << ((8 * sizeof(int)) - bits)) >> ((8 * sizeof(int)) - bits); +} +#endif + +#ifndef COPY3_IF_LT +#define COPY3_IF_LT(x, y, a, b, c, d)\ +if ((y) < (x)) {\ + (x) = (y);\ + (a) = (b);\ + (c) = (d);\ +} +#endif + +#ifndef NEG_SSR32 +# define NEG_SSR32(a,s) ((( int32_t)(a))>>(32-(s))) +#endif + +#ifndef NEG_USR32 +# define NEG_USR32(a,s) (((uint32_t)(a))>>(32-(s))) +#endif + +#if HAVE_BIGENDIAN +# ifndef PACK_2U8 +# define PACK_2U8(a,b) (((a) << 8) | (b)) +# endif +# ifndef PACK_4U8 +# define PACK_4U8(a,b,c,d) (((a) << 24) | ((b) << 16) | ((c) << 8) | (d)) +# endif +# ifndef PACK_2U16 +# define PACK_2U16(a,b) (((a) << 16) | (b)) +# endif +#else +# ifndef PACK_2U8 +# define PACK_2U8(a,b) (((b) << 8) | (a)) +# endif +# ifndef PACK_4U2 +# define PACK_4U8(a,b,c,d) (((d) << 24) | ((c) << 16) | ((b) << 8) | (a)) +# endif +# ifndef PACK_2U16 +# define PACK_2U16(a,b) (((b) << 16) | (a)) +# endif +#endif + +#ifndef PACK_2S8 +# define PACK_2S8(a,b) PACK_2U8((a)&255, (b)&255) +#endif +#ifndef PACK_4S8 +# define PACK_4S8(a,b,c,d) PACK_4U8((a)&255, (b)&255, (c)&255, (d)&255) +#endif +#ifndef PACK_2S16 +# define PACK_2S16(a,b) PACK_2U16((a)&0xffff, (b)&0xffff) +#endif + +#endif /* AVCODEC_MATHOPS_H */ + diff --git a/lib/rbcodec/codecs/libwmavoice/mdct.c b/lib/rbcodec/codecs/libwmavoice/mdct.c new file mode 100644 index 0000000000..58bff3517b --- /dev/null +++ b/lib/rbcodec/codecs/libwmavoice/mdct.c @@ -0,0 +1,234 @@ +/* + * MDCT/IMDCT transforms + * Copyright (c) 2002 Fabrice Bellard + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include +#include +#include "libavutil/common.h" +#include "libavutil/mathematics.h" +#include "fft.h" + +/** + * @file + * MDCT/IMDCT transforms. + */ + +// Generate a Kaiser-Bessel Derived Window. +#define BESSEL_I0_ITER 50 // default: 50 iterations of Bessel I0 approximation +av_cold void ff_kbd_window_init(float *window, float alpha, int n) +{ + int i, j; + double sum = 0.0, bessel, tmp; + double local_window[FF_KBD_WINDOW_MAX]; + double alpha2 = (alpha * M_PI / n) * (alpha * M_PI / n); + + //assert(n <= FF_KBD_WINDOW_MAX); + + for (i = 0; i < n; i++) { + tmp = i * (n - i) * alpha2; + bessel = 1.0; + for (j = BESSEL_I0_ITER; j > 0; j--) + bessel = bessel * tmp / (j * j) + 1; + sum += bessel; + local_window[i] = sum; + } + + sum++; + for (i = 0; i < n; i++) + window[i] = sqrt(local_window[i] / sum); +} + +#include "mdct_tablegen.h" + +/** + * init MDCT or IMDCT computation. + */ +av_cold int ff_mdct_init(FFTContext *s, int nbits, int inverse, double scale) +{ + int n, n4, i; + double alpha, theta; + int tstep; + + memset(s, 0, sizeof(*s)); + n = 1 << nbits; + s->mdct_bits = nbits; + s->mdct_size = n; + n4 = n >> 2; + s->permutation = FF_MDCT_PERM_NONE; + + if (ff_fft_init(s, s->mdct_bits - 2, inverse) < 0) + goto fail; + + s->tcos = av_malloc(n/2 * sizeof(FFTSample)); + if (!s->tcos) + goto fail; + + switch (s->permutation) { + case FF_MDCT_PERM_NONE: + s->tsin = s->tcos + n4; + tstep = 1; + break; + case FF_MDCT_PERM_INTERLEAVE: + s->tsin = s->tcos + 1; + tstep = 2; + break; + default: + goto fail; + } + + theta = 1.0 / 8.0 + (scale < 0 ? n4 : 0); + scale = sqrt(fabs(scale)); + for(i=0;itcos[i*tstep] = -cos(alpha) * scale; + s->tsin[i*tstep] = -sin(alpha) * scale; + } + return 0; + fail: + ff_mdct_end(s); + return -1; +} + +/* complex multiplication: p = a * b */ +#define CMUL(pre, pim, are, aim, bre, bim) \ +{\ + FFTSample _are = (are);\ + FFTSample _aim = (aim);\ + FFTSample _bre = (bre);\ + FFTSample _bim = (bim);\ + (pre) = _are * _bre - _aim * _bim;\ + (pim) = _are * _bim + _aim * _bre;\ +} + +/** + * Compute the middle half of the inverse MDCT of size N = 2^nbits, + * thus excluding the parts that can be derived by symmetry + * @param output N/2 samples + * @param input N/2 samples + */ +void ff_imdct_half_c(FFTContext *s, FFTSample *output, const FFTSample *input) +{ + int k, n8, n4, n2, n, j; + const uint16_t *revtab = s->revtab; + const FFTSample *tcos = s->tcos; + const FFTSample *tsin = s->tsin; + const FFTSample *in1, *in2; + FFTComplex *z = (FFTComplex *)output; + + n = 1 << s->mdct_bits; + n2 = n >> 1; + n4 = n >> 2; + n8 = n >> 3; + + /* pre rotation */ + in1 = input; + in2 = input + n2 - 1; + for(k = 0; k < n4; k++) { + j=revtab[k]; + CMUL(z[j].re, z[j].im, *in2, *in1, tcos[k], tsin[k]); + in1 += 2; + in2 -= 2; + } + ff_fft_calc(s, z); + + /* post rotation + reordering */ + for(k = 0; k < n8; k++) { + FFTSample r0, i0, r1, i1; + CMUL(r0, i1, z[n8-k-1].im, z[n8-k-1].re, tsin[n8-k-1], tcos[n8-k-1]); + CMUL(r1, i0, z[n8+k ].im, z[n8+k ].re, tsin[n8+k ], tcos[n8+k ]); + z[n8-k-1].re = r0; + z[n8-k-1].im = i0; + z[n8+k ].re = r1; + z[n8+k ].im = i1; + } +} + +/** + * Compute inverse MDCT of size N = 2^nbits + * @param output N samples + * @param input N/2 samples + */ +void ff_imdct_calc_c(FFTContext *s, FFTSample *output, const FFTSample *input) +{ + int k; + int n = 1 << s->mdct_bits; + int n2 = n >> 1; + int n4 = n >> 2; + + ff_imdct_half_c(s, output+n4, input); + + for(k = 0; k < n4; k++) { + output[k] = -output[n2-k-1]; + output[n-k-1] = output[n2+k]; + } +} + +/** + * Compute MDCT of size N = 2^nbits + * @param input N samples + * @param out N/2 samples + */ +void ff_mdct_calc_c(FFTContext *s, FFTSample *out, const FFTSample *input) +{ + int i, j, n, n8, n4, n2, n3; + FFTSample re, im; + const uint16_t *revtab = s->revtab; + const FFTSample *tcos = s->tcos; + const FFTSample *tsin = s->tsin; + FFTComplex *x = (FFTComplex *)out; + + n = 1 << s->mdct_bits; + n2 = n >> 1; + n4 = n >> 2; + n8 = n >> 3; + n3 = 3 * n4; + + /* pre rotation */ + for(i=0;itcos); + ff_fft_end(s); +} diff --git a/lib/rbcodec/codecs/libwmavoice/mdct_tablegen.h b/lib/rbcodec/codecs/libwmavoice/mdct_tablegen.h new file mode 100644 index 0000000000..51a0094221 --- /dev/null +++ b/lib/rbcodec/codecs/libwmavoice/mdct_tablegen.h @@ -0,0 +1,60 @@ +/* + * Header file for hardcoded MDCT tables + * + * Copyright (c) 2009 Reimar Döffinger + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include +// do not use libavutil/libm.h since this is compiled both +// for the host and the target and config.h is only valid for the target +#include +#include "libavutil/attributes.h" + +#if !CONFIG_HARDCODED_TABLES +SINETABLE( 32); +SINETABLE( 64); +SINETABLE( 128); +SINETABLE( 256); +SINETABLE( 512); +SINETABLE(1024); +SINETABLE(2048); +SINETABLE(4096); +#else +#include "libavcodec/mdct_tables.h" +#endif + +SINETABLE_CONST float * const ff_sine_windows[] = { + NULL, NULL, NULL, NULL, NULL, // unused + ff_sine_32 , ff_sine_64 , + ff_sine_128, ff_sine_256, ff_sine_512, ff_sine_1024, ff_sine_2048, ff_sine_4096 +}; + +// Generate a sine window. +av_cold void ff_sine_window_init(float *window, int n) { + int i; + for(i = 0; i < n; i++) + window[i] = sinf((i + 0.5) * (M_PI / (2.0 * n))); +} + +av_cold void ff_init_ff_sine_windows(int index) { + assert(index >= 0 && index < FF_ARRAY_ELEMS(ff_sine_windows)); +#if !CONFIG_HARDCODED_TABLES + ff_sine_window_init(ff_sine_windows[index], 1 << index); +#endif +} diff --git a/lib/rbcodec/codecs/libwmavoice/put_bits.h b/lib/rbcodec/codecs/libwmavoice/put_bits.h new file mode 100644 index 0000000000..d301d0afcc --- /dev/null +++ b/lib/rbcodec/codecs/libwmavoice/put_bits.h @@ -0,0 +1,343 @@ +/* + * copyright (c) 2004 Michael Niedermayer + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * bitstream writer API + */ + +#ifndef AVCODEC_PUT_BITS_H +#define AVCODEC_PUT_BITS_H + +#include +#include +#include +#include "libavutil/bswap.h" +#include "libavutil/common.h" +#include "libavutil/intreadwrite.h" +#include "libavutil/log.h" +#include "mathops.h" + +//#define ALT_BITSTREAM_WRITER +//#define ALIGNED_BITSTREAM_WRITER + +/* buf and buf_end must be present and used by every alternative writer. */ +typedef struct PutBitContext { +#ifdef ALT_BITSTREAM_WRITER + uint8_t *buf, *buf_end; + int index; +#else + uint32_t bit_buf; + int bit_left; + uint8_t *buf, *buf_ptr, *buf_end; +#endif + int size_in_bits; +} PutBitContext; + +/** + * Initialize the PutBitContext s. + * + * @param buffer the buffer where to put bits + * @param buffer_size the size in bytes of buffer + */ +static inline void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size) +{ + if(buffer_size < 0) { + buffer_size = 0; + buffer = NULL; + } + + s->size_in_bits= 8*buffer_size; + s->buf = buffer; + s->buf_end = s->buf + buffer_size; +#ifdef ALT_BITSTREAM_WRITER + s->index=0; + ((uint32_t*)(s->buf))[0]=0; +// memset(buffer, 0, buffer_size); +#else + s->buf_ptr = s->buf; + s->bit_left=32; + s->bit_buf=0; +#endif +} + +/** + * @return the total number of bits written to the bitstream. + */ +static inline int put_bits_count(PutBitContext *s) +{ +#ifdef ALT_BITSTREAM_WRITER + return s->index; +#else + return (s->buf_ptr - s->buf) * 8 + 32 - s->bit_left; +#endif +} + +/** + * Pad the end of the output stream with zeros. + */ +static inline void flush_put_bits(PutBitContext *s) +{ +#ifdef ALT_BITSTREAM_WRITER + align_put_bits(s); +#else +#ifndef BITSTREAM_WRITER_LE + s->bit_buf<<= s->bit_left; +#endif + while (s->bit_left < 32) { + /* XXX: should test end of buffer */ +#ifdef BITSTREAM_WRITER_LE + *s->buf_ptr++=s->bit_buf; + s->bit_buf>>=8; +#else + *s->buf_ptr++=s->bit_buf >> 24; + s->bit_buf<<=8; +#endif + s->bit_left+=8; + } + s->bit_left=32; + s->bit_buf=0; +#endif +} + +#if defined(ALT_BITSTREAM_WRITER) || defined(BITSTREAM_WRITER_LE) +#define align_put_bits align_put_bits_unsupported_here +#define ff_put_string ff_put_string_unsupported_here +#define ff_copy_bits ff_copy_bits_unsupported_here +#else +/** + * Pad the bitstream with zeros up to the next byte boundary. + */ +void align_put_bits(PutBitContext *s); + +/** + * Put the string string in the bitstream. + * + * @param terminate_string 0-terminates the written string if value is 1 + */ +void ff_put_string(PutBitContext *pb, const char *string, int terminate_string); + +/** + * Copy the content of src to the bitstream. + * + * @param length the number of bits of src to copy + */ +void ff_copy_bits(PutBitContext *pb, const uint8_t *src, int length); +#endif + +/** + * Write up to 31 bits into a bitstream. + * Use put_bits32 to write 32 bits. + */ +static inline void put_bits(PutBitContext *s, int n, unsigned int value) +#ifndef ALT_BITSTREAM_WRITER +{ + unsigned int bit_buf; + int bit_left; + + // printf("put_bits=%d %x\n", n, value); + assert(n <= 31 && value < (1U << n)); + + bit_buf = s->bit_buf; + bit_left = s->bit_left; + + // printf("n=%d value=%x cnt=%d buf=%x\n", n, value, bit_cnt, bit_buf); + /* XXX: optimize */ +#ifdef BITSTREAM_WRITER_LE + bit_buf |= value << (32 - bit_left); + if (n >= bit_left) { +#if !HAVE_FAST_UNALIGNED + if (3 & (intptr_t) s->buf_ptr) { + AV_WL32(s->buf_ptr, bit_buf); + } else +#endif + *(uint32_t *)s->buf_ptr = av_le2ne32(bit_buf); + s->buf_ptr+=4; + bit_buf = (bit_left==32)?0:value >> bit_left; + bit_left+=32; + } + bit_left-=n; +#else + if (n < bit_left) { + bit_buf = (bit_buf<> (n - bit_left); +#if !HAVE_FAST_UNALIGNED + if (3 & (intptr_t) s->buf_ptr) { + AV_WB32(s->buf_ptr, bit_buf); + } else +#endif + *(uint32_t *)s->buf_ptr = av_be2ne32(bit_buf); + //printf("bitbuf = %08x\n", bit_buf); + s->buf_ptr+=4; + bit_left+=32 - n; + bit_buf = value; + } +#endif + + s->bit_buf = bit_buf; + s->bit_left = bit_left; +} +#else /* ALT_BITSTREAM_WRITER defined */ +{ +# ifdef ALIGNED_BITSTREAM_WRITER +# if ARCH_X86 + __asm__ volatile( + "movl %0, %%ecx \n\t" + "xorl %%eax, %%eax \n\t" + "shrdl %%cl, %1, %%eax \n\t" + "shrl %%cl, %1 \n\t" + "movl %0, %%ecx \n\t" + "shrl $3, %%ecx \n\t" + "andl $0xFFFFFFFC, %%ecx \n\t" + "bswapl %1 \n\t" + "orl %1, (%2, %%ecx) \n\t" + "bswapl %%eax \n\t" + "addl %3, %0 \n\t" + "movl %%eax, 4(%2, %%ecx) \n\t" + : "=&r" (s->index), "=&r" (value) + : "r" (s->buf), "r" (n), "0" (s->index), "1" (value<<(-n)) + : "%eax", "%ecx" + ); +# else + int index= s->index; + uint32_t *ptr= ((uint32_t *)s->buf)+(index>>5); + + value<<= 32-n; + + ptr[0] |= av_be2ne32(value>>(index&31)); + ptr[1] = av_be2ne32(value<<(32-(index&31))); +//if(n>24) printf("%d %d\n", n, value); + index+= n; + s->index= index; +# endif +# else //ALIGNED_BITSTREAM_WRITER +# if ARCH_X86 + __asm__ volatile( + "movl $7, %%ecx \n\t" + "andl %0, %%ecx \n\t" + "addl %3, %%ecx \n\t" + "negl %%ecx \n\t" + "shll %%cl, %1 \n\t" + "bswapl %1 \n\t" + "movl %0, %%ecx \n\t" + "shrl $3, %%ecx \n\t" + "orl %1, (%%ecx, %2) \n\t" + "addl %3, %0 \n\t" + "movl $0, 4(%%ecx, %2) \n\t" + : "=&r" (s->index), "=&r" (value) + : "r" (s->buf), "r" (n), "0" (s->index), "1" (value) + : "%ecx" + ); +# else + int index= s->index; + uint32_t *ptr= (uint32_t*)(((uint8_t *)s->buf)+(index>>3)); + + ptr[0] |= av_be2ne32(value<<(32-n-(index&7) )); + ptr[1] = 0; +//if(n>24) printf("%d %d\n", n, value); + index+= n; + s->index= index; +# endif +# endif //!ALIGNED_BITSTREAM_WRITER +} +#endif + +static inline void put_sbits(PutBitContext *pb, int n, int32_t value) +{ + assert(n >= 0 && n <= 31); + + put_bits(pb, n, value & ((1<> 16; +#ifdef BITSTREAM_WRITER_LE + put_bits(s, 16, lo); + put_bits(s, 16, hi); +#else + put_bits(s, 16, hi); + put_bits(s, 16, lo); +#endif +} + +/** + * Return the pointer to the byte where the bitstream writer will put + * the next bit. + */ +static inline uint8_t* put_bits_ptr(PutBitContext *s) +{ +#ifdef ALT_BITSTREAM_WRITER + return s->buf + (s->index>>3); +#else + return s->buf_ptr; +#endif +} + +/** + * Skip the given number of bytes. + * PutBitContext must be flushed & aligned to a byte boundary before calling this. + */ +static inline void skip_put_bytes(PutBitContext *s, int n) +{ + assert((put_bits_count(s)&7)==0); +#ifdef ALT_BITSTREAM_WRITER + FIXME may need some cleaning of the buffer + s->index += n<<3; +#else + assert(s->bit_left==32); + s->buf_ptr += n; +#endif +} + +/** + * Skip the given number of bits. + * Must only be used if the actual values in the bitstream do not matter. + * If n is 0 the behavior is undefined. + */ +static inline void skip_put_bits(PutBitContext *s, int n) +{ +#ifdef ALT_BITSTREAM_WRITER + s->index += n; +#else + s->bit_left -= n; + s->buf_ptr-= 4*(s->bit_left>>5); + s->bit_left &= 31; +#endif +} + +/** + * Change the end of the buffer. + * + * @param size the new size in bytes of the buffer where to put bits + */ +static inline void set_put_bits_buffer_size(PutBitContext *s, int size) +{ + s->buf_end= s->buf + size; +} + +#endif /* AVCODEC_PUT_BITS_H */ diff --git a/lib/rbcodec/codecs/libwmavoice/rdft.c b/lib/rbcodec/codecs/libwmavoice/rdft.c new file mode 100644 index 0000000000..bc44f5aef2 --- /dev/null +++ b/lib/rbcodec/codecs/libwmavoice/rdft.c @@ -0,0 +1,133 @@ +/* + * (I)RDFT transforms + * Copyright (c) 2009 Alex Converse + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ +#include +#include +#include "libavutil/mathematics.h" +#include "fft.h" + +/** + * @file + * (Inverse) Real Discrete Fourier Transforms. + */ + +/* sin(2*pi*x/n) for 0<=xnbits; + const float k1 = 0.5; + const float k2 = 0.5 - s->inverse; + const FFTSample *tcos = s->tcos; + const FFTSample *tsin = s->tsin; + + if (!s->inverse) { + ff_fft_permute(&s->fft, (FFTComplex*)data); + ff_fft_calc(&s->fft, (FFTComplex*)data); + } + /* i=0 is a special case because of packing, the DC term is real, so we + are going to throw the N/2 term (also real) in with it. */ + ev.re = data[0]; + data[0] = ev.re+data[1]; + data[1] = ev.re-data[1]; + for (i = 1; i < (n>>2); i++) { + i1 = 2*i; + i2 = n-i1; + /* Separate even and odd FFTs */ + ev.re = k1*(data[i1 ]+data[i2 ]); + od.im = -k2*(data[i1 ]-data[i2 ]); + ev.im = k1*(data[i1+1]-data[i2+1]); + od.re = k2*(data[i1+1]+data[i2+1]); + /* Apply twiddle factors to the odd FFT and add to the even FFT */ + data[i1 ] = ev.re + od.re*tcos[i] - od.im*tsin[i]; + data[i1+1] = ev.im + od.im*tcos[i] + od.re*tsin[i]; + data[i2 ] = ev.re - od.re*tcos[i] + od.im*tsin[i]; + data[i2+1] = -ev.im + od.im*tcos[i] + od.re*tsin[i]; + } + data[2*i+1]=s->sign_convention*data[2*i+1]; + if (s->inverse) { + data[0] *= k1; + data[1] *= k1; + ff_fft_permute(&s->fft, (FFTComplex*)data); + ff_fft_calc(&s->fft, (FFTComplex*)data); + } +} + +av_cold int ff_rdft_init(RDFTContext *s, int nbits, enum RDFTransformType trans) +{ + int n = 1 << nbits; + int i; + const double theta = (trans == DFT_R2C || trans == DFT_C2R ? -1 : 1)*2*M_PI/n; + + s->nbits = nbits; + s->inverse = trans == IDFT_C2R || trans == DFT_C2R; + s->sign_convention = trans == IDFT_R2C || trans == DFT_C2R ? 1 : -1; + + if (nbits < 4 || nbits > 16) + return -1; + + if (ff_fft_init(&s->fft, nbits-1, trans == IDFT_C2R || trans == IDFT_R2C) < 0) + return -1; + + ff_init_ff_cos_tabs(nbits); + s->tcos = ff_cos_tabs[nbits]; + s->tsin = ff_sin_tabs[nbits]+(trans == DFT_R2C || trans == DFT_C2R)*(n>>2); +#if !CONFIG_HARDCODED_TABLES + for (i = 0; i < (n>>2); i++) { + s->tsin[i] = sin(i*theta); + } +#endif + s->rdft_calc = ff_rdft_calc_c; + + //if (ARCH_ARM) ff_rdft_init_arm(s); + + return 0; +} + +av_cold void ff_rdft_end(RDFTContext *s) +{ + ff_fft_end(&s->fft); +} diff --git a/lib/rbcodec/codecs/libwmavoice/utils.c b/lib/rbcodec/codecs/libwmavoice/utils.c new file mode 100644 index 0000000000..ad098f4636 --- /dev/null +++ b/lib/rbcodec/codecs/libwmavoice/utils.c @@ -0,0 +1,1188 @@ +/* + * utils for libavcodec + * Copyright (c) 2001 Fabrice Bellard + * Copyright (c) 2002-2004 Michael Niedermayer + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * utils. + */ + +//#include "libavutil/avstring.h" +//#include "libavutil/integer.h" +//#include "libavutil/crc.h" +//#include "libavutil/pixdesc.h" +//#include "libavcore/imgutils.h" +#include "avcodec.h" +//#include "dsputil.h" +//#include "opt.h" +//#include "imgconvert.h" +//#include "audioconvert.h" +#include "internal.h" +#include +#include +#include +#include + +#if 0 +static int volatile entangled_thread_counter=0; +int (*ff_lockmgr_cb)(void **mutex, enum AVLockOp op); +static void *codec_mutex; + +void *av_fast_realloc(void *ptr, unsigned int *size, unsigned int min_size) +{ + if(min_size < *size) + return ptr; + + *size= FFMAX(17*min_size/16 + 32, min_size); + + ptr= av_realloc(ptr, *size); + if(!ptr) //we could set this to the unmodified min_size but this is safer if the user lost the ptr and uses NULL now + *size= 0; + + return ptr; +} + +void av_fast_malloc(void *ptr, unsigned int *size, unsigned int min_size) +{ + void **p = ptr; + if (min_size < *size) + return; + *size= FFMAX(17*min_size/16 + 32, min_size); + av_free(*p); + *p = av_malloc(*size); + if (!*p) *size = 0; +} + +/* encoder management */ +static AVCodec *first_avcodec = NULL; + +AVCodec *av_codec_next(AVCodec *c){ + if(c) return c->next; + else return first_avcodec; +} + +void avcodec_register(AVCodec *codec) +{ + AVCodec **p; + avcodec_init(); + p = &first_avcodec; + while (*p != NULL) p = &(*p)->next; + *p = codec; + codec->next = NULL; +} + +#if LIBAVCODEC_VERSION_MAJOR < 53 +void register_avcodec(AVCodec *codec) +{ + avcodec_register(codec); +} +#endif + +unsigned avcodec_get_edge_width(void) +{ + return EDGE_WIDTH; +} + +void avcodec_set_dimensions(AVCodecContext *s, int width, int height){ + s->coded_width = width; + s->coded_height= height; + s->width = -((-width )>>s->lowres); + s->height= -((-height)>>s->lowres); +} + +typedef struct InternalBuffer{ + int last_pic_num; + uint8_t *base[4]; + uint8_t *data[4]; + int linesize[4]; + int width, height; + enum PixelFormat pix_fmt; +}InternalBuffer; + +#define INTERNAL_BUFFER_SIZE 32 + +void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height, int linesize_align[4]){ + int w_align= 1; + int h_align= 1; + + switch(s->pix_fmt){ + case PIX_FMT_YUV420P: + case PIX_FMT_YUYV422: + case PIX_FMT_UYVY422: + case PIX_FMT_YUV422P: + case PIX_FMT_YUV440P: + case PIX_FMT_YUV444P: + case PIX_FMT_GRAY8: + case PIX_FMT_GRAY16BE: + case PIX_FMT_GRAY16LE: + case PIX_FMT_YUVJ420P: + case PIX_FMT_YUVJ422P: + case PIX_FMT_YUVJ440P: + case PIX_FMT_YUVJ444P: + case PIX_FMT_YUVA420P: + w_align= 16; //FIXME check for non mpeg style codecs and use less alignment + h_align= 16; + if(s->codec_id == CODEC_ID_MPEG2VIDEO || s->codec_id == CODEC_ID_MJPEG || s->codec_id == CODEC_ID_AMV || s->codec_id == CODEC_ID_THP) + h_align= 32; // interlaced is rounded up to 2 MBs + break; + case PIX_FMT_YUV411P: + case PIX_FMT_UYYVYY411: + w_align=32; + h_align=8; + break; + case PIX_FMT_YUV410P: + if(s->codec_id == CODEC_ID_SVQ1){ + w_align=64; + h_align=64; + } + case PIX_FMT_RGB555: + if(s->codec_id == CODEC_ID_RPZA){ + w_align=4; + h_align=4; + } + case PIX_FMT_PAL8: + case PIX_FMT_BGR8: + case PIX_FMT_RGB8: + if(s->codec_id == CODEC_ID_SMC){ + w_align=4; + h_align=4; + } + break; + case PIX_FMT_BGR24: + if((s->codec_id == CODEC_ID_MSZH) || (s->codec_id == CODEC_ID_ZLIB)){ + w_align=4; + h_align=4; + } + break; + default: + w_align= 1; + h_align= 1; + break; + } + + *width = FFALIGN(*width , w_align); + *height= FFALIGN(*height, h_align); + if(s->codec_id == CODEC_ID_H264) + *height+=2; // some of the optimized chroma MC reads one line too much + + linesize_align[0] = + linesize_align[1] = + linesize_align[2] = + linesize_align[3] = STRIDE_ALIGN; +//STRIDE_ALIGN is 8 for SSE* but this does not work for SVQ1 chroma planes +//we could change STRIDE_ALIGN to 16 for x86/sse but it would increase the +//picture size unneccessarily in some cases. The solution here is not +//pretty and better ideas are welcome! +#if HAVE_MMX + if(s->codec_id == CODEC_ID_SVQ1 || s->codec_id == CODEC_ID_VP5 || + s->codec_id == CODEC_ID_VP6 || s->codec_id == CODEC_ID_VP6F || + s->codec_id == CODEC_ID_VP6A) { + linesize_align[0] = + linesize_align[1] = + linesize_align[2] = 16; + } +#endif +} + +void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height){ + int chroma_shift = av_pix_fmt_descriptors[s->pix_fmt].log2_chroma_w; + int linesize_align[4]; + int align; + avcodec_align_dimensions2(s, width, height, linesize_align); + align = FFMAX(linesize_align[0], linesize_align[3]); + linesize_align[1] <<= chroma_shift; + linesize_align[2] <<= chroma_shift; + align = FFMAX3(align, linesize_align[1], linesize_align[2]); + *width=FFALIGN(*width, align); +} + +#if LIBAVCODEC_VERSION_MAJOR < 53 +int avcodec_check_dimensions(void *av_log_ctx, unsigned int w, unsigned int h){ + return av_check_image_size(w, h, 0, av_log_ctx); +} +#endif + +int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic){ + int i; + int w= s->width; + int h= s->height; + InternalBuffer *buf; + int *picture_number; + + if(pic->data[0]!=NULL) { + av_log(s, AV_LOG_ERROR, "pic->data[0]!=NULL in avcodec_default_get_buffer\n"); + return -1; + } + if(s->internal_buffer_count >= INTERNAL_BUFFER_SIZE) { + av_log(s, AV_LOG_ERROR, "internal_buffer_count overflow (missing release_buffer?)\n"); + return -1; + } + + if(av_check_image_size(w, h, 0, s)) + return -1; + + if(s->internal_buffer==NULL){ + s->internal_buffer= av_mallocz((INTERNAL_BUFFER_SIZE+1)*sizeof(InternalBuffer)); + } +#if 0 + s->internal_buffer= av_fast_realloc( + s->internal_buffer, + &s->internal_buffer_size, + sizeof(InternalBuffer)*FFMAX(99, s->internal_buffer_count+1)/*FIXME*/ + ); +#endif + + buf= &((InternalBuffer*)s->internal_buffer)[s->internal_buffer_count]; + picture_number= &(((InternalBuffer*)s->internal_buffer)[INTERNAL_BUFFER_SIZE]).last_pic_num; //FIXME ugly hack + (*picture_number)++; + + if(buf->base[0] && (buf->width != w || buf->height != h || buf->pix_fmt != s->pix_fmt)){ + for(i=0; i<4; i++){ + av_freep(&buf->base[i]); + buf->data[i]= NULL; + } + } + + if(buf->base[0]){ + pic->age= *picture_number - buf->last_pic_num; + buf->last_pic_num= *picture_number; + }else{ + int h_chroma_shift, v_chroma_shift; + int size[4] = {0}; + int tmpsize; + int unaligned; + AVPicture picture; + int stride_align[4]; + + avcodec_get_chroma_sub_sample(s->pix_fmt, &h_chroma_shift, &v_chroma_shift); + + avcodec_align_dimensions2(s, &w, &h, stride_align); + + if(!(s->flags&CODEC_FLAG_EMU_EDGE)){ + w+= EDGE_WIDTH*2; + h+= EDGE_WIDTH*2; + } + + do { + // NOTE: do not align linesizes individually, this breaks e.g. assumptions + // that linesize[0] == 2*linesize[1] in the MPEG-encoder for 4:2:2 + av_fill_image_linesizes(picture.linesize, s->pix_fmt, w); + // increase alignment of w for next try (rhs gives the lowest bit set in w) + w += w & ~(w-1); + + unaligned = 0; + for (i=0; i<4; i++){ + unaligned |= picture.linesize[i] % stride_align[i]; + } + } while (unaligned); + + tmpsize = av_fill_image_pointers(picture.data, s->pix_fmt, h, NULL, picture.linesize); + if (tmpsize < 0) + return -1; + + for (i=0; i<3 && picture.data[i+1]; i++) + size[i] = picture.data[i+1] - picture.data[i]; + size[i] = tmpsize - (picture.data[i] - picture.data[0]); + + buf->last_pic_num= -256*256*256*64; + memset(buf->base, 0, sizeof(buf->base)); + memset(buf->data, 0, sizeof(buf->data)); + + for(i=0; i<4 && size[i]; i++){ + const int h_shift= i==0 ? 0 : h_chroma_shift; + const int v_shift= i==0 ? 0 : v_chroma_shift; + + buf->linesize[i]= picture.linesize[i]; + + buf->base[i]= av_malloc(size[i]+16); //FIXME 16 + if(buf->base[i]==NULL) return -1; + memset(buf->base[i], 128, size[i]); + + // no edge if EDGE EMU or not planar YUV + if((s->flags&CODEC_FLAG_EMU_EDGE) || !size[2]) + buf->data[i] = buf->base[i]; + else + buf->data[i] = buf->base[i] + FFALIGN((buf->linesize[i]*EDGE_WIDTH>>v_shift) + (EDGE_WIDTH>>h_shift), stride_align[i]); + } + if(size[1] && !size[2]) + ff_set_systematic_pal((uint32_t*)buf->data[1], s->pix_fmt); + buf->width = s->width; + buf->height = s->height; + buf->pix_fmt= s->pix_fmt; + pic->age= 256*256*256*64; + } + pic->type= FF_BUFFER_TYPE_INTERNAL; + + for(i=0; i<4; i++){ + pic->base[i]= buf->base[i]; + pic->data[i]= buf->data[i]; + pic->linesize[i]= buf->linesize[i]; + } + s->internal_buffer_count++; + + pic->reordered_opaque= s->reordered_opaque; + + if(s->debug&FF_DEBUG_BUFFERS) + av_log(s, AV_LOG_DEBUG, "default_get_buffer called on pic %p, %d buffers used\n", pic, s->internal_buffer_count); + + return 0; +} + +void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic){ + int i; + InternalBuffer *buf, *last; + + assert(pic->type==FF_BUFFER_TYPE_INTERNAL); + assert(s->internal_buffer_count); + + buf = NULL; /* avoids warning */ + for(i=0; iinternal_buffer_count; i++){ //just 3-5 checks so is not worth to optimize + buf= &((InternalBuffer*)s->internal_buffer)[i]; + if(buf->data[0] == pic->data[0]) + break; + } + assert(i < s->internal_buffer_count); + s->internal_buffer_count--; + last = &((InternalBuffer*)s->internal_buffer)[s->internal_buffer_count]; + + FFSWAP(InternalBuffer, *buf, *last); + + for(i=0; i<4; i++){ + pic->data[i]=NULL; +// pic->base[i]=NULL; + } +//printf("R%X\n", pic->opaque); + + if(s->debug&FF_DEBUG_BUFFERS) + av_log(s, AV_LOG_DEBUG, "default_release_buffer called on pic %p, %d buffers used\n", pic, s->internal_buffer_count); +} + +int avcodec_default_reget_buffer(AVCodecContext *s, AVFrame *pic){ + AVFrame temp_pic; + int i; + + /* If no picture return a new buffer */ + if(pic->data[0] == NULL) { + /* We will copy from buffer, so must be readable */ + pic->buffer_hints |= FF_BUFFER_HINTS_READABLE; + return s->get_buffer(s, pic); + } + + /* If internal buffer type return the same buffer */ + if(pic->type == FF_BUFFER_TYPE_INTERNAL) { + pic->reordered_opaque= s->reordered_opaque; + return 0; + } + + /* + * Not internal type and reget_buffer not overridden, emulate cr buffer + */ + temp_pic = *pic; + for(i = 0; i < 4; i++) + pic->data[i] = pic->base[i] = NULL; + pic->opaque = NULL; + /* Allocate new frame */ + if (s->get_buffer(s, pic)) + return -1; + /* Copy image data from old buffer to new buffer */ + av_picture_copy((AVPicture*)pic, (AVPicture*)&temp_pic, s->pix_fmt, s->width, + s->height); + s->release_buffer(s, &temp_pic); // Release old frame + return 0; +} + +int avcodec_default_execute(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2),void *arg, int *ret, int count, int size){ + int i; + + for(i=0; ipts= AV_NOPTS_VALUE; + pic->key_frame= 1; +} + +AVFrame *avcodec_alloc_frame(void){ + AVFrame *pic= av_malloc(sizeof(AVFrame)); + + if(pic==NULL) return NULL; + + avcodec_get_frame_defaults(pic); + + return pic; +} + +int attribute_align_arg avcodec_open(AVCodecContext *avctx, AVCodec *codec) +{ + int ret= -1; + + /* If there is a user-supplied mutex locking routine, call it. */ + if (ff_lockmgr_cb) { + if ((*ff_lockmgr_cb)(&codec_mutex, AV_LOCK_OBTAIN)) + return -1; + } + + entangled_thread_counter++; + if(entangled_thread_counter != 1){ + av_log(avctx, AV_LOG_ERROR, "insufficient thread locking around avcodec_open/close()\n"); + goto end; + } + + if(avctx->codec || !codec) + goto end; + + if (codec->priv_data_size > 0) { + avctx->priv_data = av_mallocz(codec->priv_data_size); + if (!avctx->priv_data) { + ret = AVERROR(ENOMEM); + goto end; + } + } else { + avctx->priv_data = NULL; + } + + if(avctx->coded_width && avctx->coded_height) + avcodec_set_dimensions(avctx, avctx->coded_width, avctx->coded_height); + else if(avctx->width && avctx->height) + avcodec_set_dimensions(avctx, avctx->width, avctx->height); + +#define SANE_NB_CHANNELS 128U + if (((avctx->coded_width || avctx->coded_height) + && av_check_image_size(avctx->coded_width, avctx->coded_height, 0, avctx)) + || avctx->channels > SANE_NB_CHANNELS) { + ret = AVERROR(EINVAL); + goto free_and_end; + } + + avctx->codec = codec; + if ((avctx->codec_type == AVMEDIA_TYPE_UNKNOWN || avctx->codec_type == codec->type) && + avctx->codec_id == CODEC_ID_NONE) { + avctx->codec_type = codec->type; + avctx->codec_id = codec->id; + } + if(avctx->codec_id != codec->id || avctx->codec_type != codec->type){ + av_log(avctx, AV_LOG_ERROR, "codec type or id mismatches\n"); + goto free_and_end; + } + avctx->frame_number = 0; + if(avctx->codec->init){ + if(avctx->codec_type == AVMEDIA_TYPE_VIDEO && + avctx->codec->max_lowres < avctx->lowres){ + av_log(avctx, AV_LOG_ERROR, "The maximum value for lowres supported by the decoder is %d\n", + avctx->codec->max_lowres); + goto free_and_end; + } + + ret = avctx->codec->init(avctx); + if (ret < 0) { + goto free_and_end; + } + } + ret=0; +end: + entangled_thread_counter--; + + /* Release any user-supplied mutex. */ + if (ff_lockmgr_cb) { + (*ff_lockmgr_cb)(&codec_mutex, AV_LOCK_RELEASE); + } + return ret; +free_and_end: + av_freep(&avctx->priv_data); + avctx->codec= NULL; + goto end; +} + +int attribute_align_arg avcodec_encode_audio(AVCodecContext *avctx, uint8_t *buf, int buf_size, + const short *samples) +{ + if(buf_size < FF_MIN_BUFFER_SIZE && 0){ + av_log(avctx, AV_LOG_ERROR, "buffer smaller than minimum size\n"); + return -1; + } + if((avctx->codec->capabilities & CODEC_CAP_DELAY) || samples){ + int ret = avctx->codec->encode(avctx, buf, buf_size, samples); + avctx->frame_number++; + return ret; + }else + return 0; +} + +int attribute_align_arg avcodec_encode_video(AVCodecContext *avctx, uint8_t *buf, int buf_size, + const AVFrame *pict) +{ + if(buf_size < FF_MIN_BUFFER_SIZE){ + av_log(avctx, AV_LOG_ERROR, "buffer smaller than minimum size\n"); + return -1; + } + if(av_check_image_size(avctx->width, avctx->height, 0, avctx)) + return -1; + if((avctx->codec->capabilities & CODEC_CAP_DELAY) || pict){ + int ret = avctx->codec->encode(avctx, buf, buf_size, pict); + avctx->frame_number++; + emms_c(); //needed to avoid an emms_c() call before every return; + + return ret; + }else + return 0; +} + +int avcodec_encode_subtitle(AVCodecContext *avctx, uint8_t *buf, int buf_size, + const AVSubtitle *sub) +{ + int ret; + if(sub->start_display_time) { + av_log(avctx, AV_LOG_ERROR, "start_display_time must be 0.\n"); + return -1; + } + if(sub->num_rects == 0 || !sub->rects) + return -1; + ret = avctx->codec->encode(avctx, buf, buf_size, sub); + avctx->frame_number++; + return ret; +} + +#if LIBAVCODEC_VERSION_MAJOR < 53 +int attribute_align_arg avcodec_decode_video(AVCodecContext *avctx, AVFrame *picture, + int *got_picture_ptr, + const uint8_t *buf, int buf_size) +{ + AVPacket avpkt; + av_init_packet(&avpkt); + avpkt.data = buf; + avpkt.size = buf_size; + // HACK for CorePNG to decode as normal PNG by default + avpkt.flags = AV_PKT_FLAG_KEY; + + return avcodec_decode_video2(avctx, picture, got_picture_ptr, &avpkt); +} +#endif + +int attribute_align_arg avcodec_decode_video2(AVCodecContext *avctx, AVFrame *picture, + int *got_picture_ptr, + AVPacket *avpkt) +{ + int ret; + + *got_picture_ptr= 0; + if((avctx->coded_width||avctx->coded_height) && av_check_image_size(avctx->coded_width, avctx->coded_height, 0, avctx)) + return -1; + if((avctx->codec->capabilities & CODEC_CAP_DELAY) || avpkt->size){ + ret = avctx->codec->decode(avctx, picture, got_picture_ptr, + avpkt); + + emms_c(); //needed to avoid an emms_c() call before every return; + + if (*got_picture_ptr) + avctx->frame_number++; + }else + ret= 0; + + return ret; +} + +#if LIBAVCODEC_VERSION_MAJOR < 53 +int attribute_align_arg avcodec_decode_audio2(AVCodecContext *avctx, int16_t *samples, + int *frame_size_ptr, + const uint8_t *buf, int buf_size) +{ + AVPacket avpkt; + av_init_packet(&avpkt); + avpkt.data = buf; + avpkt.size = buf_size; + + return avcodec_decode_audio3(avctx, samples, frame_size_ptr, &avpkt); +} +#endif + +int attribute_align_arg avcodec_decode_audio3(AVCodecContext *avctx, int16_t *samples, + int *frame_size_ptr, + AVPacket *avpkt) +{ + int ret; + + if((avctx->codec->capabilities & CODEC_CAP_DELAY) || avpkt->size){ + //FIXME remove the check below _after_ ensuring that all audio check that the available space is enough + if(*frame_size_ptr < AVCODEC_MAX_AUDIO_FRAME_SIZE){ + av_log(avctx, AV_LOG_ERROR, "buffer smaller than AVCODEC_MAX_AUDIO_FRAME_SIZE\n"); + return -1; + } + if(*frame_size_ptr < FF_MIN_BUFFER_SIZE || + *frame_size_ptr < avctx->channels * avctx->frame_size * sizeof(int16_t)){ + av_log(avctx, AV_LOG_ERROR, "buffer %d too small\n", *frame_size_ptr); + return -1; + } + + ret = avctx->codec->decode(avctx, samples, frame_size_ptr, avpkt); + avctx->frame_number++; + }else{ + ret= 0; + *frame_size_ptr=0; + } + return ret; +} + +#if LIBAVCODEC_VERSION_MAJOR < 53 +int avcodec_decode_subtitle(AVCodecContext *avctx, AVSubtitle *sub, + int *got_sub_ptr, + const uint8_t *buf, int buf_size) +{ + AVPacket avpkt; + av_init_packet(&avpkt); + avpkt.data = buf; + avpkt.size = buf_size; + + return avcodec_decode_subtitle2(avctx, sub, got_sub_ptr, &avpkt); +} +#endif + +int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub, + int *got_sub_ptr, + AVPacket *avpkt) +{ + int ret; + + *got_sub_ptr = 0; + ret = avctx->codec->decode(avctx, sub, got_sub_ptr, avpkt); + if (*got_sub_ptr) + avctx->frame_number++; + return ret; +} + +void avsubtitle_free(AVSubtitle *sub) +{ + int i; + + for (i = 0; i < sub->num_rects; i++) + { + av_freep(&sub->rects[i]->pict.data[0]); + av_freep(&sub->rects[i]->pict.data[1]); + av_freep(&sub->rects[i]->pict.data[2]); + av_freep(&sub->rects[i]->pict.data[3]); + av_freep(&sub->rects[i]->text); + av_freep(&sub->rects[i]->ass); + av_freep(&sub->rects[i]); + } + + av_freep(&sub->rects); + + memset(sub, 0, sizeof(AVSubtitle)); +} + +av_cold int avcodec_close(AVCodecContext *avctx) +{ + /* If there is a user-supplied mutex locking routine, call it. */ + if (ff_lockmgr_cb) { + if ((*ff_lockmgr_cb)(&codec_mutex, AV_LOCK_OBTAIN)) + return -1; + } + + entangled_thread_counter++; + if(entangled_thread_counter != 1){ + av_log(avctx, AV_LOG_ERROR, "insufficient thread locking around avcodec_open/close()\n"); + entangled_thread_counter--; + return -1; + } + + if (HAVE_THREADS && avctx->thread_opaque) + avcodec_thread_free(avctx); + if (avctx->codec && avctx->codec->close) + avctx->codec->close(avctx); + avcodec_default_free_buffers(avctx); + avctx->coded_frame = NULL; + av_freep(&avctx->priv_data); + if(avctx->codec && avctx->codec->encode) + av_freep(&avctx->extradata); + avctx->codec = NULL; + entangled_thread_counter--; + + /* Release any user-supplied mutex. */ + if (ff_lockmgr_cb) { + (*ff_lockmgr_cb)(&codec_mutex, AV_LOCK_RELEASE); + } + return 0; +} + +AVCodec *avcodec_find_encoder(enum CodecID id) +{ + AVCodec *p, *experimental=NULL; + p = first_avcodec; + while (p) { + if (p->encode != NULL && p->id == id) { + if (p->capabilities & CODEC_CAP_EXPERIMENTAL && !experimental) { + experimental = p; + } else + return p; + } + p = p->next; + } + return experimental; +} + +AVCodec *avcodec_find_encoder_by_name(const char *name) +{ + AVCodec *p; + if (!name) + return NULL; + p = first_avcodec; + while (p) { + if (p->encode != NULL && strcmp(name,p->name) == 0) + return p; + p = p->next; + } + return NULL; +} + +AVCodec *avcodec_find_decoder(enum CodecID id) +{ + AVCodec *p; + p = first_avcodec; + while (p) { + if (p->decode != NULL && p->id == id) + return p; + p = p->next; + } + return NULL; +} + +AVCodec *avcodec_find_decoder_by_name(const char *name) +{ + AVCodec *p; + if (!name) + return NULL; + p = first_avcodec; + while (p) { + if (p->decode != NULL && strcmp(name,p->name) == 0) + return p; + p = p->next; + } + return NULL; +} + +static int get_bit_rate(AVCodecContext *ctx) +{ + int bit_rate; + int bits_per_sample; + + switch(ctx->codec_type) { + case AVMEDIA_TYPE_VIDEO: + case AVMEDIA_TYPE_DATA: + case AVMEDIA_TYPE_SUBTITLE: + case AVMEDIA_TYPE_ATTACHMENT: + bit_rate = ctx->bit_rate; + break; + case AVMEDIA_TYPE_AUDIO: + bits_per_sample = av_get_bits_per_sample(ctx->codec_id); + bit_rate = bits_per_sample ? ctx->sample_rate * ctx->channels * bits_per_sample : ctx->bit_rate; + break; + default: + bit_rate = 0; + break; + } + return bit_rate; +} + +size_t av_get_codec_tag_string(char *buf, size_t buf_size, unsigned int codec_tag) +{ + int i, len, ret = 0; + + for (i = 0; i < 4; i++) { + len = snprintf(buf, buf_size, + isprint(codec_tag&0xFF) ? "%c" : "[%d]", codec_tag&0xFF); + buf += len; + buf_size = buf_size > len ? buf_size - len : 0; + ret += len; + codec_tag>>=8; + } + return ret; +} + +void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode) +{ + const char *codec_name; + AVCodec *p; + char buf1[32]; + int bitrate; + AVRational display_aspect_ratio; + + if (encode) + p = avcodec_find_encoder(enc->codec_id); + else + p = avcodec_find_decoder(enc->codec_id); + + if (p) { + codec_name = p->name; + } else if (enc->codec_id == CODEC_ID_MPEG2TS) { + /* fake mpeg2 transport stream codec (currently not + registered) */ + codec_name = "mpeg2ts"; + } else if (enc->codec_name[0] != '\0') { + codec_name = enc->codec_name; + } else { + /* output avi tags */ + char tag_buf[32]; + av_get_codec_tag_string(tag_buf, sizeof(tag_buf), enc->codec_tag); + snprintf(buf1, sizeof(buf1), "%s / 0x%04X", tag_buf, enc->codec_tag); + codec_name = buf1; + } + + switch(enc->codec_type) { + case AVMEDIA_TYPE_VIDEO: + snprintf(buf, buf_size, + "Video: %s%s", + codec_name, enc->mb_decision ? " (hq)" : ""); + if (enc->pix_fmt != PIX_FMT_NONE) { + snprintf(buf + strlen(buf), buf_size - strlen(buf), + ", %s", + avcodec_get_pix_fmt_name(enc->pix_fmt)); + } + if (enc->width) { + snprintf(buf + strlen(buf), buf_size - strlen(buf), + ", %dx%d", + enc->width, enc->height); + if (enc->sample_aspect_ratio.num) { + av_reduce(&display_aspect_ratio.num, &display_aspect_ratio.den, + enc->width*enc->sample_aspect_ratio.num, + enc->height*enc->sample_aspect_ratio.den, + 1024*1024); + snprintf(buf + strlen(buf), buf_size - strlen(buf), + " [PAR %d:%d DAR %d:%d]", + enc->sample_aspect_ratio.num, enc->sample_aspect_ratio.den, + display_aspect_ratio.num, display_aspect_ratio.den); + } + if(av_log_get_level() >= AV_LOG_DEBUG){ + int g= av_gcd(enc->time_base.num, enc->time_base.den); + snprintf(buf + strlen(buf), buf_size - strlen(buf), + ", %d/%d", + enc->time_base.num/g, enc->time_base.den/g); + } + } + if (encode) { + snprintf(buf + strlen(buf), buf_size - strlen(buf), + ", q=%d-%d", enc->qmin, enc->qmax); + } + break; + case AVMEDIA_TYPE_AUDIO: + snprintf(buf, buf_size, + "Audio: %s", + codec_name); + if (enc->sample_rate) { + snprintf(buf + strlen(buf), buf_size - strlen(buf), + ", %d Hz", enc->sample_rate); + } + av_strlcat(buf, ", ", buf_size); + avcodec_get_channel_layout_string(buf + strlen(buf), buf_size - strlen(buf), enc->channels, enc->channel_layout); + if (enc->sample_fmt != SAMPLE_FMT_NONE) { + snprintf(buf + strlen(buf), buf_size - strlen(buf), + ", %s", avcodec_get_sample_fmt_name(enc->sample_fmt)); + } + break; + case AVMEDIA_TYPE_DATA: + snprintf(buf, buf_size, "Data: %s", codec_name); + break; + case AVMEDIA_TYPE_SUBTITLE: + snprintf(buf, buf_size, "Subtitle: %s", codec_name); + break; + case AVMEDIA_TYPE_ATTACHMENT: + snprintf(buf, buf_size, "Attachment: %s", codec_name); + break; + default: + snprintf(buf, buf_size, "Invalid Codec type %d", enc->codec_type); + return; + } + if (encode) { + if (enc->flags & CODEC_FLAG_PASS1) + snprintf(buf + strlen(buf), buf_size - strlen(buf), + ", pass 1"); + if (enc->flags & CODEC_FLAG_PASS2) + snprintf(buf + strlen(buf), buf_size - strlen(buf), + ", pass 2"); + } + bitrate = get_bit_rate(enc); + if (bitrate != 0) { + snprintf(buf + strlen(buf), buf_size - strlen(buf), + ", %d kb/s", bitrate / 1000); + } +} + +unsigned avcodec_version( void ) +{ + return LIBAVCODEC_VERSION_INT; +} + +const char *avcodec_configuration(void) +{ + return FFMPEG_CONFIGURATION; +} + +const char *avcodec_license(void) +{ +#define LICENSE_PREFIX "libavcodec license: " + return LICENSE_PREFIX FFMPEG_LICENSE + sizeof(LICENSE_PREFIX) - 1; +} + +void avcodec_init(void) +{ + static int initialized = 0; + + if (initialized != 0) + return; + initialized = 1; + + dsputil_static_init(); +} + +void avcodec_flush_buffers(AVCodecContext *avctx) +{ + if(avctx->codec->flush) + avctx->codec->flush(avctx); +} + +void avcodec_default_free_buffers(AVCodecContext *s){ + int i, j; + + if(s->internal_buffer==NULL) return; + + if (s->internal_buffer_count) + av_log(s, AV_LOG_WARNING, "Found %i unreleased buffers!\n", s->internal_buffer_count); + for(i=0; iinternal_buffer)[i]; + for(j=0; j<4; j++){ + av_freep(&buf->base[j]); + buf->data[j]= NULL; + } + } + av_freep(&s->internal_buffer); + + s->internal_buffer_count=0; +} + +char av_get_pict_type_char(int pict_type){ + switch(pict_type){ + case FF_I_TYPE: return 'I'; + case FF_P_TYPE: return 'P'; + case FF_B_TYPE: return 'B'; + case FF_S_TYPE: return 'S'; + case FF_SI_TYPE:return 'i'; + case FF_SP_TYPE:return 'p'; + case FF_BI_TYPE:return 'b'; + default: return '?'; + } +} + +int av_get_bits_per_sample(enum CodecID codec_id){ + switch(codec_id){ + case CODEC_ID_ADPCM_SBPRO_2: + return 2; + case CODEC_ID_ADPCM_SBPRO_3: + return 3; + case CODEC_ID_ADPCM_SBPRO_4: + case CODEC_ID_ADPCM_CT: + case CODEC_ID_ADPCM_IMA_WAV: + case CODEC_ID_ADPCM_MS: + case CODEC_ID_ADPCM_YAMAHA: + return 4; + case CODEC_ID_PCM_ALAW: + case CODEC_ID_PCM_MULAW: + case CODEC_ID_PCM_S8: + case CODEC_ID_PCM_U8: + case CODEC_ID_PCM_ZORK: + return 8; + case CODEC_ID_PCM_S16BE: + case CODEC_ID_PCM_S16LE: + case CODEC_ID_PCM_S16LE_PLANAR: + case CODEC_ID_PCM_U16BE: + case CODEC_ID_PCM_U16LE: + return 16; + case CODEC_ID_PCM_S24DAUD: + case CODEC_ID_PCM_S24BE: + case CODEC_ID_PCM_S24LE: + case CODEC_ID_PCM_U24BE: + case CODEC_ID_PCM_U24LE: + return 24; + case CODEC_ID_PCM_S32BE: + case CODEC_ID_PCM_S32LE: + case CODEC_ID_PCM_U32BE: + case CODEC_ID_PCM_U32LE: + case CODEC_ID_PCM_F32BE: + case CODEC_ID_PCM_F32LE: + return 32; + case CODEC_ID_PCM_F64BE: + case CODEC_ID_PCM_F64LE: + return 64; + default: + return 0; + } +} + +int av_get_bits_per_sample_format(enum SampleFormat sample_fmt) { + switch (sample_fmt) { + case SAMPLE_FMT_U8: + return 8; + case SAMPLE_FMT_S16: + return 16; + case SAMPLE_FMT_S32: + case SAMPLE_FMT_FLT: + return 32; + case SAMPLE_FMT_DBL: + return 64; + default: + return 0; + } +} + +#if !HAVE_THREADS +int avcodec_thread_init(AVCodecContext *s, int thread_count){ + s->thread_count = thread_count; + return -1; +} +#endif + +unsigned int av_xiphlacing(unsigned char *s, unsigned int v) +{ + unsigned int n = 0; + + while(v >= 0xff) { + *s++ = 0xff; + v -= 0xff; + n++; + } + *s = v; + n++; + return n; +} + +#if LIBAVCODEC_VERSION_MAJOR < 53 +#include "libavcore/parseutils.h" + +int av_parse_video_frame_size(int *width_ptr, int *height_ptr, const char *str) +{ + return av_parse_video_size(width_ptr, height_ptr, str); +} + +int av_parse_video_frame_rate(AVRational *frame_rate, const char *arg) +{ + return av_parse_video_rate(frame_rate, arg); +} +#endif + +int ff_match_2uint16(const uint16_t (*tab)[2], int size, int a, int b){ + int i; + for(i=0; inext; + *p = hwaccel; + hwaccel->next = NULL; +} + +AVHWAccel *av_hwaccel_next(AVHWAccel *hwaccel) +{ + return hwaccel ? hwaccel->next : first_hwaccel; +} + +AVHWAccel *ff_find_hwaccel(enum CodecID codec_id, enum PixelFormat pix_fmt) +{ + AVHWAccel *hwaccel=NULL; + + while((hwaccel= av_hwaccel_next(hwaccel))){ + if ( hwaccel->id == codec_id + && hwaccel->pix_fmt == pix_fmt) + return hwaccel; + } + return NULL; +} + +int av_lockmgr_register(int (*cb)(void **mutex, enum AVLockOp op)) +{ + if (ff_lockmgr_cb) { + if (ff_lockmgr_cb(&codec_mutex, AV_LOCK_DESTROY)) + return -1; + } + + ff_lockmgr_cb = cb; + + if (ff_lockmgr_cb) { + if (ff_lockmgr_cb(&codec_mutex, AV_LOCK_CREATE)) + return -1; + } + return 0; +} + +unsigned int ff_toupper4(unsigned int x) +{ + return toupper( x &0xFF) + + (toupper((x>>8 )&0xFF)<<8 ) + + (toupper((x>>16)&0xFF)<<16) + + (toupper((x>>24)&0xFF)<<24); +} +#endif diff --git a/lib/rbcodec/codecs/libwmavoice/wmavoice.c b/lib/rbcodec/codecs/libwmavoice/wmavoice.c new file mode 100644 index 0000000000..4d31334c36 --- /dev/null +++ b/lib/rbcodec/codecs/libwmavoice/wmavoice.c @@ -0,0 +1,2060 @@ +/* + * Windows Media Audio Voice decoder. + * Copyright (c) 2009 Ronald S. Bultje + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * @brief Windows Media Audio Voice compatible decoder + * @author Ronald S. Bultje + */ + +#include +#include "wmavoice.h" +#include "get_bits.h" +#include "put_bits.h" +#include "wmavoice_data.h" +#include "celp_math.h" +#include "celp_filters.h" +#include "acelp_vectors.h" +#include "acelp_filters.h" +#include "lsp.h" +#include "libavutil/lzo.h" +#include "avfft.h" +#include "fft.h" + +#define MAX_BLOCKS 8 ///< maximum number of blocks per frame +#define MAX_LSPS 16 ///< maximum filter order +#define MAX_LSPS_ALIGN16 16 ///< same as #MAX_LSPS; needs to be multiple + ///< of 16 for ASM input buffer alignment +#define MAX_FRAMES 3 ///< maximum number of frames per superframe +#define MAX_FRAMESIZE 160 ///< maximum number of samples per frame +#define MAX_SIGNAL_HISTORY 416 ///< maximum excitation signal history +#define MAX_SFRAMESIZE (MAX_FRAMESIZE * MAX_FRAMES) + ///< maximum number of samples per superframe +#define SFRAME_CACHE_MAXSIZE 256 ///< maximum cache size for frame data that + ///< was split over two packets +#define VLC_NBITS 6 ///< number of bits to read per VLC iteration + +/** + * Frame type VLC coding. + */ +static VLC frame_type_vlc; + +/** + * Adaptive codebook types. + */ +enum { + ACB_TYPE_NONE = 0, ///< no adaptive codebook (only hardcoded fixed) + ACB_TYPE_ASYMMETRIC = 1, ///< adaptive codebook with per-frame pitch, which + ///< we interpolate to get a per-sample pitch. + ///< Signal is generated using an asymmetric sinc + ///< window function + ///< @note see #wmavoice_ipol1_coeffs + ACB_TYPE_HAMMING = 2 ///< Per-block pitch with signal generation using + ///< a Hamming sinc window function + ///< @note see #wmavoice_ipol2_coeffs +}; + +/** + * Fixed codebook types. + */ +enum { + FCB_TYPE_SILENCE = 0, ///< comfort noise during silence + ///< generated from a hardcoded (fixed) codebook + ///< with per-frame (low) gain values + FCB_TYPE_HARDCODED = 1, ///< hardcoded (fixed) codebook with per-block + ///< gain values + FCB_TYPE_AW_PULSES = 2, ///< Pitch-adaptive window (AW) pulse signals, + ///< used in particular for low-bitrate streams + FCB_TYPE_EXC_PULSES = 3, ///< Innovation (fixed) codebook pulse sets in + ///< combinations of either single pulses or + ///< pulse pairs +}; + +/** + * Description of frame types. + */ +static const struct frame_type_desc { + uint8_t n_blocks; ///< amount of blocks per frame (each block + ///< (contains 160/#n_blocks samples) + uint8_t log_n_blocks; ///< log2(#n_blocks) + uint8_t acb_type; ///< Adaptive codebook type (ACB_TYPE_*) + uint8_t fcb_type; ///< Fixed codebook type (FCB_TYPE_*) + uint8_t dbl_pulses; ///< how many pulse vectors have pulse pairs + ///< (rather than just one single pulse) + ///< only if #fcb_type == #FCB_TYPE_EXC_PULSES + uint16_t frame_size; ///< the amount of bits that make up the block + ///< data (per frame) +} frame_descs[17] = { + { 1, 0, ACB_TYPE_NONE, FCB_TYPE_SILENCE, 0, 0 }, + { 2, 1, ACB_TYPE_NONE, FCB_TYPE_HARDCODED, 0, 28 }, + { 2, 1, ACB_TYPE_ASYMMETRIC, FCB_TYPE_AW_PULSES, 0, 46 }, + { 2, 1, ACB_TYPE_ASYMMETRIC, FCB_TYPE_EXC_PULSES, 2, 80 }, + { 2, 1, ACB_TYPE_ASYMMETRIC, FCB_TYPE_EXC_PULSES, 5, 104 }, + { 4, 2, ACB_TYPE_ASYMMETRIC, FCB_TYPE_EXC_PULSES, 0, 108 }, + { 4, 2, ACB_TYPE_ASYMMETRIC, FCB_TYPE_EXC_PULSES, 2, 132 }, + { 4, 2, ACB_TYPE_ASYMMETRIC, FCB_TYPE_EXC_PULSES, 5, 168 }, + { 2, 1, ACB_TYPE_HAMMING, FCB_TYPE_EXC_PULSES, 0, 64 }, + { 2, 1, ACB_TYPE_HAMMING, FCB_TYPE_EXC_PULSES, 2, 80 }, + { 2, 1, ACB_TYPE_HAMMING, FCB_TYPE_EXC_PULSES, 5, 104 }, + { 4, 2, ACB_TYPE_HAMMING, FCB_TYPE_EXC_PULSES, 0, 108 }, + { 4, 2, ACB_TYPE_HAMMING, FCB_TYPE_EXC_PULSES, 2, 132 }, + { 4, 2, ACB_TYPE_HAMMING, FCB_TYPE_EXC_PULSES, 5, 168 }, + { 8, 3, ACB_TYPE_HAMMING, FCB_TYPE_EXC_PULSES, 0, 176 }, + { 8, 3, ACB_TYPE_HAMMING, FCB_TYPE_EXC_PULSES, 2, 208 }, + { 8, 3, ACB_TYPE_HAMMING, FCB_TYPE_EXC_PULSES, 5, 256 } +}; + +/** + * WMA Voice decoding context. + */ +typedef struct { + /** + * @defgroup struct_global Global values + * Global values, specified in the stream header / extradata or used + * all over. + * @{ + */ + GetBitContext gb; ///< packet bitreader. During decoder init, + ///< it contains the extradata from the + ///< demuxer. During decoding, it contains + ///< packet data. + int8_t vbm_tree[25]; ///< converts VLC codes to frame type + + int spillover_bitsize; ///< number of bits used to specify + ///< #spillover_nbits in the packet header + ///< = ceil(log2(ctx->block_align << 3)) + int history_nsamples; ///< number of samples in history for signal + ///< prediction (through ACB) + + /* postfilter specific values */ + int do_apf; ///< whether to apply the averaged + ///< projection filter (APF) + int denoise_strength; ///< strength of denoising in Wiener filter + ///< [0-11] + int denoise_tilt_corr; ///< Whether to apply tilt correction to the + ///< Wiener filter coefficients (postfilter) + int dc_level; ///< Predicted amount of DC noise, based + ///< on which a DC removal filter is used + + int lsps; ///< number of LSPs per frame [10 or 16] + int lsp_q_mode; ///< defines quantizer defaults [0, 1] + int lsp_def_mode; ///< defines different sets of LSP defaults + ///< [0, 1] + int frame_lsp_bitsize; ///< size (in bits) of LSPs, when encoded + ///< per-frame (independent coding) + int sframe_lsp_bitsize; ///< size (in bits) of LSPs, when encoded + ///< per superframe (residual coding) + + int min_pitch_val; ///< base value for pitch parsing code + int max_pitch_val; ///< max value + 1 for pitch parsing + int pitch_nbits; ///< number of bits used to specify the + ///< pitch value in the frame header + int block_pitch_nbits; ///< number of bits used to specify the + ///< first block's pitch value + int block_pitch_range; ///< range of the block pitch + int block_delta_pitch_nbits; ///< number of bits used to specify the + ///< delta pitch between this and the last + ///< block's pitch value, used in all but + ///< first block + int block_delta_pitch_hrange; ///< 1/2 range of the delta (full range is + ///< from -this to +this-1) + uint16_t block_conv_table[4]; ///< boundaries for block pitch unit/scale + ///< conversion + + /** + * @} + * @defgroup struct_packet Packet values + * Packet values, specified in the packet header or related to a packet. + * A packet is considered to be a single unit of data provided to this + * decoder by the demuxer. + * @{ + */ + int spillover_nbits; ///< number of bits of the previous packet's + ///< last superframe preceeding this + ///< packet's first full superframe (useful + ///< for re-synchronization also) + int has_residual_lsps; ///< if set, superframes contain one set of + ///< LSPs that cover all frames, encoded as + ///< independent and residual LSPs; if not + ///< set, each frame contains its own, fully + ///< independent, LSPs + int skip_bits_next; ///< number of bits to skip at the next call + ///< to #wmavoice_decode_packet() (since + ///< they're part of the previous superframe) + + uint8_t sframe_cache[SFRAME_CACHE_MAXSIZE + FF_INPUT_BUFFER_PADDING_SIZE]; + ///< cache for superframe data split over + ///< multiple packets + int sframe_cache_size; ///< set to >0 if we have data from an + ///< (incomplete) superframe from a previous + ///< packet that spilled over in the current + ///< packet; specifies the amount of bits in + ///< #sframe_cache + PutBitContext pb; ///< bitstream writer for #sframe_cache + + /** + * @} + * @defgroup struct_frame Frame and superframe values + * Superframe and frame data - these can change from frame to frame, + * although some of them do in that case serve as a cache / history for + * the next frame or superframe. + * @{ + */ + double prev_lsps[MAX_LSPS]; ///< LSPs of the last frame of the previous + ///< superframe + int last_pitch_val; ///< pitch value of the previous frame + int last_acb_type; ///< frame type [0-2] of the previous frame + int pitch_diff_sh16; ///< ((cur_pitch_val - #last_pitch_val) + ///< << 16) / #MAX_FRAMESIZE + float silence_gain; ///< set for use in blocks if #ACB_TYPE_NONE + + int aw_idx_is_ext; ///< whether the AW index was encoded in + ///< 8 bits (instead of 6) + int aw_pulse_range; ///< the range over which #aw_pulse_set1() + ///< can apply the pulse, relative to the + ///< value in aw_first_pulse_off. The exact + ///< position of the first AW-pulse is within + ///< [pulse_off, pulse_off + this], and + ///< depends on bitstream values; [16 or 24] + int aw_n_pulses[2]; ///< number of AW-pulses in each block; note + ///< that this number can be negative (in + ///< which case it basically means "zero") + int aw_first_pulse_off[2]; ///< index of first sample to which to + ///< apply AW-pulses, or -0xff if unset + int aw_next_pulse_off_cache; ///< the position (relative to start of the + ///< second block) at which pulses should + ///< start to be positioned, serves as a + ///< cache for pitch-adaptive window pulses + ///< between blocks + + int frame_cntr; ///< current frame index [0 - 0xFFFE]; is + ///< only used for comfort noise in #pRNG() + float gain_pred_err[6]; ///< cache for gain prediction + float excitation_history[MAX_SIGNAL_HISTORY]; + ///< cache of the signal of previous + ///< superframes, used as a history for + ///< signal generation + float synth_history[MAX_LSPS]; ///< see #excitation_history + /** + * @} + * @defgroup post_filter Postfilter values + * Varibales used for postfilter implementation, mostly history for + * smoothing and so on, and context variables for FFT/iFFT. + * @{ + */ + RDFTContext rdft, irdft; ///< contexts for FFT-calculation in the + ///< postfilter (for denoise filter) + DCTContext dct, dst; ///< contexts for phase shift (in Hilbert + ///< transform, part of postfilter) + float sin[511], cos[511]; ///< 8-bit cosine/sine windows over [-pi,pi] + ///< range + float postfilter_agc; ///< gain control memory, used in + ///< #adaptive_gain_control() + float dcf_mem[2]; ///< DC filter history + float zero_exc_pf[MAX_SIGNAL_HISTORY + MAX_SFRAMESIZE]; + ///< zero filter output (i.e. excitation) + ///< by postfilter + float denoise_filter_cache[MAX_FRAMESIZE]; + int denoise_filter_cache_size; ///< samples in #denoise_filter_cache + DECLARE_ALIGNED(16, float, tilted_lpcs_pf)[0x80]; + ///< aligned buffer for LPC tilting + DECLARE_ALIGNED(16, float, denoise_coeffs_pf)[0x80]; + ///< aligned buffer for denoise coefficients + DECLARE_ALIGNED(16, float, synth_filter_out_buf)[0x80 + MAX_LSPS_ALIGN16]; + ///< aligned buffer for postfilter speech + ///< synthesis + /** + * @} + */ +} WMAVoiceContext; + +/* global decode context */ +static WMAVoiceContext globWMAVoiceCtx; + + +/** + * Set up the variable bit mode (VBM) tree from container extradata. + * @param gb bit I/O context. + * The bit context (s->gb) should be loaded with byte 23-46 of the + * container extradata (i.e. the ones containing the VBM tree). + * @param vbm_tree pointer to array to which the decoded VBM tree will be + * written. + * @return 0 on success, <0 on error. + */ +static av_cold int decode_vbmtree(GetBitContext *gb, int8_t vbm_tree[25]) +{ + static const uint8_t bits[] = { + 2, 2, 2, 4, 4, 4, + 6, 6, 6, 8, 8, 8, + 10, 10, 10, 12, 12, 12, + 14, 14, 14, 14 + }; + static const uint16_t codes[] = { + 0x0000, 0x0001, 0x0002, // 00/01/10 + 0x000c, 0x000d, 0x000e, // 11+00/01/10 + 0x003c, 0x003d, 0x003e, // 1111+00/01/10 + 0x00fc, 0x00fd, 0x00fe, // 111111+00/01/10 + 0x03fc, 0x03fd, 0x03fe, // 11111111+00/01/10 + 0x0ffc, 0x0ffd, 0x0ffe, // 1111111111+00/01/10 + 0x3ffc, 0x3ffd, 0x3ffe, 0x3fff // 111111111111+xx + }; + int cntr[8], n, res; + + memset(vbm_tree, 0xff, sizeof(int8_t) * 25); + memset(cntr, 0, sizeof(cntr)); + for (n = 0; n < 17; n++) { + res = get_bits(gb, 3); + if (cntr[res] > 3) // should be >= 3 + (res == 7)) + return -1; + vbm_tree[res * 3 + cntr[res]++] = n; + } + INIT_VLC_STATIC(&frame_type_vlc, VLC_NBITS, sizeof(bits), + bits, 1, 1, codes, 2, 2, 132); + return 0; +} + +/** + * Set up decoder with parameters from demuxer (extradata etc.). + */ +av_cold int wmavoice_decode_init(AVCodecContext *ctx) +{ + int n, flags, pitch_range, lsp16_flag; + ctx->priv_data = &globWMAVoiceCtx; + WMAVoiceContext *s = ctx->priv_data; + + /** + * Extradata layout: + * - byte 0-18: WMAPro-in-WMAVoice extradata (see wmaprodec.c), + * - byte 19-22: flags field (annoyingly in LE; see below for known + * values), + * - byte 23-46: variable bitmode tree (really just 17 * 3 bits, + * rest is 0). + */ + if (ctx->extradata_size != 46) { + av_log(ctx, AV_LOG_ERROR, + "Invalid extradata size %d (should be 46)\n", + ctx->extradata_size); + return -1; + } + flags = AV_RL32(ctx->extradata + 18); + s->spillover_bitsize = 3 + av_ceil_log2(ctx->block_align); + s->do_apf = flags & 0x1; + if (s->do_apf) { + ff_rdft_init(&s->rdft, 7, DFT_R2C); + ff_rdft_init(&s->irdft, 7, IDFT_C2R); + ff_dct_init(&s->dct, 6, DCT_I); + ff_dct_init(&s->dst, 6, DST_I); + + ff_sine_window_init(s->cos, 256); + memcpy(&s->sin[255], s->cos, 256 * sizeof(s->cos[0])); + for (n = 0; n < 255; n++) { + s->sin[n] = -s->sin[510 - n]; + s->cos[510 - n] = s->cos[n]; + } + } + s->denoise_strength = (flags >> 2) & 0xF; + if (s->denoise_strength >= 12) { + av_log(ctx, AV_LOG_ERROR, + "Invalid denoise filter strength %d (max=11)\n", + s->denoise_strength); + return -1; + } + s->denoise_tilt_corr = !!(flags & 0x40); + s->dc_level = (flags >> 7) & 0xF; + s->lsp_q_mode = !!(flags & 0x2000); + s->lsp_def_mode = !!(flags & 0x4000); + lsp16_flag = flags & 0x1000; + if (lsp16_flag) { + s->lsps = 16; + s->frame_lsp_bitsize = 34; + s->sframe_lsp_bitsize = 60; + } else { + s->lsps = 10; + s->frame_lsp_bitsize = 24; + s->sframe_lsp_bitsize = 48; + } + for (n = 0; n < s->lsps; n++) + s->prev_lsps[n] = M_PI * (n + 1.0) / (s->lsps + 1.0); + + init_get_bits(&s->gb, ctx->extradata + 22, (ctx->extradata_size - 22) << 3); + if (decode_vbmtree(&s->gb, s->vbm_tree) < 0) { + av_log(ctx, AV_LOG_ERROR, "Invalid VBM tree; broken extradata?\n"); + return -1; + } + + s->min_pitch_val = ((ctx->sample_rate << 8) / 400 + 50) >> 8; + s->max_pitch_val = ((ctx->sample_rate << 8) * 37 / 2000 + 50) >> 8; + pitch_range = s->max_pitch_val - s->min_pitch_val; + s->pitch_nbits = av_ceil_log2(pitch_range); + s->last_pitch_val = 40; + s->last_acb_type = ACB_TYPE_NONE; + s->history_nsamples = s->max_pitch_val + 8; + + if (s->min_pitch_val < 1 || s->history_nsamples > MAX_SIGNAL_HISTORY) { + int min_sr = ((((1 << 8) - 50) * 400) + 0xFF) >> 8, + max_sr = ((((MAX_SIGNAL_HISTORY - 8) << 8) + 205) * 2000 / 37) >> 8; + + av_log(ctx, AV_LOG_ERROR, + "Unsupported samplerate %d (min=%d, max=%d)\n", + ctx->sample_rate, min_sr, max_sr); // 322-22097 Hz + + return -1; + } + + s->block_conv_table[0] = s->min_pitch_val; + s->block_conv_table[1] = (pitch_range * 25) >> 6; + s->block_conv_table[2] = (pitch_range * 44) >> 6; + s->block_conv_table[3] = s->max_pitch_val - 1; + s->block_delta_pitch_hrange = (pitch_range >> 3) & ~0xF; + s->block_delta_pitch_nbits = 1 + av_ceil_log2(s->block_delta_pitch_hrange); + s->block_pitch_range = s->block_conv_table[2] + + s->block_conv_table[3] + 1 + + 2 * (s->block_conv_table[1] - 2 * s->min_pitch_val); + s->block_pitch_nbits = av_ceil_log2(s->block_pitch_range); + + ctx->sample_fmt = SAMPLE_FMT_FLT; + + return 0; +} + +/** + * @defgroup postfilter Postfilter functions + * Postfilter functions (gain control, wiener denoise filter, DC filter, + * kalman smoothening, plus surrounding code to wrap it) + * @{ + */ +/** + * Adaptive gain control (as used in postfilter). + * + * Identical to #ff_adaptive_gain_control() in acelp_vectors.c, except + * that the energy here is calculated using sum(abs(...)), whereas the + * other codecs (e.g. AMR-NB, SIPRO) use sqrt(dotproduct(...)). + * + * @param out output buffer for filtered samples + * @param in input buffer containing the samples as they are after the + * postfilter steps so far + * @param speech_synth input buffer containing speech synth before postfilter + * @param size input buffer size + * @param alpha exponential filter factor + * @param gain_mem pointer to filter memory (single float) + */ +static void adaptive_gain_control(float *out, const float *in, + const float *speech_synth, + int size, float alpha, float *gain_mem) +{ + int i; + float speech_energy = 0.0, postfilter_energy = 0.0, gain_scale_factor; + float mem = *gain_mem; + + for (i = 0; i < size; i++) { + speech_energy += fabsf(speech_synth[i]); + postfilter_energy += fabsf(in[i]); + } + gain_scale_factor = (1.0 - alpha) * speech_energy / postfilter_energy; + + for (i = 0; i < size; i++) { + mem = alpha * mem + gain_scale_factor; + out[i] = in[i] * mem; + } + + *gain_mem = mem; +} + +/** + * Kalman smoothing function. + * + * This function looks back pitch +/- 3 samples back into history to find + * the best fitting curve (that one giving the optimal gain of the two + * signals, i.e. the highest dot product between the two), and then + * uses that signal history to smoothen the output of the speech synthesis + * filter. + * + * @param s WMA Voice decoding context + * @param pitch pitch of the speech signal + * @param in input speech signal + * @param out output pointer for smoothened signal + * @param size input/output buffer size + * + * @returns -1 if no smoothening took place, e.g. because no optimal + * fit could be found, or 0 on success. + */ +static int kalman_smoothen(WMAVoiceContext *s, int pitch, + const float *in, float *out, int size) +{ + int n; + float optimal_gain = 0, dot; + const float *ptr = &in[-FFMAX(s->min_pitch_val, pitch - 3)], + *end = &in[-FFMIN(s->max_pitch_val, pitch + 3)], + *best_hist_ptr; + + /* find best fitting point in history */ + do { + dot = ff_dot_productf(in, ptr, size); + if (dot > optimal_gain) { + optimal_gain = dot; + best_hist_ptr = ptr; + } + } while (--ptr >= end); + + if (optimal_gain <= 0) + return -1; + dot = ff_dot_productf(best_hist_ptr, best_hist_ptr, size); + if (dot <= 0) // would be 1.0 + return -1; + + if (optimal_gain <= dot) { + dot = dot / (dot + 0.6 * optimal_gain); // 0.625-1.000 + } else + dot = 0.625; + + /* actual smoothing */ + for (n = 0; n < size; n++) + out[n] = best_hist_ptr[n] + dot * (in[n] - best_hist_ptr[n]); + + return 0; +} + +/** + * Get the tilt factor of a formant filter from its transfer function + * @see #tilt_factor() in amrnbdec.c, which does essentially the same, + * but somehow (??) it does a speech synthesis filter in the + * middle, which is missing here + * + * @param lpcs LPC coefficients + * @param n_lpcs Size of LPC buffer + * @returns the tilt factor + */ +static float tilt_factor(const float *lpcs, int n_lpcs) +{ + float rh0, rh1; + + rh0 = 1.0 + ff_dot_productf(lpcs, lpcs, n_lpcs); + rh1 = lpcs[0] + ff_dot_productf(lpcs, &lpcs[1], n_lpcs - 1); + + return rh1 / rh0; +} + +/** + * Derive denoise filter coefficients (in real domain) from the LPCs. + */ +static void calc_input_response(WMAVoiceContext *s, float *lpcs, + int fcb_type, float *coeffs, int remainder) +{ + float last_coeff, min = 15.0, max = -15.0; + float irange, angle_mul, gain_mul, range, sq; + int n, idx; + + /* Create frequency power spectrum of speech input (i.e. RDFT of LPCs) */ + ff_rdft_calc(&s->rdft, lpcs); +#define log_range(var, assign) do { \ + float tmp = log10f(assign); var = tmp; \ + max = FFMAX(max, tmp); min = FFMIN(min, tmp); \ + } while (0) + log_range(last_coeff, lpcs[1] * lpcs[1]); + for (n = 1; n < 64; n++) + log_range(lpcs[n], lpcs[n * 2] * lpcs[n * 2] + + lpcs[n * 2 + 1] * lpcs[n * 2 + 1]); + log_range(lpcs[0], lpcs[0] * lpcs[0]); +#undef log_range + range = max - min; + lpcs[64] = last_coeff; + + /* Now, use this spectrum to pick out these frequencies with higher + * (relative) power/energy (which we then take to be "not noise"), + * and set up a table (still in lpc[]) of (relative) gains per frequency. + * These frequencies will be maintained, while others ("noise") will be + * decreased in the filter output. */ + irange = 64.0 / range; // so irange*(max-value) is in the range [0, 63] + gain_mul = range * (fcb_type == FCB_TYPE_HARDCODED ? (5.0 / 13.0) : + (5.0 / 14.7)); + angle_mul = gain_mul * (8.0 * M_LN10 / M_PI); + for (n = 0; n <= 64; n++) { + float pwr; + + idx = FFMAX(0, lrint((max - lpcs[n]) * irange) - 1); + pwr = wmavoice_denoise_power_table[s->denoise_strength][idx]; + lpcs[n] = angle_mul * pwr; + + /* 70.57 =~ 1/log10(1.0331663) */ + idx = (pwr * gain_mul - 0.0295) * 70.570526123; + if (idx > 127) { // fallback if index falls outside table range + coeffs[n] = wmavoice_energy_table[127] * + powf(1.0331663, idx - 127); + } else + coeffs[n] = wmavoice_energy_table[FFMAX(0, idx)]; + } + + /* calculate the Hilbert transform of the gains, which we do (since this + * is a sinus input) by doing a phase shift (in theory, H(sin())=cos()). + * Hilbert_Transform(RDFT(x)) = Laplace_Transform(x), which calculates the + * "moment" of the LPCs in this filter. */ + ff_dct_calc(&s->dct, lpcs); + ff_dct_calc(&s->dst, lpcs); + + /* Split out the coefficient indexes into phase/magnitude pairs */ + idx = 255 + av_clip(lpcs[64], -255, 255); + coeffs[0] = coeffs[0] * s->cos[idx]; + idx = 255 + av_clip(lpcs[64] - 2 * lpcs[63], -255, 255); + last_coeff = coeffs[64] * s->cos[idx]; + for (n = 63;; n--) { + idx = 255 + av_clip(-lpcs[64] - 2 * lpcs[n - 1], -255, 255); + coeffs[n * 2 + 1] = coeffs[n] * s->sin[idx]; + coeffs[n * 2] = coeffs[n] * s->cos[idx]; + + if (!--n) break; + + idx = 255 + av_clip( lpcs[64] - 2 * lpcs[n - 1], -255, 255); + coeffs[n * 2 + 1] = coeffs[n] * s->sin[idx]; + coeffs[n * 2] = coeffs[n] * s->cos[idx]; + } + coeffs[1] = last_coeff; + + /* move into real domain */ + ff_rdft_calc(&s->irdft, coeffs); + + /* tilt correction and normalize scale */ + memset(&coeffs[remainder], 0, sizeof(coeffs[0]) * (128 - remainder)); + if (s->denoise_tilt_corr) { + float tilt_mem = 0; + + coeffs[remainder - 1] = 0; + ff_tilt_compensation(&tilt_mem, + -1.8 * tilt_factor(coeffs, remainder - 1), + coeffs, remainder); + } + sq = (1.0 / 64.0) * sqrtf(1 / ff_dot_productf(coeffs, coeffs, remainder)); + for (n = 0; n < remainder; n++) + coeffs[n] *= sq; +} + +/** + * This function applies a Wiener filter on the (noisy) speech signal as + * a means to denoise it. + * + * - take RDFT of LPCs to get the power spectrum of the noise + speech; + * - using this power spectrum, calculate (for each frequency) the Wiener + * filter gain, which depends on the frequency power and desired level + * of noise subtraction (when set too high, this leads to artifacts) + * We can do this symmetrically over the X-axis (so 0-4kHz is the inverse + * of 4-8kHz); + * - by doing a phase shift, calculate the Hilbert transform of this array + * of per-frequency filter-gains to get the filtering coefficients; + * - smoothen/normalize/de-tilt these filter coefficients as desired; + * - take RDFT of noisy sound, apply the coefficients and take its IRDFT + * to get the denoised speech signal; + * - the leftover (i.e. output of the IRDFT on denoised speech data beyond + * the frame boundary) are saved and applied to subsequent frames by an + * overlap-add method (otherwise you get clicking-artifacts). + * + * @param s WMA Voice decoding context + * @param fcb_type Frame (codebook) type + * @param synth_pf input: the noisy speech signal, output: denoised speech + * data; should be 16-byte aligned (for ASM purposes) + * @param size size of the speech data + * @param lpcs LPCs used to synthesize this frame's speech data + */ +static void wiener_denoise(WMAVoiceContext *s, int fcb_type, + float *synth_pf, int size, + const float *lpcs) +{ + int remainder, lim, n; + + if (fcb_type != FCB_TYPE_SILENCE) { + float *tilted_lpcs = s->tilted_lpcs_pf, + *coeffs = s->denoise_coeffs_pf, tilt_mem = 0; + + tilted_lpcs[0] = 1.0; + memcpy(&tilted_lpcs[1], lpcs, sizeof(lpcs[0]) * s->lsps); + memset(&tilted_lpcs[s->lsps + 1], 0, + sizeof(tilted_lpcs[0]) * (128 - s->lsps - 1)); + ff_tilt_compensation(&tilt_mem, 0.7 * tilt_factor(lpcs, s->lsps), + tilted_lpcs, s->lsps + 2); + + /* The IRDFT output (127 samples for 7-bit filter) beyond the frame + * size is applied to the next frame. All input beyond this is zero, + * and thus all output beyond this will go towards zero, hence we can + * limit to min(size-1, 127-size) as a performance consideration. */ + remainder = FFMIN(127 - size, size - 1); + calc_input_response(s, tilted_lpcs, fcb_type, coeffs, remainder); + + /* apply coefficients (in frequency spectrum domain), i.e. complex + * number multiplication */ + memset(&synth_pf[size], 0, sizeof(synth_pf[0]) * (128 - size)); + ff_rdft_calc(&s->rdft, synth_pf); + ff_rdft_calc(&s->rdft, coeffs); + synth_pf[0] *= coeffs[0]; + synth_pf[1] *= coeffs[1]; + for (n = 1; n < 64; n++) { + float v1 = synth_pf[n * 2], v2 = synth_pf[n * 2 + 1]; + synth_pf[n * 2] = v1 * coeffs[n * 2] - v2 * coeffs[n * 2 + 1]; + synth_pf[n * 2 + 1] = v2 * coeffs[n * 2] + v1 * coeffs[n * 2 + 1]; + } + ff_rdft_calc(&s->irdft, synth_pf); + } + + /* merge filter output with the history of previous runs */ + if (s->denoise_filter_cache_size) { + lim = FFMIN(s->denoise_filter_cache_size, size); + for (n = 0; n < lim; n++) + synth_pf[n] += s->denoise_filter_cache[n]; + s->denoise_filter_cache_size -= lim; + memmove(s->denoise_filter_cache, &s->denoise_filter_cache[size], + sizeof(s->denoise_filter_cache[0]) * s->denoise_filter_cache_size); + } + + /* move remainder of filter output into a cache for future runs */ + if (fcb_type != FCB_TYPE_SILENCE) { + lim = FFMIN(remainder, s->denoise_filter_cache_size); + for (n = 0; n < lim; n++) + s->denoise_filter_cache[n] += synth_pf[size + n]; + if (lim < remainder) { + memcpy(&s->denoise_filter_cache[lim], &synth_pf[size + lim], + sizeof(s->denoise_filter_cache[0]) * (remainder - lim)); + s->denoise_filter_cache_size = remainder; + } + } +} + +/** + * Averaging projection filter, the postfilter used in WMAVoice. + * + * This uses the following steps: + * - A zero-synthesis filter (generate excitation from synth signal) + * - Kalman smoothing on excitation, based on pitch + * - Re-synthesized smoothened output + * - Iterative Wiener denoise filter + * - Adaptive gain filter + * - DC filter + * + * @param s WMAVoice decoding context + * @param synth Speech synthesis output (before postfilter) + * @param samples Output buffer for filtered samples + * @param size Buffer size of synth & samples + * @param lpcs Generated LPCs used for speech synthesis + * @param zero_exc_pf destination for zero synthesis filter (16-byte aligned) + * @param fcb_type Frame type (silence, hardcoded, AW-pulses or FCB-pulses) + * @param pitch Pitch of the input signal + */ +static void postfilter(WMAVoiceContext *s, const float *synth, + float *samples, int size, + const float *lpcs, float *zero_exc_pf, + int fcb_type, int pitch) +{ + float synth_filter_in_buf[MAX_FRAMESIZE / 2], + *synth_pf = &s->synth_filter_out_buf[MAX_LSPS_ALIGN16], + *synth_filter_in = zero_exc_pf; + + assert(size <= MAX_FRAMESIZE / 2); + + /* generate excitation from input signal */ + ff_celp_lp_zero_synthesis_filterf(zero_exc_pf, lpcs, synth, size, s->lsps); + + if (fcb_type >= FCB_TYPE_AW_PULSES && + !kalman_smoothen(s, pitch, zero_exc_pf, synth_filter_in_buf, size)) + synth_filter_in = synth_filter_in_buf; + + /* re-synthesize speech after smoothening, and keep history */ + ff_celp_lp_synthesis_filterf(synth_pf, lpcs, + synth_filter_in, size, s->lsps); + memcpy(&synth_pf[-s->lsps], &synth_pf[size - s->lsps], + sizeof(synth_pf[0]) * s->lsps); + + wiener_denoise(s, fcb_type, synth_pf, size, lpcs); + + adaptive_gain_control(samples, synth_pf, synth, size, 0.99, + &s->postfilter_agc); + + if (s->dc_level > 8) { + /* remove ultra-low frequency DC noise / highpass filter; + * coefficients are identical to those used in SIPR decoding, + * and very closely resemble those used in AMR-NB decoding. */ + ff_acelp_apply_order_2_transfer_function(samples, samples, + (const float[2]) { -1.99997, 1.0 }, + (const float[2]) { -1.9330735188, 0.93589198496 }, + 0.93980580475, s->dcf_mem, size); + } +} +/** + * @} + */ + +/** + * Dequantize LSPs + * @param lsps output pointer to the array that will hold the LSPs + * @param num number of LSPs to be dequantized + * @param values quantized values, contains n_stages values + * @param sizes range (i.e. max value) of each quantized value + * @param n_stages number of dequantization runs + * @param table dequantization table to be used + * @param mul_q LSF multiplier + * @param base_q base (lowest) LSF values + */ +static void dequant_lsps(double *lsps, int num, + const uint16_t *values, + const uint16_t *sizes, + int n_stages, const uint8_t *table, + const double *mul_q, + const double *base_q) +{ + int n, m; + + memset(lsps, 0, num * sizeof(*lsps)); + for (n = 0; n < n_stages; n++) { + const uint8_t *t_off = &table[values[n] * num]; + double base = base_q[n], mul = mul_q[n]; + + for (m = 0; m < num; m++) + lsps[m] += base + mul * t_off[m]; + + table += sizes[n] * num; + } +} + +/** + * @defgroup lsp_dequant LSP dequantization routines + * LSP dequantization routines, for 10/16LSPs and independent/residual coding. + * @note we assume enough bits are available, caller should check. + * lsp10i() consumes 24 bits; lsp10r() consumes an additional 24 bits; + * lsp16i() consumes 34 bits; lsp16r() consumes an additional 26 bits. + * @{ + */ +/** + * Parse 10 independently-coded LSPs. + */ +static void dequant_lsp10i(GetBitContext *gb, double *lsps) +{ + static const uint16_t vec_sizes[4] = { 256, 64, 32, 32 }; + static const double mul_lsf[4] = { + 5.2187144800e-3, 1.4626986422e-3, + 9.6179549166e-4, 1.1325736225e-3 + }; + static const double base_lsf[4] = { + M_PI * -2.15522e-1, M_PI * -6.1646e-2, + M_PI * -3.3486e-2, M_PI * -5.7408e-2 + }; + uint16_t v[4]; + + v[0] = get_bits(gb, 8); + v[1] = get_bits(gb, 6); + v[2] = get_bits(gb, 5); + v[3] = get_bits(gb, 5); + + dequant_lsps(lsps, 10, v, vec_sizes, 4, wmavoice_dq_lsp10i, + mul_lsf, base_lsf); +} + +/** + * Parse 10 independently-coded LSPs, and then derive the tables to + * generate LSPs for the other frames from them (residual coding). + */ +static void dequant_lsp10r(GetBitContext *gb, + double *i_lsps, const double *old, + double *a1, double *a2, int q_mode) +{ + static const uint16_t vec_sizes[3] = { 128, 64, 64 }; + static const double mul_lsf[3] = { + 2.5807601174e-3, 1.2354460219e-3, 1.1763821673e-3 + }; + static const double base_lsf[3] = { + M_PI * -1.07448e-1, M_PI * -5.2706e-2, M_PI * -5.1634e-2 + }; + const float (*ipol_tab)[2][10] = q_mode ? + wmavoice_lsp10_intercoeff_b : wmavoice_lsp10_intercoeff_a; + uint16_t interpol, v[3]; + int n; + + dequant_lsp10i(gb, i_lsps); + + interpol = get_bits(gb, 5); + v[0] = get_bits(gb, 7); + v[1] = get_bits(gb, 6); + v[2] = get_bits(gb, 6); + + for (n = 0; n < 10; n++) { + double delta = old[n] - i_lsps[n]; + a1[n] = ipol_tab[interpol][0][n] * delta + i_lsps[n]; + a1[10 + n] = ipol_tab[interpol][1][n] * delta + i_lsps[n]; + } + + dequant_lsps(a2, 20, v, vec_sizes, 3, wmavoice_dq_lsp10r, + mul_lsf, base_lsf); +} + +/** + * Parse 16 independently-coded LSPs. + */ +static void dequant_lsp16i(GetBitContext *gb, double *lsps) +{ + static const uint16_t vec_sizes[5] = { 256, 64, 128, 64, 128 }; + static const double mul_lsf[5] = { + 3.3439586280e-3, 6.9908173703e-4, + 3.3216608306e-3, 1.0334960326e-3, + 3.1899104283e-3 + }; + static const double base_lsf[5] = { + M_PI * -1.27576e-1, M_PI * -2.4292e-2, + M_PI * -1.28094e-1, M_PI * -3.2128e-2, + M_PI * -1.29816e-1 + }; + uint16_t v[5]; + + v[0] = get_bits(gb, 8); + v[1] = get_bits(gb, 6); + v[2] = get_bits(gb, 7); + v[3] = get_bits(gb, 6); + v[4] = get_bits(gb, 7); + + dequant_lsps( lsps, 5, v, vec_sizes, 2, + wmavoice_dq_lsp16i1, mul_lsf, base_lsf); + dequant_lsps(&lsps[5], 5, &v[2], &vec_sizes[2], 2, + wmavoice_dq_lsp16i2, &mul_lsf[2], &base_lsf[2]); + dequant_lsps(&lsps[10], 6, &v[4], &vec_sizes[4], 1, + wmavoice_dq_lsp16i3, &mul_lsf[4], &base_lsf[4]); +} + +/** + * Parse 16 independently-coded LSPs, and then derive the tables to + * generate LSPs for the other frames from them (residual coding). + */ +static void dequant_lsp16r(GetBitContext *gb, + double *i_lsps, const double *old, + double *a1, double *a2, int q_mode) +{ + static const uint16_t vec_sizes[3] = { 128, 128, 128 }; + static const double mul_lsf[3] = { + 1.2232979501e-3, 1.4062241527e-3, 1.6114744851e-3 + }; + static const double base_lsf[3] = { + M_PI * -5.5830e-2, M_PI * -5.2908e-2, M_PI * -5.4776e-2 + }; + const float (*ipol_tab)[2][16] = q_mode ? + wmavoice_lsp16_intercoeff_b : wmavoice_lsp16_intercoeff_a; + uint16_t interpol, v[3]; + int n; + + dequant_lsp16i(gb, i_lsps); + + interpol = get_bits(gb, 5); + v[0] = get_bits(gb, 7); + v[1] = get_bits(gb, 7); + v[2] = get_bits(gb, 7); + + for (n = 0; n < 16; n++) { + double delta = old[n] - i_lsps[n]; + a1[n] = ipol_tab[interpol][0][n] * delta + i_lsps[n]; + a1[16 + n] = ipol_tab[interpol][1][n] * delta + i_lsps[n]; + } + + dequant_lsps( a2, 10, v, vec_sizes, 1, + wmavoice_dq_lsp16r1, mul_lsf, base_lsf); + dequant_lsps(&a2[10], 10, &v[1], &vec_sizes[1], 1, + wmavoice_dq_lsp16r2, &mul_lsf[1], &base_lsf[1]); + dequant_lsps(&a2[20], 12, &v[2], &vec_sizes[2], 1, + wmavoice_dq_lsp16r3, &mul_lsf[2], &base_lsf[2]); +} + +/** + * @} + * @defgroup aw Pitch-adaptive window coding functions + * The next few functions are for pitch-adaptive window coding. + * @{ + */ +/** + * Parse the offset of the first pitch-adaptive window pulses, and + * the distribution of pulses between the two blocks in this frame. + * @param s WMA Voice decoding context private data + * @param gb bit I/O context + * @param pitch pitch for each block in this frame + */ +static void aw_parse_coords(WMAVoiceContext *s, GetBitContext *gb, + const int *pitch) +{ + static const int16_t start_offset[94] = { + -11, -9, -7, -5, -3, -1, 1, 3, 5, 7, 9, 11, + 13, 15, 18, 17, 19, 20, 21, 22, 23, 24, 25, 26, + 27, 28, 29, 30, 31, 32, 33, 35, 37, 39, 41, 43, + 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, + 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, + 93, 95, 97, 99, 101, 103, 105, 107, 109, 111, 113, 115, + 117, 119, 121, 123, 125, 127, 129, 131, 133, 135, 137, 139, + 141, 143, 145, 147, 149, 151, 153, 155, 157, 159 + }; + int bits, offset; + + /* position of pulse */ + s->aw_idx_is_ext = 0; + if ((bits = get_bits(gb, 6)) >= 54) { + s->aw_idx_is_ext = 1; + bits += (bits - 54) * 3 + get_bits(gb, 2); + } + + /* for a repeated pulse at pulse_off with a pitch_lag of pitch[], count + * the distribution of the pulses in each block contained in this frame. */ + s->aw_pulse_range = FFMIN(pitch[0], pitch[1]) > 32 ? 24 : 16; + for (offset = start_offset[bits]; offset < 0; offset += pitch[0]) ; + s->aw_n_pulses[0] = (pitch[0] - 1 + MAX_FRAMESIZE / 2 - offset) / pitch[0]; + s->aw_first_pulse_off[0] = offset - s->aw_pulse_range / 2; + offset += s->aw_n_pulses[0] * pitch[0]; + s->aw_n_pulses[1] = (pitch[1] - 1 + MAX_FRAMESIZE - offset) / pitch[1]; + s->aw_first_pulse_off[1] = offset - (MAX_FRAMESIZE + s->aw_pulse_range) / 2; + + /* if continuing from a position before the block, reset position to + * start of block (when corrected for the range over which it can be + * spread in aw_pulse_set1()). */ + if (start_offset[bits] < MAX_FRAMESIZE / 2) { + while (s->aw_first_pulse_off[1] - pitch[1] + s->aw_pulse_range > 0) + s->aw_first_pulse_off[1] -= pitch[1]; + if (start_offset[bits] < 0) + while (s->aw_first_pulse_off[0] - pitch[0] + s->aw_pulse_range > 0) + s->aw_first_pulse_off[0] -= pitch[0]; + } +} + +/** + * Apply second set of pitch-adaptive window pulses. + * @param s WMA Voice decoding context private data + * @param gb bit I/O context + * @param block_idx block index in frame [0, 1] + * @param fcb structure containing fixed codebook vector info + */ +static void aw_pulse_set2(WMAVoiceContext *s, GetBitContext *gb, + int block_idx, AMRFixed *fcb) +{ + uint16_t use_mask[7]; // only 5 are used, rest is padding + /* in this function, idx is the index in the 80-bit (+ padding) use_mask + * bit-array. Since use_mask consists of 16-bit values, the lower 4 bits + * of idx are the position of the bit within a particular item in the + * array (0 being the most significant bit, and 15 being the least + * significant bit), and the remainder (>> 4) is the index in the + * use_mask[]-array. This is faster and uses less memory than using a + * 80-byte/80-int array. */ + int pulse_off = s->aw_first_pulse_off[block_idx], + pulse_start, n, idx, range, aidx, start_off = 0; + + /* set offset of first pulse to within this block */ + if (s->aw_n_pulses[block_idx] > 0) + while (pulse_off + s->aw_pulse_range < 1) + pulse_off += fcb->pitch_lag; + + /* find range per pulse */ + if (s->aw_n_pulses[0] > 0) { + if (block_idx == 0) { + range = 32; + } else /* block_idx = 1 */ { + range = 8; + if (s->aw_n_pulses[block_idx] > 0) + pulse_off = s->aw_next_pulse_off_cache; + } + } else + range = 16; + pulse_start = s->aw_n_pulses[block_idx] > 0 ? pulse_off - range / 2 : 0; + + /* aw_pulse_set1() already applies pulses around pulse_off (to be exactly, + * in the range of [pulse_off, pulse_off + s->aw_pulse_range], and thus + * we exclude that range from being pulsed again in this function. */ + memset( use_mask, -1, 5 * sizeof(use_mask[0])); + memset(&use_mask[5], 0, 2 * sizeof(use_mask[0])); + if (s->aw_n_pulses[block_idx] > 0) + for (idx = pulse_off; idx < MAX_FRAMESIZE / 2; idx += fcb->pitch_lag) { + int excl_range = s->aw_pulse_range; // always 16 or 24 + uint16_t *use_mask_ptr = &use_mask[idx >> 4]; + int first_sh = 16 - (idx & 15); + *use_mask_ptr++ &= 0xFFFF << first_sh; + excl_range -= first_sh; + if (excl_range >= 16) { + *use_mask_ptr++ = 0; + *use_mask_ptr &= 0xFFFF >> (excl_range - 16); + } else + *use_mask_ptr &= 0xFFFF >> excl_range; + } + + /* find the 'aidx'th offset that is not excluded */ + aidx = get_bits(gb, s->aw_n_pulses[0] > 0 ? 5 - 2 * block_idx : 4); + for (n = 0; n <= aidx; pulse_start++) { + for (idx = pulse_start; idx < 0; idx += fcb->pitch_lag) ; + if (idx >= MAX_FRAMESIZE / 2) { // find from zero + if (use_mask[0]) idx = 0x0F; + else if (use_mask[1]) idx = 0x1F; + else if (use_mask[2]) idx = 0x2F; + else if (use_mask[3]) idx = 0x3F; + else if (use_mask[4]) idx = 0x4F; + else return; + idx -= av_log2_16bit(use_mask[idx >> 4]); + } + if (use_mask[idx >> 4] & (0x8000 >> (idx & 15))) { + use_mask[idx >> 4] &= ~(0x8000 >> (idx & 15)); + n++; + start_off = idx; + } + } + + fcb->x[fcb->n] = start_off; + fcb->y[fcb->n] = get_bits1(gb) ? -1.0 : 1.0; + fcb->n++; + + /* set offset for next block, relative to start of that block */ + n = (MAX_FRAMESIZE / 2 - start_off) % fcb->pitch_lag; + s->aw_next_pulse_off_cache = n ? fcb->pitch_lag - n : 0; +} + +/** + * Apply first set of pitch-adaptive window pulses. + * @param s WMA Voice decoding context private data + * @param gb bit I/O context + * @param block_idx block index in frame [0, 1] + * @param fcb storage location for fixed codebook pulse info + */ +static void aw_pulse_set1(WMAVoiceContext *s, GetBitContext *gb, + int block_idx, AMRFixed *fcb) +{ + int val = get_bits(gb, 12 - 2 * (s->aw_idx_is_ext && !block_idx)); + float v; + + if (s->aw_n_pulses[block_idx] > 0) { + int n, v_mask, i_mask, sh, n_pulses; + + if (s->aw_pulse_range == 24) { // 3 pulses, 1:sign + 3:index each + n_pulses = 3; + v_mask = 8; + i_mask = 7; + sh = 4; + } else { // 4 pulses, 1:sign + 2:index each + n_pulses = 4; + v_mask = 4; + i_mask = 3; + sh = 3; + } + + for (n = n_pulses - 1; n >= 0; n--, val >>= sh) { + fcb->y[fcb->n] = (val & v_mask) ? -1.0 : 1.0; + fcb->x[fcb->n] = (val & i_mask) * n_pulses + n + + s->aw_first_pulse_off[block_idx]; + while (fcb->x[fcb->n] < 0) + fcb->x[fcb->n] += fcb->pitch_lag; + if (fcb->x[fcb->n] < MAX_FRAMESIZE / 2) + fcb->n++; + } + } else { + int num2 = (val & 0x1FF) >> 1, delta, idx; + + if (num2 < 1 * 79) { delta = 1; idx = num2 + 1; } + else if (num2 < 2 * 78) { delta = 3; idx = num2 + 1 - 1 * 77; } + else if (num2 < 3 * 77) { delta = 5; idx = num2 + 1 - 2 * 76; } + else { delta = 7; idx = num2 + 1 - 3 * 75; } + v = (val & 0x200) ? -1.0 : 1.0; + + fcb->no_repeat_mask |= 3 << fcb->n; + fcb->x[fcb->n] = idx - delta; + fcb->y[fcb->n] = v; + fcb->x[fcb->n + 1] = idx; + fcb->y[fcb->n + 1] = (val & 1) ? -v : v; + fcb->n += 2; + } +} + +/** + * @} + * + * Generate a random number from frame_cntr and block_idx, which will lief + * in the range [0, 1000 - block_size] (so it can be used as an index in a + * table of size 1000 of which you want to read block_size entries). + * + * @param frame_cntr current frame number + * @param block_num current block index + * @param block_size amount of entries we want to read from a table + * that has 1000 entries + * @return a (non-)random number in the [0, 1000 - block_size] range. + */ +static int pRNG(int frame_cntr, int block_num, int block_size) +{ + /* array to simplify the calculation of z: + * y = (x % 9) * 5 + 6; + * z = (49995 * x) / y; + * Since y only has 9 values, we can remove the division by using a + * LUT and using FASTDIV-style divisions. For each of the 9 values + * of y, we can rewrite z as: + * z = x * (49995 / y) + x * ((49995 % y) / y) + * In this table, each col represents one possible value of y, the + * first number is 49995 / y, and the second is the FASTDIV variant + * of 49995 % y / y. */ + static const unsigned int div_tbl[9][2] = { + { 8332, 3 * 715827883U }, // y = 6 + { 4545, 0 * 390451573U }, // y = 11 + { 3124, 11 * 268435456U }, // y = 16 + { 2380, 15 * 204522253U }, // y = 21 + { 1922, 23 * 165191050U }, // y = 26 + { 1612, 23 * 138547333U }, // y = 31 + { 1388, 27 * 119304648U }, // y = 36 + { 1219, 16 * 104755300U }, // y = 41 + { 1086, 39 * 93368855U } // y = 46 + }; + unsigned int z, y, x = MUL16(block_num, 1877) + frame_cntr; + if (x >= 0xFFFF) x -= 0xFFFF; // max value of x is 8*1877+0xFFFE=0x13AA6, + // so this is effectively a modulo (%) + y = x - 9 * MULH(477218589, x); // x % 9 + z = (uint16_t) (x * div_tbl[y][0] + UMULH(x, div_tbl[y][1])); + // z = x * 49995 / (y * 5 + 6) + return z % (1000 - block_size); +} + +/** + * Parse hardcoded signal for a single block. + * @note see #synth_block(). + */ +static void synth_block_hardcoded(WMAVoiceContext *s, GetBitContext *gb, + int block_idx, int size, + const struct frame_type_desc *frame_desc, + float *excitation) +{ + float gain; + int n, r_idx; + + assert(size <= MAX_FRAMESIZE); + + /* Set the offset from which we start reading wmavoice_std_codebook */ + if (frame_desc->fcb_type == FCB_TYPE_SILENCE) { + r_idx = pRNG(s->frame_cntr, block_idx, size); + gain = s->silence_gain; + } else /* FCB_TYPE_HARDCODED */ { + r_idx = get_bits(gb, 8); + gain = wmavoice_gain_universal[get_bits(gb, 6)]; + } + + /* Clear gain prediction parameters */ + memset(s->gain_pred_err, 0, sizeof(s->gain_pred_err)); + + /* Apply gain to hardcoded codebook and use that as excitation signal */ + for (n = 0; n < size; n++) + excitation[n] = wmavoice_std_codebook[r_idx + n] * gain; +} + +/** + * Parse FCB/ACB signal for a single block. + * @note see #synth_block(). + */ +static void synth_block_fcb_acb(WMAVoiceContext *s, GetBitContext *gb, + int block_idx, int size, + int block_pitch_sh2, + const struct frame_type_desc *frame_desc, + float *excitation) +{ + static const float gain_coeff[6] = { + 0.8169, -0.06545, 0.1726, 0.0185, -0.0359, 0.0458 + }; + float pulses[MAX_FRAMESIZE / 2], pred_err, acb_gain, fcb_gain; + int n, idx, gain_weight; + AMRFixed fcb; + + assert(size <= MAX_FRAMESIZE / 2); + memset(pulses, 0, sizeof(*pulses) * size); + + fcb.pitch_lag = block_pitch_sh2 >> 2; + fcb.pitch_fac = 1.0; + fcb.no_repeat_mask = 0; + fcb.n = 0; + + /* For the other frame types, this is where we apply the innovation + * (fixed) codebook pulses of the speech signal. */ + if (frame_desc->fcb_type == FCB_TYPE_AW_PULSES) { + aw_pulse_set1(s, gb, block_idx, &fcb); + aw_pulse_set2(s, gb, block_idx, &fcb); + } else /* FCB_TYPE_EXC_PULSES */ { + int offset_nbits = 5 - frame_desc->log_n_blocks; + + fcb.no_repeat_mask = -1; + /* similar to ff_decode_10_pulses_35bits(), but with single pulses + * (instead of double) for a subset of pulses */ + for (n = 0; n < 5; n++) { + float sign; + int pos1, pos2; + + sign = get_bits1(gb) ? 1.0 : -1.0; + pos1 = get_bits(gb, offset_nbits); + fcb.x[fcb.n] = n + 5 * pos1; + fcb.y[fcb.n++] = sign; + if (n < frame_desc->dbl_pulses) { + pos2 = get_bits(gb, offset_nbits); + fcb.x[fcb.n] = n + 5 * pos2; + fcb.y[fcb.n++] = (pos1 < pos2) ? -sign : sign; + } + } + } + ff_set_fixed_vector(pulses, &fcb, 1.0, size); + + /* Calculate gain for adaptive & fixed codebook signal. + * see ff_amr_set_fixed_gain(). */ + idx = get_bits(gb, 7); + fcb_gain = expf(ff_dot_productf(s->gain_pred_err, gain_coeff, 6) - + 5.2409161640 + wmavoice_gain_codebook_fcb[idx]); + acb_gain = wmavoice_gain_codebook_acb[idx]; + pred_err = av_clipf(wmavoice_gain_codebook_fcb[idx], + -2.9957322736 /* log(0.05) */, + 1.6094379124 /* log(5.0) */); + + gain_weight = 8 >> frame_desc->log_n_blocks; + memmove(&s->gain_pred_err[gain_weight], s->gain_pred_err, + sizeof(*s->gain_pred_err) * (6 - gain_weight)); + for (n = 0; n < gain_weight; n++) + s->gain_pred_err[n] = pred_err; + + /* Calculation of adaptive codebook */ + if (frame_desc->acb_type == ACB_TYPE_ASYMMETRIC) { + int len; + for (n = 0; n < size; n += len) { + int next_idx_sh16; + int abs_idx = block_idx * size + n; + int pitch_sh16 = (s->last_pitch_val << 16) + + s->pitch_diff_sh16 * abs_idx; + int pitch = (pitch_sh16 + 0x6FFF) >> 16; + int idx_sh16 = ((pitch << 16) - pitch_sh16) * 8 + 0x58000; + idx = idx_sh16 >> 16; + if (s->pitch_diff_sh16) { + if (s->pitch_diff_sh16 > 0) { + next_idx_sh16 = (idx_sh16) &~ 0xFFFF; + } else + next_idx_sh16 = (idx_sh16 + 0x10000) &~ 0xFFFF; + len = av_clip((idx_sh16 - next_idx_sh16) / s->pitch_diff_sh16 / 8, + 1, size - n); + } else + len = size; + + ff_acelp_interpolatef(&excitation[n], &excitation[n - pitch], + wmavoice_ipol1_coeffs, 17, + idx, 9, len); + } + } else /* ACB_TYPE_HAMMING */ { + int block_pitch = block_pitch_sh2 >> 2; + idx = block_pitch_sh2 & 3; + if (idx) { + ff_acelp_interpolatef(excitation, &excitation[-block_pitch], + wmavoice_ipol2_coeffs, 4, + idx, 8, size); + } else + av_memcpy_backptr((uint8_t *) excitation, sizeof(float) * block_pitch, + sizeof(float) * size); + } + + /* Interpolate ACB/FCB and use as excitation signal */ + ff_weighted_vector_sumf(excitation, excitation, pulses, + acb_gain, fcb_gain, size); +} + +/** + * Parse data in a single block. + * @note we assume enough bits are available, caller should check. + * + * @param s WMA Voice decoding context private data + * @param gb bit I/O context + * @param block_idx index of the to-be-read block + * @param size amount of samples to be read in this block + * @param block_pitch_sh2 pitch for this block << 2 + * @param lsps LSPs for (the end of) this frame + * @param prev_lsps LSPs for the last frame + * @param frame_desc frame type descriptor + * @param excitation target memory for the ACB+FCB interpolated signal + * @param synth target memory for the speech synthesis filter output + * @return 0 on success, <0 on error. + */ +static void synth_block(WMAVoiceContext *s, GetBitContext *gb, + int block_idx, int size, + int block_pitch_sh2, + const double *lsps, const double *prev_lsps, + const struct frame_type_desc *frame_desc, + float *excitation, float *synth) +{ + double i_lsps[MAX_LSPS]; + float lpcs[MAX_LSPS]; + float fac; + int n; + + if (frame_desc->acb_type == ACB_TYPE_NONE) + synth_block_hardcoded(s, gb, block_idx, size, frame_desc, excitation); + else + synth_block_fcb_acb(s, gb, block_idx, size, block_pitch_sh2, + frame_desc, excitation); + + /* convert interpolated LSPs to LPCs */ + fac = (block_idx + 0.5) / frame_desc->n_blocks; + for (n = 0; n < s->lsps; n++) // LSF -> LSP + i_lsps[n] = cos(prev_lsps[n] + fac * (lsps[n] - prev_lsps[n])); + ff_acelp_lspd2lpc(i_lsps, lpcs, s->lsps >> 1); + + /* Speech synthesis */ + ff_celp_lp_synthesis_filterf(synth, lpcs, excitation, size, s->lsps); +} + +/** + * Synthesize output samples for a single frame. + * @note we assume enough bits are available, caller should check. + * + * @param ctx WMA Voice decoder context + * @param gb bit I/O context (s->gb or one for cross-packet superframes) + * @param frame_idx Frame number within superframe [0-2] + * @param samples pointer to output sample buffer, has space for at least 160 + * samples + * @param lsps LSP array + * @param prev_lsps array of previous frame's LSPs + * @param excitation target buffer for excitation signal + * @param synth target buffer for synthesized speech data + * @return 0 on success, <0 on error. + */ +static int synth_frame(AVCodecContext *ctx, GetBitContext *gb, int frame_idx, + float *samples, + const double *lsps, const double *prev_lsps, + float *excitation, float *synth) +{ + WMAVoiceContext *s = ctx->priv_data; + int n, n_blocks_x2, log_n_blocks_x2, cur_pitch_val; + int pitch[MAX_BLOCKS], last_block_pitch; + + /* Parse frame type ("frame header"), see frame_descs */ + int bd_idx = s->vbm_tree[get_vlc2(gb, frame_type_vlc.table, 6, 3)], + block_nsamples = MAX_FRAMESIZE / frame_descs[bd_idx].n_blocks; + + if (bd_idx < 0) { + av_log(ctx, AV_LOG_ERROR, + "Invalid frame type VLC code, skipping\n"); + return -1; + } + + /* Pitch calculation for ACB_TYPE_ASYMMETRIC ("pitch-per-frame") */ + if (frame_descs[bd_idx].acb_type == ACB_TYPE_ASYMMETRIC) { + /* Pitch is provided per frame, which is interpreted as the pitch of + * the last sample of the last block of this frame. We can interpolate + * the pitch of other blocks (and even pitch-per-sample) by gradually + * incrementing/decrementing prev_frame_pitch to cur_pitch_val. */ + n_blocks_x2 = frame_descs[bd_idx].n_blocks << 1; + log_n_blocks_x2 = frame_descs[bd_idx].log_n_blocks + 1; + cur_pitch_val = s->min_pitch_val + get_bits(gb, s->pitch_nbits); + cur_pitch_val = FFMIN(cur_pitch_val, s->max_pitch_val - 1); + if (s->last_acb_type == ACB_TYPE_NONE || + 20 * abs(cur_pitch_val - s->last_pitch_val) > + (cur_pitch_val + s->last_pitch_val)) + s->last_pitch_val = cur_pitch_val; + + /* pitch per block */ + for (n = 0; n < frame_descs[bd_idx].n_blocks; n++) { + int fac = n * 2 + 1; + + pitch[n] = (MUL16(fac, cur_pitch_val) + + MUL16((n_blocks_x2 - fac), s->last_pitch_val) + + frame_descs[bd_idx].n_blocks) >> log_n_blocks_x2; + } + + /* "pitch-diff-per-sample" for calculation of pitch per sample */ + s->pitch_diff_sh16 = + ((cur_pitch_val - s->last_pitch_val) << 16) / MAX_FRAMESIZE; + } + + /* Global gain (if silence) and pitch-adaptive window coordinates */ + switch (frame_descs[bd_idx].fcb_type) { + case FCB_TYPE_SILENCE: + s->silence_gain = wmavoice_gain_silence[get_bits(gb, 8)]; + break; + case FCB_TYPE_AW_PULSES: + aw_parse_coords(s, gb, pitch); + break; + } + + for (n = 0; n < frame_descs[bd_idx].n_blocks; n++) { + int bl_pitch_sh2; + + /* Pitch calculation for ACB_TYPE_HAMMING ("pitch-per-block") */ + switch (frame_descs[bd_idx].acb_type) { + case ACB_TYPE_HAMMING: { + /* Pitch is given per block. Per-block pitches are encoded as an + * absolute value for the first block, and then delta values + * relative to this value) for all subsequent blocks. The scale of + * this pitch value is semi-logaritmic compared to its use in the + * decoder, so we convert it to normal scale also. */ + int block_pitch, + t1 = (s->block_conv_table[1] - s->block_conv_table[0]) << 2, + t2 = (s->block_conv_table[2] - s->block_conv_table[1]) << 1, + t3 = s->block_conv_table[3] - s->block_conv_table[2] + 1; + + if (n == 0) { + block_pitch = get_bits(gb, s->block_pitch_nbits); + } else + block_pitch = last_block_pitch - s->block_delta_pitch_hrange + + get_bits(gb, s->block_delta_pitch_nbits); + /* Convert last_ so that any next delta is within _range */ + last_block_pitch = av_clip(block_pitch, + s->block_delta_pitch_hrange, + s->block_pitch_range - + s->block_delta_pitch_hrange); + + /* Convert semi-log-style scale back to normal scale */ + if (block_pitch < t1) { + bl_pitch_sh2 = (s->block_conv_table[0] << 2) + block_pitch; + } else { + block_pitch -= t1; + if (block_pitch < t2) { + bl_pitch_sh2 = + (s->block_conv_table[1] << 2) + (block_pitch << 1); + } else { + block_pitch -= t2; + if (block_pitch < t3) { + bl_pitch_sh2 = + (s->block_conv_table[2] + block_pitch) << 2; + } else + bl_pitch_sh2 = s->block_conv_table[3] << 2; + } + } + pitch[n] = bl_pitch_sh2 >> 2; + break; + } + + case ACB_TYPE_ASYMMETRIC: { + bl_pitch_sh2 = pitch[n] << 2; + break; + } + + default: // ACB_TYPE_NONE has no pitch + bl_pitch_sh2 = 0; + break; + } + + synth_block(s, gb, n, block_nsamples, bl_pitch_sh2, + lsps, prev_lsps, &frame_descs[bd_idx], + &excitation[n * block_nsamples], + &synth[n * block_nsamples]); + } + + /* Averaging projection filter, if applicable. Else, just copy samples + * from synthesis buffer */ + if (s->do_apf) { + double i_lsps[MAX_LSPS]; + float lpcs[MAX_LSPS]; + + for (n = 0; n < s->lsps; n++) // LSF -> LSP + i_lsps[n] = cos(0.5 * (prev_lsps[n] + lsps[n])); + ff_acelp_lspd2lpc(i_lsps, lpcs, s->lsps >> 1); + postfilter(s, synth, samples, 80, lpcs, + &s->zero_exc_pf[s->history_nsamples + MAX_FRAMESIZE * frame_idx], + frame_descs[bd_idx].fcb_type, pitch[0]); + + for (n = 0; n < s->lsps; n++) // LSF -> LSP + i_lsps[n] = cos(lsps[n]); + ff_acelp_lspd2lpc(i_lsps, lpcs, s->lsps >> 1); + postfilter(s, &synth[80], &samples[80], 80, lpcs, + &s->zero_exc_pf[s->history_nsamples + MAX_FRAMESIZE * frame_idx + 80], + frame_descs[bd_idx].fcb_type, pitch[0]); + } else + memcpy(samples, synth, 160 * sizeof(synth[0])); + + /* Cache values for next frame */ + s->frame_cntr++; + if (s->frame_cntr >= 0xFFFF) s->frame_cntr -= 0xFFFF; // i.e. modulo (%) + s->last_acb_type = frame_descs[bd_idx].acb_type; + switch (frame_descs[bd_idx].acb_type) { + case ACB_TYPE_NONE: + s->last_pitch_val = 0; + break; + case ACB_TYPE_ASYMMETRIC: + s->last_pitch_val = cur_pitch_val; + break; + case ACB_TYPE_HAMMING: + s->last_pitch_val = pitch[frame_descs[bd_idx].n_blocks - 1]; + break; + } + + return 0; +} + +/** + * Ensure minimum value for first item, maximum value for last value, + * proper spacing between each value and proper ordering. + * + * @param lsps array of LSPs + * @param num size of LSP array + * + * @note basically a double version of #ff_acelp_reorder_lsf(), might be + * useful to put in a generic location later on. Parts are also + * present in #ff_set_min_dist_lsf() + #ff_sort_nearly_sorted_floats(), + * which is in float. + */ +static void stabilize_lsps(double *lsps, int num) +{ + int n, m, l; + + /* set minimum value for first, maximum value for last and minimum + * spacing between LSF values. + * Very similar to ff_set_min_dist_lsf(), but in double. */ + lsps[0] = FFMAX(lsps[0], 0.0015 * M_PI); + for (n = 1; n < num; n++) + lsps[n] = FFMAX(lsps[n], lsps[n - 1] + 0.0125 * M_PI); + lsps[num - 1] = FFMIN(lsps[num - 1], 0.9985 * M_PI); + + /* reorder (looks like one-time / non-recursed bubblesort). + * Very similar to ff_sort_nearly_sorted_floats(), but in double. */ + for (n = 1; n < num; n++) { + if (lsps[n] < lsps[n - 1]) { + for (m = 1; m < num; m++) { + double tmp = lsps[m]; + for (l = m - 1; l >= 0; l--) { + if (lsps[l] <= tmp) break; + lsps[l + 1] = lsps[l]; + } + lsps[l + 1] = tmp; + } + break; + } + } +} + +/** + * Test if there's enough bits to read 1 superframe. + * + * @param orig_gb bit I/O context used for reading. This function + * does not modify the state of the bitreader; it + * only uses it to copy the current stream position + * @param s WMA Voice decoding context private data + * @return -1 if unsupported, 1 on not enough bits or 0 if OK. + */ +static int check_bits_for_superframe(GetBitContext *orig_gb, + WMAVoiceContext *s) +{ + GetBitContext s_gb, *gb = &s_gb; + int n, need_bits, bd_idx; + const struct frame_type_desc *frame_desc; + + /* initialize a copy */ + init_get_bits(gb, orig_gb->buffer, orig_gb->size_in_bits); + skip_bits_long(gb, get_bits_count(orig_gb)); + assert(get_bits_left(gb) == get_bits_left(orig_gb)); + + /* superframe header */ + if (get_bits_left(gb) < 14) + return 1; + if (!get_bits1(gb)) + return -1; // WMAPro-in-WMAVoice superframe + if (get_bits1(gb)) skip_bits(gb, 12); // number of samples in superframe + if (s->has_residual_lsps) { // residual LSPs (for all frames) + if (get_bits_left(gb) < s->sframe_lsp_bitsize) + return 1; + skip_bits_long(gb, s->sframe_lsp_bitsize); + } + + /* frames */ + for (n = 0; n < MAX_FRAMES; n++) { + int aw_idx_is_ext = 0; + + if (!s->has_residual_lsps) { // independent LSPs (per-frame) + if (get_bits_left(gb) < s->frame_lsp_bitsize) return 1; + skip_bits_long(gb, s->frame_lsp_bitsize); + } + bd_idx = s->vbm_tree[get_vlc2(gb, frame_type_vlc.table, 6, 3)]; + if (bd_idx < 0) + return -1; // invalid frame type VLC code + frame_desc = &frame_descs[bd_idx]; + if (frame_desc->acb_type == ACB_TYPE_ASYMMETRIC) { + if (get_bits_left(gb) < s->pitch_nbits) + return 1; + skip_bits_long(gb, s->pitch_nbits); + } + if (frame_desc->fcb_type == FCB_TYPE_SILENCE) { + skip_bits(gb, 8); + } else if (frame_desc->fcb_type == FCB_TYPE_AW_PULSES) { + int tmp = get_bits(gb, 6); + if (tmp >= 0x36) { + skip_bits(gb, 2); + aw_idx_is_ext = 1; + } + } + + /* blocks */ + if (frame_desc->acb_type == ACB_TYPE_HAMMING) { + need_bits = s->block_pitch_nbits + + (frame_desc->n_blocks - 1) * s->block_delta_pitch_nbits; + } else if (frame_desc->fcb_type == FCB_TYPE_AW_PULSES) { + need_bits = 2 * !aw_idx_is_ext; + } else + need_bits = 0; + need_bits += frame_desc->frame_size; + if (get_bits_left(gb) < need_bits) + return 1; + skip_bits_long(gb, need_bits); + } + + return 0; +} + +/** + * Synthesize output samples for a single superframe. If we have any data + * cached in s->sframe_cache, that will be used instead of whatever is loaded + * in s->gb. + * + * WMA Voice superframes contain 3 frames, each containing 160 audio samples, + * to give a total of 480 samples per frame. See #synth_frame() for frame + * parsing. In addition to 3 frames, superframes can also contain the LSPs + * (if these are globally specified for all frames (residually); they can + * also be specified individually per-frame. See the s->has_residual_lsps + * option), and can specify the number of samples encoded in this superframe + * (if less than 480), usually used to prevent blanks at track boundaries. + * + * @param ctx WMA Voice decoder context + * @param samples pointer to output buffer for voice samples + * @param data_size pointer containing the size of #samples on input, and the + * amount of #samples filled on output + * @return 0 on success, <0 on error or 1 if there was not enough data to + * fully parse the superframe + */ +static int synth_superframe(AVCodecContext *ctx, + float *samples, int *data_size) +{ + WMAVoiceContext *s = ctx->priv_data; + GetBitContext *gb = &s->gb, s_gb; + int n, res, n_samples = 480; + double lsps[MAX_FRAMES][MAX_LSPS]; + const double *mean_lsf = s->lsps == 16 ? + wmavoice_mean_lsf16[s->lsp_def_mode] : wmavoice_mean_lsf10[s->lsp_def_mode]; + float excitation[MAX_SIGNAL_HISTORY + MAX_SFRAMESIZE + 12]; + float synth[MAX_LSPS + MAX_SFRAMESIZE]; + + memcpy(synth, s->synth_history, + s->lsps * sizeof(*synth)); + memcpy(excitation, s->excitation_history, + s->history_nsamples * sizeof(*excitation)); + + if (s->sframe_cache_size > 0) { + gb = &s_gb; + init_get_bits(gb, s->sframe_cache, s->sframe_cache_size); + s->sframe_cache_size = 0; + } + + if ((res = check_bits_for_superframe(gb, s)) == 1) return 1; + + /* First bit is speech/music bit, it differentiates between WMAVoice + * speech samples (the actual codec) and WMAVoice music samples, which + * are really WMAPro-in-WMAVoice-superframes. I've never seen those in + * the wild yet. */ + if (!get_bits1(gb)) { + av_log_missing_feature(ctx, "WMAPro-in-WMAVoice support", 1); + return ERROR_WMAPRO_IN_WMAVOICE; + } + + /* (optional) nr. of samples in superframe; always <= 480 and >= 0 */ + if (get_bits1(gb)) { + if ((n_samples = get_bits(gb, 12)) > 480) { + av_log(ctx, AV_LOG_ERROR, + "Superframe encodes >480 samples (%d), not allowed\n", + n_samples); + return -1; + } + } + /* Parse LSPs, if global for the superframe (can also be per-frame). */ + if (s->has_residual_lsps) { + double prev_lsps[MAX_LSPS], a1[MAX_LSPS * 2], a2[MAX_LSPS * 2]; + + for (n = 0; n < s->lsps; n++) + prev_lsps[n] = s->prev_lsps[n] - mean_lsf[n]; + + if (s->lsps == 10) { + dequant_lsp10r(gb, lsps[2], prev_lsps, a1, a2, s->lsp_q_mode); + } else /* s->lsps == 16 */ + dequant_lsp16r(gb, lsps[2], prev_lsps, a1, a2, s->lsp_q_mode); + + for (n = 0; n < s->lsps; n++) { + lsps[0][n] = mean_lsf[n] + (a1[n] - a2[n * 2]); + lsps[1][n] = mean_lsf[n] + (a1[s->lsps + n] - a2[n * 2 + 1]); + lsps[2][n] += mean_lsf[n]; + } + for (n = 0; n < 3; n++) + stabilize_lsps(lsps[n], s->lsps); + } + + /* Parse frames, optionally preceeded by per-frame (independent) LSPs. */ + for (n = 0; n < 3; n++) { + if (!s->has_residual_lsps) { + int m; + + if (s->lsps == 10) { + dequant_lsp10i(gb, lsps[n]); + } else /* s->lsps == 16 */ + dequant_lsp16i(gb, lsps[n]); + + for (m = 0; m < s->lsps; m++) + lsps[n][m] += mean_lsf[m]; + stabilize_lsps(lsps[n], s->lsps); + } + + if ((res = synth_frame(ctx, gb, n, + &samples[n * MAX_FRAMESIZE], + lsps[n], n == 0 ? s->prev_lsps : lsps[n - 1], + &excitation[s->history_nsamples + n * MAX_FRAMESIZE], + &synth[s->lsps + n * MAX_FRAMESIZE]))) + return res; + } + + /* Statistics? FIXME - we don't check for length, a slight overrun + * will be caught by internal buffer padding, and anything else + * will be skipped, not read. */ + if (get_bits1(gb)) { + res = get_bits(gb, 4); + skip_bits(gb, 10 * (res + 1)); + } + + /* Specify nr. of output samples */ + *data_size = n_samples * sizeof(float); + + /* Update history */ + memcpy(s->prev_lsps, lsps[2], + s->lsps * sizeof(*s->prev_lsps)); + memcpy(s->synth_history, &synth[MAX_SFRAMESIZE], + s->lsps * sizeof(*synth)); + memcpy(s->excitation_history, &excitation[MAX_SFRAMESIZE], + s->history_nsamples * sizeof(*excitation)); + if (s->do_apf) + memmove(s->zero_exc_pf, &s->zero_exc_pf[MAX_SFRAMESIZE], + s->history_nsamples * sizeof(*s->zero_exc_pf)); + + return 0; +} + +/** + * Parse the packet header at the start of each packet (input data to this + * decoder). + * + * @param s WMA Voice decoding context private data + * @return 1 if not enough bits were available, or 0 on success. + */ +static int parse_packet_header(WMAVoiceContext *s) +{ + GetBitContext *gb = &s->gb; + unsigned int res; + + if (get_bits_left(gb) < 11) + return 1; + skip_bits(gb, 4); // packet sequence number + s->has_residual_lsps = get_bits1(gb); + do { + res = get_bits(gb, 6); // number of superframes per packet + // (minus first one if there is spillover) + if (get_bits_left(gb) < 6 * (res == 0x3F) + s->spillover_bitsize) + return 1; + } while (res == 0x3F); + s->spillover_nbits = get_bits(gb, s->spillover_bitsize); + + return 0; +} + +/** + * Copy (unaligned) bits from gb/data/size to pb. + * + * @param pb target buffer to copy bits into + * @param data source buffer to copy bits from + * @param size size of the source data, in bytes + * @param gb bit I/O context specifying the current position in the source. + * data. This function might use this to align the bit position to + * a whole-byte boundary before calling #ff_copy_bits() on aligned + * source data + * @param nbits the amount of bits to copy from source to target + * + * @note after calling this function, the current position in the input bit + * I/O context is undefined. + */ +static void copy_bits(PutBitContext *pb, + const uint8_t *data, int size, + GetBitContext *gb, int nbits) +{ + int rmn_bytes, rmn_bits; + + rmn_bits = rmn_bytes = get_bits_left(gb); + if (rmn_bits < nbits) + return; + rmn_bits &= 7; rmn_bytes >>= 3; + if ((rmn_bits = FFMIN(rmn_bits, nbits)) > 0) + put_bits(pb, rmn_bits, get_bits(gb, rmn_bits)); + ff_copy_bits(pb, data + size - rmn_bytes, + FFMIN(nbits - rmn_bits, rmn_bytes << 3)); +} + +/** + * Packet decoding: a packet is anything that the (ASF) demuxer contains, + * and we expect that the demuxer / application provides it to us as such + * (else you'll probably get garbage as output). Every packet has a size of + * ctx->block_align bytes, starts with a packet header (see + * #parse_packet_header()), and then a series of superframes. Superframe + * boundaries may exceed packets, i.e. superframes can split data over + * multiple (two) packets. + * + * For more information about frames, see #synth_superframe(). + */ +int wmavoice_decode_packet(AVCodecContext *ctx, void *data, + int *data_size, AVPacket *avpkt) +{ + WMAVoiceContext *s = ctx->priv_data; + GetBitContext *gb = &s->gb; + int size, res, pos; + + if (*data_size < 480 * sizeof(float)) { + av_log(ctx, AV_LOG_ERROR, + "Output buffer too small (%d given - %zu needed)\n", + *data_size, 480 * sizeof(float)); + return -1; + } + *data_size = 0; + + /* Packets are sometimes a multiple of ctx->block_align, with a packet + * header at each ctx->block_align bytes. However, FFmpeg's ASF demuxer + * feeds us ASF packets, which may concatenate multiple "codec" packets + * in a single "muxer" packet, so we artificially emulate that by + * capping the packet size at ctx->block_align. */ + for (size = avpkt->size; size > ctx->block_align; size -= ctx->block_align); + if (!size) + return 0; + init_get_bits(&s->gb, avpkt->data, size << 3); + + /* size == ctx->block_align is used to indicate whether we are dealing with + * a new packet or a packet of which we already read the packet header + * previously. */ + if (size == ctx->block_align) { // new packet header + if ((res = parse_packet_header(s)) < 0) + return res; + + /* If the packet header specifies a s->spillover_nbits, then we want + * to push out all data of the previous packet (+ spillover) before + * continuing to parse new superframes in the current packet. */ + if (s->spillover_nbits > 0) { + if (s->sframe_cache_size > 0) { + int cnt = get_bits_count(gb); + copy_bits(&s->pb, avpkt->data, size, gb, s->spillover_nbits); + flush_put_bits(&s->pb); + s->sframe_cache_size += s->spillover_nbits; + if ((res = synth_superframe(ctx, data, data_size)) == 0 && + *data_size > 0) { + /* convert the float values to int32 for rockbox */ + int i; + int32_t *iptr = data; + float *fptr = data; + for(i = 0; i < *data_size/sizeof(float); i++) + { + fptr[i] *= (float)(INT32_MAX); + iptr[i] = (int32_t)fptr[i]; + } + cnt += s->spillover_nbits; + s->skip_bits_next = cnt & 7; + return cnt >> 3; + } else + skip_bits_long (gb, s->spillover_nbits - cnt + + get_bits_count(gb)); // resync + } else + skip_bits_long(gb, s->spillover_nbits); // resync + } + } else if (s->skip_bits_next) + skip_bits(gb, s->skip_bits_next); + + /* Try parsing superframes in current packet */ + s->sframe_cache_size = 0; + s->skip_bits_next = 0; + pos = get_bits_left(gb); + if ((res = synth_superframe(ctx, data, data_size)) < 0) { + return res; + } else if (*data_size > 0) { + int cnt = get_bits_count(gb); + s->skip_bits_next = cnt & 7; + /* convert the float values to int32 for rockbox */ + int i; + int32_t *iptr = data; + float *fptr = data; + for(i = 0; i < *data_size/sizeof(float); i++) + { + fptr[i] *= (float)(INT32_MAX); + iptr[i] = (int32_t)fptr[i]; + } + return cnt >> 3; + } else if ((s->sframe_cache_size = pos) > 0) { + /* rewind bit reader to start of last (incomplete) superframe... */ + init_get_bits(gb, avpkt->data, size << 3); + skip_bits_long(gb, (size << 3) - pos); + //assert(get_bits_left(gb) == pos); + + /* ...and cache it for spillover in next packet */ + init_put_bits(&s->pb, s->sframe_cache, SFRAME_CACHE_MAXSIZE); + copy_bits(&s->pb, avpkt->data, size, gb, s->sframe_cache_size); + // FIXME bad - just copy bytes as whole and add use the + // skip_bits_next field + } + + return size; +} + +static av_cold int wmavoice_decode_end(AVCodecContext *ctx) +{ + WMAVoiceContext *s = ctx->priv_data; + + if (s->do_apf) { + ff_rdft_end(&s->rdft); + ff_rdft_end(&s->irdft); + ff_dct_end(&s->dct); + ff_dct_end(&s->dst); + } + + return 0; +} + +static av_cold void wmavoice_flush(AVCodecContext *ctx) +{ + WMAVoiceContext *s = ctx->priv_data; + int n; + + s->postfilter_agc = 0; + s->sframe_cache_size = 0; + s->skip_bits_next = 0; + for (n = 0; n < s->lsps; n++) + s->prev_lsps[n] = M_PI * (n + 1.0) / (s->lsps + 1.0); + memset(s->excitation_history, 0, + sizeof(*s->excitation_history) * MAX_SIGNAL_HISTORY); + memset(s->synth_history, 0, + sizeof(*s->synth_history) * MAX_LSPS); + memset(s->gain_pred_err, 0, + sizeof(s->gain_pred_err)); + + if (s->do_apf) { + memset(&s->synth_filter_out_buf[MAX_LSPS_ALIGN16 - s->lsps], 0, + sizeof(*s->synth_filter_out_buf) * s->lsps); + memset(s->dcf_mem, 0, + sizeof(*s->dcf_mem) * 2); + memset(s->zero_exc_pf, 0, + sizeof(*s->zero_exc_pf) * s->history_nsamples); + memset(s->denoise_filter_cache, 0, sizeof(s->denoise_filter_cache)); + } +} +#if 0 +AVCodec wmavoice_decoder = { + "wmavoice", + AVMEDIA_TYPE_AUDIO, + CODEC_ID_WMAVOICE, + sizeof(WMAVoiceContext), + wmavoice_decode_init, + NULL, + wmavoice_decode_end, + wmavoice_decode_packet, + CODEC_CAP_SUBFRAMES, + .flush = wmavoice_flush, + .long_name = NULL_IF_CONFIG_SMALL("Windows Media Audio Voice"), +}; +#endif + +int main(void) +{ + return 0; +} diff --git a/lib/rbcodec/codecs/libwmavoice/wmavoice.h b/lib/rbcodec/codecs/libwmavoice/wmavoice.h new file mode 100644 index 0000000000..33ec72b4e2 --- /dev/null +++ b/lib/rbcodec/codecs/libwmavoice/wmavoice.h @@ -0,0 +1,7 @@ +#include "avcodec.h" + +#define ERROR_WMAPRO_IN_WMAVOICE -0x162 + +av_cold int wmavoice_decode_init(AVCodecContext *ctx); +int wmavoice_decode_packet(AVCodecContext *ctx, void *data, + int *data_size, AVPacket *avpkt); diff --git a/lib/rbcodec/codecs/libwmavoice/wmavoice_data.h b/lib/rbcodec/codecs/libwmavoice/wmavoice_data.h new file mode 100644 index 0000000000..cbf65b043e --- /dev/null +++ b/lib/rbcodec/codecs/libwmavoice/wmavoice_data.h @@ -0,0 +1,3259 @@ +/* + * Windows Media Voice (WMAVoice) tables. + * Copyright (c) 2009 Ronald S. Bultje + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * @brief Windows Media Voice (WMAVoice) tables + * @author Ronald S. Bultje + */ + +#ifndef AVCODEC_WMAVOICE_DATA_H +#define AVCODEC_WMAVOICE_DATA_H + +#include + +static const uint8_t wmavoice_dq_lsp10i[0xf00] = { + 125, 109, 84, 55, 34, 51, 109, 112, 118, 132, + 122, 102, 78, 80, 132, 119, 132, 132, 125, 131, + 109, 91, 131, 131, 136, 136, 137, 137, 140, 145, + 140, 143, 117, 136, 122, 106, 109, 91, 115, 119, + 133, 117, 103, 80, 55, 117, 123, 102, 93, 80, + 139, 116, 70, 39, 95, 89, 103, 113, 112, 122, + 135, 244, 229, 215, 199, 181, 163, 150, 146, 144, + 143, 173, 171, 154, 155, 154, 151, 148, 145, 143, + 132, 138, 116, 85, 117, 94, 108, 117, 107, 116, + 132, 118, 123, 119, 88, 67, 49, 95, 84, 95, + 121, 103, 74, 70, 179, 164, 141, 126, 107, 112, + 119, 95, 103, 149, 139, 148, 144, 147, 148, 141, + 151, 133, 142, 129, 111, 131, 108, 128, 122, 108, + 121, 96, 115, 138, 116, 93, 105, 115, 115, 123, + 129, 106, 136, 180, 147, 130, 108, 141, 131, 118, + 136, 155, 176, 156, 135, 129, 140, 146, 142, 134, + 141, 130, 109, 80, 52, 38, 18, 47, 118, 134, + 155, 141, 100, 78, 72, 89, 79, 96, 92, 98, + 133, 111, 83, 91, 72, 58, 105, 115, 112, 120, + 145, 127, 135, 113, 113, 105, 105, 85, 69, 61, + 115, 96, 116, 145, 159, 170, 175, 175, 168, 155, + 140, 120, 84, 52, 80, 145, 125, 127, 116, 126, + 128, 108, 101, 198, 227, 200, 178, 159, 147, 148, + 121, 88, 46, 109, 124, 126, 126, 137, 147, 147, + 129, 107, 164, 148, 127, 117, 134, 120, 111, 116, + 120, 103, 98, 73, 66, 61, 70, 115, 116, 125, + 126, 100, 77, 188, 162, 140, 114, 128, 139, 123, + 145, 165, 164, 134, 109, 100, 108, 118, 127, 130, + 156, 182, 190, 173, 167, 165, 162, 157, 152, 147, + 150, 164, 179, 183, 173, 155, 140, 136, 134, 135, + 122, 92, 69, 140, 132, 118, 108, 128, 138, 132, + 123, 127, 148, 137, 150, 149, 139, 127, 124, 130, + 136, 138, 112, 70, 41, 37, 132, 140, 129, 125, + 130, 111, 78, 33, 51, 161, 141, 136, 120, 122, + 126, 110, 87, 106, 85, 68, 48, 81, 112, 113, + 135, 125, 98, 85, 102, 80, 100, 87, 86, 116, + 142, 133, 110, 66, 48, 152, 139, 135, 136, 123, + 128, 116, 89, 102, 128, 99, 83, 61, 105, 124, + 120, 94, 73, 83, 78, 100, 122, 124, 128, 132, + 144, 137, 116, 102, 75, 144, 136, 127, 140, 127, + 154, 144, 118, 99, 90, 90, 89, 75, 68, 83, + 123, 103, 89, 198, 180, 154, 138, 122, 136, 120, + 138, 118, 121, 136, 110, 105, 85, 111, 101, 104, + 121, 126, 139, 115, 99, 101, 107, 110, 123, 126, + 127, 115, 88, 109, 164, 134, 138, 138, 120, 121, + 130, 202, 195, 202, 199, 201, 181, 164, 159, 148, + 120, 116, 194, 199, 186, 171, 154, 142, 137, 133, + 137, 129, 112, 149, 134, 112, 149, 138, 120, 134, + 119, 102, 107, 83, 79, 114, 119, 127, 128, 128, + 144, 148, 165, 155, 161, 150, 135, 122, 116, 115, + 120, 99, 80, 120, 123, 124, 111, 89, 70, 108, + 118, 95, 66, 53, 105, 126, 125, 105, 83, 111, + 129, 197, 191, 197, 206, 213, 216, 208, 196, 169, + 133, 109, 127, 164, 134, 121, 99, 92, 82, 71, + 131, 121, 93, 91, 136, 105, 115, 140, 120, 110, + 150, 164, 139, 108, 87, 81, 93, 92, 104, 116, + 133, 114, 125, 126, 111, 136, 110, 156, 147, 133, + 113, 94, 118, 120, 115, 125, 124, 126, 127, 134, + 116, 131, 161, 158, 166, 157, 150, 150, 144, 141, + 125, 185, 169, 142, 140, 143, 139, 131, 134, 138, + 179, 188, 170, 150, 134, 140, 144, 133, 127, 127, + 150, 177, 204, 184, 192, 194, 190, 193, 177, 158, + 114, 113, 138, 116, 137, 135, 132, 131, 127, 134, + 120, 147, 163, 135, 133, 137, 136, 136, 133, 135, + 137, 120, 95, 73, 46, 48, 111, 97, 97, 123, + 139, 130, 109, 76, 52, 72, 61, 61, 125, 127, + 132, 119, 119, 90, 66, 41, 64, 156, 143, 129, + 131, 106, 58, 25, 99, 115, 122, 136, 129, 132, + 134, 123, 97, 53, 27, 114, 125, 114, 120, 123, + 122, 107, 93, 57, 47, 133, 128, 138, 141, 131, + 145, 132, 122, 110, 79, 57, 30, 73, 153, 144, + 150, 132, 85, 59, 133, 125, 130, 115, 100, 96, + 148, 127, 111, 86, 61, 38, 110, 121, 108, 99, + 157, 143, 105, 77, 116, 118, 115, 131, 122, 122, + 133, 119, 134, 108, 86, 61, 129, 165, 143, 127, + 125, 105, 89, 111, 97, 85, 113, 99, 98, 117, + 149, 131, 101, 106, 88, 95, 79, 119, 123, 120, + 125, 109, 81, 100, 201, 183, 156, 138, 115, 116, + 141, 119, 129, 105, 76, 60, 110, 99, 92, 82, + 150, 156, 129, 95, 69, 115, 115, 113, 134, 125, + 118, 97, 67, 96, 203, 197, 171, 151, 133, 125, + 143, 131, 120, 134, 105, 80, 51, 60, 139, 134, + 129, 160, 223, 219, 219, 212, 197, 173, 157, 146, + 132, 112, 164, 144, 119, 102, 92, 76, 73, 94, + 132, 112, 124, 114, 93, 92, 83, 73, 69, 99, + 129, 103, 188, 163, 142, 132, 127, 101, 82, 59, + 140, 141, 111, 74, 46, 105, 113, 99, 127, 122, + 125, 94, 63, 112, 116, 101, 81, 120, 136, 134, + 133, 190, 224, 193, 179, 158, 146, 143, 140, 136, + 152, 161, 132, 120, 112, 94, 114, 102, 92, 116, + 129, 194, 196, 202, 211, 212, 210, 190, 169, 152, + 166, 166, 145, 111, 91, 132, 133, 128, 136, 130, + 118, 94, 72, 74, 92, 86, 89, 92, 106, 123, + 126, 100, 86, 137, 117, 92, 76, 104, 106, 114, + 133, 109, 204, 192, 166, 148, 138, 128, 111, 81, + 118, 99, 79, 146, 169, 141, 123, 102, 131, 120, + 127, 105, 136, 204, 170, 154, 131, 145, 135, 119, + 117, 95, 64, 83, 141, 136, 118, 96, 99, 126, + 115, 93, 98, 102, 95, 105, 106, 114, 119, 128, + 131, 121, 98, 139, 149, 119, 109, 86, 105, 129, + 134, 119, 104, 169, 185, 155, 141, 122, 107, 127, + 136, 115, 85, 108, 87, 126, 102, 128, 136, 129, + 125, 99, 126, 158, 133, 139, 132, 113, 91, 107, + 141, 122, 128, 161, 130, 127, 105, 120, 118, 106, + 122, 140, 161, 168, 187, 184, 176, 158, 144, 140, + 127, 111, 89, 130, 132, 105, 134, 121, 100, 122, + 129, 110, 128, 115, 129, 116, 132, 118, 114, 119, + 138, 133, 132, 188, 183, 159, 161, 147, 134, 140, + 132, 113, 84, 167, 147, 132, 124, 109, 133, 121, + 132, 128, 116, 121, 98, 101, 145, 129, 128, 129, + 124, 112, 152, 158, 136, 161, 139, 165, 158, 142, + 139, 138, 110, 127, 148, 117, 126, 118, 101, 116, + 155, 168, 154, 128, 120, 152, 150, 141, 140, 135, + 127, 111, 109, 134, 104, 133, 110, 112, 132, 114, + 111, 87, 68, 89, 107, 121, 121, 126, 126, 129, + 120, 148, 169, 163, 173, 178, 185, 188, 178, 163, + 122, 97, 86, 117, 101, 138, 118, 142, 155, 139, + 125, 114, 131, 138, 153, 149, 163, 150, 143, 141, + 157, 161, 138, 152, 134, 121, 122, 109, 110, 124, + 151, 171, 196, 168, 145, 139, 147, 151, 146, 139, + 134, 169, 179, 170, 175, 178, 177, 173, 165, 154, + 120, 151, 118, 107, 125, 129, 133, 133, 136, 139, + 119, 141, 159, 151, 160, 165, 168, 169, 162, 152, + 115, 111, 119, 94, 117, 121, 127, 127, 132, 136, + 134, 153, 147, 142, 142, 147, 159, 159, 154, 147, + 110, 106, 139, 135, 143, 142, 147, 146, 147, 147, + 115, 133, 151, 133, 141, 142, 151, 152, 147, 144, + 115, 132, 144, 131, 125, 126, 128, 130, 131, 136, + 138, 118, 96, 71, 48, 26, 43, 130, 125, 125, + 134, 122, 98, 54, 28, 84, 77, 73, 109, 125, + 133, 112, 67, 48, 141, 129, 126, 113, 112, 118, + 143, 123, 89, 54, 71, 73, 75, 131, 123, 123, + 126, 109, 81, 31, 15, 94, 110, 109, 119, 128, + 132, 122, 97, 92, 73, 50, 27, 22, 104, 133, + 133, 119, 94, 48, 34, 168, 160, 154, 151, 130, + 147, 133, 90, 54, 71, 123, 106, 105, 93, 117, + 143, 132, 107, 69, 45, 78, 178, 169, 150, 139, + 138, 123, 116, 96, 69, 49, 32, 113, 103, 112, + 154, 151, 125, 79, 60, 152, 160, 154, 155, 137, + 142, 151, 124, 88, 66, 59, 94, 87, 95, 119, + 166, 154, 122, 92, 138, 132, 124, 114, 97, 97, + 122, 99, 98, 219, 191, 176, 165, 159, 153, 131, + 130, 119, 91, 51, 24, 41, 144, 156, 147, 139, + 139, 122, 81, 65, 124, 111, 104, 90, 94, 98, + 138, 120, 112, 91, 63, 65, 89, 75, 78, 106, + 126, 107, 91, 85, 69, 95, 90, 84, 108, 120, + 155, 139, 100, 78, 120, 110, 109, 91, 77, 73, + 144, 130, 135, 112, 88, 65, 62, 142, 129, 126, + 170, 154, 150, 131, 121, 116, 100, 92, 83, 86, + 131, 122, 98, 107, 102, 75, 54, 38, 117, 130, + 146, 139, 117, 107, 86, 66, 44, 30, 97, 128, + 129, 116, 100, 59, 108, 127, 119, 139, 129, 129, + 124, 106, 79, 49, 154, 190, 166, 152, 133, 123, + 141, 149, 123, 89, 61, 70, 143, 132, 125, 126, + 136, 113, 177, 166, 141, 123, 109, 108, 105, 93, + 137, 117, 147, 123, 99, 85, 109, 98, 91, 75, + 129, 121, 102, 78, 53, 90, 149, 136, 134, 135, + 144, 136, 126, 90, 114, 152, 137, 152, 138, 128, + 133, 115, 107, 129, 99, 78, 60, 129, 125, 118, + 147, 141, 119, 124, 110, 91, 79, 64, 106, 117, + 134, 111, 164, 143, 123, 113, 116, 95, 76, 56, + 147, 159, 140, 109, 83, 84, 140, 135, 127, 129, + 123, 104, 116, 99, 91, 87, 80, 110, 113, 121, + 124, 106, 174, 174, 152, 141, 132, 134, 126, 124, + 140, 190, 240, 215, 212, 189, 173, 158, 144, 137, + 123, 97, 79, 102, 110, 111, 90, 75, 126, 124, + 134, 121, 104, 145, 127, 100, 77, 65, 120, 118, + 123, 106, 87, 41, 68, 119, 106, 115, 109, 119, + 137, 232, 241, 225, 217, 202, 183, 169, 156, 145, + 161, 146, 127, 110, 97, 107, 88, 114, 108, 106, + 141, 244, 216, 192, 172, 163, 148, 143, 144, 144, + 128, 127, 109, 89, 77, 68, 124, 120, 121, 125, + 125, 94, 48, 71, 116, 113, 104, 120, 142, 137, + 133, 129, 115, 82, 68, 120, 99, 133, 134, 124, + 130, 106, 108, 160, 130, 111, 89, 129, 124, 119, + 134, 120, 149, 143, 116, 95, 87, 142, 132, 122, + 126, 114, 108, 107, 80, 141, 133, 123, 137, 124, + 117, 95, 69, 43, 62, 98, 114, 116, 112, 120, + 122, 99, 87, 164, 145, 123, 99, 95, 118, 105, + 126, 101, 102, 120, 113, 110, 92, 139, 134, 126, + 148, 194, 241, 219, 221, 215, 200, 193, 174, 151, + 127, 104, 122, 136, 113, 106, 110, 95, 78, 106, + 131, 163, 217, 199, 194, 175, 164, 155, 142, 138, + 139, 124, 88, 57, 161, 161, 145, 139, 124, 116, + 127, 110, 91, 98, 126, 104, 113, 98, 94, 94, + 145, 138, 114, 90, 75, 130, 117, 107, 99, 90, + 119, 98, 86, 101, 148, 133, 103, 83, 124, 131, + 143, 168, 169, 133, 110, 117, 139, 149, 147, 137, + 124, 106, 80, 138, 194, 163, 142, 119, 106, 130, + 136, 125, 105, 114, 87, 113, 101, 89, 108, 102, + 114, 90, 53, 46, 105, 116, 126, 122, 118, 122, + 124, 102, 92, 195, 167, 160, 144, 154, 154, 132, + 118, 97, 88, 72, 98, 120, 112, 98, 79, 117, + 114, 107, 185, 191, 191, 188, 175, 165, 153, 143, + 119, 97, 90, 89, 120, 151, 136, 113, 99, 112, + 141, 121, 144, 122, 125, 113, 133, 111, 92, 69, + 120, 98, 78, 109, 151, 145, 157, 157, 151, 143, + 130, 110, 120, 188, 159, 141, 119, 112, 109, 98, + 126, 112, 83, 110, 169, 139, 127, 105, 93, 123, + 141, 145, 117, 106, 91, 78, 123, 107, 101, 125, + 117, 95, 71, 147, 176, 153, 148, 133, 135, 127, + 124, 106, 79, 64, 115, 96, 108, 115, 106, 105, + 127, 115, 90, 98, 105, 81, 144, 135, 117, 125, + 126, 104, 98, 165, 138, 136, 112, 149, 148, 131, + 119, 144, 186, 185, 204, 202, 209, 200, 182, 161, + 123, 153, 190, 189, 199, 194, 191, 176, 157, 147, + 121, 103, 119, 98, 100, 120, 106, 97, 95, 126, + 137, 130, 102, 117, 117, 92, 126, 114, 101, 118, + 131, 219, 190, 167, 153, 151, 144, 140, 142, 143, + 114, 102, 151, 152, 132, 120, 112, 120, 127, 131, + 138, 122, 91, 143, 118, 120, 114, 104, 124, 117, + 148, 142, 117, 126, 97, 125, 108, 116, 142, 125, + 126, 106, 91, 169, 208, 178, 158, 138, 127, 135, + 133, 126, 101, 83, 147, 130, 125, 117, 114, 117, + 120, 103, 94, 149, 136, 129, 139, 118, 133, 133, + 147, 152, 126, 132, 119, 97, 132, 129, 114, 126, + 112, 107, 148, 125, 112, 114, 124, 125, 129, 135, + 139, 121, 157, 151, 131, 140, 118, 147, 136, 121, + 115, 105, 159, 167, 185, 191, 196, 190, 176, 160, + 124, 106, 104, 122, 130, 114, 152, 144, 134, 136, + 136, 152, 159, 153, 131, 114, 116, 126, 129, 129, + 124, 109, 87, 131, 107, 115, 130, 107, 144, 131, + 126, 162, 176, 175, 180, 176, 160, 141, 134, 134, + 136, 127, 108, 161, 162, 133, 141, 124, 112, 128, + 130, 115, 110, 140, 107, 155, 134, 131, 156, 137, + 122, 106, 116, 127, 118, 161, 150, 170, 167, 152, + 139, 177, 203, 176, 155, 139, 130, 128, 129, 132, + 137, 119, 125, 103, 110, 123, 107, 120, 108, 101, + 113, 107, 160, 154, 160, 166, 169, 176, 168, 156, + 115, 90, 65, 115, 115, 104, 120, 112, 109, 124, + 131, 123, 100, 109, 185, 158, 141, 132, 116, 119, + 139, 130, 119, 156, 124, 138, 127, 116, 141, 128, + 133, 118, 115, 180, 149, 151, 135, 130, 147, 129, + 117, 90, 80, 119, 124, 128, 132, 130, 128, 135, + 112, 97, 142, 161, 167, 165, 154, 142, 136, 135, + 118, 141, 193, 172, 157, 152, 148, 145, 146, 141, + 125, 147, 165, 166, 149, 133, 123, 122, 128, 131, + 128, 193, 177, 174, 182, 186, 197, 193, 191, 173, + 124, 144, 162, 133, 113, 113, 123, 128, 129, 130, + 117, 98, 121, 122, 137, 132, 110, 97, 111, 130, + 128, 176, 151, 125, 126, 134, 130, 121, 127, 130, + 122, 151, 142, 111, 106, 121, 126, 126, 130, 134, + 148, 167, 186, 153, 129, 122, 124, 128, 130, 128, + 148, 172, 206, 178, 171, 182, 169, 180, 172, 156, + 133, 164, 174, 160, 155, 163, 163, 172, 169, 158, + 132, 150, 147, 142, 152, 140, 140, 140, 134, 135, + 137, 158, 167, 172, 163, 153, 169, 158, 146, 147, + 150, 161, 162, 172, 153, 133, 140, 144, 136, 135, + 109, 84, 101, 120, 129, 134, 133, 136, 137, 143, + 112, 114, 157, 147, 141, 136, 135, 133, 135, 138, + 121, 154, 161, 150, 149, 154, 151, 144, 146, 144, + 111, 117, 125, 125, 130, 131, 135, 137, 143, 148, + 121, 141, 146, 131, 138, 126, 118, 111, 119, 130, + 120, 135, 145, 121, 140, 134, 138, 137, 131, 134, + 115, 137, 132, 137, 139, 138, 138, 139, 145, 149, + 131, 149, 147, 133, 132, 126, 131, 134, 130, 133, + 110, 98, 84, 141, 107, 169, 169, 123, 125, 126, + 118, 210, 98, 126, 132, 138, 128, 139, 156, 157, + 140, 142, 129, 95, 192, 178, 182, 186, 183, 159, + 135, 134, 144, 124, 100, 228, 203, 161, 122, 104, + 139, 159, 134, 161, 121, 126, 192, 152, 218, 180, + 132, 132, 119, 99, 96, 97, 80, 53, 134, 143, + 102, 114, 133, 114, 127, 83, 77, 126, 85, 107, + 110, 114, 194, 186, 139, 116, 147, 104, 129, 138, + 126, 133, 109, 144, 115, 45, 130, 97, 159, 155, + 157, 162, 189, 185, 168, 163, 151, 151, 142, 135, + 144, 147, 120, 74, 192, 186, 149, 118, 71, 84, + 143, 156, 133, 178, 168, 107, 119, 149, 105, 112, + 182, 184, 158, 118, 118, 148, 128, 177, 171, 152, + 139, 135, 126, 209, 171, 150, 123, 100, 190, 158, + 166, 97, 136, 123, 136, 139, 128, 138, 126, 121, + 132, 131, 128, 95, 60, 168, 127, 140, 208, 161, + 109, 102, 119, 162, 150, 137, 107, 200, 156, 136, + 136, 128, 103, 95, 74, 91, 220, 173, 152, 138, + 139, 129, 140, 136, 122, 82, 180, 115, 53, 90, + 121, 107, 99, 148, 116, 139, 100, 63, 191, 155, + 130, 129, 163, 155, 98, 175, 95, 151, 127, 107, + 124, 124, 116, 88, 71, 164, 148, 96, 57, 89, + 125, 117, 77, 63, 162, 144, 113, 109, 137, 134, + 134, 130, 149, 174, 158, 158, 130, 81, 28, 67, + 142, 139, 129, 100, 194, 134, 68, 175, 131, 103, + 136, 132, 122, 96, 119, 82, 115, 249, 215, 168, + 125, 139, 199, 96, 146, 123, 136, 179, 142, 137, + 181, 166, 106, 86, 122, 106, 123, 131, 106, 119, + 129, 189, 188, 147, 126, 110, 101, 114, 147, 136, + 132, 106, 72, 175, 148, 99, 130, 153, 125, 136, + 123, 119, 147, 170, 157, 126, 209, 188, 158, 152, + 101, 89, 142, 131, 161, 150, 148, 124, 89, 119, + 141, 137, 131, 103, 81, 85, 64, 175, 129, 121, + 137, 144, 142, 145, 119, 205, 148, 80, 165, 138, + 143, 137, 167, 165, 148, 149, 110, 234, 217, 170, + 167, 152, 75, 140, 155, 155, 175, 129, 136, 134, + 136, 152, 161, 131, 140, 121, 91, 79, 255, 209, + 132, 147, 120, 114, 177, 128, 110, 61, 89, 131, + 125, 127, 93, 87, 167, 115, 186, 162, 107, 106, + 134, 162, 151, 100, 79, 67, 151, 116, 130, 142, + 162, 153, 155, 143, 122, 85, 202, 187, 135, 125, + 158, 155, 103, 129, 74, 149, 130, 98, 129, 126, + 148, 152, 153, 133, 118, 94, 80, 70, 47, 90, + 124, 118, 143, 184, 158, 126, 70, 82, 111, 113, + 126, 135, 175, 141, 203, 166, 123, 123, 134, 133, + 113, 111, 128, 76, 128, 177, 151, 178, 134, 125, + 120, 120, 193, 106, 98, 134, 101, 86, 101, 114, + 136, 127, 134, 196, 86, 105, 145, 128, 119, 137, + 138, 126, 230, 161, 141, 128, 129, 136, 88, 83, + 103, 118, 178, 123, 89, 101, 161, 173, 165, 147, + 130, 123, 171, 158, 131, 81, 50, 177, 162, 136, + 125, 115, 82, 173, 195, 168, 130, 112, 112, 121, + 152, 148, 167, 87, 82, 161, 142, 147, 98, 89, + 168, 138, 97, 157, 132, 114, 74, 126, 161, 141, + 135, 123, 68, 137, 124, 118, 112, 92, 65, 96, + 191, 181, 161, 151, 141, 145, 129, 102, 97, 111, + 144, 128, 55, 128, 115, 155, 129, 184, 167, 147, + 131, 141, 125, 33, 127, 111, 127, 131, 125, 130, + 137, 130, 121, 195, 172, 177, 176, 149, 98, 97, + 126, 106, 168, 159, 144, 185, 156, 151, 182, 158, + 123, 93, 110, 116, 98, 99, 125, 136, 139, 148, + 79, 112, 149, 128, 147, 136, 118, 105, 166, 152, + 117, 115, 92, 128, 148, 132, 170, 143, 226, 190, + 122, 192, 165, 121, 143, 144, 174, 124, 113, 124, + 122, 135, 34, 93, 118, 111, 111, 136, 123, 116, + 99, 195, 139, 99, 114, 102, 96, 108, 111, 112, + 113, 129, 172, 137, 105, 139, 154, 86, 113, 108, + 132, 79, 63, 120, 93, 162, 90, 103, 94, 95, + 117, 127, 104, 100, 142, 129, 93, 27, 196, 153, + 113, 91, 101, 90, 84, 68, 138, 38, 118, 148, + 87, 103, 125, 109, 96, 152, 100, 56, 31, 62, + 176, 129, 124, 115, 103, 92, 100, 121, 130, 125, + 128, 71, 82, 71, 152, 85, 107, 116, 138, 133, + 103, 116, 139, 144, 72, 37, 118, 141, 109, 95, + 86, 92, 121, 167, 156, 104, 92, 91, 122, 114, + 89, 61, 172, 128, 95, 103, 84, 101, 88, 84, + 116, 125, 108, 62, 74, 108, 160, 143, 189, 164, + 91, 115, 144, 43, 116, 79, 106, 108, 74, 83, + 87, 90, 61, 71, 76, 76, 95, 130, 89, 94, + 114, 107, 101, 145, 161, 147, 143, 163, 147, 129, + 101, 73, 111, 108, 93, 104, 186, 141, 99, 89, + 112, 126, 111, 113, 152, 41, 159, 115, 131, 124, + 117, 101, 115, 130, 124, 87, 59, 177, 63, 85, + 109, 116, 103, 68, 145, 132, 29, 119, 96, 89, + 117, 90, 181, 103, 101, 111, 97, 96, 199, 171, + 113, 120, 93, 119, 101, 64, 56, 55, 63, 90, + 105, 101, 86, 45, 136, 179, 142, 102, 115, 114, + 113, 108, 121, 84, 23, 125, 76, 102, 119, 107, + 120, 104, 73, 177, 83, 114, 128, 85, 152, 126, + 137, 115, 149, 109, 163, 133, 110, 98, 54, 61, + 95, 111, 135, 103, 88, 164, 115, 187, 122, 98, + 129, 132, 95, 86, 71, 119, 146, 111, 38, 67, + 102, 100, 66, 148, 137, 103, 145, 95, 35, 85, + 44, 136, 102, 111, 108, 115, 136, 105, 120, 110, + 108, 147, 112, 169, 116, 146, 81, 120, 94, 84, + 93, 97, 90, 119, 102, 91, 48, 147, 204, 151, + 148, 160, 144, 131, 144, 175, 158, 133, 212, 163, + 172, 152, 151, 112, 148, 151, 145, 179, 160, 124, + 164, 164, 167, 161, 141, 120, 131, 141, 198, 177, + 169, 156, 146, 156, 124, 185, 164, 195, 181, 193, + 201, 147, 148, 168, 165, 159, 162, 148, 150, 148, + 146, 157, 158, 149, 164, 129, 160, 214, 174, 166, + 154, 176, 146, 141, 155, 140, 140, 169, 106, 155, + 166, 162, 134, 193, 157, 155, 146, 196, 171, 107, + 177, 174, 163, 155, 147, 203, 162, 146, 150, 83, + 157, 170, 180, 178, 159, 157, 151, 117, 115, 183, + 170, 180, 174, 150, 177, 173, 136, 181, 196, 184, + 164, 168, 165, 148, 175, 168, 209, 189, 159, 114, + 157, 158, 141, 168, 170, 139, 175, 128, 151, 39, + 128, 154, 159, 161, 148, 180, 131, 165, 159, 131, + 163, 150, 174, 178, 178, 198, 172, 138, 184, 191, + 143, 164, 161, 163, 210, 171, 155, 168, 150, 116, + 182, 170, 145, 152, 141, 139, 191, 149, 160, 202, + 145, 169, 145, 181, 148, 183, 197, 165, 146, 171, + 161, 153, 157, 170, 164, 149, 183, 167, 246, 235, + 162, 144, 170, 152, 173, 150, 113, 135, 156, 154, + 158, 148, 178, 159, 161, 114, 180, 156, 116, 163, + 164, 161, 122, 164, 164, 183, 135, 135, 144, 182, + 160, 147, 163, 152, 169, 185, 159, 177, 99, 211, + 168, 167, 215, 170, 150, 157, 154, 176, 154, 143, + 163, 117, 178, 160, 163, 165, 164, 166, 174, 136, + 159, 169, 152, 123, 199, 149, 169, 140, 159, 208, + 155, 161, 186, 122, 134, 167, 171, 145, 148, 176, + 148, 137, 114, 160, 166, 153, 162, 156, 164, 172, + 155, 148, 155, 182, 114, 150, 157, 154, 140, 159, + 166, 160, 169, 206, 182, 145, 157, 165, 147, 202, + 131, 154, 193, 162, 162, 149, 167, 157, 191, 188, + 149, 205, 147, 166, 150, 150, 159, 153, 171, 160 +}; + +static const uint8_t wmavoice_dq_lsp16i1[0x640] = { + 142, 121, 141, 112, 99, 119, 92, 122, 183, 155, + 122, 98, 75, 78, 85, 101, 108, 134, 128, 123, + 115, 90, 79, 58, 73, 127, 106, 60, 97, 107, + 141, 163, 130, 123, 136, 156, 201, 189, 204, 206, + 140, 116, 69, 60, 117, 123, 106, 124, 91, 63, + 150, 144, 110, 80, 63, 112, 80, 70, 76, 63, + 114, 86, 147, 165, 137, 125, 120, 140, 115, 101, + 101, 99, 166, 158, 158, 104, 126, 131, 134, 143, + 121, 102, 73, 36, 83, 132, 113, 76, 38, 20, + 132, 111, 78, 73, 51, 131, 108, 131, 105, 80, + 148, 138, 101, 65, 47, 115, 86, 50, 124, 129, + 116, 89, 85, 87, 64, 111, 74, 39, 115, 113, + 112, 83, 75, 122, 127, 114, 91, 106, 125, 130, + 131, 108, 79, 136, 112, 110, 147, 164, 144, 124, + 121, 236, 218, 190, 168, 106, 101, 160, 172, 191, + 113, 138, 102, 91, 109, 100, 71, 85, 112, 119, + 121, 96, 51, 64, 126, 135, 114, 76, 34, 104, + 145, 127, 90, 56, 131, 142, 131, 92, 123, 102, + 128, 105, 63, 24, 95, 115, 87, 49, 156, 174, + 123, 105, 88, 58, 55, 141, 119, 99, 75, 81, + 137, 117, 114, 80, 56, 119, 91, 106, 166, 135, + 114, 84, 38, 93, 116, 129, 103, 97, 87, 97, + 115, 184, 193, 173, 157, 117, 88, 114, 151, 121, + 126, 111, 75, 129, 133, 130, 107, 71, 115, 92, + 128, 108, 120, 100, 97, 111, 80, 119, 122, 91, + 114, 94, 149, 129, 136, 114, 88, 132, 110, 85, + 116, 99, 101, 71, 71, 110, 140, 142, 131, 110, + 122, 98, 83, 127, 100, 106, 130, 123, 114, 103, + 113, 87, 140, 116, 113, 140, 161, 171, 145, 129, + 115, 178, 158, 161, 160, 118, 195, 209, 221, 228, + 99, 83, 140, 134, 140, 127, 186, 168, 187, 187, + 107, 114, 100, 111, 111, 104, 130, 131, 116, 128, + 128, 104, 64, 18, 49, 126, 107, 69, 56, 153, + 154, 142, 110, 113, 89, 120, 93, 73, 190, 172, + 119, 96, 57, 21, 60, 126, 122, 81, 99, 117, + 159, 141, 108, 88, 120, 144, 125, 89, 44, 94, + 147, 131, 93, 81, 61, 133, 113, 85, 47, 62, + 123, 121, 87, 53, 90, 120, 94, 76, 70, 48, + 125, 103, 93, 64, 35, 140, 129, 88, 47, 30, + 127, 104, 58, 51, 103, 124, 100, 102, 76, 47, + 115, 87, 54, 46, 77, 182, 218, 174, 163, 145, + 140, 126, 89, 105, 82, 125, 119, 101, 69, 58, + 125, 107, 172, 145, 128, 138, 113, 109, 92, 90, + 117, 93, 83, 93, 132, 125, 102, 67, 148, 161, + 131, 110, 96, 99, 74, 119, 92, 54, 84, 81, + 110, 152, 120, 106, 131, 108, 74, 68, 99, 107, + 121, 97, 120, 101, 78, 132, 110, 127, 164, 134, + 111, 159, 204, 189, 178, 158, 183, 146, 144, 137, + 123, 106, 136, 108, 135, 117, 91, 163, 135, 113, + 119, 177, 134, 122, 121, 132, 109, 157, 131, 113, + 115, 87, 87, 100, 92, 120, 95, 59, 146, 139, + 129, 101, 135, 122, 101, 119, 100, 112, 88, 99, + 118, 90, 123, 125, 107, 121, 98, 73, 104, 80, + 112, 79, 86, 122, 96, 104, 81, 107, 90, 93, + 112, 150, 140, 109, 115, 113, 86, 73, 76, 112, + 130, 111, 101, 112, 84, 123, 97, 63, 134, 115, + 109, 77, 128, 141, 119, 125, 101, 108, 147, 119, + 134, 149, 150, 127, 115, 136, 244, 220, 210, 189, + 105, 138, 171, 156, 174, 117, 162, 133, 146, 141, + 115, 93, 119, 98, 122, 114, 106, 154, 145, 162, + 107, 131, 189, 165, 152, 101, 107, 129, 114, 139, + 116, 186, 186, 161, 180, 100, 89, 137, 116, 116, + 106, 130, 194, 196, 207, 110, 156, 157, 138, 149, + 102, 93, 159, 138, 120, 109, 132, 105, 122, 135, + 148, 128, 85, 76, 102, 168, 154, 141, 117, 100, + 125, 106, 62, 101, 146, 124, 102, 65, 25, 15, + 120, 94, 46, 21, 94, 149, 128, 115, 85, 92, + 119, 93, 70, 52, 30, 162, 151, 123, 91, 80, + 126, 112, 84, 47, 33, 138, 114, 73, 60, 87, + 126, 211, 174, 158, 143, 129, 106, 65, 31, 133, + 119, 95, 52, 99, 173, 123, 96, 119, 206, 178, + 127, 104, 60, 61, 67, 152, 136, 104, 63, 83, + 133, 130, 92, 64, 45, 120, 96, 53, 30, 130, + 128, 103, 74, 59, 35, 135, 114, 77, 30, 57, + 108, 130, 123, 90, 87, 143, 125, 93, 54, 60, + 133, 118, 79, 87, 95, 115, 89, 111, 88, 65, + 124, 102, 70, 40, 47, 148, 131, 123, 130, 104, + 127, 109, 87, 56, 121, 147, 123, 121, 107, 85, + 178, 237, 200, 193, 170, 139, 118, 100, 75, 110, + 133, 121, 81, 73, 68, 120, 195, 157, 141, 131, + 127, 102, 107, 88, 60, 136, 113, 100, 69, 45, + 128, 105, 93, 77, 67, 131, 116, 149, 184, 156, + 115, 85, 35, 45, 112, 128, 108, 68, 73, 111, + 118, 93, 187, 162, 139, 136, 115, 84, 57, 37, + 131, 133, 125, 98, 85, 138, 115, 92, 86, 61, + 116, 96, 70, 52, 110, 115, 109, 135, 104, 88, + 136, 159, 122, 109, 115, 122, 110, 98, 70, 95, + 112, 81, 68, 85, 90, 124, 101, 87, 56, 89, + 109, 82, 98, 100, 115, 124, 102, 76, 88, 63, + 111, 78, 42, 78, 102, 110, 71, 64, 131, 111, + 125, 104, 107, 87, 123, 129, 131, 99, 85, 68, + 147, 137, 102, 99, 75, 120, 155, 142, 109, 91, + 132, 109, 131, 141, 113, 136, 119, 94, 152, 128, + 127, 102, 79, 159, 134, 111, 78, 98, 109, 80, + 115, 86, 51, 63, 103, 116, 86, 170, 149, 123, + 135, 178, 159, 125, 114, 113, 189, 226, 203, 202, + 140, 117, 116, 94, 70, 128, 103, 94, 174, 149, + 118, 98, 83, 84, 106, 115, 157, 120, 94, 95, + 131, 112, 75, 96, 74, 121, 97, 144, 117, 95, + 120, 90, 140, 138, 110, 119, 93, 55, 92, 114, + 114, 87, 151, 125, 100, 111, 82, 83, 160, 139, + 114, 86, 56, 90, 138, 104, 109, 101, 77, 118, + 140, 142, 143, 148, 126, 121, 102, 129, 107, 111, + 113, 79, 58, 111, 91, 120, 94, 63, 115, 98, + 121, 94, 99, 97, 78, 120, 92, 68, 173, 148, + 122, 114, 109, 87, 82, 132, 229, 192, 176, 155, + 137, 116, 123, 97, 115, 132, 115, 86, 120, 95, + 135, 116, 101, 136, 108, 109, 74, 100, 125, 115, + 112, 158, 144, 124, 134, 114, 83, 73, 147, 120, + 120, 104, 150, 122, 116, 110, 104, 192, 183, 174, + 134, 112, 116, 120, 93, 121, 101, 93, 110, 90, + 121, 93, 147, 152, 122, 115, 153, 171, 161, 142, + 123, 95, 116, 114, 93, 113, 89, 96, 77, 93, + 113, 174, 180, 143, 138, 116, 86, 100, 135, 106, + 103, 121, 149, 115, 103, 121, 95, 82, 149, 121, + 117, 92, 93, 111, 114, 123, 209, 196, 193, 183, + 125, 102, 107, 130, 104, 115, 91, 113, 103, 99, + 114, 86, 68, 108, 110, 111, 159, 162, 125, 113, + 125, 235, 234, 225, 214, 99, 74, 118, 121, 127, + 104, 123, 158, 128, 127, 113, 96, 116, 136, 158, + 100, 80, 138, 155, 166, 118, 143, 115, 125, 114, + 119, 137, 133, 136, 139, 151, 188, 172, 174, 173, + 138, 161, 158, 158, 155, 121, 198, 194, 211, 202, + 100, 90, 112, 110, 122, 100, 91, 122, 128, 135, + 101, 109, 127, 101, 114, 105, 126, 160, 147, 143, + 109, 138, 142, 158, 163, 113, 174, 185, 188, 206, + 112, 154, 166, 176, 183, 101, 108, 140, 140, 143, + 106, 135, 130, 137, 126, 103, 114, 115, 128, 126, + 107, 86, 21, 115, 75, 117, 139, 97, 65, 105, + 64, 191, 101, 106, 139, 107, 98, 218, 132, 104, + 73, 136, 165, 84, 118, 150, 111, 58, 130, 107, + 99, 136, 132, 56, 52, 102, 136, 69, 78, 163, + 85, 173, 148, 138, 85, 69, 106, 128, 133, 155, + 104, 91, 149, 56, 104, 103, 101, 172, 96, 57, + 104, 97, 125, 197, 166, 107, 169, 47, 120, 103, + 150, 89, 99, 139, 162, 101, 69, 137, 158, 126, + 191, 173, 127, 79, 155, 51, 131, 112, 86, 74, + 135, 61, 114, 81, 125, 117, 112, 72, 175, 72, + 127, 123, 142, 132, 78, 116, 158, 111, 121, 143, + 108, 102, 89, 20, 194, 81, 99, 107, 65, 150, + 103, 78, 91, 69, 96, 104, 116, 116, 103, 105, + 107, 117, 110, 130, 28, 88, 103, 62, 72, 85, + 125, 126, 141, 126, 178, 121, 102, 57, 46, 124, + 97, 91, 89, 138, 95, 98, 143, 99, 169, 123, + 140, 119, 113, 82, 140, 118, 112, 91, 92, 241, + 134, 89, 95, 112, 78, 167, 140, 145, 121, 100, + 109, 205, 144, 91, 100, 113, 103, 142, 175, 95, + 117, 121, 35, 121, 127, 159, 129, 85, 64, 75, + 116, 98, 103, 127, 129, 66, 68, 110, 96, 86, + 79, 100, 156, 133, 92, 135, 96, 164, 132, 121, + 93, 163, 134, 91, 208, 104, 77, 126, 116, 58, + 136, 118, 132, 81, 61, 73, 115, 66, 129, 123, + 111, 85, 42, 178, 134, 108, 132, 159, 45, 157, + 105, 164, 100, 94, 60, 96, 57, 154, 105, 102, + 103, 114, 96, 12, 91, 119, 115, 67, 92, 64, + 94, 61, 106, 106, 165, 105, 94, 98, 68, 30, + 146, 130, 107, 173, 140, 102, 90, 163, 106, 184, + 100, 53, 68, 131, 92, 105, 111, 68, 153, 186, + 101, 82, 48, 99, 147, 122, 136, 176, 96, 96, + 104, 132, 167, 149, 136, 138, 144, 97, 120, 92 +}; + +static const uint8_t wmavoice_dq_lsp16i2[0x3c0] = { + 23, 12, 107, 119, 110, 205, 214, 212, 208, 201, + 102, 95, 69, 117, 107, 118, 123, 118, 123, 121, + 82, 58, 83, 95, 84, 139, 145, 153, 161, 169, + 102, 100, 138, 121, 101, 129, 130, 138, 150, 139, + 76, 104, 86, 112, 133, 113, 91, 63, 73, 129, + 199, 193, 182, 181, 172, 119, 101, 83, 94, 76, + 161, 157, 152, 157, 158, 110, 90, 121, 96, 79, + 124, 107, 114, 88, 73, 152, 137, 121, 107, 99, + 57, 50, 100, 81, 74, 115, 96, 72, 49, 69, + 83, 68, 40, 53, 103, 36, 131, 107, 84, 64, + 236, 245, 242, 231, 213, 95, 109, 88, 69, 110, + 228, 221, 204, 182, 170, 129, 110, 97, 118, 104, + 98, 76, 98, 75, 61, 93, 77, 113, 91, 72, + 116, 94, 106, 134, 118, 177, 188, 169, 162, 153, + 163, 149, 131, 131, 132, 177, 163, 173, 168, 158, + 113, 131, 107, 113, 100, 132, 143, 131, 134, 142, + 45, 36, 121, 113, 102, 43, 95, 84, 67, 56, + 76, 82, 68, 48, 33, 55, 58, 59, 43, 65, + 66, 85, 66, 81, 94, 102, 82, 54, 33, 94, + 113, 111, 89, 60, 34, 138, 120, 101, 101, 86, + 88, 73, 55, 114, 115, 92, 74, 93, 77, 123, + 90, 117, 99, 79, 59, 97, 75, 97, 122, 104, + 233, 237, 227, 208, 190, 209, 230, 233, 240, 241, + 195, 197, 188, 167, 147, 204, 185, 168, 162, 157, + 142, 124, 119, 123, 106, 117, 110, 81, 121, 123, + 74, 116, 124, 119, 120, 178, 168, 146, 132, 125, + 102, 104, 105, 110, 114, 104, 82, 78, 100, 86, + 120, 102, 105, 93, 143, 127, 108, 128, 106, 88, + 177, 189, 203, 207, 215, 101, 131, 119, 95, 73, + 149, 139, 135, 147, 153, 160, 167, 165, 174, 177, + 120, 109, 134, 140, 145, 131, 130, 142, 139, 161, + 143, 158, 148, 145, 145, 123, 142, 132, 116, 102, + 40, 23, 79, 82, 84, 26, 83, 141, 130, 122, + 65, 46, 43, 89, 86, 28, 75, 80, 79, 98, + 84, 65, 47, 26, 44, 49, 112, 101, 100, 94, + 88, 76, 75, 48, 82, 104, 100, 75, 45, 15, + 99, 83, 63, 34, 30, 66, 55, 94, 118, 113, + 122, 106, 91, 68, 60, 135, 122, 104, 77, 59, + 82, 102, 84, 62, 46, 92, 74, 55, 82, 71, + 145, 134, 118, 93, 75, 79, 62, 83, 65, 55, + 91, 94, 64, 70, 98, 89, 117, 110, 87, 97, + 210, 223, 225, 223, 213, 83, 103, 86, 101, 85, + 126, 106, 81, 79, 105, 216, 219, 217, 199, 179, + 86, 78, 115, 138, 135, 102, 84, 87, 59, 46, + 219, 206, 184, 167, 158, 201, 188, 165, 145, 135, + 87, 113, 142, 152, 155, 190, 170, 153, 149, 146, + 205, 208, 201, 185, 167, 84, 73, 124, 104, 96, + 76, 88, 99, 74, 80, 110, 125, 122, 99, 112, + 108, 84, 70, 130, 137, 161, 152, 136, 119, 105, + 110, 91, 101, 74, 96, 111, 101, 93, 153, 149, + 133, 124, 102, 97, 120, 101, 93, 75, 81, 64, + 111, 94, 107, 79, 58, 188, 206, 215, 221, 232, + 163, 175, 165, 150, 136, 103, 106, 123, 133, 132, + 168, 184, 191, 183, 170, 110, 117, 90, 98, 93, + 104, 87, 122, 98, 127, 129, 110, 127, 113, 125, + 134, 118, 102, 140, 132, 186, 199, 202, 198, 188, + 149, 147, 175, 185, 186, 117, 93, 99, 112, 93, + 107, 138, 138, 129, 128, 96, 129, 104, 118, 134, + 145, 136, 115, 121, 129, 138, 155, 148, 134, 120, + 170, 151, 150, 145, 138, 168, 173, 185, 194, 200, + 144, 159, 172, 168, 156, 121, 121, 138, 173, 168, + 126, 111, 140, 139, 117, 149, 133, 142, 137, 130, + 143, 139, 158, 158, 146, 119, 128, 121, 132, 145, + 122, 136, 159, 153, 141, 133, 133, 130, 129, 126, + 120, 76, 50, 149, 109, 92, 155, 118, 90, 66, + 132, 117, 87, 156, 117, 119, 102, 44, 83, 91, + 109, 73, 106, 84, 29, 55, 130, 112, 81, 241, + 75, 40, 91, 89, 67, 112, 90, 149, 81, 72, + 128, 90, 71, 28, 160, 73, 157, 123, 143, 108, + 63, 88, 70, 81, 97, 75, 111, 149, 113, 96, + 78, 104, 83, 179, 95, 105, 106, 65, 130, 66, + 51, 118, 92, 53, 68, 105, 75, 176, 151, 115, + 94, 75, 68, 95, 220, 103, 125, 105, 43, 95, + 39, 114, 65, 145, 135, 33, 142, 138, 103, 52, + 82, 85, 117, 110, 67, 102, 74, 42, 62, 118, + 144, 121, 82, 57, 102, 67, 75, 44, 129, 96, + 75, 63, 88, 48, 116, 135, 94, 85, 102, 66, + 122, 77, 105, 122, 152, 120, 56, 90, 83, 100, + 90, 128, 63, 80, 103, 126, 117, 103, 80, 193, + 42, 73, 117, 93, 91, 95, 128, 100, 128, 162, + 70, 120, 126, 73, 123, 99, 99, 91, 75, 135, + 81, 125, 111, 77, 13, 94, 78, 85, 187, 157, + 11, 143, 109, 99, 119, 53, 141, 82, 122, 68, + 132, 89, 136, 119, 88, 75, 49, 174, 119, 70, + 138, 121, 108, 78, 52, 104, 90, 96, 93, 93, + 114, 90, 78, 46, 58, 62, 114, 69, 44, 162, + 103, 58, 98, 141, 83, 137, 95, 119, 73, 111, + 81, 46, 126, 111, 123, 107, 117, 122, 121, 54, + 106, 104, 59, 110, 148, 97, 155, 97, 83, 133, + 97, 71, 57, 91, 58, 52, 79, 127, 152, 109, + 96, 92, 145, 107, 149, 102, 61, 125, 61, 170, + 56, 89, 77, 106, 38, 147, 96, 77, 105, 123, + 85, 83, 117, 63, 69, 126, 133, 93, 107, 92, + 77, 115, 95, 111, 103, 61, 87, 103, 98, 155, + 94, 111, 80, 78, 54, 117, 128, 130, 99, 109, + 106, 99, 113, 133, 115, 89, 65, 74, 112, 127 +}; + +static const uint8_t wmavoice_dq_lsp16i3[0x300] = { + 70, 100, 121, 129, 132, 132, 201, 188, 165, 145, 144, 136, + 112, 127, 116, 125, 130, 129, 124, 135, 135, 146, 129, 128, + 162, 158, 144, 151, 135, 129, 103, 86, 111, 113, 112, 122, + 90, 139, 129, 117, 126, 129, 142, 145, 167, 147, 124, 124, + 230, 209, 189, 175, 156, 141, 64, 80, 86, 108, 121, 129, + 44, 79, 115, 113, 115, 128, 133, 106, 79, 109, 125, 127, + 171, 156, 132, 109, 103, 115, 106, 70, 93, 145, 141, 128, + 148, 125, 122, 107, 110, 117, 146, 145, 128, 110, 98, 111, + 237, 212, 185, 156, 139, 133, 84, 55, 26, 77, 114, 127, + 172, 170, 171, 168, 162, 143, 82, 82, 76, 70, 104, 126, + 17, 95, 109, 111, 120, 132, 81, 74, 57, 126, 141, 131, + 110, 127, 162, 148, 129, 123, 177, 172, 155, 151, 145, 134, + 144, 123, 90, 66, 109, 130, 82, 127, 103, 123, 132, 131, + 127, 97, 97, 142, 140, 128, 159, 134, 136, 123, 113, 117, + 131, 140, 154, 169, 158, 134, 96, 109, 150, 122, 105, 120, + 120, 150, 152, 122, 119, 125, 123, 126, 124, 107, 100, 113, + 248, 233, 216, 189, 160, 142, 58, 24, 13, 77, 111, 127, + 183, 189, 182, 157, 140, 131, 96, 83, 59, 43, 73, 119, + 222, 196, 171, 146, 129, 128, 32, 13, 53, 101, 114, 127, + 119, 101, 70, 70, 110, 127, 77, 86, 161, 148, 130, 118, + 199, 183, 170, 167, 156, 141, 30, 115, 142, 133, 131, 130, + 101, 103, 181, 176, 152, 126, 66, 44, 73, 94, 111, 128, + 150, 122, 100, 101, 104, 118, 61, 110, 87, 76, 93, 125, + 190, 170, 150, 134, 135, 129, 112, 89, 63, 123, 141, 132, + 175, 154, 136, 142, 140, 132, 117, 143, 129, 128, 136, 132, + 168, 142, 112, 113, 128, 128, 155, 169, 159, 144, 139, 131, + 61, 136, 144, 124, 112, 123, 86, 81, 104, 121, 129, 130, + 160, 127, 118, 150, 151, 134, 126, 115, 121, 132, 134, 131, + 137, 148, 144, 139, 140, 134, 106, 102, 105, 90, 87, 113, + 134, 129, 128, 121, 121, 123, 153, 151, 129, 139, 142, 134, + 150, 142, 141, 148, 149, 141, 100, 121, 133, 147, 150, 134, + 163, 158, 147, 132, 141, 132, 142, 127, 141, 136, 136, 132, + 232, 218, 205, 189, 169, 146, 243, 224, 201, 171, 147, 138, + 224, 196, 169, 162, 154, 140, 51, 20, 59, 111, 121, 128, + 203, 197, 193, 177, 162, 145, 75, 40, 47, 122, 130, 129, + 102, 77, 47, 83, 121, 129, 111, 108, 84, 56, 63, 114, + 211, 181, 154, 137, 126, 125, 213, 198, 186, 162, 144, 138, + 41, 45, 90, 110, 118, 130, 83, 63, 130, 164, 153, 128, + 195, 167, 142, 123, 113, 119, 19, 42, 105, 113, 120, 132, + 50, 63, 49, 64, 112, 128, 114, 90, 132, 171, 162, 134, + 129, 128, 107, 83, 74, 110, 50, 116, 109, 120, 128, 132, + 94, 59, 73, 111, 117, 126, 197, 170, 166, 153, 138, 132, + 65, 48, 109, 133, 131, 128, 170, 163, 172, 158, 138, 130, + 66, 126, 147, 160, 151, 132, 42, 129, 117, 95, 91, 120, + 97, 165, 164, 142, 133, 125, 163, 142, 114, 88, 97, 122, + 104, 77, 142, 143, 128, 120, 136, 160, 188, 169, 149, 130, + 113, 83, 85, 102, 114, 125, 164, 169, 142, 120, 122, 124, + 98, 152, 132, 105, 92, 117, 42, 71, 125, 155, 151, 137, + 94, 105, 81, 107, 118, 126, 84, 56, 123, 117, 108, 122, + 174, 179, 166, 137, 118, 121, 130, 103, 147, 152, 134, 124, + 148, 127, 94, 117, 144, 134, 129, 106, 102, 95, 106, 118, + 147, 157, 153, 125, 103, 117, 155, 128, 113, 132, 120, 122, + 181, 151, 136, 126, 122, 122, 110, 111, 109, 108, 120, 124, + 97, 130, 103, 89, 107, 124, 179, 158, 158, 142, 131, 128, + 142, 111, 115, 122, 126, 125, 145, 145, 134, 115, 129, 128, + 130, 139, 112, 99, 121, 125, 79, 104, 119, 102, 105, 123, + 116, 121, 136, 125, 126, 127, 124, 100, 122, 119, 111, 119, + 159, 140, 139, 128, 138, 131, 105, 100, 116, 128, 135, 132, + 159, 142, 156, 147, 140, 134, 130, 150, 129, 126, 114, 120, + 138, 124, 146, 131, 109, 119, 93, 115, 125, 131, 125, 129, + 125, 121, 101, 119, 114, 120, 163, 154, 151, 153, 153, 139, + 166, 153, 150, 133, 119, 121, 159, 151, 128, 130, 122, 123, + 147, 154, 144, 133, 128, 127, 129, 131, 134, 140, 148, 138, + 138, 136, 120, 131, 135, 131, 150, 140, 137, 144, 129, 129 +}; + +static const uint8_t wmavoice_dq_lsp10r[0x1400] = { + 128, 128, 129, 129, 130, 130, 131, 130, 129, 129, + 134, 133, 127, 125, 136, 135, 135, 134, 173, 172, + 133, 139, 136, 165, 133, 176, 137, 159, 135, 152, + 147, 161, 147, 152, 149, 156, 146, 146, 140, 136, + 134, 135, 136, 140, 139, 155, 123, 133, 132, 142, + 132, 148, 143, 177, 124, 143, 123, 136, 126, 134, + 126, 125, 125, 124, 129, 128, 123, 123, 133, 133, + 116, 116, 121, 121, 121, 120, 129, 128, 131, 131, + 132, 133, 132, 129, 138, 124, 138, 124, 132, 100, + 135, 94, 149, 111, 152, 115, 150, 128, 141, 133, + 129, 129, 130, 129, 147, 145, 136, 137, 120, 122, + 120, 122, 127, 129, 104, 108, 113, 115, 124, 124, + 140, 139, 147, 145, 132, 130, 184, 177, 201, 196, + 170, 171, 160, 161, 145, 147, 137, 145, 131, 131, + 130, 130, 130, 130, 130, 130, 132, 134, 131, 132, + 131, 133, 141, 144, 142, 149, 84, 93, 103, 104, + 139, 139, 142, 140, 147, 147, 172, 165, 122, 121, + 98, 100, 101, 106, 112, 117, 122, 124, 124, 124, + 134, 133, 133, 133, 146, 142, 147, 145, 156, 156, + 143, 146, 119, 124, 129, 132, 151, 149, 136, 135, + 147, 148, 181, 180, 199, 188, 190, 173, 166, 161, + 147, 142, 153, 149, 154, 146, 150, 146, 138, 134, + 131, 135, 96, 136, 48, 138, 56, 131, 63, 124, + 85, 128, 103, 132, 117, 134, 120, 132, 125, 129, + 131, 130, 129, 128, 129, 128, 163, 168, 117, 120, + 121, 121, 136, 138, 131, 132, 135, 136, 131, 133, + 133, 133, 133, 134, 117, 118, 105, 109, 142, 151, + 144, 159, 131, 138, 121, 126, 123, 123, 121, 124, + 131, 131, 129, 129, 141, 140, 142, 134, 87, 90, + 109, 109, 130, 127, 139, 143, 133, 131, 127, 126, + 134, 135, 134, 136, 97, 98, 130, 132, 134, 137, + 115, 119, 125, 130, 107, 109, 119, 118, 126, 127, + 134, 135, 127, 132, 172, 203, 160, 196, 152, 179, + 152, 172, 148, 168, 153, 172, 145, 156, 137, 140, + 102, 116, 42, 56, 74, 61, 82, 70, 86, 78, + 101, 97, 104, 100, 115, 108, 116, 108, 123, 118, + 149, 143, 166, 129, 168, 96, 142, 95, 135, 98, + 117, 86, 116, 93, 121, 108, 119, 107, 121, 117, + 135, 135, 127, 138, 72, 132, 99, 136, 112, 147, + 120, 152, 136, 155, 138, 146, 140, 142, 134, 139, + 163, 145, 192, 130, 147, 124, 147, 125, 133, 125, + 127, 124, 128, 123, 129, 122, 130, 122, 130, 125, + 130, 137, 135, 180, 124, 133, 130, 129, 132, 133, + 124, 124, 131, 130, 132, 136, 126, 124, 127, 125, + 132, 132, 133, 133, 144, 140, 143, 142, 137, 135, + 143, 138, 152, 149, 221, 219, 158, 161, 143, 141, + 130, 129, 140, 135, 170, 145, 193, 156, 186, 152, + 167, 139, 151, 131, 142, 127, 134, 120, 131, 125, + 135, 133, 141, 125, 199, 109, 137, 126, 134, 123, + 130, 129, 132, 123, 128, 125, 122, 126, 125, 125, + 130, 128, 91, 89, 138, 135, 139, 134, 133, 129, + 132, 130, 125, 128, 136, 135, 129, 127, 126, 126, + 132, 131, 133, 131, 128, 120, 132, 126, 126, 119, + 134, 130, 131, 123, 104, 95, 140, 141, 136, 137, + 133, 133, 133, 134, 117, 98, 74, 49, 112, 111, + 123, 122, 126, 127, 131, 131, 127, 126, 128, 129, + 130, 131, 124, 127, 101, 107, 108, 109, 115, 115, + 100, 99, 130, 128, 134, 136, 125, 127, 128, 130, + 136, 137, 145, 150, 149, 164, 136, 151, 114, 111, + 124, 125, 143, 150, 162, 174, 158, 169, 136, 137, + 131, 131, 131, 131, 132, 133, 111, 110, 122, 121, + 136, 136, 134, 133, 131, 132, 127, 127, 125, 125, + 128, 129, 129, 130, 125, 127, 140, 140, 148, 149, + 133, 136, 146, 153, 110, 118, 127, 129, 128, 129, + 131, 133, 127, 131, 140, 161, 167, 224, 131, 139, + 136, 143, 135, 139, 138, 143, 149, 155, 141, 143, + 134, 132, 120, 111, 83, 83, 121, 126, 102, 107, + 112, 115, 97, 104, 120, 115, 129, 123, 122, 122, + 134, 135, 122, 131, 102, 124, 114, 119, 93, 103, + 78, 79, 67, 72, 66, 73, 78, 82, 103, 102, + 144, 135, 165, 139, 165, 129, 160, 126, 153, 127, + 161, 134, 160, 142, 160, 143, 148, 140, 138, 135, + 138, 95, 147, 54, 143, 78, 140, 112, 142, 113, + 140, 121, 135, 117, 135, 122, 136, 131, 131, 132, + 147, 159, 140, 156, 127, 81, 142, 128, 146, 127, + 144, 125, 146, 128, 149, 130, 144, 135, 133, 128, + 130, 131, 131, 131, 134, 139, 126, 134, 141, 154, + 168, 205, 153, 176, 148, 163, 147, 158, 141, 143, + 131, 135, 126, 146, 108, 157, 107, 156, 119, 146, + 100, 138, 104, 125, 119, 134, 101, 122, 113, 122, + 95, 133, 52, 140, 83, 136, 110, 133, 114, 131, + 123, 131, 133, 131, 138, 135, 132, 132, 127, 127, + 129, 128, 124, 122, 128, 126, 145, 170, 143, 172, + 141, 163, 143, 176, 138, 164, 139, 155, 135, 145, + 135, 136, 136, 127, 132, 76, 128, 76, 127, 63, + 125, 66, 123, 67, 120, 71, 124, 92, 122, 111, + 133, 133, 135, 136, 139, 140, 147, 147, 150, 144, + 156, 147, 150, 145, 154, 146, 120, 123, 123, 124, + 137, 133, 170, 141, 124, 124, 135, 134, 134, 135, + 132, 132, 129, 129, 130, 130, 136, 136, 130, 132, + 147, 159, 135, 158, 115, 146, 120, 148, 117, 136, + 115, 137, 113, 132, 133, 142, 140, 144, 132, 134, + 134, 135, 134, 137, 137, 147, 162, 178, 136, 147, + 134, 144, 123, 132, 111, 113, 113, 113, 124, 124, + 132, 131, 126, 126, 117, 114, 100, 95, 130, 125, + 157, 145, 164, 156, 163, 158, 145, 145, 133, 134, + 134, 134, 127, 126, 113, 102, 136, 130, 124, 122, + 143, 145, 127, 131, 135, 143, 133, 137, 132, 132, + 92, 94, 122, 125, 128, 129, 131, 130, 134, 135, + 132, 128, 129, 127, 132, 132, 131, 129, 127, 127, + 129, 129, 132, 131, 139, 131, 137, 132, 216, 178, + 146, 134, 147, 137, 151, 142, 148, 139, 144, 138, + 128, 127, 129, 129, 123, 131, 71, 91, 126, 128, + 130, 134, 117, 123, 125, 125, 135, 140, 129, 132, + 132, 132, 133, 134, 124, 130, 127, 133, 133, 138, + 142, 149, 135, 141, 145, 149, 154, 164, 135, 138, + 135, 135, 141, 142, 138, 137, 116, 96, 105, 86, + 127, 118, 128, 120, 124, 117, 125, 117, 125, 121, + 131, 131, 132, 134, 144, 145, 112, 112, 121, 123, + 113, 116, 121, 123, 139, 138, 128, 128, 131, 131, + 134, 132, 132, 132, 125, 128, 127, 130, 125, 131, + 120, 128, 90, 119, 68, 98, 99, 112, 115, 124, + 135, 135, 134, 134, 128, 129, 137, 137, 137, 138, + 110, 114, 129, 130, 144, 145, 123, 125, 129, 129, + 132, 133, 129, 130, 168, 187, 140, 149, 137, 144, + 129, 130, 129, 134, 133, 138, 118, 118, 122, 120, + 131, 130, 129, 128, 133, 133, 125, 125, 124, 123, + 181, 179, 129, 129, 131, 127, 139, 136, 130, 128, + 133, 133, 132, 132, 121, 120, 122, 119, 132, 129, + 129, 125, 107, 96, 136, 137, 150, 146, 135, 134, + 131, 131, 130, 130, 126, 123, 126, 123, 128, 125, + 130, 123, 134, 127, 183, 159, 143, 135, 137, 134, + 129, 129, 128, 128, 134, 133, 139, 138, 133, 132, + 129, 127, 154, 151, 150, 144, 146, 146, 141, 142, + 132, 132, 131, 131, 130, 130, 132, 133, 114, 115, + 132, 132, 122, 122, 132, 131, 115, 117, 120, 120, + 129, 129, 130, 130, 130, 129, 130, 131, 129, 131, + 130, 130, 129, 129, 133, 132, 143, 144, 91, 91, + 137, 136, 118, 107, 60, 45, 56, 49, 57, 52, + 60, 56, 71, 75, 77, 80, 92, 97, 106, 106, + 112, 131, 58, 121, 19, 65, 84, 101, 108, 122, + 121, 127, 112, 117, 106, 112, 117, 124, 126, 127, + 130, 129, 138, 133, 166, 155, 192, 179, 192, 177, + 208, 191, 204, 192, 186, 179, 163, 163, 138, 142, + 134, 134, 144, 142, 243, 236, 148, 146, 141, 137, + 145, 141, 151, 144, 147, 143, 135, 139, 134, 133, + 134, 128, 138, 88, 142, 10, 127, 76, 130, 96, + 129, 102, 128, 108, 123, 111, 127, 119, 127, 124, + 136, 136, 139, 139, 142, 140, 246, 241, 158, 167, + 143, 145, 146, 149, 143, 145, 148, 152, 133, 134, + 139, 135, 135, 136, 99, 137, 95, 133, 75, 138, + 67, 135, 73, 128, 83, 132, 96, 126, 115, 127, + 130, 132, 137, 136, 140, 135, 134, 130, 137, 131, + 159, 151, 215, 197, 181, 170, 160, 149, 150, 143, + 145, 148, 186, 207, 141, 147, 135, 137, 122, 122, + 126, 125, 128, 126, 127, 127, 134, 126, 131, 123, + 133, 133, 126, 122, 128, 122, 99, 93, 59, 60, + 82, 82, 106, 107, 119, 123, 124, 128, 128, 129, + 134, 137, 133, 139, 133, 136, 141, 132, 139, 122, + 142, 97, 130, 81, 128, 89, 129, 101, 125, 112, + 137, 140, 129, 148, 101, 159, 118, 180, 122, 178, + 120, 178, 116, 168, 118, 153, 127, 151, 126, 136, + 132, 134, 125, 126, 118, 105, 156, 124, 180, 132, + 163, 124, 148, 121, 131, 112, 127, 115, 125, 122, + 129, 131, 128, 129, 136, 134, 142, 141, 165, 158, + 203, 182, 141, 136, 132, 130, 135, 135, 130, 130, + 133, 133, 132, 132, 127, 126, 106, 105, 112, 110, + 106, 105, 80, 84, 100, 101, 122, 125, 126, 128, + 101, 109, 46, 59, 114, 112, 119, 119, 126, 121, + 129, 124, 128, 125, 125, 122, 123, 120, 125, 122, + 135, 134, 121, 134, 56, 139, 131, 145, 135, 138, + 136, 139, 126, 130, 122, 132, 126, 129, 124, 129, + 153, 169, 146, 179, 138, 139, 151, 143, 148, 138, + 153, 137, 142, 129, 144, 126, 140, 128, 133, 126, + 136, 134, 154, 149, 173, 157, 152, 144, 149, 141, + 137, 136, 127, 121, 123, 121, 121, 126, 120, 123, + 157, 143, 166, 135, 120, 122, 112, 118, 102, 118, + 111, 124, 134, 131, 141, 138, 135, 134, 126, 129, + 140, 123, 152, 76, 131, 116, 138, 136, 126, 134, + 130, 142, 126, 136, 120, 132, 126, 128, 124, 127, + 131, 138, 80, 147, 126, 138, 130, 140, 129, 134, + 133, 135, 131, 132, 126, 127, 127, 125, 125, 123, + 132, 132, 130, 132, 123, 130, 102, 102, 107, 110, + 116, 127, 132, 152, 142, 160, 143, 151, 142, 146, + 132, 132, 132, 132, 125, 126, 132, 140, 158, 199, + 135, 149, 134, 140, 135, 131, 129, 120, 127, 121, + 129, 130, 122, 123, 125, 124, 138, 138, 138, 135, + 140, 141, 101, 94, 105, 98, 121, 122, 127, 128, + 126, 127, 119, 121, 133, 156, 132, 159, 130, 148, + 137, 164, 127, 138, 130, 137, 135, 140, 126, 126, + 128, 129, 129, 129, 126, 124, 130, 128, 143, 138, + 149, 143, 185, 170, 129, 127, 138, 133, 138, 135, + 132, 134, 137, 144, 139, 183, 131, 145, 127, 128, + 128, 127, 128, 122, 129, 125, 145, 139, 135, 131, + 132, 133, 132, 130, 152, 96, 159, 85, 150, 105, + 154, 115, 143, 120, 138, 126, 134, 124, 130, 126, + 128, 127, 121, 123, 122, 123, 116, 125, 84, 87, + 133, 135, 129, 131, 123, 126, 133, 135, 131, 130, + 136, 134, 129, 119, 79, 63, 116, 116, 136, 133, + 133, 130, 140, 143, 127, 127, 124, 125, 127, 128, + 128, 126, 124, 120, 139, 128, 153, 134, 151, 134, + 174, 145, 159, 136, 165, 144, 171, 149, 143, 135, + 134, 134, 133, 133, 121, 119, 177, 162, 166, 154, + 127, 130, 132, 132, 136, 137, 142, 143, 138, 137, + 167, 151, 162, 142, 128, 136, 142, 148, 128, 143, + 145, 153, 140, 149, 132, 141, 128, 139, 127, 133, + 156, 169, 131, 129, 126, 120, 127, 125, 129, 120, + 131, 126, 126, 123, 124, 121, 122, 121, 123, 123, + 138, 140, 149, 156, 145, 152, 105, 102, 131, 126, + 151, 146, 147, 139, 144, 137, 143, 133, 135, 130, + 132, 130, 131, 129, 126, 130, 126, 129, 110, 135, + 115, 139, 108, 146, 105, 147, 121, 134, 124, 133, + 137, 137, 135, 134, 143, 142, 146, 146, 120, 121, + 139, 137, 133, 129, 149, 145, 139, 133, 130, 127, + 134, 134, 134, 134, 125, 124, 117, 119, 120, 113, + 84, 80, 122, 125, 108, 112, 97, 102, 118, 120, + 124, 123, 115, 116, 110, 111, 98, 97, 127, 124, + 129, 127, 120, 117, 114, 109, 106, 104, 116, 116, + 138, 138, 139, 141, 142, 146, 127, 125, 133, 130, + 134, 128, 134, 127, 116, 91, 105, 84, 114, 106, + 128, 128, 126, 126, 131, 137, 126, 129, 133, 139, + 134, 145, 132, 143, 150, 192, 131, 142, 138, 141, + 132, 130, 132, 130, 149, 138, 196, 152, 137, 125, + 134, 125, 139, 128, 133, 125, 141, 134, 134, 135, + 134, 135, 134, 135, 131, 130, 136, 133, 110, 106, + 142, 144, 153, 162, 131, 129, 134, 132, 131, 130, + 126, 125, 132, 130, 168, 153, 126, 124, 130, 126, + 140, 135, 140, 134, 138, 133, 145, 137, 135, 134, + 130, 130, 132, 131, 133, 132, 129, 129, 125, 128, + 128, 130, 133, 139, 143, 152, 193, 215, 152, 160, + 130, 131, 129, 131, 130, 131, 135, 136, 136, 141, + 83, 81, 121, 120, 136, 130, 150, 145, 147, 145, + 134, 133, 135, 133, 146, 142, 135, 131, 127, 128, + 134, 135, 93, 102, 126, 132, 131, 133, 127, 129, + 124, 125, 120, 122, 103, 106, 128, 129, 139, 138, + 127, 128, 134, 134, 143, 138, 139, 134, 135, 133, + 131, 130, 133, 131, 139, 134, 138, 136, 166, 156, + 119, 116, 121, 122, 126, 124, 116, 117, 123, 124, + 131, 131, 129, 129, 130, 128, 141, 138, 135, 132, + 154, 145, 137, 129, 131, 125, 146, 137, 138, 135, + 131, 131, 131, 132, 129, 130, 134, 138, 111, 116, + 113, 118, 123, 125, 122, 124, 143, 147, 138, 140, + 116, 113, 114, 112, 130, 126, 117, 115, 127, 126, + 139, 137, 141, 139, 131, 132, 143, 144, 139, 140, + 130, 130, 129, 128, 136, 134, 119, 117, 152, 143, + 155, 143, 120, 119, 142, 139, 124, 130, 126, 128, + 112, 110, 112, 109, 136, 132, 125, 118, 121, 115, + 103, 101, 109, 100, 125, 120, 121, 117, 122, 121, + 128, 128, 127, 127, 124, 124, 128, 127, 131, 129, + 142, 138, 147, 141, 115, 108, 113, 109, 122, 119, + 136, 133, 150, 139, 142, 131, 119, 111, 151, 137, + 121, 116, 146, 134, 137, 129, 121, 123, 127, 129, + 130, 130, 130, 130, 136, 137, 126, 126, 136, 136, + 133, 133, 139, 139, 142, 143, 119, 120, 134, 134, + 132, 132, 133, 133, 135, 138, 129, 131, 133, 134, + 135, 138, 126, 130, 117, 118, 131, 132, 135, 135, + 129, 129, 128, 128, 126, 129, 127, 129, 123, 125, + 115, 117, 156, 157, 127, 131, 129, 129, 128, 129, + 129, 130, 131, 131, 126, 127, 135, 134, 136, 135, + 140, 136, 117, 113, 132, 128, 104, 97, 109, 106, + 131, 131, 131, 131, 121, 123, 124, 125, 126, 127, + 127, 127, 135, 135, 128, 128, 130, 130, 141, 140, + 129, 129, 129, 129, 129, 127, 127, 125, 149, 146, + 125, 123, 134, 133, 134, 132, 152, 150, 138, 138, + 128, 128, 126, 125, 132, 133, 141, 143, 136, 136, + 126, 127, 126, 127, 129, 131, 128, 129, 135, 134, + 176, 139, 192, 135, 145, 122, 149, 117, 155, 134, + 169, 133, 157, 139, 142, 136, 151, 152, 142, 147, + 166, 174, 103, 107, 141, 134, 140, 136, 144, 135, + 147, 135, 156, 131, 153, 127, 133, 126, 130, 124, + 127, 130, 123, 124, 114, 105, 195, 193, 156, 157, + 165, 158, 126, 122, 149, 141, 174, 173, 152, 147, + 136, 139, 131, 138, 163, 169, 103, 124, 80, 102, + 153, 186, 121, 151, 134, 161, 156, 190, 141, 151, + 121, 123, 124, 127, 119, 127, 133, 134, 157, 156, + 81, 69, 136, 134, 160, 169, 118, 114, 135, 128, + 114, 116, 97, 97, 117, 122, 152, 161, 115, 121, + 106, 122, 135, 137, 111, 113, 125, 135, 141, 145, + 143, 146, 143, 150, 132, 136, 142, 150, 151, 167, + 101, 107, 155, 173, 112, 124, 105, 100, 128, 126, + 127, 130, 133, 134, 142, 121, 131, 116, 176, 145, + 161, 120, 209, 150, 196, 133, 147, 115, 149, 130, + 144, 145, 144, 145, 120, 119, 163, 160, 117, 118, + 123, 117, 154, 119, 193, 98, 149, 101, 137, 116, + 133, 135, 140, 143, 144, 156, 131, 146, 186, 201, + 140, 139, 123, 125, 158, 169, 157, 166, 142, 143, + 130, 131, 132, 132, 128, 128, 141, 142, 147, 149, + 145, 148, 137, 139, 129, 129, 107, 108, 157, 157, + 120, 121, 119, 119, 140, 132, 137, 131, 118, 113, + 143, 136, 134, 135, 164, 158, 133, 125, 127, 124, + 148, 122, 197, 130, 173, 145, 110, 139, 123, 165, + 83, 158, 90, 167, 93, 142, 136, 169, 134, 152, + 130, 126, 154, 138, 227, 150, 156, 114, 147, 114, + 142, 109, 135, 110, 166, 135, 176, 150, 152, 142, + 132, 132, 136, 136, 130, 135, 143, 152, 136, 144, + 152, 160, 177, 185, 112, 112, 165, 166, 160, 161, + 145, 145, 138, 139, 116, 118, 127, 131, 66, 80, + 132, 142, 119, 127, 101, 108, 120, 130, 126, 130, + 135, 135, 142, 139, 153, 137, 55, 30, 142, 139, + 139, 143, 135, 133, 129, 133, 109, 108, 129, 129, + 136, 135, 134, 131, 129, 132, 132, 134, 135, 149, + 79, 206, 123, 137, 135, 143, 130, 140, 131, 134, + 100, 99, 165, 164, 142, 123, 148, 133, 133, 122, + 142, 133, 138, 125, 119, 111, 129, 123, 137, 130, + 131, 132, 123, 129, 174, 185, 196, 181, 127, 111, + 156, 141, 132, 114, 129, 106, 132, 107, 126, 117, + 134, 140, 131, 136, 119, 146, 92, 246, 128, 132, + 125, 129, 132, 140, 128, 141, 126, 145, 137, 142, + 130, 130, 110, 115, 124, 139, 127, 151, 118, 152, + 98, 146, 36, 108, 126, 158, 112, 146, 112, 130, + 138, 136, 145, 138, 153, 145, 116, 125, 90, 103, + 137, 138, 189, 185, 141, 151, 86, 93, 111, 111, + 133, 171, 125, 209, 140, 132, 130, 134, 129, 101, + 142, 120, 142, 132, 135, 126, 141, 140, 140, 134, + 128, 123, 131, 123, 138, 118, 163, 133, 240, 197, + 176, 151, 126, 123, 81, 94, 109, 118, 124, 133, + 135, 133, 137, 134, 154, 135, 140, 155, 69, 190, + 119, 149, 141, 151, 142, 123, 135, 125, 129, 130, + 127, 125, 132, 127, 107, 80, 123, 103, 145, 131, + 133, 107, 140, 103, 135, 106, 170, 145, 159, 143, + 136, 137, 127, 130, 105, 119, 129, 134, 141, 151, + 116, 127, 119, 140, 75, 119, 152, 162, 149, 152, + 72, 138, 9, 143, 118, 160, 126, 134, 141, 147, + 135, 131, 129, 129, 135, 129, 136, 126, 133, 125, + 137, 135, 146, 141, 145, 139, 141, 140, 133, 130, + 213, 208, 139, 130, 139, 136, 117, 117, 126, 125, + 133, 130, 138, 131, 141, 100, 145, 93, 159, 121, + 144, 132, 117, 160, 102, 187, 99, 162, 117, 144, + 132, 132, 134, 134, 140, 141, 127, 126, 128, 131, + 116, 116, 121, 127, 119, 126, 114, 114, 99, 100, + 141, 144, 148, 159, 179, 224, 95, 131, 100, 125, + 87, 110, 112, 132, 134, 147, 111, 125, 122, 122, + 137, 140, 141, 129, 169, 12, 144, 132, 133, 144, + 141, 146, 137, 147, 136, 122, 133, 130, 131, 128, + 141, 142, 128, 139, 15, 69, 160, 159, 142, 130, + 137, 126, 159, 141, 145, 143, 128, 125, 134, 128, + 131, 130, 127, 127, 114, 104, 119, 98, 83, 68, + 139, 120, 173, 142, 199, 154, 191, 153, 158, 145, + 128, 130, 127, 127, 148, 150, 110, 99, 119, 109, + 120, 113, 163, 154, 110, 90, 138, 129, 149, 144, + 131, 134, 124, 142, 76, 217, 130, 129, 140, 138, + 133, 135, 145, 150, 136, 138, 127, 130, 130, 134, + 144, 119, 178, 70, 143, 130, 115, 136, 139, 138, + 129, 109, 136, 116, 147, 122, 126, 112, 126, 123, + 132, 139, 128, 144, 107, 156, 75, 163, 120, 164, + 151, 136, 151, 99, 160, 112, 159, 126, 143, 126, + 140, 138, 137, 135, 152, 108, 251, 85, 138, 116, + 137, 118, 141, 119, 136, 121, 150, 134, 138, 131, + 137, 137, 143, 144, 150, 153, 148, 154, 152, 151, + 117, 104, 124, 96, 93, 67, 146, 138, 149, 148, + 149, 153, 172, 193, 108, 114, 125, 128, 145, 165, + 149, 160, 121, 130, 115, 120, 110, 112, 121, 118, + 145, 146, 141, 142, 127, 127, 103, 95, 138, 143, + 114, 126, 109, 115, 143, 136, 153, 149, 144, 142, + 140, 138, 150, 144, 128, 116, 142, 136, 135, 122, + 93, 88, 164, 163, 141, 142, 171, 182, 154, 160, + 124, 125, 122, 123, 158, 155, 111, 97, 138, 130, + 157, 134, 101, 65, 129, 118, 121, 114, 124, 119, + 131, 133, 125, 129, 136, 147, 135, 152, 131, 133, + 110, 115, 118, 114, 161, 159, 233, 218, 172, 166, + 140, 107, 125, 0, 140, 103, 140, 115, 125, 113, + 132, 135, 128, 133, 138, 146, 131, 145, 127, 133, + 131, 131, 122, 122, 135, 132, 126, 124, 132, 133, + 164, 167, 121, 127, 117, 120, 167, 162, 145, 143, + 135, 134, 136, 134, 156, 146, 195, 177, 127, 139, + 108, 140, 141, 173, 141, 178, 131, 155, 129, 141, + 134, 134, 119, 114, 184, 184, 127, 126, 147, 151, + 130, 140, 146, 159, 134, 145, 131, 136, 137, 142, + 135, 137, 128, 136, 83, 108, 97, 98, 152, 119, + 207, 144, 142, 121, 144, 129, 131, 127, 130, 132, + 124, 125, 108, 107, 94, 116, 81, 114, 139, 173, + 131, 158, 145, 177, 141, 163, 136, 140, 143, 144, + 135, 141, 132, 136, 134, 142, 142, 136, 173, 50, + 143, 106, 142, 127, 134, 139, 127, 133, 125, 125, + 129, 130, 131, 133, 132, 148, 110, 138, 113, 135, + 138, 175, 108, 151, 55, 119, 51, 100, 93, 116, + 121, 121, 146, 151, 99, 120, 127, 137, 107, 122, + 125, 139, 110, 132, 135, 156, 141, 156, 148, 157, + 137, 137, 141, 140, 139, 137, 130, 128, 138, 136, + 132, 134, 115, 110, 177, 179, 81, 86, 100, 98, + 84, 83, 121, 121, 148, 157, 127, 133, 146, 156, + 127, 136, 143, 151, 135, 139, 138, 142, 136, 136, + 201, 164, 151, 129, 123, 136, 147, 148, 127, 142, + 128, 143, 101, 126, 119, 133, 114, 131, 116, 126, + 132, 133, 140, 140, 126, 125, 156, 153, 142, 129, + 140, 130, 77, 69, 134, 132, 146, 148, 135, 136, + 133, 132, 123, 116, 116, 103, 150, 135, 144, 127, + 130, 117, 136, 122, 122, 106, 48, 38, 81, 78, + 145, 146, 135, 136, 123, 122, 126, 133, 133, 138, + 145, 145, 144, 150, 160, 181, 142, 139, 150, 150, + 136, 136, 139, 139, 133, 133, 139, 135, 134, 129, + 140, 137, 153, 145, 132, 131, 151, 144, 68, 66, + 137, 137, 139, 139, 146, 146, 142, 139, 129, 128, + 131, 129, 133, 132, 135, 134, 135, 134, 201, 200, + 137, 136, 146, 143, 155, 153, 157, 158, 131, 138, + 140, 139, 143, 144, 128, 123, 216, 192, 159, 150, + 137, 138, 136, 142, 145, 148, 126, 162, 140, 170, + 186, 95, 131, 140, 143, 148, 133, 128, 130, 133, + 141, 139, 153, 150, 122, 122, 134, 144, 124, 130, + 159, 166, 133, 139, 151, 150, 138, 139, 131, 134, + 121, 121, 131, 129, 148, 180, 121, 135, 118, 131, + 124, 148, 119, 119, 129, 126, 150, 156, 155, 160, + 40, 154, 115, 157, 133, 129, 140, 133, 143, 133, + 143, 132, 144, 130, 141, 131, 134, 130, 137, 133, + 134, 136, 141, 140, 145, 137, 152, 124, 183, 91, + 118, 154, 123, 158, 136, 134, 140, 142, 138, 142, + 138, 135, 131, 131, 138, 129, 121, 128, 146, 219, + 124, 123, 125, 135, 120, 126, 127, 141, 133, 136, + 127, 124, 120, 107, 152, 125, 149, 108, 158, 144, + 196, 185, 174, 164, 151, 149, 138, 131, 140, 137, + 149, 148, 144, 145, 143, 145, 140, 143, 141, 147, + 112, 125, 113, 113, 149, 155, 143, 149, 146, 151, + 138, 138, 141, 138, 144, 129, 134, 125, 143, 140, + 153, 154, 142, 123, 162, 42, 154, 106, 153, 130, + 153, 153, 137, 137, 144, 144, 142, 140, 165, 151, + 161, 140, 144, 134, 156, 124, 167, 143, 166, 155, + 132, 132, 137, 138, 137, 132, 124, 127, 140, 144, + 134, 140, 162, 180, 127, 131, 152, 169, 145, 156, + 133, 134, 131, 133, 130, 132, 147, 149, 125, 117, + 127, 118, 159, 155, 147, 142, 122, 117, 145, 144, + 138, 137, 130, 133, 113, 149, 168, 224, 166, 201, + 129, 151, 147, 154, 136, 135, 140, 136, 152, 141, + 120, 112, 140, 127, 161, 100, 132, 115, 118, 125, + 115, 133, 115, 157, 144, 146, 114, 135, 127, 139, + 138, 141, 135, 135, 137, 136, 147, 142, 143, 144, + 139, 152, 142, 136, 147, 143, 177, 39, 125, 71, + 147, 143, 66, 88, 132, 158, 123, 126, 116, 135, + 119, 124, 128, 135, 133, 140, 137, 126, 137, 130, + 155, 38, 149, 103, 130, 135, 139, 143, 127, 137, + 135, 141, 138, 148, 131, 148, 136, 147, 132, 139, + 136, 140, 115, 129, 115, 151, 136, 160, 87, 131, + 157, 176, 150, 164, 140, 141, 135, 119, 137, 133, + 141, 140, 140, 139, 134, 134, 142, 144, 131, 132, + 131, 134, 131, 132, 116, 114, 129, 133, 205, 207, + 130, 133, 160, 170, 137, 127, 124, 112, 158, 146, + 155, 137, 134, 136, 137, 142, 177, 184, 149, 152, + 135, 134, 133, 132, 135, 129, 144, 136, 139, 134, + 161, 155, 126, 109, 215, 186, 177, 153, 160, 149, + 139, 139, 136, 140, 140, 142, 186, 71, 129, 144, + 131, 165, 142, 152, 140, 151, 141, 143, 137, 139, + 144, 138, 150, 135, 133, 126, 136, 143, 99, 152, + 139, 131, 190, 118, 122, 147, 134, 155, 136, 143, + 138, 135, 137, 132, 147, 144, 150, 144, 138, 134, + 129, 133, 130, 138, 56, 175, 129, 166, 147, 165, + 140, 138, 144, 137, 141, 133, 150, 139, 129, 135, + 40, 83, 126, 130, 110, 120, 100, 110, 126, 128, + 141, 142, 217, 175, 172, 151, 146, 153, 125, 132, + 128, 137, 141, 141, 145, 145, 140, 133, 132, 131, + 129, 144, 128, 177, 133, 195, 147, 120, 138, 131, + 161, 114, 166, 134, 162, 118, 161, 115, 155, 129, + 137, 136, 141, 129, 141, 132, 55, 168, 121, 126, + 136, 139, 120, 133, 149, 147, 132, 141, 131, 136, + 147, 150, 151, 132, 101, 31, 117, 101, 129, 132, + 122, 138, 128, 137, 140, 170, 131, 143, 131, 134, + 149, 192, 122, 158, 136, 146, 133, 166, 143, 141, + 141, 136, 141, 129, 125, 155, 140, 138, 137, 131, + 111, 112, 131, 132, 120, 127, 149, 148, 151, 141, + 156, 148, 133, 129, 127, 124, 144, 137, 142, 139, + 134, 133, 141, 138, 133, 135, 124, 96, 226, 152, + 116, 108, 128, 105, 155, 130, 153, 138, 144, 139, + 142, 141, 137, 135, 142, 143, 156, 162, 136, 89, + 188, 145, 181, 152, 138, 146, 146, 154, 145, 149, + 152, 133, 158, 133, 42, 153, 117, 144, 149, 139, + 125, 139, 134, 128, 150, 128, 143, 125, 135, 132, + 143, 141, 143, 141, 164, 173, 141, 142, 156, 155, + 154, 154, 169, 170, 77, 80, 112, 105, 135, 134, + 126, 143, 120, 172, 111, 144, 120, 154, 107, 153, + 95, 134, 104, 134, 128, 116, 163, 131, 151, 136, + 135, 133, 142, 143, 152, 204, 149, 112, 156, 128, + 150, 126, 127, 129, 139, 175, 143, 141, 138, 135, + 168, 148, 152, 105, 164, 121, 134, 122, 119, 109, + 122, 148, 136, 143, 153, 132, 158, 148, 149, 150, + 133, 131, 142, 141, 150, 149, 156, 173, 138, 155, + 129, 144, 111, 107, 130, 129, 96, 89, 106, 104, + 135, 135, 144, 146, 131, 153, 134, 154, 146, 166, + 117, 138, 163, 187, 190, 216, 149, 156, 149, 152, + 142, 142, 153, 154, 109, 145, 40, 102, 116, 126, + 137, 139, 149, 157, 108, 124, 139, 146, 142, 147, + 130, 126, 120, 111, 172, 146, 169, 136, 150, 135, + 126, 96, 159, 143, 150, 122, 162, 129, 156, 142, + 135, 142, 144, 138, 222, 109, 137, 145, 144, 142, + 141, 143, 138, 136, 124, 150, 133, 144, 137, 145, + 141, 144, 139, 144, 134, 154, 114, 136, 145, 173, + 151, 215, 110, 115, 127, 134, 145, 150, 145, 144, + 144, 142, 139, 131, 147, 132, 141, 119, 143, 106, + 165, 41, 147, 129, 129, 144, 138, 135, 138, 140, + 128, 150, 89, 163, 154, 115, 141, 127, 132, 145, + 135, 157, 143, 145, 140, 141, 127, 135, 127, 129, + 142, 147, 116, 147, 104, 162, 153, 143, 146, 130, + 144, 110, 133, 123, 130, 137, 118, 198, 126, 152, + 154, 146, 139, 127, 147, 112, 207, 151, 156, 136, + 162, 137, 108, 121, 130, 135, 125, 131, 131, 134, + 134, 134, 141, 144, 107, 143, 137, 144, 124, 136, + 115, 147, 130, 157, 119, 167, 71, 144, 97, 128, + 134, 138, 132, 133, 138, 138, 146, 146, 147, 131, + 141, 138, 185, 65, 145, 123, 139, 130, 142, 128, + 139, 136, 157, 147, 124, 119, 164, 148, 170, 154, + 133, 130, 157, 148, 140, 141, 130, 135, 134, 137, + 136, 137, 143, 144, 144, 144, 178, 186, 71, 73, + 120, 118, 127, 124, 152, 151, 155, 146, 141, 138, + 142, 143, 139, 143, 133, 134, 139, 140, 138, 135, + 146, 141, 78, 198, 129, 139, 141, 141, 134, 141, + 137, 136, 120, 120, 124, 118, 143, 148, 148, 152, + 131, 143, 129, 137, 152, 158, 157, 160, 175, 178, + 137, 139, 131, 133, 146, 152, 121, 147, 142, 143, + 129, 136, 149, 145, 197, 114, 103, 141, 124, 140, + 141, 140, 129, 129, 127, 130, 131, 124, 123, 117, + 150, 139, 120, 109, 119, 120, 163, 163, 117, 121, + 139, 139, 136, 136, 94, 74, 150, 145, 126, 127, + 147, 150, 158, 162, 84, 74, 136, 129, 140, 132, + 136, 135, 146, 145, 124, 116, 129, 120, 130, 129, + 130, 109, 122, 111, 160, 141, 135, 113, 131, 121, + 136, 135, 135, 135, 147, 147, 140, 140, 144, 145, + 139, 142, 131, 137, 145, 145, 143, 153, 48, 49, + 145, 143, 151, 147, 158, 146, 135, 124, 124, 116, + 159, 140, 131, 126, 123, 120, 103, 117, 113, 119, + 148, 146, 128, 124, 123, 126, 123, 120, 158, 141, + 148, 137, 146, 143, 125, 143, 89, 107, 116, 123, + 149, 147, 141, 139, 149, 153, 118, 121, 139, 138, + 105, 119, 168, 147, 139, 141, 143, 138, 133, 130, + 126, 126, 143, 142, 146, 144, 124, 123, 143, 145, + 149, 148, 147, 141, 151, 143, 118, 113, 175, 171 +}; + +static const uint8_t wmavoice_dq_lsp16r1[0x500] = { + 147, 145, 193, 168, 188, 156, 141, 145, 141, 139, + 148, 149, 148, 149, 153, 157, 144, 144, 152, 152, + 141, 145, 153, 143, 243, 134, 151, 133, 166, 135, + 150, 149, 135, 132, 32, 39, 110, 111, 109, 114, + 126, 127, 147, 146, 177, 169, 162, 156, 210, 187, + 141, 147, 95, 150, 127, 155, 108, 133, 139, 148, + 138, 138, 140, 140, 147, 146, 134, 130, 136, 134, + 147, 146, 142, 150, 62, 174, 126, 151, 122, 156, + 154, 156, 179, 184, 115, 107, 105, 99, 127, 124, + 146, 131, 140, 44, 132, 125, 156, 146, 153, 153, + 136, 137, 145, 144, 141, 139, 158, 152, 138, 132, + 145, 145, 147, 145, 146, 141, 144, 140, 110, 97, + 140, 141, 143, 142, 130, 123, 127, 117, 126, 120, + 147, 146, 161, 155, 169, 135, 122, 117, 166, 155, + 144, 144, 142, 142, 125, 122, 137, 128, 194, 172, + 127, 85, 148, 143, 153, 141, 147, 147, 140, 143, + 118, 140, 0, 69, 51, 60, 111, 123, 137, 135, + 146, 146, 164, 165, 207, 214, 145, 143, 149, 147, + 178, 168, 197, 170, 134, 154, 148, 159, 115, 140, + 103, 118, 13, 38, 139, 138, 135, 138, 140, 141, + 144, 144, 140, 140, 150, 150, 156, 157, 164, 171, + 143, 143, 140, 142, 118, 120, 172, 172, 160, 163, + 146, 147, 150, 151, 176, 176, 230, 237, 153, 153, + 168, 156, 173, 149, 164, 148, 162, 146, 178, 158, + 147, 145, 143, 145, 111, 126, 111, 130, 89, 118, + 153, 158, 122, 120, 142, 125, 124, 105, 148, 138, + 145, 144, 156, 151, 193, 154, 146, 147, 119, 135, + 142, 141, 145, 145, 152, 147, 142, 141, 146, 146, + 139, 138, 154, 154, 148, 150, 147, 149, 144, 145, + 134, 134, 141, 140, 135, 134, 145, 147, 160, 163, + 144, 145, 149, 146, 115, 67, 127, 119, 141, 135, + 145, 141, 130, 124, 143, 144, 151, 165, 141, 144, + 154, 152, 160, 136, 115, 82, 64, 71, 64, 65, + 143, 143, 151, 149, 240, 251, 165, 173, 173, 179, + 148, 134, 156, 55, 160, 105, 133, 91, 129, 96, + 149, 149, 145, 144, 160, 154, 171, 159, 140, 142, + 154, 163, 178, 244, 147, 140, 153, 150, 137, 121, + 145, 144, 145, 146, 138, 139, 149, 152, 189, 198, + 148, 148, 156, 158, 168, 182, 165, 182, 172, 201, + 143, 142, 99, 92, 152, 152, 143, 143, 127, 127, + 165, 148, 173, 124, 113, 122, 134, 142, 127, 142, + 124, 126, 137, 137, 131, 132, 144, 142, 141, 138, + 172, 176, 138, 111, 152, 136, 167, 154, 156, 137, + 140, 150, 78, 145, 158, 157, 161, 154, 155, 147, + 153, 164, 156, 191, 129, 109, 153, 146, 153, 141, + 138, 137, 141, 138, 115, 94, 144, 141, 155, 147, + 144, 142, 144, 137, 168, 113, 141, 134, 145, 137, + 146, 144, 150, 148, 140, 155, 103, 178, 137, 149, + 145, 147, 148, 153, 175, 201, 138, 146, 110, 108, + 143, 146, 124, 134, 124, 127, 164, 158, 127, 135, + 145, 146, 150, 150, 145, 147, 95, 80, 150, 151, + 149, 149, 162, 162, 144, 152, 170, 169, 145, 154, + 145, 149, 143, 146, 142, 145, 152, 146, 160, 98, + 141, 141, 153, 153, 140, 137, 131, 131, 145, 146, + 133, 132, 127, 124, 158, 150, 173, 164, 178, 167, + 146, 146, 154, 155, 117, 127, 143, 147, 147, 156, + 142, 143, 144, 145, 146, 152, 170, 199, 151, 165, + 146, 147, 139, 140, 147, 149, 132, 134, 147, 149, + 138, 139, 142, 143, 162, 188, 145, 149, 160, 164, + 150, 150, 139, 139, 143, 142, 146, 146, 137, 138, + 142, 142, 141, 140, 152, 153, 164, 171, 110, 112, + 139, 139, 143, 143, 138, 138, 142, 142, 143, 143, + 137, 140, 142, 142, 145, 141, 149, 141, 182, 135, + 146, 146, 150, 150, 144, 145, 150, 151, 135, 137, + 137, 145, 51, 62, 68, 54, 69, 57, 62, 41, + 137, 139, 139, 144, 135, 150, 225, 232, 208, 197, + 136, 135, 141, 143, 145, 150, 160, 169, 213, 247, + 142, 137, 72, 54, 110, 107, 105, 107, 127, 130, + 145, 143, 169, 155, 219, 174, 195, 164, 183, 157, + 155, 157, 239, 232, 169, 164, 170, 172, 156, 159, + 142, 143, 136, 144, 59, 100, 139, 142, 130, 138, + 147, 146, 150, 161, 128, 235, 143, 155, 146, 167, + 154, 149, 128, 151, 42, 149, 55, 136, 59, 127, + 128, 126, 74, 92, 143, 153, 140, 150, 166, 176, + 146, 152, 150, 145, 140, 100, 140, 105, 124, 59, + 195, 191, 146, 148, 144, 136, 136, 133, 129, 122, + 133, 148, 40, 147, 102, 140, 123, 148, 118, 136, + 143, 143, 150, 148, 184, 153, 160, 147, 166, 149, + 58, 68, 127, 135, 141, 145, 143, 147, 150, 151, + 140, 143, 137, 137, 120, 114, 71, 65, 125, 123, + 153, 148, 215, 159, 136, 135, 150, 146, 150, 150, + 148, 138, 166, 94, 150, 145, 145, 139, 147, 145, + 146, 147, 150, 139, 171, 63, 158, 142, 153, 133, + 147, 148, 143, 143, 76, 72, 155, 159, 164, 176, + 149, 149, 173, 195, 145, 165, 138, 144, 150, 167, + 180, 169, 146, 151, 146, 166, 147, 166, 149, 171, + 157, 156, 168, 166, 147, 149, 121, 122, 116, 124, + 145, 145, 147, 148, 172, 189, 168, 180, 144, 146, + 139, 145, 141, 150, 115, 172, 141, 146, 143, 148, + 145, 145, 142, 143, 145, 147, 138, 143, 58, 73, + 141, 142, 146, 145, 163, 149, 218, 161, 147, 132, + 152, 147, 146, 147, 140, 150, 141, 152, 89, 150, + 78, 134, 135, 137, 139, 142, 140, 137, 137, 130, + 144, 144, 152, 151, 145, 140, 181, 170, 191, 168, + 164, 166, 136, 148, 112, 124, 139, 144, 146, 149, + 142, 151, 113, 182, 137, 150, 143, 156, 138, 147, + 154, 156, 108, 102, 118, 119, 133, 139, 113, 111, + 145, 144, 150, 147, 175, 151, 104, 106, 116, 114, + 143, 144, 151, 157, 151, 191, 135, 113, 138, 123, + 146, 146, 155, 157, 106, 145, 132, 127, 140, 125, + 161, 165, 146, 150, 151, 154, 139, 140, 142, 143, + 144, 148, 145, 149, 147, 138, 168, 104, 146, 136, + 138, 140, 91, 108, 111, 110, 145, 140, 158, 154, + 130, 112, 122, 118, 136, 135, 119, 118, 141, 140, + 147, 146, 146, 145, 138, 138, 182, 188, 132, 132, + 144, 144, 156, 155, 168, 172, 123, 128, 144, 151, + 142, 140, 145, 145, 137, 144, 141, 152, 128, 188, + 149, 149, 160, 161, 160, 160, 166, 163, 130, 107, + 143, 143, 142, 142, 149, 149, 132, 132, 170, 174, + 148, 148, 154, 153, 118, 111, 157, 155, 114, 109, + 140, 139, 138, 137, 205, 187, 137, 133, 147, 144, + 144, 145, 147, 149, 105, 125, 108, 117, 155, 162, + 146, 146, 162, 157, 144, 122, 154, 143, 161, 139, + 141, 142, 130, 131, 144, 144, 142, 141, 144, 142, + 132, 132, 141, 141, 150, 151, 139, 141, 151, 153, + 142, 142, 154, 154, 150, 150, 148, 148, 166, 165, + 143, 142, 144, 144, 132, 132, 142, 144, 130, 128, + 142, 142, 143, 143, 153, 153, 147, 142, 129, 125, + 142, 141, 143, 142, 143, 147, 105, 122, 135, 140, + 141, 140, 140, 140, 151, 151, 156, 155, 146, 146, + 133, 134, 140, 142, 142, 145, 141, 146, 112, 133, + 142, 142, 145, 145, 137, 138, 155, 157, 149, 150, + 144, 144, 139, 138, 130, 128, 132, 131, 147, 147, + 139, 140, 142, 143, 115, 121, 141, 143, 137, 141, + 146, 146, 150, 150, 145, 144, 133, 133, 133, 135, + 143, 144, 144, 144, 166, 167, 139, 142, 139, 140, + 150, 149, 138, 138, 142, 140, 148, 147, 160, 155, + 146, 146, 147, 147, 138, 137, 143, 142, 151, 150 +}; + +static const uint8_t wmavoice_dq_lsp16r2[0x500] = { + 98, 98, 119, 121, 109, 112, 128, 135, 115, 121, + 159, 113, 113, 106, 127, 114, 101, 102, 105, 111, + 161, 162, 137, 138, 161, 159, 152, 150, 150, 148, + 128, 79, 131, 102, 142, 120, 133, 119, 130, 117, + 121, 115, 142, 133, 186, 155, 179, 144, 169, 135, + 107, 103, 106, 106, 122, 122, 111, 112, 112, 115, + 127, 123, 118, 115, 128, 125, 123, 119, 115, 109, + 124, 130, 117, 126, 121, 133, 84, 144, 99, 114, + 122, 125, 123, 131, 124, 135, 176, 200, 158, 176, + 68, 74, 86, 87, 117, 115, 119, 116, 135, 128, + 115, 116, 102, 104, 119, 123, 133, 148, 102, 109, + 71, 121, 106, 117, 107, 127, 106, 122, 100, 110, + 117, 115, 129, 128, 87, 84, 116, 116, 151, 157, + 116, 128, 110, 117, 119, 134, 100, 114, 120, 129, + 142, 141, 146, 151, 94, 91, 114, 114, 118, 118, + 114, 112, 112, 109, 115, 112, 123, 123, 147, 148, + 110, 164, 106, 152, 110, 158, 106, 151, 105, 135, + 85, 51, 71, 27, 71, 34, 74, 45, 85, 53, + 145, 134, 140, 130, 136, 134, 118, 122, 118, 126, + 117, 84, 121, 81, 106, 80, 109, 106, 121, 127, + 95, 94, 112, 110, 90, 94, 109, 107, 114, 109, + 117, 118, 118, 123, 107, 107, 86, 93, 29, 31, + 125, 112, 104, 60, 121, 111, 127, 116, 133, 130, + 118, 117, 148, 145, 122, 126, 124, 127, 90, 91, + 113, 110, 119, 118, 152, 147, 115, 112, 132, 131, + 129, 140, 98, 112, 73, 85, 109, 115, 122, 126, + 123, 122, 122, 122, 126, 125, 137, 140, 203, 210, + 164, 176, 114, 114, 125, 122, 119, 112, 125, 120, + 124, 122, 118, 115, 95, 96, 141, 144, 132, 131, + 127, 130, 132, 134, 116, 114, 122, 123, 137, 134, + 111, 111, 112, 116, 106, 118, 77, 101, 104, 115, + 111, 111, 125, 126, 118, 121, 113, 115, 113, 113, + 171, 170, 202, 199, 221, 206, 199, 184, 177, 167, + 73, 90, 61, 93, 43, 74, 51, 71, 51, 72, + 130, 130, 140, 137, 134, 132, 164, 160, 118, 111, + 123, 136, 133, 154, 130, 158, 106, 110, 110, 114, + 97, 97, 91, 94, 70, 69, 125, 123, 141, 140, + 119, 100, 116, 77, 111, 67, 105, 52, 95, 34, + 100, 122, 90, 124, 68, 120, 43, 117, 50, 112, + 130, 129, 192, 188, 123, 118, 124, 117, 121, 115, + 122, 111, 129, 111, 157, 85, 125, 109, 125, 119, + 143, 152, 119, 128, 114, 116, 129, 136, 148, 157, + 119, 117, 115, 115, 150, 148, 163, 154, 109, 102, + 120, 126, 73, 119, 106, 121, 102, 122, 96, 113, + 84, 83, 117, 115, 122, 117, 154, 143, 159, 142, + 118, 122, 114, 117, 115, 122, 114, 130, 99, 156, + 123, 120, 122, 116, 100, 81, 99, 91, 121, 112, + 139, 131, 164, 142, 132, 119, 145, 133, 157, 141, + 112, 109, 118, 116, 142, 134, 108, 110, 96, 99, + 111, 110, 113, 112, 111, 104, 98, 94, 131, 131, + 115, 114, 121, 118, 120, 115, 173, 148, 123, 117, + 121, 124, 122, 124, 140, 146, 78, 82, 96, 93, + 86, 90, 124, 125, 121, 123, 105, 106, 134, 135, + 107, 109, 132, 141, 100, 95, 113, 114, 102, 105, + 113, 130, 98, 145, 116, 115, 124, 117, 115, 105, + 120, 123, 89, 87, 109, 108, 102, 101, 117, 117, + 113, 122, 132, 138, 77, 116, 86, 99, 118, 126, + 123, 120, 117, 111, 124, 119, 129, 118, 63, 58, + 141, 135, 108, 106, 109, 111, 108, 110, 135, 138, + 117, 114, 134, 127, 139, 129, 138, 130, 126, 122, + 121, 118, 124, 121, 133, 130, 98, 85, 130, 123, + 147, 129, 118, 112, 148, 130, 136, 123, 148, 131, + 113, 112, 123, 118, 123, 115, 147, 95, 117, 110, + 118, 119, 112, 113, 112, 113, 119, 119, 120, 120, + 158, 133, 198, 145, 188, 129, 197, 137, 195, 133, + 132, 140, 140, 139, 158, 156, 223, 217, 233, 233, + 48, 56, 34, 37, 82, 84, 102, 102, 108, 110, + 120, 142, 136, 169, 146, 195, 136, 186, 140, 182, + 196, 186, 158, 155, 142, 134, 132, 125, 120, 119, + 97, 105, 72, 75, 82, 85, 81, 84, 107, 109, + 67, 121, 43, 119, 69, 124, 87, 129, 88, 128, + 53, 57, 93, 98, 91, 94, 93, 98, 104, 104, + 124, 123, 133, 133, 182, 181, 119, 121, 114, 116, + 128, 105, 134, 112, 131, 72, 119, 59, 111, 84, + 132, 142, 145, 180, 124, 132, 131, 143, 122, 134, + 88, 85, 103, 103, 136, 140, 131, 143, 114, 132, + 116, 57, 113, 57, 121, 76, 126, 80, 118, 86, + 127, 112, 127, 97, 131, 100, 149, 91, 163, 86, + 122, 119, 128, 121, 128, 116, 142, 127, 173, 139, + 162, 116, 166, 107, 149, 103, 152, 107, 141, 108, + 114, 113, 118, 116, 56, 43, 90, 90, 105, 105, + 132, 134, 110, 107, 106, 105, 82, 84, 84, 84, + 102, 106, 79, 89, 99, 99, 127, 129, 114, 118, + 139, 157, 116, 123, 116, 123, 87, 89, 110, 113, + 119, 126, 97, 97, 155, 163, 142, 153, 143, 146, + 117, 114, 66, 67, 125, 126, 127, 128, 114, 113, + 111, 114, 127, 133, 123, 132, 143, 162, 133, 148, + 105, 108, 114, 114, 110, 109, 57, 48, 109, 106, + 113, 130, 104, 131, 88, 139, 102, 169, 100, 172, + 129, 114, 150, 97, 114, 112, 117, 119, 109, 116, + 92, 107, 96, 116, 90, 125, 101, 122, 125, 140, + 125, 133, 122, 129, 136, 153, 125, 135, 131, 139, + 84, 71, 129, 123, 135, 120, 114, 103, 112, 101, + 108, 121, 115, 156, 106, 123, 116, 131, 127, 139, + 137, 147, 109, 117, 119, 126, 135, 144, 117, 119, + 120, 127, 76, 105, 111, 116, 120, 125, 141, 138, + 107, 104, 162, 155, 135, 130, 127, 123, 127, 121, + 102, 104, 84, 87, 112, 115, 97, 102, 78, 82, + 119, 118, 120, 123, 91, 105, 114, 119, 119, 126, + 130, 126, 134, 126, 158, 134, 133, 99, 116, 100, + 125, 122, 145, 143, 126, 117, 98, 96, 121, 120, + 152, 148, 131, 126, 130, 129, 126, 119, 87, 87, + 131, 131, 139, 137, 101, 102, 104, 105, 86, 83, + 92, 89, 111, 105, 121, 115, 137, 124, 96, 84, + 100, 96, 122, 119, 107, 108, 93, 96, 79, 82, + 128, 123, 108, 106, 123, 120, 150, 150, 143, 140, + 121, 120, 97, 99, 79, 80, 116, 116, 88, 90, + 128, 131, 101, 97, 140, 140, 117, 116, 116, 118, + 137, 135, 100, 91, 115, 112, 134, 121, 107, 99, + 120, 122, 122, 125, 124, 126, 136, 141, 89, 95, + 103, 119, 103, 116, 122, 139, 125, 137, 152, 170, + 121, 122, 124, 124, 98, 97, 137, 140, 96, 92, + 115, 113, 136, 136, 128, 132, 122, 124, 151, 158, + 100, 107, 121, 131, 131, 158, 119, 130, 113, 114, + 114, 109, 148, 130, 103, 95, 127, 116, 137, 120, + 103, 108, 97, 97, 133, 128, 113, 109, 136, 128, + 125, 124, 118, 118, 122, 121, 101, 99, 157, 152, + 138, 134, 124, 115, 113, 101, 123, 112, 124, 110, + 116, 113, 128, 121, 119, 110, 124, 113, 128, 67, + 114, 118, 114, 123, 109, 121, 102, 123, 56, 116, + 117, 111, 112, 99, 124, 114, 112, 79, 114, 88, + 112, 113, 115, 117, 126, 127, 130, 132, 123, 122, + 111, 104, 111, 102, 112, 102, 129, 118, 129, 115, + 123, 124, 130, 133, 114, 117, 125, 127, 112, 117, + 124, 125, 119, 120, 117, 116, 105, 104, 110, 110, + 125, 124, 118, 116, 124, 123, 124, 121, 133, 132, + 111, 111, 124, 124, 120, 119, 116, 116, 134, 130, + 114, 116, 112, 113, 109, 111, 116, 118, 95, 98 +}; + +static const uint8_t wmavoice_dq_lsp16r3[0x600] = { + 84, 82, 95, 94, 125, 131, 98, 102, 94, 93, 104, 104, + 127, 113, 87, 77, 125, 114, 109, 94, 94, 91, 106, 105, + 168, 125, 163, 120, 128, 100, 119, 99, 108, 97, 108, 106, + 86, 85, 128, 125, 79, 73, 103, 102, 123, 123, 116, 117, + 84, 76, 135, 131, 133, 133, 129, 130, 125, 123, 115, 114, + 94, 97, 79, 81, 115, 115, 94, 93, 128, 127, 126, 125, + 124, 111, 105, 114, 104, 117, 109, 110, 124, 125, 118, 117, + 107, 110, 106, 110, 93, 93, 149, 148, 118, 119, 111, 110, + 147, 157, 143, 156, 134, 136, 118, 121, 106, 107, 105, 105, + 114, 83, 114, 46, 106, 53, 110, 83, 107, 94, 105, 103, + 92, 90, 109, 106, 172, 160, 114, 110, 109, 110, 110, 109, + 90, 98, 98, 109, 102, 98, 97, 92, 100, 100, 101, 102, + 123, 117, 124, 98, 82, 80, 117, 115, 112, 110, 109, 108, + 107, 111, 100, 115, 105, 120, 104, 105, 83, 82, 95, 96, + 109, 120, 72, 71, 97, 104, 69, 74, 99, 102, 118, 117, + 137, 133, 142, 135, 105, 110, 121, 121, 125, 122, 114, 112, + 151, 186, 115, 132, 103, 111, 100, 104, 99, 101, 104, 105, + 18, 38, 56, 65, 76, 83, 85, 91, 101, 103, 108, 110, + 144, 135, 126, 121, 115, 113, 79, 80, 118, 117, 117, 117, + 117, 124, 115, 115, 126, 113, 130, 116, 112, 106, 108, 105, + 77, 76, 76, 80, 109, 109, 125, 129, 130, 133, 116, 118, + 96, 86, 109, 99, 102, 69, 84, 69, 107, 103, 114, 113, + 78, 118, 82, 114, 84, 129, 69, 112, 78, 98, 96, 103, + 89, 137, 96, 111, 105, 97, 93, 93, 101, 105, 105, 105, + 141, 123, 102, 93, 91, 79, 87, 81, 102, 99, 109, 108, + 94, 92, 124, 123, 130, 134, 100, 107, 71, 75, 92, 91, + 94, 104, 107, 83, 106, 101, 113, 114, 122, 122, 114, 114, + 118, 124, 103, 106, 95, 116, 90, 93, 107, 104, 109, 107, + 116, 118, 76, 72, 88, 88, 132, 132, 140, 141, 116, 116, + 90, 81, 111, 95, 139, 97, 123, 96, 112, 100, 110, 108, + 112, 116, 133, 140, 112, 120, 80, 85, 55, 55, 85, 84, + 125, 94, 111, 104, 116, 103, 112, 86, 93, 84, 99, 98, + 180, 179, 197, 197, 169, 163, 149, 146, 130, 124, 116, 115, + 76, 47, 36, 11, 43, 28, 66, 53, 82, 80, 102, 99, + 119, 123, 176, 201, 113, 120, 112, 111, 103, 105, 106, 110, + 145, 114, 112, 89, 120, 93, 123, 104, 131, 123, 113, 111, + 97, 109, 82, 106, 75, 104, 103, 115, 120, 124, 111, 114, + 114, 111, 113, 105, 34, 33, 63, 63, 105, 106, 122, 122, + 51, 41, 96, 92, 125, 125, 118, 118, 118, 119, 113, 113, + 111, 180, 108, 178, 107, 171, 110, 160, 105, 136, 102, 117, + 76, 79, 90, 92, 80, 88, 88, 93, 123, 124, 122, 122, + 131, 128, 123, 122, 151, 158, 108, 107, 129, 128, 119, 119, + 97, 99, 114, 120, 121, 125, 151, 157, 82, 89, 95, 96, + 128, 94, 130, 95, 149, 113, 149, 120, 127, 115, 113, 109, + 167, 171, 83, 80, 84, 79, 106, 106, 112, 110, 107, 108, + 130, 139, 81, 88, 107, 106, 112, 112, 119, 118, 114, 112, + 108, 105, 100, 98, 120, 116, 122, 117, 38, 37, 72, 73, + 118, 125, 110, 120, 114, 126, 135, 142, 139, 142, 118, 119, + 119, 119, 156, 145, 78, 75, 94, 94, 112, 110, 113, 113, + 101, 108, 98, 104, 103, 109, 117, 118, 167, 167, 132, 132, + 116, 108, 118, 111, 149, 136, 85, 74, 95, 92, 113, 112, + 74, 69, 104, 107, 96, 100, 117, 121, 103, 105, 103, 103, + 110, 106, 111, 101, 82, 72, 96, 92, 132, 130, 120, 121, + 116, 113, 138, 139, 104, 103, 131, 131, 68, 69, 92, 92, + 97, 97, 146, 151, 122, 132, 97, 95, 117, 116, 115, 116, + 139, 134, 110, 110, 124, 129, 100, 110, 86, 91, 100, 102, + 116, 136, 88, 90, 137, 139, 103, 114, 114, 117, 111, 110, + 82, 83, 104, 102, 97, 99, 97, 97, 58, 56, 84, 84, + 83, 122, 76, 105, 112, 126, 120, 134, 112, 120, 108, 110, + 114, 128, 73, 90, 72, 76, 98, 100, 95, 96, 101, 102, + 101, 108, 118, 126, 94, 102, 81, 83, 138, 140, 131, 130, + 88, 100, 112, 124, 105, 106, 122, 123, 121, 121, 114, 114, + 76, 108, 73, 83, 93, 95, 110, 111, 98, 99, 103, 103, + 105, 112, 98, 108, 114, 95, 117, 98, 120, 116, 116, 115, + 231, 238, 150, 146, 124, 126, 115, 122, 117, 121, 112, 112, + 74, 73, 72, 74, 60, 61, 62, 61, 85, 85, 101, 101, + 67, 69, 50, 51, 83, 83, 110, 110, 118, 113, 112, 111, + 199, 124, 184, 115, 176, 117, 165, 120, 138, 115, 116, 114, + 52, 116, 36, 107, 49, 99, 72, 106, 91, 107, 104, 105, + 140, 138, 141, 135, 154, 147, 166, 159, 139, 136, 116, 115, + 130, 119, 180, 157, 183, 149, 136, 121, 119, 114, 111, 110, + 104, 129, 113, 154, 111, 148, 108, 132, 105, 117, 106, 111, + 114, 35, 99, 65, 113, 94, 110, 98, 111, 107, 107, 106, + 106, 110, 128, 135, 162, 175, 143, 155, 115, 116, 109, 109, + 168, 155, 112, 109, 125, 125, 126, 122, 126, 124, 111, 112, + 128, 96, 160, 77, 151, 77, 121, 80, 114, 94, 107, 103, + 97, 104, 101, 116, 56, 79, 74, 83, 92, 95, 104, 106, + 63, 68, 76, 77, 110, 107, 96, 90, 85, 83, 97, 96, + 116, 110, 46, 42, 103, 100, 122, 120, 102, 101, 104, 104, + 106, 101, 109, 98, 96, 61, 67, 35, 72, 61, 96, 93, + 88, 80, 81, 76, 113, 110, 144, 143, 88, 89, 93, 94, + 95, 96, 100, 101, 136, 132, 166, 160, 148, 147, 115, 116, + 80, 78, 130, 129, 120, 108, 91, 85, 95, 91, 104, 102, + 151, 147, 106, 109, 110, 110, 64, 69, 68, 67, 96, 96, + 90, 166, 97, 128, 99, 120, 104, 121, 109, 118, 105, 109, + 122, 138, 110, 143, 75, 97, 83, 94, 89, 94, 102, 103, + 136, 142, 103, 110, 83, 89, 99, 101, 138, 138, 120, 122, + 168, 88, 105, 90, 109, 107, 110, 111, 106, 105, 103, 102, + 68, 72, 102, 104, 92, 102, 65, 75, 89, 94, 106, 106, + 83, 74, 93, 85, 73, 66, 106, 102, 100, 92, 99, 97, + 93, 99, 101, 96, 116, 112, 125, 120, 88, 88, 96, 96, + 44, 98, 93, 115, 104, 116, 103, 107, 112, 113, 107, 107, + 93, 83, 105, 99, 93, 84, 127, 125, 141, 143, 117, 118, + 106, 103, 126, 121, 137, 123, 123, 114, 147, 142, 127, 123, + 103, 110, 89, 91, 121, 124, 66, 71, 68, 69, 96, 97, + 114, 105, 68, 65, 69, 67, 96, 94, 131, 130, 123, 121, + 111, 104, 130, 121, 95, 95, 72, 74, 88, 88, 105, 104, + 135, 124, 110, 98, 114, 111, 159, 158, 111, 113, 104, 106, + 103, 108, 94, 107, 55, 57, 115, 118, 121, 122, 111, 111, + 97, 99, 106, 111, 119, 126, 59, 62, 111, 112, 124, 125, + 86, 93, 100, 110, 118, 145, 113, 132, 120, 125, 112, 112, + 101, 115, 78, 149, 81, 114, 111, 121, 108, 112, 107, 108, + 104, 104, 94, 96, 84, 83, 135, 132, 71, 69, 88, 86, + 100, 98, 62, 60, 81, 80, 90, 89, 63, 66, 89, 90, + 123, 116, 108, 99, 90, 86, 91, 92, 65, 65, 88, 88, + 84, 79, 115, 109, 123, 111, 99, 99, 134, 136, 121, 123, + 127, 137, 84, 88, 104, 107, 128, 130, 74, 69, 89, 89, + 118, 112, 143, 132, 141, 131, 113, 113, 99, 102, 104, 105, + 117, 115, 100, 99, 131, 126, 90, 88, 145, 144, 128, 127, + 112, 114, 131, 133, 85, 84, 118, 119, 151, 152, 117, 117, + 110, 105, 162, 140, 116, 107, 140, 134, 124, 122, 113, 113, + 107, 110, 124, 133, 98, 103, 99, 107, 109, 113, 112, 112, + 115, 105, 82, 77, 125, 122, 133, 132, 118, 120, 113, 113, + 101, 88, 84, 80, 97, 99, 91, 91, 94, 94, 101, 100, + 121, 86, 139, 108, 106, 93, 103, 99, 112, 108, 108, 107, + 113, 83, 105, 102, 125, 125, 114, 115, 110, 112, 108, 109, + 93, 112, 113, 121, 125, 131, 101, 101, 107, 109, 111, 111, + 98, 102, 117, 126, 80, 84, 107, 109, 83, 84, 96, 97, + 132, 136, 112, 118, 94, 93, 121, 118, 99, 98, 102, 103, + 122, 127, 128, 133, 118, 104, 102, 88, 100, 94, 104, 102, + 115, 116, 102, 105, 140, 142, 135, 130, 90, 88, 100, 101, + 94, 86, 112, 112, 89, 121, 92, 101, 109, 108, 110, 112, + 99, 93, 129, 114, 109, 99, 131, 119, 102, 97, 103, 103, + 103, 116, 124, 101, 115, 95, 105, 101, 94, 91, 100, 100, + 113, 90, 94, 86, 92, 92, 117, 111, 106, 103, 106, 105, + 115, 99, 110, 91, 107, 104, 81, 90, 108, 113, 112, 113, + 113, 114, 93, 101, 101, 102, 101, 126, 93, 103, 104, 105, + 117, 106, 124, 107, 104, 119, 108, 133, 104, 111, 104, 106 +}; + +static const float wmavoice_lsp10_intercoeff_a[32][2][10] = { + { { 0.5108627081, 0.0480548441, -1.5099149644, 0.6736935377, + 0.7536551058, 0.7651474178, 0.8510628343, 0.6667704582, + 0.7576012611, 0.7091397047 }, + { 0.1351471841, -0.1965375543, -1.6313457787, 0.3218626380, + 0.4132472873, 0.4663473070, 0.5805781186, 0.3962165117, + 0.4818550050, 0.4907165468 } }, + { { 0.8556320667, 0.7774704993, -0.0175759494, -0.1882298589, + 0.1892164350, 0.4850396216, 0.6270319819, 0.6327089071, + 0.6513319910, 0.6075088978 }, + { 0.4374088347, 0.3505934179, -0.0762144327, -0.2830760479, + -0.0626451969, 0.1500318050, 0.2602472305, 0.2781780064, + 0.3167395592, 0.3596626520 } }, + { { 0.1899779737, 0.0650856197, 0.1699010432, 0.9122628570, + 0.9097705483, 0.7433397174, 0.6304935217, 0.5164704025, + 0.4174703658, 0.5215242505 }, + { 0.0704856217, 0.0169009864, 0.0188394487, 0.5587704182, + 0.5194473267, 0.3539164960, 0.2426626086, 0.1721164286, + 0.1371548772, 0.2594856918 } }, + { { 0.8858859241, 0.9100474715, 0.8921859264, 0.9332397878, + 1.0225475132, 1.0555013716, 1.0983552337, 1.1290244758, + 1.0363244414, 0.9277705550 }, + { 0.4810934663, 0.5782935023, 0.6835935414, 0.7650781870, + 0.9018090069, 0.9996321201, 1.0219936669, 1.0474705994, + 0.9109474719, 0.7774704993 } }, + { { 0.4359549880, 0.2275702953, 0.0993548632, 0.1763395071, + 0.1055856347, 0.1018471718, 0.1170087159, 0.1221317947, + 0.1834010482, 0.2988780141 }, + { 0.1573702693, 0.1041317880, 0.0506856143, 0.0781702399, + 0.0058932900, -0.0026913285, -0.0031067133, 0.0070702136, + 0.0116394460, 0.0566394627 } }, + { { 0.8528628349, 0.8028782010, 0.4680088460, 0.9055474699, + 1.3742399514, 1.1093629301, 0.4122780561, 0.4003703594, + 0.6360319853, 0.6415704489 }, + { 0.4252934456, 0.3823703527, 0.1676856577, 0.5241550207, + 1.1995706558, 0.9088013172, 0.1224087179, 0.0730471611, + 0.3071857095, 0.3772472739 } }, + { { 0.5508781075, 0.2829549313, -0.0022067130, 0.1042702496, + 1.0318244398, 1.3258476257, 1.3550630212, 0.9931936562, + 0.7195243239, 0.6807550788 }, + { 0.2679318488, 0.0960317850, -0.1357529163, -0.1291759908, + 0.6451012194, 0.9968628883, 0.9510321021, 0.6608166099, + 0.3799472749, 0.3735780418 } }, + { { 0.9967244267, 1.0255244374, 0.9800398052, 0.7939474285, + 0.8288397491, 0.8390166759, 0.8660166860, 0.9247936308, + 0.9127474725, 0.8684397638 }, + { 0.7921474278, 0.9416859448, 0.8547320664, 0.5348165631, + 0.6231550574, 0.6703012288, 0.6987550855, 0.8147858977, + 0.7406397164, 0.6496012211 } }, + { { 0.1439394951, -0.3193529844, -0.2024914026, -0.1854606271, + 0.0877240896, 0.1617318094, 0.3087087870, 0.3777318895, + 0.3910242021, 0.4797780812 }, + { -0.0157067180, -0.1778452396, -0.1554836929, -0.1759760082, + -0.0607759655, -0.0161221027, 0.0393317640, 0.0758856237, + 0.1163856387, 0.1947548985 } }, + { { 1.1021629274, 0.9958244264, 0.4658626914, 0.3089164793, + 0.3740626574, 0.2962472439, 0.3170857131, 0.2420395315, + 0.2649549246, 0.2936857045 }, + { 0.4700857699, 0.1809087396, 0.0311625302, 0.0106009841, + 0.0311625302, 0.0266625285, 0.0221625268, 0.0156548321, + 0.0551163852, 0.1010164022 } }, + { { 0.2925087810, 0.3418011069, 0.7339243293, 0.7322627902, + 0.7288704813, 0.7924935818, 0.7724166512, 0.7819012702, + 0.8325782120, 0.7954705060 }, + { 0.0559471548, -0.0456144214, -0.0462374985, -0.1005144417, + -0.0511528850, -0.0455451906, -0.0044220984, 0.0451471508, + 0.1232394874, 0.2085318267 } }, + { { 0.2230702937, -0.9052532017, 1.2441552877, 1.0825706124, + 0.9088705480, 0.8797243834, 0.8648397624, 0.8091089725, + 0.7633474171, 0.7468704879 }, + { -0.2030452490, -1.4167303145, 1.3542322516, 0.8369397521, + 0.6148473620, 0.5560704172, 0.5450627208, 0.4978473186, + 0.4200319052, 0.4904396236 } }, + { { 0.6088242829, 0.5965704322, 0.6547242999, 0.8554936051, + -0.2989298999, 0.2404472232, 0.3573780358, 0.7499166429, + 0.7691628039, 0.6824858487 }, + { 0.2582395375, 0.2721549273, 0.3462318778, 0.4820626974, + -0.4780299664, -0.0712990463, 0.0200163722, 0.4246703684, + 0.4660011530, 0.4172626734 } }, + { { 1.1749937236, 1.0773090720, 1.0566782951, 1.0249013603, + 0.9947167337, 0.9626628757, 0.9562244117, 0.9072782397, + 0.7654243410, 0.6448935270 }, + { 1.1595552564, 0.9340013266, 0.3959395885, 0.3693549633, + 0.3915780485, 0.3104395568, 0.3499011099, 0.2236933708, + 0.1638087332, 0.1811856627 } }, + { { 0.9572628736, 0.9389859438, 0.6619243026, 0.6849089265, + 0.7276935577, 0.7839781940, 0.7987243533, 0.7748397291, + 0.7101089358, 0.7277627885 }, + { 0.5809935033, 0.5575934947, 0.3544703424, 0.3636780381, + 0.3736472726, 0.4486242235, 0.4684934616, 0.4481396079, + 0.3456780314, 0.4478626847 } }, + { { 0.1259394884, 1.3096476197, 1.0794552267, 1.0009475052, + 0.9061013162, 0.9216782451, 0.8954397738, 0.9160013199, + 0.8575012982, 0.7479089499 }, + { -0.3689222336, 1.5293861628, 0.7323320210, 0.4102703631, + 0.3825780451, 0.2828164697, 0.2644010782, 0.2455010712, + 0.2482010722, 0.2335241437 } }, + { { 0.5380704105, 0.1600702703, -0.0657605827, -0.2390452623, + -0.3885837793, -0.4150299430, -0.3001760542, -0.1451683044, + 0.1312010288, 0.2798395455 }, + { 0.2074933648, 0.0560163856, -0.0956682861, -0.2893068194, + -0.3889991641, -0.3918376267, -0.3550068438, -0.2649375796, + -0.0554451942, 0.1167317927 } }, + { { 0.6092396677, 0.5101011693, 0.4012011290, 0.5416011810, + 0.5715781152, 0.6476627588, 0.6988243163, 0.7306012511, + 0.7531704903, 0.6534781456 }, + { 0.2060395181, 0.1409625709, 0.1024702489, 0.1834010482, + 0.1946856678, 0.2547779977, 0.3134857118, 0.3283011019, + 0.3837549686, 0.3501780331 } }, + { { 0.4516011477, 0.5351627171, 0.8068243563, 0.7049858570, + 0.7165473998, 0.6005858183, 0.4870473146, 0.2500010729, + 0.3132087886, 0.4462703764 }, + { 0.1053087115, 0.1348702610, 0.4457857609, 0.3499703407, + 0.3537780344, 0.2628780007, 0.1665087342, 0.0200856030, + 0.0329625309, 0.1525241137 } }, + { { 0.7058166265, 0.7305320203, 1.1684860289, 1.4524707496, + 1.3212091625, 1.2613245249, 1.1712552607, 1.1154552400, + 1.0487167537, 0.9153782427 }, + { 0.2286087573, 0.2851703167, 1.2016475797, 1.5154707730, + 1.2726091444, 1.1459167898, 0.9801090360, 0.9296397865, + 0.8490551412, 0.6772243083 } }, + { { 0.6686396897, 0.5728935003, 0.4734780788, 0.6970243156, + 0.5852165818, -0.0762836635, -0.2054683268, -0.1380375326, + 0.1282933354, 0.3467164934 }, + { 0.2925087810, 0.2344933748, 0.1677548885, 0.2747856975, + 0.2097087502, -0.2795452774, -0.3761222363, -0.3183837533, + -0.0834836662, 0.1482318044 } }, + { { 0.6559704542, 0.7737320364, 0.9867551923, 0.9912551939, + 0.9508936405, 0.9114320874, 0.8336859047, 0.7905551195, + 0.7672935724, 0.7532397211 }, + { 0.1843702793, 0.2565087676, 0.7571858764, 0.7545551062, + 0.6793704629, 0.5981627405, 0.5078165531, 0.4282011390, + 0.3948318958, 0.4502165318 } }, + { { 0.4430857599, 0.6102781296, 0.8485012949, 0.8573628366, + 0.9078320861, 0.9979705811, 1.0411013663, 1.0524552166, + 1.0194321275, 0.9023628533 }, + { 0.0070009828, 0.0084548295, 0.1613856554, 0.3484472632, + 0.4385857582, 0.5895088911, 0.6367935240, 0.6736935377, + 0.7026320100, 0.5924165845 } }, + { { 1.0532859862, 1.1059706211, 1.1311013997, 1.1250783205, + 1.0425552130, 0.9993551970, 0.9673013389, 0.9386397898, + 0.8836013079, 0.8336859047 }, + { 0.9791398048, 1.1481321752, 1.1275706291, 1.0082167387, + 0.8809705377, 0.8031551242, 0.7287320197, 0.6496704519, + 0.5211088657, 0.4734088480 } }, + { { -0.0251221061, -0.0443682671, 0.1282241046, 0.3850703537, + 0.4252934456, 0.4547857642, 0.4690473080, 0.4873242378, + 0.6001012027, 0.5882627368 }, + { -0.0562759638, -0.0246374905, 0.0070009828, 0.0971394777, + 0.1232394874, 0.1278779507, 0.1302317977, 0.1462241113, + 0.2073549032, 0.2446010709 } }, + { { 1.1749244928, 1.1155937016, 0.9236167073, 0.6288319826, + 0.6515396833, 0.5391781032, 0.5398011804, 0.4997165501, + 0.4066703618, 0.3998857439 }, + { 0.9403013289, 0.7346166372, 0.1841625869, 0.1319625676, + 0.1395087242, 0.0857856274, 0.0952702463, 0.0860625505, + 0.0829471648, 0.1132010221 } }, + { { 0.9047167003, 0.9840551913, 0.9933321178, 0.9360090196, + 0.9164859354, 0.9213320911, 0.8701705337, 0.8815936148, + 0.8414397538, 0.8188012838 }, + { 0.0961010158, -0.0147374868, 0.0202240646, 0.1002548635, + 0.1407548785, 0.1837472022, 0.1858241260, 0.2064549029, + 0.2228626013, 0.2859318554 } }, + { { 0.4034165144, 0.1918472052, 2.1959402561, 0.4763165414, + 0.6577012241, 0.7036704719, 0.6626858413, 0.7650089562, + 0.7702704966, 0.6543781459 }, + { 0.0940933228, -0.1222529113, 2.3491480052, 0.1385394931, + 0.3052472472, 0.3665857315, 0.3350857198, 0.4722319245, + 0.4313857555, 0.3846549690 } }, + { { 0.8215012848, 0.8613782227, 1.0399936736, 1.4082322717, + 0.4075011313, 0.4091626704, 0.5230473280, 0.6101396680, + 0.7510243356, 0.7237474024 }, + { 0.4810934663, 0.5670088828, 0.9207782447, 1.3007860780, + 0.0453548431, 0.0858548582, 0.1803548932, 0.2790087759, + 0.3974626660, 0.4581780732 } }, + { { 1.5921784937, 1.4987169206, 1.1321398616, 0.8235089779, + 0.6888550818, 0.6621319950, 0.6192089021, 0.6533396840, + 0.7196627855, 0.6549319923 }, + { 1.5911400318, 1.4768399894, 0.9358705580, 0.4674549997, + 0.3522549570, 0.3144549429, 0.2985318601, 0.3559241891, + 0.4061857462, 0.3958703578 } }, + { { 0.7975474298, 0.8712782264, 0.8974474669, 0.3008164763, + 0.5562088788, 0.6655935347, 0.8921166956, 1.0918475389, + 0.9544936419, 0.8554936051 }, + { 0.3769703507, 0.4930703938, 0.6619243026, -0.0382759571, + 0.1766856611, 0.3015780151, 0.5952550471, 0.8903859258, + 0.7395320237, 0.6205935180 } }, + { { 0.2206472158, 2.4467634261, 1.2920629978, 1.0239321291, + 0.9014628530, 0.8552166820, 0.8219859004, 0.9005628526, + 0.7614781857, 0.7763628066 }, + { -0.2722068131, 2.8967635930, 1.3039706945, 0.7695089579, + 0.6132550538, 0.5701242685, 0.5737935007, 0.6533396840, + 0.5422934890, 0.5150857866 } }, +}; + +static const float wmavoice_lsp10_intercoeff_b[32][2][10] = { + { { 0.4881048799, -0.1998192370, -0.3872502148, 0.0109423101, + 0.0406953394, 0.1788437665, 0.1673750877, 0.3409781158, + 0.4061202109, 0.5221177042 }, + { 0.1492218077, -0.1372330189, -0.2683691680, -0.0621950924, + -0.0624572337, -0.0068177581, -0.0076041818, 0.0680235624, + 0.1055752933, 0.1199930608 } }, + { { 0.7934338748, 0.0012430847, 0.4239458144, 0.5521328747, + 0.6497149467, 0.6423749924, 0.7170197070, 0.7169541717, + 0.7778364718, 0.8397018015 }, + { 0.2768190503, -0.0491535664, -0.0325731337, 0.0261465013, + 0.0469867289, 0.0649434030, 0.0781815350, 0.1031504869, + 0.1194687784, 0.2451654971 } }, + { { 0.7212139666, 0.1658677757, 0.0101558864, 0.5636015534, + 1.3175852597, 1.1911676526, 1.1266809106, 0.8230558336, + 0.8604109585, 0.8094900250 }, + { 0.3658815324, 0.0816549063, -0.2092563212, 0.1946377754, + 1.0856558084, 0.9491457641, 0.8461242616, 0.5193652213, + 0.5975488424, 0.5293265879 } }, + { { 0.9507186115, 0.9078585207, 0.8773190677, 0.8677509129, + 0.8024122119, 0.8127667904, 0.8246286809, 0.8779088855, + 0.9454102516, 0.9863698184 }, + { 0.6883807778, 0.6900191605, 0.7059442401, 0.6552854478, + 0.5843107104, 0.5553441048, 0.5887671113, 0.6494528055, + 0.7725936472, 0.7792782485 } }, + { { 0.2399882078, 0.1938513517, 0.4441962242, 0.4475385249, + 0.3055235147, 0.1745184362, 0.1174371839, 0.0679580271, + 0.0782470703, 0.1695377529 }, + { 0.0170370936, 0.0253600776, 0.2072205544, 0.1907711923, + 0.1096384823, 0.0327000320, -0.0134368241, -0.0461389422, + -0.0372916758, -0.0243156850 } }, + { { 0.5457104146, 0.3774812818, 0.5235594809, 0.2994287312, + 0.2394639254, 0.5731041729, 0.9971176088, 1.1646913886, + 0.9028123021, 0.7777709365 }, + { 0.2288472056, 0.1181580722, 0.2074171603, 0.0355180502, + -0.0024924278, 0.2596487999, 0.7474936247, 0.9103488624, + 0.5927647650, 0.4772915542 } }, + { { 0.6541713476, 0.6412608922, 0.7625012100, 0.7826205492, + 0.4839106202, 0.3311478198, 0.4577620327, 0.8572652638, + 0.9442306161, 0.8282986581 }, + { 0.2852075696, 0.2614837885, 0.4221763611, 0.4314823747, + 0.1434547007, 0.0435788929, 0.1397191882, 0.5525916219, + 0.6752081811, 0.5487250388 } }, + { { 0.6742251515, 1.0610800683, 1.0500701368, 0.9570100009, + 0.9325653315, 0.9243078828, 0.9148707986, 0.8317720294, + 0.7696445584, 0.6784849465 }, + { 0.2283884585, 0.9739181101, 0.5336519182, 0.4974764287, + 0.3998288214, 0.3674543798, 0.2719694376, 0.2608939707, + 0.2087934017, 0.1675716937 } }, + { { 0.3736146986, -1.5457833707, 0.9216864705, 0.7959242165, + 0.7358283401, 0.7233110964, 0.7271121442, 0.6852350831, + 0.6891672015, 0.6589554250 }, + { 0.1246460676, -1.7167649865, 0.7037160397, 0.4803061783, + 0.4694928527, 0.4654951990, 0.5208069980, 0.5305717587, + 0.5288023055, 0.5278192759 } }, + { { 1.0116009116, 0.9882703424, 0.8393741250, 0.8889843524, + 0.8934407532, 0.8906227350, 0.9222107530, 0.8973073363, + 0.9257496595, 0.9306648076 }, + { 0.5097970665, -0.0106843412, 0.1419473886, 0.2804890275, + 0.3719763160, 0.3694859743, 0.4640534222, 0.5034401417, + 0.5592106879, 0.6652468145 } }, + { { 0.9718209803, 0.7615181804, 0.2172474563, 0.4920369983, + 0.4310891628, 0.5038333535, 0.4668059051, 0.5339140594, + 0.4453758597, 0.4050061107 }, + { 0.6543679535, 0.1205173433, -0.0050483048, 0.1580035388, + 0.1308719218, 0.1700620353, 0.1740596890, 0.2179683447, + 0.1967349052, 0.1703897119 } }, + { { 0.7663022578, 0.4025157690, 1.3811545074, 1.1642981768, + 1.0709758997, 0.9812580645, 1.0092416406, 0.9089070857, + 0.7776398659, 0.8189926445 }, + { 0.3471384346, 0.0602248609, 1.3968829811, 1.0841484964, + 0.8940305710, 0.7313719392, 0.7345176339, 0.5304406881, + 0.4076275229, 0.4535677731 } }, + { { 0.1300854981, 0.1323136985, 0.7564064264, 0.7335346043, + 0.7924508452, 0.6039057672, 0.6896914840, 0.3694859743, + 0.2825861573, 0.3179096878 }, + { -0.0208423138, -0.0530856848, 0.3449102342, 0.3819376826, + 0.4466865659, 0.2807511687, 0.3842969537, 0.1144880950, + 0.0617321730, 0.0767397583 } }, + { { 0.7559476793, 0.8462553322, 0.6452585459, 1.1308751702, + 1.0606868565, 0.9498666525, 0.7425129414, 0.6221901178, + 0.6574481130, 0.6976212561 }, + { 0.3420922160, 0.4310236275, 0.2800958157, 0.9317133725, + 0.8210897744, 0.6144569516, 0.3227593005, 0.2464762032, + 0.2769501209, 0.3521846533 } }, + { { 0.7609938979, 0.6943444908, 1.1490939856, 0.4350868165, + 0.6101971567, 0.6246149242, 0.7370079756, 0.6522052884, + 0.6966382265, 0.7565374970 }, + { 0.3939306438, 0.3449102342, 0.9874839187, 0.0910919905, + 0.2804234922, 0.2888775468, 0.4060546756, 0.3284608722, + 0.3483836055, 0.4819445610 } }, + { { 0.7828826904, 1.1833034158, 1.9916158915, 0.8667678833, + 0.9218830764, 0.8856420517, 0.9373494089, 0.7415299118, + 0.7450032830, 0.7074515522 }, + { 0.4685098231, 1.1713104546, 1.9853245020, 0.6206828058, + 0.6664264500, 0.6033814847, 0.6089519858, 0.3784643114, + 0.4212588668, 0.3441893458 } }, + { { 0.4671335816, 0.4177199602, 0.0804097354, -0.1836975515, + -0.1802241802, -0.0775958896, -0.0250365734, 0.0884050429, + 0.2136430144, 0.3472039700 }, + { 0.1187478900, 0.1122598946, -0.0381436348, -0.2284581661, + -0.2302276194, -0.1738672554, -0.1350048184, -0.0547896028, + 0.0000634491, 0.0545888245 } }, + { { 0.5545576811, 0.4791920781, 0.8204999566, 0.8462553322, + 0.9212277234, 0.8946203887, 0.9659883380, 0.9137566984, + 0.9225384295, 0.9207034409 }, + { 0.1176993251, -0.0429277122, -0.0330318809, 0.0566859543, + 0.0983008742, 0.1593797803, 0.1732077301, 0.2320584357, + 0.2739354968, 0.3753186166 } }, + { { 0.7157745361, 0.6367389560, -1.2036890686, 0.7107283175, + 0.6885118484, 0.7332724631, 0.7436270416, 0.7113181353, + 0.5935511887, 0.6023984551 }, + { 0.3664058149, 0.3280676603, -1.3082178831, 0.3909815550, + 0.3641776145, 0.3926854730, 0.3898674548, 0.4086760879, + 0.3127979338, 0.3949792087 } }, + { { 1.0267395675, 1.0621941686, 1.0415505469, 0.9971176088, + 0.9764739871, 0.9904330075, 0.9591071308, 0.9338760376, + 0.9026156962, 0.9073997736 }, + { 0.9855833948, 1.0548542142, 0.9787021875, 0.8573307991, + 0.8360973597, 0.8193203211, 0.7386463583, 0.7038471103, + 0.6333966553, 0.6434235573 } }, + { { 0.6235008240, 0.7635497749, 0.8094900250, 0.7227212787, + -0.0610809922, -0.1357912421, -0.2359291911, 0.0800165236, + 0.3972729445, 0.5078965425 }, + { 0.2983146310, 0.4983939230, 0.4145742655, 0.3284608722, + -0.3203386664, -0.3495018780, -0.4734291434, -0.1808139980, + 0.1211071610, 0.2001427412 } }, + { { 0.8925887942, 0.8804647624, 0.6153089106, 0.6760601401, + 0.7887153327, 1.0065546930, 1.0829033256, 1.0347348750, + 0.9800128937, 0.9125770628 }, + { 0.5955827832, 0.6195687056, 0.2924164534, 0.3553958833, + 0.5417127609, 0.8713553548, 0.9977729619, 0.8817754686, + 0.7645328045, 0.6604627371 } }, + { { 1.1581378579, 1.0359145105, 0.7731179297, 0.6839243770, + 0.6839899123, 0.6664264500, 0.6910677254, 0.6579068601, + 0.6779606640, 0.6243527830 }, + { 1.1508634388, 0.8400294781, 0.2358594835, 0.2542749047, + 0.2484422624, 0.2620736063, 0.2676441073, 0.2713796198, + 0.3068997562, 0.3223005533 } }, + { { 0.1376220584, 1.2572927773, 0.8593623936, 0.6218624413, + 0.5128116906, 0.5393534899, 0.4436064065, 0.4334484339, + 0.4494390488, 0.4002220333 }, + { -0.1159995794, 1.2433337569, 0.4805027843, 0.2632532418, + 0.1769432425, 0.1868390739, 0.1555131972, 0.1530228555, + 0.1490252018, 0.1559064090 } }, + { { 0.1817273200, -0.0085216761, 0.0739872754, 0.1808098257, + 0.2770811915, 0.3344901204, 0.4292541742, 0.5404020548, + 0.5780193210, 0.5707449019 }, + { -0.0035409927, -0.0188107193, -0.0057691932, 0.0132360458, + 0.0560961366, 0.0534747243, 0.1002013981, 0.1737320125, + 0.1706518531, 0.1637706459 } }, + { { 0.9648087025, 1.0030813217, 0.9501943290, 0.8381944895, + 0.7545059025, 0.7621735334, 0.7121700943, 0.7328792512, + 0.7534573376, 0.7414643764 }, + { 0.1872322857, -0.0081939995, 0.0663851798, 0.0963348150, + 0.0509188473, 0.0565548837, 0.0471833348, 0.0809340179, + 0.1049199402, 0.1751082540 } }, + { { 0.6792713702, 0.9521603882, 0.5296542645, 0.3657504618, + 0.3905883431, 0.3121425807, 0.2726903260, 0.3156159520, + 0.2859284580, 0.3179096878 }, + { 0.2307477295, 0.3771536052, 0.0743804872, 0.0260154307, + 0.0477731526, 0.0391880274, 0.0228042006, 0.0572757721, + 0.0337485969, 0.0492149293 } }, + { { 0.8649328947, 0.9505875409, 1.0443030298, 1.1704584956, + 1.2709241211, 1.3232212961, 1.2477901578, 1.1513877213, + 1.0346038043, 0.9695272446 }, + { 0.4620873630, 0.5685822368, 0.8975039423, 1.0476453304, + 1.2278674245, 1.2290470600, 1.1962138712, 1.0051129162, + 0.8706344664, 0.7477557659 } }, + { { 0.4188340604, 0.6011532843, 0.4726385474, 0.6389671564, + 0.6753392518, 0.7842589319, 0.6147846282, 0.6708828509, + 0.6406055391, 0.5398777723 }, + { 0.1012499630, 0.2312064767, 0.1773364544, 0.2800302804, + 0.3348177969, 0.4343003929, 0.2822584808, 0.3293128312, + 0.3024433553, 0.2401848137 } }, + { { 0.5049474537, 0.7943513691, 0.9536021650, 0.9407572448, + 0.9823721647, 0.9747045338, 1.0145500004, 0.9629737139, + 0.9526191354, 0.9283710718 }, + { 0.0566204190, 0.0973178446, 0.5812305510, 0.5687133074, + 0.6834000945, 0.6616423726, 0.7611905038, 0.6683925092, + 0.6463071108, 0.6118355393 } }, + { { 0.8969141245, 0.9359731674, 0.8756151497, 0.8419300020, + 0.8353109360, 0.6807131469, 0.3358008265, 0.3386188447, + 0.3524467945, 0.4495045841 }, + { 0.5298508704, 0.4606455863, 0.4934132397, 0.4415748119, + 0.4015327394, 0.2052544951, -0.0329663455, -0.0154684186, + 0.0418094397, 0.1631152928 } }, + { { 0.6345762908, 2.5209445655, 1.0373562872, 0.9166402519, + 0.8865595460, 0.8907538056, 0.8522190452, 0.7290782034, + 0.7385808229, 0.6345107555 }, + { 0.2641707361, 2.5696372986, 0.8539884984, 0.6532538533, + 0.6087553799, 0.5851626694, 0.5276226699, 0.4330552220, + 0.3971418738, 0.3599833548 } }, +}; + +static const float wmavoice_lsp16_intercoeff_a[32][2][16] = { + { { 0.5337238312, 0.4810695648, -0.3766536713, -0.1204767227, + -0.0898437500, -0.0070896149, 0.1134738922, 0.1337728500, + 0.3739156723, 0.3849058151, 0.4220180511, 0.5404901505, + 0.5224876404, 0.5502910614, 0.5313453674, 0.4405946732 }, + { 0.1775283813, 0.1679325104, -0.2702789307, -0.1359367371, + -0.1452455521, -0.0888595581, -0.0256662369, -0.0023736954, + 0.1074047089, 0.1431636810, 0.1357412338, 0.2045526505, + 0.2686481476, 0.3404531479, 0.3209333420, 0.1493968964 } }, + { { 0.7402400970, 0.0838251114, 0.6486282349, 0.6145095825, + 0.7331047058, 0.7183008194, 0.7436847687, 0.7627944946, + 0.7653779984, 0.7795667648, 0.8399305344, 0.8393154144, + 0.8219690323, 0.7474164963, 0.6681070328, 0.6490793228 }, + { 0.2850513458, -0.0544128418, -0.0300130844, 0.0204677582, + 0.0328931808, 0.0589332581, 0.0796422958, 0.1187639236, + 0.1320505142, 0.1539077759, 0.2189874649, 0.2865276337, + 0.2973947525, 0.2614307404, 0.2416648865, 0.2428951263 } }, + { { 0.6129922867, 0.7300701141, 0.2073822021, 0.5005893707, + 0.5713691711, 0.5374965668, 0.6293134689, 0.5639057159, + 0.7402811050, 0.6982889175, 0.4668397903, 0.6698703766, + 0.8758535385, 0.8678569794, 0.8678569794, 0.7810840607 }, + { 0.2986249924, 0.3269615173, 0.0096416473, 0.1800708771, + 0.2474060059, 0.2203407288, 0.3007984161, 0.2674179077, + 0.4424810410, 0.4046306610, 0.2063980103, 0.4230022430, + 0.6222190857, 0.6574449539, 0.6776618958, 0.6604385376 } }, + { { 0.7258052826, 0.5073966980, -0.3947381973, 0.5254812241, + 1.0561246872, 0.9706230164, 0.9727144241, 0.9185838699, + 0.8184833527, 0.9093980789, 0.8645353317, 0.7870302200, + 0.6347675323, 0.5123996735, 0.2846002579, 0.3252801895 }, + { 0.4306297302, 0.2182903290, -0.4902458191, 0.1783485413, + 0.7783365250, 0.7152252197, 0.7404451370, 0.6012639999, + 0.5421304703, 0.6619558334, 0.6316919327, 0.5596818924, + 0.3952398300, 0.3567333221, 0.1505041122, 0.1290159225 } }, + { { 0.3077287674, 0.2543363571, 0.2834520340, 0.5282287598, + 0.5350360870, 0.4943971634, 0.4521999359, 0.3086309433, + 0.2372770309, 0.0819387436, -0.1385612488, -0.0848407745, + -0.0380916595, 0.1192150116, 0.3228197098, 0.3012905121 }, + { 0.0567188263, 0.0196886063, 0.0682420731, 0.2102527618, + 0.2452325821, 0.2060699463, 0.1620273590, 0.0784120560, + 0.0418329239, -0.0508041382, -0.2193880081, -0.1644783020, + -0.1361827850, -0.0307512283, 0.1486587524, 0.2356367111 } }, + { { 0.4387903214, 0.5723943710, 0.6147556305, 0.9973602295, + 1.1645498276, 1.1898927689, 1.0326681137, 0.6939010620, + 0.6064310074, 0.4686441422, 0.4646663666, 0.4895582199, + 0.5654230118, 0.6004848480, 0.6179132462, 0.6439123154 }, + { 0.1324195862, 0.2426080704, 0.3132238388, 0.7359752655, + 0.9749288559, 0.9535636902, 0.8105278015, 0.4118890762, + 0.3013315201, 0.2006158829, 0.2331352234, 0.2535161972, + 0.3375005722, 0.4103307724, 0.4102897644, 0.4529380798 } }, + { { 0.7335557938, 0.9203472137, 0.4852113724, 0.8646993637, + 0.7304391861, 0.7503690720, 0.6289854050, 0.6900463104, + 0.6421079636, 0.5184278488, 0.4444904327, 0.2660236359, + 0.2143125534, 0.2406396866, 0.4836940765, 0.5597229004 }, + { 0.3689947128, 0.4967346191, 0.1176567078, 0.5127687454, + 0.3235168457, 0.3426265717, 0.2417469025, 0.3310623169, + 0.2629890442, 0.2130823135, 0.1329116821, 0.0468769073, + -0.0081968307, 0.0146446228, 0.2440433502, 0.3408632278 } }, + { { 0.9425325394, 0.9597969055, 0.6160678864, 0.7050962448, + 0.8063859940, 0.9063224792, 0.9890356064, 1.0038805008, + 1.0338163376, 0.9453620911, 0.9634056091, 0.8068370819, + 0.6859455109, 0.8909034729, 0.9990415573, 1.0122871399 }, + { 0.6895952225, 0.6451835632, 0.3169965744, 0.4268569946, + 0.5666122437, 0.7722673416, 0.8845882416, 0.9061584473, + 0.9550399780, 0.8118810654, 0.8601064682, 0.6129922867, + 0.5069866180, 0.7065315247, 0.7862920761, 0.7766551971 } }, + { { 0.5641517639, -0.0941905975, 0.0412998199, 0.1810550690, + 0.3459482193, 0.4213209152, 0.4401025772, 0.5397109985, + 0.5607891083, 0.6348905563, 0.6861915588, 0.7280607224, + 0.7267074585, 0.6447324753, 0.5948257446, 0.5475025177 }, + { 0.1906919479, -0.0519113541, -0.0608100891, -0.0018815994, + 0.0383062363, 0.0362558365, 0.0529870987, 0.0692672729, + 0.0953073502, 0.1327886581, 0.1390628815, 0.1904459000, + 0.2362518311, 0.2063980103, 0.2311668396, 0.2291574478 } }, + { { 0.9901428223, 0.9589767456, 0.9012374878, 0.8017930984, + 0.8929538727, 0.8512077332, 0.8790111542, 0.8832759857, + 0.8949632645, 0.9159183502, 0.9293279648, 0.9152622223, + 0.9247350693, 0.8753614426, 0.8730239868, 0.8066730499 }, + { 0.4230432510, -0.0464572906, 0.0182533264, 0.1159753799, + 0.2349395752, 0.2740612030, 0.2987070084, 0.3620643616, + 0.3923282623, 0.4694643021, 0.5202322006, 0.5356512070, + 0.5564012527, 0.5362663269, 0.4791831970, 0.5046901703 } }, + { { 0.9785375595, 0.8820457458, 0.3965110779, 0.4790191650, + 0.3907699585, 0.4195575714, 0.2938270569, 0.4091415405, + 0.3659191132, 0.4030723572, 0.4168510437, 0.5030908585, + 0.5023117065, 0.5511522293, 0.5354051590, 0.5563192368 }, + { 0.6592903137, 0.2933759689, 0.0562677383, 0.1286878586, + 0.0758285522, 0.1192560196, 0.0508956909, 0.1175336838, + 0.0684061050, 0.0988750458, 0.0923957825, 0.1819572449, + 0.1965150833, 0.2257537842, 0.3049812317, 0.2993221283 } }, + { { 0.7120265961, 0.7847747803, 0.6065950394, 0.7235908508, + 0.6740531921, 0.6535081863, 0.3734235764, 0.4788551331, + 0.4410867691, 0.6927528381, 1.0758495331, 1.1148891449, + 1.0708875656, 0.8896322250, 0.6401805878, 0.5057153702 }, + { 0.4210338593, 0.4763126373, 0.3229017258, 0.4079113007, + 0.3922462463, 0.3529195786, 0.1258993149, 0.2168960571, + 0.2207508087, 0.4605655670, 0.8759355545, 0.9526205063, + 0.8843832016, 0.7001342773, 0.4503545761, 0.3484086990 } }, + { { 0.5254402161, 0.5349540710, 0.7036199570, 0.6240234375, + 0.6464548111, 0.7537727356, 0.8311548233, 0.7334327698, + 0.3484907150, 0.1846637726, 0.0894021988, 0.3977823257, + 0.7672233582, 0.9224796295, 0.8818407059, 0.7453250885 }, + { 0.2587652206, 0.2524499893, 0.4135704041, 0.3129367828, + 0.3403711319, 0.4473199844, 0.5330266953, 0.4227561951, + 0.1080198288, -0.0044651031, -0.0727024078, 0.1583776474, + 0.5302381516, 0.7313823700, 0.6735610962, 0.5630855560 } }, + { { 0.7936325073, 0.8551034927, 0.9755849838, 0.8953323364, + 0.9345769882, 0.7202281952, 0.8388233185, 0.7941656113, + 0.7550849915, 0.7894906998, 0.8590402603, 0.7813711166, + 0.8483371735, 0.8652324677, 0.8586711884, 0.9584846497 }, + { 0.4781579971, 0.4731960297, 0.8289403915, 0.6175031662, + 0.7262973785, 0.3638277054, 0.5544328690, 0.4761896133, + 0.4388723373, 0.5021476746, 0.5630445480, 0.4562187195, + 0.5190429688, 0.5937595367, 0.6121721268, 0.6973457336 } }, + { { 1.0724458694, 1.0449705124, 0.8594503403, 0.7604160309, + 0.7837905884, 0.8136444092, 0.7623023987, 0.6098756790, + 0.6432561874, 0.6395244598, 0.6853713989, 0.7401580811, + 0.7399530411, 0.7652549744, 0.7675104141, 0.7393789291 }, + { 0.9382266998, 0.8419809341, 0.3087539673, 0.3620233536, + 0.3547649384, 0.4241094589, 0.2857894897, 0.2123851776, + 0.2355957031, 0.2794332504, 0.3219995499, 0.3898267746, + 0.3937635422, 0.4058198929, 0.4228382111, 0.4181222916 } }, + { { 1.0275421143, 1.0940570831, 1.0164289474, 0.9097671509, + 0.9400720596, 0.8976287842, 0.9175586700, 0.8900833130, + 0.9154262543, 0.9492578506, 1.0011329651, 1.0361537933, + 1.0359487534, 0.9320344925, 0.8974237442, 0.8811845779 }, + { 1.0046186447, 1.0860195160, 0.9442958832, 0.7473344803, + 0.7876043320, 0.7410602570, 0.7422084808, 0.6844692230, + 0.7256412506, 0.8455486298, 0.8969316483, 0.9362173080, + 0.9092340469, 0.8227071762, 0.7481546402, 0.7088689804 } }, + { { 0.2205047607, -0.0129537582, 0.0972347260, 0.1154832840, + 0.0951843262, 0.1532516479, 0.1288108826, 0.1749858856, + 0.1591157913, 0.2134923935, 0.2477340698, 0.2634811401, + 0.3032999039, 0.3272485733, 0.3170785904, 0.3172016144 }, + { 0.0032854080, -0.0446119308, 0.0284643173, 0.0155467987, + -0.0063104630, 0.0226001740, 0.0086984634, 0.0262088776, + 0.0173921585, 0.0360507965, 0.0366659164, 0.0215339661, + 0.0412178040, 0.1047391891, 0.1258172989, 0.0609836578 } }, + { { 0.1495609283, 0.3275766373, 0.8598194122, 0.6847562790, + 0.7550849915, 0.5662431717, 0.6930398941, 0.7526245117, + 0.7300291061, 0.7284708023, 0.6608896255, 0.5224056244, + 0.4273900986, 0.5757160187, 0.4625749588, 0.5123586655 }, + { -0.0352210999, -0.0428895950, 0.3110914230, 0.2699604034, + 0.3307752609, 0.2059469223, 0.2332172394, 0.3204412460, + 0.2846412659, 0.3354911804, 0.2448635101, 0.1514062881, + 0.1062564850, 0.2613077164, 0.2123441696, 0.3000602722 } }, + { { 0.6218910217, 0.6033554077, 0.4551525116, 0.3161764145, + 0.2864866257, 0.6195125580, 0.7577505112, 1.0062179565, + 0.8485012054, 0.6777849197, 0.7455301285, 0.3630485535, + 0.2327661514, 0.5563192368, 0.4448595047, 0.3806819916 }, + { 0.2624969482, 0.2679510117, 0.1839666367, 0.0335903168, + 0.0294075012, 0.2902593613, 0.4959144592, 0.7905979156, + 0.5748548508, 0.3753919601, 0.4855394363, 0.1089630127, + 0.0362968445, 0.3632535934, 0.2681150436, 0.2735691071 } }, + { { 0.7064495087, 0.4431781769, 0.7628355026, 0.7271585464, + 0.7812070847, 0.7806739807, 0.8909854889, 0.8958654404, + 0.9126787186, 0.9038209915, 0.9246120453, 0.9624624252, + 0.9732475281, 0.7420034409, 0.5060844421, 0.5189199448 }, + { 0.3457021713, -0.0149221420, 0.3174476624, 0.3580865860, + 0.4243965149, 0.4275541306, 0.5887155533, 0.6478490829, + 0.6320610046, 0.6627349854, 0.6868886948, 0.7396659851, + 0.7551259995, 0.5275316238, 0.3075237274, 0.3806819916 } }, + { { 0.4376831055, 0.4904603958, 0.6262788773, 0.5901098251, + 0.4176712036, 0.0221490860, -0.1612796783, -0.2236118317, + -0.1087894440, -0.0022506714, 0.1051902771, 0.3307752609, + 0.4167690277, 0.4997692108, 0.4645843506, 0.5228567123 }, + { 0.1228237152, 0.1671123505, 0.2931299210, 0.2549924850, + 0.1435737610, -0.1124801636, -0.2181987762, -0.2723293304, + -0.1573429108, -0.0837745667, -0.0325555801, 0.1024427414, + 0.1938495636, 0.2825498581, 0.2247285843, 0.2879629135 } }, + { { 0.6100807190, 0.7900238037, 0.9581155777, 0.8999662399, + 0.9277286530, 0.9720993042, 0.9966220856, 0.9630365372, + 0.9571723938, 0.8992280960, 0.8370189667, 0.7417984009, + 0.7174396515, 0.6122951508, 0.6746683121, 0.7030458450 }, + { 0.0859165192, 0.0914115906, 0.6077432632, 0.5471334457, + 0.5943746567, 0.6805324554, 0.6680250168, 0.6033554077, + 0.6302976608, 0.4874258041, 0.3647298813, 0.2770137787, + 0.2544183731, 0.2608156204, 0.3331537247, 0.4950942993 } }, + { { 0.4051227570, 1.1022176743, 0.8262338638, 0.6573219299, + 0.5948667526, 0.5426225662, 0.4987850189, 0.4370269775, + 0.4421119690, 0.3837165833, 0.3728494644, 0.3706760406, + 0.4169740677, 0.3559951782, 0.2994041443, 0.3896217346 }, + { 0.0716867447, 0.9253911972, 0.2780799866, 0.2460117340, + 0.1675224304, 0.1527595520, 0.1278266907, 0.1226596832, + 0.1165084839, 0.0982189178, 0.0952253342, 0.1113414764, + 0.1498889923, 0.0940361023, 0.0802984238, 0.1560811996 } }, + { { 0.7024717331, 0.7363853455, 0.9629545212, 0.9635286331, + 1.0819597244, 1.1529855728, 1.2984409332, 1.2693252563, + 1.2848672867, 1.2877378464, 1.2133083344, 1.0696573257, + 1.0864706039, 0.9851808548, 0.8312368393, 0.8047866821 }, + { 0.3001422882, 0.2273120880, 0.6279602051, 0.6936140060, + 0.8097076416, 0.9440498352, 1.1028738022, 1.1766471863, + 1.1199741364, 1.1608181000, 1.0665817261, 0.8872537613, + 0.9082908630, 0.7602519989, 0.6542053223, 0.7317514420 } }, + { { 0.0643463135, -0.6808919907, 0.2889881134, 0.6142225266, + 0.6356697083, 0.6825828552, 0.6259508133, 0.4945611954, + 0.5866651535, 0.6357517242, 0.5208883286, 0.4207878113, + 0.5125637054, 0.3758020401, 0.5424175262, 0.6172571182 }, + { -0.0636806488, -0.7585611343, 0.0850553513, 0.2996912003, + 0.3620643616, 0.4444084167, 0.4597454071, 0.3120756149, + 0.4016780853, 0.5026807785, 0.4111919403, 0.3183498383, + 0.3666572571, 0.1829824448, 0.3269205093, 0.4095926285 } }, + { { 0.9277286530, 0.9651279449, 0.9602069855, 0.9327726364, + 0.9208393097, 0.8868436813, 0.9011554718, 0.8569488525, + 0.9015245438, 0.8969726562, 0.9367094040, 0.9445009232, + 0.8617057800, 0.8215589523, 0.8333692551, 0.7939195633 }, + { 0.1719102859, 0.1142530441, 0.1245460510, 0.1646108627, + 0.1408672333, 0.0949792862, 0.0271930695, 0.0265779495, + -0.0064334869, -0.0109033585, 0.0152187347, 0.0252656937, + 0.0166950226, 0.0736141205, 0.1205682755, 0.1895437241 } }, + { { 0.5964250565, 0.6065130234, 0.7228116989, 0.7348270416, + 0.0718097687, 0.2369899750, 0.2456426620, 0.4961194992, + 0.6410417557, 0.6765956879, 0.6771287918, 0.7285938263, + 0.6706905365, 0.5105543137, 0.5068635941, 0.5430326462 }, + { 0.2782440186, 0.2620048523, 0.4424400330, 0.4124631882, + -0.1158838272, 0.0186223984, 0.0059919357, 0.1853609085, + 0.3568563461, 0.3791646957, 0.4100847244, 0.4654865265, + 0.4614677429, 0.3209743500, 0.3199081421, 0.3836755753 } }, + { { 0.8051557541, 0.8506336212, 0.9544658661, 0.5584516525, + 0.5874032974, 0.5727224350, 0.6177902222, 0.7659521103, + 0.9526205063, 1.0424280167, 1.0705595016, 1.0042905807, + 0.6005258560, 0.3886785507, 0.4739751816, 0.6542463303 }, + { 0.4775428772, 0.5541868210, 0.7128057480, 0.2146816254, + 0.2502765656, 0.2488822937, 0.3009214401, 0.4667987823, + 0.6929988861, 0.8599834442, 0.8784780502, 0.7463912964, + 0.3217535019, 0.1274986267, 0.2767267227, 0.5119485855 } }, + { { 0.5978193283, 0.5092830658, 1.0738401413, 0.7688636780, + 0.8214769363, 0.7682075500, 0.4970626831, 0.2783260345, + 0.2652854919, 0.3625154495, 0.5700569153, 0.5044031143, + 0.4003248215, 0.5162544250, 0.5727634430, 0.5538587570 }, + { 0.2752094269, 0.1747808456, 0.8557186127, 0.4280872345, + 0.5143680573, 0.4139804840, 0.1810960770, 0.0109539032, + 0.0317039490, 0.0842351913, 0.3129367828, 0.2614717484, + 0.1564092636, 0.2352676392, 0.3249931335, 0.3505821228 } }, + { { 0.7093610764, 0.7587757111, 1.8517618179, 1.0092525482, + 0.8078622818, 0.8792982101, 0.8210668564, 0.8600654602, + 0.6913585663, 0.6436662674, 0.6216859818, 0.6123771667, + 0.5940465927, 0.5910940170, 0.6505966187, 0.5801038742 }, + { 0.3370904922, 0.4681930542, 1.9236078262, 0.8053607941, + 0.5321245193, 0.6342344284, 0.5054693222, 0.5788326263, + 0.4400615692, 0.4086904526, 0.3924102783, 0.4220180511, + 0.3835115433, 0.4230432510, 0.5190839767, 0.3990535736 } }, + { { 0.6277141571, 1.1122236252, 1.0259838104, 0.9486427307, + 0.9184608459, 0.9059944153, 0.9080038071, 0.8282022476, + 0.8440313339, 0.7887935638, 0.7468013763, 0.6746683121, + 0.6319379807, 0.6246795654, 0.7263793945, 0.7349090576 }, + { 0.2427721024, 1.0851583481, 0.6180362701, 0.5837125778, + 0.4324750900, 0.4684801102, 0.3745307922, 0.3027257919, + 0.3646888733, 0.2409267426, 0.2158298492, 0.2052907944, + 0.2100887299, 0.2276401520, 0.3409452438, 0.4045896530 } }, + { { 0.8391513824, 0.8713426590, 1.1366233826, 1.1440868378, + 1.1443738937, 1.0877418518, 1.0516138077, 1.0099496841, + 0.9216184616, 0.8990640640, 0.9001302719, 0.8993101120, + 0.8055248260, 0.8150796890, 0.7272815704, 0.7196130753 }, + { 0.4634771347, 0.5807189941, 1.1287908554, 1.1066875458, + 1.0765056610, 0.9287538528, 0.8956193924, 0.8026132584, + 0.6725769043, 0.5856809616, 0.5527515411, 0.5183868408, + 0.4529380798, 0.5074377060, 0.4632720947, 0.5554990768 } }, +}; + +static const float wmavoice_lsp16_intercoeff_b[32][2][16] = { + { { 0.5431776047, -0.1212130189, -0.2471650839, 0.0683670044, + 0.1418520808, 0.2518971562, 0.3708084226, 0.4141484499, + 0.5712364912, 0.5852659345, 0.5670641661, 0.6401320100, + 0.6447737217, 0.6726239920, 0.4994724989, 0.5574678183 }, + { 0.2040718794, -0.1271064281, -0.2266163826, -0.0406349897, + -0.0145058036, 0.0283126831, 0.0851084590, 0.0913147926, + 0.1307432652, 0.1926501393, 0.2310355306, 0.2828245163, + 0.3171940446, 0.4424681067, 0.2960716486, 0.3510941863 } }, + { { 0.8073900938, 0.0403081179, 0.5392660499, 0.6928597689, + 0.6499369740, 0.7328097820, 0.7755761147, 0.7766191959, + 0.8820225596, 0.8423333168, 0.8898978233, 0.8488525748, + 0.8654375672, 0.6728326082, 0.6169234514, 0.6755967736 }, + { 0.3653843999, -0.0846008658, -0.0224332213, 0.1120721102, + 0.1020585299, 0.1741876006, 0.2129902244, 0.2160151601, + 0.3619422317, 0.4185815454, 0.5455245376, 0.5363975763, + 0.5429168344, 0.3505726457, 0.3296067119, 0.3620986938 } }, + { { 0.1843576431, 0.0179861784, 0.3122915626, 0.3600125313, + 0.2466817498, 0.2172668576, 0.1975526214, 0.1177569032, + 0.1196866035, 0.0849519968, 0.0962694287, 0.1591672301, + 0.2300446033, 0.3082756996, 0.4047607183, 0.3925045133 }, + { -0.0275964737, -0.0794897676, 0.1168181300, 0.1591150761, + 0.0915755630, 0.0460972190, 0.0562151074, 0.0084419847, + -0.0095511675, -0.0408957601, -0.0376100540, -0.0166962743, + 0.0656028390, 0.1226072311, 0.2293144464, 0.2142419219 } }, + { { 0.4781936407, -1.2478972673, 0.4884679914, 0.7755239606, + 0.6785174012, 0.6590117812, 0.6177057624, 0.6427918673, + 0.5402048230, 0.5512614846, 0.6424267888, 0.4229103327, + 0.5106334686, 0.5136062503, 0.4490395188, 0.4753251672 }, + { 0.2852236032, -1.3815159798, 0.1904075146, 0.4874770641, + 0.4593138695, 0.4182686210, 0.4174863100, 0.4604612589, + 0.4089330435, 0.3891666532, 0.4700576067, 0.2383370996, + 0.2801646590, 0.3398289084, 0.2766703367, 0.3374298215 } }, + { { 0.5925153494, 0.3858809471, 1.0754098296, 0.5752002001, + 0.5516265631, 0.4853909016, 0.4719351530, 0.5018194318, + 0.3037382960, 0.5154316425, 0.8809794784, 0.7755761147, + 0.5941321254, 0.3974069953, 0.5925675035, 0.6097261906 }, + { 0.3008176684, 0.0706617832, 0.8484353423, 0.2574254870, + 0.2815728188, 0.1930673718, 0.2523665428, 0.2691601515, + 0.1271967888, 0.2653007507, 0.6473292708, 0.5275835395, + 0.3928174376, 0.2405275702, 0.4008491635, 0.4556109309 } }, + { { 0.7339050174, 0.4290645123, 0.6859754324, 0.6349166036, + 0.8034263849, 0.8509387374, 0.8591269255, 1.1049811840, + 1.3928194642, 1.3423343301, 1.0849018693, 0.8943830729, + 0.8579795361, 0.6920774579, 0.5613272190, 0.4303162098 }, + { 0.4534726143, 0.0901674032, 0.3465046287, 0.3470261693, + 0.5217422843, 0.5874564052, 0.6014336944, 0.9161834717, + 1.2823571563, 1.2193550467, 0.8868207335, 0.6514494419, + 0.6249030232, 0.4453887343, 0.3665317893, 0.2242033482 } }, + { { 0.4293252826, 0.3303368688, 0.6181751490, 0.9884168506, + 0.9915460944, 0.7939864993, 0.3019129038, 0.2443348169, + 0.4543070793, 0.5617444515, 0.4895110726, 0.6600027084, + 0.6290231943, 0.5580936670, 0.5459417701, 0.4647378922 }, + { 0.1409133077, -0.0050137639, 0.2551307082, 0.6764833927, + 0.7112701535, 0.4648943543, 0.0301380754, -0.0235806108, + 0.1018499136, 0.2422486544, 0.2406318784, 0.4000146985, + 0.3713299632, 0.3259559274, 0.3820737004, 0.2888743877 } }, + { { 0.7733334899, 0.8321111202, 1.3098945022, 1.0331128836, + 1.0380675197, 0.9479974508, 0.9740223289, 0.9442945123, + 0.8926619887, 0.8719046712, 0.8640815616, 0.8404036164, + 0.8359183669, 0.7675965428, 0.6895219088, 0.7266034484 }, + { 0.3655408621, 0.4643206596, 1.2171645761, 0.8341451287, + 0.8387868404, 0.6713201404, 0.6814901829, 0.6294404268, + 0.5172048807, 0.5205948949, 0.5408828259, 0.5298783183, + 0.5781729817, 0.5000983477, 0.4727174640, 0.4326109886 } }, + { { 0.8902629018, 0.4598354101, 0.6392975450, 0.4483093619, + 0.6220867038, 0.6323089004, 0.7063676715, 0.3717993498, + 0.6718416810, 0.7876758575, 0.2807383537, 0.3118221760, + 0.6703813672, 0.7662405372, 0.7122610807, 0.7851724625 }, + { 0.6301705837, 0.1221378446, 0.3532846570, 0.1412783861, + 0.3471826315, 0.3435318470, 0.4466925859, 0.1390357614, + 0.4092981219, 0.5406742096, 0.0690450072, 0.0829179883, + 0.4625995755, 0.5700891018, 0.5542864203, 0.6545265317 } }, + { { -0.1100520492, 0.3803526163, 0.8075987101, 0.6903563738, + 0.8012359142, 0.7835035324, 0.8195941448, 0.8381088376, + 0.8033220768, 0.7511680126, 0.6393496990, 0.6096218824, + 0.6934856176, 0.6690253615, 0.6401841640, 0.5600233674 }, + { -0.1776958704, -0.0293175578, 0.1520742774, 0.1746048331, + 0.2222214937, 0.3052507639, 0.2977927327, 0.3797789216, + 0.3395681381, 0.2976884246, 0.2516885400, 0.2403711081, + 0.3567789793, 0.3302847147, 0.3368039727, 0.3310148716 } }, + { { 0.5587195158, 0.4676063657, 0.1392965317, -0.0990996957, + -0.0816280842, -0.1146416068, -0.0116894841, 0.0521992445, + 0.1626615524, 0.2923687100, 0.4029874802, 0.4528989196, + 0.4694839120, 0.5058352947, 0.5369191170, 0.5105291605 }, + { 0.2193530202, 0.1211469173, 0.0179861784, -0.2022604346, + -0.1409794092, -0.2121175528, -0.1152674556, -0.0594626069, + -0.0122110248, 0.0274260640, 0.1414870024, 0.2044369578, + 0.2167974710, 0.2615978122, 0.3348221183, 0.3707562685 } }, + { { 0.5948622823, 0.7065241337, 0.9414781928, 0.9340723157, + 0.8835350275, 0.9730835557, 0.8503650427, 0.8902629018, + 0.8746688366, 0.6910865307, 0.6404449344, 0.6976057887, + 0.5916287303, 0.6022160053, 0.7729684114, 0.6096740365 }, + { 0.1262058616, 0.1300652623, 0.6594290137, 0.6535877585, + 0.5639349222, 0.6982316375, 0.4828875065, 0.5577285886, + 0.4591052532, 0.2964367270, 0.2695252299, 0.3324751854, + 0.2860580683, 0.2902825475, 0.4623388052, 0.3369604349 } }, + { { 0.8821268678, 0.8539636731, 0.2898653150, 0.7478301525, + 0.5109463930, 0.8577187657, 0.4884679914, 0.7846509218, + 0.7684310079, 0.7032384276, 0.6691296697, 0.8593355417, + 0.9383489490, 0.9808023572, 0.6804992557, 0.6403927803 }, + { 0.5590324402, 0.4209806323, 0.0259135962, 0.4318808317, + 0.2104346752, 0.5453680754, 0.1783599257, 0.4467447400, + 0.4352708459, 0.4089330435, 0.3994410038, 0.5984609127, + 0.6872792840, 0.7321317792, 0.4408513308, 0.4542027712 } }, + { { 0.6371070743, 0.6311093569, 0.7152860165, 0.6929640770, + 0.2292101383, 0.3234525323, 0.9644259810, 0.9881039262, + 0.8722697496, 0.4370440841, 0.4051779509, 0.4944135547, + 0.5392660499, 0.5969484448, 0.4268740416, 0.4990552664 }, + { 0.4233797193, 0.3647063971, 0.4345406890, 0.4180078506, + -0.0006328225, 0.0586141944, 0.7620160580, 0.8152132034, + 0.6707985997, 0.2095480561, 0.2178405523, 0.2776612639, + 0.3142212629, 0.3808741570, 0.2676998377, 0.2804775834 } }, + { { 0.4509170651, 0.9490405321, 0.8557890654, 0.8271043301, + 0.6915559173, 0.7321839333, 0.6257896423, 0.6274064183, + 0.5238284469, 0.5194996595, 0.4116972089, 0.3382642865, + 0.3755022883, 0.4867990613, 0.5686287880, 0.5106856227 }, + { 0.0989292860, 0.6244857907, 0.4700576067, 0.3905226588, + 0.2630059719, 0.3009741306, 0.2150763869, 0.2067838907, + 0.1533781290, 0.1815934777, 0.1023714542, 0.0373874903, + 0.0897501707, 0.1849313378, 0.2852757573, 0.2625887394 } }, + { { 0.9954054952, 0.9554033279, 0.8237664700, 0.9780903459, + 0.7261862159, 0.7884581685, 0.7933084965, 0.7393290401, + 0.8783196211, 1.0409359932, 1.0217954516, 0.9159227014, + 0.8698185086, 0.7057939768, 0.7662926912, 0.7339571714 }, + { 0.7913266420, 0.6739278436, 0.5061482191, 0.7058982849, + 0.3480692506, 0.4338105321, 0.4428853393, 0.3758152127, + 0.5962182879, 0.7925261855, 0.7968549728, 0.6629754901, + 0.6325175166, 0.4598354101, 0.5310778618, 0.5518873334 } }, + { { 0.4638512731, 0.0604917407, 0.1897295117, 0.3403504491, + 0.4708399177, 0.5241413713, 0.6061275601, 0.6446694136, + 0.7313494682, 0.7208143473, 0.6268848777, 0.6081094146, + 0.4913364649, 0.3529717326, 0.4954566360, 0.5767126679 }, + { 0.1353849769, -0.0274400115, 0.0002537966, 0.0272174478, + 0.0555371046, 0.0652899146, 0.1010676026, 0.1073260903, + 0.1568724513, 0.2207611799, 0.1434167027, 0.2262373567, + 0.1177047491, 0.0162650943, 0.2529402375, 0.4087765813 } }, + { { 0.9700064659, 0.9917025566, 0.9159227014, 0.9309430718, + 0.8991290927, 0.9314124584, 0.9059612751, 0.9473194480, + 0.9604622722, 0.9377752542, 0.9197821021, 0.8869771957, + 0.8506779671, 0.8594920039, 0.8320589662, 0.8739908338 }, + { 0.2892394662, 0.0551198721, 0.0892807841, 0.1158793569, + 0.0905846357, 0.0738953352, 0.0395258069, 0.0240360498, + 0.0477139950, 0.0751470327, 0.1171310544, 0.1555164456, + 0.1384620667, 0.1818542480, 0.2104868293, 0.1288135648 } }, + { { 0.4101847410, 0.3326316476, 0.4666675925, 0.5077128410, + 0.5892296433, 0.4272912741, 0.0603352785, -0.8668596745, + -1.1103670001, -0.0900248885, 0.1626615524, 0.1487885714, + 0.4130010605, 0.5119373202, 0.5820323825, 0.5486016273 }, + { 0.0383262634, 0.1300652623, 0.2295230627, 0.2706204653, + 0.3722165823, 0.1698066592, -0.0934670568, -0.8677462935, + -1.0724509954, -0.2164463401, -0.0056917667, -0.0301520228, + 0.1299088001, 0.2579991817, 0.3482257128, 0.2469425201 } }, + { { 0.6031547785, 0.5515222549, 0.4292209744, 0.5027582049, + 0.8167778254, 1.0925685167, 0.9878953099, 0.7019345760, + 0.2509583831, 0.2475162148, 0.5660732388, 0.5145971775, + 0.4824181199, 0.5970005989, 0.5996604562, 0.5384315848 }, + { 0.3677313328, 0.2650399804, 0.1585935354, 0.2213348746, + 0.5566333532, 0.8425940871, 0.7604514360, 0.4523773789, + 0.0681062341, 0.0737388730, 0.3169854283, 0.2868403792, + 0.2661873698, 0.3635068536, 0.4300554395, 0.3743027449 } }, + { { 0.5017672777, 0.6634970307, 0.6869142056, 0.7066284418, + 0.5669598579, 0.0621085167, 0.0634645224, 0.2321307659, + 0.8322675824, 0.9855483770, 0.8296598792, 0.6140028238, + 0.5462546945, 0.6730412245, 0.6856103539, 0.5975221395 }, + { 0.2680649161, 0.3324230313, 0.3688787222, 0.3886451125, + 0.2774004936, -0.1695076823, -0.1353467703, 0.0159000158, + 0.5895425677, 0.7586781979, 0.5639870763, 0.3687744141, + 0.3401418328, 0.4477356672, 0.4782979488, 0.4034568667 } }, + { { 0.8838479519, 0.9025712609, 0.7326533198, 0.8124490380, + 0.8956347704, 1.1007045507, 1.2731780410, 1.2029786706, + 1.0839109421, 0.9664078355, 0.7356782556, 0.6942157745, + 0.6917645335, 0.6383587718, 0.6503020525, 0.5989302993 }, + { 0.5576764345, 0.4596789479, 0.3790487647, 0.5514179468, + 0.7333834767, 0.9612445831, 1.1976589561, 1.1094664335, + 0.8868207335, 0.6789346337, 0.4643206596, 0.4029353261, + 0.4384522438, 0.3871847987, 0.4326109886, 0.3691916466 } }, + { { 0.8520861268, 0.8413423896, 0.7238392830, 0.9103943706, + 0.7072542906, 0.6479029655, 0.4557673931, 0.1908247471, + -0.0569070578, -0.1013423204, 0.2517406940, 0.4854952097, + 0.5820845366, 0.5886037946, 0.6177579165, 0.6226603985 }, + { 0.6160889864, 0.4592095613, 0.4752208591, 0.6685559750, + 0.4326109886, 0.4077335000, 0.2314006090, 0.0173603296, + -0.2208272815, -0.3014574647, 0.0321199298, 0.2559130192, + 0.3603254557, 0.3466089368, 0.4072119594, 0.4776199460 } }, + { { 0.7083495259, 0.9001721740, 0.6795083284, 1.2743254304, + 1.3672639728, 1.2563322783, 0.8557369113, 0.8287732601, + 0.7942472696, 0.8006622195, 0.7034991980, 0.5479236245, + 0.6391932368, 0.6248508692, 0.5495925546, 0.4719351530 }, + { 0.4000146985, 0.6493632793, 0.4583229423, 1.1484255195, + 1.2521599531, 1.1232351065, 0.6150459051, 0.5347808003, + 0.4726653099, 0.5269576907, 0.4278128147, 0.2745841742, + 0.3868718743, 0.4183729291, 0.3474434018, 0.3150035739 } }, + { { 0.9070043564, 0.7648323774, 0.4281778932, 0.5475063920, + 0.4134704471, 0.4706834555, 0.4549329281, 0.4648422003, + 0.4572798610, 0.4823138118, 0.4666154385, 0.4841913581, + 0.4018922448, 0.4297946692, 0.4646857381, 0.6091003418 }, + { 0.4925360084, 0.2065231204, 0.0948612690, 0.1716842055, + 0.0992422104, 0.1332988143, 0.1255800128, 0.1257364750, + 0.0955392718, 0.1118634939, 0.1372103691, 0.1525958180, + 0.0902717113, 0.1591672301, 0.2335910797, 0.3767018318 } }, + { { 0.3185500503, 0.8677845001, 0.7776622772, 0.8160476685, + 0.8624126315, 0.8057211637, 0.8852561116, 0.8471314907, + 0.9145145416, 0.8945916891, 0.8638729453, 0.8531292081, + 0.7425104380, 0.6215651631, 0.6501455903, 0.6341864467 }, + { -0.0499705672, 0.0687842369, 0.3051464558, 0.3368039727, + 0.4942049384, 0.3823344707, 0.5683158636, 0.5044271350, + 0.6278236508, 0.5777035952, 0.5745221972, 0.5502184033, + 0.4244228005, 0.3163595796, 0.3525545001, 0.3582914472 } }, + { { 0.3200625181, 0.9415303469, 0.6067534089, 0.3568832874, + 0.1600538492, 0.2938811779, 0.2037589550, 0.3017564416, + 0.2572168708, 0.4796018004, 0.6938506961, 0.6847758889, + 0.7232134342, 0.6111343503, 0.5159531832, 0.4856516719 }, + { 0.0680540800, 0.6285016537, 0.2514277697, 0.0790064335, + -0.0687981844, 0.0521992445, -0.0055874586, 0.0537117124, + 0.0188206434, 0.1883213520, 0.4493002892, 0.4300554395, + 0.4750122428, 0.3658016324, 0.3119786382, 0.2818335891 } }, + { { 0.6864969730, 1.0815640092, 0.9838794470, 0.8845259547, + 0.9438772798, 0.8888025880, 0.8178730607, 0.8581881523, + 0.7128347754, 0.7120524645, 0.7345308661, 0.7945601940, + 0.7854853868, 0.8261655569, 0.6941114664, 0.6646444201 }, + { 0.2847542167, 0.9535257816, 0.6691818237, 0.5026538968, + 0.5945493579, 0.4125838280, 0.3886451125, 0.3740941286, + 0.2453778982, 0.2928902507, 0.3219922185, 0.4065861106, + 0.3838469386, 0.4289602041, 0.3910441995, 0.3821780086 } }, + { { 1.1335094571, 1.0390062928, 0.7019867301, 0.6203134656, + 0.6951545477, 0.4863818288, 0.6171320677, 0.6247465611, + 0.5907421112, 0.6711115241, 0.7322882414, 0.7042293549, + 0.5635698438, 0.6174449921, 0.6727283001, 0.6431047916 }, + { 1.0146503448, 0.7762541175, 0.2200310230, 0.2459515929, + 0.2703596950, 0.1376276016, 0.2522100806, 0.2622758150, + 0.2389107943, 0.2956544161, 0.3799875379, 0.3653843999, + 0.2561216354, 0.2842326760, 0.4034568667, 0.3700782657 } }, + { { 0.6342907548, 0.9627570510, 0.5214815140, -0.0226939917, + 0.5616401434, 0.7231091261, 0.7417802811, 0.9092991352, + 0.9739701748, 0.7804785967, 0.6771092415, 0.6352295280, + 0.4660417438, 0.5869870186, 0.6692339778, 0.5986173749 }, + { 0.3988673091, 0.6997441053, 0.2316613793, -0.2566571236, + 0.2685343027, 0.4484136701, 0.4490395188, 0.6886874437, + 0.7703085542, 0.5847443938, 0.4539941549, 0.4098196626, + 0.2579991817, 0.3376384377, 0.4754816294, 0.5095382333 } }, + { { 0.4443456531, 2.0296727419, 0.6569256186, 0.6439914107, + 0.6436263323, 0.5507399440, 0.6095175743, 0.6066491008, + 0.5347808003, 0.2529402375, 0.4443978071, 0.7000570297, + 0.8259569407, 0.5927761197, 0.5078171492, 0.4418422580 }, + { 0.2430831194, 1.9133691788, 0.3723730445, 0.3764410615, + 0.3874977231, 0.3212099075, 0.3832210898, 0.4474227428, + 0.3644977808, 0.0814055204, 0.2752621770, 0.4647378922, + 0.6619845629, 0.4304205179, 0.3143777251, 0.2705683112 } }, + { { 0.9740744829, 1.0730628967, 0.9743352532, 0.9098728299, + 0.9453375936, 0.9661470652, 0.9270836711, 0.9643738270, + 0.9989519715, 0.9627048969, 0.9348546267, 0.9865393043, + 0.9399657249, 0.9752218723, 0.8440544009, 0.8819182515 }, + { 0.9258319736, 1.0357205868, 0.8463491797, 0.8108844161, + 0.8391519189, 0.8566235304, 0.8305986524, 0.8880724311, + 0.9181653261, 0.8670021892, 0.8305986524, 0.8995984793, + 0.8300249577, 0.8711223602, 0.7195626497, 0.8138571978 } }, +}; + +static const double wmavoice_mean_lsf10[2][10] = { + { 0.2235394066, 0.4097484909, 0.7025292732, 1.1077160169, + 1.3939179044, 1.6741291716, 1.9552949226, 2.2199793918, + 2.5103400247, 2.7829212906 }, + { 0.1493683393, 0.3714357373, 0.7702730245, 1.0609411394, + 1.3270362536, 1.5806033119, 1.8398507524, 2.1116740248, + 2.3823505771, 2.6865718527 } +}; + +static const double wmavoice_mean_lsf16[2][16] = { + { 0.0999206754, 0.2345933590, 0.4621011210, 0.6772546160, + 0.8346396060, 1.0067495130, 1.1571691668, 1.3292508688, + 1.4941465650, 1.6600755584, 1.8461284908, 2.0529487333, + 2.2690810112, 2.4949894820, 2.7172752965, 2.9164840903 }, + { 0.0918298402, 0.2475621892, 0.4782937721, 0.6284774045, + 0.7861951264, 0.9303736000, 1.0940441024, 1.2521029300, + 1.4434732098, 1.6551410742, 1.8917962963, 2.0967280403, + 2.2981430375, 2.4826173497, 2.6827972461, 2.8811350800 } +}; + +static const float wmavoice_std_codebook[1000] = { + -0.185013, -0.150405, -0.707267, -0.284100, 0.882898, + -0.788627, 0.061005, 0.374431, 0.053843, -0.909826, + 0.543602, 0.219326, 0.285698, 0.154709, -0.455005, + 0.426276, -0.868852, -0.952324, -0.550001, 0.813814, + -0.352815, 0.242122, 0.820495, -0.189574, -0.449538, + 0.499132, -0.247783, 0.598159, 0.732040, -0.564406, + -0.631788, -0.452973, 0.285189, -0.339055, 0.262927, + 0.168087, -0.127682, -0.676067, -0.457481, 0.926161, + -0.585893, -0.913880, 0.145487, 0.699804, 0.240829, + 0.690482, 0.126081, 0.371977, 0.738158, 0.576080, + 0.185791, -0.614657, -0.181799, 0.006285, 0.195768, + 0.368663, -0.494583, 0.947985, -0.033178, -0.762543, + -0.616421, 0.335034, -0.215516, 0.668769, 0.995979, + -0.952588, -0.163144, -0.131704, -0.628655, 0.379374, + -0.205543, -0.214549, 0.465494, 0.939944, -0.514744, + -0.293676, 0.630426, 0.611336, -0.921699, 0.368584, + 0.187416, 0.264092, 0.753927, -0.994382, -0.729623, + -0.050304, 0.374280, -0.224205, -0.102319, -0.658897, + 0.013252, 0.281260, 0.676137, 0.797736, -0.049971, + 0.672115, 0.845148, 0.786885, -0.459588, -0.783507, + 0.166259, 0.334869, 0.001944, -0.368247, 0.274813, + 0.487200, 0.338077, -0.094761, 0.098536, 0.416378, + -0.726176, -0.714048, -0.319530, -0.972249, -0.708430, + -0.049153, -0.022553, 0.665850, 0.726642, 0.875127, + -0.993047, -0.260106, 0.156387, 0.683090, -0.462370, + -0.893584, 0.355205, -0.617222, 0.893301, 0.895617, + -0.400729, 0.059559, 0.230486, 0.601215, 0.691313, + -0.494701, 0.088415, 0.029390, 0.410539, -0.813049, + -0.554232, 0.684362, -0.527097, 0.126238, 0.712113, + -0.235528, -0.922915, -0.310440, -0.569678, 0.803727, + -0.435313, -0.562725, -0.456380, 0.721075, -0.879635, + 0.081250, 0.827491, 0.475570, 0.464029, 0.720792, + 0.371187, -0.936700, -0.219649, -0.398327, 0.664515, + -0.528336, 0.106972, -0.247070, 0.501053, -0.482490, + -0.060119, 0.946821, -0.798127, 0.412784, 0.073058, + 0.913986, -0.822744, 0.150143, -0.396453, -0.392421, + -0.046130, 0.168234, 0.044854, 0.497490, -0.110691, + 0.165219, -0.421259, -0.283200, -0.359212, -0.957231, + -0.562409, -0.988025, -0.893931, 0.217942, -0.386352, + 0.770585, 0.689606, 0.720620, -0.476485, 0.190659, + -0.761870, 0.463395, 0.137480, -0.559997, -0.123821, + -0.789461, -0.646011, 0.053435, 0.360682, -0.042464, + 0.661014, -0.685448, -0.874230, -0.294133, 0.812042, + 0.015078, 0.871086, -0.609218, 0.731878, -0.488126, + -0.566448, -0.830530, -0.476150, -0.460379, 0.387412, + 0.137497, -0.689794, 0.077018, -0.141883, -0.166280, + -0.732322, 0.096247, -0.702884, 0.405158, 0.536250, + 0.173295, 0.615696, 0.890239, -0.773270, -0.023622, + -0.152226, 0.887744, 0.290930, -0.026456, -0.406389, + 0.102972, 0.988622, -0.535303, 0.493754, 0.720500, + -0.023428, 0.927306, 0.889970, 0.500421, -0.533073, + 0.277382, -0.362081, -0.222867, -0.645599, 0.496035, + 0.610853, -0.377922, -0.407718, 0.907969, -0.972764, + -0.871468, 0.081264, 0.642933, -0.981230, 0.307994, + -0.380689, -0.133456, 0.195738, 0.910241, 0.840088, + 0.789349, 0.013213, 0.828710, -0.745954, -0.493033, + 0.549210, 0.230618, -0.565727, 0.439180, -0.268961, + -0.098800, -0.283438, 0.368958, 0.678333, 0.070963, + -0.135007, 0.289186, 0.693041, 0.457275, 0.197155, + 0.720277, 0.585807, -0.721581, 0.363210, 0.604577, + 0.586413, 0.982521, -0.528878, -0.217849, 0.892762, + -0.688791, -0.428500, -0.094025, -0.860081, -0.174454, + 0.412942, 0.689129, -0.943836, 0.847215, 0.128309, + -0.212797, -0.251585, 0.844871, -0.843839, -0.573252, + -0.084167, 0.021154, 0.715935, -0.391126, -0.521570, + -0.086910, -0.670848, -0.935763, 0.191509, 0.692361, + 0.668814, -0.222078, 0.674882, -0.860064, 0.560073, + 0.567644, -0.548855, -0.868427, -0.526382, -0.408936, + -0.042881, 0.886560, -0.719807, 0.013283, 0.733775, + 0.408502, 0.800487, -0.517810, 0.253372, 0.956648, + -0.091062, -0.830794, -0.022198, -0.375127, -0.221920, + 0.456232, 0.537963, 0.107232, 0.520469, -0.270529, + -0.200406, 0.189284, 0.507393, -0.525524, 0.329220, + 0.067466, -0.957881, 0.780365, 0.199039, -0.484262, + -0.628570, -0.843843, -0.597703, -0.348377, 0.169441, + -0.863928, -0.939875, -0.030073, -0.381738, 0.313497, + -0.073425, 0.527200, 0.482703, 0.904377, -0.847927, + -0.739217, 0.360609, 0.690035, 0.368015, -0.118921, + -0.580493, -0.832391, -0.929638, 0.926900, -0.357915, + 0.399582, -0.005634, -0.315796, 0.179947, -0.806596, + 0.393360, 0.732931, -0.415833, -0.724526, 0.957347, + -0.892887, 0.475366, 0.173583, -0.418554, -0.302536, + 0.627315, 0.782000, 0.497542, 0.139082, 0.570111, + 0.732375, -0.454643, 0.302218, -0.019505, 0.881778, + -0.057606, 0.273041, 0.414170, -0.503501, -0.079602, + -0.083941, 0.007178, -0.171925, 0.506856, 0.520953, + 0.631684, -0.099784, 0.253885, -0.784149, 0.175691, + 0.211231, -0.677036, -0.348943, -0.615186, -0.095591, + 0.348521, -0.987871, -0.313590, -0.153938, 0.151210, + -0.743479, -0.421562, 0.696567, 0.558739, 0.558933, + 0.578346, -0.498867, -0.168026, -0.007485, -0.002368, + 0.752372, 0.908575, -0.995190, -0.419553, 0.415430, + 0.525763, -0.787869, -0.684353, -0.220353, -0.572018, + 0.491337, 0.990879, -0.249054, -0.857606, -0.624307, + 0.655355, 0.490915, -0.612178, -0.658235, -0.663023, + 0.539032, -0.401714, -0.084585, 0.235599, -0.842975, + -0.525653, -0.186055, -0.341841, 0.306321, 0.806460, + 0.655791, 0.058693, 0.715035, 0.660601, 0.639140, + 0.130465, 0.186363, 0.851271, 0.446112, 0.966011, + -0.720746, -0.062551, 0.956890, 0.030200, 0.079843, + -0.667418, -0.314445, -0.429243, -0.279596, 0.027320, + -0.092266, -0.740564, 0.625606, 0.823149, 0.495035, + 0.782632, -0.702504, -0.691020, -0.559209, 0.603818, + -0.884560, -0.903419, -0.337489, 0.830475, 0.757182, + -0.698349, -0.039060, -0.056455, -0.847078, -0.592948, + -0.090444, -0.567824, 0.344501, -0.133554, 0.462375, + -0.575656, 0.199028, -0.852070, -0.004899, 0.919432, + 0.175251, 0.902835, -0.821132, -0.199143, 0.725984, + 0.673903, -0.416511, -0.976519, 0.982883, 0.024279, + 0.627298, -0.901677, 0.120861, -0.710191, 0.928798, + -0.121958, -0.408540, -0.110261, 0.821588, -0.255618, + 0.296790, -0.268856, 0.176557, -0.358709, 0.597589, + -0.361067, 0.065635, -0.203382, -0.213137, -0.939264, + -0.283951, 0.962113, 0.963571, -0.105083, -0.237030, + 0.689556, -0.431180, 0.346459, 0.713037, -0.448297, + -0.629262, 0.340335, -0.349973, 0.491599, 0.630144, + -0.421175, -0.630359, -0.778396, 0.468564, -0.808771, + -0.034014, -0.234646, -0.077627, -0.857457, 0.406645, + -0.480038, -0.218524, -0.527720, 0.316580, 0.568338, + -0.466984, -0.967371, 0.530452, -0.503413, -0.072454, + -0.706578, -0.813857, 0.496366, 0.639881, 0.899179, + -0.951931, -0.989381, 0.239514, -0.301904, 0.502218, + -0.130341, 0.276921, 0.871860, 0.091262, -0.254515, + -0.936911, -0.942752, 0.510839, -0.014539, -0.800209, + -0.082516, 0.505423, -0.018733, 0.389763, -0.177997, + -0.450395, 0.922779, -0.145368, -0.919943, -0.580634, + 0.782178, -0.626521, -0.394491, 0.278545, -0.986640, + -0.495312, 0.326614, -0.976021, 0.744203, -0.975290, + 0.526197, -0.386139, 0.301631, 0.398057, 0.705124, + -0.952884, 0.461146, 0.762372, 0.557954, -0.553393, + 0.962163, -0.524562, 0.952030, -0.056570, 0.865202, + -0.225967, 0.493035, 0.787981, 0.628665, 0.573093, + -0.792653, 0.410844, 0.946571, -0.187144, -0.310612, + 0.959931, 0.317544, -0.983998, 0.983911, 0.061747, + -0.959287, 0.510108, 0.675608, 0.342344, -0.091835, + 0.380731, 0.389460, -0.630689, 0.143103, -0.052586, + -0.184083, 0.105266, 0.422852, -0.232052, -0.951303, + 0.288054, 0.541981, 0.541732, 0.076035, 0.170646, + 0.114825, 0.283382, -0.418510, 0.061396, -0.903763, + 0.270879, 0.021327, 0.413782, 0.286881, 0.005238, + -0.524472, 0.327594, -0.484654, -0.848864, -0.330063, + 0.423511, 0.531868, -0.940603, 0.792822, -0.325029, + 0.006811, -0.391261, 0.780237, -0.570337, 0.376687, + 0.828934, 0.717717, -0.081333, 0.370666, -0.206248, + -0.910686, -0.514510, -0.922867, -0.329196, 0.546886, + -0.826629, 0.941683, -0.431786, 0.587152, 0.228564, + 0.573452, -0.937320, -0.443843, -0.911202, -0.786184, + 0.226094, 0.512309, 0.745684, 0.285491, 0.305131, + -0.579345, -0.707698, 0.913870, -0.799108, -0.278035, + 0.290556, -0.970174, -0.560318, -0.790776, 0.400492, + 0.233434, -0.701462, 0.885982, 0.310567, -0.030658, + 0.432868, 0.483938, -0.088976, -0.998918, 0.071090, + -0.860412, 0.574534, 0.133770, -0.304255, 0.663332, + 0.347586, 0.921839, 0.175641, 0.093270, 0.207330, + -0.519228, 0.513925, 0.499633, -0.605358, 0.714817, + -0.778402, 0.685198, 0.744643, -0.338720, 0.894422, + 0.145135, 0.894714, -0.807041, 0.031117, 0.205281, + 0.162301, -0.536015, -0.310781, -0.926675, -0.534932, + 0.760308, -0.787088, -0.960398, -0.105922, -0.091343, + 0.702934, -0.758336, -0.169504, -0.121425, 0.334935, + -0.962173, 0.359347, -0.151140, 0.537460, 0.753989, + -0.436323, 0.759058, 0.439187, -0.691680, -0.579662, + 0.333608, 0.453454, -0.684948, 0.526567, -0.515429, + 0.520333, -0.311132, -0.051443, -0.790448, -0.237807, + 0.413625, 0.969861, -0.024895, 0.453226, -0.136061, + 0.883762, 0.156160, 0.105603, -0.285741, -0.965264, + -0.559462, -0.247914, 0.394083, 0.289398, -0.710455, + 0.148072, 0.853074, -0.951397, -0.412742, -0.838606, + -0.531059, 0.920866, 0.614848, -0.216007, 0.447434, + -0.900580, -0.695673, -0.863698, 0.047977, -0.486121, + -0.101505, -0.538399, -0.516261, 0.873600, 0.914828, + 0.347678, 0.757362, 0.070988, -0.546718, -0.528380, + 0.105724, -0.106180, 0.223706, -0.500194, -0.816782, + 0.513251, 0.647878, -0.963708, 0.561854, -0.764864, + -0.802314, -0.969205, -0.843997, 0.812534, -0.185212, + 0.603436, 0.911954, 0.119114, 0.739738, -0.040069, + 0.632993, -0.361767, 0.421532, -0.883268, -0.488168, + 0.336360, 0.464411, -0.730806, -0.592652, 0.917693, + -0.259186, 0.513071, -0.188487, 0.964520, -0.987122, + -0.005270, 0.477771, 0.660756, 0.031023, 0.039625, + 0.895892, 0.228709, 0.070419, -0.948105, 0.041243, + 0.885207, 0.655331, -0.046803, 0.004321, 0.395069, + 0.913128, -0.362686, -0.966698, 0.334661, -0.245954, + -0.454865, -0.328980, -0.781543, -0.185671, 0.078368, + -0.863850, 0.555143, -0.408560, -0.052338, 0.519663, + -0.395683, 0.942393, -0.002565, -0.734927, -0.026585, + -0.962941, -0.839035, -0.797876, 0.107479, -0.787140, + 0.243367, -0.007314, 0.868191, -0.803435, 0.997007, + 0.263261, -0.890307, -0.365679, 0.296563, 0.444354, + 0.388367, 0.841698, -0.884626, 0.606824, -0.343973, + 0.193743, 0.742974, -0.788830, 0.785182, -0.309364, + 0.730833, -0.610500, -0.366971, -0.271732, -0.345427, + 0.606444, -0.234673, -0.184462, 0.808568, 0.872806, + 0.028398, 0.051936, -0.134508, -0.103410, 0.248500, + -0.137501, -0.840150, 0.358194, 0.496819, 0.456413, + -0.197453, -0.114814, 0.298111, -0.082078, -0.507990, + 0.954138, -0.888336, -0.765016, -0.834692, 0.896847, + -0.074380, 0.896141, -0.713654, 0.558649, -0.375591, + -0.059081, 0.165093, 0.389736, 0.756458, -0.026339, + 0.262542, -0.215144, -0.974403, -0.871966, 0.681446 +}; + +static const float wmavoice_gain_silence[256] = { + 0.0000188351, 0.0000249147, 0.0000294447, 0.0000365973, + 0.0000423193, 0.0000464916, 0.0000498295, 0.0000525713, + 0.0000550747, 0.0000574589, 0.0000596046, 0.0000615120, + 0.0000634193, 0.0000649691, 0.0000665188, 0.0000679493, + 0.0000692606, 0.0000704527, 0.0000716448, 0.0000728369, + 0.0000737906, 0.0000747442, 0.0000755787, 0.0000762939, + 0.0000770092, 0.0000778437, 0.0000785589, 0.0000792742, + 0.0000799894, 0.0000807047, 0.0000814199, 0.0000822544, + 0.0000829697, 0.0000838041, 0.0000845194, 0.0000854731, + 0.0000865459, 0.0000876188, 0.0000889301, 0.0000904799, + 0.0000923872, 0.0000950098, 0.0000988245, 0.0001032352, + 0.0001088381, 0.0001147985, 0.0001225471, 0.0001319647, + 0.0001431704, 0.0001568794, 0.0001744032, 0.0001952648, + 0.0002206564, 0.0002535582, 0.0002965927, 0.0003464222, + 0.0004109144, 0.0004891157, 0.0005909204, 0.0007261038, + 0.0008867979, 0.0010721684, 0.0012696981, 0.0015079975, + 0.0017461777, 0.0019979477, 0.0022052526, 0.0023679733, + 0.0025173426, 0.0026556253, 0.0027927160, 0.0029264688, + 0.0030447245, 0.0031807423, 0.0033060312, 0.0034313202, + 0.0035454035, 0.0036598444, 0.0037686825, 0.0038731098, + 0.0039769411, 0.0040702820, 0.0041661263, 0.0042562485, + 0.0043400526, 0.0044249296, 0.0045082569, 0.0045900345, + 0.0046693087, 0.0047430992, 0.0048171282, 0.0048881769, + 0.0049589872, 0.0050252676, 0.0050880909, 0.0051497221, + 0.0052082539, 0.0052671432, 0.0053246021, 0.0053800344, + 0.0054348707, 0.0054861307, 0.0055367947, 0.0055862665, + 0.0056355000, 0.0056805611, 0.0057252645, 0.0057705641, + 0.0058110952, 0.0058538914, 0.0058966875, 0.0059366226, + 0.0059723854, 0.0060091019, 0.0060437918, 0.0060794353, + 0.0061159134, 0.0061485767, 0.0061824322, 0.0062153339, + 0.0062497854, 0.0062820911, 0.0063197613, 0.0063550472, + 0.0063927174, 0.0064336061, 0.0064769983, 0.0065194368, + 0.0065603256, 0.0066006184, 0.0066410303, 0.0066826344, + 0.0067234039, 0.0067654848, 0.0068060160, 0.0068466663, + 0.0068866014, 0.0069231987, 0.0069609880, 0.0069983006, + 0.0070366859, 0.0070750713, 0.0071122646, 0.0071535110, + 0.0071973801, 0.0072410107, 0.0072846413, 0.0073343515, + 0.0073832273, 0.0074360371, 0.0074878931, 0.0075426102, + 0.0076007843, 0.0076560974, 0.0077134371, 0.0077683926, + 0.0078265667, 0.0078855753, 0.0079488754, 0.0080170631, + 0.0080827475, 0.0081528425, 0.0082212687, 0.0082877874, + 0.0083510876, 0.0084129572, 0.0084775686, 0.0085455179, + 0.0086110830, 0.0086781979, 0.0087503195, 0.0088242292, + 0.0089002848, 0.0089734793, 0.0090423822, 0.0091133118, + 0.0091816187, 0.0092473030, 0.0093164444, 0.0093911886, + 0.0094678402, 0.0095427036, 0.0096175671, 0.0096931458, + 0.0097666979, 0.0098397732, 0.0099166632, 0.0099946260, + 0.0100749731, 0.0101612806, 0.0102528334, 0.0103493929, + 0.0104434490, 0.0105448961, 0.0106583834, 0.0107737780, + 0.0108981133, 0.0110142231, 0.0111318827, 0.0112472773, + 0.0113576651, 0.0114786625, 0.0116028786, 0.0117331743, + 0.0118676424, 0.0120122433, 0.0121580362, 0.0123010874, + 0.0124633312, 0.0126402378, 0.0128232241, 0.0130140781, + 0.0132108927, 0.0134289265, 0.0136625767, 0.0138912201, + 0.0141364336, 0.0144006014, 0.0146615505, 0.0149335861, + 0.0152134895, 0.0155050755, 0.0158376694, 0.0162067413, + 0.0165973902, 0.0169926882, 0.0174319744, 0.0179271698, + 0.0184448957, 0.0190744400, 0.0197248459, 0.0204203129, + 0.0212460756, 0.0221523046, 0.0231562853, 0.0243031979, + 0.0256397724, 0.0271918774, 0.0289602280, 0.0310072899, + 0.0333702564, 0.0363805294, 0.0401413441, 0.0443998575, + 0.0498176813, 0.0562580824, 0.0640066862, 0.0732775927, + 0.0836604834, 0.0962959528, 0.1122496128, 0.1335854530, + 0.1608980894, 0.1990102530, 0.2616490126, 0.3926030397 +}; + +static const float wmavoice_gain_universal[64] = { + 0.0000000000, 0.0000000000, 0.0000015497, 0.0000015497, + 0.0000095367, 0.0000164509, 0.0000379086, 0.0000494719, + 0.0000799894, 0.0001058578, 0.0001349449, 0.0001627207, + 0.0001972914, 0.0002325773, 0.0002671480, 0.0003106594, + 0.0003589392, 0.0004127026, 0.0004582405, 0.0005071163, + 0.0005759001, 0.0006588697, 0.0007554293, 0.0008602142, + 0.0009772778, 0.0011068583, 0.0012603998, 0.0013889074, + 0.0015437603, 0.0016924143, 0.0018980503, 0.0021264553, + 0.0023632050, 0.0025693178, 0.0028522015, 0.0031896830, + 0.0034654140, 0.0037885904, 0.0041683912, 0.0046081543, + 0.0050576925, 0.0055632591, 0.0061818361, 0.0068151951, + 0.0073953867, 0.0081818104, 0.0091186762, 0.0102789402, + 0.0119919777, 0.0134155750, 0.0154829025, 0.0173798800, + 0.0199711323, 0.0229473114, 0.0268185139, 0.0319474936, + 0.0393068790, 0.0460114479, 0.0523469448, 0.0637906790, + 0.0845471621, 0.1105458736, 0.1499300003, 0.2219169140 +}; + +static const float wmavoice_gain_codebook_acb[128] = { + 0.05, 0.14, 0.16, 0.05, 0.17, 0.25, 0.07, 0.21, + 0.12, 0.22, 0.23, 0.13, 0.24, 0.32, 0.14, 0.29, + 0.31, 0.41, 0.43, 0.32, 0.43, 0.51, 0.34, 0.48, + 0.38, 0.47, 0.49, 0.38, 0.49, 0.57, 0.40, 0.54, + 0.49, 0.59, 0.61, 0.50, 0.61, 0.69, 0.52, 0.66, + 0.56, 0.65, 0.67, 0.56, 0.67, 0.75, 0.58, 0.72, + 0.65, 0.74, 0.76, 0.65, 0.76, 0.84, 0.67, 0.81, + 0.71, 0.80, 0.82, 0.71, 0.82, 0.90, 0.73, 0.87, + 0.81, 0.90, 0.92, 0.81, 0.93, 1.01, 0.83, 0.97, + 0.87, 0.96, 0.98, 0.87, 0.98, 1.06, 0.89, 1.03, + 0.92, 1.02, 1.04, 0.93, 1.04, 1.12, 0.95, 1.09, + 0.93, 1.02, 1.04, 0.93, 1.04, 1.12, 0.95, 1.09, + 0.94, 1.04, 1.05, 0.10, 1.06, 1.14, 0.96, 1.11, + 0.98, 1.08, 1.10, 0.99, 1.10, 1.18, 1.01, 1.15, + 1.06, 1.15, 1.17, 1.06, 1.17, 1.25, 1.08, 1.22, + 1.16, 1.25, 1.27, 1.16, 1.28, 1.36, 1.18, 1.32 +}; + +static const float wmavoice_gain_codebook_fcb[128] = { + -0.8439700703 /* log(0.430) */, -0.6143360001 /* log(0.541) */, + -0.1531511795 /* log(0.858) */, -0.0998203353 /* log(0.905) */, + 0.3213585988 /* log(1.379) */, 0.3777512695 /* log(1.459) */, + 0.7158866675 /* log(2.046) */, 1.2700414043 /* log(3.561) */, + -1.6873994539 /* log(0.185) */, -1.2173958247 /* log(0.296) */, + -0.4893903430 /* log(0.613) */, -0.4155154440 /* log(0.660) */, + 0.1257512053 /* log(1.134) */, 0.1947440768 /* log(1.215) */, + 0.5883420662 /* log(1.801) */, 1.1987592373 /* log(3.316) */, + -1.3586791941 /* log(0.257) */, -0.9996723408 /* log(0.368) */, + -0.3768776513 /* log(0.686) */, -0.3119747650 /* log(0.732) */, + 0.1881379421 /* log(1.207) */, 0.2523139286 /* log(1.287) */, + 0.6280751838 /* log(1.874) */, 1.2202397768 /* log(3.388) */, + -0.7381445465 /* log(0.478) */, -0.5310283311 /* log(0.588) */, + -0.0987159729 /* log(0.906) */, -0.0491902442 /* log(0.952) */, + 0.3555743385 /* log(1.427) */, 0.4101209196 /* log(1.507) */, + 0.7390761124 /* log(2.094) */, 1.2831536022 /* log(3.608) */, + -0.2497442331 /* log(0.779) */, -0.1165338163 /* log(0.890) */, + 0.1881379421 /* log(1.207) */, 0.2255406759 /* log(1.253) */, + 0.5469646704 /* log(1.728) */, 0.5922212620 /* log(1.808) */, + 0.8733832309 /* log(2.395) */, 1.3632815868 /* log(3.909) */, + -1.3903023825 /* log(0.249) */, -1.0216512475 /* log(0.360) */, + -0.3900840061 /* log(0.677) */, -0.3229638866 /* log(0.724) */, + 0.1806534997 /* log(1.198) */, 0.2460785226 /* log(1.279) */, + 0.6232610531 /* log(1.865) */, 1.2178757095 /* log(3.380) */, + -0.6033064766 /* log(0.547) */, -0.4185503477 /* log(0.658) */, + -0.0253178080 /* log(0.975) */, 0.0217614918 /* log(1.022) */, + 0.4027948796 /* log(1.496) */, 0.4555243080 /* log(1.577) */, + 0.7714961470 /* log(2.163) */, 1.3023691262 /* log(3.678) */, + -1.1056369036 /* log(0.331) */, -0.8164453969 /* log(0.442) */, + -0.2757535016 /* log(0.759) */, -0.2156715365 /* log(0.806) */, + 0.2468600779 /* log(1.280) */, 0.3082197237 /* log(1.361) */, + 0.6662897264 /* log(1.947) */, 1.2418464568 /* log(3.462) */, + -0.5395680926 /* log(0.583) */, -0.3652833185 /* log(0.694) */, + 0.0109399400 /* log(1.011) */, 0.0554347069 /* log(1.057) */, + 0.4265740713 /* log(1.532) */, 0.4774756441 /* log(1.612) */, + 0.7880027116 /* log(2.199) */, 1.3118401752 /* log(3.713) */, + -0.9571127264 /* log(0.384) */, -0.7031975164 /* log(0.495) */, + -0.2082549388 /* log(0.812) */, -0.1519863570 /* log(0.859) */, + 0.2874320412 /* log(1.333) */, 0.3464225675 /* log(1.414) */, + 0.6931471806 /* log(2.000) */, 1.2570395253 /* log(3.515) */, + -0.2420715612 /* log(0.785) */, -0.1098148660 /* log(0.896) */, + 0.1930966300 /* log(1.213) */, 0.2311117210 /* log(1.260) */, + 0.5504308784 /* log(1.734) */, 0.5960854677 /* log(1.815) */, + 0.8758853172 /* log(2.401) */, 1.3650707247 /* log(3.916) */, + 0.6564831962 /* log(1.928) */, 0.7124594916 /* log(2.039) */, + 0.8569652658 /* log(2.356) */, 0.8767179568 /* log(2.403) */, + 1.0567480846 /* log(2.877) */, 1.0841752409 /* log(2.957) */, + 1.2652560327 /* log(3.544) */, 1.6211688353 /* log(5.059) */, + -1.5417792640 /* log(0.214) */, -1.1239300967 /* log(0.325) */, + -0.4431669753 /* log(0.642) */, -5.2983173665 /* log(0.005) */, + 0.1510028735 /* log(1.163) */, 0.2183319943 /* log(1.244) */, + 0.6043159669 /* log(1.830) */, 1.2074666936 /* log(3.345) */, + -0.5124936809 /* log(0.599) */, -0.3424903089 /* log(0.710) */, + 0.0266419309 /* log(1.027) */, 0.0713899961 /* log(1.074) */, + 0.4369637752 /* log(1.548) */, 0.4879663296 /* log(1.629) */, + 0.7952524035 /* log(2.215) */, 1.3164082337 /* log(3.730) */, + -0.8867319296 /* log(0.412) */, -0.6481738149 /* log(0.523) */, + -0.1743533871 /* log(0.840) */, -0.1199102967 /* log(0.887) */, + 0.3089542077 /* log(1.362) */, 0.3660310389 /* log(1.442) */, + 0.7075430608 /* log(2.029) */, 1.2649738259 /* log(3.543) */, + -0.0943106795 /* log(0.910) */, 0.0207825392 /* log(1.021) */, + 0.2911759617 /* log(1.338) */, 0.3249778572 /* log(1.384) */, + 0.6200387087 /* log(1.859) */, 0.6621723763 /* log(1.939) */, + 0.9266370239 /* log(2.526) */, 1.3962446920 /* log(4.040) */ +}; + +static const float wmavoice_ipol1_coeffs[17*9] = { + 0, + 0.6308171151, 0.7613050340, 0.8632577061, 0.9280143976, + 0.9499985575, 0.9273047447, 0.8618999123, 0.7594153284, + -0.1791058179, -0.1351341452, -0.0589959878, 0.0472882274, + 0.1784339990, 0.3262237605, 0.4801855979, 0.6285545824, + 0, + -0.1921342459, -0.1786532696, -0.1341681625, -0.0575229186, + 0.0492091286, 0.1806929555, 0.3286687729, 0.4826357064, + 0.0807464118, 0.0506337392, 0.0080115446, -0.0428523305, + -0.0958572026, -0.1436148431, -0.1782128509, -0.1921164688, + 0, + 0.0960653644, 0.0803771760, 0.0500416081, 0.0072485465, + -0.0437018941, -0.0966834794, -0.1442930843, -0.1786170151, + -0.0391932014, -0.0189622506, 0.0070230183, 0.0356589290, + 0.0630142610, 0.0847979258, 0.0969368290, 0.0961942221, + 0, + -0.0515680681, -0.0389267015, -0.0185848991, 0.0074699190, + 0.0361179407, 0.0634181346, 0.0850781347, 0.0970333587, + 0.0178811825, 0.0048708571, -0.0108041526, -0.0271167825, + -0.0416534986, -0.0519338618, -0.0557823736, -0.0517020743, + 0, + 0.0267091128, 0.0177022810, 0.0046363524, -0.0110662053, + -0.0273700613, -0.0418578978, -0.0520511451, -0.0557823028, + -0.0069270437, 0.0008217385, 0.0097293532, 0.0185749526, + 0.0259542684, 0.0304777338, 0.0309953480, 0.0268154419, + 0, + -0.0125539196, -0.0068173436, 0.0009580161, 0.0098749646, + 0.0187084037, 0.0260526291, 0.0305201071, 0.0309665180, + 0.0019149571, -0.0022503408, -0.0068592466, -0.0112465904, + -0.0146595868, -0.0163685936, -0.0157934162, -0.0126258885, + 0, + 0.0050976076, 0.0018546581, -0.0023221741, -0.0069331308, + -0.0113109085, -0.0147021576, -0.0163786146, -0.0157635096, + -0.0001162733, 0.0019313511, 0.0040823850, 0.0060192454, + 0.0073876535, 0.0078486321, 0.0071403184, 0.0051400312, + 0, + -0.0017920607, -0.0000857157, 0.0019657183, 0.0041159806, + 0.0060465694, 0.0074030068, 0.0078470460, 0.0071185785, + -0.0004100171, -0.0015364708, -0.0025490071, -0.0033188616, + -0.0037196307, -0.0036417283, -0.0030119629, -0.0018155784, + 0, + 0.0006907531, -0.0004282868, -0.0015539061, -0.0025635813, + -0.0033285026, -0.0037224069, -0.0036361245, -0.0029972247, + 0, 0, 0, 0, 0, 0, 0, 0 +}; + +/** + * Hamming-window sinc function (num = 32, x = [ 0, 31 ]): + * (0.54 + 0.46 * cos(2 * M_PI * x / (num - 1))) * + * sin(x * M_PI / 4) / (x * M_PI / 4) + */ +static const float wmavoice_ipol2_coeffs[32] = { + 1, 0.8563459515, 0.5888634918, 0.2648358640, + 0, -0.1360490318, -0.1434589471, -0.0758505310, + 0, 0.0410402636, 0.0412485781, 0.0200064587, + 0, -0.0081391358, -0.0068223253, -0.0029313546, + 0, 0.0025864919, 0.0053062555, 0.0055688801, + 0, -0.0104795941, -0.0187493577, -0.0160592399, + 0, 0.0212381664, 0.0331059131, 0.0251942366, + 0, -0.0273968070, -0.0392575669, -0.0276240534 +}; + +/** + * LUT for 1.071575641632 * pow(1.0331663, n - 127) + */ +static const float wmavoice_energy_table[128] = { + 0.0169982178, 0.0175619858, 0.0181444519, 0.0187462362, + 0.0193679795, 0.0200103437, 0.0206740128, 0.0213596933, + 0.0220681153, 0.0228000330, 0.0235562258, 0.0243374986, + 0.0251446834, 0.0259786395, 0.0268402549, 0.0277304468, + 0.0286501631, 0.0296003830, 0.0305821182, 0.0315964139, + 0.0326443501, 0.0337270424, 0.0348456436, 0.0360013446, + 0.0371953760, 0.0384290090, 0.0397035571, 0.0410203772, + 0.0423808713, 0.0437864880, 0.0452387238, 0.0467391249, + 0.0482892887, 0.0498908657, 0.0515455612, 0.0532551367, + 0.0550214125, 0.0568462692, 0.0587316496, 0.0606795611, + 0.0626920777, 0.0647713419, 0.0669195677, 0.0691390421, + 0.0714321284, 0.0738012678, 0.0762489827, 0.0787778794, + 0.0813906502, 0.0840900769, 0.0868790336, 0.0897604897, + 0.0927375130, 0.0958132732, 0.0989910450, 0.1022742117, + 0.1056662688, 0.1091708280, 0.1127916204, 0.1165325012, + 0.1203974531, 0.1243905911, 0.1285161668, 0.1327785725, + 0.1371823465, 0.1417321773, 0.1464329093, 0.1512895470, + 0.1563072616, 0.1614913951, 0.1668474671, 0.1723811803, + 0.1780984262, 0.1840052921, 0.1901080668, 0.1964132480, + 0.2029275487, 0.2096579046, 0.2166114816, 0.2237956830, + 0.2312181577, 0.2388868085, 0.2468098001, 0.2549955679, + 0.2634528274, 0.2721905830, 0.2812181375, 0.2905451026, + 0.3001814086, 0.3101373153, 0.3204234225, 0.3310506819, + 0.3420304081, 0.3533742912, 0.3650944090, 0.3772032397, + 0.3897136755, 0.4026390362, 0.4159930832, 0.4297900346, + 0.4440445799, 0.4587718956, 0.4739876619, 0.4897080789, + 0.5059498840, 0.5227303696, 0.5400674019, 0.5579794393, + 0.5764855528, 0.5956054456, 0.6153594745, 0.6357686714, + 0.6568547659, 0.6786402082, 0.7011481929, 0.7244026842, + 0.7484284410, 0.7732510432, 0.7988969192, 0.8253933741, + 0.8527686184, 0.8810517982, 0.9102730265, 0.9404634147, + 0.9716551065, 1.0038813113, 1.0371763400, 1.0715756416 +}; + +/** + * LUT for f(x,y) = pow((y + 6.9) / 64, 0.025 * (x + 1)). + */ +static const float wmavoice_denoise_power_table[12][64] = { + { 0.9458379339, 0.9490436287, 0.9518757236, 0.9544130754, + 0.9567118717, 0.9588135761, 0.9607496688, 0.9625446194, + 0.9642178285, 0.9657849396, 0.9672587526, 0.9686498743, + 0.9699671937, 0.9712182343, 0.9724094211, 0.9735462842, + 0.9746336187, 0.9756756090, 0.9766759291, 0.9776378218, + 0.9785641645, 0.9794575217, 0.9803201890, 0.9811542296, + 0.9819615045, 0.9827436985, 0.9835023412, 0.9842388263, + 0.9849544265, 0.9856503078, 0.9863275406, 0.9869871101, + 0.9876299254, 0.9882568267, 0.9888685922, 0.9894659445, + 0.9900495551, 0.9906200497, 0.9911780119, 0.9917239872, + 0.9922584859, 0.9927819864, 0.9932949377, 0.9937977618, + 0.9942908555, 0.9947745929, 0.9952493267, 0.9957153901, + 0.9961730980, 0.9966227482, 0.9970646231, 0.9974989903, + 0.9979261037, 0.9983462046, 0.9987595223, 0.9991662752, + 0.9995666709, 0.9999609077, 1.0003491745, 1.0007316515, + 1.0011085110, 1.0014799178, 1.0018460292, 1.0022069960 }, + { 0.8946093973, 0.9006838092, 0.9060673931, 0.9109043185, + 0.9152976055, 0.9193234737, 0.9230399260, 0.9264921443, + 0.9297160207, 0.9327405496, 0.9355894944, 0.9382825789, + 0.9408363568, 0.9432648587, 0.9455800822, 0.9477923675, + 0.9499106907, 0.9519428941, 0.9538958704, 0.9557757107, + 0.9575878241, 0.9593370368, 0.9610276730, 0.9626636222, + 0.9642483964, 0.9657851769, 0.9672768552, 0.9687260672, + 0.9701352224, 0.9715065293, 0.9728420173, 0.9741435556, + 0.9754128696, 0.9766515555, 0.9778610927, 0.9790428553, + 0.9801981216, 0.9813280829, 0.9824338513, 0.9835164667, + 0.9845769028, 0.9856160726, 0.9866348334, 0.9876339913, + 0.9886143053, 0.9895764906, 0.9905212223, 0.9914491381, + 0.9923608411, 0.9932569022, 0.9941378627, 0.9950042356, + 0.9958565084, 0.9966951442, 0.9975205834, 0.9983332454, + 0.9991335296, 0.9999218170, 1.0006984708, 1.0014638383, + 1.0022182509, 1.0029620257, 1.0036954662, 1.0044188628 }, + { 0.8461555040, 0.8547882305, 0.8624635555, 0.8693789920, + 0.8756760853, 0.8814598273, 0.8868103032, 0.8917900284, + 0.8964487626, 0.9008267754, 0.9049571273, 0.9088673021, + 0.9125804007, 0.9161160306, 0.9194909803, 0.9227197376, + 0.9258148939, 0.9287874629, 0.9316471355, 0.9344024839, + 0.9370611291, 0.9396298766, 0.9421148300, 0.9445214846, + 0.9468548060, 0.9491192967, 0.9513190517, 0.9534578074, + 0.9555389816, 0.9575657096, 0.9595408742, 0.9614671327, + 0.9633469396, 0.9651825670, 0.9669761222, 0.9687295635, + 0.9704447142, 0.9721232742, 0.9737668316, 0.9753768718, + 0.9769547868, 0.9785018824, 0.9800193854, 0.9815084500, + 0.9829701633, 0.9844055505, 0.9858155796, 0.9872011653, + 0.9885631734, 0.9899024236, 0.9912196934, 0.9925157203, + 0.9937912053, 0.9950468143, 0.9962831814, 0.9975009102, + 0.9987005760, 0.9998827277, 1.0010478892, 1.0021965608, + 1.0033292209, 1.0044463270, 1.0055483173, 1.0066356112 }, + { 0.8003259737, 0.8112313241, 0.8209581209, 0.8297466775, + 0.8377697066, 0.8451556492, 0.8520027051, 0.8583876935, + 0.8643718792, 0.8700049328, 0.8753277020, 0.8803741979, + 0.8851730502, 0.8897485937, 0.8941216918, 0.8983103719, + 0.9023303202, 0.9061952736, 0.9099173316, 0.9135072091, + 0.9169744409, 0.9203275502, 0.9235741882, 0.9267212496, + 0.9297749699, 0.9327410079, 0.9356245146, 0.9384301933, + 0.9411623497, 0.9438249364, 0.9464215906, 0.9489556668, + 0.9514302661, 0.9538482608, 0.9562123167, 0.9585249126, + 0.9607883576, 0.9630048062, 0.9651762722, 0.9673046403, + 0.9693916775, 0.9714390425, 0.9734482944, 0.9754209007, + 0.9773582446, 0.9792616307, 0.9811322918, 0.9829713934, + 0.9847800389, 0.9865592739, 0.9883100900, 0.9900334289, + 0.9917301853, 0.9934012104, 0.9950473143, 0.9966692689, + 0.9982678100, 0.9998436400, 1.0013974295, 1.0029298194, + 1.0044414224, 1.0059328250, 1.0074045889, 1.0088572520 }, + { 0.7569786654, 0.7698939195, 0.7814501054, 0.7919210783, + 0.8015042240, 0.8103467104, 0.8185613167, 0.8262364557, + 0.8334427763, 0.8402376615, 0.8466683811, 0.8527743561, + 0.8585888194, 0.8641400582, 0.8694523567, 0.8745467247, + 0.8794414652, 0.8841526254, 0.8886943552, 0.8930791981, + 0.8973183276, 0.9014217415, 0.9053984227, 0.9092564737, + 0.9130032283, 0.9166453478, 0.9201889007, 0.9236394320, + 0.9270020224, 0.9302813390, 0.9334816797, 0.9366070112, + 0.9396610028, 0.9426470554, 0.9455683275, 0.9484277579, + 0.9512280860, 0.9539718690, 0.9566614986, 0.9592992147, + 0.9618871182, 0.9644271823, 0.9669212630, 0.9693711079, + 0.9717783651, 0.9741445900, 0.9764712529, 0.9787597445, + 0.9810113822, 0.9832274148, 0.9854090274, 0.9875573457, + 0.9896734398, 0.9917583281, 0.9938129803, 0.9958383209, + 0.9978352315, 0.9998045539, 1.0017470919, 1.0036636145, + 1.0055548568, 1.0074215229, 1.0092642871, 1.0110837959 }, + { 0.7159791370, 0.7306629191, 0.7438433845, 0.7558198318, + 0.7668086064, 0.7769714272, 0.7864325139, 0.7952894548, + 0.8036203840, 0.8114888792, 0.8189474022, 0.8260397728, + 0.8328029877, 0.8392685815, 0.8454636629, 0.8514117142, + 0.8571332177, 0.8626461513, 0.8679663850, 0.8731080020, + 0.8780835596, 0.8829043049, 0.8875803529, 0.8921208349, + 0.8965340237, 0.9008274393, 0.9050079382, 0.9090817905, + 0.9130547454, 0.9169320882, 0.9207186893, 0.9244190474, + 0.9280373261, 0.9315773876, 0.9350428208, 0.9384369673, + 0.9417629433, 0.9450236603, 0.9482218422, 0.9513600421, + 0.9544406555, 0.9574659338, 0.9604379957, 0.9633588374, + 0.9662303420, 0.9690542879, 0.9718323569, 0.9745661408, + 0.9772571477, 0.9799068082, 0.9825164805, 0.9850874551, + 0.9876209597, 0.9901181627, 0.9925801775, 0.9950080658, + 0.9974028405, 0.9997654692, 1.0020968764, 1.0043979464, + 1.0066695255, 1.0089124239, 1.0111274185, 1.0133152537 }, + { 0.6772002277, 0.6934309881, 0.7080464599, 0.7213643301, + 0.7336148970, 0.7449707526, 0.7555647772, 0.7655015856, + 0.7748651015, 0.7837237382, 0.7921340426, 0.8001433220, + 0.8077915768, 0.8151129499, 0.8221368310, 0.8288887107, + 0.8353908496, 0.8416628090, 0.8477218755, 0.8535834053, + 0.8592611049, 0.8647672624, 0.8701129393, 0.8753081305, + 0.8803618988, 0.8852824894, 0.8900774261, 0.8947535945, + 0.8993173131, 0.9037743949, 0.9081302004, 0.9123896841, + 0.9165574352, 0.9206377129, 0.9246344779, 0.9285514202, + 0.9323919830, 0.9361593853, 0.9398566405, 0.9434865742, + 0.9470518396, 0.9505549317, 0.9539981992, 0.9573838564, + 0.9607139933, 0.9639905847, 0.9672154989, 0.9703905051, + 0.9735172803, 0.9765974162, 0.9796324243, 0.9826237418, + 0.9855727362, 0.9884807098, 0.9913489039, 0.9941785028, + 0.9969706369, 0.9997263861, 1.0024467831, 1.0051328157, + 1.0077854297, 1.0104055314, 1.0129939892, 1.0155516364 }, + { 0.6405216642, 0.6580962612, 0.6739722363, 0.6884795488, + 0.7018580813, 0.7142880714, 0.7259086094, 0.7368294324, + 0.7471387455, 0.7569085832, 0.7661985859, 0.7750587283, + 0.7835313288, 0.7916525600, 0.7994535998, 0.8069615243, + 0.8142000068, 0.8211898738, 0.8279495504, 0.8344954211, + 0.8408421252, 0.8470027997, 0.8529892811, 0.8588122744, + 0.8644814947, 0.8700057878, 0.8753932324, 0.8806512276, + 0.8857865684, 0.8908055105, 0.8957138271, 0.9005168576, + 0.9052195513, 0.9098265046, 0.9143419945, 0.9187700080, + 0.9231142680, 0.9273782568, 0.9315652364, 0.9356782672, + 0.9397202245, 0.9436938133, 0.9476015819, 0.9514459336, + 0.9552291382, 0.9589533414, 0.9626205741, 0.9662327603, + 0.9697917251, 0.9732992008, 0.9767568340, 0.9801661903, + 0.9835287605, 0.9868459649, 0.9901191578, 0.9933496315, + 0.9965386205, 0.9996873045, 1.0027968119, 1.0058682226, + 1.0089025710, 1.0119008485, 1.0148640056, 1.0177929548 }, + { 0.6058296875, 0.6245620637, 0.6415378101, 0.6570938835, + 0.6714759586, 0.6848691001, 0.6974164561, 0.7092312055, + 0.7204044988, 0.7310109103, 0.7411122884, 0.7507605397, + 0.7599996842, 0.7688674015, 0.7773962122, 0.7856143935, + 0.7935466990, 0.8012149303, 0.8086383963, 0.8158342858, + 0.8228179717, 0.8296032631, 0.8362026133, 0.8426272954, + 0.8488875492, 0.8549927056, 0.8609512936, 0.8667711307, + 0.8724594015, 0.8780227256, 0.8834672161, 0.8887985309, + 0.8940219180, 0.8991422543, 0.9041640810, 0.9090916337, + 0.9139288704, 0.9186794948, 0.9233469789, 0.9279345818, + 0.9324453671, 0.9368822185, 0.9412478543, 0.9455448393, + 0.9497755970, 0.9539424198, 0.9580474782, 0.9620928299, + 0.9660804271, 0.9700121244, 0.9738896845, 0.9777147851, + 0.9814890239, 0.9852139236, 0.9888909370, 0.9925214512, + 0.9961067913, 0.9996482244, 1.0031469629, 1.0066041676, + 1.0100209506, 1.0133983785, 1.0167374742, 1.0200392198 }, + { 0.5730166999, 0.5927366473, 0.6106642672, 0.6271389942, + 0.6424090212, 0.6566617910, 0.6700426292, 0.6826666808, + 0.6946268614, 0.7059993279, 0.7168473476, 0.7272241023, + 0.7371747608, 0.7467380401, 0.7559474006, 0.7648319736, + 0.7734172908, 0.7817258650, 0.7897776570, 0.7975904541, + 0.8051801811, 0.8125611560, 0.8197463039, 0.8267473349, + 0.8335748949, 0.8402386937, 0.8467476129, 0.8531098003, + 0.8593327495, 0.8654233698, 0.8713880464, 0.8772326935, + 0.8829628002, 0.8885834710, 0.8940994619, 0.8995152120, + 0.9048348715, 0.9100623268, 0.9152012229, 0.9202549833, + 0.9252268281, 0.9301197899, 0.9349367288, 0.9396803449, + 0.9443531909, 0.9489576823, 0.9534961076, 0.9579706374, + 0.9623833320, 0.9667361492, 0.9710309512, 0.9752695109, + 0.9794535174, 0.9835845813, 0.9876642399, 0.9916939614, + 0.9956751493, 0.9996091459, 1.0034972362, 1.0073406510, + 1.0111405700, 1.0148981248, 1.0186144013, 1.0222904422 }, + { 0.5419809316, 0.5625329386, 0.5812764912, 0.5985496562, + 0.6146003370, 0.6296162401, 0.6437432340, 0.6570971404, + 0.6697716039, 0.6818435182, 0.6933768712, 0.7044255353, + 0.7150353340, 0.7252456009, 0.7350903742, 0.7445993259, + 0.7537984929, 0.7627108595, 0.7713568269, 0.7797545943, + 0.7879204712, 0.7958691361, 0.8036138516, 0.8111666444, + 0.8185384580, 0.8257392814, 0.8327782597, 0.8396637886, + 0.8464035955, 0.8530048108, 0.8594740287, 0.8658173611, + 0.8720404845, 0.8781486812, 0.8841468762, 0.8900396688, + 0.8958313620, 0.9015259874, 0.9071273286, 0.9126389413, + 0.9180641715, 0.9234061727, 0.9286679198, 0.9338522236, + 0.9389617420, 0.9439989920, 0.9489663591, 0.9538661069, + 0.9587003852, 0.9634712378, 0.9681806094, 0.9728303524, + 0.9774222323, 0.9819579336, 0.9864390644, 0.9908671615, + 0.9952436943, 0.9995700689, 1.0038476318, 1.0080776733, + 1.0122614305, 1.0164000906, 1.0204947932, 1.0245466331 }, + { 0.5126261246, 0.5338683013, 0.5533029807, 0.5712636181, + 0.5879954388, 0.6036845987, 0.6184760989, 0.6324853169, + 0.6458057215, 0.6585142011, 0.6706748475, 0.6823417062, + 0.6935608163, 0.7043717519, 0.7148088052, 0.7249019070, + 0.7346773529, 0.7441583823, 0.7533656456, 0.7623175831, + 0.7710307376, 0.7795200117, 0.7877988829, 0.7958795841, + 0.8037732557, 0.8114900754, 0.8190393682, 0.8264297018, + 0.8336689680, 0.8407644543, 0.8477229049, 0.8545505751, + 0.8612532786, 0.8678364291, 0.8743050768, 0.8806639416, + 0.8869174414, 0.8930697184, 0.8991246621, 0.9050859297, + 0.9109569648, 0.9167410144, 0.9224411436, 0.9280602496, + 0.9336010737, 0.9390662129, 0.9444581300, 0.9497791628, + 0.9550315328, 0.9602173528, 0.9653386345, 0.9703972943, + 0.9753951600, 0.9803339761, 0.9852154088, 0.9900410510, + 0.9948124263, 0.9995309934, 1.0041981497, 1.0088152348, + 1.0133835335, 1.0179042791, 1.0223786564, 1.0268078035 }, +}; + +#endif /* AVCODEC_WMAVOICE_DATA_H */ diff --git a/lib/rbcodec/codecs/libwmavoice/wmavoice_mainbuild.patch b/lib/rbcodec/codecs/libwmavoice/wmavoice_mainbuild.patch new file mode 100644 index 0000000000..cf349299bd --- /dev/null +++ b/lib/rbcodec/codecs/libwmavoice/wmavoice_mainbuild.patch @@ -0,0 +1,32 @@ +Index: ../codecs.make +=================================================================== +--- ../codecs.make (revision 27762) ++++ ../codecs.make (working copy) +@@ -38,6 +38,7 @@ + include $(APPSDIR)/codecs/libwavpack/libwavpack.make + include $(APPSDIR)/codecs/libwma/libwma.make + include $(APPSDIR)/codecs/libwmapro/libwmapro.make ++include $(APPSDIR)/codecs/libwmavoice/libwmavoice.make + include $(APPSDIR)/codecs/libcook/libcook.make + include $(APPSDIR)/codecs/librm/librm.make + include $(APPSDIR)/codecs/libatrac/libatrac.make +@@ -79,6 +80,7 @@ + $(CODECDIR)/ape.codec : $(CODECDIR)/libdemac.a + $(CODECDIR)/wma.codec : $(CODECDIR)/libwma.a $(CODECDIR)/libasf.a + $(CODECDIR)/wmapro.codec : $(CODECDIR)/libwmapro.a $(CODECDIR)/libasf.a ++$(CODECDIR)/wmavoice.codec : $(CODECDIR)/libwmavoice.a $(CODECDIR)/libasf.a + $(CODECDIR)/wavpack_enc.codec: $(CODECDIR)/libwavpack.a + $(CODECDIR)/asap.codec : $(CODECDIR)/libasap.a + $(CODECDIR)/cook.codec : $(CODECDIR)/libcook.a $(CODECDIR)/librm.a +Index: ../SOURCES +=================================================================== +--- ../SOURCES (revision 27762) ++++ ../SOURCES (working copy) +@@ -33,6 +33,7 @@ + wav64.c + tta.c + wmapro.c ++wmavoice.c + + #ifdef HAVE_RECORDING + diff --git a/lib/rbcodec/codecs/mod.c b/lib/rbcodec/codecs/mod.c new file mode 100644 index 0000000000..5bd64994f1 --- /dev/null +++ b/lib/rbcodec/codecs/mod.c @@ -0,0 +1,1353 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * MOD Codec for rockbox + * + * Written from scratch by Rainer Sinsch + * exclusivly for Rockbox in February 2008 + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + + /************** + * This version supports large files directly from internal memory management. + * There is a drawback however: It may happen that a song is not completely + * loaded when the internal rockbox-ringbuffer (approx. 28MB) is filled up + * As a workaround make sure you don't have directories with mods larger + * than a total of 28MB + *************/ + +#include "debug.h" +#include "codeclib.h" +#include + +#include +#include +#include +#include + + +CODEC_HEADER + +#define CHUNK_SIZE (1024*2) + + +/* This codec supports MOD Files: + * + */ + +static int32_t samples[CHUNK_SIZE] IBSS_ATTR; /* The sample buffer */ + +/* Instrument Data */ +struct s_instrument { + /* Sample name / description */ + /*char description[22];*/ + + /* Sample length in bytes */ + unsigned short length; + + /* Sample finetuning (-8 - +7) */ + signed char finetune; + + /* Sample volume (0 - 64) */ + signed char volume; + + /* Sample Repeat Position */ + unsigned short repeatoffset; + + /* Sample Repeat Length */ + unsigned short repeatlength; + + /* Offset to sample data */ + unsigned int sampledataoffset; +}; + +/* Song Data */ +struct s_song { + /* Song name / title description */ + /*char szTitle[20];*/ + + /* No. of channels in song */ + unsigned char noofchannels; + + /* No. of instruments used (either 15 or 31) */ + unsigned char noofinstruments; + + /* How many patterns are beeing played? */ + unsigned char songlength; + + /* Where to jump after the song end? */ + unsigned char songendjumpposition; + + /* Pointer to the Pattern Order Table */ + unsigned char *patternordertable; + + /* Pointer to the pattern data */ + void *patterndata; + + /* Pointer to the sample buffer */ + signed char *sampledata; + + /* Instrument data */ + struct s_instrument instrument[31]; +}; + +struct s_modchannel { + /* Current Volume */ + signed char volume; + + /* Current Offset to period in PeriodTable of notebeeing played + (can be temporarily negative) */ + short periodtableoffset; + + /* Current Period beeing played */ + short period; + + /* Current effect */ + unsigned char effect; + + /* Current parameters of effect */ + unsigned char effectparameter; + + /* Current Instrument beeing played */ + unsigned char instrument; + + /* Current Vibrato Speed */ + unsigned char vibratospeed; + + /* Current Vibrato Depth */ + unsigned char vibratodepth; + + /* Current Position for Vibrato in SinTable */ + unsigned char vibratosinpos; + + /* Current Tremolo Speed */ + unsigned char tremolospeed; + + /* Current Tremolo Depth */ + unsigned char tremolodepth; + + /* Current Position for Tremolo in SinTable */ + unsigned char tremolosinpos; + + /* Current Speed of Effect "Slide Note up" */ + unsigned char slideupspeed; + + /* Current Speed of Effect "Slide Note down" */ + unsigned char slidedownspeed; + + /* Current Speed of the "Slide to Note" effect */ + unsigned char slidetonotespeed; + + /* Current Period of the "Slide to Note" effect */ + unsigned short slidetonoteperiod; +}; + +struct s_modplayer { + /* Ticks per Line */ + unsigned char ticksperline; + + /* Beats per Minute */ + unsigned char bpm; + + /* Position of the Song in the Pattern Table (0-127) */ + unsigned char patterntableposition; + + /* Current Line (may be temporarily < 0) */ + signed char currentline; + + /* Current Tick */ + signed char currenttick; + + /* How many samples are required to calculate for each tick? */ + unsigned int samplespertick; + + /* Information about the channels */ + struct s_modchannel modchannel[8]; + + /* The Amiga Period Table */ + unsigned short *periodtable; + + /* The sinus table [-255,255] */ + signed short *sintable; + + /* Is the glissando effect enabled? */ + bool glissandoenabled; + + /* Is the Amiga Filter enabled? */ + bool amigafilterenabled; + + /* The pattern-line where the loop is carried out (set with e6 command) */ + unsigned char loopstartline; + + /* Number of times to loop */ + unsigned char looptimes; +}; + +struct s_channel { + /* Panning (0 = left, 16 = right) */ + unsigned char panning; + + /* Sample frequency of the channel */ + unsigned short frequency; + + /* Position of the sample currently played */ + unsigned int samplepos; + + /* Fractual Position of the sample currently player */ + unsigned int samplefractpos; + + /* Loop Sample */ + bool loopsample; + + /* Loop Position Start */ + unsigned int loopstart; + + /* Loop Position End */ + unsigned int loopend; + + /* Is The channel beeing played? */ + bool channelactive; + + /* The Volume (0..64) */ + signed char volume; + + /* The last sampledata beeing played (required for interpolation) */ + signed short lastsampledata; +}; + +struct s_mixer { + /* The channels */ + struct s_channel channel[32]; +}; + +struct s_song modsong IDATA_ATTR; /* The Song */ +struct s_modplayer modplayer IDATA_ATTR; /* The Module Player */ +struct s_mixer mixer IDATA_ATTR; + +/* The Amiga Period Table (+1 because we use index 0 for period 0 = no new note) */ +static unsigned short s_periodtable[37*8+1] IDATA_ATTR = + { 0, 907, 900, 893, 887, 881, 874, 868, + 862, 856, 849, 843, 837, 831, 825, 819, + 813, 808, 802, 796, 790, 785, 779, 773, + 768, 762, 757, 751, 746, 740, 735, 730, + 725, 719, 714, 709, 704, 699, 694, 689, + 684, 679, 674, 669, 664, 660, 655, 650, + 645, 641, 636, 632, 627, 623, 618, 614, + 609, 605, 600, 596, 592, 588, 583, 579, + 575, 571, 567, 563, 559, 555, 551, 547, + 543, 539, 535, 531, 527, 523, 520, 516, + 512, 509, 505, 501, 498, 494, 490, 487, + 483, 480, 477, 473, 470, 466, 463, 460, + 456, 453, 450, 446, 443, 440, 437, 434, + 431, 428, 424, 421, 418, 415, 412, 409, + 406, 404, 401, 398, 395, 392, 389, 386, + 384, 381, 378, 375, 373, 370, 367, 365, + 362, 359, 357, 354, 352, 349, 347, 344, + 342, 339, 337, 334, 332, 330, 327, 325, + 322, 320, 318, 316, 313, 311, 309, 307, + 304, 302, 300, 298, 296, 294, 291, 289, + 287, 285, 283, 281, 279, 277, 275, 273, + 271, 269, 267, 265, 263, 261, 260, 258, + 256, 254, 252, 250, 249, 247, 245, 243, + 241, 240, 238, 236, 235, 233, 231, 230, + 228, 226, 225, 223, 221, 220, 218, 217, + 215, 214, 212, 210, 209, 207, 206, 204, + 203, 202, 200, 199, 197, 196, 194, 193, + 192, 190, 189, 187, 186, 185, 183, 182, + 181, 179, 178, 177, 176, 174, 173, 172, + 171, 169, 168, 167, 166, 165, 163, 162, + 161, 160, 159, 158, 156, 155, 154, 153, + 152, 151, 150, 149, 148, 147, 145, 144, + 143, 142, 141, 140, 139, 138, 137, 136, + 135, 134, 133, 132, 131, 130, 130, 129, + 128, 127, 126, 125, 124, 123, 122, 121, + 120, 120, 119, 118, 117, 116, 115, 115, + 114, 113, 112, 111, 110, 110, 109, 108, + 107}; + +/* The sin table */ +static signed short s_sintable[0x40] IDATA_ATTR = + { 0, 25, 49, 74, 97, 120, 141, 162, + 180, 197, 212, 225, 235, 244, 250, 254, + 255, 254, 250, 244, 235, 225, 212, 197, + 180, 161, 141, 120, 97, 73, 49, 24, + 0, -25, -50, -74, -98, -120, -142, -162, + -180, -197, -212, -225, -236, -244, -250, -254, + -255, -254, -250, -244, -235, -224, -211, -197, + -180, -161, -141, -119, -97, -73, -49, -24}; + +const unsigned short mixingrate = 44100; + +STATICIRAM void mixer_playsample(int channel, int instrument) ICODE_ATTR; +void mixer_playsample(int channel, int instrument) +{ + struct s_channel *p_channel = &mixer.channel[channel]; + struct s_instrument *p_instrument = &modsong.instrument[instrument]; + + p_channel->channelactive = true; + p_channel->samplepos = p_instrument->sampledataoffset; + p_channel->samplefractpos = 0; + p_channel->loopsample = (p_instrument->repeatlength > 2); + if (p_channel->loopsample) { + p_channel->loopstart = p_instrument->repeatoffset + + p_instrument->sampledataoffset; + p_channel->loopend = p_channel->loopstart + + p_instrument->repeatlength; + } + else p_channel->loopend = p_instrument->length + + p_instrument->sampledataoffset; + + /* Remember the instrument */ + modplayer.modchannel[channel].instrument = instrument; +} + +static inline void mixer_stopsample(int channel) +{ + mixer.channel[channel].channelactive = false; +} + +static inline void mixer_continuesample(int channel) +{ + mixer.channel[channel].channelactive = true; +} + +static inline void mixer_setvolume(int channel, int volume) +{ + mixer.channel[channel].volume = volume; +} + +static inline void mixer_setpanning(int channel, int panning) +{ + mixer.channel[channel].panning = panning; +} + +static inline void mixer_setamigaperiod(int channel, int amigaperiod) +{ + /* Just to make sure we don't devide by zero + * amigaperiod shouldn't 0 anyway - if it is the case + * then something terribly went wrong */ + if (amigaperiod == 0) + return; + + mixer.channel[channel].frequency = 3579546 / amigaperiod; +} + +/* Initialize the MOD Player with default values and precalc tables */ +STATICIRAM void initmodplayer(void) ICODE_ATTR; +void initmodplayer(void) +{ + unsigned int c; +#if 0 + /* As the calculation of periodtable and sintable uses float and double + * rockbox uses two predefined tables. This reduces the codesize by + * several KB. */ + + unsigned int i; + /* Calculate Amiga Period Values + * Start with Period 907 (= C-1 with Finetune -8) and work upwards */ + double f = 907.0f; + /* Index 0 stands for no note (and therefore no period) */ + modplayer.periodtable[0] = 0; + for (i=1;i<297;i++) + { + modplayer.periodtable[i] = (unsigned short) f; + f /= 1.0072464122237039; /* = pow(2.0f, 1.0f/(12.0f*8.0f)); */ + } + + /* + * This is a more accurate but also time more consuming approach + * to calculate the amiga period table + * Commented out for speed purposes + const int finetuning = 8; + const int octaves = 3; + for (int halftone=0;halftone<=finetuning*octaves*12+7;halftone++) + { + float e = pow(2.0f, halftone/(12.0f*8.0f)); + float f = 906.55f/e; + modplayer.periodtable[halfetone+1] = (int)(f+0.5f); + } + */ + + /* Calculate Protracker Vibrato sine table + * The routine makes use of the Harmonical Oscillator Approach + * for calculating sine tables + * (see http://membres.lycos.fr/amycoders/tutorials/sintables.html) + * The routine presented here calculates a complete sine wave + * with 64 values in range [-255,255] + */ + float a, b, d, dd; + + d = 0.09817475f; /* = 2*PI/64 */ + dd = d*d; + a = 0; + b = d; + + for (i=0;i<0x40;i++) + { + modplayer.sintable[i] = (int)(255*a); + + a = a+b; + b = b-dd*a; + } +#else + /* Point to the predefined tables */ + modplayer.periodtable = s_periodtable; + modplayer.sintable = s_sintable; +#endif + /* Set Default Player Values */ + modplayer.currentline = 0; + modplayer.currenttick = 0; + modplayer.patterntableposition = 0; + modplayer.bpm = 125; + modplayer.ticksperline = 6; + modplayer.glissandoenabled = false; /* Disable glissando */ + modplayer.amigafilterenabled = false; /* Disable the Amiga Filter */ + + /* Default Panning Values */ + int panningvalues[8] = {4,12,12,4,4,12,12,4}; + for (c=0;c<8;c++) + { + /* Set Default Panning */ + mixer_setpanning(c, panningvalues[c]); + /* Reset channels in the MOD Player */ + memset(&modplayer.modchannel[c], 0, sizeof(struct s_modchannel)); + /* Don't play anything */ + mixer.channel[c].channelactive = false; + } + +} + +/* Load the MOD File from memory */ +STATICIRAM bool loadmod(void *modfile) ICODE_ATTR; +bool loadmod(void *modfile) +{ + int i; + unsigned char *periodsconverted; + + /* We don't support PowerPacker 2.0 Files */ + if (memcmp((char*) modfile, "PP20", 4) == 0) return false; + + /* Get the File Format Tag */ + char *fileformattag = (char*)modfile + 1080; + + /* Find out how many channels and instruments are used */ + if (memcmp(fileformattag, "2CHN", 4) == 0) + {modsong.noofchannels = 2; modsong.noofinstruments = 31;} + else if (memcmp(fileformattag, "M.K.", 4) == 0) + {modsong.noofchannels = 4; modsong.noofinstruments = 31;} + else if (memcmp(fileformattag, "M!K!", 4) == 0) + {modsong.noofchannels = 4; modsong.noofinstruments = 31;} + else if (memcmp(fileformattag, "4CHN", 4) == 0) + {modsong.noofchannels = 4; modsong.noofinstruments = 31;} + else if (memcmp(fileformattag, "FLT4", 4) == 0) + {modsong.noofchannels = 4; modsong.noofinstruments = 31;} + else if (memcmp(fileformattag, "6CHN", 4) == 0) + {modsong.noofchannels = 6; modsong.noofinstruments = 31;} + else if (memcmp(fileformattag, "8CHN", 4) == 0) + {modsong.noofchannels = 8; modsong.noofinstruments = 31;} + else if (memcmp(fileformattag, "OKTA", 4) == 0) + {modsong.noofchannels = 8; modsong.noofinstruments = 31;} + else if (memcmp(fileformattag, "CD81", 4) == 0) + {modsong.noofchannels = 8; modsong.noofinstruments = 31;} + else { + /* The file has no format tag, so most likely soundtracker */ + modsong.noofchannels = 4; + modsong.noofinstruments = 15; + } + + /* Get the Song title + * Skipped here + * strncpy(modsong.szTitle, (char*)pMODFile, 20); */ + + /* Get the Instrument information */ + for (i=0;idescription, (char*)p, 22); */ + p += 22; + instrument->length = (((p[0])<<8) + p[1]) << 1; p+=2; + instrument->finetune = *p++ & 0x0f; + /* Treat finetuning as signed nibble */ + if (instrument->finetune > 7) instrument->finetune -= 16; + instrument->volume = *p++; + instrument->repeatoffset = (((p[0])<<8) + p[1]) << 1; p+= 2; + instrument->repeatlength = (((p[0])<<8) + p[1]) << 1; + } + + /* Get the pattern information */ + unsigned char *p = (unsigned char *)modfile + 20 + + modsong.noofinstruments*30; + modsong.songlength = *p++; + modsong.songendjumpposition = *p++; + modsong.patternordertable = p; + + /* Find out how many patterns are used within this song */ + int maxpatterns = 0; + for (i=0;i<128;i++) + if (modsong.patternordertable[i] > maxpatterns) + maxpatterns = modsong.patternordertable[i]; + maxpatterns++; + + /* use 'restartposition' (historically set to 127) which is not used here + as a marker that periods have already been converted */ + + periodsconverted = (char*)modfile + 20 + modsong.noofinstruments*30 + 1; + + /* Get the pattern data; ST doesn't have fileformattag, so 4 bytes less */ + modsong.patterndata = periodsconverted + + (modsong.noofinstruments==15 ? 129 : 133); + + /* Convert the period values in the mod file to offsets + * in our periodtable (but only, if we haven't done this yet) */ + p = (unsigned char *) modsong.patterndata; + if (*periodsconverted != 0xfe) + { + int note, note2, channel; + for (note=0;note> 8) | (p[0] & 0xf0); + p[1] = periodoffset & 0xff; + p += 4; + } + /* Remember that we already converted the periods, + * in case the file gets reloaded by rewinding + * with 0xfe (arbitary magic value > 127) */ + *periodsconverted = 0xfe; + } + + /* Get the samples + * Calculation: The Samples come after the pattern data + * We know that there are nMaxPatterns and each pattern requires + * 4 bytes per note and per channel. + * And of course there are always lines in each channel */ + modsong.sampledata = (signed char*) modsong.patterndata + + maxpatterns*4*modsong.noofchannels*64; + int sampledataoffset = 0; + for (i=0;i> 7 is used in the original protracker source code */ + mixer_setamigaperiod(channel, p_modchannel->period+ + ((p_modchannel->vibratodepth * + modplayer.sintable[p_modchannel->vibratosinpos])>>7)); + + /* Foward in Sine Table */ + p_modchannel->vibratosinpos += p_modchannel->vibratospeed; + p_modchannel->vibratosinpos &= 0x3f; +} + +/* Apply tremolo to channel + * (same as vibrato, but only apply on volume instead of pitch) */ +STATICIRAM void tremolo(int channel) ICODE_ATTR; +void tremolo(int channel) +{ + struct s_modchannel *p_modchannel = &modplayer.modchannel[channel]; + + /* Apply Tremolo + * >> 6 is used in the original protracker source code */ + int volume = (p_modchannel->volume * + modplayer.sintable[p_modchannel->tremolosinpos])>>6; + if (volume > 64) volume = 64; + else if (volume < 0) volume = 0; + mixer_setvolume(channel, volume); + + /* Foward in Sine Table */ + p_modchannel->tremolosinpos += p_modchannel->tremolosinpos; + p_modchannel->tremolosinpos &= 0x3f; +} + +/* Apply Slide to Note effect to channel */ +STATICIRAM void slidetonote(int channel) ICODE_ATTR; +void slidetonote(int channel) +{ + struct s_modchannel *p_modchannel = &modplayer.modchannel[channel]; + + /* If there hasn't been any slide-to note set up, then return */ + if (p_modchannel->slidetonoteperiod == 0) return; + + /* Slide note up */ + if (p_modchannel->slidetonoteperiod > p_modchannel->period) + { + p_modchannel->period += p_modchannel->slidetonotespeed; + if (p_modchannel->period > p_modchannel->slidetonoteperiod) + p_modchannel->period = p_modchannel->slidetonoteperiod; + } + /* Slide note down */ + else if (p_modchannel->slidetonoteperiod < p_modchannel->period) + { + p_modchannel->period -= p_modchannel->slidetonotespeed; + if (p_modchannel->period < p_modchannel->slidetonoteperiod) + p_modchannel->period = p_modchannel->slidetonoteperiod; + } + mixer_setamigaperiod(channel, p_modchannel->period); +} + +/* Apply Slide to Note effect on channel, + * but this time with glissando enabled */ +STATICIRAM void slidetonoteglissando(int channel) ICODE_ATTR; +void slidetonoteglissando(int channel) +{ + struct s_modchannel *p_modchannel = &modplayer.modchannel[channel]; + + /* Slide note up */ + if (p_modchannel->slidetonoteperiod > p_modchannel->period) + { + p_modchannel->period = + modplayer.periodtable[p_modchannel->periodtableoffset+=8]; + if (p_modchannel->period > p_modchannel->slidetonoteperiod) + p_modchannel->period = p_modchannel->slidetonoteperiod; + } + /* Slide note down */ + else + { + p_modchannel->period = + modplayer.periodtable[p_modchannel->periodtableoffset-=8]; + if (p_modchannel->period < p_modchannel->slidetonoteperiod) + p_modchannel->period = p_modchannel->slidetonoteperiod; + } + mixer_setamigaperiod(channel, p_modchannel->period); +} + +/* Apply Volume Slide */ +STATICIRAM void volumeslide(int channel, int effectx, int effecty) ICODE_ATTR; +void volumeslide(int channel, int effectx, int effecty) +{ + struct s_modchannel *p_modchannel = &modplayer.modchannel[channel]; + + /* If both X and Y Parameters are non-zero, then the y value is ignored */ + if (effectx > 0) { + p_modchannel->volume += effectx; + if (p_modchannel->volume > 64) p_modchannel->volume = 64; + } + else { + p_modchannel->volume -= effecty; + if (p_modchannel->volume < 0) p_modchannel->volume = 0; + } + + mixer_setvolume(channel, p_modchannel->volume); +} + +/* Play the current line (at tick 0) */ +STATICIRAM void playline(int pattern, int line) ICODE_ATTR; +void playline(int pattern, int line) +{ + int c; + + /* Get pointer to the current pattern */ + unsigned char *p_line = (unsigned char*)modsong.patterndata; + p_line += pattern*64*4*modsong.noofchannels; + p_line += line*4*modsong.noofchannels; + + /* Only allow one Patternbreak Commando per Line */ + bool patternbreakdone = false; + + for (c=0;c> 4); + short periodtableoffset = ((p_note[0] & 0x0f) << 8) | p_note[1]; + + p_modchannel->effect = p_note[2] & 0x0f; + p_modchannel->effectparameter = p_note[3]; + + /* Remember Instrument and set Volume if new Instrument triggered */ + if (samplenumber > 0) + { + /* And trigger new sample, if new instrument was set */ + if (samplenumber-1 != p_modchannel->instrument) + { + /* Advance the new sample to the same offset + * the old sample was beeing played */ + int oldsampleoffset = mixer.channel[c].samplepos - + modsong.instrument[ + p_modchannel->instrument].sampledataoffset; + mixer_playsample(c, samplenumber-1); + mixer.channel[c].samplepos += oldsampleoffset; + } + + /* Remember last played instrument on channel */ + p_modchannel->instrument = samplenumber-1; + + /* Set Volume to standard instrument volume, + * if not overwritten by volume effect */ + if (p_modchannel->effect != 0x0c) + { + p_modchannel->volume = modsong.instrument[ + p_modchannel->instrument].volume; + mixer_setvolume(c, p_modchannel->volume); + } + } + /* Trigger new sample if note available */ + if (periodtableoffset > 0) + { + /* Restart instrument only when new sample triggered */ + if (samplenumber != 0) + mixer_playsample(c, (samplenumber > 0) ? + samplenumber-1 : p_modchannel->instrument); + + /* Set the new amiga period + * (but only, if there is no slide to note effect) */ + if ((p_modchannel->effect != 0x3) && + (p_modchannel->effect != 0x5)) + { + /* Apply finetuning to sample */ + p_modchannel->periodtableoffset = periodtableoffset + + modsong.instrument[p_modchannel->instrument].finetune; + p_modchannel->period = modplayer.periodtable[ + p_modchannel->periodtableoffset]; + mixer_setamigaperiod(c, p_modchannel->period); + /* When a new note is played without slide to note setup, + * then disable slide to note */ + modplayer.modchannel[c].slidetonoteperiod = + p_modchannel->period; + } + } + int effectx = p_modchannel->effectparameter>>4; + int effecty = p_modchannel->effectparameter&0x0f; + + switch (p_modchannel->effect) + { + /* Effect 0: Arpeggio */ + case 0x00: + /* Set the base period on tick 0 */ + if (p_modchannel->effectparameter > 0) + mixer_setamigaperiod(c, + modplayer.periodtable[ + p_modchannel->periodtableoffset]); + break; + /* Slide up (Portamento up) */ + case 0x01: + if (p_modchannel->effectparameter > 0) + p_modchannel->slideupspeed = + p_modchannel->effectparameter; + break; + + /* Slide down (Portamento down) */ + case 0x02: + if (p_modchannel->effectparameter > 0) + p_modchannel->slidedownspeed = + p_modchannel->effectparameter; + break; + + /* Slide to Note */ + case 0x03: + if (p_modchannel->effectparameter > 0) + p_modchannel->slidetonotespeed = + p_modchannel->effectparameter; + /* Get the slide to note directly from the pattern buffer */ + if (periodtableoffset > 0) + p_modchannel->slidetonoteperiod = + modplayer.periodtable[periodtableoffset + + modsong.instrument[ + p_modchannel->instrument].finetune]; + /* If glissando is enabled apply the effect directly here */ + if (modplayer.glissandoenabled) + slidetonoteglissando(c); + break; + + /* Set Vibrato */ + case 0x04: + if (effectx > 0) p_modchannel->vibratospeed = effectx; + if (effecty > 0) p_modchannel->vibratodepth = effecty; + break; + + /* Effect 0x06: Slide to note */ + case 0x05: + /* Get the slide to note directly from the pattern buffer */ + if (periodtableoffset > 0) + p_modchannel->slidetonoteperiod = + modplayer.periodtable[periodtableoffset + + modsong.instrument[ + p_modchannel->instrument].finetune]; + break; + + /* Effect 0x06 is "Continue Effects" */ + /* It is not processed on tick 0 */ + case 0x06: + break; + + /* Set Tremolo */ + case 0x07: + if (effectx > 0) p_modchannel->tremolodepth = effectx; + if (effecty > 0) p_modchannel->tremolospeed = effecty; + break; + + /* Set fine panning */ + case 0x08: + /* Internal panning goes from 0..15 + * Scale the fine panning value to that range */ + mixer.channel[c].panning = p_modchannel->effectparameter>>4; + break; + + /* Set Sample Offset */ + case 0x09: + { + struct s_instrument *p_instrument = + &modsong.instrument[p_modchannel->instrument]; + int sampleoffset = p_instrument->sampledataoffset; + if (sampleoffset > p_instrument->length) + sampleoffset = p_instrument->length; + /* Forward the new offset to the mixer */ + mixer.channel[c].samplepos = + p_instrument->sampledataoffset + + (p_modchannel->effectparameter<<8); + mixer.channel[c].samplefractpos = 0; + break; + } + + /* Effect 0x0a (Volume slide) is not processed on tick 0 */ + + /* Position Jump */ + case 0x0b: + modplayer.currentline = -1; + modplayer.patterntableposition = (effectx<<4)+effecty; + break; + + /* Set Volume */ + case 0x0c: + p_modchannel->volume = p_modchannel->effectparameter; + mixer_setvolume(c, p_modchannel->volume); + break; + + /* Pattern break */ + case 0x0d: + modplayer.currentline = effectx*10 + effecty - 1; + if (!patternbreakdone) + { + patternbreakdone = true; + modplayer.patterntableposition++; + } + break; + + /* Extended Effects */ + case 0x0e: + switch (effectx) + { + /* Set Filter */ + case 0x0: + modplayer.amigafilterenabled = (effecty == 0); + break; + /* Fineslide up */ + case 0x1: + mixer_setamigaperiod(c, p_modchannel->period -= + effecty); + if (p_modchannel->period < + modplayer.periodtable[37*8]) p_modchannel->period = 100; + /* Find out the new offset in the period table */ + if (p_modchannel->periodtableoffset < 36*8) + while (modplayer.periodtable[ + p_modchannel->periodtableoffset+8] >= p_modchannel->period) + p_modchannel->periodtableoffset+=8; + break; + /* Fineslide down */ + case 0x2: + mixer_setamigaperiod(c, + p_modchannel->period += effecty); + if (p_modchannel->periodtableoffset > 8) + while (modplayer.periodtable[ + p_modchannel->periodtableoffset-8] + <= p_modchannel->period) + p_modchannel->periodtableoffset-=8; + break; + /* Set glissando on/off */ + case 0x3: + modplayer.glissandoenabled = (effecty > 0); + break; + /* Set Vibrato waveform */ + case 0x4: + /* Currently not implemented */ + break; + /* Set Finetune value */ + case 0x5: + /* Treat as signed nibble */ + if (effecty > 7) effecty -= 16; + + p_modchannel->periodtableoffset += + effecty - + modsong.instrument[ + p_modchannel->instrument].finetune; + p_modchannel->period = + modplayer.periodtable[ + p_modchannel->periodtableoffset]; + modsong.instrument[ + p_modchannel->instrument].finetune = effecty; + break; + /* Pattern loop */ + case 0x6: + if (effecty == 0) + modplayer.loopstartline = line-1; + else + { + if (modplayer.looptimes == 0) + { + modplayer.currentline = + modplayer.loopstartline; + modplayer.looptimes = effecty; + } + else modplayer.looptimes--; + if (modplayer.looptimes > 0) + modplayer.currentline = + modplayer.loopstartline; + } + break; + /* Set Tremolo waveform */ + case 0x7: + /* Not yet implemented */ + break; + /* Enhanced Effect 8 is not used */ + case 0x8: + break; + /* Retrigger sample */ + case 0x9: + /* Only processed on subsequent ticks */ + break; + /* Fine volume slide up */ + case 0xa: + p_modchannel->volume += effecty; + if (p_modchannel->volume > 64) + p_modchannel->volume = 64; + mixer_setvolume(c, p_modchannel->volume); + break; + /* Fine volume slide down */ + case 0xb: + p_modchannel->volume -= effecty; + if (p_modchannel->volume < 0) + p_modchannel->volume = 0; + mixer_setvolume(c, p_modchannel->volume); + break; + /* Cut sample */ + case 0xc: + /* Continue sample */ + mixer_continuesample(c); + break; + /* Note delay (Usage: $ED + ticks to delay note.) */ + case 0xd: + /* We stop the sample here on tick 0 + * and restart it later in the effect */ + if (effecty > 0) + mixer.channel[c].channelactive = false; + break; + } + break; + + /* Set Speed */ + case 0x0f: + if (p_modchannel->effectparameter < 32) + modplayer.ticksperline = p_modchannel->effectparameter; + else + modplayer.bpm = p_modchannel->effectparameter; + break; + } + } +} + +/* Play the current effect of the note (ticks 1..speed) */ +STATICIRAM void playeffect(int currenttick) ICODE_ATTR; +void playeffect(int currenttick) +{ + int c; + + for (c=0;cperiod == 0) continue; + + unsigned char effectx = p_modchannel->effectparameter>>4; + unsigned char effecty = p_modchannel->effectparameter&0x0f; + + switch (p_modchannel->effect) + { + /* Effect 0: Arpeggio */ + case 0x00: + if (p_modchannel->effectparameter > 0) + { + unsigned short newperiodtableoffset; + switch (currenttick % 3) + { + case 0: + mixer_setamigaperiod(c, + modplayer.periodtable[ + p_modchannel->periodtableoffset]); + break; + case 1: + newperiodtableoffset = + p_modchannel->periodtableoffset+(effectx<<3); + if (newperiodtableoffset < 37*8) + mixer_setamigaperiod(c, + modplayer.periodtable[ + newperiodtableoffset]); + break; + case 2: + newperiodtableoffset = + p_modchannel->periodtableoffset+(effecty<<3); + if (newperiodtableoffset < 37*8) + mixer_setamigaperiod(c, + modplayer.periodtable[ + newperiodtableoffset]); + break; + } + } + break; + + /* Effect 1: Slide Up */ + case 0x01: + mixer_setamigaperiod(c, + p_modchannel->period -= p_modchannel->slideupspeed); + /* Find out the new offset in the period table */ + if (p_modchannel->periodtableoffset <= 37*8) + while (modplayer.periodtable[ + p_modchannel->periodtableoffset] > + p_modchannel->period) + { + p_modchannel->periodtableoffset++; + /* Make sure we don't go out of range */ + if (p_modchannel->periodtableoffset > 37*8) + { + p_modchannel->periodtableoffset = 37*8; + break; + } + } + break; + + /* Effect 2: Slide Down */ + case 0x02: + mixer_setamigaperiod(c, p_modchannel->period += + p_modchannel->slidedownspeed); + /* Find out the new offset in the period table */ + if (p_modchannel->periodtableoffset > 8) + while (modplayer.periodtable[ + p_modchannel->periodtableoffset] < + p_modchannel->period) + { + p_modchannel->periodtableoffset--; + /* Make sure we don't go out of range */ + if (p_modchannel->periodtableoffset < 1) + { + p_modchannel->periodtableoffset = 1; + break; + } + } + break; + + /* Effect 3: Slide to Note */ + case 0x03: + /* Apply smooth sliding, if no glissando is enabled */ + if (modplayer.glissandoenabled == 0) + slidetonote(c); + break; + + /* Effect 4: Vibrato */ + case 0x04: + vibrate(c); + break; + + /* Effect 5: Continue effect 3:'Slide to note', + * but also do Volume slide */ + case 0x05: + slidetonote(c); + volumeslide(c, effectx, effecty); + break; + + /* Effect 6: Continue effect 4:'Vibrato', + * but also do Volume slide */ + case 0x06: + vibrate(c); + volumeslide(c, effectx, effecty); + break; + + /* Effect 7: Tremolo */ + case 0x07: + tremolo(c); + break; + + /* Effect 8 (Set fine panning) is only processed at tick 0 */ + /* Effect 9 (Set sample offset) is only processed at tick 0 */ + + /* Effect A: Volume slide */ + case 0x0a: + volumeslide(c, effectx, effecty); + break; + + /* Effect B (Position jump) is only processed at tick 0 */ + /* Effect C (Set Volume) is only processed at tick 0 */ + /* Effect D (Pattern Preak) is only processed at tick 0 */ + /* Effect E (Enhanced Effect) */ + case 0x0e: + switch (effectx) + { + /* Retrigger sample ($E9 + Tick to Retrig note at) */ + case 0x9: + /* Don't device by zero */ + if (effecty == 0) effecty = 1; + /* Apply retrig */ + if (currenttick % effecty == 0) + mixer_playsample(c, p_modchannel->instrument); + break; + /* Cut note (Usage: $EC + Tick to Cut note at) */ + case 0xc: + if (currenttick == effecty) + mixer_stopsample(c); + break; + /* Delay note (Usage: $ED + ticks to delay note) */ + case 0xd: + /* If this is the correct tick, + * we start playing the sample now */ + if (currenttick == effecty) + mixer.channel[c].channelactive = true; + break; + + } + break; + /* Effect F (Set Speed) is only processed at tick 0 */ + + } + } +} + +static inline int clip(int i) +{ + if (i > 32767) return(32767); + else if (i < -32768) return(-32768); + else return(i); +} + +STATICIRAM void synthrender(int32_t *renderbuffer, int samplecount) ICODE_ATTR; +void synthrender(int32_t *renderbuffer, int samplecount) +{ + /* 125bpm equals to 50Hz (= 0.02s) + * => one tick = mixingrate/50, + * samples passing in one tick: + * mixingrate/(bpm/2.5) = 2.5*mixingrate/bpm */ + + int32_t *p_left = renderbuffer; /* int in rockbox */ + int32_t *p_right = p_left+1; + signed short s; + int qf_distance, qf_distance2; + + int i; + + int c, left, right; + + for (i=0;i= modplayer.ticksperline) + { + modplayer.currentline++; + modplayer.currenttick = 0; + if (modplayer.currentline == 64) + { + modplayer.patterntableposition++; + if (modplayer.patterntableposition >= modsong.songlength) + /* This is for Noise Tracker + * modplayer.patterntableposition = + * modsong.songendjumpposition; + * More compatible approach is restart from 0 */ + modplayer.patterntableposition=0; + modplayer.currentline = 0; + } + } + + modplayer.samplespertick = (20*mixingrate/modplayer.bpm)>>3; + } + /* Mix buffers from here + * Walk through all channels */ + left=0, right=0; + + /* If song has not stopped playing */ + if (modplayer.patterntableposition < 127) + /* Loop through all channels */ + for (c=0;c= mixer.channel[c].loopend) + { + if (mixer.channel[c].loopsample) + mixer.channel[c].samplepos -= + (mixer.channel[c].loopend- + mixer.channel[c].loopstart); + else mixer.channel[c].channelactive = false; + } + + /* If the sample has stopped playing don't mix it */ + if (!mixer.channel[c].channelactive) continue; + + /* Get the sample */ + s = (signed short)(modsong.sampledata[ + mixer.channel[c].samplepos]*mixer.channel[c].volume); + + /* Interpolate if the sample-frequency is lower + * than the mixing rate + * If you don't want interpolation simply skip this part */ + if (mixer.channel[c].frequency < mixingrate) + { + /* Low precision linear interpolation + * (fast integer based) */ + qf_distance = mixer.channel[c].samplefractpos<<16 / + mixingrate; + qf_distance2 = (1<<16)-qf_distance; + s = (qf_distance*s + qf_distance2* + mixer.channel[c].lastsampledata)>>16; + } + + /* Save the last played sample for interpolation purposes */ + mixer.channel[c].lastsampledata = s; + + /* Pan the sample */ + left += s*(16-mixer.channel[c].panning)>>3; + right += s*mixer.channel[c].panning>>3; + + /* Advance sample */ + mixer.channel[c].samplefractpos += mixer.channel[c].frequency; + while (mixer.channel[c].samplefractpos > mixingrate) + { + mixer.channel[c].samplefractpos -= mixingrate; + mixer.channel[c].samplepos++; + } + } + /* If we have more than 4 channels + * we have to make sure that we apply clipping */ + if (modsong.noofchannels > 4) { + *p_left = clip(left)<<13; + *p_right = clip(right)<<13; + } + else { + *p_left = left<<13; + *p_right = right<<13; + } + p_left+=2; + p_right+=2; + } +} + +/* this is the codec entry point */ +enum codec_status codec_main(enum codec_entry_call_reason reason) +{ + if (reason == CODEC_LOAD) { + /* Make use of 44.1khz */ + ci->configure(DSP_SET_FREQUENCY, 44100); + /* Sample depth is 28 bit host endian */ + ci->configure(DSP_SET_SAMPLE_DEPTH, 28); + /* Stereo output */ + ci->configure(DSP_SET_STEREO_MODE, STEREO_INTERLEAVED); + } + + return CODEC_OK; +} + +/* this is called for each file to process */ +enum codec_status codec_run(void) +{ + size_t n; + unsigned char *modfile; + int old_patterntableposition; + int bytesdone; + intptr_t param; + + if (codec_init()) { + return CODEC_ERROR; + } + + codec_set_replaygain(ci->id3); + + /* Load MOD file */ + ci->seek_buffer(0); + modfile = ci->request_buffer(&n, ci->filesize); + if (!modfile || n < (size_t)ci->filesize) { + return CODEC_ERROR; + } + + initmodplayer(); + loadmod(modfile); + + /* The main decoder loop */ + ci->set_elapsed(0); + bytesdone = 0; + old_patterntableposition = 0; + + while (1) { + enum codec_command_action action = ci->get_command(¶m); + + if (action == CODEC_ACTION_HALT) + break; + + if (action == CODEC_ACTION_SEEK_TIME) { + /* New time is ready in param */ + modplayer.patterntableposition = param/1000; + modplayer.currentline = 0; + ci->seek_complete(); + } + + if(old_patterntableposition != modplayer.patterntableposition) { + ci->set_elapsed(modplayer.patterntableposition*1000); + old_patterntableposition=modplayer.patterntableposition; + } + + synthrender(samples, CHUNK_SIZE/2); + + bytesdone += CHUNK_SIZE; + + ci->pcmbuf_insert(samples, NULL, CHUNK_SIZE/2); + + } + + return CODEC_OK; +} diff --git a/lib/rbcodec/codecs/mp3_enc.c b/lib/rbcodec/codecs/mp3_enc.c new file mode 100644 index 0000000000..2f5528f74c --- /dev/null +++ b/lib/rbcodec/codecs/mp3_enc.c @@ -0,0 +1,2629 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2006 Antonius Hellmann + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +// Shine is an MP3 encoder +// Copyright (C) 1999-2000 Gabriel Bouvigne +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Library General Public +// License as published by the Free Software Foundation; either +// version 2 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Library General Public License for more details. + +#include +#include "codeclib.h" + +CODEC_ENC_HEADER + +#define ENC_PADDING_FRAMES1 2 +#define ENC_PADDING_FRAMES2 4 +#define ENC_DELAY_SAMP 576 +#define ENC_DELAY_SIZE (ENC_DELAY_SAMP*4) +#define SAMP_PER_FRAME1 1152 +#define SAMP_PER_FRAME2 576 +#define PCM_CHUNK_SIZE1 (SAMP_PER_FRAME1*4) +#define PCM_CHUNK_SIZE2 (SAMP_PER_FRAME2*4) +#define SAMPL2 576 +#define SBLIMIT 32 +#define HTN 16 +#define memcpy ci->memcpy +#define memset ci->memset +#define putlong(c, s) if(s+sz <= 32) { cc = (cc << s) | c; sz+= s; } \ + else { putbits(cc, sz); cc = c; sz = s; } + +typedef struct { + int type; /* 0=(MPEG2 - 22.05,24,16kHz) 1=(MPEG1 - 44.1,48,32kHz) */ + int mode; /* 0=stereo, 1=jstereo, 2=dual, 3=mono */ + int bitrate; + int padding; + int num_bands; + long bitr_id; + int smpl_id; +} mpeg_t; + +/* Side information */ +typedef struct { + uint32_t part2_3_length; + int count1; /* number of 0-1-quadruples */ + uint32_t global_gain; + uint32_t table_select[4]; + uint32_t region_0_1; + uint32_t address1; + uint32_t address2; + uint32_t address3; + long quantStep; + long additStep; + uint32_t max_val; +} side_info_t; + +typedef struct { + side_info_t cod_info[2][2]; + mpeg_t mpg; + long frac_per_frame; + long byte_per_frame; + long slot_lag; + int sideinfo_len; + int mean_bits; + int ResvSize; + int channels; + int rec_mono_mode; + int granules; + long samplerate; +} config_t; + +typedef struct { + int bitpos; /* current bitpos for writing */ + uint32_t bbuf[263]; +} BF_Data; + +struct huffcodetab { + int len; /* max. index */ + const uint8_t *table; /* pointer to array[len][len] */ + const uint8_t *hlen; /* pointer to array[len][len] */ +}; + +struct huffcodebig { + int len; /* max. index */ + int linbits; /* number of linbits */ + int linmax; /* max number stored in linbits */ +}; + +#define shft4(x) ((x + 8) >> 4) +#define shft9(x) ((x + 256) >> 9) +#define shft13(x) ((x + 4096) >> 13) +#define shft15(x) ((x + 16384) >> 15) +#define shft16(x) ((x + 32768) >> 16) +#define shft_n(x,n) ((x) >> n) +#define SQRT 724 /* sqrt(2) * 512 */ + +static short mfbuf [2*(1152+512)] IBSS_ATTR; /* 3328 Bytes */ +static int sb_data [2][2][18][SBLIMIT] IBSS_ATTR; /* 13824 Bytes */ +static int mdct_freq [SAMPL2] IBSS_ATTR; /* 2304 Bytes */ +static char mdct_sign [SAMPL2] IBSS_ATTR; /* 576 Bytes */ +static short enc_data [SAMPL2] IBSS_ATTR; /* 1152 Bytes */ +static uint32_t scalefac [23] IBSS_ATTR; /* 92 Bytes */ +static BF_Data CodedData IBSS_ATTR; /* 1056 Bytes */ +static int ca [8] IBSS_ATTR; /* 32 Bytes */ +static int cs [8] IBSS_ATTR; /* 32 Bytes */ +static int cx [9] IBSS_ATTR; /* 36 Bytes */ +static int win [18][4] IBSS_ATTR; /* 288 Bytes */ +static short enwindow [15*27+24] IBSS_ATTR; /* 862 Bytes */ +static short int2idx [4096] IBSS_ATTR; /* 8192 Bytes */ +static uint8_t ht_count [2][2][16] IBSS_ATTR; /* 64 Bytes */ +static uint32_t tab01 [ 16] IBSS_ATTR; /* 64 Bytes */ +static uint32_t tab23 [ 9] IBSS_ATTR; /* 36 Bytes */ +static uint32_t tab56 [ 16] IBSS_ATTR; /* 64 Bytes */ +static uint32_t tab1315 [256] IBSS_ATTR; /* 1024 Bytes */ +static uint32_t tab1624 [256] IBSS_ATTR; /* 1024 Bytes */ +static uint32_t tab789 [ 36] IBSS_ATTR; /* 144 Bytes */ +static uint32_t tabABC [ 64] IBSS_ATTR; /* 256 Bytes */ +static uint8_t t1HB [ 4] IBSS_ATTR; +static uint8_t t2HB [ 9] IBSS_ATTR; +static uint8_t t3HB [ 9] IBSS_ATTR; +static uint8_t t5HB [ 16] IBSS_ATTR; +static uint8_t t6HB [ 16] IBSS_ATTR; +static uint8_t t7HB [ 36] IBSS_ATTR; +static uint8_t t8HB [ 36] IBSS_ATTR; +static uint8_t t9HB [ 36] IBSS_ATTR; +static uint8_t t10HB [ 64] IBSS_ATTR; +static uint8_t t11HB [ 64] IBSS_ATTR; +static uint8_t t12HB [ 64] IBSS_ATTR; +static uint8_t t13HB [256] IBSS_ATTR; +static uint8_t t15HB [256] IBSS_ATTR; +static uint16_t t16HB [256] IBSS_ATTR; +static uint16_t t24HB [256] IBSS_ATTR; +static uint8_t t1l [ 8] IBSS_ATTR; +static uint8_t t2l [ 9] IBSS_ATTR; +static uint8_t t3l [ 9] IBSS_ATTR; +static uint8_t t5l [ 16] IBSS_ATTR; +static uint8_t t6l [ 16] IBSS_ATTR; +static uint8_t t7l [ 36] IBSS_ATTR; +static uint8_t t8l [ 36] IBSS_ATTR; +static uint8_t t9l [ 36] IBSS_ATTR; +static uint8_t t10l [ 64] IBSS_ATTR; +static uint8_t t11l [ 64] IBSS_ATTR; +static uint8_t t12l [ 64] IBSS_ATTR; +static uint8_t t13l [256] IBSS_ATTR; +static uint8_t t15l [256] IBSS_ATTR; +static uint8_t t16l [256] IBSS_ATTR; +static uint8_t t24l [256] IBSS_ATTR; +static struct huffcodetab ht [HTN] IBSS_ATTR; + +static unsigned pcm_chunk_size IBSS_ATTR; +static unsigned samp_per_frame IBSS_ATTR; + +static config_t cfg IBSS_ATTR; +static char *res_buffer; +static int32_t err IBSS_ATTR; +static uint8_t band_scale_f[22]; + +static const uint8_t ht_count_const[2][2][16] = +{ { { 1, 5, 4, 5, 6, 5, 4, 4, 7, 3, 6, 0, 7, 2, 3, 1 }, /* table0 */ + { 1, 5, 5, 7, 5, 8, 7, 9, 5, 7, 7, 9, 7, 9, 9,10 } }, /* hleng0 */ + { {15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 }, /* table1 */ + { 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8 } } }; /* hleng1 */ + +static const uint8_t t1HB_const[4] = {1,1,1,0}; +static const uint8_t t2HB_const[9] = {1,2,1,3,1,1,3,2,0}; +static const uint8_t t3HB_const[9] = {3,2,1,1,1,1,3,2,0}; +static const uint8_t t5HB_const[16] = {1,2,6,5,3,1,4,4,7,5,7,1,6,1,1,0}; +static const uint8_t t6HB_const[16] = {7,3,5,1,6,2,3,2,5,4,4,1,3,3,2,0}; + +static const uint8_t t7HB_const[36] = +{ 1, 2,10,19,16,10, 3, 3, 7,10, 5, 3,11, 4,13,17, 8, 4, + 12,11,18,15,11, 2, 7, 6, 9,14, 3, 1, 6, 4, 5, 3, 2, 0 }; + +static const uint8_t t8HB_const[36] = +{ 3, 4, 6,18,12, 5, 5, 1, 2,16, 9, 3, 7, 3, 5,14, 7, 3, + 19,17,15,13,10, 4,13, 5, 8,11, 5, 1,12, 4, 4, 1, 1, 0 }; + +static const uint8_t t9HB_const[36] = +{ 7, 5, 9,14,15, 7, 6, 4, 5, 5, 6, 7, 7, 6, 8, 8, 8, 5, + 15, 6, 9,10, 5, 1,11, 7, 9, 6, 4, 1,14, 4, 6, 2, 6, 0 }; + +static const uint8_t t10HB_const[64] = +{1,2,10,23,35,30,12,17,3,3,8,12,18,21,12,7,11,9,15,21,32, + 40,19,6,14,13,22,34,46,23,18,7,20,19,33,47,27,22,9,3,31,22, + 41,26,21,20,5,3,14,13,10,11,16,6,5,1,9,8,7,8,4,4,2,0 }; + +static const uint8_t t11HB_const[64] = +{3,4,10,24,34,33,21,15,5,3,4,10,32,17,11,10,11,7,13,18,30, + 31,20,5,25,11,19,59,27,18,12,5,35,33,31,58,30,16,7,5,28,26, + 32,19,17,15,8,14,14,12,9,13,14,9,4,1,11,4,6,6,6,3,2,0 }; + +static const uint8_t t12HB_const[64] = +{9,6,16,33,41,39,38,26,7,5,6,9,23,16,26,11,17,7,11,14,21, +30,10,7,17,10,15,12,18,28,14,5,32,13,22,19,18,16,9,5,40,17, +31,29,17,13,4,2,27,12,11,15,10,7,4,1,27,12,8,12,6,3,1,0 }; + +static const uint8_t t13HB_const[256] = +{1,5,14,21,34,51,46,71,42,52,68,52,67,44,43,19,3,4,12,19,31,26,44,33,31,24,32, + 24,31,35,22,14,15,13,23,36,59,49,77,65,29,40,30,40,27,33,42,16,22,20,37,61,56, + 79,73,64,43,76,56,37,26,31,25,14,35,16,60,57,97,75,114,91,54,73,55,41,48,53, + 23,24,58,27,50,96,76,70,93,84,77,58,79,29,74,49,41,17,47,45,78,74,115,94,90, + 79,69,83,71,50,59,38,36,15,72,34,56,95,92,85,91,90,86,73,77,65,51,44,43,42,43, + 20,30,44,55,78,72,87,78,61,46,54,37,30,20,16,53,25,41,37,44,59,54,81,66,76,57, + 54,37,18,39,11,35,33,31,57,42,82,72,80,47,58,55,21,22,26,38,22,53,25,23,38,70, + 60,51,36,55,26,34,23,27,14,9,7,34,32,28,39,49,75,30,52,48,40,52,28,18,17,9,5, + 45,21,34,64,56,50,49,45,31,19,12,15,10,7,6,3,48,23,20,39,36,35,53,21,16,23,13, + 10,6,1,4,2,16,15,17,27,25,20,29,11,17,12,16,8,1,1,0,1 }; + +static const uint8_t t15HB_const[256] = +{7,12,18,53,47,76,124,108,89,123,108,119,107,81,122,63,13,5,16,27,46,36,61,51, + 42,70,52,83,65,41,59,36,19,17,15,24,41,34,59,48,40,64,50,78,62,80,56,33,29,28, + 25,43,39,63,55,93,76,59,93,72,54,75,50,29,52,22,42,40,67,57,95,79,72,57,89,69, + 49,66,46,27,77,37,35,66,58,52,91,74,62,48,79,63,90,62,40,38,125,32,60,56,50, + 92,78,65,55,87,71,51,73,51,70,30,109,53,49,94,88,75,66,122,91,73,56,42,64,44, + 21,25,90,43,41,77,73,63,56,92,77,66,47,67,48,53,36,20,71,34,67,60,58,49,88,76, + 67,106,71,54,38,39,23,15,109,53,51,47,90,82,58,57,48,72,57,41,23,27,62,9,86, + 42,40,37,70,64,52,43,70,55,42,25,29,18,11,11,118,68,30,55,50,46,74,65,49,39, + 24,16,22,13,14,7,91,44,39,38,34,63,52,45,31,52,28,19,14,8,9,3,123,60,58,53,47, + 43,32,22,37,24,17,12,15,10,2,1,71,37,34,30,28,20,17,26,21,16,10,6,8,6,2,0}; + +static const uint16_t t16HB_const[256] = +{1,5,14,44,74,63,110,93,172,149,138,242,225,195,376,17,3,4,12,20,35,62,53,47, + 83,75,68,119,201,107,207,9,15,13,23,38,67,58,103,90,161,72,127,117,110,209, + 206,16,45,21,39,69,64,114,99,87,158,140,252,212,199,387,365,26,75,36,68,65, + 115,101,179,164,155,264,246,226,395,382,362,9,66,30,59,56,102,185,173,265,142, + 253,232,400,388,378,445,16,111,54,52,100,184,178,160,133,257,244,228,217,385, + 366,715,10,98,48,91,88,165,157,148,261,248,407,397,372,380,889,884,8,85,84,81, + 159,156,143,260,249,427,401,392,383,727,713,708,7,154,76,73,141,131,256,245, + 426,406,394,384,735,359,710,352,11,139,129,67,125,247,233,229,219,393,743,737, + 720,885,882,439,4,243,120,118,115,227,223,396,746,742,736,721,712,706,223,436, + 6,202,224,222,218,216,389,386,381,364,888,443,707,440,437,1728,4,747,211,210, + 208,370,379,734,723,714,1735,883,877,876,3459,865,2,377,369,102,187,726,722, + 358,711,709,866,1734,871,3458,870,434,0,12,10,7,11,10,17,11,9,13,12,10,7,5,3, + 1,3}; + +static const uint16_t t24HB_const[256] = +{15,13,46,80,146,262,248,434,426,669,653,649,621,517,1032,88,14,12,21,38,71, + 130,122,216,209,198,327,345,319,297,279,42,47,22,41,74,68,128,120,221,207,194, + 182,340,315,295,541,18,81,39,75,70,134,125,116,220,204,190,178,325,311,293, + 271,16,147,72,69,135,127,118,112,210,200,188,352,323,306,285,540,14,263,66, + 129,126,119,114,214,202,192,180,341,317,301,281,262,12,249,123,121,117,113, + 215,206,195,185,347,330,308,291,272,520,10,435,115,111,109,211,203,196,187, + 353,332,313,298,283,531,381,17,427,212,208,205,201,193,186,177,169,320,303, + 286,268,514,377,16,335,199,197,191,189,181,174,333,321,305,289,275,521,379, + 371,11,668,184,183,179,175,344,331,314,304,290,277,530,383,373,366,10,652,346, + 171,168,164,318,309,299,287,276,263,513,375,368,362,6,648,322,316,312,307,302, + 292,284,269,261,512,376,370,364,359,4,620,300,296,294,288,282,273,266,515,380, + 374,369,365,361,357,2,1033,280,278,274,267,264,259,382,378,372,367,363,360, + 358,356,0,43,20,19,17,15,13,11,9,7,6,4,7,5,3,1,3}; + +static const uint32_t tab1315_const[256] = +{ 0x010003,0x050005,0x070006,0x080008,0x090008,0x0a0009,0x0a000a,0x0b000a, + 0x0a000a,0x0b000b,0x0c000b,0x0c000c,0x0d000c,0x0d000c,0x0e000d,0x0e000e, + 0x040005,0x060005,0x080007,0x090008,0x0a0009,0x0a0009,0x0b000a,0x0b000a, + 0x0b000a,0x0b000b,0x0c000b,0x0c000c,0x0d000c,0x0e000c,0x0e000d,0x0e000d, + 0x070006,0x080007,0x090007,0x0a0008,0x0b0009,0x0b0009,0x0c000a,0x0c000a, + 0x0b000a,0x0c000b,0x0c000b,0x0d000c,0x0d000c,0x0e000d,0x0f000d,0x0f000d, + 0x080007,0x090008,0x0a0008,0x0b0009,0x0b0009,0x0c000a,0x0c000a,0x0c000b, + 0x0c000b,0x0d000b,0x0d000c,0x0d000c,0x0d000c,0x0e000d,0x0f000d,0x0f000d, + 0x090008,0x090008,0x0b0009,0x0b0009,0x0c000a,0x0c000a,0x0d000b,0x0d000b, + 0x0c000b,0x0d000b,0x0d000c,0x0e000c,0x0e000c,0x0f000d,0x0f000d,0x10000d, + 0x0a0009,0x0a0009,0x0b0009,0x0c000a,0x0c000a,0x0c000a,0x0d000b,0x0d000b, + 0x0d000b,0x0d000b,0x0e000c,0x0d000c,0x0f000d,0x0f000d,0x10000d,0x10000e, + 0x0a000a,0x0b0009,0x0c000a,0x0c000a,0x0d000a,0x0d000b,0x0d000b,0x0d000b, + 0x0d000b,0x0e000c,0x0e000c,0x0e000c,0x0f000d,0x0f000d,0x10000e,0x10000e, + 0x0b000a,0x0b000a,0x0c000a,0x0d000b,0x0d000b,0x0d000b,0x0e000b,0x0e000c, + 0x0e000c,0x0e000c,0x0f000c,0x0f000c,0x0f000d,0x10000d,0x12000d,0x12000e, + 0x0a000a,0x0a000a,0x0b000a,0x0c000b,0x0c000b,0x0d000b,0x0d000b,0x0e000c, + 0x0e000c,0x0e000c,0x0e000c,0x0f000d,0x0f000d,0x10000e,0x11000e,0x11000e, + 0x0b000a,0x0b000a,0x0c000b,0x0c000b,0x0d000b,0x0d000b,0x0d000c,0x0f000c, + 0x0e000c,0x0f000d,0x0f000d,0x10000d,0x10000d,0x10000e,0x12000e,0x11000e, + 0x0b000b,0x0c000b,0x0c000b,0x0d000b,0x0d000c,0x0e000c,0x0e000c,0x0f000c, + 0x0e000c,0x0f000d,0x10000d,0x0f000d,0x10000d,0x11000e,0x12000f,0x13000e, + 0x0c000b,0x0c000b,0x0c000b,0x0d000b,0x0e000c,0x0e000c,0x0e000c,0x0e000c, + 0x0f000d,0x0f000d,0x0f000d,0x10000d,0x11000e,0x11000e,0x11000e,0x12000f, + 0x0c000c,0x0d000c,0x0d000b,0x0e000c,0x0e000c,0x0f000c,0x0e000d,0x0f000d, + 0x10000d,0x10000d,0x11000d,0x11000d,0x11000e,0x12000e,0x12000f,0x12000f, + 0x0d000c,0x0d000c,0x0e000c,0x0f000c,0x0f000c,0x0f000d,0x10000d,0x10000d, + 0x10000d,0x10000e,0x10000e,0x11000e,0x12000e,0x11000e,0x12000f,0x12000f, + 0x0e000d,0x0e000d,0x0e000d,0x0f000d,0x0f000d,0x0f000d,0x11000d,0x10000d, + 0x10000e,0x13000e,0x11000e,0x11000e,0x11000f,0x13000f,0x12000e,0x12000f, + 0x0d000d,0x0e000d,0x0f000d,0x10000d,0x10000d,0x10000d,0x11000d,0x10000e, + 0x11000e,0x11000e,0x12000e,0x12000e,0x15000f,0x14000f,0x15000f,0x12000f }; + +static const uint32_t tab01_const[16] = +{ 0x10004,0x50005,0x50005,0x70006,0x50005,0x80006,0x70006,0x90007, + 0x50005,0x70006,0x70006,0x90007,0x70006,0x90007,0x90007,0xa0008 }; + +static const uint32_t tab23_const[ 9] = +{ 0x10002,0x40003,0x70007,0x40004,0x50004,0x70007,0x60006,0x70007,0x80008 }; + +static const uint32_t tab56_const[16] = +{ 0x10003,0x40004,0x70006,0x80008,0x40004,0x50004,0x80006,0x90007, + 0x70005,0x80006,0x90007,0xa0008,0x80007,0x80007,0x90008,0xa0009 }; + +static const uint32_t tab789_const[36] = +{0x00100803,0x00401004,0x00701c06,0x00902407,0x00902409,0x00a0280a,0x00401004, + 0x00601005,0x00801806,0x00902807,0x00902808,0x00a0280a,0x00701c05,0x00701806, + 0x00902007,0x00a02808,0x00a02809,0x00b02c0a,0x00802407,0x00902807,0x00a02808, + 0x00b02c09,0x00b02c09,0x00b0300a,0x00802408,0x00902408,0x00a02809,0x00b02c09, + 0x00b0300a,0x00c0300b,0x00902809,0x00a02809,0x00b02c0a,0x00c02c0a,0x00c0340b, + 0x00c0340b}; + +static const uint32_t tabABC_const[64] = +{0x00100804,0x00401004,0x00701806,0x00902008,0x00a02409,0x00a0280a,0x00a0240a, + 0x00b0280a,0x00401004,0x00601405,0x00801806,0x00902007,0x00a02809,0x00b02809, + 0x00a0240a,0x00a0280a,0x00701806,0x00801c06,0x00902007,0x00a02408,0x00b02809, + 0x00c02c0a,0x00b02809,0x00b0280a,0x00802007,0x00902007,0x00a02408,0x00b02c08, + 0x00c02809,0x00c0300a,0x00b0280a,0x00c02c0a,0x00902408,0x00a02808,0x00b02809, + 0x00c02c09,0x00c02c0a,0x00c0300a,0x00c02c0a,0x00c0300b,0x00a02409,0x00b02809, + 0x00c02c0a,0x00c0300a,0x00d0300a,0x00d0340b,0x00c0300a,0x00d0340b,0x00902409, + 0x00a02409,0x00b02409,0x00c0280a,0x00c02c0a,0x00c0300b,0x00d0300b,0x00d0300c, + 0x00a0240a,0x00a0240a,0x00b0280a,0x00c02c0b,0x00c0300b,0x00d0300b,0x00d0300b, + 0x00d0300c}; + +static const uint32_t tab1624_const[256] = +{0x00010004,0x00050005,0x00070007,0x00090008,0x000a0009,0x000a000a,0x000b000a, + 0x000b000b,0x000c000b,0x000c000c,0x000c000c,0x000d000c,0x000d000c,0x000d000c, + 0x000e000d,0x000a000a,0x00040005,0x00060006,0x00080007,0x00090008,0x000a0009, + 0x000b000a,0x000b000a,0x000b000b,0x000c000b,0x000c000b,0x000c000c,0x000d000c, + 0x000e000c,0x000d000c,0x000e000c,0x000a000a,0x00070007,0x00080007,0x00090008, + 0x000a0009,0x000b0009,0x000b000a,0x000c000a,0x000c000b,0x000d000b,0x000c000b, + 0x000d000b,0x000d000c,0x000d000c,0x000e000c,0x000e000d,0x000b0009,0x00090008, + 0x00090008,0x000a0009,0x000b0009,0x000b000a,0x000c000a,0x000c000a,0x000c000b, + 0x000d000b,0x000d000b,0x000e000b,0x000e000c,0x000e000c,0x000f000c,0x000f000c, + 0x000c0009,0x000a0009,0x000a0009,0x000b0009,0x000b000a,0x000c000a,0x000c000a, + 0x000d000a,0x000d000b,0x000d000b,0x000e000b,0x000e000c,0x000e000c,0x000f000c, + 0x000f000c,0x000f000d,0x000b0009,0x000a000a,0x000a0009,0x000b000a,0x000b000a, + 0x000c000a,0x000d000a,0x000d000b,0x000e000b,0x000d000b,0x000e000b,0x000e000c, + 0x000f000c,0x000f000c,0x000f000c,0x0010000c,0x000c0009,0x000b000a,0x000b000a, + 0x000b000a,0x000c000a,0x000d000a,0x000d000b,0x000d000b,0x000d000b,0x000e000b, + 0x000e000c,0x000e000c,0x000e000c,0x000f000c,0x000f000c,0x0010000d,0x000c0009, + 0x000b000b,0x000b000a,0x000c000a,0x000c000a,0x000d000b,0x000d000b,0x000d000b, + 0x000e000b,0x000e000c,0x000f000c,0x000f000c,0x000f000c,0x000f000c,0x0011000d, + 0x0011000d,0x000c000a,0x000b000b,0x000c000b,0x000c000b,0x000d000b,0x000d000b, + 0x000d000b,0x000e000b,0x000e000b,0x000f000b,0x000f000c,0x000f000c,0x000f000c, + 0x0010000c,0x0010000d,0x0010000d,0x000c000a,0x000c000b,0x000c000b,0x000c000b, + 0x000d000b,0x000d000b,0x000e000b,0x000e000b,0x000f000c,0x000f000c,0x000f000c, + 0x000f000c,0x0010000c,0x000f000d,0x0010000d,0x000f000d,0x000d000a,0x000c000c, + 0x000d000b,0x000c000b,0x000d000b,0x000e000b,0x000e000c,0x000e000c,0x000e000c, + 0x000f000c,0x0010000c,0x0010000c,0x0010000d,0x0011000d,0x0011000d,0x0010000d, + 0x000c000a,0x000d000c,0x000d000c,0x000d000b,0x000d000b,0x000e000b,0x000e000c, + 0x000f000c,0x0010000c,0x0010000c,0x0010000c,0x0010000c,0x0010000d,0x0010000d, + 0x000f000d,0x0010000d,0x000d000a,0x000d000c,0x000e000c,0x000e000c,0x000e000c, + 0x000e000c,0x000f000c,0x000f000c,0x000f000c,0x000f000c,0x0011000c,0x0010000d, + 0x0010000d,0x0010000d,0x0010000d,0x0012000d,0x000d000a,0x000f000c,0x000e000c, + 0x000e000c,0x000e000c,0x000f000c,0x000f000c,0x0010000c,0x0010000c,0x0010000d, + 0x0012000d,0x0011000d,0x0011000d,0x0011000d,0x0013000d,0x0011000d,0x000d000a, + 0x000e000d,0x000f000c,0x000d000c,0x000e000c,0x0010000c,0x0010000c,0x000f000c, + 0x0010000d,0x0010000d,0x0011000d,0x0012000d,0x0011000d,0x0013000d,0x0011000d, + 0x0010000d,0x000d000a,0x000a0009,0x000a0009,0x000a0009,0x000b0009,0x000b0009, + 0x000c0009,0x000c0009,0x000c0009,0x000d0009,0x000d0009,0x000d0009,0x000d000a, + 0x000d000a,0x000d000a,0x000d000a,0x000a0006}; + +static const uint8_t t1l_const[8] = {1,3,2,3,1,4,3,5}; +static const uint8_t t2l_const[9] = {1,3,6,3,3,5,5,5,6}; +static const uint8_t t3l_const[9] = {2,2,6,3,2,5,5,5,6}; +static const uint8_t t5l_const[16] = {1,3,6,7,3,3,6,7,6,6,7,8,7,6,7,8}; +static const uint8_t t6l_const[16] = {3,3,5,7,3,2,4,5,4,4,5,6,6,5,6,7}; + +static const uint8_t t7l_const[36] = +{1,3,6,8,8,9,3,4,6,7,7,8,6,5,7,8,8,9,7,7,8,9,9,9,7,7,8,9,9,10,8,8,9,10,10,10}; + +static const uint8_t t8l_const[36] = +{2,3,6,8,8,9,3,2,4,8,8,8,6,4,6,8,8,9,8,8,8,9,9,10,8,7,8,9,10,10,9,8,9,9,11,11}; + +static const uint8_t t9l_const[36] = +{3,3,5,6,8,9,3,3,4,5,6,8,4,4,5,6,7,8,6,5,6,7,7,8,7,6,7,7,8,9,8,7,8,8,9,9}; + +static const uint8_t t10l_const[64] = +{1,3,6,8,9,9,9,10,3,4,6,7,8,9,8,8,6,6,7,8,9,10,9,9,7,7,8,9,10,10,9,10,8,8,9,10, + 10,10,10,10,9,9,10,10,11,11,10,11,8,8,9,10,10,10,11,11,9,8,9,10,10,11,11,11}; + +static const uint8_t t11l_const[64] = +{2,3,5,7,8,9,8,9,3,3,4,6,8,8,7,8,5,5,6,7,8,9,8,8,7,6,7,9,8,10,8,9,8,8,8,9,9,10, + 9,10,8,8,9,10,10,11,10,11,8,7,7,8,9,10,10,10,8,7,8,9,10,10,10,10}; + +static const uint8_t t12l_const[64] = +{4,3,5,7,8,9,9,9,3,3,4,5,7,7,8,8,5,4,5,6,7,8,7,8,6,5,6,6,7,8,8,8,7,6,7,7,8, + 8,8,9,8,7,8,8,8,9,8,9,8,7,7,8,8,9,9,10,9,8,8,9,9,9,9,10}; + +static const uint8_t t13l_const[256] = +{1,4,6,7,8,9,9,10,9,10,11,11,12,12,13,13,3,4,6,7,8,8,9,9,9,9,10,10,11,12,12,12, + 6,6,7,8,9,9,10,10,9,10,10,11,11,12,13,13,7,7,8,9,9,10,10,10,10,11,11,11,11,12, + 13,13,8,7,9,9,10,10,11,11,10,11,11,12,12,13,13,14,9,8,9,10,10,10,11,11,11,11, + 12,11,13,13,14,14,9,9,10,10,11,11,11,11,11,12,12,12,13,13,14,14,10,9,10,11,11, + 11,12,12,12,12,13,13,13,14,16,16,9,8,9,10,10,11,11,12,12,12,12,13,13,14,15,15, + 10,9,10,10,11,11,11,13,12,13,13,14,14,14,16,15,10,10,10,11,11,12,12,13,12,13, + 14,13,14,15,16,17,11,10,10,11,12,12,12,12,13,13,13,14,15,15,15,16,11,11,11,12, + 12,13,12,13,14,14,15,15,15,16,16,16,12,11,12,13,13,13,14,14,14,14,14,15,16,15, + 16,16,13,12,12,13,13,13,15,14,14,17,15,15,15,17,16,16,12,12,13,14,14,14,15,14, + 15,15,16,16,19,18,19,16}; + +static const uint8_t t15l_const[256] = +{3,4,5,7,7,8,9,9,9,10,10,11,11,11,12,13,4,3,5,6,7,7,8,8,8,9,9,10,10,10,11,11,5, + 5,5,6,7,7,8,8,8,9,9,10,10,11,11,11,6,6,6,7,7,8,8,9,9,9,10,10,10,11,11,11,7,6, + 7,7,8,8,9,9,9,9,10,10,10,11,11,11,8,7,7,8,8,8,9,9,9,9,10,10,11,11,11,12,9,7,8, + 8,8,9,9,9,9,10,10,10,11,11,12,12,9,8,8,9,9,9,9,10,10,10,10,10,11,11,11,12,9,8, + 8,9,9,9,9,10,10,10,10,11,11,12,12,12,9,8,9,9,9,9,10,10,10,11,11,11,11,12,12, + 12,10,9,9,9,10,10,10,10,10,11,11,11,11,12,13,12,10,9,9,9,10,10,10,10,11,11,11, + 11,12,12,12,13,11,10,9,10,10,10,11,11,11,11,11,11,12,12,13,13,11,10,10,10,10, + 11,11,11,11,12,12,12,12,12,13,13,12,11,11,11,11,11,11,11,12,12,12,12,13,13,12, + 13,12,11,11,11,11,11,11,12,12,12,12,12,13,13,13,13}; + +static const uint8_t t16l_const[256] = +{1,4,6,8,9,9,10,10,11,11,11,12,12,12,13,9,3,4,6,7,8,9,9,9,10,10,10,11,12,11,12, + 8,6,6,7,8,9,9,10,10,11,10,11,11,11,12,12,9,8,7,8,9,9,10,10,10,11,11,12,12,12, + 13,13,10,9,8,9,9,10,10,11,11,11,12,12,12,13,13,13,9,9,8,9,9,10,11,11,12,11,12, + 12,13,13,13,14,10,10,9,9,10,11,11,11,11,12,12,12,12,13,13,14,10,10,9,10,10,11, + 11,11,12,12,13,13,13,13,15,15,10,10,10,10,11,11,11,12,12,13,13,13,13,14,14,14, + 10,11,10,10,11,11,12,12,13,13,13,13,14,13,14,13,11,11,11,10,11,12,12,12,12,13, + 14,14,14,15,15,14,10,12,11,11,11,12,12,13,14,14,14,14,14,14,13,14,11,12,12,12, + 12,12,13,13,13,13,15,14,14,14,14,16,11,14,12,12,12,13,13,14,14,14,16,15,15,15, + 17,15,11,13,13,11,12,14,14,13,14,14,15,16,15,17,15,14,11,9,8,8,9,9,10,10,10, + 11,11,11,11,11,11,11,8}; + +static const uint8_t t24l_const[256] = +{4,4,6,7,8,9,9,10,10,11,11,11,11,11,12,9,4,4,5,6,7,8,8,9,9,9,10,10,10,10,10,8, + 6,5,6,7,7,8,8,9,9,9,9,10,10,10,11,7,7,6,7,7,8,8,8,9,9,9,9,10,10,10,10,7,8,7,7, + 8,8,8,8,9,9,9,10,10,10,10,11,7,9,7,8,8,8,8,9,9,9,9,10,10,10,10,10,7,9,8,8,8,8, + 9,9,9,9,10,10,10,10,10,11,7,10,8,8,8,9,9,9,9,10,10,10,10,10,11,11,8,10,9,9,9, + 9,9,9,9,9,10,10,10,10,11,11,8,10,9,9,9,9,9,9,10,10,10,10,10,11,11,11,8,11,9,9, + 9,9,10,10,10,10,10,10,11,11,11,11,8,11,10,9,9,9,10,10,10,10,10,10,11,11,11,11, + 8,11,10,10,10,10,10,10,10,10,10,11,11,11,11,11,8,11,10,10,10,10,10,10,10,11, + 11,11,11,11,11,11,8,12,10,10,10,10,10,10,11,11,11,11,11,11,11,11,8,8,7,7,7,7, + 7,7,7,7,7,7,8,8,8,8,4}; + +static const struct huffcodetab ht_const[HTN] = +{ { 0, NULL, NULL}, /* Apparently not used */ + { 2, t1HB, t1l}, + { 3, t2HB, t2l}, + { 3, t3HB, t3l}, + { 0, NULL, NULL}, /* Apparently not used */ + { 4, t5HB, t5l}, + { 4, t6HB, t6l}, + { 6, t7HB, t7l}, + { 6, t8HB, t8l}, + { 6, t9HB, t9l}, + { 8, t10HB, t10l}, + { 8, t11HB, t11l}, + { 8, t12HB, t12l}, + {16, t13HB, t13l}, + { 0, NULL, NULL}, /* Apparently not used */ + {16, t15HB, t15l} }; + +static const struct huffcodebig ht_big[HTN] = +{ { 16, 1, 1 }, + { 16, 2, 3 }, + { 16, 3, 7 }, + { 16, 4, 15 }, + { 16, 6, 63 }, + { 16, 8, 255 }, + { 16, 10, 1023 }, + { 16, 13, 8191 }, + { 16, 4, 15 }, + { 16, 5, 31 }, + { 16, 6, 63 }, + { 16, 7, 127 }, + { 16, 8, 255 }, + { 16, 9, 511 }, + { 16, 11, 2047 }, + { 16, 13, 8191 } }; + +static const struct +{ + uint32_t region0_cnt; + uint32_t region1_cnt; +} subdv_table[23] = +{ {0, 0}, /* 0 bands */ + {0, 0}, /* 1 bands */ + {0, 0}, /* 2 bands */ + {0, 0}, /* 3 bands */ + {0, 0}, /* 4 bands */ + {0, 1}, /* 5 bands */ + {1, 1}, /* 6 bands */ + {1, 1}, /* 7 bands */ + {1, 2}, /* 8 bands */ + {2, 2}, /* 9 bands */ + {2, 3}, /* 10 bands */ + {2, 3}, /* 11 bands */ + {3, 4}, /* 12 bands */ + {3, 4}, /* 13 bands */ + {3, 4}, /* 14 bands */ + {4, 5}, /* 15 bands */ + {4, 5}, /* 16 bands */ + {4, 6}, /* 17 bands */ + {5, 6}, /* 18 bands */ + {5, 6}, /* 19 bands */ + {5, 7}, /* 20 bands */ + {6, 7}, /* 21 bands */ + {6, 7}, /* 22 bands */ +}; + +static const uint32_t sfBand[6][23] = +{ +/* Table B.2.b: 22.05 kHz */ +{0,6,12,18,24,30,36,44,54,66,80,96,116,140,168,200,238,284,336,396,464,522,576}, +/* Table B.2.c: 24 kHz */ +{0,6,12,18,24,30,36,44,54,66,80,96,114,136,162,194,232,278,330,394,464,540,576}, +/* Table B.2.a: 16 kHz */ +{0,6,12,18,24,30,36,44,45,66,80,96,116,140,168,200,238,248,336,396,464,522,576}, +/* Table B.8.b: 44.1 kHz */ +{0,4, 8,12,16,20,24,30,36,44,52,62, 74, 90,110,134,162,196,238,288,342,418,576}, +/* Table B.8.c: 48 kHz */ +{0,4, 8,12,16,20,24,30,36,42,50,60, 72, 88,106,128,156,190,230,276,330,384,576}, +/* Table B.8.a: 32 kHz */ +{0,4, 8,12,16,20,24,30,36,44,54,66, 82,102,126,156,194,240,296,364,448,550,576} }; + + +static const short int2idx_const[4096] = /* int2idx[i] = sqrt(i*sqrt(i)); */ +{ + 0, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 6, 7, 7, 8, 8, 8, 9, 9, + 9, 10, 10, 11, 11, 11, 12, 12, 12, 12, 13, 13, 13, 14, 14, 14, 15, 15, 15, 16, + 16, 16, 16, 17, 17, 17, 18, 18, 18, 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, + 22, 22, 22, 22, 23, 23, 23, 23, 24, 24, 24, 24, 25, 25, 25, 25, 26, 26, 26, 26, + 27, 27, 27, 27, 28, 28, 28, 28, 29, 29, 29, 29, 30, 30, 30, 30, 31, 31, 31, 31, + 32, 32, 32, 32, 33, 33, 33, 33, 34, 34, 34, 34, 34, 35, 35, 35, 35, 36, 36, 36, + 36, 36, 37, 37, 37, 37, 38, 38, 38, 38, 38, 39, 39, 39, 39, 40, 40, 40, 40, 40, + 41, 41, 41, 41, 42, 42, 42, 42, 42, 43, 43, 43, 43, 44, 44, 44, 44, 44, 45, 45, + 45, 45, 45, 46, 46, 46, 46, 46, 47, 47, 47, 47, 47, 48, 48, 48, 48, 49, 49, 49, + 49, 49, 50, 50, 50, 50, 50, 51, 51, 51, 51, 51, 52, 52, 52, 52, 52, 53, 53, 53, + 53, 53, 54, 54, 54, 54, 54, 55, 55, 55, 55, 55, 56, 56, 56, 56, 56, 57, 57, 57, + 57, 57, 58, 58, 58, 58, 58, 58, 59, 59, 59, 59, 59, 60, 60, 60, 60, 60, 61, 61, + 61, 61, 61, 62, 62, 62, 62, 62, 62, 63, 63, 63, 63, 63, 64, 64, 64, 64, 64, 65, + 65, 65, 65, 65, 65, 66, 66, 66, 66, 66, 67, 67, 67, 67, 67, 68, 68, 68, 68, 68, + 68, 69, 69, 69, 69, 69, 70, 70, 70, 70, 70, 70, 71, 71, 71, 71, 71, 72, 72, 72, + 72, 72, 72, 73, 73, 73, 73, 73, 74, 74, 74, 74, 74, 74, 75, 75, 75, 75, 75, 75, + 76, 76, 76, 76, 76, 77, 77, 77, 77, 77, 77, 78, 78, 78, 78, 78, 78, 79, 79, 79, + 79, 79, 80, 80, 80, 80, 80, 80, 81, 81, 81, 81, 81, 81, 82, 82, 82, 82, 82, 82, + 83, 83, 83, 83, 83, 84, 84, 84, 84, 84, 84, 85, 85, 85, 85, 85, 85, 86, 86, 86, + 86, 86, 86, 87, 87, 87, 87, 87, 87, 88, 88, 88, 88, 88, 88, 89, 89, 89, 89, 89, + 89, 90, 90, 90, 90, 90, 90, 91, 91, 91, 91, 91, 91, 92, 92, 92, 92, 92, 92, 93, + 93, 93, 93, 93, 93, 94, 94, 94, 94, 94, 94, 95, 95, 95, 95, 95, 95, 96, 96, 96, + 96, 96, 96, 97, 97, 97, 97, 97, 97, 98, 98, 98, 98, 98, 98, 99, 99, 99, 99, 99, + 99, 99,100,100,100,100,100,100,101,101,101,101,101,101,102,102,102,102,102,102, +103,103,103,103,103,103,104,104,104,104,104,104,104,105,105,105,105,105,105,106, +106,106,106,106,106,107,107,107,107,107,107,107,108,108,108,108,108,108,109,109, +109,109,109,109,110,110,110,110,110,110,110,111,111,111,111,111,111,112,112,112, +112,112,112,112,113,113,113,113,113,113,114,114,114,114,114,114,115,115,115,115, +115,115,115,116,116,116,116,116,116,117,117,117,117,117,117,117,118,118,118,118, +118,118,118,119,119,119,119,119,119,120,120,120,120,120,120,120,121,121,121,121, +121,121,122,122,122,122,122,122,122,123,123,123,123,123,123,123,124,124,124,124, +124,124,125,125,125,125,125,125,125,126,126,126,126,126,126,126,127,127,127,127, +127,127,128,128,128,128,128,128,128,129,129,129,129,129,129,129,130,130,130,130, +130,130,131,131,131,131,131,131,131,132,132,132,132,132,132,132,133,133,133,133, +133,133,133,134,134,134,134,134,134,134,135,135,135,135,135,135,136,136,136,136, +136,136,136,137,137,137,137,137,137,137,138,138,138,138,138,138,138,139,139,139, +139,139,139,139,140,140,140,140,140,140,140,141,141,141,141,141,141,141,142,142, +142,142,142,142,142,143,143,143,143,143,143,143,144,144,144,144,144,144,144,145, +145,145,145,145,145,145,146,146,146,146,146,146,146,147,147,147,147,147,147,147, +148,148,148,148,148,148,148,149,149,149,149,149,149,149,150,150,150,150,150,150, +150,151,151,151,151,151,151,151,152,152,152,152,152,152,152,153,153,153,153,153, +153,153,154,154,154,154,154,154,154,154,155,155,155,155,155,155,155,156,156,156, +156,156,156,156,157,157,157,157,157,157,157,158,158,158,158,158,158,158,159,159, +159,159,159,159,159,160,160,160,160,160,160,160,160,161,161,161,161,161,161,161, +162,162,162,162,162,162,162,163,163,163,163,163,163,163,163,164,164,164,164,164, +164,164,165,165,165,165,165,165,165,166,166,166,166,166,166,166,167,167,167,167, +167,167,167,167,168,168,168,168,168,168,168,169,169,169,169,169,169,169,169,170, +170,170,170,170,170,170,171,171,171,171,171,171,171,172,172,172,172,172,172,172, +172,173,173,173,173,173,173,173,174,174,174,174,174,174,174,174,175,175,175,175, +175,175,175,176,176,176,176,176,176,176,176,177,177,177,177,177,177,177,178,178, +178,178,178,178,178,178,179,179,179,179,179,179,179,180,180,180,180,180,180,180, +180,181,181,181,181,181,181,181,182,182,182,182,182,182,182,182,183,183,183,183, +183,183,183,184,184,184,184,184,184,184,184,185,185,185,185,185,185,185,186,186, +186,186,186,186,186,186,187,187,187,187,187,187,187,187,188,188,188,188,188,188, +188,189,189,189,189,189,189,189,189,190,190,190,190,190,190,190,190,191,191,191, +191,191,191,191,192,192,192,192,192,192,192,192,193,193,193,193,193,193,193,193, +194,194,194,194,194,194,194,195,195,195,195,195,195,195,195,196,196,196,196,196, +196,196,196,197,197,197,197,197,197,197,197,198,198,198,198,198,198,198,199,199, +199,199,199,199,199,199,200,200,200,200,200,200,200,200,201,201,201,201,201,201, +201,201,202,202,202,202,202,202,202,202,203,203,203,203,203,203,203,204,204,204, +204,204,204,204,204,205,205,205,205,205,205,205,205,206,206,206,206,206,206,206, +206,207,207,207,207,207,207,207,207,208,208,208,208,208,208,208,208,209,209,209, +209,209,209,209,209,210,210,210,210,210,210,210,210,211,211,211,211,211,211,211, +211,212,212,212,212,212,212,212,212,213,213,213,213,213,213,213,213,214,214,214, +214,214,214,214,214,215,215,215,215,215,215,215,215,216,216,216,216,216,216,216, +216,217,217,217,217,217,217,217,217,218,218,218,218,218,218,218,218,219,219,219, +219,219,219,219,219,220,220,220,220,220,220,220,220,221,221,221,221,221,221,221, +221,222,222,222,222,222,222,222,222,223,223,223,223,223,223,223,223,224,224,224, +224,224,224,224,224,225,225,225,225,225,225,225,225,226,226,226,226,226,226,226, +226,227,227,227,227,227,227,227,227,228,228,228,228,228,228,228,228,229,229,229, +229,229,229,229,229,229,230,230,230,230,230,230,230,230,231,231,231,231,231,231, +231,231,232,232,232,232,232,232,232,232,233,233,233,233,233,233,233,233,234,234, +234,234,234,234,234,234,234,235,235,235,235,235,235,235,235,236,236,236,236,236, +236,236,236,237,237,237,237,237,237,237,237,238,238,238,238,238,238,238,238,238, +239,239,239,239,239,239,239,239,240,240,240,240,240,240,240,240,241,241,241,241, +241,241,241,241,242,242,242,242,242,242,242,242,242,243,243,243,243,243,243,243, +243,244,244,244,244,244,244,244,244,245,245,245,245,245,245,245,245,245,246,246, +246,246,246,246,246,246,247,247,247,247,247,247,247,247,248,248,248,248,248,248, +248,248,248,249,249,249,249,249,249,249,249,250,250,250,250,250,250,250,250,250, +251,251,251,251,251,251,251,251,252,252,252,252,252,252,252,252,253,253,253,253, +253,253,253,253,253,254,254,254,254,254,254,254,254,255,255,255,255,255,255,255, +255,255,256,256,256,256,256,256,256,256,257,257,257,257,257,257,257,257,257,258, +258,258,258,258,258,258,258,259,259,259,259,259,259,259,259,259,260,260,260,260, +260,260,260,260,261,261,261,261,261,261,261,261,261,262,262,262,262,262,262,262, +262,263,263,263,263,263,263,263,263,263,264,264,264,264,264,264,264,264,265,265, +265,265,265,265,265,265,265,266,266,266,266,266,266,266,266,267,267,267,267,267, +267,267,267,267,268,268,268,268,268,268,268,268,268,269,269,269,269,269,269,269, +269,270,270,270,270,270,270,270,270,270,271,271,271,271,271,271,271,271,271,272, +272,272,272,272,272,272,272,273,273,273,273,273,273,273,273,273,274,274,274,274, +274,274,274,274,275,275,275,275,275,275,275,275,275,276,276,276,276,276,276,276, +276,276,277,277,277,277,277,277,277,277,277,278,278,278,278,278,278,278,278,279, +279,279,279,279,279,279,279,279,280,280,280,280,280,280,280,280,280,281,281,281, +281,281,281,281,281,282,282,282,282,282,282,282,282,282,283,283,283,283,283,283, +283,283,283,284,284,284,284,284,284,284,284,284,285,285,285,285,285,285,285,285, +286,286,286,286,286,286,286,286,286,287,287,287,287,287,287,287,287,287,288,288, +288,288,288,288,288,288,288,289,289,289,289,289,289,289,289,289,290,290,290,290, +290,290,290,290,291,291,291,291,291,291,291,291,291,292,292,292,292,292,292,292, +292,292,293,293,293,293,293,293,293,293,293,294,294,294,294,294,294,294,294,294, +295,295,295,295,295,295,295,295,295,296,296,296,296,296,296,296,296,296,297,297, +297,297,297,297,297,297,297,298,298,298,298,298,298,298,298,299,299,299,299,299, +299,299,299,299,300,300,300,300,300,300,300,300,300,301,301,301,301,301,301,301, +301,301,302,302,302,302,302,302,302,302,302,303,303,303,303,303,303,303,303,303, +304,304,304,304,304,304,304,304,304,305,305,305,305,305,305,305,305,305,306,306, +306,306,306,306,306,306,306,307,307,307,307,307,307,307,307,307,308,308,308,308, +308,308,308,308,308,309,309,309,309,309,309,309,309,309,310,310,310,310,310,310, +310,310,310,311,311,311,311,311,311,311,311,311,312,312,312,312,312,312,312,312, +312,313,313,313,313,313,313,313,313,313,314,314,314,314,314,314,314,314,314,315, +315,315,315,315,315,315,315,315,316,316,316,316,316,316,316,316,316,317,317,317, +317,317,317,317,317,317,318,318,318,318,318,318,318,318,318,318,319,319,319,319, +319,319,319,319,319,320,320,320,320,320,320,320,320,320,321,321,321,321,321,321, +321,321,321,322,322,322,322,322,322,322,322,322,323,323,323,323,323,323,323,323, +323,324,324,324,324,324,324,324,324,324,325,325,325,325,325,325,325,325,325,325, +326,326,326,326,326,326,326,326,326,327,327,327,327,327,327,327,327,327,328,328, +328,328,328,328,328,328,328,329,329,329,329,329,329,329,329,329,330,330,330,330, +330,330,330,330,330,330,331,331,331,331,331,331,331,331,331,332,332,332,332,332, +332,332,332,332,333,333,333,333,333,333,333,333,333,334,334,334,334,334,334,334, +334,334,335,335,335,335,335,335,335,335,335,335,336,336,336,336,336,336,336,336, +336,337,337,337,337,337,337,337,337,337,338,338,338,338,338,338,338,338,338,338, +339,339,339,339,339,339,339,339,339,340,340,340,340,340,340,340,340,340,341,341, +341,341,341,341,341,341,341,341,342,342,342,342,342,342,342,342,342,343,343,343, +343,343,343,343,343,343,344,344,344,344,344,344,344,344,344,344,345,345,345,345, +345,345,345,345,345,346,346,346,346,346,346,346,346,346,347,347,347,347,347,347, +347,347,347,347,348,348,348,348,348,348,348,348,348,349,349,349,349,349,349,349, +349,349,350,350,350,350,350,350,350,350,350,350,351,351,351,351,351,351,351,351, +351,352,352,352,352,352,352,352,352,352,352,353,353,353,353,353,353,353,353,353, +354,354,354,354,354,354,354,354,354,355,355,355,355,355,355,355,355,355,355,356, +356,356,356,356,356,356,356,356,357,357,357,357,357,357,357,357,357,357,358,358, +358,358,358,358,358,358,358,359,359,359,359,359,359,359,359,359,359,360,360,360, +360,360,360,360,360,360,361,361,361,361,361,361,361,361,361,361,362,362,362,362, +362,362,362,362,362,363,363,363,363,363,363,363,363,363,363,364,364,364,364,364, +364,364,364,364,365,365,365,365,365,365,365,365,365,365,366,366,366,366,366,366, +366,366,366,367,367,367,367,367,367,367,367,367,367,368,368,368,368,368,368,368, +368,368,369,369,369,369,369,369,369,369,369,369,370,370,370,370,370,370,370,370, +370,370,371,371,371,371,371,371,371,371,371,372,372,372,372,372,372,372,372,372, +372,373,373,373,373,373,373,373,373,373,374,374,374,374,374,374,374,374,374,374, +375,375,375,375,375,375,375,375,375,375,376,376,376,376,376,376,376,376,376,377, +377,377,377,377,377,377,377,377,377,378,378,378,378,378,378,378,378,378,379,379, +379,379,379,379,379,379,379,379,380,380,380,380,380,380,380,380,380,380,381,381, +381,381,381,381,381,381,381,382,382,382,382,382,382,382,382,382,382,383,383,383, +383,383,383,383,383,383,383,384,384,384,384,384,384,384,384,384,385,385,385,385, +385,385,385,385,385,385,386,386,386,386,386,386,386,386,386,386,387,387,387,387, +387,387,387,387,387,387,388,388,388,388,388,388,388,388,388,389,389,389,389,389, +389,389,389,389,389,390,390,390,390,390,390,390,390,390,390,391,391,391,391,391, +391,391,391,391,391,392,392,392,392,392,392,392,392,392,393,393,393,393,393,393, +393,393,393,393,394,394,394,394,394,394,394,394,394,394,395,395,395,395,395,395, +395,395,395,395,396,396,396,396,396,396,396,396,396,397,397,397,397,397,397,397, +397,397,397,398,398,398,398,398,398,398,398,398,398,399,399,399,399,399,399,399, +399,399,399,400,400,400,400,400,400,400,400,400,400,401,401,401,401,401,401,401, +401,401,402,402,402,402,402,402,402,402,402,402,403,403,403,403,403,403,403,403, +403,403,404,404,404,404,404,404,404,404,404,404,405,405,405,405,405,405,405,405, +405,405,406,406,406,406,406,406,406,406,406,406,407,407,407,407,407,407,407,407, +407,407,408,408,408,408,408,408,408,408,408,408,409,409,409,409,409,409,409,409, +409,410,410,410,410,410,410,410,410,410,410,411,411,411,411,411,411,411,411,411, +411,412,412,412,412,412,412,412,412,412,412,413,413,413,413,413,413,413,413,413, +413,414,414,414,414,414,414,414,414,414,414,415,415,415,415,415,415,415,415,415, +415,416,416,416,416,416,416,416,416,416,416,417,417,417,417,417,417,417,417,417, +417,418,418,418,418,418,418,418,418,418,418,419,419,419,419,419,419,419,419,419, +419,420,420,420,420,420,420,420,420,420,420,421,421,421,421,421,421,421,421,421, +421,422,422,422,422,422,422,422,422,422,422,423,423,423,423,423,423,423,423,423, +423,424,424,424,424,424,424,424,424,424,424,425,425,425,425,425,425,425,425,425, +425,426,426,426,426,426,426,426,426,426,426,427,427,427,427,427,427,427,427,427, +427,428,428,428,428,428,428,428,428,428,428,429,429,429,429,429,429,429,429,429, +429,430,430,430,430,430,430,430,430,430,430,431,431,431,431,431,431,431,431,431, +431,432,432,432,432,432,432,432,432,432,432,433,433,433,433,433,433,433,433,433, +433,434,434,434,434,434,434,434,434,434,434,435,435,435,435,435,435,435,435,435, +435,435,436,436,436,436,436,436,436,436,436,436,437,437,437,437,437,437,437,437, +437,437,438,438,438,438,438,438,438,438,438,438,439,439,439,439,439,439,439,439, +439,439,440,440,440,440,440,440,440,440,440,440,441,441,441,441,441,441,441,441, +441,441,442,442,442,442,442,442,442,442,442,442,443,443,443,443,443,443,443,443, +443,443,443,444,444,444,444,444,444,444,444,444,444,445,445,445,445,445,445,445, +445,445,445,446,446,446,446,446,446,446,446,446,446,447,447,447,447,447,447,447, +447,447,447,448,448,448,448,448,448,448,448,448,448,448,449,449,449,449,449,449, +449,449,449,449,450,450,450,450,450,450,450,450,450,450,451,451,451,451,451,451, +451,451,451,451,452,452,452,452,452,452,452,452,452,452,453,453,453,453,453,453, +453,453,453,453,453,454,454,454,454,454,454,454,454,454,454,455,455,455,455,455, +455,455,455,455,455,456,456,456,456,456,456,456,456,456,456,457,457,457,457,457, +457,457,457,457,457,457,458,458,458,458,458,458,458,458,458,458,459,459,459,459, +459,459,459,459,459,459,460,460,460,460,460,460,460,460,460,460,460,461,461,461, +461,461,461,461,461,461,461,462,462,462,462,462,462,462,462,462,462,463,463,463, +463,463,463,463,463,463,463,463,464,464,464,464,464,464,464,464,464,464,465,465, +465,465,465,465,465,465,465,465,466,466,466,466,466,466,466,466,466,466,466,467, +467,467,467,467,467,467,467,467,467,468,468,468,468,468,468,468,468,468,468,469, +469,469,469,469,469,469,469,469,469,469,470,470,470,470,470,470,470,470,470,470, +471,471,471,471,471,471,471,471,471,471,472,472,472,472,472,472,472,472,472,472, +472,473,473,473,473,473,473,473,473,473,473,474,474,474,474,474,474,474,474,474, +474,475,475,475,475,475,475,475,475,475,475,475,476,476,476,476,476,476,476,476, +476,476,477,477,477,477,477,477,477,477,477,477,477,478,478,478,478,478,478,478, +478,478,478,479,479,479,479,479,479,479,479,479,479,479,480,480,480,480,480,480, +480,480,480,480,481,481,481,481,481,481,481,481,481,481,482,482,482,482,482,482, +482,482,482,482,482,483,483,483,483,483,483,483,483,483,483,484,484,484,484,484, +484,484,484,484,484,484,485,485,485,485,485,485,485,485,485,485,486,486,486,486, +486,486,486,486,486,486,486,487,487,487,487,487,487,487,487,487,487,488,488,488, +488,488,488,488,488,488,488,488,489,489,489,489,489,489,489,489,489,489,490,490, +490,490,490,490,490,490,490,490,490,491,491,491,491,491,491,491,491,491,491,492, +492,492,492,492,492,492,492,492,492,492,493,493,493,493,493,493,493,493,493,493, +494,494,494,494,494,494,494,494,494,494,494,495,495,495,495,495,495,495,495,495, +495,496,496,496,496,496,496,496,496,496,496,496,497,497,497,497,497,497,497,497, +497,497,497,498,498,498,498,498,498,498,498,498,498,499,499,499,499,499,499,499, +499,499,499,499,500,500,500,500,500,500,500,500,500,500,501,501,501,501,501,501, +501,501,501,501,501,502,502,502,502,502,502,502,502,502,502,503,503,503,503,503, +503,503,503,503,503,503,504,504,504,504,504,504,504,504,504,504,504,505,505,505, +505,505,505,505,505,505,505,506,506,506,506,506,506,506,506,506,506,506,507,507, +507,507,507,507,507,507,507,507,507,508,508,508,508,508,508,508,508,508,508,509, +509,509,509,509,509,509,509,509,509,509,510,510,510,510,510,510,510,510,510,510, +510,511,511,511,511,511,511,511,511,511,511,512,512,512,512,512 }; + +static const int order[32] = +{ 0, 1, 16, 17, 8, 9, 24, 25, 4, 5, 20, 21, 12, 13, 28, 29, + 2, 3, 18, 19,10,11, 26, 27, 6, 7, 22, 23, 14, 15, 30, 31 }; + +static const long sampr_index[2][3] = +{ { 22050, 24000, 16000 }, /* MPEG 2 */ + { 44100, 48000, 32000 } }; /* MPEG 1 */ + +static const long bitr_index[2][15] = +{ {0, 8,16,24,32,40,48,56, 64, 80, 96,112,128,144,160}, /* MPEG 2 */ + {0,32,40,48,56,64,80,96,112,128,160,192,224,256,320} }; /* MPEG 1 */ + +static const int num_bands[3][15] = +{ {0,10,10,10,10,12,14,16, 20, 22, 24, 26, 28, 30, 32}, + {0,10,10,10,10,10,12,14, 18, 24, 26, 28, 30, 32, 32}, + {0,10,12,14,18,24,26,28, 30, 32, 32, 32, 32, 32, 32} }; + +static const int cx_const[9] = +{ 16135, 10531, 5604, 15396, -2845,-12551, 14189, 8192, 16384 }; + +static const int ca_const[8] = +{-16859,-15458,-10269, -5961, -3099, -1342, -465, -121 }; + +static const int cs_const[8] = +{ 28098, 28893, 31117, 32221, 32621, 32740, 32765, 32768 }; + +static const short enwindow_const[15*27+24] = +{ 0, 65, 593, 1766, 22228, 2115, 611, 62, + 8, 119, 1419, 10564,-11659,-1635,-154, -9, + -8, -119,-1419,-10564, 11659, 1635, 154, 9, 464, 100, 91, + 0, 69, 604, 1635, 23148, 2363, 643, 62, + 7, 107, 1368, 10449,-12733,-1818,-180,-11, + -7, -107,-1368,-10449, 12733, 1818, 180, 11, 420, 200, 164, + 0, 72, 608, 1465, 23979, 2600, 671, 63, + 7, 94, 1305, 10265,-13818,-2004,-207,-12, + -7, -94,-1305,-10265, 13818, 2004, 207, 12, 380, 297, 220, + 0, 76, 606, 1256, 24718, 2825, 693, 63, + 6, 81, 1232, 10016,-14908,-2192,-236,-14, + -6, -81,-1232,-10016, 14908, 2192, 236, 14, 342, 392, 262, + 0, 78, 597, 1007, 25359, 3033, 712, 63, + 6, 68, 1150, 9706,-15995,-2380,-267,-15, + -6, -68,-1150, -9706, 15995, 2380, 267, 15, 307, 483, 289, + 0, 80, 580, 719, 25901, 3224, 726, 62, + 6, 54, 1060, 9343,-17072,-2565,-299,-17, + -6, -54,-1060, -9343, 17072, 2565, 299, 17, 274, 569, 304, + -1, 82, 555, 391, 26339, 3395, 735, 61, + 5, 40, 963, 8930,-18131,-2747,-332,-19, + -5, -40, -963, -8930, 18131, 2747, 332, 19, 242, 650, 307, + -1, 83, 523, 26, 26672, 3545, 740, 60, + 5, 27, 861, 8474,-19164,-2923,-366,-21, + -5, -27, -861, -8474, 19164, 2923, 366, 21, 212, 724, 300, + -1, 83, 482, -376, 26900, 3672, 739, 58, + 4, 14, 756, 7981,-20163,-3092,-401,-24, + -4, -14, -756, -7981, 20163, 3092, 401, 24, 183, 792, 283, + -1, 82, 433, -812, 27022, 3776, 735, 56, + 4, 1, 648, 7456,-21122,-3250,-435,-26, + -4, -1, -648, -7456, 21122, 3250, 435, 26, 155, 851, 258, + -1, 81, 376, -1281, 27038, 3855, 726, 54, + 3, -11, 539, 6907,-22032,-3397,-470,-28, + -3, 11, -539, -6907, 22032, 3397, 470, 28, 128, 903, 226, + -1, 78, 312, -1778, 26951, 3910, 713, 52, + 3, -22, 430, 6338,-22887,-3530,-503,-31, + -3, 22, -430, -6338, 22887, 3530, 503, 31, 102, 946, 188, + -2, 75, 239, -2302, 26761, 3941, 696, 49, + 3, -33, 322, 5757,-23678,-3648,-537,-34, + -3, 33, -322, -5757, 23678, 3648, 537, 34, 76, 980, 145, + -2, 70, 160, -2848, 26472, 3948, 676, 47, + 3, -42, 217, 5167,-24399,-3749,-568,-36, + -3, 42, -217, -5167, 24399, 3749, 568, 36, 50, 1004, 99, + -2, 65, 74, -3412, 26087, 3931, 653, 44, + 2, -51, 115, 4577,-25045,-3830,-599,-39, + -2, 51, -115, -4577, 25045, 3830, 599, 39, 25, 1019, 50, + + 25610,3891,627,42,-3990,-18,58,-2, + 21226,-21226,10604,-10604,1860,-1860,1458,-1458,576,-576,130,-130,60,-60,8,-8 +}; + +static const int win_const[18][4] = { + { -3072, -134, -146, 3352 }, + { -2747, -362, -471, 3579 }, + { -2387, -529, -831, 3747 }, + { -2004, -632,-1214, 3850 }, + { -1609, -666,-1609, 3884 }, + { -1214, -632,-2004, 3850 }, + { -831, -529,-2387, 3747 }, + { -471, -362,-2747, 3579 }, + { -146, -134,-3072, 3352 }, + { 134,-3072,-3352, -146 }, + { 362,-2747,-3579, -471 }, + { 529,-2387,-3747, -831 }, + { 632,-2004,-3850,-1214 }, + { 666,-1609,-3884,-1609 }, + { 632,-1214,-3850,-2004 }, + { 529, -831,-3747,-2387 }, + { 362, -471,-3579,-2747 }, + { 134, -146,-3352,-3072 } }; + +/* forward declarations */ +static int HuffmanCode( short *ix, char *xr_sign, uint32_t begin, uint32_t end, int table); +static int HuffmanCod1( short *ix, char *xr_sign, uint32_t begin, uint32_t end, int table); +static void putbits(uint32_t val, uint32_t nbit); +static int find_best_2( short *ix, uint32_t start, uint32_t end, const uint32_t *table, + uint32_t len, int *bits); +static int find_best_3( short *ix, uint32_t start, uint32_t end, const uint32_t *table, + uint32_t len, int *bits); +static int count_bit1 ( short *ix, uint32_t start, uint32_t end, int *bits ); +static int count_bigv ( short *ix, uint32_t start, uint32_t end, int table0, int table1, + int *bits); + + +static void encodeSideInfo( side_info_t si[2][2] ) +{ + int gr, ch, header; + uint32_t cc=0, sz=0; + + /* + * MPEG header layout: + * AAAAAAAA AAABBCCD EEEEFFGH IIJJKLMM + * A (31-21) = frame sync + * B (20-19) = MPEG type + * C (18-17) = MPEG layer + * D (16) = protection bit + * E (15-12) = bitrate index + * F (11-10) = samplerate index + * G (9) = padding bit + * H (8) = private bit + * I (7-6) = channel mode + * J (5-4) = mode extension (jstereo only) + * K (3) = copyright bit + * L (2) = original + * M (1-0) = emphasis + */ + + header = (0xfff00000) | /* frame sync (AAAAAAAAA AAA) + mp3 type (upper): 1 (B) */ + (0x01 << 17) | /* mp3 layer: 01 (CC) */ + ( 0x1 << 16) | /* mp3 crc: 1 (D) */ + ( 0x1 << 2); /* mp3 org: 1 (L) */ + header |= cfg.mpg.type << 19; + header |= cfg.mpg.bitr_id << 12; + header |= cfg.mpg.smpl_id << 10; + header |= cfg.mpg.padding << 9; + header |= cfg.mpg.mode << 6; + /* no emphasis (bits 0-1) */ + putbits( header, 32 ); + + if(cfg.mpg.type == 1) + { /* MPEG1 */ + if(cfg.channels == 2) { putlong( 0, 20); } + else { putlong( 0, 18); } + + for(gr=0; grpart2_3_length+42),12 ); /* add scale_facs array size */ + putlong( gi->address3>>1, 9 ); + putlong( gi->global_gain, 8 ); + putlong( 9, 4 ); /* set scale_facs compr type */ + putlong( gi->table_select[0], 6 ); + putlong( gi->table_select[1], 5 ); + putlong( gi->table_select[2], 5 ); + putlong( gi->region_0_1, 7 ); + putlong( 1 , 2 ); /* set scale_facs to 1bit */ + putlong( gi->table_select[3], 1 ); + } + } + else + { /* MPEG2 */ + if(cfg.channels == 2) { putlong( 0, 10); } + else { putlong( 0, 9); } + + for(ch=0; chpart2_3_length+42),12 ); /* add scale_facs array size */ + putlong( gi->address3>>1, 9 ); + putlong( gi->global_gain, 8 ); + putlong( 0xCA, 9 ); /* set scale_facs compr type */ + putlong( gi->table_select[0], 6 ); + putlong( gi->table_select[1], 5 ); + putlong( gi->table_select[2], 5 ); + putlong( gi->region_0_1 , 7 ); + putlong( 1 , 1 ); /* set scale_facs to 1bit */ + putlong( gi->table_select[3], 1 ); + } + } + /* flush remaining bits */ + putbits(cc, sz); +} + +/* Note the discussion of huffmancodebits() on pages 28 and 29 of the IS, + as well as the definitions of the side information on pages 26 and 27. */ +static void Huffmancodebits( short *ix, char *xr_sign, side_info_t *gi ) +{ + int region1 = gi->address1; + int region2 = gi->address2; + int bigvals = gi->address3; + int count1 = bigvals + (gi->count1 << 2); + int stuffBits = 0; + int bits = 0; + int i, v; + + for(i=v=0; i<32; i+=2) + v |= band_scale_f[i>>1] << (30-i); + putbits(v, 32); // store scale_facs (part1) + + for(v=0; i<42; i+=2) + v |= band_scale_f[i>>1] << (40-i); + putbits(v, 10); // store scale_facs (part2) + + if(region1 > 0) + bits += HuffmanCode(ix, xr_sign, 0 , region1, gi->table_select[0]); + + if(region2 > region1) + bits += HuffmanCode(ix, xr_sign, region1, region2, gi->table_select[1]); + + if(bigvals > region2) + bits += HuffmanCode(ix, xr_sign, region2, bigvals, gi->table_select[2]); + + if(count1 > bigvals) + bits += HuffmanCod1(ix, xr_sign, bigvals, count1, gi->table_select[3]); + + if((stuffBits = gi->part2_3_length - bits) > 0) + { + int stuffWords = stuffBits >> 5; + int remainBits = stuffBits & 31; + + if( remainBits ) + putbits( ~0, remainBits ); + + while( stuffWords-- ) + putbits( ~0, 32 ); /* Huffman code tables leed to padding ones */ + } +} + +int HuffmanCod1( short *ix, char *xr_sign, uint32_t begin, uint32_t end, int tbl) +{ + uint32_t cc=0, sz=0; + uint32_t i, d, p; + int sumbit=0, s=0, l=0, v, w, x, y; + #define sgnv xr_sign[i+0] + #define sgnw xr_sign[i+1] + #define sgnx xr_sign[i+2] + #define sgny xr_sign[i+3] + + for(i=begin; i 15 ) + { /* ESC-table is used */ + uint32_t linbits = ht_big[table-16].linbits; + uint16_t *hffcode = table < 24 ? t16HB : t24HB; + uint8_t *hlen = table < 24 ? t16l : t24l; + + for(i=begin; i 14) { xl = x - 15; x = 15; } + if(y > 14) { yl = y - 15; y = 15; } + + idx = x * 16 + y; + code = hffcode[idx]; + bit = hlen [idx]; + + if(x) + { + if(x > 14) + { + code = (code << linbits) | xl; + bit += linbits; + } + + code = (code << 1) | sign_x; + bit += 1; + } + + if(y) + { + if(y > 14) + { + if(bit + linbits + 1 > 32) + { + putlong( code, bit ); + sumbit += bit; + code = bit = 0; + } + + code = (code << linbits) | yl; + bit += linbits; + } + + code = (code << 1) | sign_y; + bit += 1; + } + + putlong( code, bit ); + sumbit += bit; + } + } + else + { /* No ESC-words */ + const struct huffcodetab *h = &ht[table]; + + for(i=begin; ilen + y; + code = h->table[idx]; + bit = h->hlen [idx]; + + if(x) + { + code = (code << 1) | sign_x; + bit += 1; + } + + if(y) + { + code = (code << 1) | sign_y; + bit += 1; + } + + putlong( code, bit ); + sumbit += bit; + } + } + + /* flush remaining bits */ + putbits(cc, sz); + + return sumbit; +} + +void putbits(uint32_t val, uint32_t nbit) +{ + int new_bitpos = CodedData.bitpos + nbit; + int ptrpos = CodedData.bitpos >> 5; + + val = val & (0xffffffff >> (32 - nbit)); + + /* data fit in one uint32_t */ + if(((new_bitpos - 1) >> 5) == ptrpos) + CodedData.bbuf[ptrpos] |= val << ((32 - new_bitpos) & 31); + else + { + CodedData.bbuf[ptrpos ] |= val >> ((new_bitpos - 32) & 31); + CodedData.bbuf[ptrpos+1] |= val << ((32 - new_bitpos) & 31); + } + + CodedData.bitpos = new_bitpos; +} + +/***************************************************************************/ +/* Choose the Huffman table that will encode ix[begin..end] with */ +/* the fewest bits. */ +/* Note: This code contains knowledge about the sizes and characteristic */ +/* of the Huffman tables as defined in the IS (Table B.7), and will not */ +/* work with any arbitrary tables. */ +/***************************************************************************/ +static int choose_table( short *ix, uint32_t begin, uint32_t end, int *bits ) +{ + uint32_t i; + int max, table0, table1; + + for(i=begin,max=0; i max) + max = ix[i]; + + if(max < 16) + { + /* tables without linbits */ + /* indx: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 */ + /* len: 0, 2, 3, 3, 0, 4, 4, 6, 6, 6, 8, 8, 8, 16, 0, 16 */ + switch(max) + { + case 0: return 0; + case 1: return count_bit1(ix, begin, end, bits); + case 2: return 2 + find_best_2(ix, begin, end, tab23, 3, bits); + case 3: return 5 + find_best_2(ix, begin, end, tab56, 4, bits); + case 4: + case 5: return 7 + find_best_3(ix, begin, end, tab789, 6, bits); + case 6: + case 7: return 10 + find_best_3(ix, begin, end, tabABC, 8, bits); + default: return 13 + find_best_2(ix, begin, end, tab1315, 16, bits) * 2; + } + } + else + { + /* tables with linbits */ + max -= 15; + + for(table0=0; table0<8; table0++) + if(ht_big[table0].linmax >= max) + break; + + for(table1=8; table1<16; table1++) + if(ht_big[table1].linmax >= max) + break; + + return 16 + count_bigv(ix, begin, end, table0, table1, bits); + } +} + +int find_best_2(short *ix, uint32_t start, uint32_t end, const uint32_t *table, + uint32_t len, int *bits) +{ + uint32_t i, sum = 0; + + for(i=start; i> 16)) + { + *bits = (sum & 0xffff); + return 1; + } + else + { + *bits = sum >> 16; + return 0; + } +} + +int find_best_3(short *ix, uint32_t start, uint32_t end, const uint32_t *table, + uint32_t len, int *bits) +{ + uint32_t i, j, sum = 0; + int sum1 = 0; + int sum2 = 0; + int sum3 = 0; + + /* avoid overflow in packed additions: 78*13 < 1024 */ + for(i=start; i end ? end : i + 2*78; + + for(sum=0; i> 20); + sum2 += (sum >> 10) & 0x3ff; + sum3 += (sum >> 0) & 0x3ff; + } + + i = 0; + if(sum1 > sum2) { sum1 = sum2; i = 1; } + if(sum1 > sum3) { sum1 = sum3; i = 2; } + + *bits = sum1; + + return i; +} + +/*************************************************************************/ +/* Function: Count the number of bits necessary to code the subregion. */ +/*************************************************************************/ +int count_bit1(short *ix, uint32_t start, uint32_t end, int *bits ) +{ + uint32_t i, sum = 0; + + for(i=start; i 14) { x = 15; bigv++; } + if(y > 14) { y = 15; bigv++; } + + sum += tab1624[x * 16 + y]; + } + + sum0 = (sum >> 16) + bigv * ht_big[table0].linbits; + sum1 = (sum & 0xffff) + bigv * ht_big[table1].linbits; + + if(sum0 <= sum1) + { + *bits = sum0; + return table0; + } + else + { + *bits = sum1; + return table1; + } +} + +/*************************************************************************/ +/* Function: Calculation of rzero, count1, address3 */ +/* (Partitions ix into big values, quadruples and zeros). */ +/*************************************************************************/ +static int calc_runlen( short *ix, side_info_t *si ) +{ + int p, i, sum = 0; + + for(i=SAMPL2; i-=2; ) + if(*(uint32_t*)&ix[i-2]) /* !!!! short *ix; !!!!! */ + break; + + si->count1 = 0; + + for( ; i>3; i-=4) + { + int v = ix[i-1]; + int w = ix[i-2]; + int x = ix[i-3]; + int y = ix[i-4]; + + if((v | w | x | y) <= 1) + { + p = (y<<3) + (x<<2) + (w<<1) + (v); + + sum += tab01[p]; + + si->count1++; + } + else break; + } + + si->address3 = i; + + if((sum >> 16) < (sum & 0xffff)) + { + si->table_select[3] = 0; + return sum >> 16; + } + else + { + si->table_select[3] = 1; + return sum & 0xffff; + } +} + + +/*************************************************************************/ +/* Function: Quantization of the vector xr ( -> ix) */ +/*************************************************************************/ +static int quantize_int(int *xr, short *ix, side_info_t *si) +{ + unsigned int i, idx, s, frac_pow[] = { 0x10000, 0xd745, 0xb505, 0x9838 }; + + s = frac_pow[si->quantStep & 3] >> si->quantStep / 4; + + /* check for possible 'out of range' values */ + if(((si->max_val + 256) >> 8) * s >= (65536 << 8)) + return 0; + + if(((si->max_val + 256) >> 8) * s < (4096 << 8)) + { /* all values fit the table size */ + for(i=SAMPL2; i--; ) + ix[i] = int2idx[(xr[i] * s + 0x8000) >> 16]; + } + else + { /* check each index wether it fits the table */ + for(i=SAMPL2; i--; ) + { + idx = (xr[i] * s + 0x08000) >> 16; + + if(idx > 4095) ix[i] = int2idx[(idx + 8) >> 4] << 3; + else ix[i] = int2idx[idx]; + } + } + + return 1; +} + +/*************************************************************************/ +/* subdivides the bigvalue region which will use separate Huffman tables */ +/*************************************************************************/ +static void subdivide(side_info_t *si) +{ + int scfb, count0, count1; + + if( !si->address3 ) + { /* no bigvalue region */ + si->region_0_1 = 0; + si->address1 = 0; + si->address2 = 0; + } + else + { + /* Calculate scale factor band index */ + for(scfb=0; scalefac[scfb] < si->address3; ) + scfb++; + + count0 = subdv_table[scfb].region0_cnt; + count1 = subdv_table[scfb].region1_cnt; + + si->region_0_1 = (count0 << 3) | count1; + si->address1 = scalefac[count0 + 1]; + si->address2 = scalefac[count0 + 1 + count1 + 1]; + } +} + +/*******************************************************************/ +/* Count the number of bits necessary to code the bigvalues region */ +/*******************************************************************/ +static int bigv_bitcount(short *ix, side_info_t *gi) +{ + int b1=0, b2=0, b3=0; + + /* Select huffman code tables for bigvalues regions */ + gi->table_select[0] = 0; + gi->table_select[1] = 0; + gi->table_select[2] = 0; + + if( gi->address1 > 0 ) /* region0 */ + gi->table_select[0] = choose_table(ix, 0 , gi->address1, &b1); + + if( gi->address2 > gi->address1 ) /* region1 */ + gi->table_select[1] = choose_table(ix, gi->address1, gi->address2, &b2); + + if( gi->address3 > gi->address2 ) /* region2 */ + gi->table_select[2] = choose_table(ix, gi->address2, gi->address3, &b3); + + return b1+b2+b3; +} + +static int quantize_and_count_bits(int *xr, short *ix, side_info_t *si) +{ + int bits = 10000; + + if(quantize_int(xr, ix, si)) + { + bits = calc_runlen(ix, si); /* rzero,count1,address3 */ + subdivide(si); /* bigvalues sfb division */ + bits += bigv_bitcount(ix,si); /* bit count */ + } + + return bits; +} + +/************************************************************************/ +/* The code selects the best quantStep for a particular set of scalefacs*/ +/************************************************************************/ +static int inner_loop(int *xr, int max_bits, side_info_t *si) +{ + int bits; + + while((bits=quantize_and_count_bits(xr, enc_data, si)) < max_bits-64) + { + if(si->quantStep == 0) + break; + + if(si->quantStep <= 2) + si->quantStep = 0; + else + si->quantStep -= 2; + } + + while(bits > max_bits) + { + si->quantStep++; + bits = quantize_and_count_bits(xr, enc_data, si); + } + + return bits; +} + +static void iteration_loop(int *xr, side_info_t *si, int gr_cnt) +{ + int remain, tar_bits, max_bits = cfg.mean_bits; + + /* distribute reserved bits to remaining granules */ + tar_bits = max_bits + (cfg.ResvSize / gr_cnt & ~7); + if(tar_bits > max_bits + max_bits/2) + tar_bits = max_bits + max_bits/2; + + si->part2_3_length = inner_loop(xr, tar_bits, si); + si->global_gain = si->quantStep + 142 - si->additStep; + + /* unused bits of the reservoir can be used for remaining granules */ + cfg.ResvSize += max_bits - si->part2_3_length; + + /* end: distribute the reserved bits to one or two granules */ + if(gr_cnt == 1) + { + si->part2_3_length += cfg.ResvSize; + /* mp3 format allows max 12bits for granule length */ + if(si->part2_3_length > 4092) + { + remain = (si->part2_3_length - 4092 + 31) >> 5; + si->part2_3_length -= remain << 5; + si[-1].part2_3_length += remain << 5; + + while(remain--) + putbits(~0, 32); + } + } +} + + +/* returns sum_j=0^31 a[j]*cos(PI*j*(k+1/2)/32), 0<=k<32 */ +void window_subband1(short *wk, int sb0[SBLIMIT], int sb1[SBLIMIT]) ICODE_ATTR; +void window_subband1(short *wk, int sb0[SBLIMIT], int sb1[SBLIMIT]) +{ + int k, i, u, v; + short *wp, *x1, *x2; + +#ifdef CPU_COLDFIRE + int s0, s1, t0, t1; + + for(k=0; k<18; k++, wk+=64, sb0+=SBLIMIT, sb1+=SBLIMIT) + { + wp = enwindow; + x1 = wk; + x2 = x1 - 124; + + for(i=-15; i<0; i++) + { + asm volatile( + "move.l (-224*4,%[x2]), %%d4\n" /* d4 = x2[-224] */ + "movem.l (%[wp]), %%d0-%%d3\n" /* load 8 values */ + "mac.w %%d0u, %%d4u, %%acc0\n" + "mac.w %%d0u, %%d4l, (-160*4,%[x2]), %%d4, %%acc1\n" + "mac.w %%d0l, %%d4u, %%acc0\n" + "mac.w %%d0l, %%d4l, ( -96*4,%[x2]), %%d4, %%acc1\n" + "mac.w %%d1u, %%d4u, %%acc0\n" + "mac.w %%d1u, %%d4l, ( -32*4,%[x2]), %%d4, %%acc1\n" + "mac.w %%d1l, %%d4u, %%acc0\n" + "mac.w %%d1l, %%d4l, ( 32*4,%[x2]), %%d4, %%acc1\n" + "mac.w %%d2u, %%d4u, %%acc0\n" + "mac.w %%d2u, %%d4l, ( 96*4,%[x2]), %%d4, %%acc1\n" + "mac.w %%d2l, %%d4u, %%acc0\n" + "mac.w %%d2l, %%d4l, ( 160*4,%[x2]), %%d4, %%acc1\n" + "mac.w %%d3u, %%d4u, %%acc0\n" + "mac.w %%d3u, %%d4l, ( 224*4,%[x2]), %%d4, %%acc1\n" + "mac.w %%d3l, %%d4u, %%acc0\n" + "mac.w %%d3l, %%d4l, (-256*4,%[x1]), %%d4, %%acc1\n" + "movem.l (16,%[wp]), %%d0-%%d3\n" /* load 8 values */ + "mac.w %%d0u, %%d4u, %%acc0\n" + "mac.w %%d0u, %%d4l, (-192*4,%[x1]), %%d4, %%acc1\n" + "mac.w %%d0l, %%d4u, %%acc0\n" + "mac.w %%d0l, %%d4l, (-128*4,%[x1]), %%d4, %%acc1\n" + "mac.w %%d1u, %%d4u, %%acc0\n" + "mac.w %%d1u, %%d4l, ( -64*4,%[x1]), %%d4, %%acc1\n" + "mac.w %%d1l, %%d4u, %%acc0\n" + "mac.w %%d1l, %%d4l, ( 0*4,%[x1]), %%d4, %%acc1\n" + "mac.w %%d2u, %%d4u, %%acc0\n" + "mac.w %%d2u, %%d4l, ( 64*4,%[x1]), %%d4, %%acc1\n" + "mac.w %%d2l, %%d4u, %%acc0\n" + "mac.w %%d2l, %%d4l, ( 128*4,%[x1]), %%d4, %%acc1\n" + "mac.w %%d3u, %%d4u, %%acc0\n" + "mac.w %%d3u, %%d4l, ( 192*4,%[x1]), %%d4, %%acc1\n" + "mac.w %%d3l, %%d4u, %%acc0\n" + "mac.w %%d3l, %%d4l, ( 224*4,%[x1]), %%d4, %%acc1\n" + "movclr.l %%acc0, %%d0\n" + "move.l %%d0, %[s0]\n" + "movclr.l %%acc1, %%d0\n" + "move.l %%d0, %[s1]\n" + + "movem.l (%[wp]), %%d0-%%d3\n" /* load 8 values */ + "mac.w %%d0u, %%d4u, %%acc0\n" + "mac.w %%d0u, %%d4l, ( 160*4,%[x1]), %%d4, %%acc1\n" + "mac.w %%d0l, %%d4u, %%acc0\n" + "mac.w %%d0l, %%d4l, ( 96*4,%[x1]), %%d4, %%acc1\n" + "mac.w %%d1u, %%d4u, %%acc0\n" + "mac.w %%d1u, %%d4l, ( 32*4,%[x1]), %%d4, %%acc1\n" + "mac.w %%d1l, %%d4u, %%acc0\n" + "mac.w %%d1l, %%d4l, ( -32*4,%[x1]), %%d4, %%acc1\n" + "mac.w %%d2u, %%d4u, %%acc0\n" + "mac.w %%d2u, %%d4l, ( -96*4,%[x1]), %%d4, %%acc1\n" + "mac.w %%d2l, %%d4u, %%acc0\n" + "mac.w %%d2l, %%d4l, (-160*4,%[x1]), %%d4, %%acc1\n" + "mac.w %%d3u, %%d4u, %%acc0\n" + "mac.w %%d3u, %%d4l, (-224*4,%[x1]), %%d4, %%acc1\n" + "mac.w %%d3l, %%d4u, %%acc0\n" + "mac.w %%d3l, %%d4l, ( 256*4,%[x2]), %%d4, %%acc1\n" + "movem.l (32,%[wp]), %%d0-%%d3\n" /* load 8 values */ + "mac.w %%d0u, %%d4u, %%acc0\n" + "mac.w %%d0u, %%d4l, ( 192*4,%[x2]), %%d4, %%acc1\n" + "mac.w %%d0l, %%d4u, %%acc0\n" + "mac.w %%d0l, %%d4l, ( 128*4,%[x2]), %%d4, %%acc1\n" + "mac.w %%d1u, %%d4u, %%acc0\n" + "mac.w %%d1u, %%d4l, ( 64*4,%[x2]), %%d4, %%acc1\n" + "mac.w %%d1l, %%d4u, %%acc0\n" + "mac.w %%d1l, %%d4l, ( 0*4,%[x2]), %%d4, %%acc1\n" + "mac.w %%d2u, %%d4u, %%acc0\n" + "mac.w %%d2u, %%d4l, ( -64*4,%[x2]), %%d4, %%acc1\n" + "mac.w %%d2l, %%d4u, %%acc0\n" + "mac.w %%d2l, %%d4l, (-128*4,%[x2]), %%d4, %%acc1\n" + "mac.w %%d3u, %%d4u, %%acc0\n" + "mac.w %%d3u, %%d4l, (-192*4,%[x2]), %%d4, %%acc1\n" + "mac.w %%d3l, %%d4u, %%acc0\n" + "mac.w %%d3l, %%d4l, %%acc1\n" + "movclr.l %%acc0, %%d0\n" + "move.l %%d0, %[t0]\n" + "movclr.l %%acc1, %%d0\n" + "move.l %%d0, %[t1]\n" + + : [x1] "+a" (x1), [x2] "+a" (x2), [s0] "+m" (s0), [t0] "+m" (t0), + [s1] "+m" (s1), [t1] "+m" (t1) + : [wp] "a" (wp) : "d0", "d1", "d2", "d3", "d4"); + + sb0[30+i*2] = shft4(t0) + shft13(s0) * wp[24]; + sb0[31+i*2] = shft13(t0) * wp[25] - shft13(s0) * wp[26]; + sb1[30+i*2] = shft4(t1) + shft13(s1) * wp[24]; + sb1[31+i*2] = shft13(t1) * wp[25] - shft13(s1) * wp[26]; + wp += 27; + x1 -= 2; + x2 += 2; + } + + asm volatile( + "move.l ( -32*4,%[x1]), %%d4\n" /* d4 = x1[-32] */ + "movem.l (%[wp]), %%d0-%%d3\n" /* load 8 values */ + + "mac.w %%d0u, %%d4u, %%acc0\n" + "mac.w %%d0u, %%d4l, ( -96*4,%[x1]), %%d4, %%acc1\n" + "mac.w %%d0l, %%d4u, %%acc0\n" + "mac.w %%d0l, %%d4l, (-160*4,%[x1]), %%d4, %%acc1\n" + "mac.w %%d1u, %%d4u, %%acc0\n" + "mac.w %%d1u, %%d4l, (-224*4,%[x1]), %%d4, %%acc1\n" + "mac.w %%d1l, %%d4u, %%acc0\n" + "mac.w %%d1l, %%d4l, ( 32*4,%[x1]), %%d4, %%acc1\n" + "mac.w %%d2u, %%d4u, %%acc0\n" + "mac.w %%d2u, %%d4l, ( 96*4,%[x1]), %%d4, %%acc1\n" + "mac.w %%d2l, %%d4u, %%acc0\n" + "mac.w %%d2l, %%d4l, ( 160*4,%[x1]), %%d4, %%acc1\n" + "mac.w %%d3u, %%d4u, %%acc0\n" + "mac.w %%d3u, %%d4l, ( 224*4,%[x1]), %%d4, %%acc1\n" + "mac.w %%d3l, %%d4u, %%acc0\n" + "mac.w %%d3l, %%d4l, ( -16*4,%[x1]), %%d4, %%acc1\n" + "movclr.l %%acc0, %%d0\n" + "move.l %%d0, %[s0]\n" + "movclr.l %%acc1, %%d0\n" + "move.l %%d0, %[s1]\n" + + "movem.l (16,%[wp]), %%d0-%%d3\n" /* load 8 values */ + "mac.w %%d0u, %%d4u, %%acc0\n" + "mac.w %%d0u, %%d4l, ( -48*4,%[x1]), %%d4, %%acc1\n" + "mac.w %%d1u, %%d4u, %%acc0\n" + "mac.w %%d1u, %%d4l, ( 16*4,%[x1]), %%d4, %%acc1\n" + "mac.w %%d1l, %%d4u, %%acc0\n" + "mac.w %%d1l, %%d4l, ( -80*4,%[x1]), %%d4, %%acc1\n" + "mac.w %%d2u, %%d4u, %%acc0\n" + "mac.w %%d2u, %%d4l, ( 48*4,%[x1]), %%d4, %%acc1\n" + "mac.w %%d2u, %%d4u, %%acc0\n" + "mac.w %%d2u, %%d4l, (-112*4,%[x1]), %%d4, %%acc1\n" + "mac.w %%d3u, %%d4u, %%acc0\n" + "mac.w %%d3u, %%d4l, ( 80*4,%[x1]), %%d4, %%acc1\n" + "mac.w %%d3l, %%d4u, %%acc0\n" + "mac.w %%d3l, %%d4l, (-144*4,%[x1]), %%d4, %%acc1\n" + "movem.l (32,%[wp]), %%d0-%%d3\n" /* load 8 values */ + "mac.w %%d0u, %%d4u, %%acc0\n" + "mac.w %%d0u, %%d4l, ( 112*4,%[x1]), %%d4, %%acc1\n" + "mac.w %%d0u, %%d4u, %%acc0\n" + "mac.w %%d0u, %%d4l, (-176*4,%[x1]), %%d4, %%acc1\n" + "mac.w %%d1u, %%d4u, %%acc0\n" + "mac.w %%d1u, %%d4l, ( 144*4,%[x1]), %%d4, %%acc1\n" + "mac.w %%d1l, %%d4u, %%acc0\n" + "mac.w %%d1l, %%d4l, (-208*4,%[x1]), %%d4, %%acc1\n" + "mac.w %%d2u, %%d4u, %%acc0\n" + "mac.w %%d2u, %%d4l, ( 176*4,%[x1]), %%d4, %%acc1\n" + "mac.w %%d2u, %%d4u, %%acc0\n" + "mac.w %%d2u, %%d4l, (-240*4,%[x1]), %%d4, %%acc1\n" + "mac.w %%d3u, %%d4u, %%acc0\n" + "mac.w %%d3u, %%d4l, ( 208*4,%[x1]), %%d4, %%acc1\n" + "mac.w %%d3l, %%d4u, %%acc0\n" + "mac.w %%d3l, %%d4l, %%acc1\n" + "movclr.l %%acc0, %%d0\n" + "move.l %%d0, %[t0]\n" + "movclr.l %%acc1, %%d0\n" + "move.l %%d0, %[t1]\n" + + : [x1] "+a" (x1), [s0] "+m" (s0), [t0] "+m" (t0), + [s1] "+m" (s1), [t1] "+m" (t1) + : [wp] "a" (wp) : "d0", "d1", "d2", "d3", "d4"); + + u = shft4(s0 - t0); + v = shft4(s0 + t0); + t0 = sb0[14]; + s0 = sb0[15] - t0; + + sb0[31] = v + t0; /* A0 */ + sb0[30] = u + s0; /* A1 */ + sb0[15] = u - s0; /* A2 */ + sb0[14] = v - t0; /* A3 */ + + u = shft4(s1 - t1); + v = shft4(s1 + t1); + t1 = sb1[14]; + s1 = sb1[15] - t1; + + sb1[31] = v + t1; /* A0 */ + sb1[30] = u + s1; /* A1 */ + sb1[15] = u - s1; /* A2 */ + sb1[14] = v - t1; /* A3 */ + } +#else + int ch, s, t, *a; + + for(ch=0; ch 160) + bitrate = 160; + + return ci->round_value_to_list32(bitrate, + &bitr_index[type][1], 14, true) + 1; +} + +static int find_samplerate_index(long freq, int *mp3_type) +{ + int mpeg = freq >= (32000+24000)/2 ? 1 : 0; + int i = ci->round_value_to_list32(freq, sampr_index[mpeg], 3, true); + *mp3_type = mpeg; + return i; +} + +static bool init_mp3_encoder_engine(int sample_rate, + int num_channels, + int rec_mono_mode, + struct encoder_config *enc_cfg) +{ + const bool stereo = num_channels > 1; + uint32_t avg_byte_per_frame; + + cfg.channels = stereo ? 2 : 1; + cfg.rec_mono_mode = rec_mono_mode; + cfg.mpg.mode = stereo ? 0 : 3; /* 0=stereo, 3=mono */ + cfg.mpg.smpl_id = find_samplerate_index(sample_rate, &cfg.mpg.type); + cfg.samplerate = sampr_index[cfg.mpg.type][cfg.mpg.smpl_id]; + cfg.mpg.bitr_id = find_bitrate_index(cfg.mpg.type, + enc_cfg->mp3_enc.bitrate, + stereo); + cfg.mpg.bitrate = bitr_index[cfg.mpg.type][cfg.mpg.bitr_id]; + cfg.mpg.num_bands = num_bands[stereo ? cfg.mpg.type : 2][cfg.mpg.bitr_id]; + + if (cfg.mpg.type == 1) + { + cfg.granules = 2; + pcm_chunk_size = PCM_CHUNK_SIZE1; + samp_per_frame = SAMP_PER_FRAME1; + } + else + { + cfg.granules = 1; + pcm_chunk_size = PCM_CHUNK_SIZE2; + samp_per_frame = SAMP_PER_FRAME2; + } + + memcpy(scalefac, sfBand[cfg.mpg.smpl_id + 3*cfg.mpg.type], sizeof(scalefac)); + memset(mfbuf , 0 , sizeof(mfbuf )); + memset(mdct_freq , 0 , sizeof(mdct_freq )); + memset(enc_data , 0 , sizeof(enc_data )); + memset(sb_data , 0 , sizeof(sb_data )); + memset(&CodedData, 0 , sizeof(CodedData )); + memcpy(ca , ca_const , sizeof(ca )); + memcpy(cs , cs_const , sizeof(cs )); + memcpy(cx , cx_const , sizeof(cx )); + memcpy(win , win_const , sizeof(win )); + memcpy(enwindow , enwindow_const , sizeof(enwindow )); + memcpy(int2idx , int2idx_const , sizeof(int2idx )); + memcpy(ht_count , ht_count_const , sizeof(ht_count )); + memcpy( tab01 , tab01_const , sizeof(tab01 )); + memcpy( tab23 , tab23_const , sizeof(tab23 )); + memcpy( tab56 , tab56_const , sizeof(tab56 )); + memcpy( tab1315 , tab1315_const , sizeof(tab1315 )); + memcpy( tab1624 , tab1624_const , sizeof(tab1624 )); + memcpy( tab789 , tab789_const , sizeof(tab789 )); + memcpy( tabABC , tabABC_const , sizeof(tabABC )); + memcpy( t1HB , t1HB_const , sizeof(t1HB )); + memcpy( t2HB , t2HB_const , sizeof(t2HB )); + memcpy( t3HB , t3HB_const , sizeof(t3HB )); + memcpy( t5HB , t5HB_const , sizeof(t5HB )); + memcpy( t6HB , t6HB_const , sizeof(t6HB )); + memcpy( t7HB , t7HB_const , sizeof(t7HB )); + memcpy( t8HB , t8HB_const , sizeof(t8HB )); + memcpy( t9HB , t9HB_const , sizeof(t9HB )); + memcpy(t10HB , t10HB_const , sizeof(t10HB )); + memcpy(t11HB , t11HB_const , sizeof(t11HB )); + memcpy(t12HB , t12HB_const , sizeof(t12HB )); + memcpy(t13HB , t13HB_const , sizeof(t13HB )); + memcpy(t15HB , t15HB_const , sizeof(t15HB )); + memcpy(t16HB , t16HB_const , sizeof(t16HB )); + memcpy(t24HB , t24HB_const , sizeof(t24HB )); + memcpy( t1l , t1l_const , sizeof(t1l )); + memcpy( t2l , t2l_const , sizeof(t2l )); + memcpy( t3l , t3l_const , sizeof(t3l )); + memcpy( t5l , t5l_const , sizeof(t5l )); + memcpy( t6l , t6l_const , sizeof(t6l )); + memcpy( t7l , t7l_const , sizeof(t7l )); + memcpy( t8l , t8l_const , sizeof(t8l )); + memcpy( t9l , t9l_const , sizeof(t9l )); + memcpy(t10l , t10l_const , sizeof(t10l )); + memcpy(t11l , t11l_const , sizeof(t11l )); + memcpy(t12l , t12l_const , sizeof(t12l )); + memcpy(t13l , t13l_const , sizeof(t13l )); + memcpy(t15l , t15l_const , sizeof(t15l )); + memcpy(t16l , t16l_const , sizeof(t16l )); + memcpy(t24l , t24l_const , sizeof(t24l )); + memcpy(ht , ht_const , sizeof(ht )); + + ht[ 0].table = NULL; ht[ 0].hlen = NULL; /* Apparently not used */ + ht[ 1].table = t1HB; ht[ 1].hlen = t1l; + ht[ 2].table = t2HB; ht[ 2].hlen = t2l; + ht[ 3].table = t3HB; ht[ 3].hlen = t3l; + ht[ 4].table = NULL; ht[ 4].hlen = NULL; /* Apparently not used */ + ht[ 5].table = t5HB; ht[ 5].hlen = t5l; + ht[ 6].table = t6HB; ht[ 6].hlen = t6l; + ht[ 7].table = t7HB; ht[ 7].hlen = t7l; + ht[ 8].table = t8HB; ht[ 8].hlen = t8l; + ht[ 9].table = t9HB; ht[ 9].hlen = t9l; + ht[10].table = t10HB; ht[10].hlen = t10l; + ht[11].table = t11HB; ht[11].hlen = t11l; + ht[12].table = t12HB; ht[12].hlen = t12l; + ht[13].table = t13HB; ht[13].hlen = t13l; + ht[14].table = NULL; ht[14].hlen = NULL; /* Apparently not used */ + ht[15].table = t15HB; ht[15].hlen = t15l; + + /* Figure average number of 'bytes' per frame */ + avg_byte_per_frame = SAMPL2 * 16000 * cfg.mpg.bitrate / (2 - cfg.mpg.type); + avg_byte_per_frame = avg_byte_per_frame / cfg.samplerate; + cfg.byte_per_frame = avg_byte_per_frame / 64; + cfg.frac_per_frame = avg_byte_per_frame & 63; + cfg.slot_lag = 0; + cfg.sideinfo_len = 32 + (cfg.mpg.type ? (cfg.channels == 1 ? 136 : 256) + : (cfg.channels == 1 ? 72 : 136)); + + return true; +} + +STATICIRAM void to_mono_mm(void) ICODE_ATTR; +STATICIRAM void to_mono_mm(void) +{ + /* |llllllllllllllll|rrrrrrrrrrrrrrrr| => + * |mmmmmmmmmmmmmmmm|mmmmmmmmmmmmmmmm| + */ + uint16_t *samp = &mfbuf[2*512]; + uint16_t *samp_end = samp + 2*samp_per_frame; + + inline void to_mono(uint16_t **samp) + { + int16_t l = **samp; + int16_t r = *(*samp+1); + int32_t m; + + switch(cfg.rec_mono_mode) + { + case 1: + /* mono = L */ + m = l; + break; + case 2: + /* mono = R */ + m = r; + break; + case 0: + default: + /* mono = (L+R)/2 */ + m = l + r + err; + err = m & 1; + m >>= 1; + break; + } + *(*samp)++ = (uint16_t)m; + *(*samp)++ = (uint16_t)m; + } /* to_mono */ + + do + { + to_mono(&samp); + to_mono(&samp); + to_mono(&samp); + to_mono(&samp); + to_mono(&samp); + to_mono(&samp); + to_mono(&samp); + to_mono(&samp); + } + while (samp < samp_end); +} /* to_mono_mm */ + +#ifdef ROCKBOX_LITTLE_ENDIAN +/* Swaps a frame to big endian */ +static inline void byte_swap_frame32(uint32_t *dst, uint32_t *src, + size_t size) +{ + uint32_t *src_end = SKIPBYTES(src, size); + + do + { + *dst++ = swap32(*src++); + *dst++ = swap32(*src++); + *dst++ = swap32(*src++); + *dst++ = swap32(*src++); + *dst++ = swap32(*src++); + *dst++ = swap32(*src++); + *dst++ = swap32(*src++); + *dst++ = swap32(*src++); + } + while(src < src_end); +} /* byte_swap_frame32 */ +#endif /* ROCKBOX_LITTLE_ENDIAN */ + +static void set_scale_facs(int *mdct_freq) +{ + unsigned int i, is, ie, k, s; + int max_freq_val, avrg_freq_val; + + /* calc average of first 256 frequency values */ + for(avrg_freq_val=i=0; i<256; i++) + avrg_freq_val += mdct_freq[i]; + avrg_freq_val >>= 8; + + /* if max of current band is smaller than average, increase precision */ + /* last band keeps untouched (not scaled) */ + for(is=k=0; is avrg_freq_val) + break; + + band_scale_f[k] = (unsigned char)s; + + for(i=is; s && i= 64) + { /* Padding for this frame */ + cfg.slot_lag -= 64; + cfg.mpg.padding = 1; + } + else + cfg.mpg.padding = 0; + + cfg.mean_bits = (8 * cfg.byte_per_frame + 8 * cfg.mpg.padding + - cfg.sideinfo_len) / cfg.granules / cfg.channels + - 42; // reserved for scale_facs + + /* shift out old samples */ + memcpy(mfbuf, mfbuf + 2*cfg.granules*576, 4*512); + + if (chunk->flags & CHUNKF_START_FILE) + { + /* prefix silent samples for encoder delay */ + memset(mfbuf + 2*512, 0, ENC_DELAY_SIZE); + /* read new samples to iram for further processing */ + memcpy(mfbuf + 2*512 + ENC_DELAY_SIZE/2, + buffer, pcm_chunk_size - ENC_DELAY_SIZE); + chunk->num_pcm = samp_per_frame - ENC_DELAY_SAMP; + } + else + { + /* read new samples to iram for further processing */ + memcpy(mfbuf + 2*512, buffer, pcm_chunk_size); + chunk->num_pcm = samp_per_frame; + } + + if (cfg.channels == 1) + to_mono_mm(); + + cfg.ResvSize = 0; + gr_cnt = cfg.granules * cfg.channels; + CodedData.bitpos = cfg.sideinfo_len; /* leave space for mp3 header */ + + for(gr=0; gr> 2); + for(k=1,ii=0; ii<3 && k; ii++) + { + int *mdct = mdct_freq; + int band; + + cfg.cod_info[gr][ch].additStep = 4 * (14 - shift); + + for(band=0; band=0; --k) + { + int bu, bd; + bu = shft15(mdct[k]) * ca[k] + + shft15(mdct[-1-k]) * cs[k]; + bd = shft15(mdct[k]) * cs[k] - + shft15(mdct[-1-k]) * ca[k]; + mdct[-1-k] = bu; + mdct[ k ] = bd; + } + } + } + + max = 0; + for(k=0; k<576; k++) + { + if(mdct_freq[k] < 0) + { + mdct_sign[k] = 1; /* negative */ + mdct_freq[k] = shft13(-mdct_freq[k]); + } + else + { + mdct_sign[k] = 0; /* positive */ + mdct_freq[k] = shft13(mdct_freq[k]); + } + + if(max < (uint32_t)mdct_freq[k]) + max = (uint32_t)mdct_freq[k]; + } + cfg.cod_info[gr][ch].max_val = max; + + /* calc new shift for higher integer precision */ + for(k=0; max<(uint32_t)(0x7800>>k); k++) shift--; + for( ; (max>>k)>=(uint32_t)0x10000; k++) shift++; + if(shift < 0) shift = 0; + } + + cfg.cod_info[gr][ch].quantStep += + cfg.cod_info[gr][ch].additStep; + + set_scale_facs(mdct_freq); + + /* bit and noise allocation */ + iteration_loop(mdct_freq, &cfg.cod_info[gr][ch], + gr_cnt--); + /* write the frame to the bitstream */ + Huffmancodebits(enc_data, mdct_sign, + &cfg.cod_info[gr][ch]); + + cfg.cod_info[gr][ch].quantStep -= + cfg.cod_info[gr][ch].additStep; + + if(cfg.granules == 1) + { + memcpy(sb_data[ch][0], sb_data[ch][1], + sizeof(sb_data[ch][0])); + } + } + } + + chunk->enc_size = cfg.byte_per_frame + cfg.mpg.padding; + + /* finish this chunk by adding sideinfo header data */ + CodedData.bitpos = 0; + encodeSideInfo( cfg.cod_info ); + +#ifdef ROCKBOX_BIG_ENDIAN + /* copy chunk to enc_buffer */ + memcpy(chunk->enc_data, CodedData.bbuf, chunk->enc_size); +#else + /* swap frame to big endian */ + byte_swap_frame32((uint32_t *)chunk->enc_data, CodedData.bbuf, chunk->enc_size); +#endif +} /* encode_frame */ + +/* called very often - inline */ +static inline bool is_file_data_ok(struct enc_file_event_data *filed) +{ + return filed->rec_file >= 0 && (long)filed->chunk->flags >= 0; +} /* is_event_ok */ + +static unsigned char mp3_data[16384] __attribute__((aligned(4))); +static unsigned int mp3_data_len; /* current data size in buffer */ + +/* called very often - inline */ +static inline bool on_write_chunk(struct enc_file_event_data *data) +{ + if (!is_file_data_ok(data)) + return false; + + if (data->chunk->enc_data == NULL) + { +#ifdef ROCKBOX_HAS_LOGF + ci->logf("mp3 enc: NULL data"); +#endif + return true; + } + + /* if current chunk doesn't fit => write collected data */ + if (mp3_data_len + data->chunk->enc_size > sizeof(mp3_data)) + { + if (ci->write(data->rec_file, mp3_data, + mp3_data_len) != (ssize_t)mp3_data_len) + return false; + + mp3_data_len = 0; + } + + memcpy(mp3_data+mp3_data_len, data->chunk->enc_data, + data->chunk->enc_size); + + mp3_data_len += data->chunk->enc_size; + + data->num_pcm_samples += data->chunk->num_pcm; + return true; +} /* on_write_chunk */ + +static bool on_start_file(struct enc_file_event_data *data) +{ + if ((data->chunk->flags & CHUNKF_ERROR) || *data->filename == '\0') + return false; + + data->rec_file = ci->open(data->filename, O_RDWR|O_CREAT|O_TRUNC, 0666); + + if (data->rec_file < 0) + return false; + + /* reset sample count */ + data->num_pcm_samples = 0; + + /* reset buffer write position */ + mp3_data_len = 0; + + return true; +} /* on_start_file */ + +static bool on_end_file(struct enc_file_event_data *data) +{ + if (data->rec_file < 0) + return false; /* file already closed, nothing more we can do */ + + /* write the remaining mp3_data */ + if (ci->write(data->rec_file, mp3_data, mp3_data_len) + != (ssize_t)mp3_data_len) + return false; + + /* reset buffer write position */ + mp3_data_len = 0; + + /* always _try_ to write the file header, even on error */ + if (ci->close(data->rec_file) != 0) + return false; + + data->rec_file = -1; + + return true; +} /* on_end_file */ + +static void on_rec_new_stream(struct enc_buffer_event_data *data) +{ + int num_frames = cfg.mpg.type == 1 ? + ENC_PADDING_FRAMES1 : ENC_PADDING_FRAMES2; + + if (data->flags & CHUNKF_END_FILE) + { + /* add silent frames to end - encoder will also be flushed for start + of next file if any */ + memset(res_buffer, 0, pcm_chunk_size); + + /* the initial chunk given for the end is at enc_wr_index */ + while (num_frames-- > 0) + { + data->chunk->enc_data = ENC_CHUNK_SKIP_HDR(data->chunk->enc_data, + data->chunk); + + encode_frame(res_buffer, data->chunk); + data->chunk->num_pcm = samp_per_frame; + + ci->enc_finish_chunk(); + data->chunk = ci->enc_get_chunk(); + } + } + else if (data->flags & CHUNKF_PRERECORD) + { + /* nothing to add and we cannot change prerecorded data */ + } + else if (data->flags & CHUNKF_START_FILE) + { + /* starting fresh ... be sure to flush encoder first */ + struct enc_chunk_hdr *chunk = ENC_CHUNK_HDR(res_buffer); + + chunk->flags = 0; + chunk->enc_data = ENC_CHUNK_SKIP_HDR(chunk->enc_data, chunk); + + while (num_frames-- > 0) + { + memset(chunk->enc_data, 0, pcm_chunk_size); + encode_frame(chunk->enc_data, chunk); + } + } +} /* on_rec_new_stream */ + +static void enc_events_callback(enum enc_events event, void *data) +{ + switch (event) + { + case ENC_WRITE_CHUNK: + if (on_write_chunk((struct enc_file_event_data *)data)) + return; + + break; + + case ENC_START_FILE: + if (on_start_file((struct enc_file_event_data *)data)) + return; + + break; + + case ENC_END_FILE: + if (on_end_file((struct enc_file_event_data *)data)) + return; + + break; + + case ENC_REC_NEW_STREAM: + on_rec_new_stream((struct enc_buffer_event_data *)data); + return; + + default: + return; + } + + /* Something failed above. Signal error back to core. */ + ((struct enc_file_event_data *)data)->chunk->flags |= CHUNKF_ERROR; +} /* enc_events_callback */ + +static bool enc_init(void) +{ + struct enc_inputs inputs; + struct enc_parameters params; + + if (ci->enc_get_inputs == NULL || + ci->enc_set_parameters == NULL || + ci->enc_get_chunk == NULL || + ci->enc_finish_chunk == NULL || + ci->enc_get_pcm_data == NULL || + ci->enc_unget_pcm_data == NULL ) + return false; + + ci->enc_get_inputs(&inputs); + + if (inputs.config->afmt != AFMT_MPA_L3) + return false; + + init_mp3_encoder_engine(inputs.sample_rate, inputs.num_channels, + inputs.rec_mono_mode, inputs.config); + + err = 0; + + /* configure the buffer system */ + params.afmt = AFMT_MPA_L3; + params.chunk_size = cfg.byte_per_frame + 1; + params.enc_sample_rate = cfg.samplerate; + /* need enough reserved bytes to hold one frame of pcm samples + hdr + for padding and flushing */ + params.reserve_bytes = ENC_CHUNK_HDR_SIZE + pcm_chunk_size; + params.events_callback = enc_events_callback; + ci->enc_set_parameters(¶ms); + + res_buffer = params.reserve_buffer; + +#ifdef CPU_COLDFIRE + asm volatile ("move.l #0, %macsr"); /* integer mode */ +#endif + + return true; +} /* enc_init */ + +/* this is the codec entry point */ +enum codec_status codec_main(enum codec_entry_call_reason reason) +{ + if (reason == CODEC_LOAD) { + if (!enc_init()) + return CODEC_ERROR; + } + else if (reason == CODEC_UNLOAD) { + /* reset parameters to initial state */ + ci->enc_set_parameters(NULL); + } + + return CODEC_OK; +} + +/* this is called for each file to process */ +enum codec_status codec_run(void) +{ + /* main encoding loop */ + while(ci->get_command(NULL) != CODEC_ACTION_HALT) + { + char *buffer = buffer = ci->enc_get_pcm_data(pcm_chunk_size); + struct enc_chunk_hdr *chunk; + + if(buffer == NULL) + continue; + + chunk = ci->enc_get_chunk(); + chunk->enc_data = ENC_CHUNK_SKIP_HDR(chunk->enc_data, chunk); + + encode_frame(buffer, chunk); + + if (chunk->num_pcm < samp_per_frame) + { + ci->enc_unget_pcm_data(pcm_chunk_size - chunk->num_pcm*4); + chunk->num_pcm = samp_per_frame; + } + + ci->enc_finish_chunk(); + } + + return CODEC_OK; +} diff --git a/lib/rbcodec/codecs/mpa.c b/lib/rbcodec/codecs/mpa.c new file mode 100644 index 0000000000..f9bf7e600f --- /dev/null +++ b/lib/rbcodec/codecs/mpa.c @@ -0,0 +1,521 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2005 Dave Chapman + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include "codeclib.h" +#include +#include + +CODEC_HEADER + +#if NUM_CORES > 1 && !defined(MPEGPLAYER) +#define MPA_SYNTH_ON_COP +#endif + +static struct mad_stream stream IBSS_ATTR; +static struct mad_frame frame IBSS_ATTR; +static struct mad_synth synth IBSS_ATTR; + +#ifdef MPA_SYNTH_ON_COP +static volatile short die IBSS_ATTR = 0; /*thread should die*/ + +#if (CONFIG_CPU == PP5024) || (CONFIG_CPU == PP5022) +static mad_fixed_t sbsample_prev[2][36][32] IBSS_ATTR; +#else +static mad_fixed_t sbsample_prev[2][36][32] SHAREDBSS_ATTR; +#endif + +static struct semaphore synth_done_sem IBSS_ATTR; +static struct semaphore synth_pending_sem IBSS_ATTR; +#endif + +#define INPUT_CHUNK_SIZE 8192 + +static mad_fixed_t mad_frame_overlap[2][32][18] IBSS_ATTR; +static mad_fixed_t sbsample[2][36][32] IBSS_ATTR; + +static unsigned char mad_main_data[MAD_BUFFER_MDLEN] IBSS_ATTR; +/* TODO: what latency does layer 1 have? */ +static int mpeg_latency[3] = { 0, 481, 529 }; +static int mpeg_framesize[3] = {384, 1152, 1152}; + +static void init_mad(void) +{ + ci->memset(&stream, 0, sizeof(struct mad_stream)); + ci->memset(&frame , 0, sizeof(struct mad_frame)); + ci->memset(&synth , 0, sizeof(struct mad_synth)); + +#ifdef MPA_SYNTH_ON_COP + frame.sbsample_prev = &sbsample_prev; + frame.sbsample = &sbsample; +#else + frame.sbsample_prev = &sbsample; + frame.sbsample = &sbsample; +#endif + + /* We do this so libmad doesn't try to call codec_calloc(). This needs to + * be called before mad_stream_init(), mad_frame_inti() and + * mad_synth_init(). */ + frame.overlap = &mad_frame_overlap; + stream.main_data = &mad_main_data; + + /* Call mad initialization. Those will zero the arrays frame.overlap, + * frame.sbsample and frame.sbsample_prev. Therefore there is no need to + * zero them here. */ + mad_stream_init(&stream); + mad_frame_init(&frame); + mad_synth_init(&synth); +} + +static int get_file_pos(int newtime) +{ + int pos = -1; + struct mp3entry *id3 = ci->id3; + + if (id3->vbr) { + /* Convert newtime and id3->length to seconds to + * avoid overflow */ + unsigned int newtime_s = newtime/1000; + unsigned int length_s = id3->length/1000; + + if (id3->has_toc) { + /* Use the TOC to find the new position */ + unsigned int percent, remainder; + int curtoc, nexttoc, plen; + + percent = (newtime_s*100) / length_s; + if (percent > 99) + percent = 99; + + curtoc = id3->toc[percent]; + + if (percent < 99) { + nexttoc = id3->toc[percent+1]; + } else { + nexttoc = 256; + } + + pos = (id3->filesize/256)*curtoc; + + /* Use the remainder to get a more accurate position */ + remainder = (newtime_s*100) % length_s; + remainder = (remainder*100) / length_s; + plen = (nexttoc - curtoc)*(id3->filesize/256); + pos += (plen/100)*remainder; + } else { + /* No TOC exists, estimate the new position */ + pos = (id3->filesize / length_s) * newtime_s; + } + } else if (id3->bitrate) { + pos = newtime * (id3->bitrate / 8); + } else { + return -1; + } + + /* Don't seek right to the end of the file so that we can + transition properly to the next song */ + if (pos >= (int)(id3->filesize - id3->id3v1len)) + pos = id3->filesize - id3->id3v1len - 1; + + /* id3->filesize excludes id3->first_frame_offset, so add it now */ + pos += id3->first_frame_offset; + + return pos; +} + +static void set_elapsed(struct mp3entry* id3) +{ + unsigned long offset = id3->offset > id3->first_frame_offset ? + id3->offset - id3->first_frame_offset : 0; + unsigned long elapsed = id3->elapsed; + + if ( id3->vbr ) { + if ( id3->has_toc ) { + /* calculate elapsed time using TOC */ + int i; + unsigned int remainder, plen, relpos, nextpos; + + /* find wich percent we're at */ + for (i=0; i<100; i++ ) + if ( offset < id3->toc[i] * (id3->filesize / 256) ) + break; + + i--; + if (i < 0) + i = 0; + + relpos = id3->toc[i]; + + if (i < 99) + nextpos = id3->toc[i+1]; + else + nextpos = 256; + + remainder = offset - (relpos * (id3->filesize / 256)); + + /* set time for this percent (divide before multiply to prevent + overflow on long files. loss of precision is negligible on + short files) */ + elapsed = i * (id3->length / 100); + + /* calculate remainder time */ + plen = (nextpos - relpos) * (id3->filesize / 256); + elapsed += (((remainder * 100) / plen) * (id3->length / 10000)); + } + else { + /* no TOC exists. set a rough estimate using average bitrate */ + int tpk = id3->length / + ((id3->filesize - id3->first_frame_offset - id3->id3v1len) / + 1024); + elapsed = offset / 1024 * tpk; + } + } + else + { + /* constant bitrate, use exact calculation */ + if (id3->bitrate != 0) + elapsed = offset / (id3->bitrate / 8); + } + + ci->set_elapsed(elapsed); +} + +#ifdef MPA_SYNTH_ON_COP + +/* + * Run the synthesis filter on the COProcessor + */ + +static int mad_synth_thread_stack[DEFAULT_STACK_SIZE/sizeof(int)] IBSS_ATTR; + +static const unsigned char * const mad_synth_thread_name = "mp3dec"; +static unsigned int mad_synth_thread_id = 0; + + +static void mad_synth_thread(void) +{ + while(1) { + ci->semaphore_release(&synth_done_sem); + ci->semaphore_wait(&synth_pending_sem, TIMEOUT_BLOCK); + + if(die) + break; + + mad_synth_frame(&synth, &frame); + } +} + +/* wait for the synth thread to go idle which indicates a PCM frame has been + * synthesized */ +static inline void mad_synth_thread_wait_pcm(void) +{ + ci->semaphore_wait(&synth_done_sem, TIMEOUT_BLOCK); +} + +/* increment the done semaphore - used after a wait for idle to preserve the + * semaphore count */ +static inline void mad_synth_thread_unwait_pcm(void) +{ + ci->semaphore_release(&synth_done_sem); +} + +/* after synth thread has gone idle - switch decoded frames and commence + * synthesis on it */ +static void mad_synth_thread_ready(void) +{ + mad_fixed_t (*temp)[2][36][32]; + + /*circular buffer that holds 2 frames' samples*/ + temp=frame.sbsample; + frame.sbsample = frame.sbsample_prev; + frame.sbsample_prev=temp; + + ci->semaphore_release(&synth_pending_sem); +} + +static bool mad_synth_thread_create(void) +{ + ci->semaphore_init(&synth_done_sem, 1, 0); + ci->semaphore_init(&synth_pending_sem, 1, 0); + + mad_synth_thread_id = ci->create_thread(mad_synth_thread, + mad_synth_thread_stack, + sizeof(mad_synth_thread_stack), 0, + mad_synth_thread_name + IF_PRIO(, PRIORITY_PLAYBACK) + IF_COP(, COP)); + + if (mad_synth_thread_id == 0) + return false; + + return true; +} + +static void mad_synth_thread_quit(void) +{ + /* mop up COP thread */ + die = 1; + ci->semaphore_release(&synth_pending_sem); + ci->thread_wait(mad_synth_thread_id); + ci->commit_discard_dcache(); +} +#else +static inline void mad_synth_thread_ready(void) +{ + mad_synth_frame(&synth, &frame); +} + +static inline bool mad_synth_thread_create(void) +{ + return true; +} + +static inline void mad_synth_thread_quit(void) +{ +} + +static inline void mad_synth_thread_wait_pcm(void) +{ +} + +static inline void mad_synth_thread_unwait_pcm(void) +{ +} +#endif /* MPA_SYNTH_ON_COP */ + +/* this is the codec entry point */ +enum codec_status codec_main(enum codec_entry_call_reason reason) +{ + if (reason == CODEC_LOAD) { + /* Create a decoder instance */ + if (codec_init()) + return CODEC_ERROR; + + ci->configure(DSP_SET_SAMPLE_DEPTH, MAD_F_FRACBITS); + + /* does nothing on 1 processor systems except return true */ + if(!mad_synth_thread_create()) + return CODEC_ERROR; + } + else if (reason == CODEC_UNLOAD) { + /* mop up COP thread - MT only */ + mad_synth_thread_quit(); + } + + return CODEC_OK; +} + +/* this is called for each file to process */ +enum codec_status codec_run(void) +{ + size_t size; + int file_end; + int samples_to_skip; /* samples to skip in total for this file (at start) */ + char *inputbuffer; + int64_t samplesdone; + int stop_skip, start_skip; + int current_stereo_mode = -1; + unsigned long current_frequency = 0; + int framelength; + int padding = MAD_BUFFER_GUARD; /* to help mad decode the last frame */ + intptr_t param; + + /* Reinitializing seems to be necessary to avoid playback quircks when seeking. */ + init_mad(); + + file_end = 0; + + ci->configure(DSP_SWITCH_FREQUENCY, ci->id3->frequency); + current_frequency = ci->id3->frequency; + codec_set_replaygain(ci->id3); + + if (ci->id3->offset) { + ci->seek_buffer(ci->id3->offset); + set_elapsed(ci->id3); + } + else + ci->seek_buffer(ci->id3->first_frame_offset); + + if (ci->id3->lead_trim >= 0 && ci->id3->tail_trim >= 0) { + stop_skip = ci->id3->tail_trim - mpeg_latency[ci->id3->layer]; + if (stop_skip < 0) stop_skip = 0; + start_skip = ci->id3->lead_trim + mpeg_latency[ci->id3->layer]; + } else { + stop_skip = 0; + /* We want to skip this amount anyway */ + start_skip = mpeg_latency[ci->id3->layer]; + } + + /* Libmad will not decode the last frame without 8 bytes of extra padding + in the buffer. So, we can trick libmad into not decoding the last frame + if we are to skip it entirely and then cut the appropriate samples from + final frame that we did decode. Note, if all tags (ID3, APE) are not + properly stripped from the end of the file, this trick will not work. */ + if (stop_skip >= mpeg_framesize[ci->id3->layer]) { + padding = 0; + stop_skip -= mpeg_framesize[ci->id3->layer]; + } else { + padding = MAD_BUFFER_GUARD; + } + + samplesdone = ((int64_t)ci->id3->elapsed) * current_frequency / 1000; + + /* Don't skip any samples unless we start at the beginning. */ + if (samplesdone > 0) + samples_to_skip = 0; + else + samples_to_skip = start_skip; + + framelength = 0; + + /* This is the decoding loop. */ + while (1) { + enum codec_command_action action = ci->get_command(¶m); + + if (action == CODEC_ACTION_HALT) + break; + + if (action == CODEC_ACTION_SEEK_TIME) { + int newpos; + + /*make sure the synth thread is idle before seeking - MT only*/ + mad_synth_thread_wait_pcm(); + mad_synth_thread_unwait_pcm(); + + samplesdone = ((int64_t)param)*current_frequency/1000; + + if (param == 0) { + newpos = ci->id3->first_frame_offset; + samples_to_skip = start_skip; + } else { + newpos = get_file_pos(param); + samples_to_skip = 0; + } + + if (!ci->seek_buffer(newpos)) + { + ci->seek_complete(); + break; + } + + ci->set_elapsed((samplesdone * 1000) / current_frequency); + ci->seek_complete(); + init_mad(); + framelength = 0; + } + + /* Lock buffers */ + if (stream.error == 0) { + inputbuffer = ci->request_buffer(&size, INPUT_CHUNK_SIZE); + if (size == 0 || inputbuffer == NULL) + break; + mad_stream_buffer(&stream, (unsigned char *)inputbuffer, + size + padding); + } + + if (mad_frame_decode(&frame, &stream)) { + if (stream.error == MAD_ERROR_BUFLEN) { + /* This makes the codec support partially corrupted files */ + if (file_end == 30) + break; + + /* Fill the buffer */ + if (stream.next_frame) + ci->advance_buffer(stream.next_frame - stream.buffer); + else + ci->advance_buffer(size); + stream.error = 0; /* Must get new inputbuffer next time */ + file_end++; + continue; + } else if (MAD_RECOVERABLE(stream.error)) { + /* Probably syncing after a seek */ + continue; + } else { + /* Some other unrecoverable error */ + return CODEC_ERROR; + } + } + + /* Do the pcmbuf insert here. Note, this is the PREVIOUS frame's pcm + data (not the one just decoded above). When we exit the decoding + loop we will need to process the final frame that was decoded. */ + mad_synth_thread_wait_pcm(); + + if (framelength > 0) { + + /* In case of a mono file, the second array will be ignored. */ + ci->pcmbuf_insert(&synth.pcm.samples[0][samples_to_skip], + &synth.pcm.samples[1][samples_to_skip], + framelength); + + /* Only skip samples for the first frame added. */ + samples_to_skip = 0; + } + + /* Initiate PCM synthesis on the COP (MT) or perform it here (ST) */ + mad_synth_thread_ready(); + + /* Check if sample rate and stereo settings changed in this frame. */ + if (frame.header.samplerate != current_frequency) { + current_frequency = frame.header.samplerate; + ci->configure(DSP_SWITCH_FREQUENCY, current_frequency); + } + if (MAD_NCHANNELS(&frame.header) == 2) { + if (current_stereo_mode != STEREO_NONINTERLEAVED) { + ci->configure(DSP_SET_STEREO_MODE, STEREO_NONINTERLEAVED); + current_stereo_mode = STEREO_NONINTERLEAVED; + } + } else { + if (current_stereo_mode != STEREO_MONO) { + ci->configure(DSP_SET_STEREO_MODE, STEREO_MONO); + current_stereo_mode = STEREO_MONO; + } + } + + if (stream.next_frame) + ci->advance_buffer(stream.next_frame - stream.buffer); + else + ci->advance_buffer(size); + stream.error = 0; /* Must get new inputbuffer next time */ + file_end = 0; + + framelength = synth.pcm.length - samples_to_skip; + if (framelength < 0) { + framelength = 0; + samples_to_skip -= synth.pcm.length; + } + + samplesdone += framelength; + ci->set_elapsed((samplesdone * 1000) / current_frequency); + } + + /* wait for synth idle - MT only*/ + mad_synth_thread_wait_pcm(); + mad_synth_thread_unwait_pcm(); + + /* Finish the remaining decoded frame. + Cut the required samples from the end. */ + if (framelength > stop_skip){ + ci->pcmbuf_insert(synth.pcm.samples[0], synth.pcm.samples[1], + framelength - stop_skip); + } + + return CODEC_OK; +} diff --git a/lib/rbcodec/codecs/mpc.c b/lib/rbcodec/codecs/mpc.c new file mode 100644 index 0000000000..b2628f988e --- /dev/null +++ b/lib/rbcodec/codecs/mpc.c @@ -0,0 +1,186 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2005 Thom Johansen + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include "codeclib.h" +#include +#include + +CODEC_HEADER + +static MPC_SAMPLE_FORMAT sample_buffer[MPC_DECODER_BUFFER_LENGTH] IBSS_ATTR; + +/* Our implementations of the mpc_reader callback functions. */ +static mpc_int32_t read_impl(mpc_reader *reader, void *ptr, mpc_int32_t size) +{ + (void)reader; + return ((mpc_int32_t)(ci->read_filebuf(ptr, size))); +} + +static mpc_bool_t seek_impl(mpc_reader *reader, mpc_int32_t offset) +{ + (void)reader; + return ci->seek_buffer(offset); +} + +static mpc_int32_t tell_impl(mpc_reader *reader) +{ + (void)reader; + return ci->curpos; +} + +static mpc_int32_t get_size_impl(mpc_reader *reader) +{ + (void)reader; + return ci->filesize; +} + +/* this is the codec entry point */ +enum codec_status codec_main(enum codec_entry_call_reason reason) +{ + if (reason == CODEC_LOAD) { + /* musepack's sample representation is 18.14 + * DSP_SET_SAMPLE_DEPTH = 14 (FRACT) + 16 (NATIVE) - 1 (SIGN) = 29 */ + ci->configure(DSP_SET_SAMPLE_DEPTH, 29); + } + + return CODEC_OK; +} + +/* this is called for each file to process */ +enum codec_status codec_run(void) +{ + mpc_int64_t samplesdone; + uint32_t frequency; /* 0.1 kHz accuracy */ + uint32_t elapsed_time; /* milliseconds */ + uint32_t byterate; /* bytes per second */ + mpc_status status; + mpc_reader reader; + mpc_streaminfo info; + mpc_frame_info frame; + mpc_demux *demux = NULL; + intptr_t param; + + frame.buffer = sample_buffer; + + /* Create a decoder instance */ + reader.read = read_impl; + reader.seek = seek_impl; + reader.tell = tell_impl; + reader.get_size = get_size_impl; + + if (codec_init()) + return CODEC_ERROR; + + /* Prep position */ + ci->seek_buffer(0); + + /* Initialize demux/decoder. */ + demux = mpc_demux_init(&reader); + if (NULL == demux) + return CODEC_ERROR; + + /* Read file's streaminfo data. */ + mpc_demux_get_info(demux, &info); + + byterate = (mpc_uint32_t)(info.average_bitrate) / 8; + frequency = info.sample_freq / 100; /* 0.1 kHz accuracy */ + ci->configure(DSP_SWITCH_FREQUENCY, info.sample_freq); + + /* Remark: rockbox offset is the file offset in bytes. So, estimate the + * sample seek position from the file offset, the sampling frequency and + * the bitrate. As the saved position is exactly calculated the reverse way + * there is no loss of information except rounding. */ + samplesdone = 100 * (((mpc_uint64_t)ci->id3->offset * frequency) / byterate); + + /* Set up digital signal processing for correct number of channels */ + /* NOTE: current musepack format only allows for stereo files + but code is here to handle other configurations anyway */ + if (info.channels == 2) + ci->configure(DSP_SET_STEREO_MODE, STEREO_NONINTERLEAVED); + else if (info.channels == 1) + ci->configure(DSP_SET_STEREO_MODE, STEREO_MONO); + else + return CODEC_ERROR; + + codec_set_replaygain(ci->id3); + + /* Resume to saved sample offset. */ + elapsed_time = 0; + + if (samplesdone > 0) + { + if (mpc_demux_seek_sample(demux, samplesdone) == MPC_STATUS_OK) + { + elapsed_time = (samplesdone*10)/frequency; + } + else + { + samplesdone = 0; + } + } + + ci->set_elapsed(elapsed_time); + + /* This is the decoding loop. */ + do + { + enum codec_command_action action = ci->get_command(¶m); + + if (action == CODEC_ACTION_HALT) + return CODEC_OK; + + /* Complete seek handler. */ + if (action == CODEC_ACTION_SEEK_TIME) + { + mpc_int64_t new_offset = (param/10)*frequency; + if (mpc_demux_seek_sample(demux, new_offset) == MPC_STATUS_OK) + { + samplesdone = new_offset; + } + + elapsed_time = (samplesdone*10)/frequency; + ci->set_elapsed(elapsed_time); + ci->seek_complete(); + } + + /* Decode one frame. */ + status = mpc_demux_decode(demux, &frame); + ci->yield(); + if (frame.bits == -1) + { + /* Decoding error, exit decoding loop. */ + return (status == MPC_STATUS_OK) ? CODEC_OK : CODEC_ERROR; + } + else + { + /* Decoding passed, insert samples to PCM buffer. */ + ci->pcmbuf_insert(frame.buffer, + frame.buffer + MPC_FRAME_LENGTH, + frame.samples); + samplesdone += frame.samples; + elapsed_time = (samplesdone*10)/frequency; + ci->set_elapsed(elapsed_time); + /* Remark: rockbox offset is the file offset in bytes. So estimate + * this offset from the samples, sampling frequency and bitrate */ + ci->set_offset( (samplesdone * byterate)/(frequency*100) ); + } + } while (true); +} diff --git a/lib/rbcodec/codecs/nsf.c b/lib/rbcodec/codecs/nsf.c new file mode 100644 index 0000000000..4c5b37c3fa --- /dev/null +++ b/lib/rbcodec/codecs/nsf.c @@ -0,0 +1,135 @@ + +/* Ripped off from Game_Music_Emu 0.5.2. http://www.slack.net/~ant/ */ + +#define GME_NSF_TYPE + +#include +#include "libgme/nsf_emu.h" + +CODEC_HEADER + +/* Maximum number of bytes to process in one iteration */ +#define CHUNK_SIZE (1024*2) + +static int16_t samples[CHUNK_SIZE] IBSS_ATTR; +static struct Nsf_Emu nsf_emu; + +/****************** rockbox interface ******************/ + +static void set_codec_track(int t, int multitrack) { + Nsf_start_track(&nsf_emu, t); + + /* for REPEAT_ONE we disable track limits */ + if (!ci->loop_track()) { + Track_set_fade(&nsf_emu, Track_length( &nsf_emu, t ) - 4000, 4000); + } + if (multitrack) ci->set_elapsed(t*1000); /* t is track no to display */ + else ci->set_elapsed(0); +} + +/* this is the codec entry point */ +enum codec_status codec_main(enum codec_entry_call_reason reason) +{ + if (reason == CODEC_LOAD) { + /* we only render 16 bits */ + ci->configure(DSP_SET_SAMPLE_DEPTH, 16); + + /* 44 Khz, Interleaved stereo */ + ci->configure(DSP_SET_FREQUENCY, 44100); + ci->configure(DSP_SET_STEREO_MODE, STEREO_INTERLEAVED); + + Nsf_init(&nsf_emu); + Nsf_set_sample_rate(&nsf_emu, 44100); + } + + return CODEC_OK; +} + +/* this is called for each file to process */ +enum codec_status codec_run(void) +{ + blargg_err_t err; + uint8_t *buf; + size_t n; + int track, is_multitrack; + uint32_t elapsed_time; + intptr_t param; + + track = is_multitrack = 0; + elapsed_time = 0; + + DEBUGF("NSF: next_track\n"); + if (codec_init()) { + return CODEC_ERROR; + } + + codec_set_replaygain(ci->id3); + + /* Read the entire file */ + DEBUGF("NSF: request file\n"); + ci->seek_buffer(0); + buf = ci->request_buffer(&n, ci->filesize); + if (!buf || n < (size_t)ci->filesize) { + DEBUGF("NSF: file load failed\n"); + return CODEC_ERROR; + } + + if ((err = Nsf_load_mem(&nsf_emu, buf, ci->filesize))) { + DEBUGF("NSF: Nsf_load_mem failed (%s)\n", err); + return CODEC_ERROR; + } + + /* Update internal track count */ + if (nsf_emu.m3u.size > 0) + nsf_emu.track_count = nsf_emu.m3u.size; + + if (nsf_emu.track_count > 1) is_multitrack = 1; + +next_track: + set_codec_track(track, is_multitrack); + + /* The main decoder loop */ + while (1) { + enum codec_command_action action = ci->get_command(¶m); + + if (action == CODEC_ACTION_HALT) + break; + + if (action == CODEC_ACTION_SEEK_TIME) { + if (is_multitrack) { + track = param/1000; + ci->seek_complete(); + if (track >= nsf_emu.track_count) break; + goto next_track; + } + + ci->set_elapsed(param); + elapsed_time = param; + Track_seek(&nsf_emu, param); + ci->seek_complete(); + + /* Set fade again */ + if (!ci->loop_track()) { + Track_set_fade(&nsf_emu, Track_length( &nsf_emu, track ), 4000); + } + } + + /* Generate audio buffer */ + err = Nsf_play(&nsf_emu, CHUNK_SIZE, samples); + if (err || Track_ended(&nsf_emu)) { + track++; + if (track >= nsf_emu.track_count) break; + goto next_track; + } + + ci->pcmbuf_insert(samples, NULL, CHUNK_SIZE >> 1); + + /* Set elapsed time for one track files */ + if (is_multitrack == 0) { + elapsed_time += (CHUNK_SIZE / 2) * 10 / 441; + ci->set_elapsed(elapsed_time); + } + } + + return CODEC_OK; +} diff --git a/lib/rbcodec/codecs/raac.c b/lib/rbcodec/codecs/raac.c new file mode 100644 index 0000000000..0ef7e715bc --- /dev/null +++ b/lib/rbcodec/codecs/raac.c @@ -0,0 +1,212 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2009 Mohamed Tarek + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include "codeclib.h" +#include "librm/rm.h" +#include "libfaad/common.h" +#include "libfaad/structs.h" +#include "libfaad/decoder.h" +/* rockbox: not used +#include "libfaad/output.h" +*/ + +CODEC_HEADER + +static void init_rm(RMContext *rmctx) +{ + memcpy(rmctx, (void*)(( (intptr_t)ci->id3->id3v2buf + 3 ) &~ 3), sizeof(RMContext)); +} + +static RMContext rmctx; +static RMPacket pkt; + +/* this is the codec entry point */ +enum codec_status codec_main(enum codec_entry_call_reason reason) +{ + if (reason == CODEC_LOAD) { + /* Generic codec initialisation */ + ci->configure(DSP_SET_STEREO_MODE, STEREO_NONINTERLEAVED); + ci->configure(DSP_SET_SAMPLE_DEPTH, 29); + } + + return CODEC_OK; +} + +/* this is called for each file to process */ +enum codec_status codec_run(void) +{ + static NeAACDecFrameInfo frame_info; + NeAACDecHandle decoder; + size_t n; + unsigned int i; + unsigned char* buffer; + int err, consumed, pkt_offset, skipped = 0; + uint32_t s = 0; /* sample rate */ + unsigned char c = 0; /* channels */ + int playback_on = -1; + size_t resume_offset; + intptr_t param; + enum codec_command_action action = CODEC_ACTION_NULL; + + if (codec_init()) { + DEBUGF("FAAD: Codec init error\n"); + return CODEC_ERROR; + } + + resume_offset = ci->id3->offset; + + ci->memset(&rmctx,0,sizeof(RMContext)); + ci->memset(&pkt,0,sizeof(RMPacket)); + + ci->seek_buffer(0); + + init_rm(&rmctx); + ci->configure(DSP_SWITCH_FREQUENCY, ci->id3->frequency); + codec_set_replaygain(ci->id3); + + /* initialise the sound converter */ + decoder = NeAACDecOpen(); + + if (!decoder) { + DEBUGF("FAAD: Decode open error\n"); + return CODEC_ERROR; + } + + NeAACDecConfigurationPtr conf = NeAACDecGetCurrentConfiguration(decoder); + conf->outputFormat = FAAD_FMT_16BIT; /* irrelevant, we don't convert */ + NeAACDecSetConfiguration(decoder, conf); + + decoder->config.defObjectType = rmctx.codec_extradata[0]; + decoder->config.defSampleRate = rmctx.sample_rate; + err = NeAACDecInit(decoder, NULL, 0, &s, &c); + + if (err) { + DEBUGF("FAAD: DecInit: %d, %d\n", err, decoder->object_type); + return CODEC_ERROR; + } + + /* check for a mid-track resume and force a seek time accordingly */ + if(resume_offset > rmctx.data_offset + DATA_HEADER_SIZE) { + resume_offset -= rmctx.data_offset + DATA_HEADER_SIZE; + /* put number of subpackets to skip in resume_offset */ + resume_offset /= (rmctx.block_align + PACKET_HEADER_SIZE); + param = (int)resume_offset * ((rmctx.block_align * 8 * 1000)/rmctx.bit_rate); + action = CODEC_ACTION_SEEK_TIME; + } + ci->set_elapsed(0); + ci->advance_buffer(rmctx.data_offset + DATA_HEADER_SIZE); + + /* The main decoding loop */ + while (1) { + if (action == CODEC_ACTION_NULL) + action = ci->get_command(¶m); + + if (action == CODEC_ACTION_HALT) + break; + + if (action == CODEC_ACTION_SEEK_TIME) { + /* Do not allow seeking beyond the file's length */ + if ((unsigned) param > ci->id3->length) { + ci->set_elapsed(ci->id3->length); + ci->seek_complete(); + break; + } + + ci->seek_buffer(rmctx.data_offset + DATA_HEADER_SIZE); + + /* Seek to the start of the track */ + if (param == 0) { + ci->set_elapsed(0); + ci->seek_complete(); + action = CODEC_ACTION_NULL; + continue; + } + + skipped = 0; + while(1) { + buffer = ci->request_buffer(&n,rmctx.audio_framesize + 1000); + pkt_offset = skipped - pkt.length; + consumed = rm_get_packet(&buffer, &rmctx, &pkt); + if(consumed < 0 && playback_on != 0) { + if(playback_on == -1) { + /* Error only if packet-parsing failed and playback hadn't started */ + DEBUGF("rm_get_packet failed\n"); + ci->seek_complete(); + return CODEC_ERROR; + } + else { + ci->seek_complete(); + return CODEC_OK; + } + } + skipped += pkt.length; + + if(pkt.timestamp > (unsigned)param) + break; + + ci->advance_buffer(pkt.length); + } + ci->seek_buffer(pkt_offset + rmctx.data_offset + DATA_HEADER_SIZE); + buffer = ci->request_buffer(&n,rmctx.audio_framesize + 1000); + NeAACDecPostSeekReset(decoder, decoder->frame); + ci->set_elapsed(pkt.timestamp); + ci->seek_complete(); + } + + action = CODEC_ACTION_NULL; + + /* Request the required number of bytes from the input buffer */ + buffer=ci->request_buffer(&n,rmctx.audio_framesize + 1000); + consumed = rm_get_packet(&buffer, &rmctx, &pkt); + + if(consumed < 0 && playback_on != 0) { + if(playback_on == -1) { + /* Error only if packet-parsing failed and playback hadn't started */ + DEBUGF("rm_get_packet failed\n"); + return CODEC_ERROR; + } + else + break; + } + + playback_on = 1; + if (pkt.timestamp >= ci->id3->length) + break; + + /* Decode one block - returned samples will be host-endian */ + for(i = 0; i < rmctx.sub_packet_cnt; i++) { + NeAACDecDecode(decoder, &frame_info, buffer, rmctx.sub_packet_lengths[i]); + buffer += rmctx.sub_packet_lengths[i]; + if (frame_info.error > 0) { + DEBUGF("FAAD: decode error '%s'\n", NeAACDecGetErrorMessage(frame_info.error)); + return CODEC_ERROR; + } + ci->pcmbuf_insert(decoder->time_out[0], + decoder->time_out[1], + decoder->frameLength); + ci->set_elapsed(pkt.timestamp); + } + + ci->advance_buffer(pkt.length); + } + + return CODEC_OK; +} diff --git a/lib/rbcodec/codecs/sgc.c b/lib/rbcodec/codecs/sgc.c new file mode 100644 index 0000000000..348a54a2d3 --- /dev/null +++ b/lib/rbcodec/codecs/sgc.c @@ -0,0 +1,123 @@ + +/* Ripped off from Game_Music_Emu 0.5.2. http://www.slack.net/~ant/ */ + +#include +#include "libgme/sgc_emu.h" + +CODEC_HEADER + +/* Maximum number of bytes to process in one iteration */ +#define CHUNK_SIZE (1024*2) + +static int16_t samples[CHUNK_SIZE] IBSS_ATTR; +static struct Sgc_Emu sgc_emu; + +/* Coleco Bios */ +/* Colecovision not supported yet +static char coleco_bios[0x2000]; +*/ + +/****************** rockbox interface ******************/ + +static void set_codec_track(int t) { + Sgc_start_track(&sgc_emu, t); + + /* for REPEAT_ONE we disable track limits */ + if (!ci->loop_track()) { + Track_set_fade(&sgc_emu, Track_get_length( &sgc_emu, t ), 4000); + } + ci->set_elapsed(t*1000); /* t is track no to display */ +} + +/* this is the codec entry point */ +enum codec_status codec_main(enum codec_entry_call_reason reason) +{ + if (reason == CODEC_LOAD) { + /* we only render 16 bits */ + ci->configure(DSP_SET_SAMPLE_DEPTH, 16); + + /* 44 Khz, Interleaved stereo */ + ci->configure(DSP_SET_FREQUENCY, 44100); + ci->configure(DSP_SET_STEREO_MODE, STEREO_INTERLEAVED); + + Sgc_init(&sgc_emu); + Sgc_set_sample_rate(&sgc_emu, 44100); + + /* set coleco bios, should be named coleco_bios.rom */ + /* Colecovision not supported yet + int fd = ci->open("/coleco_bios.rom", O_RDONLY); + if ( fd >= 0 ) { + ci->read(fd, coleco_bios, 0x2000); + ci->close(fd); + set_coleco_bios( &sgc_emu, coleco_bios ); + } + */ + } + + return CODEC_OK; +} + +/* this is called for each file to process */ +enum codec_status codec_run(void) +{ + blargg_err_t err; + uint8_t *buf; + size_t n; + intptr_t param; + int track = 0; + + DEBUGF("SGC: next_track\n"); + if (codec_init()) { + return CODEC_ERROR; + } + + codec_set_replaygain(ci->id3); + + /* Read the entire file */ + DEBUGF("SGC: request file\n"); + ci->seek_buffer(0); + buf = ci->request_buffer(&n, ci->filesize); + if (!buf || n < (size_t)ci->filesize) { + DEBUGF("SGC: file load failed\n"); + return CODEC_ERROR; + } + + if ((err = Sgc_load_mem(&sgc_emu, buf, ci->filesize))) { + DEBUGF("SGC: Sgc_load_mem failed (%s)\n", err); + return CODEC_ERROR; + } + + /* Update internal track count */ + if (sgc_emu.m3u.size > 0) + sgc_emu.track_count = sgc_emu.m3u.size; + +next_track: + set_codec_track(track); + + /* The main decoder loop */ + while (1) { + enum codec_command_action action = ci->get_command(¶m); + + if (action == CODEC_ACTION_HALT) + break; + + if (action == CODEC_ACTION_SEEK_TIME) { + track = param/1000; + ci->seek_complete(); + if (track >= sgc_emu.track_count) break; + goto next_track; + } + + /* Generate audio buffer */ + err = Sgc_play(&sgc_emu, CHUNK_SIZE, samples); + if (err || Track_ended(&sgc_emu)) { + track++; + if (track >= sgc_emu.track_count) break; + goto next_track; + } + + ci->pcmbuf_insert(samples, NULL, CHUNK_SIZE >> 1); + } + + return CODEC_OK; +} diff --git a/lib/rbcodec/codecs/shorten.c b/lib/rbcodec/codecs/shorten.c new file mode 100644 index 0000000000..a8ab3f30a0 --- /dev/null +++ b/lib/rbcodec/codecs/shorten.c @@ -0,0 +1,164 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id: + * + * Copyright (C) 2005 Mark Arigo + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include "codeclib.h" +#include + +CODEC_HEADER + +#ifndef IBSS_ATTR_SHORTEN_DECODED0 +#define IBSS_ATTR_SHORTEN_DECODED0 IBSS_ATTR +#endif + +static int32_t decoded0[MAX_DECODE_SIZE] IBSS_ATTR_SHORTEN_DECODED0; +static int32_t decoded1[MAX_DECODE_SIZE] IBSS_ATTR; + +static int32_t offset0[MAX_OFFSET_SIZE] IBSS_ATTR; +static int32_t offset1[MAX_OFFSET_SIZE] IBSS_ATTR; + +static int8_t ibuf[MAX_BUFFER_SIZE] IBSS_ATTR; + +/* this is the codec entry point */ +enum codec_status codec_main(enum codec_entry_call_reason reason) +{ + if (reason == CODEC_LOAD) { + /* Generic codec initialisation */ + ci->configure(DSP_SET_STEREO_MODE, STEREO_NONINTERLEAVED); + ci->configure(DSP_SET_SAMPLE_DEPTH, SHN_OUTPUT_DEPTH-1); + } + + return CODEC_OK; +} + +/* this is called for each file to process */ +enum codec_status codec_run(void) +{ + ShortenContext sc; + uint32_t samplesdone; + uint32_t elapsedtime; + int8_t *buf; + int consumed, res, nsamples; + size_t bytesleft; + intptr_t param; + + /* Codec initialization */ + if (codec_init()) { + LOGF("Shorten: codec_init error\n"); + return CODEC_ERROR; + } + + codec_set_replaygain(ci->id3); + + /* Shorten decoder initialization */ + ci->memset(&sc, 0, sizeof(ShortenContext)); + + /* Skip id3v2 tags */ + ci->seek_buffer(ci->id3->first_frame_offset); + + /* Read the shorten & wave headers */ + buf = ci->request_buffer(&bytesleft, MAX_HEADER_SIZE); + res = shorten_init(&sc, (unsigned char *)buf, bytesleft); + if (res < 0) { + LOGF("Shorten: shorten_init error: %d\n", res); + return CODEC_ERROR; + } + + ci->id3->frequency = sc.sample_rate; + ci->configure(DSP_SWITCH_FREQUENCY, sc.sample_rate); + + if (sc.sample_rate) { + ci->id3->length = (sc.totalsamples / sc.sample_rate) * 1000; + } else { + ci->id3->length = 0; + } + + if (ci->id3->length) { + ci->id3->bitrate = (ci->id3->filesize * 8) / ci->id3->length; + } + + consumed = sc.gb.index/8; + ci->advance_buffer(consumed); + sc.bitindex = sc.gb.index - 8*consumed; + +seek_start: + ci->set_elapsed(0); + + /* The main decoding loop */ + ci->memset(&decoded0, 0, sizeof(int32_t)*MAX_DECODE_SIZE); + ci->memset(&decoded1, 0, sizeof(int32_t)*MAX_DECODE_SIZE); + ci->memset(&offset0, 0, sizeof(int32_t)*MAX_OFFSET_SIZE); + ci->memset(&offset1, 0, sizeof(int32_t)*MAX_OFFSET_SIZE); + + samplesdone = 0; + buf = ci->request_buffer(&bytesleft, MAX_BUFFER_SIZE); + while (bytesleft) { + enum codec_command_action action = ci->get_command(¶m); + + if (action == CODEC_ACTION_HALT) + break; + + /* Seek to start of track */ + if (action == CODEC_ACTION_SEEK_TIME) { + if (param == 0 && + ci->seek_buffer(sc.header_bits/8 + ci->id3->first_frame_offset)) { + sc.bitindex = sc.header_bits - 8*(sc.header_bits/8); + ci->seek_complete(); + goto seek_start; + } + ci->seek_complete(); + } + + /* Decode a frame */ + ci->memcpy(ibuf, buf, bytesleft); /* copy buf to iram */ + res = shorten_decode_frames(&sc, &nsamples, decoded0, decoded1, + offset0, offset1, (unsigned char *)ibuf, + bytesleft, ci->yield); + + if (res == FN_ERROR) { + LOGF("Shorten: shorten_decode_frames error (%lu)\n", + (unsigned long)samplesdone); + return CODEC_ERROR; + } else { + /* Insert decoded samples in pcmbuf */ + if (nsamples) { + ci->yield(); + ci->pcmbuf_insert(decoded0 + sc.nwrap, decoded1 + sc.nwrap, + nsamples); + + /* Update the elapsed-time indicator */ + samplesdone += nsamples; + elapsedtime = (samplesdone*10) / (sc.sample_rate/100); + ci->set_elapsed(elapsedtime); + } + + /* End of shorten stream...go to next track */ + if (res == FN_QUIT) + break; + } + + consumed = sc.gb.index/8; + ci->advance_buffer(consumed); + buf = ci->request_buffer(&bytesleft, MAX_BUFFER_SIZE); + sc.bitindex = sc.gb.index - 8*consumed; + } + + return CODEC_OK; +} diff --git a/lib/rbcodec/codecs/sid.c b/lib/rbcodec/codecs/sid.c new file mode 100644 index 0000000000..9b19a20ba7 --- /dev/null +++ b/lib/rbcodec/codecs/sid.c @@ -0,0 +1,1340 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * SID Codec for rockbox based on the TinySID engine + * + * Written by Tammo Hinrichs (kb) and Rainer Sinsch in 1998-1999 + * Ported to rockbox on 14 April 2006 + * + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + + /***************************** + * kb explicitly points out that this emulation sounds crappy, though + * we decided to put it open source so everyone can enjoy sidmusic + * on rockbox + * + *****************************/ + + /********************* + * v1.1 + * Added 16-04-2006: Rainer Sinsch + * Removed all time critical floating point operations and + * replaced them with quick & dirty integer calculations + * + * Added 17-04-2006: Rainer Sinsch + * Improved quick & dirty integer calculations for the resonant filter + * Improved audio quality by 4 bits + * + * v1.2 + * Added 17-04-2006: Dave Chapman + * Improved file loading + * + * Added 17-04-2006: Rainer Sinsch + * Added sample routines + * Added cia timing routines + * Added fast forwarding capabilities + * Corrected bug in sid loading + * + * v1.2.1 + * Added 04-05-2006: Rainer Sinsch + * Implemented Marco Alanens suggestion for subsong selection: + * Select the subsong by seeking: Each second represents a subsong + * + **************************/ + +#define USE_FILTER + +#include "debug.h" +#include "codeclib.h" +#include + +CODEC_HEADER + +#define CHUNK_SIZE (1024*2) +#define SID_BUFFER_SIZE 0x10000 +#define SAMPLE_RATE 44100 + +/* This codec supports SID Files: + * + */ + +static int32_t samples[CHUNK_SIZE] IBSS_ATTR; /* The sample buffer */ + +void sidPoke(int reg, unsigned char val) ICODE_ATTR; + +#define FLAG_N 128 +#define FLAG_V 64 +#define FLAG_B 16 +#define FLAG_D 8 +#define FLAG_I 4 +#define FLAG_Z 2 +#define FLAG_C 1 + +#define imp 0 +#define imm 1 +#define _abs 2 +#define absx 3 +#define absy 4 +#define zp 6 +#define zpx 7 +#define zpy 8 +#define ind 9 +#define indx 10 +#define indy 11 +#define acc 12 +#define rel 13 + +enum { + adc, _and, asl, bcc, bcs, beq, bit, bmi, bne, bpl, _brk, bvc, bvs, clc, + cld, cli, clv, cmp, cpx, cpy, dec, dex, dey, eor, inc, inx, iny, jmp, + jsr, lda, ldx, ldy, lsr, _nop, ora, pha, php, pla, plp, rol, ror, rti, + rts, sbc, sec, sed, sei, sta, stx, sty, tax, tay, tsx, txa, txs, tya, + xxx +}; + +/* SID register definition */ +struct s6581 { + struct sidvoice { + unsigned short freq; + unsigned short pulse; + unsigned char wave; + unsigned char ad; + unsigned char sr; + } v[3]; + unsigned char ffreqlo; + unsigned char ffreqhi; + unsigned char res_ftv; + unsigned char ftp_vol; +}; + +/* internal oscillator def */ +struct sidosc { + unsigned long freq; + unsigned long pulse; + unsigned char wave; + unsigned char filter; + unsigned long attack; + unsigned long decay; + unsigned long sustain; + unsigned long release; + unsigned long counter; + signed long envval; + unsigned char envphase; + unsigned long noisepos; + unsigned long noiseval; + unsigned char noiseout; +}; + +/* internal filter def */ +struct sidflt { + int freq; + unsigned char l_ena; + unsigned char b_ena; + unsigned char h_ena; + unsigned char v3ena; + int vol; + int rez; + int h; + int b; + int l; +}; + +/* ------------------------ pseudo-constants (depending on mixing freq) */ +int mixing_frequency IDATA_ATTR; +unsigned long freqmul IDATA_ATTR; +int filtmul IDATA_ATTR; +#ifndef ROCKBOX +unsigned long attacks [16] IDATA_ATTR; +unsigned long releases[16] IDATA_ATTR; +#endif + +/* ------------------------------------------------------------ globals */ +struct s6581 sid IDATA_ATTR; +struct sidosc osc[3] IDATA_ATTR; +struct sidflt filter IDATA_ATTR; + +/* ------------------------------------------------------ C64 Emu Stuff */ +unsigned char bval IDATA_ATTR; +unsigned short wval IDATA_ATTR; +/* -------------------------------------------------- Register & memory */ +unsigned char a,x,y,s,p IDATA_ATTR; +unsigned short pc IDATA_ATTR; + +unsigned char memory[65536]; + +/* ----------------------------------------- Variables for sample stuff */ +static int sample_active IDATA_ATTR; +static int sample_position, sample_start, sample_end, sample_repeat_start IDATA_ATTR; +static int fracPos IDATA_ATTR; /* Fractal position of sample */ +static int sample_period IDATA_ATTR; +static int sample_repeats IDATA_ATTR; +static int sample_order IDATA_ATTR; +static int sample_nibble IDATA_ATTR; + +static int internal_period, internal_order, internal_start, internal_end, + internal_add, internal_repeat_times, internal_repeat_start IDATA_ATTR; + +/* ---------------------------------------------------------- constants */ +#ifndef ROCKBOX +static const float attackTimes[16] ICONST_ATTR = +{ + 0.0022528606, 0.0080099577, 0.0157696042, 0.0237795619, + 0.0372963655, 0.0550684591, 0.0668330845, 0.0783473987, + 0.0981219818, 0.244554021, 0.489108042, 0.782472742, + 0.977715461, 2.93364701, 4.88907793, 7.82272493 +}; +static const float decayReleaseTimes[16] ICONST_ATTR = +{ + 0.00891777693, 0.024594051, 0.0484185907, 0.0730116639, 0.114512475, + 0.169078356, 0.205199432, 0.240551975, 0.301266125, 0.750858245, + 1.50171551, 2.40243682, 3.00189298, 9.00721405, 15.010998, 24.0182111 +}; +#else +#define DIV(X) ((int)(0x1000000 / (X * SAMPLE_RATE))) +static const unsigned long attacks[16] ICONST_ATTR = +{ + DIV(0.0022528606), DIV(0.0080099577), DIV(0.0157696042), DIV(0.0237795619), + DIV(0.0372963655), DIV(0.0550684591), DIV(0.0668330845), DIV(0.0783473987), + DIV(0.0981219818), DIV(0.2445540210), DIV(0.4891080420), DIV(0.7824727420), + DIV(0.9777154610), DIV(2.9336470100), DIV(4.8890779300), DIV(7.8227249300) +}; +static const unsigned long releases[16] ICONST_ATTR = +{ + DIV(0.00891777693), DIV(0.0245940510), DIV(0.0484185907), DIV(0.0730116639), + DIV(0.11451247500), DIV(0.1690783560), DIV(0.2051994320), DIV(0.2405519750), + DIV(0.30126612500), DIV(0.7508582450), DIV(1.5017155100), DIV(2.4024368200), + DIV(3.00189298000), DIV(9.0072140500), DIV(15.010998000), DIV(24.018211100) +}; +#endif +static const int opcodes[256] ICONST_ATTR = { + _brk,ora,xxx,xxx,xxx,ora,asl,xxx,php,ora,asl,xxx,xxx,ora,asl,xxx, + bpl,ora,xxx,xxx,xxx,ora,asl,xxx,clc,ora,xxx,xxx,xxx,ora,asl,xxx, + jsr,_and,xxx,xxx,bit,_and,rol,xxx,plp,_and,rol,xxx,bit,_and,rol,xxx, + bmi,_and,xxx,xxx,xxx,_and,rol,xxx,sec,_and,xxx,xxx,xxx,_and,rol,xxx, + rti,eor,xxx,xxx,xxx,eor,lsr,xxx,pha,eor,lsr,xxx,jmp,eor,lsr,xxx, + bvc,eor,xxx,xxx,xxx,eor,lsr,xxx,cli,eor,xxx,xxx,xxx,eor,lsr,xxx, + rts,adc,xxx,xxx,xxx,adc,ror,xxx,pla,adc,ror,xxx,jmp,adc,ror,xxx, + bvs,adc,xxx,xxx,xxx,adc,ror,xxx,sei,adc,xxx,xxx,xxx,adc,ror,xxx, + xxx,sta,xxx,xxx,sty,sta,stx,xxx,dey,xxx,txa,xxx,sty,sta,stx,xxx, + bcc,sta,xxx,xxx,sty,sta,stx,xxx,tya,sta,txs,xxx,xxx,sta,xxx,xxx, + ldy,lda,ldx,xxx,ldy,lda,ldx,xxx,tay,lda,tax,xxx,ldy,lda,ldx,xxx, + bcs,lda,xxx,xxx,ldy,lda,ldx,xxx,clv,lda,tsx,xxx,ldy,lda,ldx,xxx, + cpy,cmp,xxx,xxx,cpy,cmp,dec,xxx,iny,cmp,dex,xxx,cpy,cmp,dec,xxx, + bne,cmp,xxx,xxx,xxx,cmp,dec,xxx,cld,cmp,xxx,xxx,xxx,cmp,dec,xxx, + cpx,sbc,xxx,xxx,cpx,sbc,inc,xxx,inx,sbc,_nop,xxx,cpx,sbc,inc,xxx, + beq,sbc,xxx,xxx,xxx,sbc,inc,xxx,sed,sbc,xxx,xxx,xxx,sbc,inc,xxx +}; + + +static const int modes[256] ICONST_ATTR = { + imp,indx,xxx,xxx,zp,zp,zp,xxx,imp,imm,acc,xxx,_abs,_abs,_abs,xxx, + rel,indy,xxx,xxx,xxx,zpx,zpx,xxx,imp,absy,xxx,xxx,xxx,absx,absx,xxx, + _abs,indx,xxx,xxx,zp,zp,zp,xxx,imp,imm,acc,xxx,_abs,_abs,_abs,xxx, + rel,indy,xxx,xxx,xxx,zpx,zpx,xxx,imp,absy,xxx,xxx,xxx,absx,absx,xxx, + imp,indx,xxx,xxx,zp,zp,zp,xxx,imp,imm,acc,xxx,_abs,_abs,_abs,xxx, + rel,indy,xxx,xxx,xxx,zpx,zpx,xxx,imp,absy,xxx,xxx,xxx,absx,absx,xxx, + imp,indx,xxx,xxx,zp,zp,zp,xxx,imp,imm,acc,xxx,ind,_abs,_abs,xxx, + rel,indy,xxx,xxx,xxx,zpx,zpx,xxx,imp,absy,xxx,xxx,xxx,absx,absx,xxx, + imm,indx,xxx,xxx,zp,zp,zp,xxx,imp,imm,acc,xxx,_abs,_abs,_abs,xxx, + rel,indy,xxx,xxx,zpx,zpx,zpy,xxx,imp,absy,acc,xxx,xxx,absx,absx,xxx, + imm,indx,imm,xxx,zp,zp,zp,xxx,imp,imm,acc,xxx,_abs,_abs,_abs,xxx, + rel,indy,xxx,xxx,zpx,zpx,zpy,xxx,imp,absy,acc,xxx,absx,absx,absy,xxx, + imm,indx,xxx,xxx,zp,zp,zp,xxx,imp,imm,acc,xxx,_abs,_abs,_abs,xxx, + rel,indy,xxx,xxx,zpx,zpx,zpx,xxx,imp,absy,acc,xxx,xxx,absx,absx,xxx, + imm,indx,xxx,xxx,zp,zp,zp,xxx,imp,imm,acc,xxx,_abs,_abs,_abs,xxx, + rel,indy,xxx,xxx,zpx,zpx,zpx,xxx,imp,absy,acc,xxx,xxx,absx,absx,xxx +}; + +/* Routines for quick & dirty float calculation */ + +static inline int quickfloat_ConvertFromInt(int i) +{ + return (i<<16); +} +#ifndef ROCKBOX +static inline int quickfloat_ConvertFromFloat(float f) +{ + return (int)(f*(1<<16)); +} +#else +#define quickfloat_ConvertFromFloat(X) (int)(X*(1<<16)) +#endif +static inline int quickfloat_Multiply(int a, int b) +{ + return (a>>8)*(b>>8); +} +static inline int quickfloat_ConvertToInt(int i) +{ + return (i>>16); +} + +/* Get the bit from an unsigned long at a specified position */ +static inline unsigned char get_bit(unsigned long val, unsigned char b) +{ + return (unsigned char) ((val >> b) & 1); +} + + +static inline int GenerateDigi(int sIn) +{ + static int sample = 0; + + if (!sample_active) return(sIn); + + if ((sample_position < sample_end) && (sample_position >= sample_start)) + { + sIn += sample; + + fracPos += 985248/sample_period; + + if (fracPos > mixing_frequency) + { + fracPos%=mixing_frequency; + + // N�hstes Samples holen + if (sample_order == 0) { + sample_nibble++; // Nähstes Sample-Nibble + if (sample_nibble==2) { + sample_nibble = 0; + sample_position++; + } + } + else { + sample_nibble--; + if (sample_nibble < 0) { + sample_nibble=1; + sample_position++; + } + } + if (sample_repeats) + { + if (sample_position > sample_end) + { + sample_repeats--; + sample_position = sample_repeat_start; + } + else sample_active = 0; + } + + sample = memory[sample_position&0xffff]; + if (sample_nibble==1) // Hi-Nibble holen? + sample = (sample & 0xf0)>>4; + else sample = sample & 0x0f; + + sample -= 7; + sample <<= 10; + } + } + + return (sIn); +} + +/* ------------------------------------------------------------- synthesis + initialize SID and frequency dependant values */ +void synth_init(unsigned long mixfrq) ICODE_ATTR; +void synth_init(unsigned long mixfrq) +{ +#ifndef ROCKBOX + int i; +#endif + mixing_frequency = mixfrq; + fracPos = 0; + freqmul = 15872000 / mixfrq; + filtmul = quickfloat_ConvertFromFloat(21.5332031f)/mixfrq; +#ifndef ROCKBOX + for (i=0;i<16;i++) { + attacks [i]=(int) (0x1000000 / (attackTimes[i]*mixfrq)); + releases[i]=(int) (0x1000000 / (decayReleaseTimes[i]*mixfrq)); + } +#endif + memset(&sid,0,sizeof(sid)); + memset(osc,0,sizeof(osc)); + memset(&filter,0,sizeof(filter)); + osc[0].noiseval = 0xffffff; + osc[1].noiseval = 0xffffff; + osc[2].noiseval = 0xffffff; +} + +/* render a buffer of n samples with the actual register contents */ +void synth_render (int32_t *buffer, unsigned long len) ICODE_ATTR; +void synth_render (int32_t *buffer, unsigned long len) +{ + unsigned long bp; + /* step 1: convert the not easily processable sid registers into some + more convenient and fast values (makes the thing much faster + if you process more than 1 sample value at once) */ + unsigned char v; + for (v=0;v<3;v++) { + osc[v].pulse = (sid.v[v].pulse & 0xfff) << 16; + osc[v].filter = get_bit(sid.res_ftv,v); + osc[v].attack = attacks[sid.v[v].ad >> 4]; + osc[v].decay = releases[sid.v[v].ad & 0xf]; + osc[v].sustain = sid.v[v].sr & 0xf0; + osc[v].release = releases[sid.v[v].sr & 0xf]; + osc[v].wave = sid.v[v].wave; + osc[v].freq = ((unsigned long)sid.v[v].freq)*freqmul; + } + +#ifdef USE_FILTER + filter.freq = (16*sid.ffreqhi + (sid.ffreqlo&0x7)) * filtmul; + + if (filter.freq>quickfloat_ConvertFromInt(1)) + filter.freq=quickfloat_ConvertFromInt(1); + /* the above line isnt correct at all - the problem is that the filter + works only up to rmxfreq/4 - this is sufficient for 44KHz but isnt + for 32KHz and lower - well, but sound quality is bad enough then to + neglect the fact that the filter doesnt come that high ;) */ + filter.l_ena = get_bit(sid.ftp_vol,4); + filter.b_ena = get_bit(sid.ftp_vol,5); + filter.h_ena = get_bit(sid.ftp_vol,6); + filter.v3ena = !get_bit(sid.ftp_vol,7); + filter.vol = (sid.ftp_vol & 0xf); + filter.rez = quickfloat_ConvertFromFloat(1.2f) - + quickfloat_ConvertFromFloat(0.04f)*(sid.res_ftv >> 4); + + /* We precalculate part of the quick float operation, saves time in loop later */ + filter.rez>>=8; +#endif + + + /* now render the buffer */ + for (bp=0;bp>19); + if (osc[v].counter>>27) + triout^=0xff; + unsigned char sawout = (unsigned char) (osc[v].counter >> 20); + unsigned char plsout = (unsigned char) ((osc[v].counter > osc[v].pulse)-1); + + /* generate noise waveform exactly as the SID does. */ + if (osc[v].noisepos!=(osc[v].counter>>23)) + { + osc[v].noisepos = osc[v].counter >> 23; + osc[v].noiseval = (osc[v].noiseval << 1) | + (get_bit(osc[v].noiseval,22) ^ get_bit(osc[v].noiseval,17)); + osc[v].noiseout = (get_bit(osc[v].noiseval,22) << 7) | + (get_bit(osc[v].noiseval,20) << 6) | + (get_bit(osc[v].noiseval,16) << 5) | + (get_bit(osc[v].noiseval,13) << 4) | + (get_bit(osc[v].noiseval,11) << 3) | + (get_bit(osc[v].noiseval, 7) << 2) | + (get_bit(osc[v].noiseval, 4) << 1) | + (get_bit(osc[v].noiseval, 2) << 0); + } + unsigned char nseout = osc[v].noiseout; + + /* modulate triangle wave if ringmod bit set */ + if (osc[v].wave & 0x04) + if (osc[refosc].counter < 0x8000000) + triout ^= 0xff; + + /* now mix the oscillators with an AND operation as stated in + the SID's reference manual - even if this is completely wrong. + well, at least, the $30 and $70 waveform sounds correct and there's + no real solution to do $50 and $60, so who cares. */ + + unsigned char outv=0xFF; + if (osc[v].wave & 0x10) outv &= triout; + if (osc[v].wave & 0x20) outv &= sawout; + if (osc[v].wave & 0x40) outv &= plsout; + if (osc[v].wave & 0x80) outv &= nseout; + + /* so now process the volume according to the phase and adsr values */ + switch (osc[v].envphase) { + case 0 : { /* Phase 0 : Attack */ + osc[v].envval+=osc[v].attack; + if (osc[v].envval >= 0xFFFFFF) + { + osc[v].envval = 0xFFFFFF; + osc[v].envphase = 1; + } + break; + } + case 1 : { /* Phase 1 : Decay */ + osc[v].envval-=osc[v].decay; + if ((signed int) osc[v].envval <= (signed int) (osc[v].sustain<<16)) + { + osc[v].envval = osc[v].sustain<<16; + osc[v].envphase = 2; + } + break; + } + case 2 : { /* Phase 2 : Sustain */ + if ((signed int) osc[v].envval != (signed int) (osc[v].sustain<<16)) + { + osc[v].envphase = 1; + } + /* :) yes, thats exactly how the SID works. and maybe + a music routine out there supports this, so better + let it in, thanks :) */ + break; + } + case 3 : { /* Phase 3 : Release */ + osc[v].envval-=osc[v].release; + if (osc[v].envval < 0x40000) osc[v].envval= 0x40000; + + /* the volume offset is because the SID does not + completely silence the voices when it should. most + emulators do so though and thats the main reason + why the sound of emulators is too, err... emulated :) */ + break; + } + } + +#ifdef USE_FILTER + + /* now route the voice output to either the non-filtered or the + filtered channel and dont forget to blank out osc3 if desired */ + + if (v<2 || filter.v3ena) + { + if (osc[v].filter) + outf+=(((int)(outv-0x80))*osc[v].envval)>>22; + else + outo+=(((int)(outv-0x80))*osc[v].envval)>>22; + } +#endif +#ifndef USE_FILTER + /* Don't use filters, just mix all voices together */ + outf+=((signed short)(outv-0x80)) * (osc[v].envval>>4); +#endif + } + + +#ifdef USE_FILTER + /* step 3 + * so, now theres finally time to apply the multi-mode resonant filter + * to the signal. The easiest thing ist just modelling a real electronic + * filter circuit instead of fiddling around with complex IIRs or even + * FIRs ... + * it sounds as good as them or maybe better and needs only 3 MULs and + * 4 ADDs for EVERYTHING. SIDPlay uses this kind of filter, too, but + * Mage messed the whole thing completely up - as the rest of the + * emulator. + * This filter sounds a lot like the 8580, as the low-quality, dirty + * sound of the 6581 is uuh too hard to achieve :) */ + + filter.h = quickfloat_ConvertFromInt(outf) - (filter.b>>8)*filter.rez - filter.l; + filter.b += quickfloat_Multiply(filter.freq, filter.h); + filter.l += quickfloat_Multiply(filter.freq, filter.b); + + outf = 0; + + if (filter.l_ena) outf+=quickfloat_ConvertToInt(filter.l); + if (filter.b_ena) outf+=quickfloat_ConvertToInt(filter.b); + if (filter.h_ena) outf+=quickfloat_ConvertToInt(filter.h); + + int final_sample = (filter.vol*(outo+outf)); + *(buffer+bp)= GenerateDigi(final_sample)<<13; +#endif +#ifndef USE_FILTER + *(buffer+bp) = GenerateDigi(outf)<<3; +#endif + } +} + + + +/* +* C64 Mem Routines +*/ +static inline unsigned char getmem(unsigned short addr) +{ + return memory[addr]; +} + +static inline void setmem(unsigned short addr, unsigned char value) +{ + if ((addr&0xfc00)==0xd400) + { + sidPoke(addr&0x1f,value); + /* New SID-Register */ + if (addr > 0xd418) + { + switch (addr) + { + case 0xd41f: /* Start-Hi */ + internal_start = (internal_start&0x00ff) | (value<<8); break; + case 0xd41e: /* Start-Lo */ + internal_start = (internal_start&0xff00) | (value); break; + case 0xd47f: /* Repeat-Hi */ + internal_repeat_start = (internal_repeat_start&0x00ff) | (value<<8); break; + case 0xd47e: /* Repeat-Lo */ + internal_repeat_start = (internal_repeat_start&0xff00) | (value); break; + case 0xd43e: /* End-Hi */ + internal_end = (internal_end&0x00ff) | (value<<8); break; + case 0xd43d: /* End-Lo */ + internal_end = (internal_end&0xff00) | (value); break; + case 0xd43f: /* Loop-Size */ + internal_repeat_times = value; break; + case 0xd45e: /* Period-Hi */ + internal_period = (internal_period&0x00ff) | (value<<8); break; + case 0xd45d: /* Period-Lo */ + internal_period = (internal_period&0xff00) | (value); break; + case 0xd47d: /* Sample Order */ + internal_order = value; break; + case 0xd45f: /* Sample Add */ + internal_add = value; break; + case 0xd41d: /* Start sampling */ + sample_repeats = internal_repeat_times; + sample_position = internal_start; + sample_start = internal_start; + sample_end = internal_end; + sample_repeat_start = internal_repeat_start; + sample_period = internal_period; + sample_order = internal_order; + switch (value) + { + case 0xfd: sample_active = 0; break; + case 0xfe: + case 0xff: sample_active = 1; break; + default: return; + } + break; + } + } + } + else memory[addr]=value; +} + +/* +* Poke a value into the sid register +*/ +void sidPoke(int reg, unsigned char val) ICODE_ATTR; +void sidPoke(int reg, unsigned char val) +{ + int voice=0; + + if ((reg >= 7) && (reg <=13)) {voice=1; reg-=7;} + else if ((reg >= 14) && (reg <=20)) {voice=2; reg-=14;} + + switch (reg) { + case 0: { /* Set frequency: Low byte */ + sid.v[voice].freq = (sid.v[voice].freq&0xff00)+val; + break; + } + case 1: { /* Set frequency: High byte */ + sid.v[voice].freq = (sid.v[voice].freq&0xff)+(val<<8); + break; + } + case 2: { /* Set pulse width: Low byte */ + sid.v[voice].pulse = (sid.v[voice].pulse&0xff00)+val; + break; + } + case 3: { /* Set pulse width: High byte */ + sid.v[voice].pulse = (sid.v[voice].pulse&0xff)+(val<<8); + break; + } + case 4: { sid.v[voice].wave = val; + /* Directly look at GATE-Bit! + * a change may happen twice or more often during one cpujsr + * Put the Envelope Generator into attack or release phase if desired + */ + if ((val & 0x01) == 0) osc[voice].envphase=3; + else if (osc[voice].envphase==3) osc[voice].envphase=0; + break; + } + + case 5: { sid.v[voice].ad = val; break;} + case 6: { sid.v[voice].sr = val; break;} + + case 21: { sid.ffreqlo = val; break; } + case 22: { sid.ffreqhi = val; break; } + case 23: { sid.res_ftv = val; break; } + case 24: { sid.ftp_vol = val; break;} + } + return; +} + +static inline unsigned char getaddr(int mode) +{ + unsigned short ad,ad2; + switch(mode) + { + case imp: + return 0; + case imm: + return getmem(pc++); + case _abs: + ad=getmem(pc++); + ad|=256*getmem(pc++); + return getmem(ad); + case absx: + ad=getmem(pc++); + ad|=256*getmem(pc++); + ad2=ad+x; + return getmem(ad2); + case absy: + ad=getmem(pc++); + ad|=256*getmem(pc++); + ad2=ad+y; + return getmem(ad2); + case zp: + ad=getmem(pc++); + return getmem(ad); + case zpx: + ad=getmem(pc++); + ad+=x; + return getmem(ad&0xff); + case zpy: + ad=getmem(pc++); + ad+=y; + return getmem(ad&0xff); + case indx: + ad=getmem(pc++); + ad+=x; + ad2=getmem(ad&0xff); + ad++; + ad2|=getmem(ad&0xff)<<8; + return getmem(ad2); + case indy: + ad=getmem(pc++); + ad2=getmem(ad); + ad2|=getmem((ad+1)&0xff)<<8; + ad=ad2+y; + return getmem(ad); + case acc: + return a; + } + return 0; +} + +static inline void setaddr(int mode, unsigned char val) +{ + unsigned short ad,ad2; + switch(mode) + { + case _abs: + ad=getmem(pc-2); + ad|=256*getmem(pc-1); + setmem(ad,val); + return; + case absx: + ad=getmem(pc-2); + ad|=256*getmem(pc-1); + ad2=ad+x; + setmem(ad2,val); + return; + case zp: + ad=getmem(pc-1); + setmem(ad,val); + return; + case zpx: + ad=getmem(pc-1); + ad+=x; + setmem(ad&0xff,val); + return; + case acc: + a=val; + return; + } +} + + +static inline void putaddr(int mode, unsigned char val) +{ + unsigned short ad,ad2; + switch(mode) + { + case _abs: + ad=getmem(pc++); + ad|=getmem(pc++)<<8; + setmem(ad,val); + return; + case absx: + ad=getmem(pc++); + ad|=getmem(pc++)<<8; + ad2=ad+x; + setmem(ad2,val); + return; + case absy: + ad=getmem(pc++); + ad|=getmem(pc++)<<8; + ad2=ad+y; + setmem(ad2,val); + return; + case zp: + ad=getmem(pc++); + setmem(ad,val); + return; + case zpx: + ad=getmem(pc++); + ad+=x; + setmem(ad&0xff,val); + return; + case zpy: + ad=getmem(pc++); + ad+=y; + setmem(ad&0xff,val); + return; + case indx: + ad=getmem(pc++); + ad+=x; + ad2=getmem(ad&0xff); + ad++; + ad2|=getmem(ad&0xff)<<8; + setmem(ad2,val); + return; + case indy: + ad=getmem(pc++); + ad2=getmem(ad); + ad2|=getmem((ad+1)&0xff)<<8; + ad=ad2+y; + setmem(ad,val); + return; + case acc: + a=val; + return; + } +} + + +static inline void setflags(int flag, int cond) +{ + if (cond) p|=flag; + else p&=~flag; +} + + +static inline void push(unsigned char val) +{ + setmem(0x100+s,val); + if (s) s--; +} + +static inline unsigned char pop(void) +{ + if (s<0xff) s++; + return getmem(0x100+s); +} + +static inline void branch(int flag) +{ + signed char dist; + dist=(signed char)getaddr(imm); + wval=pc+dist; + if (flag) pc=wval; +} + +void cpuReset(void) ICODE_ATTR; +void cpuReset(void) +{ + a=x=y=0; + p=0; + s=255; + pc=getaddr(0xfffc); +} + +void cpuResetTo(unsigned short npc, unsigned char na) ICODE_ATTR; +void cpuResetTo(unsigned short npc, unsigned char na) +{ + a=na; + x=0; + y=0; + p=0; + s=255; + pc=npc; +} + +static inline void cpuParse(void) +{ + unsigned char opc=getmem(pc++); + int cmd=opcodes[opc]; + int addr=modes[opc]; + int c; + switch (cmd) + { + case adc: + wval=(unsigned short)a+getaddr(addr)+((p&FLAG_C)?1:0); + setflags(FLAG_C, wval&0x100); + a=(unsigned char)wval; + setflags(FLAG_Z, !a); + setflags(FLAG_N, a&0x80); + setflags(FLAG_V, (!!(p&FLAG_C)) ^ (!!(p&FLAG_N))); + break; + case _and: + bval=getaddr(addr); + a&=bval; + setflags(FLAG_Z, !a); + setflags(FLAG_N, a&0x80); + break; + case asl: + wval=getaddr(addr); + wval<<=1; + setaddr(addr,(unsigned char)wval); + setflags(FLAG_Z,!wval); + setflags(FLAG_N,wval&0x80); + setflags(FLAG_C,wval&0x100); + break; + case bcc: + branch(!(p&FLAG_C)); + break; + case bcs: + branch(p&FLAG_C); + break; + case bne: + branch(!(p&FLAG_Z)); + break; + case beq: + branch(p&FLAG_Z); + break; + case bpl: + branch(!(p&FLAG_N)); + break; + case bmi: + branch(p&FLAG_N); + break; + case bvc: + branch(!(p&FLAG_V)); + break; + case bvs: + branch(p&FLAG_V); + break; + case bit: + bval=getaddr(addr); + setflags(FLAG_Z,!(a&bval)); + setflags(FLAG_N,bval&0x80); + setflags(FLAG_V,bval&0x40); + break; + case _brk: + pc=0; /* Just quit the emulation */ + break; + case clc: + setflags(FLAG_C,0); + break; + case cld: + setflags(FLAG_D,0); + break; + case cli: + setflags(FLAG_I,0); + break; + case clv: + setflags(FLAG_V,0); + break; + case cmp: + bval=getaddr(addr); + wval=(unsigned short)a-bval; + setflags(FLAG_Z,!wval); + setflags(FLAG_N,wval&0x80); + setflags(FLAG_C,a>=bval); + break; + case cpx: + bval=getaddr(addr); + wval=(unsigned short)x-bval; + setflags(FLAG_Z,!wval); + setflags(FLAG_N,wval&0x80); + setflags(FLAG_C,x>=bval); + break; + case cpy: + bval=getaddr(addr); + wval=(unsigned short)y-bval; + setflags(FLAG_Z,!wval); + setflags(FLAG_N,wval&0x80); + setflags(FLAG_C,y>=bval); + break; + case dec: + bval=getaddr(addr); + bval--; + setaddr(addr,bval); + setflags(FLAG_Z,!bval); + setflags(FLAG_N,bval&0x80); + break; + case dex: + x--; + setflags(FLAG_Z,!x); + setflags(FLAG_N,x&0x80); + break; + case dey: + y--; + setflags(FLAG_Z,!y); + setflags(FLAG_N,y&0x80); + break; + case eor: + bval=getaddr(addr); + a^=bval; + setflags(FLAG_Z,!a); + setflags(FLAG_N,a&0x80); + break; + case inc: + bval=getaddr(addr); + bval++; + setaddr(addr,bval); + setflags(FLAG_Z,!bval); + setflags(FLAG_N,bval&0x80); + break; + case inx: + x++; + setflags(FLAG_Z,!x); + setflags(FLAG_N,x&0x80); + break; + case iny: + y++; + setflags(FLAG_Z,!y); + setflags(FLAG_N,y&0x80); + break; + case jmp: + wval=getmem(pc++); + wval|=256*getmem(pc++); + switch (addr) + { + case _abs: + pc=wval; + break; + case ind: + pc=getmem(wval); + pc|=256*getmem(wval+1); + break; + } + break; + case jsr: + push((pc+1)>>8); + push((pc+1)); + wval=getmem(pc++); + wval|=256*getmem(pc++); + pc=wval; + break; + case lda: + a=getaddr(addr); + setflags(FLAG_Z,!a); + setflags(FLAG_N,a&0x80); + break; + case ldx: + x=getaddr(addr); + setflags(FLAG_Z,!x); + setflags(FLAG_N,x&0x80); + break; + case ldy: + y=getaddr(addr); + setflags(FLAG_Z,!y); + setflags(FLAG_N,y&0x80); + break; + case lsr: + bval=getaddr(addr); wval=(unsigned char)bval; + wval>>=1; + setaddr(addr,(unsigned char)wval); + setflags(FLAG_Z,!wval); + setflags(FLAG_N,wval&0x80); + setflags(FLAG_C,bval&1); + break; + case _nop: + break; + case ora: + bval=getaddr(addr); + a|=bval; + setflags(FLAG_Z,!a); + setflags(FLAG_N,a&0x80); + break; + case pha: + push(a); + break; + case php: + push(p); + break; + case pla: + a=pop(); + setflags(FLAG_Z,!a); + setflags(FLAG_N,a&0x80); + break; + case plp: + p=pop(); + break; + case rol: + bval=getaddr(addr); + c=!!(p&FLAG_C); + setflags(FLAG_C,bval&0x80); + bval<<=1; + bval|=c; + setaddr(addr,bval); + setflags(FLAG_N,bval&0x80); + setflags(FLAG_Z,!bval); + break; + case ror: + bval=getaddr(addr); + c=!!(p&FLAG_C); + setflags(FLAG_C,bval&1); + bval>>=1; + bval|=128*c; + setaddr(addr,bval); + setflags(FLAG_N,bval&0x80); + setflags(FLAG_Z,!bval); + break; + case rti: + /* Treat RTI like RTS */ + case rts: + wval=pop(); + wval|=pop()<<8; + pc=wval+1; + break; + case sbc: + bval=getaddr(addr)^0xff; + wval=(unsigned short)a+bval+((p&FLAG_C)?1:0); + setflags(FLAG_C, wval&0x100); + a=(unsigned char)wval; + setflags(FLAG_Z, !a); + setflags(FLAG_N, a>127); + setflags(FLAG_V, (!!(p&FLAG_C)) ^ (!!(p&FLAG_N))); + break; + case sec: + setflags(FLAG_C,1); + break; + case sed: + setflags(FLAG_D,1); + break; + case sei: + setflags(FLAG_I,1); + break; + case sta: + putaddr(addr,a); + break; + case stx: + putaddr(addr,x); + break; + case sty: + putaddr(addr,y); + break; + case tax: + x=a; + setflags(FLAG_Z, !x); + setflags(FLAG_N, x&0x80); + break; + case tay: + y=a; + setflags(FLAG_Z, !y); + setflags(FLAG_N, y&0x80); + break; + case tsx: + x=s; + setflags(FLAG_Z, !x); + setflags(FLAG_N, x&0x80); + break; + case txa: + a=x; + setflags(FLAG_Z, !a); + setflags(FLAG_N, a&0x80); + break; + case txs: + s=x; + break; + case tya: + a=y; + setflags(FLAG_Z, !a); + setflags(FLAG_N, a&0x80); + break; + } +} + +void cpuJSR(unsigned short npc, unsigned char na) ICODE_ATTR; +void cpuJSR(unsigned short npc, unsigned char na) +{ + a=na; + x=0; + y=0; + p=0; + s=255; + pc=npc; + push(0); + push(0); + + while (pc > 1) + cpuParse(); + +} + +void c64Init(int nSampleRate) ICODE_ATTR; +void c64Init(int nSampleRate) +{ + synth_init(nSampleRate); + memset(memory, 0, sizeof(memory)); + + cpuReset(); +} + + + +unsigned short LoadSIDFromMemory(void *pSidData, unsigned short *load_addr, + unsigned short *init_addr, unsigned short *play_addr, unsigned char *subsongs, unsigned char *startsong, unsigned char *speed, unsigned short size) ICODE_ATTR; +unsigned short LoadSIDFromMemory(void *pSidData, unsigned short *load_addr, + unsigned short *init_addr, unsigned short *play_addr, unsigned char *subsongs, unsigned char *startsong, unsigned char *speed, unsigned short size) +{ + unsigned char *pData; + unsigned char data_file_offset; + + pData = (unsigned char*)pSidData; + data_file_offset = pData[7]; + + *load_addr = pData[8]<<8; + *load_addr|= pData[9]; + + *init_addr = pData[10]<<8; + *init_addr|= pData[11]; + + *play_addr = pData[12]<<8; + *play_addr|= pData[13]; + + *subsongs = pData[0xf]-1; + *startsong = pData[0x11]-1; + + *load_addr = pData[data_file_offset]; + *load_addr|= pData[data_file_offset+1]<<8; + + *speed = pData[0x15]; + + memset(memory, 0, sizeof(memory)); + memcpy(&memory[*load_addr], &pData[data_file_offset+2], size-(data_file_offset+2)); + + if (*play_addr == 0) + { + cpuJSR(*init_addr, 0); + *play_addr = (memory[0x0315]<<8)+memory[0x0314]; + } + + return *load_addr; +} + +static int nSamplesRendered = 0; +static int nSamplesPerCall = 882; /* This is PAL SID single speed (44100/50Hz) */ +static int nSamplesToRender = 0; + +/* this is the codec entry point */ +enum codec_status codec_main(enum codec_entry_call_reason reason) +{ + if (reason == CODEC_LOAD) { + /* Make use of 44.1khz */ + ci->configure(DSP_SWITCH_FREQUENCY, SAMPLE_RATE); + /* Sample depth is 28 bit host endian */ + ci->configure(DSP_SET_SAMPLE_DEPTH, 28); + /* Mono output */ + ci->configure(DSP_SET_STEREO_MODE, STEREO_MONO); + } + + return CODEC_OK; +} + +/* this is called for each file to process */ +enum codec_status codec_run(void) +{ + size_t filesize; + unsigned short load_addr, init_addr, play_addr; + unsigned char subSongsMax, subSong, song_speed; + unsigned char *sidfile = NULL; + intptr_t param; + + if (codec_init()) { + return CODEC_ERROR; + } + + codec_set_replaygain(ci->id3); + + /* Load SID file the read_filebuf callback will return the full requested + * size if at all possible, so there is no need to loop */ + ci->seek_buffer(0); + sidfile = ci->request_buffer(&filesize, SID_BUFFER_SIZE); + + if (filesize == 0) { + return CODEC_ERROR; + } + + c64Init(SAMPLE_RATE); + LoadSIDFromMemory(sidfile, &load_addr, &init_addr, &play_addr, + &subSongsMax, &subSong, &song_speed, (unsigned short)filesize); + sidPoke(24, 15); /* Turn on full volume */ + cpuJSR(init_addr, subSong); /* Start the song initialize */ + + + /* Set the elapsed time to the current subsong (in seconds) */ + ci->set_elapsed(subSong*1000); + + /* The main decoder loop */ + while (1) { + enum codec_command_action action = ci->get_command(¶m); + + if (action == CODEC_ACTION_HALT) + break; + + if (action == CODEC_ACTION_SEEK_TIME) { + /* New time is ready in param */ + + /* Start playing from scratch */ + c64Init(SAMPLE_RATE); + LoadSIDFromMemory(sidfile, &load_addr, &init_addr, &play_addr, + &subSongsMax, &subSong, &song_speed, (unsigned short)filesize); + sidPoke(24, 15); /* Turn on full volume */ + subSong = param / 1000; /* Now use the current seek time in seconds as subsong */ + cpuJSR(init_addr, subSong); /* Start the song initialize */ + nSamplesToRender = 0; /* Start the rendering from scratch */ + + /* Set the elapsed time to the current subsong (in seconds) */ + ci->set_elapsed(subSong*1000); + ci->seek_complete(); + } + + nSamplesRendered = 0; + while (nSamplesRendered < CHUNK_SIZE) + { + if (nSamplesToRender == 0) + { + cpuJSR(play_addr, 0); + + /* Find out if cia timing is used and how many samples + have to be calculated for each cpujsr */ + int nRefreshCIA = (int)(20000*(memory[0xdc04]|(memory[0xdc05]<<8))/0x4c00); + if ((nRefreshCIA==0) || (song_speed == 0)) + nRefreshCIA = 20000; + nSamplesPerCall = mixing_frequency*nRefreshCIA/1000000; + + nSamplesToRender = nSamplesPerCall; + } + if (nSamplesRendered + nSamplesToRender > CHUNK_SIZE) + { + synth_render(samples+nSamplesRendered, CHUNK_SIZE-nSamplesRendered); + nSamplesToRender -= CHUNK_SIZE-nSamplesRendered; + nSamplesRendered = CHUNK_SIZE; + } + else + { + synth_render(samples+nSamplesRendered, nSamplesToRender); + nSamplesRendered += nSamplesToRender; + nSamplesToRender = 0; + } + } + + ci->pcmbuf_insert(samples, NULL, CHUNK_SIZE); + } + + return CODEC_OK; +} diff --git a/lib/rbcodec/codecs/smaf.c b/lib/rbcodec/codecs/smaf.c new file mode 100644 index 0000000000..0203d1b4e3 --- /dev/null +++ b/lib/rbcodec/codecs/smaf.c @@ -0,0 +1,492 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (c) 2010 Yoshihisa Uchida + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include "codeclib.h" +#include "codecs/libpcm/support_formats.h" + +CODEC_HEADER + +/* + * SMAF (Synthetic music Mobile Application Format) + * + * References + * [1] YAMAHA Corporation, Synthetic music Mobile Application Format Ver.3.05, 2002 + */ + +enum { + SMAF_AUDIO_TRACK_CHUNK = 0, /* PCM Audio Track */ + SMAF_SCORE_TRACK_CHUNK, /* Score Track */ +}; + +/* SMAF supported codec formats */ +enum { + SMAF_FORMAT_UNSUPPORT = 0, /* unsupported format */ + SMAF_FORMAT_SIGNED_PCM, /* 2's complement PCM */ + SMAF_FORMAT_UNSIGNED_PCM, /* Offset Binary PCM */ + SMAF_FORMAT_ADPCM, /* YAMAHA ADPCM */ +}; + +static const int support_formats[2][3] = { + {SMAF_FORMAT_SIGNED_PCM, SMAF_FORMAT_ADPCM, SMAF_FORMAT_UNSUPPORT }, + {SMAF_FORMAT_SIGNED_PCM, SMAF_FORMAT_UNSIGNED_PCM, SMAF_FORMAT_ADPCM }, +}; + +static const struct pcm_entry pcm_codecs[] = { + { SMAF_FORMAT_SIGNED_PCM, get_linear_pcm_codec }, + { SMAF_FORMAT_UNSIGNED_PCM, get_linear_pcm_codec }, + { SMAF_FORMAT_ADPCM, get_yamaha_adpcm_codec }, +}; + +#define NUM_FORMATS 3 + +static const int basebits[4] = { 4, 8, 12, 16 }; + +#define PCM_SAMPLE_SIZE (2048*2) + +static int32_t samples[PCM_SAMPLE_SIZE] IBSS_ATTR; + +static const struct pcm_codec *get_codec(uint32_t formattag) +{ + int i; + + for (i = 0; i < NUM_FORMATS; i++) + { + if (pcm_codecs[i].format_tag == formattag) + { + if (pcm_codecs[i].get_codec) + return pcm_codecs[i].get_codec(); + return 0; + } + } + return 0; +} + +static unsigned int get_be32(const uint8_t *buf) +{ + return (buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3]; +} + +static int convert_smaf_channels(unsigned int ch) +{ + return (ch >> 7) + 1; +} + +static int convert_smaf_audio_format(unsigned int chunk, unsigned int audio_format) +{ + int idx = (audio_format & 0x70) >> 4; + + if (idx < 3) + return support_formats[chunk][idx]; + + DEBUGF("CODEC_ERROR: unsupport audio format: %d\n", audio_format); + return SMAF_FORMAT_UNSUPPORT; +} + +static int convert_smaf_audio_basebit(unsigned int basebit) +{ + if (basebit < 4) + return basebits[basebit]; + + DEBUGF("CODEC_ERROR: illegal basebit: %d\n", basebit); + return 0; +} + +static unsigned int search_chunk(const unsigned char *name, int nlen, off_t *pos) +{ + const unsigned char *buf; + unsigned int chunksize; + size_t size; + + while (true) + { + buf = ci->request_buffer(&size, 8); + if (size < 8) + break; + + chunksize = get_be32(buf + 4); + ci->advance_buffer(8); + *pos += 8; + if (memcmp(buf, name, nlen) == 0) + return chunksize; + + ci->advance_buffer(chunksize); + *pos += chunksize; + } + DEBUGF("CODEC_ERROR: missing '%s' chunk\n", name); + return 0; +} + +static bool parse_audio_track(struct pcm_format *fmt, unsigned int chunksize, off_t *pos) +{ + const unsigned char *buf; + size_t size; + + /* search PCM Audio Track Chunk */ + ci->advance_buffer(chunksize); + *pos += chunksize; + if (search_chunk("ATR", 3, pos) == 0) + { + DEBUGF("CODEC_ERROR: missing PCM Audio Track Chunk\n"); + return false; + } + + /* + * get format + * buf + * +0: Format Type + * +1: Sequence Type + * +2: bit 7 0:mono/1:stereo, bit 4-6 format, bit 0-3: frequency + * +3: bit 4-7: base bit + * +4: TimeBase_D + * +5: TimeBase_G + * + * Note: If PCM Audio Track does not include Sequence Data Chunk, + * tmp+6 is the start position of Wave Data Chunk. + */ + buf = ci->request_buffer(&size, 6); + if (size < 6) + { + DEBUGF("CODEC_ERROR: smaf is too small\n"); + return false; + } + + fmt->formattag = convert_smaf_audio_format(SMAF_AUDIO_TRACK_CHUNK, buf[2]); + fmt->channels = convert_smaf_channels(buf[2]); + fmt->bitspersample = convert_smaf_audio_basebit(buf[3] >> 4); + + /* search Wave Data Chunk */ + ci->advance_buffer(6); + *pos += 6; + fmt->numbytes = search_chunk("Awa", 3, pos); + if (fmt->numbytes == 0) + { + DEBUGF("CODEC_ERROR: missing Wave Data Chunk\n"); + return false; + } + + return true; +} + +static bool parse_score_track(struct pcm_format *fmt, off_t *pos) +{ + const unsigned char *buf; + unsigned int chunksize; + size_t size; + + /* parse Optional Data Chunk */ + buf = ci->request_buffer(&size, 13); + if (size < 13) + { + DEBUGF("CODEC_ERROR: smaf is too small\n"); + return false; + } + + if (memcmp(buf + 5, "OPDA", 4) != 0) + { + DEBUGF("CODEC_ERROR: missing Optional Data Chunk\n"); + return false; + } + + /* Optional Data Chunk size */ + chunksize = get_be32(buf + 9); + + /* search Score Track Chunk */ + ci->advance_buffer(13 + chunksize); + *pos += (13 + chunksize); + if (search_chunk("MTR", 3, pos) == 0) + { + DEBUGF("CODEC_ERROR: missing Score Track Chunk\n"); + return false; + } + + /* + * search next chunk + * usually, next chunk ('M***') found within 40 bytes. + */ + buf = ci->request_buffer(&size, 40); + if (size < 40) + { + DEBUGF("CODEC_ERROR: smaf is too small\n"); + return false; + } + + size = 0; + while (size < 40 && buf[size] != 'M') + size++; + + if (size >= 40) + { + DEBUGF("CODEC_ERROR: missing Score Track Stream PCM Data Chunk"); + return false; + } + + /* search Score Track Stream PCM Data Chunk */ + ci->advance_buffer(size); + *pos += size; + if (search_chunk("Mtsp", 4, pos) == 0) + { + DEBUGF("CODEC_ERROR: missing Score Track Stream PCM Data Chunk\n"); + return false; + } + + /* + * parse Score Track Stream Wave Data Chunk + * buf + * +4-7: chunk size (WaveType(3bytes) + wave data count) + * +8: bit 7 0:mono/1:stereo, bit 4-6 format, bit 0-3: base bit + * +9: frequency (MSB) + * +10: frequency (LSB) + */ + buf = ci->request_buffer(&size, 9); + if (size < 9) + { + DEBUGF("CODEC_ERROR: smaf is too small\n"); + return false; + } + + if (memcmp(buf, "Mwa", 3) != 0) + { + DEBUGF("CODEC_ERROR: missing Score Track Stream Wave Data Chunk\n"); + return false; + } + + fmt->formattag = convert_smaf_audio_format(SMAF_SCORE_TRACK_CHUNK, buf[8]); + fmt->channels = convert_smaf_channels(buf[8]); + fmt->bitspersample = convert_smaf_audio_basebit(buf[8] & 0xf); + fmt->numbytes = get_be32(buf + 4) - 3; + + *pos += 11; + return true; +} + +static bool parse_header(struct pcm_format *fmt, off_t *pos) +{ + const unsigned char *buf; + unsigned int chunksize; + size_t size; + + ci->memset(fmt, 0, sizeof(struct pcm_format)); + + /* check File Chunk and Contents Info Chunk */ + buf = ci->request_buffer(&size, 16); + if (size < 16) + { + DEBUGF("CODEC_ERROR: smaf is too small\n"); + return false; + } + + if ((memcmp(buf, "MMMD", 4) != 0) || (memcmp(buf + 8, "CNTI", 4) != 0)) + { + DEBUGF("CODEC_ERROR: does not smaf format\n"); + return false; + } + + chunksize = get_be32(buf + 12); + ci->advance_buffer(16); + *pos = 16; + if (chunksize > 5) + { + if (!parse_audio_track(fmt, chunksize, pos)) + return false; + } + else if (!parse_score_track(fmt, pos)) + return false; + + /* data signess (default signed) */ + fmt->is_signed = (fmt->formattag != SMAF_FORMAT_UNSIGNED_PCM); + + /* data is always big endian */ + fmt->is_little_endian = false; + + return true; +} + +static struct pcm_format format; +static uint32_t bytesdone; + +static uint8_t *read_buffer(size_t *realsize) +{ + uint8_t *buffer = (uint8_t *)ci->request_buffer(realsize, format.chunksize); + if (bytesdone + (*realsize) > format.numbytes) + *realsize = format.numbytes - bytesdone; + bytesdone += *realsize; + ci->advance_buffer(*realsize); + return buffer; +} + +/* this is the codec entry point */ +enum codec_status codec_main(enum codec_entry_call_reason reason) +{ + if (reason == CODEC_LOAD) { + /* Generic codec initialisation */ + ci->configure(DSP_SET_SAMPLE_DEPTH, PCM_OUTPUT_DEPTH-1); + } + + return CODEC_OK; +} + +/* this is called for each file to process */ +enum codec_status codec_run(void) +{ + uint32_t decodedsamples; + size_t n; + int bufcount; + int endofstream; + uint8_t *smafbuf; + off_t firstblockposn; /* position of the first block in file */ + const struct pcm_codec *codec; + intptr_t param; + + if (codec_init()) + return CODEC_ERROR; + + codec_set_replaygain(ci->id3); + + /* Need to save offset for later use (cleared indirectly by advance_buffer) */ + bytesdone = ci->id3->offset; + + decodedsamples = 0; + codec = 0; + + ci->seek_buffer(0); + if (!parse_header(&format, &firstblockposn)) + { + return CODEC_ERROR; + } + + codec = get_codec(format.formattag); + if (codec == 0) + { + DEBUGF("CODEC_ERROR: unsupport audio format: 0x%x\n", (int)format.formattag); + return CODEC_ERROR; + } + + if (!codec->set_format(&format)) + { + return CODEC_ERROR; + } + + /* check chunksize */ + if ((format.chunksize / format.blockalign) * format.samplesperblock * format.channels + > PCM_SAMPLE_SIZE) + format.chunksize = (PCM_SAMPLE_SIZE / format.blockalign) * format.blockalign; + if (format.chunksize == 0) + { + DEBUGF("CODEC_ERROR: chunksize is 0\n"); + return CODEC_ERROR; + } + + ci->configure(DSP_SWITCH_FREQUENCY, ci->id3->frequency); + + if (format.channels == 2) { + ci->configure(DSP_SET_STEREO_MODE, STEREO_INTERLEAVED); + } else if (format.channels == 1) { + ci->configure(DSP_SET_STEREO_MODE, STEREO_MONO); + } else { + DEBUGF("CODEC_ERROR: more than 2 channels unsupported\n"); + return CODEC_ERROR; + } + + ci->seek_buffer(firstblockposn); + + /* make sure we're at the correct offset */ + if (bytesdone > (uint32_t) firstblockposn) + { + /* Round down to previous block */ + struct pcm_pos *newpos = codec->get_seek_pos(bytesdone - firstblockposn, + PCM_SEEK_POS, &read_buffer); + + if (newpos->pos > format.numbytes) + return CODEC_OK; + + if (ci->seek_buffer(firstblockposn + newpos->pos)) + { + bytesdone = newpos->pos; + decodedsamples = newpos->samples; + } + } + else + { + /* already where we need to be */ + bytesdone = 0; + } + + ci->set_elapsed(decodedsamples*1000LL/ci->id3->frequency); + + /* The main decoder loop */ + endofstream = 0; + + while (!endofstream) { + enum codec_command_action action = ci->get_command(¶m); + + if (action == CODEC_ACTION_HALT) + break; + + if (action == CODEC_ACTION_SEEK_TIME) { + struct pcm_pos *newpos = codec->get_seek_pos(param, PCM_SEEK_TIME, + &read_buffer); + + if (newpos->pos > format.numbytes) + { + ci->set_elapsed(ci->id3->length); + ci->seek_complete(); + break; + } + + if (ci->seek_buffer(firstblockposn + newpos->pos)) + { + bytesdone = newpos->pos; + decodedsamples = newpos->samples; + } + + ci->set_elapsed(decodedsamples*1000LL/ci->id3->frequency); + ci->seek_complete(); + } + + smafbuf = (uint8_t *)ci->request_buffer(&n, format.chunksize); + + if (n == 0) + break; /* End of stream */ + + if (bytesdone + n > format.numbytes) { + n = format.numbytes - bytesdone; + endofstream = 1; + } + + if (codec->decode(smafbuf, n, samples, &bufcount) == CODEC_ERROR) + { + DEBUGF("codec error\n"); + return CODEC_ERROR; + } + + ci->pcmbuf_insert(samples, NULL, bufcount); + + ci->advance_buffer(n); + bytesdone += n; + decodedsamples += bufcount; + if (bytesdone >= format.numbytes) + endofstream = 1; + + ci->set_elapsed(decodedsamples*1000LL/ci->id3->frequency); + } + + return CODEC_OK; +} diff --git a/lib/rbcodec/codecs/spc.c b/lib/rbcodec/codecs/spc.c new file mode 100644 index 0000000000..809562e2a0 --- /dev/null +++ b/lib/rbcodec/codecs/spc.c @@ -0,0 +1,586 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2007-2008 Michael Sevakis (jhMikeS) + * Copyright (C) 2006-2007 Adam Gashlin (hcs) + * Copyright (C) 2004-2007 Shay Green (blargg) + * Copyright (C) 2002 Brad Martin + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +/* lovingly ripped off from Game_Music_Emu 0.5.2. http://www.slack.net/~ant/ */ +/* DSP Based on Brad Martin's OpenSPC DSP emulator */ +/* tag reading from sexyspc by John Brawn (John_Brawn@yahoo.com) and others */ +#include "codeclib.h" +#include "../fracmul.h" +#include "libspc/spc_codec.h" +#include "libspc/spc_profiler.h" + +CODEC_HEADER + +/**************** ID666 parsing ****************/ + +static struct { + unsigned char isBinary; + char song[32]; + char game[32]; + char dumper[16]; + char comments[32]; + int day,month,year; + unsigned long length; + unsigned long fade; + char artist[32]; + unsigned char muted; + unsigned char emulator; +} ID666; + +static int LoadID666(unsigned char *buf) { + unsigned char *ib=buf; + int isbinary = 1; + int i; + + memcpy(ID666.song,ib,32); + ID666.song[31]=0; + ib+=32; + + memcpy(ID666.game,ib,32); + ID666.game[31]=0; + ib+=32; + + memcpy(ID666.dumper,ib,16); + ID666.dumper[15]=0; + ib+=16; + + memcpy(ID666.comments,ib,32); + ID666.comments[31]=0; + ib+=32; + + /* Ok, now comes the fun part. */ + + /* Date check */ + if(ib[2] == '/' && ib[5] == '/' ) + isbinary = 0; + + /* Reserved bytes check */ + if(ib[0xD2 - 0x2E - 112] >= '0' && + ib[0xD2 - 0x2E - 112] <= '9' && + ib[0xD3 - 0x2E - 112] == 0x00) + isbinary = 0; + + /* is length & fade only digits? */ + for (i=0;i<8 && ( + (ib[0xA9 - 0x2E - 112+i]>='0'&&ib[0xA9 - 0x2E - 112+i]<='9') || + ib[0xA9 - 0x2E - 112+i]=='\0'); + i++); + if (i==8) isbinary=0; + + ID666.isBinary = isbinary; + + if(isbinary) { + DEBUGF("binary tag detected\n"); + ID666.year=*ib; + ib++; + ID666.year|=*ib<<8; + ib++; + ID666.month=*ib; + ib++; + ID666.day=*ib; + ib++; + + ib+=7; + + ID666.length=*ib; + ib++; + + ID666.length|=*ib<<8; + ib++; + + ID666.length|=*ib<<16; + ID666.length*=1000; + ib++; + + ID666.fade=*ib; + ib++; + ID666.fade|=*ib<<8; + ib++; + ID666.fade|=*ib<<16; + ib++; + ID666.fade|=*ib<<24; + ib++; + + memcpy(ID666.artist,ib,32); + ID666.artist[31]=0; + ib+=32; + + ID666.muted=*ib; + ib++; + + ID666.emulator=*ib; + ib++; + } else { + unsigned long tmp; + char buf[64]; + + DEBUGF("text tag detected\n"); + + memcpy(buf, ib, 2); + buf[2] = 0; + tmp = 0; + for (i=0;i<2 && buf[i]>='0' && buf[i]<='9';i++) tmp=tmp*10+buf[i]-'0'; + ID666.month = tmp; + ib+=3; + + memcpy(buf, ib, 2); + buf[2] = 0; + tmp = 0; + for (i=0;i<2 && buf[i]>='0' && buf[i]<='9';i++) tmp=tmp*10+buf[i]-'0'; + ID666.day = tmp; + ib+=3; + + memcpy(buf, ib, 4); + buf[4] = 0; + tmp = 0; + for (i=0;i<4 && buf[i]>='0' && buf[i]<='9';i++) tmp=tmp*10+buf[i]-'0'; + ID666.year = tmp; + ib+=5; + + memcpy(buf, ib, 3); + buf[3] = 0; + tmp = 0; + for (i=0;i<3 && buf[i]>='0' && buf[i]<='9';i++) tmp=tmp*10+buf[i]-'0'; + ID666.length = tmp * 1000; + ib+=3; + + memcpy(buf, ib, 5); + buf[5] = 0; + tmp = 0; + for (i=0;i<5 && buf[i]>='0' && buf[i]<='9';i++) tmp=tmp*10+buf[i]-'0'; + ID666.fade = tmp; + ib+=5; + + memcpy(ID666.artist,ib,32); + ID666.artist[31]=0; + ib+=32; + + /*I have no idea if this is right or not.*/ + ID666.muted=*ib; + ib++; + + memcpy(buf, ib, 1); + buf[1] = 0; + tmp = 0; + ib++; + } + return 1; +} + +/**************** Codec ****************/ +enum {SAMPLE_RATE = 32000}; +static struct Spc_Emu spc_emu IBSS_ATTR_SPC CACHEALIGN_ATTR; + +#if SPC_DUAL_CORE +/** Implementations for pipelined dual-core operation **/ +static int spc_emu_thread_stack[DEFAULT_STACK_SIZE/sizeof(int)] + CACHEALIGN_ATTR; + +static const unsigned char * const spc_emu_thread_name = "spc emu"; +static unsigned int emu_thread_id = 0; + +enum +{ + SPC_EMU_AUDIO = 0, + SPC_EMU_LOAD, + SPC_EMU_QUIT, +}; + +struct spc_load +{ + uint8_t *buf; + size_t size; +}; + +/* sample queue */ +#define WAV_NUM_CHUNKS 2 +#define WAV_CHUNK_MASK (WAV_NUM_CHUNKS-1) +struct sample_queue_chunk +{ + long id; + union + { + intptr_t data; + int32_t audio[WAV_CHUNK_SIZE*2]; + }; +}; + +static struct +{ + int head, tail; + struct semaphore emu_sem_head; + struct semaphore emu_sem_tail; + struct semaphore emu_evt_reply; + intptr_t retval; + struct sample_queue_chunk wav_chunk[WAV_NUM_CHUNKS]; +} sample_queue SHAREDBSS_ATTR; + +static inline void samples_release_wrbuf(void) +{ + sample_queue.tail++; + ci->semaphore_release(&sample_queue.emu_sem_head); +} + +static inline struct sample_queue_chunk * samples_get_wrbuf(void) +{ + ci->semaphore_wait(&sample_queue.emu_sem_tail, TIMEOUT_BLOCK); + return &sample_queue.wav_chunk[sample_queue.tail & WAV_CHUNK_MASK]; +} + +static inline void samples_release_rdbuf(void) +{ + if (sample_queue.head != sample_queue.tail) { + sample_queue.head++; + } + + ci->semaphore_release(&sample_queue.emu_sem_tail); +} + +static inline int32_t * samples_get_rdbuf(void) +{ + ci->semaphore_wait(&sample_queue.emu_sem_head, TIMEOUT_BLOCK); + return sample_queue.wav_chunk[sample_queue.head & WAV_CHUNK_MASK].audio; +} + +static intptr_t emu_thread_send_msg(long id, intptr_t data) +{ + struct sample_queue_chunk *chunk; + /* Grab an audio output buffer */ + ci->semaphore_wait(&sample_queue.emu_sem_head, TIMEOUT_BLOCK); + chunk = &sample_queue.wav_chunk[sample_queue.head & WAV_CHUNK_MASK]; + /* Place a message in it instead of audio */ + chunk->id = id; + chunk->data = data; + /* Release it to the emu thread */ + samples_release_rdbuf(); + + if (id != SPC_EMU_QUIT) { + /* Wait for a response */ + ci->semaphore_wait(&sample_queue.emu_evt_reply, TIMEOUT_BLOCK); + } + + return sample_queue.retval; +} + +/* thread function */ +static bool emu_thread_process_msg(struct sample_queue_chunk *chunk) +{ + long id = chunk->id; + bool ret = id != SPC_EMU_QUIT; + + chunk->id = SPC_EMU_AUDIO; /* Reset chunk type to audio */ + sample_queue.retval = 0; + + if (id == SPC_EMU_LOAD) + { + struct spc_load *ld = (struct spc_load *)chunk->data; + ci->commit_discard_dcache(); + SPC_Init(&spc_emu); + sample_queue.retval = SPC_load_spc(&spc_emu, ld->buf, ld->size); + + /* Empty the audio queue */ + ci->semaphore_release(&sample_queue.emu_sem_tail); + ci->semaphore_release(&sample_queue.emu_sem_tail); + ci->semaphore_wait(&sample_queue.emu_sem_head, TIMEOUT_NOBLOCK); + ci->semaphore_wait(&sample_queue.emu_sem_head, TIMEOUT_NOBLOCK); + sample_queue.head = sample_queue.tail = 0; + } + + if (id != SPC_EMU_QUIT) { + ci->semaphore_release(&sample_queue.emu_evt_reply); + } + + return ret; +} + +static void spc_emu_thread(void) +{ + CPU_Init(&spc_emu); + + while (1) { + /* get a buffer for output */ + struct sample_queue_chunk *chunk = samples_get_wrbuf(); + + if (chunk->id != SPC_EMU_AUDIO) { + /* This chunk doesn't contain audio but a command */ + if (!emu_thread_process_msg(chunk)) + break; + /* Have to re-get this pointer to keep semaphore counts correct */ + continue; + } + + ENTER_TIMER(render); + /* fill samples buffer */ + if ( SPC_play(&spc_emu, WAV_CHUNK_SIZE*2, chunk->audio) ) + assert( false ); + EXIT_TIMER(render); + + /* done so release it to output */ + samples_release_wrbuf(); + ci->yield(); + } +} + +static bool spc_emu_start(void) +{ + emu_thread_id = ci->create_thread(spc_emu_thread, spc_emu_thread_stack, + sizeof(spc_emu_thread_stack), CREATE_THREAD_FROZEN, + spc_emu_thread_name IF_PRIO(, PRIORITY_PLAYBACK), COP); + + if (emu_thread_id == 0) + return false; + + /* Initialize audio queue as full to prevent emu thread from trying to run the + emulator before loading something */ + ci->semaphore_init(&sample_queue.emu_evt_reply, 1, 0); + ci->semaphore_init(&sample_queue.emu_sem_tail, 2, 0); + ci->semaphore_init(&sample_queue.emu_sem_head, 2, 2); + sample_queue.head = 0; + sample_queue.tail = 2; + + /* Start it running */ + ci->thread_thaw(emu_thread_id); + return true; +} + +/* load a new program on the emu thread */ +static inline int load_spc_buffer(uint8_t *buf, size_t size) +{ + struct spc_load ld = { buf, size }; + ci->commit_dcache(); + return emu_thread_send_msg(SPC_EMU_LOAD, (intptr_t)&ld); +} + +static inline void spc_emu_quit(void) +{ + if (emu_thread_id != 0) { + emu_thread_send_msg(SPC_EMU_QUIT, 0); + /* Wait for emu thread to be killed */ + ci->thread_wait(emu_thread_id); + ci->commit_discard_dcache(); + } +} + +static inline int32_t * spc_play_get_samples(void) +{ + /* obtain filled samples buffer */ + return samples_get_rdbuf(); +} + +static inline void spc_play_send_samples(int32_t *samples) +{ + ci->pcmbuf_insert(samples, samples+WAV_CHUNK_SIZE, WAV_CHUNK_SIZE); + /* done with chunk so release it to emu thread */ + samples_release_rdbuf(); +} + +#else /* !SPC_DUAL_CORE */ +/** Implementations for single-core operation **/ +static int32_t wav_chunk[WAV_CHUNK_SIZE*2] IBSS_ATTR; + +/* load a new program into emu */ +static inline int load_spc_buffer(uint8_t *buf, size_t size) +{ + SPC_Init(&spc_emu); + return SPC_load_spc(&spc_emu, buf, size); +} + +static inline bool spc_emu_start(void) +{ +#ifdef CPU_COLDFIRE + /* signed integer mode with saturation */ + coldfire_set_macsr(EMAC_SATURATE); +#endif + CPU_Init(&spc_emu); + return true; +} + +static inline void spc_play_send_samples(int32_t *samples) +{ + ci->pcmbuf_insert(samples, samples+WAV_CHUNK_SIZE, WAV_CHUNK_SIZE); +} + +#define spc_emu_quit() +#define samples_release_rdbuf() + +static inline int32_t * spc_play_get_samples(void) +{ + ENTER_TIMER(render); + /* fill samples buffer */ + if ( SPC_play(&spc_emu,WAV_CHUNK_SIZE*2,wav_chunk) ) + assert( false ); + EXIT_TIMER(render); + return wav_chunk; +} +#endif /* SPC_DUAL_CORE */ + +/* The main decoder loop */ +static int play_track( void ) +{ + int sampleswritten=0; + + unsigned long fadestartsample = ID666.length*(long long) SAMPLE_RATE/1000; + unsigned long fadeendsample = (ID666.length+ID666.fade)*(long long) SAMPLE_RATE/1000; + int fadedec = 0; + int fadevol = 0x7fffffffl; + intptr_t param; + + if (fadeendsample>fadestartsample) + fadedec=0x7fffffffl/(fadeendsample-fadestartsample)+1; + + ENTER_TIMER(total); + + while ( 1 ) + { + enum codec_command_action action = ci->get_command(¶m); + + if (action == CODEC_ACTION_HALT) + break; + + if (action == CODEC_ACTION_SEEK_TIME) { + int curtime = sampleswritten*1000LL/SAMPLE_RATE; + DEBUGF("seek to %ld\ncurrently at %d\n", (long)param, curtime); + if (param < curtime) { + DEBUGF("seek backwards = reset\n"); + ci->set_elapsed(0); + ci->seek_complete(); + return 1; + } + + ci->set_elapsed(curtime); + ci->seek_complete(); + } + + int32_t *samples = spc_play_get_samples(); + + sampleswritten += WAV_CHUNK_SIZE; + + /* is track timed? */ + if (!ci->loop_track() && ci->id3->length) { + unsigned long curtime = sampleswritten*1000LL/SAMPLE_RATE; + unsigned long lasttimesample = (sampleswritten-WAV_CHUNK_SIZE); + + /* fade? */ + if (curtime>ID666.length) + { + #ifdef CPU_COLDFIRE + /* Have to switch modes to do this */ + long macsr = coldfire_get_macsr(); + coldfire_set_macsr(EMAC_SATURATE | EMAC_FRACTIONAL | EMAC_ROUND); + #endif + int i; + for (i=0;ifadestartsample) { + if (fadevol>0) { + samples[i] = FRACMUL(samples[i], fadevol); + samples[i+WAV_CHUNK_SIZE] = FRACMUL(samples[i+WAV_CHUNK_SIZE], fadevol); + } else samples[i]=samples[i+WAV_CHUNK_SIZE]=0; + fadevol-=fadedec; + } + } + #ifdef CPU_COLDFIRE + coldfire_set_macsr(macsr); + #endif + } + /* end? */ + if (lasttimesample>=fadeendsample) + { + samples_release_rdbuf(); + break; + } + } + + spc_play_send_samples(samples); + + if (ci->loop_track()) + ci->set_elapsed(0); + else + ci->set_elapsed(sampleswritten*1000LL/SAMPLE_RATE); + } + + EXIT_TIMER(total); + return 0; +} + +/* this is the codec entry point */ +enum codec_status codec_main(enum codec_entry_call_reason reason) +{ + if (reason == CODEC_LOAD) { + if (!spc_emu_start()) + return CODEC_ERROR; + + ci->configure(DSP_SET_SAMPLE_DEPTH, 24); + ci->configure(DSP_SET_FREQUENCY, SAMPLE_RATE); + ci->configure(DSP_SET_STEREO_MODE, STEREO_NONINTERLEAVED); + } + else if (reason == CODEC_UNLOAD) { + spc_emu_quit(); + } + + return CODEC_OK; +} + +/* this is called for each file to process */ +enum codec_status codec_run(void) +{ + DEBUGF("SPC: next_track\n"); + if (codec_init()) + return CODEC_ERROR; + DEBUGF("SPC: after init\n"); + + codec_set_replaygain(ci->id3); + + /* Read the entire file */ + DEBUGF("SPC: request initial buffer\n"); + ci->seek_buffer(0); + size_t buffersize; + uint8_t* buffer = ci->request_buffer(&buffersize, ci->filesize); + if (!buffer) + return CODEC_ERROR; + + DEBUGF("SPC: read size = 0x%lx\n",(unsigned long)buffersize); + ci->set_elapsed(0); + + do + { + if (load_spc_buffer(buffer, buffersize)) { + DEBUGF("SPC load failure\n"); + return CODEC_ERROR; + } + + LoadID666(buffer+0x2e); + + if (!ci->loop_track() && ID666.length==0) { + ID666.length=3*60*1000; /* 3 minutes */ + ID666.fade=5*1000; /* 5 seconds */ + } + + reset_profile_timers(); + } + while ( play_track() ); + + print_timers(ci->id3->path); + + return CODEC_OK; +} diff --git a/lib/rbcodec/codecs/speex.c b/lib/rbcodec/codecs/speex.c new file mode 100644 index 0000000000..ac3bc963b1 --- /dev/null +++ b/lib/rbcodec/codecs/speex.c @@ -0,0 +1,583 @@ +/************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * + * Copyright (C) 2006 Frederik M.J. Vestre + * Based on vorbis.c codec interface: + * Copyright (C) 2002 Björn Stenberg + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ***************************************************************************/ + +#include "libspeex/speex/ogg.h" +#include "libspeex/speex/speex.h" +#include "libspeex/speex/speex_callbacks.h" +#include "libspeex/speex/speex_header.h" +#include "libspeex/speex/speex_stereo.h" +#include "libspeex/speex/speex_config_types.h" +#include "codeclib.h" + +/* Room for one stereo frame of max size, 2*640 */ +#define MAX_FRAME_SIZE 1280 +#define CHUNKSIZE 10000 /*2kb*/ +#define SEEK_CHUNKSIZE 7*CHUNKSIZE + +CODEC_HEADER + +static spx_int16_t output[MAX_FRAME_SIZE] IBSS_ATTR; + +static int get_more_data(spx_ogg_sync_state *oy) +{ + int bytes; + char *buffer; + + buffer = (char *)spx_ogg_sync_buffer(oy,CHUNKSIZE); + + bytes = ci->read_filebuf(buffer, sizeof(char)*CHUNKSIZE); + + spx_ogg_sync_wrote(oy,bytes); + + return bytes; +} + +/* The read/seek functions track absolute position within the stream */ + +static spx_int64_t get_next_page(spx_ogg_sync_state *oy,spx_ogg_page *og, + spx_int64_t boundary) +{ + spx_int64_t localoffset = ci->curpos; + long more; + long ret; + + if (boundary > 0) + boundary += ci->curpos; + + while (1) { + more = spx_ogg_sync_pageseek(oy,og); + + if (more < 0) { + /* skipped n bytes */ + localoffset-=more; + } else { + if (more == 0) { + /* send more paramedics */ + if(!boundary)return(-1); + { + ret = get_more_data(oy); + if (ret == 0) + return(-2); + + if (ret < 0) + return(-3); + } + } else { + /* got a page. Return the offset at the page beginning, + advance the internal offset past the page end */ + + spx_int64_t ret=localoffset; + + return(ret); + } + } + } +} + +static spx_int64_t seek_backwards(spx_ogg_sync_state *oy, spx_ogg_page *og, + spx_int64_t wantedpos) +{ + spx_int64_t crofs; + spx_int64_t *curoffset=&crofs; + *curoffset=ci->curpos; + spx_int64_t begin=*curoffset; + spx_int64_t end=begin; + spx_int64_t ret; + spx_int64_t offset=-1; + spx_int64_t avgpagelen=-1; + spx_int64_t lastgranule=-1; + + short time = -1; + + while (offset == -1) { + + begin -= SEEK_CHUNKSIZE; + + if (begin < 0) { + if (time < 0) { + begin = 0; + time++; + } else { + LOGF("Can't seek that early:%lld\n",begin); + return -3; /* too early */ + } + } + + *curoffset = begin; + + ci->seek_buffer(*curoffset); + + spx_ogg_sync_reset(oy); + + lastgranule = -1; + + while (*curoffset < end) { + ret = get_next_page(oy,og,end-*curoffset); + + if (ret > 0) { + if (lastgranule != -1) { + if (avgpagelen < 0) + avgpagelen = (spx_ogg_page_granulepos(og)-lastgranule); + else + avgpagelen=((spx_ogg_page_granulepos(og)-lastgranule) + + avgpagelen) / 2; + } + + lastgranule=spx_ogg_page_granulepos(og); + + if ((lastgranule - (avgpagelen/4)) < wantedpos && + (lastgranule + avgpagelen + (avgpagelen/4)) > wantedpos) { + + /*wanted offset found Yeay!*/ + + /*LOGF("GnPagefound:%d,%d,%d,%d\n",ret, + lastgranule,wantedpos,avgpagelen);*/ + + return ret; + + } else if (lastgranule > wantedpos) { /*too late, seek more*/ + if (offset != -1) { + LOGF("Toolate, returnanyway:%lld,%lld,%lld,%lld\n", + ret,lastgranule,wantedpos,avgpagelen); + return ret; + } + break; + } else{ /*if (spx_ogg_page_granulepos(&og)curpos; + spx_int64_t curoffset; + curoffset = *curbyteoffset; + spx_int64_t offset = 0; + spx_ogg_page og = {0,0,0,0}; + spx_int64_t avgpagelen = -1; + spx_int64_t lastgranule = -1; + + if(abs(pos-curpos)>10000 && headerssize>0 && curoffset-headerssize>10000) { + /* if seeking for more that 10sec, + headersize is known & more than 10kb is played, + try to guess a place to seek from the number of + bytes playe for this position, this works best when + the bitrate is relativly constant. + */ + + curoffset = (((*curbyteoffset-headerssize) * pos)/curpos)*98/100; + if (curoffset < 0) + curoffset=0; + + //spx_int64_t toffset=curoffset; + + ci->seek_buffer(curoffset); + + spx_ogg_sync_reset(oy); + + offset = get_next_page(oy,&og,-1); + + if (offset < 0) { /* could not find new page,use old offset */ + LOGF("Seek/guess/fault:%lld->-<-%d,%lld:%lld,%d,%ld,%d\n", + curpos,0,pos,offset,0, + ci->curpos,/*stream_length*/0); + + curoffset = *curbyteoffset; + + ci->seek_buffer(curoffset); + + spx_ogg_sync_reset(oy); + } else { + if (spx_ogg_page_granulepos(&og) == 0 && pos > 5000) { + LOGF("SEEK/guess/fault:%lld->-<-%lld,%lld:%lld,%d,%ld,%d\n", + curpos,spx_ogg_page_granulepos(&og),pos, + offset,0,ci->curpos,/*stream_length*/0); + + curoffset = *curbyteoffset; + + ci->seek_buffer(curoffset); + + spx_ogg_sync_reset(oy); + } else { + curoffset = offset; + curpos = spx_ogg_page_granulepos(&og); + } + } + } + + /* which way do we want to seek? */ + + if (curpos > pos) { /* backwards */ + offset = seek_backwards(oy,&og,pos); + + if (offset > 0) { + *curbyteoffset = curoffset; + return 1; + } + } else { /* forwards */ + + while ( (offset = get_next_page(oy,&og,-1)) > 0) { + if (lastgranule != -1) { + if (avgpagelen < 0) + avgpagelen = (spx_ogg_page_granulepos(&og) - lastgranule); + else + avgpagelen = ((spx_ogg_page_granulepos(&og) - lastgranule) + + avgpagelen) / 2; + } + + lastgranule = spx_ogg_page_granulepos(&og); + + if ( ((lastgranule - (avgpagelen/4)) < pos && ( lastgranule + + avgpagelen + (avgpagelen / 4)) > pos) || + lastgranule > pos) { + + /*wanted offset found Yeay!*/ + + *curbyteoffset = offset; + + return offset; + } + } + } + + ci->seek_buffer(*curbyteoffset); + + spx_ogg_sync_reset(oy); + + LOGF("Seek failed:%lld\n", offset); + + return -1; +} + +static void *process_header(spx_ogg_packet *op, + int enh_enabled, + int *frame_size, + int *rate, + int *nframes, + int *channels, + SpeexStereoState *stereo, + int *extra_headers + ) +{ + void *st; + const SpeexMode *mode; + SpeexHeader *header; + int modeID; + SpeexCallback callback; + + header = speex_packet_to_header((char*)op->packet, op->bytes); + + if (!header){ + DEBUGF ("Cannot read header\n"); + return NULL; + } + + if (header->mode >= SPEEX_NB_MODES){ + DEBUGF ("Mode does not exist\n"); + return NULL; + } + + modeID = header->mode; + + mode = speex_lib_get_mode(modeID); + + if (header->speex_version_id > 1) { + DEBUGF("Undecodeable bitstream"); + return NULL; + } + + if (mode->bitstream_version < header->mode_bitstream_version){ + DEBUGF("Undecodeable bitstream, newer bitstream"); + return NULL; + } + + if (mode->bitstream_version > header->mode_bitstream_version){ + DEBUGF("Too old bitstream"); + return NULL; + } + + st = speex_decoder_init(mode); + if (!st){ + DEBUGF("Decoder init failed"); + return NULL; + } + speex_decoder_ctl(st, SPEEX_SET_ENH, &enh_enabled); + speex_decoder_ctl(st, SPEEX_GET_FRAME_SIZE, frame_size); + + if (header->nb_channels!=1){ + callback.callback_id = SPEEX_INBAND_STEREO; + callback.func = speex_std_stereo_request_handler; + callback.data = stereo; + speex_decoder_ctl(st, SPEEX_SET_HANDLER, &callback); + } + *channels = header->nb_channels; + + if (!*rate) + *rate = header->rate; + + speex_decoder_ctl(st, SPEEX_SET_SAMPLING_RATE, rate); + + *nframes = header->frames_per_packet; + + *extra_headers = header->extra_headers; + + return st; +} + +/* this is the codec entry point */ +enum codec_status codec_main(enum codec_entry_call_reason reason) +{ + /* Nothing to do */ + return CODEC_OK; + (void)reason; +} + +/* this is called for each file to process */ +enum codec_status codec_run(void) +{ + int error = CODEC_ERROR; + + SpeexBits bits; + int eof = 0; + spx_ogg_sync_state oy; + spx_ogg_page og; + spx_ogg_packet op; + spx_ogg_stream_state os; + spx_int64_t page_granule = 0; + spx_int64_t cur_granule = 0; + int enh_enabled = 1; + int nframes = 2; + int eos = 0; + SpeexStereoState *stereo; + int channels = -1; + int samplerate = ci->id3->frequency; + int extra_headers = 0; + int stream_init = 0; + /* rockbox: comment 'set but unused' variables + int page_nb_packets; + */ + int frame_size; + int packet_count = 0; + int lookahead; + int headerssize = 0; + unsigned long strtoffset = ci->id3->offset; + void *st = NULL; + int j = 0; + intptr_t param; + + memset(&bits, 0, sizeof(bits)); + memset(&oy, 0, sizeof(oy)); + + /* Ogg handling still uses mallocs, so reset the malloc buffer per track */ + if (codec_init()) { + goto exit; + } + + ci->seek_buffer(0); + ci->set_elapsed(0); + + stereo = speex_stereo_state_init(); + spx_ogg_sync_init(&oy); + spx_ogg_alloc_buffer(&oy,2*CHUNKSIZE); + + codec_set_replaygain(ci->id3); + + eof = 0; + while (!eof) { + enum codec_command_action action = ci->get_command(¶m); + + if (action == CODEC_ACTION_HALT) + break; + + /*seek (seeks to the page before the position) */ + if (action == CODEC_ACTION_SEEK_TIME) { + if(samplerate!=0&&packet_count>1){ + LOGF("Speex seek page:%lld,%lld,%ld,%lld,%d\n", + ((spx_int64_t)param/1000) * + (spx_int64_t)samplerate, + page_granule, (long)param, + (page_granule/samplerate)*1000, samplerate); + + speex_seek_page_granule(((spx_int64_t)param/1000) * + (spx_int64_t)samplerate, + page_granule, &oy, headerssize); + } + + ci->set_elapsed(param); + ci->seek_complete(); + } + +next_page: + /*Get the ogg buffer for writing*/ + if(get_more_data(&oy)<1){/*read error*/ + goto done; + } + + /* Loop for all complete pages we got (most likely only one) */ + while (spx_ogg_sync_pageout(&oy, &og) == 1) { + int packet_no; + if (stream_init == 0) { + spx_ogg_stream_init(&os, spx_ogg_page_serialno(&og)); + stream_init = 1; + } + + /* Add page to the bitstream */ + spx_ogg_stream_pagein(&os, &og); + + page_granule = spx_ogg_page_granulepos(&og); + /* page_nb_packets = spx_ogg_page_packets(&og); */ + + cur_granule = page_granule; + + /* Extract all available packets */ + packet_no=0; + + while (!eos && spx_ogg_stream_packetout(&os, &op)==1){ + /* If first packet, process as Speex header */ + if (packet_count==0){ + st = process_header(&op, enh_enabled, &frame_size, + &samplerate, &nframes, &channels, + stereo, &extra_headers); + + speex_decoder_ctl(st, SPEEX_GET_LOOKAHEAD, &lookahead); + if (!nframes) + nframes=1; + + if (!st){ + goto done; + } + + ci->configure(DSP_SET_FREQUENCY, ci->id3->frequency); + ci->configure(DSP_SET_SAMPLE_DEPTH, 16); + if (channels == 2) { + ci->configure(DSP_SET_STEREO_MODE, STEREO_INTERLEAVED); + } else if (channels == 1) { + ci->configure(DSP_SET_STEREO_MODE, STEREO_MONO); + } + + /* Speex header in its own page, add the whole page + headersize */ + headerssize += og.header_len+og.body_len; + + } else if (packet_count<=1+extra_headers){ + /* add packet to headersize */ + headerssize += op.bytes; + + /* Ignore extra headers */ + } else { + if (packet_count <= 2+extra_headers) { + if (strtoffset) { + ci->seek_buffer(strtoffset); + spx_ogg_sync_reset(&oy); + packet_count++; + goto next_page; + } + } + packet_no++; + + if (op.e_o_s) /* End of stream condition */ + eos=1; + + /* Set Speex bitstream to point to Ogg packet */ + speex_bits_set_bit_buffer(&bits, (char *)op.packet, + op.bytes); + for (j = 0; j != nframes; j++){ + int ret; + + /* Decode frame */ + ret = speex_decode_int(st, &bits, output); + + if (ret == -1) + break; + + if (ret == -2) + break; + + if (speex_bits_remaining(&bits) < 0) + break; + + if (channels == 2) + speex_decode_stereo_int(output, frame_size, stereo); + + if (frame_size > 0) { + spx_int16_t *frame_start = output + lookahead; + + if (channels == 2) + frame_start += lookahead; + ci->pcmbuf_insert(frame_start, NULL, + frame_size - lookahead); + lookahead = 0; + /* 2 bytes/sample */ + cur_granule += frame_size / 2; + + ci->set_offset((long) ci->curpos); + + ci->set_elapsed((samplerate == 0) ? 0 : + cur_granule * 1000 / samplerate); + } + } + } + packet_count++; + } + } + } + + error = CODEC_OK; +done: + /* Clean things up for the next track */ + speex_bits_destroy(&bits); + + if (st) + speex_decoder_destroy(st); + + if (stream_init) + spx_ogg_stream_destroy(&os); + + spx_ogg_sync_destroy(&oy); + +exit: + return error; +} diff --git a/lib/rbcodec/codecs/tta.c b/lib/rbcodec/codecs/tta.c new file mode 100644 index 0000000000..dda33b3f5e --- /dev/null +++ b/lib/rbcodec/codecs/tta.c @@ -0,0 +1,127 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2010 Yoshihisa Uchida + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include "codeclib.h" +#include "codecs/libtta/ttalib.h" + +CODEC_HEADER + +/* + * TTA (True Audio) codec: + * + * References + * [1] TRUE AUDIO CODEC SOFTWARE http://true-audio.com/ + */ + +static int32_t samples[PCM_BUFFER_LENGTH * 2] IBSS_ATTR; + +/* this is the codec entry point */ +enum codec_status codec_main(enum codec_entry_call_reason reason) +{ + if (reason == CODEC_LOAD) { + /* Generic codec initialisation */ + ci->configure(DSP_SET_SAMPLE_DEPTH, TTA_OUTPUT_DEPTH - 1); + } + + return CODEC_OK; +} + +/* this is called for each file to process */ +enum codec_status codec_run(void) +{ + tta_info info; + unsigned int decodedsamples; + int endofstream; + int new_pos = 0; + int sample_count; + intptr_t param; + + if (codec_init()) + { + DEBUGF("codec_init() error\n"); + return CODEC_ERROR; + } + + ci->seek_buffer(0); + + if (set_tta_info(&info) < 0 || player_init(&info) < 0) + return CODEC_ERROR; + + codec_set_replaygain(ci->id3); + + ci->configure(DSP_SWITCH_FREQUENCY, ci->id3->frequency); + if (info.NCH == 2) { + ci->configure(DSP_SET_STEREO_MODE, STEREO_INTERLEAVED); + } else if (info.NCH == 1) { + ci->configure(DSP_SET_STEREO_MODE, STEREO_MONO); + } else { + DEBUGF("CODEC_ERROR: more than 2 channels\n"); + player_stop(); + return CODEC_ERROR; + } + + /* The main decoder loop */ + decodedsamples = 0; + endofstream = 0; + + if (ci->id3->offset > 0) + { + /* Need to save offset for later use (cleared indirectly by advance_buffer) */ + new_pos = set_position(ci->id3->offset, TTA_SEEK_POS); + if (new_pos >= 0) + decodedsamples = new_pos; + } + + ci->set_elapsed((uint64_t)info.LENGTH * 1000 * decodedsamples / info.DATALENGTH); + + while (!endofstream) + { + enum codec_command_action action = ci->get_command(¶m); + + if (action == CODEC_ACTION_HALT) + break; + + if (action == CODEC_ACTION_SEEK_TIME) + { + new_pos = set_position(param / SEEK_STEP, TTA_SEEK_TIME); + if (new_pos >= 0) + { + decodedsamples = new_pos; + } + + ci->set_elapsed((uint64_t)info.LENGTH * 1000 * decodedsamples / info.DATALENGTH); + ci->seek_complete(); + } + + sample_count = get_samples(samples); + if (sample_count < 0) + break; + + ci->pcmbuf_insert(samples, NULL, sample_count); + decodedsamples += sample_count; + if (decodedsamples >= info.DATALENGTH) + endofstream = 1; + ci->set_elapsed((uint64_t)info.LENGTH * 1000 * decodedsamples / info.DATALENGTH); + } + + player_stop(); + return CODEC_OK; +} diff --git a/lib/rbcodec/codecs/vgm.c b/lib/rbcodec/codecs/vgm.c new file mode 100644 index 0000000000..416f772f1d --- /dev/null +++ b/lib/rbcodec/codecs/vgm.c @@ -0,0 +1,142 @@ + +/* Ripped off from Game_Music_Emu 0.5.2. http://www.slack.net/~ant/ */ +/* Inflate code taken from WikiViewer plugin by Adam Gashlin */ + +#include + +#include "libgme/blargg_endian.h" +#include "libgme/vgm_emu.h" +#include "libgme/inflate/mallocer.h" +#include "libgme/inflate/inflate.h" + +CODEC_HEADER + +/* Maximum number of bytes to process in one iteration */ +#define CHUNK_SIZE (1024*4) +#define MAINMEMBUF 0 + +static int16_t samples[CHUNK_SIZE] IBSS_ATTR; +static struct Vgm_Emu vgm_emu; + +static void *inflatebuf; /* heap for gunzip */ +static char *songbuf; /* destination for uncompressed song */ +static uint32_t songbuflen=0; /* size of the song buffer */ +static uint32_t songlen=0; /* used size of the song buffer */ + +/****************** rockbox interface ******************/ + +/* this is the codec entry point */ +enum codec_status codec_main(enum codec_entry_call_reason reason) +{ + if (reason == CODEC_LOAD) { + /* we only render 16 bits */ + ci->configure(DSP_SET_SAMPLE_DEPTH, 16); + + /* 32 Khz, Interleaved stereo */ + ci->configure(DSP_SET_FREQUENCY, 44100); + ci->configure(DSP_SET_STEREO_MODE, STEREO_INTERLEAVED); + + Vgm_init(&vgm_emu); + Vgm_set_sample_rate(&vgm_emu, 44100); + } + + return CODEC_OK; +} + +/* this is called for each file to process */ +enum codec_status codec_run(void) +{ + blargg_err_t err; + uint8_t *buf; + size_t n; + intptr_t param; + + uint32_t elapsed_time = 0; + + DEBUGF("VGM: next_track\n"); + if (codec_init()) { + return CODEC_ERROR; + } + + codec_set_replaygain(ci->id3); + + /* Read the entire file */ + DEBUGF("VGM: request file\n"); + ci->seek_buffer(0); + buf = ci->request_buffer(&n, ci->filesize); + if (!buf) { + DEBUGF("VGM: file load failed\n"); + return CODEC_ERROR; + } + + /* If couldn't get the whole buffer + will trim file and put and 'end_command' + at the end*/ + if (n < (size_t)ci->filesize) { + DEBUGF("VGM: file was trimmed\n"); + } + + /* If is gzipped decompress it */ + if ( get_le16( buf ) == 0x8b1f ) { + wpw_init_mempool(MAINMEMBUF); + inflatebuf=wpw_malloc(MAINMEMBUF,0x13500); + + /* Will use available remaining memory + as output buffer */ + songbuflen=wpw_available(MAINMEMBUF); + songbuf=wpw_malloc(MAINMEMBUF,songbuflen); + + songlen=decompress(buf,n,songbuf,songbuflen,0,inflatebuf); + + if ((err = Vgm_load_mem(&vgm_emu, songbuf, songlen, true))) { + DEBUGF("VGM: Vgm_load_mem failed (%s)\n", err); + return CODEC_ERROR; + } + + /* Since metadata parser doesn't support VGZ + will set song length here */ + ci->id3->length = Track_get_length( &vgm_emu ); + } + else if ((err = Vgm_load_mem(&vgm_emu, buf, n, false))) { + DEBUGF("VGM: Vgm_load failed_mem (%s)\n", err); + return CODEC_ERROR; + } + + Vgm_start_track(&vgm_emu); + + /* for REPEAT_ONE we disable track limits */ + if (!ci->loop_track()) { + Track_set_fade(&vgm_emu, ci->id3->length - 4000, 4000); + } + + ci->set_elapsed(0); + + /* The main decoder loop */ + while (1) { + enum codec_command_action action = ci->get_command(¶m); + + if (action == CODEC_ACTION_HALT) + break; + + if (action == CODEC_ACTION_SEEK_TIME) { + ci->set_elapsed(param); + elapsed_time = param; + Track_seek(&vgm_emu, param); + ci->seek_complete(); + + /* Set fade again in case we seek to start of song */ + Track_set_fade(&vgm_emu, ci->id3->length - 4000, 4000); + } + + /* Generate audio buffer */ + err = Vgm_play(&vgm_emu, CHUNK_SIZE, samples); + if (err || Track_ended(&vgm_emu)) break; + + ci->pcmbuf_insert(samples, NULL, CHUNK_SIZE >> 1); + + elapsed_time += (CHUNK_SIZE / 2) * 10 / 441; + ci->set_elapsed(elapsed_time); + } + + return CODEC_OK; +} diff --git a/lib/rbcodec/codecs/vorbis.c b/lib/rbcodec/codecs/vorbis.c new file mode 100644 index 0000000000..944dd6d60c --- /dev/null +++ b/lib/rbcodec/codecs/vorbis.c @@ -0,0 +1,263 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2002 Björn Stenberg + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include "codeclib.h" +#include "libtremor/ivorbisfile.h" +#include "libtremor/ogg.h" +#ifdef SIMULATOR +#include +#endif + +CODEC_HEADER + +#if defined(CPU_ARM) || defined(CPU_COLDFIRE) || defined(CPU_MIPS) +#include +jmp_buf rb_jump_buf; +#endif + +/* Some standard functions and variables needed by Tremor */ + +static size_t read_handler(void *ptr, size_t size, size_t nmemb, void *datasource) +{ + (void)datasource; + return ci->read_filebuf(ptr, nmemb*size); +} + +static int initial_seek_handler(void *datasource, ogg_int64_t offset, int whence) +{ + (void)datasource; + (void)offset; + (void)whence; + return -1; +} + +static int seek_handler(void *datasource, ogg_int64_t offset, int whence) +{ + (void)datasource; + + if (whence == SEEK_CUR) { + offset += ci->curpos; + } else if (whence == SEEK_END) { + offset += ci->filesize; + } + + if (ci->seek_buffer(offset)) { + return 0; + } + + return -1; +} + +static int close_handler(void *datasource) +{ + (void)datasource; + return 0; +} + +static long tell_handler(void *datasource) +{ + (void)datasource; + return ci->curpos; +} + +/* This sets the DSP parameters based on the current logical bitstream + * (sampling rate, number of channels, etc). + */ +static bool vorbis_set_codec_parameters(OggVorbis_File *vf) +{ + vorbis_info *vi; + + vi = ov_info(vf, -1); + + if (vi == NULL) { + return false; + } + + ci->configure(DSP_SWITCH_FREQUENCY, ci->id3->frequency); + codec_set_replaygain(ci->id3); + + if (vi->channels == 2) { + ci->configure(DSP_SET_STEREO_MODE, STEREO_NONINTERLEAVED); + } else if (vi->channels == 1) { + ci->configure(DSP_SET_STEREO_MODE, STEREO_MONO); + } + + return true; +} + +/* this is the codec entry point */ +enum codec_status codec_main(enum codec_entry_call_reason reason) +{ + if (reason == CODEC_LOAD) { + if (codec_init()) + return CODEC_ERROR; + ci->configure(DSP_SET_SAMPLE_DEPTH, 24); + } + + return CODEC_OK; +} + +/* this is called for each file to process */ +enum codec_status codec_run(void) +{ + ov_callbacks callbacks; + OggVorbis_File vf; + ogg_int32_t **pcm; + + int error = CODEC_ERROR; + long n; + int current_section; + int previous_section; + int eof; + ogg_int64_t vf_offsets[2]; + ogg_int64_t vf_dataoffsets; + ogg_uint32_t vf_serialnos; + ogg_int64_t vf_pcmlengths[2]; + intptr_t param; + +#if defined(CPU_ARM) || defined(CPU_COLDFIRE) || defined(CPU_MIPS) + if (setjmp(rb_jump_buf) != 0) { + /* malloc failed; finish with this track */ + goto done; + } +#endif + ogg_malloc_init(); + + /* Create a decoder instance */ + callbacks.read_func = read_handler; + callbacks.seek_func = initial_seek_handler; + callbacks.tell_func = tell_handler; + callbacks.close_func = close_handler; + + ci->seek_buffer(0); + + /* Open a non-seekable stream */ + error = ov_open_callbacks(ci, &vf, NULL, 0, callbacks); + + /* If the non-seekable open was successful, we need to supply the missing + * data to make it seekable. This is a hack, but it's reasonable since we + * don't want to run the whole file through the buffer before we start + * playing. Using Tremor's seekable open routine would cause us to do + * this, so we pretend not to be seekable at first. Then we fill in the + * missing fields of vf with 1) information in ci->id3, and 2) info + * obtained by Tremor in the above ov_open call. + * + * Note that this assumes there is only ONE logical Vorbis bitstream in our + * physical Ogg bitstream. This is verified in metadata.c, well before we + * get here. + */ + if (!error) { + ogg_free(vf.offsets); + ogg_free(vf.dataoffsets); + ogg_free(vf.serialnos); + + vf.offsets = vf_offsets; + vf.dataoffsets = &vf_dataoffsets; + vf.serialnos = &vf_serialnos; + vf.pcmlengths = vf_pcmlengths; + + vf.offsets[0] = 0; + vf.offsets[1] = ci->id3->filesize; + vf.dataoffsets[0] = vf.offset; + vf.pcmlengths[0] = 0; + vf.pcmlengths[1] = ci->id3->samples; + vf.serialnos[0] = vf.current_serialno; + vf.callbacks.seek_func = seek_handler; + vf.seekable = 1; + vf.end = ci->id3->filesize; + vf.ready_state = OPENED; + vf.links = 1; + } else { + DEBUGF("Vorbis: ov_open failed: %d\n", error); + goto done; + } + + if (ci->id3->offset) { + ci->seek_buffer(ci->id3->offset); + ov_raw_seek(&vf, ci->id3->offset); + ci->set_elapsed(ov_time_tell(&vf)); + ci->set_offset(ov_raw_tell(&vf)); + } + else { + ci->set_elapsed(0); + } + + previous_section = -1; + eof = 0; + while (!eof) { + enum codec_command_action action = ci->get_command(¶m); + + if (action == CODEC_ACTION_HALT) + break; + + if (action == CODEC_ACTION_SEEK_TIME) { + if (ov_time_seek(&vf, param)) { + //ci->logf("ov_time_seek failed"); + } + + ci->set_elapsed(ov_time_tell(&vf)); + ci->seek_complete(); + } + + /* Read host-endian signed 24-bit PCM samples */ + n = ov_read_fixed(&vf, &pcm, 1024, ¤t_section); + + /* Change DSP and buffer settings for this bitstream */ + if (current_section != previous_section) { + if (!vorbis_set_codec_parameters(&vf)) { + goto done; + } else { + previous_section = current_section; + } + } + + if (n == 0) { + eof = 1; + } else if (n < 0) { + DEBUGF("Vorbis: Error decoding frame\n"); + } else { + ci->pcmbuf_insert(pcm[0], pcm[1], n); + ci->set_offset(ov_raw_tell(&vf)); + ci->set_elapsed(ov_time_tell(&vf)); + } + } + + error = CODEC_OK; +done: +#if 0 /* defined(SIMULATOR) */ + { + size_t bufsize; + void* buf = ci->codec_get_buffer(&bufsize); + + DEBUGF("Vorbis: Memory max: %zu\n", get_max_size(buf)); + } +#endif + ogg_malloc_destroy(); + + /* Clean things up for the next track */ + vf.dataoffsets = NULL; + vf.offsets = NULL; + vf.serialnos = NULL; + vf.pcmlengths = NULL; + ov_clear(&vf); + + return error; +} diff --git a/lib/rbcodec/codecs/vox.c b/lib/rbcodec/codecs/vox.c new file mode 100644 index 0000000000..279d003162 --- /dev/null +++ b/lib/rbcodec/codecs/vox.c @@ -0,0 +1,201 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2010 Yoshihisa Uchida + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include "codeclib.h" +#include "codecs/libpcm/support_formats.h" + +CODEC_HEADER + +/* vox codec (Dialogic telephony file formats) */ + +#define PCM_SAMPLE_SIZE (2048) + +static int32_t samples[PCM_SAMPLE_SIZE] IBSS_ATTR; + +static struct pcm_format format; +static uint32_t bytesdone; + +static uint8_t *read_buffer(size_t *realsize) +{ + uint8_t *buffer = (uint8_t *)ci->request_buffer(realsize, format.chunksize); + if (bytesdone + (*realsize) > format.numbytes) + *realsize = format.numbytes - bytesdone; + bytesdone += *realsize; + ci->advance_buffer(*realsize); + return buffer; +} + +/* this is the codec entry point */ +enum codec_status codec_main(enum codec_entry_call_reason reason) +{ + if (reason == CODEC_LOAD) { + /* Generic codec initialisation */ + ci->configure(DSP_SET_SAMPLE_DEPTH, PCM_OUTPUT_DEPTH-1); + } + + return CODEC_OK; +} + +/* this is called for each file to process */ +enum codec_status codec_run(void) +{ + uint32_t decodedsamples; + size_t n; + int bufcount; + int endofstream; + uint8_t *voxbuf; + off_t firstblockposn = 0; /* position of the first block in file */ + const struct pcm_codec *codec; + intptr_t param; + + if (codec_init()) { + DEBUGF("codec_init() error\n"); + return CODEC_ERROR; + } + + codec_set_replaygain(ci->id3); + + /* Need to save offset for later use (cleared indirectly by advance_buffer) */ + bytesdone = ci->id3->offset; + ci->seek_buffer(0); + + ci->memset(&format, 0, sizeof(struct pcm_format)); + + /* set format */ + format.channels = 1; + format.bitspersample = 4; + format.numbytes = ci->id3->filesize; + format.blockalign = 1; + + /* advance to first WAVE chunk */ + firstblockposn = 0; + decodedsamples = 0; + ci->advance_buffer(firstblockposn); + + /* + * get codec + * supports dialogic oki adpcm only + */ + codec = get_dialogic_oki_adpcm_codec(); + if (!codec) + { + DEBUGF("CODEC_ERROR: dialogic oki adpcm codec does not load.\n"); + return CODEC_ERROR; + } + + if (!codec->set_format(&format)) { + return CODEC_ERROR; + } + + if (format.numbytes == 0) { + DEBUGF("CODEC_ERROR: data size is 0\n"); + return CODEC_ERROR; + } + + /* check chunksize */ + if (format.chunksize * 2 > PCM_SAMPLE_SIZE) + format.chunksize = PCM_SAMPLE_SIZE / 2; + if (format.chunksize == 0) + { + DEBUGF("CODEC_ERROR: chunksize is 0\n"); + return CODEC_ERROR; + } + + ci->configure(DSP_SWITCH_FREQUENCY, ci->id3->frequency); + ci->configure(DSP_SET_STEREO_MODE, STEREO_MONO); + + /* make sure we're at the correct offset */ + if (bytesdone > (uint32_t) firstblockposn) { + /* Round down to previous block */ + struct pcm_pos *newpos = codec->get_seek_pos(bytesdone - firstblockposn, + PCM_SEEK_POS, &read_buffer); + + if (newpos->pos > format.numbytes) { + return CODEC_OK; + } + if (ci->seek_buffer(firstblockposn + newpos->pos)) + { + bytesdone = newpos->pos; + decodedsamples = newpos->samples; + } + } else { + /* already where we need to be */ + bytesdone = 0; + } + + ci->set_elapsed(decodedsamples*1000LL/ci->id3->frequency); + + /* The main decoder loop */ + endofstream = 0; + + while (!endofstream) { + enum codec_command_action action = ci->get_command(¶m); + + if (action == CODEC_ACTION_HALT) + break; + + if (action == CODEC_ACTION_SEEK_TIME) { + struct pcm_pos *newpos = codec->get_seek_pos(param, PCM_SEEK_TIME, + &read_buffer); + + if (newpos->pos > format.numbytes) + { + ci->set_elapsed(ci->id3->length); + ci->seek_complete(); + break; + } + + if (ci->seek_buffer(firstblockposn + newpos->pos)) + { + bytesdone = newpos->pos; + decodedsamples = newpos->samples; + } + + ci->set_elapsed(decodedsamples*1000LL/ci->id3->frequency); + ci->seek_complete(); + } + + voxbuf = (uint8_t *)ci->request_buffer(&n, format.chunksize); + if (n == 0) + break; /* End of stream */ + if (bytesdone + n > format.numbytes) { + n = format.numbytes - bytesdone; + endofstream = 1; + } + + if (codec->decode(voxbuf, n, samples, &bufcount) == CODEC_ERROR) + { + DEBUGF("codec error\n"); + return CODEC_ERROR; + } + + ci->pcmbuf_insert(samples, NULL, bufcount); + ci->advance_buffer(n); + bytesdone += n; + decodedsamples += bufcount; + + if (bytesdone >= format.numbytes) + endofstream = 1; + ci->set_elapsed(decodedsamples*1000LL/ci->id3->frequency); + } + + return CODEC_OK; +} diff --git a/lib/rbcodec/codecs/wav.c b/lib/rbcodec/codecs/wav.c new file mode 100644 index 0000000000..d20331bc6c --- /dev/null +++ b/lib/rbcodec/codecs/wav.c @@ -0,0 +1,437 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2005 Dave Chapman + * Copyright (C) 2009 Yoshihisa Uchida + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include "codeclib.h" +#include "codecs/libpcm/support_formats.h" + +CODEC_HEADER + +/* WAVE (RIFF) codec: + * + * For a good documentation on WAVE files, see: + * http://www.tsp.ece.mcgill.ca/MMSP/Documents/AudioFormats/WAVE/WAVE.html + * and + * http://www.sonicspot.com/guide/wavefiles.html + * + * For sample WAV files, see: + * http://www.tsp.ece.mcgill.ca/MMSP/Documents/AudioFormats/WAVE/Samples.html + * + */ + +#define PCM_SAMPLE_SIZE (4096*2) + +static int32_t samples[PCM_SAMPLE_SIZE] IBSS_ATTR; + +/* This codec support WAVE files with the following formats: */ +enum +{ + WAVE_FORMAT_UNKNOWN = 0x0000, /* Microsoft Unknown Wave Format */ + WAVE_FORMAT_PCM = 0x0001, /* Microsoft PCM Format */ + WAVE_FORMAT_ADPCM = 0x0002, /* Microsoft ADPCM Format */ + WAVE_FORMAT_IEEE_FLOAT = 0x0003, /* IEEE Float */ + WAVE_FORMAT_ALAW = 0x0006, /* Microsoft ALAW */ + WAVE_FORMAT_MULAW = 0x0007, /* Microsoft MULAW */ + WAVE_FORMAT_DVI_ADPCM = 0x0011, /* Intel's DVI ADPCM */ + WAVE_FORMAT_DIALOGIC_OKI_ADPCM = 0x0017, /* Dialogic OKI ADPCM */ + WAVE_FORMAT_YAMAHA_ADPCM = 0x0020, /* Yamaha ADPCM */ + WAVE_FORMAT_XBOX_ADPCM = 0x0069, /* XBOX ADPCM */ + IBM_FORMAT_MULAW = 0x0101, /* same as WAVE_FORMAT_MULAW */ + IBM_FORMAT_ALAW = 0x0102, /* same as WAVE_FORMAT_ALAW */ + WAVE_FORMAT_SWF_ADPCM = 0x5346, /* Adobe SWF ADPCM */ + WAVE_FORMAT_EXTENSIBLE = 0xFFFE +}; + +static const struct pcm_entry wave_codecs[] = { + { WAVE_FORMAT_UNKNOWN, 0 }, + { WAVE_FORMAT_PCM, get_linear_pcm_codec }, + { WAVE_FORMAT_ADPCM, get_ms_adpcm_codec }, + { WAVE_FORMAT_IEEE_FLOAT, get_ieee_float_codec }, + { WAVE_FORMAT_ALAW, get_itut_g711_alaw_codec }, + { WAVE_FORMAT_MULAW, get_itut_g711_mulaw_codec }, + { WAVE_FORMAT_DVI_ADPCM, get_dvi_adpcm_codec }, + { WAVE_FORMAT_DIALOGIC_OKI_ADPCM, get_dialogic_oki_adpcm_codec }, + { WAVE_FORMAT_YAMAHA_ADPCM, get_yamaha_adpcm_codec }, + { WAVE_FORMAT_XBOX_ADPCM, get_dvi_adpcm_codec }, + { IBM_FORMAT_MULAW, get_itut_g711_mulaw_codec }, + { IBM_FORMAT_ALAW, get_itut_g711_alaw_codec }, + { WAVE_FORMAT_SWF_ADPCM, get_swf_adpcm_codec }, +}; + +#define NUM_FORMATS 13 + +static const struct pcm_codec *get_wave_codec(uint32_t formattag) +{ + int i; + + for (i = 0; i < NUM_FORMATS; i++) + { + if (wave_codecs[i].format_tag == formattag) + { + if (wave_codecs[i].get_codec) + return wave_codecs[i].get_codec(); + return 0; + } + } + return 0; +} + +static struct pcm_format format; +static uint32_t bytesdone; + +static bool set_msadpcm_coeffs(const uint8_t *buf) +{ + int i; + int num; + int size; + + buf += 4; /* skip 'fmt ' */ + size = buf[0] | (buf[1] << 8) | (buf[1] << 16) | (buf[1] << 24); + if (size < 50) + { + DEBUGF("CODEC_ERROR: microsoft adpcm 'fmt ' chunk size=%lu < 50\n", + (unsigned long)size); + return false; + } + + /* get nNumCoef */ + buf += 24; + num = buf[0] | (buf[1] << 8); + + /* + * In many case, nNumCoef is 7. + * Depending upon the encoder, as for this value there is a possibility of + * increasing more. + * If you found the file where this value exceeds 7, please report. + */ + if (num != MSADPCM_NUM_COEFF) + { + DEBUGF("CODEC_ERROR: microsoft adpcm nNumCoef=%d != 7\n", num); + return false; + } + + /* get aCoeffs */ + buf += 2; + for (i = 0; i < MSADPCM_NUM_COEFF; i++) + { + format.coeffs[i][0] = buf[0] | (SE(buf[1]) << 8); + format.coeffs[i][1] = buf[2] | (SE(buf[3]) << 8); + buf += 4; + } + + return true; +} + +static uint8_t *read_buffer(size_t *realsize) +{ + uint8_t *buffer = (uint8_t *)ci->request_buffer(realsize, format.chunksize); + if (bytesdone + (*realsize) > format.numbytes) + *realsize = format.numbytes - bytesdone; + bytesdone += *realsize; + ci->advance_buffer(*realsize); + return buffer; +} + +/* this is the codec entry point */ +enum codec_status codec_main(enum codec_entry_call_reason reason) +{ + if (reason == CODEC_LOAD) { + /* Generic codec initialisation */ + ci->configure(DSP_SET_SAMPLE_DEPTH, PCM_OUTPUT_DEPTH-1); + } + + return CODEC_OK; +} + +/* this is called for each file to process */ +enum codec_status codec_run(void) +{ + uint32_t decodedsamples; + size_t n; + int bufcount; + int endofstream; + unsigned char *buf; + uint8_t *wavbuf; + off_t firstblockposn; /* position of the first block in file */ + const struct pcm_codec *codec; + uint32_t size; + intptr_t param; + + if (codec_init()) { + DEBUGF("codec_init() error\n"); + return CODEC_ERROR; + } + + codec_set_replaygain(ci->id3); + + /* Need to save offset for later use (cleared indirectly by advance_buffer) */ + bytesdone = ci->id3->offset; + + /* get RIFF chunk header */ + ci->seek_buffer(0); + buf = ci->request_buffer(&n, 12); + if (n < 12) { + DEBUGF("request_buffer error\n"); + return CODEC_ERROR; + } + if ((memcmp(buf, "RIFF", 4) != 0) || (memcmp(&buf[8], "WAVE", 4) != 0)) { + DEBUGF("CODEC_ERROR: missing riff header\n"); + return CODEC_ERROR; + } + + /* advance to first WAVE chunk */ + ci->advance_buffer(12); + + firstblockposn = 12; + ci->memset(&format, 0, sizeof(struct pcm_format)); + format.is_signed = true; + format.is_little_endian = true; + + decodedsamples = 0; + codec = 0; + + /* iterate over WAVE chunks until the 'data' chunk, which should be after the 'fmt ' chunk */ + while (true) { + /* get WAVE chunk header */ + buf = ci->request_buffer(&n, 1024); + if (n < 8) { + DEBUGF("data chunk request_buffer error\n"); + /* no more chunks, 'data' chunk must not have been found */ + return CODEC_ERROR; + } + + /* chunkSize */ + size = (buf[4]|(buf[5]<<8)|(buf[6]<<16)|(buf[7]<<24)); + if (memcmp(buf, "fmt ", 4) == 0) { + if (size < 16) { + DEBUGF("CODEC_ERROR: 'fmt ' chunk size=%lu < 16\n", + (unsigned long)size); + return CODEC_ERROR; + } + /* wFormatTag */ + format.formattag=buf[8]|(buf[9]<<8); + /* wChannels */ + format.channels=buf[10]|(buf[11]<<8); + /* skipping dwSamplesPerSec */ + /* skipping dwAvgBytesPerSec */ + /* wBlockAlign */ + format.blockalign=buf[20]|(buf[21]<<8); + /* wBitsPerSample */ + format.bitspersample=buf[22]|(buf[23]<<8); + if (format.formattag != WAVE_FORMAT_PCM) { + if (size < 18) { + /* this is not a fatal error with some formats, + * we'll see later if we can't decode it */ + DEBUGF("CODEC_WARNING: non-PCM WAVE (formattag=0x%x) " + "doesn't have ext. fmt descr (chunksize=%d<18).\n", + (unsigned int)format.formattag, (int)size); + } + else + { + if (format.formattag != WAVE_FORMAT_EXTENSIBLE) + format.samplesperblock = buf[26]|(buf[27]<<8); + else + { + format.size = buf[24]|(buf[25]<<8); + if (format.size < 22) { + DEBUGF("CODEC_ERROR: WAVE_FORMAT_EXTENSIBLE is " + "missing extension\n"); + return CODEC_ERROR; + } + /* wValidBitsPerSample */ + format.bitspersample = buf[26]|(buf[27]<<8); + /* skipping dwChannelMask (4bytes) */ + /* SubFormat (only get the first two bytes) */ + format.formattag = buf[32]|(buf[33]<<8); + } + } + } + + /* msadpcm specific */ + if (format.formattag == WAVE_FORMAT_ADPCM) + { + if (!set_msadpcm_coeffs(buf)) + { + return CODEC_ERROR; + } + } + + /* get codec */ + codec = get_wave_codec(format.formattag); + if (!codec) + { + DEBUGF("CODEC_ERROR: unsupported wave format 0x%x\n", + (unsigned int) format.formattag); + return CODEC_ERROR; + } + + /* riff 8bit linear pcm is unsigned */ + if (format.formattag == WAVE_FORMAT_PCM && format.bitspersample == 8) + format.is_signed = false; + + /* set format, parse codec specific tag, check format, and calculate chunk size */ + if (!codec->set_format(&format)) + { + return CODEC_ERROR; + } + } else if (memcmp(buf, "data", 4) == 0) { + format.numbytes = size; + /* advance to start of data */ + ci->advance_buffer(8); + firstblockposn += 8; + break; + } else if (memcmp(buf, "fact", 4) == 0) { + /* dwSampleLength */ + if (size >= 4) + format.totalsamples = + (buf[8]|(buf[9]<<8)|(buf[10]<<16)|(buf[11]<<24)); + } else { + DEBUGF("unknown WAVE chunk: '%c%c%c%c', size=%lu\n", + buf[0], buf[1], buf[2], buf[3], (unsigned long)size); + } + + /* go to next chunk (even chunk sizes must be padded) */ + size += 8 + (size & 0x01); + + ci->advance_buffer(size); + firstblockposn += size; + } + + if (!codec) + { + DEBUGF("CODEC_ERROR: 'fmt ' chunk not found\n"); + return CODEC_ERROR; + } + + /* common format check */ + if (format.channels == 0) { + DEBUGF("CODEC_ERROR: 'fmt ' chunk not found or 0-channels file\n"); + return CODEC_ERROR; + } + if (format.samplesperblock == 0) { + DEBUGF("CODEC_ERROR: 'fmt ' chunk not found or 0-wSamplesPerBlock file\n"); + return CODEC_ERROR; + } + if (format.blockalign == 0) + { + DEBUGF("CODEC_ERROR: 'fmt ' chunk not found or 0-blockalign file\n"); + return CODEC_ERROR; + } + if (format.numbytes == 0) { + DEBUGF("CODEC_ERROR: 'data' chunk not found or has zero-length\n"); + return CODEC_ERROR; + } + + /* check chunksize */ + if ((format.chunksize / format.blockalign) * format.samplesperblock * format.channels + > PCM_SAMPLE_SIZE) + format.chunksize = (PCM_SAMPLE_SIZE / format.blockalign) * format.blockalign; + if (format.chunksize == 0) + { + DEBUGF("CODEC_ERROR: chunksize is 0\n"); + return CODEC_ERROR; + } + + ci->configure(DSP_SWITCH_FREQUENCY, ci->id3->frequency); + if (format.channels == 2) { + ci->configure(DSP_SET_STEREO_MODE, STEREO_INTERLEAVED); + } else if (format.channels == 1) { + ci->configure(DSP_SET_STEREO_MODE, STEREO_MONO); + } else { + DEBUGF("CODEC_ERROR: more than 2 channels\n"); + return CODEC_ERROR; + } + + /* make sure we're at the correct offset */ + if (bytesdone > (uint32_t) firstblockposn) { + /* Round down to previous block */ + struct pcm_pos *newpos = codec->get_seek_pos(bytesdone - firstblockposn, + PCM_SEEK_POS, &read_buffer); + + if (newpos->pos > format.numbytes) + return CODEC_OK; + if (ci->seek_buffer(firstblockposn + newpos->pos)) + { + bytesdone = newpos->pos; + decodedsamples = newpos->samples; + } + } else { + /* already where we need to be */ + bytesdone = 0; + } + + ci->set_elapsed(decodedsamples*1000LL/ci->id3->frequency); + + /* The main decoder loop */ + endofstream = 0; + + while (!endofstream) { + enum codec_command_action action = ci->get_command(¶m); + + if (action == CODEC_ACTION_HALT) + break; + + if (action == CODEC_ACTION_SEEK_TIME) { + struct pcm_pos *newpos = codec->get_seek_pos(param, PCM_SEEK_TIME, + &read_buffer); + if (newpos->pos > format.numbytes) + { + ci->set_elapsed(ci->id3->length); + ci->seek_complete(); + break; + } + + if (ci->seek_buffer(firstblockposn + newpos->pos)) + { + bytesdone = newpos->pos; + decodedsamples = newpos->samples; + } + + ci->set_elapsed(decodedsamples*1000LL/ci->id3->frequency); + ci->seek_complete(); + } + + wavbuf = (uint8_t *)ci->request_buffer(&n, format.chunksize); + if (n == 0) + break; /* End of stream */ + if (bytesdone + n > format.numbytes) { + n = format.numbytes - bytesdone; + endofstream = 1; + } + + if (codec->decode(wavbuf, n, samples, &bufcount) == CODEC_ERROR) + { + DEBUGF("codec error\n"); + return CODEC_ERROR; + } + + ci->pcmbuf_insert(samples, NULL, bufcount); + ci->advance_buffer(n); + bytesdone += n; + decodedsamples += bufcount; + + if (bytesdone >= format.numbytes) + endofstream = 1; + ci->set_elapsed(decodedsamples*1000LL/ci->id3->frequency); + } + + return CODEC_OK; +} diff --git a/lib/rbcodec/codecs/wav64.c b/lib/rbcodec/codecs/wav64.c new file mode 100644 index 0000000000..184f39bf18 --- /dev/null +++ b/lib/rbcodec/codecs/wav64.c @@ -0,0 +1,441 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2010 Yoshihisa Uchida + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include "codeclib.h" +#include "codecs/libpcm/support_formats.h" + +CODEC_HEADER + +/* Wave64 codec + * + * References + * [1] VCS Aktiengesellschaft, Sony Wave64, Informations_about_Sony_Wave64.pdf + */ + +#define PCM_SAMPLE_SIZE (4096*2) + +static int32_t samples[PCM_SAMPLE_SIZE] IBSS_ATTR; + +/* Wave64 GUIDs */ +#define WAVE64_GUID_RIFF "riff\x2e\x91\xcf\x11\xa5\xd6\x28\xdb\x04\xc1\x00\x00" +#define WAVE64_GUID_WAVE "wave\xf3\xac\xd3\x11\x8c\xd1\x00\xc0\x4f\x8e\xdb\x8a" +#define WAVE64_GUID_FMT "fmt \xf3\xac\xd3\x11\x8c\xd1\x00\xc0\x4f\x8e\xdb\x8a" +#define WAVE64_GUID_FACT "fact\xf3\xac\xd3\x11\x8c\xd1\x00\xc0\x4f\x8e\xdb\x8a" +#define WAVE64_GUID_DATA "data\xf3\xac\xd3\x11\x8c\xd1\x00\xc0\x4f\x8e\xdb\x8a" + +/* This codec support WAVE files with the following formats: */ +enum +{ + WAVE_FORMAT_UNKNOWN = 0x0000, /* Microsoft Unknown Wave Format */ + WAVE_FORMAT_PCM = 0x0001, /* Microsoft PCM Format */ + WAVE_FORMAT_ADPCM = 0x0002, /* Microsoft ADPCM Format */ + WAVE_FORMAT_IEEE_FLOAT = 0x0003, /* IEEE Float */ + WAVE_FORMAT_ALAW = 0x0006, /* Microsoft ALAW */ + WAVE_FORMAT_MULAW = 0x0007, /* Microsoft MULAW */ + WAVE_FORMAT_DVI_ADPCM = 0x0011, /* Intel's DVI ADPCM */ + WAVE_FORMAT_DIALOGIC_OKI_ADPCM = 0x0017, /* Dialogic OKI ADPCM */ + WAVE_FORMAT_YAMAHA_ADPCM = 0x0020, /* Yamaha ADPCM */ + WAVE_FORMAT_XBOX_ADPCM = 0x0069, /* XBOX ADPCM */ + IBM_FORMAT_MULAW = 0x0101, /* same as WAVE_FORMAT_MULAW */ + IBM_FORMAT_ALAW = 0x0102, /* same as WAVE_FORMAT_ALAW */ + WAVE_FORMAT_SWF_ADPCM = 0x5346, /* Adobe SWF ADPCM */ + WAVE_FORMAT_EXTENSIBLE = 0xFFFE +}; + +const struct pcm_entry wave_codecs[] = { + { WAVE_FORMAT_UNKNOWN, 0 }, + { WAVE_FORMAT_PCM, get_linear_pcm_codec }, + { WAVE_FORMAT_ADPCM, get_ms_adpcm_codec }, + { WAVE_FORMAT_IEEE_FLOAT, get_ieee_float_codec }, + { WAVE_FORMAT_ALAW, get_itut_g711_alaw_codec }, + { WAVE_FORMAT_MULAW, get_itut_g711_mulaw_codec }, + { WAVE_FORMAT_DVI_ADPCM, get_dvi_adpcm_codec }, + { WAVE_FORMAT_DIALOGIC_OKI_ADPCM, get_dialogic_oki_adpcm_codec }, + { WAVE_FORMAT_YAMAHA_ADPCM, get_yamaha_adpcm_codec }, + { WAVE_FORMAT_XBOX_ADPCM, get_dvi_adpcm_codec }, + { IBM_FORMAT_MULAW, get_itut_g711_mulaw_codec }, + { IBM_FORMAT_ALAW, get_itut_g711_alaw_codec }, + { WAVE_FORMAT_SWF_ADPCM, get_swf_adpcm_codec }, +}; + +#define NUM_FORMATS 13 + +static const struct pcm_codec *get_wave_codec(uint32_t formattag) +{ + int i; + + for (i = 0; i < NUM_FORMATS; i++) + { + if (wave_codecs[i].format_tag == formattag) + { + if (wave_codecs[i].get_codec) + return wave_codecs[i].get_codec(); + return 0; + } + } + return 0; +} + +static struct pcm_format format; +static uint32_t bytesdone; + +/* Read an unaligned 64-bit little endian unsigned integer from buffer. */ +static uint64_t get_uint64_le(void* buf) +{ + unsigned char* p = (unsigned char*) buf; + + return p[0] | (p[1] << 8) | (p[2] << 16) | (p[3] << 24) | ((uint64_t)p[4] << 32) | + ((uint64_t)p[5] << 40) | ((uint64_t)p[6] << 48) | ((uint64_t)p[7] << 56); +} + +static bool set_msadpcm_coeffs(unsigned char *buf) +{ + int i; + int num; + uint64_t size; + + buf += 16; /* skip 'fmt ' GUID */ + size = get_uint64_le(buf); + if (size < 50) + { + DEBUGF("CODEC_ERROR: microsoft adpcm 'fmt ' chunk size=%d < 50\n", (int)size); + return false; + } + + /* get nNumCoef */ + buf += 28; + num = buf[0] | (buf[1] << 8); + + /* + * In many case, nNumCoef is 7. + * Depending upon the encoder, as for this value there is a possibility of + * increasing more. + * If you found the file where this value exceeds 7, please report. + */ + if (num != MSADPCM_NUM_COEFF) + { + DEBUGF("CODEC_ERROR: microsoft adpcm nNumCoef=%d != 7\n", num); + return false; + } + + /* get aCoeffs */ + buf += 2; + for (i = 0; i < MSADPCM_NUM_COEFF; i++) + { + format.coeffs[i][0] = buf[0] | (SE(buf[1]) << 8); + format.coeffs[i][1] = buf[2] | (SE(buf[3]) << 8); + buf += 4; + } + + return true; +} + +static uint8_t *read_buffer(size_t *realsize) +{ + uint8_t *buffer = (uint8_t *)ci->request_buffer(realsize, format.chunksize); + if (bytesdone + (*realsize) > format.numbytes) + *realsize = format.numbytes - bytesdone; + bytesdone += *realsize; + ci->advance_buffer(*realsize); + return buffer; +} + +/* this is the codec entry point */ +enum codec_status codec_main(enum codec_entry_call_reason reason) +{ + if (reason == CODEC_LOAD) { + /* Generic codec initialisation */ + ci->configure(DSP_SET_SAMPLE_DEPTH, PCM_OUTPUT_DEPTH-1); + } + + return CODEC_OK; +} + +/* this is called for each file to process */ +enum codec_status codec_run(void) +{ + uint32_t decodedsamples; + size_t n; + int bufcount; + int endofstream; + unsigned char *buf; + uint8_t *wavbuf; + off_t firstblockposn; /* position of the first block in file */ + const struct pcm_codec *codec; + uint64_t size; + intptr_t param; + + if (codec_init()) { + DEBUGF("codec_init() error\n"); + return CODEC_ERROR; + } + + codec_set_replaygain(ci->id3); + + /* Need to save offset for later use (cleared indirectly by advance_buffer) */ + bytesdone = ci->id3->offset; + + /* get RIFF chunk header */ + ci->seek_buffer(0); + buf = ci->request_buffer(&n, 40); + if (n < 40) { + DEBUGF("request_buffer error\n"); + return CODEC_ERROR; + } + if ((memcmp(buf , WAVE64_GUID_RIFF, 16) != 0) || + (memcmp(buf+24, WAVE64_GUID_WAVE, 16) != 0)) + { + return CODEC_ERROR; + } + + /* advance to first WAVE chunk */ + ci->advance_buffer(40); + + firstblockposn = 40; + ci->memset(&format, 0, sizeof(struct pcm_format)); + format.is_signed = true; + format.is_little_endian = true; + + decodedsamples = 0; + codec = 0; + + /* iterate over WAVE chunks until the 'data' chunk, which should be after the 'fmt ' chunk */ + while (true) { + /* get WAVE chunk header */ + buf = ci->request_buffer(&n, 1024); + if (n < 8) { + DEBUGF("data chunk request_buffer error\n"); + /* no more chunks, 'data' chunk must not have been found */ + return CODEC_ERROR; + } + + /* chunkSize */ + size = get_uint64_le(buf+16) - 24; + if (memcmp(buf, WAVE64_GUID_FMT, 16) == 0) { + if (size < 16) { + DEBUGF("CODEC_ERROR: 'fmt ' chunk size=%d < 16\n", (int)size); + return CODEC_ERROR; + } + /* wFormatTag */ + format.formattag=buf[24]|(buf[25]<<8); + /* wChannels */ + format.channels=buf[26]|(buf[27]<<8); + /* skipping dwSamplesPerSec */ + /* skipping dwAvgBytesPerSec */ + /* wBlockAlign */ + format.blockalign=buf[36]|(buf[37]<<8); + /* wBitsPerSample */ + format.bitspersample=buf[38]|(buf[39]<<8); + if (format.formattag != WAVE_FORMAT_PCM) { + if (size < 18) { + /* this is not a fatal error with some formats, + * we'll see later if we can't decode it */ + DEBUGF("CODEC_WARNING: non-PCM WAVE (formattag=0x%x) " + "doesn't have ext. fmt descr (chunksize=%d<18).\n", + (unsigned int)format.formattag, (int)size); + } + else + { + if (format.formattag != WAVE_FORMAT_EXTENSIBLE) + format.samplesperblock = buf[42]|(buf[43]<<8); + else { + format.size = buf[40]|(buf[41]<<8); + if (format.size < 22) { + DEBUGF("CODEC_ERROR: WAVE_FORMAT_EXTENSIBLE is " + "missing extension\n"); + return CODEC_ERROR; + } + /* wValidBitsPerSample */ + format.bitspersample = buf[42]|(buf[43]<<8); + /* skipping dwChannelMask (4bytes) */ + /* SubFormat (only get the first two bytes) */ + format.formattag = buf[48]|(buf[49]<<8); + } + } + } + + /* msadpcm specific */ + if (format.formattag == WAVE_FORMAT_ADPCM) + { + if (!set_msadpcm_coeffs(buf)) + return CODEC_ERROR; + } + + /* get codec */ + codec = get_wave_codec(format.formattag); + if (!codec) + { + DEBUGF("CODEC_ERROR: unsupported wave format 0x%x\n", + (unsigned int) format.formattag); + return CODEC_ERROR; + } + + /* riff 8bit linear pcm is unsigned */ + if (format.formattag == WAVE_FORMAT_PCM && format.bitspersample == 8) + format.is_signed = false; + + /* check format, and calculate chunk size */ + if (!codec->set_format(&format)) + return CODEC_ERROR; + } else if (memcmp(buf, WAVE64_GUID_DATA, 16) == 0) { + format.numbytes = size; + /* advance to start of data */ + ci->advance_buffer(24); + firstblockposn += 24; + break; + } else if (memcmp(buf, WAVE64_GUID_FACT, 16) == 0) { + /* skip 'fact' chunk */ + } else { + DEBUGF("unknown Wave64 chunk: " + "'%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x'\n", + buf[0], buf[1], buf[ 2], buf[ 3], buf[ 4], buf[ 5], buf[ 6], buf[ 7], + buf[8], buf[9], buf[10], buf[11], buf[12], buf[13], buf[14], buf[15]); + } + + /* go to next chunk (8byte bound) */ + size += 24 + ((1 + ~size) & 0x07); + + ci->advance_buffer(size); + firstblockposn += size; + } + + if (!codec) + { + DEBUGF("CODEC_ERROR: 'fmt ' chunk not found\n"); + return CODEC_ERROR; + } + + /* common format check */ + if (format.channels == 0) { + DEBUGF("CODEC_ERROR: 'fmt ' chunk not found or 0-channels file\n"); + return CODEC_ERROR; + } + if (format.samplesperblock == 0) { + DEBUGF("CODEC_ERROR: 'fmt ' chunk not found or 0-wSamplesPerBlock file\n"); + return CODEC_ERROR; + } + if (format.blockalign == 0) + { + DEBUGF("CODEC_ERROR: 'fmt ' chunk not found or 0-blockalign file\n"); + return CODEC_ERROR; + } + if (format.numbytes == 0) { + DEBUGF("CODEC_ERROR: 'data' chunk not found or has zero-length\n"); + return CODEC_ERROR; + } + + /* check chunksize */ + if ((format.chunksize / format.blockalign) * format.samplesperblock * format.channels + > PCM_SAMPLE_SIZE) + format.chunksize = (PCM_SAMPLE_SIZE / format.blockalign) * format.blockalign; + if (format.chunksize == 0) + { + DEBUGF("CODEC_ERROR: chunksize is 0\n"); + return CODEC_ERROR; + } + + ci->configure(DSP_SWITCH_FREQUENCY, ci->id3->frequency); + if (format.channels == 2) { + ci->configure(DSP_SET_STEREO_MODE, STEREO_INTERLEAVED); + } else if (format.channels == 1) { + ci->configure(DSP_SET_STEREO_MODE, STEREO_MONO); + } else { + DEBUGF("CODEC_ERROR: more than 2 channels\n"); + return CODEC_ERROR; + } + + /* make sure we're at the correct offset */ + if (bytesdone > (uint32_t) firstblockposn) { + /* Round down to previous block */ + struct pcm_pos *newpos = codec->get_seek_pos(bytesdone - firstblockposn, + PCM_SEEK_POS, &read_buffer); + + if (newpos->pos > format.numbytes) { + return CODEC_OK; + } + if (ci->seek_buffer(firstblockposn + newpos->pos)) + { + bytesdone = newpos->pos; + decodedsamples = newpos->samples; + } + } else { + /* already where we need to be */ + bytesdone = 0; + } + + ci->set_elapsed(decodedsamples*1000LL/ci->id3->frequency); + + /* The main decoder loop */ + endofstream = 0; + + while (!endofstream) { + enum codec_command_action action = ci->get_command(¶m); + + if (action == CODEC_ACTION_HALT) + break; + + if (action == CODEC_ACTION_SEEK_TIME) { + struct pcm_pos *newpos = codec->get_seek_pos(param, PCM_SEEK_TIME, + &read_buffer); + + if (newpos->pos > format.numbytes) + { + ci->set_elapsed(ci->id3->length); + ci->seek_complete(); + break; + } + + if (ci->seek_buffer(firstblockposn + newpos->pos)) + { + bytesdone = newpos->pos; + decodedsamples = newpos->samples; + } + + ci->set_elapsed(decodedsamples*1000LL/ci->id3->frequency); + ci->seek_complete(); + } + + wavbuf = (uint8_t *)ci->request_buffer(&n, format.chunksize); + if (n == 0) + break; /* End of stream */ + if (bytesdone + n > format.numbytes) { + n = format.numbytes - bytesdone; + endofstream = 1; + } + + if (codec->decode(wavbuf, n, samples, &bufcount) == CODEC_ERROR) + { + DEBUGF("codec error\n"); + return CODEC_ERROR; + } + + ci->pcmbuf_insert(samples, NULL, bufcount); + ci->advance_buffer(n); + bytesdone += n; + decodedsamples += bufcount; + + if (bytesdone >= format.numbytes) + endofstream = 1; + ci->set_elapsed(decodedsamples*1000LL/ci->id3->frequency); + } + + return CODEC_OK; +} diff --git a/lib/rbcodec/codecs/wav_enc.c b/lib/rbcodec/codecs/wav_enc.c new file mode 100644 index 0000000000..e4afeaf93c --- /dev/null +++ b/lib/rbcodec/codecs/wav_enc.c @@ -0,0 +1,386 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2006 Antonius Hellmann + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include +#include "codeclib.h" + +CODEC_ENC_HEADER + +struct riff_header +{ + uint8_t riff_id[4]; /* 00h - "RIFF" */ + uint32_t riff_size; /* 04h - sz following headers + data_size */ + /* format header */ + uint8_t format[4]; /* 08h - "WAVE" */ + uint8_t format_id[4]; /* 0Ch - "fmt " */ + uint32_t format_size; /* 10h - 16 for PCM (sz format data) */ + /* format data */ + uint16_t audio_format; /* 14h - 1=PCM */ + uint16_t num_channels; /* 16h - 1=M, 2=S, etc. */ + uint32_t sample_rate; /* 18h - HZ */ + uint32_t byte_rate; /* 1Ch - num_channels*sample_rate*bits_per_sample/8 */ + uint16_t block_align; /* 20h - num_channels*bits_per_samples/8 */ + uint16_t bits_per_sample; /* 22h - 8=8 bits, 16=16 bits, etc. */ + /* Not for audio_format=1 (PCM) */ +/* unsigned short extra_param_size; 24h - size of extra data */ +/* unsigned char *extra_params; */ + /* data header */ + uint8_t data_id[4]; /* 24h - "data" */ + uint32_t data_size; /* 28h - num_samples*num_channels*bits_per_sample/8 */ +/* unsigned char *data; 2ch - actual sound data */ +} __attribute__((packed)); + +#define RIFF_FMT_HEADER_SIZE 12 /* format -> format_size */ +#define RIFF_FMT_DATA_SIZE 16 /* audio_format -> bits_per_sample */ +#define RIFF_DATA_HEADER_SIZE 8 /* data_id -> data_size */ + +#define PCM_DEPTH_BYTES 2 +#define PCM_DEPTH_BITS 16 +#define PCM_SAMP_PER_CHUNK 2048 +#define PCM_CHUNK_SIZE (PCM_SAMP_PER_CHUNK*4) + +static int num_channels IBSS_ATTR; +static int rec_mono_mode IBSS_ATTR; +static uint32_t sample_rate; +static uint32_t enc_size; +static int32_t err IBSS_ATTR; + +static const struct riff_header riff_header = +{ + /* "RIFF" header */ + { 'R', 'I', 'F', 'F' }, /* riff_id */ + 0, /* riff_size (*) */ + /* format header */ + { 'W', 'A', 'V', 'E' }, /* format */ + { 'f', 'm', 't', ' ' }, /* format_id */ + htole32(16), /* format_size */ + /* format data */ + htole16(1), /* audio_format */ + 0, /* num_channels (*) */ + 0, /* sample_rate (*) */ + 0, /* byte_rate (*) */ + 0, /* block_align (*) */ + htole16(PCM_DEPTH_BITS), /* bits_per_sample */ + /* data header */ + { 'd', 'a', 't', 'a' }, /* data_id */ + 0 /* data_size (*) */ + /* (*) updated during ENC_END_FILE event */ +}; + +/* called version often - inline */ +static inline bool is_file_data_ok(struct enc_file_event_data *data) ICODE_ATTR; +static inline bool is_file_data_ok(struct enc_file_event_data *data) +{ + return data->rec_file >= 0 && (long)data->chunk->flags >= 0; +} /* is_file_data_ok */ + +/* called version often - inline */ +static inline bool on_write_chunk(struct enc_file_event_data *data) ICODE_ATTR; +static inline bool on_write_chunk(struct enc_file_event_data *data) +{ + if (!is_file_data_ok(data)) + return false; + + if (data->chunk->enc_data == NULL) + { +#ifdef ROCKBOX_HAS_LOGF + ci->logf("wav enc: NULL data"); +#endif + return true; + } + + if (ci->write(data->rec_file, data->chunk->enc_data, + data->chunk->enc_size) != (ssize_t)data->chunk->enc_size) + return false; + + data->num_pcm_samples += data->chunk->num_pcm; + return true; +} /* on_write_chunk */ + +static bool on_start_file(struct enc_file_event_data *data) +{ + if ((data->chunk->flags & CHUNKF_ERROR) || *data->filename == '\0') + return false; + + data->rec_file = ci->open(data->filename, O_RDWR|O_CREAT|O_TRUNC, 0666); + + if (data->rec_file < 0) + return false; + + /* reset sample count */ + data->num_pcm_samples = 0; + + /* write template header */ + if (ci->write(data->rec_file, &riff_header, sizeof (riff_header)) + != sizeof (riff_header)) + { + return false; + } + + data->new_enc_size += sizeof (riff_header); + return true; +} /* on_start_file */ + +static bool on_end_file(struct enc_file_event_data *data) +{ + /* update template header */ + struct riff_header hdr; + uint32_t data_size; + + if (data->rec_file < 0) + return false; /* file already closed, nothing more we can do */ + + /* always _try_ to write the file header, even on error */ + if ((ci->lseek(data->rec_file, 0, SEEK_SET)) || + (ci->read(data->rec_file, &hdr, sizeof (hdr)) != sizeof (hdr))) + { + return false; + } + + data_size = data->num_pcm_samples*num_channels*PCM_DEPTH_BYTES; + + /* "RIFF" header */ + hdr.riff_size = htole32(RIFF_FMT_HEADER_SIZE + RIFF_FMT_DATA_SIZE + + RIFF_DATA_HEADER_SIZE + data_size); + + /* format data */ + hdr.num_channels = htole16(num_channels); + hdr.sample_rate = htole32(sample_rate); + hdr.byte_rate = htole32(sample_rate*num_channels* PCM_DEPTH_BYTES); + hdr.block_align = htole16(num_channels*PCM_DEPTH_BYTES); + + /* data header */ + hdr.data_size = htole32(data_size); + + if (ci->lseek(data->rec_file, 0, SEEK_SET) != 0 || + ci->write(data->rec_file, &hdr, sizeof (hdr)) != sizeof (hdr) || + ci->close(data->rec_file) != 0) + { + return false; + } + + data->rec_file = -1; + + return true; +} /* on_end_file */ + +STATICIRAM void enc_events_callback(enum enc_events event, void *data) + ICODE_ATTR; +STATICIRAM void enc_events_callback(enum enc_events event, void *data) +{ + switch (event) + { + case ENC_WRITE_CHUNK: + if (on_write_chunk((struct enc_file_event_data *)data)) + return; + + break; + + case ENC_START_FILE: + if (on_start_file((struct enc_file_event_data *)data)) + return; + + break; + + case ENC_END_FILE: + if (on_end_file((struct enc_file_event_data *)data)) + return; + + break; + + default: + return; + } + + /* Something failed above. Signal error back to core. */ + ((struct enc_file_event_data *)data)->chunk->flags |= CHUNKF_ERROR; +} /* enc_events_callback */ + +/* convert native pcm samples to wav format samples */ +static inline void sample_to_mono(uint32_t **src, uint32_t **dst) +{ + int32_t lr1, lr2; + + switch(rec_mono_mode) + { + case 1: + /* mono = L */ + lr1 = *(*src)++; + lr1 = lr1 >> 16; + lr2 = *(*src)++; + lr2 = lr2 >> 16; + break; + case 2: + /* mono = R */ + lr1 = *(*src)++; + lr1 = (uint16_t)lr1; + lr2 = *(*src)++; + lr2 = (uint16_t)lr2; + break; + case 0: + default: + /* mono = (L+R)/2 */ + lr1 = *(*src)++; + lr1 = (int16_t)lr1 + (lr1 >> 16) + err; + err = lr1 & 1; + lr1 >>= 1; + + lr2 = *(*src)++; + lr2 = (int16_t)lr2 + (lr2 >> 16) + err; + err = lr2 & 1; + lr2 >>= 1; + break; + } + *(*dst)++ = htole32((lr2 << 16) | (uint16_t)lr1); +} /* sample_to_mono */ + +STATICIRAM void chunk_to_wav_format(uint32_t *src, uint32_t *dst) ICODE_ATTR; +STATICIRAM void chunk_to_wav_format(uint32_t *src, uint32_t *dst) +{ + if (num_channels == 1) + { + /* On big endian: + * |LLLLLLLLllllllll|RRRRRRRRrrrrrrrr| + * |LLLLLLLLllllllll|RRRRRRRRrrrrrrrr| => + * |mmmmmmmmMMMMMMMM|mmmmmmmmMMMMMMMM| + * + * On little endian: + * |llllllllLLLLLLLL|rrrrrrrrRRRRRRRR| + * |llllllllLLLLLLLL|rrrrrrrrRRRRRRRR| => + * |mmmmmmmmMMMMMMMM|mmmmmmmmMMMMMMMM| + */ + uint32_t *src_end = src + PCM_SAMP_PER_CHUNK; + + do + { + sample_to_mono(&src, &dst); + sample_to_mono(&src, &dst); + sample_to_mono(&src, &dst); + sample_to_mono(&src, &dst); + sample_to_mono(&src, &dst); + sample_to_mono(&src, &dst); + sample_to_mono(&src, &dst); + sample_to_mono(&src, &dst); + } + while (src < src_end); + } + else + { +#ifdef ROCKBOX_BIG_ENDIAN + /* |LLLLLLLLllllllll|RRRRRRRRrrrrrrrr| => + * |llllllllLLLLLLLL|rrrrrrrrRRRRRRRR| + */ + uint32_t *src_end = src + PCM_SAMP_PER_CHUNK; + + do + { + *dst++ = swap_odd_even32(*src++); + *dst++ = swap_odd_even32(*src++); + *dst++ = swap_odd_even32(*src++); + *dst++ = swap_odd_even32(*src++); + *dst++ = swap_odd_even32(*src++); + *dst++ = swap_odd_even32(*src++); + *dst++ = swap_odd_even32(*src++); + *dst++ = swap_odd_even32(*src++); + } + while (src < src_end); +#else + /* |llllllllLLLLLLLL|rrrrrrrrRRRRRRRR| => + * |llllllllLLLLLLLL|rrrrrrrrRRRRRRRR| + */ + ci->memcpy(dst, src, PCM_CHUNK_SIZE); +#endif + } +} /* chunk_to_wav_format */ + +static bool init_encoder(void) +{ + struct enc_inputs inputs; + struct enc_parameters params; + + if (ci->enc_get_inputs == NULL || + ci->enc_set_parameters == NULL || + ci->enc_get_chunk == NULL || + ci->enc_finish_chunk == NULL || + ci->enc_get_pcm_data == NULL ) + return false; + + ci->enc_get_inputs(&inputs); + + if (inputs.config->afmt != AFMT_PCM_WAV) + return false; + + sample_rate = inputs.sample_rate; + num_channels = inputs.num_channels; + rec_mono_mode = inputs.rec_mono_mode; + err = 0; + + /* configure the buffer system */ + params.afmt = AFMT_PCM_WAV; + enc_size = PCM_CHUNK_SIZE*inputs.num_channels / 2; + params.chunk_size = enc_size; + params.enc_sample_rate = sample_rate; + params.reserve_bytes = 0; + params.events_callback = enc_events_callback; + ci->enc_set_parameters(¶ms); + + return true; +} /* init_encoder */ + +/* this is the codec entry point */ +enum codec_status codec_main(enum codec_entry_call_reason reason) +{ + if (reason == CODEC_LOAD) { + if (!init_encoder()) + return CODEC_ERROR; + } + else if (reason == CODEC_UNLOAD) { + /* reset parameters to initial state */ + ci->enc_set_parameters(NULL); + } + + return CODEC_OK; +} + +/* this is called for each file to process */ +enum codec_status codec_run(void) +{ + /* main encoding loop */ + while(ci->get_command(NULL) != CODEC_ACTION_HALT) + { + uint32_t *src = (uint32_t *)ci->enc_get_pcm_data(PCM_CHUNK_SIZE); + struct enc_chunk_hdr *chunk; + + if(src == NULL) + continue; + + chunk = ci->enc_get_chunk(); + chunk->enc_size = enc_size; + chunk->num_pcm = PCM_SAMP_PER_CHUNK; + chunk->enc_data = ENC_CHUNK_SKIP_HDR(chunk->enc_data, chunk); + + chunk_to_wav_format(src, (uint32_t *)chunk->enc_data); + + ci->enc_finish_chunk(); + } + + return CODEC_OK; +} diff --git a/lib/rbcodec/codecs/wavpack.c b/lib/rbcodec/codecs/wavpack.c new file mode 100644 index 0000000000..4d42391fc1 --- /dev/null +++ b/lib/rbcodec/codecs/wavpack.c @@ -0,0 +1,127 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2005 David Bryant + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include "codeclib.h" +#include "libwavpack/wavpack.h" + +CODEC_HEADER + +#define BUFFER_SIZE 4096 + +static int32_t temp_buffer [BUFFER_SIZE] IBSS_ATTR; + +static int32_t read_callback (void *buffer, int32_t bytes) +{ + int32_t retval = ci->read_filebuf (buffer, bytes); + ci->set_offset(ci->curpos); + return retval; +} + +/* this is the codec entry point */ +enum codec_status codec_main(enum codec_entry_call_reason reason) +{ + if (reason == CODEC_LOAD) { + /* Generic codec initialisation */ + ci->configure(DSP_SET_SAMPLE_DEPTH, 28); + } + + return CODEC_OK; +} + +/* this is called for each file to process */ +enum codec_status codec_run(void) +{ + WavpackContext *wpc; + char error [80]; + /* rockbox: comment 'set but unused' variables + int bps; + */ + int nchans, sr_100; + intptr_t param; + + if (codec_init()) + return CODEC_ERROR; + + ci->seek_buffer (ci->id3->offset); + + /* Create a decoder instance */ + wpc = WavpackOpenFileInput (read_callback, error); + + if (!wpc) + return CODEC_ERROR; + + ci->configure(DSP_SWITCH_FREQUENCY, WavpackGetSampleRate (wpc)); + codec_set_replaygain(ci->id3); + /* bps = WavpackGetBytesPerSample (wpc); */ + nchans = WavpackGetReducedChannels (wpc); + ci->configure(DSP_SET_STEREO_MODE, nchans == 2 ? STEREO_INTERLEAVED : STEREO_MONO); + sr_100 = ci->id3->frequency / 100; + + ci->set_elapsed (WavpackGetSampleIndex (wpc) / sr_100 * 10); + + /* The main decoder loop */ + + while (1) { + int32_t nsamples; + enum codec_command_action action = ci->get_command(¶m); + + if (action == CODEC_ACTION_HALT) + break; + + if (action == CODEC_ACTION_SEEK_TIME) { + int curpos_ms = WavpackGetSampleIndex (wpc) / sr_100 * 10; + int n, d, skip; + + if (param > curpos_ms) { + n = param - curpos_ms; + d = ci->id3->length - curpos_ms; + skip = (int)((int64_t)(ci->filesize - ci->curpos) * n / d); + ci->seek_buffer (ci->curpos + skip); + } + else if (curpos_ms != 0) { + n = curpos_ms - param; + d = curpos_ms; + skip = (int)((int64_t) ci->curpos * n / d); + ci->seek_buffer (ci->curpos - skip); + } + + wpc = WavpackOpenFileInput (read_callback, error); + if (!wpc) + { + ci->seek_complete(); + break; + } + + ci->set_elapsed (WavpackGetSampleIndex (wpc) / sr_100 * 10); + ci->seek_complete(); + } + + nsamples = WavpackUnpackSamples (wpc, temp_buffer, BUFFER_SIZE / nchans); + + if (!nsamples) + break; + + ci->pcmbuf_insert (temp_buffer, NULL, nsamples); + ci->set_elapsed (WavpackGetSampleIndex (wpc) / sr_100 * 10); + } + + return CODEC_OK; +} diff --git a/lib/rbcodec/codecs/wavpack_enc.c b/lib/rbcodec/codecs/wavpack_enc.c new file mode 100644 index 0000000000..730cf0734b --- /dev/null +++ b/lib/rbcodec/codecs/wavpack_enc.c @@ -0,0 +1,467 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2006 Antonius Hellmann + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include "codeclib.h" +#include "libwavpack/wavpack.h" + +CODEC_ENC_HEADER + +/** Types **/ +typedef struct +{ + uint8_t type; /* Type of metadata */ + uint8_t word_size; /* Size of metadata in words */ +} __attribute__((packed)) WavpackMetadataHeader; + +struct riff_header +{ + uint8_t riff_id[4]; /* 00h - "RIFF" */ + uint32_t riff_size; /* 04h - sz following headers + data_size */ + /* format header */ + uint8_t format[4]; /* 08h - "WAVE" */ + uint8_t format_id[4]; /* 0Ch - "fmt " */ + uint32_t format_size; /* 10h - 16 for PCM (sz format data) */ + /* format data */ + uint16_t audio_format; /* 14h - 1=PCM */ + uint16_t num_channels; /* 16h - 1=M, 2=S, etc. */ + uint32_t sample_rate; /* 18h - HZ */ + uint32_t byte_rate; /* 1Ch - num_channels*sample_rate*bits_per_sample/8 */ + uint16_t block_align; /* 20h - num_channels*bits_per_samples/8 */ + uint16_t bits_per_sample; /* 22h - 8=8 bits, 16=16 bits, etc. */ + /* Not for audio_format=1 (PCM) */ +/* unsigned short extra_param_size; 24h - size of extra data */ +/* unsigned char *extra_params; */ + /* data header */ + uint8_t data_id[4]; /* 24h - "data" */ + uint32_t data_size; /* 28h - num_samples*num_channels*bits_per_sample/8 */ +/* unsigned char *data; 2ch - actual sound data */ +} __attribute__((packed)); + +#define RIFF_FMT_HEADER_SIZE 12 /* format -> format_size */ +#define RIFF_FMT_DATA_SIZE 16 /* audio_format -> bits_per_sample */ +#define RIFF_DATA_HEADER_SIZE 8 /* data_id -> data_size */ + +#define PCM_DEPTH_BITS 16 +#define PCM_DEPTH_BYTES 2 +#define PCM_SAMP_PER_CHUNK 5000 +#define PCM_CHUNK_SIZE (4*PCM_SAMP_PER_CHUNK) + +/** Data **/ +static int8_t input_buffer[PCM_CHUNK_SIZE*2] IBSS_ATTR; +static WavpackConfig config IBSS_ATTR; +static WavpackContext *wpc; +static int32_t data_size, input_size, input_step IBSS_ATTR; +static int32_t err IBSS_ATTR; + +static const WavpackMetadataHeader wvpk_mdh = +{ + ID_RIFF_HEADER, + sizeof (struct riff_header) / sizeof (uint16_t), +}; + +static const struct riff_header riff_header = +{ + /* "RIFF" header */ + { 'R', 'I', 'F', 'F' }, /* riff_id */ + 0, /* riff_size (*) */ + /* format header */ + { 'W', 'A', 'V', 'E' }, /* format */ + { 'f', 'm', 't', ' ' }, /* format_id */ + htole32(16), /* format_size */ + /* format data */ + htole16(1), /* audio_format */ + 0, /* num_channels (*) */ + 0, /* sample_rate (*) */ + 0, /* byte_rate (*) */ + 0, /* block_align (*) */ + htole16(PCM_DEPTH_BITS), /* bits_per_sample */ + /* data header */ + { 'd', 'a', 't', 'a' }, /* data_id */ + 0 /* data_size (*) */ + /* (*) updated during ENC_END_FILE event */ +}; + +static inline void sample_to_int32_mono(int32_t **src, int32_t **dst) +{ + int32_t t = *(*src)++; + /* endianness irrelevant */ + t = (int16_t)t + (t >> 16) + err; + err = t & 1; + *(*dst)++ = t >> 1; +} /* sample_to_int32_mono */ + +static inline void sample_to_int32_stereo(int32_t **src, int32_t **dst) +{ + int32_t t = *(*src)++; +#ifdef ROCKBOX_BIG_ENDIAN + *(*dst)++ = t >> 16, *(*dst)++ = (int16_t)t; +#else + *(*dst)++ = (int16_t)t, *(*dst)++ = t >> 16; +#endif +} /* sample_to_int32_stereo */ + +STATICIRAM void chunk_to_int32(int32_t *src) ICODE_ATTR; +STATICIRAM void chunk_to_int32(int32_t *src) +{ + int32_t *src_end, *dst; +#ifdef USE_IRAM + /* copy to IRAM before converting data */ + dst = (int32_t *)input_buffer + PCM_SAMP_PER_CHUNK; + src_end = dst + PCM_SAMP_PER_CHUNK; + + memcpy(dst, src, PCM_CHUNK_SIZE); + + src = dst; +#else + src_end = src + PCM_SAMP_PER_CHUNK; +#endif + + dst = (int32_t *)input_buffer; + + if (config.num_channels == 1) + { + /* + * |llllllllllllllll|rrrrrrrrrrrrrrrr| => + * |mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm| + */ + do + { + /* read 10 longs and write 10 longs */ + sample_to_int32_mono(&src, &dst); + sample_to_int32_mono(&src, &dst); + sample_to_int32_mono(&src, &dst); + sample_to_int32_mono(&src, &dst); + sample_to_int32_mono(&src, &dst); + sample_to_int32_mono(&src, &dst); + sample_to_int32_mono(&src, &dst); + sample_to_int32_mono(&src, &dst); + sample_to_int32_mono(&src, &dst); + sample_to_int32_mono(&src, &dst); + } + while(src < src_end); + + return; + } + else + { + /* + * |llllllllllllllll|rrrrrrrrrrrrrrrr| => + * |llllllllllllllllllllllllllllllll|rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr| + */ + do + { + /* read 10 longs and write 20 longs */ + sample_to_int32_stereo(&src, &dst); + sample_to_int32_stereo(&src, &dst); + sample_to_int32_stereo(&src, &dst); + sample_to_int32_stereo(&src, &dst); + sample_to_int32_stereo(&src, &dst); + sample_to_int32_stereo(&src, &dst); + sample_to_int32_stereo(&src, &dst); + sample_to_int32_stereo(&src, &dst); + sample_to_int32_stereo(&src, &dst); + sample_to_int32_stereo(&src, &dst); + } + while (src < src_end); + + return; + } +} /* chunk_to_int32 */ + +/* called very often - inline */ +static inline bool is_file_data_ok(struct enc_file_event_data *data) ICODE_ATTR; +static inline bool is_file_data_ok(struct enc_file_event_data *data) +{ + return data->rec_file >= 0 && (long)data->chunk->flags >= 0; +} /* is_file_data_ok */ + +/* called very often - inline */ +static inline bool on_write_chunk(struct enc_file_event_data *data) ICODE_ATTR; +static inline bool on_write_chunk(struct enc_file_event_data *data) +{ + if (!is_file_data_ok(data)) + return false; + + if (data->chunk->enc_data == NULL) + { +#ifdef ROCKBOX_HAS_LOGF + ci->logf("wvpk enc: NULL data"); +#endif + return true; + } + + /* update timestamp (block_index) */ + ((WavpackHeader *)data->chunk->enc_data)->block_index = + htole32(data->num_pcm_samples); + + if (ci->write(data->rec_file, data->chunk->enc_data, + data->chunk->enc_size) != (ssize_t)data->chunk->enc_size) + return false; + + data->num_pcm_samples += data->chunk->num_pcm; + return true; +} /* on_write_chunk */ + +static bool on_start_file(struct enc_file_event_data *data) +{ + if ((data->chunk->flags & CHUNKF_ERROR) || *data->filename == '\0') + return false; + + data->rec_file = ci->open(data->filename, O_RDWR|O_CREAT|O_TRUNC, 0666); + + if (data->rec_file < 0) + return false; + + /* reset sample count */ + data->num_pcm_samples = 0; + + /* write template headers */ + if (ci->write(data->rec_file, &wvpk_mdh, sizeof (wvpk_mdh)) + != sizeof (wvpk_mdh) || + ci->write(data->rec_file, &riff_header, sizeof (riff_header)) + != sizeof (riff_header)) + { + return false; + } + + data->new_enc_size += sizeof(wvpk_mdh) + sizeof(riff_header); + return true; +} /* on_start_file */ + +static bool on_end_file(struct enc_file_event_data *data) +{ + struct + { + WavpackMetadataHeader wpmdh; + struct riff_header rhdr; + WavpackHeader wph; + } __attribute__ ((packed)) h; + + uint32_t data_size; + + if (data->rec_file < 0) + return false; /* file already closed, nothing more we can do */ + + /* always _try_ to write the file header, even on error */ + + /* read template headers at start */ + if (ci->lseek(data->rec_file, 0, SEEK_SET) != 0 || + ci->read(data->rec_file, &h, sizeof (h)) != sizeof (h)) + return false; + + data_size = data->num_pcm_samples*config.num_channels*PCM_DEPTH_BYTES; + + /** "RIFF" header **/ + h.rhdr.riff_size = htole32(RIFF_FMT_HEADER_SIZE + + RIFF_FMT_DATA_SIZE + RIFF_DATA_HEADER_SIZE + data_size); + + /* format data */ + h.rhdr.num_channels = htole16(config.num_channels); + h.rhdr.sample_rate = htole32(config.sample_rate); + h.rhdr.byte_rate = htole32(config.sample_rate*config.num_channels* + PCM_DEPTH_BYTES); + h.rhdr.block_align = htole16(config.num_channels*PCM_DEPTH_BYTES); + + /* data header */ + h.rhdr.data_size = htole32(data_size); + + /** Wavpack header **/ + h.wph.ckSize = htole32(letoh32(h.wph.ckSize) + sizeof (h.wpmdh) + + sizeof (h.rhdr)); + h.wph.total_samples = htole32(data->num_pcm_samples); + + /* MDH|RIFF|WVPK => WVPK|MDH|RIFF */ + if (ci->lseek(data->rec_file, 0, SEEK_SET) + != 0 || + ci->write(data->rec_file, &h.wph, sizeof (h.wph)) + != sizeof (h.wph) || + ci->write(data->rec_file, &h.wpmdh, sizeof (h.wpmdh)) + != sizeof (h.wpmdh) || + ci->write(data->rec_file, &h.rhdr, sizeof (h.rhdr)) + != sizeof (h.rhdr) || + ci->close(data->rec_file) != 0 ) + { + return false; + } + + data->rec_file = -1; + + return true; +} /* on_end_file */ + +STATICIRAM void enc_events_callback(enum enc_events event, void *data) + ICODE_ATTR; +STATICIRAM void enc_events_callback(enum enc_events event, void *data) +{ + switch (event) + { + case ENC_WRITE_CHUNK: + if (on_write_chunk((struct enc_file_event_data *)data)) + return; + + break; + + case ENC_START_FILE: + /* write metadata header and RIFF header */ + if (on_start_file((struct enc_file_event_data *)data)) + return; + + break; + + case ENC_END_FILE: + if (on_end_file((struct enc_file_event_data *)data)) + return; + + break; + + default: + return; + } + + /* Something failed above. Signal error back to core. */ + ((struct enc_file_event_data *)data)->chunk->flags |= CHUNKF_ERROR; +} /* enc_events_callback */ + +static bool init_encoder(void) +{ + struct enc_inputs inputs; + struct enc_parameters params; + + codec_init(); + + if (ci->enc_get_inputs == NULL || + ci->enc_set_parameters == NULL || + ci->enc_get_chunk == NULL || + ci->enc_finish_chunk == NULL || + ci->enc_get_pcm_data == NULL || + ci->enc_unget_pcm_data == NULL ) + return false; + + ci->enc_get_inputs(&inputs); + + if (inputs.config->afmt != AFMT_WAVPACK) + return false; + + memset(&config, 0, sizeof (config)); + config.bits_per_sample = PCM_DEPTH_BITS; + config.bytes_per_sample = PCM_DEPTH_BYTES; + config.sample_rate = inputs.sample_rate; + config.num_channels = inputs.num_channels; + + wpc = WavpackOpenFileOutput (); + + if (!WavpackSetConfiguration(wpc, &config, -1)) + return false; + + err = 0; + + /* configure the buffer system */ + params.afmt = AFMT_WAVPACK; + input_size = PCM_CHUNK_SIZE*inputs.num_channels / 2; + data_size = 105*input_size / 100; + input_size *= 2; + input_step = input_size / 4; + params.chunk_size = data_size; + params.enc_sample_rate = inputs.sample_rate; + params.reserve_bytes = 0; + params.events_callback = enc_events_callback; + + ci->enc_set_parameters(¶ms); + + return true; +} /* init_encoder */ + +/* this is the codec entry point */ +enum codec_status codec_main(enum codec_entry_call_reason reason) +{ + if (reason == CODEC_LOAD) { + /* initialize params and config */ + if (!init_encoder()) + return CODEC_ERROR; + } + else if (reason == CODEC_UNLOAD) { + /* reset parameters to initial state */ + ci->enc_set_parameters(NULL); + } + + return CODEC_OK; +} + +/* this is called for each file to process */ +enum codec_status codec_run(void) +{ + /* main encoding loop */ + while(ci->get_command(NULL) != CODEC_ACTION_HALT) + { + uint8_t *src = (uint8_t *)ci->enc_get_pcm_data(PCM_CHUNK_SIZE); + struct enc_chunk_hdr *chunk; + bool abort_chunk; + uint8_t *dst; + uint8_t *src_end; + + if(src == NULL) + continue; + + chunk = ci->enc_get_chunk(); + + /* reset counts and pointer */ + chunk->enc_size = 0; + chunk->num_pcm = 0; + chunk->enc_data = NULL; + + dst = ENC_CHUNK_SKIP_HDR(dst, chunk); + + WavpackStartBlock(wpc, dst, dst + data_size); + + chunk_to_int32((uint32_t*)src); + src = input_buffer; + src_end = src + input_size; + + /* encode chunk in four steps yielding between each */ + do + { + abort_chunk = true; + if (WavpackPackSamples(wpc, (int32_t *)src, + PCM_SAMP_PER_CHUNK/4)) + { + chunk->num_pcm += PCM_SAMP_PER_CHUNK/4; + ci->yield(); + /* could've been stopped in some way */ + abort_chunk = chunk->flags & CHUNKF_ABORT; + } + + src += input_step; + } + while (!abort_chunk && src < src_end); + + if (!abort_chunk) + { + chunk->enc_data = dst; + if (chunk->num_pcm < PCM_SAMP_PER_CHUNK) + ci->enc_unget_pcm_data(PCM_CHUNK_SIZE - chunk->num_pcm*4); + /* finish the chunk and store chunk size info */ + chunk->enc_size = WavpackFinishBlock(wpc); + ci->enc_finish_chunk(); + } + } + + return CODEC_OK; +} diff --git a/lib/rbcodec/codecs/wma.c b/lib/rbcodec/codecs/wma.c new file mode 100755 index 0000000000..f9501ffad3 --- /dev/null +++ b/lib/rbcodec/codecs/wma.c @@ -0,0 +1,196 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2007 Dave Chapman + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include "codeclib.h" +#include "libasf/asf.h" +#include "libwma/wmadec.h" + +CODEC_HEADER + +/* NOTE: WMADecodeContext is 120152 bytes (on x86) */ +static WMADecodeContext wmadec; + +/* this is the codec entry point */ +enum codec_status codec_main(enum codec_entry_call_reason reason) +{ + if (reason == CODEC_LOAD) { + /* Generic codec initialisation */ + ci->configure(DSP_SET_SAMPLE_DEPTH, 29); + } + + return CODEC_OK; +} + +/* this is called for each file to process */ +enum codec_status codec_run(void) +{ + uint32_t elapsedtime; + asf_waveformatex_t wfx; + size_t resume_offset; + int i; + int wmares = 0; + int res = 0; + uint8_t* audiobuf; + int audiobufsize; + int packetlength = 0; + int errcount = 0; + intptr_t param; + + /* Remember the resume position - when the codec is opened, the + playback engine will reset it. */ + resume_offset = ci->id3->offset; + +restart_track: + + /* Proper reset of the decoder context. */ + memset(&wmadec, 0, sizeof(wmadec)); + + if (codec_init()) { + LOGF("WMA: Error initialising codec\n"); + return CODEC_ERROR; + } + + /* Copy the format metadata we've stored in the id3 TOC field. This + saves us from parsing it again here. */ + memcpy(&wfx, ci->id3->toc, sizeof(wfx)); + + ci->seek_buffer(ci->id3->first_frame_offset); + if (wma_decode_init(&wmadec,&wfx) < 0) { + LOGF("WMA: Unsupported or corrupt file\n"); + return CODEC_ERROR; + } + + if (resume_offset > ci->id3->first_frame_offset) + { + /* Get start of current packet */ + int packet_offset = (resume_offset - ci->id3->first_frame_offset) + % wfx.packet_size; + ci->seek_buffer(resume_offset - packet_offset); + elapsedtime = asf_get_timestamp(&i); + } + else + { + /* Now advance the file position to the first frame */ + ci->seek_buffer(ci->id3->first_frame_offset); + elapsedtime = 0; + } + + ci->set_elapsed(elapsedtime); + + resume_offset = 0; + ci->configure(DSP_SWITCH_FREQUENCY, wfx.rate); + ci->configure(DSP_SET_STEREO_MODE, wfx.channels == 1 ? + STEREO_MONO : STEREO_NONINTERLEAVED); + codec_set_replaygain(ci->id3); + + /* The main decoding loop */ + while (res >= 0) + { + enum codec_command_action action = ci->get_command(¶m); + + if (action == CODEC_ACTION_HALT) + break; + + /* Deal with any pending seek requests */ + if (action == CODEC_ACTION_SEEK_TIME) { + + /*flush the wma decoder state*/ + wmadec.last_superframe_len = 0; + wmadec.last_bitoffset = 0; + + /*zero the frame out buffer so we don't overlap with a + stale samples*/ + memset((*(wmadec.frame_out)), 0, + sizeof(fixed32) * MAX_CHANNELS * BLOCK_MAX_SIZE * 2); + + if (param == 0) { + ci->set_elapsed(0); + ci->seek_complete(); + goto restart_track; /* Pretend you never saw this... */ + } + + elapsedtime = asf_seek(param, &wfx); + if (elapsedtime < 1){ + ci->set_elapsed(0); + ci->seek_complete(); + break; + } + /*DEBUGF("Seek returned %d\n", (int)elapsedtime);*/ + + ci->set_elapsed(elapsedtime); + ci->seek_complete(); + } + errcount = 0; +new_packet: + res = asf_read_packet(&audiobuf, &audiobufsize, &packetlength, &wfx); + + if (res < 0) { + /* We'll try to recover from a parse error a certain number of + * times. If we succeed, the error counter will be reset. + */ + + if (res == ASF_ERROR_EOF) { + /* File ended - not an error */ + break; + } + + errcount++; + DEBUGF("read_packet error %d, errcount %d\n",wmares, errcount); + if (errcount > 5) { + return CODEC_ERROR; + } else { + ci->advance_buffer(packetlength); + goto new_packet; + } + } else if (res > 0) { + wma_decode_superframe_init(&wmadec, audiobuf, audiobufsize); + + for (i=0; i < wmadec.nb_frames; i++) + { + wmares = wma_decode_superframe_frame(&wmadec, + audiobuf, audiobufsize); + + ci->yield (); + + if (wmares < 0) { + /* Do the above, but for errors in decode. */ + errcount++; + DEBUGF("WMA decode error %d, errcount %d\n",wmares, errcount); + if (errcount > 5) { + return CODEC_ERROR; + } else { + ci->advance_buffer(packetlength); + goto new_packet; + } + } else if (wmares > 0) { + ci->pcmbuf_insert((*wmadec.frame_out)[0], (*wmadec.frame_out)[1], wmares); + elapsedtime += (wmares*10)/(wfx.rate/100); + ci->set_elapsed(elapsedtime); + } + } + } + + ci->advance_buffer(packetlength); + } + + /*LOGF("WMA: Decoded %ld samples\n",elapsedtime*wfx.rate/1000);*/ + return CODEC_OK; +} diff --git a/lib/rbcodec/codecs/wmapro.c b/lib/rbcodec/codecs/wmapro.c new file mode 100644 index 0000000000..bab3b5a027 --- /dev/null +++ b/lib/rbcodec/codecs/wmapro.c @@ -0,0 +1,152 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2010 Mohamed Tarek + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include "codeclib.h" +#include "libasf/asf.h" +#include "libwmapro/wmaprodec.h" + +CODEC_HEADER + +static int32_t *dec[2]; /* pointers to the output buffers in WMAProDecodeCtx in + wmaprodec.c */ + + +/* this is the codec entry point */ +enum codec_status codec_main(enum codec_entry_call_reason reason) +{ + if (reason == CODEC_LOAD) { + /* Generic codec initialisation */ + ci->configure(DSP_SET_SAMPLE_DEPTH, WMAPRO_DSP_SAMPLE_DEPTH); + } + + return CODEC_OK; +} + +/* this is called for each file to process */ +enum codec_status codec_run(void) +{ + uint32_t elapsedtime; + asf_waveformatex_t wfx; /* Holds the stream properties */ + int res; /* Return values from asf_read_packet() and decode_packet() */ + uint8_t* audiobuf; /* Pointer to the payload of one wma pro packet */ + int audiobufsize; /* Payload size */ + int packetlength = 0; /* Logical packet size (minus the header size) */ + int outlen = 0; /* Number of bytes written to the output buffer */ + int pktcnt = 0; /* Count of the packets played */ + uint8_t *data; /* Pointer to decoder input buffer */ + int size; /* Size of the input frame to the decoder */ + intptr_t param; + +restart_track: + if (codec_init()) { + LOGF("(WMA PRO) Error: Error initialising codec\n"); + return CODEC_ERROR; + } + + /* Copy the format metadata we've stored in the id3 TOC field. This + saves us from parsing it again here. */ + memcpy(&wfx, ci->id3->toc, sizeof(wfx)); + + ci->configure(DSP_SWITCH_FREQUENCY, wfx.rate); + ci->configure(DSP_SET_STEREO_MODE, wfx.channels == 1 ? + STEREO_MONO : STEREO_NONINTERLEAVED); + codec_set_replaygain(ci->id3); + + if (decode_init(&wfx) < 0) { + LOGF("(WMA PRO) Error: Unsupported or corrupt file\n"); + return CODEC_ERROR; + } + + /* Now advance the file position to the first frame */ + ci->seek_buffer(ci->id3->first_frame_offset); + + elapsedtime = 0; + ci->set_elapsed(0); + + /* The main decoding loop */ + + while (pktcnt < wfx.numpackets) + { + enum codec_command_action action = ci->get_command(¶m); + + if (action == CODEC_ACTION_HALT) + break; + + /* Deal with any pending seek requests */ + if (action == CODEC_ACTION_SEEK_TIME) { + if (param == 0) { + ci->set_elapsed(0); + ci->seek_complete(); + goto restart_track; /* Pretend you never saw this... */ + } + + elapsedtime = asf_seek(param, &wfx); + if (elapsedtime < 1){ + ci->set_elapsed(0); + ci->seek_complete(); + break; + } + + ci->set_elapsed(elapsedtime); + ci->seek_complete(); + } + + res = asf_read_packet(&audiobuf, &audiobufsize, &packetlength, &wfx); + + if (res < 0) { + LOGF("(WMA PRO) Warning: asf_read_packet returned %d", res); + return CODEC_ERROR; + } else { + data = audiobuf; + size = audiobufsize; + pktcnt++; + + /* We now loop on the packet, decoding and outputting the subframes + * one-by-one. For more information about how wma pro structures its + * audio frames, see libwmapro/wmaprodec.c */ + while(size > 0) + { + res = decode_packet(&wfx, dec, &outlen, data, size); + if(res < 0) { + LOGF("(WMA PRO) Error: decode_packet returned %d", res); + return CODEC_ERROR; + } + data += res; + size -= res; + if(outlen) { + ci->yield (); + outlen /= (wfx.channels); + ci->pcmbuf_insert(dec[0], dec[1], outlen ); + elapsedtime += outlen*10/(wfx.rate/100); + ci->set_elapsed(elapsedtime); + ci->yield (); + } + } + + } + + /* Advance to the next logical packet */ + ci->advance_buffer(packetlength); + } + + return CODEC_OK; +} + diff --git a/lib/rbcodec/codecs/wmavoice.c b/lib/rbcodec/codecs/wmavoice.c new file mode 100644 index 0000000000..9cf5a49f1a --- /dev/null +++ b/lib/rbcodec/codecs/wmavoice.c @@ -0,0 +1,195 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2010 Mohamed Tarek + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include "codeclib.h" +#include "libasf/asf.h" +#include "libwmavoice/wmavoice.h" + +CODEC_HEADER + +static AVCodecContext avctx; +static AVPacket avpkt; + +#define MAX_FRAMES 3 /*maximum number of frames per superframe*/ +#define MAX_FRAMESIZE 160 /* maximum number of samples per frame */ +#define BUFSIZE MAX_FRAMES*MAX_FRAMESIZE +static int32_t decoded[BUFSIZE] IBSS_ATTR; + + +/* This function initialises AVCodecContext with the data needed for the wmapro + * decoder to work. The required data is taken from asf_waveformatex_t because that's + * what the rockbox asf metadata parser fill/work with. In the future, when the + * codec is being optimised for on-target playback this function should not be needed. */ +static void init_codec_ctx(AVCodecContext *avctx, asf_waveformatex_t *wfx) +{ + /* Copy the extra-data */ + avctx->extradata_size = wfx->datalen; + avctx->extradata = (uint8_t *)malloc(wfx->datalen*sizeof(uint8_t)); + memcpy(avctx->extradata, wfx->data, wfx->datalen*sizeof(uint8_t)); + + avctx->block_align = wfx->blockalign; + avctx->sample_rate = wfx->rate; + avctx->channels = wfx->channels; + +} + +/* this is the codec entry point */ +enum codec_status codec_main(enum codec_entry_call_reason reason) +{ + if (reason == CODEC_LOAD) { + /* Generic codec initialisation */ + ci->configure(DSP_SET_SAMPLE_DEPTH, 31); + } + + return CODEC_OK; +} + +/* this is called for each file to process */ +enum codec_status codec_run(void) +{ + uint32_t elapsedtime; + asf_waveformatex_t wfx; /* Holds the stream properties */ + size_t resume_offset; + int res; /* Return values from asf_read_packet() and decode_packet() */ + uint8_t* audiobuf; /* Pointer to the payload of one wma pro packet */ + int audiobufsize; /* Payload size */ + int packetlength = 0; /* Logical packet size (minus the header size) */ + int outlen = 0; /* Number of bytes written to the output buffer */ + int pktcnt = 0; /* Count of the packets played */ + intptr_t param; + + /* Remember the resume position */ + resume_offset = ci->id3->offset; +restart_track: + if (codec_init()) { + LOGF("(WMA Voice) Error: Error initialising codec\n"); + return CODEC_ERROR; + } + + /* Copy the format metadata we've stored in the id3 TOC field. This + saves us from parsing it again here. */ + memcpy(&wfx, ci->id3->toc, sizeof(wfx)); + memset(&avctx, 0, sizeof(AVCodecContext)); + memset(&avpkt, 0, sizeof(AVPacket)); + + ci->configure(DSP_SWITCH_FREQUENCY, wfx.rate); + ci->configure(DSP_SET_STEREO_MODE, wfx.channels == 1 ? + STEREO_MONO : STEREO_INTERLEAVED); + codec_set_replaygain(ci->id3); + + ci->seek_buffer(0); + + /* Initialise the AVCodecContext */ + init_codec_ctx(&avctx, &wfx); + + if (wmavoice_decode_init(&avctx) < 0) { + LOGF("(WMA Voice) Error: Unsupported or corrupt file\n"); + return CODEC_ERROR; + } + + /* Now advance the file position to the first frame */ + ci->seek_buffer(ci->id3->first_frame_offset); + + elapsedtime = 0; + ci->set_elapsed(0); + + resume_offset = 0; + + /* The main decoding loop */ + + while (pktcnt < wfx.numpackets) + { + enum codec_command_action action = ci->get_command(¶m); + + if (action == CODEC_ACTION_HALT) + break; + + /* Deal with any pending seek requests */ + if (action == CODEC_ACTION_SEEK_TIME) { + ci->set_elapsed(param); + + if (param == 0) { + ci->set_elapsed(0); + ci->seek_complete(); + goto restart_track; /* Pretend you never saw this... */ + } + + elapsedtime = asf_seek(param, &wfx); + if (elapsedtime < 1){ + ci->set_elapsed(0); + ci->seek_complete(); + goto next_track; + } + + ci->set_elapsed(elapsedtime); + ci->seek_complete(); + } + +new_packet: + res = asf_read_packet(&audiobuf, &audiobufsize, &packetlength, &wfx); + + if (res < 0) { + LOGF("(WMA Voice) read_packet error %d\n",res); + return CODEC_ERROR; + } else { + avpkt.data = audiobuf; + avpkt.size = audiobufsize; + pktcnt++; + + while(avpkt.size > 0) + { + /* wmavoice_decode_packet checks for the output buffer size to + avoid overflows */ + outlen = BUFSIZE*sizeof(int32_t); + + res = wmavoice_decode_packet(&avctx, decoded, &outlen, &avpkt); + if(res < 0) { + LOGF("(WMA Voice) Error: decode_packet returned %d", res); + if(res == ERROR_WMAPRO_IN_WMAVOICE){ + /* Just skip this packet */ + ci->advance_buffer(packetlength); + goto new_packet; + } + else { + return CODEC_ERROR; + } + } + avpkt.data += res; + avpkt.size -= res; + if(outlen) { + ci->yield (); + outlen /= sizeof(int32_t); + ci->pcmbuf_insert(decoded, NULL, outlen); + elapsedtime += outlen*10/(wfx.rate/100); + ci->set_elapsed(elapsedtime); + ci->yield (); + } + } + + } + + /* Advance to the next logical packet */ + ci->advance_buffer(packetlength); + } + + return CODEC_OK; +} + diff --git a/lib/rbcodec/rbcodec.make b/lib/rbcodec/rbcodec.make index cd669d22c9..3dfade1826 100644 --- a/lib/rbcodec/rbcodec.make +++ b/lib/rbcodec/rbcodec.make @@ -11,9 +11,14 @@ RBCODECLIB_SRC := $(call preprocess, $(RBCODECLIB_DIR)/SOURCES) RBCODECLIB_OBJ := $(call c2obj, $(RBCODECLIB_SRC)) RBCODECLIB := $(BUILDDIR)/lib/librbcodec.a -INCLUDES += -I$(RBCODECLIB_DIR) -I$(RBCODECLIB_DIR)/dsp -I$(RBCODECLIB_DIR)/metadata +INCLUDES += -I$(RBCODECLIB_DIR) -I$(RBCODECLIB_DIR)/codecs \ + -I$(RBCODECLIB_DIR)/dsp -I$(RBCODECLIB_DIR)/metadata OTHER_SRC += $(RBCODECLIB_SRC) CORE_LIBS += $(RBCODECLIB) $(RBCODECLIB): $(RBCODECLIB_OBJ) $(call PRINTS,AR $(@F))$(AR) rcs $@ $^ >/dev/null + +ifdef SOFTWARECODECS + include $(RBCODECLIB_DIR)/codecs/codecs.make +endif diff --git a/lib/rbcodec/test/warble.make b/lib/rbcodec/test/warble.make index 2c1fb13889..f2234c03b5 100644 --- a/lib/rbcodec/test/warble.make +++ b/lib/rbcodec/test/warble.make @@ -9,15 +9,14 @@ -RBCODEC_DIR = $(ROOTDIR)/lib/rbcodec +RBCODECLIB_DIR = $(ROOTDIR)/lib/rbcodec RBCODEC_BLD = $(BUILDDIR)/lib/rbcodec GCCOPTS += -D__PCTOOL__ $(TARGET) -DDEBUG -g -std=gnu99 `$(SDLCONFIG) --cflags` -DCODECDIR="\"$(CODECDIR)\"" SRC= $(call preprocess, $(ROOTDIR)/lib/rbcodec/test/SOURCES) -INCLUDES += -I$(ROOTDIR)/apps -I$(ROOTDIR)/apps/codecs -I$(ROOTDIR)/apps/codecs/lib \ - -I$(ROOTDIR)/apps/gui +INCLUDES += -I$(ROOTDIR)/apps -I$(ROOTDIR)/apps/gui INCLUDES += -I$(ROOTDIR)/firmware/export -I$(ROOTDIR)/firmware/include \ -I$(ROOTDIR)/firmware/target/hosted \ -I$(ROOTDIR)/firmware/target/hosted/sdl diff --git a/rbutil/rbutilqt/INSTALL b/rbutil/rbutilqt/INSTALL index 9795a8ede4..2476eb2902 100644 --- a/rbutil/rbutilqt/INSTALL +++ b/rbutil/rbutilqt/INSTALL @@ -23,7 +23,7 @@ Requirements: - gcc - Qt 4.5.0 or later - at least the following folders from Rockbox svn: - o apps/codecs/libspeex + o lib/rbcodec/codecs/libspeex o rbutil/ o tools/ - libusb (Linux only) diff --git a/rbutil/rbutilqt/rbutilqt.qrc b/rbutil/rbutilqt/rbutilqt.qrc index e7eff5212f..2dd317032e 100644 --- a/rbutil/rbutilqt/rbutilqt.qrc +++ b/rbutil/rbutilqt/rbutilqt.qrc @@ -2,7 +2,7 @@ ../../docs/CREDITS ../../docs/gpl-2.0.html - ../../apps/codecs/libspeex/COPYING + ../../lib/rbcodec/codecs/libspeex/COPYING ../../tools/VOICE_PAUSE.wav diff --git a/tools/buildzip.pl b/tools/buildzip.pl index 2aa990ac7d..82074016f3 100755 --- a/tools/buildzip.pl +++ b/tools/buildzip.pl @@ -486,7 +486,7 @@ STOP # Android has codecs installed as native libraries so they are not needed # in the zip. if ($modelname !~ /android/) { - find(find_copyfile(qr/.*\.codec/, abs_path("$temp_dir/codecs/")), 'apps/codecs'); + find(find_copyfile(qr/.*\.codec/, abs_path("$temp_dir/codecs/")), 'lib/rbcodec/codecs'); } # remove directory again if no codec was copied diff --git a/tools/codecscan.pl b/tools/codecscan.pl index c21295d49f..4f0cbc73af 100755 --- a/tools/codecscan.pl +++ b/tools/codecscan.pl @@ -1,6 +1,6 @@ #!/usr/bin/perl -$codecs="apps/codecs"; +$codecs="lib/rbcodec/codecs"; opendir(DIR, $codecs) || die "can't opendir $some_dir: $!"; my @maps = sort grep { /\.map/ && -f "$codecs/$_" } readdir(DIR); diff --git a/tools/configure b/tools/configure index 73639cfb5c..23731530d1 100755 --- a/tools/configure +++ b/tools/configure @@ -3849,6 +3849,7 @@ export CPU=${t_cpu} export MANUFACTURER=${t_manufacturer} export OBJDIR=${pwd} export BUILDDIR=${pwd} +export RBCODEC_BLD=${pwd}/lib/rbcodec export LANGUAGE=${language} export VOICELANGUAGE=${voicelanguage} export MEMORYSIZE=${memory} diff --git a/tools/rbspeex/Makefile b/tools/rbspeex/Makefile index 247d25e1db..2435caeaf4 100644 --- a/tools/rbspeex/Makefile +++ b/tools/rbspeex/Makefile @@ -11,7 +11,7 @@ ifndef V SILENT = @ endif -SPEEXSRC = ../../apps/codecs/libspeex +SPEEXSRC = ../../lib/rbcodec/codecs/libspeex INCLUDES = -I $(SPEEXSRC) SPEEXOPTS = -DHAVE_CONFIG_H -DROCKBOX_VOICE_ENCODER diff --git a/tools/root.make b/tools/root.make index 0fc6c55403..689047e9db 100644 --- a/tools/root.make +++ b/tools/root.make @@ -101,17 +101,12 @@ else ifneq (,$(findstring database,$(APP_TYPE))) else ifneq (,$(findstring warble,$(APP_TYPE))) include $(ROOTDIR)/lib/rbcodec/test/warble.make include $(ROOTDIR)/lib/tlsf/libtlsf.make - include $(APPSDIR)/codecs/codecs.make include $(ROOTDIR)/lib/rbcodec/rbcodec.make else include $(APPSDIR)/apps.make include $(ROOTDIR)/lib/rbcodec/rbcodec.make include $(APPSDIR)/lang/lang.make - ifdef SOFTWARECODECS - include $(APPSDIR)/codecs/codecs.make - endif - ifdef ENABLEDPLUGINS include $(APPSDIR)/plugins/bitmaps/pluginbitmaps.make include $(APPSDIR)/plugins/plugins.make @@ -206,7 +201,7 @@ $(LINKROM): $(ROMLDS) $(BUILDDIR)/rockbox.elf : $$(OBJ) $(FIRMLIB) $(VOICESPEEXLIB) $(CORE_LIBS) $$(LINKRAM) $(call PRINTS,LD $(@F))$(CC) $(GCCOPTS) -Os -nostdlib -o $@ $(OBJ) \ -L$(BUILDDIR)/firmware -lfirmware \ - -L$(BUILDDIR)/apps/codecs $(call a2lnk, $(VOICESPEEXLIB)) \ + -L$(RBCODEC_BLD)/codecs $(call a2lnk, $(VOICESPEEXLIB)) \ -L$(BUILDDIR)/lib $(call a2lnk, $(CORE_LIBS)) \ -lgcc $(BOOTBOXLDOPTS) $(GLOBAL_LDOPTS) \ -T$(LINKRAM) -Wl,-Map,$(BUILDDIR)/rockbox.map @@ -214,7 +209,7 @@ $(BUILDDIR)/rockbox.elf : $$(OBJ) $(FIRMLIB) $(VOICESPEEXLIB) $(CORE_LIBS) $$(LI $(BUILDDIR)/rombox.elf : $$(OBJ) $(FIRMLIB) $(VOICESPEEXLIB) $(CORE_LIBS) $$(LINKROM) $(call PRINTS,LD $(@F))$(CC) $(GCCOPTS) -Os -nostdlib -o $@ $(OBJ) \ -L$(BUILDDIR)/firmware -lfirmware \ - -L$(BUILDDIR)/apps/codecs $(call a2lnk, $(VOICESPEEXLIB)) \ + -L$(RBCODEC_BLD)/codecs $(call a2lnk, $(VOICESPEEXLIB)) \ -L$(BUILDDIR)/lib $(call a2lnk, $(CORE_LIBS)) \ -lgcc $(BOOTBOXLDOPTS) $(GLOBAL_LDOPTS) \ -T$(LINKROM) -Wl,-Map,$(BUILDDIR)/rombox.map diff --git a/utils/analysis/cmp-plugins-size.py b/utils/analysis/cmp-plugins-size.py index 05c97486aa..d8f482c017 100755 --- a/utils/analysis/cmp-plugins-size.py +++ b/utils/analysis/cmp-plugins-size.py @@ -149,8 +149,8 @@ newver = rb_version(sys.argv[2]) oldplugindir = sys.argv[1] + '/apps/plugins' newplugindir = sys.argv[2] + '/apps/plugins' -oldcodecsdir = sys.argv[1] + '/apps/codecs' -newcodecsdir = sys.argv[2] + '/apps/codecs' +oldcodecsdir = sys.argv[1] + '/lib/rbcodec/codecs' +newcodecsdir = sys.argv[2] + '/lib/rbcodec/codecs' if os.path.lexists(oldplugindir) and os.path.lexists(newplugindir): compare(oldplugindir, newplugindir, oldver, newver) diff --git a/utils/analysis/find_addr.pl b/utils/analysis/find_addr.pl index dd42ef6dd8..628fb3dda8 100755 --- a/utils/analysis/find_addr.pl +++ b/utils/analysis/find_addr.pl @@ -100,12 +100,12 @@ if($lookaddr != 0) close MAKEFILE; # Generate a list of all codecs - open FINDCODECS, "find apps/codecs/ -name '*.elf' 2>&1 |" or die "Can't open pipe: $!"; + open FINDCODECS, "find lib/rbcodec/codecs/ -name '*.elf' 2>&1 |" or die "Can't open pipe: $!"; my @codecs; while() { chomp($_); - $_ =~ s/apps\/codecs\///; + $_ =~ s/lib\/rbcodec\/codecs\///; push(@codecs, $_); } close FINDCODECS; diff --git a/utils/common/deploy-rbutil.py b/utils/common/deploy-rbutil.py index 0a68dbe805..6db45eec4c 100755 --- a/utils/common/deploy-rbutil.py +++ b/utils/common/deploy-rbutil.py @@ -26,7 +26,7 @@ deploy.svnpaths = \ "tools/ucl", "tools/rbspeex", "utils/imxtools", - "apps/codecs/libspeex", + "lib/rbcodec/codecs/libspeex", "docs/COPYING", "docs/gpl-2.0.html", "docs/logo/rockbox-clef.svg", -- cgit v1.2.3